aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/rename-qtdeclarative-symbols.sh642
-rw-r--r--doc/src/localstorage/localstorage.qdoc2
-rw-r--r--doc/src/qml/basictypes.qdoc2
-rw-r--r--doc/src/qml/c++models.qdoc10
-rw-r--r--doc/src/qml/codingconventions.qdoc20
-rw-r--r--doc/src/qml/debugging.qdoc10
-rw-r--r--doc/src/qml/dynamicobjects.qdoc32
-rw-r--r--doc/src/qml/extending-tutorial.qdoc30
-rw-r--r--doc/src/qml/integrating.qdoc18
-rw-r--r--doc/src/qml/javascriptblocks.qdoc40
-rw-r--r--doc/src/qml/modules.qdoc44
-rw-r--r--doc/src/qml/network.qdoc10
-rw-r--r--doc/src/qml/propertybinding.qdoc54
-rw-r--r--doc/src/qml/qmlcomponents.qdoc40
-rw-r--r--doc/src/qml/qmldocument.qdoc10
-rw-r--r--doc/src/qml/qmlengine.qdoc136
-rw-r--r--doc/src/qml/qmlevents.qdoc16
-rw-r--r--doc/src/qml/qmlintro.qdoc2
-rw-r--r--doc/src/qml/qmlplugins.qdoc12
-rw-r--r--doc/src/qml/qmlruntime.qdoc38
-rw-r--r--doc/src/qml/qmlsyntax.qdoc2
-rw-r--r--doc/src/qml/qmltypes.qdoc10
-rw-r--r--doc/src/qml/qmlviewer.qdoc2
-rw-r--r--doc/src/qml/qtbinding.qdoc166
-rw-r--r--doc/src/qml/qtdeclarative.qdoc48
-rw-r--r--doc/src/qml/qtprogrammers.qdoc14
-rw-r--r--doc/src/qtquick2/animation.qdoc28
-rw-r--r--doc/src/qtquick2/focus.qdoc22
-rw-r--r--doc/src/qtquick2/modelview.qdoc30
-rw-r--r--doc/src/qtquick2/mouseevents.qdoc6
-rw-r--r--doc/src/qtquick2/positioners.qdoc8
-rw-r--r--doc/src/qtquick2/qmltexthandling.qdoc4
-rw-r--r--doc/src/qtquick2/qtquick-intro.qdoc10
-rw-r--r--doc/src/qtquick2/qtquick2.qdoc2
-rw-r--r--doc/src/qtquick2/righttoleft.qdoc12
-rw-r--r--doc/src/qtquick2/states.qdoc6
-rw-r--r--doc/src/qtquick2/writingcomponents.qdoc34
-rw-r--r--doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp124
-rw-r--r--doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp60
-rw-r--r--doc/src/snippets/declarative/qtbinding/context/main.cpp56
-rw-r--r--doc/src/snippets/declarative/qtbinding/enums/imageviewer.h68
-rw-r--r--doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp59
-rw-r--r--doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp63
-rw-r--r--doc/src/snippets/declarative/qtbinding/loading/main.cpp90
-rw-r--r--doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h56
-rw-r--r--doc/src/snippets/declarative/qtbinding/newelements/main.cpp62
-rw-r--r--doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp61
-rw-r--r--doc/src/snippets/declarative/qtbinding/resources/main.cpp57
-rw-r--r--doc/src/snippets/declarative/qtbinding/resources/resources.pro4
-rw-r--r--doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h64
-rw-r--r--doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp81
-rw-r--r--doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp59
-rw-r--r--doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp67
-rw-r--r--doc/src/snippets/declarative/text/onLinkActivated.qml54
-rw-r--r--doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp62
-rw-r--r--doc/src/snippets/qml/Button.qml (renamed from doc/src/snippets/declarative/Button.qml)0
-rw-r--r--doc/src/snippets/qml/SelfDestroyingRect.qml (renamed from doc/src/snippets/declarative/SelfDestroyingRect.qml)0
-rw-r--r--doc/src/snippets/qml/Sprite.qml (renamed from doc/src/snippets/declarative/Sprite.qml)0
-rw-r--r--doc/src/snippets/qml/anchoranimation.qml (renamed from doc/src/snippets/declarative/anchoranimation.qml)0
-rw-r--r--doc/src/snippets/qml/anchorchanges.qml (renamed from doc/src/snippets/declarative/anchorchanges.qml)0
-rw-r--r--doc/src/snippets/qml/animatedimage.qml (renamed from doc/src/snippets/declarative/animatedimage.qml)0
-rw-r--r--doc/src/snippets/qml/animation.qml (renamed from doc/src/snippets/declarative/animation.qml)0
-rw-r--r--doc/src/snippets/qml/application.qml (renamed from doc/src/snippets/declarative/application.qml)0
-rw-r--r--doc/src/snippets/qml/behavior.qml (renamed from doc/src/snippets/declarative/behavior.qml)0
-rw-r--r--doc/src/snippets/qml/borderimage/borderimage-scaled.qml (renamed from doc/src/snippets/declarative/borderimage/borderimage-scaled.qml)0
-rw-r--r--doc/src/snippets/qml/borderimage/borderimage-tiled.qml (renamed from doc/src/snippets/declarative/borderimage/borderimage-tiled.qml)0
-rw-r--r--doc/src/snippets/qml/borderimage/normal-image.qml (renamed from doc/src/snippets/declarative/borderimage/normal-image.qml)0
-rw-r--r--doc/src/snippets/qml/codingconventions/dotproperties.qml (renamed from doc/src/snippets/declarative/codingconventions/dotproperties.qml)0
-rw-r--r--doc/src/snippets/qml/codingconventions/javascript-imports.qml (renamed from doc/src/snippets/declarative/codingconventions/javascript-imports.qml)0
-rw-r--r--doc/src/snippets/qml/codingconventions/javascript.qml (renamed from doc/src/snippets/declarative/codingconventions/javascript.qml)0
-rw-r--r--doc/src/snippets/qml/codingconventions/lists.qml (renamed from doc/src/snippets/declarative/codingconventions/lists.qml)0
-rw-r--r--doc/src/snippets/qml/codingconventions/myscript.js (renamed from doc/src/snippets/declarative/codingconventions/myscript.js)0
-rw-r--r--doc/src/snippets/qml/codingconventions/photo.qml (renamed from doc/src/snippets/declarative/codingconventions/photo.qml)0
-rw-r--r--doc/src/snippets/qml/codingconventions/private.qml (renamed from doc/src/snippets/declarative/codingconventions/private.qml)0
-rw-r--r--doc/src/snippets/qml/coloranimation.qml (renamed from doc/src/snippets/declarative/coloranimation.qml)0
-rw-r--r--doc/src/snippets/qml/colors.qml (renamed from doc/src/snippets/declarative/colors.qml)0
-rw-r--r--doc/src/snippets/qml/column/column-transitions.qml (renamed from doc/src/snippets/declarative/column/column-transitions.qml)0
-rw-r--r--doc/src/snippets/qml/column/column.qml (renamed from doc/src/snippets/declarative/column/column.qml)0
-rw-r--r--doc/src/snippets/qml/column/vertical-positioner.qml (renamed from doc/src/snippets/declarative/column/vertical-positioner.qml)0
-rw-r--r--doc/src/snippets/qml/comments.qml (renamed from doc/src/snippets/declarative/comments.qml)0
-rw-r--r--doc/src/snippets/qml/component.qml (renamed from doc/src/snippets/declarative/component.qml)0
-rw-r--r--doc/src/snippets/qml/componentCreation.js (renamed from doc/src/snippets/declarative/componentCreation.js)0
-rw-r--r--doc/src/snippets/qml/createComponent-simple.qml (renamed from doc/src/snippets/declarative/createComponent-simple.qml)0
-rw-r--r--doc/src/snippets/qml/createComponent.qml (renamed from doc/src/snippets/declarative/createComponent.qml)0
-rw-r--r--doc/src/snippets/qml/createQmlObject.qml (renamed from doc/src/snippets/declarative/createQmlObject.qml)0
-rw-r--r--doc/src/snippets/qml/drag.qml (renamed from doc/src/snippets/declarative/drag.qml)0
-rw-r--r--doc/src/snippets/qml/dynamicObjects-destroy.qml (renamed from doc/src/snippets/declarative/dynamicObjects-destroy.qml)0
-rw-r--r--doc/src/snippets/qml/events.qml (renamed from doc/src/snippets/declarative/events.qml)0
-rw-r--r--doc/src/snippets/qml/flickable.qml (renamed from doc/src/snippets/declarative/flickable.qml)0
-rw-r--r--doc/src/snippets/qml/flickableScrollbar.qml (renamed from doc/src/snippets/declarative/flickableScrollbar.qml)0
-rw-r--r--doc/src/snippets/qml/flipable/flipable.qml (renamed from doc/src/snippets/declarative/flipable/flipable.qml)0
-rw-r--r--doc/src/snippets/qml/flow.qml (renamed from doc/src/snippets/declarative/flow.qml)0
-rw-r--r--doc/src/snippets/qml/focus/MyClickableWidget.qml (renamed from doc/src/snippets/declarative/focus/MyClickableWidget.qml)0
-rw-r--r--doc/src/snippets/qml/focus/MyWidget.qml (renamed from doc/src/snippets/declarative/focus/MyWidget.qml)0
-rw-r--r--doc/src/snippets/qml/focus/advancedFocus.qml (renamed from doc/src/snippets/declarative/focus/advancedFocus.qml)0
-rw-r--r--doc/src/snippets/qml/focus/basicwidget.qml (renamed from doc/src/snippets/declarative/focus/basicwidget.qml)0
-rw-r--r--doc/src/snippets/qml/focus/clickablewidget.qml (renamed from doc/src/snippets/declarative/focus/clickablewidget.qml)0
-rw-r--r--doc/src/snippets/qml/focus/myfocusscopewidget.qml (renamed from doc/src/snippets/declarative/focus/myfocusscopewidget.qml)0
-rw-r--r--doc/src/snippets/qml/focus/rectangle.qml (renamed from doc/src/snippets/declarative/focus/rectangle.qml)0
-rw-r--r--doc/src/snippets/qml/focus/widget.qml (renamed from doc/src/snippets/declarative/focus/widget.qml)0
-rw-r--r--doc/src/snippets/qml/folderlistmodel.qml (renamed from doc/src/snippets/declarative/folderlistmodel.qml)0
-rw-r--r--doc/src/snippets/qml/gradient.qml (renamed from doc/src/snippets/declarative/gradient.qml)0
-rw-r--r--doc/src/snippets/qml/grid-spacing.qml (renamed from doc/src/snippets/declarative/grid-spacing.qml)0
-rw-r--r--doc/src/snippets/qml/grid/grid-items.qml (renamed from doc/src/snippets/declarative/grid/grid-items.qml)0
-rw-r--r--doc/src/snippets/qml/grid/grid-no-spacing.qml (renamed from doc/src/snippets/declarative/grid/grid-no-spacing.qml)0
-rw-r--r--doc/src/snippets/qml/grid/grid-spacing.qml (renamed from doc/src/snippets/declarative/grid/grid-spacing.qml)0
-rw-r--r--doc/src/snippets/qml/grid/grid.qml (renamed from doc/src/snippets/declarative/grid/grid.qml)0
-rw-r--r--doc/src/snippets/qml/gridview/ContactModel.qml (renamed from doc/src/snippets/declarative/gridview/ContactModel.qml)0
-rw-r--r--doc/src/snippets/qml/gridview/gridview.qml (renamed from doc/src/snippets/declarative/gridview/gridview.qml)0
-rw-r--r--doc/src/snippets/qml/image.qml (renamed from doc/src/snippets/declarative/image.qml)0
-rw-r--r--doc/src/snippets/qml/imports/chart.qml (renamed from doc/src/snippets/declarative/imports/chart.qml)0
-rw-r--r--doc/src/snippets/qml/imports/installed-module.qml (renamed from doc/src/snippets/declarative/imports/installed-module.qml)0
-rw-r--r--doc/src/snippets/qml/imports/merged-named-imports.qml (renamed from doc/src/snippets/declarative/imports/merged-named-imports.qml)0
-rw-r--r--doc/src/snippets/qml/imports/named-imports.qml (renamed from doc/src/snippets/declarative/imports/named-imports.qml)0
-rw-r--r--doc/src/snippets/qml/imports/network-imports.qml (renamed from doc/src/snippets/declarative/imports/network-imports.qml)0
-rw-r--r--doc/src/snippets/qml/imports/qtquick-1.0.qml (renamed from doc/src/snippets/declarative/imports/qtquick-1.0.qml)0
-rw-r--r--doc/src/snippets/qml/imports/timeexample.qml (renamed from doc/src/snippets/declarative/imports/timeexample.qml)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/connectjs.qml (renamed from doc/src/snippets/declarative/integrating-javascript/connectjs.qml)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/includejs/app.qml (renamed from doc/src/snippets/declarative/integrating-javascript/includejs/app.qml)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/includejs/factorial.js (renamed from doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/includejs/script.js (renamed from doc/src/snippets/declarative/integrating-javascript/includejs/script.js)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp124
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h (renamed from doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml (renamed from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js (renamed from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml (renamed from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml (renamed from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js (renamed from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml (renamed from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml (renamed from doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml)0
-rw-r--r--doc/src/snippets/qml/integrating-javascript/script.js (renamed from doc/src/snippets/declarative/integrating-javascript/script.js)0
-rw-r--r--doc/src/snippets/qml/keynavigation.qml (renamed from doc/src/snippets/declarative/keynavigation.qml)0
-rw-r--r--doc/src/snippets/qml/keys/keys-handler.qml (renamed from doc/src/snippets/declarative/keys/keys-handler.qml)0
-rw-r--r--doc/src/snippets/qml/keys/keys-pressed.qml (renamed from doc/src/snippets/declarative/keys/keys-pressed.qml)0
-rw-r--r--doc/src/snippets/qml/layoutmirroring.qml (renamed from doc/src/snippets/declarative/layoutmirroring.qml)0
-rw-r--r--doc/src/snippets/qml/listmodel-modify.qml (renamed from doc/src/snippets/declarative/listmodel-modify.qml)0
-rw-r--r--doc/src/snippets/qml/listmodel-nested.qml (renamed from doc/src/snippets/declarative/listmodel-nested.qml)0
-rw-r--r--doc/src/snippets/qml/listmodel-simple.qml (renamed from doc/src/snippets/declarative/listmodel-simple.qml)0
-rw-r--r--doc/src/snippets/qml/listmodel.qml (renamed from doc/src/snippets/declarative/listmodel.qml)0
-rw-r--r--doc/src/snippets/qml/listview-decorations.qml (renamed from doc/src/snippets/declarative/listview-decorations.qml)0
-rw-r--r--doc/src/snippets/qml/listview-sections.qml (renamed from doc/src/snippets/declarative/listview-sections.qml)0
-rw-r--r--doc/src/snippets/qml/listview.qml (renamed from doc/src/snippets/declarative/listview.qml)0
-rw-r--r--doc/src/snippets/qml/listview/ContactModel.qml (renamed from doc/src/snippets/declarative/listview/ContactModel.qml)0
-rw-r--r--doc/src/snippets/qml/listview/listview-snippet.qml (renamed from doc/src/snippets/declarative/listview/listview-snippet.qml)0
-rw-r--r--doc/src/snippets/qml/listview/listview.qml (renamed from doc/src/snippets/declarative/listview/listview.qml)0
-rw-r--r--doc/src/snippets/qml/loader/KeyReader.qml (renamed from doc/src/snippets/declarative/loader/KeyReader.qml)0
-rw-r--r--doc/src/snippets/qml/loader/MyItem.qml (renamed from doc/src/snippets/declarative/loader/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/loader/connections.qml (renamed from doc/src/snippets/declarative/loader/connections.qml)0
-rw-r--r--doc/src/snippets/qml/loader/focus.qml (renamed from doc/src/snippets/declarative/loader/focus.qml)0
-rw-r--r--doc/src/snippets/qml/loader/simple.qml (renamed from doc/src/snippets/declarative/loader/simple.qml)0
-rw-r--r--doc/src/snippets/qml/loader/sizeitem.qml (renamed from doc/src/snippets/declarative/loader/sizeitem.qml)0
-rw-r--r--doc/src/snippets/qml/loader/sizeloader.qml (renamed from doc/src/snippets/declarative/loader/sizeloader.qml)0
-rw-r--r--doc/src/snippets/qml/models/views-models-delegates.qml (renamed from doc/src/snippets/declarative/models/views-models-delegates.qml)0
-rw-r--r--doc/src/snippets/qml/models/visual-model-and-view.qml (renamed from doc/src/snippets/declarative/models/visual-model-and-view.qml)0
-rw-r--r--doc/src/snippets/qml/mousearea/mousearea-snippet.qml (renamed from doc/src/snippets/declarative/mousearea/mousearea-snippet.qml)0
-rw-r--r--doc/src/snippets/qml/mousearea/mousearea.qml (renamed from doc/src/snippets/declarative/mousearea/mousearea.qml)0
-rw-r--r--doc/src/snippets/qml/mousearea/mouseareadragfilter.qml (renamed from doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml)0
-rw-r--r--doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml (renamed from doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml)0
-rw-r--r--doc/src/snippets/qml/numberanimation.qml (renamed from doc/src/snippets/declarative/numberanimation.qml)0
-rw-r--r--doc/src/snippets/qml/parallelanimation.qml (renamed from doc/src/snippets/declarative/parallelanimation.qml)0
-rw-r--r--doc/src/snippets/qml/parentanimation.qml (renamed from doc/src/snippets/declarative/parentanimation.qml)0
-rw-r--r--doc/src/snippets/qml/parentchange.qml (renamed from doc/src/snippets/declarative/parentchange.qml)0
-rw-r--r--doc/src/snippets/qml/path/arcdirection.qml (renamed from doc/src/snippets/declarative/path/arcdirection.qml)0
-rw-r--r--doc/src/snippets/qml/path/arcradius.qml (renamed from doc/src/snippets/declarative/path/arcradius.qml)0
-rw-r--r--doc/src/snippets/qml/path/basicarc.qml (renamed from doc/src/snippets/declarative/path/basicarc.qml)0
-rw-r--r--doc/src/snippets/qml/path/basiccurve.qml (renamed from doc/src/snippets/declarative/path/basiccurve.qml)0
-rw-r--r--doc/src/snippets/qml/path/largearc.qml (renamed from doc/src/snippets/declarative/path/largearc.qml)0
-rw-r--r--doc/src/snippets/qml/pathinterpolator.qml (renamed from doc/src/snippets/declarative/pathinterpolator.qml)0
-rw-r--r--doc/src/snippets/qml/pathview/ContactModel.qml (renamed from doc/src/snippets/declarative/pathview/ContactModel.qml)0
-rw-r--r--doc/src/snippets/qml/pathview/pathattributes.qml (renamed from doc/src/snippets/declarative/pathview/pathattributes.qml)0
-rw-r--r--doc/src/snippets/qml/pathview/pathview.qml (renamed from doc/src/snippets/declarative/pathview/pathview.qml)0
-rw-r--r--doc/src/snippets/qml/properties.qml (renamed from doc/src/snippets/declarative/properties.qml)0
-rw-r--r--doc/src/snippets/qml/propertyaction-sequential.qml (renamed from doc/src/snippets/declarative/propertyaction-sequential.qml)0
-rw-r--r--doc/src/snippets/qml/propertyaction.qml (renamed from doc/src/snippets/declarative/propertyaction.qml)0
-rw-r--r--doc/src/snippets/qml/propertyanimation.qml (renamed from doc/src/snippets/declarative/propertyanimation.qml)0
-rw-r--r--doc/src/snippets/qml/propertychanges.qml (renamed from doc/src/snippets/declarative/propertychanges.qml)0
-rw-r--r--doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml (renamed from doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml)0
-rw-r--r--doc/src/snippets/qml/qml-data-models/listelements.qml (renamed from doc/src/snippets/declarative/qml-data-models/listelements.qml)0
-rw-r--r--doc/src/snippets/qml/qml-data-models/listmodel-listview.qml (renamed from doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml)0
-rw-r--r--doc/src/snippets/qml/qml-documents/inline-component.qml (renamed from doc/src/snippets/declarative/qml-documents/inline-component.qml)0
-rw-r--r--doc/src/snippets/qml/qml-documents/inline-text-component.qml (renamed from doc/src/snippets/declarative/qml-documents/inline-text-component.qml)0
-rw-r--r--doc/src/snippets/qml/qml-documents/non-trivial.qml (renamed from doc/src/snippets/declarative/qml-documents/non-trivial.qml)0
-rw-r--r--doc/src/snippets/qml/qml-documents/qmldocuments.qml (renamed from doc/src/snippets/declarative/qml-documents/qmldocuments.qml)0
-rw-r--r--doc/src/snippets/qml/qml-intro/images/qt-logo.svg (renamed from doc/src/snippets/declarative/qml-intro/images/qt-logo.svg)0
-rw-r--r--doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h (renamed from doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h)0
-rw-r--r--doc/src/snippets/qml/qtbinding/context-advanced/connections.qml (renamed from doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/context-advanced/main.cpp60
-rw-r--r--doc/src/snippets/qml/qtbinding/context/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/context/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/context/main.cpp56
-rw-r--r--doc/src/snippets/qml/qtbinding/enums/imageviewer.h68
-rw-r--r--doc/src/snippets/qml/qtbinding/enums/standalone.qml (renamed from doc/src/snippets/declarative/qtbinding/enums/standalone.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp59
-rw-r--r--doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h (renamed from doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h)0
-rw-r--r--doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/functions-qml/main.cpp63
-rw-r--r--doc/src/snippets/qml/qtbinding/loading/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/loading/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/loading/main.cpp90
-rw-r--r--doc/src/snippets/qml/qtbinding/newelements/imageviewer.h56
-rw-r--r--doc/src/snippets/qml/qtbinding/newelements/main.cpp62
-rw-r--r--doc/src/snippets/qml/qtbinding/newelements/standalone.qml (renamed from doc/src/snippets/declarative/qtbinding/newelements/standalone.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h (renamed from doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h)0
-rw-r--r--doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/properties-qml/main.cpp61
-rw-r--r--doc/src/snippets/qml/qtbinding/resources/example.qrc (renamed from doc/src/snippets/declarative/qtbinding/resources/example.qrc)0
-rw-r--r--doc/src/snippets/qml/qtbinding/resources/main.cpp57
-rw-r--r--doc/src/snippets/qml/qtbinding/resources/main.qml (renamed from doc/src/snippets/declarative/qtbinding/resources/main.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/resources/resources.pro4
-rw-r--r--doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h64
-rw-r--r--doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp81
-rw-r--r--doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml (renamed from doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/signals-qml/main.cpp59
-rw-r--r--doc/src/snippets/qml/qtbinding/signals-qml/myclass.h (renamed from doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h)0
-rw-r--r--doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml (renamed from doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml)0
-rw-r--r--doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp67
-rw-r--r--doc/src/snippets/qml/qtobject.qml (renamed from doc/src/snippets/declarative/qtobject.qml)0
-rw-r--r--doc/src/snippets/qml/rectangle/rect-border-width.qml (renamed from doc/src/snippets/declarative/rectangle/rect-border-width.qml)0
-rw-r--r--doc/src/snippets/qml/rectangle/rectangle-colors.qml (renamed from doc/src/snippets/declarative/rectangle/rectangle-colors.qml)0
-rw-r--r--doc/src/snippets/qml/rectangle/rectangle-gradient.qml (renamed from doc/src/snippets/declarative/rectangle/rectangle-gradient.qml)0
-rw-r--r--doc/src/snippets/qml/rectangle/rectangle.qml (renamed from doc/src/snippets/declarative/rectangle/rectangle.qml)0
-rw-r--r--doc/src/snippets/qml/repeaters/repeater-grid-index.qml (renamed from doc/src/snippets/declarative/repeaters/repeater-grid-index.qml)0
-rw-r--r--doc/src/snippets/qml/repeaters/repeater.qml (renamed from doc/src/snippets/declarative/repeaters/repeater.qml)0
-rw-r--r--doc/src/snippets/qml/reusablecomponents/Button.qml (renamed from doc/src/snippets/declarative/reusablecomponents/Button.qml)0
-rw-r--r--doc/src/snippets/qml/reusablecomponents/application.qml (renamed from doc/src/snippets/declarative/reusablecomponents/application.qml)0
-rw-r--r--doc/src/snippets/qml/reusablecomponents/component.qml (renamed from doc/src/snippets/declarative/reusablecomponents/component.qml)0
-rw-r--r--doc/src/snippets/qml/reusablecomponents/focusbutton.qml (renamed from doc/src/snippets/declarative/reusablecomponents/focusbutton.qml)0
-rw-r--r--doc/src/snippets/qml/reusablecomponents/qmldir (renamed from doc/src/snippets/declarative/reusablecomponents/qmldir)0
-rw-r--r--doc/src/snippets/qml/righttoleft.qml (renamed from doc/src/snippets/declarative/righttoleft.qml)0
-rw-r--r--doc/src/snippets/qml/righttoleft/Child.qml (renamed from doc/src/snippets/declarative/righttoleft/Child.qml)0
-rw-r--r--doc/src/snippets/qml/rotation.qml (renamed from doc/src/snippets/declarative/rotation.qml)0
-rw-r--r--doc/src/snippets/qml/rotationanimation.qml (renamed from doc/src/snippets/declarative/rotationanimation.qml)0
-rw-r--r--doc/src/snippets/qml/row.qml (renamed from doc/src/snippets/declarative/row.qml)0
-rw-r--r--doc/src/snippets/qml/row/row.qml (renamed from doc/src/snippets/declarative/row/row.qml)0
-rw-r--r--doc/src/snippets/qml/script.js (renamed from doc/src/snippets/declarative/script.js)0
-rw-r--r--doc/src/snippets/qml/sequentialanimation.qml (renamed from doc/src/snippets/declarative/sequentialanimation.qml)0
-rw-r--r--doc/src/snippets/qml/smoothedanimation.qml (renamed from doc/src/snippets/declarative/smoothedanimation.qml)0
-rw-r--r--doc/src/snippets/qml/springanimation.qml (renamed from doc/src/snippets/declarative/springanimation.qml)0
-rw-r--r--doc/src/snippets/qml/state-when.qml (renamed from doc/src/snippets/declarative/state-when.qml)0
-rw-r--r--doc/src/snippets/qml/state.qml (renamed from doc/src/snippets/declarative/state.qml)0
-rw-r--r--doc/src/snippets/qml/states.qml (renamed from doc/src/snippets/declarative/states.qml)0
-rw-r--r--doc/src/snippets/qml/states/statechangescript.qml (renamed from doc/src/snippets/declarative/states/statechangescript.qml)0
-rw-r--r--doc/src/snippets/qml/systempalette.qml (renamed from doc/src/snippets/declarative/systempalette.qml)0
-rw-r--r--doc/src/snippets/qml/text/onLinkActivated.qml54
-rw-r--r--doc/src/snippets/qml/texthandling.qml (renamed from doc/src/snippets/declarative/texthandling.qml)0
-rw-r--r--doc/src/snippets/qml/transition-from-to-modified.qml (renamed from doc/src/snippets/declarative/transition-from-to-modified.qml)0
-rw-r--r--doc/src/snippets/qml/transition-from-to.qml (renamed from doc/src/snippets/declarative/transition-from-to.qml)0
-rw-r--r--doc/src/snippets/qml/transition-reversible.qml (renamed from doc/src/snippets/declarative/transition-reversible.qml)0
-rw-r--r--doc/src/snippets/qml/transition.qml (renamed from doc/src/snippets/declarative/transition.qml)0
-rw-r--r--doc/src/snippets/qml/transitions-list.qml (renamed from doc/src/snippets/declarative/transitions-list.qml)0
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml (renamed from doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml)0
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml (renamed from doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml)0
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml (renamed from doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml)0
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml (renamed from doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml)0
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml (renamed from doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml)0
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml (renamed from doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml)0
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml (renamed from doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml)0
-rw-r--r--doc/src/snippets/qml/visualdatagroup.qml (renamed from doc/src/snippets/declarative/visualdatagroup.qml)0
-rw-r--r--doc/src/snippets/qml/visualdatamodel.qml (renamed from doc/src/snippets/declarative/visualdatamodel.qml)0
-rw-r--r--doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp62
-rw-r--r--doc/src/snippets/qml/visualdatamodel_rootindex/view.qml (renamed from doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml)0
-rw-r--r--doc/src/snippets/qml/workerscript.qml (renamed from doc/src/snippets/declarative/workerscript.qml)0
-rw-r--r--doc/src/snippets/qml/xmlrole.qml (renamed from doc/src/snippets/declarative/xmlrole.qml)0
-rw-r--r--doc/src/snippets/qml/xmlrole.xml (renamed from doc/src/snippets/declarative/xmlrole.xml)0
-rw-r--r--doc/src/snippets/qtjavascript/evaluation/main.cpp2
-rw-r--r--doc/src/snippets/qtjavascript/registeringobjects/main.cpp2
-rw-r--r--doc/src/snippets/qtjavascript/registeringvalues/main.cpp2
-rw-r--r--doc/src/whatsnew.qdoc4
-rw-r--r--examples/HACKING2
-rw-r--r--examples/demos/calculator/CalculatorCore/Button.qml2
-rw-r--r--examples/demos/calculator/CalculatorCore/Display.qml2
-rw-r--r--examples/demos/calculator/calculator-desktop.qml2
-rw-r--r--examples/demos/calculator/calculator-mobile.qml2
-rw-r--r--examples/demos/calculator/calculator.pro2
-rw-r--r--examples/demos/calculator/main.cpp2
-rw-r--r--examples/demos/flickr/content/Button.qml2
-rw-r--r--examples/demos/flickr/content/GridDelegate.qml2
-rw-r--r--examples/demos/flickr/content/ImageDetails.qml2
-rw-r--r--examples/demos/flickr/content/ListDelegate.qml2
-rw-r--r--examples/demos/flickr/content/Progress.qml2
-rw-r--r--examples/demos/flickr/content/RssModel.qml2
-rw-r--r--examples/demos/flickr/content/ScrollBar.qml2
-rw-r--r--examples/demos/flickr/content/Slider.qml2
-rw-r--r--examples/demos/flickr/content/TitleBar.qml2
-rw-r--r--examples/demos/flickr/content/ToolBar.qml2
-rw-r--r--examples/demos/flickr/content/UnifiedDelegate.qml2
-rw-r--r--examples/demos/flickr/flickr-90.qml2
-rw-r--r--examples/demos/flickr/flickr.qml2
-rw-r--r--examples/demos/minehunt/MinehuntCore/Explosion.qml2
-rw-r--r--examples/demos/minehunt/MinehuntCore/Tile.qml2
-rw-r--r--examples/demos/minehunt/main.cpp4
-rw-r--r--examples/demos/minehunt/minehunt.cpp10
-rw-r--r--examples/demos/minehunt/minehunt.h6
-rw-r--r--examples/demos/minehunt/minehunt.pro2
-rw-r--r--examples/demos/minehunt/minehunt.qml2
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml2
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml2
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/Button.qml2
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml2
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml2
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml2
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/RssModel.qml2
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/Tag.qml2
-rw-r--r--examples/demos/photoviewer/photoviewer.qml2
-rw-r--r--examples/demos/plasmapatrol/content/BlasterHardpoint.qml2
-rw-r--r--examples/demos/plasmapatrol/content/Button.qml2
-rw-r--r--examples/demos/plasmapatrol/content/CannonHardpoint.qml2
-rw-r--r--examples/demos/plasmapatrol/content/ChoiceBox.qml2
-rw-r--r--examples/demos/plasmapatrol/content/Cruiser.qml2
-rw-r--r--examples/demos/plasmapatrol/content/Frigate.qml2
-rw-r--r--examples/demos/plasmapatrol/content/Hardpoint.qml2
-rw-r--r--examples/demos/plasmapatrol/content/HelpScreens.qml2
-rw-r--r--examples/demos/plasmapatrol/content/LaserHardpoint.qml2
-rw-r--r--examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml2
-rw-r--r--examples/demos/plasmapatrol/content/SequentialLoader.qml2
-rw-r--r--examples/demos/plasmapatrol/content/Ship.qml2
-rw-r--r--examples/demos/plasmapatrol/content/Sloop.qml2
-rw-r--r--examples/demos/plasmapatrol/plasmapatrol.qml2
-rw-r--r--examples/demos/rssnews/content/BusyIndicator.qml2
-rw-r--r--examples/demos/rssnews/content/CategoryDelegate.qml2
-rw-r--r--examples/demos/rssnews/content/NewsDelegate.qml2
-rw-r--r--examples/demos/rssnews/content/RssFeeds.qml2
-rw-r--r--examples/demos/rssnews/content/ScrollBar.qml2
-rw-r--r--examples/demos/rssnews/rssnews.qml2
-rw-r--r--examples/demos/samegame/content/BoomBlock.qml2
-rw-r--r--examples/demos/samegame/content/Button.qml2
-rw-r--r--examples/demos/samegame/content/Dialog.qml2
-rw-r--r--examples/demos/samegame/content/GameArea.qml2
-rw-r--r--examples/demos/samegame/content/NameInputDialog.qml2
-rw-r--r--examples/demos/samegame/samegame.qml2
-rw-r--r--examples/demos/snake/content/Button.qml2
-rw-r--r--examples/demos/snake/content/Cookie.qml2
-rw-r--r--examples/demos/snake/content/HighScoreModel.qml2
-rw-r--r--examples/demos/snake/content/Link.qml2
-rw-r--r--examples/demos/snake/content/Skull.qml2
-rw-r--r--examples/demos/snake/snake.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/Button.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/FatDelegate.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/Input.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/Loading.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/MultiTitleBar.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/RssModel.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/SearchView.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/TitleBar.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/ToolBar.qml2
-rw-r--r--examples/demos/twitter/TwitterCore/UserModel.qml2
-rw-r--r--examples/demos/twitter/twitter.qml2
-rw-r--r--examples/embedded/embedded.pro2
-rw-r--r--examples/embedded/qmlcalculator/deployment.pri4
-rw-r--r--examples/embedded/qmlcalculator/qmlcalculator.cpp63
-rw-r--r--examples/embedded/qmlcalculator/qmlcalculator.pro5
-rw-r--r--examples/embedded/qmlclocks/deployment.pri4
-rw-r--r--examples/embedded/qmlclocks/qmlclocks.cpp63
-rw-r--r--examples/embedded/qmlclocks/qmlclocks.pro5
-rw-r--r--examples/embedded/qmldialcontrol/deployment.pri4
-rw-r--r--examples/embedded/qmldialcontrol/qmldialcontrol.cpp63
-rw-r--r--examples/embedded/qmldialcontrol/qmldialcontrol.pro5
-rw-r--r--examples/embedded/qmleasing/deployment.pri4
-rw-r--r--examples/embedded/qmleasing/qmleasing.cpp63
-rw-r--r--examples/embedded/qmleasing/qmleasing.pro5
-rw-r--r--examples/embedded/qmlflickr/deployment.pri4
-rw-r--r--examples/embedded/qmlflickr/qmlflickr.cpp104
-rw-r--r--examples/embedded/qmlflickr/qmlflickr.pro5
-rw-r--r--examples/embedded/qmlphotoviewer/deployment.pri4
-rw-r--r--examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp104
-rw-r--r--examples/embedded/qmlphotoviewer/qmlphotoviewer.pro5
-rw-r--r--examples/embedded/qmltwitter/deployment.pri4
-rw-r--r--examples/embedded/qmltwitter/qmltwitter.cpp103
-rw-r--r--examples/embedded/qmltwitter/qmltwitter.pro5
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/qml/README13
-rw-r--r--examples/qml/accessibility/accessibility.qml105
-rw-r--r--examples/qml/accessibility/widgets/Button.qml79
-rw-r--r--examples/qml/animation/animation.qml62
-rw-r--r--examples/qml/animation/animation.qmlproject (renamed from examples/qtquick/animation/animation.qmlproject)0
-rw-r--r--examples/qml/animation/basics/color-animation.qml121
-rw-r--r--examples/qml/animation/basics/images/face-smile.png (renamed from examples/qtquick/animation/basics/images/face-smile.png)bin15408 -> 15408 bytes
-rw-r--r--examples/qml/animation/basics/images/moon.png (renamed from examples/qtquick/animation/basics/images/moon.png)bin2433 -> 2433 bytes
-rw-r--r--examples/qml/animation/basics/images/shadow.png (renamed from examples/qtquick/animation/basics/images/shadow.png)bin425 -> 425 bytes
-rw-r--r--examples/qml/animation/basics/images/star.png (renamed from examples/qtquick/animation/basics/images/star.png)bin349 -> 349 bytes
-rw-r--r--examples/qml/animation/basics/images/sun.png (renamed from examples/qtquick/animation/basics/images/sun.png)bin8153 -> 8153 bytes
-rw-r--r--examples/qml/animation/basics/property-animation.qml (renamed from examples/qtquick/animation/basics/property-animation.qml)0
-rw-r--r--examples/qml/animation/behaviors/SideRect.qml (renamed from examples/qtquick/animation/behaviors/SideRect.qml)0
-rw-r--r--examples/qml/animation/behaviors/behavior-example.qml118
-rw-r--r--examples/qml/animation/behaviors/wigglytext.qml108
-rw-r--r--examples/qml/animation/easing/content/QuitButton.qml (renamed from examples/qtquick/animation/easing/content/QuitButton.qml)0
-rw-r--r--examples/qml/animation/easing/content/quit.png (renamed from examples/qtquick/animation/easing/content/quit.png)bin583 -> 583 bytes
-rw-r--r--examples/qml/animation/easing/easing.qml170
-rw-r--r--examples/qml/animation/pathanimation/pathanimation.qml108
-rw-r--r--examples/qml/animation/pathinterpolator/pathinterpolator.qml115
-rw-r--r--examples/qml/animation/states/qt-logo.png (renamed from examples/qtquick/animation/states/qt-logo.png)bin5149 -> 5149 bytes
-rw-r--r--examples/qml/animation/states/states.qml (renamed from examples/qtquick/animation/states/states.qml)0
-rw-r--r--examples/qml/animation/states/transitions.qml (renamed from examples/qtquick/animation/states/transitions.qml)0
-rw-r--r--examples/qml/calculator/calculator.qml163
-rw-r--r--examples/qml/calculator/content/Button.qml84
-rw-r--r--examples/qml/calculator/content/Display.qml68
-rw-r--r--examples/qml/calculator/content/calculator.js91
-rw-r--r--examples/qml/calculator/content/images/button-.pngbin0 -> 1288 bytes
-rw-r--r--examples/qml/calculator/content/images/button-blue.pngbin0 -> 1565 bytes
-rw-r--r--examples/qml/calculator/content/images/button-green.pngbin0 -> 1543 bytes
-rw-r--r--examples/qml/calculator/content/images/button-purple.pngbin0 -> 1566 bytes
-rw-r--r--examples/qml/calculator/content/images/button-red.pngbin0 -> 1586 bytes
-rw-r--r--examples/qml/calculator/content/images/display.pngbin0 -> 998 bytes
-rw-r--r--examples/qml/calculator/content/qmldir2
-rw-r--r--examples/qml/canvas/bezierCurve/bezierCurve.qml (renamed from examples/qtquick/canvas/bezierCurve/bezierCurve.qml)0
-rw-r--r--examples/qml/canvas/clip/clip.qml (renamed from examples/qtquick/canvas/clip/clip.qml)0
-rw-r--r--examples/qml/canvas/contents/Button.qml (renamed from examples/qtquick/canvas/contents/Button.qml)0
-rw-r--r--examples/qml/canvas/contents/ScrollBar.qml (renamed from examples/qtquick/canvas/contents/ScrollBar.qml)0
-rw-r--r--examples/qml/canvas/contents/Slider.qml (renamed from examples/qtquick/canvas/contents/Slider.qml)0
-rw-r--r--examples/qml/canvas/contents/Stocks.qml (renamed from examples/qtquick/canvas/contents/Stocks.qml)0
-rw-r--r--examples/qml/canvas/contents/TitleBar.qml (renamed from examples/qtquick/canvas/contents/TitleBar.qml)0
-rw-r--r--examples/qml/canvas/contents/ToolBar.qml (renamed from examples/qtquick/canvas/contents/ToolBar.qml)0
-rw-r--r--examples/qml/canvas/contents/images/button-pressed.png (renamed from examples/qtquick/canvas/contents/images/button-pressed.png)bin571 -> 571 bytes
-rw-r--r--examples/qml/canvas/contents/images/button.png (renamed from examples/qtquick/canvas/contents/images/button.png)bin564 -> 564 bytes
-rw-r--r--examples/qml/canvas/contents/images/default.svg (renamed from examples/qtquick/canvas/contents/images/default.svg)0
-rwxr-xr-xexamples/qml/canvas/contents/images/gloss.png (renamed from examples/qtquick/canvas/contents/images/gloss.png)bin1236 -> 1236 bytes
-rwxr-xr-xexamples/qml/canvas/contents/images/lineedit.png (renamed from examples/qtquick/canvas/contents/images/lineedit.png)bin1415 -> 1415 bytes
-rw-r--r--examples/qml/canvas/contents/images/lineedit.sci (renamed from examples/qtquick/canvas/contents/images/lineedit.sci)0
-rwxr-xr-xexamples/qml/canvas/contents/images/quit.png (renamed from examples/qtquick/canvas/contents/images/quit.png)bin2369 -> 2369 bytes
-rwxr-xr-xexamples/qml/canvas/contents/images/stripes.png (renamed from examples/qtquick/canvas/contents/images/stripes.png)bin257 -> 257 bytes
-rwxr-xr-xexamples/qml/canvas/contents/images/titlebar.png (renamed from examples/qtquick/canvas/contents/images/titlebar.png)bin1436 -> 1436 bytes
-rw-r--r--examples/qml/canvas/contents/images/titlebar.sci (renamed from examples/qtquick/canvas/contents/images/titlebar.sci)0
-rwxr-xr-xexamples/qml/canvas/contents/images/toolbutton.png (renamed from examples/qtquick/canvas/contents/images/toolbutton.png)bin2550 -> 2550 bytes
-rw-r--r--examples/qml/canvas/contents/images/toolbutton.sci (renamed from examples/qtquick/canvas/contents/images/toolbutton.sci)0
-rw-r--r--examples/qml/canvas/contents/qt-logo.png (renamed from examples/qtquick/canvas/contents/qt-logo.png)bin23519 -> 23519 bytes
-rw-r--r--examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml (renamed from examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml)0
-rw-r--r--examples/qml/canvas/roundedrect/roundedrect.qml (renamed from examples/qtquick/canvas/roundedrect/roundedrect.qml)0
-rw-r--r--examples/qml/canvas/smile/smile.qml (renamed from examples/qtquick/canvas/smile/smile.qml)0
-rw-r--r--examples/qml/canvas/squircle/squircle.png (renamed from examples/qtquick/canvas/squircle/squircle.png)bin771 -> 771 bytes
-rw-r--r--examples/qml/canvas/squircle/squircle.qml (renamed from examples/qtquick/canvas/squircle/squircle.qml)0
-rw-r--r--examples/qml/canvas/stockchart/README (renamed from examples/qtquick/canvas/stockchart/README)0
-rw-r--r--examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir (renamed from examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir)0
-rw-r--r--examples/qml/canvas/stockchart/model.cpp (renamed from examples/qtquick/canvas/stockchart/model.cpp)0
-rw-r--r--examples/qml/canvas/stockchart/model.h (renamed from examples/qtquick/canvas/stockchart/model.h)0
-rw-r--r--examples/qml/canvas/stockchart/plugin.cpp60
-rw-r--r--examples/qml/canvas/stockchart/stock.qml (renamed from examples/qtquick/canvas/stockchart/stock.qml)0
-rw-r--r--examples/qml/canvas/stockchart/stockchart.pro20
-rw-r--r--examples/qml/canvas/tiger/tiger.js (renamed from examples/qtquick/canvas/tiger/tiger.js)0
-rw-r--r--examples/qml/canvas/tiger/tiger.qml (renamed from examples/qtquick/canvas/tiger/tiger.qml)0
-rw-r--r--examples/qml/canvas/twitterfriends/TwitterUser.qml (renamed from examples/qtquick/canvas/twitterfriends/TwitterUser.qml)0
-rw-r--r--examples/qml/canvas/twitterfriends/cache.js (renamed from examples/qtquick/canvas/twitterfriends/cache.js)0
-rw-r--r--examples/qml/canvas/twitterfriends/twitter.qml (renamed from examples/qtquick/canvas/twitterfriends/twitter.qml)0
-rw-r--r--examples/qml/cppextensions/imageprovider/imageprovider.cpp18
-rw-r--r--examples/qml/cppextensions/imageprovider/imageprovider.pro8
-rw-r--r--examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp8
-rw-r--r--examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro2
-rw-r--r--examples/qml/cppextensions/plugins/plugin.cpp8
-rw-r--r--examples/qml/cppextensions/plugins/plugins.pro8
-rw-r--r--examples/qml/cppextensions/referenceexamples/adding/adding.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/adding/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/attached/attached.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/attached/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/binding/binding.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h12
-rw-r--r--examples/qml/cppextensions/referenceexamples/binding/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/coercion/coercion.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/coercion/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/default/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/default/default.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/default/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/extended/extended.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/extended/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/grouped/grouped.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/grouped/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/methods/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/methods/methods.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/properties/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/properties/properties.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/signal/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/signal/signal.pro6
-rw-r--r--examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp4
-rw-r--r--examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h6
-rw-r--r--examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h14
-rw-r--r--examples/qml/cppextensions/referenceexamples/valuesource/main.cpp8
-rw-r--r--examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro6
-rw-r--r--examples/qml/draganddrop/dragtarget.qmlproject (renamed from examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject)0
-rw-r--r--examples/qml/draganddrop/tiles/DragTile.qml89
-rw-r--r--examples/qml/draganddrop/tiles/DropTile.qml68
-rw-r--r--examples/qml/draganddrop/tiles/tiles.qml109
-rw-r--r--examples/qml/draganddrop/views/gridview.qml117
-rw-r--r--examples/qml/flickr/content/Button.qml79
-rw-r--r--examples/qml/flickr/content/GridDelegate.qml111
-rw-r--r--examples/qml/flickr/content/ImageDetails.qml323
-rw-r--r--examples/qml/flickr/content/ListDelegate.qml64
-rw-r--r--examples/qml/flickr/content/Progress.qml88
-rw-r--r--examples/qml/flickr/content/RssModel.qml64
-rw-r--r--examples/qml/flickr/content/ScrollBar.qml81
-rw-r--r--examples/qml/flickr/content/Slider.qml91
-rw-r--r--examples/qml/flickr/content/TitleBar.qml128
-rw-r--r--examples/qml/flickr/content/ToolBar.qml69
-rw-r--r--examples/qml/flickr/content/UnifiedDelegate.qml154
-rw-r--r--examples/qml/flickr/content/images/gloss.pngbin0 -> 1236 bytes
-rw-r--r--examples/qml/flickr/content/images/lineedit.pngbin0 -> 1415 bytes
-rw-r--r--examples/qml/flickr/content/images/lineedit.sci5
-rw-r--r--examples/qml/flickr/content/images/noise.pngbin0 -> 25447 bytes
-rw-r--r--examples/qml/flickr/content/images/particle.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/blur-circle3.png)bin5148 -> 5148 bytes
-rw-r--r--examples/qml/flickr/content/images/quit.pngbin0 -> 2369 bytes
-rw-r--r--examples/qml/flickr/content/images/squareParticle.pngbin0 -> 933 bytes
-rw-r--r--examples/qml/flickr/content/images/stripes.pngbin0 -> 257 bytes
-rw-r--r--examples/qml/flickr/content/images/titlebar.pngbin0 -> 1436 bytes
-rw-r--r--examples/qml/flickr/content/images/titlebar.sci5
-rw-r--r--examples/qml/flickr/content/images/toolbutton.pngbin0 -> 2550 bytes
-rw-r--r--examples/qml/flickr/content/images/toolbutton.sci5
-rw-r--r--examples/qml/flickr/content/qmldir10
-rw-r--r--examples/qml/flickr/flickr-90.qml52
-rw-r--r--examples/qml/flickr/flickr.qml158
-rw-r--r--examples/qml/flickr/flickr.qmlproject17
-rw-r--r--examples/qml/imageelements/borderimage.qml97
-rw-r--r--examples/qml/imageelements/content/BearSheet.png (renamed from examples/qtquick/imageelements/content/BearSheet.png)bin406337 -> 406337 bytes
-rw-r--r--examples/qml/imageelements/content/ImageCell.qml (renamed from examples/qtquick/imageelements/content/ImageCell.qml)0
-rw-r--r--examples/qml/imageelements/content/MyBorderImage.qml90
-rw-r--r--examples/qml/imageelements/content/ShadowRectangle.qml (renamed from examples/qtquick/imageelements/content/ShadowRectangle.qml)0
-rw-r--r--examples/qml/imageelements/content/bw.png (renamed from examples/qtquick/imageelements/content/bw.png)bin1357 -> 1357 bytes
-rw-r--r--examples/qml/imageelements/content/colors-round.sci (renamed from examples/qtquick/imageelements/content/colors-round.sci)0
-rw-r--r--examples/qml/imageelements/content/colors-stretch.sci (renamed from examples/qtquick/imageelements/content/colors-stretch.sci)0
-rw-r--r--examples/qml/imageelements/content/colors.png (renamed from examples/qtquick/imageelements/content/colors.png)bin1655 -> 1655 bytes
-rw-r--r--examples/qml/imageelements/content/qt-logo.png (renamed from examples/qtquick/imageelements/content/qt-logo.png)bin5149 -> 5149 bytes
-rw-r--r--examples/qml/imageelements/content/shadow.png (renamed from examples/qtquick/imageelements/content/shadow.png)bin588 -> 588 bytes
-rw-r--r--examples/qml/imageelements/content/speaker.png (renamed from examples/qtquick/imageelements/content/speaker.png)bin784525 -> 784525 bytes
-rw-r--r--examples/qml/imageelements/image.qml67
-rw-r--r--examples/qml/imageelements/imageelements.qml58
-rw-r--r--examples/qml/imageelements/imageelements.qmlproject (renamed from examples/qtquick/imageelements/imageelements.qmlproject)0
-rw-r--r--examples/qml/imageelements/shadows.qml (renamed from examples/qtquick/imageelements/shadows.qml)0
-rw-r--r--examples/qml/imageelements/simplesprite.qml59
-rw-r--r--examples/qml/imageelements/spriteimage.qml116
-rw-r--r--examples/qml/keyinteraction/focus/Core/ContextMenu.qml (renamed from examples/qtquick/keyinteraction/focus/Core/ContextMenu.qml)0
-rw-r--r--examples/qml/keyinteraction/focus/Core/GridMenu.qml (renamed from examples/qtquick/keyinteraction/focus/Core/GridMenu.qml)0
-rw-r--r--examples/qml/keyinteraction/focus/Core/ListMenu.qml (renamed from examples/qtquick/keyinteraction/focus/Core/ListMenu.qml)0
-rw-r--r--examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml (renamed from examples/qtquick/keyinteraction/focus/Core/ListViewDelegate.qml)0
-rw-r--r--examples/qml/keyinteraction/focus/Core/images/arrow.png (renamed from examples/qtquick/keyinteraction/focus/Core/images/arrow.png)bin583 -> 583 bytes
-rw-r--r--examples/qml/keyinteraction/focus/Core/images/qt-logo.png (renamed from examples/qtquick/keyinteraction/focus/Core/images/qt-logo.png)bin5149 -> 5149 bytes
-rw-r--r--examples/qml/keyinteraction/focus/focus.qml (renamed from examples/qtquick/keyinteraction/focus/focus.qml)0
-rw-r--r--examples/qml/minehunt/MinehuntCore/Explosion.qml69
-rw-r--r--examples/qml/minehunt/MinehuntCore/Tile.qml128
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/back.pngbin0 -> 558 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/background.pngbin0 -> 313930 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/bomb-color.pngbin0 -> 284 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/bomb.pngbin0 -> 535 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/face-sad.pngbin0 -> 14844 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/face-smile-big.pngbin0 -> 13810 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/face-smile.png (renamed from examples/qtquick/modelviews/parallax/content/pics/face-smile.png)bin15408 -> 15408 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/flag-color.pngbin0 -> 219 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/flag.pngbin0 -> 196 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/front.pngbin0 -> 580 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/quit.png (renamed from examples/qtquick/modelviews/parallax/content/quit.png)bin583 -> 583 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/pics/star.pngbin0 -> 2677 bytes
-rw-r--r--examples/qml/minehunt/MinehuntCore/qmldir2
-rw-r--r--examples/qml/minehunt/README6
-rw-r--r--examples/qml/minehunt/main.cpp64
-rw-r--r--examples/qml/minehunt/minehunt.cpp221
-rw-r--r--examples/qml/minehunt/minehunt.h129
-rw-r--r--examples/qml/minehunt/minehunt.pro5
-rw-r--r--examples/qml/minehunt/minehunt.qml112
-rw-r--r--examples/qml/minehunt/minehunt.qmlproject16
-rw-r--r--examples/qml/minehunt/minehunt.qrc20
-rw-r--r--examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro10
-rw-r--r--examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc (renamed from examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.qrc)0
-rw-r--r--examples/qml/modelviews/abstractitemmodel/main.cpp70
-rw-r--r--examples/qml/modelviews/abstractitemmodel/model.cpp (renamed from examples/qtquick/modelviews/abstractitemmodel/model.cpp)0
-rw-r--r--examples/qml/modelviews/abstractitemmodel/model.h (renamed from examples/qtquick/modelviews/abstractitemmodel/model.h)0
-rw-r--r--examples/qml/modelviews/abstractitemmodel/view.qml (renamed from examples/qtquick/modelviews/abstractitemmodel/view.qml)0
-rw-r--r--examples/qml/modelviews/gridview/gridview-example.qml (renamed from examples/qtquick/modelviews/gridview/gridview-example.qml)0
-rw-r--r--examples/qml/modelviews/gridview/pics/AddressBook_48.png (renamed from examples/qtquick/modelviews/gridview/pics/AddressBook_48.png)bin3350 -> 3350 bytes
-rw-r--r--examples/qml/modelviews/gridview/pics/AudioPlayer_48.png (renamed from examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png)bin3806 -> 3806 bytes
-rw-r--r--examples/qml/modelviews/gridview/pics/Camera_48.png (renamed from examples/qtquick/modelviews/gridview/pics/Camera_48.png)bin3540 -> 3540 bytes
-rw-r--r--examples/qml/modelviews/gridview/pics/DateBook_48.png (renamed from examples/qtquick/modelviews/gridview/pics/DateBook_48.png)bin2610 -> 2610 bytes
-rw-r--r--examples/qml/modelviews/gridview/pics/EMail_48.png (renamed from examples/qtquick/modelviews/gridview/pics/EMail_48.png)bin3655 -> 3655 bytes
-rw-r--r--examples/qml/modelviews/gridview/pics/TodoList_48.png (renamed from examples/qtquick/modelviews/gridview/pics/TodoList_48.png)bin3429 -> 3429 bytes
-rw-r--r--examples/qml/modelviews/gridview/pics/VideoPlayer_48.png (renamed from examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png)bin4151 -> 4151 bytes
-rw-r--r--examples/qml/modelviews/listview/content/PetsModel.qml (renamed from examples/qtquick/modelviews/listview/content/PetsModel.qml)0
-rw-r--r--examples/qml/modelviews/listview/content/PressAndHoldButton.qml (renamed from examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml)0
-rw-r--r--examples/qml/modelviews/listview/content/RecipesModel.qml (renamed from examples/qtquick/modelviews/listview/content/RecipesModel.qml)0
-rw-r--r--examples/qml/modelviews/listview/content/TextButton.qml (renamed from examples/qtquick/modelviews/listview/content/TextButton.qml)0
-rw-r--r--examples/qml/modelviews/listview/content/ToggleButton.qml58
-rw-r--r--examples/qml/modelviews/listview/content/pics/arrow-down.png (renamed from examples/qtquick/modelviews/listview/content/pics/arrow-down.png)bin594 -> 594 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/arrow-up.png (renamed from examples/qtquick/modelviews/listview/content/pics/arrow-up.png)bin692 -> 692 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/fruit-salad.jpg (renamed from examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg)bin17952 -> 17952 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/hamburger.jpg (renamed from examples/qtquick/modelviews/listview/content/pics/hamburger.jpg)bin8572 -> 8572 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/lemonade.jpg (renamed from examples/qtquick/modelviews/listview/content/pics/lemonade.jpg)bin6645 -> 6645 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/list-delete.png (renamed from examples/qtquick/modelviews/listview/content/pics/list-delete.png)bin831 -> 831 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/minus-sign.png (renamed from examples/qtquick/modelviews/listview/content/pics/minus-sign.png)bin250 -> 250 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/moreDown.png (renamed from examples/qtquick/modelviews/listview/content/pics/moreDown.png)bin217 -> 217 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/moreUp.png (renamed from examples/qtquick/modelviews/listview/content/pics/moreUp.png)bin212 -> 212 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/pancakes.jpg (renamed from examples/qtquick/modelviews/listview/content/pics/pancakes.jpg)bin9163 -> 9163 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/plus-sign.png (renamed from examples/qtquick/modelviews/listview/content/pics/plus-sign.png)bin462 -> 462 bytes
-rw-r--r--examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg (renamed from examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg)bin8639 -> 8639 bytes
-rw-r--r--examples/qml/modelviews/listview/dynamiclist.qml (renamed from examples/qtquick/modelviews/listview/dynamiclist.qml)0
-rw-r--r--examples/qml/modelviews/listview/expandingdelegates.qml (renamed from examples/qtquick/modelviews/listview/expandingdelegates.qml)0
-rw-r--r--examples/qml/modelviews/listview/highlight.qml (renamed from examples/qtquick/modelviews/listview/highlight.qml)0
-rw-r--r--examples/qml/modelviews/listview/highlightranges.qml (renamed from examples/qtquick/modelviews/listview/highlightranges.qml)0
-rw-r--r--examples/qml/modelviews/listview/sections.qml (renamed from examples/qtquick/modelviews/listview/sections.qml)0
-rw-r--r--examples/qml/modelviews/modelviews.pro (renamed from examples/qtquick/modelviews/modelviews.pro)0
-rw-r--r--examples/qml/modelviews/modelviews.qml64
-rw-r--r--examples/qml/modelviews/modelviews.qmlproject (renamed from examples/qtquick/modelviews/modelviews.qmlproject)0
-rw-r--r--examples/qml/modelviews/objectlistmodel/dataobject.cpp (renamed from examples/qtquick/modelviews/objectlistmodel/dataobject.cpp)0
-rw-r--r--examples/qml/modelviews/objectlistmodel/dataobject.h (renamed from examples/qtquick/modelviews/objectlistmodel/dataobject.h)0
-rw-r--r--examples/qml/modelviews/objectlistmodel/main.cpp78
-rw-r--r--examples/qml/modelviews/objectlistmodel/objectlistmodel.pro6
-rw-r--r--examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject (renamed from examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject)0
-rw-r--r--examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc (renamed from examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc)0
-rw-r--r--examples/qml/modelviews/objectlistmodel/view.qml (renamed from examples/qtquick/modelviews/objectlistmodel/view.qml)0
-rw-r--r--examples/qml/modelviews/package/Delegate.qml (renamed from examples/qtquick/modelviews/package/Delegate.qml)0
-rw-r--r--examples/qml/modelviews/package/view.qml76
-rw-r--r--examples/qml/modelviews/parallax/content/ParallaxView.qml (renamed from examples/qtquick/modelviews/parallax/content/ParallaxView.qml)0
-rw-r--r--examples/qml/modelviews/parallax/content/Smiley.qml (renamed from examples/qtquick/modelviews/parallax/content/Smiley.qml)0
-rw-r--r--examples/qml/modelviews/parallax/content/pics/background.jpg (renamed from examples/qtquick/modelviews/parallax/content/pics/background.jpg)bin209814 -> 209814 bytes
-rw-r--r--examples/qml/modelviews/parallax/content/pics/face-smile.png (renamed from examples/qtquick/shadereffects/content/face-smile.png)bin15408 -> 15408 bytes
-rw-r--r--examples/qml/modelviews/parallax/content/pics/home-page.png (renamed from examples/qtquick/modelviews/parallax/content/pics/home-page.png)bin3051 -> 3051 bytes
-rw-r--r--examples/qml/modelviews/parallax/content/pics/home-page.svg (renamed from examples/qtquick/modelviews/parallax/content/pics/home-page.svg)0
-rw-r--r--examples/qml/modelviews/parallax/content/pics/shadow.png (renamed from examples/qtquick/modelviews/parallax/content/pics/shadow.png)bin425 -> 425 bytes
-rw-r--r--examples/qml/modelviews/parallax/content/pics/yast-joystick.png (renamed from examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png)bin2723 -> 2723 bytes
-rw-r--r--examples/qml/modelviews/parallax/content/pics/yast-wol.png (renamed from examples/qtquick/modelviews/parallax/content/pics/yast-wol.png)bin3769 -> 3769 bytes
-rw-r--r--examples/qml/modelviews/parallax/parallax.qml77
-rw-r--r--examples/qml/modelviews/pathview/pathview-example.qml (renamed from examples/qtquick/modelviews/pathview/pathview-example.qml)0
-rw-r--r--examples/qml/modelviews/pathview/pics/AddressBook_48.png (renamed from examples/qtquick/modelviews/pathview/pics/AddressBook_48.png)bin3350 -> 3350 bytes
-rw-r--r--examples/qml/modelviews/pathview/pics/AudioPlayer_48.png (renamed from examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png)bin3806 -> 3806 bytes
-rw-r--r--examples/qml/modelviews/pathview/pics/Camera_48.png (renamed from examples/qtquick/modelviews/pathview/pics/Camera_48.png)bin3540 -> 3540 bytes
-rw-r--r--examples/qml/modelviews/pathview/pics/DateBook_48.png (renamed from examples/qtquick/modelviews/pathview/pics/DateBook_48.png)bin2610 -> 2610 bytes
-rw-r--r--examples/qml/modelviews/pathview/pics/EMail_48.png (renamed from examples/qtquick/modelviews/pathview/pics/EMail_48.png)bin3655 -> 3655 bytes
-rw-r--r--examples/qml/modelviews/pathview/pics/TodoList_48.png (renamed from examples/qtquick/modelviews/pathview/pics/TodoList_48.png)bin3429 -> 3429 bytes
-rw-r--r--examples/qml/modelviews/pathview/pics/VideoPlayer_48.png (renamed from examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png)bin4151 -> 4151 bytes
-rw-r--r--examples/qml/modelviews/stringlistmodel/main.cpp77
-rw-r--r--examples/qml/modelviews/stringlistmodel/stringlistmodel.pro4
-rw-r--r--examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc (renamed from examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc)0
-rw-r--r--examples/qml/modelviews/stringlistmodel/view.qml (renamed from examples/qtquick/modelviews/stringlistmodel/view.qml)0
-rw-r--r--examples/qml/modelviews/visualdatamodel/dragselection.qml (renamed from examples/qtquick/modelviews/visualdatamodel/dragselection.qml)0
-rw-r--r--examples/qml/modelviews/visualdatamodel/slideshow.qml (renamed from examples/qtquick/modelviews/visualdatamodel/slideshow.qml)0
-rw-r--r--examples/qml/modelviews/visualdatamodel/sortedmodel.qml (renamed from examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml)0
-rw-r--r--examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject14
-rw-r--r--examples/qml/modelviews/visualitemmodel/visualitemmodel.qml115
-rw-r--r--examples/qml/openglunderqml/main.cpp (renamed from examples/qtquick/openglunderqml/main.cpp)0
-rw-r--r--examples/qml/openglunderqml/main.qml (renamed from examples/qtquick/openglunderqml/main.qml)0
-rw-r--r--examples/qml/openglunderqml/openglunderqml.pro6
-rw-r--r--examples/qml/openglunderqml/squircle.cpp (renamed from examples/qtquick/openglunderqml/squircle.cpp)0
-rw-r--r--examples/qml/openglunderqml/squircle.h (renamed from examples/qtquick/openglunderqml/squircle.h)0
-rw-r--r--examples/qml/painteditem/painteditem.pro (renamed from examples/qtquick/painteditem/painteditem.pro)0
-rw-r--r--examples/qml/painteditem/smile/main.cpp96
-rw-r--r--examples/qml/painteditem/smile/smile.pro11
-rw-r--r--examples/qml/painteditem/smile/smile.qml (renamed from examples/qtquick/painteditem/smile/smile.qml)0
-rw-r--r--examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h56
-rw-r--r--examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir (renamed from examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir)0
-rw-r--r--examples/qml/painteditem/textballoons/textballoon.cpp (renamed from examples/qtquick/painteditem/textballoons/textballoon.cpp)0
-rw-r--r--examples/qml/painteditem/textballoons/textballoon.h (renamed from examples/qtquick/painteditem/textballoons/textballoon.h)0
-rw-r--r--examples/qml/painteditem/textballoons/textballoons.pro23
-rw-r--r--examples/qml/painteditem/textballoons/textballoons.qml (renamed from examples/qtquick/painteditem/textballoons/textballoons.qml)0
-rw-r--r--examples/qml/particles/affectors/age.qml97
-rw-r--r--examples/qml/particles/affectors/attractor.qml213
-rw-r--r--examples/qml/particles/affectors/customaffector.qml173
-rw-r--r--examples/qml/particles/affectors/friction.qml109
-rw-r--r--examples/qml/particles/affectors/gravity.qml103
-rw-r--r--examples/qml/particles/affectors/groupgoal.qml193
-rw-r--r--examples/qml/particles/affectors/move.qml141
-rw-r--r--examples/qml/particles/affectors/spritegoal.qml212
-rw-r--r--examples/qml/particles/affectors/turbulence.qml135
-rw-r--r--examples/qml/particles/affectors/wander.qml95
-rw-r--r--examples/qml/particles/customparticle/blurparticles.qml140
-rw-r--r--examples/qml/particles/customparticle/fragmentshader.qml115
-rw-r--r--examples/qml/particles/customparticle/imagecolors.qml118
-rw-r--r--examples/qml/particles/emitters/burstandpulse.qml84
-rw-r--r--examples/qml/particles/emitters/customemitter.qml92
-rw-r--r--examples/qml/particles/emitters/emitmask.qml72
-rw-r--r--examples/qml/particles/emitters/maximumemitted.qml81
-rw-r--r--examples/qml/particles/emitters/shapeanddirection.qml112
-rw-r--r--examples/qml/particles/emitters/timedgroupchanges.qml121
-rw-r--r--examples/qml/particles/emitters/trailemitter.qml175
-rw-r--r--examples/qml/particles/emitters/velocityfrommotion.qml311
-rw-r--r--examples/qml/particles/exampleslauncher/content/Button.qml73
-rw-r--r--examples/qml/particles/exampleslauncher/content/Shell.qml78
-rw-r--r--examples/qml/particles/exampleslauncher/content/launcher.js8
-rw-r--r--examples/qml/particles/exampleslauncher/exampleslauncher.qml116
-rw-r--r--examples/qml/particles/imageparticle/allatonce.qml98
-rw-r--r--examples/qml/particles/imageparticle/colored.qml86
-rw-r--r--examples/qml/particles/imageparticle/colortable.qml84
-rw-r--r--examples/qml/particles/imageparticle/deformation.qml121
-rw-r--r--examples/qml/particles/imageparticle/rotation.qml71
-rw-r--r--examples/qml/particles/imageparticle/sharing.qml199
-rw-r--r--examples/qml/particles/imageparticle/sprites.qml116
-rw-r--r--examples/qml/particles/images/_explo.pngbin0 -> 81528 bytes
-rwxr-xr-xexamples/qml/particles/images/backgroundLeaves.jpgbin0 -> 78665 bytes
-rw-r--r--examples/qml/particles/images/bear_tiles.pngbin0 -> 40349 bytes
-rw-r--r--examples/qml/particles/images/candle.pngbin0 -> 1348 bytes
-rw-r--r--examples/qml/particles/images/colortable.pngbin0 -> 704 bytes
-rw-r--r--examples/qml/particles/images/finalfrontier.pngbin0 -> 695061 bytes
-rw-r--r--examples/qml/particles/images/flower.pngbin0 -> 4683 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/allatonce.pngbin0 -> 7075 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/attractor.pngbin0 -> 31296 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/blurparticles.pngbin0 -> 19109 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/close.pngbin0 -> 2144 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/colortable.pngbin0 -> 6538 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/customaffector.pngbin0 -> 10350 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/customemitter.pngbin0 -> 22967 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/deformation.pngbin0 -> 2870 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/delegates.pngbin0 -> 1892 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/dynamicemitters.pngbin0 -> 9347 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/emitmask.pngbin0 -> 45055 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/flickr.pngbin0 -> 10542 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/fragmentshader.pngbin0 -> 22294 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/gridsplosion.pngbin0 -> 8154 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/groupgoal.pngbin0 -> 7173 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/imagecolors.pngbin0 -> 56647 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/list.pngbin0 -> 32912 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/maximumemitted.pngbin0 -> 1019 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/multiplepainters.pngbin0 -> 8572 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/package.pngbin0 -> 3163 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/particleview.pngbin0 -> 26560 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/plasmapatrol.pngbin0 -> 9839 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/remove.pngbin0 -> 2144 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/rotation.pngbin0 -> 20661 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/samegame.pngbin0 -> 8647 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/shapeanddirection.pngbin0 -> 11359 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/spaceexplorer.pngbin0 -> 9152 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/spritegoal.pngbin0 -> 35579 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/sprites.pngbin0 -> 17009 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/spritevariedparticles.pngbin0 -> 2569 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/startstop.pngbin0 -> 13670 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/timedgroupchanges.pngbin0 -> 16139 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/trailemitter.pngbin0 -> 5371 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/trails.pngbin0 -> 23168 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/turbulence.pngbin0 -> 9684 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/velocityfrommotion.pngbin0 -> 36360 bytes
-rw-r--r--examples/qml/particles/images/launcherIcons/wander.pngbin0 -> 5858 bytes
-rw-r--r--examples/qml/particles/images/matchmask.pngbin0 -> 2369 bytes
-rw-r--r--examples/qml/particles/images/meteor.pngbin0 -> 83169 bytes
-rw-r--r--examples/qml/particles/images/meteor_explo.pngbin0 -> 219946 bytes
-rw-r--r--examples/qml/particles/images/meteors.pngbin0 -> 132137 bytes
-rw-r--r--examples/qml/particles/images/nullRock.pngbin0 -> 140 bytes
-rw-r--r--examples/qml/particles/images/particle.pngbin0 -> 861 bytes
-rw-r--r--examples/qml/particles/images/particle2.pngbin0 -> 3909 bytes
-rw-r--r--examples/qml/particles/images/particle3.pngbin0 -> 3186 bytes
-rw-r--r--examples/qml/particles/images/particle4.pngbin0 -> 1799 bytes
-rw-r--r--examples/qml/particles/images/particleA.pngbin0 -> 3541 bytes
-rw-r--r--examples/qml/particles/images/portal_bg.pngbin0 -> 96858 bytes
-rw-r--r--examples/qml/particles/images/realLeaf1.pngbin0 -> 15625 bytes
-rw-r--r--examples/qml/particles/images/realLeaf2.pngbin0 -> 13660 bytes
-rw-r--r--examples/qml/particles/images/realLeaf3.pngbin0 -> 23809 bytes
-rw-r--r--examples/qml/particles/images/realLeaf4.pngbin0 -> 23655 bytes
-rw-r--r--examples/qml/particles/images/rocket.pngbin0 -> 7315 bytes
-rw-r--r--examples/qml/particles/images/rocket2.pngbin0 -> 1918 bytes
-rw-r--r--examples/qml/particles/images/sizeInOut.pngbin0 -> 251 bytes
-rw-r--r--examples/qml/particles/images/snowflake.pngbin0 -> 189327 bytes
-rw-r--r--examples/qml/particles/images/sparkleSize.pngbin0 -> 378 bytes
-rw-r--r--examples/qml/particles/images/star.pngbin0 -> 1550 bytes
-rw-r--r--examples/qml/particles/images/starfish_0.pngbin0 -> 15972 bytes
-rw-r--r--examples/qml/particles/images/starfish_1.pngbin0 -> 15746 bytes
-rw-r--r--examples/qml/particles/images/starfish_2.pngbin0 -> 16067 bytes
-rw-r--r--examples/qml/particles/images/starfish_3.pngbin0 -> 16201 bytes
-rw-r--r--examples/qml/particles/images/starfish_4.pngbin0 -> 14698 bytes
-rw-r--r--examples/qml/particles/images/starfish_mask.pngbin0 -> 11301 bytes
-rw-r--r--examples/qml/particles/itemparticle/content/Delegate.qml88
-rw-r--r--examples/qml/particles/itemparticle/content/Delegate2.qml79
-rw-r--r--examples/qml/particles/itemparticle/content/ExpandingDelegate.qml204
-rw-r--r--examples/qml/particles/itemparticle/content/RssModel.qml56
-rw-r--r--examples/qml/particles/itemparticle/content/bubble.pngbin0 -> 3413 bytes
-rw-r--r--examples/qml/particles/itemparticle/content/script.js27
-rw-r--r--examples/qml/particles/itemparticle/delegates.qml91
-rw-r--r--examples/qml/particles/itemparticle/particleview.qml274
-rw-r--r--examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject19
-rw-r--r--examples/qml/particles/plasmapatrol/TODO10
-rw-r--r--examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml133
-rw-r--r--examples/qml/particles/plasmapatrol/content/Button.qml66
-rw-r--r--examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml97
-rw-r--r--examples/qml/particles/plasmapatrol/content/ChoiceBox.qml105
-rw-r--r--examples/qml/particles/plasmapatrol/content/Cruiser.qml146
-rw-r--r--examples/qml/particles/plasmapatrol/content/Frigate.qml114
-rw-r--r--examples/qml/particles/plasmapatrol/content/Hardpoint.qml114
-rw-r--r--examples/qml/particles/plasmapatrol/content/HelpScreens.qml268
-rw-r--r--examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml108
-rw-r--r--examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml173
-rw-r--r--examples/qml/particles/plasmapatrol/content/SequentialLoader.qml54
-rw-r--r--examples/qml/particles/plasmapatrol/content/Ship.qml114
-rw-r--r--examples/qml/particles/plasmapatrol/content/Sloop.qml108
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/TitleText.pngbin0 -> 1109 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/blur-circle2.pngbin0 -> 3627 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/blur-circle3.pngbin0 -> 5148 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/finalfrontier.pngbin0 -> 695061 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/meteor.pngbin0 -> 83169 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/meteor_explo.pngbin0 -> 81528 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/nullRock.pngbin0 -> 140 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/particle.pngbin0 -> 861 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/star.pngbin0 -> 1550 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/star2.pngbin0 -> 6507 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/content/pics/star3.pngbin0 -> 4602 bytes
-rw-r--r--examples/qml/particles/plasmapatrol/plasmapatrol.qml386
-rw-r--r--examples/qml/particles/simple/dynamiccomparison.qml126
-rw-r--r--examples/qml/particles/simple/dynamicemitters.qml122
-rw-r--r--examples/qml/particles/simple/multiplepainters.qml90
-rw-r--r--examples/qml/particles/simple/startstop.qml81
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml147
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml50
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/Button.qml72
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml86
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml188
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml57
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/RssModel.qml57
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/Tag.qml91
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.pngbin0 -> 588 bytes
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/images/cardboard.pngbin0 -> 8844 bytes
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/qmldir8
-rw-r--r--examples/qml/photoviewer/PhotoViewerCore/script/script.js27
-rw-r--r--examples/qml/photoviewer/i18n/base.ts30
-rw-r--r--examples/qml/photoviewer/i18n/qml_fr.qmbin0 -> 268 bytes
-rw-r--r--examples/qml/photoviewer/i18n/qml_fr.ts30
-rw-r--r--examples/qml/photoviewer/photoviewer.qml110
-rw-r--r--examples/qml/photoviewer/photoviewer.qmlproject20
-rw-r--r--examples/qml/positioners/content/Button.qml (renamed from examples/qtquick/positioners/content/Button.qml)0
-rw-r--r--examples/qml/positioners/content/add.png (renamed from examples/qtquick/positioners/content/add.png)bin810 -> 810 bytes
-rw-r--r--examples/qml/positioners/content/del.png (renamed from examples/qtquick/positioners/content/del.png)bin488 -> 488 bytes
-rw-r--r--examples/qml/positioners/positioners-attachedproperties.qml (renamed from examples/qtquick/positioners/positioners-attachedproperties.qml)0
-rw-r--r--examples/qml/positioners/positioners.qml264
-rw-r--r--examples/qml/righttoleft/layoutdirection/layoutdirection.qml (renamed from examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml)0
-rw-r--r--examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject (renamed from examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject)0
-rw-r--r--examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml (renamed from examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml)0
-rw-r--r--examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject (renamed from examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject)0
-rw-r--r--examples/qml/righttoleft/textalignment/textalignment.qml (renamed from examples/qtquick/righttoleft/textalignment/textalignment.qml)0
-rw-r--r--examples/qml/righttoleft/textalignment/textalignment.qmlproject (renamed from examples/qtquick/righttoleft/textalignment/textalignment.qmlproject)0
-rw-r--r--examples/qml/rssnews/content/BusyIndicator.qml53
-rw-r--r--examples/qml/rssnews/content/CategoryDelegate.qml82
-rw-r--r--examples/qml/rssnews/content/NewsDelegate.qml71
-rw-r--r--examples/qml/rssnews/content/RssFeeds.qml59
-rw-r--r--examples/qml/rssnews/content/ScrollBar.qml107
-rw-r--r--examples/qml/rssnews/content/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--examples/qml/rssnews/content/images/scrollbar.pngbin0 -> 161 bytes
-rw-r--r--examples/qml/rssnews/rssnews.qml112
-rw-r--r--examples/qml/rssnews/rssnews.qmlproject16
-rw-r--r--examples/qml/samegame/content/BoomBlock.qml112
-rw-r--r--examples/qml/samegame/content/Button.qml75
-rw-r--r--examples/qml/samegame/content/Dialog.qml81
-rw-r--r--examples/qml/samegame/content/GameArea.qml92
-rw-r--r--examples/qml/samegame/content/NameInputDialog.qml93
-rw-r--r--examples/qml/samegame/content/pics/background.pngbin0 -> 313930 bytes
-rw-r--r--examples/qml/samegame/content/pics/blueStone.png (renamed from tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png)bin3054 -> 3054 bytes
-rw-r--r--examples/qml/samegame/content/pics/greenStone.png (renamed from tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png)bin2932 -> 2932 bytes
-rw-r--r--examples/qml/samegame/content/pics/particle.pngbin0 -> 861 bytes
-rw-r--r--examples/qml/samegame/content/pics/redStone.png (renamed from tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png)bin2902 -> 2902 bytes
-rw-r--r--examples/qml/samegame/content/pics/yellowStone.png (renamed from tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png)bin3056 -> 3056 bytes
-rwxr-xr-xexamples/qml/samegame/content/samegame.js290
-rw-r--r--examples/qml/samegame/samegame.qml87
-rw-r--r--examples/qml/samegame/samegame.qmlproject16
-rw-r--r--examples/qml/script/shell/main.cpp2
-rw-r--r--examples/qml/script/shell/shell.pro2
-rw-r--r--examples/qml/shadereffects/content/Slider.qml (renamed from examples/qtquick/shadereffects/content/Slider.qml)0
-rw-r--r--examples/qml/shadereffects/content/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/qml/shadereffects/content/qt-logo.png (renamed from examples/qtquick/shadereffects/content/qt-logo.png)bin13923 -> 13923 bytes
-rw-r--r--examples/qml/shadereffects/shadereffects.qml300
-rw-r--r--examples/qml/shared/Button.qml64
-rw-r--r--examples/qml/shared/LauncherList.qml101
-rw-r--r--examples/qml/shared/README11
-rw-r--r--examples/qml/shared/SimpleLauncherDelegate.qml53
-rw-r--r--examples/qml/shared/back.pngbin0 -> 404 bytes
-rw-r--r--examples/qml/snake/content/Button.qml66
-rw-r--r--examples/qml/snake/content/Cookie.qml102
-rw-r--r--examples/qml/snake/content/HighScoreModel.qml140
-rw-r--r--examples/qml/snake/content/Link.qml129
-rw-r--r--examples/qml/snake/content/Skull.qml62
-rw-r--r--examples/qml/snake/content/pics/README1
-rw-r--r--examples/qml/snake/content/pics/background.pngbin0 -> 144508 bytes
-rw-r--r--examples/qml/snake/content/pics/blueStar.pngbin0 -> 272 bytes
-rw-r--r--examples/qml/snake/content/pics/blueStone.pngbin0 -> 3139 bytes
-rw-r--r--examples/qml/snake/content/pics/cookie.pngbin0 -> 2729 bytes
-rw-r--r--examples/qml/snake/content/pics/eyes.svg118
-rw-r--r--examples/qml/snake/content/pics/head.pngbin0 -> 3473 bytes
-rw-r--r--examples/qml/snake/content/pics/pause.pngbin0 -> 4327 bytes
-rw-r--r--examples/qml/snake/content/pics/redStar.pngbin0 -> 273 bytes
-rw-r--r--examples/qml/snake/content/pics/redStone.pngbin0 -> 3456 bytes
-rw-r--r--examples/qml/snake/content/pics/skull.pngbin0 -> 2543 bytes
-rw-r--r--examples/qml/snake/content/pics/snake.jpgbin0 -> 663901 bytes
-rw-r--r--examples/qml/snake/content/pics/star.pngbin0 -> 262 bytes
-rw-r--r--examples/qml/snake/content/pics/stoneShadow.pngbin0 -> 1699 bytes
-rw-r--r--examples/qml/snake/content/pics/yellowStar.pngbin0 -> 276 bytes
-rw-r--r--examples/qml/snake/content/pics/yellowStone.pngbin0 -> 2667 bytes
-rw-r--r--examples/qml/snake/content/snake.js316
-rw-r--r--examples/qml/snake/snake.qml272
-rw-r--r--examples/qml/snake/snake.qmlproject16
-rw-r--r--examples/qml/sqllocalstorage/hello.qml78
-rw-r--r--examples/qml/text/fonts/availableFonts.qml (renamed from examples/qtquick/text/fonts/availableFonts.qml)0
-rw-r--r--examples/qml/text/fonts/banner.qml (renamed from examples/qtquick/text/fonts/banner.qml)0
-rw-r--r--examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf (renamed from examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf)bin24544 -> 24544 bytes
-rw-r--r--examples/qml/text/fonts/fonts.qml (renamed from examples/qtquick/text/fonts/fonts.qml)0
-rw-r--r--examples/qml/text/fonts/hello.qml (renamed from examples/qtquick/text/fonts/hello.qml)0
-rw-r--r--examples/qml/text/imgtag/TextWithImage.qml (renamed from examples/qtquick/text/imgtag/TextWithImage.qml)0
-rw-r--r--examples/qml/text/imgtag/images/face-sad.png (renamed from examples/qtquick/text/imgtag/images/face-sad.png)bin6148 -> 6148 bytes
-rw-r--r--examples/qml/text/imgtag/images/face-smile-big.png (renamed from examples/qtquick/text/imgtag/images/face-smile-big.png)bin6058 -> 6058 bytes
-rw-r--r--examples/qml/text/imgtag/images/face-smile.png (renamed from examples/qtquick/text/imgtag/images/face-smile.png)bin6446 -> 6446 bytes
-rw-r--r--examples/qml/text/imgtag/images/heart200.png (renamed from examples/qtquick/text/imgtag/images/heart200.png)bin8248 -> 8248 bytes
-rw-r--r--examples/qml/text/imgtag/images/qtlogo.png (renamed from examples/qtquick/text/imgtag/images/qtlogo.png)bin6450 -> 6450 bytes
-rw-r--r--examples/qml/text/imgtag/images/starfish_2.png (renamed from examples/qtquick/text/imgtag/images/starfish_2.png)bin18243 -> 18243 bytes
-rw-r--r--examples/qml/text/imgtag/imgtag.qml (renamed from examples/qtquick/text/imgtag/imgtag.qml)0
-rw-r--r--examples/qml/text/styledtext-layout.qml (renamed from examples/qtquick/text/styledtext-layout.qml)0
-rw-r--r--examples/qml/text/text.qml57
-rw-r--r--examples/qml/text/text.qmlproject (renamed from examples/qtquick/text/text.qmlproject)0
-rw-r--r--examples/qml/text/textselection/pics/endHandle.png (renamed from examples/qtquick/text/textselection/pics/endHandle.png)bin185 -> 185 bytes
-rw-r--r--examples/qml/text/textselection/pics/endHandle.sci (renamed from examples/qtquick/text/textselection/pics/endHandle.sci)0
-rw-r--r--examples/qml/text/textselection/pics/startHandle.png (renamed from examples/qtquick/text/textselection/pics/startHandle.png)bin178 -> 178 bytes
-rw-r--r--examples/qml/text/textselection/pics/startHandle.sci (renamed from examples/qtquick/text/textselection/pics/startHandle.sci)0
-rw-r--r--examples/qml/text/textselection/textselection.qml (renamed from examples/qtquick/text/textselection/textselection.qml)0
-rw-r--r--examples/qml/threading/threadedlistmodel/dataloader.js (renamed from examples/qtquick/threading/threadedlistmodel/dataloader.js)0
-rw-r--r--examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject (renamed from examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject)0
-rw-r--r--examples/qml/threading/threadedlistmodel/timedisplay.qml (renamed from examples/qtquick/threading/threadedlistmodel/timedisplay.qml)0
-rw-r--r--examples/qml/threading/workerscript/workerscript.js (renamed from examples/qtquick/threading/workerscript/workerscript.js)0
-rw-r--r--examples/qml/threading/workerscript/workerscript.qml (renamed from examples/qtquick/threading/workerscript/workerscript.qml)0
-rw-r--r--examples/qml/threading/workerscript/workerscript.qmlproject (renamed from examples/qtquick/threading/workerscript/workerscript.qmlproject)0
-rw-r--r--examples/qml/touchinteraction/mousearea/mousearea-example.qml (renamed from examples/qtquick/mousearea/mousearea-example.qml)0
-rw-r--r--examples/qml/touchinteraction/multipointtouch/bearwhack.qml (renamed from examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml)0
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml (renamed from examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml)0
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/Bear0.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png)bin15163 -> 15163 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/Bear1.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png)bin99378 -> 99378 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/Bear2.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png)bin80759 -> 80759 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/Bear3.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png)bin21122 -> 21122 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/BearB.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/BearB.png)bin18667 -> 18667 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml180
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/ParticleFlame.qml (renamed from examples/qtquick/touchinteraction/multipointtouch/content/ParticleFlame.qml)0
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/blur-circle.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/blur-circle.png)bin4279 -> 4279 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/blur-circle3.pngbin0 -> 5148 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/heart-blur.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/heart-blur.png)bin5406 -> 5406 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/content/title.png (renamed from examples/qtquick/touchinteraction/multipointtouch/content/title.png)bin81252 -> 81252 bytes
-rw-r--r--examples/qml/touchinteraction/multipointtouch/multiflame.qml (renamed from examples/qtquick/touchinteraction/multipointtouch/multiflame.qml)0
-rw-r--r--examples/qml/touchinteraction/pincharea/flickresize.qml (renamed from examples/qtquick/touchinteraction/pincharea/flickresize.qml)0
-rw-r--r--examples/qml/touchinteraction/pincharea/qt-logo.jpg (renamed from examples/qtquick/touchinteraction/pincharea/qt-logo.jpg)bin40886 -> 40886 bytes
-rw-r--r--examples/qml/touchinteraction/touchinteraction.qml57
-rw-r--r--examples/qml/touchinteraction/touchinteraction.qmlproject (renamed from examples/qtquick/touchinteraction/touchinteraction.qmlproject)0
-rw-r--r--examples/qml/toys/clocks/clocks.qml88
-rw-r--r--examples/qml/toys/clocks/content/Clock.qml (renamed from examples/qtquick/modelviews/parallax/content/Clock.qml)0
-rw-r--r--examples/qml/toys/clocks/content/QuitButton.qml (renamed from examples/qtquick/modelviews/parallax/content/QuitButton.qml)0
-rw-r--r--examples/qml/toys/clocks/content/arrow.pngbin0 -> 692 bytes
-rw-r--r--examples/qml/toys/clocks/content/background.png (renamed from examples/qtquick/modelviews/parallax/content/background.png)bin46895 -> 46895 bytes
-rw-r--r--examples/qml/toys/clocks/content/center.png (renamed from examples/qtquick/modelviews/parallax/content/center.png)bin765 -> 765 bytes
-rw-r--r--examples/qml/toys/clocks/content/clock-night.png (renamed from examples/qtquick/modelviews/parallax/content/clock-night.png)bin23359 -> 23359 bytes
-rw-r--r--examples/qml/toys/clocks/content/clock.png (renamed from examples/qtquick/modelviews/parallax/content/clock.png)bin20653 -> 20653 bytes
-rw-r--r--examples/qml/toys/clocks/content/hour.png (renamed from examples/qtquick/modelviews/parallax/content/hour.png)bin625 -> 625 bytes
-rw-r--r--examples/qml/toys/clocks/content/minute.png (renamed from examples/qtquick/modelviews/parallax/content/minute.png)bin625 -> 625 bytes
-rw-r--r--examples/qml/toys/clocks/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/qml/toys/clocks/content/second.png (renamed from examples/qtquick/modelviews/parallax/content/second.png)bin303 -> 303 bytes
-rw-r--r--examples/qml/toys/corkboards/content/Day.qml (renamed from examples/qtquick/touchinteraction/flickable/content/Day.qml)0
-rw-r--r--examples/qml/toys/corkboards/content/cork.jpg (renamed from examples/qtquick/touchinteraction/flickable/content/cork.jpg)bin149337 -> 149337 bytes
-rw-r--r--examples/qml/toys/corkboards/content/note-yellow.png (renamed from examples/qtquick/touchinteraction/flickable/content/note-yellow.png)bin54559 -> 54559 bytes
-rw-r--r--examples/qml/toys/corkboards/content/tack.png (renamed from examples/qtquick/touchinteraction/flickable/content/tack.png)bin7282 -> 7282 bytes
-rw-r--r--examples/qml/toys/corkboards/corkboards.qml (renamed from examples/qtquick/touchinteraction/flickable/corkboards.qml)0
-rw-r--r--examples/qml/toys/dynamicscene/content/Button.qml80
-rw-r--r--examples/qml/toys/dynamicscene/content/GenericSceneItem.qml49
-rw-r--r--examples/qml/toys/dynamicscene/content/PaletteItem.qml59
-rw-r--r--examples/qml/toys/dynamicscene/content/PerspectiveItem.qml65
-rw-r--r--examples/qml/toys/dynamicscene/content/Sun.qml78
-rw-r--r--examples/qml/toys/dynamicscene/content/images/NOTE1
-rw-r--r--examples/qml/toys/dynamicscene/content/images/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/qml/toys/dynamicscene/content/images/moon.pngbin0 -> 1757 bytes
-rw-r--r--examples/qml/toys/dynamicscene/content/images/rabbit_brown.pngbin0 -> 1245 bytes
-rw-r--r--examples/qml/toys/dynamicscene/content/images/rabbit_bw.pngbin0 -> 1759 bytes
-rw-r--r--examples/qml/toys/dynamicscene/content/images/star.pngbin0 -> 349 bytes
-rw-r--r--examples/qml/toys/dynamicscene/content/images/sun.pngbin0 -> 8153 bytes
-rw-r--r--examples/qml/toys/dynamicscene/content/images/tree_s.pngbin0 -> 3406 bytes
-rw-r--r--examples/qml/toys/dynamicscene/content/itemCreation.js62
-rw-r--r--examples/qml/toys/dynamicscene/dynamicscene.qml275
-rw-r--r--examples/qml/toys/tic-tac-toe/content/Button.qml79
-rw-r--r--examples/qml/toys/tic-tac-toe/content/TicTac.qml60
-rw-r--r--examples/qml/toys/tic-tac-toe/content/pics/board.pngbin0 -> 12258 bytes
-rw-r--r--examples/qml/toys/tic-tac-toe/content/pics/o.pngbin0 -> 1470 bytes
-rw-r--r--examples/qml/toys/tic-tac-toe/content/pics/x.pngbin0 -> 1331 bytes
-rw-r--r--examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js149
-rw-r--r--examples/qml/toys/tic-tac-toe/tic-tac-toe.qml123
-rw-r--r--examples/qml/toys/tvtennis/tvtennis.qml109
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml102
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml90
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml98
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml121
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml98
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml143
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml120
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml98
-rw-r--r--examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml219
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/app.qml60
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro5
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/main.cpp57
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/piechart.cpp79
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/piechart.h71
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/app.qml66
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro5
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/main.cpp57
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/piechart.cpp84
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/piechart.h84
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/app.qml74
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro5
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/main.cpp57
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp86
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/piechart.h84
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml60
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro7
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp66
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp70
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h78
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp66
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h66
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/app.qml70
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro7
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/main.cpp58
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp72
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/piechart.h75
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp86
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h76
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir1
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/app.qml69
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro18
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp54
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h55
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp71
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/piechart.h69
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp86
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/pieslice.h74
-rw-r--r--examples/qml/tutorials/extending/extending.pro10
-rw-r--r--examples/qml/tutorials/helloworld/Cell.qml72
-rw-r--r--examples/qml/tutorials/helloworld/tutorial1.qml63
-rw-r--r--examples/qml/tutorials/helloworld/tutorial2.qml72
-rw-r--r--examples/qml/tutorials/helloworld/tutorial3.qml91
-rw-r--r--examples/qml/tutorials/samegame/samegame1/Block.qml53
-rw-r--r--examples/qml/tutorials/samegame/samegame1/Button.qml83
-rw-r--r--examples/qml/tutorials/samegame/samegame1/samegame.qml82
-rw-r--r--examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject16
-rw-r--r--examples/qml/tutorials/samegame/samegame2/Block.qml51
-rw-r--r--examples/qml/tutorials/samegame/samegame2/Button.qml81
-rw-r--r--examples/qml/tutorials/samegame/samegame2/samegame.js63
-rw-r--r--examples/qml/tutorials/samegame/samegame2/samegame.qml85
-rw-r--r--examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject16
-rw-r--r--examples/qml/tutorials/samegame/samegame3/Block.qml63
-rw-r--r--examples/qml/tutorials/samegame/samegame3/Button.qml81
-rw-r--r--examples/qml/tutorials/samegame/samegame3/Dialog.qml71
-rw-r--r--examples/qml/tutorials/samegame/samegame3/samegame.js174
-rw-r--r--examples/qml/tutorials/samegame/samegame3/samegame.qml109
-rw-r--r--examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject16
-rw-r--r--examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml122
-rw-r--r--examples/qml/tutorials/samegame/samegame4/content/Button.qml81
-rw-r--r--examples/qml/tutorials/samegame/samegame4/content/Dialog.qml107
-rwxr-xr-xexamples/qml/tutorials/samegame/samegame4/content/samegame.js226
-rw-r--r--examples/qml/tutorials/samegame/samegame4/highscores/README1
-rwxr-xr-xexamples/qml/tutorials/samegame/samegame4/highscores/score_data.xml2
-rwxr-xr-xexamples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl28
-rwxr-xr-xexamples/qml/tutorials/samegame/samegame4/highscores/scores.php31
-rw-r--r--examples/qml/tutorials/samegame/samegame4/samegame.qml115
-rw-r--r--examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject16
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/background.jpgbin0 -> 36473 bytes
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/blueStar.pngbin0 -> 278 bytes
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/blueStone.pngbin0 -> 3054 bytes
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/greenStar.pngbin0 -> 273 bytes
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/greenStone.pngbin0 -> 2932 bytes
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/redStar.pngbin0 -> 274 bytes
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/redStone.pngbin0 -> 2902 bytes
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/star.pngbin0 -> 262 bytes
-rw-r--r--examples/qml/tutorials/samegame/shared/pics/yellowStone.pngbin0 -> 3056 bytes
-rw-r--r--examples/qml/tutorials/tutorials.pro5
-rw-r--r--examples/qml/tutorials/tutorials.qmlproject14
-rw-r--r--examples/qml/twitter/TwitterCore/Button.qml90
-rw-r--r--examples/qml/twitter/TwitterCore/FatDelegate.qml105
-rw-r--r--examples/qml/twitter/TwitterCore/Input.qml65
-rw-r--r--examples/qml/twitter/TwitterCore/Loading.qml49
-rw-r--r--examples/qml/twitter/TwitterCore/MultiTitleBar.qml60
-rw-r--r--examples/qml/twitter/TwitterCore/RssModel.qml80
-rw-r--r--examples/qml/twitter/TwitterCore/SearchView.qml124
-rw-r--r--examples/qml/twitter/TwitterCore/TitleBar.qml130
-rw-r--r--examples/qml/twitter/TwitterCore/ToolBar.qml64
-rw-r--r--examples/qml/twitter/TwitterCore/UserModel.qml66
-rw-r--r--examples/qml/twitter/TwitterCore/images/gloss.pngbin0 -> 1236 bytes
-rw-r--r--examples/qml/twitter/TwitterCore/images/lineedit.pngbin0 -> 1415 bytes
-rw-r--r--examples/qml/twitter/TwitterCore/images/lineedit.sci5
-rw-r--r--examples/qml/twitter/TwitterCore/images/loading.pngbin0 -> 813 bytes
-rw-r--r--examples/qml/twitter/TwitterCore/images/quit.pngbin0 -> 2369 bytes
-rw-r--r--examples/qml/twitter/TwitterCore/images/stripes.pngbin0 -> 257 bytes
-rw-r--r--examples/qml/twitter/TwitterCore/images/titlebar.pngbin0 -> 1436 bytes
-rw-r--r--examples/qml/twitter/TwitterCore/images/titlebar.sci5
-rw-r--r--examples/qml/twitter/TwitterCore/images/toolbutton.pngbin0 -> 2550 bytes
-rw-r--r--examples/qml/twitter/TwitterCore/images/toolbutton.sci5
-rw-r--r--examples/qml/twitter/TwitterCore/qmldir10
-rw-r--r--examples/qml/twitter/twitter.qml135
-rw-r--r--examples/qml/twitter/twitter.qmlproject16
-rw-r--r--examples/qml/ui-components/dialcontrol/content/Dial.qml86
-rw-r--r--examples/qml/ui-components/dialcontrol/content/QuitButton.qml52
-rw-r--r--examples/qml/ui-components/dialcontrol/content/background.pngbin0 -> 35876 bytes
-rw-r--r--examples/qml/ui-components/dialcontrol/content/needle.pngbin0 -> 342 bytes
-rw-r--r--examples/qml/ui-components/dialcontrol/content/needle_shadow.pngbin0 -> 632 bytes
-rw-r--r--examples/qml/ui-components/dialcontrol/content/overlay.pngbin0 -> 3564 bytes
-rw-r--r--examples/qml/ui-components/dialcontrol/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/qml/ui-components/dialcontrol/dialcontrol.qml98
-rw-r--r--examples/qml/ui-components/flipable/content/5_heart.pngbin0 -> 3872 bytes
-rw-r--r--examples/qml/ui-components/flipable/content/9_club.pngbin0 -> 6135 bytes
-rw-r--r--examples/qml/ui-components/flipable/content/Card.qml80
-rw-r--r--examples/qml/ui-components/flipable/content/back.pngbin0 -> 1418 bytes
-rw-r--r--examples/qml/ui-components/flipable/flipable.qml55
-rw-r--r--examples/qml/ui-components/progressbar/content/ProgressBar.qml83
-rw-r--r--examples/qml/ui-components/progressbar/content/background.pngbin0 -> 426 bytes
-rw-r--r--examples/qml/ui-components/progressbar/main.qml73
-rw-r--r--examples/qml/ui-components/scrollbar/ScrollBar.qml74
-rw-r--r--examples/qml/ui-components/scrollbar/main.qml93
-rw-r--r--examples/qml/ui-components/scrollbar/pics/niagara_falls.jpgbin0 -> 142510 bytes
-rw-r--r--examples/qml/ui-components/scrollbar/scrollbar.qmlproject16
-rw-r--r--examples/qml/ui-components/searchbox/SearchBox.qml109
-rw-r--r--examples/qml/ui-components/searchbox/images/clear.pngbin0 -> 429 bytes
-rw-r--r--examples/qml/ui-components/searchbox/images/lineedit-bg-focus.pngbin0 -> 526 bytes
-rw-r--r--examples/qml/ui-components/searchbox/images/lineedit-bg.pngbin0 -> 426 bytes
-rw-r--r--examples/qml/ui-components/searchbox/main.qml60
-rw-r--r--examples/qml/ui-components/searchbox/searchbox.qmlproject16
-rw-r--r--examples/qml/ui-components/slideswitch/content/Switch.qml117
-rw-r--r--examples/qml/ui-components/slideswitch/content/background.pngbin0 -> 3091 bytes
-rw-r--r--examples/qml/ui-components/slideswitch/content/background.svg23
-rw-r--r--examples/qml/ui-components/slideswitch/content/knob.pngbin0 -> 3101 bytes
-rw-r--r--examples/qml/ui-components/slideswitch/content/knob.svg867
-rw-r--r--examples/qml/ui-components/slideswitch/slideswitch.qml51
-rw-r--r--examples/qml/ui-components/spinner/content/Spinner.qml70
-rw-r--r--examples/qml/ui-components/spinner/content/spinner-bg.pngbin0 -> 345 bytes
-rw-r--r--examples/qml/ui-components/spinner/content/spinner-select.pngbin0 -> 320 bytes
-rw-r--r--examples/qml/ui-components/spinner/main.qml61
-rw-r--r--examples/qml/ui-components/spinner/spinner.qmlproject16
-rw-r--r--examples/qml/ui-components/tabwidget/TabWidget.qml102
-rw-r--r--examples/qml/ui-components/tabwidget/main.qml99
-rw-r--r--examples/qml/ui-components/tabwidget/tab.pngbin0 -> 507 bytes
-rw-r--r--examples/qml/ui-components/tabwidget/tabwidget.qmlproject16
-rw-r--r--examples/qml/window/Window.qml58
-rw-r--r--examples/qml/window/screen/screenInfo.qml90
-rw-r--r--examples/qml/window/standalone.qml71
-rw-r--r--examples/qml/window/window.cpp58
-rw-r--r--examples/qml/window/window.pro5
-rw-r--r--examples/qml/xml/xmlhttprequest/data.xml5
-rw-r--r--examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml95
-rw-r--r--examples/qtquick/accessibility/accessibility.pro10
-rw-r--r--examples/qtquick/accessibility/accessibility.qml110
-rw-r--r--examples/qtquick/accessibility/content/Button.qml80
-rw-r--r--examples/qtquick/animation/animation.pro10
-rw-r--r--examples/qtquick/canvas/stockchart/plugin.cpp60
-rw-r--r--examples/qtquick/canvas/stockchart/stockchart.pro20
-rw-r--r--examples/qtquick/draganddrop/draganddrop.pro10
-rw-r--r--examples/qtquick/imageelements/imageelements.pro10
-rw-r--r--examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.pro10
-rw-r--r--examples/qtquick/modelviews/abstractitemmodel/main.cpp70
-rw-r--r--examples/qtquick/modelviews/listview/content/ToggleButton.qml58
-rw-r--r--examples/qtquick/modelviews/objectlistmodel/main.cpp78
-rw-r--r--examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro6
-rw-r--r--examples/qtquick/modelviews/stringlistmodel/main.cpp77
-rw-r--r--examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro4
-rw-r--r--examples/qtquick/openglunderqml/openglunderqml.pro6
-rw-r--r--examples/qtquick/painteditem/smile/main.cpp96
-rw-r--r--examples/qtquick/painteditem/smile/smile.pro11
-rw-r--r--examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h55
-rw-r--r--examples/qtquick/painteditem/textballoons/textballoons.pro25
-rw-r--r--examples/qtquick/shadereffects/shadereffects.qml315
-rw-r--r--examples/quick/accessibility/accessibility.pro10
-rw-r--r--examples/quick/accessibility/accessibility.qml110
-rw-r--r--examples/quick/accessibility/accessibility.qmlproject (renamed from examples/qtquick/accessibility/accessibility.qmlproject)0
-rw-r--r--examples/quick/accessibility/content/Button.qml80
-rw-r--r--examples/quick/accessibility/main.cpp (renamed from examples/qtquick/accessibility/main.cpp)0
-rw-r--r--examples/quick/animation/animation.pro10
-rw-r--r--examples/quick/animation/animation.qml (renamed from examples/qtquick/animation/animation.qml)0
-rw-r--r--examples/quick/animation/animation.qmlproject16
-rw-r--r--examples/quick/animation/basics/color-animation.qml (renamed from examples/qtquick/animation/basics/color-animation.qml)0
-rw-r--r--examples/quick/animation/basics/images/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/quick/animation/basics/images/moon.pngbin0 -> 2433 bytes
-rw-r--r--examples/quick/animation/basics/images/shadow.pngbin0 -> 425 bytes
-rw-r--r--examples/quick/animation/basics/images/star.pngbin0 -> 349 bytes
-rw-r--r--examples/quick/animation/basics/images/sun.pngbin0 -> 8153 bytes
-rw-r--r--examples/quick/animation/basics/property-animation.qml105
-rw-r--r--examples/quick/animation/behaviors/SideRect.qml62
-rw-r--r--examples/quick/animation/behaviors/behavior-example.qml (renamed from examples/qtquick/animation/behaviors/behavior-example.qml)0
-rw-r--r--examples/quick/animation/behaviors/tvtennis.qml (renamed from examples/qtquick/animation/behaviors/tvtennis.qml)0
-rw-r--r--examples/quick/animation/behaviors/wigglytext.qml (renamed from examples/qtquick/animation/behaviors/wigglytext.qml)0
-rw-r--r--examples/quick/animation/easing/content/QuitButton.qml52
-rw-r--r--examples/quick/animation/easing/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/animation/easing/easing.qml (renamed from examples/qtquick/animation/easing/easing.qml)0
-rw-r--r--examples/quick/animation/main.cpp (renamed from examples/qtquick/animation/main.cpp)0
-rw-r--r--examples/quick/animation/pathanimation/pathanimation.qml (renamed from examples/qtquick/animation/pathanimation/pathanimation.qml)0
-rw-r--r--examples/quick/animation/pathinterpolator/pathinterpolator.qml (renamed from examples/qtquick/animation/pathinterpolator/pathinterpolator.qml)0
-rw-r--r--examples/quick/animation/states/qt-logo.png (renamed from tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png)bin5149 -> 5149 bytes
-rw-r--r--examples/quick/animation/states/states.qml101
-rw-r--r--examples/quick/animation/states/transitions.qml130
-rw-r--r--examples/quick/canvas/bezierCurve/bezierCurve.qml124
-rw-r--r--examples/quick/canvas/clip/clip.qml150
-rw-r--r--examples/quick/canvas/contents/Button.qml87
-rw-r--r--examples/quick/canvas/contents/ScrollBar.qml74
-rw-r--r--examples/quick/canvas/contents/Slider.qml115
-rw-r--r--examples/quick/canvas/contents/Stocks.qml147
-rw-r--r--examples/quick/canvas/contents/TitleBar.qml70
-rw-r--r--examples/quick/canvas/contents/ToolBar.qml69
-rw-r--r--examples/quick/canvas/contents/images/button-pressed.pngbin0 -> 571 bytes
-rw-r--r--examples/quick/canvas/contents/images/button.pngbin0 -> 564 bytes
-rw-r--r--examples/quick/canvas/contents/images/default.svg82
-rwxr-xr-xexamples/quick/canvas/contents/images/gloss.pngbin0 -> 1236 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/lineedit.pngbin0 -> 1415 bytes
-rw-r--r--examples/quick/canvas/contents/images/lineedit.sci5
-rwxr-xr-xexamples/quick/canvas/contents/images/quit.pngbin0 -> 2369 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/stripes.pngbin0 -> 257 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/titlebar.pngbin0 -> 1436 bytes
-rw-r--r--examples/quick/canvas/contents/images/titlebar.sci5
-rwxr-xr-xexamples/quick/canvas/contents/images/toolbutton.pngbin0 -> 2550 bytes
-rw-r--r--examples/quick/canvas/contents/images/toolbutton.sci5
-rw-r--r--examples/quick/canvas/contents/qt-logo.pngbin0 -> 23519 bytes
-rw-r--r--examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml128
-rw-r--r--examples/quick/canvas/roundedrect/roundedrect.qml125
-rw-r--r--examples/quick/canvas/smile/smile.qml128
-rw-r--r--examples/quick/canvas/squircle/squircle.pngbin0 -> 771 bytes
-rw-r--r--examples/quick/canvas/squircle/squircle.qml155
-rw-r--r--examples/quick/canvas/stockchart/README5
-rw-r--r--examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir1
-rw-r--r--examples/quick/canvas/stockchart/model.cpp255
-rw-r--r--examples/quick/canvas/stockchart/model.h166
-rw-r--r--examples/quick/canvas/stockchart/plugin.cpp60
-rw-r--r--examples/quick/canvas/stockchart/stock.qml726
-rw-r--r--examples/quick/canvas/stockchart/stockchart.pro20
-rw-r--r--examples/quick/canvas/tiger/tiger.js721
-rw-r--r--examples/quick/canvas/tiger/tiger.qml129
-rw-r--r--examples/quick/canvas/twitterfriends/TwitterUser.qml294
-rw-r--r--examples/quick/canvas/twitterfriends/cache.js42
-rw-r--r--examples/quick/canvas/twitterfriends/twitter.qml141
-rw-r--r--examples/quick/draganddrop/draganddrop.pro10
-rw-r--r--examples/quick/draganddrop/draganddrop.qml (renamed from examples/qtquick/draganddrop/draganddrop.qml)0
-rw-r--r--examples/quick/draganddrop/draganddrop.qmlproject (renamed from examples/qtquick/draganddrop/draganddrop.qmlproject)0
-rw-r--r--examples/quick/draganddrop/main.cpp (renamed from examples/qtquick/draganddrop/main.cpp)0
-rw-r--r--examples/quick/draganddrop/tiles/DragTile.qml (renamed from examples/qtquick/draganddrop/tiles/DragTile.qml)0
-rw-r--r--examples/quick/draganddrop/tiles/DropTile.qml (renamed from examples/qtquick/draganddrop/tiles/DropTile.qml)0
-rw-r--r--examples/quick/draganddrop/tiles/tiles.qml (renamed from examples/qtquick/draganddrop/tiles/tiles.qml)0
-rw-r--r--examples/quick/draganddrop/views/gridview.qml (renamed from examples/qtquick/draganddrop/views/gridview.qml)0
-rw-r--r--examples/quick/imageelements/animatedsprite.qml (renamed from examples/qtquick/imageelements/animatedsprite.qml)0
-rw-r--r--examples/quick/imageelements/borderimage.qml (renamed from examples/qtquick/imageelements/borderimage.qml)0
-rw-r--r--examples/quick/imageelements/content/BearSheet.pngbin0 -> 406337 bytes
-rw-r--r--examples/quick/imageelements/content/BorderImageSelector.qml (renamed from examples/qtquick/imageelements/content/BorderImageSelector.qml)0
-rw-r--r--examples/quick/imageelements/content/ImageCell.qml60
-rw-r--r--examples/quick/imageelements/content/MyBorderImage.qml (renamed from examples/qtquick/imageelements/content/MyBorderImage.qml)0
-rw-r--r--examples/quick/imageelements/content/ShadowRectangle.qml54
-rw-r--r--examples/quick/imageelements/content/bw.pngbin0 -> 1357 bytes
-rw-r--r--examples/quick/imageelements/content/colors-round.sci7
-rw-r--r--examples/quick/imageelements/content/colors-stretch.sci5
-rw-r--r--examples/quick/imageelements/content/colors.png (renamed from tests/auto/qtquick2/qquickborderimage/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--examples/quick/imageelements/content/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--examples/quick/imageelements/content/shadow.pngbin0 -> 588 bytes
-rw-r--r--examples/quick/imageelements/content/speaker.pngbin0 -> 784525 bytes
-rw-r--r--examples/quick/imageelements/image.qml (renamed from examples/qtquick/imageelements/image.qml)0
-rw-r--r--examples/quick/imageelements/imageelements.pro10
-rw-r--r--examples/quick/imageelements/imageelements.qml (renamed from examples/qtquick/imageelements/imageelements.qml)0
-rw-r--r--examples/quick/imageelements/imageelements.qmlproject16
-rw-r--r--examples/quick/imageelements/main.cpp (renamed from examples/qtquick/imageelements/main.cpp)0
-rw-r--r--examples/quick/imageelements/shadows.qml64
-rw-r--r--examples/quick/imageelements/spritesequence.qml (renamed from examples/qtquick/imageelements/spritesequence.qml)0
-rw-r--r--examples/quick/keyinteraction/focus/Core/ContextMenu.qml65
-rw-r--r--examples/quick/keyinteraction/focus/Core/GridMenu.qml105
-rw-r--r--examples/quick/keyinteraction/focus/Core/ListMenu.qml105
-rw-r--r--examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml85
-rw-r--r--examples/quick/keyinteraction/focus/Core/images/arrow.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/keyinteraction/focus/Core/images/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--examples/quick/keyinteraction/focus/focus.qml111
-rw-r--r--examples/quick/modelviews/abstractitemmodel/abstractitemmodel.pro10
-rw-r--r--examples/quick/modelviews/abstractitemmodel/abstractitemmodel.qrc6
-rw-r--r--examples/quick/modelviews/abstractitemmodel/main.cpp70
-rw-r--r--examples/quick/modelviews/abstractitemmodel/model.cpp90
-rw-r--r--examples/quick/modelviews/abstractitemmodel/model.h83
-rw-r--r--examples/quick/modelviews/abstractitemmodel/view.qml50
-rw-r--r--examples/quick/modelviews/gridview/gridview-example.qml93
-rw-r--r--examples/quick/modelviews/gridview/pics/AddressBook_48.pngbin0 -> 3350 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/AudioPlayer_48.pngbin0 -> 3806 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/Camera_48.pngbin0 -> 3540 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/DateBook_48.pngbin0 -> 2610 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/EMail_48.pngbin0 -> 3655 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/TodoList_48.pngbin0 -> 3429 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/VideoPlayer_48.pngbin0 -> 4151 bytes
-rw-r--r--examples/quick/modelviews/listview/content/PetsModel.qml98
-rw-r--r--examples/quick/modelviews/listview/content/PressAndHoldButton.qml82
-rw-r--r--examples/quick/modelviews/listview/content/RecipesModel.qml129
-rw-r--r--examples/quick/modelviews/listview/content/TextButton.qml78
-rw-r--r--examples/quick/modelviews/listview/content/ToggleButton.qml58
-rw-r--r--examples/quick/modelviews/listview/content/pics/arrow-down.pngbin0 -> 594 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/arrow-up.pngbin0 -> 692 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/fruit-salad.jpgbin0 -> 17952 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/hamburger.jpgbin0 -> 8572 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/lemonade.jpgbin0 -> 6645 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/list-delete.pngbin0 -> 831 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/minus-sign.pngbin0 -> 250 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/moreDown.pngbin0 -> 217 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/moreUp.pngbin0 -> 212 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/pancakes.jpgbin0 -> 9163 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/plus-sign.pngbin0 -> 462 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/vegetable-soup.jpgbin0 -> 8639 bytes
-rw-r--r--examples/quick/modelviews/listview/dynamiclist.qml203
-rw-r--r--examples/quick/modelviews/listview/expandingdelegates.qml202
-rw-r--r--examples/quick/modelviews/listview/highlight.qml99
-rw-r--r--examples/quick/modelviews/listview/highlightranges.qml122
-rw-r--r--examples/quick/modelviews/listview/sections.qml127
-rw-r--r--examples/quick/modelviews/modelviews.pro8
-rw-r--r--examples/quick/modelviews/modelviews.qml (renamed from examples/qtquick/modelviews/modelviews.qml)0
-rw-r--r--examples/quick/modelviews/modelviews.qmlproject16
-rw-r--r--examples/quick/modelviews/objectlistmodel/dataobject.cpp78
-rw-r--r--examples/quick/modelviews/objectlistmodel/dataobject.h76
-rw-r--r--examples/quick/modelviews/objectlistmodel/main.cpp78
-rw-r--r--examples/quick/modelviews/objectlistmodel/objectlistmodel.pro6
-rw-r--r--examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject14
-rw-r--r--examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc5
-rw-r--r--examples/quick/modelviews/objectlistmodel/view.qml55
-rw-r--r--examples/quick/modelviews/package/Delegate.qml88
-rw-r--r--examples/quick/modelviews/package/view.qml (renamed from examples/qtquick/modelviews/package/view.qml)0
-rw-r--r--examples/quick/modelviews/parallax/content/Clock.qml143
-rw-r--r--examples/quick/modelviews/parallax/content/ParallaxView.qml123
-rw-r--r--examples/quick/modelviews/parallax/content/QuitButton.qml52
-rw-r--r--examples/quick/modelviews/parallax/content/Smiley.qml84
-rw-r--r--examples/quick/modelviews/parallax/content/background.pngbin0 -> 46895 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/center.pngbin0 -> 765 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/clock-night.pngbin0 -> 23359 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/clock.pngbin0 -> 20653 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/hour.pngbin0 -> 625 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/minute.pngbin0 -> 625 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/background.jpgbin0 -> 209814 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/home-page.pngbin0 -> 3051 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/home-page.svg445
-rw-r--r--examples/quick/modelviews/parallax/content/pics/shadow.pngbin0 -> 425 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/yast-joystick.pngbin0 -> 2723 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/yast-wol.pngbin0 -> 3769 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/second.pngbin0 -> 303 bytes
-rw-r--r--examples/quick/modelviews/parallax/parallax.qml (renamed from examples/qtquick/modelviews/parallax/parallax.qml)0
-rw-r--r--examples/quick/modelviews/pathview/pathview-example.qml107
-rw-r--r--examples/quick/modelviews/pathview/pics/AddressBook_48.pngbin0 -> 3350 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/AudioPlayer_48.pngbin0 -> 3806 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/Camera_48.pngbin0 -> 3540 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/DateBook_48.pngbin0 -> 2610 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/EMail_48.pngbin0 -> 3655 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/TodoList_48.pngbin0 -> 3429 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/VideoPlayer_48.pngbin0 -> 4151 bytes
-rw-r--r--examples/quick/modelviews/stringlistmodel/main.cpp77
-rw-r--r--examples/quick/modelviews/stringlistmodel/stringlistmodel.pro4
-rw-r--r--examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc5
-rw-r--r--examples/quick/modelviews/stringlistmodel/view.qml54
-rw-r--r--examples/quick/modelviews/visualdatamodel/dragselection.qml200
-rw-r--r--examples/quick/modelviews/visualdatamodel/slideshow.qml156
-rw-r--r--examples/quick/modelviews/visualdatamodel/sortedmodel.qml141
-rw-r--r--examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject14
-rw-r--r--examples/quick/modelviews/visualitemmodel/visualitemmodel.qml (renamed from examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml)0
-rw-r--r--examples/quick/mousearea/mousearea-example.qml176
-rw-r--r--examples/quick/openglunderqml/main.cpp60
-rw-r--r--examples/quick/openglunderqml/main.qml78
-rw-r--r--examples/quick/openglunderqml/openglunderqml.pro6
-rw-r--r--examples/quick/openglunderqml/squircle.cpp123
-rw-r--r--examples/quick/openglunderqml/squircle.h76
-rw-r--r--examples/quick/painteditem/painteditem.pro5
-rw-r--r--examples/quick/painteditem/smile/main.cpp96
-rw-r--r--examples/quick/painteditem/smile/smile.pro11
-rw-r--r--examples/quick/painteditem/smile/smile.qml132
-rw-r--r--examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h55
-rw-r--r--examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir1
-rw-r--r--examples/quick/painteditem/textballoons/textballoon.cpp92
-rw-r--r--examples/quick/painteditem/textballoons/textballoon.h68
-rw-r--r--examples/quick/painteditem/textballoons/textballoon.json (renamed from examples/qtquick/painteditem/textballoons/textballoon.json)0
-rw-r--r--examples/quick/painteditem/textballoons/textballoons.pro25
-rw-r--r--examples/quick/painteditem/textballoons/textballoons.qml110
-rw-r--r--examples/quick/positioners/content/Button.qml78
-rw-r--r--examples/quick/positioners/content/add.pngbin0 -> 810 bytes
-rw-r--r--examples/quick/positioners/content/del.pngbin0 -> 488 bytes
-rw-r--r--examples/quick/positioners/positioners-attachedproperties.qml106
-rw-r--r--examples/quick/positioners/positioners.qml (renamed from examples/qtquick/positioners/positioners.qml)0
-rw-r--r--examples/quick/quick.pro (renamed from examples/qtquick/qtquick.pro)0
-rw-r--r--examples/quick/righttoleft/layoutdirection/layoutdirection.qml246
-rw-r--r--examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject16
-rw-r--r--examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml313
-rw-r--r--examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject16
-rw-r--r--examples/quick/righttoleft/textalignment/textalignment.qml427
-rw-r--r--examples/quick/righttoleft/textalignment/textalignment.qmlproject16
-rw-r--r--examples/quick/shadereffects/content/Slider.qml93
-rw-r--r--examples/quick/shadereffects/content/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/quick/shadereffects/content/qt-logo.pngbin0 -> 13923 bytes
-rw-r--r--examples/quick/shadereffects/shadereffects.qml315
-rw-r--r--examples/quick/text/fonts/availableFonts.qml57
-rw-r--r--examples/quick/text/fonts/banner.qml61
-rw-r--r--examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf (renamed from tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf)bin24544 -> 24544 bytes
-rw-r--r--examples/quick/text/fonts/fonts.qml104
-rw-r--r--examples/quick/text/fonts/hello.qml79
-rw-r--r--examples/quick/text/imgtag/TextWithImage.qml55
-rw-r--r--examples/quick/text/imgtag/images/face-sad.png (renamed from tests/auto/qtquick2/qquicktext/data/images/face-sad.png)bin6148 -> 6148 bytes
-rw-r--r--examples/quick/text/imgtag/images/face-smile-big.pngbin0 -> 6058 bytes
-rw-r--r--examples/quick/text/imgtag/images/face-smile.pngbin0 -> 6446 bytes
-rw-r--r--examples/quick/text/imgtag/images/heart200.png (renamed from tests/auto/qtquick2/qquicktext/data/images/heart200.png)bin8248 -> 8248 bytes
-rw-r--r--examples/quick/text/imgtag/images/qtlogo.pngbin0 -> 6450 bytes
-rw-r--r--examples/quick/text/imgtag/images/starfish_2.png (renamed from tests/auto/qtquick2/qquicktext/data/images/starfish_2.png)bin18243 -> 18243 bytes
-rw-r--r--examples/quick/text/imgtag/imgtag.qml101
-rw-r--r--examples/quick/text/styledtext-layout.qml107
-rw-r--r--examples/quick/text/text.qml (renamed from examples/qtquick/text/text.qml)0
-rw-r--r--examples/quick/text/text.qmlproject16
-rw-r--r--examples/quick/text/textselection/pics/endHandle.pngbin0 -> 185 bytes
-rw-r--r--examples/quick/text/textselection/pics/endHandle.sci5
-rw-r--r--examples/quick/text/textselection/pics/startHandle.pngbin0 -> 178 bytes
-rw-r--r--examples/quick/text/textselection/pics/startHandle.sci5
-rw-r--r--examples/quick/text/textselection/textselection.qml211
-rw-r--r--examples/quick/threading/threadedlistmodel/dataloader.js49
-rw-r--r--examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject56
-rw-r--r--examples/quick/threading/threadedlistmodel/timedisplay.qml76
-rw-r--r--examples/quick/threading/workerscript/workerscript.js15
-rw-r--r--examples/quick/threading/workerscript/workerscript.qml83
-rw-r--r--examples/quick/threading/workerscript/workerscript.qmlproject16
-rw-r--r--examples/quick/touchinteraction/flickable/content/Day.qml153
-rw-r--r--examples/quick/touchinteraction/flickable/content/cork.jpgbin0 -> 149337 bytes
-rw-r--r--examples/quick/touchinteraction/flickable/content/note-yellow.pngbin0 -> 54559 bytes
-rw-r--r--examples/quick/touchinteraction/flickable/content/tack.pngbin0 -> 7282 bytes
-rw-r--r--examples/quick/touchinteraction/flickable/corkboards.qml116
-rw-r--r--examples/quick/touchinteraction/multipointtouch/bearwhack.qml133
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml70
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/Bear0.pngbin0 -> 15163 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/Bear1.pngbin0 -> 99378 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/Bear2.pngbin0 -> 80759 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/Bear3.pngbin0 -> 21122 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/BearB.pngbin0 -> 18667 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml (renamed from examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml)0
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml65
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/blur-circle.pngbin0 -> 4279 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/blur-circle3.pngbin0 -> 5148 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/heart-blur.pngbin0 -> 5406 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/title.pngbin0 -> 81252 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/multiflame.qml91
-rw-r--r--examples/quick/touchinteraction/pincharea/flickresize.qml97
-rw-r--r--examples/quick/touchinteraction/pincharea/qt-logo.jpgbin0 -> 40886 bytes
-rw-r--r--examples/quick/touchinteraction/touchinteraction.qml (renamed from examples/qtquick/touchinteraction/touchinteraction.qml)0
-rw-r--r--examples/quick/touchinteraction/touchinteraction.qmlproject16
-rw-r--r--examples/tutorials/extending/chapter1-basics/chapter1-basics.pro2
-rw-r--r--examples/tutorials/extending/chapter2-methods/chapter2-methods.pro2
-rw-r--r--examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro2
-rw-r--r--examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro2
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro2
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/piechart.cpp6
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/piechart.h6
-rw-r--r--examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro2
-rw-r--r--examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp2
-rw-r--r--examples/tutorials/extending/chapter6-plugins/chartsplugin.h6
-rw-r--r--examples/tutorials/extending/chapter6-plugins/piechart.cpp6
-rw-r--r--examples/tutorials/extending/chapter6-plugins/piechart.h6
-rw-r--r--examples/tutorials/gettingStartedQml/core/Button.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/core/EditMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/core/FileDialog.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/core/FileMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/core/MenuBar.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/core/TextArea.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp4
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h10
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/directory.cpp16
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/directory.h8
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/file.cpp2
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/file.h2
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/filedialog.pro2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part0/Button.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part1/Button.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part2/Button.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part3/Button.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part4/Button.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp6
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h8
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp18
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h8
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h2
-rw-r--r--examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro2
-rw-r--r--examples/tutorials/gettingStartedQml/texteditor.qml2
-rw-r--r--examples/window/window.cpp8
-rw-r--r--examples/window/window.pro2
-rw-r--r--modules/qt_declarative.pri181
-rw-r--r--modules/qt_qml.pri17
-rw-r--r--modules/qt_qmltest.pri2
-rw-r--r--modules/qt_quick.pri2
-rw-r--r--src/compatibility/compatibility.pro33
-rw-r--r--src/declarative/animations/qabstractanimationjob.cpp544
-rw-r--r--src/declarative/animations/qabstractanimationjob_p.h232
-rw-r--r--src/declarative/animations/qanimationgroupjob.cpp164
-rw-r--r--src/declarative/animations/qanimationgroupjob_p.h93
-rw-r--r--src/declarative/animations/qanimationjobutil_p.h59
-rw-r--r--src/declarative/animations/qparallelanimationgroupjob.cpp227
-rw-r--r--src/declarative/animations/qparallelanimationgroupjob_p.h81
-rw-r--r--src/declarative/animations/qpauseanimationjob.cpp71
-rw-r--r--src/declarative/animations/qpauseanimationjob_p.h75
-rw-r--r--src/declarative/animations/qsequentialanimationgroupjob.cpp388
-rw-r--r--src/declarative/animations/qsequentialanimationgroupjob_p.h108
-rw-r--r--src/declarative/debugger/debugger.pri32
-rw-r--r--src/declarative/debugger/qdebugmessageservice.cpp126
-rw-r--r--src/declarative/debugger/qdebugmessageservice_p.h91
-rw-r--r--src/declarative/debugger/qdeclarativedebug.h66
-rw-r--r--src/declarative/debugger/qdeclarativedebugclient.cpp421
-rw-r--r--src/declarative/debugger/qdeclarativedebugclient_p.h131
-rw-r--r--src/declarative/debugger/qdeclarativedebughelper.cpp70
-rw-r--r--src/declarative/debugger/qdeclarativedebughelper_p.h86
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver.cpp539
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver_p.h105
-rw-r--r--src/declarative/debugger/qdeclarativedebugserverconnection_p.h86
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice.cpp268
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice_p.h113
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice_p_p.h82
-rw-r--r--src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h98
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebug.cpp1072
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebug_p.h397
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebugservice.cpp733
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebugservice_p.h136
-rw-r--r--src/declarative/debugger/qdeclarativeinspectorinterface_p.h85
-rw-r--r--src/declarative/debugger/qdeclarativeinspectorservice.cpp184
-rw-r--r--src/declarative/debugger/qdeclarativeinspectorservice_p.h101
-rw-r--r--src/declarative/debugger/qdeclarativeprofilerservice.cpp315
-rw-r--r--src/declarative/debugger/qdeclarativeprofilerservice_p.h302
-rw-r--r--src/declarative/debugger/qpacketprotocol.cpp550
-rw-r--r--src/declarative/debugger/qpacketprotocol_p.h137
-rw-r--r--src/declarative/debugger/qv8debugservice.cpp294
-rw-r--r--src/declarative/debugger/qv8debugservice_p.h105
-rw-r--r--src/declarative/debugger/qv8profilerservice.cpp301
-rw-r--r--src/declarative/debugger/qv8profilerservice_p.h120
-rw-r--r--src/declarative/declarative.pro34
-rw-r--r--src/declarative/qml/ftw/ftw.pri29
-rw-r--r--src/declarative/qml/ftw/qbitfield_p.h165
-rw-r--r--src/declarative/qml/ftw/qdeclarativepool.cpp92
-rw-r--r--src/declarative/qml/ftw/qdeclarativepool_p.h278
-rw-r--r--src/declarative/qml/ftw/qdeclarativerefcount_p.h192
-rw-r--r--src/declarative/qml/ftw/qdeclarativethread.cpp359
-rw-r--r--src/declarative/qml/ftw/qdeclarativethread_p.h318
-rw-r--r--src/declarative/qml/ftw/qdeclarativetrace.cpp154
-rw-r--r--src/declarative/qml/ftw/qdeclarativetrace_p.h294
-rw-r--r--src/declarative/qml/ftw/qdeletewatcher_p.h113
-rw-r--r--src/declarative/qml/ftw/qfastmetabuilder.cpp313
-rw-r--r--src/declarative/qml/ftw/qfastmetabuilder_p.h206
-rw-r--r--src/declarative/qml/ftw/qfieldlist_p.h426
-rw-r--r--src/declarative/qml/ftw/qfinitestack_p.h186
-rw-r--r--src/declarative/qml/ftw/qflagpointer_p.h338
-rw-r--r--src/declarative/qml/ftw/qhashedstring.cpp490
-rw-r--r--src/declarative/qml/ftw/qhashedstring_p.h1418
-rw-r--r--src/declarative/qml/ftw/qhashfield_p.h120
-rw-r--r--src/declarative/qml/ftw/qintrusivelist.cpp179
-rw-r--r--src/declarative/qml/ftw/qintrusivelist_p.h274
-rw-r--r--src/declarative/qml/ftw/qlazilyallocated_p.h146
-rw-r--r--src/declarative/qml/ftw/qpodvector_p.h173
-rw-r--r--src/declarative/qml/ftw/qpointervaluepair_p.h196
-rw-r--r--src/declarative/qml/ftw/qrecursionwatcher_p.h105
-rw-r--r--src/declarative/qml/ftw/qrecyclepool_p.h220
-rw-r--r--src/declarative/qml/parser/parser.pri19
-rw-r--r--src/declarative/qml/parser/qdeclarativejs.g3016
-rw-r--r--src/declarative/qml/parser/qdeclarativejsast.cpp931
-rw-r--r--src/declarative/qml/parser/qdeclarativejsast_p.h2640
-rw-r--r--src/declarative/qml/parser/qdeclarativejsastfwd_p.h186
-rw-r--r--src/declarative/qml/parser/qdeclarativejsastvisitor.cpp58
-rw-r--r--src/declarative/qml/parser/qdeclarativejsastvisitor_p.h329
-rw-r--r--src/declarative/qml/parser/qdeclarativejsengine_p.cpp161
-rw-r--r--src/declarative/qml/parser/qdeclarativejsengine_p.h126
-rw-r--r--src/declarative/qml/parser/qdeclarativejsglobal_p.h69
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar.cpp1013
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar_p.h211
-rw-r--r--src/declarative/qml/parser/qdeclarativejskeywords_p.h860
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp1166
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer_p.h248
-rw-r--r--src/declarative/qml/parser/qdeclarativejsmemorypool_p.h173
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser.cpp1812
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser_p.h248
-rw-r--r--src/declarative/qml/qdeclarative.h451
-rw-r--r--src/declarative/qml/qdeclarativeaccessors.cpp127
-rw-r--r--src/declarative/qml/qdeclarativeaccessors_p.h165
-rw-r--r--src/declarative/qml/qdeclarativeapplication.cpp124
-rw-r--r--src/declarative/qml/qdeclarativeapplication_p.h87
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp551
-rw-r--r--src/declarative/qml/qdeclarativebinding_p.h219
-rw-r--r--src/declarative/qml/qdeclarativebinding_p_p.h89
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp305
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal_p.h103
-rw-r--r--src/declarative/qml/qdeclarativecleanup.cpp118
-rw-r--r--src/declarative/qml/qdeclarativecleanup_p.h87
-rw-r--r--src/declarative/qml/qdeclarativecompileddata.cpp261
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp3904
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h467
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp1352
-rw-r--r--src/declarative/qml/qdeclarativecomponent.h138
-rw-r--r--src/declarative/qml/qdeclarativecomponent_p.h131
-rw-r--r--src/declarative/qml/qdeclarativecomponentattached_p.h85
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp811
-rw-r--r--src/declarative/qml/qdeclarativecontext.h113
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h334
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp319
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h168
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p_p.h89
-rw-r--r--src/declarative/qml/qdeclarativedata_p.h207
-rw-r--r--src/declarative/qml/qdeclarativedirparser.cpp298
-rw-r--r--src/declarative/qml/qdeclarativedirparser_p.h166
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp1854
-rw-r--r--src/declarative/qml/qdeclarativeengine.h138
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h522
-rw-r--r--src/declarative/qml/qdeclarativeerror.cpp285
-rw-r--r--src/declarative/qml/qdeclarativeerror.h85
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp982
-rw-r--r--src/declarative/qml/qdeclarativeexpression.h121
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h406
-rw-r--r--src/declarative/qml/qdeclarativeextensioninterface.h80
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.cpp171
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.h77
-rw-r--r--src/declarative/qml/qdeclarativeglobal_p.h131
-rw-r--r--src/declarative/qml/qdeclarativeguard_p.h218
-rw-r--r--src/declarative/qml/qdeclarativeimageprovider.cpp334
-rw-r--r--src/declarative/qml/qdeclarativeimageprovider.h95
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp1183
-rw-r--r--src/declarative/qml/qdeclarativeimport_p.h157
-rw-r--r--src/declarative/qml/qdeclarativeincubator.cpp697
-rw-r--r--src/declarative/qml/qdeclarativeincubator.h129
-rw-r--r--src/declarative/qml/qdeclarativeincubator_p.h106
-rw-r--r--src/declarative/qml/qdeclarativeinfo.cpp192
-rw-r--r--src/declarative/qml/qdeclarativeinfo.h103
-rw-r--r--src/declarative/qml/qdeclarativeinstruction.cpp278
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h558
-rw-r--r--src/declarative/qml/qdeclarativeintegercache.cpp82
-rw-r--r--src/declarative/qml/qdeclarativeintegercache_p.h97
-rw-r--r--src/declarative/qml/qdeclarativelist.cpp417
-rw-r--r--src/declarative/qml/qdeclarativelist.h151
-rw-r--r--src/declarative/qml/qdeclarativelist_p.h85
-rw-r--r--src/declarative/qml/qdeclarativelistmodel.cpp2467
-rw-r--r--src/declarative/qml/qdeclarativelistmodel_p.h199
-rw-r--r--src/declarative/qml/qdeclarativelistmodel_p_p.h378
-rw-r--r--src/declarative/qml/qdeclarativelistmodelworkeragent.cpp246
-rw-r--r--src/declarative/qml/qdeclarativelistmodelworkeragent_p.h161
-rw-r--r--src/declarative/qml/qdeclarativelocale.cpp1126
-rw-r--r--src/declarative/qml/qdeclarativelocale_p.h135
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp1359
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h268
-rw-r--r--src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp103
-rw-r--r--src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h65
-rw-r--r--src/declarative/qml/qdeclarativenotifier.cpp115
-rw-r--r--src/declarative/qml/qdeclarativenotifier_p.h206
-rw-r--r--src/declarative/qml/qdeclarativenullablevalue_p_p.h81
-rw-r--r--src/declarative/qml/qdeclarativeopenmetaobject.cpp387
-rw-r--r--src/declarative/qml/qdeclarativeopenmetaobject_p.h130
-rw-r--r--src/declarative/qml/qdeclarativeparserstatus.cpp107
-rw-r--r--src/declarative/qml/qdeclarativeparserstatus.h74
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h263
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp1917
-rw-r--r--src/declarative/qml/qdeclarativeproperty.h142
-rw-r--r--src/declarative/qml/qdeclarativeproperty_p.h171
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp891
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h384
-rw-r--r--src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp79
-rw-r--r--src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h76
-rw-r--r--src/declarative/qml/qdeclarativepropertyvaluesource.cpp76
-rw-r--r--src/declarative/qml/qdeclarativepropertyvaluesource.h69
-rw-r--r--src/declarative/qml/qdeclarativeproxymetaobject.cpp124
-rw-r--r--src/declarative/qml/qdeclarativeproxymetaobject_p.h99
-rw-r--r--src/declarative/qml/qdeclarativerewrite.cpp424
-rw-r--r--src/declarative/qml/qdeclarativerewrite_p.h150
-rw-r--r--src/declarative/qml/qdeclarativescript.cpp1700
-rw-r--r--src/declarative/qml/qdeclarativescript_p.h533
-rw-r--r--src/declarative/qml/qdeclarativescriptstring.cpp157
-rw-r--r--src/declarative/qml/qdeclarativescriptstring.h89
-rw-r--r--src/declarative/qml/qdeclarativescriptstring_p.h64
-rw-r--r--src/declarative/qml/qdeclarativestringconverters.cpp311
-rw-r--r--src/declarative/qml/qdeclarativestringconverters_p.h93
-rw-r--r--src/declarative/qml/qdeclarativetypeloader.cpp1926
-rw-r--r--src/declarative/qml/qdeclarativetypeloader_p.h435
-rw-r--r--src/declarative/qml/qdeclarativetypenamecache.cpp127
-rw-r--r--src/declarative/qml/qdeclarativetypenamecache_p.h187
-rw-r--r--src/declarative/qml/qdeclarativetypenotavailable.cpp53
-rw-r--r--src/declarative/qml/qdeclarativetypenotavailable_p.h64
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp868
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h635
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp1370
-rw-r--r--src/declarative/qml/qdeclarativevme_p.h238
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject.cpp1110
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject_p.h221
-rw-r--r--src/declarative/qml/qdeclarativewatcher.cpp188
-rw-r--r--src/declarative/qml/qdeclarativewatcher_p.h94
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp730
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript_p.h130
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp1797
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest_p.h73
-rw-r--r--src/declarative/qml/qlistmodelinterface.cpp104
-rw-r--r--src/declarative/qml/qlistmodelinterface_p.h83
-rw-r--r--src/declarative/qml/qml.pri125
-rw-r--r--src/declarative/qml/rewriter/textwriter.cpp217
-rw-r--r--src/declarative/qml/rewriter/textwriter_p.h101
-rw-r--r--src/declarative/qml/v4/qv4bindings.cpp1615
-rw-r--r--src/declarative/qml/v4/qv4bindings_p.h155
-rw-r--r--src/declarative/qml/v4/qv4compiler.cpp1419
-rw-r--r--src/declarative/qml/v4/qv4compiler_p.h105
-rw-r--r--src/declarative/qml/v4/qv4compiler_p_p.h246
-rw-r--r--src/declarative/qml/v4/qv4instruction.cpp421
-rw-r--r--src/declarative/qml/v4/qv4instruction_p.h435
-rw-r--r--src/declarative/qml/v4/qv4ir.cpp883
-rw-r--r--src/declarative/qml/v4/qv4ir_p.h605
-rw-r--r--src/declarative/qml/v4/qv4irbuilder.cpp1305
-rw-r--r--src/declarative/qml/v4/qv4irbuilder_p.h240
-rw-r--r--src/declarative/qml/v4/qv4program_p.h123
-rw-r--r--src/declarative/qml/v8/notes.txt4
-rw-r--r--src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp1321
-rw-r--r--src/declarative/qml/v8/qdeclarativebuiltinfunctions_p.h110
-rw-r--r--src/declarative/qml/v8/qjsconverter_impl_p.h268
-rw-r--r--src/declarative/qml/v8/qjsconverter_p.h111
-rw-r--r--src/declarative/qml/v8/qjsengine.h159
-rw-r--r--src/declarative/qml/v8/qjsengine_p.h75
-rw-r--r--src/declarative/qml/v8/qjsvalue.h160
-rw-r--r--src/declarative/qml/v8/qjsvalue_impl_p.h995
-rw-r--r--src/declarative/qml/v8/qjsvalue_p.h213
-rw-r--r--src/declarative/qml/v8/qjsvalueiterator.h81
-rw-r--r--src/declarative/qml/v8/qjsvalueiterator_impl_p.h139
-rw-r--r--src/declarative/qml/v8/qjsvalueiterator_p.h86
-rw-r--r--src/declarative/qml/v8/qscript_impl_p.h61
-rw-r--r--src/declarative/qml/v8/qscriptisolate_p.h89
-rw-r--r--src/declarative/qml/v8/qscriptoriginalglobalobject_p.h177
-rw-r--r--src/declarative/qml/v8/qscriptshareddata_p.h169
-rw-r--r--src/declarative/qml/v8/qscripttools_p.h86
-rw-r--r--src/declarative/qml/v8/qv8_p.h42
-rw-r--r--src/declarative/qml/v8/qv8bindings.cpp285
-rw-r--r--src/declarative/qml/v8/qv8bindings_p.h148
-rw-r--r--src/declarative/qml/v8/qv8contextwrapper.cpp455
-rw-r--r--src/declarative/qml/v8/qv8contextwrapper_p.h120
-rw-r--r--src/declarative/qml/v8/qv8debug_p.h42
-rw-r--r--src/declarative/qml/v8/qv8domerrors.cpp73
-rw-r--r--src/declarative/qml/v8/qv8domerrors_p.h94
-rw-r--r--src/declarative/qml/v8/qv8engine.cpp1600
-rw-r--r--src/declarative/qml/v8/qv8engine_impl_p.h173
-rw-r--r--src/declarative/qml/v8/qv8engine_p.h631
-rw-r--r--src/declarative/qml/v8/qv8include.cpp244
-rw-r--r--src/declarative/qml/v8/qv8include_p.h113
-rw-r--r--src/declarative/qml/v8/qv8listwrapper.cpp194
-rw-r--r--src/declarative/qml/v8/qv8listwrapper_p.h97
-rw-r--r--src/declarative/qml/v8/qv8profiler_p.h42
-rw-r--r--src/declarative/qml/v8/qv8qobjectwrapper.cpp2113
-rw-r--r--src/declarative/qml/v8/qv8qobjectwrapper_p.h159
-rw-r--r--src/declarative/qml/v8/qv8sequencewrapper.cpp264
-rw-r--r--src/declarative/qml/v8/qv8sequencewrapper_p.h106
-rw-r--r--src/declarative/qml/v8/qv8sequencewrapper_p_p.h503
-rw-r--r--src/declarative/qml/v8/qv8sqlerrors.cpp64
-rw-r--r--src/declarative/qml/v8/qv8sqlerrors_p.h77
-rw-r--r--src/declarative/qml/v8/qv8stringwrapper.cpp78
-rw-r--r--src/declarative/qml/v8/qv8stringwrapper_p.h76
-rw-r--r--src/declarative/qml/v8/qv8typewrapper.cpp314
-rw-r--r--src/declarative/qml/v8/qv8typewrapper_p.h94
-rw-r--r--src/declarative/qml/v8/qv8valuetypewrapper.cpp387
-rw-r--r--src/declarative/qml/v8/qv8valuetypewrapper_p.h104
-rw-r--r--src/declarative/qml/v8/qv8variantresource_p.h81
-rw-r--r--src/declarative/qml/v8/qv8variantwrapper.cpp279
-rw-r--r--src/declarative/qml/v8/qv8variantwrapper_p.h110
-rw-r--r--src/declarative/qml/v8/qv8worker.cpp392
-rw-r--r--src/declarative/qml/v8/qv8worker_p.h75
-rw-r--r--src/declarative/qml/v8/v8.pri45
-rw-r--r--src/declarative/util/qdeclarativepropertymap.cpp309
-rw-r--r--src/declarative/util/qdeclarativepropertymap.h89
-rw-r--r--src/declarative/util/util.pri5
-rw-r--r--src/imports/folderlistmodel/folderlistmodel.pro8
-rw-r--r--src/imports/folderlistmodel/plugin.cpp14
-rw-r--r--src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp697
-rw-r--r--src/imports/folderlistmodel/qdeclarativefolderlistmodel.h169
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp697
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.h169
-rw-r--r--src/imports/localstorage/localstorage.pro4
-rw-r--r--src/imports/localstorage/plugin.cpp46
-rw-r--r--src/imports/qimportbase.pri2
-rw-r--r--src/imports/qtquick2/plugin.cpp8
-rw-r--r--src/imports/qtquick2/qtquick2.pro4
-rw-r--r--src/imports/testlib/main.cpp30
-rw-r--r--src/imports/testlib/signalspy.h6
-rw-r--r--src/imports/testlib/testcase.h6
-rw-r--r--src/imports/testlib/testlib.pro6
-rw-r--r--src/imports/xmllistmodel/plugin.cpp16
-rw-r--r--src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp1160
-rw-r--r--src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h212
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel.cpp1160
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel_p.h212
-rw-r--r--src/imports/xmllistmodel/xmllistmodel.pro8
-rw-r--r--src/plugins/accessible/quick/main.cpp4
-rw-r--r--src/plugins/accessible/quick/qaccessiblequickitem.cpp4
-rw-r--r--src/plugins/accessible/quick/qaccessiblequickitem.h6
-rw-r--r--src/plugins/accessible/quick/qaccessiblequickview.cpp4
-rw-r--r--src/plugins/accessible/quick/qaccessiblequickview.h2
-rw-r--r--src/plugins/accessible/quick/quick.pro2
-rw-r--r--src/plugins/accessible/shared/qaccessiblebase.pri4
-rw-r--r--src/plugins/accessible/shared/qdeclarativeaccessible.cpp161
-rw-r--r--src/plugins/accessible/shared/qdeclarativeaccessible.h96
-rw-r--r--src/plugins/accessible/shared/qqmlaccessible.cpp161
-rw-r--r--src/plugins/accessible/shared/qqmlaccessible.h96
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro4
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp12
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h12
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/qostdevice.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_ost/usbostcomm.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/highlight.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro6
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp6
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h4
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h18
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro6
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp16
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h14
-rw-r--r--src/plugins/qmltooling/shared/abstracttool.cpp2
-rw-r--r--src/plugins/qmltooling/shared/abstracttool.h2
-rw-r--r--src/plugins/qmltooling/shared/abstractviewinspector.cpp30
-rw-r--r--src/plugins/qmltooling/shared/abstractviewinspector.h14
-rw-r--r--src/plugins/qmltooling/shared/qdeclarativeinspectorprotocol.h137
-rw-r--r--src/plugins/qmltooling/shared/qmlinspectorconstants.h4
-rw-r--r--src/plugins/qmltooling/shared/qqmlinspectorprotocol.h137
-rw-r--r--src/qml/animations/animations.pri (renamed from src/declarative/animations/animations.pri)0
-rw-r--r--src/qml/animations/qabstractanimationjob.cpp544
-rw-r--r--src/qml/animations/qabstractanimationjob_p.h233
-rw-r--r--src/qml/animations/qanimationgroupjob.cpp164
-rw-r--r--src/qml/animations/qanimationgroupjob_p.h93
-rw-r--r--src/qml/animations/qanimationjobutil_p.h59
-rw-r--r--src/qml/animations/qparallelanimationgroupjob.cpp227
-rw-r--r--src/qml/animations/qparallelanimationgroupjob_p.h81
-rw-r--r--src/qml/animations/qpauseanimationjob.cpp71
-rw-r--r--src/qml/animations/qpauseanimationjob_p.h75
-rw-r--r--src/qml/animations/qsequentialanimationgroupjob.cpp388
-rw-r--r--src/qml/animations/qsequentialanimationgroupjob_p.h108
-rw-r--r--src/qml/debugger/debugger.pri32
-rw-r--r--src/qml/debugger/qdebugmessageservice.cpp126
-rw-r--r--src/qml/debugger/qdebugmessageservice_p.h91
-rw-r--r--src/qml/debugger/qpacketprotocol.cpp550
-rw-r--r--src/qml/debugger/qpacketprotocol_p.h137
-rw-r--r--src/qml/debugger/qqmldebug.h66
-rw-r--r--src/qml/debugger/qqmldebugclient.cpp421
-rw-r--r--src/qml/debugger/qqmldebugclient_p.h131
-rw-r--r--src/qml/debugger/qqmldebughelper.cpp70
-rw-r--r--src/qml/debugger/qqmldebughelper_p.h84
-rw-r--r--src/qml/debugger/qqmldebugserver.cpp540
-rw-r--r--src/qml/debugger/qqmldebugserver_p.h105
-rw-r--r--src/qml/debugger/qqmldebugserverconnection_p.h87
-rw-r--r--src/qml/debugger/qqmldebugservice.cpp268
-rw-r--r--src/qml/debugger/qqmldebugservice_p.h113
-rw-r--r--src/qml/debugger/qqmldebugservice_p_p.h82
-rw-r--r--src/qml/debugger/qqmldebugstatesdelegate_p.h98
-rw-r--r--src/qml/debugger/qqmlenginedebug.cpp1072
-rw-r--r--src/qml/debugger/qqmlenginedebug_p.h397
-rw-r--r--src/qml/debugger/qqmlenginedebugservice.cpp733
-rw-r--r--src/qml/debugger/qqmlenginedebugservice_p.h136
-rw-r--r--src/qml/debugger/qqmlinspectorinterface_p.h86
-rw-r--r--src/qml/debugger/qqmlinspectorservice.cpp186
-rw-r--r--src/qml/debugger/qqmlinspectorservice_p.h101
-rw-r--r--src/qml/debugger/qqmlprofilerservice.cpp315
-rw-r--r--src/qml/debugger/qqmlprofilerservice_p.h303
-rw-r--r--src/qml/debugger/qv8debugservice.cpp294
-rw-r--r--src/qml/debugger/qv8debugservice_p.h105
-rw-r--r--src/qml/debugger/qv8profilerservice.cpp301
-rw-r--r--src/qml/debugger/qv8profilerservice_p.h120
-rw-r--r--src/qml/qml.pro37
-rw-r--r--src/qml/qml/ftw/ftw.pri29
-rw-r--r--src/qml/qml/ftw/qbitfield_p.h165
-rw-r--r--src/qml/qml/ftw/qdeletewatcher_p.h113
-rw-r--r--src/qml/qml/ftw/qfastmetabuilder.cpp313
-rw-r--r--src/qml/qml/ftw/qfastmetabuilder_p.h206
-rw-r--r--src/qml/qml/ftw/qfieldlist_p.h426
-rw-r--r--src/qml/qml/ftw/qfinitestack_p.h186
-rw-r--r--src/qml/qml/ftw/qflagpointer_p.h338
-rw-r--r--src/qml/qml/ftw/qhashedstring.cpp490
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h1418
-rw-r--r--src/qml/qml/ftw/qhashfield_p.h120
-rw-r--r--src/qml/qml/ftw/qintrusivelist.cpp179
-rw-r--r--src/qml/qml/ftw/qintrusivelist_p.h274
-rw-r--r--src/qml/qml/ftw/qlazilyallocated_p.h146
-rw-r--r--src/qml/qml/ftw/qpodvector_p.h173
-rw-r--r--src/qml/qml/ftw/qpointervaluepair_p.h196
-rw-r--r--src/qml/qml/ftw/qqmlpool.cpp92
-rw-r--r--src/qml/qml/ftw/qqmlpool_p.h278
-rw-r--r--src/qml/qml/ftw/qqmlrefcount_p.h192
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp359
-rw-r--r--src/qml/qml/ftw/qqmlthread_p.h318
-rw-r--r--src/qml/qml/ftw/qqmltrace.cpp154
-rw-r--r--src/qml/qml/ftw/qqmltrace_p.h294
-rw-r--r--src/qml/qml/ftw/qrecursionwatcher_p.h105
-rw-r--r--src/qml/qml/ftw/qrecyclepool_p.h220
-rw-r--r--src/qml/qml/parser/parser.pri19
-rw-r--r--src/qml/qml/parser/qqmljs.g3016
-rw-r--r--src/qml/qml/parser/qqmljsast.cpp931
-rw-r--r--src/qml/qml/parser/qqmljsast_p.h2640
-rw-r--r--src/qml/qml/parser/qqmljsastfwd_p.h186
-rw-r--r--src/qml/qml/parser/qqmljsastvisitor.cpp58
-rw-r--r--src/qml/qml/parser/qqmljsastvisitor_p.h329
-rw-r--r--src/qml/qml/parser/qqmljsengine_p.cpp161
-rw-r--r--src/qml/qml/parser/qqmljsengine_p.h126
-rw-r--r--src/qml/qml/parser/qqmljsglobal_p.h69
-rw-r--r--src/qml/qml/parser/qqmljsgrammar.cpp1013
-rw-r--r--src/qml/qml/parser/qqmljsgrammar_p.h211
-rw-r--r--src/qml/qml/parser/qqmljskeywords_p.h860
-rw-r--r--src/qml/qml/parser/qqmljslexer.cpp1166
-rw-r--r--src/qml/qml/parser/qqmljslexer_p.h248
-rw-r--r--src/qml/qml/parser/qqmljsmemorypool_p.h173
-rw-r--r--src/qml/qml/parser/qqmljsparser.cpp1812
-rw-r--r--src/qml/qml/parser/qqmljsparser_p.h248
-rw-r--r--src/qml/qml/qlistmodelinterface.cpp104
-rw-r--r--src/qml/qml/qlistmodelinterface_p.h83
-rw-r--r--src/qml/qml/qml.pri125
-rw-r--r--src/qml/qml/qqml.h451
-rw-r--r--src/qml/qml/qqmlaccessors.cpp127
-rw-r--r--src/qml/qml/qqmlaccessors_p.h166
-rw-r--r--src/qml/qml/qqmlbinding.cpp551
-rw-r--r--src/qml/qml/qqmlbinding_p.h219
-rw-r--r--src/qml/qml/qqmlbinding_p_p.h89
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp305
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h103
-rw-r--r--src/qml/qml/qqmlcleanup.cpp118
-rw-r--r--src/qml/qml/qqmlcleanup_p.h87
-rw-r--r--src/qml/qml/qqmlcompileddata.cpp261
-rw-r--r--src/qml/qml/qqmlcompiler.cpp3904
-rw-r--r--src/qml/qml/qqmlcompiler_p.h467
-rw-r--r--src/qml/qml/qqmlcomponent.cpp1352
-rw-r--r--src/qml/qml/qqmlcomponent.h138
-rw-r--r--src/qml/qml/qqmlcomponent_p.h131
-rw-r--r--src/qml/qml/qqmlcomponentattached_p.h85
-rw-r--r--src/qml/qml/qqmlcontext.cpp811
-rw-r--r--src/qml/qml/qqmlcontext.h113
-rw-r--r--src/qml/qml/qqmlcontext_p.h334
-rw-r--r--src/qml/qml/qqmlcustomparser.cpp319
-rw-r--r--src/qml/qml/qqmlcustomparser_p.h168
-rw-r--r--src/qml/qml/qqmlcustomparser_p_p.h89
-rw-r--r--src/qml/qml/qqmldata_p.h207
-rw-r--r--src/qml/qml/qqmldirparser.cpp298
-rw-r--r--src/qml/qml/qqmldirparser_p.h166
-rw-r--r--src/qml/qml/qqmlengine.cpp1854
-rw-r--r--src/qml/qml/qqmlengine.h138
-rw-r--r--src/qml/qml/qqmlengine_p.h522
-rw-r--r--src/qml/qml/qqmlerror.cpp285
-rw-r--r--src/qml/qml/qqmlerror.h87
-rw-r--r--src/qml/qml/qqmlexpression.cpp982
-rw-r--r--src/qml/qml/qqmlexpression.h121
-rw-r--r--src/qml/qml/qqmlexpression_p.h406
-rw-r--r--src/qml/qml/qqmlextensioninterface.h81
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp171
-rw-r--r--src/qml/qml/qqmlextensionplugin.h77
-rw-r--r--src/qml/qml/qqmlglobal_p.h129
-rw-r--r--src/qml/qml/qqmlguard_p.h218
-rw-r--r--src/qml/qml/qqmlimageprovider.cpp334
-rw-r--r--src/qml/qml/qqmlimageprovider.h96
-rw-r--r--src/qml/qml/qqmlimport.cpp1183
-rw-r--r--src/qml/qml/qqmlimport_p.h157
-rw-r--r--src/qml/qml/qqmlincubator.cpp697
-rw-r--r--src/qml/qml/qqmlincubator.h130
-rw-r--r--src/qml/qml/qqmlincubator_p.h106
-rw-r--r--src/qml/qml/qqmlinfo.cpp192
-rw-r--r--src/qml/qml/qqmlinfo.h103
-rw-r--r--src/qml/qml/qqmlinstruction.cpp278
-rw-r--r--src/qml/qml/qqmlinstruction_p.h558
-rw-r--r--src/qml/qml/qqmlintegercache.cpp82
-rw-r--r--src/qml/qml/qqmlintegercache_p.h97
-rw-r--r--src/qml/qml/qqmllist.cpp417
-rw-r--r--src/qml/qml/qqmllist.h151
-rw-r--r--src/qml/qml/qqmllist_p.h85
-rw-r--r--src/qml/qml/qqmllocale.cpp1126
-rw-r--r--src/qml/qml/qqmllocale_p.h135
-rw-r--r--src/qml/qml/qqmlmetatype.cpp1359
-rw-r--r--src/qml/qml/qqmlmetatype_p.h268
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp103
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.h66
-rw-r--r--src/qml/qml/qqmlnotifier.cpp115
-rw-r--r--src/qml/qml/qqmlnotifier_p.h206
-rw-r--r--src/qml/qml/qqmlnullablevalue_p_p.h81
-rw-r--r--src/qml/qml/qqmlopenmetaobject.cpp387
-rw-r--r--src/qml/qml/qqmlopenmetaobject_p.h130
-rw-r--r--src/qml/qml/qqmlparserstatus.cpp107
-rw-r--r--src/qml/qml/qqmlparserstatus.h75
-rw-r--r--src/qml/qml/qqmlprivate.h265
-rw-r--r--src/qml/qml/qqmlproperty.cpp1917
-rw-r--r--src/qml/qml/qqmlproperty.h143
-rw-r--r--src/qml/qml/qqmlproperty_p.h171
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp891
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h384
-rw-r--r--src/qml/qml/qqmlpropertyvalueinterceptor.cpp79
-rw-r--r--src/qml/qml/qqmlpropertyvalueinterceptor_p.h77
-rw-r--r--src/qml/qml/qqmlpropertyvaluesource.cpp76
-rw-r--r--src/qml/qml/qqmlpropertyvaluesource.h70
-rw-r--r--src/qml/qml/qqmlproxymetaobject.cpp124
-rw-r--r--src/qml/qml/qqmlproxymetaobject_p.h99
-rw-r--r--src/qml/qml/qqmlrewrite.cpp424
-rw-r--r--src/qml/qml/qqmlrewrite_p.h150
-rw-r--r--src/qml/qml/qqmlscript.cpp1700
-rw-r--r--src/qml/qml/qqmlscript_p.h533
-rw-r--r--src/qml/qml/qqmlscriptstring.cpp157
-rw-r--r--src/qml/qml/qqmlscriptstring.h90
-rw-r--r--src/qml/qml/qqmlscriptstring_p.h64
-rw-r--r--src/qml/qml/qqmlstringconverters.cpp311
-rw-r--r--src/qml/qml/qqmlstringconverters_p.h93
-rw-r--r--src/qml/qml/qqmltypeloader.cpp1926
-rw-r--r--src/qml/qml/qqmltypeloader_p.h435
-rw-r--r--src/qml/qml/qqmltypenamecache.cpp127
-rw-r--r--src/qml/qml/qqmltypenamecache_p.h187
-rw-r--r--src/qml/qml/qqmltypenotavailable.cpp53
-rw-r--r--src/qml/qml/qqmltypenotavailable_p.h64
-rw-r--r--src/qml/qml/qqmlvaluetype.cpp868
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h635
-rw-r--r--src/qml/qml/qqmlvme.cpp1370
-rw-r--r--src/qml/qml/qqmlvme_p.h238
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp1110
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h221
-rw-r--r--src/qml/qml/qqmlwatcher.cpp188
-rw-r--r--src/qml/qml/qqmlwatcher_p.h94
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp1797
-rw-r--r--src/qml/qml/qqmlxmlhttprequest_p.h73
-rw-r--r--src/qml/qml/qquickapplication.cpp124
-rw-r--r--src/qml/qml/qquickapplication_p.h87
-rw-r--r--src/qml/qml/qquicklistmodel.cpp2467
-rw-r--r--src/qml/qml/qquicklistmodel_p.h199
-rw-r--r--src/qml/qml/qquicklistmodel_p_p.h378
-rw-r--r--src/qml/qml/qquicklistmodelworkeragent.cpp246
-rw-r--r--src/qml/qml/qquicklistmodelworkeragent_p.h161
-rw-r--r--src/qml/qml/qquickworkerscript.cpp730
-rw-r--r--src/qml/qml/qquickworkerscript_p.h130
-rw-r--r--src/qml/qml/rewriter/rewriter.pri (renamed from src/declarative/qml/rewriter/rewriter.pri)0
-rw-r--r--src/qml/qml/rewriter/textwriter.cpp217
-rw-r--r--src/qml/qml/rewriter/textwriter_p.h101
-rw-r--r--src/qml/qml/v4/qv4bindings.cpp1615
-rw-r--r--src/qml/qml/v4/qv4bindings_p.h155
-rw-r--r--src/qml/qml/v4/qv4compiler.cpp1420
-rw-r--r--src/qml/qml/v4/qv4compiler_p.h105
-rw-r--r--src/qml/qml/v4/qv4compiler_p_p.h246
-rw-r--r--src/qml/qml/v4/qv4instruction.cpp421
-rw-r--r--src/qml/qml/v4/qv4instruction_p.h435
-rw-r--r--src/qml/qml/v4/qv4ir.cpp883
-rw-r--r--src/qml/qml/v4/qv4ir_p.h605
-rw-r--r--src/qml/qml/v4/qv4irbuilder.cpp1306
-rw-r--r--src/qml/qml/v4/qv4irbuilder_p.h240
-rw-r--r--src/qml/qml/v4/qv4program_p.h123
-rw-r--r--src/qml/qml/v4/v4.pri (renamed from src/declarative/qml/v4/v4.pri)0
-rw-r--r--src/qml/qml/v8/notes.txt4
-rw-r--r--src/qml/qml/v8/qjsconverter_impl_p.h268
-rw-r--r--src/qml/qml/v8/qjsconverter_p.h111
-rw-r--r--src/qml/qml/v8/qjsengine.cpp (renamed from src/declarative/qml/v8/qjsengine.cpp)0
-rw-r--r--src/qml/qml/v8/qjsengine.h159
-rw-r--r--src/qml/qml/v8/qjsengine_p.h75
-rw-r--r--src/qml/qml/v8/qjsvalue.cpp (renamed from src/declarative/qml/v8/qjsvalue.cpp)0
-rw-r--r--src/qml/qml/v8/qjsvalue.h160
-rw-r--r--src/qml/qml/v8/qjsvalue_impl_p.h995
-rw-r--r--src/qml/qml/v8/qjsvalue_p.h213
-rw-r--r--src/qml/qml/v8/qjsvalueiterator.cpp (renamed from src/declarative/qml/v8/qjsvalueiterator.cpp)0
-rw-r--r--src/qml/qml/v8/qjsvalueiterator.h82
-rw-r--r--src/qml/qml/v8/qjsvalueiterator_impl_p.h139
-rw-r--r--src/qml/qml/v8/qjsvalueiterator_p.h86
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp1321
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h110
-rw-r--r--src/qml/qml/v8/qscript_impl_p.h61
-rw-r--r--src/qml/qml/v8/qscriptisolate_p.h89
-rw-r--r--src/qml/qml/v8/qscriptoriginalglobalobject_p.h177
-rw-r--r--src/qml/qml/v8/qscriptshareddata_p.h169
-rw-r--r--src/qml/qml/v8/qscripttools_p.h86
-rw-r--r--src/qml/qml/v8/qv8_p.h42
-rw-r--r--src/qml/qml/v8/qv8bindings.cpp285
-rw-r--r--src/qml/qml/v8/qv8bindings_p.h148
-rw-r--r--src/qml/qml/v8/qv8contextwrapper.cpp455
-rw-r--r--src/qml/qml/v8/qv8contextwrapper_p.h120
-rw-r--r--src/qml/qml/v8/qv8debug_p.h42
-rw-r--r--src/qml/qml/v8/qv8domerrors.cpp73
-rw-r--r--src/qml/qml/v8/qv8domerrors_p.h94
-rw-r--r--src/qml/qml/v8/qv8engine.cpp1600
-rw-r--r--src/qml/qml/v8/qv8engine_impl_p.h173
-rw-r--r--src/qml/qml/v8/qv8engine_p.h631
-rw-r--r--src/qml/qml/v8/qv8include.cpp244
-rw-r--r--src/qml/qml/v8/qv8include_p.h113
-rw-r--r--src/qml/qml/v8/qv8listwrapper.cpp194
-rw-r--r--src/qml/qml/v8/qv8listwrapper_p.h97
-rw-r--r--src/qml/qml/v8/qv8profiler_p.h42
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp2113
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper_p.h159
-rw-r--r--src/qml/qml/v8/qv8sequencewrapper.cpp264
-rw-r--r--src/qml/qml/v8/qv8sequencewrapper_p.h106
-rw-r--r--src/qml/qml/v8/qv8sequencewrapper_p_p.h503
-rw-r--r--src/qml/qml/v8/qv8sqlerrors.cpp64
-rw-r--r--src/qml/qml/v8/qv8sqlerrors_p.h77
-rw-r--r--src/qml/qml/v8/qv8stringwrapper.cpp78
-rw-r--r--src/qml/qml/v8/qv8stringwrapper_p.h78
-rw-r--r--src/qml/qml/v8/qv8typewrapper.cpp314
-rw-r--r--src/qml/qml/v8/qv8typewrapper_p.h94
-rw-r--r--src/qml/qml/v8/qv8valuetypewrapper.cpp387
-rw-r--r--src/qml/qml/v8/qv8valuetypewrapper_p.h104
-rw-r--r--src/qml/qml/v8/qv8variantresource_p.h81
-rw-r--r--src/qml/qml/v8/qv8variantwrapper.cpp279
-rw-r--r--src/qml/qml/v8/qv8variantwrapper_p.h110
-rw-r--r--src/qml/qml/v8/qv8worker.cpp392
-rw-r--r--src/qml/qml/v8/qv8worker_p.h75
-rw-r--r--src/qml/qml/v8/script.pri (renamed from src/declarative/qml/v8/script.pri)0
-rw-r--r--src/qml/qml/v8/v8.pri45
-rw-r--r--src/qml/qtqmlglobal.h67
-rw-r--r--src/qml/qtqmlglobal_p.h60
-rw-r--r--src/qml/util/qqmlpropertymap.cpp309
-rw-r--r--src/qml/util/qqmlpropertymap.h91
-rw-r--r--src/qml/util/util.pri5
-rw-r--r--src/qmldevtools/qmldevtools.pro2
-rw-r--r--src/qmltest/qmltest.pro2
-rw-r--r--src/qmltest/quicktest.cpp18
-rw-r--r--src/qmltest/quicktestevent.cpp4
-rw-r--r--src/quick/designer/designersupport.cpp16
-rw-r--r--src/quick/designer/designersupport.h8
-rw-r--r--src/quick/items/context2d/qquickcanvascontext.cpp2
-rw-r--r--src/quick/items/context2d/qquickcanvascontext_p.h2
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp32
-rw-r--r--src/quick/items/context2d/qquickcanvasitem_p.h12
-rw-r--r--src/quick/items/context2d/qquickcanvasitemnode.cpp2
-rw-r--r--src/quick/items/context2d/qquickcanvasitemnode_p.h2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp14
-rw-r--r--src/quick/items/context2d/qquickcontext2d_p.h8
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp4
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h4
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture_p.h2
-rw-r--r--src/quick/items/context2d/qquickcontext2dtile.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2dtile_p.h2
-rw-r--r--src/quick/items/items.pri6
-rw-r--r--src/quick/items/qquickaccessibleattached.cpp2
-rw-r--r--src/quick/items/qquickaccessibleattached_p.h2
-rw-r--r--src/quick/items/qquickanchors.cpp4
-rw-r--r--src/quick/items/qquickanchors_p.h4
-rw-r--r--src/quick/items/qquickanchors_p_p.h2
-rw-r--r--src/quick/items/qquickanimatedimage.cpp12
-rw-r--r--src/quick/items/qquickanimatedimage_p.h2
-rw-r--r--src/quick/items/qquickanimatedimage_p_p.h2
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp8
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h2
-rw-r--r--src/quick/items/qquickanimation.cpp1044
-rw-r--r--src/quick/items/qquickanimation_p.h203
-rw-r--r--src/quick/items/qquickanimation_p_p.h161
-rw-r--r--src/quick/items/qquickborderimage.cpp29
-rw-r--r--src/quick/items/qquickborderimage_p.h2
-rw-r--r--src/quick/items/qquickborderimage_p_p.h4
-rw-r--r--src/quick/items/qquickcanvas.cpp20
-rw-r--r--src/quick/items/qquickcanvas.h8
-rw-r--r--src/quick/items/qquickcanvas_p.h6
-rw-r--r--src/quick/items/qquickclipnode.cpp2
-rw-r--r--src/quick/items/qquickclipnode_p.h2
-rw-r--r--src/quick/items/qquickdrag.cpp12
-rw-r--r--src/quick/items/qquickdrag_p.h10
-rw-r--r--src/quick/items/qquickdroparea.cpp10
-rw-r--r--src/quick/items/qquickdroparea_p.h6
-rw-r--r--src/quick/items/qquickevents.cpp2
-rw-r--r--src/quick/items/qquickevents_p_p.h4
-rw-r--r--src/quick/items/qquickflickable.cpp38
-rw-r--r--src/quick/items/qquickflickable_p.h10
-rw-r--r--src/quick/items/qquickflickable_p_p.h28
-rw-r--r--src/quick/items/qquickflipable.cpp14
-rw-r--r--src/quick/items/qquickflipable_p.h2
-rw-r--r--src/quick/items/qquickfocusscope.cpp2
-rw-r--r--src/quick/items/qquickfocusscope_p.h2
-rw-r--r--src/quick/items/qquickgridview.cpp34
-rw-r--r--src/quick/items/qquickgridview_p.h6
-rw-r--r--src/quick/items/qquickimage.cpp8
-rw-r--r--src/quick/items/qquickimage_p.h2
-rw-r--r--src/quick/items/qquickimage_p_p.h2
-rw-r--r--src/quick/items/qquickimagebase.cpp10
-rw-r--r--src/quick/items/qquickimagebase_p.h2
-rw-r--r--src/quick/items/qquickimagebase_p_p.h6
-rw-r--r--src/quick/items/qquickimplicitsizeitem.cpp2
-rw-r--r--src/quick/items/qquickimplicitsizeitem_p.h2
-rw-r--r--src/quick/items/qquickimplicitsizeitem_p_p.h2
-rw-r--r--src/quick/items/qquickitem.cpp119
-rw-r--r--src/quick/items/qquickitem.h36
-rw-r--r--src/quick/items/qquickitem_p.h86
-rw-r--r--src/quick/items/qquickitemanimation.cpp1044
-rw-r--r--src/quick/items/qquickitemanimation_p.h203
-rw-r--r--src/quick/items/qquickitemanimation_p_p.h161
-rw-r--r--src/quick/items/qquickitemchangelistener_p.h2
-rw-r--r--src/quick/items/qquickitemsmodule.cpp50
-rw-r--r--src/quick/items/qquickitemsmodule_p.h4
-rw-r--r--src/quick/items/qquickitemview.cpp106
-rw-r--r--src/quick/items/qquickitemview_p.h80
-rw-r--r--src/quick/items/qquickitemview_p_p.h40
-rw-r--r--src/quick/items/qquickitemviewtransition.cpp26
-rw-r--r--src/quick/items/qquickitemviewtransition_p.h28
-rw-r--r--src/quick/items/qquicklistview.cpp60
-rw-r--r--src/quick/items/qquicklistview_p.h14
-rw-r--r--src/quick/items/qquickloader.cpp78
-rw-r--r--src/quick/items/qquickloader_p.h10
-rw-r--r--src/quick/items/qquickloader_p_p.h20
-rw-r--r--src/quick/items/qquickmousearea.cpp14
-rw-r--r--src/quick/items/qquickmousearea_p.h4
-rw-r--r--src/quick/items/qquickmousearea_p_p.h4
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp4
-rw-r--r--src/quick/items/qquickmultipointtoucharea_p.h20
-rw-r--r--src/quick/items/qquickninepatchnode.cpp2
-rw-r--r--src/quick/items/qquickninepatchnode_p.h2
-rw-r--r--src/quick/items/qquickpainteditem.cpp2
-rw-r--r--src/quick/items/qquickpainteditem.h2
-rw-r--r--src/quick/items/qquickpainteditem_p.h2
-rw-r--r--src/quick/items/qquickpathview.cpp69
-rw-r--r--src/quick/items/qquickpathview_p.h30
-rw-r--r--src/quick/items/qquickpathview_p_p.h30
-rw-r--r--src/quick/items/qquickpositioners.cpp54
-rw-r--r--src/quick/items/qquickpositioners_p.h16
-rw-r--r--src/quick/items/qquickpositioners_p_p.h8
-rw-r--r--src/quick/items/qquickrectangle.cpp16
-rw-r--r--src/quick/items/qquickrectangle_p.h6
-rw-r--r--src/quick/items/qquickrectangle_p_p.h2
-rw-r--r--src/quick/items/qquickrepeater.cpp40
-rw-r--r--src/quick/items/qquickrepeater_p.h12
-rw-r--r--src/quick/items/qquickrepeater_p_p.h4
-rw-r--r--src/quick/items/qquickscalegrid.cpp4
-rw-r--r--src/quick/items/qquickscalegrid_p_p.h6
-rw-r--r--src/quick/items/qquickscreen.cpp2
-rw-r--r--src/quick/items/qquickscreen_p.h6
-rw-r--r--src/quick/items/qquickshadereffect.cpp2
-rw-r--r--src/quick/items/qquickshadereffect_p.h2
-rw-r--r--src/quick/items/qquickshadereffectmesh.cpp2
-rw-r--r--src/quick/items/qquickshadereffectmesh_p.h4
-rw-r--r--src/quick/items/qquickshadereffectnode.cpp2
-rw-r--r--src/quick/items/qquickshadereffectnode_p.h2
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp2
-rw-r--r--src/quick/items/qquickshadereffectsource_p.h2
-rw-r--r--src/quick/items/qquicksprite.cpp4
-rw-r--r--src/quick/items/qquicksprite_p.h8
-rw-r--r--src/quick/items/qquickspriteengine.cpp32
-rw-r--r--src/quick/items/qquickspriteengine_p.h38
-rw-r--r--src/quick/items/qquickspriteimage.cpp482
-rw-r--r--src/quick/items/qquickspriteimage_p.h148
-rw-r--r--src/quick/items/qquickspritesequence.cpp12
-rw-r--r--src/quick/items/qquickspritesequence_p.h6
-rw-r--r--src/quick/items/qquickstateoperations.cpp358
-rw-r--r--src/quick/items/qquickstateoperations_p.h98
-rw-r--r--src/quick/items/qquicktext.cpp59
-rw-r--r--src/quick/items/qquicktext_p.h2
-rw-r--r--src/quick/items/qquicktext_p_p.h16
-rw-r--r--src/quick/items/qquicktextedit.cpp24
-rw-r--r--src/quick/items/qquicktextedit_p.h8
-rw-r--r--src/quick/items/qquicktextedit_p_p.h6
-rw-r--r--src/quick/items/qquicktextinput.cpp20
-rw-r--r--src/quick/items/qquicktextinput_p.h10
-rw-r--r--src/quick/items/qquicktextinput_p_p.h8
-rw-r--r--src/quick/items/qquicktextnode.cpp4
-rw-r--r--src/quick/items/qquicktextnode_p.h2
-rw-r--r--src/quick/items/qquicktranslate.cpp2
-rw-r--r--src/quick/items/qquicktranslate_p.h2
-rw-r--r--src/quick/items/qquickview.cpp62
-rw-r--r--src/quick/items/qquickview.h16
-rw-r--r--src/quick/items/qquickview_p.h14
-rw-r--r--src/quick/items/qquickvisualadaptormodel.cpp38
-rw-r--r--src/quick/items/qquickvisualadaptormodel_p.h6
-rw-r--r--src/quick/items/qquickvisualdatamodel.cpp170
-rw-r--r--src/quick/items/qquickvisualdatamodel_p.h54
-rw-r--r--src/quick/items/qquickvisualdatamodel_p_p.h98
-rw-r--r--src/quick/items/qquickvisualitemmodel.cpp28
-rw-r--r--src/quick/items/qquickvisualitemmodel_p.h12
-rw-r--r--src/quick/items/qquickwindowmanager.cpp4
-rw-r--r--src/quick/items/qquickwindowmanager_p.h2
-rw-r--r--src/quick/items/qquickwindowmodule.cpp2
-rw-r--r--src/quick/items/qquickwindowmodule_p.h4
-rw-r--r--src/quick/items/syncexcludes4
-rw-r--r--src/quick/particles/qquickage.cpp2
-rw-r--r--src/quick/particles/qquickage_p.h2
-rw-r--r--src/quick/particles/qquickangledirection.cpp2
-rw-r--r--src/quick/particles/qquickangledirection_p.h2
-rw-r--r--src/quick/particles/qquickcumulativedirection.cpp6
-rw-r--r--src/quick/particles/qquickcumulativedirection_p.h8
-rw-r--r--src/quick/particles/qquickcustomaffector.cpp16
-rw-r--r--src/quick/particles/qquickcustomaffector_p.h4
-rw-r--r--src/quick/particles/qquickcustomparticle.cpp2
-rw-r--r--src/quick/particles/qquickcustomparticle_p.h2
-rw-r--r--src/quick/particles/qquickdirection.cpp2
-rw-r--r--src/quick/particles/qquickdirection_p.h2
-rw-r--r--src/quick/particles/qquickellipseextruder.cpp2
-rw-r--r--src/quick/particles/qquickellipseextruder_p.h2
-rw-r--r--src/quick/particles/qquickfriction.cpp2
-rw-r--r--src/quick/particles/qquickfriction_p.h2
-rw-r--r--src/quick/particles/qquickgravity.cpp2
-rw-r--r--src/quick/particles/qquickgravity_p.h2
-rw-r--r--src/quick/particles/qquickgroupgoal.cpp2
-rw-r--r--src/quick/particles/qquickgroupgoal_p.h2
-rw-r--r--src/quick/particles/qquickimageparticle.cpp10
-rw-r--r--src/quick/particles/qquickimageparticle_p.h12
-rw-r--r--src/quick/particles/qquickitemparticle.cpp4
-rw-r--r--src/quick/particles/qquickitemparticle_p.h14
-rw-r--r--src/quick/particles/qquicklineextruder.cpp2
-rw-r--r--src/quick/particles/qquicklineextruder_p.h2
-rw-r--r--src/quick/particles/qquickmaskextruder.cpp6
-rw-r--r--src/quick/particles/qquickmaskextruder_p.h6
-rw-r--r--src/quick/particles/qquickparticleaffector.cpp2
-rw-r--r--src/quick/particles/qquickparticleaffector_p.h2
-rw-r--r--src/quick/particles/qquickparticleemitter.cpp10
-rw-r--r--src/quick/particles/qquickparticleemitter_p.h4
-rw-r--r--src/quick/particles/qquickparticleextruder.cpp2
-rw-r--r--src/quick/particles/qquickparticleextruder_p.h2
-rw-r--r--src/quick/particles/qquickparticlegroup.cpp10
-rw-r--r--src/quick/particles/qquickparticlegroup_p.h12
-rw-r--r--src/quick/particles/qquickparticlepainter.cpp2
-rw-r--r--src/quick/particles/qquickparticlepainter_p.h2
-rw-r--r--src/quick/particles/qquickparticlesmodule.cpp2
-rw-r--r--src/quick/particles/qquickparticlesmodule_p.h4
-rw-r--r--src/quick/particles/qquickparticlesystem.cpp11
-rw-r--r--src/quick/particles/qquickparticlesystem_p.h10
-rw-r--r--src/quick/particles/qquickpointattractor.cpp2
-rw-r--r--src/quick/particles/qquickpointattractor_p.h2
-rw-r--r--src/quick/particles/qquickpointdirection.cpp2
-rw-r--r--src/quick/particles/qquickpointdirection_p.h2
-rw-r--r--src/quick/particles/qquickrectangleextruder.cpp2
-rw-r--r--src/quick/particles/qquickrectangleextruder_p.h2
-rw-r--r--src/quick/particles/qquickspritegoal.cpp2
-rw-r--r--src/quick/particles/qquickspritegoal_p.h4
-rw-r--r--src/quick/particles/qquicktargetdirection.cpp2
-rw-r--r--src/quick/particles/qquicktargetdirection_p.h2
-rw-r--r--src/quick/particles/qquicktrailemitter.cpp12
-rw-r--r--src/quick/particles/qquicktrailemitter_p.h4
-rw-r--r--src/quick/particles/qquickturbulence.cpp2
-rw-r--r--src/quick/particles/qquickturbulence_p.h4
-rw-r--r--src/quick/particles/qquickv8particledata.cpp6
-rw-r--r--src/quick/particles/qquickv8particledata_p.h4
-rw-r--r--src/quick/particles/qquickwander.cpp2
-rw-r--r--src/quick/particles/qquickwander_p.h2
-rw-r--r--src/quick/qtquick2.cpp86
-rw-r--r--src/quick/qtquick2_p.h4
-rw-r--r--src/quick/qtquickglobal.h2
-rw-r--r--src/quick/qtquickglobal_p.h2
-rw-r--r--src/quick/quick.pro12
-rw-r--r--src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgnodeupdater.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgnodeupdater_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode_p.h2
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp2
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h2
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp16
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h8
-rw-r--r--src/quick/scenegraph/qsgcontextplugin.cpp6
-rw-r--r--src/quick/scenegraph/qsgcontextplugin_p.h8
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultimagenode.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultimagenode_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode_p.h2
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode.cpp2
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp2
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.h2
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h2
-rw-r--r--src/quick/scenegraph/qsgflashnode.cpp2
-rw-r--r--src/quick/scenegraph/qsgflashnode_p.h2
-rw-r--r--src/quick/scenegraph/qsgpathsimplifier.cpp1673
-rw-r--r--src/quick/scenegraph/qsgpathsimplifier_p.h68
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp2
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgareaallocator.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgareaallocator_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgdistancefieldutil.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgdistancefieldutil_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgengine.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgengine.h2
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.h2
-rw-r--r--src/quick/scenegraph/util/qsgpainternode.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgpainternode_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgsimplematerial.h2
-rw-r--r--src/quick/scenegraph/util/qsgsimplerectnode.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgsimplerectnode.h2
-rw-r--r--src/quick/scenegraph/util/qsgsimpletexturenode.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgsimpletexturenode.h2
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp5
-rw-r--r--src/quick/scenegraph/util/qsgtexture.h2
-rw-r--r--src/quick/scenegraph/util/qsgtexture_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.h2
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgtextureprovider.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgtextureprovider.h2
-rw-r--r--src/quick/scenegraph/util/qsgvertexcolormaterial.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgvertexcolormaterial.h2
-rw-r--r--src/quick/util/qdeclarativeanimation.cpp2530
-rw-r--r--src/quick/util/qdeclarativeanimation_p.h464
-rw-r--r--src/quick/util/qdeclarativeanimation_p_p.h322
-rw-r--r--src/quick/util/qdeclarativeanimationcontroller.cpp204
-rw-r--r--src/quick/util/qdeclarativeanimationcontroller_p.h94
-rw-r--r--src/quick/util/qdeclarativebehavior.cpp238
-rw-r--r--src/quick/util/qdeclarativebehavior_p.h93
-rw-r--r--src/quick/util/qdeclarativebind.cpp309
-rw-r--r--src/quick/util/qdeclarativebind_p.h96
-rw-r--r--src/quick/util/qdeclarativechangeset.cpp479
-rw-r--r--src/quick/util/qdeclarativechangeset_p.h166
-rw-r--r--src/quick/util/qdeclarativeconnections.cpp307
-rw-r--r--src/quick/util/qdeclarativeconnections_p.h100
-rw-r--r--src/quick/util/qdeclarativefontloader.cpp335
-rw-r--r--src/quick/util/qdeclarativefontloader_p.h95
-rw-r--r--src/quick/util/qdeclarativelistaccessor.cpp138
-rw-r--r--src/quick/util/qdeclarativelistaccessor_p.h78
-rw-r--r--src/quick/util/qdeclarativelistcompositor.cpp1214
-rw-r--r--src/quick/util/qdeclarativelistcompositor_p.h382
-rw-r--r--src/quick/util/qdeclarativepackage.cpp202
-rw-r--r--src/quick/util/qdeclarativepackage_p.h96
-rw-r--r--src/quick/util/qdeclarativepath.cpp1798
-rw-r--r--src/quick/util/qdeclarativepath_p.h451
-rw-r--r--src/quick/util/qdeclarativepath_p_p.h88
-rw-r--r--src/quick/util/qdeclarativepathinterpolator.cpp169
-rw-r--r--src/quick/util/qdeclarativepathinterpolator_p.h98
-rw-r--r--src/quick/util/qdeclarativepixmapcache.cpp1280
-rw-r--r--src/quick/util/qdeclarativepixmapcache_p.h144
-rw-r--r--src/quick/util/qdeclarativepropertychanges.cpp796
-rw-r--r--src/quick/util/qdeclarativepropertychanges_p.h110
-rw-r--r--src/quick/util/qdeclarativesmoothedanimation.cpp557
-rw-r--r--src/quick/util/qdeclarativesmoothedanimation_p.h100
-rw-r--r--src/quick/util/qdeclarativesmoothedanimation_p_p.h154
-rw-r--r--src/quick/util/qdeclarativespringanimation.cpp593
-rw-r--r--src/quick/util/qdeclarativespringanimation_p.h107
-rw-r--r--src/quick/util/qdeclarativestate.cpp729
-rw-r--r--src/quick/util/qdeclarativestate_p.h210
-rw-r--r--src/quick/util/qdeclarativestate_p_p.h264
-rw-r--r--src/quick/util/qdeclarativestategroup.cpp516
-rw-r--r--src/quick/util/qdeclarativestategroup_p.h95
-rw-r--r--src/quick/util/qdeclarativestateoperations.cpp157
-rw-r--r--src/quick/util/qdeclarativestateoperations_p.h85
-rw-r--r--src/quick/util/qdeclarativestyledtext.cpp815
-rw-r--r--src/quick/util/qdeclarativestyledtext_p.h105
-rw-r--r--src/quick/util/qdeclarativesvgparser.cpp614
-rw-r--r--src/quick/util/qdeclarativesvgparser_p.h60
-rw-r--r--src/quick/util/qdeclarativesystempalette.cpp312
-rw-r--r--src/quick/util/qdeclarativesystempalette_p.h120
-rw-r--r--src/quick/util/qdeclarativetimeline.cpp947
-rw-r--r--src/quick/util/qdeclarativetimeline_p_p.h200
-rw-r--r--src/quick/util/qdeclarativetimer.cpp327
-rw-r--r--src/quick/util/qdeclarativetimer_p.h111
-rw-r--r--src/quick/util/qdeclarativetransition.cpp412
-rw-r--r--src/quick/util/qdeclarativetransition_p.h127
-rw-r--r--src/quick/util/qdeclarativetransitionmanager.cpp294
-rw-r--r--src/quick/util/qdeclarativetransitionmanager_p_p.h91
-rw-r--r--src/quick/util/qdeclarativeutilmodule.cpp103
-rw-r--r--src/quick/util/qdeclarativeutilmodule_p.h61
-rw-r--r--src/quick/util/qquickanimation.cpp2530
-rw-r--r--src/quick/util/qquickanimation_p.h464
-rw-r--r--src/quick/util/qquickanimation_p_p.h322
-rw-r--r--src/quick/util/qquickanimationcontroller.cpp204
-rw-r--r--src/quick/util/qquickanimationcontroller_p.h94
-rw-r--r--src/quick/util/qquickbehavior.cpp238
-rw-r--r--src/quick/util/qquickbehavior_p.h93
-rw-r--r--src/quick/util/qquickbind.cpp309
-rw-r--r--src/quick/util/qquickbind_p.h96
-rw-r--r--src/quick/util/qquickchangeset.cpp479
-rw-r--r--src/quick/util/qquickchangeset_p.h166
-rw-r--r--src/quick/util/qquickconnections.cpp307
-rw-r--r--src/quick/util/qquickconnections_p.h100
-rw-r--r--src/quick/util/qquickfontloader.cpp335
-rw-r--r--src/quick/util/qquickfontloader_p.h95
-rw-r--r--src/quick/util/qquicklistaccessor.cpp138
-rw-r--r--src/quick/util/qquicklistaccessor_p.h78
-rw-r--r--src/quick/util/qquicklistcompositor.cpp1214
-rw-r--r--src/quick/util/qquicklistcompositor_p.h382
-rw-r--r--src/quick/util/qquickpackage.cpp202
-rw-r--r--src/quick/util/qquickpackage_p.h96
-rw-r--r--src/quick/util/qquickpath.cpp1798
-rw-r--r--src/quick/util/qquickpath_p.h451
-rw-r--r--src/quick/util/qquickpath_p_p.h88
-rw-r--r--src/quick/util/qquickpathinterpolator.cpp169
-rw-r--r--src/quick/util/qquickpathinterpolator_p.h98
-rw-r--r--src/quick/util/qquickpixmapcache.cpp1280
-rw-r--r--src/quick/util/qquickpixmapcache_p.h144
-rw-r--r--src/quick/util/qquickpropertychanges.cpp796
-rw-r--r--src/quick/util/qquickpropertychanges_p.h110
-rw-r--r--src/quick/util/qquicksmoothedanimation.cpp557
-rw-r--r--src/quick/util/qquicksmoothedanimation_p.h100
-rw-r--r--src/quick/util/qquicksmoothedanimation_p_p.h154
-rw-r--r--src/quick/util/qquickspringanimation.cpp593
-rw-r--r--src/quick/util/qquickspringanimation_p.h107
-rw-r--r--src/quick/util/qquickstate.cpp729
-rw-r--r--src/quick/util/qquickstate_p.h210
-rw-r--r--src/quick/util/qquickstate_p_p.h264
-rw-r--r--src/quick/util/qquickstatechangescript.cpp158
-rw-r--r--src/quick/util/qquickstatechangescript_p.h85
-rw-r--r--src/quick/util/qquickstategroup.cpp516
-rw-r--r--src/quick/util/qquickstategroup_p.h95
-rw-r--r--src/quick/util/qquickstyledtext.cpp815
-rw-r--r--src/quick/util/qquickstyledtext_p.h105
-rw-r--r--src/quick/util/qquicksvgparser.cpp614
-rw-r--r--src/quick/util/qquicksvgparser_p.h60
-rw-r--r--src/quick/util/qquicksystempalette.cpp312
-rw-r--r--src/quick/util/qquicksystempalette_p.h120
-rw-r--r--src/quick/util/qquicktimeline.cpp947
-rw-r--r--src/quick/util/qquicktimeline_p_p.h200
-rw-r--r--src/quick/util/qquicktimer.cpp327
-rw-r--r--src/quick/util/qquicktimer_p.h111
-rw-r--r--src/quick/util/qquicktransition.cpp412
-rw-r--r--src/quick/util/qquicktransition_p.h127
-rw-r--r--src/quick/util/qquicktransitionmanager.cpp294
-rw-r--r--src/quick/util/qquicktransitionmanager_p_p.h91
-rw-r--r--src/quick/util/qquickutilmodule.cpp103
-rw-r--r--src/quick/util/qquickutilmodule_p.h61
-rw-r--r--src/quick/util/util.pri116
-rw-r--r--src/src.pro3
-rw-r--r--sync.profile193
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/compilerwarnings/data/test_cpp.txt2
-rw-r--r--tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro5
-rw-r--r--tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp229
-rw-r--r--tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro5
-rw-r--r--tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp310
-rw-r--r--tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro5
-rw-r--r--tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp931
-rw-r--r--tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro5
-rw-r--r--tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp470
-rw-r--r--tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro5
-rw-r--r--tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp1617
-rw-r--r--tests/auto/declarative/debugger/debugger.pro16
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro21
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp242
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro11
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp197
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro29
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp1790
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro11
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp216
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro11
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp1235
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro9
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro3
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp186
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro12
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro15
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp310
-rw-r--r--tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro10
-rw-r--r--tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp263
-rw-r--r--tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro16
-rw-r--r--tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp294
-rw-r--r--tests/auto/declarative/debugger/shared/debugutil.cpp190
-rw-r--r--tests/auto/declarative/debugger/shared/debugutil_p.h127
-rw-r--r--tests/auto/declarative/declarative.pro56
-rw-r--r--tests/auto/declarative/parserstress/parserstress.pro12
-rw-r--r--tests/auto/declarative/parserstress/tst_parserstress.cpp154
-rw-r--r--tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro15
-rw-r--r--tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp197
-rw-r--r--tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro9
-rw-r--r--tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp812
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro15
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp218
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp292
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/data/tracing.qml56
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp170
-rw-r--r--tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro15
-rw-r--r--tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp652
-rw-r--r--tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro9
-rw-r--r--tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp106
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro22
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp210
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h1313
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp6097
-rw-r--r--tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp365
-rw-r--r--tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp243
-rw-r--r--tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp121
-rw-r--r--tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro14
-rw-r--r--tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp179
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp424
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro18
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/testtypes.cpp137
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/testtypes.h125
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp1030
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro14
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp221
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp678
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro18
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h824
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp2290
-rw-r--r--tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro9
-rw-r--r--tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp1637
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro15
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp1632
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro15
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp570
-rw-r--r--tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro15
-rw-r--r--tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp1219
-rw-r--r--tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro14
-rw-r--r--tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp364
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp202
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp84
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp84
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp83
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp73
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp73
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp58
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp83
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro8
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro9
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp353
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro19
-rw-r--r--tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp210
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp1721
-rw-r--r--tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro8
-rw-r--r--tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp281
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro9
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp241
-rw-r--r--tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp732
-rw-r--r--tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro15
-rw-r--r--tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp243
-rw-r--r--tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro16
-rw-r--r--tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp137
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro18
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h219
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp1319
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp300
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro19
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp1160
-rw-r--r--tests/auto/declarative/qjsengine/qjsengine.pro13
-rw-r--r--tests/auto/declarative/qjsvalue/qjsvalue.pro6
-rw-r--r--tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro7
-rw-r--r--tests/auto/declarative/qmlmin/qmlmin.pro9
-rw-r--r--tests/auto/declarative/qmlmin/tst_qmlmin.cpp193
-rwxr-xr-xtests/auto/declarative/runall.sh100
-rw-r--r--tests/auto/declarative/v4/testtypes.cpp49
-rw-r--r--tests/auto/declarative/v4/tst_v4.cpp371
-rw-r--r--tests/auto/declarative/v4/v4.pro17
-rw-r--r--tests/auto/headersclean/headersclean.pro2
-rw-r--r--tests/auto/headersclean/tst_headersclean.cpp2
-rw-r--r--tests/auto/host.pro9
-rw-r--r--tests/auto/particles/qquickage/qquickage.pro2
-rw-r--r--tests/auto/particles/qquickangleddirection/qquickangleddirection.pro2
-rw-r--r--tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro2
-rw-r--r--tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro2
-rw-r--r--tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro2
-rw-r--r--tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro2
-rw-r--r--tests/auto/particles/qquickfriction/qquickfriction.pro2
-rw-r--r--tests/auto/particles/qquickgravity/qquickgravity.pro2
-rw-r--r--tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro2
-rw-r--r--tests/auto/particles/qquickimageparticle/qquickimageparticle.pro2
-rw-r--r--tests/auto/particles/qquickitemparticle/qquickitemparticle.pro2
-rw-r--r--tests/auto/particles/qquicklineextruder/qquicklineextruder.pro2
-rw-r--r--tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro2
-rw-r--r--tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro2
-rw-r--r--tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro2
-rw-r--r--tests/auto/particles/qquickpointattractor/qquickpointattractor.pro2
-rw-r--r--tests/auto/particles/qquickpointdirection/qquickpointdirection.pro2
-rw-r--r--tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro2
-rw-r--r--tests/auto/particles/qquickspritegoal/qquickspritegoal.pro2
-rw-r--r--tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro2
-rw-r--r--tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro2
-rw-r--r--tests/auto/particles/qquickturbulence/qquickturbulence.pro2
-rw-r--r--tests/auto/particles/qquickwander/qquickwander.pro2
-rw-r--r--tests/auto/qml/animation/animation.pro (renamed from tests/auto/declarative/animation/animation.pro)0
-rw-r--r--tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro5
-rw-r--r--tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp229
-rw-r--r--tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro5
-rw-r--r--tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp310
-rw-r--r--tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro5
-rw-r--r--tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp931
-rw-r--r--tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro5
-rw-r--r--tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp470
-rw-r--r--tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro5
-rw-r--r--tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp1617
-rw-r--r--tests/auto/qml/debugger/debugger.pro16
-rw-r--r--tests/auto/qml/debugger/qdebugmessageservice/data/test.qml (renamed from tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro21
-rw-r--r--tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp242
-rw-r--r--tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro10
-rw-r--r--tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp263
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro11
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp197
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/condition.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/exception.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/test.js (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.js)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/test.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/timer.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro29
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp1790
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro11
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp216
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro11
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp1235
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/app/app.pro9
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/app/main.cpp (renamed from tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp)0
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml (renamed from tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick2.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro3
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp186
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro12
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml (renamed from tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml (renamed from tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro15
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp310
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/data/console.qml (renamed from tests/auto/declarative/debugger/qv8profilerservice/data/console.qml)0
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/data/exit.qml (renamed from tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml)0
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/data/test.qml (renamed from tests/auto/declarative/debugger/qv8profilerservice/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro16
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp294
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp190
-rw-r--r--tests/auto/qml/debugger/shared/debugutil_p.h127
-rw-r--r--tests/auto/qml/parserstress/parserstress.pro12
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-2.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.13-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-13.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.14.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.15.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.16.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.17.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.18.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.19.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.20.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-13.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-14.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-15.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-16.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-17.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-18.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.25-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.26-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.27-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.28-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.29-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.30-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.31-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.32-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.33-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.34-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.35-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.14-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-10-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-6-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-7-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-02.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.13.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.14.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.15.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.16.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.17.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.18.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/NativeObjects/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/NativeObjects/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma/README (renamed from tests/auto/declarative/parserstress/tests/ecma/README)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/SourceText/6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/SourceText/6-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/SourceText/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/SourceText/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.10-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-19.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-6-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-7-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.7-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.8-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.9-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.10-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.9-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.8.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.9-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/8.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/8.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/8.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/8.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/8.6.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/jsref.js (renamed from tests/auto/declarative/parserstress/tests/ecma/jsref.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/template.js (renamed from tests/auto/declarative/parserstress/tests/ecma/template.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/README (renamed from tests/auto/declarative/parserstress/tests/ecma_2/README)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/jsref.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/jsref.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/template.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/template.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.5.1-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/regress-101488.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-101488.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/regress-130451.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-130451.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-02.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-03.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-04.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-387501.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-421325.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-430717.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.1.2-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.3.2-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.4.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5-02.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/binding-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/binding-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-02.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-03.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.6.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.6.1-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.1-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.2-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Expressions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Expressions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/call-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/call-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-131964.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-131964.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-137181.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-137181.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-193555.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-193555.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-313570.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-49286.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-49286.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-58274.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-58274.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-85880.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-85880.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-94506.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-94506.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-97921.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-97921.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/scope-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/scope-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.2-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.2-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-02.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/regress-442242-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.1-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-005.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-361274.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-385393-07.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-72773.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-79129-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Operators/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/order-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/README (renamed from tests/auto/declarative/parserstress/tests/ecma_3/README)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-122076.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-122076.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-123437.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-123437.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-165353.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-165353.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169497.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169497.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-187133.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-187133.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-188206.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-188206.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-191479.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-191479.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-202564.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-202564.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209067.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209067.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209919.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209919.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-216591.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-216591.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-220367-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-220367-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223273.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223273.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223535.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223535.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-224676.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-224676.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225289.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225289.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225343.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225343.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-24712.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-24712.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-285219.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-28686.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-28686.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-289669.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-307456.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Regress/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-385393-04.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-419152.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420087.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420610.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-441477-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-131348.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-131348.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-157509.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-157509.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-194364.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-194364.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-226517.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-226517.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-302439.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-324650.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/switch-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/switch-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-189898.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-304376.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-313567.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-392378.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-83293.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/10.1.3-2.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/7.9.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-103087.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-103087.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-02.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-220367-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-220367-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-228087.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-228087.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-274152.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-320854.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-327170.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-368516.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-385393-03.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-429248.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-430740.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/template.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/template.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/shell.js (renamed from tests/auto/declarative/parserstress/tests/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tst_parserstress.cpp154
-rw-r--r--tests/auto/qml/qjsengine/qjsengine.pro13
-rw-r--r--tests/auto/qml/qjsengine/script/com/__init__.js (renamed from tests/auto/declarative/qjsengine/script/com/__init__.js)0
-rw-r--r--tests/auto/qml/qjsengine/script/com/trolltech/__init__.js (renamed from tests/auto/declarative/qjsengine/script/com/trolltech/__init__.js)0
-rw-r--r--tests/auto/qml/qjsengine/script/com/trolltech/recursive/__init__.js (renamed from tests/auto/declarative/qjsengine/script/com/trolltech/recursive/__init__.js)0
-rw-r--r--tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js (renamed from tests/auto/declarative/qjsengine/script/com/trolltech/syntaxerror/__init__.js)0
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp (renamed from tests/auto/declarative/qjsengine/tst_qjsengine.cpp)0
-rw-r--r--tests/auto/qml/qjsvalue/qjsvalue.pro6
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp (renamed from tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp)0
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.h (renamed from tests/auto/declarative/qjsvalue/tst_qjsvalue.h)0
-rw-r--r--tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro7
-rw-r--r--tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp (renamed from tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp)0
-rw-r--r--tests/auto/qml/qml.pro56
-rw-r--r--tests/auto/qml/qmlmin/qmlmin.pro9
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp193
-rw-r--r--tests/auto/qml/qmlplugindump/qmlplugindump.pro (renamed from tests/auto/declarative/qmlplugindump/qmlplugindump.pro)0
-rw-r--r--tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp (renamed from tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp)0
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createObject.qml (renamed from tests/auto/declarative/qdeclarativecomponent/data/createObject.qml)0
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml (renamed from tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml)0
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createParentReference.qml (renamed from tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml)0
-rw-r--r--tests/auto/qml/qqmlcomponent/data/incubateObject.qml (renamed from tests/auto/declarative/qdeclarativecomponent/data/incubateObject.qml)0
-rw-r--r--tests/auto/qml/qqmlcomponent/qqmlcomponent.pro15
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp218
-rw-r--r--tests/auto/qml/qqmlconsole/data/assert.qml (renamed from tests/auto/declarative/qdeclarativeconsole/data/assert.qml)0
-rw-r--r--tests/auto/qml/qqmlconsole/data/exception.qml (renamed from tests/auto/declarative/qdeclarativeconsole/data/exception.qml)0
-rw-r--r--tests/auto/qml/qqmlconsole/data/logging.qml (renamed from tests/auto/declarative/qdeclarativeconsole/data/logging.qml)0
-rw-r--r--tests/auto/qml/qqmlconsole/data/profiling.qml (renamed from tests/auto/declarative/qdeclarativeconsole/data/profiling.qml)0
-rw-r--r--tests/auto/qml/qqmlconsole/data/tracing.qml56
-rw-r--r--tests/auto/qml/qqmlconsole/qqmlconsole.pro15
-rw-r--r--tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp170
-rw-r--r--tests/auto/qml/qqmlcontext/data/Object_22535.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/Object_22535.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/RefreshExpressionsType.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/data/qtbug_22535.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/qtbug_22535.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/data/refreshExpressions.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/refreshExpressions.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/refreshExpressionsRootContext.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/qqmlcontext.pro15
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp652
-rw-r--r--tests/auto/qml/qqmlcpputils/qqmlcpputils.pro9
-rw-r--r--tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp106
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/CustomObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/MethodsObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarInheritanceComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarOwnershipComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVar.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVariant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceVarComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/Scope6Nested.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ScopeObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/SequenceConversionComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.7.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/attachedProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/automaticSemicolon.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/bindingLoop.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/blank.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/blank.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/booleanConversion.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/bug.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/compiled.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deferredProperties.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deleteLater.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deleteWhileBindingRunning.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deletedEngine.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deletedObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/doubleEvaluate.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreationOwnership.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicString.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicString.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/elementAssign.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/enums.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/enums.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/eval.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/eval.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/exception.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/exception.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/extensionObjects.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/forInLoop.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/forInLoop.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/function.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/function.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/importScope.1.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/importScope.2.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/importScope.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/in.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/in.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_callback.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_callback.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_pragma.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_remote.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_remote.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_remote_missing.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_shared.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_shared.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/js/include2.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/js/include3.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFive.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFour.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importOne.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibrary.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importThree.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importTwo.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importWithNoImports.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testModuleImport.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testScriptImport.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importOne.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importPragmaLibrary.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importWithImports.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testModuleImport.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testScriptImport.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/listAssignment.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/listAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/listProperties.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/listToVariant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMajorVersionFail.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMinorVersionFail.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApi.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiCaching.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiEnums.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiWriting.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApi.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiCaching.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiWriting.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/nonExistentAttachedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/nonNotifyable.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nonscriptable.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/numberAssignment.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectConversion.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/objectConversion.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectName.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ownership.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertySplicing.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.7.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.8.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.9.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.inherit.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.reparent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarCpp.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarImplicitOwnership.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.type.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlToString.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qobjectDerivedArgument.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_11600.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21580.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_21864.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22464.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22843.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_9792.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/realToInt.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/regExp.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/regExp.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/regExp.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/remote_file.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml23
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml23
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameWithBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceObjectGc.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptErrors.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.array.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.error.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.copy.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.indexes.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.error.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.threads.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.error.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalHandlers.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalHandlers.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalWithJSValueInVariant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalWithQJSValue.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalWithUnknownTypes.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/stringArg.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/stringArg.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/threadScript.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/threadScript.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/transientErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/typeOf.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/typeOf.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/unaryExpression.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/unaryExpression.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/urlListProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/urlListProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/v8bindingException.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/v8bindingException.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/v8functionException.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/v8functionException.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/withStatement.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/withStatement.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/qqmlecmascript.pro22
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp210
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h1313
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp6097
-rw-r--r--tests/auto/qml/qqmlengine/qqmlengine.pro9
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp365
-rw-r--r--tests/auto/qml/qqmlerror/data/test.txt (renamed from tests/auto/declarative/qdeclarativeerror/data/test.txt)0
-rw-r--r--tests/auto/qml/qqmlerror/qqmlerror.pro15
-rw-r--r--tests/auto/qml/qqmlerror/tst_qqmlerror.cpp243
-rw-r--r--tests/auto/qml/qqmlexpression/data/scriptString.qml (renamed from tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml)0
-rw-r--r--tests/auto/qml/qqmlexpression/qqmlexpression.pro15
-rw-r--r--tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp121
-rw-r--r--tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro9
-rw-r--r--tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp424
-rw-r--r--tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/AsynchronousIfNestedType.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.1.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.2.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.3.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/chainInCompletion.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/chainInCompletion.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/chainedAsynchronousIfNested.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/clear.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/clear.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/clearDuringCompletion.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/contextDelete.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/forceCompletion.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/forceCompletion.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/nestedComponent.js (renamed from tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.js)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/nestedComponent.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/noIncubationController.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/noIncubationController.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt (renamed from tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/objectDeleted.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.1.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.2.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/selfDelete.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/selfDelete.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/setInitialState.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/setInitialState.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/statusChanged.nested.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/statusChanged.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/statusChanged.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/qqmlincubator.pro18
-rw-r--r--tests/auto/qml/qqmlincubator/testtypes.cpp137
-rw-r--r--tests/auto/qml/qqmlincubator/testtypes.h125
-rw-r--r--tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp1030
-rw-r--r--tests/auto/qml/qqmlinfo/data/NestedComponent.qml (renamed from tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlinfo/data/NestedObject.qml (renamed from tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml (renamed from tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml)0
-rw-r--r--tests/auto/qml/qqmlinfo/data/qmlObject.qml (renamed from tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml)0
-rw-r--r--tests/auto/qml/qqmlinfo/qqmlinfo.pro14
-rw-r--r--tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp221
-rw-r--r--tests/auto/qml/qqmlinstruction/qqmlinstruction.pro8
-rw-r--r--tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp678
-rw-r--r--tests/auto/qml/qqmllanguage/data/Alias.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/Alias.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/Alias2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/Alias3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/Alias4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/ComponentComposite.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeType2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeType3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeType4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/HelperAlias.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/I18n.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/I18n.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/I18nType30.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/LocalLast.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/MyComponent.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/NestedAlias.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/OnCompletedType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/OnDestructionType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignToNamespace.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/attachedProperties.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/componentCompositeType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/cppnamespace.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/crash2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/crash2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customOnProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customParserTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customVariantTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/defaultGrouped.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/destroyedSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/doubleSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/duplicateIDs.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicProperties.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/empty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/empty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/empty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/emptySignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/enumTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/failingComponentTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/finalOverride.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nScript.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nStrings.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/idProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importFile.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importFile.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importFile.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNewerVersion.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNonExist.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNonExist.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importscript.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCase.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/interfaceProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/interfaceQList.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidImportID.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidOn.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidOn.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidOn.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listProperties.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/method.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/method.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/method.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingObject.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingObject.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nestedErrors.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/noCreation.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/noCreation.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/notAvailable.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullDotProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/onCompleted.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/onDestruction.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyInit.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyInit.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyValueSource.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/LocalInternal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/Test.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestLocal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestNamed.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestSubDir.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/UndeclaredLocal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/WrongTestLocal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/noqmldir/Test.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/pics/blue.png)bin84 -> 84 bytes
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/SubTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readonly.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readonly.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/registrationOrder.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/registrationOrder.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/revisions11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/revisionssub11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleBindings.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleContainer.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleObject.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/singularProperty.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/singularProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/subdir/Test.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/test.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/test.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/test2.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/test2.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/unregisteredObject.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/valueTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/variantNotify.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/versionedbase.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.12.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.13.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.14.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.15.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.16.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.17.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/qqmllanguage.pro18
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp (renamed from tests/auto/declarative/qdeclarativelanguage/testtypes.cpp)0
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h824
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp2290
-rw-r--r--tests/auto/qml/qqmllistreference/data/MyType.qml (renamed from tests/auto/declarative/qdeclarativelistreference/data/MyType.qml)0
-rw-r--r--tests/auto/qml/qqmllistreference/data/engineTypes.qml (renamed from tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllistreference/data/variantToList.qml (renamed from tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml)0
-rw-r--r--tests/auto/qml/qqmllistreference/qqmllistreference.pro15
-rw-r--r--tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp570
-rw-r--r--tests/auto/qml/qqmllocale/data/date.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/date.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/data/functions.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/functions.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/data/localeCompare.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/localeCompare.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/data/number.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/number.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/data/properties.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/properties.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/qqmllocale.pro15
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp1219
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/method.1.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/method.2.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/method.3.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.alias.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.bool.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.color.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.date.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.int.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.real.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.string.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.url.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.var.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.variant.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.1.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.2.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.3.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.4.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.5.qml (renamed from tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml)0
-rw-r--r--tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro14
-rw-r--r--tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp364
-rw-r--r--tests/auto/qml/qqmlmetatype/qqmlmetatype.pro7
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp202
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/implicitQmldir.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/implicitQmldir.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/pluginWithQmlFile.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/works.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/works.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/works2.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/works2.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/works21.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/works21.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/empty.json (renamed from tests/auto/declarative/qdeclarativemoduleplugin/empty.json)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp84
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp84
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp83
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp73
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp73
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp58
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp83
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro8
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro9
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp353
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro19
-rw-r--r--tests/auto/qml/qqmlparser/qqmlparser.pro9
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp210
-rw-r--r--tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml (renamed from tests/auto/declarative/qdeclarativepixmapcache/data/dataLeak.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/TestType.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/TestType.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/assignEmptyVariantMap.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/qqmlproperty.pro15
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp1721
-rw-r--r--tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro8
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp281
-rw-r--r--tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro9
-rw-r--r--tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp241
-rw-r--r--tests/auto/qml/qqmlqt/data/atob.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/atob.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/btoa.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/btoa.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createComponent.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/createComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createComponentData.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createComponent_lib.js (renamed from tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createComponent_lib.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createQmlObject.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/darker.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/darker.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/dateTimeConversion.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/enums.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/enums.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/fontFamilies.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/formatting.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/formatting.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/hsla.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/hsla.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/isQtObject.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/lighter.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/lighter.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/md5.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/md5.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/openUrlExternally.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js (renamed from tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js)0
-rw-r--r--tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/point.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/point.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/quit.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/quit.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/rect.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/rect.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/resolvedUrl.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/resolvedUrl.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/rgba.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/rgba.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/size.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/size.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/tint.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/tint.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/vector.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/vector.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/vector4.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/vector4.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/qqmlqt.pro15
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp732
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/README (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/README)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/changeversion.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/creation-a.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/creation-a.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/creation.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/creation.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-a.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-a.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-b.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-b.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-creation.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-creation.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-notransaction.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-outsidetransaction.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/iteration-forwardonly.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/iteration.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/iteration.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/readonly-error.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/readonly-error.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/readonly.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/reopen1.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/reopen1.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/reopen2.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/reopen2.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/selection-bindnames.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/selection.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/selection.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro15
-rw-r--r--tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp243
-rw-r--r--tests/auto/qml/qqmltranslation/data/idtranslation.qml (renamed from tests/auto/declarative/qdeclarativetranslation/data/idtranslation.qml)0
-rw-r--r--tests/auto/qml/qqmltranslation/data/qml_fr.qm (renamed from tests/auto/declarative/qdeclarativetranslation/data/qml_fr.qm)bin374 -> 374 bytes
-rw-r--r--tests/auto/qml/qqmltranslation/data/qml_fr.ts (renamed from tests/auto/declarative/qdeclarativetranslation/data/qml_fr.ts)0
-rw-r--r--tests/auto/qml/qqmltranslation/data/qmlid_fr.qm (renamed from tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.qm)bin119 -> 119 bytes
-rw-r--r--tests/auto/qml/qqmltranslation/data/qmlid_fr.ts (renamed from tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.ts)0
-rw-r--r--tests/auto/qml/qqmltranslation/data/translation.qml (renamed from tests/auto/declarative/qdeclarativetranslation/data/translation.qml)0
-rw-r--r--tests/auto/qml/qqmltranslation/data/translation.qrc (renamed from tests/auto/declarative/qdeclarativetranslation/data/translation.qrc)0
-rw-r--r--tests/auto/qml/qqmltranslation/qqmltranslation.pro16
-rw-r--r--tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp137
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/deletedObject.js (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.1.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.5.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/returnValues.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/valueSources.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/variant_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro18
-rw-r--r--tests/auto/qml/qqmlvaluetypes/testtypes.cpp (renamed from tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/testtypes.h219
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp1319
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/attr.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/attr.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/document.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/document.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/element.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/element.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.400.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/text.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/text.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/utf16.html (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml)bin154 -> 154 bytes
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro19
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp1160
-rw-r--r--tests/auto/qml/qquickbinding/data/deletedObject.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/data/restoreBinding.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/restoreBinding.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/restoreBindingWithLoop.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/data/test-binding.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/test-binding.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/data/test-binding2.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/qquickbinding.pro15
-rw-r--r--tests/auto/qml/qquickbinding/tst_qquickbinding.cpp197
-rw-r--r--tests/auto/qml/qquickchangeset/qquickchangeset.pro9
-rw-r--r--tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp812
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-targetchange.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/error-object.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/error-object.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/error-property.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/error-property.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/error-property2.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/error-syntax.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/moduleapi-target.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/moduleapi-target.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/test-connection.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/test-connection2.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/test-connection3.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/trimming.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/trimming.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/qquickconnection.pro15
-rw-r--r--tests/auto/qml/qquickconnection/tst_qquickconnection.cpp292
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/basic.qml (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/dummy.qml (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/resetFiltering.qml)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/innerdir/test2.txt)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/test.txt)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro14
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp179
-rw-r--r--tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro9
-rw-r--r--tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp1637
-rw-r--r--tests/auto/qml/qquicklistmodel/data/enumerate.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/model.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/model.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/multipleroles.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/script.js (renamed from tests/auto/declarative/qdeclarativelistmodel/data/script.js)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/signalhandlers.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workerremoveelement.js (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.js)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workerremoveelement.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workerremovelist.js (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.js)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workerremovelist.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workersync.js (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workersync.js)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workersync.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workersync.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/qquicklistmodel.pro15
-rw-r--r--tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp1632
-rw-r--r--tests/auto/qml/qquickworkerscript/data/BaseWorker.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/Global.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/Global.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/externalObjectWorker.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_error_onCall.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_fixed_return.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_include.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_pragma.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/stressDispose.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/stressDispose.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_include.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_pragma.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/qquickworkerscript.pro15
-rw-r--r--tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp300
-rw-r--r--tests/auto/qml/runall.sh100
-rw-r--r--tests/auto/qml/v4/data/colorType.qml (renamed from tests/auto/declarative/v4/data/colorType.qml)0
-rw-r--r--tests/auto/qml/v4/data/conditionalExpr.qml (renamed from tests/auto/declarative/v4/data/conditionalExpr.qml)0
-rw-r--r--tests/auto/qml/v4/data/doubleBoolJump.qml (renamed from tests/auto/declarative/v4/data/doubleBoolJump.qml)0
-rw-r--r--tests/auto/qml/v4/data/fetchException.qml (renamed from tests/auto/declarative/v4/data/fetchException.qml)0
-rw-r--r--tests/auto/qml/v4/data/logicalOr.2.qml (renamed from tests/auto/declarative/v4/data/logicalOr.2.qml)0
-rw-r--r--tests/auto/qml/v4/data/logicalOr.qml (renamed from tests/auto/declarative/v4/data/logicalOr.qml)0
-rw-r--r--tests/auto/qml/v4/data/nestedLogicalOr.qml (renamed from tests/auto/declarative/v4/data/nestedLogicalOr.qml)0
-rw-r--r--tests/auto/qml/v4/data/nestedObjectAccess.qml (renamed from tests/auto/declarative/v4/data/nestedObjectAccess.qml)0
-rw-r--r--tests/auto/qml/v4/data/nullQObject.qml (renamed from tests/auto/declarative/v4/data/nullQObject.qml)0
-rw-r--r--tests/auto/qml/v4/data/qrealToIntRounding.qml (renamed from tests/auto/declarative/v4/data/qrealToIntRounding.qml)0
-rw-r--r--tests/auto/qml/v4/data/qtbug_21883.qml (renamed from tests/auto/declarative/v4/data/qtbug_21883.qml)0
-rw-r--r--tests/auto/qml/v4/data/qtbug_22816.qml (renamed from tests/auto/declarative/v4/data/qtbug_22816.qml)0
-rw-r--r--tests/auto/qml/v4/data/stringComparison.qml (renamed from tests/auto/declarative/v4/data/stringComparison.qml)0
-rw-r--r--tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml (renamed from tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml)0
-rw-r--r--tests/auto/qml/v4/data/unaryMinus.qml (renamed from tests/auto/declarative/v4/data/unaryMinus.qml)0
-rw-r--r--tests/auto/qml/v4/data/unaryPlus.qml (renamed from tests/auto/declarative/v4/data/unaryPlus.qml)0
-rw-r--r--tests/auto/qml/v4/data/unnecessaryReeval.qml (renamed from tests/auto/declarative/v4/data/unnecessaryReeval.qml)0
-rw-r--r--tests/auto/qml/v4/testtypes.cpp49
-rw-r--r--tests/auto/qml/v4/testtypes.h (renamed from tests/auto/declarative/v4/testtypes.h)0
-rw-r--r--tests/auto/qml/v4/tst_v4.cpp371
-rw-r--r--tests/auto/qml/v4/v4.pro17
-rw-r--r--tests/auto/qmldevtools/compile/tst_compile.cpp10
-rw-r--r--tests/auto/qmltest/createbenchmark/item.qml2
-rw-r--r--tests/auto/qmltest/qmltest.pro2
-rw-r--r--tests/auto/qmltest/qqmlbinding/tst_binding.qml (renamed from tests/auto/qmltest/qdeclarativebinding/tst_binding.qml)0
-rw-r--r--tests/auto/qmltest/qqmlbinding/tst_binding2.qml (renamed from tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml)0
-rw-r--r--tests/auto/qtquick2/examples/examples.pro10
-rw-r--r--tests/auto/qtquick2/examples/tst_examples.cpp299
-rw-r--r--tests/auto/qtquick2/geometry/geometry.pro9
-rw-r--r--tests/auto/qtquick2/nodes/nodes.pro9
-rw-r--r--tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro10
-rw-r--r--tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp42
-rw-r--r--tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro18
-rw-r--r--tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp1334
-rw-r--r--tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro7
-rw-r--r--tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp159
-rw-r--r--tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp473
-rw-r--r--tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro17
-rw-r--r--tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp255
-rw-r--r--tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp199
-rw-r--r--tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro21
-rw-r--r--tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp467
-rw-r--r--tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp242
-rw-r--r--tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp133
-rw-r--r--tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro14
-rw-r--r--tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp1608
-rw-r--r--tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro8
-rw-r--r--tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp189
-rw-r--r--tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro8
-rw-r--r--tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp185
-rw-r--r--tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro8
-rw-r--r--tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp393
-rw-r--r--tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp962
-rw-r--r--tests/auto/qtquick2/qquickaccessible/data/hittest.qml176
-rw-r--r--tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro25
-rw-r--r--tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp410
-rw-r--r--tests/auto/qtquick2/qquickanchors/qquickanchors.pro16
-rw-r--r--tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp710
-rw-r--r--tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro17
-rw-r--r--tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp374
-rw-r--r--tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro15
-rw-r--r--tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp83
-rw-r--r--tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro17
-rw-r--r--tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp373
-rw-r--r--tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro20
-rw-r--r--tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp775
-rw-r--r--tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro34
-rw-r--r--tests/auto/qtquick2/qquickdrag/qquickdrag.pro9
-rw-r--r--tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp1034
-rw-r--r--tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro11
-rw-r--r--tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp1118
-rw-r--r--tests/auto/qtquick2/qquickflickable/qquickflickable.pro15
-rw-r--r--tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp663
-rw-r--r--tests/auto/qtquick2/qquickflipable/qquickflipable.pro15
-rw-r--r--tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp135
-rw-r--r--tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro14
-rw-r--r--tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp636
-rw-r--r--tests/auto/qtquick2/qquickgridview/data/addTransitions.qml129
-rw-r--r--tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml143
-rw-r--r--tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml146
-rw-r--r--tests/auto/qtquick2/qquickgridview/qquickgridview.pro15
-rw-r--r--tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp5310
-rw-r--r--tests/auto/qtquick2/qquickimage/qquickimage.pro17
-rw-r--r--tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp749
-rw-r--r--tests/auto/qtquick2/qquickitem/qquickitem.pro14
-rw-r--r--tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp1468
-rw-r--r--tests/auto/qtquick2/qquickitem2/qquickitem2.pro15
-rw-r--r--tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp1380
-rw-r--r--tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro38
-rw-r--r--tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp436
-rw-r--r--tests/auto/qtquick2/qquicklistview/data/addTransitions.qml134
-rw-r--r--tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml141
-rw-r--r--tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml144
-rw-r--r--tests/auto/qtquick2/qquicklistview/qquicklistview.pro16
-rw-r--r--tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp5997
-rw-r--r--tests/auto/qtquick2/qquickloader/qquickloader.pro19
-rw-r--r--tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp987
-rw-r--r--tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro17
-rw-r--r--tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp806
-rw-r--r--tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro11
-rw-r--r--tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp727
-rw-r--r--tests/auto/qtquick2/qquickpathview/qquickpathview.pro15
-rw-r--r--tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp1458
-rw-r--r--tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro15
-rw-r--r--tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp404
-rw-r--r--tests/auto/qtquick2/qquickpositioners/data/transitions.qml196
-rw-r--r--tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro15
-rw-r--r--tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp1927
-rw-r--r--tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro15
-rw-r--r--tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp644
-rw-r--r--tests/auto/qtquick2/qquickscreen/qquickscreen.pro10
-rw-r--r--tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp77
-rw-r--r--tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro8
-rw-r--r--tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro15
-rw-r--r--tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp98
-rw-r--r--tests/auto/qtquick2/qquicktext/qquicktext.pro19
-rw-r--r--tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp2484
-rw-r--r--tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro16
-rw-r--r--tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp3881
-rw-r--r--tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro13
-rw-r--r--tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp4703
-rw-r--r--tests/auto/qtquick2/qquickview/qquickview.pro13
-rw-r--r--tests/auto/qtquick2/qquickview/tst_qquickview.cpp207
-rw-r--r--tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro16
-rw-r--r--tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp3446
-rw-r--r--tests/auto/qtquick2/qtquick2.pro71
-rw-r--r--tests/auto/qtquick2/rendernode/rendernode.pro18
-rw-r--r--tests/auto/qtquick2/rendernode/tst_rendernode.cpp242
-rw-r--r--tests/auto/qtquick2/shared/util.pri7
-rw-r--r--tests/auto/qtquick2/shared/viewtestutil.cpp493
-rw-r--r--tests/auto/qtquick2/shared/viewtestutil.h182
-rw-r--r--tests/auto/qtquick2/shared/visualtestutil.h112
-rw-r--r--tests/auto/quick/examples/data/dummytest.qml (renamed from tests/auto/qtquick2/examples/data/dummytest.qml)0
-rw-r--r--tests/auto/quick/examples/data/webbrowser/webbrowser.qml (renamed from tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml)0
-rw-r--r--tests/auto/quick/examples/examples.pro10
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp299
-rw-r--r--tests/auto/quick/geometry/geometry.pro9
-rw-r--r--tests/auto/quick/geometry/tst_geometry.cpp (renamed from tests/auto/qtquick2/geometry/tst_geometry.cpp)0
-rw-r--r--tests/auto/quick/nodes/nodes.pro9
-rw-r--r--tests/auto/quick/nodes/tst_nodestest.cpp (renamed from tests/auto/qtquick2/nodes/tst_nodestest.cpp)0
-rw-r--r--tests/auto/quick/qquickaccessible/data/checkbuttons.qml (renamed from tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml)0
-rw-r--r--tests/auto/quick/qquickaccessible/data/hittest.qml176
-rw-r--r--tests/auto/quick/qquickaccessible/data/pushbutton.qml (renamed from tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml)0
-rw-r--r--tests/auto/quick/qquickaccessible/data/statictext.qml (renamed from tests/auto/qtquick2/qquickaccessible/data/statictext.qml)0
-rw-r--r--tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml (renamed from tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml)0
-rw-r--r--tests/auto/quick/qquickaccessible/qquickaccessible.pro25
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp410
-rw-r--r--tests/auto/quick/qquickanchors/data/anchors.qml (renamed from tests/auto/qtquick2/qquickanchors/data/anchors.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/centerin.qml (renamed from tests/auto/qtquick2/qquickanchors/data/centerin.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/centerinRotation.qml (renamed from tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/crash1.qml (renamed from tests/auto/qtquick2/qquickanchors/data/crash1.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/fill.qml (renamed from tests/auto/qtquick2/qquickanchors/data/fill.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/hvCenter.qml (renamed from tests/auto/qtquick2/qquickanchors/data/hvCenter.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/loop1.qml (renamed from tests/auto/qtquick2/qquickanchors/data/loop1.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/loop2.qml (renamed from tests/auto/qtquick2/qquickanchors/data/loop2.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/margins.qml (renamed from tests/auto/qtquick2/qquickanchors/data/margins.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/stretch.qml (renamed from tests/auto/qtquick2/qquickanchors/data/stretch.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/qquickanchors.pro16
-rw-r--r--tests/auto/quick/qquickanchors/tst_qquickanchors.cpp710
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/colors.gif (renamed from tests/auto/qtquick2/qquickanimatedimage/data/colors.gif)bin505 -> 505 bytes
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/colors.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/colors.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/hearts.gif (renamed from tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif)bin6524 -> 6524 bytes
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/hearts.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/qmldir (renamed from tests/auto/qtquick2/qquickanimatedimage/data/qmldir)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickman.gif (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif)bin164923 -> 164923 bytes
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickman.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro17
-rw-r--r--tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp374
-rw-r--r--tests/auto/quick/qquickanimatedsprite/data/basic.qml (renamed from tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedsprite/data/squarefacesprite.png (renamed from tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro15
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp83
-rw-r--r--tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml (renamed from tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml)0
-rw-r--r--tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro10
-rw-r--r--tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp42
-rw-r--r--tests/auto/quick/qquickanimations/data/Double.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/attached.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badproperty1.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badproperty2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badtype1.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badtype2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badtype3.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badtype4.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/disabledTransition.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/dontAutoStart.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/dontStart.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/dontStart2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/dotproperty.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/looping.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/mixedtype1.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/mixedtype2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/nonTransitionBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathAnimation.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathAnimation2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathInterpolator.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathTransition.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pauseBindingBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pauseBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties3.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties4.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties5.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition3.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition4.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition5.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition6.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition7.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/reanchor.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/registrationBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/reparent.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/rotation.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/runningTrueBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/valuesource.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/valuesource2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/qquickanimations.pro18
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp1334
-rw-r--r--tests/auto/quick/qquickapplication/qquickapplication.pro7
-rw-r--r--tests/auto/quick/qquickapplication/tst_qquickapplication.cpp159
-rw-r--r--tests/auto/quick/qquickbehaviors/data/binding.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/color.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/cpptrigger.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/disabled.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/dontStart.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/empty.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/explicit.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/groupProperty.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/groupProperty2.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/loop.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/parent.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/qtbug12295.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/runningTrue.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/scripttrigger.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/simple.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/startup.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/startup2.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/valueType.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/qquickbehaviors.pro15
-rw-r--r--tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp473
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-mirror.png (renamed from tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png)bin5554 -> 5554 bytes
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci (renamed from tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci)0
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-round-remote.sci (renamed from tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci)0
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-round.sci (renamed from tests/auto/qtquick2/qquickborderimage/data/colors-round.sci)0
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors.png (renamed from tests/auto/qtquick2/qquickcanvas/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/quick/qquickborderimage/data/heart200.png (renamed from tests/auto/qtquick2/qquickborderimage/data/heart200.png)bin7943 -> 7943 bytes
-rw-r--r--tests/auto/quick/qquickborderimage/data/invalid.sci (renamed from tests/auto/qtquick2/qquickborderimage/data/invalid.sci)0
-rw-r--r--tests/auto/quick/qquickborderimage/data/mirror.qml (renamed from tests/auto/qtquick2/qquickborderimage/data/mirror.qml)0
-rw-r--r--tests/auto/quick/qquickborderimage/qquickborderimage.pro17
-rw-r--r--tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp373
-rw-r--r--tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml (renamed from tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml)0
-rw-r--r--tests/auto/quick/qquickcanvas/data/Headless.qml (renamed from tests/auto/qtquick2/qquickcanvas/data/Headless.qml)0
-rw-r--r--tests/auto/quick/qquickcanvas/data/colors.png (renamed from tests/auto/qtquick2/qquickimage/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/quick/qquickcanvas/data/focus.qml (renamed from tests/auto/qtquick2/qquickcanvas/data/focus.qml)0
-rw-r--r--tests/auto/quick/qquickcanvas/data/window.qml (renamed from tests/auto/qtquick2/qquickcanvas/data/window.qml)0
-rw-r--r--tests/auto/quick/qquickcanvas/qquickcanvas.pro20
-rw-r--r--tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp775
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/anim-gr.gif (renamed from tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif)bin241 -> 241 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/anim-gr.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png)bin460 -> 460 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png)bin422 -> 422 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/background.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/background.png)bin86 -> 86 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/broken.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/broken.png)bin87 -> 87 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png)bin120 -> 120 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green-16x16.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png)bin92 -> 92 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green-1x1.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png)bin82 -> 82 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png)bin103 -> 103 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green-2x2.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png)bin118 -> 118 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green.png)bin87 -> 87 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png)bin130 -> 130 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/red-16x16.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png)bin130 -> 130 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/red.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/red.png)bin87 -> 87 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/redtransparent.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png)bin109 -> 109 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png)bin131 -> 131 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png)bin120 -> 120 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/testhelper.js (renamed from tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/transparent.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/transparent.png)bin100 -> 100 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/transparent50.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png)bin155 -> 155 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_arc.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_composite.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_context.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_line.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_path.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_state.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_text.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_transform.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/yellow.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/yellow.png)bin95 -> 95 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/yellow75.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png)bin150 -> 150 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro34
-rw-r--r--tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp (renamed from tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp)0
-rw-r--r--tests/auto/quick/qquickdrag/qquickdrag.pro9
-rw-r--r--tests/auto/quick/qquickdrag/tst_qquickdrag.cpp1034
-rw-r--r--tests/auto/quick/qquickdroparea/qquickdroparea.pro11
-rw-r--r--tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp1118
-rw-r--r--tests/auto/quick/qquickflickable/data/disabled.qml (renamed from tests/auto/qtquick2/qquickflickable/data/disabled.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickable01.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickable01.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickable02.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickable02.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickable03.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickable03.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickable04.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickable04.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/margins.qml (renamed from tests/auto/qtquick2/qquickflickable/data/margins.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/nestedPressDelay.qml (renamed from tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/resize.qml (renamed from tests/auto/qtquick2/qquickflickable/data/resize.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/wheel.qml (renamed from tests/auto/qtquick2/qquickflickable/data/wheel.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/qquickflickable.pro15
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp663
-rw-r--r--tests/auto/quick/qquickflipable/data/crash.qml (renamed from tests/auto/qtquick2/qquickflipable/data/crash.qml)0
-rw-r--r--tests/auto/quick/qquickflipable/data/flipable-abort.qml (renamed from tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml)0
-rw-r--r--tests/auto/quick/qquickflipable/data/test-flipable.qml (renamed from tests/auto/qtquick2/qquickflipable/data/test-flipable.qml)0
-rw-r--r--tests/auto/quick/qquickflipable/qquickflipable.pro15
-rw-r--r--tests/auto/quick/qquickflipable/tst_qquickflipable.cpp135
-rw-r--r--tests/auto/quick/qquickfocusscope/data/canvasFocus.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/chain.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/chain.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/forcefocus.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/qtBug13380.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/signalEmission.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test2.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test2.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test3.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test3.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test4.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test4.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test5.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test5.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/qquickfocusscope.pro14
-rw-r--r--tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp636
-rw-r--r--tests/auto/quick/qquickfontloader/data/daniel.ttf (renamed from tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf)bin51984 -> 51984 bytes
-rw-r--r--tests/auto/quick/qquickfontloader/data/dummy.ttf (renamed from tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf)0
-rw-r--r--tests/auto/quick/qquickfontloader/data/qtbug-20268.qml (renamed from tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml)0
-rw-r--r--tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttfbin0 -> 24544 bytes
-rw-r--r--tests/auto/quick/qquickfontloader/qquickfontloader.pro17
-rw-r--r--tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp255
-rw-r--r--tests/auto/quick/qquickgridview/data/ComponentView.qml (renamed from tests/auto/qtquick2/qquickgridview/data/ComponentView.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/addTransitions.qml129
-rw-r--r--tests/auto/quick/qquickgridview/data/asyncloader.qml (renamed from tests/auto/qtquick2/qquickgridview/data/asyncloader.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/attachedSignals.qml (renamed from tests/auto/qtquick2/qquickgridview/data/attachedSignals.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/creationContext.qml (renamed from tests/auto/qtquick2/qquickgridview/data/creationContext.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/displacedTransitions.qml (renamed from tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/displaygrid.qml (renamed from tests/auto/qtquick2/qquickgridview/data/displaygrid.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/footer.qml (renamed from tests/auto/qtquick2/qquickgridview/data/footer.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview-enforcerange.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview-enforcerange.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview-initCurrent.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview-noCurrent.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview-noCurrent.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview1.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview1.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview2.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview2.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview3.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview3.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview4.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview4.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/header.qml (renamed from tests/auto/qtquick2/qquickgridview/data/header.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/manual-highlight.qml (renamed from tests/auto/qtquick2/qquickgridview/data/manual-highlight.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/margins.qml (renamed from tests/auto/qtquick2/qquickgridview/data/margins.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/mirroring.qml (renamed from tests/auto/qtquick2/qquickgridview/data/mirroring.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/moveTransitions.qml143
-rw-r--r--tests/auto/quick/qquickgridview/data/multipleTransitions.qml (renamed from tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/populateTransitions.qml (renamed from tests/auto/qtquick2/qquickgridview/data/populateTransitions.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/propertychangestest.qml (renamed from tests/auto/qtquick2/qquickgridview/data/propertychangestest.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/removeTransitions.qml146
-rw-r--r--tests/auto/quick/qquickgridview/data/resizeview.qml (renamed from tests/auto/qtquick2/qquickgridview/data/resizeview.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/setindex.qml (renamed from tests/auto/qtquick2/qquickgridview/data/setindex.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/snapOneRow.qml (renamed from tests/auto/qtquick2/qquickgridview/data/snapOneRow.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/snapToRow.qml (renamed from tests/auto/qtquick2/qquickgridview/data/snapToRow.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/unaligned.qml (renamed from tests/auto/qtquick2/qquickgridview/data/unaligned.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/unrequestedItems.qml (renamed from tests/auto/qtquick2/qquickgridview/data/unrequestedItems.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/qquickgridview.pro15
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp5310
-rw-r--r--tests/auto/quick/qquickimage/data/aspectratio.qml (renamed from tests/auto/qtquick2/qquickimage/data/aspectratio.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/big.jpeg (renamed from tests/auto/qtquick2/qquickimage/data/big.jpeg)bin1700081 -> 1700081 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/big256.png (renamed from tests/auto/qtquick2/qquickimage/data/big256.png)bin3566 -> 3566 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/colors.png (renamed from tests/auto/qtquick2/qquickimage/data/colors1.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/colors1.pngbin0 -> 1655 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/green.png (renamed from tests/auto/qtquick2/qquickimage/data/green.png)bin314 -> 314 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/heart-win32.png (renamed from tests/auto/qtquick2/qquickimage/data/heart-win32.png)bin12621 -> 12621 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/heart.png (renamed from tests/auto/qtquick2/qquickimage/data/heart.png)bin12577 -> 12577 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/heart.svg (renamed from tests/auto/qtquick2/qquickimage/data/heart.svg)0
-rw-r--r--tests/auto/quick/qquickimage/data/heart200-win32.png (renamed from tests/auto/qtquick2/qquickimage/data/heart200-win32.png)bin8062 -> 8062 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/heart200.png (renamed from tests/auto/qtquick2/qquickimage/data/heart200.png)bin8063 -> 8063 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/htiling.qml (renamed from tests/auto/qtquick2/qquickimage/data/htiling.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/mirror.qml (renamed from tests/auto/qtquick2/qquickimage/data/mirror.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/nullpixmap.qml (renamed from tests/auto/qtquick2/qquickimage/data/nullpixmap.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/pattern.png (renamed from tests/auto/qtquick2/qquickimage/data/pattern.png)bin1371 -> 1371 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/qtbug_16389.qml (renamed from tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/qtbug_22125.qml (renamed from tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/rect.png (renamed from tests/auto/qtquick2/qquickimage/data/rect.png)bin171 -> 171 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/sourceSize.qml (renamed from tests/auto/qtquick2/qquickimage/data/sourceSize.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/vtiling.qml (renamed from tests/auto/qtquick2/qquickimage/data/vtiling.qml)0
-rw-r--r--tests/auto/quick/qquickimage/qquickimage.pro17
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp749
-rw-r--r--tests/auto/quick/qquickitem/data/order.1.qml (renamed from tests/auto/qtquick2/qquickitem/data/order.1.qml)0
-rw-r--r--tests/auto/quick/qquickitem/data/order.2.qml (renamed from tests/auto/qtquick2/qquickitem/data/order.2.qml)0
-rw-r--r--tests/auto/quick/qquickitem/data/polishOnCompleted.qml (renamed from tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml)0
-rw-r--r--tests/auto/quick/qquickitem/qquickitem.pro14
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp1468
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenProperty.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRect.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenRect.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRectBug.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRectBug2.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRectBug3.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/implicitsize.qml (renamed from tests/auto/qtquick2/qquickitem2/data/implicitsize.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keynavigationtest.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keysim.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keysim.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keyspriority.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keyspriority.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keystest.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keystest.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/layoutmirroring.qml (renamed from tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/mapCoordinates.qml (renamed from tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/parentLoop.qml (renamed from tests/auto/qtquick2/qquickitem2/data/parentLoop.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/propertychanges.qml (renamed from tests/auto/qtquick2/qquickitem2/data/propertychanges.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/qtbug_16871.qml (renamed from tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/resourcesProperty.qml (renamed from tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/transformCrash.qml (renamed from tests/auto/qtquick2/qquickitem2/data/transformCrash.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/visiblechildren.qml (renamed from tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/qquickitem2.pro15
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp1380
-rw-r--r--tests/auto/quick/qquickitemlayer/data/DisableLayer.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Effect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Effect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Enabled.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/ItemEffect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Mipmap.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Smooth.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/SourceRect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/TextureProvider.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Visible.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Visible.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/ZOrder.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/qquickitemlayer.pro38
-rw-r--r--tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp436
-rw-r--r--tests/auto/quick/qquicklistview/data/ComponentView.qml (renamed from tests/auto/qtquick2/qquicklistview/data/ComponentView.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/Page.qml (renamed from tests/auto/qtquick2/qquicklistview/data/Page.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/addTransitions.qml134
-rw-r--r--tests/auto/quick/qquicklistview/data/asyncloader.qml (renamed from tests/auto/qtquick2/qquicklistview/data/asyncloader.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/attachedSignals.qml (renamed from tests/auto/qtquick2/qquicklistview/data/attachedSignals.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/creationContext.qml (renamed from tests/auto/qtquick2/qquicklistview/data/creationContext.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/displacedTransitions.qml (renamed from tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/displaylist.qml (renamed from tests/auto/qtquick2/qquicklistview/data/displaylist.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/fillModelOnComponentCompleted.qml (renamed from tests/auto/qtquick2/qquicklistview/data/fillModelOnComponentCompleted.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/footer.qml (renamed from tests/auto/qtquick2/qquicklistview/data/footer.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/header.qml (renamed from tests/auto/qtquick2/qquicklistview/data/header.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/headerfooter.qml (renamed from tests/auto/qtquick2/qquicklistview/data/headerfooter.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/itemlist.qml (renamed from tests/auto/qtquick2/qquicklistview/data/itemlist.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-enforcerange-nohighlight.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-enforcerange-nohighlight.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-enforcerange.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-enforcerange.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-initCurrent.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-initCurrent.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-noCurrent.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-noCurrent.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-sections-package.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-sections-package.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-sections.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-sections.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-sections_delegate.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listviewtest-package.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listviewtest-package.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listviewtest.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listviewtest.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/manual-highlight.qml (renamed from tests/auto/qtquick2/qquicklistview/data/manual-highlight.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/margins.qml (renamed from tests/auto/qtquick2/qquicklistview/data/margins.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/margins2.qml (renamed from tests/auto/qtquick2/qquicklistview/data/margins2.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/moveTransitions.qml141
-rw-r--r--tests/auto/quick/qquicklistview/data/multipleTransitions.qml (renamed from tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/populateTransitions.qml (renamed from tests/auto/qtquick2/qquicklistview/data/populateTransitions.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/propertychangestest.qml (renamed from tests/auto/qtquick2/qquicklistview/data/propertychangestest.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug-21742.qml (renamed from tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug14821.qml (renamed from tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug16037.qml (renamed from tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/removeTransitions.qml144
-rw-r--r--tests/auto/quick/qquicklistview/data/resizeview.qml (renamed from tests/auto/qtquick2/qquicklistview/data/resizeview.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/rightToLeft.qml (renamed from tests/auto/qtquick2/qquicklistview/data/rightToLeft.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/sectionpropertychange.qml (renamed from tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/sizelessthan1.qml (renamed from tests/auto/qtquick2/qquicklistview/data/sizelessthan1.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItem.qml (renamed from tests/auto/qtquick2/qquicklistview/data/snapOneItem.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/snapToItem.qml (renamed from tests/auto/qtquick2/qquicklistview/data/snapToItem.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/strictlyenforcerange.qml (renamed from tests/auto/qtquick2/qquicklistview/data/strictlyenforcerange.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/unrequestedItems.qml (renamed from tests/auto/qtquick2/qquicklistview/data/unrequestedItems.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/incrementalmodel.cpp (renamed from tests/auto/qtquick2/qquicklistview/incrementalmodel.cpp)0
-rw-r--r--tests/auto/quick/qquicklistview/incrementalmodel.h (renamed from tests/auto/qtquick2/qquicklistview/incrementalmodel.h)0
-rw-r--r--tests/auto/quick/qquicklistview/qquicklistview.pro16
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp5997
-rw-r--r--tests/auto/quick/qquickloader/data/ActiveComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/AnchoredLoader.qml (renamed from tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/BigComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/BigComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/BlueRect.qml (renamed from tests/auto/qtquick2/qquickloader/data/BlueRect.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/CreationContextLoader.qml (renamed from tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml (renamed from tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/GreenRect.qml (renamed from tests/auto/qtquick2/qquickloader/data/GreenRect.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/NoResize.qml (renamed from tests/auto/qtquick2/qquickloader/data/NoResize.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml (renamed from tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/QTBUG_16928.qml (renamed from tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/QTBUG_17114.qml (renamed from tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/Rect120x60.qml (renamed from tests/auto/qtquick2/qquickloader/data/Rect120x60.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SetSourceComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml (renamed from tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml (renamed from tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SizeToItem.qml (renamed from tests/auto/qtquick2/qquickloader/data/SizeToItem.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SizeToLoader.qml (renamed from tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/VmeError.qml (renamed from tests/auto/qtquick2/qquickloader/data/VmeError.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.1.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.1.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.2.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.2.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.3.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.3.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.4.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.4.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.5.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.5.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.6.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.6.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.7.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.7.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.8.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.8.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/asynchronous.qml (renamed from tests/auto/qtquick2/qquickloader/data/asynchronous.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/crash.qml (renamed from tests/auto/qtquick2/qquickloader/data/crash.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/creationContext.qml (renamed from tests/auto/qtquick2/qquickloader/data/creationContext.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/differentorigin.qml (renamed from tests/auto/qtquick2/qquickloader/data/differentorigin.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/implicitSize.qml (renamed from tests/auto/qtquick2/qquickloader/data/implicitSize.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/nonItem.qml (renamed from tests/auto/qtquick2/qquickloader/data/nonItem.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/parented.qml (renamed from tests/auto/qtquick2/qquickloader/data/parented.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/qmldir (renamed from tests/auto/qtquick2/qquickloader/data/qmldir)0
-rw-r--r--tests/auto/quick/qquickloader/data/sameorigin-load.qml (renamed from tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/sameorigin.qml (renamed from tests/auto/qtquick2/qquickloader/data/sameorigin.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/sizebound.qml (renamed from tests/auto/qtquick2/qquickloader/data/sizebound.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/vmeErrors.qml (renamed from tests/auto/qtquick2/qquickloader/data/vmeErrors.qml)0
-rw-r--r--tests/auto/quick/qquickloader/qquickloader.pro19
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp987
-rw-r--r--tests/auto/quick/qquickmousearea/data/clickThrough.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/clickThrough2.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/clickandhold.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/clicktwice.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/doubleclick.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/dragging.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/dragging.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/dragproperties.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/dragreset.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/dragreset.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/hoverPosition.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/hoverPropagation.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/hoverVisible.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/noclickandhold.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/pressedCanceled.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/pressedOrdering.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/preventstealing.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/rejectEvent.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/qquickmousearea.pro17
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp806
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/basic.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/nested.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/properties.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro11
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp727
-rw-r--r--tests/auto/quick/qquickpath/data/arc.qml (renamed from tests/auto/qtquick2/qdeclarativepath/data/arc.qml)0
-rw-r--r--tests/auto/quick/qquickpath/data/closedcurve.qml (renamed from tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml)0
-rw-r--r--tests/auto/quick/qquickpath/data/curve.qml (renamed from tests/auto/qtquick2/qdeclarativepath/data/curve.qml)0
-rw-r--r--tests/auto/quick/qquickpath/data/svg.qml (renamed from tests/auto/qtquick2/qdeclarativepath/data/svg.qml)0
-rw-r--r--tests/auto/quick/qquickpath/qquickpath.pro15
-rw-r--r--tests/auto/quick/qquickpath/tst_qquickpath.cpp199
-rw-r--r--tests/auto/quick/qquickpathview/data/ComponentView.qml (renamed from tests/auto/qtquick2/qquickpathview/data/ComponentView.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/asyncloader.qml (renamed from tests/auto/qtquick2/qquickpathview/data/asyncloader.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/closedPath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/closedPath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/creationContext.qml (renamed from tests/auto/qtquick2/qquickpathview/data/creationContext.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/datamodel.qml (renamed from tests/auto/qtquick2/qquickpathview/data/datamodel.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/displaypath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/displaypath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/dragpath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/dragpath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/emptymodel.qml (renamed from tests/auto/qtquick2/qquickpathview/data/emptymodel.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/missingPercent.qml (renamed from tests/auto/qtquick2/qquickpathview/data/missingPercent.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/openPath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/openPath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathUpdate.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathline.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathline.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathtest.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathtest.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview0.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview0.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview1.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview1.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview2.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview2.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview3.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview3.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview_package.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview_package.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/propertychanges.qml (renamed from tests/auto/qtquick2/qquickpathview/data/propertychanges.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/treemodel.qml (renamed from tests/auto/qtquick2/qquickpathview/data/treemodel.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/undefinedpath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/vdm.qml (renamed from tests/auto/qtquick2/qquickpathview/data/vdm.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/qquickpathview.pro15
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp1458
-rw-r--r--tests/auto/quick/qquickpincharea/data/pinchproperties.qml (renamed from tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml)0
-rw-r--r--tests/auto/quick/qquickpincharea/qquickpincharea.pro15
-rw-r--r--tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp404
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/exists.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/exists1.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/exists2.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists1.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists2.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists3.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists4.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists5.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists6.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists7.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists8.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/massive.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png)bin31834 -> 31834 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro21
-rw-r--r--tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp467
-rw-r--r--tests/auto/quick/qquickpositioners/data/allInvisible.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/flowtest.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/flowtest.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/grid-animated.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/grid-spacing.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/gridtest.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/gridtest.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal-animated.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/horizontal.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/propertychangestest.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/rectangleComponent.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/repeatertest.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/transitions.qml196
-rw-r--r--tests/auto/quick/qquickpositioners/data/vertical-animated.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/vertical-spacing.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/vertical.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/vertical.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/qquickpositioners.pro15
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp1927
-rw-r--r--tests/auto/quick/qquickrepeater/data/asyncloader.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/initparent.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/initparent.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/intmodel.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/intmodel.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/itemlist.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/itemlist.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/modelChanged.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/objlist.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/objlist.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/properties.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/properties.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/repeater1.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/repeater1.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/repeater2.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/repeater2.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/qquickrepeater.pro15
-rw-r--r--tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp644
-rw-r--r--tests/auto/quick/qquickscreen/data/screen.qml (renamed from tests/auto/qtquick2/qquickscreen/data/screen.qml)0
-rw-r--r--tests/auto/quick/qquickscreen/qquickscreen.pro10
-rw-r--r--tests/auto/quick/qquickscreen/tst_qquickscreen.cpp77
-rw-r--r--tests/auto/quick/qquickshadereffect/qquickshadereffect.pro8
-rw-r--r--tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp (renamed from tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro15
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp242
-rw-r--r--tests/auto/quick/qquickspringanimation/data/springanimation1.qml (renamed from tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml)0
-rw-r--r--tests/auto/quick/qquickspringanimation/data/springanimation2.qml (renamed from tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml)0
-rw-r--r--tests/auto/quick/qquickspringanimation/data/springanimation3.qml (renamed from tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml)0
-rw-r--r--tests/auto/quick/qquickspringanimation/qquickspringanimation.pro15
-rw-r--r--tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp133
-rw-r--r--tests/auto/quick/qquickspriteimage/data/advance.qml66
-rw-r--r--tests/auto/quick/qquickspriteimage/data/basic.qml60
-rw-r--r--tests/auto/quick/qquickspriteimage/data/squarefacesprite.png (renamed from tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquickspriteimage/qquickspriteimage.pro15
-rw-r--r--tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp98
-rw-r--r--tests/auto/quick/qquickspritesequence/data/advance.qml (renamed from tests/auto/qtquick2/qquickspritesequence/data/advance.qml)0
-rw-r--r--tests/auto/quick/qquickspritesequence/data/basic.qml (renamed from tests/auto/qtquick2/qquickspritesequence/data/basic.qml)0
-rw-r--r--tests/auto/quick/qquickspritesequence/data/squarefacesprite.pngbin0 -> 496 bytes
-rw-r--r--tests/auto/quick/qquickspritesequence/qquickspritesequence.pro15
-rw-r--r--tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp98
-rw-r--r--tests/auto/quick/qquickstates/data/ExtendedRectangle.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/Implementation/MyType.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--tests/auto/quick/qquickstates/data/QTBUG-14830.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges1.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges4.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges5.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChangesCrash.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorRewindBug.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorRewindBug2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/avoidFastForward.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicBinding.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicBinding2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicBinding3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicBinding4.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicChanges.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicChanges2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicChanges3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicChanges4.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicExtension.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/deleting.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/deleting.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/deletingState.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/editProperties.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/explicit.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/explicit.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/extendsBug.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/fakeExtension.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/illegalObj.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/illegalTempState.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/image.png (renamed from tests/auto/qtquick2/qdeclarativestates/data/image.png)bin173 -> 173 bytes
-rw-r--r--tests/auto/quick/qquickstates/data/legalTempState.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/nonExistantProp.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange1.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange4.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange5.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange6.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/propertyErrors.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/reset.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/reset.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/restoreEntryValues.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/returnToBase.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/revertListBug.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/script.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/script.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverride.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverride2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverrideCrash.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/unnamedWhen.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/urlResolution.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/whenOrdering.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml)0
-rw-r--r--tests/auto/quick/qquickstates/qquickstates.pro14
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp1608
-rw-r--r--tests/auto/quick/qquickstyledtext/qquickstyledtext.pro8
-rw-r--r--tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp189
-rw-r--r--tests/auto/quick/qquicksystempalette/qquicksystempalette.pro8
-rw-r--r--tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp185
-rw-r--r--tests/auto/quick/qquicktext/data/alignments.qml (renamed from tests/auto/qtquick2/qquicktext/data/alignments.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_cb.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_cb.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_cc.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_cc.png)bin556 -> 556 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_ct.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_ct.png)bin533 -> 533 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_lb.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_lb.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_lc.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_lc.png)bin535 -> 535 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_lt.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_lt.png)bin514 -> 514 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_rb.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_rb.png)bin505 -> 505 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_rc.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_rc.png)bin559 -> 559 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_rt.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_rt.png)bin539 -> 539 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/fontSizeMode.qml (renamed from tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml (renamed from tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/http/exists.png (renamed from tests/auto/qtquick2/qquicktext/data/http/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/images/face-sad.pngbin0 -> 6148 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/images/heart200.pngbin0 -> 8248 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/images/starfish_2.pngbin0 -> 18243 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/imgTagsElide.qml (renamed from tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/imgTagsUpdates.qml (renamed from tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/lineCount.qml (renamed from tests/auto/qtquick2/qquicktext/data/lineCount.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/lineHeight.qml (renamed from tests/auto/qtquick2/qquicktext/data/lineHeight.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/lineLayout.qml (renamed from tests/auto/qtquick2/qquicktext/data/lineLayout.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/multilengthStrings.qml (renamed from tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml (renamed from tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/multilineelide.qml (renamed from tests/auto/qtquick2/qquicktext/data/multilineelide.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/pixelFontSizes.qml (renamed from tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/pointFontSizes.qml (renamed from tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/qtbug_14734.qml (renamed from tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/rotated.qml (renamed from tests/auto/qtquick2/qquicktext/data/rotated.qml)0
-rw-r--r--tests/auto/quick/qquicktext/qquicktext.pro19
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp2484
-rw-r--r--tests/auto/quick/qquicktextedit/data/Cursor.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/Cursor.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/CursorRect.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_cb.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_cc.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png)bin556 -> 556 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_ct.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png)bin533 -> 533 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_lb.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_lc.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png)bin535 -> 535 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_lt.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png)bin514 -> 514 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_rb.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png)bin505 -> 505 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_rc.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png)bin559 -> 559 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_rt.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png)bin539 -> 539 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTest.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTestInline.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorVisible.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/geometrySignals.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/ErrItem.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/NormItem.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/exists.png (renamed from tests/auto/qtquick2/qquicktextedit/data/http/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/qmldir (renamed from tests/auto/qtquick2/qquicktextedit/data/http/qmldir)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/inputContext.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/inputContext.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/inputmethodhints.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/linkActivated.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_default.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_false.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_true.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/navigation.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/navigation.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/openInputPanel.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/persistentSelection.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/positionAt.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/positionAt.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/qtbug-22058.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/readOnly.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/readOnly.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/qquicktextedit.pro16
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp3881
-rw-r--r--tests/auto/quick/qquicktextinput/data/Cursor.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/Cursor.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorTest.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorTestInline.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorVisible.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/echoMode.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/echoMode.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/geometrySignals.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/halign_center.png (renamed from tests/auto/qtquick2/qquicktextinput/data/halign_center.png)bin293 -> 293 bytes
-rw-r--r--tests/auto/quick/qquicktextinput/data/halign_left.png (renamed from tests/auto/qtquick2/qquicktextinput/data/halign_left.png)bin291 -> 291 bytes
-rw-r--r--tests/auto/quick/qquicktextinput/data/halign_right.png (renamed from tests/auto/qtquick2/qquicktextinput/data/halign_right.png)bin292 -> 292 bytes
-rw-r--r--tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/inputContext.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/inputContext.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/inputmethods.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/masks.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/masks.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/maxLength.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/maxLength.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/mouseselection_true.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/navigation.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/navigation.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/negativeDimensions.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/openInputPanel.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/persistentSelection.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/positionAt.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/positionAt.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/readOnly.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/readOnly.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/validators.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/validators.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/qquicktextinput.pro13
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp4703
-rw-r--r--tests/auto/quick/qquicktimer/qquicktimer.pro8
-rw-r--r--tests/auto/quick/qquicktimer/tst_qquicktimer.cpp393
-rw-r--r--tests/auto/quick/qquickview/data/error1.qml (renamed from tests/auto/qtquick2/qquickview/data/error1.qml)0
-rw-r--r--tests/auto/quick/qquickview/data/resizemodeitem.qml (renamed from tests/auto/qtquick2/qquickview/data/resizemodeitem.qml)0
-rw-r--r--tests/auto/quick/qquickview/qquickview.pro13
-rw-r--r--tests/auto/quick/qquickview/tst_qquickview.cpp207
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/create.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/datalist.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/groups.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/packageView.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro16
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp3446
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/empty.xml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/get.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/model.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/model.xml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/model2.xml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/recipes.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/recipes.xml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/testtypes.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/unique.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro15
-rw-r--r--tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp962
-rw-r--r--tests/auto/quick/quick.pro75
-rw-r--r--tests/auto/quick/rendernode/data/MessUpState.qml (renamed from tests/auto/qtquick2/rendernode/data/MessUpState.qml)0
-rw-r--r--tests/auto/quick/rendernode/data/RenderOrder.qml (renamed from tests/auto/qtquick2/rendernode/data/RenderOrder.qml)0
-rw-r--r--tests/auto/quick/rendernode/rendernode.pro18
-rw-r--r--tests/auto/quick/rendernode/tst_rendernode.cpp242
-rw-r--r--tests/auto/quick/shared/util.pri7
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp493
-rw-r--r--tests/auto/quick/shared/viewtestutil.h182
-rw-r--r--tests/auto/quick/shared/visualtestutil.cpp (renamed from tests/auto/qtquick2/shared/visualtestutil.cpp)0
-rw-r--r--tests/auto/quick/shared/visualtestutil.h112
-rw-r--r--tests/auto/shared/util.cpp32
-rw-r--r--tests/auto/shared/util.h24
-rw-r--r--tests/auto/shared/util.pri2
-rw-r--r--tests/benchmarks/declarative/animation/animation.pro10
-rw-r--r--tests/benchmarks/declarative/animation/tst_animation.cpp204
-rw-r--r--tests/benchmarks/declarative/binding/binding.pro11
-rw-r--r--tests/benchmarks/declarative/binding/testtypes.h83
-rw-r--r--tests/benchmarks/declarative/binding/tst_binding.cpp188
-rw-r--r--tests/benchmarks/declarative/compilation/compilation.pro11
-rw-r--r--tests/benchmarks/declarative/compilation/data/BoomBlock.qml106
-rw-r--r--tests/benchmarks/declarative/compilation/tst_compilation.cpp160
-rw-r--r--tests/benchmarks/declarative/creation/creation.pro10
-rw-r--r--tests/benchmarks/declarative/creation/data/item.qml75
-rw-r--r--tests/benchmarks/declarative/creation/data/qobject.qml45
-rw-r--r--tests/benchmarks/declarative/creation/tst_creation.cpp361
-rw-r--r--tests/benchmarks/declarative/declarative.pro18
-rw-r--r--tests/benchmarks/declarative/holistic/holistic.pro13
-rw-r--r--tests/benchmarks/declarative/holistic/testtypes.cpp98
-rw-r--r--tests/benchmarks/declarative/holistic/testtypes.h355
-rw-r--r--tests/benchmarks/declarative/holistic/tst_holistic.cpp607
-rw-r--r--tests/benchmarks/declarative/javascript/javascript.pro11
-rw-r--r--tests/benchmarks/declarative/javascript/testtypes.cpp48
-rw-r--r--tests/benchmarks/declarative/javascript/tst_javascript.cpp123
-rw-r--r--tests/benchmarks/declarative/js/qjsengine/qjsengine.pro7
-rw-r--r--tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp600
-rw-r--r--tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro7
-rw-r--r--tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp979
-rw-r--r--tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro7
-rw-r--r--tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp309
-rw-r--r--tests/benchmarks/declarative/pointers/pointers.pro8
-rw-r--r--tests/benchmarks/declarative/pointers/tst_pointers.cpp77
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml44
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml47
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml44
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml47
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml112
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml56
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml46
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro11
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h83
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp116
-rw-r--r--tests/benchmarks/declarative/qdeclarativedebugtrace/qdeclarativedebugtrace.pro8
-rw-r--r--tests/benchmarks/declarative/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp100
-rw-r--r--tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro11
-rw-r--r--tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp108
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml44
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml47
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro10
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp110
-rw-r--r--tests/benchmarks/declarative/qmltime/example.qml55
-rw-r--r--tests/benchmarks/declarative/qmltime/qmltime.cpp283
-rw-r--r--tests/benchmarks/declarative/qmltime/qmltime.pro8
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml75
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml82
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/anchors/null.qml68
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/animation/large.qml82
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml82
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml75
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml75
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml53
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml75
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml48
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml57
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml56
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml55
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml57
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml78
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml75
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml78
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml54
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml59
-rw-r--r--tests/benchmarks/declarative/script/data/CustomObject.qml48
-rw-r--r--tests/benchmarks/declarative/script/data/block.qml75
-rw-r--r--tests/benchmarks/declarative/script/data/enums.qml51
-rw-r--r--tests/benchmarks/declarative/script/data/namespacedEnums.qml52
-rw-r--r--tests/benchmarks/declarative/script/data/scriptCall.qml54
-rw-r--r--tests/benchmarks/declarative/script/data/signal_args.qml47
-rw-r--r--tests/benchmarks/declarative/script/data/signal_heavyArgsAccess.qml51
-rw-r--r--tests/benchmarks/declarative/script/data/signal_heavyIdAccess.qml54
-rw-r--r--tests/benchmarks/declarative/script/data/signal_qml.qml47
-rw-r--r--tests/benchmarks/declarative/script/data/signal_unconnected.qml45
-rw-r--r--tests/benchmarks/declarative/script/data/signal_unusedArgs.qml47
-rw-r--r--tests/benchmarks/declarative/script/data/slot_complex.qml57
-rw-r--r--tests/benchmarks/declarative/script/data/slot_complex_js.qml49
-rw-r--r--tests/benchmarks/declarative/script/data/slot_simple.qml50
-rw-r--r--tests/benchmarks/declarative/script/data/slot_simple_js.qml48
-rw-r--r--tests/benchmarks/declarative/script/script.pro11
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp852
-rw-r--r--tests/benchmarks/declarative/typeimports/data/QmlTestType1.qml43
-rw-r--r--tests/benchmarks/declarative/typeimports/data/QmlTestType2.qml43
-rw-r--r--tests/benchmarks/declarative/typeimports/data/QmlTestType3.qml43
-rw-r--r--tests/benchmarks/declarative/typeimports/data/QmlTestType4.qml43
-rw-r--r--tests/benchmarks/declarative/typeimports/data/cpp.qml56
-rw-r--r--tests/benchmarks/declarative/typeimports/data/qml.qml54
-rw-r--r--tests/benchmarks/declarative/typeimports/tst_typeimports.cpp135
-rw-r--r--tests/benchmarks/declarative/typeimports/typeimports.pro9
-rw-r--r--tests/benchmarks/particles/affectors/affectors.pro2
-rw-r--r--tests/benchmarks/particles/emission/emission.pro2
-rw-r--r--tests/benchmarks/qml/animation/animation.pro10
-rw-r--r--tests/benchmarks/qml/animation/data/animation.qml (renamed from tests/benchmarks/declarative/animation/data/animation.qml)0
-rw-r--r--tests/benchmarks/qml/animation/tst_animation.cpp204
-rw-r--r--tests/benchmarks/qml/binding/binding.pro11
-rw-r--r--tests/benchmarks/qml/binding/data/creation.txt (renamed from tests/benchmarks/declarative/binding/data/creation.txt)0
-rw-r--r--tests/benchmarks/qml/binding/data/idproperty.txt (renamed from tests/benchmarks/declarative/binding/data/idproperty.txt)0
-rw-r--r--tests/benchmarks/qml/binding/data/localproperty.txt (renamed from tests/benchmarks/declarative/binding/data/localproperty.txt)0
-rw-r--r--tests/benchmarks/qml/binding/data/objectproperty.txt (renamed from tests/benchmarks/declarative/binding/data/objectproperty.txt)0
-rw-r--r--tests/benchmarks/qml/binding/testtypes.cpp (renamed from tests/benchmarks/declarative/binding/testtypes.cpp)0
-rw-r--r--tests/benchmarks/qml/binding/testtypes.h83
-rw-r--r--tests/benchmarks/qml/binding/tst_binding.cpp188
-rw-r--r--tests/benchmarks/qml/compilation/compilation.pro11
-rw-r--r--tests/benchmarks/qml/compilation/data/BoomBlock.qml106
-rw-r--r--tests/benchmarks/qml/compilation/tst_compilation.cpp160
-rw-r--r--tests/benchmarks/qml/creation/creation.pro10
-rw-r--r--tests/benchmarks/qml/creation/data/item.qml75
-rw-r--r--tests/benchmarks/qml/creation/data/qobject.qml45
-rw-r--r--tests/benchmarks/qml/creation/tst_creation.cpp361
-rw-r--r--tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicFour.qml (renamed from tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicOne.qml (renamed from tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicThree.qml (renamed from tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicTwo.qml (renamed from tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/Mlbsi.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/Mldsi.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/Mlsi.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/ModuleBm.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/Msbsi.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/Msdsi.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/Mssi.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/PragmaBm.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/PragmaModuleBm.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/Slsi.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/Sssi.qml (renamed from tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi1.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi1.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi10.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi10.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi11.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi11.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi12.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi12.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi13.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi13.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi14.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi14.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi15.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi15.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi2.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi2.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi3.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi3.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi4.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi4.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi5.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi5.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi6.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi6.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi7.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi7.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi8.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi8.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlbsi9.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlbsi9.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi1.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi1.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi10.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi10.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi11.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi11.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi12.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi12.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi13.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi13.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi14.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi14.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi15.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi15.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi2.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi2.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi3.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi3.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi4.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi4.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi5.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi5.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi6.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi6.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi7.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi7.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi8.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi8.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mldsi9.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mldsi9.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mlsi.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mlsi.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/moduleBm.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/moduleBm.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi1.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi1.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi10.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi10.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi11.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi11.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi12.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi12.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi13.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi13.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi14.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi14.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi15.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi15.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi2.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi2.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi3.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi3.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi4.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi4.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi5.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi5.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi6.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi6.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi7.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi7.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi8.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi8.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msbsi9.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msbsi9.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi1.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi1.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi10.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi10.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi11.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi11.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi12.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi12.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi13.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi13.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi14.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi14.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi15.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi15.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi2.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi2.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi3.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi3.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi4.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi4.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi5.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi5.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi6.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi6.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi7.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi7.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi8.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi8.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/msdsi9.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/msdsi9.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/mssi.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/mssi.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/pragmaBmOne.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmOne.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/pragmaBmTwo.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmTwo.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/pragmaLib.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/pragmaLib.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/pragmaModuleBm.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/pragmaModuleBm.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/slsi.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/slsi.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsImports/sssi.js (renamed from tests/benchmarks/declarative/holistic/data/jsImports/sssi.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsTargets/JsOne.qml (renamed from tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/jsTargets/JsTwo.qml (renamed from tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/largeTargets/gridview-example.qml (renamed from tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/largeTargets/layoutdirection.qml (renamed from tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/largeTargets/mousearea-example.qml (renamed from tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/resolutionTargets/ResolveOne.qml (renamed from tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/CppToJs.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/CppToQml.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEight.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEleven.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFive.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFour.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppNine.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppOne.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSeven.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSix.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTen.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppThree.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTwo.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceOne.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceTwo.qml (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/scopeSwitching/cppToJs.js (renamed from tests/benchmarks/declarative/holistic/data/scopeSwitching/cppToJs.js)0
-rw-r--r--tests/benchmarks/qml/holistic/data/smallTargets/SmallFour.qml (renamed from tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/smallTargets/SmallOne.qml (renamed from tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/smallTargets/SmallThree.qml (renamed from tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/data/smallTargets/SmallTwo.qml (renamed from tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml)0
-rw-r--r--tests/benchmarks/qml/holistic/holistic.pro13
-rw-r--r--tests/benchmarks/qml/holistic/testtypes.cpp98
-rw-r--r--tests/benchmarks/qml/holistic/testtypes.h355
-rw-r--r--tests/benchmarks/qml/holistic/tst_holistic.cpp607
-rw-r--r--tests/benchmarks/qml/javascript/data/NestedIdObject.qml (renamed from tests/benchmarks/declarative/javascript/data/NestedIdObject.qml)0
-rw-r--r--tests/benchmarks/qml/javascript/data/intQObjectProperty.qml (renamed from tests/benchmarks/declarative/javascript/data/intQObjectProperty.qml)0
-rw-r--r--tests/benchmarks/qml/javascript/data/localId.qml (renamed from tests/benchmarks/declarative/javascript/data/localId.qml)0
-rw-r--r--tests/benchmarks/qml/javascript/data/nestedId.qml (renamed from tests/benchmarks/declarative/javascript/data/nestedId.qml)0
-rw-r--r--tests/benchmarks/qml/javascript/data/stringQObjectProperty.qml (renamed from tests/benchmarks/declarative/javascript/data/stringQObjectProperty.qml)0
-rw-r--r--tests/benchmarks/qml/javascript/javascript.pro11
-rw-r--r--tests/benchmarks/qml/javascript/testtypes.cpp48
-rw-r--r--tests/benchmarks/qml/javascript/testtypes.h (renamed from tests/benchmarks/declarative/javascript/testtypes.h)0
-rw-r--r--tests/benchmarks/qml/javascript/tst_javascript.cpp123
-rw-r--r--tests/benchmarks/qml/js/js.pro (renamed from tests/benchmarks/declarative/js/js.pro)0
-rw-r--r--tests/benchmarks/qml/js/qjsengine/qjsengine.pro7
-rw-r--r--tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp600
-rw-r--r--tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro7
-rw-r--r--tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp979
-rw-r--r--tests/benchmarks/qml/js/qjsvalueiterator/qjsvalueiterator.pro7
-rw-r--r--tests/benchmarks/qml/js/qjsvalueiterator/tst_qjsvalueiterator.cpp309
-rw-r--r--tests/benchmarks/qml/painting/data/63x63.png (renamed from tests/benchmarks/declarative/painting/data/63x63.png)bin3077 -> 3077 bytes
-rw-r--r--tests/benchmarks/qml/painting/data/63x63_opaque.png (renamed from tests/benchmarks/declarative/painting/data/63x63_opaque.png)bin3440 -> 3440 bytes
-rw-r--r--tests/benchmarks/qml/painting/data/64x64.png (renamed from tests/benchmarks/declarative/painting/data/64x64.png)bin3101 -> 3101 bytes
-rw-r--r--tests/benchmarks/qml/painting/data/64x64_opaque.png (renamed from tests/benchmarks/declarative/painting/data/64x64_opaque.png)bin3588 -> 3588 bytes
-rw-r--r--tests/benchmarks/qml/painting/paintbenchmark.cpp (renamed from tests/benchmarks/declarative/painting/paintbenchmark.cpp)0
-rw-r--r--tests/benchmarks/qml/painting/painting.pro (renamed from tests/benchmarks/declarative/painting/painting.pro)0
-rw-r--r--tests/benchmarks/qml/pointers/pointers.pro8
-rw-r--r--tests/benchmarks/qml/pointers/tst_pointers.cpp77
-rw-r--r--tests/benchmarks/qml/qml.pro18
-rw-r--r--tests/benchmarks/qml/qmltime/example.qml55
-rw-r--r--tests/benchmarks/qml/qmltime/qmltime.cpp283
-rw-r--r--tests/benchmarks/qml/qmltime/qmltime.pro8
-rw-r--r--tests/benchmarks/qml/qmltime/tests/anchors/empty.qml75
-rw-r--r--tests/benchmarks/qml/qmltime/tests/anchors/fill.qml82
-rw-r--r--tests/benchmarks/qml/qmltime/tests/anchors/null.qml68
-rw-r--r--tests/benchmarks/qml/qmltime/tests/animation/large.qml82
-rw-r--r--tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml82
-rw-r--r--tests/benchmarks/qml/qmltime/tests/item_creation/children.qml75
-rw-r--r--tests/benchmarks/qml/qmltime/tests/item_creation/data.qml75
-rw-r--r--tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml53
-rw-r--r--tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml75
-rw-r--r--tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml48
-rw-r--r--tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml57
-rw-r--r--tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml56
-rw-r--r--tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml55
-rw-r--r--tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml57
-rw-r--r--tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml78
-rw-r--r--tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml75
-rw-r--r--tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml78
-rw-r--r--tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml54
-rw-r--r--tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml59
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/myqmlobject.qml44
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/myqmlobject_binding.qml47
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/object.qml44
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/object_id.qml47
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/samegame/BoomBlock.qml112
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/blueStone.pngbin0 -> 3054 bytes
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/greenStone.pngbin0 -> 2932 bytes
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/redStone.pngbin0 -> 2902 bytes
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/yellowStone.pngbin0 -> 3056 bytes
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.2.qml56
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.qml46
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/qqmlcomponent.pro11
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/testtypes.cpp (renamed from tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp)0
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/testtypes.h83
-rw-r--r--tests/benchmarks/qml/qqmlcomponent/tst_qqmlcomponent.cpp116
-rw-r--r--tests/benchmarks/qml/qqmldebugtrace/qqmldebugtrace.pro8
-rw-r--r--tests/benchmarks/qml/qqmldebugtrace/tst_qqmldebugtrace.cpp100
-rw-r--r--tests/benchmarks/qml/qqmlimage/image.png (renamed from tests/benchmarks/declarative/qdeclarativeimage/image.png)bin611 -> 611 bytes
-rw-r--r--tests/benchmarks/qml/qqmlimage/qqmlimage.pro11
-rw-r--r--tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp108
-rw-r--r--tests/benchmarks/qml/qqmlmetaproperty/data/object.qml44
-rw-r--r--tests/benchmarks/qml/qqmlmetaproperty/data/synthesized_object.qml47
-rw-r--r--tests/benchmarks/qml/qqmlmetaproperty/qqmlmetaproperty.pro10
-rw-r--r--tests/benchmarks/qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp110
-rw-r--r--tests/benchmarks/qml/script/data/CustomObject.qml48
-rw-r--r--tests/benchmarks/qml/script/data/block.qml75
-rw-r--r--tests/benchmarks/qml/script/data/enums.qml51
-rw-r--r--tests/benchmarks/qml/script/data/global.js (renamed from tests/benchmarks/declarative/script/data/global.js)0
-rw-r--r--tests/benchmarks/qml/script/data/global_prop.qml (renamed from tests/benchmarks/declarative/script/data/global_prop.qml)0
-rw-r--r--tests/benchmarks/qml/script/data/namespacedEnums.qml52
-rw-r--r--tests/benchmarks/qml/script/data/script.js (renamed from tests/benchmarks/declarative/script/data/script.js)0
-rw-r--r--tests/benchmarks/qml/script/data/script2.js (renamed from tests/benchmarks/declarative/script/data/script2.js)0
-rw-r--r--tests/benchmarks/qml/script/data/scriptCall.qml54
-rw-r--r--tests/benchmarks/qml/script/data/signal_args.qml47
-rw-r--r--tests/benchmarks/qml/script/data/signal_heavyArgsAccess.qml51
-rw-r--r--tests/benchmarks/qml/script/data/signal_heavyIdAccess.qml54
-rw-r--r--tests/benchmarks/qml/script/data/signal_qml.qml47
-rw-r--r--tests/benchmarks/qml/script/data/signal_unconnected.qml45
-rw-r--r--tests/benchmarks/qml/script/data/signal_unusedArgs.qml47
-rw-r--r--tests/benchmarks/qml/script/data/slot_complex.qml57
-rw-r--r--tests/benchmarks/qml/script/data/slot_complex_js.js (renamed from tests/benchmarks/declarative/script/data/slot_complex_js.js)0
-rw-r--r--tests/benchmarks/qml/script/data/slot_complex_js.qml49
-rw-r--r--tests/benchmarks/qml/script/data/slot_simple.qml50
-rw-r--r--tests/benchmarks/qml/script/data/slot_simple_js.js (renamed from tests/benchmarks/declarative/script/data/slot_simple_js.js)0
-rw-r--r--tests/benchmarks/qml/script/data/slot_simple_js.qml48
-rw-r--r--tests/benchmarks/qml/script/script.pro11
-rw-r--r--tests/benchmarks/qml/script/tst_script.cpp852
-rw-r--r--tests/benchmarks/qml/typeimports/data/QmlTestType1.qml43
-rw-r--r--tests/benchmarks/qml/typeimports/data/QmlTestType2.qml43
-rw-r--r--tests/benchmarks/qml/typeimports/data/QmlTestType3.qml43
-rw-r--r--tests/benchmarks/qml/typeimports/data/QmlTestType4.qml43
-rw-r--r--tests/benchmarks/qml/typeimports/data/cpp.qml56
-rw-r--r--tests/benchmarks/qml/typeimports/data/qml.qml54
-rw-r--r--tests/benchmarks/qml/typeimports/tst_typeimports.cpp135
-rw-r--r--tests/benchmarks/qml/typeimports/typeimports.pro9
-rw-r--r--tests/global/global.cfg2
-rw-r--r--tests/manual/accessibility/animation.qml2
-rw-r--r--tests/manual/accessibility/behavior.qml2
-rw-r--r--tests/manual/accessibility/flickable.qml2
-rw-r--r--tests/manual/accessibility/hittest.qml2
-rw-r--r--tests/manual/accessibility/numberanimation.qml2
-rw-r--r--tests/manual/accessibility/textandbuttons.qml2
-rw-r--r--tests/manual/accessibility/transition.qml2
-rw-r--r--tests/testapplications/qsgimage/ImageNG.qml2
-rw-r--r--tests/testapplications/qsgimage/img-align.qml2
-rw-r--r--tools/qmleasing/TextField.qml2
-rw-r--r--tools/qmleasing/easing.qml2
-rw-r--r--tools/qmleasing/qmleasing.pro2
-rw-r--r--tools/qmlmin/main.cpp20
-rw-r--r--tools/qmlmin/qmlmin.pro2
-rw-r--r--tools/qmlplugindump/main.cpp68
-rw-r--r--tools/qmlplugindump/qmlplugindump.pro4
-rw-r--r--tools/qmlprofiler/commandlistener.cpp2
-rw-r--r--tools/qmlprofiler/commandlistener.h2
-rw-r--r--tools/qmlprofiler/constants.h2
-rw-r--r--tools/qmlprofiler/profileclient.cpp62
-rw-r--r--tools/qmlprofiler/profileclient.h22
-rw-r--r--tools/qmlprofiler/profiledata.cpp244
-rw-r--r--tools/qmlprofiler/profiledata.h42
-rw-r--r--tools/qmlprofiler/qmlprofiler.pro4
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp58
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.h10
-rw-r--r--tools/qmlscene/main.cpp18
-rw-r--r--tools/qmlscene/qmlscene.pro4
-rw-r--r--tools/qmltestrunner/qmltestrunner.pro4
6502 files changed, 276790 insertions, 232061 deletions
diff --git a/bin/rename-qtdeclarative-symbols.sh b/bin/rename-qtdeclarative-symbols.sh
new file mode 100755
index 0000000000..0d521dd5a8
--- /dev/null
+++ b/bin/rename-qtdeclarative-symbols.sh
@@ -0,0 +1,642 @@
+#!/bin/sh
+#############################################################################
+##
+## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: http://www.qt-project.org/
+##
+## This file is part of the QtQml module of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## GNU Lesser General Public License Usage
+## 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.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU General
+## Public License version 3.0 as published by the Free Software Foundation
+## and appearing in the file LICENSE.GPL included in the packaging of this
+## file. Please review the following information to ensure the GNU General
+## Public License version 3.0 requirements will be met:
+## http://www.gnu.org/copyleft/gpl.html.
+##
+## Other Usage
+## Alternatively, this file may be used in accordance with the terms and
+## conditions contained in a signed written agreement between you and Nokia.
+##
+##
+##
+##
+##
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# Replaces deprecated QDeclarative symbol names with their replacements
+#
+# Changes instances in all regular files under the specified directory;
+# use on a clean source tree!
+
+if [ "$#" -lt "1" ]
+then
+ echo " Usage: $0 <directory>"
+ exit 1;
+fi
+
+MODIFY_DIR="$1"
+
+QML_SYMBOLS="\
+ QDeclarativeAbstractBinding
+ QDeclarativeAbstractBoundSignal
+ QDeclarativeAbstractExpression
+ QDeclarativeAccessible
+ QDeclarativeAccessors
+ QDeclarativeAccessorProperties
+ QDeclarativeAnimationTimer
+ QDeclarativeAssociationList
+ QDeclarativeAttachedPropertiesFunc
+ QDeclarativeBinding
+ QDeclarativeBindingPrivate
+ QDeclarativeBindingProfiler
+ QDeclarativeBoundSignal
+ QDeclarativeBoundSignalParameters
+ QDeclarativeBoundSignalProxy
+ QDeclarativeBuiltinFunctions
+ QDeclarativeCleanup
+ QDeclarativeColorValueType
+ QDeclarativeCompiledData
+ QDeclarativeCompiler
+ QDeclarativeCompilerTypes
+ QDeclarativeCompilingProfiler
+ QDeclarativeComponent
+ QDeclarativeComponentAttached
+ QDeclarativeComponentExtension
+ QDeclarativeComponentPrivate
+ QDeclarativeComponent_setQmlParent
+ QDeclarativeCompositeTypeData
+ QDeclarativeConnectionsParser
+ QDeclarativeContext
+ QDeclarativeContextData
+ QDeclarativeContextPrivate
+ QDeclarativeCustomParser
+ QDeclarativeCustomParserNode
+ QDeclarativeCustomParserNodePrivate
+ QDeclarativeCustomParserProperty
+ QDeclarativeCustomParserPropertyPrivate
+ QDeclarativeData
+ QDeclarativeDataBlob
+ QDeclarativeDataExtended
+ QDeclarativeDataLoader
+ QDeclarativeDataLoaderNetworkReplyProxy
+ QDeclarativeDataLoaderThread
+ QDeclarativeDateExtension
+ QDeclarativeDataTest
+ QDeclarativeDebug
+ QDeclarativeDebugClient
+ QDeclarativeDebugClientPrivate
+ QDeclarativeDebugConnection
+ QDeclarativeDebugConnectionPrivate
+ QDeclarativeDebugContextReference
+ QDeclarativeDebugData
+ QDeclarativeDebugEngineReference
+ QDeclarativeDebugEnginesQuery
+ QDeclarativeDebugExpressionQuery
+ QDeclarativeDebugFileReference
+ QDeclarativeDebugger
+ QDeclarativeDebuggingEnabler
+ QDeclarativeDebugHelper
+ QDeclarativeDebugObjectExpressionWatch
+ QDeclarativeDebugObjectQuery
+ QDeclarativeDebugObjectReference
+ QDeclarativeDebugPropertyReference
+ QDeclarativeDebugPropertyWatch
+ QDeclarativeDebugQuery
+ QDeclarativeDebugRootContextQuery
+ QDeclarativeDebugServer
+ QDeclarativeDebugServerConnection
+ QDeclarativeDebugServerPrivate
+ QDeclarativeDebugServerThread
+ QDeclarativeDebugService
+ QDeclarativeDebugServicePrivate
+ QDeclarativeDebugStatesDelegate
+ QDeclarativeDebugTrace
+ QDeclarativeDebugWatch
+ QDeclarativeDelayedError
+ QDeclarativeDirComponents
+ QDeclarativeDirParser
+ QDeclarativeDirScripts
+ QDeclarativeDOMNodeResource
+ QDeclarativeEasingValueType
+ QDeclarativeElement
+ QDeclarativeEngine
+ QDeclarativeEngineDebug
+ QDeclarativeEngineDebugClient
+ QDeclarativeEngineDebugService
+ QDeclarativeEngineDebugPrivate
+ QDeclarativeEnginePrivate
+ QDeclarativeError
+ QDeclarativeErrorPrivate
+ QDeclarativeExpression
+ QDeclarativeExpressionPrivate
+ QDeclarativeExtensionInterface
+ QDeclarativeExtensionPlugin
+ QDeclarativeFontValueType
+ QDeclarativeGraphics_DerivedObject
+ QDeclarativeGuard
+ QDeclarativeGuardedContextData
+ QDeclarativeGuardImpl
+ QDeclarativeHandlingSignalProfiler
+ QDeclarativeImageProvider
+ QDeclarativeImageProviderPrivate
+ QDeclarativeImportDatabase
+ QDeclarativeImportedNamespace
+ QDeclarativeImports
+ QDeclarativeImportsPrivate
+ QDeclarativeIncubationController
+ QDeclarativeIncubator
+ QDeclarativeIncubatorController
+ QDeclarativeIncubatorPrivate
+ QDeclarativeIncubators
+ QDeclarativeInfo
+ QDeclarativeInfoPrivate
+ QDeclarativeInspector
+ QDeclarativeInspectorInterface
+ QDeclarativeInspectorService
+ QDeclarativeInstruction
+ QDeclarativeInstructionData
+ QDeclarativeInstructionMeta
+ QDeclarativeIntegerCache
+ QDeclarativeJavaScriptExpression
+ QDeclarativeJavaScriptExpressionGuard
+ QDeclarativeJS
+ QDeclarativeJSGrammar
+ QDeclarativeListProperty
+ QDeclarativeListReference
+ QDeclarativeListReferencePrivate
+ QDeclarativeLocale
+ QDeclarativeLocalStoragePlugin
+ QDeclarativeMatrix4x4ValueType
+ QDeclarativeMetaType
+ QDeclarativeMetaTypeData
+ QDeclarativeNetworkAccessManagerFactory
+ QDeclarativeNotifier
+ QDeclarativeNotifierEndpoint
+ QDeclarativeNullableValue
+ QDeclarativeNumberExtension
+ QDeclarativeObjectCreatingProfiler
+ QDeclarativeObjectData
+ QDeclarativeObjectProperty
+ QDeclarativeObserverMode
+ QDeclarativeOpenMetaObject
+ QDeclarativeOpenMetaObjectPrivate
+ QDeclarativeOpenMetaObjectType
+ QDeclarativeOpenMetaObjectTypePrivate
+ QDeclarativeParser
+ QDeclarativeParserStatus
+ QDeclarativePointFValueType
+ QDeclarativePointValueType
+ QDeclarativePool
+ QDeclarativePrivate
+ QDeclarativeProfilerData
+ QDeclarativeProfilerService
+ QDeclarativeProperties
+ QDeclarativeProperty
+ QDeclarativePropertyCache
+ QDeclarativePropertyCacheMethodArguments
+ QDeclarativePropertyData
+ QDeclarativePropertyMap
+ QDeclarativePropertyMapMetaObject
+ QDeclarativePropertyMapPrivate
+ QDeclarativePropertyPrivate
+ QDeclarativePropertyRawData
+ QDeclarativePropertyValueInterceptor
+ QDeclarativePropertyValueSource
+ QDeclarativeProxyMetaObject
+ QDeclarativeQmldirData
+ QDeclarativeQtQuick1Module
+ QDeclarativeQtQuick2Module
+ QDeclarativeQtQuick2DebugStatesDelegate
+ QDeclarativeQuaternionValueType
+ QDeclarativeRectFValueType
+ QDeclarativeRectValueType
+ QDeclarativeRefCount
+ QDeclarativeRefPointer
+ QDeclarativeRegisterType
+ QDeclarativeRewrite
+ QDeclarativeScript
+ QDeclarativeScriptBlob
+ QDeclarativeScriptData
+ QDeclarativeScriptPrivate
+ QDeclarativeScriptString
+ QDeclarativeScriptStringPrivate
+ QDeclarativeSizeFValueType
+ QDeclarativeSizeValueType
+ QDeclarativeSqlDatabaseData
+ QDeclarativeStringConverters
+ QDeclarativeThread
+ QDeclarativeThreadPrivate
+ QDeclarativeTrace
+ QDeclarativeType
+ QDeclarativeTypeData
+ QDeclarativeTypeInfo
+ QDeclarativeTypeLoader
+ QDeclarativeTypeModule
+ QDeclarativeTypeModulePrivate
+ QDeclarativeTypeModuleVersion
+ QDeclarativeTypeNameCache
+ QDeclarativeTypeNotAvailable
+ QDeclarativeTypePrivate
+ QDeclarativeTypesExtensionInterface
+ QDeclarativeV8Function
+ QDeclarativeV8Handle
+ QDeclarativeValueType
+ QDeclarativeValueTypeProxyBinding
+ QDeclarativeValueTypeFactory
+ QDeclarativeVector2DValueType
+ QDeclarativeVector3DValueType
+ QDeclarativeVector4DValueType
+ QDeclarativeVME
+ QDeclarativeVMEGuard
+ QDeclarativeVMEMetaData
+ QDeclarativeVMEMetaObject
+ QDeclarativeVMEMetaObjectEndpoint
+ QDeclarativeVMEVariant
+ QDeclarativeVMETypes
+ QDeclarativeWatcher
+ QDeclarativeWatchProxy
+ QDeclarativeXMLHttpRequest
+ QDeclarativeXMLHttpRequestData
+ QDeclarative_isFileCaseCorrect
+ QDeclarative_setParent_noEvent
+ QQuickProperties
+ QQuickPropertyCacheMethodArguments
+ QQuickPropertyData
+"
+
+QUICK_SYMBOLS="\
+ QDeclarativeAbstractAnimation
+ QDeclarativeAbstractAnimationAction
+ QDeclarativeAbstractAnimationPrivate
+ QDeclarativeAction
+ QDeclarativeActionEvent
+ QDeclarativeAnchors
+ QDeclarativeAnimationController
+ QDeclarativeAnimationControllerPrivate
+ QDeclarativeAnimationGroup
+ QDeclarativeAnimationGroupPrivate
+ QDeclarativeAnimationPropertyUpdater
+ QDeclarativeApplication
+ QDeclarativeApplicationPrivate
+ QDeclarativeBehavior
+ QDeclarativeBehaviorPrivate
+ QDeclarativeBind
+ QDeclarativeBindPrivate
+ QDeclarativeBulkValueAnimator
+ QDeclarativeBulkValueUpdater
+ QDeclarativeCachedBezier
+ QDeclarativeChangeSet
+ QDeclarativeColorAnimation
+ QDeclarativeConnections
+ QDeclarativeConnectionsPrivate
+ QDeclarativeCurve
+ QDeclarativeDefaultTextureFactory
+ QDeclarativeFlick
+ QDeclarativeFocusPanel
+ QDeclarativeFolderListModel
+ QDeclarativeFolderListModelPrivate
+ QDeclarativeFontLoader
+ QDeclarativeFontLoaderPrivate
+ QDeclarativeFontObject
+ QDeclarativeGestureArea
+ QDeclarativeGestureAreaParser
+ QDeclarativeGestureAreaPrivate
+ QDeclarativeGraphics
+ QDeclarativeItem
+ QDeclarativeItemAccessor
+ QDeclarativeItemChangeListener
+ QDeclarativeItemKeyFilter
+ QDeclarativeItemPrivate
+ QDeclarativeListAccessor
+ QDeclarativeListCompositor
+ QDeclarativeListElement
+ QDeclarativeListModel
+ QDeclarativeListModelParser
+ QDeclarativeListModelWorkerAgent
+ QDeclarativeListView
+ QDeclarativeNumberAnimation
+ QDeclarativePackage
+ QDeclarativePackageAttached
+ QDeclarativePackagePrivate
+ QDeclarativeParallelAnimation
+ QDeclarativeParticle
+ QDeclarativeParticleMotion
+ QDeclarativeParticleMotionGravity
+ QDeclarativeParticleMotionLinear
+ QDeclarativeParticleMotionWander
+ QDeclarativeParticles
+ QDeclarativeParticlesPainter
+ QDeclarativeParticlesPrivate
+ QDeclarativePath
+ QDeclarativePathArc
+ QDeclarativePathAttribute
+ QDeclarativePathCatmullRomCurve
+ QDeclarativePathCubic
+ QDeclarativePathCurve
+ QDeclarativePathData
+ QDeclarativePathElement
+ QDeclarativePathInterpolator
+ QDeclarativePathLine
+ QDeclarativePathPercent
+ QDeclarativePathPrivate
+ QDeclarativePathQuad
+ QDeclarativePathSvg
+ QDeclarativePauseAnimation
+ QDeclarativePauseAnimationPrivate
+ QDeclarativePixmap
+ QDeclarativePixmapData
+ QDeclarativePixmapKey
+ QDeclarativePixmapNull
+ QDeclarativePixmapReader
+ QDeclarativePixmapReaderThreadObject
+ QDeclarativePixmapReply
+ QDeclarativePixmapStore
+ QDeclarativePropertyAction
+ QDeclarativePropertyActionPrivate
+ QDeclarativePropertyAnimation
+ QDeclarativePropertyAnimationPrivate
+ QDeclarativePropertyChanges
+ QDeclarativePropertyChangesParser
+ QDeclarativePropertyChangesPrivate
+ QDeclarativeReplaceSignalHandler
+ QDeclarativeRevertAction
+ QDeclarativeRotationAnimation
+ QDeclarativeRotationAnimationPrivate
+ QDeclarativeSequentialAnimation
+ QDeclarativeScriptAction
+ QDeclarativeScriptActionPrivate
+ QDeclarativeSetPropertyAnimationAction
+ QDeclarativeSimpleAction
+ QDeclarativeSmoothedAnimation
+ QDeclarativeSmoothedAnimationPrivate
+ QDeclarativeSpringAnimation
+ QDeclarativeSpringAnimationPrivate
+ QDeclarativeState
+ QDeclarativeStateActions
+ QDeclarativeStateChange
+ QDeclarativeStateChangeScript
+ QDeclarativeStateChangeScriptPrivate
+ QDeclarativeStateGroup
+ QDeclarativeStateGroupPrivate
+ QDeclarativeStateOperation
+ QDeclarativeStateOperationPrivate
+ QDeclarativeStatePrivate
+ QDeclarativeStyledText
+ QDeclarativeStyledTextImgTag
+ QDeclarativeStyledTextPrivate
+ QDeclarativeSystemPalette
+ QDeclarativeSystemPalettePrivate
+ QDeclarativeTextureFactory
+ QDeclarativeTimeLine
+ QDeclarativeTimeLineCallback
+ QDeclarativeTimeLineObject
+ QDeclarativeTimeLinePrivate
+ QDeclarativeTimeLineValue
+ QDeclarativeTimeLineValueProxy
+ QDeclarativeTimeLineValues
+ QDeclarativeTimer
+ QDeclarativeTimerPrivate
+ QDeclarativeTransition
+ QDeclarativeTransitionInstance
+ QDeclarativeTransitionManager
+ QDeclarativeTransitionManagerPrivate
+ QDeclarativeTransitionPrivate
+ QDeclarativeUtilModule
+ QDeclarativeVector3dAnimation
+ QDeclarativeView
+ QDeclarativeViewInspector
+ QDeclarativeViewInspectorPrivate
+ QDeclarativeViewPrivate
+ QDeclarativeWebView
+ QDeclarativeXmlListModel
+ QDeclarativeXmlListModelPrivate
+ QDeclarativeXmlListModelRole
+ QDeclarativeXmlListRange
+ QDeclarativeXmlQueryEngine
+ QDeclarativeXmlQueryResult
+ QDeclarativeXmlQueryThreadObject
+ QDeclarativeXmlRoleList
+ QDeclarativeSvgParser
+ QDeclarativeWorkerScript
+ QDeclarativeWorkerScriptEngine
+ QDeclarativeWorkerScriptEnginePrivate
+"
+
+QML_INCLUDE_FILES="\
+ qdeclarativeaccessible.h
+ qdeclarativeaccessors_p.h
+ qdeclarativebinding_p.h
+ qdeclarativebinding_p_p.h
+ qdeclarativeboundsignal_p.h
+ qdeclarativebuiltinfunctions_p.h
+ qdeclarativecleanup_p.h
+ qdeclarativecompiler_p.h
+ qdeclarativecomponentattached_p.h
+ qdeclarativecomponent.h
+ qdeclarativecomponent_p.h
+ qdeclarativecontext.h
+ qdeclarativecontext_p.h
+ qdeclarativecustomparser_p.h
+ qdeclarativecustomparser_p_p.h
+ qdeclarativedata_p.h
+ qdeclarativedebugclient_p.h
+ qdeclarativedebug.h
+ qdeclarativedebughelper_p.h
+ qdeclarativedebugserverconnection_p.h
+ qdeclarativedebugserver_p.h
+ qdeclarativedebugservice_p.h
+ qdeclarativedebugservice_p_p.h
+ qdeclarativedebugstatesdelegate_p.h
+ qdeclarativedebugtrace_p.h
+ qdeclarativedirparser_p.h
+ qdeclarativeenginedebug_p.h
+ qdeclarativeenginedebugservice_p.h
+ qdeclarativeengine.h
+ qdeclarativeengine_p.h
+ qdeclarativeerror.h
+ qdeclarativeexpression.h
+ qdeclarativeexpression_p.h
+ qdeclarativeextensioninterface.h
+ qdeclarativeextensionplugin.h
+ qdeclarativeglobal_p.h
+ qdeclarativeguard_p.h
+ qdeclarative.h
+ qdeclarativeimageprovider.h
+ qdeclarativeimport_p.h
+ qdeclarativeincubator.h
+ qdeclarativeincubator_p.h
+ qdeclarativeinfo.h
+ qdeclarativeinspectorinterface_p.h
+ qdeclarativeinspectorprotocol.h
+ qdeclarativeinspectorservice_p.h
+ qdeclarativeinstruction_p.h
+ qdeclarativeintegercache_p.h
+ qdeclarativejsastfwd_p.h
+ qdeclarativejsast_p.h
+ qdeclarativejsastvisitor_p.h
+ qdeclarativejsengine_p.h
+ qdeclarativejsglobal_p.h
+ qdeclarativejsgrammar_p.h
+ qdeclarativejskeywords_p.h
+ qdeclarativejslexer_p.h
+ qdeclarativejsmemorypool_p.h
+ qdeclarativejsparser_p.h
+ qdeclarativelist.h
+ qdeclarativelist_p.h
+ qdeclarativelocale_p.h
+ qdeclarativemetatype_p.h
+ qdeclarativenetworkaccessmanagerfactory.h
+ qdeclarativenotifier_p.h
+ qdeclarativenullablevalue_p_p.h
+ qdeclarativeopenmetaobject_p.h
+ qdeclarativeparserstatus.h
+ qdeclarativepool_p.h
+ qdeclarativeprivate.h
+ qdeclarativeprofilerservice_p.h
+ qdeclarativepropertycache_p.h
+ qdeclarativeproperty.h
+ qdeclarativepropertymap.h
+ qdeclarativeproperty_p.h
+ qdeclarativepropertyvalueinterceptor_p.h
+ qdeclarativepropertyvaluesource.h
+ qdeclarativeproxymetaobject_p.h
+ qdeclarativerefcount_p.h
+ qdeclarativerewrite_p.h
+ qdeclarativescript_p.h
+ qdeclarativescriptstring.h
+ qdeclarativescriptstring_p.h
+ qdeclarativesqldatabase_p.h
+ qdeclarativestringconverters_p.h
+ qdeclarativethread_p.h
+ qdeclarativetrace_p.h
+ qdeclarativetypeloader_p.h
+ qdeclarativetypenamecache_p.h
+ qdeclarativetypenotavailable_p.h
+ qdeclarativevaluetype_p.h
+ qdeclarativevmemetaobject_p.h
+ qdeclarativevme_p.h
+ qdeclarativewatcher_p.h
+ qdeclarativexmlhttprequest_p.h
+ qdeclarativexmllistmodel_p.h
+"
+
+QUICK_INCLUDE_FILES="\
+ qdeclarativeanimation_p.h
+ qdeclarativeanimation_p_p.h
+ qdeclarativeanimationcontroller_p.h
+ qdeclarativeapplication_p.h
+ qdeclarativebehavior_p.h
+ qdeclarativebind_p.h
+ qdeclarativechangeset_p.h
+ qdeclarativeconnections_p.h
+ qdeclarativefolderlistmodel.h
+ qdeclarativefontloader_p.h
+ qdeclarativelistaccessor_p.h
+ qdeclarativelistcompositor_p.h
+ qdeclarativelistmodel_p.h
+ qdeclarativelistmodel_p_p.h
+ qdeclarativelistmodelworkeragent_p.h
+ qdeclarativepackage_p.h
+ qdeclarativepathinterpolator_p.h
+ qdeclarativepath_p.h
+ qdeclarativepath_p_p.h
+ qdeclarativepixmapcache_p.h
+ qdeclarativepropertychanges_p.h
+ qdeclarativesmoothedanimation_p.h
+ qdeclarativesmoothedanimation_p_p.h
+ qdeclarativespringanimation_p.h
+ qdeclarativestategroup_p.h
+ qdeclarativestateoperations_p.h
+ qdeclarativestate_p.h
+ qdeclarativestate_p_p.h
+ qdeclarativestyledtext_p.h
+ qdeclarativesvgparser_p.h
+ qdeclarativesystempalette_p.h
+ qdeclarativetimeline_p_p.h
+ qdeclarativetimer_p.h
+ qdeclarativetransitionmanager_p_p.h
+ qdeclarativetransition_p.h
+ qdeclarativeutilmodule_p.h
+ qdeclarativeworkerscript_p.h
+"
+
+replaceMatch()
+{
+ SYMBOL="$1"
+ REPLACEMENT="$2"
+ echo "Replacing $SYMBOL with $REPLACEMENT:"
+
+ CONTAINERS=$(find "$MODIFY_DIR" ! -path ".git" -type f | xargs grep -l -I "$SYMBOL")
+ for CONTAINER in $CONTAINERS
+ do
+ echo " $CONTAINER"
+ TMP_FILE="$CONTAINER.tmp"
+
+ sed 's|'"$SYMBOL"'|'"$REPLACEMENT"'|g' <"$CONTAINER" >"$TMP_FILE"
+ mv "$TMP_FILE" "$CONTAINER"
+ done
+ echo
+}
+
+for QML_SYMBOL in $QML_SYMBOLS
+do
+ QML_REPLACEMENT="QQml${QML_SYMBOL#QDeclarative}"
+ replaceMatch "\<QtDeclarative/$QML_SYMBOL\>" "QtQml/$QML_REPLACEMENT"
+ replaceMatch "\<$QML_SYMBOL\>" "$QML_REPLACEMENT"
+done
+
+for QUICK_SYMBOL in $QUICK_SYMBOLS
+do
+ QUICK_REPLACEMENT="QQuick${QUICK_SYMBOL#QDeclarative}"
+ replaceMatch "\<QtDeclarative/$QUICK_SYMBOL\>" "QtQuick/$QUICK_REPLACEMENT"
+ replaceMatch "\<$QUICK_SYMBOL\>" "$QUICK_REPLACEMENT"
+done
+
+for QML_INCLUDE_FILE in $QML_INCLUDE_FILES
+do
+ QML_INCLUDE_REPLACEMENT="qqml${QML_INCLUDE_FILE#qdeclarative}"
+ replaceMatch "\<$QML_INCLUDE_FILE\>" "$QML_INCLUDE_REPLACEMENT"
+done
+
+for QUICK_INCLUDE_FILE in $QUICK_INCLUDE_FILES
+do
+ QUICK_INCLUDE_REPLACEMENT="qquick${QUICK_INCLUDE_FILE#qdeclarative}"
+ replaceMatch "\<$QUICK_INCLUDE_FILE\>" "$QUICK_INCLUDE_REPLACEMENT"
+done
+
+# Various one-off replacements
+replaceMatch "\<QtDeclarative\>" "QtQml"
+replaceMatch "\<asQDeclarativeContext" "asQQmlContext"
+
+# Replace any references to the 'declarative' module with 'qml'
+echo "Replacing module declarative with qml:"
+CONTAINERS=$(find "$MODIFY_DIR" \( -name \*\.pro -o -name \*\.pri \) | xargs grep -l -I "\<declarative\>")
+for CONTAINER in $CONTAINERS
+do
+ echo " $CONTAINER"
+ TMP_FILE="$CONTAINER.tmp"
+
+ sed 's|\<declarative\>|qml|g' <"$CONTAINER" >"$TMP_FILE"
+ mv "$TMP_FILE" "$CONTAINER"
+done
+echo
+
+echo "Replacements complete"
+exit 0
diff --git a/doc/src/localstorage/localstorage.qdoc b/doc/src/localstorage/localstorage.qdoc
index 7f4c2b021e..5287120e86 100644
--- a/doc/src/localstorage/localstorage.qdoc
+++ b/doc/src/localstorage/localstorage.qdoc
@@ -58,7 +58,7 @@ provide the ability to access local storage in an SQL database.
These databases are user-specific and QML-specific, but accessible to all QML applications.
They are stored in the \c Databases subdirectory
-of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases.
+of QQmlEngine::offlineStoragePath(), currently as SQLite databases.
Database connections are automatically closed during Javascript garbage collection.
diff --git a/doc/src/qml/basictypes.qdoc b/doc/src/qml/basictypes.qdoc
index 150383fdc2..0f66a96731 100644
--- a/doc/src/qml/basictypes.qdoc
+++ b/doc/src/qml/basictypes.qdoc
@@ -180,7 +180,7 @@
\div{float-right}
\inlineimage declarative-colors.png
\enddiv
- \snippet doc/src/snippets/declarative/colors.qml colors
+ \snippet doc/src/snippets/qml/colors.qml colors
Or with the \l{QML:Qt::rgba()}{Qt.rgba()}, \l{QML:Qt::hsla()}{Qt.hsla()}, \l{QML:Qt::darker()}{Qt.darker()},
\l{QML:Qt::lighter()}{Qt.lighter()} or \l{QML:Qt::tint()}{Qt.tint()} functions:
diff --git a/doc/src/qml/c++models.qdoc b/doc/src/qml/c++models.qdoc
index e2498134fe..943c79c184 100644
--- a/doc/src/qml/c++models.qdoc
+++ b/doc/src/qml/c++models.qdoc
@@ -57,7 +57,7 @@ models.
\bold{Note:} There is no way for the view to know that the contents of a QStringList
have changed. If the QStringList changes, it will be necessary to reset
- the model by calling QDeclarativeContext::setContextProperty() again.
+ the model by calling QQmlContext::setContextProperty() again.
\section1 QObjectList-based model
@@ -92,7 +92,7 @@ models.
Note: There is no way for the view to know that the contents of a QList
have changed. If the QList changes, it will be necessary to reset
- the model by calling QDeclarativeContext::setContextProperty() again.
+ the model by calling QQmlContext::setContextProperty() again.
\section1 QAbstractItemModel
@@ -160,10 +160,10 @@ models.
\section1 Exposing C++ Data Models to QML
-The above examples use QDeclarativeContext::setContextProperty() to set
+The above examples use QQmlContext::setContextProperty() to set
model values directly in QML components. An alternative to this is to
register the C++ model class as a QML type from a QML C++ plugin using
-QDeclarativeExtensionPlugin. This would allow the model classes to be
+QQmlExtensionPlugin. This would allow the model classes to be
created directly as elements within QML:
\table
@@ -171,7 +171,7 @@ created directly as elements within QML:
\o
\code
-class MyModelPlugin : public QDeclarativeExtensionPlugin
+class MyModelPlugin : public QQmlExtensionPlugin
{
public:
void registerTypes(const char *uri)
diff --git a/doc/src/qml/codingconventions.qdoc b/doc/src/qml/codingconventions.qdoc
index 89fdfd59f9..9e1ce34c2c 100644
--- a/doc/src/qml/codingconventions.qdoc
+++ b/doc/src/qml/codingconventions.qdoc
@@ -52,7 +52,7 @@ For better readability, we separate these different parts with an empty line.
For example, a hypothetical \i photo QML object would look like this:
-\snippet doc/src/snippets/declarative/codingconventions/photo.qml 0
+\snippet doc/src/snippets/qml/codingconventions/photo.qml 0
\section1 Grouped Properties
@@ -62,11 +62,11 @@ we use the \i {group notation} rather than the \i {dot notation} to improve read
For example, this:
-\snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 0
+\snippet doc/src/snippets/qml/codingconventions/dotproperties.qml 0
can be written like this:
-\snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 1
+\snippet doc/src/snippets/qml/codingconventions/dotproperties.qml 1
\section1 Private Properties
@@ -78,7 +78,7 @@ the implementation. As a convention, private properties begin with two
accessible but is not meant for public use. Note that QML and JavaScript will
grant the user access to these properties.
-\snippet doc/src/snippets/declarative/codingconventions/private.qml 0
+\snippet doc/src/snippets/qml/codingconventions/private.qml 0
\section1 Lists
@@ -89,30 +89,30 @@ For example, it is very common for a component to only have one state.
In this case, instead of:
-\snippet doc/src/snippets/declarative/codingconventions/lists.qml 0
+\snippet doc/src/snippets/qml/codingconventions/lists.qml 0
we will write this:
-\snippet doc/src/snippets/declarative/codingconventions/lists.qml 1
+\snippet doc/src/snippets/qml/codingconventions/lists.qml 1
\section1 JavaScript Code
If the script is a single expression, we recommend writing it inline:
-\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 0
+\snippet doc/src/snippets/qml/codingconventions/javascript.qml 0
If the script is only a couple of lines long, we generally use a block:
-\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 1
+\snippet doc/src/snippets/qml/codingconventions/javascript.qml 1
If the script is more than a couple of lines long or can be used by different objects, we recommend creating a function and calling it like this:
-\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 2
+\snippet doc/src/snippets/qml/codingconventions/javascript.qml 2
For long scripts, we will put the functions in their own JavaScript file and import it like this:
-\snippet doc/src/snippets/declarative/codingconventions/javascript-imports.qml 0
+\snippet doc/src/snippets/qml/codingconventions/javascript-imports.qml 0
*/
diff --git a/doc/src/qml/debugging.qdoc b/doc/src/qml/debugging.qdoc
index 520e23abb5..562464a419 100644
--- a/doc/src/qml/debugging.qdoc
+++ b/doc/src/qml/debugging.qdoc
@@ -148,11 +148,11 @@ 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
-QDeclarativeImportDatabase::addImportPath "/qt-sdk/imports"
-QDeclarativeImportDatabase::addImportPath "/qt-sdk/bin/QMLViewer.app/Contents/MacOS"
-QDeclarativeImportDatabase::addToImport 0x106237370 "." -1.-1 File as ""
-QDeclarativeImportDatabase::addToImport 0x106237370 "Qt" 4.7 Library as ""
-QDeclarativeImportDatabase::resolveType "Rectangle" = "QDeclarativeRectangle"
+QQmlImportDatabase::addImportPath "/qt-sdk/imports"
+QQmlImportDatabase::addImportPath "/qt-sdk/bin/QMLViewer.app/Contents/MacOS"
+QQmlImportDatabase::addToImport 0x106237370 "." -1.-1 File as ""
+QQmlImportDatabase::addToImport 0x106237370 "Qt" 4.7 Library as ""
+QQmlImportDatabase::resolveType "Rectangle" = "QDeclarativeRectangle"
\endcode
diff --git a/doc/src/qml/dynamicobjects.qdoc b/doc/src/qml/dynamicobjects.qdoc
index e3d9adb49a..c50f9dd337 100644
--- a/doc/src/qml/dynamicobjects.qdoc
+++ b/doc/src/qml/dynamicobjects.qdoc
@@ -80,31 +80,31 @@ the component. This function can take one or two arguments:
Here is an example. First there is \c Sprite.qml, which defines a simple QML component:
-\snippet doc/src/snippets/declarative/Sprite.qml 0
+\snippet doc/src/snippets/qml/Sprite.qml 0
Our main application file, \c main.qml, imports a \c componentCreation.js JavaScript file
that will create \c Sprite objects:
-\snippet doc/src/snippets/declarative/createComponent.qml 0
+\snippet doc/src/snippets/qml/createComponent.qml 0
Here is \c componentCreation.js. Notice it checks whether the component \l{Component::status}{status} is
\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 vars
+\snippet doc/src/snippets/qml/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
+\snippet doc/src/snippets/qml/componentCreation.js func
+\snippet doc/src/snippets/qml/componentCreation.js remote
+\snippet doc/src/snippets/qml/componentCreation.js func-end
\codeline
-\snippet doc/src/snippets/declarative/componentCreation.js finishCreation
+\snippet doc/src/snippets/qml/componentCreation.js finishCreation
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 func
-\snippet doc/src/snippets/declarative/componentCreation.js local
-\snippet doc/src/snippets/declarative/componentCreation.js func-end
+\snippet doc/src/snippets/qml/componentCreation.js func
+\snippet doc/src/snippets/qml/componentCreation.js local
+\snippet doc/src/snippets/qml/componentCreation.js func-end
Notice in both instances, \l {Component::createObject()}{createObject()} is called with
\c appWindow passed as an argument so that the created object will become a child of the
@@ -124,7 +124,7 @@ use the signal \c connect() method. See
If the QML is not defined until runtime, you can create a QML item from
a string of QML using the \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example:
-\snippet doc/src/snippets/declarative/createQmlObject.qml 0
+\snippet doc/src/snippets/qml/createQmlObject.qml 0
The first argument is the string of QML to create. Just like in a new file, you will need to
import any types you wish to use. The second argument is the parent item for the new item;
@@ -145,7 +145,7 @@ The actual creation context depends on how an item is created:
\list
\o If \l {QML:Qt::createComponent()}{Qt.createComponent()} is used, the creation context
- is the QDeclarativeContext in which this method is called
+ is the QQmlContext in which this method is called
\o If \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}
if called, the creation context is the context of the parent item passed to this method
\o If a \c {Component{}} item is defined and \l {Component::createObject()}{createObject()}
@@ -181,8 +181,8 @@ component. Each instance runs a NumberAnimation, and when the animation has fini
\o \c SelfDestroyingRect.qml
\row
-\o \snippet doc/src/snippets/declarative/dynamicObjects-destroy.qml 0
-\o \snippet doc/src/snippets/declarative/SelfDestroyingRect.qml 0
+\o \snippet doc/src/snippets/qml/dynamicObjects-destroy.qml 0
+\o \snippet doc/src/snippets/qml/SelfDestroyingRect.qml 0
\endtable
@@ -209,6 +209,6 @@ destroyed if they were dynamically created.
Objects created with \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}
can similarly be destroyed using \c destroy():
-\snippet doc/src/snippets/declarative/createQmlObject.qml 0
-\snippet doc/src/snippets/declarative/createQmlObject.qml destroy
+\snippet doc/src/snippets/qml/createQmlObject.qml 0
+\snippet doc/src/snippets/qml/createQmlObject.qml destroy
*/
diff --git a/doc/src/qml/extending-tutorial.qdoc b/doc/src/qml/extending-tutorial.qdoc
index 00f4bb5691..b995c32cca 100644
--- a/doc/src/qml/extending-tutorial.qdoc
+++ b/doc/src/qml/extending-tutorial.qdoc
@@ -100,14 +100,14 @@ Here is our \c PieChart class, defined in \c piechart.h:
\snippet declarative/tutorials/extending/chapter1-basics/piechart.h 0
-The class inherits from QDeclarativeItem because we want to override
-QDeclarativeItem::paint() in order to draw. If the class just represented some
+The class inherits from QQuickItem because we want to override
+QQuickItem::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.
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
+and overrides QQuickItem::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:
@@ -127,7 +127,7 @@ converted to a QColor object for the PieChart \c color property. Automatic conve
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
+We'll also create a C++ application that uses a QQuickView to run and
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 PieChart.
@@ -265,7 +265,7 @@ int-type property to store an identifier for each chart:
\code
// C++
- class PieChart : public QDeclarativeItem
+ class PieChart : public QQuickItem
{
Q_PROPERTY(int chartId READ chartId WRITE setChartId NOTIFY chartIdChanged)
...
@@ -306,7 +306,7 @@ we assign an \c PieSlice value which itself contains a \c color:
\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml 0
-Like \c PieChart, this new \c PieSlice type inherits from QDeclarativeItem and declares
+Like \c PieChart, this new \c PieSlice type inherits from QQuickItem and declares
its properties with Q_PROPERTY():
\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h 0
@@ -324,7 +324,7 @@ and associated method signatures:
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
+QQuickItem::setParentItem() so that the \c PieChart knows to paint this child
item when its contents are drawn:
\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp 0
@@ -359,7 +359,7 @@ have a \c slices property that accepts a list of \c PieSlice items:
\image extending-tutorial-chapter5.png
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
+declared as a QQmlListProperty type. The QQmlListProperty 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
@@ -372,9 +372,9 @@ store the internal list of slices as \c m_slices:
\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.
+it is still modifiable because of the way QQmlListProperty works.
In the \c PieChart implementation, we implement \c PieChart::slices() to
-return a QDeclarativeListProperty value and indicate that the internal
+return a QQmlListProperty 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:
@@ -382,7 +382,7 @@ to add items to the list:
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
+QQmlListProperty 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
@@ -400,7 +400,7 @@ The complete code can be seen in the updated \c examples/tutorials/extending/cha
\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
+which is displayed using a QQuickView 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 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
@@ -414,8 +414,8 @@ To create a plugin library, we need:
\o A \l{Writing a qmldir file}{qmldir} file that tells the QML engine to load the plugin
\endlist
-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
+First, we create a plugin class named \c ChartsPlugin. It subclasses QQmlExtensionPlugin
+and registers our QML types in the inherited \l{QQmlExtensionPlugin::}{registerTypes()} method. It also calls
Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}.
Here is the \c ChartsPlugin definition in \c chartsplugin.h:
@@ -464,7 +464,7 @@ 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 Define list property types using QQmlListProperty
\o Create a plugin library by defining a Qt plugin and writing a \c qmldir file
\endlist
diff --git a/doc/src/qml/integrating.qdoc b/doc/src/qml/integrating.qdoc
index 7cd15a4fd4..2a88246006 100644
--- a/doc/src/qml/integrating.qdoc
+++ b/doc/src/qml/integrating.qdoc
@@ -38,13 +38,13 @@ depending on the characteristics of your existing UI code.
\section1 Integrating with a \l{QWidget}-based UI
If you have an existing QWidget-based UI, QML widgets can be integrated into
-it using QDeclarativeView. QDeclarativeView is a subclass of QWidget so you
+it using QQuickView. QQuickView is a subclass of QWidget so you
can add it to your user interface like any other QWidget. Use
-QDeclarativeView::setSource() to load a QML file into the view, then add the
+QQuickView::setSource() to load a QML file into the view, then add the
view to your UI:
\code
-QDeclarativeView *qmlView = new QDeclarativeView;
+QQuickView *qmlView = new QQuickView;
qmlView->setSource(QUrl::fromLocalFile("myqml.qml"));
QWidget *widget = myExistingWidget();
@@ -52,11 +52,11 @@ QVBoxLayout *layout = new QVBoxLayout(widget);
layout->addWidget(qmlView);
\endcode
-The one drawback to this approach is that QDeclarativeView is slower to initialize
-and uses more memory than a QWidget, and creating large numbers of QDeclarativeView
+The one drawback to this approach is that QQuickView is slower to initialize
+and uses more memory than a QWidget, and creating large numbers of QQuickView
objects may lead to performance degradation. If this is the case, it may be
better to rewrite your widgets in QML, and load the widgets from a main QML widget
-instead of using QDeclarativeView.
+instead of using QQuickView.
Keep in mind that QWidgets were designed for a different type of user interface
than QML, so it is not always a good idea to port a QWidget-based application to
@@ -71,7 +71,7 @@ of simple and dynamic elements.
If you have an existing UI based on the \l{Graphics View Framework},
you can integrate QML widgets directly into your QGraphicsScene. Use
-QDeclarativeComponent to create a QGraphicsObject from a QML file, and
+QQmlComponent to create a QGraphicsObject from a QML file, and
place the graphics object into your scene using \l{QGraphicsScene::addItem()}, or
reparent it to an item already in the \l{QGraphicsScene}.
@@ -79,8 +79,8 @@ For example:
\code
QGraphicsScene* scene = myExistingGraphicsScene();
-QDeclarativeEngine *engine = new QDeclarativeEngine;
-QDeclarativeComponent component(engine, QUrl::fromLocalFile("myqml.qml"));
+QQmlEngine *engine = new QQmlEngine;
+QQmlComponent component(engine, QUrl::fromLocalFile("myqml.qml"));
QGraphicsObject *object =
qobject_cast<QGraphicsObject *>(component.create());
scene->addItem(object);
diff --git a/doc/src/qml/javascriptblocks.qdoc b/doc/src/qml/javascriptblocks.qdoc
index 4cc98f1d7a..0c1d4c284c 100644
--- a/doc/src/qml/javascriptblocks.qdoc
+++ b/doc/src/qml/javascriptblocks.qdoc
@@ -200,8 +200,8 @@ in \c script.js:
\table
\row
-\o \snippet doc/src/snippets/declarative/integrating-javascript/connectjs.qml 0
-\o \snippet doc/src/snippets/declarative/integrating-javascript/script.js 0
+\o \snippet doc/src/snippets/qml/integrating-javascript/connectjs.qml 0
+\o \snippet doc/src/snippets/qml/integrating-javascript/script.js 0
\endtable
The \c jsFunction() will now be called whenever MouseArea's \c clicked signal is emitted.
@@ -222,7 +222,7 @@ Both relative and absolute JavaScript URLs can be imported. In the case of a
relative URL, the location is resolved relative to the location of the
\l {QML Document} that contains the import. If the script file is not accessible,
an error will occur. If the JavaScript needs to be fetched from a network
-resource, the component's \l {QDeclarativeComponent::status()}{status} is set to
+resource, the component's \l {QQmlComponent::status()}{status} is set to
"Loading" until the script has been downloaded.
Imported JavaScript files are always qualified using the "as" keyword. The
@@ -243,10 +243,10 @@ which in turn can call \c factorial() in \c factorial.js, as it has included
\table
\row
-\o {1,2} \snippet doc/src/snippets/declarative/integrating-javascript/includejs/app.qml 0
-\o \snippet doc/src/snippets/declarative/integrating-javascript/includejs/script.js 0
+\o {1,2} \snippet doc/src/snippets/qml/integrating-javascript/includejs/app.qml 0
+\o \snippet doc/src/snippets/qml/integrating-javascript/includejs/script.js 0
\row
-\o \snippet doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js 0
+\o \snippet doc/src/snippets/qml/integrating-javascript/includejs/factorial.js 0
\endtable
Notice that calling \l {QML:Qt::include()}{Qt.include()} imports all functions from
@@ -479,11 +479,11 @@ themselves.
For the following examples, imagine that we have defined the following class:
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h 0
and that we have registered it with the QML type-system as follows:
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 0
The AvatarExample class has a property which is a pixmap. When the property
is accessed in JavaScript scope, a copy of the resource will be created and
@@ -498,9 +498,9 @@ unless the client explicitly preserves it.
In the following example, the scarce resource will be automatically released
after the binding evaluation is complete.
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml 0
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 1
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 1
\section2 Example Two: Automatic Release Prevented By Reference
@@ -509,9 +509,9 @@ released after the binding expression evaluation is
complete, because there is a property var referencing the
scarce resource.
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml 0
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 2
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 2
\section2 Example Three: Explicit Preservation
@@ -519,11 +519,11 @@ In this example, the resource must be explicitly preserved in order
to prevent the declarative engine from automatically releasing the
resource after evaluation of the imported script.
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js 0
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml 0
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 3
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 3
\section2 Example Four: Explicit Destruction
@@ -532,11 +532,11 @@ scarce resource variant. This example shows how a client may free system
resources by releasing the scarce resource held in a JavaScript object, if
required, during evaluation of a JavaScript expression.
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js 0
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml 0
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 4
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 4
\section2 Example Five: Explicit Destruction And JavaScript References
@@ -546,8 +546,8 @@ to one scarce resource is held, and the client calls destroy() on one
of those references (to explicitly release the scarce resource), all of
the references will be affected.
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml 0
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml 0
-\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 5
+\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 5
*/
diff --git a/doc/src/qml/modules.qdoc b/doc/src/qml/modules.qdoc
index f75c03301c..27f8ae8fb1 100644
--- a/doc/src/qml/modules.qdoc
+++ b/doc/src/qml/modules.qdoc
@@ -45,14 +45,14 @@ example, an \c import statement is required to use:
\list
\o A component defined in another QML file that is not in the same directory
\o A component defined in a QML file located on a remote server
-\o A \l{QDeclarativeExtensionPlugin}{QML extension plugin} library (unless the plugin is installed in the same directory)
+\o A \l{QQmlExtensionPlugin}{QML extension plugin} library (unless the plugin is installed in the same directory)
\o A JavaScript file (note this must be imported using \l {#namespaces}{named imports})
\endlist
An \c import statement includes the module name, and possibly a version number.
This can be seen in the snippet commonly found at the top of QML files:
-\snippet doc/src/snippets/declarative/imports/qtquick-1.0.qml import
+\snippet doc/src/snippets/qml/imports/qtquick-1.0.qml import
This imports version 1.0 of the "QtQuick" module into the global namespace. (The QML
library itself must be imported to use any of the \l {QML Elements}, as they
@@ -111,7 +111,7 @@ Window {
Similarly, if the directory resided on a network source, it could
be imported like this:
-\snippet doc/src/snippets/declarative/imports/network-imports.qml imports
+\snippet doc/src/snippets/qml/imports/network-imports.qml imports
A located module can also be imported as a network resource if it has a
\l{Writing a qmldir file}{qmldir file} in the directory that specifies the QML files
@@ -145,7 +145,7 @@ a later version was used, as the \c qmldir file specifies that these elements
are only available in the 1.0 version.
Note that modules imported as a network resource allow only access to components
-defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{QML extension plugins}
+defined in QML files; components defined by C++ \l{QQmlExtensionPlugin}{QML extension plugins}
are not available.
@@ -153,7 +153,7 @@ are not available.
\section1 Installed Modules
Installed modules are modules that are made available through the QML import path,
-as defined by QDeclarativeEngine::importPathList(), or modules defined within
+as defined by QQmlEngine::importPathList(), or modules defined within
C++ application code. An installed module is referred to by a URI, which allows
the module to be imported from QML code without specifying a complete filesystem
path or network resource URL.
@@ -161,7 +161,7 @@ path or network resource URL.
When importing an installed module, an un-quoted URI is
used, with a mandatory version number:
-\snippet doc/src/snippets/declarative/imports/installed-module.qml imports
+\snippet doc/src/snippets/qml/imports/installed-module.qml imports
When a module is imported, the QML engine searches the QML import path for a matching
module. The root directory of the module must contain a
@@ -177,7 +177,7 @@ module could be located under \c com/nokia/qml/mymodule.2/qmldir or
\c com/nokia/qml/mymodule.2.1/qmldir. The engine will automatically load
the module which matches best.
-The import path, as returned by QDeclarativeEngine::importPathList(), defines the default
+The import path, as returned by QQmlEngine::importPathList(), defines the default
locations to be searched by the QML engine for a matching module. By default, this list
contains:
@@ -187,7 +187,7 @@ contains:
\o Paths specified by the \c QML_IMPORT_PATH environment variable
\endlist
-Additional import paths can be added through QDeclarativeEngine::addImportPath() or the
+Additional import paths can be added through QQmlEngine::addImportPath() or the
\c QML_IMPORT_PATH environment variable. When running the \l {QML Viewer}, you
can also use the \c -I option to add an import path.
@@ -227,7 +227,7 @@ as \c http://www.some-server.com/qml and this URL was added to the QML import pa
QML code would work just the same.
Note that modules imported as a network resource allow only access to components
-defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{QML extension plugins}
+defined in QML files; components defined by C++ \l{QQmlExtensionPlugin}{QML extension plugins}
are not available.
@@ -244,10 +244,10 @@ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
This allows the application's QML files to use the \c PieChart type by importing the declared
\c Charts module:
-\snippet doc/src/snippets/declarative/imports/chart.qml import
+\snippet doc/src/snippets/qml/imports/chart.qml import
-For \l{QDeclarativeExtensionPlugin}{QML plugins}, the
-module URI is automatically passed to QDeclarativeExtensionPlugin::registerTypes(). This method
+For \l{QQmlExtensionPlugin}{QML plugins}, the
+module URI is automatically passed to QQmlExtensionPlugin::registerTypes(). This method
can be reimplemented by the developer to register the necessary types for the module. Below is the
\c registerTypes() implementation from the \l{declarative/cppextensions/plugins}{QML plugins}
example:
@@ -257,7 +257,7 @@ example:
Once the plugin is built and installed, and includes a \l{Writing a qmldir file}{qmldir file},
the module can be imported from QML, like this:
-\snippet doc/src/snippets/declarative/imports/timeexample.qml import
+\snippet doc/src/snippets/qml/imports/timeexample.qml import
Unlike QML types defined by QML files, a QML type defined in a C++ extension plugin cannot be loaded by
a module that is imported as a network resource.
@@ -271,15 +271,15 @@ By default, when a module is imported, its contents are imported into the global
To import a module into a specific namespace, use the \i as keyword:
-\snippet doc/src/snippets/declarative/imports/named-imports.qml imports
+\snippet doc/src/snippets/qml/imports/named-imports.qml imports
Types from these modules can then only be used when qualified by the namespace:
-\snippet doc/src/snippets/declarative/imports/named-imports.qml imported items
+\snippet doc/src/snippets/qml/imports/named-imports.qml imported items
Multiple modules can be imported into the same namespace in the same way that multiple modules can be imported into the global namespace:
-\snippet doc/src/snippets/declarative/imports/merged-named-imports.qml imports
+\snippet doc/src/snippets/qml/imports/merged-named-imports.qml imports
\section2 JavaScript Files
@@ -381,14 +381,14 @@ into a Namespace exported by the module. The contents of the script file are ma
available inside the namespace <Namespace>, which has the version number
<InitialVersion>.
-\bold {plugin <Name> [<Path>]} lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins} to the module. <Name> is the name of the library. It is usually not the same as the file name
+\bold {plugin <Name> [<Path>]} lines are used to add \l{QQmlExtensionPlugin}{QML C++ plugins} to the module. <Name> is the name of the library. It is usually not the same as the file name
of the plugin binary, which is platform dependent; e.g. the library \c MyAppTypes would produce
\c libMyAppTypes.so on Linux and \c MyAppTypes.dll on Windows.
<Path> is an optional argument specifying either an absolute path to the directory containing the
plugin file, or a relative path from the directory containing the \c qmldir file to the directory
containing the plugin file. By default the engine searches for the plugin library in the directory that contains the \c qmldir
-file. The plugin search path can be queried with QDeclarativeEngine::pluginPathList() and modified using QDeclarativeEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path.
+file. The plugin search path can be queried with QQmlEngine::pluginPathList() and modified using QQmlEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path.
\bold {typeinfo <File>} lines add \l{Writing a qmltypes file}{type description files} to
the module that can be read by QML tools such as Qt Creator to get information about the
@@ -434,7 +434,7 @@ to \c /tmp/imports/My/Module/qmldir to register it.
While the qmldump tool covers most cases, it does not work if:
\list
-\o The plugin uses a \l{QDeclarativeCustomParser}. The component that uses
+\o The plugin uses a \l{QQmlCustomParser}. The component that uses
the custom parser will not get its members documented.
\o The plugin can not be loaded. In particular if you cross-compiled
the plugin for a different architecture, qmldump will not be able to
@@ -456,7 +456,7 @@ Module {
// The name is a unique identifier used to refer to this type.
// It is recommended you simply use the C++ type name.
- name: "QDeclarativeAbstractAnimation"
+ name: "QQuickAbstractAnimation"
// The name of the prototype Component.
prototype: "QObject"
@@ -492,12 +492,12 @@ Module {
Property {
name: "animations";
- type: "QDeclarativeAbstractAnimation"
+ type: "QQuickAbstractAnimation"
// defaults to false, whether this property is read only
isReadonly: true
// defaults to false, whether the type of this property was a pointer in C++
isPointer: true
- // defaults to false: whether the type actually is a QDeclarativeListProperty<type>
+ // defaults to false: whether the type actually is a QQmlListProperty<type>
isList: true
// defaults to 0: the meta object revision that introduced this property
revision: 1
diff --git a/doc/src/qml/network.qdoc b/doc/src/qml/network.qdoc
index 15a17203c3..71f42a4bfe 100644
--- a/doc/src/qml/network.qdoc
+++ b/doc/src/qml/network.qdoc
@@ -118,11 +118,11 @@ See the \tt examples/declarative/flickr for a real demonstration of this.
\section1 Configuring the Network Access Manager
-All network access from QML is managed by a QNetworkAccessManager set on the QDeclarativeEngine which executes the QML.
+All network access from QML is managed by a QNetworkAccessManager set on the QQmlEngine which executes the QML.
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 {QML Viewer} sets a QDeclarativeNetworkAccessManagerFactory which
+providing a QQmlNetworkAccessManagerFactory and setting it via
+QQmlEngine::setNetworkAccessManagerFactory().
+For example, the \l {QML Viewer} sets a QQmlNetworkAccessManagerFactory 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.
@@ -134,7 +134,7 @@ the executable using \l{The Qt Resource System}. Using this, an executable can r
that is compiled into the executable:
\code
- QDeclarativeView *canvas = new QDeclarativeView;
+ QQuickView *canvas = new QQuickView;
canvas->setUrl(QUrl("qrc:/dial.qml"));
\endcode
diff --git a/doc/src/qml/propertybinding.qdoc b/doc/src/qml/propertybinding.qdoc
index b89b3d7a61..6dd862f55b 100644
--- a/doc/src/qml/propertybinding.qdoc
+++ b/doc/src/qml/propertybinding.qdoc
@@ -44,10 +44,10 @@ The syntax for properties is:
Elements already possess useful properties but, to create custom properties,
precede the property name with the keyword \c property.
-\snippet doc/src/snippets/declarative/properties.qml parent begin
-\snippet doc/src/snippets/declarative/properties.qml inherited properties
-\snippet doc/src/snippets/declarative/properties.qml custom properties
-\snippet doc/src/snippets/declarative/properties.qml parent end
+\snippet doc/src/snippets/qml/properties.qml parent begin
+\snippet doc/src/snippets/qml/properties.qml inherited properties
+\snippet doc/src/snippets/qml/properties.qml custom properties
+\snippet doc/src/snippets/qml/properties.qml parent end
QML property rules coincide with many of JavaScript's property rules, for example,
property names must begin with a lowercase letter.
@@ -62,14 +62,14 @@ to other property values or data accessible in the application. The property val
automatically kept up to date if the other properties or data values change.
Property bindings are created in QML using the colon "\c {:}" before the value:
-\snippet doc/src/snippets/declarative/properties.qml property binding
+\snippet doc/src/snippets/qml/properties.qml property binding
The property binding causes the width of the \c Rectangle to update whenever the
\c {parent}'s width changes.
QML extends a standards compliant JavaScript engine, so any valid JavaScript expression can be
used as a property binding. Bindings can access object properties, make function calls and even
use built-in JavaScript objects such as \c {Date} and \c {Math}.
-\snippet doc/src/snippets/declarative/properties.qml JavaScript sample
+\snippet doc/src/snippets/qml/properties.qml JavaScript sample
While syntactically bindings can be of arbitrary complexity, if a binding starts to become
overly complex - such as involving multiple lines, or imperative loops - it may be better
@@ -82,13 +82,13 @@ function.
When working with both QML and JavaScript, it is important to differentiate between
QML property binding and JavaScript value assignment. In QML, a property
binding is created using the colon "\c {:}".
-\snippet doc/src/snippets/declarative/properties.qml property binding
+\snippet doc/src/snippets/qml/properties.qml property binding
The property binding causes the width of the \c Rectangle to update whenever the
\c {parent}'s width changes.
Assigning a property value (using the equals sign "\c {=}") does not create a
property binding.
-\snippet doc/src/snippets/declarative/properties.qml property assignment
+\snippet doc/src/snippets/qml/properties.qml property assignment
Instead of creating a property binding, the assignment simply sets the \c Rectangle
\c width value to a number when the \c Component.onCompleted code is invoked.
@@ -186,7 +186,7 @@ Care must be taken when referring to the parent of an object property binding.
Elements and components that are bound to properties are not necessarily set
as children of the properties' component.
-\snippet doc/src/snippets/declarative/properties.qml object binding
+\snippet doc/src/snippets/qml/properties.qml object binding
The code snippet has a \l Gradient element that attempts to print its parent's
\c width value. However, the \c Gradient element is bound to the \c gradient
property, not the \c children property of the \c Rectangle. As a result, the
@@ -205,7 +205,7 @@ Certain objects provide additional properties by \i attaching properties to othe
objects. For example, the \l Keys element have properties that can \i attach to other QML
objects to provide keyboard handling.
-\snippet doc/src/snippets/declarative/properties.qml list attached property
+\snippet doc/src/snippets/qml/properties.qml list attached property
The element \l ListView provides the delegate, \c listdelegate, the property
\c isCurrentItem as an attached property. The \c ListView.isCurrentItem
\i{attached property} provides highlight information to the delegate.
@@ -221,7 +221,7 @@ to provide additional functionality to objects. Two prominent elements,
\l Component and \l Keys element provide
\l{QML Signal and Handler Event System}{signal handlers} as attached signal
handlers.
-\snippet doc/src/snippets/declarative/properties.qml attached signal handler
+\snippet doc/src/snippets/qml/properties.qml attached signal handler
Read the \l{QML Signal and Handler Event System} and the \l{Keyboard Focus in QML}
articles for more information.
@@ -232,14 +232,14 @@ Some properties may accept a binding to a list property, where more than one
component can bind to the property. List properties allow multiple
\l {State}{States}, \l {Gradient}{Gradients}, and other components to bind to a
single property.
-\snippet doc/src/snippets/declarative/properties.qml list property
+\snippet doc/src/snippets/qml/properties.qml list property
The list is enclosed in square brackets, with a comma separating the
list elements. In cases where you are only assigning a single item to a
list, you may omit the square brackets.
-\snippet doc/src/snippets/declarative/properties.qml single property
+\snippet doc/src/snippets/qml/properties.qml single property
To access the list, use the \c index property.
-\snippet doc/src/snippets/declarative/properties.qml print list property
+\snippet doc/src/snippets/qml/properties.qml print list property
The snippet code simply prints the name of the first state, \c FETCH.
See the \l{list}{list type} documentation
@@ -252,7 +252,7 @@ In some cases properties form a logical group and use either the \i dot notation
or \i group notation.
Grouped properties may be written both ways:
-\snippet doc/src/snippets/declarative/properties.qml grouped properties
+\snippet doc/src/snippets/qml/properties.qml grouped properties
In the element documentation grouped properties are shown using the dot notation.
@@ -275,18 +275,18 @@ Accessing the aliasing property is similar to accessing a regular property. In
addition, the optional \c default keyword indicates that the aliasing property
is a \l{Default Properties}{default property}.
-\snippet doc/src/snippets/declarative/Button.qml property alias
+\snippet doc/src/snippets/qml/Button.qml property alias
When importing the component as a \c Button, the \c buttonlabel is directly
accessible through the \c label property.
-\snippet doc/src/snippets/declarative/properties.qml alias usage
+\snippet doc/src/snippets/qml/properties.qml alias usage
In addition, the \c id property may also be aliased and referred outside the
component.
-\snippet doc/src/snippets/declarative/Button.qml parent begin
-\snippet doc/src/snippets/declarative/Button.qml id alias
-\snippet doc/src/snippets/declarative/Button.qml parent end
+\snippet doc/src/snippets/qml/Button.qml parent begin
+\snippet doc/src/snippets/qml/Button.qml id alias
+\snippet doc/src/snippets/qml/Button.qml parent end
The \c imagebutton component has the ability to modify the child \l Image object
and its properties.
-\snippet doc/src/snippets/declarative/properties.qml image alias
+\snippet doc/src/snippets/qml/properties.qml image alias
Using aliases, properties may be exposed to the
\l{qml-top-level-component}{top level component}. Exposing properties to the
@@ -299,7 +299,7 @@ Aliases are only activated once the component
when an uninitialized alias is referenced. Likewise, aliasing an aliasing
property will also result in an error.
-\snippet doc/src/snippets/declarative/properties.qml alias complete
+\snippet doc/src/snippets/qml/properties.qml alias complete
When importing the component, however, aliasing properties appear as regular Qt
properties and consequently can be used in alias references.
@@ -309,7 +309,7 @@ property, effectively overwriting the existing property. For example,
the following component has a \c color alias property, named the same as the built-in
\l {Rectangle::color} property:
-\snippet doc/src/snippets/declarative/properties.qml alias overwrite
+\snippet doc/src/snippets/qml/properties.qml alias overwrite
Any object that use this component and refer to its \c color property will be
referring to the alias rather than the ordinary \l {Rectangle::color} property.
@@ -328,13 +328,13 @@ as the \i {default property}. For example, the State element's default property
is its \l{State::changes}{changes} property. \l PropertyChanges elements
may simply be placed as the \c{State}'s children and they will be bound to the
\c changes property.
-\snippet doc/src/snippets/declarative/properties.qml state default
+\snippet doc/src/snippets/qml/properties.qml state default
Similarly, the \l Item element's default property is its
\l{Item::data}{data} property. The \c data property manages Item's
\c children and \c resources properties. This way, different data types may be
placed as direct children of the \c Item.
-\snippet doc/src/snippets/declarative/properties.qml default property
+\snippet doc/src/snippets/qml/properties.qml default property
Reassigning a default property is useful when a component is reused. For
example, the \l{declarative/ui-components/tabwidget}{TabWidget} example uses
@@ -350,14 +350,14 @@ For example, to bind a property exposed from the \l{The QML Engine}{declarative
runtime} or \l{QmlGlobalQtObject}{Qt object}, such as the \c system.brightness
property, to a value written in QML, you could use the \l Binding element as
follows:
-\snippet doc/src/snippets/declarative/properties.qml binding element
+\snippet doc/src/snippets/qml/properties.qml binding element
\section1 Changing Property Values in States
The \l PropertyChanges element is for setting property bindings within a
\l State element to set a property binding.
-\snippet doc/src/snippets/declarative/properties.qml PropertyChanges element
+\snippet doc/src/snippets/qml/properties.qml PropertyChanges element
The rectangle's \c color property will bind to the \c warning component's
\c color property when its \c state is set to the \c WARNING state.
*/
diff --git a/doc/src/qml/qmlcomponents.qdoc b/doc/src/qml/qmlcomponents.qdoc
index bcc465f4b2..21b94f2ae3 100644
--- a/doc/src/qml/qmlcomponents.qdoc
+++ b/doc/src/qml/qmlcomponents.qdoc
@@ -50,7 +50,7 @@ is the emphasis in QML.
Any snippet of QML code may become a component, by placing the code in a QML
file, whose file extension is \c .qml). A complete Button component that
responds to user input may be in a Button.qml file.
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml document
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml document
The component name, \c Button, matches the QML filename, \c Button.qml.
Also, the first character is in upper case. Matching the names allow
@@ -60,9 +60,9 @@ naming components with different filenames.
Alternatively, a \l Component element may encapsulate a QML object to form a
component.
-\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent begin
-\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component
-\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent end
+\snippet doc/src/snippets/qml/reusablecomponents/component.qml parent begin
+\snippet doc/src/snippets/qml/reusablecomponents/component.qml define inline component
+\snippet doc/src/snippets/qml/reusablecomponents/component.qml parent end
Components may incorporate any \l{Qt Quick}{QML feature} such as:
@@ -89,7 +89,7 @@ A component defined in a \c .qml file is directly usable by declaring the name
of the component. For example, a button defined in \c Button.qml is created by
declaring a \c Button. The button is defined in the
\l {qml-define-components}{Defining New Components} section.
-\snippet doc/src/snippets/declarative/reusablecomponents/application.qml document
+\snippet doc/src/snippets/qml/reusablecomponents/application.qml document
Note that the component name, \c Button, matches the QML filename, \c Button.qml.
Also, the first character is in upper case. Matching the names allow
@@ -100,7 +100,7 @@ For flexibility, a \c qmldir file is for dictating which additional components,
plugins, or directories should be imported. By using a \c qmldir file, component
names do not need to match the filenames. The \c qmldir file should, however, be
in an imported path.
-\snippet doc/src/snippets/declarative/reusablecomponents/qmldir document
+\snippet doc/src/snippets/qml/reusablecomponents/qmldir document
\section2 Loading an Inline Component
@@ -109,8 +109,8 @@ delayed. A component may be created during a MouseArea event or by using a
\l Loader element. The component can create an object, which is addressable in a
similar way as an \l {qml-id}{identifier}. Thus, the created object may
have its bindings set and read like a normal QML object.
-\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component
-\snippet doc/src/snippets/declarative/reusablecomponents/component.qml create inline component
+\snippet doc/src/snippets/qml/reusablecomponents/component.qml define inline component
+\snippet doc/src/snippets/qml/reusablecomponents/component.qml create inline component
\keyword qml-component-properties
\section1 Component Properties
@@ -140,11 +140,11 @@ Consider the Button component from the
object is a \l Rectangle. When imported, the Button component will possess the
Rectangle's properties, methods, signals, and any custom properties.
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml properties
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent begin
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml ellipses
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml properties
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml ellipses
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent end
The Button's \c text alias is accessible from outside the component as well as
the Rectangle's visual properties and signals such as \c x, \c y, \c anchors,
@@ -156,7 +156,7 @@ children which is beneficial for certain types of interfaces. However, since
\c FocusScopes are not visual elements, the visual properties of its child need
to be exposed.
-\snippet doc/src/snippets/declarative/reusablecomponents/focusbutton.qml document
+\snippet doc/src/snippets/qml/reusablecomponents/focusbutton.qml document
\keyword qml-id
\section2 The Object Identifier
@@ -165,7 +165,7 @@ Each QML object may be given a special unique identifier called an \c id.
No other object within the same QML component (see \l{QML Documents}) can have
the same \c id value. QML objects may then access an object using the \c id
property.
-\snippet doc/src/snippets/declarative/properties.qml id property
+\snippet doc/src/snippets/qml/properties.qml id property
A component may readily access its parent's properties by using the \c parent
property.
@@ -178,15 +178,15 @@ Note that an \c id must begin with a lower-case letter or an underscore. The
Objects or Items declared within a component can be made accessible by binding their id to a
property alias.
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml object alias
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml text
-\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent begin
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml object alias
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml text
+\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent end
The advantage of using an alias instead a property of type of the object is that the value of
the alias cannot be overridden, and members of the object can be used in property bindings when
declaring an instance of the component.
-\snippet doc/src/snippets/declarative/reusablecomponents/application.qml grouped property
+\snippet doc/src/snippets/qml/reusablecomponents/application.qml grouped property
If a property of type \c Text was used instead of an alias in this instance there would be no
guarantee that \c label would be initialized before the binding was attempted which would cause
the binding to fail.
diff --git a/doc/src/qml/qmldocument.qdoc b/doc/src/qml/qmldocument.qdoc
index fedeba35e1..426f135a45 100644
--- a/doc/src/qml/qmldocument.qdoc
+++ b/doc/src/qml/qmldocument.qdoc
@@ -36,7 +36,7 @@ from text data.
Here is a simple QML document:
-\snippet doc/src/snippets/declarative/qml-documents/non-trivial.qml document
+\snippet doc/src/snippets/qml/qml-documents/non-trivial.qml document
QML documents are always encoded in UTF-8 format.
@@ -79,7 +79,7 @@ text property:
\o application.qml
\row
-\o \snippet doc/src/snippets/declarative/qml-documents/qmldocuments.qml document
+\o \snippet doc/src/snippets/qml/qml-documents/qmldocuments.qml document
\o
\qml
import QtQuick 2.0
@@ -138,14 +138,14 @@ These final two examples perform identically to the original document.
\table
\row
\o
-\snippet doc/src/snippets/declarative/qml-documents/inline-component.qml document
+\snippet doc/src/snippets/qml/qml-documents/inline-component.qml document
\o
-\snippet doc/src/snippets/declarative/qml-documents/inline-text-component.qml document
+\snippet doc/src/snippets/qml/qml-documents/inline-text-component.qml document
\endtable
For information about components, the \l{QML Components} article details the
creation of components and how to load them in other components.
-\sa QDeclarativeComponent
+\sa QQmlComponent
*/
diff --git a/doc/src/qml/qmlengine.qdoc b/doc/src/qml/qmlengine.qdoc
index 3e8ef1ae3f..0865755c7b 100644
--- a/doc/src/qml/qmlengine.qdoc
+++ b/doc/src/qml/qmlengine.qdoc
@@ -38,16 +38,16 @@ specified in QML files, plugins, or applications.
\section1 Core Module Classes
- The \l{QtDeclarative}{Qt Declarative} module provides a set of C++ APIs for
+ The \l{QtQml}{Qt Declarative} module provides a set of C++ APIs for
extending your QML applications from C++ and embedding QML into C++
applications. There are several core classes in the Qt Declarative module
that provide the essential capabilities for doing this. These are:
\list
- \o QDeclarativeEngine: A QML engine provides the environment for executing QML code. Every
+ \o QQmlEngine: A QML engine provides the environment for executing QML code. Every
application requires at least one engine instance.
- \o QDeclarativeComponent: A component encapsulates QML information.
- \o QDeclarativeContext: A context allows an application to expose data to
+ \o QQmlComponent: A component encapsulates QML information.
+ \o QQmlContext: A context allows an application to expose data to
the QML components created by an engine.
\endlist
@@ -61,27 +61,27 @@ specified in QML files, plugins, or applications.
\endlist
\section2 Declarative Engine
- A QDeclarativeEngine allows the configuration of global settings that
+ A QQmlEngine allows the configuration of global settings that
apply to all of its QML component instances: for example, the
QNetworkAccessManager to be used for network communications, and the
file path to be used for persistent storage.
- QDeclarativeComponent is used to load QML documents. Each
- QDeclarativeComponent instance represents a single document. A component
+ QQmlComponent is used to load QML documents. Each
+ QQmlComponent instance represents a single document. A component
can be created from the URL or file path of a QML document, or the raw
QML code of the document. Component instances are instatiated through
- the QDeclarativeComponent::create() method, like this:
+ the QQmlComponent::create() method, like this:
\code
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml"));
QObject *rectangleInstance = component.create();
// ...
delete rectangleInstance;
\endcode
- QML documents can also be loaded using QDeclarativeView. This class
+ QML documents can also be loaded using QQuickView. This class
provides a convenient QWidget-based view for embedding QML components
into QGraphicsView-based applications. (For other methods of integrating
QML into QWidget-based applications, see \l {Integrating QML Code with
@@ -91,44 +91,44 @@ specified in QML files, plugins, or applications.
\section2 Loading QML Components from C++
- A QML document can be loaded with QDeclarativeComponent or QDeclarativeView.
- QDeclarativeComponent loads a QML component as a C++ object;
- QDeclarativeView also does this, but additionally loads the QML component
+ A QML document can be loaded with QQmlComponent or QQuickView.
+ QQmlComponent loads a QML component as a C++ object;
+ QQuickView also does this, but additionally loads the QML component
directly into a QGraphicsView. It is convenient for loading a displayable
QML component into a QWidget-based application.
For example, suppose there is a \c MyItem.qml file that looks like this:
- \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start
- \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end
+ \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start
+ \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end
- This QML document can be loaded with QDeclarativeComponent or
- QDeclarativeView with the following C++ code. Using a QDeclarativeComponent
- requires calling QDeclarativeComponent::create() to create a new instance of
- the component, while a QDeclarativeView automatically creates an instance of
- the component, which is accessible via QDeclarativeView::rootObject():
+ This QML document can be loaded with QQmlComponent or
+ QQuickView with the following C++ code. Using a QQmlComponent
+ requires calling QQmlComponent::create() to create a new instance of
+ the component, while a QQuickView automatically creates an instance of
+ the component, which is accessible via QQuickView::rootObject():
\table
\row
\o
- \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-a
+ \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-a
\dots 0
- \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-b
+ \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-b
\o
- \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeView
+ \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQuickView
\endtable
This \c object is the instance of the \c MyItem.qml component that has been
created. You can now modify the item's properties using
- QObject::setProperty() or QDeclarativeProperty:
+ QObject::setProperty() or QQmlProperty:
- \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp properties
+ \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp properties
Alternatively, you can cast the object to its actual type and call functions
with compile-time safety. In this case the base object of \c MyItem.qml is
- an \l Item, which is defined by the QDeclarativeItem class:
+ an \l Item, which is defined by the QQuickItem class:
- \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp cast
+ \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp cast
You can also connect to any signals or call functions defined in the
component using QMetaObject::invokeMethod() and QObject::connect(). See \l
@@ -141,14 +141,14 @@ specified in QML files, plugins, or applications.
the QObject::objectName property with QObject::findChild(). For example, if
the root item in \c MyItem.qml had a child \l Rectangle item:
- \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start
+ \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start
\codeline
- \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml child
- \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end
+ \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml child
+ \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end
The child could be located like this:
- \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp findChild
+ \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp findChild
If \c objectName is used inside a delegate of a ListView, \l Repeater or
some other element that creates multiple instances of its delegates, there
@@ -172,20 +172,20 @@ specified in QML files, plugins, or applications.
\section2 Embedding C++ Objects into QML Components
When loading a QML scene into a C++ application, it can be useful to
- directly embed C++ data into the QML object. QDeclarativeContext enables
+ directly embed C++ data into the QML object. QQmlContext enables
this by exposing data to the context of a QML component, allowing data to be
injected from C++ into QML.
For example, here is a QML item that refers to a \c currentDateTime value
that does not exist in the current scope:
- \snippet doc/src/snippets/declarative/qtbinding/context/MyItem.qml 0
+ \snippet doc/src/snippets/qml/qtbinding/context/MyItem.qml 0
This \c currentDateTime value can be set directly by the C++ application
that loads the QML component, using
- QDeclarativeContext::setContextProperty():
+ QQmlContext::setContextProperty():
- \snippet doc/src/snippets/declarative/qtbinding/context/main.cpp 0
+ \snippet doc/src/snippets/qml/qtbinding/context/main.cpp 0
Context properties can hold either QVariant or QObject* values. This means
custom C++ objects can also be injected using this approach, and these
@@ -196,11 +196,11 @@ specified in QML files, plugins, or applications.
\table
\row
\o
- \snippet doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h 0
+ \snippet doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h 0
\codeline
- \snippet doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp 0
+ \snippet doc/src/snippets/qml/qtbinding/context-advanced/main.cpp 0
\o
- \snippet doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml 0
+ \snippet doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml 0
\endtable
(Note that date/time values returned from C++ to QML can be formatted through
@@ -212,7 +212,7 @@ specified in QML files, plugins, or applications.
connected to using an \c onDataChanged handler within a \l Connections
object:
- \snippet doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml 0
+ \snippet doc/src/snippets/qml/qtbinding/context-advanced/connections.qml 0
Context properties can be useful for using C++ based data models in a QML view. See the
\l {declarative/modelviews/stringlistmodel}{String ListModel},
@@ -221,7 +221,7 @@ specified in QML files, plugins, or applications.
respective examples on using QStringListModel, QObjectList-based models and QAbstractItemModel
in QML views.
- Also see the QDeclarativeContext documentation for more information.
+ Also see the QQmlContext documentation for more information.
\section1 Invoking QML Entities through the Engine
@@ -246,8 +246,8 @@ specified in QML files, plugins, or applications.
\table
\row
- \o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml 0
- \o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp 0
+ \o \snippet doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml 0
+ \o \snippet doc/src/snippets/qml/qtbinding/functions-qml/main.cpp 0
\endtable
Notice the Q_RETURN_ARG() and Q_ARG() arguments for
@@ -257,16 +257,16 @@ specified in QML files, plugins, or applications.
To call a C++ function from QML, the function must be either a Qt slot, or a
function marked with the Q_INVOKABLE macro, to be available to QML. In the
following example, the QML code invokes methods on the \c myObject object,
- which has been set using QDeclarativeContext::setContextProperty():
+ which has been set using QQmlContext::setContextProperty():
\table
\row
\o
- \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml 0
+ \snippet doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml 0
\o
- \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h 0
+ \snippet doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h 0
\codeline
- \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp 0
+ \snippet doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp 0
\endtable
QML supports the calling of overloaded C++ functions. If there are multiple
@@ -289,11 +289,11 @@ specified in QML files, plugins, or applications.
\table
\row
\o
- \snippet doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml 0
+ \snippet doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml 0
\o
- \snippet doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h 0
+ \snippet doc/src/snippets/qml/qtbinding/signals-qml/myclass.h 0
\codeline
- \snippet doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp 0
+ \snippet doc/src/snippets/qml/qtbinding/signals-qml/main.cpp 0
\endtable
To connect to Qt C++ signals from within QML, use a signal handler with the
@@ -308,12 +308,12 @@ specified in QML files, plugins, or applications.
\row
\o
- \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h start
+ \snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h start
\dots 4
- \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h end
+ \snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h end
\o
- \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml 0
+ \snippet doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml 0
\endtable
(Note that if a signal has been declared as the NOTIFY signal for a
@@ -326,13 +326,13 @@ specified in QML files, plugins, or applications.
If, however, the object with the signal is not created from within the QML
code, and the QML item only has a reference to the created object - for
example, if the object was set using
- QDeclarativeContext::setContextProperty() - then the \l Connections element
+ QQmlContext::setContextProperty() - then the \l Connections element
can be used instead to create the signal handler:
\table
\row
- \o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp connections
- \o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0
+ \o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp connections
+ \o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml 0
\endtable
C++ signals can use enum values as parameters provided that the enum is
@@ -346,14 +346,14 @@ specified in QML files, plugins, or applications.
Any properties declared in a QML object are automatically accessible from
C++. Given a QML item like this:
- \snippet doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml 0
+ \snippet doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml 0
The value of the \c someNumber property can be set and read using
- QDeclarativeProperty, or QObject::setProperty() and QObject::property():
+ QQmlProperty, or QObject::setProperty() and QObject::property():
- \snippet doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp 0
+ \snippet doc/src/snippets/qml/qtbinding/properties-qml/main.cpp 0
- You should always use QObject::setProperty(), QDeclarativeProperty or
+ You should always use QObject::setProperty(), QQmlProperty or
QMetaProperty::write() to change a QML property value, to ensure the QML
engine is made aware of the property change. For example, say you have a
custom element \c PushButton with a \c buttonText property that internally
@@ -362,7 +362,7 @@ specified in QML files, plugins, or applications.
\badcode
// BAD!
- QDeclarativeComponent component(engine, "MyButton.qml");
+ QQmlComponent component(engine, "MyButton.qml");
PushButton *button = qobject_cast<PushButton*>(component.create());
button->m_buttonText = "Click me";
\endcode
@@ -381,8 +381,8 @@ specified in QML files, plugins, or applications.
\table
\row
- \o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h 0
- \o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml 0
+ \o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h 0
+ \o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml 0
\endtable
Notice the \c backgroundColorChanged signal is declared as the NOTIFY signal
@@ -401,7 +401,7 @@ specified in QML files, plugins, or applications.
Additional Qt code is runnable in the engine as a QML plugin. The \l{QML
Plugins} article covers the creation and usage patterns of QML plugins. The
- QDeclarativeExtensionPlugin class is an abstract class for writing QML
+ QQmlExtensionPlugin class is an abstract class for writing QML
plugins. The \l {How to Create Qt Plugins} contains more information about
Qt's plugin system.
@@ -413,17 +413,17 @@ specified in QML files, plugins, or applications.
initializing some costly data structures until after all the properties have
been set.
- The QML engine defines an interface class called QDeclarativeParserStatus,
+ The QML engine defines an interface class called QQmlParserStatus,
which contains a number of virtual methods that are invoked at various
stages during component instantiation. To receive these notifications, an
- element implementation inherits QDeclarativeParserStatus and notifies the Qt
+ element implementation inherits QQmlParserStatus and notifies the Qt
meta system using the Q_INTERFACES() macro.
\code
- class Example : public QObject, public QDeclarativeParserStatus
+ class Example : public QObject, public QQmlParserStatus
{
Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
+ Q_INTERFACES(QQmlParserStatus)
public:
virtual void componentComplete()
{
diff --git a/doc/src/qml/qmlevents.qdoc b/doc/src/qml/qmlevents.qdoc
index f29b2f260b..1f2e7a9908 100644
--- a/doc/src/qml/qmlevents.qdoc
+++ b/doc/src/qml/qmlevents.qdoc
@@ -58,9 +58,9 @@ Attempting to declare two signals or methods with the same name in the same type
block generates an error. However, a new signal may reuse the name of an existing signal on the type. (This should be done with caution, as the existing signal may be hidden and become inaccessible.)
Here are various examples of signal declarations:
-\snippet doc/src/snippets/declarative/events.qml parent begin
-\snippet doc/src/snippets/declarative/events.qml signal declaration
-\snippet doc/src/snippets/declarative/events.qml parent end
+\snippet doc/src/snippets/qml/events.qml parent begin
+\snippet doc/src/snippets/qml/events.qml signal declaration
+\snippet doc/src/snippets/qml/events.qml parent end
If the signal has no parameters, the "\c{()}" brackets are optional. If
parameters are used, the parameter types must be declared, as for the \c string
@@ -69,17 +69,17 @@ and \c variant arguments of the \c perform signal.
Adding a signal to an item automatically adds a \i{signal handler} as well. The
signal hander is named \c on<SignalName>, with the first letter of the signal in
uppercase. The previous signals have the following signal handlers:
-\snippet doc/src/snippets/declarative/events.qml signal handler declaration
+\snippet doc/src/snippets/qml/events.qml signal handler declaration
Further, each QML properties have a \c{<property_name>Changed} signal and its
corresponding \c{on<property_name>Changed} signal handler. As a result, property
changes may notify other components for any changes.
-\snippet doc/src/snippets/declarative/events.qml automatic signals
+\snippet doc/src/snippets/qml/events.qml automatic signals
To emit a signal, invoke it as a method. The signal handler binding is similar
to a property binding and it is invoked when the signal is emitted. Use the
defined argument names to access the respective arguments.
-\snippet doc/src/snippets/declarative/events.qml signal emit
+\snippet doc/src/snippets/qml/events.qml signal emit
Note that the \c Component.onCompleted is an
\l{attached-signalhandlers}{attached signal handler}; it is invoked when the
\l Component initialization is complete.
@@ -93,7 +93,7 @@ automatically invoked whenever the signal is emitted. This mechanism enables a
signal to be received by a method instead of a
\l {Signal Handlers}{signal handler}.
-\snippet doc/src/snippets/declarative/events.qml connect method
+\snippet doc/src/snippets/qml/events.qml connect method
The \c {connect()} method is appropriate when connecting a JavaScript method to
a signal.
@@ -104,7 +104,7 @@ signals.
By connecting signals to other signals, the \c connect() method can form different
signal chains.
-\snippet doc/src/snippets/declarative/events.qml forward signal
+\snippet doc/src/snippets/qml/events.qml forward signal
Whenever the \l MouseArea \c clicked signal is emitted, the \c send
diff --git a/doc/src/qml/qmlintro.qdoc b/doc/src/qml/qmlintro.qdoc
index 03ee94d6d1..3290a27bc3 100644
--- a/doc/src/qml/qmlintro.qdoc
+++ b/doc/src/qml/qmlintro.qdoc
@@ -1197,7 +1197,7 @@ arrange a set of Rectangle items. The Repeater item creates a series of 24
rectangles for the Grid item to position in a 5 by 5 arrangement.
\clearfloat
-\snippet doc/src/snippets/declarative/repeaters/repeater-grid-index.qml document
+\snippet doc/src/snippets/qml/repeaters/repeater-grid-index.qml document
The number of items created by a Repeater is held by its \l{Repeater::}{count}
property. It is not possible to set this property to determine the number of
diff --git a/doc/src/qml/qmlplugins.qdoc b/doc/src/qml/qmlplugins.qdoc
index 9b6fe29c1e..e41bba2906 100644
--- a/doc/src/qml/qmlplugins.qdoc
+++ b/doc/src/qml/qmlplugins.qdoc
@@ -36,16 +36,16 @@
C++ code as plugins. Plugins are imported and labeled as modules and
its content are available as components.
- QDeclarativeExtensionPlugin is a plugin interface that makes it possible to
+ QQmlExtensionPlugin 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 1
- \o Subclass QDeclarativeExtensionPlugin
- \o Implement QDeclarativeExtensionPlugin's
- \l{QDeclarativeExtensionPlugin::}{registerTypes()} method
+ \o Subclass QQmlExtensionPlugin
+ \o Implement QQmlExtensionPlugin's
+ \l{QQmlExtensionPlugin::}{registerTypes()} method
\o Register types with qmlRegisterType()
\o Export the class using the Q_EXPORT_PLUGIN2() macro
\o Write a project file for the plugin
@@ -67,8 +67,8 @@
\dots
A plugin class, \c QExampleQMLPlugin, is a subclass of
- \l QDeclarativeExtensionPlugin and it implements the
- \l{QDeclarativeExtensionPlugin::}{registerTypes()} method.
+ \l QQmlExtensionPlugin and it implements the
+ \l{QQmlExtensionPlugin::}{registerTypes()} method.
In the registerTypes() method, the plugin class can
\l{register-c++-type}{register} the \c TimeModel class to the declarative
diff --git a/doc/src/qml/qmlruntime.qdoc b/doc/src/qml/qmlruntime.qdoc
index 5853c14844..a803fabd7a 100644
--- a/doc/src/qml/qmlruntime.qdoc
+++ b/doc/src/qml/qmlruntime.qdoc
@@ -35,8 +35,8 @@ Declarative UI engine along with the built-in QML elements and plugin modules,
and it also provides access to third-party QML elements and modules.
Applications that use QML need to invoke the QML runtime in order to
-execute QML documents. This can be done by creating a QDeclarativeView
-or a QDeclarativeEngine, as described below. In addition, the Declarative UI
+execute QML documents. This can be done by creating a QQuickView
+or a QQmlEngine, as described below. In addition, the Declarative UI
package includes the \QQV tool, which loads \c .qml files. This tool is
useful for developing and testing QML code without the need to write
a C++ application to load the QML runtime.
@@ -47,17 +47,17 @@ a C++ application to load the QML runtime.
To deploy an application that uses QML, the QML runtime must be invoked by
the application. This is done by writing a Qt C++ application that loads the
-QDeclarativeEngine by either:
+QQmlEngine by either:
\list
-\o Loading the QML file through a QDeclarativeView instance, or
-\o Creating a QDeclarativeEngine instance and loading QML files with QDeclarativeComponent
+\o Loading the QML file through a QQuickView instance, or
+\o Creating a QQmlEngine instance and loading QML files with QQmlComponent
\endlist
-\section2 Deploying with QDeclarativeView
+\section2 Deploying with QQuickView
-QDeclarativeView is a QWidget-based class that is able to load QML files.
+QQuickView is a QWidget-based class that is able to load QML files.
For example, if there is a QML file, \c application.qml, like this:
\qml
@@ -70,13 +70,13 @@ It can be loaded in a Qt application's \c main.cpp file like this:
\code
#include <QApplication>
- #include <QDeclarativeView>
+ #include <QQuickView>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QDeclarativeView view;
+ QQuickView view;
view.setSource(QUrl::fromLocalFile("application.qml"));
view.show();
@@ -97,27 +97,27 @@ the \c declarative module for the \c QT variable. For example:
\endcode
-\section2 Creating a QDeclarativeEngine directly
+\section2 Creating a QQmlEngine directly
If \c application.qml does not have any graphical components, or if it is
-preferred to avoid QDeclarativeView for other reasons, the QDeclarativeEngine
+preferred to avoid QQuickView for other reasons, the QQmlEngine
can be constructed directly instead. In this case, \c application.qml is
-loaded as a QDeclarativeComponent instance rather than placed into a view:
+loaded as a QQmlComponent instance rather than placed into a view:
\code
#include <QApplication>
- #include <QDeclarativeEngine>
- #include <QDeclarativeContext>
- #include <QDeclarativeComponent>
+ #include <QQmlEngine>
+ #include <QQmlContext>
+ #include <QQmlComponent>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QDeclarativeEngine engine;
- QDeclarativeContext *objectContext = new QDeclarativeContext(engine.rootContext());
+ QQmlEngine engine;
+ QQmlContext *objectContext = new QQmlContext(engine.rootContext());
- QDeclarativeComponent component(&engine, "application.qml");
+ QQmlComponent component(&engine, "application.qml");
QObject *object = component.create(objectContext);
// ... delete object and objectContext when necessary
@@ -127,7 +127,7 @@ loaded as a QDeclarativeComponent instance rather than placed into a view:
\endcode
See \l {Using QML Bindings in C++ Applications} for more information about using
-QDeclarativeEngine, QDeclarativeContext and QDeclarativeComponent, as well
+QQmlEngine, QQmlContext and QQmlComponent, as well
as details on including QML files through \l{The Qt Resource System}{Qt's Resource system}.
diff --git a/doc/src/qml/qmlsyntax.qdoc b/doc/src/qml/qmlsyntax.qdoc
index b2b7fc89bd..1cd6ad7f46 100644
--- a/doc/src/qml/qmlsyntax.qdoc
+++ b/doc/src/qml/qmlsyntax.qdoc
@@ -133,7 +133,7 @@ Commenting in QML is similar to JavaScript.
\o Multiline comments start with /* and finish with *\/
\endlist
-\snippet doc/src/snippets/declarative/comments.qml 0
+\snippet doc/src/snippets/qml/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
diff --git a/doc/src/qml/qmltypes.qdoc b/doc/src/qml/qmltypes.qdoc
index 964ff98a15..9555e54f7e 100644
--- a/doc/src/qml/qmltypes.qdoc
+++ b/doc/src/qml/qmltypes.qdoc
@@ -350,7 +350,7 @@ Q_PROPERTY(int size READ size CONSTANT)
Properties that are lists of objects or Qt interfaces are also declared with
the Q_PROPERTY() macro. However, list properties must have the type
- \l{QDeclarativeListProperty}{QDeclarativeListProperty<T>}.
+ \l{QQmlListProperty}{QQmlListProperty<T>}.
\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 2
@@ -361,7 +361,7 @@ Q_PROPERTY(int size READ size CONSTANT)
\l {Extending QML - Object and List Property Types Example} shows the
complete code used to create the \c BirthdayParty type. For more
- information, visit \l{QDeclarativeListProperty}{QDeclarativeListProperty<T>}
+ information, visit \l{QQmlListProperty}{QQmlListProperty<T>}
for creating list properties.
\section2 Sequence Types
@@ -756,8 +756,8 @@ itself, the QML engine sets up an association between the value source and
the property.
Property value sources are special types that derive from the
-QDeclarativePropertyValueSource base class. This base class contains a single method,
-QDeclarativePropertyValueSource::setTarget(), that the QML engine invokes when
+QQmlPropertyValueSource base class. This base class contains a single method,
+QQmlPropertyValueSource::setTarget(), that the QML engine invokes when
associating the property value source with a property. The relevant part of
the \c HappyBirthdaySong type declaration looks like this:
@@ -771,7 +771,7 @@ contain properties, signals and methods just like other types.
When a property value source object is assigned to a property, QML first tries
to assign it normally, as though it were a regular QML type. Only if this
-assignment fails does the engine call the \l {QDeclarativePropertyValueSource::}{setTarget()} method. This allows
+assignment fails does the engine call the \l {QQmlPropertyValueSource::}{setTarget()} method. This allows
the type to also be used in contexts other than just as a value source.
\l {Extending QML - Property Value Source Example} shows the complete code used
diff --git a/doc/src/qml/qmlviewer.qdoc b/doc/src/qml/qmlviewer.qdoc
index 6439e95f4e..9006a053fc 100644
--- a/doc/src/qml/qmlviewer.qdoc
+++ b/doc/src/qml/qmlviewer.qdoc
@@ -160,7 +160,7 @@ QtObject { property int time: 54321 }
\endqml
To replace this with real data, you can simply bind the real data object to
-the root context in C++ using QDeclarativeContext::setContextProperty(). This
+the root context in C++ using QQmlContext::setContextProperty(). This
is detailed in \l {Using QML Bindings in C++ Applications}.
\section1 Using the \c runtime object
diff --git a/doc/src/qml/qtbinding.qdoc b/doc/src/qml/qtbinding.qdoc
index 10581857dc..7410836e9c 100644
--- a/doc/src/qml/qtbinding.qdoc
+++ b/doc/src/qml/qtbinding.qdoc
@@ -43,12 +43,12 @@ You may want to mix QML and C++ for a number of reasons. For example:
\o To use functionality defined in a C++ source (for example, when using a C++ Qt-based data model, or
calling functions in a third-party C++ library)
\o To access functionality in the Qt Declarative module (for example, to dynamically generate
-images using QDeclarativeImageProvider)
+images using QQmlImageProvider)
\o To write your own QML elements (whether for your applications, or for distribution to others)
\endlist
To use the Qt Declarative module, you must include and link to the module appropriately, as shown on
-the \l {QtDeclarative}{module index page}. The \l {Qt Declarative UI Runtime} documentation
+the \l {QtQml}{module index page}. The \l {Qt Declarative UI Runtime} documentation
shows how to build a basic C++ application that uses this module.
@@ -59,32 +59,32 @@ embedding QML into C++ applications. There are several core classes in the Qt De
that provide the essential capabilities for doing this. These are:
\list
-\o QDeclarativeEngine: A QML engine provides the environment for executing QML code. Every
+\o QQmlEngine: A QML engine provides the environment for executing QML code. Every
application requires at least one engine instance.
-\o QDeclarativeComponent: A component encapsulates a \l{QML Documents}{QML document}.
-\o QDeclarativeContext: A context allows an application to expose data to the QML components
+\o QQmlComponent: A component encapsulates a \l{QML Documents}{QML document}.
+\o QQmlContext: A context allows an application to expose data to the QML components
created by an engine.
\endlist
-A QDeclarativeEngine allows the configuration of global settings that apply to all of its QML
+A QQmlEngine allows the configuration of global settings that apply to all of its QML
component instances: for example, the QNetworkAccessManager to be used for network communications,
and the file path to be used for persistent storage.
-QDeclarativeComponent is used to load QML documents. Each QDeclarativeComponent instance represents
+QQmlComponent is used to load QML documents. Each QQmlComponent instance represents
a single document. A component can be created from the URL or file path of a QML document, or the raw
QML code of the document. Component instances are instatiated through the
-QDeclarativeComponent::create() method, like this:
+QQmlComponent::create() method, like this:
\code
-QDeclarativeEngine engine;
-QDeclarativeComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml"));
+QQmlEngine engine;
+QQmlComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml"));
QObject *rectangleInstance = component.create();
// ...
delete rectangleInstance;
\endcode
-QML documents can also be loaded using QDeclarativeView. This class provides a convenient
+QML documents can also be loaded using QQuickView. This class provides a convenient
QWidget-based view for embedding QML components into QGraphicsView-based applications. (For other
methods of integrating QML into QWidget-based applications, see \l {Integrating QML Code with existing Qt
UI code}.)
@@ -108,41 +108,41 @@ these methods throughout your application as appropriate.
\section2 Loading QML Components from C++
-A QML document can be loaded with QDeclarativeComponent or QDeclarativeView. QDeclarativeComponent
-loads a QML component as a C++ object; QDeclarativeView also does this,
+A QML document can be loaded with QQmlComponent or QQuickView. QQmlComponent
+loads a QML component as a C++ object; QQuickView also does this,
but additionally loads the QML component directly into a QGraphicsView. It is convenient for loading
a displayable QML component into a QWidget-based application.
For example, suppose there is a \c MyItem.qml file that looks like this:
-\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start
-\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end
+\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start
+\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end
-This QML document can be loaded with QDeclarativeComponent or QDeclarativeView with the following
-C++ code. Using a QDeclarativeComponent requires calling QDeclarativeComponent::create() to create
-a new instance of the component, while a QDeclarativeView automatically creates an instance of the
-component, which is accessible via QDeclarativeView::rootObject():
+This QML document can be loaded with QQmlComponent or QQuickView with the following
+C++ code. Using a QQmlComponent requires calling QQmlComponent::create() to create
+a new instance of the component, while a QQuickView automatically creates an instance of the
+component, which is accessible via QQuickView::rootObject():
\table
\row
\o
-\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-a
+\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-a
\dots 0
-\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-b
+\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-b
\o
-\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeView
+\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQuickView
\endtable
This \c object is the instance of the \c MyItem.qml component that has been created. You can now
-modify the item's properties using QObject::setProperty() or QDeclarativeProperty:
+modify the item's properties using QObject::setProperty() or QQmlProperty:
-\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp properties
+\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp properties
Alternatively, you can cast the object to its actual type and call functions with compile-time
safety. In this case the base object of \c MyItem.qml is an \l Item, which is defined by the
-QDeclarativeItem class:
+QQuickItem class:
-\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp cast
+\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp cast
You can also connect to any signals or call functions defined in the component using
QMetaObject::invokeMethod() and QObject::connect(). See \l {Exchanging data between QML and C++}
@@ -154,14 +154,14 @@ QML components are essentially object trees with children that have siblings and
Child objects of QML components can be located using the QObject::objectName property with
QObject::findChild(). For example, if the root item in \c MyItem.qml had a child \l Rectangle item:
-\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start
+\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start
\codeline
-\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml child
-\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end
+\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml child
+\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end
The child could be located like this:
-\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp findChild
+\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp findChild
If \c objectName is used inside a delegate of a ListView, \l Repeater or some other
element that creates multiple instances of its delegates, there will be multiple children with
@@ -181,18 +181,18 @@ the QML user interface implementation and the composition of the QML object tree
\section2 Embedding C++ Objects into QML Components
When loading a QML scene into a C++ application, it can be useful to directly embed C++ data into
-the QML object. QDeclarativeContext enables this by exposing data to the context of a QML
+the QML object. QQmlContext enables this by exposing data to the context of a QML
component, allowing data to be injected from C++ into QML.
For example, here is a QML item that refers to a \c currentDateTime value that does not exist in
the current scope:
-\snippet doc/src/snippets/declarative/qtbinding/context/MyItem.qml 0
+\snippet doc/src/snippets/qml/qtbinding/context/MyItem.qml 0
This \c currentDateTime value can be set directly by the C++ application that loads the QML
-component, using QDeclarativeContext::setContextProperty():
+component, using QQmlContext::setContextProperty():
-\snippet doc/src/snippets/declarative/qtbinding/context/main.cpp 0
+\snippet doc/src/snippets/qml/qtbinding/context/main.cpp 0
Context properties can hold either QVariant or QObject* values. This means custom C++ objects can
also be injected using this approach, and these objects can be modified and read directly in QML.
@@ -202,11 +202,11 @@ invokes a method on the object instance:
\table
\row
\o
-\snippet doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h 0
+\snippet doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h 0
\codeline
-\snippet doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp 0
+\snippet doc/src/snippets/qml/qtbinding/context-advanced/main.cpp 0
\o
-\snippet doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml 0
+\snippet doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml 0
\endtable
(Note that date/time values returned from C++ to QML can be formatted through
@@ -217,7 +217,7 @@ If the QML item needs to receive signals from the context property, it can conne
dataChanged(), this signal can be connected to using an \c onDataChanged handler within
a \l Connections object:
-\snippet doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml 0
+\snippet doc/src/snippets/qml/qtbinding/context-advanced/connections.qml 0
Context properties can be useful for using C++ based data models in a QML view. See the
\l {declarative/modelviews/stringlistmodel}{String ListModel},
@@ -226,7 +226,7 @@ Context properties can be useful for using C++ based data models in a QML view.
respective examples on using QStringListModel, QObjectList-based models and QAbstractItemModel
in QML views.
-Also see the QDeclarativeContext documentation for more information.
+Also see the QQmlContext documentation for more information.
\section2 Defining New QML Elements
@@ -236,30 +236,30 @@ defined by C++ classes; in fact, many of the core \l {QML Elements} are implemen
C++ classes. When you create a QML object using one of these elements, you are simply creating an
instance of a QObject-based C++ class and setting its properties.
-To create a visual item that fits in with the Qt Quick elements, base your class off \l QDeclarativeItem instead of QObject directly.
-You can then implement your own painting and functionality like any other QGraphicsObject. Note that QGraphicsItem::ItemHasNoContents is set by default on QDeclarativeItem because
+To create a visual item that fits in with the Qt Quick elements, base your class off \l QQuickItem instead of QObject directly.
+You can then implement your own painting and functionality like any other QGraphicsObject. Note that QGraphicsItem::ItemHasNoContents is set by default on QQuickItem because
it does not paint anything; you will need to clear this if your item is supposed to paint anything (as opposed to being solely for input handling or logical grouping).
For example, here is an \c ImageViewer class with an \c image URL property:
-\snippet doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h 0
+\snippet doc/src/snippets/qml/qtbinding/newelements/imageviewer.h 0
-Aside from the fact that it inherits QDeclarativeItem, this is an ordinary class that could
+Aside from the fact that it inherits QQuickItem, this is an ordinary class that could
exist outside of QML. However, once it is registered with the QML engine using qmlRegisterType():
-\snippet doc/src/snippets/declarative/qtbinding/newelements/main.cpp register
+\snippet doc/src/snippets/qml/qtbinding/newelements/main.cpp register
-Then, any QML code loaded by your C++ application or \l{QDeclarativeExtensionPlugin}{plugin} can create and manipulate
+Then, any QML code loaded by your C++ application or \l{QQmlExtensionPlugin}{plugin} can create and manipulate
\c ImageViewer objects:
-\snippet doc/src/snippets/declarative/qtbinding/newelements/standalone.qml 0
+\snippet doc/src/snippets/qml/qtbinding/newelements/standalone.qml 0
-It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QDeclarativeItem.
+It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QQuickItem.
This is because the GraphicsView backend is intended to be an implementation detail for QML, so the QtQuick items can be moved to faster backends as they become available with no change from a QML perspective.
-To minimize any porting requirements for custom visual items, try to stick to the documented properties in QDeclarativeItem where possible. Properties QDeclarativeItem inherits but doesn't document are classed as implementation details; they are not officially supported and may disappear between releases.
+To minimize any porting requirements for custom visual items, try to stick to the documented properties in QQuickItem where possible. Properties QQuickItem inherits but doesn't document are classed as implementation details; they are not officially supported and may disappear between releases.
-Note that custom C++ types do not have to inherit from QDeclarativeItem; this is only necessary if it is
+Note that custom C++ types do not have to inherit from QQuickItem; this is only necessary if it is
a displayable item. If the item is not displayable, it can simply inherit from QObject.
For more information on defining new QML elements, see the \l {Tutorial: Writing QML extensions with C++}
@@ -286,8 +286,8 @@ QMetaObject::invokeMethod(). Here is a C++ application that uses this to call a
\table
\row
-\o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml 0
-\o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp 0
+\o \snippet doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml 0
+\o \snippet doc/src/snippets/qml/qtbinding/functions-qml/main.cpp 0
\endtable
Notice the Q_RETURN_ARG() and Q_ARG() arguments for QMetaObject::invokeMethod() must be specified as
@@ -295,16 +295,16 @@ QVariant types, as this is the generic data type used for QML functions and retu
To call a C++ function from QML, the function must be either a Qt slot, or a function marked with
the Q_INVOKABLE macro, to be available to QML. In the following example, the QML code invokes
-methods on the \c myObject object, which has been set using QDeclarativeContext::setContextProperty():
+methods on the \c myObject object, which has been set using QQmlContext::setContextProperty():
\table
\row
\o
-\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml 0
+\snippet doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml 0
\o
-\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h 0
+\snippet doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h 0
\codeline
-\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp 0
+\snippet doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp 0
\endtable
QML supports the calling of overloaded C++ functions. If there are multiple C++ functions with the
@@ -325,11 +325,11 @@ is emitted:
\table
\row
\o
-\snippet doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml 0
+\snippet doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml 0
\o
-\snippet doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h 0
+\snippet doc/src/snippets/qml/qtbinding/signals-qml/myclass.h 0
\codeline
-\snippet doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp 0
+\snippet doc/src/snippets/qml/qtbinding/signals-qml/main.cpp 0
\endtable
To connect to Qt C++ signals from within QML, use a signal handler with the \c on<SignalName> syntax.
@@ -342,12 +342,12 @@ C++ object are connected to through \c onImagedChanged and \c onLoadingError sig
\row
\o
-\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h start
+\snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h start
\dots 4
-\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h end
+\snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h end
\o
-\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml 0
+\snippet doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml 0
\endtable
(Note that if a signal has been declared as the NOTIFY signal for a property, QML allows it to be
@@ -357,13 +357,13 @@ received with an \c on<Property>Changed handler even if the signal's name does n
If, however, the object with the signal is not created from within the QML code, and the QML item only has a
reference to the created object - for example, if the object was set using
-QDeclarativeContext::setContextProperty() - then the \l Connections element can be used
+QQmlContext::setContextProperty() - then the \l Connections element can be used
instead to create the signal handler:
\table
\row
-\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp connections
-\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0
+\o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp connections
+\o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml 0
\endtable
C++ signals can use enum values as parameters provided that the enum is declared in the
@@ -376,14 +376,14 @@ See \l {Using enumerations of a custom type} below for details.
Any properties declared in a QML object are automatically accessible from C++. Given a QML item
like this:
-\snippet doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml 0
+\snippet doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml 0
-The value of the \c someNumber property can be set and read using QDeclarativeProperty, or
+The value of the \c someNumber property can be set and read using QQmlProperty, or
QObject::setProperty() and QObject::property():
-\snippet doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp 0
+\snippet doc/src/snippets/qml/qtbinding/properties-qml/main.cpp 0
-You should always use QObject::setProperty(), QDeclarativeProperty or QMetaProperty::write() to
+You should always use QObject::setProperty(), QQmlProperty or QMetaProperty::write() to
change a QML property value, to ensure the QML engine is made aware of the property change. For example,
say you have a custom element \c PushButton with a \c buttonText property that internally reflects
the value of a \c m_buttonText member variable. Modifying the member variable directly like this is
@@ -391,7 +391,7 @@ not a good idea:
\badcode
// BAD!
-QDeclarativeComponent component(engine, "MyButton.qml");
+QQmlComponent component(engine, "MyButton.qml");
PushButton *button = qobject_cast<PushButton*>(component.create());
button->m_buttonText = "Click me";
\endcode
@@ -410,8 +410,8 @@ property. This property can be written to and read from QML:
\table
\row
-\o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h 0
-\o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml 0
+\o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h 0
+\o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml 0
\endtable
Notice the \c backgroundColorChanged signal is declared as the NOTIFY signal for the
@@ -468,8 +468,8 @@ converted to JavaScript array and object values, repectively:
\o String format
\o Example
\row
-\o \snippet doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml 0
-\o \snippet doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp 0
+\o \snippet doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml 0
+\o \snippet doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp 0
\endtable
This produces output like:
@@ -492,13 +492,13 @@ side, and is automatically converted to a QVariantList or QVariantMap when it is
To use an enumeration from a custom C++ component, the enumeration must be declared with Q_ENUMS() to
register it with Qt's meta object system. For example, the following C++ type has a \c Status enum:
-\snippet doc/src/snippets/declarative/qtbinding/enums/imageviewer.h start
-\snippet doc/src/snippets/declarative/qtbinding/enums/imageviewer.h end
+\snippet doc/src/snippets/qml/qtbinding/enums/imageviewer.h start
+\snippet doc/src/snippets/qml/qtbinding/enums/imageviewer.h end
Providing the \c ImageViewer class has been registered using qmlRegisterType(), its \c Status enum can
now be used from QML:
-\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 0
+\snippet doc/src/snippets/qml/qtbinding/enums/standalone.qml 0
The C++ type must be registered with QML to use its enums. If your C++ type is not instantiable, it
can be registered using qmlRegisterUncreatableType(). To be accessible from QML, the names of enum values
@@ -525,7 +525,7 @@ function, the enum type must be registered using qRegisterMetaType().
For QML signals, enum values may be used as signal parameters using the \c int type:
-\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 1
+\snippet doc/src/snippets/qml/qtbinding/enums/standalone.qml 1
\section2 Automatic Type Conversion from Strings
@@ -594,11 +594,11 @@ a QColor-type property or to call a C++ function that requires a QColor paramete
\section1 Writing QML plugins
-The Qt Declarative module includes the QDeclarativeExtensionPlugin class, which is an abstract
+The Qt Declarative module includes the QQmlExtensionPlugin class, which is an abstract
class for writing QML plugins. This allows QML extension types to be dynamically loaded into
QML applications.
-See the QDeclarativeExtensionPlugin documentation and \l {How to Create Qt Plugins} for more
+See the QQmlExtensionPlugin documentation and \l {How to Create Qt Plugins} for more
details.
@@ -643,22 +643,22 @@ project
The \c main.qml and \c background.png files will be packaged as resource files. This is
done in the \c example.qrc resource collection file:
-\quotefile doc/src/snippets/declarative/qtbinding/resources/example.qrc
+\quotefile doc/src/snippets/qml/qtbinding/resources/example.qrc
Since \c background.png is a resource file, \c main.qml can refer to it using the relative
path specified in \c example.qrc:
-\snippet doc/src/snippets/declarative/qtbinding/resources/main.qml 0
+\snippet doc/src/snippets/qml/qtbinding/resources/main.qml 0
To allow QML to locate resource files correctly, the \c main.cpp loads the main QML
file, \c main.qml, as a resource file using the \c qrc scheme:
-\snippet doc/src/snippets/declarative/qtbinding/resources/main.cpp 0
+\snippet doc/src/snippets/qml/qtbinding/resources/main.cpp 0
Finally \c project.pro uses the RESOURCES variable to indicate that \c example.qrc should
be used to build the application resources:
-\quotefile doc/src/snippets/declarative/qtbinding/resources/resources.pro
+\quotefile doc/src/snippets/qml/qtbinding/resources/resources.pro
See \l {The Qt Resource System} for more information.
diff --git a/doc/src/qml/qtdeclarative.qdoc b/doc/src/qml/qtdeclarative.qdoc
index c4b59fb07b..9d14f7fc57 100644
--- a/doc/src/qml/qtdeclarative.qdoc
+++ b/doc/src/qml/qtdeclarative.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \module QtDeclarative
+ \module QtQml
\title Qt Declarative Module
\ingroup modules
@@ -37,7 +37,7 @@
following directive:
\code
- #include <QtDeclarative>
+ #include <QtQml>
\endcode
To link against the module, add this line to your \l qmake \c
@@ -54,16 +54,16 @@
/*!
\macro QML_DECLARE_TYPE()
- \relates QDeclarativeEngine
+ \relates QQmlEngine
- Equivalent to \c Q_DECLARE_METATYPE(TYPE *) and \c Q_DECLARE_METATYPE(QDeclarativeListProperty<TYPE>)
+ Equivalent to \c Q_DECLARE_METATYPE(TYPE *) and \c Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
- #include <QtDeclarative> to use this macro.
+ #include <QtQml> to use this macro.
*/
/*!
\macro QML_DECLARE_TYPEINFO(Type,Flags)
- \relates QDeclarativeEngine
+ \relates QQmlEngine
Declares additional properties of the given \a Type as described by the
specified \a Flags.
@@ -71,13 +71,13 @@
Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which
declares that the \a Type supports \l {Attached Properties}.
- #include <QtDeclarative> to use this macro.
+ #include <QtQml> to use this macro.
*/
/*!
\fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
- \relates QDeclarativeEngine
+ \relates QQmlEngine
This template function registers the C++ type in the QML system with
the name \a qmlName, in the library imported from \a uri having the
@@ -105,7 +105,7 @@
"com.mycompany.qmlcomponents":
\code
- #include <QtDeclarative>
+ #include <QtQml>
...
@@ -131,7 +131,7 @@
/*!
\fn int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
- \relates QDeclarativeEngine
+ \relates QQmlEngine
This template function registers the specified revision of a C++ type in the QML system with
the library imported from \a uri having the version number composed
@@ -150,7 +150,7 @@
/*!
\fn int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
- \relates QDeclarativeEngine
+ \relates QQmlEngine
This template function registers the C++ type in the QML system with
the name \a qmlName, in the library imported from \a uri having the
@@ -163,14 +163,14 @@
Returns the QML type id.
- #include <QtDeclarative> to use this function.
+ #include <QtQml> to use this function.
\sa qmlRegisterTypeNotAvailable()
*/
/*!
\fn int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
- \relates QDeclarativeEngine
+ \relates QQmlEngine
This function registers a type in the QML system with the name \a qmlName, in the library imported from \a uri having the
version number composed from \a versionMajor and \a versionMinor, but any attempt to instantiate the type
@@ -200,40 +200,40 @@
Without this, a generic "Game is not a type" message would be given.
- #include <QtDeclarative> to use this function.
+ #include <QtQml> to use this function.
\sa qmlRegisterUncreatableType()
*/
/*!
\fn int qmlRegisterType()
- \relates QDeclarativeEngine
+ \relates QQmlEngine
\overload
This template function registers the C++ type in the QML
system. Instances of this type cannot be created from the QML
system.
- #include <QtDeclarative> to use this function.
+ #include <QtQml> to use this function.
Returns the QML type id.
*/
/*!
\fn int qmlRegisterInterface(const char *typeName)
- \relates QDeclarativeEngine
+ \relates QQmlEngine
This template function registers the C++ type in the QML system
under the name \a typeName.
- #include <QtDeclarative> to use this function.
+ #include <QtQml> to use this function.
Returns the QML type id.
*/
/*!
- \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QJSValue (*callback)(QDeclarativeEngine *, QJSEngine *))
- \relates QDeclarativeEngine
+ \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QJSValue (*callback)(QQmlEngine *, QJSEngine *))
+ \relates QQmlEngine
This function may be used to register a module API provider \a callback in a particular \a uri
with a version specified in \a versionMajor and \a versionMinor.
@@ -250,7 +250,7 @@
Usage:
\code
// first, define the module API provider function (callback).
- static QJSValue *example_qjsvalue_module_api_provider(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
+ static QJSValue *example_qjsvalue_module_api_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
@@ -278,8 +278,8 @@
*/
/*!
- \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QObject *(*callback)(QDeclarativeEngine *, QJSEngine *))
- \relates QDeclarativeEngine
+ \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QObject *(*callback)(QQmlEngine *, QJSEngine *))
+ \relates QQmlEngine
This function may be used to register a module API provider \a callback in a particular \a uri
with a version specified in \a versionMajor and \a versionMinor.
@@ -325,7 +325,7 @@
};
// second, define the module API provider function (callback).
- static QObject *example_qobject_module_api_provider(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
+ static QObject *example_qobject_module_api_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
diff --git a/doc/src/qml/qtprogrammers.qdoc b/doc/src/qml/qtprogrammers.qdoc
index 215f71859c..9338a2c29f 100644
--- a/doc/src/qml/qtprogrammers.qdoc
+++ b/doc/src/qml/qtprogrammers.qdoc
@@ -44,7 +44,7 @@ QML provides direct access to the following concepts from Qt:
\o QAction - the \l {QML Basic Types}{action} type
\o QObject signals and slots - available as functions to call in JavaScript
\o QObject properties - available as variables in JavaScript
- \o QWidget - QDeclarativeView is a QML-displaying widget
+ \o QWidget - QQuickView is a QML-displaying widget
\o Qt models - used directly in data binding (QAbstractItemModel)
\endlist
@@ -71,12 +71,12 @@ QML Items also serve these purposes. Each is considered separately below.
\section2 Simple Widgets
-The most important rule to remember while implementing a new QDeclarativeItem in C++
+The most important rule to remember while implementing a new QQuickItem in C++
is that it should not contain any look and feel policies; leave that to the QML
usage of the item.
As an example, imagine you wanted a reusable Button item. If you therefore decided
-to write a QDeclarativeItem subclass to implement a button, just as QToolButton
+to write a QQuickItem subclass to implement a button, just as QToolButton
subclasses QWidget for this purpose, following the rule above, your
\c QDeclarativeButton would not have any appearance; just the notions of enabled,
triggering, etc.
@@ -92,7 +92,7 @@ between states, and exactly how it responds to mouse, key, or touch input, shoul
all be left for definition in QML.
It is illustrative to note that QDeclarativeTextEdit is built upon QTextControl,
-QDeclarativeWebView is built upon QWebPage, and ListView uses QAbstractItemModel,
+QQuickWebView is built upon QWebPage, and ListView uses QAbstractItemModel,
just as QTextEdit, QWebView, and QListView are built upon those same UI-agnostic
components.
@@ -167,7 +167,7 @@ QGraphicsWidgets are usually designed to be laid out with QGraphicsLayouts. QML
not use QGraphicsLayouts, as the Qt layouts do not mix well with animated and fluid
UIs, so the geometry interface is one of the main differences. When writing QML
elements, you allow the designers to place their bounding rectangle using absolute
-geometry, bindings or anchors (all set up for you when you inherit QDeclarativeItem)
+geometry, bindings or anchors (all set up for you when you inherit QQuickItem)
and you do not use layouts or size hints. If size hints are appropriate, then place
them in the QML documentation so that the designers know how to use the item best,
but still have complete control over the look and feel.
@@ -182,14 +182,14 @@ look and feel (which involves the UI logic) can be written in QML.
Both differences are caused by the different method of interaction. QGraphicsWidget
is a QGraphicsObject subclass which makes fluid UI development from C++ easier, and
-QDeclarativeItem is a QGraphicsObject subclass which makes fluid UI development
+QQuickItem is a QGraphicsObject subclass which makes fluid UI development
from QML easier. The difference, therefore, is primarily one of the interface
exposed, and the design of the items that come with it; the declarative primitives
for QML and nothing for QGraphicsWidget, because you need to write your own UI
logic into the subclass.
If you wish to use both QML and C++ to write the UI, for example to ease the
-transition period, it is recommended to use QDeclarativeItem subclasses, although
+transition period, it is recommended to use QQuickItem subclasses, although
you can use QGraphicsWidgets as well. To allow for easier use from C++, make the
root item of each C++ component a \l LayoutItem, and load individual "widgets" of
QML (possibly comprised of multiple files, and containing a self-contained bundle
diff --git a/doc/src/qtquick2/animation.qdoc b/doc/src/qtquick2/animation.qdoc
index 626571f50e..cf656fb209 100644
--- a/doc/src/qtquick2/animation.qdoc
+++ b/doc/src/qtquick2/animation.qdoc
@@ -76,14 +76,14 @@ There are several ways of setting animation to an object.
To create an immediate movement or animated movement, set the property value
directly. This may be done in signal handlers or attached properties.
-\snippet doc/src/snippets/declarative/animation.qml direct property change
+\snippet doc/src/snippets/qml/animation.qml direct property change
However, to create more control, \i {property animations} apply smooth movements
by interpolating values between property value changes. Property animations
provide timing controls and allows different interpolations through
\l{qml-easing-animation}{easing curves}.
-\snippet doc/src/snippets/declarative/animation.qml property animation
+\snippet doc/src/snippets/qml/animation.qml property animation
Specialized \l{qml-property-animation-elements}{property animation elements}
have more efficient implementations than the \l{PropertyAnimation} element. They
@@ -112,14 +112,14 @@ change from the \c pressed state to the \c released state. Likewise, there would
be an animation during the change from the \c released state to the \c pressed
state.
-\snippet doc/src/snippets/declarative/animation.qml transition animation
+\snippet doc/src/snippets/qml/animation.qml transition animation
Binding the \c to and \c from properties to the state's name will assign that
particular transition to the state change. For simple or symmetric transitions,
setting the to \c to property to the wild card symbol, "\c{*}", denotes
that the transition applies to any state change.
-\snippet doc/src/snippets/declarative/animation.qml wildcard animation
+\snippet doc/src/snippets/qml/animation.qml wildcard animation
\section2 Default Animation as Behaviors
@@ -133,7 +133,7 @@ A ball component might have a behavior animation assigned to its \c x, \c y, and
elastic effect. In effect, this behavior animation would apply the elastic
effect to the properties whenever the ball moves.
-\snippet doc/src/snippets/declarative/animation.qml behavior animation
+\snippet doc/src/snippets/qml/animation.qml behavior animation
There are several methods of assigning behavior animations to properties. The
\c{Behavior on <property>} declaration is a convenient way of assigning a
@@ -156,7 +156,7 @@ object. Using the \l{SequentialAnimation} element, the opacity animations will
play after the preceding animation finishes. The \l{ParallelAnimation} element
will play the animations at the same time.
-\snippet doc/src/snippets/declarative/animation.qml sequential animation
+\snippet doc/src/snippets/qml/animation.qml sequential animation
Once individual animations are placed into a SequentialAnimation or
ParallelAnimation, they can no longer be started and stopped independently. The
@@ -257,15 +257,15 @@ Rectangle {
-\snippet doc/src/snippets/declarative/animation-elements.qml color
-\snippet doc/src/snippets/declarative/animation-propertyvaluesource.qml 0
-\snippet doc/src/snippets/declarative/animation-signalhandler.qml 0
-\snippet doc/src/snippets/declarative/animation-standalone.qml 0
+\snippet doc/src/snippets/qml/animation-elements.qml color
+\snippet doc/src/snippets/qml/animation-propertyvaluesource.qml 0
+\snippet doc/src/snippets/qml/animation-signalhandler.qml 0
+\snippet doc/src/snippets/qml/animation-standalone.qml 0
-\snippet doc/src/snippets/declarative/animation-transitions.qml 0
-\snippet doc/src/snippets/declarative/animation-groups.qml 0
+\snippet doc/src/snippets/qml/animation-transitions.qml 0
+\snippet doc/src/snippets/qml/animation-groups.qml 0
-\snippet doc/src/snippets/declarative/animation-groups.qml 1
-\snippet doc/src/snippets/declarative/animation-groups.qml 0
+\snippet doc/src/snippets/qml/animation-groups.qml 1
+\snippet doc/src/snippets/qml/animation-groups.qml 0
\image propanim.gif
diff --git a/doc/src/qtquick2/focus.qdoc b/doc/src/qtquick2/focus.qdoc
index 05d797e7be..e2c4c79d3c 100644
--- a/doc/src/qtquick2/focus.qdoc
+++ b/doc/src/qtquick2/focus.qdoc
@@ -43,7 +43,7 @@ and to address some of the cases unique to fluid user interfaces, the QML items
When the user presses or releases a key, the following occurs:
\list 1
\o Qt receives the key action and generates a key event.
-\o If the Qt widget containing the \l QDeclarativeView has focus, the key event
+\o If the Qt widget containing the \l QQuickView has focus, the key event
is delivered to it. Otherwise, regular Qt key handling continues.
\o The key event is delivered by the scene to the QML \l Item with
\i {active focus}. If no Item has active focus, the key event is
@@ -56,8 +56,8 @@ If the \c {Rectangle} element in the following example has active focus and the
it will bubble up to its parent. However, pressing the \c B key will bubble up to the root
item and thus subsequently be ignored.
-\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event
-\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event end
+\snippet doc/src/snippets/qml/focus/rectangle.qml simple key event
+\snippet doc/src/snippets/qml/focus/rectangle.qml simple key event end
\o If the root \l Item is reached, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues.
@@ -71,7 +71,7 @@ Whether or not an \l Item has active focus can be queried through the
property \c {Item::activeFocus} property. For example, here we have a \l Text
element whose text is determined by whether or not it has active focus.
-\snippet doc/src/snippets/declarative/focus/rectangle.qml active focus
+\snippet doc/src/snippets/qml/focus/rectangle.qml active focus
\section1 Acquiring Focus and Focus Scopes
@@ -82,7 +82,7 @@ sufficient. If we run the following example with the \l {QML Viewer}, we see tha
the \c {keyHandler} element has active focus and pressing the \c A, \c B,
or \c C keys modifies the text appropriately.
-\snippet doc/src/snippets/declarative/focus/basicwidget.qml focus true
+\snippet doc/src/snippets/qml/focus/basicwidget.qml focus true
\image declarative-qmlfocus1.png
@@ -95,10 +95,10 @@ set the first one to have focus. The intention is that when the \c A, \c B, or
responds accordingly.
The code that imports and creates two MyWidget instances:
-\snippet doc/src/snippets/declarative/focus/widget.qml window
+\snippet doc/src/snippets/qml/focus/widget.qml window
The MyWidget code:
-\snippet doc/src/snippets/declarative/focus/MyWidget.qml mywidget
+\snippet doc/src/snippets/qml/focus/MyWidget.qml mywidget
We would like to have the first MyWidget object to have the focus by setting its
\c focus property to \c true. However, by running the code, we can confirm that
@@ -126,7 +126,7 @@ A focus scope is created by declaring the \l FocusScope element.
In the next example, a \l FocusScope element is added to the component, and the
visual result shown.
-\snippet doc/src/snippets/declarative/focus/myfocusscopewidget.qml widget in focusscope
+\snippet doc/src/snippets/qml/focus/myfocusscopewidget.qml widget in focusscope
\image declarative-qmlfocus3.png
@@ -158,10 +158,10 @@ Now, clicking either MyClickableWidget gives it focus and the other widget
loses the focus.
The code that imports and creates two MyClickableWidget instances:
-\snippet doc/src/snippets/declarative/focus/clickablewidget.qml clickable window
+\snippet doc/src/snippets/qml/focus/clickablewidget.qml clickable window
The MyClickableWidget code:
-\snippet doc/src/snippets/declarative/focus/MyClickableWidget.qml clickable in focusscope
+\snippet doc/src/snippets/qml/focus/MyClickableWidget.qml clickable in focusscope
\image declarative-qmlfocus4.png
@@ -188,7 +188,7 @@ current item delegate to react to key presses.
This contrived example shows how this works. Pressing the \c Return key will
print the name of the current list item.
-\snippet doc/src/snippets/declarative/focus/advancedFocus.qml FocusScope delegate
+\snippet doc/src/snippets/qml/focus/advancedFocus.qml FocusScope delegate
\image declarative-qmlfocus5.png
diff --git a/doc/src/qtquick2/modelview.qdoc b/doc/src/qtquick2/modelview.qdoc
index 56c726eab8..5d799027ad 100644
--- a/doc/src/qtquick2/modelview.qdoc
+++ b/doc/src/qtquick2/modelview.qdoc
@@ -80,13 +80,13 @@ To visualize data, bind the view's \c model property to a model and the
Suppose that a specific club wants to decorate its members list with its brand
colors. A member list is in a \c model and the \c delegate will display the
model's content.
- \snippet doc/src/snippets/declarative/listview-decorations.qml model
- \snippet doc/src/snippets/declarative/listview-decorations.qml delegate
+ \snippet doc/src/snippets/qml/listview-decorations.qml model
+ \snippet doc/src/snippets/qml/listview-decorations.qml delegate
The club may decorate the members list by binding visual objects to the \c
header and \c footer properties. The visual object may be defined inline, in
another file, or in a \l {Component} element.
- \snippet doc/src/snippets/declarative/listview-decorations.qml decorations
+ \snippet doc/src/snippets/qml/listview-decorations.qml decorations
\image listview-decorations.png
\section2 Mouse and Touch Handling
@@ -110,8 +110,8 @@ To visualize data, bind the view's \c model property to a model and the
A list may contain a list indicating people's names and the team on which
team the person belongs.
- \snippet doc/src/snippets/declarative/listview-sections.qml model
- \snippet doc/src/snippets/declarative/listview-sections.qml delegate
+ \snippet doc/src/snippets/qml/listview-sections.qml model
+ \snippet doc/src/snippets/qml/listview-sections.qml delegate
The ListView element has the \c section \l{Property Binding in QML#Attached
Properties}{attached property} that can combine adjacent and related
@@ -119,7 +119,7 @@ To visualize data, bind the view's \c model property to a model and the
which list element property to use as sections. The \c criteria can dictate
how the section names are displayed and the \c delegate is similar to the
views' \l {qml-view-delegate}{delegate} property.
- \snippet doc/src/snippets/declarative/listview-sections.qml section
+ \snippet doc/src/snippets/qml/listview-sections.qml section
\image listview-section.png
\keyword qml-view-delegate
@@ -129,7 +129,7 @@ To visualize data, bind the view's \c model property to a model and the
visualize each item list according to the template defined by the delegate.
Items in a model are accessible through the \c index property as well as the
item's properties.
- \snippet doc/src/snippets/declarative/listview.qml delegate
+ \snippet doc/src/snippets/qml/listview.qml delegate
\image listview-setup.png
\section2 Accessing Views and Models from Delegates
@@ -150,7 +150,7 @@ To visualize data, bind the view's \c model property to a model and the
the model, and the color of one of the fields depends on the property
\i{fruit_color} of the view.
- \snippet doc/src/snippets/declarative/models/views-models-delegates.qml rectangle
+ \snippet doc/src/snippets/qml/models/views-models-delegates.qml rectangle
\keyword qml-data-models
\section1 Models
@@ -159,7 +159,7 @@ To visualize data, bind the view's \c model property to a model and the
bind to. Here is a ListModel with two roles, \i type and \i age, and a
ListView with a delegate that binds to these roles to display their values:
- \snippet doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml document
+ \snippet doc/src/snippets/qml/qml-data-models/listmodel-listview.qml document
If there is a naming clash between the model's properties and the delegate's
properties, the roles can be accessed with the qualified \i model name
@@ -197,12 +197,12 @@ To visualize data, bind the view's \c model property to a model and the
ListModel is a simple hierarchy of elements specified in QML. The
available roles are specified by the \l ListElement properties.
- \snippet doc/src/snippets/declarative/qml-data-models/listelements.qml model
+ \snippet doc/src/snippets/qml/qml-data-models/listelements.qml model
The above model has two roles, \i name and \i cost. These can be bound
to by a ListView delegate, for example:
- \snippet doc/src/snippets/declarative/qml-data-models/listelements.qml view
+ \snippet doc/src/snippets/qml/qml-data-models/listelements.qml view
ListModel provides methods to manipulate the ListModel directly via JavaScript.
In this case, the first item inserted determines the roles available
@@ -210,9 +210,9 @@ To visualize data, bind the view's \c model property to a model and the
created and populated via JavaScript, the roles provided by the first
insertion are the only roles that will be shown in the view:
- \snippet doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml model
+ \snippet doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml model
\dots
- \snippet doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml mouse area
+ \snippet doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml mouse area
When the MouseArea is clicked, \c fruitModel will have two roles, \i cost and \i name.
Even if subsequent roles are added, only the first two will be handled by views
@@ -253,7 +253,7 @@ To visualize data, bind the view's \c model property to a model and the
VisualItemModel provide the contents of the delegate. The model
does not provide any roles.
- \snippet doc/src/snippets/declarative/models/visual-model-and-view.qml visual model and view
+ \snippet doc/src/snippets/qml/models/visual-model-and-view.qml visual model and view
Note that in the above example there is no delegate required.
The items of the model itself provide the visual elements that
@@ -347,7 +347,7 @@ The following example shows a repeater used with a \l{#Grid}{Grid} item to
arrange a set of Rectangle items. The Repeater item creates a series of 24
rectangles for the Grid item to position in a 5 by 5 arrangement.
-\snippet doc/src/snippets/declarative/repeaters/repeater-grid-index.qml document
+\snippet doc/src/snippets/qml/repeaters/repeater-grid-index.qml document
The number of items created by a Repeater is held by its \l{Repeater::}{count}
property. It is not possible to set this property to determine the number of
diff --git a/doc/src/qtquick2/mouseevents.qdoc b/doc/src/qtquick2/mouseevents.qdoc
index d981c7c1dd..e452611416 100644
--- a/doc/src/qtquick2/mouseevents.qdoc
+++ b/doc/src/qtquick2/mouseevents.qdoc
@@ -55,7 +55,7 @@ to define this area is to anchor the \c MouseArea to its parent's area using the
component), then the MouseArea will fill the area defined by the parent's
dimensions. Alternatively, an area smaller or larger than the parent is
definable.
-\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml anchor fill
+\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml anchor fill
\section1 Receiving Events
@@ -77,7 +77,7 @@ gestures in greater detail:
\endlist
These signals have signal handlers that are invoked when the signals are emitted.
-\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml mouse handlers
+\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml mouse handlers
\section1 Enabling Gestures
Some mouse gestures and button clicks need to be enabled before they send or
@@ -95,7 +95,7 @@ positioning even when there are no mouse button presses. Setting the
\c hoverEnabled property to \c true, in turn will enable the \c entered,
\c exited, and \c positionChanged signal and their respective signal handlers.
-\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml enable handlers
+\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml enable handlers
Additionally, to disable the whole mouse area, set the \c MouseArea
element's \c enabled property to \c false.
diff --git a/doc/src/qtquick2/positioners.qdoc b/doc/src/qtquick2/positioners.qdoc
index c7110f7cf9..55be7087fd 100644
--- a/doc/src/qtquick2/positioners.qdoc
+++ b/doc/src/qtquick2/positioners.qdoc
@@ -61,7 +61,7 @@ uses a Column item to arrange three \l Rectangle items in an area defined
by an outer \l Item. The \l{Column::spacing}{spacing} property is set to
include a small amount of space between the rectangles.
-\snippet doc/src/snippets/declarative/column/column.qml document
+\snippet doc/src/snippets/qml/column/column.qml document
Note that, since Column inherits directly from Item, any background color
must be added to a parent Rectangle, if desired.
@@ -80,7 +80,7 @@ include a small amount of space between the rectangles.
We ensure that the parent Rectangle is large enough so that there is some space
left around the edges of the horizontally centered Row item.
-\snippet doc/src/snippets/declarative/row.qml document
+\snippet doc/src/snippets/qml/row.qml document
\section2 Grid
@@ -93,7 +93,7 @@ The following example uses a Grid item to place four \l Rectangle items
in a 2-by-2 grid. As with the other positioners, the spacing between items
can be specified using the \l{Grid::spacing}{spacing} property.
-\snippet doc/src/snippets/declarative/grid-spacing.qml document
+\snippet doc/src/snippets/qml/grid-spacing.qml document
There is no difference between horizontal and vertical spacing inserted
between items, so any additional space must be added within the items
@@ -122,7 +122,7 @@ The following example shows a Flow item containing a number of \l Text
child items. These are arranged in a similar way to those shown in the
screenshots.
-\snippet doc/src/snippets/declarative/flow.qml document
+\snippet doc/src/snippets/qml/flow.qml document
The main differences between the Grid and Flow positioners are that items
inside a Flow will wrap when they run out of space on the minor axis, and
diff --git a/doc/src/qtquick2/qmltexthandling.qdoc b/doc/src/qtquick2/qmltexthandling.qdoc
index 876ab3c42f..6e6b2a4c6b 100644
--- a/doc/src/qtquick2/qmltexthandling.qdoc
+++ b/doc/src/qtquick2/qmltexthandling.qdoc
@@ -62,10 +62,10 @@ respective element documentation.
The \l {Validators}{validator} elements enforce the type and format of
\l TextInput objects.
-\snippet doc/src/snippets/declarative/texthandling.qml int validator
+\snippet doc/src/snippets/qml/texthandling.qml int validator
The validator elements bind to \c {TextInput}'s \c validator property.
-\snippet doc/src/snippets/declarative/texthandling.qml regexp validator
+\snippet doc/src/snippets/qml/texthandling.qml regexp validator
The regular expression in the snippet will only allow the inputted text to be
\c {fruit basket}.
diff --git a/doc/src/qtquick2/qtquick-intro.qdoc b/doc/src/qtquick2/qtquick-intro.qdoc
index 8aeab7e199..9eebb0bddc 100644
--- a/doc/src/qtquick2/qtquick-intro.qdoc
+++ b/doc/src/qtquick2/qtquick-intro.qdoc
@@ -34,7 +34,7 @@ create the kind of intuitive, modern, and fluid user interfaces that are
increasingly used on mobile phones, media players, set-top boxes, and other
portable devices. Qt Quick consists of a rich set of user interface
\l{QML Elements}{elements}, a \l{QML Syntax}{declarative} language for
-describing user interfaces, and a language \l{QtDeclarative Module}{runtime}. A
+describing user interfaces, and a language \l{QtQml Module}{runtime}. A
collection of C++ APIs is used to integrate these high level features with
classic Qt applications. Version 2.1 of the Qt Creator integrated development
environment (IDE) introduces tools for developing Qt Quick applications.
@@ -74,16 +74,16 @@ used to implement high level user interface logic.
\l{How to Learn QML} introduces the reader to the language and declarative
concepts.
-\section1 QtDeclarative Module
+\section1 QtQml Module
-To make Qt Quick possible, Qt introduces the \l{QtDeclarative} module. The
+To make Qt Quick possible, Qt introduces the \l{QtQml} module. The
module creates a JavaScript runtime that QML runs under with a Qt based backend.
-Because QtDeclarative and QML are built upon Qt, they inherit many of Qt's
+Because QtQml and QML are built upon Qt, they inherit many of Qt's
technology, namely the \l{Signals and Slots}{signals and slots} mechanism and
the \l{The Meta-Object System}{meta-object} system. Data created using C++ are
directly accessible from QML, and QML objects are also accessible from C++ code.
-The QtDeclarative module separates the interface logic in QML from the
+The QtQml module separates the interface logic in QML from the
application logic in C++. It also allows the range of standard QML elements
to be \l{Extending QML with C++}{extended with new ones written in C++}.
diff --git a/doc/src/qtquick2/qtquick2.qdoc b/doc/src/qtquick2/qtquick2.qdoc
index 6a1b7999c9..20361adb16 100644
--- a/doc/src/qtquick2/qtquick2.qdoc
+++ b/doc/src/qtquick2/qtquick2.qdoc
@@ -32,7 +32,7 @@
\brief The QML Elements
This QML module contains all the QML elements that are
- instantiated as objects of C++ classes in the QtDeclarative
+ instantiated as objects of C++ classes in the QtQml
module. These elements work with the Scenegraph renderer and
their own canvas.
*/
diff --git a/doc/src/qtquick2/righttoleft.qdoc b/doc/src/qtquick2/righttoleft.qdoc
index b2cff57ee0..1781e3582a 100644
--- a/doc/src/qtquick2/righttoleft.qdoc
+++ b/doc/src/qtquick2/righttoleft.qdoc
@@ -68,7 +68,7 @@ Note that when \l LayoutMirroring is set, the \c horizontalAlignment property va
the effective alignment of the text element that takes the mirroring into account can be read from the
\c effectiveHorizontalAlignment property.
-\snippet doc/src/snippets/declarative/righttoleft.qml 0
+\snippet doc/src/snippets/qml/righttoleft.qml 0
\section1 Layout direction of positioners and views
@@ -84,7 +84,7 @@ This causes the effective \c layoutDirection of positioners and views to be mirr
of the \c layoutDirection property will remain unchanged; the effective layout direction of positioners and
views that takes the mirroring into account can be read from the \c effectiveLayoutDirection property.
-\snippet doc/src/snippets/declarative/righttoleft.qml 1
+\snippet doc/src/snippets/qml/righttoleft.qml 1
\section1 Layout mirroring
@@ -95,11 +95,11 @@ support for existing left-to-right Qt Quick applications. It mirrors the behavio
You can enable layout mirroring for a particular \l Item:
-\snippet doc/src/snippets/declarative/righttoleft.qml 2
+\snippet doc/src/snippets/qml/righttoleft.qml 2
Or set all child elements to also inherit the layout direction:
-\snippet doc/src/snippets/declarative/righttoleft.qml 3
+\snippet doc/src/snippets/qml/righttoleft.qml 3
Applying mirroring in this manner does not change the actual value of the relevant anchor,
\c layoutDirection or \c horizontalAlignment properties. The separate read-only property
@@ -116,7 +116,7 @@ especially in views that rely on both the anchors and x coordinate-based positio
the \l LayoutMirroring attached property to apply mirroring to an item that is positioned using \l {Item::}{x}
coordinates:
-\snippet doc/src/snippets/declarative/righttoleft.qml 4
+\snippet doc/src/snippets/qml/righttoleft.qml 4
Not all layouts should necessarily be mirrored. There are cases where a visual element is positioned to
the right side of the screen for improved one-handed use, because most people are right-handed, and not
@@ -135,7 +135,7 @@ aligned and just make sure that text is translated and aligned properly.
Most images do not need to be mirrored, but some directional icons, such as arrows, may need to be mirrored.
The painting of these icons can be mirrored with a dedicated \c mirror property introduced in Qt Quick 1.1:
-\snippet doc/src/snippets/declarative/righttoleft.qml 5
+\snippet doc/src/snippets/qml/righttoleft.qml 5
\section1 Default layout direction
diff --git a/doc/src/qtquick2/states.qdoc b/doc/src/qtquick2/states.qdoc
index 559b4facac..622a1619b0 100644
--- a/doc/src/qtquick2/states.qdoc
+++ b/doc/src/qtquick2/states.qdoc
@@ -80,7 +80,7 @@ signal should be \c green and the warning \c flag is down. Meanwhile, in the
\c CRITICAL state, the \c color should be \c red and the flag is \c up. We may
model the states using the \c State element and the color and flag
configurations with the \c PropertyChanges element.
-\snippet doc/src/snippets/declarative/states.qml signal states
+\snippet doc/src/snippets/qml/states.qml signal states
The \l PropertyChanges element will change the values of object properties.
Objects are referenced through their \l {qml-id}{id}. Objects outside
the component are also referenced using the \c id property, exemplified by the
@@ -89,7 +89,7 @@ property change to the external \c flag object.
Further, the state may change by assigning the \c state property with the
appropriate signal state. A state switch could be in a \l MouseArea element,
assigning a different state whenever the signal receives a mouse click.
-\snippet doc/src/snippets/declarative/states.qml switch states
+\snippet doc/src/snippets/qml/states.qml switch states
The State element is not limited to performing modifications on property values.
It can also:
@@ -115,7 +115,7 @@ expressions to change the state whenever the bound expression evaluates to
\c true. The \c when property will revert the state back to the
\l {The Default State}{default state} when the expression evaluates to false.
-\snippet doc/src/snippets/declarative/states.qml when property
+\snippet doc/src/snippets/qml/states.qml when property
The \c bell component will change to the \c RINGING state whenever the
\c signal.state is \c CRITICAL.
diff --git a/doc/src/qtquick2/writingcomponents.qdoc b/doc/src/qtquick2/writingcomponents.qdoc
index 64d28eff0b..31267cf20c 100644
--- a/doc/src/qtquick2/writingcomponents.qdoc
+++ b/doc/src/qtquick2/writingcomponents.qdoc
@@ -55,14 +55,14 @@ For example, one of the simplest and most common components you can build in QML
button-type component. Below, we implement this component as a \l Rectangle with a clickable
\l MouseArea, in a file named \c Button.qml:
-\snippet doc/src/snippets/declarative/qml-extending-types/components/Button.qml 0
+\snippet doc/src/snippets/qml/qml-extending-types/components/Button.qml 0
Now this component can be reused by another file within the same directory. Since the file is
named \c Button.qml, the component is referred to as \c Button:
\table
\row
-\o \snippet doc/src/snippets/declarative/qml-extending-types/components/application.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/components/application.qml 0
\o \image qml-extending-types.png
\endtable
@@ -73,7 +73,7 @@ customize the \c width, \c height, \c radius and \c color properties of \c Butto
If \c Button.qml was not in the same directory, \c application.qml would need to load it as a
-\l {Modules}{module} from a specific filesystem path or \l{QDeclarativeExtensionPlugin}{plugin}.
+\l {Modules}{module} from a specific filesystem path or \l{QQmlExtensionPlugin}{plugin}.
Also, note the letter case of the component file name is significant on some (notably UNIX)
filesystems. It is recommended the file name case matches the case of the QML component name
exactly - for example, \c Box.qml and not \c BoX.qml - regardless of the platform to which the
@@ -119,8 +119,8 @@ an \c ImageViewer object and read or modify the \c currentImage value:
\table
\row
-\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/ImageViewer.qml 0
-\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/application.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/properties/ImageViewer.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/properties/application.qml 0
\endtable
It is optional for a property to have a default value. The default value is a convenient shortcut, and is
@@ -195,7 +195,7 @@ property name.
For example, the following \c onMyNumberChanged signal handler is automatically called whenever the
\c myNumber property changes:
-\snippet doc/src/snippets/declarative/qml-extending-types/properties/property-signals.qml 0
+\snippet doc/src/snippets/qml/qml-extending-types/properties/property-signals.qml 0
\section2 Default properties
@@ -266,7 +266,7 @@ declaring the alias, and, optionally, <property> refers to a property on that ob
For example, below is a \c Button.qml component with a \c buttonText aliased property which is
connected to the child Text object's \c text property:
-\snippet doc/src/snippets/declarative/qml-extending-types/properties/alias.qml 0
+\snippet doc/src/snippets/qml/qml-extending-types/properties/alias.qml 0
The following code would create a \c Button with a defined text string for the
child \l Text object:
@@ -290,8 +290,8 @@ been changed to an alias to the child \l Image object:
\table
\row
-\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/alias/ImageViewer.qml 0
-\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/alias/application.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/properties/alias/ImageViewer.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/properties/alias/application.qml 0
\endtable
Instead of being limited to setting the \l Image source, \c application.qml can now directly
@@ -335,7 +335,7 @@ It is possible for an aliased property to have the same name as an existing prop
the following component has a \c color alias property, named the same as the built-in
\l {Rectangle::color} property:
-\snippet doc/src/snippets/declarative/qml-extending-types/properties/alias-override.qml 0
+\snippet doc/src/snippets/qml/qml-extending-types/properties/alias-override.qml 0
Any objects that use this component and refer to its \c color property will be
referring to the alias rather than the ordinary \l {Rectangle::color} property. Internally,
@@ -366,7 +366,7 @@ the parameters by name.
Here is an example of a component with a \c say() method that accepts a single \c text argument:
-\snippet doc/src/snippets/declarative/qml-extending-types/methods/app.qml 0
+\snippet doc/src/snippets/qml/qml-extending-types/methods/app.qml 0
A method can be connected to a signal so that it is automatically invoked whenever the signal
is emitted. See \l {Connecting signals to methods and other signals} below.
@@ -422,8 +422,8 @@ signal is received by \c application.qml through an \c onButtonClicked signal ha
\table
\row
-\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/basic.qml 0
-\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/no-parameters.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/signals/basic.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/signals/no-parameters.qml 0
\endtable
If the signal has parameters, they are accessible by parameter name in the signal handler.
@@ -431,8 +431,8 @@ In the example below, \c buttonClicked is emitted with \c xPos and \c yPos param
\table
\row
-\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/Button.qml 0
-\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/parameters.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/signals/Button.qml 0
+\o \snippet doc/src/snippets/qml/qml-extending-types/signals/parameters.qml 0
\endtable
@@ -446,7 +446,7 @@ to be received by a method instead of a \l {Signal Handlers}{signal handler}.
For example, the \c application.qml above could be rewritten as:
-\snippet doc/src/snippets/declarative/qml-extending-types/signals/connectslots.qml 0
+\snippet doc/src/snippets/qml/qml-extending-types/signals/connectslots.qml 0
The \c myMethod() method will be called whenever the \c buttonClicked signal is received.
@@ -458,7 +458,7 @@ or \l {Integrating JavaScript}{integrating JavaScript code}, then you will find
objects dynamically, and connects the \c buttonClicked signal of each object to the
\c myMethod() function:
-\snippet doc/src/snippets/declarative/qml-extending-types/signals/connectdynamic.qml 0
+\snippet doc/src/snippets/qml/qml-extending-types/signals/connectdynamic.qml 0
In the same way, you could connect a signal to methods defined in a dynamically
created object, or \l {Receiving QML Signals in JavaScript}{connect a signal to a JavaScript method}.
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp b/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp
deleted file mode 100644
index 8825cca4bb..0000000000
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 "avatarExample.h"
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-
-void registerTypes()
-{
-//![0]
- qmlRegisterType<AvatarExample>("Qt.example", 1, 0, "AvatarExample");
-//![0]
-}
-
-void expectOne()
-{
-//![1]
-QDeclarativeComponent component(&engine, "exampleOne.qml");
-QObject *object = component.create();
-// The scarce resource will have been released automatically
-// by this point, after the binding expression was evaluated.
-delete object;
-//![1]
-}
-
-void expectTwo()
-{
-//![2]
-QDeclarativeComponent component(&engine, "exampleTwo.qml");
-QObject *object = component.create();
-// The scarce resource will not have been released automatically
-// after the binding expression was evaluated.
-// Since the scarce resource was not released explicitly prior
-// to the binding expression being evaluated, we get:
-bool expectedResult = (object->property("avatar").isValid() == true);
-delete object;
-//![2]
-}
-
-void expectThree()
-{
-//![3]
-QDeclarativeComponent component(&engine, "exampleThree.qml");
-QObject *object = component.create();
-// The resource was preserved explicitly during evaluation of the
-// JavaScript expression. Thus, during property assignment, the
-// scarce resource was still valid, and so we get:
-bool expectedResult = (object->property("avatar").isValid() == true);
-// The scarce resource will not be released until all references to
-// the resource are released, and the JavaScript garbage collector runs.
-delete object;
-//![3]
-}
-
-void expectFour()
-{
-//![4]
-QDeclarativeComponent component(&engine, "exampleFour.qml");
-QObject *object = component.create();
-// The scarce resource was explicitly preserved by the client during
-// the importAvatar() function, and so the scarce resource
-// remains valid until the explicit call to releaseAvatar(). As such,
-// we get the expected results:
-bool expectedResultOne = (object->property("avatarOne").isValid() == true);
-bool expectedResultTwo = (object->property("avatarTwo").isValid() == false);
-// Because the scarce resource referenced by avatarTwo was released explicitly,
-// it will no longer be consuming any system resources (beyond what a normal
-// JS Object would; that small overhead will exist until the JS GC runs, as per
-// any other JavaScript object).
-delete object;
-//![4]
-}
-
-void expectFive()
-{
-//![5]
-QDeclarativeComponent component(&engine, "exampleFive.qml");
-QObject *object = component.create();
-// We have the expected results:
-bool expectedResultOne = (object->property("avatarOne").isValid() == false);
-bool expectedResultTwo = (object->property("avatarTwo").isValid() == false);
-// Because although only avatarTwo was explicitly released,
-// avatarOne and avatarTwo were referencing the same
-// scarce resource.
-delete object;
-//![5]
-}
diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp b/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp
deleted file mode 100644
index d7cfe6f3ef..0000000000
--- a/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-#include "applicationdata.h"
-
-//![0]
-int main(int argc, char *argv[]) {
- QApplication app(argc, argv);
-
- QDeclarativeView view;
-
- ApplicationData data;
- view.rootContext()->setContextProperty("applicationData", &data);
-
- view.setSource(QUrl::fromLocalFile("MyItem.qml"));
- view.show();
-
- return app.exec();
-}
-//![0]
-
diff --git a/doc/src/snippets/declarative/qtbinding/context/main.cpp b/doc/src/snippets/declarative/qtbinding/context/main.cpp
deleted file mode 100644
index e0d9a83e64..0000000000
--- a/doc/src/snippets/declarative/qtbinding/context/main.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
-//![0]
-QDeclarativeView view;
-view.rootContext()->setContextProperty("currentDateTime", QDateTime::currentDateTime());
-view.setSource(QUrl::fromLocalFile("MyItem.qml"));
-view.show();
-//![0]
-
- return app.exec();
-}
-
diff --git a/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h b/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h
deleted file mode 100644
index de9f2ecaab..0000000000
--- a/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-//![start]
-class ImageViewer : public QDeclarativeItem
-{
- Q_OBJECT
- Q_ENUMS(Status)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
-public:
- enum Status {
- Ready,
- Loading,
- Error
- };
-
- Status status() const;
-//![start]
-
- ImageViewer(QDeclarativeItem *parent = 0);
-
-public slots:
- void emitSignals();
-
-//![end]
-signals:
- void statusChanged();
-};
-//![end]
diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp b/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp
deleted file mode 100644
index 5e6c474a8f..0000000000
--- a/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-#include "myclass.h"
-
-//![0]
-int main(int argc, char *argv[]) {
- QApplication app(argc, argv);
-
- QDeclarativeView view;
- MyClass myClass;
- view.rootContext()->setContextProperty("myObject", &myClass);
-
- view.setSource(QUrl::fromLocalFile("MyItem.qml"));
- view.show();
-
- return app.exec();
-}
-//![0]
-
diff --git a/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp
deleted file mode 100644
index ba72e9459a..0000000000
--- a/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
-//![0]
-// main.cpp
-QDeclarativeEngine engine;
-QDeclarativeComponent component(&engine, "MyItem.qml");
-QObject *object = component.create();
-
-QVariant returnedValue;
-QVariant msg = "Hello from C++";
-QMetaObject::invokeMethod(object, "myQmlFunction",
- Q_RETURN_ARG(QVariant, returnedValue),
- Q_ARG(QVariant, msg));
-
-qDebug() << "QML function returned:" << returnedValue.toString();
-delete object;
-//![0]
-}
-
diff --git a/doc/src/snippets/declarative/qtbinding/loading/main.cpp b/doc/src/snippets/declarative/qtbinding/loading/main.cpp
deleted file mode 100644
index 839b7352a5..0000000000
--- a/doc/src/snippets/declarative/qtbinding/loading/main.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-static void withComponent()
-{
-//![QDeclarativeComponent-a]
-// Using QDeclarativeComponent
-QDeclarativeEngine engine;
-QDeclarativeComponent component(&engine,
- QUrl::fromLocalFile("MyItem.qml"));
-QObject *object = component.create();
-//![QDeclarativeComponent-a]
-}
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
-//![QDeclarativeView]
-// Using QDeclarativeView
-QDeclarativeView view;
-view.setSource(QUrl::fromLocalFile("MyItem.qml"));
-view.show();
-QObject *object = view.rootObject();
-//![QDeclarativeView]
-
-//![properties]
-object->setProperty("width", 500);
-QDeclarativeProperty(object, "width").write(500);
-//![properties]
-
-//![cast]
-QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(object);
-item->setWidth(500);
-//![cast]
-
-//![findChild]
-QObject *rect = object->findChild<QObject*>("rect");
-if (rect)
- rect->setProperty("color", "red");
-//![findChild]
-
-//![QDeclarativeComponent-b]
-delete object;
-//![QDeclarativeComponent-b]
-
-withComponent();
-
- return app.exec();
-}
-
diff --git a/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h b/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h
deleted file mode 100644
index 7bbc243d83..0000000000
--- a/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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$
-**
-****************************************************************************/
-//![0]
-#include <QtCore>
-#include <QtDeclarative>
-
-class ImageViewer : public QDeclarativeItem
-{
- Q_OBJECT
- Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged)
-
-public:
- void setImage(const QUrl &url);
- QUrl image() const;
-
-signals:
- void imageChanged();
-};
-//![0]
diff --git a/doc/src/snippets/declarative/qtbinding/newelements/main.cpp b/doc/src/snippets/declarative/qtbinding/newelements/main.cpp
deleted file mode 100644
index ead2fd1722..0000000000
--- a/doc/src/snippets/declarative/qtbinding/newelements/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-#include "imageviewer.h"
-
-void ImageViewer::setImage(const QUrl &url) {}
-QUrl ImageViewer::image() const { return QUrl(); }
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- //![register]
- qmlRegisterType<ImageViewer>("MyLibrary", 1, 0, "ImageViewer");
- //![register]
-
- QDeclarativeView view;
- view.setSource(QUrl::fromLocalFile("standalone.qml"));
- view.show();
-
- return app.exec();
-}
-
diff --git a/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp
deleted file mode 100644
index 91347ee70f..0000000000
--- a/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
-//![0]
-QDeclarativeEngine engine;
-QDeclarativeComponent component(&engine, "MyItem.qml");
-QObject *object = component.create();
-
-qDebug() << "Property value:" << QDeclarativeProperty::read(object, "someNumber").toInt();
-QDeclarativeProperty::write(object, "someNumber", 5000);
-
-qDebug() << "Property value:" << object->property("someNumber").toInt();
-object->setProperty("someNumber", 100);
-//![0]
-
- return app.exec();
-}
-
diff --git a/doc/src/snippets/declarative/qtbinding/resources/main.cpp b/doc/src/snippets/declarative/qtbinding/resources/main.cpp
deleted file mode 100644
index 0ec1189eeb..0000000000
--- a/doc/src/snippets/declarative/qtbinding/resources/main.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QApplication>
-#include <QDeclarativeView>
-#include <QDeclarativeContext>
-
-//![0]
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QDeclarativeView view;
- view.setSource(QUrl("qrc:/main.qml"));
- view.show();
-
- return app.exec();
-}
-//![0]
-
diff --git a/doc/src/snippets/declarative/qtbinding/resources/resources.pro b/doc/src/snippets/declarative/qtbinding/resources/resources.pro
deleted file mode 100644
index cc01ee126f..0000000000
--- a/doc/src/snippets/declarative/qtbinding/resources/resources.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-QT += declarative
-
-SOURCES += main.cpp
-RESOURCES += example.qrc
diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h b/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h
deleted file mode 100644
index a066447cfb..0000000000
--- a/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-//![start]
-class ImageViewer : public QDeclarativeItem
-{
- Q_OBJECT
- Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged)
-public:
-//![start]
- ImageViewer(QDeclarativeItem *item = 0);
-
- void setImage(const QUrl &url) {}
- QUrl image() const { return QUrl(); }
-
-public slots:
- void emitSignals();
-
-//![end]
-signals:
- void imageChanged();
- void loadingError(const QString &errorMsg);
-};
-//![end]
-
diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp b/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp
deleted file mode 100644
index f3ea3f26df..0000000000
--- a/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-#include "imageviewer.h"
-
-
-ImageViewer::ImageViewer(QDeclarativeItem *item)
- : QDeclarativeItem(item)
-{
- QTimer::singleShot(0, this, SLOT(emitSignals()));
-}
-
-void ImageViewer::emitSignals()
-{
- emit imageChanged();
- emit loadingError("some error message");
-}
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- qmlRegisterType<ImageViewer>("MyLibrary", 1, 0, "ImageViewer");
-
- QDeclarativeView standalone;
- standalone.setSource(QUrl::fromLocalFile("standalone.qml"));
- standalone.show();
-
-//![connections]
-ImageViewer viewer;
-
-QDeclarativeView view;
-view.rootContext()->setContextProperty("imageViewer", &viewer);
-
-view.setSource(QUrl::fromLocalFile("MyItem.qml"));
-view.show();
-//![connections]
-
- return app.exec();
-}
-
-
diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp
deleted file mode 100644
index 084d5f0e4b..0000000000
--- a/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-//![0]
-int main(int argc, char *argv[]) {
- QApplication app(argc, argv);
-
- QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml"));
- QObject *item = view.rootObject();
-
- MyClass myClass;
- QObject::connect(item, SIGNAL(qmlSignal(QString)),
- &myClass, SLOT(cppSlot(QString)));
-
- view.show();
- return app.exec();
-}
-//![0]
-
-#include "moc_main.cpp"
diff --git a/doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp b/doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp
deleted file mode 100644
index 1cebecdff4..0000000000
--- a/doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 <QtCore>
-#include <QtDeclarative>
-
-int main(int argc, char *argv[]) {
- QApplication app(argc, argv);
-
-//![0]
-// C++
-QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml"));
-
-QVariantList list;
-list << 10 << Qt::green << "bottles";
-
-QVariantMap map;
-map.insert("language", "QML");
-map.insert("released", QDate(2010, 9, 21));
-
-QMetaObject::invokeMethod(view.rootObject(), "readValues",
- Q_ARG(QVariant, QVariant::fromValue(list)),
- Q_ARG(QVariant, QVariant::fromValue(map)));
-//![0]
-
- view.setSource(QUrl::fromLocalFile("MyItem.qml"));
- view.show();
-
- return app.exec();
-}
-
diff --git a/doc/src/snippets/declarative/text/onLinkActivated.qml b/doc/src/snippets/declarative/text/onLinkActivated.qml
deleted file mode 100644
index 71545ad3e2..0000000000
--- a/doc/src/snippets/declarative/text/onLinkActivated.qml
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 QtQuick 2.0
-
-Rectangle {
- width: 700; height: 400
-
-//![0]
- Text {
- textFormat: Text.RichText
- text: "The main website is at <a href=\"http://qt.nokia.com\">Nokia Qt DF</a>."
- onLinkActivated: console.log(link + " link activated")
- }
-//![0]
-
-}
-
diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp
deleted file mode 100644
index 206828e883..0000000000
--- a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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$
-**
-****************************************************************************/
-#include <QDeclarativeView>
-#include <QDeclarativeContext>
-
-#include <QApplication>
-#include <QDirModel>
-
-//![0]
-int main(int argc, char ** argv)
-{
- QApplication app(argc, argv);
-
- QDeclarativeView view;
-
- QDirModel model;
- view.rootContext()->setContextProperty("dirModel", &model);
-
- view.setSource(QUrl::fromLocalFile("view.qml"));
- view.show();
-
- return app.exec();
-}
-//![0]
-
diff --git a/doc/src/snippets/declarative/Button.qml b/doc/src/snippets/qml/Button.qml
index 0525ac1383..0525ac1383 100644
--- a/doc/src/snippets/declarative/Button.qml
+++ b/doc/src/snippets/qml/Button.qml
diff --git a/doc/src/snippets/declarative/SelfDestroyingRect.qml b/doc/src/snippets/qml/SelfDestroyingRect.qml
index baa4ab63a1..baa4ab63a1 100644
--- a/doc/src/snippets/declarative/SelfDestroyingRect.qml
+++ b/doc/src/snippets/qml/SelfDestroyingRect.qml
diff --git a/doc/src/snippets/declarative/Sprite.qml b/doc/src/snippets/qml/Sprite.qml
index ec08963be5..ec08963be5 100644
--- a/doc/src/snippets/declarative/Sprite.qml
+++ b/doc/src/snippets/qml/Sprite.qml
diff --git a/doc/src/snippets/declarative/anchoranimation.qml b/doc/src/snippets/qml/anchoranimation.qml
index 8f0603fab8..8f0603fab8 100644
--- a/doc/src/snippets/declarative/anchoranimation.qml
+++ b/doc/src/snippets/qml/anchoranimation.qml
diff --git a/doc/src/snippets/declarative/anchorchanges.qml b/doc/src/snippets/qml/anchorchanges.qml
index 9cc9d15221..9cc9d15221 100644
--- a/doc/src/snippets/declarative/anchorchanges.qml
+++ b/doc/src/snippets/qml/anchorchanges.qml
diff --git a/doc/src/snippets/declarative/animatedimage.qml b/doc/src/snippets/qml/animatedimage.qml
index a483619e11..a483619e11 100644
--- a/doc/src/snippets/declarative/animatedimage.qml
+++ b/doc/src/snippets/qml/animatedimage.qml
diff --git a/doc/src/snippets/declarative/animation.qml b/doc/src/snippets/qml/animation.qml
index d45ded397f..d45ded397f 100644
--- a/doc/src/snippets/declarative/animation.qml
+++ b/doc/src/snippets/qml/animation.qml
diff --git a/doc/src/snippets/declarative/application.qml b/doc/src/snippets/qml/application.qml
index 4e847176fa..4e847176fa 100644
--- a/doc/src/snippets/declarative/application.qml
+++ b/doc/src/snippets/qml/application.qml
diff --git a/doc/src/snippets/declarative/behavior.qml b/doc/src/snippets/qml/behavior.qml
index 4776e09a54..4776e09a54 100644
--- a/doc/src/snippets/declarative/behavior.qml
+++ b/doc/src/snippets/qml/behavior.qml
diff --git a/doc/src/snippets/declarative/borderimage/borderimage-scaled.qml b/doc/src/snippets/qml/borderimage/borderimage-scaled.qml
index 468aa24eab..468aa24eab 100644
--- a/doc/src/snippets/declarative/borderimage/borderimage-scaled.qml
+++ b/doc/src/snippets/qml/borderimage/borderimage-scaled.qml
diff --git a/doc/src/snippets/declarative/borderimage/borderimage-tiled.qml b/doc/src/snippets/qml/borderimage/borderimage-tiled.qml
index 69297378bf..69297378bf 100644
--- a/doc/src/snippets/declarative/borderimage/borderimage-tiled.qml
+++ b/doc/src/snippets/qml/borderimage/borderimage-tiled.qml
diff --git a/doc/src/snippets/declarative/borderimage/normal-image.qml b/doc/src/snippets/qml/borderimage/normal-image.qml
index 3bd34e3933..3bd34e3933 100644
--- a/doc/src/snippets/declarative/borderimage/normal-image.qml
+++ b/doc/src/snippets/qml/borderimage/normal-image.qml
diff --git a/doc/src/snippets/declarative/codingconventions/dotproperties.qml b/doc/src/snippets/qml/codingconventions/dotproperties.qml
index 75f4629b3e..75f4629b3e 100644
--- a/doc/src/snippets/declarative/codingconventions/dotproperties.qml
+++ b/doc/src/snippets/qml/codingconventions/dotproperties.qml
diff --git a/doc/src/snippets/declarative/codingconventions/javascript-imports.qml b/doc/src/snippets/qml/codingconventions/javascript-imports.qml
index 5ea66a9b1f..5ea66a9b1f 100644
--- a/doc/src/snippets/declarative/codingconventions/javascript-imports.qml
+++ b/doc/src/snippets/qml/codingconventions/javascript-imports.qml
diff --git a/doc/src/snippets/declarative/codingconventions/javascript.qml b/doc/src/snippets/qml/codingconventions/javascript.qml
index de3cc21493..de3cc21493 100644
--- a/doc/src/snippets/declarative/codingconventions/javascript.qml
+++ b/doc/src/snippets/qml/codingconventions/javascript.qml
diff --git a/doc/src/snippets/declarative/codingconventions/lists.qml b/doc/src/snippets/qml/codingconventions/lists.qml
index f99c92b08e..f99c92b08e 100644
--- a/doc/src/snippets/declarative/codingconventions/lists.qml
+++ b/doc/src/snippets/qml/codingconventions/lists.qml
diff --git a/doc/src/snippets/declarative/codingconventions/myscript.js b/doc/src/snippets/qml/codingconventions/myscript.js
index e7f83c259c..e7f83c259c 100644
--- a/doc/src/snippets/declarative/codingconventions/myscript.js
+++ b/doc/src/snippets/qml/codingconventions/myscript.js
diff --git a/doc/src/snippets/declarative/codingconventions/photo.qml b/doc/src/snippets/qml/codingconventions/photo.qml
index 1bd2811e9f..1bd2811e9f 100644
--- a/doc/src/snippets/declarative/codingconventions/photo.qml
+++ b/doc/src/snippets/qml/codingconventions/photo.qml
diff --git a/doc/src/snippets/declarative/codingconventions/private.qml b/doc/src/snippets/qml/codingconventions/private.qml
index 9aba1d0377..9aba1d0377 100644
--- a/doc/src/snippets/declarative/codingconventions/private.qml
+++ b/doc/src/snippets/qml/codingconventions/private.qml
diff --git a/doc/src/snippets/declarative/coloranimation.qml b/doc/src/snippets/qml/coloranimation.qml
index bb2d83bfb8..bb2d83bfb8 100644
--- a/doc/src/snippets/declarative/coloranimation.qml
+++ b/doc/src/snippets/qml/coloranimation.qml
diff --git a/doc/src/snippets/declarative/colors.qml b/doc/src/snippets/qml/colors.qml
index 7f94c6b843..7f94c6b843 100644
--- a/doc/src/snippets/declarative/colors.qml
+++ b/doc/src/snippets/qml/colors.qml
diff --git a/doc/src/snippets/declarative/column/column-transitions.qml b/doc/src/snippets/qml/column/column-transitions.qml
index 8e291b12c8..8e291b12c8 100644
--- a/doc/src/snippets/declarative/column/column-transitions.qml
+++ b/doc/src/snippets/qml/column/column-transitions.qml
diff --git a/doc/src/snippets/declarative/column/column.qml b/doc/src/snippets/qml/column/column.qml
index 3d51728d13..3d51728d13 100644
--- a/doc/src/snippets/declarative/column/column.qml
+++ b/doc/src/snippets/qml/column/column.qml
diff --git a/doc/src/snippets/declarative/column/vertical-positioner.qml b/doc/src/snippets/qml/column/vertical-positioner.qml
index 1661c46ba8..1661c46ba8 100644
--- a/doc/src/snippets/declarative/column/vertical-positioner.qml
+++ b/doc/src/snippets/qml/column/vertical-positioner.qml
diff --git a/doc/src/snippets/declarative/comments.qml b/doc/src/snippets/qml/comments.qml
index 8c3f0045b9..8c3f0045b9 100644
--- a/doc/src/snippets/declarative/comments.qml
+++ b/doc/src/snippets/qml/comments.qml
diff --git a/doc/src/snippets/declarative/component.qml b/doc/src/snippets/qml/component.qml
index e2a359e0e4..e2a359e0e4 100644
--- a/doc/src/snippets/declarative/component.qml
+++ b/doc/src/snippets/qml/component.qml
diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/qml/componentCreation.js
index 7364139d3d..7364139d3d 100644
--- a/doc/src/snippets/declarative/componentCreation.js
+++ b/doc/src/snippets/qml/componentCreation.js
diff --git a/doc/src/snippets/declarative/createComponent-simple.qml b/doc/src/snippets/qml/createComponent-simple.qml
index 3f90a39166..3f90a39166 100644
--- a/doc/src/snippets/declarative/createComponent-simple.qml
+++ b/doc/src/snippets/qml/createComponent-simple.qml
diff --git a/doc/src/snippets/declarative/createComponent.qml b/doc/src/snippets/qml/createComponent.qml
index e2d81170e4..e2d81170e4 100644
--- a/doc/src/snippets/declarative/createComponent.qml
+++ b/doc/src/snippets/qml/createComponent.qml
diff --git a/doc/src/snippets/declarative/createQmlObject.qml b/doc/src/snippets/qml/createQmlObject.qml
index 76cf836914..76cf836914 100644
--- a/doc/src/snippets/declarative/createQmlObject.qml
+++ b/doc/src/snippets/qml/createQmlObject.qml
diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/qml/drag.qml
index 286fcfc52b..286fcfc52b 100644
--- a/doc/src/snippets/declarative/drag.qml
+++ b/doc/src/snippets/qml/drag.qml
diff --git a/doc/src/snippets/declarative/dynamicObjects-destroy.qml b/doc/src/snippets/qml/dynamicObjects-destroy.qml
index 66fbc0b243..66fbc0b243 100644
--- a/doc/src/snippets/declarative/dynamicObjects-destroy.qml
+++ b/doc/src/snippets/qml/dynamicObjects-destroy.qml
diff --git a/doc/src/snippets/declarative/events.qml b/doc/src/snippets/qml/events.qml
index b9c5fef954..b9c5fef954 100644
--- a/doc/src/snippets/declarative/events.qml
+++ b/doc/src/snippets/qml/events.qml
diff --git a/doc/src/snippets/declarative/flickable.qml b/doc/src/snippets/qml/flickable.qml
index fda2615e14..fda2615e14 100644
--- a/doc/src/snippets/declarative/flickable.qml
+++ b/doc/src/snippets/qml/flickable.qml
diff --git a/doc/src/snippets/declarative/flickableScrollbar.qml b/doc/src/snippets/qml/flickableScrollbar.qml
index fd0aee3fc1..fd0aee3fc1 100644
--- a/doc/src/snippets/declarative/flickableScrollbar.qml
+++ b/doc/src/snippets/qml/flickableScrollbar.qml
diff --git a/doc/src/snippets/declarative/flipable/flipable.qml b/doc/src/snippets/qml/flipable/flipable.qml
index 4e451204d4..4e451204d4 100644
--- a/doc/src/snippets/declarative/flipable/flipable.qml
+++ b/doc/src/snippets/qml/flipable/flipable.qml
diff --git a/doc/src/snippets/declarative/flow.qml b/doc/src/snippets/qml/flow.qml
index 1141269986..1141269986 100644
--- a/doc/src/snippets/declarative/flow.qml
+++ b/doc/src/snippets/qml/flow.qml
diff --git a/doc/src/snippets/declarative/focus/MyClickableWidget.qml b/doc/src/snippets/qml/focus/MyClickableWidget.qml
index 7017f1bcb6..7017f1bcb6 100644
--- a/doc/src/snippets/declarative/focus/MyClickableWidget.qml
+++ b/doc/src/snippets/qml/focus/MyClickableWidget.qml
diff --git a/doc/src/snippets/declarative/focus/MyWidget.qml b/doc/src/snippets/qml/focus/MyWidget.qml
index 5899b18ae0..5899b18ae0 100644
--- a/doc/src/snippets/declarative/focus/MyWidget.qml
+++ b/doc/src/snippets/qml/focus/MyWidget.qml
diff --git a/doc/src/snippets/declarative/focus/advancedFocus.qml b/doc/src/snippets/qml/focus/advancedFocus.qml
index ec4efca450..ec4efca450 100644
--- a/doc/src/snippets/declarative/focus/advancedFocus.qml
+++ b/doc/src/snippets/qml/focus/advancedFocus.qml
diff --git a/doc/src/snippets/declarative/focus/basicwidget.qml b/doc/src/snippets/qml/focus/basicwidget.qml
index bd5778948a..bd5778948a 100644
--- a/doc/src/snippets/declarative/focus/basicwidget.qml
+++ b/doc/src/snippets/qml/focus/basicwidget.qml
diff --git a/doc/src/snippets/declarative/focus/clickablewidget.qml b/doc/src/snippets/qml/focus/clickablewidget.qml
index 81bd5f7e51..81bd5f7e51 100644
--- a/doc/src/snippets/declarative/focus/clickablewidget.qml
+++ b/doc/src/snippets/qml/focus/clickablewidget.qml
diff --git a/doc/src/snippets/declarative/focus/myfocusscopewidget.qml b/doc/src/snippets/qml/focus/myfocusscopewidget.qml
index f568c39a32..f568c39a32 100644
--- a/doc/src/snippets/declarative/focus/myfocusscopewidget.qml
+++ b/doc/src/snippets/qml/focus/myfocusscopewidget.qml
diff --git a/doc/src/snippets/declarative/focus/rectangle.qml b/doc/src/snippets/qml/focus/rectangle.qml
index cb00f1f11a..cb00f1f11a 100644
--- a/doc/src/snippets/declarative/focus/rectangle.qml
+++ b/doc/src/snippets/qml/focus/rectangle.qml
diff --git a/doc/src/snippets/declarative/focus/widget.qml b/doc/src/snippets/qml/focus/widget.qml
index 5ee8a71846..5ee8a71846 100644
--- a/doc/src/snippets/declarative/focus/widget.qml
+++ b/doc/src/snippets/qml/focus/widget.qml
diff --git a/doc/src/snippets/declarative/folderlistmodel.qml b/doc/src/snippets/qml/folderlistmodel.qml
index 5878640567..5878640567 100644
--- a/doc/src/snippets/declarative/folderlistmodel.qml
+++ b/doc/src/snippets/qml/folderlistmodel.qml
diff --git a/doc/src/snippets/declarative/gradient.qml b/doc/src/snippets/qml/gradient.qml
index a5af6a7930..a5af6a7930 100644
--- a/doc/src/snippets/declarative/gradient.qml
+++ b/doc/src/snippets/qml/gradient.qml
diff --git a/doc/src/snippets/declarative/grid-spacing.qml b/doc/src/snippets/qml/grid-spacing.qml
index 1385492ac6..1385492ac6 100644
--- a/doc/src/snippets/declarative/grid-spacing.qml
+++ b/doc/src/snippets/qml/grid-spacing.qml
diff --git a/doc/src/snippets/declarative/grid/grid-items.qml b/doc/src/snippets/qml/grid/grid-items.qml
index 8afb170f75..8afb170f75 100644
--- a/doc/src/snippets/declarative/grid/grid-items.qml
+++ b/doc/src/snippets/qml/grid/grid-items.qml
diff --git a/doc/src/snippets/declarative/grid/grid-no-spacing.qml b/doc/src/snippets/qml/grid/grid-no-spacing.qml
index c44eadce63..c44eadce63 100644
--- a/doc/src/snippets/declarative/grid/grid-no-spacing.qml
+++ b/doc/src/snippets/qml/grid/grid-no-spacing.qml
diff --git a/doc/src/snippets/declarative/grid/grid-spacing.qml b/doc/src/snippets/qml/grid/grid-spacing.qml
index 1385492ac6..1385492ac6 100644
--- a/doc/src/snippets/declarative/grid/grid-spacing.qml
+++ b/doc/src/snippets/qml/grid/grid-spacing.qml
diff --git a/doc/src/snippets/declarative/grid/grid.qml b/doc/src/snippets/qml/grid/grid.qml
index 7fb1bb6f5a..7fb1bb6f5a 100644
--- a/doc/src/snippets/declarative/grid/grid.qml
+++ b/doc/src/snippets/qml/grid/grid.qml
diff --git a/doc/src/snippets/declarative/gridview/ContactModel.qml b/doc/src/snippets/qml/gridview/ContactModel.qml
index f744c1e73f..f744c1e73f 100644
--- a/doc/src/snippets/declarative/gridview/ContactModel.qml
+++ b/doc/src/snippets/qml/gridview/ContactModel.qml
diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/qml/gridview/gridview.qml
index d3b37d1338..d3b37d1338 100644
--- a/doc/src/snippets/declarative/gridview/gridview.qml
+++ b/doc/src/snippets/qml/gridview/gridview.qml
diff --git a/doc/src/snippets/declarative/image.qml b/doc/src/snippets/qml/image.qml
index 61724ffeea..61724ffeea 100644
--- a/doc/src/snippets/declarative/image.qml
+++ b/doc/src/snippets/qml/image.qml
diff --git a/doc/src/snippets/declarative/imports/chart.qml b/doc/src/snippets/qml/imports/chart.qml
index d5a2d3bf45..d5a2d3bf45 100644
--- a/doc/src/snippets/declarative/imports/chart.qml
+++ b/doc/src/snippets/qml/imports/chart.qml
diff --git a/doc/src/snippets/declarative/imports/installed-module.qml b/doc/src/snippets/qml/imports/installed-module.qml
index c263ea89ed..c263ea89ed 100644
--- a/doc/src/snippets/declarative/imports/installed-module.qml
+++ b/doc/src/snippets/qml/imports/installed-module.qml
diff --git a/doc/src/snippets/declarative/imports/merged-named-imports.qml b/doc/src/snippets/qml/imports/merged-named-imports.qml
index a75687c740..a75687c740 100644
--- a/doc/src/snippets/declarative/imports/merged-named-imports.qml
+++ b/doc/src/snippets/qml/imports/merged-named-imports.qml
diff --git a/doc/src/snippets/declarative/imports/named-imports.qml b/doc/src/snippets/qml/imports/named-imports.qml
index 125e6cfa27..125e6cfa27 100644
--- a/doc/src/snippets/declarative/imports/named-imports.qml
+++ b/doc/src/snippets/qml/imports/named-imports.qml
diff --git a/doc/src/snippets/declarative/imports/network-imports.qml b/doc/src/snippets/qml/imports/network-imports.qml
index f039c44f1e..f039c44f1e 100644
--- a/doc/src/snippets/declarative/imports/network-imports.qml
+++ b/doc/src/snippets/qml/imports/network-imports.qml
diff --git a/doc/src/snippets/declarative/imports/qtquick-1.0.qml b/doc/src/snippets/qml/imports/qtquick-1.0.qml
index 481bc12e7e..481bc12e7e 100644
--- a/doc/src/snippets/declarative/imports/qtquick-1.0.qml
+++ b/doc/src/snippets/qml/imports/qtquick-1.0.qml
diff --git a/doc/src/snippets/declarative/imports/timeexample.qml b/doc/src/snippets/qml/imports/timeexample.qml
index 4d79dbe15e..4d79dbe15e 100644
--- a/doc/src/snippets/declarative/imports/timeexample.qml
+++ b/doc/src/snippets/qml/imports/timeexample.qml
diff --git a/doc/src/snippets/declarative/integrating-javascript/connectjs.qml b/doc/src/snippets/qml/integrating-javascript/connectjs.qml
index 89c9ebc21a..89c9ebc21a 100644
--- a/doc/src/snippets/declarative/integrating-javascript/connectjs.qml
+++ b/doc/src/snippets/qml/integrating-javascript/connectjs.qml
diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/app.qml b/doc/src/snippets/qml/integrating-javascript/includejs/app.qml
index 0dd7b533a6..0dd7b533a6 100644
--- a/doc/src/snippets/declarative/integrating-javascript/includejs/app.qml
+++ b/doc/src/snippets/qml/integrating-javascript/includejs/app.qml
diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js b/doc/src/snippets/qml/integrating-javascript/includejs/factorial.js
index a7bc4ac69f..a7bc4ac69f 100644
--- a/doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js
+++ b/doc/src/snippets/qml/integrating-javascript/includejs/factorial.js
diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/script.js b/doc/src/snippets/qml/integrating-javascript/includejs/script.js
index 964b2f5e8a..964b2f5e8a 100644
--- a/doc/src/snippets/declarative/integrating-javascript/includejs/script.js
+++ b/doc/src/snippets/qml/integrating-javascript/includejs/script.js
diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp
new file mode 100644
index 0000000000..e018a68292
--- /dev/null
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "avatarExample.h"
+#include <QQmlEngine>
+#include <QQmlComponent>
+
+void registerTypes()
+{
+//![0]
+ qmlRegisterType<AvatarExample>("Qt.example", 1, 0, "AvatarExample");
+//![0]
+}
+
+void expectOne()
+{
+//![1]
+QQmlComponent component(&engine, "exampleOne.qml");
+QObject *object = component.create();
+// The scarce resource will have been released automatically
+// by this point, after the binding expression was evaluated.
+delete object;
+//![1]
+}
+
+void expectTwo()
+{
+//![2]
+QQmlComponent component(&engine, "exampleTwo.qml");
+QObject *object = component.create();
+// The scarce resource will not have been released automatically
+// after the binding expression was evaluated.
+// Since the scarce resource was not released explicitly prior
+// to the binding expression being evaluated, we get:
+bool expectedResult = (object->property("avatar").isValid() == true);
+delete object;
+//![2]
+}
+
+void expectThree()
+{
+//![3]
+QQmlComponent component(&engine, "exampleThree.qml");
+QObject *object = component.create();
+// The resource was preserved explicitly during evaluation of the
+// JavaScript expression. Thus, during property assignment, the
+// scarce resource was still valid, and so we get:
+bool expectedResult = (object->property("avatar").isValid() == true);
+// The scarce resource will not be released until all references to
+// the resource are released, and the JavaScript garbage collector runs.
+delete object;
+//![3]
+}
+
+void expectFour()
+{
+//![4]
+QQmlComponent component(&engine, "exampleFour.qml");
+QObject *object = component.create();
+// The scarce resource was explicitly preserved by the client during
+// the importAvatar() function, and so the scarce resource
+// remains valid until the explicit call to releaseAvatar(). As such,
+// we get the expected results:
+bool expectedResultOne = (object->property("avatarOne").isValid() == true);
+bool expectedResultTwo = (object->property("avatarTwo").isValid() == false);
+// Because the scarce resource referenced by avatarTwo was released explicitly,
+// it will no longer be consuming any system resources (beyond what a normal
+// JS Object would; that small overhead will exist until the JS GC runs, as per
+// any other JavaScript object).
+delete object;
+//![4]
+}
+
+void expectFive()
+{
+//![5]
+QQmlComponent component(&engine, "exampleFive.qml");
+QObject *object = component.create();
+// We have the expected results:
+bool expectedResultOne = (object->property("avatarOne").isValid() == false);
+bool expectedResultTwo = (object->property("avatarTwo").isValid() == false);
+// Because although only avatarTwo was explicitly released,
+// avatarOne and avatarTwo were referencing the same
+// scarce resource.
+delete object;
+//![5]
+}
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h
index d9fbff4fde..d9fbff4fde 100644
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml
index 7cfab16a51..7cfab16a51 100644
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js
index d104e6f6c7..d104e6f6c7 100644
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml
index f5811602dc..f5811602dc 100644
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml
index cf9b3ebc5d..cf9b3ebc5d 100644
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js
index 44df13f7a4..44df13f7a4 100644
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml
index 3f12458cec..3f12458cec 100644
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml
diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml
index f322fb9ed9..f322fb9ed9 100644
--- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml
+++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml
diff --git a/doc/src/snippets/declarative/integrating-javascript/script.js b/doc/src/snippets/qml/integrating-javascript/script.js
index 006cf1aead..006cf1aead 100644
--- a/doc/src/snippets/declarative/integrating-javascript/script.js
+++ b/doc/src/snippets/qml/integrating-javascript/script.js
diff --git a/doc/src/snippets/declarative/keynavigation.qml b/doc/src/snippets/qml/keynavigation.qml
index 4854ecd0ed..4854ecd0ed 100644
--- a/doc/src/snippets/declarative/keynavigation.qml
+++ b/doc/src/snippets/qml/keynavigation.qml
diff --git a/doc/src/snippets/declarative/keys/keys-handler.qml b/doc/src/snippets/qml/keys/keys-handler.qml
index 21fc98e23d..21fc98e23d 100644
--- a/doc/src/snippets/declarative/keys/keys-handler.qml
+++ b/doc/src/snippets/qml/keys/keys-handler.qml
diff --git a/doc/src/snippets/declarative/keys/keys-pressed.qml b/doc/src/snippets/qml/keys/keys-pressed.qml
index 3c9a2d9dce..3c9a2d9dce 100644
--- a/doc/src/snippets/declarative/keys/keys-pressed.qml
+++ b/doc/src/snippets/qml/keys/keys-pressed.qml
diff --git a/doc/src/snippets/declarative/layoutmirroring.qml b/doc/src/snippets/qml/layoutmirroring.qml
index 5daf3f58b3..5daf3f58b3 100644
--- a/doc/src/snippets/declarative/layoutmirroring.qml
+++ b/doc/src/snippets/qml/layoutmirroring.qml
diff --git a/doc/src/snippets/declarative/listmodel-modify.qml b/doc/src/snippets/qml/listmodel-modify.qml
index 308453b393..308453b393 100644
--- a/doc/src/snippets/declarative/listmodel-modify.qml
+++ b/doc/src/snippets/qml/listmodel-modify.qml
diff --git a/doc/src/snippets/declarative/listmodel-nested.qml b/doc/src/snippets/qml/listmodel-nested.qml
index bac95608e1..bac95608e1 100644
--- a/doc/src/snippets/declarative/listmodel-nested.qml
+++ b/doc/src/snippets/qml/listmodel-nested.qml
diff --git a/doc/src/snippets/declarative/listmodel-simple.qml b/doc/src/snippets/qml/listmodel-simple.qml
index e8c4cea68e..e8c4cea68e 100644
--- a/doc/src/snippets/declarative/listmodel-simple.qml
+++ b/doc/src/snippets/qml/listmodel-simple.qml
diff --git a/doc/src/snippets/declarative/listmodel.qml b/doc/src/snippets/qml/listmodel.qml
index e93732e2ee..e93732e2ee 100644
--- a/doc/src/snippets/declarative/listmodel.qml
+++ b/doc/src/snippets/qml/listmodel.qml
diff --git a/doc/src/snippets/declarative/listview-decorations.qml b/doc/src/snippets/qml/listview-decorations.qml
index ccd7023d9c..ccd7023d9c 100644
--- a/doc/src/snippets/declarative/listview-decorations.qml
+++ b/doc/src/snippets/qml/listview-decorations.qml
diff --git a/doc/src/snippets/declarative/listview-sections.qml b/doc/src/snippets/qml/listview-sections.qml
index 59cfdf80bb..59cfdf80bb 100644
--- a/doc/src/snippets/declarative/listview-sections.qml
+++ b/doc/src/snippets/qml/listview-sections.qml
diff --git a/doc/src/snippets/declarative/listview.qml b/doc/src/snippets/qml/listview.qml
index e8752a47cd..e8752a47cd 100644
--- a/doc/src/snippets/declarative/listview.qml
+++ b/doc/src/snippets/qml/listview.qml
diff --git a/doc/src/snippets/declarative/listview/ContactModel.qml b/doc/src/snippets/qml/listview/ContactModel.qml
index 395c637b6a..395c637b6a 100644
--- a/doc/src/snippets/declarative/listview/ContactModel.qml
+++ b/doc/src/snippets/qml/listview/ContactModel.qml
diff --git a/doc/src/snippets/declarative/listview/listview-snippet.qml b/doc/src/snippets/qml/listview/listview-snippet.qml
index 1458e9aa50..1458e9aa50 100644
--- a/doc/src/snippets/declarative/listview/listview-snippet.qml
+++ b/doc/src/snippets/qml/listview/listview-snippet.qml
diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/qml/listview/listview.qml
index 689e6d2c45..689e6d2c45 100644
--- a/doc/src/snippets/declarative/listview/listview.qml
+++ b/doc/src/snippets/qml/listview/listview.qml
diff --git a/doc/src/snippets/declarative/loader/KeyReader.qml b/doc/src/snippets/qml/loader/KeyReader.qml
index ef15a01bb1..ef15a01bb1 100644
--- a/doc/src/snippets/declarative/loader/KeyReader.qml
+++ b/doc/src/snippets/qml/loader/KeyReader.qml
diff --git a/doc/src/snippets/declarative/loader/MyItem.qml b/doc/src/snippets/qml/loader/MyItem.qml
index 2879e7ae23..2879e7ae23 100644
--- a/doc/src/snippets/declarative/loader/MyItem.qml
+++ b/doc/src/snippets/qml/loader/MyItem.qml
diff --git a/doc/src/snippets/declarative/loader/connections.qml b/doc/src/snippets/qml/loader/connections.qml
index 82d770b2cb..82d770b2cb 100644
--- a/doc/src/snippets/declarative/loader/connections.qml
+++ b/doc/src/snippets/qml/loader/connections.qml
diff --git a/doc/src/snippets/declarative/loader/focus.qml b/doc/src/snippets/qml/loader/focus.qml
index 4447c62905..4447c62905 100644
--- a/doc/src/snippets/declarative/loader/focus.qml
+++ b/doc/src/snippets/qml/loader/focus.qml
diff --git a/doc/src/snippets/declarative/loader/simple.qml b/doc/src/snippets/qml/loader/simple.qml
index a4408c2231..a4408c2231 100644
--- a/doc/src/snippets/declarative/loader/simple.qml
+++ b/doc/src/snippets/qml/loader/simple.qml
diff --git a/doc/src/snippets/declarative/loader/sizeitem.qml b/doc/src/snippets/qml/loader/sizeitem.qml
index d673d82817..d673d82817 100644
--- a/doc/src/snippets/declarative/loader/sizeitem.qml
+++ b/doc/src/snippets/qml/loader/sizeitem.qml
diff --git a/doc/src/snippets/declarative/loader/sizeloader.qml b/doc/src/snippets/qml/loader/sizeloader.qml
index 551324598c..551324598c 100644
--- a/doc/src/snippets/declarative/loader/sizeloader.qml
+++ b/doc/src/snippets/qml/loader/sizeloader.qml
diff --git a/doc/src/snippets/declarative/models/views-models-delegates.qml b/doc/src/snippets/qml/models/views-models-delegates.qml
index e9f872578f..e9f872578f 100644
--- a/doc/src/snippets/declarative/models/views-models-delegates.qml
+++ b/doc/src/snippets/qml/models/views-models-delegates.qml
diff --git a/doc/src/snippets/declarative/models/visual-model-and-view.qml b/doc/src/snippets/qml/models/visual-model-and-view.qml
index 97e443b675..97e443b675 100644
--- a/doc/src/snippets/declarative/models/visual-model-and-view.qml
+++ b/doc/src/snippets/qml/models/visual-model-and-view.qml
diff --git a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml b/doc/src/snippets/qml/mousearea/mousearea-snippet.qml
index 237c0c31b0..237c0c31b0 100644
--- a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml
+++ b/doc/src/snippets/qml/mousearea/mousearea-snippet.qml
diff --git a/doc/src/snippets/declarative/mousearea/mousearea.qml b/doc/src/snippets/qml/mousearea/mousearea.qml
index 1f35cd8b5f..1f35cd8b5f 100644
--- a/doc/src/snippets/declarative/mousearea/mousearea.qml
+++ b/doc/src/snippets/qml/mousearea/mousearea.qml
diff --git a/doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml b/doc/src/snippets/qml/mousearea/mouseareadragfilter.qml
index 922bfea636..922bfea636 100644
--- a/doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml
+++ b/doc/src/snippets/qml/mousearea/mouseareadragfilter.qml
diff --git a/doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml b/doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml
index e4c2ffb039..e4c2ffb039 100644
--- a/doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml
+++ b/doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml
diff --git a/doc/src/snippets/declarative/numberanimation.qml b/doc/src/snippets/qml/numberanimation.qml
index 404381863d..404381863d 100644
--- a/doc/src/snippets/declarative/numberanimation.qml
+++ b/doc/src/snippets/qml/numberanimation.qml
diff --git a/doc/src/snippets/declarative/parallelanimation.qml b/doc/src/snippets/qml/parallelanimation.qml
index 20f6ccc1df..20f6ccc1df 100644
--- a/doc/src/snippets/declarative/parallelanimation.qml
+++ b/doc/src/snippets/qml/parallelanimation.qml
diff --git a/doc/src/snippets/declarative/parentanimation.qml b/doc/src/snippets/qml/parentanimation.qml
index 60429ed61c..60429ed61c 100644
--- a/doc/src/snippets/declarative/parentanimation.qml
+++ b/doc/src/snippets/qml/parentanimation.qml
diff --git a/doc/src/snippets/declarative/parentchange.qml b/doc/src/snippets/qml/parentchange.qml
index 4ae4476e13..4ae4476e13 100644
--- a/doc/src/snippets/declarative/parentchange.qml
+++ b/doc/src/snippets/qml/parentchange.qml
diff --git a/doc/src/snippets/declarative/path/arcdirection.qml b/doc/src/snippets/qml/path/arcdirection.qml
index 7522649607..7522649607 100644
--- a/doc/src/snippets/declarative/path/arcdirection.qml
+++ b/doc/src/snippets/qml/path/arcdirection.qml
diff --git a/doc/src/snippets/declarative/path/arcradius.qml b/doc/src/snippets/qml/path/arcradius.qml
index 04f2919270..04f2919270 100644
--- a/doc/src/snippets/declarative/path/arcradius.qml
+++ b/doc/src/snippets/qml/path/arcradius.qml
diff --git a/doc/src/snippets/declarative/path/basicarc.qml b/doc/src/snippets/qml/path/basicarc.qml
index 562f2a0adf..562f2a0adf 100644
--- a/doc/src/snippets/declarative/path/basicarc.qml
+++ b/doc/src/snippets/qml/path/basicarc.qml
diff --git a/doc/src/snippets/declarative/path/basiccurve.qml b/doc/src/snippets/qml/path/basiccurve.qml
index feb783cb01..feb783cb01 100644
--- a/doc/src/snippets/declarative/path/basiccurve.qml
+++ b/doc/src/snippets/qml/path/basiccurve.qml
diff --git a/doc/src/snippets/declarative/path/largearc.qml b/doc/src/snippets/qml/path/largearc.qml
index 69ce953c92..69ce953c92 100644
--- a/doc/src/snippets/declarative/path/largearc.qml
+++ b/doc/src/snippets/qml/path/largearc.qml
diff --git a/doc/src/snippets/declarative/pathinterpolator.qml b/doc/src/snippets/qml/pathinterpolator.qml
index 77cc664e27..77cc664e27 100644
--- a/doc/src/snippets/declarative/pathinterpolator.qml
+++ b/doc/src/snippets/qml/pathinterpolator.qml
diff --git a/doc/src/snippets/declarative/pathview/ContactModel.qml b/doc/src/snippets/qml/pathview/ContactModel.qml
index d191413f27..d191413f27 100644
--- a/doc/src/snippets/declarative/pathview/ContactModel.qml
+++ b/doc/src/snippets/qml/pathview/ContactModel.qml
diff --git a/doc/src/snippets/declarative/pathview/pathattributes.qml b/doc/src/snippets/qml/pathview/pathattributes.qml
index d555998650..d555998650 100644
--- a/doc/src/snippets/declarative/pathview/pathattributes.qml
+++ b/doc/src/snippets/qml/pathview/pathattributes.qml
diff --git a/doc/src/snippets/declarative/pathview/pathview.qml b/doc/src/snippets/qml/pathview/pathview.qml
index e5249d4cb6..e5249d4cb6 100644
--- a/doc/src/snippets/declarative/pathview/pathview.qml
+++ b/doc/src/snippets/qml/pathview/pathview.qml
diff --git a/doc/src/snippets/declarative/properties.qml b/doc/src/snippets/qml/properties.qml
index 21894b68e0..21894b68e0 100644
--- a/doc/src/snippets/declarative/properties.qml
+++ b/doc/src/snippets/qml/properties.qml
diff --git a/doc/src/snippets/declarative/propertyaction-sequential.qml b/doc/src/snippets/qml/propertyaction-sequential.qml
index 77d6ec194e..77d6ec194e 100644
--- a/doc/src/snippets/declarative/propertyaction-sequential.qml
+++ b/doc/src/snippets/qml/propertyaction-sequential.qml
diff --git a/doc/src/snippets/declarative/propertyaction.qml b/doc/src/snippets/qml/propertyaction.qml
index 5ddef30177..5ddef30177 100644
--- a/doc/src/snippets/declarative/propertyaction.qml
+++ b/doc/src/snippets/qml/propertyaction.qml
diff --git a/doc/src/snippets/declarative/propertyanimation.qml b/doc/src/snippets/qml/propertyanimation.qml
index b5781af94a..b5781af94a 100644
--- a/doc/src/snippets/declarative/propertyanimation.qml
+++ b/doc/src/snippets/qml/propertyanimation.qml
diff --git a/doc/src/snippets/declarative/propertychanges.qml b/doc/src/snippets/qml/propertychanges.qml
index 3be13f7861..3be13f7861 100644
--- a/doc/src/snippets/declarative/propertychanges.qml
+++ b/doc/src/snippets/qml/propertychanges.qml
diff --git a/doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml b/doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml
index da9610c117..da9610c117 100644
--- a/doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml
+++ b/doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml
diff --git a/doc/src/snippets/declarative/qml-data-models/listelements.qml b/doc/src/snippets/qml/qml-data-models/listelements.qml
index 0097423142..0097423142 100644
--- a/doc/src/snippets/declarative/qml-data-models/listelements.qml
+++ b/doc/src/snippets/qml/qml-data-models/listelements.qml
diff --git a/doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml b/doc/src/snippets/qml/qml-data-models/listmodel-listview.qml
index 406fada2ce..406fada2ce 100644
--- a/doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml
+++ b/doc/src/snippets/qml/qml-data-models/listmodel-listview.qml
diff --git a/doc/src/snippets/declarative/qml-documents/inline-component.qml b/doc/src/snippets/qml/qml-documents/inline-component.qml
index 7e01ca369b..7e01ca369b 100644
--- a/doc/src/snippets/declarative/qml-documents/inline-component.qml
+++ b/doc/src/snippets/qml/qml-documents/inline-component.qml
diff --git a/doc/src/snippets/declarative/qml-documents/inline-text-component.qml b/doc/src/snippets/qml/qml-documents/inline-text-component.qml
index 2405585b43..2405585b43 100644
--- a/doc/src/snippets/declarative/qml-documents/inline-text-component.qml
+++ b/doc/src/snippets/qml/qml-documents/inline-text-component.qml
diff --git a/doc/src/snippets/declarative/qml-documents/non-trivial.qml b/doc/src/snippets/qml/qml-documents/non-trivial.qml
index bd1b94a3cc..bd1b94a3cc 100644
--- a/doc/src/snippets/declarative/qml-documents/non-trivial.qml
+++ b/doc/src/snippets/qml/qml-documents/non-trivial.qml
diff --git a/doc/src/snippets/declarative/qml-documents/qmldocuments.qml b/doc/src/snippets/qml/qml-documents/qmldocuments.qml
index cf60741f0c..cf60741f0c 100644
--- a/doc/src/snippets/declarative/qml-documents/qmldocuments.qml
+++ b/doc/src/snippets/qml/qml-documents/qmldocuments.qml
diff --git a/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg b/doc/src/snippets/qml/qml-intro/images/qt-logo.svg
index 8c018be6a2..8c018be6a2 100644
--- a/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg
+++ b/doc/src/snippets/qml/qml-intro/images/qt-logo.svg
diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml b/doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml
index a9b873d4b0..a9b873d4b0 100644
--- a/doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml
diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h b/doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h
index fc5bbc6400..fc5bbc6400 100644
--- a/doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h
+++ b/doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h
diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml b/doc/src/snippets/qml/qtbinding/context-advanced/connections.qml
index 01f0cdefb9..01f0cdefb9 100644
--- a/doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml
+++ b/doc/src/snippets/qml/qtbinding/context-advanced/connections.qml
diff --git a/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp b/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp
new file mode 100644
index 0000000000..b9676e4b66
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+#include "applicationdata.h"
+
+//![0]
+int main(int argc, char *argv[]) {
+ QApplication app(argc, argv);
+
+ QQuickView view;
+
+ ApplicationData data;
+ view.rootContext()->setContextProperty("applicationData", &data);
+
+ view.setSource(QUrl::fromLocalFile("MyItem.qml"));
+ view.show();
+
+ return app.exec();
+}
+//![0]
+
diff --git a/doc/src/snippets/declarative/qtbinding/context/MyItem.qml b/doc/src/snippets/qml/qtbinding/context/MyItem.qml
index 3abf2411f0..3abf2411f0 100644
--- a/doc/src/snippets/declarative/qtbinding/context/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/context/MyItem.qml
diff --git a/doc/src/snippets/qml/qtbinding/context/main.cpp b/doc/src/snippets/qml/qtbinding/context/main.cpp
new file mode 100644
index 0000000000..0849a845a6
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/context/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//![0]
+QQuickView view;
+view.rootContext()->setContextProperty("currentDateTime", QDateTime::currentDateTime());
+view.setSource(QUrl::fromLocalFile("MyItem.qml"));
+view.show();
+//![0]
+
+ return app.exec();
+}
+
diff --git a/doc/src/snippets/qml/qtbinding/enums/imageviewer.h b/doc/src/snippets/qml/qtbinding/enums/imageviewer.h
new file mode 100644
index 0000000000..df9709953f
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/enums/imageviewer.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+//![start]
+class ImageViewer : public QQuickItem
+{
+ Q_OBJECT
+ Q_ENUMS(Status)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+public:
+ enum Status {
+ Ready,
+ Loading,
+ Error
+ };
+
+ Status status() const;
+//![start]
+
+ ImageViewer(QQuickItem *parent = 0);
+
+public slots:
+ void emitSignals();
+
+//![end]
+signals:
+ void statusChanged();
+};
+//![end]
diff --git a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml b/doc/src/snippets/qml/qtbinding/enums/standalone.qml
index 5641854175..5641854175 100644
--- a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml
+++ b/doc/src/snippets/qml/qtbinding/enums/standalone.qml
diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml
index e5ba588b25..e5ba588b25 100644
--- a/doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml
diff --git a/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp b/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp
new file mode 100644
index 0000000000..3d63e055a3
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+#include "myclass.h"
+
+//![0]
+int main(int argc, char *argv[]) {
+ QApplication app(argc, argv);
+
+ QQuickView view;
+ MyClass myClass;
+ view.rootContext()->setContextProperty("myObject", &myClass);
+
+ view.setSource(QUrl::fromLocalFile("MyItem.qml"));
+ view.show();
+
+ return app.exec();
+}
+//![0]
+
diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h b/doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h
index 8b6847ca99..8b6847ca99 100644
--- a/doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h
+++ b/doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h
diff --git a/doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml
index a8b41d55a0..a8b41d55a0 100644
--- a/doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml
diff --git a/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp b/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp
new file mode 100644
index 0000000000..5c6a0c507d
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//![0]
+// main.cpp
+QQmlEngine engine;
+QQmlComponent component(&engine, "MyItem.qml");
+QObject *object = component.create();
+
+QVariant returnedValue;
+QVariant msg = "Hello from C++";
+QMetaObject::invokeMethod(object, "myQmlFunction",
+ Q_RETURN_ARG(QVariant, returnedValue),
+ Q_ARG(QVariant, msg));
+
+qDebug() << "QML function returned:" << returnedValue.toString();
+delete object;
+//![0]
+}
+
diff --git a/doc/src/snippets/declarative/qtbinding/loading/MyItem.qml b/doc/src/snippets/qml/qtbinding/loading/MyItem.qml
index b496479c95..b496479c95 100644
--- a/doc/src/snippets/declarative/qtbinding/loading/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/loading/MyItem.qml
diff --git a/doc/src/snippets/qml/qtbinding/loading/main.cpp b/doc/src/snippets/qml/qtbinding/loading/main.cpp
new file mode 100644
index 0000000000..98ed4173f9
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/loading/main.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+static void withComponent()
+{
+//![QQmlComponent-a]
+// Using QQmlComponent
+QQmlEngine engine;
+QQmlComponent component(&engine,
+ QUrl::fromLocalFile("MyItem.qml"));
+QObject *object = component.create();
+//![QQmlComponent-a]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//![QQuickView]
+// Using QQuickView
+QQuickView view;
+view.setSource(QUrl::fromLocalFile("MyItem.qml"));
+view.show();
+QObject *object = view.rootObject();
+//![QQuickView]
+
+//![properties]
+object->setProperty("width", 500);
+QQmlProperty(object, "width").write(500);
+//![properties]
+
+//![cast]
+QQuickItem *item = qobject_cast<QQuickItem*>(object);
+item->setWidth(500);
+//![cast]
+
+//![findChild]
+QObject *rect = object->findChild<QObject*>("rect");
+if (rect)
+ rect->setProperty("color", "red");
+//![findChild]
+
+//![QQmlComponent-b]
+delete object;
+//![QQmlComponent-b]
+
+withComponent();
+
+ return app.exec();
+}
+
diff --git a/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h b/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h
new file mode 100644
index 0000000000..3559951693
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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$
+**
+****************************************************************************/
+//![0]
+#include <QtCore>
+#include <QtQml>
+
+class ImageViewer : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged)
+
+public:
+ void setImage(const QUrl &url);
+ QUrl image() const;
+
+signals:
+ void imageChanged();
+};
+//![0]
diff --git a/doc/src/snippets/qml/qtbinding/newelements/main.cpp b/doc/src/snippets/qml/qtbinding/newelements/main.cpp
new file mode 100644
index 0000000000..8ab7eb63f4
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/newelements/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+#include "imageviewer.h"
+
+void ImageViewer::setImage(const QUrl &url) {}
+QUrl ImageViewer::image() const { return QUrl(); }
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ //![register]
+ qmlRegisterType<ImageViewer>("MyLibrary", 1, 0, "ImageViewer");
+ //![register]
+
+ QQuickView view;
+ view.setSource(QUrl::fromLocalFile("standalone.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/doc/src/snippets/declarative/qtbinding/newelements/standalone.qml b/doc/src/snippets/qml/qtbinding/newelements/standalone.qml
index d2a8926bd0..d2a8926bd0 100644
--- a/doc/src/snippets/declarative/qtbinding/newelements/standalone.qml
+++ b/doc/src/snippets/qml/qtbinding/newelements/standalone.qml
diff --git a/doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml
index f2a14d92a4..f2a14d92a4 100644
--- a/doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml
diff --git a/doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h b/doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h
index b558e8528f..b558e8528f 100644
--- a/doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h
+++ b/doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h
diff --git a/doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml
index 87015eac24..87015eac24 100644
--- a/doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml
diff --git a/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp b/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp
new file mode 100644
index 0000000000..15cb517c7b
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//![0]
+QQmlEngine engine;
+QQmlComponent component(&engine, "MyItem.qml");
+QObject *object = component.create();
+
+qDebug() << "Property value:" << QQmlProperty::read(object, "someNumber").toInt();
+QQmlProperty::write(object, "someNumber", 5000);
+
+qDebug() << "Property value:" << object->property("someNumber").toInt();
+object->setProperty("someNumber", 100);
+//![0]
+
+ return app.exec();
+}
+
diff --git a/doc/src/snippets/declarative/qtbinding/resources/example.qrc b/doc/src/snippets/qml/qtbinding/resources/example.qrc
index 5e4941512b..5e4941512b 100644
--- a/doc/src/snippets/declarative/qtbinding/resources/example.qrc
+++ b/doc/src/snippets/qml/qtbinding/resources/example.qrc
diff --git a/doc/src/snippets/qml/qtbinding/resources/main.cpp b/doc/src/snippets/qml/qtbinding/resources/main.cpp
new file mode 100644
index 0000000000..2902064fc9
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/resources/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QApplication>
+#include <QQuickView>
+#include <QQmlContext>
+
+//![0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QQuickView view;
+ view.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+
+ return app.exec();
+}
+//![0]
+
diff --git a/doc/src/snippets/declarative/qtbinding/resources/main.qml b/doc/src/snippets/qml/qtbinding/resources/main.qml
index 670d1a5309..670d1a5309 100644
--- a/doc/src/snippets/declarative/qtbinding/resources/main.qml
+++ b/doc/src/snippets/qml/qtbinding/resources/main.qml
diff --git a/doc/src/snippets/qml/qtbinding/resources/resources.pro b/doc/src/snippets/qml/qtbinding/resources/resources.pro
new file mode 100644
index 0000000000..5aee288a6e
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/resources/resources.pro
@@ -0,0 +1,4 @@
+QT += qml
+
+SOURCES += main.cpp
+RESOURCES += example.qrc
diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml
index 17df7704c5..17df7704c5 100644
--- a/doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml
diff --git a/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h b/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h
new file mode 100644
index 0000000000..3423295234
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+//![start]
+class ImageViewer : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged)
+public:
+//![start]
+ ImageViewer(QQuickItem *item = 0);
+
+ void setImage(const QUrl &url) {}
+ QUrl image() const { return QUrl(); }
+
+public slots:
+ void emitSignals();
+
+//![end]
+signals:
+ void imageChanged();
+ void loadingError(const QString &errorMsg);
+};
+//![end]
+
diff --git a/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp b/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp
new file mode 100644
index 0000000000..402e811913
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+#include "imageviewer.h"
+
+
+ImageViewer::ImageViewer(QQuickItem *item)
+ : QQuickItem(item)
+{
+ QTimer::singleShot(0, this, SLOT(emitSignals()));
+}
+
+void ImageViewer::emitSignals()
+{
+ emit imageChanged();
+ emit loadingError("some error message");
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<ImageViewer>("MyLibrary", 1, 0, "ImageViewer");
+
+ QQuickView standalone;
+ standalone.setSource(QUrl::fromLocalFile("standalone.qml"));
+ standalone.show();
+
+//![connections]
+ImageViewer viewer;
+
+QQuickView view;
+view.rootContext()->setContextProperty("imageViewer", &viewer);
+
+view.setSource(QUrl::fromLocalFile("MyItem.qml"));
+view.show();
+//![connections]
+
+ return app.exec();
+}
+
+
diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml b/doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml
index 33afc1f39c..33afc1f39c 100644
--- a/doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml
+++ b/doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml
diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml
index 9269b51863..9269b51863 100644
--- a/doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml
diff --git a/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp b/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp
new file mode 100644
index 0000000000..8528d9ce5e
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+//![0]
+int main(int argc, char *argv[]) {
+ QApplication app(argc, argv);
+
+ QQuickView view(QUrl::fromLocalFile("MyItem.qml"));
+ QObject *item = view.rootObject();
+
+ MyClass myClass;
+ QObject::connect(item, SIGNAL(qmlSignal(QString)),
+ &myClass, SLOT(cppSlot(QString)));
+
+ view.show();
+ return app.exec();
+}
+//![0]
+
+#include "moc_main.cpp"
diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h b/doc/src/snippets/qml/qtbinding/signals-qml/myclass.h
index 6275de6b2c..6275de6b2c 100644
--- a/doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h
+++ b/doc/src/snippets/qml/qtbinding/signals-qml/myclass.h
diff --git a/doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml b/doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml
index ff4be87795..ff4be87795 100644
--- a/doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml
+++ b/doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml
diff --git a/doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp b/doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp
new file mode 100644
index 0000000000..a10b9a8c12
--- /dev/null
+++ b/doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <QtCore>
+#include <QtQml>
+
+int main(int argc, char *argv[]) {
+ QApplication app(argc, argv);
+
+//![0]
+// C++
+QQuickView view(QUrl::fromLocalFile("MyItem.qml"));
+
+QVariantList list;
+list << 10 << Qt::green << "bottles";
+
+QVariantMap map;
+map.insert("language", "QML");
+map.insert("released", QDate(2010, 9, 21));
+
+QMetaObject::invokeMethod(view.rootObject(), "readValues",
+ Q_ARG(QVariant, QVariant::fromValue(list)),
+ Q_ARG(QVariant, QVariant::fromValue(map)));
+//![0]
+
+ view.setSource(QUrl::fromLocalFile("MyItem.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/doc/src/snippets/declarative/qtobject.qml b/doc/src/snippets/qml/qtobject.qml
index 04811b6316..04811b6316 100644
--- a/doc/src/snippets/declarative/qtobject.qml
+++ b/doc/src/snippets/qml/qtobject.qml
diff --git a/doc/src/snippets/declarative/rectangle/rect-border-width.qml b/doc/src/snippets/qml/rectangle/rect-border-width.qml
index 6dd4dbe739..6dd4dbe739 100644
--- a/doc/src/snippets/declarative/rectangle/rect-border-width.qml
+++ b/doc/src/snippets/qml/rectangle/rect-border-width.qml
diff --git a/doc/src/snippets/declarative/rectangle/rectangle-colors.qml b/doc/src/snippets/qml/rectangle/rectangle-colors.qml
index 70f7a203f4..70f7a203f4 100644
--- a/doc/src/snippets/declarative/rectangle/rectangle-colors.qml
+++ b/doc/src/snippets/qml/rectangle/rectangle-colors.qml
diff --git a/doc/src/snippets/declarative/rectangle/rectangle-gradient.qml b/doc/src/snippets/qml/rectangle/rectangle-gradient.qml
index e8146a6467..e8146a6467 100644
--- a/doc/src/snippets/declarative/rectangle/rectangle-gradient.qml
+++ b/doc/src/snippets/qml/rectangle/rectangle-gradient.qml
diff --git a/doc/src/snippets/declarative/rectangle/rectangle.qml b/doc/src/snippets/qml/rectangle/rectangle.qml
index c315a27da0..c315a27da0 100644
--- a/doc/src/snippets/declarative/rectangle/rectangle.qml
+++ b/doc/src/snippets/qml/rectangle/rectangle.qml
diff --git a/doc/src/snippets/declarative/repeaters/repeater-grid-index.qml b/doc/src/snippets/qml/repeaters/repeater-grid-index.qml
index 0f2b770d82..0f2b770d82 100644
--- a/doc/src/snippets/declarative/repeaters/repeater-grid-index.qml
+++ b/doc/src/snippets/qml/repeaters/repeater-grid-index.qml
diff --git a/doc/src/snippets/declarative/repeaters/repeater.qml b/doc/src/snippets/qml/repeaters/repeater.qml
index 856b038a04..856b038a04 100644
--- a/doc/src/snippets/declarative/repeaters/repeater.qml
+++ b/doc/src/snippets/qml/repeaters/repeater.qml
diff --git a/doc/src/snippets/declarative/reusablecomponents/Button.qml b/doc/src/snippets/qml/reusablecomponents/Button.qml
index cedc782f75..cedc782f75 100644
--- a/doc/src/snippets/declarative/reusablecomponents/Button.qml
+++ b/doc/src/snippets/qml/reusablecomponents/Button.qml
diff --git a/doc/src/snippets/declarative/reusablecomponents/application.qml b/doc/src/snippets/qml/reusablecomponents/application.qml
index 42428ce25e..42428ce25e 100644
--- a/doc/src/snippets/declarative/reusablecomponents/application.qml
+++ b/doc/src/snippets/qml/reusablecomponents/application.qml
diff --git a/doc/src/snippets/declarative/reusablecomponents/component.qml b/doc/src/snippets/qml/reusablecomponents/component.qml
index 9a60468d73..9a60468d73 100644
--- a/doc/src/snippets/declarative/reusablecomponents/component.qml
+++ b/doc/src/snippets/qml/reusablecomponents/component.qml
diff --git a/doc/src/snippets/declarative/reusablecomponents/focusbutton.qml b/doc/src/snippets/qml/reusablecomponents/focusbutton.qml
index 34fc6294e2..34fc6294e2 100644
--- a/doc/src/snippets/declarative/reusablecomponents/focusbutton.qml
+++ b/doc/src/snippets/qml/reusablecomponents/focusbutton.qml
diff --git a/doc/src/snippets/declarative/reusablecomponents/qmldir b/doc/src/snippets/qml/reusablecomponents/qmldir
index 253732de01..253732de01 100644
--- a/doc/src/snippets/declarative/reusablecomponents/qmldir
+++ b/doc/src/snippets/qml/reusablecomponents/qmldir
diff --git a/doc/src/snippets/declarative/righttoleft.qml b/doc/src/snippets/qml/righttoleft.qml
index 0566be2f67..0566be2f67 100644
--- a/doc/src/snippets/declarative/righttoleft.qml
+++ b/doc/src/snippets/qml/righttoleft.qml
diff --git a/doc/src/snippets/declarative/righttoleft/Child.qml b/doc/src/snippets/qml/righttoleft/Child.qml
index 50068540cb..50068540cb 100644
--- a/doc/src/snippets/declarative/righttoleft/Child.qml
+++ b/doc/src/snippets/qml/righttoleft/Child.qml
diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/qml/rotation.qml
index c7f9df3a9b..c7f9df3a9b 100644
--- a/doc/src/snippets/declarative/rotation.qml
+++ b/doc/src/snippets/qml/rotation.qml
diff --git a/doc/src/snippets/declarative/rotationanimation.qml b/doc/src/snippets/qml/rotationanimation.qml
index caa1ce8207..caa1ce8207 100644
--- a/doc/src/snippets/declarative/rotationanimation.qml
+++ b/doc/src/snippets/qml/rotationanimation.qml
diff --git a/doc/src/snippets/declarative/row.qml b/doc/src/snippets/qml/row.qml
index 3e505717d6..3e505717d6 100644
--- a/doc/src/snippets/declarative/row.qml
+++ b/doc/src/snippets/qml/row.qml
diff --git a/doc/src/snippets/declarative/row/row.qml b/doc/src/snippets/qml/row/row.qml
index 465baa577b..465baa577b 100644
--- a/doc/src/snippets/declarative/row/row.qml
+++ b/doc/src/snippets/qml/row/row.qml
diff --git a/doc/src/snippets/declarative/script.js b/doc/src/snippets/qml/script.js
index f55dee3507..f55dee3507 100644
--- a/doc/src/snippets/declarative/script.js
+++ b/doc/src/snippets/qml/script.js
diff --git a/doc/src/snippets/declarative/sequentialanimation.qml b/doc/src/snippets/qml/sequentialanimation.qml
index 73923e4ea0..73923e4ea0 100644
--- a/doc/src/snippets/declarative/sequentialanimation.qml
+++ b/doc/src/snippets/qml/sequentialanimation.qml
diff --git a/doc/src/snippets/declarative/smoothedanimation.qml b/doc/src/snippets/qml/smoothedanimation.qml
index ba6f505976..ba6f505976 100644
--- a/doc/src/snippets/declarative/smoothedanimation.qml
+++ b/doc/src/snippets/qml/smoothedanimation.qml
diff --git a/doc/src/snippets/declarative/springanimation.qml b/doc/src/snippets/qml/springanimation.qml
index e04c483405..e04c483405 100644
--- a/doc/src/snippets/declarative/springanimation.qml
+++ b/doc/src/snippets/qml/springanimation.qml
diff --git a/doc/src/snippets/declarative/state-when.qml b/doc/src/snippets/qml/state-when.qml
index de9fb39cef..de9fb39cef 100644
--- a/doc/src/snippets/declarative/state-when.qml
+++ b/doc/src/snippets/qml/state-when.qml
diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/qml/state.qml
index 5948cba770..5948cba770 100644
--- a/doc/src/snippets/declarative/state.qml
+++ b/doc/src/snippets/qml/state.qml
diff --git a/doc/src/snippets/declarative/states.qml b/doc/src/snippets/qml/states.qml
index aeb805f38e..aeb805f38e 100644
--- a/doc/src/snippets/declarative/states.qml
+++ b/doc/src/snippets/qml/states.qml
diff --git a/doc/src/snippets/declarative/states/statechangescript.qml b/doc/src/snippets/qml/states/statechangescript.qml
index 262938fc9c..262938fc9c 100644
--- a/doc/src/snippets/declarative/states/statechangescript.qml
+++ b/doc/src/snippets/qml/states/statechangescript.qml
diff --git a/doc/src/snippets/declarative/systempalette.qml b/doc/src/snippets/qml/systempalette.qml
index 4cb42dee93..4cb42dee93 100644
--- a/doc/src/snippets/declarative/systempalette.qml
+++ b/doc/src/snippets/qml/systempalette.qml
diff --git a/doc/src/snippets/qml/text/onLinkActivated.qml b/doc/src/snippets/qml/text/onLinkActivated.qml
new file mode 100644
index 0000000000..03641d989e
--- /dev/null
+++ b/doc/src/snippets/qml/text/onLinkActivated.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml 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 QtQuick 2.0
+
+Rectangle {
+ width: 700; height: 400
+
+//![0]
+ Text {
+ textFormat: Text.RichText
+ text: "The main website is at <a href=\"http://qt.nokia.com\">Nokia Qt DF</a>."
+ onLinkActivated: console.log(link + " link activated")
+ }
+//![0]
+
+}
+
diff --git a/doc/src/snippets/declarative/texthandling.qml b/doc/src/snippets/qml/texthandling.qml
index 03e5011202..03e5011202 100644
--- a/doc/src/snippets/declarative/texthandling.qml
+++ b/doc/src/snippets/qml/texthandling.qml
diff --git a/doc/src/snippets/declarative/transition-from-to-modified.qml b/doc/src/snippets/qml/transition-from-to-modified.qml
index 184e95afe2..184e95afe2 100644
--- a/doc/src/snippets/declarative/transition-from-to-modified.qml
+++ b/doc/src/snippets/qml/transition-from-to-modified.qml
diff --git a/doc/src/snippets/declarative/transition-from-to.qml b/doc/src/snippets/qml/transition-from-to.qml
index c876f5cb9c..c876f5cb9c 100644
--- a/doc/src/snippets/declarative/transition-from-to.qml
+++ b/doc/src/snippets/qml/transition-from-to.qml
diff --git a/doc/src/snippets/declarative/transition-reversible.qml b/doc/src/snippets/qml/transition-reversible.qml
index 4f7ae83468..4f7ae83468 100644
--- a/doc/src/snippets/declarative/transition-reversible.qml
+++ b/doc/src/snippets/qml/transition-reversible.qml
diff --git a/doc/src/snippets/declarative/transition.qml b/doc/src/snippets/qml/transition.qml
index 614c5d364f..614c5d364f 100644
--- a/doc/src/snippets/declarative/transition.qml
+++ b/doc/src/snippets/qml/transition.qml
diff --git a/doc/src/snippets/declarative/transitions-list.qml b/doc/src/snippets/qml/transitions-list.qml
index f2ba768559..f2ba768559 100644
--- a/doc/src/snippets/declarative/transitions-list.qml
+++ b/doc/src/snippets/qml/transitions-list.qml
diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml
index cb94acb2b1..cb94acb2b1 100644
--- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml
diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml
index 84c4848a76..84c4848a76 100644
--- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml
diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml
index 89353b40e8..89353b40e8 100644
--- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml
diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml
index 0644caaec7..0644caaec7 100644
--- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml
diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml
index 4b1685719d..4b1685719d 100644
--- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml
diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml
index 0e7d1e8d82..0e7d1e8d82 100644
--- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml
diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml
index 7fa7e48f82..7fa7e48f82 100644
--- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml
diff --git a/doc/src/snippets/declarative/visualdatagroup.qml b/doc/src/snippets/qml/visualdatagroup.qml
index 46ac9a3d7a..46ac9a3d7a 100644
--- a/doc/src/snippets/declarative/visualdatagroup.qml
+++ b/doc/src/snippets/qml/visualdatagroup.qml
diff --git a/doc/src/snippets/declarative/visualdatamodel.qml b/doc/src/snippets/qml/visualdatamodel.qml
index 87b836e224..87b836e224 100644
--- a/doc/src/snippets/declarative/visualdatamodel.qml
+++ b/doc/src/snippets/qml/visualdatamodel.qml
diff --git a/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp
new file mode 100644
index 0000000000..4468d06db4
--- /dev/null
+++ b/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml 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$
+**
+****************************************************************************/
+#include <QQuickView>
+#include <QQmlContext>
+
+#include <QApplication>
+#include <QDirModel>
+
+//![0]
+int main(int argc, char ** argv)
+{
+ QApplication app(argc, argv);
+
+ QQuickView view;
+
+ QDirModel model;
+ view.rootContext()->setContextProperty("dirModel", &model);
+
+ view.setSource(QUrl::fromLocalFile("view.qml"));
+ view.show();
+
+ return app.exec();
+}
+//![0]
+
diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml b/doc/src/snippets/qml/visualdatamodel_rootindex/view.qml
index 24d6b47f8d..24d6b47f8d 100644
--- a/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml
+++ b/doc/src/snippets/qml/visualdatamodel_rootindex/view.qml
diff --git a/doc/src/snippets/declarative/workerscript.qml b/doc/src/snippets/qml/workerscript.qml
index 6af6b47766..6af6b47766 100644
--- a/doc/src/snippets/declarative/workerscript.qml
+++ b/doc/src/snippets/qml/workerscript.qml
diff --git a/doc/src/snippets/declarative/xmlrole.qml b/doc/src/snippets/qml/xmlrole.qml
index 34868fb76d..34868fb76d 100644
--- a/doc/src/snippets/declarative/xmlrole.qml
+++ b/doc/src/snippets/qml/xmlrole.qml
diff --git a/doc/src/snippets/declarative/xmlrole.xml b/doc/src/snippets/qml/xmlrole.xml
index c9f999e523..c9f999e523 100644
--- a/doc/src/snippets/declarative/xmlrole.xml
+++ b/doc/src/snippets/qml/xmlrole.xml
diff --git a/doc/src/snippets/qtjavascript/evaluation/main.cpp b/doc/src/snippets/qtjavascript/evaluation/main.cpp
index 8d1cbf0484..3d3e3bfda2 100644
--- a/doc/src/snippets/qtjavascript/evaluation/main.cpp
+++ b/doc/src/snippets/qtjavascript/evaluation/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtDeclarative>
+#include <QtQml>
int main(int argc, char *argv[])
{
diff --git a/doc/src/snippets/qtjavascript/registeringobjects/main.cpp b/doc/src/snippets/qtjavascript/registeringobjects/main.cpp
index 27d696da63..f34c1061fe 100644
--- a/doc/src/snippets/qtjavascript/registeringobjects/main.cpp
+++ b/doc/src/snippets/qtjavascript/registeringobjects/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include <QObject>
-#include <QtDeclarative>
+#include <QtQml>
#include "myobject.h"
int main(int argc, char *argv[])
diff --git a/doc/src/snippets/qtjavascript/registeringvalues/main.cpp b/doc/src/snippets/qtjavascript/registeringvalues/main.cpp
index be2d293cf7..f168f4f554 100644
--- a/doc/src/snippets/qtjavascript/registeringvalues/main.cpp
+++ b/doc/src/snippets/qtjavascript/registeringvalues/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtDeclarative>
+#include <QtQml>
int main(int argc, char *argv[])
{
diff --git a/doc/src/whatsnew.qdoc b/doc/src/whatsnew.qdoc
index 1c92cdb16b..c791e72c25 100644
--- a/doc/src/whatsnew.qdoc
+++ b/doc/src/whatsnew.qdoc
@@ -67,8 +67,8 @@ Properties of the "var" type may hold JavaScript references. See \l{QML Basic T
QML properties of type \c var and \c variant can now hold pixmaps. See \l{Scarce Resources in JavaScript} for more information
-QDeclarativeExpression can now be directly (and more efficiently) constructed from a
-QDeclarativeScriptString.
+QQmlExpression can now be directly (and more efficiently) constructed from a
+QQmlScriptString.
Support for certain sequence types (QList<int>, QList<qreal>, QList<bool>, QList<QUrl>, QList<QString> and QStringList) has been improved.
QObjects can define Q_PROPERTYs of these types which can be accessed transparently from JavaScript. See the section on
diff --git a/examples/HACKING b/examples/HACKING
index 7eea4975ac..9539d2d129 100644
--- a/examples/HACKING
+++ b/examples/HACKING
@@ -1,4 +1,4 @@
-Some guidelines for QtDeclarative examples
+Some guidelines for QtQml examples
Snippets
---
diff --git a/examples/demos/calculator/CalculatorCore/Button.qml b/examples/demos/calculator/CalculatorCore/Button.qml
index 872fc81174..e7b3637b4c 100644
--- a/examples/demos/calculator/CalculatorCore/Button.qml
+++ b/examples/demos/calculator/CalculatorCore/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/calculator/CalculatorCore/Display.qml b/examples/demos/calculator/CalculatorCore/Display.qml
index 3333484971..3dceeab169 100644
--- a/examples/demos/calculator/CalculatorCore/Display.qml
+++ b/examples/demos/calculator/CalculatorCore/Display.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/calculator/calculator-desktop.qml b/examples/demos/calculator/calculator-desktop.qml
index 7e72f50beb..be65c77170 100644
--- a/examples/demos/calculator/calculator-desktop.qml
+++ b/examples/demos/calculator/calculator-desktop.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/calculator/calculator-mobile.qml b/examples/demos/calculator/calculator-mobile.qml
index b4fc372b39..7ee622f698 100644
--- a/examples/demos/calculator/calculator-mobile.qml
+++ b/examples/demos/calculator/calculator-mobile.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/calculator/calculator.pro b/examples/demos/calculator/calculator.pro
index 3bf3b8ca2f..297d5cfdbb 100644
--- a/examples/demos/calculator/calculator.pro
+++ b/examples/demos/calculator/calculator.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += quick declarative
+QT += quick qml
SOURCES += main.cpp
target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calculator
diff --git a/examples/demos/calculator/main.cpp b/examples/demos/calculator/main.cpp
index c7f9b29952..fafe14fe46 100644
--- a/examples/demos/calculator/main.cpp
+++ b/examples/demos/calculator/main.cpp
@@ -41,7 +41,7 @@
#include <QGuiApplication>
#include <QStringList>
#include <QQuickView>
-#include <QDeclarativeEngine>
+#include <QQmlEngine>
void usage()
{
diff --git a/examples/demos/flickr/content/Button.qml b/examples/demos/flickr/content/Button.qml
index d6a8d3e001..57f846aec3 100644
--- a/examples/demos/flickr/content/Button.qml
+++ b/examples/demos/flickr/content/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/GridDelegate.qml b/examples/demos/flickr/content/GridDelegate.qml
index 794d768c74..f8838bd609 100644
--- a/examples/demos/flickr/content/GridDelegate.qml
+++ b/examples/demos/flickr/content/GridDelegate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/ImageDetails.qml b/examples/demos/flickr/content/ImageDetails.qml
index 83f2537d65..42b5e845ea 100644
--- a/examples/demos/flickr/content/ImageDetails.qml
+++ b/examples/demos/flickr/content/ImageDetails.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/ListDelegate.qml b/examples/demos/flickr/content/ListDelegate.qml
index 9c239151f1..00f837f862 100644
--- a/examples/demos/flickr/content/ListDelegate.qml
+++ b/examples/demos/flickr/content/ListDelegate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/Progress.qml b/examples/demos/flickr/content/Progress.qml
index 81f1e79ed6..ed2629b48a 100644
--- a/examples/demos/flickr/content/Progress.qml
+++ b/examples/demos/flickr/content/Progress.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/RssModel.qml b/examples/demos/flickr/content/RssModel.qml
index f28a23d502..51cea498e6 100644
--- a/examples/demos/flickr/content/RssModel.qml
+++ b/examples/demos/flickr/content/RssModel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/ScrollBar.qml b/examples/demos/flickr/content/ScrollBar.qml
index 388e43dc2d..7c62ad088f 100644
--- a/examples/demos/flickr/content/ScrollBar.qml
+++ b/examples/demos/flickr/content/ScrollBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/Slider.qml b/examples/demos/flickr/content/Slider.qml
index 0f9e8b20f2..c4e743641f 100644
--- a/examples/demos/flickr/content/Slider.qml
+++ b/examples/demos/flickr/content/Slider.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/TitleBar.qml b/examples/demos/flickr/content/TitleBar.qml
index 3dab005a11..223939f81a 100644
--- a/examples/demos/flickr/content/TitleBar.qml
+++ b/examples/demos/flickr/content/TitleBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/ToolBar.qml b/examples/demos/flickr/content/ToolBar.qml
index e82be63e7e..356993b41a 100644
--- a/examples/demos/flickr/content/ToolBar.qml
+++ b/examples/demos/flickr/content/ToolBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/content/UnifiedDelegate.qml b/examples/demos/flickr/content/UnifiedDelegate.qml
index 00a777b0a1..0b068c0abe 100644
--- a/examples/demos/flickr/content/UnifiedDelegate.qml
+++ b/examples/demos/flickr/content/UnifiedDelegate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/flickr-90.qml b/examples/demos/flickr/flickr-90.qml
index ae06957649..b95b1c9872 100644
--- a/examples/demos/flickr/flickr-90.qml
+++ b/examples/demos/flickr/flickr-90.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/flickr/flickr.qml b/examples/demos/flickr/flickr.qml
index 74c41f185b..98ca5197ab 100644
--- a/examples/demos/flickr/flickr.qml
+++ b/examples/demos/flickr/flickr.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/minehunt/MinehuntCore/Explosion.qml b/examples/demos/minehunt/MinehuntCore/Explosion.qml
index 0983b68db4..a1b4292bcf 100644
--- a/examples/demos/minehunt/MinehuntCore/Explosion.qml
+++ b/examples/demos/minehunt/MinehuntCore/Explosion.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/minehunt/MinehuntCore/Tile.qml b/examples/demos/minehunt/MinehuntCore/Tile.qml
index 14c1f51f9e..1180b6f584 100644
--- a/examples/demos/minehunt/MinehuntCore/Tile.qml
+++ b/examples/demos/minehunt/MinehuntCore/Tile.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/minehunt/main.cpp b/examples/demos/minehunt/main.cpp
index 47c0436969..0aa11a1d7a 100644
--- a/examples/demos/minehunt/main.cpp
+++ b/examples/demos/minehunt/main.cpp
@@ -41,8 +41,8 @@
#include <QtGui/QGuiApplication>
#include <QtQuick/qquickview.h>
-#include <QtDeclarative/QDeclarativeContext>
-#include <QtDeclarative/QDeclarativeEngine>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
#include "minehunt.h"
diff --git a/examples/demos/minehunt/minehunt.cpp b/examples/demos/minehunt/minehunt.cpp
index facbec375a..cde30278b3 100644
--- a/examples/demos/minehunt/minehunt.cpp
+++ b/examples/demos/minehunt/minehunt.cpp
@@ -45,25 +45,25 @@
#include "minehunt.h"
-void tilesPropAppend(QDeclarativeListProperty<TileData>* prop, TileData* value)
+void tilesPropAppend(QQmlListProperty<TileData>* prop, TileData* value)
{
Q_UNUSED(prop);
Q_UNUSED(value);
return; //Append not supported
}
-int tilesPropCount(QDeclarativeListProperty<TileData>* prop)
+int tilesPropCount(QQmlListProperty<TileData>* prop)
{
return static_cast<QList<TileData*>*>(prop->data)->count();
}
-TileData* tilesPropAt(QDeclarativeListProperty<TileData>* prop, int index)
+TileData* tilesPropAt(QQmlListProperty<TileData>* prop, int index)
{
return static_cast<QList<TileData*>*>(prop->data)->at(index);
}
-QDeclarativeListProperty<TileData> MinehuntGame::tiles(){
- return QDeclarativeListProperty<TileData>(this, &_tiles, &tilesPropAppend,
+QQmlListProperty<TileData> MinehuntGame::tiles(){
+ return QQmlListProperty<TileData>(this, &_tiles, &tilesPropAppend,
&tilesPropCount, &tilesPropAt, 0);
}
diff --git a/examples/demos/minehunt/minehunt.h b/examples/demos/minehunt/minehunt.h
index a0ae23fa8a..34bab71218 100644
--- a/examples/demos/minehunt/minehunt.h
+++ b/examples/demos/minehunt/minehunt.h
@@ -40,7 +40,7 @@
****************************************************************************/
-#include <qdeclarative.h>
+#include <qqml.h>
class TileData : public QObject
{
@@ -85,8 +85,8 @@ class MinehuntGame : public QObject
public:
MinehuntGame();
- Q_PROPERTY(QDeclarativeListProperty<TileData> tiles READ tiles CONSTANT)
- QDeclarativeListProperty<TileData> tiles();
+ Q_PROPERTY(QQmlListProperty<TileData> tiles READ tiles CONSTANT)
+ QQmlListProperty<TileData> tiles();
Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
bool isPlaying() {return playing;}
diff --git a/examples/demos/minehunt/minehunt.pro b/examples/demos/minehunt/minehunt.pro
index 81b6b80486..78e874d805 100644
--- a/examples/demos/minehunt/minehunt.pro
+++ b/examples/demos/minehunt/minehunt.pro
@@ -1,4 +1,4 @@
-QT += declarative quick
+QT += qml quick
HEADERS += minehunt.h
SOURCES += main.cpp minehunt.cpp
diff --git a/examples/demos/minehunt/minehunt.qml b/examples/demos/minehunt/minehunt.qml
index 7c4948a3bb..42dc408fff 100644
--- a/examples/demos/minehunt/minehunt.qml
+++ b/examples/demos/minehunt/minehunt.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
index f183c4b2a0..164f47faa9 100644
--- a/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
+++ b/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
index 2b1a75f369..867c268399 100644
--- a/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
+++ b/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/PhotoViewerCore/Button.qml b/examples/demos/photoviewer/PhotoViewerCore/Button.qml
index fcce969fbd..8f4177c097 100644
--- a/examples/demos/photoviewer/PhotoViewerCore/Button.qml
+++ b/examples/demos/photoviewer/PhotoViewerCore/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml
index 5d845938c7..435ad2644f 100644
--- a/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml
+++ b/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
index b972c938eb..5d4e5aee5d 100644
--- a/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
+++ b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml
index 43c936e342..58beef57f3 100644
--- a/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml
+++ b/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml b/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml
index ab818924ac..1598977bb1 100644
--- a/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml
+++ b/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/PhotoViewerCore/Tag.qml b/examples/demos/photoviewer/PhotoViewerCore/Tag.qml
index 2b546a3ac6..ed4a248a7b 100644
--- a/examples/demos/photoviewer/PhotoViewerCore/Tag.qml
+++ b/examples/demos/photoviewer/PhotoViewerCore/Tag.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/photoviewer/photoviewer.qml b/examples/demos/photoviewer/photoviewer.qml
index 918438832b..208720b9e6 100644
--- a/examples/demos/photoviewer/photoviewer.qml
+++ b/examples/demos/photoviewer/photoviewer.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/BlasterHardpoint.qml b/examples/demos/plasmapatrol/content/BlasterHardpoint.qml
index 4ac30d0202..10c50d43c8 100644
--- a/examples/demos/plasmapatrol/content/BlasterHardpoint.qml
+++ b/examples/demos/plasmapatrol/content/BlasterHardpoint.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/Button.qml b/examples/demos/plasmapatrol/content/Button.qml
index 405b99304f..992be295fc 100644
--- a/examples/demos/plasmapatrol/content/Button.qml
+++ b/examples/demos/plasmapatrol/content/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/CannonHardpoint.qml b/examples/demos/plasmapatrol/content/CannonHardpoint.qml
index c4aa412760..48eb9d171a 100644
--- a/examples/demos/plasmapatrol/content/CannonHardpoint.qml
+++ b/examples/demos/plasmapatrol/content/CannonHardpoint.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/ChoiceBox.qml b/examples/demos/plasmapatrol/content/ChoiceBox.qml
index a678bc9dd4..6e21101f2e 100644
--- a/examples/demos/plasmapatrol/content/ChoiceBox.qml
+++ b/examples/demos/plasmapatrol/content/ChoiceBox.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/Cruiser.qml b/examples/demos/plasmapatrol/content/Cruiser.qml
index c689879dce..c469eb46d2 100644
--- a/examples/demos/plasmapatrol/content/Cruiser.qml
+++ b/examples/demos/plasmapatrol/content/Cruiser.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/Frigate.qml b/examples/demos/plasmapatrol/content/Frigate.qml
index de099bed72..92c63b87d1 100644
--- a/examples/demos/plasmapatrol/content/Frigate.qml
+++ b/examples/demos/plasmapatrol/content/Frigate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/Hardpoint.qml b/examples/demos/plasmapatrol/content/Hardpoint.qml
index 5c7fb5521b..9e6057057d 100644
--- a/examples/demos/plasmapatrol/content/Hardpoint.qml
+++ b/examples/demos/plasmapatrol/content/Hardpoint.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/HelpScreens.qml b/examples/demos/plasmapatrol/content/HelpScreens.qml
index 9297f86f31..db70c6ee90 100644
--- a/examples/demos/plasmapatrol/content/HelpScreens.qml
+++ b/examples/demos/plasmapatrol/content/HelpScreens.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/LaserHardpoint.qml b/examples/demos/plasmapatrol/content/LaserHardpoint.qml
index 87ac3e9e62..a7baed604b 100644
--- a/examples/demos/plasmapatrol/content/LaserHardpoint.qml
+++ b/examples/demos/plasmapatrol/content/LaserHardpoint.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml
index 1d856b5805..e1924c3467 100644
--- a/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml
+++ b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/SequentialLoader.qml b/examples/demos/plasmapatrol/content/SequentialLoader.qml
index eaef87fe57..3707759ce3 100644
--- a/examples/demos/plasmapatrol/content/SequentialLoader.qml
+++ b/examples/demos/plasmapatrol/content/SequentialLoader.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/Ship.qml b/examples/demos/plasmapatrol/content/Ship.qml
index a928cd2a2e..bd023b1dc2 100644
--- a/examples/demos/plasmapatrol/content/Ship.qml
+++ b/examples/demos/plasmapatrol/content/Ship.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/content/Sloop.qml b/examples/demos/plasmapatrol/content/Sloop.qml
index c6b1183162..3bc58a28b0 100644
--- a/examples/demos/plasmapatrol/content/Sloop.qml
+++ b/examples/demos/plasmapatrol/content/Sloop.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/plasmapatrol/plasmapatrol.qml b/examples/demos/plasmapatrol/plasmapatrol.qml
index 45f81c7222..b14ac6385b 100644
--- a/examples/demos/plasmapatrol/plasmapatrol.qml
+++ b/examples/demos/plasmapatrol/plasmapatrol.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/rssnews/content/BusyIndicator.qml b/examples/demos/rssnews/content/BusyIndicator.qml
index b6264ead92..f1abd1119c 100644
--- a/examples/demos/rssnews/content/BusyIndicator.qml
+++ b/examples/demos/rssnews/content/BusyIndicator.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/rssnews/content/CategoryDelegate.qml b/examples/demos/rssnews/content/CategoryDelegate.qml
index 1a56184489..fe64238adb 100644
--- a/examples/demos/rssnews/content/CategoryDelegate.qml
+++ b/examples/demos/rssnews/content/CategoryDelegate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/rssnews/content/NewsDelegate.qml b/examples/demos/rssnews/content/NewsDelegate.qml
index 84019a9179..59ab269d3b 100644
--- a/examples/demos/rssnews/content/NewsDelegate.qml
+++ b/examples/demos/rssnews/content/NewsDelegate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/rssnews/content/RssFeeds.qml b/examples/demos/rssnews/content/RssFeeds.qml
index 278f05752c..ed58ef3852 100644
--- a/examples/demos/rssnews/content/RssFeeds.qml
+++ b/examples/demos/rssnews/content/RssFeeds.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/rssnews/content/ScrollBar.qml b/examples/demos/rssnews/content/ScrollBar.qml
index 4ca4132c6b..7b1a2ac3e5 100644
--- a/examples/demos/rssnews/content/ScrollBar.qml
+++ b/examples/demos/rssnews/content/ScrollBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/rssnews/rssnews.qml b/examples/demos/rssnews/rssnews.qml
index 491cefda07..d26b94b6d3 100644
--- a/examples/demos/rssnews/rssnews.qml
+++ b/examples/demos/rssnews/rssnews.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/samegame/content/BoomBlock.qml b/examples/demos/samegame/content/BoomBlock.qml
index 47f86bd81b..a348368ae1 100644
--- a/examples/demos/samegame/content/BoomBlock.qml
+++ b/examples/demos/samegame/content/BoomBlock.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/samegame/content/Button.qml b/examples/demos/samegame/content/Button.qml
index b305455c92..2d1a993226 100644
--- a/examples/demos/samegame/content/Button.qml
+++ b/examples/demos/samegame/content/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/samegame/content/Dialog.qml b/examples/demos/samegame/content/Dialog.qml
index 80e5984bfe..c81580e6a5 100644
--- a/examples/demos/samegame/content/Dialog.qml
+++ b/examples/demos/samegame/content/Dialog.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/samegame/content/GameArea.qml b/examples/demos/samegame/content/GameArea.qml
index a43d55117a..3422582b21 100644
--- a/examples/demos/samegame/content/GameArea.qml
+++ b/examples/demos/samegame/content/GameArea.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/samegame/content/NameInputDialog.qml b/examples/demos/samegame/content/NameInputDialog.qml
index 602e69789a..7c3bfa274a 100644
--- a/examples/demos/samegame/content/NameInputDialog.qml
+++ b/examples/demos/samegame/content/NameInputDialog.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/samegame/samegame.qml b/examples/demos/samegame/samegame.qml
index 201f826a29..b98b6a0074 100644
--- a/examples/demos/samegame/samegame.qml
+++ b/examples/demos/samegame/samegame.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/snake/content/Button.qml b/examples/demos/snake/content/Button.qml
index dfac45049a..4f294556b3 100644
--- a/examples/demos/snake/content/Button.qml
+++ b/examples/demos/snake/content/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/snake/content/Cookie.qml b/examples/demos/snake/content/Cookie.qml
index cae53af525..35ffe400b8 100644
--- a/examples/demos/snake/content/Cookie.qml
+++ b/examples/demos/snake/content/Cookie.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/snake/content/HighScoreModel.qml b/examples/demos/snake/content/HighScoreModel.qml
index af66b99ede..734a661f5b 100644
--- a/examples/demos/snake/content/HighScoreModel.qml
+++ b/examples/demos/snake/content/HighScoreModel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/snake/content/Link.qml b/examples/demos/snake/content/Link.qml
index 891adafe5e..aab005afd5 100644
--- a/examples/demos/snake/content/Link.qml
+++ b/examples/demos/snake/content/Link.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/snake/content/Skull.qml b/examples/demos/snake/content/Skull.qml
index 9026790a5d..0c173be7da 100644
--- a/examples/demos/snake/content/Skull.qml
+++ b/examples/demos/snake/content/Skull.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/snake/snake.qml b/examples/demos/snake/snake.qml
index fca3273def..efd5747173 100644
--- a/examples/demos/snake/snake.qml
+++ b/examples/demos/snake/snake.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/Button.qml b/examples/demos/twitter/TwitterCore/Button.qml
index 064fd4b277..353b993742 100644
--- a/examples/demos/twitter/TwitterCore/Button.qml
+++ b/examples/demos/twitter/TwitterCore/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/FatDelegate.qml b/examples/demos/twitter/TwitterCore/FatDelegate.qml
index 5fd0d1622b..4cb0dfc713 100644
--- a/examples/demos/twitter/TwitterCore/FatDelegate.qml
+++ b/examples/demos/twitter/TwitterCore/FatDelegate.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/Input.qml b/examples/demos/twitter/TwitterCore/Input.qml
index 2987b9e5d8..68b1c6186a 100644
--- a/examples/demos/twitter/TwitterCore/Input.qml
+++ b/examples/demos/twitter/TwitterCore/Input.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/Loading.qml b/examples/demos/twitter/TwitterCore/Loading.qml
index 8f7c868bee..566857b8b2 100644
--- a/examples/demos/twitter/TwitterCore/Loading.qml
+++ b/examples/demos/twitter/TwitterCore/Loading.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/MultiTitleBar.qml b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml
index f52ce5be26..3920520b7a 100644
--- a/examples/demos/twitter/TwitterCore/MultiTitleBar.qml
+++ b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/RssModel.qml b/examples/demos/twitter/TwitterCore/RssModel.qml
index c4050994e6..27f7495be2 100644
--- a/examples/demos/twitter/TwitterCore/RssModel.qml
+++ b/examples/demos/twitter/TwitterCore/RssModel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/SearchView.qml b/examples/demos/twitter/TwitterCore/SearchView.qml
index 82a8559889..7732e6f68d 100644
--- a/examples/demos/twitter/TwitterCore/SearchView.qml
+++ b/examples/demos/twitter/TwitterCore/SearchView.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/TitleBar.qml b/examples/demos/twitter/TwitterCore/TitleBar.qml
index 3624048c4d..3e0818b0dd 100644
--- a/examples/demos/twitter/TwitterCore/TitleBar.qml
+++ b/examples/demos/twitter/TwitterCore/TitleBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/ToolBar.qml b/examples/demos/twitter/TwitterCore/ToolBar.qml
index 06d3324ee3..d4265f3e98 100644
--- a/examples/demos/twitter/TwitterCore/ToolBar.qml
+++ b/examples/demos/twitter/TwitterCore/ToolBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/TwitterCore/UserModel.qml b/examples/demos/twitter/TwitterCore/UserModel.qml
index f88837c344..428089b539 100644
--- a/examples/demos/twitter/TwitterCore/UserModel.qml
+++ b/examples/demos/twitter/TwitterCore/UserModel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/demos/twitter/twitter.qml b/examples/demos/twitter/twitter.qml
index 26e4a7079b..aca0968cfb 100644
--- a/examples/demos/twitter/twitter.qml
+++ b/examples/demos/twitter/twitter.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/examples/embedded/embedded.pro b/examples/embedded/embedded.pro
new file mode 100644
index 0000000000..81334fa552
--- /dev/null
+++ b/examples/embedded/embedded.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += qmleasing qmlflickr qmldialcontrol qmlcalculator qmlphotoviewer qmlclocks qmltwitter
diff --git a/examples/embedded/qmlcalculator/deployment.pri b/examples/embedded/qmlcalculator/deployment.pri
new file mode 100644
index 0000000000..4286bb6e24
--- /dev/null
+++ b/examples/embedded/qmlcalculator/deployment.pri
@@ -0,0 +1,4 @@
+qmlcalculator_src = $$PWD/../../qml/calculator
+
+qmlcalculator_files.files = $$qmlcalculator_src/calculator.qml $$qmlcalculator_src/Core
+DEPLOYMENT += qmlcalculator_files
diff --git a/examples/embedded/qmlcalculator/qmlcalculator.cpp b/examples/embedded/qmlcalculator/qmlcalculator.cpp
new file mode 100644
index 0000000000..17bf0f14f2
--- /dev/null
+++ b/examples/embedded/qmlcalculator/qmlcalculator.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QFileInfo>
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+
+ const QString mainQmlApp = QLatin1String("calculator.qml");
+ QQuickView view;
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit()));
+
+#if defined(QT_KEYPAD_NAVIGATION)
+ QApplication::setNavigationMode(Qt::NavigationModeCursorAuto);
+#endif // QT_KEYPAD_NAVIGATION
+
+ view.show();
+ return application.exec();
+}
diff --git a/examples/embedded/qmlcalculator/qmlcalculator.pro b/examples/embedded/qmlcalculator/qmlcalculator.pro
new file mode 100644
index 0000000000..4ebf2d5972
--- /dev/null
+++ b/examples/embedded/qmlcalculator/qmlcalculator.pro
@@ -0,0 +1,5 @@
+!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.")
+
+QT += qml
+SOURCES += $$PWD/qmlcalculator.cpp
+include($$PWD/deployment.pri)
diff --git a/examples/embedded/qmlclocks/deployment.pri b/examples/embedded/qmlclocks/deployment.pri
new file mode 100644
index 0000000000..75b39ac48f
--- /dev/null
+++ b/examples/embedded/qmlclocks/deployment.pri
@@ -0,0 +1,4 @@
+qmlclocks_src = $$PWD/../../../examples/qml/toys/clocks
+
+qmlclocks_files.files = $$qmlclocks_src/clocks.qml $$qmlclocks_src/content
+DEPLOYMENT += qmlclocks_files
diff --git a/examples/embedded/qmlclocks/qmlclocks.cpp b/examples/embedded/qmlclocks/qmlclocks.cpp
new file mode 100644
index 0000000000..1f9a553944
--- /dev/null
+++ b/examples/embedded/qmlclocks/qmlclocks.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QFileInfo>
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+
+ const QString mainQmlApp = QLatin1String("clocks.qml");
+ QQuickView view;
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit()));
+
+#if defined(QT_KEYPAD_NAVIGATION)
+ QApplication::setNavigationMode(Qt::NavigationModeCursorAuto);
+#endif // QT_KEYPAD_NAVIGATION
+
+ view.show();
+ return application.exec();
+}
diff --git a/examples/embedded/qmlclocks/qmlclocks.pro b/examples/embedded/qmlclocks/qmlclocks.pro
new file mode 100644
index 0000000000..43a9e31972
--- /dev/null
+++ b/examples/embedded/qmlclocks/qmlclocks.pro
@@ -0,0 +1,5 @@
+!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.")
+
+QT += qml
+SOURCES += $$PWD/qmlclocks.cpp
+include($$PWD/deployment.pri)
diff --git a/examples/embedded/qmldialcontrol/deployment.pri b/examples/embedded/qmldialcontrol/deployment.pri
new file mode 100644
index 0000000000..58c815e1e5
--- /dev/null
+++ b/examples/embedded/qmldialcontrol/deployment.pri
@@ -0,0 +1,4 @@
+qmldialcontrol_src = $$PWD/../../../examples/qml/ui-components/dialcontrol
+
+qmldialcontrol_files.files = $$qmldialcontrol_src/dialcontrol.qml $$qmldialcontrol_src/content
+DEPLOYMENT += qmldialcontrol_files
diff --git a/examples/embedded/qmldialcontrol/qmldialcontrol.cpp b/examples/embedded/qmldialcontrol/qmldialcontrol.cpp
new file mode 100644
index 0000000000..6f81e5f8a0
--- /dev/null
+++ b/examples/embedded/qmldialcontrol/qmldialcontrol.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QFileInfo>
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+
+ const QString mainQmlApp = QLatin1String("dialcontrol.qml");
+ QQuickView view;
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit()));
+
+#if defined(QT_KEYPAD_NAVIGATION)
+ QApplication::setNavigationMode(Qt::NavigationModeCursorAuto);
+#endif // QT_KEYPAD_NAVIGATION
+
+ view.show();
+ return application.exec();
+}
diff --git a/examples/embedded/qmldialcontrol/qmldialcontrol.pro b/examples/embedded/qmldialcontrol/qmldialcontrol.pro
new file mode 100644
index 0000000000..58ed7cabb8
--- /dev/null
+++ b/examples/embedded/qmldialcontrol/qmldialcontrol.pro
@@ -0,0 +1,5 @@
+!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.")
+
+QT += qml
+SOURCES += $$PWD/qmldialcontrol.cpp
+include($$PWD/deployment.pri)
diff --git a/examples/embedded/qmleasing/deployment.pri b/examples/embedded/qmleasing/deployment.pri
new file mode 100644
index 0000000000..427259b816
--- /dev/null
+++ b/examples/embedded/qmleasing/deployment.pri
@@ -0,0 +1,4 @@
+qmleasing_src = $$PWD/../../../examples/qml/animation/easing
+
+qmleasing_files.files = $$qmleasing_src/easing.qml $$qmleasing_src/content
+DEPLOYMENT += qmleasing_files
diff --git a/examples/embedded/qmleasing/qmleasing.cpp b/examples/embedded/qmleasing/qmleasing.cpp
new file mode 100644
index 0000000000..d516825d9a
--- /dev/null
+++ b/examples/embedded/qmleasing/qmleasing.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QFileInfo>
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+
+ const QString mainQmlApp = QLatin1String("easing.qml");
+ QQuickView view;
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit()));
+
+#if defined(QT_KEYPAD_NAVIGATION)
+ QApplication::setNavigationMode(Qt::NavigationModeCursorAuto);
+#endif // QT_KEYPAD_NAVIGATION
+
+ view.show();
+ return application.exec();
+}
diff --git a/examples/embedded/qmleasing/qmleasing.pro b/examples/embedded/qmleasing/qmleasing.pro
new file mode 100644
index 0000000000..6e0383502b
--- /dev/null
+++ b/examples/embedded/qmleasing/qmleasing.pro
@@ -0,0 +1,5 @@
+!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.")
+
+QT += qml
+SOURCES += $$PWD/qmleasing.cpp
+include($$PWD/deployment.pri)
diff --git a/examples/embedded/qmlflickr/deployment.pri b/examples/embedded/qmlflickr/deployment.pri
new file mode 100644
index 0000000000..7b9b62b459
--- /dev/null
+++ b/examples/embedded/qmlflickr/deployment.pri
@@ -0,0 +1,4 @@
+qmlflickr_src = $$PWD/../../qml/flickr
+
+qmlflickr_files.files = $$qmlflickr_src/flickr.qml $$qmlflickr_src/common $$qmlflickr_src/mobile
+DEPLOYMENT += qmlflickr_files
diff --git a/examples/embedded/qmlflickr/qmlflickr.cpp b/examples/embedded/qmlflickr/qmlflickr.cpp
new file mode 100644
index 0000000000..268542e61b
--- /dev/null
+++ b/examples/embedded/qmlflickr/qmlflickr.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QSettings>
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlNetworkAccessManagerFactory>
+#include <QtNetwork/QNetworkConfiguration>
+#include <QtNetwork/QNetworkConfigurationManager>
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtQml/QQmlEngine>
+
+// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise
+// the system default.
+class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
+{
+public:
+ ~NetworkAccessManagerFactory() { }
+
+ QNetworkAccessManager *create(QObject *parent);
+};
+
+QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
+{
+ QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent);
+
+ QNetworkConfigurationManager manager;
+ if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
+ // Get saved network configuration
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ settings.beginGroup(QLatin1String("QtNetwork"));
+ const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
+ settings.endGroup();
+
+ // If the saved network configuration is not currently discovered use the system default
+ QNetworkConfiguration config = manager.configurationFromIdentifier(id);
+ if ((config.state() & QNetworkConfiguration::Discovered) !=
+ QNetworkConfiguration::Discovered) {
+ config = manager.defaultConfiguration();
+ }
+
+ accessManager->setConfiguration(config);
+ }
+
+ return accessManager;
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+
+ NetworkAccessManagerFactory networkAccessManagerFactory;
+
+ const QString mainQmlApp = QLatin1String("flickr.qml");
+ QQuickView view;
+ view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory);
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit()));
+ view.setGeometry(QRect(100, 100, 360, 640));
+ view.show();
+ return application.exec();
+}
+
diff --git a/examples/embedded/qmlflickr/qmlflickr.pro b/examples/embedded/qmlflickr/qmlflickr.pro
new file mode 100644
index 0000000000..141c02d3fe
--- /dev/null
+++ b/examples/embedded/qmlflickr/qmlflickr.pro
@@ -0,0 +1,5 @@
+!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.")
+
+QT += qml network
+SOURCES += $$PWD/qmlflickr.cpp
+include($$PWD/deployment.pri)
diff --git a/examples/embedded/qmlphotoviewer/deployment.pri b/examples/embedded/qmlphotoviewer/deployment.pri
new file mode 100644
index 0000000000..ea9a052b4b
--- /dev/null
+++ b/examples/embedded/qmlphotoviewer/deployment.pri
@@ -0,0 +1,4 @@
+qmlphotoviewer_src = $$PWD/../../qml/photoviewer
+
+qmlphotoviewer_files.files = $$qmlphotoviewer_src/photoviewer.qml $$qmlphotoviewer_src/PhotoViewerCore
+DEPLOYMENT += qmlphotoviewer_files
diff --git a/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp b/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp
new file mode 100644
index 0000000000..18bf1ae094
--- /dev/null
+++ b/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QSettings>
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlNetworkAccessManagerFactory>
+#include <QtNetwork/QNetworkConfiguration>
+#include <QtNetwork/QNetworkConfigurationManager>
+#include <QtNetwork/QNetworkAccessManager>
+
+// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise
+// the system default.
+class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
+{
+public:
+ ~NetworkAccessManagerFactory() { }
+
+ QNetworkAccessManager *create(QObject *parent);
+};
+
+QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
+{
+ QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent);
+
+ QNetworkConfigurationManager manager;
+ if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
+ // Get saved network configuration
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ settings.beginGroup(QLatin1String("QtNetwork"));
+ const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
+ settings.endGroup();
+
+ // If the saved network configuration is not currently discovered use the system default
+ QNetworkConfiguration config = manager.configurationFromIdentifier(id);
+ if ((config.state() & QNetworkConfiguration::Discovered) !=
+ QNetworkConfiguration::Discovered) {
+ config = manager.defaultConfiguration();
+ }
+
+ accessManager->setConfiguration(config);
+ }
+
+ return accessManager;
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+
+ NetworkAccessManagerFactory networkAccessManagerFactory;
+
+ const QString mainQmlApp = QLatin1String("photoviewer.qml");
+ QQuickView view;
+ view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory);
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+
+ QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit()));
+ view.setGeometry(QRect(100, 100, 360, 640));
+ view.show();
+ return application.exec();
+}
+
diff --git a/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro b/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro
new file mode 100644
index 0000000000..1c0301118e
--- /dev/null
+++ b/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro
@@ -0,0 +1,5 @@
+!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.")
+
+QT += qml network
+SOURCES += $$PWD/qmlphotoviewer.cpp
+include($$PWD/deployment.pri)
diff --git a/examples/embedded/qmltwitter/deployment.pri b/examples/embedded/qmltwitter/deployment.pri
new file mode 100644
index 0000000000..2f3066bc72
--- /dev/null
+++ b/examples/embedded/qmltwitter/deployment.pri
@@ -0,0 +1,4 @@
+qmltwitter_src = $$PWD/../../qml/twitter
+
+qmltwitter_files.files = $$qmltwitter_src/twitter.qml $$qmltwitter_src/TwitterCore
+DEPLOYMENT += qmltwitter_files
diff --git a/examples/embedded/qmltwitter/qmltwitter.cpp b/examples/embedded/qmltwitter/qmltwitter.cpp
new file mode 100644
index 0000000000..a3a5c40f34
--- /dev/null
+++ b/examples/embedded/qmltwitter/qmltwitter.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QSettings>
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlNetworkAccessManagerFactory>
+#include <QtNetwork/QNetworkConfiguration>
+#include <QtNetwork/QNetworkConfigurationManager>
+#include <QtNetwork/QNetworkAccessManager>
+
+// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise
+// the system default.
+class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
+{
+public:
+ ~NetworkAccessManagerFactory() { }
+
+ QNetworkAccessManager *create(QObject *parent);
+};
+
+QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
+{
+ QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent);
+
+ QNetworkConfigurationManager manager;
+ if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
+ // Get saved network configuration
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ settings.beginGroup(QLatin1String("QtNetwork"));
+ const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
+ settings.endGroup();
+
+ // If the saved network configuration is not currently discovered use the system default
+ QNetworkConfiguration config = manager.configurationFromIdentifier(id);
+ if ((config.state() & QNetworkConfiguration::Discovered) !=
+ QNetworkConfiguration::Discovered) {
+ config = manager.defaultConfiguration();
+ }
+
+ accessManager->setConfiguration(config);
+ }
+
+ return accessManager;
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+
+ NetworkAccessManagerFactory networkAccessManagerFactory;
+
+ const QString mainQmlApp = QLatin1String("twitter.qml");
+ QQuickView view;
+ view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory);
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit()));
+ view.setGeometry(QRect(100, 100, 360, 640));
+ view.show();
+ return application.exec();
+}
+
diff --git a/examples/embedded/qmltwitter/qmltwitter.pro b/examples/embedded/qmltwitter/qmltwitter.pro
new file mode 100644
index 0000000000..eca46f9f97
--- /dev/null
+++ b/examples/embedded/qmltwitter/qmltwitter.pro
@@ -0,0 +1,5 @@
+!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.")
+
+QT += qml network
+SOURCES += $$PWD/qmltwitter.cpp
+include($$PWD/deployment.pri)
diff --git a/examples/examples.pro b/examples/examples.pro
index 2b78ed7e12..d3d2f5520f 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += demos shared localstorage particles qml qtquick tutorials window
+SUBDIRS += demos shared localstorage particles qml quick tutorials window
contains(QT_CONFIG, qmltest): SUBDIRS += qmltest
diff --git a/examples/qml/README b/examples/qml/README
new file mode 100644
index 0000000000..56c48d71fb
--- /dev/null
+++ b/examples/qml/README
@@ -0,0 +1,13 @@
+The Qt Declarative module provides the ability to specify and implement
+your user interface declaratively, using the Qt Meta-Object Language (QML). This
+language is very expressive and human readable, and can be used by
+designers to actually implement their UI vision. QML UIs can integrate
+with C++ code in many ways, including being loaded as a part of a C++ UI
+and loading data models from C++ and interacting with them.
+
+Mostof these examples can be viewed directly with the
+QML viewer utility, without requiring compilation.
+
+
+Documentation for these examples can be found via the Examples
+link in the main Qt documentation.
diff --git a/examples/qml/accessibility/accessibility.qml b/examples/qml/accessibility/accessibility.qml
new file mode 100644
index 0000000000..e0152f065b
--- /dev/null
+++ b/examples/qml/accessibility/accessibility.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0
+import "widgets"
+
+Rectangle {
+ id: window
+
+ width: 360; height: 300
+ color: "white"
+
+ Column {
+ id: column
+ spacing: 6
+ anchors.fill: parent
+ width: parent.width
+ Row {
+ spacing: 6
+ width: column.width
+ Button { width: 100; height: column.h + 20; text: "Send" }
+ Button { width: 100; height: column.h + 20; text: "Discard" }
+ }
+
+ Row {
+ spacing: 6
+ width: column.width
+ height: column.h
+ Text {
+ id: subjectLabel
+ Accessible.role: Accessible.StaticText
+ Accessible.name: text
+ text: "Subject:"
+ width: 50
+ }
+ Rectangle {
+ id: subjectBorder
+ Accessible.role: Accessible.EditableText
+ Accessible.name: subjectEdit.text
+ border.width: 1
+ border.color: "black"
+ height: subjectEdit.height
+ width: 304
+ TextInput {
+ id: subjectEdit
+ text: "Vacation plans"
+ }
+ }
+ }
+ Rectangle {
+ id: textBorder
+ Accessible.role: Accessible.EditableText
+ property alias text : textEdit.text
+ border.width: 1
+ border.color: "black"
+ width: parent.width
+ height: textEdit.height
+ TextEdit {
+ id: textEdit
+ text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke"
+ width: parent.width
+ wrapMode: TextEdit.WordWrap
+ }
+ }
+ }
+}
diff --git a/examples/qml/accessibility/widgets/Button.qml b/examples/qml/accessibility/widgets/Button.qml
new file mode 100644
index 0000000000..793f895c57
--- /dev/null
+++ b/examples/qml/accessibility/widgets/Button.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: button
+
+ property alias text : buttonText.text
+ Accessible.name: text
+ Accessible.description: "This button does " + text
+ Accessible.role: Accessible.Button
+
+ signal clicked
+
+ width: buttonText.width + 20
+ height: 30
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightsteelblue" }
+ GradientStop { position: 1.0; color: "blue" }
+ }
+ border.width: 2
+ border.color: "black";
+ radius: 10
+
+ Text {
+ id: buttonText
+ text: parent.description
+ anchors.centerIn: parent
+ font.pixelSize: parent.height * .5
+ style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ checked = !checked;
+ }
+ }
+}
diff --git a/examples/qml/animation/animation.qml b/examples/qml/animation/animation.qml
new file mode 100644
index 0000000000..7c5829e790
--- /dev/null
+++ b/examples/qml/animation/animation.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../shared"
+
+Item {
+ height: 480
+ width: 320
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("ColorAnimation", "Interpolates between colors", Qt.resolvedUrl("basics/color-animation.qml"));
+ addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml"));
+ addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml"));
+ addExample("WigglyText", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml"));
+ addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml"));
+ addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml"));
+ addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml"));
+ addExample("PathAnimation", "Animate along a path", Qt.resolvedUrl("pathanimation/pathanimation.qml"));
+ addExample("PathInterpolator", "Interpolates along a path", Qt.resolvedUrl("pathinterpolator/pathinterpolator.qml"));
+ }
+ }
+}
diff --git a/examples/qtquick/animation/animation.qmlproject b/examples/qml/animation/animation.qmlproject
index 2e96daa881..2e96daa881 100644
--- a/examples/qtquick/animation/animation.qmlproject
+++ b/examples/qml/animation/animation.qmlproject
diff --git a/examples/qml/animation/basics/color-animation.qml b/examples/qml/animation/basics/color-animation.qml
new file mode 100644
index 0000000000..a54091d7dd
--- /dev/null
+++ b/examples/qml/animation/basics/color-animation.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: window
+ width: 640; height: 480
+
+ // Let's draw the sky...
+ Rectangle {
+ anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 }
+ ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 }
+ }
+ }
+ GradientStop {
+ position: 1.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 }
+ ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 }
+ }
+ }
+ }
+ }
+
+ // the sun, moon, and stars
+ Item {
+ width: parent.width; height: 2 * parent.height
+ NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite }
+ Image {
+ source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter
+ rotation: -3 * parent.rotation
+ }
+ Image {
+ source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter
+ rotation: -parent.rotation
+ }
+ ParticleSystem {
+ id: particlesystem
+ x: 0; y: parent.height/2
+ width: parent.width; height: parent.height/2
+ ImageParticle {
+ source: "images/star.png"
+ groups: ["star"]
+ color: "#00333333"
+ SequentialAnimation on opacity {
+ loops: Animation.Infinite
+ NumberAnimation { from: 0; to: 1; duration: 5000 }
+ NumberAnimation { from: 1; to: 0; duration: 5000 }
+ }
+ }
+ Emitter {
+ group: "star"
+ anchors.fill: parent
+ emitRate: parent.width / 50
+ lifeSpan: 5000
+ }
+ }
+ }
+
+ // ...and the ground.
+ Rectangle {
+ anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 }
+ ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 }
+ }
+ }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+}
diff --git a/examples/qtquick/animation/basics/images/face-smile.png b/examples/qml/animation/basics/images/face-smile.png
index 3d66d72578..3d66d72578 100644
--- a/examples/qtquick/animation/basics/images/face-smile.png
+++ b/examples/qml/animation/basics/images/face-smile.png
Binary files differ
diff --git a/examples/qtquick/animation/basics/images/moon.png b/examples/qml/animation/basics/images/moon.png
index 9407b2b4f0..9407b2b4f0 100644
--- a/examples/qtquick/animation/basics/images/moon.png
+++ b/examples/qml/animation/basics/images/moon.png
Binary files differ
diff --git a/examples/qtquick/animation/basics/images/shadow.png b/examples/qml/animation/basics/images/shadow.png
index 8270565e87..8270565e87 100644
--- a/examples/qtquick/animation/basics/images/shadow.png
+++ b/examples/qml/animation/basics/images/shadow.png
Binary files differ
diff --git a/examples/qtquick/animation/basics/images/star.png b/examples/qml/animation/basics/images/star.png
index 27ef924267..27ef924267 100644
--- a/examples/qtquick/animation/basics/images/star.png
+++ b/examples/qml/animation/basics/images/star.png
Binary files differ
diff --git a/examples/qtquick/animation/basics/images/sun.png b/examples/qml/animation/basics/images/sun.png
index 7713ca5ce7..7713ca5ce7 100644
--- a/examples/qtquick/animation/basics/images/sun.png
+++ b/examples/qml/animation/basics/images/sun.png
Binary files differ
diff --git a/examples/qtquick/animation/basics/property-animation.qml b/examples/qml/animation/basics/property-animation.qml
index 4a4d3e3b2a..4a4d3e3b2a 100644
--- a/examples/qtquick/animation/basics/property-animation.qml
+++ b/examples/qml/animation/basics/property-animation.qml
diff --git a/examples/qtquick/animation/behaviors/SideRect.qml b/examples/qml/animation/behaviors/SideRect.qml
index 623c6965d8..623c6965d8 100644
--- a/examples/qtquick/animation/behaviors/SideRect.qml
+++ b/examples/qml/animation/behaviors/SideRect.qml
diff --git a/examples/qml/animation/behaviors/behavior-example.qml b/examples/qml/animation/behaviors/behavior-example.qml
new file mode 100644
index 0000000000..89fc9992b6
--- /dev/null
+++ b/examples/qml/animation/behaviors/behavior-example.qml
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 600; height: 400
+ color: "#343434"
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 200; height: 200
+ radius: 30
+ color: "transparent"
+ border.width: 4; border.color: "white"
+
+
+ SideRect {
+ id: leftRect
+ anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left }
+ text: "Left"
+ }
+
+ SideRect {
+ id: rightRect
+ anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right }
+ text: "Right"
+ }
+
+ SideRect {
+ id: topRect
+ anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter }
+ text: "Top"
+ }
+
+ SideRect {
+ id: bottomRect
+ anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter }
+ text: "Bottom"
+ }
+
+
+ Rectangle {
+ id: focusRect
+
+ property string text
+
+ x: 62; y: 75; width: 75; height: 50
+ radius: 6
+ border.width: 4; border.color: "white"
+ color: "firebrick"
+
+ // Set an 'elastic' behavior on the focusRect's x property.
+ Behavior on x {
+ NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 }
+ }
+
+ // Set an 'elastic' behavior on the focusRect's y property.
+ Behavior on y {
+ NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 }
+ }
+
+ Text {
+ id: focusText
+ text: focusRect.text
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 16; font.bold: true
+
+ // Set a behavior on the focusText's x property:
+ // Set the opacity to 0, set the new text value, then set the opacity back to 1.
+ Behavior on text {
+ SequentialAnimation {
+ NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 }
+ NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/qml/animation/behaviors/wigglytext.qml b/examples/qml/animation/behaviors/wigglytext.qml
new file mode 100644
index 0000000000..e2ed472088
--- /dev/null
+++ b/examples/qml/animation/behaviors/wigglytext.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Drag this text..."
+ property bool animated: true
+
+ width: 640; height: 480; color: "#474747"; focus: true
+
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace)
+ container.remove()
+ else if (event.text != "") {
+ container.append(event.text)
+ }
+ }
+
+ function append(text) {
+ container.animated = false
+ var lastLetter = container.children[container.children.length - 1]
+ var newLetter = letterComponent.createObject(container)
+ newLetter.text = text
+ newLetter.follow = lastLetter
+ container.animated = true
+ }
+
+ function remove() {
+ if (container.children.length)
+ container.children[container.children.length - 1].destroy()
+ }
+
+ function doLayout() {
+ var follow = null
+ for (var i = 0; i < container.text.length; ++i) {
+ var newLetter = letterComponent.createObject(container)
+ newLetter.text = container.text[i]
+ newLetter.follow = follow
+ follow = newLetter
+ }
+ }
+
+ Component {
+ id: letterComponent
+ Text {
+ id: letter
+ property variant follow
+
+ x: follow ? follow.x + follow.width : container.width / 3
+ y: follow ? follow.y : container.height / 2
+
+ font.pixelSize: 40; font.bold: true
+ color: "#999999"; styleColor: "#222222"; style: Text.Raised
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: letter; drag.axis: Drag.XandYAxis
+ onPressed: letter.color = "#dddddd"
+ onReleased: letter.color = "#999999"
+ }
+
+ Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } }
+ Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } }
+ }
+ }
+
+ Component.onCompleted: doLayout()
+}
diff --git a/examples/qtquick/animation/easing/content/QuitButton.qml b/examples/qml/animation/easing/content/QuitButton.qml
index 702b892d23..702b892d23 100644
--- a/examples/qtquick/animation/easing/content/QuitButton.qml
+++ b/examples/qml/animation/easing/content/QuitButton.qml
diff --git a/examples/qtquick/animation/easing/content/quit.png b/examples/qml/animation/easing/content/quit.png
index b822057d4e..b822057d4e 100644
--- a/examples/qtquick/animation/easing/content/quit.png
+++ b/examples/qml/animation/easing/content/quit.png
Binary files differ
diff --git a/examples/qml/animation/easing/easing.qml b/examples/qml/animation/easing/easing.qml
new file mode 100644
index 0000000000..207b653d6e
--- /dev/null
+++ b/examples/qml/animation/easing/easing.qml
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: window
+ width: 600; height: 460; color: "#232323"
+
+ property var easingCurve: [ 0.2, 0.2, 0.13, 0.65, 0.2, 0.8,
+ 0.624, 0.98, 0.93, 0.95, 1, 1 ]
+
+ ListModel {
+ id: easingTypes
+ ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" }
+ ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" }
+ ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" }
+ ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" }
+ ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" }
+ ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" }
+ ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" }
+ ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" }
+ ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" }
+ ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" }
+ ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" }
+ ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" }
+ ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" }
+ ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" }
+ ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" }
+ ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" }
+ ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" }
+ ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" }
+ ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" }
+ ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" }
+ ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" }
+ ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" }
+ ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" }
+ ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" }
+ ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" }
+ ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" }
+ ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" }
+ ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" }
+ ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" }
+ ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" }
+ ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" }
+ ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" }
+ ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" }
+ ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" }
+ ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" }
+ ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" }
+ ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" }
+ ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" }
+ ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" }
+ ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" }
+ ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" }
+ ListElement { name: "Easing.Bezier"; type: Easing.Bezier; ballColor: "Chartreuse"; }
+ }
+
+ Component {
+ id: delegate
+
+ Item {
+ height: 56; width: window.width
+
+ Text { text: name; anchors.centerIn: parent; color: "White" }
+
+ Rectangle {
+ id: slot1; color: "#121212"; x: 30; height: 46; width: 46
+ border.color: "#343434"; border.width: 1; radius: 12
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Rectangle {
+ id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46
+ border.color: "#343434"; border.width: 1; radius: 12
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Rectangle {
+ id: rect; x: 30; color: "#454545"
+ border.color: "White"; border.width: 2
+ height: 46; width: 46; radius: 12
+ anchors.verticalCenter: parent.verticalCenter
+
+ MouseArea {
+ onClicked: if (rect.state == '') rect.state = "right"; else rect.state = ''
+ anchors.fill: parent
+ anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself
+ }
+
+ states : State {
+ name: "right"
+ PropertyChanges { target: rect; x: window.width - 76; color: ballColor }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 }
+ ColorAnimation { properties: "color"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 }
+ }
+ }
+ }
+ }
+
+ Flickable {
+ anchors.fill: parent
+ contentHeight: layout.height+50
+ Rectangle {
+ id: titlePane
+ color: "#444444"
+ height: 35
+ anchors { top: parent.top; left: parent.left; right: parent.right }
+ QuitButton {
+ id: quitButton
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ }
+ }
+ Column {
+ id: layout
+ anchors { top: titlePane.bottom; topMargin: 10; left: parent.left; right: parent.right }
+ Repeater { model: easingTypes; delegate: delegate }
+ }
+ }
+
+ function getBezierCurve(name)
+ {
+ if (name === "Easing.Bezier")
+ return easingCurve;
+ return [];
+ }
+}
diff --git a/examples/qml/animation/pathanimation/pathanimation.qml b/examples/qml/animation/pathanimation/pathanimation.qml
new file mode 100644
index 0000000000..4d0a31bdf8
--- /dev/null
+++ b/examples/qml/animation/pathanimation/pathanimation.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: window
+ width: 400
+ height: 400
+
+ Canvas {
+ id: canvas
+ anchors.fill: parent
+ smooth: true
+
+ onPaint: {
+ context.clearRect(0, 0, width, height)
+ context.strokeStyle = "black"
+ context.path = pathAnim.path
+ context.stroke()
+ }
+ }
+
+ PathAnimation {
+ id: pathAnim
+
+ duration: 2000
+ easing.type: Easing.InQuad
+
+ target: box
+ orientation: PathAnimation.RightFirst
+ anchorPoint: Qt.point(box.width/2, box.height/2)
+ path: Path {
+ startX: 50; startY: 50
+
+ PathCubic {
+ x: window.width - 50
+ y: window.height - 50
+
+ control1X: x; control1Y: 50
+ control2X: 50; control2Y: y
+ }
+
+ onChanged: canvas.requestPaint()
+ }
+ }
+
+ Rectangle {
+ id: box
+
+ x: 25; y: 25
+ width: 50; height: 50
+ border.width: 1
+ smooth: true
+
+ Text {
+ anchors.centerIn: parent
+ text: "Box"
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: pathAnim.restart()
+ }
+
+ Text {
+ text: "Click anywhere to animate along the path"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+}
diff --git a/examples/qml/animation/pathinterpolator/pathinterpolator.qml b/examples/qml/animation/pathinterpolator/pathinterpolator.qml
new file mode 100644
index 0000000000..67a34ce582
--- /dev/null
+++ b/examples/qml/animation/pathinterpolator/pathinterpolator.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: window
+ width: 400
+ height: 400
+
+ Canvas {
+ id: canvas
+ anchors.fill: parent
+ smooth: true
+
+ onPaint: {
+ context.clearRect(0, 0, width, height)
+ context.strokeStyle = "black"
+ context.path = motionPath.path
+ context.stroke()
+ }
+ }
+
+ PathInterpolator {
+ id: motionPath
+
+ path: Path {
+ startX: 50; startY: 50
+
+ PathCubic {
+ x: window.width - 50
+ y: window.height - 50
+
+ control1X: x; control1Y: 50
+ control2X: 50; control2Y: y
+ }
+
+ onChanged: canvas.requestPaint()
+ }
+
+ NumberAnimation on progress {
+ id: progressAnim
+ running: false
+ from: 0; to: 1
+ duration: 2000
+ easing.type: Easing.InQuad
+ }
+ }
+
+ Rectangle {
+ id: box
+
+ width: 50; height: 50
+ border.width: 1
+ smooth: true
+
+ //bind our attributes to follow the path as progress changes
+ x: motionPath.x
+ y: motionPath.y
+ rotation: motionPath.angle
+ transform: Translate { x: -box.width/2; y: -box.height/2 }
+
+ Text {
+ anchors.centerIn: parent
+ text: "Box"
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: progressAnim.restart()
+ }
+
+ Text {
+ text: "Click anywhere to animate along the path"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+}
diff --git a/examples/qtquick/animation/states/qt-logo.png b/examples/qml/animation/states/qt-logo.png
index 14ddf2a028..14ddf2a028 100644
--- a/examples/qtquick/animation/states/qt-logo.png
+++ b/examples/qml/animation/states/qt-logo.png
Binary files differ
diff --git a/examples/qtquick/animation/states/states.qml b/examples/qml/animation/states/states.qml
index 7ca56a9295..7ca56a9295 100644
--- a/examples/qtquick/animation/states/states.qml
+++ b/examples/qml/animation/states/states.qml
diff --git a/examples/qtquick/animation/states/transitions.qml b/examples/qml/animation/states/transitions.qml
index d57924d6d2..d57924d6d2 100644
--- a/examples/qtquick/animation/states/transitions.qml
+++ b/examples/qml/animation/states/transitions.qml
diff --git a/examples/qml/calculator/calculator.qml b/examples/qml/calculator/calculator.qml
new file mode 100644
index 0000000000..913643a93b
--- /dev/null
+++ b/examples/qml/calculator/calculator.qml
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0
+import "content"
+import "content/calculator.js" as CalcEngine
+
+Rectangle {
+ id: window
+
+ width: 360; height: 480
+ color: "#282828"
+
+ property string rotateLeft: "\u2939"
+ property string rotateRight: "\u2935"
+ property string leftArrow: "\u2190"
+ property string division : "\u00f7"
+ property string multiplication : "\u00d7"
+ property string squareRoot : "\u221a"
+ property string plusminus : "\u00b1"
+
+ function doOp(operation) { CalcEngine.doOperation(operation) }
+
+ Item {
+ id: main
+ state: "orientation " + Screen.orientation
+
+ property bool landscapeWindow: window.width > window.height
+ property real baseWidth: landscapeWindow ? window.height : window.width
+ property real baseHeight: landscapeWindow ? window.width : window.height
+ property real rotationDelta: landscapeWindow ? -90 : 0
+
+ rotation: rotationDelta
+ width: main.baseWidth
+ height: main.baseHeight
+ anchors.centerIn: parent
+
+ Column {
+ id: box; spacing: 8
+
+ anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
+
+ Display {
+ id: display
+ width: box.width-3
+ height: 64
+ }
+
+ Column {
+ id: column; spacing: 6
+
+ property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
+ property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
+
+ Row {
+ spacing: 6
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
+ }
+
+ Row {
+ spacing: 6
+ property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
+
+ Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
+ }
+
+ Grid {
+ id: grid; rows: 5; columns: 5; spacing: 6
+
+ property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
+
+ Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: division }
+ Button { width: grid.w; height: column.h; operation: squareRoot }
+ Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: multiplication }
+ Button { width: grid.w; height: column.h; operation: "x^2" }
+ Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "-" }
+ Button { width: grid.w; height: column.h; operation: "1/x" }
+ Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "." }
+ Button { width: grid.w; height: column.h; operation: plusminus }
+ Button { width: grid.w; height: column.h; operation: "+" }
+ Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "orientation " + Qt.LandscapeOrientation
+ PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ },
+ State {
+ name: "orientation " + Qt.InvertedPortraitOrientation
+ PropertyChanges { target: main; rotation: 180 + rotationDelta; }
+ },
+ State {
+ name: "orientation " + Qt.InvertedLandscapeOrientation
+ PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ }
+ ]
+
+ transitions: Transition {
+ SequentialAnimation {
+ RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint }
+ NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
+ }
+ }
+ }
+}
diff --git a/examples/qml/calculator/content/Button.qml b/examples/qml/calculator/content/Button.qml
new file mode 100644
index 0000000000..feaa5e7df3
--- /dev/null
+++ b/examples/qml/calculator/content/Button.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+BorderImage {
+ id: button
+
+ property alias operation: buttonText.text
+ property string color: ""
+
+ Accessible.name: operation
+ Accessible.description: "This button does " + operation
+ Accessible.role: Accessible.Button
+
+ signal clicked
+
+ source: "images/button-" + color + ".png"; clip: true
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+
+ Rectangle {
+ id: shade
+ anchors.fill: button; radius: 10; color: "black"; opacity: 0
+ }
+
+ Text {
+ id: buttonText
+ anchors.centerIn: parent; anchors.verticalCenterOffset: -1
+ font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5
+ style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ doOp(operation)
+ button.clicked()
+ }
+ }
+
+ states: State {
+ name: "pressed"; when: mouseArea.pressed == true
+ PropertyChanges { target: shade; opacity: .4 }
+ }
+}
diff --git a/examples/qml/calculator/content/Display.qml b/examples/qml/calculator/content/Display.qml
new file mode 100644
index 0000000000..3dceeab169
--- /dev/null
+++ b/examples/qml/calculator/content/Display.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+BorderImage {
+ id: image
+
+ property alias text : displayText.text
+ property alias currentOperation : operationText
+
+ source: "images/display.png"
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+
+ Text {
+ id: displayText
+ anchors {
+ right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1
+ rightMargin: 6; left: operationText.right
+ }
+ font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight
+ color: "#343434"; smooth: true; font.bold: true
+ }
+ Text {
+ id: operationText
+ font.bold: true; font.pixelSize: parent.height * .7
+ color: "#343434"; smooth: true
+ anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter }
+ }
+}
diff --git a/examples/qml/calculator/content/calculator.js b/examples/qml/calculator/content/calculator.js
new file mode 100644
index 0000000000..7c363c7f30
--- /dev/null
+++ b/examples/qml/calculator/content/calculator.js
@@ -0,0 +1,91 @@
+
+var curVal = 0
+var memory = 0
+var lastOp = ""
+var timer = 0
+
+function disabled(op) {
+ if (op == "." && display.text.toString().search(/\./) != -1) {
+ return true
+ } else if (op == squareRoot && display.text.toString().search(/-/) != -1) {
+ return true
+ } else {
+ return false
+ }
+}
+
+function doOperation(op) {
+ if (disabled(op)) {
+ return
+ }
+
+ if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) {
+ if (display.text.toString().length >= 14)
+ return; // No arbitrary length numbers
+ if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) {
+ display.text = display.text + op.toString()
+ } else {
+ display.text = op
+ }
+ lastOp = op
+ return
+ }
+ lastOp = op
+
+ if (display.currentOperation.text == "+") {
+ display.text = Number(display.text.valueOf()) + Number(curVal.valueOf())
+ } else if (display.currentOperation.text == "-") {
+ display.text = Number(curVal) - Number(display.text.valueOf())
+ } else if (display.currentOperation.text == multiplication) {
+ display.text = Number(curVal) * Number(display.text.valueOf())
+ } else if (display.currentOperation.text == division) {
+ display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString()
+ } else if (display.currentOperation.text == "=") {
+ }
+
+ if (op == "+" || op == "-" || op == multiplication || op == division) {
+ display.currentOperation.text = op
+ curVal = display.text.valueOf()
+ return
+ }
+
+ curVal = 0
+ display.currentOperation.text = ""
+
+ if (op == "1/x") {
+ display.text = (1 / display.text.valueOf()).toString()
+ } else if (op == "x^2") {
+ display.text = (display.text.valueOf() * display.text.valueOf()).toString()
+ } else if (op == "Abs") {
+ display.text = (Math.abs(display.text.valueOf())).toString()
+ } else if (op == "Int") {
+ display.text = (Math.floor(display.text.valueOf())).toString()
+ } else if (op == plusminus) {
+ display.text = (display.text.valueOf() * -1).toString()
+ } else if (op == squareRoot) {
+ display.text = (Math.sqrt(display.text.valueOf())).toString()
+ } else if (op == "mc") {
+ memory = 0;
+ } else if (op == "m+") {
+ memory += display.text.valueOf()
+ } else if (op == "mr") {
+ display.text = memory.toString()
+ } else if (op == "m-") {
+ memory = display.text.valueOf()
+ } else if (op == leftArrow) {
+ display.text = display.text.toString().slice(0, -1)
+ if (display.text.length == 0) {
+ display.text = "0"
+ }
+ } else if (op == "Off") {
+ Qt.quit();
+ } else if (op == "C") {
+ display.text = "0"
+ } else if (op == "AC") {
+ curVal = 0
+ memory = 0
+ lastOp = ""
+ display.text ="0"
+ }
+}
+
diff --git a/examples/qml/calculator/content/images/button-.png b/examples/qml/calculator/content/images/button-.png
new file mode 100644
index 0000000000..544e514536
--- /dev/null
+++ b/examples/qml/calculator/content/images/button-.png
Binary files differ
diff --git a/examples/qml/calculator/content/images/button-blue.png b/examples/qml/calculator/content/images/button-blue.png
new file mode 100644
index 0000000000..5f92de32d0
--- /dev/null
+++ b/examples/qml/calculator/content/images/button-blue.png
Binary files differ
diff --git a/examples/qml/calculator/content/images/button-green.png b/examples/qml/calculator/content/images/button-green.png
new file mode 100644
index 0000000000..36c93914c7
--- /dev/null
+++ b/examples/qml/calculator/content/images/button-green.png
Binary files differ
diff --git a/examples/qml/calculator/content/images/button-purple.png b/examples/qml/calculator/content/images/button-purple.png
new file mode 100644
index 0000000000..347cbbea9d
--- /dev/null
+++ b/examples/qml/calculator/content/images/button-purple.png
Binary files differ
diff --git a/examples/qml/calculator/content/images/button-red.png b/examples/qml/calculator/content/images/button-red.png
new file mode 100644
index 0000000000..3b335891ae
--- /dev/null
+++ b/examples/qml/calculator/content/images/button-red.png
Binary files differ
diff --git a/examples/qml/calculator/content/images/display.png b/examples/qml/calculator/content/images/display.png
new file mode 100644
index 0000000000..9507f4382e
--- /dev/null
+++ b/examples/qml/calculator/content/images/display.png
Binary files differ
diff --git a/examples/qml/calculator/content/qmldir b/examples/qml/calculator/content/qmldir
new file mode 100644
index 0000000000..a926b93fac
--- /dev/null
+++ b/examples/qml/calculator/content/qmldir
@@ -0,0 +1,2 @@
+Button Button.qml
+Display Display.qml
diff --git a/examples/qtquick/canvas/bezierCurve/bezierCurve.qml b/examples/qml/canvas/bezierCurve/bezierCurve.qml
index f57839b0a5..f57839b0a5 100644
--- a/examples/qtquick/canvas/bezierCurve/bezierCurve.qml
+++ b/examples/qml/canvas/bezierCurve/bezierCurve.qml
diff --git a/examples/qtquick/canvas/clip/clip.qml b/examples/qml/canvas/clip/clip.qml
index d861ff0a46..d861ff0a46 100644
--- a/examples/qtquick/canvas/clip/clip.qml
+++ b/examples/qml/canvas/clip/clip.qml
diff --git a/examples/qtquick/canvas/contents/Button.qml b/examples/qml/canvas/contents/Button.qml
index 1413cdb9fa..1413cdb9fa 100644
--- a/examples/qtquick/canvas/contents/Button.qml
+++ b/examples/qml/canvas/contents/Button.qml
diff --git a/examples/qtquick/canvas/contents/ScrollBar.qml b/examples/qml/canvas/contents/ScrollBar.qml
index 98b8efee4a..98b8efee4a 100644
--- a/examples/qtquick/canvas/contents/ScrollBar.qml
+++ b/examples/qml/canvas/contents/ScrollBar.qml
diff --git a/examples/qtquick/canvas/contents/Slider.qml b/examples/qml/canvas/contents/Slider.qml
index 1050e307f6..1050e307f6 100644
--- a/examples/qtquick/canvas/contents/Slider.qml
+++ b/examples/qml/canvas/contents/Slider.qml
diff --git a/examples/qtquick/canvas/contents/Stocks.qml b/examples/qml/canvas/contents/Stocks.qml
index 043bca132e..043bca132e 100644
--- a/examples/qtquick/canvas/contents/Stocks.qml
+++ b/examples/qml/canvas/contents/Stocks.qml
diff --git a/examples/qtquick/canvas/contents/TitleBar.qml b/examples/qml/canvas/contents/TitleBar.qml
index 28edda2ae7..28edda2ae7 100644
--- a/examples/qtquick/canvas/contents/TitleBar.qml
+++ b/examples/qml/canvas/contents/TitleBar.qml
diff --git a/examples/qtquick/canvas/contents/ToolBar.qml b/examples/qml/canvas/contents/ToolBar.qml
index 7ae7391ddf..7ae7391ddf 100644
--- a/examples/qtquick/canvas/contents/ToolBar.qml
+++ b/examples/qml/canvas/contents/ToolBar.qml
diff --git a/examples/qtquick/canvas/contents/images/button-pressed.png b/examples/qml/canvas/contents/images/button-pressed.png
index e434d327f2..e434d327f2 100644
--- a/examples/qtquick/canvas/contents/images/button-pressed.png
+++ b/examples/qml/canvas/contents/images/button-pressed.png
Binary files differ
diff --git a/examples/qtquick/canvas/contents/images/button.png b/examples/qml/canvas/contents/images/button.png
index 56a63ce641..56a63ce641 100644
--- a/examples/qtquick/canvas/contents/images/button.png
+++ b/examples/qml/canvas/contents/images/button.png
Binary files differ
diff --git a/examples/qtquick/canvas/contents/images/default.svg b/examples/qml/canvas/contents/images/default.svg
index 248199cc4e..248199cc4e 100644
--- a/examples/qtquick/canvas/contents/images/default.svg
+++ b/examples/qml/canvas/contents/images/default.svg
diff --git a/examples/qtquick/canvas/contents/images/gloss.png b/examples/qml/canvas/contents/images/gloss.png
index 5d370cd93d..5d370cd93d 100755
--- a/examples/qtquick/canvas/contents/images/gloss.png
+++ b/examples/qml/canvas/contents/images/gloss.png
Binary files differ
diff --git a/examples/qtquick/canvas/contents/images/lineedit.png b/examples/qml/canvas/contents/images/lineedit.png
index 2cc38dc35b..2cc38dc35b 100755
--- a/examples/qtquick/canvas/contents/images/lineedit.png
+++ b/examples/qml/canvas/contents/images/lineedit.png
Binary files differ
diff --git a/examples/qtquick/canvas/contents/images/lineedit.sci b/examples/qml/canvas/contents/images/lineedit.sci
index 054bff78be..054bff78be 100644
--- a/examples/qtquick/canvas/contents/images/lineedit.sci
+++ b/examples/qml/canvas/contents/images/lineedit.sci
diff --git a/examples/qtquick/canvas/contents/images/quit.png b/examples/qml/canvas/contents/images/quit.png
index 5bda1b6e0d..5bda1b6e0d 100755
--- a/examples/qtquick/canvas/contents/images/quit.png
+++ b/examples/qml/canvas/contents/images/quit.png
Binary files differ
diff --git a/examples/qtquick/canvas/contents/images/stripes.png b/examples/qml/canvas/contents/images/stripes.png
index 9f36727ea4..9f36727ea4 100755
--- a/examples/qtquick/canvas/contents/images/stripes.png
+++ b/examples/qml/canvas/contents/images/stripes.png
Binary files differ
diff --git a/examples/qtquick/canvas/contents/images/titlebar.png b/examples/qml/canvas/contents/images/titlebar.png
index 51c90082d0..51c90082d0 100755
--- a/examples/qtquick/canvas/contents/images/titlebar.png
+++ b/examples/qml/canvas/contents/images/titlebar.png
Binary files differ
diff --git a/examples/qtquick/canvas/contents/images/titlebar.sci b/examples/qml/canvas/contents/images/titlebar.sci
index 0418d94cd6..0418d94cd6 100644
--- a/examples/qtquick/canvas/contents/images/titlebar.sci
+++ b/examples/qml/canvas/contents/images/titlebar.sci
diff --git a/examples/qtquick/canvas/contents/images/toolbutton.png b/examples/qml/canvas/contents/images/toolbutton.png
index 11310013ee..11310013ee 100755
--- a/examples/qtquick/canvas/contents/images/toolbutton.png
+++ b/examples/qml/canvas/contents/images/toolbutton.png
Binary files differ
diff --git a/examples/qtquick/canvas/contents/images/toolbutton.sci b/examples/qml/canvas/contents/images/toolbutton.sci
index 9e4f965307..9e4f965307 100644
--- a/examples/qtquick/canvas/contents/images/toolbutton.sci
+++ b/examples/qml/canvas/contents/images/toolbutton.sci
diff --git a/examples/qtquick/canvas/contents/qt-logo.png b/examples/qml/canvas/contents/qt-logo.png
index 5ab3a1b0c4..5ab3a1b0c4 100644
--- a/examples/qtquick/canvas/contents/qt-logo.png
+++ b/examples/qml/canvas/contents/qt-logo.png
Binary files differ
diff --git a/examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml
index bc3ca0071a..bc3ca0071a 100644
--- a/examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml
+++ b/examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml
diff --git a/examples/qtquick/canvas/roundedrect/roundedrect.qml b/examples/qml/canvas/roundedrect/roundedrect.qml
index fd86c63a3b..fd86c63a3b 100644
--- a/examples/qtquick/canvas/roundedrect/roundedrect.qml
+++ b/examples/qml/canvas/roundedrect/roundedrect.qml
diff --git a/examples/qtquick/canvas/smile/smile.qml b/examples/qml/canvas/smile/smile.qml
index 28a48a6c81..28a48a6c81 100644
--- a/examples/qtquick/canvas/smile/smile.qml
+++ b/examples/qml/canvas/smile/smile.qml
diff --git a/examples/qtquick/canvas/squircle/squircle.png b/examples/qml/canvas/squircle/squircle.png
index 86c69d945f..86c69d945f 100644
--- a/examples/qtquick/canvas/squircle/squircle.png
+++ b/examples/qml/canvas/squircle/squircle.png
Binary files differ
diff --git a/examples/qtquick/canvas/squircle/squircle.qml b/examples/qml/canvas/squircle/squircle.qml
index 2fc65b67b3..2fc65b67b3 100644
--- a/examples/qtquick/canvas/squircle/squircle.qml
+++ b/examples/qml/canvas/squircle/squircle.qml
diff --git a/examples/qtquick/canvas/stockchart/README b/examples/qml/canvas/stockchart/README
index 2652866ed6..2652866ed6 100644
--- a/examples/qtquick/canvas/stockchart/README
+++ b/examples/qml/canvas/stockchart/README
diff --git a/examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir
index 4c60e556d4..4c60e556d4 100644
--- a/examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir
+++ b/examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir
diff --git a/examples/qtquick/canvas/stockchart/model.cpp b/examples/qml/canvas/stockchart/model.cpp
index 42eb2d592f..42eb2d592f 100644
--- a/examples/qtquick/canvas/stockchart/model.cpp
+++ b/examples/qml/canvas/stockchart/model.cpp
diff --git a/examples/qtquick/canvas/stockchart/model.h b/examples/qml/canvas/stockchart/model.h
index 95e6f4891c..95e6f4891c 100644
--- a/examples/qtquick/canvas/stockchart/model.h
+++ b/examples/qml/canvas/stockchart/model.h
diff --git a/examples/qml/canvas/stockchart/plugin.cpp b/examples/qml/canvas/stockchart/plugin.cpp
new file mode 100644
index 0000000000..3b354e2b31
--- /dev/null
+++ b/examples/qml/canvas/stockchart/plugin.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/QQmlExtensionPlugin>
+#include <QtQml/qqml.h>
+#include <QtGui/QGuiApplication>
+#include "model.h"
+
+class QStockChartExampleQmlPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample"));
+ qmlRegisterType<StockModel>(uri, 1, 0, "StockModel");
+ qmlRegisterType<StockPrice>(uri, 1, 0, "StockPrice");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin);
diff --git a/examples/qtquick/canvas/stockchart/stock.qml b/examples/qml/canvas/stockchart/stock.qml
index 1c95fde2ce..1c95fde2ce 100644
--- a/examples/qtquick/canvas/stockchart/stock.qml
+++ b/examples/qml/canvas/stockchart/stock.qml
diff --git a/examples/qml/canvas/stockchart/stockchart.pro b/examples/qml/canvas/stockchart/stockchart.pro
new file mode 100644
index 0000000000..0e3ca82c44
--- /dev/null
+++ b/examples/qml/canvas/stockchart/stockchart.pro
@@ -0,0 +1,20 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml network
+
+DESTDIR = com/nokia/StockChartExample
+TARGET = qmlstockchartexampleplugin
+
+SOURCES += model.cpp plugin.cpp
+HEADERS += model.h
+qqmlsources.files += \
+ com/nokia/StockChartExample/qmldir \
+ stock.qml
+
+qqmlsources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample
+
+sources.files += stockchart.pro model.h model.cpp plugin.cpp README
+sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins
+target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample
+
+INSTALLS += qqmlsources sources target
diff --git a/examples/qtquick/canvas/tiger/tiger.js b/examples/qml/canvas/tiger/tiger.js
index 4be0d26c9d..4be0d26c9d 100644
--- a/examples/qtquick/canvas/tiger/tiger.js
+++ b/examples/qml/canvas/tiger/tiger.js
diff --git a/examples/qtquick/canvas/tiger/tiger.qml b/examples/qml/canvas/tiger/tiger.qml
index 2eb1bb2106..2eb1bb2106 100644
--- a/examples/qtquick/canvas/tiger/tiger.qml
+++ b/examples/qml/canvas/tiger/tiger.qml
diff --git a/examples/qtquick/canvas/twitterfriends/TwitterUser.qml b/examples/qml/canvas/twitterfriends/TwitterUser.qml
index 8b906216ef..8b906216ef 100644
--- a/examples/qtquick/canvas/twitterfriends/TwitterUser.qml
+++ b/examples/qml/canvas/twitterfriends/TwitterUser.qml
diff --git a/examples/qtquick/canvas/twitterfriends/cache.js b/examples/qml/canvas/twitterfriends/cache.js
index 6c8a1cd71a..6c8a1cd71a 100644
--- a/examples/qtquick/canvas/twitterfriends/cache.js
+++ b/examples/qml/canvas/twitterfriends/cache.js
diff --git a/examples/qtquick/canvas/twitterfriends/twitter.qml b/examples/qml/canvas/twitterfriends/twitter.qml
index 9dc2bcc939..9dc2bcc939 100644
--- a/examples/qtquick/canvas/twitterfriends/twitter.qml
+++ b/examples/qml/canvas/twitterfriends/twitter.qml
diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.cpp b/examples/qml/cppextensions/imageprovider/imageprovider.cpp
index 7fe4b72c08..f6632a89e8 100644
--- a/examples/qml/cppextensions/imageprovider/imageprovider.cpp
+++ b/examples/qml/cppextensions/imageprovider/imageprovider.cpp
@@ -39,19 +39,19 @@
****************************************************************************/
-#include <qdeclarativeextensionplugin.h>
+#include <qqmlextensionplugin.h>
-#include <qdeclarativeengine.h>
-#include <qdeclarativeimageprovider.h>
+#include <qqmlengine.h>
+#include <qqmlimageprovider.h>
#include <QImage>
#include <QPainter>
//![0]
-class ColorImageProvider : public QDeclarativeImageProvider
+class ColorImageProvider : public QQmlImageProvider
{
public:
ColorImageProvider()
- : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap)
+ : QQmlImageProvider(QQmlImageProvider::Pixmap)
{
}
@@ -84,17 +84,17 @@ public:
//![1]
-class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin
+class ImageProviderExtensionPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "imageprovider.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "imageprovider.json")
public:
void registerTypes(const char *uri)
{
Q_UNUSED(uri);
}
- void initializeEngine(QDeclarativeEngine *engine, const char *uri)
+ void initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(uri);
engine->addImageProvider("colors", new ColorImageProvider);
@@ -103,7 +103,7 @@ public:
};
-#define QDeclarativeExtensionInterface_iid "org.qt-project.Qt.QDeclarativeExtensionInterface"
+#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface"
#include "imageprovider.moc"
diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.pro b/examples/qml/cppextensions/imageprovider/imageprovider.pro
index dd128d56a8..b4a832b720 100644
--- a/examples/qml/cppextensions/imageprovider/imageprovider.pro
+++ b/examples/qml/cppextensions/imageprovider/imageprovider.pro
@@ -1,6 +1,6 @@
TEMPLATE = lib
CONFIG += qt plugin
-QT += declarative
+QT += qml
DESTDIR = ImageProviderCore
TARGET = qmlimageproviderplugin
@@ -10,13 +10,13 @@ SOURCES += imageprovider.cpp
OTHER_FILES += imageprovider.json
sources.files = $$SOURCES imageprovider.qml imageprovider.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore
ImageProviderCore_sources.files = \
ImageProviderCore/qmldir
-ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore
+ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore
INSTALLS = sources ImageProviderCore_sources target
diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp
index 2bad2aa285..6ebded0512 100644
--- a/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp
+++ b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp
@@ -42,13 +42,13 @@
#include <QNetworkAccessManager>
#include <QNetworkProxy>
-#include <QDeclarativeEngine>
-#include <QDeclarativeNetworkAccessManagerFactory>
+#include <QQmlEngine>
+#include <QQmlNetworkAccessManagerFactory>
#include <QtQuick/QQuickView>
/*
- This example illustrates using a QDeclarativeNetworkAccessManagerFactory to
+ This example illustrates using a QQmlNetworkAccessManagerFactory to
create a QNetworkAccessManager with a proxy.
Usage:
@@ -58,7 +58,7 @@
static QString proxyHost;
static int proxyPort = 0;
-class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory
+class MyNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
{
public:
virtual QNetworkAccessManager *create(QObject *parent);
diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro
index 479af364d0..6cbc24a7b8 100644
--- a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro
+++ b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro
@@ -1,4 +1,4 @@
-QT += declarative quick network
+QT += qml quick network
SOURCES += main.cpp
RESOURCES += networkaccessmanagerfactory.qrc
diff --git a/examples/qml/cppextensions/plugins/plugin.cpp b/examples/qml/cppextensions/plugins/plugin.cpp
index 4ba0a928eb..5e9900cb4f 100644
--- a/examples/qml/cppextensions/plugins/plugin.cpp
+++ b/examples/qml/cppextensions/plugins/plugin.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtDeclarative/QDeclarativeExtensionPlugin>
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/QQmlExtensionPlugin>
+#include <QtQml/qqml.h>
#include <qdebug.h>
#include <qdatetime.h>
#include <qbasictimer.h>
@@ -138,10 +138,10 @@ int TimeModel::instances=0;
MinuteTimer *TimeModel::timer=0;
//![plugin]
-class QExampleQmlPlugin : public QDeclarativeExtensionPlugin
+class QExampleQmlPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "plugin.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json")
public:
void registerTypes(const char *uri)
diff --git a/examples/qml/cppextensions/plugins/plugins.pro b/examples/qml/cppextensions/plugins/plugins.pro
index a28582a07a..08a4d1a61c 100644
--- a/examples/qml/cppextensions/plugins/plugins.pro
+++ b/examples/qml/cppextensions/plugins/plugins.pro
@@ -1,6 +1,6 @@
TEMPLATE = lib
CONFIG += qt plugin
-QT += declarative
+QT += qml
DESTDIR = com/nokia/TimeExample
TARGET = qmlqtimeexampleplugin
@@ -17,11 +17,11 @@ qdeclarativesources.files += \
com/nokia/TimeExample/hour.png \
com/nokia/TimeExample/minute.png
-qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample
sources.files += plugins.pro plugin.cpp plugins.qml README
-sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins
-target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample
+sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins
+target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample
INSTALLS += qdeclarativesources sources target
diff --git a/examples/qml/cppextensions/referenceexamples/adding/adding.pro b/examples/qml/cppextensions/referenceexamples/adding/adding.pro
index 1a972926b7..706322e9ff 100644
--- a/examples/qml/cppextensions/referenceexamples/adding/adding.pro
+++ b/examples/qml/cppextensions/referenceexamples/adding/adding.pro
@@ -1,11 +1,11 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp
HEADERS += person.h
RESOURCES += adding.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/adding/main.cpp b/examples/qml/cppextensions/referenceexamples/adding/main.cpp
index 4c1918b6de..c3a0ab6812 100644
--- a/examples/qml/cppextensions/referenceexamples/adding/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/adding/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "person.h"
@@ -50,8 +50,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Person>("People", 1,0, "Person");
//![0]
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
Person *person = qobject_cast<Person *>(component.create());
if (person) {
qWarning() << "The person's name is" << person->name();
diff --git a/examples/qml/cppextensions/referenceexamples/attached/attached.pro b/examples/qml/cppextensions/referenceexamples/attached/attached.pro
index 4cfd4e0aed..f4385e1a30 100644
--- a/examples/qml/cppextensions/referenceexamples/attached/attached.pro
+++ b/examples/qml/cppextensions/referenceexamples/attached/attached.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -7,7 +7,7 @@ HEADERS += person.h \
birthdayparty.h
RESOURCES += attached.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp
index feefef4fe1..c4f906119a 100644
--- a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp
@@ -69,9 +69,9 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h
index c789c0bd51..1da6c34026 100644
--- a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h
@@ -42,7 +42,7 @@
#include <QObject>
#include <QDate>
-#include <qdeclarative.h>
+#include <qqml.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -63,7 +63,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *host READ host WRITE setHost)
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -71,7 +71,7 @@ public:
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/attached/main.cpp b/examples/qml/cppextensions/referenceexamples/attached/main.cpp
index 4c2c3003fe..ce067bbbf7 100644
--- a/examples/qml/cppextensions/referenceexamples/attached/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/attached/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -55,8 +55,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Boy>("People", 1,0, "Boy");
qmlRegisterType<Girl>("People", 1,0, "Girl");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/binding/binding.pro b/examples/qml/cppextensions/referenceexamples/binding/binding.pro
index 2add33fa47..0379f93ea7 100644
--- a/examples/qml/cppextensions/referenceexamples/binding/binding.pro
+++ b/examples/qml/cppextensions/referenceexamples/binding/binding.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -9,7 +9,7 @@ HEADERS += person.h \
happybirthdaysong.h
RESOURCES += binding.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp
index 4f5acdfb75..62499862f0 100644
--- a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp
@@ -75,9 +75,9 @@ void BirthdayParty::setHost(Person *c)
emit hostChanged();
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h
index 376d107f26..195e9cd9cf 100644
--- a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QDate>
#include <QDebug>
-#include <qdeclarative.h>
+#include <qqml.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -69,7 +69,7 @@ class BirthdayParty : public QObject
// ![0]
Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged)
// ![0]
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement)
Q_CLASSINFO("DefaultProperty", "guests")
public:
@@ -78,7 +78,7 @@ public:
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp
index df4dbec9c4..90220e15ae 100644
--- a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp
+++ b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp
@@ -49,7 +49,7 @@ HappyBirthdaySong::HappyBirthdaySong(QObject *parent)
timer->start(1000);
}
-void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p)
+void HappyBirthdaySong::setTarget(const QQmlProperty &p)
{
m_target = p;
}
diff --git a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h
index a9f3a94544..ace48b2af0 100644
--- a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h
+++ b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h
@@ -40,20 +40,20 @@
#ifndef HAPPYBIRTHDAYSONG_H
#define HAPPYBIRTHDAYSONG_H
-#include <QDeclarativePropertyValueSource>
-#include <QDeclarativeProperty>
+#include <QQmlPropertyValueSource>
+#include <QQmlProperty>
#include <QStringList>
-class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource
+class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_INTERFACES(QDeclarativePropertyValueSource)
+ Q_INTERFACES(QQmlPropertyValueSource)
public:
HappyBirthdaySong(QObject *parent = 0);
- virtual void setTarget(const QDeclarativeProperty &);
+ virtual void setTarget(const QQmlProperty &);
QString name() const;
void setName(const QString &);
@@ -66,7 +66,7 @@ signals:
private:
int m_line;
QStringList m_lyrics;
- QDeclarativeProperty m_target;
+ QQmlProperty m_target;
QString m_name;
};
diff --git a/examples/qml/cppextensions/referenceexamples/binding/main.cpp b/examples/qml/cppextensions/referenceexamples/binding/main.cpp
index 551d24b702..389cb7609b 100644
--- a/examples/qml/cppextensions/referenceexamples/binding/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/binding/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "happybirthdaysong.h"
@@ -56,8 +56,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Boy>("People", 1,0, "Boy");
qmlRegisterType<Girl>("People", 1,0, "Girl");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp
index 1859ca9461..e15ffe1604 100644
--- a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp
@@ -54,9 +54,9 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h
index 4315d3727e..43611693d9 100644
--- a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h
@@ -41,7 +41,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
#include "person.h"
class BirthdayParty : public QObject
@@ -49,7 +49,7 @@ class BirthdayParty : public QObject
Q_OBJECT
// ![0]
Q_PROPERTY(Person *host READ host WRITE setHost)
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
// ![0]
public:
BirthdayParty(QObject *parent = 0);
@@ -57,7 +57,7 @@ public:
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro
index 742b85b683..60e8532bab 100644
--- a/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro
+++ b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -7,7 +7,7 @@ HEADERS += person.h \
birthdayparty.h
RESOURCES += coercion.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/coercion/main.cpp b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp
index 95b309de4c..15e41ca597 100644
--- a/examples/qml/cppextensions/referenceexamples/coercion/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -58,8 +58,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Girl>("People", 1,0, "Girl");
//![register boy girl]
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp
index 1859ca9461..e15ffe1604 100644
--- a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp
@@ -54,9 +54,9 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h
index cfca6689db..3ee635039d 100644
--- a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h
@@ -41,7 +41,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
#include "person.h"
// ![0]
@@ -49,7 +49,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *host READ host WRITE setHost)
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -57,7 +57,7 @@ public:
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/default/default.pro b/examples/qml/cppextensions/referenceexamples/default/default.pro
index 6533cdd7d3..36ef39fc55 100644
--- a/examples/qml/cppextensions/referenceexamples/default/default.pro
+++ b/examples/qml/cppextensions/referenceexamples/default/default.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -7,7 +7,7 @@ HEADERS += person.h \
birthdayparty.h
RESOURCES += default.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/default/main.cpp b/examples/qml/cppextensions/referenceexamples/default/main.cpp
index 3a03279129..175945fc5d 100644
--- a/examples/qml/cppextensions/referenceexamples/default/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/default/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -53,8 +53,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Boy>("People", 1,0, "Boy");
qmlRegisterType<Girl>("People", 1,0, "Girl");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/extended/extended.pro b/examples/qml/cppextensions/referenceexamples/extended/extended.pro
index 3d9f59c470..206ea19c61 100644
--- a/examples/qml/cppextensions/referenceexamples/extended/extended.pro
+++ b/examples/qml/cppextensions/referenceexamples/extended/extended.pro
@@ -1,11 +1,11 @@
-QT += declarative widgets
+QT += qml widgets
SOURCES += main.cpp \
lineedit.cpp
HEADERS += lineedit.h
RESOURCES += extended.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp
index 8f7fd8aa93..a3b1d0d54e 100644
--- a/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp
+++ b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
#include "lineedit.h"
-#include <qdeclarative.h>
+#include <qqml.h>
LineEditExtension::LineEditExtension(QObject *object)
: QObject(object), m_lineedit(static_cast<QLineEdit *>(object))
diff --git a/examples/qml/cppextensions/referenceexamples/extended/main.cpp b/examples/qml/cppextensions/referenceexamples/extended/main.cpp
index 3c580396f2..de7c450169 100644
--- a/examples/qml/cppextensions/referenceexamples/extended/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/extended/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include <QLineEdit>
#include "lineedit.h"
@@ -50,8 +50,8 @@ int main(int argc, char ** argv)
qmlRegisterExtendedType<QLineEdit, LineEditExtension>("People", 1,0, "QLineEdit");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
QLineEdit *edit = qobject_cast<QLineEdit *>(component.create());
if (edit) {
diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp
index 1859ca9461..e15ffe1604 100644
--- a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp
@@ -54,9 +54,9 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h
index 491903adc5..5ca0e9b982 100644
--- a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h
@@ -41,14 +41,14 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
#include "person.h"
class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *host READ host WRITE setHost)
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -56,7 +56,7 @@ public:
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro
index aab0c8469a..d32a98f79b 100644
--- a/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro
+++ b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -7,7 +7,7 @@ HEADERS += person.h \
birthdayparty.h
RESOURCES += grouped.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/grouped/main.cpp b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp
index de7d714c52..55be3b715b 100644
--- a/examples/qml/cppextensions/referenceexamples/grouped/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -54,8 +54,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Boy>("People", 1,0, "Boy");
qmlRegisterType<Girl>("People", 1,0, "Girl");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp
index 35444f505a..c96f41d944 100644
--- a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp
@@ -55,9 +55,9 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h
index e49afdb78d..df8a859972 100644
--- a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h
@@ -41,21 +41,21 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
#include "person.h"
class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *host READ host WRITE setHost)
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
public:
BirthdayParty(QObject *parent = 0);
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/methods/main.cpp b/examples/qml/cppextensions/referenceexamples/methods/main.cpp
index d037d88f20..1e502c3943 100644
--- a/examples/qml/cppextensions/referenceexamples/methods/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/methods/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -51,8 +51,8 @@ int main(int argc, char ** argv)
qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
qmlRegisterType<Person>("People", 1,0, "Person");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/methods/methods.pro b/examples/qml/cppextensions/referenceexamples/methods/methods.pro
index ee28355188..f4c63bfa29 100644
--- a/examples/qml/cppextensions/referenceexamples/methods/methods.pro
+++ b/examples/qml/cppextensions/referenceexamples/methods/methods.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -7,7 +7,7 @@ HEADERS += person.h \
birthdayparty.h
RESOURCES += methods.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp
index 0038cd0a41..8e79d07748 100644
--- a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp
@@ -55,9 +55,9 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h
index 2c3d128b6d..84eefa52ae 100644
--- a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h
@@ -41,7 +41,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
#include "person.h"
// ![0]
@@ -53,7 +53,7 @@ class BirthdayParty : public QObject
Q_PROPERTY(Person *host READ host WRITE setHost)
// ![1]
// ![2]
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
// ![2]
// ![3]
public:
@@ -62,7 +62,7 @@ public:
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/properties/main.cpp b/examples/qml/cppextensions/referenceexamples/properties/main.cpp
index 421ce9fbaa..cc0de89221 100644
--- a/examples/qml/cppextensions/referenceexamples/properties/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/properties/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -53,8 +53,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Person>("People", 1,0, "Person");
//![register list]
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/properties/properties.pro b/examples/qml/cppextensions/referenceexamples/properties/properties.pro
index 936d0ea429..e079b1f79e 100644
--- a/examples/qml/cppextensions/referenceexamples/properties/properties.pro
+++ b/examples/qml/cppextensions/referenceexamples/properties/properties.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -7,7 +7,7 @@ HEADERS += person.h \
birthdayparty.h
RESOURCES += properties.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp
index d576c2a278..b9f7e15907 100644
--- a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp
@@ -70,9 +70,9 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h
index 45ad4f0acf..3f1b020b5a 100644
--- a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h
@@ -42,7 +42,7 @@
#include <QObject>
#include <QDate>
-#include <qdeclarative.h>
+#include <qqml.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -63,7 +63,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *host READ host WRITE setHost)
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -71,7 +71,7 @@ public:
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/signal/main.cpp b/examples/qml/cppextensions/referenceexamples/signal/main.cpp
index 5800cf450f..21a26d9b67 100644
--- a/examples/qml/cppextensions/referenceexamples/signal/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/signal/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -55,8 +55,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Boy>("People", 1,0, "Boy");
qmlRegisterType<Girl>("People", 1,0, "Girl");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/signal/signal.pro b/examples/qml/cppextensions/referenceexamples/signal/signal.pro
index 8ffdb50f90..d426e398a5 100644
--- a/examples/qml/cppextensions/referenceexamples/signal/signal.pro
+++ b/examples/qml/cppextensions/referenceexamples/signal/signal.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -7,7 +7,7 @@ HEADERS += person.h \
birthdayparty.h
RESOURCES += signal.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal
INSTALLS += target sources
diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp
index 09137c41a8..aa8bc77116 100644
--- a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp
@@ -70,9 +70,9 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QDeclarativeListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
- return QDeclarativeListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h
index 5d561da807..f3635e899b 100644
--- a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h
+++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QDate>
#include <QDebug>
-#include <qdeclarative.h>
+#include <qqml.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -64,7 +64,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *host READ host WRITE setHost)
- Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
// ![0]
Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement)
// ![0]
@@ -75,7 +75,7 @@ public:
Person *host() const;
void setHost(Person *);
- QDeclarativeListProperty<Person> guests();
+ QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp
index 629c354543..d69154b57a 100644
--- a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp
+++ b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp
@@ -49,7 +49,7 @@ HappyBirthdaySong::HappyBirthdaySong(QObject *parent)
timer->start(1000);
}
-void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p)
+void HappyBirthdaySong::setTarget(const QQmlProperty &p)
{
m_target = p;
}
diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h
index 9721350435..19e47c28ac 100644
--- a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h
+++ b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h
@@ -40,24 +40,24 @@
#ifndef HAPPYBIRTHDAYSONG_H
#define HAPPYBIRTHDAYSONG_H
-#include <QDeclarativePropertyValueSource>
-#include <QDeclarativeProperty>
-#include <qdeclarative.h>
+#include <QQmlPropertyValueSource>
+#include <QQmlProperty>
+#include <qqml.h>
#include <QStringList>
// ![0]
-class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource
+class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource
{
Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueSource)
+ Q_INTERFACES(QQmlPropertyValueSource)
// ![0]
Q_PROPERTY(QString name READ name WRITE setName)
// ![1]
public:
HappyBirthdaySong(QObject *parent = 0);
- virtual void setTarget(const QDeclarativeProperty &);
+ virtual void setTarget(const QQmlProperty &);
// ![1]
QString name() const;
@@ -69,7 +69,7 @@ private slots:
private:
int m_line;
QStringList m_lyrics;
- QDeclarativeProperty m_target;
+ QQmlProperty m_target;
QString m_name;
// ![2]
};
diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp
index 53d676dfbe..e119e719af 100644
--- a/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp
+++ b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "happybirthdaysong.h"
@@ -57,8 +57,8 @@ int main(int argc, char ** argv)
qmlRegisterType<Boy>("People", 1,0, "Boy");
qmlRegisterType<Girl>("People", 1,0, "Girl");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:example.qml"));
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->host()) {
diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro
index a978d8452a..afc1784d71 100644
--- a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro
+++ b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
SOURCES += main.cpp \
person.cpp \
@@ -9,7 +9,7 @@ HEADERS += person.h \
happybirthdaysong.h
RESOURCES += valuesource.qrc
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource
INSTALLS += target sources
diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/qml/draganddrop/dragtarget.qmlproject
index 2bb4016996..2bb4016996 100644
--- a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject
+++ b/examples/qml/draganddrop/dragtarget.qmlproject
diff --git a/examples/qml/draganddrop/tiles/DragTile.qml b/examples/qml/draganddrop/tiles/DragTile.qml
new file mode 100644
index 0000000000..2813fa8caf
--- /dev/null
+++ b/examples/qml/draganddrop/tiles/DragTile.qml
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+ property string colorKey
+
+ width: 100; height: 100
+
+ MouseArea {
+ id: mouseArea
+
+ width: 100; height: 100
+ anchors.centerIn: parent
+
+ drag.target: tile
+
+ onReleased: parent = tile.Drag.target !== null ? tile.Drag.target : root
+
+ Rectangle {
+ id: tile
+
+ width: 100; height: 100
+
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter
+ color: colorKey
+
+ Drag.keys: [ colorKey ]
+ Drag.active: mouseArea.drag.active
+ Drag.hotSpot.x: 50
+ Drag.hotSpot.y: 50
+
+ Text {
+ anchors.fill: parent
+ color: "white"
+ font.pixelSize: 90
+ text: modelData + 1
+ horizontalAlignment:Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ states: State {
+ when: mouseArea.drag.active
+ ParentChange { target: tile; parent: root }
+ AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined }
+ }
+ }
+ }
+}
+
diff --git a/examples/qml/draganddrop/tiles/DropTile.qml b/examples/qml/draganddrop/tiles/DropTile.qml
new file mode 100644
index 0000000000..e8566f04cc
--- /dev/null
+++ b/examples/qml/draganddrop/tiles/DropTile.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+DropArea {
+ id: dragTarget
+
+ property string colorKey
+ property alias dropProxy: dragTarget
+
+ width: 100; height: 100
+ keys: [ colorKey ]
+
+ Rectangle {
+ id: dropRectangle
+
+ anchors.fill: parent
+ color: colorKey
+
+ states: [
+ State {
+ when: dragTarget.containsDrag
+ PropertyChanges {
+ target: dropRectangle
+ color: "grey"
+ }
+ }
+ ]
+ }
+}
diff --git a/examples/qml/draganddrop/tiles/tiles.qml b/examples/qml/draganddrop/tiles/tiles.qml
new file mode 100644
index 0000000000..31c87f8244
--- /dev/null
+++ b/examples/qml/draganddrop/tiles/tiles.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 620
+ height: 410
+
+ color: "black"
+
+ Grid {
+ id: redDestination
+
+ anchors.left: redSource.right; anchors.top: parent.top;
+ anchors.margins: 5
+ width: 300
+ height: 300
+ opacity: 0.5
+ columns: 3
+
+ Repeater {
+ model: 9;
+ delegate: DropTile { colorKey: "red" }
+ }
+ }
+
+ Grid {
+ anchors.right: blueSource.left; anchors.bottom: parent.bottom;
+ anchors.margins: 5
+ width: 300
+ height: 300
+
+ opacity: 0.5
+
+ columns: 3
+
+ Repeater {
+ model: 9
+ delegate: DropTile { colorKey: "blue" }
+ }
+ }
+
+ Column {
+ id: redSource
+
+ anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom
+ anchors.margins: 5
+ width: 100
+ spacing: -60
+
+ Repeater {
+ model: 9
+ delegate: DragTile { colorKey: "red" }
+ }
+ }
+ Column {
+ id: blueSource
+
+ anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: parent.bottom
+ anchors.margins: 5
+ width: 100
+ spacing: -60
+
+ Repeater {
+ model: 9
+ delegate: DragTile { colorKey: "blue" }
+ }
+ }
+}
diff --git a/examples/qml/draganddrop/views/gridview.qml b/examples/qml/draganddrop/views/gridview.qml
new file mode 100644
index 0000000000..375f3d2824
--- /dev/null
+++ b/examples/qml/draganddrop/views/gridview.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+GridView {
+ id: root
+ width: 360; height: 360
+ cellWidth: 90; cellHeight: 90
+
+ model: VisualDataModel {
+ id: visualModel
+ model: ListModel {
+ id: colorModel
+ ListElement { color: "blue" }
+ ListElement { color: "green" }
+ ListElement { color: "red" }
+ ListElement { color: "yellow" }
+ ListElement { color: "orange" }
+ ListElement { color: "purple" }
+ ListElement { color: "cyan" }
+ ListElement { color: "magenta" }
+ ListElement { color: "chartreuse" }
+ ListElement { color: "aquamarine" }
+ ListElement { color: "indigo" }
+ ListElement { color: "black" }
+ ListElement { color: "chartreuse" }
+ ListElement { color: "violet" }
+ ListElement { color: "grey" }
+ ListElement { color: "springgreen" }
+ }
+
+ delegate: MouseArea {
+ id: delegateRoot
+
+ property int visualIndex: VisualDataModel.itemsIndex
+
+ width: 90; height: 90
+ drag.target: icon
+
+ Rectangle {
+ id: icon
+ width: 80; height: 80
+ anchors {
+ horizontalCenter: parent.horizontalCenter;
+ verticalCenter: parent.verticalCenter
+ }
+ color: model.color
+ radius: 3
+
+ Drag.active: delegateRoot.pressed
+ Drag.source: delegateRoot
+ Drag.hotSpot.x: 40
+ Drag.hotSpot.y: 40
+
+ states: [
+ State {
+ when: icon.Drag.active
+ ParentChange {
+ target: icon
+ parent: root
+ }
+
+ AnchorChanges {
+ target: icon;
+ anchors.horizontalCenter: undefined;
+ anchors.verticalCenter: undefined
+ }
+ }
+ ]
+ }
+
+ DropArea {
+ anchors { fill: parent; margins: 15 }
+
+ onEntered: visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex)
+ }
+ }
+ }
+}
diff --git a/examples/qml/flickr/content/Button.qml b/examples/qml/flickr/content/Button.qml
new file mode 100644
index 0000000000..57f846aec3
--- /dev/null
+++ b/examples/qml/flickr/content/Button.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ signal clicked
+
+ property string text
+
+ BorderImage {
+ id: buttonImage
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ BorderImage {
+ id: pressed
+ opacity: 0
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ color: "white"
+ anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15
+ text: container.text; style: Text.Raised; styleColor: "black"
+ }
+ states: [
+ State {
+ name: "Pressed"
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ }
+ ]
+}
diff --git a/examples/qml/flickr/content/GridDelegate.qml b/examples/qml/flickr/content/GridDelegate.qml
new file mode 100644
index 0000000000..f8838bd609
--- /dev/null
+++ b/examples/qml/flickr/content/GridDelegate.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
+ }
+
+ Item {
+ anchors.centerIn: parent
+ scale: 0.0
+ Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
+ id: scaleMe
+
+ Item {
+ width: 77; height: 77; anchors.centerIn: parent
+ Rectangle {
+ id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
+ Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
+ Image { source: "images/gloss.png" }
+ }
+ }
+
+ Connections {
+ target: toolBar
+ onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
+ }
+
+ states: [
+ State {
+ name: "Show"; when: thumb.status == Image.Ready
+ PropertyChanges { target: scaleMe; scale: 1 }
+ },
+ State {
+ name: "Details"
+ PropertyChanges { target: scaleMe; scale: 1 }
+ ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
+ PropertyChanges { target: background; state: "DetailedView" }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "Show"; to: "Details"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ },
+ Transition {
+ from: "Details"; to: "Show"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ }
+ ]
+ }
+ MouseArea { anchors.fill: wrapper; onClicked: photoClicked() }
+}
+
diff --git a/examples/qml/flickr/content/ImageDetails.qml b/examples/qml/flickr/content/ImageDetails.qml
new file mode 100644
index 0000000000..42b5e845ea
--- /dev/null
+++ b/examples/qml/flickr/content/ImageDetails.qml
@@ -0,0 +1,323 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Flipable {
+ id: container
+
+ property alias frontContainer: containerFront
+ property string photoTitle: ""
+ property string photoTags: ""
+ property int photoWidth
+ property int photoHeight
+ property string photoType
+ property string photoAuthor
+ property string photoDate
+ property string photoUrl
+ property int rating: 2
+ property variant prevScale: 1.0
+
+ property int flipDuration: 1600
+
+ signal closed
+
+ transform: Rotation {
+ id: itemRotation
+ origin.x: container.width / 2;
+ axis.y: 1; axis.z: 0
+ }
+
+ front: Item {
+ id: containerFront; anchors.fill: container
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"; opacity: 0.4
+ }
+
+ Column {
+ spacing: 10
+ anchors {
+ left: parent.left; leftMargin: 10
+ right: parent.right; rightMargin: 10
+ top: parent.top; topMargin: 120
+ }
+ Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width }
+ }
+ }
+
+ back: Item {
+ anchors.fill: container
+
+ Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 }
+
+ Progress {
+ anchors.centerIn: parent; width: 200; height: 22
+ progress: bigImage.progress; visible: bigImage.status != Image.Ready
+ }
+
+ Flickable {
+ id: flickable; anchors.fill: parent; clip: true
+ contentWidth: imageContainer.width; contentHeight: imageContainer.height
+
+ function updateMinimumScale() {
+ if (bigImage.status == Image.Ready && bigImage.width != 0) {
+ slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
+ if (bigImage.width * slider.value > flickable.width) {
+ var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale;
+ flickable.contentX = xoff - flickable.width/2;
+ }
+ if (bigImage.height * slider.value > flickable.height) {
+ var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale;
+ flickable.contentY = yoff - flickable.height/2;
+ }
+ prevScale = slider.value;
+ }
+ }
+
+ onWidthChanged: updateMinimumScale()
+ onHeightChanged: updateMinimumScale()
+
+ Item {
+ id: imageContainer
+ width: Math.max(bigImage.width * bigImage.scale, flickable.width);
+ height: Math.max(bigImage.height * bigImage.scale, flickable.height);
+ Image {
+ id: bigImage; source: container.photoUrl; scale: slider.value
+ anchors.centerIn: parent; smooth: !flickable.movingVertically
+ onStatusChanged : {
+ // Default scale shows the entire image.
+ if (bigImage.status == Image.Ready && bigImage.width != 0) {
+ slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
+ prevScale = Math.min(slider.minimum, 1);
+ slider.value = prevScale;
+ }
+ if (inBackState && bigImage.status == Image.Ready)
+ effectBox.imageInAnim();
+ }
+ property bool inBackState: false
+ onInBackStateChanged:{
+ if(inBackState && bigImage.status == Image.Ready)
+ effectBox.imageInAnim();
+ else if (!inBackState && bigImage.status == Image.Ready)
+ effectBox.imageOutAnim();
+ }
+ }
+ ShaderEffectSource{
+ id: pictureSource
+ sourceItem: bigImage
+ smooth: true
+ //Workaround: Doesn't work below lines
+ width: bigImage.width
+ height: bigImage.width
+ visible: false
+ }
+ Turbulence{//only fill visible rect
+ id: turbulence
+ system: imageSystem
+ anchors.fill: parent
+ strength: 240
+ enabled: false
+ }
+
+ Item{
+ id: effectBox
+ width: bigImage.width * bigImage.scale
+ height: bigImage.height * bigImage.scale
+ anchors.centerIn: parent
+ function imageInAnim(){
+ bigImage.visible = false;
+ noiseIn.visible = true;
+ endEffectTimer.start();
+ }
+ function imageOutAnim(){
+ bigImage.visible = false;
+ noiseIn.visible = false;
+ turbulence.enabled = true;
+ endEffectTimer.start();
+ pixelEmitter.burst(2048);
+ }
+ Timer{
+ id: endEffectTimer
+ interval: flipDuration
+ repeat: false
+ running: false
+ onTriggered:{
+ turbulence.enabled = false;
+ noiseIn.visible = false;
+ bigImage.visible = true;
+ }
+ }
+ ShaderEffect{
+ id: noiseIn
+ anchors.fill: parent
+ property real t: 0
+ visible: false
+ onVisibleChanged: tAnim.start()
+ NumberAnimation{
+ id: tAnim
+ target: noiseIn
+ property: "t"
+ from: 0.0
+ to: 1.0
+ duration: flipDuration
+ }
+ property variant source: pictureSource
+ property variant noise: ShaderEffectSource{
+ sourceItem:Image{
+ source: "images/noise.png"
+ }
+ hideSource: true
+ smooth: false
+ }
+ fragmentShader:"
+ uniform sampler2D noise;
+ uniform sampler2D source;
+ uniform highp float t;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main(){
+ //Want to use noise2, but it always returns (0,0)?
+ if(texture2D(noise, qt_TexCoord0).w <= t)
+ gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity;
+ else
+ gl_FragColor = vec4(0.,0.,0.,0.);
+ }
+ "
+ }
+ ParticleSystem{
+ id: imageSystem
+ }
+ Emitter{
+ id: pixelEmitter
+ system: imageSystem
+ //anchors.fill: parent
+ width: Math.min(bigImage.width * bigImage.scale, flickable.width);
+ height: Math.min(bigImage.height * bigImage.scale, flickable.height);
+ anchors.centerIn: parent
+ size: 4
+ lifeSpan: flipDuration
+ emitRate: 2048
+ enabled: false
+ }
+ CustomParticle{
+ id: blowOut
+ system: imageSystem
+ property real maxWidth: effectBox.width
+ property real maxHeight: effectBox.height
+ vertexShader:"
+ uniform highp float maxWidth;
+ uniform highp float maxHeight;
+
+ varying highp vec2 fTex2;
+
+ void main() {
+ defaultMain();
+ fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight);
+ }
+ "
+ property variant pictureTexture: pictureSource
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D pictureTexture;
+ varying highp vec2 fTex2;
+ void main() {
+ gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity;
+ }"
+ }
+
+
+
+ }
+ }
+ }
+
+ Text {
+ text: "Image Unavailable"
+ visible: bigImage.status == Image.Error
+ anchors.centerIn: parent; color: "white"; font.bold: true
+ }
+
+ Slider {
+ id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum }
+ anchors {
+ bottom: parent.bottom; bottomMargin: 65
+ left: parent.left; leftMargin: 25
+ right: parent.right; rightMargin: 25
+ }
+ onValueChanged: {
+ if (bigImage.width * value > flickable.width) {
+ var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale;
+ flickable.contentX = xoff - flickable.width/2;
+ }
+ if (bigImage.height * value > flickable.height) {
+ var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale;
+ flickable.contentY = yoff - flickable.height/2;
+ }
+ prevScale = value;
+ }
+ }
+ }
+
+ states: State {
+ name: "Back"
+ PropertyChanges { target: itemRotation; angle: 180 }
+ PropertyChanges { target: toolBar; button2Visible: false }
+ PropertyChanges { target: toolBar; button1Label: "Back" }
+ PropertyChanges { target: bigImage; inBackState: true }
+ }
+
+ transitions: Transition {
+ SequentialAnimation {
+ PropertyAction { target: bigImage; property: "smooth"; value: false }
+ NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration }
+ PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically }
+ }
+ }
+}
diff --git a/examples/qml/flickr/content/ListDelegate.qml b/examples/qml/flickr/content/ListDelegate.qml
new file mode 100644
index 0000000000..00f837f862
--- /dev/null
+++ b/examples/qml/flickr/content/ListDelegate.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Component {
+ Item {
+ id: wrapper; width: wrapper.ListView.view.width; height: 86
+ Item {
+ id: moveMe
+ Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
+ Rectangle {
+ x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true
+
+ Image { source: imagePath; x: 1; y: 1 }
+ Image { source: "images/gloss.png" }
+ }
+ Column {
+ x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2
+ Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
+ Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
+ Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
+ }
+ }
+ }
+}
diff --git a/examples/qml/flickr/content/Progress.qml b/examples/qml/flickr/content/Progress.qml
new file mode 100644
index 0000000000..ed2629b48a
--- /dev/null
+++ b/examples/qml/flickr/content/Progress.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item{
+ id: container
+ property variant progress: 0
+
+ Rectangle {
+ anchors.fill: parent; smooth: true
+ border.color: "white"; border.width: 0; radius: height/2 - 2
+ gradient: Gradient {
+ GradientStop { position: 0; color: "#66343434" }
+ GradientStop { position: 1.0; color: "#66000000" }
+ }
+ }
+
+ ParticleSystem{
+ running: container.visible
+ id: barSys
+ }
+ ImageParticle{
+ color: "lightsteelblue"
+ alpha: 0.1
+ colorVariation: 0.05
+ source: "images/particle.png"
+ system: barSys
+ }
+ Emitter{
+ y: 2; height: parent.height-4;
+ x: 2; width: Math.max(parent.width * progress - 4, 0);
+ speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 }
+ system: barSys
+ emitRate: width;
+ lifeSpan: 1000
+ size: 20
+ sizeVariation: 4
+ endSize: 12
+ maximumEmitted: parent.width;
+ }
+
+ Text {
+ text: Math.round(progress * 100) + "%"
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15
+ }
+}
diff --git a/examples/qml/flickr/content/RssModel.qml b/examples/qml/flickr/content/RssModel.qml
new file mode 100644
index 0000000000..51cea498e6
--- /dev/null
+++ b/examples/qml/flickr/content/RssModel.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ property string tags : ""
+
+ function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")+"format=rss2"
+ query: "/rss/channel/item"
+ namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" }
+ XmlRole { name: "url"; query: "media:content/@url/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "tags"; query: "media:category/string()" }
+ XmlRole { name: "photoWidth"; query: "media:content/@width/string()" }
+ XmlRole { name: "photoHeight"; query: "media:content/@height/string()" }
+ XmlRole { name: "photoType"; query: "media:content/@type/string()" }
+ XmlRole { name: "photoAuthor"; query: "author/string()" }
+ XmlRole { name: "photoDate"; query: "pubDate/string()" }
+}
diff --git a/examples/qml/flickr/content/ScrollBar.qml b/examples/qml/flickr/content/ScrollBar.qml
new file mode 100644
index 0000000000..7c62ad088f
--- /dev/null
+++ b/examples/qml/flickr/content/ScrollBar.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property variant flickableArea
+
+ Rectangle {
+ radius: 5
+ color: "black"
+ opacity: 0.3
+ border.color: "white"
+ border.width: 2
+ x: 0
+ y: flickableArea.visibleArea.yPosition * container.height
+ width: parent.width
+ height: flickableArea.visibleArea.heightRatio * container.height
+ }
+ states: [
+ State {
+ name: "show"
+ when: flickableArea.movingVertically
+ PropertyChanges {
+ target: container
+ opacity: 1
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ target: container
+ properties: "opacity"
+ duration: 400
+ }
+ }
+ ]
+}
diff --git a/examples/qml/flickr/content/Slider.qml b/examples/qml/flickr/content/Slider.qml
new file mode 100644
index 0000000000..c4e743641f
--- /dev/null
+++ b/examples/qml/flickr/content/Slider.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: slider; width: 400; height: 16
+
+ // value is read/write.
+ property real value: 1
+ onValueChanged: updatePos();
+ property real maximum: 1
+ property real minimum: 1
+ property int xMax: width - handle.width - 4
+ onXMaxChanged: updatePos();
+ onMinimumChanged: updatePos();
+
+ function updatePos() {
+ if (maximum > minimum) {
+ var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum);
+ pos = Math.min(pos, width - handle.width - 2);
+ pos = Math.max(pos, 2);
+ handle.x = pos;
+ } else {
+ handle.x = 2;
+ }
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ border.color: "white"; border.width: 0; radius: 8
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#66343434" }
+ GradientStop { position: 1.0; color: "#66000000" }
+ }
+ }
+
+ Rectangle {
+ id: handle; smooth: true
+ y: 2; width: 30; height: slider.height-4; radius: 6
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightgray" }
+ GradientStop { position: 1.0; color: "gray" }
+ }
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent; drag.target: parent
+ drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2
+ onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; }
+ }
+ }
+}
diff --git a/examples/qml/flickr/content/TitleBar.qml b/examples/qml/flickr/content/TitleBar.qml
new file mode 100644
index 0000000000..223939f81a
--- /dev/null
+++ b/examples/qml/flickr/content/TitleBar.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: titleBar
+ property string untaggedString: "Uploads from everyone"
+ property string taggedString: "Recent uploads tagged "
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Item {
+ id: container
+ width: (parent.width * 2) - 55 ; height: parent.height
+
+ function accept() {
+ imageDetails.closed()
+ titleBar.state = ""
+ background.state = ""
+ rssModel.tags = editor.text
+ }
+
+ Image {
+ id: quitButton
+ anchors.left: parent.left//; anchors.leftMargin: 0
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/quit.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+ Text {
+ id: categoryText
+ anchors {
+ left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ elide: Text.ElideLeft
+ text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags)
+ font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black"
+ }
+
+ Button {
+ id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..."
+ onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags"
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Item {
+ id: lineEdit
+ y: 4; height: parent.height - 9
+ anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 }
+
+ BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
+
+ TextInput {
+ id: editor
+ anchors {
+ left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ cursorVisible: true; font.bold: true
+ color: "#151515"; selectionColor: "Green"
+ }
+
+ Keys.forwardTo: [ (returnKey), (editor)]
+
+ Item {
+ id: returnKey
+ Keys.onReturnPressed: container.accept()
+ Keys.onEnterPressed: container.accept()
+ Keys.onEscapePressed: titleBar.state = ""
+ }
+ }
+ }
+
+ states: State {
+ name: "Tags"
+ PropertyChanges { target: container; x: -tagButton.x + 5 }
+ PropertyChanges { target: tagButton; text: "OK" }
+ PropertyChanges { target: editor; focus: true }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
+ }
+}
diff --git a/examples/qml/flickr/content/ToolBar.qml b/examples/qml/flickr/content/ToolBar.qml
new file mode 100644
index 0000000000..356993b41a
--- /dev/null
+++ b/examples/qml/flickr/content/ToolBar.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: toolbar
+
+ property alias button1Label: button1.text
+ property alias button2Label: button2.text
+ property alias button2Visible: button2.visible
+
+ signal button1Clicked
+ signal button2Clicked
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Row {
+ anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30
+ Button {
+ id: button1
+ width: 140; height: 32
+ onClicked: toolbar.button1Clicked()
+ }
+
+ Button {
+ id: button2; width: 140; height: 32
+ onClicked: toolbar.button2Clicked()
+ }
+ }
+}
diff --git a/examples/qml/flickr/content/UnifiedDelegate.qml b/examples/qml/flickr/content/UnifiedDelegate.qml
new file mode 100644
index 0000000000..0b068c0abe
--- /dev/null
+++ b/examples/qml/flickr/content/UnifiedDelegate.qml
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Package {
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
+ }
+
+ Item {
+ id: gridwrapper;
+ width: GridView.view.cellWidth; height: GridView.view.cellHeight
+ Package.name: "grid"
+ }
+ Item {
+ id: streamwrapper;
+ width: 80; height: 80
+ Package.name: "stream"
+ }
+ Item {
+ //anchors.centerIn: parent//Doesn't animate :(
+ width: 80; height: 80
+ scale: 0.0
+ Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
+ id: scaleMe
+
+ Item {
+ id: whiteRectContainer
+ width: 77; height: 77; anchors.centerIn: parent
+ Rectangle {
+ id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
+ x:0; y:0
+ Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
+ Image { source: "images/gloss.png" }
+ MouseArea { anchors.fill: parent; onClicked: photoClicked() }
+ }
+ }
+
+ Connections {
+ target: toolBar
+ onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
+ }
+
+ state: 'inStream'
+ states: [
+ State {
+ name: "Show"; when: thumb.status == Image.Ready
+ PropertyChanges { target: scaleMe; scale: 1; }
+ },
+ State {
+ name: "Details"
+ PropertyChanges { target: scaleMe; scale: 1 }
+ ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
+ PropertyChanges { target: background; state: "DetailedView" }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "Show"; to: "Details"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ },
+ Transition {
+ from: "Details"; to: "Show"
+ SequentialAnimation{
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ }
+ }
+ ]
+ Item{
+ id: stateContainer
+ states: [
+ State {
+ name: 'inStream'
+ when: screen.inGridView == false
+ ParentChange {
+ target: scaleMe; parent: streamwrapper
+ x: 0; y: 0;
+ }
+ },
+ State {
+ name: 'inGrid'
+ when: screen.inGridView == true
+ ParentChange {
+ target: scaleMe; parent: gridwrapper
+ x: 0; y: 0;
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/qml/flickr/content/images/gloss.png b/examples/qml/flickr/content/images/gloss.png
new file mode 100644
index 0000000000..5d370cd93d
--- /dev/null
+++ b/examples/qml/flickr/content/images/gloss.png
Binary files differ
diff --git a/examples/qml/flickr/content/images/lineedit.png b/examples/qml/flickr/content/images/lineedit.png
new file mode 100644
index 0000000000..2cc38dc35b
--- /dev/null
+++ b/examples/qml/flickr/content/images/lineedit.png
Binary files differ
diff --git a/examples/qml/flickr/content/images/lineedit.sci b/examples/qml/flickr/content/images/lineedit.sci
new file mode 100644
index 0000000000..054bff78be
--- /dev/null
+++ b/examples/qml/flickr/content/images/lineedit.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/examples/qml/flickr/content/images/noise.png b/examples/qml/flickr/content/images/noise.png
new file mode 100644
index 0000000000..c5a5ba0053
--- /dev/null
+++ b/examples/qml/flickr/content/images/noise.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/blur-circle3.png b/examples/qml/flickr/content/images/particle.png
index dbc39cb16e..dbc39cb16e 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/blur-circle3.png
+++ b/examples/qml/flickr/content/images/particle.png
Binary files differ
diff --git a/examples/qml/flickr/content/images/quit.png b/examples/qml/flickr/content/images/quit.png
new file mode 100644
index 0000000000..5bda1b6e0d
--- /dev/null
+++ b/examples/qml/flickr/content/images/quit.png
Binary files differ
diff --git a/examples/qml/flickr/content/images/squareParticle.png b/examples/qml/flickr/content/images/squareParticle.png
new file mode 100644
index 0000000000..faf85c24e0
--- /dev/null
+++ b/examples/qml/flickr/content/images/squareParticle.png
Binary files differ
diff --git a/examples/qml/flickr/content/images/stripes.png b/examples/qml/flickr/content/images/stripes.png
new file mode 100644
index 0000000000..9f36727ea4
--- /dev/null
+++ b/examples/qml/flickr/content/images/stripes.png
Binary files differ
diff --git a/examples/qml/flickr/content/images/titlebar.png b/examples/qml/flickr/content/images/titlebar.png
new file mode 100644
index 0000000000..51c90082d0
--- /dev/null
+++ b/examples/qml/flickr/content/images/titlebar.png
Binary files differ
diff --git a/examples/qml/flickr/content/images/titlebar.sci b/examples/qml/flickr/content/images/titlebar.sci
new file mode 100644
index 0000000000..0418d94cd6
--- /dev/null
+++ b/examples/qml/flickr/content/images/titlebar.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/examples/qml/flickr/content/images/toolbutton.png b/examples/qml/flickr/content/images/toolbutton.png
new file mode 100644
index 0000000000..11310013ee
--- /dev/null
+++ b/examples/qml/flickr/content/images/toolbutton.png
Binary files differ
diff --git a/examples/qml/flickr/content/images/toolbutton.sci b/examples/qml/flickr/content/images/toolbutton.sci
new file mode 100644
index 0000000000..9e4f965307
--- /dev/null
+++ b/examples/qml/flickr/content/images/toolbutton.sci
@@ -0,0 +1,5 @@
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/examples/qml/flickr/content/qmldir b/examples/qml/flickr/content/qmldir
new file mode 100644
index 0000000000..adc2479b9f
--- /dev/null
+++ b/examples/qml/flickr/content/qmldir
@@ -0,0 +1,10 @@
+ImageDetails ImageDetails.qml
+LikeOMeter LikeOMeter.qml
+Loading Loading.qml
+MediaButton MediaButton.qml
+MediaLineEdit MediaLineEdit.qml
+Progress Progress.qml
+RssModel RssModel.qml
+ScrollBar ScrollBar.qml
+Slider Slider.qml
+Star Star.qml
diff --git a/examples/qml/flickr/flickr-90.qml b/examples/qml/flickr/flickr-90.qml
new file mode 100644
index 0000000000..b95b1c9872
--- /dev/null
+++ b/examples/qml/flickr/flickr-90.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ width: 480; height: 320
+
+ Loader {
+ y: 320; rotation: -90
+ transformOrigin: Item.TopLeft
+ source: "flickr.qml"
+ }
+}
diff --git a/examples/qml/flickr/flickr.qml b/examples/qml/flickr/flickr.qml
new file mode 100644
index 0000000000..98ca5197ab
--- /dev/null
+++ b/examples/qml/flickr/flickr.qml
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Item {
+ id: screen; width: 320; height: 480
+ property bool inGridView : true
+
+ Rectangle {
+ id: background
+ anchors.fill: parent; color: "#343434";
+
+ Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
+ ParticleSystem {
+ id: bgParticles
+ anchors.fill: parent
+ ImageParticle {
+ groups: ["trail"]
+ source: "content/images/particle.png"
+ color: "#1A1A6F"
+ alpha: 0.1
+ colorVariation: 0.01
+ blueVariation: 0.8
+ }
+ Emitter {
+ group: "drops"
+ width: parent.width
+ emitRate: 0.5
+ lifeSpan: 20000
+ startTime: 16000
+ speed: PointDirection{
+ y: {screen.height/18}
+ }
+ }
+ TrailEmitter {
+ follow: "drops"
+ group: "trail"
+ emitRatePerParticle: 18
+ size: 32
+ endSize: 0
+ sizeVariation: 4
+ lifeSpan: 1200
+ anchors.fill: parent
+ emitWidth: 16
+ emitHeight: 16
+ emitShape: EllipseShape{}
+ }
+ }
+
+ VisualDataModel{
+ id: vdm
+ delegate: UnifiedDelegate{}
+ model: RssModel { id: rssModel }
+ }
+
+ Item {
+ id: views
+ width: parent.width
+ anchors.top: titleBar.bottom; anchors.bottom: toolBar.top
+
+ GridView {
+ id: photoGridView; model: vdm.parts.grid
+ cacheBuffer: 1000
+ cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height
+ }
+
+ states: State {
+ name: "GridView"; when: state.inGridView == true
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+
+ ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height }
+
+ Item { id: foreground; anchors.fill: parent }
+ }
+
+ TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 }
+
+ ToolBar {
+ id: toolBar
+ height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
+ button1Label: "Update"; button2Label: "View mode"
+ onButton1Clicked: rssModel.reload()
+ onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true
+ }
+
+ Connections {
+ target: imageDetails
+ onClosed: {
+ if (background.state == "DetailedView") {
+ background.state = '';
+ imageDetails.photoUrl = "";
+ }
+ }
+ }
+
+ states: State {
+ name: "DetailedView"
+ PropertyChanges { target: views; x: -parent.width }
+ PropertyChanges { target: toolBar; button1Label: "View..." }
+ PropertyChanges {
+ target: toolBar
+ onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state=''
+ }
+ PropertyChanges { target: toolBar; button2Label: "Back" }
+ PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+
+ }
+}
diff --git a/examples/qml/flickr/flickr.qmlproject b/examples/qml/flickr/flickr.qmlproject
new file mode 100644
index 0000000000..af5179d84b
--- /dev/null
+++ b/examples/qml/flickr/flickr.qmlproject
@@ -0,0 +1,17 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "flickr.qml"
+ //mainFile: "flickr-90.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/imageelements/borderimage.qml b/examples/qml/imageelements/borderimage.qml
new file mode 100644
index 0000000000..3dd5d1d9bb
--- /dev/null
+++ b/examples/qml/imageelements/borderimage.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: page
+ width: 1030; height: 540
+
+ Grid {
+ anchors.centerIn: parent; spacing: 20
+
+ MyBorderImage {
+ minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240
+ source: "content/colors.png"; margin: 30
+ }
+
+ MyBorderImage {
+ minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat
+ }
+
+ MyBorderImage {
+ minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat
+ }
+
+ MyBorderImage {
+ minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round
+ }
+
+ MyBorderImage {
+ minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ }
+
+ MyBorderImage {
+ minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat
+ }
+
+ MyBorderImage {
+ minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat
+ }
+
+ MyBorderImage {
+ minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round
+ }
+ }
+}
diff --git a/examples/qtquick/imageelements/content/BearSheet.png b/examples/qml/imageelements/content/BearSheet.png
index a084bf0f1e..a084bf0f1e 100644
--- a/examples/qtquick/imageelements/content/BearSheet.png
+++ b/examples/qml/imageelements/content/BearSheet.png
Binary files differ
diff --git a/examples/qtquick/imageelements/content/ImageCell.qml b/examples/qml/imageelements/content/ImageCell.qml
index fcc6b47af5..fcc6b47af5 100644
--- a/examples/qtquick/imageelements/content/ImageCell.qml
+++ b/examples/qml/imageelements/content/ImageCell.qml
diff --git a/examples/qml/imageelements/content/MyBorderImage.qml b/examples/qml/imageelements/content/MyBorderImage.qml
new file mode 100644
index 0000000000..178e3706db
--- /dev/null
+++ b/examples/qml/imageelements/content/MyBorderImage.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property alias horizontalMode: image.horizontalTileMode
+ property alias verticalMode: image.verticalTileMode
+ property alias source: image.source
+
+ property int minWidth
+ property int minHeight
+ property int maxWidth
+ property int maxHeight
+ property int margin
+
+ width: 240; height: 240
+
+ BorderImage {
+ id: image; anchors.centerIn: parent
+
+ SequentialAnimation on width {
+ loops: Animation.Infinite
+ NumberAnimation {
+ from: container.minWidth; to: container.maxWidth
+ duration: 2000; easing.type: Easing.InOutQuad
+ }
+ NumberAnimation {
+ from: container.maxWidth; to: container.minWidth
+ duration: 2000; easing.type: Easing.InOutQuad
+ }
+ }
+
+ SequentialAnimation on height {
+ loops: Animation.Infinite
+ NumberAnimation {
+ from: container.minHeight; to: container.maxHeight
+ duration: 2000; easing.type: Easing.InOutQuad
+ }
+ NumberAnimation {
+ from: container.maxHeight; to: container.minHeight
+ duration: 2000; easing.type: Easing.InOutQuad
+ }
+ }
+
+ border.top: container.margin
+ border.left: container.margin
+ border.bottom: container.margin
+ border.right: container.margin
+ }
+}
diff --git a/examples/qtquick/imageelements/content/ShadowRectangle.qml b/examples/qml/imageelements/content/ShadowRectangle.qml
index e6fd13bb26..e6fd13bb26 100644
--- a/examples/qtquick/imageelements/content/ShadowRectangle.qml
+++ b/examples/qml/imageelements/content/ShadowRectangle.qml
diff --git a/examples/qtquick/imageelements/content/bw.png b/examples/qml/imageelements/content/bw.png
index 486eaae96e..486eaae96e 100644
--- a/examples/qtquick/imageelements/content/bw.png
+++ b/examples/qml/imageelements/content/bw.png
Binary files differ
diff --git a/examples/qtquick/imageelements/content/colors-round.sci b/examples/qml/imageelements/content/colors-round.sci
index 506f6f5f99..506f6f5f99 100644
--- a/examples/qtquick/imageelements/content/colors-round.sci
+++ b/examples/qml/imageelements/content/colors-round.sci
diff --git a/examples/qtquick/imageelements/content/colors-stretch.sci b/examples/qml/imageelements/content/colors-stretch.sci
index e4989a723c..e4989a723c 100644
--- a/examples/qtquick/imageelements/content/colors-stretch.sci
+++ b/examples/qml/imageelements/content/colors-stretch.sci
diff --git a/examples/qtquick/imageelements/content/colors.png b/examples/qml/imageelements/content/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/examples/qtquick/imageelements/content/colors.png
+++ b/examples/qml/imageelements/content/colors.png
Binary files differ
diff --git a/examples/qtquick/imageelements/content/qt-logo.png b/examples/qml/imageelements/content/qt-logo.png
index 14ddf2a028..14ddf2a028 100644
--- a/examples/qtquick/imageelements/content/qt-logo.png
+++ b/examples/qml/imageelements/content/qt-logo.png
Binary files differ
diff --git a/examples/qtquick/imageelements/content/shadow.png b/examples/qml/imageelements/content/shadow.png
index 431af8545d..431af8545d 100644
--- a/examples/qtquick/imageelements/content/shadow.png
+++ b/examples/qml/imageelements/content/shadow.png
Binary files differ
diff --git a/examples/qtquick/imageelements/content/speaker.png b/examples/qml/imageelements/content/speaker.png
index fb0e857859..fb0e857859 100644
--- a/examples/qtquick/imageelements/content/speaker.png
+++ b/examples/qml/imageelements/content/speaker.png
Binary files differ
diff --git a/examples/qml/imageelements/image.qml b/examples/qml/imageelements/image.qml
new file mode 100644
index 0000000000..4ca26c1630
--- /dev/null
+++ b/examples/qml/imageelements/image.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 490
+ height: 285
+
+ Grid {
+ property int cellWidth: (width - (spacing * (columns - 1))) / columns
+ property int cellHeight: (height - (spacing * (rows - 1))) / rows
+
+ anchors.fill: parent
+ anchors.margins: 30
+
+ columns: 3
+ rows: 2
+ spacing: 30
+
+ ImageCell { mode: Image.Stretch; caption: "Stretch" }
+ ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" }
+ ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" }
+
+ ImageCell { mode: Image.Tile; caption: "Tile" }
+ ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" }
+ ImageCell { mode: Image.TileVertically; caption: "TileVertically" }
+ }
+}
diff --git a/examples/qml/imageelements/imageelements.qml b/examples/qml/imageelements/imageelements.qml
new file mode 100644
index 0000000000..2ef5154968
--- /dev/null
+++ b/examples/qml/imageelements/imageelements.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../shared"
+
+Item {
+ height: 480
+ width: 640
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("BorderImage", "An image with scaled borders", Qt.resolvedUrl("borderimage.qml"));
+ addExample("Image", "A showcase of the options available to Image", Qt.resolvedUrl("image.qml"));
+ addExample("Shadows", "Rectangles with a drop-shadow effect", Qt.resolvedUrl("shadows.qml"));
+ addExample("Simple Sprite", "A simple sprite-based animation", Qt.resolvedUrl("simplesprite.qml"));
+ addExample("Sprite Image", "A sprite-based animation with complex transitions", Qt.resolvedUrl("spriteimage.qml"));
+ }
+ }
+}
diff --git a/examples/qtquick/imageelements/imageelements.qmlproject b/examples/qml/imageelements/imageelements.qmlproject
index 4292a0c112..4292a0c112 100644
--- a/examples/qtquick/imageelements/imageelements.qmlproject
+++ b/examples/qml/imageelements/imageelements.qmlproject
diff --git a/examples/qtquick/imageelements/shadows.qml b/examples/qml/imageelements/shadows.qml
index aa5022ab36..aa5022ab36 100644
--- a/examples/qtquick/imageelements/shadows.qml
+++ b/examples/qml/imageelements/shadows.qml
diff --git a/examples/qml/imageelements/simplesprite.qml b/examples/qml/imageelements/simplesprite.qml
new file mode 100644
index 0000000000..f619913bfc
--- /dev/null
+++ b/examples/qml/imageelements/simplesprite.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ width: 400
+ height: 400
+ Rectangle {
+ anchors.fill: parent
+ color: "white"
+ }
+ SpriteImage {
+ anchors.fill: parent
+ Sprite{
+ source: "content/speaker.png"
+ frames: 60
+ frameSync: true
+ frameWidth: 170
+ frameHeight: 170
+ }
+ }
+}
diff --git a/examples/qml/imageelements/spriteimage.qml b/examples/qml/imageelements/spriteimage.qml
new file mode 100644
index 0000000000..559bb10a50
--- /dev/null
+++ b/examples/qml/imageelements/spriteimage.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ width: 480
+ height: 1280
+ MouseArea {
+ onClicked: anim.start();
+ anchors.fill: parent
+ }
+ SequentialAnimation {
+ id: anim
+ ScriptAction { script: image.goalSprite = "falling"; }
+ NumberAnimation { target: image; property: "y"; to: 1480; duration: 12000; }
+ ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} }
+ PropertyAction { target: image; property: "y"; value: 0 }
+ }
+ SpriteImage {
+ id: image
+ width: 256
+ height: 256
+ anchors.horizontalCenter: parent.horizontalCenter
+ interpolate: false
+ goalSprite: ""
+ Sprite{
+ name: "still"
+ source: "content/BearSheet.png"
+ frames: 1
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 100
+ to: {"still":1, "blink":0.1, "floating":0}
+ }
+ Sprite{
+ name: "blink"
+ source: "content/BearSheet.png"
+ frames: 3
+ frameX: 256
+ frameY: 1536
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 100
+ to: {"still":1}
+ }
+ Sprite{
+ name: "floating"
+ source: "content/BearSheet.png"
+ frames: 9
+ frameX: 0
+ frameY: 0
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 160
+ to: {"still":0, "flailing":1}
+ }
+ Sprite{
+ name: "flailing"
+ source: "content/BearSheet.png"
+ frames: 8
+ frameX: 0
+ frameY: 768
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 160
+ to: {"falling":1}
+ }
+ Sprite{
+ name: "falling"
+ source: "content/BearSheet.png"
+ frames: 5
+ frameY: 1280
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 160
+ to: {"falling":1}
+ }
+ }
+}
diff --git a/examples/qtquick/keyinteraction/focus/Core/ContextMenu.qml b/examples/qml/keyinteraction/focus/Core/ContextMenu.qml
index dc68aa2b30..dc68aa2b30 100644
--- a/examples/qtquick/keyinteraction/focus/Core/ContextMenu.qml
+++ b/examples/qml/keyinteraction/focus/Core/ContextMenu.qml
diff --git a/examples/qtquick/keyinteraction/focus/Core/GridMenu.qml b/examples/qml/keyinteraction/focus/Core/GridMenu.qml
index 75bbe682af..75bbe682af 100644
--- a/examples/qtquick/keyinteraction/focus/Core/GridMenu.qml
+++ b/examples/qml/keyinteraction/focus/Core/GridMenu.qml
diff --git a/examples/qtquick/keyinteraction/focus/Core/ListMenu.qml b/examples/qml/keyinteraction/focus/Core/ListMenu.qml
index 7a62f33428..7a62f33428 100644
--- a/examples/qtquick/keyinteraction/focus/Core/ListMenu.qml
+++ b/examples/qml/keyinteraction/focus/Core/ListMenu.qml
diff --git a/examples/qtquick/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml
index b28b02616d..b28b02616d 100644
--- a/examples/qtquick/keyinteraction/focus/Core/ListViewDelegate.qml
+++ b/examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml
diff --git a/examples/qtquick/keyinteraction/focus/Core/images/arrow.png b/examples/qml/keyinteraction/focus/Core/images/arrow.png
index 14978c2e56..14978c2e56 100644
--- a/examples/qtquick/keyinteraction/focus/Core/images/arrow.png
+++ b/examples/qml/keyinteraction/focus/Core/images/arrow.png
Binary files differ
diff --git a/examples/qtquick/keyinteraction/focus/Core/images/qt-logo.png b/examples/qml/keyinteraction/focus/Core/images/qt-logo.png
index 14ddf2a028..14ddf2a028 100644
--- a/examples/qtquick/keyinteraction/focus/Core/images/qt-logo.png
+++ b/examples/qml/keyinteraction/focus/Core/images/qt-logo.png
Binary files differ
diff --git a/examples/qtquick/keyinteraction/focus/focus.qml b/examples/qml/keyinteraction/focus/focus.qml
index 9300ad4f6e..9300ad4f6e 100644
--- a/examples/qtquick/keyinteraction/focus/focus.qml
+++ b/examples/qml/keyinteraction/focus/focus.qml
diff --git a/examples/qml/minehunt/MinehuntCore/Explosion.qml b/examples/qml/minehunt/MinehuntCore/Explosion.qml
new file mode 100644
index 0000000000..a1b4292bcf
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/Explosion.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ property bool explode : false
+ ParticleSystem {
+ width: 40
+ height: 40
+ ImageParticle {
+ groups: ["star"]
+ source: "file:MinehuntCore/pics/star.png" // TODO: Use qrc path once QTBUG-21129 is fixed
+ }
+ Emitter {
+ id: particles
+ enabled: false
+ anchors.centerIn: parent
+ group: "star"
+ speed: AngleDirection { angleVariation: 360; magnitude: 150; magnitudeVariation: 50 }
+ emitRate: 200
+ z: 100
+ lifeSpan: 1000
+ }
+ }
+ states: State { name: "exploding"; when: explode
+ StateChangeScript { script: particles.burst(200); }
+ }
+
+}
diff --git a/examples/qml/minehunt/MinehuntCore/Tile.qml b/examples/qml/minehunt/MinehuntCore/Tile.qml
new file mode 100644
index 0000000000..1180b6f584
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/Tile.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Flipable {
+ id: flipable
+ property int angle: 0
+
+ width: 40; height: 40
+ transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle }
+
+ front: Image {
+ source: "pics/front.png"; width: 40; height: 40
+
+ Image {
+ anchors.centerIn: parent
+ source: "pics/flag.png"; opacity: modelData.hasFlag
+
+ Behavior on opacity { NumberAnimation {} }
+ }
+ }
+
+ back: Image {
+ source: "pics/back.png"
+ width: 40; height: 40
+
+ Text {
+ anchors.centerIn: parent
+ text: modelData.hint; color: "white"; font.bold: true
+ opacity: !modelData.hasMine && modelData.hint > 0
+ }
+
+ Image {
+ anchors.centerIn: parent
+ source: "pics/bomb.png"; opacity: modelData.hasMine
+ }
+
+ Explosion { id: expl }
+ }
+
+ states: State {
+ name: "back"; when: modelData.flipped
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ property real pauseDur: 250
+ transitions: Transition {
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ var ret = Math.abs(flipable.x - field.clickx)
+ + Math.abs(flipable.y - field.clicky);
+ if (modelData.hasMine && modelData.flipped)
+ pauseDur = ret * 3
+ else
+ pauseDur = ret
+ }
+ }
+ PauseAnimation {
+ duration: pauseDur
+ }
+ RotationAnimation { easing.type: Easing.InOutQuad }
+ ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ field.clickx = flipable.x
+ field.clicky = flipable.y
+ var row = Math.floor(index / 9)
+ var col = index - (Math.floor(index / 9) * 9)
+ if (mouse.button == undefined || mouse.button == Qt.RightButton) {
+ flag(row, col)
+ } else {
+ flip(row, col)
+ }
+ }
+ onPressAndHold: {
+ field.clickx = flipable.x
+ field.clicky = flipable.y
+ var row = Math.floor(index / 9)
+ var col = index - (Math.floor(index / 9) * 9)
+ flag(row, col)
+ }
+ }
+}
diff --git a/examples/qml/minehunt/MinehuntCore/pics/back.png b/examples/qml/minehunt/MinehuntCore/pics/back.png
new file mode 100644
index 0000000000..f6b3f0b4d7
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/back.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/background.png b/examples/qml/minehunt/MinehuntCore/pics/background.png
new file mode 100644
index 0000000000..3734a27744
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/background.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png b/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png
new file mode 100644
index 0000000000..61ad0a928f
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/bomb.png b/examples/qml/minehunt/MinehuntCore/pics/bomb.png
new file mode 100644
index 0000000000..a992575518
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/bomb.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/face-sad.png b/examples/qml/minehunt/MinehuntCore/pics/face-sad.png
new file mode 100644
index 0000000000..cf00aafe1f
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/face-sad.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png b/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png
new file mode 100644
index 0000000000..f9c2335df5
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/pics/face-smile.png b/examples/qml/minehunt/MinehuntCore/pics/face-smile.png
index 3d66d72578..3d66d72578 100644
--- a/examples/qtquick/modelviews/parallax/content/pics/face-smile.png
+++ b/examples/qml/minehunt/MinehuntCore/pics/face-smile.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/flag-color.png b/examples/qml/minehunt/MinehuntCore/pics/flag-color.png
new file mode 100644
index 0000000000..aadad0f11a
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/flag-color.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/flag.png b/examples/qml/minehunt/MinehuntCore/pics/flag.png
new file mode 100644
index 0000000000..39cde4df82
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/flag.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/front.png b/examples/qml/minehunt/MinehuntCore/pics/front.png
new file mode 100644
index 0000000000..834331bd49
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/front.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/quit.png b/examples/qml/minehunt/MinehuntCore/pics/quit.png
index b822057d4e..b822057d4e 100644
--- a/examples/qtquick/modelviews/parallax/content/quit.png
+++ b/examples/qml/minehunt/MinehuntCore/pics/quit.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/pics/star.png b/examples/qml/minehunt/MinehuntCore/pics/star.png
new file mode 100644
index 0000000000..3772359188
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/pics/star.png
Binary files differ
diff --git a/examples/qml/minehunt/MinehuntCore/qmldir b/examples/qml/minehunt/MinehuntCore/qmldir
new file mode 100644
index 0000000000..a0213a19c4
--- /dev/null
+++ b/examples/qml/minehunt/MinehuntCore/qmldir
@@ -0,0 +1,2 @@
+Explosion 2.0 Explosion.qml
+Tile 2.0 Tile.qml
diff --git a/examples/qml/minehunt/README b/examples/qml/minehunt/README
new file mode 100644
index 0000000000..3849ca5fbf
--- /dev/null
+++ b/examples/qml/minehunt/README
@@ -0,0 +1,6 @@
+Minehunt has to be compiled to run.
+
+To compile the C++ part, do 'qmake && make'.
+To run, simply run the executable.
+To deploy on a device, do 'make sis'.
+
diff --git a/examples/qml/minehunt/main.cpp b/examples/qml/minehunt/main.cpp
new file mode 100644
index 0000000000..0aa11a1d7a
--- /dev/null
+++ b/examples/qml/minehunt/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtQuick/qquickview.h>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
+
+#include "minehunt.h"
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+ QQuickView canvas;
+
+ qmlRegisterType<TileData>();
+ MinehuntGame* game = new MinehuntGame();
+
+ canvas.setResizeMode(QQuickView::SizeRootObjectToView);
+ canvas.engine()->rootContext()->setContextObject(game);
+ canvas.setSource(QString("qrc:///minehunt.qml"));
+ QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit()));
+
+ canvas.show();
+ return app.exec();
+}
diff --git a/examples/qml/minehunt/minehunt.cpp b/examples/qml/minehunt/minehunt.cpp
new file mode 100644
index 0000000000..cde30278b3
--- /dev/null
+++ b/examples/qml/minehunt/minehunt.cpp
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stdlib.h>
+#include <QTime>
+#include <QTimer>
+
+#include "minehunt.h"
+
+void tilesPropAppend(QQmlListProperty<TileData>* prop, TileData* value)
+{
+ Q_UNUSED(prop);
+ Q_UNUSED(value);
+ return; //Append not supported
+}
+
+int tilesPropCount(QQmlListProperty<TileData>* prop)
+{
+ return static_cast<QList<TileData*>*>(prop->data)->count();
+}
+
+TileData* tilesPropAt(QQmlListProperty<TileData>* prop, int index)
+{
+ return static_cast<QList<TileData*>*>(prop->data)->at(index);
+}
+
+QQmlListProperty<TileData> MinehuntGame::tiles(){
+ return QQmlListProperty<TileData>(this, &_tiles, &tilesPropAppend,
+ &tilesPropCount, &tilesPropAt, 0);
+}
+
+MinehuntGame::MinehuntGame()
+: numCols(9), numRows(9), playing(true), won(false)
+{
+ setObjectName("mainObject");
+ srand(QTime(0,0,0).secsTo(QTime::currentTime()));
+
+ //initialize array
+ for(int ii = 0; ii < numRows * numCols; ++ii) {
+ _tiles << new TileData;
+ }
+ reset();
+
+}
+
+void MinehuntGame::setBoard()
+{
+ foreach(TileData* t, _tiles){
+ t->setHasMine(false);
+ t->setHint(-1);
+ }
+ //place mines
+ int mines = nMines;
+ remaining = numRows*numCols-mines;
+ while ( mines ) {
+ int col = int((double(rand()) / double(RAND_MAX)) * numCols);
+ int row = int((double(rand()) / double(RAND_MAX)) * numRows);
+
+ TileData* t = tile( row, col );
+
+ if (t && !t->hasMine()) {
+ t->setHasMine( true );
+ mines--;
+ }
+ }
+
+ //set hints
+ for (int r = 0; r < numRows; r++)
+ for (int c = 0; c < numCols; c++) {
+ TileData* t = tile(r, c);
+ if (t && !t->hasMine()) {
+ int hint = getHint(r,c);
+ t->setHint(hint);
+ }
+ }
+
+ setPlaying(true);
+}
+
+void MinehuntGame::reset()
+{
+ foreach(TileData* t, _tiles){
+ t->unflip();
+ t->setHasFlag(false);
+ }
+ nMines = 12;
+ nFlags = 0;
+ emit numMinesChanged();
+ emit numFlagsChanged();
+ setPlaying(false);
+ QTimer::singleShot(600,this, SLOT(setBoard()));
+}
+
+int MinehuntGame::getHint(int row, int col)
+{
+ int hint = 0;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData* t = tile(r, c);
+ if (t && t->hasMine())
+ hint++;
+ }
+ return hint;
+}
+
+bool MinehuntGame::flip(int row, int col)
+{
+ if(!playing)
+ return false;
+
+ TileData *t = tile(row, col);
+ if (!t || t->hasFlag())
+ return false;
+
+ if(t->flipped()){
+ int flags = 0;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData *nearT = tile(r, c);
+ if(!nearT || nearT == t)
+ continue;
+ if(nearT->hasFlag())
+ flags++;
+ }
+ if(!t->hint() || t->hint() != flags)
+ return false;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData *nearT = tile(r, c);
+ if (nearT && !nearT->flipped() && !nearT->hasFlag()) {
+ flip( r, c );
+ }
+ }
+ return true;
+ }
+
+ t->flip();
+
+ if (t->hint() == 0) {
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData* t = tile(r, c);
+ if (t && !t->flipped()) {
+ flip( r, c );
+ }
+ }
+ }
+
+ if(t->hasMine()){
+ for (int r = 0; r < numRows; r++)//Flip all other mines
+ for (int c = 0; c < numCols; c++) {
+ TileData* t = tile(r, c);
+ if (t && t->hasMine()) {
+ flip(r, c);
+ }
+ }
+ won = false;
+ hasWonChanged();
+ setPlaying(false);
+ return true;
+ }
+
+ remaining--;
+ if(!remaining){
+ won = true;
+ hasWonChanged();
+ setPlaying(false);
+ return true;
+ }
+ return true;
+}
+
+bool MinehuntGame::flag(int row, int col)
+{
+ TileData *t = tile(row, col);
+ if(!t || !playing || t->flipped())
+ return false;
+
+ t->setHasFlag(!t->hasFlag());
+ nFlags += (t->hasFlag()?1:-1);
+ emit numFlagsChanged();
+ return true;
+}
diff --git a/examples/qml/minehunt/minehunt.h b/examples/qml/minehunt/minehunt.h
new file mode 100644
index 0000000000..34bab71218
--- /dev/null
+++ b/examples/qml/minehunt/minehunt.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <qqml.h>
+
+class TileData : public QObject
+{
+ Q_OBJECT
+public:
+ TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {}
+
+ Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged)
+ bool hasFlag() const { return _hasFlag; }
+
+ Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged)
+ bool hasMine() const { return _hasMine; }
+
+ Q_PROPERTY(int hint READ hint NOTIFY hintChanged)
+ int hint() const { return _hint; }
+
+ Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged())
+ bool flipped() const { return _flipped; }
+
+ void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();}
+ void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();}
+ void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); }
+ void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); }
+ void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); }
+
+signals:
+ void flippedChanged();
+ void hasFlagChanged();
+ void hintChanged();
+ void hasMineChanged();
+
+private:
+ bool _hasFlag;
+ bool _hasMine;
+ int _hint;
+ bool _flipped;
+};
+
+class MinehuntGame : public QObject
+{
+ Q_OBJECT
+public:
+ MinehuntGame();
+
+ Q_PROPERTY(QQmlListProperty<TileData> tiles READ tiles CONSTANT)
+ QQmlListProperty<TileData> tiles();
+
+ Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
+ bool isPlaying() {return playing;}
+
+ Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged)
+ bool hasWon() {return won;}
+
+ Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged)
+ int numMines() const{return nMines;}
+
+ Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged)
+ int numFlags() const{return nFlags;}
+
+public slots:
+ Q_INVOKABLE bool flip(int row, int col);
+ Q_INVOKABLE bool flag(int row, int col);
+ void setBoard();
+ void reset();
+
+signals:
+ void isPlayingChanged();
+ void hasWonChanged();
+ void numMinesChanged();
+ void numFlagsChanged();
+
+private:
+ bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; }
+ TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; }
+ int getHint(int row, int col);
+ void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();}
+
+ QList<TileData *> _tiles;
+ int numCols;
+ int numRows;
+ bool playing;
+ bool won;
+ int remaining;
+ int nMines;
+ int nFlags;
+};
diff --git a/examples/qml/minehunt/minehunt.pro b/examples/qml/minehunt/minehunt.pro
new file mode 100644
index 0000000000..78e874d805
--- /dev/null
+++ b/examples/qml/minehunt/minehunt.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += minehunt.h
+SOURCES += main.cpp minehunt.cpp
+RESOURCES = minehunt.qrc
diff --git a/examples/qml/minehunt/minehunt.qml b/examples/qml/minehunt/minehunt.qml
new file mode 100644
index 0000000000..42dc408fff
--- /dev/null
+++ b/examples/qml/minehunt/minehunt.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "MinehuntCore" 2.0
+
+Item {
+ id: field
+ property int clickx: 0
+ property int clicky: 0
+
+ width: 450; height: 450
+
+ Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile }
+
+ Grid {
+ anchors.horizontalCenter: parent.horizontalCenter
+ columns: 9; spacing: 1
+
+ Repeater {
+ id: repeater
+ model: tiles
+ delegate: Tile {}
+ }
+ }
+
+ Row {
+ id: gamedata
+ x: 20; spacing: 20
+ anchors.bottom: field.bottom; anchors.bottomMargin: 15
+
+ Image {
+ source: "MinehuntCore/pics/quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ y: 10
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -20
+ onClicked: Qt.quit()
+ }
+ }
+ Column {
+ spacing: 2
+ Image { source: "MinehuntCore/pics/bomb-color.png" }
+ Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines }
+ }
+
+ Column {
+ spacing: 2
+ Image { source: "MinehuntCore/pics/flag-color.png" }
+ Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags }
+ }
+ }
+
+ Image {
+ anchors.bottom: field.bottom; anchors.bottomMargin: 15
+ anchors.right: field.right; anchors.rightMargin: 20
+ source: isPlaying ? 'MinehuntCore/pics/face-smile.png' :
+ hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png'
+
+ MouseArea { anchors.fill: parent; onPressed: reset() }
+ }
+ Text {
+ anchors.centerIn: parent; width: parent.width - 20
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.WordWrap
+ text: "Minehunt demo has to be compiled to run.\n\nPlease see README."
+ color: "white"; font.bold: true; font.pixelSize: 14
+ visible: tiles == undefined
+ }
+
+}
diff --git a/examples/qml/minehunt/minehunt.qmlproject b/examples/qml/minehunt/minehunt.qmlproject
new file mode 100644
index 0000000000..5aeb78f1ea
--- /dev/null
+++ b/examples/qml/minehunt/minehunt.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "minehunt.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/minehunt/minehunt.qrc b/examples/qml/minehunt/minehunt.qrc
new file mode 100644
index 0000000000..fa8e27d383
--- /dev/null
+++ b/examples/qml/minehunt/minehunt.qrc
@@ -0,0 +1,20 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>minehunt.qml</file>
+ <file>MinehuntCore/Explosion.qml</file>
+ <file>MinehuntCore/Tile.qml</file>
+ <file>MinehuntCore/qmldir</file>
+ <file>MinehuntCore/pics/background.png</file>
+ <file>MinehuntCore/pics/back.png</file>
+ <file>MinehuntCore/pics/bomb-color.png</file>
+ <file>MinehuntCore/pics/bomb.png</file>
+ <file>MinehuntCore/pics/face-sad.png</file>
+ <file>MinehuntCore/pics/face-smile-big.png</file>
+ <file>MinehuntCore/pics/face-smile.png</file>
+ <file>MinehuntCore/pics/flag-color.png</file>
+ <file>MinehuntCore/pics/flag.png</file>
+ <file>MinehuntCore/pics/front.png</file>
+ <file>MinehuntCore/pics/quit.png</file>
+ <file>MinehuntCore/pics/star.png</file>
+</qresource>
+</RCC>
diff --git a/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro
new file mode 100644
index 0000000000..f786d9356f
--- /dev/null
+++ b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = abstractitemmodel
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += qml quick
+
+HEADERS = model.h
+SOURCES = main.cpp \
+ model.cpp
+RESOURCES += abstractitemmodel.qrc
diff --git a/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc
index 4ae861cb3d..4ae861cb3d 100644
--- a/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.qrc
+++ b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc
diff --git a/examples/qml/modelviews/abstractitemmodel/main.cpp b/examples/qml/modelviews/abstractitemmodel/main.cpp
new file mode 100644
index 0000000000..f5930ce840
--- /dev/null
+++ b/examples/qml/modelviews/abstractitemmodel/main.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+
+#include <QGuiApplication>
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+//![0]
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ AnimalModel model;
+ model.addAnimal(Animal("Wolf", "Medium"));
+ model.addAnimal(Animal("Polar bear", "Large"));
+ model.addAnimal(Animal("Quoll", "Small"));
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/qtquick/modelviews/abstractitemmodel/model.cpp b/examples/qml/modelviews/abstractitemmodel/model.cpp
index 8f7649c0d4..8f7649c0d4 100644
--- a/examples/qtquick/modelviews/abstractitemmodel/model.cpp
+++ b/examples/qml/modelviews/abstractitemmodel/model.cpp
diff --git a/examples/qtquick/modelviews/abstractitemmodel/model.h b/examples/qml/modelviews/abstractitemmodel/model.h
index 1378c4487e..1378c4487e 100644
--- a/examples/qtquick/modelviews/abstractitemmodel/model.h
+++ b/examples/qml/modelviews/abstractitemmodel/model.h
diff --git a/examples/qtquick/modelviews/abstractitemmodel/view.qml b/examples/qml/modelviews/abstractitemmodel/view.qml
index 64f5871d4b..64f5871d4b 100644
--- a/examples/qtquick/modelviews/abstractitemmodel/view.qml
+++ b/examples/qml/modelviews/abstractitemmodel/view.qml
diff --git a/examples/qtquick/modelviews/gridview/gridview-example.qml b/examples/qml/modelviews/gridview/gridview-example.qml
index ea3bb5cec9..ea3bb5cec9 100644
--- a/examples/qtquick/modelviews/gridview/gridview-example.qml
+++ b/examples/qml/modelviews/gridview/gridview-example.qml
diff --git a/examples/qtquick/modelviews/gridview/pics/AddressBook_48.png b/examples/qml/modelviews/gridview/pics/AddressBook_48.png
index 1ab7c8eec1..1ab7c8eec1 100644
--- a/examples/qtquick/modelviews/gridview/pics/AddressBook_48.png
+++ b/examples/qml/modelviews/gridview/pics/AddressBook_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png b/examples/qml/modelviews/gridview/pics/AudioPlayer_48.png
index f4b8689f87..f4b8689f87 100644
--- a/examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png
+++ b/examples/qml/modelviews/gridview/pics/AudioPlayer_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/gridview/pics/Camera_48.png b/examples/qml/modelviews/gridview/pics/Camera_48.png
index c76b524945..c76b524945 100644
--- a/examples/qtquick/modelviews/gridview/pics/Camera_48.png
+++ b/examples/qml/modelviews/gridview/pics/Camera_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/gridview/pics/DateBook_48.png b/examples/qml/modelviews/gridview/pics/DateBook_48.png
index 58f5787fb8..58f5787fb8 100644
--- a/examples/qtquick/modelviews/gridview/pics/DateBook_48.png
+++ b/examples/qml/modelviews/gridview/pics/DateBook_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/gridview/pics/EMail_48.png b/examples/qml/modelviews/gridview/pics/EMail_48.png
index d6d84a61be..d6d84a61be 100644
--- a/examples/qtquick/modelviews/gridview/pics/EMail_48.png
+++ b/examples/qml/modelviews/gridview/pics/EMail_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/gridview/pics/TodoList_48.png b/examples/qml/modelviews/gridview/pics/TodoList_48.png
index 0988448d9b..0988448d9b 100644
--- a/examples/qtquick/modelviews/gridview/pics/TodoList_48.png
+++ b/examples/qml/modelviews/gridview/pics/TodoList_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png b/examples/qml/modelviews/gridview/pics/VideoPlayer_48.png
index 52638c50a7..52638c50a7 100644
--- a/examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png
+++ b/examples/qml/modelviews/gridview/pics/VideoPlayer_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/PetsModel.qml b/examples/qml/modelviews/listview/content/PetsModel.qml
index 4f2087d95e..4f2087d95e 100644
--- a/examples/qtquick/modelviews/listview/content/PetsModel.qml
+++ b/examples/qml/modelviews/listview/content/PetsModel.qml
diff --git a/examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml b/examples/qml/modelviews/listview/content/PressAndHoldButton.qml
index b20d8f64f1..b20d8f64f1 100644
--- a/examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml
+++ b/examples/qml/modelviews/listview/content/PressAndHoldButton.qml
diff --git a/examples/qtquick/modelviews/listview/content/RecipesModel.qml b/examples/qml/modelviews/listview/content/RecipesModel.qml
index 86210ba436..86210ba436 100644
--- a/examples/qtquick/modelviews/listview/content/RecipesModel.qml
+++ b/examples/qml/modelviews/listview/content/RecipesModel.qml
diff --git a/examples/qtquick/modelviews/listview/content/TextButton.qml b/examples/qml/modelviews/listview/content/TextButton.qml
index 980ee21553..980ee21553 100644
--- a/examples/qtquick/modelviews/listview/content/TextButton.qml
+++ b/examples/qml/modelviews/listview/content/TextButton.qml
diff --git a/examples/qml/modelviews/listview/content/ToggleButton.qml b/examples/qml/modelviews/listview/content/ToggleButton.qml
new file mode 100644
index 0000000000..52f4988f03
--- /dev/null
+++ b/examples/qml/modelviews/listview/content/ToggleButton.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml 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 QtQuick 2.0
+
+Rectangle {
+ id: root
+ property alias label: text.text
+ property bool active: false
+ signal toggled
+ width: 149
+ height: 30
+ radius: 3
+ color: active ? "green" : "lightgray"
+ border.width: 1
+ Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { active = !active; root.toggled() }
+ }
+}
diff --git a/examples/qtquick/modelviews/listview/content/pics/arrow-down.png b/examples/qml/modelviews/listview/content/pics/arrow-down.png
index 29d1d4439a..29d1d4439a 100644
--- a/examples/qtquick/modelviews/listview/content/pics/arrow-down.png
+++ b/examples/qml/modelviews/listview/content/pics/arrow-down.png
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/arrow-up.png b/examples/qml/modelviews/listview/content/pics/arrow-up.png
index e437312217..e437312217 100644
--- a/examples/qtquick/modelviews/listview/content/pics/arrow-up.png
+++ b/examples/qml/modelviews/listview/content/pics/arrow-up.png
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg b/examples/qml/modelviews/listview/content/pics/fruit-salad.jpg
index da5a6b10a2..da5a6b10a2 100644
--- a/examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg
+++ b/examples/qml/modelviews/listview/content/pics/fruit-salad.jpg
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/hamburger.jpg b/examples/qml/modelviews/listview/content/pics/hamburger.jpg
index d0a15be1bf..d0a15be1bf 100644
--- a/examples/qtquick/modelviews/listview/content/pics/hamburger.jpg
+++ b/examples/qml/modelviews/listview/content/pics/hamburger.jpg
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/lemonade.jpg b/examples/qml/modelviews/listview/content/pics/lemonade.jpg
index db445c9ac8..db445c9ac8 100644
--- a/examples/qtquick/modelviews/listview/content/pics/lemonade.jpg
+++ b/examples/qml/modelviews/listview/content/pics/lemonade.jpg
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/list-delete.png b/examples/qml/modelviews/listview/content/pics/list-delete.png
index df2a147d24..df2a147d24 100644
--- a/examples/qtquick/modelviews/listview/content/pics/list-delete.png
+++ b/examples/qml/modelviews/listview/content/pics/list-delete.png
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/minus-sign.png b/examples/qml/modelviews/listview/content/pics/minus-sign.png
index d6f233d739..d6f233d739 100644
--- a/examples/qtquick/modelviews/listview/content/pics/minus-sign.png
+++ b/examples/qml/modelviews/listview/content/pics/minus-sign.png
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/moreDown.png b/examples/qml/modelviews/listview/content/pics/moreDown.png
index 31a35d5c20..31a35d5c20 100644
--- a/examples/qtquick/modelviews/listview/content/pics/moreDown.png
+++ b/examples/qml/modelviews/listview/content/pics/moreDown.png
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/moreUp.png b/examples/qml/modelviews/listview/content/pics/moreUp.png
index fefb9c9098..fefb9c9098 100644
--- a/examples/qtquick/modelviews/listview/content/pics/moreUp.png
+++ b/examples/qml/modelviews/listview/content/pics/moreUp.png
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/pancakes.jpg b/examples/qml/modelviews/listview/content/pics/pancakes.jpg
index 60c439638e..60c439638e 100644
--- a/examples/qtquick/modelviews/listview/content/pics/pancakes.jpg
+++ b/examples/qml/modelviews/listview/content/pics/pancakes.jpg
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/plus-sign.png b/examples/qml/modelviews/listview/content/pics/plus-sign.png
index 40df1134f8..40df1134f8 100644
--- a/examples/qtquick/modelviews/listview/content/pics/plus-sign.png
+++ b/examples/qml/modelviews/listview/content/pics/plus-sign.png
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg
index 9dce332041..9dce332041 100644
--- a/examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg
+++ b/examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg
Binary files differ
diff --git a/examples/qtquick/modelviews/listview/dynamiclist.qml b/examples/qml/modelviews/listview/dynamiclist.qml
index ee7c6329bc..ee7c6329bc 100644
--- a/examples/qtquick/modelviews/listview/dynamiclist.qml
+++ b/examples/qml/modelviews/listview/dynamiclist.qml
diff --git a/examples/qtquick/modelviews/listview/expandingdelegates.qml b/examples/qml/modelviews/listview/expandingdelegates.qml
index 43a9662422..43a9662422 100644
--- a/examples/qtquick/modelviews/listview/expandingdelegates.qml
+++ b/examples/qml/modelviews/listview/expandingdelegates.qml
diff --git a/examples/qtquick/modelviews/listview/highlight.qml b/examples/qml/modelviews/listview/highlight.qml
index d8f76080e6..d8f76080e6 100644
--- a/examples/qtquick/modelviews/listview/highlight.qml
+++ b/examples/qml/modelviews/listview/highlight.qml
diff --git a/examples/qtquick/modelviews/listview/highlightranges.qml b/examples/qml/modelviews/listview/highlightranges.qml
index a536ddcbb2..a536ddcbb2 100644
--- a/examples/qtquick/modelviews/listview/highlightranges.qml
+++ b/examples/qml/modelviews/listview/highlightranges.qml
diff --git a/examples/qtquick/modelviews/listview/sections.qml b/examples/qml/modelviews/listview/sections.qml
index 2e63a86bb6..2e63a86bb6 100644
--- a/examples/qtquick/modelviews/listview/sections.qml
+++ b/examples/qml/modelviews/listview/sections.qml
diff --git a/examples/qtquick/modelviews/modelviews.pro b/examples/qml/modelviews/modelviews.pro
index 7748da0471..7748da0471 100644
--- a/examples/qtquick/modelviews/modelviews.pro
+++ b/examples/qml/modelviews/modelviews.pro
diff --git a/examples/qml/modelviews/modelviews.qml b/examples/qml/modelviews/modelviews.qml
new file mode 100644
index 0000000000..86b10ca4ba
--- /dev/null
+++ b/examples/qml/modelviews/modelviews.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../shared"
+
+Item {
+ height: 480
+ width: 480
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Dynamic List", "A ListView harboring dynamic data", Qt.resolvedUrl("listview/dynamiclist.qml"));
+ addExample("Expanding Delegates", "Delegates that expand to fill the list when clicked", Qt.resolvedUrl("listview/expandingdelegates.qml"));
+ addExample("Highlight", "Adding a highlight to the current item", Qt.resolvedUrl("listview/highlight.qml"));
+ addExample("Sections", "A ListView with section headers", Qt.resolvedUrl("listview/sections.qml"));
+ addExample("GridView", "A view laid out in a grid", Qt.resolvedUrl("gridview/gridview-example.qml"));
+ addExample("PathView", "A view laid out along a path", Qt.resolvedUrl("pathview/pathview-example.qml"));
+ addExample("Package", "Using a package to transition items between views", Qt.resolvedUrl("package/view.qml"));
+ addExample("Parallax", "Adds a background and a parallax effect to a ListView", Qt.resolvedUrl("parallax/parallax.qml"));
+ addExample("Slideshow", "A model demonstrating delayed image loading", Qt.resolvedUrl("visualdatamodel/slideshow.qml"));
+ addExample("Sorted Model", "Two views on a model, one of which is sorted", Qt.resolvedUrl("visualdatamodel/sortedmodel.qml"));
+ addExample("VisualItemModel", "A model that consists of the actual Items", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml"));
+ }
+ }
+}
diff --git a/examples/qtquick/modelviews/modelviews.qmlproject b/examples/qml/modelviews/modelviews.qmlproject
index 40f9e568fd..40f9e568fd 100644
--- a/examples/qtquick/modelviews/modelviews.qmlproject
+++ b/examples/qml/modelviews/modelviews.qmlproject
diff --git a/examples/qtquick/modelviews/objectlistmodel/dataobject.cpp b/examples/qml/modelviews/objectlistmodel/dataobject.cpp
index 7216283616..7216283616 100644
--- a/examples/qtquick/modelviews/objectlistmodel/dataobject.cpp
+++ b/examples/qml/modelviews/objectlistmodel/dataobject.cpp
diff --git a/examples/qtquick/modelviews/objectlistmodel/dataobject.h b/examples/qml/modelviews/objectlistmodel/dataobject.h
index bea92a273c..bea92a273c 100644
--- a/examples/qtquick/modelviews/objectlistmodel/dataobject.h
+++ b/examples/qml/modelviews/objectlistmodel/dataobject.h
diff --git a/examples/qml/modelviews/objectlistmodel/main.cpp b/examples/qml/modelviews/objectlistmodel/main.cpp
new file mode 100644
index 0000000000..bb3895f7c0
--- /dev/null
+++ b/examples/qml/modelviews/objectlistmodel/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications 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 <QGuiApplication>
+
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+#include "dataobject.h"
+
+/*
+ This example illustrates exposing a QList<QObject*> as a
+ model in QML
+*/
+
+//![0]
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ QList<QObject*> dataList;
+ dataList.append(new DataObject("Item 1", "red"));
+ dataList.append(new DataObject("Item 2", "green"));
+ dataList.append(new DataObject("Item 3", "blue"));
+ dataList.append(new DataObject("Item 4", "yellow"));
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro b/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro
new file mode 100644
index 0000000000..7f323c3999
--- /dev/null
+++ b/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro
@@ -0,0 +1,6 @@
+QT += qml quick
+
+SOURCES += main.cpp \
+ dataobject.cpp
+HEADERS += dataobject.h
+RESOURCES += objectlistmodel.qrc
diff --git a/examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject
index 2bb4016996..2bb4016996 100644
--- a/examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject
+++ b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject
diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc
index 17e9301471..17e9301471 100644
--- a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc
+++ b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc
diff --git a/examples/qtquick/modelviews/objectlistmodel/view.qml b/examples/qml/modelviews/objectlistmodel/view.qml
index 3954e79829..3954e79829 100644
--- a/examples/qtquick/modelviews/objectlistmodel/view.qml
+++ b/examples/qml/modelviews/objectlistmodel/view.qml
diff --git a/examples/qtquick/modelviews/package/Delegate.qml b/examples/qml/modelviews/package/Delegate.qml
index 97c7840cb4..97c7840cb4 100644
--- a/examples/qtquick/modelviews/package/Delegate.qml
+++ b/examples/qml/modelviews/package/Delegate.qml
diff --git a/examples/qml/modelviews/package/view.qml b/examples/qml/modelviews/package/view.qml
new file mode 100644
index 0000000000..5b2fd9481c
--- /dev/null
+++ b/examples/qml/modelviews/package/view.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "white"
+ width: 400
+ height: 200
+
+ ListModel {
+ id: myModel
+ ListElement { display: "One" }
+ ListElement { display: "Two" }
+ ListElement { display: "Three" }
+ ListElement { display: "Four" }
+ ListElement { display: "Five" }
+ ListElement { display: "Six" }
+ ListElement { display: "Seven" }
+ ListElement { display: "Eight" }
+ }
+ //![0]
+ VisualDataModel {
+ id: visualModel
+ delegate: Delegate {}
+ model: myModel
+ }
+
+ ListView {
+ width: 200; height:200
+ model: visualModel.parts.list
+ }
+ GridView {
+ x: 200; width: 200; height:200
+ cellHeight: 50
+ model: visualModel.parts.grid
+ }
+ //![0]
+}
diff --git a/examples/qtquick/modelviews/parallax/content/ParallaxView.qml b/examples/qml/modelviews/parallax/content/ParallaxView.qml
index 2acf50dcef..2acf50dcef 100644
--- a/examples/qtquick/modelviews/parallax/content/ParallaxView.qml
+++ b/examples/qml/modelviews/parallax/content/ParallaxView.qml
diff --git a/examples/qtquick/modelviews/parallax/content/Smiley.qml b/examples/qml/modelviews/parallax/content/Smiley.qml
index 982b6c5d2b..982b6c5d2b 100644
--- a/examples/qtquick/modelviews/parallax/content/Smiley.qml
+++ b/examples/qml/modelviews/parallax/content/Smiley.qml
diff --git a/examples/qtquick/modelviews/parallax/content/pics/background.jpg b/examples/qml/modelviews/parallax/content/pics/background.jpg
index 61cca2f138..61cca2f138 100644
--- a/examples/qtquick/modelviews/parallax/content/pics/background.jpg
+++ b/examples/qml/modelviews/parallax/content/pics/background.jpg
Binary files differ
diff --git a/examples/qtquick/shadereffects/content/face-smile.png b/examples/qml/modelviews/parallax/content/pics/face-smile.png
index 3d66d72578..3d66d72578 100644
--- a/examples/qtquick/shadereffects/content/face-smile.png
+++ b/examples/qml/modelviews/parallax/content/pics/face-smile.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/pics/home-page.png b/examples/qml/modelviews/parallax/content/pics/home-page.png
index bd090c3708..bd090c3708 100644
--- a/examples/qtquick/modelviews/parallax/content/pics/home-page.png
+++ b/examples/qml/modelviews/parallax/content/pics/home-page.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/pics/home-page.svg b/examples/qml/modelviews/parallax/content/pics/home-page.svg
index 4f16958844..4f16958844 100644
--- a/examples/qtquick/modelviews/parallax/content/pics/home-page.svg
+++ b/examples/qml/modelviews/parallax/content/pics/home-page.svg
diff --git a/examples/qtquick/modelviews/parallax/content/pics/shadow.png b/examples/qml/modelviews/parallax/content/pics/shadow.png
index 8270565e87..8270565e87 100644
--- a/examples/qtquick/modelviews/parallax/content/pics/shadow.png
+++ b/examples/qml/modelviews/parallax/content/pics/shadow.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png b/examples/qml/modelviews/parallax/content/pics/yast-joystick.png
index 858cea0301..858cea0301 100644
--- a/examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png
+++ b/examples/qml/modelviews/parallax/content/pics/yast-joystick.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/pics/yast-wol.png b/examples/qml/modelviews/parallax/content/pics/yast-wol.png
index 7712180a3b..7712180a3b 100644
--- a/examples/qtquick/modelviews/parallax/content/pics/yast-wol.png
+++ b/examples/qml/modelviews/parallax/content/pics/yast-wol.png
Binary files differ
diff --git a/examples/qml/modelviews/parallax/parallax.qml b/examples/qml/modelviews/parallax/parallax.qml
new file mode 100644
index 0000000000..6981095a80
--- /dev/null
+++ b/examples/qml/modelviews/parallax/parallax.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../toys/clocks/content" // for loading the Clock element
+import "content"
+
+Rectangle {
+ width: 320; height: 480
+
+ ParallaxView {
+ id: parallax
+ anchors.fill: parent
+ background: "content/pics/background.jpg"
+
+ Item {
+ property url icon: "content/pics/yast-wol.png"
+ width: 320; height: 480
+ Clock { anchors.centerIn: parent }
+ }
+
+ Item {
+ property url icon: "content/pics/home-page.png"
+ width: 320; height: 480
+ Smiley { }
+ }
+
+ Item {
+ property url icon: "content/pics/yast-joystick.png"
+ width: 320; height: 480
+
+ Loader {
+ anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter }
+ width: 300; height: 400
+ clip: true;
+ source: "../../samegame/samegame.qml"
+ }
+ }
+ }
+}
diff --git a/examples/qtquick/modelviews/pathview/pathview-example.qml b/examples/qml/modelviews/pathview/pathview-example.qml
index 6161343830..6161343830 100644
--- a/examples/qtquick/modelviews/pathview/pathview-example.qml
+++ b/examples/qml/modelviews/pathview/pathview-example.qml
diff --git a/examples/qtquick/modelviews/pathview/pics/AddressBook_48.png b/examples/qml/modelviews/pathview/pics/AddressBook_48.png
index 1ab7c8eec1..1ab7c8eec1 100644
--- a/examples/qtquick/modelviews/pathview/pics/AddressBook_48.png
+++ b/examples/qml/modelviews/pathview/pics/AddressBook_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png b/examples/qml/modelviews/pathview/pics/AudioPlayer_48.png
index f4b8689f87..f4b8689f87 100644
--- a/examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png
+++ b/examples/qml/modelviews/pathview/pics/AudioPlayer_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/pathview/pics/Camera_48.png b/examples/qml/modelviews/pathview/pics/Camera_48.png
index c76b524945..c76b524945 100644
--- a/examples/qtquick/modelviews/pathview/pics/Camera_48.png
+++ b/examples/qml/modelviews/pathview/pics/Camera_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/pathview/pics/DateBook_48.png b/examples/qml/modelviews/pathview/pics/DateBook_48.png
index 58f5787fb8..58f5787fb8 100644
--- a/examples/qtquick/modelviews/pathview/pics/DateBook_48.png
+++ b/examples/qml/modelviews/pathview/pics/DateBook_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/pathview/pics/EMail_48.png b/examples/qml/modelviews/pathview/pics/EMail_48.png
index d6d84a61be..d6d84a61be 100644
--- a/examples/qtquick/modelviews/pathview/pics/EMail_48.png
+++ b/examples/qml/modelviews/pathview/pics/EMail_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/pathview/pics/TodoList_48.png b/examples/qml/modelviews/pathview/pics/TodoList_48.png
index 0988448d9b..0988448d9b 100644
--- a/examples/qtquick/modelviews/pathview/pics/TodoList_48.png
+++ b/examples/qml/modelviews/pathview/pics/TodoList_48.png
Binary files differ
diff --git a/examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png b/examples/qml/modelviews/pathview/pics/VideoPlayer_48.png
index 52638c50a7..52638c50a7 100644
--- a/examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png
+++ b/examples/qml/modelviews/pathview/pics/VideoPlayer_48.png
Binary files differ
diff --git a/examples/qml/modelviews/stringlistmodel/main.cpp b/examples/qml/modelviews/stringlistmodel/main.cpp
new file mode 100644
index 0000000000..12859316a3
--- /dev/null
+++ b/examples/qml/modelviews/stringlistmodel/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications 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 <QGuiApplication>
+#include <QStringList>
+
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+
+/*
+ This example illustrates exposing a QStringList as a
+ model in QML
+*/
+
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+//![0]
+ QStringList dataList;
+ dataList.append("Item 1");
+ dataList.append("Item 2");
+ dataList.append("Item 3");
+ dataList.append("Item 4");
+
+ QQuickView view;
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro b/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro
new file mode 100644
index 0000000000..19e62cd1b7
--- /dev/null
+++ b/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro
@@ -0,0 +1,4 @@
+QT += qml quick
+
+SOURCES += main.cpp
+RESOURCES += stringlistmodel.qrc
diff --git a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc
index 17e9301471..17e9301471 100644
--- a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc
+++ b/examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc
diff --git a/examples/qtquick/modelviews/stringlistmodel/view.qml b/examples/qml/modelviews/stringlistmodel/view.qml
index 945763c295..945763c295 100644
--- a/examples/qtquick/modelviews/stringlistmodel/view.qml
+++ b/examples/qml/modelviews/stringlistmodel/view.qml
diff --git a/examples/qtquick/modelviews/visualdatamodel/dragselection.qml b/examples/qml/modelviews/visualdatamodel/dragselection.qml
index c3186a5ad8..c3186a5ad8 100644
--- a/examples/qtquick/modelviews/visualdatamodel/dragselection.qml
+++ b/examples/qml/modelviews/visualdatamodel/dragselection.qml
diff --git a/examples/qtquick/modelviews/visualdatamodel/slideshow.qml b/examples/qml/modelviews/visualdatamodel/slideshow.qml
index 040c6be307..040c6be307 100644
--- a/examples/qtquick/modelviews/visualdatamodel/slideshow.qml
+++ b/examples/qml/modelviews/visualdatamodel/slideshow.qml
diff --git a/examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml b/examples/qml/modelviews/visualdatamodel/sortedmodel.qml
index 8d3b0a58e5..8d3b0a58e5 100644
--- a/examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml
+++ b/examples/qml/modelviews/visualdatamodel/sortedmodel.qml
diff --git a/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml b/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml
new file mode 100644
index 0000000000..3425150d9a
--- /dev/null
+++ b/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This example demonstrates placing items in a view using
+// a VisualItemModel
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "lightgray"
+ width: 240
+ height: 320
+ property bool printDestruction: false
+
+ VisualItemModel {
+ id: itemModel
+
+ Rectangle {
+ width: view.width; height: view.height
+ color: "#FFFEF0"
+ Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent }
+
+ Component.onDestruction: if (printDestruction) print("destroyed 1")
+ }
+ Rectangle {
+ width: view.width; height: view.height
+ color: "#F0FFF7"
+ Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent }
+
+ Component.onDestruction: if (printDestruction) print("destroyed 2")
+ }
+ Rectangle {
+ width: view.width; height: view.height
+ color: "#F4F0FF"
+ Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent }
+
+ Component.onDestruction: if (printDestruction) print("destroyed 3")
+ }
+ }
+
+ ListView {
+ id: view
+ anchors { fill: parent; bottomMargin: 30 }
+ model: itemModel
+ preferredHighlightBegin: 0; preferredHighlightEnd: 0
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem; flickDeceleration: 2000
+ cacheBuffer: 200
+ }
+
+ Rectangle {
+ width: 240; height: 30
+ anchors { top: view.bottom; bottom: parent.bottom }
+ color: "gray"
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+
+ Repeater {
+ model: itemModel.count
+
+ Rectangle {
+ width: 5; height: 5
+ radius: 3
+ color: view.currentIndex == index ? "blue" : "white"
+
+ MouseArea {
+ width: 20; height: 20
+ anchors.centerIn: parent
+ onClicked: view.currentIndex = index
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/qtquick/openglunderqml/main.cpp b/examples/qml/openglunderqml/main.cpp
index 3b682deaec..3b682deaec 100644
--- a/examples/qtquick/openglunderqml/main.cpp
+++ b/examples/qml/openglunderqml/main.cpp
diff --git a/examples/qtquick/openglunderqml/main.qml b/examples/qml/openglunderqml/main.qml
index 1485cbbdb8..1485cbbdb8 100644
--- a/examples/qtquick/openglunderqml/main.qml
+++ b/examples/qml/openglunderqml/main.qml
diff --git a/examples/qml/openglunderqml/openglunderqml.pro b/examples/qml/openglunderqml/openglunderqml.pro
new file mode 100644
index 0000000000..64a58b3729
--- /dev/null
+++ b/examples/qml/openglunderqml/openglunderqml.pro
@@ -0,0 +1,6 @@
+QT += qml quick
+
+HEADERS += squircle.h
+SOURCES += squircle.cpp main.cpp
+
+OTHER_FILES += main.qml
diff --git a/examples/qtquick/openglunderqml/squircle.cpp b/examples/qml/openglunderqml/squircle.cpp
index b56f0baaf6..b56f0baaf6 100644
--- a/examples/qtquick/openglunderqml/squircle.cpp
+++ b/examples/qml/openglunderqml/squircle.cpp
diff --git a/examples/qtquick/openglunderqml/squircle.h b/examples/qml/openglunderqml/squircle.h
index 283131a662..283131a662 100644
--- a/examples/qtquick/openglunderqml/squircle.h
+++ b/examples/qml/openglunderqml/squircle.h
diff --git a/examples/qtquick/painteditem/painteditem.pro b/examples/qml/painteditem/painteditem.pro
index e3afd6b0f0..e3afd6b0f0 100644
--- a/examples/qtquick/painteditem/painteditem.pro
+++ b/examples/qml/painteditem/painteditem.pro
diff --git a/examples/qml/painteditem/smile/main.cpp b/examples/qml/painteditem/smile/main.cpp
new file mode 100644
index 0000000000..1c7888b10b
--- /dev/null
+++ b/examples/qml/painteditem/smile/main.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QPainter>
+#include <QtQml/qqml.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickpainteditem.h>
+class MyPaintItem : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged)
+public:
+ MyPaintItem()
+ : QQuickPaintedItem()
+ , m_face(QLatin1String(":-)"))
+ {
+ setAntialiasing(true);
+ }
+ QString face() const {return m_face;}
+ void setFace(const QString &face) {
+ if (m_face != face) {
+ m_face = face;
+ emit faceChanged();
+ }
+ }
+ virtual void paint(QPainter *p)
+ {
+ QRectF rect(0, 0, width(), height());
+ rect.adjust(10, 10, -10, -10);
+ p->setPen(QPen(Qt::black, 20));
+ p->setBrush(Qt::yellow);
+ p->drawEllipse(rect);
+ p->setPen(Qt::black);
+ p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2)));
+ p->drawText(rect, Qt::AlignCenter, m_face);
+ }
+signals:
+ void faceChanged();
+private:
+ QString m_face;
+};
+
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<MyPaintItem>("MyModule", 1, 0, "MyPaintItem");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("smile.qml"));
+ view.show();
+ view.raise();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/examples/qml/painteditem/smile/smile.pro b/examples/qml/painteditem/smile/smile.pro
new file mode 100644
index 0000000000..b1af4ee0ad
--- /dev/null
+++ b/examples/qml/painteditem/smile/smile.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = painteditem
+
+QT += qml quick
+
+macx: CONFIG -= app_bundle
+
+SOURCES += main.cpp
+
+CONFIG += console
+
diff --git a/examples/qtquick/painteditem/smile/smile.qml b/examples/qml/painteditem/smile/smile.qml
index 33919bc04f..33919bc04f 100644
--- a/examples/qtquick/painteditem/smile/smile.qml
+++ b/examples/qml/painteditem/smile/smile.qml
diff --git a/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h
new file mode 100644
index 0000000000..e6523e15a9
--- /dev/null
+++ b/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QQmlExtensionPlugin>
+
+#include "../textballoon.h"
+
+class TextBalloonPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ qmlRegisterType<TextBalloon>(uri, 1, 0, "TextBalloon");
+ }
+};
+
+Q_EXPORT_PLUGIN2(qmltextballoonplugin, TextBalloonPlugin);
diff --git a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir
index e8a08ae9d3..e8a08ae9d3 100644
--- a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir
+++ b/examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir
diff --git a/examples/qtquick/painteditem/textballoons/textballoon.cpp b/examples/qml/painteditem/textballoons/textballoon.cpp
index d097adfe1b..d097adfe1b 100644
--- a/examples/qtquick/painteditem/textballoons/textballoon.cpp
+++ b/examples/qml/painteditem/textballoons/textballoon.cpp
diff --git a/examples/qtquick/painteditem/textballoons/textballoon.h b/examples/qml/painteditem/textballoons/textballoon.h
index 93ed0a7105..93ed0a7105 100644
--- a/examples/qtquick/painteditem/textballoons/textballoon.h
+++ b/examples/qml/painteditem/textballoons/textballoon.h
diff --git a/examples/qml/painteditem/textballoons/textballoons.pro b/examples/qml/painteditem/textballoons/textballoons.pro
new file mode 100644
index 0000000000..9bc0f3c04a
--- /dev/null
+++ b/examples/qml/painteditem/textballoons/textballoons.pro
@@ -0,0 +1,23 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml quick
+
+TARGET = qmltextballoonplugin
+
+HEADERS += TextBalloonPlugin/plugin.h \
+ textballoon.h
+
+SOURCES += textballoon.cpp
+
+DESTDIR = TextBalloonPlugin
+
+qqmlsources.files += \
+ TextBalloonPlugin/qmldir
+
+qqmlsources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin
+
+sources.files = textballoons.qml
+sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons
+target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin
+
+INSTALLS = qqmlsources sources target
diff --git a/examples/qtquick/painteditem/textballoons/textballoons.qml b/examples/qml/painteditem/textballoons/textballoons.qml
index b00ce2bfed..b00ce2bfed 100644
--- a/examples/qtquick/painteditem/textballoons/textballoons.qml
+++ b/examples/qml/painteditem/textballoons/textballoons.qml
diff --git a/examples/qml/particles/affectors/age.qml b/examples/qml/particles/affectors/age.qml
new file mode 100644
index 0000000000..1e7774b63b
--- /dev/null
+++ b/examples/qml/particles/affectors/age.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 600
+ color: "white"
+
+ ParticleSystem { id: particles }
+
+ ImageParticle {
+ system: particles
+ sprites: Sprite {
+ name: "snow"
+ source: "../images/snowflake.png"
+ frames: 51
+ frameDuration: 40
+ frameDurationVariation: 8
+ }
+ }
+
+ Emitter {
+ system: particles
+ emitRate: 20
+ lifeSpan: 8000
+ speed: PointDirection { y:80; yVariation: 40; }
+ acceleration: PointDirection { y: 4 }
+ size: 36
+ endSize: 12
+ sizeVariation: 8
+ width: parent.width
+ height: 100
+ }
+
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ hoverEnabled: true
+ }
+
+ Rectangle {
+ color: "#803333AA"
+ border.color: "black"
+ x: ma.mouseX - 36
+ y: ma.mouseY - 36
+ width: 72
+ height: 72
+ Age {
+ anchors.fill: parent
+ system: particles
+ once: true
+ lifeLeft: 1200
+ advancePosition: false
+ }
+ }
+}
diff --git a/examples/qml/particles/affectors/attractor.qml b/examples/qml/particles/affectors/attractor.qml
new file mode 100644
index 0000000000..460a497a92
--- /dev/null
+++ b/examples/qml/particles/affectors/attractor.qml
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 540
+ color: "black"
+ property bool spacePressed: false
+ focus: true
+ Image {
+ source: "../images/finalfrontier.png"
+ anchors.centerIn:parent
+ }
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Space) {
+ spacePressed = true;
+ event.accepted = true;
+ }
+ }
+ Keys.onReleased: {
+ if (event.key == Qt.Key_Space) {
+ spacePressed = false;
+ event.accepted = true;
+ }
+ }
+
+ Emitter {
+ group: "stars"
+ system: particles
+ emitRate: 40
+ lifeSpan: 4000
+ enabled: true
+ size: 30
+ sizeVariation: 10
+ speed: PointDirection { x: 220; xVariation: 40 }
+ height: parent.height
+ }
+ Emitter {
+ group: "roids"
+ system: particles
+ emitRate: 10
+ lifeSpan: 4000
+ enabled: true
+ size: 30
+ sizeVariation: 10
+ speed: PointDirection { x: 220; xVariation: 40 }
+ height: parent.height
+ }
+ ParticleSystem {
+ id: particles
+ anchors.fill: parent
+ }
+ ImageParticle {
+ id: stars
+ groups: ["stars"]
+ system: particles
+ source: "../images/star.png"
+ color: "white"
+ colorVariation: 0.1
+ alpha: 0
+ }
+ ImageParticle {
+ id: roids
+ groups: ["roids"]
+ system: particles
+ sprites: Sprite {
+ id: spinState
+ name: "spinning"
+ source: "../images/meteor.png"
+ frames: 35
+ frameDuration: 60
+ }
+ }
+ ImageParticle {
+ id: shot
+ groups: ["shot"]
+ system: particles
+ source: "../images/star.png"
+
+ color: "#0FF06600"
+ colorVariation: 0.3
+ }
+ ImageParticle {
+ id: engine
+ groups: ["engine"]
+ system: particles
+ source: "../images/particle4.png"
+
+ color: "orange"
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "red"
+ to: "cyan"
+ duration: 1000
+ }
+ ColorAnimation {
+ from: "cyan"
+ to: "red"
+ duration: 1000
+ }
+ }
+
+ colorVariation: 0.2
+ }
+ Attractor {
+ id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000;
+ system: particles
+ affectedParameter: Attractor.Acceleration
+ proportionalToDistance: Attractor.InverseQuadratic
+ }
+ Age {
+ system: particles
+ x: gs.pointX - 8;
+ y: gs.pointY - 8;
+ width: 16
+ height: 16
+ }
+ Rectangle {
+ color: "black"
+ width: 8
+ height: 8
+ radius: 4
+ x: gs.pointX - 4
+ y: gs.pointY - 4
+ }
+
+ Image {
+ source:"../images/rocket2.png"
+ id: ship
+ width: 45
+ height: 22
+ MouseArea {
+ id: ma
+ anchors.fill: parent;
+ drag.axis: Drag.XandYAxis
+ drag.target: ship
+ }
+ }
+ Emitter {
+ group: "engine"
+ system: particles
+ emitRate: 200
+ lifeSpan: 1000
+ size: 10
+ endSize: 4
+ sizeVariation: 4
+ speed: PointDirection { x: -128; xVariation: 32 }
+ height: ship.height
+ y: ship.y
+ x: ship.x
+ width: 20
+ }
+ Emitter {
+ group: "shot"
+ system: particles
+ emitRate: 32
+ lifeSpan: 2000
+ enabled: spacePressed
+ size: 40
+ speed: PointDirection { x: 256; }
+ x: ship.x + ship.width
+ y: ship.y + ship.height/2
+ }
+
+ Text {
+ color: "white"
+ anchors.bottom: parent.bottom
+ text:"Drag the ship, Spacebar to fire."
+ }
+}
+
diff --git a/examples/qml/particles/affectors/customaffector.qml b/examples/qml/particles/affectors/customaffector.qml
new file mode 100644
index 0000000000..3f98cd5b43
--- /dev/null
+++ b/examples/qml/particles/affectors/customaffector.qml
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ width: 360
+ height: 600
+
+ Image {
+ source: "../images/backgroundLeaves.jpg"
+ anchors.fill: parent
+ }
+ ParticleSystem {
+ id: sys
+ }
+ Emitter {
+ system: sys
+ width: parent.width
+ emitRate: 4
+ lifeSpan: 14000
+ size: 80
+ speed: PointDirection { y: 60 }
+ }
+ Wander {
+ system: sys
+ anchors.fill: parent
+ anchors.bottomMargin: 100
+ xVariance: 60
+ pace: 60
+ }
+
+ Affector {
+ system: sys
+ property real coefficient: 0.1
+ property real speed: 1.5
+ width: parent.width
+ height: parent.height - 100
+ onAffectParticles: {
+ /* //Linear movement
+ if (particle.r == 0) {
+ particle.r = Math.random() > 0.5 ? -1 : 1;
+ }else if (particle.r == 1) {
+ particle.rotation += speed * dt;
+ if(particle.rotation >= maxAngle)
+ particle.r = -1;
+ }else if (particle.r == -1) {
+ particle.rotation -= speed * dt;
+ if(particle.rotation <= -1 * maxAngle)
+ particle.r = 1;
+ }
+ */
+ //Wobbly movement
+ for (var i=0; i<particles.length; i++) {
+ var particle = particles[i];
+ if (particle.r == 0.0) {
+ particle.r = Math.random() + 0.01;
+ }
+ particle.rotation += speed * particle.r * dt;
+ particle.r -= particle.rotation * coefficient;
+ if (particle.r == 0.0)
+ particle.r -= particle.rotation * 0.000001;
+ particle.update = 1;
+ }
+ }
+ }
+
+ Affector {//Custom Friction, adds some 'randomness'
+ system: sys
+ //onceOff: true
+ x: -60
+ width: parent.width + 120
+ height: 100
+ anchors.bottom: parent.bottom
+ onAffectParticles: {
+ for (var i=0; i<particles.length; i++) {
+ var particle = particles[i];
+ var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1;
+ var yslow = dt * pseudoRand * 0.5 + 1;
+ var xslow = dt * pseudoRand * 0.05 + 1;
+ if (particle.vy < 1)
+ particle.vy = 0;
+ else
+ particle.vy = (particle.vy / yslow);
+ if (particle.vx < 1)
+ particle.vx = 0;
+ else
+ particle.vx = (particle.vx / xslow);
+ particle.update = true;
+ }
+ }
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ id: particles
+ system: sys
+ sprites: [Sprite {
+ source: "../images/realLeaf1.png"
+ frames: 1
+ frameDuration: 1
+ to: {"a":1, "b":1, "c":1, "d":1}
+ }, Sprite {
+ name: "a"
+ source: "../images/realLeaf1.png"
+ frames: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "b"
+ source: "../images/realLeaf2.png"
+ frames: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "c"
+ source: "../images/realLeaf3.png"
+ frames: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "d"
+ source: "../images/realLeaf4.png"
+ frames: 1
+ frameDuration: 10000
+ }
+ ]
+
+ width: 100
+ height: 100
+ x: 20
+ y: 20
+ z:4
+ }
+}
diff --git a/examples/qml/particles/affectors/friction.qml b/examples/qml/particles/affectors/friction.qml
new file mode 100644
index 0000000000..4161fd9f02
--- /dev/null
+++ b/examples/qml/particles/affectors/friction.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ width: 360
+ height: 600
+
+ Image {
+ source: "../images/backgroundLeaves.jpg"
+ anchors.fill: parent
+ }
+ ParticleSystem { id: sys }
+ Emitter {
+ system: sys
+ width: parent.width
+ emitRate: 4
+ lifeSpan: 14000
+ size: 80
+ speed: PointDirection { y: 160; yVariation: 80; xVariation: 20 }
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ id: particles
+ system: sys
+ sprites: [Sprite {
+ source: "../images/realLeaf1.png"
+ frames: 1
+ frameDuration: 1
+ to: {"a":1, "b":1, "c":1, "d":1}
+ }, Sprite {
+ name: "a"
+ source: "../images/realLeaf1.png"
+ frames: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "b"
+ source: "../images/realLeaf2.png"
+ frames: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "c"
+ source: "../images/realLeaf3.png"
+ frames: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "d"
+ source: "../images/realLeaf4.png"
+ frames: 1
+ frameDuration: 10000
+ }
+ ]
+
+ width: 100
+ height: 100
+ x: 20
+ y: 20
+ z:4
+ }
+ Friction {
+ anchors.fill: parent
+ anchors.margins: -40
+ system: sys
+ factor: 0.4
+ }
+}
diff --git a/examples/qml/particles/affectors/gravity.qml b/examples/qml/particles/affectors/gravity.qml
new file mode 100644
index 0000000000..b90d83e1c8
--- /dev/null
+++ b/examples/qml/particles/affectors/gravity.qml
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: window
+ width: 480; height: 480
+ Rectangle {
+ id: sky
+ anchors.fill: parent
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: "DeepSkyBlue"
+ }
+ GradientStop {
+ position: 1.0
+ color: "SkyBlue"
+ }
+ }
+ }
+
+ Rectangle {
+ id: ground
+ width: parent.width * 2
+ height: parent.height
+ y: parent.height/2
+ x: -parent.height/2
+ transformOrigin: Item.Top
+ rotation: 0
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "ForestGreen"; }
+ GradientStop { position: 1.0; color: "DarkGreen"; }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPositionChanged: {
+ var rot = Math.atan2(mouseY - window.height/2,mouseX - window.width/2) * 180/Math.PI;
+ ground.rotation = rot;
+ }
+ }
+
+ ParticleSystem { id: sys }
+ Gravity {
+ system: sys
+ magnitude: 32
+ angle: ground.rotation + 90
+ }
+ Emitter {
+ system: sys
+ anchors.centerIn: parent
+ emitRate: 1
+ lifeSpan: 10000
+ size: 64
+ }
+ ImageParticle {
+ anchors.fill: parent
+ system: sys
+ source: "../images/realLeaf1.png"
+ }
+
+}
diff --git a/examples/qml/particles/affectors/groupgoal.qml b/examples/qml/particles/affectors/groupgoal.qml
new file mode 100644
index 0000000000..273ec1a30c
--- /dev/null
+++ b/examples/qml/particles/affectors/groupgoal.qml
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+
+Rectangle {
+ id: root
+ width: 360
+ height: 600
+ color: "black"
+
+ property int score: 0
+ Text {
+ color: "white"
+ anchors.right: parent.right
+ text: score
+ }
+
+ ParticleSystem {
+ id: particles
+ anchors.fill: parent
+ ParticleGroup {
+ name: "unlit"
+ duration: 1000
+ to: {"lighting":1, "unlit":99}
+ ImageParticle {
+ source: "../images/particleA.png"
+ colorVariation: 0.1
+ color: "#2060160f"
+ }
+ GroupGoal {
+ whenCollidingWith: ["lit"]
+ goalState: "lighting"
+ jump: true
+ }
+ }
+ ParticleGroup {
+ name: "lighting"
+ duration: 100
+ to: {"lit":1}
+ }
+ ParticleGroup {
+ name: "lit"
+ duration: 10000
+ onEntered: score++;
+ TrailEmitter {
+ id: fireballFlame
+ group: "flame"
+
+ emitRatePerParticle: 48
+ lifeSpan: 200
+ emitWidth: 8
+ emitHeight: 8
+
+ size: 24
+ sizeVariation: 8
+ endSize: 4
+ }
+
+ TrailEmitter {
+ id: fireballSmoke
+ group: "smoke"
+
+ emitRatePerParticle: 120
+ lifeSpan: 2000
+ emitWidth: 16
+ emitHeight: 16
+
+ speed: PointDirection {yVariation: 16; xVariation: 16}
+ acceleration: PointDirection {y: -16}
+
+ size: 24
+ sizeVariation: 8
+ endSize: 8
+ }
+ }
+
+ ImageParticle {
+ id: smoke
+ anchors.fill: parent
+ groups: ["smoke"]
+ source: "../images/particle.png"
+ colorVariation: 0
+ color: "#00111111"
+ }
+ ImageParticle {
+ id: pilot
+ anchors.fill: parent
+ groups: ["pilot"]
+ source: "../images/particle.png"
+ redVariation: 0.01
+ blueVariation: 0.4
+ color: "#0010004f"
+ }
+ ImageParticle {
+ id: flame
+ anchors.fill: parent
+ groups: ["flame", "lit", "lighting"]
+ source: "../images/particleA.png"
+ colorVariation: 0.1
+ color: "#00ff400f"
+ }
+
+ Emitter {
+ height: parent.height/2
+ emitRate: 4
+ lifeSpan: 4000//TODO: Infinite & kill zone
+ size: 24
+ sizeVariation: 4
+ speed: PointDirection {x:120; xVariation: 80; yVariation: 50}
+ acceleration: PointDirection {y:120}
+ group: "unlit"
+ }
+
+ Emitter {
+ id: flamer
+ x: 100
+ y: 300
+ group: "pilot"
+ emitRate: 80
+ lifeSpan: 600
+ size: 24
+ sizeVariation: 2
+ endSize: 0
+ speed: PointDirection { y:-100; yVariation: 4; xVariation: 4 }
+ GroupGoal {
+ groups: ["unlit"]
+ goalState: "lit"
+ jump: true
+ system: particles
+ x: -15
+ y: -55
+ height: 75
+ width: 30
+ shape: MaskShape {source: "../images/matchmask.png"}
+ }
+ }
+ //Click to enflame
+ GroupGoal {
+ groups: ["unlit"]
+ goalState: "lighting"
+ jump: true
+ enabled: ma.pressed
+ width: 18
+ height: 18
+ x: ma.mouseX - width/2
+ y: ma.mouseY - height/2
+ }
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/examples/qml/particles/affectors/move.qml b/examples/qml/particles/affectors/move.qml
new file mode 100644
index 0000000000..f290173ca8
--- /dev/null
+++ b/examples/qml/particles/affectors/move.qml
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 540
+ color: "black"
+ ParticleSystem {
+ anchors.fill: parent
+ ImageParticle {
+ groups: ["A"]
+ anchors.fill: parent
+ source: "../images/star.png"
+ color:"#FF1010"
+ redVariation: 0.8
+ }
+
+ Emitter {
+ group: "A"
+ emitRate: 100
+ lifeSpan: 2800
+ size: 32
+ sizeVariation: 8
+ speed: PointDirection{ x: 66; xVariation: 20 }
+ width: 80
+ height: 80
+ }
+
+ Affector {
+ groups: ["A"]
+ x: 120
+ width: 80
+ height: 80
+ once: true
+ position: PointDirection { x: 120; }
+ }
+
+ ImageParticle {
+ groups: ["B"]
+ anchors.fill: parent
+ source: "../images/star.png"
+ color:"#10FF10"
+ greenVariation: 0.8
+ }
+
+ Emitter {
+ group: "B"
+ emitRate: 100
+ lifeSpan: 2800
+ size: 32
+ sizeVariation: 8
+ speed: PointDirection{ x: 240; xVariation: 60 }
+ y: 260
+ width: 10
+ height: 10
+ }
+
+ Affector {
+ groups: ["B"]
+ x: 120
+ y: 240
+ width: 80
+ height: 80
+ once: true
+ speed: AngleDirection { angleVariation:360; magnitude: 72 }
+ }
+
+ ImageParticle {
+ groups: ["C"]
+ anchors.fill: parent
+ source: "../images/star.png"
+ color:"#1010FF"
+ blueVariation: 0.8
+ }
+
+ Emitter {
+ group: "C"
+ y: 400
+ emitRate: 100
+ lifeSpan: 2800
+ size: 32
+ sizeVariation: 8
+ speed: PointDirection{ x: 80; xVariation: 10 }
+ acceleration: PointDirection { y: 10; x: 20; }
+ width: 80
+ height: 80
+ }
+
+ Affector {
+ groups: ["C"]
+ x: 120
+ y: 400
+ width: 80
+ height: 120
+ once: true
+ relative: false
+ acceleration: PointDirection { y: -80; }
+ }
+
+ }
+}
diff --git a/examples/qml/particles/affectors/spritegoal.qml b/examples/qml/particles/affectors/spritegoal.qml
new file mode 100644
index 0000000000..1ea61442aa
--- /dev/null
+++ b/examples/qml/particles/affectors/spritegoal.qml
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: root
+ width: 360
+ height: 540
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ }
+
+ ParticleSystem { id: sys }
+ Image {
+ source: "../images/finalfrontier.png"
+ transformOrigin: Item.Center
+ anchors.centerIn: parent
+ smooth: true
+ NumberAnimation on rotation {
+ from: 0
+ to: 360
+ duration: 200000
+ loops: Animation.Infinite
+ }
+
+ }
+ ImageParticle {
+ system: sys
+ groups: ["starfield"]
+ source: "../images/star.png"
+ colorVariation: 0.3
+ color: "white"
+ }
+ Emitter {
+ id: starField
+ system: sys
+ group: "starfield"
+
+ emitRate: 80
+ lifeSpan: 2500
+
+ anchors.centerIn: parent
+
+ //acceleration: AngledDirection {angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent speed?
+ acceleration: PointDirection { xVariation: 200; yVariation: 200; }
+
+ size: 0
+ endSize: 80
+ sizeVariation: 10
+ }
+ Emitter {
+ system: sys
+ group: "meteor"
+ emitRate: 12
+ lifeSpan: 5000
+ acceleration: PointDirection { xVariation: 80; yVariation: 80; }
+ size: 15
+ endSize: 300
+ anchors.centerIn: parent
+ }
+ ImageParticle {
+ system: sys
+ groups: ["meteor"]
+ sprites:[Sprite {
+ id: spinState
+ name: "spinning"
+ source: "../images/meteor.png"
+ frames: 35
+ frameDuration: 40
+ randomStart: true
+ to: {"explode":0, "spinning":1}
+ },Sprite {
+ name: "explode"
+ source: "../images/_explo.png"
+ frames: 22
+ frameDuration: 40
+ to: {"nullFrame":1}
+ },Sprite {//Not sure if this is needed, but seemed easiest
+ name: "nullFrame"
+ source: "../images/nullRock.png"
+ frames: 1
+ frameDuration: 1000
+ }
+ ]
+ }
+ SpriteGoal {
+ groups: ["meteor"]
+ system: sys
+ goalState: "explode"
+ jump: true
+ anchors.centerIn: holder//A bug in affectors currently isn't compensating for relative x,y. when that's fixed this can just anchors.fill: rocketShip
+ width: 60
+ height: 60
+ }
+ Image {
+ id: rocketShip
+ source: "../images/rocket.png"
+ smooth: true
+ anchors.centerIn: holder
+ rotation: (circle.percent+0.25) * 360
+ z: 2
+ }
+ Item {
+ id: holder
+ x: circle.x - Math.sin(circle.percent * 6.28316530714)*200
+ y: circle.y + Math.cos(circle.percent * 6.28316530714)*200
+ z: 1
+ }
+
+ Item {
+ id: circle
+ x: root.width / 1.2
+ y: root.height / 1.7
+ property real percent: 0
+
+ SequentialAnimation on percent {
+ id: circleAnim1
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation {
+ duration: 4000
+ from: 1
+ to: 0
+ }
+
+ }
+ }
+
+ ImageParticle {
+ z:0
+ system: sys
+ groups: ["exhaust"]
+ source: "../images/particle4.png"
+
+ color: "orange"
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "red"
+ to: "cyan"
+ duration: 1000
+ }
+ ColorAnimation {
+ from: "cyan"
+ to: "red"
+ duration: 1000
+ }
+ }
+
+ colorVariation: 0.2
+ }
+
+ Emitter {
+ id: trailsNormal2
+ system: sys
+ group: "exhaust"
+
+ emitRate: 300
+ lifeSpan: 500
+
+ y: holder.y
+ x: holder.x
+
+ speed: PointDirection { xVariation: 40; yVariation: 40; }
+ speedFromMovement: 16
+
+ acceleration: PointDirection { xVariation: 10; yVariation: 10; }
+
+ size: 4
+ sizeVariation: 4
+ }
+}
diff --git a/examples/qml/particles/affectors/turbulence.qml b/examples/qml/particles/affectors/turbulence.qml
new file mode 100644
index 0000000000..f3ad13431f
--- /dev/null
+++ b/examples/qml/particles/affectors/turbulence.qml
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 600
+ color: "#222222"
+ id: root
+ Image {
+ source: "../images/candle.png"
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottomMargin: -8
+ anchors.horizontalCenterOffset: 2
+ }
+ ParticleSystem {
+ id: ps
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: turb.enabled = !turb.enabled
+ }
+
+ Turbulence {
+ id: turb
+ system: ps
+ enabled: true
+ height: (parent.height / 2)
+ width: parent.width / 2
+ x: parent. width / 4
+ anchors.fill: parent
+ strength: 32
+ }
+
+ ImageParticle {
+ groups: ["smoke"]
+ system: ps
+ source: "../images/particle.png"
+ color: "#11111111"
+ colorVariation: 0
+ }
+ ImageParticle {
+ groups: ["flame"]
+ system: ps
+ source: "../images/particle.png"
+ color: "#11ff400f"
+ colorVariation: 0.1
+ }
+ Emitter {
+ anchors.centerIn: parent
+ system: ps
+ group: "flame"
+
+ emitRate: 120
+ lifeSpan: 1200
+ size: 20
+ endSize: 10
+ sizeVariation: 10
+ acceleration: PointDirection { y: -40 }
+ speed: AngleDirection { angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
+ }
+ TrailEmitter {
+ id: smoke1
+ width: root.width
+ height: root.height/2 - 20
+ system: ps
+ group: "smoke"
+ follow: "flame"
+
+ emitRatePerParticle: 1
+ lifeSpan: 2400
+ lifeSpanVariation: 400
+ size: 16
+ endSize: 8
+ sizeVariation: 8
+ acceleration: PointDirection { y: -40 }
+ speed: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+ }
+ TrailEmitter {
+ id: smoke2
+ width: root.width
+ height: root.height/2 - 40
+ system: ps
+ group: "smoke"
+ follow: "flame"
+
+ emitRatePerParticle: 4
+ lifeSpan: 2400
+ size: 36
+ endSize: 24
+ sizeVariation: 12
+ acceleration: PointDirection { y: -40 }
+ speed: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+ }
+}
diff --git a/examples/qml/particles/affectors/wander.qml b/examples/qml/particles/affectors/wander.qml
new file mode 100644
index 0000000000..31a0b4a796
--- /dev/null
+++ b/examples/qml/particles/affectors/wander.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "../exampleslauncher/content" as UI
+
+Rectangle {
+ width: 360
+ height: 540
+ ParticleSystem { id: particles }
+ ImageParticle {
+ system: particles
+ sprites: Sprite {
+ name: "snow"
+ source: "../images/snowflake.png"
+ frames: 51
+ frameDuration: 40
+ frameDurationVariation: 8
+ }
+ }
+
+ Wander {
+ id: wanderer
+ system: particles
+ anchors.fill: parent
+ xVariance: 360/(wanderer.affectedParameter+1);
+ pace: 100*(wanderer.affectedParameter+1);
+ }
+
+ Emitter {
+ system: particles
+ emitRate: 20
+ lifeSpan: 7000
+ speed: PointDirection { y:80; yVariation: 40; }
+ acceleration: PointDirection { y: 4 }
+ size: 20
+ sizeVariation: 10
+ width: parent.width
+ height: 100
+ }
+ Row {
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ UI.Button {
+ text:"dx/dt"
+ onClicked: wanderer.affectedParameter = Wander.Position;
+ }
+ UI.Button {
+ text:"dv/dt"
+ onClicked: wanderer.affectedParameter = Wander.Velocity;
+ }
+ UI.Button {
+ text:"da/dt"
+ onClicked: wanderer.affectedParameter = Wander.Acceleration;
+ }
+ }
+}
diff --git a/examples/qml/particles/customparticle/blurparticles.qml b/examples/qml/particles/customparticle/blurparticles.qml
new file mode 100644
index 0000000000..3d72425655
--- /dev/null
+++ b/examples/qml/particles/customparticle/blurparticles.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "white"
+ width: 240
+ height: 360
+ ParticleSystem {
+ id: sys
+ }
+ Emitter {
+ system:sys
+ height: parent.height
+ emitRate: 1
+ lifeSpan: 12000
+ speed: PointDirection {x:20;}
+ size: 128
+ }
+ ShaderEffectSource {
+ id: theSource
+ sourceItem: theItem
+ hideSource: true
+ }
+ Image {
+ id: theItem
+ source: "../images/starfish_1.png"
+ }
+
+ CustomParticle {
+ system: sys
+ vertexShader:"
+ uniform lowp float qt_Opacity;
+ varying lowp float fFade;
+ varying lowp float fBlur;
+
+ void main() {
+ defaultMain();
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = fadeIn * fadeOut * qt_Opacity;
+ fBlur = max(0.2 * t, t * qt_ParticleR);
+ }
+ "
+ property variant source: theSource
+ property variant blurred: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(0.0, 1.0 / height)
+ property variant source: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(1.0 / width, 0.0)
+ property variant source: theSource
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform sampler2D blurred;
+ varying highp vec2 qt_TexCoord0;
+ varying highp float fBlur;
+ varying highp float fFade;
+ void main() {
+ gl_FragColor = mix(texture2D(source, qt_TexCoord0), texture2D(blurred, qt_TexCoord0), min(1.0,fBlur*3.0)) * fFade;
+ }"
+
+ }
+}
+
diff --git a/examples/qml/particles/customparticle/fragmentshader.qml b/examples/qml/particles/customparticle/fragmentshader.qml
new file mode 100644
index 0000000000..34acb1bd7c
--- /dev/null
+++ b/examples/qml/particles/customparticle/fragmentshader.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ id: root
+ width: 1024
+ height: 768
+ Rectangle {
+ z: -1
+ anchors.fill: parent
+ color: "black"
+ Text {
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 36
+ color: "white"
+ text: "It's all in the fragment shader."
+ }
+ }
+
+ Emitter {
+ emitRate: 400
+ lifeSpan: 8000
+ size: 24
+ sizeVariation: 16
+ speed: PointDirection {x: root.width/10; y: root.height/10;}
+ //acceleration: AngledDirection {angle:225; magnitude: root.width/36; angleVariation: 45; magnitudeVariation: 80}
+ acceleration: PointDirection {x: -root.width/40; y: -root.height/40; xVariation: -root.width/20; yVariation: -root.width/20}
+ }
+
+ CustomParticle {
+ vertexShader:"
+ uniform lowp float qt_Opacity;
+ varying lowp float fFade;
+ varying highp vec2 fPos;
+
+ void main() {
+ qt_TexCoord0 = qt_ParticleTex;
+ highp float size = qt_ParticleData.z;
+ highp float endSize = qt_ParticleData.w;
+
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
+
+ highp float currentSize = mix(size, endSize, t * t);
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos = qt_ParticlePos
+ - currentSize / 2. + currentSize * qt_ParticleTex // adjust size
+ + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector..
+ + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.);
+
+ gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
+
+ highp float fadeIn = min(t * 20., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = fadeIn * fadeOut * qt_Opacity;
+ fPos = vec2(pos.x/1024., pos.y/768.);
+ }
+ "
+ fragmentShader: "
+ varying highp vec2 fPos;
+ varying lowp float fFade;
+ varying highp vec2 qt_TexCoord0;
+ void main() {//*2 because this generates dark colors mostly
+ highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0);
+ highp float dist = length(circlePos);
+ highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0);
+ gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade;
+ }"
+
+ }
+}
diff --git a/examples/qml/particles/customparticle/imagecolors.qml b/examples/qml/particles/customparticle/imagecolors.qml
new file mode 100644
index 0000000000..94e5123a0c
--- /dev/null
+++ b/examples/qml/particles/customparticle/imagecolors.qml
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+ Rectangle {
+ id: root
+ color: "white"
+ width: 310
+ height: 300
+ anchors.centerIn: parent
+ ParticleSystem { id: sys }
+ CustomParticle {
+ system: sys
+ property real maxWidth: root.width
+ property real maxHeight: root.height
+ ShaderEffectSource {
+ id: pictureSource
+ sourceItem: picture
+ hideSource: true
+ }
+ Image {
+ id: picture
+ source: "../images/starfish_3.png"
+ }
+ ShaderEffectSource {
+ id: particleSource
+ sourceItem: particle
+ hideSource: true
+ }
+ Image {
+ id: particle
+ source: "../images/particle4.png"
+ }
+ vertexShader:"
+ uniform highp float maxWidth;
+ uniform highp float maxHeight;
+ varying highp vec2 fTex2;
+ varying lowp float fFade;
+ uniform lowp float qt_Opacity;
+
+ void main() {
+ fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight);
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
+ fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity;
+ defaultMain();
+ }
+ "
+ property variant particleTexture: particleSource
+ property variant pictureTexture: pictureSource
+ fragmentShader: "
+ uniform sampler2D particleTexture;
+ uniform sampler2D pictureTexture;
+ varying highp vec2 qt_TexCoord0;
+ varying highp vec2 fTex2;
+ varying lowp float fFade;
+ void main() {
+ gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade;
+ }"
+ }
+
+ Emitter {
+ id: emitter
+ system: sys
+ enabled: false
+ lifeSpan: 8000
+ maximumEmitted: 4000
+ anchors.fill: parent
+ size: 16
+ acceleration: PointDirection { xVariation: 12; yVariation: 12 }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: emitter.burst(4000);
+ }
+ }
+}
diff --git a/examples/qml/particles/emitters/burstandpulse.qml b/examples/qml/particles/emitters/burstandpulse.qml
new file mode 100644
index 0000000000..1b1c2a60c9
--- /dev/null
+++ b/examples/qml/particles/emitters/burstandpulse.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 540
+ color: "black"
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (mouse.button == Qt.LeftButton)
+ emitter.burst(1000);
+ else
+ emitter.pulse(500);
+ }
+ }
+
+ ParticleSystem {
+ id: particles
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../images/star.png"
+ alpha: 0
+ colorVariation: 0.6
+ }
+
+ Emitter {
+ id: emitter
+ x: ma.mouseX
+ y: ma.mouseY
+ system: particles
+ emitRate: 2000
+ lifeSpan: 2000
+ enabled: false
+ speed: AngleDirection{magnitude: 64; angleVariation: 360}
+ size: 24
+ sizeVariation: 8
+ }
+}
diff --git a/examples/qml/particles/emitters/customemitter.qml b/examples/qml/particles/emitters/customemitter.qml
new file mode 100644
index 0000000000..757c836106
--- /dev/null
+++ b/examples/qml/particles/emitters/customemitter.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ id: sys
+ width: 360
+ height: 600
+ running: true
+ Rectangle {
+ z: -1
+ anchors.fill: parent
+ color: "black"
+ }
+
+ property real petalLength: 180
+ property real petalRotation: 0
+ NumberAnimation on petalRotation {
+ from: 0;
+ to: 360;
+ loops: -1;
+ running: true
+ duration: 24000
+ }
+
+ function convert(a) {return a*(Math.PI/180);}
+ Emitter {
+ lifeSpan: 4000
+ emitRate: 120
+ size: 12
+ anchors.centerIn: parent
+ onEmitParticles: {
+ for (var i=0; i<particles.length; i++) {
+ var particle = particles[i];
+ particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24));
+ var theta = Math.floor(Math.random() * 6.0) / 6.0;
+ theta *= 2.0*Math.PI;
+ theta += sys.convert(sys.petalRotation);
+ particle.initialVX = petalLength * Math.cos(theta);
+ particle.initialVY = petalLength * Math.sin(theta);
+ particle.initialAX = particle.initialVX * -0.5;
+ particle.initialAY = particle.initialVY * -0.5;
+ }
+ }
+ }
+
+ ImageParticle {
+ source: "../images/particle4.png"
+ alpha: 0.0
+ redVariation: 0.6
+ color: "white"
+ }
+}
diff --git a/examples/qml/particles/emitters/emitmask.qml b/examples/qml/particles/emitters/emitmask.qml
new file mode 100644
index 0000000000..9c02f6a213
--- /dev/null
+++ b/examples/qml/particles/emitters/emitmask.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "goldenrod"
+ width: 400
+ height: 400
+ ParticleSystem {
+ width: 300
+ height: 300
+ anchors.centerIn: parent
+
+ ImageParticle {
+ source: "../images/particle.png"
+ z: 2
+ anchors.fill: parent
+ color: "#336666CC"
+ colorVariation: 0.0
+ }
+
+ Emitter {
+ anchors.fill: parent
+ emitRate: 6000
+ lifeSpan: 720
+ size: 10
+ shape: MaskShape {
+ source: "../images/starfish_mask.png"
+ }
+ }
+
+ }
+}
diff --git a/examples/qml/particles/emitters/maximumemitted.qml b/examples/qml/particles/emitters/maximumemitted.qml
new file mode 100644
index 0000000000..6dbdf8db61
--- /dev/null
+++ b/examples/qml/particles/emitters/maximumemitted.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "black"
+ width: 360
+ height: 540
+ ParticleSystem {
+ id: sys
+ onEmptyChanged: if (empty) sys.pause();
+ }
+
+ ImageParticle {
+ system: sys
+ id: cp
+ source: "../images/particle.png"
+ colorVariation: 0.4
+ color: "#000000FF"
+ }
+
+ Emitter {
+ //burst on click
+ id: bursty
+ system: sys
+ enabled: ma.pressed
+ x: ma.mouseX
+ y: ma.mouseY
+ emitRate: 16000
+ maximumEmitted: 4000
+ acceleration: AngleDirection {angleVariation: 360; magnitude: 360; }
+ size: 8
+ endSize: 16
+ sizeVariation: 4
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: sys.resume()
+ id: ma
+ }
+}
diff --git a/examples/qml/particles/emitters/shapeanddirection.qml b/examples/qml/particles/emitters/shapeanddirection.qml
new file mode 100644
index 0000000000..43623427b6
--- /dev/null
+++ b/examples/qml/particles/emitters/shapeanddirection.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 540
+ color: "black"
+ Image {
+ anchors.fill: parent
+ source: "../images/portal_bg.png"
+ }
+
+ ParticleSystem {
+ id: particles
+ }
+
+ ImageParticle {
+ groups: ["center","edge"]
+ anchors.fill: parent
+ system: particles
+ source: "../images/particle.png"
+ colorVariation: 0.1
+ color: "#009999FF"
+ }
+
+ Emitter {
+ anchors.fill: parent
+ group: "center"
+ system: particles
+ emitRate: 400
+ lifeSpan: 2000
+ size: 20
+ sizeVariation: 2
+ endSize: 0
+ shape: EllipseShape {fill: false}
+ speed: TargetDirection {
+ targetX: root.width/2
+ targetY: root.height/2
+ proportionalMagnitude: true
+ magnitude: 0.5
+ }
+ }
+
+ Emitter {
+ anchors.fill: parent
+ group: "edge"
+ startTime: 2000
+ system: particles
+ emitRate: 2000
+ lifeSpan: 2000
+ size: 28
+ sizeVariation: 2
+ endSize: 16
+ shape: EllipseShape {fill: false}
+ speed: TargetDirection {
+ targetX: root.width/2
+ targetY: root.height/2
+ proportionalMagnitude: true
+ magnitude: 0.1
+ magnitudeVariation: 0.1
+ }
+ acceleration: TargetDirection {
+ targetX: root.width/2
+ targetY: root.height/2
+ targetVariation: 200
+ proportionalMagnitude: true
+ magnitude: 0.1
+ magnitudeVariation: 0.1
+ }
+ }
+}
diff --git a/examples/qml/particles/emitters/timedgroupchanges.qml b/examples/qml/particles/emitters/timedgroupchanges.qml
new file mode 100644
index 0000000000..699e7eb066
--- /dev/null
+++ b/examples/qml/particles/emitters/timedgroupchanges.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 600
+ color: "black"
+ ParticleSystem {
+ anchors.fill: parent
+ id: syssy
+ ParticleGroup {
+ name: "fire"
+ duration: 2000
+ durationVariation: 2000
+ to: {"splode":1}
+ }
+ ParticleGroup {
+ name: "splode"
+ duration: 400
+ to: {"dead":1}
+ TrailEmitter {
+ group: "works"
+ emitRatePerParticle: 100
+ lifeSpan: 1000
+ maximumEmitted: 1200
+ size: 8
+ speed: AngleDirection {angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;}
+ acceleration: PointDirection {y:100; yVariation: 20}
+ }
+ }
+ ParticleGroup {
+ name: "dead"
+ duration: 1000
+ Affector {
+ once: true
+ onAffected: worksEmitter.burst(400,x,y)
+ }
+ }
+
+ Timer {
+ interval: 6000
+ running: true
+ triggeredOnStart: true
+ repeat: true
+ onTriggered:startingEmitter.pulse(100);
+ }
+ Emitter {
+ id: startingEmitter
+ group: "fire"
+ width: parent.width
+ y: parent.height
+ enabled: false
+ emitRate: 80
+ lifeSpan: 6000
+ speed: PointDirection {y:-100;}
+ size: 32
+ }
+
+ Emitter {
+ id: worksEmitter
+ group: "works"
+ enabled: false
+ emitRate: 100
+ lifeSpan: 1600
+ maximumEmitted: 6400
+ size: 8
+ speed: CumulativeDirection {
+ PointDirection {y:-100}
+ AngleDirection {angleVariation: 360; magnitudeVariation: 80;}
+ }
+ acceleration: PointDirection {y:100; yVariation: 20}
+ }
+
+ ImageParticle {
+ groups: ["works", "fire", "splode"]
+ source: "../images/particle.png"
+ entryEffect: ImageParticle.Scale
+ }
+ }
+}
+
diff --git a/examples/qml/particles/emitters/trailemitter.qml b/examples/qml/particles/emitters/trailemitter.qml
new file mode 100644
index 0000000000..e896329ca1
--- /dev/null
+++ b/examples/qml/particles/emitters/trailemitter.qml
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 540
+ color: "black"
+
+ ParticleSystem {
+ id: particles
+ }
+
+ ImageParticle {
+ id: smoke
+ system: particles
+ anchors.fill: parent
+ groups: ["A", "B"]
+ source: "../images/particle.png"
+ colorVariation: 0
+ color: "#00111111"
+ }
+ ImageParticle {
+ id: flame
+ anchors.fill: parent
+ system: particles
+ groups: ["C", "D"]
+ source: "../images/particle.png"
+ colorVariation: 0.1
+ color: "#00ff400f"
+ }
+
+ Emitter {
+ id: fire
+ system: particles
+ group: "C"
+
+ y: parent.height
+ width: parent.width
+
+ emitRate: 350
+ lifeSpan: 3500
+
+ acceleration: PointDirection { y: -17; xVariation: 3 }
+ speed: PointDirection {xVariation: 3}
+
+ size: 24
+ sizeVariation: 8
+ endSize: 4
+ }
+
+ TrailEmitter {
+ id: fireSmoke
+ group: "B"
+ system: particles
+ follow: "C"
+ width: root.width
+ height: root.height - 68
+
+ emitRatePerParticle: 1
+ lifeSpan: 2000
+
+ speed: PointDirection {y:-17*6; yVariation: -17; xVariation: 3}
+ acceleration: PointDirection {xVariation: 3}
+
+ size: 36
+ sizeVariation: 8
+ endSize: 16
+ }
+
+ TrailEmitter {
+ id: fireballFlame
+ anchors.fill: parent
+ system: particles
+ group: "D"
+ follow: "E"
+
+ emitRatePerParticle: 120
+ lifeSpan: 180
+ emitWidth: TrailEmitter.ParticleSize
+ emitHeight: TrailEmitter.ParticleSize
+ emitShape: EllipseShape{}
+
+ size: 16
+ sizeVariation: 4
+ endSize: 4
+ }
+
+ TrailEmitter {
+ id: fireballSmoke
+ anchors.fill: parent
+ system: particles
+ group: "A"
+ follow: "E"
+
+ emitRatePerParticle: 128
+ lifeSpan: 2400
+ emitWidth: TrailEmitter.ParticleSize
+ emitHeight: TrailEmitter.ParticleSize
+ emitShape: EllipseShape{}
+
+ speed: PointDirection {yVariation: 16; xVariation: 16}
+ acceleration: PointDirection {y: -16}
+
+ size: 24
+ sizeVariation: 8
+ endSize: 8
+ }
+
+ Emitter {
+ id: balls
+ system: particles
+ group: "E"
+
+ y: parent.height
+ width: parent.width
+
+ emitRate: 2
+ lifeSpan: 7000
+
+ speed: PointDirection {y:-17*4*2; xVariation: 6*6}
+ acceleration: PointDirection {y: 17*2; xVariation: 6*6}
+
+ size: 8
+ sizeVariation: 4
+ }
+
+ Turbulence { //A bit of turbulence makes the smoke look better
+ anchors.fill: parent
+ groups: ["A","B"]
+ strength: 32
+ system: particles
+ }
+}
+
diff --git a/examples/qml/particles/emitters/velocityfrommotion.qml b/examples/qml/particles/emitters/velocityfrommotion.qml
new file mode 100644
index 0000000000..7ad2b4d6c4
--- /dev/null
+++ b/examples/qml/particles/emitters/velocityfrommotion.qml
@@ -0,0 +1,311 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+
+ id: root
+
+ height: 540
+ width: 360
+
+ gradient: Gradient {
+ GradientStop { position: 0; color: "#000020" }
+ GradientStop { position: 1; color: "#000000" }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: root
+ }
+
+ ParticleSystem { id: sys1 }
+ ImageParticle {
+ system: sys1
+ source: "../images/particle.png"
+ color: "cyan"
+ alpha: 0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "cyan"
+ to: "magenta"
+ duration: 1000
+ }
+ ColorAnimation {
+ from: "magenta"
+ to: "blue"
+ duration: 2000
+ }
+ ColorAnimation {
+ from: "blue"
+ to: "violet"
+ duration: 2000
+ }
+ ColorAnimation {
+ from: "violet"
+ to: "cyan"
+ duration: 2000
+ }
+ }
+ colorVariation: 0.3
+ }
+ Emitter {
+ id: trailsNormal
+ system: sys1
+
+ emitRate: 500
+ lifeSpan: 2000
+
+
+ y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
+ x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
+
+ speed: PointDirection {xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection {xVariation: 10; yVariation: 10;}
+ speedFromMovement: 8
+
+ size: 8
+ sizeVariation: 4
+ }
+ ParticleSystem { id: sys2 }
+ ImageParticle {
+ color: "cyan"
+ system: sys2
+ alpha: 0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "magenta"
+ to: "cyan"
+ duration: 1000
+ }
+ ColorAnimation {
+ from: "cyan"
+ to: "magenta"
+ duration: 2000
+ }
+ }
+ colorVariation: 0.5
+ source: "../images/star.png"
+ }
+ Emitter {
+ id: trailsStars
+ system: sys2
+
+ emitRate: 100
+ lifeSpan: 2200
+
+
+ y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
+ x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
+
+ speed: PointDirection {xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection {xVariation: 10; yVariation: 10;}
+ speedFromMovement: 8
+
+ size: 22
+ sizeVariation: 4
+ }
+ ParticleSystem { id: sys3; }
+ ImageParticle {
+ source: "../images/particle.png"
+ system: sys3
+ color: "orange"
+ alpha: 0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "red"
+ to: "green"
+ duration: 2000
+ }
+ ColorAnimation {
+ from: "green"
+ to: "red"
+ duration: 2000
+ }
+ }
+
+ colorVariation: 0.2
+
+ }
+ Emitter {
+ id: trailsNormal2
+ system: sys3
+
+ emitRate: 300
+ lifeSpan: 2000
+
+ y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy
+ x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx
+
+ speedFromMovement: 16
+
+ speed: PointDirection {xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection {xVariation: 10; yVariation: 10;}
+
+ size: 12
+ sizeVariation: 4
+ }
+ ParticleSystem { id: sys4; }
+ ImageParticle {
+ system: sys4
+ source: "../images/star.png"
+ color: "green"
+ alpha: 0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "green"
+ to: "red"
+ duration: 2000
+ }
+ ColorAnimation {
+ from: "red"
+ to: "green"
+ duration: 2000
+ }
+ }
+
+ colorVariation: 0.5
+ }
+ Emitter {
+ id: trailsStars2
+ system: sys4
+
+ emitRate: 50
+ lifeSpan: 2200
+
+
+ y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy
+ x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx
+
+ speedFromMovement: 16
+ speed: PointDirection {xVariation: 2; yVariation: 2;}
+ acceleration: PointDirection {xVariation: 10; yVariation: 10;}
+
+ size: 22
+ sizeVariation: 4
+ }
+
+
+
+ color: "white"
+
+ Item {
+ id: circle
+ //anchors.fill: parent
+ property real radius: 0
+ property real dx: root.width / 2
+ property real dy: root.height / 2
+ property real cx: radius * Math.sin(percent*6.283185307179) + dx
+ property real cy: radius * Math.cos(percent*6.283185307179) + dy
+ property real percent: 0
+
+ SequentialAnimation on percent {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation {
+ duration: 1000
+ from: 1
+ to: 0
+ loops: 8
+ }
+ NumberAnimation {
+ duration: 1000
+ from: 0
+ to: 1
+ loops: 8
+ }
+
+ }
+
+ SequentialAnimation on radius {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation {
+ duration: 4000
+ from: 0
+ to: 100
+ }
+ NumberAnimation {
+ duration: 4000
+ from: 100
+ to: 0
+ }
+ }
+ }
+
+ Item {
+ id: circle3
+ property real radius: 100
+ property real dx: root.width / 2
+ property real dy: root.height / 2
+ property real cx: radius * Math.sin(percent*6.283185307179) + dx
+ property real cy: radius * Math.cos(percent*6.283185307179) + dy
+ property real percent: 0
+
+ SequentialAnimation on percent {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation { from: 0.0; to: 1 ; duration: 10000; }
+ }
+ }
+
+ Item {
+ id: circle2
+ property real radius: 30
+ property real dx: circle3.cx
+ property real dy: circle3.cy
+ property real cx: radius * Math.sin(percent*6.283185307179) + dx
+ property real cy: radius * Math.cos(percent*6.283185307179) + dy
+ property real percent: 0
+
+ SequentialAnimation on percent {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation { from: 0.0; to: 1 ; duration: 1000; }
+ }
+ }
+
+}
diff --git a/examples/qml/particles/exampleslauncher/content/Button.qml b/examples/qml/particles/exampleslauncher/content/Button.qml
new file mode 100644
index 0000000000..e51a9be003
--- /dev/null
+++ b/examples/qml/particles/exampleslauncher/content/Button.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 20
+ smooth: true
+ property color myCol: "#999999"
+ border { width: 1; color: Qt.darker(myCol) }
+ radius: 8
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return Qt.darker(myCol)
+ else
+ return Qt.lighter(myCol)
+ }
+ }
+ GradientStop { position: 1.0; color: myCol }
+ }
+
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: "black"; font.pixelSize: 24
+ }
+}
diff --git a/examples/qml/particles/exampleslauncher/content/Shell.qml b/examples/qml/particles/exampleslauncher/content/Shell.qml
new file mode 100644
index 0000000000..afab77485f
--- /dev/null
+++ b/examples/qml/particles/exampleslauncher/content/Shell.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Loader {
+ id: ldr
+ visible: false
+ focus: visible
+ onVisibleChanged: source = ""
+ opacity: visible?1:0
+ Behavior on opacity {NumberAnimation {}}
+
+ function setDemo(str) {
+ visible = true;
+ source = str;
+ }
+ Image {//TODO: Augment with PARTICLES
+ z: 1
+ source: "../../images/launcherIcons/close.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: ldr.visible = false;
+ }
+ }
+ Rectangle {
+ z: -1
+ anchors.fill: parent
+ color:"black"
+ Text {
+ color: "white"
+ anchors.centerIn: parent
+ text: ldr.Status == Loader.Error ? "Error :(" : "Loading..."
+ }
+ MouseArea {
+ id: graball
+ anchors.fill: parent
+ onClicked:;
+ }
+ }
+}
diff --git a/examples/qml/particles/exampleslauncher/content/launcher.js b/examples/qml/particles/exampleslauncher/content/launcher.js
new file mode 100644
index 0000000000..a296dbd6a6
--- /dev/null
+++ b/examples/qml/particles/exampleslauncher/content/launcher.js
@@ -0,0 +1,8 @@
+function nameFromPath(path){
+ var ret = path.split('/');
+ return ret[ret.length-1].split('.')[0];
+}
+function iconFromPath(path){
+ var ret = path.split('/');
+ return "../images/launcherIcons/" + ret[ret.length-1].split('.')[0] + ".png";
+}
diff --git a/examples/qml/particles/exampleslauncher/exampleslauncher.qml b/examples/qml/particles/exampleslauncher/exampleslauncher.qml
new file mode 100644
index 0000000000..22914343ba
--- /dev/null
+++ b/examples/qml/particles/exampleslauncher/exampleslauncher.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content/launcher.js" as Util
+import "content"
+
+Rectangle {
+ color: "black"
+ width: 360
+ height: 600
+ Shell {
+ z: 1
+ id: shell
+ anchors.fill: parent
+ }
+
+ VisualDataModel {//TODO: Transitions between modes (and a second mode...)
+ id: vdm
+ model: [
+ "../../affectors/attractor.qml",
+ "../../affectors/customaffector.qml",
+ "../../affectors/groupgoal.qml",
+ "../../affectors/spritegoal.qml",
+ "../../affectors/turbulence.qml",
+ "../../affectors/wander.qml",
+ "../../customparticle/blurparticles.qml",
+ "../../customparticle/fragmentshader.qml",
+ "../../customparticle/imagecolors.qml",
+ "../../emitters/customemitter.qml",
+ "../../emitters/emitmask.qml",
+ "../../emitters/maximumemitted.qml",
+ "../../emitters/shapeanddirection.qml",
+ "../../emitters/timedgroupchanges.qml",
+ "../../emitters/trailemitter.qml",
+ "../../emitters/velocityfrommotion.qml",
+ "../../imageparticle/allatonce.qml",
+ "../../imageparticle/colortable.qml",
+ "../../imageparticle/deformation.qml",
+ "../../imageparticle/rotation.qml",
+ "../../imageparticle/sprites.qml",
+ "../../itemparticle/delegates.qml",
+ "../../itemparticle/particleview.qml",
+ "../../simple/dynamicemitters.qml",
+ "../../simple/multiplepainters.qml",
+ "../../simple/startstop.qml",
+ "../../plasmapatrol/plasmapatrol.qml"
+ ]
+ delegate: Rectangle {
+ color: "white"
+ width: 96
+ height: 96
+ Image {
+ width: 72
+ height: 72
+ anchors.centerIn: parent
+ source: Util.iconFromPath(modelData)
+ }
+ Text {
+ text: Util.nameFromPath(modelData)
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 8
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: shell.setDemo(modelData)
+ }
+ }
+ }
+
+ GridView {
+ anchors.fill: parent
+ cellWidth: 120
+ cellHeight: 120
+ model: vdm
+ }
+}
diff --git a/examples/qml/particles/imageparticle/allatonce.qml b/examples/qml/particles/imageparticle/allatonce.qml
new file mode 100644
index 0000000000..fbc634ec9a
--- /dev/null
+++ b/examples/qml/particles/imageparticle/allatonce.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "white"
+ width: 640
+ height: 480
+ ParticleSystem {
+ id: sys
+ }
+
+ ImageParticle {
+ sprites: [
+ Sprite {
+ name: "bear"
+ source: "../images/bear_tiles.png"
+ frames: 13
+ frameDuration: 120
+ }
+ ]
+ colorVariation: 0.5
+ rotationSpeedVariation: 360
+ system: sys
+ colorTable: "../trails/../images/colortable.png"
+ }
+
+ Friction {
+ factor: 0.1
+ system: sys
+ }
+
+ Emitter {
+ system: sys
+ anchors.centerIn: parent
+ id: particles
+ emitRate: 200
+ lifeSpan: 6000
+ speed: AngleDirection {angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
+ size: 60
+ endSize: 120
+ }
+
+ Text {
+ x: 16
+ y: 16
+ text: "QML..."
+ style: Text.Outline; styleColor: "#AAAAAA"
+ font.pixelSize: 32
+ }
+ Text {
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ anchors.margins: 16
+ text: "... can you be trusted with the power?"
+ style: Text.Outline; styleColor: "#AAAAAA"
+ font.pixelSize: width > 400 ? 32 : 16
+ }
+}
diff --git a/examples/qml/particles/imageparticle/colored.qml b/examples/qml/particles/imageparticle/colored.qml
new file mode 100644
index 0000000000..ac760b6219
--- /dev/null
+++ b/examples/qml/particles/imageparticle/colored.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 540
+ color: "black"
+ ParticleSystem {
+ anchors.fill: parent
+ ImageParticle {
+ groups: ["stars"]
+ anchors.fill: parent
+ source: "../images/star.png"
+ }
+ Emitter {
+ group: "stars"
+ emitRate: 800
+ lifeSpan: 2400
+ size: 24
+ sizeVariation: 8
+ anchors.fill: parent
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ source: "../images/star.png"
+ alpha: 0
+ alphaVariation: 0.2
+ colorVariation: 1.0
+ }
+
+ Emitter {
+ anchors.centerIn: parent
+ emitRate: 400
+ lifeSpan: 2400
+ size: 48
+ sizeVariation: 8
+ speed: AngleDirection {angleVariation: 180; magnitude: 60}
+ }
+
+ Turbulence {
+ anchors.fill: parent
+ strength: 2
+ }
+ }
+}
diff --git a/examples/qml/particles/imageparticle/colortable.qml b/examples/qml/particles/imageparticle/colortable.qml
new file mode 100644
index 0000000000..623029dae0
--- /dev/null
+++ b/examples/qml/particles/imageparticle/colortable.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick.Particles 2.0
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 540
+ color: "black"
+
+ ParticleSystem { id: particles }
+
+ ImageParticle {
+ system: particles
+ colorVariation: 0.5
+ alpha: 0
+
+ source: "../images/particle.png"
+ colorTable: "../images/colortable.png"
+ sizeTable: "../images/colortable.png"
+ }
+
+ Emitter {
+ system: particles
+ emitRate: 500
+ lifeSpan: 2000
+
+ y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3
+ x: root.width / 2 + Math.cos(t) * root.width * 0.3
+ property real t;
+
+ NumberAnimation on t {
+ from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite
+ }
+
+ speedFromMovement: 20
+
+ speed: PointDirection { xVariation: 5; yVariation: 5;}
+ acceleration: PointDirection { xVariation: 5; yVariation: 5;}
+
+ size: 16
+ //endSize: 8
+ //sizeVariation: 8
+ }
+}
diff --git a/examples/qml/particles/imageparticle/deformation.qml b/examples/qml/particles/imageparticle/deformation.qml
new file mode 100644
index 0000000000..e282927e78
--- /dev/null
+++ b/examples/qml/particles/imageparticle/deformation.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "goldenrod"
+ width: 400
+ height: 400
+ ParticleSystem {id:sys}
+
+ ImageParticle {
+ system: sys
+ groups: ["goingLeft", "goingRight"]
+ source: "../images/starfish_4.png"
+ rotation: 90
+ rotationSpeed: 90
+ autoRotation: true
+ }
+ ImageParticle {
+ system: sys
+ groups: ["goingDown"]
+ source: "../images/starfish_0.png"
+ rotation: 180
+ yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; }
+ }
+
+ Timer {
+ running: true
+ repeat: false
+ interval: 100
+ onTriggered: emitA.enabled = true;
+ }
+ Timer {
+ running: true
+ repeat: false
+ interval: 4200
+ onTriggered: emitB.enabled = true;
+ }
+ Timer {
+ running: true
+ repeat: false
+ interval: 8400
+ onTriggered: emitC.enabled = true;
+ }
+
+ Emitter {
+ id: emitA
+ x: 0
+ y: 120
+ system: sys
+ enabled: false
+ group: "goingRight"
+ speed: PointDirection { x: 100 }
+ lifeSpan: 4000
+ emitRate: 1
+ size: 128
+ }
+ Emitter {
+ id: emitB
+ x: 400
+ y: 240
+ system: sys
+ enabled: false
+ group: "goingLeft"
+ speed: PointDirection { x: -100 }
+ lifeSpan: 4000
+ emitRate: 1
+ size: 128
+ }
+ Emitter {
+ id: emitC
+ x: 0
+ y: 360
+ system: sys
+ enabled: false
+ group: "goingDown"
+ speed: PointDirection { x: 100 }
+ lifeSpan: 4000
+ emitRate: 1
+ size: 128
+ }
+}
diff --git a/examples/qml/particles/imageparticle/rotation.qml b/examples/qml/particles/imageparticle/rotation.qml
new file mode 100644
index 0000000000..3a75c379ed
--- /dev/null
+++ b/examples/qml/particles/imageparticle/rotation.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "goldenrod"
+ width: 2000
+ height: 2000
+ ParticleSystem {id: sys}
+ ImageParticle {
+ id: up
+ system: sys
+ source: "../images/starfish_2.png"
+ }
+
+ Emitter {
+ anchors.centerIn: parent
+ system: sys
+ emitRate: 10
+ size: 200
+ lifeSpan: 10000
+ speed: AngleDirection {angleVariation: 360; magnitudeVariation: 100;}
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ up.autoRotation = !up.autoRotation
+ up.rotation = up.autoRotation ? -90 : 0
+ }
+ }
+}
diff --git a/examples/qml/particles/imageparticle/sharing.qml b/examples/qml/particles/imageparticle/sharing.qml
new file mode 100644
index 0000000000..27e08322d9
--- /dev/null
+++ b/examples/qml/particles/imageparticle/sharing.qml
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This example shows how to create your own highlight delegate for a ListView
+// that uses a SpringAnimation to provide custom movement when the
+// highlight bar is moved between items.
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ property real delegateHeight: 65
+ width: 200; height: 300
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#EEEEFF" }
+ GradientStop { position: 1.0; color: "lightblue" }
+ }
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+ Component {
+ id: petDelegate
+ Item {
+ id: wrapper
+ width: 200; height: delegateHeight
+ z: 10
+ Column {
+ Text {color: "white"; text: name; font.pixelSize: 18 }
+ Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 }
+ Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 }
+ }
+ // indent the item if it is the current item
+ states: State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 20 }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 200 }
+ }
+ }
+ }
+
+ // Define a highlight with customised movement between items.
+ Component {
+ id: highlightBar
+ Rectangle {
+ z: 0
+ width: 200; height: delegateHeight
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#99FF99" }
+ GradientStop { position: 1.0; color: "#88FF88" }
+ }
+ y: listView.currentItem.y;
+ Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../images/flower.png"
+ color: "red"
+ clip: true
+ alpha: 1.0
+ }
+ }
+ }
+
+ ListView {
+ id: listView
+ width: 200; height: parent.height
+
+ model: petsModel
+ delegate: petDelegate
+ focus: true
+
+ // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem
+ // to false so the highlight delegate can control how the highlight is moved.
+ highlight: highlightBar
+ highlightFollowsCurrentItem: false
+
+ ParticleSystem { id: particles }
+ Emitter {
+ system: particles
+ anchors.fill: parent
+ emitRate: 1
+ lifeSpan: 10000
+ size: 24
+ sizeVariation: 8
+ speed: AngleDirection { angleVariation: 360; magnitude: 3 }
+ maximumEmitted: 10
+ startTime: 5000
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../images/flower.png"
+ alpha: 0.1
+ color: "white"
+ rotationVariation: 180
+ z: -1
+ }
+ }
+
+ ListModel {
+ id: petsModel
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+ }
+
+}
diff --git a/examples/qml/particles/imageparticle/sprites.qml b/examples/qml/particles/imageparticle/sprites.qml
new file mode 100644
index 0000000000..0fe4f31ea3
--- /dev/null
+++ b/examples/qml/particles/imageparticle/sprites.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "lightsteelblue"
+ width: 800
+ height: 800
+ id: root
+
+ SpriteImage {
+ sprites: Sprite {
+ name: "bear"
+ source: "../images/bear_tiles.png"
+ frames: 13
+ frameDuration: 120
+ }
+ width: 250
+ height: 250
+ x: 20
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 20
+ z:4
+ }
+
+ ParticleSystem { id: sys }
+
+ ImageParticle {
+ anchors.fill: parent
+ id: particles
+ system: sys
+ sprites: [Sprite {
+ name: "happy"
+ source: "../images/starfish_1.png"
+ frames: 1
+ frameDuration: 260
+ to: {"happy": 1, "silly": 1, "angry": 1}
+ }, Sprite {
+ name: "angry"
+ source: "../images/starfish_0.png"
+ frames: 1
+ frameDuration: 260
+ to: {"happy": 1, "silly": 1, "angry": 1}
+ }, Sprite {
+ name: "silly"
+ source: "../images/starfish_2.png"
+ frames: 1
+ frameDuration: 260
+ to: {"happy": 1, "silly": 1, "noticedbear": 0}
+ }, Sprite {
+ name: "noticedbear"
+ source: "../images/starfish_3.png"
+ frames: 1
+ frameDuration: 2600
+ }]
+ }
+
+ Emitter {
+ system: sys
+ emitRate: 2
+ lifeSpan: 10000
+ speed: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5}
+ acceleration: PointDirection { y: 10 }
+ size: 160
+ sizeVariation: 40
+ width: parent.width
+ height: 100
+ }
+
+ SpriteGoal {
+ system: sys
+ width: root.width;
+ height: root.height/2;
+ y: root.height/2;
+ goalState:"noticedbear"
+ }
+}
diff --git a/examples/qml/particles/images/_explo.png b/examples/qml/particles/images/_explo.png
new file mode 100644
index 0000000000..4297245d49
--- /dev/null
+++ b/examples/qml/particles/images/_explo.png
Binary files differ
diff --git a/examples/qml/particles/images/backgroundLeaves.jpg b/examples/qml/particles/images/backgroundLeaves.jpg
new file mode 100755
index 0000000000..08be16751d
--- /dev/null
+++ b/examples/qml/particles/images/backgroundLeaves.jpg
Binary files differ
diff --git a/examples/qml/particles/images/bear_tiles.png b/examples/qml/particles/images/bear_tiles.png
new file mode 100644
index 0000000000..6bbb2a9b6d
--- /dev/null
+++ b/examples/qml/particles/images/bear_tiles.png
Binary files differ
diff --git a/examples/qml/particles/images/candle.png b/examples/qml/particles/images/candle.png
new file mode 100644
index 0000000000..8fa3193719
--- /dev/null
+++ b/examples/qml/particles/images/candle.png
Binary files differ
diff --git a/examples/qml/particles/images/colortable.png b/examples/qml/particles/images/colortable.png
new file mode 100644
index 0000000000..a62ceeb4a0
--- /dev/null
+++ b/examples/qml/particles/images/colortable.png
Binary files differ
diff --git a/examples/qml/particles/images/finalfrontier.png b/examples/qml/particles/images/finalfrontier.png
new file mode 100644
index 0000000000..2ba1815230
--- /dev/null
+++ b/examples/qml/particles/images/finalfrontier.png
Binary files differ
diff --git a/examples/qml/particles/images/flower.png b/examples/qml/particles/images/flower.png
new file mode 100644
index 0000000000..b5c606210e
--- /dev/null
+++ b/examples/qml/particles/images/flower.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/allatonce.png b/examples/qml/particles/images/launcherIcons/allatonce.png
new file mode 100644
index 0000000000..b61d2d50d8
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/allatonce.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/attractor.png b/examples/qml/particles/images/launcherIcons/attractor.png
new file mode 100644
index 0000000000..4bd8040c3b
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/attractor.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/blurparticles.png b/examples/qml/particles/images/launcherIcons/blurparticles.png
new file mode 100644
index 0000000000..4337f979cb
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/blurparticles.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/close.png b/examples/qml/particles/images/launcherIcons/close.png
new file mode 100644
index 0000000000..c37714ee8f
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/close.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/colortable.png b/examples/qml/particles/images/launcherIcons/colortable.png
new file mode 100644
index 0000000000..8841ea30f9
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/colortable.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/customaffector.png b/examples/qml/particles/images/launcherIcons/customaffector.png
new file mode 100644
index 0000000000..d02e7918fa
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/customaffector.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/customemitter.png b/examples/qml/particles/images/launcherIcons/customemitter.png
new file mode 100644
index 0000000000..6d492573d1
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/customemitter.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/deformation.png b/examples/qml/particles/images/launcherIcons/deformation.png
new file mode 100644
index 0000000000..d1b722df01
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/deformation.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/delegates.png b/examples/qml/particles/images/launcherIcons/delegates.png
new file mode 100644
index 0000000000..929414cd0e
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/delegates.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/dynamicemitters.png b/examples/qml/particles/images/launcherIcons/dynamicemitters.png
new file mode 100644
index 0000000000..0cdef9d21e
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/dynamicemitters.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/emitmask.png b/examples/qml/particles/images/launcherIcons/emitmask.png
new file mode 100644
index 0000000000..e943a4adb9
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/emitmask.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/flickr.png b/examples/qml/particles/images/launcherIcons/flickr.png
new file mode 100644
index 0000000000..4de2650280
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/flickr.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/fragmentshader.png b/examples/qml/particles/images/launcherIcons/fragmentshader.png
new file mode 100644
index 0000000000..7c6de498d5
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/fragmentshader.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/gridsplosion.png b/examples/qml/particles/images/launcherIcons/gridsplosion.png
new file mode 100644
index 0000000000..ec75453df6
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/gridsplosion.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/groupgoal.png b/examples/qml/particles/images/launcherIcons/groupgoal.png
new file mode 100644
index 0000000000..69c6f64e54
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/groupgoal.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/imagecolors.png b/examples/qml/particles/images/launcherIcons/imagecolors.png
new file mode 100644
index 0000000000..0ff13a346e
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/imagecolors.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/list.png b/examples/qml/particles/images/launcherIcons/list.png
new file mode 100644
index 0000000000..bc13263cff
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/list.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/maximumemitted.png b/examples/qml/particles/images/launcherIcons/maximumemitted.png
new file mode 100644
index 0000000000..4ef0435991
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/maximumemitted.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/multiplepainters.png b/examples/qml/particles/images/launcherIcons/multiplepainters.png
new file mode 100644
index 0000000000..a28e3c4f02
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/multiplepainters.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/package.png b/examples/qml/particles/images/launcherIcons/package.png
new file mode 100644
index 0000000000..eba8951c26
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/package.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/particleview.png b/examples/qml/particles/images/launcherIcons/particleview.png
new file mode 100644
index 0000000000..a74f9a0340
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/particleview.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/plasmapatrol.png b/examples/qml/particles/images/launcherIcons/plasmapatrol.png
new file mode 100644
index 0000000000..fda852b420
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/plasmapatrol.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/remove.png b/examples/qml/particles/images/launcherIcons/remove.png
new file mode 100644
index 0000000000..c37714ee8f
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/remove.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/rotation.png b/examples/qml/particles/images/launcherIcons/rotation.png
new file mode 100644
index 0000000000..6a8dbea236
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/rotation.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/samegame.png b/examples/qml/particles/images/launcherIcons/samegame.png
new file mode 100644
index 0000000000..d00698264b
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/samegame.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/shapeanddirection.png b/examples/qml/particles/images/launcherIcons/shapeanddirection.png
new file mode 100644
index 0000000000..9c1f910d0c
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/shapeanddirection.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/spaceexplorer.png b/examples/qml/particles/images/launcherIcons/spaceexplorer.png
new file mode 100644
index 0000000000..770584a0fa
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/spaceexplorer.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/spritegoal.png b/examples/qml/particles/images/launcherIcons/spritegoal.png
new file mode 100644
index 0000000000..77480c6f09
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/spritegoal.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/sprites.png b/examples/qml/particles/images/launcherIcons/sprites.png
new file mode 100644
index 0000000000..144216ac7c
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/sprites.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/spritevariedparticles.png b/examples/qml/particles/images/launcherIcons/spritevariedparticles.png
new file mode 100644
index 0000000000..495bb6beee
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/spritevariedparticles.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/startstop.png b/examples/qml/particles/images/launcherIcons/startstop.png
new file mode 100644
index 0000000000..0ff53196a6
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/startstop.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/timedgroupchanges.png b/examples/qml/particles/images/launcherIcons/timedgroupchanges.png
new file mode 100644
index 0000000000..ec9f826495
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/timedgroupchanges.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/trailemitter.png b/examples/qml/particles/images/launcherIcons/trailemitter.png
new file mode 100644
index 0000000000..39acf8b40d
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/trailemitter.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/trails.png b/examples/qml/particles/images/launcherIcons/trails.png
new file mode 100644
index 0000000000..0337ebcfd8
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/trails.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/turbulence.png b/examples/qml/particles/images/launcherIcons/turbulence.png
new file mode 100644
index 0000000000..2b9446ea90
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/turbulence.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/velocityfrommotion.png b/examples/qml/particles/images/launcherIcons/velocityfrommotion.png
new file mode 100644
index 0000000000..79baa08293
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/velocityfrommotion.png
Binary files differ
diff --git a/examples/qml/particles/images/launcherIcons/wander.png b/examples/qml/particles/images/launcherIcons/wander.png
new file mode 100644
index 0000000000..d98e14b8ae
--- /dev/null
+++ b/examples/qml/particles/images/launcherIcons/wander.png
Binary files differ
diff --git a/examples/qml/particles/images/matchmask.png b/examples/qml/particles/images/matchmask.png
new file mode 100644
index 0000000000..e575875c55
--- /dev/null
+++ b/examples/qml/particles/images/matchmask.png
Binary files differ
diff --git a/examples/qml/particles/images/meteor.png b/examples/qml/particles/images/meteor.png
new file mode 100644
index 0000000000..e8c368aea7
--- /dev/null
+++ b/examples/qml/particles/images/meteor.png
Binary files differ
diff --git a/examples/qml/particles/images/meteor_explo.png b/examples/qml/particles/images/meteor_explo.png
new file mode 100644
index 0000000000..e659bfe2cf
--- /dev/null
+++ b/examples/qml/particles/images/meteor_explo.png
Binary files differ
diff --git a/examples/qml/particles/images/meteors.png b/examples/qml/particles/images/meteors.png
new file mode 100644
index 0000000000..bada8a1407
--- /dev/null
+++ b/examples/qml/particles/images/meteors.png
Binary files differ
diff --git a/examples/qml/particles/images/nullRock.png b/examples/qml/particles/images/nullRock.png
new file mode 100644
index 0000000000..4076327a1a
--- /dev/null
+++ b/examples/qml/particles/images/nullRock.png
Binary files differ
diff --git a/examples/qml/particles/images/particle.png b/examples/qml/particles/images/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/qml/particles/images/particle.png
Binary files differ
diff --git a/examples/qml/particles/images/particle2.png b/examples/qml/particles/images/particle2.png
new file mode 100644
index 0000000000..36349c6c6e
--- /dev/null
+++ b/examples/qml/particles/images/particle2.png
Binary files differ
diff --git a/examples/qml/particles/images/particle3.png b/examples/qml/particles/images/particle3.png
new file mode 100644
index 0000000000..905d8f37b8
--- /dev/null
+++ b/examples/qml/particles/images/particle3.png
Binary files differ
diff --git a/examples/qml/particles/images/particle4.png b/examples/qml/particles/images/particle4.png
new file mode 100644
index 0000000000..bc95b703c1
--- /dev/null
+++ b/examples/qml/particles/images/particle4.png
Binary files differ
diff --git a/examples/qml/particles/images/particleA.png b/examples/qml/particles/images/particleA.png
new file mode 100644
index 0000000000..c63acdee1f
--- /dev/null
+++ b/examples/qml/particles/images/particleA.png
Binary files differ
diff --git a/examples/qml/particles/images/portal_bg.png b/examples/qml/particles/images/portal_bg.png
new file mode 100644
index 0000000000..3c59eeabb9
--- /dev/null
+++ b/examples/qml/particles/images/portal_bg.png
Binary files differ
diff --git a/examples/qml/particles/images/realLeaf1.png b/examples/qml/particles/images/realLeaf1.png
new file mode 100644
index 0000000000..6cabf29efd
--- /dev/null
+++ b/examples/qml/particles/images/realLeaf1.png
Binary files differ
diff --git a/examples/qml/particles/images/realLeaf2.png b/examples/qml/particles/images/realLeaf2.png
new file mode 100644
index 0000000000..bfeca861d5
--- /dev/null
+++ b/examples/qml/particles/images/realLeaf2.png
Binary files differ
diff --git a/examples/qml/particles/images/realLeaf3.png b/examples/qml/particles/images/realLeaf3.png
new file mode 100644
index 0000000000..b1071e862b
--- /dev/null
+++ b/examples/qml/particles/images/realLeaf3.png
Binary files differ
diff --git a/examples/qml/particles/images/realLeaf4.png b/examples/qml/particles/images/realLeaf4.png
new file mode 100644
index 0000000000..d61d53d10e
--- /dev/null
+++ b/examples/qml/particles/images/realLeaf4.png
Binary files differ
diff --git a/examples/qml/particles/images/rocket.png b/examples/qml/particles/images/rocket.png
new file mode 100644
index 0000000000..a171610b03
--- /dev/null
+++ b/examples/qml/particles/images/rocket.png
Binary files differ
diff --git a/examples/qml/particles/images/rocket2.png b/examples/qml/particles/images/rocket2.png
new file mode 100644
index 0000000000..7110f8fdc6
--- /dev/null
+++ b/examples/qml/particles/images/rocket2.png
Binary files differ
diff --git a/examples/qml/particles/images/sizeInOut.png b/examples/qml/particles/images/sizeInOut.png
new file mode 100644
index 0000000000..0a306ea21a
--- /dev/null
+++ b/examples/qml/particles/images/sizeInOut.png
Binary files differ
diff --git a/examples/qml/particles/images/snowflake.png b/examples/qml/particles/images/snowflake.png
new file mode 100644
index 0000000000..490887a82f
--- /dev/null
+++ b/examples/qml/particles/images/snowflake.png
Binary files differ
diff --git a/examples/qml/particles/images/sparkleSize.png b/examples/qml/particles/images/sparkleSize.png
new file mode 100644
index 0000000000..752056541b
--- /dev/null
+++ b/examples/qml/particles/images/sparkleSize.png
Binary files differ
diff --git a/examples/qml/particles/images/star.png b/examples/qml/particles/images/star.png
new file mode 100644
index 0000000000..0d592cfa87
--- /dev/null
+++ b/examples/qml/particles/images/star.png
Binary files differ
diff --git a/examples/qml/particles/images/starfish_0.png b/examples/qml/particles/images/starfish_0.png
new file mode 100644
index 0000000000..8747f0236e
--- /dev/null
+++ b/examples/qml/particles/images/starfish_0.png
Binary files differ
diff --git a/examples/qml/particles/images/starfish_1.png b/examples/qml/particles/images/starfish_1.png
new file mode 100644
index 0000000000..1f3f159d5e
--- /dev/null
+++ b/examples/qml/particles/images/starfish_1.png
Binary files differ
diff --git a/examples/qml/particles/images/starfish_2.png b/examples/qml/particles/images/starfish_2.png
new file mode 100644
index 0000000000..c6c7e5a676
--- /dev/null
+++ b/examples/qml/particles/images/starfish_2.png
Binary files differ
diff --git a/examples/qml/particles/images/starfish_3.png b/examples/qml/particles/images/starfish_3.png
new file mode 100644
index 0000000000..307a89f815
--- /dev/null
+++ b/examples/qml/particles/images/starfish_3.png
Binary files differ
diff --git a/examples/qml/particles/images/starfish_4.png b/examples/qml/particles/images/starfish_4.png
new file mode 100644
index 0000000000..d61c26545a
--- /dev/null
+++ b/examples/qml/particles/images/starfish_4.png
Binary files differ
diff --git a/examples/qml/particles/images/starfish_mask.png b/examples/qml/particles/images/starfish_mask.png
new file mode 100644
index 0000000000..2ef74f902b
--- /dev/null
+++ b/examples/qml/particles/images/starfish_mask.png
Binary files differ
diff --git a/examples/qml/particles/itemparticle/content/Delegate.qml b/examples/qml/particles/itemparticle/content/Delegate.qml
new file mode 100644
index 0000000000..97c7840cb4
--- /dev/null
+++ b/examples/qml/particles/itemparticle/content/Delegate.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+Package {
+ Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' }
+ Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' }
+
+ Rectangle {
+ id: wrapper
+ width: 200; height: 25
+ color: 'lightsteelblue'
+
+ Text { text: display; anchors.centerIn: parent }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (wrapper.state == 'inList')
+ wrapper.state = 'inGrid';
+ else
+ wrapper.state = 'inList';
+ }
+ }
+
+ state: 'inList'
+ states: [
+ State {
+ name: 'inList'
+ ParentChange { target: wrapper; parent: listDelegate }
+ },
+ State {
+ name: 'inGrid'
+ ParentChange {
+ target: wrapper; parent: gridDelegate
+ x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/qml/particles/itemparticle/content/Delegate2.qml b/examples/qml/particles/itemparticle/content/Delegate2.qml
new file mode 100644
index 0000000000..cf60d43dc2
--- /dev/null
+++ b/examples/qml/particles/itemparticle/content/Delegate2.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+Package {
+ Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' }
+ Item { id: particleDelegate; width: w; height: h; Package.name: 'particles'
+
+ Rectangle {
+ id: wrapper
+ width: w; height: h;
+ color: col
+ rotation: Math.random()*360
+ Behavior on rotation {RotationAnimation {}}
+
+ states: State {
+ name: "gridded"
+ when: root.inGrid
+ PropertyChanges {
+ target: wrapper
+ rotation: 0
+ }
+ ParentChange {
+ target: wrapper
+ parent: gridDelegate
+ x:0
+ y:0
+ }
+ }
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+ }
+}
+//![0]
diff --git a/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml b/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml
new file mode 100644
index 0000000000..87f723d3f7
--- /dev/null
+++ b/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../../modelviews/listview/content"
+
+// This example illustrates expanding a list item to show a more detailed view.
+
+ // Delegate for the recipes. This delegate has two modes:
+ // 1. List mode (default), which just shows the picture and title of the recipe.
+ // 2. Details mode, which also shows the ingredients and method.
+ Component {
+ id: recipeDelegate
+
+ Item {
+ id: recipe
+
+ // Create a property to contain the visibility of the details.
+ // We can bind multiple element's opacity to this one property,
+ // rather than having a "PropertyChanges" line for each element we
+ // want to fade.
+ property real detailsOpacity : 0
+
+ //this bit changed for aesthetics
+ width: 70
+ height: 70
+ // A simple rounded rectangle for the background
+ Rectangle {
+ id: background
+ x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
+ color: "ivory"
+ border.color: "orange"
+ radius: 5
+ }
+ Image {
+ anchors.fill:parent
+ anchors.margins: -32
+ source: "bubble.png"
+ }
+
+
+ // This mouse region covers the entire delegate.
+ // When clicked it changes mode to 'Details'. If we are already
+ // in Details mode, then no change will happen.
+ MouseArea {
+ anchors.fill: parent
+ onClicked: recipe.state = 'Details';
+ }
+
+ // Lay out the page: picture, title and ingredients at the top, and method at the
+ // bottom. Note that elements that should not be visible in the list
+ // mode have their opacity set to recipe.detailsOpacity.
+ Row {
+ id: topLayout
+ x: 10; y: 10; height: recipeImage.height; width: parent.width
+ spacing: 10
+
+ Image {
+ id: recipeImage
+ width: 50; height: 50
+ source: "../../modelviews/listview/" + picture
+ }
+
+ Column {
+ width: background.width - recipeImage.width - 20; height: recipeImage.height
+ spacing: 5
+
+ Text {
+ text: title
+ font.bold: true; font.pointSize: 16
+ }
+
+ Text {
+ text: "Ingredients"
+ font.pointSize: 12; font.bold: true
+ opacity: recipe.detailsOpacity
+ }
+
+ Text {
+ text: ingredients
+ wrapMode: Text.WordWrap
+ width: parent.width
+ opacity: recipe.detailsOpacity
+ }
+ }
+ }
+
+ Item {
+ id: details
+ x: 10; width: parent.width - 20
+ anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 }
+ opacity: recipe.detailsOpacity
+
+ Text {
+ id: methodTitle
+ anchors.top: parent.top
+ text: "Method"
+ font.pointSize: 12; font.bold: true
+ }
+
+ Flickable {
+ id: flick
+ width: parent.width
+ anchors { top: methodTitle.bottom; bottom: parent.bottom }
+ contentHeight: methodText.height
+ clip: true
+
+ Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width }
+ }
+
+ Image {
+ anchors { right: flick.right; top: flick.top }
+ source: "../../modelviews/listview/" + "content/pics/moreUp.png"
+ opacity: flick.atYBeginning ? 0 : 1
+ }
+
+ Image {
+ anchors { right: flick.right; bottom: flick.bottom }
+ source: "../../modelviews/listview/" + "content/pics/moreDown.png"
+ opacity: flick.atYEnd ? 0 : 1
+ }
+ }
+
+ // A button to close the detailed view, i.e. set the state back to default ('').
+ TextButton {
+ y: 10
+ anchors { right: background.right; rightMargin: 10 }
+ opacity: recipe.detailsOpacity
+ text: "Close"
+
+ onClicked: recipe.state = '';
+ }
+
+ states: State {
+ name: "Details"
+
+ PropertyChanges { target: background; color: "white" }
+ PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger
+ PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible
+ PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view
+
+ // Move the list so that this item is at the top.
+ //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y }
+
+ // Disallow flicking while we're in detailed view
+ //PropertyChanges { target: recipe.ListView.view; interactive: false }
+ }
+
+ transitions: Transition {
+ //The only strictly necessary particle specific lines
+ to: "Details"
+ reversible: true
+ ScriptAction {script: {
+ if(state == "Details")
+ mp.freeze(index);
+ else
+ mp.unfreeze(index);
+ }
+ }
+ // Make the state changes smooth
+ ParallelAnimation {
+ ColorAnimation { property: "color"; duration: 500 }
+ NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" }
+ }
+ }
+ }
+ }
diff --git a/examples/qml/particles/itemparticle/content/RssModel.qml b/examples/qml/particles/itemparticle/content/RssModel.qml
new file mode 100644
index 0000000000..46027600b3
--- /dev/null
+++ b/examples/qml/particles/itemparticle/content/RssModel.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ property string tags : ""
+
+ function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "content"; query: "content/string()" }
+ XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" }
+}
diff --git a/examples/qml/particles/itemparticle/content/bubble.png b/examples/qml/particles/itemparticle/content/bubble.png
new file mode 100644
index 0000000000..c7f479e9e3
--- /dev/null
+++ b/examples/qml/particles/itemparticle/content/bubble.png
Binary files differ
diff --git a/examples/qml/particles/itemparticle/content/script.js b/examples/qml/particles/itemparticle/content/script.js
new file mode 100644
index 0000000000..e8ef93a847
--- /dev/null
+++ b/examples/qml/particles/itemparticle/content/script.js
@@ -0,0 +1,27 @@
+.pragma library
+
+function getWidth(string) {
+ return (string.match(/width=\"([0-9]+)\"/))[1]
+}
+
+function getHeight(string) {
+ return (string.match(/height=\"([0-9]+)\"/))[1]
+}
+
+function getImagePath(string) {
+ var pattern = /src=\"http:\/\/(\S+)\"/
+ return (string.match(pattern))[1]
+}
+
+function calculateScale(width, height, cellSize) {
+ var widthScale = (cellSize * 1.0) / width
+ var heightScale = (cellSize * 1.0) / height
+ var scale = 0
+
+ if (widthScale <= heightScale) {
+ scale = widthScale;
+ } else if (heightScale < widthScale) {
+ scale = heightScale;
+ }
+ return scale;
+}
diff --git a/examples/qml/particles/itemparticle/delegates.qml b/examples/qml/particles/itemparticle/delegates.qml
new file mode 100644
index 0000000000..58734d320a
--- /dev/null
+++ b/examples/qml/particles/itemparticle/delegates.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root;
+ width: 360
+ height: 600
+ color: "black"
+
+ function newPithySaying() {
+ switch (Math.floor(Math.random()*16)) {
+ case 0: return "Hello World";
+ case 1: return "G'day Mate";
+ case 2: return "Code Less";
+ case 3: return "Create More";
+ case 4: return "Deploy Everywhere";
+ case 5: return "Qt Meta-object Language";
+ case 6: return "Qt Magic Language";
+ case 7: return "Fluid UIs";
+ case 8: return "Touchable";
+ case 9: return "How's it going?";
+ case 10: return "Do you like text?";
+ case 11: return "Enjoy!";
+ case 12: return "ERROR: Out of pith";
+ case 13: return "Punctuation Failure";
+ case 14: return "I can go faster";
+ case 15: return "I can go slower";
+ default: return "OMGWTFBBQ";
+ }
+ }
+
+ ParticleSystem {
+ anchors.fill: parent
+ id: syssy
+ Emitter {
+ anchors.centerIn: parent
+ emitRate: 1
+ lifeSpan: 4800
+ lifeSpanVariation: 1600
+ speed: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20}
+ }
+ ItemParticle {
+ delegate: Text {
+ text: root.newPithySaying();
+ color: "white"
+ font.pixelSize: 18
+ font.bold: true
+ }
+ }
+ }
+}
diff --git a/examples/qml/particles/itemparticle/particleview.qml b/examples/qml/particles/itemparticle/particleview.qml
new file mode 100644
index 0000000000..774539a958
--- /dev/null
+++ b/examples/qml/particles/itemparticle/particleview.qml
@@ -0,0 +1,274 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content/script.js" as Script
+import "content"
+
+Item {
+ id: root
+ width: 640
+ height: 480
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ z: -1
+ }
+ Item {
+ id: loading
+ Behavior on opacity {NumberAnimation {}}
+ anchors.fill: parent
+ Text {
+ anchors.centerIn: parent
+ text: "Loading"
+ color: "white"
+ }
+ }
+ ParticleSystem {
+ id: sys;
+ running: true
+ }
+ Emitter {
+ id: emitter
+ system: sys
+ height: parent.height - 132/2
+ x: -132/2
+ y: 132/2
+ speed: PointDirection { x: 32; xVariation: 8 }
+ emitRate: 0.5
+ lifeSpan: Emitter.InfiniteLife
+ group: "photos"
+ }
+ Age {
+ system: sys
+ x: parent.width + 132/2
+ height: parent.height
+ width: 1000
+ }
+ ImageParticle {
+ system: sys
+ groups: ["fireworks"]
+ source: "../trails/../images/star.png"
+ color: "lightsteelblue"
+ alpha: 0
+ colorVariation: 0
+ z: 1000
+ }
+ ItemParticle {
+ id: mp
+ z: 0
+ system: sys
+ fade: false
+ groups: ["photos"]
+ }
+ Component {
+ id: alertDelegate
+ Rectangle {
+ width: 132
+ height: 132
+ NumberAnimation on scale {
+ running: true
+ loops: 1
+ from: 0.2
+ to: 1
+ }
+ Image {
+ source: "../asteroid/../images/rocket.png"
+ anchors.centerIn: parent
+ }
+ Text {
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "A new ship has arrived!"
+ }
+ }
+ }
+ property Item alertItem;
+ function alert() {
+ //resetter.active = false
+ force.active = true;
+ alertItem = alertDelegate.createObject(root);
+ alertItem.x = root.width/2 - alertItem.width/2
+ alertItem.y = root.height/2 - alertItem.height/2
+ spawnFireworks.pulse(200);
+ stopAlert.start();
+ }
+ focus: true
+ Keys.onSpacePressed: alert();
+ Timer {
+ id: stopAlert
+ running: false
+ repeat: false
+ interval: 800
+ onTriggered: {
+ force.active = false
+ //resetter.active = true;
+ mp.take(alertItem, true);
+ centerEmitter.burst(1);
+ }
+ }
+ Attractor {
+ id: force
+ system: sys
+ pointX: root.width/2
+ pointY: root.height/2
+ strength: -10000
+ enabled: false
+ anchors.centerIn: parent
+ width: parent.width/2
+ height: parent.height/2
+ groups:["photos"]
+ affectedParameter: Attractor.Position
+ }
+ Emitter {
+ id: centerEmitter
+ speed: PointDirection { x: 32; xVariation: 8;}
+ emitRate: 0.5
+ lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
+ maximumEmitted: 20
+ group: "photos"
+ system: sys
+ anchors.centerIn: parent
+ enabled: false
+
+ //TODO: Zoom in effect
+ }
+ Emitter {
+ id: spawnFireworks
+ group: "fireworks"
+ system: sys
+ maximumEmitted: 400
+ emitRate: 400
+ lifeSpan: 2800
+ x: parent.width/2
+ y: parent.height/2 - 64
+ width: 8
+ height: 8
+ enabled: false
+ size: 32
+ endSize: 8
+ speed: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
+ acceleration: PointDirection { y: 160 }
+ }
+ Item { x: -1000; y: -1000 //offscreen
+ Repeater {//Load them here, add to system on completed
+ model: theModel
+ delegate: theDelegate
+ }
+ }
+ RssModel {id: theModel; tags:"particle,particles"}
+ Component {
+ id: theDelegate
+ Rectangle {
+ id: container
+ border.width: 2
+ property real myRand: Math.random();//'depth'
+ z: Math.floor(myRand * 100)
+ scale: (myRand + 1.0)/2;
+ //TODO: Darken based on 'depth'
+ width: 132
+ height: 132
+ //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity);
+ ItemParticle.onDetached: mp.take(container);//respawns
+ function manage()
+ {
+ if (state == "selected") {
+ console.log("Taking " + index);
+ mp.freeze(container);
+ } else {
+ console.log("Returning " +index);
+ mp.unfreeze(container);
+ }
+ }
+ Image {
+ id: img
+ anchors.centerIn: parent
+ smooth: true; source: "http://" + Script.getImagePath(content); cache: true
+ fillMode: Image.PreserveAspectFit;
+ width: parent.width-4; height: parent.height-4
+ onStatusChanged: if (img.status == Image.Ready) {
+ loading.opacity = 0;
+ mp.take(container);
+ }
+ }
+ Text {
+ anchors.bottom: parent.bottom
+ width: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ elide: Text.ElideRight
+ text: title
+ color: "black"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.state == "selected" ? container.state = "" : container.state = "selected"
+ }
+ states: State {
+ name: "selected"
+ ParentChange {
+ target: container
+ parent: root
+ x: 0
+ y: 0
+ }
+ PropertyChanges {
+ target: container
+ width: root.width
+ height: root.height
+ z: 101
+ opacity: 1
+ rotation: 0
+ }
+ }
+ transitions: Transition {
+ to: "selected"
+ reversible: true
+ SequentialAnimation {
+ ScriptAction {script: container.manage();}
+ ParallelAnimation {
+ ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly
+ NumberAnimation { properties: "width, height, z, rotation" }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject b/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject
new file mode 100644
index 0000000000..548295243d
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject
@@ -0,0 +1,19 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "plasmapatrol.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ Files {
+ paths: ["TODO"]
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/TODO b/examples/qml/particles/plasmapatrol/TODO
new file mode 100644
index 0000000000..ef9d21a73d
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/TODO
@@ -0,0 +1,10 @@
+Realistic Tasks:
+Particle explosions on ship death.
+Better help text (both content and styled a little nicer).
+Hardpoint help showing them firing across the screen.
+Endless Demo Mode
+
+Nice-but-i-doubt-it-will-get-done Tasks:
+Particle Text for the winner.
+Particle-based buttons.
+Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish').
diff --git a/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml b/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml
new file mode 100644
index 0000000000..10c50d43c8
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property Item targetObj: container
+ property Item hardpoint: container
+ property ParticleSystem system
+ property int blasts: 16
+ property int bonusBlasts: 12
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter {
+ id: visualization
+ group: "blaster"
+ system: container.system
+ enabled: show
+ anchors.fill: parent
+ shape: EllipseShape {}
+ speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true}
+ lifeSpan: 1000
+ emitRate: 64
+
+ size: 24
+ sizeVariation: 24
+ endSize: 0
+ }
+
+ property int blastsLeft: 0
+ function fireAt(targetArg, container) {
+ target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2);
+ targetObj = targetArg;
+ hardpoint = container;
+ blastsLeft = blasts;
+ rofTimer.repeat = true;
+ rofTimer.start();
+ }
+ Timer {
+ id: rofTimer
+ interval: 30;//Has to be greater than 1 frame or they stack up
+ running: false
+ repeat: false
+ onTriggered: {
+ if (targetObj.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var hit;
+ if (blastsLeft >= bonusBlasts)
+ hit = Math.random() > targetObj.dodge;
+ else
+ hit = false; //purely aesthetic shots, because the damage isn't that fine grained
+ if (hit == true) {
+ switch (targetObj.shipType) {
+ case 1: hardpoint.damageDealt += 4; break;
+ case 2: hardpoint.damageDealt += 5; break;
+ case 3: hardpoint.damageDealt += 1; break;
+ default: hardpoint.damageDealt += 100;
+ }
+ }
+ blastVector.targetX = target.x;
+ blastVector.targetY = target.y;
+ if (!hit) {//TODO: Actual targetVariation
+ blastVector.targetX += (128 * Math.random() - 64);
+ blastVector.targetY += (128 * Math.random() - 64);
+ }
+ emitter.burst(1);
+ blastsLeft--;
+ if (!blastsLeft)
+ rofTimer.repeat = false;
+ }
+ }
+ Emitter {
+ id: emitter
+ group: "blaster"
+ enabled: false
+ system: container.system
+ anchors.centerIn: parent
+
+ lifeSpan: 1000
+ emitRate: 16
+ maximumEmitted: blasts
+ size: 24
+ endSize:16
+ sizeVariation: 8
+ speed: TargetDirection {
+ id: blastVector
+ targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
+ }
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/Button.qml b/examples/qml/particles/plasmapatrol/content/Button.qml
new file mode 100644
index 0000000000..992be295fc
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/Button.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+//TODO: Add particles to this component too
+Rectangle {
+ id: container
+ property alias text: txt.text
+ signal clicked
+ //color: "lightsteelblue"
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightsteelblue" }
+ GradientStop { position: 1.0; color: "steelblue" }
+ }
+ height: 64
+ radius: 16
+ width: 128
+ Text {
+ id: txt
+ anchors.centerIn: parent
+ font.pixelSize: 24
+ color: "white"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked()
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml b/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml
new file mode 100644
index 0000000000..48eb9d171a
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter {
+ id: visualization
+ group: "cannon"
+ enabled: container.show
+ system: container.system
+ anchors.centerIn: parent
+ lifeSpan: 2000
+ emitRate: 1
+
+ size: 4
+ endSize: 0
+ }
+
+ function fireAt(targetArg, hardpoint) {
+ target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2);
+ if (container.hp <= 0 || targetArg.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var hit = Math.random() > targetArg.dodge
+ if (hit) {
+ switch (targetArg.shipType) {
+ case 1: hardpoint.damageDealt += 8; break;
+ case 2: hardpoint.damageDealt += 10; break;
+ case 3: hardpoint.damageDealt += 16; break;
+ default: hardpoint.damageDealt += 1000;
+ }
+ }
+ emitter.burst(1);
+ }
+ Emitter {
+ id: emitter
+ group: "cannon"
+ enabled: false
+ system: container.system
+ anchors.centerIn: parent
+
+ lifeSpan: 1000
+ emitRate: 1
+ size: 8
+ endSize: 4
+ speed: TargetDirection {
+ id: blastVector
+ targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
+ }
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml b/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml
new file mode 100644
index 0000000000..6e21101f2e
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ width: 360
+ height: 160
+ property ParticleSystem system
+ Ship {
+ id: nully
+ system: system
+ }
+ property Item target: nully
+ /*
+ Component.onCompleted: {
+ container.target.shipType = 1
+ container.target.gunType = 1
+ }
+ */
+ Row {
+ anchors.horizontalCenter: parent.horizontalCenter
+ height: parent.height
+ spacing: 8
+ Button {
+ width: 80
+ height: 80
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Cycle\nShip"
+ onClicked: {
+ var nextVal = container.target.shipType;
+ if(nextVal == 3)
+ nextVal = 1;
+ else
+ nextVal++;
+ container.target.shipType = nextVal;
+ }
+ }
+ Item {
+ width: 128
+ height: 128
+ anchors.verticalCenter: parent.verticalCenter
+ Ship {
+ hp: 20
+ anchors.centerIn: parent
+ shipType: container.target.shipType
+ gunType: container.target.gunType
+ system: container.system
+ }
+ }
+ Button {
+ width: 80
+ height: 80
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Cycle\nGun"
+ onClicked: {
+ var nextVal = container.target.gunType;
+ if(nextVal == 3)
+ nextVal = 1;
+ else
+ nextVal++;
+ container.target.gunType = nextVal;
+ }
+ }
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/Cruiser.qml b/examples/qml/particles/plasmapatrol/content/Cruiser.qml
new file mode 100644
index 0000000000..c469eb46d2
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/Cruiser.qml
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.01
+ property real dodge: initialDodge
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter {
+ //TODO: Cooler would be an 'orbiting' affector
+ //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles
+ system: container.system
+ group: container.shipParticle
+ anchors.centerIn: parent
+ width: 64
+ height: 64
+ shape: EllipseShape {}
+
+ emitRate: hp > 0 ? hp * 1 + 20 : 0
+ lifeSpan: 2400
+ maximumEmitted: (maxHP * 1 + 20)*2.4
+
+ size: 48
+ sizeVariation: 16
+ endSize: 16
+
+ speed: AngleDirection {angleVariation:360; magnitudeVariation: 32}
+ }
+ Emitter {
+ system: container.system
+ group: "cruiserArmor"
+ anchors.fill: parent
+ shape: EllipseShape { fill: false }
+ enabled: hp>0
+
+ emitRate: 16
+ lifeSpan: 2000
+
+ size: 48
+ sizeVariation: 24
+
+ SpriteGoal {
+ id: destructor
+ system: container.system
+ enabled: container.hp <=0
+ anchors.fill: parent
+ groups: ["cruiserArmor"]
+ goalState: "death"
+// jump: true
+ once: true
+ }
+ }
+
+ Timer {
+ id: fireControl
+ property int next: Math.floor(Math.random() * 3) + 1
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered: {
+ if (next == 1) {
+ gun1.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ } else if (next == 2) {
+ gun2.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ } else if (next == 3) {
+ gun3.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ }
+ }
+ }
+
+ Hardpoint {//TODO: Hardpoint abstraction
+ x: 112 - 12 - 8*2
+ y: 128 - 12 - 12*2
+ id: gun1
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint {
+ x: 64 - 12
+ y: 0 - 12 + 12*2
+ id: gun2
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint {
+ x: 16 - 12 + 8*2
+ y: 128 - 12 - 12*2
+ id: gun3
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/Frigate.qml b/examples/qml/particles/plasmapatrol/content/Frigate.qml
new file mode 100644
index 0000000000..92c63b87d1
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/Frigate.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.2
+ property real dodge: initialDodge
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter {
+ system: container.system
+ group: "frigateShield"
+ anchors.centerIn: parent
+ size: 92
+ emitRate: 1
+ lifeSpan: 4800
+ enabled: hp > 0
+ }
+ Emitter {
+ system: container.system
+ group: container.shipParticle
+ anchors.centerIn: parent
+ width: 64
+ height: 16
+ shape: EllipseShape {}
+
+ size: 16
+ sizeVariation: 8
+ endSize: 8
+ emitRate: hp > 0 ? hp * 1 + 20 : 0
+ lifeSpan: 1200
+ maximumEmitted: (maxHP * 1 + 20)*2
+ }
+ Timer {
+ id: fireControl
+ property int next: Math.floor(Math.random() * 2) + 1
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered: {
+ if (next == 1) {
+ gun1.fireAt(container.target);
+ next = Math.floor(Math.random() * 2) + 1;
+ } else if (next == 2) {
+ gun2.fireAt(container.target);
+ next = Math.floor(Math.random() * 2) + 1;
+ }
+ }
+ }
+
+ Hardpoint {
+ x: 128 - 32 - 12
+ y: 64 - 12
+ id: gun1
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint {
+ x: 0 + 32 - 12
+ y: 64 - 12
+ id: gun2
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/Hardpoint.qml b/examples/qml/particles/plasmapatrol/content/Hardpoint.qml
new file mode 100644
index 0000000000..9e6057057d
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/Hardpoint.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ //ReflectiveProperties
+ //TransferredProperties
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+ property int hardpointType: 0 //default is pea shooter - always bad.
+
+ property Item targetObj: null
+ property int damageDealt: 0
+ onDamageDealtChanged: dealDamageTimer.start();
+ Timer {
+ id: dealDamageTimer
+ interval: 16
+ running: false
+ repeat: false
+ onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;}
+ }
+ width: 24
+ height: 24
+ function fireAt(targetArg) {//Each implement own
+ if (targetArg != null) {
+ hardpointLoader.item.fireAt(targetArg, container);
+ targetObj = targetArg;
+ }
+ }
+ Loader {
+ id: hardpointLoader
+ sourceComponent: {
+ switch (hardpointType) {
+ case 1: laserComponent; break;
+ case 2: blasterComponent; break;
+ case 3: cannonComponent; break;
+ default: emptyComponent;
+ }
+ }
+ }
+ Component {
+ id: laserComponent
+ LaserHardpoint {
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component {
+ id: blasterComponent
+ BlasterHardpoint {
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component {
+ id: cannonComponent
+ CannonHardpoint {
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component {
+ id: emptyComponent
+ Item {
+ function fireAt(obj) {
+ console.log("Firing null weapon. It hurts.");
+ }
+ }
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/HelpScreens.qml b/examples/qml/particles/plasmapatrol/content/HelpScreens.qml
new file mode 100644
index 0000000000..db70c6ee90
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/HelpScreens.qml
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+SequentialLoader {
+ id: hLdr
+ signal exitDesired
+ Component.onCompleted: advance();
+ ParticleSystem { id: helpSystem }
+ PlasmaPatrolParticles { sys: helpSystem }
+ pages: [
+ Component {Item {
+ id: story
+ Text {
+ color: "white"
+ text: "Story"
+ font.pixelSize: 48
+ }
+ /*
+ Flickable {
+ y: 60
+ width: 360
+ height: 500
+ contentHeight: txt1.height
+ contentWidth: 360//TODO: Less magic numbers?
+ */
+ Text {
+ id: txt1
+ color: "white"
+ y: 60
+ font.pixelSize: 18
+ text: "
+In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths.
+
+You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat!
+ "
+ width: 360
+ wrapMode: Text.WordWrap
+ }
+ // }
+ Button {
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button {
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component {Item {
+ id: ships
+ Text {
+ color: "white"
+ text: "Vessels"
+ font.pixelSize: 48
+ }
+ Column {
+ spacing: 16
+ y: 60
+ Row {
+ height: 128
+ Sloop {
+ system: helpSystem
+ }
+ Text {
+ text: "The nimble sloop"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row {
+ height: 128
+ Frigate {
+ system: helpSystem
+ }
+ Text {
+ text: "The versitile shield frigate"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row {
+ height: 128
+ Cruiser {
+ system: helpSystem
+ }
+ Text {
+ text: "The armored cruiser"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ }
+ Button {
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button {
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component {Item {
+ id: guns
+ Text {
+ color: "white"
+ text: "Hardpoints"
+ font.pixelSize: 48
+ }
+ Column {
+ spacing: 16
+ y: 60
+ Row {
+ height: 128
+ LaserHardpoint {
+ system: helpSystem
+ }
+ Text {
+ text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row {
+ height: 128
+ BlasterHardpoint {
+ system: helpSystem
+ }
+ Text {
+ text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row {
+ height: 128
+ CannonHardpoint {
+ system: helpSystem
+ }
+ Text {
+ text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ }
+ Button {
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button {
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component {Item {
+ id: strategy
+ Text {
+ color: "white"
+ text: "Strategy"
+ font.pixelSize: 48
+ }
+ Flickable {
+ y: 60
+ width: 360
+ height: 500
+ contentHeight: txt1.height
+ contentWidth: 360//TODO: Less magic numbers?
+ Text {
+ id: txt1
+ color: "white"
+ font.pixelSize: 18
+ text: "
+Basic Strategy: Good luck, have fun - don't die.
+More to come after thorough playtesting.
+ "
+ width: 360
+ wrapMode: Text.WordWrap
+ }
+ }
+ Button {
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Story"
+ onClicked: {hLdr.at=0; hLdr.advance();}
+ }
+ Button {
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }}
+ ]
+}
diff --git a/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml b/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml
new file mode 100644
index 0000000000..a7baed604b
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter {
+ id: visualization
+ group: "laser"
+ system: container.system
+ anchors.fill: parent
+ enabled: container.show
+ shape: EllipseShape {}
+ speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true }
+ lifeSpan: 1000
+ emitRate: 64
+
+ size: 24
+ sizeVariation: 8
+ endSize: 8
+ }
+
+ function fireAt(targetArg, hardpoint) {
+ if (targetArg.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var offset = 0;
+ if (Math.random() < 0.99) {
+ switch (targetArg.shipType) {
+ case 1: hardpoint.damageDealt += 16; break;
+ case 2: hardpoint.damageDealt += 4; break;
+ case 3: hardpoint.damageDealt += 8; break;
+ default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels
+ }
+ } else {//Misses with Lasers are really rare
+ offset = Math.random() * 100;
+ }
+ target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2);
+ emitter.pulse(100);
+ // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y)));
+ }
+ Emitter {
+ id: emitter
+ group: "laser"
+ enabled: false
+ system: container.system
+ x: Math.min(container.width/2, target.x);
+ width: Math.max(container.width/2, target.x) - x;
+ y: Math.min(container.height/2, target.y);
+ height: Math.max(container.height/2, target.y) - y;
+ shape: LineShape {
+ mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR
+ }
+
+ lifeSpan: 1000
+ emitRate: 8000
+ maximumEmitted: 800
+ size: 16
+ endSize: 0
+
+ speed: PointDirection {xVariation: 4; yVariation: 4}
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml
new file mode 100644
index 0000000000..87809965b2
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ property ParticleSystem sys
+ ImageParticle {
+ system: sys
+ groups: ["default"]
+ source: "pics/blur-circle3.png"
+ color: "#003A3A3A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle {
+ system: sys
+ groups: ["redTeam"]
+ source: "pics/blur-circle3.png"
+ color: "#0028060A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle {
+ system: sys
+ groups: ["greenTeam"]
+ source: "pics/blur-circle3.png"
+ color: "#0006280A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle {
+ system: sys
+ groups: ["blaster"]
+ source: "pics/star2.png"
+ //color: "#0F282406"
+ color: "#0F484416"
+ colorVariation: 0.2
+ z: 2
+ }
+ ImageParticle {
+ system: sys
+ groups: ["laser"]
+ source: "pics/star3.png"
+ //color: "#00123F68"
+ color: "#00428FF8"
+ colorVariation: 0.2
+ z: 2
+ }
+ ImageParticle {
+ system: sys
+ groups: ["cannon"]
+ source: "pics/particle.png"
+ color: "#80FFAAFF"
+ colorVariation: 0.1
+ z: 2
+ }
+ ImageParticle {
+ system: sys
+ groups: ["cannonCore"]
+ source: "pics/particle.png"
+ color: "#00666666"
+ colorVariation: 0.8
+ z: 1
+ }
+ ImageParticle {
+ system: sys
+ groups: ["cannonWake"]
+ source: "pics/star.png"
+ color: "#00CCCCCC"
+ colorVariation: 0.2
+ z: 1
+ }
+ ImageParticle {
+ system: sys
+ groups: ["frigateShield"]
+ source: "pics/blur-circle2.png"
+ color: "#00000000"
+ colorVariation: 0.05
+ blueVariation: 0.5
+ greenVariation: 0.1
+ z: 3
+ }
+ ImageParticle {
+ system: sys
+ groups: ["cruiserArmor"]
+ z: 1
+ sprites:[Sprite {
+ id: spinState
+ name: "spinning"
+ source: "pics/meteor.png"
+ frames: 35
+ frameDuration: 40
+ to: {"death":0, "spinning":1}
+ },Sprite {
+ name: "death"
+ source: "pics/meteor_explo.png"
+ frames: 22
+ frameDuration: 40
+ to: {"null":1}
+ }, Sprite {
+ name: "null"
+ source: "pics/nullRock.png"
+ frames: 1
+ frameDuration: 1000
+ }
+ ]
+ }
+ TrailEmitter {
+ system: sys
+ group: "cannonWake"
+ follow: "cannon"
+ emitRatePerParticle: 64
+ lifeSpan: 600
+ speed: AngleDirection { angleVariation: 360; magnitude: 48}
+ size: 16
+ endSize: 8
+ sizeVariation: 2
+ enabled: true
+ width: 1000//XXX: Terrible hack
+ height: 1000
+ }
+ TrailEmitter {
+ system: sys
+ group: "cannonCore"
+ follow: "cannon"
+ emitRatePerParticle: 256
+ lifeSpan: 128
+ size: 24
+ endSize: 8
+ enabled: true
+ width: 1000//XXX: Terrible hack
+ height: 1000
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml b/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml
new file mode 100644
index 0000000000..3707759ce3
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ id: container
+ //TODO: Somehow get particles into this?
+ property list<Component> pages
+ property Item cur: null
+ property int at: 0
+ function advance() {
+ if(cur != null)
+ cur.destroy();
+ cur = pages[at++].createObject(container);
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/Ship.qml b/examples/qml/particles/plasmapatrol/content/Ship.qml
new file mode 100644
index 0000000000..bd023b1dc2
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/Ship.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: me
+ //Reflective Properties
+ width: shipLoader.width
+ height: shipLoader.height
+ //Transfered Properties
+ property int hp: 100//shipLoader.item.maxHP
+ property real dodge: shipLoader.item.initialDodge
+ property ParticleSystem system
+ property int targetIdx: 0
+ property Item target: targets[targetIdx] == undefined?null:targets[targetIdx]
+ Connections {
+ target: me.target
+ onHpChanged: if (me.target.hp<=0) me.targetIdx++;
+ }
+ property list<Item> targets
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ property int shipType: 0
+ Component {
+ id: sloopComp
+ Sloop {
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component {
+ id: frigateComp
+ Frigate {
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component {
+ id: cruiserComp
+ Cruiser {
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component {
+ id: dumbComp
+ Item {
+ property int maxHP: 0
+ property int initialDodge: 0
+ }
+ }
+ Loader {
+ id: shipLoader
+ sourceComponent: {
+ switch (shipType) {
+ case 1: sloopComp; break;
+ case 2: frigateComp; break;
+ case 3: cruiserComp; break;
+ default: dumbComp;
+ }
+ }
+ }
+}
diff --git a/examples/qml/particles/plasmapatrol/content/Sloop.qml b/examples/qml/particles/plasmapatrol/content/Sloop.qml
new file mode 100644
index 0000000000..3bc58a28b0
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/Sloop.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.5
+ property real dodge: initialDodge
+ property int blinkInterval: 800
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter {
+ id: emitter
+ //TODO: Cooler would be an 'orbiting' affector
+ //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles
+ system: container.system
+ group: container.shipParticle
+ shape: EllipseShape {}
+
+ emitRate: hp > 0 ? hp + 20 : 0
+ lifeSpan: blinkInterval
+ maximumEmitted: (maxHP + 20)
+
+ acceleration: AngleDirection {angleVariation: 360; magnitude: 8}
+
+ size: 24
+ endSize: 4
+ sizeVariation: 8
+ width: 16
+ height: 16
+ x: 64
+ y: 64
+ Behavior on x {NumberAnimation {duration:blinkInterval}}
+ Behavior on y {NumberAnimation {duration:blinkInterval}}
+ Timer {
+ interval: blinkInterval
+ running: true
+ repeat: true
+ onTriggered: {
+ emitter.x = Math.random() * 48 + 32
+ emitter.y = Math.random() * 48 + 32
+ }
+ }
+ }
+ Hardpoint {
+ anchors.centerIn: parent
+ id: gun2
+ system: container.system
+ show: container.hp > 0
+ hardpointType: gunType
+ }
+ Timer {
+ id: fireControl
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered: {
+ gun2.fireAt(container.target);
+ }
+ }
+
+}
diff --git a/examples/qml/particles/plasmapatrol/content/pics/TitleText.png b/examples/qml/particles/plasmapatrol/content/pics/TitleText.png
new file mode 100644
index 0000000000..dc3acebe39
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/TitleText.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png b/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png
new file mode 100644
index 0000000000..f7c9f3e98e
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png b/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png
new file mode 100644
index 0000000000..dbc39cb16e
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png b/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png
new file mode 100644
index 0000000000..2ba1815230
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/meteor.png b/examples/qml/particles/plasmapatrol/content/pics/meteor.png
new file mode 100644
index 0000000000..e8c368aea7
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/meteor.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png b/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png
new file mode 100644
index 0000000000..4297245d49
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/nullRock.png b/examples/qml/particles/plasmapatrol/content/pics/nullRock.png
new file mode 100644
index 0000000000..4076327a1a
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/nullRock.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/particle.png b/examples/qml/particles/plasmapatrol/content/pics/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/particle.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/star.png b/examples/qml/particles/plasmapatrol/content/pics/star.png
new file mode 100644
index 0000000000..0d592cfa87
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/star.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/star2.png b/examples/qml/particles/plasmapatrol/content/pics/star2.png
new file mode 100644
index 0000000000..bb55c44788
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/star2.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/content/pics/star3.png b/examples/qml/particles/plasmapatrol/content/pics/star3.png
new file mode 100644
index 0000000000..636a25f480
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/content/pics/star3.png
Binary files differ
diff --git a/examples/qml/particles/plasmapatrol/plasmapatrol.qml b/examples/qml/particles/plasmapatrol/plasmapatrol.qml
new file mode 100644
index 0000000000..b14ac6385b
--- /dev/null
+++ b/examples/qml/particles/plasmapatrol/plasmapatrol.qml
@@ -0,0 +1,386 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Rectangle {
+ id: root
+ property bool readySetGo: false
+ //Debugging
+ property int hits: 0
+ property int misses: 0
+ property real ratio: hits/(misses?misses:1)
+ //Move to JS file?
+ property Ship redVar1: Ship {shipType: 1; gunType: 1}
+ property Ship redVar2: Ship {shipType: 1; gunType: 2}
+ property Ship redVar3: Ship {shipType: 1; gunType: 3}
+ property Ship greenVar1: Ship {shipType: 3; gunType: 1}
+ property Ship greenVar2: Ship {shipType: 2; gunType: 2}
+ property Ship greenVar3: Ship {shipType: 1; gunType: 3}
+ property string winner: "0"
+ property int players: 0
+ function aiSet(ship) {
+ ship.gunType = Math.floor(Math.random() * 3) + 1
+ ship.shipType = Math.floor(Math.random() * 3) + 1
+ }
+
+ width: 360
+ height: 600
+ color: "black"
+ SequentialLoader {
+ anchors.fill: parent
+ //General Children
+ Image {
+ anchors.centerIn: parent
+ source: "../images/finalfrontier.png"
+ }
+ ParticleSystem {
+ id: particles
+ }
+ PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane
+ //Component parts
+ id: pageControl
+ Component.onCompleted: advance();
+ pages:[
+ Component {Item {
+ id: menu
+ width: root.width
+ height: root.height
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.width
+ spacing: 8
+ Item {
+ id: title
+ width: root.width
+ height: 240
+ Emitter {
+ anchors.fill: parent
+ system: particles
+ enabled: true
+ group: "default"
+ emitRate: 1200
+ lifeSpan: 1200
+ shape: MaskShape {source:"content/pics/TitleText.png"}
+ size: 16
+ endSize: 0
+ sizeVariation: 8
+ speed: AngleDirection {angleVariation:360; magnitudeVariation: 6}
+ }
+ }
+ Button {
+ text: "1P"
+ onClicked: {root.players = 1; pageControl.advance();}
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button {
+ text: "2P"
+ onClicked: {root.players = 2; pageControl.advance();}
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button {
+ text: "Demo"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {root.players = 0;
+ aiSet(redVar1);
+ aiSet(redVar2);
+ aiSet(redVar3);
+ aiSet(greenVar1);
+ aiSet(greenVar2);
+ aiSet(greenVar3);
+ pageControl.at = 5;//TODO: Not a magic number
+ pageControl.advance();}
+ }
+ Button {
+ text: "Help"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ pageControl.at = 7;//TODO: Not a magic number
+ pageControl.advance();
+ }
+ }
+ Button {
+ text: "Quit"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: Qt.quit();
+ }
+ }
+ }},
+ Component {Item {
+ id: p1Screen
+ z: 101
+ width: root.width
+ height: root.height
+ Rectangle {
+ anchors.fill: parent
+ color: "red"
+ }
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player\n 1"
+ horizontalAlignment: Text.AlignHCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: pageControl.advance()
+ }
+ }},
+ Component {Item {
+ id: p1Choices
+ z: 3
+ width: root.width
+ height: root.height
+ Rectangle {
+ color: "black"
+ anchors.fill: parent
+ }
+ Column {
+ spacing: 16
+ width: root.width
+ anchors.horizontalCenter: parent.horizontalCenter
+ ChoiceBox {
+ target: redVar1
+ system: particles
+ }
+ ChoiceBox {
+ target: redVar2
+ system: particles
+ }
+ ChoiceBox {
+ target: redVar3
+ system: particles
+ }
+ Button {
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Next"
+ onClicked: {
+ if (root.players < 2) {
+ aiSet(greenVar1);
+ aiSet(greenVar2);
+ aiSet(greenVar3);
+ pageControl.at = 5;//TODO: Not a magic number
+ }
+ pageControl.advance();
+ }
+ }
+ }
+ }},
+ Component {Item {
+ id: p2Screen
+ z: 101
+ width: root.width
+ height: root.height
+ Rectangle {
+ anchors.fill: parent
+ color: "green"
+ }
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player\n 2"
+ horizontalAlignment: Text.AlignHCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: pageControl.advance()
+ }
+ }},
+ Component {Item {
+ id: p2Choices
+ z: 1
+ width: root.width
+ height: root.height
+ Rectangle {
+ color: "black"
+ anchors.fill: parent
+ }
+ Column {
+ spacing: 16
+ width: root.width
+ anchors.horizontalCenter: parent.horizontalCenter
+ ChoiceBox {
+ target: greenVar1
+ system: particles
+ }
+ ChoiceBox {
+ target: greenVar2
+ system: particles
+ }
+ ChoiceBox {
+ target: greenVar3
+ system: particles
+ }
+ Button {
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Next"
+ onClicked: pageControl.advance()
+ }
+ }
+ }},
+ Component {Item {
+ id: arena
+ width: root.width
+ height: root.height
+ z: 0
+ Component.onCompleted: root.readySetGo = true
+ Component.onDestruction: root.readySetGo = false
+ property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0
+ onVictoryChanged: {
+ if (redShip3.hp <= 0) {
+ if (greenShip3.hp <= 0) {
+ root.winner = "1&2"
+ }else {
+ root.winner = "2"
+ }
+ } else {
+ root.winner = "1"
+ }
+ winTimer.start()
+ }
+ Timer {
+ id: winTimer
+ interval: 1200
+ repeat: false
+ running: false
+ onTriggered: pageControl.advance();
+ }
+ Ship {
+ id: redShip1
+ shipParticle: "redTeam"
+ system: particles
+ x: 180-64
+ y: 128
+ shipType: redVar1.shipType
+ gunType: redVar1.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+ Ship {
+ id: redShip2
+ shipParticle: "redTeam"
+ system: particles
+ x: 0
+ y: 0
+ shipType: redVar2.shipType
+ gunType: redVar2.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+ Ship {
+ id: redShip3
+ shipParticle: "redTeam"
+ system: particles
+ x: 360-128
+ y: 0
+ shipType: redVar3.shipType
+ gunType: redVar3.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+
+ Ship {
+ id: greenShip1
+ shipParticle: "greenTeam"
+ system: particles
+ x: 180-64
+ y: 600 - 128 - 128
+ shipType: greenVar1.shipType
+ gunType: greenVar1.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ Ship {
+ id: greenShip2
+ shipParticle: "greenTeam"
+ system: particles
+ x: 0
+ y: 600-128
+ shipType: greenVar2.shipType
+ gunType: greenVar2.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ Ship {
+ id: greenShip3
+ shipParticle: "greenTeam"
+ system: particles
+ x: 360 - 128
+ y: 600 - 128
+ shipType: greenVar3.shipType
+ gunType: greenVar3.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ }},
+ Component {Item {
+ id: winScreen
+ z: 101
+ width: root.width
+ height: root.height
+ /*
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ }
+ */
+ Text {//TODO: Particle Text?
+ anchors.fill: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player " + root.winner + " wins!"
+ wrapMode: Text.WordWrap
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {pageControl.at = 0; pageControl.advance();}
+ }
+ }},
+ Component {
+ HelpScreens {
+ onExitDesired: {pageControl.at = 0; pageControl.advance();}
+ }
+ }
+ ]
+ }
+}
diff --git a/examples/qml/particles/simple/dynamiccomparison.qml b/examples/qml/particles/simple/dynamiccomparison.qml
new file mode 100644
index 0000000000..a7cdb9b32a
--- /dev/null
+++ b/examples/qml/particles/simple/dynamiccomparison.qml
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ color: "black"
+ width: 640
+ height: 480
+ ParticleSystem {
+ id: sys
+ }
+
+ ImageParticle {
+ system: sys
+ source: "../images/particle.png"
+ color: "white"
+ colorVariation: 1.0
+ alpha: 0.1
+ entryEffect: ImageParticle.None
+ }
+
+ Emitter {
+ id: emitter
+ system: sys
+ width: parent.width/2
+ speed: PointDirection {y: 72; yVariation: 24}
+ lifeSpan: 10000
+ emitRate: 1000
+ enabled: false
+ size: 32
+ }
+
+ Item {
+ id: fakeEmitter
+ function burst(number) {
+ while (number > 0) {
+ var item = fakeParticle.createObject(root);
+ item.lifeSpan = Math.random() * 5000 + 5000;
+ item.x = Math.random() * 320 + 320;
+ item.y = 0;
+ number--;
+ }
+ }
+
+ Component {
+ id: fakeParticle
+ Image {
+ id: container
+ property int lifeSpan: 10000
+ width: 32
+ height: 32
+ source: "../images/particle.png"
+ y: 0
+ PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true}
+ SequentialAnimation on opacity {
+ running: true
+ NumberAnimation { from:0; to: 1; duration: 500}
+ PauseAnimation { duration: container.lifeSpan - 1000}
+ NumberAnimation { from:1; to: 0; duration: 500}
+ ScriptAction { script: container.destroy(); }
+ }
+ }
+ }
+ }
+
+ Text {
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ text: "1000 particles"
+ color: "white"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: emitter.burst(1000);
+ }
+ }
+ Text {
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ text: "1000 items"
+ color: "white"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: fakeEmitter.burst(1000);
+ }
+ }
+}
diff --git a/examples/qml/particles/simple/dynamicemitters.qml b/examples/qml/particles/simple/dynamicemitters.qml
new file mode 100644
index 0000000000..4431ebe82e
--- /dev/null
+++ b/examples/qml/particles/simple/dynamicemitters.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ color: "black"
+ width: 640
+ height: 480
+ ParticleSystem {
+ id: sys
+ }
+ ImageParticle {
+ system: sys
+ source: "../images/particle.png"
+ color: "white"
+ colorVariation: 1.0
+ alpha: 0.1
+ }
+
+ Component {
+ id: emitterComp
+ Emitter {
+ id: container
+ Emitter {
+ id: emitMore
+ system: sys
+ emitRate: 128
+ lifeSpan: 600
+ size: 16
+ endSize: 8
+ speed: AngleDirection {angleVariation:360; magnitude: 60}
+ }
+
+ property int life: 2600
+ property real targetX: 0
+ property real targetY: 0
+ function go() {
+ xAnim.start();
+ yAnim.start();
+ container.enabled = true
+ }
+ system: sys
+ emitRate: 32
+ lifeSpan: 600
+ size: 24
+ endSize: 8
+ NumberAnimation on x {
+ id: xAnim;
+ to: targetX
+ duration: life
+ running: false
+ }
+ NumberAnimation on y {
+ id: yAnim;
+ to: targetY
+ duration: life
+ running: false
+ }
+ Timer {
+ interval: life
+ running: true
+ onTriggered: container.destroy();
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ for (var i=0; i<8; i++) {
+ var obj = emitterComp.createObject(root);
+ obj.x = mouse.x
+ obj.y = mouse.y
+ obj.targetX = Math.random() * 240 - 120 + obj.x
+ obj.targetY = Math.random() * 240 - 120 + obj.y
+ obj.life = Math.round(Math.random() * 2400) + 200
+ obj.emitRate = Math.round(Math.random() * 32) + 32
+ obj.go();
+ }
+ }
+ }
+}
diff --git a/examples/qml/particles/simple/multiplepainters.qml b/examples/qml/particles/simple/multiplepainters.qml
new file mode 100644
index 0000000000..c1b85caa2d
--- /dev/null
+++ b/examples/qml/particles/simple/multiplepainters.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 600
+ color: "darkblue"
+ property bool cloneMode: false
+ ParticleSystem {
+ id: sys
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: cloneMode = !cloneMode;
+ }
+ Emitter {
+ system: sys
+ y:root.height + 20
+ width: root.width
+ emitRate: 200
+ lifeSpan: 4000
+ startTime: 4000
+ speed: PointDirection { y: -120; }
+ }
+
+ ImageParticle {
+ system: sys
+ visible: !cloneMode
+ source: "../images/particle2.png"
+ }
+
+ ImageParticle {
+ system: sys
+ visible: cloneMode
+ z: 0
+ source: "../images/particle3.png"
+ }
+
+ ImageParticle {
+ system: sys
+ clip: true
+ visible: cloneMode
+ y: 120
+ height: 240
+ width: root.width
+ z: 1
+ source: "../images/particle.png"
+ }
+}
diff --git a/examples/qml/particles/simple/startstop.qml b/examples/qml/particles/simple/startstop.qml
new file mode 100644
index 0000000000..62105b28a0
--- /dev/null
+++ b/examples/qml/particles/simple/startstop.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 540
+ color: "black"
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (mouse.button == Qt.LeftButton)
+ particles.running = !particles.running
+ else
+ particles.paused = !particles.paused;
+ }
+ }
+
+ ParticleSystem {
+ id: particles
+ running: false
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../images/star.png"
+ sizeTable: "../images/sparkleSize.png"
+ alpha: 0
+ colorVariation: 0.6
+ }
+
+ Emitter {
+ anchors.fill: parent
+ system: particles
+ emitRate: 2000
+ lifeSpan: 2000
+ size: 30
+ sizeVariation: 10
+ }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml
new file mode 100644
index 0000000000..164f47faa9
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Component {
+ id: albumDelegate
+ Package {
+
+ Item {
+ Package.name: 'browser'
+ GridView {
+ id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21
+ x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false
+ onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain)
+ }
+ }
+
+ Item {
+ Package.name: 'fullscreen'
+ ListView {
+ id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal
+ width: mainWindow.width; height: mainWindow.height; interactive: false
+ onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain)
+ highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
+ }
+ }
+
+ Item {
+ Package.name: 'album'
+ id: albumWrapper; width: 210; height: 220
+
+ VisualDataModel {
+ id: visualModel; delegate: PhotoDelegate { }
+ model: RssModel { id: rssModel; tags: tag }
+ }
+
+ BusyIndicator {
+ id: busyIndicator
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ on: rssModel.status != XmlListModel.Ready
+ }
+
+ PathView {
+ id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5
+ visible: !busyIndicator.visible
+ anchors.centerIn: parent; anchors.verticalCenterOffset: -30
+ path: Path {
+ PathAttribute { name: 'z'; value: 9999.0 }
+ PathLine { x: 1; y: 1 }
+ PathAttribute { name: 'z'; value: 0.0 }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid'
+ }
+
+ Tag {
+ anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 }
+ frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode
+ onTagChanged: rssModel.tags = tag
+ onBackClicked: if (mainWindow.editMode) photosModel.remove(index);
+ }
+
+ states: [
+ State {
+ name: 'inGrid'
+ PropertyChanges { target: photosGridView; interactive: true }
+ PropertyChanges { target: albumsShade; opacity: 1 }
+ PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 }
+ },
+ State {
+ name: 'fullscreen'; extend: 'inGrid'
+ PropertyChanges { target: photosGridView; interactive: false }
+ PropertyChanges { target: photosListView; interactive: true }
+ PropertyChanges { target: photosShade; opacity: 1 }
+ PropertyChanges { target: backButton; y: -backButton.height - 8 }
+ }
+ ]
+
+ GridView.onAdd: NumberAnimation {
+ target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad
+ }
+ GridView.onRemove: SequentialAnimation {
+ PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true }
+ NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad }
+ PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false }
+ }
+
+ transitions: [
+ Transition {
+ from: '*'; to: 'inGrid'
+ SequentialAnimation {
+ NumberAnimation { properties: 'opacity'; duration: 250 }
+ PauseAnimation { duration: 350 }
+ NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: '*'
+ NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml
new file mode 100644
index 0000000000..867c268399
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+ NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/Button.qml b/examples/qml/photoviewer/PhotoViewerCore/Button.qml
new file mode 100644
index 0000000000..8f4177c097
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/Button.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property alias label: labelText.text
+ property color tint: "transparent"
+ signal clicked
+
+ width: labelText.width + 70 ; height: labelText.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true }
+
+ Rectangle {
+ anchors.fill: container; color: container.tint; visible: container.tint != ""
+ opacity: 0.25; smooth: true
+ }
+
+ Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: container.clicked()
+ }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml
new file mode 100644
index 0000000000..435ad2644f
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property string label
+ signal clicked
+ signal labelChanged(string label)
+
+ width: textInput.width + 70 ; height: textInput.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true }
+
+ TextInput {
+ id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true
+ Keys.onReturnPressed: {
+ 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
+ }
+ }
+
+ Rectangle {
+ anchors.fill: container; border.color: "steelblue"; border.width: 4
+ color: "transparent"; visible: textInput.focus; smooth: true
+ }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); }
+ }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml
new file mode 100644
index 0000000000..5d4e5aee5d
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "script/script.js" as Script
+
+Package {
+ Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z }
+ Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 }
+ Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 }
+
+ Item {
+ width: 160; height: 153
+
+ Item {
+ id: photoWrapper
+
+ property double randomAngle: Math.random() * (2 * 6 + 1) - 6
+ property double randomAngle2: Math.random() * (2 * 6 + 1) - 6
+
+ x: 0; y: 0; width: 140; height: 133
+ z: stackItem.PathView.z; rotation: photoWrapper.randomAngle
+
+ BorderImage {
+ anchors {
+ fill: originalImage.status == Image.Ready ? border : placeHolder
+ leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8
+ }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+ Rectangle {
+ id: placeHolder
+
+ property int w: Script.getWidth(content)
+ property int h: Script.getHeight(content)
+ property double s: Script.calculateScale(w, h, photoWrapper.width)
+
+ color: 'white'; anchors.centerIn: parent; smooth: true
+ width: w * s; height: h * s; visible: originalImage.status != Image.Ready
+ Rectangle {
+ color: "#878787"; smooth: true
+ anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 }
+ }
+ }
+ Rectangle {
+ id: border; color: 'white'; anchors.centerIn: parent; smooth: true
+ width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6
+ visible: !placeHolder.visible
+ }
+ BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready }
+ Image {
+ id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content); cache: false
+ fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
+ }
+ Image {
+ id: hqImage; smooth: true; source: ""; visible: false; cache: false
+ fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
+ }
+ Binding {
+ target: mainWindow; property: "downloadProgress"; value: hqImage.progress
+ when: listItem.ListView.isCurrentItem
+ }
+ Binding {
+ target: mainWindow; property: "imageLoading"
+ value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem
+ }
+ MouseArea {
+ width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage
+ onClicked: {
+ if (albumWrapper.state == 'inGrid') {
+ gridItem.GridView.view.currentIndex = index;
+ albumWrapper.state = 'fullscreen'
+ } else {
+ gridItem.GridView.view.currentIndex = index;
+ albumWrapper.state = 'inGrid'
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: 'stacked'; when: albumWrapper.state == ''
+ ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 }
+ PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 }
+ },
+ State {
+ name: 'inGrid'; when: albumWrapper.state == 'inGrid'
+ ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 }
+ },
+ State {
+ name: 'fullscreen'; when: albumWrapper.state == 'fullscreen'
+ ParentChange {
+ target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0
+ width: mainWindow.width; height: mainWindow.height
+ }
+ PropertyChanges { target: border; opacity: 0 }
+ PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: 'stacked'; to: 'inGrid'
+ SequentialAnimation {
+ PauseAnimation { duration: 10 * index }
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart'
+ }
+ }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: 'stacked'
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: 'fullscreen'
+ SequentialAnimation {
+ PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 }
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ targets: [ photoWrapper, border ]
+ properties: 'x,y,width,height,opacity,rotation'
+ duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
+ }
+ }
+ }
+ },
+ Transition {
+ from: 'fullscreen'; to: 'inGrid'
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ targets: [ photoWrapper, border ]
+ properties: 'x,y,width,height,rotation,opacity'
+ duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
+ }
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml
new file mode 100644
index 0000000000..58beef57f3
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property real progress: 0
+
+ Behavior on opacity { NumberAnimation { duration: 600 } }
+
+ Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 }
+
+ Rectangle {
+ id: fill; color: "white"; height: container.height
+ width: container.width * container.progress
+ }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml b/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml
new file mode 100644
index 0000000000..1598977bb1
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ property string tags : ""
+
+ function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "content"; query: "content/string()" }
+ XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/Tag.qml b/examples/qml/photoviewer/PhotoViewerCore/Tag.qml
new file mode 100644
index 0000000000..ed4a248a7b
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/Tag.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Flipable {
+ id: flipable
+
+ property alias frontLabel: frontButton.label
+ property alias backLabel: backButton.label
+
+ property int angle: 0
+ property int randomAngle: Math.random() * (2 * 6 + 1) - 6
+ property bool flipped: false
+
+ signal frontClicked
+ signal backClicked
+ signal tagChanged(string tag)
+
+ front: EditableButton {
+ id: frontButton; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ onClicked: flipable.frontClicked()
+ onLabelChanged: flipable.tagChanged(label)
+ }
+
+ back: Button {
+ id: backButton; tint: "red"; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ onClicked: flipable.backClicked()
+ }
+
+ transform: Rotation {
+ origin.x: flipable.width / 2; origin.y: flipable.height / 2
+ axis.x: 0; axis.y: 1; axis.z: 0
+ angle: flipable.angle
+ }
+
+ states: State {
+ name: "back"; when: flipable.flipped
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { properties: "angle"; duration: 400 }
+ SequentialAnimation {
+ NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 }
+ NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 }
+ }
+ }
+ }
+}
diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png
new file mode 100644
index 0000000000..431af8545d
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png
Binary files differ
diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/busy.png b/examples/qml/photoviewer/PhotoViewerCore/images/busy.png
new file mode 100644
index 0000000000..664c2b1491
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/images/busy.png
Binary files differ
diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png
new file mode 100644
index 0000000000..1847ab528d
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png
Binary files differ
diff --git a/examples/qml/photoviewer/PhotoViewerCore/qmldir b/examples/qml/photoviewer/PhotoViewerCore/qmldir
new file mode 100644
index 0000000000..d3c247f21a
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/qmldir
@@ -0,0 +1,8 @@
+AlbumDelegate AlbumDelegate.qml
+PhotoDelegate PhotoDelegate.qml
+ProgressBar ProgressBar.qml
+RssModel RssModel.qml
+BusyIndicator BusyIndicator.qml
+EditableButton EditableButton.qml
+Button Button.qml
+Tag Tag.qml
diff --git a/examples/qml/photoviewer/PhotoViewerCore/script/script.js b/examples/qml/photoviewer/PhotoViewerCore/script/script.js
new file mode 100644
index 0000000000..e8ef93a847
--- /dev/null
+++ b/examples/qml/photoviewer/PhotoViewerCore/script/script.js
@@ -0,0 +1,27 @@
+.pragma library
+
+function getWidth(string) {
+ return (string.match(/width=\"([0-9]+)\"/))[1]
+}
+
+function getHeight(string) {
+ return (string.match(/height=\"([0-9]+)\"/))[1]
+}
+
+function getImagePath(string) {
+ var pattern = /src=\"http:\/\/(\S+)\"/
+ return (string.match(pattern))[1]
+}
+
+function calculateScale(width, height, cellSize) {
+ var widthScale = (cellSize * 1.0) / width
+ var heightScale = (cellSize * 1.0) / height
+ var scale = 0
+
+ if (widthScale <= heightScale) {
+ scale = widthScale;
+ } else if (heightScale < widthScale) {
+ scale = heightScale;
+ }
+ return scale;
+}
diff --git a/examples/qml/photoviewer/i18n/base.ts b/examples/qml/photoviewer/i18n/base.ts
new file mode 100644
index 0000000000..1accfd2f90
--- /dev/null
+++ b/examples/qml/photoviewer/i18n/base.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <source>Remove</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>photoviewer</name>
+ <message>
+ <location filename="../photoviewer.qml" line="30"/>
+ <source>Add</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="39"/>
+ <source>Edit</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="52"/>
+ <source>Back</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/qml/photoviewer/i18n/qml_fr.qm b/examples/qml/photoviewer/i18n/qml_fr.qm
new file mode 100644
index 0000000000..c24fcbc46c
--- /dev/null
+++ b/examples/qml/photoviewer/i18n/qml_fr.qm
Binary files differ
diff --git a/examples/qml/photoviewer/i18n/qml_fr.ts b/examples/qml/photoviewer/i18n/qml_fr.ts
new file mode 100644
index 0000000000..9f892db616
--- /dev/null
+++ b/examples/qml/photoviewer/i18n/qml_fr.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr_FR">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <source>Remove</source>
+ <translation>Supprimer</translation>
+ </message>
+</context>
+<context>
+ <name>photoviewer</name>
+ <message>
+ <location filename="../photoviewer.qml" line="30"/>
+ <source>Add</source>
+ <translation>Ajouter</translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="39"/>
+ <source>Edit</source>
+ <translation>Éditer</translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="52"/>
+ <source>Back</source>
+ <translation>Retour</translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/qml/photoviewer/photoviewer.qml b/examples/qml/photoviewer/photoviewer.qml
new file mode 100644
index 0000000000..208720b9e6
--- /dev/null
+++ b/examples/qml/photoviewer/photoviewer.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "PhotoViewerCore"
+
+Rectangle {
+ id: mainWindow
+
+ property real downloadProgress: 0
+ property bool imageLoading: false
+ property bool editMode: false
+
+ width: 800; height: 480; color: "#d5d6d8"
+
+ ListModel {
+ id: photosModel
+ ListElement { tag: "Flowers" }
+ ListElement { tag: "Wildlife" }
+ ListElement { tag: "Prague" }
+ }
+
+ VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} }
+
+ GridView {
+ id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220
+ model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0
+ }
+
+ Column {
+ spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 }
+ Button {
+ id: newButton; label: qsTr("Add"); rotation: 3
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ mainWindow.editMode = false
+ photosModel.append( { tag: "" } )
+ albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain)
+ }
+ }
+ Button {
+ id: deleteButton; label: qsTr("Edit"); rotation: -2;
+ onClicked: mainWindow.editMode = !mainWindow.editMode
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button {
+ id: quitButton; label: qsTr("Quit"); rotation: -2;
+ onClicked: Qt.quit()
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+
+ Rectangle {
+ id: albumsShade; color: mainWindow.color
+ width: parent.width; height: parent.height; opacity: 0.0
+ }
+
+ ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false }
+
+ Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 }
+
+ Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 }
+
+ ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false }
+
+ Item { id: foreground; anchors.fill: parent }
+
+ ProgressBar {
+ progress: mainWindow.downloadProgress; width: parent.width; height: 4
+ anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0
+ }
+}
diff --git a/examples/qml/photoviewer/photoviewer.qmlproject b/examples/qml/photoviewer/photoviewer.qmlproject
new file mode 100644
index 0000000000..600bdb10f4
--- /dev/null
+++ b/examples/qml/photoviewer/photoviewer.qmlproject
@@ -0,0 +1,20 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "photoviewer.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ Files {
+ filter: "*.ts"
+ directory: "i18n"
+ }
+}
diff --git a/examples/qtquick/positioners/content/Button.qml b/examples/qml/positioners/content/Button.qml
index ee3aa9057e..ee3aa9057e 100644
--- a/examples/qtquick/positioners/content/Button.qml
+++ b/examples/qml/positioners/content/Button.qml
diff --git a/examples/qtquick/positioners/content/add.png b/examples/qml/positioners/content/add.png
index 1ee45423e3..1ee45423e3 100644
--- a/examples/qtquick/positioners/content/add.png
+++ b/examples/qml/positioners/content/add.png
Binary files differ
diff --git a/examples/qtquick/positioners/content/del.png b/examples/qml/positioners/content/del.png
index 8d2eaed523..8d2eaed523 100644
--- a/examples/qtquick/positioners/content/del.png
+++ b/examples/qml/positioners/content/del.png
Binary files differ
diff --git a/examples/qtquick/positioners/positioners-attachedproperties.qml b/examples/qml/positioners/positioners-attachedproperties.qml
index a05927f5ea..a05927f5ea 100644
--- a/examples/qtquick/positioners/positioners-attachedproperties.qml
+++ b/examples/qml/positioners/positioners-attachedproperties.qml
diff --git a/examples/qml/positioners/positioners.qml b/examples/qml/positioners/positioners.qml
new file mode 100644
index 0000000000..d9d16649ff
--- /dev/null
+++ b/examples/qml/positioners/positioners.qml
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: page
+ width: 420; height: 420
+
+ Column {
+ id: layout1
+ y: 0
+ move: Transition {
+ NumberAnimation { properties: "y"; easing.type: Easing.OutBounce }
+ }
+ add: Transition {
+ NumberAnimation { properties: "y"; easing.type: Easing.OutQuad }
+ }
+
+ Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueV1
+ visible: opacity != 0
+ width: 100; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueV2
+ visible: opacity != 0
+ width: 100; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 }
+ }
+
+ Row {
+ id: layout2
+ y: 300
+ move: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.OutBounce }
+ }
+ add: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.OutQuad }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueH1
+ visible: opacity != 0
+ width: 50; height: 100
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueH2
+ visible: opacity != 0
+ width: 50; height: 100
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ }
+
+ Button {
+ x: 135; y: 90
+ text: "Remove"
+ icon: "del.png"
+
+ onClicked: {
+ blueH2.opacity = 0
+ blueH1.opacity = 0
+ blueV1.opacity = 0
+ blueV2.opacity = 0
+ blueG1.opacity = 0
+ blueG2.opacity = 0
+ blueG3.opacity = 0
+ blueF1.opacity = 0
+ blueF2.opacity = 0
+ blueF3.opacity = 0
+ }
+ }
+
+ Button {
+ x: 145; y: 140
+ text: "Add"
+ icon: "add.png"
+
+ onClicked: {
+ blueH2.opacity = 1
+ blueH1.opacity = 1
+ blueV1.opacity = 1
+ blueV2.opacity = 1
+ blueG1.opacity = 1
+ blueG2.opacity = 1
+ blueG3.opacity = 1
+ blueF1.opacity = 1
+ blueF2.opacity = 1
+ blueF3.opacity = 1
+ }
+ }
+
+ Grid {
+ x: 260; y: 0
+ columns: 3
+
+ move: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
+ }
+
+ add: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueG1
+ visible: opacity != 0
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueG2
+ visible: opacity != 0
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueG3
+ visible: opacity != 0
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ }
+
+ Flow {
+ id: layout4
+ x: 260; y: 250; width: 150
+
+ move: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
+ }
+
+ add: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueF1
+ visible: opacity != 0
+ width: 60; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueF2
+ visible: opacity != 0
+ width: 60; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueF3
+ visible: opacity != 0
+ width: 40; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 }
+ }
+
+}
diff --git a/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml b/examples/qml/righttoleft/layoutdirection/layoutdirection.qml
index 0c65647d5b..0c65647d5b 100644
--- a/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml
+++ b/examples/qml/righttoleft/layoutdirection/layoutdirection.qml
diff --git a/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject
index 33cbb3c9e2..33cbb3c9e2 100644
--- a/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject
+++ b/examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject
diff --git a/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml
index 5c4739bd57..5c4739bd57 100644
--- a/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml
+++ b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml
diff --git a/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject
index 72bc04a8a9..72bc04a8a9 100644
--- a/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject
+++ b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject
diff --git a/examples/qtquick/righttoleft/textalignment/textalignment.qml b/examples/qml/righttoleft/textalignment/textalignment.qml
index ef5b97bb1a..ef5b97bb1a 100644
--- a/examples/qtquick/righttoleft/textalignment/textalignment.qml
+++ b/examples/qml/righttoleft/textalignment/textalignment.qml
diff --git a/examples/qtquick/righttoleft/textalignment/textalignment.qmlproject b/examples/qml/righttoleft/textalignment/textalignment.qmlproject
index e4b5061364..e4b5061364 100644
--- a/examples/qtquick/righttoleft/textalignment/textalignment.qmlproject
+++ b/examples/qml/righttoleft/textalignment/textalignment.qmlproject
diff --git a/examples/qml/rssnews/content/BusyIndicator.qml b/examples/qml/rssnews/content/BusyIndicator.qml
new file mode 100644
index 0000000000..f1abd1119c
--- /dev/null
+++ b/examples/qml/rssnews/content/BusyIndicator.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+
+ NumberAnimation on rotation {
+ running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200
+ }
+}
diff --git a/examples/qml/rssnews/content/CategoryDelegate.qml b/examples/qml/rssnews/content/CategoryDelegate.qml
new file mode 100644
index 0000000000..fe64238adb
--- /dev/null
+++ b/examples/qml/rssnews/content/CategoryDelegate.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: delegate
+
+ width: delegate.ListView.view.width; height: 60
+
+ Text {
+ text: name
+ color: delegate.ListView.isCurrentItem ? "white" : "black"
+ font { family: "Helvetica"; pixelSize: 16; bold: true }
+ anchors {
+ left: parent.left; leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ }
+ }
+
+ BusyIndicator {
+ scale: 0.6
+ on: delegate.ListView.isCurrentItem && window.loading
+ anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter }
+ }
+
+ Rectangle {
+ width: delegate.width; height: 1; color: "#cccccc"
+ anchors.bottom: delegate.bottom
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+ Rectangle {
+ width: delegate.width; height: 1; color: "white"
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+
+ MouseArea {
+ anchors.fill: delegate
+ onClicked: {
+ delegate.ListView.view.currentIndex = index
+ window.currentFeed = feed
+ }
+ }
+}
diff --git a/examples/qml/rssnews/content/NewsDelegate.qml b/examples/qml/rssnews/content/NewsDelegate.qml
new file mode 100644
index 0000000000..59ab269d3b
--- /dev/null
+++ b/examples/qml/rssnews/content/NewsDelegate.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: delegate
+ height: column.height + 40
+ width: delegate.ListView.view.width
+
+ Column {
+ id: column
+ x: 20; y: 20
+ width: parent.width - 40
+
+ Text {
+ id: titleText
+ text: title; width: parent.width; wrapMode: Text.WordWrap
+ font { bold: true; family: "Helvetica"; pointSize: 16 }
+ }
+
+ Text {
+ id: descriptionText
+ width: parent.width; text: description
+ wrapMode: Text.WordWrap; font.family: "Helvetica"
+ }
+ }
+
+ Rectangle {
+ width: parent.width; height: 1; color: "#cccccc"
+ anchors.bottom: parent.bottom
+ }
+}
diff --git a/examples/qml/rssnews/content/RssFeeds.qml b/examples/qml/rssnews/content/RssFeeds.qml
new file mode 100644
index 0000000000..ed58ef3852
--- /dev/null
+++ b/examples/qml/rssnews/content/RssFeeds.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id: rssFeeds
+
+ ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" }
+ ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" }
+ ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" }
+ ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" }
+ ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" }
+ ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" }
+ ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" }
+ ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" }
+ ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" }
+ ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" }
+ ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" }
+ ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" }
+}
diff --git a/examples/qml/rssnews/content/ScrollBar.qml b/examples/qml/rssnews/content/ScrollBar.qml
new file mode 100644
index 0000000000..7b1a2ac3e5
--- /dev/null
+++ b/examples/qml/rssnews/content/ScrollBar.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property variant scrollArea
+ property variant orientation: Qt.Vertical
+
+ opacity: 0
+
+ function position()
+ {
+ var ny = 0;
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+ if (ny > 2) return ny; else return 2;
+ }
+
+ function size()
+ {
+ var nh, ny;
+
+ if (container.orientation == Qt.Vertical)
+ nh = scrollArea.visibleArea.heightRatio * container.height;
+ else
+ nh = scrollArea.visibleArea.widthRatio * container.width;
+
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+
+ if (ny > 3) {
+ var t;
+ if (container.orientation == Qt.Vertical)
+ t = Math.ceil(container.height - 3 - ny);
+ else
+ t = Math.ceil(container.width - 3 - ny);
+ if (nh > t) return t; else return nh;
+ } else return nh + ny;
+ }
+
+ Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 }
+
+ BorderImage {
+ source: "images/scrollbar.png"
+ border { left: 1; right: 1; top: 1; bottom: 1 }
+ x: container.orientation == Qt.Vertical ? 2 : position()
+ width: container.orientation == Qt.Vertical ? container.width - 4 : size()
+ y: container.orientation == Qt.Vertical ? position() : 2
+ height: container.orientation == Qt.Vertical ? size() : container.height - 4
+ }
+
+ states: State {
+ name: "visible"
+ when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally
+ PropertyChanges { target: container; opacity: 1.0 }
+ }
+
+ transitions: Transition {
+ from: "visible"; to: ""
+ NumberAnimation { properties: "opacity"; duration: 600 }
+ }
+}
diff --git a/examples/qml/rssnews/content/images/busy.png b/examples/qml/rssnews/content/images/busy.png
new file mode 100644
index 0000000000..664c2b1491
--- /dev/null
+++ b/examples/qml/rssnews/content/images/busy.png
Binary files differ
diff --git a/examples/qml/rssnews/content/images/scrollbar.png b/examples/qml/rssnews/content/images/scrollbar.png
new file mode 100644
index 0000000000..0228dcf9eb
--- /dev/null
+++ b/examples/qml/rssnews/content/images/scrollbar.png
Binary files differ
diff --git a/examples/qml/rssnews/rssnews.qml b/examples/qml/rssnews/rssnews.qml
new file mode 100644
index 0000000000..d26b94b6d3
--- /dev/null
+++ b/examples/qml/rssnews/rssnews.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+import "content"
+
+Rectangle {
+ id: window
+ width: 800; height: 480
+
+ property string currentFeed: "rss.news.yahoo.com/rss/topstories"
+ property bool loading: feedModel.status == XmlListModel.Loading
+
+ RssFeeds { id: rssFeeds }
+
+ XmlListModel {
+ id: feedModel
+ source: "http://" + window.currentFeed
+ query: "/rss/channel/item"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "link"; query: "link/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ }
+
+ Row {
+ Rectangle {
+ width: 220; height: window.height
+ color: "#efefef"
+
+ ListView {
+ focus: true
+ id: categories
+ anchors.fill: parent
+ model: rssFeeds
+ footer: quitButtonDelegate
+ delegate: CategoryDelegate {}
+ highlight: Rectangle { color: "steelblue" }
+ highlightMoveSpeed: 9999999
+ }
+ ScrollBar {
+ scrollArea: categories; height: categories.height; width: 8
+ anchors.right: categories.right
+ }
+ }
+ ListView {
+ id: list
+ width: window.width - 220; height: window.height
+ model: feedModel
+ delegate: NewsDelegate {}
+ }
+ }
+ Component {
+ id: quitButtonDelegate
+ Item {
+ width: categories.width; height: 60
+ Text {
+ text: "Quit"
+ font { family: "Helvetica"; pixelSize: 16; bold: true }
+ anchors {
+ left: parent.left; leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+ }
+ ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right }
+ Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" }
+}
diff --git a/examples/qml/rssnews/rssnews.qmlproject b/examples/qml/rssnews/rssnews.qmlproject
new file mode 100644
index 0000000000..5becbdaed0
--- /dev/null
+++ b/examples/qml/rssnews/rssnews.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "rssnews.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/samegame/content/BoomBlock.qml b/examples/qml/samegame/content/BoomBlock.qml
new file mode 100644
index 0000000000..a348368ae1
--- /dev/null
+++ b/examples/qml/samegame/content/BoomBlock.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+
+ Image {
+ id: img
+ source: {
+ if(type == 0){
+ "pics/redStone.png";
+ } else if(type == 1) {
+ "pics/blueStone.png";
+ } else {
+ "pics/greenStone.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+ Emitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if(type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else {
+ "green";
+ }
+ }
+ anchors.fill: parent
+
+ speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
+ shape: EllipseShape{fill:true}
+ enabled: false;
+ lifeSpan: 700; lifeSpanVariation: 100
+ emitRate: 1000
+ maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
+ size: 28
+ endSize: 14
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100);} }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/examples/qml/samegame/content/Button.qml b/examples/qml/samegame/content/Button.qml
new file mode 100644
index 0000000000..2d1a993226
--- /dev/null
+++ b/examples/qml/samegame/content/Button.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 20
+ smooth: true
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ radius: 8
+ color: activePalette.button
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24
+ }
+}
diff --git a/examples/qml/samegame/content/Dialog.qml b/examples/qml/samegame/content/Dialog.qml
new file mode 100644
index 0000000000..c81580e6a5
--- /dev/null
+++ b/examples/qml/samegame/content/Dialog.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ anchors.centerIn: parent
+
+ property Item text: dialogText
+ property bool open: false
+
+ signal closed
+ signal opened
+ function forceClose() {
+ if(!open)
+ return; //already closed
+ page.open = false;
+ page.closed();
+ page.opacity = 0;
+ }
+
+ function show(txt) {
+ page.open = true;
+ page.opened();
+ dialogText.text = txt;
+ page.opacity = 1;
+ }
+
+ width: dialogText.width + 20; height: dialogText.height + 20
+ color: "white"
+ border.width: 1
+ opacity: 0
+ visible: opacity > 0
+ Behavior on opacity {
+ NumberAnimation { duration: 1000 }
+ }
+
+ Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+
+ MouseArea { anchors.fill: parent; onClicked: forceClose(); }
+}
+
diff --git a/examples/qml/samegame/content/GameArea.qml b/examples/qml/samegame/content/GameArea.qml
new file mode 100644
index 0000000000..3422582b21
--- /dev/null
+++ b/examples/qml/samegame/content/GameArea.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "samegame.js" as Logic
+
+Item {
+ id: gameCanvas
+ property int score: 0
+ property int blockSize: 40
+ property ParticleSystem ps: particleSystem
+ Image {
+ id: background
+ anchors.fill: parent
+ z: -1
+ source: "pics/background.png"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ width: 480
+ height: 800
+ MouseArea {
+ anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y);
+ }
+ ParticleSystem{
+ id: particleSystem;
+ onEmptyChanged: if (empty) paused = true;
+ z:2
+ ImageParticle {
+ groups: ["red"]
+ color: Qt.darker("red");//Actually want desaturated...
+ source: "pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["green"]
+ color: Qt.darker("green");//Actually want desaturated...
+ source: "pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["blue"]
+ color: Qt.darker("blue");//Actually want desaturated...
+ source: "pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ anchors.fill: parent
+ }
+}
+
diff --git a/examples/qml/samegame/content/NameInputDialog.qml b/examples/qml/samegame/content/NameInputDialog.qml
new file mode 100644
index 0000000000..7c3bfa274a
--- /dev/null
+++ b/examples/qml/samegame/content/NameInputDialog.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Dialog {
+ id: nameInputDialog
+
+ property int initialWidth: 0
+ property alias name: nameInputText.text
+
+ anchors.centerIn: parent
+ z: 22;
+
+ Behavior on width {
+ NumberAnimation {}
+ enabled: nameInputDialog.initialWidth != 0
+ }
+
+ signal accepted(string name)
+ onClosed: {
+ if (nameInputText.text != "")
+ accepted(name);
+ }
+ Text {
+ id: dialogText
+ anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter }
+ text: "You won! Please enter your name: "
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (nameInputText.text == "")
+ nameInputText.openSoftwareInputPanel();
+ else
+ nameInputDialog.forceClose();
+ }
+ }
+
+ TextInput {
+ id: nameInputText
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ focus: visible
+ autoScroll: false
+ maximumLength: 24
+ onTextChanged: {
+ var newWidth = nameInputText.width + dialogText.width + 40;
+ if ( (newWidth > nameInputDialog.width && newWidth < screen.width)
+ || (nameInputDialog.width > nameInputDialog.initialWidth) )
+ nameInputDialog.width = newWidth;
+ }
+ onAccepted: {
+ nameInputDialog.forceClose();
+ }
+ }
+}
diff --git a/examples/qml/samegame/content/pics/background.png b/examples/qml/samegame/content/pics/background.png
new file mode 100644
index 0000000000..3734a27744
--- /dev/null
+++ b/examples/qml/samegame/content/pics/background.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png b/examples/qml/samegame/content/pics/blueStone.png
index 20e43c75b6..20e43c75b6 100644
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png
+++ b/examples/qml/samegame/content/pics/blueStone.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png b/examples/qml/samegame/content/pics/greenStone.png
index b568a1900c..b568a1900c 100644
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png
+++ b/examples/qml/samegame/content/pics/greenStone.png
Binary files differ
diff --git a/examples/qml/samegame/content/pics/particle.png b/examples/qml/samegame/content/pics/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/qml/samegame/content/pics/particle.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png b/examples/qml/samegame/content/pics/redStone.png
index 36b09a2686..36b09a2686 100644
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png
+++ b/examples/qml/samegame/content/pics/redStone.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png b/examples/qml/samegame/content/pics/yellowStone.png
index b1ce76212c..b1ce76212c 100644
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png
+++ b/examples/qml/samegame/content/pics/yellowStone.png
Binary files differ
diff --git a/examples/qml/samegame/content/samegame.js b/examples/qml/samegame/content/samegame.js
new file mode 100755
index 0000000000..611767584b
--- /dev/null
+++ b/examples/qml/samegame/content/samegame.js
@@ -0,0 +1,290 @@
+/* This script file handles the game logic */
+.pragma library
+.import QtQuick.LocalStorage 2.0 as Sql
+
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn*maxRow;
+var board = new Array(maxIndex);
+var blockSrc = "BoomBlock.qml";
+var scoresURL = "";
+var gameDuration;
+var component = Qt.createComponent(blockSrc);
+var highScoreBar = -1;
+var gameCanvas;
+var nameInputDialog = null;
+var dialog = null;
+
+// Index function used instead of a 2D array
+function index(column, row)
+{
+ return column + row * maxColumn;
+}
+
+function timeStr(msecs)
+{
+ var secs = Math.floor(msecs/1000);
+ var m = Math.floor(secs/60);
+ var ret = "" + m + "m " + (secs%60) + "s";
+ return ret;
+}
+
+function startNewGame(gc)
+{
+ gameCanvas = gc;
+ // Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ // Calculate board size
+ maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ // Close dialogs
+ if(nameInputDialog != null)
+ nameInputDialog.forceClose();
+ if(dialog != null)
+ dialog.forceClose();
+
+ // Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+ gameDuration = new Date();
+}
+
+var fillFound; // Set after a floodFill call to the number of blocks found
+var floodBoard; // Set to 1 if the floodFill reaches off that node
+
+// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
+function handleClick(x,y)
+{
+ if(gameCanvas == undefined){
+ console.log("But the game hasn't started yet!");
+ return;
+ }
+ var column = Math.floor(x/gameCanvas.blockSize);
+ var row = Math.floor(y/gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ // If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column,row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+
+function floodFill(column,row,type)
+{
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column,row)].type;
+
+ // Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; // Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown()
+{
+ // Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column,row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ // Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * gameCanvas.blockSize;
+ board[index(column - fallDist,row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+function victoryCheck()
+{
+ // Awards bonuses for no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+ // Checks for game over
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
+ gameDuration = new Date() - gameDuration;
+ if(nameInputDialog == null){
+ nameInputDialog = Qt.createQmlObject('import "."; import "samegame.js" as Logic; NameInputDialog{onAccepted: Logic.saveHighScore(name)}', gameCanvas, "highscoredialog.qml");
+ }
+ if(dialog == null){
+ dialog = Qt.createComponent("Dialog.qml").createObject(gameCanvas);
+ }
+ initHighScoreBar();
+ if(gameCanvas.score > highScoreBar){
+ nameInputDialog.show("You won! Please enter your name: ");
+ nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
+ if (nameInputDialog.name == "")
+ nameInputDialog.width = nameInputDialog.initialWidth;
+ nameInputDialog.text.opacity = 0; // Just a spacer
+ }else{
+ dialog.show("You won!");
+ }
+ }
+}
+
+// Only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type)
+{
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) ||
+ floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
+function createBlock(column,row)
+{
+ // Note that we don't wait for the component to become ready. This will
+ // only work if the block QML is a local file. Otherwise the component will
+ // not be ready immediately. There is a statusChanged signal on the
+ // component you could use if you want to wait to load remote files.
+ if(component.status == 1){
+ var dynamicObject = component.createObject(gameCanvas,
+ {"type": Math.floor(Math.random() * 3),
+ "x": column*gameCanvas.blockSize,
+ "width": gameCanvas.blockSize,
+ "height": gameCanvas.blockSize,
+ "particleSystem": gameCanvas.ps});
+ if(dynamicObject == null){
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.y = row*gameCanvas.blockSize;
+ dynamicObject.spawned = true;
+
+ board[index(column,row)] = dynamicObject;
+ }else{
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+function initHighScoreBar()
+{
+ var db = Sql.openDatabaseSync(
+ "SameGameScores",
+ "1.0",
+ "Local SameGame High Scores",
+ 100
+ );
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ // Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
+ + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10');
+ if(rs.rows.length < 10)
+ highScoreBar = 0;
+ else
+ highScoreBar = rs.rows.item(rs.rows.length - 1).score;
+ }
+ );
+}
+
+function saveHighScore(name)
+{
+ if (scoresURL != "")
+ sendHighScore(name);
+ // Offline storage
+ var db = Sql.openDatabaseSync(
+ "SameGameScores",
+ "1.0",
+ "Local SameGame High Scores",
+ 100
+ );
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [
+ name,
+ gameCanvas.score,
+ maxColumn + "x" + maxRow,
+ Math.floor(gameDuration / 1000)
+ ];
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+
+ // Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
+ + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for this grid size\n\n"
+ for (var i = 0; i < rs.rows.length; i++) {
+ r += (i+1) + ". " + rs.rows.item(i).name + ' got '
+ + rs.rows.item(i).score + ' points in '
+ + rs.rows.item(i).time + ' seconds.\n';
+ }
+ if(rs.rows.length == 10)
+ highScoreBar = rs.rows.item(9).score;
+ dialog.show(r);
+ }
+ );
+}
diff --git a/examples/qml/samegame/samegame.qml b/examples/qml/samegame/samegame.qml
new file mode 100644
index 0000000000..b98b6a0074
--- /dev/null
+++ b/examples/qml/samegame/samegame.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+import "content/samegame.js" as Logic
+
+Rectangle {
+ id: screen
+ width: 480; height: 640
+
+ SystemPalette { id: activePalette }
+
+ GameArea {
+ id: gameCanvas
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 80
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ id: newGameButton
+ anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: Logic.startNewGame(gameCanvas)
+ }
+
+ Button {
+ text: "Quit"
+ anchors { left: newGameButton.right; leftMargin: 12; verticalCenter: parent.verticalCenter }
+ onClicked: Qt.quit();
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ font.bold: true
+ font.pixelSize: 24
+ color: activePalette.windowText
+ }
+ }
+}
diff --git a/examples/qml/samegame/samegame.qmlproject b/examples/qml/samegame/samegame.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/qml/samegame/samegame.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/script/shell/main.cpp b/examples/qml/script/shell/main.cpp
index 9f0edf4a25..a4059122bf 100644
--- a/examples/qml/script/shell/main.cpp
+++ b/examples/qml/script/shell/main.cpp
@@ -46,7 +46,7 @@
#include <QtGui/QGuiApplication>
-#include <QtDeclarative/qjsengine.h>
+#include <QtQml/qjsengine.h>
#include <stdlib.h>
diff --git a/examples/qml/script/shell/shell.pro b/examples/qml/script/shell/shell.pro
index 00191ab3d0..5f6b23862b 100644
--- a/examples/qml/script/shell/shell.pro
+++ b/examples/qml/script/shell/shell.pro
@@ -1,4 +1,4 @@
-QT += declarative
+QT += qml
win32: CONFIG += console
mac:CONFIG -= app_bundle
diff --git a/examples/qtquick/shadereffects/content/Slider.qml b/examples/qml/shadereffects/content/Slider.qml
index 4ddc6d3432..4ddc6d3432 100644
--- a/examples/qtquick/shadereffects/content/Slider.qml
+++ b/examples/qml/shadereffects/content/Slider.qml
diff --git a/examples/qml/shadereffects/content/face-smile.png b/examples/qml/shadereffects/content/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/qml/shadereffects/content/face-smile.png
Binary files differ
diff --git a/examples/qtquick/shadereffects/content/qt-logo.png b/examples/qml/shadereffects/content/qt-logo.png
index 7d3e97eb36..7d3e97eb36 100644
--- a/examples/qtquick/shadereffects/content/qt-logo.png
+++ b/examples/qml/shadereffects/content/qt-logo.png
Binary files differ
diff --git a/examples/qml/shadereffects/shadereffects.qml b/examples/qml/shadereffects/shadereffects.qml
new file mode 100644
index 0000000000..842e42b89f
--- /dev/null
+++ b/examples/qml/shadereffects/shadereffects.qml
@@ -0,0 +1,300 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Image {
+ width: 640
+ height: 360
+ source: "../snake/content/pics/background.png"
+
+ ShaderEffectSource {
+ id: theSource
+ sourceItem: theItem
+ smooth: true
+ }
+
+ function saturate(x) {
+ return Math.min(Math.max(x, 0), 1)
+ }
+
+ function sliderToColor(x) {
+ return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)),
+ saturate(Math.min(6 * x, 4 - 6 * x)),
+ saturate(Math.min(6 * x - 2, 6 - 6 * x)))
+ }
+
+ Grid {
+ anchors.centerIn: parent
+ columns: 3
+
+ Item {
+ id: theItem
+ width: 180
+ height: 180
+ ListView {
+ anchors.centerIn: parent
+ width: 160
+ height: 140
+ clip: true
+ snapMode: ListView.SnapOneItem
+ model: VisualItemModel {
+ Text {
+ width: 160
+ height: 140
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 120
+ font.family: "Times"
+ color: "blue"
+ text: "Qt"
+ }
+ Image {
+ width: 160
+ height: 140
+ source: "content/qt-logo.png"
+ smooth: true
+ }
+ Image {
+ width: 160
+ height: 140
+ source: "content/face-smile.png"
+ smooth: true
+ }
+ }
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property real amplitude: 0.04 * wobbleSlider.value
+ property real frequency: 20
+ property real time: 0
+ NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
+ fragmentShader:
+ "uniform lowp float qt_Opacity;" +
+ "uniform highp float amplitude;" +
+ "uniform highp float frequency;" +
+ "uniform highp float time;" +
+ "uniform sampler2D source;" +
+ "varying highp vec2 qt_TexCoord0;" +
+ "void main() {" +
+ " highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
+ " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" +
+ "}"
+ Slider {
+ id: wobbleSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property variant shadow: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(0.0, 1.0 / height)
+ property variant source: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(1.0 / width, 0.0)
+ property variant source: theSource
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ property real angle: 0
+ property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle))
+ NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 }
+ property variant delta: Qt.size(offset.x / width, offset.y / height)
+ property real darkness: shadowSlider.value
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform highp vec2 offset;
+ uniform sampler2D source;
+ uniform sampler2D shadow;
+ uniform highp float darkness;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 fg = texture2D(source, qt_TexCoord0);
+ lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta);
+ gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity;
+ }"
+ Slider {
+ id: shadowSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property variant delta: Qt.size(0.5 / width, 0.5 / height)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ uniform highp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta);
+ lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y));
+ lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y));
+ lowp vec4 br = texture2D(source, qt_TexCoord0 + delta);
+ lowp vec4 gx = (tl + bl) - (tr + br);
+ lowp vec4 gy = (tl + tr) - (bl + br);
+ gl_FragColor.xyz = vec3(0.);
+ gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity;
+ }"
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property color tint: sliderToColor(colorizeSlider.value)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp vec4 tint;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 c = texture2D(source, qt_TexCoord0);
+ lowp float lo = min(min(c.x, c.y), c.z);
+ lowp float hi = max(max(c.x, c.y), c.z);
+ gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w);
+ }"
+ Slider {
+ id: colorizeSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ mesh: Qt.size(10, 10)
+ property variant source: theSource
+ property real bend: 0
+ property real minimize: 0
+ property real side: genieSlider.value
+ SequentialAnimation on bend {
+ loops: Animation.Infinite
+ NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1600 }
+ NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1000 }
+ }
+ SequentialAnimation on minimize {
+ loops: Animation.Infinite
+ PauseAnimation { duration: 300 }
+ NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1300 }
+ }
+ vertexShader: "
+ uniform highp mat4 qt_Matrix;
+ uniform highp float bend;
+ uniform highp float minimize;
+ uniform highp float side;
+ uniform highp float width;
+ uniform highp float height;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ qt_TexCoord0 = qt_MultiTexCoord0;
+ highp vec4 pos = qt_Vertex;
+ pos.y = mix(qt_Vertex.y, height, minimize);
+ highp float t = pos.y / height;
+ t = (3. - 2. * t) * t * t;
+ pos.x = mix(qt_Vertex.x, side * width, t * bend);
+ gl_Position = qt_Matrix * pos;
+ }"
+ Slider {
+ id: genieSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ }
+}
diff --git a/examples/qml/shared/Button.qml b/examples/qml/shared/Button.qml
new file mode 100644
index 0000000000..a899a1410b
--- /dev/null
+++ b/examples/qml/shared/Button.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property string text: "Button"
+ property string subText: "Just a button"
+ signal clicked
+
+ width: buttonLabel.width + 20; height: col.height + 12
+
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+ Column {
+ spacing: 2
+ id: col
+ Text {
+ id: buttonLabel; text: container.text; color: "black"; font.pixelSize: 24
+ }
+ Text {
+ id: buttonLabel2; text: container.subText; color: "black"; font.pixelSize: 12
+ }
+ }
+}
diff --git a/examples/qml/shared/LauncherList.qml b/examples/qml/shared/LauncherList.qml
new file mode 100644
index 0000000000..782fcc7ddd
--- /dev/null
+++ b/examples/qml/shared/LauncherList.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+ListView {
+ //model is a list of {"name":"somename", "url":"file:///some/url/mainfile.qml"}
+ //function used to add to model A) to enforce scheme B) to allow Qt.resolveUrl in url assignments
+ function addExample(name, desc, url)
+ {
+ myModel.append({"name":name, "description":desc, "url":url})
+ }
+ function hideExample()
+ {
+ ei.visible = false;
+ }
+
+ clip: true
+ delegate: SimpleLauncherDelegate{exampleItem: ei}
+ model: ListModel {id:myModel}
+ Item {
+ id: ei
+ visible: false
+ clip: true
+ property url exampleUrl
+ onExampleUrlChanged: visible = (exampleUrl == '' ? false : true);//Setting exampleUrl automatically shows example
+ anchors.fill: parent
+ anchors.bottomMargin: 40
+ Rectangle {
+ id: bg
+ anchors.fill: parent
+ color: "white"
+ }
+ MouseArea{
+ anchors.fill: parent
+ enabled: ei.visible
+ //Eats mouse events
+ }
+ Loader{
+ source: ei.exampleUrl
+ anchors.fill: parent
+ }
+ }
+ Rectangle {
+ id: bar
+ visible: ei.visible
+ anchors.bottom: parent.bottom
+ width: parent.width
+ height: 40
+ MouseArea{
+ anchors.fill: parent
+ enabled: ei.visible
+ //Eats mouse events
+ }
+ Image {
+ source: "back.png"
+ anchors.verticalCenter: parent.verticalCenter
+ x: 4
+ MouseArea {
+ anchors.fill: parent
+ onClicked: ei.exampleUrl = "";
+ }
+ }
+ }
+}
diff --git a/examples/qml/shared/README b/examples/qml/shared/README
new file mode 100644
index 0000000000..bf16f238c7
--- /dev/null
+++ b/examples/qml/shared/README
@@ -0,0 +1,11 @@
+These files are shared between multiple examples as a set of common and
+reusuable components. While they do demonstrate the building of reusable
+components in QML, they are not official examples themselves.
+Consequently they do not have entries in the Qt documentation, and are
+documented only through the code comments within the files. Developers
+new to QML are strongly encouraged to go through the official examples
+before delving into this directory.
+
+For most application use, see the Qt Quick Components project to find
+ready-made Components you can use in your own projects. Qt Declarative
+examples do not use them only to avoid external dependencies.
diff --git a/examples/qml/shared/SimpleLauncherDelegate.qml b/examples/qml/shared/SimpleLauncherDelegate.qml
new file mode 100644
index 0000000000..c3708fe259
--- /dev/null
+++ b/examples/qml/shared/SimpleLauncherDelegate.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ id: container
+ property Item exampleItem
+ width: ListView.view.width
+ height: 64
+ Button {
+ anchors.fill: parent
+ text: name
+ subText: description
+ onClicked: exampleItem.exampleUrl = url;
+ }
+}
diff --git a/examples/qml/shared/back.png b/examples/qml/shared/back.png
new file mode 100644
index 0000000000..506ac42fcf
--- /dev/null
+++ b/examples/qml/shared/back.png
Binary files differ
diff --git a/examples/qml/snake/content/Button.qml b/examples/qml/snake/content/Button.qml
new file mode 100644
index 0000000000..4f294556b3
--- /dev/null
+++ b/examples/qml/snake/content/Button.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ signal clicked
+ property string text: "Button"
+
+ color: activePalette.button; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ }
+}
diff --git a/examples/qml/snake/content/Cookie.qml b/examples/qml/snake/content/Cookie.qml
new file mode 100644
index 0000000000..35ffe400b8
--- /dev/null
+++ b/examples/qml/snake/content/Cookie.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: root
+ property bool dying: false
+ property int row;
+ property int column;
+ x: margin + column * gridSize
+ y: margin + row * gridSize
+
+ width: gridSize
+ height: gridSize
+ property int value : 1;
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "pics/cookie.png"
+ opacity: 0
+ Text {
+ font.bold: true
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: value
+ }
+ }
+
+
+ ParticleSystem {
+ width:1; height:1; anchors.centerIn: parent;
+ ImageParticle {
+ groups: ["star"]
+ source: "pics/yellowStar.png"
+ }
+ Emitter {
+ id: particles
+ anchors.fill: parent
+ group: "star"
+ emitRate: 50
+ enabled: false
+ lifeSpan: 700
+ acceleration: AngleDirection { angleVariation: 360; magnitude: 200 }
+ }
+ }
+
+ states: [
+ State{ name: "AliveState"; when: dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+ State{ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ }
+ ]
+ transitions: [
+ Transition {
+ NumberAnimation { target: img; property: "opacity"; duration: 100 }
+ }
+ ]
+}
diff --git a/examples/qml/snake/content/HighScoreModel.qml b/examples/qml/snake/content/HighScoreModel.qml
new file mode 100644
index 0000000000..734a661f5b
--- /dev/null
+++ b/examples/qml/snake/content/HighScoreModel.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.LocalStorage 2.0 as Sql
+
+// Models a high score table.
+//
+// Use this component like this:
+//
+// HighScoreModel {
+// id: highScores
+// game: "MyCoolGame"
+// }
+//
+// Then use either use the top-score properties:
+//
+// Text { text: "HI: " + highScores.topScore }
+//
+// or, use the model in a view:
+//
+// ListView {
+// model: highScore
+// delegate: Component {
+// ... player ... score ...
+// }
+// }
+//
+// Add new scores via:
+//
+// saveScore(newScore)
+//
+// or:
+//
+// savePlayerScore(playerName,newScore)
+//
+// The best maxScore scores added by this method will be retained in an SQL database,
+// and presented in the model and in the topScore/topPlayer properties.
+//
+
+ListModel {
+ id: model
+ property string game: ""
+ property int topScore: 0
+ property string topPlayer: ""
+ property int maxScores: 10
+
+ function __db()
+ {
+ return Sql.openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000);
+ }
+ function __ensureTables(tx)
+ {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []);
+ }
+
+ function fillModel() {
+ __db().transaction(
+ function(tx) {
+ __ensureTables(tx);
+ var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]);
+ model.clear();
+ if (rs.rows.length > 0) {
+ topScore = rs.rows.item(0).score
+ topPlayer = rs.rows.item(0).player
+ for (var i=0; i<rs.rows.length; ++i) {
+ if (i < maxScores)
+ model.append(rs.rows.item(i))
+ }
+ if (rs.rows.length > maxScores)
+ tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?",
+ [game, rs.rows.item(maxScores).score]);
+ }
+ }
+ )
+ }
+
+ function savePlayerScore(player,score) {
+ __db().transaction(
+ function(tx) {
+ __ensureTables(tx);
+ tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]);
+ fillModel();
+ }
+ )
+ }
+
+ function saveScore(score) {
+ savePlayerScore("player",score);
+ }
+
+ function clearScores() {
+ __db().transaction(
+ function(tx) {
+ tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]);
+ fillModel();
+ }
+ )
+ }
+
+ Component.onCompleted: { fillModel() }
+}
diff --git a/examples/qml/snake/content/Link.qml b/examples/qml/snake/content/Link.qml
new file mode 100644
index 0000000000..aab005afd5
--- /dev/null
+++ b/examples/qml/snake/content/Link.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item { id:link
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property int row: 0
+ property int column: 0
+ property int rotation;
+
+ width: 40;
+ height: 40
+
+ x: margin - 3 + gridSize * column
+ y: margin - 3 + gridSize * row
+ Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} }
+ Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } }
+
+
+ Item {
+ id: img
+ anchors.fill: parent
+ Image {
+ source: {
+ if(type == 1) {
+ "pics/blueStone.png";
+ } else if (type == 2) {
+ "pics/head.png";
+ } else {
+ "pics/redStone.png";
+ }
+ }
+
+ transform: Rotation {
+ id: actualImageRotation
+ origin.x: width/2; origin.y: height/2;
+ angle: rotation * 90
+ Behavior on angle {
+ RotationAnimation{
+ direction: RotationAnimation.Shortest
+ duration: spawned ? 200 : 0
+ }
+ }
+ }
+ }
+
+ Image {
+ source: "pics/stoneShadow.png"
+ }
+
+ opacity: 0
+ }
+
+ ParticleSystem {
+ width:1; height:1; anchors.centerIn: parent;
+ ImageParticle {
+ groups: ["star"]
+ source: type == 1 ? "pics/blueStar.png" : "pics/redStar.png"
+ }
+ Emitter {
+ id: particles
+ anchors.fill: parent
+ group: "star"
+ emitRate: 50
+ enabled: false
+ lifeSpan: 700
+ acceleration: AngleDirection { angleVariation: 360; magnitude: 200 }
+ }
+ }
+
+ states: [
+ State{ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+ State{ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ NumberAnimation { target: img; property: "opacity"; duration: 200 }
+ }
+ ]
+
+}
diff --git a/examples/qml/snake/content/Skull.qml b/examples/qml/snake/content/Skull.qml
new file mode 100644
index 0000000000..e3f77fdac6
--- /dev/null
+++ b/examples/qml/snake/content/Skull.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ property bool spawned: false
+ property int row;
+ property int column;
+ property int verticalMovement;
+ property int horizontalMovement;
+
+ x: margin + column * gridSize + 2
+ y: margin + row * gridSize - 3
+ Behavior on x { NumberAnimation { duration: spawned ? halfbeatInterval : 0} }
+ Behavior on y { NumberAnimation { duration: spawned ? halfbeatInterval : 0 } }
+
+ opacity: spawned ? 1 : 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+
+ source: "pics/skull.png"
+ width: 24
+ height: 40
+}
diff --git a/examples/qml/snake/content/pics/README b/examples/qml/snake/content/pics/README
new file mode 100644
index 0000000000..0215132caa
--- /dev/null
+++ b/examples/qml/snake/content/pics/README
@@ -0,0 +1 @@
+snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo.
diff --git a/examples/qml/snake/content/pics/background.png b/examples/qml/snake/content/pics/background.png
new file mode 100644
index 0000000000..72dffaa843
--- /dev/null
+++ b/examples/qml/snake/content/pics/background.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/blueStar.png b/examples/qml/snake/content/pics/blueStar.png
new file mode 100644
index 0000000000..ba7acabd26
--- /dev/null
+++ b/examples/qml/snake/content/pics/blueStar.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/blueStone.png b/examples/qml/snake/content/pics/blueStone.png
new file mode 100644
index 0000000000..356affdd95
--- /dev/null
+++ b/examples/qml/snake/content/pics/blueStone.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/cookie.png b/examples/qml/snake/content/pics/cookie.png
new file mode 100644
index 0000000000..aec2957f34
--- /dev/null
+++ b/examples/qml/snake/content/pics/cookie.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/eyes.svg b/examples/qml/snake/content/pics/eyes.svg
new file mode 100644
index 0000000000..1078692725
--- /dev/null
+++ b/examples/qml/snake/content/pics/eyes.svg
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ width="40"
+ height="40"
+ version="1.0"
+ sodipodi:docname="eyes.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs5">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective9" />
+ </defs>
+ <sodipodi:namedview
+ inkscape:window-height="838"
+ inkscape:window-width="907"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="12.35"
+ inkscape:cx="20"
+ inkscape:cy="20"
+ inkscape:window-x="117"
+ inkscape:window-y="45"
+ inkscape:current-layer="svg2" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2384"
+ sodipodi:cx="18.056681"
+ sodipodi:cy="9.5141697"
+ sodipodi:rx="7.1255059"
+ sodipodi:ry="11.295547"
+ d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
+ transform="matrix(1.0089865,0,0,0.5462656,-4.9233835,3.3301401)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path3158"
+ sodipodi:cx="18.056681"
+ sodipodi:cy="9.5141697"
+ sodipodi:rx="7.1255059"
+ sodipodi:ry="11.295547"
+ d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
+ transform="matrix(1.0089865,0,0,0.5462656,9.6190931,3.3522563)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1"
+ id="path3182"
+ sodipodi:cx="16.275303"
+ sodipodi:cy="12.307693"
+ sodipodi:rx="2.2672064"
+ sodipodi:ry="3.4008098"
+ d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
+ sodipodi:start="0"
+ sodipodi:end="3.1240432"
+ transform="translate(11.65992,-9.740891)"
+ sodipodi:open="true" />
+ <rect
+ style="fill:#000000;fill-opacity:0"
+ id="rect2382"
+ width="40"
+ height="40"
+ x="0"
+ y="-7.1054274e-15"
+ inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1"
+ id="path2383"
+ sodipodi:cx="16.275303"
+ sodipodi:cy="12.307693"
+ sodipodi:rx="2.2672064"
+ sodipodi:ry="3.4008098"
+ d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
+ sodipodi:start="0"
+ sodipodi:end="3.1240432"
+ transform="translate(-3.3200119,-9.821862)"
+ sodipodi:open="true" />
+</svg>
diff --git a/examples/qml/snake/content/pics/head.png b/examples/qml/snake/content/pics/head.png
new file mode 100644
index 0000000000..550e002687
--- /dev/null
+++ b/examples/qml/snake/content/pics/head.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/pause.png b/examples/qml/snake/content/pics/pause.png
new file mode 100644
index 0000000000..056d97dd17
--- /dev/null
+++ b/examples/qml/snake/content/pics/pause.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/redStar.png b/examples/qml/snake/content/pics/redStar.png
new file mode 100644
index 0000000000..cd06854719
--- /dev/null
+++ b/examples/qml/snake/content/pics/redStar.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/redStone.png b/examples/qml/snake/content/pics/redStone.png
new file mode 100644
index 0000000000..9bb7fe4277
--- /dev/null
+++ b/examples/qml/snake/content/pics/redStone.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/skull.png b/examples/qml/snake/content/pics/skull.png
new file mode 100644
index 0000000000..63186167bd
--- /dev/null
+++ b/examples/qml/snake/content/pics/skull.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/snake.jpg b/examples/qml/snake/content/pics/snake.jpg
new file mode 100644
index 0000000000..e91a784f71
--- /dev/null
+++ b/examples/qml/snake/content/pics/snake.jpg
Binary files differ
diff --git a/examples/qml/snake/content/pics/star.png b/examples/qml/snake/content/pics/star.png
new file mode 100644
index 0000000000..defbde53ca
--- /dev/null
+++ b/examples/qml/snake/content/pics/star.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/stoneShadow.png b/examples/qml/snake/content/pics/stoneShadow.png
new file mode 100644
index 0000000000..1bd56afd04
--- /dev/null
+++ b/examples/qml/snake/content/pics/stoneShadow.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/yellowStar.png b/examples/qml/snake/content/pics/yellowStar.png
new file mode 100644
index 0000000000..52fb9c4b78
--- /dev/null
+++ b/examples/qml/snake/content/pics/yellowStar.png
Binary files differ
diff --git a/examples/qml/snake/content/pics/yellowStone.png b/examples/qml/snake/content/pics/yellowStone.png
new file mode 100644
index 0000000000..c56124a895
--- /dev/null
+++ b/examples/qml/snake/content/pics/yellowStone.png
Binary files differ
diff --git a/examples/qml/snake/content/snake.js b/examples/qml/snake/content/snake.js
new file mode 100644
index 0000000000..107c9f4591
--- /dev/null
+++ b/examples/qml/snake/content/snake.js
@@ -0,0 +1,316 @@
+
+var snake = new Array;
+var board = new Array;
+var links = new Array;
+var scheduledDirections = new Array;
+var numRows = 1;
+var numColumns = 1;
+var linkComponent = Qt.createComponent("Link.qml");
+var cookieComponent = Qt.createComponent("Cookie.qml");
+var cookie;
+var linksToGrow = 0;
+var linksToDie = 0;
+var waitForCookie = 0;
+var growType = 0;
+var skullMovementsBeforeDirectionChange = 0;
+
+
+function rand(n)
+{
+ return (Math.floor(Math.random() * n));
+}
+
+function scheduleDirection(dir)
+{
+ if (state == "starting") {
+ direction = dir;
+ headDirection = direction;
+ head.rotation = headDirection;
+ } else if (state == "running"){
+ direction = dir;
+ if(scheduledDirections[scheduledDirections.length-1]!=direction)
+ scheduledDirections.push(direction);
+ }
+}
+
+function startNewGame()
+{
+ if (state == "starting") {
+ return;
+ }
+
+ if (activeGame) {
+ endGame();
+ startNewGameTimer.running = true;
+ return;
+ }
+
+ state = "starting";
+
+ numRows = numRowsAvailable;
+ numColumns = numColumnsAvailable;
+ board = new Array(numRows * numColumns);
+ snake = new Array;
+ scheduledDirections = new Array;
+ growType = 0;
+
+ skull.z = numRows * numColumns + 1;
+
+ for (var i = 0; i < numRows * numColumns; ++i) {
+ if (i < links.length) {
+ var link = links[i];
+ link.spawned = false;
+ link.dying = false;
+ } else {
+ if(linkComponent.status != Component.Ready) {
+ if(linkComponent.status == Component.Error)
+ console.log(linkComponent.errorString());
+ else
+ console.log("Still loading linkComponent");
+ continue;//TODO: Better error handling?
+ }
+ var link = linkComponent.createObject(playfield);
+ link.z = numRows * numColumns + 1 - i;
+ link.type = i == 0 ? 2 : 0;
+ link.spawned = false;
+ link.dying = false;
+ links.push(link);
+ }
+ }
+
+ head = links[0];
+ snake.push(head);
+ head.row = numRows/2 -1;
+ head.column = numColumns/2 -1;
+ head.spawned = true;
+
+ linksToGrow = 5;
+ linksToDie = 0;
+ waitForCookie = 5;
+ score = 0;
+ startHeartbeatTimer.running = true;
+}
+
+function endGame()
+{
+ activeGame = false;
+ for(var i in snake)
+ snake[i].dying = true;
+ if (cookie) {
+ cookie.dying = true;
+ cookie = 0;
+ }
+ lastScore = score;
+ highScores.saveScore(lastScore);
+ state = "";
+}
+
+function move() {
+
+ if (!head)
+ return;
+
+ var dir = direction;
+
+ if (scheduledDirections.length) {
+ dir = scheduledDirections.shift();
+ }
+
+ if (state == "starting") {
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+ return;
+ }
+
+ var row = head.row;
+ var column = head.column;
+
+ if (dir == 0) {
+ row = row - 1;
+ } else if (dir == 1) {
+ column = column + 1
+ } else if (dir == 2) {
+ row = row + 1;
+ } else if (dir == 3) {
+ column = column - 1;
+ }
+
+ //validate the new position
+ if (row < 0 || row >= numRows
+ || column < 0 || column >= numColumns
+ || (row == skull.row && column == skull.column)
+ || !isFree(row, column)) {
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+ endGame();
+ return;
+ }
+
+ var newLink;
+ if (linksToGrow > 0) {
+ --linksToGrow;
+ newLink = links[snake.length];
+ newLink.spawned = false;
+ newLink.rotation = snake[snake.length-1].rotation;
+ newLink.type = growType;
+ newLink.dying = false;
+ snake.push(newLink);
+ } else {
+ var lastLink = snake[snake.length-1];
+ board[lastLink.row * numColumns + lastLink.column] = undefined;
+ }
+
+ if (waitForCookie > 0) {
+ if (--waitForCookie == 0)
+ createCookie(cookie? (cookie.value+1) : 1);
+ }
+
+ for (var i = snake.length-1; i > 0; --i) {
+ snake[i].row = snake[i-1].row;
+ snake[i].column = snake[i-1].column;
+ snake[i].rotation = snake[i-1].rotation;
+ }
+
+ if (newLink) {
+ newLink.spawned = true;
+ }
+
+ // move the head
+ head.row = row;
+ head.column = column;
+ board[row * numColumns + column] = head;
+
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+
+ var value = testCookie(row, column);
+ if (value > 0) {
+ linksToGrow += value;
+ score += value;
+ }
+}
+
+function isFree(row, column)
+{
+ return board[row * numColumns + column] == undefined;
+}
+
+function isHead(row, column)
+{
+ return head.column == column && head.row == row;
+}
+
+function testCookie(row, column)
+{
+ if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) {
+ var value = cookie.value;
+ waitForCookie = value;
+ growType = snake[snake.length-1].type == 1 ? 0 : 1;
+ cookie.dying = true;
+ cookie.z = numRows * numColumns + 2;
+ return value;
+ }
+ return 0;
+}
+
+function moveSkull()
+{
+
+ if (linksToDie > 0) {
+ --linksToDie;
+ var link = snake.pop();
+ link.dying = true;
+ board[link.row * numColumns + link.column] = undefined;
+ if (score > 0)
+ --score;
+ if (snake.length == 0) {
+ endGame();
+ return;
+ }
+ }
+
+ var row = skull.row;
+ var column = skull.column;
+ if (isHead(row, column)) {
+ endGame();
+ return;
+ }
+ row += skull.verticalMovement;
+ column += skull.horizontalMovement;
+
+ var attempts = 4;
+
+ while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows
+ || column < 0 || column >= numColumns
+ || (!isFree(row, column) && !isHead(row, column))) {
+ var d = rand(8);
+ skull.verticalMovement = 0;
+ skull.horizontalMovement = 0;
+ skullMovementsBeforeDirectionChange = rand(20)+1;
+ if (d == 0) {
+ skull.verticalMovement = -1
+ } else if (d == 1) {
+ skull.horizontalMovement = -1;
+ } else if (d == 2) {
+ skull.verticalMovement = 1
+ } else if (d == 3){
+ skull.horizontalMovement = 1;
+ } else if (cookie) {
+ var rd = cookie.row - skull.row;
+ var rc = cookie.column - skull.column;
+ if (Math.abs(rd) > Math.abs(rc)) {
+ skull.verticalMovement = rd > 0 ? 1 : -1;
+ skullMovementsBeforeDirectionChange = Math.abs(rd);
+ } else {
+ skull.horizontalMovement= rc > 0 ? 1 : -1;
+ skullMovementsBeforeDirectionChange = Math.abs(rc);
+ }
+ }
+ row = skull.row + skull.verticalMovement;
+ column = skull.column + skull.horizontalMovement;
+ if (--attempts == 0)
+ return;
+ }
+
+ skull.row = row;
+ skull.column = column;
+ --skullMovementsBeforeDirectionChange;
+ var value = testCookie(row, column);
+ if (value > 0)
+ linksToDie += value/2;
+
+ if (isHead(row, column))
+ endGame();
+}
+
+function createCookie(value) {
+ if (numRows * numColumns - snake.length < 10)
+ return;
+
+ var column = rand(numColumns);
+ var row = rand(numRows);
+ while (!isFree(row, column)) {
+ column++;
+ if (column == numColumns) {
+ column = 0;
+ row++;
+ if (row == numRows)
+ row = 0;
+ }
+ }
+
+ if(cookieComponent.status != Component.Ready) {
+ if(cookieComponent.status == Component.Error)
+ console.log(cookieComponent.errorString());
+ else
+ console.log("Still loading cookieComponent");
+ return;//TODO: Better error handling?
+ }
+ cookie = cookieComponent.createObject(head.parent);
+ cookie.value = value;
+ cookie.row = row;
+ cookie.column = column;
+}
diff --git a/examples/qml/snake/snake.qml b/examples/qml/snake/snake.qml
new file mode 100644
index 0000000000..d389077bde
--- /dev/null
+++ b/examples/qml/snake/snake.qml
@@ -0,0 +1,272 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content" as Content
+import "content/snake.js" as Logic
+
+Rectangle {
+ id: screen;
+ SystemPalette { id: activePalette }
+ color: activePalette.window
+ property bool activeGame: false
+
+ property int gridSize : 34
+ property int margin: 4
+ property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize)
+ property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize)
+
+ property int lastScore : 0
+
+ property int score: 0;
+ property int heartbeatInterval: 200
+ property int halfbeatInterval: 160
+
+ width: 480
+ height: 750
+
+ property int direction
+ property int headDirection
+
+ property variant head;
+
+ Content.HighScoreModel {
+ id: highScores
+ game: "Snake"
+ }
+
+ Timer {
+ id: heartbeat;
+ interval: heartbeatInterval;
+ running: activeGame
+ repeat: true
+ onTriggered: { Logic.move() }
+ }
+ Timer {
+ id: halfbeat;
+ interval: halfbeatInterval;
+ repeat: true
+ running: heartbeat.running
+ onTriggered: { Logic.moveSkull() }
+ }
+ Timer {
+ id: startNewGameTimer;
+ interval: 700;
+ onTriggered: { Logic.startNewGame(); }
+ }
+
+ Timer {
+ id: startHeartbeatTimer;
+ interval: 1000 ;
+ onTriggered: { state = "running"; activeGame = true; }
+ }
+
+ Image{
+ id: pauseDialog
+ z: 1
+ source: "content/pics/pause.png"
+ anchors.centerIn: parent;
+ //opacity is deliberately not animated
+ opacity: 0 //Was !Qt.application.active && activeGame, but application doesn't work (QTBUG-23331)
+ }
+
+ Image {
+
+ Image {
+ id: title
+ source: "content/pics/snake.jpg"
+ fillMode: Image.PreserveAspectCrop
+ anchors.fill: parent
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+
+ Column {
+ spacing: 140
+ anchors.verticalCenter: parent.verticalCenter;
+ anchors.left: parent.left;
+ anchors.right: parent.right;
+
+ Text {
+ color: "white"
+ font.pointSize: 48
+ font.italic: true;
+ font.bold: true;
+ text: "Snake"
+ anchors.horizontalCenter: parent.horizontalCenter;
+ }
+
+ Text {
+ color: "white"
+ font.pointSize: 24
+ anchors.horizontalCenter: parent.horizontalCenter;
+ //horizontalAlignment: Text.AlignHCenter
+ text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore;
+ }
+ }
+ }
+
+ source: "content/pics/background.png"
+ fillMode: Image.PreserveAspectCrop
+
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: toolbar.top
+
+ Rectangle {
+ id: playfield
+ border.width: 1
+ border.color: "white"
+ color: "transparent"
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: (screen.height - 32 - height)/2;
+ width: numColumnsAvailable * gridSize + 2*margin
+ height: numRowsAvailable * gridSize + 2*margin
+
+
+ Content.Skull {
+ id: skull
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ if (screen.state == "") {
+ Logic.startNewGame();
+ return;
+ }
+ if (direction == 0 || direction == 2)
+ Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3);
+ else
+ Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0);
+ }
+ }
+ }
+
+ }
+
+ Rectangle {
+ id: progressBar
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ color: "transparent"
+ border.width: 2
+ border.color: "#221edd"
+ x: 50
+ y: 50
+ width: 200
+ height: 30
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: 40
+
+ Rectangle {
+ id: progressIndicator
+ color: "#221edd";
+ width: 0;
+ height: 30;
+ }
+ }
+
+ Rectangle {
+ id: toolbar
+ color: activePalette.window
+ height: 32; width: parent.width
+ anchors.bottom: screen.bottom
+
+ Content.Button {
+ id: btnA; text: "New Game"; onClicked: Logic.startNewGame();
+ anchors.left: parent.left; anchors.leftMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Content.Button {
+ text: "Quit"
+ anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ onClicked: Qt.quit();
+ }
+
+ Text {
+ color: activePalette.text
+ text: "Score: " + score; font.bold: true
+ anchors.right: parent.right; anchors.rightMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+
+ focus: true
+ Keys.onSpacePressed: Logic.startNewGame();
+ Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3);
+ Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1);
+ Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0);
+ Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2);
+
+ states: [
+ State {
+ name: "starting"
+ PropertyChanges {target: progressIndicator; width: 200}
+ PropertyChanges {target: title; opacity: 0}
+ PropertyChanges {target: progressBar; opacity: 1}
+ },
+ State {
+ name: "running"
+ PropertyChanges {target: progressIndicator; width: 200}
+ PropertyChanges {target: title; opacity: 0}
+ PropertyChanges {target: skull; row: 0; column: 0; }
+ PropertyChanges {target: skull; spawned: 1}
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "*"
+ to: "starting"
+ NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
+ NumberAnimation { property: "opacity"; duration: 200 }
+ },
+ Transition {
+ to: "starting"
+ NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
+ NumberAnimation { property: "opacity"; duration: 200 }
+ }
+ ]
+
+}
diff --git a/examples/qml/snake/snake.qmlproject b/examples/qml/snake/snake.qmlproject
new file mode 100644
index 0000000000..fb015465d1
--- /dev/null
+++ b/examples/qml/snake/snake.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "snake.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/sqllocalstorage/hello.qml b/examples/qml/sqllocalstorage/hello.qml
new file mode 100644
index 0000000000..3496b86bd9
--- /dev/null
+++ b/examples/qml/sqllocalstorage/hello.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import QtQuick 2.0
+import QtQuick.LocalStorage 2.0 as LS
+
+Rectangle {
+ color: "white"
+ width: 200
+ height: 100
+
+ Text {
+ text: "?"
+ anchors.horizontalCenter: parent.horizontalCenter
+ function findGreetings() {
+ var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000);
+
+ db.transaction(
+ function(tx) {
+ // Create the database if it doesn't already exist
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
+
+ // Add (another) greeting row
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+
+ // Show all added greetings
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+
+ var r = ""
+ for(var i = 0; i < rs.rows.length; i++) {
+ r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
+ }
+ text = r
+ }
+ )
+ }
+
+ Component.onCompleted: findGreetings()
+ }
+}
+//![0]
diff --git a/examples/qtquick/text/fonts/availableFonts.qml b/examples/qml/text/fonts/availableFonts.qml
index 0b87259556..0b87259556 100644
--- a/examples/qtquick/text/fonts/availableFonts.qml
+++ b/examples/qml/text/fonts/availableFonts.qml
diff --git a/examples/qtquick/text/fonts/banner.qml b/examples/qml/text/fonts/banner.qml
index 6c9aa25fa1..6c9aa25fa1 100644
--- a/examples/qtquick/text/fonts/banner.qml
+++ b/examples/qml/text/fonts/banner.qml
diff --git a/examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf b/examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf
index cf93f9651f..cf93f9651f 100644
--- a/examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf
+++ b/examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf
Binary files differ
diff --git a/examples/qtquick/text/fonts/fonts.qml b/examples/qml/text/fonts/fonts.qml
index 78cef25eae..78cef25eae 100644
--- a/examples/qtquick/text/fonts/fonts.qml
+++ b/examples/qml/text/fonts/fonts.qml
diff --git a/examples/qtquick/text/fonts/hello.qml b/examples/qml/text/fonts/hello.qml
index d9479fb208..d9479fb208 100644
--- a/examples/qtquick/text/fonts/hello.qml
+++ b/examples/qml/text/fonts/hello.qml
diff --git a/examples/qtquick/text/imgtag/TextWithImage.qml b/examples/qml/text/imgtag/TextWithImage.qml
index bc09aa2a52..bc09aa2a52 100644
--- a/examples/qtquick/text/imgtag/TextWithImage.qml
+++ b/examples/qml/text/imgtag/TextWithImage.qml
diff --git a/examples/qtquick/text/imgtag/images/face-sad.png b/examples/qml/text/imgtag/images/face-sad.png
index 24188b7985..24188b7985 100644
--- a/examples/qtquick/text/imgtag/images/face-sad.png
+++ b/examples/qml/text/imgtag/images/face-sad.png
Binary files differ
diff --git a/examples/qtquick/text/imgtag/images/face-smile-big.png b/examples/qml/text/imgtag/images/face-smile-big.png
index d05e0bf21e..d05e0bf21e 100644
--- a/examples/qtquick/text/imgtag/images/face-smile-big.png
+++ b/examples/qml/text/imgtag/images/face-smile-big.png
Binary files differ
diff --git a/examples/qtquick/text/imgtag/images/face-smile.png b/examples/qml/text/imgtag/images/face-smile.png
index e5e1d1353c..e5e1d1353c 100644
--- a/examples/qtquick/text/imgtag/images/face-smile.png
+++ b/examples/qml/text/imgtag/images/face-smile.png
Binary files differ
diff --git a/examples/qtquick/text/imgtag/images/heart200.png b/examples/qml/text/imgtag/images/heart200.png
index cedd3ea608..cedd3ea608 100644
--- a/examples/qtquick/text/imgtag/images/heart200.png
+++ b/examples/qml/text/imgtag/images/heart200.png
Binary files differ
diff --git a/examples/qtquick/text/imgtag/images/qtlogo.png b/examples/qml/text/imgtag/images/qtlogo.png
index 996719a4c6..996719a4c6 100644
--- a/examples/qtquick/text/imgtag/images/qtlogo.png
+++ b/examples/qml/text/imgtag/images/qtlogo.png
Binary files differ
diff --git a/examples/qtquick/text/imgtag/images/starfish_2.png b/examples/qml/text/imgtag/images/starfish_2.png
index 132c20ffd0..132c20ffd0 100644
--- a/examples/qtquick/text/imgtag/images/starfish_2.png
+++ b/examples/qml/text/imgtag/images/starfish_2.png
Binary files differ
diff --git a/examples/qtquick/text/imgtag/imgtag.qml b/examples/qml/text/imgtag/imgtag.qml
index 9d181af2cb..9d181af2cb 100644
--- a/examples/qtquick/text/imgtag/imgtag.qml
+++ b/examples/qml/text/imgtag/imgtag.qml
diff --git a/examples/qtquick/text/styledtext-layout.qml b/examples/qml/text/styledtext-layout.qml
index 4571330568..4571330568 100644
--- a/examples/qtquick/text/styledtext-layout.qml
+++ b/examples/qml/text/styledtext-layout.qml
diff --git a/examples/qml/text/text.qml b/examples/qml/text/text.qml
new file mode 100644
index 0000000000..14a88d2e91
--- /dev/null
+++ b/examples/qml/text/text.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../shared"
+
+Item {
+ height: 480
+ width: 480
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Hello", "An Animated Hello World", Qt.resolvedUrl("fonts/hello.qml"));
+ addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml"));
+ addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml"));
+ addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml"));
+ }
+ }
+}
diff --git a/examples/qtquick/text/text.qmlproject b/examples/qml/text/text.qmlproject
index c08d9b9a89..c08d9b9a89 100644
--- a/examples/qtquick/text/text.qmlproject
+++ b/examples/qml/text/text.qmlproject
diff --git a/examples/qtquick/text/textselection/pics/endHandle.png b/examples/qml/text/textselection/pics/endHandle.png
index 1a4bc5d7a0..1a4bc5d7a0 100644
--- a/examples/qtquick/text/textselection/pics/endHandle.png
+++ b/examples/qml/text/textselection/pics/endHandle.png
Binary files differ
diff --git a/examples/qtquick/text/textselection/pics/endHandle.sci b/examples/qml/text/textselection/pics/endHandle.sci
index 4f51f24278..4f51f24278 100644
--- a/examples/qtquick/text/textselection/pics/endHandle.sci
+++ b/examples/qml/text/textselection/pics/endHandle.sci
diff --git a/examples/qtquick/text/textselection/pics/startHandle.png b/examples/qml/text/textselection/pics/startHandle.png
index deedcd5c91..deedcd5c91 100644
--- a/examples/qtquick/text/textselection/pics/startHandle.png
+++ b/examples/qml/text/textselection/pics/startHandle.png
Binary files differ
diff --git a/examples/qtquick/text/textselection/pics/startHandle.sci b/examples/qml/text/textselection/pics/startHandle.sci
index f9eae204c1..f9eae204c1 100644
--- a/examples/qtquick/text/textselection/pics/startHandle.sci
+++ b/examples/qml/text/textselection/pics/startHandle.sci
diff --git a/examples/qtquick/text/textselection/textselection.qml b/examples/qml/text/textselection/textselection.qml
index 7938ce5bf7..7938ce5bf7 100644
--- a/examples/qtquick/text/textselection/textselection.qml
+++ b/examples/qml/text/textselection/textselection.qml
diff --git a/examples/qtquick/threading/threadedlistmodel/dataloader.js b/examples/qml/threading/threadedlistmodel/dataloader.js
index 4d2aab323d..4d2aab323d 100644
--- a/examples/qtquick/threading/threadedlistmodel/dataloader.js
+++ b/examples/qml/threading/threadedlistmodel/dataloader.js
diff --git a/examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject
index e7c8e69f14..e7c8e69f14 100644
--- a/examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject
+++ b/examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject
diff --git a/examples/qtquick/threading/threadedlistmodel/timedisplay.qml b/examples/qml/threading/threadedlistmodel/timedisplay.qml
index 48d0f659e5..48d0f659e5 100644
--- a/examples/qtquick/threading/threadedlistmodel/timedisplay.qml
+++ b/examples/qml/threading/threadedlistmodel/timedisplay.qml
diff --git a/examples/qtquick/threading/workerscript/workerscript.js b/examples/qml/threading/workerscript/workerscript.js
index f76471f920..f76471f920 100644
--- a/examples/qtquick/threading/workerscript/workerscript.js
+++ b/examples/qml/threading/workerscript/workerscript.js
diff --git a/examples/qtquick/threading/workerscript/workerscript.qml b/examples/qml/threading/workerscript/workerscript.qml
index 7fced8166c..7fced8166c 100644
--- a/examples/qtquick/threading/workerscript/workerscript.qml
+++ b/examples/qml/threading/workerscript/workerscript.qml
diff --git a/examples/qtquick/threading/workerscript/workerscript.qmlproject b/examples/qml/threading/workerscript/workerscript.qmlproject
index 6d7a91feeb..6d7a91feeb 100644
--- a/examples/qtquick/threading/workerscript/workerscript.qmlproject
+++ b/examples/qml/threading/workerscript/workerscript.qmlproject
diff --git a/examples/qtquick/mousearea/mousearea-example.qml b/examples/qml/touchinteraction/mousearea/mousearea-example.qml
index 30e3e62864..30e3e62864 100644
--- a/examples/qtquick/mousearea/mousearea-example.qml
+++ b/examples/qml/touchinteraction/mousearea/mousearea-example.qml
diff --git a/examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml b/examples/qml/touchinteraction/multipointtouch/bearwhack.qml
index db46473c05..db46473c05 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml
+++ b/examples/qml/touchinteraction/multipointtouch/bearwhack.qml
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml
index aede1a8f4e..aede1a8f4e 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml
+++ b/examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png b/examples/qml/touchinteraction/multipointtouch/content/Bear0.png
index 64a02cec8e..64a02cec8e 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png
+++ b/examples/qml/touchinteraction/multipointtouch/content/Bear0.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png b/examples/qml/touchinteraction/multipointtouch/content/Bear1.png
index 3b88f3b32e..3b88f3b32e 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png
+++ b/examples/qml/touchinteraction/multipointtouch/content/Bear1.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png b/examples/qml/touchinteraction/multipointtouch/content/Bear2.png
index 337b636070..337b636070 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png
+++ b/examples/qml/touchinteraction/multipointtouch/content/Bear2.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png b/examples/qml/touchinteraction/multipointtouch/content/Bear3.png
index f0e68590f4..f0e68590f4 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png
+++ b/examples/qml/touchinteraction/multipointtouch/content/Bear3.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/BearB.png b/examples/qml/touchinteraction/multipointtouch/content/BearB.png
index c9a84ae1d4..c9a84ae1d4 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/BearB.png
+++ b/examples/qml/touchinteraction/multipointtouch/content/BearB.png
Binary files differ
diff --git a/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml
new file mode 100644
index 0000000000..05d74ab0ea
--- /dev/null
+++ b/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ id: particleSystem
+ function explode(x,y) {
+ fireEmitter.burst(100,x,y);
+ }
+
+ Emitter {
+ id: emitter
+ group: "bears"
+ width: parent.width
+ emitRate: 1
+ NumberAnimation on emitRate {
+ id: goFaster
+ from: 1
+ to: 16
+ running: particleSystem.running
+ loops: 1
+ duration: 60000 * 5
+ easing.type: Easing.Linear
+ }
+ lifeSpan: 4000 + 800*(16-emitRate)
+ maximumEmitted: 128
+ size: 64
+ speed: PointDirection{ y: 40 + 10 * emitter.emitRate }
+ }
+
+ Emitter {
+ id: fireEmitter
+ enabled: false
+ maximumEmitted: 6000
+ group: "flame"
+ emitRate: 1000
+ size: 16
+ endSize: 8
+ speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 120;} PointDirection { y: -60 }}
+ lifeSpan: 400
+ }
+ Emitter {
+ id: heartEmitter
+ enabled: false
+ maximumEmitted: 6000
+ group: "hearts"
+ emitRate: 1000
+ size: 16
+ endSize: 8
+ speed: AngleDirection {angleVariation: 180; magnitudeVariation: 180;}
+ lifeSpan: 600
+ }
+ Emitter {
+ id: bloodEmitter
+ enabled: false
+ maximumEmitted: 6000
+ group: "blood"
+ emitRate: 1000
+ size: 16
+ endSize: 8
+ speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 80;} PointDirection { y: 40 }}
+ lifeSpan: 600
+ }
+
+ Affector {
+ width: parent.width
+ height: 64
+ once: true
+ y: parent.height - 32
+ groups: "bears"
+ onAffectParticles: {
+ for (var i=0;i<particles.length; i++) {
+ if (particles[i].animationIndex != 0) {
+ score++;
+ bloodEmitter.burst(100, particles[i].x, particles[i].y);
+ } else {
+ score--;
+ heartEmitter.burst(100, particles[i].x, particles[i].y);
+ }
+ particles[i].update = 1.0;
+ particles[i].t -= 1000.0;
+ }
+ }
+ }
+ ImageParticle {
+ groups: ["flame"]
+ source: "blur-circle.png"
+ z: 4
+ colorVariation: 0.1
+ color: "#ffa24d"
+ alpha: 0.4
+ }
+ ImageParticle {
+ groups: ["blood"]
+ color: "red"
+ z: 2
+ source: "blur-circle3.png"
+ alpha: 0.2
+ }
+ ImageParticle {
+ groups: ["hearts"]
+ color: "#ff66AA"
+ z: 3
+ source: "heart-blur.png"
+ alpha: 0.4
+ autoRotation: true
+ }
+ ImageParticle {
+ groups: ["bears"]
+ z: 1
+ spritesInterpolate: false
+ sprites:[
+ Sprite{
+ name: "floating"
+ source: "Bear1.png"
+ frames: 9
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 80
+ to: {"still":0, "flailing":0}
+ },
+ Sprite{
+ name: "flailing"
+ source: "Bear2.png"
+ frames: 8
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 80
+ to: {"falling":1}
+ },
+ Sprite{
+ name: "falling"
+ source: "Bear3.png"
+ frames: 5
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 80
+ to: {"falling":1}
+ }
+ ]
+ }
+}
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/ParticleFlame.qml b/examples/qml/touchinteraction/multipointtouch/content/ParticleFlame.qml
index 9788c5c665..9788c5c665 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/ParticleFlame.qml
+++ b/examples/qml/touchinteraction/multipointtouch/content/ParticleFlame.qml
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/blur-circle.png b/examples/qml/touchinteraction/multipointtouch/content/blur-circle.png
index 1b03cd0b2c..1b03cd0b2c 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/blur-circle.png
+++ b/examples/qml/touchinteraction/multipointtouch/content/blur-circle.png
Binary files differ
diff --git a/examples/qml/touchinteraction/multipointtouch/content/blur-circle3.png b/examples/qml/touchinteraction/multipointtouch/content/blur-circle3.png
new file mode 100644
index 0000000000..dbc39cb16e
--- /dev/null
+++ b/examples/qml/touchinteraction/multipointtouch/content/blur-circle3.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/heart-blur.png b/examples/qml/touchinteraction/multipointtouch/content/heart-blur.png
index dbc38804ee..dbc38804ee 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/heart-blur.png
+++ b/examples/qml/touchinteraction/multipointtouch/content/heart-blur.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/title.png b/examples/qml/touchinteraction/multipointtouch/content/title.png
index d630ea2643..d630ea2643 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/title.png
+++ b/examples/qml/touchinteraction/multipointtouch/content/title.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/multiflame.qml b/examples/qml/touchinteraction/multipointtouch/multiflame.qml
index 72a0ce21f8..72a0ce21f8 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/multiflame.qml
+++ b/examples/qml/touchinteraction/multipointtouch/multiflame.qml
diff --git a/examples/qtquick/touchinteraction/pincharea/flickresize.qml b/examples/qml/touchinteraction/pincharea/flickresize.qml
index 037766e4a0..037766e4a0 100644
--- a/examples/qtquick/touchinteraction/pincharea/flickresize.qml
+++ b/examples/qml/touchinteraction/pincharea/flickresize.qml
diff --git a/examples/qtquick/touchinteraction/pincharea/qt-logo.jpg b/examples/qml/touchinteraction/pincharea/qt-logo.jpg
index 4014b4659c..4014b4659c 100644
--- a/examples/qtquick/touchinteraction/pincharea/qt-logo.jpg
+++ b/examples/qml/touchinteraction/pincharea/qt-logo.jpg
Binary files differ
diff --git a/examples/qml/touchinteraction/touchinteraction.qml b/examples/qml/touchinteraction/touchinteraction.qml
new file mode 100644
index 0000000000..ac0c8bfc55
--- /dev/null
+++ b/examples/qml/touchinteraction/touchinteraction.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../shared"
+
+Item {
+ height: 480
+ width: 320
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("MouseArea", "Using the basic touch input element", Qt.resolvedUrl("mousearea/mousearea-example.qml"));
+ addExample("Multipoint Flames", "Create multiple flames with multiple fingers", Qt.resolvedUrl("multipointtouch/multiflame.qml"));
+ addExample("Bear-Whack", "Use multiple touches to knock all the bears down", Qt.resolvedUrl("multipointtouch/bearwhack.qml"));
+ addExample("Flick Resize", "Manipulate images using pinch gestures", Qt.resolvedUrl("pincharea/flickresize.qml"));
+ }
+ }
+}
diff --git a/examples/qtquick/touchinteraction/touchinteraction.qmlproject b/examples/qml/touchinteraction/touchinteraction.qmlproject
index a9aa9d2e81..a9aa9d2e81 100644
--- a/examples/qtquick/touchinteraction/touchinteraction.qmlproject
+++ b/examples/qml/touchinteraction/touchinteraction.qmlproject
diff --git a/examples/qml/toys/clocks/clocks.qml b/examples/qml/toys/clocks/clocks.qml
new file mode 100644
index 0000000000..288e50c9eb
--- /dev/null
+++ b/examples/qml/toys/clocks/clocks.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: root
+ width: 640; height: 320
+ color: "#646464"
+
+ ListView {
+ id: clockview
+ anchors.fill: parent
+ orientation: ListView.Horizontal
+ cacheBuffer: 2000
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.ApplyRange
+
+ delegate: Clock { city: cityName; shift: timeShift }
+ model: ListModel {
+ ListElement { cityName: "New York"; timeShift: -4 }
+ ListElement { cityName: "London"; timeShift: 0 }
+ ListElement { cityName: "Oslo"; timeShift: 1 }
+ ListElement { cityName: "Mumbai"; timeShift: 5.5 }
+ ListElement { cityName: "Tokyo"; timeShift: 9 }
+ ListElement { cityName: "Brisbane"; timeShift: 10 }
+ ListElement { cityName: "Los Angeles"; timeShift: -8 }
+ }
+ }
+
+ Image {
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ anchors.margins: 10
+ source: "content/arrow.png"
+ rotation: -90
+ opacity: clockview.atXBeginning ? 0 : 0.5
+ Behavior on opacity { NumberAnimation { duration: 500 } }
+ }
+
+ Image {
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.margins: 10
+ source: "content/arrow.png"
+ rotation: 90
+ opacity: clockview.atXEnd ? 0 : 0.5
+ Behavior on opacity { NumberAnimation { duration: 500 } }
+ }
+}
diff --git a/examples/qtquick/modelviews/parallax/content/Clock.qml b/examples/qml/toys/clocks/content/Clock.qml
index 7f0e8cba83..7f0e8cba83 100644
--- a/examples/qtquick/modelviews/parallax/content/Clock.qml
+++ b/examples/qml/toys/clocks/content/Clock.qml
diff --git a/examples/qtquick/modelviews/parallax/content/QuitButton.qml b/examples/qml/toys/clocks/content/QuitButton.qml
index 702b892d23..702b892d23 100644
--- a/examples/qtquick/modelviews/parallax/content/QuitButton.qml
+++ b/examples/qml/toys/clocks/content/QuitButton.qml
diff --git a/examples/qml/toys/clocks/content/arrow.png b/examples/qml/toys/clocks/content/arrow.png
new file mode 100644
index 0000000000..e437312217
--- /dev/null
+++ b/examples/qml/toys/clocks/content/arrow.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/background.png b/examples/qml/toys/clocks/content/background.png
index a885950862..a885950862 100644
--- a/examples/qtquick/modelviews/parallax/content/background.png
+++ b/examples/qml/toys/clocks/content/background.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/center.png b/examples/qml/toys/clocks/content/center.png
index 7fbd802a44..7fbd802a44 100644
--- a/examples/qtquick/modelviews/parallax/content/center.png
+++ b/examples/qml/toys/clocks/content/center.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/clock-night.png b/examples/qml/toys/clocks/content/clock-night.png
index cc7151a397..cc7151a397 100644
--- a/examples/qtquick/modelviews/parallax/content/clock-night.png
+++ b/examples/qml/toys/clocks/content/clock-night.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/clock.png b/examples/qml/toys/clocks/content/clock.png
index 462edacc0e..462edacc0e 100644
--- a/examples/qtquick/modelviews/parallax/content/clock.png
+++ b/examples/qml/toys/clocks/content/clock.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/hour.png b/examples/qml/toys/clocks/content/hour.png
index f8061a1235..f8061a1235 100644
--- a/examples/qtquick/modelviews/parallax/content/hour.png
+++ b/examples/qml/toys/clocks/content/hour.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/minute.png b/examples/qml/toys/clocks/content/minute.png
index 1297ec7c2b..1297ec7c2b 100644
--- a/examples/qtquick/modelviews/parallax/content/minute.png
+++ b/examples/qml/toys/clocks/content/minute.png
Binary files differ
diff --git a/examples/qml/toys/clocks/content/quit.png b/examples/qml/toys/clocks/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/qml/toys/clocks/content/quit.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/content/second.png b/examples/qml/toys/clocks/content/second.png
index 4aa9fb5e8e..4aa9fb5e8e 100644
--- a/examples/qtquick/modelviews/parallax/content/second.png
+++ b/examples/qml/toys/clocks/content/second.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/flickable/content/Day.qml b/examples/qml/toys/corkboards/content/Day.qml
index 7fe625c305..7fe625c305 100644
--- a/examples/qtquick/touchinteraction/flickable/content/Day.qml
+++ b/examples/qml/toys/corkboards/content/Day.qml
diff --git a/examples/qtquick/touchinteraction/flickable/content/cork.jpg b/examples/qml/toys/corkboards/content/cork.jpg
index 160bc002bf..160bc002bf 100644
--- a/examples/qtquick/touchinteraction/flickable/content/cork.jpg
+++ b/examples/qml/toys/corkboards/content/cork.jpg
Binary files differ
diff --git a/examples/qtquick/touchinteraction/flickable/content/note-yellow.png b/examples/qml/toys/corkboards/content/note-yellow.png
index 8ddecc8b03..8ddecc8b03 100644
--- a/examples/qtquick/touchinteraction/flickable/content/note-yellow.png
+++ b/examples/qml/toys/corkboards/content/note-yellow.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/flickable/content/tack.png b/examples/qml/toys/corkboards/content/tack.png
index cef2d1cd23..cef2d1cd23 100644
--- a/examples/qtquick/touchinteraction/flickable/content/tack.png
+++ b/examples/qml/toys/corkboards/content/tack.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/flickable/corkboards.qml b/examples/qml/toys/corkboards/corkboards.qml
index dc3aa6b378..dc3aa6b378 100644
--- a/examples/qtquick/touchinteraction/flickable/corkboards.qml
+++ b/examples/qml/toys/corkboards/corkboards.qml
diff --git a/examples/qml/toys/dynamicscene/content/Button.qml b/examples/qml/toys/dynamicscene/content/Button.qml
new file mode 100644
index 0000000000..014692274a
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/Button.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property variant text
+ signal clicked
+
+ height: text.height + 10; width: text.width + 20
+ border.width: 1
+ radius: 4
+ smooth: true
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: !mouseArea.pressed ? activePalette.light : activePalette.button
+ }
+ GradientStop {
+ position: 1.0
+ color: !mouseArea.pressed ? activePalette.button : activePalette.dark
+ }
+ }
+
+ SystemPalette { id: activePalette }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked()
+ }
+
+ Text {
+ id: text
+ anchors.centerIn:parent
+ font.pointSize: 10
+ text: parent.text
+ color: activePalette.buttonText
+ }
+}
diff --git a/examples/qml/toys/dynamicscene/content/GenericSceneItem.qml b/examples/qml/toys/dynamicscene/content/GenericSceneItem.qml
new file mode 100644
index 0000000000..0408aa87fb
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/GenericSceneItem.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ property bool created: false
+ property string image
+
+ source: image
+
+}
diff --git a/examples/qml/toys/dynamicscene/content/PaletteItem.qml b/examples/qml/toys/dynamicscene/content/PaletteItem.qml
new file mode 100644
index 0000000000..e993f89989
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/PaletteItem.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "itemCreation.js" as Code
+
+Image {
+ id: paletteItem
+
+ property string componentFile
+ property string image
+
+ source: image
+
+ MouseArea {
+ anchors.fill: parent
+
+ onPressed: Code.startDrag(mouse);
+ onPositionChanged: Code.continueDrag(mouse);
+ onReleased: Code.endDrag(mouse);
+ }
+}
diff --git a/examples/qml/toys/dynamicscene/content/PerspectiveItem.qml b/examples/qml/toys/dynamicscene/content/PerspectiveItem.qml
new file mode 100644
index 0000000000..f651369452
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/PerspectiveItem.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: rootItem
+
+ property bool created: false
+ property string image
+
+ property double scaledBottom: y + (height + height*scale) / 2
+ property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset)
+
+ source: image
+ opacity: onLand ? 1 : 0.25
+ scale: Math.max((y + height - 250) * 0.01, 0.3)
+ smooth: true
+
+ onCreatedChanged: {
+ if (created && !onLand)
+ rootItem.destroy();
+ else
+ z = scaledBottom;
+ }
+
+ onYChanged: z = scaledBottom;
+}
diff --git a/examples/qml/toys/dynamicscene/content/Sun.qml b/examples/qml/toys/dynamicscene/content/Sun.qml
new file mode 100644
index 0000000000..b84516eecc
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/Sun.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: sun
+
+ property bool created: false
+ property string image: "images/sun.png"
+
+ source: image
+
+ // once item is created, start moving offscreen
+ NumberAnimation on y {
+ to: (window.height / 2) + window.centerOffset
+ running: created
+ onRunningChanged: {
+ if (running)
+ duration = (window.height + window.centerOffset - sun.y) * 10;
+ else
+ state = "OffScreen"
+ }
+ }
+
+ states: State {
+ name: "OffScreen"
+ StateChangeScript {
+ script: { sun.created = false; sun.destroy() }
+ }
+ }
+
+ onCreatedChanged: {
+ if (created) {
+ sun.z = 1; // above the sky but below the ground layer
+ window.activeSuns++;
+ } else {
+ window.activeSuns--;
+ }
+ }
+}
diff --git a/examples/qml/toys/dynamicscene/content/images/NOTE b/examples/qml/toys/dynamicscene/content/images/NOTE
new file mode 100644
index 0000000000..fcd87f9132
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/images/NOTE
@@ -0,0 +1 @@
+Images (except star.png) are from the KDE project.
diff --git a/examples/qml/toys/dynamicscene/content/images/face-smile.png b/examples/qml/toys/dynamicscene/content/images/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/images/face-smile.png
Binary files differ
diff --git a/examples/qml/toys/dynamicscene/content/images/moon.png b/examples/qml/toys/dynamicscene/content/images/moon.png
new file mode 100644
index 0000000000..1c0d6066a8
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/images/moon.png
Binary files differ
diff --git a/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png b/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png
new file mode 100644
index 0000000000..ebfdeed332
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png
Binary files differ
diff --git a/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png b/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png
new file mode 100644
index 0000000000..7bff9b92ca
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png
Binary files differ
diff --git a/examples/qml/toys/dynamicscene/content/images/star.png b/examples/qml/toys/dynamicscene/content/images/star.png
new file mode 100644
index 0000000000..27ef924267
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/images/star.png
Binary files differ
diff --git a/examples/qml/toys/dynamicscene/content/images/sun.png b/examples/qml/toys/dynamicscene/content/images/sun.png
new file mode 100644
index 0000000000..7713ca5ce7
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/images/sun.png
Binary files differ
diff --git a/examples/qml/toys/dynamicscene/content/images/tree_s.png b/examples/qml/toys/dynamicscene/content/images/tree_s.png
new file mode 100644
index 0000000000..6eac35a729
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/images/tree_s.png
Binary files differ
diff --git a/examples/qml/toys/dynamicscene/content/itemCreation.js b/examples/qml/toys/dynamicscene/content/itemCreation.js
new file mode 100644
index 0000000000..40f5415f9f
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/content/itemCreation.js
@@ -0,0 +1,62 @@
+var itemComponent = null;
+var draggedItem = null;
+var startingMouse;
+var posnInWindow;
+
+function startDrag(mouse)
+{
+ posnInWindow = paletteItem.mapToItem(window, 0, 0);
+ startingMouse = { x: mouse.x, y: mouse.y }
+ loadComponent();
+}
+
+//Creation is split into two functions due to an asynchronous wait while
+//possible external files are loaded.
+
+function loadComponent() {
+ if (itemComponent != null) { // component has been previously loaded
+ createItem();
+ return;
+ }
+
+ itemComponent = Qt.createComponent(paletteItem.componentFile);
+ if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately
+ component.statusChanged.connect(createItem);
+ else
+ createItem();
+}
+
+function createItem() {
+ if (itemComponent.status == Component.Ready && draggedItem == null) {
+ draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3});
+ // make sure created item is above the ground layer
+ } else if (itemComponent.status == Component.Error) {
+ draggedItem = null;
+ console.log("error creating component");
+ console.log(itemComponent.errorString());
+ }
+}
+
+function continueDrag(mouse)
+{
+ if (draggedItem == null)
+ return;
+
+ draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x;
+ draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y;
+}
+
+function endDrag(mouse)
+{
+ if (draggedItem == null)
+ return;
+
+ if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox
+ draggedItem.destroy();
+ draggedItem = null;
+ } else {
+ draggedItem.created = true;
+ draggedItem = null;
+ }
+}
+
diff --git a/examples/qml/toys/dynamicscene/dynamicscene.qml b/examples/qml/toys/dynamicscene/dynamicscene.qml
new file mode 100644
index 0000000000..e64eb0fd0f
--- /dev/null
+++ b/examples/qml/toys/dynamicscene/dynamicscene.qml
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Item {
+ id: window
+
+ property int activeSuns: 0
+ property int centerOffset: 72
+
+ height: 480; width: 360
+
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: window.focus = false;
+ }
+
+ //This is the message box that pops up when there's an error
+ Rectangle {
+ id: dialog
+
+ opacity: 0
+ anchors.centerIn: parent
+ width: dialogText.width + 6; height: dialogText.height + 6
+ border.color: 'black'
+ color: 'lightsteelblue'
+ z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones.
+
+ function show(str){
+ dialogText.text = str;
+ dialogAnim.start();
+ }
+
+ Text {
+ id: dialogText
+ x: 3; y: 3
+ font.pixelSize: 14
+ }
+
+ SequentialAnimation {
+ id: dialogAnim
+ NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 }
+ PauseAnimation { duration: 5000 }
+ NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 }
+ }
+ }
+
+ Item {
+ id: scene
+ anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right}
+ z: 10
+ }
+
+ // sky
+ Rectangle {
+ id: sky
+ anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" }
+ GradientStop { id: gradientStopB; position: 1.0; color: "#437284" }
+ }
+ }
+
+ // stars (when there's no sun)
+ ParticleSystem {
+ id: particlesystem
+ anchors.fill: sky
+
+ ImageParticle {
+ id: stars
+ source: "content/images/star.png"
+ groups: ["stars"]
+ opacity: .5
+ }
+
+ Emitter {
+ id: starsemitter
+ anchors.fill: parent
+ emitRate: parent.width / 50
+ lifeSpan: 5000
+ group: "stars"
+ }
+ }
+
+ // ground
+ Rectangle {
+ id: ground
+ z: 2 // just above the sun so that the sun can set behind it
+ anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "ForestGreen" }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+
+ SystemPalette { id: activePalette }
+
+ // right-hand panel
+ Rectangle {
+ id: toolbox
+
+ height: centerOffset * 2
+ color: activePalette.window
+ anchors { right: parent.right; top: parent.top; left: parent.left}
+
+ Column {
+ anchors.centerIn: parent
+ spacing: 8
+
+ Text { text: "Drag an item into the scene." }
+
+ Rectangle {
+ width: palette.width + 10; height: palette.height + 10
+ border.color: "black"
+
+ Row {
+ id: palette
+ anchors.centerIn: parent
+ spacing: 8
+
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "Sun.qml"
+ source: "content/images/sun.png"
+ image: "images/sun.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "GenericSceneItem.qml"
+ source: "content/images/moon.png"
+ image: "images/moon.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "PerspectiveItem.qml"
+ source: "content/images/tree_s.png"
+ image: "images/tree_s.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "PerspectiveItem.qml"
+ source: "content/images/rabbit_brown.png"
+ image: "images/rabbit_brown.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "PerspectiveItem.qml"
+ source: "content/images/rabbit_bw.png"
+ image: "images/rabbit_bw.png"
+ }
+ }
+ }
+
+ Text { text: "Active Suns: " + activeSuns }
+ }
+ }
+
+ //Popup toolbox down the bottom
+ Rectangle {
+ id: popupToolbox
+ z: 1000
+ width: parent.width
+ height: popupColumn.height + 16
+ color: activePalette.window
+
+ property bool poppedUp: false
+ property int downY: window.height - (createButton.height + 16)
+ property int upY: window.height - (popupColumn.height + 16)
+ y: poppedUp ? upY : downY
+ Behavior on y { NumberAnimation {}}
+
+ Column {
+ id: popupColumn
+ y: 8
+ anchors.centerIn: parent
+ spacing: 8
+
+ Row {
+ height: createButton.height
+ spacing: 8
+ Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter }
+ Button {
+ id: popupButton
+ text: popupToolbox.poppedUp ? "Hide" : "Show"
+ onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp
+ }
+ Button {
+ id: createButton
+ text: "Create"
+ onClicked: {
+ try {
+ Qt.createQmlObject(qmlText.text, scene, 'CustomObject');
+ } catch(err) {
+ dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message);
+ }
+ }
+ }
+
+ }
+
+ Rectangle {
+ width: 360; height: 240
+
+ TextEdit {
+ id: qmlText
+ anchors.fill: parent; anchors.margins: 5
+ readOnly: false
+ font.pixelSize: 14
+ selectByMouse: true
+ wrapMode: TextEdit.WordWrap
+
+ text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}"
+ }
+ }
+ }
+ }
+
+ //Day state, for when a sun is added to the scene
+ states: State {
+ name: "Day"
+ when: window.activeSuns > 0
+
+ PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" }
+ PropertyChanges { target: gradientStopB; color: "SkyBlue" }
+ PropertyChanges { target: stars; opacity: 0 }
+ }
+
+ //! [top-level transitions]
+ transitions: Transition {
+ PropertyAnimation { duration: 3000 }
+ ColorAnimation { duration: 3000 }
+ }
+ //! [top-level transitions]
+}
diff --git a/examples/qml/toys/tic-tac-toe/content/Button.qml b/examples/qml/toys/tic-tac-toe/content/Button.qml
new file mode 100644
index 0000000000..6dd141f838
--- /dev/null
+++ b/examples/qml/toys/tic-tac-toe/content/Button.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text
+ property bool pressed: false
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 6
+ border { width: 1; color: Qt.darker(container.color) }
+ radius: 8
+ color: "lightgray"
+ smooth: true
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: container.pressed ? "darkgray" : "white"
+ }
+ GradientStop {
+ position: 1.0
+ color: container.color
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked()
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ text: container.text
+ font.pixelSize: 14
+ }
+}
diff --git a/examples/qml/toys/tic-tac-toe/content/TicTac.qml b/examples/qml/toys/tic-tac-toe/content/TicTac.qml
new file mode 100644
index 0000000000..e74bc6bcda
--- /dev/null
+++ b/examples/qml/toys/tic-tac-toe/content/TicTac.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ signal clicked
+
+ states: [
+ State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } },
+ State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } }
+ ]
+
+ Image {
+ id: image
+ anchors.centerIn: parent
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: parent.clicked()
+ }
+}
diff --git a/examples/qml/toys/tic-tac-toe/content/pics/board.png b/examples/qml/toys/tic-tac-toe/content/pics/board.png
new file mode 100644
index 0000000000..7e5b7ba27c
--- /dev/null
+++ b/examples/qml/toys/tic-tac-toe/content/pics/board.png
Binary files differ
diff --git a/examples/qml/toys/tic-tac-toe/content/pics/o.png b/examples/qml/toys/tic-tac-toe/content/pics/o.png
new file mode 100644
index 0000000000..abc7ee020b
--- /dev/null
+++ b/examples/qml/toys/tic-tac-toe/content/pics/o.png
Binary files differ
diff --git a/examples/qml/toys/tic-tac-toe/content/pics/x.png b/examples/qml/toys/tic-tac-toe/content/pics/x.png
new file mode 100644
index 0000000000..ddc65c83b8
--- /dev/null
+++ b/examples/qml/toys/tic-tac-toe/content/pics/x.png
Binary files differ
diff --git a/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js
new file mode 100644
index 0000000000..5a166b750f
--- /dev/null
+++ b/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js
@@ -0,0 +1,149 @@
+function winner(board)
+{
+ for (var i=0; i<3; ++i) {
+ if (board.children[i].state != ""
+ && board.children[i].state == board.children[i+3].state
+ && board.children[i].state == board.children[i+6].state)
+ return true
+
+ if (board.children[i*3].state != ""
+ && board.children[i*3].state == board.children[i*3+1].state
+ && board.children[i*3].state == board.children[i*3+2].state)
+ return true
+ }
+
+ if (board.children[0].state != ""
+ && board.children[0].state == board.children[4].state != ""
+ && board.children[0].state == board.children[8].state != "")
+ return true
+
+ if (board.children[2].state != ""
+ && board.children[2].state == board.children[4].state != ""
+ && board.children[2].state == board.children[6].state != "")
+ return true
+
+ return false
+}
+
+function restartGame()
+{
+ game.running = true
+
+ for (var i=0; i<9; ++i)
+ board.children[i].state = ""
+}
+
+function makeMove(pos, player)
+{
+ board.children[pos].state = player
+ if (winner(board)) {
+ gameFinished(player + " wins")
+ return true
+ } else {
+ return false
+ }
+}
+
+function canPlayAtPos(pos)
+{
+ return board.children[pos].state == ""
+}
+
+function computerTurn()
+{
+ var r = Math.random();
+ if (r < game.difficulty)
+ smartAI();
+ else
+ randomAI();
+}
+
+function smartAI()
+{
+ function boardCopy(a) {
+ var ret = new Object;
+ ret.children = new Array(9);
+ for (var i = 0; i<9; i++) {
+ ret.children[i] = new Object;
+ ret.children[i].state = a.children[i].state;
+ }
+ return ret;
+ }
+
+ for (var i=0; i<9; i++) {
+ var simpleBoard = boardCopy(board);
+ if (canPlayAtPos(i)) {
+ simpleBoard.children[i].state = "O";
+ if (winner(simpleBoard)) {
+ makeMove(i, "O")
+ return
+ }
+ }
+ }
+ for (var i=0; i<9; i++) {
+ var simpleBoard = boardCopy(board);
+ if (canPlayAtPos(i)) {
+ simpleBoard.children[i].state = "X";
+ if (winner(simpleBoard)) {
+ makeMove(i, "O")
+ return
+ }
+ }
+ }
+
+ function thwart(a,b,c) { //If they are at a, try b or c
+ if (board.children[a].state == "X") {
+ if (canPlayAtPos(b)) {
+ makeMove(b, "O")
+ return true
+ } else if (canPlayAtPos(c)) {
+ makeMove(c, "O")
+ return true
+ }
+ }
+ return false;
+ }
+
+ if (thwart(4,0,2)) return;
+ if (thwart(0,4,3)) return;
+ if (thwart(2,4,1)) return;
+ if (thwart(6,4,7)) return;
+ if (thwart(8,4,5)) return;
+ if (thwart(1,4,2)) return;
+ if (thwart(3,4,0)) return;
+ if (thwart(5,4,8)) return;
+ if (thwart(7,4,6)) return;
+
+ for (var i =0; i<9; i++) {
+ if (canPlayAtPos(i)) {
+ makeMove(i, "O")
+ return
+ }
+ }
+ restartGame();
+}
+
+function randomAI()
+{
+ var unfilledPosns = new Array();
+
+ for (var i=0; i<9; ++i) {
+ if (canPlayAtPos(i))
+ unfilledPosns.push(i);
+ }
+
+ if (unfilledPosns.length == 0) {
+ restartGame();
+ } else {
+ var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)];
+ makeMove(choice, "O");
+ }
+}
+
+function gameFinished(message)
+{
+ messageDisplay.text = message
+ messageDisplay.visible = true
+ game.running = false
+}
+
diff --git a/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml b/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml
new file mode 100644
index 0000000000..8d15233eaa
--- /dev/null
+++ b/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+import "content/tic-tac-toe.js" as Logic
+
+Rectangle {
+ id: game
+
+ property bool running: true
+ property real difficulty: 1.0 //chance it will actually think
+
+ width: display.width; height: display.height + 10
+
+ Image {
+ id: boardImage
+ source: "content/pics/board.png"
+ }
+
+
+ Column {
+ id: display
+
+ Grid {
+ id: board
+ width: boardImage.width; height: boardImage.height
+ columns: 3
+
+ Repeater {
+ model: 9
+
+ TicTac {
+ width: board.width/3
+ height: board.height/3
+
+ onClicked: {
+ if (game.running && Logic.canPlayAtPos(index)) {
+ if (!Logic.makeMove(index, "X"))
+ Logic.computerTurn();
+ }
+ }
+ }
+ }
+ }
+
+ Row {
+ spacing: 4
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Button {
+ text: "Hard"
+ pressed: game.difficulty == 1.0
+ onClicked: { game.difficulty = 1.0 }
+ }
+ Button {
+ text: "Moderate"
+ pressed: game.difficulty == 0.8
+ onClicked: { game.difficulty = 0.8 }
+ }
+ Button {
+ text: "Easy"
+ pressed: game.difficulty == 0.2
+ onClicked: { game.difficulty = 0.2 }
+ }
+ }
+ }
+
+
+ Text {
+ id: messageDisplay
+ anchors.centerIn: parent
+ color: "blue"
+ style: Text.Outline; styleColor: "white"
+ font.pixelSize: 50; font.bold: true
+ visible: false
+
+ Timer {
+ running: messageDisplay.visible
+ onTriggered: {
+ messageDisplay.visible = false;
+ Logic.restartGame();
+ }
+ }
+ }
+}
diff --git a/examples/qml/toys/tvtennis/tvtennis.qml b/examples/qml/toys/tvtennis/tvtennis.qml
new file mode 100644
index 0000000000..63866e3ce6
--- /dev/null
+++ b/examples/qml/toys/tvtennis/tvtennis.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 640; height: 480
+ color: "Black"
+
+ // Make a ball to bounce
+ Rectangle {
+ id: ball
+
+ // Add a property for the target y coordinate
+ property variant direction : "right"
+
+ x: 20; width: 20; height: 20; z: 1
+ color: "Lime"
+
+ // Move the ball to the right and back to the left repeatedly
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { to: page.width - 40; duration: 2000 }
+ PropertyAction { target: ball; property: "direction"; value: "left" }
+ NumberAnimation { to: 20; duration: 2000 }
+ PropertyAction { target: ball; property: "direction"; value: "right" }
+ }
+
+ // Make y move with a velocity of 200
+ Behavior on y { SpringAnimation{ velocity: 200; }
+ }
+
+ Component.onCompleted: y = page.height-10; // start the ball motion
+
+ // Detect the ball hitting the top or bottom of the view and bounce it
+ onYChanged: {
+ if (y <= 0) {
+ y = page.height - 20;
+ } else if (y >= page.height - 20) {
+ y = 0;
+ }
+ }
+ }
+
+ // Place bats to the left and right of the view, following the y
+ // coordinates of the ball.
+ Rectangle {
+ id: leftBat
+ color: "Lime"
+ x: 2; width: 20; height: 90
+ y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45;
+ Behavior on y { SpringAnimation{ velocity: 300 } }
+ }
+ Rectangle {
+ id: rightBat
+ color: "Lime"
+ x: page.width - 22; width: 20; height: 90
+ y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45;
+ Behavior on y { SpringAnimation{ velocity: 300 } }
+ }
+
+ // The rest, to make it look realistic, if neither ever scores...
+ Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 }
+ Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 }
+ Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 }
+ Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 }
+ Repeater {
+ model: page.height / 20
+ Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 }
+ }
+}
diff --git a/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml
new file mode 100644
index 0000000000..f07613c968
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+//![0]
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+//![1]
+}
+//![1]
diff --git a/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml
new file mode 100644
index 0000000000..1a9dd453ce
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+//![1]
+ Component {
+ id: dragDelegate
+
+ Rectangle {
+ id: content
+
+ anchors { left: parent.left; right: parent.right }
+ height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ radius: 2
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+ }
+ }
+//![1]
+//![2]
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: PetsModel {}
+ delegate: dragDelegate
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+//![2]
+}
+//![0]
diff --git a/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml
new file mode 100644
index 0000000000..4f2087d95e
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml
new file mode 100644
index 0000000000..9e654a685c
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+//![0]
+ Component {
+ id: dragDelegate
+
+//![1]
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+//![1]
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+//![3]
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+//![3]
+ radius: 2
+//![4]
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+//![4]
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+//![2]
+ }
+ }
+//![2]
+ }
+//![0]
+
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: PetsModel {}
+ delegate: dragDelegate
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+}
diff --git a/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml
new file mode 100644
index 0000000000..4f2087d95e
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml
new file mode 100644
index 0000000000..5a579f78d9
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//![0]
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+ Component {
+ id: dragDelegate
+
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+//![0]
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+
+ radius: 2
+//![1]
+ Drag.active: dragArea.held
+ Drag.source: dragArea
+ Drag.hotSpot.x: width / 2
+ Drag.hotSpot.y: height / 2
+//![1]
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+//![2]
+ }
+//![3]
+ DropArea {
+ anchors { fill: parent; margins: 10 }
+
+ onEntered: {
+ visualModel.items.move(
+ drag.source.VisualDataModel.itemsIndex,
+ dragArea.VisualDataModel.itemsIndex)
+ }
+ }
+//![3]
+ }
+ }
+//![2]
+//![4]
+ VisualDataModel {
+ id: visualModel
+
+ model: PetsModel {}
+ delegate: dragDelegate
+ }
+
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: visualModel
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+//![4]
+//![5]
+}
+//![5]
diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml
new file mode 100644
index 0000000000..c6b8287beb
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: selector
+
+ property alias list: view.model
+ property alias selectedIndex: view.currentIndex
+ property alias label: labelText.text
+ property bool expanded
+
+ width: 100; height: labelText.implicitHeight + 26
+
+ Rectangle {
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom; }
+
+ height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20)
+ Behavior on height { NumberAnimation { duration: 300 } }
+
+ radius: 2
+ border.width: 1
+ border.color: "yellow"
+ color: "yellow"
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: selector.expanded = !selector.expanded
+
+ Text {
+ id: labelText
+ anchors { left: parent.left; top: parent.top; margins: 2 }
+ }
+
+ Rectangle {
+ anchors {
+ left: parent.left; top: labelText.bottom;
+ right: parent.right; bottom: parent.bottom;
+ margins: 2
+ leftMargin: 10
+ }
+
+ radius: 2
+ color: "white"
+
+ ListView {
+ id: view
+
+ anchors.fill: parent
+
+ clip: true
+
+ delegate: Text {
+ anchors { left: parent.left; right: parent.right }
+ height: 20
+
+ verticalAlignment: Text.AlignVCenter
+
+ text: modelData
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ view.currentIndex = index
+ selector.expanded = !selector.expanded
+ }
+ }
+ }
+ highlight: Rectangle {
+ anchors { left: parent.left; right: parent.right }
+ height: 20
+ radius: 2
+
+ color: "yellow"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml
new file mode 100644
index 0000000000..4f2087d95e
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml
new file mode 100644
index 0000000000..9bd4e0c438
--- /dev/null
+++ b/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+ Component {
+ id: dragDelegate
+
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ enabled: visualModel.sortOrder == visualModel.lessThan.length
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+
+ radius: 2
+
+ Drag.active: dragArea.held
+ Drag.source: dragArea
+ Drag.hotSpot.x: width / 2
+ Drag.hotSpot.y: height / 2
+
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+ }
+
+ DropArea {
+ anchors { fill: parent; margins: 10 }
+
+ onEntered: {
+ visualModel.items.move(
+ drag.source.VisualDataModel.itemsIndex,
+ dragArea.VisualDataModel.itemsIndex)
+ }
+ }
+ }
+ }
+//![0]
+ VisualDataModel {
+ id: visualModel
+//![4]
+ property var lessThan: [
+ function(left, right) { return left.name < right.name },
+ function(left, right) { return left.type < right.type },
+ function(left, right) { return left.age < right.age },
+ function(left, right) {
+ if (left.size == "Small")
+ return true
+ else if (right.size == "Small")
+ return false
+ else if (left.size == "Medium")
+ return true
+ else
+ return false
+ }
+ ]
+//![4]
+//![6]
+
+ property int sortOrder: orderSelector.selectedIndex
+ onSortOrderChanged: items.setGroups(0, items.count, "unsorted")
+
+//![6]
+//![3]
+ function insertPosition(lessThan, item) {
+ var lower = 0
+ var upper = items.count
+ while (lower < upper) {
+ var middle = Math.floor(lower + (upper - lower) / 2)
+ var result = lessThan(item.model, items.get(middle).model);
+ if (result) {
+ upper = middle
+ } else {
+ lower = middle + 1
+ }
+ }
+ return lower
+ }
+
+ function sort(lessThan) {
+ while (unsortedItems.count > 0) {
+ var item = unsortedItems.get(0)
+ var index = insertPosition(lessThan, item)
+
+ item.groups = "items"
+ items.move(item.itemsIndex, index)
+ }
+ }
+//![3]
+
+//![1]
+ items.includeByDefault: false
+//![5]
+ groups: VisualDataGroup {
+ id: unsortedItems
+ name: "unsorted"
+
+ includeByDefault: true
+//![1]
+ onChanged: {
+ if (visualModel.sortOrder == visualModel.lessThan.length)
+ setGroups(0, count, "items")
+ else
+ visualModel.sort(visualModel.lessThan[visualModel.sortOrder])
+ }
+//![2]
+ }
+//![2]
+//![5]
+ model: PetsModel {}
+ delegate: dragDelegate
+ }
+//![0]
+ ListView {
+ id: view
+
+ anchors {
+ left: parent.left; top: parent.top; right: parent.right; bottom: orderSelector.top;
+ margins: 2
+ }
+
+ model: visualModel
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+
+ ListSelector {
+ id: orderSelector
+
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 }
+
+ label: "Sort By"
+ list: [ "Name", "Type", "Age", "Size", "Custom" ]
+ }
+}
diff --git a/examples/qml/tutorials/extending/chapter1-basics/app.qml b/examples/qml/tutorials/extending/chapter1-basics/app.qml
new file mode 100644
index 0000000000..6f0c1d3a23
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/app.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ name: "A simple pie chart"
+ color: "red"
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: aPieChart.name
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter1-basics/main.cpp b/examples/qml/tutorials/extending/chapter1-basics/main.cpp
new file mode 100644
index 0000000000..ed9e412bd6
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp
new file mode 100644
index 0000000000..bc81d6a3a0
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "piechart.h"
+#include <QPainter>
+
+//![0]
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+//![0]
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+void PieChart::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+//![1]
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+//![1]
+
diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.h b/examples/qml/tutorials/extending/chapter1-basics/piechart.h
new file mode 100644
index 0000000000..71a8786e7d
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIECHART_H
+#define PIECHART_H
+
+//![0]
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+class PieChart : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+private:
+ QString m_name;
+ QColor m_color;
+};
+//![0]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter2-methods/app.qml b/examples/qml/tutorials/extending/chapter2-methods/app.qml
new file mode 100644
index 0000000000..eee0933734
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/app.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ color: "red"
+
+ onChartCleared: console.log("The chart has been cleared")
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ 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/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter2-methods/main.cpp b/examples/qml/tutorials/extending/chapter2-methods/main.cpp
new file mode 100644
index 0000000000..ed9e412bd6
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp
new file mode 100644
index 0000000000..71be74e943
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "piechart.h"
+#include <QPainter>
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+void PieChart::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
+//![0]
+void PieChart::clearChart()
+{
+ setColor(QColor(Qt::transparent));
+ update();
+
+ emit chartCleared();
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.h b/examples/qml/tutorials/extending/chapter2-methods/piechart.h
new file mode 100644
index 0000000000..7650d6e8d7
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieChart : public QQuickPaintedItem
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+//![1]
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+//![2]
+ Q_INVOKABLE void clearChart();
+
+signals:
+ void chartCleared();
+//![2]
+
+private:
+ QString m_name;
+ QColor m_color;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/app.qml b/examples/qml/tutorials/extending/chapter3-bindings/app.qml
new file mode 100644
index 0000000000..4ad929132c
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/app.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+
+ PieChart {
+ id: chartA
+ width: 100; height: 100
+ color: "red"
+ }
+
+ PieChart {
+ id: chartB
+ width: 100; height: 100
+ color: chartA.color
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { chartA.color = "blue" }
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to change the chart color"
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp
new file mode 100644
index 0000000000..ed9e412bd6
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp
new file mode 100644
index 0000000000..2a392125da
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "piechart.h"
+#include <QPainter>
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+//![0]
+void PieChart::setColor(const QColor &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ update(); // repaint with the new color
+ emit colorChanged();
+ }
+}
+//![0]
+
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
+void PieChart::clearChart()
+{
+ setColor(QColor(Qt::transparent));
+ update();
+}
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h
new file mode 100644
index 0000000000..77075b5727
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIECHART_H
+#define PIECHART_H
+
+#include <QColor>
+#include <QtQuick/QQuickPaintedItem>
+
+//![0]
+class PieChart : public QQuickPaintedItem
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+ Q_INVOKABLE void clearChart();
+
+//![2]
+signals:
+ void colorChanged();
+//![2]
+
+private:
+ QString m_name;
+ QColor m_color;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml
new file mode 100644
index 0000000000..06490773f4
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: chart
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ pieSlice: PieSlice {
+ anchors.fill: parent
+ color: "red"
+ }
+ }
+
+ Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color)
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
new file mode 100644
index 0000000000..23eb222ea3
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -0,0 +1,7 @@
+QT += qml quick
+
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp
new file mode 100644
index 0000000000..537ea766fc
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "piechart.h"
+#include "pieslice.h"
+
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+//![0]
+int main(int argc, char *argv[])
+{
+//![0]
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+//![1]
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+//![1]
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+
+//![2]
+}
+//![2]
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
new file mode 100644
index 0000000000..3cf9bdc00c
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+PieSlice *PieChart::pieSlice() const
+{
+ return m_pieSlice;
+}
+
+//![0]
+void PieChart::setPieSlice(PieSlice *pieSlice)
+{
+ m_pieSlice = pieSlice;
+ pieSlice->setParentItem(this);
+}
+//![0]
+
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h
new file mode 100644
index 0000000000..b89db5a2b1
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+//![0]
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ PieSlice *pieSlice() const;
+ void setPieSlice(PieSlice *pieSlice);
+//![2]
+
+private:
+ QString m_name;
+ PieSlice *m_pieSlice;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
new file mode 100644
index 0000000000..654a46fc8d
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
new file mode 100644
index 0000000000..8fc445d471
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+};
+//![0]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/app.qml b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml
new file mode 100644
index 0000000000..37b0626948
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
new file mode 100644
index 0000000000..23eb222ea3
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
@@ -0,0 +1,7 @@
+QT += qml quick
+
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp
new file mode 100644
index 0000000000..59587733eb
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "piechart.h"
+#include "pieslice.h"
+
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp
new file mode 100644
index 0000000000..9c2c6accf3
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+//![0]
+QQmlListProperty<PieSlice> PieChart::slices()
+{
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice);
+}
+
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
+{
+ PieChart *chart = qobject_cast<PieChart *>(list->object);
+ if (chart) {
+ slice->setParentItem(chart);
+ chart->m_slices.append(slice);
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h
new file mode 100644
index 0000000000..6c17bc1258
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+//![0]
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ QQmlListProperty<PieSlice> slices();
+
+private:
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
+
+ QString m_name;
+ QList<PieSlice *> m_slices;
+};
+//![2]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp
new file mode 100644
index 0000000000..5bca2d58d8
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+int PieSlice::fromAngle() const
+{
+ return m_fromAngle;
+}
+
+void PieSlice::setFromAngle(int angle)
+{
+ m_fromAngle = angle;
+}
+
+int PieSlice::angleSpan() const
+{
+ return m_angleSpan;
+}
+
+void PieSlice::setAngleSpan(int angle)
+{
+ m_angleSpan = angle;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16);
+}
+
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h
new file mode 100644
index 0000000000..f6497fcbae
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+//![0]
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ int fromAngle() const;
+ void setFromAngle(int angle);
+
+ int angleSpan() const;
+ void setAngleSpan(int span);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+ int m_fromAngle;
+ int m_angleSpan;
+};
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir b/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir
new file mode 100644
index 0000000000..72650d8243
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir
@@ -0,0 +1 @@
+plugin chartsplugin \ No newline at end of file
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/app.qml b/examples/qml/tutorials/extending/chapter6-plugins/app.qml
new file mode 100644
index 0000000000..b6eac44e27
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/app.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import "ChartsPlugin" 1.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
new file mode 100644
index 0000000000..75f88b2eaa
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
@@ -0,0 +1,18 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml quick
+
+DESTDIR = ChartsPlugin
+TARGET = chartsplugin
+
+OBJECTS_DIR = tmp
+MOC_DIR = tmp
+
+HEADERS += piechart.h \
+ pieslice.h \
+ chartsplugin.h
+
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ chartsplugin.cpp
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp
new file mode 100644
index 0000000000..f95cf1003b
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "chartsplugin.h"
+//![0]
+#include "piechart.h"
+#include "pieslice.h"
+#include <qqml.h>
+
+void ChartsPlugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<PieChart>(uri, 1, 0, "PieChart");
+ qmlRegisterType<PieSlice>(uri, 1, 0, "PieSlice");
+}
+
+Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin);
+//![0]
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h
new file mode 100644
index 0000000000..2dc477f794
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 CHARTSPLUGIN_H
+#define CHARTSPLUGIN_H
+
+//![0]
+#include <QQmlExtensionPlugin>
+
+class ChartsPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri);
+};
+//![0]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp
new file mode 100644
index 0000000000..b00f4139be
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QQmlListProperty<PieSlice> PieChart::slices()
+{
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice);
+}
+
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
+{
+ PieChart *chart = qobject_cast<PieChart *>(list->object);
+ if (chart) {
+ slice->setParentItem(chart);
+ chart->m_slices.append(slice);
+ }
+}
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.h b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h
new file mode 100644
index 0000000000..2ee8108784
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+public:
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QQmlListProperty<PieSlice> slices();
+
+private:
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
+
+ QString m_name;
+ QList<PieSlice *> m_slices;
+};
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp
new file mode 100644
index 0000000000..5bca2d58d8
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+int PieSlice::fromAngle() const
+{
+ return m_fromAngle;
+}
+
+void PieSlice::setFromAngle(int angle)
+{
+ m_fromAngle = angle;
+}
+
+int PieSlice::angleSpan() const
+{
+ return m_angleSpan;
+}
+
+void PieSlice::setAngleSpan(int angle)
+{
+ m_angleSpan = angle;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16);
+}
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h
new file mode 100644
index 0000000000..8a636fb3e7
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ int fromAngle() const;
+ void setFromAngle(int angle);
+
+ int angleSpan() const;
+ void setAngleSpan(int span);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+ int m_fromAngle;
+ int m_angleSpan;
+};
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/extending.pro b/examples/qml/tutorials/extending/extending.pro
new file mode 100644
index 0000000000..967473fda0
--- /dev/null
+++ b/examples/qml/tutorials/extending/extending.pro
@@ -0,0 +1,10 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ chapter1-basics \
+ chapter2-methods \
+ chapter3-bindings \
+ chapter4-customPropertyTypes \
+ chapter5-listproperties \
+ chapter6-plugins
+
diff --git a/examples/qml/tutorials/helloworld/Cell.qml b/examples/qml/tutorials/helloworld/Cell.qml
new file mode 100644
index 0000000000..7140dcb2c1
--- /dev/null
+++ b/examples/qml/tutorials/helloworld/Cell.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+//![1]
+Item {
+ id: container
+//![4]
+ property alias cellColor: rectangle.color
+//![4]
+//![5]
+ signal clicked(color cellColor)
+//![5]
+
+ width: 40; height: 25
+//![1]
+
+//![2]
+ Rectangle {
+ id: rectangle
+ border.color: "white"
+ anchors.fill: parent
+ }
+//![2]
+
+//![3]
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked(container.cellColor)
+ }
+//![3]
+}
+//![0]
diff --git a/examples/qml/tutorials/helloworld/tutorial1.qml b/examples/qml/tutorials/helloworld/tutorial1.qml
new file mode 100644
index 0000000000..f0eb42d696
--- /dev/null
+++ b/examples/qml/tutorials/helloworld/tutorial1.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+//![3]
+import QtQuick 2.0
+//![3]
+
+//![1]
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+//![1]
+
+//![2]
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+//![2]
+}
+//![0]
diff --git a/examples/qml/tutorials/helloworld/tutorial2.qml b/examples/qml/tutorials/helloworld/tutorial2.qml
new file mode 100644
index 0000000000..c5c045aace
--- /dev/null
+++ b/examples/qml/tutorials/helloworld/tutorial2.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+
+ Grid {
+ id: colorPicker
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
+ rows: 2; columns: 3; spacing: 3
+
+//![1]
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+//![1]
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/helloworld/tutorial3.qml b/examples/qml/tutorials/helloworld/tutorial3.qml
new file mode 100644
index 0000000000..c804bfca1d
--- /dev/null
+++ b/examples/qml/tutorials/helloworld/tutorial3.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+
+//![1]
+ MouseArea { id: mouseArea; anchors.fill: parent }
+//![1]
+
+//![2]
+ states: State {
+ name: "down"; when: mouseArea.pressed == true
+ PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" }
+ }
+//![2]
+
+//![3]
+ transitions: Transition {
+ from: ""; to: "down"; reversible: true
+ ParallelAnimation {
+ NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad }
+ ColorAnimation { duration: 500 }
+ }
+ }
+//![3]
+ }
+
+ Grid {
+ id: colorPicker
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
+ rows: 2; columns: 3; spacing: 3
+
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/samegame/samegame1/Block.qml b/examples/qml/tutorials/samegame/samegame1/Block.qml
new file mode 100644
index 0000000000..32ef8c2bba
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame1/Block.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "../shared/pics/redStone.png"
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/samegame/samegame1/Button.qml b/examples/qml/tutorials/samegame/samegame1/Button.qml
new file mode 100644
index 0000000000..6d1d1268de
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame1/Button.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/samegame/samegame1/samegame.qml b/examples/qml/tutorials/samegame/samegame1/samegame.qml
new file mode 100644
index 0000000000..73e2cc31fd
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame1/samegame.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: console.log("This doesn't do anything yet...")
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame2/Block.qml b/examples/qml/tutorials/samegame/samegame2/Block.qml
new file mode 100644
index 0000000000..8056b39480
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame2/Block.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "../shared/pics/redStone.png"
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame2/Button.qml b/examples/qml/tutorials/samegame/samegame2/Button.qml
new file mode 100644
index 0000000000..248c20cf0f
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame2/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame2/samegame.js b/examples/qml/tutorials/samegame/samegame2/samegame.js
new file mode 100644
index 0000000000..c749dc17b1
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame2/samegame.js
@@ -0,0 +1,63 @@
+//![0]
+var blockSize = 40;
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxColumn = Math.floor(background.width / blockSize);
+ maxRow = Math.floor(background.height / blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("Block.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(background);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.x = column * blockSize;
+ dynamicObject.y = row * blockSize;
+ dynamicObject.width = blockSize;
+ dynamicObject.height = blockSize;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+//![0]
+
diff --git a/examples/qml/tutorials/samegame/samegame2/samegame.qml b/examples/qml/tutorials/samegame/samegame2/samegame.qml
new file mode 100644
index 0000000000..c50010e97d
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame2/samegame.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//![2]
+import "samegame.js" as SameGame
+//![2]
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 32
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+//![1]
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+//![1]
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame3/Block.qml b/examples/qml/tutorials/samegame/samegame3/Block.qml
new file mode 100644
index 0000000000..9c41048fcb
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame3/Block.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ property int type: 0
+
+ Image {
+ id: img
+
+ anchors.fill: parent
+ source: {
+ if (type == 0)
+ return "../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../shared/pics/blueStone.png";
+ else
+ return "../shared/pics/greenStone.png";
+ }
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/samegame/samegame3/Button.qml b/examples/qml/tutorials/samegame/samegame3/Button.qml
new file mode 100644
index 0000000000..248c20cf0f
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame3/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame3/Dialog.qml b/examples/qml/tutorials/samegame/samegame3/Dialog.qml
new file mode 100644
index 0000000000..df1fa37d6a
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame3/Dialog.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
+ }
+
+ function hide() {
+ container.opacity = 0;
+ }
+
+ width: dialogText.width + 20
+ height: dialogText.height + 20
+ opacity: 0
+
+ Text {
+ id: dialogText
+ anchors.centerIn: parent
+ text: ""
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: hide();
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/samegame/samegame3/samegame.js b/examples/qml/tutorials/samegame/samegame3/samegame.js
new file mode 100644
index 0000000000..df5bdfb049
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame3/samegame.js
@@ -0,0 +1,174 @@
+/* This script file handles the game logic */
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Calculate board size
+ maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Close dialogs
+ dialog.hide();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("Block.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(gameCanvas);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.x = column * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound; //Set after a floodFill call to the number of blocks found
+var floodBoard; //Set to 1 if the floodFill reaches off that node
+
+//![1]
+function handleClick(xPos, yPos) {
+ var column = Math.floor(xPos / gameCanvas.blockSize);
+ var row = Math.floor(yPos / gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column, row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+//![1]
+
+function floodFill(column, row, type) {
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column, row)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; //Can't remove single blocks
+ board[index(column, row)].opacity = 0;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown() {
+ //Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column, row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y += fallDist * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ var fallDist = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (var row = 0; row < maxRow; row++) {
+ var obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x -= fallDist * gameCanvas.blockSize;
+ board[index(column - fallDist, row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![2]
+function victoryCheck() {
+ //Award bonus points if no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+
+ //Check whether game has finished
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1)))
+ dialog.show("Game Over. Your score is " + gameCanvas.score);
+}
+//![2]
+
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type) {
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
diff --git a/examples/qml/tutorials/samegame/samegame3/samegame.qml b/examples/qml/tutorials/samegame/samegame3/samegame.qml
new file mode 100644
index 0000000000..f14829ef63
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame3/samegame.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+import "samegame.js" as SameGame
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+//![1]
+ Item {
+ id: gameCanvas
+
+ property int score: 0
+ property int blockSize: 40
+
+ width: parent.width - (parent.width % blockSize)
+ height: parent.height - (parent.height % blockSize)
+ anchors.centerIn: parent
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: SameGame.handleClick(mouse.x, mouse.y)
+ }
+ }
+//![1]
+ }
+
+//![2]
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
+//![2]
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml
new file mode 100644
index 0000000000..3786b9c0d1
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Qt.labs.particles 1.0
+
+Item {
+ id: block
+
+ property int type: 0
+ property bool dying: false
+
+ //![1]
+ property bool spawned: false
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ //![1]
+
+ //![2]
+ Image {
+ id: img
+
+ anchors.fill: parent
+ source: {
+ if (type == 0)
+ return "../../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStone.png";
+ else
+ return "../../shared/pics/greenStone.png";
+ }
+ opacity: 0
+
+ Behavior on opacity {
+ NumberAnimation { properties:"opacity"; duration: 200 }
+ }
+ }
+ //![2]
+
+ //![3]
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation: 30
+ source: {
+ if (type == 0)
+ return "../../shared/pics/redStar.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStar.png";
+ else
+ return "../../shared/pics/greenStar.png";
+ }
+ }
+ //![3]
+
+ //![4]
+ states: [
+ State {
+ name: "AliveState"
+ when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"
+ when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+ //![4]
+}
diff --git a/examples/qml/tutorials/samegame/samegame4/content/Button.qml b/examples/qml/tutorials/samegame/samegame4/content/Button.qml
new file mode 100644
index 0000000000..248c20cf0f
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/content/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml b/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml
new file mode 100644
index 0000000000..984b3ddb6a
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+Rectangle {
+ id: container
+//![0]
+
+//![1]
+ property string inputText: textInput.text
+ signal closed
+
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
+ textInput.opacity = 0;
+ }
+
+ function showWithInput(text) {
+ show(text);
+ textInput.opacity = 1;
+ textInput.focus = true;
+ textInput.text = ""
+ }
+
+ function hide() {
+ textInput.focus = false;
+ container.opacity = 0;
+ container.closed();
+ }
+//![1]
+
+ width: dialogText.width + textInput.width + 20
+ height: dialogText.height + 20
+ opacity: 0
+ visible: opacity > 0
+
+ Text {
+ id: dialogText
+ anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 }
+ text: ""
+ }
+
+//![2]
+ TextInput {
+ id: textInput
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ width: 80
+ text: ""
+
+ onAccepted: container.hide() // close dialog when Enter is pressed
+ }
+//![2]
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ if (textInput.text == "" && textInput.opacity > 0)
+ textInput.openSoftwareInputPanel();
+ else
+ hide();
+ }
+ }
+
+//![3]
+}
+//![3]
diff --git a/examples/qml/tutorials/samegame/samegame4/content/samegame.js b/examples/qml/tutorials/samegame/samegame4/content/samegame.js
new file mode 100755
index 0000000000..7bb7243914
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/content/samegame.js
@@ -0,0 +1,226 @@
+/* This script file handles the game logic */
+.import QtQuick.LocalStorage 2.0 as Sql
+
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+var scoresURL = "";
+var gameDuration;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Close dialogs
+ nameInputDialog.hide();
+ dialog.hide();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+
+ gameDuration = new Date();
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("content/BoomBlock.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(gameCanvas);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.x = column * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
+ dynamicObject.spawned = true;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound; //Set after a floodFill call to the number of blocks found
+var floodBoard; //Set to 1 if the floodFill reaches off that node
+
+function handleClick(xPos, yPos) {
+ var column = Math.floor(xPos / gameCanvas.blockSize);
+ var row = Math.floor(yPos / gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column, row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+
+function floodFill(column, row, type) {
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column, row)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; //Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown() {
+ //Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column, row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * gameCanvas.blockSize;
+ board[index(column - fallDist, row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![3]
+function victoryCheck() {
+//![3]
+ //Award bonus points if no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+
+//![4]
+ //Check whether game has finished
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
+ gameDuration = new Date() - gameDuration;
+ nameInputDialog.showWithInput("You won! Please enter your name: ");
+ }
+}
+//![4]
+
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type) {
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
+//![2]
+function saveHighScore(name) {
+ if (scoresURL != "")
+ sendHighScore(name);
+
+ var db = Sql.openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100);
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)];
+ db.transaction(function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for a standard sized grid\n\n"
+ for (var i = 0; i < rs.rows.length; i++) {
+ r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n';
+ }
+ dialog.show(r);
+ });
+}
+//![2]
+
+//![1]
+function sendHighScore(name) {
+ var postman = new XMLHttpRequest()
+ var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000);
+ postman.open("POST", scoresURL, true);
+ postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ postman.onreadystatechange = function() {
+ if (postman.readyState == postman.DONE) {
+ dialog.show("Your score has been uploaded.");
+ }
+ }
+ postman.send(postData);
+}
+//![1]
diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/README b/examples/qml/tutorials/samegame/samegame4/highscores/README
new file mode 100644
index 0000000000..eaa00fae37
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml
new file mode 100755
index 0000000000..c3fd90d9cf
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl
new file mode 100755
index 0000000000..670354c965
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <xsl:sort select="score" data-type="number" order="descending"/>
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/scores.php b/examples/qml/tutorials/samegame/samegame4/highscores/scores.php
new file mode 100755
index 0000000000..daf480e21b
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/highscores/scores.php
@@ -0,0 +1,31 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ $file = fopen("score_data.xml", "a");
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>
diff --git a/examples/qml/tutorials/samegame/samegame4/samegame.qml b/examples/qml/tutorials/samegame/samegame4/samegame.qml
new file mode 100644
index 0000000000..c21b8de8bd
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/samegame.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+import "content/samegame.js" as SameGame
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ Item {
+ id: gameCanvas
+ property int score: 0
+ property int blockSize: 40
+
+ anchors.centerIn: parent
+ width: parent.width - (parent.width % blockSize);
+ height: parent.height - (parent.height % blockSize);
+
+ MouseArea {
+ anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
+ }
+ }
+ }
+
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
+
+ //![0]
+ Dialog {
+ id: nameInputDialog
+ anchors.centerIn: parent
+ z: 100
+
+ onClosed: {
+ if (nameInputDialog.inputText != "")
+ SameGame.saveHighScore(nameInputDialog.inputText);
+ }
+ }
+ //![0]
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ }
+ }
+}
diff --git a/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/tutorials/samegame/shared/pics/background.jpg b/examples/qml/tutorials/samegame/shared/pics/background.jpg
new file mode 100644
index 0000000000..903d395c8d
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/background.jpg
Binary files differ
diff --git a/examples/qml/tutorials/samegame/shared/pics/blueStar.png b/examples/qml/tutorials/samegame/shared/pics/blueStar.png
new file mode 100644
index 0000000000..ff9588f80a
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/blueStar.png
Binary files differ
diff --git a/examples/qml/tutorials/samegame/shared/pics/blueStone.png b/examples/qml/tutorials/samegame/shared/pics/blueStone.png
new file mode 100644
index 0000000000..20e43c75b6
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/blueStone.png
Binary files differ
diff --git a/examples/qml/tutorials/samegame/shared/pics/greenStar.png b/examples/qml/tutorials/samegame/shared/pics/greenStar.png
new file mode 100644
index 0000000000..cd06854719
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/greenStar.png
Binary files differ
diff --git a/examples/qml/tutorials/samegame/shared/pics/greenStone.png b/examples/qml/tutorials/samegame/shared/pics/greenStone.png
new file mode 100644
index 0000000000..b568a1900c
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/greenStone.png
Binary files differ
diff --git a/examples/qml/tutorials/samegame/shared/pics/redStar.png b/examples/qml/tutorials/samegame/shared/pics/redStar.png
new file mode 100644
index 0000000000..0a4dffe583
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/redStar.png
Binary files differ
diff --git a/examples/qml/tutorials/samegame/shared/pics/redStone.png b/examples/qml/tutorials/samegame/shared/pics/redStone.png
new file mode 100644
index 0000000000..36b09a2686
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/redStone.png
Binary files differ
diff --git a/examples/qml/tutorials/samegame/shared/pics/star.png b/examples/qml/tutorials/samegame/shared/pics/star.png
new file mode 100644
index 0000000000..defbde53ca
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/star.png
Binary files differ
diff --git a/examples/qml/tutorials/samegame/shared/pics/yellowStone.png b/examples/qml/tutorials/samegame/shared/pics/yellowStone.png
new file mode 100644
index 0000000000..b1ce76212c
--- /dev/null
+++ b/examples/qml/tutorials/samegame/shared/pics/yellowStone.png
Binary files differ
diff --git a/examples/qml/tutorials/tutorials.pro b/examples/qml/tutorials/tutorials.pro
new file mode 100644
index 0000000000..0a82c1e704
--- /dev/null
+++ b/examples/qml/tutorials/tutorials.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ extending
+
diff --git a/examples/qml/tutorials/tutorials.qmlproject b/examples/qml/tutorials/tutorials.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/qml/tutorials/tutorials.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/Button.qml b/examples/qml/twitter/TwitterCore/Button.qml
new file mode 100644
index 0000000000..353b993742
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/Button.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ signal clicked
+
+ property string text
+ property bool keyUsing: false
+
+ BorderImage {
+ id: buttonImage
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ BorderImage {
+ id: pressed
+ opacity: 0
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ id: btnText
+ color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";}
+ anchors.centerIn: buttonImage; font.bold: true
+ text: container.text; style: Text.Raised; styleColor: "black"
+ font.pixelSize: 12
+ }
+ states: [
+ State {
+ name: "Pressed"
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ },
+ State {
+ name: "Focused"
+ when: container.activeFocus == true
+ PropertyChanges { target: btnText; color: "#FFFFFF" }
+ }
+ ]
+ transitions: Transition {
+ ColorAnimation { target: btnText; }
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/FatDelegate.qml b/examples/qml/twitter/TwitterCore/FatDelegate.qml
new file mode 100644
index 0000000000..4cb0dfc713
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/FatDelegate.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Component {
+ id: listDelegate
+ Item {
+ id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5
+ function handleLink(link){
+ if(link.slice(0,3) == 'app'){
+ screen.setUser(link.slice(7));
+ }else if(link.slice(0,4) == 'http'){
+ Qt.openUrlExternally(link);
+ }
+ }
+ function addTags(str){
+ var ret = str.replace(/@[a-zA-Z0-9_]+/g, '<a href="app://$&">$&</a>');//click to jump to user?
+ var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '<a href="$&">$&</a>');//surrounds http links with html link tags
+ return ret2;
+ }
+
+ // Strip away paranthesis
+ function userName(str) {
+ var user = str.replace(/\([\S|\s]*\)/gi, "");
+ return user.trim();
+ }
+
+ Item {
+ id: moveMe; height: parent.height
+ Rectangle {
+ id: blackRect
+ color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1
+ }
+ Item {
+ id: image; x: 6; width: 48; height: 48; smooth: true
+ anchors.verticalCenter: parent.verticalCenter
+
+ Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready }
+ Image {
+ id: realImage;
+ source: userImage; x: 1; y: 1;
+ width:48; height:48; opacity:0 ;
+ onStatusChanged: {
+ if(status==Image.Ready)
+ image.state="loaded"
+ }
+ }
+ states: State {
+ name: "loaded";
+ PropertyChanges { target: realImage ; opacity:1 }
+ }
+ transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } }
+
+ }
+ Text { id:txt; y:4; x: 56
+ text: '<html>'
+ + '<a href="app://@'+userName(name)+'"><b>'+userName(name) + "</b></a> from " +source
+ + "<br /><b>" + statusText + "</b></html>";
+ textFormat: Text.StyledText
+ color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap; linkColor: "#aaccaa"
+ anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
+ onLinkActivated: wrapper.handleLink(link)
+ }
+ }
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/Input.qml b/examples/qml/twitter/TwitterCore/Input.qml
new file mode 100644
index 0000000000..68b1c6186a
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/Input.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id:container
+ width: 220
+ height: 28
+ BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
+ signal accepted
+ property alias text: input.text
+ property alias item:input
+ TextInput{
+ id: input
+ width: parent.width - 12
+ anchors.centerIn: parent
+ maximumLength:21
+ font.pixelSize: 16;
+ font.bold: true
+ color: "#151515"; selectionColor: "mediumseagreen"
+ focus: true
+ onAccepted:{container.accepted()}
+ text: ""
+ selectByMouse: true
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/Loading.qml b/examples/qml/twitter/TwitterCore/Loading.qml
new file mode 100644
index 0000000000..566857b8b2
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/Loading.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: loading; source: "images/loading.png"
+ NumberAnimation on rotation {
+ from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/MultiTitleBar.qml b/examples/qml/twitter/TwitterCore/MultiTitleBar.qml
new file mode 100644
index 0000000000..3920520b7a
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/MultiTitleBar.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ TitleBar { id: titleBar; width: parent.width; height: 60;
+ y: -80
+ untaggedString: "Latest tweets from everyone"
+ taggedString: "Latest tweets from "
+ }
+ states: [
+ State {
+ name: "search"; when: screen.state!="search"
+ PropertyChanges { target: titleBar; y: 0 }
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } }
+ ]
+}
+
diff --git a/examples/qml/twitter/TwitterCore/RssModel.qml b/examples/qml/twitter/TwitterCore/RssModel.qml
new file mode 100644
index 0000000000..27f7495be2
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/RssModel.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Item { id: wrapper
+ property variant model: xmlModel
+ property string from : ""
+ property string to : ""
+ property string phrase : ""
+
+ property string mode : "everyone"
+ property int status: xmlModel.status
+ function reload() { xmlModel.reload(); }
+
+ XmlListModel {
+ id: xmlModel
+
+ function encodePhrase(x) { return encodeURIComponent(x); }
+
+ source: (from=="" && to=="" && phrase=="") ? "" :
+ 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+encodePhrase(phrase)
+
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
+ "declare namespace twitter=\"http://api.twitter.com/\";";
+
+ query: "/feed/entry"
+
+ XmlRole { name: "statusText"; query: "content/string()" }
+ XmlRole { name: "timestamp"; query: "published/string()" }
+ XmlRole { name: "source"; query: "twitter:source/string()" }
+ XmlRole { name: "name"; query: "author/name/string()" }
+ XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" }
+
+ }
+ Binding {
+ property: "mode"
+ target: wrapper
+ value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}}
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/SearchView.qml b/examples/qml/twitter/TwitterCore/SearchView.qml
new file mode 100644
index 0000000000..7732e6f68d
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/SearchView.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: wrapper
+ Column {
+ anchors.centerIn: parent
+ spacing: 20
+ Column{
+ spacing: 4
+ Text {
+ text: "Posted by:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: fromIn
+ KeyNavigation.backtab: searchbutton
+ KeyNavigation.tab:toIn
+ onAccepted:searchbutton.doSearch();
+ focus: true
+ }
+ Text {
+ text: "In reply to:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: toIn
+ KeyNavigation.backtab: fromIn
+ KeyNavigation.tab:phraseIn
+ onAccepted:searchbutton.doSearch();
+ }
+ Text {
+ text: "Search phrase:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: phraseIn
+ KeyNavigation.backtab: toIn
+ KeyNavigation.tab:searchbutton
+ onAccepted:searchbutton.doSearch();
+ text: "Qt Quick"
+ }
+ }
+ Button {
+ width: 100
+ height: 32
+ id: searchbutton
+ keyUsing: true;
+ opacity: 1
+ text: "Search"
+ KeyNavigation.tab: fromIn
+ Keys.onReturnPressed: searchbutton.doSearch();
+ Keys.onEnterPressed: searchbutton.doSearch();
+ Keys.onSelectPressed: searchbutton.doSearch();
+ Keys.onSpacePressed: searchbutton.doSearch();
+ onClicked: searchbutton.doSearch();
+
+ function doSearch() {
+ // Search ! allowed
+ if (wrapper.state=="invalidinput")
+ return;
+
+ rssModel.from=fromIn.text;
+ rssModel.to= toIn.text;
+ rssModel.phrase = phraseIn.text;
+ screen.focus = true;
+ screen.state = ""
+ }
+ }
+ }
+ states:
+ State {
+ name: "invalidinput"
+ when: fromIn.text=="" && toIn.text=="" && phraseIn.text==""
+ PropertyChanges { target: searchbutton ; opacity: 0.6 ; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 }
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/TitleBar.qml b/examples/qml/twitter/TwitterCore/TitleBar.qml
new file mode 100644
index 0000000000..3e0818b0dd
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/TitleBar.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: titleBar
+ property string untaggedString: "Uploads from everyone"
+ property string taggedString: "Recent uploads tagged "
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Item {
+ id: container
+ width: (parent.width * 2) - 55 ; height: parent.height
+
+ function accept() {
+ titleBar.state = ""
+ background.state = ""
+ rssModel.tags = editor.text
+ }
+
+ Item {
+ id:imageBox
+ x: 6; width: 0; height: 50; smooth: true
+ anchors.verticalCenter: parent.verticalCenter
+
+ UserModel { user: rssModel.from; id: userModel }
+ Component {
+ id: imgDelegate;
+ Item {
+ id:imageitem
+ visible:true
+ Loading { width:48; height:48; visible: realImage.status != Image.Ready }
+ Image { id: realImage; source: image; width:48; height:48; opacity:0; }
+ states:
+ State {
+ name: "loaded"
+ when: (realImage.status == Image.Ready)
+ PropertyChanges { target: realImage; opacity:1 }
+ }
+ transitions: Transition {
+ NumberAnimation { target: realImage; property: "opacity"; duration: 200 }
+ }
+ }
+ }
+ ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate }
+ states:
+ State {
+ when: !userModel.user==""
+ PropertyChanges { target: imageBox; width: 50; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: imageBox; property: "width"; duration: 200 }
+ }
+ }
+
+ Image {
+ id: quitButton
+ x: 5
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/quit.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+ Text {
+ id: categoryText
+ anchors {
+ left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ elide: Text.ElideLeft
+ text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from)
+ font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black"
+ font.pixelSize: 12
+ }
+ }
+
+ states: State {
+ name: "Tags"
+ PropertyChanges { target: container; x: -tagButton.x + 5 }
+ PropertyChanges { target: editor; focus: true }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/ToolBar.qml b/examples/qml/twitter/TwitterCore/ToolBar.qml
new file mode 100644
index 0000000000..d4265f3e98
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/ToolBar.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: toolbar
+
+ property alias button1Label: button1.text
+ property alias button2Label: button2.text
+ signal button1Clicked
+ signal button2Clicked
+ focus:true
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+ Button {
+ id: button1
+ anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32
+ onClicked: toolbar.button1Clicked()
+ focus:true
+ }
+ Button {
+ id: button2
+ anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32
+ onClicked: toolbar.button2Clicked()
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/UserModel.qml b/examples/qml/twitter/TwitterCore/UserModel.qml
new file mode 100644
index 0000000000..428089b539
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/UserModel.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+//This "model" gets the user information about the searched user. Mainly for the icon.
+
+Item { id: wrapper
+ property variant model: xmlModel
+ property string user : ""
+ property int status: xmlModel.status
+ function reload() { xmlModel.reload(); }
+ XmlListModel {
+ id: xmlModel
+
+ source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : ""
+ query: "/user"
+
+ XmlRole { name: "name"; query: "name/string()" }
+ XmlRole { name: "screenName"; query: "screen_name/string()" }
+ XmlRole { name: "image"; query: "profile_image_url/string()" }
+ XmlRole { name: "location"; query: "location/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "followers"; query: "followers_count/string()" }
+ //TODO: Could also get the user's color scheme, timezone and a few other things
+ }
+}
diff --git a/examples/qml/twitter/TwitterCore/images/gloss.png b/examples/qml/twitter/TwitterCore/images/gloss.png
new file mode 100644
index 0000000000..5d370cd93d
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/gloss.png
Binary files differ
diff --git a/examples/qml/twitter/TwitterCore/images/lineedit.png b/examples/qml/twitter/TwitterCore/images/lineedit.png
new file mode 100644
index 0000000000..2cc38dc35b
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/lineedit.png
Binary files differ
diff --git a/examples/qml/twitter/TwitterCore/images/lineedit.sci b/examples/qml/twitter/TwitterCore/images/lineedit.sci
new file mode 100644
index 0000000000..054bff78be
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/lineedit.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/examples/qml/twitter/TwitterCore/images/loading.png b/examples/qml/twitter/TwitterCore/images/loading.png
new file mode 100644
index 0000000000..47a1589c5d
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/loading.png
Binary files differ
diff --git a/examples/qml/twitter/TwitterCore/images/quit.png b/examples/qml/twitter/TwitterCore/images/quit.png
new file mode 100644
index 0000000000..5bda1b6e0d
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/quit.png
Binary files differ
diff --git a/examples/qml/twitter/TwitterCore/images/stripes.png b/examples/qml/twitter/TwitterCore/images/stripes.png
new file mode 100644
index 0000000000..9f36727ea4
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/stripes.png
Binary files differ
diff --git a/examples/qml/twitter/TwitterCore/images/titlebar.png b/examples/qml/twitter/TwitterCore/images/titlebar.png
new file mode 100644
index 0000000000..51c90082d0
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/titlebar.png
Binary files differ
diff --git a/examples/qml/twitter/TwitterCore/images/titlebar.sci b/examples/qml/twitter/TwitterCore/images/titlebar.sci
new file mode 100644
index 0000000000..0418d94cd6
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/titlebar.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/examples/qml/twitter/TwitterCore/images/toolbutton.png b/examples/qml/twitter/TwitterCore/images/toolbutton.png
new file mode 100644
index 0000000000..11310013ee
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/toolbutton.png
Binary files differ
diff --git a/examples/qml/twitter/TwitterCore/images/toolbutton.sci b/examples/qml/twitter/TwitterCore/images/toolbutton.sci
new file mode 100644
index 0000000000..9e4f965307
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/images/toolbutton.sci
@@ -0,0 +1,5 @@
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/examples/qml/twitter/TwitterCore/qmldir b/examples/qml/twitter/TwitterCore/qmldir
new file mode 100644
index 0000000000..452a648b23
--- /dev/null
+++ b/examples/qml/twitter/TwitterCore/qmldir
@@ -0,0 +1,10 @@
+SearchView 2.0 SearchView.qml
+Button 2.0 Button.qml
+Input 2.0 Input.qml
+FatDelegate 2.0 FatDelegate.qml
+Loading 2.0 Loading.qml
+MultiTitleBar 2.0 MultiTitleBar.qml
+TitleBar 2.0 TitleBar.qml
+RssModel 2.0 RssModel.qml
+UserModel 2.0 UserModel.qml
+ToolBar 2.0 ToolBar.qml
diff --git a/examples/qml/twitter/twitter.qml b/examples/qml/twitter/twitter.qml
new file mode 100644
index 0000000000..aca0968cfb
--- /dev/null
+++ b/examples/qml/twitter/twitter.qml
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+import "TwitterCore" 2.0 as Twitter
+
+Item {
+ id: screen; width: 320; height: 480
+ property bool userView : false
+ property variant tmpStr
+ function setUser(str){hack.running = true; tmpStr = str}
+ function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""}
+ state:"searchquery"
+ //Workaround for bug 260266
+ Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
+ Keys.onEscapePressed: screen.state="searchquery"
+ Keys.onBacktabPressed: screen.state="searchquery"
+ Rectangle {
+ id: background
+ anchors.fill: parent; color: "#343434";
+
+ state:"searchquery"
+ Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: screen.focus = false;
+ }
+
+ Twitter.RssModel { id: rssModel }
+ Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'}
+ Text {
+ width: 180
+ text: "Could not access twitter using this screen name and password pair.";
+ color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap
+ visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent
+ }
+
+ Item {
+ id: views
+ x: 2; width: parent.width - 4
+ y:60 //Below the title bars
+ height: parent.height - 100
+
+ Text {
+ id:title
+ text: "Search Twitter"
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black"
+ opacity:0
+ }
+
+ Twitter.SearchView{
+ id: searchView
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.width; height: parent.height-60;
+ x: -(screen.width * 1.5)
+ }
+
+ Twitter.FatDelegate { id: fatDelegate }
+ ListView {
+ id: mainView; model: rssModel.model; delegate: fatDelegate;
+ width: parent.width; height: parent.height; x: 0; cacheBuffer: 100;
+ }
+ }
+
+ Twitter.MultiTitleBar { id: titleBar; width: parent.width }
+ Twitter.ToolBar { id: toolBar; height: 40;
+ //anchors.bottom: parent.bottom;
+ //TODO: Use anchor changes instead of hard coding
+ y: screen.height - 40
+ width: parent.width; opacity: 0.9
+ button1Label: "New Search"
+ button2Label: "Update"
+ onButton1Clicked:
+ {
+ screen.state="searchquery"
+ }
+ onButton2Clicked: rssModel.reload();
+ }
+ }
+ states: [
+ State {
+ name: "searchquery";
+ PropertyChanges { target: searchView; x: 0; focus:true}
+ PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
+ PropertyChanges { target: titleBar; y: -80 }
+ PropertyChanges { target: toolBar; y: screen.height }
+ PropertyChanges { target: toolBar }
+ PropertyChanges { target: title; opacity:1}
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } }
+ ]
+}
diff --git a/examples/qml/twitter/twitter.qmlproject b/examples/qml/twitter/twitter.qmlproject
new file mode 100644
index 0000000000..b14f71fdfd
--- /dev/null
+++ b/examples/qml/twitter/twitter.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "twitter.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/ui-components/dialcontrol/content/Dial.qml b/examples/qml/ui-components/dialcontrol/content/Dial.qml
new file mode 100644
index 0000000000..c61adee364
--- /dev/null
+++ b/examples/qml/ui-components/dialcontrol/content/Dial.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+ property real value : 0
+
+ width: 210; height: 210
+
+ Image { source: "background.png" }
+
+//! [needle_shadow]
+ Image {
+ x: 96
+ y: 35
+ source: "needle_shadow.png"
+ transform: Rotation {
+ origin.x: 9; origin.y: 67
+ angle: needleRotation.angle
+ }
+ }
+//! [needle_shadow]
+//! [needle]
+ Image {
+ id: needle
+ x: 98; y: 33
+ smooth: true
+ source: "needle.png"
+ transform: Rotation {
+ id: needleRotation
+ origin.x: 5; origin.y: 65
+ //! [needle angle]
+ angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
+ Behavior on angle {
+ SpringAnimation {
+ spring: 1.4
+ damping: .15
+ }
+ }
+ //! [needle angle]
+ }
+ }
+//! [needle]
+//! [overlay]
+ Image { x: 21; y: 18; source: "overlay.png" }
+//! [overlay]
+}
diff --git a/examples/qml/ui-components/dialcontrol/content/QuitButton.qml b/examples/qml/ui-components/dialcontrol/content/QuitButton.qml
new file mode 100644
index 0000000000..702b892d23
--- /dev/null
+++ b/examples/qml/ui-components/dialcontrol/content/QuitButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Image {
+ source: "quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: Qt.quit()
+ }
+}
diff --git a/examples/qml/ui-components/dialcontrol/content/background.png b/examples/qml/ui-components/dialcontrol/content/background.png
new file mode 100644
index 0000000000..75d555d7ab
--- /dev/null
+++ b/examples/qml/ui-components/dialcontrol/content/background.png
Binary files differ
diff --git a/examples/qml/ui-components/dialcontrol/content/needle.png b/examples/qml/ui-components/dialcontrol/content/needle.png
new file mode 100644
index 0000000000..2d19f75039
--- /dev/null
+++ b/examples/qml/ui-components/dialcontrol/content/needle.png
Binary files differ
diff --git a/examples/qml/ui-components/dialcontrol/content/needle_shadow.png b/examples/qml/ui-components/dialcontrol/content/needle_shadow.png
new file mode 100644
index 0000000000..8d8a928cc5
--- /dev/null
+++ b/examples/qml/ui-components/dialcontrol/content/needle_shadow.png
Binary files differ
diff --git a/examples/qml/ui-components/dialcontrol/content/overlay.png b/examples/qml/ui-components/dialcontrol/content/overlay.png
new file mode 100644
index 0000000000..3860a7b590
--- /dev/null
+++ b/examples/qml/ui-components/dialcontrol/content/overlay.png
Binary files differ
diff --git a/examples/qml/ui-components/dialcontrol/content/quit.png b/examples/qml/ui-components/dialcontrol/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/qml/ui-components/dialcontrol/content/quit.png
Binary files differ
diff --git a/examples/qml/ui-components/dialcontrol/dialcontrol.qml b/examples/qml/ui-components/dialcontrol/dialcontrol.qml
new file mode 100644
index 0000000000..d645b34aa4
--- /dev/null
+++ b/examples/qml/ui-components/dialcontrol/dialcontrol.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [imports]
+import QtQuick 2.0
+import "content"
+//! [imports]
+
+//! [0]
+Rectangle {
+ color: "#545454"
+ width: 300; height: 300
+
+ // Dial with a slider to adjust it
+ Dial {
+ id: dial
+ anchors.centerIn: parent
+ value: slider.x * 100 / (container.width - 34)
+ }
+
+ Rectangle {
+ id: container
+ anchors { bottom: parent.bottom; left: parent.left
+ right: parent.right; leftMargin: 20; rightMargin: 20
+ bottomMargin: 10
+ }
+ height: 16
+
+ radius: 8
+ opacity: 0.7
+ smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "gray" }
+ GradientStop { position: 1.0; color: "white" }
+ }
+
+ Rectangle {
+ id: slider
+ x: 1; y: 1; width: 30; height: 14
+ radius: 6
+ smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#424242" }
+ GradientStop { position: 1.0; color: "black" }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ anchors.margins: -16 // Increase mouse area a lot outside the slider
+ drag.target: parent; drag.axis: Drag.XAxis
+ drag.minimumX: 2; drag.maximumX: container.width - 32
+ }
+ }
+ }
+ QuitButton {
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.margins: 10
+ }
+}
+//! [0]
diff --git a/examples/qml/ui-components/flipable/content/5_heart.png b/examples/qml/ui-components/flipable/content/5_heart.png
new file mode 100644
index 0000000000..fb59d81453
--- /dev/null
+++ b/examples/qml/ui-components/flipable/content/5_heart.png
Binary files differ
diff --git a/examples/qml/ui-components/flipable/content/9_club.png b/examples/qml/ui-components/flipable/content/9_club.png
new file mode 100644
index 0000000000..2545001904
--- /dev/null
+++ b/examples/qml/ui-components/flipable/content/9_club.png
Binary files differ
diff --git a/examples/qml/ui-components/flipable/content/Card.qml b/examples/qml/ui-components/flipable/content/Card.qml
new file mode 100644
index 0000000000..6006ea14fc
--- /dev/null
+++ b/examples/qml/ui-components/flipable/content/Card.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Flipable {
+ id: container
+
+ property alias source: frontImage.source
+ property bool flipped: true
+ property int xAxis: 0
+ property int yAxis: 0
+ property int angle: 0
+
+ width: front.width; height: front.height
+
+ front: Image { id: frontImage; smooth: true }
+ back: Image { source: "back.png"; smooth: true }
+
+ state: "back"
+
+ MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped }
+
+ transform: Rotation {
+ id: rotation; origin.x: container.width / 2; origin.y: container.height / 2
+ axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0
+ }
+
+ states: State {
+ name: "back"; when: container.flipped
+ PropertyChanges { target: rotation; angle: container.angle }
+ }
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { target: rotation; properties: "angle"; duration: 600 }
+ SequentialAnimation {
+ NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 }
+ NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 }
+ }
+ }
+ }
+}
diff --git a/examples/qml/ui-components/flipable/content/back.png b/examples/qml/ui-components/flipable/content/back.png
new file mode 100644
index 0000000000..f715d7487e
--- /dev/null
+++ b/examples/qml/ui-components/flipable/content/back.png
Binary files differ
diff --git a/examples/qml/ui-components/flipable/flipable.qml b/examples/qml/ui-components/flipable/flipable.qml
new file mode 100644
index 0000000000..4af64afc53
--- /dev/null
+++ b/examples/qml/ui-components/flipable/flipable.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: window
+
+ width: 480; height: 320
+ color: "darkgreen"
+
+ Row {
+ anchors.centerIn: parent; spacing: 30
+ Card { source: "content/9_club.png"; angle: 180; yAxis: 1 }
+ Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 }
+ }
+}
diff --git a/examples/qml/ui-components/progressbar/content/ProgressBar.qml b/examples/qml/ui-components/progressbar/content/ProgressBar.qml
new file mode 100644
index 0000000000..c9be8d7336
--- /dev/null
+++ b/examples/qml/ui-components/progressbar/content/ProgressBar.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: progressbar
+
+ property int minimum: 0
+ property int maximum: 100
+ property int value: 0
+ property alias color: gradient1.color
+ property alias secondColor: gradient2.color
+
+ width: 250; height: 23
+ clip: true
+
+ BorderImage {
+ source: "background.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ }
+
+ Rectangle {
+ id: highlight
+
+ property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6)
+
+ width: highlight.widthDest
+ Behavior on width { SmoothedAnimation { velocity: 1200 } }
+
+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 }
+ radius: 1
+ gradient: Gradient {
+ GradientStop { id: gradient1; position: 0.0 }
+ GradientStop { id: gradient2; position: 1.0 }
+ }
+
+ }
+ Text {
+ anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter }
+ color: "white"
+ font.bold: true
+ text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%'
+ }
+}
diff --git a/examples/qml/ui-components/progressbar/content/background.png b/examples/qml/ui-components/progressbar/content/background.png
new file mode 100644
index 0000000000..9044226f85
--- /dev/null
+++ b/examples/qml/ui-components/progressbar/content/background.png
Binary files differ
diff --git a/examples/qml/ui-components/progressbar/main.qml b/examples/qml/ui-components/progressbar/main.qml
new file mode 100644
index 0000000000..367e4c1265
--- /dev/null
+++ b/examples/qml/ui-components/progressbar/main.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: main
+
+ width: 600; height: 405
+ color: "#edecec"
+
+ Flickable {
+ anchors.fill: parent
+ contentHeight: column.height + 20
+
+ Column {
+ id: column
+ x: 10; y: 10
+ spacing: 10
+
+ Repeater {
+ model: 25
+
+ ProgressBar {
+ property int r: Math.floor(Math.random() * 5000 + 1000)
+ width: main.width - 20
+
+ NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite }
+ ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite }
+ ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/qml/ui-components/scrollbar/ScrollBar.qml b/examples/qml/ui-components/scrollbar/ScrollBar.qml
new file mode 100644
index 0000000000..a3d0d3841c
--- /dev/null
+++ b/examples/qml/ui-components/scrollbar/ScrollBar.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: scrollBar
+
+ // The properties that define the scrollbar's state.
+ // position and pageSize are in the range 0.0 - 1.0. They are relative to the
+ // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
+ // of the height of the view.
+ // orientation can be either Qt.Vertical or Qt.Horizontal
+ property real position
+ property real pageSize
+ property variant orientation : Qt.Vertical
+
+ // A light, semi-transparent background
+ Rectangle {
+ id: background
+ anchors.fill: parent
+ radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
+ color: "white"
+ opacity: 0.3
+ }
+
+ // Size the bar to the required size, depending upon the orientation.
+ Rectangle {
+ x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
+ y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
+ width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
+ height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
+ radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
+ color: "black"
+ opacity: 0.7
+ }
+}
diff --git a/examples/qml/ui-components/scrollbar/main.qml b/examples/qml/ui-components/scrollbar/main.qml
new file mode 100644
index 0000000000..a7d602b437
--- /dev/null
+++ b/examples/qml/ui-components/scrollbar/main.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 640
+ height: 480
+
+ // Create a flickable to view a large image.
+ Flickable {
+ id: view
+ anchors.fill: parent
+ contentWidth: picture.width
+ contentHeight: picture.height
+
+ Image {
+ id: picture
+ source: "pics/niagara_falls.jpg"
+ asynchronous: true
+ }
+
+ // Only show the scrollbars when the view is moving.
+ states: State {
+ name: "ShowBars"
+ when: view.movingVertically || view.movingHorizontally
+ PropertyChanges { target: verticalScrollBar; opacity: 1 }
+ PropertyChanges { target: horizontalScrollBar; opacity: 1 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "opacity"; duration: 400 }
+ }
+ }
+
+ // Attach scrollbars to the right and bottom edges of the view.
+ ScrollBar {
+ id: verticalScrollBar
+ width: 12; height: view.height-12
+ anchors.right: view.right
+ opacity: 0
+ orientation: Qt.Vertical
+ position: view.visibleArea.yPosition
+ pageSize: view.visibleArea.heightRatio
+ }
+
+ ScrollBar {
+ id: horizontalScrollBar
+ width: view.width-12; height: 12
+ anchors.bottom: view.bottom
+ opacity: 0
+ orientation: Qt.Horizontal
+ position: view.visibleArea.xPosition
+ pageSize: view.visibleArea.widthRatio
+ }
+}
diff --git a/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg
new file mode 100644
index 0000000000..e625c0d3e6
--- /dev/null
+++ b/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg
Binary files differ
diff --git a/examples/qml/ui-components/scrollbar/scrollbar.qmlproject b/examples/qml/ui-components/scrollbar/scrollbar.qmlproject
new file mode 100644
index 0000000000..e5a8bf02ca
--- /dev/null
+++ b/examples/qml/ui-components/scrollbar/scrollbar.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/ui-components/searchbox/SearchBox.qml b/examples/qml/ui-components/searchbox/SearchBox.qml
new file mode 100644
index 0000000000..6f6f486412
--- /dev/null
+++ b/examples/qml/ui-components/searchbox/SearchBox.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: focusScope
+ width: 250; height: 28
+
+ BorderImage {
+ source: "images/lineedit-bg.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ }
+
+ BorderImage {
+ source: "images/lineedit-bg-focus.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ visible: parent.activeFocus ? true : false
+ }
+
+ Text {
+ id: typeSomething
+ anchors.fill: parent; anchors.leftMargin: 8
+ verticalAlignment: Text.AlignVCenter
+ text: "Type something..."
+ color: "gray"
+ font.italic: true
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); }
+ }
+
+ TextInput {
+ id: textInput
+ anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter }
+ focus: true
+ selectByMouse: true
+ }
+
+ Image {
+ id: clear
+ anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
+ source: "images/clear.png"
+ opacity: 0
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); }
+ }
+ }
+
+ states: State {
+ name: "hasText"; when: textInput.text != ''
+ PropertyChanges { target: typeSomething; opacity: 0 }
+ PropertyChanges { target: clear; opacity: 1 }
+ }
+
+ transitions: [
+ Transition {
+ from: ""; to: "hasText"
+ NumberAnimation { exclude: typeSomething; properties: "opacity" }
+ },
+ Transition {
+ from: "hasText"; to: ""
+ NumberAnimation { properties: "opacity" }
+ }
+ ]
+}
diff --git a/examples/qml/ui-components/searchbox/images/clear.png b/examples/qml/ui-components/searchbox/images/clear.png
new file mode 100644
index 0000000000..91eb270695
--- /dev/null
+++ b/examples/qml/ui-components/searchbox/images/clear.png
Binary files differ
diff --git a/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png
new file mode 100644
index 0000000000..bbfac38d2d
--- /dev/null
+++ b/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png
Binary files differ
diff --git a/examples/qml/ui-components/searchbox/images/lineedit-bg.png b/examples/qml/ui-components/searchbox/images/lineedit-bg.png
new file mode 100644
index 0000000000..9044226f85
--- /dev/null
+++ b/examples/qml/ui-components/searchbox/images/lineedit-bg.png
Binary files differ
diff --git a/examples/qml/ui-components/searchbox/main.qml b/examples/qml/ui-components/searchbox/main.qml
new file mode 100644
index 0000000000..6e9731cf9c
--- /dev/null
+++ b/examples/qml/ui-components/searchbox/main.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 500; height: 250
+ color: "#edecec"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: page.focus = false;
+ }
+ Column {
+ anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }
+ spacing: 10
+
+ SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true }
+ SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 }
+ SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 }
+ }
+}
diff --git a/examples/qml/ui-components/searchbox/searchbox.qmlproject b/examples/qml/ui-components/searchbox/searchbox.qmlproject
new file mode 100644
index 0000000000..e5a8bf02ca
--- /dev/null
+++ b/examples/qml/ui-components/searchbox/searchbox.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/ui-components/slideswitch/content/Switch.qml b/examples/qml/ui-components/slideswitch/content/Switch.qml
new file mode 100644
index 0000000000..981fc16673
--- /dev/null
+++ b/examples/qml/ui-components/slideswitch/content/Switch.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Item {
+ id: toggleswitch
+ width: background.width; height: background.height
+
+//![1]
+ property bool on: false
+//![1]
+
+//![2]
+ function toggle() {
+ if (toggleswitch.state == "on")
+ toggleswitch.state = "off";
+ else
+ toggleswitch.state = "on";
+ }
+//![2]
+
+//![3]
+ function releaseSwitch() {
+ if (knob.x == 1) {
+ if (toggleswitch.state == "off") return;
+ }
+ if (knob.x == 78) {
+ if (toggleswitch.state == "on") return;
+ }
+ toggle();
+ }
+//![3]
+
+//![4]
+ Image {
+ id: background
+ source: "background.png"
+ MouseArea { anchors.fill: parent; onClicked: toggle() }
+ }
+//![4]
+
+//![5]
+ Image {
+ id: knob
+ x: 1; y: 2
+ source: "knob.png"
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78
+ onClicked: toggle()
+ onReleased: releaseSwitch()
+ }
+ }
+//![5]
+
+//![6]
+ states: [
+ State {
+ name: "on"
+ PropertyChanges { target: knob; x: 78 }
+ PropertyChanges { target: toggleswitch; on: true }
+ },
+ State {
+ name: "off"
+ PropertyChanges { target: knob; x: 1 }
+ PropertyChanges { target: toggleswitch; on: false }
+ }
+ ]
+//![6]
+
+//![7]
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 }
+ }
+//![7]
+}
+//![0]
diff --git a/examples/qml/ui-components/slideswitch/content/background.png b/examples/qml/ui-components/slideswitch/content/background.png
new file mode 100644
index 0000000000..d736815870
--- /dev/null
+++ b/examples/qml/ui-components/slideswitch/content/background.png
Binary files differ
diff --git a/examples/qml/ui-components/slideswitch/content/background.svg b/examples/qml/ui-components/slideswitch/content/background.svg
new file mode 100644
index 0000000000..f920d3e47a
--- /dev/null
+++ b/examples/qml/ui-components/slideswitch/content/background.svg
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+]>
+<svg version="1.1"
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+ x="0px" y="0px" width="130px" height="56px" viewBox="0 0 130 56" enable-background="new 0 0 130 56" xml:space="preserve">
+<defs>
+</defs>
+<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-37.5005" y1="-66" x2="-37.5005" y2="-121.9985" gradientTransform="matrix(1 0 0 -1 102.5 -66)">
+ <stop offset="0.0056" style="stop-color:#000000"/>
+ <stop offset="1" style="stop-color:#EAECEF"/>
+</linearGradient>
+<path fill="url(#SVGID_1_)" d="M101.998,55.998H28c-15.439,0-28-12.562-28-28C0,12.56,12.561,0,28,0h73.998
+ c15.439,0,28,12.559,28,27.998C129.998,43.438,117.438,55.998,101.998,55.998L101.998,55.998z"/>
+<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="-5.5" y1="-132.1338" x2="-69.5002" y2="-55.8613" gradientTransform="matrix(1 0 0 -1 102.5 -66)">
+ <stop offset="0.0056" style="stop-color:#000000"/>
+ <stop offset="1" style="stop-color:#828385"/>
+</linearGradient>
+<path fill="url(#SVGID_2_)" d="M127.999,27.998c0,14.359-11.642,26-26,26h-74c-14.359,0-26-11.641-26-26l0,0
+ c0-14.359,11.641-26,26-26h74C116.357,1.998,127.999,13.639,127.999,27.998L127.999,27.998z"/>
+</svg>
diff --git a/examples/qml/ui-components/slideswitch/content/knob.png b/examples/qml/ui-components/slideswitch/content/knob.png
new file mode 100644
index 0000000000..ee0a436f84
--- /dev/null
+++ b/examples/qml/ui-components/slideswitch/content/knob.png
Binary files differ
diff --git a/examples/qml/ui-components/slideswitch/content/knob.svg b/examples/qml/ui-components/slideswitch/content/knob.svg
new file mode 100644
index 0000000000..fb6933718e
--- /dev/null
+++ b/examples/qml/ui-components/slideswitch/content/knob.svg
@@ -0,0 +1,867 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ x="0px"
+ y="0px"
+ width="52px"
+ height="52px"
+ viewBox="0 0 52 52"
+ enable-background="new 0 0 52 52"
+ xml:space="preserve"
+ id="svg3883"
+ sodipodi:version="0.32"
+ inkscape:version="0.44.1"
+ sodipodi:docname="knob_on.svg"
+ sodipodi:docbase="/local/axel/embeddedwidgets/embeddedstories/skins/svgslideswitch/MetallicBrush"><metadata
+ id="metadata4200"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
+ inkscape:window-height="640"
+ inkscape:window-width="937"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:zoom="8.3653846"
+ inkscape:cx="26.000002"
+ inkscape:cy="26"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:current-layer="svg3883" />
+<defs
+ id="defs3885">
+</defs>
+<linearGradient
+ id="SVGID_1_"
+ gradientUnits="userSpaceOnUse"
+ x1="-59.7866"
+ y1="-115.917"
+ x2="-93.2123"
+ y2="-76.0818"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#000000"
+ id="stop3888" />
+ <stop
+ offset="1"
+ style="stop-color:#EAECEF"
+ id="stop3890" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="26"
+ id="circle3892"
+ style="fill:url(#SVGID_1_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="26"
+ sodipodi:ry="26"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_2_"
+ gradientUnits="userSpaceOnUse"
+ x1="-100.5"
+ y1="-96"
+ x2="-52.5"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3895" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3897" />
+ <stop
+ offset="0.6043"
+ style="stop-color:#E7EAED"
+ id="stop3899" />
+ <stop
+ offset="0.6751"
+ style="stop-color:#DEE4E7"
+ id="stop3901" />
+ <stop
+ offset="0.7358"
+ style="stop-color:#CFD9DD"
+ id="stop3903" />
+ <stop
+ offset="0.791"
+ style="stop-color:#B9CACF"
+ id="stop3905" />
+ <stop
+ offset="0.8425"
+ style="stop-color:#9EB6BD"
+ id="stop3907" />
+ <stop
+ offset="0.891"
+ style="stop-color:#7B9EA7"
+ id="stop3909" />
+ <stop
+ offset="0.9374"
+ style="stop-color:#53828C"
+ id="stop3911" />
+ <stop
+ offset="0.9809"
+ style="stop-color:#25626E"
+ id="stop3913" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3915" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="24"
+ id="circle3917"
+ style="fill:url(#SVGID_2_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="24"
+ sodipodi:ry="24"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_3_"
+ gradientUnits="userSpaceOnUse"
+ x1="-98.6328"
+ y1="-96"
+ x2="-54.3672"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3920" />
+ <stop
+ offset="0.073"
+ style="stop-color:#8FAECB"
+ id="stop3922" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3924" />
+ <stop
+ offset="0.5902"
+ style="stop-color:#E7E9ED"
+ id="stop3926" />
+ <stop
+ offset="0.618"
+ style="stop-color:#E4E7EB"
+ id="stop3928" />
+ <stop
+ offset="0.6697"
+ style="stop-color:#E0E4E9"
+ id="stop3930" />
+ <stop
+ offset="0.7211"
+ style="stop-color:#D4DCE1"
+ id="stop3932" />
+ <stop
+ offset="0.7722"
+ style="stop-color:#C0CFD5"
+ id="stop3934" />
+ <stop
+ offset="0.809"
+ style="stop-color:#ADC2C9"
+ id="stop3936" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3938" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="22.132999"
+ id="circle3940"
+ style="fill:url(#SVGID_3_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="22.132999"
+ sodipodi:ry="22.132999"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_4_"
+ gradientUnits="userSpaceOnUse"
+ x1="-96.7671"
+ y1="-96"
+ x2="-56.2324"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3943" />
+ <stop
+ offset="0.073"
+ style="stop-color:#86A7C4"
+ id="stop3945" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3947" />
+ <stop
+ offset="0.577"
+ style="stop-color:#E7EAED"
+ id="stop3949" />
+ <stop
+ offset="0.618"
+ style="stop-color:#E1E6EA"
+ id="stop3951" />
+ <stop
+ offset="0.6697"
+ style="stop-color:#DDE3E8"
+ id="stop3953" />
+ <stop
+ offset="0.7211"
+ style="stop-color:#D1DBE1"
+ id="stop3955" />
+ <stop
+ offset="0.7722"
+ style="stop-color:#BDCDD5"
+ id="stop3957" />
+ <stop
+ offset="0.809"
+ style="stop-color:#AAC0CA"
+ id="stop3959" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3961" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="20.267"
+ id="circle3963"
+ style="fill:url(#SVGID_4_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="20.267"
+ sodipodi:ry="20.267"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_5_"
+ gradientUnits="userSpaceOnUse"
+ x1="-94.8999"
+ y1="-96"
+ x2="-58.0996"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3966" />
+ <stop
+ offset="0.073"
+ style="stop-color:#7E9FBC"
+ id="stop3968" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3970" />
+ <stop
+ offset="0.5709"
+ style="stop-color:#E6E9ED"
+ id="stop3972" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DFE4E9"
+ id="stop3974" />
+ <stop
+ offset="0.6687"
+ style="stop-color:#DBE1E7"
+ id="stop3976" />
+ <stop
+ offset="0.7193"
+ style="stop-color:#CFD9E0"
+ id="stop3978" />
+ <stop
+ offset="0.7695"
+ style="stop-color:#BBCCD6"
+ id="stop3980" />
+ <stop
+ offset="0.809"
+ style="stop-color:#A6BECA"
+ id="stop3982" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3984" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="18.4"
+ id="circle3986"
+ style="fill:url(#SVGID_5_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="18.4"
+ sodipodi:ry="18.4"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_6_"
+ gradientUnits="userSpaceOnUse"
+ x1="-93.0332"
+ y1="-96"
+ x2="-59.9668"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3989" />
+ <stop
+ offset="0.073"
+ style="stop-color:#7697B4"
+ id="stop3991" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3993" />
+ <stop
+ offset="0.5636"
+ style="stop-color:#E6E9ED"
+ id="stop3995" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DCE2E8"
+ id="stop3997" />
+ <stop
+ offset="0.6687"
+ style="stop-color:#D8DFE6"
+ id="stop3999" />
+ <stop
+ offset="0.7193"
+ style="stop-color:#CCD7E0"
+ id="stop4001" />
+ <stop
+ offset="0.7695"
+ style="stop-color:#B8CAD5"
+ id="stop4003" />
+ <stop
+ offset="0.809"
+ style="stop-color:#A3BCCA"
+ id="stop4005" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4007" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="16.533001"
+ id="circle4009"
+ style="fill:url(#SVGID_6_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="16.533001"
+ sodipodi:ry="16.533001"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_7_"
+ gradientUnits="userSpaceOnUse"
+ x1="-91.167"
+ y1="-96"
+ x2="-61.833"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4012" />
+ <stop
+ offset="0.073"
+ style="stop-color:#6D8FAD"
+ id="stop4014" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4016" />
+ <stop
+ offset="0.5605"
+ style="stop-color:#E5E8EC"
+ id="stop4018" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DAE1E7"
+ id="stop4020" />
+ <stop
+ offset="0.6679"
+ style="stop-color:#D6DEE5"
+ id="stop4022" />
+ <stop
+ offset="0.7175"
+ style="stop-color:#CAD6DF"
+ id="stop4024" />
+ <stop
+ offset="0.7669"
+ style="stop-color:#B6C9D6"
+ id="stop4026" />
+ <stop
+ offset="0.809"
+ style="stop-color:#9FBACB"
+ id="stop4028" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4030" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="14.667"
+ id="circle4032"
+ style="fill:url(#SVGID_7_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="14.667"
+ sodipodi:ry="14.667"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_8_"
+ gradientUnits="userSpaceOnUse"
+ x1="-89.2998"
+ y1="-96"
+ x2="-63.7002"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4035" />
+ <stop
+ offset="0.073"
+ style="stop-color:#6587A5"
+ id="stop4037" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4039" />
+ <stop
+ offset="0.5588"
+ style="stop-color:#E4E8EC"
+ id="stop4041" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D8DFE7"
+ id="stop4043" />
+ <stop
+ offset="0.6675"
+ style="stop-color:#D4DCE5"
+ id="stop4045" />
+ <stop
+ offset="0.7167"
+ style="stop-color:#C8D5E0"
+ id="stop4047" />
+ <stop
+ offset="0.7657"
+ style="stop-color:#B4C8D6"
+ id="stop4049" />
+ <stop
+ offset="0.809"
+ style="stop-color:#9CB8CB"
+ id="stop4051" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4053" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="12.8"
+ id="circle4055"
+ style="fill:url(#SVGID_8_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="12.8"
+ sodipodi:ry="12.8"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_9_"
+ gradientUnits="userSpaceOnUse"
+ x1="-87.4331"
+ y1="-96"
+ x2="-65.5664"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4058" />
+ <stop
+ offset="0.073"
+ style="stop-color:#5D809D"
+ id="stop4060" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4062" />
+ <stop
+ offset="0.5567"
+ style="stop-color:#E3E7EC"
+ id="stop4064" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D5DDE6"
+ id="stop4066" />
+ <stop
+ offset="0.6671"
+ style="stop-color:#D1DAE4"
+ id="stop4068" />
+ <stop
+ offset="0.7159"
+ style="stop-color:#C5D3DF"
+ id="stop4070" />
+ <stop
+ offset="0.7645"
+ style="stop-color:#B1C6D6"
+ id="stop4072" />
+ <stop
+ offset="0.809"
+ style="stop-color:#98B5CB"
+ id="stop4074" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4076" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="10.933"
+ id="circle4078"
+ style="fill:url(#SVGID_9_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="10.933"
+ sodipodi:ry="10.933"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_10_"
+ gradientUnits="userSpaceOnUse"
+ x1="-85.5659"
+ y1="-96"
+ x2="-67.4336"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4081" />
+ <stop
+ offset="0.073"
+ style="stop-color:#547896"
+ id="stop4083" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4085" />
+ <stop
+ offset="0.5588"
+ style="stop-color:#E1E6EB"
+ id="stop4087" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D3DCE5"
+ id="stop4089" />
+ <stop
+ offset="0.6663"
+ style="stop-color:#CFD9E3"
+ id="stop4091" />
+ <stop
+ offset="0.7143"
+ style="stop-color:#C3D2DF"
+ id="stop4093" />
+ <stop
+ offset="0.7621"
+ style="stop-color:#AFC5D7"
+ id="stop4095" />
+ <stop
+ offset="0.809"
+ style="stop-color:#94B3CC"
+ id="stop4097" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4099" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="9.066"
+ id="circle4101"
+ style="fill:url(#SVGID_10_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="9.066"
+ sodipodi:ry="9.066"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_11_"
+ gradientUnits="userSpaceOnUse"
+ x1="-83.7002"
+ y1="-96"
+ x2="-69.2998"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4104" />
+ <stop
+ offset="0.073"
+ style="stop-color:#4C708E"
+ id="stop4106" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4108" />
+ <stop
+ offset="0.5625"
+ style="stop-color:#DEE4EA"
+ id="stop4110" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D0DAE4"
+ id="stop4112" />
+ <stop
+ offset="0.6663"
+ style="stop-color:#CCD7E2"
+ id="stop4114" />
+ <stop
+ offset="0.7143"
+ style="stop-color:#C0D0DE"
+ id="stop4116" />
+ <stop
+ offset="0.7621"
+ style="stop-color:#ACC3D6"
+ id="stop4118" />
+ <stop
+ offset="0.809"
+ style="stop-color:#91B1CC"
+ id="stop4120" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4122" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="7.1999998"
+ id="circle4124"
+ style="fill:url(#SVGID_11_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="7.1999998"
+ sodipodi:ry="7.1999998"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_12_"
+ gradientUnits="userSpaceOnUse"
+ x1="-81.833"
+ y1="-96"
+ x2="-71.167"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4127" />
+ <stop
+ offset="0.073"
+ style="stop-color:#446986"
+ id="stop4129" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4131" />
+ <stop
+ offset="0.5757"
+ style="stop-color:#D9E0E8"
+ id="stop4133" />
+ <stop
+ offset="0.618"
+ style="stop-color:#CED8E3"
+ id="stop4135" />
+ <stop
+ offset="0.6655"
+ style="stop-color:#CAD5E2"
+ id="stop4137" />
+ <stop
+ offset="0.7129"
+ style="stop-color:#BECEDD"
+ id="stop4139" />
+ <stop
+ offset="0.7601"
+ style="stop-color:#AAC1D6"
+ id="stop4141" />
+ <stop
+ offset="0.807"
+ style="stop-color:#8EB0CC"
+ id="stop4143" />
+ <stop
+ offset="0.809"
+ style="stop-color:#8DAFCC"
+ id="stop4145" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4147" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="5.3330002"
+ id="circle4149"
+ style="fill:url(#SVGID_12_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="5.3330002"
+ sodipodi:ry="5.3330002"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_13_"
+ gradientUnits="userSpaceOnUse"
+ x1="-79.9658"
+ y1="-96"
+ x2="-73.0342"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4152" />
+ <stop
+ offset="0.073"
+ style="stop-color:#3B617F"
+ id="stop4154" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4156" />
+ <stop
+ offset="0.6087"
+ style="stop-color:#CED9E3"
+ id="stop4158" />
+ <stop
+ offset="0.618"
+ style="stop-color:#CBD7E2"
+ id="stop4160" />
+ <stop
+ offset="0.6655"
+ style="stop-color:#C7D4E1"
+ id="stop4162" />
+ <stop
+ offset="0.7129"
+ style="stop-color:#BBCDDD"
+ id="stop4164" />
+ <stop
+ offset="0.7601"
+ style="stop-color:#A7C0D6"
+ id="stop4166" />
+ <stop
+ offset="0.807"
+ style="stop-color:#8BAECD"
+ id="stop4168" />
+ <stop
+ offset="0.809"
+ style="stop-color:#8AADCD"
+ id="stop4170" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4172" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="3.4660001"
+ id="circle4174"
+ style="fill:url(#SVGID_13_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="3.4660001"
+ sodipodi:ry="3.4660001"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_14_"
+ gradientUnits="userSpaceOnUse"
+ x1="-78.1001"
+ y1="-96"
+ x2="-74.9004"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4177" />
+ <stop
+ offset="0.073"
+ style="stop-color:#335977"
+ id="stop4179" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4181" />
+ <stop
+ offset="0.618"
+ style="stop-color:#C9D5E1"
+ id="stop4183" />
+ <stop
+ offset="0.6648"
+ style="stop-color:#C5D3E0"
+ id="stop4185" />
+ <stop
+ offset="0.7114"
+ style="stop-color:#B9CBDC"
+ id="stop4187" />
+ <stop
+ offset="0.758"
+ style="stop-color:#A5BFD6"
+ id="stop4189" />
+ <stop
+ offset="0.8042"
+ style="stop-color:#89ADCE"
+ id="stop4191" />
+ <stop
+ offset="0.809"
+ style="stop-color:#86ABCD"
+ id="stop4193" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4195" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="1.6"
+ id="circle4197"
+ style="fill:url(#SVGID_14_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="1.6"
+ sodipodi:ry="1.6"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+</svg> \ No newline at end of file
diff --git a/examples/qml/ui-components/slideswitch/slideswitch.qml b/examples/qml/ui-components/slideswitch/slideswitch.qml
new file mode 100644
index 0000000000..60a331407c
--- /dev/null
+++ b/examples/qml/ui-components/slideswitch/slideswitch.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ color: "white"
+ width: 400; height: 250
+
+//![0]
+ Switch { anchors.centerIn: parent; on: false }
+//![0]
+}
diff --git a/examples/qml/ui-components/spinner/content/Spinner.qml b/examples/qml/ui-components/spinner/content/Spinner.qml
new file mode 100644
index 0000000000..d7bbeb33ee
--- /dev/null
+++ b/examples/qml/ui-components/spinner/content/Spinner.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ property alias model: view.model
+ property alias delegate: view.delegate
+ property alias currentIndex: view.currentIndex
+ property real itemHeight: 30
+
+ source: "spinner-bg.png"
+ clip: true
+
+ PathView {
+ id: view
+ anchors.fill: parent
+
+ pathItemCount: height/itemHeight
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 }
+ dragMargin: view.width/2
+
+ path: Path {
+ startX: view.width/2; startY: -itemHeight/2
+ PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight }
+ }
+ }
+
+ Keys.onDownPressed: view.incrementCurrentIndex()
+ Keys.onUpPressed: view.decrementCurrentIndex()
+}
diff --git a/examples/qml/ui-components/spinner/content/spinner-bg.png b/examples/qml/ui-components/spinner/content/spinner-bg.png
new file mode 100644
index 0000000000..b3556f1f9f
--- /dev/null
+++ b/examples/qml/ui-components/spinner/content/spinner-bg.png
Binary files differ
diff --git a/examples/qml/ui-components/spinner/content/spinner-select.png b/examples/qml/ui-components/spinner/content/spinner-select.png
new file mode 100644
index 0000000000..95a17a1fe2
--- /dev/null
+++ b/examples/qml/ui-components/spinner/content/spinner-select.png
Binary files differ
diff --git a/examples/qml/ui-components/spinner/main.qml b/examples/qml/ui-components/spinner/main.qml
new file mode 100644
index 0000000000..7584c98396
--- /dev/null
+++ b/examples/qml/ui-components/spinner/main.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 240; height: 320
+
+ Column {
+ y: 20; x: 20; spacing: 20
+
+ Spinner {
+ id: spinner
+ width: 200; height: 240
+ focus: true
+ model: 20
+ itemHeight: 30
+ delegate: Text { font.pixelSize: 25; text: index; height: 30 }
+ }
+
+ Text { text: "Current item index: " + spinner.currentIndex }
+ }
+}
diff --git a/examples/qml/ui-components/spinner/spinner.qmlproject b/examples/qml/ui-components/spinner/spinner.qmlproject
new file mode 100644
index 0000000000..e5a8bf02ca
--- /dev/null
+++ b/examples/qml/ui-components/spinner/spinner.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/ui-components/tabwidget/TabWidget.qml b/examples/qml/ui-components/tabwidget/TabWidget.qml
new file mode 100644
index 0000000000..560ed1f58a
--- /dev/null
+++ b/examples/qml/ui-components/tabwidget/TabWidget.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: tabWidget
+
+ // 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 "Property Binding"
+ // documentation for details on default properties.
+ default property alias content: stack.children
+
+ property int current: 0
+
+ onCurrentChanged: setOpacities()
+ Component.onCompleted: setOpacities()
+
+ function setOpacities() {
+ for (var i = 0; i < stack.children.length; ++i) {
+ stack.children[i].opacity = (i == current ? 1 : 0)
+ }
+ }
+
+ Row {
+ id: header
+
+ Repeater {
+ model: stack.children.length
+ delegate: Rectangle {
+ width: tabWidget.width / stack.children.length; height: 36
+
+ Rectangle {
+ width: parent.width; height: 1
+ anchors { bottom: parent.bottom; bottomMargin: 1 }
+ color: "#acb2c2"
+ }
+ BorderImage {
+ anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
+ border { left: 7; right: 7 }
+ source: "tab.png"
+ visible: tabWidget.current == index
+ }
+ Text {
+ horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
+ anchors.fill: parent
+ text: stack.children[index].title
+ elide: Text.ElideRight
+ font.bold: tabWidget.current == index
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: tabWidget.current = index
+ }
+ }
+ }
+ }
+
+ Item {
+ id: stack
+ width: tabWidget.width
+ anchors.top: header.bottom; anchors.bottom: tabWidget.bottom
+ }
+}
diff --git a/examples/qml/ui-components/tabwidget/main.qml b/examples/qml/ui-components/tabwidget/main.qml
new file mode 100644
index 0000000000..df99c11b7d
--- /dev/null
+++ b/examples/qml/ui-components/tabwidget/main.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TabWidget {
+ id: tabs
+ width: 640; height: 480
+
+ Rectangle {
+ property string title: "Red"
+ anchors.fill: parent
+ color: "#e3e3e3"
+
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 20
+ color: "#ff7f7f"
+ Text {
+ width: parent.width - 20
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Roses are red"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
+ }
+ }
+ }
+
+ Rectangle {
+ property string title: "Green"
+ anchors.fill: parent
+ color: "#e3e3e3"
+
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 20
+ color: "#7fff7f"
+ Text {
+ width: parent.width - 20
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Flower stems are green"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
+ }
+ }
+ }
+
+ Rectangle {
+ property string title: "Blue"
+ anchors.fill: parent; color: "#e3e3e3"
+
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 20
+ color: "#7f7fff"
+ Text {
+ width: parent.width - 20
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Violets are blue"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
+ }
+ }
+ }
+}
diff --git a/examples/qml/ui-components/tabwidget/tab.png b/examples/qml/ui-components/tabwidget/tab.png
new file mode 100644
index 0000000000..ad8021605f
--- /dev/null
+++ b/examples/qml/ui-components/tabwidget/tab.png
Binary files differ
diff --git a/examples/qml/ui-components/tabwidget/tabwidget.qmlproject b/examples/qml/ui-components/tabwidget/tabwidget.qmlproject
new file mode 100644
index 0000000000..e5a8bf02ca
--- /dev/null
+++ b/examples/qml/ui-components/tabwidget/tabwidget.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qml/window/Window.qml b/examples/qml/window/Window.qml
new file mode 100644
index 0000000000..48478458c6
--- /dev/null
+++ b/examples/qml/window/Window.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0 as Window
+
+Window.Window {
+ width: 640
+ height: 480
+ visible: true //It's false by default
+ property Component self
+ Component.onCompleted: self = Qt.createComponent("Window.qml")
+ Text{
+ text: "Hello World!"
+ anchors.centerIn: parent
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: self.createObject();
+ }
+}
diff --git a/examples/qml/window/screen/screenInfo.qml b/examples/qml/window/screen/screenInfo.qml
new file mode 100644
index 0000000000..54299ba4e0
--- /dev/null
+++ b/examples/qml/window/screen/screenInfo.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0 as Window
+
+Item {
+ id: root
+ width: 400
+ height: 200
+ Item {
+ id: main
+ state: "orientation " + Window.Screen.orientation
+
+ property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation
+ property real baseWidth: landscapeWindow ? root.height : root.width
+ property real baseHeight: landscapeWindow ? root.width : root.height
+ property real rotationDelta: landscapeWindow ? -90 : 0
+
+ rotation: rotationDelta
+ width: main.baseWidth
+ height: main.baseHeight
+ anchors.centerIn: parent
+
+ Text {
+ text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation
+ anchors.centerIn:parent
+ }
+
+
+ states: [
+ State {
+ name: "orientation " + Qt.LandscapeOrientation
+ PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ },
+ State {
+ name: "orientation " + Qt.InvertedPortraitOrientation
+ PropertyChanges { target: main; rotation: 180 + rotationDelta; }
+ },
+ State {
+ name: "orientation " + Qt.InvertedLandscapeOrientation
+ PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ }
+ ]
+
+ transitions: Transition {
+ SequentialAnimation {
+ RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint }
+ NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
+ }
+ }
+ }
+}
diff --git a/examples/qml/window/standalone.qml b/examples/qml/window/standalone.qml
new file mode 100644
index 0000000000..335cf7b635
--- /dev/null
+++ b/examples/qml/window/standalone.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0 as Window
+
+Item {
+ width: 640
+ height: 480
+ Text {
+ anchors.centerIn: parent
+ text: "First Window"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ Window.Window {
+ width: 640
+ height: 480
+ x: 640
+ y: 480
+ visible: true
+ color: "green"
+ Text {
+ anchors.centerIn: parent
+ text: "Second Window"
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+}
diff --git a/examples/qml/window/window.cpp b/examples/qml/window/window.cpp
new file mode 100644
index 0000000000..2112ab8f45
--- /dev/null
+++ b/examples/qml/window/window.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlComponent>
+#include <QtCore/QUrl>
+#include <QDebug>
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(QUrl::fromLocalFile("Window.qml"));
+ if ( component.isReady() )
+ component.create();
+ else
+ qWarning() << component.errorString();
+ return app.exec();
+}
diff --git a/examples/qml/window/window.pro b/examples/qml/window/window.pro
new file mode 100644
index 0000000000..c4518418f6
--- /dev/null
+++ b/examples/qml/window/window.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+CONFIG += qt
+QT += qml
+
+SOURCES += window.cpp
diff --git a/examples/qml/xml/xmlhttprequest/data.xml b/examples/qml/xml/xmlhttprequest/data.xml
new file mode 100644
index 0000000000..8b7f1e116d
--- /dev/null
+++ b/examples/qml/xml/xmlhttprequest/data.xml
@@ -0,0 +1,5 @@
+<data>
+ <element1 />
+ <element2 />
+</data>
+
diff --git a/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml b/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml
new file mode 100644
index 0000000000..28ba078160
--- /dev/null
+++ b/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 350; height: 400
+
+ function showRequestInfo(text) {
+ log.text = log.text + "\n" + text
+ console.log(text)
+ }
+
+ Text { id: log; anchors.fill: parent; anchors.margins: 10 }
+
+ Rectangle {
+ id: button
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10
+ width: buttonText.width + 10; height: buttonText.height + 10
+ border.width: mouseArea.pressed ? 2 : 1
+ radius : 5; smooth: true
+
+ Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ log.text = ""
+ console.log("\n")
+
+ var doc = new XMLHttpRequest();
+ doc.onreadystatechange = function() {
+ if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ showRequestInfo("Headers -->");
+ showRequestInfo(doc.getAllResponseHeaders ());
+ showRequestInfo("Last modified -->");
+ showRequestInfo(doc.getResponseHeader ("Last-Modified"));
+
+ } else if (doc.readyState == XMLHttpRequest.DONE) {
+ var a = doc.responseXML.documentElement;
+ for (var ii = 0; ii < a.childNodes.length; ++ii) {
+ showRequestInfo(a.childNodes[ii].nodeName);
+ }
+ showRequestInfo("Headers -->");
+ showRequestInfo(doc.getAllResponseHeaders ());
+ showRequestInfo("Last modified -->");
+ showRequestInfo(doc.getResponseHeader ("Last-Modified"));
+ }
+ }
+
+ doc.open("GET", "data.xml");
+ doc.send();
+ }
+ }
+ }
+}
+
diff --git a/examples/qtquick/accessibility/accessibility.pro b/examples/qtquick/accessibility/accessibility.pro
deleted file mode 100644
index 20d68e0c5c..0000000000
--- a/examples/qtquick/accessibility/accessibility.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = app
-
-QT += quick declarative
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility
-qml.files = accessibility.qml content
-qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility
-INSTALLS += target qml
-
diff --git a/examples/qtquick/accessibility/accessibility.qml b/examples/qtquick/accessibility/accessibility.qml
deleted file mode 100644
index ff115ab4b3..0000000000
--- a/examples/qtquick/accessibility/accessibility.qml
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "content"
-
-/*!
- \title QtQuick Examples - Accessibility
- \example qtquick/accessibility
- \brief This example has accessible buttons.
-
-*/
-
-Rectangle {
- id: window
-
- width: 320; height: 480
- color: "white"
-
- Column {
- id: column
- spacing: 6
- anchors.fill: parent
- width: parent.width
- Row {
- spacing: 6
- width: column.width
- Button { width: 100; height: column.h + 20; text: "Send" }
- Button { width: 100; height: column.h + 20; text: "Discard" }
- }
-
- Row {
- spacing: 6
- width: column.width
- height: column.h
- Text {
- id: subjectLabel
- Accessible.role: Accessible.StaticText
- Accessible.name: text
- text: "Subject:"
- }
- Rectangle {
- id: subjectBorder
- Accessible.role: Accessible.EditableText
- Accessible.name: subjectEdit.text
- border.width: 1
- border.color: "black"
- height: subjectEdit.height
- width: 240
- TextInput {
- id: subjectEdit
- text: "Vacation plans"
- }
- }
- }
- Rectangle {
- id: textBorder
- Accessible.role: Accessible.EditableText
- property alias text : textEdit.text
- border.width: 1
- border.color: "black"
- width: parent.width - 2
- height: parent.height - (textBorder.y + column.spacing)
- TextEdit {
- id: textEdit
- text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke"
- width: parent.width
- wrapMode: TextEdit.WordWrap
- }
- }
- }
-}
diff --git a/examples/qtquick/accessibility/content/Button.qml b/examples/qtquick/accessibility/content/Button.qml
deleted file mode 100644
index 33cee8036c..0000000000
--- a/examples/qtquick/accessibility/content/Button.qml
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: button
-
- property bool checked: false
- property alias text : buttonText.text
- Accessible.name: text
- Accessible.description: "This button does " + text
- Accessible.role: Accessible.Button
-
- signal clicked
-
- width: buttonText.width + 20
- height: 30
- gradient: Gradient {
- GradientStop { position: 0.0; color: "lightsteelblue" }
- GradientStop { position: 1.0; color: "blue" }
- }
- border.width: 2
- border.color: "black";
- radius: 10
-
- Text {
- id: buttonText
- text: parent.description
- anchors.centerIn: parent
- font.pixelSize: parent.height * .5
- style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: {
- checked = !checked;
- }
- }
-}
diff --git a/examples/qtquick/animation/animation.pro b/examples/qtquick/animation/animation.pro
deleted file mode 100644
index 7e4cf9ef66..0000000000
--- a/examples/qtquick/animation/animation.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = app
-
-QT += quick declarative
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation
-qml.files = animation.qml basics behaviors easing pathanimation pathinterpolator states
-qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation
-INSTALLS += target qml
-
diff --git a/examples/qtquick/canvas/stockchart/plugin.cpp b/examples/qtquick/canvas/stockchart/plugin.cpp
deleted file mode 100644
index af64af4da8..0000000000
--- a/examples/qtquick/canvas/stockchart/plugin.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtDeclarative/QDeclarativeExtensionPlugin>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtGui/QGuiApplication>
-#include "model.h"
-
-class QStockChartExampleQmlPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- void registerTypes(const char *uri)
- {
- Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample"));
- qmlRegisterType<StockModel>(uri, 1, 0, "StockModel");
- qmlRegisterType<StockPrice>(uri, 1, 0, "StockPrice");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin);
diff --git a/examples/qtquick/canvas/stockchart/stockchart.pro b/examples/qtquick/canvas/stockchart/stockchart.pro
deleted file mode 100644
index 4006b5dccf..0000000000
--- a/examples/qtquick/canvas/stockchart/stockchart.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TEMPLATE = lib
-CONFIG += qt plugin
-QT += declarative network
-
-DESTDIR = com/nokia/StockChartExample
-TARGET = qmlstockchartexampleplugin
-
-SOURCES += model.cpp plugin.cpp
-HEADERS += model.h
-qdeclarativesources.files += \
- com/nokia/StockChartExample/qmldir \
- stock.qml
-
-qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample
-
-sources.files += stockchart.pro model.h model.cpp plugin.cpp README
-sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins
-target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample
-
-INSTALLS += qdeclarativesources sources target
diff --git a/examples/qtquick/draganddrop/draganddrop.pro b/examples/qtquick/draganddrop/draganddrop.pro
deleted file mode 100644
index f937039ca2..0000000000
--- a/examples/qtquick/draganddrop/draganddrop.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = app
-
-QT += quick declarative
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/draganddrop
-qml.files = draganddrop.qml tiles views
-qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/draganddrop
-INSTALLS += target qml
-
diff --git a/examples/qtquick/imageelements/imageelements.pro b/examples/qtquick/imageelements/imageelements.pro
deleted file mode 100644
index 5300cbd870..0000000000
--- a/examples/qtquick/imageelements/imageelements.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = app
-
-QT += quick declarative
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/imageelements
-qml.files = borderimage.qml content imageelements.qml image.qml shadows.qml simplesprite.qml spriteimage.qml
-qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/imageelements
-INSTALLS += target qml
-
diff --git a/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.pro
deleted file mode 100644
index eaf2b30c89..0000000000
--- a/examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = app
-TARGET = abstractitemmodel
-DEPENDPATH += .
-INCLUDEPATH += .
-QT += declarative quick
-
-HEADERS = model.h
-SOURCES = main.cpp \
- model.cpp
-RESOURCES += abstractitemmodel.qrc
diff --git a/examples/qtquick/modelviews/abstractitemmodel/main.cpp b/examples/qtquick/modelviews/abstractitemmodel/main.cpp
deleted file mode 100644
index b6ca2df26e..0000000000
--- a/examples/qtquick/modelviews/abstractitemmodel/main.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "model.h"
-
-#include <QGuiApplication>
-#include <qdeclarativeengine.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarative.h>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-
-//![0]
-int main(int argc, char ** argv)
-{
- QGuiApplication app(argc, argv);
-
- AnimalModel model;
- model.addAnimal(Animal("Wolf", "Medium"));
- model.addAnimal(Animal("Polar bear", "Large"));
- model.addAnimal(Animal("Quoll", "Small"));
-
- QQuickView view;
- view.setResizeMode(QQuickView::SizeRootObjectToView);
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-//![0]
-
- view.setSource(QUrl("qrc:view.qml"));
- view.show();
-
- return app.exec();
-}
-
diff --git a/examples/qtquick/modelviews/listview/content/ToggleButton.qml b/examples/qtquick/modelviews/listview/content/ToggleButton.qml
deleted file mode 100644
index 0754d9849b..0000000000
--- a/examples/qtquick/modelviews/listview/content/ToggleButton.qml
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** 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 QtQuick 2.0
-
-Rectangle {
- id: root
- property alias label: text.text
- property bool active: false
- signal toggled
- width: 149
- height: 30
- radius: 3
- color: active ? "green" : "lightgray"
- border.width: 1
- Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 }
- MouseArea {
- anchors.fill: parent
- onClicked: { active = !active; root.toggled() }
- }
-}
diff --git a/examples/qtquick/modelviews/objectlistmodel/main.cpp b/examples/qtquick/modelviews/objectlistmodel/main.cpp
deleted file mode 100644
index c8542976c3..0000000000
--- a/examples/qtquick/modelviews/objectlistmodel/main.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications 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 <QGuiApplication>
-
-#include <qdeclarativeengine.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarative.h>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-
-#include "dataobject.h"
-
-/*
- This example illustrates exposing a QList<QObject*> as a
- model in QML
-*/
-
-//![0]
-int main(int argc, char ** argv)
-{
- QGuiApplication app(argc, argv);
-
- QList<QObject*> dataList;
- dataList.append(new DataObject("Item 1", "red"));
- dataList.append(new DataObject("Item 2", "green"));
- dataList.append(new DataObject("Item 3", "blue"));
- dataList.append(new DataObject("Item 4", "yellow"));
-
- QQuickView view;
- view.setResizeMode(QQuickView::SizeRootObjectToView);
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-//![0]
-
- view.setSource(QUrl("qrc:view.qml"));
- view.show();
-
- return app.exec();
-}
-
diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro b/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro
deleted file mode 100644
index 74dc5b1016..0000000000
--- a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-QT += declarative quick
-
-SOURCES += main.cpp \
- dataobject.cpp
-HEADERS += dataobject.h
-RESOURCES += objectlistmodel.qrc
diff --git a/examples/qtquick/modelviews/stringlistmodel/main.cpp b/examples/qtquick/modelviews/stringlistmodel/main.cpp
deleted file mode 100644
index 47d7fdaa8c..0000000000
--- a/examples/qtquick/modelviews/stringlistmodel/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications 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 <QGuiApplication>
-#include <QStringList>
-
-#include <qdeclarativeengine.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarative.h>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-
-
-/*
- This example illustrates exposing a QStringList as a
- model in QML
-*/
-
-int main(int argc, char ** argv)
-{
- QGuiApplication app(argc, argv);
-
-//![0]
- QStringList dataList;
- dataList.append("Item 1");
- dataList.append("Item 2");
- dataList.append("Item 3");
- dataList.append("Item 4");
-
- QQuickView view;
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-//![0]
-
- view.setSource(QUrl("qrc:view.qml"));
- view.show();
-
- return app.exec();
-}
-
diff --git a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro b/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro
deleted file mode 100644
index 540d8c71f0..0000000000
--- a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-QT += declarative quick
-
-SOURCES += main.cpp
-RESOURCES += stringlistmodel.qrc
diff --git a/examples/qtquick/openglunderqml/openglunderqml.pro b/examples/qtquick/openglunderqml/openglunderqml.pro
deleted file mode 100644
index 117ad0c33e..0000000000
--- a/examples/qtquick/openglunderqml/openglunderqml.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-QT += declarative quick
-
-HEADERS += squircle.h
-SOURCES += squircle.cpp main.cpp
-
-OTHER_FILES += main.qml
diff --git a/examples/qtquick/painteditem/smile/main.cpp b/examples/qtquick/painteditem/smile/main.cpp
deleted file mode 100644
index 1e6b42351d..0000000000
--- a/examples/qtquick/painteditem/smile/main.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QPainter>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/qquickpainteditem.h>
-class MyPaintItem : public QQuickPaintedItem
-{
- Q_OBJECT
- Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged)
-public:
- MyPaintItem()
- : QQuickPaintedItem()
- , m_face(QLatin1String(":-)"))
- {
- setAntialiasing(true);
- }
- QString face() const {return m_face;}
- void setFace(const QString &face) {
- if (m_face != face) {
- m_face = face;
- emit faceChanged();
- }
- }
- virtual void paint(QPainter *p)
- {
- QRectF rect(0, 0, width(), height());
- rect.adjust(10, 10, -10, -10);
- p->setPen(QPen(Qt::black, 20));
- p->setBrush(Qt::yellow);
- p->drawEllipse(rect);
- p->setPen(Qt::black);
- p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2)));
- p->drawText(rect, Qt::AlignCenter, m_face);
- }
-signals:
- void faceChanged();
-private:
- QString m_face;
-};
-
-int main(int argc, char ** argv)
-{
- QGuiApplication app(argc, argv);
-
- qmlRegisterType<MyPaintItem>("MyModule", 1, 0, "MyPaintItem");
-
- QQuickView view;
- view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl::fromLocalFile("smile.qml"));
- view.show();
- view.raise();
-
- return app.exec();
-}
-
-#include "main.moc"
diff --git a/examples/qtquick/painteditem/smile/smile.pro b/examples/qtquick/painteditem/smile/smile.pro
deleted file mode 100644
index 780d351fe6..0000000000
--- a/examples/qtquick/painteditem/smile/smile.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = app
-TARGET = painteditem
-
-QT += declarative quick
-
-macx: CONFIG -= app_bundle
-
-SOURCES += main.cpp
-
-CONFIG += console
-
diff --git a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h
deleted file mode 100644
index f444d31f4e..0000000000
--- a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDeclarativeExtensionPlugin>
-
-#include "../textballoon.h"
-
-class TextBalloonPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "textballoon.json")
-public:
- void registerTypes(const char *uri)
- {
- qmlRegisterType<TextBalloon>(uri, 1, 0, "TextBalloon");
- }
-};
diff --git a/examples/qtquick/painteditem/textballoons/textballoons.pro b/examples/qtquick/painteditem/textballoons/textballoons.pro
deleted file mode 100644
index e0b9404f65..0000000000
--- a/examples/qtquick/painteditem/textballoons/textballoons.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-TEMPLATE = lib
-CONFIG += qt plugin
-QT += declarative quick
-
-TARGET = qmltextballoonplugin
-
-HEADERS += TextBalloonPlugin/plugin.h \
- textballoon.h
-
-SOURCES += textballoon.cpp
-
-OTHER_FILES += textballoon.json
-
-DESTDIR = TextBalloonPlugin
-
-qdeclarativesources.files += \
- TextBalloonPlugin/qmldir
-
-qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin
-
-sources.files = textballoons.qml
-sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons
-target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin
-
-INSTALLS = qdeclarativesources sources target
diff --git a/examples/qtquick/shadereffects/shadereffects.qml b/examples/qtquick/shadereffects/shadereffects.qml
deleted file mode 100644
index 70bcf1352a..0000000000
--- a/examples/qtquick/shadereffects/shadereffects.qml
+++ /dev/null
@@ -1,315 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the Declarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "content"
-
-Image {
- width: 320
- height: 480
-/*!
- \title QML Examples - Shader Effects
- \example declarative/shadereffects
- \image qml-shadereffects-example.png
- \brief This is a shader effects example
-
- This example demonstrates a couple of visual effects that you can perform
- with shaders in QtQuick 2.0
-*/
- source: "../snake/content/pics/background.png"
-
- Flickable {
- anchors.fill: parent
- contentWidth: 640
- contentHeight: 360
-
- ShaderEffectSource {
- id: theSource
- sourceItem: theItem
- smooth: true
- }
-
- function saturate(x) {
- return Math.min(Math.max(x, 0), 1)
- }
-
- function sliderToColor(x) {
- return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)),
- saturate(Math.min(6 * x, 4 - 6 * x)),
- saturate(Math.min(6 * x - 2, 6 - 6 * x)))
- }
-
- Grid {
- anchors.centerIn: parent
- columns: 3
-
- Item {
- id: theItem
- width: 180
- height: 180
- ListView {
- anchors.centerIn: parent
- width: 160
- height: 140
- clip: true
- snapMode: ListView.SnapOneItem
- model: VisualItemModel {
- Text {
- width: 160
- height: 140
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: 120
- font.family: "Times"
- color: "blue"
- text: "Qt"
- }
- Image {
- width: 160
- height: 140
- source: "content/qt-logo.png"
- smooth: true
- }
- Image {
- width: 160
- height: 140
- source: "content/face-smile.png"
- smooth: true
- }
- }
- }
- }
- ShaderEffect {
- width: 180
- height: 180
- property variant source: theSource
- property real amplitude: 0.04 * wobbleSlider.value
- property real frequency: 20
- property real time: 0
- NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
- fragmentShader:
- "uniform lowp float qt_Opacity;" +
- "uniform highp float amplitude;" +
- "uniform highp float frequency;" +
- "uniform highp float time;" +
- "uniform sampler2D source;" +
- "varying highp vec2 qt_TexCoord0;" +
- "void main() {" +
- " highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
- " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" +
- "}"
- Slider {
- id: wobbleSlider
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- height: 40
- }
- }
- ShaderEffect {
- width: 180
- height: 180
- property variant source: theSource
- property variant shadow: ShaderEffectSource {
- smooth: true
- sourceItem: ShaderEffect {
- width: theItem.width
- height: theItem.height
- property variant delta: Qt.size(0.0, 1.0 / height)
- property variant source: ShaderEffectSource {
- smooth: true
- sourceItem: ShaderEffect {
- width: theItem.width
- height: theItem.height
- property variant delta: Qt.size(1.0 / width, 0.0)
- property variant source: theSource
- fragmentShader: "
- uniform lowp float qt_Opacity;
- uniform sampler2D source;
- uniform highp vec2 delta;
- varying highp vec2 qt_TexCoord0;
- void main() {
- gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
- + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
- + 0.2466 * texture2D(source, qt_TexCoord0)
- + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
- + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
- }"
- }
- }
- fragmentShader: "
- uniform lowp float qt_Opacity;
- uniform sampler2D source;
- uniform highp vec2 delta;
- varying highp vec2 qt_TexCoord0;
- void main() {
- gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
- + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
- + 0.2466 * texture2D(source, qt_TexCoord0)
- + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
- + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
- }"
- }
- }
- property real angle: 0
- property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle))
- NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 }
- property variant delta: Qt.size(offset.x / width, offset.y / height)
- property real darkness: shadowSlider.value
- fragmentShader: "
- uniform lowp float qt_Opacity;
- uniform highp vec2 offset;
- uniform sampler2D source;
- uniform sampler2D shadow;
- uniform highp float darkness;
- uniform highp vec2 delta;
- varying highp vec2 qt_TexCoord0;
- void main() {
- lowp vec4 fg = texture2D(source, qt_TexCoord0);
- lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta);
- gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity;
- }"
- Slider {
- id: shadowSlider
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- height: 40
- }
- }
- ShaderEffect {
- width: 180
- height: 180
- property variant source: theSource
- property variant delta: Qt.size(0.5 / width, 0.5 / height)
- fragmentShader: "
- uniform sampler2D source;
- uniform highp vec2 delta;
- uniform highp float qt_Opacity;
- varying highp vec2 qt_TexCoord0;
- void main() {
- lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta);
- lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y));
- lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y));
- lowp vec4 br = texture2D(source, qt_TexCoord0 + delta);
- lowp vec4 gx = (tl + bl) - (tr + br);
- lowp vec4 gy = (tl + tr) - (bl + br);
- gl_FragColor.xyz = vec3(0.);
- gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity;
- }"
- }
- ShaderEffect {
- width: 180
- height: 180
- property variant source: theSource
- property color tint: sliderToColor(colorizeSlider.value)
- fragmentShader: "
- uniform sampler2D source;
- uniform lowp vec4 tint;
- uniform lowp float qt_Opacity;
- varying highp vec2 qt_TexCoord0;
- void main() {
- lowp vec4 c = texture2D(source, qt_TexCoord0);
- lowp float lo = min(min(c.x, c.y), c.z);
- lowp float hi = max(max(c.x, c.y), c.z);
- gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w);
- }"
- Slider {
- id: colorizeSlider
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- height: 40
- }
- }
- ShaderEffect {
- width: 180
- height: 180
- mesh: Qt.size(10, 10)
- property variant source: theSource
- property real bend: 0
- property real minimize: 0
- property real side: genieSlider.value
- SequentialAnimation on bend {
- loops: Animation.Infinite
- NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
- PauseAnimation { duration: 1600 }
- NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
- PauseAnimation { duration: 1000 }
- }
- SequentialAnimation on minimize {
- loops: Animation.Infinite
- PauseAnimation { duration: 300 }
- NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
- PauseAnimation { duration: 1000 }
- NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
- PauseAnimation { duration: 1300 }
- }
- vertexShader: "
- uniform highp mat4 qt_Matrix;
- uniform highp float bend;
- uniform highp float minimize;
- uniform highp float side;
- uniform highp float width;
- uniform highp float height;
- attribute highp vec4 qt_Vertex;
- attribute highp vec2 qt_MultiTexCoord0;
- varying highp vec2 qt_TexCoord0;
- void main() {
- qt_TexCoord0 = qt_MultiTexCoord0;
- highp vec4 pos = qt_Vertex;
- pos.y = mix(qt_Vertex.y, height, minimize);
- highp float t = pos.y / height;
- t = (3. - 2. * t) * t * t;
- pos.x = mix(qt_Vertex.x, side * width, t * bend);
- gl_Position = qt_Matrix * pos;
- }"
- Slider {
- id: genieSlider
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- height: 40
- }
- }
- }
- }
-}
diff --git a/examples/quick/accessibility/accessibility.pro b/examples/quick/accessibility/accessibility.pro
new file mode 100644
index 0000000000..2826161945
--- /dev/null
+++ b/examples/quick/accessibility/accessibility.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility
+qml.files = accessibility.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility
+INSTALLS += target qml
+
diff --git a/examples/quick/accessibility/accessibility.qml b/examples/quick/accessibility/accessibility.qml
new file mode 100644
index 0000000000..2804d2abc8
--- /dev/null
+++ b/examples/quick/accessibility/accessibility.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+/*!
+ \title QtQuick Examples - Accessibility
+ \example qtquick/accessibility
+ \brief This example has accessible buttons.
+
+*/
+
+Rectangle {
+ id: window
+
+ width: 320; height: 480
+ color: "white"
+
+ Column {
+ id: column
+ spacing: 6
+ anchors.fill: parent
+ width: parent.width
+ Row {
+ spacing: 6
+ width: column.width
+ Button { width: 100; height: column.h + 20; text: "Send" }
+ Button { width: 100; height: column.h + 20; text: "Discard" }
+ }
+
+ Row {
+ spacing: 6
+ width: column.width
+ height: column.h
+ Text {
+ id: subjectLabel
+ Accessible.role: Accessible.StaticText
+ Accessible.name: text
+ text: "Subject:"
+ }
+ Rectangle {
+ id: subjectBorder
+ Accessible.role: Accessible.EditableText
+ Accessible.name: subjectEdit.text
+ border.width: 1
+ border.color: "black"
+ height: subjectEdit.height
+ width: 240
+ TextInput {
+ id: subjectEdit
+ text: "Vacation plans"
+ }
+ }
+ }
+ Rectangle {
+ id: textBorder
+ Accessible.role: Accessible.EditableText
+ property alias text : textEdit.text
+ border.width: 1
+ border.color: "black"
+ width: parent.width - 2
+ height: parent.height - (textBorder.y + column.spacing)
+ TextEdit {
+ id: textEdit
+ text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke"
+ width: parent.width
+ wrapMode: TextEdit.WordWrap
+ }
+ }
+ }
+}
diff --git a/examples/qtquick/accessibility/accessibility.qmlproject b/examples/quick/accessibility/accessibility.qmlproject
index 04a3190914..04a3190914 100644
--- a/examples/qtquick/accessibility/accessibility.qmlproject
+++ b/examples/quick/accessibility/accessibility.qmlproject
diff --git a/examples/quick/accessibility/content/Button.qml b/examples/quick/accessibility/content/Button.qml
new file mode 100644
index 0000000000..2c203abe11
--- /dev/null
+++ b/examples/quick/accessibility/content/Button.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: button
+
+ property bool checked: false
+ property alias text : buttonText.text
+ Accessible.name: text
+ Accessible.description: "This button does " + text
+ Accessible.role: Accessible.Button
+
+ signal clicked
+
+ width: buttonText.width + 20
+ height: 30
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightsteelblue" }
+ GradientStop { position: 1.0; color: "blue" }
+ }
+ border.width: 2
+ border.color: "black";
+ radius: 10
+
+ Text {
+ id: buttonText
+ text: parent.description
+ anchors.centerIn: parent
+ font.pixelSize: parent.height * .5
+ style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ checked = !checked;
+ }
+ }
+}
diff --git a/examples/qtquick/accessibility/main.cpp b/examples/quick/accessibility/main.cpp
index 89e23b477b..89e23b477b 100644
--- a/examples/qtquick/accessibility/main.cpp
+++ b/examples/quick/accessibility/main.cpp
diff --git a/examples/quick/animation/animation.pro b/examples/quick/animation/animation.pro
new file mode 100644
index 0000000000..cdf83f80c8
--- /dev/null
+++ b/examples/quick/animation/animation.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation
+qml.files = animation.qml basics behaviors easing pathanimation pathinterpolator states
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation
+INSTALLS += target qml
+
diff --git a/examples/qtquick/animation/animation.qml b/examples/quick/animation/animation.qml
index bca68457d9..bca68457d9 100644
--- a/examples/qtquick/animation/animation.qml
+++ b/examples/quick/animation/animation.qml
diff --git a/examples/quick/animation/animation.qmlproject b/examples/quick/animation/animation.qmlproject
new file mode 100644
index 0000000000..2e96daa881
--- /dev/null
+++ b/examples/quick/animation/animation.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "animation.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qtquick/animation/basics/color-animation.qml b/examples/quick/animation/basics/color-animation.qml
index f1bf40c40b..f1bf40c40b 100644
--- a/examples/qtquick/animation/basics/color-animation.qml
+++ b/examples/quick/animation/basics/color-animation.qml
diff --git a/examples/quick/animation/basics/images/face-smile.png b/examples/quick/animation/basics/images/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/quick/animation/basics/images/face-smile.png
Binary files differ
diff --git a/examples/quick/animation/basics/images/moon.png b/examples/quick/animation/basics/images/moon.png
new file mode 100644
index 0000000000..9407b2b4f0
--- /dev/null
+++ b/examples/quick/animation/basics/images/moon.png
Binary files differ
diff --git a/examples/quick/animation/basics/images/shadow.png b/examples/quick/animation/basics/images/shadow.png
new file mode 100644
index 0000000000..8270565e87
--- /dev/null
+++ b/examples/quick/animation/basics/images/shadow.png
Binary files differ
diff --git a/examples/quick/animation/basics/images/star.png b/examples/quick/animation/basics/images/star.png
new file mode 100644
index 0000000000..27ef924267
--- /dev/null
+++ b/examples/quick/animation/basics/images/star.png
Binary files differ
diff --git a/examples/quick/animation/basics/images/sun.png b/examples/quick/animation/basics/images/sun.png
new file mode 100644
index 0000000000..7713ca5ce7
--- /dev/null
+++ b/examples/quick/animation/basics/images/sun.png
Binary files differ
diff --git a/examples/quick/animation/basics/property-animation.qml b/examples/quick/animation/basics/property-animation.qml
new file mode 100644
index 0000000000..4a4d3e3b2a
--- /dev/null
+++ b/examples/quick/animation/basics/property-animation.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: window
+ width: 320; height: 480
+
+ // Let's draw the sky...
+ Rectangle {
+ anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "DeepSkyBlue" }
+ GradientStop { position: 1.0; color: "LightSkyBlue" }
+ }
+ }
+
+ // ...and the ground.
+ Rectangle {
+ anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "ForestGreen" }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+
+ // The shadow for the smiley face
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: smiley.minHeight + 58
+ source: "images/shadow.png"
+
+ // The scale property depends on the y position of the smiley face.
+ scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight)
+ }
+
+ Image {
+ id: smiley
+ property int maxHeight: window.height / 3
+ property int minHeight: 2 * window.height / 3
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: minHeight
+ source: "images/face-smile.png"
+
+ // Animate the y property. Setting loops to Animation.Infinite makes the
+ // animation repeat indefinitely, otherwise it would only run once.
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+
+ // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function
+ NumberAnimation {
+ from: smiley.minHeight; to: smiley.maxHeight
+ easing.type: Easing.OutExpo; duration: 300
+ }
+
+ // Then move back to minHeight in 1 second, using the OutBounce easing function
+ NumberAnimation {
+ from: smiley.maxHeight; to: smiley.minHeight
+ easing.type: Easing.OutBounce; duration: 1000
+ }
+
+ // Then pause for 500ms
+ PauseAnimation { duration: 500 }
+ }
+ }
+}
diff --git a/examples/quick/animation/behaviors/SideRect.qml b/examples/quick/animation/behaviors/SideRect.qml
new file mode 100644
index 0000000000..623c6965d8
--- /dev/null
+++ b/examples/quick/animation/behaviors/SideRect.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: myRect
+
+ property string text
+
+ width: 75; height: 50
+ radius: 6
+ color: "#646464"
+ border.width: 4; border.color: "white"
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onEntered: {
+ focusRect.x = myRect.x;
+ focusRect.y = myRect.y;
+ focusRect.text = myRect.text;
+ }
+ }
+}
diff --git a/examples/qtquick/animation/behaviors/behavior-example.qml b/examples/quick/animation/behaviors/behavior-example.qml
index a88d7c8c7b..a88d7c8c7b 100644
--- a/examples/qtquick/animation/behaviors/behavior-example.qml
+++ b/examples/quick/animation/behaviors/behavior-example.qml
diff --git a/examples/qtquick/animation/behaviors/tvtennis.qml b/examples/quick/animation/behaviors/tvtennis.qml
index 108f19a11d..108f19a11d 100644
--- a/examples/qtquick/animation/behaviors/tvtennis.qml
+++ b/examples/quick/animation/behaviors/tvtennis.qml
diff --git a/examples/qtquick/animation/behaviors/wigglytext.qml b/examples/quick/animation/behaviors/wigglytext.qml
index 4bb94da100..4bb94da100 100644
--- a/examples/qtquick/animation/behaviors/wigglytext.qml
+++ b/examples/quick/animation/behaviors/wigglytext.qml
diff --git a/examples/quick/animation/easing/content/QuitButton.qml b/examples/quick/animation/easing/content/QuitButton.qml
new file mode 100644
index 0000000000..702b892d23
--- /dev/null
+++ b/examples/quick/animation/easing/content/QuitButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Image {
+ source: "quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: Qt.quit()
+ }
+}
diff --git a/examples/quick/animation/easing/content/quit.png b/examples/quick/animation/easing/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/quick/animation/easing/content/quit.png
Binary files differ
diff --git a/examples/qtquick/animation/easing/easing.qml b/examples/quick/animation/easing/easing.qml
index 8977029fb3..8977029fb3 100644
--- a/examples/qtquick/animation/easing/easing.qml
+++ b/examples/quick/animation/easing/easing.qml
diff --git a/examples/qtquick/animation/main.cpp b/examples/quick/animation/main.cpp
index 799dfd7725..799dfd7725 100644
--- a/examples/qtquick/animation/main.cpp
+++ b/examples/quick/animation/main.cpp
diff --git a/examples/qtquick/animation/pathanimation/pathanimation.qml b/examples/quick/animation/pathanimation/pathanimation.qml
index f995218c6c..f995218c6c 100644
--- a/examples/qtquick/animation/pathanimation/pathanimation.qml
+++ b/examples/quick/animation/pathanimation/pathanimation.qml
diff --git a/examples/qtquick/animation/pathinterpolator/pathinterpolator.qml b/examples/quick/animation/pathinterpolator/pathinterpolator.qml
index 5a137c732d..5a137c732d 100644
--- a/examples/qtquick/animation/pathinterpolator/pathinterpolator.qml
+++ b/examples/quick/animation/pathinterpolator/pathinterpolator.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png b/examples/quick/animation/states/qt-logo.png
index 14ddf2a028..14ddf2a028 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png
+++ b/examples/quick/animation/states/qt-logo.png
Binary files differ
diff --git a/examples/quick/animation/states/states.qml b/examples/quick/animation/states/states.qml
new file mode 100644
index 0000000000..7ca56a9295
--- /dev/null
+++ b/examples/quick/animation/states/states.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 640; height: 480
+ color: "#343434"
+
+ Image {
+ id: userIcon
+ x: topLeftRect.x; y: topLeftRect.y
+ source: "qt-logo.png"
+ }
+
+ Rectangle {
+ id: topLeftRect
+
+ anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to the default state, returning the image to
+ // its initial position
+ MouseArea { anchors.fill: parent; onClicked: page.state = '' }
+ }
+
+ Rectangle {
+ id: middleRightRect
+
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'middleRight'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' }
+ }
+
+ Rectangle {
+ id: bottomLeftRect
+
+ anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'bottomLeft'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' }
+ }
+
+ states: [
+ // In state 'middleRight', move the image to middleRightRect
+ State {
+ name: "middleRight"
+ PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y }
+ },
+
+ // In state 'bottomLeft', move the image to bottomLeftRect
+ State {
+ name: "bottomLeft"
+ PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y }
+ }
+ ]
+}
diff --git a/examples/quick/animation/states/transitions.qml b/examples/quick/animation/states/transitions.qml
new file mode 100644
index 0000000000..d57924d6d2
--- /dev/null
+++ b/examples/quick/animation/states/transitions.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+/*
+ This is exactly the same as states.qml, except that we have appended
+ a set of transitions to apply animations when the item changes
+ between each state.
+*/
+
+Rectangle {
+ id: page
+ width: 640; height: 480
+ color: "#343434"
+
+ Image {
+ id: userIcon
+ x: topLeftRect.x; y: topLeftRect.y
+ source: "qt-logo.png"
+ }
+
+ Rectangle {
+ id: topLeftRect
+
+ anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to the default state, returning the image to
+ // its initial position
+ MouseArea { anchors.fill: parent; onClicked: page.state = '' }
+ }
+
+ Rectangle {
+ id: middleRightRect
+
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'middleRight'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' }
+ }
+
+ Rectangle {
+ id: bottomLeftRect
+
+ anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'bottomLeft'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' }
+ }
+
+ states: [
+ // In state 'middleRight', move the image to middleRightRect
+ State {
+ name: "middleRight"
+ PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y }
+ },
+
+ // In state 'bottomLeft', move the image to bottomLeftRect
+ State {
+ name: "bottomLeft"
+ PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y }
+ }
+ ]
+
+ // Transitions define how the properties change when the item moves between each state
+ transitions: [
+
+ // When transitioning to 'middleRight' move x,y over a duration of 1 second,
+ // with OutBounce easing function.
+ Transition {
+ from: "*"; to: "middleRight"
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 }
+ },
+
+ // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds,
+ // with InOutQuad easing function.
+ Transition {
+ from: "*"; to: "bottomLeft"
+ NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 }
+ },
+
+ // For any other state changes move x,y linearly over duration of 200ms.
+ Transition {
+ NumberAnimation { properties: "x,y"; duration: 200 }
+ }
+ ]
+}
diff --git a/examples/quick/canvas/bezierCurve/bezierCurve.qml b/examples/quick/canvas/bezierCurve/bezierCurve.qml
new file mode 100644
index 0000000000..f57839b0a5
--- /dev/null
+++ b/examples/quick/canvas/bezierCurve/bezierCurve.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ property string strokeStyle:"red"
+ property string fillStyle:"red"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75,40);
+ ctx.bezierCurveTo(75,37,70,25,50,25);
+ ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
+ ctx.bezierCurveTo(20,80,40,102,75,120);
+ ctx.bezierCurveTo(110,102,130,80,130,62.5);
+ ctx.bezierCurveTo(130,62.5,130,25,100,25);
+ ctx.bezierCurveTo(85,25,75,37,75,40);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/clip/clip.qml b/examples/quick/canvas/clip/clip.qml
new file mode 100644
index 0000000000..d861ff0a46
--- /dev/null
+++ b/examples/quick/canvas/clip/clip.qml
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter}
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:2
+ property int nSize:nCtrl.value
+ property real radius:rCtrl.value
+ property bool fill:true
+ property bool stroke:false
+ property real px:xCtrl.value
+ property real py:yCtrl.value
+ property real alpha:alphaCtrl.value
+ property string imagefile:"../contents/qt-logo.png"
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+ Component.onCompleted:loadImage(canvas.imagefile);
+
+ onAlphaChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onNSizeChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onPxChanged:requestPaint();
+ onPyChanged:requestPaint();
+
+ onImageLoaded : requestPaint();
+
+ onPaint: squcirle();
+
+ function squcirle() {
+ var ctx = canvas.getContext("2d");
+ var N = canvas.nSize;
+ var R = canvas.radius;
+
+ N=Math.abs(N);
+ var M=N;
+ if (N>100) M=100;
+ if (N<0.00000000001) M=0.00000000001;
+
+ ctx.save();
+ ctx.globalAlpha =canvas.alpha;
+ ctx.fillStyle = "gray";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.beginPath();
+ var i = 0, x, y;
+ for (i=0; i<(2*R+1); i++){
+ x = Math.round(i-R) + canvas.px;
+ y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
+
+ if (i == 0)
+ ctx.moveTo(x, y);
+ else
+ ctx.lineTo(x, y);
+ }
+
+ for (i=(2*R); i<(4*R+1); i++){
+ x =Math.round(3*R-i)+canvas.px;
+ y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
+ ctx.lineTo(x, y);
+ }
+ ctx.closePath();
+ if (canvas.stroke) {
+ ctx.stroke();
+ }
+
+ if (canvas.fill) {
+ ctx.fill();
+ }
+ ctx.clip();
+
+ ctx.drawImage(canvas.imagefile, 0, 0);
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"}
+ Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"}
+ Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"}
+ Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/contents/Button.qml b/examples/quick/canvas/contents/Button.qml
new file mode 100644
index 0000000000..1413cdb9fa
--- /dev/null
+++ b/examples/quick/canvas/contents/Button.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ signal clicked
+
+ property string text
+ width: buttonText.width + 28
+ height: buttonText.height + 14
+
+ BorderImage {
+ id: buttonImage
+ source: "images/toolbutton.sci"
+ width: container.width - 10
+ height: container.height
+ }
+ BorderImage {
+ id: pressed
+ opacity: 0
+ source: "images/toolbutton.sci"
+ width: container.width - 10
+ height: container.height
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ id: buttonText
+ color: "white"
+ anchors.centerIn: buttonImage
+ font.bold: true
+ font.pointSize: 15
+ text: container.text
+ style: Text.Raised
+ styleColor: "black"
+ }
+ states: [
+ State {
+ name: "Pressed"
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ }
+ ]
+} \ No newline at end of file
diff --git a/examples/quick/canvas/contents/ScrollBar.qml b/examples/quick/canvas/contents/ScrollBar.qml
new file mode 100644
index 0000000000..98b8efee4a
--- /dev/null
+++ b/examples/quick/canvas/contents/ScrollBar.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: scrollBar
+ // The properties that define the scrollbar's state.
+ // position and pageSize are in the range 0.0 - 1.0. They are relative to the
+ // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
+ // of the height of the view.
+ // orientation can be either 'Vertical' or 'Horizontal'
+ property real position
+ property real pageSize
+ property string orientation : "Vertical"
+ property alias bgColor: background.color
+ property alias fgColor: thumb.color
+
+ // A light, semi-transparent background
+ Rectangle {
+ id: background
+ radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
+ color: "white"; opacity: 0.3
+ anchors.fill: parent
+ }
+ // Size the bar to the required size, depending upon the orientation.
+ Rectangle {
+ id: thumb
+ opacity: 0.7
+ color: "black"
+ radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
+ x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
+ y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
+ width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
+ height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
+ }
+}
diff --git a/examples/quick/canvas/contents/Slider.qml b/examples/quick/canvas/contents/Slider.qml
new file mode 100644
index 0000000000..093b9e40dd
--- /dev/null
+++ b/examples/quick/canvas/contents/Slider.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id:slider
+ property real min:0
+ property real max:1
+ property real value: min + (max - min) * (bar.x / (foo.width - bar.width))
+ property real init:min+(max-min)/2
+ property string name:"Slider"
+
+ Component.onCompleted: setValue(init)
+ function setValue(v) {
+ if (min < max)
+ bar.x = v/(max - min) * (foo.width - bar.width);
+ }
+ Rectangle {
+ id:sliderName
+ anchors.left:parent.left
+ height: childrenRect.height
+ width:childrenRect.width
+ anchors.verticalCenter:parent.verticalCenter
+ Text {
+ text:slider.name
+ font.pointSize:12
+ }
+ }
+ Item {
+ id: foo
+ height: 6
+ width: parent.width - 4 - sliderName.width
+ anchors.verticalCenter:parent.verticalCenter
+ anchors.left:sliderName.right
+ anchors.leftMargin:5
+ Rectangle {
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: bar.horizontalCenter
+ color: "blue"
+ radius: 3
+ }
+ Rectangle {
+ height: parent.height
+ anchors.left: bar.horizontalCenter
+ anchors.right: parent.right
+ color: "gray"
+ radius: 3
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ radius: 3
+ border.width: 2
+ border.color: "black"
+ }
+
+ Rectangle {
+ id: bar
+ y: -7
+ width: 20
+ height: 20
+ radius: 15
+ color: "white"
+ border.width: 2
+ border.color: "black"
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: foo.width - parent.width
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/contents/Stocks.qml b/examples/quick/canvas/contents/Stocks.qml
new file mode 100644
index 0000000000..043bca132e
--- /dev/null
+++ b/examples/quick/canvas/contents/Stocks.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id:stocks
+ //Data from : http://en.wikipedia.org/wiki/NASDAQ-100
+
+ ListElement {name:"Activision Blizzard"; stockId:"ATVI"}
+ ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"}
+ ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"}
+ ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"}
+ ListElement {name:"Altera Corporation"; stockId:"ALTR"}
+ ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"}
+ ListElement {name:"Amgen Inc."; stockId:"AMGN"}
+ ListElement {name:"Apollo Group, Inc."; stockId:"APOL"}
+ ListElement {name:"Apple Inc."; stockId:"AAPL"}
+ ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"}
+ ListElement {name:"Autodesk, Inc."; stockId:"ADSK"}
+ ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"}
+ ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"}
+ ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"}
+ ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"}
+ ListElement {name:"BMC Software, Inc."; stockId:"BMC"}
+ ListElement {name:"Broadcom Corporation"; stockId:"BRCM"}
+ ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"}
+ ListElement {name:"CA, Inc."; stockId:"CA"}
+ ListElement {name:"Celgene Corporation"; stockId:"CELG"}
+ ListElement {name:"Cephalon, Inc."; stockId:"CEPH"}
+ ListElement {name:"Cerner Corporation"; stockId:"CERN"}
+ ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"}
+ ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"}
+ ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"}
+ ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"}
+ ListElement {name:"Comcast Corporation"; stockId:"CMCSA"}
+ ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"}
+ ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"}
+ ListElement {name:"Dell Inc."; stockId:"DELL"}
+ ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"}
+ ListElement {name:"DirecTV"; stockId:"DTV"}
+ ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"}
+ ListElement {name:"eBay Inc."; stockId:"EBAY"}
+ ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"}
+ ListElement {name:"Expedia, Inc."; stockId:"EXPE"}
+ ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"}
+ ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"}
+ ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"}
+ ListElement {name:"Fastenal Company"; stockId:"FAST"}
+ ListElement {name:"First Solar, Inc."; stockId:"FSLR"}
+ ListElement {name:"Fiserv, Inc."; stockId:"FISV"}
+ ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"}
+ ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"}
+ ListElement {name:"Garmin Ltd."; stockId:"GRMN"}
+ ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"}
+ ListElement {name:"Google Inc."; stockId:"GOOG"}
+ ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"}
+ ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"}
+ ListElement {name:"Illumina, Inc."; stockId:"ILMN"}
+ ListElement {name:"Infosys Technologies"; stockId:"INFY"}
+ ListElement {name:"Intel Corporation"; stockId:"INTC"}
+ ListElement {name:"Intuit, Inc."; stockId:"INTU"}
+ ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"}
+ ListElement {name:"Joy Global Inc."; stockId:"JOYG"}
+ ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"}
+ ListElement {name:"Lam Research Corporation"; stockId:"LRCX"}
+ ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"}
+ ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"}
+ ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"}
+ ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"}
+ ListElement {name:"Mattel, Inc."; stockId:"MAT"}
+ ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"}
+ ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"}
+ ListElement {name:"Micron Technology, Inc."; stockId:"MU"}
+ ListElement {name:"Microsoft Corporation"; stockId:"MSFT"}
+ ListElement {name:"Mylan, Inc."; stockId:"MYL"}
+ ListElement {name:"NetApp, Inc."; stockId:"NTAP"}
+ ListElement {name:"Netflix, Inc."; stockId:"NFLX"}
+ ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"}
+ ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"}
+ ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"}
+ ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"}
+ ListElement {name:"Oracle Corporation"; stockId:"ORCL"}
+ ListElement {name:"PACCAR Inc."; stockId:"PCAR"}
+ ListElement {name:"Paychex, Inc."; stockId:"PAYX"}
+ ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"}
+ ListElement {name:"Qiagen N.V."; stockId:"QGEN"}
+ ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"}
+ ListElement {name:"Research in Motion Limited"; stockId:"RIMM"}
+ ListElement {name:"Ross Stores Inc."; stockId:"ROST"}
+ ListElement {name:"SanDisk Corporation"; stockId:"SNDK"}
+ ListElement {name:"Seagate Technology Holdings"; stockId:"STX"}
+ ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"}
+ ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"}
+ ListElement {name:"Staples Inc."; stockId:"SPLS"}
+ ListElement {name:"Starbucks Corporation"; stockId:"SBUX"}
+ ListElement {name:"Stericycle, Inc"; stockId:"SRCL"}
+ ListElement {name:"Symantec Corporation"; stockId:"SYMC"}
+ ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"}
+ ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"}
+ ListElement {name:"VeriSign, Inc."; stockId:"VRSN"}
+ ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"}
+ ListElement {name:"Virgin Media, Inc."; stockId:"VMED"}
+ ListElement {name:"Vodafone Group, plc."; stockId:"VOD"}
+ ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"}
+ ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"}
+ ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"}
+ ListElement {name:"Xilinx, Inc."; stockId:"XLNX"}
+ ListElement {name:"Yahoo! Inc."; stockId:"YHOO"}
+}
diff --git a/examples/quick/canvas/contents/TitleBar.qml b/examples/quick/canvas/contents/TitleBar.qml
new file mode 100644
index 0000000000..28edda2ae7
--- /dev/null
+++ b/examples/quick/canvas/contents/TitleBar.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: titleBar
+ property string title: ""
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Image {
+ id: quitButton
+ anchors.left: parent.left//; anchors.leftMargin: 0
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/quit.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+ Text {
+ id: categoryText
+ anchors {
+ left: quitButton.right; right: parent.right; //leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ elide: Text.ElideLeft
+ text: title
+ font.bold: true; font.pointSize: 20; color: "White"; style: Text.Raised; styleColor: "Black"
+ }
+}
diff --git a/examples/quick/canvas/contents/ToolBar.qml b/examples/quick/canvas/contents/ToolBar.qml
new file mode 100644
index 0000000000..7ae7391ddf
--- /dev/null
+++ b/examples/quick/canvas/contents/ToolBar.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: toolbar
+
+ property variant labels
+ signal buttonClicked(int index)
+
+ BorderImage {
+ source: "images/titlebar.sci"
+ width: parent.width
+ height: parent.height + 14
+ y: -7
+ }
+
+ Row {
+ y: 3
+ anchors.horizontalCenter: parent.horizontalCenter
+ Repeater {
+ model: toolbar.labels
+ delegate:
+ Button {
+ text: modelData
+ onClicked: toolbar.buttonClicked(model.index)
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/canvas/contents/images/button-pressed.png b/examples/quick/canvas/contents/images/button-pressed.png
new file mode 100644
index 0000000000..e434d327f2
--- /dev/null
+++ b/examples/quick/canvas/contents/images/button-pressed.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/button.png b/examples/quick/canvas/contents/images/button.png
new file mode 100644
index 0000000000..56a63ce641
--- /dev/null
+++ b/examples/quick/canvas/contents/images/button.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/default.svg b/examples/quick/canvas/contents/images/default.svg
new file mode 100644
index 0000000000..248199cc4e
--- /dev/null
+++ b/examples/quick/canvas/contents/images/default.svg
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48px" height="48px" id="svg1306">
+ <defs id="defs1308">
+ <linearGradient id="linearGradient4083">
+ <stop id="stop4085" offset="0" stop-color="#ffffff" stop-opacity="0"/>
+ <stop offset="0.75" id="stop4089" stop-color="#ffffff" stop-opacity="0"/>
+ <stop id="stop4087" offset="1" stop-color="#ffffff" stop-opacity="1"/>
+ </linearGradient>
+ <linearGradient id="linearGradient4032">
+ <stop id="stop4034" offset="0" stop-color="#fff7c2" stop-opacity="0.63829786"/>
+ <stop offset="0.59394139" id="stop4036" stop-color="#fcaf3e" stop-opacity="0.18348624"/>
+ <stop id="stop4038" offset="0.83850551" stop-color="#fcaf3e" stop-opacity="0.50458717"/>
+ <stop id="stop4040" offset="1" stop-color="#fcaf3e" stop-opacity="1"/>
+ </linearGradient>
+ <linearGradient id="linearGradient4026">
+ <stop id="stop4028" offset="0" stop-color="#fff9c6" stop-opacity="1"/>
+ <stop offset="0.54166669" id="stop4042" stop-color="#fff28c" stop-opacity="1"/>
+ <stop id="stop4030" offset="1" stop-color="#ffea85" stop-opacity="1"/>
+ </linearGradient>
+ <linearGradient xlink:href="#linearGradient4026" id="linearGradient3168" gradientUnits="userSpaceOnUse" x1="-28.968945" y1="-25.326815" x2="-37.19698" y2="-9.5590506"/>
+ <radialGradient xlink:href="#linearGradient4032" id="radialGradient4020" cx="-33.519073" cy="-22.113297" fx="-33.519073" fy="-22.113297" r="9.5" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.487739,1.292402,-1.10267,0.497242,-41.77393,32.41492)"/>
+ <radialGradient xlink:href="#linearGradient4083" id="radialGradient4081" cx="23.99999" cy="23.381506" fx="23.99999" fy="23.381506" r="19.141981" gradientTransform="matrix(1.006701,2.235326e-16,-2.23715e-16,1.007522,-0.160816,0.426981)" gradientUnits="userSpaceOnUse"/>
+ </defs>
+
+ <metadata id="metadata1311">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:title>weather-clear</dc:title>
+ <dc:date>January 2006</dc:date>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Ryan Collier (pseudo)</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:publisher>
+ <cc:Agent>
+ <dc:title>http://www.tango-project.org</dc:title>
+ </cc:Agent>
+ </dc:publisher>
+ <dc:source>http://www.pseudocode.org</dc:source>
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li>weather</rdf:li>
+ <rdf:li>applet</rdf:li>
+ <rdf:li>notification</rdf:li>
+ </rdf:Bag>
+ </dc:subject>
+ <cc:license rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/"/>
+ <dc:contributor>
+ <cc:Agent>
+ <dc:title>Garrett LeSage</dc:title>
+ </cc:Agent>
+ </dc:contributor>
+ </cc:Work>
+ <cc:License rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+ <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Attribution"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/ShareAlike"/>
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer1">
+ <g>
+ <g opacity="0.7">
+ <path d="M 24 2.5 L 21.625 9.1875 C 22.399034 9.0641318 23.191406 9 24 9 C 24.808594 9 25.600966 9.0641317 26.375 9.1875 L 24 2.5 z M 8.8125 8.78125 L 11.84375 15.21875 C 12.779034 13.928569 13.928569 12.779034 15.21875 11.84375 L 8.8125 8.78125 z M 39.21875 8.78125 L 32.78125 11.84375 C 34.071431 12.779034 35.220966 13.928569 36.15625 15.21875 L 39.21875 8.78125 z M 9.1875 21.59375 L 2.5 23.96875 L 9.1875 26.34375 C 9.0673373 25.57952 9 24.797813 9 24 C 9 23.180625 9.0608858 22.377571 9.1875 21.59375 z M 38.8125 21.625 C 38.935868 22.399034 39 23.191406 39 24 C 39 24.808594 38.935868 25.600966 38.8125 26.375 L 45.5 24 L 38.8125 21.625 z M 11.84375 32.78125 L 8.8125 39.1875 L 15.21875 36.15625 C 13.928569 35.220966 12.779034 34.071431 11.84375 32.78125 z M 36.15625 32.78125 C 35.229789 34.05926 34.087617 35.194799 32.8125 36.125 L 39.21875 39.1875 L 36.15625 32.78125 z M 21.625 38.8125 L 24 45.5 L 26.375 38.8125 C 25.600966 38.935868 24.808594 39 24 39 C 23.191406 39 22.399034 38.935868 21.625 38.8125 z " fill="#fce94f" fill-opacity="1" stroke="#fcaf3e" stroke-width="0.73732895" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ <path d="M 24 5.25 L 22.65625 9.0625 C 23.098888 9.0231486 23.547187 9 24 9 C 24.452813 9 24.901112 9.0231486 25.34375 9.0625 L 24 5.25 z M 10.78125 10.75 L 12.5 14.375 C 13.071538 13.694089 13.724004 13.038745 14.40625 12.46875 L 10.78125 10.75 z M 37.25 10.75 L 33.625 12.46875 C 34.304675 13.038189 34.961811 13.695325 35.53125 14.375 L 37.25 10.75 z M 9.0625 22.625 L 5.28125 23.96875 L 9.0625 25.3125 C 9.024981 24.880146 9 24.442031 9 24 C 9 23.536406 9.0212735 23.077908 9.0625 22.625 z M 38.9375 22.65625 C 38.976851 23.098888 39 23.547187 39 24 C 39 24.452813 38.976851 24.901112 38.9375 25.34375 L 42.71875 24 L 38.9375 22.65625 z M 35.53125 33.59375 C 34.958293 34.27954 34.309985 34.957363 33.625 35.53125 L 37.25 37.25 L 35.53125 33.59375 z M 12.5 33.625 L 10.78125 37.21875 L 14.375 35.5 C 13.702932 34.935884 13.064116 34.297068 12.5 33.625 z M 22.65625 38.9375 L 24 42.71875 L 25.34375 38.9375 C 24.901112 38.976851 24.452813 39 24 39 C 23.547187 39 23.098888 38.976851 22.65625 38.9375 z " fill="none" fill-opacity="1" stroke="url(#radialGradient4081)" stroke-width="0.84646249" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ </g>
+ <g>
+ <g>
+ <path transform="matrix(0.778062,-1.061285,1.061287,0.778062,67.47952,3.641324)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="#ffee54" fill-opacity="1" stroke="#fcaf3e" stroke-width="0.75991178" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ <path transform="matrix(1.244257,-0.167707,0.216642,1.251844,67.61648,40.527)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="url(#radialGradient4020)" fill-opacity="1" stroke="none" stroke-width="1.01737845" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ <path transform="matrix(0.715791,-0.976349,0.97635,0.715792,64.00044,5.269544)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="none" fill-opacity="1" stroke="url(#linearGradient3168)" stroke-width="0.82601947" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ </g>
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/examples/quick/canvas/contents/images/gloss.png b/examples/quick/canvas/contents/images/gloss.png
new file mode 100755
index 0000000000..5d370cd93d
--- /dev/null
+++ b/examples/quick/canvas/contents/images/gloss.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/lineedit.png b/examples/quick/canvas/contents/images/lineedit.png
new file mode 100755
index 0000000000..2cc38dc35b
--- /dev/null
+++ b/examples/quick/canvas/contents/images/lineedit.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/lineedit.sci b/examples/quick/canvas/contents/images/lineedit.sci
new file mode 100644
index 0000000000..054bff78be
--- /dev/null
+++ b/examples/quick/canvas/contents/images/lineedit.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/examples/quick/canvas/contents/images/quit.png b/examples/quick/canvas/contents/images/quit.png
new file mode 100755
index 0000000000..5bda1b6e0d
--- /dev/null
+++ b/examples/quick/canvas/contents/images/quit.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/stripes.png b/examples/quick/canvas/contents/images/stripes.png
new file mode 100755
index 0000000000..9f36727ea4
--- /dev/null
+++ b/examples/quick/canvas/contents/images/stripes.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/titlebar.png b/examples/quick/canvas/contents/images/titlebar.png
new file mode 100755
index 0000000000..51c90082d0
--- /dev/null
+++ b/examples/quick/canvas/contents/images/titlebar.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/titlebar.sci b/examples/quick/canvas/contents/images/titlebar.sci
new file mode 100644
index 0000000000..0418d94cd6
--- /dev/null
+++ b/examples/quick/canvas/contents/images/titlebar.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/examples/quick/canvas/contents/images/toolbutton.png b/examples/quick/canvas/contents/images/toolbutton.png
new file mode 100755
index 0000000000..11310013ee
--- /dev/null
+++ b/examples/quick/canvas/contents/images/toolbutton.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/toolbutton.sci b/examples/quick/canvas/contents/images/toolbutton.sci
new file mode 100644
index 0000000000..9e4f965307
--- /dev/null
+++ b/examples/quick/canvas/contents/images/toolbutton.sci
@@ -0,0 +1,5 @@
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/examples/quick/canvas/contents/qt-logo.png b/examples/quick/canvas/contents/qt-logo.png
new file mode 100644
index 0000000000..5ab3a1b0c4
--- /dev/null
+++ b/examples/quick/canvas/contents/qt-logo.png
Binary files differ
diff --git a/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml
new file mode 100644
index 0000000000..bc3ca0071a
--- /dev/null
+++ b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ property string strokeStyle:"steelblue"
+ property string fillStyle:"yellow"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75,25);
+ ctx.quadraticCurveTo(25,25,25,62.5);
+ ctx.quadraticCurveTo(25,100,50,100);
+ ctx.quadraticCurveTo(50,120,30,125);
+ ctx.quadraticCurveTo(60,120,65,100);
+ ctx.quadraticCurveTo(125,100,125,62.5);
+ ctx.quadraticCurveTo(125,25,75,25);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+
+
+ ctx.fillStyle="green";
+ ctx.font = "Bold 15px";
+
+ ctx.fillText("QML酷毙了", 30, 60);
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/roundedrect/roundedrect.qml b/examples/quick/canvas/roundedrect/roundedrect.qml
new file mode 100644
index 0000000000..fd86c63a3b
--- /dev/null
+++ b/examples/quick/canvas/roundedrect/roundedrect.qml
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter}
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ property int radius: rCtrl.value
+ property int rectx: rxCtrl.value
+ property int recty: ryCtrl.value
+ property int rectWidth: width - 2*rectx
+ property int rectHeight: height - 2*recty
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onRectxChanged:requestPaint();
+ onRectyChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+
+ onPaint: {
+ var ctx = getContext("2d");
+ ctx.save();
+ ctx.clearRect(0,0,canvas.width, canvas.height);
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.lineWidth = canvas.lineWidth
+ ctx.fillStyle = canvas.fillStyle
+ ctx.globalAlpha = canvas.alpha
+ ctx.beginPath();
+ ctx.moveTo(rectx+radius,recty); // top side
+ ctx.lineTo(rectx+rectWidth-radius,recty);
+ // draw top right corner
+ ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius);
+ ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side
+ // draw bottom right corner
+ ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius);
+ ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side
+ // draw bottom left corner
+ ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius);
+ ctx.lineTo(rectx,recty+radius); // left side
+ // draw top left corner
+ ctx.arcTo(rectx,recty,rectx+radius,recty,radius);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:rxCtrl; width:300; height:30; min:5; max:30; init:10; name:"rectx"}
+ Slider {id:ryCtrl; width:300; height:30; min:5; max:30; init:10; name:"recty"}
+ Slider {id:rCtrl; width:300; height:30; min:10; max:100; init:40; name:"Radius"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/smile/smile.qml b/examples/quick/canvas/smile/smile.qml
new file mode 100644
index 0000000000..28a48a6c81
--- /dev/null
+++ b/examples/quick/canvas/smile/smile.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ property string strokeStyle:"green"
+ property string fillStyle:"yellow"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75 + 50 * Math.cos(0),
+ 75 - 50 * Math.sin(Math.PI*2));
+ ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle
+ ctx.moveTo(75,70);
+ ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise)
+ ctx.moveTo(60,65);
+ ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye
+ ctx.moveTo(90 + 5 * Math.cos(0),
+ 65 - 5 * Math.sin(Math.PI*2));
+ ctx.moveTo(90,65);
+ ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/squircle/squircle.png b/examples/quick/canvas/squircle/squircle.png
new file mode 100644
index 0000000000..86c69d945f
--- /dev/null
+++ b/examples/quick/canvas/squircle/squircle.png
Binary files differ
diff --git a/examples/quick/canvas/squircle/squircle.qml b/examples/quick/canvas/squircle/squircle.qml
new file mode 100644
index 0000000000..2fc65b67b3
--- /dev/null
+++ b/examples/quick/canvas/squircle/squircle.qml
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter}
+ Image {
+ anchors.horizontalCenter:parent.horizontalCenter
+ source:"squircle.png"
+ width:250
+ height:25
+ }
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:2
+ property int nSize:nCtrl.value
+ property real radius:rCtrl.value
+ property bool fill:true
+ property bool stroke:false
+ property real px:xCtrl.value
+ property real py:yCtrl.value
+ property real alpha:alphaCtrl.value
+
+ onAlphaChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onNSizeChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onPxChanged:requestPaint();
+ onPyChanged:requestPaint();
+
+
+ onPaint: squcirle();
+
+ function squcirle() {
+ var ctx = canvas.getContext("2d");
+ var N = canvas.nSize;
+ var R = canvas.radius;
+
+ N=Math.abs(N);
+ var M=N;
+ if (N>100) M=100;
+ if (N<0.00000000001) M=0.00000000001;
+
+ ctx.save();
+ ctx.globalAlpha =canvas.alpha;
+ ctx.fillStyle = "gray";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.beginPath();
+ var i = 0, x, y;
+ for (i=0; i<(2*R+1); i++){
+ x = Math.round(i-R) + canvas.px;
+ y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
+
+ if (i == 0)
+ ctx.moveTo(x, y);
+ else
+ ctx.lineTo(x, y);
+ }
+
+ for (i=(2*R); i<(4*R+1); i++){
+ x =Math.round(3*R-i)+canvas.px;
+ y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
+ ctx.lineTo(x, y);
+ }
+ ctx.closePath();
+ if (canvas.stroke) {
+ ctx.stroke();
+ }
+
+ if (canvas.fill) {
+ ctx.fill();
+ }
+
+ ctx.fillStyle = "yellow";
+ ctx.font = "Helvetica 16px";
+ ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py);
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"}
+ Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"}
+ Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"}
+ Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/stockchart/README b/examples/quick/canvas/stockchart/README
new file mode 100644
index 0000000000..2652866ed6
--- /dev/null
+++ b/examples/quick/canvas/stockchart/README
@@ -0,0 +1,5 @@
+To run:
+
+ make install
+ QML_IMPORT_PATH=$PWD qmlscene stock.qml
+
diff --git a/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir
new file mode 100644
index 0000000000..4c60e556d4
--- /dev/null
+++ b/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir
@@ -0,0 +1 @@
+plugin qmlstockchartexampleplugin
diff --git a/examples/quick/canvas/stockchart/model.cpp b/examples/quick/canvas/stockchart/model.cpp
new file mode 100644
index 0000000000..42eb2d592f
--- /dev/null
+++ b/examples/quick/canvas/stockchart/model.cpp
@@ -0,0 +1,255 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+
+#include <QtCore/QUrl>
+#include <QtCore/QDate>
+#include <QtCore/QList>
+#include <QtCore/QStringList>
+#include <QtCore/QDebug>
+
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtNetwork/QNetworkReply>
+
+StockModel::StockModel(QObject *parent)
+ : QAbstractListModel(parent)
+ , _startDate(QDate(1995, 4, 25))
+ , _endDate(QDate::currentDate())
+ , _dataCycle(StockModel::Daily)
+ , _manager(0)
+ , _updating(false)
+{
+ QHash<int, QByteArray> roles;
+ roles[StockModel::DateRole] = "date";
+ roles[StockModel::SectionRole] = "year";
+ roles[StockModel::OpenPriceRole] = "openPrice";
+ roles[StockModel::ClosePriceRole] = "closePrice";
+ roles[StockModel::HighPriceRole] = "highPrice";
+ roles[StockModel::LowPriceRole] = "lowPrice";
+ roles[StockModel::VolumeRole] = "volume";
+ roles[StockModel::AdjustedPriceRole] = "adjustedPrice";
+ setRoleNames(roles);
+
+ connect(this, SIGNAL(stockNameChanged()), SLOT(requestData()));
+ connect(this, SIGNAL(startDateChanged()), SLOT(requestData()));
+ connect(this, SIGNAL(endDateChanged()), SLOT(requestData()));
+ connect(this, SIGNAL(dataCycleChanged()), SLOT(requestData()));
+
+ _manager = new QNetworkAccessManager(this);
+ connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(update(QNetworkReply*)));
+
+}
+
+int StockModel::rowCount(const QModelIndex & parent) const {
+ Q_UNUSED(parent);
+ return _prices.count();
+}
+
+StockPrice* StockModel::stockPriceAtIndex(int idx) const
+{
+ if (idx >=0 && idx < _prices.size()) {
+ return _prices[idx];
+ }
+ return 0;
+}
+
+
+void StockModel::requestData()
+{
+ if (!_updating) {
+ _updating = true;
+ QMetaObject::invokeMethod(this, "doRequest", Qt::QueuedConnection);
+ }
+}
+
+void StockModel::doRequest()
+{
+ /*
+ Fetch stock data from yahoo finance:
+ url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv
+ s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962
+ d:end day, e:end month, f:end year, default:today (data only available 3 days before today)
+ g:data cycle(d daily, w weekly, m monthly, v Dividend)
+ */
+ if (_manager && !_stockName.isEmpty() && _endDate > _startDate) {
+ QString query("http://ichart.finance.yahoo.com/table.csv?s=%1&a=%2&b=%3&c=%4&d=%5&e=%6&f=%7&g=%8&ignore=.csv");
+ query = query.arg(_stockName)
+ .arg(_startDate.day()).arg(_startDate.month()).arg(_startDate.year())
+ .arg(_endDate.day()).arg(_endDate.month()).arg(_endDate.year())
+ .arg(dataCycleString());
+
+ qDebug() << "request stock data:" << query;
+ QNetworkReply* reply = _manager->get(QNetworkRequest(QUrl(query)));
+ connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64)));
+ }
+}
+
+void StockModel::update(QNetworkReply *reply)
+{
+ _updating = false;
+
+ if (reply) {
+ if (reply->error() == QNetworkReply::NoError) {
+ beginResetModel();
+
+ foreach (StockPrice* p, _prices) {
+ p->deleteLater();
+ }
+
+ _prices.clear();
+
+ while (!reply->atEnd()) {
+ QString line = reply->readLine();
+ QStringList fields = line.split(',');
+
+ //data format:Date,Open,High,Low,Close,Volume,Adjusted close price
+ //example: 2011-06-24,6.03,6.04,5.88,5.88,20465200,5.88
+ if (fields.size() == 7) {
+ StockPrice* price = new StockPrice(this);
+ price->setDate(QDate::fromString(fields[0], Qt::ISODate));
+ price->setOpenPrice(fields[1].toFloat());
+ price->setHighPrice(fields[2].toFloat());
+ price->setLowPrice(fields[3].toFloat());
+ price->setClosePrice(fields[4].toFloat());
+ price->setVolume(fields[5].toInt());
+ price->setAdjustedPrice(fields[6].toFloat());
+ _prices.prepend(price);
+ }
+ }
+ qDebug() << "get stock data successfully, total:" << _prices.count() << "records.";
+ } else {
+ qDebug() << "get stock data failed:" << reply->errorString();
+ }
+ reply->deleteLater();
+ endResetModel();
+ emit dataChanged(QModelIndex(), QModelIndex());
+ }
+}
+
+QVariant StockModel::data(const QModelIndex & index, int role) const {
+ if (index.row() < 0 || index.row() > _prices.count())
+ return QVariant();
+
+ const StockPrice* price = _prices[index.row()];
+ if (role == StockModel::DateRole)
+ return price->date();
+ else if (role == StockModel::OpenPriceRole)
+ return price->openPrice();
+ else if (role == StockModel::ClosePriceRole)
+ return price->closePrice();
+ else if (role == StockModel::HighPriceRole)
+ return price->highPrice();
+ else if (role == StockModel::LowPriceRole)
+ return price->lowPrice();
+ else if (role == StockModel::AdjustedPriceRole)
+ return price->adjustedPrice();
+ else if (role == StockModel::VolumeRole)
+ return price->volume();
+ else if (role == StockModel::SectionRole)
+ return price->date().year();
+ return QVariant();
+}
+
+QString StockModel::stockName() const
+{
+ return _stockName;
+}
+void StockModel::setStockName(const QString& name)
+{
+ if (_stockName != name) {
+ _stockName = name;
+ emit stockNameChanged();
+ }
+}
+
+QDate StockModel::startDate() const
+{
+ return _startDate;
+}
+void StockModel::setStartDate(const QDate& date)
+{
+ if (_startDate.isValid() && _startDate != date) {
+ _startDate = date;
+ emit startDateChanged();
+ }
+}
+
+QDate StockModel::endDate() const
+{
+ return _endDate;
+}
+void StockModel::setEndDate(const QDate& date)
+{
+ if (_endDate.isValid() && _endDate != date) {
+ _endDate = date;
+ emit endDateChanged();
+ }
+}
+
+StockModel::StockDataCycle StockModel::dataCycle() const
+{
+ return _dataCycle;
+}
+
+QString StockModel::dataCycleString() const
+{
+ switch (_dataCycle) {
+ case StockModel::Daily:
+ return QString('d');
+ break;
+ case StockModel::Weekly:
+ return QString('w');
+ case StockModel::Monthly:
+ return QString('m');
+ case StockModel::Dividend:
+ return QString('v');
+ }
+
+ return QString('d');
+}
+
+
+void StockModel::setDataCycle(StockModel::StockDataCycle cycle)
+{
+ if (_dataCycle != cycle) {
+ _dataCycle = cycle;
+ emit dataCycleChanged();
+ }
+}
diff --git a/examples/quick/canvas/stockchart/model.h b/examples/quick/canvas/stockchart/model.h
new file mode 100644
index 0000000000..95e6f4891c
--- /dev/null
+++ b/examples/quick/canvas/stockchart/model.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/QAbstractListModel>
+#include <QtCore/QDate>
+
+class StockPrice : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDate date READ date)
+ Q_PROPERTY(qreal openPrice READ openPrice)
+ Q_PROPERTY(qreal closePrice READ closePrice)
+ Q_PROPERTY(qreal highPrice READ highPrice)
+ Q_PROPERTY(qreal lowPrice READ lowPrice)
+ Q_PROPERTY(qint32 volume READ volume)
+ Q_PROPERTY(qreal adjustedPrice READ adjustedPrice)
+public:
+
+ StockPrice(QObject *parent = 0)
+ : QObject(parent)
+ , _openPrice(-1)
+ , _closePrice(-1)
+ , _highPrice(-1)
+ , _lowPrice(-1)
+ , _volume(-1)
+ , _adjustedPrice(-1)
+ {
+ }
+ QDate date() const {return _date;}
+ qreal openPrice() const {return _openPrice; }
+ qreal closePrice() const {return _closePrice;}
+ qreal highPrice() const {return _highPrice;}
+ qreal lowPrice() const{return _lowPrice;}
+ qreal adjustedPrice() const{return _adjustedPrice;}
+ qint32 volume() const{return _volume;}
+
+ void setDate(const QDate& date){_date = date;}
+ void setOpenPrice(qreal price){_openPrice = price;}
+ void setClosePrice(qreal price){_closePrice = price;}
+ void setHighPrice(qreal price){_highPrice = price;}
+ void setLowPrice(qreal price){_lowPrice = price;}
+ void setAdjustedPrice(qreal price) {_adjustedPrice = price;}
+ void setVolume(qint32 volume) {_volume = volume;}
+
+private:
+ QDate _date;
+ qreal _openPrice;
+ qreal _closePrice;
+ qreal _highPrice;
+ qreal _lowPrice;
+ qint32 _volume;
+ qreal _adjustedPrice;
+};
+
+class QNetworkReply;
+class QNetworkAccessManager;
+class StockModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString stockName READ stockName WRITE setStockName NOTIFY stockNameChanged)
+ Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged)
+ Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged)
+ Q_PROPERTY(StockDataCycle dataCycle READ dataCycle WRITE setDataCycle NOTIFY dataCycleChanged)
+
+ Q_ENUMS(StockDataCycle)
+public:
+ enum StockDataCycle {
+ Daily,
+ Weekly,
+ Monthly,
+ Dividend
+ };
+
+ enum StockModelRoles {
+ DateRole = Qt::UserRole + 1,
+ SectionRole,
+ OpenPriceRole,
+ ClosePriceRole,
+ HighPriceRole,
+ LowPriceRole,
+ VolumeRole,
+ AdjustedPriceRole
+ };
+
+ StockModel(QObject *parent = 0);
+
+ QString stockName() const;
+ void setStockName(const QString& name);
+
+ QDate startDate() const;
+ void setStartDate(const QDate& date);
+
+ QDate endDate() const;
+ void setEndDate(const QDate& date);
+
+ StockDataCycle dataCycle() const;
+ void setDataCycle(StockDataCycle cycle);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+signals:
+ void stockNameChanged();
+ void startDateChanged();
+ void endDateChanged();
+ void dataCycleChanged();
+ void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
+
+public slots:
+ void requestData();
+ StockPrice* stockPriceAtIndex(int idx) const;
+private slots:
+ void doRequest();
+ void update(QNetworkReply* reply);
+private:
+ QString dataCycleString() const;
+ QList<StockPrice*> _prices;
+ QString _stockName;
+ QDate _startDate;
+ QDate _endDate;
+ StockDataCycle _dataCycle;
+ QNetworkAccessManager* _manager;
+ bool _updating;
+};
+
+
+
+
diff --git a/examples/quick/canvas/stockchart/plugin.cpp b/examples/quick/canvas/stockchart/plugin.cpp
new file mode 100644
index 0000000000..3b354e2b31
--- /dev/null
+++ b/examples/quick/canvas/stockchart/plugin.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/QQmlExtensionPlugin>
+#include <QtQml/qqml.h>
+#include <QtGui/QGuiApplication>
+#include "model.h"
+
+class QStockChartExampleQmlPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample"));
+ qmlRegisterType<StockModel>(uri, 1, 0, "StockModel");
+ qmlRegisterType<StockPrice>(uri, 1, 0, "StockPrice");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin);
diff --git a/examples/quick/canvas/stockchart/stock.qml b/examples/quick/canvas/stockchart/stock.qml
new file mode 100644
index 0000000000..1c95fde2ce
--- /dev/null
+++ b/examples/quick/canvas/stockchart/stock.qml
@@ -0,0 +1,726 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import com.nokia.StockChartExample 1.0
+import "../contents"
+
+Rectangle {
+ id:container
+ width: 360; height: 600
+ color: "#343434";
+ Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 }
+
+
+ TitleBar {
+ id: titleBar
+ width: parent.width
+ anchors.top : container.top
+ height: 40
+ opacity: 0.9
+ }
+
+ StockModel {
+ id:stockModel
+ dataCycle: StockModel.Daily
+ function dataCycleName() {
+ if (dataCycle === StockModel.Weekly)
+ return "Weekly";
+ else if (dataCycle === StockModel.Monthly)
+ return "Monthly";
+ return "Daily";
+ }
+
+ onDataChanged: {
+ if (view.viewType == "chart") {
+ canvas.requestPaint();
+ }
+ }
+ onDownloadProgress: {
+ if (bytesReceived == bytesTotal && bytesTotal != -1) {
+ progress.opacity = 0;
+ } else {
+ progress.opacity = 0.8;
+ progress.text = "downloading " + stockModel.dataCycleName() + " data ..."+ Math.round(bytesReceived/1000) + " KB";
+ }
+ }
+
+ property string description:"";
+ }
+
+ Stocks {id:stocks}
+
+ Rectangle {
+ id: header
+ width: parent.width
+ height: 20
+ color: "steelblue"
+ opacity: 0
+ Row {
+ spacing: 2
+ Text {
+ id:t
+ font.pointSize:15
+ horizontalAlignment:Text.AlignHCenter
+ font.bold: true
+ font.underline:true
+ }
+ Rectangle {
+ height:20
+ width:50
+ Text {text:"Stock list"; font.pointSize:15; font.bold: true}
+ }
+ }
+ }
+
+ ListView {
+ id:stockList
+ width: parent.width
+ anchors.bottom: container.bottom
+ anchors.top : titleBar.bottom
+ focus: true
+ keyNavigationWraps: true
+ spacing:1
+ opacity: 1
+ model: stocks
+
+ Component.onCompleted: opacity = 0.9;
+ onOpacityChanged: {
+ titleBar.title = "Top 100 NASDAQ stocks"
+ }
+
+
+ delegate : Rectangle {
+ height: 30
+ width: view.width
+ color: {
+ if (ListView.isCurrentItem)
+ return focus ? "lightyellow" : "pink";
+ return index % 2 == 0 ? "lightblue" : "lightsteelblue"
+ }
+ Text {
+ font.pointSize:20
+ text: index + ". " + stockId + " \t(" + name + ")";
+ }
+ MouseArea {
+ anchors.fill: parent;
+ onDoubleClicked: {
+ stockList.opacity = 0;
+ stockModel.stockName = stockId;
+ stockModel.description = "NASDAQ:" + stockId + " (" + name + ")";
+ view.opacity = 1;
+ view.viewType = "chart";
+ canvas.opacity = 0.7;
+ }
+ onClicked: stockList.currentIndex = index
+ }//mousearea
+ }//delegate
+ }
+
+ ListView {
+ id:view
+ width: container.width
+ height: container.height - 50
+ anchors.bottom: container.bottom
+ focus: true
+ keyNavigationWraps: true
+
+ spacing:1
+ opacity: 0
+ model: stockModel
+ highlightFollowsCurrentItem: false
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ preferredHighlightBegin:50
+ preferredHighlightEnd : height - 50
+ highlight: listHighlight
+
+ //header : Text {}
+ delegate: listDelegate
+ snapMode: ListView.SnapToItem
+
+ property string viewType : "list"
+ property int topIndex:indexAt(0,contentY);
+ property int bottomIndex:indexAt(0, contentY+height);
+
+ onCountChanged: {
+
+ titleBar.title = stockModel.description + " " + Qt.formatDate(stockModel.startDate, "yyyy-MM-dd") + " - " +
+ Qt.formatDate(stockModel.endDate, "yyyy-MM-dd") + " " + stockModel.dataCycleName() +
+ " records:" + view.count;
+
+ }
+
+ Component {
+ id: listDelegate
+ Rectangle {
+ height: 20
+ width: view.width
+ border.color: "lightsteelblue"
+ border.width: 1
+ color: {
+ if (ListView.isCurrentItem)
+ return focus ? "lightyellow" : "pink";
+
+ return index % 2 == 0 ? "lightblue" : "lightsteelblue"
+ }
+ Text {
+ font.pointSize:13
+ text: index + ". " + Qt.formatDate(date, "yyyy-MM-dd")
+ + "\t " + Math.round(openPrice*100)/100
+ + "\t " + Math.round(highPrice*100)/100
+ + "\t " + Math.round(lowPrice*100)/100
+ + "\t " + Math.round(closePrice*100)/100
+ + "\t " + volume + "\t "
+ + Math.round(adjustedPrice*100)/100;
+ }
+ MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index}
+ }
+ }
+
+ Component {
+ id: chartDelegate
+ Rectangle {
+ height: 20
+ width: view.width/view.count * canvas.scaleX
+ border.color: "lightsteelblue"
+ border.width: 1
+ color: {
+ if (ListView.isCurrentItem)
+ return focus ? "lightyellow" : "pink";
+
+ return index % 2 == 0 ? "lightblue" : "lightsteelblue"
+ }
+
+ Text {
+ anchors.bottom: parent.bottom
+ font.pointSize: {
+ if (parent.width <= 4)
+ return 1;
+ if (parent.width <= 50)
+ return parent.width/4;
+ return 15;
+ }
+ horizontalAlignment:Text.AlignHCenter
+ verticalAlignment:Text.AlignBottom
+ text:font.pointSize > 1 ? Qt.formatDate(date, "d/M/yy") : ""
+ }
+ MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index}
+ }
+ }
+
+ Component {
+ id:chartHighlight
+ Rectangle { radius: 5; width:40; height: 20; color: "lightsteelblue" }
+ }
+
+ Component {
+ id:listHighlight
+ Rectangle { radius: 5; width:container.width; height: 20; color: "lightsteelblue" }
+ }
+
+
+
+
+ onViewTypeChanged : {
+ if (viewType == "list") {
+ view.orientation = ListView.Vertical;
+ view.delegate = listDelegate;
+// view.section.property = "year";
+// view.section.criteria = ViewSection.FullString;
+// view.section.delegate = sectionHeading;
+ view.highlight = listHighlight;
+ view.opacity = 1;
+ canvas.opacity = 0;
+ // comment.opacity = 0;
+
+ } else if (viewType == "chart") {
+ view.orientation = ListView.Horizontal;
+ view.delegate = chartDelegate;
+ //comment.opacity = 0.6;
+
+ view.opacity = 1;
+ view.height = 30
+
+ canvas.opacity = 0.7;
+ canvas.requestPaint();
+ } else {
+ viewType = "list";
+ }
+ }
+
+
+ onCurrentIndexChanged: {
+ //header.updateCurrent(stockModel.stockPriceAtIndex(view.currentIndex));
+ if (viewType == "chart") {
+ canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX);
+ canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX);
+
+ canvas.requestPaint();
+ }
+ }
+ onContentYChanged: { // keep "current" item visible
+ topIndex = indexAt(0,contentY);
+ bottomIndex = indexAt(0, contentY+height);
+
+ if (topIndex != -1 && currentIndex <= topIndex)
+ currentIndex = topIndex+1;
+ else if (bottomIndex != -1 && currentIndex >= bottomIndex)
+ currentIndex = bottomIndex-1;
+ if (viewType == "chart")
+ canvas.requestPaint();
+ }
+
+ onContentXChanged: { // keep "current" item visible
+ topIndex = indexAt(contentX,0);
+ bottomIndex = indexAt(contentX+width, 0);
+
+ if (topIndex != -1 && currentIndex <= topIndex)
+ currentIndex = topIndex+1;
+ else if (bottomIndex != -1 && currentIndex >= bottomIndex)
+ currentIndex = bottomIndex-1;
+ if (viewType == "chart")
+ canvas.requestPaint();
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onDoubleClicked: {
+ if (view.viewType == "list")
+ view.viewType = "chart";
+ else
+ view.viewType = "list";
+ }
+ }
+ }
+
+
+
+ Canvas {
+ id:canvas
+ anchors.top : titleBar.bottom
+ anchors.bottom : view.top
+ width:container.width;
+ opacity:0
+ renderTarget: Canvas.Image
+ renderStrategy: Canvas.Immediate
+ property bool running:false
+ property int frames:first
+ property int mouseX:0;
+ property int mouseY:0;
+ property int mousePressedX:0;
+ property int mousePressedY:0;
+ property int movedY:0
+ property real scaleX:1.0;
+ property real scaleY:1.0;
+ property int first:0;
+ property int last:view.count - 1;
+
+ onOpacityChanged: {
+ if (opacity > 0)
+ requestPaint();
+ }
+ Text {
+ id:comment
+ x:100
+ y:50
+ font.pointSize: 20
+ color:"white"
+ opacity: 0.7
+ focus:false
+ text: stockModel.description
+ function updateCurrent(price)
+ {
+ if (price !== undefined) {
+ text =stockModel.description + "\n"
+ + Qt.formatDate(price.date, "yyyy-MM-dd") + " OPEN:"
+ + Math.round(price.openPrice*100)/100 + " HIGH:"
+ + Math.round(price.highPrice*100)/100 + " LOW:"
+ + Math.round(price.lowPrice*100)/100 + " CLOSE:"
+ + Math.round(price.closePrice*100)/100 + " VOLUME:"
+ + price.volume;
+ }
+ }
+ }
+
+ Text {
+ id:priceAxis
+ x:25
+ y:25
+ font.pointSize: 15
+ color:"yellow"
+ opacity: 0.7
+ focus: false
+ }
+ Text {
+ id:volumeAxis
+ x:canvas.width - 200
+ y:25
+ font.pointSize: 15
+ color:"yellow"
+ opacity: 0.7
+ }
+
+ Rectangle {
+ id:progress
+ x:canvas.width/2 - 100
+ y:canvas.height/2
+ width:childrenRect.width
+ height: childrenRect.height
+ opacity: 0
+ color:"white"
+ property string text;
+ Text {
+ text:parent.text
+ font.pointSize: 20
+ }
+ }
+
+ Button {
+ id:runButton
+ text:"Run this chart"
+ y:0
+ x:canvas.width/2 - 50
+ opacity: 0.5
+ onClicked: {
+ if (canvas.running) {
+ canvas.running = false;
+ canvas.frames = canvas.first;
+ canvas.requestPaint();
+ text = "Run this chart";
+ comment.text = stockModel.description;
+ } else {
+ text = " Stop running ";
+ canvas.runChart();
+ }
+ }
+ }
+ Button {
+ id:returnButton
+ text:"Stocks"
+ y:0
+ anchors.left : runButton.right
+ anchors.leftMargin : 20
+ opacity: 0.5
+ onClicked: {
+ stockList.opacity = 1;
+ canvas.opacity = 0;
+ }
+ }
+ PinchArea {
+ anchors.fill: parent
+ onPinchUpdated : {
+ var current = pinch.center;
+ var scale = pinch.scale;
+ console.log("center:" + pinch.center + " scale:" + pinch.scale);
+ //canvas.requestPaint();
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onDoubleClicked: {
+ if (stockModel.dataCycle == StockModel.Daily)
+ stockModel.dataCycle = StockModel.Weekly;
+ else if (stockModel.dataCycle == StockModel.Weekly)
+ stockModel.dataCycle = StockModel.Monthly;
+ else
+ stockModel.dataCycle = StockModel.Daily;
+ }
+
+ onPositionChanged: {
+ if (mouse.modifiers & Qt.ControlModifier) {
+ if (canvas.mouseX == 0 && canvas.mouseY == 0) {
+ canvas.mouseX = mouse.x;
+ canvas.mouseY = mouse.y;
+ }
+ } else{
+ var w = (view.width/view.count)*canvas.scaleX;
+
+ //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2);
+
+ var movedX = Math.round((canvas.mousePressedX - mouse.x)/w);
+ if (movedX != 0 || canvas.movedY != 0) {
+ if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) {
+ canvas.first += movedX;
+ canvas.last += movedX;
+ }
+ canvas.requestPaint();
+ }
+ }
+ }
+
+ onPressed: {
+ canvas.mousePressedX = mouse.x;
+ canvas.mousePressedY = mouse.y;
+ }
+
+ onReleased : {
+ if (mouse.modifiers & Qt.ControlModifier) {
+ var sx = mouse.x - canvas.mouseX;
+ var sy = canvas.mouseY - mouse.y;
+
+ if (Math.abs(sx) < 50) sx = 0;
+ if (Math.abs(sy) < 50) sy = 0;
+
+ if (sx > 0)
+ canvas.scaleX *= sx/100 +1;
+ else
+ canvas.scaleX *= 1/(-sx/100 + 1);
+
+ if (sy > 0)
+ canvas.scaleY *= sy/100 +1;
+ else
+ canvas.scaleY *= 1/(-sy/100 + 1);
+
+ if (canvas.scaleX < 1)
+ canvas.scaleX = 1;
+
+ //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY);
+
+ canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX);
+ canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX);
+
+ canvas.mouseX = 0;
+ canvas.mouseY = 0;
+ canvas.mousePressedX = 0;
+ canvas.mousePressedY = 0;
+ canvas.requestPaint();
+ }
+ }
+ }
+
+ function runChart() {
+ canvas.running = true;
+ requestPaint();
+ }
+
+ function showPriceAt(x) {
+ var w = (view.width/view.count)*canvas.scaleX;
+ //header.updateCurrent(stockModel.stockPriceAtIndex(canvas.first + Math.round(x/w)));
+ //console.log("x:" + x + " w:" + w + " index:" + (canvas.first + Math.round(x/w)));
+ }
+
+ function drawPrice(ctx, from, to, color, price, points, highest)
+ {
+ ctx.globalAlpha = 0.7;
+ ctx.strokeStyle = color;
+ ctx.lineWidth = 1;
+ ctx.beginPath();
+
+ //price x axis
+ priceAxis.text = "price:" + Math.round(highest);
+ ctx.font = "bold 12px sans-serif";
+
+ ctx.strokeText("price", 25, 25);
+ for (var j = 1; j < 30; j++) {
+ var val = (highest * j) / 30;
+ val = canvas.height * (1 - val/highest);
+ ctx.beginPath();
+
+ ctx.moveTo(10, val);
+ if (j % 5)
+ ctx.lineTo(15, val);
+ else
+ ctx.lineTo(20, val);
+ ctx.stroke();
+ }
+
+ ctx.beginPath();
+ ctx.moveTo(10, 0);
+ ctx.lineTo(10, canvas.height);
+ ctx.stroke();
+
+
+ var w = canvas.width/points.length;
+ var end = canvas.running? canvas.frames - canvas.first :points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var y = points[i][price];
+ y += canvas.movedY;
+
+ y = canvas.height * (1 - y/highest);
+ if (i == 0) {
+ ctx.moveTo(x+w/2, y);
+ } else {
+ ctx.lineTo(x+w/2, y);
+ }
+ }
+ ctx.stroke();
+ }
+
+ function drawKLine(ctx, from, to, points, highest)
+ {
+ ctx.globalAlpha = 0.4;
+ ctx.lineWidth = 2;
+ var end = canvas.running? canvas.frames - canvas.first :points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var open = canvas.height * (1 - points[i].open/highest) - canvas.movedY;
+ var close = canvas.height * (1 - points[i].close/highest) - canvas.movedY;
+ var high = canvas.height * (1 - points[i].high/highest) - canvas.movedY;
+ var low = canvas.height * (1 - points[i].low/highest) - canvas.movedY;
+
+ var top, bottom;
+ if (close <= open) {
+ ctx.fillStyle = Qt.rgba(1, 0, 0, 1);
+ ctx.strokeStyle = Qt.rgba(1, 0, 0, 1);
+ top = close;
+ bottom = open;
+ } else {
+ ctx.fillStyle = Qt.rgba(0, 1, 0, 1);
+ ctx.strokeStyle = Qt.rgba(0, 1, 0, 1);
+ top = open;
+ bottom = close;
+ }
+
+ var w1, w2;
+ w1 = canvas.width/points.length;
+ w2 = w1 > 10 ? w1/2 : w1;
+
+ ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top);
+ ctx.beginPath();
+ ctx.moveTo(x+w1/2, high);
+ ctx.lineTo(x+w1/2, low);
+ ctx.stroke();
+ }
+ ctx.globalAlpha = 1;
+
+ }
+
+ function drawVolume(ctx, from, to, color, price, points, highest)
+ {
+ ctx.fillStyle = color;
+ ctx.globalAlpha = 0.6;
+ ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1);
+ ctx.lineWidth = 1;
+
+ //volume x axis
+ volumeAxis.text = "volume:" + Math.round(highest/(1000*100)) + "M";
+ for (var j = 1; j < 30; j++) {
+ var val = (highest * j) / 30;
+ val = canvas.height * (1 - val/highest);
+ ctx.beginPath();
+ if (j % 5)
+ ctx.moveTo(canvas.width - 15, val);
+ else
+ ctx.moveTo(canvas.width - 20, val);
+ ctx.lineTo(canvas.width - 10, val);
+ ctx.stroke();
+ }
+
+ ctx.beginPath();
+ ctx.moveTo(canvas.width - 10, 0);
+ ctx.lineTo(canvas.width - 10, canvas.height);
+ ctx.stroke();
+
+ var end = canvas.running? canvas.frames - canvas.first :points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var y = points[i][price];
+ y = canvas.height * (1 - y/highest);
+ ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y);
+ }
+ }
+/*
+ onPainted : {
+ if (canvas.running) {
+ if (frames >= last) {
+ canvas.running = false;
+ canvas.frames = first;
+ runButton.text = "Run this chart";
+ comment.text = stockModel.description;
+ requestPaint();
+ } else {
+ frames += Math.round(view.count / 100);
+ if (frames > last) frames = last;
+ var price = stockModel.stockPriceAtIndex(frames);
+ if (price) {
+ comment.updateCurrent(price);
+ }
+
+ requestPaint();
+ }
+ }
+ }
+*/
+ onPaint: {
+ if (view.currentIndex <= 0)
+ first = 0;
+ if (last >= view.count)
+ last = view.count - 1;
+
+ //console.log("painting... first:" + first + ", last:" + last + " current:" + view.currentIndex);
+ var ctx = canvas.getContext("2d");
+ ctx.save();
+
+ ctx.globalCompositeOperation = "source-over";
+ ctx.lineWidth = 1;
+ ctx.lineJoin = "round";
+ ctx.fillStyle = "rgba(0,0,0,0)";
+
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+
+
+ var highestPrice = 500/canvas.scaleY;
+ var highestValume = 600 * 1000 * 1000/canvas.scaleY;
+ var points = [];
+ for (var i = 0; i <= last - first; i++) {
+ var price = stockModel.stockPriceAtIndex(i + first);
+ points.push({
+ x: i*canvas.width/(last-first+1),
+ open: price.openPrice,
+ close: price.closePrice,
+ high:price.highPrice,
+ low:price.lowPrice,
+ volume:price.volume
+ });
+ }
+
+ drawPrice(ctx, first, last, Qt.rgba(1, 0, 0, 1),"high", points, highestPrice);
+ drawPrice(ctx, first, last, Qt.rgba(0, 1, 0, 1),"low", points, highestPrice);
+ drawPrice(ctx, first, last, Qt.rgba(0, 0, 1, 1),"open", points, highestPrice);
+ drawPrice(ctx, first, last, Qt.rgba(0.5, 0.5, 0.5, 1),"close", points, highestPrice);
+ drawVolume(ctx, first, last, Qt.rgba(0.3, 0.5, 0.7, 1),"volume", points, highestValume);
+ drawKLine(ctx, first, last, points, highestPrice);
+ ctx.restore();
+ }
+ }
+}
diff --git a/examples/quick/canvas/stockchart/stockchart.pro b/examples/quick/canvas/stockchart/stockchart.pro
new file mode 100644
index 0000000000..e368746db5
--- /dev/null
+++ b/examples/quick/canvas/stockchart/stockchart.pro
@@ -0,0 +1,20 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml network
+
+DESTDIR = com/nokia/StockChartExample
+TARGET = qmlstockchartexampleplugin
+
+SOURCES += model.cpp plugin.cpp
+HEADERS += model.h
+qdeclarativesources.files += \
+ com/nokia/StockChartExample/qmldir \
+ stock.qml
+
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample
+
+sources.files += stockchart.pro model.h model.cpp plugin.cpp README
+sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins
+target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample
+
+INSTALLS += qdeclarativesources sources target
diff --git a/examples/quick/canvas/tiger/tiger.js b/examples/quick/canvas/tiger/tiger.js
new file mode 100644
index 0000000000..4be0d26c9d
--- /dev/null
+++ b/examples/quick/canvas/tiger/tiger.js
@@ -0,0 +1,721 @@
+var tiger = [
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000",
+ "path":"M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"}
+ ,
+ {"fill": "#cc7226", "stroke":"#000000",
+ "path":"M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"}
+ ,
+ {"fill": "#e87f3a",
+ "path":"M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"}
+ ,
+ {"fill": "#ea8c4d",
+ "path":"M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"}
+ ,
+ {"fill": "#ec9961",
+ "path":"M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"}
+ ,
+ {"fill": "#eea575",
+ "path":"M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"}
+ ,
+ {"fill": "#f1b288",
+ "path":"M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"}
+ ,
+ {"fill": "#f3bf9c",
+ "path":"M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"}
+ ,
+ {"fill": "#f5ccb0",
+ "path":"M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"}
+ ,
+ {"fill": "#f8d8c4",
+ "path":"M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"}
+ ,
+ {"fill": "#fae5d7",
+ "path":"M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"}
+ ,
+ {"fill": "#fcf2eb",
+ "path":"M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"}
+ ,
+ {"fill": "#e5668c",
+ "path":"M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"}
+ ,
+ {"fill": "#b23259",
+ "path":"M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"}
+ ,
+ {"fill": "#a5264c",
+ "path":"M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"}
+ ,
+ {"fill": "#ff727f", "stroke":"#000000",
+ "path":"M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"}
+ ,
+ {"fill": "#cc3f4c",
+ "path":"M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"}
+ ,
+ {"stroke":"#a51926", "width":2,
+ "path":"M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M47 244.801C47 244.801 50.6 242.401 53 243.601"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"}
+ ,
+ {"fill": "#b2b2b2",
+ "path":"M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"}
+ ,
+ {"fill": "#e5e5b2",
+ "path":"M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"}
+ ,
+ {"fill": "#e5e5b2",
+ "path":"M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"}
+ ,
+ {"fill": "#ea8e51",
+ "path":"M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"}
+ ,
+ {"fill": "#efaa7c",
+ "path":"M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"}
+ ,
+ {"fill": "#f4c6a8",
+ "path":"M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"}
+ ,
+ {"fill": "#f9e2d3",
+ "path":"M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"}
+ ,
+ {"fill": "#659900",
+ "path":"M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"}
+ ,
+ {"fill": "#000000",
+ "path":"M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"}
+ ,
+ {"fill": "#eb955c",
+ "path":"M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"}
+ ,
+ {"fill": "#f2b892",
+ "path":"M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"}
+ ,
+ {"fill": "#f8dcc8",
+ "path":"M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"}
+ ,
+ {"fill": "#000000",
+ "path":"M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"}
+ ,
+ {"fill": "#000000",
+ "path":"M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"}
+ ,
+ {"fill": "#323232",
+ "path":"M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"}
+ ,
+ {"fill": "#666666",
+ "path":"M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"}
+ ,
+ {"fill": "#999999",
+ "path":"M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"}
+ ,
+ {"fill": "#992600",
+ "path":"M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"}
+ ,
+ {"fill": "#000000",
+ "path":"M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"}
+ ,
+ {"fill": "#000000",
+ "path":"M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"}
+ ,
+ {"fill": "#000000",
+ "path":"M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"}
+ ,
+ {"fill": "#4c0000",
+ "path":"M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"}
+ ,
+ {"fill": "#659900",
+ "path":"M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-65.4 9z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"}
+ ,
+ {"fill": "#e59999",
+ "path":"M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"}
+ ,
+ {"fill": "#b26565",
+ "path":"M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"}
+ ,
+ {"fill": "#000000",
+ "path":"M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"}
+ ,
+ {"fill": "#000000",
+ "path":"M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"}
+ ,
+ {"fill": "#000000",
+ "path":"M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"}
+ ,
+ {"fill": "#000000",
+ "path":"M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"}
+ ,
+ {"fill": "#000000",
+ "path":"M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"}
+ ,
+ {"fill": "#000000",
+ "path":"M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"}
+ ,
+ {"fill": "#000000",
+ "path":"M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"}
+ ,
+ {"fill": "#000000",
+ "path":"M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"}
+ ,
+ {"fill": "#000000",
+ "path":"M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"}
+ ,
+ {"fill": "#000000",
+ "path":"M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"}
+ ,
+ {"fill": "#000000",
+ "path":"M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"}
+ ,
+ {"fill": "#000000",
+ "path":"M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"}
+ ,
+ {"fill": "#000000",
+ "path":"M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"}
+ ,
+ {"fill": "#000000",
+ "path":"M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-89.25 169L-67.25 173.75"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-39 331C-39 331 -39.5 327.5 -48.5 338"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-33.5 336C-33.5 336 -31.5 329.5 -38 334"}
+ ,
+ {"stroke":"#000000",
+ "path":"M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"}
+]; \ No newline at end of file
diff --git a/examples/quick/canvas/tiger/tiger.qml b/examples/quick/canvas/tiger/tiger.qml
new file mode 100644
index 0000000000..2eb1bb2106
--- /dev/null
+++ b/examples/quick/canvas/tiger/tiger.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+import "tiger.js" as Tiger
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.FramebufferObject
+ renderStrategy: Canvas.Cooperative
+ property string strokeStyle:"steelblue"
+ property string fillStyle:"yellow"
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ property int frame:0
+
+ onFillChanged: requestPaint();
+ onStrokeChanged: requestPaint();
+ onAlphaChanged: requestPaint();
+ onScaleXChanged: requestPaint();
+ onScaleYChanged: requestPaint();
+ onRotateChanged: requestPaint();
+
+ onPainted : {
+ canvas.frame++;
+ if (canvas.frame < Tiger.tiger.length)
+ requestPaint();
+ }
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.globalCompositeOperation = "source-over";
+ ctx.translate(canvas.width/2, canvas.height/2);
+ ctx.strokeStyle = Qt.rgba(.3, .3, .3,1);
+ ctx.lineWidth = 1;
+
+
+ for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) {
+ if (Tiger.tiger[i].width != undefined)
+ ctx.lineWidth = Tiger.tiger[i].width;
+
+ if (Tiger.tiger[i].path != undefined)
+ ctx.path = Tiger.tiger[i].path;
+
+ if (Tiger.tiger[i].fill != undefined) {
+ ctx.fillStyle = Tiger.tiger[i].fill;
+ ctx.fill();
+ }
+
+ if (Tiger.tiger[i].stroke != undefined) {
+ ctx.strokeStyle = Tiger.tiger[i].stroke;
+ ctx.stroke();
+ }
+ }
+ ctx.restore();
+ }
+ }
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/twitterfriends/TwitterUser.qml b/examples/quick/canvas/twitterfriends/TwitterUser.qml
new file mode 100644
index 0000000000..8b906216ef
--- /dev/null
+++ b/examples/quick/canvas/twitterfriends/TwitterUser.qml
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id:twitterUser
+ property variant friends : [];
+ property string name : "";
+ property string twitterId : "";
+ property string image : "";
+ property string url : "";
+ property string desc : "";
+ width : 0;
+ height : 0;
+ property int posX:0;
+ property int posY:0;
+ property bool hasFocus : false;
+ property variant canvas;
+ property variant manager;
+ property variant linkColor;
+ property bool selected : false;
+
+ Rectangle {
+ id:twitterStatus
+ x:twitterUser.width
+ y:twitterUser.height
+ width:250
+ height:60
+ opacity: 0
+ border.color:"steelblue"
+ border.width:3
+ Column {
+ spacing:2
+ Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere}
+ Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere}
+ }
+ }
+
+ function moved() {
+ twitterUser.posX = twitterUser.x;
+ twitterUser.posY = twitterUser.y;
+ twitterUser.canvas.requestPaint();
+ }
+
+ onXChanged: moved();
+ onYChanged: moved();
+
+ MouseArea {
+ anchors.fill:parent
+ drag.target : twitterUser
+ drag.axis : Drag.XandYAxis
+
+ onClicked: {
+ if (!twitterUser.selected) {
+ twitterUser.selected = true;
+ twitterStatus.opacity = 1;
+ twitterStatus.visible = true;
+ } else {
+ twitterUser.selected = false;
+ twitterStatus.opacity = 0;
+ }
+ }
+
+ onDoubleClicked : {
+ twitterStatus.opacity = 0;
+ twitterUser.selected = false;
+ twitterUser.hasFocus = true;
+ twitterUser.canvas.twitterName = twitterUser.name;
+ twitterUser.canvas.twitterId = twitterUser.twitterId;
+ twitterUser.canvas.loading = true;
+ twitterUser.createFriends();
+ }
+ }
+
+ function show(ctx, layoutChanged) {
+ var w = canvas.width;
+ var h = canvas.height;
+ if (twitterUser.hasFocus) {
+ twitterUser.width = 60
+ twitterUser.height = 60
+ twitterUser.posX = w/2;
+ twitterUser.posY = h/2;
+ } else {
+ twitterUser.width = 40
+ twitterUser.height = 40
+ }
+
+
+ if (twitterUser.hasFocus) {
+ if (layoutChanged)
+ twitterUser.layoutFriends();
+ twitterUser.linkFriends(ctx);
+ twitterUser.showFriends(ctx);
+ ctx.shadowOffsetX = 5;
+ ctx.shadowOffsetY = 5;
+ ctx.shadowBlur = 7;
+ ctx.shadowColor = "blue";
+ ctx.globalAlpha = 1;
+ } else {
+ ctx.shadowOffsetX = 5;
+ ctx.shadowOffsetY = 5;
+ ctx.shadowBlur = 7;
+ ctx.shadowColor = twitterUser.linkColor;
+ ctx.globalAlpha = 0.6;
+ }
+
+ if (twitterUser.canvas.isImageLoaded(twitterUser.image)) {
+ ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height);
+ }
+// ctx.font = "15px";
+// var nameSize = ctx.measureText(twitterUser.name).width;
+// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10);
+ }
+ function dump() {
+ console.log("name:" + twitterUser.name
+ + " x:" + twitterUser.posX
+ + " y:" + twitterUser.posY
+ + " width:" + twitterUser.width
+ + " height:" + twitterUser.height
+ + " id:" + twitterUser.twitterId
+ + " image:" + twitterUser.image
+ + " url:" + twitterUser.url + "\n" + twitterUser.desc);
+ }
+
+ function layoutFriends() {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend) {
+ friend.x = Math.random() *w;
+ friend.y = Math.random() *h;
+ }
+ }
+ }
+
+ function showFriends(ctx) {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length && i < 15; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend && twitterUser.canvas.isImageLoaded(friend.image)) {
+ friend.hasFocus = false;
+ friend.show(ctx, false);
+ }
+ }
+ }
+
+ function linkFriends(ctx) {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length && i < 15; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend && twitterUser.canvas.isImageLoaded(friend.image)) {
+ if (!friend.linkColor)
+ friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255
+ , ((Math.random() * 200) +55)/255
+ , ((Math.random() * 200) +55)/255, 0.8);
+ ctx.strokeStyle = friend.linkColor;
+ ctx.lineWidth = 8;
+ ctx.beginPath();
+ ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2);
+ ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2);
+ ctx.stroke();
+ }
+ }
+ }
+
+
+ function create(url) {
+ var x = new XMLHttpRequest;
+ x.open("GET", url);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ var user = eval('(' + x.responseText +')')[0];
+ twitterUser.name = user.name;
+ twitterUser.twitterId = user.id;
+ twitterUser.image = user.profile_image_url;
+ twitterUser.canvas.loadImage(twitterUser.image);
+ twitterUser.url = user.url;
+ twitterUser.desc = user.description;
+ twitterUser.createFriends();
+ }
+ }
+ x.send();
+ }
+
+ function createByName(name) {
+ if (twitterUser.name === "" && twitterUser.twitterId === "") {
+ twitterUser.name = name;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name;
+ twitterUser.create(userUrl);
+ }
+ }
+
+ function createById(id) {
+ if (twitterUser.name === "" && twitterUser.twitterId === "") {
+ twitterUser.twitterId = id;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id;
+ twitterUser.create(userUrl);
+ }
+ }
+
+ function createFriends() {
+ if (twitterUser.friends.length === 0) {
+ var x = new XMLHttpRequest;
+ var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId;
+ x.open("GET", friendsUrl);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ twitterUser.friends = eval('(' + x.responseText +')').ids;
+ var doRequest = false;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=";
+
+ for (var i=0; i<twitterUser.friends.length && i < 100; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (!friend) {
+ userUrl += "," + twitterUser.friends[i];
+ doRequest = true;
+ }
+ }
+
+ if (!doRequest) return;
+
+ var xx = new XMLHttpRequest;
+ xx.open("GET", userUrl);
+ xx.onreadystatechange = function() {
+ if (xx.readyState == XMLHttpRequest.DONE) {
+ var friendUsers = eval('(' + xx.responseText +')');
+ for(var i=0; i<friendUsers.length; i++) {
+ var friend = manager.createTwitterUser(twitterUser.canvas);
+ friend.name = friendUsers[i].name;
+ friend.twitterId = friendUsers[i].id;
+ friend.image = friendUsers[i].profile_image_url ? friendUsers[i].profile_image_url : "";
+ friend.url = friendUsers[i].url ? friendUsers[i].url : "";
+ friend.desc = friendUsers[i].description ? friendUsers[i].description : "";
+ friend.manager = twitterUser.manager;
+ twitterUser.canvas.loadImage(friend.image);
+ }
+
+ if (twitterUser.hasFocus && twitterUser.canvas) {
+ twitterUser.canvas.layoutChanged = true;
+ twitterUser.canvas.loading = false;
+ twitterUser.canvas.requestPaint();
+ }
+ }
+ }
+ xx.send();
+ }
+ }
+ x.send();
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/quick/canvas/twitterfriends/cache.js b/examples/quick/canvas/twitterfriends/cache.js
new file mode 100644
index 0000000000..6c8a1cd71a
--- /dev/null
+++ b/examples/quick/canvas/twitterfriends/cache.js
@@ -0,0 +1,42 @@
+var UserCache = function() {
+ this._users = [];
+}
+
+
+UserCache.prototype.getById = function(id){
+ for (var i=0; i < this._users.length; i++){
+ var user = this._users[i];
+ if (user.twitterId == id) {
+ return user;
+ }
+ }
+}
+UserCache.prototype.getByName = function(name){
+ for (var i=0; i < this._users.length; i++){
+ var user = this._users[i];
+ if (user.name == name)
+ return user;
+ }
+}
+
+UserCache.prototype.add = function(user){
+ this._users[this._users.length] = user;
+}
+
+
+var cache = new UserCache;
+
+function getById(id) {
+ return cache.getById(id);
+}
+
+function getByName(name) {
+ return cache.getByName(name);
+}
+
+function createTwitterUser(canvas) {
+ var user = Qt.createQmlObject("import QtQuick 2.0; TwitterUser{}", canvas);
+ user.canvas = canvas;
+ cache.add(user);
+ return user;
+}
diff --git a/examples/quick/canvas/twitterfriends/twitter.qml b/examples/quick/canvas/twitterfriends/twitter.qml
new file mode 100644
index 0000000000..9dc2bcc939
--- /dev/null
+++ b/examples/quick/canvas/twitterfriends/twitter.qml
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+import "cache.js" as TwitterUserCache
+Rectangle {
+ width:360
+ height:600
+ color:"black"
+ QtObject {
+ id:twitterManager
+ function getById(id) {
+ return TwitterUserCache.cache.getById(id);
+ }
+
+ function getByName(name) {
+ return TwitterUserCache.cache.getByName(name);
+ }
+
+ function createTwitterUser(canvas) {
+ return TwitterUserCache.createTwitterUser(canvas);
+ }
+ }
+ Rectangle {
+ id:inputContainer
+ width:parent.width-4
+ height:40
+ anchors.top:parent.top
+ anchors.topMargin:4
+ anchors.horizontalCenter:parent.horizontalCenter
+ radius:8
+ border.color:"steelblue"
+ Text {
+ text:inputName.text == "" ? "Enter your twitter name..." : ""
+ id:inputLabel
+ anchors.centerIn:parent
+ font.pointSize:12
+ opacity:.5
+ color:"steelblue"
+ }
+ TextInput {
+ id:inputName
+ anchors.centerIn:parent
+ font.pointSize : 20
+ opacity:1
+ color:"steelblue"
+ width:parent.width-6
+ height:parent.height-6
+ text:""
+ autoScroll:true
+ focus:true
+ selectByMouse:true
+ onAccepted : {canvas.twitterName = text; canvas.requestPaint();}
+ }
+ }
+ Canvas {
+ id:canvas
+ width:parent.width
+ anchors.top :inputContainer.bottom
+ anchors.bottom : parent.bottom
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ property bool layoutChanged:true
+ property string twitterName:""
+ property string twitterId:""
+ property bool loading:false
+
+ onLoadingChanged: requestPaint();
+ onWidthChanged: { layoutChanged = true; requestPaint();}
+ onHeightChanged: { layoutChanged = true; requestPaint();}
+ onTwitterNameChanged: inputName.text = twitterName;
+ onImageLoaded:requestPaint();
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.fillStyle="black";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ if (canvas.twitterName != "" || canvas.twitterId != "") {
+ var user = canvas.twitterId ? TwitterUserCache.getById(canvas.twitterId) : TwitterUserCache.getByName(canvas.twitterName);
+ if (!user) {
+ user = TwitterUserCache.createTwitterUser(canvas);
+ user.hasFocus = true;
+ user.manager = twitterManager;
+ user.createByName(canvas.twitterName);
+ canvas.loading = true;
+ }
+
+ if (canvas.loading) {
+ ctx.font = "40px";
+ ctx.fillStyle = "steelblue";
+ ctx.fillText("Loading...", canvas.width/2 - 80, canvas.height/2);
+ } else {
+ user.show(ctx, layoutChanged);
+ }
+ layoutChanged = false;
+ }
+ ctx.restore();
+ }
+ }
+}
diff --git a/examples/quick/draganddrop/draganddrop.pro b/examples/quick/draganddrop/draganddrop.pro
new file mode 100644
index 0000000000..3f535312e0
--- /dev/null
+++ b/examples/quick/draganddrop/draganddrop.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/draganddrop
+qml.files = draganddrop.qml tiles views
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/draganddrop
+INSTALLS += target qml
+
diff --git a/examples/qtquick/draganddrop/draganddrop.qml b/examples/quick/draganddrop/draganddrop.qml
index 88e6d5e021..88e6d5e021 100644
--- a/examples/qtquick/draganddrop/draganddrop.qml
+++ b/examples/quick/draganddrop/draganddrop.qml
diff --git a/examples/qtquick/draganddrop/draganddrop.qmlproject b/examples/quick/draganddrop/draganddrop.qmlproject
index b8b15c3444..b8b15c3444 100644
--- a/examples/qtquick/draganddrop/draganddrop.qmlproject
+++ b/examples/quick/draganddrop/draganddrop.qmlproject
diff --git a/examples/qtquick/draganddrop/main.cpp b/examples/quick/draganddrop/main.cpp
index 0d74fbfe2e..0d74fbfe2e 100644
--- a/examples/qtquick/draganddrop/main.cpp
+++ b/examples/quick/draganddrop/main.cpp
diff --git a/examples/qtquick/draganddrop/tiles/DragTile.qml b/examples/quick/draganddrop/tiles/DragTile.qml
index 1f4a8c2bea..1f4a8c2bea 100644
--- a/examples/qtquick/draganddrop/tiles/DragTile.qml
+++ b/examples/quick/draganddrop/tiles/DragTile.qml
diff --git a/examples/qtquick/draganddrop/tiles/DropTile.qml b/examples/quick/draganddrop/tiles/DropTile.qml
index 98fedeb775..98fedeb775 100644
--- a/examples/qtquick/draganddrop/tiles/DropTile.qml
+++ b/examples/quick/draganddrop/tiles/DropTile.qml
diff --git a/examples/qtquick/draganddrop/tiles/tiles.qml b/examples/quick/draganddrop/tiles/tiles.qml
index 0b5647bc2b..0b5647bc2b 100644
--- a/examples/qtquick/draganddrop/tiles/tiles.qml
+++ b/examples/quick/draganddrop/tiles/tiles.qml
diff --git a/examples/qtquick/draganddrop/views/gridview.qml b/examples/quick/draganddrop/views/gridview.qml
index b18078f48d..b18078f48d 100644
--- a/examples/qtquick/draganddrop/views/gridview.qml
+++ b/examples/quick/draganddrop/views/gridview.qml
diff --git a/examples/qtquick/imageelements/animatedsprite.qml b/examples/quick/imageelements/animatedsprite.qml
index 337456f785..337456f785 100644
--- a/examples/qtquick/imageelements/animatedsprite.qml
+++ b/examples/quick/imageelements/animatedsprite.qml
diff --git a/examples/qtquick/imageelements/borderimage.qml b/examples/quick/imageelements/borderimage.qml
index 30120fe60d..30120fe60d 100644
--- a/examples/qtquick/imageelements/borderimage.qml
+++ b/examples/quick/imageelements/borderimage.qml
diff --git a/examples/quick/imageelements/content/BearSheet.png b/examples/quick/imageelements/content/BearSheet.png
new file mode 100644
index 0000000000..a084bf0f1e
--- /dev/null
+++ b/examples/quick/imageelements/content/BearSheet.png
Binary files differ
diff --git a/examples/qtquick/imageelements/content/BorderImageSelector.qml b/examples/quick/imageelements/content/BorderImageSelector.qml
index f3a534b3cd..f3a534b3cd 100644
--- a/examples/qtquick/imageelements/content/BorderImageSelector.qml
+++ b/examples/quick/imageelements/content/BorderImageSelector.qml
diff --git a/examples/quick/imageelements/content/ImageCell.qml b/examples/quick/imageelements/content/ImageCell.qml
new file mode 100644
index 0000000000..fcc6b47af5
--- /dev/null
+++ b/examples/quick/imageelements/content/ImageCell.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ property alias mode: image.fillMode
+ property alias caption: captionItem.text
+
+ width: parent.cellWidth; height: parent.cellHeight
+
+ Image {
+ id: image
+ width: parent.width; height: parent.height - captionItem.height
+ source: "qt-logo.png"
+ clip: true // only makes a difference if mode is PreserveAspectCrop
+ smooth: true
+ }
+
+ Text {
+ id: captionItem
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom
+ }
+}
diff --git a/examples/qtquick/imageelements/content/MyBorderImage.qml b/examples/quick/imageelements/content/MyBorderImage.qml
index 93880f12bb..93880f12bb 100644
--- a/examples/qtquick/imageelements/content/MyBorderImage.qml
+++ b/examples/quick/imageelements/content/MyBorderImage.qml
diff --git a/examples/quick/imageelements/content/ShadowRectangle.qml b/examples/quick/imageelements/content/ShadowRectangle.qml
new file mode 100644
index 0000000000..e6fd13bb26
--- /dev/null
+++ b/examples/quick/imageelements/content/ShadowRectangle.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property alias color : rectangle.color
+
+ BorderImage {
+ anchors.fill: rectangle
+ anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+ source: "shadow.png"; smooth: true
+ }
+
+ Rectangle { id: rectangle; anchors.fill: parent }
+}
diff --git a/examples/quick/imageelements/content/bw.png b/examples/quick/imageelements/content/bw.png
new file mode 100644
index 0000000000..486eaae96e
--- /dev/null
+++ b/examples/quick/imageelements/content/bw.png
Binary files differ
diff --git a/examples/quick/imageelements/content/colors-round.sci b/examples/quick/imageelements/content/colors-round.sci
new file mode 100644
index 0000000000..506f6f5f99
--- /dev/null
+++ b/examples/quick/imageelements/content/colors-round.sci
@@ -0,0 +1,7 @@
+border.left:30
+border.top:30
+border.right:30
+border.bottom:30
+horizontalTileRule:Round
+verticalTileRule:Round
+source:colors.png
diff --git a/examples/quick/imageelements/content/colors-stretch.sci b/examples/quick/imageelements/content/colors-stretch.sci
new file mode 100644
index 0000000000..e4989a723c
--- /dev/null
+++ b/examples/quick/imageelements/content/colors-stretch.sci
@@ -0,0 +1,5 @@
+border.left:30
+border.top:30
+border.right:30
+border.bottom:30
+source:colors.png
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors.png b/examples/quick/imageelements/content/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors.png
+++ b/examples/quick/imageelements/content/colors.png
Binary files differ
diff --git a/examples/quick/imageelements/content/qt-logo.png b/examples/quick/imageelements/content/qt-logo.png
new file mode 100644
index 0000000000..14ddf2a028
--- /dev/null
+++ b/examples/quick/imageelements/content/qt-logo.png
Binary files differ
diff --git a/examples/quick/imageelements/content/shadow.png b/examples/quick/imageelements/content/shadow.png
new file mode 100644
index 0000000000..431af8545d
--- /dev/null
+++ b/examples/quick/imageelements/content/shadow.png
Binary files differ
diff --git a/examples/quick/imageelements/content/speaker.png b/examples/quick/imageelements/content/speaker.png
new file mode 100644
index 0000000000..fb0e857859
--- /dev/null
+++ b/examples/quick/imageelements/content/speaker.png
Binary files differ
diff --git a/examples/qtquick/imageelements/image.qml b/examples/quick/imageelements/image.qml
index ccefaf6b74..ccefaf6b74 100644
--- a/examples/qtquick/imageelements/image.qml
+++ b/examples/quick/imageelements/image.qml
diff --git a/examples/quick/imageelements/imageelements.pro b/examples/quick/imageelements/imageelements.pro
new file mode 100644
index 0000000000..89abac6e25
--- /dev/null
+++ b/examples/quick/imageelements/imageelements.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/imageelements
+qml.files = borderimage.qml content imageelements.qml image.qml shadows.qml simplesprite.qml spriteimage.qml
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/imageelements
+INSTALLS += target qml
+
diff --git a/examples/qtquick/imageelements/imageelements.qml b/examples/quick/imageelements/imageelements.qml
index bb23ef6979..bb23ef6979 100644
--- a/examples/qtquick/imageelements/imageelements.qml
+++ b/examples/quick/imageelements/imageelements.qml
diff --git a/examples/quick/imageelements/imageelements.qmlproject b/examples/quick/imageelements/imageelements.qmlproject
new file mode 100644
index 0000000000..4292a0c112
--- /dev/null
+++ b/examples/quick/imageelements/imageelements.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "imageelements.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qtquick/imageelements/main.cpp b/examples/quick/imageelements/main.cpp
index 72850f93c1..72850f93c1 100644
--- a/examples/qtquick/imageelements/main.cpp
+++ b/examples/quick/imageelements/main.cpp
diff --git a/examples/quick/imageelements/shadows.qml b/examples/quick/imageelements/shadows.qml
new file mode 100644
index 0000000000..aa5022ab36
--- /dev/null
+++ b/examples/quick/imageelements/shadows.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: window
+
+ width: 480; height: 320
+ color: "gray"
+
+ ShadowRectangle {
+ anchors.centerIn: parent; width: 250; height: 250
+ color: "lightsteelblue"
+ }
+
+ ShadowRectangle {
+ anchors.centerIn: parent; width: 200; height: 200
+ color: "steelblue"
+ }
+
+ ShadowRectangle {
+ anchors.centerIn: parent; width: 150; height: 150
+ color: "thistle"
+ }
+}
diff --git a/examples/qtquick/imageelements/spritesequence.qml b/examples/quick/imageelements/spritesequence.qml
index 01f34e5c7a..01f34e5c7a 100644
--- a/examples/qtquick/imageelements/spritesequence.qml
+++ b/examples/quick/imageelements/spritesequence.qml
diff --git a/examples/quick/keyinteraction/focus/Core/ContextMenu.qml b/examples/quick/keyinteraction/focus/Core/ContextMenu.qml
new file mode 100644
index 0000000000..dc68aa2b30
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/ContextMenu.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: container
+
+ property bool open: false
+
+ Item {
+ anchors.fill: parent
+
+ Rectangle {
+ anchors.fill: parent
+ color: "#D1DBBD"
+ focus: true
+ Keys.onRightPressed: mainView.focus = true
+
+ Text {
+ anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 }
+ color: "black"
+ font.pixelSize: 14
+ text: "Context Menu"
+ }
+ }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/GridMenu.qml b/examples/quick/keyinteraction/focus/Core/GridMenu.qml
new file mode 100644
index 0000000000..75bbe682af
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/GridMenu.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ property alias interactive: gridView.interactive
+
+ onActiveFocusChanged: {
+ if (activeFocus)
+ mainView.state = ""
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ clip: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#193441" }
+ GradientStop { position: 1.0; color: Qt.darker("#193441") }
+ }
+
+ GridView {
+ id: gridView
+ anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20
+ cellWidth: 152; cellHeight: 152
+ focus: true
+ model: 12
+
+ KeyNavigation.down: listMenu
+ KeyNavigation.left: contextMenu
+
+ delegate: Item {
+ id: container
+ width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ Rectangle {
+ id: content
+ color: "transparent"
+ smooth: true
+ anchors.fill: parent; anchors.margins: 20; radius: 10
+
+ Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; smooth: true }
+ Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
+ onClicked: {
+ container.GridView.view.currentIndex = index
+ container.forceActiveFocus()
+ }
+ }
+
+ states: State {
+ name: "active"; when: container.activeFocus
+ PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; duration: 100 }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/ListMenu.qml b/examples/quick/keyinteraction/focus/Core/ListMenu.qml
new file mode 100644
index 0000000000..7a62f33428
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/ListMenu.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ clip: true
+
+ onActiveFocusChanged: {
+ if (activeFocus)
+ mainView.state = "showListViews"
+ }
+
+ ListView {
+ id: list1
+ y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20
+ focus: true
+ KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2
+ model: 10; cacheBuffer: 200
+ delegate: ListViewDelegate {}
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: Easing.OutQuint }
+ }
+ }
+
+ ListView {
+ id: list2
+ y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20
+ KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
+ model: 10; cacheBuffer: 200
+ delegate: ListViewDelegate {}
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: Easing.OutQuint }
+ }
+ }
+
+ ListView {
+ id: list3
+ y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20
+ KeyNavigation.up: gridMenu; KeyNavigation.left: list2
+ model: 10; cacheBuffer: 200
+ delegate: ListViewDelegate {}
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: Easing.OutQuint }
+ }
+ }
+
+ Rectangle { width: parent.width; height: 1; color: "#D1DBBD" }
+
+ Rectangle {
+ y: 1; width: parent.width; height: 10
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#3E606F" }
+ GradientStop { position: 1.0; color: "transparent" }
+ }
+ }
+
+ Rectangle {
+ y: parent.height - 10; width: parent.width; height: 10
+ gradient: Gradient {
+ GradientStop { position: 1.0; color: "#3E606F" }
+ GradientStop { position: 0.0; color: "transparent" }
+ }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml
new file mode 100644
index 0000000000..b28b02616d
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+ width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10
+
+ Rectangle {
+ id: content
+ anchors.centerIn: parent; width: container.width - 40; height: container.height - 10
+ color: "transparent"
+ smooth: true
+ radius: 10
+
+ Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 }
+ }
+
+ Text {
+ id: label
+ anchors.centerIn: content
+ text: "List element " + (index + 1)
+ color: "#193441"
+ font.pixelSize: 14
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
+ onClicked: {
+ container.ListView.view.currentIndex = index
+ container.forceActiveFocus()
+ }
+ }
+
+ states: State {
+ name: "active"; when: container.activeFocus
+ PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ PropertyChanges { target: label; font.pixelSize: 16 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; duration: 100 }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/images/arrow.png b/examples/quick/keyinteraction/focus/Core/images/arrow.png
new file mode 100644
index 0000000000..14978c2e56
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/images/arrow.png
Binary files differ
diff --git a/examples/quick/keyinteraction/focus/Core/images/qt-logo.png b/examples/quick/keyinteraction/focus/Core/images/qt-logo.png
new file mode 100644
index 0000000000..14ddf2a028
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/images/qt-logo.png
Binary files differ
diff --git a/examples/quick/keyinteraction/focus/focus.qml b/examples/quick/keyinteraction/focus/focus.qml
new file mode 100644
index 0000000000..9300ad4f6e
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/focus.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "Core"
+
+Rectangle {
+ id: window
+
+ width: 800; height: 480
+ color: "#3E606F"
+
+ FocusScope {
+ id: mainView
+
+ width: parent.width; height: parent.height
+ focus: true
+
+ GridMenu {
+ id: gridMenu
+ width: parent.width; height: 320
+
+ focus: true
+ interactive: parent.activeFocus
+ }
+
+ ListMenu {
+ id: listMenu
+ y: 320; width: parent.width; height: 320
+ }
+
+ Rectangle {
+ id: shade
+ anchors.fill: parent
+ color: "black"
+ opacity: 0
+ }
+
+ states: State {
+ name: "showListViews"
+ PropertyChanges { target: gridMenu; y: -160 }
+ PropertyChanges { target: listMenu; y: 160 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint }
+ }
+ }
+
+ Image {
+ source: "Core/images/arrow.png"
+ rotation: 90
+ anchors.verticalCenter: parent.verticalCenter
+
+ MouseArea {
+ anchors.fill: parent; anchors.margins: -10
+ onClicked: contextMenu.focus = true
+ }
+ }
+
+ ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height }
+
+ states: State {
+ name: "contextMenuOpen"
+ when: !mainView.activeFocus
+ PropertyChanges { target: contextMenu; x: 0; open: true }
+ PropertyChanges { target: mainView; x: 130 }
+ PropertyChanges { target: shade; opacity: 0.25 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint }
+ }
+}
diff --git a/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.pro
new file mode 100644
index 0000000000..f786d9356f
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = abstractitemmodel
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += qml quick
+
+HEADERS = model.h
+SOURCES = main.cpp \
+ model.cpp
+RESOURCES += abstractitemmodel.qrc
diff --git a/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.qrc
new file mode 100644
index 0000000000..4ae861cb3d
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>view.qml</file>
+</qresource>
+</RCC>
+
diff --git a/examples/quick/modelviews/abstractitemmodel/main.cpp b/examples/quick/modelviews/abstractitemmodel/main.cpp
new file mode 100644
index 0000000000..f5930ce840
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/main.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+
+#include <QGuiApplication>
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+//![0]
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ AnimalModel model;
+ model.addAnimal(Animal("Wolf", "Medium"));
+ model.addAnimal(Animal("Polar bear", "Large"));
+ model.addAnimal(Animal("Quoll", "Small"));
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/quick/modelviews/abstractitemmodel/model.cpp b/examples/quick/modelviews/abstractitemmodel/model.cpp
new file mode 100644
index 0000000000..8f7649c0d4
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/model.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+
+Animal::Animal(const QString &type, const QString &size)
+ : m_type(type), m_size(size)
+{
+}
+
+QString Animal::type() const
+{
+ return m_type;
+}
+
+QString Animal::size() const
+{
+ return m_size;
+}
+
+//![0]
+AnimalModel::AnimalModel(QObject *parent)
+ : QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[TypeRole] = "type";
+ roles[SizeRole] = "size";
+ setRoleNames(roles);
+}
+//![0]
+
+void AnimalModel::addAnimal(const Animal &animal)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ m_animals << animal;
+ endInsertRows();
+}
+
+int AnimalModel::rowCount(const QModelIndex & parent) const {
+ return m_animals.count();
+}
+
+QVariant AnimalModel::data(const QModelIndex & index, int role) const {
+ if (index.row() < 0 || index.row() >= m_animals.count())
+ return QVariant();
+
+ const Animal &animal = m_animals[index.row()];
+ if (role == TypeRole)
+ return animal.type();
+ else if (role == SizeRole)
+ return animal.size();
+ return QVariant();
+}
+
diff --git a/examples/quick/modelviews/abstractitemmodel/model.h b/examples/quick/modelviews/abstractitemmodel/model.h
new file mode 100644
index 0000000000..1378c4487e
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/model.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QAbstractListModel>
+#include <QStringList>
+
+//![0]
+class Animal
+{
+public:
+ Animal(const QString &type, const QString &size);
+//![0]
+
+ QString type() const;
+ QString size() const;
+
+private:
+ QString m_type;
+ QString m_size;
+//![1]
+};
+
+class AnimalModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum AnimalRoles {
+ TypeRole = Qt::UserRole + 1,
+ SizeRole
+ };
+
+ AnimalModel(QObject *parent = 0);
+//![1]
+
+ void addAnimal(const Animal &animal);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+private:
+ QList<Animal> m_animals;
+//![2]
+};
+//![2]
+
+
diff --git a/examples/quick/modelviews/abstractitemmodel/view.qml b/examples/quick/modelviews/abstractitemmodel/view.qml
new file mode 100644
index 0000000000..64f5871d4b
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/view.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+//![0]
+ListView {
+ width: 200; height: 250
+
+ model: myModel
+ delegate: Text { text: "Animal: " + type + ", " + size }
+}
+//![0]
+
diff --git a/examples/quick/modelviews/gridview/gridview-example.qml b/examples/quick/modelviews/gridview/gridview-example.qml
new file mode 100644
index 0000000000..ea3bb5cec9
--- /dev/null
+++ b/examples/quick/modelviews/gridview/gridview-example.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 300; height: 400
+ color: "white"
+
+ ListModel {
+ id: appModel
+ ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" }
+ ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" }
+ ListElement { name: "Camera"; icon: "pics/Camera_48.png" }
+ ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" }
+ ListElement { name: "Messaging"; icon: "pics/EMail_48.png" }
+ ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" }
+ ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" }
+ }
+
+ Component {
+ id: appDelegate
+
+ Item {
+ width: 100; height: 100
+
+ Image {
+ id: myIcon
+ y: 20; anchors.horizontalCenter: parent.horizontalCenter
+ source: icon
+ }
+ Text {
+ anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter }
+ text: name
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: parent.GridView.view.currentIndex = index
+ }
+ }
+ }
+
+ Component {
+ id: appHighlight
+ Rectangle { width: 80; height: 80; color: "lightsteelblue" }
+ }
+
+ GridView {
+ anchors.fill: parent
+ cellWidth: 100; cellHeight: 100
+ highlight: appHighlight
+ focus: true
+ model: appModel
+ delegate: appDelegate
+ }
+}
diff --git a/examples/quick/modelviews/gridview/pics/AddressBook_48.png b/examples/quick/modelviews/gridview/pics/AddressBook_48.png
new file mode 100644
index 0000000000..1ab7c8eec1
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/AddressBook_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png b/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png
new file mode 100644
index 0000000000..f4b8689f87
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/Camera_48.png b/examples/quick/modelviews/gridview/pics/Camera_48.png
new file mode 100644
index 0000000000..c76b524945
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/Camera_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/DateBook_48.png b/examples/quick/modelviews/gridview/pics/DateBook_48.png
new file mode 100644
index 0000000000..58f5787fb8
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/DateBook_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/EMail_48.png b/examples/quick/modelviews/gridview/pics/EMail_48.png
new file mode 100644
index 0000000000..d6d84a61be
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/EMail_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/TodoList_48.png b/examples/quick/modelviews/gridview/pics/TodoList_48.png
new file mode 100644
index 0000000000..0988448d9b
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/TodoList_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png b/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png
new file mode 100644
index 0000000000..52638c50a7
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/PetsModel.qml b/examples/quick/modelviews/listview/content/PetsModel.qml
new file mode 100644
index 0000000000..4f2087d95e
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/quick/modelviews/listview/content/PressAndHoldButton.qml b/examples/quick/modelviews/listview/content/PressAndHoldButton.qml
new file mode 100644
index 0000000000..b20d8f64f1
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/PressAndHoldButton.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+
+ property int repeatDelay: 300
+ property int repeatDuration: 75
+ property bool pressed: false
+
+ signal clicked
+
+ scale: pressed ? 0.9 : 1
+
+ function release() {
+ autoRepeatClicks.stop()
+ container.pressed = false
+ }
+
+ SequentialAnimation on pressed {
+ id: autoRepeatClicks
+ running: false
+
+ PropertyAction { target: container; property: "pressed"; value: true }
+ ScriptAction { script: container.clicked() }
+ PauseAnimation { duration: repeatDelay }
+
+ SequentialAnimation {
+ loops: Animation.Infinite
+ ScriptAction { script: container.clicked() }
+ PauseAnimation { duration: repeatDuration }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onPressed: autoRepeatClicks.start()
+ onReleased: container.release()
+ onCanceled: container.release()
+ }
+}
+
diff --git a/examples/quick/modelviews/listview/content/RecipesModel.qml b/examples/quick/modelviews/listview/content/RecipesModel.qml
new file mode 100644
index 0000000000..86210ba436
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/RecipesModel.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ title: "Pancakes"
+ picture: "content/pics/pancakes.jpg"
+ ingredients: "<html>
+ <ul>
+ <li> 1 cup (150g) self-raising flour
+ <li> 1 tbs caster sugar
+ <li> 3/4 cup (185ml) milk
+ <li> 1 egg
+ </ul>
+ </html>"
+ method: "<html>
+ <ol>
+ <li> Sift flour and sugar together into a bowl. Add a pinch of salt.
+ <li> Beat milk and egg together, then add to dry ingredients. Beat until smooth.
+ <li> Pour mixture into a pan on medium heat and cook until bubbles appear on the surface.
+ <li> Turn over and cook other side until golden.
+ </ol>
+ </html>"
+ }
+ ListElement {
+ title: "Fruit Salad"
+ picture: "content/pics/fruit-salad.jpg"
+ ingredients: "* Seasonal Fruit"
+ method: "* Chop fruit and place in a bowl."
+ }
+ ListElement {
+ title: "Vegetable Soup"
+ picture: "content/pics/vegetable-soup.jpg"
+ ingredients: "<html>
+ <ul>
+ <li> 1 onion
+ <li> 1 turnip
+ <li> 1 potato
+ <li> 1 carrot
+ <li> 1 head of celery
+ <li> 1 1/2 litres of water
+ </ul>
+ </html>"
+ method: "<html>
+ <ol>
+ <li> Chop vegetables.
+ <li> Boil in water until vegetables soften.
+ <li> Season with salt and pepper to taste.
+ </ol>
+ </html>"
+ }
+ ListElement {
+ title: "Hamburger"
+ picture: "content/pics/hamburger.jpg"
+ ingredients: "<html>
+ <ul>
+ <li> 500g minced beef
+ <li> Seasoning
+ <li> lettuce, tomato, onion, cheese
+ <li> 1 hamburger bun for each burger
+ </ul>
+ </html>"
+ method: "<html>
+ <ol>
+ <li> Mix the beef, together with seasoning, in a food processor.
+ <li> Shape the beef into burgers.
+ <li> Grill the burgers for about 5 mins on each side (until cooked through)
+ <li> Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion.
+ </ol>
+ </html>"
+ }
+ ListElement {
+ title: "Lemonade"
+ picture: "content/pics/lemonade.jpg"
+ ingredients: "<html>
+ <ul>
+ <li> 1 cup Lemon Juice
+ <li> 1 cup Sugar
+ <li> 6 Cups of Water (2 cups warm water, 4 cups cold water)
+ </ul>
+ </html>"
+ method: "<html>
+ <ol>
+ <li> Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves.
+ <li> Pour in lemon juice, stir again, and add 4 cups of cold water.
+ <li> Chill or serve over ice cubes.
+ </ol>
+ </html>"
+ }
+}
diff --git a/examples/quick/modelviews/listview/content/TextButton.qml b/examples/quick/modelviews/listview/content/TextButton.qml
new file mode 100644
index 0000000000..980ee21553
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/TextButton.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property alias text: label.text
+
+ signal clicked
+
+ width: label.width + 20; height: label.height + 6
+ smooth: true
+ radius: 10
+
+ gradient: Gradient {
+ GradientStop { id: gradientStop; position: 0.0; color: palette.light }
+ GradientStop { position: 1.0; color: palette.button }
+ }
+
+ SystemPalette { id: palette }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: { container.clicked() }
+ }
+
+ Text {
+ id: label
+ anchors.centerIn: parent
+ }
+
+ states: State {
+ name: "pressed"
+ when: mouseArea.pressed
+ PropertyChanges { target: gradientStop; color: palette.dark }
+ }
+}
+
diff --git a/examples/quick/modelviews/listview/content/ToggleButton.qml b/examples/quick/modelviews/listview/content/ToggleButton.qml
new file mode 100644
index 0000000000..52f4988f03
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/ToggleButton.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml 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 QtQuick 2.0
+
+Rectangle {
+ id: root
+ property alias label: text.text
+ property bool active: false
+ signal toggled
+ width: 149
+ height: 30
+ radius: 3
+ color: active ? "green" : "lightgray"
+ border.width: 1
+ Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { active = !active; root.toggled() }
+ }
+}
diff --git a/examples/quick/modelviews/listview/content/pics/arrow-down.png b/examples/quick/modelviews/listview/content/pics/arrow-down.png
new file mode 100644
index 0000000000..29d1d4439a
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/arrow-down.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/arrow-up.png b/examples/quick/modelviews/listview/content/pics/arrow-up.png
new file mode 100644
index 0000000000..e437312217
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/arrow-up.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg b/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg
new file mode 100644
index 0000000000..da5a6b10a2
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/hamburger.jpg b/examples/quick/modelviews/listview/content/pics/hamburger.jpg
new file mode 100644
index 0000000000..d0a15be1bf
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/hamburger.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/lemonade.jpg b/examples/quick/modelviews/listview/content/pics/lemonade.jpg
new file mode 100644
index 0000000000..db445c9ac8
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/lemonade.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/list-delete.png b/examples/quick/modelviews/listview/content/pics/list-delete.png
new file mode 100644
index 0000000000..df2a147d24
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/list-delete.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/minus-sign.png b/examples/quick/modelviews/listview/content/pics/minus-sign.png
new file mode 100644
index 0000000000..d6f233d739
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/minus-sign.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/moreDown.png b/examples/quick/modelviews/listview/content/pics/moreDown.png
new file mode 100644
index 0000000000..31a35d5c20
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/moreDown.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/moreUp.png b/examples/quick/modelviews/listview/content/pics/moreUp.png
new file mode 100644
index 0000000000..fefb9c9098
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/moreUp.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/pancakes.jpg b/examples/quick/modelviews/listview/content/pics/pancakes.jpg
new file mode 100644
index 0000000000..60c439638e
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/pancakes.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/plus-sign.png b/examples/quick/modelviews/listview/content/pics/plus-sign.png
new file mode 100644
index 0000000000..40df1134f8
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/plus-sign.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg
new file mode 100644
index 0000000000..9dce332041
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/dynamiclist.qml b/examples/quick/modelviews/listview/dynamiclist.qml
new file mode 100644
index 0000000000..ee7c6329bc
--- /dev/null
+++ b/examples/quick/modelviews/listview/dynamiclist.qml
@@ -0,0 +1,203 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import "content"
+
+// This example shows how items can be dynamically added to and removed from
+// a ListModel, and how these list modifications can be animated.
+
+Rectangle {
+ id: container
+ width: 500; height: 400
+ color: "#343434"
+
+ // The model:
+ ListModel {
+ id: fruitModel
+
+ ListElement {
+ name: "Apple"; cost: 2.45
+ attributes: [
+ ListElement { description: "Core" },
+ ListElement { description: "Deciduous" }
+ ]
+ }
+ ListElement {
+ name: "Banana"; cost: 1.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Seedless" }
+ ]
+ }
+ ListElement {
+ name: "Cumquat"; cost: 3.25
+ attributes: [
+ ListElement { description: "Citrus" }
+ ]
+ }
+ ListElement {
+ name: "Durian"; cost: 9.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Smelly" }
+ ]
+ }
+ }
+
+ // The delegate for each fruit in the model:
+ Component {
+ id: listDelegate
+
+ Item {
+ id: delegateItem
+ width: listView.width; height: 55
+ clip: true
+
+ Row {
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: 10
+
+ Column {
+ Image {
+ source: "content/pics/arrow-up.png"
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) }
+ }
+ Image { source: "content/pics/arrow-down.png"
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) }
+ }
+ }
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+
+ Text {
+ text: name
+ font.pixelSize: 15
+ color: "white"
+ }
+ Row {
+ spacing: 5
+ Repeater {
+ model: attributes
+ Text { text: description; color: "White" }
+ }
+ }
+ }
+ }
+
+ Row {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ spacing: 10
+
+ PressAndHoldButton {
+ anchors.verticalCenter: parent.verticalCenter
+ source: "content/pics/plus-sign.png"
+ onClicked: fruitModel.setProperty(index, "cost", cost + 0.25)
+ }
+
+ Text {
+ id: costText
+ anchors.verticalCenter: parent.verticalCenter
+ text: '$' + Number(cost).toFixed(2)
+ font.pixelSize: 15
+ color: "white"
+ font.bold: true
+ }
+
+ PressAndHoldButton {
+ anchors.verticalCenter: parent.verticalCenter
+ source: "content/pics/minus-sign.png"
+ onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25))
+ }
+
+ Image {
+ source: "content/pics/list-delete.png"
+ MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) }
+ }
+ }
+
+ // Animate adding and removing of items:
+
+ ListView.onAdd: SequentialAnimation {
+ PropertyAction { target: delegateItem; property: "height"; value: 0 }
+ NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad }
+ }
+
+ ListView.onRemove: SequentialAnimation {
+ PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true }
+ NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad }
+
+ // Make sure delayRemove is set back to false so that the item can be destroyed
+ PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false }
+ }
+ }
+ }
+
+ // The view:
+ ListView {
+ id: listView
+ anchors.fill: parent; anchors.margins: 20
+ model: fruitModel
+ delegate: listDelegate
+ }
+
+ Row {
+ anchors { left: parent.left; bottom: parent.bottom; margins: 20 }
+ spacing: 10
+
+ TextButton {
+ text: "Add an item"
+ onClicked: {
+ fruitModel.append({
+ "name": "Pizza Margarita",
+ "cost": 5.95,
+ "attributes": [{"description": "Cheese"}, {"description": "Tomato"}]
+ })
+ }
+ }
+
+ TextButton {
+ text: "Remove all items"
+ onClicked: fruitModel.clear()
+ }
+ }
+}
+
diff --git a/examples/quick/modelviews/listview/expandingdelegates.qml b/examples/quick/modelviews/listview/expandingdelegates.qml
new file mode 100644
index 0000000000..43a9662422
--- /dev/null
+++ b/examples/quick/modelviews/listview/expandingdelegates.qml
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+// This example illustrates expanding a list item to show a more detailed view.
+
+Rectangle {
+ id: page
+ width: 400; height: 240
+ color: "black"
+
+ // Delegate for the recipes. This delegate has two modes:
+ // 1. List mode (default), which just shows the picture and title of the recipe.
+ // 2. Details mode, which also shows the ingredients and method.
+ Component {
+ id: recipeDelegate
+
+ Item {
+ id: recipe
+
+ // Create a property to contain the visibility of the details.
+ // We can bind multiple element's opacity to this one property,
+ // rather than having a "PropertyChanges" line for each element we
+ // want to fade.
+ property real detailsOpacity : 0
+
+ width: listView.width
+ height: 70
+
+ // A simple rounded rectangle for the background
+ Rectangle {
+ id: background
+ x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
+ color: "ivory"
+ border.color: "orange"
+ radius: 5
+ }
+
+ // This mouse region covers the entire delegate.
+ // When clicked it changes mode to 'Details'. If we are already
+ // in Details mode, then no change will happen.
+ MouseArea {
+ anchors.fill: parent
+ onClicked: recipe.state = 'Details';
+ }
+
+ // Lay out the page: picture, title and ingredients at the top, and method at the
+ // bottom. Note that elements that should not be visible in the list
+ // mode have their opacity set to recipe.detailsOpacity.
+ Row {
+ id: topLayout
+ x: 10; y: 10; height: recipeImage.height; width: parent.width
+ spacing: 10
+
+ Image {
+ id: recipeImage
+ width: 50; height: 50
+ source: picture
+ }
+
+ Column {
+ width: background.width - recipeImage.width - 20; height: recipeImage.height
+ spacing: 5
+
+ Text {
+ text: title
+ font.bold: true; font.pointSize: 16
+ }
+
+ Text {
+ text: "Ingredients"
+ font.pointSize: 12; font.bold: true
+ opacity: recipe.detailsOpacity
+ }
+
+ Text {
+ text: ingredients
+ wrapMode: Text.WordWrap
+ width: parent.width
+ opacity: recipe.detailsOpacity
+ }
+ }
+ }
+
+ Item {
+ id: details
+ x: 10; width: parent.width - 20
+ anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 }
+ opacity: recipe.detailsOpacity
+
+ Text {
+ id: methodTitle
+ anchors.top: parent.top
+ text: "Method"
+ font.pointSize: 12; font.bold: true
+ }
+
+ Flickable {
+ id: flick
+ width: parent.width
+ anchors { top: methodTitle.bottom; bottom: parent.bottom }
+ contentHeight: methodText.height
+ clip: true
+
+ Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width }
+ }
+
+ Image {
+ anchors { right: flick.right; top: flick.top }
+ source: "content/pics/moreUp.png"
+ opacity: flick.atYBeginning ? 0 : 1
+ }
+
+ Image {
+ anchors { right: flick.right; bottom: flick.bottom }
+ source: "content/pics/moreDown.png"
+ opacity: flick.atYEnd ? 0 : 1
+ }
+ }
+
+ // A button to close the detailed view, i.e. set the state back to default ('').
+ TextButton {
+ y: 10
+ anchors { right: background.right; rightMargin: 10 }
+ opacity: recipe.detailsOpacity
+ text: "Close"
+
+ onClicked: recipe.state = '';
+ }
+
+ states: State {
+ name: "Details"
+
+ PropertyChanges { target: background; color: "white" }
+ PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger
+ PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible
+ PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view
+
+ // Move the list so that this item is at the top.
+ PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y }
+
+ // Disallow flicking while we're in detailed view
+ PropertyChanges { target: recipe.ListView.view; interactive: false }
+ }
+
+ transitions: Transition {
+ // Make the state changes smooth
+ ParallelAnimation {
+ ColorAnimation { property: "color"; duration: 500 }
+ NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" }
+ }
+ }
+ }
+ }
+
+ // The actual list
+ ListView {
+ id: listView
+ anchors.fill: parent
+ model: RecipesModel {}
+ delegate: recipeDelegate
+ }
+}
diff --git a/examples/quick/modelviews/listview/highlight.qml b/examples/quick/modelviews/listview/highlight.qml
new file mode 100644
index 0000000000..d8f76080e6
--- /dev/null
+++ b/examples/quick/modelviews/listview/highlight.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This example shows how to create your own highlight delegate for a ListView
+// that uses a SpringAnimation to provide custom movement when the
+// highlight bar is moved between items.
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 200; height: 300
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+ Component {
+ id: petDelegate
+ Item {
+ id: wrapper
+ width: 200; height: 55
+ Column {
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ }
+ // indent the item if it is the current item
+ states: State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 20 }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 200 }
+ }
+ }
+ }
+
+ // Define a highlight with customised movement between items.
+ Component {
+ id: highlightBar
+ Rectangle {
+ width: 200; height: 50
+ color: "#FFFF88"
+ y: listView.currentItem.y;
+ Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } }
+ }
+ }
+
+ ListView {
+ id: listView
+ width: 200; height: parent.height
+
+ model: PetsModel {}
+ delegate: petDelegate
+ focus: true
+
+ // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem
+ // to false so the highlight delegate can control how the highlight is moved.
+ highlight: highlightBar
+ highlightFollowsCurrentItem: false
+ }
+}
diff --git a/examples/quick/modelviews/listview/highlightranges.qml b/examples/quick/modelviews/listview/highlightranges.qml
new file mode 100644
index 0000000000..a536ddcbb2
--- /dev/null
+++ b/examples/quick/modelviews/listview/highlightranges.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: root
+ property int current: 0
+ width: 600; height: 300
+
+ // This example shows the same model in three different ListView items,
+ // with different highlight ranges. The highlight ranges are set by the
+ // preferredHighlightBegin and preferredHighlightEnd properties in ListView.
+ //
+ // The first ListView does not set a highlight range, so its currentItem
+ // can move freely within the visible area. If it moves outside the
+ // visible area, the view is automatically scrolled to keep the current
+ // item visible.
+ //
+ // The second ListView sets a highlight range which attempts to keep the
+ // current item within the the bounds of the range. However,
+ // items will not scroll beyond the beginning or end of the view,
+ // forcing the highlight to move outside the range at the ends.
+ //
+ // The third ListView sets the highlightRangeMode to StrictlyEnforceRange
+ // and sets a range smaller than the height of an item. This
+ // forces the current item to change when the view is flicked,
+ // since the highlight is unable to move.
+ //
+ // All ListViews bind their currentIndex to the root.current property.
+ // The first ListView sets root.current whenever its currentIndex changes
+ // due to keyboard interaction.
+ // Flicking the third ListView with the mouse also changes root.current.
+
+ ListView {
+ id: list1
+ width: 200; height: parent.height
+ model: PetsModel {}
+ delegate: petDelegate
+
+ highlight: Rectangle { color: "lightsteelblue" }
+ currentIndex: root.current
+ onCurrentIndexChanged: root.current = currentIndex
+ focus: true
+ }
+
+ ListView {
+ id: list2
+ x: list1.width
+ width: 200; height: parent.height
+ model: PetsModel {}
+ delegate: petDelegate
+
+ highlight: Rectangle { color: "yellow" }
+ currentIndex: root.current
+ preferredHighlightBegin: 80; preferredHighlightEnd: 220
+ highlightRangeMode: ListView.ApplyRange
+ }
+
+ ListView {
+ id: list3
+ x: list1.width + list2.width
+ width: 200; height: parent.height
+ model: PetsModel {}
+ delegate: petDelegate
+
+ highlight: Rectangle { color: "yellow" }
+ currentIndex: root.current
+ onCurrentIndexChanged: root.current = currentIndex
+ preferredHighlightBegin: 125; preferredHighlightEnd: 125
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ }
+
+ // The delegate for each list
+ Component {
+ id: petDelegate
+ Column {
+ width: 200
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ }
+ }
+}
diff --git a/examples/quick/modelviews/listview/sections.qml b/examples/quick/modelviews/listview/sections.qml
new file mode 100644
index 0000000000..2e63a86bb6
--- /dev/null
+++ b/examples/quick/modelviews/listview/sections.qml
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This example shows how a ListView can be separated into sections using
+// the ListView.section attached property.
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: container
+ width: 300
+ height: 360
+
+ ListModel {
+ id: animalsModel
+ ListElement { name: "Ant"; size: "Tiny" }
+ ListElement { name: "Flea"; size: "Tiny" }
+ ListElement { name: "Parrot"; size: "Small" }
+ ListElement { name: "Guinea pig"; size: "Small" }
+ ListElement { name: "Rat"; size: "Small" }
+ ListElement { name: "Butterfly"; size: "Small" }
+ ListElement { name: "Dog"; size: "Medium" }
+ ListElement { name: "Cat"; size: "Medium" }
+ ListElement { name: "Pony"; size: "Medium" }
+ ListElement { name: "Koala"; size: "Medium" }
+ ListElement { name: "Horse"; size: "Large" }
+ ListElement { name: "Tiger"; size: "Large" }
+ ListElement { name: "Giraffe"; size: "Large" }
+ ListElement { name: "Elephant"; size: "Huge" }
+ ListElement { name: "Whale"; size: "Huge" }
+ }
+
+//! [0]
+ // The delegate for each section header
+ Component {
+ id: sectionHeading
+ Rectangle {
+ width: container.width
+ height: childrenRect.height
+ color: "lightsteelblue"
+
+ Text {
+ text: section
+ font.bold: true
+ font.pixelSize: 20
+ }
+ }
+ }
+
+ ListView {
+ id: view
+ anchors.top: parent.top
+ anchors.bottom: buttonBar.top
+ width: parent.width
+ model: animalsModel
+ delegate: Text { text: name; font.pixelSize: 18 }
+
+ section.property: "size"
+ section.criteria: ViewSection.FullString
+ section.delegate: sectionHeading
+ }
+//! [0]
+
+ Row {
+ id: buttonBar
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 1
+ spacing: 1
+ ToggleButton {
+ label: "CurrentLabelAtStart"
+ onToggled: {
+ if (active)
+ view.section.labelPositioning |= ViewSection.CurrentLabelAtStart
+ else
+ view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart
+ }
+ }
+ ToggleButton {
+ label: "NextLabelAtEnd"
+ onToggled: {
+ if (active)
+ view.section.labelPositioning |= ViewSection.NextLabelAtEnd
+ else
+ view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/modelviews/modelviews.pro b/examples/quick/modelviews/modelviews.pro
new file mode 100644
index 0000000000..7748da0471
--- /dev/null
+++ b/examples/quick/modelviews/modelviews.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ abstractitemmodel \
+ objectlistmodel \
+ stringlistmodel
+
+
diff --git a/examples/qtquick/modelviews/modelviews.qml b/examples/quick/modelviews/modelviews.qml
index f11608bcc7..f11608bcc7 100644
--- a/examples/qtquick/modelviews/modelviews.qml
+++ b/examples/quick/modelviews/modelviews.qml
diff --git a/examples/quick/modelviews/modelviews.qmlproject b/examples/quick/modelviews/modelviews.qmlproject
new file mode 100644
index 0000000000..40f9e568fd
--- /dev/null
+++ b/examples/quick/modelviews/modelviews.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "modelviews.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/modelviews/objectlistmodel/dataobject.cpp b/examples/quick/modelviews/objectlistmodel/dataobject.cpp
new file mode 100644
index 0000000000..7216283616
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/dataobject.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include "dataobject.h"
+
+DataObject::DataObject(QObject *parent)
+ : QObject(parent)
+{
+}
+
+DataObject::DataObject(const QString &name, const QString &color, QObject *parent)
+ : QObject(parent), m_name(name), m_color(color)
+{
+}
+
+QString DataObject::name() const
+{
+ return m_name;
+}
+
+void DataObject::setName(const QString &name)
+{
+ if (name != m_name) {
+ m_name = name;
+ emit nameChanged();
+ }
+}
+
+QString DataObject::color() const
+{
+ return m_color;
+}
+
+void DataObject::setColor(const QString &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ emit colorChanged();
+ }
+}
diff --git a/examples/quick/modelviews/objectlistmodel/dataobject.h b/examples/quick/modelviews/objectlistmodel/dataobject.h
new file mode 100644
index 0000000000..bea92a273c
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/dataobject.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DATAOBJECT_H
+#define DATAOBJECT_H
+
+#include <QObject>
+
+//![0]
+class DataObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
+//![0]
+
+public:
+ DataObject(QObject *parent=0);
+ DataObject(const QString &name, const QString &color, QObject *parent=0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString color() const;
+ void setColor(const QString &color);
+
+signals:
+ void nameChanged();
+ void colorChanged();
+
+private:
+ QString m_name;
+ QString m_color;
+//![1]
+};
+//![1]
+
+#endif // DATAOBJECT_H
diff --git a/examples/quick/modelviews/objectlistmodel/main.cpp b/examples/quick/modelviews/objectlistmodel/main.cpp
new file mode 100644
index 0000000000..bb3895f7c0
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications 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 <QGuiApplication>
+
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+#include "dataobject.h"
+
+/*
+ This example illustrates exposing a QList<QObject*> as a
+ model in QML
+*/
+
+//![0]
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ QList<QObject*> dataList;
+ dataList.append(new DataObject("Item 1", "red"));
+ dataList.append(new DataObject("Item 2", "green"));
+ dataList.append(new DataObject("Item 3", "blue"));
+ dataList.append(new DataObject("Item 4", "yellow"));
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro b/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro
new file mode 100644
index 0000000000..7f323c3999
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro
@@ -0,0 +1,6 @@
+QT += qml quick
+
+SOURCES += main.cpp \
+ dataobject.cpp
+HEADERS += dataobject.h
+RESOURCES += objectlistmodel.qrc
diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc
new file mode 100644
index 0000000000..17e9301471
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>view.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/quick/modelviews/objectlistmodel/view.qml b/examples/quick/modelviews/objectlistmodel/view.qml
new file mode 100644
index 0000000000..3954e79829
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/view.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+ListView {
+ width: 100; height: 100
+
+ model: myModel
+ delegate: Rectangle {
+ height: 25
+ width: 100
+ color: model.modelData.color
+ Text { text: name }
+ }
+}
+//![0]
diff --git a/examples/quick/modelviews/package/Delegate.qml b/examples/quick/modelviews/package/Delegate.qml
new file mode 100644
index 0000000000..97c7840cb4
--- /dev/null
+++ b/examples/quick/modelviews/package/Delegate.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+Package {
+ Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' }
+ Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' }
+
+ Rectangle {
+ id: wrapper
+ width: 200; height: 25
+ color: 'lightsteelblue'
+
+ Text { text: display; anchors.centerIn: parent }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (wrapper.state == 'inList')
+ wrapper.state = 'inGrid';
+ else
+ wrapper.state = 'inList';
+ }
+ }
+
+ state: 'inList'
+ states: [
+ State {
+ name: 'inList'
+ ParentChange { target: wrapper; parent: listDelegate }
+ },
+ State {
+ name: 'inGrid'
+ ParentChange {
+ target: wrapper; parent: gridDelegate
+ x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/qtquick/modelviews/package/view.qml b/examples/quick/modelviews/package/view.qml
index 7ba6664ae2..7ba6664ae2 100644
--- a/examples/qtquick/modelviews/package/view.qml
+++ b/examples/quick/modelviews/package/view.qml
diff --git a/examples/quick/modelviews/parallax/content/Clock.qml b/examples/quick/modelviews/parallax/content/Clock.qml
new file mode 100644
index 0000000000..7f0e8cba83
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/Clock.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id : clock
+ width: {
+ if (ListView.view && ListView.view.width >= 200)
+ return ListView.view.width / Math.floor(ListView.view.width / 200.0);
+ else
+ return 200;
+ }
+
+ height: {
+ if (ListView.view && ListView.view.height >= 240)
+ return ListView.view.height;
+ else
+ return 240;
+ }
+
+ property alias city: cityLabel.text
+ property int hours
+ property int minutes
+ property int seconds
+ property real shift
+ property bool night: false
+ property bool internationalTime: true //Unset for local time
+
+ function timeChanged() {
+ var date = new Date;
+ hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
+ night = ( hours < 7 || hours > 19 )
+ minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
+ seconds = date.getUTCSeconds();
+ }
+
+ Timer {
+ interval: 100; running: true; repeat: true;
+ onTriggered: clock.timeChanged()
+ }
+
+ Item {
+ anchors.centerIn: parent
+ width: 200; height: 240
+
+ Image { id: background; source: "clock.png"; visible: clock.night == false }
+ Image { source: "clock-night.png"; visible: clock.night == true }
+
+
+ Image {
+ x: 92.5; y: 27
+ source: "hour.png"
+ smooth: true
+ transform: Rotation {
+ id: hourRotation
+ 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 }
+ }
+ }
+ }
+
+ Image {
+ x: 93.5; y: 17
+ source: "minute.png"
+ smooth: true
+ transform: Rotation {
+ id: minuteRotation
+ origin.x: 6.5; origin.y: 83;
+ angle: clock.minutes * 6
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ x: 97.5; y: 20
+ source: "second.png"
+ smooth: true
+ transform: Rotation {
+ id: secondRotation
+ origin.x: 2.5; origin.y: 80;
+ angle: clock.seconds * 6
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ anchors.centerIn: background; source: "center.png"
+ }
+
+ Text {
+ id: cityLabel
+ y: 210; anchors.horizontalCenter: parent.horizontalCenter
+ color: "white"
+ font.family: "Helvetica"
+ font.bold: true; font.pixelSize: 16
+ style: Text.Raised; styleColor: "black"
+ }
+ }
+}
diff --git a/examples/quick/modelviews/parallax/content/ParallaxView.qml b/examples/quick/modelviews/parallax/content/ParallaxView.qml
new file mode 100644
index 0000000000..2acf50dcef
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/ParallaxView.qml
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+
+ property alias background: background.source
+ property int currentIndex: 0
+ default property alias content: visualModel.children
+
+ Image {
+ id: background
+ fillMode: Image.TileHorizontally
+ x: -list.contentX / 2
+ width: Math.max(list.contentWidth, parent.width)
+ }
+
+ ListView {
+ id: list
+ anchors.fill: parent
+
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ orientation: Qt.Horizontal
+ boundsBehavior: Flickable.DragOverBounds
+ model: VisualItemModel { id: visualModel }
+
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ snapMode: ListView.SnapOneItem
+ }
+
+ ListView {
+ id: selector
+
+ height: 50
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: Math.min(count * 50, parent.width - 20)
+ interactive: width == parent.width - 20
+ orientation: Qt.Horizontal
+
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ model: visualModel.children
+ delegate: Item {
+ width: 50; height: 50
+ id: delegateRoot
+
+ Image {
+ id: image
+ source: modelData.icon
+ smooth: true
+ scale: 0.8
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { root.currentIndex = index }
+ }
+
+ states: State {
+ name: "Selected"
+ when: delegateRoot.ListView.isCurrentItem == true
+ PropertyChanges {
+ target: image
+ scale: 1
+ y: -5
+ }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "scale,y" }
+ }
+ }
+
+ Rectangle {
+ color: "#60FFFFFF"
+ x: -10; y: -10; z: -1
+ width: parent.width + 20; height: parent.height + 20
+ radius: 10
+ }
+ }
+}
diff --git a/examples/quick/modelviews/parallax/content/QuitButton.qml b/examples/quick/modelviews/parallax/content/QuitButton.qml
new file mode 100644
index 0000000000..702b892d23
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/QuitButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Image {
+ source: "quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: Qt.quit()
+ }
+}
diff --git a/examples/quick/modelviews/parallax/content/Smiley.qml b/examples/quick/modelviews/parallax/content/Smiley.qml
new file mode 100644
index 0000000000..982b6c5d2b
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/Smiley.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+// This is taken from the declarative animation/basics/property-animation.qml
+// example
+
+Item {
+ id: window
+ width: 320; height: 480
+
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: smiley.minHeight + 58
+ source: "pics/shadow.png"
+
+ scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight)
+ }
+
+ Image {
+ id: smiley
+ property int maxHeight: window.height / 3
+ property int minHeight: 2 * window.height / 3
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: minHeight
+ source: "pics/face-smile.png"
+
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+
+ NumberAnimation {
+ from: smiley.minHeight; to: smiley.maxHeight
+ easing.type: Easing.OutExpo; duration: 300
+ }
+
+ NumberAnimation {
+ from: smiley.maxHeight; to: smiley.minHeight
+ easing.type: Easing.OutBounce; duration: 1000
+ }
+
+ PauseAnimation { duration: 500 }
+ }
+ }
+}
+
diff --git a/examples/quick/modelviews/parallax/content/background.png b/examples/quick/modelviews/parallax/content/background.png
new file mode 100644
index 0000000000..a885950862
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/background.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/center.png b/examples/quick/modelviews/parallax/content/center.png
new file mode 100644
index 0000000000..7fbd802a44
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/center.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/clock-night.png b/examples/quick/modelviews/parallax/content/clock-night.png
new file mode 100644
index 0000000000..cc7151a397
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/clock-night.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/clock.png b/examples/quick/modelviews/parallax/content/clock.png
new file mode 100644
index 0000000000..462edacc0e
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/clock.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/hour.png b/examples/quick/modelviews/parallax/content/hour.png
new file mode 100644
index 0000000000..f8061a1235
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/hour.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/minute.png b/examples/quick/modelviews/parallax/content/minute.png
new file mode 100644
index 0000000000..1297ec7c2b
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/minute.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/background.jpg b/examples/quick/modelviews/parallax/content/pics/background.jpg
new file mode 100644
index 0000000000..61cca2f138
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/background.jpg
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/face-smile.png b/examples/quick/modelviews/parallax/content/pics/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/face-smile.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/home-page.png b/examples/quick/modelviews/parallax/content/pics/home-page.png
new file mode 100644
index 0000000000..bd090c3708
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/home-page.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/home-page.svg b/examples/quick/modelviews/parallax/content/pics/home-page.svg
new file mode 100644
index 0000000000..4f16958844
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/home-page.svg
@@ -0,0 +1,445 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ overflow="visible"
+ enable-background="new 0 0 128 129.396"
+ xml:space="preserve"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="go-home.svg"
+ sodipodi:docbase="/home/jimmac/src/cvs/tango-icon-theme/scalable/actions"
+ version="1.0"
+ inkscape:export-filename="/home/tigert/My Downloads/go-home.png"
+ inkscape:export-xdpi="90.000000"
+ inkscape:export-ydpi="90.000000"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata367"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" /><dc:title>Go Home</dc:title><dc:creator><cc:Agent><dc:title>Jakub Steiner</dc:title></cc:Agent></dc:creator><dc:source>http://jimmac.musichall.cz</dc:source><dc:subject><rdf:Bag><rdf:li>home</rdf:li><rdf:li>return</rdf:li><rdf:li>go</rdf:li><rdf:li>default</rdf:li><rdf:li>user</rdf:li><rdf:li>directory</rdf:li></rdf:Bag></dc:subject><dc:contributor><cc:Agent><dc:title>Tuomas Kuosmanen</dc:title></cc:Agent></dc:contributor></cc:Work><cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/"><cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" /><cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" /><cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /></cc:License></rdf:RDF></metadata><defs
+ id="defs365"><inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 24 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="48 : 24 : 1"
+ inkscape:persp3d-origin="24 : 16 : 1"
+ id="perspective92" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5060"
+ id="radialGradient5031"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
+ cx="605.71429"
+ cy="486.64789"
+ fx="605.71429"
+ fy="486.64789"
+ r="117.14286" /><linearGradient
+ inkscape:collect="always"
+ id="linearGradient5060"><stop
+ style="stop-color:black;stop-opacity:1;"
+ offset="0"
+ id="stop5062" /><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="1"
+ id="stop5064" /></linearGradient><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5060"
+ id="radialGradient5029"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.774389,0,0,1.969706,-1891.633,-872.8854)"
+ cx="605.71429"
+ cy="486.64789"
+ fx="605.71429"
+ fy="486.64789"
+ r="117.14286" /><linearGradient
+ id="linearGradient5048"><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="0"
+ id="stop5050" /><stop
+ id="stop5056"
+ offset="0.5"
+ style="stop-color:black;stop-opacity:1;" /><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="1"
+ id="stop5052" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5048"
+ id="linearGradient5027"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.774389,0,0,1.969706,-1892.179,-872.8854)"
+ x1="302.85715"
+ y1="366.64789"
+ x2="302.85715"
+ y2="609.50507" /><linearGradient
+ id="linearGradient2406"><stop
+ style="stop-color:#7c7e79;stop-opacity:1;"
+ offset="0"
+ id="stop2408" /><stop
+ id="stop2414"
+ offset="0.1724138"
+ style="stop-color:#848681;stop-opacity:1;" /><stop
+ style="stop-color:#898c86;stop-opacity:1;"
+ offset="1"
+ id="stop2410" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2390"><stop
+ style="stop-color:#919191;stop-opacity:1;"
+ offset="0"
+ id="stop2392" /><stop
+ style="stop-color:#919191;stop-opacity:0;"
+ offset="1"
+ id="stop2394" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2378"><stop
+ style="stop-color:#575757;stop-opacity:1;"
+ offset="0"
+ id="stop2380" /><stop
+ style="stop-color:#575757;stop-opacity:0;"
+ offset="1"
+ id="stop2382" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2368"><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2370" /><stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2372" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2349"><stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop2351" /><stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop2353" /></linearGradient><linearGradient
+ id="linearGradient2341"><stop
+ id="stop2343"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1;" /><stop
+ id="stop2345"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:0;" /></linearGradient><linearGradient
+ id="linearGradient2329"><stop
+ style="stop-color:#000000;stop-opacity:0.18556701;"
+ offset="0"
+ id="stop2331" /><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="1"
+ id="stop2333" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2319"><stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop2321" /><stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop2323" /></linearGradient><linearGradient
+ id="linearGradient2307"><stop
+ style="stop-color:#edd400;stop-opacity:1;"
+ offset="0"
+ id="stop2309" /><stop
+ style="stop-color:#998800;stop-opacity:1;"
+ offset="1"
+ id="stop2311" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2299"><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2301" /><stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2303" /></linearGradient><linearGradient
+ id="XMLID_2_"
+ gradientUnits="userSpaceOnUse"
+ x1="80.223602"
+ y1="117.5205"
+ x2="48.046001"
+ y2="59.7995"
+ gradientTransform="matrix(0.314683,0.000000,0.000000,0.314683,4.128264,3.742874)">
+ <stop
+ offset="0"
+ style="stop-color:#CCCCCC"
+ id="stop17" />
+ <stop
+ offset="0.9831"
+ style="stop-color:#FFFFFF"
+ id="stop19" />
+ <midPointStop
+ offset="0"
+ style="stop-color:#CCCCCC"
+ id="midPointStop48" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#CCCCCC"
+ id="midPointStop50" />
+ <midPointStop
+ offset="0.9831"
+ style="stop-color:#FFFFFF"
+ id="midPointStop52" />
+ </linearGradient><linearGradient
+ inkscape:collect="always"
+ xlink:href="#XMLID_2_"
+ id="linearGradient1514"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.336922,0.000000,0.000000,0.166888,17.98288,15.46151)"
+ x1="52.006104"
+ y1="166.1331"
+ x2="14.049017"
+ y2="-42.218513" /><linearGradient
+ id="XMLID_39_"
+ gradientUnits="userSpaceOnUse"
+ x1="64.387703"
+ y1="65.124001"
+ x2="64.387703"
+ y2="35.569"
+ gradientTransform="matrix(0.354101,0.000000,0.000000,0.354101,1.638679,-8.364921e-2)">
+ <stop
+ offset="0"
+ style="stop-color:#FFFFFF"
+ id="stop336" />
+ <stop
+ offset="0.8539"
+ style="stop-color:#FF6200"
+ id="stop338" />
+ <stop
+ offset="1"
+ style="stop-color:#F25D00"
+ id="stop340" />
+ <midPointStop
+ offset="0"
+ style="stop-color:#FFFFFF"
+ id="midPointStop335" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#FFFFFF"
+ id="midPointStop337" />
+ <midPointStop
+ offset="0.8539"
+ style="stop-color:#FF6200"
+ id="midPointStop339" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#FF6200"
+ id="midPointStop341" />
+ <midPointStop
+ offset="1"
+ style="stop-color:#F25D00"
+ id="midPointStop343" />
+ </linearGradient><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2299"
+ id="radialGradient2305"
+ cx="7.5326638"
+ cy="24.202574"
+ fx="7.5326638"
+ fy="24.202574"
+ r="8.2452128"
+ gradientTransform="matrix(4.100086,-1.627292e-17,2.125447e-14,4.201322,-25.41506,-78.53967)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2307"
+ id="radialGradient2313"
+ cx="19.985598"
+ cy="36.77816"
+ fx="19.985598"
+ fy="36.77816"
+ r="1.0821035"
+ gradientTransform="matrix(1.125263,0.000000,0.000000,0.982744,-3.428678,0.565787)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2319"
+ id="radialGradient2325"
+ cx="20.443665"
+ cy="37.425829"
+ fx="20.443665"
+ fy="37.425829"
+ r="1.0821035"
+ gradientTransform="matrix(1.125263,0.000000,0.000000,0.982744,-3.428678,0.731106)"
+ gradientUnits="userSpaceOnUse" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2329"
+ id="linearGradient2335"
+ x1="17.602522"
+ y1="26.057423"
+ x2="17.682528"
+ y2="32.654099"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.898789,0,0,1.071914,0.478025,-2.080838)" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2341"
+ id="radialGradient2339"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(4.100086,1.627292e-17,2.125447e-14,-4.201322,-5.198109,105.3535)"
+ cx="11.68129"
+ cy="19.554111"
+ fx="11.68129"
+ fy="19.554111"
+ r="8.2452126" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2349"
+ id="radialGradient2355"
+ cx="24.023088"
+ cy="40.56913"
+ fx="24.023088"
+ fy="40.56913"
+ r="16.28684"
+ gradientTransform="matrix(1.000000,0.000000,0.000000,0.431250,1.157278e-15,23.07369)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2368"
+ id="radialGradient2374"
+ cx="29.913452"
+ cy="30.442923"
+ fx="29.913452"
+ fy="30.442923"
+ r="4.0018832"
+ gradientTransform="matrix(3.751495,-2.191984e-22,1.723265e-22,3.147818,-82.00907,-65.70704)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2378"
+ id="radialGradient2384"
+ cx="24.195112"
+ cy="10.577631"
+ fx="24.195112"
+ fy="10.577631"
+ r="15.242914"
+ gradientTransform="matrix(1.125263,-3.585417e-8,4.269819e-8,1.340059,-3.006704,1.355395)"
+ gradientUnits="userSpaceOnUse" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2390"
+ id="linearGradient2396"
+ x1="30.603519"
+ y1="37.337803"
+ x2="30.603519"
+ y2="36.112415"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.263867,0,0,0.859794,-6.499556,8.390924)" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2406"
+ id="linearGradient2412"
+ x1="17.850183"
+ y1="28.939463"
+ x2="19.040216"
+ y2="41.03223"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.888785,0,0,1.08932,2.41099,-1.524336)" /></defs><sodipodi:namedview
+ inkscape:cy="-2.3755359"
+ inkscape:cx="25.234802"
+ inkscape:zoom="1"
+ inkscape:window-height="691"
+ inkscape:window-width="872"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ borderopacity="0.21568627"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:showpageshadow="false"
+ inkscape:window-x="466"
+ inkscape:window-y="157"
+ inkscape:current-layer="svg2"
+ fill="#555753"
+ showgrid="false"
+ stroke="#a40000"
+ showguides="true"
+ inkscape:guide-bbox="true" />
+ <g
+ style="display:inline"
+ id="g5022"
+ transform="matrix(2.158196e-2,0,0,1.859457e-2,43.12251,41.63767)"><rect
+ y="-150.69685"
+ x="-1559.2523"
+ height="478.35718"
+ width="1339.6335"
+ id="rect4173"
+ style="opacity:0.40206185;color:black;fill:url(#linearGradient5027);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:nodetypes="cccc"
+ id="path5058"
+ d="M -219.61876,-150.68038 C -219.61876,-150.68038 -219.61876,327.65041 -219.61876,327.65041 C -76.744594,328.55086 125.78146,220.48075 125.78138,88.454235 C 125.78138,-43.572302 -33.655436,-150.68036 -219.61876,-150.68038 z "
+ style="opacity:0.40206185;color:black;fill:url(#radialGradient5029);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:0.40206185;color:black;fill:url(#radialGradient5031);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M -1559.2523,-150.68038 C -1559.2523,-150.68038 -1559.2523,327.65041 -1559.2523,327.65041 C -1702.1265,328.55086 -1904.6525,220.48075 -1904.6525,88.454235 C -1904.6525,-43.572302 -1745.2157,-150.68036 -1559.2523,-150.68038 z "
+ id="path5018"
+ sodipodi:nodetypes="cccc" /></g><path
+ style="color:#000000;fill:url(#linearGradient1514);fill-opacity:1;fill-rule:nonzero;stroke:#757575;stroke-width:1.0000006;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 21.619576,8.1833733 L 27.577035,8.1833733 C 28.416767,8.1833733 41.46351,23.618701 41.46351,24.524032 L 41.019989,43.020777 C 41.019989,43.92611 40.343959,44.654954 39.504227,44.654954 L 8.0469496,44.654954 C 7.2072167,44.654954 6.5311871,43.92611 6.5311871,43.020777 L 6.5876651,24.524032 C 6.5876651,23.618701 20.779844,8.1833733 21.619576,8.1833733 z "
+ id="rect1512"
+ sodipodi:nodetypes="ccccccccc" /><path
+ style="fill:none"
+ id="path5"
+ d="M 46.963575,45.735573 L 1.6386762,45.735573 L 1.6386762,0.41067554 L 46.963575,0.41067554 L 46.963575,45.735573 z " /><path
+ style="fill:url(#linearGradient2335);fill-opacity:1;fill-rule:evenodd"
+ id="path2327"
+ d="M 23,29 L 22.954256,44.090942 L 11.111465,44.090942 L 11,29 L 23,29 z "
+ clip-rule="evenodd"
+ sodipodi:nodetypes="ccccc" /><path
+ sodipodi:nodetypes="ccccccccc"
+ id="path2357"
+ d="M 21.780459,9.405584 L 27.339556,9.405584 C 28.123138,9.405584 40.340425,23.805172 40.340425,24.649756 L 39.993267,42.862067 C 39.993267,43.321326 39.84953,43.515532 39.480892,43.515532 L 8.0936894,43.529812 C 7.7250517,43.529812 7.5097258,43.449894 7.5097258,43.076262 L 7.7250676,24.649756 C 7.7250676,23.805172 20.99688,9.405584 21.780459,9.405584 z "
+ style="opacity:0.3125;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.00000012;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ clip-rule="evenodd"
+ d="M 7.2075295,27.943053 L 7.1532728,30.538247 L 25.521437,17.358993 L 40.807832,28.513421 L 40.879142,28.201707 L 24.508686,12.297576 L 7.2075295,27.943053 z "
+ id="path23"
+ style="opacity:0.2;fill:url(#radialGradient2384);fill-opacity:1;fill-rule:evenodd"
+ sodipodi:nodetypes="ccccccc" /><path
+ clip-rule="evenodd"
+ d="M 22,30 L 22,44.090942 L 12.188971,44.090942 L 12,30 L 22,30 z "
+ id="path188"
+ style="fill:url(#linearGradient2412);fill-opacity:1;fill-rule:evenodd"
+ sodipodi:nodetypes="ccccc" /><path
+ style="opacity:0.40909089;fill:url(#radialGradient2325);fill-opacity:1;fill-rule:evenodd"
+ id="path2315"
+ d="M 19.576856,36.44767 C 20.249646,36.44767 20.793472,36.922275 20.793472,37.506177 C 20.793472,38.095988 20.249646,38.574532 19.576856,38.574532 C 18.904584,38.574532 18.35817,38.095988 18.35817,37.506177 C 18.358685,36.922275 18.904584,36.44767 19.576856,36.44767 z "
+ clip-rule="evenodd" /><path
+ clip-rule="evenodd"
+ d="M 19.462314,35.932229 C 20.135103,35.932229 20.678929,36.406834 20.678929,36.990736 C 20.678929,37.580545 20.135103,38.059089 19.462314,38.059089 C 18.790041,38.059089 18.243627,37.580545 18.243627,36.990736 C 18.244142,36.406834 18.790041,35.932229 19.462314,35.932229 z "
+ id="path217"
+ style="fill:url(#radialGradient2313);fill-opacity:1;fill-rule:evenodd" /><path
+ d="M 24.447748,11.559337 L 43.374808,28.729205 L 43.869487,29.121196 L 44.273163,28.949811 L 43.900293,28.188138 L 43.622679,27.964702 L 24.447748,12.392396 L 5.0582327,28.135731 L 4.8206309,28.279851 L 4.603921,28.986637 L 5.0373408,29.115885 L 5.4218948,28.807462 L 24.447748,11.559337 z "
+ id="path342"
+ style="fill:url(#XMLID_39_)"
+ sodipodi:nodetypes="ccccccccccccc" /><path
+ style="fill:#ef2929;stroke:#a40000"
+ id="path362"
+ d="M 24.330168,2.2713382 L 2.4484294,20.372675 L 1.8237005,27.538603 L 3.8236367,29.602926 C 3.8236367,29.602926 24.231018,12.445641 24.44773,12.274963 L 44.08027,29.818223 L 45.978694,27.494226 L 44.362903,20.382852 L 24.44773,2.1668788 L 24.330168,2.2713382 z "
+ sodipodi:nodetypes="cccccccccc" />
+<path
+ style="opacity:0.40909089;color:#000000;fill:url(#radialGradient2305);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 2.8413446,20.613129 L 2.5497894,27.236494 L 24.369219,8.980075 L 24.298891,3.0867443 L 2.8413446,20.613129 z "
+ id="path1536"
+ sodipodi:nodetypes="ccccc" /><path
+ sodipodi:nodetypes="ccccc"
+ id="path2337"
+ d="M 24.483763,8.7509884 L 24.583223,2.9098867 L 43.912186,20.56184 L 45.403998,27.062652 L 24.483763,8.7509884 z "
+ style="opacity:0.13636367;color:#000000;fill:url(#radialGradient2339);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:0.31818183;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.99999934;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 27.102228,27.719824 L 36.142223,27.719824 C 36.912818,27.719824 37.53319,28.340194 37.53319,29.110791 L 37.525229,38.190012 C 37.525229,38.960608 36.928907,39.455981 36.158311,39.455981 L 27.102228,39.455981 C 26.331631,39.455981 25.711261,38.835608 25.711261,38.065012 L 25.711261,29.110791 C 25.711261,28.340194 26.331631,27.719824 27.102228,27.719824 z "
+ id="rect2361"
+ sodipodi:nodetypes="ccccccccc" /><rect
+ style="opacity:1;color:#000000;fill:#3465a4;fill-opacity:1;fill-rule:nonzero;stroke:#757575;stroke-width:0.9999994;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="rect3263"
+ width="10.001333"
+ height="9.9624557"
+ x="26.507767"
+ y="28.514256"
+ rx="0.38128215"
+ ry="0.38128215" /><path
+ style="opacity:0.39772728;color:#000000;fill:url(#radialGradient2374);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999958;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 27.107118,34.408261 C 30.725101,34.739438 32.634842,32.962557 35.97527,32.855521 L 36,29.00603 L 27.088388,29 L 27.107118,34.408261 z "
+ id="rect2363"
+ sodipodi:nodetypes="ccccc" /></svg> \ No newline at end of file
diff --git a/examples/quick/modelviews/parallax/content/pics/shadow.png b/examples/quick/modelviews/parallax/content/pics/shadow.png
new file mode 100644
index 0000000000..8270565e87
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/shadow.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/yast-joystick.png b/examples/quick/modelviews/parallax/content/pics/yast-joystick.png
new file mode 100644
index 0000000000..858cea0301
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/yast-joystick.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/yast-wol.png b/examples/quick/modelviews/parallax/content/pics/yast-wol.png
new file mode 100644
index 0000000000..7712180a3b
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/yast-wol.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/quit.png b/examples/quick/modelviews/parallax/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/quit.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/second.png b/examples/quick/modelviews/parallax/content/second.png
new file mode 100644
index 0000000000..4aa9fb5e8e
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/second.png
Binary files differ
diff --git a/examples/qtquick/modelviews/parallax/parallax.qml b/examples/quick/modelviews/parallax/parallax.qml
index 30578e510e..30578e510e 100644
--- a/examples/qtquick/modelviews/parallax/parallax.qml
+++ b/examples/quick/modelviews/parallax/parallax.qml
diff --git a/examples/quick/modelviews/pathview/pathview-example.qml b/examples/quick/modelviews/pathview/pathview-example.qml
new file mode 100644
index 0000000000..6161343830
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pathview-example.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 400; height: 240
+ color: "white"
+
+ ListModel {
+ id: appModel
+ ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" }
+ ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" }
+ ListElement { name: "Camera"; icon: "pics/Camera_48.png" }
+ ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" }
+ ListElement { name: "Messaging"; icon: "pics/EMail_48.png" }
+ ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" }
+ ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" }
+ }
+
+ Component {
+ id: appDelegate
+ Item {
+ width: 100; height: 100
+ scale: PathView.iconScale
+
+ Image {
+ id: myIcon
+ y: 20; anchors.horizontalCenter: parent.horizontalCenter
+ source: icon
+ smooth: true
+ }
+ Text {
+ anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter }
+ text: name
+ smooth: true
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: view.currentIndex = index
+ }
+ }
+ }
+
+ Component {
+ id: appHighlight
+ Rectangle { width: 80; height: 80; color: "lightsteelblue" }
+ }
+
+ PathView {
+ id: view
+ anchors.fill: parent
+ highlight: appHighlight
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ focus: true
+ model: appModel
+ delegate: appDelegate
+ path: Path {
+ startX: 10
+ startY: 50
+ PathAttribute { name: "iconScale"; value: 0.5 }
+ PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 }
+ PathAttribute { name: "iconScale"; value: 1.0 }
+ PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 }
+ PathAttribute { name: "iconScale"; value: 0.5 }
+ }
+ }
+}
diff --git a/examples/quick/modelviews/pathview/pics/AddressBook_48.png b/examples/quick/modelviews/pathview/pics/AddressBook_48.png
new file mode 100644
index 0000000000..1ab7c8eec1
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/AddressBook_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png b/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png
new file mode 100644
index 0000000000..f4b8689f87
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/Camera_48.png b/examples/quick/modelviews/pathview/pics/Camera_48.png
new file mode 100644
index 0000000000..c76b524945
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/Camera_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/DateBook_48.png b/examples/quick/modelviews/pathview/pics/DateBook_48.png
new file mode 100644
index 0000000000..58f5787fb8
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/DateBook_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/EMail_48.png b/examples/quick/modelviews/pathview/pics/EMail_48.png
new file mode 100644
index 0000000000..d6d84a61be
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/EMail_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/TodoList_48.png b/examples/quick/modelviews/pathview/pics/TodoList_48.png
new file mode 100644
index 0000000000..0988448d9b
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/TodoList_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png b/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png
new file mode 100644
index 0000000000..52638c50a7
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png
Binary files differ
diff --git a/examples/quick/modelviews/stringlistmodel/main.cpp b/examples/quick/modelviews/stringlistmodel/main.cpp
new file mode 100644
index 0000000000..12859316a3
--- /dev/null
+++ b/examples/quick/modelviews/stringlistmodel/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications 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 <QGuiApplication>
+#include <QStringList>
+
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+
+/*
+ This example illustrates exposing a QStringList as a
+ model in QML
+*/
+
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+//![0]
+ QStringList dataList;
+ dataList.append("Item 1");
+ dataList.append("Item 2");
+ dataList.append("Item 3");
+ dataList.append("Item 4");
+
+ QQuickView view;
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro b/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro
new file mode 100644
index 0000000000..19e62cd1b7
--- /dev/null
+++ b/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro
@@ -0,0 +1,4 @@
+QT += qml quick
+
+SOURCES += main.cpp
+RESOURCES += stringlistmodel.qrc
diff --git a/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc
new file mode 100644
index 0000000000..17e9301471
--- /dev/null
+++ b/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>view.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/quick/modelviews/stringlistmodel/view.qml b/examples/quick/modelviews/stringlistmodel/view.qml
new file mode 100644
index 0000000000..945763c295
--- /dev/null
+++ b/examples/quick/modelviews/stringlistmodel/view.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//![0]
+
+ListView {
+ width: 100; height: 100
+
+ model: myModel
+ delegate: Rectangle {
+ height: 25
+ width: 100
+ Text { text: modelData }
+ }
+}
+//![0]
diff --git a/examples/quick/modelviews/visualdatamodel/dragselection.qml b/examples/quick/modelviews/visualdatamodel/dragselection.qml
new file mode 100644
index 0000000000..c3186a5ad8
--- /dev/null
+++ b/examples/quick/modelviews/visualdatamodel/dragselection.qml
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+
+ width: 320
+ height: 480
+
+ property bool dragging: false
+
+ Component {
+ id: packageDelegate
+ Package {
+ id: packageRoot
+
+ MouseArea {
+ id: visibleContainer
+ Package.name: "visible"
+
+ width: 64
+ height: 64
+ enabled: packageRoot.VisualDataModel.inSelected
+
+ drag.target: draggable
+
+ Item {
+ id: draggable
+
+ width: 64
+ height: 64
+
+ Drag.active: visibleContainer.drag.active
+
+ anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }
+
+ states: State {
+ when: visibleContainer.drag.active
+ AnchorChanges { target: draggable; anchors { horizontalCenter: undefined; verticalCenter: undefined} }
+ ParentChange { target: selectionView; parent: draggable; x: 0; y: 0 }
+ PropertyChanges { target: root; dragging: true }
+ ParentChange { target: draggable; parent: root }
+ }
+ }
+ DropArea {
+ anchors.fill: parent
+ onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.VisualDataModel.itemsIndex), selectedItems.count)
+ }
+ }
+ Item {
+ id: selectionContainer
+ Package.name: "selection"
+
+ width: 64
+ height: 64
+
+ visible: PathView.onPath
+ }
+ Rectangle {
+ id: content
+ parent: visibleContainer
+
+ width: 58
+ height: 58
+
+ radius: 8
+
+ gradient: Gradient {
+ GradientStop { id: gradientStart; position: 0.0; color: "#8AC953" }
+ GradientStop { id: gradientEnd; position: 1.0; color: "#8BC953" }
+ }
+
+ border.width: 2
+ border.color: "#007423"
+
+ state: root.dragging && packageRoot.VisualDataModel.inSelected ? "selected" : "visible"
+
+ Text {
+ anchors.fill: parent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "white"
+ text: modelData
+ font.pixelSize: 18
+ }
+
+ Rectangle {
+ anchors { right: parent.right; top: parent.top; margins: 3 }
+ width: 12; height: 12
+ color: packageRoot.VisualDataModel.inSelected ? "black" : "white"
+ radius: 6
+
+ border.color: "white"
+ border.width: 2
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: packageRoot.VisualDataModel.inSelected = !packageRoot.VisualDataModel.inSelected
+ }
+ }
+
+ states: [
+ State {
+ name: "selected"
+ ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 }
+ PropertyChanges { target: packageRoot; VisualDataModel.inItems: visibleContainer.drag.active }
+ PropertyChanges { target: gradientStart; color: "#017423" }
+ PropertyChanges { target: gradientStart; color: "#007423" }
+ }, State {
+ name: "visible"
+ PropertyChanges { target: packageRoot; VisualDataModel.inItems: true }
+ ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 }
+ PropertyChanges { target: gradientStart; color: "#8AC953" }
+ PropertyChanges { target: gradientStart; color: "#8BC953" }
+ }
+ ]
+ transitions: Transition {
+ PropertyAction { target: packageRoot; properties: "VisualDataModel.inItems" }
+ ParentAnimation {
+ target: content
+ NumberAnimation { target: content; properties: "x,y"; duration: 500 }
+ }
+ ColorAnimation { targets: [gradientStart, gradientEnd]; duration: 500 }
+ }
+ }
+ }
+ }
+
+ VisualDataModel {
+ id: visualModel
+ model: 35
+ delegate: packageDelegate
+
+ groups: VisualDataGroup { id: selectedItems; name: "selected" }
+
+ Component.onCompleted: parts.selection.filterOnGroup = "selected"
+ }
+
+ PathView {
+ id: selectionView
+
+ height: 64
+ width: 64
+
+ model: visualModel.parts.selection
+
+ path: Path {
+ startX: 0
+ startY: 0
+ PathLine { x: 64; y: 64 }
+ }
+ }
+
+ GridView {
+ id: itemsView
+ anchors { fill: parent }
+ cellWidth: 64
+ cellHeight: 64
+ model: visualModel.parts.visible
+ }
+}
diff --git a/examples/quick/modelviews/visualdatamodel/slideshow.qml b/examples/quick/modelviews/visualdatamodel/slideshow.qml
new file mode 100644
index 0000000000..040c6be307
--- /dev/null
+++ b/examples/quick/modelviews/visualdatamodel/slideshow.qml
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Rectangle {
+ id: root
+
+ property Item displayItem: null
+
+ width: 300; height: 400
+
+ color: "black"
+
+ VisualDataModel {
+ id: visualModel
+
+ model: XmlListModel {
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2"
+ query: "/rss/channel/item"
+ namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
+
+ XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" }
+ XmlRole { name: "url"; query: "media:content/@url/string()" }
+ }
+
+ delegate: Item {
+ id: delegateItem
+
+ width: 76; height: 76
+
+ Rectangle {
+ id: image
+ x: 0; y: 0; width: 76; height: 76
+ border.width: 1
+ border.color: "white"
+ color: "black"
+
+ Image {
+ anchors.fill: parent
+ anchors.leftMargin: 1
+ anchors.topMargin: 1
+
+ source: imagePath
+ fillMode: Image.PreserveAspectFit
+
+ }
+
+ MouseArea {
+ id: clickArea
+ anchors.fill: parent
+
+ onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null
+ }
+
+ states: [
+ State {
+ when: root.displayItem === delegateItem
+ name: "inDisplay";
+ ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 }
+ PropertyChanges { target: image; z: 2 }
+ PropertyChanges { target: delegateItem; VisualDataModel.inItems: false }
+ },
+ State {
+ when: root.displayItem !== delegateItem
+ name: "inList";
+ ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 }
+ PropertyChanges { target: image; z: 1 }
+ PropertyChanges { target: delegateItem; VisualDataModel.inItems: true }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "inList"
+ SequentialAnimation {
+ PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: true }
+ ParentAnimation {
+ target: image;
+ via: root
+ NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 }
+ }
+ }
+ }, Transition {
+ from: "inDisplay"
+ SequentialAnimation {
+ ParentAnimation {
+ target: image
+ NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 }
+ }
+ PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: false }
+ }
+ }
+ ]
+ }
+ }
+ }
+
+
+ PathView {
+ id: imagePath
+
+ anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom }
+ model: visualModel
+
+ pathItemCount: 7
+ path: Path {
+ startX: -50; startY: 0
+ PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 }
+ PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 }
+ }
+ }
+
+ Item {
+ id: imageContainer
+ anchors { fill: parent; bottomMargin: 100 }
+ }
+}
diff --git a/examples/quick/modelviews/visualdatamodel/sortedmodel.qml b/examples/quick/modelviews/visualdatamodel/sortedmodel.qml
new file mode 100644
index 0000000000..8d3b0a58e5
--- /dev/null
+++ b/examples/quick/modelviews/visualdatamodel/sortedmodel.qml
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 480; height: 640
+
+ Component {
+ id: numberDelegate
+
+ Text {
+ id: numberText
+ anchors { left: parent.left; right: parent.right }
+ text: number
+
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 18
+
+ Text {
+ anchors { left: parent.left; baseline: parent.baseline }
+ text: index
+
+ horizontalAlignment: Text.AlignLeft
+ font.pixelSize: 12
+ }
+ Text {
+ anchors { right: parent.right; baseline: parent.baseline }
+ text: numberText.VisualDataModel.itemsIndex
+
+ horizontalAlignment: Text.AlignRight
+ font.pixelSize: 12
+ }
+ }
+ }
+
+ ListView {
+ anchors {
+ left: parent.left; top: parent.top;
+ right: parent.horizontalCenter; bottom: button.top
+ leftMargin: 2; topMargin: 2; rightMargin: 1; bottomMargin: 2
+ }
+
+ model: ListModel {
+ id: unsortedModel
+ }
+ delegate: numberDelegate
+ }
+ ListView {
+ anchors {
+ left: parent.horizontalCenter; top: parent.top;
+ right: parent.right; bottom: button.top
+ leftMargin: 1; topMargin: 2; rightMargin: 2; bottomMargin: 2
+ }
+ model: VisualDataModel {
+ model: unsortedModel
+ delegate: numberDelegate
+
+ items.onChanged: {
+ for (var i = 0; i < inserted.length; ++i) {
+ for (var j = inserted[i].index; j < inserted[i].index + inserted[i].count; ++j) {
+ var number = items.get(j).model.number
+ for (var l = 0, k = 0; l < unsortedModel.count; ++l) {
+ if (l == inserted[k].index) {
+ l += inserted[k].count - 1
+ ++k
+ } else if (number < items.get(l).model.number) {
+ items.move(j, l, 1)
+ break
+ }
+ }
+ inserted[i].index += 1;
+ inserted[i].count -= 1;
+ }
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: button
+
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 }
+ height: moreText.implicitHeight + 4
+
+ color: "black"
+
+ Text {
+ id: moreText
+
+ anchors.fill: parent
+ text: "More"
+ color: "white"
+ font.pixelSize: 18
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: unsortedModel.append({ "number": Math.floor(Math.random() * 100) })
+ }
+ }
+}
diff --git a/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml b/examples/quick/modelviews/visualitemmodel/visualitemmodel.qml
index 2e012adec6..2e012adec6 100644
--- a/examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml
+++ b/examples/quick/modelviews/visualitemmodel/visualitemmodel.qml
diff --git a/examples/quick/mousearea/mousearea-example.qml b/examples/quick/mousearea/mousearea-example.qml
new file mode 100644
index 0000000000..30e3e62864
--- /dev/null
+++ b/examples/quick/mousearea/mousearea-example.qml
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: box
+ width: 400; height: 300
+
+ Rectangle {
+ id: redSquare
+ width: 120; height: 120
+ anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10
+ color: "red"
+
+ Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ property string buttonID
+
+ acceptedButtons: Qt.AllButtons
+ // Value 'All.Buttons' is eqivalent to:
+ // 'Qt::LeftButton | Qt::RightButton | Qt::MiddleButton .... | Qt::ExtraButton24'
+
+ onEntered: info.text = 'Entered'
+ onExited: info.text = 'Exited (pressed=' + pressed + ')'
+
+ onPressed: {
+ if (mouse.button == Qt.LeftButton)
+ buttonID = 'LeftButton'
+ else if (mouse.button == Qt.RightButton)
+ buttonID = 'RightButton'
+ else if (mouse.button == Qt.MidButton)
+ buttonID = 'MiddleButton'
+ else if (mouse.button == Qt.BackButton)
+ buttonID = 'BackButton'
+ else if (mouse.button == Qt.ForwardButton)
+ buttonID = 'ForwardButton'
+ else if (mouse.button == Qt.TaskButton)
+ buttonID = 'TaskButton'
+ else if (mouse.button == Qt.ExtraButton4)
+ buttonID = 'ExtraButton4'
+ else if (mouse.button == Qt.ExtraButton5)
+ buttonID = 'ExtraButton5'
+ else if (mouse.button == Qt.ExtraButton6)
+ buttonID = 'ExtraButton6'
+ else if (mouse.button == Qt.ExtraButton7)
+ buttonID = 'ExtraButton7'
+ else if (mouse.button == Qt.ExtraButton8)
+ buttonID = 'ExtraButton8'
+ else if (mouse.button == Qt.ExtraButton9)
+ buttonID = 'ExtraButton9'
+ else if (mouse.button == Qt.ExtraButton10)
+ buttonID = 'ExtraButton10'
+ else if (mouse.button == Qt.ExtraButton11)
+ buttonID = 'ExtraButton11'
+ else if (mouse.button == Qt.ExtraButton12)
+ buttonID = 'ExtraButton12'
+ else if (mouse.button == Qt.ExtraButton13)
+ buttonID = 'ExtraButton13'
+ else if (mouse.button == Qt.ExtraButton14)
+ buttonID = 'ExtraButton14'
+ else if (mouse.button == Qt.ExtraButton15)
+ buttonID = 'ExtraButton15'
+ else if (mouse.button == Qt.ExtraButton16)
+ buttonID = 'ExtraButton16'
+ else if (mouse.button == Qt.ExtraButton17)
+ buttonID = 'ExtraButton17'
+ else if (mouse.button == Qt.ExtraButton18)
+ buttonID = 'ExtraButton18'
+ else if (mouse.button == Qt.ExtraButton19)
+ buttonID = 'ExtraButton19'
+ else if (mouse.button == Qt.ExtraButton20)
+ buttonID = 'ExtraButton20'
+ else if (mouse.button == Qt.ExtraButton21)
+ buttonID = 'ExtraButton21'
+ else if (mouse.button == Qt.ExtraButton22)
+ buttonID = 'ExtraButton22'
+ else if (mouse.button == Qt.ExtraButton23)
+ buttonID = 'ExtraButton23'
+ else if (mouse.button == Qt.ExtraButton24)
+ buttonID = 'ExtraButton24'
+
+ info.text = 'Pressed (' + buttonID + ' shift='
+ + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')'
+ var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y)
+ posInfo.text = + mouse.x + ',' + mouse.y + ' in square'
+ + ' (' + posInBox.x + ',' + posInBox.y + ' in window)'
+ }
+
+ onReleased: {
+ btn.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')'
+ posInfo.text = ''
+ }
+
+ onPressAndHold: btn.text = 'Press and hold'
+ onClicked: btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')'
+ onDoubleClicked: btn.text = 'Double clicked'
+ }
+ }
+
+ Rectangle {
+ id: blueSquare
+ width: 120; height: 120
+ x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors
+ color: "blue"
+
+ Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: blueSquare
+ drag.axis: Drag.XandYAxis
+ drag.minimumX: 0
+ drag.maximumX: box.width - parent.width
+ drag.minimumY: 0
+ drag.maximumY: box.height - parent.width
+ }
+ }
+
+ Text {
+ id: info
+ anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20
+
+ onTextChanged: console.log(text)
+ }
+
+ Text {
+ id: btn
+ anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20
+ }
+
+ Text {
+ id: posInfo
+ anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20
+ }
+}
diff --git a/examples/quick/openglunderqml/main.cpp b/examples/quick/openglunderqml/main.cpp
new file mode 100644
index 0000000000..3b682deaec
--- /dev/null
+++ b/examples/quick/openglunderqml/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+
+#include <QtQuick/QQuickView>
+
+#include "squircle.h"
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<Squircle>("QtQuick", 2, 0, "Squircle");
+
+ QQuickView view;
+ view.setSource(QUrl("main.qml"));
+ view.show();
+
+ return app.exec();
+
+}
diff --git a/examples/quick/openglunderqml/main.qml b/examples/quick/openglunderqml/main.qml
new file mode 100644
index 0000000000..1485cbbdb8
--- /dev/null
+++ b/examples/quick/openglunderqml/main.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+
+ width: 400
+ height: 300
+
+ Squircle {
+ SequentialAnimation on t {
+ NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
+ NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
+ loops: Animation.Infinite
+ running: true
+ }
+ }
+
+ Rectangle {
+ color: Qt.rgba(1, 1, 1, 0.8);
+ radius: 10
+ border.width: 1
+ border.color: "white"
+ anchors.fill: label
+ anchors.margins: -10
+ }
+
+ Text {
+ id: label
+ color: "black"
+ wrapMode: Text.WordWrap
+ text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickCanvas. This text label and its border is rendered using QML"
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ anchors.margins: 20
+ }
+
+}
diff --git a/examples/quick/openglunderqml/openglunderqml.pro b/examples/quick/openglunderqml/openglunderqml.pro
new file mode 100644
index 0000000000..64a58b3729
--- /dev/null
+++ b/examples/quick/openglunderqml/openglunderqml.pro
@@ -0,0 +1,6 @@
+QT += qml quick
+
+HEADERS += squircle.h
+SOURCES += squircle.cpp main.cpp
+
+OTHER_FILES += main.qml
diff --git a/examples/quick/openglunderqml/squircle.cpp b/examples/quick/openglunderqml/squircle.cpp
new file mode 100644
index 0000000000..b56f0baaf6
--- /dev/null
+++ b/examples/quick/openglunderqml/squircle.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "squircle.h"
+
+#include <QtQuick/qsgengine.h>
+#include <QtQuick/qquickcanvas.h>
+#include <QOpenGLShaderProgram>
+
+Squircle::Squircle()
+ : m_program(0)
+{
+ setFlag(ItemHasContents);
+}
+
+void Squircle::itemChange(ItemChange change, const ItemChangeData &)
+{
+ // The ItemSceneChange event is sent when we are first attached to a canvas.
+ if (change == ItemSceneChange) {
+ QQuickCanvas *c = canvas();
+
+ // Connect our the beforeRendering signal to our paint function.
+ // Since this call is executed on the rendering thread it must be
+ // a Qt::DirectConnection
+ connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
+
+ // If we allow QML to do the clearing, they would clear what we paint
+ // and nothing would show.
+ c->setClearBeforeRendering(false);
+ }
+}
+
+
+void Squircle::paint()
+{
+ if (!m_program) {
+ m_program = new QOpenGLShaderProgram();
+ m_program->addShaderFromSourceCode(QOpenGLShader::Vertex,
+ "attribute highp vec4 vertices;"
+ "varying highp vec2 coords;"
+ "void main() {"
+ " gl_Position = vertices;"
+ " coords = vertices.xy;"
+ "}");
+ m_program->addShaderFromSourceCode(QOpenGLShader::Fragment,
+ "uniform lowp float t;"
+ "varying highp vec2 coords;"
+ "void main() {"
+ " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));"
+ " i = smoothstep(t - 0.3, t + 0.3, i);"
+ " gl_FragColor = vec4(coords / 2. + .5, i, i);"
+ "}");
+
+ m_program->bindAttributeLocation("vertices", 0);
+ m_program->link();
+ }
+
+ m_program->bind();
+
+ m_program->enableAttributeArray(0);
+
+ float values[] = {
+ -1, -1,
+ 1, -1,
+ -1, 1,
+ 1, 1
+ };
+ m_program->setAttributeArray(0, GL_FLOAT, values, 2);
+ m_program->setUniformValue("t", (float) m_t);
+
+ glDisable(GL_DEPTH_TEST);
+
+ glClearColor(0, 0, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ m_program->disableAttributeArray(0);
+ m_program->release();
+}
+
+
diff --git a/examples/quick/openglunderqml/squircle.h b/examples/quick/openglunderqml/squircle.h
new file mode 100644
index 0000000000..283131a662
--- /dev/null
+++ b/examples/quick/openglunderqml/squircle.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SQUIRCLE_H
+#define SQUIRCLE_H
+
+#include <QtQuick/QQuickItem>
+#include <QtGui/QOpenGLShaderProgram>
+
+class Squircle : public QQuickItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
+
+public:
+ Squircle();
+
+ qreal t() const { return m_t; }
+ void setT(qreal t) { m_t = t; emit tChanged(); }
+
+ void itemChange(ItemChange change, const ItemChangeData &);
+
+signals:
+ void tChanged();
+
+public slots:
+ void paint();
+
+private:
+ QOpenGLShaderProgram *m_program;
+
+ qreal m_t;
+ bool m_render_under;
+ bool m_render_over;
+};
+
+#endif // SQUIRCLE_H
diff --git a/examples/quick/painteditem/painteditem.pro b/examples/quick/painteditem/painteditem.pro
new file mode 100644
index 0000000000..e3afd6b0f0
--- /dev/null
+++ b/examples/quick/painteditem/painteditem.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS = \
+ smile \
+ textballoons
diff --git a/examples/quick/painteditem/smile/main.cpp b/examples/quick/painteditem/smile/main.cpp
new file mode 100644
index 0000000000..1c7888b10b
--- /dev/null
+++ b/examples/quick/painteditem/smile/main.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QPainter>
+#include <QtQml/qqml.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickpainteditem.h>
+class MyPaintItem : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged)
+public:
+ MyPaintItem()
+ : QQuickPaintedItem()
+ , m_face(QLatin1String(":-)"))
+ {
+ setAntialiasing(true);
+ }
+ QString face() const {return m_face;}
+ void setFace(const QString &face) {
+ if (m_face != face) {
+ m_face = face;
+ emit faceChanged();
+ }
+ }
+ virtual void paint(QPainter *p)
+ {
+ QRectF rect(0, 0, width(), height());
+ rect.adjust(10, 10, -10, -10);
+ p->setPen(QPen(Qt::black, 20));
+ p->setBrush(Qt::yellow);
+ p->drawEllipse(rect);
+ p->setPen(Qt::black);
+ p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2)));
+ p->drawText(rect, Qt::AlignCenter, m_face);
+ }
+signals:
+ void faceChanged();
+private:
+ QString m_face;
+};
+
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<MyPaintItem>("MyModule", 1, 0, "MyPaintItem");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("smile.qml"));
+ view.show();
+ view.raise();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/examples/quick/painteditem/smile/smile.pro b/examples/quick/painteditem/smile/smile.pro
new file mode 100644
index 0000000000..b1af4ee0ad
--- /dev/null
+++ b/examples/quick/painteditem/smile/smile.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = painteditem
+
+QT += qml quick
+
+macx: CONFIG -= app_bundle
+
+SOURCES += main.cpp
+
+CONFIG += console
+
diff --git a/examples/quick/painteditem/smile/smile.qml b/examples/quick/painteditem/smile/smile.qml
new file mode 100644
index 0000000000..33919bc04f
--- /dev/null
+++ b/examples/quick/painteditem/smile/smile.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import MyModule 1.0
+
+Rectangle {
+ width: 500
+ height: 500
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#00249a" }
+ GradientStop { position: 0.7; color: "#ffd94f" }
+ GradientStop { position: 1.0; color: "#ffa322" }
+ }
+ MyPaintItem {
+ renderTarget:PaintedItem.Image
+ clip:true
+ width:240
+ height:240
+ anchors.left : parent.left
+ anchors.top :parent.top
+ anchors.margins: 10
+ smooth: true
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (parent.face == ":-)")
+ parent.face = ":-(";
+ else
+ parent.face = ":-)";
+ parent.update()
+ }
+ }
+ }
+ MyPaintItem {
+ clip:true
+ renderTarget:PaintedItem.Image
+ width:240
+ height:240
+ anchors.right : parent.right
+ anchors.top :parent.top
+ anchors.margins: 10
+ smooth: true
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (parent.face == ":-)")
+ parent.face = ":-(";
+ else
+ parent.face = ":-)";
+ parent.update()
+ }
+ }
+ }
+ MyPaintItem {
+ clip:true
+ renderTarget:PaintedItem.Image
+ width:240
+ height:240
+ anchors.left : parent.left
+ anchors.bottom :parent.bottom
+ anchors.margins: 10
+ smooth: true
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (parent.face == ":-)")
+ parent.face = ":-(";
+ else
+ parent.face = ":-)";
+ parent.update()
+ }
+ }
+ }
+ MyPaintItem {
+ clip:true
+ renderTarget:PaintedItem.Image
+ width:240
+ height:240
+ anchors.right : parent.right
+ anchors.bottom :parent.bottom
+ anchors.margins: 10
+ smooth: true
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (parent.face == ":-)")
+ parent.face = ":-(";
+ else
+ parent.face = ":-)";
+ parent.update()
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h
new file mode 100644
index 0000000000..c500c1c525
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QQmlExtensionPlugin>
+
+#include "../textballoon.h"
+
+class TextBalloonPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "textballoon.json")
+public:
+ void registerTypes(const char *uri)
+ {
+ qmlRegisterType<TextBalloon>(uri, 1, 0, "TextBalloon");
+ }
+};
diff --git a/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir
new file mode 100644
index 0000000000..e8a08ae9d3
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir
@@ -0,0 +1 @@
+plugin qmltextballoonplugin
diff --git a/examples/quick/painteditem/textballoons/textballoon.cpp b/examples/quick/painteditem/textballoons/textballoon.cpp
new file mode 100644
index 0000000000..d097adfe1b
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoon.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textballoon.h"
+
+//! [0]
+TextBalloon::TextBalloon(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+ , rightAligned(false)
+{
+}
+//! [0]
+
+//! [1]
+void TextBalloon::paint(QPainter *painter)
+{
+ QBrush brush(QColor("#007430"));
+
+ painter->setBrush(brush);
+ painter->setPen(Qt::NoPen);
+ painter->setRenderHint(QPainter::Antialiasing);
+
+ painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10);
+
+ if (rightAligned)
+ {
+ const QPointF points[3] = {
+ QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0),
+ QPointF(boundingRect().width() - 20.0, boundingRect().height()),
+ QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0),
+ };
+ painter->drawConvexPolygon(points, 3);
+ }
+ else
+ {
+ const QPointF points[3] = {
+ QPointF(10.0, boundingRect().height() - 10.0),
+ QPointF(20.0, boundingRect().height()),
+ QPointF(30.0, boundingRect().height() - 10.0),
+ };
+ painter->drawConvexPolygon(points, 3);
+ }
+}
+//! [1]
+
+bool TextBalloon::isRightAligned()
+{
+ return this->rightAligned;
+}
+
+void TextBalloon::setRightAligned(bool rightAligned)
+{
+ this->rightAligned = rightAligned;
+}
diff --git a/examples/quick/painteditem/textballoons/textballoon.h b/examples/quick/painteditem/textballoons/textballoon.h
new file mode 100644
index 0000000000..93ed0a7105
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoon.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXTBALLOON_H
+#define TEXTBALLOON_H
+
+#include <QtQuick>
+
+//! [0]
+class TextBalloon : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged)
+
+ public:
+ TextBalloon(QQuickItem *parent = 0);
+ void paint(QPainter *painter);
+
+ bool isRightAligned();
+ void setRightAligned(bool rightAligned);
+
+ private:
+ bool rightAligned;
+
+ signals:
+ void rightAlignedChanged();
+};
+//! [0]
+
+#endif
diff --git a/examples/qtquick/painteditem/textballoons/textballoon.json b/examples/quick/painteditem/textballoons/textballoon.json
index 0967ef424b..0967ef424b 100644
--- a/examples/qtquick/painteditem/textballoons/textballoon.json
+++ b/examples/quick/painteditem/textballoons/textballoon.json
diff --git a/examples/quick/painteditem/textballoons/textballoons.pro b/examples/quick/painteditem/textballoons/textballoons.pro
new file mode 100644
index 0000000000..d612048ee8
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoons.pro
@@ -0,0 +1,25 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml quick
+
+TARGET = qmltextballoonplugin
+
+HEADERS += TextBalloonPlugin/plugin.h \
+ textballoon.h
+
+SOURCES += textballoon.cpp
+
+OTHER_FILES += textballoon.json
+
+DESTDIR = TextBalloonPlugin
+
+qdeclarativesources.files += \
+ TextBalloonPlugin/qmldir
+
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin
+
+sources.files = textballoons.qml
+sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons
+target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin
+
+INSTALLS = qdeclarativesources sources target
diff --git a/examples/quick/painteditem/textballoons/textballoons.qml b/examples/quick/painteditem/textballoons/textballoons.qml
new file mode 100644
index 0000000000..b00ce2bfed
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoons.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import TextBalloonPlugin 1.0
+
+Item {
+ height: 480
+ width: 640
+
+ //! [0]
+ ListModel {
+ id: balloonModel
+ ListElement {
+ balloonWidth: 200
+ }
+ ListElement {
+ balloonWidth: 350
+ }
+ }
+
+ ListView {
+ anchors.bottom: controls.top
+ anchors.bottomMargin: 2
+ anchors.top: parent.top
+ id: balloonView
+ delegate: TextBalloon {
+ anchors.right: index % 2 == 0 ? undefined : parent.right
+ height: 60
+ rightAligned: index % 2 == 0 ? false : true
+ width: balloonWidth
+ }
+ model: balloonModel
+ spacing: 5
+ width: parent.width
+ }
+ //! [0]
+
+ //! [1]
+ Rectangle {
+ id: controls
+
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.margins: 1
+ anchors.right: parent.right
+ border.width: 2
+ color: "white"
+ height: parent.height * 0.15
+
+ Text {
+ anchors.centerIn: parent
+ text: "Add another balloon"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: {
+ balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)})
+ balloonView.positionViewAtIndex(balloonView.count -1, ListView.End)
+ }
+ onEntered: {
+ parent.color = "#8ac953"
+ }
+ onExited: {
+ parent.color = "white"
+ }
+ }
+ }
+ //! [1]
+}
diff --git a/examples/quick/positioners/content/Button.qml b/examples/quick/positioners/content/Button.qml
new file mode 100644
index 0000000000..ee3aa9057e
--- /dev/null
+++ b/examples/quick/positioners/content/Button.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+
+ property string text
+ property string icon
+ signal clicked
+
+ border.color: "black"; color: "steelblue"; radius: 5
+ width: pix.width + textelement.width + 13
+ height: pix.height + 10
+
+ Image { id: pix; x: 5; y:5; source: parent.icon }
+
+ Text {
+ id: textelement
+ text: page.text; color: "white"
+ x: pix.width + pix.x + 3
+ anchors.verticalCenter: pix.verticalCenter
+ }
+
+ MouseArea {
+ id: mr
+ anchors.fill: parent
+ onClicked: { parent.focus = true; page.clicked() }
+ }
+
+ states: State {
+ name: "pressed"; when: mr.pressed
+ PropertyChanges { target: textelement; x: 5 }
+ PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 }
+ }
+}
diff --git a/examples/quick/positioners/content/add.png b/examples/quick/positioners/content/add.png
new file mode 100644
index 0000000000..1ee45423e3
--- /dev/null
+++ b/examples/quick/positioners/content/add.png
Binary files differ
diff --git a/examples/quick/positioners/content/del.png b/examples/quick/positioners/content/del.png
new file mode 100644
index 0000000000..8d2eaed523
--- /dev/null
+++ b/examples/quick/positioners/content/del.png
Binary files differ
diff --git a/examples/quick/positioners/positioners-attachedproperties.qml b/examples/quick/positioners/positioners-attachedproperties.qml
new file mode 100644
index 0000000000..a05927f5ea
--- /dev/null
+++ b/examples/quick/positioners/positioners-attachedproperties.qml
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 100
+
+ // Create row with four rectangles, the fourth one is hidden
+ Row {
+ id: row
+
+ Rectangle {
+ id: red
+ color: "red"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(red.Positioner)
+ }
+ }
+
+ Rectangle {
+ id: green
+ color: "green"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(green.Positioner)
+ }
+ }
+
+ Rectangle {
+ id: blue
+ color: "blue"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(blue.Positioner)
+ }
+ }
+
+ // This rectangle is not visible, so it doesn't have a positioner value
+ Rectangle {
+ color: "black"
+ width: 100
+ height: 100
+ visible: false
+ }
+
+ // Print the index of the child item in the positioner and convenience
+ // properties showing if it's the first or last item.
+ function showInfo(positioner) {
+ console.log("Item Index = " + positioner.index)
+ console.log(" isFirstItem = " + positioner.isFirstItem)
+ console.log(" isLastItem = " + positioner.isLastItem)
+ }
+ }
+}
diff --git a/examples/qtquick/positioners/positioners.qml b/examples/quick/positioners/positioners.qml
index 6627ad7dd4..6627ad7dd4 100644
--- a/examples/qtquick/positioners/positioners.qml
+++ b/examples/quick/positioners/positioners.qml
diff --git a/examples/qtquick/qtquick.pro b/examples/quick/quick.pro
index 529f65ac25..529f65ac25 100644
--- a/examples/qtquick/qtquick.pro
+++ b/examples/quick/quick.pro
diff --git a/examples/quick/righttoleft/layoutdirection/layoutdirection.qml b/examples/quick/righttoleft/layoutdirection/layoutdirection.qml
new file mode 100644
index 0000000000..0c65647d5b
--- /dev/null
+++ b/examples/quick/righttoleft/layoutdirection/layoutdirection.qml
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ property bool mirror
+ property int direction: Qt.application.layoutDirection
+ LayoutMirroring.enabled: mirror
+ LayoutMirroring.childrenInherit: true
+ width: column.width + 80
+ height: column.height + 40
+ Column {
+ id: column
+ width: 190
+ spacing: 10
+ anchors.centerIn: parent
+
+ Text {
+ text: "Row"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Row {
+ layoutDirection: root.direction
+ spacing: 10
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 4
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "Grid"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Grid {
+ layoutDirection: root.direction
+ spacing: 10; columns: 4
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 11
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "Flow"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Flow {
+ layoutDirection: root.direction
+ spacing: 10; width: parent.width
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 10
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "ListView"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ ListView {
+ id: listView
+ clip: true
+ width: parent.width; height: 40
+ layoutDirection: root.direction
+ orientation: Qt.Horizontal
+ model: 48
+ delegate: viewDelegate
+ }
+
+ Text {
+ text: "GridView"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ GridView {
+ clip: true
+ width: 200; height: 160
+ cellWidth: 50; cellHeight: 50
+ layoutDirection: root.direction
+ model: 48
+ delegate: viewDelegate
+ }
+
+ Rectangle {
+ height: 50; width: parent.width
+ color: mouseArea.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.direction ? "Right to left" : "Left to right"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ if (root.direction == Qt.LeftToRight) {
+ root.direction = Qt.RightToLeft;
+ } else {
+ root.direction = Qt.LeftToRight;
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ height: 50; width: parent.width
+ color: mouseArea2.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ anchors.fill: parent
+ onClicked: {
+ root.mirror = !root.mirror;
+ }
+ }
+ }
+ }
+
+ Component {
+ id: positionerDelegate
+ Rectangle {
+ width: 40; height: 40
+ color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0)
+ Text {
+ text: parent.parent.value+1
+ color: "white"
+ font.pixelSize: 18
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Component {
+ id: viewDelegate
+ Item {
+ width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50
+ Rectangle {
+ width: 40; height: 40
+ color: Qt.rgba(0.5+(48 - index)*Math.random()/48,
+ 0.3+index*Math.random()/48,
+ 0.3*Math.random(),
+ 1.0)
+ Text {
+ text: index+1
+ color: "white"
+ font.pixelSize: 18
+ anchors.centerIn: parent
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject
new file mode 100644
index 0000000000..33cbb3c9e2
--- /dev/null
+++ b/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "layoutdirection.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml
new file mode 100644
index 0000000000..5c4739bd57
--- /dev/null
+++ b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml
@@ -0,0 +1,313 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft
+ LayoutMirroring.enabled: mirror
+ LayoutMirroring.childrenInherit: true
+ width: 400
+ height: 875
+ color: "lightsteelblue"
+
+ Column {
+ spacing: 10
+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 }
+
+ Text {
+ text: "Positioners"
+ anchors.left: parent.left
+ }
+
+ Column {
+ id: positioners
+ spacing: 5
+ anchors.left: parent.left
+ Row {
+ id: row
+ spacing: 4
+ property string text: "THISISROW"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Flow {
+ id: flow
+ spacing: 4
+ width: 90
+ property string text: "THISISFLOW"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Grid {
+ id: grid
+ spacing: 4
+ columns: 6
+ property string text: "THISISGRID"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Component {
+ id: positionerDelegate
+ Text {
+ color: "white"
+ font.pixelSize: 20
+ text: parent.text[index]
+ Rectangle {
+ z: -1
+ opacity: 0.7
+ color: "black"
+ anchors.fill: parent
+ }
+ }
+ }
+ }
+
+ Text {
+ text: "Text alignment"
+ anchors.left: parent.left
+ }
+
+ Rectangle {
+ id: textStrings
+ width: 148
+ height: 85
+ color: "white"
+ anchors.left: parent.left
+ Column {
+ spacing: 5
+ width: parent.width
+ anchors { fill: parent; margins: 5 }
+ Text {
+ id: englishText
+ width: parent.width
+ text: "English text"
+ }
+ Text {
+ id: arabicText
+ width: parent.width
+ text: "النص العربي"
+ }
+ Text {
+ id: leftAlignedText
+ width: parent.width
+ text: "Text aligned to left"
+ horizontalAlignment: Text.AlignLeft
+ }
+ Text {
+ id: rightAlignedText
+ width: parent.width
+ text: "Text aligned to right"
+ horizontalAlignment: Text.AlignRight
+ }
+ }
+ }
+
+ Text {
+ text: "Model views"
+ anchors.left: parent.left
+ }
+
+ Column {
+ id: views
+ spacing: 10
+ anchors.left: parent.left
+ ListView {
+ id: listView
+ z: -1
+ clip: true
+ model: text.length
+ width: 360; height: 45
+ orientation: Qt.Horizontal
+ property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW"
+ delegate: Rectangle {
+ color: "black"
+ width: 45; height: 45
+ Rectangle {
+ anchors { fill: parent; margins: 1 }
+ color: "red"
+ }
+ Text {
+ text: listView.text[index]
+ font.pixelSize: 30
+ anchors.centerIn: parent
+ }
+ }
+ }
+ GridView {
+ id: gridView
+ z: -1
+ clip: true
+ model: text.length
+ width: 180; height: 90
+ cellWidth: 45; cellHeight: 45
+ property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW"
+ anchors.left: parent.left
+ delegate: Rectangle {
+ color: "black"
+ width: 45; height: 45
+ Rectangle {
+ anchors { fill: parent; margins: 1 }
+ color: "red"
+ }
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 30
+ text: gridView.text[index]
+ }
+ }
+ }
+ }
+
+ Text {
+ text: "Item x"
+ anchors.left: parent.left
+ }
+ Rectangle {
+ id: items
+ color: Qt.rgba(0.2, 0.2, 0.2, 0.6)
+ width: 275; height: 95
+ anchors.left: parent.left
+ Rectangle {
+ y: 5; x: 5
+ width: 130; height: 40
+ Text {
+ text: "Item with x: 5\n(not mirrored)"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ color: Qt.rgba(0.7, 0.7, 0.7)
+ y: 50; x: mirror(5)
+ width: 130; height: 40
+ function mirror(value) {
+ return LayoutMirroring.enabled ? (parent.width - width - value) : value;
+ }
+ Text {
+ text: "Item with x: " + parent.x + "\n(manually mirrored)"
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Text {
+ text: "Item anchors"
+ anchors.left: parent.left
+ }
+
+ Rectangle {
+ id: anchoredItems
+ color: Qt.rgba(0.2, 0.2, 0.2, 0.6)
+ width: 270; height: 170
+ anchors.left: parent.left
+ Rectangle {
+ id: blackRectangle
+ color: "black"
+ width: 180; height: 90
+ anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 }
+ Text {
+ text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent."
+ color: "white"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: whiteRectangle
+ color: "white"
+ width: 120; height: 70
+ anchors { left: parent.left; bottom: parent.bottom }
+ Text {
+ text: "Left side anchored\nto the left side\nof the parent."
+ color: "black"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: grayRectangle
+ color: Qt.rgba(0.7, 0.7, 0.7)
+ width: 140; height: 90
+ anchors { right: parent.right; bottom: parent.bottom }
+ Text {
+ text: "Right side anchored\nto the right side\nof the parent."
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Rectangle {
+ id: mirrorButton
+ color: mouseArea2.pressed ? "black" : "gray"
+ height: 50; width: parent.width
+ anchors.left: parent.left
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ anchors.fill: parent
+ onClicked: {
+ root.mirror = !root.mirror;
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject
new file mode 100644
index 0000000000..72bc04a8a9
--- /dev/null
+++ b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "layoutmirroring.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/righttoleft/textalignment/textalignment.qml b/examples/quick/righttoleft/textalignment/textalignment.qml
new file mode 100644
index 0000000000..ef5b97bb1a
--- /dev/null
+++ b/examples/quick/righttoleft/textalignment/textalignment.qml
@@ -0,0 +1,427 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ color: "white"
+ width: containerColumn.width
+ height: containerColumn.height + containerColumn.anchors.topMargin
+
+ property bool mirror: false
+ property variant horizontalAlignment: undefined
+
+ property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"]
+ property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"]
+ property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"]
+ property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput]
+
+ function shortText(horizontalAlignment) {
+
+ // all the different QML editors have
+ // the same alignment values
+ switch (horizontalAlignment) {
+ case Text.AlignLeft:
+ return "L";
+ case Text.AlignRight:
+ return "R";
+ case Text.AlignHCenter:
+ return "C";
+ case Text.AlignJustify:
+ return "J";
+ default:
+ return "Error";
+ }
+ }
+ Column {
+ id: containerColumn
+ spacing: 10
+ width: editorTypeRow.width
+ anchors { top: parent.top; topMargin: 5 }
+ Row {
+ id: editorTypeRow
+ Repeater {
+ model: editorType.length
+ Item {
+ width: editorColumn.width
+ height: editorColumn.height
+ Column {
+ id: editorColumn
+ spacing: 5
+ width: textColumn.width+10
+ Text {
+ text: root.editorType[index]
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Column {
+ id: textColumn
+ spacing: 5
+ anchors.horizontalCenter: parent.horizontalCenter
+ Repeater {
+ model: textComponents.length
+ delegate: textComponents[index]
+ }
+ }
+ }
+ }
+ }
+ }
+ Column {
+ spacing: 2
+ width: parent.width
+ Rectangle {
+ // button
+ height: 50; width: parent.width
+ color: mouseArea.pressed ? "black" : "lightgray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ property int index: 0
+ anchors.fill: parent
+ onClicked: root.mirror = !root.mirror
+ }
+ }
+ Rectangle {
+ // button
+ height: 50; width: parent.width
+ color: mouseArea2.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: {
+ if (root.horizontalAlignment == undefined)
+ return "Implict alignment";
+ switch (root.horizontalAlignment) {
+ case Text.AlignLeft:
+ return "Left alignment";
+ case Text.AlignRight:
+ return "Right alignment";
+ case Text.AlignHCenter:
+ return "Center alignment";
+ case Text.AlignJustify:
+ return "Justify alignment";
+ }
+ }
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ property int index: 0
+ anchors.fill: parent
+ onClicked: {
+ if (index < 0) {
+ root.horizontalAlignment = undefined;
+ } else {
+ root.horizontalAlignment = Math.pow(2, index);
+ }
+ index = (index + 2) % 5 - 1;
+ }
+ }
+ }
+ }
+ }
+
+ Component {
+ id: plainTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: styledTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ style: Text.Sunken
+ styleColor: "white"
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: richTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: italicRichTextComponent
+ Text {
+ width: 180
+ text: "<i>" + root.text[index] + "</i>"
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ Rectangle {
+ z: -1
+ color: parent.backgroundColor
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: plainTextEdit
+ TextEdit {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ cursorVisible: true
+ wrapMode: TextEdit.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.5, 0.5, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: italicTextEdit
+ TextEdit {
+ width: 180
+ text: "<i>" + root.text[index] + "<i>"
+ font.pixelSize: 24
+ cursorVisible: true
+ wrapMode: TextEdit.WordWrap
+ textFormat: TextEdit.RichText
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.5, 0.5, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: textInput
+ Item {
+ width: 180
+ height: textInput.text.length > 20 ? 3*textInput.height : textInput.height
+ TextInput {
+ id: textInput
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ cursorVisible: true
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.6, 0.4, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/righttoleft/textalignment/textalignment.qmlproject b/examples/quick/righttoleft/textalignment/textalignment.qmlproject
new file mode 100644
index 0000000000..e4b5061364
--- /dev/null
+++ b/examples/quick/righttoleft/textalignment/textalignment.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "textalignment.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/shadereffects/content/Slider.qml b/examples/quick/shadereffects/content/Slider.qml
new file mode 100644
index 0000000000..ff5f628b14
--- /dev/null
+++ b/examples/quick/shadereffects/content/Slider.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property real value: bar.x / (foo.width - bar.width)
+ Item {
+ id: foo
+ width: parent.width - 4
+ height: 6
+ anchors.centerIn: parent
+
+ Rectangle {
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: bar.horizontalCenter
+ color: "blue"
+ radius: 3
+ }
+ Rectangle {
+ height: parent.height
+ anchors.left: bar.horizontalCenter
+ anchors.right: parent.right
+ color: "gray"
+ radius: 3
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ radius: 3
+ border.width: 2
+ border.color: "black"
+ }
+
+ Rectangle {
+ id: bar
+ y: -7
+ width: 20
+ height: 20
+ radius: 15
+ color: "white"
+ border.width: 2
+ border.color: "black"
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: foo.width - parent.width
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/shadereffects/content/face-smile.png b/examples/quick/shadereffects/content/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/quick/shadereffects/content/face-smile.png
Binary files differ
diff --git a/examples/quick/shadereffects/content/qt-logo.png b/examples/quick/shadereffects/content/qt-logo.png
new file mode 100644
index 0000000000..7d3e97eb36
--- /dev/null
+++ b/examples/quick/shadereffects/content/qt-logo.png
Binary files differ
diff --git a/examples/quick/shadereffects/shadereffects.qml b/examples/quick/shadereffects/shadereffects.qml
new file mode 100644
index 0000000000..b820c8131e
--- /dev/null
+++ b/examples/quick/shadereffects/shadereffects.qml
@@ -0,0 +1,315 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Image {
+ width: 320
+ height: 480
+/*!
+ \title QML Examples - Shader Effects
+ \example declarative/shadereffects
+ \image qml-shadereffects-example.png
+ \brief This is a shader effects example
+
+ This example demonstrates a couple of visual effects that you can perform
+ with shaders in QtQuick 2.0
+*/
+ source: "../snake/content/pics/background.png"
+
+ Flickable {
+ anchors.fill: parent
+ contentWidth: 640
+ contentHeight: 360
+
+ ShaderEffectSource {
+ id: theSource
+ sourceItem: theItem
+ smooth: true
+ }
+
+ function saturate(x) {
+ return Math.min(Math.max(x, 0), 1)
+ }
+
+ function sliderToColor(x) {
+ return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)),
+ saturate(Math.min(6 * x, 4 - 6 * x)),
+ saturate(Math.min(6 * x - 2, 6 - 6 * x)))
+ }
+
+ Grid {
+ anchors.centerIn: parent
+ columns: 3
+
+ Item {
+ id: theItem
+ width: 180
+ height: 180
+ ListView {
+ anchors.centerIn: parent
+ width: 160
+ height: 140
+ clip: true
+ snapMode: ListView.SnapOneItem
+ model: VisualItemModel {
+ Text {
+ width: 160
+ height: 140
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 120
+ font.family: "Times"
+ color: "blue"
+ text: "Qt"
+ }
+ Image {
+ width: 160
+ height: 140
+ source: "content/qt-logo.png"
+ smooth: true
+ }
+ Image {
+ width: 160
+ height: 140
+ source: "content/face-smile.png"
+ smooth: true
+ }
+ }
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property real amplitude: 0.04 * wobbleSlider.value
+ property real frequency: 20
+ property real time: 0
+ NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
+ fragmentShader:
+ "uniform lowp float qt_Opacity;" +
+ "uniform highp float amplitude;" +
+ "uniform highp float frequency;" +
+ "uniform highp float time;" +
+ "uniform sampler2D source;" +
+ "varying highp vec2 qt_TexCoord0;" +
+ "void main() {" +
+ " highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
+ " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" +
+ "}"
+ Slider {
+ id: wobbleSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property variant shadow: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(0.0, 1.0 / height)
+ property variant source: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(1.0 / width, 0.0)
+ property variant source: theSource
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ property real angle: 0
+ property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle))
+ NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 }
+ property variant delta: Qt.size(offset.x / width, offset.y / height)
+ property real darkness: shadowSlider.value
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform highp vec2 offset;
+ uniform sampler2D source;
+ uniform sampler2D shadow;
+ uniform highp float darkness;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 fg = texture2D(source, qt_TexCoord0);
+ lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta);
+ gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity;
+ }"
+ Slider {
+ id: shadowSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property variant delta: Qt.size(0.5 / width, 0.5 / height)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ uniform highp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta);
+ lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y));
+ lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y));
+ lowp vec4 br = texture2D(source, qt_TexCoord0 + delta);
+ lowp vec4 gx = (tl + bl) - (tr + br);
+ lowp vec4 gy = (tl + tr) - (bl + br);
+ gl_FragColor.xyz = vec3(0.);
+ gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity;
+ }"
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property color tint: sliderToColor(colorizeSlider.value)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp vec4 tint;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 c = texture2D(source, qt_TexCoord0);
+ lowp float lo = min(min(c.x, c.y), c.z);
+ lowp float hi = max(max(c.x, c.y), c.z);
+ gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w);
+ }"
+ Slider {
+ id: colorizeSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ mesh: Qt.size(10, 10)
+ property variant source: theSource
+ property real bend: 0
+ property real minimize: 0
+ property real side: genieSlider.value
+ SequentialAnimation on bend {
+ loops: Animation.Infinite
+ NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1600 }
+ NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1000 }
+ }
+ SequentialAnimation on minimize {
+ loops: Animation.Infinite
+ PauseAnimation { duration: 300 }
+ NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1300 }
+ }
+ vertexShader: "
+ uniform highp mat4 qt_Matrix;
+ uniform highp float bend;
+ uniform highp float minimize;
+ uniform highp float side;
+ uniform highp float width;
+ uniform highp float height;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ qt_TexCoord0 = qt_MultiTexCoord0;
+ highp vec4 pos = qt_Vertex;
+ pos.y = mix(qt_Vertex.y, height, minimize);
+ highp float t = pos.y / height;
+ t = (3. - 2. * t) * t * t;
+ pos.x = mix(qt_Vertex.x, side * width, t * bend);
+ gl_Position = qt_Matrix * pos;
+ }"
+ Slider {
+ id: genieSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/text/fonts/availableFonts.qml b/examples/quick/text/fonts/availableFonts.qml
new file mode 100644
index 0000000000..0b87259556
--- /dev/null
+++ b/examples/quick/text/fonts/availableFonts.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 480; height: 640; color: "steelblue"
+
+ ListView {
+ anchors.fill: parent; model: Qt.fontFamilies()
+
+ delegate: Item {
+ height: 40; width: ListView.view.width
+ Text {
+ anchors.centerIn: parent
+ text: modelData; font.family: modelData; font.pixelSize: 24; color: "white"
+ }
+ }
+ }
+}
diff --git a/examples/quick/text/fonts/banner.qml b/examples/quick/text/fonts/banner.qml
new file mode 100644
index 0000000000..6c9aa25fa1
--- /dev/null
+++ b/examples/quick/text/fonts/banner.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: screen
+
+ property int pixelSize: screen.height * 1.25
+ property color textColor: "lightsteelblue"
+ property string text: "Hello world! "
+
+ width: 640; height: 320
+ color: "steelblue"
+
+ Row {
+ y: -screen.height / 4.5
+
+ NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite }
+ Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ }
+}
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf b/examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf
index cf93f9651f..cf93f9651f 100644
--- a/tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf
+++ b/examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf
Binary files differ
diff --git a/examples/quick/text/fonts/fonts.qml b/examples/quick/text/fonts/fonts.qml
new file mode 100644
index 0000000000..78cef25eae
--- /dev/null
+++ b/examples/quick/text/fonts/fonts.qml
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ property string myText: "The quick brown fox jumps over the lazy dog."
+
+ width: 800; height: 480
+ color: "steelblue"
+
+ FontLoader { id: fixedFont; name: "Courier" }
+ FontLoader { id: localFont; source: "content/fonts/tarzeau_ocr_a.ttf" }
+ FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" }
+
+ Column {
+ anchors { fill: parent; leftMargin: 10; rightMargin: 10 }
+ spacing: 15
+
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideRight
+ font.family: "Times"; font.pointSize: 42
+ }
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideLeft
+ font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase }
+ }
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideMiddle
+ font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase }
+ }
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideRight
+ font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps }
+ }
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideLeft
+ font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize }
+ }
+ Text {
+ text: {
+ if (webFont.status == FontLoader.Ready) myText
+ else if (webFont.status == FontLoader.Loading) "Loading..."
+ else if (webFont.status == FontLoader.Error) "Error loading font"
+ }
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideMiddle
+ font.family: webFont.name; font.pointSize: 42
+ }
+ }
+}
diff --git a/examples/quick/text/fonts/hello.qml b/examples/quick/text/fonts/hello.qml
new file mode 100644
index 0000000000..d9479fb208
--- /dev/null
+++ b/examples/quick/text/fonts/hello.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: screen
+
+ width: 800; height: 480
+ color: "black"
+
+ Item {
+ id: container
+ x: screen.width / 2; y: screen.height / 2
+
+ Text {
+ id: text
+ anchors.centerIn: parent
+ color: "white"
+ text: "Hello world!"
+ font.pixelSize: 60
+ smooth: true
+
+ SequentialAnimation on font.letterSpacing {
+ loops: Animation.Infinite;
+ NumberAnimation { from: 0; to: 150; easing.type: Easing.InQuad; duration: 3000 }
+ ScriptAction {
+ script: {
+ container.y = (screen.height / 4) + (Math.random() * screen.height / 2)
+ container.x = (screen.width / 4) + (Math.random() * screen.width / 2)
+ }
+ }
+ }
+
+ SequentialAnimation on opacity {
+ loops: Animation.Infinite;
+ NumberAnimation { from: 1; to: 0; duration: 2600 }
+ PauseAnimation { duration: 400 }
+ }
+ }
+ }
+}
diff --git a/examples/quick/text/imgtag/TextWithImage.qml b/examples/quick/text/imgtag/TextWithImage.qml
new file mode 100644
index 0000000000..bc09aa2a52
--- /dev/null
+++ b/examples/quick/text/imgtag/TextWithImage.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Text {
+ width: parent.width
+ font.pointSize: 14
+ wrapMode: Text.WordWrap
+ textFormat: Text.StyledText
+ horizontalAlignment: main.hAlign
+
+ Rectangle {
+ border.color: "#efefef"
+ color: "transparent"
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/qtquick2/qquicktext/data/images/face-sad.png b/examples/quick/text/imgtag/images/face-sad.png
index 24188b7985..24188b7985 100644
--- a/tests/auto/qtquick2/qquicktext/data/images/face-sad.png
+++ b/examples/quick/text/imgtag/images/face-sad.png
Binary files differ
diff --git a/examples/quick/text/imgtag/images/face-smile-big.png b/examples/quick/text/imgtag/images/face-smile-big.png
new file mode 100644
index 0000000000..d05e0bf21e
--- /dev/null
+++ b/examples/quick/text/imgtag/images/face-smile-big.png
Binary files differ
diff --git a/examples/quick/text/imgtag/images/face-smile.png b/examples/quick/text/imgtag/images/face-smile.png
new file mode 100644
index 0000000000..e5e1d1353c
--- /dev/null
+++ b/examples/quick/text/imgtag/images/face-smile.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/images/heart200.png b/examples/quick/text/imgtag/images/heart200.png
index cedd3ea608..cedd3ea608 100644
--- a/tests/auto/qtquick2/qquicktext/data/images/heart200.png
+++ b/examples/quick/text/imgtag/images/heart200.png
Binary files differ
diff --git a/examples/quick/text/imgtag/images/qtlogo.png b/examples/quick/text/imgtag/images/qtlogo.png
new file mode 100644
index 0000000000..996719a4c6
--- /dev/null
+++ b/examples/quick/text/imgtag/images/qtlogo.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/images/starfish_2.png b/examples/quick/text/imgtag/images/starfish_2.png
index 132c20ffd0..132c20ffd0 100644
--- a/tests/auto/qtquick2/qquicktext/data/images/starfish_2.png
+++ b/examples/quick/text/imgtag/images/starfish_2.png
Binary files differ
diff --git a/examples/quick/text/imgtag/imgtag.qml b/examples/quick/text/imgtag/imgtag.qml
new file mode 100644
index 0000000000..9d181af2cb
--- /dev/null
+++ b/examples/quick/text/imgtag/imgtag.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+ width: 320; height: 480
+ focus: true
+
+ property var hAlign: Text.AlignLeft
+
+ Flickable {
+ anchors.fill: parent
+ contentWidth: parent.width
+ contentHeight: col.height + 20
+
+ Column {
+ id: col
+ x: 10; y: 10
+ spacing: 20
+ width: parent.width - 20
+
+ TextWithImage {
+ text: "This is a <b>happy</b> face<img src=\"images/face-smile.png\">"
+ }
+ TextWithImage {
+ text: "This is a <b>very<img src=\"images/face-smile-big.png\" align=\"middle\"/>happy</b> face aligned in the middle."
+ }
+ TextWithImage {
+ elide: Text.ElideRight
+ maximumLineCount: 2
+ text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis<img src=\"images/face-sad.png\" align=\"top\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis."
+ }
+ TextWithImage {
+ text: "This is a tiny<img src=\"images/face-smile.png\" width=\"15\" height=\"15\">happy face."
+ }
+ TextWithImage {
+ text: "This is a starfish<img src=\"images/starfish_2.png\" width=\"50\" height=\"50\" align=\"top\">aligned to the top and another one<img src=\"images/heart200.png\" width=\"50\" height=\"50\">aligned to the bottom."
+ }
+ TextWithImage {
+ text: "Qt logos<img src=\"images/qtlogo.png\" width=\"55\" height=\"60\" align=\"middle\"><img src=\"images/qtlogo.png\" width=\"37\" height=\"40\" align=\"middle\"><img src=\"images/qtlogo.png\" width=\"18\" height=\"20\" align=\"middle\">aligned in the middle with different sizes."
+ }
+ TextWithImage {
+ text: "Some hearts<img src=\"images/heart200.png\" width=\"20\" height=\"20\" align=\"bottom\"><img src=\"images/heart200.png\" width=\"30\" height=\"30\" align=\"bottom\"> <img src=\"images/heart200.png\" width=\"40\" height=\"40\"><img src=\"images/heart200.png\" width=\"50\" height=\"50\" align=\"bottom\">with different sizes."
+ }
+ TextWithImage {
+ text: "Resized image<img width=\"80\" height=\"76\" align=\"middle\" src=\"http://files.app4mobile.com/wp-content/uploads/2011/08/nokia-n9-price-specification-features-us-europe-india.jpg\">from the internet."
+ }
+ TextWithImage {
+ text: "Image<img align=\"middle\" src=\"http://qt.gitorious.org/images/sites/qt/logo.png\">from the internet."
+ }
+ TextWithImage {
+ height: 120
+ verticalAlignment: Text.AlignVCenter
+ text: "This is a <b>happy</b> face<img src=\"images/face-smile.png\"> with an explicit height."
+ }
+ }
+ }
+
+ Keys.onUpPressed: main.hAlign = Text.AlignHCenter
+ Keys.onLeftPressed: main.hAlign = Text.AlignLeft
+ Keys.onRightPressed: main.hAlign = Text.AlignRight
+}
diff --git a/examples/quick/text/styledtext-layout.qml b/examples/quick/text/styledtext-layout.qml
new file mode 100644
index 0000000000..4571330568
--- /dev/null
+++ b/examples/quick/text/styledtext-layout.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+ width: 320; height: 480
+ focus: true
+
+ property real offset: 0
+ property real margin: 10
+
+ Keys.onLeftPressed: myText.horizontalAlignment = Text.AlignLeft
+ Keys.onUpPressed: myText.horizontalAlignment = Text.AlignHCenter
+ Keys.onRightPressed: myText.horizontalAlignment = Text.AlignRight
+ Keys.onDownPressed: myText.horizontalAlignment = Text.AlignJustify
+
+ Text {
+ id: myText
+ anchors.fill: parent
+ anchors.margins: 10
+ wrapMode: Text.WordWrap
+ font.family: "Times New Roman"
+ font.pixelSize: 13
+ textFormat: Text.StyledText
+ horizontalAlignment: Text.AlignJustify
+
+ text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui sed eu egestas est facilis <a href=\"www.nokia.com\">www.nokia.com</a>.<br/>Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Phasellus id neque id velit facilisis cursus ac sit amet nibh. Donec enim arcu, pharetra non semper nec, iaculis eget elit. Nunc blandit condimentum odio vel egestas.<br><ul type=\"bullet\"><li>Coffee<ol type=\"a\"><li>Espresso<li><b>Cappuccino</b><li><i>Flat White</i><li>Latte</ol><li>Juice<ol type=\"1\"><li>Orange</li><li>Apple</li><li>Pineapple</li><li>Tomato</li></ol></li></ul><p><font color=\"#434343\"><i>Proin consectetur <b>sapien</b> in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit."
+
+ onLineLaidOut: {
+ line.width = width / 2 - (2 * margin)
+ if (line.number === 30) {
+ main.offset = line.y
+ }
+ if (line.number >= 30) {
+ line.x = width / 2 + margin
+ line.y -= main.offset
+ }
+ if ((line.y + line.height) > rect.y && line.y < (rect.y + rect.height)) {
+ if (line.number < 30)
+ line.width = Math.min((rect.x - line.x), line.width)
+ else {
+ line.x = Math.max((rect.x + rect.width), width / 2 + margin)
+ line.width = Math.min((width - margin - line.x), line.width)
+ }
+ }
+ }
+
+ Item {
+ id: rect
+ x: 28; y: 20
+ width: 60; height: 60
+
+ Rectangle {
+ anchors { fill: parent; leftMargin: 2; rightMargin: 2 }
+ color: "lightsteelblue"; opacity: 0.3
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: rect
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1
+ onPositionChanged: myText.doLayout()
+ }
+ }
+ }
+
+}
diff --git a/examples/qtquick/text/text.qml b/examples/quick/text/text.qml
index 9bfd290059..9bfd290059 100644
--- a/examples/qtquick/text/text.qml
+++ b/examples/quick/text/text.qml
diff --git a/examples/quick/text/text.qmlproject b/examples/quick/text/text.qmlproject
new file mode 100644
index 0000000000..c08d9b9a89
--- /dev/null
+++ b/examples/quick/text/text.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "text.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/text/textselection/pics/endHandle.png b/examples/quick/text/textselection/pics/endHandle.png
new file mode 100644
index 0000000000..1a4bc5d7a0
--- /dev/null
+++ b/examples/quick/text/textselection/pics/endHandle.png
Binary files differ
diff --git a/examples/quick/text/textselection/pics/endHandle.sci b/examples/quick/text/textselection/pics/endHandle.sci
new file mode 100644
index 0000000000..4f51f24278
--- /dev/null
+++ b/examples/quick/text/textselection/pics/endHandle.sci
@@ -0,0 +1,5 @@
+border.left: 0
+border.top: 6
+border.bottom: 6
+border.right: 6
+source: endHandle.png
diff --git a/examples/quick/text/textselection/pics/startHandle.png b/examples/quick/text/textselection/pics/startHandle.png
new file mode 100644
index 0000000000..deedcd5c91
--- /dev/null
+++ b/examples/quick/text/textselection/pics/startHandle.png
Binary files differ
diff --git a/examples/quick/text/textselection/pics/startHandle.sci b/examples/quick/text/textselection/pics/startHandle.sci
new file mode 100644
index 0000000000..f9eae204c1
--- /dev/null
+++ b/examples/quick/text/textselection/pics/startHandle.sci
@@ -0,0 +1,5 @@
+border.left: 6
+border.top: 6
+border.bottom: 6
+border.right: 0
+source: startHandle.png
diff --git a/examples/quick/text/textselection/textselection.qml b/examples/quick/text/textselection/textselection.qml
new file mode 100644
index 0000000000..7938ce5bf7
--- /dev/null
+++ b/examples/quick/text/textselection/textselection.qml
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Rectangle {
+ id: editor
+ color: "lightGrey"
+ width: 640; height: 480
+
+ Rectangle {
+ color: "white"
+ anchors.fill: parent
+ anchors.margins: 20
+
+ BorderImage {
+ id: startHandle
+ source: "pics/startHandle.sci"
+ opacity: 0.0
+ width: 10
+ x: edit.positionToRectangle(edit.selectionStart).x - flick.contentX-width
+ y: edit.positionToRectangle(edit.selectionStart).y - flick.contentY
+ height: edit.positionToRectangle(edit.selectionStart).height
+ }
+
+ BorderImage {
+ id: endHandle
+ source: "pics/endHandle.sci"
+ opacity: 0.0
+ width: 10
+ x: edit.positionToRectangle(edit.selectionEnd).x - flick.contentX
+ y: edit.positionToRectangle(edit.selectionEnd).y - flick.contentY
+ height: edit.positionToRectangle(edit.selectionEnd).height
+ }
+
+ Flickable {
+ id: flick
+
+ anchors.fill: parent
+ contentWidth: edit.paintedWidth
+ contentHeight: edit.paintedHeight
+ interactive: true
+ clip: true
+
+ function ensureVisible(r) {
+ if (contentX >= r.x)
+ contentX = r.x;
+ else if (contentX+width <= r.x+r.width)
+ contentX = r.x+r.width-width;
+ if (contentY >= r.y)
+ contentY = r.y;
+ else if (contentY+height <= r.y+r.height)
+ contentY = r.y+r.height-height;
+ }
+
+ TextEdit {
+ id: edit
+ width: flick.width
+ height: flick.height
+ focus: true
+ wrapMode: TextEdit.Wrap
+ textFormat: TextEdit.RichText
+
+ onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
+
+ text: "<h1>Text Selection</h1>"
+ +"<p>This example is a whacky text selection mechanisms, showing how these can be implemented in the TextEdit element, to cater for whatever style is appropriate for the target platform."
+ +"<p><b>Press-and-hold</b> to select a word, then drag the selection handles."
+ +"<p><b>Drag outside the selection</b> to scroll the text."
+ +"<p><b>Click inside the selection</b> to cut/copy/paste/cancel selection."
+ +"<p>It's too whacky to let you paste if there is no current selection."
+
+ }
+ }
+
+ Item {
+ id: menu
+ opacity: 0.0
+ width: 100
+ height: 120
+ anchors.centerIn: parent
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ radius: 15
+ color: "#806080FF"
+ anchors.fill: parent
+ }
+
+ Column {
+ anchors.centerIn: parent
+ spacing: 8
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ color: "#ff7090FF"
+ width: 60
+ height: 16
+
+ Text { anchors.centerIn: parent; text: "Cut" }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { edit.cut(); editor.state = "" }
+ }
+ }
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ color: "#ff7090FF"
+ width: 60
+ height: 16
+
+ Text { anchors.centerIn: parent; text: "Copy" }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { edit.copy(); editor.state = "selection" }
+ }
+ }
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ color: "#ff7090FF"
+ width: 60
+ height: 16
+
+ Text { anchors.centerIn: parent; text: "Paste" }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" }
+ }
+ }
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ color: "#ff7090FF"
+ width: 60
+ height: 16
+
+ Text { anchors.centerIn: parent; text: "Deselect" }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ edit.cursorPosition = edit.selectionEnd;
+ edit.deselect();
+ editor.state = ""
+ }
+ }
+ }
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "selection"
+ PropertyChanges { target: startHandle; opacity: 1.0 }
+ PropertyChanges { target: endHandle; opacity: 1.0 }
+ },
+ State {
+ name: "menu"
+ PropertyChanges { target: startHandle; opacity: 0.5 }
+ PropertyChanges { target: endHandle; opacity: 0.5 }
+ PropertyChanges { target: menu; opacity: 1.0 }
+ }
+ ]
+}
diff --git a/examples/quick/threading/threadedlistmodel/dataloader.js b/examples/quick/threading/threadedlistmodel/dataloader.js
new file mode 100644
index 0000000000..4d2aab323d
--- /dev/null
+++ b/examples/quick/threading/threadedlistmodel/dataloader.js
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// ![0]
+WorkerScript.onMessage = function(msg) {
+ if (msg.action == 'appendCurrentTime') {
+ var data = {'time': new Date().toTimeString()};
+ msg.model.append(data);
+ msg.model.sync(); // updates the changes to the list
+ }
+}
+// ![0]
diff --git a/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject
new file mode 100644
index 0000000000..e7c8e69f14
--- /dev/null
+++ b/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QmlProject 1.1
+
+Project {
+ mainFile: "timedisplay.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/threading/threadedlistmodel/timedisplay.qml b/examples/quick/threading/threadedlistmodel/timedisplay.qml
new file mode 100644
index 0000000000..48d0f659e5
--- /dev/null
+++ b/examples/quick/threading/threadedlistmodel/timedisplay.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// ![0]
+import QtQuick 2.0
+
+Rectangle {
+ color: "white"
+ width: 200
+ height: 300
+
+ ListView {
+ anchors.fill: parent
+ model: listModel
+ delegate: Component {
+ Text { text: time }
+ }
+
+ ListModel { id: listModel }
+
+ WorkerScript {
+ id: worker
+ source: "dataloader.js"
+ }
+
+ Timer {
+ id: timer
+ interval: 2000; repeat: true
+ running: true
+ triggeredOnStart: true
+
+ onTriggered: {
+ var msg = {'action': 'appendCurrentTime', 'model': listModel};
+ worker.sendMessage(msg);
+ }
+ }
+ }
+}
+// ![0]
diff --git a/examples/quick/threading/workerscript/workerscript.js b/examples/quick/threading/workerscript/workerscript.js
new file mode 100644
index 0000000000..f76471f920
--- /dev/null
+++ b/examples/quick/threading/workerscript/workerscript.js
@@ -0,0 +1,15 @@
+var lastx = 0;
+var lasty = 0;
+
+WorkerScript.onMessage = function(message) {
+ var ydiff = message.y - lasty;
+ var xdiff = message.x - lastx;
+
+ var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff);
+
+ lastx = message.x;
+ lasty = message.y;
+
+ WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} );
+}
+
diff --git a/examples/quick/threading/workerscript/workerscript.qml b/examples/quick/threading/workerscript/workerscript.qml
new file mode 100644
index 0000000000..7fced8166c
--- /dev/null
+++ b/examples/quick/threading/workerscript/workerscript.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 480; height: 320
+
+ WorkerScript {
+ id: myWorker
+ source: "workerscript.js"
+
+ onMessage: {
+ console.log("Moved " + messageObject.xmove + " along the X axis.");
+ console.log("Moved " + messageObject.ymove + " along the Y axis.");
+ console.log("Moved " + messageObject.move + " pixels.");
+ }
+ }
+
+ Rectangle {
+ width: 200; height: 200
+ anchors.left: parent.left; anchors.leftMargin: 20
+ color: "red"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } );
+ }
+ }
+
+ Rectangle {
+ width: 200; height: 200
+ anchors.right: parent.right; anchors.rightMargin: 20
+ color: "blue"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } );
+ }
+ }
+
+ Text {
+ text: "Click a Rectangle!"
+ anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 }
+ }
+}
diff --git a/examples/quick/threading/workerscript/workerscript.qmlproject b/examples/quick/threading/workerscript/workerscript.qmlproject
new file mode 100644
index 0000000000..6d7a91feeb
--- /dev/null
+++ b/examples/quick/threading/workerscript/workerscript.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "workerscript.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/touchinteraction/flickable/content/Day.qml b/examples/quick/touchinteraction/flickable/content/Day.qml
new file mode 100644
index 0000000000..7fe625c305
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/content/Day.qml
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Component {
+ Item {
+ property variant stickies
+
+ id: page
+ width: ListView.view.width+40; height: ListView.view.height
+
+
+ Image {
+ source: "cork.jpg"
+ width: page.ListView.view.width
+ height: page.ListView.view.height
+ fillMode: Image.PreserveAspectCrop
+ clip: true
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: page.focus = false;
+ }
+
+ Text {
+ text: name; x: 15; y: 8; height: 40; width: 370
+ font.pixelSize: 18; font.bold: true; color: "white"
+ style: Text.Outline; styleColor: "black"
+ }
+
+ Repeater {
+ model: notes
+ Item {
+ id: stickyPage
+
+ property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100
+ property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50
+
+ x: randomX; y: randomY
+
+ rotation: -flickable.horizontalVelocity / 100;
+ Behavior on rotation {
+ SpringAnimation { spring: 2.0; damping: 0.15 }
+ }
+
+ Item {
+ id: sticky
+ scale: 0.7
+
+ Image {
+ id: stickyImage
+ x: 8 + -width * 0.6 / 2; y: -20
+ source: "note-yellow.png"
+ scale: 0.6; transformOrigin: Item.TopLeft
+ smooth: true
+ }
+
+ TextEdit {
+ id: myText
+ x: -104; y: 36; width: 215; height: 200
+ smooth: true
+ font.pixelSize: 24
+ readOnly: false
+ rotation: -8
+ text: noteText
+ }
+
+ Item {
+ x: stickyImage.x; y: -20
+ width: stickyImage.width * stickyImage.scale
+ height: stickyImage.height * stickyImage.scale
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ drag.target: stickyPage
+ drag.axis: Drag.XandYAxis
+ drag.minimumY: 0
+ drag.maximumY: page.height - 80
+ drag.minimumX: 100
+ drag.maximumX: page.width - 140
+ onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); }
+ }
+ }
+ }
+
+ Image {
+ x: -width / 2; y: -height * 0.5 / 2
+ source: "tack.png"
+ scale: 0.7; transformOrigin: Item.TopLeft
+ }
+
+ states: State {
+ name: "pressed"
+ when: mouse.pressed
+ PropertyChanges { target: sticky; rotation: 8; scale: 1 }
+ PropertyChanges { target: page; z: 8 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "rotation,scale"; duration: 200 }
+ }
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/examples/quick/touchinteraction/flickable/content/cork.jpg b/examples/quick/touchinteraction/flickable/content/cork.jpg
new file mode 100644
index 0000000000..160bc002bf
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/content/cork.jpg
Binary files differ
diff --git a/examples/quick/touchinteraction/flickable/content/note-yellow.png b/examples/quick/touchinteraction/flickable/content/note-yellow.png
new file mode 100644
index 0000000000..8ddecc8b03
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/content/note-yellow.png
Binary files differ
diff --git a/examples/quick/touchinteraction/flickable/content/tack.png b/examples/quick/touchinteraction/flickable/content/tack.png
new file mode 100644
index 0000000000..cef2d1cd23
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/content/tack.png
Binary files differ
diff --git a/examples/quick/touchinteraction/flickable/corkboards.qml b/examples/quick/touchinteraction/flickable/corkboards.qml
new file mode 100644
index 0000000000..dc3aa6b378
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/corkboards.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 800; height: 480
+ color: "#464646"
+
+ ListModel {
+ id: list
+
+ ListElement {
+ name: "Sunday"
+ notes: [
+ ListElement { noteText: "Lunch" },
+ ListElement { noteText: "Birthday Party" }
+ ]
+ }
+
+ ListElement {
+ name: "Monday"
+ notes: [
+ ListElement { noteText: "Pickup kids from\nschool\n4.30pm" },
+ ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" }
+ ]
+ }
+
+ ListElement {
+ name: "Tuesday"
+ notes: [
+ ListElement { noteText: "Walk dog" },
+ ListElement { noteText: "Buy newspaper" }
+ ]
+ }
+
+ ListElement {
+ name: "Wednesday"
+ notes: [ ListElement { noteText: "Cook dinner" } ]
+ }
+
+ ListElement {
+ name: "Thursday"
+ notes: [
+ ListElement { noteText: "Meeting\n5.30pm" },
+ ListElement { noteText: "Weed garden" }
+ ]
+ }
+
+ ListElement {
+ name: "Friday"
+ notes: [
+ ListElement { noteText: "More work" },
+ ListElement { noteText: "Grocery shopping" }
+ ]
+ }
+
+ ListElement {
+ name: "Saturday"
+ notes: [
+ ListElement { noteText: "Drink" },
+ ListElement { noteText: "Download Qt\nPlay with QML" }
+ ]
+ }
+ }
+
+ ListView {
+ id: flickable
+
+ anchors.fill: parent
+ focus: true
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem
+ model: list
+ delegate: Day { }
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml
new file mode 100644
index 0000000000..db46473c05
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Item {
+ id: root
+ height: 640
+ width: 320
+ Item {
+ id: startScreen
+ anchors.fill: parent
+ z: 1000
+ Image {
+ source: "content/title.png"
+ anchors.centerIn: parent
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {//Game Start
+ parent.visible = false;
+ }
+ }
+ }
+ Rectangle {
+ id: bg
+ anchors.fill: parent
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "DarkBlue" }
+ GradientStop { position: 0.8; color: "SkyBlue" }
+ GradientStop { position: 0.81; color: "ForestGreen" }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+
+ BearWhackParticleSystem {
+ id: particleSystem
+ anchors.fill: parent
+ running: !startScreen.visible
+ }
+
+ property int score: 0
+
+ Text {
+ anchors.right: parent.right
+ anchors.margins: 4
+ anchors.top: parent.top
+ color: "white"
+ function padded(num) {
+ var ret = num.toString();
+ while (ret.length < 6)
+ ret = "0" + ret;
+ return ret;
+ }
+ text: "Score: " + padded(score)
+ }
+ MultiPointTouchArea {
+ anchors.fill: parent
+ touchPoints: [//Support up to 4 touches at once?
+ AugmentedTouchPoint{ system: particleSystem },
+ AugmentedTouchPoint{ system: particleSystem },
+ AugmentedTouchPoint{ system: particleSystem },
+ AugmentedTouchPoint{ system: particleSystem }
+ ]
+ }
+ MouseArea{
+ anchors.fill: parent
+ id: ma
+ onPressedChanged: {
+ if (pressed) {
+ timer.restart();
+ sgoal.enabled = true;
+ particleSystem.explode(mouseX,mouseY);
+ }
+ }
+ Timer {
+ id: timer
+ interval: 100
+ running: false
+ repeat: false
+ onTriggered: sgoal.enabled = false
+ }
+ SpriteGoal {
+ id: sgoal
+ x: ma.mouseX - 16
+ y: ma.mouseY - 16
+ width: 32
+ height: 32
+ system: particleSystem
+ parent: particleSystem
+ goalState: "falling"
+ enabled: false
+ }
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml
new file mode 100644
index 0000000000..aede1a8f4e
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+TouchPoint {
+ id: container
+ property ParticleSystem system
+ onPressedChanged: {
+ if (pressed) {
+ timer.restart();
+ child.enabled = true;
+ system.explode(x,y);
+ }
+ }
+ property QtObject obj: Timer {
+ id: timer
+ interval: 100
+ running: false
+ repeat: false
+ onTriggered: child.enabled = false
+ }
+ property Item child: SpriteGoal {
+ enabled: false
+ x: container.area.x - 16
+ y: container.area.y - 16
+ width: container.area.width + 32
+ height: container.area.height + 32 //+32 so it doesn't have to hit the exact center
+ system: container.system
+ parent: container.system
+ goalState: "falling"
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear0.png b/examples/quick/touchinteraction/multipointtouch/content/Bear0.png
new file mode 100644
index 0000000000..64a02cec8e
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/Bear0.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear1.png b/examples/quick/touchinteraction/multipointtouch/content/Bear1.png
new file mode 100644
index 0000000000..3b88f3b32e
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/Bear1.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear2.png b/examples/quick/touchinteraction/multipointtouch/content/Bear2.png
new file mode 100644
index 0000000000..337b636070
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/Bear2.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear3.png b/examples/quick/touchinteraction/multipointtouch/content/Bear3.png
new file mode 100644
index 0000000000..f0e68590f4
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/Bear3.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/BearB.png b/examples/quick/touchinteraction/multipointtouch/content/BearB.png
new file mode 100644
index 0000000000..c9a84ae1d4
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/BearB.png
Binary files differ
diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml
index bed03e99aa..bed03e99aa 100644
--- a/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml
+++ b/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml
diff --git a/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml b/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml
new file mode 100644
index 0000000000..9788c5c665
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ property alias color: img.color
+ property alias emitting: emitter.enabled
+ ImageParticle {
+ id: img
+ source: "blur-circle.png"
+ colorVariation: 0.1
+ color: "#ff521d"
+ alpha: 0
+ }
+ Emitter {
+ id: emitter
+ speedFromMovement: 20
+ emitRate: 80
+ lifeSpan: 1500
+ speed: PointDirection{ y: -90; yVariation: 50; }
+ acceleration: PointDirection{ xVariation: 100; yVariation: 90; }
+ size: 51
+ sizeVariation: 53
+ endSize: 64
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png b/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png
new file mode 100644
index 0000000000..1b03cd0b2c
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png b/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png
new file mode 100644
index 0000000000..dbc39cb16e
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png b/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png
new file mode 100644
index 0000000000..dbc38804ee
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/title.png b/examples/quick/touchinteraction/multipointtouch/content/title.png
new file mode 100644
index 0000000000..d630ea2643
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/title.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/multiflame.qml b/examples/quick/touchinteraction/multipointtouch/multiflame.qml
new file mode 100644
index 0000000000..72a0ce21f8
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/multiflame.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 360
+ height: 480
+ color: "black"
+
+ MultiPointTouchArea {
+ anchors.fill: parent
+ minimumTouchPoints: 1
+ maximumTouchPoints: 5
+ touchPoints: [
+ TouchPoint { id: touch1 },
+ TouchPoint { id: touch2 },
+ TouchPoint { id: touch11 },
+ TouchPoint { id: touch21 },
+ TouchPoint { id: touch31 }
+ ]
+ }
+
+ ParticleFlame {
+ color: "red"
+ x: touch1.x
+ y: touch1.y
+ emitting: touch1.pressed
+ }
+ ParticleFlame {
+ color: "green"
+ x: touch2.x
+ y: touch2.y
+ emitting: touch2.pressed
+ }
+ ParticleFlame {
+ color: "yellow"
+ x: touch11.x
+ y: touch11.y
+ emitting: touch11.pressed
+ }
+ ParticleFlame {
+ color: "blue"
+ x: touch21.x
+ y: touch21.y
+ emitting: touch21.pressed
+ }
+ ParticleFlame {
+ color: "violet"
+ x: touch31.x
+ y: touch31.y
+ emitting: touch31.pressed
+ }
+}
diff --git a/examples/quick/touchinteraction/pincharea/flickresize.qml b/examples/quick/touchinteraction/pincharea/flickresize.qml
new file mode 100644
index 0000000000..037766e4a0
--- /dev/null
+++ b/examples/quick/touchinteraction/pincharea/flickresize.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 640
+ height: 360
+ color: "gray"
+
+ Flickable {
+ id: flick
+ anchors.fill: parent
+ contentWidth: 500
+ contentHeight: 500
+
+ PinchArea {
+ width: Math.max(flick.contentWidth, flick.width)
+ height: Math.max(flick.contentHeight, flick.height)
+
+ property real initialWidth
+ property real initialHeight
+ onPinchStarted: {
+ initialWidth = flick.contentWidth
+ initialHeight = flick.contentHeight
+ }
+
+ onPinchUpdated: {
+ // adjust content pos due to drag
+ flick.contentX += pinch.previousCenter.x - pinch.center.x
+ flick.contentY += pinch.previousCenter.y - pinch.center.y
+
+ // resize content
+ flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center)
+ }
+
+ onPinchFinished: {
+ // Move its content within bounds.
+ flick.returnToBounds()
+ }
+
+ Rectangle {
+ width: flick.contentWidth
+ height: flick.contentHeight
+ color: "white"
+ Image {
+ anchors.fill: parent
+ source: "qt-logo.jpg"
+ MouseArea {
+ anchors.fill: parent
+ onDoubleClicked: {
+ flick.contentWidth = 500
+ flick.contentHeight = 500
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/touchinteraction/pincharea/qt-logo.jpg b/examples/quick/touchinteraction/pincharea/qt-logo.jpg
new file mode 100644
index 0000000000..4014b4659c
--- /dev/null
+++ b/examples/quick/touchinteraction/pincharea/qt-logo.jpg
Binary files differ
diff --git a/examples/qtquick/touchinteraction/touchinteraction.qml b/examples/quick/touchinteraction/touchinteraction.qml
index b4a930c495..b4a930c495 100644
--- a/examples/qtquick/touchinteraction/touchinteraction.qml
+++ b/examples/quick/touchinteraction/touchinteraction.qml
diff --git a/examples/quick/touchinteraction/touchinteraction.qmlproject b/examples/quick/touchinteraction/touchinteraction.qmlproject
new file mode 100644
index 0000000000..a9aa9d2e81
--- /dev/null
+++ b/examples/quick/touchinteraction/touchinteraction.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "touchinteraction.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro
index affc57ce1f..8ed66f8b66 100644
--- a/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro
+++ b/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -1,4 +1,4 @@
-QT += declarative quick
+QT += qml quick
HEADERS += piechart.h
SOURCES += piechart.cpp \
diff --git a/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro
index affc57ce1f..8ed66f8b66 100644
--- a/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro
+++ b/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro
@@ -1,4 +1,4 @@
-QT += declarative quick
+QT += qml quick
HEADERS += piechart.h
SOURCES += piechart.cpp \
diff --git a/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
index affc57ce1f..8ed66f8b66 100644
--- a/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
+++ b/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
@@ -1,4 +1,4 @@
-QT += declarative quick
+QT += qml quick
HEADERS += piechart.h
SOURCES += piechart.cpp \
diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
index 6724fa0375..23eb222ea3 100644
--- a/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
+++ b/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -1,4 +1,4 @@
-QT += declarative quick
+QT += qml quick
HEADERS += piechart.h \
pieslice.h
diff --git a/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
index 6724fa0375..23eb222ea3 100644
--- a/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
+++ b/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
@@ -1,4 +1,4 @@
-QT += declarative quick
+QT += qml quick
HEADERS += piechart.h \
pieslice.h
diff --git a/examples/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/tutorials/extending/chapter5-listproperties/piechart.cpp
index bfcb607e60..910916508e 100644
--- a/examples/tutorials/extending/chapter5-listproperties/piechart.cpp
+++ b/examples/tutorials/extending/chapter5-listproperties/piechart.cpp
@@ -56,12 +56,12 @@ void PieChart::setName(const QString &name)
}
//![0]
-QDeclarativeListProperty<PieSlice> PieChart::slices()
+QQmlListProperty<PieSlice> PieChart::slices()
{
- return QDeclarativeListProperty<PieSlice>(this, 0, &PieChart::append_slice);
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice);
}
-void PieChart::append_slice(QDeclarativeListProperty<PieSlice> *list, PieSlice *slice)
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
{
PieChart *chart = qobject_cast<PieChart *>(list->object);
if (chart) {
diff --git a/examples/tutorials/extending/chapter5-listproperties/piechart.h b/examples/tutorials/extending/chapter5-listproperties/piechart.h
index 9beabda5f3..6c17bc1258 100644
--- a/examples/tutorials/extending/chapter5-listproperties/piechart.h
+++ b/examples/tutorials/extending/chapter5-listproperties/piechart.h
@@ -48,7 +48,7 @@ class PieSlice;
class PieChart : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<PieSlice> slices READ slices)
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
//![0]
Q_PROPERTY(QString name READ name WRITE setName)
@@ -61,10 +61,10 @@ public:
void setName(const QString &name);
//![2]
- QDeclarativeListProperty<PieSlice> slices();
+ QQmlListProperty<PieSlice> slices();
private:
- static void append_slice(QDeclarativeListProperty<PieSlice> *list, PieSlice *slice);
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
QString m_name;
QList<PieSlice *> m_slices;
diff --git a/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
index c243ec4572..75f88b2eaa 100644
--- a/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
+++ b/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
@@ -1,6 +1,6 @@
TEMPLATE = lib
CONFIG += qt plugin
-QT += declarative quick
+QT += qml quick
DESTDIR = ChartsPlugin
TARGET = chartsplugin
diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp
index d75f810964..0cead527b8 100644
--- a/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp
+++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp
@@ -41,7 +41,7 @@
//![0]
#include "piechart.h"
#include "pieslice.h"
-#include <qdeclarative.h>
+#include <qqml.h>
void ChartsPlugin::registerTypes(const char *uri)
{
diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/tutorials/extending/chapter6-plugins/chartsplugin.h
index 863564b09c..4db1b01987 100644
--- a/examples/tutorials/extending/chapter6-plugins/chartsplugin.h
+++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.h
@@ -41,12 +41,12 @@
#define CHARTSPLUGIN_H
//![0]
-#include <QDeclarativeExtensionPlugin>
+#include <QQmlExtensionPlugin>
-class ChartsPlugin : public QDeclarativeExtensionPlugin
+class ChartsPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "chartsplugin.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "chartsplugin.json")
public:
void registerTypes(const char *uri);
diff --git a/examples/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/tutorials/extending/chapter6-plugins/piechart.cpp
index 2a8f40289e..b188e39d81 100644
--- a/examples/tutorials/extending/chapter6-plugins/piechart.cpp
+++ b/examples/tutorials/extending/chapter6-plugins/piechart.cpp
@@ -55,12 +55,12 @@ void PieChart::setName(const QString &name)
m_name = name;
}
-QDeclarativeListProperty<PieSlice> PieChart::slices()
+QQmlListProperty<PieSlice> PieChart::slices()
{
- return QDeclarativeListProperty<PieSlice>(this, 0, &PieChart::append_slice);
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice);
}
-void PieChart::append_slice(QDeclarativeListProperty<PieSlice> *list, PieSlice *slice)
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
{
PieChart *chart = qobject_cast<PieChart *>(list->object);
if (chart) {
diff --git a/examples/tutorials/extending/chapter6-plugins/piechart.h b/examples/tutorials/extending/chapter6-plugins/piechart.h
index fe6b96afdc..2ee8108784 100644
--- a/examples/tutorials/extending/chapter6-plugins/piechart.h
+++ b/examples/tutorials/extending/chapter6-plugins/piechart.h
@@ -47,7 +47,7 @@ class PieSlice;
class PieChart : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<PieSlice> slices READ slices)
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
Q_PROPERTY(QString name READ name WRITE setName)
public:
@@ -56,10 +56,10 @@ public:
QString name() const;
void setName(const QString &name);
- QDeclarativeListProperty<PieSlice> slices();
+ QQmlListProperty<PieSlice> slices();
private:
- static void append_slice(QDeclarativeListProperty<PieSlice> *list, PieSlice *slice);
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
QString m_name;
QList<PieSlice *> m_slices;
diff --git a/examples/tutorials/gettingStartedQml/core/Button.qml b/examples/tutorials/gettingStartedQml/core/Button.qml
index 41be4134bd..9ea8c6dfff 100644
--- a/examples/tutorials/gettingStartedQml/core/Button.qml
+++ b/examples/tutorials/gettingStartedQml/core/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/core/EditMenu.qml b/examples/tutorials/gettingStartedQml/core/EditMenu.qml
index 7471669a37..dcac7bd29a 100644
--- a/examples/tutorials/gettingStartedQml/core/EditMenu.qml
+++ b/examples/tutorials/gettingStartedQml/core/EditMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/core/FileDialog.qml b/examples/tutorials/gettingStartedQml/core/FileDialog.qml
index 2d08e19bcf..0a4341b868 100644
--- a/examples/tutorials/gettingStartedQml/core/FileDialog.qml
+++ b/examples/tutorials/gettingStartedQml/core/FileDialog.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/core/FileMenu.qml b/examples/tutorials/gettingStartedQml/core/FileMenu.qml
index 67d747d8fb..a4be5eff15 100644
--- a/examples/tutorials/gettingStartedQml/core/FileMenu.qml
+++ b/examples/tutorials/gettingStartedQml/core/FileMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/core/MenuBar.qml b/examples/tutorials/gettingStartedQml/core/MenuBar.qml
index 68e25899e3..8d7be29fdd 100644
--- a/examples/tutorials/gettingStartedQml/core/MenuBar.qml
+++ b/examples/tutorials/gettingStartedQml/core/MenuBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/core/TextArea.qml b/examples/tutorials/gettingStartedQml/core/TextArea.qml
index 2ca145260c..99fb5ca60c 100644
--- a/examples/tutorials/gettingStartedQml/core/TextArea.qml
+++ b/examples/tutorials/gettingStartedQml/core/TextArea.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp
index 626ef93adc..776af5629b 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp
+++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -41,7 +41,7 @@
#include "dialogPlugin.h"
#include "directory.h"
#include "file.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
void DialogPlugin::registerTypes(const char *uri)
{
diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h
index 7ad707f6d9..fcaa210457 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h
+++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -41,15 +41,15 @@
#ifndef DIALOGPLUGIN_H
#define DIALOGPLUGIN_H
-#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtQml/QQmlExtensionPlugin>
-class DialogPlugin : public QDeclarativeExtensionPlugin
+class DialogPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "dialogplugin.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "dialogplugin.json")
public:
- //registerTypes is inherited from QDeclarativeExtensionPlugin
+ //registerTypes is inherited from QQmlExtensionPlugin
void registerTypes(const char *uri);
};
diff --git a/examples/tutorials/gettingStartedQml/filedialog/directory.cpp b/examples/tutorials/gettingStartedQml/filedialog/directory.cpp
index 3253327cb4..eadc11e52f 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/directory.cpp
+++ b/examples/tutorials/gettingStartedQml/filedialog/directory.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -72,7 +72,7 @@ int Directory::filesCount() const
/*
Function called to append data onto list property
*/
-void appendFiles(QDeclarativeListProperty<File> * property, File * file)
+void appendFiles(QQmlListProperty<File> * property, File * file)
{
Q_UNUSED(property);
Q_UNUSED(file);
@@ -82,7 +82,7 @@ void appendFiles(QDeclarativeListProperty<File> * property, File * file)
/*
Function called to retrieve file in the list using an index
*/
-File* fileAt(QDeclarativeListProperty<File> * property, int index)
+File* fileAt(QQmlListProperty<File> * property, int index)
{
return static_cast< QList<File *> *>(property->data)->at(index);
}
@@ -90,7 +90,7 @@ File* fileAt(QDeclarativeListProperty<File> * property, int index)
/*
Returns the number of files in the list
*/
-int filesSize(QDeclarativeListProperty<File> * property)
+int filesSize(QQmlListProperty<File> * property)
{
return static_cast< QList<File *> *>(property->data)->size();
}
@@ -98,18 +98,18 @@ int filesSize(QDeclarativeListProperty<File> * property)
/*
Function called to empty the list property contents
*/
-void clearFilesPtr(QDeclarativeListProperty<File> *property)
+void clearFilesPtr(QQmlListProperty<File> *property)
{
return static_cast< QList<File *> *>(property->data)->clear();
}
/*
-Returns the list of files as a QDeclarativeListProperty.
+Returns the list of files as a QQmlListProperty.
*/
-QDeclarativeListProperty<File> Directory::files()
+QQmlListProperty<File> Directory::files()
{
refresh();
- return QDeclarativeListProperty<File>( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr );
+ return QQmlListProperty<File>( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr );
}
/*
diff --git a/examples/tutorials/gettingStartedQml/filedialog/directory.h b/examples/tutorials/gettingStartedQml/filedialog/directory.h
index 04317707c3..30d6751bd2 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/directory.h
+++ b/examples/tutorials/gettingStartedQml/filedialog/directory.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -46,7 +46,7 @@
#include <QDir>
#include <QStringList>
#include <QTextStream>
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
#include <QObject>
class Directory : public QObject {
@@ -57,7 +57,7 @@ class Directory : public QObject {
Q_PROPERTY(int filesCount READ filesCount)
//list property containing file names as QString
- Q_PROPERTY(QDeclarativeListProperty<File> files READ files CONSTANT )
+ Q_PROPERTY(QQmlListProperty<File> files READ files CONSTANT )
//file name of the text file to read/write
Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
@@ -72,7 +72,7 @@ class Directory : public QObject {
int filesCount() const;
QString filename() const;
QString fileContent() const;
- QDeclarativeListProperty<File> files();
+ QQmlListProperty<File> files();
//properties' write functions
void setFilename(const QString &str);
diff --git a/examples/tutorials/gettingStartedQml/filedialog/file.cpp b/examples/tutorials/gettingStartedQml/filedialog/file.cpp
index 120486315b..e3b22027f5 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/file.cpp
+++ b/examples/tutorials/gettingStartedQml/filedialog/file.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/filedialog/file.h b/examples/tutorials/gettingStartedQml/filedialog/file.h
index 6b8806ee32..d13638b414 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/file.h
+++ b/examples/tutorials/gettingStartedQml/filedialog/file.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro b/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro
index d85787d00c..85edb40257 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro
+++ b/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro
@@ -1,6 +1,6 @@
TEMPLATE = lib
CONFIG += qt plugin
-QT += declarative
+QT += qml
DESTDIR += ../plugins
OBJECTS_DIR = tmp
diff --git a/examples/tutorials/gettingStartedQml/parts/part0/Button.qml b/examples/tutorials/gettingStartedQml/parts/part0/Button.qml
index 3097a7615c..6cae3f3ab3 100644
--- a/examples/tutorials/gettingStartedQml/parts/part0/Button.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part0/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part1/Button.qml b/examples/tutorials/gettingStartedQml/parts/part1/Button.qml
index 70f7508de3..118e6fc4d3 100644
--- a/examples/tutorials/gettingStartedQml/parts/part1/Button.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part1/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml
index 5d14fc4f69..231a20a3a2 100644
--- a/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml
index ddb6df438c..c36f6d4734 100644
--- a/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml b/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml
index e0f377cfe5..f43a56ea7a 100644
--- a/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part2/Button.qml b/examples/tutorials/gettingStartedQml/parts/part2/Button.qml
index 65660b0cc1..aa178f8bf9 100644
--- a/examples/tutorials/gettingStartedQml/parts/part2/Button.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part2/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml
index 2a4c0a2834..fb2db7ade3 100644
--- a/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml
index 3f60bc6c2a..b715298147 100644
--- a/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml
index 99151ff9b0..408b561022 100644
--- a/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part3/Button.qml b/examples/tutorials/gettingStartedQml/parts/part3/Button.qml
index 65660b0cc1..aa178f8bf9 100644
--- a/examples/tutorials/gettingStartedQml/parts/part3/Button.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part3/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml
index 2a4c0a2834..fb2db7ade3 100644
--- a/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml
index 3f60bc6c2a..b715298147 100644
--- a/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml
index 99151ff9b0..408b561022 100644
--- a/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml
index faee31e97c..279ae045c3 100644
--- a/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml
index c14437dcd0..54fa115aec 100644
--- a/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part4/Button.qml b/examples/tutorials/gettingStartedQml/parts/part4/Button.qml
index 5572989f5d..7fb4f1e536 100644
--- a/examples/tutorials/gettingStartedQml/parts/part4/Button.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part4/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml
index 07282733f7..cdfbd30a06 100644
--- a/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml
index 1aa98a9498..a1d95bf87a 100644
--- a/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml
index ba1697f6f8..024c60f87c 100644
--- a/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml b/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml
index 11864d337e..0216131819 100644
--- a/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml
index b3b1e07294..de664a15fd 100644
--- a/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml
index 13735b35c9..43a6bc0eea 100644
--- a/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml
index b517971c55..50501ddadc 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml
index 628af3a835..f6dd54ac9a 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml
index a92e51eb94..fe4bbf4cb2 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml
index eeea0d2304..af83ef5e63 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml
index 2a33a30d43..57555010b6 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml
index 81898ea86b..4a13f59dac 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml
index 0d77c30317..0882633c59 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml
+++ b/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp
index e4692b0a47..bd5c3f7428 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp
+++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -41,7 +41,7 @@
#include "dialogPlugin.h"
#include "directory.h"
#include "file.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
void DialogPlugin::registerTypes(const char *uri){
@@ -49,7 +49,7 @@ void DialogPlugin::registerTypes(const char *uri){
qmlRegisterType<Directory>(uri, 1, 0, "Directory");
qmlRegisterType<File>(uri,1,0,"File");
- //qRegisterMetaType<QDeclarativeListProperty<QString> > ("QDeclarativeListProperty<QString>");
+ //qRegisterMetaType<QQmlListProperty<QString> > ("QQmlListProperty<QString>");
}
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h
index b46d252616..8d5459a543 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h
+++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -41,14 +41,14 @@
#ifndef DIALOGPLUGIN_H
#define DIALOGPLUGIN_H
-#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtQml/QQmlExtensionPlugin>
-class DialogPlugin : public QDeclarativeExtensionPlugin
+class DialogPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
public:
- //registerTypes is inherited from QDeclarativeExtensionPlugin
+ //registerTypes is inherited from QQmlExtensionPlugin
void registerTypes(const char *uri);
};
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp
index b2984d3c2d..2247360017 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp
+++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -74,39 +74,39 @@ int Directory:: filesCount() const{
/*
Function called to append data onto list property
*/
-void appendFiles(QDeclarativeListProperty<File> * property, File * file){
+void appendFiles(QQmlListProperty<File> * property, File * file){
//Do nothing. can't add to a directory using this method
}
/*
Function called to retrieve file in the list using an index
*/
-File* fileAt(QDeclarativeListProperty<File> * property, int index){
+File* fileAt(QQmlListProperty<File> * property, int index){
return static_cast< QList<File *> *>(property->data)->at(index);
}
/*
Returns the number of files in the list
*/
-int filesSize(QDeclarativeListProperty<File> * property){
+int filesSize(QQmlListProperty<File> * property){
return static_cast< QList<File *> *>(property->data)->size();
}
/*
Function called to empty the list property contents
*/
-void clearFilesPtr(QDeclarativeListProperty<File> *property){
+void clearFilesPtr(QQmlListProperty<File> *property){
return static_cast< QList<File *> *>(property->data)->clear();
}
/*
-Returns the list of files as a QDeclarativeListProperty.
+Returns the list of files as a QQmlListProperty.
*/
-QDeclarativeListProperty<File> Directory::files(){
+QQmlListProperty<File> Directory::files(){
refresh();
-// return QDeclarativeListProperty<QString>(this,m_filePtrList); //not recommended in the docs
- return QDeclarativeListProperty<File>( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr );
+// return QQmlListProperty<QString>(this,m_filePtrList); //not recommended in the docs
+ return QQmlListProperty<File>( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr );
}
/*
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h
index 53872f257b..a47e9e112f 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h
+++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -46,7 +46,7 @@
#include <QDir>
#include <QStringList>
#include <QTextStream>
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
#include <QObject>
class Directory : public QObject{
@@ -57,7 +57,7 @@ class Directory : public QObject{
Q_PROPERTY(int filesCount READ filesCount)
//list property containing file names as QString
- Q_PROPERTY(QDeclarativeListProperty<File> files READ files CONSTANT )
+ Q_PROPERTY(QQmlListProperty<File> files READ files CONSTANT )
//file name of the text file to read/write
Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
@@ -72,7 +72,7 @@ class Directory : public QObject{
int filesCount() const;
QString filename() const;
QString fileContent() const;
- QDeclarativeListProperty<File> files();
+ QQmlListProperty<File> files();
//properties' write functions
void setFilename(const QString &str);
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp
index c1b57297cf..2385ed3240 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp
+++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h
index d57595607c..251b45282d 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h
+++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro
index 6247747003..71abddc7e3 100644
--- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro
+++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro
@@ -1,6 +1,6 @@
TEMPLATE = lib
CONFIG += qt plugin
-QT += declarative
+QT += qml
DESTDIR += ../plugins
OBJECTS_DIR = tmp
diff --git a/examples/tutorials/gettingStartedQml/texteditor.qml b/examples/tutorials/gettingStartedQml/texteditor.qml
index 76d79b6b90..05358294f5 100644
--- a/examples/tutorials/gettingStartedQml/texteditor.qml
+++ b/examples/tutorials/gettingStartedQml/texteditor.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
diff --git a/examples/window/window.cpp b/examples/window/window.cpp
index 4854256190..2112ab8f45 100644
--- a/examples/window/window.cpp
+++ b/examples/window/window.cpp
@@ -39,16 +39,16 @@
****************************************************************************/
#include <QtGui/QGuiApplication>
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QtDeclarative/QDeclarativeComponent>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlComponent>
#include <QtCore/QUrl>
#include <QDebug>
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
component.loadUrl(QUrl::fromLocalFile("Window.qml"));
if ( component.isReady() )
component.create();
diff --git a/examples/window/window.pro b/examples/window/window.pro
index 74804bd776..c4518418f6 100644
--- a/examples/window/window.pro
+++ b/examples/window/window.pro
@@ -1,5 +1,5 @@
TEMPLATE = app
CONFIG += qt
-QT += declarative
+QT += qml
SOURCES += window.cpp
diff --git a/modules/qt_declarative.pri b/modules/qt_declarative.pri
index 54727d462a..619f562f49 100644
--- a/modules/qt_declarative.pri
+++ b/modules/qt_declarative.pri
@@ -4,14 +4,189 @@ QT.declarative.MINOR_VERSION = 0
QT.declarative.PATCH_VERSION = 0
QT.declarative.name = QtDeclarative
-QT.declarative.bins = $$QT_MODULE_BIN_BASE
QT.declarative.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtDeclarative
QT.declarative.private_includes = $$QT_MODULE_INCLUDE_BASE/QtDeclarative/$$QT.declarative.VERSION
QT.declarative.sources = $$QT_MODULE_BASE/src/declarative
-QT.declarative.libs = $$QT_MODULE_LIB_BASE
QT.declarative.plugins = $$QT_MODULE_PLUGIN_BASE
QT.declarative.imports = $$QT_MODULE_IMPORT_BASE
QT.declarative.depends = gui network xmlpatterns
-QT.declarative.DEFINES = QT_DECLARATIVE_LIB
+QT.declarative.DEFINES = \
+ QDeclarativeAbstractAnimation=QQuickAbstractAnimation\
+ QDeclarativeAbstractBinding=QQmlAbstractBinding\
+ QDeclarativeAbstractBoundSignal=QQmlAbstractBoundSignal\
+ QDeclarativeAccessible=QQmlAccessible\
+ QDeclarativeAccessibleAttached=QQmlAccessibleAttached\
+ QDeclarativeAccessorProperties=QQmlAccessorProperties\
+ QDeclarativeAction=QQuickAction\
+ QDeclarativeActionEvent=QQuickActionEvent\
+ QDeclarativeAnimationGroup=QQuickAnimationGroup\
+ QDeclarativeAnimationPropertyUpdater=QQuickAnimationPropertyUpdater\
+ QDeclarativeApplication=QQuickApplication\
+ QDeclarativeBehavior=QQuickBehavior\
+ QDeclarativeBind=QQuickBind\
+ QDeclarativeBinding=QQmlBinding\
+ QDeclarativeBindingProfiler=QQmlBindingProfiler\
+ QDeclarativeBoundSignal=QQmlBoundSignal\
+ QDeclarativeBuiltinFunctions=QQmlBuiltinFunctions\
+ QDeclarativeBulkValueAnimator=QQuickBulkValueAnimator\
+ QDeclarativeChangeSet=QQuickChangeSet\
+ QDeclarativeCleanup=QQmlCleanup\
+ QDeclarativeColorAnimation=QQuickColorAnimation\
+ QDeclarativeColorValueType=QQmlColorValueType\
+ QDeclarativeCompiledData=QQmlCompiledData\
+ QDeclarativeCompiler=QQmlCompiler\
+ QDeclarativeCompilerTypes=QQmlCompilerTypes\
+ QDeclarativeComponent=QQmlComponent\
+ QDeclarativeComponentAttached=QQmlComponentAttached\
+ QDeclarativeComponentPrivate=QQmlComponentPrivate\
+ QDeclarativeConnections=QQuickConnections\
+ QDeclarativeContext=QQmlContext\
+ QDeclarativeContextData=QQmlContextData\
+ QDeclarativeCurve=QQuickCurve\
+ QDeclarativeCustomParser=QQmlCustomParser\
+ QDeclarativeCustomParserNode=QQmlCustomParserNode\
+ QDeclarativeCustomParserProperty=QQmlCustomParserProperty\
+ QDeclarativeData=QQmlData\
+ QDeclarativeDataBlob=QQmlDataBlob\
+ QDeclarativeDataLoader=QQmlDataLoader\
+ QDeclarativeDebug=QQmlDebug\
+ QDeclarativeDebugClient=QQmlDebugClient\
+ QDeclarativeDebugConnection=QQmlDebugConnection\
+ QDeclarativeDebugContextReference=QQmlDebugContextReference\
+ QDeclarativeDebugData=QQmlDebugData\
+ QDeclarativeDebugEngineReference=QQmlDebugEngineReference\
+ QDeclarativeDebugEnginesQuery=QQmlDebugEnginesQuery\
+ QDeclarativeDebugExpressionQuery=QQmlDebugExpressionQuery\
+ QDeclarativeDebugFileReference=QQmlDebugFileReference\
+ QDeclarativeDebuggingEnabler=QQmlDebuggingEnabler\
+ QDeclarativeDebugHelper=QQmlDebugHelper\
+ QDeclarativeDebugObjectExpressionWatch=QQmlDebugObjectExpressionWatch\
+ QDeclarativeDebugObjectQuery=QQmlDebugObjectQuery\
+ QDeclarativeDebugObjectReference=QQmlDebugObjectReference\
+ QDeclarativeDebugPropertyReference=QQmlDebugPropertyReference\
+ QDeclarativeDebugPropertyWatch=QQmlDebugPropertyWatch\
+ QDeclarativeDebugQuery=QQmlDebugQuery\
+ QDeclarativeDebugRootContextQuery=QQmlDebugRootContextQuery\
+ QDeclarativeDebugServer=QQmlDebugServer\
+ QDeclarativeDebugServerConnection=QQmlDebugServerConnection\
+ QDeclarativeDebugService=QQmlDebugService\
+ QDeclarativeDebugTrace=QQmlDebugTrace\
+ QDeclarativeDebugWatch=QQmlDebugWatch\
+ QDeclarativeEasingValueType=QQmlEasingValueType\
+ QDeclarativeEngine=QQmlEngine\
+ QDeclarativeEngineDebug=QQmlEngineDebug\
+ QDeclarativeEngineDebugService=QQmlEngineDebugService\
+ QDeclarativeEnginePrivate=QQmlEnginePrivate\
+ QDeclarativeError=QQmlError\
+ QDeclarativeExpression=QQmlExpression\
+ QDeclarativeExpressionPrivate=QQmlExpressionPrivate\
+ QDeclarativeExtensionInterface=QQmlExtensionInterface\
+ QDeclarativeExtensionPlugin=QQmlExtensionPlugin\
+ QDeclarativeFontLoader=QQuickFontLoader\
+ QDeclarativeFontValueType=QQmlFontValueType\
+ QDeclarativeGuard=QQmlGuard\
+ QDeclarativeImageProvider=QQmlImageProvider\
+ QDeclarativeImports=QQmlImports\
+ QDeclarativeIncubationController=QQmlIncubationController\
+ QDeclarativeIncubator=QQmlIncubator\
+ QDeclarativeInfo=QQmlInfo\
+ QDeclarativeInspector=QQmlInspector\
+ QDeclarativeInspectorInterface=QQmlInspectorInterface\
+ QDeclarativeInspectorService=QQmlInspectorService\
+ QDeclarativeInstruction=QQmlInstruction\
+ QDeclarativeJS=QQmlJS\
+ QDeclarativeListAccessor=QQuickListAccessor\
+ QDeclarativeListCompositor=QQuickListCompositor\
+ QDeclarativeListModel=QQuickListModel\
+ QDeclarativeListModelWorkerAgent=QQuickListModelWorkerAgent\
+ QDeclarativeListProperty=QQmlListProperty\
+ QDeclarativeListReference=QQmlListReference\
+ QDeclarativeLocale=QQmlLocale\
+ QDeclarativeMatrix4x4ValueType=QQmlMatrix4x4ValueType\
+ QDeclarativeMetaType=QQmlMetaType\
+ QDeclarativeNetworkAccessManagerFactory=QQmlNetworkAccessManagerFactory\
+ QDeclarativeNotifier=QQmlNotifier\
+ QDeclarativeNullableValue=QQmlNullableValue\
+ QDeclarativeNumberAnimation=QQuickNumberAnimation\
+ QDeclarativeOpenMetaObject=QQmlOpenMetaObject\
+ QDeclarativeOpenMetaObjectType=QQmlOpenMetaObjectType\
+ QDeclarativePackage=QQuickPackage\
+ QDeclarativeParser=QQmlParser\
+ QDeclarativeParserStatus=QQmlParserStatus\
+ QDeclarativePath=QQuickPath\
+ QDeclarativePathArc=QQuickPathArc\
+ QDeclarativePathAttribute=QQuickPathAttribute\
+ QDeclarativePathCatmullRomCurve=QQuickPathCatmullRomCurve\
+ QDeclarativePathCubic=QQuickPathCubic\
+ QDeclarativePathElement=QQuickPathElement\
+ QDeclarativePathInterpolator=QQuickPathInterpolator\
+ QDeclarativePathLine=QQuickPathLine\
+ QDeclarativePathPercent=QQuickPathPercent\
+ QDeclarativePathQuad=QQuickPathQuad\
+ QDeclarativePathSvg=QQuickPathSvg\
+ QDeclarativePauseAnimation=QQuickPauseAnimation\
+ QDeclarativePixmap=QQuickPixmap\
+ QDeclarativePointFValueType=QQmlPointFValueType\
+ QDeclarativePointValueType=QQmlPointValueType\
+ QDeclarativePool=QQmlPool\
+ QDeclarativePrivate=QQmlPrivate\
+ QDeclarativeProperty=QQmlProperty\
+ QDeclarativePropertyAnimation=QQuickPropertyAnimation\
+ QDeclarativePropertyCache=QQmlPropertyCache\
+ QDeclarativePropertyChanges=QQuickPropertyChanges\
+ QDeclarativePropertyMap=QQmlPropertyMap\
+ QDeclarativePropertyPrivate=QQmlPropertyPrivate\
+ QDeclarativePropertyValueInterceptor=QQmlPropertyValueInterceptor\
+ QDeclarativePropertyValueSource=QQmlPropertyValueSource\
+ QDeclarativeQmldirData=QQmlQmldirData\
+ QDeclarativeQtQuick1Module=QQmlQtQuick1Module\
+ QDeclarativeQtQuick2Module=QQmlQtQuick2Module\
+ QDeclarativeQuaternionValueType=QQmlQuaternionValueType\
+ QDeclarativeRectFValueType=QQmlRectFValueType\
+ QDeclarativeRectValueType=QQmlRectValueType\
+ QDeclarativeRewrite=QQmlRewrite\
+ QDeclarativeRotationAnimation=QQuickRotationAnimation\
+ QDeclarativeScript=QQmlScript\
+ QDeclarativeScriptAction=QQuickScriptAction\
+ QDeclarativeScriptBlob=QQmlScriptBlob\
+ QDeclarativeStringConverters=QQmlStringConverters\
+ QDeclarativeScriptData=QQmlScriptData\
+ QDeclarativeScriptString=QQmlScriptString\
+ QDeclarativeSizeFValueType=QQmlSizeFValueType\
+ QDeclarativeSizeValueType=QQmlSizeValueType\
+ QDeclarativeSmoothedAnimation=QQuickSmoothedAnimation\
+ QDeclarativeSpringAnimation=QQuickSpringAnimation\
+ QDeclarativeState=QQuickState\
+ QDeclarativeStateChangeScript=QQuickStateChangeScript\
+ QDeclarativeStateGroup=QQuickStateGroup\
+ QDeclarativeStateOperation=QQuickStateOperation\
+ QDeclarativeStyledText=QQuickStyledText\
+ QDeclarativeStyledTextImgTag=QQuickStyledTextImgTag\
+ QDeclarativeSvgParser=QQmlSvgParser\
+ QDeclarativeSystemPalette=QQuickSystemPalette\
+ QDeclarativeTextureFactory=QQuickTextureFactory\
+ QDeclarativeTimeLine=QQuickTimeLine\
+ QDeclarativeTimeLineCallback=QQuickTimeLineCallback\
+ QDeclarativeTimeLineObject=QQuickTimeLineObject\
+ QDeclarativeTimeLineValue=QQuickTimeLineValue\
+ QDeclarativeTimer=QQuickTimer\
+ QDeclarativeTransition=QQuickTransition\
+ QDeclarativeTransitionManager=QQuickTransitionManager\
+ QDeclarativeType=QQmlType\
+ QDeclarativeTypeData=QQmlTypeData\
+ QDeclarativeTypeLoader=QQmlTypeLoader\
+ QDeclarativeTypesExtensionInterface=QQmlTypesExtensionInterface\
+ QDeclarativeV8Function=QQmlV8Function\
+ QDeclarativeValueType=QQmlValueType\
+ QDeclarativeValueTypeFactory=QQmlValueTypeFactory\
+ QDeclarativeVector2DValueType=QQmlVector2DValueType\
+ QDeclarativeVector3dAnimation=QQuickVector3dAnimation\
+ QDeclarativeVector3DValueType=QQmlVector3DValueType\
+ QDeclarativeVector4DValueType=QQmlVector4DValueType\
+ QDeclarativeVME=QQmlVME\
+ QDeclarativeVMEMetaObject=QQmlVMEMetaObject\
+ QDeclarativeVMETypes=QQmlVMETypes\
+ QDeclarativeWorkerScript=QQuickWorkerScript\
+ QDeclarativeXmlListModel=QQuickXmlListModel
QT_CONFIG += declarative
diff --git a/modules/qt_qml.pri b/modules/qt_qml.pri
new file mode 100644
index 0000000000..82e70e3e93
--- /dev/null
+++ b/modules/qt_qml.pri
@@ -0,0 +1,17 @@
+QT.qml.VERSION = 5.0.0
+QT.qml.MAJOR_VERSION = 5
+QT.qml.MINOR_VERSION = 0
+QT.qml.PATCH_VERSION = 0
+
+QT.qml.name = QtQml
+QT.qml.bins = $$QT_MODULE_BIN_BASE
+QT.qml.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtQml
+QT.qml.private_includes = $$QT_MODULE_INCLUDE_BASE/QtQml/$$QT.qml.VERSION
+QT.qml.sources = $$QT_MODULE_BASE/src/qml
+QT.qml.libs = $$QT_MODULE_LIB_BASE
+QT.qml.plugins = $$QT_MODULE_PLUGIN_BASE
+QT.qml.imports = $$QT_MODULE_IMPORT_BASE
+QT.qml.depends = gui network xmlpatterns
+QT.qml.DEFINES = QT_QML_LIB
+
+QT_CONFIG += qml
diff --git a/modules/qt_qmltest.pri b/modules/qt_qmltest.pri
index d00f621237..e3d747f700 100644
--- a/modules/qt_qmltest.pri
+++ b/modules/qt_qmltest.pri
@@ -11,7 +11,7 @@ QT.qmltest.sources = $$QT_MODULE_BASE/src/qmltest
QT.qmltest.libs = $$QT_MODULE_LIB_BASE
QT.qmltest.plugins = $$QT_MODULE_PLUGIN_BASE
QT.qmltest.imports = $$QT_MODULE_IMPORT_BASE
-QT.qmltest.depends = declarative testlib
+QT.qmltest.depends = qml testlib
QT.qmltest.DEFINES = QT_QMLTEST_LIB
QT_CONFIG += qmltest
diff --git a/modules/qt_quick.pri b/modules/qt_quick.pri
index 0dc827b732..dc71b31194 100644
--- a/modules/qt_quick.pri
+++ b/modules/qt_quick.pri
@@ -11,7 +11,7 @@ QT.quick.sources = $$QT_MODULE_BASE/src/quick
QT.quick.libs = $$QT_MODULE_LIB_BASE
QT.quick.plugins = $$QT_MODULE_PLUGIN_BASE
QT.quick.imports = $$QT_MODULE_IMPORT_BASE
-QT.quick.depends = declarative
+QT.quick.depends = qml
QT.quick.DEFINES = QT_QUICK_LIB
QT_CONFIG += quick
diff --git a/src/compatibility/compatibility.pro b/src/compatibility/compatibility.pro
new file mode 100644
index 0000000000..7dd6e43f75
--- /dev/null
+++ b/src/compatibility/compatibility.pro
@@ -0,0 +1,33 @@
+TARGET = QtDeclarative
+TEMPLATE = subdirs
+
+MODULE_PRI = ../../modules/qt_declarative.pri
+
+QT = qml
+
+pritarget.path = $$[QT_INSTALL_DATA]/mkspecs/modules
+pritarget.files = $$MODULE_PRI
+INSTALLS += pritarget
+
+#load up the headers info
+CONFIG += qt_install_headers
+HEADERS_PRI = ../../include/QtDeclarative/headers.pri
+include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI)
+
+INSTALL_HEADERS = $$SYNCQT.HEADER_FILES
+
+flat_headers.files = $$INSTALL_HEADERS
+flat_headers.path = $$[QT_INSTALL_HEADERS]/Qt
+INSTALLS += flat_headers
+
+class_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET
+class_headers.files = $$SYNCQT.HEADER_CLASSES
+INSTALLS += class_headers
+
+targ_headers.files = $$INSTALL_HEADERS
+targ_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET
+INSTALLS += targ_headers
+
+private_headers.files = $$SYNCQT.PRIVATE_HEADER_FILES
+private_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET/$${QT.declarative.VERSION}/$$TARGET/private
+INSTALLS += private_headers
diff --git a/src/declarative/animations/qabstractanimationjob.cpp b/src/declarative/animations/qabstractanimationjob.cpp
deleted file mode 100644
index 4d149ce99a..0000000000
--- a/src/declarative/animations/qabstractanimationjob.cpp
+++ /dev/null
@@ -1,544 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qthreadstorage.h>
-
-#include "private/qabstractanimationjob_p.h"
-#include "private/qanimationgroupjob_p.h"
-#include "private/qanimationjobutil_p.h"
-
-#define DEFAULT_TIMER_INTERVAL 16
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_THREAD
-Q_GLOBAL_STATIC(QThreadStorage<QDeclarativeAnimationTimer *>, animationTimer)
-#endif
-
-QDeclarativeAnimationTimer::QDeclarativeAnimationTimer() :
- QAbstractAnimationTimer(), lastTick(0), lastDelta(0),
- currentAnimationIdx(0), insideTick(false),
- startAnimationPending(false), stopTimerPending(false),
- runningLeafAnimations(0)
-{
-}
-
-QDeclarativeAnimationTimer *QDeclarativeAnimationTimer::instance(bool create)
-{
- QDeclarativeAnimationTimer *inst;
-#ifndef QT_NO_THREAD
- if (create && !animationTimer()->hasLocalData()) {
- inst = new QDeclarativeAnimationTimer;
- animationTimer()->setLocalData(inst);
- } else {
- inst = animationTimer() ? animationTimer()->localData() : 0;
- }
-#else
- static QAnimationTimer unifiedTimer;
- inst = &unifiedTimer;
-#endif
- return inst;
-}
-
-QDeclarativeAnimationTimer *QDeclarativeAnimationTimer::instance()
-{
- return instance(true);
-}
-
-void QDeclarativeAnimationTimer::ensureTimerUpdate()
-{
- QDeclarativeAnimationTimer *inst = QDeclarativeAnimationTimer::instance(false);
- QUnifiedTimer *instU = QUnifiedTimer::instance(false);
- if (instU && inst && inst->isPaused)
- instU->updateAnimationTimers(-1);
-}
-
-void QDeclarativeAnimationTimer::updateAnimationsTime(qint64 delta)
-{
- //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations
- if (insideTick)
- return;
-
- lastTick += delta;
- lastDelta = delta;
-
- //we make sure we only call update time if the time has actually changed
- //it might happen in some cases that the time doesn't change because events are delayed
- //when the CPU load is high
- if (delta) {
- insideTick = true;
- for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
- QAbstractAnimationJob *animation = animations.at(currentAnimationIdx);
- int elapsed = animation->m_totalCurrentTime
- + (animation->direction() == QAbstractAnimationJob::Forward ? delta : -delta);
- animation->setCurrentTime(elapsed);
- }
- insideTick = false;
- currentAnimationIdx = 0;
- }
-}
-
-void QDeclarativeAnimationTimer::updateAnimationTimer()
-{
- QDeclarativeAnimationTimer *inst = QDeclarativeAnimationTimer::instance(false);
- if (inst)
- inst->restartAnimationTimer();
-}
-
-void QDeclarativeAnimationTimer::restartAnimationTimer()
-{
- if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty())
- QUnifiedTimer::pauseAnimationTimer(this, closestPauseAnimationTimeToFinish());
- else if (isPaused)
- QUnifiedTimer::resumeAnimationTimer(this);
- else if (!isRegistered)
- QUnifiedTimer::startAnimationTimer(this);
-}
-
-void QDeclarativeAnimationTimer::startAnimations()
-{
- startAnimationPending = false;
- //force timer to update, which prevents large deltas for our newly added animations
- if (!animations.isEmpty())
- QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime();
-
- //we transfer the waiting animations into the "really running" state
- animations += animationsToStart;
- animationsToStart.clear();
- if (!animations.isEmpty())
- restartAnimationTimer();
-}
-
-void QDeclarativeAnimationTimer::stopTimer()
-{
- stopTimerPending = false;
- if (animations.isEmpty()) {
- QUnifiedTimer::resumeAnimationTimer(this);
- QUnifiedTimer::stopAnimationTimer(this);
- // invalidate the start reference time
- lastTick = 0;
- lastDelta = 0;
- }
-}
-
-void QDeclarativeAnimationTimer::registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel)
-{
- QDeclarativeAnimationTimer *inst = instance(true); //we create the instance if needed
- inst->registerRunningAnimation(animation);
- if (isTopLevel) {
- Q_ASSERT(!animation->m_hasRegisteredTimer);
- animation->m_hasRegisteredTimer = true;
- inst->animationsToStart << animation;
- if (!inst->startAnimationPending) {
- inst->startAnimationPending = true;
- QMetaObject::invokeMethod(inst, "startAnimations", Qt::QueuedConnection);
- }
- }
-}
-
-void QDeclarativeAnimationTimer::unregisterAnimation(QAbstractAnimationJob *animation)
-{
- QDeclarativeAnimationTimer *inst = QDeclarativeAnimationTimer::instance(false);
- if (inst) {
- //at this point the unified timer should have been created
- //but it might also have been already destroyed in case the application is shutting down
-
- inst->unregisterRunningAnimation(animation);
-
- if (!animation->m_hasRegisteredTimer)
- return;
-
- int idx = inst->animations.indexOf(animation);
- if (idx != -1) {
- inst->animations.removeAt(idx);
- // this is needed if we unregister an animation while its running
- if (idx <= inst->currentAnimationIdx)
- --inst->currentAnimationIdx;
-
- if (inst->animations.isEmpty() && !inst->stopTimerPending) {
- inst->stopTimerPending = true;
- QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection);
- }
- } else {
- inst->animationsToStart.removeOne(animation);
- }
- }
- animation->m_hasRegisteredTimer = false;
-}
-
-void QDeclarativeAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animation)
-{
- if (animation->m_isGroup)
- return;
-
- if (animation->m_isPause) {
- runningPauseAnimations << animation;
- } else
- runningLeafAnimations++;
-}
-
-void QDeclarativeAnimationTimer::unregisterRunningAnimation(QAbstractAnimationJob *animation)
-{
- if (animation->m_isGroup)
- return;
-
- if (animation->m_isPause)
- runningPauseAnimations.removeOne(animation);
- else
- runningLeafAnimations--;
- Q_ASSERT(runningLeafAnimations >= 0);
-}
-
-int QDeclarativeAnimationTimer::closestPauseAnimationTimeToFinish()
-{
- int closestTimeToFinish = INT_MAX;
- for (int i = 0; i < runningPauseAnimations.size(); ++i) {
- QAbstractAnimationJob *animation = runningPauseAnimations.at(i);
- int timeToFinish;
-
- if (animation->direction() == QAbstractAnimationJob::Forward)
- timeToFinish = animation->duration() - animation->currentLoopTime();
- else
- timeToFinish = animation->currentLoopTime();
-
- if (timeToFinish < closestTimeToFinish)
- closestTimeToFinish = timeToFinish;
- }
- return closestTimeToFinish;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-QAbstractAnimationJob::QAbstractAnimationJob()
- : m_isPause(false)
- , m_isGroup(false)
- , m_loopCount(1)
- , m_group(0)
- , m_direction(QAbstractAnimationJob::Forward)
- , m_state(QAbstractAnimationJob::Stopped)
- , m_totalCurrentTime(0)
- , m_currentTime(0)
- , m_currentLoop(0)
- , m_hasRegisteredTimer(false)
- , m_uncontrolledFinishTime(-1)
- , m_wasDeleted(0)
- , m_nextSibling(0)
- , m_previousSibling(0)
-{
-}
-
-QAbstractAnimationJob::~QAbstractAnimationJob()
-{
- if (m_wasDeleted)
- *m_wasDeleted = true;
-
- //we can't call stop here. Otherwise we get pure virtual calls
- if (m_state != Stopped) {
- State oldState = m_state;
- m_state = Stopped;
- stateChanged(oldState, m_state);
- if (oldState == Running)
- QDeclarativeAnimationTimer::unregisterAnimation(this);
- }
-
- if (m_group)
- m_group->removeAnimation(this);
-}
-
-void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState)
-{
- if (m_state == newState)
- return;
-
- if (m_loopCount == 0)
- return;
-
- State oldState = m_state;
- int oldCurrentTime = m_currentTime;
- int oldCurrentLoop = m_currentLoop;
- Direction oldDirection = m_direction;
-
- // check if we should Rewind
- if ((newState == Paused || newState == Running) && oldState == Stopped) {
- //here we reset the time if needed
- //we don't call setCurrentTime because this might change the way the animation
- //behaves: changing the state or changing the current value
- m_totalCurrentTime = m_currentTime = (m_direction == Forward) ?
- 0 : (m_loopCount == -1 ? duration() : totalDuration());
- }
-
- m_state = newState;
- //(un)registration of the animation must always happen before calls to
- //virtual function (updateState) to ensure a correct state of the timer
- bool isTopLevel = !m_group || m_group->isStopped();
- if (oldState == Running) {
- if (newState == Paused && m_hasRegisteredTimer)
- QDeclarativeAnimationTimer::ensureTimerUpdate();
- //the animation, is not running any more
- QDeclarativeAnimationTimer::unregisterAnimation(this);
- } else if (newState == Running) {
- QDeclarativeAnimationTimer::registerAnimation(this, isTopLevel);
- }
-
- //starting an animation qualifies as a top level loop change
- if (newState == Running && oldState == Stopped && !m_group)
- topLevelAnimationLoopChanged();
-
- RETURN_IF_DELETED(updateState(newState, oldState));
-
- if (newState != m_state) //this is to be safe if updateState changes the state
- return;
-
- // Notify state change
- stateChanged(newState, oldState);
- if (newState != m_state) //this is to be safe if updateState changes the state
- return;
-
- switch (m_state) {
- case Paused:
- break;
- case Running:
- {
- // this ensures that the value is updated now that the animation is running
- if (oldState == Stopped) {
- if (isTopLevel) {
- // currentTime needs to be updated if pauseTimer is active
- QDeclarativeAnimationTimer::ensureTimerUpdate();
- setCurrentTime(m_totalCurrentTime);
- }
- }
- }
- break;
- case Stopped:
- // Leave running state.
- int dura = duration();
-
- if (dura == -1 || m_loopCount < 0
- || (oldDirection == Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * m_loopCount))
- || (oldDirection == Backward && oldCurrentTime == 0)) {
- finished();
- }
- break;
- }
-}
-
-void QAbstractAnimationJob::setDirection(Direction direction)
-{
- if (m_direction == direction)
- return;
-
- if (m_state == Stopped) {
- if (m_direction == Backward) {
- m_currentTime = duration();
- m_currentLoop = m_loopCount - 1;
- } else {
- m_currentTime = 0;
- m_currentLoop = 0;
- }
- }
-
- // the commands order below is important: first we need to setCurrentTime with the old direction,
- // then update the direction on this and all children and finally restart the pauseTimer if needed
- if (m_hasRegisteredTimer)
- QDeclarativeAnimationTimer::ensureTimerUpdate();
-
- m_direction = direction;
- updateDirection(direction);
-
- if (m_hasRegisteredTimer)
- // needed to update the timer interval in case of a pause animation
- QDeclarativeAnimationTimer::updateAnimationTimer();
-}
-
-void QAbstractAnimationJob::setLoopCount(int loopCount)
-{
- m_loopCount = loopCount;
-}
-
-int QAbstractAnimationJob::totalDuration() const
-{
- int dura = duration();
- if (dura <= 0)
- return dura;
- int loopcount = loopCount();
- if (loopcount < 0)
- return -1;
- return dura * loopcount;
-}
-
-void QAbstractAnimationJob::setCurrentTime(int msecs)
-{
- msecs = qMax(msecs, 0);
- // Calculate new time and loop.
- int dura = duration();
- int totalDura = dura <= 0 ? dura : ((m_loopCount < 0) ? -1 : dura * m_loopCount);
- if (totalDura != -1)
- msecs = qMin(totalDura, msecs);
- m_totalCurrentTime = msecs;
-
- // Update new values.
- int oldLoop = m_currentLoop;
- m_currentLoop = ((dura <= 0) ? 0 : (msecs / dura));
- if (m_currentLoop == m_loopCount) {
- //we're at the end
- m_currentTime = qMax(0, dura);
- m_currentLoop = qMax(0, m_loopCount - 1);
- } else {
- if (m_direction == Forward) {
- m_currentTime = (dura <= 0) ? msecs : (msecs % dura);
- } else {
- m_currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1;
- if (m_currentTime == dura)
- --m_currentLoop;
- }
- }
-
- if (m_currentLoop != oldLoop && !m_group) //### verify Running as well?
- topLevelAnimationLoopChanged();
-
- RETURN_IF_DELETED(updateCurrentTime(m_currentTime));
-
- if (m_currentLoop != oldLoop)
- currentLoopChanged(m_currentLoop);
-
- // All animations are responsible for stopping the animation when their
- // own end state is reached; in this case the animation is time driven,
- // and has reached the end.
- if ((m_direction == Forward && m_totalCurrentTime == totalDura)
- || (m_direction == Backward && m_totalCurrentTime == 0)) {
- stop();
- }
-}
-
-void QAbstractAnimationJob::start()
-{
- if (m_state == Running)
- return;
- setState(Running);
-}
-
-void QAbstractAnimationJob::stop()
-{
- if (m_state == Stopped)
- return;
- setState(Stopped);
-}
-
-void QAbstractAnimationJob::pause()
-{
- if (m_state == Stopped) {
- qWarning("QAbstractAnimationJob::pause: Cannot pause a stopped animation");
- return;
- }
-
- setState(Paused);
-}
-
-void QAbstractAnimationJob::resume()
-{
- if (m_state != Paused) {
- qWarning("QAbstractAnimationJob::resume: "
- "Cannot resume an animation that is not paused");
- return;
- }
- setState(Running);
-}
-
-void QAbstractAnimationJob::updateState(QAbstractAnimationJob::State newState,
- QAbstractAnimationJob::State oldState)
-{
- Q_UNUSED(oldState);
- Q_UNUSED(newState);
-}
-
-void QAbstractAnimationJob::updateDirection(QAbstractAnimationJob::Direction direction)
-{
- Q_UNUSED(direction);
-}
-
-void QAbstractAnimationJob::finished()
-{
- //TODO: update this code so it is valid to delete the animation in animationFinished
- for (int i = 0; i < changeListeners.count(); ++i) {
- const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i);
- if (change.types & QAbstractAnimationJob::Completion)
- change.listener->animationFinished(this);
- }
-
- if (m_group && (duration() == -1 || loopCount() < 0)) {
- //this is an uncontrolled animation, need to notify the group animation we are finished
- m_group->uncontrolledAnimationFinished(this);
- }
-}
-
-void QAbstractAnimationJob::stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState)
-{
- for (int i = 0; i < changeListeners.count(); ++i) {
- const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i);
- if (change.types & QAbstractAnimationJob::StateChange)
- change.listener->animationStateChanged(this, newState, oldState);
- }
-}
-
-void QAbstractAnimationJob::currentLoopChanged(int currentLoop)
-{
- Q_UNUSED(currentLoop);
- for (int i = 0; i < changeListeners.count(); ++i) {
- const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i);
- if (change.types & QAbstractAnimationJob::CurrentLoop)
- change.listener->animationCurrentLoopChanged(this);
- }
-}
-
-void QAbstractAnimationJob::addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes changes)
-{
- changeListeners.append(ChangeListener(listener, changes));
-}
-
-void QAbstractAnimationJob::removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes changes)
-{
- changeListeners.removeOne(ChangeListener(listener, changes));
-}
-
-
-QT_END_NAMESPACE
-
-//#include "moc_qabstractanimation2_p.cpp"
diff --git a/src/declarative/animations/qabstractanimationjob_p.h b/src/declarative/animations/qabstractanimationjob_p.h
deleted file mode 100644
index 675082f0b7..0000000000
--- a/src/declarative/animations/qabstractanimationjob_p.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTANIMATIONJOB_P_H
-#define QABSTRACTANIMATIONJOB_P_H
-
-#include <QtCore/QObject>
-#include <QtCore/private/qabstractanimation_p.h>
-#include "private/qpodvector_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QAnimationGroupJob;
-class QAnimationJobChangeListener;
-class Q_DECLARATIVE_EXPORT QAbstractAnimationJob
-{
- Q_DISABLE_COPY(QAbstractAnimationJob)
-public:
- enum Direction {
- Forward,
- Backward
- };
-
- enum State {
- Stopped,
- Paused,
- Running
- };
-
- QAbstractAnimationJob();
- virtual ~QAbstractAnimationJob();
-
- //definition
- inline QAnimationGroupJob *group() const {return m_group;}
-
- inline int loopCount() const {return m_loopCount;}
- void setLoopCount(int loopCount);
-
- int totalDuration() const;
- virtual int duration() const {return 0;}
-
- inline QAbstractAnimationJob::Direction direction() const {return m_direction;}
- void setDirection(QAbstractAnimationJob::Direction direction);
-
- //state
- inline int currentTime() const {return m_totalCurrentTime;}
- inline int currentLoopTime() const {return m_currentTime;}
- inline int currentLoop() const {return m_currentLoop;}
- inline QAbstractAnimationJob::State state() const {return m_state;}
- inline bool isRunning() { return m_state == Running; }
- inline bool isStopped() { return m_state == Stopped; }
- inline bool isPaused() { return m_state == Paused; }
-
- void setCurrentTime(int msecs);
-
- void start();
- void pause();
- void resume();
- void stop();
-
- enum ChangeType {
- Completion = 0x01,
- StateChange = 0x02,
- CurrentLoop = 0x04
- };
- Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
-
- void addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes);
- void removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes);
-
- QAbstractAnimationJob *nextSibling() const { return m_nextSibling; }
- QAbstractAnimationJob *previousSibling() const { return m_previousSibling; }
-
-protected:
- virtual void updateCurrentTime(int) {}
- virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
- virtual void updateDirection(QAbstractAnimationJob::Direction direction);
- virtual void topLevelAnimationLoopChanged() {}
-
- void setState(QAbstractAnimationJob::State state);
-
- void finished();
- void stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
- void currentLoopChanged(int currentLoop);
- void directionChanged(QAbstractAnimationJob::Direction);
-
- //definition
- bool m_isPause;
- bool m_isGroup;
- int m_loopCount;
- QAnimationGroupJob *m_group;
- QAbstractAnimationJob::Direction m_direction;
-
- //state
- QAbstractAnimationJob::State m_state;
- int m_totalCurrentTime;
- int m_currentTime;
- int m_currentLoop;
- bool m_hasRegisteredTimer;
- //records the finish time for an uncontrolled animation (used by animation groups)
- int m_uncontrolledFinishTime;
- bool *m_wasDeleted;
-
- struct ChangeListener {
- ChangeListener(QAnimationJobChangeListener *l, QAbstractAnimationJob::ChangeTypes t) : listener(l), types(t) {}
- QAnimationJobChangeListener *listener;
- QAbstractAnimationJob::ChangeTypes types;
- bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
- };
- QPODVector<ChangeListener,4> changeListeners;
-
- QAbstractAnimationJob *m_nextSibling;
- QAbstractAnimationJob *m_previousSibling;
-
- friend class QDeclarativeAnimationTimer;
- friend class QAnimationGroupJob;
-};
-
-class Q_AUTOTEST_EXPORT QAnimationJobChangeListener
-{
-public:
- virtual void animationFinished(QAbstractAnimationJob *) {}
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) {}
- virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) {}
-};
-
-class Q_DECLARATIVE_EXPORT QDeclarativeAnimationTimer : public QAbstractAnimationTimer
-{
- Q_OBJECT
-private:
- QDeclarativeAnimationTimer();
-
-public:
- static QDeclarativeAnimationTimer *instance();
- static QDeclarativeAnimationTimer *instance(bool create);
-
- static void registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel);
- static void unregisterAnimation(QAbstractAnimationJob *animation);
-
- /*
- this is used for updating the currentTime of all animations in case the pause
- timer is active or, otherwise, only of the animation passed as parameter.
- */
- static void ensureTimerUpdate();
-
- /*
- this will evaluate the need of restarting the pause timer in case there is still
- some pause animations running.
- */
- static void updateAnimationTimer();
-
- void restartAnimationTimer();
- void updateAnimationsTime(qint64 timeStep);
-
- int currentDelta() { return lastDelta; }
-
- //useful for profiling/debugging
- int runningAnimationCount() { return animations.count(); }
-
-private Q_SLOTS:
- void startAnimations();
- void stopTimer();
-
-private:
- qint64 lastTick;
- int lastDelta;
- int currentAnimationIdx;
- bool insideTick;
- bool startAnimationPending;
- bool stopTimerPending;
-
- QList<QAbstractAnimationJob*> animations, animationsToStart;
-
- // this is the count of running animations that are not a group neither a pause animation
- int runningLeafAnimations;
- QList<QAbstractAnimationJob*> runningPauseAnimations;
-
- void registerRunningAnimation(QAbstractAnimationJob *animation);
- void unregisterRunningAnimation(QAbstractAnimationJob *animation);
-
- int closestPauseAnimationTimeToFinish();
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractAnimationJob::ChangeTypes)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTANIMATIONJOB_P_H
diff --git a/src/declarative/animations/qanimationgroupjob.cpp b/src/declarative/animations/qanimationgroupjob.cpp
deleted file mode 100644
index 7e26f9778d..0000000000
--- a/src/declarative/animations/qanimationgroupjob.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "private/qanimationgroupjob_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QAnimationGroupJob::QAnimationGroupJob()
- : QAbstractAnimationJob(), m_firstChild(0), m_lastChild(0)
-{
- m_isGroup = true;
-}
-
-QAnimationGroupJob::~QAnimationGroupJob()
-{
- while (firstChild() != 0)
- delete firstChild();
-}
-
-void QAnimationGroupJob::topLevelAnimationLoopChanged()
-{
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
- animation->topLevelAnimationLoopChanged();
-}
-
-void QAnimationGroupJob::appendAnimation(QAbstractAnimationJob *animation)
-{
- if (QAnimationGroupJob *oldGroup = animation->m_group)
- oldGroup->removeAnimation(animation);
-
- Q_ASSERT(!animation->previousSibling() && !animation->nextSibling());
-
- if (m_lastChild)
- m_lastChild->m_nextSibling = animation;
- else
- m_firstChild = animation;
- animation->m_previousSibling = m_lastChild;
- m_lastChild = animation;
-
- animation->m_group = this;
- animationInserted(animation);
-}
-
-void QAnimationGroupJob::prependAnimation(QAbstractAnimationJob *animation)
-{
- if (QAnimationGroupJob *oldGroup = animation->m_group)
- oldGroup->removeAnimation(animation);
-
- Q_ASSERT(!previousSibling() && !nextSibling());
-
- if (m_firstChild)
- m_firstChild->m_previousSibling = animation;
- else
- m_lastChild = animation;
- animation->m_nextSibling = m_firstChild;
- m_firstChild = animation;
-
- animation->m_group = this;
- animationInserted(animation);
-}
-
-void QAnimationGroupJob::removeAnimation(QAbstractAnimationJob *animation)
-{
- Q_ASSERT(animation);
- Q_ASSERT(animation->m_group == this);
- QAbstractAnimationJob *prev = animation->previousSibling();
- QAbstractAnimationJob *next = animation->nextSibling();
-
- if (prev)
- prev->m_nextSibling = next;
- else
- m_firstChild = next;
-
- if (next)
- next->m_previousSibling = prev;
- else
- m_lastChild = prev;
-
- animation->m_previousSibling = 0;
- animation->m_nextSibling = 0;
-
- animation->m_group = 0;
- animationRemoved(animation, prev, next);
-}
-
-void QAnimationGroupJob::clear()
-{
- //### should this remove and delete, or just remove?
- while (firstChild() != 0)
- delete firstChild(); //removeAnimation(firstChild());
-}
-
-void QAnimationGroupJob::resetUncontrolledAnimationsFinishTime()
-{
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
- if (animation->duration() == -1 || animation->loopCount() < 0) {
- resetUncontrolledAnimationFinishTime(animation);
- }
- }
-}
-
-void QAnimationGroupJob::resetUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim)
-{
- setUncontrolledAnimationFinishTime(anim, -1);
-}
-
-void QAnimationGroupJob::setUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim, int time)
-{
- anim->m_uncontrolledFinishTime = time;
-}
-
-void QAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation)
-{
- Q_UNUSED(animation);
-}
-
-void QAnimationGroupJob::animationRemoved(QAbstractAnimationJob* anim, QAbstractAnimationJob* , QAbstractAnimationJob* )
-{
- resetUncontrolledAnimationFinishTime(anim);
- if (!firstChild()) {
- m_currentTime = 0;
- stop();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/animations/qanimationgroupjob_p.h b/src/declarative/animations/qanimationgroupjob_p.h
deleted file mode 100644
index d1917a5249..0000000000
--- a/src/declarative/animations/qanimationgroupjob_p.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QANIMATIONGROUPJOB_P_H
-#define QANIMATIONGROUPJOB_P_H
-
-#include "private/qabstractanimationjob_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QAnimationGroupJob : public QAbstractAnimationJob
-{
- Q_DISABLE_COPY(QAnimationGroupJob)
-public:
- QAnimationGroupJob();
- ~QAnimationGroupJob();
-
- void appendAnimation(QAbstractAnimationJob *animation);
- void prependAnimation(QAbstractAnimationJob *animation);
- void removeAnimation(QAbstractAnimationJob *animation);
-
- QAbstractAnimationJob *firstChild() const { return m_firstChild; }
- QAbstractAnimationJob *lastChild() const { return m_lastChild; }
-
- void clear();
-
- //called by QAbstractAnimationJob
- virtual void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
-protected:
- void topLevelAnimationLoopChanged();
-
- virtual void animationInserted(QAbstractAnimationJob*) { }
- virtual void animationRemoved(QAbstractAnimationJob*, QAbstractAnimationJob*, QAbstractAnimationJob*);
-
- //TODO: confirm location of these (should any be moved into QAbstractAnimationJob?)
- void resetUncontrolledAnimationsFinishTime();
- void resetUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim);
- int uncontrolledAnimationFinishTime(QAbstractAnimationJob *anim) const { return anim->m_uncontrolledFinishTime; }
- void setUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim, int time);
-
-private:
- //definition
- QAbstractAnimationJob *m_firstChild;
- QAbstractAnimationJob *m_lastChild;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QANIMATIONGROUPJOB_P_H
diff --git a/src/declarative/animations/qanimationjobutil_p.h b/src/declarative/animations/qanimationjobutil_p.h
deleted file mode 100644
index b8a627e2da..0000000000
--- a/src/declarative/animations/qanimationjobutil_p.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QANIMATIONJOBUTIL_P_H
-#define QANIMATIONJOBUTIL_P_H
-
-#define RETURN_IF_DELETED(func) \
-{ \
- bool *prevWasDeleted = m_wasDeleted; \
- bool wasDeleted = false; \
- m_wasDeleted = &wasDeleted; \
- func; \
- if (wasDeleted) { \
- if (prevWasDeleted) \
- *prevWasDeleted = true; \
- return; \
- } \
- m_wasDeleted = prevWasDeleted; \
-}
-
-#endif // QANIMATIONJOBUTIL_P_H
diff --git a/src/declarative/animations/qparallelanimationgroupjob.cpp b/src/declarative/animations/qparallelanimationgroupjob.cpp
deleted file mode 100644
index 5a417dccf4..0000000000
--- a/src/declarative/animations/qparallelanimationgroupjob.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "private/qparallelanimationgroupjob_p.h"
-#include "private/qanimationjobutil_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QParallelAnimationGroupJob::QParallelAnimationGroupJob()
- : QAnimationGroupJob()
- , m_previousLoop(0)
- , m_previousCurrentTime(0)
-{
-}
-
-QParallelAnimationGroupJob::~QParallelAnimationGroupJob()
-{
-}
-
-int QParallelAnimationGroupJob::duration() const
-{
- int ret = 0;
-
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
- int currentDuration = animation->totalDuration();
- //this takes care of the case where a parallel animation group has controlled and uncontrolled
- //animations, and the uncontrolled stop before the controlled
- if (currentDuration == -1)
- currentDuration = uncontrolledAnimationFinishTime(animation);
- if (currentDuration == -1)
- return -1; // Undetermined length
-
- ret = qMax(ret, currentDuration);
- }
-
- return ret;
-}
-
-void QParallelAnimationGroupJob::updateCurrentTime(int /*currentTime*/)
-{
- if (!firstChild())
- return;
-
- if (m_currentLoop > m_previousLoop) {
- // simulate completion of the loop
- int dura = duration();
- if (dura > 0) {
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
- if (!animation->isStopped())
- RETURN_IF_DELETED(animation->setCurrentTime(dura)); // will stop
- }
- }
- } else if (m_currentLoop < m_previousLoop) {
- // simulate completion of the loop seeking backwards
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
- //we need to make sure the animation is in the right state
- //and then rewind it
- applyGroupState(animation);
- RETURN_IF_DELETED(animation->setCurrentTime(0));
- animation->stop();
- }
- }
-
- // finally move into the actual time of the current loop
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
- const int dura = animation->totalDuration();
- //if the loopcount is bigger we should always start all animations
- if (m_currentLoop > m_previousLoop
- //if we're at the end of the animation, we need to start it if it wasn't already started in this loop
- //this happens in Backward direction where not all animations are started at the same time
- || shouldAnimationStart(animation, m_previousCurrentTime > dura /*startIfAtEnd*/)) {
- applyGroupState(animation);
- }
-
- if (animation->state() == state()) {
- RETURN_IF_DELETED(animation->setCurrentTime(m_currentTime));
- if (dura > 0 && m_currentTime > dura)
- animation->stop();
- }
- }
- m_previousLoop = m_currentLoop;
- m_previousCurrentTime = m_currentTime;
-}
-
-void QParallelAnimationGroupJob::updateState(QAbstractAnimationJob::State newState,
- QAbstractAnimationJob::State oldState)
-{
- QAnimationGroupJob::updateState(newState, oldState);
-
- switch (newState) {
- case Stopped:
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
- animation->stop();
- break;
- case Paused:
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
- if (animation->isRunning())
- animation->pause();
- break;
- case Running:
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
- if (oldState == Stopped)
- animation->stop();
- resetUncontrolledAnimationFinishTime(animation);
- animation->setDirection(m_direction);
- if (shouldAnimationStart(animation, oldState == Stopped))
- animation->start();
- }
- break;
- }
-}
-
-bool QParallelAnimationGroupJob::shouldAnimationStart(QAbstractAnimationJob *animation, bool startIfAtEnd) const
-{
- const int dura = animation->totalDuration();
-
- if (dura == -1)
- return uncontrolledAnimationFinishTime(animation) == -1;
-
- if (startIfAtEnd)
- return m_currentTime <= dura;
- if (m_direction == Forward)
- return m_currentTime < dura;
- else //direction == Backward
- return m_currentTime && m_currentTime <= dura;
-}
-
-void QParallelAnimationGroupJob::applyGroupState(QAbstractAnimationJob *animation)
-{
- switch (m_state)
- {
- case Running:
- animation->start();
- break;
- case Paused:
- animation->pause();
- break;
- case Stopped:
- default:
- break;
- }
-}
-
-void QParallelAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direction direction)
-{
- //we need to update the direction of the current animation
- if (!isStopped()) {
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
- animation->setDirection(direction);
- }
- } else {
- if (direction == Forward) {
- m_previousLoop = 0;
- m_previousCurrentTime = 0;
- } else {
- // Looping backwards with loopCount == -1 does not really work well...
- m_previousLoop = (m_loopCount == -1 ? 0 : m_loopCount - 1);
- m_previousCurrentTime = duration();
- }
- }
-}
-
-void QParallelAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation)
-{
- Q_ASSERT(animation && (animation->duration() == -1 || animation->loopCount() < 0));
- int uncontrolledRunningCount = 0;
-
- for (QAbstractAnimationJob *child = firstChild(); child; child = child->nextSibling()) {
- if (child == animation) {
- setUncontrolledAnimationFinishTime(animation, animation->currentTime());
- } else if (child->duration() == -1 || child->loopCount() < 0) {
- if (uncontrolledAnimationFinishTime(child) == -1)
- ++uncontrolledRunningCount;
- }
- }
-
- if (uncontrolledRunningCount > 0)
- return;
-
- int maxDuration = 0;
- for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
- maxDuration = qMax(maxDuration, animation->totalDuration());
-
- if (m_currentTime >= maxDuration)
- stop();
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/animations/qparallelanimationgroupjob_p.h b/src/declarative/animations/qparallelanimationgroupjob_p.h
deleted file mode 100644
index 42a96b50d5..0000000000
--- a/src/declarative/animations/qparallelanimationgroupjob_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPARALLELANIMATIONGROUPJOB_P_H
-#define QPARALLELANIMATIONGROUPJOB_P_H
-
-#include "private/qanimationgroupjob_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QParallelAnimationGroupJob : public QAnimationGroupJob
-{
- Q_DISABLE_COPY(QParallelAnimationGroupJob)
-public:
- QParallelAnimationGroupJob();
- ~QParallelAnimationGroupJob();
-
- int duration() const;
-
-protected:
- void updateCurrentTime(int currentTime);
- void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
- void updateDirection(QAbstractAnimationJob::Direction direction);
- void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
-
-private:
- bool shouldAnimationStart(QAbstractAnimationJob *animation, bool startIfAtEnd) const;
- void applyGroupState(QAbstractAnimationJob *animation);
-
- //state
- int m_previousLoop;
- int m_previousCurrentTime;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPARALLELANIMATIONGROUPJOB_P_H
diff --git a/src/declarative/animations/qpauseanimationjob.cpp b/src/declarative/animations/qpauseanimationjob.cpp
deleted file mode 100644
index c362f5ab58..0000000000
--- a/src/declarative/animations/qpauseanimationjob.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "private/qpauseanimationjob_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QPauseAnimationJob::QPauseAnimationJob(int duration)
- : QAbstractAnimationJob()
- , m_duration(duration)
-{
- m_isPause = true;
-}
-
-QPauseAnimationJob::~QPauseAnimationJob()
-{
-}
-
-int QPauseAnimationJob::duration() const
-{
- return m_duration;
-}
-
-void QPauseAnimationJob::setDuration(int msecs)
-{
- m_duration = msecs;
-}
-
-void QPauseAnimationJob::updateCurrentTime(int)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/animations/qpauseanimationjob_p.h b/src/declarative/animations/qpauseanimationjob_p.h
deleted file mode 100644
index d4af832577..0000000000
--- a/src/declarative/animations/qpauseanimationjob_p.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPAUSEANIMATIONJOB_P_H
-#define QPAUSEANIMATIONJOB_P_H
-
-#include <private/qanimationgroupjob_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QPauseAnimationJob : public QAbstractAnimationJob
-{
- Q_DISABLE_COPY(QPauseAnimationJob)
-public:
- explicit QPauseAnimationJob(int duration = 250);
- ~QPauseAnimationJob();
-
- int duration() const;
- void setDuration(int msecs);
-
-protected:
- void updateCurrentTime(int);
-
-private:
- //definition
- int m_duration;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPAUSEANIMATIONJOB_P_H
diff --git a/src/declarative/animations/qsequentialanimationgroupjob.cpp b/src/declarative/animations/qsequentialanimationgroupjob.cpp
deleted file mode 100644
index f999ca34d7..0000000000
--- a/src/declarative/animations/qsequentialanimationgroupjob.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "private/qsequentialanimationgroupjob_p.h"
-#include "private/qpauseanimationjob_p.h"
-#include "private/qanimationjobutil_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QSequentialAnimationGroupJob::QSequentialAnimationGroupJob()
- : QAnimationGroupJob()
- , m_currentAnimation(0)
- , m_previousLoop(0)
-{
-}
-
-QSequentialAnimationGroupJob::~QSequentialAnimationGroupJob()
-{
-}
-
-bool QSequentialAnimationGroupJob::atEnd() const
-{
- // we try to detect if we're at the end of the group
- //this is true if the following conditions are true:
- // 1. we're in the last loop
- // 2. the direction is forward
- // 3. the current animation is the last one
- // 4. the current animation has reached its end
- const int animTotalCurrentTime = m_currentAnimation->currentTime();
- return (m_currentLoop == m_loopCount - 1
- && m_direction == Forward
- && !m_currentAnimation->nextSibling()
- && animTotalCurrentTime == animationActualTotalDuration(m_currentAnimation));
-}
-
-int QSequentialAnimationGroupJob::animationActualTotalDuration(QAbstractAnimationJob *anim) const
-{
- int ret = anim->totalDuration();
- if (ret == -1)
- ret = uncontrolledAnimationFinishTime(anim); //we can try the actual duration there
- return ret;
-}
-
-QSequentialAnimationGroupJob::AnimationIndex QSequentialAnimationGroupJob::indexForCurrentTime() const
-{
- Q_ASSERT(firstChild());
-
- AnimationIndex ret;
- QAbstractAnimationJob *anim = 0;
- int duration = 0;
-
- for (anim = firstChild(); anim; anim = anim->nextSibling()) {
- duration = animationActualTotalDuration(anim);
-
- // 'animation' is the current animation if one of these reasons is true:
- // 1. it's duration is undefined
- // 2. it ends after msecs
- // 3. it is the last animation (this can happen in case there is at least 1 uncontrolled animation)
- // 4. it ends exactly in msecs and the direction is backwards
- if (duration == -1 || m_currentTime < (ret.timeOffset + duration)
- || (m_currentTime == (ret.timeOffset + duration) && m_direction == QAbstractAnimationJob::Backward)) {
- ret.animation = anim;
- return ret;
- }
-
- if (anim == m_currentAnimation)
- ret.afterCurrent = true;
-
- // 'animation' has a non-null defined duration and is not the one at time 'msecs'.
- ret.timeOffset += duration;
- }
-
- // this can only happen when one of those conditions is true:
- // 1. the duration of the group is undefined and we passed its actual duration
- // 2. there are only 0-duration animations in the group
- ret.timeOffset -= duration;
- ret.animation = lastChild();
- return ret;
-}
-
-void QSequentialAnimationGroupJob::restart()
-{
- // restarting the group by making the first/last animation the current one
- if (m_direction == Forward) {
- m_previousLoop = 0;
- if (m_currentAnimation == firstChild())
- activateCurrentAnimation();
- else
- setCurrentAnimation(firstChild());
- }
- else { // direction == Backward
- m_previousLoop = m_loopCount - 1;
- if (m_currentAnimation == lastChild())
- activateCurrentAnimation();
- else
- setCurrentAnimation(lastChild());
- }
-}
-
-void QSequentialAnimationGroupJob::advanceForwards(const AnimationIndex &newAnimationIndex)
-{
- if (m_previousLoop < m_currentLoop) {
- // we need to fast forward to the end
- for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = anim->nextSibling()) {
- setCurrentAnimation(anim, true);
- RETURN_IF_DELETED(anim->setCurrentTime(animationActualTotalDuration(anim)));
- }
- // this will make sure the current animation is reset to the beginning
- if (firstChild() && !firstChild()->nextSibling()) //count == 1
- // we need to force activation because setCurrentAnimation will have no effect
- activateCurrentAnimation();
- else
- setCurrentAnimation(firstChild(), true);
- }
-
- // and now we need to fast forward from the current position to
- for (QAbstractAnimationJob *anim = m_currentAnimation; anim && anim != newAnimationIndex.animation; anim = anim->nextSibling()) { //### WRONG,
- setCurrentAnimation(anim, true);
- RETURN_IF_DELETED(anim->setCurrentTime(animationActualTotalDuration(anim)));
- }
- // setting the new current animation will happen later
-}
-
-void QSequentialAnimationGroupJob::rewindForwards(const AnimationIndex &newAnimationIndex)
-{
- if (m_previousLoop > m_currentLoop) {
- // we need to fast rewind to the beginning
- for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = anim->previousSibling()) {
- setCurrentAnimation(anim, true);
- RETURN_IF_DELETED(anim->setCurrentTime(0));
- }
- // this will make sure the current animation is reset to the end
- if (lastChild() && !lastChild()->previousSibling()) //count == 1
- // we need to force activation because setCurrentAnimation will have no effect
- activateCurrentAnimation();
- else {
- setCurrentAnimation(lastChild(), true);
- }
- }
-
- // and now we need to fast rewind from the current position to
- for (QAbstractAnimationJob *anim = m_currentAnimation; anim && anim != newAnimationIndex.animation; anim = anim->previousSibling()) {
- setCurrentAnimation(anim, true);
- RETURN_IF_DELETED(anim->setCurrentTime(0));
- }
- // setting the new current animation will happen later
-}
-
-int QSequentialAnimationGroupJob::duration() const
-{
- int ret = 0;
-
- for (QAbstractAnimationJob *anim = firstChild(); anim; anim = anim->nextSibling()) {
- const int currentDuration = anim->totalDuration();
- if (currentDuration == -1)
- return -1; // Undetermined length
-
- ret += currentDuration;
- }
-
- return ret;
-}
-
-void QSequentialAnimationGroupJob::updateCurrentTime(int currentTime)
-{
- if (!m_currentAnimation)
- return;
-
- const QSequentialAnimationGroupJob::AnimationIndex newAnimationIndex = indexForCurrentTime();
-
- // newAnimationIndex.index is the new current animation
- if (m_previousLoop < m_currentLoop
- || (m_previousLoop == m_currentLoop && m_currentAnimation != newAnimationIndex.animation && newAnimationIndex.afterCurrent)) {
- // advancing with forward direction is the same as rewinding with backwards direction
- RETURN_IF_DELETED(advanceForwards(newAnimationIndex));
- } else if (m_previousLoop > m_currentLoop
- || (m_previousLoop == m_currentLoop && m_currentAnimation != newAnimationIndex.animation && !newAnimationIndex.afterCurrent)) {
- // rewinding with forward direction is the same as advancing with backwards direction
- RETURN_IF_DELETED(rewindForwards(newAnimationIndex));
- }
-
- setCurrentAnimation(newAnimationIndex.animation);
-
- const int newCurrentTime = currentTime - newAnimationIndex.timeOffset;
-
- if (m_currentAnimation) {
- RETURN_IF_DELETED(m_currentAnimation->setCurrentTime(newCurrentTime));
- if (atEnd()) {
- //we make sure that we don't exceed the duration here
- m_currentTime += m_currentAnimation->currentTime() - newCurrentTime;
- stop();
- }
- } else {
- //the only case where currentAnimation could be null
- //is when all animations have been removed
- Q_ASSERT(!firstChild());
- m_currentTime = 0;
- stop();
- }
-
- m_previousLoop = m_currentLoop;
-}
-
-void QSequentialAnimationGroupJob::updateState(QAbstractAnimationJob::State newState,
- QAbstractAnimationJob::State oldState)
-{
- QAnimationGroupJob::updateState(newState, oldState);
-
- if (!m_currentAnimation)
- return;
-
- switch (newState) {
- case Stopped:
- m_currentAnimation->stop();
- break;
- case Paused:
- if (oldState == m_currentAnimation->state() && oldState == Running)
- m_currentAnimation->pause();
- else
- restart();
- break;
- case Running:
- if (oldState == m_currentAnimation->state() && oldState == Paused)
- m_currentAnimation->start();
- else
- restart();
- break;
- }
-}
-
-void QSequentialAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direction direction)
-{
- // we need to update the direction of the current animation
- if (!isStopped() && m_currentAnimation)
- m_currentAnimation->setDirection(direction);
-}
-
-void QSequentialAnimationGroupJob::setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate)
-{
- if (!anim) {
- Q_ASSERT(!firstChild());
- m_currentAnimation = 0;
- return;
- }
-
- if (anim == m_currentAnimation)
- return;
-
- // stop the old current animation
- if (m_currentAnimation)
- m_currentAnimation->stop();
-
- m_currentAnimation = anim;
-
- activateCurrentAnimation(intermediate);
-}
-
-void QSequentialAnimationGroupJob::activateCurrentAnimation(bool intermediate)
-{
- if (!m_currentAnimation || isStopped())
- return;
-
- m_currentAnimation->stop();
-
- // we ensure the direction is consistent with the group's direction
- m_currentAnimation->setDirection(m_direction);
-
- // reset the finish time of the animation if it is uncontrolled
- if (m_currentAnimation->totalDuration() == -1)
- resetUncontrolledAnimationFinishTime(m_currentAnimation);
-
- m_currentAnimation->start();
- if (!intermediate && isPaused())
- m_currentAnimation->pause();
-}
-
-void QSequentialAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation)
-{
- Q_UNUSED(animation);
- Q_ASSERT(animation == m_currentAnimation);
-
- setUncontrolledAnimationFinishTime(m_currentAnimation, m_currentAnimation->currentTime());
-
- if ((m_direction == Forward && m_currentAnimation == lastChild())
- || (m_direction == Backward && m_currentAnimation == firstChild())) {
- // we don't handle looping of a group with undefined duration
- stop();
- } else if (m_direction == Forward) {
- // set the current animation to be the next one
- setCurrentAnimation(m_currentAnimation->nextSibling());
- } else {
- // set the current animation to be the previous one
- setCurrentAnimation(m_currentAnimation->previousSibling());
- }
-}
-
-void QSequentialAnimationGroupJob::animationInserted(QAbstractAnimationJob *anim)
-{
- if (m_currentAnimation == 0)
- setCurrentAnimation(firstChild()); // initialize the current animation
-
- if (m_currentAnimation == anim->nextSibling()
- && m_currentAnimation->currentTime() == 0 && m_currentAnimation->currentLoop() == 0) {
- //in this case we simply insert the animation before the current one has actually started
- setCurrentAnimation(anim);
- }
-
-// TODO
-// if (index < m_currentAnimationIndex || m_currentLoop != 0) {
-// qWarning("QSequentialGroup::insertAnimation only supports to add animations after the current one.");
-// return; //we're not affected because it is added after the current one
-// }
-}
-
-void QSequentialAnimationGroupJob::animationRemoved(QAbstractAnimationJob *anim, QAbstractAnimationJob *prev, QAbstractAnimationJob *next)
-{
- QAnimationGroupJob::animationRemoved(anim, prev, next);
-
- Q_ASSERT(m_currentAnimation); // currentAnimation should always be set
-
- bool removingCurrent = anim == m_currentAnimation;
- if (removingCurrent) {
- if (next)
- setCurrentAnimation(next); //let's try to take the next one
- else if (prev)
- setCurrentAnimation(prev);
- else// case all animations were removed
- setCurrentAnimation(0);
- }
-
- // duration of the previous animations up to the current animation
- m_currentTime = 0;
- for (QAbstractAnimationJob *anim = firstChild(); anim; anim = anim->nextSibling()) {
- if (anim == m_currentAnimation)
- break;
- m_currentTime += animationActualTotalDuration(anim);
-
- }
-
- if (!removingCurrent) {
- //the current animation is not the one being removed
- //so we add its current time to the current time of this group
- m_currentTime += m_currentAnimation->currentTime();
- }
-
- //let's also update the total current time
- m_totalCurrentTime = m_currentTime + m_loopCount * duration();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/animations/qsequentialanimationgroupjob_p.h b/src/declarative/animations/qsequentialanimationgroupjob_p.h
deleted file mode 100644
index 4c1fb2d55a..0000000000
--- a/src/declarative/animations/qsequentialanimationgroupjob_p.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSEQUENTIALANIMATIONGROUPJOB_P_H
-#define QSEQUENTIALANIMATIONGROUPJOB_P_H
-
-#include <private/qanimationgroupjob_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QPauseAnimationJob;
-class Q_DECLARATIVE_EXPORT QSequentialAnimationGroupJob : public QAnimationGroupJob
-{
- Q_DISABLE_COPY(QSequentialAnimationGroupJob)
-public:
- QSequentialAnimationGroupJob();
- ~QSequentialAnimationGroupJob();
-
- int duration() const;
-
- QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; }
-
-protected:
- void updateCurrentTime(int);
- void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
- void updateDirection(QAbstractAnimationJob::Direction direction);
- void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
-
-private:
- struct AnimationIndex
- {
- AnimationIndex() : afterCurrent(false), timeOffset(0), animation(0) {}
- // AnimationIndex points to the animation at timeOffset, skipping 0 duration animations.
- // Note that the index semantic is slightly different depending on the direction.
- bool afterCurrent; //whether animation is before or after m_currentAnimation //TODO: make enum Before/After/Same
- int timeOffset; // time offset when the animation at index starts.
- QAbstractAnimationJob *animation; //points to the animation at timeOffset
- };
-
- int animationActualTotalDuration(QAbstractAnimationJob *anim) const;
- AnimationIndex indexForCurrentTime() const;
-
- void setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate = false);
- void activateCurrentAnimation(bool intermediate = false);
-
- void animationInserted(QAbstractAnimationJob *anim);
- void animationRemoved(QAbstractAnimationJob *anim,QAbstractAnimationJob*,QAbstractAnimationJob*);
-
- bool atEnd() const;
-
- void restart();
-
- // handle time changes
- void rewindForwards(const AnimationIndex &newAnimationIndex);
- void advanceForwards(const AnimationIndex &newAnimationIndex);
-
- //state
- QAbstractAnimationJob *m_currentAnimation;
- int m_previousLoop;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QSEQUENTIALANIMATIONGROUPJOB_P_H
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri
deleted file mode 100644
index 8e29e9fdf6..0000000000
--- a/src/declarative/debugger/debugger.pri
+++ /dev/null
@@ -1,32 +0,0 @@
-SOURCES += \
- $$PWD/qpacketprotocol.cpp \
- $$PWD/qdeclarativedebugservice.cpp \
- $$PWD/qdeclarativedebugclient.cpp \
- $$PWD/qdeclarativeenginedebug.cpp \
- $$PWD/qdeclarativeprofilerservice.cpp \
- $$PWD/qdeclarativedebughelper.cpp \
- $$PWD/qdeclarativedebugserver.cpp \
- $$PWD/qdeclarativeinspectorservice.cpp \
- $$PWD/qv8debugservice.cpp \
- $$PWD/qv8profilerservice.cpp \
- $$PWD/qdeclarativeenginedebugservice.cpp \
- $$PWD/qdebugmessageservice.cpp
-
-HEADERS += \
- $$PWD/qpacketprotocol_p.h \
- $$PWD/qdeclarativedebugservice_p.h \
- $$PWD/qdeclarativedebugservice_p_p.h \
- $$PWD/qdeclarativedebugclient_p.h \
- $$PWD/qdeclarativeenginedebug_p.h \
- $$PWD/qdeclarativeprofilerservice_p.h \
- $$PWD/qdeclarativedebughelper_p.h \
- $$PWD/qdeclarativedebugserver_p.h \
- $$PWD/qdeclarativedebugserverconnection_p.h \
- $$PWD/qdeclarativedebugstatesdelegate_p.h \
- $$PWD/qdeclarativeinspectorservice_p.h \
- $$PWD/qdeclarativeinspectorinterface_p.h \
- $$PWD/qv8debugservice_p.h \
- $$PWD/qv8profilerservice_p.h \
- $$PWD/qdeclarativeenginedebugservice_p.h \
- $$PWD/qdeclarativedebug.h \
- $$PWD/qdebugmessageservice_p.h
diff --git a/src/declarative/debugger/qdebugmessageservice.cpp b/src/declarative/debugger/qdebugmessageservice.cpp
deleted file mode 100644
index ca75199f58..0000000000
--- a/src/declarative/debugger/qdebugmessageservice.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdebugmessageservice_p.h"
-#include "qdeclarativedebugservice_p_p.h"
-
-#include <QDataStream>
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QDebugMessageService, declarativeDebugMessageService)
-
-void DebugMessageHandler(QtMsgType type, const QMessageLogContext &ctxt,
- const char *buf)
-{
- QDebugMessageService::instance()->sendDebugMessage(type, ctxt, buf);
-}
-
-class QDebugMessageServicePrivate : public QDeclarativeDebugServicePrivate
-{
-public:
- QDebugMessageServicePrivate()
- : oldMsgHandler(0)
- , prevState(QDeclarativeDebugService::NotConnected)
- {
- }
-
- QMessageHandler oldMsgHandler;
- QDeclarativeDebugService::State prevState;
-};
-
-QDebugMessageService::QDebugMessageService(QObject *parent) :
- QDeclarativeDebugService(*(new QDebugMessageServicePrivate()),
- QLatin1String("DebugMessages"), 2, parent)
-{
- Q_D(QDebugMessageService);
-
- registerService();
- if (state() == Enabled) {
- d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler);
- d->prevState = Enabled;
- }
-}
-
-QDebugMessageService *QDebugMessageService::instance()
-{
- return declarativeDebugMessageService();
-}
-
-void QDebugMessageService::sendDebugMessage(QtMsgType type,
- const QMessageLogContext &ctxt,
- const char *buf)
-{
- Q_D(QDebugMessageService);
-
- //We do not want to alter the message handling mechanism
- //We just eavesdrop and forward the messages to a port
- //only if a client is connected to it.
- QByteArray message;
- QDataStream ws(&message, QIODevice::WriteOnly);
- ws << QByteArray("MESSAGE") << type << QString::fromLocal8Bit(buf).toUtf8();
- ws << QString::fromLatin1(ctxt.file).toUtf8();
- ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8();
-
- sendMessage(message);
- if (d->oldMsgHandler)
- (*d->oldMsgHandler)(type, ctxt, buf);
-}
-
-void QDebugMessageService::stateChanged(State state)
-{
- Q_D(QDebugMessageService);
-
- if (state != Enabled && d->prevState == Enabled) {
- QMessageHandler handler = qInstallMessageHandler(d->oldMsgHandler);
- // has our handler been overwritten in between?
- if (handler != DebugMessageHandler)
- qInstallMessageHandler(handler);
-
- } else if (state == Enabled && d->prevState != Enabled) {
- d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler);
-
- }
-
- d->prevState = state;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdebugmessageservice_p.h b/src/declarative/debugger/qdebugmessageservice_p.h
deleted file mode 100644
index b907341541..0000000000
--- a/src/declarative/debugger/qdebugmessageservice_p.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDEBUGMESSAGESERVICE_P_H
-#define QDEBUGMESSAGESERVICE_P_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 "qdeclarativedebugservice_p.h"
-
-#include <QtCore/qlogging.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDebugMessageServicePrivate;
-
-class QDebugMessageService : public QDeclarativeDebugService
-{
- Q_OBJECT
-public:
- QDebugMessageService(QObject *parent = 0);
-
- static QDebugMessageService *instance();
-
- void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt,
- const char *buf);
-
-protected:
- void stateChanged(State);
-
-private:
- Q_DISABLE_COPY(QDebugMessageService)
- Q_DECLARE_PRIVATE(QDebugMessageService)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDEBUGMESSAGESERVICE_P_H
diff --git a/src/declarative/debugger/qdeclarativedebug.h b/src/declarative/debugger/qdeclarativedebug.h
deleted file mode 100644
index e23e4ff41a..0000000000
--- a/src/declarative/debugger/qdeclarativedebug.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDEBUG_H
-#define QDECLARATIVEDEBUG_H
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-struct Q_DECLARATIVE_EXPORT QDeclarativeDebuggingEnabler
-{
- QDeclarativeDebuggingEnabler();
-};
-
-// Execute code in constructor before first QDeclarativeEngine is instantiated
-#if defined(QT_DECLARATIVE_DEBUG)
-static QDeclarativeDebuggingEnabler qmlEnableDebuggingHelper;
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEDEBUG_H
diff --git a/src/declarative/debugger/qdeclarativedebugclient.cpp b/src/declarative/debugger/qdeclarativedebugclient.cpp
deleted file mode 100644
index df250f3ef6..0000000000
--- a/src/declarative/debugger/qdeclarativedebugclient.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativedebugclient_p.h"
-
-#include "qpacketprotocol_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstringlist.h>
-#include <QtNetwork/qnetworkproxy.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-const int protocolVersion = 1;
-const QString serverId = QLatin1String("QDeclarativeDebugServer");
-const QString clientId = QLatin1String("QDeclarativeDebugClient");
-
-class QDeclarativeDebugClientPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeDebugClient)
-public:
- QDeclarativeDebugClientPrivate();
-
- QString name;
- QDeclarativeDebugConnection *connection;
-};
-
-class QDeclarativeDebugConnectionPrivate : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c);
- QDeclarativeDebugConnection *q;
- QPacketProtocol *protocol;
- QIODevice *device;
-
- bool gotHello;
- QHash <QString, float> serverPlugins;
- QHash<QString, QDeclarativeDebugClient *> plugins;
-
- void advertisePlugins();
- void connectDeviceSignals();
-
-public Q_SLOTS:
- void connected();
- void readyRead();
- void deviceAboutToClose();
-};
-
-QDeclarativeDebugConnectionPrivate::QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c)
- : QObject(c), q(c), protocol(0), device(0), gotHello(false)
-{
- protocol = new QPacketProtocol(q, this);
- QObject::connect(c, SIGNAL(connected()), this, SLOT(connected()));
- QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
-}
-
-void QDeclarativeDebugConnectionPrivate::advertisePlugins()
-{
- if (!q->isConnected())
- return;
-
- QPacket pack;
- pack << serverId << 1 << plugins.keys();
- protocol->send(pack);
- q->flush();
-}
-
-void QDeclarativeDebugConnectionPrivate::connected()
-{
- QPacket pack;
- pack << serverId << 0 << protocolVersion << plugins.keys();
- protocol->send(pack);
- q->flush();
-}
-
-void QDeclarativeDebugConnectionPrivate::readyRead()
-{
- if (!gotHello) {
- QPacket pack = protocol->read();
- QString name;
-
- pack >> name;
-
- bool validHello = false;
- if (name == clientId) {
- int op = -1;
- pack >> op;
- if (op == 0) {
- int version = -1;
- pack >> version;
- if (version == protocolVersion) {
- QStringList pluginNames;
- QList<float> pluginVersions;
- pack >> pluginNames;
- if (!pack.isEmpty())
- pack >> pluginVersions;
-
- const int pluginNamesSize = pluginNames.size();
- const int pluginVersionsSize = pluginVersions.size();
- for (int i = 0; i < pluginNamesSize; ++i) {
- float pluginVersion = 1.0;
- if (i < pluginVersionsSize)
- pluginVersion = pluginVersions.at(i);
- serverPlugins.insert(pluginNames.at(i), pluginVersion);
- }
-
- validHello = true;
- }
- }
- }
-
- if (!validHello) {
- qWarning("QDeclarativeDebugConnection: Invalid hello message");
- QObject::disconnect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
- return;
- }
- gotHello = true;
-
- QHash<QString, QDeclarativeDebugClient *>::Iterator iter = plugins.begin();
- for (; iter != plugins.end(); ++iter) {
- QDeclarativeDebugClient::State newState = QDeclarativeDebugClient::Unavailable;
- if (serverPlugins.contains(iter.key()))
- newState = QDeclarativeDebugClient::Enabled;
- iter.value()->stateChanged(newState);
- }
- }
-
- while (protocol->packetsAvailable()) {
- QPacket pack = protocol->read();
- QString name;
- pack >> name;
-
- if (name == clientId) {
- int op = -1;
- pack >> op;
-
- if (op == 1) {
- // Service Discovery
- QHash<QString, float> oldServerPlugins = serverPlugins;
- serverPlugins.clear();
-
- QStringList pluginNames;
- QList<float> pluginVersions;
- pack >> pluginNames;
- if (!pack.isEmpty())
- pack >> pluginVersions;
-
- const int pluginNamesSize = pluginNames.size();
- const int pluginVersionsSize = pluginVersions.size();
- for (int i = 0; i < pluginNamesSize; ++i) {
- float pluginVersion = 1.0;
- if (i < pluginVersionsSize)
- pluginVersion = pluginVersions.at(i);
- serverPlugins.insert(pluginNames.at(i), pluginVersion);
- }
-
- QHash<QString, QDeclarativeDebugClient *>::Iterator iter = plugins.begin();
- for (; iter != plugins.end(); ++iter) {
- const QString pluginName = iter.key();
- QDeclarativeDebugClient::State newSate = QDeclarativeDebugClient::Unavailable;
- if (serverPlugins.contains(pluginName))
- newSate = QDeclarativeDebugClient::Enabled;
-
- if (oldServerPlugins.contains(pluginName)
- != serverPlugins.contains(pluginName)) {
- iter.value()->stateChanged(newSate);
- }
- }
- } else {
- qWarning() << "QDeclarativeDebugConnection: Unknown control message id" << op;
- }
- } else {
- QByteArray message;
- pack >> message;
-
- QHash<QString, QDeclarativeDebugClient *>::Iterator iter =
- plugins.find(name);
- if (iter == plugins.end()) {
- qWarning() << "QDeclarativeDebugConnection: Message received for missing plugin" << name;
- } else {
- (*iter)->messageReceived(message);
- }
- }
- }
-}
-
-void QDeclarativeDebugConnectionPrivate::deviceAboutToClose()
-{
- // This is nasty syntax but we want to emit our own aboutToClose signal (by calling QIODevice::close())
- // without calling the underlying device close fn as that would cause an infinite loop
- q->QIODevice::close();
-}
-
-QDeclarativeDebugConnection::QDeclarativeDebugConnection(QObject *parent)
- : QIODevice(parent), d(new QDeclarativeDebugConnectionPrivate(this))
-{
-}
-
-QDeclarativeDebugConnection::~QDeclarativeDebugConnection()
-{
- QHash<QString, QDeclarativeDebugClient*>::iterator iter = d->plugins.begin();
- for (; iter != d->plugins.end(); ++iter) {
- iter.value()->d_func()->connection = 0;
- iter.value()->stateChanged(QDeclarativeDebugClient::NotConnected);
- }
-}
-
-bool QDeclarativeDebugConnection::isConnected() const
-{
- return state() == QAbstractSocket::ConnectedState;
-}
-
-qint64 QDeclarativeDebugConnection::readData(char *data, qint64 maxSize)
-{
- return d->device->read(data, maxSize);
-}
-
-qint64 QDeclarativeDebugConnection::writeData(const char *data, qint64 maxSize)
-{
- return d->device->write(data, maxSize);
-}
-
-qint64 QDeclarativeDebugConnection::bytesAvailable() const
-{
- return d->device->bytesAvailable();
-}
-
-bool QDeclarativeDebugConnection::isSequential() const
-{
- return true;
-}
-
-void QDeclarativeDebugConnection::close()
-{
- if (isOpen()) {
- QIODevice::close();
- d->device->close();
- emit stateChanged(QAbstractSocket::UnconnectedState);
-
- QHash<QString, QDeclarativeDebugClient*>::iterator iter = d->plugins.begin();
- for (; iter != d->plugins.end(); ++iter) {
- iter.value()->stateChanged(QDeclarativeDebugClient::NotConnected);
- }
- }
-}
-
-bool QDeclarativeDebugConnection::waitForConnected(int msecs)
-{
- QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
- if (socket)
- return socket->waitForConnected(msecs);
- return false;
-}
-
-QAbstractSocket::SocketState QDeclarativeDebugConnection::state() const
-{
- QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
- if (socket)
- return socket->state();
-
- return QAbstractSocket::UnconnectedState;
-}
-
-void QDeclarativeDebugConnection::flush()
-{
- QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
- if (socket) {
- socket->flush();
- return;
- }
-}
-
-void QDeclarativeDebugConnection::connectToHost(const QString &hostName, quint16 port)
-{
- QTcpSocket *socket = new QTcpSocket(d);
- socket->setProxy(QNetworkProxy::NoProxy);
- d->device = socket;
- d->connectDeviceSignals();
- d->gotHello = false;
- connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
- connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError)));
- connect(socket, SIGNAL(connected()), this, SIGNAL(connected()));
- socket->connectToHost(hostName, port);
- QIODevice::open(ReadWrite | Unbuffered);
-}
-
-void QDeclarativeDebugConnectionPrivate::connectDeviceSignals()
-{
- connect(device, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)));
- connect(device, SIGNAL(readyRead()), q, SIGNAL(readyRead()));
- connect(device, SIGNAL(aboutToClose()), this, SLOT(deviceAboutToClose()));
-}
-
-//
-
-QDeclarativeDebugClientPrivate::QDeclarativeDebugClientPrivate()
- : connection(0)
-{
-}
-
-QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name,
- QDeclarativeDebugConnection *parent)
- : QObject(*(new QDeclarativeDebugClientPrivate), parent)
-{
- Q_D(QDeclarativeDebugClient);
- d->name = name;
- d->connection = parent;
-
- if (!d->connection)
- return;
-
- if (d->connection->d->plugins.contains(name)) {
- qWarning() << "QDeclarativeDebugClient: Conflicting plugin name" << name;
- d->connection = 0;
- } else {
- d->connection->d->plugins.insert(name, this);
- d->connection->d->advertisePlugins();
- }
-}
-
-QDeclarativeDebugClient::~QDeclarativeDebugClient()
-{
- Q_D(QDeclarativeDebugClient);
- if (d->connection && d->connection->d) {
- d->connection->d->plugins.remove(d->name);
- d->connection->d->advertisePlugins();
- }
-}
-
-QString QDeclarativeDebugClient::name() const
-{
- Q_D(const QDeclarativeDebugClient);
- return d->name;
-}
-
-float QDeclarativeDebugClient::serviceVersion() const
-{
- Q_D(const QDeclarativeDebugClient);
- if (d->connection->d->serverPlugins.contains(d->name))
- return d->connection->d->serverPlugins.value(d->name);
- return -1;
-}
-
-QDeclarativeDebugClient::State QDeclarativeDebugClient::state() const
-{
- Q_D(const QDeclarativeDebugClient);
- if (!d->connection
- || !d->connection->isConnected()
- || !d->connection->d->gotHello)
- return NotConnected;
-
- if (d->connection->d->serverPlugins.contains(d->name))
- return Enabled;
-
- return Unavailable;
-}
-
-void QDeclarativeDebugClient::sendMessage(const QByteArray &message)
-{
- Q_D(QDeclarativeDebugClient);
- if (state() != Enabled)
- return;
-
- QPacket pack;
- pack << d->name << message;
- d->connection->d->protocol->send(pack);
- d->connection->flush();
-}
-
-void QDeclarativeDebugClient::stateChanged(State)
-{
-}
-
-void QDeclarativeDebugClient::messageReceived(const QByteArray &)
-{
-}
-
-QT_END_NAMESPACE
-
-#include <qdeclarativedebugclient.moc>
diff --git a/src/declarative/debugger/qdeclarativedebugclient_p.h b/src/declarative/debugger/qdeclarativedebugclient_p.h
deleted file mode 100644
index 93c5be9e44..0000000000
--- a/src/declarative/debugger/qdeclarativedebugclient_p.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDEBUGCLIENT_H
-#define QDECLARATIVEDEBUGCLIENT_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 <QtNetwork/qtcpsocket.h>
-
-#include <private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeDebugConnectionPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugConnection : public QIODevice
-{
- Q_OBJECT
- Q_DISABLE_COPY(QDeclarativeDebugConnection)
-public:
- QDeclarativeDebugConnection(QObject * = 0);
- ~QDeclarativeDebugConnection();
-
- void connectToHost(const QString &hostName, quint16 port);
-
- qint64 bytesAvailable() const;
- bool isConnected() const;
- QAbstractSocket::SocketState state() const;
- void flush();
- bool isSequential() const;
- void close();
- bool waitForConnected(int msecs = 30000);
-
-signals:
- void connected();
- void stateChanged(QAbstractSocket::SocketState socketState);
- void error(QAbstractSocket::SocketError socketError);
-
-protected:
- qint64 readData(char *data, qint64 maxSize);
- qint64 writeData(const char *data, qint64 maxSize);
-
-private:
- QDeclarativeDebugConnectionPrivate *d;
- friend class QDeclarativeDebugClient;
- friend class QDeclarativeDebugClientPrivate;
-};
-
-class QDeclarativeDebugClientPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugClient : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeDebugClient)
- Q_DISABLE_COPY(QDeclarativeDebugClient)
-
-public:
- enum State { NotConnected, Unavailable, Enabled };
-
- QDeclarativeDebugClient(const QString &, QDeclarativeDebugConnection *parent);
- ~QDeclarativeDebugClient();
-
- QString name() const;
- float serviceVersion() const;
- State state() const;
-
- virtual void sendMessage(const QByteArray &);
-
-protected:
- virtual void stateChanged(State);
- virtual void messageReceived(const QByteArray &);
-
-private:
- friend class QDeclarativeDebugConnection;
- friend class QDeclarativeDebugConnectionPrivate;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEDEBUGCLIENT_H
diff --git a/src/declarative/debugger/qdeclarativedebughelper.cpp b/src/declarative/debugger/qdeclarativedebughelper.cpp
deleted file mode 100644
index 45d488fe1b..0000000000
--- a/src/declarative/debugger/qdeclarativedebughelper.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativedebughelper_p.h"
-
-#include <QtCore/QAbstractAnimation>
-#include <QtDeclarative/QJSEngine>
-
-#include <private/qdeclarativeengine_p.h>
-#include <private/qabstractanimation_p.h>
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-void QDeclarativeDebugHelper::setAnimationSlowDownFactor(qreal factor)
-{
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setSlowModeEnabled(factor != 1.0);
- timer->setSlowdownFactor(factor);
-}
-
-void QDeclarativeDebugHelper::enableDebugging() {
- qWarning("QDeclarativeDebugHelper::enableDebugging() is deprecated! Add CONFIG += declarative_debug to your .pro file instead.");
-#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
- if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
- qWarning("Qml debugging is enabled. Only use this in a safe environment!");
- }
- QDeclarativeEnginePrivate::qml_debugging_enabled = true;
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebughelper_p.h b/src/declarative/debugger/qdeclarativedebughelper_p.h
deleted file mode 100644
index d24bc8c19f..0000000000
--- a/src/declarative/debugger/qdeclarativedebughelper_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDEBUGHELPER_P_H
-#define QDECLARATIVEDEBUGHELPER_P_H
-
-#include <QtCore/qglobal.h>
-
-#include <private/qdeclarativeglobal_p.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.
-//
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-
-#ifndef QT_BUILD_DECLARATIVE_LIB
-#warning Use of this header file is deprecated! Add CONFIG += declarative_debug to your .pro file instead.
-#endif
-
-// Helper methods to access private API through a stable interface
-// This is used in the qmljsdebugger library of QtCreator.
-class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper
-{
-public:
- static void setAnimationSlowDownFactor(qreal factor);
-
- // Enables remote debugging functionality
- // Only use this for debugging in a safe environment!
- static void enableDebugging();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEDEBUGHELPER_P_H
diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp
deleted file mode 100644
index 482847c7a7..0000000000
--- a/src/declarative/debugger/qdeclarativedebugserver.cpp
+++ /dev/null
@@ -1,539 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativedebugserver_p.h"
-#include "qdeclarativedebugservice_p.h"
-#include "qdeclarativedebugservice_p_p.h"
-#include <private/qdeclarativeengine_p.h>
-
-#include <QtCore/QDir>
-#include <QtCore/QPluginLoader>
-#include <QtCore/QStringList>
-#include <QtCore/qwaitcondition.h>
-
-#include <private/qobject_p.h>
-#include <private/qcoreapplication_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*
- QDeclarativeDebug Protocol (Version 1):
-
- handshake:
- 1. Client sends
- "QDeclarativeDebugServer" 0 version pluginNames
- version: an int representing the highest protocol version the client knows
- pluginNames: plugins available on client side
- 2. Server sends
- "QDeclarativeDebugClient" 0 version pluginNames pluginVersions
- version: an int representing the highest protocol version the client & server know
- pluginNames: plugins available on server side. plugins both in the client and server message are enabled.
- client plugin advertisement
- 1. Client sends
- "QDeclarativeDebugServer" 1 pluginNames
- server plugin advertisement
- 1. Server sends
- "QDeclarativeDebugClient" 1 pluginNames pluginVersions
- plugin communication:
- Everything send with a header different to "QDeclarativeDebugServer" is sent to the appropriate plugin.
- */
-
-const int protocolVersion = 1;
-
-// print detailed information about loading of plugins
-DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE)
-
-class QDeclarativeDebugServerThread;
-
-class QDeclarativeDebugServerPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeDebugServer)
-public:
- QDeclarativeDebugServerPrivate();
-
- void advertisePlugins();
- QDeclarativeDebugServerConnection *loadConnectionPlugin(const QString &pluginName);
-
- QDeclarativeDebugServerConnection *connection;
- QHash<QString, QDeclarativeDebugService *> plugins;
- mutable QReadWriteLock pluginsLock;
- QStringList clientPlugins;
- bool gotHello;
-
- QMutex messageArrivedMutex;
- QWaitCondition messageArrivedCondition;
- QStringList waitingForMessageNames;
- QDeclarativeDebugServerThread *thread;
- QPluginLoader loader;
-
-private:
- // private slot
- void _q_sendMessages(const QList<QByteArray> &messages);
-};
-
-class QDeclarativeDebugServerThread : public QThread
-{
-public:
- void setPluginName(const QString &pluginName) {
- m_pluginName = pluginName;
- }
-
- void setPort(int port, bool block) {
- m_port = port;
- m_block = block;
- }
-
- void run();
-
-private:
- QString m_pluginName;
- int m_port;
- bool m_block;
-};
-
-QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate() :
- connection(0),
- gotHello(false),
- thread(0)
-{
- // used in _q_sendMessages
- qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>");
-}
-
-void QDeclarativeDebugServerPrivate::advertisePlugins()
-{
- Q_Q(QDeclarativeDebugServer);
-
- if (!gotHello)
- return;
-
- QByteArray message;
- {
- QDataStream out(&message, QIODevice::WriteOnly);
- QStringList pluginNames;
- QList<float> pluginVersions;
- foreach (QDeclarativeDebugService *service, plugins.values()) {
- pluginNames << service->name();
- pluginVersions << service->version();
- }
- out << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << pluginNames << pluginVersions;
- }
-
- QMetaObject::invokeMethod(q, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList<QByteArray>, QList<QByteArray>() << message));
-}
-
-QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin(
- const QString &pluginName)
-{
-#ifndef QT_NO_LIBRARY
- QStringList pluginCandidates;
- const QStringList paths = QCoreApplication::libraryPaths();
- foreach (const QString &libPath, paths) {
- const QDir dir(libPath + QLatin1String("/qmltooling"));
- if (dir.exists()) {
- QStringList plugins(dir.entryList(QDir::Files));
- foreach (const QString &pluginPath, plugins) {
- if (QFileInfo(pluginPath).fileName().contains(pluginName))
- pluginCandidates << dir.absoluteFilePath(pluginPath);
- }
- }
- }
-
- foreach (const QString &pluginPath, pluginCandidates) {
- if (qmlDebugVerbose())
- qDebug() << "QDeclarativeDebugServer: Trying to load plugin " << pluginPath << "...";
-
- loader.setFileName(pluginPath);
- if (!loader.load()) {
- if (qmlDebugVerbose())
- qDebug() << "QDeclarativeDebugServer: Error while loading: " << loader.errorString();
- continue;
- }
- if (QObject *instance = loader.instance())
- connection = qobject_cast<QDeclarativeDebugServerConnection*>(instance);
-
- if (connection) {
- if (qmlDebugVerbose())
- qDebug() << "QDeclarativeDebugServer: Plugin successfully loaded.";
-
- return connection;
- }
-
- if (qmlDebugVerbose())
- qDebug() << "QDeclarativeDebugServer: Plugin does not implement interface QDeclarativeDebugServerConnection.";
-
- loader.unload();
- }
-#endif
- return 0;
-}
-
-void QDeclarativeDebugServerThread::run()
-{
- QDeclarativeDebugServer *server = QDeclarativeDebugServer::instance();
- QDeclarativeDebugServerConnection *connection
- = server->d_func()->loadConnectionPlugin(m_pluginName);
- if (connection) {
- connection->setServer(QDeclarativeDebugServer::instance());
- connection->setPort(m_port, m_block);
- } else {
- QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
- qWarning() << QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
- "Remote debugger plugin has not been found.").arg(appD->qmljsDebugArgumentsString());
- }
-
- exec();
-
- // make sure events still waiting are processed
- QEventLoop eventLoop;
- eventLoop.processEvents(QEventLoop::AllEvents);
-}
-
-bool QDeclarativeDebugServer::hasDebuggingClient() const
-{
- Q_D(const QDeclarativeDebugServer);
- return d->connection
- && d->connection->isConnected()
- && d->gotHello;
-}
-
-static QDeclarativeDebugServer *qDeclarativeDebugServer = 0;
-
-
-static void cleanup()
-{
- delete qDeclarativeDebugServer;
- qDeclarativeDebugServer = 0;
-}
-
-QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
-{
- static bool commandLineTested = false;
-
- if (!commandLineTested) {
- commandLineTested = true;
-
- QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
-#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
- // ### remove port definition when protocol is changed
- int port = 0;
- bool block = false;
- bool ok = false;
-
- // format: qmljsdebugger=port:3768[,block] OR qmljsdebugger=ost[,block]
- if (!appD->qmljsDebugArgumentsString().isEmpty()) {
- if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
- qWarning() << QString::fromLatin1(
- "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
- "Debugging has not been enabled.").arg(
- appD->qmljsDebugArgumentsString());
- return 0;
- }
-
- QString pluginName;
- if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) {
- int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(','));
- port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok);
- pluginName = QLatin1String("qmldbg_tcp");
- } else if (appD->qmljsDebugArgumentsString().contains(QLatin1String("ost"))) {
- pluginName = QLatin1String("qmldbg_ost");
- ok = true;
- }
-
- block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block"));
-
- if (ok) {
- qDeclarativeDebugServer = new QDeclarativeDebugServer();
- QDeclarativeDebugServerThread *thread = new QDeclarativeDebugServerThread;
- qDeclarativeDebugServer->d_func()->thread = thread;
- qDeclarativeDebugServer->moveToThread(thread);
- thread->setPluginName(pluginName);
- thread->setPort(port, block);
- thread->start();
-
- if (block) {
- QDeclarativeDebugServerPrivate *d = qDeclarativeDebugServer->d_func();
- d->messageArrivedMutex.lock();
- d->messageArrivedCondition.wait(&d->messageArrivedMutex);
- d->messageArrivedMutex.unlock();
- }
-
- } else {
- qWarning() << QString::fromLatin1(
- "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
- "Format is -qmljsdebugger=port:<port>[,block]").arg(
- appD->qmljsDebugArgumentsString());
- }
- }
-#else
- if (!appD->qmljsDebugArgumentsString().isEmpty()) {
- qWarning() << QString::fromLatin1(
- "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
- "QtDeclarative is not configured for debugging.").arg(
- appD->qmljsDebugArgumentsString());
- }
-#endif
- }
-
- return qDeclarativeDebugServer;
-}
-
-QDeclarativeDebugServer::QDeclarativeDebugServer()
- : QObject(*(new QDeclarativeDebugServerPrivate))
-{
- qAddPostRoutine(cleanup);
-}
-
-QDeclarativeDebugServer::~QDeclarativeDebugServer()
-{
- Q_D(QDeclarativeDebugServer);
-
- QReadLocker(&d->pluginsLock);
- {
- foreach (QDeclarativeDebugService *service, d->plugins.values()) {
- service->stateAboutToBeChanged(QDeclarativeDebugService::NotConnected);
- service->d_func()->server = 0;
- service->d_func()->state = QDeclarativeDebugService::NotConnected;
- service->stateChanged(QDeclarativeDebugService::NotConnected);
- }
- }
-
- if (d->thread) {
- d->thread->exit();
- d->thread->wait();
- delete d->thread;
- }
- delete d->connection;
-}
-
-void QDeclarativeDebugServer::receiveMessage(const QByteArray &message)
-{
- Q_D(QDeclarativeDebugServer);
-
- QDataStream in(message);
-
- QString name;
-
- in >> name;
- if (name == QLatin1String("QDeclarativeDebugServer")) {
- int op = -1;
- in >> op;
- if (op == 0) {
- int version;
- in >> version >> d->clientPlugins;
-
- // Send the hello answer immediately, since it needs to arrive before
- // the plugins below start sending messages.
- QByteArray helloAnswer;
- {
- QDataStream out(&helloAnswer, QIODevice::WriteOnly);
- QStringList pluginNames;
- QList<float> pluginVersions;
- foreach (QDeclarativeDebugService *service, d->plugins.values()) {
- pluginNames << service->name();
- pluginVersions << service->version();
- }
-
- out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << pluginNames << pluginVersions;
- }
- d->connection->send(QList<QByteArray>() << helloAnswer);
-
- d->gotHello = true;
-
- QReadLocker(&d->pluginsLock);
- QHash<QString, QDeclarativeDebugService*>::ConstIterator iter = d->plugins.constBegin();
- for (; iter != d->plugins.constEnd(); ++iter) {
- QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable;
- if (d->clientPlugins.contains(iter.key()))
- newState = QDeclarativeDebugService::Enabled;
- iter.value()->d_func()->state = newState;
- iter.value()->stateChanged(newState);
- }
-
- qWarning("QDeclarativeDebugServer: Connection established");
- d->messageArrivedCondition.wakeAll();
-
- } else if (op == 1) {
-
- // Service Discovery
- QStringList oldClientPlugins = d->clientPlugins;
- in >> d->clientPlugins;
-
- QReadLocker(&d->pluginsLock);
- QHash<QString, QDeclarativeDebugService*>::ConstIterator iter = d->plugins.constBegin();
- for (; iter != d->plugins.constEnd(); ++iter) {
- const QString pluginName = iter.key();
- QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable;
- if (d->clientPlugins.contains(pluginName))
- newState = QDeclarativeDebugService::Enabled;
-
- if (oldClientPlugins.contains(pluginName)
- != d->clientPlugins.contains(pluginName)) {
- iter.value()->d_func()->state = newState;
- iter.value()->stateChanged(newState);
- }
- }
-
- } else {
- qWarning("QDeclarativeDebugServer: Invalid control message %d", op);
- d->connection->disconnect();
- return;
- }
-
- } else {
- if (d->gotHello) {
- QByteArray message;
- in >> message;
-
- QReadLocker(&d->pluginsLock);
- QHash<QString, QDeclarativeDebugService *>::Iterator iter = d->plugins.find(name);
- if (iter == d->plugins.end()) {
- qWarning() << "QDeclarativeDebugServer: Message received for missing plugin" << name;
- } else {
- (*iter)->messageReceived(message);
-
- if (d->waitingForMessageNames.removeOne(name))
- d->messageArrivedCondition.wakeAll();
- }
- } else {
- qWarning("QDeclarativeDebugServer: Invalid hello message");
- }
-
- }
-}
-
-void QDeclarativeDebugServerPrivate::_q_sendMessages(const QList<QByteArray> &messages)
-{
- if (connection)
- connection->send(messages);
-}
-
-QList<QDeclarativeDebugService*> QDeclarativeDebugServer::services() const
-{
- const Q_D(QDeclarativeDebugServer);
- QReadLocker(&d->pluginsLock);
- return d->plugins.values();
-}
-
-QStringList QDeclarativeDebugServer::serviceNames() const
-{
- const Q_D(QDeclarativeDebugServer);
- QReadLocker(&d->pluginsLock);
- return d->plugins.keys();
-}
-
-bool QDeclarativeDebugServer::addService(QDeclarativeDebugService *service)
-{
- Q_D(QDeclarativeDebugServer);
- {
- QWriteLocker(&d->pluginsLock);
- if (!service || d->plugins.contains(service->name()))
- return false;
- d->plugins.insert(service->name(), service);
- }
- {
- QReadLocker(&d->pluginsLock);
- d->advertisePlugins();
- QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable;
- if (d->clientPlugins.contains(service->name()))
- newState = QDeclarativeDebugService::Enabled;
- service->d_func()->state = newState;
- }
- return true;
-}
-
-bool QDeclarativeDebugServer::removeService(QDeclarativeDebugService *service)
-{
- Q_D(QDeclarativeDebugServer);
- {
- QWriteLocker(&d->pluginsLock);
- if (!service || !d->plugins.contains(service->name()))
- return false;
- d->plugins.remove(service->name());
- }
- {
- QReadLocker(&d->pluginsLock);
- QDeclarativeDebugService::State newState = QDeclarativeDebugService::NotConnected;
- service->stateAboutToBeChanged(newState);
- d->advertisePlugins();
- service->d_func()->server = 0;
- service->d_func()->state = newState;
- service->stateChanged(newState);
- }
-
- return true;
-}
-
-void QDeclarativeDebugServer::sendMessages(QDeclarativeDebugService *service,
- const QList<QByteArray> &messages)
-{
- QList<QByteArray> prefixedMessages;
- foreach (const QByteArray &message, messages) {
- QByteArray prefixed;
- QDataStream out(&prefixed, QIODevice::WriteOnly);
- out << service->name() << message;
- prefixedMessages << prefixed;
- }
-
- QMetaObject::invokeMethod(this, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList<QByteArray>, prefixedMessages));
-}
-
-bool QDeclarativeDebugServer::waitForMessage(QDeclarativeDebugService *service)
-{
- Q_D(QDeclarativeDebugServer);
- QReadLocker(&d->pluginsLock);
-
- if (!service
- || !d->plugins.contains(service->name()))
- return false;
-
- d->messageArrivedMutex.lock();
- d->waitingForMessageNames << service->name();
- do {
- d->messageArrivedCondition.wait(&d->messageArrivedMutex);
- } while (d->waitingForMessageNames.contains(service->name()));
- d->messageArrivedMutex.unlock();
- return true;
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qdeclarativedebugserver_p.cpp"
diff --git a/src/declarative/debugger/qdeclarativedebugserver_p.h b/src/declarative/debugger/qdeclarativedebugserver_p.h
deleted file mode 100644
index 8f7f748761..0000000000
--- a/src/declarative/debugger/qdeclarativedebugserver_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDEBUGSERVER_H
-#define QDECLARATIVEDEBUGSERVER_H
-
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativedebugserverconnection_p.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.
-//
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeDebugService;
-
-class QDeclarativeDebugServerPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeDebugServer : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeDebugServer)
- Q_DISABLE_COPY(QDeclarativeDebugServer)
-public:
- ~QDeclarativeDebugServer();
-
- static QDeclarativeDebugServer *instance();
-
- void setConnection(QDeclarativeDebugServerConnection *connection);
-
- bool hasDebuggingClient() const;
-
- QList<QDeclarativeDebugService*> services() const;
- QStringList serviceNames() const;
-
-
- bool addService(QDeclarativeDebugService *service);
- bool removeService(QDeclarativeDebugService *service);
-
- void receiveMessage(const QByteArray &message);
-
- bool waitForMessage(QDeclarativeDebugService *service);
- void sendMessages(QDeclarativeDebugService *service, const QList<QByteArray> &messages);
-
-private:
- friend class QDeclarativeDebugService;
- friend class QDeclarativeDebugServicePrivate;
- friend class QDeclarativeDebugServerThread;
- QDeclarativeDebugServer();
- Q_PRIVATE_SLOT(d_func(), void _q_sendMessages(QList<QByteArray>))
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEDEBUGSERVICE_H
diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
deleted file mode 100644
index e78657a73d..0000000000
--- a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDEBUGSERVERCONNECTION_H
-#define QDECLARATIVEDEBUGSERVERCONNECTION_H
-
-#include <private/qdeclarativeglobal_p.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.
-//
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeDebugServer;
-class Q_DECLARATIVE_EXPORT QDeclarativeDebugServerConnection
-{
-public:
- QDeclarativeDebugServerConnection() {}
- virtual ~QDeclarativeDebugServerConnection() {}
-
- virtual void setServer(QDeclarativeDebugServer *server) = 0;
- virtual void setPort(int port, bool bock) = 0;
- virtual bool isConnected() const = 0;
- virtual void send(const QList<QByteArray> &messages) = 0;
- virtual void disconnect() = 0;
- virtual bool waitForMessage() = 0;
-};
-
-#define QDeclarativeDebugServerConnection_iid "org.qt-project.Qt.QDeclarativeDebugServerConnection"
-
-Q_DECLARE_INTERFACE(QDeclarativeDebugServerConnection, QDeclarativeDebugServerConnection_iid)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEDEBUGSERVERCONNECTION_H
diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp
deleted file mode 100644
index 96344d7717..0000000000
--- a/src/declarative/debugger/qdeclarativedebugservice.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativedebugservice_p.h"
-#include "qdeclarativedebugservice_p_p.h"
-#include "qdeclarativedebugserver_p.h"
-
-#include <QtCore/QDebug>
-#include <QtCore/QStringList>
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeDebugServicePrivate::QDeclarativeDebugServicePrivate()
- : server(0)
-{
-}
-
-QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, float version, QObject *parent)
- : QObject(*(new QDeclarativeDebugServicePrivate), parent)
-{
- Q_D(QDeclarativeDebugService);
- d->name = name;
- d->version = version;
- d->server = QDeclarativeDebugServer::instance();
- d->state = QDeclarativeDebugService::NotConnected;
-
-
-}
-
-QDeclarativeDebugService::QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd,
- const QString &name, float version, QObject *parent)
- : QObject(dd, parent)
-{
- Q_D(QDeclarativeDebugService);
- d->name = name;
- d->version = version;
- d->server = QDeclarativeDebugServer::instance();
- d->state = QDeclarativeDebugService::NotConnected;
-}
-
-/**
- Registers the service. This should be called in the constructor of the inherited class. From
- then on the service might get asynchronous calls to messageReceived().
- */
-QDeclarativeDebugService::State QDeclarativeDebugService::registerService()
-{
- Q_D(QDeclarativeDebugService);
- if (!d->server)
- return NotConnected;
-
- if (d->server->serviceNames().contains(d->name)) {
- qWarning() << "QDeclarativeDebugService: Conflicting plugin name" << d->name;
- d->server = 0;
- } else {
- d->server->addService(this);
- }
- return state();
-}
-
-QDeclarativeDebugService::~QDeclarativeDebugService()
-{
- Q_D(const QDeclarativeDebugService);
- if (d->server) {
- d->server->removeService(this);
- }
-}
-
-QString QDeclarativeDebugService::name() const
-{
- Q_D(const QDeclarativeDebugService);
- return d->name;
-}
-
-float QDeclarativeDebugService::version() const
-{
- Q_D(const QDeclarativeDebugService);
- return d->version;
-}
-
-QDeclarativeDebugService::State QDeclarativeDebugService::state() const
-{
- Q_D(const QDeclarativeDebugService);
- return d->state;
-}
-
-namespace {
-
-struct ObjectReference
-{
- QPointer<QObject> object;
- int id;
-};
-
-struct ObjectReferenceHash
-{
- ObjectReferenceHash() : nextId(0) {}
-
- QHash<QObject *, ObjectReference> objects;
- QHash<int, QObject *> ids;
-
- int nextId;
-};
-
-}
-Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash);
-
-
-/*!
- Returns a unique id for \a object. Calling this method multiple times
- for the same object will return the same id.
-*/
-int QDeclarativeDebugService::idForObject(QObject *object)
-{
- if (!object)
- return -1;
-
- ObjectReferenceHash *hash = objectReferenceHash();
- QHash<QObject *, ObjectReference>::Iterator iter =
- hash->objects.find(object);
-
- if (iter == hash->objects.end()) {
- int id = hash->nextId++;
-
- hash->ids.insert(id, object);
- iter = hash->objects.insert(object, ObjectReference());
- iter->object = object;
- iter->id = id;
- } else if (iter->object != object) {
- int id = hash->nextId++;
-
- hash->ids.remove(iter->id);
-
- hash->ids.insert(id, object);
- iter->object = object;
- iter->id = id;
- }
- return iter->id;
-}
-
-/*!
- Returns the object for unique \a id. If the object has not previously been
- assigned an id, through idForObject(), then 0 is returned. If the object
- has been destroyed, 0 is returned.
-*/
-QObject *QDeclarativeDebugService::objectForId(int id)
-{
- ObjectReferenceHash *hash = objectReferenceHash();
-
- QHash<int, QObject *>::Iterator iter = hash->ids.find(id);
- if (iter == hash->ids.end())
- return 0;
-
-
- QHash<QObject *, ObjectReference>::Iterator objIter =
- hash->objects.find(*iter);
- Q_ASSERT(objIter != hash->objects.end());
-
- if (objIter->object == 0) {
- hash->ids.erase(iter);
- hash->objects.erase(objIter);
- return 0;
- } else {
- return *iter;
- }
-}
-
-bool QDeclarativeDebugService::isDebuggingEnabled()
-{
- return QDeclarativeDebugServer::instance() != 0;
-}
-
-bool QDeclarativeDebugService::hasDebuggingClient()
-{
- return QDeclarativeDebugServer::instance() != 0
- && QDeclarativeDebugServer::instance()->hasDebuggingClient();
-}
-
-QString QDeclarativeDebugService::objectToString(QObject *obj)
-{
- if(!obj)
- return QLatin1String("NULL");
-
- QString objectName = obj->objectName();
- if(objectName.isEmpty())
- objectName = QLatin1String("<unnamed>");
-
- QString rv = QString::fromUtf8(obj->metaObject()->className()) +
- QLatin1String(": ") + objectName;
-
- return rv;
-}
-
-void QDeclarativeDebugService::sendMessage(const QByteArray &message)
-{
- sendMessages(QList<QByteArray>() << message);
-}
-
-void QDeclarativeDebugService::sendMessages(const QList<QByteArray> &messages)
-{
- Q_D(QDeclarativeDebugService);
-
- if (state() != Enabled)
- return;
-
- d->server->sendMessages(this, messages);
-}
-
-bool QDeclarativeDebugService::waitForMessage()
-{
- Q_D(QDeclarativeDebugService);
-
- if (state() != Enabled)
- return false;
-
- return d->server->waitForMessage(this);
-}
-
-void QDeclarativeDebugService::stateAboutToBeChanged(State)
-{
-}
-
-void QDeclarativeDebugService::stateChanged(State)
-{
-}
-
-void QDeclarativeDebugService::messageReceived(const QByteArray &)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h
deleted file mode 100644
index 203e27ad09..0000000000
--- a/src/declarative/debugger/qdeclarativedebugservice_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDEBUGSERVICE_H
-#define QDECLARATIVEDEBUGSERVICE_H
-
-#include <QtCore/qobject.h>
-
-#include <private/qdeclarativeglobal_p.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.
-//
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeDebugServicePrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugService : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeDebugService)
- Q_DISABLE_COPY(QDeclarativeDebugService)
-
-public:
- explicit QDeclarativeDebugService(const QString &, float version, QObject *parent = 0);
- ~QDeclarativeDebugService();
-
- QString name() const;
- float version() const;
-
- enum State { NotConnected, Unavailable, Enabled };
- State state() const;
-
- void sendMessage(const QByteArray &);
- void sendMessages(const QList<QByteArray> &);
- bool waitForMessage();
-
- static int idForObject(QObject *);
- static QObject *objectForId(int);
-
- static QString objectToString(QObject *obj);
-
- static bool isDebuggingEnabled();
- static bool hasDebuggingClient();
-
-protected:
- QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, const QString &name, float version, QObject *parent = 0);
-
- State registerService();
-
- virtual void stateAboutToBeChanged(State);
- virtual void stateChanged(State);
- virtual void messageReceived(const QByteArray &);
-
-private:
- friend class QDeclarativeDebugServer;
- friend class QDeclarativeDebugServerPrivate;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEDEBUGSERVICE_H
-
diff --git a/src/declarative/debugger/qdeclarativedebugservice_p_p.h b/src/declarative/debugger/qdeclarativedebugservice_p_p.h
deleted file mode 100644
index 6638ccbec7..0000000000
--- a/src/declarative/debugger/qdeclarativedebugservice_p_p.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDEBUGSERVICE_P_H
-#define QDECLARATIVEDEBUGSERVICE_P_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 <private/qobject_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeDebugServer;
-
-class QDeclarativeDebugServicePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeDebugService)
-public:
- QDeclarativeDebugServicePrivate();
-
- QString name;
- float version;
- QDeclarativeDebugServer *server;
- QDeclarativeDebugService::State state;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEDEBUGSERVICE_P_H
diff --git a/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h b/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h
deleted file mode 100644
index 868357723d..0000000000
--- a/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDEBUGSTATESDELEGATE_P_H
-#define QDECLARATIVEDEBUGSTATESDELEGATE_P_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 <private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeContext;
-class QDeclarativeProperty;
-class QObject;
-class QString;
-class QVariant;
-
-class QDeclarativeDebugStatesDelegate
-{
-protected:
- QDeclarativeDebugStatesDelegate() {}
-
-public:
- virtual ~QDeclarativeDebugStatesDelegate() {}
-
- virtual void buildStatesList(QDeclarativeContext *ctxt, bool cleanList) = 0;
- virtual void updateBinding(QDeclarativeContext *context,
- const QDeclarativeProperty &property,
- const QVariant &expression, bool isLiteralValue,
- const QString &fileName, int line, int column,
- bool *inBaseState) = 0;
- virtual bool setBindingForInvalidProperty(QObject *object,
- const QString &propertyName,
- const QVariant &expression,
- bool isLiteralValue) = 0;
- virtual void resetBindingForInvalidProperty(QObject *object,
- const QString &propertyName) = 0;
-
-private:
- Q_DISABLE_COPY(QDeclarativeDebugStatesDelegate)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEDEBUGSTATESDELEGATE_P_H
diff --git a/src/declarative/debugger/qdeclarativeenginedebug.cpp b/src/declarative/debugger/qdeclarativeenginedebug.cpp
deleted file mode 100644
index 462f99937e..0000000000
--- a/src/declarative/debugger/qdeclarativeenginedebug.cpp
+++ /dev/null
@@ -1,1072 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeenginedebug_p.h"
-
-#include "qdeclarativedebugclient_p.h"
-
-#include "qdeclarativeenginedebugservice_p.h"
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngineDebugClient : public QDeclarativeDebugClient
-{
-public:
- QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p);
-
-protected:
- virtual void stateChanged(State state);
- virtual void messageReceived(const QByteArray &);
-
-private:
- QDeclarativeEngineDebugPrivate *priv;
- friend class QDeclarativeEngineDebugPrivate;
-};
-
-class QDeclarativeEngineDebugPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeEngineDebug)
-public:
- QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *);
- ~QDeclarativeEngineDebugPrivate();
-
- void stateChanged(QDeclarativeEngineDebug::State status);
- void message(const QByteArray &);
-
- QDeclarativeEngineDebugClient *client;
- int nextId;
- int getId();
-
- void decode(QDataStream &, QDeclarativeDebugContextReference &);
- void decode(QDataStream &, QDeclarativeDebugObjectReference &, bool simple);
-
- static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugEnginesQuery *);
- static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugRootContextQuery *);
- static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugObjectQuery *);
- static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugExpressionQuery *);
- static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugWatch *);
-
- QHash<int, QDeclarativeDebugEnginesQuery *> enginesQuery;
- QHash<int, QDeclarativeDebugRootContextQuery *> rootContextQuery;
- QHash<int, QDeclarativeDebugObjectQuery *> objectQuery;
- QHash<int, QDeclarativeDebugExpressionQuery *> expressionQuery;
-
- QHash<int, QDeclarativeDebugWatch *> watched;
-};
-
-QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client,
- QDeclarativeEngineDebugPrivate *p)
- : QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p)
-{
-}
-
-void QDeclarativeEngineDebugClient::stateChanged(State status)
-{
- if (priv)
- priv->stateChanged(static_cast<QDeclarativeEngineDebug::State>(status));
-}
-
-void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data)
-{
- if (priv)
- priv->message(data);
-}
-
-QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c)
- : client(new QDeclarativeEngineDebugClient(c, this)), nextId(0)
-{
-}
-
-QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate()
-{
- if (client)
- client->priv = 0;
- delete client;
-
- QHash<int, QDeclarativeDebugEnginesQuery*>::iterator enginesIter = enginesQuery.begin();
- for (; enginesIter != enginesQuery.end(); ++enginesIter) {
- enginesIter.value()->m_client = 0;
- if (enginesIter.value()->state() == QDeclarativeDebugQuery::Waiting)
- enginesIter.value()->setState(QDeclarativeDebugQuery::Error);
- }
-
- QHash<int, QDeclarativeDebugRootContextQuery*>::iterator rootContextIter = rootContextQuery.begin();
- for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) {
- rootContextIter.value()->m_client = 0;
- if (rootContextIter.value()->state() == QDeclarativeDebugQuery::Waiting)
- rootContextIter.value()->setState(QDeclarativeDebugQuery::Error);
- }
-
- QHash<int, QDeclarativeDebugObjectQuery*>::iterator objectIter = objectQuery.begin();
- for (; objectIter != objectQuery.end(); ++objectIter) {
- objectIter.value()->m_client = 0;
- if (objectIter.value()->state() == QDeclarativeDebugQuery::Waiting)
- objectIter.value()->setState(QDeclarativeDebugQuery::Error);
- }
-
- QHash<int, QDeclarativeDebugExpressionQuery*>::iterator exprIter = expressionQuery.begin();
- for (; exprIter != expressionQuery.end(); ++exprIter) {
- exprIter.value()->m_client = 0;
- if (exprIter.value()->state() == QDeclarativeDebugQuery::Waiting)
- exprIter.value()->setState(QDeclarativeDebugQuery::Error);
- }
-
- QHash<int, QDeclarativeDebugWatch*>::iterator watchIter = watched.begin();
- for (; watchIter != watched.end(); ++watchIter) {
- watchIter.value()->m_client = 0;
- watchIter.value()->setState(QDeclarativeDebugWatch::Dead);
- }
-}
-
-int QDeclarativeEngineDebugPrivate::getId()
-{
- return nextId++;
-}
-
-void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugEnginesQuery *q)
-{
- if (c && q) {
- QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
- p->enginesQuery.remove(q->m_queryId);
- }
-}
-
-void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c,
- QDeclarativeDebugRootContextQuery *q)
-{
- if (c && q) {
- QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
- p->rootContextQuery.remove(q->m_queryId);
- }
-}
-
-void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugObjectQuery *q)
-{
- if (c && q) {
- QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
- p->objectQuery.remove(q->m_queryId);
- }
-}
-
-void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugExpressionQuery *q)
-{
- if (c && q) {
- QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
- p->expressionQuery.remove(q->m_queryId);
- }
-}
-
-void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugWatch *w)
-{
- if (c && w) {
- QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
- p->watched.remove(w->m_queryId);
- }
-}
-
-void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o,
- bool simple)
-{
- QDeclarativeEngineDebugService::QDeclarativeObjectData data;
- ds >> data;
- o.m_debugId = data.objectId;
- o.m_class = data.objectType;
- o.m_idString = data.idString;
- o.m_name = data.objectName;
- o.m_source.m_url = data.url;
- o.m_source.m_lineNumber = data.lineNumber;
- o.m_source.m_columnNumber = data.columnNumber;
- o.m_contextDebugId = data.contextId;
-
- if (simple)
- return;
-
- int childCount;
- bool recur;
- ds >> childCount >> recur;
-
- for (int ii = 0; ii < childCount; ++ii) {
- o.m_children.append(QDeclarativeDebugObjectReference());
- decode(ds, o.m_children.last(), !recur);
- }
-
- int propCount;
- ds >> propCount;
-
- for (int ii = 0; ii < propCount; ++ii) {
- QDeclarativeEngineDebugService::QDeclarativeObjectProperty data;
- ds >> data;
- QDeclarativeDebugPropertyReference prop;
- prop.m_objectDebugId = o.m_debugId;
- prop.m_name = data.name;
- prop.m_binding = data.binding;
- prop.m_hasNotifySignal = data.hasNotifySignal;
- prop.m_valueTypeName = data.valueTypeName;
- switch (data.type) {
- case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Basic:
- case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::List:
- case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::SignalProperty:
- {
- prop.m_value = data.value;
- break;
- }
- case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Object:
- {
- QDeclarativeDebugObjectReference obj;
- obj.m_debugId = prop.m_value.toInt();
- prop.m_value = QVariant::fromValue(obj);
- break;
- }
- case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Unknown:
- break;
- }
- o.m_properties << prop;
- }
-}
-
-void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugContextReference &c)
-{
- ds >> c.m_name >> c.m_debugId;
-
- int contextCount;
- ds >> contextCount;
-
- for (int ii = 0; ii < contextCount; ++ii) {
- c.m_contexts.append(QDeclarativeDebugContextReference());
- decode(ds, c.m_contexts.last());
- }
-
- int objectCount;
- ds >> objectCount;
-
- for (int ii = 0; ii < objectCount; ++ii) {
- QDeclarativeDebugObjectReference obj;
- decode(ds, obj, true);
-
- obj.m_contextDebugId = c.m_debugId;
- c.m_objects << obj;
- }
-}
-
-void QDeclarativeEngineDebugPrivate::stateChanged(QDeclarativeEngineDebug::State status)
-{
- emit q_func()->stateChanged(status);
-}
-
-void QDeclarativeEngineDebugPrivate::message(const QByteArray &data)
-{
- QDataStream ds(data);
-
- QByteArray type;
- ds >> type;
-
- //qDebug() << "QDeclarativeEngineDebugPrivate::message()" << type;
-
- if (type == "LIST_ENGINES_R") {
- int queryId;
- ds >> queryId;
-
- QDeclarativeDebugEnginesQuery *query = enginesQuery.value(queryId);
- if (!query)
- return;
- enginesQuery.remove(queryId);
-
- int count;
- ds >> count;
-
- for (int ii = 0; ii < count; ++ii) {
- QDeclarativeDebugEngineReference ref;
- ds >> ref.m_name;
- ds >> ref.m_debugId;
- query->m_engines << ref;
- }
-
- query->m_client = 0;
- query->setState(QDeclarativeDebugQuery::Completed);
- } else if (type == "LIST_OBJECTS_R") {
- int queryId;
- ds >> queryId;
-
- QDeclarativeDebugRootContextQuery *query = rootContextQuery.value(queryId);
- if (!query)
- return;
- rootContextQuery.remove(queryId);
-
- if (!ds.atEnd())
- decode(ds, query->m_context);
-
- query->m_client = 0;
- query->setState(QDeclarativeDebugQuery::Completed);
- } else if (type == "FETCH_OBJECT_R") {
- int queryId;
- ds >> queryId;
-
- QDeclarativeDebugObjectQuery *query = objectQuery.value(queryId);
- if (!query)
- return;
- objectQuery.remove(queryId);
-
- if (!ds.atEnd())
- decode(ds, query->m_object, false);
-
- query->m_client = 0;
- query->setState(QDeclarativeDebugQuery::Completed);
- } else if (type == "EVAL_EXPRESSION_R") {
- int queryId;
- QVariant result;
- ds >> queryId >> result;
-
- QDeclarativeDebugExpressionQuery *query = expressionQuery.value(queryId);
- if (!query)
- return;
- expressionQuery.remove(queryId);
-
- query->m_result = result;
- query->m_client = 0;
- query->setState(QDeclarativeDebugQuery::Completed);
- } else if (type == "WATCH_PROPERTY_R") {
- int queryId;
- bool ok;
- ds >> queryId >> ok;
-
- QDeclarativeDebugWatch *watch = watched.value(queryId);
- if (!watch)
- return;
-
- watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive);
- } else if (type == "WATCH_OBJECT_R") {
- int queryId;
- bool ok;
- ds >> queryId >> ok;
-
- QDeclarativeDebugWatch *watch = watched.value(queryId);
- if (!watch)
- return;
-
- watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive);
- } else if (type == "WATCH_EXPR_OBJECT_R") {
- int queryId;
- bool ok;
- ds >> queryId >> ok;
-
- QDeclarativeDebugWatch *watch = watched.value(queryId);
- if (!watch)
- return;
-
- watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive);
- } else if (type == "UPDATE_WATCH") {
- int queryId;
- int debugId;
- QByteArray name;
- QVariant value;
- ds >> queryId >> debugId >> name >> value;
-
- QDeclarativeDebugWatch *watch = watched.value(queryId, 0);
- if (!watch)
- return;
- emit watch->valueChanged(name, value);
- } else if (type == "OBJECT_CREATED") {
- emit q_func()->newObjects();
- }
-}
-
-QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent)
- : QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent)
-{
-}
-
-QDeclarativeEngineDebug::~QDeclarativeEngineDebug()
-{
-}
-
-QDeclarativeEngineDebug::State QDeclarativeEngineDebug::state() const
-{
- Q_D(const QDeclarativeEngineDebug);
-
- return static_cast<QDeclarativeEngineDebug::State>(d->client->state());
-}
-
-QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent)
-{
- Q_D(QDeclarativeEngineDebug);
-
- QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent);
- if (d->client->state() == QDeclarativeDebugClient::Enabled) {
- int queryId = d->getId();
- watch->m_queryId = queryId;
- watch->m_client = this;
- watch->m_objectDebugId = property.objectDebugId();
- watch->m_name = property.name();
- d->watched.insert(queryId, watch);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8();
- d->client->sendMessage(message);
- } else {
- watch->m_state = QDeclarativeDebugWatch::Dead;
- }
-
- return watch;
-}
-
-QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugContextReference &, const QString &, QObject *)
-{
- qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented");
- return 0;
-}
-
-QDeclarativeDebugObjectExpressionWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, const QString &expr, QObject *parent)
-{
- Q_D(QDeclarativeEngineDebug);
- QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent);
- if (d->client->state() == QDeclarativeDebugClient::Enabled) {
- int queryId = d->getId();
- watch->m_queryId = queryId;
- watch->m_client = this;
- watch->m_objectDebugId = object.debugId();
- watch->m_expr = expr;
- d->watched.insert(queryId, watch);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr;
- d->client->sendMessage(message);
- } else {
- watch->m_state = QDeclarativeDebugWatch::Dead;
- }
- return watch;
-}
-
-QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, QObject *parent)
-{
- Q_D(QDeclarativeEngineDebug);
-
- QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent);
- if (d->client->state() == QDeclarativeDebugClient::Enabled) {
- int queryId = d->getId();
- watch->m_queryId = queryId;
- watch->m_client = this;
- watch->m_objectDebugId = object.debugId();
- d->watched.insert(queryId, watch);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId();
- d->client->sendMessage(message);
- } else {
- watch->m_state = QDeclarativeDebugWatch::Dead;
- }
-
- return watch;
-}
-
-QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugFileReference &, QObject *)
-{
- qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented");
- return 0;
-}
-
-void QDeclarativeEngineDebug::removeWatch(QDeclarativeDebugWatch *watch)
-{
- Q_D(QDeclarativeEngineDebug);
-
- if (!watch || !watch->m_client)
- return;
-
- watch->m_client = 0;
- watch->setState(QDeclarativeDebugWatch::Inactive);
-
- d->watched.remove(watch->queryId());
-
- if (d->client && d->client->state() == QDeclarativeDebugClient::Enabled) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("NO_WATCH") << watch->queryId();
- d->client->sendMessage(message);
- }
-}
-
-QDeclarativeDebugEnginesQuery *QDeclarativeEngineDebug::queryAvailableEngines(QObject *parent)
-{
- Q_D(QDeclarativeEngineDebug);
-
- QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent);
- if (d->client->state() == QDeclarativeDebugClient::Enabled) {
- query->m_client = this;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->enginesQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("LIST_ENGINES") << queryId;
- d->client->sendMessage(message);
- } else {
- query->m_state = QDeclarativeDebugQuery::Error;
- }
-
- return query;
-}
-
-QDeclarativeDebugRootContextQuery *QDeclarativeEngineDebug::queryRootContexts(const QDeclarativeDebugEngineReference &engine, QObject *parent)
-{
- Q_D(QDeclarativeEngineDebug);
-
- QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent);
- if (d->client->state() == QDeclarativeDebugClient::Enabled && engine.debugId() != -1) {
- query->m_client = this;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->rootContextQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId();
- d->client->sendMessage(message);
- } else {
- query->m_state = QDeclarativeDebugQuery::Error;
- }
-
- return query;
-}
-
-QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclarativeDebugObjectReference &object, QObject *parent)
-{
- Q_D(QDeclarativeEngineDebug);
-
- QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent);
- if (d->client->state() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) {
- query->m_client = this;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->objectQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
- << false << true;
- d->client->sendMessage(message);
- } else {
- query->m_state = QDeclarativeDebugQuery::Error;
- }
-
- return query;
-}
-
-QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(const QDeclarativeDebugObjectReference &object, QObject *parent)
-{
- Q_D(QDeclarativeEngineDebug);
-
- QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent);
- if (d->client->state() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) {
- query->m_client = this;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->objectQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
- << true << true;
- d->client->sendMessage(message);
- } else {
- query->m_state = QDeclarativeDebugQuery::Error;
- }
-
- return query;
-}
-
-QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent)
-{
- Q_D(QDeclarativeEngineDebug);
-
- QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent);
- if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
- query->m_client = this;
- query->m_expr = expr;
- int queryId = d->getId();
- query->m_queryId = queryId;
- d->expressionQuery.insert(queryId, query);
-
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr;
- d->client->sendMessage(message);
- } else {
- query->m_state = QDeclarativeDebugQuery::Error;
- }
-
- return query;
-}
-
-bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName,
- const QVariant &bindingExpression,
- bool isLiteralValue,
- QString source, int line)
-{
- Q_D(QDeclarativeEngineDebug);
-
- if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line;
- d->client->sendMessage(message);
- return true;
- } else {
- return false;
- }
-}
-
-bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName)
-{
- Q_D(QDeclarativeEngineDebug);
-
- if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName;
- d->client->sendMessage(message);
- return true;
- } else {
- return false;
- }
-}
-
-bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &methodName,
- const QString &methodBody)
-{
- Q_D(QDeclarativeEngineDebug);
-
- if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody;
- d->client->sendMessage(message);
- return true;
- } else {
- return false;
- }
-}
-
-QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent)
- : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1)
-{
-}
-
-QDeclarativeDebugWatch::~QDeclarativeDebugWatch()
-{
- if (m_client && m_queryId != -1)
- QDeclarativeEngineDebugPrivate::remove(m_client, this);
-}
-
-int QDeclarativeDebugWatch::queryId() const
-{
- return m_queryId;
-}
-
-int QDeclarativeDebugWatch::objectDebugId() const
-{
- return m_objectDebugId;
-}
-
-QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state() const
-{
- return m_state;
-}
-
-void QDeclarativeDebugWatch::setState(State s)
-{
- if (m_state == s)
- return;
- m_state = s;
- emit stateChanged(m_state);
-}
-
-QDeclarativeDebugPropertyWatch::QDeclarativeDebugPropertyWatch(QObject *parent)
- : QDeclarativeDebugWatch(parent)
-{
-}
-
-QString QDeclarativeDebugPropertyWatch::name() const
-{
- return m_name;
-}
-
-
-QDeclarativeDebugObjectExpressionWatch::QDeclarativeDebugObjectExpressionWatch(QObject *parent)
- : QDeclarativeDebugWatch(parent)
-{
-}
-
-QString QDeclarativeDebugObjectExpressionWatch::expression() const
-{
- return m_expr;
-}
-
-
-QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent)
- : QObject(parent), m_state(Waiting)
-{
-}
-
-QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state() const
-{
- return m_state;
-}
-
-bool QDeclarativeDebugQuery::isWaiting() const
-{
- return m_state == Waiting;
-}
-
-void QDeclarativeDebugQuery::setState(State s)
-{
- if (m_state == s)
- return;
- m_state = s;
- emit stateChanged(m_state);
-}
-
-QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent)
- : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
-{
-}
-
-QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery()
-{
- if (m_client && m_queryId != -1)
- QDeclarativeEngineDebugPrivate::remove(m_client, this);
-}
-
-QList<QDeclarativeDebugEngineReference> QDeclarativeDebugEnginesQuery::engines() const
-{
- return m_engines;
-}
-
-QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent)
- : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
-{
-}
-
-QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery()
-{
- if (m_client && m_queryId != -1)
- QDeclarativeEngineDebugPrivate::remove(m_client, this);
-}
-
-QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext() const
-{
- return m_context;
-}
-
-QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent)
- : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
-{
-}
-
-QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery()
-{
- if (m_client && m_queryId != -1)
- QDeclarativeEngineDebugPrivate::remove(m_client, this);
-}
-
-QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const
-{
- return m_object;
-}
-
-QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent)
- : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
-{
-}
-
-QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery()
-{
- if (m_client && m_queryId != -1)
- QDeclarativeEngineDebugPrivate::remove(m_client, this);
-}
-
-QVariant QDeclarativeDebugExpressionQuery::expression() const
-{
- return m_expr;
-}
-
-QVariant QDeclarativeDebugExpressionQuery::result() const
-{
- return m_result;
-}
-
-QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference()
- : m_debugId(-1)
-{
-}
-
-QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId)
- : m_debugId(debugId)
-{
-}
-
-QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o)
- : m_debugId(o.m_debugId), m_name(o.m_name)
-{
-}
-
-QDeclarativeDebugEngineReference &
-QDeclarativeDebugEngineReference::operator=(const QDeclarativeDebugEngineReference &o)
-{
- m_debugId = o.m_debugId; m_name = o.m_name;
- return *this;
-}
-
-int QDeclarativeDebugEngineReference::debugId() const
-{
- return m_debugId;
-}
-
-QString QDeclarativeDebugEngineReference::name() const
-{
- return m_name;
-}
-
-QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference()
- : m_debugId(-1), m_contextDebugId(-1)
-{
-}
-
-QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId)
- : m_debugId(debugId), m_contextDebugId(-1)
-{
-}
-
-QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o)
- : m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString),
- m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId),
- m_properties(o.m_properties), m_children(o.m_children)
-{
-}
-
-QDeclarativeDebugObjectReference &
-QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o)
-{
- m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString;
- m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
- m_properties = o.m_properties; m_children = o.m_children;
- return *this;
-}
-
-int QDeclarativeDebugObjectReference::debugId() const
-{
- return m_debugId;
-}
-
-QString QDeclarativeDebugObjectReference::className() const
-{
- return m_class;
-}
-
-QString QDeclarativeDebugObjectReference::idString() const
-{
- return m_idString;
-}
-
-QString QDeclarativeDebugObjectReference::name() const
-{
- return m_name;
-}
-
-QDeclarativeDebugFileReference QDeclarativeDebugObjectReference::source() const
-{
- return m_source;
-}
-
-int QDeclarativeDebugObjectReference::contextDebugId() const
-{
- return m_contextDebugId;
-}
-
-QList<QDeclarativeDebugPropertyReference> QDeclarativeDebugObjectReference::properties() const
-{
- return m_properties;
-}
-
-QList<QDeclarativeDebugObjectReference> QDeclarativeDebugObjectReference::children() const
-{
- return m_children;
-}
-
-QDeclarativeDebugContextReference::QDeclarativeDebugContextReference()
- : m_debugId(-1)
-{
-}
-
-QDeclarativeDebugContextReference::QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &o)
- : m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts)
-{
-}
-
-QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o)
-{
- m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects;
- m_contexts = o.m_contexts;
- return *this;
-}
-
-int QDeclarativeDebugContextReference::debugId() const
-{
- return m_debugId;
-}
-
-QString QDeclarativeDebugContextReference::name() const
-{
- return m_name;
-}
-
-QList<QDeclarativeDebugObjectReference> QDeclarativeDebugContextReference::objects() const
-{
- return m_objects;
-}
-
-QList<QDeclarativeDebugContextReference> QDeclarativeDebugContextReference::contexts() const
-{
- return m_contexts;
-}
-
-QDeclarativeDebugFileReference::QDeclarativeDebugFileReference()
- : m_lineNumber(-1), m_columnNumber(-1)
-{
-}
-
-QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &o)
- : m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber)
-{
-}
-
-QDeclarativeDebugFileReference &QDeclarativeDebugFileReference::operator=(const QDeclarativeDebugFileReference &o)
-{
- m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber;
- return *this;
-}
-
-QUrl QDeclarativeDebugFileReference::url() const
-{
- return m_url;
-}
-
-void QDeclarativeDebugFileReference::setUrl(const QUrl &u)
-{
- m_url = u;
-}
-
-int QDeclarativeDebugFileReference::lineNumber() const
-{
- return m_lineNumber;
-}
-
-void QDeclarativeDebugFileReference::setLineNumber(int l)
-{
- m_lineNumber = l;
-}
-
-int QDeclarativeDebugFileReference::columnNumber() const
-{
- return m_columnNumber;
-}
-
-void QDeclarativeDebugFileReference::setColumnNumber(int c)
-{
- m_columnNumber = c;
-}
-
-QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference()
- : m_objectDebugId(-1), m_hasNotifySignal(false)
-{
-}
-
-QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &o)
- : m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value),
- m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding),
- m_hasNotifySignal(o.m_hasNotifySignal)
-{
-}
-
-QDeclarativeDebugPropertyReference &QDeclarativeDebugPropertyReference::operator=(const QDeclarativeDebugPropertyReference &o)
-{
- m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value;
- m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding;
- m_hasNotifySignal = o.m_hasNotifySignal;
- return *this;
-}
-
-int QDeclarativeDebugPropertyReference::objectDebugId() const
-{
- return m_objectDebugId;
-}
-
-QString QDeclarativeDebugPropertyReference::name() const
-{
- return m_name;
-}
-
-QString QDeclarativeDebugPropertyReference::valueTypeName() const
-{
- return m_valueTypeName;
-}
-
-QVariant QDeclarativeDebugPropertyReference::value() const
-{
- return m_value;
-}
-
-QString QDeclarativeDebugPropertyReference::binding() const
-{
- return m_binding;
-}
-
-bool QDeclarativeDebugPropertyReference::hasNotifySignal() const
-{
- return m_hasNotifySignal;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/debugger/qdeclarativeenginedebug_p.h b/src/declarative/debugger/qdeclarativeenginedebug_p.h
deleted file mode 100644
index 5ca2987da3..0000000000
--- a/src/declarative/debugger/qdeclarativeenginedebug_p.h
+++ /dev/null
@@ -1,397 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEENGINEDEBUG_H
-#define QDECLARATIVEENGINEDEBUG_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/qobject.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qvariant.h>
-
-#include <private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeDebugConnection;
-class QDeclarativeDebugWatch;
-class QDeclarativeDebugPropertyWatch;
-class QDeclarativeDebugObjectExpressionWatch;
-class QDeclarativeDebugEnginesQuery;
-class QDeclarativeDebugRootContextQuery;
-class QDeclarativeDebugObjectQuery;
-class QDeclarativeDebugExpressionQuery;
-class QDeclarativeDebugPropertyReference;
-class QDeclarativeDebugContextReference;
-class QDeclarativeDebugObjectReference;
-class QDeclarativeDebugFileReference;
-class QDeclarativeDebugEngineReference;
-class QDeclarativeEngineDebugPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject
-{
- Q_OBJECT
-public:
- enum State { NotConnected, Unavailable, Enabled };
-
- explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
- ~QDeclarativeEngineDebug();
-
- State state() const;
-
- QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &,
- QObject *parent = 0);
- QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &,
- QObject *parent = 0);
- QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &,
- QObject *parent = 0);
- QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &,
- QObject *parent = 0);
- QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &,
- QObject *parent = 0);
-
- void removeWatch(QDeclarativeDebugWatch *watch);
-
- QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
- QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &,
- QObject *parent = 0);
- QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &,
- QObject *parent = 0);
- QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &,
- QObject *parent = 0);
- QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId,
- const QString &expr,
- QObject *parent = 0);
- bool setBindingForObject(int objectDebugId, const QString &propertyName,
- const QVariant &bindingExpression, bool isLiteralValue,
- QString source = QString(), int line = -1);
- bool resetBindingForObject(int objectDebugId, const QString &propertyName);
- bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
-
-Q_SIGNALS:
- void newObjects();
- void stateChanged(State state);
-
-private:
- Q_DECLARE_PRIVATE(QDeclarativeEngineDebug)
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject
-{
- Q_OBJECT
-public:
- enum State { Waiting, Active, Inactive, Dead };
-
- QDeclarativeDebugWatch(QObject *);
- ~QDeclarativeDebugWatch();
-
- int queryId() const;
- int objectDebugId() const;
- State state() const;
-
-Q_SIGNALS:
- void stateChanged(QDeclarativeDebugWatch::State);
- //void objectChanged(int, const QDeclarativeDebugObjectReference &);
- //void valueChanged(int, const QVariant &);
-
- // Server sends value as string if it is a user-type variant
- void valueChanged(const QByteArray &name, const QVariant &value);
-
-private:
- friend class QDeclarativeEngineDebug;
- friend class QDeclarativeEngineDebugPrivate;
- void setState(State);
- State m_state;
- int m_queryId;
- QDeclarativeEngineDebug *m_client;
- int m_objectDebugId;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch
-{
- Q_OBJECT
-public:
- QDeclarativeDebugPropertyWatch(QObject *parent);
-
- QString name() const;
-
-private:
- friend class QDeclarativeEngineDebug;
- QString m_name;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch
-{
- Q_OBJECT
-public:
- QDeclarativeDebugObjectExpressionWatch(QObject *parent);
-
- QString expression() const;
-
-private:
- friend class QDeclarativeEngineDebug;
- QString m_expr;
- int m_debugId;
-};
-
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject
-{
- Q_OBJECT
-public:
- enum State { Waiting, Error, Completed };
-
- State state() const;
- bool isWaiting() const;
-
-Q_SIGNALS:
- void stateChanged(QDeclarativeDebugQuery::State);
-
-protected:
- QDeclarativeDebugQuery(QObject *);
-
-private:
- friend class QDeclarativeEngineDebug;
- friend class QDeclarativeEngineDebugPrivate;
- void setState(State);
- State m_state;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugFileReference
-{
-public:
- QDeclarativeDebugFileReference();
- QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &);
- QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &);
-
- QUrl url() const;
- void setUrl(const QUrl &);
- int lineNumber() const;
- void setLineNumber(int);
- int columnNumber() const;
- void setColumnNumber(int);
-
-private:
- friend class QDeclarativeEngineDebugPrivate;
- QUrl m_url;
- int m_lineNumber;
- int m_columnNumber;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEngineReference
-{
-public:
- QDeclarativeDebugEngineReference();
- QDeclarativeDebugEngineReference(int);
- QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &);
- QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &);
-
- int debugId() const;
- QString name() const;
-
-private:
- friend class QDeclarativeEngineDebugPrivate;
- int m_debugId;
- QString m_name;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectReference
-{
-public:
- QDeclarativeDebugObjectReference();
- QDeclarativeDebugObjectReference(int);
- QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &);
- QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &);
-
- int debugId() const;
- QString className() const;
- QString idString() const;
- QString name() const;
-
- QDeclarativeDebugFileReference source() const;
- int contextDebugId() const;
-
- QList<QDeclarativeDebugPropertyReference> properties() const;
- QList<QDeclarativeDebugObjectReference> children() const;
-
-private:
- friend class QDeclarativeEngineDebugPrivate;
- int m_debugId;
- QString m_class;
- QString m_idString;
- QString m_name;
- QDeclarativeDebugFileReference m_source;
- int m_contextDebugId;
- QList<QDeclarativeDebugPropertyReference> m_properties;
- QList<QDeclarativeDebugObjectReference> m_children;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugContextReference
-{
-public:
- QDeclarativeDebugContextReference();
- QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &);
- QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &);
-
- int debugId() const;
- QString name() const;
-
- QList<QDeclarativeDebugObjectReference> objects() const;
- QList<QDeclarativeDebugContextReference> contexts() const;
-
-private:
- friend class QDeclarativeEngineDebugPrivate;
- int m_debugId;
- QString m_name;
- QList<QDeclarativeDebugObjectReference> m_objects;
- QList<QDeclarativeDebugContextReference> m_contexts;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyReference
-{
-public:
- QDeclarativeDebugPropertyReference();
- QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &);
- QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &);
-
- int objectDebugId() const;
- QString name() const;
- QVariant value() const;
- QString valueTypeName() const;
- QString binding() const;
- bool hasNotifySignal() const;
-
-private:
- friend class QDeclarativeEngineDebugPrivate;
- int m_objectDebugId;
- QString m_name;
- QVariant m_value;
- QString m_valueTypeName;
- QString m_binding;
- bool m_hasNotifySignal;
-};
-
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery
-{
- Q_OBJECT
-public:
- virtual ~QDeclarativeDebugEnginesQuery();
- QList<QDeclarativeDebugEngineReference> engines() const;
-private:
- friend class QDeclarativeEngineDebug;
- friend class QDeclarativeEngineDebugPrivate;
- QDeclarativeDebugEnginesQuery(QObject *);
- QDeclarativeEngineDebug *m_client;
- int m_queryId;
- QList<QDeclarativeDebugEngineReference> m_engines;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery
-{
- Q_OBJECT
-public:
- virtual ~QDeclarativeDebugRootContextQuery();
- QDeclarativeDebugContextReference rootContext() const;
-private:
- friend class QDeclarativeEngineDebug;
- friend class QDeclarativeEngineDebugPrivate;
- QDeclarativeDebugRootContextQuery(QObject *);
- QDeclarativeEngineDebug *m_client;
- int m_queryId;
- QDeclarativeDebugContextReference m_context;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery
-{
- Q_OBJECT
-public:
- virtual ~QDeclarativeDebugObjectQuery();
- QDeclarativeDebugObjectReference object() const;
-private:
- friend class QDeclarativeEngineDebug;
- friend class QDeclarativeEngineDebugPrivate;
- QDeclarativeDebugObjectQuery(QObject *);
- QDeclarativeEngineDebug *m_client;
- int m_queryId;
- QDeclarativeDebugObjectReference m_object;
-
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery
-{
- Q_OBJECT
-public:
- virtual ~QDeclarativeDebugExpressionQuery();
- QVariant expression() const;
- QVariant result() const;
-private:
- friend class QDeclarativeEngineDebug;
- friend class QDeclarativeEngineDebugPrivate;
- QDeclarativeDebugExpressionQuery(QObject *);
- QDeclarativeEngineDebug *m_client;
- int m_queryId;
- QVariant m_expr;
- QVariant m_result;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeDebugEngineReference)
-Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference)
-Q_DECLARE_METATYPE(QDeclarativeDebugContextReference)
-Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEENGINEDEBUG_H
diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp
deleted file mode 100644
index 4943959c33..0000000000
--- a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp
+++ /dev/null
@@ -1,733 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeenginedebugservice_p.h"
-
-#include "qdeclarativedebugstatesdelegate_p.h"
-#include <private/qdeclarativeboundsignal_p.h>
-#include <qdeclarativeengine.h>
-#include <private/qdeclarativemetatype_p.h>
-#include <qdeclarativeproperty.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativecontext_p.h>
-#include <private/qdeclarativewatcher_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <private/qdeclarativevmemetaobject_p.h>
-#include <private/qdeclarativeexpression_p.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qmetaobject.h>
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QDeclarativeEngineDebugService, qmlEngineDebugService);
-
-QDeclarativeEngineDebugService *QDeclarativeEngineDebugService::instance()
-{
- return qmlEngineDebugService();
-}
-
-QDeclarativeEngineDebugService::QDeclarativeEngineDebugService(QObject *parent)
- : QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), 1, parent),
- m_watch(new QDeclarativeWatcher(this)),
- m_statesDelegate(0)
-{
- QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)),
- this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant)));
-
- registerService();
-}
-
-QDeclarativeEngineDebugService::~QDeclarativeEngineDebugService()
-{
- delete m_statesDelegate;
-}
-
-QDataStream &operator<<(QDataStream &ds,
- const QDeclarativeEngineDebugService::QDeclarativeObjectData &data)
-{
- ds << data.url << data.lineNumber << data.columnNumber << data.idString
- << data.objectName << data.objectType << data.objectId << data.contextId;
- return ds;
-}
-
-QDataStream &operator>>(QDataStream &ds,
- QDeclarativeEngineDebugService::QDeclarativeObjectData &data)
-{
- ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
- >> data.objectName >> data.objectType >> data.objectId >> data.contextId;
- return ds;
-}
-
-QDataStream &operator<<(QDataStream &ds,
- const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data)
-{
- ds << (int)data.type << data.name << data.value << data.valueTypeName
- << data.binding << data.hasNotifySignal;
- return ds;
-}
-
-QDataStream &operator>>(QDataStream &ds,
- QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data)
-{
- int type;
- ds >> type >> data.name >> data.value >> data.valueTypeName
- >> data.binding >> data.hasNotifySignal;
- data.type = (QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Type)type;
- return ds;
-}
-
-static inline bool isSignalPropertyName(const QString &signalName)
-{
- // see QmlCompiler::isSignalPropertyName
- return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) &&
- signalName.at(2).isLetter() && signalName.at(2).isUpper();
-}
-
-static bool hasValidSignal(QObject *object, const QString &propertyName)
-{
- if (!isSignalPropertyName(propertyName))
- return false;
-
- QString signalName = propertyName.mid(2);
- signalName[0] = signalName.at(0).toLower();
-
- int sigIdx = QDeclarativePropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex();
-
- if (sigIdx == -1)
- return false;
-
- return true;
-}
-
-QDeclarativeEngineDebugService::QDeclarativeObjectProperty
-QDeclarativeEngineDebugService::propertyData(QObject *obj, int propIdx)
-{
- QDeclarativeObjectProperty rv;
-
- QMetaProperty prop = obj->metaObject()->property(propIdx);
-
- rv.type = QDeclarativeObjectProperty::Unknown;
- rv.valueTypeName = QString::fromUtf8(prop.typeName());
- rv.name = QString::fromUtf8(prop.name());
- rv.hasNotifySignal = prop.hasNotifySignal();
- QDeclarativeAbstractBinding *binding =
- QDeclarativePropertyPrivate::binding(QDeclarativeProperty(obj, rv.name));
- if (binding)
- rv.binding = binding->expression();
-
- if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) {
- rv.type = QDeclarativeObjectProperty::Basic;
- } else if (QDeclarativeMetaType::isQObject(prop.userType())) {
- rv.type = QDeclarativeObjectProperty::Object;
- } else if (QDeclarativeMetaType::isList(prop.userType())) {
- rv.type = QDeclarativeObjectProperty::List;
- }
-
- QVariant value;
- if (rv.type != QDeclarativeObjectProperty::Unknown && prop.userType() != 0) {
- value = prop.read(obj);
- }
- rv.value = valueContents(value);
-
- return rv;
-}
-
-QVariant QDeclarativeEngineDebugService::valueContents(const QVariant &value) const
-{
- int userType = value.userType();
-
- //QObject * is not streamable.
- //Convert all such instances to a String value
-
- if (value.type() == QVariant::List) {
- QVariantList contents;
- QVariantList list = value.toList();
- int count = list.size();
- for (int i = 0; i < count; i++)
- contents << valueContents(list.at(i));
- return contents;
- }
-
- if (value.type() == QVariant::Map) {
- QVariantMap contents;
- QMapIterator<QString, QVariant> i(value.toMap());
- while (i.hasNext()) {
- i.next();
- contents.insert(i.key(), valueContents(i.value()));
- }
- return contents;
- }
-
- if (QDeclarativeValueTypeFactory::isValueType(userType))
- return value;
-
- if (QDeclarativeMetaType::isQObject(userType)) {
- QObject *o = QDeclarativeMetaType::toQObject(value);
- if (o) {
- QString name = o->objectName();
- if (name.isEmpty())
- name = QLatin1String("<unnamed object>");
- return name;
- }
- }
-
- return QLatin1String("<unknown value>");
-}
-
-void QDeclarativeEngineDebugService::buildObjectDump(QDataStream &message,
- QObject *object, bool recur, bool dumpProperties)
-{
- message << objectData(object);
-
- QObjectList children = object->children();
-
- int childrenCount = children.count();
- for (int ii = 0; ii < children.count(); ++ii) {
- if (qobject_cast<QDeclarativeContext*>(children[ii]) || QDeclarativeBoundSignal::cast(children[ii]))
- --childrenCount;
- }
-
- message << childrenCount << recur;
-
- QList<QDeclarativeObjectProperty> fakeProperties;
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QObject *child = children.at(ii);
- if (qobject_cast<QDeclarativeContext*>(child))
- continue;
- QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal) {
- if (!dumpProperties)
- continue;
- QDeclarativeObjectProperty prop;
- prop.type = QDeclarativeObjectProperty::SignalProperty;
- prop.hasNotifySignal = false;
- QDeclarativeExpression *expr = signal->expression();
- if (expr) {
- prop.value = expr->expression();
- QObject *scope = expr->scopeObject();
- if (scope) {
- QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature());
- int lparen = sig.indexOf(QLatin1Char('('));
- if (lparen >= 0) {
- QString methodName = sig.mid(0, lparen);
- prop.name = QLatin1String("on") + methodName[0].toUpper()
- + methodName.mid(1);
- }
- }
- }
- fakeProperties << prop;
- } else {
- if (recur)
- buildObjectDump(message, child, recur, dumpProperties);
- else
- message << objectData(child);
- }
- }
-
- if (!dumpProperties) {
- message << 0;
- return;
- }
-
- QList<int> propertyIndexes;
- for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) {
- if (object->metaObject()->property(ii).isScriptable())
- propertyIndexes << ii;
- }
-
- message << propertyIndexes.size() + fakeProperties.count();
-
- for (int ii = 0; ii < propertyIndexes.size(); ++ii)
- message << propertyData(object, propertyIndexes.at(ii));
-
- for (int ii = 0; ii < fakeProperties.count(); ++ii)
- message << fakeProperties[ii];
-}
-
-void QDeclarativeEngineDebugService::prepareDeferredObjects(QObject *obj)
-{
- qmlExecuteDeferred(obj);
-
- QObjectList children = obj->children();
- for (int ii = 0; ii < children.count(); ++ii) {
- QObject *child = children.at(ii);
- prepareDeferredObjects(child);
- }
-
-}
-
-void QDeclarativeEngineDebugService::buildObjectList(QDataStream &message, QDeclarativeContext *ctxt)
-{
- QDeclarativeContextData *p = QDeclarativeContextData::get(ctxt);
-
- QString ctxtName = ctxt->objectName();
- int ctxtId = QDeclarativeDebugService::idForObject(ctxt);
-
- message << ctxtName << ctxtId;
-
- int count = 0;
-
- QDeclarativeContextData *child = p->childContexts;
- while (child) {
- ++count;
- child = child->nextChild;
- }
-
- message << count;
-
- child = p->childContexts;
- while (child) {
- buildObjectList(message, child->asQDeclarativeContext());
- child = child->nextChild;
- }
-
- // Clean deleted objects
- QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt);
- for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
- if (!ctxtPriv->instances.at(ii)) {
- ctxtPriv->instances.removeAt(ii);
- --ii;
- }
- }
-
- message << ctxtPriv->instances.count();
- for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
- message << objectData(ctxtPriv->instances.at(ii));
- }
-}
-
-void QDeclarativeEngineDebugService::buildStatesList(QDeclarativeContext *ctxt, bool cleanList)
-{
- if (m_statesDelegate)
- m_statesDelegate->buildStatesList(ctxt, cleanList);
-}
-
-QDeclarativeEngineDebugService::QDeclarativeObjectData
-QDeclarativeEngineDebugService::objectData(QObject *object)
-{
- QDeclarativeData *ddata = QDeclarativeData::get(object);
- QDeclarativeObjectData rv;
- if (ddata && ddata->outerContext) {
- rv.url = ddata->outerContext->url;
- rv.lineNumber = ddata->lineNumber;
- rv.columnNumber = ddata->columnNumber;
- } else {
- rv.lineNumber = -1;
- rv.columnNumber = -1;
- }
-
- QDeclarativeContext *context = qmlContext(object);
- if (context) {
- QDeclarativeContextData *cdata = QDeclarativeContextData::get(context);
- if (cdata)
- rv.idString = cdata->findObjectId(object);
- }
-
- rv.objectName = object->objectName();
- rv.objectId = QDeclarativeDebugService::idForObject(object);
- rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object));
-
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
- if (type) {
- QString typeName = type->qmlTypeName();
- int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
- rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1);
- } else {
- rv.objectType = QString::fromUtf8(object->metaObject()->className());
- int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_"));
- if (marker != -1)
- rv.objectType = rv.objectType.left(marker);
- }
-
- return rv;
-}
-
-void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message)
-{
- QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message));
-}
-
-void QDeclarativeEngineDebugService::processMessage(const QByteArray &message)
-{
- QDataStream ds(message);
-
- QByteArray type;
- ds >> type;
-
- if (type == "LIST_ENGINES") {
- int queryId;
- ds >> queryId;
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("LIST_ENGINES_R");
- rs << queryId << m_engines.count();
-
- for (int ii = 0; ii < m_engines.count(); ++ii) {
- QDeclarativeEngine *engine = m_engines.at(ii);
-
- QString engineName = engine->objectName();
- int engineId = QDeclarativeDebugService::idForObject(engine);
-
- rs << engineName << engineId;
- }
-
- sendMessage(reply);
- } else if (type == "LIST_OBJECTS") {
- int queryId;
- int engineId = -1;
- ds >> queryId >> engineId;
-
- QDeclarativeEngine *engine =
- qobject_cast<QDeclarativeEngine *>(QDeclarativeDebugService::objectForId(engineId));
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("LIST_OBJECTS_R") << queryId;
-
- if (engine) {
- buildObjectList(rs, engine->rootContext());
- buildStatesList(engine->rootContext(), true);
- }
-
- sendMessage(reply);
- } else if (type == "FETCH_OBJECT") {
- int queryId;
- int objectId;
- bool recurse;
- bool dumpProperties = true;
-
- ds >> queryId >> objectId >> recurse >> dumpProperties;
-
- QObject *object = QDeclarativeDebugService::objectForId(objectId);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("FETCH_OBJECT_R") << queryId;
-
- if (object) {
- if (recurse)
- prepareDeferredObjects(object);
- buildObjectDump(rs, object, recurse, dumpProperties);
- }
-
- sendMessage(reply);
- } else if (type == "WATCH_OBJECT") {
- int queryId;
- int objectId;
-
- ds >> queryId >> objectId;
- bool ok = m_watch->addWatch(queryId, objectId);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("WATCH_OBJECT_R") << queryId << ok;
-
- sendMessage(reply);
- } else if (type == "WATCH_PROPERTY") {
- int queryId;
- int objectId;
- QByteArray property;
-
- ds >> queryId >> objectId >> property;
- bool ok = m_watch->addWatch(queryId, objectId, property);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok;
-
- sendMessage(reply);
- } else if (type == "WATCH_EXPR_OBJECT") {
- int queryId;
- int debugId;
- QString expr;
-
- ds >> queryId >> debugId >> expr;
- bool ok = m_watch->addWatch(queryId, debugId, expr);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok;
- sendMessage(reply);
- } else if (type == "NO_WATCH") {
- int queryId;
-
- ds >> queryId;
- m_watch->removeWatch(queryId);
- } else if (type == "EVAL_EXPRESSION") {
- int queryId;
- int objectId;
- QString expr;
-
- ds >> queryId >> objectId >> expr;
-
- QObject *object = QDeclarativeDebugService::objectForId(objectId);
- QDeclarativeContext *context = qmlContext(object);
- QVariant result;
- if (object && context) {
- QDeclarativeExpression exprObj(context, object, expr);
- bool undefined = false;
- QVariant value = exprObj.evaluate(&undefined);
- if (undefined)
- result = QLatin1String("<undefined>");
- else
- result = valueContents(value);
- } else {
- result = QLatin1String("<unknown context>");
- }
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result;
-
- sendMessage(reply);
- } else if (type == "SET_BINDING") {
- int objectId;
- QString propertyName;
- QVariant expr;
- bool isLiteralValue;
- QString filename;
- int line;
- ds >> objectId >> propertyName >> expr >> isLiteralValue;
- if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2
- ds >> filename >> line;
- }
- setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
- } else if (type == "RESET_BINDING") {
- int objectId;
- QString propertyName;
- ds >> objectId >> propertyName;
- resetBinding(objectId, propertyName);
- } else if (type == "SET_METHOD_BODY") {
- int objectId;
- QString methodName;
- QString methodBody;
- ds >> objectId >> methodName >> methodBody;
- setMethodBody(objectId, methodName, methodBody);
- }
-}
-
-void QDeclarativeEngineDebugService::setBinding(int objectId,
- const QString &propertyName,
- const QVariant &expression,
- bool isLiteralValue,
- QString filename,
- int line,
- int column)
-{
- QObject *object = objectForId(objectId);
- QDeclarativeContext *context = qmlContext(object);
-
- if (object && context) {
- QDeclarativeProperty property(object, propertyName, context);
- if (property.isValid()) {
-
- bool inBaseState = true;
- if (m_statesDelegate) {
- m_statesDelegate->updateBinding(context, property, expression, isLiteralValue,
- filename, line, column, &inBaseState);
- }
-
- if (inBaseState) {
- if (isLiteralValue) {
- property.write(expression);
- } else if (hasValidSignal(object, propertyName)) {
- QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
- QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
- declarativeExpression->setSourceLocation(filename, line, column);
- } else if (property.isProperty()) {
- QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
- binding->setTarget(property);
- binding->setSourceLocation(filename, line, column);
- binding->setNotifyOnValueChanged(true);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
- if (oldBinding)
- oldBinding->destroy();
- binding->update();
- } else {
- qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
- }
- }
-
- } else {
- // not a valid property
- bool ok = false;
- if (m_statesDelegate)
- ok = m_statesDelegate->setBindingForInvalidProperty(object, propertyName, expression, isLiteralValue);
- if (!ok)
- qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
- }
- }
-}
-
-void QDeclarativeEngineDebugService::resetBinding(int objectId, const QString &propertyName)
-{
- QObject *object = objectForId(objectId);
- QDeclarativeContext *context = qmlContext(object);
-
- if (object && context) {
- if (object->property(propertyName.toLatin1()).isValid()) {
- QDeclarativeProperty property(object, propertyName);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(property);
- if (oldBinding) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, 0);
- if (oldBinding)
- oldBinding->destroy();
- }
- if (property.isResettable()) {
- // Note: this will reset the property in any case, without regard to states
- // Right now almost no QDeclarativeItem has reset methods for its properties (with the
- // notable exception of QDeclarativeAnchors), so this is not a big issue
- // later on, setBinding does take states into account
- property.reset();
- } else {
- // overwrite with default value
- if (QDeclarativeType *objType = QDeclarativeMetaType::qmlType(object->metaObject())) {
- if (QObject *emptyObject = objType->create()) {
- if (emptyObject->property(propertyName.toLatin1()).isValid()) {
- QVariant defaultValue = QDeclarativeProperty(emptyObject, propertyName).read();
- if (defaultValue.isValid()) {
- setBinding(objectId, propertyName, defaultValue, true);
- }
- }
- delete emptyObject;
- }
- }
- }
- } else if (hasValidSignal(object, propertyName)) {
- QDeclarativeProperty property(object, propertyName, context);
- QDeclarativePropertyPrivate::setSignalExpression(property, 0);
- } else {
- if (m_statesDelegate)
- m_statesDelegate->resetBindingForInvalidProperty(object, propertyName);
- }
- }
-}
-
-void QDeclarativeEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body)
-{
- QObject *object = objectForId(objectId);
- QDeclarativeContext *context = qmlContext(object);
- if (!object || !context || !context->engine())
- return;
- QDeclarativeContextData *contextData = QDeclarativeContextData::get(context);
- if (!contextData)
- return;
-
- QDeclarativePropertyData dummy;
- QDeclarativePropertyData *prop =
- QDeclarativePropertyCache::property(context->engine(), object, method, dummy);
-
- if (!prop || !prop->isVMEFunction())
- return;
-
- QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex);
- QList<QByteArray> paramNames = metaMethod.parameterNames();
-
- QString paramStr;
- for (int ii = 0; ii < paramNames.count(); ++ii) {
- if (ii != 0) paramStr.append(QLatin1String(","));
- paramStr.append(QString::fromUtf8(paramNames.at(ii)));
- }
-
- QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr +
- QLatin1String(") {");
- jsfunction += body;
- jsfunction += QLatin1String("\n})");
-
- QDeclarativeVMEMetaObject *vmeMetaObject =
- static_cast<QDeclarativeVMEMetaObject*>(QObjectPrivate::get(object)->metaObject);
- Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this
-
- int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
- vmeMetaObject->setVmeMethod(prop->coreIndex, QDeclarativeExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
-}
-
-void QDeclarativeEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
-{
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
-
- rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value);
-
- sendMessage(reply);
-}
-
-void QDeclarativeEngineDebugService::addEngine(QDeclarativeEngine *engine)
-{
- Q_ASSERT(engine);
- Q_ASSERT(!m_engines.contains(engine));
-
- m_engines.append(engine);
-}
-
-void QDeclarativeEngineDebugService::remEngine(QDeclarativeEngine *engine)
-{
- Q_ASSERT(engine);
- Q_ASSERT(m_engines.contains(engine));
-
- m_engines.removeAll(engine);
-}
-
-void QDeclarativeEngineDebugService::objectCreated(QDeclarativeEngine *engine, QObject *object)
-{
- Q_ASSERT(engine);
- Q_ASSERT(m_engines.contains(engine));
-
- int engineId = QDeclarativeDebugService::idForObject(engine);
- int objectId = QDeclarativeDebugService::idForObject(object);
-
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
-
- rs << QByteArray("OBJECT_CREATED") << engineId << objectId;
- sendMessage(reply);
-}
-
-void QDeclarativeEngineDebugService::setStatesDelegate(QDeclarativeDebugStatesDelegate *delegate)
-{
- m_statesDelegate = delegate;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h
deleted file mode 100644
index d252654492..0000000000
--- a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEENGINEDEBUGSERVICE_P_H
-#define QDECLARATIVEENGINEDEBUGSERVICE_P_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 <private/qdeclarativedebugservice_p.h>
-
-#include <QtCore/qurl.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-class QDeclarativeContext;
-class QDeclarativeWatcher;
-class QDataStream;
-class QDeclarativeDebugStatesDelegate;
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebugService : public QDeclarativeDebugService
-{
- Q_OBJECT
-public:
- QDeclarativeEngineDebugService(QObject * = 0);
- ~QDeclarativeEngineDebugService();
-
- struct QDeclarativeObjectData {
- QUrl url;
- int lineNumber;
- int columnNumber;
- QString idString;
- QString objectName;
- QString objectType;
- int objectId;
- int contextId;
- };
-
- struct QDeclarativeObjectProperty {
- enum Type { Unknown, Basic, Object, List, SignalProperty };
- Type type;
- QString name;
- QVariant value;
- QString valueTypeName;
- QString binding;
- bool hasNotifySignal;
- };
-
- void addEngine(QDeclarativeEngine *);
- void remEngine(QDeclarativeEngine *);
- void objectCreated(QDeclarativeEngine *, QObject *);
-
- void setStatesDelegate(QDeclarativeDebugStatesDelegate *);
-
- static QDeclarativeEngineDebugService *instance();
-
-protected:
- virtual void messageReceived(const QByteArray &);
-
-private Q_SLOTS:
- void processMessage(const QByteArray &msg);
- void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
-
-private:
- void prepareDeferredObjects(QObject *);
- void buildObjectList(QDataStream &, QDeclarativeContext *);
- void buildObjectDump(QDataStream &, QObject *, bool, bool);
- void buildStatesList(QDeclarativeContext *, bool);
- QDeclarativeObjectData objectData(QObject *);
- QDeclarativeObjectProperty propertyData(QObject *, int);
- QVariant valueContents(const QVariant &defaultValue) const;
- void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1, int column = 0);
- void resetBinding(int objectId, const QString &propertyName);
- void setMethodBody(int objectId, const QString &method, const QString &body);
-
- QList<QDeclarativeEngine *> m_engines;
- QDeclarativeWatcher *m_watch;
- QDeclarativeDebugStatesDelegate *m_statesDelegate;
-};
-Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectData &);
-Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectData &);
-Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &);
-Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectProperty &);
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEENGINEDEBUGSERVICE_P_H
-
diff --git a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h
deleted file mode 100644
index 77f208ce5b..0000000000
--- a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEINSPECTORINTERFACE_H
-#define QDECLARATIVEINSPECTORINTERFACE_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 <private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class Q_DECLARATIVE_EXPORT QDeclarativeInspectorInterface
-{
-public:
- QDeclarativeInspectorInterface() {}
- virtual ~QDeclarativeInspectorInterface() {}
-
- virtual bool canHandleView(QObject *view) = 0;
-
- virtual void activate(QObject *view) = 0;
- virtual void deactivate() = 0;
-
- virtual void clientMessage(const QByteArray &message) = 0;
-};
-
-#define QDeclarativeInspectorInterface_iid "org.qt-project.Qt.QDeclarativeInspectorInterface"
-
-Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, QDeclarativeInspectorInterface_iid)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEINSPECTORINTERFACE_H
diff --git a/src/declarative/debugger/qdeclarativeinspectorservice.cpp b/src/declarative/debugger/qdeclarativeinspectorservice.cpp
deleted file mode 100644
index 94b04985ba..0000000000
--- a/src/declarative/debugger/qdeclarativeinspectorservice.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeinspectorservice_p.h"
-#include "qdeclarativeinspectorinterface_p.h"
-#include "qdeclarativedebugserver_p.h"
-
-#include <QtCore/QCoreApplication>
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtCore/QPluginLoader>
-
-// print detailed information about loading of plugins
-DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE)
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance)
-
-QDeclarativeInspectorService::QDeclarativeInspectorService()
- : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"), 1)
- , m_currentInspectorPlugin(0)
-{
- registerService();
-}
-
-QDeclarativeInspectorService *QDeclarativeInspectorService::instance()
-{
- return serviceInstance();
-}
-
-void QDeclarativeInspectorService::addView(QObject *view)
-{
- m_views.append(view);
- updateState();
-}
-
-void QDeclarativeInspectorService::removeView(QObject *view)
-{
- m_views.removeAll(view);
- updateState();
-}
-
-void QDeclarativeInspectorService::sendMessage(const QByteArray &message)
-{
- if (state() != Enabled)
- return;
-
- QDeclarativeDebugService::sendMessage(message);
-}
-
-void QDeclarativeInspectorService::stateChanged(State /*state*/)
-{
- QMetaObject::invokeMethod(this, "updateState", Qt::QueuedConnection);
-}
-
-void QDeclarativeInspectorService::updateState()
-{
- if (m_views.isEmpty()) {
- if (m_currentInspectorPlugin) {
- m_currentInspectorPlugin->deactivate();
- m_currentInspectorPlugin = 0;
- }
- return;
- }
-
- if (state() == Enabled) {
- if (m_inspectorPlugins.isEmpty())
- loadInspectorPlugins();
-
- if (m_inspectorPlugins.isEmpty()) {
- qWarning() << "QDeclarativeInspector: No plugins found.";
- QDeclarativeDebugServer::instance()->removeService(this);
- return;
- }
-
- foreach (QDeclarativeInspectorInterface *inspector, m_inspectorPlugins) {
- if (inspector->canHandleView(m_views.first())) {
- m_currentInspectorPlugin = inspector;
- break;
- }
- }
-
- if (!m_currentInspectorPlugin) {
- qWarning() << "QDeclarativeInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'.";
- return;
- }
- m_currentInspectorPlugin->activate(m_views.first());
- } else {
- if (m_currentInspectorPlugin) {
- m_currentInspectorPlugin->deactivate();
- m_currentInspectorPlugin = 0;
- }
- }
-}
-
-void QDeclarativeInspectorService::messageReceived(const QByteArray &message)
-{
- QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message));
-}
-
-void QDeclarativeInspectorService::processMessage(const QByteArray &message)
-{
- if (m_currentInspectorPlugin)
- m_currentInspectorPlugin->clientMessage(message);
-}
-
-void QDeclarativeInspectorService::loadInspectorPlugins()
-{
- QStringList pluginCandidates;
- const QStringList paths = QCoreApplication::libraryPaths();
- foreach (const QString &libPath, paths) {
- const QDir dir(libPath + QLatin1String("/qmltooling"));
- if (dir.exists())
- foreach (const QString &pluginPath, dir.entryList(QDir::Files))
- pluginCandidates << dir.absoluteFilePath(pluginPath);
- }
-
- foreach (const QString &pluginPath, pluginCandidates) {
- if (qmlDebugVerbose())
- qDebug() << "QDeclarativeInspector: Trying to load plugin " << pluginPath << "...";
-
- QPluginLoader loader(pluginPath);
- if (!loader.load()) {
- if (qmlDebugVerbose())
- qDebug() << "QDeclarativeInspector: Error while loading: " << loader.errorString();
-
- continue;
- }
-
- QDeclarativeInspectorInterface *inspector =
- qobject_cast<QDeclarativeInspectorInterface*>(loader.instance());
- if (inspector) {
- if (qmlDebugVerbose())
- qDebug() << "QDeclarativeInspector: Plugin successfully loaded.";
- m_inspectorPlugins << inspector;
- } else {
- if (qmlDebugVerbose())
- qDebug() << "QDeclarativeInspector: Plugin does not implement interface QDeclarativeInspectorInterface.";
-
- loader.unload();
- }
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativeinspectorservice_p.h b/src/declarative/debugger/qdeclarativeinspectorservice_p.h
deleted file mode 100644
index 7ed530adc0..0000000000
--- a/src/declarative/debugger/qdeclarativeinspectorservice_p.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEINSPECTORSERVICE_H
-#define QDECLARATIVEINSPECTORSERVICE_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 "qdeclarativedebugservice_p.h"
-#include <private/qdeclarativeglobal_p.h>
-
-#include <QtCore/QList>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeInspectorInterface;
-
-class Q_DECLARATIVE_EXPORT QDeclarativeInspectorService : public QDeclarativeDebugService
-{
- Q_OBJECT
-
-public:
- QDeclarativeInspectorService();
- static QDeclarativeInspectorService *instance();
-
- void addView(QObject *);
- void removeView(QObject *);
-
- void sendMessage(const QByteArray &message);
-
-protected:
- virtual void stateChanged(State state);
- virtual void messageReceived(const QByteArray &);
-
-private slots:
- void processMessage(const QByteArray &message);
- void updateState();
-
-private:
- void loadInspectorPlugins();
-
- QList<QObject*> m_views;
- QDeclarativeInspectorInterface *m_currentInspectorPlugin;
- QList<QDeclarativeInspectorInterface*> m_inspectorPlugins;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEINSPECTORSERVICE_H
diff --git a/src/declarative/debugger/qdeclarativeprofilerservice.cpp b/src/declarative/debugger/qdeclarativeprofilerservice.cpp
deleted file mode 100644
index 3ad87495bb..0000000000
--- a/src/declarative/debugger/qdeclarativeprofilerservice.cpp
+++ /dev/null
@@ -1,315 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeprofilerservice_p.h"
-
-#include <QtCore/qdatastream.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qthread.h>
-#include <QtCore/qcoreapplication.h>
-
-// this contains QUnifiedTimer
-#include <private/qabstractanimation_p.h>
-
-QT_BEGIN_NAMESPACE
-
-// instance will be set, unset in constructor. Allows static methods to be inlined.
-QDeclarativeProfilerService *QDeclarativeProfilerService::instance = 0;
-Q_GLOBAL_STATIC(QDeclarativeProfilerService, profilerInstance)
-
-
-// convert to a QByteArray that can be sent to the debug client
-// use of QDataStream can skew results
-// (see tst_qdeclarativedebugtrace::trace() benchmark)
-QByteArray QDeclarativeProfilerData::toByteArray() const
-{
- QByteArray data;
- //### using QDataStream is relatively expensive
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << time << messageType << detailType;
- if (messageType == (int)QDeclarativeProfilerService::RangeData)
- ds << detailData;
- if (messageType == (int)QDeclarativeProfilerService::RangeLocation)
- ds << detailData << line << column;
- if (messageType == (int)QDeclarativeProfilerService::Event &&
- detailType == (int)QDeclarativeProfilerService::AnimationFrame)
- ds << framerate << animationcount;
- return data;
-}
-
-QDeclarativeProfilerService::QDeclarativeProfilerService()
- : QDeclarativeDebugService(QLatin1String("CanvasFrameRate"), 1),
- m_enabled(false), m_messageReceived(false)
-{
- m_timer.start();
-
- if (registerService() == Enabled) {
- // wait for first message indicating whether to trace or not
- while (!m_messageReceived)
- waitForMessage();
-
- QUnifiedTimer::instance()->registerProfilerCallback( &animationFrame );
- }
-}
-
-QDeclarativeProfilerService::~QDeclarativeProfilerService()
-{
- instance = 0;
-}
-
-void QDeclarativeProfilerService::initialize()
-{
- // just make sure that the service is properly registered
- instance = profilerInstance();
-}
-
-bool QDeclarativeProfilerService::startProfiling()
-{
- return profilerInstance()->startProfilingImpl();
-}
-
-bool QDeclarativeProfilerService::stopProfiling()
-{
- return profilerInstance()->stopProfilingImpl();
-}
-
-void QDeclarativeProfilerService::sendStartedProfilingMessage()
-{
- profilerInstance()->sendStartedProfilingMessageImpl();
-}
-
-void QDeclarativeProfilerService::addEvent(EventType t)
-{
- profilerInstance()->addEventImpl(t);
-}
-
-void QDeclarativeProfilerService::animationFrame(qint64 delta)
-{
- profilerInstance()->animationFrameImpl(delta);
-}
-
-void QDeclarativeProfilerService::sendProfilingData()
-{
- profilerInstance()->sendMessages();
-}
-
-bool QDeclarativeProfilerService::startProfilingImpl()
-{
- bool success = false;
- if (!profilingEnabled()) {
- setProfilingEnabled(true);
- sendStartedProfilingMessageImpl();
- success = true;
- }
- return success;
-}
-
-bool QDeclarativeProfilerService::stopProfilingImpl()
-{
- bool success = false;
- if (profilingEnabled()) {
- addEventImpl(EndTrace);
- setProfilingEnabled(false);
- success = true;
- }
- return success;
-}
-
-void QDeclarativeProfilerService::sendStartedProfilingMessageImpl()
-{
- if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
- return;
-
- QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)StartTrace, QString(), -1, -1, 0, 0};
- QDeclarativeDebugService::sendMessage(ed.toByteArray());
-}
-
-void QDeclarativeProfilerService::addEventImpl(EventType event)
-{
- if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
- return;
-
- QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)event, QString(), -1, -1, 0, 0};
- processMessage(ed);
-}
-
-void QDeclarativeProfilerService::startRange(RangeType range)
-{
- if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
- return;
-
- QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeStart, (int)range, QString(), -1, -1, 0, 0};
- processMessage(rd);
-}
-
-void QDeclarativeProfilerService::rangeData(RangeType range, const QString &rData)
-{
- if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
- return;
-
- QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData, -1, -1, 0, 0};
- processMessage(rd);
-}
-
-void QDeclarativeProfilerService::rangeData(RangeType range, const QUrl &rData)
-{
- if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
- return;
-
- QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData.toString(QUrl::FormattingOption(0x100)), -1, -1, 0, 0};
- processMessage(rd);
-}
-
-void QDeclarativeProfilerService::rangeLocation(RangeType range, const QString &fileName, int line, int column)
-{
- if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
- return;
-
- QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName, line, column, 0, 0};
- processMessage(rd);
-}
-
-void QDeclarativeProfilerService::rangeLocation(RangeType range, const QUrl &fileName, int line, int column)
-{
- if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
- return;
-
- QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName.toString(QUrl::FormattingOption(0x100)), line, column, 0, 0};
- processMessage(rd);
-}
-
-void QDeclarativeProfilerService::endRange(RangeType range)
-{
- if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled)
- return;
-
- QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeEnd, (int)range, QString(), -1, -1, 0, 0};
- processMessage(rd);
-}
-
-void QDeclarativeProfilerService::animationFrameImpl(qint64 delta)
-{
- Q_ASSERT(QDeclarativeDebugService::isDebuggingEnabled());
- if (!m_enabled)
- return;
-
- int animCount = QUnifiedTimer::instance()->runningAnimationCount();
-
- if (animCount > 0 && delta > 0) {
- // trim fps to integer
- int fps = 1000 / delta;
- QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)AnimationFrame, QString(), -1, -1, fps, animCount};
- processMessage(ed);
- }
-}
-
-/*
- Either send the message directly, or queue up
- a list of messages to send later (via sendMessages)
-*/
-void QDeclarativeProfilerService::processMessage(const QDeclarativeProfilerData &message)
-{
- QMutexLocker locker(&m_mutex);
- m_data.append(message);
-}
-
-bool QDeclarativeProfilerService::profilingEnabled()
-{
- return m_enabled;
-}
-
-void QDeclarativeProfilerService::setProfilingEnabled(bool enable)
-{
- m_enabled = enable;
-}
-
-/*
- Send the messages queued up by processMessage
-*/
-void QDeclarativeProfilerService::sendMessages()
-{
- QMutexLocker locker(&m_mutex);
- QList<QByteArray> messages;
- for (int i = 0; i < m_data.count(); ++i)
- messages << m_data.at(i).toByteArray();
- m_data.clear();
-
- //indicate completion
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (qint64)-1 << (int)Complete;
- messages << data;
-
- QDeclarativeDebugService::sendMessages(messages);
-}
-
-void QDeclarativeProfilerService::stateAboutToBeChanged(QDeclarativeDebugService::State newState)
-{
- if (state() == newState)
- return;
-
- if (state() == Enabled
- && m_enabled) {
- stopProfilingImpl();
- sendMessages();
- }
-}
-
-void QDeclarativeProfilerService::messageReceived(const QByteArray &message)
-{
- QByteArray rwData = message;
- QDataStream stream(&rwData, QIODevice::ReadOnly);
-
- bool enabled;
- stream >> enabled;
-
- m_messageReceived = true;
-
- if (enabled) {
- startProfilingImpl();
- } else {
- if (stopProfilingImpl())
- sendMessages();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativeprofilerservice_p.h b/src/declarative/debugger/qdeclarativeprofilerservice_p.h
deleted file mode 100644
index ef92e6800e..0000000000
--- a/src/declarative/debugger/qdeclarativeprofilerservice_p.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROFILERSERVICE_P_H
-#define QDECLARATIVEPROFILERSERVICE_P_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 <private/qdeclarativedebugservice_p.h>
-#include <QtCore/qelapsedtimer.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qstringbuilder.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-struct Q_AUTOTEST_EXPORT QDeclarativeProfilerData
-{
- qint64 time;
- int messageType;
- int detailType;
-
- //###
- QString detailData; //used by RangeData and RangeLocation
- int line; //used by RangeLocation
- int column; //used by RangeLocation
- int framerate; //used by animation events
- int animationcount; //used by animation events
-
- QByteArray toByteArray() const;
-};
-
-Q_DECLARE_TYPEINFO(QDeclarativeProfilerData, Q_MOVABLE_TYPE);
-
-class QUrl;
-class QDeclarativeEngine;
-
-
-class Q_DECLARATIVE_EXPORT QDeclarativeProfilerService : public QDeclarativeDebugService
-{
-public:
- enum Message {
- Event,
- RangeStart,
- RangeData,
- RangeLocation,
- RangeEnd,
- Complete, // end of transmission
-
- MaximumMessage
- };
-
- enum EventType {
- FramePaint,
- Mouse,
- Key,
- AnimationFrame,
- EndTrace,
- StartTrace,
-
- MaximumEventType
- };
-
- enum RangeType {
- Painting,
- Compiling,
- Creating,
- Binding, //running a binding
- HandlingSignal, //running a signal handler
-
- MaximumRangeType
- };
-
- static void initialize();
-
- static bool startProfiling();
- static bool stopProfiling();
- static void sendStartedProfilingMessage();
- static void addEvent(EventType);
- static void animationFrame(qint64);
-
- static void sendProfilingData();
-
- QDeclarativeProfilerService();
- ~QDeclarativeProfilerService();
-
-protected:
- virtual void stateAboutToBeChanged(State state);
- virtual void messageReceived(const QByteArray &);
-
-private:
- bool startProfilingImpl();
- bool stopProfilingImpl();
- void sendStartedProfilingMessageImpl();
- void addEventImpl(EventType);
- void animationFrameImpl(qint64);
-
- void startRange(RangeType);
- void rangeData(RangeType, const QString &);
- void rangeData(RangeType, const QUrl &);
- void rangeLocation(RangeType, const QString &, int, int);
- void rangeLocation(RangeType, const QUrl &, int, int);
- void endRange(RangeType);
-
-
- bool profilingEnabled();
- void setProfilingEnabled(bool enable);
- void sendMessages();
- void processMessage(const QDeclarativeProfilerData &);
-
-private:
- QElapsedTimer m_timer;
- bool m_enabled;
- bool m_messageReceived;
- QVector<QDeclarativeProfilerData> m_data;
- QMutex m_mutex;
-
- static QDeclarativeProfilerService *instance;
-
- friend struct QDeclarativeBindingProfiler;
- friend struct QDeclarativeHandlingSignalProfiler;
- friend struct QDeclarativeObjectCreatingProfiler;
- friend struct QDeclarativeCompilingProfiler;
-};
-
-//
-// RAII helper structs
-//
-
-struct QDeclarativeBindingProfiler {
- QDeclarativeBindingProfiler(const QString &url, int line, int column)
- {
- QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance;
- enabled = instance ? instance->profilingEnabled() : false;
- if (enabled) {
- instance->startRange(QDeclarativeProfilerService::Binding);
- instance->rangeLocation(QDeclarativeProfilerService::Binding, url, line, column);
- }
- }
-
- ~QDeclarativeBindingProfiler()
- {
- if (enabled)
- QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Binding);
- }
-
- void addDetail(const QString &details)
- {
- if (enabled)
- QDeclarativeProfilerService::instance->rangeData(QDeclarativeProfilerService::Binding,
- details);
- }
-\
- bool enabled;
-};
-
-struct QDeclarativeHandlingSignalProfiler {
- QDeclarativeHandlingSignalProfiler()
- {
- enabled = QDeclarativeProfilerService::instance
- ? QDeclarativeProfilerService::instance->profilingEnabled() : false;
- if (enabled) {
- QDeclarativeProfilerService::instance->startRange(
- QDeclarativeProfilerService::HandlingSignal);
- }
- }
-
- void setSignalInfo(const QString &name, const QString &expression)
- {
- if (enabled)
- QDeclarativeProfilerService::instance->rangeData(
- QDeclarativeProfilerService::HandlingSignal,
- name % QLatin1String(": ") % expression);
- }
-
- void setLocation(const QString &file, int line, int column)
- {
- if (enabled)
- QDeclarativeProfilerService::instance->rangeLocation(
- QDeclarativeProfilerService::HandlingSignal, file, line, column);
- }
-
- ~QDeclarativeHandlingSignalProfiler()
- {
- if (enabled)
- QDeclarativeProfilerService::instance->endRange(
- QDeclarativeProfilerService::HandlingSignal);
- }
-
- bool enabled;
-};
-
-struct QDeclarativeObjectCreatingProfiler {
- QDeclarativeObjectCreatingProfiler()
- {
- QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance;
- enabled = instance ?
- instance->profilingEnabled() : false;
- if (enabled)
- instance->startRange(QDeclarativeProfilerService::Creating);
- }
-
- void setTypeName(const QString &typeName)
- {
- if (enabled)
- QDeclarativeProfilerService::instance->rangeData(
- QDeclarativeProfilerService::Creating, typeName);
- }
-
- void setLocation(const QUrl &url, int line, int column)
- {
- if (enabled)
- QDeclarativeProfilerService::instance->rangeLocation(
- QDeclarativeProfilerService::Creating, url, line, column);
- }
-
- ~QDeclarativeObjectCreatingProfiler()
- {
- if (enabled)
- QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Creating);
- }
-
- bool enabled;
-};
-
-struct QDeclarativeCompilingProfiler {
- QDeclarativeCompilingProfiler(const QString &name)
- {
- QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance;
- enabled = instance ?
- instance->profilingEnabled() : false;
- if (enabled) {
- instance->startRange(QDeclarativeProfilerService::Compiling);
- instance->rangeLocation(QDeclarativeProfilerService::Compiling, name, 1, 1);
- instance->rangeData(QDeclarativeProfilerService::Compiling, name);
- }
- }
-
- ~QDeclarativeCompilingProfiler()
- {
- if (enabled)
- QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Compiling);
- }
-
- bool enabled;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPROFILERSERVICE_P_H
-
diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp
deleted file mode 100644
index fa5d676e0a..0000000000
--- a/src/declarative/debugger/qpacketprotocol.cpp
+++ /dev/null
@@ -1,550 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpacketprotocol_p.h"
-
-#include <QtCore/QBuffer>
-#include <QtCore/QElapsedTimer>
-
-QT_BEGIN_NAMESPACE
-
-static const unsigned int MAX_PACKET_SIZE = 0x7FFFFFFF;
-
-/*!
- \class QPacketProtocol
- \internal
-
- \brief The QPacketProtocol class encapsulates communicating discrete packets
- across fragmented IO channels, such as TCP sockets.
-
- QPacketProtocol makes it simple to send arbitrary sized data "packets" across
- fragmented transports such as TCP and UDP.
-
- As transmission boundaries are not respected, sending packets over protocols
- like TCP frequently involves "stitching" them back together at the receiver.
- QPacketProtocol makes this easier by performing this task for you. Packet
- data sent using QPacketProtocol is prepended with a 4-byte size header
- allowing the receiving QPacketProtocol to buffer the packet internally until
- it has all been received. QPacketProtocol does not perform any sanity
- checking on the size or on the data, so this class should only be used in
- prototyping or trusted situations where DOS attacks are unlikely.
-
- QPacketProtocol does not perform any communications itself. Instead it can
- operate on any QIODevice that supports the QIODevice::readyRead() signal. A
- logical "packet" is encapsulated by the companion QPacket class. The
- following example shows two ways to send data using QPacketProtocol. The
- transmitted data is equivalent in both.
-
- \code
- QTcpSocket socket;
- // ... connect socket ...
-
- QPacketProtocol protocol(&socket);
-
- // Send packet the quick way
- protocol.send() << "Hello world" << 123;
-
- // Send packet the longer way
- QPacket packet;
- packet << "Hello world" << 123;
- protocol.send(packet);
- \endcode
-
- Likewise, the following shows how to read data from QPacketProtocol, assuming
- that the QPacketProtocol::readyRead() signal has been emitted.
-
- \code
- // ... QPacketProtocol::readyRead() is emitted ...
-
- int a;
- QByteArray b;
-
- // Receive packet the quick way
- protocol.read() >> a >> b;
-
- // Receive packet the longer way
- QPacket packet = protocol.read();
- p >> a >> b;
- \endcode
-
- \ingroup io
- \sa QPacket
-*/
-
-class QPacketProtocolPrivate : public QObject
-{
- Q_OBJECT
-public:
- QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev)
- : QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
- waitingForPacket(false), dev(_dev)
- {
- Q_ASSERT(4 == sizeof(qint32));
-
- QObject::connect(this, SIGNAL(readyRead()),
- parent, SIGNAL(readyRead()));
- QObject::connect(this, SIGNAL(packetWritten()),
- parent, SIGNAL(packetWritten()));
- QObject::connect(this, SIGNAL(invalidPacket()),
- parent, SIGNAL(invalidPacket()));
- QObject::connect(dev, SIGNAL(readyRead()),
- this, SLOT(readyToRead()));
- QObject::connect(dev, SIGNAL(aboutToClose()),
- this, SLOT(aboutToClose()));
- QObject::connect(dev, SIGNAL(bytesWritten(qint64)),
- this, SLOT(bytesWritten(qint64)));
- }
-
-Q_SIGNALS:
- void readyRead();
- void packetWritten();
- void invalidPacket();
-
-public Q_SLOTS:
- void aboutToClose()
- {
- inProgress.clear();
- sendingPackets.clear();
- inProgressSize = -1;
- }
-
- void bytesWritten(qint64 bytes)
- {
- Q_ASSERT(!sendingPackets.isEmpty());
-
- while (bytes) {
- if (sendingPackets.at(0) > bytes) {
- sendingPackets[0] -= bytes;
- bytes = 0;
- } else {
- bytes -= sendingPackets.at(0);
- sendingPackets.removeFirst();
- emit packetWritten();
- }
- }
- }
-
- void readyToRead()
- {
- while (true) {
- // Need to get trailing data
- if (-1 == inProgressSize) {
- // We need a size header of sizeof(qint32)
- if (sizeof(qint32) > (uint)dev->bytesAvailable())
- return;
-
- // Read size header
- int read = dev->read((char *)&inProgressSize, sizeof(qint32));
- Q_ASSERT(read == sizeof(qint32));
- Q_UNUSED(read);
-
- // Check sizing constraints
- if (inProgressSize > maxPacketSize) {
- QObject::disconnect(dev, SIGNAL(readyRead()),
- this, SLOT(readyToRead()));
- QObject::disconnect(dev, SIGNAL(aboutToClose()),
- this, SLOT(aboutToClose()));
- QObject::disconnect(dev, SIGNAL(bytesWritten(qint64)),
- this, SLOT(bytesWritten(qint64)));
- dev = 0;
- emit invalidPacket();
- return;
- }
-
- inProgressSize -= sizeof(qint32);
- } else {
- inProgress.append(dev->read(inProgressSize - inProgress.size()));
-
- if (inProgressSize == inProgress.size()) {
- // Packet has arrived!
- packets.append(inProgress);
- inProgressSize = -1;
- inProgress.clear();
-
- waitingForPacket = false;
- emit readyRead();
- } else
- return;
- }
- }
- }
-
-public:
- QList<qint64> sendingPackets;
- QList<QByteArray> packets;
- QByteArray inProgress;
- qint32 inProgressSize;
- qint32 maxPacketSize;
- bool waitingForPacket;
- QIODevice *dev;
-};
-
-/*!
- Construct a QPacketProtocol instance that works on \a dev with the
- specified \a parent.
- */
-QPacketProtocol::QPacketProtocol(QIODevice *dev, QObject *parent)
- : QObject(parent), d(new QPacketProtocolPrivate(this, dev))
-{
- Q_ASSERT(dev);
-}
-
-/*!
- Destroys the QPacketProtocol instance.
- */
-QPacketProtocol::~QPacketProtocol()
-{
-}
-
-/*!
- Returns the maximum packet size allowed. By default this is
- 2,147,483,647 bytes.
-
- If a packet claiming to be larger than the maximum packet size is received,
- the QPacketProtocol::invalidPacket() signal is emitted.
-
- \sa QPacketProtocol::setMaximumPacketSize()
- */
-qint32 QPacketProtocol::maximumPacketSize() const
-{
- return d->maxPacketSize;
-}
-
-/*!
- Sets the maximum allowable packet size to \a max.
-
- \sa QPacketProtocol::maximumPacketSize()
- */
-qint32 QPacketProtocol::setMaximumPacketSize(qint32 max)
-{
- if (max > (signed)sizeof(qint32))
- d->maxPacketSize = max;
- return d->maxPacketSize;
-}
-
-/*!
- Returns a streamable object that is transmitted on destruction. For example
-
- \code
- protocol.send() << "Hello world" << 123;
- \endcode
-
- will send a packet containing "Hello world" and 123. To construct more
- complex packets, explicitly construct a QPacket instance.
- */
-QPacketAutoSend QPacketProtocol::send()
-{
- return QPacketAutoSend(this);
-}
-
-/*!
- \fn void QPacketProtocol::send(const QPacket & packet)
-
- Transmit the \a packet.
- */
-void QPacketProtocol::send(const QPacket & p)
-{
- if (p.b.isEmpty())
- return; // We don't send empty packets
-
- qint64 sendSize = p.b.size() + sizeof(qint32);
-
- d->sendingPackets.append(sendSize);
- qint32 sendSize32 = sendSize;
- qint64 writeBytes = d->dev->write((char *)&sendSize32, sizeof(qint32));
- Q_ASSERT(writeBytes == sizeof(qint32));
- writeBytes = d->dev->write(p.b);
- Q_ASSERT(writeBytes == p.b.size());
-}
-
-/*!
- Returns the number of received packets yet to be read.
- */
-qint64 QPacketProtocol::packetsAvailable() const
-{
- return d->packets.count();
-}
-
-/*!
- Discard any unread packets.
- */
-void QPacketProtocol::clear()
-{
- d->packets.clear();
-}
-
-/*!
- Return the next unread packet, or an invalid QPacket instance if no packets
- are available. This method does NOT block.
- */
-QPacket QPacketProtocol::read()
-{
- if (0 == d->packets.count())
- return QPacket();
-
- QPacket rv(d->packets.at(0));
- d->packets.removeFirst();
- return rv;
-}
-
-/*
- Returns the difference between msecs and elapsed. If msecs is -1,
- however, -1 is returned.
-*/
-static int qt_timeout_value(int msecs, int elapsed)
-{
- if (msecs == -1)
- return -1;
-
- int timeout = msecs - elapsed;
- return timeout < 0 ? 0 : timeout;
-}
-
-/*!
- This function locks until a new packet is available for reading and the
- \l{QIODevice::}{readyRead()} signal has been emitted. The function
- will timeout after \a msecs milliseconds; the default timeout is
- 30000 milliseconds.
-
- The function returns true if the readyRead() signal is emitted and
- there is new data available for reading; otherwise it returns false
- (if an error occurred or the operation timed out).
- */
-
-bool QPacketProtocol::waitForReadyRead(int msecs)
-{
- if (!d->packets.isEmpty())
- return true;
-
- QElapsedTimer stopWatch;
- stopWatch.start();
-
- d->waitingForPacket = true;
- do {
- if (!d->dev->waitForReadyRead(msecs))
- return false;
- if (!d->waitingForPacket)
- return true;
- msecs = qt_timeout_value(msecs, stopWatch.elapsed());
- } while (true);
-}
-
-/*!
- Return the QIODevice passed to the QPacketProtocol constructor.
-*/
-QIODevice *QPacketProtocol::device()
-{
- return d->dev;
-}
-
-/*!
- \fn void QPacketProtocol::readyRead()
-
- Emitted whenever a new packet is received. Applications may use
- QPacketProtocol::read() to retrieve this packet.
- */
-
-/*!
- \fn void QPacketProtocol::invalidPacket()
-
- A packet larger than the maximum allowable packet size was received. The
- packet will be discarded and, as it indicates corruption in the protocol, no
- further packets will be received.
- */
-
-/*!
- \fn void QPacketProtocol::packetWritten()
-
- Emitted each time a packet is completing written to the device. This signal
- may be used for communications flow control.
- */
-
-/*!
- \class QPacket
- \internal
-
- \brief The QPacket class encapsulates an unfragmentable packet of data to be
- transmitted by QPacketProtocol.
-
- The QPacket class works together with QPacketProtocol to make it simple to
- send arbitrary sized data "packets" across fragmented transports such as TCP
- and UDP.
-
- QPacket provides a QDataStream interface to an unfragmentable packet.
- Applications should construct a QPacket, propagate it with data and then
- transmit it over a QPacketProtocol instance. For example:
- \code
- QPacketProtocol protocol(...);
-
- QPacket myPacket;
- myPacket << "Hello world!" << 123;
- protocol.send(myPacket);
- \endcode
-
- As long as both ends of the connection are using the QPacketProtocol class,
- the data within this packet will be delivered unfragmented at the other end,
- ready for extraction.
-
- \code
- QByteArray greeting;
- int count;
-
- QPacket myPacket = protocol.read();
-
- myPacket >> greeting >> count;
- \endcode
-
- Only packets returned from QPacketProtocol::read() may be read from. QPacket
- instances constructed by directly by applications are for transmission only
- and are considered "write only". Attempting to read data from them will
- result in undefined behavior.
-
- \ingroup io
- \sa QPacketProtocol
- */
-
-/*!
- Constructs an empty write-only packet.
- */
-QPacket::QPacket()
- : QDataStream(), buf(0)
-{
- buf = new QBuffer(&b);
- buf->open(QIODevice::WriteOnly);
- setDevice(buf);
- setVersion(QDataStream::Qt_4_7);
-}
-
-/*!
- Destroys the QPacket instance.
- */
-QPacket::~QPacket()
-{
- if (buf) {
- delete buf;
- buf = 0;
- }
-}
-
-/*!
- Creates a copy of \a other. The initial stream positions are shared, but the
- two packets are otherwise independent.
- */
-QPacket::QPacket(const QPacket & other)
- : QDataStream(), b(other.b), buf(0)
-{
- buf = new QBuffer(&b);
- buf->open(other.buf->openMode());
- setDevice(buf);
-}
-
-/*!
- \internal
- */
-QPacket::QPacket(const QByteArray & ba)
- : QDataStream(), b(ba), buf(0)
-{
- buf = new QBuffer(&b);
- buf->open(QIODevice::ReadOnly);
- setDevice(buf);
-}
-
-/*!
- Returns true if this packet is empty - that is, contains no data.
- */
-bool QPacket::isEmpty() const
-{
- return b.isEmpty();
-}
-
-/*!
- Returns raw packet data.
- */
-QByteArray QPacket::data() const
-{
- return b;
-}
-
-/*!
- Clears data in the packet. This is useful for reusing one writable packet.
- For example
- \code
- QPacketProtocol protocol(...);
-
- QPacket packet;
-
- packet << "Hello world!" << 123;
- protocol.send(packet);
-
- packet.clear();
- packet << "Goodbyte world!" << 789;
- protocol.send(packet);
- \endcode
- */
-void QPacket::clear()
-{
- QBuffer::OpenMode oldMode = buf->openMode();
- buf->close();
- b.clear();
- buf->setBuffer(&b); // reset QBuffer internals with new size of b.
- buf->open(oldMode);
-}
-
-/*!
- \class QPacketAutoSend
- \internal
-
- \internal
- */
-QPacketAutoSend::QPacketAutoSend(QPacketProtocol *_p)
- : QPacket(), p(_p)
-{
-}
-
-QPacketAutoSend::~QPacketAutoSend()
-{
- if (!b.isEmpty())
- p->send(*this);
-}
-
-QT_END_NAMESPACE
-
-#include <qpacketprotocol.moc>
diff --git a/src/declarative/debugger/qpacketprotocol_p.h b/src/declarative/debugger/qpacketprotocol_p.h
deleted file mode 100644
index eda7bfbac9..0000000000
--- a/src/declarative/debugger/qpacketprotocol_p.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPACKETPROTOCOL_H
-#define QPACKETPROTOCOL_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/qobject.h>
-#include <QtCore/qdatastream.h>
-
-#include <private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QIODevice;
-class QBuffer;
-class QPacket;
-class QPacketAutoSend;
-class QPacketProtocolPrivate;
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QPacketProtocol : public QObject
-{
- Q_OBJECT
-public:
- explicit QPacketProtocol(QIODevice *dev, QObject *parent = 0);
- virtual ~QPacketProtocol();
-
- qint32 maximumPacketSize() const;
- qint32 setMaximumPacketSize(qint32);
-
- QPacketAutoSend send();
- void send(const QPacket &);
-
- qint64 packetsAvailable() const;
- QPacket read();
-
- bool waitForReadyRead(int msecs = 3000);
-
- void clear();
-
- QIODevice *device();
-
-Q_SIGNALS:
- void readyRead();
- void invalidPacket();
- void packetWritten();
-
-private:
- QPacketProtocolPrivate *d;
-};
-
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QPacket : public QDataStream
-{
-public:
- QPacket();
- QPacket(const QPacket &);
- virtual ~QPacket();
-
- void clear();
- bool isEmpty() const;
- QByteArray data() const;
-
-protected:
- friend class QPacketProtocol;
- QPacket(const QByteArray &ba);
- QByteArray b;
- QBuffer *buf;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QPacketAutoSend : public QPacket
-{
-public:
- virtual ~QPacketAutoSend();
-
-private:
- friend class QPacketProtocol;
- QPacketAutoSend(QPacketProtocol *);
- QPacketProtocol *p;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/debugger/qv8debugservice.cpp b/src/declarative/debugger/qv8debugservice.cpp
deleted file mode 100644
index 389c465420..0000000000
--- a/src/declarative/debugger/qv8debugservice.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8debugservice_p.h"
-#include "qdeclarativedebugservice_p_p.h"
-#include <private/qjsconverter_impl_p.h>
-#include <private/qv8engine_p.h>
-
-#include <QtCore/QHash>
-#include <QtCore/QFileInfo>
-#include <QtCore/QMutex>
-
-//V8 DEBUG SERVICE PROTOCOL
-// <HEADER><COMMAND><DATA>
-// <HEADER> : "V8DEBUG"
-// <COMMAND> : ["connect", "disconnect", "interrupt",
-// "v8request", "v8message", "breakonsignal",
-// "breakaftercompile"]
-// <DATA> : connect, disconnect, interrupt: empty
-// v8request, v8message: <JSONrequest_string>
-// breakonsignal: <signalname_string><enabled_bool>
-// breakaftercompile: <enabled_bool>
-
-const char *V8_DEBUGGER_KEY_VERSION = "version";
-const char *V8_DEBUGGER_KEY_CONNECT = "connect";
-const char *V8_DEBUGGER_KEY_INTERRUPT = "interrupt";
-const char *V8_DEBUGGER_KEY_DISCONNECT = "disconnect";
-const char *V8_DEBUGGER_KEY_REQUEST = "v8request";
-const char *V8_DEBUGGER_KEY_V8MESSAGE = "v8message";
-const char *V8_DEBUGGER_KEY_BREAK_ON_SIGNAL = "breakonsignal";
-const char *V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE = "breakaftercompile";
-
-QT_BEGIN_NAMESPACE
-
-struct SignalHandlerData
-{
- QString functionName;
- bool enabled;
-};
-
-Q_GLOBAL_STATIC(QV8DebugService, v8ServiceInstance)
-
-// DebugMessageHandler will call back already when the QV8DebugService constructor is
-// running, we therefore need a plain pointer.
-static QV8DebugService *v8ServiceInstancePtr = 0;
-
-void DebugMessageDispatchHandler()
-{
- QMetaObject::invokeMethod(v8ServiceInstancePtr, "processDebugMessages", Qt::QueuedConnection);
-}
-
-void DebugMessageHandler(const v8::Debug::Message& message)
-{
- v8::DebugEvent event = message.GetEvent();
-
- if (event != v8::Break && event != v8::Exception &&
- event != v8::AfterCompile && event != v8::BeforeCompile)
- return;
- v8ServiceInstancePtr->debugMessageHandler(QJSConverter::toString(message.GetJSON()), event);
-}
-
-class QV8DebugServicePrivate : public QDeclarativeDebugServicePrivate
-{
-public:
- QV8DebugServicePrivate()
- : connectReceived(false)
- , breakAfterCompile(false)
- , engine(0)
- {
- }
-
- void initializeDebuggerThread();
-
- static QByteArray packMessage(const QString &type, const QString &message = QString());
-
- bool connectReceived;
- bool breakAfterCompile;
- QMutex initializeMutex;
- QStringList breakOnSignals;
- const QV8Engine *engine;
-};
-
-QV8DebugService::QV8DebugService(QObject *parent)
- : QDeclarativeDebugService(*(new QV8DebugServicePrivate()),
- QLatin1String("V8Debugger"), 2, parent)
-{
- Q_D(QV8DebugService);
- v8ServiceInstancePtr = this;
- // wait for stateChanged() -> initialize()
- d->initializeMutex.lock();
- if (registerService() == Enabled) {
- init();
- // ,block mode, client attached
- while (!d->connectReceived) {
- waitForMessage();
- }
- } else {
- d->initializeMutex.unlock();
- }
-}
-
-QV8DebugService::~QV8DebugService()
-{
-}
-
-QV8DebugService *QV8DebugService::instance()
-{
- return v8ServiceInstance();
-}
-
-void QV8DebugService::initialize(const QV8Engine *engine)
-{
- // just make sure that the service is properly registered
- v8ServiceInstance()->setEngine(engine);
-}
-
-void QV8DebugService::setEngine(const QV8Engine *engine)
-{
- Q_D(QV8DebugService);
-
- d->engine = engine;
-}
-
-void QV8DebugService::debugMessageHandler(const QString &message, const v8::DebugEvent &event)
-{
- Q_D(QV8DebugService);
- sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_V8MESSAGE), message));
- if (event == v8::AfterCompile && d->breakAfterCompile)
- scheduledDebugBreak(true);
-}
-
-void QV8DebugService::signalEmitted(const QString &signal)
-{
- //This function is only called by QDeclarativeBoundSignal
- //only if there is a slot connected to the signal. Hence, there
- //is no need for additional check.
- Q_D(QV8DebugService);
-
- //Parse just the name and remove the class info
- //Normalize to Lower case.
- QString signalName = signal.left(signal.indexOf(QLatin1String("("))).toLower();
-
- foreach (const QString &signal, d->breakOnSignals) {
- if (signal == signalName) {
- scheduledDebugBreak(true);
- break;
- }
- }
-}
-
-// executed in the gui thread
-void QV8DebugService::init()
-{
- Q_D(QV8DebugService);
- v8::Debug::SetMessageHandler2(DebugMessageHandler);
- v8::Debug::SetDebugMessageDispatchHandler(DebugMessageDispatchHandler);
- d->initializeMutex.unlock();
-}
-
-// executed in the gui thread
-void QV8DebugService::scheduledDebugBreak(bool schedule)
-{
- if (schedule)
- v8::Debug::DebugBreak();
- else
- v8::Debug::CancelDebugBreak();
-}
-
-// executed in the debugger thread
-void QV8DebugService::stateChanged(QDeclarativeDebugService::State newState)
-{
- Q_D(QV8DebugService);
- if (newState == Enabled) {
- // execute in GUI thread
- d->initializeMutex.lock();
- QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
- }
-}
-
-// executed in the debugger thread
-void QV8DebugService::messageReceived(const QByteArray &message)
-{
- Q_D(QV8DebugService);
-
- QDataStream ds(message);
- QByteArray header;
- ds >> header;
-
- if (header == "V8DEBUG") {
- QByteArray command;
- QByteArray data;
- ds >> command >> data;
-
- if (command == V8_DEBUGGER_KEY_CONNECT) {
- QMutexLocker locker(&d->initializeMutex);
- d->connectReceived = true;
- sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_CONNECT)));
-
- } else if (command == V8_DEBUGGER_KEY_INTERRUPT) {
- // break has to be executed in gui thread
- QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, true));
- sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_INTERRUPT)));
-
- } else if (command == V8_DEBUGGER_KEY_DISCONNECT) {
- // cancel break has to be executed in gui thread
- QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, false));
- sendDebugMessage(QString::fromUtf8(data));
-
- } else if (command == V8_DEBUGGER_KEY_REQUEST) {
- sendDebugMessage(QString::fromUtf8(data));
-
- } else if (command == V8_DEBUGGER_KEY_BREAK_ON_SIGNAL) {
- QDataStream rs(data);
- QByteArray signal;
- bool enabled;
- rs >> signal >> enabled;
- //Normalize to lower case.
- QString signalName(QString::fromUtf8(signal).toLower());
- if (enabled)
- d->breakOnSignals.append(signalName);
- else
- d->breakOnSignals.removeOne(signalName);
- sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_ON_SIGNAL)));
-
- } else if (command == V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE) {
- QDataStream rs(data);
- rs >> d->breakAfterCompile;
- sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE)));
-
- }
- }
-}
-
-void QV8DebugService::sendDebugMessage(const QString &message)
-{
- v8::Debug::SendCommand(message.utf16(), message.size());
-}
-
-void QV8DebugService::processDebugMessages()
-{
- Q_D(QV8DebugService);
- v8::HandleScope handleScope;
- v8::Context::Scope contextScope(d->engine->context());
- v8::Debug::ProcessDebugMessages();
-}
-
-QByteArray QV8DebugServicePrivate::packMessage(const QString &type, const QString &message)
-{
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- QByteArray cmd("V8DEBUG");
- rs << cmd << type.toUtf8() << message.toUtf8();
- return reply;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qv8debugservice_p.h b/src/declarative/debugger/qv8debugservice_p.h
deleted file mode 100644
index 3f1d1ca177..0000000000
--- a/src/declarative/debugger/qv8debugservice_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8DEBUGSERVICE_P_H
-#define QV8DEBUGSERVICE_P_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 "qdeclarativedebugservice_p.h"
-#include <private/qv8debug_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QV8Engine;
-class QV8DebugServicePrivate;
-
-class QV8DebugService : public QDeclarativeDebugService
-{
- Q_OBJECT
-public:
- QV8DebugService(QObject *parent = 0);
- ~QV8DebugService();
-
- static QV8DebugService *instance();
- static void initialize(const QV8Engine *engine);
-
- void debugMessageHandler(const QString &message, const v8::DebugEvent &event);
-
- void signalEmitted(const QString &signal);
-
-public slots:
- void processDebugMessages();
-
-private slots:
- void scheduledDebugBreak(bool schedule);
- void sendDebugMessage(const QString &message);
- void init();
-
-protected:
- void stateChanged(State newState);
- void messageReceived(const QByteArray &);
-
-private:
- void setEngine(const QV8Engine *engine);
-
-private:
- Q_DISABLE_COPY(QV8DebugService)
- Q_DECLARE_PRIVATE(QV8DebugService)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV8DEBUGSERVICE_P_H
diff --git a/src/declarative/debugger/qv8profilerservice.cpp b/src/declarative/debugger/qv8profilerservice.cpp
deleted file mode 100644
index 7a8a3507cf..0000000000
--- a/src/declarative/debugger/qv8profilerservice.cpp
+++ /dev/null
@@ -1,301 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8profilerservice_p.h"
-#include "qdeclarativedebugservice_p_p.h"
-#include "private/qjsconverter_impl_p.h"
-#include <private/qv8profiler_p.h>
-
-#include <QtCore/QHash>
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QV8ProfilerService, v8ProfilerInstance)
-
-class DebugServiceOutputStream : public v8::OutputStream
-{
- QDeclarativeDebugService &_service;
-public:
- DebugServiceOutputStream(QDeclarativeDebugService &service)
- : v8::OutputStream(),
- _service(service) {}
- void EndOfStream() {}
- WriteResult WriteAsciiChunk(char *rawData, int size)
- {
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << QV8ProfilerService::V8SnapshotChunk << QByteArray(rawData, size);
- _service.sendMessage(data);
- return kContinue;
- }
-};
-
-// convert to a QByteArray that can be sent to the debug client
-QByteArray QV8ProfilerData::toByteArray() const
-{
- QByteArray data;
- //### using QDataStream is relatively expensive
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << messageType << filename << functionname << lineNumber << totalTime << selfTime << treeLevel;
-
- return data;
-}
-
-class QV8ProfilerServicePrivate : public QDeclarativeDebugServicePrivate
-{
- Q_DECLARE_PUBLIC(QV8ProfilerService)
-
-public:
- QV8ProfilerServicePrivate()
- :initialized(false)
- {
- }
-
- void takeSnapshot(v8::HeapSnapshot::Type);
-
- void printProfileTree(const v8::CpuProfileNode *node, int level = 0);
- void sendMessages();
-
- QList<QV8ProfilerData> m_data;
-
- bool initialized;
- QList<QString> m_ongoing;
-};
-
-QV8ProfilerService::QV8ProfilerService(QObject *parent)
- : QDeclarativeDebugService(*(new QV8ProfilerServicePrivate()), QLatin1String("V8Profiler"), 1, parent)
-{
- Q_D(QV8ProfilerService);
-
- if (registerService() == Enabled) {
- // ,block mode, client attached
- while (!d->initialized)
- waitForMessage();
- }
-}
-
-QV8ProfilerService::~QV8ProfilerService()
-{
-}
-
-QV8ProfilerService *QV8ProfilerService::instance()
-{
- return v8ProfilerInstance();
-}
-
-void QV8ProfilerService::initialize()
-{
- // just make sure that the service is properly registered
- v8ProfilerInstance();
-}
-
-void QV8ProfilerService::stateAboutToBeChanged(QDeclarativeDebugService::State newState)
-{
- Q_D(QV8ProfilerService);
-
- if (state() == newState)
- return;
-
- if (state() == Enabled) {
- foreach (const QString &title, d->m_ongoing)
- QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, title));
- sendProfilingData();
- }
-}
-
-void QV8ProfilerService::messageReceived(const QByteArray &message)
-{
- Q_D(QV8ProfilerService);
-
- QDataStream ds(message);
- QByteArray command;
- QByteArray option;
- QByteArray title;
- ds >> command >> option;
-
- if (command == "V8PROFILER") {
- ds >> title;
- QString titleStr = QString::fromUtf8(title);
- if (option == "start") {
- QMetaObject::invokeMethod(this, "startProfiling", Qt::QueuedConnection, Q_ARG(QString, titleStr));
- } else if (option == "stop" && d->initialized) {
- QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, titleStr));
- QMetaObject::invokeMethod(this, "sendProfilingData", Qt::QueuedConnection);
- }
- d->initialized = true;
- }
-
- if (command == "V8SNAPSHOT") {
- if (option == "full")
- QMetaObject::invokeMethod(this, "takeSnapshot", Qt::QueuedConnection);
- else if (option == "delete") {
- QMetaObject::invokeMethod(this, "deleteSnapshots", Qt::QueuedConnection);
- }
- }
-
- QDeclarativeDebugService::messageReceived(message);
-}
-
-void QV8ProfilerService::startProfiling(const QString &title)
-{
- Q_D(QV8ProfilerService);
- // Start Profiling
-
- if (d->m_ongoing.contains(title))
- return;
-
- v8::HandleScope handle_scope;
- v8::Handle<v8::String> v8title = v8::String::New(reinterpret_cast<const uint16_t*>(title.data()), title.size());
- v8::CpuProfiler::StartProfiling(v8title);
-
- d->m_ongoing.append(title);
-
- // indicate profiling started
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (int)QV8ProfilerService::V8Started;
-
- sendMessage(data);
-}
-
-void QV8ProfilerService::stopProfiling(const QString &title)
-{
- Q_D(QV8ProfilerService);
- // Stop profiling
-
- if (!d->m_ongoing.contains(title))
- return;
- d->m_ongoing.removeOne(title);
-
- v8::HandleScope handle_scope;
- v8::Handle<v8::String> v8title = v8::String::New(reinterpret_cast<const uint16_t*>(title.data()), title.size());
- const v8::CpuProfile *cpuProfile = v8::CpuProfiler::StopProfiling(v8title);
- if (cpuProfile) {
- // can happen at start
- const v8::CpuProfileNode *rootNode = cpuProfile->GetTopDownRoot();
- d->printProfileTree(rootNode);
- } else {
- // indicate completion, even without data
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (int)QV8ProfilerService::V8Complete;
-
- sendMessage(data);
- }
-}
-
-void QV8ProfilerService::takeSnapshot()
-{
- Q_D(QV8ProfilerService);
- d->takeSnapshot(v8::HeapSnapshot::kFull);
-}
-
-void QV8ProfilerService::deleteSnapshots()
-{
- v8::HeapProfiler::DeleteAllSnapshots();
-}
-
-void QV8ProfilerService::sendProfilingData()
-{
- Q_D(QV8ProfilerService);
- // Send messages to client
- d->sendMessages();
-}
-
-void QV8ProfilerServicePrivate::printProfileTree(const v8::CpuProfileNode *node, int level)
-{
- for (int index = 0 ; index < node->GetChildrenCount() ; index++) {
- const v8::CpuProfileNode* childNode = node->GetChild(index);
- QString scriptResourceName = QJSConverter::toString(childNode->GetScriptResourceName());
- if (scriptResourceName.length() > 0) {
-
- QV8ProfilerData rd = {(int)QV8ProfilerService::V8Entry, scriptResourceName,
- QJSConverter::toString(childNode->GetFunctionName()),
- childNode->GetLineNumber(), childNode->GetTotalTime(), childNode->GetSelfTime(), level};
- m_data.append(rd);
-
- // different nodes might have common children: fix at client side
- if (childNode->GetChildrenCount() > 0) {
- printProfileTree(childNode, level+1);
- }
- }
- }
-}
-
-void QV8ProfilerServicePrivate::takeSnapshot(v8::HeapSnapshot::Type snapshotType)
-{
- Q_Q(QV8ProfilerService);
-
- v8::HandleScope scope;
- v8::Local<v8::String> title = v8::String::New("");
-
- DebugServiceOutputStream outputStream(*q);
- const v8::HeapSnapshot *snapshot = v8::HeapProfiler::TakeSnapshot(title, snapshotType);
- snapshot->Serialize(&outputStream, v8::HeapSnapshot::kJSON);
-
- //indicate completion
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (int)QV8ProfilerService::V8SnapshotComplete;
-
- q->sendMessage(data);
-}
-
-void QV8ProfilerServicePrivate::sendMessages()
-{
- Q_Q(QV8ProfilerService);
-
- QList<QByteArray> messages;
- for (int i = 0; i < m_data.count(); ++i)
- messages << m_data.at(i).toByteArray();
- q->sendMessages(messages);
- m_data.clear();
-
- //indicate completion
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (int)QV8ProfilerService::V8Complete;
-
- q->sendMessage(data);
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qv8profilerservice_p.h b/src/declarative/debugger/qv8profilerservice_p.h
deleted file mode 100644
index 3762845fd3..0000000000
--- a/src/declarative/debugger/qv8profilerservice_p.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8PROFILERSERVICE_P_H
-#define QV8PROFILERSERVICE_P_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 <private/qdeclarativedebugservice_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-struct Q_AUTOTEST_EXPORT QV8ProfilerData
-{
- int messageType;
- QString filename;
- QString functionname;
- int lineNumber;
- double totalTime;
- double selfTime;
- int treeLevel;
-
- QByteArray toByteArray() const;
-};
-
-class QDeclarativeEngine;
-class QV8ProfilerServicePrivate;
-
-class Q_AUTOTEST_EXPORT QV8ProfilerService : public QDeclarativeDebugService
-{
- Q_OBJECT
-public:
- enum MessageType {
- V8Entry,
- V8Complete,
- V8SnapshotChunk,
- V8SnapshotComplete,
- V8Started,
-
- V8MaximumMessage
- };
-
- QV8ProfilerService(QObject *parent = 0);
- ~QV8ProfilerService();
-
- static QV8ProfilerService *instance();
- static void initialize();
-
-public slots:
- void startProfiling(const QString &title);
- void stopProfiling(const QString &title);
- void takeSnapshot();
- void deleteSnapshots();
-
- void sendProfilingData();
-
-protected:
- void stateAboutToBeChanged(State state);
- void messageReceived(const QByteArray &);
-
-private:
- Q_DISABLE_COPY(QV8ProfilerService)
- Q_DECLARE_PRIVATE(QV8ProfilerService)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV8PROFILERSERVICE_P_H
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
deleted file mode 100644
index 1da58ce5d9..0000000000
--- a/src/declarative/declarative.pro
+++ /dev/null
@@ -1,34 +0,0 @@
-load(qt_module)
-
-TARGET = QtDeclarative
-QPRO_PWD = $$PWD
-
-CONFIG += module
-MODULE_PRI += ../../modules/qt_declarative.pri
-
-QT = core-private gui gui-private network v8-private
-
-DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES
-win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
-win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS
-solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
-
-unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
-
-exists("qdeclarative_enable_gcov") {
- QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors
- LIBS += -lgcov
-}
-
-load(qt_module_config)
-
-HEADERS += qtdeclarativeversion.h
-
-#INCLUDEPATH -= $$QMAKE_INCDIR_QT/$$TARGET
-#DESTDIR=.
-
-#modules
-include(util/util.pri)
-include(qml/qml.pri)
-include(debugger/debugger.pri)
-include(animations/animations.pri) \ No newline at end of file
diff --git a/src/declarative/qml/ftw/ftw.pri b/src/declarative/qml/ftw/ftw.pri
deleted file mode 100644
index 26343422c5..0000000000
--- a/src/declarative/qml/ftw/ftw.pri
+++ /dev/null
@@ -1,29 +0,0 @@
-HEADERS += \
- $$PWD/qbitfield_p.h \
- $$PWD/qintrusivelist_p.h \
- $$PWD/qpodvector_p.h \
- $$PWD/qhashedstring_p.h \
- $$PWD/qdeclarativerefcount_p.h \
- $$PWD/qdeclarativepool_p.h \
- $$PWD/qfieldlist_p.h \
- $$PWD/qfastmetabuilder_p.h \
- $$PWD/qhashfield_p.h \
- $$PWD/qdeclarativethread_p.h \
- $$PWD/qfinitestack_p.h \
- $$PWD/qrecursionwatcher_p.h \
- $$PWD/qdeletewatcher_p.h \
- $$PWD/qrecyclepool_p.h \
- $$PWD/qflagpointer_p.h \
- $$PWD/qdeclarativetrace_p.h \
- $$PWD/qpointervaluepair_p.h \
- $$PWD/qlazilyallocated_p.h \
-
-SOURCES += \
- $$PWD/qintrusivelist.cpp \
- $$PWD/qhashedstring.cpp \
- $$PWD/qdeclarativepool.cpp \
- $$PWD/qfastmetabuilder.cpp \
- $$PWD/qdeclarativethread.cpp \
- $$PWD/qdeclarativetrace.cpp \
-
-contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
diff --git a/src/declarative/qml/ftw/qbitfield_p.h b/src/declarative/qml/ftw/qbitfield_p.h
deleted file mode 100644
index addd21c96d..0000000000
--- a/src/declarative/qml/ftw/qbitfield_p.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBITFIELD_P_H
-#define QBITFIELD_P_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>
-
-QT_BEGIN_NAMESPACE
-
-class QBitField
-{
-public:
- inline QBitField();
- inline QBitField(const quint32 *, int bits);
- inline QBitField(const QBitField &);
- inline ~QBitField();
-
- inline QBitField &operator=(const QBitField &);
-
- inline quint32 size() const;
- inline QBitField united(const QBitField &);
- inline bool testBit(int) const;
-
-private:
- quint32 bits:31;
- quint32 *ownData;
- const quint32 *data;
-};
-
-QBitField::QBitField()
-: bits(0), ownData(0), data(0)
-{
-}
-
-QBitField::QBitField(const quint32 *bitData, int bitCount)
-: bits((quint32)bitCount), ownData(0), data(bitData)
-{
-}
-
-QBitField::QBitField(const QBitField &other)
-: bits(other.bits), ownData(other.ownData), data(other.data)
-{
- if (ownData)
- ++(*ownData);
-}
-
-QBitField::~QBitField()
-{
- if (ownData)
- if(0 == --(*ownData)) delete [] ownData;
-}
-
-QBitField &QBitField::operator=(const QBitField &other)
-{
- if (other.data == data)
- return *this;
-
- if (ownData)
- if(0 == --(*ownData)) delete [] ownData;
-
- bits = other.bits;
- ownData = other.ownData;
- data = other.data;
-
- if (ownData)
- ++(*ownData);
-
- return *this;
-}
-
-inline quint32 QBitField::size() const
-{
- return bits;
-}
-
-QBitField QBitField::united(const QBitField &o)
-{
- if (o.bits == 0) {
- return *this;
- } else if (bits == 0) {
- return o;
- } else {
- int max = (bits > o.bits)?bits:o.bits;
- int length = (max + 31) / 32;
- QBitField rv;
- rv.bits = max;
- rv.ownData = new quint32[length + 1];
- *(rv.ownData) = 1;
- rv.data = rv.ownData + 1;
- if (bits > o.bits) {
- ::memcpy((quint32 *)rv.data, data, length * sizeof(quint32));
- for (quint32 ii = 0; ii < (o.bits + quint32(31)) / 32; ++ii)
- ((quint32 *)rv.data)[ii] |= o.data[ii];
- } else {
- ::memcpy((quint32 *)rv.data, o.data, length * sizeof(quint32));
- for (quint32 ii = 0; ii < (bits + quint32(31)) / 32; ++ii)
- ((quint32 *)rv.data)[ii] |= data[ii];
- }
- return rv;
- }
-}
-
-bool QBitField::testBit(int b) const
-{
- Q_ASSERT(b >= 0);
- if ((quint32)b < bits) {
- return data[b / 32] & (1 << (b % 32));
- } else {
- return false;
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // QBITFIELD_P_H
diff --git a/src/declarative/qml/ftw/qdeclarativepool.cpp b/src/declarative/qml/ftw/qdeclarativepool.cpp
deleted file mode 100644
index d816e5bb95..0000000000
--- a/src/declarative/qml/ftw/qdeclarativepool.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepool_p.h"
-
-// #define POOL_DEBUG
-
-QT_BEGIN_NAMESPACE
-
-void QDeclarativePool::newpage()
-{
-#ifdef POOL_DEBUG
- qWarning("QDeclarativePool: Allocating page");
-#endif
-
- Page *page = (Page *)malloc(sizeof(Page));
- page->header.next = _page;
- page->header.free = page->memory;
- _page = page;
-}
-
-void QDeclarativePool::clear()
-{
-#ifdef POOL_DEBUG
- int count = 0;
-#endif
-
- Class *c = _classList;
- while (c) {
- Class *n = c->_next;
- c->_destroy(c);
-#ifdef POOL_DEBUG
- ++count;
-#endif
- c = n;
- }
-
-#ifdef POOL_DEBUG
- qWarning("QDeclarativePool: Destroyed %d objects", count);
-#endif
-
- Page *p = _page;
- while (p) {
- Page *n = p->header.next;
- free(p);
- p = n;
- }
-
- _classList = 0;
- _page = 0;
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/ftw/qdeclarativepool_p.h b/src/declarative/qml/ftw/qdeclarativepool_p.h
deleted file mode 100644
index d04c0e9eef..0000000000
--- a/src/declarative/qml/ftw/qdeclarativepool_p.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPOOL_P_H
-#define QDECLARATIVEPOOL_P_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/qstring.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_NAMESPACE
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_EXPORT QDeclarativePool
-{
-public:
- // The class has a destructor that needs to be called
- class Class {
- public:
- inline QDeclarativePool *pool() const;
-
- private:
- void *operator new(size_t);
- void *operator new(size_t, void *m) { return m; }
- friend class QDeclarativePool;
-
- QDeclarativePool *_pool;
- Class *_next;
- void (*_destroy)(Class *);
- };
-
- // The class is plain old data and no destructor needs to
- // be called
- class POD {
- public:
- inline QDeclarativePool *pool() const;
-
- private:
- void *operator new(size_t);
- void *operator new(size_t, void *m) { return m; }
- friend class QDeclarativePool;
-
- QDeclarativePool *_pool;
- };
-
- inline QDeclarativePool();
- inline ~QDeclarativePool();
-
- void clear();
-
- template<typename T>
- inline T *New();
- template<typename T>
- inline T *NewRaw();
- template<typename T>
- inline T *NewRawArray(int length);
-
- inline QString *NewString(const QString &);
- inline QByteArray *NewByteArray(const QByteArray &);
- inline QUrl *NewUrl(const QUrl &);
-
- template<typename T>
- struct List {
- List() : m_length(0), m_data(0) {}
- List(const List &o) : m_length(o.m_length), m_data(o.m_data) {}
- List &operator=(const List &o) {
- m_length = o.m_length;
- m_data = o.m_data;
- return *this;
- }
-
- int count() const {
- return m_length;
- }
- int length() const {
- return m_length;
- }
- const T &at(int index) const {
- Q_ASSERT(index < m_length);
- return m_data[index];
- };
- T &operator[](int index) {
- Q_ASSERT(index < m_length);
- return m_data[index];
- };
- private:
- friend class QDeclarativePool;
- List(T *d, int l) : m_length(l), m_data(d) {}
- int m_length;
- T *m_data;
- };
-
- template<typename T>
- inline List<T> NewRawList(int length);
-
-private:
- struct StringClass : public QString, public Class {
- };
- struct ByteArrayClass : public QByteArray, public Class {
- };
- struct UrlClass : public QUrl, public Class {
- };
-
- inline void *allocate(int size);
- void newpage();
-
- template<typename T>
- inline void initialize(POD *);
- template<typename T>
- inline void initialize(Class *);
- template<typename T>
- static void destroy(Class *c);
-
- struct Page {
- struct Header {
- Page *next;
- char *free;
- } header;
-
- static const int pageSize = 4 * 4096 - sizeof(Header);
-
- char memory[pageSize];
- };
-
- Page *_page;
- Class *_classList;
-};
-
-QDeclarativePool::QDeclarativePool()
-: _page(0), _classList(0)
-{
-}
-
-QDeclarativePool::~QDeclarativePool()
-{
- clear();
-}
-
-template<typename T>
-T *QDeclarativePool::New()
-{
- T *rv = new (allocate(sizeof(T))) T;
- initialize<T>(rv);
- rv->_pool = this;
- return rv;
-}
-
-template<typename T>
-T *QDeclarativePool::NewRaw()
-{
- return (T*)allocate(sizeof(T));
-}
-
-template<typename T>
-T *QDeclarativePool::NewRawArray(int length)
-{
- return (T*)allocate(length * sizeof(T));
-}
-
-template<typename T>
-QDeclarativePool::List<T> QDeclarativePool::NewRawList(int length)
-{
- return List<T>(NewRawArray<T>(length), length);
-}
-
-QString *QDeclarativePool::NewString(const QString &s)
-{
- QString *rv = New<StringClass>();
- *rv = s;
- return rv;
-}
-
-QByteArray *QDeclarativePool::NewByteArray(const QByteArray &s)
-{
- QByteArray *rv = New<ByteArrayClass>();
- *rv = s;
- return rv;
-}
-
-QUrl *QDeclarativePool::NewUrl(const QUrl &s)
-{
- QUrl *rv = New<UrlClass>();
- *rv = s;
- return rv;
-}
-
-void *QDeclarativePool::allocate(int size)
-{
- if (!_page || (_page->header.free + size) > (_page->memory + Page::pageSize))
- newpage();
-
- void *rv = _page->header.free;
- _page->header.free += size + ((8 - size) & 7); // ensure 8 byte alignment;
- return rv;
-}
-
-template<typename T>
-void QDeclarativePool::initialize(QDeclarativePool::POD *)
-{
-}
-
-template<typename T>
-void QDeclarativePool::initialize(QDeclarativePool::Class *c)
-{
- c->_next = _classList;
- c->_destroy = &destroy<T>;
- _classList = c;
-}
-
-template<typename T>
-void QDeclarativePool::destroy(Class *c)
-{
- static_cast<T *>(c)->~T();
-}
-
-QDeclarativePool *QDeclarativePool::Class::pool() const
-{
- return _pool;
-}
-
-QDeclarativePool *QDeclarativePool::POD::pool() const
-{
- return _pool;
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEPOOL_P_H
-
diff --git a/src/declarative/qml/ftw/qdeclarativerefcount_p.h b/src/declarative/qml/ftw/qdeclarativerefcount_p.h
deleted file mode 100644
index 05aede4534..0000000000
--- a/src/declarative/qml/ftw/qdeclarativerefcount_p.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEREFCOUNT_P_H
-#define QDECLARATIVEREFCOUNT_P_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/qatomic.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeRefCount
-{
-public:
- inline QDeclarativeRefCount();
- inline virtual ~QDeclarativeRefCount();
- inline void addref();
- inline void release();
-
-protected:
- inline virtual void destroy();
-
-private:
- QAtomicInt refCount;
-};
-
-template<class T>
-class QDeclarativeRefPointer
-{
-public:
- inline QDeclarativeRefPointer();
- inline QDeclarativeRefPointer(T *);
- inline QDeclarativeRefPointer(const QDeclarativeRefPointer<T> &);
- inline ~QDeclarativeRefPointer();
-
- inline QDeclarativeRefPointer<T> &operator=(const QDeclarativeRefPointer<T> &o);
- inline QDeclarativeRefPointer<T> &operator=(T *);
-
- inline bool isNull() const { return !o; }
-
- inline T* operator->() const { return o; }
- inline T& operator*() const { return *o; }
- inline operator T*() const { return o; }
- inline T* data() const { return o; }
-
- inline QDeclarativeRefPointer<T> &take(T *);
-
-private:
- T *o;
-};
-
-QDeclarativeRefCount::QDeclarativeRefCount()
-: refCount(1)
-{
-}
-
-QDeclarativeRefCount::~QDeclarativeRefCount()
-{
- Q_ASSERT(refCount.load() == 0);
-}
-
-void QDeclarativeRefCount::addref()
-{
- Q_ASSERT(refCount.load() > 0);
- refCount.ref();
-}
-
-void QDeclarativeRefCount::release()
-{
- Q_ASSERT(refCount.load() > 0);
- if (!refCount.deref())
- destroy();
-}
-
-void QDeclarativeRefCount::destroy()
-{
- delete this;
-}
-
-template<class T>
-QDeclarativeRefPointer<T>::QDeclarativeRefPointer()
-: o(0)
-{
-}
-
-template<class T>
-QDeclarativeRefPointer<T>::QDeclarativeRefPointer(T *o)
-: o(o)
-{
- if (o) o->addref();
-}
-
-template<class T>
-QDeclarativeRefPointer<T>::QDeclarativeRefPointer(const QDeclarativeRefPointer<T> &other)
-: o(other.o)
-{
- if (o) o->addref();
-}
-
-template<class T>
-QDeclarativeRefPointer<T>::~QDeclarativeRefPointer()
-{
- if (o) o->release();
-}
-
-template<class T>
-QDeclarativeRefPointer<T> &QDeclarativeRefPointer<T>::operator=(const QDeclarativeRefPointer<T> &other)
-{
- if (other.o) other.o->addref();
- if (o) o->release();
- o = other.o;
- return *this;
-}
-
-template<class T>
-QDeclarativeRefPointer<T> &QDeclarativeRefPointer<T>::operator=(T *other)
-{
- if (other) other->addref();
- if (o) o->release();
- o = other;
- return *this;
-}
-
-/*!
-Takes ownership of \a other. take() does *not* add a reference, as it assumes ownership
-of the callers reference of other.
-*/
-template<class T>
-QDeclarativeRefPointer<T> &QDeclarativeRefPointer<T>::take(T *other)
-{
- if (o) o->release();
- o = other;
- return *this;
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEREFCOUNT_P_H
diff --git a/src/declarative/qml/ftw/qdeclarativethread.cpp b/src/declarative/qml/ftw/qdeclarativethread.cpp
deleted file mode 100644
index be51a09f8d..0000000000
--- a/src/declarative/qml/ftw/qdeclarativethread.cpp
+++ /dev/null
@@ -1,359 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativethread_p.h"
-
-#include <private/qfieldlist_p.h>
-
-#include <QtCore/qmutex.h>
-#include <QtCore/qthread.h>
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qwaitcondition.h>
-#include <QtCore/qcoreapplication.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeThreadPrivate : public QThread
-{
-public:
- QDeclarativeThreadPrivate(QDeclarativeThread *);
- QDeclarativeThread *q;
-
- virtual void run();
-
- inline void lock() { _mutex.lock(); }
- inline void unlock() { _mutex.unlock(); }
- inline void wait() { _wait.wait(&_mutex); }
- inline void wakeOne() { _wait.wakeOne(); }
- inline void wakeAll() { _wait.wakeAll(); }
-
- quint32 m_threadProcessing:1; // Set when the thread is processing messages
- quint32 m_mainProcessing:1; // Set when the main thread is processing messages
- quint32 m_shutdown:1; // Set by main thread to request a shutdown
- quint32 m_mainThreadWaiting:1; // Set by main thread if it is waiting for the message queue to empty
-
- typedef QFieldList<QDeclarativeThread::Message, &QDeclarativeThread::Message::next> MessageList;
- MessageList threadList;
- MessageList mainList;
-
- QDeclarativeThread::Message *mainSync;
-
- void triggerMainEvent();
- void triggerThreadEvent();
-
- void mainEvent();
- void threadEvent();
-
-protected:
- virtual bool event(QEvent *);
-
-private:
- struct MainObject : public QObject {
- MainObject(QDeclarativeThreadPrivate *p);
- virtual bool event(QEvent *e);
- QDeclarativeThreadPrivate *p;
- };
- MainObject m_mainObject;
-
- QMutex _mutex;
- QWaitCondition _wait;
-};
-
-QDeclarativeThreadPrivate::MainObject::MainObject(QDeclarativeThreadPrivate *p)
-: p(p)
-{
-}
-
-// Trigger mainEvent in main thread. Must be called from thread.
-void QDeclarativeThreadPrivate::triggerMainEvent()
-{
- Q_ASSERT(q->isThisThread());
- QCoreApplication::postEvent(&m_mainObject, new QEvent(QEvent::User));
-}
-
-// Trigger even in thread. Must be called from main thread.
-void QDeclarativeThreadPrivate::triggerThreadEvent()
-{
- Q_ASSERT(!q->isThisThread());
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
-}
-
-bool QDeclarativeThreadPrivate::MainObject::event(QEvent *e)
-{
- if (e->type() == QEvent::User)
- p->mainEvent();
- return QObject::event(e);
-}
-
-QDeclarativeThreadPrivate::QDeclarativeThreadPrivate(QDeclarativeThread *q)
-: q(q), m_threadProcessing(false), m_mainProcessing(false), m_shutdown(false),
- m_mainThreadWaiting(false), mainSync(0), m_mainObject(this)
-{
-}
-
-bool QDeclarativeThreadPrivate::event(QEvent *e)
-{
- if (e->type() == QEvent::User)
- threadEvent();
- return QThread::event(e);
-}
-
-void QDeclarativeThreadPrivate::run()
-{
- lock();
-
- wakeOne();
-
- unlock();
-
- q->startupThread();
- exec();
-}
-
-void QDeclarativeThreadPrivate::mainEvent()
-{
- lock();
-
- m_mainProcessing = true;
-
- while (!mainList.isEmpty() || mainSync) {
- bool isSync = mainSync != 0;
- QDeclarativeThread::Message *message = isSync?mainSync:mainList.takeFirst();
- unlock();
-
- message->call(q);
- delete message;
-
- lock();
-
- if (isSync) {
- mainSync = 0;
- wakeOne();
- }
- }
-
- m_mainProcessing = false;
-
- unlock();
-}
-
-void QDeclarativeThreadPrivate::threadEvent()
-{
- lock();
-
- if (m_shutdown) {
- quit();
- wakeOne();
- unlock();
- q->shutdownThread();
- } else {
- m_threadProcessing = true;
-
- while (!threadList.isEmpty()) {
- QDeclarativeThread::Message *message = threadList.first();
-
- unlock();
-
- message->call(q);
-
- lock();
-
- delete threadList.takeFirst();
- }
-
- wakeOne();
-
- m_threadProcessing = false;
-
- unlock();
- }
-}
-
-QDeclarativeThread::QDeclarativeThread()
-: d(new QDeclarativeThreadPrivate(this))
-{
- d->lock();
- d->start();
- d->wait();
- d->unlock();
- d->moveToThread(d);
-
-}
-
-QDeclarativeThread::~QDeclarativeThread()
-{
- delete d;
-}
-
-void QDeclarativeThread::shutdown()
-{
- d->lock();
- Q_ASSERT(!d->m_shutdown);
- d->m_shutdown = true;
- if (d->threadList.isEmpty() && d->m_threadProcessing == false)
- d->triggerThreadEvent();
- d->wait();
- d->unlock();
- d->QThread::wait();
-}
-
-void QDeclarativeThread::lock()
-{
- d->lock();
-}
-
-void QDeclarativeThread::unlock()
-{
- d->unlock();
-}
-
-void QDeclarativeThread::wakeOne()
-{
- d->wakeOne();
-}
-
-void QDeclarativeThread::wakeAll()
-{
- d->wakeAll();
-}
-
-void QDeclarativeThread::wait()
-{
- d->wait();
-}
-
-bool QDeclarativeThread::isThisThread() const
-{
- return QThread::currentThread() == d;
-}
-
-QThread *QDeclarativeThread::thread() const
-{
- return const_cast<QThread *>(static_cast<const QThread *>(d));
-}
-
-// Called when the thread starts. Do startup stuff in here.
-void QDeclarativeThread::startupThread()
-{
-}
-
-// Called when the thread shuts down. Do cleanup in here.
-void QDeclarativeThread::shutdownThread()
-{
-}
-
-void QDeclarativeThread::internalCallMethodInThread(Message *message)
-{
- Q_ASSERT(!isThisThread());
- d->lock();
- Q_ASSERT(d->m_mainThreadWaiting == false);
-
- bool wasEmpty = d->threadList.isEmpty();
- d->threadList.append(message);
- if (wasEmpty && d->m_threadProcessing == false)
- d->triggerThreadEvent();
-
- d->m_mainThreadWaiting = true;
-
- do {
- if (d->mainSync) {
- QDeclarativeThread::Message *message = d->mainSync;
- unlock();
- message->call(this);
- delete message;
- lock();
- d->mainSync = 0;
- wakeOne();
- } else {
- d->wait();
- }
- } while (d->mainSync || !d->threadList.isEmpty());
-
- d->m_mainThreadWaiting = false;
- d->unlock();
-}
-
-void QDeclarativeThread::internalCallMethodInMain(Message *message)
-{
- Q_ASSERT(isThisThread());
-
- d->lock();
-
- Q_ASSERT(d->mainSync == 0);
- d->mainSync = message;
-
- if (d->m_mainThreadWaiting) {
- d->wakeOne();
- } else if (d->m_mainProcessing) {
- // Do nothing - it is already looping
- } else {
- d->triggerMainEvent();
- }
-
- while (d->mainSync && !d->m_shutdown)
- d->wait();
-
- d->unlock();
-}
-
-void QDeclarativeThread::internalPostMethodToThread(Message *message)
-{
- Q_ASSERT(!isThisThread());
- d->lock();
- bool wasEmpty = d->threadList.isEmpty();
- d->threadList.append(message);
- if (wasEmpty && d->m_threadProcessing == false)
- d->triggerThreadEvent();
- d->unlock();
-}
-
-void QDeclarativeThread::internalPostMethodToMain(Message *message)
-{
- Q_ASSERT(isThisThread());
- d->lock();
- bool wasEmpty = d->mainList.isEmpty();
- d->mainList.append(message);
- if (wasEmpty && d->m_mainProcessing == false)
- d->triggerMainEvent();
- d->unlock();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/ftw/qdeclarativethread_p.h b/src/declarative/qml/ftw/qdeclarativethread_p.h
deleted file mode 100644
index ce9eb1d88f..0000000000
--- a/src/declarative/qml/ftw/qdeclarativethread_p.h
+++ /dev/null
@@ -1,318 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETHREAD_P_H
-#define QDECLARATIVETHREAD_P_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 <private/qintrusivelist_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QThread;
-
-class QDeclarativeThreadPrivate;
-class QDeclarativeThread
-{
-public:
- QDeclarativeThread();
- virtual ~QDeclarativeThread();
- void shutdown();
-
- void lock();
- void unlock();
- void wakeOne();
- void wakeAll();
- void wait();
-
- QThread *thread() const;
- bool isThisThread() const;
-
- // Synchronously invoke a method in the thread
- template<class O>
- inline void callMethodInThread(void (O::*Member)());
- template<typename T, class V, class O>
- inline void callMethodInThread(void (O::*Member)(V), const T &);
- template<typename T, typename T2, class V, class V2, class O>
- inline void callMethodInThread(void (O::*Member)(V, V2), const T &, const T2 &);
-
- // Synchronously invoke a method in the main thread. If the main thread is
- // blocked in a callMethodInThread() call, the call is made from within that
- // call.
- template<class O>
- inline void callMethodInMain(void (O::*Member)());
- template<typename T, class V, class O>
- inline void callMethodInMain(void (O::*Member)(V), const T &);
- template<typename T, typename T2, class V, class V2, class O>
- inline void callMethodInMain(void (O::*Member)(V, V2), const T &, const T2 &);
-
- // Asynchronously invoke a method in the thread.
- template<class O>
- inline void postMethodToThread(void (O::*Member)());
- template<typename T, class V, class O>
- inline void postMethodToThread(void (O::*Member)(V), const T &);
- template<typename T, typename T2, class V, class V2, class O>
- inline void postMethodToThread(void (O::*Member)(V, V2), const T &, const T2 &);
-
- // Asynchronously invoke a method in the main thread.
- template<class O>
- inline void postMethodToMain(void (O::*Member)());
- template<typename T, class V, class O>
- inline void postMethodToMain(void (O::*Member)(V), const T &);
- template<typename T, typename T2, class V, class V2, class O>
- inline void postMethodToMain(void (O::*Member)(V, V2), const T &, const T2 &);
-
-protected:
- virtual void startupThread();
- virtual void shutdownThread();
-
-private:
- friend class QDeclarativeThreadPrivate;
-
- struct Message {
- Message() : next(0) {}
- virtual ~Message() {}
- Message *next;
- virtual void call(QDeclarativeThread *) = 0;
- };
- void internalCallMethodInThread(Message *);
- void internalCallMethodInMain(Message *);
- void internalPostMethodToThread(Message *);
- void internalPostMethodToMain(Message *);
- QDeclarativeThreadPrivate *d;
-};
-
-template<class O>
-void QDeclarativeThread::callMethodInThread(void (O::*Member)())
-{
- struct I : public Message {
- void (O::*Member)();
- I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)();
- }
- };
- internalCallMethodInThread(new I(Member));
-}
-
-template<typename T, class V, class O>
-void QDeclarativeThread::callMethodInThread(void (O::*Member)(V), const T &arg)
-{
- struct I : public Message {
- void (O::*Member)(V);
- T arg;
- I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)(arg);
- }
- };
- internalCallMethodInThread(new I(Member, arg));
-}
-
-template<typename T, typename T2, class V, class V2, class O>
-void QDeclarativeThread::callMethodInThread(void (O::*Member)(V, V2), const T &arg, const T2 &arg2)
-{
- struct I : public Message {
- void (O::*Member)(V, V2);
- T arg;
- T2 arg2;
- I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)(arg, arg2);
- }
- };
- internalCallMethodInThread(new I(Member, arg, arg2));
-}
-
-template<class O>
-void QDeclarativeThread::callMethodInMain(void (O::*Member)())
-{
- struct I : public Message {
- void (O::*Member)();
- I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)();
- }
- };
- internalCallMethodInMain(new I(Member));
-}
-
-template<typename T, class V, class O>
-void QDeclarativeThread::callMethodInMain(void (O::*Member)(V), const T &arg)
-{
- struct I : public Message {
- void (O::*Member)(V);
- T arg;
- I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)(arg);
- }
- };
- internalCallMethodInMain(new I(Member, arg));
-}
-
-template<typename T, typename T2, class V, class V2, class O>
-void QDeclarativeThread::callMethodInMain(void (O::*Member)(V, V2), const T &arg, const T2 &arg2)
-{
- struct I : public Message {
- void (O::*Member)(V, V2);
- T arg;
- T2 arg2;
- I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)(arg, arg2);
- }
- };
- internalCallMethodInMain(new I(Member, arg, arg2));
-}
-
-template<class O>
-void QDeclarativeThread::postMethodToThread(void (O::*Member)())
-{
- struct I : public Message {
- void (O::*Member)();
- I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)();
- }
- };
- internalPostMethodToThread(new I(Member));
-}
-
-template<typename T, class V, class O>
-void QDeclarativeThread::postMethodToThread(void (O::*Member)(V), const T &arg)
-{
- struct I : public Message {
- void (O::*Member)(V);
- T arg;
- I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)(arg);
- }
- };
- internalPostMethodToThread(new I(Member, arg));
-}
-
-template<typename T, typename T2, class V, class V2, class O>
-void QDeclarativeThread::postMethodToThread(void (O::*Member)(V, V2), const T &arg, const T2 &arg2)
-{
- struct I : public Message {
- void (O::*Member)(V, V2);
- T arg;
- T2 arg2;
- I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)(arg, arg2);
- }
- };
- internalPostMethodToThread(new I(Member, arg, arg2));
-}
-
-template<class O>
-void QDeclarativeThread::postMethodToMain(void (O::*Member)())
-{
- struct I : public Message {
- void (O::*Member)();
- I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)();
- }
- };
- internalPostMethodToMain(new I(Member));
-}
-
-template<typename T, class V, class O>
-void QDeclarativeThread::postMethodToMain(void (O::*Member)(V), const T &arg)
-{
- struct I : public Message {
- void (O::*Member)(V);
- T arg;
- I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)(arg);
- }
- };
- internalPostMethodToMain(new I(Member, arg));
-}
-
-template<typename T, typename T2, class V, class V2, class O>
-void QDeclarativeThread::postMethodToMain(void (O::*Member)(V, V2), const T &arg, const T2 &arg2)
-{
- struct I : public Message {
- void (O::*Member)(V, V2);
- T arg;
- T2 arg2;
- I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QDeclarativeThread *thread) {
- O *me = static_cast<O *>(thread);
- (me->*Member)(arg, arg2);
- }
- };
- internalPostMethodToMain(new I(Member, arg, arg2));
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVETHREAD_P_H
diff --git a/src/declarative/qml/ftw/qdeclarativetrace.cpp b/src/declarative/qml/ftw/qdeclarativetrace.cpp
deleted file mode 100644
index 7c814e37c1..0000000000
--- a/src/declarative/qml/ftw/qdeclarativetrace.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetrace_p.h"
-
-#ifdef QML_ENABLE_TRACE
-#include <stdio.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QML_ENABLE_TRACE
-
-QDeclarativeTrace::Pool QDeclarativeTrace::logPool;
-QDeclarativeTrace::Entry *QDeclarativeTrace::first = 0;
-QDeclarativeTrace::Entry *QDeclarativeTrace::last = 0;
-
-static qint64 toNsecs(QDeclarativeTrace::TimeType time)
-{
-#ifdef Q_OS_MAC
- static mach_timebase_info_data_t info = {0,0};
- if (info.denom == 0)
- mach_timebase_info(&info);
- return time * info.numer / info.denom;
-#else
- qint64 rv = time.tv_sec * 1000000000 + time.tv_nsec;
- return rv;
-#endif
-}
-
-QDeclarativeTrace::Pool::Pool()
-{
- first = New<Entry>();
- last = first;
-}
-
-QDeclarativeTrace::Pool::~Pool()
-{
- char buffer[128];
- sprintf(buffer, "qml.%d.log", ::getpid());
- FILE *out = fopen(buffer, "w");
- if (!out) {
- fprintf (stderr, "QML Log: Could not open %s\n", buffer);
- return;
- } else {
- fprintf (stderr, "QML Log: Writing log to %s\n", buffer);
- }
-
- QDeclarativeTrace::Entry *cur = QDeclarativeTrace::first;
- QByteArray indent;
- int depth = -1;
-
- qint64 firstTime = -1;
-
- while (cur) {
-
- switch (cur->type) {
- case QDeclarativeTrace::Entry::RangeStart: {
- RangeStart *rs = static_cast<QDeclarativeTrace::RangeStart *>(cur);
-
- qint64 nsecs = toNsecs(rs->time);
-
- if (firstTime == -1)
- firstTime = nsecs;
-
- nsecs -= firstTime;
-
- depth++;
- indent = QByteArray(depth * 4, ' ');
- fprintf(out, "%s%s @%lld (%lld ns)\n", indent.constData(),
- rs->description, nsecs, toNsecs(rs->end->time) - nsecs - firstTime);
- } break;
- case QDeclarativeTrace::Entry::RangeEnd:
- depth--;
- indent = QByteArray(depth * 4, ' ');
- break;
- case QDeclarativeTrace::Entry::Detail:
- fprintf(out, "%s %s\n", indent.constData(),
- static_cast<QDeclarativeTrace::Detail *>(cur)->description);
- break;
- case QDeclarativeTrace::Entry::IntDetail:
- fprintf(out, "%s %s: %d\n", indent.constData(),
- static_cast<QDeclarativeTrace::Detail *>(cur)->description,
- static_cast<QDeclarativeTrace::IntDetail *>(cur)->value);
- break;
- case QDeclarativeTrace::Entry::StringDetail: {
- QByteArray vLatin1 = static_cast<QDeclarativeTrace::StringDetail *>(cur)->value->toLatin1();
- fprintf(out, "%s %s: %s\n", indent.constData(),
- static_cast<QDeclarativeTrace::Detail *>(cur)->description,
- vLatin1.constData());
- } break;
- case QDeclarativeTrace::Entry::UrlDetail: {
- QByteArray vLatin1 = static_cast<QDeclarativeTrace::UrlDetail *>(cur)->value->toString().toLatin1();
- fprintf(out, "%s %s: %s\n", indent.constData(),
- static_cast<QDeclarativeTrace::Detail *>(cur)->description,
- vLatin1.constData());
- } break;
- case QDeclarativeTrace::Entry::Event: {
- Event *ev = static_cast<QDeclarativeTrace::Event *>(cur);
- qint64 nsecs = toNsecs(ev->time) - firstTime;
- fprintf(out, "%s + %s @%lld +%lld ns\n", indent.constData(),
- ev->description, nsecs, nsecs - (toNsecs(ev->start->time) - firstTime));
- } break;
- case QDeclarativeTrace::Entry::Null:
- default:
- break;
- }
- cur = cur->next;
- }
- fclose(out);
-}
-
-#endif
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/ftw/qdeclarativetrace_p.h b/src/declarative/qml/ftw/qdeclarativetrace_p.h
deleted file mode 100644
index 89ed26e925..0000000000
--- a/src/declarative/qml/ftw/qdeclarativetrace_p.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETRACE_P_H
-#define QDECLARATIVETRACE_P_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 <private/qdeclarativepool_p.h>
-
-// #define QML_ENABLE_TRACE
-
-#if defined(QML_ENABLE_TRACE) && defined(Q_OS_MAC)
-#include <mach/mach_time.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QUrl;
-class QDeclarativeTrace
-{
-public:
- inline QDeclarativeTrace(const char *desc);
- inline ~QDeclarativeTrace();
-
- inline void addDetail(const char *);
- inline void addDetail(const char *, int);
- inline void addDetail(const char *, const QString &);
- inline void addDetail(const char *, const QUrl &);
-
- inline void event(const char *desc);
-
-#ifdef QML_ENABLE_TRACE
-
-#ifdef Q_OS_MAC
- typedef uint64_t TimeType;
-#else
- typedef timespec TimeType;
-#endif
-
- struct Entry : public QDeclarativePool::POD {
- enum Type { Null, RangeStart, RangeEnd, Detail, IntDetail, StringDetail, UrlDetail, Event };
- inline Entry();
- inline Entry(Type);
- Type type;
- Entry *next;
- };
- struct RangeEnd : public Entry {
- inline RangeEnd();
- TimeType time;
- };
- struct RangeStart : public Entry {
- inline RangeStart();
- const char *description;
- TimeType time;
- QDeclarativeTrace::RangeEnd *end;
- };
- struct Detail : public Entry {
- inline Detail();
- inline Detail(Type t);
- const char *description;
- };
- struct IntDetail : public Detail {
- inline IntDetail();
- int value;
- };
- struct StringDetail : public Detail {
- inline StringDetail();
- QString *value;
- };
- struct UrlDetail : public Detail {
- inline UrlDetail();
- QUrl *value;
- };
- struct Event : public Entry {
- inline Event();
- const char *description;
- TimeType time;
- QDeclarativeTrace::RangeStart *start;
- };
-
- struct Pool : public QDeclarativePool {
- Pool();
- ~Pool();
- };
-
- static Pool logPool;
- static Entry *first;
- static Entry *last;
-
-private:
- RangeStart *start;
-
- static TimeType gettime() {
-#ifdef Q_OS_MAC
- return mach_absolute_time();
-#else
- TimeType ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts;
-#endif
- }
-#endif
-};
-
-#ifdef QML_ENABLE_TRACE
-QDeclarativeTrace::Entry::Entry()
-: type(Null), next(0)
-{
-}
-
-QDeclarativeTrace::Entry::Entry(Type type)
-: type(type), next(0)
-{
- QDeclarativeTrace::last->next = this;
- QDeclarativeTrace::last = this;
-}
-
-QDeclarativeTrace::RangeEnd::RangeEnd()
-: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::RangeEnd),
- time(gettime())
-{
-}
-
-QDeclarativeTrace::RangeStart::RangeStart()
-: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::RangeStart),
- description(0), time(gettime())
-{
-}
-
-QDeclarativeTrace::Detail::Detail()
-: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::Detail),
- description(0)
-{
-}
-
-QDeclarativeTrace::Detail::Detail(Type type)
-: QDeclarativeTrace::Entry(type), description(0)
-{
-}
-
-QDeclarativeTrace::IntDetail::IntDetail()
-: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::IntDetail),
- value(0)
-{
-}
-
-QDeclarativeTrace::StringDetail::StringDetail()
-: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::StringDetail),
- value(0)
-{
-}
-
-QDeclarativeTrace::UrlDetail::UrlDetail()
-: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::UrlDetail),
- value(0)
-{
-}
-
-QDeclarativeTrace::Event::Event()
-: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::Event),
- description(0), time(gettime()), start(0)
-{
-}
-#endif
-
-QDeclarativeTrace::QDeclarativeTrace(const char *desc)
-{
-#ifdef QML_ENABLE_TRACE
- RangeStart *e = logPool.New<RangeStart>();
- e->description = desc;
- e->end = 0;
- start = e;
-#else
- Q_UNUSED(desc);
-#endif
-}
-
-QDeclarativeTrace::~QDeclarativeTrace()
-{
-#ifdef QML_ENABLE_TRACE
- RangeEnd *e = logPool.New<RangeEnd>();
- start->end = e;
-#endif
-}
-
-void QDeclarativeTrace::addDetail(const char *desc)
-{
-#ifdef QML_ENABLE_TRACE
- Detail *e = logPool.New<Detail>();
- e->description = desc;
-#else
- Q_UNUSED(desc);
-#endif
-}
-
-void QDeclarativeTrace::addDetail(const char *desc, int v)
-{
-#ifdef QML_ENABLE_TRACE
- IntDetail *e = logPool.New<IntDetail>();
- e->description = desc;
- e->value = v;
-#else
- Q_UNUSED(desc);
- Q_UNUSED(v);
-#endif
-}
-
-void QDeclarativeTrace::addDetail(const char *desc, const QString &v)
-{
-#ifdef QML_ENABLE_TRACE
- StringDetail *e = logPool.New<StringDetail>();
- e->description = desc;
- e->value = logPool.NewString(v);
-#else
- Q_UNUSED(desc);
- Q_UNUSED(v);
-#endif
-}
-
-void QDeclarativeTrace::addDetail(const char *desc, const QUrl &v)
-{
-#ifdef QML_ENABLE_TRACE
- UrlDetail *e = logPool.New<UrlDetail>();
- e->description = desc;
- e->value = logPool.NewUrl(v);
-#else
- Q_UNUSED(desc);
- Q_UNUSED(v);
-#endif
-}
-
-void QDeclarativeTrace::event(const char *desc)
-{
-#ifdef QML_ENABLE_TRACE
- Event *e = logPool.New<Event>();
- e->start = start;
- e->description = desc;
-#else
- Q_UNUSED(desc);
-#endif
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVETRACE_P_H
diff --git a/src/declarative/qml/ftw/qdeletewatcher_p.h b/src/declarative/qml/ftw/qdeletewatcher_p.h
deleted file mode 100644
index 020907aa65..0000000000
--- a/src/declarative/qml/ftw/qdeletewatcher_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDELETEWATCHER_P_H
-#define QDELETEWATCHER_P_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>
-
-QT_BEGIN_NAMESPACE
-
-class QDeleteWatchable
-{
-public:
- inline QDeleteWatchable();
- inline ~QDeleteWatchable();
-private:
- friend class QDeleteWatcher;
- bool *_w;
-};
-
-class QDeleteWatcher {
-public:
- inline QDeleteWatcher(QDeleteWatchable *data);
- inline ~QDeleteWatcher();
- inline bool wasDeleted() const;
-private:
- void *operator new(size_t);
- bool *_w;
- bool _s;
- QDeleteWatchable *m_d;
-};
-
-QDeleteWatchable::QDeleteWatchable()
-: _w(0)
-{
-}
-
-QDeleteWatchable::~QDeleteWatchable()
-{
- if (_w) *_w = true;
-}
-
-QDeleteWatcher::QDeleteWatcher(QDeleteWatchable *data)
-: _s(false), m_d(data)
-{
- if (!m_d->_w)
- m_d->_w = &_s;
- _w = m_d->_w;
-}
-
-QDeleteWatcher::~QDeleteWatcher()
-{
- if (false == *_w && &_s == m_d->_w)
- m_d->_w = 0;
-}
-
-bool QDeleteWatcher::wasDeleted() const
-{
- return *_w;
-}
-
-QT_END_NAMESPACE
-
-#endif // QDELETEWATCHER_P_H
diff --git a/src/declarative/qml/ftw/qfastmetabuilder.cpp b/src/declarative/qml/ftw/qfastmetabuilder.cpp
deleted file mode 100644
index 327ed861f6..0000000000
--- a/src/declarative/qml/ftw/qfastmetabuilder.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfastmetabuilder_p.h"
-
-#include <QtCore/qmetaobject.h>
-#include <private/qobject_p.h>
-#include <private/qmetaobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-struct QFastMetaBuilderHeader
-{
- int fieldCount;
-};
-
-#define FMBHEADER_FIELD_COUNT 1
-
-#define HEADER_FIELD_COUNT 14
-#define CLASSINFO_FIELD_COUNT 2
-#define METHOD_FIELD_COUNT 5
-#define PROPERTY_FIELD_COUNT 3
-#define PROPERTY_NOTIFY_FIELD_COUNT 1
-
-static inline uint *fieldPointer(QByteArray &data)
-{ return reinterpret_cast<uint *>(data.data()) + FMBHEADER_FIELD_COUNT; }
-
-static inline const uint *fieldPointer(const QByteArray &data)
-{ return reinterpret_cast<const uint *>(data.constData()) + FMBHEADER_FIELD_COUNT; }
-
-static inline QMetaObjectPrivate *priv(QByteArray &data)
-{ return reinterpret_cast<QMetaObjectPrivate*>(fieldPointer(data)); }
-
-static inline const QMetaObjectPrivate *priv(const QByteArray &data)
-{ return reinterpret_cast<const QMetaObjectPrivate*>(fieldPointer(data)); }
-
-static inline QFastMetaBuilderHeader *header(QByteArray &data)
-{ return reinterpret_cast<QFastMetaBuilderHeader*>(data.data()); }
-
-static inline const QFastMetaBuilderHeader *header(const QByteArray &data)
-{ return reinterpret_cast<const QFastMetaBuilderHeader*>(data.constData()); }
-
-QFastMetaBuilder::QFastMetaBuilder()
-: m_zeroPtr(0), m_stringData(0), m_stringDataLength(0), m_stringDataAllocated(0)
-{
-}
-
-QFastMetaBuilder::~QFastMetaBuilder()
-{
-}
-
-QFastMetaBuilder::StringRef QFastMetaBuilder::init(int classNameLength,
- int propertyCount, int methodCount,
- int signalCount, int classInfoCount)
-{
- Q_ASSERT(m_data.isEmpty());
- Q_ASSERT(classNameLength > 0);
- Q_ASSERT(propertyCount >= 0);
- Q_ASSERT(methodCount >= 0);
- Q_ASSERT(signalCount >= 0);
- Q_ASSERT(classInfoCount >= 0);
-
- int fieldCount = FMBHEADER_FIELD_COUNT +
- HEADER_FIELD_COUNT +
- propertyCount * (PROPERTY_FIELD_COUNT + PROPERTY_NOTIFY_FIELD_COUNT) +
- methodCount * (METHOD_FIELD_COUNT) +
- signalCount * (METHOD_FIELD_COUNT) +
- classInfoCount * CLASSINFO_FIELD_COUNT;
-
- m_data.resize(fieldCount * sizeof(uint) + classNameLength + 1);
- m_stringData = m_data.data() + m_data.size() - classNameLength - 1;
- m_stringDataLength = classNameLength + 1;
- m_stringDataAllocated = classNameLength + 1;
- m_stringData[classNameLength] = 0;
- m_zeroPtr = classNameLength;
-
- header(m_data)->fieldCount = fieldCount;
-
- QMetaObjectPrivate *p = priv(m_data);
-
- int dataIndex = HEADER_FIELD_COUNT;
-
- p->revision = 6;
- p->className = 0;
-
- // Class infos
- p->classInfoCount = classInfoCount;
- if (p->classInfoCount) {
- p->classInfoData = dataIndex;
- dataIndex += p->classInfoCount * CLASSINFO_FIELD_COUNT;
- } else {
- p->classInfoData = 0;
- }
-
- // Methods
- p->methodCount = methodCount + signalCount;
- if (p->methodCount) {
- p->methodData = dataIndex;
- dataIndex += p->methodCount * METHOD_FIELD_COUNT;
- } else {
- p->methodData = 0;
- }
- p->signalCount = signalCount;
-
- // Properties
- p->propertyCount = propertyCount;
- if (p->propertyCount) {
- p->propertyData = dataIndex;
- dataIndex += p->propertyCount * (PROPERTY_FIELD_COUNT + PROPERTY_NOTIFY_FIELD_COUNT);
- } else {
- p->propertyData = 0;
- }
-
- // Flags
- p->flags = DynamicMetaObject; // Always dynamic
-
- // Enums and constructors not supported
- p->enumeratorCount = 0;
- p->enumeratorData = 0;
- p->constructorCount = 0;
- p->constructorData = 0;
-
- StringRef className;
- className._b = this;
- className._o = 0;
- className._l = classNameLength;
- return className;
-}
-
-// Allocate a string of \a length. \a length should *not* include the null terminator.
-QFastMetaBuilder::StringRef QFastMetaBuilder::newString(int length)
-{
- Q_ASSERT(length > 0);
-
- StringRef sr;
- sr._b = this;
- sr._o = m_stringDataLength;
- sr._l = length;
-
- m_stringDataLength += length + 1 /* for null terminator */;
-
- return sr;
-}
-
-void QFastMetaBuilder::setClassInfo(int index, const StringRef &key, const StringRef &value)
-{
- Q_ASSERT(!m_data.isEmpty());
- Q_ASSERT(!key.isEmpty() && !value.isEmpty());
-
- QMetaObjectPrivate *p = priv(m_data);
- Q_ASSERT(index < p->classInfoCount);
-
- uint *ptr = fieldPointer(m_data) + p->classInfoData + index * CLASSINFO_FIELD_COUNT;
- // classinfo: key, value
- ptr[0] = key.offset(); ptr[1] = value.offset();
-}
-
-void QFastMetaBuilder::setProperty(int index, const StringRef &name, const StringRef &type,
- QMetaType::Type mtype, PropertyFlag flags, int notifySignal)
-{
- Q_ASSERT(!m_data.isEmpty());
- Q_ASSERT(!name.isEmpty() && !type.isEmpty());
-
- QMetaObjectPrivate *p = priv(m_data);
- Q_ASSERT(index < p->propertyCount);
-
- uint *ptr = fieldPointer(m_data) + p->propertyData + index * PROPERTY_FIELD_COUNT;
- // properties: name, type, flags
- ptr[0] = name.offset();
- ptr[1] = type.offset();
- if (notifySignal == -1) {
- ptr[2] = mtype << 24;
- ptr[2] |= flags | Scriptable | Readable;
- *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = 0;
- } else {
- ptr[2] = mtype << 24;
- ptr[2] |= flags | Scriptable | Readable | Notify;
- *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = notifySignal;
- }
-}
-
-void QFastMetaBuilder::setProperty(int index, const StringRef &name, const StringRef &type,
- QFastMetaBuilder::PropertyFlag flags, int notifySignal)
-{
- Q_ASSERT(!m_data.isEmpty());
- Q_ASSERT(!name.isEmpty() && !type.isEmpty());
-
- QMetaObjectPrivate *p = priv(m_data);
- Q_ASSERT(index < p->propertyCount);
-
- uint *ptr = fieldPointer(m_data) + p->propertyData + index * PROPERTY_FIELD_COUNT;
- // properties: name, type, flags
- ptr[0] = name.offset();
- ptr[1] = type.offset();
- if (notifySignal == -1) {
- ptr[2] = flags | Scriptable | Readable;
- *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = 0;
- } else {
- ptr[2] = flags | Scriptable | Readable | Notify;
- *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = notifySignal;
- }
-}
-
-void QFastMetaBuilder::setSignal(int index, const StringRef &signature,
- const StringRef &parameterNames,
- const StringRef &type)
-{
- Q_ASSERT(!m_data.isEmpty());
- Q_ASSERT(!signature.isEmpty());
-
- QMetaObjectPrivate *p = priv(m_data);
- int mindex = metaObjectIndexForSignal(index);
-
- uint *ptr = fieldPointer(m_data) + p->methodData + mindex * METHOD_FIELD_COUNT;
- // methods: signature, parameters, type, tag, flags
- ptr[0] = signature.offset();
- ptr[1] = parameterNames.isEmpty()?m_zeroPtr:parameterNames.offset();
- ptr[2] = type.isEmpty()?m_zeroPtr:type.offset();
- ptr[3] = m_zeroPtr;
- ptr[4] = AccessProtected | MethodSignal;
-}
-
-void QFastMetaBuilder::setMethod(int index, const StringRef &signature,
- const StringRef &parameterNames,
- const StringRef &type)
-{
- Q_ASSERT(!m_data.isEmpty());
- Q_ASSERT(!signature.isEmpty());
-
- QMetaObjectPrivate *p = priv(m_data);
- int mindex = metaObjectIndexForMethod(index);
-
- uint *ptr = fieldPointer(m_data) + p->methodData + mindex * METHOD_FIELD_COUNT;
- // methods: signature, parameters, type, tag, flags
- ptr[0] = signature.offset();
- ptr[1] = parameterNames.isEmpty()?m_zeroPtr:parameterNames.offset();
- ptr[2] = type.isEmpty()?m_zeroPtr:type.offset();
- ptr[3] = m_zeroPtr;
- ptr[4] = AccessProtected | MethodSlot;
-}
-
-int QFastMetaBuilder::metaObjectIndexForSignal(int index) const
-{
- Q_ASSERT(!m_data.isEmpty());
- Q_ASSERT(index < priv(m_data)->signalCount);
- return index;
-}
-
-int QFastMetaBuilder::metaObjectIndexForMethod(int index) const
-{
- Q_ASSERT(!m_data.isEmpty());
-
- const QMetaObjectPrivate *p = priv(m_data);
- Q_ASSERT(index < (p->methodCount - p->signalCount));
- return index + p->signalCount;
-}
-
-void QFastMetaBuilder::allocateStringData()
-{
- if (m_stringDataAllocated < m_stringDataLength) {
- m_data.resize(m_data.size() + m_stringDataLength - m_stringDataAllocated);
- m_stringDataAllocated = m_stringDataLength;
- m_stringData = m_data.data() + header(m_data)->fieldCount * sizeof(uint);
- }
-}
-
-void QFastMetaBuilder::fromData(QMetaObject *output, const QMetaObject *parent, const QByteArray &data)
-{
- output->d.superdata = parent;
- output->d.stringdata = data.constData() + header(data)->fieldCount * sizeof(uint);
- output->d.data = fieldPointer(data);
- output->d.extradata = 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/ftw/qfastmetabuilder_p.h b/src/declarative/qml/ftw/qfastmetabuilder_p.h
deleted file mode 100644
index e8b7394fe4..0000000000
--- a/src/declarative/qml/ftw/qfastmetabuilder_p.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFASTMETABUILDER_P_H
-#define QFASTMETABUILDER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of moc. This header file may change from version to version without notice,
-// or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qmetatype.h>
-#include <QtCore/qmetaobject.h>
-
-#include <private/qhashedstring_p.h>
-
-QT_BEGIN_NAMESPACE
-
-struct QMetaObject;
-class QFastMetaBuilder
-{
-public:
- QFastMetaBuilder();
- ~QFastMetaBuilder();
-
- struct StringRef {
- public:
- inline StringRef();
- inline StringRef(const StringRef &);
- inline StringRef &operator=(const StringRef &);
-
- inline void load(const QHashedStringRef &);
- inline void load(const QByteArray &);
- inline void load(const char *);
-
- inline bool isEmpty() const;
- inline QFastMetaBuilder *builder() const;
- inline int offset() const;
- inline char *data();
- inline int length() const;
- private:
- friend class QFastMetaBuilder;
-
- QFastMetaBuilder *_b;
- int _o;
- int _l;
- };
- StringRef newString(int length);
-
- // Returns class name
- StringRef init(int classNameLength,
- int propertyCount, int methodCount,
- int signalCount, int classInfoCount);
-
- void setClassInfo(int index, const StringRef &key, const StringRef &value);
-
- enum PropertyFlag {
- None = 0x00000000,
- Writable = 0x00000002,
- Resettable = 0x00000004,
- Constant = 0x00000400,
- Final = 0x00000800
- };
- // void setProperty(int index, const StringRef &name, QMetaType::Type type, int notifySignal = -1);
- void setProperty(int index, const StringRef &name, const StringRef &type,
- QMetaType::Type mtype, PropertyFlag flags, int notifySignal = -1);
- void setProperty(int index, const StringRef &name, const StringRef &type,
- PropertyFlag flags, int notifySignal = -1);
- void setMethod(int index, const StringRef &signature,
- const StringRef &parameterNames = StringRef(),
- const StringRef &type = StringRef());
- void setSignal(int index, const StringRef &signature,
- const StringRef &parameterNames = StringRef(),
- const StringRef &type = StringRef());
-
- int metaObjectIndexForSignal(int) const;
- int metaObjectIndexForMethod(int) const;
-
- QByteArray toData() const { return m_data; }
- static void fromData(QMetaObject *, const QMetaObject *parent, const QByteArray &);
-private:
- friend struct StringRef;
-
- QByteArray m_data;
- int m_zeroPtr;
-
- void allocateStringData();
- char *m_stringData;
- int m_stringDataLength;
- int m_stringDataAllocated;
-};
-
-QFastMetaBuilder::StringRef::StringRef()
-: _b(0), _o(0), _l(0)
-{
-}
-
-QFastMetaBuilder::StringRef::StringRef(const StringRef &o)
-: _b(o._b), _o(o._o), _l(o._l)
-{
-}
-
-QFastMetaBuilder::StringRef &QFastMetaBuilder::StringRef::operator=(const StringRef &o)
-{
- _b = o._b;
- _o = o._o;
- _l = o._l;
- return *this;
-}
-
-bool QFastMetaBuilder::StringRef::isEmpty() const
-{
- return _l == 0;
-}
-
-QFastMetaBuilder *QFastMetaBuilder::StringRef::builder() const
-{
- return _b;
-}
-
-int QFastMetaBuilder::StringRef::offset() const
-{
- return _o;
-}
-
-char *QFastMetaBuilder::StringRef::data()
-{
- Q_ASSERT(_b);
- if (_b->m_stringDataLength != _b->m_stringDataAllocated)
- _b->allocateStringData();
- return _b->m_stringData + _o;
-}
-
-int QFastMetaBuilder::StringRef::length() const
-{
- return _l;
-}
-
-void QFastMetaBuilder::StringRef::load(const QHashedStringRef &str)
-{
- Q_ASSERT(str.utf8length() == _l);
- str.writeUtf8(data());
- *(data() + _l) = 0;
-}
-
-void QFastMetaBuilder::StringRef::load(const QByteArray &str)
-{
- Q_ASSERT(str.length() == _l);
- strcpy(data(), str.constData());
-}
-
-void QFastMetaBuilder::StringRef::load(const char *str)
-{
- Q_ASSERT(strlen(str) == (uint)_l);
- strcpy(data(), str);
-}
-
-QT_END_NAMESPACE
-
-#endif // QFASTMETABUILDER_P_H
-
diff --git a/src/declarative/qml/ftw/qfieldlist_p.h b/src/declarative/qml/ftw/qfieldlist_p.h
deleted file mode 100644
index 4253779e78..0000000000
--- a/src/declarative/qml/ftw/qfieldlist_p.h
+++ /dev/null
@@ -1,426 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFIELDLIST_P_H
-#define QFIELDLIST_P_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 <private/qflagpointer_p.h>
-
-// QForwardFieldList is a super simple linked list that can only prepend
-template<class N, N *N::*nextMember>
-class QForwardFieldList
-{
-public:
- inline QForwardFieldList();
- inline N *first() const;
- inline N *takeFirst();
-
- inline void prepend(N *);
-
- inline bool isEmpty() const;
- inline bool isOne() const;
- inline bool isMany() const;
-
- static inline N *next(N *v);
-
- inline bool flag() const;
- inline void setFlag();
- inline void clearFlag();
- inline void setFlagValue(bool);
-
- inline bool flag2() const;
- inline void setFlag2();
- inline void clearFlag2();
- inline void setFlag2Value(bool);
-private:
- QFlagPointer<N> _first;
-};
-
-// QFieldList is a simple linked list, that can append and prepend and also
-// maintains a count
-template<class N, N *N::*nextMember>
-class QFieldList
-{
-public:
- inline QFieldList();
- inline N *first() const;
- inline N *takeFirst();
-
- inline void append(N *);
- inline void prepend(N *);
-
- inline bool isEmpty() const;
- inline bool isOne() const;
- inline bool isMany() const;
- inline int count() const;
-
- inline void append(QFieldList<N, nextMember> &);
- inline void prepend(QFieldList<N, nextMember> &);
- inline void insertAfter(N *, QFieldList<N, nextMember> &);
-
- inline void copyAndClear(QFieldList<N, nextMember> &);
- inline void copyAndClearAppend(QForwardFieldList<N, nextMember> &);
- inline void copyAndClearPrepend(QForwardFieldList<N, nextMember> &);
-
- static inline N *next(N *v);
-
- inline bool flag() const;
- inline void setFlag();
- inline void clearFlag();
- inline void setFlagValue(bool);
-private:
- N *_first;
- N *_last;
- quint32 _flag:1;
- quint32 _count:31;
-};
-
-template<class N, N *N::*nextMember>
-QForwardFieldList<N, nextMember>::QForwardFieldList()
-{
-}
-
-template<class N, N *N::*nextMember>
-N *QForwardFieldList<N, nextMember>::first() const
-{
- return *_first;
-}
-
-template<class N, N *N::*nextMember>
-N *QForwardFieldList<N, nextMember>::takeFirst()
-{
- N *value = *_first;
- if (value) {
- _first = next(value);
- value->*nextMember = 0;
- }
- return value;
-}
-
-template<class N, N *N::*nextMember>
-void QForwardFieldList<N, nextMember>::prepend(N *v)
-{
- Q_ASSERT(v->*nextMember == 0);
- v->*nextMember = *_first;
- _first = v;
-}
-
-template<class N, N *N::*nextMember>
-bool QForwardFieldList<N, nextMember>::isEmpty() const
-{
- return _first.isNull();
-}
-
-template<class N, N *N::*nextMember>
-bool QForwardFieldList<N, nextMember>::isOne() const
-{
- return *_first && _first->*nextMember == 0;
-}
-
-template<class N, N *N::*nextMember>
-bool QForwardFieldList<N, nextMember>::isMany() const
-{
- return *_first && _first->*nextMember != 0;
-}
-
-template<class N, N *N::*nextMember>
-N *QForwardFieldList<N, nextMember>::next(N *v)
-{
- Q_ASSERT(v);
- return v->*nextMember;
-}
-
-template<class N, N *N::*nextMember>
-bool QForwardFieldList<N, nextMember>::flag() const
-{
- return _first.flag();
-}
-
-template<class N, N *N::*nextMember>
-void QForwardFieldList<N, nextMember>::setFlag()
-{
- _first.setFlag();
-}
-
-template<class N, N *N::*nextMember>
-void QForwardFieldList<N, nextMember>::clearFlag()
-{
- _first.clearFlag();
-}
-
-template<class N, N *N::*nextMember>
-void QForwardFieldList<N, nextMember>::setFlagValue(bool v)
-{
- _first.setFlagValue(v);
-}
-
-template<class N, N *N::*nextMember>
-bool QForwardFieldList<N, nextMember>::flag2() const
-{
- return _first.flag2();
-}
-
-template<class N, N *N::*nextMember>
-void QForwardFieldList<N, nextMember>::setFlag2()
-{
- _first.setFlag2();
-}
-
-template<class N, N *N::*nextMember>
-void QForwardFieldList<N, nextMember>::clearFlag2()
-{
- _first.clearFlag2();
-}
-
-template<class N, N *N::*nextMember>
-void QForwardFieldList<N, nextMember>::setFlag2Value(bool v)
-{
- _first.setFlag2Value(v);
-}
-
-template<class N, N *N::*nextMember>
-QFieldList<N, nextMember>::QFieldList()
-: _first(0), _last(0), _flag(0), _count(0)
-{
-}
-
-template<class N, N *N::*nextMember>
-N *QFieldList<N, nextMember>::first() const
-{
- return _first;
-}
-
-template<class N, N *N::*nextMember>
-N *QFieldList<N, nextMember>::takeFirst()
-{
- N *value = _first;
- if (value) {
- _first = next(value);
- if (_last == value) {
- Q_ASSERT(_first == 0);
- _last = 0;
- }
- value->*nextMember = 0;
- --_count;
- }
- return value;
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::append(N *v)
-{
- Q_ASSERT(v->*nextMember == 0);
- if (isEmpty()) {
- _first = v;
- _last = v;
- } else {
- _last->*nextMember = v;
- _last = v;
- }
- ++_count;
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::prepend(N *v)
-{
- Q_ASSERT(v->*nextMember == 0);
- if (isEmpty()) {
- _first = v;
- _last = v;
- } else {
- v->*nextMember = _first;
- _first = v;
- }
- ++_count;
-}
-
-template<class N, N *N::*nextMember>
-bool QFieldList<N, nextMember>::isEmpty() const
-{
- return _count == 0;
-}
-
-template<class N, N *N::*nextMember>
-bool QFieldList<N, nextMember>::isOne() const
-{
- return _count == 1;
-}
-
-template<class N, N *N::*nextMember>
-bool QFieldList<N, nextMember>::isMany() const
-{
- return _count > 1;
-}
-
-template<class N, N *N::*nextMember>
-int QFieldList<N, nextMember>::count() const
-{
- return _count;
-}
-
-template<class N, N *N::*nextMember>
-N *QFieldList<N, nextMember>::next(N *v)
-{
- Q_ASSERT(v);
- return v->*nextMember;
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::append(QFieldList<N, nextMember> &o)
-{
- if (!o.isEmpty()) {
- if (isEmpty()) {
- _first = o._first;
- _last = o._last;
- _count = o._count;
- } else {
- _last->*nextMember = o._first;
- _last = o._last;
- _count += o._count;
- }
- o._first = o._last = 0; o._count = 0;
- }
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::prepend(QFieldList<N, nextMember> &o)
-{
- if (!o.isEmpty()) {
- if (isEmpty()) {
- _first = o._first;
- _last = o._last;
- _count = o._count;
- } else {
- o._last->*nextMember = _first;
- _first = o._first;
- _count += o._count;
- }
- o._first = o._last = 0; o._count = 0;
- }
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::insertAfter(N *after, QFieldList<N, nextMember> &o)
-{
- if (after == 0) {
- prepend(o);
- } else if (after == _last) {
- append(o);
- } else if (!o.isEmpty()) {
- if (isEmpty()) {
- _first = o._first;
- _last = o._last;
- _count = o._count;
- } else {
- o._last->*nextMember = after->*nextMember;
- after->*nextMember = o._first;
- _count += o._count;
- }
- o._first = o._last = 0; o._count = 0;
- }
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::copyAndClear(QFieldList<N, nextMember> &o)
-{
- _first = o._first;
- _last = o._last;
- _count = o._count;
- o._first = o._last = 0;
- o._count = 0;
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::copyAndClearAppend(QForwardFieldList<N, nextMember> &o)
-{
- _first = 0;
- _last = 0;
- _count = 0;
- while (N *n = o.takeFirst()) append(n);
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::copyAndClearPrepend(QForwardFieldList<N, nextMember> &o)
-{
- _first = 0;
- _last = 0;
- _count = 0;
- while (N *n = o.takeFirst()) prepend(n);
-}
-
-template<class N, N *N::*nextMember>
-bool QFieldList<N, nextMember>::flag() const
-{
- return _flag;
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::setFlag()
-{
- _flag = true;
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::clearFlag()
-{
- _flag = false;
-}
-
-template<class N, N *N::*nextMember>
-void QFieldList<N, nextMember>::setFlagValue(bool v)
-{
- _flag = v;
-}
-
-#endif // QFIELDLIST_P_H
diff --git a/src/declarative/qml/ftw/qfinitestack_p.h b/src/declarative/qml/ftw/qfinitestack_p.h
deleted file mode 100644
index 8161b042c2..0000000000
--- a/src/declarative/qml/ftw/qfinitestack_p.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFINITESTACK_P_H
-#define QFINITESTACK_P_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>
-
-QT_BEGIN_NAMESPACE
-
-template<typename T>
-struct QFiniteStack {
- inline QFiniteStack();
- inline ~QFiniteStack();
-
- inline void deallocate();
- inline void allocate(int size);
-
- inline bool isEmpty() const;
- inline const T &top() const;
- inline T &top();
- inline void push(const T &o);
- inline T pop();
- inline int count() const;
- inline const T &at(int index) const;
- inline T &operator[](int index);
-private:
- T *_array;
- int _alloc;
- int _size;
-};
-
-template<typename T>
-QFiniteStack<T>::QFiniteStack()
-: _array(0), _alloc(0), _size(0)
-{
-}
-
-template<typename T>
-QFiniteStack<T>::~QFiniteStack()
-{
- deallocate();
-}
-
-template<typename T>
-bool QFiniteStack<T>::isEmpty() const
-{
- return _size == 0;
-}
-
-template<typename T>
-const T &QFiniteStack<T>::top() const
-{
- return _array[_size - 1];
-}
-
-template<typename T>
-T &QFiniteStack<T>::top()
-{
- return _array[_size - 1];
-}
-
-template<typename T>
-void QFiniteStack<T>::push(const T &o)
-{
- if (QTypeInfo<T>::isComplex) {
- new (_array + _size++) T(o);
- } else {
- _array[_size++] = o;
- }
-}
-
-template<typename T>
-T QFiniteStack<T>::pop()
-{
- --_size;
-
- if (QTypeInfo<T>::isComplex) {
- T rv = _array[_size];
- (_array + _size)->~T();
- return rv;
- } else {
- return _array[_size];
- }
-}
-
-template<typename T>
-int QFiniteStack<T>::count() const
-{
- return _size;
-}
-
-template<typename T>
-const T &QFiniteStack<T>::at(int index) const
-{
- return _array[index];
-}
-
-template<typename T>
-T &QFiniteStack<T>::operator[](int index)
-{
- return _array[index];
-}
-
-template<typename T>
-void QFiniteStack<T>::allocate(int size)
-{
- Q_ASSERT(_array == 0);
- Q_ASSERT(_alloc == 0);
- Q_ASSERT(_size == 0);
-
- if (!size) return;
-
- _array = (T *)qMalloc(size * sizeof(T));
- _alloc = size;
-}
-
-template<typename T>
-void QFiniteStack<T>::deallocate()
-{
- if (QTypeInfo<T>::isComplex) {
- T *i = _array + _size;
- while (i != _array)
- (--i)->~T();
- }
-
- qFree(_array);
-
- _array = 0;
- _alloc = 0;
- _size = 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QFINITESTACK_P_H
-
diff --git a/src/declarative/qml/ftw/qflagpointer_p.h b/src/declarative/qml/ftw/qflagpointer_p.h
deleted file mode 100644
index ac462cbe30..0000000000
--- a/src/declarative/qml/ftw/qflagpointer_p.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFLAGPOINTER_P_H
-#define QFLAGPOINTER_P_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>
-
-QT_BEGIN_NAMESPACE
-
-template<typename T>
-class QFlagPointer {
-public:
- inline QFlagPointer();
- inline QFlagPointer(T *);
- inline QFlagPointer(const QFlagPointer<T> &o);
-
- inline bool isNull() const;
-
- inline bool flag() const;
- inline void setFlag();
- inline void clearFlag();
- inline void setFlagValue(bool);
-
- inline bool flag2() const;
- inline void setFlag2();
- inline void clearFlag2();
- inline void setFlag2Value(bool);
-
- inline QFlagPointer<T> &operator=(const QFlagPointer &o);
- inline QFlagPointer<T> &operator=(T *);
-
- inline T *operator->() const;
- inline T *operator*() const;
-
-private:
- quintptr ptr_value;
-
- static const quintptr FlagBit = 0x1;
- static const quintptr Flag2Bit = 0x2;
- static const quintptr FlagsMask = FlagBit | Flag2Bit;
-};
-
-template<typename T, typename T2>
-class QBiPointer {
-public:
- inline QBiPointer();
- inline QBiPointer(T *);
- inline QBiPointer(T2 *);
- inline QBiPointer(const QBiPointer<T, T2> &o);
-
- inline bool isNull() const;
- inline bool isT1() const;
- inline bool isT2() const;
-
- inline bool flag() const;
- inline void setFlag();
- inline void clearFlag();
- inline void setFlagValue(bool);
-
- inline QBiPointer<T, T2> &operator=(const QBiPointer<T, T2> &o);
- inline QBiPointer<T, T2> &operator=(T *);
- inline QBiPointer<T, T2> &operator=(T2 *);
-
- inline T *asT1() const;
- inline T2 *asT2() const;
-
-private:
- quintptr ptr_value;
-
- static const quintptr FlagBit = 0x1;
- static const quintptr Flag2Bit = 0x2;
- static const quintptr FlagsMask = FlagBit | Flag2Bit;
-};
-
-template<typename T>
-QFlagPointer<T>::QFlagPointer()
-: ptr_value(0)
-{
-}
-
-template<typename T>
-QFlagPointer<T>::QFlagPointer(T *v)
-: ptr_value(quintptr(v))
-{
- Q_ASSERT((ptr_value & FlagsMask) == 0);
-}
-
-template<typename T>
-QFlagPointer<T>::QFlagPointer(const QFlagPointer<T> &o)
-: ptr_value(o.ptr_value)
-{
-}
-
-template<typename T>
-bool QFlagPointer<T>::isNull() const
-{
- return 0 == (ptr_value & (~FlagsMask));
-}
-
-template<typename T>
-bool QFlagPointer<T>::flag() const
-{
- return ptr_value & FlagBit;
-}
-
-template<typename T>
-void QFlagPointer<T>::setFlag()
-{
- ptr_value |= FlagBit;
-}
-
-template<typename T>
-void QFlagPointer<T>::clearFlag()
-{
- ptr_value &= ~FlagBit;
-}
-
-template<typename T>
-void QFlagPointer<T>::setFlagValue(bool v)
-{
- if (v) setFlag();
- else clearFlag();
-}
-
-template<typename T>
-bool QFlagPointer<T>::flag2() const
-{
- return ptr_value & Flag2Bit;
-}
-
-template<typename T>
-void QFlagPointer<T>::setFlag2()
-{
- ptr_value|= Flag2Bit;
-}
-
-template<typename T>
-void QFlagPointer<T>::clearFlag2()
-{
- ptr_value &= ~Flag2Bit;
-}
-
-template<typename T>
-void QFlagPointer<T>::setFlag2Value(bool v)
-{
- if (v) setFlag2();
- else clearFlag2();
-}
-
-template<typename T>
-QFlagPointer<T> &QFlagPointer<T>::operator=(const QFlagPointer &o)
-{
- ptr_value = o.ptr_value;
- return *this;
-}
-
-template<typename T>
-QFlagPointer<T> &QFlagPointer<T>::operator=(T *o)
-{
- Q_ASSERT((quintptr(o) & FlagsMask) == 0);
-
- ptr_value = quintptr(o) | (ptr_value & FlagsMask);
- return *this;
-}
-
-template<typename T>
-T *QFlagPointer<T>::operator->() const
-{
- return (T *)(ptr_value & ~FlagsMask);
-}
-
-template<typename T>
-T *QFlagPointer<T>::operator*() const
-{
- return (T *)(ptr_value & ~FlagsMask);
-}
-
-template<typename T, typename T2>
-QBiPointer<T, T2>::QBiPointer()
-: ptr_value(0)
-{
-}
-
-template<typename T, typename T2>
-QBiPointer<T, T2>::QBiPointer(T *v)
-: ptr_value(quintptr(v))
-{
- Q_ASSERT((quintptr(v) & FlagsMask) == 0);
-}
-
-template<typename T, typename T2>
-QBiPointer<T, T2>::QBiPointer(T2 *v)
-: ptr_value(quintptr(v) | Flag2Bit)
-{
- Q_ASSERT((quintptr(v) & FlagsMask) == 0);
-}
-
-template<typename T, typename T2>
-QBiPointer<T, T2>::QBiPointer(const QBiPointer<T, T2> &o)
-: ptr_value(o.ptr_value)
-{
-}
-
-template<typename T, typename T2>
-bool QBiPointer<T, T2>::isNull() const
-{
- return 0 == (ptr_value & (~FlagsMask));
-}
-
-template<typename T, typename T2>
-bool QBiPointer<T, T2>::isT1() const
-{
- return !(ptr_value & Flag2Bit);
-}
-
-template<typename T, typename T2>
-bool QBiPointer<T, T2>::isT2() const
-{
- return ptr_value & Flag2Bit;
-}
-
-template<typename T, typename T2>
-bool QBiPointer<T, T2>::flag() const
-{
- return ptr_value & FlagBit;
-}
-
-template<typename T, typename T2>
-void QBiPointer<T, T2>::setFlag()
-{
- ptr_value |= FlagBit;
-}
-
-template<typename T, typename T2>
-void QBiPointer<T, T2>::clearFlag()
-{
- ptr_value &= ~FlagBit;
-}
-
-template<typename T, typename T2>
-void QBiPointer<T, T2>::setFlagValue(bool v)
-{
- if (v) setFlag();
- else clearFlag();
-}
-
-template<typename T, typename T2>
-QBiPointer<T, T2> &QBiPointer<T, T2>::operator=(const QBiPointer<T, T2> &o)
-{
- ptr_value = o.ptr_value;
- return *this;
-}
-
-template<typename T, typename T2>
-QBiPointer<T, T2> &QBiPointer<T, T2>::operator=(T *o)
-{
- Q_ASSERT((quintptr(o) & FlagsMask) == 0);
-
- ptr_value = quintptr(o) | (ptr_value & FlagBit);
- return *this;
-}
-
-template<typename T, typename T2>
-QBiPointer<T, T2> &QBiPointer<T, T2>::operator=(T2 *o)
-{
- Q_ASSERT((quintptr(o) & FlagsMask) == 0);
-
- ptr_value = quintptr(o) | (ptr_value & FlagBit) | Flag2Bit;
- return *this;
-}
-
-template<typename T, typename T2>
-T *QBiPointer<T, T2>::asT1() const
-{
- Q_ASSERT(isT1());
- return (T *)(ptr_value & ~FlagsMask);
-}
-
-template<typename T, typename T2>
-T2 *QBiPointer<T, T2>::asT2() const
-{
- Q_ASSERT(isT2());
- return (T2 *)(ptr_value & ~FlagsMask);
-}
-
-QT_END_NAMESPACE
-
-#endif // QFLAGPOINTER_P_H
diff --git a/src/declarative/qml/ftw/qhashedstring.cpp b/src/declarative/qml/ftw/qhashedstring.cpp
deleted file mode 100644
index f3b5a9ebc9..0000000000
--- a/src/declarative/qml/ftw/qhashedstring.cpp
+++ /dev/null
@@ -1,490 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qhashedstring_p.h"
-
-// This is a reimplementation of V8's string hash algorithm. It is significantly
-// faster to do it here than call into V8, but it adds the maintainence burden of
-// ensuring that the two hashes are identical. We Q_ASSERT() that the two return
-// the same value. If these asserts start to fail, the hash code needs to be
-// synced with V8.
-namespace String {
- static const int kMaxArrayIndexSize = 10;
- static const int kMaxHashCalcLength = 16383;
- static const int kNofHashBitFields = 2;
- static const int kHashShift = kNofHashBitFields;
- static const int kIsNotArrayIndexMask = 1 << 1;
- static const int kArrayIndexValueBits = 24;
- static const int kArrayIndexHashLengthShift = kArrayIndexValueBits + kNofHashBitFields;
- static const int kMaxCachedArrayIndexLength = 7;
-};
-
-template <typename schar>
-uint32_t calculateHash(const schar* chars, int length) {
- if (length > String::kMaxHashCalcLength) {
- // V8 trivial hash
- return (length << String::kHashShift) | String::kIsNotArrayIndexMask;
- }
-
- uint32_t raw_running_hash = 0;
- uint32_t array_index = 0;
- bool is_array_index = (0 < length && length <= String::kMaxArrayIndexSize);
- bool is_first_char = true;
-
- int ii = 0;
- for (;is_array_index && ii < length; ++ii) {
- quint32 c = *chars++;
-
- raw_running_hash += c;
- raw_running_hash += (raw_running_hash << 10);
- raw_running_hash ^= (raw_running_hash >> 6);
-
- if (c < '0' || c > '9') {
- is_array_index = false;
- } else {
- int d = c - '0';
- if (is_first_char) {
- is_first_char = false;
- if (c == '0' && length > 1) {
- is_array_index = false;
- continue;
- }
- }
- if (array_index > 429496729U - ((d + 2) >> 3)) {
- is_array_index = false;
- } else {
- array_index = array_index * 10 + d;
- }
- }
- }
-
- for (;ii < length; ++ii) {
- raw_running_hash += *chars++;
- raw_running_hash += (raw_running_hash << 10);
- raw_running_hash ^= (raw_running_hash >> 6);
- }
-
- if (is_array_index) {
- array_index <<= String::kHashShift;
- array_index |= length << String::kArrayIndexHashLengthShift;
- return array_index;
- } else {
- raw_running_hash += (raw_running_hash << 3);
- raw_running_hash ^= (raw_running_hash >> 11);
- raw_running_hash += (raw_running_hash << 15);
- if (raw_running_hash == 0) {
- raw_running_hash = 27;
- }
-
- return (raw_running_hash << String::kHashShift) | String::kIsNotArrayIndexMask;
- }
-}
-
-inline quint32 stringHash(const QChar* data, int length)
-{
- quint32 rv = calculateHash<quint16>((quint16*)data, length) >> String::kHashShift;
- Q_ASSERT(rv == v8::String::ComputeHash((uint16_t*)data, length));
- return rv;
-}
-
-inline quint32 stringHash(const char *data, int length)
-{
- quint32 rv = calculateHash<quint8>((quint8*)data, length) >> String::kHashShift;
- Q_ASSERT(rv == v8::String::ComputeHash((char *)data, length));
- return rv;
-}
-
-void QHashedString::computeHash() const
-{
- m_hash = stringHash(constData(), length());
-}
-
-void QHashedStringRef::computeHash() const
-{
- m_hash = stringHash(m_data, m_length);
-}
-
-void QHashedCStringRef::computeHash() const
-{
- m_hash = stringHash(m_data, m_length);
-}
-
-/*
- A QHash has initially around pow(2, MinNumBits) buckets. For
- example, if MinNumBits is 4, it has 17 buckets.
-*/
-const int MinNumBits = 4;
-
-/*
- The prime_deltas array is a table of selected prime values, even
- though it doesn't look like one. The primes we are using are 1,
- 2, 5, 11, 17, 37, 67, 131, 257, ..., i.e. primes in the immediate
- surrounding of a power of two.
-
- The primeForNumBits() function returns the prime associated to a
- power of two. For example, primeForNumBits(8) returns 257.
-*/
-
-static const uchar prime_deltas[] = {
- 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3,
- 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0
-};
-
-static inline int primeForNumBits(int numBits)
-{
- return (1 << numBits) + prime_deltas[numBits];
-}
-
-void QStringHashData::rehashToSize(int size, IteratorData first,
- IteratorData (*Iterate)(const IteratorData &),
- QStringHashNode *skip)
-{
- short bits = qMax(MinNumBits, (int)numBits);
- while (primeForNumBits(bits) < size) bits++;
-
- if (bits > numBits)
- rehashToBits(bits, first, Iterate, skip);
-}
-
-void QStringHashData::rehashToBits(short bits, IteratorData first,
- IteratorData (*Iterate)(const IteratorData &),
- QStringHashNode *skip)
-{
- numBits = qMax(MinNumBits, (int)bits);
-
- int nb = primeForNumBits(numBits);
- if (nb == numBuckets && buckets)
- return;
-
- numBuckets = nb;
-
-#ifdef QSTRINGHASH_LINK_DEBUG
- if (linkCount)
- qFatal("QStringHash: Illegal attempt to rehash a linked hash.");
-#endif
-
- delete [] buckets;
- buckets = new QStringHashNode *[numBuckets];
- ::memset(buckets, 0, sizeof(QStringHashNode *) * numBuckets);
-
- IteratorData nodeList = first;
- while (nodeList.n) {
- if (nodeList.n != skip) {
- int bucket = nodeList.n->hash % numBuckets;
- nodeList.n->next = buckets[bucket];
- buckets[bucket] = nodeList.n;
- }
-
- nodeList = Iterate(nodeList);
- }
-}
-
-// Copy of QString's qMemCompare
-bool QHashedString::compare(const QChar *lhs, const QChar *rhs, int length)
-{
- Q_ASSERT(lhs && rhs);
- const quint16 *a = (const quint16 *)lhs;
- const quint16 *b = (const quint16 *)rhs;
-
- if (a == b || !length)
- return true;
-
- register union {
- const quint16 *w;
- const quint32 *d;
- quintptr value;
- } sa, sb;
- sa.w = a;
- sb.w = b;
-
- // check alignment
- if ((sa.value & 2) == (sb.value & 2)) {
- // both addresses have the same alignment
- if (sa.value & 2) {
- // both addresses are not aligned to 4-bytes boundaries
- // compare the first character
- if (*sa.w != *sb.w)
- return false;
- --length;
- ++sa.w;
- ++sb.w;
-
- // now both addresses are 4-bytes aligned
- }
-
- // both addresses are 4-bytes aligned
- // do a fast 32-bit comparison
- register const quint32 *e = sa.d + (length >> 1);
- for ( ; sa.d != e; ++sa.d, ++sb.d) {
- if (*sa.d != *sb.d)
- return false;
- }
-
- // do we have a tail?
- return (length & 1) ? *sa.w == *sb.w : true;
- } else {
- // one of the addresses isn't 4-byte aligned but the other is
- register const quint16 *e = sa.w + length;
- for ( ; sa.w != e; ++sa.w, ++sb.w) {
- if (*sa.w != *sb.w)
- return false;
- }
- }
- return true;
-}
-
-// Unicode stuff
-static inline bool isUnicodeNonCharacter(uint ucs4)
-{
- // Unicode has a couple of "non-characters" that one can use internally,
- // but are not allowed to be used for text interchange.
- //
- // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF,
- // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and
- // U+FDEF (inclusive)
-
- return (ucs4 & 0xfffe) == 0xfffe
- || (ucs4 - 0xfdd0U) < 16;
-}
-
-static int utf8LengthFromUtf16(const QChar *uc, int len)
-{
- int length = 0;
-
- int surrogate_high = -1;
-
- const QChar *ch = uc;
- int invalid = 0;
-
- const QChar *end = ch + len;
- while (ch < end) {
- uint u = ch->unicode();
- if (surrogate_high >= 0) {
- if (u >= 0xdc00 && u < 0xe000) {
- u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000;
- surrogate_high = -1;
- } else {
- // high surrogate without low
- ++ch;
- ++invalid;
- surrogate_high = -1;
- continue;
- }
- } else if (u >= 0xdc00 && u < 0xe000) {
- // low surrogate without high
- ++ch;
- ++invalid;
- continue;
- } else if (u >= 0xd800 && u < 0xdc00) {
- surrogate_high = u;
- ++ch;
- continue;
- }
-
- if (u < 0x80) {
- ++length;
- } else {
- if (u < 0x0800) {
- ++length;
- } else {
- // is it one of the Unicode non-characters?
- if (isUnicodeNonCharacter(u)) {
- ++length;
- ++ch;
- ++invalid;
- continue;
- }
-
- if (u > 0xffff) {
- ++length;
- ++length;
- } else {
- ++length;
- }
- ++length;
- }
- ++length;
- }
- ++ch;
- }
-
- return length;
-}
-
-// Writes the utf8 version of uc to output. uc is of length len.
-// There must be at least utf8LengthFromUtf16(uc, len) bytes in output.
-// A null terminator is not written.
-static void utf8FromUtf16(char *output, const QChar *uc, int len)
-{
- uchar replacement = '?';
- int surrogate_high = -1;
-
- uchar* cursor = (uchar*)output;
- const QChar *ch = uc;
- int invalid = 0;
-
- const QChar *end = ch + len;
- while (ch < end) {
- uint u = ch->unicode();
- if (surrogate_high >= 0) {
- if (u >= 0xdc00 && u < 0xe000) {
- u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000;
- surrogate_high = -1;
- } else {
- // high surrogate without low
- *cursor = replacement;
- ++ch;
- ++invalid;
- surrogate_high = -1;
- continue;
- }
- } else if (u >= 0xdc00 && u < 0xe000) {
- // low surrogate without high
- *cursor = replacement;
- ++ch;
- ++invalid;
- continue;
- } else if (u >= 0xd800 && u < 0xdc00) {
- surrogate_high = u;
- ++ch;
- continue;
- }
-
- if (u < 0x80) {
- *cursor++ = (uchar)u;
- } else {
- if (u < 0x0800) {
- *cursor++ = 0xc0 | ((uchar) (u >> 6));
- } else {
- // is it one of the Unicode non-characters?
- if (isUnicodeNonCharacter(u)) {
- *cursor++ = replacement;
- ++ch;
- ++invalid;
- continue;
- }
-
- if (u > 0xffff) {
- *cursor++ = 0xf0 | ((uchar) (u >> 18));
- *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f);
- } else {
- *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f);
- }
- *cursor++ = 0x80 | (((uchar) (u >> 6)) & 0x3f);
- }
- *cursor++ = 0x80 | ((uchar) (u&0x3f));
- }
- ++ch;
- }
-}
-
-void QHashedStringRef::computeUtf8Length() const
-{
- if (m_length)
- m_utf8length = utf8LengthFromUtf16(m_data, m_length);
- else
- m_utf8length = 0;
-}
-
-QHashedStringRef QHashedStringRef::mid(int offset, int length) const
-{
- Q_ASSERT(offset < m_length);
- return QHashedStringRef(m_data + offset,
- (length == -1 || (offset + length) > m_length)?(m_length - offset):length);
-}
-
-bool QHashedStringRef::endsWith(const QString &s) const
-{
- return s.length() < m_length &&
- QHashedString::compare(s.constData(), m_data + m_length - s.length(), s.length());
-}
-
-bool QHashedStringRef::startsWith(const QString &s) const
-{
- return s.length() < m_length &&
- QHashedString::compare(s.constData(), m_data, s.length());
-}
-
-QString QHashedStringRef::toString() const
-{
- if (m_length == 0)
- return QString();
- return QString(m_data, m_length);
-}
-
-QByteArray QHashedStringRef::toUtf8() const
-{
- if (m_length == 0)
- return QByteArray();
-
- QByteArray result;
- result.resize(utf8length());
- writeUtf8(result.data());
- return result;
-}
-
-void QHashedStringRef::writeUtf8(char *output) const
-{
- if (m_length) {
- int ulen = utf8length();
- if (ulen == m_length) {
- // Must be a latin1 string
- uchar *o = (uchar *)output;
- const QChar *c = m_data;
- while (ulen--)
- *o++ = (uchar)((*c++).unicode());
- } else {
- utf8FromUtf16(output, m_data, m_length);
- }
- }
-}
-
-QString QHashedCStringRef::toUtf16() const
-{
- if (m_length == 0)
- return QString();
-
- QString rv;
- rv.resize(m_length);
- writeUtf16((uint16_t*)rv.data());
- return rv;
-}
-
diff --git a/src/declarative/qml/ftw/qhashedstring_p.h b/src/declarative/qml/ftw/qhashedstring_p.h
deleted file mode 100644
index b778dd4df2..0000000000
--- a/src/declarative/qml/ftw/qhashedstring_p.h
+++ /dev/null
@@ -1,1418 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QHASHEDSTRING_P_H
-#define QHASHEDSTRING_P_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/qstring.h>
-#include <private/qv8_p.h>
-
-#include <private/qflagpointer_p.h>
-
-QT_BEGIN_NAMESPACE
-
-// Enable this to debug hash linking assumptions.
-// #define QSTRINGHASH_LINK_DEBUG
-
-class QHashedStringRef;
-class Q_AUTOTEST_EXPORT QHashedString : public QString
-{
-public:
- inline QHashedString();
- inline QHashedString(const QString &string);
- inline QHashedString(const QString &string, quint32);
- inline QHashedString(const QHashedString &string);
-
- inline QHashedString &operator=(const QHashedString &string);
- inline bool operator==(const QHashedString &string) const;
- inline bool operator==(const QHashedStringRef &string) const;
-
- inline quint32 hash() const;
- inline quint32 existingHash() const;
-
- static inline bool isUpper(const QChar &);
-
- static bool compare(const QChar *lhs, const QChar *rhs, int length);
- static inline bool compare(const QChar *lhs, const char *rhs, int length);
- static inline bool compare(const char *lhs, const char *rhs, int length);
-private:
- friend class QHashedStringRef;
- friend class QStringHashNode;
-
- void computeHash() const;
- mutable quint32 m_hash;
-};
-
-class Q_AUTOTEST_EXPORT QHashedV8String
-{
-public:
- inline QHashedV8String();
- explicit inline QHashedV8String(v8::Handle<v8::String>);
- inline QHashedV8String(const QHashedV8String &string);
- inline QHashedV8String &operator=(const QHashedV8String &other);
-
- inline bool operator==(const QHashedV8String &string);
-
- inline quint32 hash() const;
- inline int length() const;
- inline quint32 symbolId() const;
-
- inline v8::Handle<v8::String> string() const;
-
- inline QString toString() const;
-
-private:
- v8::String::CompleteHashData m_hash;
- v8::Handle<v8::String> m_string;
-};
-
-class QHashedCStringRef;
-class Q_AUTOTEST_EXPORT QHashedStringRef
-{
-public:
- inline QHashedStringRef();
- inline QHashedStringRef(const QString &);
- inline QHashedStringRef(const QStringRef &);
- inline QHashedStringRef(const QChar *, int);
- inline QHashedStringRef(const QChar *, int, quint32);
- inline QHashedStringRef(const QHashedString &);
- inline QHashedStringRef(const QHashedStringRef &);
- inline QHashedStringRef &operator=(const QHashedStringRef &);
-
- inline bool operator==(const QString &string) const;
- inline bool operator==(const QHashedString &string) const;
- inline bool operator==(const QHashedStringRef &string) const;
- inline bool operator==(const QHashedCStringRef &string) const;
- inline bool operator!=(const QString &string) const;
- inline bool operator!=(const QHashedString &string) const;
- inline bool operator!=(const QHashedStringRef &string) const;
- inline bool operator!=(const QHashedCStringRef &string) const;
-
- inline quint32 hash() const;
-
- inline const QChar &at(int) const;
- inline const QChar *constData() const;
- bool startsWith(const QString &) const;
- bool endsWith(const QString &) const;
- QHashedStringRef mid(int, int) const;
-
- inline bool isEmpty() const;
- inline int length() const;
- inline bool startsWithUpper() const;
-
- QString toString() const;
-
- inline int utf8length() const;
- QByteArray toUtf8() const;
- void writeUtf8(char *) const;
-private:
- friend class QHashedString;
-
- void computeHash() const;
- void computeUtf8Length() const;
-
- const QChar *m_data;
- int m_length;
- mutable int m_utf8length;
- mutable quint32 m_hash;
-};
-
-class Q_AUTOTEST_EXPORT QHashedCStringRef
-{
-public:
- inline QHashedCStringRef();
- inline QHashedCStringRef(const char *, int);
- inline QHashedCStringRef(const char *, int, quint32);
- inline QHashedCStringRef(const QHashedCStringRef &);
-
- inline quint32 hash() const;
-
- inline const char *constData() const;
- inline int length() const;
-
- QString toUtf16() const;
- inline int utf16length() const;
- inline void writeUtf16(QChar *) const;
- inline void writeUtf16(uint16_t *) const;
-private:
- friend class QHashedStringRef;
-
- void computeHash() const;
-
- const char *m_data;
- int m_length;
- mutable quint32 m_hash;
-};
-
-class QStringHashData;
-class Q_AUTOTEST_EXPORT QStringHashNode
-{
-public:
- QStringHashNode()
- : length(0), hash(0), symbolId(0), ckey(0)
- {
- }
-
- QStringHashNode(const QHashedString &key)
- : length(key.length()), hash(key.hash()), symbolId(0)
- {
- strData = const_cast<QHashedString &>(key).data_ptr();
- setQString(true);
- strData->ref.ref();
- }
-
- QStringHashNode(const QHashedCStringRef &key)
- : length(key.length()), hash(key.hash()), symbolId(0), ckey(key.constData())
- {
- }
-
- QStringHashNode(const QStringHashNode &o)
- : length(o.length), hash(o.hash), symbolId(o.symbolId), ckey(o.ckey)
- {
- setQString(o.isQString());
- if (isQString()) { strData->ref.ref(); }
- }
-
- ~QStringHashNode()
- {
- if (isQString()) { if (!strData->ref.deref()) free(strData); }
- }
-
- QFlagPointer<QStringHashNode> next;
-
- qint32 length;
- quint32 hash;
- quint32 symbolId;
-
- union {
- const char *ckey;
- QStringData *strData;
- };
-
- bool isQString() const { return next.flag(); }
- void setQString(bool v) { if (v) next.setFlag(); else next.clearFlag(); }
-
- inline char *cStrData() const { return (char *)ckey; }
- inline uint16_t *utf16Data() const { return (uint16_t *)strData->data(); }
-
- inline bool equals(v8::Handle<v8::String> string) {
- return isQString()?string->Equals(utf16Data(), length):
- string->Equals(cStrData(), length);
- }
-
- inline bool symbolEquals(const QHashedV8String &string) {
- Q_ASSERT(string.symbolId() != 0);
- return length == string.length() && hash == string.hash() &&
- (string.symbolId() == symbolId || equals(string.string()));
- }
-
- inline bool equals(const QHashedV8String &string) {
- return length == string.length() && hash == string.hash() &&
- equals(string.string());
- }
-
- inline bool equals(const QHashedStringRef &string) {
- return length == string.length() &&
- hash == string.hash() &&
- (isQString()?QHashedString::compare(string.constData(), (QChar *)utf16Data(), length):
- QHashedString::compare(string.constData(), cStrData(), length));
- }
-
- inline bool equals(const QHashedCStringRef &string) {
- return length == string.length() &&
- hash == string.hash() &&
- (isQString()?QHashedString::compare((QChar *)utf16Data(), string.constData(), length):
- QHashedString::compare(string.constData(), cStrData(), length));
- }
-};
-
-class Q_AUTOTEST_EXPORT QStringHashData
-{
-public:
- QStringHashData()
- : buckets(0), numBuckets(0), size(0), numBits(0)
-#ifdef QSTRINGHASH_LINK_DEBUG
- , linkCount(0)
-#endif
- {}
-
- QStringHashNode **buckets;
- int numBuckets;
- int size;
- short numBits;
-#ifdef QSTRINGHASH_LINK_DEBUG
- int linkCount;
-#endif
-
- struct IteratorData {
- IteratorData() : n(0), p(0) {}
- QStringHashNode *n;
- void *p;
- };
- void rehashToBits(short, IteratorData, IteratorData (*Iterate)(const IteratorData &),
- QStringHashNode *skip = 0);
- void rehashToSize(int, IteratorData, IteratorData (*Iterate)(const IteratorData &),
- QStringHashNode *skip = 0);
-
-private:
- QStringHashData(const QStringHashData &);
- QStringHashData &operator=(const QStringHashData &);
-};
-
-template<class T>
-class QStringHash
-{
-public:
- struct Node : public QStringHashNode {
- Node(const QHashedString &key, const T &value) : QStringHashNode(key), value(value) {}
- Node(const QHashedCStringRef &key, const T &value) : QStringHashNode(key), value(value) {}
- Node(const Node &o) : QStringHashNode(o), value(o.value) {}
- Node() {}
- T value;
- };
- struct NewedNode : public Node {
- NewedNode(const QHashedString &key, const T &value) : Node(key, value), nextNewed(0) {}
- NewedNode(const QHashedCStringRef &key, const T &value) : Node(key, value), nextNewed(0) {}
- NewedNode(const Node &o) : Node(o), nextNewed(0) {}
- NewedNode *nextNewed;
- };
- struct ReservedNodePool
- {
- ReservedNodePool() : count(0), used(0), nodes(0) {}
- ~ReservedNodePool() { delete [] nodes; }
- int count;
- int used;
- Node *nodes;
- };
-
- QStringHashData data;
- NewedNode *newedNodes;
- ReservedNodePool *nodePool;
- const QStringHash<T> *link;
-
- inline Node *findNode(const QString &) const;
- inline Node *findNode(const QHashedString &) const;
- inline Node *findNode(const QHashedStringRef &) const;
- inline Node *findNode(const QHashedCStringRef &) const;
- inline Node *findNode(const QHashedV8String &) const;
- inline Node *findSymbolNode(const QHashedV8String &) const;
- inline Node *createNode(const Node &o);
- inline Node *createNode(const QHashedString &, const T &);
- inline Node *createNode(const QHashedCStringRef &, const T &);
-
- inline Node *takeNode(const QHashedString &key, const T &value);
- inline Node *takeNode(const QHashedCStringRef &key, const T &value);
- inline Node *takeNode(const Node &o);
-
- inline void copy(const QStringHash<T> &);
-
- inline QStringHashData::IteratorData iterateFirst() const;
- static inline QStringHashData::IteratorData iterateNext(const QStringHashData::IteratorData &);
-
-public:
- inline QStringHash();
- inline QStringHash(const QStringHash &);
- inline ~QStringHash();
-
- QStringHash &operator=(const QStringHash<T> &);
-
- void copyAndReserve(const QStringHash<T> &other, int additionalReserve);
- void linkAndReserve(const QStringHash<T> &other, int additionalReserve);
-
- inline bool isEmpty() const;
- inline void clear();
- inline int count() const;
-
- inline int numBuckets() const;
- inline bool isLinked() const;
-
- class ConstIterator {
- public:
- inline ConstIterator();
- inline ConstIterator(const QStringHashData::IteratorData &);
-
- inline ConstIterator &operator++();
-
- inline bool operator==(const ConstIterator &o) const;
- inline bool operator!=(const ConstIterator &o) const;
-
- inline QHashedString key() const;
- inline const T &value() const;
- inline const T &operator*() const;
-
- inline Node *node() const;
- private:
- QStringHashData::IteratorData d;
- };
-
- inline void insert(const QString &, const T &);
- inline void insert(const QHashedString &, const T &);
- inline void insert(const QHashedStringRef &, const T &);
- inline void insert(const QHashedCStringRef &, const T &);
- inline void insert(const ConstIterator &);
-
- inline T *value(const QString &) const;
- inline T *value(const QHashedString &) const;
- inline T *value(const QHashedStringRef &) const;
- inline T *value(const QHashedV8String &) const;
- inline T *value(const QHashedCStringRef &) const;
- inline T *value(const ConstIterator &) const;
-
- inline bool contains(const QString &) const;
- inline bool contains(const QHashedString &) const;
- inline bool contains(const QHashedStringRef &) const;
- inline bool contains(const QHashedCStringRef &) const;
- inline bool contains(const ConstIterator &) const;
-
- inline T &operator[](const QString &);
- inline T &operator[](const QHashedString &);
- inline T &operator[](const QHashedStringRef &);
- inline T &operator[](const QHashedCStringRef &);
-
- inline ConstIterator begin() const;
- inline ConstIterator end() const;
-
- inline void reserve(int);
-};
-
-template<class T>
-QStringHash<T>::QStringHash()
-: newedNodes(0), nodePool(0), link(0)
-{
-}
-
-template<class T>
-QStringHash<T>::QStringHash(const QStringHash<T> &other)
-: newedNodes(0), nodePool(0), link(0)
-{
- data.numBits = other.data.numBits;
- data.size = other.data.size;
- reserve(other.count());
- copy(other);
-}
-
-template<class T>
-QStringHash<T> &QStringHash<T>::operator=(const QStringHash<T> &other)
-{
- if (&other == this)
- return *this;
-
- clear();
-
- data.numBits = other.data.numBits;
- data.size = other.data.size;
- reserve(other.count());
- copy(other);
-
- return *this;
-}
-
-template<class T>
-void QStringHash<T>::copyAndReserve(const QStringHash<T> &other, int additionalReserve)
-{
- clear();
- data.numBits = other.data.numBits;
- reserve(other.count() + additionalReserve);
- copy(other);
-}
-
-template<class T>
-void QStringHash<T>::linkAndReserve(const QStringHash<T> &other, int additionalReserve)
-{
- clear();
-
- if (other.count()) {
- data.size = other.data.size;
- data.rehashToSize(other.count() + additionalReserve, iterateFirst(), iterateNext);
-
- if (data.numBuckets == other.data.numBuckets) {
- nodePool = new ReservedNodePool;
- nodePool->count = additionalReserve;
- nodePool->used = 0;
- nodePool->nodes = new Node[additionalReserve];
-
-#ifdef QSTRINGHASH_LINK_DEBUG
- data.linkCount++;
- const_cast<QStringHash<T>&>(other).data.linkCount++;
-#endif
-
- for (int ii = 0; ii < data.numBuckets; ++ii) {
- data.buckets[ii] = 0;
- Node *n = (Node *)other.data.buckets[ii];
- data.buckets[ii] = n;
- }
-
- link = &other;
- return;
- }
-
- data.size = 0;
- }
-
- data.numBits = other.data.numBits;
- reserve(other.count() + additionalReserve);
- copy(other);
-}
-
-template<class T>
-QStringHash<T>::~QStringHash()
-{
- clear();
-}
-
-template<class T>
-void QStringHash<T>::clear()
-{
-#ifdef QSTRINGHASH_LINK_DEBUG
- if (link) {
- data.linkCount--;
- const_cast<QStringHash<T> *>(link)->data.linkCount--;
- }
-
- if (data.linkCount)
- qFatal("QStringHash: Illegal attempt to clear a linked hash.");
-#endif
-
- // Delete the individually allocated nodes
- NewedNode *n = newedNodes;
- while (n) {
- NewedNode *c = n;
- n = c->nextNewed;
- delete c;
- }
- // Delete the pool allocated nodes
- if (nodePool) delete nodePool;
- delete [] data.buckets;
-
- data.buckets = 0;
- data.numBuckets = 0;
- data.numBits = 0;
- data.size = 0;
-
- newedNodes = 0;
- nodePool = 0;
- link = 0;
-}
-
-template<class T>
-bool QStringHash<T>::isEmpty() const
-{
- return data.size== 0;
-}
-
-template<class T>
-int QStringHash<T>::count() const
-{
- return data.size;
-}
-
-template<class T>
-int QStringHash<T>::numBuckets() const
-{
- return data.numBuckets;
-}
-
-template<class T>
-bool QStringHash<T>::isLinked() const
-{
- return link != 0;
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::takeNode(const QHashedString &key, const T &value)
-{
- if (nodePool && nodePool->used != nodePool->count) {
- Node *rv = nodePool->nodes + nodePool->used++;
- rv->length = key.length();
- rv->hash = key.hash();
- rv->strData = const_cast<QHashedString &>(key).data_ptr();
- rv->strData->ref.ref();
- rv->setQString(true);
- rv->value = value;
- return rv;
- } else {
- NewedNode *rv = new NewedNode(key, value);
- rv->nextNewed = newedNodes;
- newedNodes = rv;
- return rv;
- }
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::takeNode(const QHashedCStringRef &key, const T &value)
-{
- if (nodePool && nodePool->used != nodePool->count) {
- Node *rv = nodePool->nodes + nodePool->used++;
- rv->length = key.length();
- rv->hash = key.hash();
- rv->ckey = key.constData();
- rv->value = value;
- return rv;
- } else {
- NewedNode *rv = new NewedNode(key, value);
- rv->nextNewed = newedNodes;
- newedNodes = rv;
- return rv;
- }
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::takeNode(const Node &o)
-{
- if (nodePool && nodePool->used != nodePool->count) {
- Node *rv = nodePool->nodes + nodePool->used++;
- rv->length = o.length;
- rv->hash = o.hash;
- if (o.isQString()) {
- rv->strData = o.strData;
- rv->strData->ref.ref();
- rv->setQString(true);
- } else {
- rv->ckey = o.ckey;
- }
- rv->symbolId = o.symbolId;
- rv->value = o.value;
- return rv;
- } else {
- NewedNode *rv = new NewedNode(o);
- rv->nextNewed = newedNodes;
- newedNodes = rv;
- return rv;
- }
-}
-
-template<class T>
-void QStringHash<T>::copy(const QStringHash<T> &other)
-{
- Q_ASSERT(data.size == 0);
-
- data.size = other.data.size;
-
- // Ensure buckets array is created
- data.rehashToBits(data.numBits, iterateFirst(), iterateNext);
-
- if (other.link) {
- for (ConstIterator iter = other.begin(); iter != other.end(); ++iter) {
- Node *o = iter.node();
- Node *n = o->isQString()?findNode(QHashedStringRef((QChar *)o->strData->data(), o->length, o->hash)):
- findNode(QHashedCStringRef(o->ckey, o->length, o->hash));
- if (!n) {
- Node *mynode = takeNode(*o);
- int bucket = mynode->hash % data.numBuckets;
- mynode->next = data.buckets[bucket];
- data.buckets[bucket] = mynode;
- }
- }
- } else {
- for (ConstIterator iter = other.begin(); iter != other.end(); ++iter) {
- Node *o = iter.node();
- Node *mynode = takeNode(*o);
- int bucket = mynode->hash % data.numBuckets;
- mynode->next = data.buckets[bucket];
- data.buckets[bucket] = mynode;
- }
- }
-}
-
-template<class T>
-QStringHashData::IteratorData
-QStringHash<T>::iterateNext(const QStringHashData::IteratorData &d)
-{
- QStringHash<T> *This = (QStringHash<T> *)d.p;
- Node *node = (Node *)d.n;
-
- if (This->nodePool && node >= This->nodePool->nodes &&
- node < (This->nodePool->nodes + This->nodePool->used)) {
- node--;
- if (node < This->nodePool->nodes)
- node = 0;
- } else {
- NewedNode *nn = (NewedNode *)node;
- node = nn->nextNewed;
-
- if (node == 0 && This->nodePool && This->nodePool->used)
- node = This->nodePool->nodes + This->nodePool->used - 1;
- }
-
- if (node == 0 && This->link)
- return This->link->iterateFirst();
-
- QStringHashData::IteratorData rv;
- rv.n = node;
- rv.p = d.p;
- return rv;
-}
-
-template<class T>
-QStringHashData::IteratorData QStringHash<T>::iterateFirst() const
-{
- Node *n = 0;
- if (newedNodes)
- n = newedNodes;
- else if (nodePool && nodePool->used)
- n = nodePool->nodes + nodePool->used - 1;
-
- if (n == 0 && link)
- return link->iterateFirst();
-
- QStringHashData::IteratorData rv;
- rv.n = n;
- rv.p = const_cast<QStringHash<T> *>(this);
- return rv;
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::createNode(const Node &o)
-{
- Node *n = takeNode(o);
-
- if (data.size >= data.numBuckets)
- data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n);
-
- int bucket = n->hash % data.numBuckets;
- n->next = data.buckets[bucket];
- data.buckets[bucket] = n;
-
- data.size++;
-
- return n;
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::createNode(const QHashedString &key, const T &value)
-{
- Node *n = takeNode(key, value);
-
- if (data.size >= data.numBuckets)
- data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n);
-
- int bucket = key.hash() % data.numBuckets;
- n->next = data.buckets[bucket];
- data.buckets[bucket] = n;
-
- data.size++;
-
- return n;
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::createNode(const QHashedCStringRef &key, const T &value)
-{
- Node *n = takeNode(key, value);
-
- if (data.size >= data.numBuckets)
- data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n);
-
- int bucket = key.hash() % data.numBuckets;
- n->next = data.buckets[bucket];
- data.buckets[bucket] = n;
-
- data.size++;
-
- return n;
-}
-
-template<class T>
-void QStringHash<T>::insert(const QString &key, const T &value)
-{
- QHashedStringRef ch(key);
- // If this is a linked hash, we can't rely on owning the node, so we always
- // create a new one.
- Node *n = link?0:findNode(key);
- if (n) n->value = value;
- else createNode(QHashedString(key, ch.hash()), value);
-}
-
-template<class T>
-void QStringHash<T>::insert(const QHashedString &key, const T &value)
-{
- // If this is a linked hash, we can't rely on owning the node, so we always
- // create a new one.
- Node *n = link?0:findNode(key);
- if (n) n->value = value;
- else createNode(key, value);
-}
-
-template<class T>
-void QStringHash<T>::insert(const QHashedStringRef &key, const T &value)
-{
- // If this is a linked hash, we can't rely on owning the node, so we always
- // create a new one.
- Node *n = link?0:findNode(key);
- if (n) n->value = value;
- else createNode(key, value);
-}
-
-template<class T>
-void QStringHash<T>::insert(const QHashedCStringRef &key, const T &value)
-{
- // If this is a linked hash, we can't rely on owning the node, so we always
- // create a new one.
- Node *n = link?0:findNode(key);
- if (n) n->value = value;
- else createNode(key, value);
-}
-
-template<class T>
-void QStringHash<T>::insert(const ConstIterator &key)
-{
- // If this is a linked hash, we can't rely on owning the node, so we always
- // create a new one.
- if (key.node()->isQString()) {
- QHashedStringRef str((QChar *)key.node()->strData->data(), key.node()->length,
- key.node()->hash);
-
- Node *n = link?0:findNode(str);
- if (n) n->value = key.node()->value;
- else createNode(*key.node());
- } else {
- QHashedCStringRef str(key.node()->ckey, key.node()->length, key.node()->hash);
-
- Node *n = link?0:findNode(str);
- if (n) n->value = key.node()->value;
- else createNode(str, key.node()->value);
- }
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::findNode(const QString &string) const
-{
- return findNode(QHashedStringRef(string));
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedString &string) const
-{
- return findNode(QHashedStringRef(string.constData(), string.length(), string.hash()));
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedStringRef &string) const
-{
- QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0;
- while (node && !node->equals(string))
- node = (*node->next);
-
- return (Node *)node;
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedCStringRef &string) const
-{
- QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0;
- while (node && !node->equals(string))
- node = (*node->next);
-
- return (Node *)node;
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedV8String &string) const
-{
- QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0;
- while (node && !node->equals(string))
- node = (*node->next);
-
- return (Node *)node;
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::findSymbolNode(const QHashedV8String &string) const
-{
- Q_ASSERT(string.symbolId() != 0);
-
- QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0;
- while (node && !node->symbolEquals(string))
- node = (*node->next);
-
- if (node)
- node->symbolId = string.symbolId();
-
- return (Node *)node;
-}
-
-template<class T>
-T *QStringHash<T>::value(const QString &key) const
-{
- Node *n = findNode(key);
- return n?&n->value:0;
-}
-
-template<class T>
-T *QStringHash<T>::value(const QHashedString &key) const
-{
- Node *n = findNode(key);
- return n?&n->value:0;
-}
-
-template<class T>
-T *QStringHash<T>::value(const QHashedStringRef &key) const
-{
- Node *n = findNode(key);
- return n?&n->value:0;
-}
-
-template<class T>
-T *QStringHash<T>::value(const QHashedCStringRef &key) const
-{
- Node *n = findNode(key);
- return n?&n->value:0;
-}
-
-template<class T>
-T *QStringHash<T>::value(const ConstIterator &iter) const
-{
- Node *n = iter.node();
- if (n->isQString())
- return value(QHashedStringRef((QChar *)n->strData->data(), n->length, n->hash));
- else
- return value(QHashedCStringRef(n->ckey, n->length, n->hash));
-}
-
-template<class T>
-T *QStringHash<T>::value(const QHashedV8String &string) const
-{
- Node *n = string.symbolId()?findSymbolNode(string):findNode(string);
- return n?&n->value:0;
-}
-
-template<class T>
-bool QStringHash<T>::contains(const QString &s) const
-{
- return 0 != value(s);
-}
-
-template<class T>
-bool QStringHash<T>::contains(const QHashedString &s) const
-{
- return 0 != value(s);
-}
-
-template<class T>
-bool QStringHash<T>::contains(const QHashedStringRef &s) const
-{
- return 0 != value(s);
-}
-
-template<class T>
-bool QStringHash<T>::contains(const QHashedCStringRef &s) const
-{
- return 0 != value(s);
-}
-
-template<class T>
-bool QStringHash<T>::contains(const ConstIterator &s) const
-{
- return 0 != value(s);
-}
-
-template<class T>
-T &QStringHash<T>::operator[](const QString &key)
-{
- QHashedStringRef cs(key);
- Node *n = findNode(cs);
- if (n) return n->value;
- else return createNode(QHashedString(key, cs.hash()), T())->value;
-}
-
-template<class T>
-T &QStringHash<T>::operator[](const QHashedString &key)
-{
- Node *n = findNode(key);
- if (n) return n->value;
- else return createNode(key, T())->value;
-}
-
-template<class T>
-T &QStringHash<T>::operator[](const QHashedStringRef &key)
-{
- Node *n = findNode(key);
- if (n) return n->value;
- else return createNode(key, T())->value;
-}
-
-template<class T>
-T &QStringHash<T>::operator[](const QHashedCStringRef &key)
-{
- Node *n = findNode(key);
- if (n) return n->value;
- else return createNode(key, T())->value;
-}
-
-template<class T>
-void QStringHash<T>::reserve(int n)
-{
- if (nodePool || 0 == n)
- return;
-
- nodePool = new ReservedNodePool;
- nodePool->count = n;
- nodePool->used = 0;
- nodePool->nodes = new Node[n];
-
- data.rehashToSize(n, iterateFirst(), iterateNext);
-}
-
-template<class T>
-QStringHash<T>::ConstIterator::ConstIterator()
-{
-}
-
-template<class T>
-QStringHash<T>::ConstIterator::ConstIterator(const QStringHashData::IteratorData &d)
-: d(d)
-{
-}
-
-template<class T>
-typename QStringHash<T>::ConstIterator &QStringHash<T>::ConstIterator::operator++()
-{
- d = QStringHash<T>::iterateNext(d);
- return *this;
-}
-
-template<class T>
-bool QStringHash<T>::ConstIterator::operator==(const ConstIterator &o) const
-{
- return d.n == o.d.n;
-}
-
-template<class T>
-bool QStringHash<T>::ConstIterator::operator!=(const ConstIterator &o) const
-{
- return d.n != o.d.n;
-}
-
-template<class T>
-QHashedString QStringHash<T>::ConstIterator::key() const
-{
- Node *n = (Node *)d.n;
- if (n->isQString()) {
- return QHashedString(QString((QChar *)n->strData->data(), n->length), n->hash);
- } else {
- return QHashedString(QString::fromLatin1(n->ckey, n->length), n->hash);
- }
-}
-template<class T>
-const T &QStringHash<T>::ConstIterator::value() const
-{
- Node *n = (Node *)d.n;
- return n->value;
-}
-
-template<class T>
-const T &QStringHash<T>::ConstIterator::operator*() const
-{
- Node *n = (Node *)d.n;
- return n->value;
-}
-
-template<class T>
-typename QStringHash<T>::Node *QStringHash<T>::ConstIterator::node() const
-{
- Node *n = (Node *)d.n;
- return n;
-}
-
-template<class T>
-typename QStringHash<T>::ConstIterator QStringHash<T>::begin() const
-{
- return ConstIterator(iterateFirst());
-}
-
-template<class T>
-typename QStringHash<T>::ConstIterator QStringHash<T>::end() const
-{
- return ConstIterator();
-}
-
-inline uint qHash(const QHashedString &string)
-{
- return uint(string.hash());
-}
-
-inline uint qHash(const QHashedStringRef &string)
-{
- return uint(string.hash());
-}
-
-QHashedString::QHashedString()
-: QString(), m_hash(0)
-{
-}
-
-QHashedString::QHashedString(const QString &string)
-: QString(string), m_hash(0)
-{
-}
-
-QHashedString::QHashedString(const QString &string, quint32 hash)
-: QString(string), m_hash(hash)
-{
-}
-
-QHashedString::QHashedString(const QHashedString &string)
-: QString(string), m_hash(string.m_hash)
-{
-}
-
-QHashedString &QHashedString::operator=(const QHashedString &string)
-{
- static_cast<QString &>(*this) = string;
- m_hash = string.m_hash;
- return *this;
-}
-
-bool QHashedString::operator==(const QHashedString &string) const
-{
- return (string.m_hash == m_hash || !string.m_hash || !m_hash) &&
- static_cast<const QString &>(*this) == static_cast<const QString &>(string);
-}
-
-bool QHashedString::operator==(const QHashedStringRef &string) const
-{
- return length() == string.m_length &&
- (string.m_hash == m_hash || !string.m_hash || !m_hash) &&
- QHashedString::compare(constData(), string.m_data, string.m_length);
-}
-
-quint32 QHashedString::hash() const
-{
- if (!m_hash) computeHash();
- return m_hash;
-}
-
-quint32 QHashedString::existingHash() const
-{
- return m_hash;
-}
-
-bool QHashedString::isUpper(const QChar &qc)
-{
- ushort c = qc.unicode();
- // Optimize for _, a-z and A-Z.
- return ((c != '_' ) && (!(c >= 'a' && c <= 'z')) &&
- ((c >= 'A' && c <= 'Z') || QChar::category(c) == QChar::Letter_Uppercase));
-}
-
-QHashedV8String::QHashedV8String()
-{
-}
-
-QHashedV8String::QHashedV8String(v8::Handle<v8::String> string)
-: m_hash(string->CompleteHash()), m_string(string)
-{
- Q_ASSERT(!m_string.IsEmpty());
-}
-
-QHashedV8String::QHashedV8String(const QHashedV8String &string)
-: m_hash(string.m_hash), m_string(string.m_string)
-{
-}
-
-QHashedV8String &QHashedV8String::operator=(const QHashedV8String &other)
-{
- m_hash = other.m_hash;
- m_string = other.m_string;
- return *this;
-}
-
-bool QHashedV8String::operator==(const QHashedV8String &string)
-{
- return m_hash.hash == string.m_hash.hash && m_hash.length == string.m_hash.length &&
- m_string.IsEmpty() == m_string.IsEmpty() &&
- (m_string.IsEmpty() || m_string->StrictEquals(string.m_string));
-}
-
-quint32 QHashedV8String::hash() const
-{
- return m_hash.hash;
-}
-
-int QHashedV8String::length() const
-{
- return m_hash.length;
-}
-
-quint32 QHashedV8String::symbolId() const
-{
- return m_hash.symbol_id;
-}
-
-v8::Handle<v8::String> QHashedV8String::string() const
-{
- return m_string;
-}
-
-QString QHashedV8String::toString() const
-{
- QString result;
- result.reserve(m_hash.length);
-
- for (int i = 0; i < m_hash.length; ++i)
- result.append(m_string->GetCharacter(i));
-
- return result;
-}
-
-QHashedStringRef::QHashedStringRef()
-: m_data(0), m_length(0), m_utf8length(-1), m_hash(0)
-{
-}
-
-QHashedStringRef::QHashedStringRef(const QString &str)
-: m_data(str.constData()), m_length(str.length()), m_utf8length(0), m_hash(0)
-{
-}
-
-QHashedStringRef::QHashedStringRef(const QStringRef &str)
-: m_data(str.constData()), m_length(str.length()), m_utf8length(0), m_hash(0)
-{
-}
-
-QHashedStringRef::QHashedStringRef(const QChar *data, int length)
-: m_data(data), m_length(length), m_utf8length(0), m_hash(0)
-{
-}
-
-QHashedStringRef::QHashedStringRef(const QChar *data, int length, quint32 hash)
-: m_data(data), m_length(length), m_utf8length(0), m_hash(hash)
-{
-}
-
-QHashedStringRef::QHashedStringRef(const QHashedString &string)
-: m_data(string.constData()), m_length(string.length()), m_utf8length(0), m_hash(string.m_hash)
-{
-}
-
-QHashedStringRef::QHashedStringRef(const QHashedStringRef &string)
-: m_data(string.m_data), m_length(string.m_length), m_utf8length(string.m_utf8length),
- m_hash(string.m_hash)
-{
-}
-
-QHashedStringRef &QHashedStringRef::operator=(const QHashedStringRef &o)
-{
- m_data = o.m_data;
- m_length = o.m_length;
- m_utf8length = o.m_utf8length;
- m_hash = o.m_hash;
- return *this;
-}
-
-bool QHashedStringRef::operator==(const QString &string) const
-{
- return m_length == string.length() &&
- QHashedString::compare(string.constData(), m_data, m_length);
-}
-
-bool QHashedStringRef::operator==(const QHashedString &string) const
-{
- return m_length == string.length() &&
- (m_hash == string.m_hash || !m_hash || !string.m_hash) &&
- QHashedString::compare(string.constData(), m_data, m_length);
-}
-
-bool QHashedStringRef::operator==(const QHashedStringRef &string) const
-{
- return m_length == string.m_length &&
- (m_hash == string.m_hash || !m_hash || !string.m_hash) &&
- QHashedString::compare(string.m_data, m_data, m_length);
-}
-
-bool QHashedStringRef::operator==(const QHashedCStringRef &string) const
-{
- return m_length == string.m_length &&
- (m_hash == string.m_hash || !m_hash || !string.m_hash) &&
- QHashedString::compare(m_data, string.m_data, m_length);
-}
-
-bool QHashedStringRef::operator!=(const QString &string) const
-{
- return m_length != string.length() ||
- !QHashedString::compare(string.constData(), m_data, m_length);
-}
-
-bool QHashedStringRef::operator!=(const QHashedString &string) const
-{
- return m_length != string.length() ||
- (m_hash != string.m_hash && m_hash && string.m_hash) ||
- !QHashedString::compare(string.constData(), m_data, m_length);
-}
-
-bool QHashedStringRef::operator!=(const QHashedStringRef &string) const
-{
- return m_length != string.m_length ||
- (m_hash != string.m_hash && m_hash && string.m_hash) ||
- QHashedString::compare(string.m_data, m_data, m_length);
-}
-
-bool QHashedStringRef::operator!=(const QHashedCStringRef &string) const
-{
- return m_length != string.m_length ||
- (m_hash != string.m_hash && m_hash && string.m_hash) ||
- QHashedString::compare(m_data, string.m_data, m_length);
-}
-
-const QChar &QHashedStringRef::at(int index) const
-{
- Q_ASSERT(index < m_length);
- return m_data[index];
-}
-
-const QChar *QHashedStringRef::constData() const
-{
- return m_data;
-}
-
-bool QHashedStringRef::isEmpty() const
-{
- return m_length == 0;
-}
-
-int QHashedStringRef::length() const
-{
- return m_length;
-}
-
-int QHashedStringRef::utf8length() const
-{
- if (m_utf8length < m_length)
- computeUtf8Length();
- return m_utf8length;
-}
-
-bool QHashedStringRef::startsWithUpper() const
-{
- if (m_length < 1) return false;
- return QHashedString::isUpper(m_data[0]);
-}
-
-quint32 QHashedStringRef::hash() const
-{
- if (!m_hash) computeHash();
- return m_hash;
-}
-
-QHashedCStringRef::QHashedCStringRef()
-: m_data(0), m_length(0), m_hash(0)
-{
-}
-
-QHashedCStringRef::QHashedCStringRef(const char *data, int length)
-: m_data(data), m_length(length), m_hash(0)
-{
-}
-
-QHashedCStringRef::QHashedCStringRef(const char *data, int length, quint32 hash)
-: m_data(data), m_length(length), m_hash(hash)
-{
-}
-
-QHashedCStringRef::QHashedCStringRef(const QHashedCStringRef &o)
-: m_data(o.m_data), m_length(o.m_length), m_hash(o.m_hash)
-{
-}
-
-quint32 QHashedCStringRef::hash() const
-{
- if (!m_hash) computeHash();
- return m_hash;
-}
-
-const char *QHashedCStringRef::constData() const
-{
- return m_data;
-}
-
-int QHashedCStringRef::length() const
-{
- return m_length;
-}
-
-int QHashedCStringRef::utf16length() const
-{
- return m_length;
-}
-
-void QHashedCStringRef::writeUtf16(QChar *output) const
-{
- writeUtf16((uint16_t *)output);
-}
-
-void QHashedCStringRef::writeUtf16(uint16_t *output) const
-{
- int l = m_length;
- const char *d = m_data;
- while (l--)
- *output++ = *d++;
-}
-
-bool QHashedString::compare(const QChar *lhs, const char *rhs, int length)
-{
- Q_ASSERT(lhs && rhs);
- const quint16 *l = (const quint16*)lhs;
- while (length--)
- if (*l++ != *rhs++) return false;
- return true;
-}
-
-bool QHashedString::compare(const char *lhs, const char *rhs, int length)
-{
- Q_ASSERT(lhs && rhs);
- return 0 == ::memcmp(lhs, rhs, length);
-}
-
-QT_END_NAMESPACE
-
-#endif // QHASHEDSTRING_P_H
diff --git a/src/declarative/qml/ftw/qhashfield_p.h b/src/declarative/qml/ftw/qhashfield_p.h
deleted file mode 100644
index a11e8d9486..0000000000
--- a/src/declarative/qml/ftw/qhashfield_p.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QHASHFIELD_P_H
-#define QHASHFIELD_P_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>
-
-QT_BEGIN_NAMESPACE
-
-// QHashField can be used for doing coarse grained set testing, in
-// cases where you do not expect the set to contain the item. For
-// example where you would write:
-// QSet<QString> strings;
-// for (int ii = 0; ii < mystrings.count(); ++ii) {
-// if (strings.contains(mystrings.at(ii)))
-// qFatal("Duplication!");
-// strings.insert(mystrings);
-// }
-// You may write:
-// QHashField strings;
-// for (int ii = 0; ii < mystrings.count(); ++ii) {
-// if (strings.testAndSet(qHash(mystrings.at(ii)))) {
-// // The string *might* be duplicated
-// for (int jj = 0; jj < ii; ++jj) {
-// if (mystrings.at(ii) == mystrings.at(jj))
-// qFatal("Duplication!");
-// }
-// }
-// }
-// For small lists of things, where the hash is cheap to calculate
-// and you don't expect duplication this will be much faster.
-class QHashField {
-public:
- inline QHashField();
-
- inline void clear();
-
- inline bool test(quint32 hash);
- inline bool testAndSet(quint32 hash);
-private:
- quint32 m_field;
-};
-
-QHashField::QHashField()
-: m_field(0)
-{
-}
-
-void QHashField::clear()
-{
- m_field = 0;
-}
-
-bool QHashField::test(quint32 hash)
-{
- return m_field & (1 << (hash % 31));
-}
-
-bool QHashField::testAndSet(quint32 hash)
-{
- quint32 mask = 1 << (hash % 31);
- bool rv = m_field & mask;
- m_field |= mask;
- return rv;
-}
-
-QT_END_NAMESPACE
-
-#endif // QHASHFIELD_P_H
diff --git a/src/declarative/qml/ftw/qintrusivelist.cpp b/src/declarative/qml/ftw/qintrusivelist.cpp
deleted file mode 100644
index 1893eef8cd..0000000000
--- a/src/declarative/qml/ftw/qintrusivelist.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qintrusivelist_p.h"
-
-/*!
-\class QIntrusiveList
-\brief The QIntrusiveList class is a template class that provides a list of objects using static storage.
-\internal
-
-QIntrusiveList creates a linked list of objects. Adding and removing objects from the
-QIntrusiveList is a constant time operation and is very quick. The list performs no memory
-allocations, but does require the objects being added to the list to contain a QIntrusiveListNode
-instance for the list's use. Even so, for small lists QIntrusiveList uses less memory than Qt's
-other list classes.
-
-As QIntrusiveList uses storage inside the objects in the list, each object can only be in one
-list at a time. Objects are inserted by the insert() method. If the object is already
-in a list (including the one it is being inserted into) it is first removed, and then inserted
-at the head of the list. QIntrusiveList is a last-in-first-out list. That is, following an
-insert() the inserted object becomes the list's first() object.
-
-\code
-struct MyObject {
- MyObject(int value) : value(value) {}
-
- int value;
- QIntrusiveListNode node;
-};
-typedef QIntrusiveList<MyObject, &MyObject::node> MyObjectList;
-
-void foo() {
- MyObjectList list;
-
- MyObject m0(0);
- MyObject m1(1);
- MyObject m2(2);
-
- list.insert(&m0);
- list.insert(&m1);
- list.insert(&m2);
-
- // QIntrusiveList is LIFO, so will print: 2... 1... 0...
- for (MyObjectList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- qWarning() << iter->value;
- }
-}
-\endcode
-*/
-
-
-/*!
-\fn QIntrusiveList::QIntrusiveList();
-
-Construct an empty list.
-*/
-
-/*!
-\fn QIntrusiveList::~QIntrusiveList();
-
-Destroy the list. All entries are removed.
-*/
-
-/*!
-\fn void QIntrusiveList::insert(N *object);
-
-Insert \a object into the list. If \a object is a member of this, or another list, it will be
-removed and inserted at the head of this list.
-*/
-
-/*!
-\fn void QIntrusiveList::remove(N *object);
-
-Remove \a object from the list. \a object must not be null.
-*/
-
-/*!
-\fn bool QIntrusiveList::contains(N *object) const
-
-Returns true if the list contains \a object; otherwise returns false.
-*/
-
-/*!
-\fn N *QIntrusiveList::first() const
-
-Returns the first entry in this list, or null if the list is empty.
-*/
-
-/*!
-\fn N *QIntrusiveList::next(N *current)
-
-Returns the next object after \a current, or null if \a current is the last object. \a current cannot be null.
-*/
-
-/*!
-\fn iterator QIntrusiveList::begin()
-
-Returns an STL-style interator pointing to the first item in the list.
-
-\sa end()
-*/
-
-/*!
-\fn iterator QIntrusiveList::end()
-
-Returns an STL-style iterator pointing to the imaginary item after the last item in the list.
-
-\sa begin()
-*/
-
-/*!
-iterator &QInplacelist::iterator::erase()
-
-Remove the current object from the list, and return an iterator to the next element.
-*/
-
-
-/*!
-\fn QIntrusiveListNode::QIntrusiveListNode()
-
-Create a QIntrusiveListNode.
-*/
-
-/*!
-\fn QIntrusiveListNode::~QIntrusiveListNode()
-
-Destroy the QIntrusiveListNode. If the node is in a list, it is removed.
-*/
-
-/*!
-\fn void QIntrusiveListNode::remove()
-
-If in a list, remove this node otherwise do nothing.
-*/
-
-/*!
-\fn bool QIntrusiveListNode::isInList() const
-
-Returns true if this node is in a list, false otherwise.
-*/
-
diff --git a/src/declarative/qml/ftw/qintrusivelist_p.h b/src/declarative/qml/ftw/qintrusivelist_p.h
deleted file mode 100644
index fb7524c6ab..0000000000
--- a/src/declarative/qml/ftw/qintrusivelist_p.h
+++ /dev/null
@@ -1,274 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QINTRUSIVELIST_P_H
-#define QINTRUSIVELIST_P_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>
-
-QT_BEGIN_NAMESPACE
-
-class QIntrusiveListNode;
-template<class N, QIntrusiveListNode N::*member>
-class QIntrusiveList
-{
-public:
- inline QIntrusiveList();
- inline ~QIntrusiveList();
-
- inline bool isEmpty() const;
- inline void insert(N *n);
- inline void remove(N *n);
- inline bool contains(N *) const;
-
- class iterator {
- public:
- inline iterator();
- inline iterator(N *value);
-
- inline N *operator*() const;
- inline N *operator->() const;
- inline bool operator==(const iterator &other) const;
- inline bool operator!=(const iterator &other) const;
- inline iterator &operator++();
-
- inline iterator &erase();
-
- private:
- N *_value;
- };
- typedef iterator Iterator;
-
- inline N *first() const;
- static inline N *next(N *current);
-
- inline iterator begin();
- inline iterator end();
-
-private:
- static inline N *nodeToN(QIntrusiveListNode *node);
-
- QIntrusiveListNode *__first;
-};
-
-class QIntrusiveListNode
-{
-public:
- inline QIntrusiveListNode();
- inline ~QIntrusiveListNode();
-
- inline void remove();
- inline bool isInList() const;
-
- QIntrusiveListNode *_next;
- QIntrusiveListNode**_prev;
-};
-
-template<class N, QIntrusiveListNode N::*member>
-QIntrusiveList<N, member>::iterator::iterator()
-: _value(0)
-{
-}
-
-template<class N, QIntrusiveListNode N::*member>
-QIntrusiveList<N, member>::iterator::iterator(N *value)
-: _value(value)
-{
-}
-
-template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::iterator::operator*() const
-{
- return _value;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::iterator::operator->() const
-{
- return _value;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-bool QIntrusiveList<N, member>::iterator::operator==(const iterator &other) const
-{
- return other._value == _value;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-bool QIntrusiveList<N, member>::iterator::operator!=(const iterator &other) const
-{
- return other._value != _value;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-typename QIntrusiveList<N, member>::iterator &QIntrusiveList<N, member>::iterator::operator++()
-{
- _value = QIntrusiveList<N, member>::next(_value);
- return *this;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-typename QIntrusiveList<N, member>::iterator &QIntrusiveList<N, member>::iterator::erase()
-{
- N *old = _value;
- _value = QIntrusiveList<N, member>::next(_value);
- (old->*member).remove();
- return *this;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-QIntrusiveList<N, member>::QIntrusiveList()
-: __first(0)
-{
-}
-
-template<class N, QIntrusiveListNode N::*member>
-QIntrusiveList<N, member>::~QIntrusiveList()
-{
- while (__first) __first->remove();
-}
-
-template<class N, QIntrusiveListNode N::*member>
-bool QIntrusiveList<N, member>::isEmpty() const
-{
- return __first == 0;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-void QIntrusiveList<N, member>::insert(N *n)
-{
- QIntrusiveListNode *nnode = &(n->*member);
- nnode->remove();
-
- nnode->_next = __first;
- if (nnode->_next) nnode->_next->_prev = &nnode->_next;
- __first = nnode;
- nnode->_prev = &__first;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-void QIntrusiveList<N, member>::remove(N *n)
-{
- QIntrusiveListNode *nnode = &(n->*member);
- nnode->remove();
-}
-
-template<class N, QIntrusiveListNode N::*member>
-bool QIntrusiveList<N, member>::contains(N *n) const
-{
- QIntrusiveListNode *nnode = __first;
- while (nnode) {
- if (nodeToN(nnode) == n)
- return true;
- nnode = nnode->_next;
- }
- return false;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::first() const
-{
- return __first?nodeToN(__first):0;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::next(N *current)
-{
- QIntrusiveListNode *nextnode = (current->*member)._next;
- N *nextstruct = nextnode?nodeToN(nextnode):0;
- return nextstruct;
-}
-
-template<class N, QIntrusiveListNode N::*member>
-typename QIntrusiveList<N, member>::iterator QIntrusiveList<N, member>::begin()
-{
- return __first?iterator(nodeToN(__first)):iterator();
-}
-
-template<class N, QIntrusiveListNode N::*member>
-typename QIntrusiveList<N, member>::iterator QIntrusiveList<N, member>::end()
-{
- return iterator();
-}
-
-template<class N, QIntrusiveListNode N::*member>
-N *QIntrusiveList<N, member>::nodeToN(QIntrusiveListNode *node)
-{
- return (N *)((char *)node - ((char *)&(((N *)0)->*member) - (char *)0));
-}
-
-QIntrusiveListNode::QIntrusiveListNode()
-: _next(0), _prev(0)
-{
-}
-
-QIntrusiveListNode::~QIntrusiveListNode()
-{
- remove();
-}
-
-void QIntrusiveListNode::remove()
-{
- if (_prev) *_prev = _next;
- if (_next) _next->_prev = _prev;
- _prev = 0;
- _next = 0;
-}
-
-bool QIntrusiveListNode::isInList() const
-{
- return _prev != 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QINTRUSIVELIST_P_H
diff --git a/src/declarative/qml/ftw/qlazilyallocated_p.h b/src/declarative/qml/ftw/qlazilyallocated_p.h
deleted file mode 100644
index d5a9dcc3ec..0000000000
--- a/src/declarative/qml/ftw/qlazilyallocated_p.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLAZILYALLOCATED_P_H
-#define QLAZILYALLOCATED_P_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 <private/qflagpointer_p.h>
-
-QT_BEGIN_NAMESPACE
-
-template<typename T>
-class QLazilyAllocated {
-public:
- inline QLazilyAllocated();
- inline ~QLazilyAllocated();
-
- inline bool isAllocated() const;
-
- inline T *operator->() const;
-
- inline T &value();
- inline const T &value() const;
-
- inline bool flag() const;
- inline void setFlag();
- inline void clearFlag();
- inline void setFlagValue(bool);
-private:
- mutable QFlagPointer<T> d;
-};
-
-template<typename T>
-QLazilyAllocated<T>::QLazilyAllocated()
-{
-}
-
-template<typename T>
-QLazilyAllocated<T>::~QLazilyAllocated()
-{
- delete *d;
-}
-
-template<typename T>
-bool QLazilyAllocated<T>::isAllocated() const
-{
- return !d.isNull();
-}
-
-template<typename T>
-T &QLazilyAllocated<T>::value()
-{
- if (d.isNull()) d = new T;
- return *(*d);
-}
-
-template<typename T>
-const T &QLazilyAllocated<T>::value() const
-{
- if (d.isNull()) d = new T;
- return *(*d);
-}
-
-template<typename T>
-T *QLazilyAllocated<T>::operator->() const
-{
- return *d;
-}
-
-template<typename T>
-bool QLazilyAllocated<T>::flag() const
-{
- return d.flag();
-}
-
-template<typename T>
-void QLazilyAllocated<T>::setFlag()
-{
- d.setFlag();
-}
-
-template<typename T>
-void QLazilyAllocated<T>::clearFlag()
-{
- d.clearFlag();
-}
-
-template<typename T>
-void QLazilyAllocated<T>::setFlagValue(bool v)
-{
- d.setFlagValue(v);
-}
-
-QT_END_NAMESPACE
-
-#endif // QLAZILYALLOCATED_P_H
diff --git a/src/declarative/qml/ftw/qpodvector_p.h b/src/declarative/qml/ftw/qpodvector_p.h
deleted file mode 100644
index 66f970f100..0000000000
--- a/src/declarative/qml/ftw/qpodvector_p.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPODVECTOR_P_H
-#define QPODVECTOR_P_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 <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-template<class T, int Increment=1024>
-class QPODVector
-{
-public:
- QPODVector()
- : m_count(0), m_capacity(0), m_data(0) {}
- ~QPODVector() { if (m_data) ::free(m_data); }
-
- const T &at(int idx) const {
- return m_data[idx];
- }
-
- T &operator[](int idx) {
- return m_data[idx];
- }
-
- void clear() {
- m_count = 0;
- }
-
- void prepend(const T &v) {
- insert(0, v);
- }
-
- void append(const T &v) {
- insert(m_count, v);
- }
-
- void insert(int idx, const T &v) {
- if (m_count == m_capacity) {
- m_capacity += Increment;
- m_data = (T *)realloc(m_data, m_capacity * sizeof(T));
- }
- int moveCount = m_count - idx;
- if (moveCount)
- ::memmove(m_data + idx + 1, m_data + idx, moveCount * sizeof(T));
- m_count++;
- m_data[idx] = v;
- }
-
- void reserve(int count) {
- if (count >= m_capacity) {
- m_capacity = (count + (Increment-1)) & (0xFFFFFFFF - Increment + 1);
- m_data = (T *)realloc(m_data, m_capacity * sizeof(T));
- }
- }
-
- void insertBlank(int idx, int count) {
- int newSize = m_count + count;
- reserve(newSize);
- int moveCount = m_count - idx;
- if (moveCount)
- ::memmove(m_data + idx + count, m_data + idx,
- moveCount * sizeof(T));
- m_count = newSize;
- }
-
- void remove(int idx, int count = 1) {
- int moveCount = m_count - (idx + count);
- if (moveCount)
- ::memmove(m_data + idx, m_data + idx + count,
- moveCount * sizeof(T));
- m_count -= count;
- }
-
- void removeOne(const T &v) {
- int idx = 0;
- while (idx < m_count) {
- if (m_data[idx] == v) {
- remove(idx);
- return;
- }
- ++idx;
- }
- }
-
- int find(const T &v) {
- for (int idx = 0; idx < m_count; ++idx)
- if (m_data[idx] == v)
- return idx;
- return -1;
- }
-
- bool contains(const T &v) {
- return find(v) != -1;
- }
-
- int count() const {
- return m_count;
- }
-
- void copyAndClear(QPODVector<T,Increment> &other) {
- if (other.m_data) ::free(other.m_data);
- other.m_count = m_count;
- other.m_capacity = m_capacity;
- other.m_data = m_data;
- m_count = 0;
- m_capacity = 0;
- m_data = 0;
- }
-
- QPODVector<T,Increment> &operator<<(const T &v) { append(v); return *this; }
-private:
- QPODVector(const QPODVector &);
- QPODVector &operator=(const QPODVector &);
- int m_count;
- int m_capacity;
- T *m_data;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/ftw/qpointervaluepair_p.h b/src/declarative/qml/ftw/qpointervaluepair_p.h
deleted file mode 100644
index fd1a77004e..0000000000
--- a/src/declarative/qml/ftw/qpointervaluepair_p.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPOINTERVALUEPAIR_P_H
-#define QPOINTERVALUEPAIR_P_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 <private/qflagpointer_p.h>
-
-QT_BEGIN_NAMESPACE
-
-// QPointerValuePair is intended to help reduce the memory consumption of a class.
-// In the common case, QPointerValuePair behaves like a pointer. In this mode, it
-// consumes the same memory as a regular pointer.
-// Additionally, QPointerValuePair can store an arbitrary value type in *addition*
-// to the pointer. In this case, it uses slightly more memory than the pointer and
-// value type combined.
-// Consequently, this class is most useful in cases where a pointer is always stored
-// and a value type is rarely stored.
-template<typename P, typename V>
-class QPointerValuePair {
-public:
- inline QPointerValuePair();
- inline QPointerValuePair(P *);
- inline ~QPointerValuePair();
-
- inline bool isNull() const;
-
- inline bool flag() const;
- inline void setFlag();
- inline void clearFlag();
- inline void setFlagValue(bool);
-
- inline QPointerValuePair<P, V> &operator=(P *);
-
- inline P *operator->() const;
- inline P *operator*() const;
-
- inline bool hasValue() const;
- inline V &value();
- inline const V *constValue() const;
-
-private:
- struct Value { P *pointer; V value; };
- QBiPointer<P, Value> d;
-};
-
-template<typename P, typename V>
-QPointerValuePair<P, V>::QPointerValuePair()
-{
-}
-
-template<typename P, typename V>
-QPointerValuePair<P, V>::QPointerValuePair(P *p)
-: d(p)
-{
-}
-
-template<typename P, typename V>
-QPointerValuePair<P, V>::~QPointerValuePair()
-{
- if (d.isT2()) delete d.asT2();
-}
-
-template<typename P, typename V>
-bool QPointerValuePair<P, V>::isNull() const
-{
- if (d.isT1()) return 0 == d.asT1();
- else return d.asT2()->pointer == 0;
-}
-
-template<typename P, typename V>
-bool QPointerValuePair<P, V>::flag() const
-{
- return d.flag();
-}
-
-template<typename P, typename V>
-void QPointerValuePair<P, V>::setFlag()
-{
- d.setFlag();
-}
-
-template<typename P, typename V>
-void QPointerValuePair<P, V>::clearFlag()
-{
- d.clearFlag();
-}
-
-template<typename P, typename V>
-void QPointerValuePair<P, V>::setFlagValue(bool v)
-{
- d.setFlagValue(v);
-}
-
-template<typename P, typename V>
-QPointerValuePair<P, V> &QPointerValuePair<P, V>::operator=(P *o)
-{
- if (d.isT1()) d = o;
- else d.asT2()->pointer = o;
- return *this;
-}
-
-template<typename P, typename V>
-P *QPointerValuePair<P, V>::operator->() const
-{
- if (d.isT1()) return d.asT1();
- else return d.asT2()->pointer;
-}
-
-template<typename P, typename V>
-P *QPointerValuePair<P, V>::operator*() const
-{
- if (d.isT1()) return d.asT1();
- else return d.asT2()->pointer;
-}
-
-template<typename P, typename V>
-bool QPointerValuePair<P, V>::hasValue() const
-{
- return d.isT2();
-}
-
-template<typename P, typename V>
-V &QPointerValuePair<P, V>::value()
-{
- if (d.isT1()) {
- P *p = d.asT1();
- Value *value = new Value;
- value->pointer = p;
- d = value;
- }
-
- return d.asT2()->value;
-}
-
-// Will return null if hasValue() == false
-template<typename P, typename V>
-const V *QPointerValuePair<P, V>::constValue() const
-{
- if (d.isT2()) return &d.asT2()->value;
- else return 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QPOINTERVALUEPAIR_P_H
diff --git a/src/declarative/qml/ftw/qrecursionwatcher_p.h b/src/declarative/qml/ftw/qrecursionwatcher_p.h
deleted file mode 100644
index e68ec424aa..0000000000
--- a/src/declarative/qml/ftw/qrecursionwatcher_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QRECURSIONWATCHER_P_H
-#define QRECURSIONWATCHER_P_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>
-
-QT_BEGIN_NAMESPACE
-
-class QRecursionNode;
-class QRecursionNode {
-public:
- inline QRecursionNode();
- bool *_r;
-};
-
-template<class T, QRecursionNode T::*Node>
-class QRecursionWatcher {
-public:
- inline QRecursionWatcher(T *);
- inline ~QRecursionWatcher();
- inline bool hasRecursed() const;
-private:
- T *_t;
- bool _r;
-};
-
-QRecursionNode::QRecursionNode()
-: _r(0)
-{
-}
-
-template<class T, QRecursionNode T::*Node>
-QRecursionWatcher<T, Node>::QRecursionWatcher(T *t)
-: _t(t), _r(false)
-{
- if ((_t->*Node)._r) *(_t->*Node)._r = true;
- (_t->*Node)._r = &_r;
-}
-
-template<class T, QRecursionNode T::*Node>
-QRecursionWatcher<T, Node>::~QRecursionWatcher()
-{
- if ((_t->*Node)._r == &_r) (_t->*Node)._r = 0;
-}
-
-template<class T, QRecursionNode T::*Node>
-bool QRecursionWatcher<T, Node>::hasRecursed() const
-{
- return _r;
-}
-
-QT_END_NAMESPACE
-
-#endif // QRECURSIONWATCHER_P_H
diff --git a/src/declarative/qml/ftw/qrecyclepool_p.h b/src/declarative/qml/ftw/qrecyclepool_p.h
deleted file mode 100644
index ed0bbbdd27..0000000000
--- a/src/declarative/qml/ftw/qrecyclepool_p.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QRECYCLEPOOL_P_H
-#define QRECYCLEPOOL_P_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.
-//
-
-QT_BEGIN_NAMESPACE
-
-#define QRECYCLEPOOLCOOKIE 0x33218ADF
-
-template<typename T, int Step>
-class QRecyclePoolPrivate
-{
-public:
- QRecyclePoolPrivate()
- : recyclePoolHold(true), outstandingItems(0), cookie(QRECYCLEPOOLCOOKIE),
- currentPage(0), nextAllocated(0)
- {
- }
-
- bool recyclePoolHold;
- int outstandingItems;
- quint32 cookie;
-
- struct PoolType : public T {
- union {
- QRecyclePoolPrivate<T, Step> *pool;
- PoolType *nextAllocated;
- };
- };
-
- struct Page {
- Page *nextPage;
- unsigned int free;
- union {
- char array[Step * sizeof(PoolType)];
- qint64 q_for_alignment_1;
- double q_for_alignment_2;
- };
- };
-
- Page *currentPage;
- PoolType *nextAllocated;
-
- inline T *allocate();
- static inline void dispose(T *);
- inline void releaseIfPossible();
-};
-
-template<typename T, int Step = 1024>
-class QRecyclePool
-{
-public:
- inline QRecyclePool();
- inline ~QRecyclePool();
-
- inline T *New();
- template<typename T1>
- inline T *New(const T1 &);
- template<typename T1>
- inline T *New(T1 &);
-
- static inline void Delete(T *);
-
-private:
- QRecyclePoolPrivate<T, Step> *d;
-};
-
-template<typename T, int Step>
-QRecyclePool<T, Step>::QRecyclePool()
-: d(new QRecyclePoolPrivate<T, Step>())
-{
-}
-
-template<typename T, int Step>
-QRecyclePool<T, Step>::~QRecyclePool()
-{
- d->recyclePoolHold = false;
- d->releaseIfPossible();
-}
-
-template<typename T, int Step>
-T *QRecyclePool<T, Step>::New()
-{
- T *rv = d->allocate();
- new (rv) T;
- return rv;
-}
-
-template<typename T, int Step>
-template<typename T1>
-T *QRecyclePool<T, Step>::New(const T1 &a)
-{
- T *rv = d->allocate();
- new (rv) T(a);
- return rv;
-}
-
-template<typename T, int Step>
-template<typename T1>
-T *QRecyclePool<T, Step>::New(T1 &a)
-{
- T *rv = d->allocate();
- new (rv) T(a);
- return rv;
-}
-
-template<typename T, int Step>
-void QRecyclePool<T, Step>::Delete(T *t)
-{
- t->~T();
- QRecyclePoolPrivate<T, Step>::dispose(t);
-}
-
-template<typename T, int Step>
-void QRecyclePoolPrivate<T, Step>::releaseIfPossible()
-{
- if (recyclePoolHold || outstandingItems)
- return;
-
- Page *p = currentPage;
- while (p) {
- Page *n = p->nextPage;
- qFree(p);
- p = n;
- }
-
- delete this;
-}
-
-template<typename T, int Step>
-T *QRecyclePoolPrivate<T, Step>::allocate()
-{
- PoolType *rv = 0;
- if (nextAllocated) {
- rv = nextAllocated;
- nextAllocated = rv->nextAllocated;
- } else if (currentPage && currentPage->free) {
- rv = (PoolType *)(currentPage->array + (Step - currentPage->free) * sizeof(PoolType));
- currentPage->free--;
- } else {
- Page *p = (Page *)qMalloc(sizeof(Page));
- p->nextPage = currentPage;
- p->free = Step;
- currentPage = p;
-
- rv = (PoolType *)currentPage->array;
- currentPage->free--;
- }
-
- rv->pool = this;
- ++outstandingItems;
- return rv;
-}
-
-template<typename T, int Step>
-void QRecyclePoolPrivate<T, Step>::dispose(T *t)
-{
- PoolType *pt = static_cast<PoolType *>(t);
- Q_ASSERT(pt->pool && pt->pool->cookie == QRECYCLEPOOLCOOKIE);
-
- QRecyclePoolPrivate<T, Step> *This = pt->pool;
- pt->nextAllocated = This->nextAllocated;
- This->nextAllocated = pt;
- --This->outstandingItems;
- This->releaseIfPossible();
-}
-
-QT_END_NAMESPACE
-
-#endif // QRECYCLEPOOL_P_H
diff --git a/src/declarative/qml/parser/parser.pri b/src/declarative/qml/parser/parser.pri
deleted file mode 100644
index 3ae0a6d8eb..0000000000
--- a/src/declarative/qml/parser/parser.pri
+++ /dev/null
@@ -1,19 +0,0 @@
-HEADERS += \
- $$PWD/qdeclarativejsast_p.h \
- $$PWD/qdeclarativejsastfwd_p.h \
- $$PWD/qdeclarativejsastvisitor_p.h \
- $$PWD/qdeclarativejsengine_p.h \
- $$PWD/qdeclarativejsgrammar_p.h \
- $$PWD/qdeclarativejslexer_p.h \
- $$PWD/qdeclarativejsmemorypool_p.h \
- $$PWD/qdeclarativejsparser_p.h \
- $$PWD/qdeclarativejsglobal_p.h \
- $$PWD/qdeclarativejskeywords_p.h
-
-SOURCES += \
- $$PWD/qdeclarativejsast.cpp \
- $$PWD/qdeclarativejsastvisitor.cpp \
- $$PWD/qdeclarativejsengine_p.cpp \
- $$PWD/qdeclarativejsgrammar.cpp \
- $$PWD/qdeclarativejslexer.cpp \
- $$PWD/qdeclarativejsparser.cpp
diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g
deleted file mode 100644
index b87f9f8a65..0000000000
--- a/src/declarative/qml/parser/qdeclarativejs.g
+++ /dev/null
@@ -1,3016 +0,0 @@
-----------------------------------------------------------------------------
---
--- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
--- Contact: http://www.qt-project.org/
---
--- This file is part of the QtDeclarative module of the Qt Toolkit.
---
--- $QT_BEGIN_LICENSE:LGPL-ONLY$
--- GNU Lesser General Public License Usage
--- 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.
---
--- If you have questions regarding the use of this file, please contact
--- us via http://www.qt-project.org/.
---
--- $QT_END_LICENSE$
---
-----------------------------------------------------------------------------
-
-%parser QDeclarativeJSGrammar
-%decl qdeclarativejsparser_p.h
-%impl qdeclarativejsparser.cpp
-%expect 2
-%expect-rr 2
-
-%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
-%token T_BREAK "break" T_CASE "case" T_CATCH "catch"
-%token T_COLON ":" T_COMMA "," T_CONTINUE "continue"
-%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/"
-%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "."
-%token T_ELSE "else" T_EQ "=" T_EQ_EQ "=="
-%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for"
-%token T_FUNCTION "function" T_GE ">=" T_GT ">"
-%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>"
-%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if"
-%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{"
-%token T_LBRACKET "[" T_LE "<=" T_LPAREN "("
-%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<="
-%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--"
-%token T_NEW "new" T_NOT "!" T_NOT_EQ "!="
-%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|"
-%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+"
-%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?"
-%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%"
-%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")"
-%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*"
-%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal"
-%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly"
-%token T_SWITCH "switch" T_THIS "this" T_THROW "throw"
-%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof"
-%token T_VAR "var" T_VOID "void" T_WHILE "while"
-%token T_WITH "with" T_XOR "^" T_XOR_EQ "^="
-%token T_NULL "null" T_TRUE "true" T_FALSE "false"
-%token T_CONST "const"
-%token T_DEBUGGER "debugger"
-%token T_RESERVED_WORD "reserved word"
-%token T_MULTILINE_STRING_LITERAL "multiline string literal"
-%token T_COMMENT "comment"
-
---- context keywords.
-%token T_PUBLIC "public"
-%token T_IMPORT "import"
-%token T_AS "as"
-%token T_ON "on"
-
-%token T_ERROR
-
---- feed tokens
-%token T_FEED_UI_PROGRAM
-%token T_FEED_UI_OBJECT_MEMBER
-%token T_FEED_JS_STATEMENT
-%token T_FEED_JS_EXPRESSION
-%token T_FEED_JS_SOURCE_ELEMENT
-%token T_FEED_JS_PROGRAM
-
-%nonassoc SHIFT_THERE
-%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY
-%nonassoc REDUCE_HERE
-
-%start TopLevel
-
-/./****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QtDebug>
-#include <QtCore/QCoreApplication>
-
-#include <string.h>
-
-#include "qdeclarativejsengine_p.h"
-#include "qdeclarativejslexer_p.h"
-#include "qdeclarativejsast_p.h"
-#include "qdeclarativejsmemorypool_p.h"
-
-./
-
-/:/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-//
-// 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.
-//
-
-//
-// This file is automatically generated from qmljs.g.
-// Changes will be lost.
-//
-
-#ifndef QDECLARATIVEJSPARSER_P_H
-#define QDECLARATIVEJSPARSER_P_H
-
-#include "qdeclarativejsglobal_p.h"
-#include "qdeclarativejsgrammar_p.h"
-#include "qdeclarativejsast_p.h"
-#include "qdeclarativejsengine_p.h"
-
-#include <QtCore/QList>
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-class Engine;
-
-class QML_PARSER_EXPORT Parser: protected $table
-{
-public:
- union Value {
- int ival;
- double dval;
- AST::ArgumentList *ArgumentList;
- AST::CaseBlock *CaseBlock;
- AST::CaseClause *CaseClause;
- AST::CaseClauses *CaseClauses;
- AST::Catch *Catch;
- AST::DefaultClause *DefaultClause;
- AST::ElementList *ElementList;
- AST::Elision *Elision;
- AST::ExpressionNode *Expression;
- AST::Finally *Finally;
- AST::FormalParameterList *FormalParameterList;
- AST::FunctionBody *FunctionBody;
- AST::FunctionDeclaration *FunctionDeclaration;
- AST::Node *Node;
- AST::PropertyName *PropertyName;
- AST::PropertyNameAndValueList *PropertyNameAndValueList;
- AST::SourceElement *SourceElement;
- AST::SourceElements *SourceElements;
- AST::Statement *Statement;
- AST::StatementList *StatementList;
- AST::Block *Block;
- AST::VariableDeclaration *VariableDeclaration;
- AST::VariableDeclarationList *VariableDeclarationList;
-
- AST::UiProgram *UiProgram;
- AST::UiImportList *UiImportList;
- AST::UiImport *UiImport;
- AST::UiParameterList *UiParameterList;
- AST::UiPublicMember *UiPublicMember;
- AST::UiObjectDefinition *UiObjectDefinition;
- AST::UiObjectInitializer *UiObjectInitializer;
- AST::UiObjectBinding *UiObjectBinding;
- AST::UiScriptBinding *UiScriptBinding;
- AST::UiArrayBinding *UiArrayBinding;
- AST::UiObjectMember *UiObjectMember;
- AST::UiObjectMemberList *UiObjectMemberList;
- AST::UiArrayMemberList *UiArrayMemberList;
- AST::UiQualifiedId *UiQualifiedId;
- };
-
-public:
- Parser(Engine *engine);
- ~Parser();
-
- // parse a UI program
- bool parse() { return parse(T_FEED_UI_PROGRAM); }
- bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
- bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
- bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
- bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
- bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
-
- AST::UiProgram *ast() const
- { return AST::cast<AST::UiProgram *>(program); }
-
- AST::Statement *statement() const
- {
- if (! program)
- return 0;
-
- return program->statementCast();
- }
-
- AST::ExpressionNode *expression() const
- {
- if (! program)
- return 0;
-
- return program->expressionCast();
- }
-
- AST::UiObjectMember *uiObjectMember() const
- {
- if (! program)
- return 0;
-
- return program->uiObjectMemberCast();
- }
-
- AST::Node *rootNode() const
- { return program; }
-
- QList<DiagnosticMessage> diagnosticMessages() const
- { return diagnostic_messages; }
-
- inline DiagnosticMessage diagnosticMessage() const
- {
- foreach (const DiagnosticMessage &d, diagnostic_messages) {
- if (! d.kind == DiagnosticMessage::Warning)
- return d;
- }
-
- return DiagnosticMessage();
- }
-
- inline QString errorMessage() const
- { return diagnosticMessage().message; }
-
- inline int errorLineNumber() const
- { return diagnosticMessage().loc.startLine; }
-
- inline int errorColumnNumber() const
- { return diagnosticMessage().loc.startColumn; }
-
-protected:
- bool parse(int startToken);
-
- void reallocateStack();
-
- inline Value &sym(int index)
- { return sym_stack [tos + index - 1]; }
-
- inline QStringRef &stringRef(int index)
- { return string_stack [tos + index - 1]; }
-
- inline AST::SourceLocation &loc(int index)
- { return location_stack [tos + index - 1]; }
-
- AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
-
-protected:
- Engine *driver;
- MemoryPool *pool;
- int tos;
- int stack_size;
- Value *sym_stack;
- int *state_stack;
- AST::SourceLocation *location_stack;
- QStringRef *string_stack;
-
- AST::Node *program;
-
- // error recovery
- enum { TOKEN_BUFFER_SIZE = 3 };
-
- struct SavedToken {
- int token;
- double dval;
- AST::SourceLocation loc;
- QStringRef spell;
- };
-
- double yylval;
- QStringRef yytokenspell;
- AST::SourceLocation yylloc;
- AST::SourceLocation yyprevlloc;
-
- SavedToken token_buffer[TOKEN_BUFFER_SIZE];
- SavedToken *first_token;
- SavedToken *last_token;
-
- QList<DiagnosticMessage> diagnostic_messages;
-};
-
-} // end of namespace QDeclarativeJS
-
-
-:/
-
-
-/.
-
-#include "qdeclarativejsparser_p.h"
-#include <QVarLengthArray>
-
-//
-// This file is automatically generated from qmljs.g.
-// Changes will be lost.
-//
-
-using namespace QDeclarativeJS;
-
-QT_QML_BEGIN_NAMESPACE
-
-void Parser::reallocateStack()
-{
- if (! stack_size)
- stack_size = 128;
- else
- stack_size <<= 1;
-
- sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
- state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
- location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
- string_stack = reinterpret_cast<QStringRef*> (realloc(string_stack, stack_size * sizeof(QStringRef)));
-}
-
-Parser::Parser(Engine *engine):
- driver(engine),
- pool(engine->pool()),
- tos(0),
- stack_size(0),
- sym_stack(0),
- state_stack(0),
- location_stack(0),
- string_stack(0),
- first_token(0),
- last_token(0)
-{
-}
-
-Parser::~Parser()
-{
- if (stack_size) {
- free(sym_stack);
- free(state_stack);
- free(location_stack);
- free(string_stack);
- }
-}
-
-static inline AST::SourceLocation location(Lexer *lexer)
-{
- AST::SourceLocation loc;
- loc.offset = lexer->tokenOffset();
- loc.length = lexer->tokenLength();
- loc.startLine = lexer->tokenStartLine();
- loc.startColumn = lexer->tokenStartColumn();
- return loc;
-}
-
-AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
-{
- QVarLengthArray<QStringRef, 4> nameIds;
- QVarLengthArray<AST::SourceLocation, 4> locations;
-
- AST::ExpressionNode *it = expr;
- while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
- nameIds.append(m->name);
- locations.append(m->identifierToken);
- it = m->base;
- }
-
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
- AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name);
- q->identifierToken = idExpr->identifierToken;
-
- AST::UiQualifiedId *currentId = q;
- for (int i = nameIds.size() - 1; i != -1; --i) {
- currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]);
- currentId->identifierToken = locations[i];
- }
-
- return currentId->finish();
- }
-
- return 0;
-}
-
-bool Parser::parse(int startToken)
-{
- Lexer *lexer = driver->lexer();
- bool hadErrors = false;
- int yytoken = -1;
- int action = 0;
-
- token_buffer[0].token = startToken;
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- tos = -1;
- program = 0;
-
- do {
- if (++tos == stack_size)
- reallocateStack();
-
- state_stack[tos] = action;
-
- _Lcheck_token:
- if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
- yyprevlloc = yylloc;
-
- if (first_token == last_token) {
- yytoken = lexer->lex();
- yylval = lexer->tokenValue();
- yytokenspell = lexer->tokenSpell();
- yylloc = location(lexer);
- } else {
- yytoken = first_token->token;
- yylval = first_token->dval;
- yytokenspell = first_token->spell;
- yylloc = first_token->loc;
- ++first_token;
- }
- }
-
- action = t_action(action, yytoken);
- if (action > 0) {
- if (action != ACCEPT_STATE) {
- yytoken = -1;
- sym(1).dval = yylval;
- stringRef(1) = yytokenspell;
- loc(1) = yylloc;
- } else {
- --tos;
- return ! hadErrors;
- }
- } else if (action < 0) {
- const int r = -action - 1;
- tos -= rhs[r];
-
- switch (r) {
-./
-
---------------------------------------------------------------------------------------------------------
--- Declarative UI
---------------------------------------------------------------------------------------------------------
-
-TopLevel: T_FEED_UI_PROGRAM UiProgram ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_JS_STATEMENT Statement ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_JS_EXPRESSION Expression ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-TopLevel: T_FEED_JS_PROGRAM Program ;
-/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-./
-
-UiProgram: UiImportListOpt UiRootMember ;
-/.
-case $rule_number: {
- sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList,
- sym(2).UiObjectMemberList->finish());
-} break;
-./
-
-UiImportListOpt: Empty ;
-UiImportListOpt: UiImportList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).UiImportList->finish();
-} break;
-./
-
-UiImportList: UiImport ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport);
-} break;
-./
-
-UiImportList: UiImportList UiImport ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport);
-} break;
-./
-
-ImportId: MemberExpression ;
-
-UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_SEMICOLON ;
-/.
-case $rule_number: {
- sym(1).UiImport->semicolonToken = loc(2);
-} break;
-./
-
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ;
-/.
-case $rule_number: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->semicolonToken = loc(3);
-} break;
-./
-
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->asToken = loc(3);
- sym(1).UiImport->importIdToken = loc(4);
- sym(1).UiImport->importId = stringRef(4);
- sym(1).UiImport->semicolonToken = loc(5);
-} break;
-./
-
-UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- sym(1).UiImport->asToken = loc(2);
- sym(1).UiImport->importIdToken = loc(3);
- sym(1).UiImport->importId = stringRef(3);
- sym(1).UiImport->semicolonToken = loc(4);
-} break;
-./
-
-
-UiImportHead: T_IMPORT ImportId ;
-/.
-case $rule_number: {
- AST::UiImport *node = 0;
-
- if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
- node = new (pool) AST::UiImport(importIdLiteral->value);
- node->fileNameToken = loc(2);
- } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
- node = new (pool) AST::UiImport(qualifiedId);
- node->fileNameToken = loc(2);
- }
-
- sym(1).Node = node;
-
- if (node) {
- node->importToken = loc(1);
- } else {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id or a string literal")));
-
- return false; // ### remove me
- }
-} break;
-./
-
-Empty: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-UiRootMember: UiObjectDefinition ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
-} break;
-./
-
-UiObjectMemberList: UiObjectMember ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
-} break;
-./
-
-UiObjectMemberList: UiObjectMemberList UiObjectMember ;
-/.
-case $rule_number: {
- AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList(
- sym(1).UiObjectMemberList, sym(2).UiObjectMember);
- sym(1).Node = node;
-} break;
-./
-
-UiArrayMemberList: UiObjectDefinition ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember);
-} break;
-./
-
-UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ;
-/.
-case $rule_number: {
- AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList(
- sym(1).UiArrayMemberList, sym(3).UiObjectMember);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectInitializer: T_LBRACE T_RBRACE ;
-/.
-case $rule_number: {
- AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ;
-/.
-case $rule_number: {
- AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectDefinition: UiQualifiedId UiObjectInitializer ;
-/.
-case $rule_number: {
- AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId,
- sym(2).UiObjectInitializer);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: UiObjectDefinition ;
-
-UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
-/.
-case $rule_number: {
- AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding(
- sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
- node->colonToken = loc(2);
- node->lbracketToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
-/.
-case $rule_number: {
- AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
- sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ;
-/.
-case $rule_number: {
- AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
- sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- node->hasOnToken = true;
- sym(1).Node = node;
-} break;
-./
-
-UiScriptStatement: Block ;
-UiScriptStatement: EmptyStatement ;
-UiScriptStatement: ExpressionStatement ;
-UiScriptStatement: IfStatement ;
-UiScriptStatement: WithStatement ;
-UiScriptStatement: SwitchStatement ;
-UiScriptStatement: TryStatement ;
-
-UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ;
-/.
-case $rule_number:
-{
- AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding(
- sym(1).UiQualifiedId, sym(3).Statement);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiPropertyType: T_VAR ;
-UiPropertyType: T_RESERVED_WORD ;
-UiPropertyType: T_IDENTIFIER ;
-
-UiParameterListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-UiParameterListOpt: UiParameterList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).UiParameterList->finish ();
-} break;
-./
-
-UiParameterList: UiPropertyType JsIdentifier ;
-/.
-case $rule_number: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2));
- node->propertyTypeToken = loc(1);
- node->identifierToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
-/.
-case $rule_number: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
- node->commaToken = loc(2);
- node->identifierToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->parameters = sym(4).UiParameterList;
- node->semicolonToken = loc(6);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
- node->typeModifier = stringRef(2);
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4));
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3),
- sym(5).Statement);
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
- sym(6).Statement);
- node->isReadonlyMember = true;
- node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
- sym(6).Statement);
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
- node->typeModifier = stringRef(2);
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6));
- propertyName->identifierToken = loc(6);
- propertyName->next = 0;
-
- AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(
- propertyName, sym(9).UiArrayMemberList->finish());
- binding->colonToken = loc(7);
- binding->lbracketToken = loc(8);
- binding->rbracketToken = loc(10);
-
- node->binding = binding;
-
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ;
-/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3));
- propertyName->identifierToken = loc(3);
- propertyName->next = 0;
-
- AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
- propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer);
- binding->colonToken = loc(4);
-
- node->binding = binding;
-
- sym(1).Node = node;
-} break;
-./
-
-UiObjectMember: FunctionDeclaration ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
-} break;
-./
-
-UiObjectMember: VariableStatement ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
-} break;
-./
-
-JsIdentifier: T_IDENTIFIER;
-
-JsIdentifier: T_PROPERTY ;
-JsIdentifier: T_SIGNAL ;
-JsIdentifier: T_READONLY ;
-JsIdentifier: T_ON ;
-
---------------------------------------------------------------------------------------------------------
--- Expressions
---------------------------------------------------------------------------------------------------------
-
-PrimaryExpression: T_THIS ;
-/.
-case $rule_number: {
- AST::ThisExpression *node = new (pool) AST::ThisExpression();
- node->thisToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: JsIdentifier ;
-/.
-case $rule_number: {
- AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_NULL ;
-/.
-case $rule_number: {
- AST::NullExpression *node = new (pool) AST::NullExpression();
- node->nullToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_TRUE ;
-/.
-case $rule_number: {
- AST::TrueLiteral *node = new (pool) AST::TrueLiteral();
- node->trueToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_FALSE ;
-/.
-case $rule_number: {
- AST::FalseLiteral *node = new (pool) AST::FalseLiteral();
- node->falseToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_NUMERIC_LITERAL ;
-/.
-case $rule_number: {
- AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_MULTILINE_STRING_LITERAL ;
-/.case $rule_number:./
-
-PrimaryExpression: T_STRING_LITERAL ;
-/.
-case $rule_number: {
- AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1));
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_DIVIDE_ ;
-/:
-#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number
-:/
-/.
-case $rule_number: {
- bool rx = lexer->scanRegExp(Lexer::NoPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false; // ### remove me
- }
-
- loc(1).length = lexer->tokenLength();
- yylloc = loc(1); // adjust the location of the current token
-
- AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
- driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_DIVIDE_EQ ;
-/:
-#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number
-:/
-/.
-case $rule_number: {
- bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false;
- }
-
- loc(1).length = lexer->tokenLength();
- yylloc = loc(1); // adjust the location of the current token
-
- AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
- driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET Elision T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
- (AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
- sym(4).Elision->finish());
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
--- PrimaryExpression: T_LBRACE T_RBRACE ;
--- /.
--- case $rule_number: {
--- sym(1).Node = new (pool) AST::ObjectLiteral();
--- } break;
--- ./
-
-PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::ObjectLiteral *node = 0;
- if (sym(2).Node)
- node = new (pool) AST::ObjectLiteral(
- sym(2).PropertyNameAndValueList->finish ());
- else
- node = new (pool) AST::ObjectLiteral();
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ;
-/.
-case $rule_number: {
- AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
- sym(2).PropertyNameAndValueList->finish ());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-PrimaryExpression: T_LPAREN Expression T_RPAREN ;
-/.
-case $rule_number: {
- AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression);
- node->lparenToken = loc(1);
- node->rparenToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-UiQualifiedId: MemberExpression ;
-/.
-case $rule_number: {
- if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
- QLatin1String("Ignored annotation")));
-
- sym(1).Expression = mem->base;
- }
-
- if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
- sym(1).UiQualifiedId = qualifiedId;
- } else {
- sym(1).UiQualifiedId = 0;
-
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id")));
-
- return false; // ### recover
- }
-} break;
-./
-
-ElementList: AssignmentExpression ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression);
-} break;
-./
-
-ElementList: Elision AssignmentExpression ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression);
-} break;
-./
-
-ElementList: ElementList T_COMMA AssignmentExpression ;
-/.
-case $rule_number: {
- AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList,
- (AST::Elision *) 0, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ElementList: ElementList T_COMMA Elision AssignmentExpression ;
-/.
-case $rule_number: {
- AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(),
- sym(4).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-Elision: T_COMMA ;
-/.
-case $rule_number: {
- AST::Elision *node = new (pool) AST::Elision();
- node->commaToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-Elision: Elision T_COMMA ;
-/.
-case $rule_number: {
- AST::Elision *node = new (pool) AST::Elision(sym(1).Elision);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ;
-/.
-case $rule_number: {
- AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
- sym(1).PropertyName, sym(3).Expression);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ;
-/.
-case $rule_number: {
- AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
- sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
- node->commaToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: T_IDENTIFIER %prec SHIFT_THERE ;
-/.
-case $rule_number: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: T_SIGNAL ;
-/.case $rule_number:./
-
-PropertyName: T_PROPERTY ;
-/.
-case $rule_number: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: T_STRING_LITERAL ;
-/.
-case $rule_number: {
- AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: T_NUMERIC_LITERAL ;
-/.
-case $rule_number: {
- AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-PropertyName: ReservedIdentifier ;
-/.
-case $rule_number: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-ReservedIdentifier: T_BREAK ;
-ReservedIdentifier: T_CASE ;
-ReservedIdentifier: T_CATCH ;
-ReservedIdentifier: T_CONTINUE ;
-ReservedIdentifier: T_DEFAULT ;
-ReservedIdentifier: T_DELETE ;
-ReservedIdentifier: T_DO ;
-ReservedIdentifier: T_ELSE ;
-ReservedIdentifier: T_FALSE ;
-ReservedIdentifier: T_FINALLY ;
-ReservedIdentifier: T_FOR ;
-ReservedIdentifier: T_FUNCTION ;
-ReservedIdentifier: T_IF ;
-ReservedIdentifier: T_IN ;
-ReservedIdentifier: T_INSTANCEOF ;
-ReservedIdentifier: T_NEW ;
-ReservedIdentifier: T_NULL ;
-ReservedIdentifier: T_RETURN ;
-ReservedIdentifier: T_SWITCH ;
-ReservedIdentifier: T_THIS ;
-ReservedIdentifier: T_THROW ;
-ReservedIdentifier: T_TRUE ;
-ReservedIdentifier: T_TRY ;
-ReservedIdentifier: T_TYPEOF ;
-ReservedIdentifier: T_VAR ;
-ReservedIdentifier: T_VOID ;
-ReservedIdentifier: T_WHILE ;
-ReservedIdentifier: T_CONST ;
-ReservedIdentifier: T_DEBUGGER ;
-ReservedIdentifier: T_RESERVED_WORD ;
-ReservedIdentifier: T_WITH ;
-
-PropertyIdentifier: JsIdentifier ;
-PropertyIdentifier: ReservedIdentifier ;
-
-MemberExpression: PrimaryExpression ;
-MemberExpression: FunctionExpression ;
-
-MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-MemberExpression: MemberExpression T_DOT PropertyIdentifier ;
-/.
-case $rule_number: {
- AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
-/.
-case $rule_number: {
- AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList);
- node->newToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-NewExpression: MemberExpression ;
-
-NewExpression: T_NEW NewExpression ;
-/.
-case $rule_number: {
- AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression);
- node->newToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
-/.
-case $rule_number: {
- AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ;
-/.
-case $rule_number: {
- AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ;
-/.
-case $rule_number: {
- AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-CallExpression: CallExpression T_DOT PropertyIdentifier ;
-/.
-case $rule_number: {
- AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-ArgumentListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-ArgumentListOpt: ArgumentList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).ArgumentList->finish();
-} break;
-./
-
-ArgumentList: AssignmentExpression ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression);
-} break;
-./
-
-ArgumentList: ArgumentList T_COMMA AssignmentExpression ;
-/.
-case $rule_number: {
- AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LeftHandSideExpression: NewExpression ;
-LeftHandSideExpression: CallExpression ;
-PostfixExpression: LeftHandSideExpression ;
-
-PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ;
-/.
-case $rule_number: {
- AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression);
- node->incrementToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ;
-/.
-case $rule_number: {
- AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression);
- node->decrementToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: PostfixExpression ;
-
-UnaryExpression: T_DELETE UnaryExpression ;
-/.
-case $rule_number: {
- AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression);
- node->deleteToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_VOID UnaryExpression ;
-/.
-case $rule_number: {
- AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression);
- node->voidToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_TYPEOF UnaryExpression ;
-/.
-case $rule_number: {
- AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression);
- node->typeofToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_PLUS_PLUS UnaryExpression ;
-/.
-case $rule_number: {
- AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression);
- node->incrementToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_MINUS_MINUS UnaryExpression ;
-/.
-case $rule_number: {
- AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression);
- node->decrementToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_PLUS UnaryExpression ;
-/.
-case $rule_number: {
- AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression);
- node->plusToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_MINUS UnaryExpression ;
-/.
-case $rule_number: {
- AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression);
- node->minusToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_TILDE UnaryExpression ;
-/.
-case $rule_number: {
- AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression);
- node->tildeToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UnaryExpression: T_NOT UnaryExpression ;
-/.
-case $rule_number: {
- AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression);
- node->notToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-MultiplicativeExpression: UnaryExpression ;
-
-MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Mul, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Div, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Mod, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-AdditiveExpression: MultiplicativeExpression ;
-
-AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Add, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Sub, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ShiftExpression: AdditiveExpression ;
-
-ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::LShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::RShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::URShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: ShiftExpression ;
-
-RelationalExpression: RelationalExpression T_LT ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_GT ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_LE ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_GE ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpression: RelationalExpression T_IN ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::In, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: ShiftExpression ;
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpression: RelationalExpression ;
-
-EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpressionNotIn: RelationalExpressionNotIn ;
-
-EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseANDExpression: EqualityExpression ;
-
-BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseANDExpressionNotIn: EqualityExpressionNotIn ;
-
-BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseXORExpression: BitwiseANDExpression ;
-
-BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ;
-
-BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseORExpression: BitwiseXORExpression ;
-
-BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ;
-
-BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LogicalANDExpression: BitwiseORExpression ;
-
-LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ;
-
-LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LogicalORExpression: LogicalANDExpression ;
-
-LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LogicalORExpressionNotIn: LogicalANDExpressionNotIn ;
-
-LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ConditionalExpression: LogicalORExpression ;
-
-ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ;
-/.
-case $rule_number: {
- AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-ConditionalExpressionNotIn: LogicalORExpressionNotIn ;
-
-ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ;
-/.
-case $rule_number: {
- AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-AssignmentExpression: ConditionalExpression ;
-
-AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-AssignmentExpressionNotIn: ConditionalExpressionNotIn ;
-
-AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ;
-/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-AssignmentOperator: T_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::Assign;
-} break;
-./
-
-AssignmentOperator: T_STAR_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceMul;
-} break;
-./
-
-AssignmentOperator: T_DIVIDE_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceDiv;
-} break;
-./
-
-AssignmentOperator: T_REMAINDER_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceMod;
-} break;
-./
-
-AssignmentOperator: T_PLUS_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceAdd;
-} break;
-./
-
-AssignmentOperator: T_MINUS_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceSub;
-} break;
-./
-
-AssignmentOperator: T_LT_LT_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceLeftShift;
-} break;
-./
-
-AssignmentOperator: T_GT_GT_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceRightShift;
-} break;
-./
-
-AssignmentOperator: T_GT_GT_GT_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceURightShift;
-} break;
-./
-
-AssignmentOperator: T_AND_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceAnd;
-} break;
-./
-
-AssignmentOperator: T_XOR_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceXor;
-} break;
-./
-
-AssignmentOperator: T_OR_EQ ;
-/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceOr;
-} break;
-./
-
-Expression: AssignmentExpression ;
-
-Expression: Expression T_COMMA AssignmentExpression ;
-/.
-case $rule_number: {
- AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ExpressionOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-ExpressionOpt: Expression ;
-
-ExpressionNotIn: AssignmentExpressionNotIn ;
-
-ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ;
-/.
-case $rule_number: {
- AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ExpressionNotInOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-ExpressionNotInOpt: ExpressionNotIn ;
-
-Statement: Block ;
-Statement: VariableStatement ;
-Statement: EmptyStatement ;
-Statement: ExpressionStatement ;
-Statement: IfStatement ;
-Statement: IterationStatement ;
-Statement: ContinueStatement ;
-Statement: BreakStatement ;
-Statement: ReturnStatement ;
-Statement: WithStatement ;
-Statement: LabelledStatement ;
-Statement: SwitchStatement ;
-Statement: ThrowStatement ;
-Statement: TryStatement ;
-Statement: DebuggerStatement ;
-
-
-Block: T_LBRACE StatementListOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::Block *node = new (pool) AST::Block(sym(2).StatementList);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-StatementList: Statement ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::StatementList(sym(1).Statement);
-} break;
-./
-
-StatementList: StatementList Statement ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement);
-} break;
-./
-
-StatementListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-StatementListOpt: StatementList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).StatementList->finish ();
-} break;
-./
-
-VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::VariableStatement *node = new (pool) AST::VariableStatement(
- sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
- node->declarationKindToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-VariableDeclarationKind: T_CONST ;
-/.
-case $rule_number: {
- sym(1).ival = T_CONST;
-} break;
-./
-
-VariableDeclarationKind: T_VAR ;
-/.
-case $rule_number: {
- sym(1).ival = T_VAR;
-} break;
-./
-
-VariableDeclarationList: VariableDeclaration ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
-} break;
-./
-
-VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ;
-/.
-case $rule_number: {
- AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList(
- sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-VariableDeclarationListNotIn: VariableDeclarationNotIn ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
-} break;
-./
-
-VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
-} break;
-./
-
-VariableDeclaration: JsIdentifier InitialiserOpt ;
-/.
-case $rule_number: {
- AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ;
-/.
-case $rule_number: {
- AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-Initialiser: T_EQ AssignmentExpression ;
-/.
-case $rule_number: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-./
-
-InitialiserOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-InitialiserOpt: Initialiser ;
-
-InitialiserNotIn: T_EQ AssignmentExpressionNotIn ;
-/.
-case $rule_number: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-./
-
-InitialiserNotInOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-InitialiserNotInOpt: InitialiserNotIn ;
-
-EmptyStatement: T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::EmptyStatement *node = new (pool) AST::EmptyStatement();
- node->semicolonToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ExpressionStatement: Expression T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ;
-/.
-case $rule_number: {
- AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- node->elseToken = loc(6);
- sym(1).Node = node;
-} break;
-./
-
-IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-
-IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
- node->doToken = loc(1);
- node->whileToken = loc(3);
- node->lparenToken = loc(4);
- node->rparenToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
- node->whileToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression,
- sym(5).Expression, sym(7).Expression, sym(9).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->firstSemicolonToken = loc(4);
- node->secondSemicolonToken = loc(6);
- node->rparenToken = loc(8);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
- sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
- sym(8).Expression, sym(10).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->firstSemicolonToken = loc(5);
- node->secondSemicolonToken = loc(7);
- node->rparenToken = loc(9);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression,
- sym(5).Expression, sym(7).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->inToken = loc(4);
- node->rparenToken = loc(6);
- sym(1).Node = node;
-} break;
-./
-
-IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement(
- sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->inToken = loc(5);
- node->rparenToken = loc(7);
- sym(1).Node = node;
-} break;
-./
-
-ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ContinueStatement: T_CONTINUE T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
- node->continueToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
- node->continueToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-BreakStatement: T_BREAK T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
- node->breakToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
- node->breakToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
- node->returnToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ;
-/.
-case $rule_number: {
- AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
- node->withToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ;
-/.
-case $rule_number: {
- AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
- node->switchToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(5);
- sym(1).Node = node;
-} break;
-./
-
-CaseClauses: CaseClause ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
-} break;
-./
-
-CaseClauses: CaseClauses CaseClause ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
-} break;
-./
-
-CaseClausesOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-CaseClausesOpt: CaseClauses ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).CaseClauses->finish ();
-} break;
-./
-
-CaseClause: T_CASE Expression T_COLON StatementListOpt ;
-/.
-case $rule_number: {
- AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
- node->caseToken = loc(1);
- node->colonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-DefaultClause: T_DEFAULT T_COLON StatementListOpt ;
-/.
-case $rule_number: {
- AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
- node->defaultToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LabelledStatement: T_SIGNAL T_COLON Statement ;
-/.case $rule_number:./
-
-LabelledStatement: T_PROPERTY T_COLON Statement ;
-/.
-case $rule_number: {
- AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-LabelledStatement: T_IDENTIFIER T_COLON Statement ;
-/.
-case $rule_number: {
- AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ThrowStatement: T_THROW Expression T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
- node->throwToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-TryStatement: T_TRY Block Catch ;
-/.
-case $rule_number: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-TryStatement: T_TRY Block Finally ;
-/.
-case $rule_number: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-TryStatement: T_TRY Block Catch Finally ;
-/.
-case $rule_number: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ;
-/.
-case $rule_number: {
- AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
- node->catchToken = loc(1);
- node->lparenToken = loc(2);
- node->identifierToken = loc(3);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-./
-
-Finally: T_FINALLY Block ;
-/.
-case $rule_number: {
- AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
- node->finallyToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-DebuggerStatement: T_DEBUGGER T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
- node->debuggerToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-FunctionDeclaration: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-./
-
-FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
-/.
-case $rule_number: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- if (! stringRef(2).isNull())
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-./
-
-FormalParameterList: JsIdentifier ;
-/.
-case $rule_number: {
- AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-FormalParameterList: FormalParameterList T_COMMA JsIdentifier ;
-/.
-case $rule_number: {
- AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3));
- node->commaToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-./
-
-FormalParameterListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-FormalParameterListOpt: FormalParameterList ;
-/.
-case $rule_number: {
- sym(1).Node = sym(1).FormalParameterList->finish ();
-} break;
-./
-
-FunctionBodyOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-FunctionBodyOpt: FunctionBody ;
-
-FunctionBody: SourceElements ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ());
-} break;
-./
-
-Program: Empty ;
-
-Program: SourceElements ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ());
-} break;
-./
-
-SourceElements: SourceElement ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement);
-} break;
-./
-
-SourceElements: SourceElements SourceElement ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement);
-} break;
-./
-
-SourceElement: Statement ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement);
-} break;
-./
-
-SourceElement: FunctionDeclaration ;
-/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration);
-} break;
-./
-
-IdentifierOpt: ;
-/.
-case $rule_number: {
- stringRef(1) = QStringRef();
-} break;
-./
-
-IdentifierOpt: JsIdentifier ;
-
-PropertyNameAndValueListOpt: ;
-/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
-./
-
-PropertyNameAndValueListOpt: PropertyNameAndValueList ;
-
-/.
- } // switch
- action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
- } // if
- } while (action != 0);
-
- if (first_token == last_token) {
- const int errorState = state_stack[tos];
-
- // automatic insertion of `;'
- if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) {
- SavedToken &tk = token_buffer[0];
- tk.token = yytoken;
- tk.dval = yylval;
- tk.spell = yytokenspell;
- tk.loc = yylloc;
-
- yylloc = yyprevlloc;
- yylloc.offset += yylloc.length;
- yylloc.startColumn += yylloc.length;
- yylloc.length = 0;
-
- //const QString msg = qApp->translate("QDeclarativeParser", "Missing `;'");
- //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- yytoken = T_SEMICOLON;
- yylval = 0;
-
- action = errorState;
-
- goto _Lcheck_token;
- }
-
- hadErrors = true;
-
- token_buffer[0].token = yytoken;
- token_buffer[0].dval = yylval;
- token_buffer[0].spell = yytokenspell;
- token_buffer[0].loc = yylloc;
-
- token_buffer[1].token = yytoken = lexer->lex();
- token_buffer[1].dval = yylval = lexer->tokenValue();
- token_buffer[1].spell = yytokenspell = lexer->tokenSpell();
- token_buffer[1].loc = yylloc = location(lexer);
-
- if (t_action(errorState, yytoken)) {
- QString msg;
- int token = token_buffer[0].token;
- if (token < 0 || token >= TERMINAL_COUNT)
- msg = qApp->translate("QDeclarativeParser", "Syntax error");
- else
- msg = qApp->translate("QDeclarativeParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- action = errorState;
- goto _Lcheck_token;
- }
-
- static int tokens[] = {
- T_PLUS,
- T_EQ,
-
- T_COMMA,
- T_COLON,
- T_SEMICOLON,
-
- T_RPAREN, T_RBRACKET, T_RBRACE,
-
- T_NUMERIC_LITERAL,
- T_IDENTIFIER,
-
- T_LPAREN, T_LBRACKET, T_LBRACE,
-
- EOF_SYMBOL
- };
-
- for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
- int a = t_action(errorState, *tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = *tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[2];
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
- if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
- tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
- tk == T_FEED_JS_SOURCE_ELEMENT)
- continue;
-
- int a = t_action(errorState, tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- const QString msg = qApp->translate("QDeclarativeParser", "Syntax error");
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
- }
-
- return false;
-}
-
-QT_QML_END_NAMESPACE
-
-
-./
-/:
-QT_QML_END_NAMESPACE
-
-
-
-#endif // QDECLARATIVEJSPARSER_P_H
-:/
diff --git a/src/declarative/qml/parser/qdeclarativejsast.cpp b/src/declarative/qml/parser/qdeclarativejsast.cpp
deleted file mode 100644
index 8654c4392f..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsast.cpp
+++ /dev/null
@@ -1,931 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativejsast_p.h"
-
-#include "qdeclarativejsastvisitor_p.h"
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS { namespace AST {
-
-void Node::accept(Visitor *visitor)
-{
- if (visitor->preVisit(this)) {
- accept0(visitor);
- }
- visitor->postVisit(this);
-}
-
-void Node::accept(Node *node, Visitor *visitor)
-{
- if (node)
- node->accept(visitor);
-}
-
-ExpressionNode *Node::expressionCast()
-{
- return 0;
-}
-
-BinaryExpression *Node::binaryExpressionCast()
-{
- return 0;
-}
-
-Statement *Node::statementCast()
-{
- return 0;
-}
-
-UiObjectMember *Node::uiObjectMemberCast()
-{
- return 0;
-}
-
-ExpressionNode *ExpressionNode::expressionCast()
-{
- return this;
-}
-
-BinaryExpression *BinaryExpression::binaryExpressionCast()
-{
- return this;
-}
-
-Statement *Statement::statementCast()
-{
- return this;
-}
-
-UiObjectMember *UiObjectMember::uiObjectMemberCast()
-{
- return this;
-}
-
-void NestedExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
- visitor->endVisit(this);
-}
-
-void ThisExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void IdentifierExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void NullExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void TrueLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void FalseLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void StringLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void NumericLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void RegExpLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void ArrayLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(elements, visitor);
- accept(elision, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ObjectLiteral::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(properties, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ElementList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (ElementList *it = this; it; it = it->next) {
- accept(it->elision, visitor);
- accept(it->expression, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void Elision::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- // ###
- }
-
- visitor->endVisit(this);
-}
-
-void PropertyNameAndValueList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (PropertyNameAndValueList *it = this; it; it = it->next) {
- accept(it->name, visitor);
- accept(it->value, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void IdentifierPropertyName::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void StringLiteralPropertyName::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void NumericLiteralPropertyName::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void ArrayMemberExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void FieldMemberExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void NewMemberExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- accept(arguments, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void NewExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void CallExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- accept(arguments, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ArgumentList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (ArgumentList *it = this; it; it = it->next) {
- accept(it->expression, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void PostIncrementExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void PostDecrementExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(base, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void DeleteExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void VoidExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void TypeOfExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void PreIncrementExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void PreDecrementExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UnaryPlusExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UnaryMinusExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void TildeExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void NotExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void BinaryExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(left, visitor);
- accept(right, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ConditionalExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(ok, visitor);
- accept(ko, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Expression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(left, visitor);
- accept(right, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Block::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void StatementList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (StatementList *it = this; it; it = it->next) {
- accept(it->statement, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void VariableStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(declarations, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void VariableDeclarationList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (VariableDeclarationList *it = this; it; it = it->next) {
- accept(it->declaration, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void VariableDeclaration::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void EmptyStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void ExpressionStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void IfStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(ok, visitor);
- accept(ko, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void DoWhileStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void WhileStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ForStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(initialiser, visitor);
- accept(condition, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void LocalForStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(declarations, visitor);
- accept(condition, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ForEachStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(initialiser, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void LocalForEachStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(declaration, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ContinueStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void BreakStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void ReturnStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void WithStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void SwitchStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(block, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void CaseBlock::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(clauses, visitor);
- accept(defaultClause, visitor);
- accept(moreClauses, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void CaseClauses::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (CaseClauses *it = this; it; it = it->next) {
- accept(it->clause, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void CaseClause::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- accept(statements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void DefaultClause::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void LabelledStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void ThrowStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void TryStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- accept(catchExpression, visitor);
- accept(finallyExpression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Catch::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Finally::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void FunctionDeclaration::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(formals, visitor);
- accept(body, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void FunctionExpression::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(formals, visitor);
- accept(body, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void FormalParameterList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- // ###
- }
-
- visitor->endVisit(this);
-}
-
-void FunctionBody::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(elements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void Program::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(elements, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void SourceElements::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (SourceElements *it = this; it; it = it->next) {
- accept(it->element, visitor);
- }
- }
-
- visitor->endVisit(this);
-}
-
-void FunctionSourceElement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(declaration, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void StatementSourceElement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void DebuggerStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void UiProgram::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(imports, visitor);
- accept(members, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiPublicMember::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(statement, visitor);
- accept(binding, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiObjectDefinition::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(qualifiedTypeNameId, visitor);
- accept(initializer, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiObjectInitializer::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(members, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiObjectBinding::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(qualifiedId, visitor);
- accept(qualifiedTypeNameId, visitor);
- accept(initializer, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiScriptBinding::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(qualifiedId, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiArrayBinding::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(qualifiedId, visitor);
- accept(members, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiObjectMemberList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (UiObjectMemberList *it = this; it; it = it->next)
- accept(it->member, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiArrayMemberList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- for (UiArrayMemberList *it = this; it; it = it->next)
- accept(it->member, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiQualifiedId::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
-void UiImport::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(importUri, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiImportList::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(import, visitor);
- accept(next, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void UiSourceElement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(sourceElement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-} } // namespace QDeclarativeJS::AST
-
-QT_QML_END_NAMESPACE
-
-
diff --git a/src/declarative/qml/parser/qdeclarativejsast_p.h b/src/declarative/qml/parser/qdeclarativejsast_p.h
deleted file mode 100644
index 04bf3ce122..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsast_p.h
+++ /dev/null
@@ -1,2640 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEJSAST_P_H
-#define QDECLARATIVEJSAST_P_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 "qdeclarativejsastvisitor_p.h"
-#include "qdeclarativejsglobal_p.h"
-#include "qdeclarativejsmemorypool_p.h"
-
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-#define QDECLARATIVEJS_DECLARE_AST_NODE(name) \
- enum { K = Kind_##name };
-
-namespace QSOperator // ### rename
-{
-
-enum Op {
- Add,
- And,
- InplaceAnd,
- Assign,
- BitAnd,
- BitOr,
- BitXor,
- InplaceSub,
- Div,
- InplaceDiv,
- Equal,
- Ge,
- Gt,
- In,
- InplaceAdd,
- InstanceOf,
- Le,
- LShift,
- InplaceLeftShift,
- Lt,
- Mod,
- InplaceMod,
- Mul,
- InplaceMul,
- NotEqual,
- Or,
- InplaceOr,
- RShift,
- InplaceRightShift,
- StrictEqual,
- StrictNotEqual,
- Sub,
- URShift,
- InplaceURightShift,
- InplaceXor
-};
-
-} // namespace QSOperator
-
-namespace QDeclarativeJS {
-
-namespace AST {
-
-template <typename _T1, typename _T2>
-_T1 cast(_T2 *ast)
-{
- if (ast && ast->kind == static_cast<_T1>(0)->K)
- return static_cast<_T1>(ast);
-
- return 0;
-}
-
-class QML_PARSER_EXPORT Node: public Managed
-{
-public:
- enum Kind {
- Kind_Undefined,
-
- Kind_ArgumentList,
- Kind_ArrayLiteral,
- Kind_ArrayMemberExpression,
- Kind_BinaryExpression,
- Kind_Block,
- Kind_BreakStatement,
- Kind_CallExpression,
- Kind_CaseBlock,
- Kind_CaseClause,
- Kind_CaseClauses,
- Kind_Catch,
- Kind_ConditionalExpression,
- Kind_ContinueStatement,
- Kind_DebuggerStatement,
- Kind_DefaultClause,
- Kind_DeleteExpression,
- Kind_DoWhileStatement,
- Kind_ElementList,
- Kind_Elision,
- Kind_EmptyStatement,
- Kind_Expression,
- Kind_ExpressionStatement,
- Kind_FalseLiteral,
- Kind_FieldMemberExpression,
- Kind_Finally,
- Kind_ForEachStatement,
- Kind_ForStatement,
- Kind_FormalParameterList,
- Kind_FunctionBody,
- Kind_FunctionDeclaration,
- Kind_FunctionExpression,
- Kind_FunctionSourceElement,
- Kind_IdentifierExpression,
- Kind_IdentifierPropertyName,
- Kind_IfStatement,
- Kind_LabelledStatement,
- Kind_LocalForEachStatement,
- Kind_LocalForStatement,
- Kind_NewExpression,
- Kind_NewMemberExpression,
- Kind_NotExpression,
- Kind_NullExpression,
- Kind_NumericLiteral,
- Kind_NumericLiteralPropertyName,
- Kind_ObjectLiteral,
- Kind_PostDecrementExpression,
- Kind_PostIncrementExpression,
- Kind_PreDecrementExpression,
- Kind_PreIncrementExpression,
- Kind_Program,
- Kind_PropertyName,
- Kind_PropertyNameAndValueList,
- Kind_RegExpLiteral,
- Kind_ReturnStatement,
- Kind_SourceElement,
- Kind_SourceElements,
- Kind_StatementList,
- Kind_StatementSourceElement,
- Kind_StringLiteral,
- Kind_StringLiteralPropertyName,
- Kind_SwitchStatement,
- Kind_ThisExpression,
- Kind_ThrowStatement,
- Kind_TildeExpression,
- Kind_TrueLiteral,
- Kind_TryStatement,
- Kind_TypeOfExpression,
- Kind_UnaryMinusExpression,
- Kind_UnaryPlusExpression,
- Kind_VariableDeclaration,
- Kind_VariableDeclarationList,
- Kind_VariableStatement,
- Kind_VoidExpression,
- Kind_WhileStatement,
- Kind_WithStatement,
- Kind_NestedExpression,
-
- Kind_UiArrayBinding,
- Kind_UiImport,
- Kind_UiImportList,
- Kind_UiObjectBinding,
- Kind_UiObjectDefinition,
- Kind_UiObjectInitializer,
- Kind_UiObjectMemberList,
- Kind_UiArrayMemberList,
- Kind_UiProgram,
- Kind_UiParameterList,
- Kind_UiPublicMember,
- Kind_UiQualifiedId,
- Kind_UiScriptBinding,
- Kind_UiSourceElement
- };
-
- inline Node()
- : kind(Kind_Undefined) {}
-
- // NOTE: node destructors are never called,
- // instead we block free the memory
- // (see the NodePool class)
- virtual ~Node() {}
-
- virtual ExpressionNode *expressionCast();
- virtual BinaryExpression *binaryExpressionCast();
- virtual Statement *statementCast();
- virtual UiObjectMember *uiObjectMemberCast();
-
- void accept(Visitor *visitor);
- static void accept(Node *node, Visitor *visitor);
-
- inline static void acceptChild(Node *node, Visitor *visitor)
- { return accept(node, visitor); } // ### remove
-
- virtual void accept0(Visitor *visitor) = 0;
- virtual SourceLocation firstSourceLocation() const = 0;
- virtual SourceLocation lastSourceLocation() const = 0;
-
-// attributes
- int kind;
-};
-
-class QML_PARSER_EXPORT ExpressionNode: public Node
-{
-public:
- ExpressionNode() {}
-
- virtual ExpressionNode *expressionCast();
-};
-
-class QML_PARSER_EXPORT Statement: public Node
-{
-public:
- Statement() {}
-
- virtual Statement *statementCast();
-};
-
-class QML_PARSER_EXPORT NestedExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(NestedExpression)
-
- NestedExpression(ExpressionNode *expression)
- : expression(expression)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lparenToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rparenToken; }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ThisExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ThisExpression)
-
- ThisExpression() { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return thisToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return thisToken; }
-
-// attributes
- SourceLocation thisToken;
-};
-
-class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(IdentifierExpression)
-
- IdentifierExpression(const QStringRef &n):
- name (n) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return identifierToken; }
-
-// attributes
- QStringRef name;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT NullExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(NullExpression)
-
- NullExpression() { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return nullToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return nullToken; }
-
-// attributes
- SourceLocation nullToken;
-};
-
-class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(TrueLiteral)
-
- TrueLiteral() { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return trueToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return trueToken; }
-
-// attributes
- SourceLocation trueToken;
-};
-
-class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(FalseLiteral)
-
- FalseLiteral() { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return falseToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return falseToken; }
-
-// attributes
- SourceLocation falseToken;
-};
-
-class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(NumericLiteral)
-
- NumericLiteral(double v):
- value(v) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return literalToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return literalToken; }
-
-// attributes:
- double value;
- SourceLocation literalToken;
-};
-
-class QML_PARSER_EXPORT StringLiteral: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(StringLiteral)
-
- StringLiteral(const QStringRef &v):
- value (v) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return literalToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return literalToken; }
-
-// attributes:
- QStringRef value;
- SourceLocation literalToken;
-};
-
-class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(RegExpLiteral)
-
- RegExpLiteral(const QStringRef &p, int f):
- pattern (p), flags (f) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return literalToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return literalToken; }
-
-// attributes:
- QStringRef pattern;
- int flags;
- SourceLocation literalToken;
-};
-
-class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ArrayLiteral)
-
- ArrayLiteral(Elision *e):
- elements (0), elision (e)
- { kind = K; }
-
- ArrayLiteral(ElementList *elts):
- elements (elts), elision (0)
- { kind = K; }
-
- ArrayLiteral(ElementList *elts, Elision *e):
- elements (elts), elision (e)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lbracketToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbracketToken; }
-
-// attributes
- ElementList *elements;
- Elision *elision;
- SourceLocation lbracketToken;
- SourceLocation commaToken;
- SourceLocation rbracketToken;
-};
-
-class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ObjectLiteral)
-
- ObjectLiteral():
- properties (0) { kind = K; }
-
- ObjectLiteral(PropertyNameAndValueList *plist):
- properties (plist) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lbraceToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbraceToken; }
-
-// attributes
- PropertyNameAndValueList *properties;
- SourceLocation lbraceToken;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT Elision: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(Elision)
-
- Elision():
- next (this) { kind = K; }
-
- Elision(Elision *previous)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return commaToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : commaToken; }
-
- inline Elision *finish ()
- {
- Elision *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- Elision *next;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT ElementList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ElementList)
-
- ElementList(Elision *e, ExpressionNode *expr):
- elision (e), expression (expr), next (this)
- { kind = K; }
-
- ElementList(ElementList *previous, Elision *e, ExpressionNode *expr):
- elision (e), expression (expr)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- inline ElementList *finish ()
- {
- ElementList *front = next;
- next = 0;
- return front;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- {
- if (elision)
- return elision->firstSourceLocation();
- return expression->firstSourceLocation();
- }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (next)
- return next->lastSourceLocation();
- return expression->lastSourceLocation();
- }
-
-// attributes
- Elision *elision;
- ExpressionNode *expression;
- ElementList *next;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT PropertyName: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(PropertyName)
-
- PropertyName() { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- { return propertyNameToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return propertyNameToken; }
-
-// attributes
- SourceLocation propertyNameToken;
-};
-
-class QML_PARSER_EXPORT PropertyNameAndValueList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(PropertyNameAndValueList)
-
- PropertyNameAndValueList(PropertyName *n, ExpressionNode *v):
- name (n), value (v), next (this)
- { kind = K; }
-
- PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v):
- name (n), value (v)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return name->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (next)
- return next->lastSourceLocation();
- return value->lastSourceLocation();
- }
-
- inline PropertyNameAndValueList *finish ()
- {
- PropertyNameAndValueList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- PropertyName *name;
- ExpressionNode *value;
- PropertyNameAndValueList *next;
- SourceLocation colonToken;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(IdentifierPropertyName)
-
- IdentifierPropertyName(const QStringRef &n):
- id (n) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- QStringRef id;
-};
-
-class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(StringLiteralPropertyName)
-
- StringLiteralPropertyName(const QStringRef &n):
- id (n) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- QStringRef id;
-};
-
-class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(NumericLiteralPropertyName)
-
- NumericLiteralPropertyName(double n):
- id (n) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- double id;
-};
-
-class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ArrayMemberExpression)
-
- ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e):
- base (b), expression (e)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbracketToken; }
-
-// attributes
- ExpressionNode *base;
- ExpressionNode *expression;
- SourceLocation lbracketToken;
- SourceLocation rbracketToken;
-};
-
-class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(FieldMemberExpression)
-
- FieldMemberExpression(ExpressionNode *b, const QStringRef &n):
- base (b), name (n)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return identifierToken; }
-
- // attributes
- ExpressionNode *base;
- QStringRef name;
- SourceLocation dotToken;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(NewMemberExpression)
-
- NewMemberExpression(ExpressionNode *b, ArgumentList *a):
- base (b), arguments (a)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return newToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rparenToken; }
-
- // attributes
- ExpressionNode *base;
- ArgumentList *arguments;
- SourceLocation newToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT NewExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(NewExpression)
-
- NewExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return newToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation newToken;
-};
-
-class QML_PARSER_EXPORT CallExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(CallExpression)
-
- CallExpression(ExpressionNode *b, ArgumentList *a):
- base (b), arguments (a)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return rparenToken; }
-
-// attributes
- ExpressionNode *base;
- ArgumentList *arguments;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ArgumentList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ArgumentList)
-
- ArgumentList(ExpressionNode *e):
- expression (e), next (this)
- { kind = K; }
-
- ArgumentList(ArgumentList *previous, ExpressionNode *e):
- expression (e)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return expression->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (next)
- return next->lastSourceLocation();
- return expression->lastSourceLocation();
- }
-
- inline ArgumentList *finish ()
- {
- ArgumentList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- ExpressionNode *expression;
- ArgumentList *next;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(PostIncrementExpression)
-
- PostIncrementExpression(ExpressionNode *b):
- base (b) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return incrementToken; }
-
-// attributes
- ExpressionNode *base;
- SourceLocation incrementToken;
-};
-
-class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(PostDecrementExpression)
-
- PostDecrementExpression(ExpressionNode *b):
- base (b) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return base->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return decrementToken; }
-
-// attributes
- ExpressionNode *base;
- SourceLocation decrementToken;
-};
-
-class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(DeleteExpression)
-
- DeleteExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return deleteToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation deleteToken;
-};
-
-class QML_PARSER_EXPORT VoidExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(VoidExpression)
-
- VoidExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return voidToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation voidToken;
-};
-
-class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(TypeOfExpression)
-
- TypeOfExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return typeofToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation typeofToken;
-};
-
-class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(PreIncrementExpression)
-
- PreIncrementExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return incrementToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation incrementToken;
-};
-
-class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(PreDecrementExpression)
-
- PreDecrementExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return decrementToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation decrementToken;
-};
-
-class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UnaryPlusExpression)
-
- UnaryPlusExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return plusToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation plusToken;
-};
-
-class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UnaryMinusExpression)
-
- UnaryMinusExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return minusToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation minusToken;
-};
-
-class QML_PARSER_EXPORT TildeExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(TildeExpression)
-
- TildeExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return tildeToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation tildeToken;
-};
-
-class QML_PARSER_EXPORT NotExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(NotExpression)
-
- NotExpression(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return notToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation notToken;
-};
-
-class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(BinaryExpression)
-
- BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r):
- left (l), op (o), right (r)
- { kind = K; }
-
- virtual BinaryExpression *binaryExpressionCast();
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return left->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return right->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *left;
- int op;
- ExpressionNode *right;
- SourceLocation operatorToken;
-};
-
-class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ConditionalExpression)
-
- ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f):
- expression (e), ok (t), ko (f)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return expression->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return ko->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- ExpressionNode *ok;
- ExpressionNode *ko;
- SourceLocation questionToken;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(Expression)
-
- Expression(ExpressionNode *l, ExpressionNode *r):
- left (l), right (r) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return left->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return right->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *left;
- ExpressionNode *right;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT Block: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(Block)
-
- Block(StatementList *slist):
- statements (slist) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lbraceToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbraceToken; }
-
- // attributes
- StatementList *statements;
- SourceLocation lbraceToken;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT StatementList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(StatementList)
-
- StatementList(Statement *stmt):
- statement (stmt), next (this)
- { kind = K; }
-
- StatementList(StatementList *previous, Statement *stmt):
- statement (stmt)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return statement->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : statement->lastSourceLocation(); }
-
- inline StatementList *finish ()
- {
- StatementList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- Statement *statement;
- StatementList *next;
-};
-
-class QML_PARSER_EXPORT VariableStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(VariableStatement)
-
- VariableStatement(VariableDeclarationList *vlist):
- declarations (vlist)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return declarationKindToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- VariableDeclarationList *declarations;
- SourceLocation declarationKindToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT VariableDeclaration: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(VariableDeclaration)
-
- VariableDeclaration(const QStringRef &n, ExpressionNode *e):
- name (n), expression (e), readOnly(false)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return expression ? expression->lastSourceLocation() : identifierToken; }
-
-// attributes
- QStringRef name;
- ExpressionNode *expression;
- bool readOnly;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT VariableDeclarationList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(VariableDeclarationList)
-
- VariableDeclarationList(VariableDeclaration *decl):
- declaration (decl), next (this)
- { kind = K; }
-
- VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl):
- declaration (decl)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return declaration->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (next)
- return next->lastSourceLocation();
- return declaration->lastSourceLocation();
- }
-
- inline VariableDeclarationList *finish (bool readOnly)
- {
- VariableDeclarationList *front = next;
- next = 0;
- if (readOnly) {
- VariableDeclarationList *vdl;
- for (vdl = front; vdl != 0; vdl = vdl->next)
- vdl->declaration->readOnly = true;
- }
- return front;
- }
-
-// attributes
- VariableDeclaration *declaration;
- VariableDeclarationList *next;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT EmptyStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(EmptyStatement)
-
- EmptyStatement() { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return semicolonToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT ExpressionStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ExpressionStatement)
-
- ExpressionStatement(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return expression->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT IfStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(IfStatement)
-
- IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0):
- expression (e), ok (t), ko (f)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return ifToken; }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (ko)
- return ko->lastSourceLocation();
-
- return ok->lastSourceLocation();
- }
-
-// attributes
- ExpressionNode *expression;
- Statement *ok;
- Statement *ko;
- SourceLocation ifToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
- SourceLocation elseToken;
-};
-
-class QML_PARSER_EXPORT DoWhileStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(DoWhileStatement)
-
- DoWhileStatement(Statement *stmt, ExpressionNode *e):
- statement (stmt), expression (e)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return doToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- Statement *statement;
- ExpressionNode *expression;
- SourceLocation doToken;
- SourceLocation whileToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT WhileStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(WhileStatement)
-
- WhileStatement(ExpressionNode *e, Statement *stmt):
- expression (e), statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return whileToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation whileToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ForStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ForStatement)
-
- ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
- initialiser (i), condition (c), expression (e), statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return forToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *initialiser;
- ExpressionNode *condition;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation firstSemicolonToken;
- SourceLocation secondSemicolonToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT LocalForStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(LocalForStatement)
-
- LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
- declarations (vlist), condition (c), expression (e), statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return forToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- VariableDeclarationList *declarations;
- ExpressionNode *condition;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation varToken;
- SourceLocation firstSemicolonToken;
- SourceLocation secondSemicolonToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ForEachStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ForEachStatement)
-
- ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt):
- initialiser (i), expression (e), statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return forToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *initialiser;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation inToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT LocalForEachStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(LocalForEachStatement)
-
- LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt):
- declaration (v), expression (e), statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return forToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- VariableDeclaration *declaration;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation varToken;
- SourceLocation inToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT ContinueStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ContinueStatement)
-
- ContinueStatement(const QStringRef &l = QStringRef()):
- label (l) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return continueToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- QStringRef label;
- SourceLocation continueToken;
- SourceLocation identifierToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT BreakStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(BreakStatement)
-
- BreakStatement(const QStringRef &l):
- label (l) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return breakToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
- // attributes
- QStringRef label;
- SourceLocation breakToken;
- SourceLocation identifierToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT ReturnStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ReturnStatement)
-
- ReturnStatement(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return returnToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- ExpressionNode *expression;
- SourceLocation returnToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT WithStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(WithStatement)
-
- WithStatement(ExpressionNode *e, Statement *stmt):
- expression (e), statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return withToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation withToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT CaseBlock: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(CaseBlock)
-
- CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0):
- clauses (c), defaultClause (d), moreClauses (r)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lbraceToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbraceToken; }
-
-// attributes
- CaseClauses *clauses;
- DefaultClause *defaultClause;
- CaseClauses *moreClauses;
- SourceLocation lbraceToken;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT SwitchStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(SwitchStatement)
-
- SwitchStatement(ExpressionNode *e, CaseBlock *b):
- expression (e), block (b)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return switchToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return block->rbraceToken; }
-
-// attributes
- ExpressionNode *expression;
- CaseBlock *block;
- SourceLocation switchToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT CaseClause: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(CaseClause)
-
- CaseClause(ExpressionNode *e, StatementList *slist):
- expression (e), statements (slist)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return caseToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statements ? statements->lastSourceLocation() : colonToken; }
-
-// attributes
- ExpressionNode *expression;
- StatementList *statements;
- SourceLocation caseToken;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT CaseClauses: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(CaseClauses)
-
- CaseClauses(CaseClause *c):
- clause (c), next (this)
- { kind = K; }
-
- CaseClauses(CaseClauses *previous, CaseClause *c):
- clause (c)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return clause->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : clause->lastSourceLocation(); }
-
- inline CaseClauses *finish ()
- {
- CaseClauses *front = next;
- next = 0;
- return front;
- }
-
-//attributes
- CaseClause *clause;
- CaseClauses *next;
-};
-
-class QML_PARSER_EXPORT DefaultClause: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(DefaultClause)
-
- DefaultClause(StatementList *slist):
- statements (slist)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return defaultToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statements ? statements->lastSourceLocation() : colonToken; }
-
-// attributes
- StatementList *statements;
- SourceLocation defaultToken;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT LabelledStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(LabelledStatement)
-
- LabelledStatement(const QStringRef &l, Statement *stmt):
- label (l), statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- QStringRef label;
- Statement *statement;
- SourceLocation identifierToken;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT ThrowStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(ThrowStatement)
-
- ThrowStatement(ExpressionNode *e):
- expression (e) { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return throwToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
- // attributes
- ExpressionNode *expression;
- SourceLocation throwToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT Catch: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(Catch)
-
- Catch(const QStringRef &n, Block *stmt):
- name (n), statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return catchToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- QStringRef name;
- Block *statement;
- SourceLocation catchToken;
- SourceLocation lparenToken;
- SourceLocation identifierToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT Finally: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(Finally)
-
- Finally(Block *stmt):
- statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return finallyToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement ? statement->lastSourceLocation() : finallyToken; }
-
-// attributes
- Block *statement;
- SourceLocation finallyToken;
-};
-
-class QML_PARSER_EXPORT TryStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(TryStatement)
-
- TryStatement(Statement *stmt, Catch *c, Finally *f):
- statement (stmt), catchExpression (c), finallyExpression (f)
- { kind = K; }
-
- TryStatement(Statement *stmt, Finally *f):
- statement (stmt), catchExpression (0), finallyExpression (f)
- { kind = K; }
-
- TryStatement(Statement *stmt, Catch *c):
- statement (stmt), catchExpression (c), finallyExpression (0)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return tryToken; }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (finallyExpression)
- return finallyExpression->statement->rbraceToken;
- else if (catchExpression)
- return catchExpression->statement->rbraceToken;
-
- return statement->lastSourceLocation();
- }
-
-// attributes
- Statement *statement;
- Catch *catchExpression;
- Finally *finallyExpression;
- SourceLocation tryToken;
-};
-
-class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(FunctionExpression)
-
- FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b):
- name (n), formals (f), body (b)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return functionToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbraceToken; }
-
-// attributes
- QStringRef name;
- FormalParameterList *formals;
- FunctionBody *body;
- SourceLocation functionToken;
- SourceLocation identifierToken;
- SourceLocation lparenToken;
- SourceLocation rparenToken;
- SourceLocation lbraceToken;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(FunctionDeclaration)
-
- FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b):
- FunctionExpression(n, f, b)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-};
-
-class QML_PARSER_EXPORT FormalParameterList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(FormalParameterList)
-
- FormalParameterList(const QStringRef &n):
- name (n), next (this)
- { kind = K; }
-
- FormalParameterList(FormalParameterList *previous, const QStringRef &n):
- name (n)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : identifierToken; }
-
- inline FormalParameterList *finish ()
- {
- FormalParameterList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- QStringRef name;
- FormalParameterList *next;
- SourceLocation commaToken;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT SourceElement: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(SourceElement)
-
- inline SourceElement()
- { kind = K; }
-};
-
-class QML_PARSER_EXPORT SourceElements: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(SourceElements)
-
- SourceElements(SourceElement *elt):
- element (elt), next (this)
- { kind = K; }
-
- SourceElements(SourceElements *previous, SourceElement *elt):
- element (elt)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return element->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
-
- inline SourceElements *finish ()
- {
- SourceElements *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- SourceElement *element;
- SourceElements *next;
-};
-
-class QML_PARSER_EXPORT FunctionBody: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(FunctionBody)
-
- FunctionBody(SourceElements *elts):
- elements (elts)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return elements ? elements->firstSourceLocation() : SourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return elements ? elements->lastSourceLocation() : SourceLocation(); }
-
-// attributes
- SourceElements *elements;
-};
-
-class QML_PARSER_EXPORT Program: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(Program)
-
- Program(SourceElements *elts):
- elements (elts)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return elements ? elements->firstSourceLocation() : SourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return elements ? elements->lastSourceLocation() : SourceLocation(); }
-
-// attributes
- SourceElements *elements;
-};
-
-class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(FunctionSourceElement)
-
- FunctionSourceElement(FunctionDeclaration *f):
- declaration (f)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return declaration->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return declaration->lastSourceLocation(); }
-
-// attributes
- FunctionDeclaration *declaration;
-};
-
-class QML_PARSER_EXPORT StatementSourceElement: public SourceElement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(StatementSourceElement)
-
- StatementSourceElement(Statement *stmt):
- statement (stmt)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return statement->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
-// attributes
- Statement *statement;
-};
-
-class QML_PARSER_EXPORT DebuggerStatement: public Statement
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(DebuggerStatement)
-
- DebuggerStatement()
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return debuggerToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- SourceLocation debuggerToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT UiQualifiedId: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiQualifiedId)
-
- UiQualifiedId(const QStringRef &name)
- : next(this), name(name)
- { kind = K; }
-
- UiQualifiedId(UiQualifiedId *previous, const QStringRef &name)
- : name(name)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- UiQualifiedId *finish()
- {
- UiQualifiedId *head = next;
- next = 0;
- return head;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : identifierToken; }
-
-// attributes
- UiQualifiedId *next;
- QStringRef name;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT UiImport: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiImport)
-
- UiImport(const QStringRef &fileName)
- : fileName(fileName), importUri(0)
- { kind = K; }
-
- UiImport(UiQualifiedId *uri)
- : importUri(uri)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return importToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return semicolonToken; }
-
-// attributes
- QStringRef fileName;
- UiQualifiedId *importUri;
- QStringRef importId;
- SourceLocation importToken;
- SourceLocation fileNameToken;
- SourceLocation versionToken;
- SourceLocation asToken;
- SourceLocation importIdToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT UiImportList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiImportList)
-
- UiImportList(UiImport *import)
- : import(import),
- next(this)
- { kind = K; }
-
- UiImportList(UiImportList *previous, UiImport *import)
- : import(import)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- UiImportList *finish()
- {
- UiImportList *head = next;
- next = 0;
- return head;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return import->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : import->lastSourceLocation(); }
-
-// attributes
- UiImport *import;
- UiImportList *next;
-};
-
-class QML_PARSER_EXPORT UiObjectMember: public Node
-{
-public:
- virtual SourceLocation firstSourceLocation() const = 0;
- virtual SourceLocation lastSourceLocation() const = 0;
-
- virtual UiObjectMember *uiObjectMemberCast();
-};
-
-class QML_PARSER_EXPORT UiObjectMemberList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectMemberList)
-
- UiObjectMemberList(UiObjectMember *member)
- : next(this), member(member)
- { kind = K; }
-
- UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member)
- : member(member)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return member->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
-
- UiObjectMemberList *finish()
- {
- UiObjectMemberList *head = next;
- next = 0;
- return head;
- }
-
-// attributes
- UiObjectMemberList *next;
- UiObjectMember *member;
-};
-
-class QML_PARSER_EXPORT UiProgram: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiProgram)
-
- UiProgram(UiImportList *imports, UiObjectMemberList *members)
- : imports(imports), members(members)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- {
- if (imports)
- return imports->firstSourceLocation();
- else if (members)
- return members->firstSourceLocation();
- return SourceLocation();
- }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (members)
- return members->lastSourceLocation();
- else if (imports)
- return imports->lastSourceLocation();
- return SourceLocation();
- }
-
-// attributes
- UiImportList *imports;
- UiObjectMemberList *members;
-};
-
-class QML_PARSER_EXPORT UiArrayMemberList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiArrayMemberList)
-
- UiArrayMemberList(UiObjectMember *member)
- : next(this), member(member)
- { kind = K; }
-
- UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member)
- : member(member)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return member->firstSourceLocation(); }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
-
- UiArrayMemberList *finish()
- {
- UiArrayMemberList *head = next;
- next = 0;
- return head;
- }
-
-// attributes
- UiArrayMemberList *next;
- UiObjectMember *member;
- SourceLocation commaToken;
-};
-
-class QML_PARSER_EXPORT UiObjectInitializer: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectInitializer)
-
- UiObjectInitializer(UiObjectMemberList *members)
- : members(members)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return lbraceToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbraceToken; }
-
-// attributes
- SourceLocation lbraceToken;
- UiObjectMemberList *members;
- SourceLocation rbraceToken;
-};
-
-class QML_PARSER_EXPORT UiParameterList: public Node
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiParameterList)
-
- UiParameterList(const QStringRef &t, const QStringRef &n):
- type (t), name (n), next (this)
- { kind = K; }
-
- UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n):
- type (t), name (n)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- virtual void accept0(Visitor *) {}
-
- virtual SourceLocation firstSourceLocation() const
- { return propertyTypeToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return next ? next->lastSourceLocation() : identifierToken; }
-
- inline UiParameterList *finish ()
- {
- UiParameterList *front = next;
- next = 0;
- return front;
- }
-
-// attributes
- QStringRef type;
- QStringRef name;
- UiParameterList *next;
- SourceLocation commaToken;
- SourceLocation propertyTypeToken;
- SourceLocation identifierToken;
-};
-
-class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiPublicMember)
-
- UiPublicMember(const QStringRef &memberType,
- const QStringRef &name)
- : type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
- { kind = K; }
-
- UiPublicMember(const QStringRef &memberType,
- const QStringRef &name,
- Statement *statement)
- : type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- {
- if (defaultToken.isValid())
- return defaultToken;
- else if (readonlyToken.isValid())
- return readonlyToken;
-
- return propertyToken;
- }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (binding)
- return binding->lastSourceLocation();
- if (statement)
- return statement->lastSourceLocation();
-
- return semicolonToken;
- }
-
-// attributes
- enum { Signal, Property } type;
- QStringRef typeModifier;
- QStringRef memberType;
- QStringRef name;
- Statement *statement; // initialized with a JS expression
- UiObjectMember *binding; // initialized with a QML object or array.
- bool isDefaultMember;
- bool isReadonlyMember;
- UiParameterList *parameters;
- SourceLocation defaultToken;
- SourceLocation readonlyToken;
- SourceLocation propertyToken;
- SourceLocation typeModifierToken;
- SourceLocation typeToken;
- SourceLocation identifierToken;
- SourceLocation colonToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectDefinition)
-
- UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId,
- UiObjectInitializer *initializer)
- : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
- { kind = K; }
-
- virtual void accept0(Visitor *visitor);
-
- virtual SourceLocation firstSourceLocation() const
- { return qualifiedTypeNameId->identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return initializer->rbraceToken; }
-
-// attributes
- UiQualifiedId *qualifiedTypeNameId;
- UiObjectInitializer *initializer;
-};
-
-class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiSourceElement)
-
- UiSourceElement(Node *sourceElement)
- : sourceElement(sourceElement)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- {
- if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
- return funDecl->firstSourceLocation();
- else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
- return varStmt->firstSourceLocation();
-
- return SourceLocation();
- }
-
- virtual SourceLocation lastSourceLocation() const
- {
- if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
- return funDecl->lastSourceLocation();
- else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
- return varStmt->lastSourceLocation();
-
- return SourceLocation();
- }
-
- virtual void accept0(Visitor *visitor);
-
-
-// attributes
- Node *sourceElement;
-};
-
-class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectBinding)
-
- UiObjectBinding(UiQualifiedId *qualifiedId,
- UiQualifiedId *qualifiedTypeNameId,
- UiObjectInitializer *initializer)
- : qualifiedId(qualifiedId),
- qualifiedTypeNameId(qualifiedTypeNameId),
- initializer(initializer),
- hasOnToken(false)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- {
- if (hasOnToken && qualifiedTypeNameId)
- return qualifiedTypeNameId->identifierToken;
-
- return qualifiedId->identifierToken;
- }
-
- virtual SourceLocation lastSourceLocation() const
- { return initializer->rbraceToken; }
-
- virtual void accept0(Visitor *visitor);
-
-
-// attributes
- UiQualifiedId *qualifiedId;
- UiQualifiedId *qualifiedTypeNameId;
- UiObjectInitializer *initializer;
- SourceLocation colonToken;
- bool hasOnToken;
-};
-
-class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiScriptBinding)
-
- UiScriptBinding(UiQualifiedId *qualifiedId,
- Statement *statement)
- : qualifiedId(qualifiedId),
- statement(statement)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- { return qualifiedId->identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return statement->lastSourceLocation(); }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiQualifiedId *qualifiedId;
- Statement *statement;
- SourceLocation colonToken;
-};
-
-class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember
-{
-public:
- QDECLARATIVEJS_DECLARE_AST_NODE(UiArrayBinding)
-
- UiArrayBinding(UiQualifiedId *qualifiedId,
- UiArrayMemberList *members)
- : qualifiedId(qualifiedId),
- members(members)
- { kind = K; }
-
- virtual SourceLocation firstSourceLocation() const
- { return qualifiedId->identifierToken; }
-
- virtual SourceLocation lastSourceLocation() const
- { return rbracketToken; }
-
- virtual void accept0(Visitor *visitor);
-
-// attributes
- UiQualifiedId *qualifiedId;
- UiArrayMemberList *members;
- SourceLocation colonToken;
- SourceLocation lbracketToken;
- SourceLocation rbracketToken;
-};
-
-} } // namespace AST
-
-
-
-QT_QML_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/parser/qdeclarativejsastfwd_p.h b/src/declarative/qml/parser/qdeclarativejsastfwd_p.h
deleted file mode 100644
index 9c7d0a51e6..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsastfwd_p.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEJSAST_FWD_P_H
-#define QDECLARATIVEJSAST_FWD_P_H
-
-#include "qdeclarativejsglobal_p.h"
-
-#include <QtCore/qglobal.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.
-//
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS { namespace AST {
-
-class SourceLocation
-{
-public:
- SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
- : offset(offset), length(length),
- startLine(line), startColumn(column)
- { }
-
- bool isValid() const { return length != 0; }
-
- quint32 begin() const { return offset; }
- quint32 end() const { return offset + length; }
-
-// attributes
- // ### encode
- quint32 offset;
- quint32 length;
- quint32 startLine;
- quint32 startColumn;
-};
-
-class Visitor;
-class Node;
-class ExpressionNode;
-class Statement;
-class ThisExpression;
-class IdentifierExpression;
-class NullExpression;
-class TrueLiteral;
-class FalseLiteral;
-class NumericLiteral;
-class StringLiteral;
-class RegExpLiteral;
-class ArrayLiteral;
-class ObjectLiteral;
-class ElementList;
-class Elision;
-class PropertyNameAndValueList;
-class PropertyName;
-class IdentifierPropertyName;
-class StringLiteralPropertyName;
-class NumericLiteralPropertyName;
-class ArrayMemberExpression;
-class FieldMemberExpression;
-class NewMemberExpression;
-class NewExpression;
-class CallExpression;
-class ArgumentList;
-class PostIncrementExpression;
-class PostDecrementExpression;
-class DeleteExpression;
-class VoidExpression;
-class TypeOfExpression;
-class PreIncrementExpression;
-class PreDecrementExpression;
-class UnaryPlusExpression;
-class UnaryMinusExpression;
-class TildeExpression;
-class NotExpression;
-class BinaryExpression;
-class ConditionalExpression;
-class Expression; // ### rename
-class Block;
-class StatementList;
-class VariableStatement;
-class VariableDeclarationList;
-class VariableDeclaration;
-class EmptyStatement;
-class ExpressionStatement;
-class IfStatement;
-class DoWhileStatement;
-class WhileStatement;
-class ForStatement;
-class LocalForStatement;
-class ForEachStatement;
-class LocalForEachStatement;
-class ContinueStatement;
-class BreakStatement;
-class ReturnStatement;
-class WithStatement;
-class SwitchStatement;
-class CaseBlock;
-class CaseClauses;
-class CaseClause;
-class DefaultClause;
-class LabelledStatement;
-class ThrowStatement;
-class TryStatement;
-class Catch;
-class Finally;
-class FunctionDeclaration;
-class FunctionExpression;
-class FormalParameterList;
-class FunctionBody;
-class Program;
-class SourceElements;
-class SourceElement;
-class FunctionSourceElement;
-class StatementSourceElement;
-class DebuggerStatement;
-class NestedExpression;
-
-// ui elements
-class UiProgram;
-class UiImportList;
-class UiImport;
-class UiPublicMember;
-class UiObjectDefinition;
-class UiObjectInitializer;
-class UiObjectBinding;
-class UiScriptBinding;
-class UiSourceElement;
-class UiArrayBinding;
-class UiObjectMember;
-class UiObjectMemberList;
-class UiArrayMemberList;
-class UiQualifiedId;
-
-} } // namespace AST
-
-QT_QML_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp b/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp
deleted file mode 100644
index 671abd76db..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativejsastvisitor_p.h"
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS { namespace AST {
-
-Visitor::Visitor()
-{
-}
-
-Visitor::~Visitor()
-{
-}
-
-} } // namespace QDeclarativeJS::AST
-
-QT_QML_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h b/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h
deleted file mode 100644
index 639cb33d49..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEJSASTVISITOR_P_H
-#define QDECLARATIVEJSASTVISITOR_P_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 "qdeclarativejsastfwd_p.h"
-#include "qdeclarativejsglobal_p.h"
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS { namespace AST {
-
-class QML_PARSER_EXPORT Visitor
-{
-public:
- Visitor();
- virtual ~Visitor();
-
- virtual bool preVisit(Node *) { return true; }
- virtual void postVisit(Node *) {}
-
- // Ui
- virtual bool visit(UiProgram *) { return true; }
- virtual bool visit(UiImportList *) { return true; }
- virtual bool visit(UiImport *) { return true; }
- virtual bool visit(UiPublicMember *) { return true; }
- virtual bool visit(UiSourceElement *) { return true; }
- virtual bool visit(UiObjectDefinition *) { return true; }
- virtual bool visit(UiObjectInitializer *) { return true; }
- virtual bool visit(UiObjectBinding *) { return true; }
- virtual bool visit(UiScriptBinding *) { return true; }
- virtual bool visit(UiArrayBinding *) { return true; }
- virtual bool visit(UiObjectMemberList *) { return true; }
- virtual bool visit(UiArrayMemberList *) { return true; }
- virtual bool visit(UiQualifiedId *) { return true; }
-
- virtual void endVisit(UiProgram *) {}
- virtual void endVisit(UiImportList *) {}
- virtual void endVisit(UiImport *) {}
- virtual void endVisit(UiPublicMember *) {}
- virtual void endVisit(UiSourceElement *) {}
- virtual void endVisit(UiObjectDefinition *) {}
- virtual void endVisit(UiObjectInitializer *) {}
- virtual void endVisit(UiObjectBinding *) {}
- virtual void endVisit(UiScriptBinding *) {}
- virtual void endVisit(UiArrayBinding *) {}
- virtual void endVisit(UiObjectMemberList *) {}
- virtual void endVisit(UiArrayMemberList *) {}
- virtual void endVisit(UiQualifiedId *) {}
-
- // QDeclarativeJS
- virtual bool visit(ThisExpression *) { return true; }
- virtual void endVisit(ThisExpression *) {}
-
- virtual bool visit(IdentifierExpression *) { return true; }
- virtual void endVisit(IdentifierExpression *) {}
-
- virtual bool visit(NullExpression *) { return true; }
- virtual void endVisit(NullExpression *) {}
-
- virtual bool visit(TrueLiteral *) { return true; }
- virtual void endVisit(TrueLiteral *) {}
-
- virtual bool visit(FalseLiteral *) { return true; }
- virtual void endVisit(FalseLiteral *) {}
-
- virtual bool visit(StringLiteral *) { return true; }
- virtual void endVisit(StringLiteral *) {}
-
- virtual bool visit(NumericLiteral *) { return true; }
- virtual void endVisit(NumericLiteral *) {}
-
- virtual bool visit(RegExpLiteral *) { return true; }
- virtual void endVisit(RegExpLiteral *) {}
-
- virtual bool visit(ArrayLiteral *) { return true; }
- virtual void endVisit(ArrayLiteral *) {}
-
- virtual bool visit(ObjectLiteral *) { return true; }
- virtual void endVisit(ObjectLiteral *) {}
-
- virtual bool visit(ElementList *) { return true; }
- virtual void endVisit(ElementList *) {}
-
- virtual bool visit(Elision *) { return true; }
- virtual void endVisit(Elision *) {}
-
- virtual bool visit(PropertyNameAndValueList *) { return true; }
- virtual void endVisit(PropertyNameAndValueList *) {}
-
- virtual bool visit(NestedExpression *) { return true; }
- virtual void endVisit(NestedExpression *) {}
-
- virtual bool visit(IdentifierPropertyName *) { return true; }
- virtual void endVisit(IdentifierPropertyName *) {}
-
- virtual bool visit(StringLiteralPropertyName *) { return true; }
- virtual void endVisit(StringLiteralPropertyName *) {}
-
- virtual bool visit(NumericLiteralPropertyName *) { return true; }
- virtual void endVisit(NumericLiteralPropertyName *) {}
-
- virtual bool visit(ArrayMemberExpression *) { return true; }
- virtual void endVisit(ArrayMemberExpression *) {}
-
- virtual bool visit(FieldMemberExpression *) { return true; }
- virtual void endVisit(FieldMemberExpression *) {}
-
- virtual bool visit(NewMemberExpression *) { return true; }
- virtual void endVisit(NewMemberExpression *) {}
-
- virtual bool visit(NewExpression *) { return true; }
- virtual void endVisit(NewExpression *) {}
-
- virtual bool visit(CallExpression *) { return true; }
- virtual void endVisit(CallExpression *) {}
-
- virtual bool visit(ArgumentList *) { return true; }
- virtual void endVisit(ArgumentList *) {}
-
- virtual bool visit(PostIncrementExpression *) { return true; }
- virtual void endVisit(PostIncrementExpression *) {}
-
- virtual bool visit(PostDecrementExpression *) { return true; }
- virtual void endVisit(PostDecrementExpression *) {}
-
- virtual bool visit(DeleteExpression *) { return true; }
- virtual void endVisit(DeleteExpression *) {}
-
- virtual bool visit(VoidExpression *) { return true; }
- virtual void endVisit(VoidExpression *) {}
-
- virtual bool visit(TypeOfExpression *) { return true; }
- virtual void endVisit(TypeOfExpression *) {}
-
- virtual bool visit(PreIncrementExpression *) { return true; }
- virtual void endVisit(PreIncrementExpression *) {}
-
- virtual bool visit(PreDecrementExpression *) { return true; }
- virtual void endVisit(PreDecrementExpression *) {}
-
- virtual bool visit(UnaryPlusExpression *) { return true; }
- virtual void endVisit(UnaryPlusExpression *) {}
-
- virtual bool visit(UnaryMinusExpression *) { return true; }
- virtual void endVisit(UnaryMinusExpression *) {}
-
- virtual bool visit(TildeExpression *) { return true; }
- virtual void endVisit(TildeExpression *) {}
-
- virtual bool visit(NotExpression *) { return true; }
- virtual void endVisit(NotExpression *) {}
-
- virtual bool visit(BinaryExpression *) { return true; }
- virtual void endVisit(BinaryExpression *) {}
-
- virtual bool visit(ConditionalExpression *) { return true; }
- virtual void endVisit(ConditionalExpression *) {}
-
- virtual bool visit(Expression *) { return true; }
- virtual void endVisit(Expression *) {}
-
- virtual bool visit(Block *) { return true; }
- virtual void endVisit(Block *) {}
-
- virtual bool visit(StatementList *) { return true; }
- virtual void endVisit(StatementList *) {}
-
- virtual bool visit(VariableStatement *) { return true; }
- virtual void endVisit(VariableStatement *) {}
-
- virtual bool visit(VariableDeclarationList *) { return true; }
- virtual void endVisit(VariableDeclarationList *) {}
-
- virtual bool visit(VariableDeclaration *) { return true; }
- virtual void endVisit(VariableDeclaration *) {}
-
- virtual bool visit(EmptyStatement *) { return true; }
- virtual void endVisit(EmptyStatement *) {}
-
- virtual bool visit(ExpressionStatement *) { return true; }
- virtual void endVisit(ExpressionStatement *) {}
-
- virtual bool visit(IfStatement *) { return true; }
- virtual void endVisit(IfStatement *) {}
-
- virtual bool visit(DoWhileStatement *) { return true; }
- virtual void endVisit(DoWhileStatement *) {}
-
- virtual bool visit(WhileStatement *) { return true; }
- virtual void endVisit(WhileStatement *) {}
-
- virtual bool visit(ForStatement *) { return true; }
- virtual void endVisit(ForStatement *) {}
-
- virtual bool visit(LocalForStatement *) { return true; }
- virtual void endVisit(LocalForStatement *) {}
-
- virtual bool visit(ForEachStatement *) { return true; }
- virtual void endVisit(ForEachStatement *) {}
-
- virtual bool visit(LocalForEachStatement *) { return true; }
- virtual void endVisit(LocalForEachStatement *) {}
-
- virtual bool visit(ContinueStatement *) { return true; }
- virtual void endVisit(ContinueStatement *) {}
-
- virtual bool visit(BreakStatement *) { return true; }
- virtual void endVisit(BreakStatement *) {}
-
- virtual bool visit(ReturnStatement *) { return true; }
- virtual void endVisit(ReturnStatement *) {}
-
- virtual bool visit(WithStatement *) { return true; }
- virtual void endVisit(WithStatement *) {}
-
- virtual bool visit(SwitchStatement *) { return true; }
- virtual void endVisit(SwitchStatement *) {}
-
- virtual bool visit(CaseBlock *) { return true; }
- virtual void endVisit(CaseBlock *) {}
-
- virtual bool visit(CaseClauses *) { return true; }
- virtual void endVisit(CaseClauses *) {}
-
- virtual bool visit(CaseClause *) { return true; }
- virtual void endVisit(CaseClause *) {}
-
- virtual bool visit(DefaultClause *) { return true; }
- virtual void endVisit(DefaultClause *) {}
-
- virtual bool visit(LabelledStatement *) { return true; }
- virtual void endVisit(LabelledStatement *) {}
-
- virtual bool visit(ThrowStatement *) { return true; }
- virtual void endVisit(ThrowStatement *) {}
-
- virtual bool visit(TryStatement *) { return true; }
- virtual void endVisit(TryStatement *) {}
-
- virtual bool visit(Catch *) { return true; }
- virtual void endVisit(Catch *) {}
-
- virtual bool visit(Finally *) { return true; }
- virtual void endVisit(Finally *) {}
-
- virtual bool visit(FunctionDeclaration *) { return true; }
- virtual void endVisit(FunctionDeclaration *) {}
-
- virtual bool visit(FunctionExpression *) { return true; }
- virtual void endVisit(FunctionExpression *) {}
-
- virtual bool visit(FormalParameterList *) { return true; }
- virtual void endVisit(FormalParameterList *) {}
-
- virtual bool visit(FunctionBody *) { return true; }
- virtual void endVisit(FunctionBody *) {}
-
- virtual bool visit(Program *) { return true; }
- virtual void endVisit(Program *) {}
-
- virtual bool visit(SourceElements *) { return true; }
- virtual void endVisit(SourceElements *) {}
-
- virtual bool visit(FunctionSourceElement *) { return true; }
- virtual void endVisit(FunctionSourceElement *) {}
-
- virtual bool visit(StatementSourceElement *) { return true; }
- virtual void endVisit(StatementSourceElement *) {}
-
- virtual bool visit(DebuggerStatement *) { return true; }
- virtual void endVisit(DebuggerStatement *) {}
-};
-
-} } // namespace AST
-
-QT_QML_END_NAMESPACE
-
-#endif // QDECLARATIVEJSASTVISITOR_P_H
diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.cpp b/src/declarative/qml/parser/qdeclarativejsengine_p.cpp
deleted file mode 100644
index 534849cd53..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsengine_p.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativejsengine_p.h"
-#include "qdeclarativejsglobal_p.h"
-
-#include <qnumeric.h>
-#include <QHash>
-#include <QDebug>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-static int toDigit(char c)
-{
- if ((c >= '0') && (c <= '9'))
- return c - '0';
- else if ((c >= 'a') && (c <= 'z'))
- return 10 + c - 'a';
- else if ((c >= 'A') && (c <= 'Z'))
- return 10 + c - 'A';
- return -1;
-}
-
-double integerFromString(const char *buf, int size, int radix)
-{
- if (size == 0)
- return qSNaN();
-
- double sign = 1.0;
- int i = 0;
- if (buf[0] == '+') {
- ++i;
- } else if (buf[0] == '-') {
- sign = -1.0;
- ++i;
- }
-
- if (((size-i) >= 2) && (buf[i] == '0')) {
- if (((buf[i+1] == 'x') || (buf[i+1] == 'X'))
- && (radix < 34)) {
- if ((radix != 0) && (radix != 16))
- return 0;
- radix = 16;
- i += 2;
- } else {
- if (radix == 0) {
- radix = 8;
- ++i;
- }
- }
- } else if (radix == 0) {
- radix = 10;
- }
-
- int j = i;
- for ( ; i < size; ++i) {
- int d = toDigit(buf[i]);
- if ((d == -1) || (d >= radix))
- break;
- }
- double result;
- if (j == i) {
- if (!qstrcmp(buf, "Infinity"))
- result = qInf();
- else
- result = qSNaN();
- } else {
- result = 0;
- double multiplier = 1;
- for (--i ; i >= j; --i, multiplier *= radix)
- result += toDigit(buf[i]) * multiplier;
- }
- result *= sign;
- return result;
-}
-
-double integerFromString(const QString &str, int radix)
-{
- QByteArray ba = str.trimmed().toLatin1();
- return integerFromString(ba.constData(), ba.size(), radix);
-}
-
-
-Engine::Engine()
- : _lexer(0)
-{ }
-
-Engine::~Engine()
-{ }
-
-void Engine::setCode(const QString &code)
-{ _code = code; }
-
-void Engine::addComment(int pos, int len, int line, int col)
-{ if (len > 0) _comments.append(QDeclarativeJS::AST::SourceLocation(pos, len, line, col)); }
-
-QList<QDeclarativeJS::AST::SourceLocation> Engine::comments() const
-{ return _comments; }
-
-Lexer *Engine::lexer() const
-{ return _lexer; }
-
-void Engine::setLexer(Lexer *lexer)
-{ _lexer = lexer; }
-
-MemoryPool *Engine::pool()
-{ return &_pool; }
-
-QStringRef Engine::newStringRef(const QString &text)
-{
- const int pos = _extraCode.length();
- _extraCode += text;
- return _extraCode.midRef(pos, text.length());
-}
-
-QStringRef Engine::newStringRef(const QChar *chars, int size)
-{ return newStringRef(QString(chars, size)); }
-
-} // end of namespace QDeclarativeJS
-
-QT_QML_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.h b/src/declarative/qml/parser/qdeclarativejsengine_p.h
deleted file mode 100644
index db8a462d3f..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsengine_p.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEJSENGINE_P_H
-#define QDECLARATIVEJSENGINE_P_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 "qdeclarativejsglobal_p.h"
-#include "qdeclarativejsastfwd_p.h"
-#include "qdeclarativejsmemorypool_p.h"
-
-#include <QString>
-#include <QSet>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-class Lexer;
-class MemoryPool;
-
-class QML_PARSER_EXPORT DiagnosticMessage
-{
-public:
- enum Kind { Warning, Error };
-
- DiagnosticMessage()
- : kind(Error) {}
-
- DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
- : kind(kind), loc(loc), message(message) {}
-
- bool isWarning() const
- { return kind == Warning; }
-
- bool isError() const
- { return kind == Error; }
-
- Kind kind;
- AST::SourceLocation loc;
- QString message;
-};
-
-class QML_PARSER_EXPORT Engine
-{
- Lexer *_lexer;
- MemoryPool _pool;
- QList<AST::SourceLocation> _comments;
- QString _extraCode;
- QString _code;
-
-public:
- Engine();
- ~Engine();
-
- void setCode(const QString &code);
-
- void addComment(int pos, int len, int line, int col);
- QList<AST::SourceLocation> comments() const;
-
- Lexer *lexer() const;
- void setLexer(Lexer *lexer);
-
- MemoryPool *pool();
-
- inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); }
-
- QStringRef newStringRef(const QString &s);
- QStringRef newStringRef(const QChar *chars, int size);
-};
-
-double integerFromString(const char *buf, int size, int radix);
-
-} // end of namespace QDeclarativeJS
-
-QT_QML_END_NAMESPACE
-
-#endif // QDECLARATIVEJSENGINE_P_H
diff --git a/src/declarative/qml/parser/qdeclarativejsglobal_p.h b/src/declarative/qml/parser/qdeclarativejsglobal_p.h
deleted file mode 100644
index 993f4ae3dc..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsglobal_p.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QDECLARATIVEJSGLOBAL_P_H
-#define QDECLARATIVEJSGLOBAL_P_H
-
-#include <QtCore/qglobal.h>
-
-#ifdef QT_CREATOR
-# define QT_QML_BEGIN_NAMESPACE
-# define QT_QML_END_NAMESPACE
-
-# ifdef QDECLARATIVEJS_BUILD_DIR
-# define QML_PARSER_EXPORT Q_DECL_EXPORT
-# elif QML_BUILD_STATIC_LIB
-# define QML_PARSER_EXPORT
-# else
-# define QML_PARSER_EXPORT Q_DECL_IMPORT
-# endif // QDECLARATIVEJS_BUILD_DIR
-
-#else // !QT_CREATOR
-# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
-# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
-# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB)
- // QmlDevTools is a static library
-# define QML_PARSER_EXPORT
-# else
-# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT
-# endif
-#endif // QT_CREATOR
-
-#endif // QDECLARATIVEJSGLOBAL_P_H
diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
deleted file mode 100644
index 1e509e5651..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
+++ /dev/null
@@ -1,1013 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// This file was generated by qlalr - DO NOT EDIT!
-#include "qdeclarativejsgrammar_p.h"
-
-QT_BEGIN_NAMESPACE
-
-const char *const QDeclarativeJSGrammar::spell [] = {
- "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ",", "continue",
- "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===",
- "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier",
- "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=",
- "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=",
- "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return",
- ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch",
- "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^",
- "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", "public",
- "import", "as", "on", 0, 0, 0, 0, 0, 0, 0,
- 0, 0};
-
-const short QDeclarativeJSGrammar::lhs [] = {
- 102, 102, 102, 102, 102, 102, 103, 109, 109, 112,
- 112, 114, 113, 113, 113, 113, 113, 113, 113, 113,
- 116, 111, 110, 119, 119, 120, 120, 121, 121, 118,
- 107, 107, 107, 107, 123, 123, 123, 123, 123, 123,
- 123, 107, 131, 131, 131, 132, 132, 133, 133, 107,
- 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
- 107, 107, 107, 107, 107, 107, 117, 117, 117, 117,
- 117, 136, 136, 136, 136, 136, 136, 136, 136, 136,
- 136, 136, 136, 136, 136, 136, 136, 136, 136, 122,
- 138, 138, 138, 138, 137, 137, 140, 140, 142, 142,
- 142, 142, 142, 142, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 144, 144, 115, 115, 115,
- 115, 115, 147, 147, 148, 148, 148, 148, 146, 146,
- 149, 149, 150, 150, 151, 151, 151, 152, 152, 152,
- 152, 152, 152, 152, 152, 152, 152, 153, 153, 153,
- 153, 154, 154, 154, 155, 155, 155, 155, 156, 156,
- 156, 156, 156, 156, 156, 157, 157, 157, 157, 157,
- 157, 158, 158, 158, 158, 158, 159, 159, 159, 159,
- 159, 160, 160, 161, 161, 162, 162, 163, 163, 164,
- 164, 165, 165, 166, 166, 167, 167, 168, 168, 169,
- 169, 170, 170, 171, 171, 141, 141, 172, 172, 173,
- 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
- 173, 105, 105, 174, 174, 175, 175, 176, 176, 104,
- 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
- 104, 104, 104, 104, 124, 185, 185, 184, 184, 135,
- 135, 186, 186, 187, 187, 189, 189, 188, 190, 193,
- 191, 191, 194, 192, 192, 125, 126, 126, 127, 127,
- 177, 177, 177, 177, 177, 177, 177, 178, 178, 178,
- 178, 179, 179, 179, 179, 180, 180, 128, 129, 195,
- 195, 198, 198, 196, 196, 199, 197, 181, 181, 181,
- 182, 182, 130, 130, 130, 200, 201, 183, 183, 134,
- 145, 205, 205, 202, 202, 203, 203, 206, 108, 108,
- 207, 207, 106, 106, 204, 204, 139, 139, 208};
-
-const short QDeclarativeJSGrammar::rhs [] = {
- 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
- 2, 1, 2, 2, 3, 3, 5, 5, 4, 4,
- 2, 0, 1, 1, 2, 1, 3, 2, 3, 2,
- 1, 5, 4, 4, 1, 1, 1, 1, 1, 1,
- 1, 3, 1, 1, 1, 0, 1, 2, 4, 6,
- 6, 3, 3, 7, 7, 4, 4, 5, 5, 5,
- 6, 6, 10, 6, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 3, 3, 4, 5, 3, 4, 3, 1,
- 1, 2, 3, 4, 1, 2, 3, 5, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 4,
- 3, 5, 1, 2, 4, 4, 4, 3, 0, 1,
- 1, 3, 1, 1, 1, 2, 2, 1, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 1, 3, 3,
- 3, 1, 3, 3, 1, 3, 3, 3, 1, 3,
- 3, 3, 3, 3, 3, 1, 3, 3, 3, 3,
- 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
- 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
- 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
- 3, 1, 5, 1, 5, 1, 3, 1, 3, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 3, 0, 1, 1, 3, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 3, 1, 2, 0, 1, 3,
- 3, 1, 1, 1, 3, 1, 3, 2, 2, 2,
- 0, 1, 2, 0, 1, 1, 2, 2, 7, 5,
- 7, 7, 5, 9, 10, 7, 8, 2, 2, 3,
- 3, 2, 2, 3, 3, 3, 3, 5, 5, 3,
- 5, 1, 2, 0, 1, 4, 3, 3, 3, 3,
- 3, 3, 3, 3, 4, 5, 2, 2, 2, 8,
- 8, 1, 3, 0, 1, 0, 1, 1, 1, 1,
- 1, 2, 1, 1, 0, 1, 0, 1, 2};
-
-const short QDeclarativeJSGrammar::action_default [] = {
- 0, 0, 22, 0, 0, 0, 22, 0, 175, 242,
- 206, 214, 210, 154, 226, 202, 3, 139, 73, 155,
- 218, 222, 143, 172, 153, 158, 138, 192, 179, 0,
- 80, 81, 76, 345, 67, 347, 0, 0, 0, 0,
- 78, 0, 0, 74, 77, 71, 0, 0, 68, 70,
- 69, 79, 72, 0, 75, 0, 0, 168, 0, 0,
- 155, 174, 157, 156, 0, 0, 0, 170, 171, 169,
- 173, 0, 203, 0, 0, 0, 0, 193, 0, 0,
- 0, 0, 0, 0, 183, 0, 0, 0, 177, 178,
- 176, 181, 185, 184, 182, 180, 195, 194, 196, 0,
- 211, 0, 207, 0, 0, 149, 136, 148, 137, 105,
- 106, 107, 132, 108, 133, 109, 110, 111, 112, 113,
- 114, 115, 116, 117, 118, 119, 120, 121, 134, 122,
- 123, 124, 125, 126, 127, 128, 129, 130, 131, 135,
- 0, 0, 147, 243, 150, 0, 151, 0, 152, 146,
- 0, 239, 232, 230, 237, 238, 236, 235, 241, 234,
- 233, 231, 240, 227, 0, 215, 0, 0, 219, 0,
- 0, 223, 0, 0, 149, 141, 0, 140, 0, 145,
- 159, 0, 346, 334, 335, 0, 332, 0, 333, 0,
- 336, 250, 257, 256, 264, 252, 0, 253, 337, 0,
- 344, 254, 255, 260, 258, 341, 338, 343, 261, 0,
- 272, 0, 0, 0, 0, 345, 67, 0, 347, 68,
- 244, 286, 69, 0, 0, 0, 273, 0, 0, 262,
- 263, 0, 251, 259, 287, 288, 331, 342, 0, 302,
- 303, 304, 305, 0, 298, 299, 300, 301, 328, 329,
- 0, 0, 0, 0, 0, 291, 292, 248, 246, 208,
- 216, 212, 228, 204, 249, 0, 155, 220, 224, 197,
- 186, 0, 0, 205, 0, 0, 0, 0, 198, 0,
- 0, 0, 0, 0, 190, 188, 191, 189, 187, 200,
- 199, 201, 0, 213, 0, 209, 0, 247, 155, 0,
- 229, 244, 245, 0, 244, 0, 0, 294, 0, 0,
- 0, 296, 0, 217, 0, 0, 221, 0, 0, 225,
- 284, 0, 276, 285, 279, 0, 283, 0, 244, 277,
- 0, 244, 0, 0, 295, 0, 0, 0, 297, 346,
- 334, 0, 0, 336, 0, 330, 0, 320, 0, 0,
- 0, 290, 0, 289, 0, 348, 0, 104, 266, 269,
- 0, 105, 272, 108, 133, 110, 111, 76, 115, 116,
- 67, 117, 120, 74, 77, 68, 244, 69, 79, 123,
- 72, 125, 75, 127, 128, 273, 130, 131, 135, 0,
- 97, 0, 0, 99, 103, 101, 88, 100, 102, 0,
- 98, 87, 267, 265, 143, 144, 149, 0, 142, 0,
- 319, 0, 306, 307, 0, 318, 0, 0, 0, 309,
- 314, 312, 315, 0, 0, 313, 314, 0, 310, 0,
- 311, 268, 317, 0, 268, 316, 0, 321, 322, 0,
- 268, 323, 324, 0, 0, 325, 0, 0, 0, 326,
- 327, 161, 160, 0, 0, 0, 293, 0, 0, 0,
- 308, 281, 274, 0, 282, 278, 0, 280, 270, 0,
- 271, 275, 91, 0, 0, 95, 82, 0, 84, 93,
- 0, 85, 94, 96, 86, 92, 83, 0, 89, 165,
- 163, 167, 164, 162, 166, 339, 6, 340, 4, 2,
- 65, 90, 0, 0, 68, 70, 69, 31, 5, 0,
- 66, 0, 45, 44, 43, 0, 0, 58, 0, 59,
- 35, 36, 37, 38, 40, 41, 62, 39, 0, 45,
- 0, 0, 0, 0, 0, 54, 0, 55, 0, 0,
- 26, 0, 0, 63, 27, 0, 30, 28, 24, 0,
- 29, 25, 0, 56, 0, 57, 143, 0, 60, 64,
- 0, 0, 0, 0, 61, 0, 52, 46, 53, 47,
- 0, 0, 0, 0, 49, 0, 50, 51, 48, 0,
- 0, 143, 268, 0, 0, 42, 105, 272, 108, 133,
- 110, 111, 76, 115, 116, 67, 117, 120, 74, 77,
- 68, 244, 69, 79, 123, 72, 125, 75, 127, 128,
- 273, 130, 131, 135, 0, 32, 33, 0, 34, 8,
- 0, 10, 0, 9, 0, 1, 21, 12, 0, 13,
- 0, 14, 0, 19, 20, 0, 15, 16, 0, 17,
- 18, 11, 23, 7, 349};
-
-const short QDeclarativeJSGrammar::goto_default [] = {
- 7, 625, 207, 196, 205, 508, 496, 624, 643, 495,
- 623, 621, 626, 22, 622, 18, 507, 549, 539, 546,
- 541, 526, 191, 195, 197, 201, 233, 208, 230, 530,
- 570, 569, 200, 232, 26, 474, 473, 356, 355, 9,
- 354, 357, 107, 17, 145, 24, 13, 144, 19, 25,
- 57, 23, 8, 28, 27, 269, 15, 263, 10, 259,
- 12, 261, 11, 260, 20, 267, 21, 268, 14, 262,
- 258, 299, 411, 264, 265, 202, 193, 192, 204, 203,
- 229, 194, 360, 359, 231, 463, 462, 321, 322, 465,
- 324, 464, 323, 419, 423, 426, 422, 421, 441, 442,
- 185, 199, 181, 184, 198, 206, 0};
-
-const short QDeclarativeJSGrammar::action_index [] = {
- 404, 1275, 2411, 2411, 2509, 1000, 68, 92, 90, -102,
- 88, 62, 60, 256, -102, 298, 86, -102, -102, 638,
- 83, 134, 172, 219, -102, -102, -102, 454, 194, 1275,
- -102, -102, -102, 381, -102, 2215, 1555, 1275, 1275, 1275,
- -102, 790, 1275, -102, -102, -102, 1275, 1275, -102, -102,
- -102, -102, -102, 1275, -102, 1275, 1275, -102, 1275, 1275,
- 102, 217, -102, -102, 1275, 1275, 1275, -102, -102, -102,
- 204, 1275, 304, 1275, 1275, 1275, 1275, 539, 1275, 1275,
- 1275, 1275, 1275, 1275, 308, 1275, 1275, 1275, 103, 131,
- 135, 308, 210, 225, 216, 308, 444, 390, 434, 1275,
- 82, 1275, 100, 2117, 1275, 1275, -102, -102, -102, -102,
- -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
- -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
- -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
- 139, 1275, -102, -102, 91, 10, -102, 1275, -102, -102,
- 1275, -102, -102, -102, -102, -102, -102, -102, -102, -102,
- -102, -102, -102, -102, 1275, 26, 1275, 1275, 69, 66,
- 1275, -102, 2117, 1275, 1275, -102, 97, -102, 44, -102,
- -102, 67, -102, 297, 78, 24, -102, 291, -102, 36,
- 2411, -102, -102, -102, -102, -102, 234, -102, -102, 12,
- -102, -102, -102, -102, -102, -102, 2411, -102, -102, 464,
- -102, 461, 115, 2509, 42, 381, 58, 46, 2705, 70,
- 1275, -102, 74, 57, 1275, 65, -102, 59, 61, -102,
- -102, 367, -102, -102, -102, -102, -102, -102, 106, -102,
- -102, -102, -102, 87, -102, -102, -102, -102, -102, -102,
- 56, 55, 1275, 99, 84, -102, -102, 1461, -102, 75,
- 48, 52, -102, 306, 72, 53, 579, 77, 110, 370,
- 230, 381, 1275, 286, 1275, 1275, 1275, 1275, 380, 1275,
- 1275, 1275, 1275, 1275, 184, 169, 166, 190, 198, 460,
- 363, 353, 1275, 50, 1275, 63, 1275, -102, 638, 1275,
- -102, 1275, 64, 39, 1275, 30, 2509, -102, 1275, 173,
- 2509, -102, 1275, 79, 1275, 1275, 81, 80, 1275, -102,
- 71, 149, 32, -102, -102, 1275, -102, 381, 1275, -102,
- 73, 1275, 76, 2509, -102, 1275, 142, 2509, -102, -16,
- 381, -42, -12, 2411, -39, -102, 2509, -102, 1275, 154,
- 2509, 14, 2509, -102, 20, 16, -32, -102, -102, 2509,
- -51, 519, -4, 511, 136, 1275, 2509, -2, -35, 395,
- -1, -27, 908, 4, 6, -102, 1370, -102, 0, -36,
- 27, 1275, 47, 22, 1275, 45, 1275, 21, 17, 1275,
- -102, 2313, 144, -102, -102, -102, -102, -102, -102, 1275,
- -102, -102, -102, -102, 274, -102, 1275, -21, -102, 2509,
- -102, 138, -102, -102, 2509, -102, 1275, 132, 5, -102,
- 40, -102, 41, 101, 1275, -102, 38, 34, -102, -38,
- -102, 2509, -102, 105, 2509, -102, 245, -102, -102, 96,
- 2509, 11, -102, -7, -11, -102, 352, 8, 18, -102,
- -102, -102, -102, 1275, 129, 2509, -102, 1275, 130, 2509,
- -102, 49, -102, 226, -102, -102, 1275, -102, -102, 362,
- -102, -102, -102, 107, 1837, -102, -102, 1649, -102, -102,
- 1743, -102, -102, -102, -102, -102, -102, 114, -102, -102,
- -102, -102, -102, -102, -102, -102, -102, 2411, -102, -102,
- -102, 94, 9, 818, 189, -10, 31, -102, -102, 223,
- -102, 191, -102, -102, -102, 300, 178, -102, 1928, -102,
- -102, -102, -102, -102, -102, -102, -102, -102, 257, -25,
- 381, 195, -22, 305, 240, -102, -6, -102, 818, 127,
- -102, -18, 818, -102, -102, 1184, -102, -102, -102, 1092,
- -102, -102, 237, -102, 1928, -102, 294, -8, -102, -102,
- 176, 381, 19, 1928, -102, 165, -102, 174, -102, 2,
- -52, 381, 183, 381, -102, 117, -102, -102, -102, 2019,
- 880, 285, 2607, 1555, 3, -102, 522, 35, 453, 108,
- 1275, 2509, 51, 23, 475, 54, -17, 700, 7, 43,
- -102, 1370, -102, 28, -3, 33, 1275, 37, 15, 1275,
- 25, 1275, 1, 13, 124, -102, -102, 29, -102, -102,
- 728, -102, 250, -43, 627, -102, -102, 231, 372, -102,
- 222, -102, 111, -102, -102, 381, -102, -102, 104, -102,
- -102, -102, -102, -102, -102,
-
- -107, 9, -103, 2, 5, 266, 1, -107, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, -39,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, 86,
- -107, -107, -107, 8, -107, -107, -22, 19, 71, 174,
- -107, 186, 171, -107, -107, -107, 184, 178, -107, -107,
- -107, -107, -107, 144, -107, 124, 150, -107, 165, 161,
- -107, -107, -107, -107, 156, 160, 157, -107, -107, -107,
- -107, 147, -107, 142, 135, 179, 166, -107, 177, 170,
- 117, 72, 134, 92, -107, 75, 94, 66, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, 181,
- -107, 106, -107, 143, 78, 55, -107, -107, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, -5, -107, -107, -107, -107, -107, 54, -107, -107,
- 51, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, -107, -107, -107, 114, -107, 113, 38, -107, -107,
- 41, -107, 231, 63, 112, -107, -107, -107, -107, -107,
- -107, -107, -107, 30, -107, -107, -107, 52, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, -107, -107, -107, -107, -107, 36, -107, -107, 45,
- -107, 42, -107, 40, -107, 80, -107, -107, 77, -107,
- 88, -107, -107, -107, 83, 74, -107, -107, -107, -107,
- -107, -10, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, -107, 23, -107, -107, -107, -107, 100, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, 4, 223, -107, 230, 236, 222, 205, -107, 127,
- 125, 115, 96, 102, -107, -107, -107, -107, -107, -107,
- -107, -107, 234, -107, 215, -107, 199, -107, -107, 197,
- -107, 190, -107, -107, 163, -107, 90, -107, 0, -107,
- -1, -107, 203, -107, 189, 211, -107, -107, 195, -107,
- -107, -107, -107, -107, -107, 191, -107, 98, 119, -107,
- -107, 95, -107, 81, -107, 79, -107, 82, -107, -107,
- 101, -107, -107, -16, -107, -107, 53, -107, 46, -107,
- 57, -107, 59, -107, -107, -107, -107, -107, -107, 35,
- -107, 33, -107, 39, -107, 89, 67, -107, -107, 58,
- -107, -107, 84, -107, -107, -107, 73, -107, -107, -107,
- -107, 65, -107, 43, 93, -107, 109, -107, -107, 49,
- -107, 47, -107, -107, -107, -107, -107, -107, -107, 50,
- -107, -107, -107, -107, -107, -107, 108, -107, -107, 61,
- -107, -107, -107, -107, 62, -107, 68, -107, -107, -107,
- -107, -107, -23, -107, 69, -107, -19, -107, -107, -107,
- -107, 97, -107, -107, 99, -107, -107, -107, -107, -107,
- 60, -61, -107, -107, 34, -107, 37, -107, 29, -107,
- -107, -107, -107, 32, -107, 76, -107, 44, -107, 56,
- -107, -107, -107, -107, -107, -107, 31, -107, -107, 116,
- -107, -107, -107, -107, -6, -107, -107, 70, -107, -107,
- 64, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -107, -107, -107, -107, -107, -107, -107, 193, -107, -107,
- -107, -107, -107, 7, -107, -107, -107, -107, -107, -107,
- -107, -20, -107, -107, -107, -7, -107, -107, 290, -107,
- -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
- -2, -25, -107, -15, -107, -107, -107, -107, 172, -107,
- -107, -107, 287, -107, -107, 288, -107, -107, -107, 291,
- -107, -107, -107, -107, 336, -107, -107, 20, -107, -107,
- 15, 3, -107, 304, -107, -107, -107, 24, -107, -107,
- -107, 28, 21, 26, -107, -107, -107, -107, -107, 320,
- 104, -107, 13, 381, -3, -107, 6, -107, 10, -107,
- 167, 22, -107, -107, 12, -107, -107, 87, -107, -107,
- -107, 25, -107, -107, -107, -107, 11, -107, 14, 85,
- -107, 121, -107, -107, -107, -107, -107, 27, -107, -107,
- 17, -107, -107, 18, 91, -107, -107, -107, 16, -107,
- -107, -107, -107, -107, -107, -4, -107, -107, -107, -107,
- -107, -107, -107, -107, -107};
-
-const short QDeclarativeJSGrammar::action_info [] = {
- 416, 257, 533, -132, 403, -113, 346, -102, 575, 348,
- 572, -121, 531, -103, -121, 545, 345, 430, 342, 348,
- 340, 343, 440, 401, 391, 545, 563, 389, 538, 446,
- 352, 444, -129, 416, -124, -102, 545, 453, 420, 408,
- -124, 431, -132, 424, -126, 424, 424, 620, 440, 457,
- -103, 440, -129, 457, -126, 440, 560, 453, -113, 257,
- 565, 346, 545, 335, 272, 346, 466, 236, 448, 190,
- 149, 164, 141, 170, 99, 511, 272, 409, 257, 312,
- 296, 414, 348, 312, 189, 164, 187, 318, 325, 71,
- 306, 252, 644, 416, 141, 453, 292, 457, 440, 147,
- 304, 71, 443, 183, 179, 141, 0, 141, 0, 172,
- 99, 427, 434, 141, 301, 477, 444, 0, 0, 0,
- 0, 0, 141, 0, 0, 0, 0, 292, 173, 294,
- 58, 294, 542, 251, 331, 542, 333, 141, 141, 101,
- 141, 59, 0, 58, 62, 256, 255, 141, 247, 246,
- 141, 399, 0, 177, 59, 63, 428, 327, 620, 254,
- 314, 101, 141, 478, 315, 640, 639, 242, 241, 249,
- 248, 58, 634, 633, 488, 58, 249, 248, 577, 576,
- 615, 141, 59, 543, 166, 518, 59, 172, 167, 455,
- 459, 85, 418, 86, 85, 142, 86, 249, 248, 413,
- 412, 567, 337, 512, 87, 512, 173, 87, 174, 85,
- 328, 86, 512, 0, 350, 85, 64, 86, 529, 85,
- 512, 86, 87, 85, 512, 86, 568, 566, 87, 64,
- 579, 64, 87, 310, 469, 85, 87, 86, 0, 519,
- 517, 85, 141, 86, 554, 0, 172, 536, 87, 514,
- 85, 514, 86, 141, 87, 85, 545, 86, 514, 0,
- 513, 65, 513, 87, 514, 173, 514, 66, 87, 513,
- 514, 103, 172, 0, 65, 513, 65, 513, 0, 0,
- 66, 513, 66, 637, 636, 0, 0, 470, 468, 172,
- 104, 173, 105, 406, 0, 235, 234, 630, 555, 553,
- 172, 537, 535, 0, 274, 275, 438, 437, 173, 172,
- 406, 631, 629, 635, 0, 580, 73, 74, -90, 173,
- 34, 174, 73, 74, 274, 275, 34, -90, 173, 34,
- 174, 276, 277, 85, 34, 86, 0, 0, 0, 0,
- 0, 628, 0, 75, 76, 0, 87, 0, 0, 75,
- 76, 276, 277, 0, 0, 0, 0, 48, 50, 49,
- 0, 0, 0, 48, 50, 49, 48, 50, 49, 0,
- 0, 48, 50, 49, 0, 0, 279, 280, 0, 0,
- 0, 34, 0, 45, 0, 281, 279, 280, 282, 45,
- 283, 34, 45, 279, 280, 281, 34, 45, 282, 0,
- 283, 34, 281, 279, 280, 282, 0, 283, 0, 0,
- 34, 0, 281, 78, 79, 282, 0, 283, 48, 50,
- 49, 80, 81, 0, 34, 82, 0, 83, 48, 50,
- 49, -345, 0, 48, 50, 49, 0, 0, 48, 50,
- 49, 0, 0, 0, 45, 0, 0, 48, 50, 49,
- 0, 0, 0, 0, 45, 0, 0, 78, 79, 45,
- 0, 48, 50, 49, 45, 80, 81, 78, 79, 82,
- 0, 83, 0, 45, 0, 80, 81, 78, 79, 82,
- 0, 83, 34, 279, 280, 80, 81, 45, 0, 82,
- 34, 83, 281, 34, 0, 282, 0, 283, 6, 5,
- 4, 1, 3, 2, 34, 0, 0, 0, 0, 0,
- 0, -345, 0, 0, 245, 244, 0, 0, 0, 48,
- 50, 49, 245, 244, 0, 240, 239, 48, 50, 49,
- 48, 50, 49, 0, 0, 0, 0, 0, 0, 0,
- 34, 48, 50, 49, 0, 45, 0, 0, 34, 0,
- 0, 34, 0, 45, 0, 0, 45, 0, 0, 0,
- 0, 0, 78, 79, 0, 0, 0, 45, 0, 0,
- 80, 81, 245, 244, 82, 0, 83, 48, 50, 49,
- 240, 239, 151, 240, 239, 48, 50, 49, 48, 50,
- 49, 0, 152, 0, 0, 0, 153, 0, 0, 0,
- 0, 0, 0, 45, 0, 154, 0, 155, 0, 0,
- 308, 45, 0, 0, 45, 0, 0, 0, 156, 0,
- 157, 62, 0, 0, 0, 0, 0, 0, 158, 0,
- 0, 159, 63, 0, 0, 0, 0, 160, 0, 30,
- 31, 151, 0, 161, 0, 0, 0, 0, 0, 33,
- 0, 152, 0, 0, 0, 153, 34, 0, 0, 162,
- 35, 36, 0, 37, 154, 0, 155, 0, 0, 0,
- 503, 0, 0, 0, 44, 0, 0, 156, 0, 157,
- 62, 0, 0, 0, 0, 0, 0, 158, 0, 0,
- 159, 63, 51, 48, 50, 49, 160, 52, 0, 0,
- 0, 0, 161, 0, 0, 0, 0, 0, 43, 54,
- 32, 0, 30, 31, 40, 0, 0, 0, 162, 45,
- 0, 0, 33, 0, 0, 0, 0, 0, 0, 34,
- 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
- 30, 31, 0, 41, 0, 0, 0, 44, 0, 0,
- 33, 0, 0, 0, 0, 0, 0, 34, 0, 0,
- 0, 35, 36, 0, 37, 51, 48, 50, 49, 0,
- 52, 503, 0, 0, 0, 44, 0, 0, 0, 0,
- 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
- 0, 0, 45, 51, 48, 50, 49, 0, 52, 0,
- 0, 0, 30, 31, 0, 0, 0, 0, 0, 43,
- 54, 32, 33, 0, 0, 40, 0, 0, 0, 34,
- 45, 0, 0, 35, 36, 0, 37, 0, 0, 0,
- 30, 31, 0, 41, 0, 0, 0, 44, 0, 0,
- 33, 0, 0, 0, 0, 0, 0, 34, 0, 0,
- 0, 35, 36, 0, 37, 51, 48, 50, 49, 0,
- 52, 503, 0, 0, 0, 44, 0, 0, 0, 0,
- 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
- 0, 0, 45, 51, 48, 50, 49, 0, 52, 0,
- 0, 0, 30, 31, 0, 0, 0, 0, 0, 43,
- 54, 32, 33, 0, 0, 40, 0, 0, 0, 34,
- 45, 0, 0, 35, 36, 0, 37, 0, 0, 0,
- 30, 31, 0, 503, 0, 0, 0, 44, 0, 0,
- 33, 0, 0, 0, 0, 0, 0, 34, 0, 0,
- 0, 35, 36, 0, 37, 51, 48, 50, 49, 0,
- 52, 41, 0, 0, 0, 44, 0, 0, 0, 0,
- 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
- 0, 0, 45, 51, 48, 50, 49, 0, 52, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 43,
- 54, 32, 0, 0, 0, 40, 0, 0, 0, 0,
- 45, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 502, 0, 30, 31, 0, 0, 0, 0, 0, 0,
- 0, 0, 215, 0, 0, 0, 0, 0, 0, 34,
- 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
- 0, 0, 0, 503, 0, 0, 0, 44, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 51, 504, 506, 505, 0,
- 52, 0, 0, 0, 0, 226, 0, 0, 0, 0,
- 0, 43, 54, 32, 210, 0, 0, 40, 0, 0,
- 0, 0, 45, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 502, 0, 30, 31, 0, 0, 0, 0,
- 0, 0, 0, 0, 215, 0, 0, 0, 0, 0,
- 0, 34, 0, 0, 0, 35, 36, 0, 37, 0,
- 0, 0, 0, 0, 0, 503, 0, 0, 0, 44,
- 0, 0, 0, 0, 0, 0, 0, 550, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 51, 504, 506,
- 505, 0, 52, 0, 0, 0, 0, 226, 0, 0,
- 0, 0, 0, 43, 54, 32, 210, 0, 0, 40,
- 0, 0, 0, 0, 45, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 502, 0, 30, 31, 0, 0,
- 0, 0, 0, 0, 0, 0, 215, 0, 0, 0,
- 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
- 37, 0, 0, 0, 0, 0, 0, 503, 0, 0,
- 0, 44, 0, 0, 0, 0, 0, 0, 0, 547,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 51,
- 504, 506, 505, 0, 52, 0, 0, 0, 0, 226,
- 0, 0, 0, 0, 0, 43, 54, 32, 210, 0,
- 0, 40, 0, 0, 0, 0, 45, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 29, 30, 31, 0,
- 0, 0, 0, 0, 0, 0, 0, 33, 0, 0,
- 0, 0, 0, 0, 34, 0, 0, 0, 35, 36,
- 0, 37, 0, 0, 0, 38, 0, 39, 41, 42,
- 0, 0, 44, 0, 0, 0, 46, 0, 47, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 51, 48, 50, 49, 0, 52, 0, 53, 0, 55,
- 0, 56, 0, 0, 0, 0, 43, 54, 32, 0,
- 0, 0, 40, 0, 0, 0, 0, 45, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, -122, 0, 0,
- 0, 29, 30, 31, 0, 0, 0, 0, 0, 0,
- 0, 0, 33, 0, 0, 0, 0, 0, 0, 34,
- 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
- 38, 0, 39, 41, 42, 0, 0, 44, 0, 0,
- 0, 46, 0, 47, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 51, 48, 50, 49, 0,
- 52, 0, 53, 0, 55, 0, 56, 0, 0, 0,
- 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
- 0, 0, 45, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 29, 30, 31, 0, 0, 0, 0, 0,
- 0, 0, 0, 33, 0, 0, 0, 0, 0, 0,
- 34, 0, 0, 0, 35, 36, 0, 37, 0, 0,
- 0, 38, 0, 39, 41, 42, 0, 0, 44, 0,
- 0, 0, 46, 0, 47, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 51, 48, 50, 49,
- 0, 52, 0, 53, 0, 55, 271, 56, 0, 0,
- 0, 0, 43, 54, 32, 0, 0, 0, 40, 0,
- 0, 0, 0, 45, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 475, 0, 0, 29, 30, 31, 0,
- 0, 0, 0, 0, 0, 0, 0, 33, 0, 0,
- 0, 0, 0, 0, 34, 0, 0, 0, 35, 36,
- 0, 37, 0, 0, 0, 38, 0, 39, 41, 42,
- 0, 0, 44, 0, 0, 0, 46, 0, 47, 0,
- 0, 476, 0, 0, 0, 0, 0, 0, 0, 0,
- 51, 48, 50, 49, 0, 52, 0, 53, 0, 55,
- 0, 56, 0, 0, 0, 0, 43, 54, 32, 0,
- 0, 0, 40, 0, 0, 0, 0, 45, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 475, 0, 0,
- 29, 30, 31, 0, 0, 0, 0, 0, 0, 0,
- 0, 33, 0, 0, 0, 0, 0, 0, 34, 0,
- 0, 0, 35, 36, 0, 37, 0, 0, 0, 38,
- 0, 39, 41, 42, 0, 0, 44, 0, 0, 0,
- 46, 0, 47, 0, 0, 481, 0, 0, 0, 0,
- 0, 0, 0, 0, 51, 48, 50, 49, 0, 52,
- 0, 53, 0, 55, 0, 56, 0, 0, 0, 0,
- 43, 54, 32, 0, 0, 0, 40, 0, 0, 0,
- 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 483, 0, 0, 29, 30, 31, 0, 0, 0,
- 0, 0, 0, 0, 0, 33, 0, 0, 0, 0,
- 0, 0, 34, 0, 0, 0, 35, 36, 0, 37,
- 0, 0, 0, 38, 0, 39, 41, 42, 0, 0,
- 44, 0, 0, 0, 46, 0, 47, 0, 0, 484,
- 0, 0, 0, 0, 0, 0, 0, 0, 51, 48,
- 50, 49, 0, 52, 0, 53, 0, 55, 0, 56,
- 0, 0, 0, 0, 43, 54, 32, 0, 0, 0,
- 40, 0, 0, 0, 0, 45, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 483, 0, 0, 29, 30,
- 31, 0, 0, 0, 0, 0, 0, 0, 0, 33,
- 0, 0, 0, 0, 0, 0, 34, 0, 0, 0,
- 35, 36, 0, 37, 0, 0, 0, 38, 0, 39,
- 41, 42, 0, 0, 44, 0, 0, 0, 46, 0,
- 47, 0, 0, 486, 0, 0, 0, 0, 0, 0,
- 0, 0, 51, 48, 50, 49, 0, 52, 0, 53,
- 0, 55, 0, 56, 0, 0, 0, 0, 43, 54,
- 32, 0, 0, 0, 40, 0, 0, 0, 0, 45,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
- 30, 31, 0, 0, 0, 0, 0, 0, 0, 0,
- 33, 0, 0, 0, 0, 0, 0, 34, 217, 0,
- 0, 218, 36, 0, 37, 0, 0, 0, 38, 0,
- 39, 41, 42, 0, 0, 44, 0, 0, 0, 46,
- 0, 47, 0, 0, 0, 0, 0, 0, 0, 221,
- 0, 0, 0, 51, 48, 50, 49, 223, 52, 0,
- 53, 225, 55, 0, 56, 0, 228, 0, 0, 43,
- 54, 32, 0, 0, 0, 40, 0, 0, 0, 0,
- 45, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 29, 30, 31, 0, 0, 0, 0, 0, 0, 0,
- 0, 33, 0, 0, 0, 0, 0, 0, 34, 217,
- 0, 0, 582, 583, 0, 37, 0, 0, 0, 38,
- 0, 39, 41, 42, 0, 0, 44, 0, 0, 0,
- 46, 0, 47, 0, 0, 0, 0, 0, 0, 0,
- 221, 0, 0, 0, 51, 48, 50, 49, 223, 52,
- 0, 53, 225, 55, 0, 56, 0, 228, 0, 0,
- 43, 54, 32, 0, 0, 0, 40, 0, 0, 0,
- 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 109, 110, 111, 0, 0, 113, 115, 116, 0,
- 0, 117, 0, 118, 0, 0, 0, 120, 121, 122,
- 0, 0, 0, 0, 0, 0, 34, 123, 124, 125,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 126, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 129, 0, 0, 0,
- 0, 0, 0, 48, 50, 49, 130, 131, 132, 0,
- 134, 135, 136, 137, 138, 139, 0, 0, 127, 133,
- 119, 112, 114, 128, 0, 0, 0, 0, 0, 45,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 109,
- 110, 111, 0, 0, 113, 115, 116, 0, 0, 117,
- 0, 118, 0, 0, 0, 120, 121, 122, 0, 0,
- 0, 0, 0, 0, 393, 123, 124, 125, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 126, 0,
- 0, 0, 394, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 129, 0, 0, 0, 0, 0,
- 398, 395, 397, 0, 130, 131, 132, 0, 134, 135,
- 136, 137, 138, 139, 0, 0, 127, 133, 119, 112,
- 114, 128, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 109, 110, 111,
- 0, 0, 113, 115, 116, 0, 0, 117, 0, 118,
- 0, 0, 0, 120, 121, 122, 0, 0, 0, 0,
- 0, 0, 393, 123, 124, 125, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 126, 0, 0, 0,
- 394, 0, 0, 0, 0, 0, 0, 0, 396, 0,
- 0, 0, 129, 0, 0, 0, 0, 0, 398, 395,
- 397, 0, 130, 131, 132, 0, 134, 135, 136, 137,
- 138, 139, 0, 0, 127, 133, 119, 112, 114, 128,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 209, 0, 0, 0, 0,
- 211, 0, 29, 30, 31, 213, 0, 0, 0, 0,
- 0, 0, 214, 215, 0, 0, 0, 0, 0, 0,
- 216, 217, 0, 0, 218, 36, 0, 37, 0, 0,
- 0, 38, 0, 39, 41, 42, 0, 0, 44, 0,
- 0, 0, 46, 0, 47, 0, 0, 0, 0, 0,
- 220, 0, 221, 0, 0, 0, 51, 219, 222, 49,
- 223, 52, 224, 53, 225, 55, 226, 56, 227, 228,
- 0, 0, 43, 54, 32, 210, 212, 0, 40, 0,
- 0, 0, 0, 45, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 209, 0, 0, 0, 0, 211, 0,
- 29, 30, 31, 213, 0, 0, 0, 0, 0, 0,
- 214, 33, 0, 0, 0, 0, 0, 0, 216, 217,
- 0, 0, 218, 36, 0, 37, 0, 0, 0, 38,
- 0, 39, 41, 42, 0, 0, 44, 0, 0, 0,
- 46, 0, 47, 0, 0, 0, 0, 0, 220, 0,
- 221, 0, 0, 0, 51, 219, 222, 49, 223, 52,
- 224, 53, 225, 55, 226, 56, 227, 228, 0, 0,
- 43, 54, 32, 210, 212, 0, 40, 0, 0, 0,
- 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 586, 110, 111, 0, 0, 588, 115, 590, 30,
- 31, 591, 0, 118, 0, 0, 0, 120, 593, 594,
- 0, 0, 0, 0, 0, 0, 595, 596, 124, 125,
- 218, 36, 0, 37, 0, 0, 0, 38, 0, 39,
- 597, 42, 0, 0, 599, 0, 0, 0, 46, 0,
- 47, 0, 0, 0, 0, 0, 601, 0, 221, 0,
- 0, 0, 603, 600, 602, 49, 604, 605, 606, 53,
- 608, 609, 610, 611, 612, 613, 0, 0, 598, 607,
- 592, 587, 589, 128, 40, 0, 0, 0, 0, 45,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 361,
- 110, 111, 0, 0, 363, 115, 365, 30, 31, 366,
- 0, 118, 0, 0, 0, 120, 368, 369, 0, 0,
- 0, 0, 0, 0, 370, 371, 124, 125, 218, 36,
- 0, 37, 0, 0, 0, 38, 0, 39, 372, 42,
- 0, 0, 374, 0, 0, 0, 46, 0, 47, 0,
- -268, 0, 0, 0, 376, 0, 221, 0, 0, 0,
- 378, 375, 377, 49, 379, 380, 381, 53, 383, 384,
- 385, 386, 387, 388, 0, 0, 373, 382, 367, 362,
- 364, 128, 40, 0, 0, 0, 0, 45, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-
- 534, 311, 497, 309, 532, 461, 498, 499, 516, 515,
- 619, 638, 16, 552, 436, 358, 616, 472, 562, 320,
- 528, 238, 487, 182, 250, 243, 253, 182, 302, 641,
- 627, 632, 150, 485, 143, 454, 439, 402, 445, 559,
- 237, 574, 250, 578, 561, 186, 618, 458, 238, 349,
- 573, 449, 447, 571, 243, 347, 450, 243, 460, 351,
- 238, 353, 358, 410, 415, 439, 176, 188, 436, 250,
- 467, 417, 433, 182, 425, 429, 302, 169, 456, 358,
- 171, 140, 336, 334, 338, 344, 436, 392, 390, 400,
- 163, 302, 307, 148, 146, 339, 439, 404, 302, 358,
- 404, 358, 0, 482, 501, 480, 0, 642, 0, 479,
- 0, 0, 0, 320, 60, 0, 186, 501, 90, 60,
- 60, 489, 302, 60, 617, 93, 0, 88, 0, 405,
- 0, 461, 405, 60, 60, 451, 180, 60, 0, 180,
- 60, 60, 60, 451, 60, 95, 89, 146, 266, 287,
- 60, 146, 407, 270, 60, 288, 178, 60, 106, 452,
- 0, 60, 60, 60, 102, 60, 302, 332, 286, 60,
- 92, 452, 60, 60, 451, 60, 165, 168, 285, 432,
- 284, 435, 60, 60, 108, 501, 329, 94, 540, 96,
- 60, 330, 60, 302, 494, 60, 77, 237, 60, 404,
- 452, 341, 471, 72, 60, 60, 67, 69, 60, 60,
- 68, 0, 70, 60, 60, 60, 61, 180, 60, 60,
- 98, 491, 60, 91, 490, 60, 60, 60, 493, 60,
- 84, 405, 60, 97, 492, 305, 0, 60, 0, 298,
- 0, 100, 270, 298, 270, 298, 106, 298, 270, 0,
- 270, 60, 270, 60, 316, 0, 270, 0, 270, 298,
- 291, 326, 303, 60, 270, 319, 313, 300, 270, 297,
- 60, 60, 108, 175, 295, 270, 270, 290, 60, 501,
- 273, 317, 60, 270, 60, 278, 509, 270, 0, 270,
- 0, 289, 0, 548, 0, 293, 551, 0, 500, 510,
- 501, 501, 0, 544, 501, 0, 0, 0, 509, 0,
- 0, 509, 520, 521, 522, 523, 527, 524, 525, 0,
- 500, 510, 0, 500, 510, 564, 520, 521, 522, 523,
- 527, 524, 525, 581, 0, 0, 0, 0, 0, 0,
- 584, 585, 520, 521, 522, 523, 527, 524, 525, 556,
- 0, 0, 0, 0, 0, 0, 557, 558, 520, 521,
- 522, 523, 527, 524, 525, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 556, 0, 0, 540, 0, 614,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 472, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0};
-
-const short QDeclarativeJSGrammar::action_check [] = {
- 36, 36, 24, 7, 55, 7, 7, 7, 60, 36,
- 8, 7, 37, 7, 7, 33, 55, 55, 60, 36,
- 36, 33, 33, 55, 8, 33, 7, 7, 34, 36,
- 16, 20, 7, 36, 7, 7, 33, 36, 33, 60,
- 7, 7, 7, 5, 7, 5, 5, 90, 33, 36,
- 7, 33, 7, 36, 7, 33, 66, 36, 7, 36,
- 29, 7, 33, 31, 1, 7, 17, 55, 60, 33,
- 60, 2, 8, 7, 48, 66, 1, 7, 36, 2,
- 8, 7, 36, 2, 60, 2, 8, 7, 17, 1,
- 60, 36, 0, 36, 8, 36, 48, 36, 33, 8,
- 61, 1, 6, 36, 60, 8, -1, 8, -1, 15,
- 48, 10, 7, 8, 61, 8, 20, -1, -1, -1,
- -1, -1, 8, -1, -1, -1, -1, 48, 34, 79,
- 40, 79, 8, 77, 61, 8, 60, 8, 8, 79,
- 8, 51, -1, 40, 42, 61, 62, 8, 61, 62,
- 8, 7, -1, 56, 51, 53, 55, 8, 90, 60,
- 50, 79, 8, 56, 54, 61, 62, 61, 62, 61,
- 62, 40, 61, 62, 60, 40, 61, 62, 61, 62,
- 56, 8, 51, 56, 50, 7, 51, 15, 54, 60,
- 60, 25, 60, 27, 25, 56, 27, 61, 62, 61,
- 62, 36, 60, 29, 38, 29, 34, 38, 36, 25,
- 61, 27, 29, -1, 60, 25, 12, 27, 29, 25,
- 29, 27, 38, 25, 29, 27, 61, 62, 38, 12,
- 7, 12, 38, 60, 8, 25, 38, 27, -1, 61,
- 62, 25, 8, 27, 7, -1, 15, 7, 38, 75,
- 25, 75, 27, 8, 38, 25, 33, 27, 75, -1,
- 86, 57, 86, 38, 75, 34, 75, 63, 38, 86,
- 75, 15, 15, -1, 57, 86, 57, 86, -1, -1,
- 63, 86, 63, 61, 62, -1, -1, 61, 62, 15,
- 34, 34, 36, 36, -1, 61, 62, 47, 61, 62,
- 15, 61, 62, -1, 18, 19, 61, 62, 34, 15,
- 36, 61, 62, 91, -1, 92, 18, 19, 33, 34,
- 29, 36, 18, 19, 18, 19, 29, 33, 34, 29,
- 36, 45, 46, 25, 29, 27, -1, -1, -1, -1,
- -1, 91, -1, 45, 46, -1, 38, -1, -1, 45,
- 46, 45, 46, -1, -1, -1, -1, 66, 67, 68,
- -1, -1, -1, 66, 67, 68, 66, 67, 68, -1,
- -1, 66, 67, 68, -1, -1, 23, 24, -1, -1,
- -1, 29, -1, 92, -1, 32, 23, 24, 35, 92,
- 37, 29, 92, 23, 24, 32, 29, 92, 35, -1,
- 37, 29, 32, 23, 24, 35, -1, 37, -1, -1,
- 29, -1, 32, 23, 24, 35, -1, 37, 66, 67,
- 68, 31, 32, -1, 29, 35, -1, 37, 66, 67,
- 68, 36, -1, 66, 67, 68, -1, -1, 66, 67,
- 68, -1, -1, -1, 92, -1, -1, 66, 67, 68,
- -1, -1, -1, -1, 92, -1, -1, 23, 24, 92,
- -1, 66, 67, 68, 92, 31, 32, 23, 24, 35,
- -1, 37, -1, 92, -1, 31, 32, 23, 24, 35,
- -1, 37, 29, 23, 24, 31, 32, 92, -1, 35,
- 29, 37, 32, 29, -1, 35, -1, 37, 94, 95,
- 96, 97, 98, 99, 29, -1, -1, -1, -1, -1,
- -1, 36, -1, -1, 61, 62, -1, -1, -1, 66,
- 67, 68, 61, 62, -1, 61, 62, 66, 67, 68,
- 66, 67, 68, -1, -1, -1, -1, -1, -1, -1,
- 29, 66, 67, 68, -1, 92, -1, -1, 29, -1,
- -1, 29, -1, 92, -1, -1, 92, -1, -1, -1,
- -1, -1, 23, 24, -1, -1, -1, 92, -1, -1,
- 31, 32, 61, 62, 35, -1, 37, 66, 67, 68,
- 61, 62, 3, 61, 62, 66, 67, 68, 66, 67,
- 68, -1, 13, -1, -1, -1, 17, -1, -1, -1,
- -1, -1, -1, 92, -1, 26, -1, 28, -1, -1,
- 31, 92, -1, -1, 92, -1, -1, -1, 39, -1,
- 41, 42, -1, -1, -1, -1, -1, -1, 49, -1,
- -1, 52, 53, -1, -1, -1, -1, 58, -1, 12,
- 13, 3, -1, 64, -1, -1, -1, -1, -1, 22,
- -1, 13, -1, -1, -1, 17, 29, -1, -1, 80,
- 33, 34, -1, 36, 26, -1, 28, -1, -1, -1,
- 43, -1, -1, -1, 47, -1, -1, 39, -1, 41,
- 42, -1, -1, -1, -1, -1, -1, 49, -1, -1,
- 52, 53, 65, 66, 67, 68, 58, 70, -1, -1,
- -1, -1, 64, -1, -1, -1, -1, -1, 81, 82,
- 83, -1, 12, 13, 87, -1, -1, -1, 80, 92,
- -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
- -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- 12, 13, -1, 43, -1, -1, -1, 47, -1, -1,
- 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
- -1, 33, 34, -1, 36, 65, 66, 67, 68, -1,
- 70, 43, -1, -1, -1, 47, -1, -1, -1, -1,
- -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
- -1, -1, 92, 65, 66, 67, 68, -1, 70, -1,
- -1, -1, 12, 13, -1, -1, -1, -1, -1, 81,
- 82, 83, 22, -1, -1, 87, -1, -1, -1, 29,
- 92, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- 12, 13, -1, 43, -1, -1, -1, 47, -1, -1,
- 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
- -1, 33, 34, -1, 36, 65, 66, 67, 68, -1,
- 70, 43, -1, -1, -1, 47, -1, -1, -1, -1,
- -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
- -1, -1, 92, 65, 66, 67, 68, -1, 70, -1,
- -1, -1, 12, 13, -1, -1, -1, -1, -1, 81,
- 82, 83, 22, -1, -1, 87, -1, -1, -1, 29,
- 92, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- 12, 13, -1, 43, -1, -1, -1, 47, -1, -1,
- 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
- -1, 33, 34, -1, 36, 65, 66, 67, 68, -1,
- 70, 43, -1, -1, -1, 47, -1, -1, -1, -1,
- -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
- -1, -1, 92, 65, 66, 67, 68, -1, 70, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 81,
- 82, 83, -1, -1, -1, 87, -1, -1, -1, -1,
- 92, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 10, -1, 12, 13, -1, -1, -1, -1, -1, -1,
- -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
- -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
- 70, -1, -1, -1, -1, 75, -1, -1, -1, -1,
- -1, 81, 82, 83, 84, -1, -1, 87, -1, -1,
- -1, -1, 92, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 10, -1, 12, 13, -1, -1, -1, -1,
- -1, -1, -1, -1, 22, -1, -1, -1, -1, -1,
- -1, 29, -1, -1, -1, 33, 34, -1, 36, -1,
- -1, -1, -1, -1, -1, 43, -1, -1, -1, 47,
- -1, -1, -1, -1, -1, -1, -1, 55, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,
- 68, -1, 70, -1, -1, -1, -1, 75, -1, -1,
- -1, -1, -1, 81, 82, 83, 84, -1, -1, 87,
- -1, -1, -1, -1, 92, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 10, -1, 12, 13, -1, -1,
- -1, -1, -1, -1, -1, -1, 22, -1, -1, -1,
- -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
- 36, -1, -1, -1, -1, -1, -1, 43, -1, -1,
- -1, 47, -1, -1, -1, -1, -1, -1, -1, 55,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 65,
- 66, 67, 68, -1, 70, -1, -1, -1, -1, 75,
- -1, -1, -1, -1, -1, 81, 82, 83, 84, -1,
- -1, 87, -1, -1, -1, -1, 92, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 11, 12, 13, -1,
- -1, -1, -1, -1, -1, -1, -1, 22, -1, -1,
- -1, -1, -1, -1, 29, -1, -1, -1, 33, 34,
- -1, 36, -1, -1, -1, 40, -1, 42, 43, 44,
- -1, -1, 47, -1, -1, -1, 51, -1, 53, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 65, 66, 67, 68, -1, 70, -1, 72, -1, 74,
- -1, 76, -1, -1, -1, -1, 81, 82, 83, -1,
- -1, -1, 87, -1, -1, -1, -1, 92, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 7, -1, -1,
- -1, 11, 12, 13, -1, -1, -1, -1, -1, -1,
- -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
- -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
- -1, 51, -1, 53, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
- 70, -1, 72, -1, 74, -1, 76, -1, -1, -1,
- -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
- -1, -1, 92, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 11, 12, 13, -1, -1, -1, -1, -1,
- -1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
- 29, -1, -1, -1, 33, 34, -1, 36, -1, -1,
- -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
- -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 65, 66, 67, 68,
- -1, 70, -1, 72, -1, 74, 75, 76, -1, -1,
- -1, -1, 81, 82, 83, -1, -1, -1, 87, -1,
- -1, -1, -1, 92, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 8, -1, -1, 11, 12, 13, -1,
- -1, -1, -1, -1, -1, -1, -1, 22, -1, -1,
- -1, -1, -1, -1, 29, -1, -1, -1, 33, 34,
- -1, 36, -1, -1, -1, 40, -1, 42, 43, 44,
- -1, -1, 47, -1, -1, -1, 51, -1, 53, -1,
- -1, 56, -1, -1, -1, -1, -1, -1, -1, -1,
- 65, 66, 67, 68, -1, 70, -1, 72, -1, 74,
- -1, 76, -1, -1, -1, -1, 81, 82, 83, -1,
- -1, -1, 87, -1, -1, -1, -1, 92, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 8, -1, -1,
- 11, 12, 13, -1, -1, -1, -1, -1, -1, -1,
- -1, 22, -1, -1, -1, -1, -1, -1, 29, -1,
- -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
- -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
- 51, -1, 53, -1, -1, 56, -1, -1, -1, -1,
- -1, -1, -1, -1, 65, 66, 67, 68, -1, 70,
- -1, 72, -1, 74, -1, 76, -1, -1, -1, -1,
- 81, 82, 83, -1, -1, -1, 87, -1, -1, -1,
- -1, 92, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 8, -1, -1, 11, 12, 13, -1, -1, -1,
- -1, -1, -1, -1, -1, 22, -1, -1, -1, -1,
- -1, -1, 29, -1, -1, -1, 33, 34, -1, 36,
- -1, -1, -1, 40, -1, 42, 43, 44, -1, -1,
- 47, -1, -1, -1, 51, -1, 53, -1, -1, 56,
- -1, -1, -1, -1, -1, -1, -1, -1, 65, 66,
- 67, 68, -1, 70, -1, 72, -1, 74, -1, 76,
- -1, -1, -1, -1, 81, 82, 83, -1, -1, -1,
- 87, -1, -1, -1, -1, 92, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 8, -1, -1, 11, 12,
- 13, -1, -1, -1, -1, -1, -1, -1, -1, 22,
- -1, -1, -1, -1, -1, -1, 29, -1, -1, -1,
- 33, 34, -1, 36, -1, -1, -1, 40, -1, 42,
- 43, 44, -1, -1, 47, -1, -1, -1, 51, -1,
- 53, -1, -1, 56, -1, -1, -1, -1, -1, -1,
- -1, -1, 65, 66, 67, 68, -1, 70, -1, 72,
- -1, 74, -1, 76, -1, -1, -1, -1, 81, 82,
- 83, -1, -1, -1, 87, -1, -1, -1, -1, 92,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 11,
- 12, 13, -1, -1, -1, -1, -1, -1, -1, -1,
- 22, -1, -1, -1, -1, -1, -1, 29, 30, -1,
- -1, 33, 34, -1, 36, -1, -1, -1, 40, -1,
- 42, 43, 44, -1, -1, 47, -1, -1, -1, 51,
- -1, 53, -1, -1, -1, -1, -1, -1, -1, 61,
- -1, -1, -1, 65, 66, 67, 68, 69, 70, -1,
- 72, 73, 74, -1, 76, -1, 78, -1, -1, 81,
- 82, 83, -1, -1, -1, 87, -1, -1, -1, -1,
- 92, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 11, 12, 13, -1, -1, -1, -1, -1, -1, -1,
- -1, 22, -1, -1, -1, -1, -1, -1, 29, 30,
- -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
- -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
- 51, -1, 53, -1, -1, -1, -1, -1, -1, -1,
- 61, -1, -1, -1, 65, 66, 67, 68, 69, 70,
- -1, 72, 73, 74, -1, 76, -1, 78, -1, -1,
- 81, 82, 83, -1, -1, -1, 87, -1, -1, -1,
- -1, 92, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 4, 5, 6, -1, -1, 9, 10, 11, -1,
- -1, 14, -1, 16, -1, -1, -1, 20, 21, 22,
- -1, -1, -1, -1, -1, -1, 29, 30, 31, 32,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 43, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
- -1, -1, -1, 66, 67, 68, 69, 70, 71, -1,
- 73, 74, 75, 76, 77, 78, -1, -1, 81, 82,
- 83, 84, 85, 86, -1, -1, -1, -1, -1, 92,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
- 5, 6, -1, -1, 9, 10, 11, -1, -1, 14,
- -1, 16, -1, -1, -1, 20, 21, 22, -1, -1,
- -1, -1, -1, -1, 29, 30, 31, 32, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 43, -1,
- -1, -1, 47, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
- 65, 66, 67, -1, 69, 70, 71, -1, 73, 74,
- 75, 76, 77, 78, -1, -1, 81, 82, 83, 84,
- 85, 86, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 4, 5, 6,
- -1, -1, 9, 10, 11, -1, -1, 14, -1, 16,
- -1, -1, -1, 20, 21, 22, -1, -1, -1, -1,
- -1, -1, 29, 30, 31, 32, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 43, -1, -1, -1,
- 47, -1, -1, -1, -1, -1, -1, -1, 55, -1,
- -1, -1, 59, -1, -1, -1, -1, -1, 65, 66,
- 67, -1, 69, 70, 71, -1, 73, 74, 75, 76,
- 77, 78, -1, -1, 81, 82, 83, 84, 85, 86,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 4, -1, -1, -1, -1,
- 9, -1, 11, 12, 13, 14, -1, -1, -1, -1,
- -1, -1, 21, 22, -1, -1, -1, -1, -1, -1,
- 29, 30, -1, -1, 33, 34, -1, 36, -1, -1,
- -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
- -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
- 59, -1, 61, -1, -1, -1, 65, 66, 67, 68,
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- -1, -1, 81, 82, 83, 84, 85, -1, 87, -1,
- -1, -1, -1, 92, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 4, -1, -1, -1, -1, 9, -1,
- 11, 12, 13, 14, -1, -1, -1, -1, -1, -1,
- 21, 22, -1, -1, -1, -1, -1, -1, 29, 30,
- -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
- -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
- 51, -1, 53, -1, -1, -1, -1, -1, 59, -1,
- 61, -1, -1, -1, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 74, 75, 76, 77, 78, -1, -1,
- 81, 82, 83, 84, 85, -1, 87, -1, -1, -1,
- -1, 92, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 4, 5, 6, -1, -1, 9, 10, 11, 12,
- 13, 14, -1, 16, -1, -1, -1, 20, 21, 22,
- -1, -1, -1, -1, -1, -1, 29, 30, 31, 32,
- 33, 34, -1, 36, -1, -1, -1, 40, -1, 42,
- 43, 44, -1, -1, 47, -1, -1, -1, 51, -1,
- 53, -1, -1, -1, -1, -1, 59, -1, 61, -1,
- -1, -1, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, -1, -1, 81, 82,
- 83, 84, 85, 86, 87, -1, -1, -1, -1, 92,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
- 5, 6, -1, -1, 9, 10, 11, 12, 13, 14,
- -1, 16, -1, -1, -1, 20, 21, 22, -1, -1,
- -1, -1, -1, -1, 29, 30, 31, 32, 33, 34,
- -1, 36, -1, -1, -1, 40, -1, 42, 43, 44,
- -1, -1, 47, -1, -1, -1, 51, -1, 53, -1,
- 55, -1, -1, -1, 59, -1, 61, -1, -1, -1,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, -1, -1, 81, 82, 83, 84,
- 85, 86, 87, -1, -1, -1, -1, 92, -1, -1,
- -1, -1, -1, -1, -1, -1, -1,
-
- 15, 2, 105, 3, 29, 15, 4, 2, 15, 29,
- 9, 15, 3, 15, 3, 2, 19, 39, 15, 15,
- 13, 15, 3, 15, 2, 15, 3, 15, 3, 11,
- 13, 15, 71, 39, 39, 3, 22, 2, 99, 19,
- 4, 15, 2, 15, 29, 15, 19, 3, 15, 3,
- 29, 22, 15, 29, 15, 2, 22, 15, 2, 2,
- 15, 2, 2, 2, 2, 22, 3, 15, 3, 2,
- 39, 3, 3, 15, 97, 94, 3, 39, 2, 2,
- 39, 3, 3, 2, 2, 101, 3, 40, 39, 39,
- 39, 3, 2, 39, 39, 15, 22, 13, 3, 2,
- 13, 2, -1, 39, 13, 35, -1, 16, -1, 39,
- -1, -1, -1, 15, 48, -1, 15, 13, 52, 48,
- 48, 50, 3, 48, 20, 53, -1, 52, -1, 45,
- -1, 15, 45, 48, 48, 50, 50, 48, -1, 50,
- 48, 48, 48, 50, 48, 53, 52, 39, 48, 53,
- 48, 39, 44, 53, 48, 53, 44, 48, 15, 50,
- -1, 48, 48, 48, 58, 48, 3, 72, 53, 48,
- 53, 50, 48, 48, 50, 48, 62, 64, 53, 82,
- 53, 82, 48, 48, 41, 13, 88, 53, 16, 54,
- 48, 72, 48, 3, 50, 48, 54, 4, 48, 13,
- 50, 100, 86, 56, 48, 48, 50, 50, 48, 48,
- 50, -1, 51, 48, 48, 48, 51, 50, 48, 48,
- 54, 50, 48, 53, 50, 48, 48, 48, 50, 48,
- 53, 45, 48, 54, 50, 72, -1, 48, -1, 48,
- -1, 60, 53, 48, 53, 48, 15, 48, 53, -1,
- 53, 48, 53, 48, 65, -1, 53, -1, 53, 48,
- 55, 70, 72, 48, 53, 70, 63, 70, 53, 70,
- 48, 48, 41, 42, 59, 53, 53, 55, 48, 13,
- 57, 70, 48, 53, 48, 55, 20, 53, -1, 53,
- -1, 55, -1, 5, -1, 61, 5, -1, 32, 33,
- 13, 13, -1, 16, 13, -1, -1, -1, 20, -1,
- -1, 20, 22, 23, 24, 25, 26, 27, 28, -1,
- 32, 33, -1, 32, 33, 21, 22, 23, 24, 25,
- 26, 27, 28, 13, -1, -1, -1, -1, -1, -1,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 13,
- -1, -1, -1, -1, -1, -1, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 13, -1, -1, 16, -1, 18,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1};
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
deleted file mode 100644
index 5503ff763f..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-// This file was generated by qlalr - DO NOT EDIT!
-#ifndef QDECLARATIVEJSGRAMMAR_P_H
-#define QDECLARATIVEJSGRAMMAR_P_H
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeJSGrammar
-{
-public:
- enum VariousConstants {
- EOF_SYMBOL = 0,
- REDUCE_HERE = 101,
- SHIFT_THERE = 100,
- T_AND = 1,
- T_AND_AND = 2,
- T_AND_EQ = 3,
- T_AS = 91,
- T_AUTOMATIC_SEMICOLON = 62,
- T_BREAK = 4,
- T_CASE = 5,
- T_CATCH = 6,
- T_COLON = 7,
- T_COMMA = 8,
- T_COMMENT = 88,
- T_CONST = 84,
- T_CONTINUE = 9,
- T_DEBUGGER = 85,
- T_DEFAULT = 10,
- T_DELETE = 11,
- T_DIVIDE_ = 12,
- T_DIVIDE_EQ = 13,
- T_DO = 14,
- T_DOT = 15,
- T_ELSE = 16,
- T_EQ = 17,
- T_EQ_EQ = 18,
- T_EQ_EQ_EQ = 19,
- T_ERROR = 93,
- T_FALSE = 83,
- T_FEED_JS_EXPRESSION = 97,
- T_FEED_JS_PROGRAM = 99,
- T_FEED_JS_SOURCE_ELEMENT = 98,
- T_FEED_JS_STATEMENT = 96,
- T_FEED_UI_OBJECT_MEMBER = 95,
- T_FEED_UI_PROGRAM = 94,
- T_FINALLY = 20,
- T_FOR = 21,
- T_FUNCTION = 22,
- T_GE = 23,
- T_GT = 24,
- T_GT_GT = 25,
- T_GT_GT_EQ = 26,
- T_GT_GT_GT = 27,
- T_GT_GT_GT_EQ = 28,
- T_IDENTIFIER = 29,
- T_IF = 30,
- T_IMPORT = 90,
- T_IN = 31,
- T_INSTANCEOF = 32,
- T_LBRACE = 33,
- T_LBRACKET = 34,
- T_LE = 35,
- T_LPAREN = 36,
- T_LT = 37,
- T_LT_LT = 38,
- T_LT_LT_EQ = 39,
- T_MINUS = 40,
- T_MINUS_EQ = 41,
- T_MINUS_MINUS = 42,
- T_MULTILINE_STRING_LITERAL = 87,
- T_NEW = 43,
- T_NOT = 44,
- T_NOT_EQ = 45,
- T_NOT_EQ_EQ = 46,
- T_NULL = 81,
- T_NUMERIC_LITERAL = 47,
- T_ON = 92,
- T_OR = 48,
- T_OR_EQ = 49,
- T_OR_OR = 50,
- T_PLUS = 51,
- T_PLUS_EQ = 52,
- T_PLUS_PLUS = 53,
- T_PROPERTY = 66,
- T_PUBLIC = 89,
- T_QUESTION = 54,
- T_RBRACE = 55,
- T_RBRACKET = 56,
- T_READONLY = 68,
- T_REMAINDER = 57,
- T_REMAINDER_EQ = 58,
- T_RESERVED_WORD = 86,
- T_RETURN = 59,
- T_RPAREN = 60,
- T_SEMICOLON = 61,
- T_SIGNAL = 67,
- T_STAR = 63,
- T_STAR_EQ = 64,
- T_STRING_LITERAL = 65,
- T_SWITCH = 69,
- T_THIS = 70,
- T_THROW = 71,
- T_TILDE = 72,
- T_TRUE = 82,
- T_TRY = 73,
- T_TYPEOF = 74,
- T_VAR = 75,
- T_VOID = 76,
- T_WHILE = 77,
- T_WITH = 78,
- T_XOR = 79,
- T_XOR_EQ = 80,
-
- ACCEPT_STATE = 644,
- RULE_COUNT = 349,
- STATE_COUNT = 645,
- TERMINAL_COUNT = 102,
- NON_TERMINAL_COUNT = 107,
-
- GOTO_INDEX_OFFSET = 645,
- GOTO_INFO_OFFSET = 2807,
- GOTO_CHECK_OFFSET = 2807
- };
-
- static const char *const spell [];
- static const short lhs [];
- static const short rhs [];
- static const short goto_default [];
- static const short action_default [];
- static const short action_index [];
- static const short action_info [];
- static const short action_check [];
-
- static inline int nt_action (int state, int nt)
- {
- const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;
- if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)
- return goto_default [nt];
-
- return action_info [GOTO_INFO_OFFSET + yyn];
- }
-
- static inline int t_action (int state, int token)
- {
- const int yyn = action_index [state] + token;
-
- if (yyn < 0 || action_check [yyn] != token)
- return - action_default [state];
-
- return action_info [yyn];
- }
-};
-
-
-QT_END_NAMESPACE
-#endif // QDECLARATIVEJSGRAMMAR_P_H
-
diff --git a/src/declarative/qml/parser/qdeclarativejskeywords_p.h b/src/declarative/qml/parser/qdeclarativejskeywords_p.h
deleted file mode 100644
index fac5b7b5f6..0000000000
--- a/src/declarative/qml/parser/qdeclarativejskeywords_p.h
+++ /dev/null
@@ -1,860 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEJSKEYWORDS_P_H
-#define QDECLARATIVEJSKEYWORDS_P_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.
-//
-
-static inline int classify2(const QChar *s, bool qmlMode) {
- if (s[0].unicode() == 'a') {
- if (s[1].unicode() == 's') {
- return qmlMode ? Lexer::T_AS : Lexer::T_RESERVED_WORD;
- }
- }
- else if (s[0].unicode() == 'd') {
- if (s[1].unicode() == 'o') {
- return Lexer::T_DO;
- }
- }
- else if (s[0].unicode() == 'i') {
- if (s[1].unicode() == 'f') {
- return Lexer::T_IF;
- }
- else if (s[1].unicode() == 'n') {
- return Lexer::T_IN;
- }
- }
- else if (qmlMode && s[0].unicode() == 'o') {
- if (s[1].unicode() == 'n') {
- return Lexer::T_ON;
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify3(const QChar *s, bool /*qmlMode*/) {
- if (s[0].unicode() == 'f') {
- if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 'r') {
- return Lexer::T_FOR;
- }
- }
- }
- else if (s[0].unicode() == 'i') {
- if (s[1].unicode() == 'n') {
- if (s[2].unicode() == 't') {
- return Lexer::T_INT;
- }
- }
- }
- else if (s[0].unicode() == 'n') {
- if (s[1].unicode() == 'e') {
- if (s[2].unicode() == 'w') {
- return Lexer::T_NEW;
- }
- }
- }
- else if (s[0].unicode() == 't') {
- if (s[1].unicode() == 'r') {
- if (s[2].unicode() == 'y') {
- return Lexer::T_TRY;
- }
- }
- }
- else if (s[0].unicode() == 'v') {
- if (s[1].unicode() == 'a') {
- if (s[2].unicode() == 'r') {
- return Lexer::T_VAR;
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify4(const QChar *s, bool /*qmlMode*/) {
- if (s[0].unicode() == 'b') {
- if (s[1].unicode() == 'y') {
- if (s[2].unicode() == 't') {
- if (s[3].unicode() == 'e') {
- return Lexer::T_BYTE;
- }
- }
- }
- }
- else if (s[0].unicode() == 'c') {
- if (s[1].unicode() == 'a') {
- if (s[2].unicode() == 's') {
- if (s[3].unicode() == 'e') {
- return Lexer::T_CASE;
- }
- }
- }
- else if (s[1].unicode() == 'h') {
- if (s[2].unicode() == 'a') {
- if (s[3].unicode() == 'r') {
- return Lexer::T_CHAR;
- }
- }
- }
- }
- else if (s[0].unicode() == 'e') {
- if (s[1].unicode() == 'l') {
- if (s[2].unicode() == 's') {
- if (s[3].unicode() == 'e') {
- return Lexer::T_ELSE;
- }
- }
- }
- else if (s[1].unicode() == 'n') {
- if (s[2].unicode() == 'u') {
- if (s[3].unicode() == 'm') {
- return Lexer::T_ENUM;
- }
- }
- }
- }
- else if (s[0].unicode() == 'g') {
- if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 't') {
- if (s[3].unicode() == 'o') {
- return Lexer::T_GOTO;
- }
- }
- }
- }
- else if (s[0].unicode() == 'l') {
- if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 'n') {
- if (s[3].unicode() == 'g') {
- return Lexer::T_LONG;
- }
- }
- }
- }
- else if (s[0].unicode() == 'n') {
- if (s[1].unicode() == 'u') {
- if (s[2].unicode() == 'l') {
- if (s[3].unicode() == 'l') {
- return Lexer::T_NULL;
- }
- }
- }
- }
- else if (s[0].unicode() == 't') {
- if (s[1].unicode() == 'h') {
- if (s[2].unicode() == 'i') {
- if (s[3].unicode() == 's') {
- return Lexer::T_THIS;
- }
- }
- }
- else if (s[1].unicode() == 'r') {
- if (s[2].unicode() == 'u') {
- if (s[3].unicode() == 'e') {
- return Lexer::T_TRUE;
- }
- }
- }
- }
- else if (s[0].unicode() == 'v') {
- if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 'i') {
- if (s[3].unicode() == 'd') {
- return Lexer::T_VOID;
- }
- }
- }
- }
- else if (s[0].unicode() == 'w') {
- if (s[1].unicode() == 'i') {
- if (s[2].unicode() == 't') {
- if (s[3].unicode() == 'h') {
- return Lexer::T_WITH;
- }
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify5(const QChar *s, bool /*qmlMode*/) {
- if (s[0].unicode() == 'b') {
- if (s[1].unicode() == 'r') {
- if (s[2].unicode() == 'e') {
- if (s[3].unicode() == 'a') {
- if (s[4].unicode() == 'k') {
- return Lexer::T_BREAK;
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'c') {
- if (s[1].unicode() == 'a') {
- if (s[2].unicode() == 't') {
- if (s[3].unicode() == 'c') {
- if (s[4].unicode() == 'h') {
- return Lexer::T_CATCH;
- }
- }
- }
- }
- else if (s[1].unicode() == 'l') {
- if (s[2].unicode() == 'a') {
- if (s[3].unicode() == 's') {
- if (s[4].unicode() == 's') {
- return Lexer::T_CLASS;
- }
- }
- }
- }
- else if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 'n') {
- if (s[3].unicode() == 's') {
- if (s[4].unicode() == 't') {
- return Lexer::T_CONST;
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'f') {
- if (s[1].unicode() == 'a') {
- if (s[2].unicode() == 'l') {
- if (s[3].unicode() == 's') {
- if (s[4].unicode() == 'e') {
- return Lexer::T_FALSE;
- }
- }
- }
- }
- else if (s[1].unicode() == 'i') {
- if (s[2].unicode() == 'n') {
- if (s[3].unicode() == 'a') {
- if (s[4].unicode() == 'l') {
- return Lexer::T_FINAL;
- }
- }
- }
- }
- else if (s[1].unicode() == 'l') {
- if (s[2].unicode() == 'o') {
- if (s[3].unicode() == 'a') {
- if (s[4].unicode() == 't') {
- return Lexer::T_FLOAT;
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 's') {
- if (s[1].unicode() == 'h') {
- if (s[2].unicode() == 'o') {
- if (s[3].unicode() == 'r') {
- if (s[4].unicode() == 't') {
- return Lexer::T_SHORT;
- }
- }
- }
- }
- else if (s[1].unicode() == 'u') {
- if (s[2].unicode() == 'p') {
- if (s[3].unicode() == 'e') {
- if (s[4].unicode() == 'r') {
- return Lexer::T_SUPER;
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 't') {
- if (s[1].unicode() == 'h') {
- if (s[2].unicode() == 'r') {
- if (s[3].unicode() == 'o') {
- if (s[4].unicode() == 'w') {
- return Lexer::T_THROW;
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'w') {
- if (s[1].unicode() == 'h') {
- if (s[2].unicode() == 'i') {
- if (s[3].unicode() == 'l') {
- if (s[4].unicode() == 'e') {
- return Lexer::T_WHILE;
- }
- }
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify6(const QChar *s, bool qmlMode) {
- if (s[0].unicode() == 'd') {
- if (s[1].unicode() == 'e') {
- if (s[2].unicode() == 'l') {
- if (s[3].unicode() == 'e') {
- if (s[4].unicode() == 't') {
- if (s[5].unicode() == 'e') {
- return Lexer::T_DELETE;
- }
- }
- }
- }
- }
- else if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 'u') {
- if (s[3].unicode() == 'b') {
- if (s[4].unicode() == 'l') {
- if (s[5].unicode() == 'e') {
- return Lexer::T_DOUBLE;
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'e') {
- if (s[1].unicode() == 'x') {
- if (s[2].unicode() == 'p') {
- if (s[3].unicode() == 'o') {
- if (s[4].unicode() == 'r') {
- if (s[5].unicode() == 't') {
- return Lexer::T_EXPORT;
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'i') {
- if (s[1].unicode() == 'm') {
- if (s[2].unicode() == 'p') {
- if (s[3].unicode() == 'o') {
- if (s[4].unicode() == 'r') {
- if (s[5].unicode() == 't') {
- return qmlMode ? Lexer::T_IMPORT : Lexer::T_RESERVED_WORD;
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'n') {
- if (s[1].unicode() == 'a') {
- if (s[2].unicode() == 't') {
- if (s[3].unicode() == 'i') {
- if (s[4].unicode() == 'v') {
- if (s[5].unicode() == 'e') {
- return Lexer::T_NATIVE;
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'p') {
- if (s[1].unicode() == 'u') {
- if (s[2].unicode() == 'b') {
- if (s[3].unicode() == 'l') {
- if (s[4].unicode() == 'i') {
- if (s[5].unicode() == 'c') {
- return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD;
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'r') {
- if (s[1].unicode() == 'e') {
- if (s[2].unicode() == 't') {
- if (s[3].unicode() == 'u') {
- if (s[4].unicode() == 'r') {
- if (s[5].unicode() == 'n') {
- return Lexer::T_RETURN;
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 's') {
- if (qmlMode && s[1].unicode() == 'i') {
- if (s[2].unicode() == 'g') {
- if (s[3].unicode() == 'n') {
- if (s[4].unicode() == 'a') {
- if (s[5].unicode() == 'l') {
- return Lexer::T_SIGNAL;
- }
- }
- }
- }
- }
- else if (s[1].unicode() == 't') {
- if (s[2].unicode() == 'a') {
- if (s[3].unicode() == 't') {
- if (s[4].unicode() == 'i') {
- if (s[5].unicode() == 'c') {
- return Lexer::T_STATIC;
- }
- }
- }
- }
- }
- else if (s[1].unicode() == 'w') {
- if (s[2].unicode() == 'i') {
- if (s[3].unicode() == 't') {
- if (s[4].unicode() == 'c') {
- if (s[5].unicode() == 'h') {
- return Lexer::T_SWITCH;
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 't') {
- if (s[1].unicode() == 'h') {
- if (s[2].unicode() == 'r') {
- if (s[3].unicode() == 'o') {
- if (s[4].unicode() == 'w') {
- if (s[5].unicode() == 's') {
- return Lexer::T_THROWS;
- }
- }
- }
- }
- }
- else if (s[1].unicode() == 'y') {
- if (s[2].unicode() == 'p') {
- if (s[3].unicode() == 'e') {
- if (s[4].unicode() == 'o') {
- if (s[5].unicode() == 'f') {
- return Lexer::T_TYPEOF;
- }
- }
- }
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify7(const QChar *s, bool /*qmlMode*/) {
- if (s[0].unicode() == 'b') {
- if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 'o') {
- if (s[3].unicode() == 'l') {
- if (s[4].unicode() == 'e') {
- if (s[5].unicode() == 'a') {
- if (s[6].unicode() == 'n') {
- return Lexer::T_BOOLEAN;
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'd') {
- if (s[1].unicode() == 'e') {
- if (s[2].unicode() == 'f') {
- if (s[3].unicode() == 'a') {
- if (s[4].unicode() == 'u') {
- if (s[5].unicode() == 'l') {
- if (s[6].unicode() == 't') {
- return Lexer::T_DEFAULT;
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'e') {
- if (s[1].unicode() == 'x') {
- if (s[2].unicode() == 't') {
- if (s[3].unicode() == 'e') {
- if (s[4].unicode() == 'n') {
- if (s[5].unicode() == 'd') {
- if (s[6].unicode() == 's') {
- return Lexer::T_EXTENDS;
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'f') {
- if (s[1].unicode() == 'i') {
- if (s[2].unicode() == 'n') {
- if (s[3].unicode() == 'a') {
- if (s[4].unicode() == 'l') {
- if (s[5].unicode() == 'l') {
- if (s[6].unicode() == 'y') {
- return Lexer::T_FINALLY;
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'p') {
- if (s[1].unicode() == 'a') {
- if (s[2].unicode() == 'c') {
- if (s[3].unicode() == 'k') {
- if (s[4].unicode() == 'a') {
- if (s[5].unicode() == 'g') {
- if (s[6].unicode() == 'e') {
- return Lexer::T_PACKAGE;
- }
- }
- }
- }
- }
- }
- else if (s[1].unicode() == 'r') {
- if (s[2].unicode() == 'i') {
- if (s[3].unicode() == 'v') {
- if (s[4].unicode() == 'a') {
- if (s[5].unicode() == 't') {
- if (s[6].unicode() == 'e') {
- return Lexer::T_PRIVATE;
- }
- }
- }
- }
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify8(const QChar *s, bool qmlMode) {
- if (s[0].unicode() == 'a') {
- if (s[1].unicode() == 'b') {
- if (s[2].unicode() == 's') {
- if (s[3].unicode() == 't') {
- if (s[4].unicode() == 'r') {
- if (s[5].unicode() == 'a') {
- if (s[6].unicode() == 'c') {
- if (s[7].unicode() == 't') {
- return Lexer::T_ABSTRACT;
- }
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'c') {
- if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 'n') {
- if (s[3].unicode() == 't') {
- if (s[4].unicode() == 'i') {
- if (s[5].unicode() == 'n') {
- if (s[6].unicode() == 'u') {
- if (s[7].unicode() == 'e') {
- return Lexer::T_CONTINUE;
- }
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'd') {
- if (s[1].unicode() == 'e') {
- if (s[2].unicode() == 'b') {
- if (s[3].unicode() == 'u') {
- if (s[4].unicode() == 'g') {
- if (s[5].unicode() == 'g') {
- if (s[6].unicode() == 'e') {
- if (s[7].unicode() == 'r') {
- return Lexer::T_DEBUGGER;
- }
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'f') {
- if (s[1].unicode() == 'u') {
- if (s[2].unicode() == 'n') {
- if (s[3].unicode() == 'c') {
- if (s[4].unicode() == 't') {
- if (s[5].unicode() == 'i') {
- if (s[6].unicode() == 'o') {
- if (s[7].unicode() == 'n') {
- return Lexer::T_FUNCTION;
- }
- }
- }
- }
- }
- }
- }
- }
- else if (qmlMode && s[0].unicode() == 'p') {
- if (s[1].unicode() == 'r') {
- if (s[2].unicode() == 'o') {
- if (s[3].unicode() == 'p') {
- if (s[4].unicode() == 'e') {
- if (s[5].unicode() == 'r') {
- if (s[6].unicode() == 't') {
- if (s[7].unicode() == 'y') {
- return Lexer::T_PROPERTY;
- }
- }
- }
- }
- }
- }
- }
- }
- else if (qmlMode && s[0].unicode() == 'r') {
- if (s[1].unicode() == 'e') {
- if (s[2].unicode() == 'a') {
- if (s[3].unicode() == 'd') {
- if (s[4].unicode() == 'o') {
- if (s[5].unicode() == 'n') {
- if (s[6].unicode() == 'l') {
- if (s[7].unicode() == 'y') {
- return Lexer::T_READONLY;
- }
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'v') {
- if (s[1].unicode() == 'o') {
- if (s[2].unicode() == 'l') {
- if (s[3].unicode() == 'a') {
- if (s[4].unicode() == 't') {
- if (s[5].unicode() == 'i') {
- if (s[6].unicode() == 'l') {
- if (s[7].unicode() == 'e') {
- return Lexer::T_VOLATILE;
- }
- }
- }
- }
- }
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify9(const QChar *s, bool /*qmlMode*/) {
- if (s[0].unicode() == 'i') {
- if (s[1].unicode() == 'n') {
- if (s[2].unicode() == 't') {
- if (s[3].unicode() == 'e') {
- if (s[4].unicode() == 'r') {
- if (s[5].unicode() == 'f') {
- if (s[6].unicode() == 'a') {
- if (s[7].unicode() == 'c') {
- if (s[8].unicode() == 'e') {
- return Lexer::T_INTERFACE;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 'p') {
- if (s[1].unicode() == 'r') {
- if (s[2].unicode() == 'o') {
- if (s[3].unicode() == 't') {
- if (s[4].unicode() == 'e') {
- if (s[5].unicode() == 'c') {
- if (s[6].unicode() == 't') {
- if (s[7].unicode() == 'e') {
- if (s[8].unicode() == 'd') {
- return Lexer::T_PROTECTED;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- else if (s[0].unicode() == 't') {
- if (s[1].unicode() == 'r') {
- if (s[2].unicode() == 'a') {
- if (s[3].unicode() == 'n') {
- if (s[4].unicode() == 's') {
- if (s[5].unicode() == 'i') {
- if (s[6].unicode() == 'e') {
- if (s[7].unicode() == 'n') {
- if (s[8].unicode() == 't') {
- return Lexer::T_TRANSIENT;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify10(const QChar *s, bool /*qmlMode*/) {
- if (s[0].unicode() == 'i') {
- if (s[1].unicode() == 'm') {
- if (s[2].unicode() == 'p') {
- if (s[3].unicode() == 'l') {
- if (s[4].unicode() == 'e') {
- if (s[5].unicode() == 'm') {
- if (s[6].unicode() == 'e') {
- if (s[7].unicode() == 'n') {
- if (s[8].unicode() == 't') {
- if (s[9].unicode() == 's') {
- return Lexer::T_IMPLEMENTS;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- else if (s[1].unicode() == 'n') {
- if (s[2].unicode() == 's') {
- if (s[3].unicode() == 't') {
- if (s[4].unicode() == 'a') {
- if (s[5].unicode() == 'n') {
- if (s[6].unicode() == 'c') {
- if (s[7].unicode() == 'e') {
- if (s[8].unicode() == 'o') {
- if (s[9].unicode() == 'f') {
- return Lexer::T_INSTANCEOF;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-static inline int classify12(const QChar *s, bool /*qmlMode*/) {
- if (s[0].unicode() == 's') {
- if (s[1].unicode() == 'y') {
- if (s[2].unicode() == 'n') {
- if (s[3].unicode() == 'c') {
- if (s[4].unicode() == 'h') {
- if (s[5].unicode() == 'r') {
- if (s[6].unicode() == 'o') {
- if (s[7].unicode() == 'n') {
- if (s[8].unicode() == 'i') {
- if (s[9].unicode() == 'z') {
- if (s[10].unicode() == 'e') {
- if (s[11].unicode() == 'd') {
- return Lexer::T_SYNCHRONIZED;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return Lexer::T_IDENTIFIER;
-}
-
-int Lexer::classify(const QChar *s, int n, bool qmlMode) {
- switch (n) {
- case 2: return classify2(s, qmlMode);
- case 3: return classify3(s, qmlMode);
- case 4: return classify4(s, qmlMode);
- case 5: return classify5(s, qmlMode);
- case 6: return classify6(s, qmlMode);
- case 7: return classify7(s, qmlMode);
- case 8: return classify8(s, qmlMode);
- case 9: return classify9(s, qmlMode);
- case 10: return classify10(s, qmlMode);
- case 12: return classify12(s, qmlMode);
- default: return Lexer::T_IDENTIFIER;
- } // switch
-}
-
-#endif // QDECLARATIVEJSKEYWORDS_P_H
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp
deleted file mode 100644
index e292490499..0000000000
--- a/src/declarative/qml/parser/qdeclarativejslexer.cpp
+++ /dev/null
@@ -1,1166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativejslexer_p.h"
-#include "qdeclarativejsengine_p.h"
-#include "qdeclarativejsmemorypool_p.h"
-
-#include <QtCore/QCoreApplication>
-#include <QtCore/QVarLengthArray>
-#include <QtCore/QDebug>
-
-QT_BEGIN_NAMESPACE
-Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
-QT_END_NAMESPACE
-
-using namespace QDeclarativeJS;
-
-static int regExpFlagFromChar(const QChar &ch)
-{
- switch (ch.unicode()) {
- case 'g': return Lexer::RegExp_Global;
- case 'i': return Lexer::RegExp_IgnoreCase;
- case 'm': return Lexer::RegExp_Multiline;
- }
- return 0;
-}
-
-static unsigned char convertHex(ushort c)
-{
- if (c >= '0' && c <= '9')
- return (c - '0');
- else if (c >= 'a' && c <= 'f')
- return (c - 'a' + 10);
- else
- return (c - 'A' + 10);
-}
-
-static QChar convertHex(QChar c1, QChar c2)
-{
- return QChar((convertHex(c1.unicode()) << 4) + convertHex(c2.unicode()));
-}
-
-static QChar convertUnicode(QChar c1, QChar c2, QChar c3, QChar c4)
-{
- return QChar((convertHex(c3.unicode()) << 4) + convertHex(c4.unicode()),
- (convertHex(c1.unicode()) << 4) + convertHex(c2.unicode()));
-}
-
-Lexer::Lexer(Engine *engine)
- : _engine(engine)
- , _codePtr(0)
- , _lastLinePtr(0)
- , _tokenLinePtr(0)
- , _tokenStartPtr(0)
- , _char(QLatin1Char('\n'))
- , _errorCode(NoError)
- , _currentLineNumber(0)
- , _tokenValue(0)
- , _parenthesesState(IgnoreParentheses)
- , _parenthesesCount(0)
- , _stackToken(-1)
- , _patternFlags(0)
- , _tokenKind(0)
- , _tokenLength(0)
- , _tokenLine(0)
- , _validTokenText(false)
- , _prohibitAutomaticSemicolon(false)
- , _restrictedKeyword(false)
- , _terminator(false)
- , _followsClosingBrace(false)
- , _delimited(true)
- , _qmlMode(true)
-{
- if (engine)
- engine->setLexer(this);
-}
-
-bool Lexer::qmlMode() const
-{
- return _qmlMode;
-}
-
-QString Lexer::code() const
-{
- return _code;
-}
-
-void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
-{
- if (_engine)
- _engine->setCode(code);
-
- _qmlMode = qmlMode;
- _code = code;
- _tokenText.clear();
- _tokenText.reserve(1024);
- _errorMessage.clear();
- _tokenSpell = QStringRef();
-
- _codePtr = code.unicode();
- _lastLinePtr = _codePtr;
- _tokenLinePtr = _codePtr;
- _tokenStartPtr = _codePtr;
-
- _char = QLatin1Char('\n');
- _errorCode = NoError;
-
- _currentLineNumber = lineno;
- _tokenValue = 0;
-
- // parentheses state
- _parenthesesState = IgnoreParentheses;
- _parenthesesCount = 0;
-
- _stackToken = -1;
-
- _patternFlags = 0;
- _tokenLength = 0;
- _tokenLine = lineno;
-
- _validTokenText = false;
- _prohibitAutomaticSemicolon = false;
- _restrictedKeyword = false;
- _terminator = false;
- _followsClosingBrace = false;
- _delimited = true;
-}
-
-void Lexer::scanChar()
-{
- _char = *_codePtr++;
-
- if (_char == QLatin1Char('\n')) {
- _lastLinePtr = _codePtr; // points to the first character after the newline
- ++_currentLineNumber;
- }
-}
-
-int Lexer::lex()
-{
- const int previousTokenKind = _tokenKind;
-
- _tokenSpell = QStringRef();
- _tokenKind = scanToken();
- _tokenLength = _codePtr - _tokenStartPtr - 1;
-
- _delimited = false;
- _restrictedKeyword = false;
- _followsClosingBrace = (previousTokenKind == T_RBRACE);
-
- // update the flags
- switch (_tokenKind) {
- case T_LBRACE:
- case T_SEMICOLON:
- case T_COLON:
- _delimited = true;
- break;
-
- case T_IF:
- case T_FOR:
- case T_WHILE:
- case T_WITH:
- _parenthesesState = CountParentheses;
- _parenthesesCount = 0;
- break;
-
- case T_DO:
- _parenthesesState = BalancedParentheses;
- break;
-
- case T_CONTINUE:
- case T_BREAK:
- case T_RETURN:
- case T_THROW:
- _restrictedKeyword = true;
- break;
- } // switch
-
- // update the parentheses state
- switch (_parenthesesState) {
- case IgnoreParentheses:
- break;
-
- case CountParentheses:
- if (_tokenKind == T_RPAREN) {
- --_parenthesesCount;
- if (_parenthesesCount == 0)
- _parenthesesState = BalancedParentheses;
- } else if (_tokenKind == T_LPAREN) {
- ++_parenthesesCount;
- }
- break;
-
- case BalancedParentheses:
- _parenthesesState = IgnoreParentheses;
- break;
- } // switch
-
- return _tokenKind;
-}
-
-bool Lexer::isUnicodeEscapeSequence(const QChar *chars)
-{
- if (isHexDigit(chars[0]) && isHexDigit(chars[1]) && isHexDigit(chars[2]) && isHexDigit(chars[3]))
- return true;
-
- return false;
-}
-
-QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok)
-{
- if (_char == QLatin1Char('u') && isUnicodeEscapeSequence(&_codePtr[0])) {
- scanChar(); // skip u
-
- const QChar c1 = _char;
- scanChar();
-
- const QChar c2 = _char;
- scanChar();
-
- const QChar c3 = _char;
- scanChar();
-
- const QChar c4 = _char;
- scanChar();
-
- if (ok)
- *ok = true;
-
- return convertUnicode(c1, c2, c3, c4);
- }
-
- *ok = false;
- return QChar();
-}
-
-int Lexer::scanToken()
-{
- if (_stackToken != -1) {
- int tk = _stackToken;
- _stackToken = -1;
- return tk;
- }
-
- _terminator = false;
-
-again:
- _validTokenText = false;
- _tokenLinePtr = _lastLinePtr;
-
- while (_char.isSpace()) {
- if (_char == QLatin1Char('\n')) {
- _tokenLinePtr = _codePtr;
-
- if (_restrictedKeyword) {
- // automatic semicolon insertion
- _tokenLine = _currentLineNumber;
- _tokenStartPtr = _codePtr - 1; // ### TODO: insert it before the optional \r sequence.
- return T_SEMICOLON;
- } else {
- _terminator = true;
- syncProhibitAutomaticSemicolon();
- }
- }
-
- scanChar();
- }
-
- _tokenStartPtr = _codePtr - 1;
- _tokenLine = _currentLineNumber;
-
- if (_char.isNull())
- return EOF_SYMBOL;
-
- const QChar ch = _char;
- scanChar();
-
- switch (ch.unicode()) {
- case '~': return T_TILDE;
- case '}': return T_RBRACE;
-
- case '|':
- if (_char == QLatin1Char('|')) {
- scanChar();
- return T_OR_OR;
- } else if (_char == QLatin1Char('=')) {
- scanChar();
- return T_OR_EQ;
- }
- return T_OR;
-
- case '{': return T_LBRACE;
-
- case '^':
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_XOR_EQ;
- }
- return T_XOR;
-
- case ']': return T_RBRACKET;
- case '[': return T_LBRACKET;
- case '?': return T_QUESTION;
-
- case '>':
- if (_char == QLatin1Char('>')) {
- scanChar();
- if (_char == QLatin1Char('>')) {
- scanChar();
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_GT_GT_GT_EQ;
- }
- return T_GT_GT_GT;
- } else if (_char == QLatin1Char('=')) {
- scanChar();
- return T_GT_GT_EQ;
- }
- return T_GT_GT;
- } else if (_char == QLatin1Char('=')) {
- scanChar();
- return T_GE;
- }
- return T_GT;
-
- case '=':
- if (_char == QLatin1Char('=')) {
- scanChar();
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_EQ_EQ_EQ;
- }
- return T_EQ_EQ;
- }
- return T_EQ;
-
- case '<':
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_LE;
- } else if (_char == QLatin1Char('<')) {
- scanChar();
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_LT_LT_EQ;
- }
- return T_LT_LT;
- }
- return T_LT;
-
- case ';': return T_SEMICOLON;
- case ':': return T_COLON;
-
- case '/':
- if (_char == QLatin1Char('*')) {
- scanChar();
- while (!_char.isNull()) {
- if (_char == QLatin1Char('*')) {
- scanChar();
- if (_char == QLatin1Char('/')) {
- scanChar();
-
- if (_engine) {
- _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 4,
- tokenStartLine(), tokenStartColumn() + 2);
- }
-
- goto again;
- }
- } else {
- scanChar();
- }
- }
- } else if (_char == QLatin1Char('/')) {
- while (!_char.isNull() && _char != QLatin1Char('\n')) {
- scanChar();
- }
- if (_engine) {
- _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 2,
- tokenStartLine(), tokenStartColumn() + 2);
- }
- goto again;
- } if (_char == QLatin1Char('=')) {
- scanChar();
- return T_DIVIDE_EQ;
- }
- return T_DIVIDE_;
-
- case '.':
- if (_char.isDigit()) {
- QVarLengthArray<char,32> chars;
-
- chars.append(ch.unicode()); // append the `.'
-
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar();
- }
-
- if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
- if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
- _codePtr[1].isDigit())) {
-
- chars.append(_char.unicode());
- scanChar(); // consume `e'
-
- if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
- chars.append(_char.unicode());
- scanChar(); // consume the sign
- }
-
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar();
- }
- }
- }
-
- chars.append('\0');
-
- const char *begin = chars.constData();
- const char *end = 0;
- bool ok = false;
-
- _tokenValue = qstrtod(begin, &end, &ok);
-
- if (end - begin != chars.size() - 1) {
- _errorCode = IllegalExponentIndicator;
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal syntax for exponential number");
- return T_ERROR;
- }
-
- return T_NUMERIC_LITERAL;
- }
- return T_DOT;
-
- case '-':
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_MINUS_EQ;
- } else if (_char == QLatin1Char('-')) {
- scanChar();
-
- if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) {
- _stackToken = T_MINUS_MINUS;
- return T_SEMICOLON;
- }
-
- return T_MINUS_MINUS;
- }
- return T_MINUS;
-
- case ',': return T_COMMA;
-
- case '+':
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_PLUS_EQ;
- } else if (_char == QLatin1Char('+')) {
- scanChar();
-
- if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) {
- _stackToken = T_PLUS_PLUS;
- return T_SEMICOLON;
- }
-
- return T_PLUS_PLUS;
- }
- return T_PLUS;
-
- case '*':
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_STAR_EQ;
- }
- return T_STAR;
-
- case ')': return T_RPAREN;
- case '(': return T_LPAREN;
-
- case '&':
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_AND_EQ;
- } else if (_char == QLatin1Char('&')) {
- scanChar();
- return T_AND_AND;
- }
- return T_AND;
-
- case '%':
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_REMAINDER_EQ;
- }
- return T_REMAINDER;
-
- case '!':
- if (_char == QLatin1Char('=')) {
- scanChar();
- if (_char == QLatin1Char('=')) {
- scanChar();
- return T_NOT_EQ_EQ;
- }
- return T_NOT_EQ;
- }
- return T_NOT;
-
- case '\'':
- case '"': {
- const QChar quote = ch;
- bool multilineStringLiteral = false;
-
- const QChar *startCode = _codePtr;
-
- if (_engine) {
- while (!_char.isNull()) {
- if (_char == QLatin1Char('\n') || _char == QLatin1Char('\\')) {
- break;
- } else if (_char == quote) {
- _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);
- scanChar();
-
- return T_STRING_LITERAL;
- }
- scanChar();
- }
- }
-
- _validTokenText = true;
- _tokenText.resize(0);
- startCode--;
- while (startCode != _codePtr - 1)
- _tokenText += *startCode++;
-
- while (! _char.isNull()) {
- if (_char == QLatin1Char('\n')) {
- multilineStringLiteral = true;
- _tokenText += _char;
- scanChar();
- } else if (_char == quote) {
- scanChar();
-
- if (_engine)
- _tokenSpell = _engine->newStringRef(_tokenText);
-
- return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL;
- } else if (_char == QLatin1Char('\\')) {
- scanChar();
-
- QChar u;
- bool ok = false;
-
- switch (_char.unicode()) {
- // unicode escape sequence
- case 'u':
- u = decodeUnicodeEscapeCharacter(&ok);
- if (! ok)
- u = _char;
- break;
-
- // hex escape sequence
- case 'x':
- case 'X':
- if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) {
- scanChar();
-
- const QChar c1 = _char;
- scanChar();
-
- const QChar c2 = _char;
- scanChar();
-
- u = convertHex(c1, c2);
- } else {
- u = _char;
- }
- break;
-
- // single character escape sequence
- case '\\': u = QLatin1Char('\\'); scanChar(); break;
- case '\'': u = QLatin1Char('\''); scanChar(); break;
- case '\"': u = QLatin1Char('\"'); scanChar(); break;
- case 'b': u = QLatin1Char('\b'); scanChar(); break;
- case 'f': u = QLatin1Char('\f'); scanChar(); break;
- case 'n': u = QLatin1Char('\n'); scanChar(); break;
- case 'r': u = QLatin1Char('\r'); scanChar(); break;
- case 't': u = QLatin1Char('\t'); scanChar(); break;
- case 'v': u = QLatin1Char('\v'); scanChar(); break;
-
- case '0':
- if (! _codePtr[1].isDigit()) {
- scanChar();
- u = QLatin1Char('\0');
- } else {
- // ### parse deprecated octal escape sequence ?
- u = _char;
- }
- break;
-
- case '\r':
- while (_char == QLatin1Char('\r'))
- scanChar();
-
- if (_char == QLatin1Char('\n')) {
- u = _char;
- scanChar();
- } else {
- u = QLatin1Char('\n');
- }
-
- break;
-
- case '\n':
- u = _char;
- scanChar();
- break;
-
- default:
- // non escape character
- u = _char;
- scanChar();
- }
-
- _tokenText += u;
- } else {
- _tokenText += _char;
- scanChar();
- }
- }
-
- _errorCode = UnclosedStringLiteral;
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unclosed string at end of line");
- return T_ERROR;
- }
-
- default:
- if (ch.isLetter() || ch == QLatin1Char('$') || ch == QLatin1Char('_') || (ch == QLatin1Char('\\') && _char == QLatin1Char('u'))) {
- bool identifierWithEscapeChars = false;
- if (ch == QLatin1Char('\\')) {
- identifierWithEscapeChars = true;
- _tokenText.resize(0);
- bool ok = false;
- _tokenText += decodeUnicodeEscapeCharacter(&ok);
- _validTokenText = true;
- if (! ok) {
- _errorCode = IllegalUnicodeEscapeSequence;
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence");
- return T_ERROR;
- }
- }
- while (true) {
- if (_char.isLetterOrNumber() || _char == QLatin1Char('$') || _char == QLatin1Char('_')) {
- if (identifierWithEscapeChars)
- _tokenText += _char;
-
- scanChar();
- } else if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) {
- if (! identifierWithEscapeChars) {
- identifierWithEscapeChars = true;
- _tokenText.resize(0);
- _tokenText.insert(0, _tokenStartPtr, _codePtr - _tokenStartPtr - 1);
- _validTokenText = true;
- }
-
- scanChar(); // skip '\\'
- bool ok = false;
- _tokenText += decodeUnicodeEscapeCharacter(&ok);
- if (! ok) {
- _errorCode = IllegalUnicodeEscapeSequence;
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence");
- return T_ERROR;
- }
- } else {
- _tokenLength = _codePtr - _tokenStartPtr - 1;
-
- int kind = T_IDENTIFIER;
-
- if (! identifierWithEscapeChars)
- kind = classify(_tokenStartPtr, _tokenLength, _qmlMode);
-
- if (_engine) {
- if (kind == T_IDENTIFIER && identifierWithEscapeChars)
- _tokenSpell = _engine->newStringRef(_tokenText);
- else
- _tokenSpell = _engine->midRef(_tokenStartPtr - _code.unicode(), _tokenLength);
- }
-
- return kind;
- }
- }
- } else if (ch.isDigit()) {
- if (ch != QLatin1Char('0')) {
- double integer = ch.unicode() - '0';
-
- QChar n = _char;
- const QChar *code = _codePtr;
- while (n.isDigit()) {
- integer = integer * 10 + (n.unicode() - '0');
- n = *code++;
- }
-
- if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) {
- if (code != _codePtr) {
- _codePtr = code - 1;
- scanChar();
- }
- _tokenValue = integer;
- return T_NUMERIC_LITERAL;
- }
- }
-
- QVarLengthArray<char,32> chars;
- chars.append(ch.unicode());
-
- if (ch == QLatin1Char('0') && (_char == QLatin1Char('x') || _char == QLatin1Char('X'))) {
- // parse hex integer literal
-
- chars.append(_char.unicode());
- scanChar(); // consume `x'
-
- while (isHexDigit(_char)) {
- chars.append(_char.unicode());
- scanChar();
- }
-
- _tokenValue = integerFromString(chars.constData(), chars.size(), 16);
- return T_NUMERIC_LITERAL;
- }
-
- // decimal integer literal
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar(); // consume the digit
- }
-
- if (_char == QLatin1Char('.')) {
- chars.append(_char.unicode());
- scanChar(); // consume `.'
-
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar();
- }
-
- if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
- if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
- _codePtr[1].isDigit())) {
-
- chars.append(_char.unicode());
- scanChar(); // consume `e'
-
- if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
- chars.append(_char.unicode());
- scanChar(); // consume the sign
- }
-
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar();
- }
- }
- }
- } else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
- if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
- _codePtr[1].isDigit())) {
-
- chars.append(_char.unicode());
- scanChar(); // consume `e'
-
- if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
- chars.append(_char.unicode());
- scanChar(); // consume the sign
- }
-
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar();
- }
- }
- }
-
- chars.append('\0');
-
- const char *begin = chars.constData();
- const char *end = 0;
- bool ok = false;
-
- _tokenValue = qstrtod(begin, &end, &ok);
-
- if (end - begin != chars.size() - 1) {
- _errorCode = IllegalExponentIndicator;
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal syntax for exponential number");
- return T_ERROR;
- }
-
- return T_NUMERIC_LITERAL;
- }
-
- break;
- }
-
- return T_ERROR;
-}
-
-bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
-{
- _tokenText.resize(0);
- _validTokenText = true;
- _patternFlags = 0;
-
- if (prefix == EqualPrefix)
- _tokenText += QLatin1Char('=');
-
- while (true) {
- switch (_char.unicode()) {
- case 0: // eof
- case '\n': case '\r': // line terminator
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression literal");
- return false;
-
- case '/':
- scanChar();
-
- // scan the flags
- _patternFlags = 0;
- while (isIdentLetter(_char)) {
- int flag = regExpFlagFromChar(_char);
- if (flag == 0) {
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Invalid regular expression flag '%0'")
- .arg(QChar(_char));
- return false;
- }
- _patternFlags |= flag;
- scanChar();
- }
-
- _tokenLength = _codePtr - _tokenStartPtr - 1;
- return true;
-
- case '\\':
- // regular expression backslash sequence
- _tokenText += _char;
- scanChar();
-
- if (_char.isNull() || isLineTerminator()) {
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression backslash sequence");
- return false;
- }
-
- _tokenText += _char;
- scanChar();
- break;
-
- case '[':
- // regular expression class
- _tokenText += _char;
- scanChar();
-
- while (! _char.isNull() && ! isLineTerminator()) {
- if (_char == QLatin1Char(']'))
- break;
- else if (_char == QLatin1Char('\\')) {
- // regular expression backslash sequence
- _tokenText += _char;
- scanChar();
-
- if (_char.isNull() || isLineTerminator()) {
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression backslash sequence");
- return false;
- }
-
- _tokenText += _char;
- scanChar();
- } else {
- _tokenText += _char;
- scanChar();
- }
- }
-
- if (_char != QLatin1Char(']')) {
- _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression class");
- return false;
- }
-
- _tokenText += _char;
- scanChar(); // skip ]
- break;
-
- default:
- _tokenText += _char;
- scanChar();
- } // switch
- } // while
-
- return false;
-}
-
-bool Lexer::isLineTerminator() const
-{
- return (_char == QLatin1Char('\n') || _char == QLatin1Char('\r'));
-}
-
-bool Lexer::isIdentLetter(QChar ch)
-{
- // ASCII-biased, since all reserved words are ASCII, aand hence the
- // bulk of content to be parsed.
- if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z'))
- || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z'))
- || ch == QLatin1Char('$')
- || ch == QLatin1Char('_'))
- return true;
- if (ch.unicode() < 128)
- return false;
- return ch.isLetterOrNumber();
-}
-
-bool Lexer::isDecimalDigit(ushort c)
-{
- return (c >= '0' && c <= '9');
-}
-
-bool Lexer::isHexDigit(QChar c)
-{
- return ((c >= QLatin1Char('0') && c <= QLatin1Char('9'))
- || (c >= QLatin1Char('a') && c <= QLatin1Char('f'))
- || (c >= QLatin1Char('A') && c <= QLatin1Char('F')));
-}
-
-bool Lexer::isOctalDigit(ushort c)
-{
- return (c >= '0' && c <= '7');
-}
-
-int Lexer::tokenKind() const
-{
- return _tokenKind;
-}
-
-int Lexer::tokenOffset() const
-{
- return _tokenStartPtr - _code.unicode();
-}
-
-int Lexer::tokenLength() const
-{
- return _tokenLength;
-}
-
-int Lexer::tokenStartLine() const
-{
- return _tokenLine;
-}
-
-int Lexer::tokenStartColumn() const
-{
- return _tokenStartPtr - _tokenLinePtr + 1;
-}
-
-int Lexer::tokenEndLine() const
-{
- return _currentLineNumber;
-}
-
-int Lexer::tokenEndColumn() const
-{
- return _codePtr - _lastLinePtr;
-}
-
-QStringRef Lexer::tokenSpell() const
-{
- return _tokenSpell;
-}
-
-double Lexer::tokenValue() const
-{
- return _tokenValue;
-}
-
-QString Lexer::tokenText() const
-{
- if (_validTokenText)
- return _tokenText;
-
- if (_tokenKind == T_STRING_LITERAL)
- return QString(_tokenStartPtr + 1, _tokenLength - 2);
-
- return QString(_tokenStartPtr, _tokenLength);
-}
-
-Lexer::Error Lexer::errorCode() const
-{
- return _errorCode;
-}
-
-QString Lexer::errorMessage() const
-{
- return _errorMessage;
-}
-
-void Lexer::syncProhibitAutomaticSemicolon()
-{
- if (_parenthesesState == BalancedParentheses) {
- // we have seen something like "if (foo)", which means we should
- // never insert an automatic semicolon at this point, since it would
- // then be expanded into an empty statement (ECMA-262 7.9.1)
- _prohibitAutomaticSemicolon = true;
- _parenthesesState = IgnoreParentheses;
- } else {
- _prohibitAutomaticSemicolon = false;
- }
-}
-
-bool Lexer::prevTerminator() const
-{
- return _terminator;
-}
-
-bool Lexer::followsClosingBrace() const
-{
- return _followsClosingBrace;
-}
-
-bool Lexer::canInsertAutomaticSemicolon(int token) const
-{
- return token == T_RBRACE
- || token == EOF_SYMBOL
- || _terminator
- || _followsClosingBrace;
-}
-
-bool Lexer::scanDirectives(Directives *directives)
-{
- if (_qmlMode) {
- // the directives are a Javascript-only extension.
- return false;
- }
-
- lex(); // fetch the first token
-
- if (_tokenKind != T_DOT)
- return true;
-
- do {
- lex(); // skip T_DOT
-
- const int lineNumber = tokenStartLine();
-
- if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD))
- return false; // expected a valid QML/JS directive
-
- const QString directiveName = tokenText();
-
- if (! (directiveName == QLatin1String("pragma") ||
- directiveName == QLatin1String("import")))
- return false; // not a valid directive name
-
- // it must be a pragma or an import directive.
- if (directiveName == QLatin1String("pragma")) {
- // .pragma library
- if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library")))
- return false; // expected `library
-
- // we found a .pragma library directive
- directives->pragmaLibrary();
-
- } else {
- Q_ASSERT(directiveName == QLatin1String("import"));
- lex(); // skip .import
-
- QString pathOrUri;
- QString version;
- bool fileImport = false; // file or uri import
-
- if (_tokenKind == T_STRING_LITERAL) {
- // .import T_STRING_LITERAL as T_IDENTIFIER
-
- fileImport = true;
- pathOrUri = tokenText();
-
- } else if (_tokenKind == T_IDENTIFIER) {
- // .import T_IDENTIFIER (. T_IDENTIFIER)* T_NUMERIC_LITERAL as T_IDENTIFIER
-
- pathOrUri = tokenText();
-
- lex(); // skip the first T_IDENTIFIER
- for (; _tokenKind == T_DOT; lex()) {
- if (lex() != T_IDENTIFIER)
- return false;
-
- pathOrUri += QLatin1Char('.');
- pathOrUri += tokenText();
- }
-
- if (_tokenKind != T_NUMERIC_LITERAL)
- return false; // expected the module version number
-
- version = tokenText();
- }
-
- //
- // recognize the mandatory `as' followed by the module name
- //
- if (! (lex() == T_RESERVED_WORD && tokenText() == QLatin1String("as")))
- return false; // expected `as'
-
- if (lex() != T_IDENTIFIER)
- return false; // expected module name
-
- const QString module = tokenText();
-
- if (fileImport)
- directives->importFile(pathOrUri, module);
- else
- directives->importModule(pathOrUri, version, module);
- }
-
- if (tokenStartLine() != lineNumber)
- return false; // the directives cannot span over multiple lines
-
- // fetch the first token after the .pragma/.import directive
- lex();
- } while (_tokenKind == T_DOT);
-
- return true;
-}
-
-#include "qdeclarativejskeywords_p.h"
diff --git a/src/declarative/qml/parser/qdeclarativejslexer_p.h b/src/declarative/qml/parser/qdeclarativejslexer_p.h
deleted file mode 100644
index 806603e022..0000000000
--- a/src/declarative/qml/parser/qdeclarativejslexer_p.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEJSLEXER_P_H
-#define QDECLARATIVEJSLEXER_P_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 "qdeclarativejsglobal_p.h"
-#include "qdeclarativejsgrammar_p.h"
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-class Engine;
-
-class QML_PARSER_EXPORT Directives {
-public:
- virtual ~Directives() {}
-
- virtual void pragmaLibrary()
- {
- }
-
- virtual void importFile(const QString &jsfile, const QString &module)
- {
- Q_UNUSED(jsfile);
- Q_UNUSED(module);
- }
-
- virtual void importModule(const QString &uri, const QString &version, const QString &module)
- {
- Q_UNUSED(uri);
- Q_UNUSED(version);
- Q_UNUSED(module);
- }
-};
-
-class QML_PARSER_EXPORT Lexer: public QDeclarativeJSGrammar
-{
-public:
- enum {
- T_ABSTRACT = T_RESERVED_WORD,
- T_BOOLEAN = T_RESERVED_WORD,
- T_BYTE = T_RESERVED_WORD,
- T_CHAR = T_RESERVED_WORD,
- T_CLASS = T_RESERVED_WORD,
- T_DOUBLE = T_RESERVED_WORD,
- T_ENUM = T_RESERVED_WORD,
- T_EXPORT = T_RESERVED_WORD,
- T_EXTENDS = T_RESERVED_WORD,
- T_FINAL = T_RESERVED_WORD,
- T_FLOAT = T_RESERVED_WORD,
- T_GOTO = T_RESERVED_WORD,
- T_IMPLEMENTS = T_RESERVED_WORD,
- T_INT = T_RESERVED_WORD,
- T_INTERFACE = T_RESERVED_WORD,
- T_LET = T_RESERVED_WORD,
- T_LONG = T_RESERVED_WORD,
- T_NATIVE = T_RESERVED_WORD,
- T_PACKAGE = T_RESERVED_WORD,
- T_PRIVATE = T_RESERVED_WORD,
- T_PROTECTED = T_RESERVED_WORD,
- T_SHORT = T_RESERVED_WORD,
- T_STATIC = T_RESERVED_WORD,
- T_SUPER = T_RESERVED_WORD,
- T_SYNCHRONIZED = T_RESERVED_WORD,
- T_THROWS = T_RESERVED_WORD,
- T_TRANSIENT = T_RESERVED_WORD,
- T_VOLATILE = T_RESERVED_WORD,
- T_YIELD = T_RESERVED_WORD
- };
-
- enum Error {
- NoError,
- IllegalCharacter,
- UnclosedStringLiteral,
- IllegalEscapeSequence,
- IllegalUnicodeEscapeSequence,
- UnclosedComment,
- IllegalExponentIndicator,
- IllegalIdentifier
- };
-
- enum RegExpBodyPrefix {
- NoPrefix,
- EqualPrefix
- };
-
- enum RegExpFlag {
- RegExp_Global = 0x01,
- RegExp_IgnoreCase = 0x02,
- RegExp_Multiline = 0x04
- };
-
-public:
- Lexer(Engine *engine);
-
- bool qmlMode() const;
-
- QString code() const;
- void setCode(const QString &code, int lineno, bool qmlMode = true);
-
- int lex();
-
- bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix);
- bool scanDirectives(Directives *directives);
-
- int regExpFlags() const { return _patternFlags; }
- QString regExpPattern() const { return _tokenText; }
-
- int tokenKind() const;
- int tokenOffset() const;
- int tokenLength() const;
-
- int tokenStartLine() const;
- int tokenStartColumn() const;
-
- int tokenEndLine() const;
- int tokenEndColumn() const;
-
- QStringRef tokenSpell() const;
- double tokenValue() const;
- QString tokenText() const;
-
- Error errorCode() const;
- QString errorMessage() const;
-
- bool prevTerminator() const;
- bool followsClosingBrace() const;
- bool canInsertAutomaticSemicolon(int token) const;
-
- enum ParenthesesState {
- IgnoreParentheses,
- CountParentheses,
- BalancedParentheses
- };
-
-protected:
- int classify(const QChar *s, int n, bool qmlMode);
-
-private:
- inline void scanChar();
- int scanToken();
-
- bool isLineTerminator() const;
- static bool isIdentLetter(QChar c);
- static bool isDecimalDigit(ushort c);
- static bool isHexDigit(QChar c);
- static bool isOctalDigit(ushort c);
- static bool isUnicodeEscapeSequence(const QChar *chars);
-
- void syncProhibitAutomaticSemicolon();
- QChar decodeUnicodeEscapeCharacter(bool *ok);
-
-private:
- Engine *_engine;
-
- QString _code;
- QString _tokenText;
- QString _errorMessage;
- QStringRef _tokenSpell;
-
- const QChar *_codePtr;
- const QChar *_lastLinePtr;
- const QChar *_tokenLinePtr;
- const QChar *_tokenStartPtr;
-
- QChar _char;
- Error _errorCode;
-
- int _currentLineNumber;
- double _tokenValue;
-
- // parentheses state
- ParenthesesState _parenthesesState;
- int _parenthesesCount;
-
- int _stackToken;
-
- int _patternFlags;
- int _tokenKind;
- int _tokenLength;
- int _tokenLine;
-
- bool _validTokenText;
- bool _prohibitAutomaticSemicolon;
- bool _restrictedKeyword;
- bool _terminator;
- bool _followsClosingBrace;
- bool _delimited;
- bool _qmlMode;
-};
-
-} // end of namespace QDeclarativeJS
-
-QT_QML_END_NAMESPACE
-
-#endif // LEXER_H
diff --git a/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h b/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h
deleted file mode 100644
index 22baff2254..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEJSMEMORYPOOL_P_H
-#define QDECLARATIVEJSMEMORYPOOL_P_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 "qdeclarativejsglobal_p.h"
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qshareddata.h>
-#include <QtCore/qdebug.h>
-
-#include <cstring>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-class QML_PARSER_EXPORT MemoryPool : public QSharedData
-{
- MemoryPool(const MemoryPool &other);
- void operator =(const MemoryPool &other);
-
-public:
- MemoryPool()
- : _blocks(0),
- _allocatedBlocks(0),
- _blockCount(-1),
- _ptr(0),
- _end(0)
- { }
-
- ~MemoryPool()
- {
- if (_blocks) {
- for (int i = 0; i < _allocatedBlocks; ++i) {
- if (char *b = _blocks[i])
- qFree(b);
- }
-
- qFree(_blocks);
- }
- }
-
- inline void *allocate(size_t size)
- {
- size = (size + 7) & ~7;
- if (_ptr && (_ptr + size < _end)) {
- void *addr = _ptr;
- _ptr += size;
- return addr;
- }
- return allocate_helper(size);
- }
-
- void reset()
- {
- _blockCount = -1;
- _ptr = _end = 0;
- }
-
-private:
- void *allocate_helper(size_t size)
- {
- Q_ASSERT(size < BLOCK_SIZE);
-
- if (++_blockCount == _allocatedBlocks) {
- if (! _allocatedBlocks)
- _allocatedBlocks = DEFAULT_BLOCK_COUNT;
- else
- _allocatedBlocks *= 2;
-
- _blocks = (char **) qRealloc(_blocks, sizeof(char *) * _allocatedBlocks);
-
- for (int index = _blockCount; index < _allocatedBlocks; ++index)
- _blocks[index] = 0;
- }
-
- char *&block = _blocks[_blockCount];
-
- if (! block)
- block = (char *) qMalloc(BLOCK_SIZE);
-
- _ptr = block;
- _end = _ptr + BLOCK_SIZE;
-
- void *addr = _ptr;
- _ptr += size;
- return addr;
- }
-
-private:
- char **_blocks;
- int _allocatedBlocks;
- int _blockCount;
- char *_ptr;
- char *_end;
-
- enum
- {
- BLOCK_SIZE = 8 * 1024,
- DEFAULT_BLOCK_COUNT = 8
- };
-};
-
-class QML_PARSER_EXPORT Managed
-{
- Managed(const Managed &other);
- void operator = (const Managed &other);
-
-public:
- Managed() {}
- ~Managed() {}
-
- void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); }
- void operator delete(void *) {}
- void operator delete(void *, MemoryPool *) {}
-};
-
-} // namespace QDeclarativeJS
-
-QT_QML_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp
deleted file mode 100644
index 384544afe4..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsparser.cpp
+++ /dev/null
@@ -1,1812 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QtDebug>
-#include <QtCore/QCoreApplication>
-
-#include <string.h>
-
-#include "qdeclarativejsengine_p.h"
-#include "qdeclarativejslexer_p.h"
-#include "qdeclarativejsast_p.h"
-#include "qdeclarativejsmemorypool_p.h"
-
-
-
-#include "qdeclarativejsparser_p.h"
-#include <QVarLengthArray>
-
-//
-// This file is automatically generated from qmljs.g.
-// Changes will be lost.
-//
-
-using namespace QDeclarativeJS;
-
-QT_QML_BEGIN_NAMESPACE
-
-void Parser::reallocateStack()
-{
- if (! stack_size)
- stack_size = 128;
- else
- stack_size <<= 1;
-
- sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
- state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
- location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
- string_stack = reinterpret_cast<QStringRef*> (realloc(string_stack, stack_size * sizeof(QStringRef)));
-}
-
-Parser::Parser(Engine *engine):
- driver(engine),
- pool(engine->pool()),
- tos(0),
- stack_size(0),
- sym_stack(0),
- state_stack(0),
- location_stack(0),
- string_stack(0),
- first_token(0),
- last_token(0)
-{
-}
-
-Parser::~Parser()
-{
- if (stack_size) {
- free(sym_stack);
- free(state_stack);
- free(location_stack);
- free(string_stack);
- }
-}
-
-static inline AST::SourceLocation location(Lexer *lexer)
-{
- AST::SourceLocation loc;
- loc.offset = lexer->tokenOffset();
- loc.length = lexer->tokenLength();
- loc.startLine = lexer->tokenStartLine();
- loc.startColumn = lexer->tokenStartColumn();
- return loc;
-}
-
-AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
-{
- QVarLengthArray<QStringRef, 4> nameIds;
- QVarLengthArray<AST::SourceLocation, 4> locations;
-
- AST::ExpressionNode *it = expr;
- while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
- nameIds.append(m->name);
- locations.append(m->identifierToken);
- it = m->base;
- }
-
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
- AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name);
- q->identifierToken = idExpr->identifierToken;
-
- AST::UiQualifiedId *currentId = q;
- for (int i = nameIds.size() - 1; i != -1; --i) {
- currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]);
- currentId->identifierToken = locations[i];
- }
-
- return currentId->finish();
- }
-
- return 0;
-}
-
-bool Parser::parse(int startToken)
-{
- Lexer *lexer = driver->lexer();
- bool hadErrors = false;
- int yytoken = -1;
- int action = 0;
-
- token_buffer[0].token = startToken;
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- tos = -1;
- program = 0;
-
- do {
- if (++tos == stack_size)
- reallocateStack();
-
- state_stack[tos] = action;
-
- _Lcheck_token:
- if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
- yyprevlloc = yylloc;
-
- if (first_token == last_token) {
- yytoken = lexer->lex();
- yylval = lexer->tokenValue();
- yytokenspell = lexer->tokenSpell();
- yylloc = location(lexer);
- } else {
- yytoken = first_token->token;
- yylval = first_token->dval;
- yytokenspell = first_token->spell;
- yylloc = first_token->loc;
- ++first_token;
- }
- }
-
- action = t_action(action, yytoken);
- if (action > 0) {
- if (action != ACCEPT_STATE) {
- yytoken = -1;
- sym(1).dval = yylval;
- stringRef(1) = yytokenspell;
- loc(1) = yylloc;
- } else {
- --tos;
- return ! hadErrors;
- }
- } else if (action < 0) {
- const int r = -action - 1;
- tos -= rhs[r];
-
- switch (r) {
-
-case 0: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 1: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 2: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 3: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 4: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 5: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 6: {
- sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList,
- sym(2).UiObjectMemberList->finish());
-} break;
-
-case 8: {
- sym(1).Node = sym(1).UiImportList->finish();
-} break;
-
-case 9: {
- sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport);
-} break;
-
-case 10: {
- sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport);
-} break;
-
-case 13: {
- sym(1).UiImport->semicolonToken = loc(2);
-} break;
-
-case 15: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->semicolonToken = loc(3);
-} break;
-
-case 17: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->asToken = loc(3);
- sym(1).UiImport->importIdToken = loc(4);
- sym(1).UiImport->importId = stringRef(4);
- sym(1).UiImport->semicolonToken = loc(5);
-} break;
-
-case 19: {
- sym(1).UiImport->asToken = loc(2);
- sym(1).UiImport->importIdToken = loc(3);
- sym(1).UiImport->importId = stringRef(3);
- sym(1).UiImport->semicolonToken = loc(4);
-} break;
-
-case 20: {
- AST::UiImport *node = 0;
-
- if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
- node = new (pool) AST::UiImport(importIdLiteral->value);
- node->fileNameToken = loc(2);
- } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
- node = new (pool) AST::UiImport(qualifiedId);
- node->fileNameToken = loc(2);
- }
-
- sym(1).Node = node;
-
- if (node) {
- node->importToken = loc(1);
- } else {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id or a string literal")));
-
- return false; // ### remove me
- }
-} break;
-
-case 21: {
- sym(1).Node = 0;
-} break;
-
-case 22: {
- sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
-} break;
-
-case 23: {
- sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
-} break;
-
-case 24: {
- AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList(
- sym(1).UiObjectMemberList, sym(2).UiObjectMember);
- sym(1).Node = node;
-} break;
-
-case 25: {
- sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember);
-} break;
-
-case 26: {
- AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList(
- sym(1).UiArrayMemberList, sym(3).UiObjectMember);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 27: {
- AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 28: {
- AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 29: {
- AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId,
- sym(2).UiObjectInitializer);
- sym(1).Node = node;
-} break;
-
-case 31: {
- AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding(
- sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
- node->colonToken = loc(2);
- node->lbracketToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 32: {
- AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
- sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 33: {
- AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
- sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- node->hasOnToken = true;
- sym(1).Node = node;
-} break;
-
-case 41:
-{
- AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding(
- sym(1).UiQualifiedId, sym(3).Statement);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 45: {
- sym(1).Node = 0;
-} break;
-
-case 46: {
- sym(1).Node = sym(1).UiParameterList->finish ();
-} break;
-
-case 47: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2));
- node->propertyTypeToken = loc(1);
- node->identifierToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 48: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
- node->commaToken = loc(2);
- node->identifierToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 50: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->parameters = sym(4).UiParameterList;
- node->semicolonToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 52: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 54: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
- node->typeModifier = stringRef(2);
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 56: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 58: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4));
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 59: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3),
- sym(5).Statement);
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 60: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
- sym(6).Statement);
- node->isReadonlyMember = true;
- node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 61: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
- sym(6).Statement);
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 62: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
- node->typeModifier = stringRef(2);
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6));
- propertyName->identifierToken = loc(6);
- propertyName->next = 0;
-
- AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(
- propertyName, sym(9).UiArrayMemberList->finish());
- binding->colonToken = loc(7);
- binding->lbracketToken = loc(8);
- binding->rbracketToken = loc(10);
-
- node->binding = binding;
-
- sym(1).Node = node;
-} break;
-
-case 63: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3));
- propertyName->identifierToken = loc(3);
- propertyName->next = 0;
-
- AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
- propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer);
- binding->colonToken = loc(4);
-
- node->binding = binding;
-
- sym(1).Node = node;
-} break;
-
-case 64: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
-} break;
-
-case 65: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
-} break;
-
-case 71: {
- AST::ThisExpression *node = new (pool) AST::ThisExpression();
- node->thisToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 72: {
- AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 73: {
- AST::NullExpression *node = new (pool) AST::NullExpression();
- node->nullToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 74: {
- AST::TrueLiteral *node = new (pool) AST::TrueLiteral();
- node->trueToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 75: {
- AST::FalseLiteral *node = new (pool) AST::FalseLiteral();
- node->falseToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 76: {
- AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-case 77:
-case 78: {
- AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1));
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 79: {
- bool rx = lexer->scanRegExp(Lexer::NoPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false; // ### remove me
- }
-
- loc(1).length = lexer->tokenLength();
- yylloc = loc(1); // adjust the location of the current token
-
- AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
- driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 80: {
- bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false;
- }
-
- loc(1).length = lexer->tokenLength();
- yylloc = loc(1); // adjust the location of the current token
-
- AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
- driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 81: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 82: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 83: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 84: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
- (AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 85: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
- sym(4).Elision->finish());
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 86: {
- AST::ObjectLiteral *node = 0;
- if (sym(2).Node)
- node = new (pool) AST::ObjectLiteral(
- sym(2).PropertyNameAndValueList->finish ());
- else
- node = new (pool) AST::ObjectLiteral();
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 87: {
- AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
- sym(2).PropertyNameAndValueList->finish ());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 88: {
- AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression);
- node->lparenToken = loc(1);
- node->rparenToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 89: {
- if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
- QLatin1String("Ignored annotation")));
-
- sym(1).Expression = mem->base;
- }
-
- if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
- sym(1).UiQualifiedId = qualifiedId;
- } else {
- sym(1).UiQualifiedId = 0;
-
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id")));
-
- return false; // ### recover
- }
-} break;
-
-case 90: {
- sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression);
-} break;
-
-case 91: {
- sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression);
-} break;
-
-case 92: {
- AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList,
- (AST::Elision *) 0, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 93: {
- AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(),
- sym(4).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 94: {
- AST::Elision *node = new (pool) AST::Elision();
- node->commaToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 95: {
- AST::Elision *node = new (pool) AST::Elision(sym(1).Elision);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 96: {
- AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
- sym(1).PropertyName, sym(3).Expression);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 97: {
- AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
- sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
- node->commaToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 98: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-case 99:
-case 100: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 101: {
- AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 102: {
- AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 103: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 139: {
- AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 140: {
- AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 141: {
- AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList);
- node->newToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 143: {
- AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression);
- node->newToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 144: {
- AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 145: {
- AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 146: {
- AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 147: {
- AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 148: {
- sym(1).Node = 0;
-} break;
-
-case 149: {
- sym(1).Node = sym(1).ArgumentList->finish();
-} break;
-
-case 150: {
- sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression);
-} break;
-
-case 151: {
- AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 155: {
- AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression);
- node->incrementToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 156: {
- AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression);
- node->decrementToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 158: {
- AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression);
- node->deleteToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 159: {
- AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression);
- node->voidToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 160: {
- AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression);
- node->typeofToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 161: {
- AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression);
- node->incrementToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 162: {
- AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression);
- node->decrementToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 163: {
- AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression);
- node->plusToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 164: {
- AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression);
- node->minusToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 165: {
- AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression);
- node->tildeToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 166: {
- AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression);
- node->notToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 168: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Mul, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 169: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Div, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 170: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Mod, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 172: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Add, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 173: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Sub, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 175: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::LShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 176: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::RShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 177: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::URShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 179: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 180: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 181: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 182: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 183: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 184: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::In, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 186: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 187: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 188: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 189: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 190: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 192: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 193: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 194: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 195: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 197: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 198: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 199: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 200: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 202: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 204: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 206: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 208: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 210: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 212: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 214: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 216: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 218: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 220: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 222: {
- AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 224: {
- AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 226: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 228: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 229: {
- sym(1).ival = QSOperator::Assign;
-} break;
-
-case 230: {
- sym(1).ival = QSOperator::InplaceMul;
-} break;
-
-case 231: {
- sym(1).ival = QSOperator::InplaceDiv;
-} break;
-
-case 232: {
- sym(1).ival = QSOperator::InplaceMod;
-} break;
-
-case 233: {
- sym(1).ival = QSOperator::InplaceAdd;
-} break;
-
-case 234: {
- sym(1).ival = QSOperator::InplaceSub;
-} break;
-
-case 235: {
- sym(1).ival = QSOperator::InplaceLeftShift;
-} break;
-
-case 236: {
- sym(1).ival = QSOperator::InplaceRightShift;
-} break;
-
-case 237: {
- sym(1).ival = QSOperator::InplaceURightShift;
-} break;
-
-case 238: {
- sym(1).ival = QSOperator::InplaceAnd;
-} break;
-
-case 239: {
- sym(1).ival = QSOperator::InplaceXor;
-} break;
-
-case 240: {
- sym(1).ival = QSOperator::InplaceOr;
-} break;
-
-case 242: {
- AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 243: {
- sym(1).Node = 0;
-} break;
-
-case 246: {
- AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 247: {
- sym(1).Node = 0;
-} break;
-
-case 264: {
- AST::Block *node = new (pool) AST::Block(sym(2).StatementList);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 265: {
- sym(1).Node = new (pool) AST::StatementList(sym(1).Statement);
-} break;
-
-case 266: {
- sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement);
-} break;
-
-case 267: {
- sym(1).Node = 0;
-} break;
-
-case 268: {
- sym(1).Node = sym(1).StatementList->finish ();
-} break;
-
-case 270: {
- AST::VariableStatement *node = new (pool) AST::VariableStatement(
- sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
- node->declarationKindToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 271: {
- sym(1).ival = T_CONST;
-} break;
-
-case 272: {
- sym(1).ival = T_VAR;
-} break;
-
-case 273: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
-} break;
-
-case 274: {
- AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList(
- sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 275: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
-} break;
-
-case 276: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
-} break;
-
-case 277: {
- AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 278: {
- AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 279: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-
-case 280: {
- sym(1).Node = 0;
-} break;
-
-case 282: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-
-case 283: {
- sym(1).Node = 0;
-} break;
-
-case 285: {
- AST::EmptyStatement *node = new (pool) AST::EmptyStatement();
- node->semicolonToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 287: {
- AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 288: {
- AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- node->elseToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 289: {
- AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 291: {
- AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
- node->doToken = loc(1);
- node->whileToken = loc(3);
- node->lparenToken = loc(4);
- node->rparenToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 292: {
- AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
- node->whileToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 293: {
- AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression,
- sym(5).Expression, sym(7).Expression, sym(9).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->firstSemicolonToken = loc(4);
- node->secondSemicolonToken = loc(6);
- node->rparenToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 294: {
- AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
- sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
- sym(8).Expression, sym(10).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->firstSemicolonToken = loc(5);
- node->secondSemicolonToken = loc(7);
- node->rparenToken = loc(9);
- sym(1).Node = node;
-} break;
-
-case 295: {
- AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression,
- sym(5).Expression, sym(7).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->inToken = loc(4);
- node->rparenToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 296: {
- AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement(
- sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->inToken = loc(5);
- node->rparenToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 298: {
- AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
- node->continueToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 300: {
- AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
- node->continueToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 302: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
- node->breakToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 304: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
- node->breakToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 306: {
- AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
- node->returnToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 307: {
- AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
- node->withToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 308: {
- AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
- node->switchToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 309: {
- AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 310: {
- AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 311: {
- sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
-} break;
-
-case 312: {
- sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
-} break;
-
-case 313: {
- sym(1).Node = 0;
-} break;
-
-case 314: {
- sym(1).Node = sym(1).CaseClauses->finish ();
-} break;
-
-case 315: {
- AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
- node->caseToken = loc(1);
- node->colonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 316: {
- AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
- node->defaultToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-case 317:
-case 318: {
- AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 319: {
- AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 321: {
- AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
- node->throwToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 322: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 323: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 324: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 325: {
- AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
- node->catchToken = loc(1);
- node->lparenToken = loc(2);
- node->identifierToken = loc(3);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 326: {
- AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
- node->finallyToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 328: {
- AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
- node->debuggerToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 329: {
- AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 330: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- if (! stringRef(2).isNull())
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 331: {
- AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 332: {
- AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3));
- node->commaToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 333: {
- sym(1).Node = 0;
-} break;
-
-case 334: {
- sym(1).Node = sym(1).FormalParameterList->finish ();
-} break;
-
-case 335: {
- sym(1).Node = 0;
-} break;
-
-case 337: {
- sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ());
-} break;
-
-case 339: {
- sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ());
-} break;
-
-case 340: {
- sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement);
-} break;
-
-case 341: {
- sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement);
-} break;
-
-case 342: {
- sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement);
-} break;
-
-case 343: {
- sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration);
-} break;
-
-case 344: {
- stringRef(1) = QStringRef();
-} break;
-
-case 346: {
- sym(1).Node = 0;
-} break;
-
- } // switch
- action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
- } // if
- } while (action != 0);
-
- if (first_token == last_token) {
- const int errorState = state_stack[tos];
-
- // automatic insertion of `;'
- if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) {
- SavedToken &tk = token_buffer[0];
- tk.token = yytoken;
- tk.dval = yylval;
- tk.spell = yytokenspell;
- tk.loc = yylloc;
-
- yylloc = yyprevlloc;
- yylloc.offset += yylloc.length;
- yylloc.startColumn += yylloc.length;
- yylloc.length = 0;
-
- //const QString msg = qApp->translate("QDeclarativeParser", "Missing `;'");
- //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- yytoken = T_SEMICOLON;
- yylval = 0;
-
- action = errorState;
-
- goto _Lcheck_token;
- }
-
- hadErrors = true;
-
- token_buffer[0].token = yytoken;
- token_buffer[0].dval = yylval;
- token_buffer[0].spell = yytokenspell;
- token_buffer[0].loc = yylloc;
-
- token_buffer[1].token = yytoken = lexer->lex();
- token_buffer[1].dval = yylval = lexer->tokenValue();
- token_buffer[1].spell = yytokenspell = lexer->tokenSpell();
- token_buffer[1].loc = yylloc = location(lexer);
-
- if (t_action(errorState, yytoken)) {
- QString msg;
- int token = token_buffer[0].token;
- if (token < 0 || token >= TERMINAL_COUNT)
- msg = qApp->translate("QDeclarativeParser", "Syntax error");
- else
- msg = qApp->translate("QDeclarativeParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- action = errorState;
- goto _Lcheck_token;
- }
-
- static int tokens[] = {
- T_PLUS,
- T_EQ,
-
- T_COMMA,
- T_COLON,
- T_SEMICOLON,
-
- T_RPAREN, T_RBRACKET, T_RBRACE,
-
- T_NUMERIC_LITERAL,
- T_IDENTIFIER,
-
- T_LPAREN, T_LBRACKET, T_LBRACE,
-
- EOF_SYMBOL
- };
-
- for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
- int a = t_action(errorState, *tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = *tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[2];
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
- if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
- tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
- tk == T_FEED_JS_SOURCE_ELEMENT)
- continue;
-
- int a = t_action(errorState, tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- const QString msg = qApp->translate("QDeclarativeParser", "Syntax error");
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
- }
-
- return false;
-}
-
-QT_QML_END_NAMESPACE
-
-
diff --git a/src/declarative/qml/parser/qdeclarativejsparser_p.h b/src/declarative/qml/parser/qdeclarativejsparser_p.h
deleted file mode 100644
index 1e6da5944b..0000000000
--- a/src/declarative/qml/parser/qdeclarativejsparser_p.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-//
-// 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.
-//
-
-//
-// This file is automatically generated from qmljs.g.
-// Changes will be lost.
-//
-
-#ifndef QDECLARATIVEJSPARSER_P_H
-#define QDECLARATIVEJSPARSER_P_H
-
-#include "qdeclarativejsglobal_p.h"
-#include "qdeclarativejsgrammar_p.h"
-#include "qdeclarativejsast_p.h"
-#include "qdeclarativejsengine_p.h"
-
-#include <QtCore/QList>
-#include <QtCore/QString>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-class Engine;
-
-class QML_PARSER_EXPORT Parser: protected QDeclarativeJSGrammar
-{
-public:
- union Value {
- int ival;
- double dval;
- AST::ArgumentList *ArgumentList;
- AST::CaseBlock *CaseBlock;
- AST::CaseClause *CaseClause;
- AST::CaseClauses *CaseClauses;
- AST::Catch *Catch;
- AST::DefaultClause *DefaultClause;
- AST::ElementList *ElementList;
- AST::Elision *Elision;
- AST::ExpressionNode *Expression;
- AST::Finally *Finally;
- AST::FormalParameterList *FormalParameterList;
- AST::FunctionBody *FunctionBody;
- AST::FunctionDeclaration *FunctionDeclaration;
- AST::Node *Node;
- AST::PropertyName *PropertyName;
- AST::PropertyNameAndValueList *PropertyNameAndValueList;
- AST::SourceElement *SourceElement;
- AST::SourceElements *SourceElements;
- AST::Statement *Statement;
- AST::StatementList *StatementList;
- AST::Block *Block;
- AST::VariableDeclaration *VariableDeclaration;
- AST::VariableDeclarationList *VariableDeclarationList;
-
- AST::UiProgram *UiProgram;
- AST::UiImportList *UiImportList;
- AST::UiImport *UiImport;
- AST::UiParameterList *UiParameterList;
- AST::UiPublicMember *UiPublicMember;
- AST::UiObjectDefinition *UiObjectDefinition;
- AST::UiObjectInitializer *UiObjectInitializer;
- AST::UiObjectBinding *UiObjectBinding;
- AST::UiScriptBinding *UiScriptBinding;
- AST::UiArrayBinding *UiArrayBinding;
- AST::UiObjectMember *UiObjectMember;
- AST::UiObjectMemberList *UiObjectMemberList;
- AST::UiArrayMemberList *UiArrayMemberList;
- AST::UiQualifiedId *UiQualifiedId;
- };
-
-public:
- Parser(Engine *engine);
- ~Parser();
-
- // parse a UI program
- bool parse() { return parse(T_FEED_UI_PROGRAM); }
- bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
- bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
- bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
- bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
- bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
-
- AST::UiProgram *ast() const
- { return AST::cast<AST::UiProgram *>(program); }
-
- AST::Statement *statement() const
- {
- if (! program)
- return 0;
-
- return program->statementCast();
- }
-
- AST::ExpressionNode *expression() const
- {
- if (! program)
- return 0;
-
- return program->expressionCast();
- }
-
- AST::UiObjectMember *uiObjectMember() const
- {
- if (! program)
- return 0;
-
- return program->uiObjectMemberCast();
- }
-
- AST::Node *rootNode() const
- { return program; }
-
- QList<DiagnosticMessage> diagnosticMessages() const
- { return diagnostic_messages; }
-
- inline DiagnosticMessage diagnosticMessage() const
- {
- foreach (const DiagnosticMessage &d, diagnostic_messages) {
- if (! d.kind == DiagnosticMessage::Warning)
- return d;
- }
-
- return DiagnosticMessage();
- }
-
- inline QString errorMessage() const
- { return diagnosticMessage().message; }
-
- inline int errorLineNumber() const
- { return diagnosticMessage().loc.startLine; }
-
- inline int errorColumnNumber() const
- { return diagnosticMessage().loc.startColumn; }
-
-protected:
- bool parse(int startToken);
-
- void reallocateStack();
-
- inline Value &sym(int index)
- { return sym_stack [tos + index - 1]; }
-
- inline QStringRef &stringRef(int index)
- { return string_stack [tos + index - 1]; }
-
- inline AST::SourceLocation &loc(int index)
- { return location_stack [tos + index - 1]; }
-
- AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
-
-protected:
- Engine *driver;
- MemoryPool *pool;
- int tos;
- int stack_size;
- Value *sym_stack;
- int *state_stack;
- AST::SourceLocation *location_stack;
- QStringRef *string_stack;
-
- AST::Node *program;
-
- // error recovery
- enum { TOKEN_BUFFER_SIZE = 3 };
-
- struct SavedToken {
- int token;
- double dval;
- AST::SourceLocation loc;
- QStringRef spell;
- };
-
- double yylval;
- QStringRef yytokenspell;
- AST::SourceLocation yylloc;
- AST::SourceLocation yyprevlloc;
-
- SavedToken token_buffer[TOKEN_BUFFER_SIZE];
- SavedToken *first_token;
- SavedToken *last_token;
-
- QList<DiagnosticMessage> diagnostic_messages;
-};
-
-} // end of namespace QDeclarativeJS
-
-
-
-#define J_SCRIPT_REGEXPLITERAL_RULE1 79
-
-#define J_SCRIPT_REGEXPLITERAL_RULE2 80
-
-QT_QML_END_NAMESPACE
-
-
-
-#endif // QDECLARATIVEJSPARSER_P_H
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
deleted file mode 100644
index 2d199b79e6..0000000000
--- a/src/declarative/qml/qdeclarative.h
+++ /dev/null
@@ -1,451 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVE_H
-#define QDECLARATIVE_H
-
-#include <QtDeclarative/qdeclarativeprivate.h>
-#include <QtDeclarative/qdeclarativeparserstatus.h>
-#include <QtDeclarative/qdeclarativepropertyvaluesource.h>
-#include <QtDeclarative/qdeclarativelist.h>
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qmetaobject.h>
-
-QT_BEGIN_HEADER
-
-#define QML_VERSION 0x020000
-#define QML_VERSION_STR "2.0"
-
-#define QML_DECLARE_TYPE(TYPE) \
- Q_DECLARE_METATYPE(TYPE *) \
- Q_DECLARE_METATYPE(QDeclarativeListProperty<TYPE>)
-
-#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \
- Q_DECLARE_METATYPE(QDeclarativeListProperty<TYPE>)
-
-#define QML_DECLARE_INTERFACE(INTERFACE) \
- QML_DECLARE_TYPE(INTERFACE)
-
-#define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \
- QML_DECLARE_TYPE_HASMETATYPE(INTERFACE)
-
-enum { /* TYPEINFO flags */
- QML_HAS_ATTACHED_PROPERTIES = 0x01
-};
-
-#define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \
-QT_BEGIN_NAMESPACE \
-template <> \
-class QDeclarativeTypeInfo<TYPE > \
-{ \
-public: \
- enum { \
- hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \
- }; \
-}; \
-QT_END_NAMESPACE
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativePropertyValueInterceptor;
-
-template<typename T>
-int qmlRegisterType()
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativePrivate::RegisterType type = {
- 0,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
- 0, 0,
- QString(),
-
- 0, 0, 0, 0, &T::staticMetaObject,
-
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
-
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
-
- 0, 0,
-
- 0,
- 0
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-int Q_DECLARATIVE_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message);
-
-template<typename T>
-int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativePrivate::RegisterType type = {
- 0,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
- 0, 0,
- reason,
-
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
-
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
-
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
-
- 0, 0,
-
- 0,
- 0
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-template<typename T>
-int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativePrivate::RegisterType type = {
- 0,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
- sizeof(T), QDeclarativePrivate::createInto<T>,
- QString(),
-
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
-
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
-
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
-
- 0, 0,
-
- 0,
- 0
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-template<typename T, int metaObjectRevision>
-int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativePrivate::RegisterType type = {
- 1,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
- sizeof(T), QDeclarativePrivate::createInto<T>,
- QString(),
-
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
-
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
-
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
-
- 0, 0,
-
- 0,
- metaObjectRevision
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-template<typename T, int metaObjectRevision>
-int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativePrivate::RegisterType type = {
- 1,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
- sizeof(T), QDeclarativePrivate::createInto<T>,
- QString(),
-
- uri, versionMajor, versionMinor, 0, &T::staticMetaObject,
-
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
-
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
-
- 0, 0,
-
- 0,
- metaObjectRevision
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-
-template<typename T, typename E>
-int qmlRegisterExtendedType()
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativePrivate::RegisterType type = {
- 0,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
- 0, 0,
- QString(),
-
- 0, 0, 0, 0, &T::staticMetaObject,
-
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
-
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
-
- QDeclarativePrivate::createParent<E>, &E::staticMetaObject,
-
- 0,
- 0
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-template<typename T, typename E>
-int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
- const char *qmlName)
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativeAttachedPropertiesFunc attached = QDeclarativePrivate::attachedPropertiesFunc<E>();
- const QMetaObject * attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<E>();
- if (!attached) {
- attached = QDeclarativePrivate::attachedPropertiesFunc<T>();
- attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<T>();
- }
-
- QDeclarativePrivate::RegisterType type = {
- 0,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
- sizeof(T), QDeclarativePrivate::createInto<T>,
- QString(),
-
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
-
- attached,
- attachedMetaObject,
-
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
-
- QDeclarativePrivate::createParent<E>, &E::staticMetaObject,
-
- 0,
- 0
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-template<typename T>
-int qmlRegisterInterface(const char *typeName)
-{
- QByteArray name(typeName);
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativePrivate::RegisterInterface qmlInterface = {
- 0,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
-
- qobject_interface_iid<T *>()
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::InterfaceRegistration, &qmlInterface);
-}
-
-template<typename T>
-int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
- const char *qmlName, QDeclarativeCustomParser *parser)
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
- QByteArray listName("QDeclarativeListProperty<" + name + ">");
-
- QDeclarativePrivate::RegisterType type = {
- 0,
-
- qRegisterMetaType<T *>(pointerName.constData()),
- qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
- sizeof(T), QDeclarativePrivate::createInto<T>,
- QString(),
-
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
-
- QDeclarativePrivate::attachedPropertiesFunc<T>(),
- QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
-
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
- QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
-
- 0, 0,
-
- parser,
- 0
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-class QDeclarativeContext;
-class QDeclarativeEngine;
-class QJSValue;
-class QJSEngine;
-Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *);
-Q_DECLARATIVE_EXPORT QDeclarativeContext *qmlContext(const QObject *);
-Q_DECLARATIVE_EXPORT QDeclarativeEngine *qmlEngine(const QObject *);
-Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true);
-Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObject(int *, const QObject *, const QMetaObject *, bool create);
-
-template<typename T>
-QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
-{
- static int idx = -1;
- return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create);
-}
-
-// For the use of QtQuick1 module
-Q_DECLARATIVE_EXPORT void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor);
-
-inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor,
- QJSValue (*callback)(QDeclarativeEngine *, QJSEngine *))
-{
- QDeclarativePrivate::RegisterModuleApi api = {
- 0,
-
- uri, versionMajor, versionMinor,
-
- callback, 0
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ModuleApiRegistration, &api);
-}
-
-inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor,
- QObject *(*callback)(QDeclarativeEngine *, QJSEngine *))
-{
- QDeclarativePrivate::RegisterModuleApi api = {
- 0,
-
- uri, versionMajor, versionMinor,
-
- 0, callback
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ModuleApiRegistration, &api);
-}
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QObject)
-Q_DECLARE_METATYPE(QVariant)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVE_H
diff --git a/src/declarative/qml/qdeclarativeaccessors.cpp b/src/declarative/qml/qdeclarativeaccessors.cpp
deleted file mode 100644
index 5659c2d550..0000000000
--- a/src/declarative/qml/qdeclarativeaccessors.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeaccessors_p.h"
-
-#include "qdeclarativedata_p.h"
-#include "qdeclarativenotifier_p.h"
-
-QT_BEGIN_NAMESPACE
-
-struct AccessorProperties {
- AccessorProperties();
-
- QReadWriteLock lock;
- QHash<const QMetaObject *, QDeclarativeAccessorProperties::Properties> properties;
-};
-
-Q_GLOBAL_STATIC(AccessorProperties, accessorProperties)
-
-QML_PRIVATE_ACCESSOR(QObject, QString, objectName, objectName)
-
-static void QObject_objectNameNotifier(QObject *object, intptr_t, QDeclarativeNotifier **notifier)
-{
- *notifier = QDeclarativeData::get(object, true)->objectNameNotifier();
-}
-
-static QDeclarativeAccessors QObject_objectName = { QObject_objectNameRead,
- QObject_objectNameNotifier };
-
-QML_DECLARE_PROPERTIES(QObject) {
- { QML_PROPERTY_NAME(objectName), 0, &QObject_objectName }
-};
-
-static void buildNameMask(QDeclarativeAccessorProperties::Properties &properties)
-{
- quint32 mask = 0;
-
- for (int ii = 0; ii < properties.count; ++ii) {
- Q_ASSERT(strlen(properties.properties[ii].name) == properties.properties[ii].nameLength);
- Q_ASSERT(properties.properties[ii].nameLength > 0);
-
- mask |= (1 << qMin(31U, properties.properties[ii].nameLength - 1));
- }
-
- properties.nameMask = mask;
-}
-
-AccessorProperties::AccessorProperties()
-{
- // Pre-seed QObject::objectName accessor
- typedef QDeclarativeAccessorProperties::Properties P;
- properties.insert(&QObject::staticMetaObject,
- P(qdeclarative_accessor_properties_QObject,
- sizeof(qdeclarative_accessor_properties_QObject) /
- sizeof(QDeclarativeAccessorProperties::Property)));
-}
-
-QDeclarativeAccessorProperties::Properties::Properties(Property *properties, int count)
-: count(count), properties(properties)
-{
- buildNameMask(*this);
-}
-
-QDeclarativeAccessorProperties::Properties
-QDeclarativeAccessorProperties::properties(const QMetaObject *mo)
-{
- AccessorProperties *This = accessorProperties();
-
- QReadLocker lock(&This->lock);
- return This->properties.value(mo);
-}
-
-void QDeclarativeAccessorProperties::registerProperties(const QMetaObject *mo, int count,
- Property *props)
-{
- Q_ASSERT(count > 0);
-
- Properties properties(props, count);
-
- AccessorProperties *This = accessorProperties();
-
- QWriteLocker lock(&This->lock);
-
- Q_ASSERT(!This->properties.contains(mo) || This->properties.value(mo) == properties);
-
- This->properties.insert(mo, properties);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeaccessors_p.h b/src/declarative/qml/qdeclarativeaccessors_p.h
deleted file mode 100644
index c52dc537ef..0000000000
--- a/src/declarative/qml/qdeclarativeaccessors_p.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEACCESSORS_P_H
-#define QDECLARATIVEACCESSORS_P_H
-
-#include <QtCore/qvector.h>
-#include <QtCore/qhash.h>
-#include <QtCore/QReadWriteLock>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-class QDeclarativeNotifier;
-
-// QML "accessor properties" allow V4 and V8 to bypass Qt's meta system to read and, more
-// importantly, subscribe to properties directly. Any property that is primarily read
-// from bindings is a candidate for inclusion as an accessor property.
-//
-// To define accessor properties, use the QML_DECLARE_PROPERTIES() and QML_DEFINE_PROPERTIES()
-// macros. The QML_DECLARE_PROPERTIES() macro is used to specify the properties, and the
-// QML_DEFINE_PROPERTIES() macro to register the properties with the
-// QDeclarativeAccessorProperties singleton.
-//
-// A class with accessor properties must also add the Q_CLASSINFO("qt_HasQmlAccessors", "true")
-// tag to its declaration. This is essential for QML to maintain internal consistency,
-// and forgetting to do so will probably cause your application to qFatal() with a
-// helpful reminder of this requirement.
-//
-// It is important that QML_DEFINE_PROPERTIES() has been called before QML ever sees
-// the type with the accessor properties. As QML_DEFINE_PROPERTIES() is idempotent, it is
-// recommended to call it in the type's constructor as well as when the type is registered
-// as a QML element (if it ever is). QML_DEFINE_PROPERTIES() is a very cheap operation
-// if registration has already occurred.
-
-#define QML_DECLARE_PROPERTIES(type) \
- static volatile bool qdeclarative_accessor_properties_isregistered_ ## type = false; \
- static QDeclarativeAccessorProperties::Property qdeclarative_accessor_properties_ ## type[] =
-
-#define QML_DEFINE_PROPERTIES(type) \
- do { \
- if (!qdeclarative_accessor_properties_isregistered_ ## type) { \
- int count = sizeof(qdeclarative_accessor_properties_ ## type) / \
- sizeof(QDeclarativeAccessorProperties::Property); \
- QDeclarativeAccessorProperties::registerProperties(&type::staticMetaObject, count, \
- qdeclarative_accessor_properties_ ## type);\
- qdeclarative_accessor_properties_isregistered_ ## type = true; \
- } \
- } while (false);
-
-#define QML_PRIVATE_ACCESSOR(clazz, cpptype, name, variable) \
- static void clazz ## _ ## name ## Read(QObject *o, intptr_t, void *rv) \
- { \
- clazz ## Private *d = clazz ## Private::get(static_cast<clazz *>(o)); \
- *static_cast<cpptype *>(rv) = d->variable; \
- }
-
-#define QML_PROPERTY_NAME(name) #name, sizeof #name - 1
-
-class QDeclarativeAccessors
-{
-public:
- void (*read)(QObject *object, intptr_t property, void *output);
- void (*notifier)(QObject *object, intptr_t property, QDeclarativeNotifier **notifier);
-};
-
-namespace QDeclarativeAccessorProperties {
- struct Property {
- const char *name;
- unsigned int nameLength;
- intptr_t data;
- QDeclarativeAccessors *accessors;
- };
-
- struct Properties {
- inline Properties();
- Properties(Property *, int);
-
- bool operator==(const Properties &o) const {
- return count == o.count && properties == o.properties;
- }
-
- inline Property *property(const char *name);
-
- int count;
- Property *properties;
- quint32 nameMask;
- };
-
- Properties properties(const QMetaObject *);
- void Q_DECLARATIVE_EXPORT registerProperties(const QMetaObject *, int, Property *);
-};
-
-QDeclarativeAccessorProperties::Property *
-QDeclarativeAccessorProperties::Properties::property(const char *name)
-{
- if (count == 0)
- return 0;
-
- unsigned int length = strlen(name);
-
- Q_ASSERT(length);
-
- if (nameMask & (1 << qMin(31U, length - 1))) {
-
- for (int ii = 0; ii < count; ++ii) {
- if (properties[ii].nameLength == length && 0 == qstrcmp(name, properties[ii].name))
- return &properties[ii];
- }
-
- }
-
- return 0;
-}
-
-QDeclarativeAccessorProperties::Properties::Properties()
-: count(0), properties(0), nameMask(0)
-{
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEACCESSORS_P_H
diff --git a/src/declarative/qml/qdeclarativeapplication.cpp b/src/declarative/qml/qdeclarativeapplication.cpp
deleted file mode 100644
index b5ceaf2550..0000000000
--- a/src/declarative/qml/qdeclarativeapplication.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeapplication_p.h"
-#include <private/qobject_p.h>
-#include <QtGui/QGuiApplication>
-#include <QtGui/QInputMethod>
-#include <QtCore/QDebug>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeApplicationPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeApplication)
-public:
- QDeclarativeApplicationPrivate() : active(QGuiApplication::activeWindow() != 0),
- layoutDirection(QGuiApplication::layoutDirection()) {}
- bool active;
- Qt::LayoutDirection layoutDirection;
-};
-
-/*
- This object and its properties are documented as part of the Qt object,
- in qdeclarativengine.cpp
-*/
-
-QDeclarativeApplication::QDeclarativeApplication(QObject *parent) : QObject(*new QDeclarativeApplicationPrivate(), parent)
-{
- if (qApp)
- qApp->installEventFilter(this);
-}
-
-QDeclarativeApplication::~QDeclarativeApplication()
-{
-}
-
-bool QDeclarativeApplication::active() const
-{
- Q_D(const QDeclarativeApplication);
- return d->active;
-}
-
-Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const
-{
- Q_D(const QDeclarativeApplication);
- return d->layoutDirection;
-}
-
-QObject *QDeclarativeApplication::inputPanel() const
-{
- static bool warned = false;
- if (!warned) {
- qWarning() << "Qt.application.inputPanel is deprecated, use Qt.inputMethod instead";
- warned = true;
- }
- return qApp ? qApp->inputMethod() : 0;
-}
-
-bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event)
-{
- Q_UNUSED(obj)
- Q_D(QDeclarativeApplication);
- if (event->type() == QEvent::ApplicationActivate
- || event->type() == QEvent::ApplicationDeactivate) {
- bool active = d->active;
- if (event->type() == QEvent::ApplicationActivate)
- active = true;
- else if (event->type() == QEvent::ApplicationDeactivate)
- active = false;
-
- if (d->active != active) {
- d->active = active;
- emit activeChanged();
- }
- }
- if (event->type() == QEvent::LayoutDirectionChange) {
- Qt::LayoutDirection direction = QGuiApplication::layoutDirection();
- if (d->layoutDirection != direction) {
- d->layoutDirection = direction;
- emit layoutDirectionChanged();
- }
- }
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeapplication_p.h b/src/declarative/qml/qdeclarativeapplication_p.h
deleted file mode 100644
index 4a0ff52d3e..0000000000
--- a/src/declarative/qml/qdeclarativeapplication_p.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEAPPLICATION_P_H
-#define QDECLARATIVEAPPLICATION_P_H
-
-#include <QtCore/QObject>
-#include <qdeclarative.h>
-#include <private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeApplicationPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeApplication : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(bool active READ active NOTIFY activeChanged)
- Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged)
- Q_PROPERTY(QObject *inputPanel READ inputPanel CONSTANT)
-
-public:
- explicit QDeclarativeApplication(QObject *parent = 0);
- virtual ~QDeclarativeApplication();
- bool active() const;
- Qt::LayoutDirection layoutDirection() const;
- QT_DEPRECATED QObject *inputPanel() const;
-
-protected:
- bool eventFilter(QObject *obj, QEvent *event);
-
-Q_SIGNALS:
- void activeChanged();
- void layoutDirectionChanged();
-
-private:
- Q_DISABLE_COPY(QDeclarativeApplication)
- Q_DECLARE_PRIVATE(QDeclarativeApplication)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeApplication)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEAPPLICATION_P_H
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
deleted file mode 100644
index 39032e0ca6..0000000000
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ /dev/null
@@ -1,551 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativebinding_p.h"
-#include "qdeclarativebinding_p_p.h"
-
-#include "qdeclarative.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativeinfo.h"
-#include "qdeclarativecompiler_p.h"
-#include "qdeclarativedata_p.h"
-#include <private/qdeclarativeprofilerservice_p.h>
-#include <private/qdeclarativetrace_p.h>
-
-#include <QVariant>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeAbstractBinding::QDeclarativeAbstractBinding()
-: m_prevBinding(0), m_nextBinding(0)
-{
-}
-
-QDeclarativeAbstractBinding::~QDeclarativeAbstractBinding()
-{
- Q_ASSERT(m_prevBinding == 0);
- Q_ASSERT(*m_mePtr == 0);
-}
-
-/*!
-Destroy the binding. Use this instead of calling delete.
-
-Bindings are free to implement their own memory management, so the delete operator is not
-necessarily safe. The default implementation clears the binding, removes it from the object
-and calls delete.
-*/
-void QDeclarativeAbstractBinding::destroy()
-{
- removeFromObject();
- clear();
-
- delete this;
-}
-
-/*!
-Add this binding to \a object.
-
-This transfers ownership of the binding to the object, marks the object's property as
-being bound.
-
-However, it does not enable the binding itself or call update() on it.
-*/
-void QDeclarativeAbstractBinding::addToObject()
-{
- Q_ASSERT(!m_prevBinding);
-
- QObject *obj = object();
- Q_ASSERT(obj);
-
- int index = propertyIndex();
-
- QDeclarativeData *data = QDeclarativeData::get(obj, true);
-
- if (index & 0xFF000000) {
- // Value type
-
- int coreIndex = index & 0xFFFFFF;
-
- // Find the value type proxy (if there is one)
- QDeclarativeValueTypeProxyBinding *proxy = 0;
- if (data->hasBindingBit(coreIndex)) {
- QDeclarativeAbstractBinding *b = data->bindings;
- while (b && b->propertyIndex() != coreIndex)
- b = b->m_nextBinding;
- Q_ASSERT(b && b->bindingType() == QDeclarativeAbstractBinding::ValueTypeProxy);
- proxy = static_cast<QDeclarativeValueTypeProxyBinding *>(b);
- }
-
- if (!proxy) {
- proxy = new QDeclarativeValueTypeProxyBinding(obj, coreIndex);
-
- Q_ASSERT(proxy->propertyIndex() == coreIndex);
- Q_ASSERT(proxy->object() == obj);
-
- proxy->addToObject();
- }
-
- m_nextBinding = proxy->m_bindings;
- if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding;
- m_prevBinding = &proxy->m_bindings;
- proxy->m_bindings = this;
-
- } else {
- m_nextBinding = data->bindings;
- if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding;
- m_prevBinding = &data->bindings;
- data->bindings = this;
-
- data->setBindingBit(obj, index);
- }
-}
-
-/*!
-Remove the binding from the object.
-*/
-void QDeclarativeAbstractBinding::removeFromObject()
-{
- if (m_prevBinding) {
- int index = propertyIndex();
-
- *m_prevBinding = m_nextBinding;
- if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding;
- m_prevBinding = 0;
- m_nextBinding = 0;
-
- if (index & 0xFF000000) {
- // Value type - we don't remove the proxy from the object. It will sit their happily
- // doing nothing until it is removed by a write, a binding change or it is reused
- // to hold more sub-bindings.
- } else if (QObject *obj = object()) {
- QDeclarativeData *data = QDeclarativeData::get(obj, false);
- if (data) data->clearBindingBit(index);
- }
- }
-}
-
-static void bindingDummyDeleter(QDeclarativeAbstractBinding *)
-{
-}
-
-QDeclarativeAbstractBinding::Pointer QDeclarativeAbstractBinding::weakPointer()
-{
- if (m_mePtr.value().isNull())
- m_mePtr.value() = QSharedPointer<QDeclarativeAbstractBinding>(this, bindingDummyDeleter);
-
- return m_mePtr.value().toWeakRef();
-}
-
-void QDeclarativeAbstractBinding::clear()
-{
- if (!m_mePtr.isNull()) {
- **m_mePtr = 0;
- m_mePtr = 0;
- }
-}
-
-void QDeclarativeAbstractBinding::retargetBinding(QObject *, int)
-{
- qFatal("QDeclarativeAbstractBinding::retargetBinding() called on illegal binding.");
-}
-
-QString QDeclarativeAbstractBinding::expression() const
-{
- return QLatin1String("<Unknown>");
-}
-
-void QDeclarativeAbstractBinding::setEnabled(bool enabled, QDeclarativePropertyPrivate::WriteFlags flags)
-{
- if (enabled) update(flags);
-}
-
-QDeclarativeBinding::Identifier QDeclarativeBinding::Invalid = -1;
-
-void QDeclarativeBindingPrivate::refresh()
-{
- Q_Q(QDeclarativeBinding);
- q->update();
-}
-
-QDeclarativeBindingPrivate::QDeclarativeBindingPrivate()
-: updating(false), enabled(false), target(), targetProperty(0)
-{
-}
-
-QDeclarativeBindingPrivate::~QDeclarativeBindingPrivate()
-{
-}
-
-QDeclarativeBinding *
-QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeContext *ctxt,
- const QString &url, int lineNumber, QObject *parent)
-{
- if (id < 0)
- return 0;
-
- QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(ctxt);
-
- QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(ctxt->engine());
- QDeclarativeCompiledData *cdata = 0;
- QDeclarativeTypeData *typeData = 0;
- if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
- typeData = engine->typeLoader.get(ctxtdata->url);
- cdata = typeData->compiledData();
- }
- QDeclarativeBinding *rv = cdata ? new QDeclarativeBinding(cdata->primitives.at(id), true, obj, ctxtdata, url, lineNumber, 0, parent) : 0;
- if (cdata)
- cdata->release();
- if (typeData)
- typeData->release();
- return rv;
-}
-
-QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContext *ctxt,
- QObject *parent)
-: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), obj, str, *new QDeclarativeBindingPrivate)
-{
- setParent(parent);
- setNotifyOnValueChanged(true);
-}
-
-QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContextData *ctxt,
- QObject *parent)
-: QDeclarativeExpression(ctxt, obj, str, *new QDeclarativeBindingPrivate)
-{
- setParent(parent);
- setNotifyOnValueChanged(true);
-}
-
-QDeclarativeBinding::QDeclarativeBinding(const QString &str, bool isRewritten, QObject *obj,
- QDeclarativeContextData *ctxt,
- const QString &url, int lineNumber, int columnNumber,
- QObject *parent)
-: QDeclarativeExpression(ctxt, obj, str, isRewritten, url, lineNumber, columnNumber, *new QDeclarativeBindingPrivate)
-{
- setParent(parent);
- setNotifyOnValueChanged(true);
-}
-
-/*!
- \internal
-
- To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle<v8::Function>.
- For example:
- v8::Handle<v8::Function> function;
- new QDeclarativeBinding(&function, scope, ctxt);
- */
-QDeclarativeBinding::QDeclarativeBinding(void *functionPtr, QObject *obj, QDeclarativeContextData *ctxt,
- QObject *parent)
-: QDeclarativeExpression(ctxt, obj, functionPtr, *new QDeclarativeBindingPrivate)
-{
- setParent(parent);
- setNotifyOnValueChanged(true);
-}
-
-QDeclarativeBinding::~QDeclarativeBinding()
-{
-}
-
-void QDeclarativeBinding::setTarget(const QDeclarativeProperty &prop)
-{
- Q_D(QDeclarativeBinding);
- d->property = prop;
- d->target = d->property.object();
- d->targetProperty = QDeclarativePropertyPrivate::get(d->property)->core.encodedIndex();
-
- update();
-}
-
-void QDeclarativeBinding::setTarget(QObject *object,
- const QDeclarativePropertyData &core,
- QDeclarativeContextData *ctxt)
-{
- Q_D(QDeclarativeBinding);
- d->property = QDeclarativePropertyPrivate::restore(object, core, ctxt);
- d->target = d->property.object();
- d->targetProperty = QDeclarativePropertyPrivate::get(d->property)->core.encodedIndex();
-
- update();
-}
-
-QDeclarativeProperty QDeclarativeBinding::property() const
-{
- Q_D(const QDeclarativeBinding);
- return d->property;
-}
-
-void QDeclarativeBinding::setEvaluateFlags(EvaluateFlags flags)
-{
- Q_D(QDeclarativeBinding);
- d->setRequiresThisObject(flags & RequiresThisObject);
-}
-
-QDeclarativeBinding::EvaluateFlags QDeclarativeBinding::evaluateFlags() const
-{
- Q_D(const QDeclarativeBinding);
- return d->requiresThisObject()?RequiresThisObject:None;
-}
-
-void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
-{
- Q_D(QDeclarativeBinding);
-
- if (!d->enabled || !d->context() || !d->context()->isValid())
- return;
-
- QDeclarativeTrace trace("General Binding Update");
- trace.addDetail("URL", d->url);
- trace.addDetail("Line", d->line);
- trace.addDetail("Column", d->columnNumber);
-
- if (!d->updating) {
- QDeclarativeBindingProfiler prof(d->url, d->line, d->column);
- prof.addDetail(expression());
- d->updating = true;
-
- QDeclarativeAbstractExpression::DeleteWatcher watcher(d);
-
- if (d->property.propertyType() == qMetaTypeId<QDeclarativeBinding *>()) {
-
- int idx = d->property.index();
- Q_ASSERT(idx != -1);
-
- QDeclarativeBinding *t = this;
- int status = -1;
- void *a[] = { &t, 0, &status, &flags };
- QMetaObject::metacall(d->property.object(),
- QMetaObject::WriteProperty,
- idx, a);
-
- } else {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context()->engine);
- ep->referenceScarceResources();
-
- bool isUndefined = false;
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(ep->v8engine()->context());
- v8::Local<v8::Value> result = d->v8value(0, &isUndefined);
-
- trace.event("writing binding result");
-
- bool needsErrorData = false;
- if (!watcher.wasDeleted() && !d->hasError())
- needsErrorData = !QDeclarativePropertyPrivate::writeBinding(d->property, d->context(),
- d, result,
- isUndefined, flags);
-
- if (!watcher.wasDeleted()) {
-
- if (needsErrorData) {
- QUrl url = QUrl(d->url);
- int line = d->line;
- if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
-
- d->delayedError()->error.setUrl(url);
- d->delayedError()->error.setLine(line);
- d->delayedError()->error.setColumn(-1);
- }
-
- if (d->hasError()) {
- if (!d->delayedError()->addError(ep)) ep->warning(this->error());
- } else {
- d->clearError();
- }
-
- }
-
- ep->dereferenceScarceResources();
- }
-
- if (!watcher.wasDeleted())
- d->updating = false;
- } else {
- QDeclarativeBindingPrivate::printBindingLoopError(d->property);
- }
-}
-
-void QDeclarativeBindingPrivate::printBindingLoopError(QDeclarativeProperty &prop)
-{
- qmlInfo(prop.object()) << QDeclarativeBinding::tr("Binding loop detected for property \"%1\"").arg(prop.name());
-}
-
-void QDeclarativeBindingPrivate::expressionChanged()
-{
- Q_Q(QDeclarativeBinding);
- q->update();
-}
-
-void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags)
-{
- Q_D(QDeclarativeBinding);
- d->enabled = e;
- setNotifyOnValueChanged(e);
-
- if (e)
- update(flags);
-}
-
-bool QDeclarativeBinding::enabled() const
-{
- Q_D(const QDeclarativeBinding);
-
- return d->enabled;
-}
-
-QString QDeclarativeBinding::expression() const
-{
- return QDeclarativeExpression::expression();
-}
-
-int QDeclarativeBinding::propertyIndex() const
-{
- Q_D(const QDeclarativeBinding);
- return d->targetProperty;
-}
-
-QObject *QDeclarativeBinding::object() const
-{
- Q_D(const QDeclarativeBinding);
- return d->target;
-}
-
-void QDeclarativeBinding::retargetBinding(QObject *t, int i)
-{
- Q_D(QDeclarativeBinding);
- d->target = t;
- d->targetProperty = i;
-}
-
-QDeclarativeValueTypeProxyBinding::QDeclarativeValueTypeProxyBinding(QObject *o, int index)
-: m_object(o), m_index(index), m_bindings(0)
-{
-}
-
-QDeclarativeValueTypeProxyBinding::~QDeclarativeValueTypeProxyBinding()
-{
- while (m_bindings) {
- QDeclarativeAbstractBinding *binding = m_bindings;
- binding->setEnabled(false, 0);
- binding->destroy();
- }
-}
-
-void QDeclarativeValueTypeProxyBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags)
-{
- if (e) {
- QDeclarativeAbstractBinding *bindings = m_bindings;
- recursiveEnable(bindings, flags);
- } else {
- QDeclarativeAbstractBinding *bindings = m_bindings;
- recursiveDisable(bindings);
- }
-}
-
-void QDeclarativeValueTypeProxyBinding::recursiveEnable(QDeclarativeAbstractBinding *b, QDeclarativePropertyPrivate::WriteFlags flags)
-{
- if (!b)
- return;
-
- recursiveEnable(b->m_nextBinding, flags);
-
- if (b)
- b->setEnabled(true, flags);
-}
-
-void QDeclarativeValueTypeProxyBinding::recursiveDisable(QDeclarativeAbstractBinding *b)
-{
- if (!b)
- return;
-
- recursiveDisable(b->m_nextBinding);
-
- if (b)
- b->setEnabled(false, 0);
-}
-
-void QDeclarativeValueTypeProxyBinding::update(QDeclarativePropertyPrivate::WriteFlags)
-{
-}
-
-QDeclarativeAbstractBinding *QDeclarativeValueTypeProxyBinding::binding(int propertyIndex)
-{
- QDeclarativeAbstractBinding *binding = m_bindings;
-
- while (binding && binding->propertyIndex() != propertyIndex)
- binding = binding->m_nextBinding;
-
- return binding;
-}
-
-/*!
-Removes a collection of bindings, corresponding to the set bits in \a mask.
-*/
-void QDeclarativeValueTypeProxyBinding::removeBindings(quint32 mask)
-{
- QDeclarativeAbstractBinding *binding = m_bindings;
- while (binding) {
- if (mask & (1 << (binding->propertyIndex() >> 24))) {
- QDeclarativeAbstractBinding *remove = binding;
- binding = remove->m_nextBinding;
- *remove->m_prevBinding = remove->m_nextBinding;
- if (remove->m_nextBinding) remove->m_nextBinding->m_prevBinding = remove->m_prevBinding;
- remove->m_prevBinding = 0;
- remove->m_nextBinding = 0;
- remove->destroy();
- } else {
- binding = binding->m_nextBinding;
- }
- }
-}
-
-int QDeclarativeValueTypeProxyBinding::propertyIndex() const
-{
- return m_index;
-}
-
-QObject *QDeclarativeValueTypeProxyBinding::object() const
-{
- return m_object;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h
deleted file mode 100644
index 61cf7dd550..0000000000
--- a/src/declarative/qml/qdeclarativebinding_p.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEBINDING_P_H
-#define QDECLARATIVEBINDING_P_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 "qdeclarative.h"
-#include "qdeclarativepropertyvaluesource.h"
-#include "qdeclarativeexpression.h"
-#include "qdeclarativeproperty.h"
-#include "qdeclarativeproperty_p.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QMetaProperty>
-
-#include <private/qpointervaluepair_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAbstractBinding
-{
-public:
- typedef QWeakPointer<QDeclarativeAbstractBinding> Pointer;
-
- QDeclarativeAbstractBinding();
-
- virtual void destroy();
-
- virtual QString expression() const;
-
- enum Type { PropertyBinding, ValueTypeProxy };
- virtual Type bindingType() const { return PropertyBinding; }
-
- // Should return the encoded property index for the binding. Should return this value
- // even if the binding is not enabled or added to an object.
- // Encoding is: coreIndex | (valueTypeIndex << 24)
- virtual int propertyIndex() const = 0;
- // Should return the object for the binding. Should return this object even if the
- // binding is not enabled or added to the object.
- virtual QObject *object() const = 0;
-
- void setEnabled(bool e) { setEnabled(e, QDeclarativePropertyPrivate::DontRemoveBinding); }
- virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags) = 0;
-
- void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); }
- virtual void update(QDeclarativePropertyPrivate::WriteFlags) = 0;
-
- void addToObject();
- void removeFromObject();
-
- static inline Pointer getPointer(QDeclarativeAbstractBinding *p);
-
-protected:
- virtual ~QDeclarativeAbstractBinding();
- void clear();
-
- // Called by QDeclarativePropertyPrivate to "move" a binding to a different property.
- // This is only used for alias properties, and only used by QDeclarativeBinding not
- // V8 or V4 bindings. The default implementation qFatal()'s to ensure that the
- // method is never called for V4 or V8 bindings.
- virtual void retargetBinding(QObject *, int);
-private:
- Pointer weakPointer();
-
- friend class QDeclarativeData;
- friend class QDeclarativeComponentPrivate;
- friend class QDeclarativeValueTypeProxyBinding;
- friend class QDeclarativePropertyPrivate;
- friend class QDeclarativeVME;
- friend class QtSharedPointer::ExternalRefCount<QDeclarativeAbstractBinding>;
-
- typedef QSharedPointer<QDeclarativeAbstractBinding> SharedPointer;
- // To save memory, we also store the rarely used weakPointer() instance in here
- QPointerValuePair<QDeclarativeAbstractBinding*, SharedPointer> m_mePtr;
-
- QDeclarativeAbstractBinding **m_prevBinding;
- QDeclarativeAbstractBinding *m_nextBinding;
-};
-
-class QDeclarativeValueTypeProxyBinding : public QDeclarativeAbstractBinding
-{
-public:
- QDeclarativeValueTypeProxyBinding(QObject *o, int coreIndex);
-
- virtual Type bindingType() const { return ValueTypeProxy; }
-
- virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags);
- virtual void update(QDeclarativePropertyPrivate::WriteFlags);
- virtual int propertyIndex() const;
- virtual QObject *object() const;
-
- QDeclarativeAbstractBinding *binding(int propertyIndex);
-
- void removeBindings(quint32 mask);
-
-protected:
- ~QDeclarativeValueTypeProxyBinding();
-
-private:
- void recursiveEnable(QDeclarativeAbstractBinding *, QDeclarativePropertyPrivate::WriteFlags);
- void recursiveDisable(QDeclarativeAbstractBinding *);
-
- friend class QDeclarativeAbstractBinding;
- QObject *m_object;
- int m_index;
- QDeclarativeAbstractBinding *m_bindings;
-};
-
-class QDeclarativeContext;
-class QDeclarativeBindingPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBinding : public QDeclarativeExpression,
- public QDeclarativeAbstractBinding
-{
-Q_OBJECT
-public:
- enum EvaluateFlag { None = 0x00, RequiresThisObject = 0x01 };
- Q_DECLARE_FLAGS(EvaluateFlags, EvaluateFlag)
-
- QDeclarativeBinding(const QString &, QObject *, QDeclarativeContext *, QObject *parent=0);
- QDeclarativeBinding(const QString &, QObject *, QDeclarativeContextData *, QObject *parent=0);
- QDeclarativeBinding(const QString &, bool isRewritten, QObject *, QDeclarativeContextData *,
- const QString &url, int lineNumber, int columnNumber = 0, QObject *parent=0);
- QDeclarativeBinding(void *, QObject *, QDeclarativeContextData *, QObject *parent=0);
-
- void setTarget(const QDeclarativeProperty &);
- void setTarget(QObject *, const QDeclarativePropertyData &, QDeclarativeContextData *);
- QDeclarativeProperty property() const;
-
- void setEvaluateFlags(EvaluateFlags flags);
- EvaluateFlags evaluateFlags() const;
-
- bool enabled() const;
-
- // Inherited from QDeclarativeAbstractBinding
- virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags);
- virtual void update(QDeclarativePropertyPrivate::WriteFlags flags);
- virtual QString expression() const;
- virtual int propertyIndex() const;
- virtual QObject *object() const;
- virtual void retargetBinding(QObject *, int);
-
- typedef int Identifier;
- static Identifier Invalid;
- static QDeclarativeBinding *createBinding(Identifier, QObject *, QDeclarativeContext *,
- const QString &, int, QObject *parent=0);
-
-
-public Q_SLOTS:
- void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); }
-
-protected:
- ~QDeclarativeBinding();
-
-private:
- Q_DECLARE_PRIVATE(QDeclarativeBinding)
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeBinding::EvaluateFlags)
-
-QDeclarativeAbstractBinding::Pointer
-QDeclarativeAbstractBinding::getPointer(QDeclarativeAbstractBinding *p)
-{
- return p ? p->weakPointer() : Pointer();
-}
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeBinding*)
-
-#endif // QDECLARATIVEBINDING_P_H
diff --git a/src/declarative/qml/qdeclarativebinding_p_p.h b/src/declarative/qml/qdeclarativebinding_p_p.h
deleted file mode 100644
index 030bd32ef3..0000000000
--- a/src/declarative/qml/qdeclarativebinding_p_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEBINDING_P_P_H
-#define QDECLARATIVEBINDING_P_P_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 "qdeclarativebinding_p.h"
-
-#include "qdeclarativeproperty.h"
-#include "qdeclarativeexpression_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeBindingPrivate : public QDeclarativeExpressionPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeBinding)
-public:
- QDeclarativeBindingPrivate();
- ~QDeclarativeBindingPrivate();
-
- virtual void expressionChanged();
-
- static void printBindingLoopError(QDeclarativeProperty &prop);
-
-protected:
- virtual void refresh();
-
-private:
- bool updating:1;
- bool enabled:1;
- int columnNumber;
- QDeclarativeProperty property;
-
- QObject *target;
- int targetProperty;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEBINDING_P_P_H
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
deleted file mode 100644
index bf96f03016..0000000000
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeboundsignal_p.h"
-
-#include <private/qmetaobjectbuilder_p.h>
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativeexpression_p.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativemetatype_p.h"
-#include "qdeclarative.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativeglobal_p.h"
-#include <private/qdeclarativeprofilerservice_p.h>
-#include <private/qv8debugservice_p.h>
-
-#include <QtCore/qstringbuilder.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeBoundSignalParameters : public QObject
-{
-Q_OBJECT
-public:
- QDeclarativeBoundSignalParameters(const QMetaMethod &, QObject * = 0);
- ~QDeclarativeBoundSignalParameters();
-
- void setValues(void **);
- void clearValues();
-
-private:
- friend class MetaObject;
- int metaCall(QMetaObject::Call, int _id, void **);
- struct MetaObject : public QAbstractDynamicMetaObject {
- MetaObject(QDeclarativeBoundSignalParameters *b)
- : parent(b) {}
-
- int metaCall(QMetaObject::Call c, int id, void **a) {
- return parent->metaCall(c, id, a);
- }
- QDeclarativeBoundSignalParameters *parent;
- };
-
- int *types;
- void **values;
- QMetaObject *myMetaObject;
-};
-
-static int evaluateIdx = -1;
-
-QDeclarativeAbstractBoundSignal::QDeclarativeAbstractBoundSignal(QObject *parent)
-: QObject(parent)
-{
-}
-
-QDeclarativeAbstractBoundSignal::~QDeclarativeAbstractBoundSignal()
-{
-}
-
-QDeclarativeBoundSignal::QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal,
- QObject *parent)
-: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0)
-{
- // This is thread safe. Although it may be updated by two threads, they
- // will both set it to the same value - so the worst thing that can happen
- // is that they both do the work to figure it out. Boo hoo.
- if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
-
- QDeclarative_setParent_noEvent(this, parent);
- QDeclarativePropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
-}
-
-QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val,
- QObject *scope, const QMetaMethod &signal,
- QObject *parent)
-: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0)
-{
- // This is thread safe. Although it may be updated by two threads, they
- // will both set it to the same value - so the worst thing that can happen
- // is that they both do the work to figure it out. Boo hoo.
- if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
-
- QDeclarative_setParent_noEvent(this, parent);
- QDeclarativePropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
-
- m_expression = new QDeclarativeExpression(ctxt, scope, val);
-}
-
-QDeclarativeBoundSignal::~QDeclarativeBoundSignal()
-{
- delete m_expression;
- m_expression = 0;
-}
-
-int QDeclarativeBoundSignal::index() const
-{
- return m_signal.methodIndex();
-}
-
-/*!
- Returns the signal expression.
-*/
-QDeclarativeExpression *QDeclarativeBoundSignal::expression() const
-{
- return m_expression;
-}
-
-/*!
- Sets the signal expression to \a e. Returns the current signal expression,
- or null if there is no signal expression.
-
- The QDeclarativeBoundSignal instance takes ownership of \a e. The caller is
- assumes ownership of the returned QDeclarativeExpression.
-*/
-QDeclarativeExpression *QDeclarativeBoundSignal::setExpression(QDeclarativeExpression *e)
-{
- QDeclarativeExpression *rv = m_expression;
- m_expression = e;
- if (m_expression) m_expression->setNotifyOnValueChanged(false);
- return rv;
-}
-
-QDeclarativeBoundSignal *QDeclarativeBoundSignal::cast(QObject *o)
-{
- QDeclarativeAbstractBoundSignal *s = qobject_cast<QDeclarativeAbstractBoundSignal*>(o);
- return static_cast<QDeclarativeBoundSignal *>(s);
-}
-
-int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
-{
- if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) {
- if (!m_expression)
- return -1;
-
- if (QDeclarativeDebugService::isDebuggingEnabled())
- QV8DebugService::instance()->signalEmitted(QString::fromAscii(m_signal.signature()));
-
- QDeclarativeHandlingSignalProfiler prof;
- if (prof.enabled) {
- prof.setSignalInfo(QString::fromLatin1(m_signal.signature()),
- m_expression->expression());
- prof.setLocation(m_expression->sourceFile(), m_expression->lineNumber(),
- m_expression->columnNumber());
- }
-
- m_isEvaluating = true;
- if (!m_paramsValid) {
- if (!m_signal.parameterTypes().isEmpty())
- m_params = new QDeclarativeBoundSignalParameters(m_signal, this);
- m_paramsValid = true;
- }
-
- if (m_params) m_params->setValues(a);
- if (m_expression && m_expression->engine()) {
- QDeclarativeExpressionPrivate::get(m_expression)->value(m_params);
- if (m_expression && m_expression->hasError())
- QDeclarativeEnginePrivate::warning(m_expression->engine(), m_expression->error());
- }
- if (m_params) m_params->clearValues();
- m_isEvaluating = false;
- return -1;
- } else {
- return QObject::qt_metacall(c, id, a);
- }
-}
-
-QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMetaMethod &method,
- QObject *parent)
-: QObject(parent), types(0), values(0)
-{
- MetaObject *mo = new MetaObject(this);
-
- // ### Optimize!
- QMetaObjectBuilder mob;
- mob.setSuperClass(&QDeclarativeBoundSignalParameters::staticMetaObject);
- mob.setClassName("QDeclarativeBoundSignalParameters");
-
- QList<QByteArray> paramTypes = method.parameterTypes();
- QList<QByteArray> paramNames = method.parameterNames();
- types = new int[paramTypes.count()];
- for (int ii = 0; ii < paramTypes.count(); ++ii) {
- const QByteArray &type = paramTypes.at(ii);
- const QByteArray &name = paramNames.at(ii);
-
- if (name.isEmpty() || type.isEmpty()) {
- types[ii] = 0;
- continue;
- }
-
- QVariant::Type t = (QVariant::Type)QMetaType::type(type.constData());
- if (QDeclarativeMetaType::isQObject(t)) {
- types[ii] = QMetaType::QObjectStar;
- QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*");
- prop.setWritable(false);
- } else {
- QByteArray propType = type;
- if (t >= QVariant::UserType || t == QVariant::Invalid) {
- QByteArray scope;
- QByteArray name;
- int scopeIdx = propType.lastIndexOf("::");
- if (scopeIdx != -1) {
- scope = propType.left(scopeIdx);
- name = propType.mid(scopeIdx + 2);
- } else {
- name = propType;
- }
- const QMetaObject *meta;
- if (scope == "Qt")
- meta = &QObject::staticQtMetaObject;
- else
- meta = parent->parent()->metaObject(); //### assumes parent->parent()
- for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
- QMetaEnum m = meta->enumerator(i);
- if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) {
- t = QVariant::Int;
- propType = "int";
- break;
- }
- }
- }
- types[ii] = t;
- QMetaPropertyBuilder prop = mob.addProperty(name, propType);
- prop.setWritable(false);
- }
- }
- myMetaObject = mob.toMetaObject();
- *static_cast<QMetaObject *>(mo) = *myMetaObject;
-
- d_ptr->metaObject = mo;
-}
-
-QDeclarativeBoundSignalParameters::~QDeclarativeBoundSignalParameters()
-{
- delete [] types;
- free(myMetaObject);
-}
-
-void QDeclarativeBoundSignalParameters::setValues(void **v)
-{
- values = v;
-}
-
-void QDeclarativeBoundSignalParameters::clearValues()
-{
- values = 0;
-}
-
-int QDeclarativeBoundSignalParameters::metaCall(QMetaObject::Call c, int id, void **a)
-{
- if (!values)
- return -1;
-
- if (c == QMetaObject::ReadProperty && id >= 1) {
- int t = types[id - 1];
- void *p = a[0];
- QMetaType::destruct(t, p);
- QMetaType::construct(t, p, values[id]);
- return -1;
- } else {
- return qt_metacall(c, id, a);
- }
-}
-
-QT_END_NAMESPACE
-
-#include <qdeclarativeboundsignal.moc>
diff --git a/src/declarative/qml/qdeclarativeboundsignal_p.h b/src/declarative/qml/qdeclarativeboundsignal_p.h
deleted file mode 100644
index b747d9d7a5..0000000000
--- a/src/declarative/qml/qdeclarativeboundsignal_p.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEBOUNDSIGNAL_P_H
-#define QDECLARATIVEBOUNDSIGNAL_P_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 "qdeclarativeexpression.h"
-
-#include <QtCore/qmetaobject.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_DECLARATIVE_EXPORT QDeclarativeAbstractBoundSignal : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeAbstractBoundSignal(QObject *parent = 0);
- virtual ~QDeclarativeAbstractBoundSignal() = 0;
-};
-
-class QDeclarativeBoundSignalParameters;
-class Q_DECLARATIVE_EXPORT QDeclarativeBoundSignal : public QDeclarativeAbstractBoundSignal
-{
-public:
- QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal, QObject *parent);
- QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val, QObject *scope,
- const QMetaMethod &signal, QObject *parent);
- virtual ~QDeclarativeBoundSignal();
-
- int index() const;
-
- QDeclarativeExpression *expression() const;
- QDeclarativeExpression *setExpression(QDeclarativeExpression *);
-
- bool isEvaluating() const { return m_isEvaluating; }
-
- static QDeclarativeBoundSignal *cast(QObject *);
-
-protected:
- virtual int qt_metacall(QMetaObject::Call c, int id, void **a);
-
-private:
- QDeclarativeExpression *m_expression;
- QMetaMethod m_signal;
- bool m_paramsValid : 1;
- bool m_isEvaluating : 1;
- QDeclarativeBoundSignalParameters *m_params;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEBOUNDSIGNAL_P_H
diff --git a/src/declarative/qml/qdeclarativecleanup.cpp b/src/declarative/qml/qdeclarativecleanup.cpp
deleted file mode 100644
index aa7a1e3254..0000000000
--- a/src/declarative/qml/qdeclarativecleanup.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecleanup_p.h"
-
-#include "qdeclarativeengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
-\internal
-\class QDeclarativeCleanup
-\brief The QDeclarativeCleanup provides a callback when a QDeclarativeEngine is deleted.
-
-Any object that needs cleanup to occur before the QDeclarativeEngine's V8 engine is
-destroyed should inherit from QDeclarativeCleanup. The clear() virtual method will be
-called by QDeclarativeEngine just before it destroys the context.
-*/
-
-
-/*
-Create a QDeclarativeCleanup that is not associated with any engine.
-*/
-QDeclarativeCleanup::QDeclarativeCleanup()
-: prev(0), next(0), engine(0)
-{
-}
-
-/*!
-Create a QDeclarativeCleanup for \a engine
-*/
-QDeclarativeCleanup::QDeclarativeCleanup(QDeclarativeEngine *engine)
-: prev(0), next(0), engine(0)
-{
- if (!engine)
- return;
-
- addToEngine(engine);
-}
-
-/*!
-Adds this object to \a engine's cleanup list. hasEngine() must be false
-before calling this method.
-*/
-void QDeclarativeCleanup::addToEngine(QDeclarativeEngine *engine)
-{
- Q_ASSERT(engine);
- Q_ASSERT(QDeclarativeEnginePrivate::isEngineThread(engine));
-
- this->engine = engine;
-
- QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
-
- if (p->cleanup) next = p->cleanup;
- p->cleanup = this;
- prev = &p->cleanup;
- if (next) next->prev = &next;
-}
-
-/*!
-\fn bool QDeclarativeCleanup::hasEngine() const
-
-Returns true if this QDeclarativeCleanup is associated with an engine, otherwise false.
-*/
-
-/*!
-\internal
-*/
-QDeclarativeCleanup::~QDeclarativeCleanup()
-{
- Q_ASSERT(!prev || engine);
- Q_ASSERT(!prev || QDeclarativeEnginePrivate::isEngineThread(engine));
-
- if (prev) *prev = next;
- if (next) next->prev = prev;
- prev = 0;
- next = 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecleanup_p.h b/src/declarative/qml/qdeclarativecleanup_p.h
deleted file mode 100644
index bf84269698..0000000000
--- a/src/declarative/qml/qdeclarativecleanup_p.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECLEANUP_P_H
-#define QDECLARATIVECLEANUP_P_H
-
-#include <QtCore/qglobal.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.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_EXPORT QDeclarativeCleanup
-{
-public:
- QDeclarativeCleanup();
- QDeclarativeCleanup(QDeclarativeEngine *);
- virtual ~QDeclarativeCleanup();
-
- bool hasEngine() const { return prev != 0; }
- void addToEngine(QDeclarativeEngine *);
-protected:
- virtual void clear() = 0;
-
-private:
- friend class QDeclarativeEnginePrivate;
- QDeclarativeCleanup **prev;
- QDeclarativeCleanup *next;
-
- // Only used for asserts
- QDeclarativeEngine *engine;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVECLEANUP_P_H
-
diff --git a/src/declarative/qml/qdeclarativecompileddata.cpp b/src/declarative/qml/qdeclarativecompileddata.cpp
deleted file mode 100644
index 6ace1d3042..0000000000
--- a/src/declarative/qml/qdeclarativecompileddata.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecompiler_p.h"
-#include "qdeclarativeengine.h"
-#include "qdeclarativecomponent.h"
-#include "qdeclarativecomponent_p.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativecontext_p.h"
-#ifdef QML_THREADED_VME_INTERPRETER
-#include "qdeclarativevme_p.h"
-#endif
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-int QDeclarativeCompiledData::pack(const char *data, size_t size)
-{
- const char *p = packData.constData();
- unsigned int ps = packData.size();
-
- for (unsigned int ii = 0; (ii + size) <= ps; ii += sizeof(int)) {
- if (0 == ::memcmp(p + ii, data, size))
- return ii;
- }
-
- int rv = packData.size();
- packData.append(data, size);
- return rv;
-}
-
-int QDeclarativeCompiledData::indexForString(const QString &data)
-{
- int idx = primitives.indexOf(data);
- if (idx == -1) {
- idx = primitives.count();
- primitives << data;
- }
- return idx;
-}
-
-int QDeclarativeCompiledData::indexForByteArray(const QByteArray &data)
-{
- int idx = datas.indexOf(data);
- if (idx == -1) {
- idx = datas.count();
- datas << data;
- }
- return idx;
-}
-
-int QDeclarativeCompiledData::indexForUrl(const QUrl &data)
-{
- int idx = urls.indexOf(data);
- if (idx == -1) {
- idx = urls.count();
- urls << data;
- }
- return idx;
-}
-
-QDeclarativeCompiledData::QDeclarativeCompiledData(QDeclarativeEngine *engine)
-: engine(engine), importCache(0), root(0), rootPropertyCache(0)
-{
- Q_ASSERT(engine);
-
- bytecode.reserve(1024);
-}
-
-void QDeclarativeCompiledData::destroy()
-{
- if (engine && hasEngine())
- QDeclarativeEnginePrivate::deleteInEngineThread(engine, this);
- else
- delete this;
-}
-
-QDeclarativeCompiledData::~QDeclarativeCompiledData()
-{
- clear();
-
- for (int ii = 0; ii < types.count(); ++ii) {
- if (types.at(ii).component)
- types.at(ii).component->release();
- if (types.at(ii).typePropertyCache)
- types.at(ii).typePropertyCache->release();
- }
-
- for (int ii = 0; ii < propertyCaches.count(); ++ii)
- propertyCaches.at(ii)->release();
-
- for (int ii = 0; ii < contextCaches.count(); ++ii)
- contextCaches.at(ii)->release();
-
- for (int ii = 0; ii < scripts.count(); ++ii)
- scripts.at(ii)->release();
-
- if (importCache)
- importCache->release();
-
- if (rootPropertyCache)
- rootPropertyCache->release();
-}
-
-void QDeclarativeCompiledData::clear()
-{
- for (int ii = 0; ii < programs.count(); ++ii)
- qPersistentDispose(programs[ii].bindings);
-}
-
-const QMetaObject *QDeclarativeCompiledData::TypeReference::metaObject() const
-{
- if (type) {
- return type->metaObject();
- } else {
- Q_ASSERT(component);
- return component->root;
- }
-}
-
-/*!
-Returns the property cache, if one alread exists. The cache is not referenced.
-*/
-QDeclarativePropertyCache *QDeclarativeCompiledData::TypeReference::propertyCache() const
-{
- if (type)
- return typePropertyCache;
- else
- return component->rootPropertyCache;
-}
-
-/*!
-Returns the property cache, creating one if it doesn't already exist. The cache is not referenced.
-*/
-QDeclarativePropertyCache *QDeclarativeCompiledData::TypeReference::createPropertyCache(QDeclarativeEngine *engine)
-{
- if (typePropertyCache) {
- return typePropertyCache;
- } else if (type) {
- typePropertyCache = QDeclarativeEnginePrivate::get(engine)->cache(type->metaObject());
- typePropertyCache->addref();
- return typePropertyCache;
- } else {
- return component->rootPropertyCache;
- }
-}
-
-
-void QDeclarativeCompiledData::dumpInstructions()
-{
- if (!name.isEmpty())
- qWarning() << name;
- qWarning().nospace() << "Index\tOperation\t\tData1\tData2\tData3\tComments";
- qWarning().nospace() << "-------------------------------------------------------------------------------";
-
- const char *instructionStream = bytecode.constData();
- const char *endInstructionStream = bytecode.constData() + bytecode.size();
-
- int instructionCount = 0;
- while (instructionStream < endInstructionStream) {
- QDeclarativeInstruction *instr = (QDeclarativeInstruction *)instructionStream;
- dump(instr, instructionCount);
- instructionStream += QDeclarativeInstruction::size(instructionType(instr));
- instructionCount++;
- }
-
- qWarning().nospace() << "-------------------------------------------------------------------------------";
-}
-
-int QDeclarativeCompiledData::addInstructionHelper(QDeclarativeInstruction::Type type, QDeclarativeInstruction &instr)
-{
-#ifdef QML_THREADED_VME_INTERPRETER
- instr.common.code = QDeclarativeVME::instructionJumpTable()[static_cast<int>(type)];
-#else
- instr.common.instructionType = type;
-#endif
- int ptrOffset = bytecode.size();
- int size = QDeclarativeInstruction::size(type);
- if (bytecode.capacity() <= bytecode.size() + size)
- bytecode.reserve(bytecode.size() + size + 512);
- bytecode.append(reinterpret_cast<const char *>(&instr), size);
- return ptrOffset;
-}
-
-int QDeclarativeCompiledData::nextInstructionIndex()
-{
- return bytecode.size();
-}
-
-QDeclarativeInstruction *QDeclarativeCompiledData::instruction(int index)
-{
- return (QDeclarativeInstruction *)(bytecode.constData() + index);
-}
-
-QDeclarativeInstruction::Type QDeclarativeCompiledData::instructionType(const QDeclarativeInstruction *instr)
-{
-#ifdef QML_THREADED_VME_INTERPRETER
- void **jumpTable = QDeclarativeVME::instructionJumpTable();
- void *code = instr->common.code;
-
-# define QML_CHECK_INSTR_CODE(I, FMT) \
- if (jumpTable[static_cast<int>(QDeclarativeInstruction::I)] == code) \
- return QDeclarativeInstruction::I;
-
- FOR_EACH_QML_INSTR(QML_CHECK_INSTR_CODE)
- Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid instruction address");
- return static_cast<QDeclarativeInstruction::Type>(0);
-# undef QML_CHECK_INSTR_CODE
-#else
- return static_cast<QDeclarativeInstruction::Type>(instr->common.instructionType);
-#endif
-}
-
-void QDeclarativeCompiledData::initialize(QDeclarativeEngine *engine)
-{
- Q_ASSERT(!hasEngine());
- QDeclarativeCleanup::addToEngine(engine);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
deleted file mode 100644
index aaa1acaaa3..0000000000
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ /dev/null
@@ -1,3904 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecompiler_p.h"
-
-#include "qdeclarativepropertyvaluesource.h"
-#include "qdeclarativecomponent.h"
-#include <private/qmetaobjectbuilder_p.h>
-#include <private/qfastmetabuilder_p.h>
-#include "qdeclarativestringconverters_p.h"
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativeengine.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativemetatype_p.h"
-#include "qdeclarativecustomparser_p_p.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativecomponent_p.h"
-#include <private/qdeclarativejsast_p.h>
-#include "qdeclarativevmemetaobject_p.h"
-#include "qdeclarativeexpression_p.h"
-#include "qdeclarativeproperty_p.h"
-#include "qdeclarativerewrite_p.h"
-#include "qdeclarativescriptstring.h"
-#include "qdeclarativeglobal_p.h"
-#include "qdeclarativebinding_p.h"
-#include <private/qv4compiler_p.h>
-
-#include <QColor>
-#include <QDebug>
-#include <QPointF>
-#include <QSizeF>
-#include <QRectF>
-#include <QAtomicInt>
-#include <QtCore/qdebug.h>
-#include <QtCore/qdatetime.h>
-
-Q_DECLARE_METATYPE(QList<int>)
-Q_DECLARE_METATYPE(QList<qreal>)
-Q_DECLARE_METATYPE(QList<bool>)
-Q_DECLARE_METATYPE(QList<QString>)
-Q_DECLARE_METATYPE(QList<QUrl>)
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
-DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATS);
-
-using namespace QDeclarativeJS;
-using namespace QDeclarativeScript;
-using namespace QDeclarativeCompilerTypes;
-
-static QString id_string(QLatin1String("id"));
-static QString on_string(QLatin1String("on"));
-static QString Changed_string(QLatin1String("Changed"));
-static QString Component_string(QLatin1String("Component"));
-static QString Component_import_string(QLatin1String("QML/Component"));
-static QString qsTr_string(QLatin1String("qsTr"));
-static QString qsTrId_string(QLatin1String("qsTrId"));
-
-/*!
- Instantiate a new QDeclarativeCompiler.
-*/
-QDeclarativeCompiler::QDeclarativeCompiler(QDeclarativePool *pool)
-: pool(pool), output(0), engine(0), unitRoot(0), unit(0), cachedComponentTypeRef(-1),
- cachedTranslationContextIndex(-1), componentStats(0)
-{
- if (compilerStatDump())
- componentStats = pool->New<ComponentStats>();
-}
-
-/*!
- Returns true if the last call to compile() caused errors.
-
- \sa errors()
-*/
-bool QDeclarativeCompiler::isError() const
-{
- return !exceptions.isEmpty();
-}
-
-/*!
- Return the list of errors from the last call to compile(), or an empty list
- if there were no errors.
-*/
-QList<QDeclarativeError> QDeclarativeCompiler::errors() const
-{
- return exceptions;
-}
-
-/*!
- Returns true if \a name refers to an attached property, false otherwise.
-
- Attached property names are those that start with a capital letter.
-*/
-bool QDeclarativeCompiler::isAttachedPropertyName(const QString &name)
-{
- return isAttachedPropertyName(QHashedStringRef(&name));
-}
-
-bool QDeclarativeCompiler::isAttachedPropertyName(const QHashedStringRef &name)
-{
- return !name.isEmpty() && name.at(0).isUpper();
-}
-
-/*!
- Returns true if \a name refers to a signal property, false otherwise.
-
- Signal property names are those that start with "on", followed by a first
- character which is either a capital letter or one or more underscores followed
- by a capital letter, which is then followed by other allowed characters.
-
- Note that although ECMA-262r3 supports dollarsigns and escaped unicode
- character codes in property names, for simplicity and performance reasons
- QML only supports letters, numbers and underscores.
-*/
-bool QDeclarativeCompiler::isSignalPropertyName(const QString &name)
-{
- return isSignalPropertyName(QStringRef(&name));
-}
-
-bool QDeclarativeCompiler::isSignalPropertyName(const QHashedStringRef &name)
-{
- if (name.length() < 3) return false;
- if (!name.startsWith(on_string)) return false;
- int ns = name.length();
- for (int i = 2; i < ns; ++i) {
- const QChar curr = name.at(i);
- if (curr.unicode() == '_') continue;
- if (curr.isUpper()) return true;
- return false;
- }
- return false; // consists solely of underscores - invalid.
-}
-
-/*!
- \macro COMPILE_EXCEPTION
- \internal
- Inserts an error into the QDeclarativeCompiler error list, and returns false
- (failure).
-
- \a token is used to source the error line and column, and \a desc is the
- error itself. \a desc can be an expression that can be piped into QDebug.
-
- For example:
-
- \code
- COMPILE_EXCEPTION(property, tr("Error for property \"%1\"").arg(property->name));
- \endcode
-*/
-#define COMPILE_EXCEPTION_LOCATION(line, column, desc) \
- { \
- QDeclarativeError error; \
- error.setUrl(output->url); \
- error.setLine(line); \
- error.setColumn(column); \
- error.setDescription(desc.trimmed()); \
- exceptions << error; \
- return false; \
- }
-
-#define COMPILE_EXCEPTION(token, desc) \
- COMPILE_EXCEPTION_LOCATION((token)->location.start.line, (token)->location.start.column, desc)
-
-/*!
- \macro COMPILE_CHECK
- \internal
- Returns false if \a is false, otherwise does nothing.
-*/
-#define COMPILE_CHECK(a) \
- { \
- if (!a) return false; \
- }
-
-/*!
- Returns true if literal \a v can be assigned to property \a prop, otherwise
- false.
-
- This test corresponds to action taken by genLiteralAssignment(). Any change
- made here, must have a corresponding action in genLiteralAssigment().
-*/
-bool QDeclarativeCompiler::testLiteralAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Value *v)
-{
- const QDeclarativeScript::Variant &value = v->value;
-
- if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration)
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
-
- if (prop->core.isEnum()) {
- QMetaProperty p = prop->parent->metaObject()->property(prop->index);
- int enumValue;
- bool ok;
- if (p.isFlagType()) {
- enumValue = p.enumerator().keysToValue(value.asString().toUtf8().constData(), &ok);
- } else
- enumValue = p.enumerator().keyToValue(value.asString().toUtf8().constData(), &ok);
-
- if (!ok)
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: unknown enumeration"));
-
- v->value = QDeclarativeScript::Variant((double)enumValue);
- return true;
- }
-
- int type = prop->type;
-
- switch(type) {
- case QMetaType::QVariant:
- break;
- case QVariant::String:
- if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string expected"));
- break;
- case QVariant::StringList: // we expect a string literal. A string list is not a literal assignment.
- if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string or string list expected"));
- break;
- case QVariant::ByteArray:
- if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: byte array expected"));
- break;
- case QVariant::Url:
- if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: url expected"));
- break;
- case QVariant::RegExp:
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: regular expression expected; use /pattern/ syntax"));
- break;
- case QVariant::UInt:
- {
- bool ok = v->value.isNumber();
- if (ok) {
- double n = v->value.asNumber();
- if (double(uint(n)) != n)
- ok = false;
- }
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected"));
- }
- break;
- case QVariant::Int:
- {
- bool ok = v->value.isNumber();
- if (ok) {
- double n = v->value.asNumber();
- if (double(int(n)) != n)
- ok = false;
- }
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected"));
- }
- break;
- case QMetaType::Float:
- 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: number expected"));
- break;
- case QVariant::Color:
- {
- bool ok;
- QDeclarativeStringConverters::colorFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: color expected"));
- }
- break;
-#ifndef QT_NO_DATESTRING
- case QVariant::Date:
- {
- bool ok;
- QDeclarativeStringConverters::dateFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: date expected"));
- }
- break;
- case QVariant::Time:
- {
- bool ok;
- QDeclarativeStringConverters::timeFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: time expected"));
- }
- break;
- case QVariant::DateTime:
- {
- bool ok;
- QDeclarativeStringConverters::dateTimeFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: datetime expected"));
- }
- break;
-#endif // QT_NO_DATESTRING
- case QVariant::Point:
- case QVariant::PointF:
- {
- bool ok;
- QDeclarativeStringConverters::pointFFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: point expected"));
- }
- break;
- case QVariant::Size:
- case QVariant::SizeF:
- {
- bool ok;
- QDeclarativeStringConverters::sizeFFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: size expected"));
- }
- break;
- case QVariant::Rect:
- case QVariant::RectF:
- {
- bool ok;
- QDeclarativeStringConverters::rectFFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: rect expected"));
- }
- break;
- case QVariant::Bool:
- {
- if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: boolean expected"));
- }
- break;
- case QVariant::Vector3D:
- {
- bool ok;
- QDeclarativeStringConverters::vector3DFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 3D vector expected"));
- }
- break;
- case QVariant::Vector4D:
- {
- bool ok;
- QDeclarativeStringConverters::vector4DFromString(value.asString(), &ok);
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 4D vector expected"));
- }
- break;
- default:
- {
- // check if assigning a literal value to a list property.
- // in each case, check the singular, since an Array of the specified type
- // will not go via this literal assignment codepath.
- if (type == qMetaTypeId<QList<qreal> >()) {
- if (!v->value.isNumber()) {
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: real or array of reals expected"));
- }
- break;
- } else if (type == qMetaTypeId<QList<int> >()) {
- bool ok = v->value.isNumber();
- if (ok) {
- double n = v->value.asNumber();
- if (double(int(n)) != n)
- ok = false;
- }
- if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int or array of ints expected"));
- break;
- } else if (type == qMetaTypeId<QList<bool> >()) {
- if (!v->value.isBoolean()) {
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: bool or array of bools expected"));
- }
- break;
- } else if (type == qMetaTypeId<QList<QString> >()) { // we expect a string literal. A string list is not a literal assignment.
- if (!v->value.isString()) {
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: string or array of strings expected"));
- }
- break;
- } else if (type == qMetaTypeId<QList<QUrl> >()) {
- if (!v->value.isString()) {
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: url or array of urls expected"));
- }
- break;
- }
-
- // otherwise, check for existence of string converter to custom type
- QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
- if (!converter)
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName((QVariant::Type)type))));
- }
- break;
- }
- return true;
-}
-
-static QUrl urlFromUserString(const QString &data)
-{
- QUrl u;
- // Preserve any valid percent-encoded octets supplied by the source
- u.setEncodedUrl(data.toUtf8(), QUrl::TolerantMode);
- return u;
-}
-
-/*!
- Generate a store instruction for assigning literal \a v to property \a prop.
-
- Any literal assignment that is approved in testLiteralAssignment() must have
- a corresponding action in this method.
-*/
-void QDeclarativeCompiler::genLiteralAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Value *v)
-{
- if (prop->core.isEnum()) {
- Q_ASSERT(v->value.isNumber());
- // Preresolved value
- int value = (int)v->value.asNumber();
-
- Instruction::StoreInteger instr;
- instr.propertyIndex = prop->index;
- instr.value = value;
- output->addInstruction(instr);
- return;
- }
-
- int type = prop->type;
- switch(type) {
- case QMetaType::QVariant:
- {
- if (v->value.isNumber()) {
- double n = v->value.asNumber();
- if (double(int(n)) == n) {
- if (prop->core.isVMEProperty()) {
- Instruction::StoreVarInteger instr;
- instr.propertyIndex = prop->index;
- instr.value = int(n);
- output->addInstruction(instr);
- } else {
- Instruction::StoreVariantInteger instr;
- instr.propertyIndex = prop->index;
- instr.value = int(n);
- output->addInstruction(instr);
- }
- } else {
- if (prop->core.isVMEProperty()) {
- Instruction::StoreVarDouble instr;
- instr.propertyIndex = prop->index;
- instr.value = n;
- output->addInstruction(instr);
- } else {
- Instruction::StoreVariantDouble instr;
- instr.propertyIndex = prop->index;
- instr.value = n;
- output->addInstruction(instr);
- }
- }
- } else if (v->value.isBoolean()) {
- if (prop->core.isVMEProperty()) {
- Instruction::StoreVarBool instr;
- instr.propertyIndex = prop->index;
- instr.value = v->value.asBoolean();
- output->addInstruction(instr);
- } else {
- Instruction::StoreVariantBool instr;
- instr.propertyIndex = prop->index;
- instr.value = v->value.asBoolean();
- output->addInstruction(instr);
- }
- } else {
- if (prop->core.isVMEProperty()) {
- Instruction::StoreVar instr;
- instr.propertyIndex = prop->index;
- instr.value = output->indexForString(v->value.asString());
- output->addInstruction(instr);
- } else {
- Instruction::StoreVariant instr;
- instr.propertyIndex = prop->index;
- instr.value = output->indexForString(v->value.asString());
- output->addInstruction(instr);
- }
- }
- }
- break;
- case QVariant::String:
- {
- Instruction::StoreString instr;
- instr.propertyIndex = prop->index;
- instr.value = output->indexForString(v->value.asString());
- output->addInstruction(instr);
- }
- break;
- case QVariant::StringList:
- {
- Instruction::StoreStringList instr;
- instr.propertyIndex = prop->index;
- instr.value = output->indexForString(v->value.asString());
- output->addInstruction(instr);
- }
- break;
- case QVariant::ByteArray:
- {
- Instruction::StoreByteArray instr;
- instr.propertyIndex = prop->index;
- instr.value = output->indexForByteArray(v->value.asString().toLatin1());
- output->addInstruction(instr);
- }
- break;
- case QVariant::Url:
- {
- Instruction::StoreUrl instr;
- QString string = v->value.asString();
- QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string));
- instr.propertyIndex = prop->index;
- instr.value = output->indexForUrl(u);
- output->addInstruction(instr);
- }
- break;
- case QVariant::UInt:
- {
- Instruction::StoreInteger instr;
- instr.propertyIndex = prop->index;
- instr.value = uint(v->value.asNumber());
- output->addInstruction(instr);
- }
- break;
- case QVariant::Int:
- {
- Instruction::StoreInteger instr;
- instr.propertyIndex = prop->index;
- instr.value = int(v->value.asNumber());
- output->addInstruction(instr);
- }
- break;
- case QMetaType::Float:
- {
- Instruction::StoreFloat instr;
- instr.propertyIndex = prop->index;
- instr.value = float(v->value.asNumber());
- output->addInstruction(instr);
- }
- break;
- case QVariant::Double:
- {
- Instruction::StoreDouble instr;
- instr.propertyIndex = prop->index;
- instr.value = v->value.asNumber();
- output->addInstruction(instr);
- }
- break;
- case QVariant::Color:
- {
- Instruction::StoreColor instr;
- QColor c = QDeclarativeStringConverters::colorFromString(v->value.asString());
- instr.propertyIndex = prop->index;
- instr.value = c.rgba();
- output->addInstruction(instr);
- }
- break;
-#ifndef QT_NO_DATESTRING
- case QVariant::Date:
- {
- Instruction::StoreDate instr;
- QDate d = QDeclarativeStringConverters::dateFromString(v->value.asString());
- instr.propertyIndex = prop->index;
- instr.value = d.toJulianDay();
- output->addInstruction(instr);
- }
- break;
- case QVariant::Time:
- {
- Instruction::StoreTime instr;
- QTime time = QDeclarativeStringConverters::timeFromString(v->value.asString());
- instr.propertyIndex = prop->index;
- Q_ASSERT(sizeof(instr.time) == sizeof(QTime));
- ::memcpy(&instr.time, &time, sizeof(QTime));
- output->addInstruction(instr);
- }
- break;
- case QVariant::DateTime:
- {
- Instruction::StoreDateTime instr;
- QDateTime dateTime = QDeclarativeStringConverters::dateTimeFromString(v->value.asString());
- QTime time = dateTime.time();
- instr.propertyIndex = prop->index;
- instr.date = dateTime.date().toJulianDay();
- Q_ASSERT(sizeof(instr.time) == sizeof(QTime));
- ::memcpy(&instr.time, &time, sizeof(QTime));
- output->addInstruction(instr);
- }
- break;
-#endif // QT_NO_DATESTRING
- case QVariant::Point:
- {
- Instruction::StorePoint instr;
- bool ok;
- QPoint point = QDeclarativeStringConverters::pointFFromString(v->value.asString(), &ok).toPoint();
- instr.propertyIndex = prop->index;
- instr.point.xp = point.x();
- instr.point.yp = point.y();
- output->addInstruction(instr);
- }
- break;
- case QVariant::PointF:
- {
- Instruction::StorePointF instr;
- bool ok;
- QPointF point = QDeclarativeStringConverters::pointFFromString(v->value.asString(), &ok);
- instr.propertyIndex = prop->index;
- instr.point.xp = point.x();
- instr.point.yp = point.y();
- output->addInstruction(instr);
- }
- break;
- case QVariant::Size:
- {
- Instruction::StoreSize instr;
- bool ok;
- QSize size = QDeclarativeStringConverters::sizeFFromString(v->value.asString(), &ok).toSize();
- instr.propertyIndex = prop->index;
- instr.size.wd = size.width();
- instr.size.ht = size.height();
- output->addInstruction(instr);
- }
- break;
- case QVariant::SizeF:
- {
- Instruction::StoreSizeF instr;
- bool ok;
- QSizeF size = QDeclarativeStringConverters::sizeFFromString(v->value.asString(), &ok);
- instr.propertyIndex = prop->index;
- instr.size.wd = size.width();
- instr.size.ht = size.height();
- output->addInstruction(instr);
- }
- break;
- case QVariant::Rect:
- {
- Instruction::StoreRect instr;
- bool ok;
- QRect rect = QDeclarativeStringConverters::rectFFromString(v->value.asString(), &ok).toRect();
- instr.propertyIndex = prop->index;
- instr.rect.x1 = rect.left();
- instr.rect.y1 = rect.top();
- instr.rect.x2 = rect.right();
- instr.rect.y2 = rect.bottom();
- output->addInstruction(instr);
- }
- break;
- case QVariant::RectF:
- {
- Instruction::StoreRectF instr;
- bool ok;
- QRectF rect = QDeclarativeStringConverters::rectFFromString(v->value.asString(), &ok);
- instr.propertyIndex = prop->index;
- instr.rect.xp = rect.left();
- instr.rect.yp = rect.top();
- instr.rect.w = rect.width();
- instr.rect.h = rect.height();
- output->addInstruction(instr);
- }
- break;
- case QVariant::Bool:
- {
- Instruction::StoreBool instr;
- bool b = v->value.asBoolean();
- instr.propertyIndex = prop->index;
- instr.value = b;
- output->addInstruction(instr);
- }
- break;
- case QVariant::Vector3D:
- {
- Instruction::StoreVector3D instr;
- bool ok;
- QVector3D vector = QDeclarativeStringConverters::vector3DFromString(v->value.asString(), &ok);
- instr.propertyIndex = prop->index;
- instr.vector.xp = vector.x();
- instr.vector.yp = vector.y();
- instr.vector.zp = vector.z();
- output->addInstruction(instr);
- }
- break;
- case QVariant::Vector4D:
- {
- Instruction::StoreVector4D instr;
- bool ok;
- QVector4D vector = QDeclarativeStringConverters::vector4DFromString(v->value.asString(), &ok);
- instr.propertyIndex = prop->index;
- instr.vector.xp = vector.x();
- instr.vector.yp = vector.y();
- instr.vector.zp = vector.z();
- instr.vector.wp = vector.w();
- output->addInstruction(instr);
- }
- break;
- default:
- {
- // generate single literal value assignment to a list property if required
- if (type == qMetaTypeId<QList<qreal> >()) {
- Instruction::StoreDoubleQList instr;
- instr.propertyIndex = prop->index;
- instr.value = v->value.asNumber();
- output->addInstruction(instr);
- break;
- } else if (type == qMetaTypeId<QList<int> >()) {
- Instruction::StoreIntegerQList instr;
- instr.propertyIndex = prop->index;
- instr.value = int(v->value.asNumber());
- output->addInstruction(instr);
- break;
- } else if (type == qMetaTypeId<QList<bool> >()) {
- Instruction::StoreBoolQList instr;
- bool b = v->value.asBoolean();
- instr.propertyIndex = prop->index;
- instr.value = b;
- output->addInstruction(instr);
- break;
- } else if (type == qMetaTypeId<QList<QUrl> >()) {
- Instruction::StoreUrlQList instr;
- QString string = v->value.asString();
- QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string));
- instr.propertyIndex = prop->index;
- instr.value = output->indexForUrl(u);
- output->addInstruction(instr);
- break;
- } else if (type == qMetaTypeId<QList<QString> >()) {
- Instruction::StoreStringQList instr;
- instr.propertyIndex = prop->index;
- instr.value = output->indexForString(v->value.asString());
- output->addInstruction(instr);
- break;
- }
-
- // otherwise, generate custom type literal assignment
- Instruction::AssignCustomType instr;
- instr.propertyIndex = prop->index;
- instr.primitive = output->indexForString(v->value.asString());
- instr.type = type;
- output->addInstruction(instr);
- }
- break;
- }
-}
-
-/*!
- Resets data by clearing the lists that the QDeclarativeCompiler modifies.
-*/
-void QDeclarativeCompiler::reset(QDeclarativeCompiledData *data)
-{
- data->types.clear();
- data->primitives.clear();
- data->datas.clear();
- data->bytecode.resize(0);
-}
-
-/*!
- Compile \a unit, and store the output in \a out. \a engine is the QDeclarativeEngine
- with which the QDeclarativeCompiledData will be associated.
-
- Returns true on success, false on failure. On failure, the compile errors
- are available from errors().
-
- If the environment variant QML_COMPILER_DUMP is set
- (eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr
- on a successful compiler.
-*/
-bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
- QDeclarativeTypeData *unit,
- QDeclarativeCompiledData *out)
-{
- exceptions.clear();
-
- Q_ASSERT(out);
- reset(out);
-
- QDeclarativeScript::Object *root = unit->parser().tree();
- Q_ASSERT(root);
-
- this->engine = engine;
- this->enginePrivate = QDeclarativeEnginePrivate::get(engine);
- this->unit = unit;
- this->unitRoot = root;
- this->output = out;
-
- // Compile types
- const QList<QDeclarativeTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
- QList<QDeclarativeScript::TypeReference *> referencedTypes = unit->parser().referencedTypes();
-
- for (int ii = 0; ii < resolvedTypes.count(); ++ii) {
- QDeclarativeCompiledData::TypeReference ref;
-
- const QDeclarativeTypeData::TypeReference &tref = resolvedTypes.at(ii);
- QDeclarativeScript::TypeReference *parserRef = referencedTypes.at(ii);
-
- if (tref.type) {
- ref.type = tref.type;
- if (!ref.type->isCreatable()) {
- QString err = ref.type->noCreationReason();
- if (err.isEmpty())
- err = tr( "Element is not creatable.");
- COMPILE_EXCEPTION(parserRef->refObjects.first(), err);
- }
-
- if (ref.type->containsRevisionedAttributes()) {
- QDeclarativeError cacheError;
- ref.typePropertyCache = enginePrivate->cache(ref.type, resolvedTypes.at(ii).minorVersion,
- cacheError);
- if (!ref.typePropertyCache)
- COMPILE_EXCEPTION(parserRef->refObjects.first(), cacheError.description());
- ref.typePropertyCache->addref();
- }
-
- } else if (tref.typeData) {
- ref.component = tref.typeData->compiledData();
- }
- ref.className = parserRef->name;
- out->types << ref;
- }
-
- compileTree(root);
-
- if (!isError()) {
- if (compilerDump())
- out->dumpInstructions();
- if (componentStats)
- dumpStats();
- Q_ASSERT(out->rootPropertyCache);
- } else {
- reset(out);
- }
-
- compileState = 0;
- output = 0;
- this->engine = 0;
- this->enginePrivate = 0;
- this->unit = 0;
- this->cachedComponentTypeRef = -1;
- this->cachedTranslationContextIndex = -1;
- this->unitRoot = 0;
-
- return !isError();
-}
-
-void QDeclarativeCompiler::compileTree(QDeclarativeScript::Object *tree)
-{
- compileState = pool->New<ComponentCompileState>();
-
- compileState->root = tree;
- if (componentStats)
- componentStats->componentStat.lineNumber = tree->location.start.line;
-
- // We generate the importCache before we build the tree so that
- // it can be used in the binding compiler. Given we "expect" the
- // QML compilation to succeed, this isn't a waste.
- output->importCache = new QDeclarativeTypeNameCache();
- foreach (const QString &ns, unit->namespaces()) {
- output->importCache->add(ns);
- }
-
- int scriptIndex = 0;
- foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) {
- QString qualifier = script.qualifier;
- QString enclosingNamespace;
-
- const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.'));
- if (lastDotIndex != -1) {
- enclosingNamespace = qualifier.left(lastDotIndex);
- qualifier = qualifier.mid(lastDotIndex+1);
- }
-
- output->importCache->add(qualifier, scriptIndex++, enclosingNamespace);
- }
-
- unit->imports().populateCache(output->importCache, engine);
-
- if (!buildObject(tree, BindingContext()) || !completeComponentBuild())
- return;
-
- Instruction::Init init;
- init.bindingsSize = compileState->totalBindingsCount;
- init.parserStatusSize = compileState->parserStatusCount;
- init.contextCache = genContextCache();
- init.objectStackSize = compileState->objectDepth.maxDepth();
- init.listStackSize = compileState->listDepth.maxDepth();
- if (compileState->compiledBindingData.isEmpty())
- init.compiledBinding = -1;
- else
- init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData);
- output->addInstruction(init);
-
- foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) {
- Instruction::StoreImportedScript import;
- import.value = output->scripts.count();
-
- QDeclarativeScriptData *scriptData = script.script->scriptData();
- scriptData->addref();
- output->scripts << scriptData;
- output->addInstruction(import);
- }
-
- if (!compileState->v8BindingProgram.isEmpty()) {
- Instruction::InitV8Bindings bindings;
- int index = output->programs.count();
-
- typedef QDeclarativeCompiledData::V8Program V8Program;
- output->programs.append(V8Program(compileState->v8BindingProgram, output));
-
- bindings.programIndex = index;
- bindings.line = compileState->v8BindingProgramLine;
- output->addInstruction(bindings);
- }
-
- genObject(tree);
-
- Instruction::SetDefault def;
- output->addInstruction(def);
-
- Instruction::Done done;
- output->addInstruction(done);
-
- Q_ASSERT(tree->metatype);
-
- if (tree->metadata.isEmpty()) {
- output->root = tree->metatype;
- } else {
- static_cast<QMetaObject &>(output->rootData) = *tree->metaObject();
- output->root = &output->rootData;
- }
- if (!tree->metadata.isEmpty())
- enginePrivate->registerCompositeType(output);
-}
-
-static bool QStringList_contains(const QStringList &list, const QHashedStringRef &string)
-{
- for (int ii = 0; ii < list.count(); ++ii)
- if (string == list.at(ii))
- return true;
-
- return false;
-}
-
-bool QDeclarativeCompiler::buildObject(QDeclarativeScript::Object *obj, const BindingContext &ctxt)
-{
- if (componentStats)
- componentStats->componentStat.objects++;
-
- Q_ASSERT (obj->type != -1);
- const QDeclarativeCompiledData::TypeReference &tr = output->types.at(obj->type);
- obj->metatype = tr.metaObject();
-
- if (tr.type)
- obj->typeName = tr.type->qmlTypeName();
-
- // This object is a "Component" element
- if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) {
- COMPILE_CHECK(buildComponent(obj, ctxt));
- return true;
- }
-
- if (tr.component) {
- typedef QDeclarativeInstruction I;
- const I *init = ((const I *)tr.component->bytecode.constData());
- Q_ASSERT(init && tr.component->instructionType(init) == QDeclarativeInstruction::Init);
-
- // Adjust stack depths to include nested components
- compileState->objectDepth.pushPop(init->init.objectStackSize);
- compileState->listDepth.pushPop(init->init.listStackSize);
- compileState->parserStatusCount += init->init.parserStatusSize;
- compileState->totalBindingsCount += init->init.bindingsSize;
- }
-
- compileState->objectDepth.push();
-
- // Object instantiations reset the binding context
- BindingContext objCtxt(obj);
-
- // Create the synthesized meta object, ignoring aliases
- COMPILE_CHECK(checkDynamicMeta(obj));
- COMPILE_CHECK(mergeDynamicMetaProperties(obj));
- COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases));
-
- // Find the native type and check for the QDeclarativeParserStatus interface
- QDeclarativeType *type = toQmlType(obj);
- Q_ASSERT(type);
- obj->parserStatusCast = type->parserStatusCast();
- if (obj->parserStatusCast != -1)
- compileState->parserStatusCount++;
-
- // Check if this is a custom parser type. Custom parser types allow
- // assignments to non-existent properties. These assignments are then
- // compiled by the type.
- bool isCustomParser = output->types.at(obj->type).type &&
- output->types.at(obj->type).type->customParser() != 0;
- QList<QDeclarativeCustomParserProperty> customProps;
-
- // Fetch the list of deferred properties
- QStringList deferredList = deferredProperties(obj);
-
- // Must do id property first. This is to ensure that the id given to any
- // id reference created matches the order in which the objects are
- // instantiated
- for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
- if (prop->name() == id_string) {
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- break;
- }
- }
-
- // Merge
- Property *defaultProperty = 0;
- Property *skipProperty = 0;
- if (obj->defaultProperty) {
- defaultProperty = obj->defaultProperty;
-
- Property *explicitProperty = 0;
-
- const QMetaObject *mo = obj->metatype;
- int idx = mo->indexOfClassInfo("DefaultProperty");
- if (idx != -1) {
- QMetaClassInfo info = mo->classInfo(idx);
- const char *p = info.value();
- if (p) {
- int plen = 0;
- char ord = 0;
- while (char c = p[plen++]) { ord |= c; };
- --plen;
-
- if (ord & 0x80) {
- // Utf8 - unoptimal, but seldom hit
- QString *s = pool->NewString(QString::fromUtf8(p, plen));
- QHashedStringRef r(*s);
-
- if (obj->propertiesHashField.test(r.hash())) {
- for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) {
- if (ep->name() == r) {
- explicitProperty = ep;
- break;
- }
- }
- }
-
- if (!explicitProperty)
- defaultProperty->setName(r);
-
- } else {
- QHashedCStringRef r(p, plen);
-
- if (obj->propertiesHashField.test(r.hash())) {
- for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) {
- if (ep->name() == r) {
- explicitProperty = ep;
- break;
- }
- }
- }
-
- if (!explicitProperty) {
- // Set the default property name
- QChar *buffer = pool->NewRawArray<QChar>(r.length());
- r.writeUtf16(buffer);
- defaultProperty->setName(QHashedStringRef(buffer, r.length(), r.hash()));
- }
- }
- }
- }
-
- if (explicitProperty && !explicitProperty->value && !explicitProperty->values.isEmpty()) {
-
- skipProperty = explicitProperty; // We merge the values into defaultProperty
-
- // Find the correct insertion point
- Value *insertPos = 0;
-
- for (Value *v = defaultProperty->values.first(); v; v = Property::ValueList::next(v)) {
- if (!(v->location.start < explicitProperty->values.first()->location.start))
- break;
- insertPos = v;
- }
-
- defaultProperty->values.insertAfter(insertPos, explicitProperty->values);
- }
- }
-
- QDeclarativeCustomParser *cp = 0;
- if (isCustomParser)
- cp = output->types.at(obj->type).type->customParser();
-
- // Build all explicit properties specified
- for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
-
- if (prop == skipProperty)
- continue;
- if (prop->name() == id_string)
- continue;
-
- bool canDefer = false;
- if (isCustomParser) {
- if (doesPropertyExist(prop, obj) &&
- (!(cp->flags() & QDeclarativeCustomParser::AcceptsAttachedProperties) ||
- !isAttachedPropertyName(prop->name()))) {
- int ids = compileState->ids.count();
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- canDefer = ids == compileState->ids.count();
- } else if (isSignalPropertyName(prop->name()) &&
- (cp->flags() & QDeclarativeCustomParser::AcceptsSignalHandlers)) {
- COMPILE_CHECK(buildSignal(prop,obj,objCtxt));
- } else {
- customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop);
- }
- } else {
- if (isSignalPropertyName(prop->name())) {
- COMPILE_CHECK(buildSignal(prop,obj,objCtxt));
- } else {
- int ids = compileState->ids.count();
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- canDefer = ids == compileState->ids.count();
- }
- }
-
- if (canDefer && !deferredList.isEmpty() && QStringList_contains(deferredList, prop->name()))
- prop->isDeferred = true;
-
- }
-
- // Build the default property
- if (defaultProperty) {
- Property *prop = defaultProperty;
-
- bool canDefer = false;
- if (isCustomParser) {
- if (doesPropertyExist(prop, obj)) {
- int ids = compileState->ids.count();
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- canDefer = ids == compileState->ids.count();
- } else {
- customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop);
- }
- } else {
- int ids = compileState->ids.count();
- COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
- canDefer = ids == compileState->ids.count();
- }
-
- if (canDefer && !deferredList.isEmpty() && QStringList_contains(deferredList, prop->name()))
- prop->isDeferred = true;
- }
-
- // Compile custom parser parts
- if (isCustomParser && !customProps.isEmpty()) {
- cp->clearErrors();
- cp->compiler = this;
- cp->object = obj;
- obj->custom = cp->compile(customProps);
- cp->compiler = 0;
- cp->object = 0;
- foreach (QDeclarativeError err, cp->errors()) {
- err.setUrl(output->url);
- exceptions << err;
- }
- }
-
- compileState->objectDepth.pop();
-
- return true;
-}
-
-void QDeclarativeCompiler::genObject(QDeclarativeScript::Object *obj)
-{
- QDeclarativeCompiledData::TypeReference &tr = output->types[obj->type];
- if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) {
- genComponent(obj);
- return;
- }
-
- // Create the object
- if (obj->custom.isEmpty() && output->types.at(obj->type).type &&
- !output->types.at(obj->type).type->isExtendedType() && obj != compileState->root) {
-
- Instruction::CreateSimpleObject create;
- create.create = output->types.at(obj->type).type->createFunction();
- create.typeSize = output->types.at(obj->type).type->createSize();
- create.type = obj->type;
- create.line = obj->location.start.line;
- create.column = obj->location.start.column;
- output->addInstruction(create);
-
- } else {
-
- if (output->types.at(obj->type).type) {
- Instruction::CreateCppObject create;
- create.line = obj->location.start.line;
- create.column = obj->location.start.column;
- create.data = -1;
- if (!obj->custom.isEmpty())
- create.data = output->indexForByteArray(obj->custom);
- create.type = obj->type;
- create.isRoot = (compileState->root == obj);
- output->addInstruction(create);
- } else {
- Instruction::CreateQMLObject create;
- create.type = obj->type;
- create.isRoot = (compileState->root == obj);
-
- if (!obj->bindingBitmask.isEmpty()) {
- Q_ASSERT(obj->bindingBitmask.size() % 4 == 0);
- create.bindingBits = output->indexForByteArray(obj->bindingBitmask);
- } else {
- create.bindingBits = -1;
- }
- output->addInstruction(create);
-
- Instruction::CompleteQMLObject complete;
- complete.line = obj->location.start.line;
- complete.column = obj->location.start.column;
- complete.isRoot = (compileState->root == obj);
- output->addInstruction(complete);
- }
- }
-
- // Setup the synthesized meta object if necessary
- if (!obj->metadata.isEmpty()) {
- Instruction::StoreMetaObject meta;
- meta.data = output->indexForByteArray(obj->metadata);
- meta.aliasData = output->indexForByteArray(obj->synthdata);
- meta.propertyCache = output->propertyCaches.count();
-
- QDeclarativePropertyCache *propertyCache = obj->synthCache;
- Q_ASSERT(propertyCache);
- propertyCache->addref();
-
- // Add flag for alias properties
- if (!obj->synthdata.isEmpty()) {
- const QDeclarativeVMEMetaData *vmeMetaData =
- reinterpret_cast<const QDeclarativeVMEMetaData *>(obj->synthdata.constData());
- for (int ii = 0; ii < vmeMetaData->aliasCount; ++ii) {
- int index = obj->metaObject()->propertyOffset() + vmeMetaData->propertyCount + ii;
- QDeclarativePropertyData *data = propertyCache->property(index);
- data->setFlags(data->getFlags() | QDeclarativePropertyData::IsAlias);
- }
- }
-
- if (obj == unitRoot) {
- propertyCache->addref();
- output->rootPropertyCache = propertyCache;
- }
-
- output->propertyCaches << propertyCache;
- output->addInstruction(meta);
- } else if (obj == unitRoot) {
- output->rootPropertyCache = tr.createPropertyCache(engine);
- output->rootPropertyCache->addref();
- }
-
- // Set the object id
- if (!obj->id.isEmpty()) {
- Instruction::SetId id;
- id.value = output->indexForString(obj->id);
- id.index = obj->idIndex;
- output->addInstruction(id);
- }
-
- // Begin the class
- if (tr.type && obj->parserStatusCast != -1) {
- Instruction::BeginObject begin;
- begin.castValue = obj->parserStatusCast;
- output->addInstruction(begin);
- }
-
- genObjectBody(obj);
-}
-
-void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
-{
- for (Property *prop = obj->scriptStringProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- Q_ASSERT(prop->scriptStringScope != -1);
- const QString &script = prop->values.first()->value.asScript();
- Instruction::StoreScriptString ss;
- ss.propertyIndex = prop->index;
- ss.value = output->indexForString(script);
- ss.scope = prop->scriptStringScope;
-// ss.bindingId = rewriteBinding(script, prop->name());
- ss.bindingId = rewriteBinding(prop->values.first()->value, QString()); // XXX
- ss.line = prop->location.start.line;
- ss.column = prop->location.start.column;
- output->addInstruction(ss);
- }
-
- bool seenDefer = false;
- for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- if (prop->isDeferred) {
- seenDefer = true;
- continue;
- }
- if (!prop->isAlias)
- genValueProperty(prop, obj);
- }
- if (seenDefer) {
- Instruction::Defer defer;
- defer.deferCount = 0;
- int deferIdx = output->addInstruction(defer);
- int nextInstructionIndex = output->nextInstructionIndex();
-
- Instruction::DeferInit dinit;
- // XXX - these are now massive over allocations
- dinit.bindingsSize = compileState->totalBindingsCount;
- dinit.parserStatusSize = compileState->parserStatusCount;
- dinit.objectStackSize = compileState->objectDepth.maxDepth();
- dinit.listStackSize = compileState->listDepth.maxDepth();
- output->addInstruction(dinit);
-
- for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- if (!prop->isDeferred)
- continue;
- genValueProperty(prop, obj);
- }
-
- Instruction::Done done;
- output->addInstruction(done);
-
- output->instruction(deferIdx)->defer.deferCount = output->nextInstructionIndex() - nextInstructionIndex;
- }
-
- for (Property *prop = obj->signalProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
-
- QDeclarativeScript::Value *v = prop->values.first();
-
- if (v->type == Value::SignalObject) {
-
- genObject(v->object);
-
- Instruction::AssignSignalObject assign;
- assign.line = v->location.start.line;
- assign.signal = output->indexForString(prop->name().toString());
- output->addInstruction(assign);
-
- } else if (v->type == Value::SignalExpression) {
-
- Instruction::StoreSignal store;
- store.signalIndex = prop->index;
- const QString &rewrite = rewriteSignalHandler(v->value, prop->name().toString());
- store.value = output->indexForByteArray(rewrite.toUtf8());
- store.context = v->signalExpressionContextStack;
- store.line = v->location.start.line;
- store.column = v->location.start.column;
- output->addInstruction(store);
-
- }
-
- }
-
- for (Property *prop = obj->attachedProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- Instruction::FetchAttached fetch;
- fetch.id = prop->index;
- fetch.line = prop->location.start.line;
- output->addInstruction(fetch);
-
- genObjectBody(prop->value);
-
- Instruction::PopFetchedObject pop;
- output->addInstruction(pop);
- }
-
- for (Property *prop = obj->groupedProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- Instruction::FetchObject fetch;
- fetch.property = prop->index;
- fetch.line = prop->location.start.line;
- output->addInstruction(fetch);
-
- if (!prop->value->metadata.isEmpty()) {
- Instruction::StoreMetaObject meta;
- meta.data = output->indexForByteArray(prop->value->metadata);
- meta.aliasData = output->indexForByteArray(prop->value->synthdata);
- meta.propertyCache = -1;
- output->addInstruction(meta);
- }
-
- genObjectBody(prop->value);
-
- Instruction::PopFetchedObject pop;
- output->addInstruction(pop);
- }
-
- for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- if (!prop->isAlias)
- genValueTypeProperty(obj, prop);
- }
-
- for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- if (prop->isDeferred)
- continue;
- if (prop->isAlias)
- genValueProperty(prop, obj);
- }
-
- for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
- if (prop->isAlias)
- genValueTypeProperty(obj, prop);
- }
-}
-
-void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *prop)
-{
- Instruction::FetchValueType fetch;
- fetch.property = prop->index;
- fetch.type = prop->type;
- fetch.bindingSkipList = 0;
-
- if (obj->type == -1 || output->types.at(obj->type).component) {
- // We only have to do this if this is a composite type. If it is a builtin
- // type it can't possibly already have bindings that need to be cleared.
- for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) {
- if (!vprop->values.isEmpty()) {
- Q_ASSERT(vprop->index >= 0 && vprop->index < 32);
- fetch.bindingSkipList |= (1 << vprop->index);
- }
- }
- }
-
- output->addInstruction(fetch);
-
- for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) {
- genPropertyAssignment(vprop, prop->value, prop);
- }
-
- Instruction::PopValueType pop;
- pop.property = prop->index;
- pop.type = prop->type;
- pop.bindingSkipList = 0;
- output->addInstruction(pop);
-}
-
-void QDeclarativeCompiler::genComponent(QDeclarativeScript::Object *obj)
-{
- QDeclarativeScript::Object *root = obj->defaultProperty->values.first()->object;
- Q_ASSERT(root);
-
- Instruction::CreateComponent create;
- create.line = root->location.start.line;
- create.column = root->location.start.column;
- create.endLine = root->location.end.line;
- create.isRoot = (compileState->root == obj);
- int createInstruction = output->addInstruction(create);
- int nextInstructionIndex = output->nextInstructionIndex();
-
- ComponentCompileState *oldCompileState = compileState;
- compileState = componentState(root);
-
- Instruction::Init init;
- init.bindingsSize = compileState->totalBindingsCount;
- init.parserStatusSize = compileState->parserStatusCount;
- init.contextCache = genContextCache();
- init.objectStackSize = compileState->objectDepth.maxDepth();
- init.listStackSize = compileState->listDepth.maxDepth();
- if (compileState->compiledBindingData.isEmpty())
- init.compiledBinding = -1;
- else
- init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData);
- output->addInstruction(init);
-
- if (!compileState->v8BindingProgram.isEmpty()) {
- Instruction::InitV8Bindings bindings;
- int index = output->programs.count();
-
- typedef QDeclarativeCompiledData::V8Program V8Program;
- output->programs.append(V8Program(compileState->v8BindingProgram, output));
-
- bindings.programIndex = index;
- bindings.line = compileState->v8BindingProgramLine;
- output->addInstruction(bindings);
- }
-
- genObject(root);
-
- Instruction::SetDefault def;
- output->addInstruction(def);
-
- Instruction::Done done;
- output->addInstruction(done);
-
- output->instruction(createInstruction)->createComponent.count =
- output->nextInstructionIndex() - nextInstructionIndex;
-
- compileState = oldCompileState;
-
- if (!obj->id.isEmpty()) {
- Instruction::SetId id;
- id.value = output->indexForString(obj->id);
- id.index = obj->idIndex;
- output->addInstruction(id);
- }
-
- if (obj == unitRoot) {
- output->rootPropertyCache = output->types[obj->type].createPropertyCache(engine);
- output->rootPropertyCache->addref();
- }
-}
-
-bool QDeclarativeCompiler::buildComponent(QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- // The special "Component" element can only have the id property and a
- // default property, that actually defines the component's tree
-
- compileState->objectDepth.push();
-
- // Find, check and set the "id" property (if any)
- Property *idProp = 0;
- if (obj->properties.isMany() ||
- (obj->properties.isOne() && obj->properties.first()->name() != id_string))
- COMPILE_EXCEPTION(obj->properties.first(), tr("Component elements may not contain properties other than id"));
-
- if (!obj->properties.isEmpty())
- idProp = obj->properties.first();
-
- if (idProp) {
- if (idProp->value || idProp->values.isMany() || idProp->values.first()->object)
- COMPILE_EXCEPTION(idProp, tr("Invalid component id specification"));
- COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()))
-
- QString idVal = idProp->values.first()->primitive();
-
- if (compileState->ids.value(idVal))
- COMPILE_EXCEPTION(idProp, tr("id is not unique"));
-
- obj->id = idVal;
- addId(idVal, obj);
- }
-
- // Check the Component tree is well formed
- if (obj->defaultProperty &&
- (obj->defaultProperty->value || obj->defaultProperty->values.isMany() ||
- (obj->defaultProperty->values.isOne() && !obj->defaultProperty->values.first()->object)))
- COMPILE_EXCEPTION(obj, tr("Invalid component body specification"));
-
- if (!obj->dynamicProperties.isEmpty())
- COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new properties."));
- if (!obj->dynamicSignals.isEmpty())
- COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new signals."));
- if (!obj->dynamicSlots.isEmpty())
- COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new functions."));
-
- QDeclarativeScript::Object *root = 0;
- if (obj->defaultProperty && !obj->defaultProperty->values.isEmpty())
- root = obj->defaultProperty->values.first()->object;
-
- if (!root)
- COMPILE_EXCEPTION(obj, tr("Cannot create empty component specification"));
-
- // Build the component tree
- COMPILE_CHECK(buildComponentFromRoot(root, ctxt));
-
- compileState->objectDepth.pop();
-
- return true;
-}
-
-bool QDeclarativeCompiler::buildComponentFromRoot(QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- ComponentCompileState *oldComponentCompileState = compileState;
- compileState = pool->New<ComponentCompileState>();
- compileState->root = obj;
- compileState->nested = true;
-
- if (componentStats) {
- ComponentStat oldComponentStat = componentStats->componentStat;
-
- componentStats->componentStat = ComponentStat();
- componentStats->componentStat.lineNumber = obj->location.start.line;
-
- if (obj)
- COMPILE_CHECK(buildObject(obj, ctxt));
-
- COMPILE_CHECK(completeComponentBuild());
-
- componentStats->componentStat = oldComponentStat;
- } else {
- if (obj)
- COMPILE_CHECK(buildObject(obj, ctxt));
-
- COMPILE_CHECK(completeComponentBuild());
- }
-
- compileState = oldComponentCompileState;
-
- return true;
-}
-
-
-// Build a sub-object. A sub-object is one that was not created directly by
-// QML - such as a grouped property object, or an attached object. Sub-object's
-// can't have an id, involve a custom parser, have attached properties etc.
-bool QDeclarativeCompiler::buildSubObject(QDeclarativeScript::Object *obj, const BindingContext &ctxt)
-{
- Q_ASSERT(obj->metatype);
- Q_ASSERT(!obj->defaultProperty);
- Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
- // sub-context
-
- for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
- if (isSignalPropertyName(prop->name())) {
- COMPILE_CHECK(buildSignal(prop, obj, ctxt));
- } else {
- COMPILE_CHECK(buildProperty(prop, obj, ctxt));
- }
- }
-
- return true;
-}
-
-int QDeclarativeCompiler::componentTypeRef()
-{
- if (cachedComponentTypeRef == -1) {
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(Component_import_string,1,0);
- for (int ii = output->types.count() - 1; ii >= 0; --ii) {
- if (output->types.at(ii).type == t) {
- cachedComponentTypeRef = ii;
- return ii;
- }
- }
- QDeclarativeCompiledData::TypeReference ref;
- ref.className = Component_string;
- ref.type = t;
- output->types << ref;
- cachedComponentTypeRef = output->types.count() - 1;
- }
- return cachedComponentTypeRef;
-}
-
-int QDeclarativeCompiler::translationContextIndex()
-{
- if (cachedTranslationContextIndex == -1) {
- // This code must match that in the qsTr() implementation
- const QString &path = output->name;
- int lastSlash = path.lastIndexOf(QLatin1Char('/'));
- QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, path.length()-lastSlash-5) :
- QString();
- QByteArray contextUtf8 = context.toUtf8();
- cachedTranslationContextIndex = output->indexForByteArray(contextUtf8);
- }
- return cachedTranslationContextIndex;
-}
-
-bool QDeclarativeCompiler::buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- Q_ASSERT(obj->metaObject());
-
- const QHashedStringRef &propName = prop->name();
-
- Q_ASSERT(propName.startsWith(on_string));
- QString name = propName.mid(2, -1).toString();
-
- // Note that the property name could start with any alpha or '_' or '$' character,
- // so we need to do the lower-casing of the first alpha character.
- for (int firstAlphaIndex = 0; firstAlphaIndex < name.size(); ++firstAlphaIndex) {
- if (name.at(firstAlphaIndex).isUpper()) {
- name[firstAlphaIndex] = name.at(firstAlphaIndex).toLower();
- break;
- }
- }
-
- bool notInRevision = false;
-
- QDeclarativePropertyData *sig = signal(obj, QStringRef(&name), &notInRevision);
-
- if (sig == 0) {
-
- if (notInRevision && 0 == property(obj, propName, 0)) {
- Q_ASSERT(obj->type != -1);
- const QList<QDeclarativeTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
- const QDeclarativeTypeData::TypeReference &type = resolvedTypes.at(obj->type);
- if (type.type) {
- COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion));
- } else {
- COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(elementName(obj)).arg(prop->name().toString()));
- }
- }
-
- // If the "on<Signal>" name doesn't resolve into a signal, try it as a
- // property.
- COMPILE_CHECK(buildProperty(prop, obj, ctxt));
-
- } else {
-
- if (prop->value || !prop->values.isOne())
- COMPILE_EXCEPTION(prop, tr("Incorrectly specified signal assignment"));
-
- prop->index = sig->coreIndex;
- prop->core = *sig;
-
- obj->addSignalProperty(prop);
-
- if (prop->values.first()->object) {
- COMPILE_CHECK(buildObject(prop->values.first()->object, ctxt));
- prop->values.first()->type = Value::SignalObject;
- } else {
- prop->values.first()->type = Value::SignalExpression;
-
- if (!prop->values.first()->value.isScript())
- COMPILE_EXCEPTION(prop, tr("Cannot assign a value to a signal (expecting a script to be run)"));
-
- QString script = prop->values.first()->value.asScript().trimmed();
- if (script.isEmpty())
- COMPILE_EXCEPTION(prop, tr("Empty signal assignment"));
-
- prop->values.first()->signalExpressionContextStack = ctxt.stack;
- }
- }
-
- return true;
-}
-
-
-/*!
- Returns true if (value) property \a prop exists on obj, false otherwise.
-*/
-bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj)
-{
- if (prop->name().isEmpty())
- return false;
- if(isAttachedPropertyName(prop->name()) || prop->name() == id_string)
- return true;
-
- return property(obj, prop->name()) != 0;
-}
-
-bool QDeclarativeCompiler::buildProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- if (prop->isEmpty())
- COMPILE_EXCEPTION(prop, tr("Empty property assignment"));
-
- const QMetaObject *metaObject = obj->metaObject();
- Q_ASSERT(metaObject);
-
- if (isAttachedPropertyName(prop->name())) {
- // Setup attached property data
-
- if (ctxt.isSubContext()) {
- // Attached properties cannot be used on sub-objects. Sub-objects
- // always exist in a binding sub-context, which is what we test
- // for here.
- COMPILE_EXCEPTION(prop, tr("Attached properties cannot be used here"));
- }
-
- QDeclarativeType *type = 0;
- QDeclarativeImportedNamespace *typeNamespace = 0;
- unit->imports().resolveType(prop->name().toString(), &type, 0, 0, 0, &typeNamespace);
-
- if (typeNamespace) {
- COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj,
- ctxt));
- return true;
- } else if (!type || !type->attachedPropertiesType()) {
- COMPILE_EXCEPTION(prop, tr("Non-existent attached object"));
- }
-
- if (!prop->value)
- COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment"));
-
- Q_ASSERT(type->attachedPropertiesFunction());
- prop->index = type->attachedPropertiesId();
- prop->value->metatype = type->attachedPropertiesType();
- } else {
- // Setup regular property data
- bool notInRevision = false;
- QDeclarativePropertyData *d =
- prop->name().isEmpty()?0:property(obj, prop->name(), &notInRevision);
-
- if (d == 0 && notInRevision) {
- const QList<QDeclarativeTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
- const QDeclarativeTypeData::TypeReference &type = resolvedTypes.at(obj->type);
- if (type.type) {
- COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion));
- } else {
- COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(elementName(obj)).arg(prop->name().toString()));
- }
- } else if (d) {
- prop->index = d->coreIndex;
- prop->core = *d;
- } else if (prop->isDefault) {
- QMetaProperty p = QDeclarativeMetaType::defaultProperty(metaObject);
- QDeclarativePropertyData defaultPropertyData;
- defaultPropertyData.load(p, engine);
- if (p.name())
- prop->setName(QLatin1String(p.name()));
- prop->core = defaultPropertyData;
- prop->index = prop->core.coreIndex;
- }
-
- // We can't error here as the "id" property does not require a
- // successful index resolution
- if (prop->index != -1)
- prop->type = prop->core.propType;
-
- // Check if this is an alias
- if (prop->index != -1 &&
- prop->parent &&
- prop->parent->type != -1 &&
- output->types.at(prop->parent->type).component) {
-
- QDeclarativePropertyCache *cache = output->types.at(prop->parent->type).component->rootPropertyCache;
- if (cache && cache->property(prop->index) && cache->property(prop->index)->isAlias())
- prop->isAlias = true;
- }
-
- if (prop->index != -1 && !prop->values.isEmpty())
- prop->parent->setBindingBit(prop->index);
- }
-
- if (!prop->isDefault && prop->name() == id_string && !ctxt.isSubContext()) {
-
- // The magic "id" behavior doesn't apply when "id" is resolved as a
- // default property or to sub-objects (which are always in binding
- // sub-contexts)
- COMPILE_CHECK(buildIdProperty(prop, obj));
- if (prop->type == QVariant::String &&
- prop->values.first()->value.isString())
- COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
-
- } else if (isAttachedPropertyName(prop->name())) {
-
- COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
-
- } else if (prop->index == -1) {
-
- if (prop->isDefault) {
- COMPILE_EXCEPTION(prop->values.first(), tr("Cannot assign to non-existent default property"));
- } else {
- COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString()));
- }
-
- } else if (prop->value) {
-
- COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt));
-
- } else if (prop->core.isQList()) {
-
- COMPILE_CHECK(buildListProperty(prop, obj, ctxt));
-
- } else if (prop->type == qMetaTypeId<QDeclarativeScriptString>()) {
-
- COMPILE_CHECK(buildScriptStringProperty(prop, obj, ctxt));
-
- } else {
-
- COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
-
- }
-
- return true;
-}
-
-bool QDeclarativeCompiler::buildPropertyInNamespace(QDeclarativeImportedNamespace *ns,
- QDeclarativeScript::Property *nsProp,
- QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- if (!nsProp->value)
- COMPILE_EXCEPTION(nsProp, tr("Invalid use of namespace"));
-
- for (Property *prop = nsProp->value->properties.first(); prop; prop = nsProp->value->properties.next(prop)) {
-
- if (!isAttachedPropertyName(prop->name()))
- COMPILE_EXCEPTION(prop, tr("Not an attached property name"));
-
- // Setup attached property data
-
- QDeclarativeType *type = 0;
- unit->imports().resolveType(ns, prop->name().toString(), &type, 0, 0, 0);
-
- if (!type || !type->attachedPropertiesType())
- COMPILE_EXCEPTION(prop, tr("Non-existent attached object"));
-
- if (!prop->value)
- COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment"));
-
- Q_ASSERT(type->attachedPropertiesFunction());
- prop->index = type->index();
- prop->value->metatype = type->attachedPropertiesType();
-
- COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
- }
-
- return true;
-}
-
-void QDeclarativeCompiler::genValueProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj)
-{
- if (prop->core.isQList()) {
- genListProperty(prop, obj);
- } else {
- genPropertyAssignment(prop, obj);
- }
-}
-
-void QDeclarativeCompiler::genListProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj)
-{
- int listType = enginePrivate->listType(prop->type);
-
- Instruction::FetchQList fetch;
- fetch.property = prop->index;
- bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType);
- fetch.type = listType;
- output->addInstruction(fetch);
-
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
-
- if (v->type == Value::CreatedObject) {
-
- genObject(v->object);
- if (listTypeIsInterface) {
- Instruction::AssignObjectList assign;
- assign.line = prop->location.start.line;
- output->addInstruction(assign);
- } else {
- Instruction::StoreObjectQList store;
- output->addInstruction(store);
- }
-
- } else if (v->type == Value::PropertyBinding) {
-
- genBindingAssignment(v, prop, obj);
-
- }
-
- }
-
- Instruction::PopQList pop;
- output->addInstruction(pop);
-}
-
-void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Property *valueTypeProperty)
-{
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
-
- Q_ASSERT(v->type == Value::CreatedObject ||
- v->type == Value::PropertyBinding ||
- v->type == Value::Literal);
-
- if (v->type == Value::CreatedObject) {
-
- genObject(v->object);
-
- if (QDeclarativeMetaType::isInterface(prop->type)) {
-
- Instruction::StoreInterface store;
- store.line = v->object->location.start.line;
- store.propertyIndex = prop->index;
- output->addInstruction(store);
-
- } else if (prop->type == QMetaType::QVariant) {
-
- if (prop->core.isVMEProperty()) {
- Instruction::StoreVarObject store;
- store.line = v->object->location.start.line;
- store.propertyIndex = prop->index;
- output->addInstruction(store);
- } else {
- Instruction::StoreVariantObject store;
- store.line = v->object->location.start.line;
- store.propertyIndex = prop->index;
- output->addInstruction(store);
- }
-
-
- } else {
-
- Instruction::StoreObject store;
- store.line = v->object->location.start.line;
- store.propertyIndex = prop->index;
- output->addInstruction(store);
-
- }
- } else if (v->type == Value::PropertyBinding) {
-
- genBindingAssignment(v, prop, obj, valueTypeProperty);
-
- } else if (v->type == Value::Literal) {
-
- genLiteralAssignment(prop, v);
-
- }
-
- }
-
- for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
-
- Q_ASSERT(v->type == Value::ValueSource ||
- v->type == Value::ValueInterceptor);
-
- if (v->type == Value::ValueSource) {
- genObject(v->object);
-
- Instruction::StoreValueSource store;
- if (valueTypeProperty) {
- store.property = genValueTypeData(prop, valueTypeProperty);
- store.owner = 1;
- } else {
- store.property = prop->core;
- store.owner = 0;
- }
- QDeclarativeType *valueType = toQmlType(v->object);
- store.castValue = valueType->propertyValueSourceCast();
- output->addInstruction(store);
-
- } else if (v->type == Value::ValueInterceptor) {
- genObject(v->object);
-
- Instruction::StoreValueInterceptor store;
- if (valueTypeProperty) {
- store.property = genValueTypeData(prop, valueTypeProperty);
- store.owner = 1;
- } else {
- store.property = prop->core;
- store.owner = 0;
- }
- QDeclarativeType *valueType = toQmlType(v->object);
- store.castValue = valueType->propertyValueInterceptorCast();
- output->addInstruction(store);
- }
-
- }
-}
-
-bool QDeclarativeCompiler::buildIdProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj)
-{
- if (prop->value ||
- prop->values.isMany() ||
- prop->values.first()->object)
- COMPILE_EXCEPTION(prop, tr("Invalid use of id property"));
-
- QDeclarativeScript::Value *idValue = prop->values.first();
- QString val = idValue->primitive();
-
- COMPILE_CHECK(checkValidId(idValue, val));
-
- if (compileState->ids.value(val))
- COMPILE_EXCEPTION(prop, tr("id is not unique"));
-
- prop->values.first()->type = Value::Id;
-
- obj->id = val;
- addId(val, obj);
-
- return true;
-}
-
-void QDeclarativeCompiler::addId(const QString &id, QDeclarativeScript::Object *obj)
-{
- Q_UNUSED(id);
- Q_ASSERT(!compileState->ids.value(id));
- Q_ASSERT(obj->id == id);
- obj->idIndex = compileState->ids.count();
- compileState->ids.append(obj);
-}
-
-void QDeclarativeCompiler::addBindingReference(JSBindingReference *ref)
-{
- Q_ASSERT(ref->value && !ref->value->bindingReference);
- ref->value->bindingReference = ref;
- compileState->totalBindingsCount++;
- compileState->bindings.prepend(ref);
-}
-
-void QDeclarativeCompiler::saveComponentState()
-{
- Q_ASSERT(compileState->root);
- Q_ASSERT(compileState->root->componentCompileState == 0);
-
- compileState->root->componentCompileState = compileState;
-
- if (componentStats)
- componentStats->savedComponentStats.append(componentStats->componentStat);
-}
-
-QDeclarativeCompilerTypes::ComponentCompileState *
-QDeclarativeCompiler::componentState(QDeclarativeScript::Object *obj)
-{
- Q_ASSERT(obj->componentCompileState);
- return obj->componentCompileState;
-}
-
-// Build attached property object. In this example,
-// Text {
-// GridView.row: 10
-// }
-// GridView is an attached property object.
-bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->value);
- Q_ASSERT(prop->index != -1); // This is set in buildProperty()
-
- compileState->objectDepth.push();
-
- obj->addAttachedProperty(prop);
-
- COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
-
- compileState->objectDepth.pop();
-
- return true;
-}
-
-
-// Build "grouped" properties. In this example:
-// Text {
-// font.pointSize: 12
-// font.family: "Helvetica"
-// }
-// font is a nested property. pointSize and family are not.
-bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->type != 0);
- Q_ASSERT(prop->index != -1);
-
- if (QDeclarativeValueTypeFactory::isValueType(prop->type)) {
- if (prop->type >= 0 && enginePrivate->valueTypes[prop->type]) {
-
- if (!prop->values.isEmpty()) {
- if (prop->values.first()->location < prop->value->location) {
- COMPILE_EXCEPTION(prop->value, tr( "Property has already been assigned a value"));
- } else {
- COMPILE_EXCEPTION(prop->values.first(), tr( "Property has already been assigned a value"));
- }
- }
-
- if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) {
- COMPILE_EXCEPTION(prop, tr( "Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
- }
-
-
- if (prop->isAlias) {
- for (Property *vtProp = prop->value->properties.first(); vtProp; vtProp = prop->value->properties.next(vtProp)) {
- vtProp->isAlias = true;
- }
- }
-
- COMPILE_CHECK(buildValueTypeProperty(enginePrivate->valueTypes[prop->type],
- prop->value, obj, ctxt.incr()));
- obj->addValueTypeProperty(prop);
- } else {
- COMPILE_EXCEPTION(prop, tr("Invalid grouped property access"));
- }
-
- } else {
- // Load the nested property's meta type
- prop->value->metatype = enginePrivate->metaObjectForType(prop->type);
- if (!prop->value->metatype)
- COMPILE_EXCEPTION(prop, tr("Invalid grouped property access"));
-
- if (!prop->values.isEmpty())
- COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign a value directly to a grouped property"));
-
- obj->addGroupedProperty(prop);
-
- compileState->objectDepth.push();
-
- COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
-
- compileState->objectDepth.pop();
- }
-
- return true;
-}
-
-bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Object *baseObj,
- const BindingContext &ctxt)
-{
- compileState->objectDepth.push();
-
- if (obj->defaultProperty)
- COMPILE_EXCEPTION(obj, tr("Invalid property use"));
- obj->metatype = type->metaObject();
-
- for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
-
- QDeclarativePropertyData *d = property(obj, prop->name());
- if (d == 0)
- COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString()));
-
- prop->index = d->coreIndex;
- prop->type = d->propType;
- prop->core = *d;
- prop->isValueTypeSubProperty = true;
-
- if (prop->value)
- COMPILE_EXCEPTION(prop, tr("Property assignment expected"));
-
- if (prop->values.isMany()) {
- COMPILE_EXCEPTION(prop, tr("Single property assignment expected"));
- } else if (!prop->values.isEmpty()) {
- QDeclarativeScript::Value *value = prop->values.first();
-
- if (value->object) {
- COMPILE_EXCEPTION(prop, tr("Unexpected object assignment"));
- } else if (value->value.isScript()) {
- // ### Check for writability
-
- //optimization for <Type>.<EnumValue> enum assignments
- bool isEnumAssignment = false;
-
- if (prop->core.isEnum())
- COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, value, &isEnumAssignment));
-
- if (isEnumAssignment) {
- value->type = Value::Literal;
- } else {
- JSBindingReference *reference = pool->New<JSBindingReference>();
- reference->expression = value->value;
- reference->property = prop;
- reference->value = value;
- reference->bindingContext = ctxt;
- reference->bindingContext.owner++;
- addBindingReference(reference);
- value->type = Value::PropertyBinding;
- }
- } else {
- COMPILE_CHECK(testLiteralAssignment(prop, value));
- value->type = Value::Literal;
- }
- }
-
- for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
- Q_ASSERT(v->object);
-
- COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt));
- }
-
- obj->addValueProperty(prop);
- }
-
- compileState->objectDepth.pop();
-
- return true;
-}
-
-// Build assignments to QML lists. QML lists are properties of type
-// QDeclarativeListProperty<T>. List properties can accept a list of
-// objects, or a single binding.
-bool QDeclarativeCompiler::buildListProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->core.isQList());
-
- compileState->listDepth.push();
-
- int t = prop->type;
-
- obj->addValueProperty(prop);
-
- int listType = enginePrivate->listType(t);
- bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType);
-
- bool assignedBinding = false;
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
- if (v->object) {
- v->type = Value::CreatedObject;
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- // We check object coercian here. We check interface assignment
- // at runtime.
- if (!listTypeIsInterface) {
- if (!canCoerce(listType, v->object)) {
- COMPILE_EXCEPTION(v, tr("Cannot assign object to list"));
- }
- }
-
- } else if (v->value.isScript()) {
- if (assignedBinding)
- COMPILE_EXCEPTION(v, tr("Can only assign one binding to lists"));
-
- assignedBinding = true;
- COMPILE_CHECK(buildBinding(v, prop, ctxt));
- v->type = Value::PropertyBinding;
- } else {
- COMPILE_EXCEPTION(v, tr("Cannot assign primitives to lists"));
- }
- }
-
- compileState->listDepth.pop();
-
- return true;
-}
-
-// Compiles an assignment to a QDeclarativeScriptString property
-bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- if (prop->values.isMany())
- COMPILE_EXCEPTION(prop->values.first()->nextValue, tr( "Cannot assign multiple values to a script property"));
-
- if (prop->values.first()->object)
- COMPILE_EXCEPTION(prop->values.first(), tr( "Invalid property assignment: script expected"));
-
- prop->scriptStringScope = ctxt.stack;
- obj->addScriptStringProperty(prop);
-
- return true;
-}
-
-// Compile regular property assignments of the form "property: <value>"
-bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const BindingContext &ctxt)
-{
- obj->addValueProperty(prop);
-
- if (prop->values.isMany())
- COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign multiple values to a singular property") );
-
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
- if (v->object) {
-
- COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
-
- } else {
-
- COMPILE_CHECK(buildPropertyLiteralAssignment(prop, obj, v, ctxt));
-
- }
- }
-
- for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
- Q_ASSERT(v->object);
- COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt));
- }
-
- return true;
-}
-
-// Compile assigning a single object instance to a regular property
-bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Value *v,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->index != -1);
- Q_ASSERT(v->object->type != -1);
-
- if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration)
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
-
- if (QDeclarativeMetaType::isInterface(prop->type)) {
-
- // Assigning an object to an interface ptr property
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- v->type = Value::CreatedObject;
-
- } else if (prop->type == QMetaType::QVariant) {
-
- // Assigning an object to a QVariant
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- v->type = Value::CreatedObject;
- } else {
- // Normally buildObject() will set this up, but we need the static
- // meta object earlier to test for assignability. It doesn't matter
- // that there may still be outstanding synthesized meta object changes
- // on this type, as they are not relevant for assignability testing
- v->object->metatype = output->types.at(v->object->type).metaObject();
- Q_ASSERT(v->object->metaObject());
-
- // We want to raw metaObject here as the raw metaobject is the
- // actual property type before we applied any extensions that might
- // effect the properties on the type, but don't effect assignability
- const QMetaObject *propertyMetaObject = enginePrivate->rawMetaObjectForType(prop->type);
-
- // Will be true if the assgned type inherits propertyMetaObject
- bool isAssignable = false;
- // Determine isAssignable value
- if (propertyMetaObject) {
- const QMetaObject *c = v->object->metatype;
- while(c) {
- isAssignable |= (QDeclarativePropertyPrivate::equal(c, propertyMetaObject));
- c = c->superClass();
- }
- }
-
- if (isAssignable) {
- // Simple assignment
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- v->type = Value::CreatedObject;
- } else if (propertyMetaObject == &QDeclarativeComponent::staticMetaObject) {
- // Automatic "Component" insertion
- QDeclarativeScript::Object *root = v->object;
- QDeclarativeScript::Object *component = pool->New<Object>();
- component->type = componentTypeRef();
- component->typeName = QStringLiteral("Qt/Component");
- component->metatype = &QDeclarativeComponent::staticMetaObject;
- component->location = root->location;
- QDeclarativeScript::Value *componentValue = pool->New<Value>();
- componentValue->object = root;
- component->getDefaultProperty()->addValue(componentValue);
- v->object = component;
- COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
- } else {
- COMPILE_EXCEPTION(v->object, tr("Cannot assign object to property"));
- }
- }
-
- return true;
-}
-
-// Compile assigning a single object instance to a regular property using the "on" syntax.
-//
-// For example:
-// Item {
-// NumberAnimation on x { }
-// }
-bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Object *baseObj,
- QDeclarativeScript::Value *v,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->index != -1);
- Q_ASSERT(v->object->type != -1);
-
- Q_UNUSED(obj);
-
- if (!prop->core.isWritable())
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
-
-
- // Normally buildObject() will set this up, but we need the static
- // meta object earlier to test for assignability. It doesn't matter
- // that there may still be outstanding synthesized meta object changes
- // on this type, as they are not relevant for assignability testing
- v->object->metatype = output->types.at(v->object->type).metaObject();
- Q_ASSERT(v->object->metaObject());
-
- // Will be true if the assigned type inherits QDeclarativePropertyValueSource
- bool isPropertyValue = false;
- // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor
- bool isPropertyInterceptor = false;
- if (QDeclarativeType *valueType = toQmlType(v->object)) {
- isPropertyValue = valueType->propertyValueSourceCast() != -1;
- isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1;
- }
-
- if (isPropertyValue || isPropertyInterceptor) {
- // Assign as a property value source
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- if (isPropertyInterceptor && prop->parent->synthdata.isEmpty())
- buildDynamicMeta(baseObj, ForceCreation);
- v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
- } else {
- COMPILE_EXCEPTION(v, tr("\"%1\" cannot operate on \"%2\"").arg(v->object->typeName).arg(prop->name().toString()));
- }
-
- return true;
-}
-
-// Compile assigning a literal or binding to a regular property
-bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Value *v,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->index != -1);
-
- if (v->value.isScript()) {
-
- //optimization for <Type>.<EnumValue> enum assignments
- if (prop->core.isEnum()) {
- bool isEnumAssignment = false;
- COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, v, &isEnumAssignment));
- if (isEnumAssignment) {
- v->type = Value::Literal;
- return true;
- }
- }
-
- // Test for other binding optimizations
- if (!buildLiteralBinding(v, prop, ctxt))
- COMPILE_CHECK(buildBinding(v, prop, ctxt));
-
- v->type = Value::PropertyBinding;
-
- } else {
-
- COMPILE_CHECK(testLiteralAssignment(prop, v));
-
- v->type = Value::Literal;
- }
-
- return true;
-}
-
-bool QDeclarativeCompiler::testQualifiedEnumAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Value *v,
- bool *isAssignment)
-{
- *isAssignment = false;
- if (!prop->core.isEnum())
- return true;
-
- QMetaProperty mprop = obj->metaObject()->property(prop->index);
-
- if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration)
- COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
-
- QString string = v->value.asString();
- if (!string.at(0).isUpper())
- return true;
-
- QStringList parts = string.split(QLatin1Char('.'));
- if (parts.count() != 2)
- return true;
-
- QString typeName = parts.at(0);
- QDeclarativeType *type = 0;
- unit->imports().resolveType(typeName, &type, 0, 0, 0, 0);
-
- //handle enums on value types (where obj->typeName is empty)
- QString objTypeName = obj->typeName;
- if (objTypeName.isEmpty()) {
- QDeclarativeType *objType = toQmlType(obj);
- if (objType)
- objTypeName = objType->qmlTypeName();
- }
-
- if (!type)
- return true;
-
- QString enumValue = parts.at(1);
- int value;
- bool ok;
-
- if (objTypeName == type->qmlTypeName()) {
- // When these two match, we can short cut the search
- if (mprop.isFlagType()) {
- value = mprop.enumerator().keysToValue(enumValue.toUtf8().constData(), &ok);
- } else {
- value = mprop.enumerator().keyToValue(enumValue.toUtf8().constData(), &ok);
- }
- } else {
- // Otherwise we have to search the whole type
- // This matches the logic in QV8TypeWrapper
- QByteArray enumName = enumValue.toUtf8();
- const QMetaObject *metaObject = type->baseMetaObject();
- ok = false;
- for (int ii = metaObject->enumeratorCount() - 1; !ok && ii >= 0; --ii) {
- QMetaEnum e = metaObject->enumerator(ii);
- value = e.keyToValue(enumName.constData(), &ok);
- }
- }
-
- if (!ok)
- return true;
-
- v->type = Value::Literal;
- v->value = QDeclarativeScript::Variant((double)value);
- *isAssignment = true;
-
- return true;
-}
-
-struct StaticQtMetaObject : public QObject
-{
- static const QMetaObject *get()
- { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
-};
-
-// Similar logic to above, but not knowing target property.
-int QDeclarativeCompiler::evaluateEnum(const QByteArray& script) const
-{
- int dot = script.indexOf('.');
- if (dot > 0) {
- const QByteArray &scope = script.left(dot);
- QDeclarativeType *type = 0;
- unit->imports().resolveType(QString::fromUtf8(script.left(dot)), &type, 0, 0, 0, 0);
- if (!type && scope != "Qt")
- return -1;
- const QMetaObject *mo = type ? type->metaObject() : StaticQtMetaObject::get();
- const char *key = script.constData() + dot+1;
- int i = mo->enumeratorCount();
- while (i--) {
- bool ok;
- int v = mo->enumerator(i).keyToValue(key, &ok);
- if (ok)
- return v;
- }
- }
- return -1;
-}
-
-const QMetaObject *QDeclarativeCompiler::resolveType(const QString& name) const
-{
- QDeclarativeType *qmltype = 0;
- if (!unit->imports().resolveType(name, &qmltype, 0, 0, 0, 0))
- return 0;
- if (!qmltype)
- return 0;
- return qmltype->metaObject();
-}
-
-// similar to logic of completeComponentBuild, but also sticks data
-// into primitives at the end
-int QDeclarativeCompiler::rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name)
-{
- QDeclarativeRewrite::RewriteBinding rewriteBinding;
- rewriteBinding.setName(QLatin1Char('$') + name.mid(name.lastIndexOf(QLatin1Char('.')) + 1));
-
- QString rewrite = rewriteBinding(value.asAST(), value.asScript(), 0);
-
- return output->indexForString(rewrite);
-}
-
-QString QDeclarativeCompiler::rewriteSignalHandler(const QDeclarativeScript::Variant& value, const QString &name)
-{
- QDeclarativeRewrite::RewriteSignalHandler rewriteSignalHandler;
- return rewriteSignalHandler(value.asAST(), value.asScript(), name);
-}
-
-// Ensures that the dynamic meta specification on obj is valid
-bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeScript::Object *obj)
-{
- bool seenDefaultProperty = false;
-
- // We use a coarse grain, 31 bit hash to check if there are duplicates.
- // Calculating the hash for the names is not a waste as we have to test
- // them against the illegalNames set anyway.
- QHashField propNames;
- QHashField methodNames;
-
- // Check properties
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
- const QDeclarativeScript::Object::DynamicProperty &prop = *p;
-
- if (prop.isDefaultProperty) {
- if (seenDefaultProperty)
- COMPILE_EXCEPTION(&prop, tr("Duplicate default property"));
- seenDefaultProperty = true;
- }
-
- if (propNames.testAndSet(prop.name.hash())) {
- for (Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p;
- p2 = obj->dynamicProperties.next(p2)) {
- if (p2->name == prop.name) {
- COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line,
- prop.nameLocation.column,
- tr("Duplicate property name"));
- }
- }
- }
-
- if (prop.name.at(0).isUpper()) {
- COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line,
- prop.nameLocation.column,
- tr("Property names cannot begin with an upper case letter"));
- }
-
- if (enginePrivate->v8engine()->illegalNames().contains(prop.name)) {
- COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line,
- prop.nameLocation.column,
- tr("Illegal property name"));
- }
- }
-
- for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
- const QDeclarativeScript::Object::DynamicSignal &currSig = *s;
-
- if (methodNames.testAndSet(currSig.name.hash())) {
- for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2 != s;
- s2 = obj->dynamicSignals.next(s2)) {
- if (s2->name == currSig.name)
- COMPILE_EXCEPTION(&currSig, tr("Duplicate signal name"));
- }
- }
-
- if (currSig.name.at(0).isUpper())
- COMPILE_EXCEPTION(&currSig, tr("Signal names cannot begin with an upper case letter"));
- if (enginePrivate->v8engine()->illegalNames().contains(currSig.name))
- COMPILE_EXCEPTION(&currSig, tr("Illegal signal name"));
- }
-
- for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
- const QDeclarativeScript::Object::DynamicSlot &currSlot = *s;
-
- if (methodNames.testAndSet(currSlot.name.hash())) {
- for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2;
- s2 = obj->dynamicSignals.next(s2)) {
- if (s2->name == currSlot.name)
- COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name"));
- }
- for (Object::DynamicSlot *s2 = obj->dynamicSlots.first(); s2 != s;
- s2 = obj->dynamicSlots.next(s2)) {
- if (s2->name == currSlot.name)
- COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name"));
- }
- }
-
- if (currSlot.name.at(0).isUpper())
- COMPILE_EXCEPTION(&currSlot, tr("Method names cannot begin with an upper case letter"));
- if (enginePrivate->v8engine()->illegalNames().contains(currSlot.name))
- COMPILE_EXCEPTION(&currSlot, tr("Illegal method name"));
- }
-
- return true;
-}
-
-bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeScript::Object *obj)
-{
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
- p = obj->dynamicProperties.next(p)) {
-
- if (!p->defaultValue || p->type == Object::DynamicProperty::Alias)
- continue;
-
- Property *property = 0;
- if (p->isDefaultProperty) {
- property = obj->getDefaultProperty();
- } else {
- property = obj->getProperty(p->name);
- if (!property->values.isEmpty())
- COMPILE_EXCEPTION(property, tr("Property value set multiple times"));
- }
-
- if (p->isReadOnly)
- property->isReadOnlyDeclaration = true;
-
- if (property->value)
- COMPILE_EXCEPTION(property, tr("Invalid property nesting"));
-
- property->values.append(p->defaultValue->values);
- }
- return true;
-}
-
-Q_GLOBAL_STATIC(QAtomicInt, classIndexCounter)
-
-bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeScript::Object *obj, DynamicMetaMode mode)
-{
- Q_ASSERT(obj);
- Q_ASSERT(obj->metatype);
-
- if (mode != ForceCreation &&
- obj->dynamicProperties.isEmpty() &&
- obj->dynamicSignals.isEmpty() &&
- obj->dynamicSlots.isEmpty())
- return true;
-
- bool resolveAlias = (mode == ResolveAliases);
-
- const Object::DynamicProperty *defaultProperty = 0;
- int aliasCount = 0;
- int varPropCount = 0;
- int totalPropCount = 0;
- int firstPropertyVarIndex = 0;
-
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
-
- if (p->type == Object::DynamicProperty::Alias)
- aliasCount++;
- if (p->type == Object::DynamicProperty::Var)
- varPropCount++;
-
- if (p->isDefaultProperty &&
- (resolveAlias || p->type != Object::DynamicProperty::Alias))
- defaultProperty = p;
-
- if (!resolveAlias) {
- // No point doing this for both the alias and non alias cases
- QDeclarativePropertyData *d = property(obj, p->name);
- if (d && d->isFinal())
- COMPILE_EXCEPTION(p, tr("Cannot override FINAL property"));
- }
- }
-
- bool buildData = resolveAlias || aliasCount == 0;
-
- QByteArray dynamicData;
- if (buildData) {
- typedef QDeclarativeVMEMetaData VMD;
-
- dynamicData = QByteArray(sizeof(QDeclarativeVMEMetaData) +
- (obj->dynamicProperties.count() - aliasCount) * sizeof(VMD::PropertyData) +
- obj->dynamicSlots.count() * sizeof(VMD::MethodData) +
- aliasCount * sizeof(VMD::AliasData), 0);
- }
-
- int uniqueClassId = classIndexCounter()->fetchAndAddRelaxed(1);
-
- QByteArray newClassName = obj->metatype->className();
- newClassName.append("_QML_");
- newClassName.append(QByteArray::number(uniqueClassId));
-
- if (compileState->root == obj && !compileState->nested) {
- QString path = output->url.path();
- int lastSlash = path.lastIndexOf(QLatin1Char('/'));
- if (lastSlash > -1) {
- QString nameBase = path.mid(lastSlash + 1, path.length()-lastSlash-5);
- if (!nameBase.isEmpty() && nameBase.at(0).isUpper())
- newClassName = nameBase.toUtf8() + "_QMLTYPE_" + QByteArray::number(uniqueClassId);
- }
- }
-
- QFastMetaBuilder builder;
- QFastMetaBuilder::StringRef classNameRef = builder.init(newClassName.length(),
- obj->dynamicProperties.count() - (resolveAlias?0:aliasCount),
- obj->dynamicSlots.count(),
- obj->dynamicSignals.count() + obj->dynamicProperties.count(),
- defaultProperty?1:0);
-
- struct TypeData {
- Object::DynamicProperty::Type dtype;
- int metaType;
- const char *cppType;
- } builtinTypes[] = {
- { Object::DynamicProperty::Var, QMetaType::QVariant, "QVariant" },
- { Object::DynamicProperty::Variant, QMetaType::QVariant, "QVariant" },
- { Object::DynamicProperty::Int, QMetaType::Int, "int" },
- { Object::DynamicProperty::Bool, QMetaType::Bool, "bool" },
- { Object::DynamicProperty::Real, QMetaType::Double, "double" },
- { Object::DynamicProperty::String, QMetaType::QString, "QString" },
- { Object::DynamicProperty::Url, QMetaType::QUrl, "QUrl" },
- { Object::DynamicProperty::Color, QMetaType::QColor, "QColor" },
- { Object::DynamicProperty::Time, QMetaType::QTime, "QTime" },
- { Object::DynamicProperty::Date, QMetaType::QDate, "QDate" },
- { Object::DynamicProperty::DateTime, QMetaType::QDateTime, "QDateTime" },
- };
- static const int builtinTypeCount = sizeof(builtinTypes) / sizeof(TypeData);
- QFastMetaBuilder::StringRef typeRefs[builtinTypeCount];
-
- // Reserve dynamic properties
- if (obj->dynamicProperties.count()) {
- typedef QDeclarativeVMEMetaData VMD;
-
- int effectivePropertyIndex = 0;
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
-
- // Reserve space for name
- p->nameRef = builder.newString(p->name.utf8length());
-
- int propertyType = 0;
- bool readonly = false;
- QFastMetaBuilder::StringRef typeRef;
-
- if (p->type == Object::DynamicProperty::Alias) {
- continue;
- } else if (p->type < builtinTypeCount) {
- Q_ASSERT(builtinTypes[p->type].dtype == p->type);
- propertyType = builtinTypes[p->type].metaType;
- if (typeRefs[p->type].isEmpty())
- typeRefs[p->type] = builder.newString(strlen(builtinTypes[p->type].cppType));
- typeRef = typeRefs[p->type];
-
- } else {
- Q_ASSERT(p->type == Object::DynamicProperty::CustomList ||
- p->type == Object::DynamicProperty::Custom);
-
- // XXX don't double resolve this in the case of an alias run
-
- QByteArray customTypeName;
- QDeclarativeType *qmltype = 0;
- QString url;
- if (!unit->imports().resolveType(p->customType.toString(), &qmltype, &url, 0, 0, 0))
- COMPILE_EXCEPTION(p, tr("Invalid property type"));
-
- if (!qmltype) {
- QDeclarativeTypeData *tdata = enginePrivate->typeLoader.get(QUrl(url));
- Q_ASSERT(tdata);
- Q_ASSERT(tdata->isComplete());
-
- QDeclarativeCompiledData *data = tdata->compiledData();
- customTypeName = data->root->className();
- data->release();
- tdata->release();
- } else {
- customTypeName = qmltype->typeName();
- }
-
- if (p->type == Object::DynamicProperty::Custom) {
- customTypeName += '*';
- propertyType = QMetaType::QObjectStar;
- } else {
- readonly = true;
- customTypeName = QByteArray("QDeclarativeListProperty<") + customTypeName + QByteArray(">");
- propertyType = qMetaTypeId<QDeclarativeListProperty<QObject> >();
- }
-
- p->resolvedCustomTypeName = pool->NewByteArray(customTypeName);
- p->typeRef = builder.newString(customTypeName.length());
- typeRef = p->typeRef;
- }
-
- if (p->type == Object::DynamicProperty::Var)
- continue;
-
- if (p->isReadOnly)
- readonly = true;
-
- if (buildData) {
- VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data();
- vmd->propertyCount++;
- (vmd->propertyData() + effectivePropertyIndex)->propertyType = propertyType;
- }
-
- if (p->type < builtinTypeCount)
- builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef, (QMetaType::Type)propertyType,
- readonly?QFastMetaBuilder::None:QFastMetaBuilder::Writable,
- effectivePropertyIndex);
- else
- builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef,
- readonly?QFastMetaBuilder::None:QFastMetaBuilder::Writable,
- effectivePropertyIndex);
-
- p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()"));
- builder.setSignal(effectivePropertyIndex, p->changedSignatureRef);
-
- effectivePropertyIndex++;
- }
-
- if (varPropCount) {
- VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data();
- if (buildData)
- vmd->varPropertyCount = varPropCount;
- firstPropertyVarIndex = effectivePropertyIndex;
- totalPropCount = varPropCount + effectivePropertyIndex;
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
- if (p->type == Object::DynamicProperty::Var) {
- QFastMetaBuilder::StringRef typeRef = typeRefs[p->type];
- if (buildData) {
- vmd->propertyCount++;
- (vmd->propertyData() + effectivePropertyIndex)->propertyType = QMetaType::QVariant;
- }
-
- builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef,
- QMetaType::QVariant,
- p->isReadOnly?QFastMetaBuilder::None:QFastMetaBuilder::Writable,
- effectivePropertyIndex);
-
- p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()"));
- builder.setSignal(effectivePropertyIndex, p->changedSignatureRef);
-
- effectivePropertyIndex++;
- }
- }
- }
-
- if (aliasCount) {
- int aliasIndex = 0;
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
- if (p->type == Object::DynamicProperty::Alias) {
- if (resolveAlias) {
- Q_ASSERT(buildData);
- ((QDeclarativeVMEMetaData *)dynamicData.data())->aliasCount++;
- COMPILE_CHECK(compileAlias(builder, dynamicData, obj, effectivePropertyIndex,
- aliasIndex, *p));
- }
- // Even if we aren't resolving the alias, we need a fake signal so that the
- // metaobject remains consistent across the resolve and non-resolve alias runs
- p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()"));
- builder.setSignal(effectivePropertyIndex, p->changedSignatureRef);
- effectivePropertyIndex++;
- aliasIndex++;
- }
- }
- }
- }
-
- // Reserve default property
- QFastMetaBuilder::StringRef defPropRef;
- if (defaultProperty) {
- defPropRef = builder.newString(strlen("DefaultProperty"));
- builder.setClassInfo(0, defPropRef, defaultProperty->nameRef);
- }
-
- // Reserve dynamic signals
- int signalIndex = 0;
- for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
-
- int paramCount = s->parameterNames.count();
-
- int signatureSize = s->name.utf8length() + 2 /* paren */;
- int namesSize = 0;
- if (paramCount) signatureSize += s->parameterTypesLength() + (paramCount - 1) /* commas */;
- if (paramCount) namesSize += s->parameterNamesLength() + (paramCount - 1) /* commas */;
-
- s->signatureRef = builder.newString(signatureSize);
- if (namesSize) s->parameterNamesRef = builder.newString(namesSize);
-
- if (buildData)
- ((QDeclarativeVMEMetaData *)dynamicData.data())->signalCount++;
-
- builder.setSignal(signalIndex + obj->dynamicProperties.count(), s->signatureRef, s->parameterNamesRef);
- ++signalIndex;
- }
-
- // Reserve dynamic slots
- if (obj->dynamicSlots.count()) {
-
- // Allocate QVariant string
- if (typeRefs[0].isEmpty())
- typeRefs[0] = builder.newString(strlen(builtinTypes[0].cppType));
-
- typedef QDeclarativeVMEMetaData VMD;
-
- int methodIndex = 0;
- for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
- int paramCount = s->parameterNames.count();
-
- int signatureSize = s->name.utf8length() + 2 /* paren */;
- int namesSize = 0;
- if (paramCount) signatureSize += (paramCount * strlen("QVariant") + (paramCount - 1));
- if (paramCount) namesSize += s->parameterNamesLength() + (paramCount - 1 /* commas */);
-
- s->signatureRef = builder.newString(signatureSize);
- if (namesSize) s->parameterNamesRef = builder.newString(namesSize);
-
- builder.setMethod(methodIndex, s->signatureRef, s->parameterNamesRef, typeRefs[0]);
-
- if (buildData) {
- QString funcScript;
- funcScript.reserve(strlen("(function ") + s->name.length() + 1 /* lparen */ +
- namesSize + 1 /* rparen */ + s->body.length() + 1 /* rparen */);
- funcScript = QLatin1String("(function ") + s->name.toString() + QLatin1Char('(');
- for (int jj = 0; jj < paramCount; ++jj) {
- if (jj) funcScript.append(QLatin1Char(','));
- funcScript.append(QLatin1String(s->parameterNames.at(jj)));
- }
- funcScript += QLatin1Char(')') + s->body + QLatin1Char(')');
-
- QByteArray utf8 = funcScript.toUtf8();
- VMD::MethodData methodData = { s->parameterNames.count(), 0,
- utf8.length(),
- s->location.start.line };
-
- VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data();
- vmd->methodCount++;
-
- VMD::MethodData &md = *(vmd->methodData() + methodIndex);
- md = methodData;
- md.bodyOffset = dynamicData.size();
-
- dynamicData.append((const char *)utf8.constData(), utf8.length());
- }
-
-
- methodIndex++;
- }
- }
-
- // Now allocate used builtin types
- for (int ii = 0; ii < builtinTypeCount; ++ii) {
- if (!typeRefs[ii].isEmpty())
- typeRefs[ii].load(builtinTypes[ii].cppType);
- }
-
- // Now allocate properties
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
-
- char *d = p->changedSignatureRef.data();
- p->name.writeUtf8(d);
- strcpy(d + p->name.utf8length(), "Changed()");
-
- if (p->type == Object::DynamicProperty::Alias && !resolveAlias)
- continue;
-
- p->nameRef.load(p->name);
-
- if (p->type >= builtinTypeCount) {
- Q_ASSERT(p->resolvedCustomTypeName);
- p->typeRef.load(*p->resolvedCustomTypeName);
- }
- }
-
- // Allocate default property if necessary
- if (defaultProperty)
- strcpy(defPropRef.data(), "DefaultProperty");
-
- // Now allocate signals
- for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
-
- char *d = s->signatureRef.data();
- char *d2 = s->parameterNamesRef.isEmpty()?0:s->parameterNamesRef.data();
- s->name.writeUtf8(d); d += s->name.utf8length();
- *d++ = '(';
-
- for (int jj = 0; jj < s->parameterNames.count(); ++jj) {
- if (jj != 0) { *d++ = ','; *d2++ = ','; }
- strcpy(d, s->parameterTypes.at(jj).constData());
- d += s->parameterTypes.at(jj).length();
- s->parameterNames.at(jj).writeUtf8(d2);
- d2 += s->parameterNames.at(jj).utf8length();
- }
- *d++ = ')';
- *d = 0;
- if (d2) *d2 = 0;
- }
-
- // Now allocate methods
- for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
- char *d = s->signatureRef.data();
- char *d2 = s->parameterNamesRef.isEmpty()?0:s->parameterNamesRef.data();
- s->name.writeUtf8(d); d += s->name.utf8length();
- *d++ = '(';
- for (int jj = 0; jj < s->parameterNames.count(); ++jj) {
- if (jj != 0) { *d++ = ','; *d2++ = ','; }
- strcpy(d, "QVariant");
- d += strlen("QVariant");
- strcpy(d2, s->parameterNames.at(jj).constData());
- d2 += s->parameterNames.at(jj).length();
- }
- *d++ = ')';
- *d = 0;
- if (d2) *d2 = 0;
- }
-
- // Now allocate class name
- classNameRef.load(newClassName);
-
- obj->metadata = builder.toData();
- builder.fromData(&obj->extObject, obj->metatype, obj->metadata);
-
- if (mode == IgnoreAliases && aliasCount)
- compileState->aliasingObjects.append(obj);
-
- obj->synthdata = dynamicData;
-
- if (obj->synthCache) {
- obj->synthCache->release();
- obj->synthCache = 0;
- }
-
- if (obj->type != -1) {
- QDeclarativePropertyCache *superCache = output->types[obj->type].createPropertyCache(engine);
- QDeclarativePropertyCache *cache =
- superCache->copyAndAppend(engine, &obj->extObject,
- QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::IsVMEFunction,
- QDeclarativePropertyData::IsVMESignal);
-
- // now we modify the flags appropriately for var properties.
- int propertyOffset = obj->extObject.propertyOffset();
- QDeclarativePropertyData *currPropData = 0;
- for (int pvi = firstPropertyVarIndex; pvi < totalPropCount; ++pvi) {
- currPropData = cache->property(pvi + propertyOffset);
- currPropData->setFlags(currPropData->getFlags() | QDeclarativePropertyData::IsVMEProperty);
- }
-
- obj->synthCache = cache;
- }
-
- return true;
-}
-
-bool QDeclarativeCompiler::checkValidId(QDeclarativeScript::Value *v, const QString &val)
-{
- if (val.isEmpty())
- COMPILE_EXCEPTION(v, tr( "Invalid empty ID"));
-
- QChar ch = val.at(0);
- if (ch.isLetter() && !ch.isLower())
- COMPILE_EXCEPTION(v, tr( "IDs cannot start with an uppercase letter"));
-
- QChar u(QLatin1Char('_'));
- if (!ch.isLetter() && ch != u)
- COMPILE_EXCEPTION(v, tr( "IDs must start with a letter or underscore"));
-
- for (int ii = 1; ii < val.count(); ++ii) {
- ch = val.at(ii);
- if (!ch.isLetterOrNumber() && ch != u)
- COMPILE_EXCEPTION(v, tr( "IDs must contain only letters, numbers, and underscores"));
- }
-
- if (enginePrivate->v8engine()->illegalNames().contains(val))
- COMPILE_EXCEPTION(v, tr( "ID illegally masks global JavaScript property"));
-
- return true;
-}
-
-#include <private/qdeclarativejsparser_p.h>
-
-static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
-{
- if (node->kind == QDeclarativeJS::AST::Node::Kind_IdentifierExpression) {
- QString name =
- static_cast<QDeclarativeJS::AST::IdentifierExpression *>(node)->name.toString();
- return QStringList() << name;
- } else if (node->kind == QDeclarativeJS::AST::Node::Kind_FieldMemberExpression) {
- QDeclarativeJS::AST::FieldMemberExpression *expr = static_cast<QDeclarativeJS::AST::FieldMemberExpression *>(node);
-
- QStringList rv = astNodeToStringList(expr->base);
- if (rv.isEmpty())
- return rv;
- rv.append(expr->name.toString());
- return rv;
- }
- return QStringList();
-}
-
-bool QDeclarativeCompiler::compileAlias(QFastMetaBuilder &builder,
- QByteArray &data,
- QDeclarativeScript::Object *obj,
- int propIndex, int aliasIndex,
- Object::DynamicProperty &prop)
-{
- if (!prop.defaultValue)
- COMPILE_EXCEPTION(obj, tr("No property alias location"));
-
- if (!prop.defaultValue->values.isOne() ||
- prop.defaultValue->values.first()->object ||
- !prop.defaultValue->values.first()->value.isScript())
- COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
-
- QDeclarativeJS::AST::Node *node = prop.defaultValue->values.first()->value.asAST();
- if (!node)
- COMPILE_EXCEPTION(obj, tr("No property alias location")); // ### Can this happen?
-
- QStringList alias = astNodeToStringList(node);
-
- if (alias.count() < 1 || alias.count() > 3)
- COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>"));
-
- QDeclarativeScript::Object *idObject = compileState->ids.value(alias.at(0));
- if (!idObject)
- COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0)));
-
- QByteArray typeName;
-
- int propIdx = -1;
- int flags = 0;
- int type = 0;
- bool writable = false;
- bool resettable = false;
- if (alias.count() == 2 || alias.count() == 3) {
- propIdx = indexOfProperty(idObject, alias.at(1));
-
- if (-1 == propIdx) {
- COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
- } else if (propIdx > 0xFFFF) {
- COMPILE_EXCEPTION(prop.defaultValue, tr("Alias property exceeds alias bounds"));
- }
-
- QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx);
- if (!aliasProperty.isScriptable())
- COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
-
- writable = aliasProperty.isWritable() && !prop.isReadOnly;
- resettable = aliasProperty.isResettable() && !prop.isReadOnly;
-
- if (aliasProperty.type() < QVariant::UserType
- || uint(aliasProperty.type()) == QMetaType::QVariant)
- type = aliasProperty.type();
-
- if (alias.count() == 3) {
- QDeclarativeValueType *valueType = enginePrivate->valueTypes[aliasProperty.type()];
- if (!valueType)
- COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
-
- propIdx |= ((unsigned int)aliasProperty.type()) << 24;
-
- int valueTypeIndex = valueType->metaObject()->indexOfProperty(alias.at(2).toUtf8().constData());
- if (valueTypeIndex == -1)
- COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
- Q_ASSERT(valueTypeIndex <= 0xFF);
-
- aliasProperty = valueType->metaObject()->property(valueTypeIndex);
- propIdx |= (valueTypeIndex << 16);
-
- // update the property type
- type = aliasProperty.type();
- if (type >= (int)QVariant::UserType)
- type = 0;
- }
-
- if (aliasProperty.isEnumType())
- typeName = "int"; // Avoid introducing a dependency on the aliased metaobject
- else
- typeName = aliasProperty.typeName();
- } else {
- Q_ASSERT(idObject->type != -1); // How else did it get an id?
-
- const QDeclarativeCompiledData::TypeReference &ref = output->types.at(idObject->type);
- if (ref.type)
- typeName = ref.type->typeName();
- else
- typeName = ref.component->root->className();
-
- typeName += '*';
- }
-
- if (typeName.endsWith('*'))
- flags |= QML_ALIAS_FLAG_PTR;
-
- QDeclarativeVMEMetaData::AliasData aliasData = { idObject->idIndex, propIdx, flags };
-
- typedef QDeclarativeVMEMetaData VMD;
- VMD *vmd = (QDeclarativeVMEMetaData *)data.data();
- *(vmd->aliasData() + aliasIndex) = aliasData;
-
- prop.nameRef = builder.newString(prop.name.utf8length());
- prop.resolvedCustomTypeName = pool->NewByteArray(typeName);
- prop.typeRef = builder.newString(typeName.length());
-
- int propertyFlags = 0;
- if (writable)
- propertyFlags |= QFastMetaBuilder::Writable;
- if (resettable)
- propertyFlags |= QFastMetaBuilder::Resettable;
-
- builder.setProperty(propIndex, prop.nameRef, prop.typeRef, (QMetaType::Type)type,
- (QFastMetaBuilder::PropertyFlag)propertyFlags,
- propIndex);
-
- return true;
-}
-
-bool QDeclarativeCompiler::buildBinding(QDeclarativeScript::Value *value,
- QDeclarativeScript::Property *prop,
- const BindingContext &ctxt)
-{
- Q_ASSERT(prop->index != -1);
- Q_ASSERT(prop->parent);
- Q_ASSERT(prop->parent->metaObject());
-
- if (!prop->core.isWritable() && !prop->core.isQList() && !prop->isReadOnlyDeclaration)
- COMPILE_EXCEPTION(prop, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
-
- JSBindingReference *reference = pool->New<JSBindingReference>();
- reference->expression = value->value;
- reference->property = prop;
- reference->value = value;
- reference->bindingContext = ctxt;
- addBindingReference(reference);
-
- return true;
-}
-
-bool QDeclarativeCompiler::buildLiteralBinding(QDeclarativeScript::Value *v,
- QDeclarativeScript::Property *prop,
- const QDeclarativeCompilerTypes::BindingContext &)
-{
- Q_ASSERT(v->value.isScript());
-
- if (!prop->core.isWritable())
- return false;
-
- AST::Node *binding = v->value.asAST();
-
- if (prop->type == QVariant::String) {
- if (AST::CallExpression *e = AST::cast<AST::CallExpression *>(binding)) {
- if (AST::IdentifierExpression *i = AST::cast<AST::IdentifierExpression *>(e->base)) {
- if (i->name == qsTrId_string) {
- AST::ArgumentList *arg1 = e->arguments?e->arguments:0;
- AST::ArgumentList *arg2 = arg1?arg1->next:0;
-
- if (arg1 && arg1->expression->kind == AST::Node::Kind_StringLiteral &&
- (!arg2 || arg2->expression->kind == AST::Node::Kind_NumericLiteral) &&
- (!arg2 || !arg2->next)) {
-
- QStringRef text;
- int n = -1;
-
- text = AST::cast<AST::StringLiteral *>(arg1->expression)->value;
- if (arg2) n = (int)AST::cast<AST::NumericLiteral *>(arg2->expression)->value;
-
- TrBindingReference *reference = pool->New<TrBindingReference>();
- reference->dataType = BindingReference::TrId;
- reference->text = text;
- reference->n = n;
- v->bindingReference = reference;
- return true;
- }
-
- } else if (i->name == qsTr_string) {
-
- AST::ArgumentList *arg1 = e->arguments?e->arguments:0;
- AST::ArgumentList *arg2 = arg1?arg1->next:0;
- AST::ArgumentList *arg3 = arg2?arg2->next:0;
-
- if (arg1 && arg1->expression->kind == AST::Node::Kind_StringLiteral &&
- (!arg2 || arg2->expression->kind == AST::Node::Kind_StringLiteral) &&
- (!arg3 || arg3->expression->kind == AST::Node::Kind_NumericLiteral) &&
- (!arg3 || !arg3->next)) {
-
- QStringRef text;
- QStringRef comment;
- int n = -1;
-
- text = AST::cast<AST::StringLiteral *>(arg1->expression)->value;
- if (arg2) comment = AST::cast<AST::StringLiteral *>(arg2->expression)->value;
- if (arg3) n = (int)AST::cast<AST::NumericLiteral *>(arg3->expression)->value;
-
- TrBindingReference *reference = pool->New<TrBindingReference>();
- reference->dataType = BindingReference::Tr;
- reference->text = text;
- reference->comment = comment;
- reference->n = n;
- v->bindingReference = reference;
- return true;
- }
-
- }
- }
- }
-
- }
-
- return false;
-}
-
-void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *binding,
- QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Property *valueTypeProperty)
-{
- Q_UNUSED(obj);
- Q_ASSERT(binding->bindingReference);
-
- const BindingReference &ref = *binding->bindingReference;
- if (ref.dataType == BindingReference::TrId) {
- const TrBindingReference &tr = static_cast<const TrBindingReference &>(ref);
-
- Instruction::StoreTrIdString store;
- store.propertyIndex = prop->core.coreIndex;
- store.text = output->indexForByteArray(tr.text.toUtf8());
- store.n = tr.n;
- output->addInstruction(store);
- } else if (ref.dataType == BindingReference::Tr) {
- const TrBindingReference &tr = static_cast<const TrBindingReference &>(ref);
-
- Instruction::StoreTrString store;
- store.propertyIndex = prop->core.coreIndex;
- store.context = translationContextIndex();
- store.text = output->indexForByteArray(tr.text.toUtf8());
- store.comment = output->indexForByteArray(tr.comment.toUtf8());
- store.n = tr.n;
- output->addInstruction(store);
- } else if (ref.dataType == BindingReference::V4) {
- const JSBindingReference &js = static_cast<const JSBindingReference &>(ref);
-
- Instruction::StoreV4Binding store;
- store.value = js.compiledIndex;
- store.context = js.bindingContext.stack;
- store.owner = js.bindingContext.owner;
- if (valueTypeProperty) {
- store.property = (valueTypeProperty->index & 0xFFFF) |
- ((valueTypeProperty->type & 0xFF)) << 16 |
- ((prop->index & 0xFF) << 24);
- store.isRoot = (compileState->root == valueTypeProperty->parent);
- } else {
- store.property = prop->index;
- store.isRoot = (compileState->root == obj);
- }
- store.line = binding->location.start.line;
- store.column = binding->location.start.column;
- output->addInstruction(store);
- } else if (ref.dataType == BindingReference::V8) {
- const JSBindingReference &js = static_cast<const JSBindingReference &>(ref);
-
- Instruction::StoreV8Binding store;
- store.value = js.compiledIndex;
- store.context = js.bindingContext.stack;
- store.owner = js.bindingContext.owner;
- if (valueTypeProperty) {
- store.isRoot = (compileState->root == valueTypeProperty->parent);
- } else {
- store.isRoot = (compileState->root == obj);
- }
- store.line = binding->location.start.line;
- store.column = binding->location.start.column;
-
- Q_ASSERT(js.bindingContext.owner == 0 ||
- (js.bindingContext.owner != 0 && valueTypeProperty));
- if (js.bindingContext.owner) {
- store.property = genValueTypeData(prop, valueTypeProperty);
- } else {
- store.property = prop->core;
- }
-
- output->addInstruction(store);
- } else if (ref.dataType == BindingReference::QtScript) {
- const JSBindingReference &js = static_cast<const JSBindingReference &>(ref);
-
- QDeclarativeInstruction store;
- store.assignBinding.value = output->indexForString(js.rewrittenExpression);
- store.assignBinding.context = js.bindingContext.stack;
- store.assignBinding.owner = js.bindingContext.owner;
- store.assignBinding.line = binding->location.start.line;
- store.assignBinding.column = binding->location.start.column;
-
- if (valueTypeProperty) {
- store.assignBinding.isRoot = (compileState->root == valueTypeProperty->parent);
- } else {
- store.assignBinding.isRoot = (compileState->root == obj);
- }
-
- Q_ASSERT(js.bindingContext.owner == 0 ||
- (js.bindingContext.owner != 0 && valueTypeProperty));
- if (js.bindingContext.owner) {
- store.assignBinding.property = genValueTypeData(prop, valueTypeProperty);
- } else {
- store.assignBinding.property = prop->core;
- }
- output->addInstructionHelper(
- !prop->isAlias ? QDeclarativeInstruction::StoreBinding
- : QDeclarativeInstruction::StoreBindingOnAlias
- , store);
- } else {
- Q_ASSERT(!"Unhandled BindingReference::DataType type");
- }
-}
-
-int QDeclarativeCompiler::genContextCache()
-{
- if (compileState->ids.count() == 0)
- return -1;
-
- QDeclarativeIntegerCache *cache = new QDeclarativeIntegerCache();
- cache->reserve(compileState->ids.count());
- for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o))
- cache->add(o->id, o->idIndex);
-
- output->contextCaches.append(cache);
- return output->contextCaches.count() - 1;
-}
-
-QDeclarativePropertyData
-QDeclarativeCompiler::genValueTypeData(QDeclarativeScript::Property *valueTypeProp,
- QDeclarativeScript::Property *prop)
-{
- typedef QDeclarativePropertyPrivate QDPP;
- return QDPP::saveValueType(prop->parent->metaObject(), prop->index,
- enginePrivate->valueTypes[prop->type]->metaObject(),
- valueTypeProp->index, engine);
-}
-
-bool QDeclarativeCompiler::completeComponentBuild()
-{
- if (componentStats)
- componentStats->componentStat.ids = compileState->ids.count();
-
- for (Object *aliasObject = compileState->aliasingObjects.first(); aliasObject;
- aliasObject = compileState->aliasingObjects.next(aliasObject))
- COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
-
- QV4Compiler::Expression expr(unit->imports());
- expr.component = compileState->root;
- expr.ids = &compileState->ids;
- expr.importCache = output->importCache;
-
- QV4Compiler bindingCompiler;
-
- QList<JSBindingReference*> sharedBindings;
-
- for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) {
-
- JSBindingReference &binding = *b;
-
- // ### We don't currently optimize for bindings on alias's - because
- // of the solution to QTBUG-13719
- if (!binding.property->isAlias) {
- expr.context = binding.bindingContext.object;
- expr.property = binding.property;
- expr.expression = binding.expression;
-
- int index = bindingCompiler.compile(expr, enginePrivate);
- if (index != -1) {
- binding.dataType = BindingReference::V4;
- binding.compiledIndex = index;
- if (componentStats)
- componentStats->componentStat.optimizedBindings.append(b->value->location);
- continue;
- }
- }
-
- // Pre-rewrite the expression
- QString expression = binding.expression.asScript();
-
- QDeclarativeRewrite::RewriteBinding rewriteBinding;
- rewriteBinding.setName(QLatin1Char('$')+binding.property->name().toString());
- bool isSharable = false;
- binding.rewrittenExpression = rewriteBinding(binding.expression.asAST(), expression, &isSharable);
-
- if (isSharable && !binding.property->isAlias /* See above re alias */ &&
- binding.property->type != qMetaTypeId<QDeclarativeBinding*>()) {
- binding.dataType = BindingReference::V8;
- sharedBindings.append(b);
-
- if (componentStats)
- componentStats->componentStat.sharedBindings.append(b->value->location);
- } else {
- binding.dataType = BindingReference::QtScript;
-
- if (componentStats)
- componentStats->componentStat.scriptBindings.append(b->value->location);
- }
- }
-
- if (!sharedBindings.isEmpty()) {
- struct Sort {
- static bool lt(const JSBindingReference *lhs, const JSBindingReference *rhs)
- {
- return lhs->value->location.start.line < rhs->value->location.start.line;
- }
- };
-
- qSort(sharedBindings.begin(), sharedBindings.end(), Sort::lt);
-
- int startLineNumber = sharedBindings.at(0)->value->location.start.line;
- int lineNumber = startLineNumber;
-
- QByteArray functionArray("[", 1);
- for (int ii = 0; ii < sharedBindings.count(); ++ii) {
-
- JSBindingReference *reference = sharedBindings.at(ii);
- QDeclarativeScript::Value *value = reference->value;
- const QString &expression = reference->rewrittenExpression;
-
- if (ii != 0) functionArray.append(",", 1);
-
- while (lineNumber < value->location.start.line) {
- lineNumber++;
- functionArray.append("\n", 1);
- }
-
- functionArray += expression.toUtf8();
- lineNumber += expression.count(QLatin1Char('\n'));
- reference->compiledIndex = ii;
- }
- functionArray.append("]", 1);
-
- compileState->v8BindingProgram = functionArray;
- compileState->v8BindingProgramLine = startLineNumber;
- }
-
- if (bindingCompiler.isValid())
- compileState->compiledBindingData = bindingCompiler.program();
-
- // Check pop()'s matched push()'s
- Q_ASSERT(compileState->objectDepth.depth() == 0);
- Q_ASSERT(compileState->listDepth.depth() == 0);
-
- saveComponentState();
-
- return true;
-}
-
-void QDeclarativeCompiler::dumpStats()
-{
- Q_ASSERT(componentStats);
- qWarning().nospace() << "QML Document: " << output->url.toString();
- for (int ii = 0; ii < componentStats->savedComponentStats.count(); ++ii) {
- const ComponentStat &stat = componentStats->savedComponentStats.at(ii);
- qWarning().nospace() << " Component Line " << stat.lineNumber;
- qWarning().nospace() << " Total Objects: " << stat.objects;
- qWarning().nospace() << " IDs Used: " << stat.ids;
- qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings.count();
-
- {
- QByteArray output;
- for (int ii = 0; ii < stat.optimizedBindings.count(); ++ii) {
- if (0 == (ii % 10)) {
- if (ii) output.append("\n");
- output.append(" ");
- }
-
- output.append("(");
- output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.line));
- output.append(":");
- output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.column));
- output.append(") ");
- }
- if (!output.isEmpty())
- qWarning().nospace() << output.constData();
- }
-
- qWarning().nospace() << " Shared Bindings: " << stat.sharedBindings.count();
- {
- QByteArray output;
- for (int ii = 0; ii < stat.sharedBindings.count(); ++ii) {
- if (0 == (ii % 10)) {
- if (ii) output.append("\n");
- output.append(" ");
- }
-
- output.append("(");
- output.append(QByteArray::number(stat.sharedBindings.at(ii).start.line));
- output.append(":");
- output.append(QByteArray::number(stat.sharedBindings.at(ii).start.column));
- output.append(") ");
- }
- if (!output.isEmpty())
- qWarning().nospace() << output.constData();
- }
-
- qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings.count();
- {
- QByteArray output;
- for (int ii = 0; ii < stat.scriptBindings.count(); ++ii) {
- if (0 == (ii % 10)) {
- if (ii) output.append("\n");
- output.append(" ");
- }
-
- output.append("(");
- output.append(QByteArray::number(stat.scriptBindings.at(ii).start.line));
- output.append(":");
- output.append(QByteArray::number(stat.scriptBindings.at(ii).start.column));
- output.append(") ");
- }
- if (!output.isEmpty())
- qWarning().nospace() << output.constData();
- }
- }
-}
-
-/*!
- Returns true if from can be assigned to a (QObject) property of type
- to.
-*/
-bool QDeclarativeCompiler::canCoerce(int to, QDeclarativeScript::Object *from)
-{
- const QMetaObject *toMo = enginePrivate->rawMetaObjectForType(to);
- const QMetaObject *fromMo = from->metaObject();
-
- while (fromMo) {
- if (QDeclarativePropertyPrivate::equal(fromMo, toMo))
- return true;
- fromMo = fromMo->superClass();
- }
- return false;
-}
-
-/*!
- Returns the element name, as written in the QML file, for o.
-*/
-QString QDeclarativeCompiler::elementName(QDeclarativeScript::Object *o)
-{
- Q_ASSERT(o);
- if (o->type != -1) {
- return output->types.at(o->type).className;
- } else {
- return QString();
- }
-}
-
-QDeclarativeType *QDeclarativeCompiler::toQmlType(QDeclarativeScript::Object *from)
-{
- // ### Optimize
- const QMetaObject *mo = from->metatype;
- QDeclarativeType *type = 0;
- while (!type && mo) {
- type = QDeclarativeMetaType::qmlType(mo);
- mo = mo->superClass();
- }
- return type;
-}
-
-QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeScript::Object *obj)
-{
- const QMetaObject *mo = obj->metatype;
-
- int idx = mo->indexOfClassInfo("DeferredPropertyNames");
- if (idx == -1)
- return QStringList();
-
- QMetaClassInfo classInfo = mo->classInfo(idx);
- QStringList rv = QString::fromUtf8(classInfo.value()).split(QLatin1Char(','));
- return rv;
-}
-
-QDeclarativePropertyData *
-QDeclarativeCompiler::property(QDeclarativeScript::Object *object, int index)
-{
- QDeclarativePropertyCache *cache = 0;
-
- if (object->synthCache)
- cache = object->synthCache;
- else if (object->type != -1)
- cache = output->types[object->type].createPropertyCache(engine);
- else
- cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject());
-
- return cache->property(index);
-}
-
-QDeclarativePropertyData *
-QDeclarativeCompiler::property(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision)
-{
- if (notInRevision) *notInRevision = false;
-
- QDeclarativePropertyCache *cache = 0;
-
- if (object->synthCache)
- cache = object->synthCache;
- else if (object->type != -1)
- cache = output->types[object->type].createPropertyCache(engine);
- else
- cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject());
-
- QDeclarativePropertyData *d = cache->property(name);
-
- // Find the first property
- while (d && d->isFunction())
- d = cache->overrideData(d);
-
- if (d && !cache->isAllowedInRevision(d)) {
- if (notInRevision) *notInRevision = true;
- return 0;
- } else {
- return d;
- }
-}
-
-// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName
-QDeclarativePropertyData *
-QDeclarativeCompiler::signal(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision)
-{
- if (notInRevision) *notInRevision = false;
-
- QDeclarativePropertyCache *cache = 0;
-
- if (object->synthCache)
- cache = object->synthCache;
- else if (object->type != -1)
- cache = output->types[object->type].createPropertyCache(engine);
- else
- cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject());
-
-
- QDeclarativePropertyData *d = cache->property(name);
- if (notInRevision) *notInRevision = false;
-
- while (d && !(d->isFunction()))
- d = cache->overrideData(d);
-
- if (d && !cache->isAllowedInRevision(d)) {
- if (notInRevision) *notInRevision = true;
- return 0;
- } else if (d) {
- return d;
- }
-
- if (name.endsWith(Changed_string)) {
- QHashedStringRef propName = name.mid(0, name.length() - Changed_string.length());
-
- d = property(object, propName, notInRevision);
- if (d)
- return cache->method(d->notifyIndex);
- }
-
- return 0;
-}
-
-// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName
-int QDeclarativeCompiler::indexOfSignal(QDeclarativeScript::Object *object, const QString &name,
- bool *notInRevision)
-{
- QDeclarativePropertyData *d = signal(object, QStringRef(&name), notInRevision);
- return d?d->coreIndex:-1;
-}
-
-int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QString &name,
- bool *notInRevision)
-{
- return indexOfProperty(object, QStringRef(&name), notInRevision);
-}
-
-int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QHashedStringRef &name,
- bool *notInRevision)
-{
- QDeclarativePropertyData *d = property(object, name, notInRevision);
- return d?d->coreIndex:-1;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
deleted file mode 100644
index 3ef4668b79..0000000000
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ /dev/null
@@ -1,467 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECOMPILER_P_H
-#define QDECLARATIVECOMPILER_P_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 "qdeclarative.h"
-#include "qdeclarativeerror.h"
-#include <private/qv8_p.h>
-#include "qdeclarativeinstruction_p.h"
-#include "qdeclarativescript_p.h"
-#include "qdeclarativeengine_p.h"
-#include <private/qbitfield_p.h>
-#include "qdeclarativepropertycache_p.h"
-#include "qdeclarativeintegercache_p.h"
-#include "qdeclarativetypenamecache_p.h"
-#include "qdeclarativetypeloader_p.h"
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qset.h>
-#include <QtCore/QCoreApplication>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-class QDeclarativeComponent;
-class QDeclarativeContext;
-class QDeclarativeContextData;
-
-class Q_AUTOTEST_EXPORT QDeclarativeCompiledData : public QDeclarativeRefCount,
- public QDeclarativeCleanup
-{
-public:
- QDeclarativeCompiledData(QDeclarativeEngine *engine);
- virtual ~QDeclarativeCompiledData();
-
- QDeclarativeEngine *engine;
-
- QString name;
- QUrl url;
- QDeclarativeTypeNameCache *importCache;
-
- struct TypeReference
- {
- TypeReference()
- : type(0), typePropertyCache(0), component(0) {}
-
- QString className;
- QDeclarativeType *type;
- QDeclarativePropertyCache *typePropertyCache;
- QDeclarativeCompiledData *component;
-
- const QMetaObject *metaObject() const;
- QDeclarativePropertyCache *propertyCache() const;
- QDeclarativePropertyCache *createPropertyCache(QDeclarativeEngine *);
- };
- QList<TypeReference> types;
-
- struct V8Program {
- V8Program(const QByteArray &p, QDeclarativeCompiledData *c)
- : program(p), cdata(c) {}
-
- QByteArray program;
- v8::Persistent<v8::Array> bindings;
- QDeclarativeCompiledData *cdata;
- };
-
- QList<V8Program> programs;
-
- const QMetaObject *root;
- QAbstractDynamicMetaObject rootData;
- QDeclarativePropertyCache *rootPropertyCache;
- QList<QString> primitives;
- QList<QByteArray> datas;
- QByteArray bytecode;
- QList<QDeclarativePropertyCache *> propertyCaches;
- QList<QDeclarativeIntegerCache *> contextCaches;
- QList<QDeclarativeScriptData *> scripts;
- QList<QUrl> urls;
-
- struct Instruction {
-#define QML_INSTR_DATA_TYPEDEF(I, FMT) typedef QDeclarativeInstructionData<QDeclarativeInstruction::I> I;
- FOR_EACH_QML_INSTR(QML_INSTR_DATA_TYPEDEF)
-#undef QML_INSTR_DATA_TYPEDEF
- private:
- Instruction();
- };
-
- void dumpInstructions();
-
- template <int Instr>
- int addInstruction(const QDeclarativeInstructionData<Instr> &data)
- {
- QDeclarativeInstruction genericInstr;
- QDeclarativeInstructionMeta<Instr>::setData(genericInstr, data);
- return addInstructionHelper(static_cast<QDeclarativeInstruction::Type>(Instr), genericInstr);
- }
- int nextInstructionIndex();
- QDeclarativeInstruction *instruction(int index);
- QDeclarativeInstruction::Type instructionType(const QDeclarativeInstruction *instr);
-
- bool isInitialized() const { return hasEngine(); }
- void initialize(QDeclarativeEngine *);
-
-protected:
- virtual void destroy(); // From QDeclarativeRefCount
- virtual void clear(); // From QDeclarativeCleanup
-
-private:
- friend class QDeclarativeCompiler;
-
- int addInstructionHelper(QDeclarativeInstruction::Type type, QDeclarativeInstruction &instr);
- void dump(QDeclarativeInstruction *, int idx = -1);
- QDeclarativeCompiledData(const QDeclarativeCompiledData &other);
- QDeclarativeCompiledData &operator=(const QDeclarativeCompiledData &other);
- QByteArray packData;
- int pack(const char *, size_t);
-
- int indexForString(const QString &);
- int indexForByteArray(const QByteArray &);
- int indexForUrl(const QUrl &);
-};
-
-namespace QDeclarativeCompilerTypes {
- struct BindingContext
- {
- BindingContext()
- : stack(0), owner(0), object(0) {}
- BindingContext(QDeclarativeScript::Object *o)
- : stack(0), owner(0), object(o) {}
- BindingContext incr() const {
- BindingContext rv(object);
- rv.stack = stack + 1;
- return rv;
- }
- bool isSubContext() const { return stack != 0; }
- int stack;
- int owner;
- QDeclarativeScript::Object *object;
- };
-
- struct BindingReference
- {
- enum DataType { QtScript, V4, V8,
- Tr, TrId };
- DataType dataType;
- };
-
- struct JSBindingReference : public QDeclarativePool::Class,
- public BindingReference
- {
- JSBindingReference() : nextReference(0) {}
-
- QDeclarativeScript::Variant expression;
- QDeclarativeScript::Property *property;
- QDeclarativeScript::Value *value;
-
- int compiledIndex;
-
- QString rewrittenExpression;
- BindingContext bindingContext;
-
- JSBindingReference *nextReference;
- };
-
- struct TrBindingReference : public QDeclarativePool::POD,
- public BindingReference
- {
- QStringRef text;
- QStringRef comment;
- int n;
- };
-
- struct IdList : public QFieldList<QDeclarativeScript::Object,
- &QDeclarativeScript::Object::nextIdObject>
- {
- QDeclarativeScript::Object *value(const QString &id) const {
- for (QDeclarativeScript::Object *o = first(); o; o = next(o)) {
- if (o->id == id)
- return o;
- }
- return 0;
- }
- };
-
- struct DepthStack {
- DepthStack() : _depth(0), _maxDepth(0) {}
- DepthStack(const DepthStack &o) : _depth(o._depth), _maxDepth(o._maxDepth) {}
- DepthStack &operator=(const DepthStack &o) { _depth = o._depth; _maxDepth = o._maxDepth; return *this; }
-
- int depth() const { return _depth; }
- int maxDepth() const { return _maxDepth; }
-
- void push() { ++_depth; _maxDepth = qMax(_depth, _maxDepth); }
- void pop() { --_depth; Q_ASSERT(_depth >= 0); Q_ASSERT(_maxDepth > _depth); }
-
- void pushPop(int count) { _maxDepth = qMax(_depth + count, _maxDepth); }
- private:
- int _depth;
- int _maxDepth;
- };
-
- // Contains all the incremental compiler state about a component. As
- // a single QML file can have multiple components defined, there may be
- // more than one of these for each compile
- struct ComponentCompileState : public QDeclarativePool::Class
- {
- ComponentCompileState()
- : parserStatusCount(0), totalBindingsCount(0), pushedProperties(0), nested(false),
- v8BindingProgramLine(-1), root(0) {}
-
- IdList ids;
- int parserStatusCount;
- int totalBindingsCount;
- int pushedProperties;
- bool nested;
-
- QByteArray compiledBindingData;
- QByteArray v8BindingProgram;
- int v8BindingProgramLine;
-
- DepthStack objectDepth;
- DepthStack listDepth;
-
- typedef QDeclarativeCompilerTypes::JSBindingReference B;
- typedef QFieldList<B, &B::nextReference> JSBindingReferenceList;
- JSBindingReferenceList bindings;
- typedef QDeclarativeScript::Object O;
- typedef QFieldList<O, &O::nextAliasingObject> AliasingObjectsList;
- AliasingObjectsList aliasingObjects;
- QDeclarativeScript::Object *root;
- };
-};
-
-class QMetaObjectBuilder;
-class Q_AUTOTEST_EXPORT QDeclarativeCompiler
-{
- Q_DECLARE_TR_FUNCTIONS(QDeclarativeCompiler)
-public:
- QDeclarativeCompiler(QDeclarativePool *);
-
- bool compile(QDeclarativeEngine *, QDeclarativeTypeData *, QDeclarativeCompiledData *);
-
- bool isError() const;
- QList<QDeclarativeError> errors() const;
-
- static bool isAttachedPropertyName(const QString &);
- static bool isSignalPropertyName(const QString &);
- static bool isAttachedPropertyName(const QHashedStringRef &);
- static bool isSignalPropertyName(const QHashedStringRef &);
-
- int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum
- const QMetaObject *resolveType(const QString& name) const; // for QDeclarativeCustomParser::resolveType
- int rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name); // for QDeclarativeCustomParser::rewriteBinding
- QString rewriteSignalHandler(const QDeclarativeScript::Variant& value, const QString &name); // for QDeclarativeCustomParser::rewriteSignalHandler
-
-private:
- typedef QDeclarativeCompiledData::Instruction Instruction;
-
- static void reset(QDeclarativeCompiledData *);
-
- void compileTree(QDeclarativeScript::Object *tree);
-
-
- bool buildObject(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
- bool buildComponent(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
- bool buildSubObject(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
- bool buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj,
- const QDeclarativeCompilerTypes::BindingContext &);
- bool buildProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj,
- const QDeclarativeCompilerTypes::BindingContext &);
- bool buildPropertyInNamespace(QDeclarativeImportedNamespace *ns,
- QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const QDeclarativeCompilerTypes::BindingContext &);
- bool buildIdProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj);
- bool buildAttachedProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildGroupedProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildValueTypeProperty(QObject *type,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Object *baseObj,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildListProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildScriptStringProperty(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildPropertyAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildPropertyObjectAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Value *value,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildPropertyOnAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Object *baseObj,
- QDeclarativeScript::Value *value,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildPropertyLiteralAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Value *value,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool doesPropertyExist(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj);
- bool testLiteralAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Value *value);
- bool testQualifiedEnumAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Value *value,
- bool *isAssignment);
- enum DynamicMetaMode { IgnoreAliases, ResolveAliases, ForceCreation };
- bool mergeDynamicMetaProperties(QDeclarativeScript::Object *obj);
- bool buildDynamicMeta(QDeclarativeScript::Object *obj, DynamicMetaMode mode);
- bool checkDynamicMeta(QDeclarativeScript::Object *obj);
- bool buildBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildLiteralBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop,
- const QDeclarativeCompilerTypes::BindingContext &ctxt);
- bool buildComponentFromRoot(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &);
- bool compileAlias(QFastMetaBuilder &,
- QByteArray &data,
- QDeclarativeScript::Object *obj,
- int propIndex, int aliasIndex,
- QDeclarativeScript::Object::DynamicProperty &);
- bool completeComponentBuild();
- bool checkValidId(QDeclarativeScript::Value *, const QString &);
-
-
- void genObject(QDeclarativeScript::Object *obj);
- void genObjectBody(QDeclarativeScript::Object *obj);
- void genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *);
- void genComponent(QDeclarativeScript::Object *obj);
- void genValueProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj);
- void genListProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj);
- void genPropertyAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Property *valueTypeProperty = 0);
- void genLiteralAssignment(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Value *value);
- void genBindingAssignment(QDeclarativeScript::Value *binding,
- QDeclarativeScript::Property *prop,
- QDeclarativeScript::Object *obj,
- QDeclarativeScript::Property *valueTypeProperty = 0);
- int genContextCache();
-
- QDeclarativePropertyData genValueTypeData(QDeclarativeScript::Property *prop,
- QDeclarativeScript::Property *valueTypeProp);
-
- int componentTypeRef();
- int translationContextIndex();
-
- static QDeclarativeType *toQmlType(QDeclarativeScript::Object *from);
- bool canCoerce(int to, QDeclarativeScript::Object *from);
-
- QString elementName(QDeclarativeScript::Object *);
-
- QStringList deferredProperties(QDeclarativeScript::Object *);
-
- QDeclarativePropertyData *property(QDeclarativeScript::Object *, int);
- QDeclarativePropertyData *property(QDeclarativeScript::Object *, const QHashedStringRef &,
- bool *notInRevision = 0);
- QDeclarativePropertyData *signal(QDeclarativeScript::Object *, const QHashedStringRef &,
- bool *notInRevision = 0);
- int indexOfProperty(QDeclarativeScript::Object *, const QHashedStringRef &, bool *notInRevision = 0);
- int indexOfProperty(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0);
- int indexOfSignal(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0);
-
- void addId(const QString &, QDeclarativeScript::Object *);
-
- void dumpStats();
-
- void addBindingReference(QDeclarativeCompilerTypes::JSBindingReference *);
-
- QDeclarativeCompilerTypes::ComponentCompileState *compileState;
-
- QDeclarativePool *pool;
-
- QDeclarativeCompilerTypes::ComponentCompileState *componentState(QDeclarativeScript::Object *);
- void saveComponentState();
-
- QList<QDeclarativeError> exceptions;
- QDeclarativeCompiledData *output;
- QDeclarativeEngine *engine;
- QDeclarativeEnginePrivate *enginePrivate;
- QDeclarativeScript::Object *unitRoot;
- QDeclarativeTypeData *unit;
- int cachedComponentTypeRef;
- int cachedTranslationContextIndex;
-
- // Compiler component statistics. Only collected if QML_COMPILER_STATS=1
- struct ComponentStat
- {
- ComponentStat() : ids(0), objects(0) {}
-
- int lineNumber;
-
- int ids;
- QList<QDeclarativeScript::LocationSpan> scriptBindings;
- QList<QDeclarativeScript::LocationSpan> sharedBindings;
- QList<QDeclarativeScript::LocationSpan> optimizedBindings;
- int objects;
- };
- struct ComponentStats : public QDeclarativePool::Class
- {
- ComponentStat componentStat;
- QList<ComponentStat> savedComponentStats;
- };
- ComponentStats *componentStats;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVECOMPILER_P_H
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
deleted file mode 100644
index 57c30748f3..0000000000
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ /dev/null
@@ -1,1352 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecomponent.h"
-#include "qdeclarativecomponent_p.h"
-#include "qdeclarativecomponentattached_p.h"
-
-#include "qdeclarativecompiler_p.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativevme_p.h"
-#include "qdeclarative.h"
-#include "qdeclarativeengine.h"
-#include "qdeclarativebinding_p.h"
-#include "qdeclarativebinding_p_p.h"
-#include "qdeclarativeglobal_p.h"
-#include "qdeclarativescript_p.h"
-#include <private/qdeclarativeprofilerservice_p.h>
-#include <private/qdeclarativeenginedebugservice_p.h>
-#include "qdeclarativeincubator.h"
-#include "qdeclarativeincubator_p.h"
-
-#include <private/qv8engine_p.h>
-#include <private/qv8include_p.h>
-
-#include <QStack>
-#include <QStringList>
-#include <QtCore/qdebug.h>
-#include <qdeclarativeinfo.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeComponentExtension : public QV8Engine::Deletable
-{
-public:
- QDeclarativeComponentExtension(QV8Engine *);
- virtual ~QDeclarativeComponentExtension();
-
- v8::Persistent<v8::Function> incubationConstructor;
- v8::Persistent<v8::Script> initialProperties;
- v8::Persistent<v8::Function> forceCompletion;
-};
-V8_DEFINE_EXTENSION(QDeclarativeComponentExtension, componentExtension);
-
-/*
- Try to do what's necessary for a reasonable display of the type
- name, but no more (just enough for the client to do more extensive cleanup).
-
- Should only be called when debugging is enabled.
-*/
-static inline QString buildTypeNameForDebug(const QMetaObject *metaObject)
-{
- static const QString qmlMarker(QLatin1String("_QML"));
- static const QChar underscore(QLatin1Char('_'));
- static const QChar asterisk(QLatin1Char('*'));
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(metaObject);
- QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(metaObject->className());
- if (!type) {
- //### optimize further?
- int marker = typeName.indexOf(qmlMarker);
- if (marker != -1 && marker < typeName.count() - 1) {
- if (typeName[marker + 1] == underscore) {
- const QString className = typeName.left(marker) + asterisk;
- type = QDeclarativeMetaType::qmlType(QMetaType::type(className.toUtf8()));
- if (type)
- typeName = type->qmlTypeName();
- }
- }
- }
- return typeName;
-}
-
-/*!
- \class QDeclarativeComponent
- \since 4.7
- \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 QtQuick 2.0
-
- 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
-
-
- \section2 Network Components
-
- If the URL passed to QDeclarativeComponent is a network resource, or if the QML document references a
- network resource, the QDeclarativeComponent has to fetch the network data before it is able to create
- objects. In this case, the QDeclarativeComponent will have a \l {QDeclarativeComponent::Loading}{Loading}
- \l {QDeclarativeComponent::status()}{status}. An application will have to wait until the component
- is \l {QDeclarativeComponent::Ready}{Ready} before calling \l {QDeclarativeComponent::create()}.
-
- The following example shows how to load a QML file from a network resource. After creating
- the QDeclarativeComponent, it tests whether the component is loading. If it is, it connects to the
- QDeclarativeComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method
- directly. Note that QDeclarativeComponent::isLoading() may be false for a network component if the
- component has been cached and is ready immediately.
-
- \code
- MyApplication::MyApplication()
- {
- // ...
- component = new QDeclarativeComponent(engine, QUrl("http://www.example.com/main.qml"));
- if (component->isLoading())
- QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
- this, SLOT(continueLoading()));
- else
- continueLoading();
- }
-
- void MyApplication::continueLoading()
- {
- if (component->isError()) {
- qWarning() << component->errors();
- } else {
- QObject *myObject = component->create();
- }
- }
- \endcode
-
- \sa {Using QML Bindings in C++ Applications}, {Integrating QML Code with Existing Qt UI Code}
-*/
-
-/*!
- \qmlclass Component QDeclarativeComponent
- \ingroup qml-utility-elements
- \since 4.7
- \brief The Component element encapsulates a QML component definition.
-
- Components are reusable, encapsulated QML elements with well-defined interfaces.
-
- Components are often defined by \l {qdeclarativedocuments.html}{component files} -
- that is, \c .qml files. The \e Component element essentially allows QML components
- to be defined inline, within a \l {QML Document}{QML document}, rather than as a separate QML 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.
- It contains a single item, a \l Rectangle:
-
- \snippet doc/src/snippets/declarative/component.qml 0
-
- 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 QML
- file, and is not loaded until requested (in this case, by the
- two \l Loader objects).
-
- Defining a \c Component is similar to defining a \l {QML Document}{QML document}.
- A QML document has a single top-level item that defines the behaviors and
- properties of that component, and cannot define properties or behaviors outside
- of that top-level item. In the same way, a \c Component definition contains a single
- top level item (which in the above example is a \l Rectangle) and cannot define any
- data outside of this item, with the exception of an \e id (which in the above example
- is \e redSquare).
-
- The \c Component element is commonly used to provide graphical components
- for views. For example, the ListView::delegate property requires a \c Component
- to specify how each list item is to be displayed.
-
- \c Component objects can also be created dynamically using
- \l{QML:Qt::createComponent()}{Qt.createComponent()}.
-*/
-
-/*!
- \qmlattachedsignal Component::onCompleted()
-
- Emitted after component "startup" has completed. This can be used to
- execute script code at startup, once the full QML environment has been
- established.
-
- The \c {Component::onCompleted} attached property can be applied to
- any element. The order of running the \c onCompleted scripts is
- undefined.
-
- \qml
- Rectangle {
- Component.onCompleted: console.log("Completed Running!")
- Rectangle {
- Component.onCompleted: console.log("Nested Completed Running!")
- }
- }
- \endqml
-*/
-
-/*!
- \qmlattachedsignal Component::onDestruction()
-
- Emitted as the component begins destruction. This can be used to undo
- work done in the onCompleted signal, or other imperative code in your
- application.
-
- The \c {Component::onDestruction} attached property can be applied to
- any element. However, it applies to the destruction of the component as
- a whole, and not the destruction of the specific object. The order of
- running the \c onDestruction scripts is undefined.
-
- \qml
- Rectangle {
- Component.onDestruction: console.log("Destruction Beginning!")
- Rectangle {
- Component.onDestruction: console.log("Nested Destruction Beginning!")
- }
- }
- \endqml
-
- \sa QtDeclarative
-*/
-
-/*!
- \enum QDeclarativeComponent::Status
-
- Specifies the loading status of the QDeclarativeComponent.
-
- \value Null This QDeclarativeComponent has no data. Call loadUrl() or setData() to add QML content.
- \value Ready This QDeclarativeComponent is ready and create() may be called.
- \value Loading This QDeclarativeComponent is loading network data.
- \value Error An error has occurred. Call errors() to retrieve a list of \{QDeclarativeError}{errors}.
-*/
-
-void QDeclarativeComponentPrivate::typeDataReady(QDeclarativeTypeData *)
-{
- Q_Q(QDeclarativeComponent);
-
- Q_ASSERT(typeData);
-
- fromTypeData(typeData);
- typeData = 0;
-
- emit q->statusChanged(q->status());
-}
-
-void QDeclarativeComponentPrivate::typeDataProgress(QDeclarativeTypeData *, qreal p)
-{
- Q_Q(QDeclarativeComponent);
-
- progress = p;
-
- emit q->progressChanged(p);
-}
-
-void QDeclarativeComponentPrivate::fromTypeData(QDeclarativeTypeData *data)
-{
- url = data->finalUrl();
- QDeclarativeCompiledData *c = data->compiledData();
-
- if (!c) {
- Q_ASSERT(data->isError());
- state.errors = data->errors();
- } else {
- cc = c;
- }
-
- data->release();
-}
-
-void QDeclarativeComponentPrivate::clear()
-{
- if (typeData) {
- typeData->unregisterCallback(this);
- typeData->release();
- typeData = 0;
- }
-
- if (cc) {
- cc->release();
- cc = 0;
- }
-}
-
-/*!
- \internal
-*/
-QDeclarativeComponent::QDeclarativeComponent(QObject *parent)
- : QObject(*(new QDeclarativeComponentPrivate), parent)
-{
-}
-
-/*!
- Destruct the QDeclarativeComponent.
-*/
-QDeclarativeComponent::~QDeclarativeComponent()
-{
- Q_D(QDeclarativeComponent);
-
- if (d->state.completePending) {
- qWarning("QDeclarativeComponent: Component destroyed while completion pending");
- d->completeCreate();
- }
-
- if (d->typeData) {
- d->typeData->unregisterCallback(d);
- d->typeData->release();
- }
- if (d->cc)
- d->cc->release();
-}
-
-/*!
- \qmlproperty enumeration Component::status
- This property holds the status of component loading. It can be one of:
- \list
- \o Component.Null - no data is available for the component
- \o Component.Ready - the component has been loaded, and can be used to create instances.
- \o Component.Loading - the component is currently being loaded
- \o Component.Error - an error occurred while loading the component.
- Calling errorString() will provide a human-readable description of any errors.
- \endlist
- */
-
-/*!
- \property QDeclarativeComponent::status
- The component's current \l{QDeclarativeComponent::Status} {status}.
- */
-QDeclarativeComponent::Status QDeclarativeComponent::status() const
-{
- Q_D(const QDeclarativeComponent);
-
- if (d->typeData)
- return Loading;
- else if (!d->state.errors.isEmpty())
- return Error;
- else if (d->engine && d->cc)
- return Ready;
- else
- return Null;
-}
-
-/*!
- Returns true if status() == QDeclarativeComponent::Null.
-*/
-bool QDeclarativeComponent::isNull() const
-{
- return status() == Null;
-}
-
-/*!
- Returns true if status() == QDeclarativeComponent::Ready.
-*/
-bool QDeclarativeComponent::isReady() const
-{
- return status() == Ready;
-}
-
-/*!
- Returns true if status() == QDeclarativeComponent::Error.
-*/
-bool QDeclarativeComponent::isError() const
-{
- return status() == Error;
-}
-
-/*!
- Returns true if status() == QDeclarativeComponent::Loading.
-*/
-bool QDeclarativeComponent::isLoading() const
-{
- return status() == Loading;
-}
-
-/*!
- \qmlproperty real Component::progress
- The progress of loading the component, from 0.0 (nothing loaded)
- to 1.0 (finished).
-*/
-
-/*!
- \property QDeclarativeComponent::progress
- The progress of loading the component, from 0.0 (nothing loaded)
- to 1.0 (finished).
-*/
-qreal QDeclarativeComponent::progress() const
-{
- Q_D(const QDeclarativeComponent);
- return d->progress;
-}
-
-/*!
- \fn void QDeclarativeComponent::progressChanged(qreal progress)
-
- Emitted whenever the component's loading progress changes. \a progress will be the
- current progress between 0.0 (nothing loaded) and 1.0 (finished).
-*/
-
-/*!
- \fn void QDeclarativeComponent::statusChanged(QDeclarativeComponent::Status status)
-
- Emitted whenever the component's status changes. \a status will be the
- new status.
-*/
-
-/*!
- Create a QDeclarativeComponent with no data and give it the specified
- \a engine and \a parent. Set the data with setData().
-*/
-QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QObject *parent)
- : QObject(*(new QDeclarativeComponentPrivate), parent)
-{
- Q_D(QDeclarativeComponent);
- d->engine = engine;
-}
-
-/*!
- Create a QDeclarativeComponent from the given \a url and give it the
- specified \a parent and \a engine.
-
- Ensure that the URL provided is full and correct, in particular, use
- \l QUrl::fromLocalFile() when loading a file from the local filesystem.
-
- \sa loadUrl()
-*/
-QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QUrl &url, QObject *parent)
-: QObject(*(new QDeclarativeComponentPrivate), parent)
-{
- Q_D(QDeclarativeComponent);
- d->engine = engine;
- loadUrl(url);
-}
-
-/*!
- Create a QDeclarativeComponent from the given \a fileName and give it the specified
- \a parent and \a engine.
-
- \sa loadUrl()
-*/
-QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QString &fileName,
- QObject *parent)
-: QObject(*(new QDeclarativeComponentPrivate), parent)
-{
- Q_D(QDeclarativeComponent);
- d->engine = engine;
- loadUrl(d->engine->baseUrl().resolved(QUrl::fromLocalFile(fileName)));
-}
-
-/*!
- \internal
-*/
-QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QDeclarativeCompiledData *cc, int start, QObject *parent)
- : QObject(*(new QDeclarativeComponentPrivate), parent)
-{
- Q_D(QDeclarativeComponent);
- d->engine = engine;
- d->cc = cc;
- cc->addref();
- d->start = start;
- d->url = cc->url;
- d->progress = 1.0;
-}
-
-/*!
- Sets the QDeclarativeComponent to use the given QML \a data. If \a url
- is provided, it is used to set the component name and to provide
- a base path for items resolved by this component.
-*/
-void QDeclarativeComponent::setData(const QByteArray &data, const QUrl &url)
-{
- Q_D(QDeclarativeComponent);
-
- d->clear();
-
- d->url = url;
-
- QDeclarativeTypeData *typeData = QDeclarativeEnginePrivate::get(d->engine)->typeLoader.get(data, url);
-
- if (typeData->isCompleteOrError()) {
- d->fromTypeData(typeData);
- } else {
- d->typeData = typeData;
- d->typeData->registerCallback(d);
- }
-
- d->progress = 1.0;
- emit statusChanged(status());
- emit progressChanged(d->progress);
-}
-
-/*!
-Returns the QDeclarativeContext the component was created in. This is only
-valid for components created directly from QML.
-*/
-QDeclarativeContext *QDeclarativeComponent::creationContext() const
-{
- Q_D(const QDeclarativeComponent);
- if(d->creationContext)
- return d->creationContext->asQDeclarativeContext();
-
- return qmlContext(this);
-}
-
-/*!
- Load the QDeclarativeComponent from the provided \a url.
-
- Ensure that the URL provided is full and correct, in particular, use
- \l QUrl::fromLocalFile() when loading a file from the local filesystem.
-*/
-void QDeclarativeComponent::loadUrl(const QUrl &url)
-{
- Q_D(QDeclarativeComponent);
-
- d->clear();
-
- if ((url.isRelative() && !url.isEmpty())
- || url.scheme() == QLatin1String("file")) // Workaround QTBUG-11929
- d->url = d->engine->baseUrl().resolved(url);
- else
- d->url = url;
-
- if (url.isEmpty()) {
- QDeclarativeError error;
- error.setDescription(tr("Invalid empty URL"));
- d->state.errors << error;
- return;
- }
-
- QDeclarativeTypeData *data = QDeclarativeEnginePrivate::get(d->engine)->typeLoader.get(d->url);
-
- if (data->isCompleteOrError()) {
- d->fromTypeData(data);
- d->progress = 1.0;
- } else {
- d->typeData = data;
- d->typeData->registerCallback(d);
- d->progress = data->progress();
- }
-
- emit statusChanged(status());
- emit progressChanged(d->progress);
-}
-
-/*!
- Return the list of errors that occurred during the last compile or create
- operation. An empty list is returned if isError() is not set.
-*/
-QList<QDeclarativeError> QDeclarativeComponent::errors() const
-{
- Q_D(const QDeclarativeComponent);
- if (isError())
- return d->state.errors;
- else
- return QList<QDeclarativeError>();
-}
-
-/*!
- \qmlmethod string Component::errorString()
-
- Returns a human-readable description of any errors.
-
- The string includes the file, location, and description of each error.
- If multiple errors are present they are separated by a newline character.
-
- If no errors are present, an empty string is returned.
-*/
-
-/*!
- \internal
- errorString is only meant as a way to get the errors in script
-*/
-QString QDeclarativeComponent::errorString() const
-{
- Q_D(const QDeclarativeComponent);
- QString ret;
- if(!isError())
- return ret;
- foreach(const QDeclarativeError &e, d->state.errors) {
- ret += e.url().toString() + QLatin1Char(':') +
- QString::number(e.line()) + QLatin1Char(' ') +
- e.description() + QLatin1Char('\n');
- }
- return ret;
-}
-
-/*!
- \qmlproperty url Component::url
- The component URL. This is the URL that was used to construct the component.
-*/
-
-/*!
- \property QDeclarativeComponent::url
- The component URL. This is the URL passed to either the constructor,
- or the loadUrl() or setData() methods.
-*/
-QUrl QDeclarativeComponent::url() const
-{
- Q_D(const QDeclarativeComponent);
- return d->url;
-}
-
-/*!
- \internal
-*/
-QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
-}
-
-/*!
- Create an object instance from this component. Returns 0 if creation
- failed. \a context specifies the context within which to create the object
- instance.
-
- If \a context is 0 (the default), it will create the instance in the
- engine' s \l {QDeclarativeEngine::rootContext()}{root context}.
-*/
-QObject *QDeclarativeComponent::create(QDeclarativeContext *context)
-{
- Q_D(QDeclarativeComponent);
-
- if (!context)
- context = d->engine->rootContext();
-
- QObject *rv = beginCreate(context);
- completeCreate();
- return rv;
-}
-
-/*!
- This method provides more advanced control over component instance creation.
- In general, programmers should use QDeclarativeComponent::create() to create a
- component.
-
- Create an object instance from this component. Returns 0 if creation
- failed. \a publicContext specifies the context within which to create the object
- instance.
-
- When QDeclarativeComponent constructs an instance, it occurs in three steps:
- \list 1
- \i The object hierarchy is created, and constant values are assigned.
- \i Property bindings are evaluated for the the first time.
- \i If applicable, QDeclarativeParserStatus::componentComplete() is called on objects.
- \endlist
- QDeclarativeComponent::beginCreate() differs from QDeclarativeComponent::create() in that it
- only performs step 1. QDeclarativeComponent::completeCreate() must be called to
- complete steps 2 and 3.
-
- This breaking point is sometimes useful when using attached properties to
- communicate information to an instantiated component, as it allows their
- initial values to be configured before property bindings take effect.
-*/
-QObject *QDeclarativeComponent::beginCreate(QDeclarativeContext *publicContext)
-{
- Q_D(QDeclarativeComponent);
-
- Q_ASSERT(publicContext);
- QDeclarativeContextData *context = QDeclarativeContextData::get(publicContext);
-
- return d->beginCreate(context);
-}
-
-QObject *
-QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context)
-{
- Q_Q(QDeclarativeComponent);
- if (!context) {
- qWarning("QDeclarativeComponent: Cannot create a component in a null context");
- return 0;
- }
-
- if (!context->isValid()) {
- qWarning("QDeclarativeComponent: Cannot create a component in an invalid context");
- return 0;
- }
-
- if (context->engine != engine) {
- qWarning("QDeclarativeComponent: Must create component in context from the same QDeclarativeEngine");
- return 0;
- }
-
- if (state.completePending) {
- qWarning("QDeclarativeComponent: Cannot create new component instance before completing the previous");
- return 0;
- }
-
- if (!q->isReady()) {
- qWarning("QDeclarativeComponent: Component is not ready");
- return 0;
- }
-
- QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
-
- if (enginePriv->inProgressCreations == 0) {
- // only track root, since further ones might not be properly nested
- profiler = new QDeclarativeObjectCreatingProfiler();
- }
-
- enginePriv->inProgressCreations++;
- state.errors.clear();
- state.completePending = true;
-
- enginePriv->referenceScarceResources();
- state.vme.init(context, cc, start, creationContext);
- QObject *rv = state.vme.execute(&state.errors);
- enginePriv->dereferenceScarceResources();
-
- if (rv) {
- QDeclarativeData *ddata = QDeclarativeData::get(rv);
- Q_ASSERT(ddata);
- ddata->indestructible = true;
- }
-
- if (enginePriv->isDebugging && rv) {
- if (!context->isInternal)
- context->asQDeclarativeContextPrivate()->instances.append(rv);
- QDeclarativeEngineDebugService::instance()->objectCreated(engine, rv);
-
- if (profiler && profiler->enabled) {
- profiler->setTypeName(buildTypeNameForDebug(rv->metaObject()));
- QDeclarativeData *data = QDeclarativeData::get(rv);
- Q_ASSERT(data);
- profiler->setLocation(cc->url, data->lineNumber, data->columnNumber);
- }
- }
-
- return rv;
-}
-
-void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *enginePriv,
- QObject *object, ConstructionState *state)
-{
- enginePriv->inProgressCreations++;
- state->errors.clear();
- state->completePending = true;
-
- state->vme.initDeferred(object);
- state->vme.execute(&state->errors);
-}
-
-void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state)
-{
- if (state->completePending) {
- state->vme.complete();
-
- state->completePending = false;
-
- enginePriv->inProgressCreations--;
-
- if (0 == enginePriv->inProgressCreations) {
- while (enginePriv->erroredBindings) {
- enginePriv->warning(enginePriv->erroredBindings->error);
- enginePriv->erroredBindings->removeError();
- }
- }
- }
-}
-
-/*!
- This method provides more advanced control over component instance creation.
- In general, programmers should use QDeclarativeComponent::create() to create a
- component.
-
- Complete a component creation begin with QDeclarativeComponent::beginCreate().
-*/
-void QDeclarativeComponent::completeCreate()
-{
- Q_D(QDeclarativeComponent);
-
- d->completeCreate();
-}
-
-void QDeclarativeComponentPrivate::completeCreate()
-{
- if (state.completePending) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- complete(ep, &state);
-
- delete profiler;
- profiler = 0;
- }
-}
-
-QDeclarativeComponentAttached::QDeclarativeComponentAttached(QObject *parent)
-: QObject(parent), prev(0), next(0)
-{
-}
-
-QDeclarativeComponentAttached::~QDeclarativeComponentAttached()
-{
- if (prev) *prev = next;
- if (next) next->prev = prev;
- prev = 0;
- next = 0;
-}
-
-/*!
- \internal
-*/
-QDeclarativeComponentAttached *QDeclarativeComponent::qmlAttachedProperties(QObject *obj)
-{
- QDeclarativeComponentAttached *a = new QDeclarativeComponentAttached(obj);
-
- QDeclarativeEngine *engine = qmlEngine(obj);
- if (!engine)
- return a;
-
- if (QDeclarativeEnginePrivate::get(engine)->activeVME) { // XXX should only be allowed during begin
- QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
- a->add(&p->activeVME->componentAttached);
- } else {
- QDeclarativeData *d = QDeclarativeData::get(obj);
- Q_ASSERT(d);
- Q_ASSERT(d->context);
- a->add(&d->context->componentAttached);
- }
-
- return a;
-}
-
-void QDeclarativeComponent::create(QDeclarativeIncubator &i, QDeclarativeContext *context,
- QDeclarativeContext *forContext)
-{
- Q_D(QDeclarativeComponent);
-
- if (!context)
- context = d->engine->rootContext();
-
- QDeclarativeContextData *contextData = QDeclarativeContextData::get(context);
- QDeclarativeContextData *forContextData = contextData;
- if (forContext) forContextData = QDeclarativeContextData::get(forContext);
-
- if (!contextData->isValid()) {
- qWarning("QDeclarativeComponent: Cannot create a component in an invalid context");
- return;
- }
-
- if (contextData->engine != d->engine) {
- qWarning("QDeclarativeComponent: Must create component in context from the same QDeclarativeEngine");
- return;
- }
-
- if (!isReady()) {
- qWarning("QDeclarativeComponent: Component is not ready");
- return;
- }
-
- i.clear();
- QDeclarativeIncubatorPrivate *p = i.d;
-
- QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(d->engine);
-
- p->component = d->cc; p->component->addref();
- p->vme.init(contextData, d->cc, d->start, d->creationContext);
-
- enginePriv->incubate(i, forContextData);
-}
-
-class QV8IncubatorResource : public QV8ObjectResource,
- public QDeclarativeIncubator
-{
-V8_RESOURCE_TYPE(IncubatorType)
-public:
- QV8IncubatorResource(QV8Engine *engine, IncubationMode = Asynchronous);
-
- static v8::Handle<v8::Value> StatusChangedGetter(v8::Local<v8::String>,
- const v8::AccessorInfo& info);
- static v8::Handle<v8::Value> StatusGetter(v8::Local<v8::String>,
- const v8::AccessorInfo& info);
- static v8::Handle<v8::Value> ObjectGetter(v8::Local<v8::String>,
- const v8::AccessorInfo& info);
- static v8::Handle<v8::Value> ForceCompletionGetter(v8::Local<v8::String>,
- const v8::AccessorInfo& info);
- static v8::Handle<v8::Value> ForceCompletion(const v8::Arguments &args);
-
- static void StatusChangedSetter(v8::Local<v8::String>, v8::Local<v8::Value> value,
- const v8::AccessorInfo& info);
-
- void dispose();
-
- v8::Persistent<v8::Object> me;
- QDeclarativeGuard<QObject> parent;
- v8::Persistent<v8::Value> valuemap;
- v8::Persistent<v8::Object> qmlGlobal;
-protected:
- virtual void statusChanged(Status);
- virtual void setInitialState(QObject *);
-};
-
-static void QDeclarativeComponent_setQmlParent(QObject *me, QObject *parent)
-{
- if (parent) {
- me->setParent(parent);
- typedef QDeclarativePrivate::AutoParentFunction APF;
- QList<APF> functions = QDeclarativeMetaType::parentFunctions();
-
- bool needParent = false;
- for (int ii = 0; ii < functions.count(); ++ii) {
- QDeclarativePrivate::AutoParentResult res = functions.at(ii)(me, parent);
- if (res == QDeclarativePrivate::Parented) {
- needParent = false;
- break;
- } else if (res == QDeclarativePrivate::IncompatibleParent) {
- needParent = true;
- }
- }
- if (needParent)
- qWarning("QDeclarativeComponent: Created graphical object was not "
- "placed in the graphics scene.");
- }
-}
-
-/*!
- \qmlmethod object Component::createObject(Item parent, object properties)
-
- Creates and returns an object instance of this component that will have
- the given \a parent and \a properties. The \a properties argument is optional.
- Returns null if object creation fails.
-
- The object will be created in the same context as the one in which the component
- was created. This function will always return null when called on components
- which were not created in QML.
-
- If you wish to create an object without setting a parent, specify \c null for
- the \a parent value. Note that if the returned object is to be displayed, you
- must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent}
- property, or else the object will not be visible.
-
- If a \a parent is not provided to createObject(), a reference to the returned object must be held so that
- it is not destroyed by the garbage collector. This is true regardless of whether \l{Item::parent} is set afterwards,
- since setting the Item parent does not change object ownership; only the graphical parent is changed.
-
- As of QtQuick 1.1, this method accepts an optional \a properties argument that specifies a
- map of initial property values for the created object. These values are applied before object
- creation is finalized. (This is more efficient than setting property values after object creation,
- particularly where large sets of property values are defined, and also allows property bindings
- to be set up before the object is created.)
-
- The \a properties argument is specified as a map of property-value items. For example, the code
- below creates an object with initial \c x and \c y values of 100 and 200, respectively:
-
- \js
- var component = Qt.createComponent("Button.qml");
- if (component.status == Component.Ready)
- component.createObject(parent, {"x": 100, "y": 100});
- \endjs
-
- Dynamically created instances can be deleted with the \c destroy() method.
- See \l {Dynamic Object Management in QML} for more information.
-*/
-void QDeclarativeComponent::createObject(QDeclarativeV8Function *args)
-{
- Q_D(QDeclarativeComponent);
- Q_ASSERT(d->engine);
- Q_ASSERT(args);
-
- QObject *parent = 0;
- v8::Local<v8::Object> valuemap;
-
- if (args->Length() >= 1)
- parent = args->engine()->toQObject((*args)[0]);
-
- if (args->Length() >= 2) {
- v8::Local<v8::Value> v = (*args)[1];
- if (!v->IsObject() || v->IsArray()) {
- qmlInfo(this) << tr("createObject: value is not an object");
- args->returnValue(v8::Null());
- return;
- }
- valuemap = v8::Local<v8::Object>::Cast(v);
- }
-
- QV8Engine *v8engine = args->engine();
-
- QDeclarativeContext *ctxt = creationContext();
- if (!ctxt) ctxt = d->engine->rootContext();
-
- QObject *rv = beginCreate(ctxt);
-
- if (!rv) {
- args->returnValue(v8::Null());
- return;
- }
-
- QDeclarativeComponent_setQmlParent(rv, parent);
-
- v8::Handle<v8::Value> ov = v8engine->newQObject(rv);
- Q_ASSERT(ov->IsObject());
- v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(ov);
-
- if (!valuemap.IsEmpty()) {
- QDeclarativeComponentExtension *e = componentExtension(v8engine);
- // Try catch isn't needed as the function itself is loaded with try/catch
- v8::Handle<v8::Value> function = e->initialProperties->Run(args->qmlGlobal());
- v8::Handle<v8::Value> args[] = { object, valuemap };
- v8::Handle<v8::Function>::Cast(function)->Call(v8engine->global(), 2, args);
- }
-
- d->completeCreate();
-
- Q_ASSERT(QDeclarativeData::get(rv));
- QDeclarativeData::get(rv)->setImplicitDestructible();
-
- if (!rv)
- args->returnValue(v8::Null());
- else
- args->returnValue(object);
-}
-
-/*!
- \qmlmethod object Component::incubateObject(Item parent, object properties, enum mode)
-
- Creates an incubator for instance of this component. Incubators allow new component
- instances to be instantiated asynchronously and not cause freezes in the UI.
-
- The \a parent argument specifies the parent the created instance will have. Omitting the
- parameter or passing null will create anobject with no parent. In this case, a reference
- to the created object must be maintained by the application of the object will eventually
- be garbage collected.
-
- The \a properties argument is specified as a map of property-value items which will be
- set on the created object during its construction. \a mode may be Qt.Synchronous or
- Qt.Asynchronous and controls whether the instance is created synchronously or asynchronously.
- The default is asynchronously. In some circumstances, even if Qt.Synchronous is specified,
- the incubator may create the object asynchronously. This happens if the component calling
- incubateObject() is itself being created asynchronously.
-
- All three arguments are optional.
-
- If successful, the method returns an incubator, otherwise null. The incubator has the following
- properties:
-
- \list
- \i status The status of the incubator. Valid values are Component.Ready, Component.Loading and
- Component.Error.
- \i object The created object instance. Will only be available once the incubator is in the
- Ready status.
- \i onStatusChanged Specifies a callback function to be invoked when the status changes. The
- status is passed as a parameter to the callback.
- \i forceCompletion() Call to complete incubation synchronously.
- \endlist
-
- The following example demonstrates how to use an incubator:
-
- \js
- var component = Qt.createComponent("Button.qml");
-
- var incubator = component.incubateObject(parent, { x: 10, y: 10 });
- if (incubator.status != Component.Ready) {
- incubator.onStatusChanged = function(status) {
- if (status == Component.Ready) {
- print ("Object", incubator.object, "is now ready!");
- }
- }
- } else {
- print ("Object", incubator.object, "is ready immediately!");
- }
- \endjs
-*/
-
-void QDeclarativeComponent::incubateObject(QDeclarativeV8Function *args)
-{
- Q_D(QDeclarativeComponent);
- Q_ASSERT(d->engine);
- Q_UNUSED(d);
- Q_ASSERT(args);
-
- QObject *parent = 0;
- v8::Local<v8::Object> valuemap;
- QDeclarativeIncubator::IncubationMode mode = QDeclarativeIncubator::Asynchronous;
-
- if (args->Length() >= 1)
- parent = args->engine()->toQObject((*args)[0]);
-
- if (args->Length() >= 2) {
- v8::Local<v8::Value> v = (*args)[1];
- if (v->IsNull()) {
- } else if (!v->IsObject() || v->IsArray()) {
- qmlInfo(this) << tr("createObject: value is not an object");
- args->returnValue(v8::Null());
- return;
- } else {
- valuemap = v8::Local<v8::Object>::Cast(v);
- }
- }
-
- if (args->Length() >= 3) {
- quint32 v = (*args)[2]->Uint32Value();
- if (v == 0)
- mode = QDeclarativeIncubator::Asynchronous;
- else if (v == 1)
- mode = QDeclarativeIncubator::AsynchronousIfNested;
- }
-
- QDeclarativeComponentExtension *e = componentExtension(args->engine());
-
- QV8IncubatorResource *r = new QV8IncubatorResource(args->engine(), mode);
- v8::Local<v8::Object> o = e->incubationConstructor->NewInstance();
- o->SetExternalResource(r);
-
- if (!valuemap.IsEmpty()) {
- r->valuemap = qPersistentNew(valuemap);
- r->qmlGlobal = qPersistentNew(args->qmlGlobal());
- }
- r->parent = parent;
- r->me = qPersistentNew(o);
-
- create(*r, creationContext());
-
- if (r->status() == QDeclarativeIncubator::Null) {
- r->dispose();
- args->returnValue(v8::Null());
- } else {
- args->returnValue(o);
- }
-}
-
-// XXX used by QSGLoader
-void QDeclarativeComponentPrivate::initializeObjectWithInitialProperties(v8::Handle<v8::Object> qmlGlobal, v8::Handle<v8::Object> valuemap, QObject *toCreate)
-{
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- QV8Engine *v8engine = ep->v8engine();
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(v8engine->context());
- v8::Handle<v8::Value> ov = v8engine->newQObject(toCreate);
- Q_ASSERT(ov->IsObject());
- v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(ov);
-
- if (!valuemap.IsEmpty()) {
- QDeclarativeComponentExtension *e = componentExtension(v8engine);
- // Try catch isn't needed as the function itself is loaded with try/catch
- v8::Handle<v8::Value> function = e->initialProperties->Run(qmlGlobal);
- v8::Handle<v8::Value> args[] = { object, valuemap };
- v8::Handle<v8::Function>::Cast(function)->Call(v8engine->global(), 2, args);
- }
-
- QDeclarativeData *ddata = QDeclarativeData::get(toCreate);
- Q_ASSERT(ddata);
- ddata->setImplicitDestructible();
-}
-
-
-QDeclarativeComponentExtension::QDeclarativeComponentExtension(QV8Engine *engine)
-{
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- forceCompletion = qPersistentNew(V8FUNCTION(QV8IncubatorResource::ForceCompletion, engine));
-
- {
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->InstanceTemplate()->SetInternalFieldCount(1);
- ft->InstanceTemplate()->SetAccessor(v8::String::New("onStatusChanged"),
- QV8IncubatorResource::StatusChangedGetter,
- QV8IncubatorResource::StatusChangedSetter);
- ft->InstanceTemplate()->SetAccessor(v8::String::New("status"),
- QV8IncubatorResource::StatusGetter);
- ft->InstanceTemplate()->SetAccessor(v8::String::New("object"),
- QV8IncubatorResource::ObjectGetter);
- ft->InstanceTemplate()->SetAccessor(v8::String::New("forceCompletion"),
- QV8IncubatorResource::ForceCompletionGetter);
- incubationConstructor = qPersistentNew(ft->GetFunction());
- }
-
- {
-#define INITIALPROPERTIES_SOURCE \
- "(function(object, values) {"\
- "try {"\
- "for(var property in values) {" \
- "try {"\
- "var properties = property.split(\".\");"\
- "var o = object;"\
- "for (var ii = 0; ii < properties.length - 1; ++ii) {"\
- "o = o[properties[ii]];"\
- "}"\
- "o[properties[properties.length - 1]] = values[property];"\
- "} catch(e) {}"\
- "}"\
- "} catch(e) {}"\
- "})"
- initialProperties = qPersistentNew(engine->qmlModeCompile(QLatin1String(INITIALPROPERTIES_SOURCE)));
-#undef INITIALPROPERTIES_SOURCE
- }
-}
-
-v8::Handle<v8::Value> QV8IncubatorResource::ObjectGetter(v8::Local<v8::String>,
- const v8::AccessorInfo& info)
-{
- QV8IncubatorResource *r = v8_resource_check<QV8IncubatorResource>(info.This());
- return r->engine->newQObject(r->object());
-}
-
-v8::Handle<v8::Value> QV8IncubatorResource::ForceCompletionGetter(v8::Local<v8::String>,
- const v8::AccessorInfo& info)
-{
- QV8IncubatorResource *r = v8_resource_check<QV8IncubatorResource>(info.This());
- return componentExtension(r->engine)->forceCompletion;
-}
-
-v8::Handle<v8::Value> QV8IncubatorResource::ForceCompletion(const v8::Arguments &args)
-{
- QV8IncubatorResource *r = v8_resource_cast<QV8IncubatorResource>(args.This());
- if (!r)
- V8THROW_TYPE("Not an incubator object");
-
- r->forceCompletion();
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> QV8IncubatorResource::StatusGetter(v8::Local<v8::String>,
- const v8::AccessorInfo& info)
-{
- QV8IncubatorResource *r = v8_resource_check<QV8IncubatorResource>(info.This());
- return v8::Integer::NewFromUnsigned(r->status());
-}
-
-v8::Handle<v8::Value> QV8IncubatorResource::StatusChangedGetter(v8::Local<v8::String>,
- const v8::AccessorInfo& info)
-{
- return info.This()->GetInternalField(0);
-}
-
-void QV8IncubatorResource::StatusChangedSetter(v8::Local<v8::String>, v8::Local<v8::Value> value,
- const v8::AccessorInfo& info)
-{
- info.This()->SetInternalField(0, value);
-}
-
-QDeclarativeComponentExtension::~QDeclarativeComponentExtension()
-{
- qPersistentDispose(incubationConstructor);
- qPersistentDispose(initialProperties);
- qPersistentDispose(forceCompletion);
-}
-
-QV8IncubatorResource::QV8IncubatorResource(QV8Engine *engine, IncubationMode m)
-: QV8ObjectResource(engine), QDeclarativeIncubator(m)
-{
-}
-
-void QV8IncubatorResource::setInitialState(QObject *o)
-{
- QDeclarativeComponent_setQmlParent(o, parent);
-
- if (!valuemap.IsEmpty()) {
- QDeclarativeComponentExtension *e = componentExtension(engine);
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- v8::Handle<v8::Value> function = e->initialProperties->Run(qmlGlobal);
- v8::Handle<v8::Value> args[] = { engine->newQObject(o), valuemap };
- v8::Handle<v8::Function>::Cast(function)->Call(engine->global(), 2, args);
-
- qPersistentDispose(valuemap);
- qPersistentDispose(qmlGlobal);
- }
-}
-
-void QV8IncubatorResource::dispose()
-{
- qPersistentDispose(valuemap);
- qPersistentDispose(qmlGlobal);
- // No further status changes are forthcoming, so we no long need a self reference
- qPersistentDispose(me);
-}
-
-void QV8IncubatorResource::statusChanged(Status s)
-{
- if (s == Ready) {
- Q_ASSERT(QDeclarativeData::get(object()));
- QDeclarativeData::get(object())->setImplicitDestructible();
- }
-
- if (!me.IsEmpty()) { // Will be false in synchronous mode
- v8::HandleScope scope;
- v8::Local<v8::Value> callback = me->GetInternalField(0);
-
- if (!callback.IsEmpty() && !callback->IsUndefined()) {
-
- if (callback->IsFunction()) {
- v8::Context::Scope context_scope(engine->context());
- v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(callback);
- v8::Handle<v8::Value> args[] = { v8::Integer::NewFromUnsigned(s) };
- v8::TryCatch tc;
- f->Call(me, 1, args);
- if (tc.HasCaught()) {
- QDeclarativeError error;
- QDeclarativeExpressionPrivate::exceptionToError(tc.Message(), error);
- QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate::get(engine->engine()),
- error);
- }
- }
- }
- }
-
- if (s == Ready || s == Error)
- dispose();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h
deleted file mode 100644
index 2bd292081c..0000000000
--- a/src/declarative/qml/qdeclarativecomponent.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECOMPONENT_H
-#define QDECLARATIVECOMPONENT_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeerror.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qstring.h>
-#include <QtDeclarative/qjsvalue.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QByteArray;
-class QDeclarativeEngine;
-class QDeclarativeComponent;
-class QDeclarativeIncubator;
-class QDeclarativeV8Function;
-class QDeclarativeCompiledData;
-class QDeclarativeComponentPrivate;
-class QDeclarativeComponentAttached;
-
-class Q_DECLARATIVE_EXPORT QDeclarativeComponent : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeComponent)
-
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(QUrl url READ url CONSTANT)
-
-public:
- QDeclarativeComponent(QObject *parent = 0);
- QDeclarativeComponent(QDeclarativeEngine *, QObject *parent=0);
- QDeclarativeComponent(QDeclarativeEngine *, const QString &fileName, QObject *parent = 0);
- QDeclarativeComponent(QDeclarativeEngine *, const QUrl &url, QObject *parent = 0);
- virtual ~QDeclarativeComponent();
-
- Q_ENUMS(Status)
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
-
- bool isNull() const;
- bool isReady() const;
- bool isError() const;
- bool isLoading() const;
-
- QList<QDeclarativeError> errors() const;
- Q_INVOKABLE QString errorString() const;
-
- qreal progress() const;
-
- QUrl url() const;
-
- virtual QObject *create(QDeclarativeContext *context = 0);
- virtual QObject *beginCreate(QDeclarativeContext *);
- virtual void completeCreate();
-
- void create(QDeclarativeIncubator &, QDeclarativeContext *context = 0,
- QDeclarativeContext *forContext = 0);
-
- QDeclarativeContext *creationContext() const;
-
- static QDeclarativeComponentAttached *qmlAttachedProperties(QObject *);
-
-public Q_SLOTS:
- void loadUrl(const QUrl &url);
- void setData(const QByteArray &, const QUrl &baseUrl);
-
-Q_SIGNALS:
- void statusChanged(QDeclarativeComponent::Status);
- void progressChanged(qreal);
-
-protected:
- QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject* parent);
- Q_INVOKABLE void createObject(QDeclarativeV8Function *);
- Q_INVOKABLE void incubateObject(QDeclarativeV8Function *);
-
-private:
- QDeclarativeComponent(QDeclarativeEngine *, QDeclarativeCompiledData *, int, QObject *parent);
-
- Q_DISABLE_COPY(QDeclarativeComponent)
- friend class QDeclarativeVME;
- friend class QDeclarativeTypeData;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeComponent::Status)
-QML_DECLARE_TYPE(QDeclarativeComponent)
-QML_DECLARE_TYPEINFO(QDeclarativeComponent, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVECOMPONENT_H
diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h
deleted file mode 100644
index 6824bd2927..0000000000
--- a/src/declarative/qml/qdeclarativecomponent_p.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECOMPONENT_P_H
-#define QDECLARATIVECOMPONENT_P_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 "qdeclarativecomponent.h"
-
-#include <private/qv8_p.h>
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativetypeloader_p.h"
-#include <private/qbitfield_p.h>
-#include "qdeclarativevme_p.h"
-#include "qdeclarativeerror.h"
-#include "qdeclarative.h"
-#include "../debugger/qdeclarativeprofilerservice_p.h"
-
-#include <QtCore/QString>
-#include <QtCore/QStringList>
-#include <QtCore/QList>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-
-class QDeclarativeComponent;
-class QDeclarativeEngine;
-class QDeclarativeCompiledData;
-
-class QDeclarativeComponentAttached;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeComponentPrivate : public QObjectPrivate, public QDeclarativeTypeData::TypeDataCallback
-{
- Q_DECLARE_PUBLIC(QDeclarativeComponent)
-
-public:
- QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0), profiler(0) {}
-
- QObject *beginCreate(QDeclarativeContextData *);
- void completeCreate();
- void initializeObjectWithInitialProperties(v8::Handle<v8::Object> qmlGlobal, v8::Handle<v8::Object> valuemap, QObject *toCreate);
-
- QDeclarativeTypeData *typeData;
- virtual void typeDataReady(QDeclarativeTypeData *);
- virtual void typeDataProgress(QDeclarativeTypeData *, qreal);
-
- void fromTypeData(QDeclarativeTypeData *data);
-
- QUrl url;
- qreal progress;
-
- int start;
- QDeclarativeCompiledData *cc;
-
- struct ConstructionState {
- ConstructionState() : completePending(false) {}
-
- QDeclarativeVME vme;
- QList<QDeclarativeError> errors;
- bool completePending;
- };
- ConstructionState state;
-
- static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object,
- ConstructionState *state);
- static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state);
-
- QDeclarativeEngine *engine;
- QDeclarativeGuardedContextData creationContext;
- QDeclarativeObjectCreatingProfiler *profiler;
-
- void clear();
-
- static QDeclarativeComponentPrivate *get(QDeclarativeComponent *c) {
- return static_cast<QDeclarativeComponentPrivate *>(QObjectPrivate::get(c));
- }
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVECOMPONENT_P_H
diff --git a/src/declarative/qml/qdeclarativecomponentattached_p.h b/src/declarative/qml/qdeclarativecomponentattached_p.h
deleted file mode 100644
index cd21ea1dcb..0000000000
--- a/src/declarative/qml/qdeclarativecomponentattached_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECOMPONENTATTACHED_P_H
-#define QDECLARATIVECOMPONENTATTACHED_P_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtCore/QObject>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class Q_AUTOTEST_EXPORT QDeclarativeComponentAttached : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeComponentAttached(QObject *parent = 0);
- ~QDeclarativeComponentAttached();
-
- void add(QDeclarativeComponentAttached **a) {
- prev = a; next = *a; *a = this;
- if (next) next->prev = &next;
- }
- void rem() {
- if (next) next->prev = prev;
- *prev = next;
- next = 0; prev = 0;
- }
- QDeclarativeComponentAttached **prev;
- QDeclarativeComponentAttached *next;
-
-Q_SIGNALS:
- void completed();
- void destruction();
-
-private:
- friend class QDeclarativeVME;
- friend class QDeclarativeContextData;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVECOMPONENTATTACHED_P_H
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
deleted file mode 100644
index 102992947e..0000000000
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ /dev/null
@@ -1,811 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecontext.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativecomponentattached_p.h"
-
-#include "qdeclarativecomponent_p.h"
-#include "qdeclarativeexpression_p.h"
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativeengine.h"
-#include "qdeclarativeinfo.h"
-#include <private/qv4bindings_p.h>
-#include <private/qv8bindings_p.h>
-
-#include <qjsengine.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeContextPrivate::QDeclarativeContextPrivate()
-: data(0), notifyIndex(-1)
-{
-}
-
-/*!
- \class QDeclarativeContext
- \since 4.7
- \brief The QDeclarativeContext class defines a context within a QML engine.
- \mainclass
-
- Contexts allow data to be exposed to the QML components instantiated by the
- QML engine.
-
- Each QDeclarativeContext contains a set of properties, distinct from its QObject
- properties, that allow data to be explicitly bound to a context by name. The
- context properties are defined and updated by calling
- QDeclarativeContext::setContextProperty(). The following example shows a Qt model
- being bound to a context and then accessed from a QML file.
-
- \code
- QDeclarativeEngine engine;
- QStringListModel modelData;
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- context->setContextProperty("myModel", &modelData);
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl());
- QObject *window = component.create(context);
- \endcode
-
- Note it is the responsibility of the creator to delete any QDeclarativeContext it
- constructs. If the \c context object in the example is no longer needed when the
- \c window component instance is destroyed, the \c context must be destroyed explicitly.
- The simplest way to ensure this is to set \c window as the parent of \c context.
-
- To simplify binding and maintaining larger data sets, a context object can be set
- on a QDeclarativeContext. All the properties of the context object are available
- by name in the context, as though they were all individually added through calls
- to QDeclarativeContext::setContextProperty(). Changes to the property's values are
- detected through the property's notify signal. Setting a context object is both
- faster and easier than manually adding and maintaing context property values.
-
- The following example has the same effect as the previous one, but it uses a context
- object.
-
- \code
- class MyDataSet : ... {
- ...
- Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged)
- ...
- };
-
- MyDataSet myDataSet;
- QDeclarativeEngine engine;
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- context->setContextObject(&myDataSet);
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl());
- component.create(context);
- \endcode
-
- All properties added explicitly by QDeclarativeContext::setContextProperty() take
- precedence over the context object's properties.
-
- \section2 The Context Hierarchy
-
- Contexts form a hierarchy. The root of this hierarchy is the QML engine's
- \l {QDeclarativeEngine::rootContext()}{root context}. Child contexts inherit
- the context properties of their parents; if a child context sets a context property
- that already exists in its parent, the new context property overrides that of the
- parent.
-
- The following example defines two contexts - \c context1 and \c context2. The
- second context overrides the "b" context property inherited from the first with a
- new value.
-
- \code
- QDeclarativeEngine engine;
- QDeclarativeContext *context1 = new QDeclarativeContext(engine.rootContext());
- QDeclarativeContext *context2 = new QDeclarativeContext(context1);
-
- context1->setContextProperty("a", 12);
- context1->setContextProperty("b", 12);
-
- context2->setContextProperty("b", 15);
- \endcode
-
- While QML objects instantiated in a context are not strictly owned by that
- context, their bindings are. If a context is destroyed, the property bindings of
- outstanding QML objects will stop evaluating.
-
- \warning Setting the context object or adding new context properties after an object
- 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 Bindings in C++ Applications}
-*/
-
-/*! \internal */
-QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *e, bool)
-: QObject(*(new QDeclarativeContextPrivate))
-{
- Q_D(QDeclarativeContext);
- d->data = new QDeclarativeContextData(this);
-
- d->data->engine = e;
-}
-
-/*!
- Create a new QDeclarativeContext as a child of \a engine's root context, and the
- QObject \a parent.
-*/
-QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *engine, QObject *parent)
-: QObject(*(new QDeclarativeContextPrivate), parent)
-{
- Q_D(QDeclarativeContext);
- d->data = new QDeclarativeContextData(this);
-
- d->data->setParent(engine?QDeclarativeContextData::get(engine->rootContext()):0);
-}
-
-/*!
- Create a new QDeclarativeContext with the given \a parentContext, and the
- QObject \a parent.
-*/
-QDeclarativeContext::QDeclarativeContext(QDeclarativeContext *parentContext, QObject *parent)
-: QObject(*(new QDeclarativeContextPrivate), parent)
-{
- Q_D(QDeclarativeContext);
- d->data = new QDeclarativeContextData(this);
-
- d->data->setParent(parentContext?QDeclarativeContextData::get(parentContext):0);
-}
-
-/*!
- \internal
-*/
-QDeclarativeContext::QDeclarativeContext(QDeclarativeContextData *data)
-: QObject(*(new QDeclarativeContextPrivate), 0)
-{
- Q_D(QDeclarativeContext);
- d->data = data;
-}
-
-/*!
- Destroys the QDeclarativeContext.
-
- Any expressions, or sub-contexts dependent on this context will be
- invalidated, but not destroyed (unless they are parented to the QDeclarativeContext
- object).
- */
-QDeclarativeContext::~QDeclarativeContext()
-{
- Q_D(QDeclarativeContext);
-
- if (!d->data->isInternal)
- d->data->destroy();
-}
-
-/*!
- Returns whether the context is valid.
-
- To be valid, a context must have a engine, and it's contextObject(), if any,
- must not have been deleted.
-*/
-bool QDeclarativeContext::isValid() const
-{
- Q_D(const QDeclarativeContext);
- return d->data && d->data->isValid();
-}
-
-/*!
- Return the context's QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the
- QDeclarativeEngine was destroyed.
-*/
-QDeclarativeEngine *QDeclarativeContext::engine() const
-{
- Q_D(const QDeclarativeContext);
- return d->data->engine;
-}
-
-/*!
- Return the context's parent QDeclarativeContext, or 0 if this context has no
- parent or if the parent has been destroyed.
-*/
-QDeclarativeContext *QDeclarativeContext::parentContext() const
-{
- Q_D(const QDeclarativeContext);
- return d->data->parent?d->data->parent->asQDeclarativeContext():0;
-}
-
-/*!
- Return the context object, or 0 if there is no context object.
-*/
-QObject *QDeclarativeContext::contextObject() const
-{
- Q_D(const QDeclarativeContext);
- return d->data->contextObject;
-}
-
-/*!
- Set the context \a object.
-*/
-void QDeclarativeContext::setContextObject(QObject *object)
-{
- Q_D(QDeclarativeContext);
-
- QDeclarativeContextData *data = d->data;
-
- if (data->isInternal) {
- qWarning("QDeclarativeContext: Cannot set context object for internal context.");
- return;
- }
-
- if (!isValid()) {
- qWarning("QDeclarativeContext: Cannot set context object on invalid context.");
- return;
- }
-
- data->contextObject = object;
-}
-
-/*!
- Set a the \a value of the \a name property on this context.
-*/
-void QDeclarativeContext::setContextProperty(const QString &name, const QVariant &value)
-{
- Q_D(QDeclarativeContext);
- if (d->notifyIndex == -1)
- d->notifyIndex = this->metaObject()->methodCount();
-
- QDeclarativeContextData *data = d->data;
-
- if (data->isInternal) {
- qWarning("QDeclarativeContext: Cannot set property on internal context.");
- return;
- }
-
- if (!isValid()) {
- qWarning("QDeclarativeContext: Cannot set property on invalid context.");
- return;
- }
-
- if (data->engine) {
- bool ok;
- QObject *o = QDeclarativeEnginePrivate::get(data->engine)->toQObject(value, &ok);
- if (ok) {
- setContextProperty(name, o);
- return;
- }
- }
-
- if (!data->propertyNames) data->propertyNames = new QDeclarativeIntegerCache();
-
- int idx = data->propertyNames->value(name);
- if (idx == -1) {
- data->propertyNames->add(name, data->idValueCount + d->propertyValues.count());
- d->propertyValues.append(value);
-
- data->refreshExpressions();
- } else {
- d->propertyValues[idx] = value;
- QMetaObject::activate(this, idx + d->notifyIndex, 0);
- }
-}
-
-/*!
- Set the \a value of the \a name property on this context.
-
- QDeclarativeContext does \bold not take ownership of \a value.
-*/
-void QDeclarativeContext::setContextProperty(const QString &name, QObject *value)
-{
- Q_D(QDeclarativeContext);
- if (d->notifyIndex == -1)
- d->notifyIndex = this->metaObject()->methodCount();
-
- QDeclarativeContextData *data = d->data;
-
- if (data->isInternal) {
- qWarning("QDeclarativeContext: Cannot set property on internal context.");
- return;
- }
-
- if (!isValid()) {
- qWarning("QDeclarativeContext: Cannot set property on invalid context.");
- return;
- }
-
- if (!data->propertyNames) data->propertyNames = new QDeclarativeIntegerCache();
- int idx = data->propertyNames->value(name);
-
- if (idx == -1) {
- data->propertyNames->add(name, data->idValueCount + d->propertyValues.count());
- d->propertyValues.append(QVariant::fromValue(value));
-
- data->refreshExpressions();
- } else {
- d->propertyValues[idx] = QVariant::fromValue(value);
- QMetaObject::activate(this, idx + d->notifyIndex, 0);
- }
-}
-
-/*!
- Returns the value of the \a name property for this context
- as a QVariant.
- */
-QVariant QDeclarativeContext::contextProperty(const QString &name) const
-{
- Q_D(const QDeclarativeContext);
- QVariant value;
- int idx = -1;
-
- QDeclarativeContextData *data = d->data;
-
- if (data->propertyNames)
- idx = data->propertyNames->value(name);
-
- if (idx == -1) {
- QByteArray utf8Name = name.toUtf8();
- if (data->contextObject) {
- QObject *obj = data->contextObject;
- QDeclarativePropertyData local;
- QDeclarativePropertyData *property =
- QDeclarativePropertyCache::property(data->engine, obj, name, local);
-
- if (property) value = obj->metaObject()->property(property->coreIndex).read(obj);
- }
- if (!value.isValid() && parentContext())
- value = parentContext()->contextProperty(name);
- } else {
- if (idx >= d->propertyValues.count())
- value = QVariant::fromValue(data->idValues[idx - d->propertyValues.count()].data());
- else
- value = d->propertyValues[idx];
- }
-
- return value;
-}
-
-/*!
-Returns the name of \a object in this context, or an empty string if \a object
-is not named in the context. Objects are named by setContextProperty(), or by ids in
-the case of QML created contexts.
-
-If the object has multiple names, the first is returned.
-*/
-QString QDeclarativeContext::nameForObject(QObject *object) const
-{
- Q_D(const QDeclarativeContext);
-
- return d->data->findObjectId(object);
-}
-
-/*!
- Resolves the URL \a src relative to the URL of the
- containing component.
-
- \sa QDeclarativeEngine::baseUrl(), setBaseUrl()
-*/
-QUrl QDeclarativeContext::resolvedUrl(const QUrl &src)
-{
- Q_D(QDeclarativeContext);
- return d->data->resolvedUrl(src);
-}
-
-QUrl QDeclarativeContextData::resolvedUrl(const QUrl &src)
-{
- QDeclarativeContextData *ctxt = this;
-
- if (src.isRelative() && !src.isEmpty()) {
- if (ctxt) {
- while(ctxt) {
- if(ctxt->url.isValid())
- break;
- else
- ctxt = ctxt->parent;
- }
-
- if (ctxt)
- return ctxt->url.resolved(src);
- else if (engine)
- return engine->baseUrl().resolved(src);
- }
- return QUrl();
- } else {
- return src;
- }
-}
-
-
-/*!
- Explicitly sets the url resolvedUrl() will use for relative references to \a baseUrl.
-
- Calling this function will override the url of the containing
- component used by default.
-
- \sa resolvedUrl()
-*/
-void QDeclarativeContext::setBaseUrl(const QUrl &baseUrl)
-{
- Q_D(QDeclarativeContext);
-
- d->data->url = baseUrl;
- d->data->urlString = baseUrl.toString();
-}
-
-/*!
- Returns the base url of the component, or the containing component
- if none is set.
-*/
-QUrl QDeclarativeContext::baseUrl() const
-{
- Q_D(const QDeclarativeContext);
- const QDeclarativeContextData* data = d->data;
- while (data && data->url.isEmpty())
- data = data->parent;
-
- if (data)
- return data->url;
- else
- return QUrl();
-}
-
-int QDeclarativeContextPrivate::context_count(QDeclarativeListProperty<QObject> *prop)
-{
- QDeclarativeContext *context = static_cast<QDeclarativeContext*>(prop->object);
- QDeclarativeContextPrivate *d = QDeclarativeContextPrivate::get(context);
- int contextProperty = (int)(quintptr)prop->data;
-
- if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId<QList<QObject*> >()) {
- return 0;
- } else {
- return ((const QList<QObject> *)d->propertyValues.at(contextProperty).constData())->count();
- }
-}
-
-QObject *QDeclarativeContextPrivate::context_at(QDeclarativeListProperty<QObject> *prop, int index)
-{
- QDeclarativeContext *context = static_cast<QDeclarativeContext*>(prop->object);
- QDeclarativeContextPrivate *d = QDeclarativeContextPrivate::get(context);
- int contextProperty = (int)(quintptr)prop->data;
-
- if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId<QList<QObject*> >()) {
- return 0;
- } else {
- return ((const QList<QObject*> *)d->propertyValues.at(contextProperty).constData())->at(index);
- }
-}
-
-
-QDeclarativeContextData::QDeclarativeContextData()
-: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false),
- isPragmaLibraryContext(false), unresolvedNames(false), publicContext(0), activeVMEData(0),
- propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
- expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0),
- componentAttached(0), v4bindings(0), v8bindings(0)
-{
-}
-
-QDeclarativeContextData::QDeclarativeContextData(QDeclarativeContext *ctxt)
-: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false),
- isPragmaLibraryContext(false), unresolvedNames(false), publicContext(ctxt), activeVMEData(0),
- propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
- expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0),
- componentAttached(0), v4bindings(0), v8bindings(0)
-{
-}
-
-void QDeclarativeContextData::invalidate()
-{
- while (componentAttached) {
- QDeclarativeComponentAttached *a = componentAttached;
- componentAttached = a->next;
- if (componentAttached) componentAttached->prev = &componentAttached;
-
- a->next = 0;
- a->prev = 0;
-
- emit a->destruction();
- }
-
- while (childContexts) {
- if (childContexts->ownedByParent) {
- childContexts->destroy();
- } else {
- childContexts->invalidate();
- }
- }
-
- if (prevChild) {
- *prevChild = nextChild;
- if (nextChild) nextChild->prevChild = prevChild;
- nextChild = 0;
- prevChild = 0;
- }
-
- engine = 0;
- parent = 0;
-}
-
-void QDeclarativeContextData::clearContext()
-{
- if (engine) {
- while (componentAttached) {
- QDeclarativeComponentAttached *a = componentAttached;
- componentAttached = a->next;
- if (componentAttached) componentAttached->prev = &componentAttached;
-
- a->next = 0;
- a->prev = 0;
-
- emit a->destruction();
- }
- }
-
- QDeclarativeAbstractExpression *expression = expressions;
- while (expression) {
- QDeclarativeAbstractExpression *nextExpression = expression->m_nextExpression;
-
- expression->m_prevExpression = 0;
- expression->m_nextExpression = 0;
-
- expression->setContext(0);
-
- expression = nextExpression;
- }
- expressions = 0;
-}
-
-void QDeclarativeContextData::destroy()
-{
- if (linkedContext)
- linkedContext->destroy();
-
- if (engine) invalidate();
-
- clearContext();
-
- while (contextObjects) {
- QDeclarativeData *co = contextObjects;
- contextObjects = contextObjects->nextContextObject;
-
- co->context = 0;
- co->outerContext = 0;
- co->nextContextObject = 0;
- co->prevContextObject = 0;
- }
-
- QDeclarativeGuardedContextData *contextGuard = contextGuards;
- while (contextGuard) {
- QDeclarativeGuardedContextData *next = contextGuard->m_next;
- contextGuard->m_next = 0;
- contextGuard->m_prev = 0;
- contextGuard->m_contextData = 0;
- contextGuard = next;
- }
- contextGuards = 0;
-
- if (propertyNames)
- propertyNames->release();
-
- if (imports)
- imports->release();
-
- if (v4bindings)
- v4bindings->release();
-
- if (v8bindings)
- v8bindings->release();
-
- for (int ii = 0; ii < importedScripts.count(); ++ii) {
- qPersistentDispose(importedScripts[ii]);
- }
-
- delete [] idValues;
-
- if (isInternal)
- delete publicContext;
-
- delete this;
-}
-
-void QDeclarativeContextData::setParent(QDeclarativeContextData *p, bool parentTakesOwnership)
-{
- if (p) {
- parent = p;
- engine = p->engine;
- nextChild = p->childContexts;
- if (nextChild) nextChild->prevChild = &nextChild;
- prevChild = &p->childContexts;
- p->childContexts = this;
- ownedByParent = parentTakesOwnership;
- }
-}
-
-void QDeclarativeContextData::refreshExpressionsRecursive(QDeclarativeAbstractExpression *expression)
-{
- QDeclarativeAbstractExpression::DeleteWatcher w(expression);
-
- if (expression->m_nextExpression)
- refreshExpressionsRecursive(expression->m_nextExpression);
-
- if (!w.wasDeleted())
- expression->refresh();
-}
-
-static inline bool expressions_to_run(QDeclarativeContextData *ctxt, bool isGlobalRefresh)
-{
- return ctxt->expressions && (!isGlobalRefresh || ctxt->unresolvedNames);
-}
-
-void QDeclarativeContextData::refreshExpressionsRecursive(bool isGlobal)
-{
- // For efficiency, we try and minimize the number of guards we have to create
- if (expressions_to_run(this, isGlobal) && (nextChild || childContexts)) {
- QDeclarativeGuardedContextData guard(this);
-
- if (childContexts)
- childContexts->refreshExpressionsRecursive(isGlobal);
-
- if (guard.isNull()) return;
-
- if (nextChild)
- nextChild->refreshExpressionsRecursive(isGlobal);
-
- if (guard.isNull()) return;
-
- if (expressions_to_run(this, isGlobal))
- refreshExpressionsRecursive(expressions);
-
- } else if (expressions_to_run(this, isGlobal)) {
-
- refreshExpressionsRecursive(expressions);
-
- } else if (nextChild && childContexts) {
-
- QDeclarativeGuardedContextData guard(this);
-
- childContexts->refreshExpressionsRecursive(isGlobal);
-
- if (!guard.isNull() && nextChild)
- nextChild->refreshExpressionsRecursive(isGlobal);
-
- } else if (nextChild) {
-
- nextChild->refreshExpressionsRecursive(isGlobal);
-
- } else if (childContexts) {
-
- childContexts->refreshExpressionsRecursive(isGlobal);
-
- }
-}
-
-// Refreshes all expressions that could possibly depend on this context. Refreshing flushes all
-// context-tree dependent caches in the expressions, and should occur every time the context tree
-// *structure* (not values) changes.
-void QDeclarativeContextData::refreshExpressions()
-{
- bool isGlobal = (parent == 0);
-
- // For efficiency, we try and minimize the number of guards we have to create
- if (expressions_to_run(this, isGlobal) && childContexts) {
- QDeclarativeGuardedContextData guard(this);
-
- childContexts->refreshExpressionsRecursive(isGlobal);
-
- if (!guard.isNull() && expressions_to_run(this, isGlobal))
- refreshExpressionsRecursive(expressions);
-
- } else if (expressions_to_run(this, isGlobal)) {
-
- refreshExpressionsRecursive(expressions);
-
- } else if (childContexts) {
-
- childContexts->refreshExpressionsRecursive(isGlobal);
-
- }
-}
-
-void QDeclarativeContextData::addObject(QObject *o)
-{
- QDeclarativeData *data = QDeclarativeData::get(o, true);
-
- Q_ASSERT(data->context == 0);
-
- data->context = this;
- data->outerContext = this;
-
- data->nextContextObject = contextObjects;
- if (data->nextContextObject)
- data->nextContextObject->prevContextObject = &data->nextContextObject;
- data->prevContextObject = &contextObjects;
- contextObjects = data;
-}
-
-void QDeclarativeContextData::setIdProperty(int idx, QObject *obj)
-{
- idValues[idx] = obj;
- idValues[idx].context = this;
-}
-
-void QDeclarativeContextData::setIdPropertyData(QDeclarativeIntegerCache *data)
-{
- Q_ASSERT(!propertyNames);
- propertyNames = data;
- propertyNames->addref();
-
- idValueCount = data->count();
- idValues = new ContextGuard[idValueCount];
-}
-
-QString QDeclarativeContextData::findObjectId(const QObject *obj) const
-{
- if (!propertyNames)
- return QString();
-
- for (int ii = 0; ii < idValueCount; ii++) {
- if (idValues[ii] == obj)
- return propertyNames->findId(ii);
- }
-
- if (publicContext) {
- QDeclarativeContextPrivate *p = QDeclarativeContextPrivate::get(publicContext);
- for (int ii = 0; ii < p->propertyValues.count(); ++ii)
- if (p->propertyValues.at(ii) == QVariant::fromValue((QObject *)obj))
- return propertyNames->findId(ii);
- }
-
- if (linkedContext)
- return linkedContext->findObjectId(obj);
- return QString();
-}
-
-QDeclarativeContext *QDeclarativeContextData::asQDeclarativeContext()
-{
- if (!publicContext)
- publicContext = new QDeclarativeContext(this);
- return publicContext;
-}
-
-QDeclarativeContextPrivate *QDeclarativeContextData::asQDeclarativeContextPrivate()
-{
- return QDeclarativeContextPrivate::get(asQDeclarativeContext());
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecontext.h b/src/declarative/qml/qdeclarativecontext.h
deleted file mode 100644
index b1a8362a3b..0000000000
--- a/src/declarative/qml/qdeclarativecontext.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECONTEXT_H
-#define QDECLARATIVECONTEXT_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtCore/qmetatype.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QString;
-class QDeclarativeEngine;
-class QDeclarativeRefCount;
-class QDeclarativeContextPrivate;
-class QDeclarativeCompositeTypeData;
-class QDeclarativeContextData;
-
-class Q_DECLARATIVE_EXPORT QDeclarativeContext : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeContext)
-
-public:
- QDeclarativeContext(QDeclarativeEngine *parent, QObject *objParent=0);
- QDeclarativeContext(QDeclarativeContext *parent, QObject *objParent=0);
- virtual ~QDeclarativeContext();
-
- bool isValid() const;
-
- QDeclarativeEngine *engine() const;
- QDeclarativeContext *parentContext() const;
-
- QObject *contextObject() const;
- void setContextObject(QObject *);
-
- QVariant contextProperty(const QString &) const;
- void setContextProperty(const QString &, QObject *);
- void setContextProperty(const QString &, const QVariant &);
-
- QString nameForObject(QObject *) const;
-
- QUrl resolvedUrl(const QUrl &);
-
- void setBaseUrl(const QUrl &);
- QUrl baseUrl() const;
-
-private:
- friend class QDeclarativeVME;
- friend class QDeclarativeEngine;
- friend class QDeclarativeEnginePrivate;
- friend class QDeclarativeExpression;
- friend class QDeclarativeExpressionPrivate;
- friend class QDeclarativeComponent;
- friend class QDeclarativeComponentPrivate;
- friend class QDeclarativeScriptPrivate;
- friend class QDeclarativeBoundSignalProxy;
- friend class QDeclarativeContextData;
- QDeclarativeContext(QDeclarativeContextData *);
- QDeclarativeContext(QDeclarativeEngine *, bool);
- Q_DISABLE_COPY(QDeclarativeContext)
-};
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QList<QObject*>)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVECONTEXT_H
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
deleted file mode 100644
index c53fc9cc21..0000000000
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ /dev/null
@@ -1,334 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECONTEXT_P_H
-#define QDECLARATIVECONTEXT_P_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 "qdeclarativecontext.h"
-
-#include "qdeclarativedata_p.h"
-#include "qdeclarativeintegercache_p.h"
-#include "qdeclarativetypenamecache_p.h"
-#include "qdeclarativenotifier_p.h"
-#include "qdeclarativelist.h"
-#include "qdeclarativescript_p.h"
-
-#include <QtCore/qhash.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtCore/qset.h>
-
-#include <private/qobject_p.h>
-#include <private/qflagpointer_p.h>
-#include <private/qdeclarativeguard_p.h>
-
-#include <private/qv8_p.h>
-
-
-QT_BEGIN_NAMESPACE
-
-class QV8Bindings;
-class QDeclarativeContext;
-class QDeclarativeExpression;
-class QDeclarativeEngine;
-class QDeclarativeExpression;
-class QDeclarativeExpressionPrivate;
-class QDeclarativeAbstractExpression;
-class QV4Bindings;
-class QDeclarativeContextData;
-
-class QDeclarativeContextPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeContext)
-public:
- QDeclarativeContextPrivate();
-
- QDeclarativeContextData *data;
-
- QList<QVariant> propertyValues;
- int notifyIndex;
-
- static QDeclarativeContextPrivate *get(QDeclarativeContext *context) {
- return static_cast<QDeclarativeContextPrivate *>(QObjectPrivate::get(context));
- }
- static QDeclarativeContext *get(QDeclarativeContextPrivate *context) {
- return static_cast<QDeclarativeContext *>(context->q_func());
- }
-
- // Only used for debugging
- QList<QPointer<QObject> > instances;
-
- static int context_count(QDeclarativeListProperty<QObject> *);
- static QObject *context_at(QDeclarativeListProperty<QObject> *, int);
-};
-
-class QDeclarativeVME;
-class QDeclarativeComponentAttached;
-class QDeclarativeGuardedContextData;
-class Q_DECLARATIVE_EXPORT QDeclarativeContextData
-{
-public:
- QDeclarativeContextData();
- QDeclarativeContextData(QDeclarativeContext *);
- void clearContext();
- void destroy();
- void invalidate();
-
- inline bool isValid() const {
- return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted);
- }
-
- // My parent context and engine
- QDeclarativeContextData *parent;
- QDeclarativeEngine *engine;
-
- void setParent(QDeclarativeContextData *, bool parentTakesOwnership = false);
- void refreshExpressions();
-
- void addObject(QObject *);
-
- QUrl resolvedUrl(const QUrl &);
-
- // My containing QDeclarativeContext. If isInternal is true this owns publicContext.
- // If internal is false publicContext owns this.
- QDeclarativeContext *asQDeclarativeContext();
- QDeclarativeContextPrivate *asQDeclarativeContextPrivate();
- quint32 isInternal:1;
- quint32 ownedByParent:1; // unrelated to isInternal; parent context deletes children if true.
- quint32 isJSContext:1;
- quint32 isPragmaLibraryContext:1;
- quint32 unresolvedNames:1; // True if expressions in this context failed to resolve a toplevel name
- quint32 dummy:28;
- QDeclarativeContext *publicContext;
-
- // VME data that is constructing this context if any
- void *activeVMEData;
-
- // Property name cache
- QDeclarativeIntegerCache *propertyNames;
-
- // Context object
- QObject *contextObject;
-
- // Any script blocks that exist on this context
- QList<v8::Persistent<v8::Object> > importedScripts;
-
- // Context base url
- QUrl url;
- QString urlString;
-
- // List of imports that apply to this context
- QDeclarativeTypeNameCache *imports;
-
- // My children
- QDeclarativeContextData *childContexts;
-
- // My peers in parent's childContexts list
- QDeclarativeContextData *nextChild;
- QDeclarativeContextData **prevChild;
-
- // Expressions that use this context
- QDeclarativeAbstractExpression *expressions;
-
- // Doubly-linked list of objects that are owned by this context
- QDeclarativeData *contextObjects;
-
- // Doubly-linked list of context guards (XXX merge with contextObjects)
- QDeclarativeGuardedContextData *contextGuards;
-
- // id guards
- struct ContextGuard : public QDeclarativeGuard<QObject>
- {
- inline ContextGuard();
- inline ContextGuard &operator=(QObject *obj);
- inline void objectDestroyed(QObject *);
-
- inline bool wasSet() const;
-
- QFlagPointer<QDeclarativeContextData> context;
- QDeclarativeNotifier bindings;
- };
- ContextGuard *idValues;
- int idValueCount;
- void setIdProperty(int, QObject *);
- void setIdPropertyData(QDeclarativeIntegerCache *);
-
- // Linked contexts. this owns linkedContext.
- QDeclarativeContextData *linkedContext;
-
- // Linked list of uses of the Component attached property in this
- // context
- QDeclarativeComponentAttached *componentAttached;
-
- // Optimized binding objects. Needed for deferred properties.
- QV4Bindings *v4bindings;
- QV8Bindings *v8bindings;
-
- // Return the outermost id for obj, if any.
- QString findObjectId(const QObject *obj) const;
-
- static QDeclarativeContextData *get(QDeclarativeContext *context) {
- return QDeclarativeContextPrivate::get(context)->data;
- }
-
-private:
- void refreshExpressionsRecursive(bool isGlobal);
- void refreshExpressionsRecursive(QDeclarativeAbstractExpression *);
- ~QDeclarativeContextData() {}
-};
-
-class QDeclarativeGuardedContextData
-{
-public:
- inline QDeclarativeGuardedContextData();
- inline QDeclarativeGuardedContextData(QDeclarativeContextData *);
- inline ~QDeclarativeGuardedContextData();
-
- inline QDeclarativeContextData *contextData();
- inline void setContextData(QDeclarativeContextData *);
-
- inline bool isNull() const { return !m_contextData; }
-
- inline operator QDeclarativeContextData*() const { return m_contextData; }
- inline QDeclarativeContextData* operator->() const { return m_contextData; }
- inline QDeclarativeGuardedContextData &operator=(QDeclarativeContextData *d);
-
-private:
- QDeclarativeGuardedContextData &operator=(const QDeclarativeGuardedContextData &);
- QDeclarativeGuardedContextData(const QDeclarativeGuardedContextData &);
- friend class QDeclarativeContextData;
-
- inline void clear();
-
- QDeclarativeContextData *m_contextData;
- QDeclarativeGuardedContextData *m_next;
- QDeclarativeGuardedContextData **m_prev;
-};
-
-QDeclarativeGuardedContextData::QDeclarativeGuardedContextData()
-: m_contextData(0), m_next(0), m_prev(0)
-{
-}
-
-QDeclarativeGuardedContextData::QDeclarativeGuardedContextData(QDeclarativeContextData *data)
-: m_contextData(0), m_next(0), m_prev(0)
-{
- setContextData(data);
-}
-
-QDeclarativeGuardedContextData::~QDeclarativeGuardedContextData()
-{
- clear();
-}
-
-void QDeclarativeGuardedContextData::setContextData(QDeclarativeContextData *contextData)
-{
- clear();
-
- if (contextData) {
- m_contextData = contextData;
- m_next = contextData->contextGuards;
- if (m_next) m_next->m_prev = &m_next;
- m_prev = &contextData->contextGuards;
- contextData->contextGuards = this;
- }
-}
-
-QDeclarativeContextData *QDeclarativeGuardedContextData::contextData()
-{
- return m_contextData;
-}
-
-void QDeclarativeGuardedContextData::clear()
-{
- if (m_prev) {
- *m_prev = m_next;
- if (m_next) m_next->m_prev = m_prev;
- m_contextData = 0;
- m_next = 0;
- m_prev = 0;
- }
-}
-
-QDeclarativeGuardedContextData &
-QDeclarativeGuardedContextData::operator=(QDeclarativeContextData *d)
-{
- setContextData(d);
- return *this;
-}
-
-QDeclarativeContextData::ContextGuard::ContextGuard()
-: context(0)
-{
-}
-
-QDeclarativeContextData::ContextGuard &QDeclarativeContextData::ContextGuard::operator=(QObject *obj)
-{
- QDeclarativeGuard<QObject>::operator=(obj);
- context.setFlag();
- bindings.notify(); // For alias connections
- return *this;
-}
-
-void QDeclarativeContextData::ContextGuard::objectDestroyed(QObject *)
-{
- if (context->contextObject && !QObjectPrivate::get(context->contextObject)->wasDeleted)
- bindings.notify();
-}
-
-bool QDeclarativeContextData::ContextGuard::wasSet() const
-{
- return context.flag();
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVECONTEXT_P_H
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
deleted file mode 100644
index a746700aa6..0000000000
--- a/src/declarative/qml/qdeclarativecustomparser.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecustomparser_p.h"
-#include "qdeclarativecustomparser_p_p.h"
-
-#include "qdeclarativecompiler_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QDeclarativeScript;
-
-/*!
- \class QDeclarativeCustomParser
- \brief The QDeclarativeCustomParser class allows you to add new arbitrary types to QML.
- \internal
-
- By subclassing QDeclarativeCustomParser, you can add a parser for
- building a particular type.
-
- The subclass must implement compile() and setCustomData(), and register
- itself in the meta type system by calling the macro:
-
- \code
- QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass)
- \endcode
-*/
-
-/*
- \fn QByteArray QDeclarativeCustomParser::compile(const QList<QDeclarativeCustomParserProperty> & properties)
-
- The custom parser processes \a properties, and returns
- a QByteArray containing data meaningful only to the
- custom parser; the type engine will pass this same data to
- setCustomData() when making an instance of the data.
-
- Errors must be reported via the error() functions.
-
- The QByteArray may be cached between executions of the system, so
- it must contain correctly-serialized data (not, for example,
- pointers to stack objects).
-*/
-
-/*
- \fn void QDeclarativeCustomParser::setCustomData(QObject *object, const QByteArray &data)
-
- This function sets \a object to have the properties defined
- by \a data, which is a block of data previously returned by a call
- to compile().
-
- Errors should be reported using qmlInfo(object).
-
- The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE.
-*/
-
-QDeclarativeCustomParserNode
-QDeclarativeCustomParserNodePrivate::fromObject(QDeclarativeScript::Object *root)
-{
- QDeclarativeCustomParserNode rootNode;
- rootNode.d->name = root->typeName;
- rootNode.d->location = root->location.start;
-
- for (Property *p = root->properties.first(); p; p = root->properties.next(p)) {
- rootNode.d->properties << fromProperty(p);
- }
-
- if (root->defaultProperty)
- rootNode.d->properties << fromProperty(root->defaultProperty);
-
- return rootNode;
-}
-
-QDeclarativeCustomParserProperty
-QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeScript::Property *p)
-{
- QDeclarativeCustomParserProperty prop;
- prop.d->name = p->name().toString();
- prop.d->isList = p->values.isMany();
- prop.d->location = p->location.start;
-
- if (p->value) {
- QDeclarativeCustomParserNode node = fromObject(p->value);
- QList<QDeclarativeCustomParserProperty> props = node.properties();
- for (int ii = 0; ii < props.count(); ++ii)
- prop.d->values << QVariant::fromValue(props.at(ii));
- } else {
- for (QDeclarativeScript::Value *v = p->values.first(); v; v = p->values.next(v)) {
- v->type = QDeclarativeScript::Value::Literal;
-
- if(v->object) {
- QDeclarativeCustomParserNode node = fromObject(v->object);
- prop.d->values << QVariant::fromValue(node);
- } else {
- prop.d->values << QVariant::fromValue(v->value);
- }
-
- }
- }
-
- return prop;
-}
-
-QDeclarativeCustomParserNode::QDeclarativeCustomParserNode()
-: d(new QDeclarativeCustomParserNodePrivate)
-{
-}
-
-QDeclarativeCustomParserNode::QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &other)
-: d(new QDeclarativeCustomParserNodePrivate)
-{
- *this = other;
-}
-
-QDeclarativeCustomParserNode &QDeclarativeCustomParserNode::operator=(const QDeclarativeCustomParserNode &other)
-{
- d->name = other.d->name;
- d->properties = other.d->properties;
- d->location = other.d->location;
- return *this;
-}
-
-QDeclarativeCustomParserNode::~QDeclarativeCustomParserNode()
-{
- delete d; d = 0;
-}
-
-QString QDeclarativeCustomParserNode::name() const
-{
- return d->name;
-}
-
-QList<QDeclarativeCustomParserProperty> QDeclarativeCustomParserNode::properties() const
-{
- return d->properties;
-}
-
-QDeclarativeScript::Location QDeclarativeCustomParserNode::location() const
-{
- return d->location;
-}
-
-QDeclarativeCustomParserProperty::QDeclarativeCustomParserProperty()
-: d(new QDeclarativeCustomParserPropertyPrivate)
-{
-}
-
-QDeclarativeCustomParserProperty::QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &other)
-: d(new QDeclarativeCustomParserPropertyPrivate)
-{
- *this = other;
-}
-
-QDeclarativeCustomParserProperty &QDeclarativeCustomParserProperty::operator=(const QDeclarativeCustomParserProperty &other)
-{
- d->name = other.d->name;
- d->isList = other.d->isList;
- d->values = other.d->values;
- d->location = other.d->location;
- return *this;
-}
-
-QDeclarativeCustomParserProperty::~QDeclarativeCustomParserProperty()
-{
- delete d; d = 0;
-}
-
-QString QDeclarativeCustomParserProperty::name() const
-{
- return d->name;
-}
-
-bool QDeclarativeCustomParserProperty::isList() const
-{
- return d->isList;
-}
-
-QDeclarativeScript::Location QDeclarativeCustomParserProperty::location() const
-{
- return d->location;
-}
-
-QList<QVariant> QDeclarativeCustomParserProperty::assignedValues() const
-{
- return d->values;
-}
-
-void QDeclarativeCustomParser::clearErrors()
-{
- exceptions.clear();
-}
-
-/*!
- Reports an error with the given \a description.
-
- This can only be used during the compile() step. For errors during setCustomData(), use qmlInfo().
-
- An error is generated referring to the position of the element in the source file.
-*/
-void QDeclarativeCustomParser::error(const QString& description)
-{
- Q_ASSERT(object);
- QDeclarativeError error;
- QString exceptionDescription;
- error.setLine(object->location.start.line);
- error.setColumn(object->location.start.column);
- error.setDescription(description);
- exceptions << error;
-}
-
-/*!
- Reports an error in parsing \a prop, with the given \a description.
-
- An error is generated referring to the position of \a node in the source file.
-*/
-void QDeclarativeCustomParser::error(const QDeclarativeCustomParserProperty& prop, const QString& description)
-{
- QDeclarativeError error;
- QString exceptionDescription;
- error.setLine(prop.location().line);
- error.setColumn(prop.location().column);
- error.setDescription(description);
- exceptions << error;
-}
-
-/*!
- Reports an error in parsing \a node, with the given \a description.
-
- An error is generated referring to the position of \a node in the source file.
-*/
-void QDeclarativeCustomParser::error(const QDeclarativeCustomParserNode& node, const QString& description)
-{
- QDeclarativeError error;
- QString exceptionDescription;
- error.setLine(node.location().line);
- error.setColumn(node.location().column);
- error.setDescription(description);
- exceptions << error;
-}
-
-/*!
- If \a script is a simply enum expression (eg. Text.AlignLeft),
- returns the integer equivalent (eg. 1).
-
- Otherwise, returns -1.
-*/
-int QDeclarativeCustomParser::evaluateEnum(const QByteArray& script) const
-{
- return compiler->evaluateEnum(script);
-}
-
-/*!
- Resolves \a name to a type, or 0 if it is not a type. This can be used
- to type-check object nodes.
-*/
-const QMetaObject *QDeclarativeCustomParser::resolveType(const QString& name) const
-{
- return compiler->resolveType(name);
-}
-
-/*!
- Rewrites \a value and returns an identifier that can be
- used to construct the binding later. \a name
- is used as the name of the rewritten function.
-*/
-QDeclarativeBinding::Identifier QDeclarativeCustomParser::rewriteBinding(const QDeclarativeScript::Variant &value, const QString& name)
-{
- return compiler->rewriteBinding(value, name);
-}
-
-/*!
- Returns a rewritten \a handler. \a name
- is used as the name of the rewritten function.
-*/
-QString QDeclarativeCustomParser::rewriteSignalHandler(const QDeclarativeScript::Variant &value, const QString &name)
-{
- return compiler->rewriteSignalHandler(value , name);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
deleted file mode 100644
index 92d1ca7af2..0000000000
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECUSTOMPARSER_H
-#define QDECLARATIVECUSTOMPARSER_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 "qdeclarativemetatype_p.h"
-#include "qdeclarativeerror.h"
-#include "qdeclarativescript_p.h"
-#include "qdeclarativebinding_p.h"
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qxmlstream.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeCompiler;
-
-class QDeclarativeCustomParserPropertyPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserProperty
-{
-public:
- QDeclarativeCustomParserProperty();
- QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &);
- QDeclarativeCustomParserProperty &operator=(const QDeclarativeCustomParserProperty &);
- ~QDeclarativeCustomParserProperty();
-
- QString name() const;
- QDeclarativeScript::Location location() const;
-
- bool isList() const;
- // Will be one of QDeclarativeScript::Variant, QDeclarativeCustomParserProperty or
- // QDeclarativeCustomParserNode
- QList<QVariant> assignedValues() const;
-
-private:
- friend class QDeclarativeCustomParserNodePrivate;
- friend class QDeclarativeCustomParserPropertyPrivate;
- QDeclarativeCustomParserPropertyPrivate *d;
-};
-
-class QDeclarativeCustomParserNodePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserNode
-{
-public:
- QDeclarativeCustomParserNode();
- QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &);
- QDeclarativeCustomParserNode &operator=(const QDeclarativeCustomParserNode &);
- ~QDeclarativeCustomParserNode();
-
- QString name() const;
- QDeclarativeScript::Location location() const;
-
- QList<QDeclarativeCustomParserProperty> properties() const;
-
-private:
- friend class QDeclarativeCustomParserNodePrivate;
- QDeclarativeCustomParserNodePrivate *d;
-};
-
-class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser
-{
-public:
- enum Flag {
- NoFlag = 0x00000000,
- AcceptsAttachedProperties = 0x00000001,
- AcceptsSignalHandlers = 0x00000002
- };
- Q_DECLARE_FLAGS(Flags, Flag)
-
- QDeclarativeCustomParser() : compiler(0), object(0), m_flags(NoFlag) {}
- QDeclarativeCustomParser(Flags f) : compiler(0), object(0), m_flags(f) {}
- virtual ~QDeclarativeCustomParser() {}
-
- void clearErrors();
- Flags flags() const { return m_flags; }
-
- virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &)=0;
- virtual void setCustomData(QObject *, const QByteArray &)=0;
-
- QList<QDeclarativeError> errors() const { return exceptions; }
-
-protected:
- void error(const QString& description);
- void error(const QDeclarativeCustomParserProperty&, const QString& description);
- void error(const QDeclarativeCustomParserNode&, const QString& description);
-
- int evaluateEnum(const QByteArray&) const;
-
- const QMetaObject *resolveType(const QString&) const;
-
- QDeclarativeBinding::Identifier rewriteBinding(const QDeclarativeScript::Variant&, const QString&);
- QString rewriteSignalHandler(const QDeclarativeScript::Variant&, const QString&);
-
-private:
- QList<QDeclarativeError> exceptions;
- QDeclarativeCompiler *compiler;
- QDeclarativeScript::Object *object;
- Flags m_flags;
- friend class QDeclarativeCompiler;
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeCustomParser::Flags);
-
-#if 0
-#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
- qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)
-#endif
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeCustomParserProperty)
-Q_DECLARE_METATYPE(QDeclarativeCustomParserNode)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/qml/qdeclarativecustomparser_p_p.h b/src/declarative/qml/qdeclarativecustomparser_p_p.h
deleted file mode 100644
index e7228f07f0..0000000000
--- a/src/declarative/qml/qdeclarativecustomparser_p_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECUSTOMPARSER_P_H
-#define QDECLARATIVECUSTOMPARSER_P_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 "qdeclarativecustomparser_p.h"
-
-#include "qdeclarativescript_p.h"
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeCustomParserNodePrivate
-{
-public:
- QString name;
- QList<QDeclarativeCustomParserProperty> properties;
- QDeclarativeScript::Location location;
-
- static QDeclarativeCustomParserNode fromObject(QDeclarativeScript::Object *);
- static QDeclarativeCustomParserProperty fromProperty(QDeclarativeScript::Property *);
-};
-
-class QDeclarativeCustomParserPropertyPrivate
-{
-public:
- QDeclarativeCustomParserPropertyPrivate()
- : isList(false) {}
-
- QString name;
- bool isList;
- QDeclarativeScript::Location location;
- QList<QVariant> values;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVECUSTOMPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h
deleted file mode 100644
index 0f75d620b8..0000000000
--- a/src/declarative/qml/qdeclarativedata_p.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDATA_P_H
-#define QDECLARATIVEDATA_P_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 <private/qobject_p.h>
-
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-template <class Key, class T> class QHash;
-class QDeclarativeGuardImpl;
-class QDeclarativeCompiledData;
-class QDeclarativeAbstractBinding;
-class QDeclarativeContext;
-class QDeclarativePropertyCache;
-class QDeclarativeContextData;
-class QDeclarativeNotifier;
-class QDeclarativeDataExtended;
-class QDeclarativeNotifierEndpoint;
-// This class is structured in such a way, that simply zero'ing it is the
-// default state for elemental object allocations. This is crucial in the
-// workings of the QDeclarativeInstruction::CreateSimpleObject instruction.
-// Don't change anything here without first considering that case!
-class Q_DECLARATIVE_EXPORT QDeclarativeData : public QAbstractDeclarativeData
-{
-public:
- QDeclarativeData()
- : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false),
- hasTaintedV8Object(false), notifyList(0), context(0), outerContext(0), bindings(0),
- nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0),
- lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), v8objectid(0),
- propertyCache(0), guards(0), extendedData(0) {
- init();
- }
-
- static inline void init() {
- QAbstractDeclarativeData::destroyed = destroyed;
- QAbstractDeclarativeData::parentChanged = parentChanged;
- QAbstractDeclarativeData::objectNameChanged = objectNameChanged;
- QAbstractDeclarativeData::signalEmitted = signalEmitted;
- }
-
- static void destroyed(QAbstractDeclarativeData *, QObject *);
- static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *);
- static void objectNameChanged(QAbstractDeclarativeData *, QObject *);
- static void signalEmitted(QAbstractDeclarativeData *, QObject *, int, void **);
-
- void destroyed(QObject *);
- void parentChanged(QObject *, QObject *);
- void objectNameChanged(QObject *);
-
- void setImplicitDestructible() {
- if (!explicitIndestructibleSet) indestructible = false;
- }
-
- quint32 ownMemory:1;
- quint32 ownContext:1;
- quint32 indestructible:1;
- quint32 explicitIndestructibleSet:1;
- quint32 hasTaintedV8Object:1;
- quint32 dummy:27;
-
- struct NotifyList {
- quint64 connectionMask;
-
- quint16 maximumTodoIndex;
- quint16 notifiesSize;
-
- QDeclarativeNotifierEndpoint *todo;
- QDeclarativeNotifierEndpoint**notifies;
- void layout();
- private:
- void layout(QDeclarativeNotifierEndpoint*);
- };
- NotifyList *notifyList;
-
- inline QDeclarativeNotifierEndpoint *notify(int index);
- void addNotify(int index, QDeclarativeNotifierEndpoint *);
-
- // The context that created the C++ object
- QDeclarativeContextData *context;
- // The outermost context in which this object lives
- QDeclarativeContextData *outerContext;
-
- QDeclarativeAbstractBinding *bindings;
-
- // Linked list for QDeclarativeContext::contextObjects
- QDeclarativeData *nextContextObject;
- QDeclarativeData**prevContextObject;
-
- int bindingBitsSize;
- quint32 *bindingBits;
- bool hasBindingBit(int) const;
- void clearBindingBit(int);
- void setBindingBit(QObject *obj, int);
-
- ushort lineNumber;
- ushort columnNumber;
-
- QDeclarativeCompiledData *deferredComponent; // Can't this be found from the context?
- unsigned int deferredIdx;
-
- quint32 v8objectid;
- v8::Persistent<v8::Object> v8object;
-
- QDeclarativePropertyCache *propertyCache;
-
- QDeclarativeGuardImpl *guards;
-
- static QDeclarativeData *get(const QObject *object, bool create = false) {
- QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
- if (priv->wasDeleted) {
- Q_ASSERT(!create);
- return 0;
- } else if (priv->declarativeData) {
- return static_cast<QDeclarativeData *>(priv->declarativeData);
- } else if (create) {
- priv->declarativeData = new QDeclarativeData;
- return static_cast<QDeclarativeData *>(priv->declarativeData);
- } else {
- return 0;
- }
- }
-
- bool hasExtendedData() const { return extendedData != 0; }
- QDeclarativeNotifier *objectNameNotifier() const;
- QHash<int, QObject *> *attachedProperties() const;
-
-private:
- // For objectNameNotifier and attachedProperties
- mutable QDeclarativeDataExtended *extendedData;
-};
-
-QDeclarativeNotifierEndpoint *QDeclarativeData::notify(int index)
-{
- Q_ASSERT(index <= 0xFFFF);
-
- if (!notifyList || !(notifyList->connectionMask & (1ULL << quint64(index % 64)))) {
- return 0;
- } else if (index < notifyList->notifiesSize) {
- return notifyList->notifies[index];
- } else if (index <= notifyList->maximumTodoIndex) {
- notifyList->layout();
- }
-
- if (index < notifyList->notifiesSize) {
- return notifyList->notifies[index];
- } else {
- return 0;
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEDATA_P_H
diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp
deleted file mode 100644
index f7d5be3601..0000000000
--- a/src/declarative/qml/qdeclarativedirparser.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativedirparser_p.h"
-#include "qdeclarativeerror.h"
-#include "qdeclarativeglobal_p.h"
-
-#include <QtCore/QTextStream>
-#include <QtCore/QFile>
-#include <QtCore/QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeDirParser::QDeclarativeDirParser()
- : _isParsed(false)
-{
-}
-
-QDeclarativeDirParser::~QDeclarativeDirParser()
-{
-}
-
-QUrl QDeclarativeDirParser::url() const
-{
- return _url;
-}
-
-void QDeclarativeDirParser::setUrl(const QUrl &url)
-{
- _url = url;
-}
-
-QString QDeclarativeDirParser::fileSource() const
-{
- return _filePathSouce;
-}
-
-void QDeclarativeDirParser::setFileSource(const QString &filePath)
-{
- _filePathSouce = filePath;
-}
-
-QString QDeclarativeDirParser::source() const
-{
- return _source;
-}
-
-void QDeclarativeDirParser::setSource(const QString &source)
-{
- _isParsed = false;
- _source = source;
-}
-
-bool QDeclarativeDirParser::isParsed() const
-{
- return _isParsed;
-}
-
-bool QDeclarativeDirParser::parse()
-{
- if (_isParsed)
- return true;
-
- _isParsed = true;
- _errors.clear();
- _plugins.clear();
- _components.clear();
- _scripts.clear();
-
- if (_source.isEmpty() && !_filePathSouce.isEmpty()) {
- QFile file(_filePathSouce);
- if (!QDeclarative_isFileCaseCorrect(_filePathSouce)) {
- QDeclarativeError error;
- error.setDescription(QString::fromUtf8("cannot load module \"$$URI$$\": File name case mismatch for \"%1\"").arg(_filePathSouce));
- _errors.prepend(error);
- return false;
- } else if (file.open(QFile::ReadOnly)) {
- _source = QString::fromUtf8(file.readAll());
- } else {
- QDeclarativeError error;
- error.setDescription(QString::fromUtf8("module \"$$URI$$\" definition \"%1\" not readable").arg(_filePathSouce));
- _errors.prepend(error);
- return false;
- }
- }
-
- QTextStream stream(&_source);
- int lineNumber = 0;
-
- forever {
- ++lineNumber;
-
- const QString line = stream.readLine();
- if (line.isNull())
- break;
-
- QString sections[3];
- int sectionCount = 0;
-
- int index = 0;
- const int length = line.length();
-
- while (index != length) {
- const QChar ch = line.at(index);
-
- if (ch.isSpace()) {
- do { ++index; }
- while (index != length && line.at(index).isSpace());
-
- } else if (ch == QLatin1Char('#')) {
- // recognized a comment
- break;
-
- } else {
- const int start = index;
-
- do { ++index; }
- while (index != length && !line.at(index).isSpace());
-
- const QString lexeme = line.mid(start, index - start);
-
- if (sectionCount >= 3) {
- reportError(lineNumber, start, QLatin1String("unexpected token"));
-
- } else {
- sections[sectionCount++] = lexeme;
- }
- }
- }
-
- if (sectionCount == 0) {
- continue; // no sections, no party.
-
- } else if (sections[0] == QLatin1String("plugin")) {
- if (sectionCount < 2) {
- reportError(lineNumber, -1,
- QString::fromUtf8("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1));
-
- continue;
- }
-
- const Plugin entry(sections[1], sections[2]);
-
- _plugins.append(entry);
-
- } else if (sections[0] == QLatin1String("internal")) {
- if (sectionCount != 3) {
- reportError(lineNumber, -1,
- QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
- continue;
- }
- Component entry(sections[1], sections[2], -1, -1);
- entry.internal = true;
- _components.append(entry);
- } else if (sections[0] == QLatin1String("typeinfo")) {
- if (sectionCount != 2) {
- reportError(lineNumber, -1,
- QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
- continue;
- }
-#ifdef QT_CREATOR
- TypeInfo typeInfo(sections[1]);
- _typeInfos.append(typeInfo);
-#endif
-
- } else if (sectionCount == 2) {
- // No version specified (should only be used for relative qmldir files)
- const Component entry(sections[0], sections[1], -1, -1);
- _components.append(entry);
- } else if (sectionCount == 3) {
- const QString &version = sections[1];
- const int dotIndex = version.indexOf(QLatin1Char('.'));
-
- if (dotIndex == -1) {
- reportError(lineNumber, -1, QLatin1String("expected '.'"));
- } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) {
- reportError(lineNumber, -1, QLatin1String("unexpected '.'"));
- } else {
- bool validVersionNumber = false;
- const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber);
-
- if (validVersionNumber) {
- const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber);
-
- if (validVersionNumber) {
- const QString &fileName = sections[2];
-
- if (fileName.endsWith(QLatin1String(".js"))) {
- // A 'js' extension indicates a namespaced script import
- const Script entry(sections[0], fileName, majorVersion, minorVersion);
- _scripts.append(entry);
- } else {
- const Component entry(sections[0], fileName, majorVersion, minorVersion);
- _components.append(entry);
- }
- }
- }
- }
- } else {
- reportError(lineNumber, -1,
- QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount));
- }
- }
-
- return hasError();
-}
-
-void QDeclarativeDirParser::reportError(int line, int column, const QString &description)
-{
- QDeclarativeError error;
- error.setUrl(_url);
- error.setLine(line);
- error.setColumn(column);
- error.setDescription(description);
- _errors.append(error);
-}
-
-bool QDeclarativeDirParser::hasError() const
-{
- if (! _errors.isEmpty())
- return true;
-
- return false;
-}
-
-QList<QDeclarativeError> QDeclarativeDirParser::errors(const QString &uri) const
-{
- QList<QDeclarativeError> errors = _errors;
- for (int i = 0; i < errors.size(); ++i) {
- QDeclarativeError &e = errors[i];
- QString description = e.description();
- description.replace(QLatin1String("$$URI$$"), uri);
- e.setDescription(description);
- }
- return errors;
-}
-
-QList<QDeclarativeDirParser::Plugin> QDeclarativeDirParser::plugins() const
-{
- return _plugins;
-}
-
-QList<QDeclarativeDirParser::Component> QDeclarativeDirParser::components() const
-{
- return _components;
-}
-
-QList<QDeclarativeDirParser::Script> QDeclarativeDirParser::scripts() const
-{
- return _scripts;
-}
-
-#ifdef QT_CREATOR
-QList<QDeclarativeDirParser::TypeInfo> QDeclarativeDirParser::typeInfos() const
-{
- return _typeInfos;
-}
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativedirparser_p.h b/src/declarative/qml/qdeclarativedirparser_p.h
deleted file mode 100644
index 40b4b57a12..0000000000
--- a/src/declarative/qml/qdeclarativedirparser_p.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDIRPARSER_P_H
-#define QDECLARATIVEDIRPARSER_P_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/QUrl>
-#include <QtCore/QHash>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeError;
-class QDeclarativeDirParser
-{
- Q_DISABLE_COPY(QDeclarativeDirParser)
-
-public:
- QDeclarativeDirParser();
- ~QDeclarativeDirParser();
-
- QUrl url() const;
- void setUrl(const QUrl &url);
-
- QString fileSource() const;
- void setFileSource(const QString &filePath);
-
- QString source() const;
- void setSource(const QString &source);
-
- bool isParsed() const;
- bool parse();
-
- bool hasError() const;
- QList<QDeclarativeError> errors(const QString &uri) const;
-
- struct Plugin
- {
- Plugin() {}
-
- Plugin(const QString &name, const QString &path)
- : name(name), path(path) {}
-
- QString name;
- QString path;
- };
-
- struct Component
- {
- Component()
- : majorVersion(0), minorVersion(0), internal(false) {}
-
- Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
- : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
- internal(false) {}
-
- QString typeName;
- QString fileName;
- int majorVersion;
- int minorVersion;
- bool internal;
- };
-
- struct Script
- {
- Script()
- : majorVersion(0), minorVersion(0) {}
-
- Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion)
- : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
-
- QString nameSpace;
- QString fileName;
- int majorVersion;
- int minorVersion;
- };
-
- QList<Component> components() const;
- QList<Script> scripts() const;
- QList<Plugin> plugins() const;
-
-#ifdef QT_CREATOR
- struct TypeInfo
- {
- TypeInfo() {}
- TypeInfo(const QString &fileName)
- : fileName(fileName) {}
-
- QString fileName;
- };
-
- QList<TypeInfo> typeInfos() const;
-#endif
-
-private:
- void reportError(int line, int column, const QString &message);
-
-private:
- QList<QDeclarativeError> _errors;
- QUrl _url;
- QString _source;
- QString _filePathSouce;
- QList<Component> _components;
- QList<Script> _scripts;
- QList<Plugin> _plugins;
-#ifdef QT_CREATOR
- QList<TypeInfo> _typeInfos;
-#endif
- unsigned _isParsed: 1;
-};
-
-typedef QList<QDeclarativeDirParser::Component> QDeclarativeDirComponents;
-typedef QList<QDeclarativeDirParser::Script> QDeclarativeDirScripts;
-
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEDIRPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
deleted file mode 100644
index 963bec57b5..0000000000
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ /dev/null
@@ -1,1854 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativeengine.h"
-#include "qdeclarativecomponentattached_p.h"
-
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativecompiler_p.h"
-#include "qdeclarative.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativeexpression.h"
-#include "qdeclarativecomponent.h"
-#include "qdeclarativebinding_p_p.h"
-#include "qdeclarativevme_p.h"
-#include <private/qdeclarativeenginedebugservice_p.h>
-#include "qdeclarativestringconverters_p.h"
-#include "qdeclarativexmlhttprequest_p.h"
-#include "qdeclarativescriptstring.h"
-#include "qdeclarativeglobal_p.h"
-#include "qdeclarativelistmodel_p.h"
-#include "qdeclarativeworkerscript_p.h"
-#include "qdeclarativecomponent_p.h"
-#include "qdeclarativenetworkaccessmanagerfactory.h"
-#include "qdeclarativeimageprovider.h"
-#include "qdeclarativedirparser_p.h"
-#include "qdeclarativeextensioninterface.h"
-#include "qdeclarativelist_p.h"
-#include "qdeclarativetypenamecache_p.h"
-#include "qdeclarativenotifier_p.h"
-#include <private/qdeclarativeprofilerservice_p.h>
-#include <private/qdeclarativeapplication_p.h>
-#include <private/qv8debugservice_p.h>
-#include <private/qdebugmessageservice_p.h>
-#include "qdeclarativeincubator.h"
-#include <private/qv8profilerservice_p.h>
-
-#include <QtCore/qstandardpaths.h>
-#include <QtCore/qsettings.h>
-
-#include <QtCore/qmetaobject.h>
-#include <QNetworkAccessManager>
-#include <QDebug>
-#include <QMetaObject>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qmutex.h>
-#include <QtNetwork/qnetworkconfigmanager.h>
-
-#include <private/qobject_p.h>
-
-#include <private/qdeclarativelocale_p.h>
-
-#ifdef Q_OS_WIN // for %APPDATA%
-#include <qt_windows.h>
-#include <qlibrary.h>
-#include <windows.h>
-
-#define CSIDL_APPDATA 0x001a // <username>\Application Data
-#endif
-
-Q_DECLARE_METATYPE(QDeclarativeProperty)
-
-QT_BEGIN_NAMESPACE
-
-void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor)
-{
- QDeclarativeEnginePrivate::registerBaseTypes(uri, versionMajor, versionMinor);
- QDeclarativeValueTypeFactory::registerBaseTypes(uri, versionMajor, versionMinor);
-}
-
-/*!
- \qmlclass QtObject QObject
- \ingroup qml-utility-elements
- \since 4.7
- \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 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 QtObject::objectName
- 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 QtQuick 2.0
-
- Item {
- width: 200; height: 200
-
- 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
-*/
-
-bool QDeclarativeEnginePrivate::qml_debugging_enabled = false;
-
-void QDeclarativeEnginePrivate::registerBaseTypes(const char *uri, int versionMajor, int versionMinor)
-{
- qmlRegisterType<QDeclarativeComponent>(uri,versionMajor,versionMinor,"Component");
- qmlRegisterType<QObject>(uri,versionMajor,versionMinor,"QtObject");
- qmlRegisterType<QDeclarativeListElement>(uri, versionMajor, versionMinor,"ListElement");
- qmlRegisterCustomType<QDeclarativeListModel>(uri, versionMajor, versionMinor,"ListModel", new QDeclarativeListModelParser);
- qmlRegisterType<QDeclarativeWorkerScript>(uri,versionMajor,versionMinor,"WorkerScript");
-}
-
-void QDeclarativeEnginePrivate::defineModule()
-{
- registerBaseTypes("QtQuick", 2, 0);
- qmlRegisterType<QDeclarativeBinding>();
- qmlRegisterUncreatableType<QDeclarativeApplication>("QtQuick",2,0,"Application", QDeclarativeApplication::tr("Application is an abstract class"));
- qmlRegisterUncreatableType<QDeclarativeLocale>("QtQuick",2,0,"Locale",QDeclarativeEngine::tr("Locale cannot be instantiated. Use Qt.locale()"));
-}
-
-/*!
-\qmlclass Qt QDeclarativeEnginePrivate
- \ingroup qml-utility-elements
-\brief The QML global Qt object provides useful enums and functions from Qt.
-
-\keyword QmlGlobalQtObject
-
-\brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files.
-
-The \c Qt object is a global object with utility functions, properties and enums.
-
-It is not instantiable; to use it, call the members of the global \c Qt object directly.
-For example:
-
-\qml
-import QtQuick 2.0
-
-Text {
- color: Qt.rgba(1, 0, 0, 1)
- text: Qt.md5("hello, world")
-}
-\endqml
-
-
-\section1 Enums
-
-The Qt object contains the enums available in the \l {Qt Namespace}. For example, you can access
-the \l Qt::LeftButton and \l Qt::RightButton enum values as \c Qt.LeftButton and \c Qt.RightButton.
-
-
-\section1 Types
-The Qt object also contains helper functions for creating objects of specific
-data types. This is primarily useful when setting the properties of an item
-when the property has one of the following types:
-
-\list
-\o \c color - use \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::hsla()}{Qt.hsla()}, \l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()}
-\o \c rect - use \l{Qt::rect()}{Qt.rect()}
-\o \c point - use \l{Qt::point()}{Qt.point()}
-\o \c size - use \l{Qt::size()}{Qt.size()}
-\o \c vector3d - use \l{Qt::vector3d()}{Qt.vector3d()}
-\endlist
-
-There are also string based constructors for these types. See \l{qdeclarativebasictypes.html}{QML Basic Types} for more information.
-
-\section1 Date/Time Formatters
-
-The Qt object contains several functions for formatting QDateTime, QDate and QTime values.
-
-\list
- \o \l{Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)}
- \o \l{Qt::formatDate}{string Qt.formatDate(datetime date, variant format)}
- \o \l{Qt::formatTime}{string Qt.formatTime(datetime date, variant format)}
-\endlist
-
-The format specification is described at \l{Qt::formatDateTime}{Qt.formatDateTime}.
-
-
-\section1 Dynamic Object Creation
-The following functions on the global object allow you to dynamically create QML
-items from files or strings. See \l{Dynamic Object Management in QML} for an overview
-of their use.
-
-\list
- \o \l{Qt::createComponent()}{object Qt.createComponent(url)}
- \o \l{Qt::createQmlObject()}{object Qt.createQmlObject(string qml, object parent, string filepath)}
-\endlist
-*/
-
-
-/*!
- \qmlproperty object Qt::application
- \since QtQuick 1.1
-
- The \c application object provides access to global application state
- properties shared by many QML components.
-
- Its properties are:
-
- \table
- \row
- \o \c application.active
- \o
- This read-only property indicates whether the application is the top-most and focused
- application, and the user is able to interact with the application. The property
- is false when the application is in the background, the device keylock or screen
- saver is active, the screen backlight is turned off, or the global system dialog
- is being displayed on top of the application. It can be used for stopping and
- pausing animations, timers and active processing of data in order to save device
- battery power and free device memory and processor load when the application is not
- active.
-
- \row
- \o \c application.layoutDirection
- \o
- This read-only property can be used to query the default layout direction of the
- application. On system start-up, the default layout direction depends on the
- application's language. The property has a value of \c Qt.RightToLeft in locales
- where text and graphic elements are read from right to left, and \c Qt.LeftToRight
- where the reading direction flows from left to right. You can bind to this
- property to customize your application layouts to support both layout directions.
-
- Possible values are:
-
- \list
- \o Qt.LeftToRight - Text and graphics elements should be positioned
- from left to right.
- \o Qt.RightToLeft - Text and graphics elements should be positioned
- from right to left.
- \endlist
-
- \row
- \o \c application.inputPanel
- \o
- This read-only property allows access to application's QInputPanel object
- and all its properties and slots. See the QInputPanel documentation for
- further details. Deprecated in favor of Qt.InputMethod
- \endtable
-
- The following example uses the \c application object to indicate
- whether the application is currently active:
-
- \snippet doc/src/snippets/declarative/application.qml document
-
- \qmlproperty object Qt::inputMethod
- \since QtQuick 2.0
-
- The \c inputMethod object allows access to application's QInputMethod object
- and all its properties and slots. See the QInputMethod documentation for
- further details.
-*/
-
-
-/*!
-\qmlmethod object Qt::include(string url, jsobject callback)
-
-Includes another JavaScript file. This method can only be used from within JavaScript files,
-and not regular QML files.
-
-This imports all functions from \a url into the current script's namespace.
-
-Qt.include() returns an object that describes the status of the operation. The object has
-a single property, \c {status}, that is set to one of the following values:
-
-\table
-\header \o Symbol \o Value \o Description
-\row \o result.OK \o 0 \o The include completed successfully.
-\row \o result.LOADING \o 1 \o Data is being loaded from the network.
-\row \o result.NETWORK_ERROR \o 2 \o A network error occurred while fetching the url.
-\row \o result.EXCEPTION \o 3 \o A JavaScript exception occurred while executing the included code.
-An additional \c exception property will be set in this case.
-\endtable
-
-The \c status property will be updated as the operation progresses.
-
-If provided, \a callback is invoked when the operation completes. The callback is passed
-the same object as is returned from the Qt.include() call.
-*/
-// Qt.include() is implemented in qv8include.cpp
-
-
-QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
-: propertyCapture(0), rootContext(0), isDebugging(false),
- outputWarningsToStdErr(true), sharedContext(0), sharedScope(0),
- cleanup(0), erroredBindings(0), inProgressCreations(0),
- workerScriptEngine(0), activeVME(0),
- networkAccessManager(0), networkAccessManagerFactory(0),
- scarceResourcesRefCount(0), typeLoader(e), importDatabase(e), uniqueId(1),
- incubatorCount(0), incubationController(0), mutex(QMutex::Recursive)
-{
-}
-
-QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate()
-{
- if (inProgressCreations)
- qWarning() << QDeclarativeEngine::tr("There are still \"%1\" items in the process of being created at engine destruction.").arg(inProgressCreations);
-
- while (cleanup) {
- QDeclarativeCleanup *c = cleanup;
- cleanup = c->next;
- if (cleanup) cleanup->prev = &cleanup;
- c->next = 0;
- c->prev = 0;
- c->clear();
- }
-
- doDeleteInEngineThread();
-
- if (incubationController) incubationController->d = 0;
- incubationController = 0;
-
- delete rootContext;
- rootContext = 0;
-
- for(QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.constBegin(); iter != m_compositeTypes.constEnd(); ++iter)
- (*iter)->release();
- for(QHash<const QMetaObject *, QDeclarativePropertyCache *>::Iterator iter = propertyCache.begin(); iter != propertyCache.end(); ++iter)
- (*iter)->release();
- for(QHash<QPair<QDeclarativeType *, int>, QDeclarativePropertyCache *>::Iterator iter = typePropertyCache.begin(); iter != typePropertyCache.end(); ++iter)
- (*iter)->release();
- for(QHash<QDeclarativeMetaType::ModuleApi, QDeclarativeMetaType::ModuleApiInstance *>::Iterator iter = moduleApiInstances.begin(); iter != moduleApiInstances.end(); ++iter) {
- delete (*iter)->qobjectApi;
- delete *iter;
- }
-}
-
-void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o)
-{
- QObjectPrivate *p = QObjectPrivate::get(o);
- if (p->declarativeData) {
- QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
- if (d->ownContext && d->context) {
- d->context->destroy();
- d->context = 0;
- }
- }
-}
-
-void QDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o)
-{
- static_cast<QDeclarativeData *>(d)->destroyed(o);
-}
-
-void QDeclarativeData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p)
-{
- static_cast<QDeclarativeData *>(d)->parentChanged(o, p);
-}
-
-void QDeclarativeData::objectNameChanged(QAbstractDeclarativeData *d, QObject *o)
-{
- static_cast<QDeclarativeData *>(d)->objectNameChanged(o);
-}
-
-void QDeclarativeData::signalEmitted(QAbstractDeclarativeData *, QObject *object, int index, void **)
-{
- QDeclarativeData *ddata = QDeclarativeData::get(object, false);
- if (!ddata) return; // Probably being deleted
-
- QDeclarativeNotifierEndpoint *ep = ddata->notify(index);
- if (ep) QDeclarativeNotifier::emitNotify(ep);
-}
-
-void QDeclarativeEnginePrivate::init()
-{
- Q_Q(QDeclarativeEngine);
-
- static bool firstTime = true;
- if (firstTime) {
- qmlRegisterType<QDeclarativeComponent>("QML", 1, 0, "Component");
-
- firstTime = false;
- }
-
- qRegisterMetaType<QVariant>("QVariant");
- qRegisterMetaType<QDeclarativeScriptString>("QDeclarativeScriptString");
- qRegisterMetaType<QJSValue>("QJSValue");
- qRegisterMetaType<QDeclarativeComponent::Status>("QDeclarativeComponent::Status");
- qRegisterMetaType<QList<QObject*> >("QList<QObject*>");
- qRegisterMetaType<QList<int> >("QList<int>");
- qRegisterMetaType<QDeclarativeV8Handle>("QDeclarativeV8Handle");
-
- QDeclarativeData::init();
-
- v8engine()->setEngine(q);
-
- rootContext = new QDeclarativeContext(q,true);
-
- if (QCoreApplication::instance()->thread() == q->thread() &&
- QDeclarativeEngineDebugService::isDebuggingEnabled()) {
- isDebugging = true;
- QDeclarativeEngineDebugService::instance()->addEngine(q);
- QV8DebugService::initialize(v8engine());
- QV8ProfilerService::initialize();
- QDeclarativeProfilerService::initialize();
- QDebugMessageService::instance();
- }
-
- QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
- offlineStoragePath = dataLocation.replace(QLatin1Char('/'), QDir::separator()) +
- QDir::separator() + QLatin1String("QML") +
- QDir::separator() + QLatin1String("OfflineStorage");
-}
-
-QDeclarativeWorkerScriptEngine *QDeclarativeEnginePrivate::getWorkerScriptEngine()
-{
- Q_Q(QDeclarativeEngine);
- if (!workerScriptEngine)
- workerScriptEngine = new QDeclarativeWorkerScriptEngine(q);
- return workerScriptEngine;
-}
-
-/*!
- \class QDeclarativeEngine
- \since 4.7
- \brief The QDeclarativeEngine class provides an environment for instantiating QML components.
- \mainclass
-
- Each QML component is instantiated in a QDeclarativeContext.
- QDeclarativeContext's are essential for passing data to QML
- components. In QML, contexts are arranged hierarchically and this
- hierarchy is managed by the QDeclarativeEngine.
-
- Prior to creating any QML components, an application must have
- created a QDeclarativeEngine to gain access to a QML context. The
- following example shows how to create a simple Text item.
-
- \code
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nText { text: \"Hello world!\" }", QUrl());
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create());
-
- //add item to view, etc
- ...
- \endcode
-
- In this case, the Text item will be created in the engine's
- \l {QDeclarativeEngine::rootContext()}{root context}.
-
- \sa QDeclarativeComponent QDeclarativeContext
-*/
-
-/*!
- Create a new QDeclarativeEngine with the given \a parent.
-*/
-QDeclarativeEngine::QDeclarativeEngine(QObject *parent)
-: QJSEngine(*new QDeclarativeEnginePrivate(this), parent)
-{
- Q_D(QDeclarativeEngine);
- d->init();
-}
-
-/*!
- Destroys the QDeclarativeEngine.
-
- Any QDeclarativeContext's created on this engine will be
- invalidated, but not destroyed (unless they are parented to the
- QDeclarativeEngine object).
-*/
-QDeclarativeEngine::~QDeclarativeEngine()
-{
- Q_D(QDeclarativeEngine);
- if (d->isDebugging) {
- QDeclarativeEngineDebugService::instance()->remEngine(this);
- }
-
- // if we are the parent of any of the qobject module api instances,
- // we need to remove them from our internal list, in order to prevent
- // a segfault in engine private dtor.
- QList<QDeclarativeMetaType::ModuleApi> keys = d->moduleApiInstances.keys();
- QObject *currQObjectApi = 0;
- QDeclarativeMetaType::ModuleApiInstance *currInstance = 0;
- foreach (const QDeclarativeMetaType::ModuleApi &key, keys) {
- currInstance = d->moduleApiInstances.value(key);
- currQObjectApi = currInstance->qobjectApi;
- if (this->children().contains(currQObjectApi)) {
- delete currQObjectApi;
- delete currInstance;
- d->moduleApiInstances.remove(key);
- }
- }
-
- // ensure we clean up QObjects with JS ownership
- d->v8engine()->gc();
-
- if (d->incubationController)
- d->incubationController->d = 0;
-}
-
-/*! \fn void QDeclarativeEngine::quit()
- This signal is emitted when the QML loaded by the engine would like to quit.
- */
-
-/*! \fn void QDeclarativeEngine::warnings(const QList<QDeclarativeError> &warnings)
- This signal is emitted when \a warnings messages are generated by QML.
- */
-
-/*!
- Clears the engine's internal component cache.
-
- Normally the QDeclarativeEngine caches components loaded from qml
- files. This method clears this cache and forces the component to be
- reloaded.
- */
-void QDeclarativeEngine::clearComponentCache()
-{
- Q_D(QDeclarativeEngine);
- d->typeLoader.clearCache();
-}
-
-/*!
- Returns the engine's root context.
-
- The root context is automatically created by the QDeclarativeEngine.
- Data that should be available to all QML component instances
- instantiated by the engine should be put in the root context.
-
- Additional data that should only be available to a subset of
- component instances should be added to sub-contexts parented to the
- root context.
-*/
-QDeclarativeContext *QDeclarativeEngine::rootContext() const
-{
- Q_D(const QDeclarativeEngine);
- return d->rootContext;
-}
-
-/*!
- Sets the \a factory to use for creating QNetworkAccessManager(s).
-
- QNetworkAccessManager is used for all network access by QML. By
- implementing a factory it is possible to create custom
- QNetworkAccessManager with specialized caching, proxy and cookie
- support.
-
- The factory must be set before executing the engine.
-*/
-void QDeclarativeEngine::setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *factory)
-{
- Q_D(QDeclarativeEngine);
- QMutexLocker locker(&d->mutex);
- d->networkAccessManagerFactory = factory;
-}
-
-/*!
- Returns the current QDeclarativeNetworkAccessManagerFactory.
-
- \sa setNetworkAccessManagerFactory()
-*/
-QDeclarativeNetworkAccessManagerFactory *QDeclarativeEngine::networkAccessManagerFactory() const
-{
- Q_D(const QDeclarativeEngine);
- return d->networkAccessManagerFactory;
-}
-
-void QDeclarativeEnginePrivate::registerFinalizeCallback(QObject *obj, int index)
-{
- if (activeVME) {
- activeVME->finalizeCallbacks.append(qMakePair(QDeclarativeGuard<QObject>(obj), index));
- } else {
- void *args[] = { 0 };
- QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, args);
- }
-}
-
-QNetworkAccessManager *QDeclarativeEnginePrivate::createNetworkAccessManager(QObject *parent) const
-{
- QMutexLocker locker(&mutex);
- QNetworkAccessManager *nam;
- if (networkAccessManagerFactory) {
- nam = networkAccessManagerFactory->create(parent);
- } else {
- nam = new QNetworkAccessManager(parent);
- }
-
- return nam;
-}
-
-QNetworkAccessManager *QDeclarativeEnginePrivate::getNetworkAccessManager() const
-{
- Q_Q(const QDeclarativeEngine);
- if (!networkAccessManager)
- networkAccessManager = createNetworkAccessManager(const_cast<QDeclarativeEngine*>(q));
- return networkAccessManager;
-}
-
-/*!
- Returns a common QNetworkAccessManager which can be used by any QML
- element instantiated by this engine.
-
- If a QDeclarativeNetworkAccessManagerFactory has been set and a
- QNetworkAccessManager has not yet been created, the
- QDeclarativeNetworkAccessManagerFactory will be used to create the
- QNetworkAccessManager; otherwise the returned QNetworkAccessManager
- will have no proxy or cache set.
-
- \sa setNetworkAccessManagerFactory()
-*/
-QNetworkAccessManager *QDeclarativeEngine::networkAccessManager() const
-{
- Q_D(const QDeclarativeEngine);
- return d->getNetworkAccessManager();
-}
-
-/*!
-
- Sets the \a provider to use for images requested via the \e
- image: url scheme, with host \a providerId. The QDeclarativeEngine
- takes ownership of \a provider.
-
- Image providers enable support for pixmap and threaded image
- requests. See the QDeclarativeImageProvider documentation for details on
- implementing and using image providers.
-
- All required image providers should be added to the engine before any
- QML sources files are loaded.
-
- \sa removeImageProvider()
-*/
-void QDeclarativeEngine::addImageProvider(const QString &providerId, QDeclarativeImageProvider *provider)
-{
- Q_D(QDeclarativeEngine);
- QMutexLocker locker(&d->mutex);
- d->imageProviders.insert(providerId.toLower(), QSharedPointer<QDeclarativeImageProvider>(provider));
-}
-
-/*!
- Returns the QDeclarativeImageProvider set for \a providerId.
-
- Returns the provider if it was found; otherwise returns 0.
-*/
-QDeclarativeImageProvider *QDeclarativeEngine::imageProvider(const QString &providerId) const
-{
- Q_D(const QDeclarativeEngine);
- QMutexLocker locker(&d->mutex);
- return d->imageProviders.value(providerId).data();
-}
-
-/*!
- Removes the QDeclarativeImageProvider for \a providerId.
-
- \sa addImageProvider()
-*/
-void QDeclarativeEngine::removeImageProvider(const QString &providerId)
-{
- Q_D(QDeclarativeEngine);
- QMutexLocker locker(&d->mutex);
- d->imageProviders.take(providerId);
-}
-
-QDeclarativeImageProvider::ImageType QDeclarativeEnginePrivate::getImageProviderType(const QUrl &url)
-{
- QMutexLocker locker(&mutex);
- QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
- locker.unlock();
- if (provider)
- return provider->imageType();
- return QDeclarativeImageProvider::Invalid;
-}
-
-QDeclarativeTextureFactory *QDeclarativeEnginePrivate::getTextureFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
-{
- QMutexLocker locker(&mutex);
- QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
- locker.unlock();
- if (provider) {
- QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1);
- return provider->requestTexture(imageId, size, req_size);
- }
- return 0;
-}
-
-QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
-{
- QMutexLocker locker(&mutex);
- QImage image;
- QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
- locker.unlock();
- if (provider) {
- QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1);
- image = provider->requestImage(imageId, size, req_size);
- }
- return image;
-}
-
-QPixmap QDeclarativeEnginePrivate::getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
-{
- QMutexLocker locker(&mutex);
- QPixmap pixmap;
- QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
- locker.unlock();
- if (provider) {
- QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1);
- pixmap = provider->requestPixmap(imageId, size, req_size);
- }
- return pixmap;
-}
-
-/*!
- Return the base URL for this engine. The base URL is only used to
- resolve components when a relative URL is passed to the
- QDeclarativeComponent constructor.
-
- If a base URL has not been explicitly set, this method returns the
- application's current working directory.
-
- \sa setBaseUrl()
-*/
-QUrl QDeclarativeEngine::baseUrl() const
-{
- Q_D(const QDeclarativeEngine);
- if (d->baseUrl.isEmpty()) {
- return QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
- } else {
- return d->baseUrl;
- }
-}
-
-/*!
- Set the base URL for this engine to \a url.
-
- \sa baseUrl()
-*/
-void QDeclarativeEngine::setBaseUrl(const QUrl &url)
-{
- Q_D(QDeclarativeEngine);
- d->baseUrl = url;
-}
-
-/*!
- Returns true if warning messages will be output to stderr in addition
- to being emitted by the warnings() signal, otherwise false.
-
- The default value is true.
-*/
-bool QDeclarativeEngine::outputWarningsToStandardError() const
-{
- Q_D(const QDeclarativeEngine);
- return d->outputWarningsToStdErr;
-}
-
-/*!
- Set whether warning messages will be output to stderr to \a enabled.
-
- If \a enabled is true, any warning messages generated by QML will be
- output to stderr and emitted by the warnings() signal. If \a enabled
- is false, on the warnings() signal will be emitted. This allows
- applications to handle warning output themselves.
-
- The default value is true.
-*/
-void QDeclarativeEngine::setOutputWarningsToStandardError(bool enabled)
-{
- Q_D(QDeclarativeEngine);
- d->outputWarningsToStdErr = enabled;
-}
-
-/*!
- Attempt to free unused memory.
-*/
-void QDeclarativeEngine::collectGarbage()
-{
- QV8Engine::gc();
-}
-
-/*!
- Returns the QDeclarativeContext for the \a object, or 0 if no
- context has been set.
-
- When the QDeclarativeEngine instantiates a QObject, the context is
- set automatically.
- */
-QDeclarativeContext *QDeclarativeEngine::contextForObject(const QObject *object)
-{
- if(!object)
- return 0;
-
- QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
-
- QDeclarativeData *data =
- static_cast<QDeclarativeData *>(priv->declarativeData);
-
- if (!data)
- return 0;
- else if (data->outerContext)
- return data->outerContext->asQDeclarativeContext();
- else
- return 0;
-}
-
-/*!
- Sets the QDeclarativeContext for the \a object to \a context.
- If the \a object already has a context, a warning is
- output, but the context is not changed.
-
- When the QDeclarativeEngine instantiates a QObject, the context is
- set automatically.
- */
-void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContext *context)
-{
- if (!object || !context)
- return;
-
- QDeclarativeData *data = QDeclarativeData::get(object, true);
- if (data->context) {
- qWarning("QDeclarativeEngine::setContextForObject(): Object already has a QDeclarativeContext");
- return;
- }
-
- QDeclarativeContextData *contextData = QDeclarativeContextData::get(context);
- contextData->addObject(object);
-}
-
-/*!
- \enum QDeclarativeEngine::ObjectOwnership
-
- Ownership controls whether or not QML automatically destroys the
- QObject when the object is garbage collected by the JavaScript
- engine. The two ownership options are:
-
- \value CppOwnership The object is owned by C++ code, and will
- never be deleted by QML. The JavaScript destroy() method cannot be
- used on objects with CppOwnership. This option is similar to
- QScriptEngine::QtOwnership.
-
- \value JavaScriptOwnership The object is owned by JavaScript.
- When the object is returned to QML as the return value of a method
- call or property access, QML will delete the object if there are no
- remaining JavaScript references to it and it has no
- QObject::parent(). This option is similar to
- QScriptEngine::ScriptOwnership.
-
- Generally an application doesn't need to set an object's ownership
- explicitly. QML uses a heuristic to set the default object
- ownership. By default, an object that is created by QML has
- JavaScriptOwnership. The exception to this are the root objects
- created by calling QDeclarativeComponent::create() or
- QDeclarativeComponent::beginCreate() which have CppOwnership by
- default. The ownership of these root-level objects is considered to
- have been transferred to the C++ caller.
-
- Objects not-created by QML have CppOwnership by default. The
- exception to this is objects returned from a C++ method call. The
- ownership of these objects is passed to JavaScript.
-
- Calling setObjectOwnership() overrides the default ownership
- heuristic used by QML.
-*/
-
-/*!
- Sets the \a ownership of \a object.
-*/
-void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership)
-{
- if (!object)
- return;
-
- QDeclarativeData *ddata = QDeclarativeData::get(object, true);
- if (!ddata)
- return;
-
- ddata->indestructible = (ownership == CppOwnership)?true:false;
- ddata->explicitIndestructibleSet = true;
-}
-
-/*!
- Returns the ownership of \a object.
-*/
-QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(QObject *object)
-{
- if (!object)
- return CppOwnership;
-
- QDeclarativeData *ddata = QDeclarativeData::get(object, false);
- if (!ddata)
- return CppOwnership;
- else
- return ddata->indestructible?CppOwnership:JavaScriptOwnership;
-}
-
-bool QDeclarativeEngine::event(QEvent *e)
-{
- Q_D(QDeclarativeEngine);
- if (e->type() == QEvent::User)
- d->doDeleteInEngineThread();
-
- return QJSEngine::event(e);
-}
-
-void QDeclarativeEnginePrivate::doDeleteInEngineThread()
-{
- QFieldList<Deletable, &Deletable::next> list;
- mutex.lock();
- list.copyAndClear(toDeleteInEngineThread);
- mutex.unlock();
-
- while (Deletable *d = list.takeFirst())
- delete d;
-}
-
-Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
-{
- QDeclarativeData *data = QDeclarativeData::get(object);
-
- if (data && data->deferredComponent) {
- QDeclarativeObjectCreatingProfiler prof;
- if (prof.enabled) {
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
- prof.setTypeName(type ? type->qmlTypeName()
- : QString::fromUtf8(object->metaObject()->className()));
- if (data->outerContext)
- prof.setLocation(data->outerContext->url, data->lineNumber, data->columnNumber);
- }
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine);
-
- QDeclarativeComponentPrivate::ConstructionState state;
- QDeclarativeComponentPrivate::beginDeferred(ep, object, &state);
-
- data->deferredComponent->release();
- data->deferredComponent = 0;
-
- QDeclarativeComponentPrivate::complete(ep, &state);
- }
-}
-
-QDeclarativeContext *qmlContext(const QObject *obj)
-{
- return QDeclarativeEngine::contextForObject(obj);
-}
-
-QDeclarativeEngine *qmlEngine(const QObject *obj)
-{
- QDeclarativeData *data = QDeclarativeData::get(obj, false);
- if (!data || !data->context)
- return 0;
- return data->context->engine;
-}
-
-QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create)
-{
- QDeclarativeData *data = QDeclarativeData::get(object);
- if (!data)
- return 0; // Attached properties are only on objects created by QML
-
- QObject *rv = data->hasExtendedData()?data->attachedProperties()->value(id):0;
- if (rv || !create)
- return rv;
-
- QDeclarativeAttachedPropertiesFunc pf = QDeclarativeMetaType::attachedPropertiesFuncById(id);
- if (!pf)
- return 0;
-
- rv = pf(const_cast<QObject *>(object));
-
- if (rv)
- data->attachedProperties()->insert(id, rv);
-
- return rv;
-}
-
-QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
- const QMetaObject *attachedMetaObject, bool create)
-{
- if (*idCache == -1)
- *idCache = QDeclarativeMetaType::attachedPropertiesFuncId(attachedMetaObject);
-
- if (*idCache == -1 || !object)
- return 0;
-
- return qmlAttachedPropertiesObjectById(*idCache, object, create);
-}
-
-QDeclarativeDebuggingEnabler::QDeclarativeDebuggingEnabler()
-{
-#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
- if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
- qWarning("Qml debugging is enabled. Only use this in a safe environment!");
- }
- QDeclarativeEnginePrivate::qml_debugging_enabled = true;
-#endif
-}
-
-
-class QDeclarativeDataExtended {
-public:
- QDeclarativeDataExtended();
- ~QDeclarativeDataExtended();
-
- QHash<int, QObject *> attachedProperties;
- QDeclarativeNotifier objectNameNotifier;
-};
-
-QDeclarativeDataExtended::QDeclarativeDataExtended()
-{
-}
-
-QDeclarativeDataExtended::~QDeclarativeDataExtended()
-{
-}
-
-void QDeclarativeData::NotifyList::layout(QDeclarativeNotifierEndpoint *endpoint)
-{
- if (endpoint->next)
- layout(endpoint->next);
-
- int index = endpoint->sourceSignal;
- index = qMin(index, 0xFFFF - 1);
-
- endpoint->next = notifies[index];
- if (endpoint->next) endpoint->next->prev = &endpoint->next;
- endpoint->prev = &notifies[index];
- notifies[index] = endpoint;
-}
-
-void QDeclarativeData::NotifyList::layout()
-{
- Q_ASSERT(maximumTodoIndex >= notifiesSize);
-
- if (todo) {
- QDeclarativeNotifierEndpoint **old = notifies;
- const int reallocSize = (maximumTodoIndex + 1) * sizeof(QDeclarativeNotifierEndpoint*);
- notifies = (QDeclarativeNotifierEndpoint**)realloc(notifies, reallocSize);
- const int memsetSize = (maximumTodoIndex - notifiesSize + 1) *
- sizeof(QDeclarativeNotifierEndpoint*);
- memset(notifies + notifiesSize, 0, memsetSize);
-
- if (notifies != old) {
- for (int ii = 0; ii < notifiesSize; ++ii)
- if (notifies[ii])
- notifies[ii]->prev = &notifies[ii];
- }
-
- notifiesSize = maximumTodoIndex + 1;
-
- layout(todo);
- }
-
- maximumTodoIndex = 0;
- todo = 0;
-}
-
-void QDeclarativeData::addNotify(int index, QDeclarativeNotifierEndpoint *endpoint)
-{
- if (!notifyList) {
- notifyList = (NotifyList *)malloc(sizeof(NotifyList));
- notifyList->connectionMask = 0;
- notifyList->maximumTodoIndex = 0;
- notifyList->notifiesSize = 0;
- notifyList->todo = 0;
- notifyList->notifies = 0;
- }
-
- Q_ASSERT(!endpoint->isConnected());
-
- index = qMin(index, 0xFFFF - 1);
- notifyList->connectionMask |= (1ULL << quint64(index % 64));
-
- if (index < notifyList->notifiesSize) {
-
- endpoint->next = notifyList->notifies[index];
- if (endpoint->next) endpoint->next->prev = &endpoint->next;
- endpoint->prev = &notifyList->notifies[index];
- notifyList->notifies[index] = endpoint;
-
- } else {
- notifyList->maximumTodoIndex = qMax(int(notifyList->maximumTodoIndex), index);
-
- endpoint->next = notifyList->todo;
- if (endpoint->next) endpoint->next->prev = &endpoint->next;
- endpoint->prev = &notifyList->todo;
- notifyList->todo = endpoint;
- }
-}
-
-QDeclarativeNotifier *QDeclarativeData::objectNameNotifier() const
-{
- if (!extendedData) extendedData = new QDeclarativeDataExtended;
- return &extendedData->objectNameNotifier;
-}
-
-QHash<int, QObject *> *QDeclarativeData::attachedProperties() const
-{
- if (!extendedData) extendedData = new QDeclarativeDataExtended;
- return &extendedData->attachedProperties;
-}
-
-void QDeclarativeData::destroyed(QObject *object)
-{
- if (deferredComponent)
- deferredComponent->release();
-
- if (nextContextObject)
- nextContextObject->prevContextObject = prevContextObject;
- if (prevContextObject)
- *prevContextObject = nextContextObject;
-
- QDeclarativeAbstractBinding *binding = bindings;
- while (binding) {
- QDeclarativeAbstractBinding *next = binding->m_nextBinding;
- binding->m_prevBinding = 0;
- binding->m_nextBinding = 0;
- binding->destroy();
- binding = next;
- }
-
- if (bindingBits)
- free(bindingBits);
-
- if (propertyCache)
- propertyCache->release();
-
- if (ownContext && context)
- context->destroy();
-
- while (guards) {
- QDeclarativeGuard<QObject> *guard = static_cast<QDeclarativeGuard<QObject> *>(guards);
- *guard = (QObject *)0;
- guard->objectDestroyed(object);
- }
-
- if (notifyList) {
- while (notifyList->todo)
- notifyList->todo->disconnect();
- for (int ii = 0; ii < notifyList->notifiesSize; ++ii) {
- while (QDeclarativeNotifierEndpoint *ep = notifyList->notifies[ii])
- ep->disconnect();
- }
- free(notifyList->notifies);
- free(notifyList);
- }
-
- if (extendedData)
- delete extendedData;
-
- v8object.Clear(); // The WeakReference handler will clean the actual handle
-
- if (ownMemory)
- delete this;
-}
-
-void QDeclarativeData::parentChanged(QObject *object, QObject *parent)
-{
- Q_UNUSED(object);
- Q_UNUSED(parent);
-}
-
-void QDeclarativeData::objectNameChanged(QObject *)
-{
- if (extendedData) objectNameNotifier()->notify();
-}
-
-bool QDeclarativeData::hasBindingBit(int bit) const
-{
- if (bindingBitsSize > bit)
- return bindingBits[bit / 32] & (1 << (bit % 32));
- else
- return false;
-}
-
-void QDeclarativeData::clearBindingBit(int bit)
-{
- if (bindingBitsSize > bit)
- bindingBits[bit / 32] &= ~(1 << (bit % 32));
-}
-
-void QDeclarativeData::setBindingBit(QObject *obj, int bit)
-{
- if (bindingBitsSize <= bit) {
- int props = obj->metaObject()->propertyCount();
- Q_ASSERT(bit < props);
-
- int arraySize = (props + 31) / 32;
- int oldArraySize = bindingBitsSize / 32;
-
- bindingBits = (quint32 *)realloc(bindingBits,
- arraySize * sizeof(quint32));
-
- memset(bindingBits + oldArraySize,
- 0x00,
- sizeof(quint32) * (arraySize - oldArraySize));
-
- bindingBitsSize = arraySize * 32;
- }
-
- bindingBits[bit / 32] |= (1 << (bit % 32));
-}
-
-QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
-{
- if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
- if (url.authority().isEmpty())
- return QLatin1Char(':') + url.path();
- return QString();
- }
- return url.toLocalFile();
-}
-
-
-static QString toLocalFile(const QString &url)
-{
- if (!url.startsWith(QLatin1String("file://"), Qt::CaseInsensitive))
- return QString();
-
- QString file = url.mid(7);
-
- //XXX TODO: handle windows hostnames: "//servername/path/to/file.txt"
-
- // magic for drives on windows
- if (file.length() > 2 && file.at(0) == QLatin1Char('/') && file.at(2) == QLatin1Char(':'))
- file.remove(0, 1);
-
- return file;
-}
-
-QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QString& url)
-{
- if (url.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive)) {
- if (url.length() > 4)
- return QLatin1Char(':') + url.mid(4);
- return QString();
- }
-
- return toLocalFile(url);
-}
-
-void QDeclarativeEnginePrivate::sendQuit()
-{
- Q_Q(QDeclarativeEngine);
- emit q->quit();
- if (q->receivers(SIGNAL(quit())) == 0) {
- qWarning("Signal QDeclarativeEngine::quit() emitted, but no receivers connected to handle it.");
- }
-}
-
-static void dumpwarning(const QDeclarativeError &error)
-{
- qWarning().nospace() << qPrintable(error.toString());
-}
-
-static void dumpwarning(const QList<QDeclarativeError> &errors)
-{
- for (int ii = 0; ii < errors.count(); ++ii)
- dumpwarning(errors.at(ii));
-}
-
-void QDeclarativeEnginePrivate::warning(const QDeclarativeError &error)
-{
- Q_Q(QDeclarativeEngine);
- q->warnings(QList<QDeclarativeError>() << error);
- if (outputWarningsToStdErr)
- dumpwarning(error);
-}
-
-void QDeclarativeEnginePrivate::warning(const QList<QDeclarativeError> &errors)
-{
- Q_Q(QDeclarativeEngine);
- q->warnings(errors);
- if (outputWarningsToStdErr)
- dumpwarning(errors);
-}
-
-void QDeclarativeEnginePrivate::warning(QDeclarativeEngine *engine, const QDeclarativeError &error)
-{
- if (engine)
- QDeclarativeEnginePrivate::get(engine)->warning(error);
- else
- dumpwarning(error);
-}
-
-void QDeclarativeEnginePrivate::warning(QDeclarativeEngine *engine, const QList<QDeclarativeError> &error)
-{
- if (engine)
- QDeclarativeEnginePrivate::get(engine)->warning(error);
- else
- dumpwarning(error);
-}
-
-void QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate *engine, const QDeclarativeError &error)
-{
- if (engine)
- engine->warning(error);
- else
- dumpwarning(error);
-}
-
-void QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate *engine, const QList<QDeclarativeError> &error)
-{
- if (engine)
- engine->warning(error);
- else
- dumpwarning(error);
-}
-
-/*
- This function should be called prior to evaluation of any js expression,
- so that scarce resources are not freed prematurely (eg, if there is a
- nested javascript expression).
- */
-void QDeclarativeEnginePrivate::referenceScarceResources()
-{
- scarceResourcesRefCount += 1;
-}
-
-/*
- This function should be called after evaluation of the js expression is
- complete, and so the scarce resources may be freed safely.
- */
-void QDeclarativeEnginePrivate::dereferenceScarceResources()
-{
- Q_ASSERT(scarceResourcesRefCount > 0);
- scarceResourcesRefCount -= 1;
-
- // if the refcount is zero, then evaluation of the "top level"
- // expression must have completed. We can safely release the
- // scarce resources.
- if (scarceResourcesRefCount == 0) {
- // iterate through the list and release them all.
- // note that the actual SRD is owned by the JS engine,
- // so we cannot delete the SRD; but we can free the
- // memory used by the variant in the SRD.
- while (ScarceResourceData *sr = scarceResources.first()) {
- sr->data = QVariant();
- scarceResources.remove(sr);
- }
- }
-}
-
-/*!
- Adds \a path as a directory where the engine searches for
- installed modules in a URL-based directory structure.
- The \a path may be a local filesystem directory or a URL.
-
- The newly added \a path will be first in the importPathList().
-
- \sa setImportPathList(), {QML Modules}
-*/
-void QDeclarativeEngine::addImportPath(const QString& path)
-{
- Q_D(QDeclarativeEngine);
- d->importDatabase.addImportPath(path);
-}
-
-/*!
- Returns the list of directories where the engine searches for
- installed modules in a URL-based directory structure.
-
- For example, if \c /opt/MyApp/lib/imports is in the path, then QML that
- imports \c com.mycompany.Feature will cause the QDeclarativeEngine to look
- in \c /opt/MyApp/lib/imports/com/mycompany/Feature/ for the components
- provided by that module. A \c qmldir file is required for defining the
- type version mapping and possibly declarative extensions plugins.
-
- By default, the list contains the directory of the application executable,
- paths specified in the \c QML_IMPORT_PATH environment variable,
- and the builtin \c ImportsPath from QLibraryInfo.
-
- \sa addImportPath() setImportPathList()
-*/
-QStringList QDeclarativeEngine::importPathList() const
-{
- Q_D(const QDeclarativeEngine);
- return d->importDatabase.importPathList();
-}
-
-/*!
- Sets \a paths as the list of directories where the engine searches for
- installed modules in a URL-based directory structure.
-
- By default, the list contains the directory of the application executable,
- paths specified in the \c QML_IMPORT_PATH environment variable,
- and the builtin \c ImportsPath from QLibraryInfo.
-
- \sa importPathList() addImportPath()
- */
-void QDeclarativeEngine::setImportPathList(const QStringList &paths)
-{
- Q_D(QDeclarativeEngine);
- d->importDatabase.setImportPathList(paths);
-}
-
-
-/*!
- Adds \a path as a directory where the engine searches for
- native plugins for imported modules (referenced in the \c qmldir file).
-
- By default, the list contains only \c ., i.e. the engine searches
- in the directory of the \c qmldir file itself.
-
- The newly added \a path will be first in the pluginPathList().
-
- \sa setPluginPathList()
-*/
-void QDeclarativeEngine::addPluginPath(const QString& path)
-{
- Q_D(QDeclarativeEngine);
- d->importDatabase.addPluginPath(path);
-}
-
-
-/*!
- Returns the list of directories where the engine searches for
- native plugins for imported modules (referenced in the \c qmldir file).
-
- By default, the list contains only \c ., i.e. the engine searches
- in the directory of the \c qmldir file itself.
-
- \sa addPluginPath() setPluginPathList()
-*/
-QStringList QDeclarativeEngine::pluginPathList() const
-{
- Q_D(const QDeclarativeEngine);
- return d->importDatabase.pluginPathList();
-}
-
-/*!
- Sets the list of directories where the engine searches for
- native plugins for imported modules (referenced in the \c qmldir file)
- to \a paths.
-
- By default, the list contains only \c ., i.e. the engine searches
- in the directory of the \c qmldir file itself.
-
- \sa pluginPathList() addPluginPath()
- */
-void QDeclarativeEngine::setPluginPathList(const QStringList &paths)
-{
- Q_D(QDeclarativeEngine);
- d->importDatabase.setPluginPathList(paths);
-}
-
-/*!
- Imports the plugin named \a filePath with the \a uri provided.
- Returns true if the plugin was successfully imported; otherwise returns false.
-
- On failure and if non-null, the \a errors list will have any errors which occurred prepended to it.
-
- The plugin has to be a Qt plugin which implements the QDeclarativeExtensionPlugin interface.
-*/
-bool QDeclarativeEngine::importPlugin(const QString &filePath, const QString &uri, QList<QDeclarativeError> *errors)
-{
- Q_D(QDeclarativeEngine);
- return d->importDatabase.importPlugin(filePath, uri, errors);
-}
-
-/*!
- Imports the plugin named \a filePath with the \a uri provided.
- Returns true if the plugin was successfully imported; otherwise returns false.
-
- On failure and if non-null, *\a errorString will be set to a message describing the failure.
-
- The plugin has to be a Qt plugin which implements the QDeclarativeExtensionPlugin interface.
-*/
-bool QDeclarativeEngine::importPlugin(const QString &filePath, const QString &uri, QString *errorString)
-{
- Q_D(QDeclarativeEngine);
- QList<QDeclarativeError> errors;
- bool retn = d->importDatabase.importPlugin(filePath, uri, &errors);
- if (!errors.isEmpty()) {
- QString builtError;
- for (int i = 0; i < errors.size(); ++i) {
- builtError = QString(QLatin1String("%1\n %2"))
- .arg(builtError)
- .arg(errors.at(i).toString());
- }
- *errorString = builtError;
- }
- return retn;
-}
-
-/*!
- \property QDeclarativeEngine::offlineStoragePath
- \brief the directory for storing offline user data
-
- Returns the directory where SQL and other offline
- storage is placed.
-
- QDeclarativeWebView and the SQL databases created with openDatabase()
- are stored here.
-
- The default is QML/OfflineStorage in the platform-standard
- user application data directory.
-
- Note that the path may not currently exist on the filesystem, so
- callers wanting to \e create new files at this location should create
- it first - see QDir::mkpath().
-*/
-void QDeclarativeEngine::setOfflineStoragePath(const QString& dir)
-{
- Q_D(QDeclarativeEngine);
- d->offlineStoragePath = dir;
-}
-
-QString QDeclarativeEngine::offlineStoragePath() const
-{
- Q_D(const QDeclarativeEngine);
- return d->offlineStoragePath;
-}
-
-static void voidptr_destructor(void *v)
-{
- void **ptr = (void **)v;
- delete ptr;
-}
-
-static void *voidptr_constructor(const void *v)
-{
- if (!v) {
- return new void*;
- } else {
- return new void*(*(void **)v);
- }
-}
-
-QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(const QMetaObject *mo)
-{
- Q_Q(QDeclarativeEngine);
-
- if (!mo->superClass()) {
- QDeclarativePropertyCache *rv = new QDeclarativePropertyCache(q, mo);
- propertyCache.insert(mo, rv);
- return rv;
- } else {
- QDeclarativePropertyCache *super = cache(mo->superClass());
- QDeclarativePropertyCache *rv = super->copyAndAppend(q, mo);
- propertyCache.insert(mo, rv);
- return rv;
- }
-}
-
-QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(QDeclarativeType *type, int minorVersion,
- QDeclarativeError &error)
-{
- QList<QDeclarativeType *> types;
-
- int maxMinorVersion = 0;
-
- const QMetaObject *metaObject = type->metaObject();
-
- while (metaObject) {
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(metaObject, type->module(),
- type->majorVersion(), minorVersion);
- if (t) {
- maxMinorVersion = qMax(maxMinorVersion, t->minorVersion());
- types << t;
- } else {
- types << 0;
- }
-
- metaObject = metaObject->superClass();
- }
-
- if (QDeclarativePropertyCache *c = typePropertyCache.value(qMakePair(type, maxMinorVersion))) {
- c->addref();
- typePropertyCache.insert(qMakePair(type, minorVersion), c);
- return c;
- }
-
- QDeclarativePropertyCache *raw = cache(type->metaObject());
-
- bool hasCopied = false;
-
- for (int ii = 0; ii < types.count(); ++ii) {
- QDeclarativeType *currentType = types.at(ii);
- if (!currentType)
- continue;
-
- int rev = currentType->metaObjectRevision();
- int moIndex = types.count() - 1 - ii;
-
- if (raw->allowedRevisionCache[moIndex] != rev) {
- if (!hasCopied) {
- raw = raw->copy();
- hasCopied = true;
- }
- raw->allowedRevisionCache[moIndex] = rev;
- }
- }
-
- // Test revision compatibility - the basic rule is:
- // * Anything that is excluded, cannot overload something that is not excluded *
-
- // Signals override:
- // * other signals and methods of the same name.
- // * properties named on<Signal Name>
- // * automatic <property name>Changed notify signals
-
- // Methods override:
- // * other methods of the same name
-
- // Properties override:
- // * other elements of the same name
-
- bool overloadError = false;
- QString overloadName;
-
-#if 0
- for (QDeclarativePropertyCache::StringCache::ConstIterator iter = raw->stringCache.begin();
- !overloadError && iter != raw->stringCache.end();
- ++iter) {
-
- QDeclarativePropertyData *d = *iter;
- if (raw->isAllowedInRevision(d))
- continue; // Not excluded - no problems
-
- // check that a regular "name" overload isn't happening
- QDeclarativePropertyData *current = d;
- while (!overloadError && current) {
- current = d->overrideData(current);
- if (current && raw->isAllowedInRevision(current))
- overloadError = true;
- }
- }
-#endif
-
- if (overloadError) {
- if (hasCopied) raw->release();
-
- error.setDescription(QLatin1String("Type ") + type->qmlTypeName() + QLatin1String(" ") + QString::number(type->majorVersion()) + QLatin1String(".") + QString::number(minorVersion) + QLatin1String(" contains an illegal property \"") + overloadName + QLatin1String("\". This is an error in the type's implementation."));
- return 0;
- }
-
- if (!hasCopied) raw->addref();
- typePropertyCache.insert(qMakePair(type, minorVersion), raw);
-
- if (minorVersion != maxMinorVersion) {
- raw->addref();
- typePropertyCache.insert(qMakePair(type, maxMinorVersion), raw);
- }
-
- return raw;
-}
-
-QDeclarativeMetaType::ModuleApiInstance *
-QDeclarativeEnginePrivate::moduleApiInstance(const QDeclarativeMetaType::ModuleApi &module)
-{
- Locker locker(this);
-
- QDeclarativeMetaType::ModuleApiInstance *a = moduleApiInstances.value(module);
- if (!a) {
- a = new QDeclarativeMetaType::ModuleApiInstance;
- a->scriptCallback = module.script;
- a->qobjectCallback = module.qobject;
- moduleApiInstances.insert(module, a);
- }
-
- return a;
-}
-
-bool QDeclarativeEnginePrivate::isQObject(int t)
-{
- Locker locker(this);
- return m_compositeTypes.contains(t) || QDeclarativeMetaType::isQObject(t);
-}
-
-QObject *QDeclarativeEnginePrivate::toQObject(const QVariant &v, bool *ok) const
-{
- Locker locker(this);
- int t = v.userType();
- if (t == QMetaType::QObjectStar || m_compositeTypes.contains(t)) {
- if (ok) *ok = true;
- return *(QObject **)(v.constData());
- } else {
- return QDeclarativeMetaType::toQObject(v, ok);
- }
-}
-
-QDeclarativeMetaType::TypeCategory QDeclarativeEnginePrivate::typeCategory(int t) const
-{
- Locker locker(this);
- if (m_compositeTypes.contains(t))
- return QDeclarativeMetaType::Object;
- else if (m_qmlLists.contains(t))
- return QDeclarativeMetaType::List;
- else
- return QDeclarativeMetaType::typeCategory(t);
-}
-
-bool QDeclarativeEnginePrivate::isList(int t) const
-{
- Locker locker(this);
- return m_qmlLists.contains(t) || QDeclarativeMetaType::isList(t);
-}
-
-int QDeclarativeEnginePrivate::listType(int t) const
-{
- Locker locker(this);
- QHash<int, int>::ConstIterator iter = m_qmlLists.find(t);
- if (iter != m_qmlLists.end())
- return *iter;
- else
- return QDeclarativeMetaType::listType(t);
-}
-
-const QMetaObject *QDeclarativeEnginePrivate::rawMetaObjectForType(int t) const
-{
- Locker locker(this);
- QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
- if (iter != m_compositeTypes.end()) {
- return (*iter)->root;
- } else {
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(t);
- return type?type->baseMetaObject():0;
- }
-}
-
-const QMetaObject *QDeclarativeEnginePrivate::metaObjectForType(int t) const
-{
- Locker locker(this);
- QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
- if (iter != m_compositeTypes.end()) {
- return (*iter)->root;
- } else {
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(t);
- return type?type->metaObject():0;
- }
-}
-
-void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData *data)
-{
- QByteArray name = data->root->className();
-
- QByteArray ptr = name + '*';
- QByteArray lst = "QDeclarativeListProperty<" + name + '>';
-
- int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor,
- voidptr_constructor);
- int lst_type = QMetaType::registerType(lst.constData(), voidptr_destructor,
- voidptr_constructor);
-
- data->addref();
-
- Locker locker(this);
- m_qmlLists.insert(lst_type, ptr_type);
- m_compositeTypes.insert(ptr_type, data);
-}
-
-bool QDeclarative_isFileCaseCorrect(const QString &fileName)
-{
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
- QFileInfo info(fileName);
- const QString absolute = info.absoluteFilePath();
-
-#if defined(Q_OS_MAC)
- const QString canonical = info.canonicalFilePath();
-#elif defined(Q_OS_WIN)
- wchar_t buffer[1024];
-
- DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024);
- if (rv == 0 || rv >= 1024) return true;
- rv = ::GetLongPathName(buffer, buffer, 1024);
- if (rv == 0 || rv >= 1024) return true;
-
- const QString canonical = QString::fromWCharArray(buffer);
-#endif
-
- const int absoluteLength = absolute.length();
- const int canonicalLength = canonical.length();
-
- const int length = qMin(absoluteLength, canonicalLength);
- for (int ii = 0; ii < length; ++ii) {
- const QChar &a = absolute.at(absoluteLength - 1 - ii);
- const QChar &c = canonical.at(canonicalLength - 1 - ii);
-
- if (a.toLower() != c.toLower())
- return true;
- if (a != c)
- return false;
- }
-#else
- Q_UNUSED(fileName)
-#endif
- return true;
-}
-
-/*!
- \fn QDeclarativeEngine *qmlEngine(const QObject *object)
- \relates QDeclarativeEngine
-
- Returns the QDeclarativeEngine associated with \a object, if any. This is equivalent to
- QDeclarativeEngine::contextForObject(object)->engine(), but more efficient.
-*/
-
-/*!
- \fn QDeclarativeContext *qmlContext(const QObject *object)
- \relates QDeclarativeEngine
-
- Returns the QDeclarativeContext associated with \a object, if any. This is equivalent to
- QDeclarativeEngine::contextForObject(object).
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h
deleted file mode 100644
index eb310d4b9a..0000000000
--- a/src/declarative/qml/qdeclarativeengine.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEENGINE_H
-#define QDECLARATIVEENGINE_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qmap.h>
-#include <QtDeclarative/qjsengine.h>
-#include <QtDeclarative/qdeclarativeerror.h>
-#include <QtDeclarative/qdeclarativedebug.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeComponent;
-class QDeclarativeEnginePrivate;
-class QDeclarativeImportsPrivate;
-class QDeclarativeExpression;
-class QDeclarativeContext;
-class QDeclarativeType;
-class QUrl;
-class QScriptContext;
-class QDeclarativeImageProvider;
-class QNetworkAccessManager;
-class QDeclarativeNetworkAccessManagerFactory;
-class QDeclarativeIncubationController;
-class Q_DECLARATIVE_EXPORT QDeclarativeEngine : public QJSEngine
-{
- Q_PROPERTY(QString offlineStoragePath READ offlineStoragePath WRITE setOfflineStoragePath)
- Q_OBJECT
-public:
- QDeclarativeEngine(QObject *p = 0);
- virtual ~QDeclarativeEngine();
-
- QDeclarativeContext *rootContext() const;
-
- void clearComponentCache();
-
- QStringList importPathList() const;
- void setImportPathList(const QStringList &paths);
- void addImportPath(const QString& dir);
-
- QStringList pluginPathList() const;
- void setPluginPathList(const QStringList &paths);
- void addPluginPath(const QString& dir);
-
- bool importPlugin(const QString &filePath, const QString &uri, QString *errorString); // XXX: Qt 5: Remove this function
- bool importPlugin(const QString &filePath, const QString &uri, QList<QDeclarativeError> *errors);
-
- void setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *);
- QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory() const;
-
- QNetworkAccessManager *networkAccessManager() const;
-
- void addImageProvider(const QString &id, QDeclarativeImageProvider *);
- QDeclarativeImageProvider *imageProvider(const QString &id) const;
- void removeImageProvider(const QString &id);
-
- void setIncubationController(QDeclarativeIncubationController *);
- QDeclarativeIncubationController *incubationController() const;
-
- void setOfflineStoragePath(const QString& dir);
- QString offlineStoragePath() const;
-
- QUrl baseUrl() const;
- void setBaseUrl(const QUrl &);
-
- bool outputWarningsToStandardError() const;
- void setOutputWarningsToStandardError(bool);
-
- void collectGarbage();
-
- static QDeclarativeContext *contextForObject(const QObject *);
- static void setContextForObject(QObject *, QDeclarativeContext *);
-
- enum ObjectOwnership { CppOwnership, JavaScriptOwnership };
- static void setObjectOwnership(QObject *, ObjectOwnership);
- static ObjectOwnership objectOwnership(QObject *);
-
-protected:
- virtual bool event(QEvent *);
-
-Q_SIGNALS:
- void quit();
- void warnings(const QList<QDeclarativeError> &warnings);
-
-private:
- Q_DISABLE_COPY(QDeclarativeEngine)
- Q_DECLARE_PRIVATE(QDeclarativeEngine)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEENGINE_H
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
deleted file mode 100644
index afc7a18161..0000000000
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ /dev/null
@@ -1,522 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEENGINE_P_H
-#define QDECLARATIVEENGINE_P_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 "qdeclarativeengine.h"
-
-#include "qdeclarativetypeloader_p.h"
-#include "qdeclarativeimport_p.h"
-#include <private/qpodvector_p.h>
-#include "qdeclarative.h"
-#include "qdeclarativevaluetype_p.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativeexpression.h"
-#include "qdeclarativeimageprovider.h"
-#include "qdeclarativeproperty_p.h"
-#include "qdeclarativepropertycache_p.h"
-#include "qdeclarativemetatype_p.h"
-#include "qdeclarativedirparser_p.h"
-#include <private/qintrusivelist_p.h>
-#include <private/qrecyclepool_p.h>
-
-#include <QtCore/qlist.h>
-#include <QtCore/qpair.h>
-#include <QtCore/qstack.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qthread.h>
-
-#include <private/qobject_p.h>
-
-#include <private/qv8engine_p.h>
-#include <private/qjsengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeContext;
-class QDeclarativeEngine;
-class QDeclarativeContextPrivate;
-class QDeclarativeExpression;
-class QDeclarativeImportDatabase;
-class QNetworkReply;
-class QNetworkAccessManager;
-class QDeclarativeNetworkAccessManagerFactory;
-class QDeclarativeAbstractBinding;
-class QDeclarativeTypeNameCache;
-class QDeclarativeComponentAttached;
-class QDeclarativeCleanup;
-class QDeclarativeDelayedError;
-class QDeclarativeWorkerScriptEngine;
-class QDeclarativeVME;
-class QDir;
-class QDeclarativeIncubator;
-
-// This needs to be declared here so that the pool for it can live in QDeclarativeEnginePrivate.
-// The inline method definitions are in qdeclarativeexpression_p.h
-class QDeclarativeJavaScriptExpressionGuard : public QDeclarativeNotifierEndpoint
-{
-public:
- inline QDeclarativeJavaScriptExpressionGuard(QDeclarativeJavaScriptExpression *);
-
- static inline void endpointCallback(QDeclarativeNotifierEndpoint *);
- static inline QDeclarativeJavaScriptExpressionGuard *New(QDeclarativeJavaScriptExpression *e,
- QDeclarativeEngine *engine);
- inline void Delete();
-
- QDeclarativeJavaScriptExpression *expression;
- QDeclarativeJavaScriptExpressionGuard *next;
-};
-
-class Q_DECLARATIVE_EXPORT QDeclarativeEnginePrivate : public QJSEnginePrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeEngine)
-public:
- QDeclarativeEnginePrivate(QDeclarativeEngine *);
- ~QDeclarativeEnginePrivate();
-
- void init();
-
- class PropertyCapture {
- public:
- inline virtual ~PropertyCapture() {}
- virtual void captureProperty(QDeclarativeNotifier *) = 0;
- virtual void captureProperty(QObject *, int, int) = 0;
- };
-
- PropertyCapture *propertyCapture;
- inline void captureProperty(QDeclarativeNotifier *);
- inline void captureProperty(QObject *, int, int);
-
- QRecyclePool<QDeclarativeJavaScriptExpressionGuard> jsExpressionGuardPool;
-
- QDeclarativeContext *rootContext;
- bool isDebugging;
-
- bool outputWarningsToStdErr;
-
- QDeclarativeContextData *sharedContext;
- QObject *sharedScope;
-
- // Registered cleanup handlers
- QDeclarativeCleanup *cleanup;
-
- // Bindings that have had errors during startup
- QDeclarativeDelayedError *erroredBindings;
- int inProgressCreations;
-
- QV8Engine *v8engine() const { return q_func()->handle(); }
-
- QDeclarativeWorkerScriptEngine *getWorkerScriptEngine();
- QDeclarativeWorkerScriptEngine *workerScriptEngine;
-
- QUrl baseUrl;
-
- typedef QPair<QDeclarativeGuard<QObject>,int> FinalizeCallback;
- void registerFinalizeCallback(QObject *obj, int index);
-
- QDeclarativeVME *activeVME;
-
- QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
- QNetworkAccessManager *getNetworkAccessManager() const;
- mutable QNetworkAccessManager *networkAccessManager;
- mutable QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory;
-
- QHash<QString,QSharedPointer<QDeclarativeImageProvider> > imageProviders;
- QDeclarativeImageProvider::ImageType getImageProviderType(const QUrl &url);
- QDeclarativeTextureFactory *getTextureFromProvider(const QUrl &url, QSize *size, const QSize& req_size);
- QImage getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size);
- QPixmap getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size);
-
- // Scarce resources are "exceptionally high cost" QVariant types where allowing the
- // normal JavaScript GC to clean them up is likely to lead to out-of-memory or other
- // out-of-resource situations. When such a resource is passed into JavaScript we
- // add it to the scarceResources list and it is destroyed when we return from the
- // JavaScript execution that created it. The user can prevent this behavior by
- // calling preserve() on the object which removes it from this scarceResource list.
- class ScarceResourceData {
- public:
- ScarceResourceData(const QVariant &data) : data(data) {}
- QVariant data;
- QIntrusiveListNode node;
- };
- QIntrusiveList<ScarceResourceData, &ScarceResourceData::node> scarceResources;
- int scarceResourcesRefCount;
- void referenceScarceResources();
- void dereferenceScarceResources();
-
- QDeclarativeTypeLoader typeLoader;
- QDeclarativeImportDatabase importDatabase;
-
- QString offlineStoragePath;
-
- mutable quint32 uniqueId;
- inline quint32 getUniqueId() const {
- return uniqueId++;
- }
-
- QDeclarativeValueTypeFactory valueTypes;
-
- // Unfortunate workaround to avoid a circular dependency between
- // qdeclarativeengine_p.h and qdeclarativeincubator_p.h
- struct Incubator {
- QIntrusiveListNode next;
- // Unfortunate workaround for MSVC
- QIntrusiveListNode nextWaitingFor;
- };
- QIntrusiveList<Incubator, &Incubator::next> incubatorList;
- unsigned int incubatorCount;
- QDeclarativeIncubationController *incubationController;
- void incubate(QDeclarativeIncubator &, QDeclarativeContextData *);
-
- // These methods may be called from any thread
- inline bool isEngineThread() const;
- inline static bool isEngineThread(const QDeclarativeEngine *);
- template<typename T>
- inline void deleteInEngineThread(T *);
- template<typename T>
- inline static void deleteInEngineThread(QDeclarativeEngine *, T *);
-
- // These methods may be called from the loader thread
- QDeclarativeMetaType::ModuleApiInstance *moduleApiInstance(const QDeclarativeMetaType::ModuleApi &module);
-
- // These methods may be called from the loader thread
- inline QDeclarativePropertyCache *cache(QObject *obj);
- inline QDeclarativePropertyCache *cache(const QMetaObject *);
- inline QDeclarativePropertyCache *cache(QDeclarativeType *, int, QDeclarativeError &error);
-
- // These methods may be called from the loader thread
- bool isQObject(int);
- QObject *toQObject(const QVariant &, bool *ok = 0) const;
- QDeclarativeMetaType::TypeCategory typeCategory(int) const;
- bool isList(int) const;
- int listType(int) const;
- const QMetaObject *rawMetaObjectForType(int) const;
- const QMetaObject *metaObjectForType(int) const;
- void registerCompositeType(QDeclarativeCompiledData *);
-
- void sendQuit();
- void warning(const QDeclarativeError &);
- void warning(const QList<QDeclarativeError> &);
- static void warning(QDeclarativeEngine *, const QDeclarativeError &);
- static void warning(QDeclarativeEngine *, const QList<QDeclarativeError> &);
- static void warning(QDeclarativeEnginePrivate *, const QDeclarativeError &);
- static void warning(QDeclarativeEnginePrivate *, const QList<QDeclarativeError> &);
-
- inline static QV8Engine *getV8Engine(QDeclarativeEngine *e);
- inline static QDeclarativeEnginePrivate *get(QDeclarativeEngine *e);
- inline static const QDeclarativeEnginePrivate *get(const QDeclarativeEngine *e);
- inline static QDeclarativeEnginePrivate *get(QDeclarativeContext *c);
- inline static QDeclarativeEnginePrivate *get(QDeclarativeContextData *c);
- inline static QDeclarativeEngine *get(QDeclarativeEnginePrivate *p);
-
- static QString urlToLocalFileOrQrc(const QUrl& url);
- static QString urlToLocalFileOrQrc(const QString& url);
-
- static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor);
- static void defineModule();
-
- static bool qml_debugging_enabled;
-
- mutable QMutex mutex;
-
-private:
- // Locker locks the QDeclarativeEnginePrivate data structures for read and write, if necessary.
- // Currently, locking is only necessary if the threaded loader is running concurrently. If it is
- // either idle, or is running with the main thread blocked, no locking is necessary. This way
- // we only pay for locking when we have to.
- // Consequently, this class should only be used to protect simple accesses or modifications of the
- // QDeclarativeEnginePrivate structures or operations that can be guarenteed not to start activity
- // on the loader thread.
- // The Locker API is identical to QMutexLocker. Locker reuses the QDeclarativeEnginePrivate::mutex
- // QMutex instance and multiple Lockers are recursive in the same thread.
- class Locker
- {
- public:
- inline Locker(const QDeclarativeEngine *);
- inline Locker(const QDeclarativeEnginePrivate *);
- inline ~Locker();
-
- inline void unlock();
- inline void relock();
-
- private:
- const QDeclarativeEnginePrivate *m_ep;
- quint32 m_locked:1;
- };
-
- // Must be called locked
- QDeclarativePropertyCache *createCache(const QMetaObject *);
- QDeclarativePropertyCache *createCache(QDeclarativeType *, int, QDeclarativeError &error);
-
- // These members must be protected by a QDeclarativeEnginePrivate::Locker as they are required by
- // the threaded loader. Only access them through their respective accessor methods.
- QHash<QDeclarativeMetaType::ModuleApi, QDeclarativeMetaType::ModuleApiInstance *> moduleApiInstances;
- QHash<const QMetaObject *, QDeclarativePropertyCache *> propertyCache;
- QHash<QPair<QDeclarativeType *, int>, QDeclarativePropertyCache *> typePropertyCache;
- QHash<int, int> m_qmlLists;
- QHash<int, QDeclarativeCompiledData *> m_compositeTypes;
-
- // These members is protected by the full QDeclarativeEnginePrivate::mutex mutex
- struct Deletable { Deletable():next(0) {} virtual ~Deletable() {} Deletable *next; };
- QFieldList<Deletable, &Deletable::next> toDeleteInEngineThread;
- void doDeleteInEngineThread();
-};
-
-QDeclarativeEnginePrivate::Locker::Locker(const QDeclarativeEngine *e)
-: m_ep(QDeclarativeEnginePrivate::get(e))
-{
- relock();
-}
-
-QDeclarativeEnginePrivate::Locker::Locker(const QDeclarativeEnginePrivate *e)
-: m_ep(e), m_locked(false)
-{
- relock();
-}
-
-QDeclarativeEnginePrivate::Locker::~Locker()
-{
- unlock();
-}
-
-void QDeclarativeEnginePrivate::Locker::unlock()
-{
- if (m_locked) {
- m_ep->mutex.unlock();
- m_locked = false;
- }
-}
-
-void QDeclarativeEnginePrivate::Locker::relock()
-{
- Q_ASSERT(!m_locked);
- if (m_ep->typeLoader.isConcurrent()) {
- m_ep->mutex.lock();
- m_locked = true;
- }
-}
-
-/*!
-Returns true if the calling thread is the QDeclarativeEngine thread.
-*/
-bool QDeclarativeEnginePrivate::isEngineThread() const
-{
- Q_Q(const QDeclarativeEngine);
- return QThread::currentThread() == q->thread();
-}
-
-/*!
-Returns true if the calling thread is the QDeclarativeEngine \a engine thread.
-*/
-bool QDeclarativeEnginePrivate::isEngineThread(const QDeclarativeEngine *engine)
-{
- Q_ASSERT(engine);
- return QDeclarativeEnginePrivate::get(engine)->isEngineThread();
-}
-
-/*!
-Delete \a value in the engine thread. If the calling thread is the engine
-thread, \a value will be deleted immediately.
-
-This method should be used for *any* type that has resources that need to
-be freed in the engine thread. This is generally types that use V8 handles.
-As there is some small overhead in checking the current thread, it is best
-practice to check if any V8 handles actually need to be freed and delete
-the instance directly if not.
-*/
-template<typename T>
-void QDeclarativeEnginePrivate::deleteInEngineThread(T *value)
-{
- Q_Q(QDeclarativeEngine);
-
- Q_ASSERT(value);
- if (isEngineThread()) {
- delete value;
- } else {
- struct I : public Deletable {
- I(T *value) : value(value) {}
- ~I() { delete value; }
- T *value;
- };
- I *i = new I(value);
- mutex.lock();
- bool wasEmpty = toDeleteInEngineThread.isEmpty();
- toDeleteInEngineThread.append(i);
- mutex.unlock();
- if (wasEmpty)
- QCoreApplication::postEvent(q, new QEvent(QEvent::User));
- }
-}
-
-/*!
-Delete \a value in the \a engine thread. If the calling thread is the engine
-thread, \a value will be deleted immediately.
-*/
-template<typename T>
-void QDeclarativeEnginePrivate::deleteInEngineThread(QDeclarativeEngine *engine, T *value)
-{
- Q_ASSERT(engine);
- QDeclarativeEnginePrivate::get(engine)->deleteInEngineThread<T>(value);
-}
-
-/*!
-Returns a QDeclarativePropertyCache for \a obj if one is available.
-
-If \a obj is null, being deleted or contains a dynamic meta object 0
-is returned.
-
-The returned cache is not referenced, so if it is to be stored, call addref().
-
-XXX thread There is a potential future race condition in this and all the cache()
-functions. As the QDeclarativePropertyCache is returned unreferenced, when called
-from the loader thread, it is possible that the cache will have been dereferenced
-and deleted before the loader thread has a chance to use or reference it. This
-can't currently happen as the cache holds a reference to the
-QDeclarativePropertyCache until the QDeclarativeEngine is destroyed.
-*/
-QDeclarativePropertyCache *QDeclarativeEnginePrivate::cache(QObject *obj)
-{
- if (!obj || QObjectPrivate::get(obj)->metaObject || QObjectPrivate::get(obj)->wasDeleted)
- return 0;
-
- Locker locker(this);
- const QMetaObject *mo = obj->metaObject();
- QDeclarativePropertyCache *rv = propertyCache.value(mo);
- if (!rv) rv = createCache(mo);
- return rv;
-}
-
-/*!
-Returns a QDeclarativePropertyCache for \a metaObject.
-
-As the cache is persisted for the life of the engine, \a metaObject must be
-a static "compile time" meta-object, or a meta-object that is otherwise known to
-exist for the lifetime of the QDeclarativeEngine.
-
-The returned cache is not referenced, so if it is to be stored, call addref().
-*/
-QDeclarativePropertyCache *QDeclarativeEnginePrivate::cache(const QMetaObject *metaObject)
-{
- Q_ASSERT(metaObject);
-
- Locker locker(this);
- QDeclarativePropertyCache *rv = propertyCache.value(metaObject);
- if (!rv) rv = createCache(metaObject);
- return rv;
-}
-
-/*!
-Returns a QDeclarativePropertyCache for \a type with \a minorVersion.
-
-The returned cache is not referenced, so if it is to be stored, call addref().
-*/
-QDeclarativePropertyCache *QDeclarativeEnginePrivate::cache(QDeclarativeType *type, int minorVersion, QDeclarativeError &error)
-{
- Q_ASSERT(type);
-
- if (minorVersion == -1 || !type->containsRevisionedAttributes())
- return cache(type->metaObject());
-
- Locker locker(this);
- QDeclarativePropertyCache *rv = typePropertyCache.value(qMakePair(type, minorVersion));
- if (!rv) rv = createCache(type, minorVersion, error);
- return rv;
-}
-
-QV8Engine *QDeclarativeEnginePrivate::getV8Engine(QDeclarativeEngine *e)
-{
- return e->d_func()->v8engine();
-}
-
-QDeclarativeEnginePrivate *QDeclarativeEnginePrivate::get(QDeclarativeEngine *e)
-{
- return e->d_func();
-}
-
-const QDeclarativeEnginePrivate *QDeclarativeEnginePrivate::get(const QDeclarativeEngine *e)
-{
- return e->d_func();
-}
-
-QDeclarativeEnginePrivate *QDeclarativeEnginePrivate::get(QDeclarativeContext *c)
-{
- return (c && c->engine()) ? QDeclarativeEnginePrivate::get(c->engine()) : 0;
-}
-
-QDeclarativeEnginePrivate *QDeclarativeEnginePrivate::get(QDeclarativeContextData *c)
-{
- return (c && c->engine) ? QDeclarativeEnginePrivate::get(c->engine) : 0;
-}
-
-QDeclarativeEngine *QDeclarativeEnginePrivate::get(QDeclarativeEnginePrivate *p)
-{
- return p->q_func();
-}
-
-void QDeclarativeEnginePrivate::captureProperty(QDeclarativeNotifier *n)
-{
- if (propertyCapture)
- propertyCapture->captureProperty(n);
-}
-
-void QDeclarativeEnginePrivate::captureProperty(QObject *o, int c, int n)
-{
- if (propertyCapture)
- propertyCapture->captureProperty(o, c, n);
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEENGINE_P_H
diff --git a/src/declarative/qml/qdeclarativeerror.cpp b/src/declarative/qml/qdeclarativeerror.cpp
deleted file mode 100644
index 4f4d3cf7aa..0000000000
--- a/src/declarative/qml/qdeclarativeerror.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeerror.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDeclarativeError
- \since 4.7
- \brief The QDeclarativeError class encapsulates a QML error.
-
- QDeclarativeError includes a textual description of the error, as well
- as location information (the file, line, and column). The toString()
- method creates a single-line, human-readable string containing all of
- this information, for example:
- \code
- file:///home/user/test.qml:7:8: Invalid property assignment: double expected
- \endcode
-
- You can use qDebug() or qWarning() to output errors to the console. This method
- will attempt to open the file indicated by the error
- and include additional contextual information.
- \code
- file:///home/user/test.qml:7:8: Invalid property assignment: double expected
- y: "hello"
- ^
- \endcode
-
- \sa QDeclarativeView::errors(), QDeclarativeComponent::errors()
-*/
-class QDeclarativeErrorPrivate
-{
-public:
- QDeclarativeErrorPrivate();
-
- QUrl url;
- QString description;
- int line;
- int column;
-};
-
-QDeclarativeErrorPrivate::QDeclarativeErrorPrivate()
-: line(-1), column(-1)
-{
-}
-
-/*!
- Creates an empty error object.
-*/
-QDeclarativeError::QDeclarativeError()
-: d(0)
-{
-}
-
-/*!
- Creates a copy of \a other.
-*/
-QDeclarativeError::QDeclarativeError(const QDeclarativeError &other)
-: d(0)
-{
- *this = other;
-}
-
-/*!
- Assigns \a other to this error object.
-*/
-QDeclarativeError &QDeclarativeError::operator=(const QDeclarativeError &other)
-{
- if (!other.d) {
- delete d;
- d = 0;
- } else {
- if (!d) d = new QDeclarativeErrorPrivate;
- d->url = other.d->url;
- d->description = other.d->description;
- d->line = other.d->line;
- d->column = other.d->column;
- }
- return *this;
-}
-
-/*!
- \internal
-*/
-QDeclarativeError::~QDeclarativeError()
-{
- delete d; d = 0;
-}
-
-/*!
- Returns true if this error is valid, otherwise false.
-*/
-bool QDeclarativeError::isValid() const
-{
- return d != 0;
-}
-
-/*!
- Returns the url for the file that caused this error.
-*/
-QUrl QDeclarativeError::url() const
-{
- if (d) return d->url;
- else return QUrl();
-}
-
-/*!
- Sets the \a url for the file that caused this error.
-*/
-void QDeclarativeError::setUrl(const QUrl &url)
-{
- if (!d) d = new QDeclarativeErrorPrivate;
- d->url = url;
-}
-
-/*!
- Returns the error description.
-*/
-QString QDeclarativeError::description() const
-{
- if (d) return d->description;
- else return QString();
-}
-
-/*!
- Sets the error \a description.
-*/
-void QDeclarativeError::setDescription(const QString &description)
-{
- if (!d) d = new QDeclarativeErrorPrivate;
- d->description = description;
-}
-
-/*!
- Returns the error line number.
-*/
-int QDeclarativeError::line() const
-{
- if (d) return d->line;
- else return -1;
-}
-
-/*!
- Sets the error \a line number.
-*/
-void QDeclarativeError::setLine(int line)
-{
- if (!d) d = new QDeclarativeErrorPrivate;
- d->line = line;
-}
-
-/*!
- Returns the error column number.
-*/
-int QDeclarativeError::column() const
-{
- if (d) return d->column;
- else return -1;
-}
-
-/*!
- Sets the error \a column number.
-*/
-void QDeclarativeError::setColumn(int column)
-{
- if (!d) d = new QDeclarativeErrorPrivate;
- d->column = column;
-}
-
-/*!
- Returns the error as a human readable string.
-*/
-QString QDeclarativeError::toString() const
-{
- QString rv;
- if (url().isEmpty()) {
- rv = QLatin1String("<Unknown File>");
- } else if (line() != -1) {
- rv = url().toString() + QLatin1Char(':') + QString::number(line());
- if(column() != -1)
- rv += QLatin1Char(':') + QString::number(column());
- } else {
- rv = url().toString();
- }
-
- rv += QLatin1String(": ") + description();
-
- return rv;
-}
-
-/*!
- \relates QDeclarativeError
- \fn QDebug operator<<(QDebug debug, const QDeclarativeError &error)
-
- Outputs a human readable version of \a error to \a debug.
-*/
-
-QDebug operator<<(QDebug debug, const QDeclarativeError &error)
-{
- debug << qPrintable(error.toString());
-
- QUrl url = error.url();
-
- if (error.line() > 0 && url.scheme() == QLatin1String("file")) {
- QString file = url.toLocalFile();
- QFile f(file);
- if (f.open(QIODevice::ReadOnly)) {
- QByteArray data = f.readAll();
- QTextStream stream(data, QIODevice::ReadOnly);
-#ifndef QT_NO_TEXTCODEC
- stream.setCodec("UTF-8");
-#endif
- const QString code = stream.readAll();
- const QStringList lines = code.split(QLatin1Char('\n'));
-
- if (lines.count() >= error.line()) {
- const QString &line = lines.at(error.line() - 1);
- debug << "\n " << qPrintable(line);
-
- if(error.column() > 0) {
- int column = qMax(0, error.column() - 1);
- column = qMin(column, line.length());
-
- QByteArray ind;
- ind.reserve(column);
- for (int i = 0; i < column; ++i) {
- const QChar ch = line.at(i);
- if (ch.isSpace())
- ind.append(ch.unicode());
- else
- ind.append(' ');
- }
- ind.append('^');
- debug << "\n " << ind.constData();
- }
- }
- }
- }
- return debug;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeerror.h b/src/declarative/qml/qdeclarativeerror.h
deleted file mode 100644
index be22768a32..0000000000
--- a/src/declarative/qml/qdeclarativeerror.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEERROR_H
-#define QDECLARATIVEERROR_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDebug;
-class QDeclarativeErrorPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeError
-{
-public:
- QDeclarativeError();
- QDeclarativeError(const QDeclarativeError &);
- QDeclarativeError &operator=(const QDeclarativeError &);
- ~QDeclarativeError();
-
- bool isValid() const;
-
- QUrl url() const;
- void setUrl(const QUrl &);
- QString description() const;
- void setDescription(const QString &);
- int line() const;
- void setLine(int);
- int column() const;
- void setColumn(int);
-
- QString toString() const;
-private:
- QDeclarativeErrorPrivate *d;
-};
-
-QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, const QDeclarativeError &error);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEERROR_H
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
deleted file mode 100644
index 1a4c486931..0000000000
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ /dev/null
@@ -1,982 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeexpression.h"
-#include "qdeclarativeexpression_p.h"
-
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativerewrite_p.h"
-#include "qdeclarativescriptstring_p.h"
-#include "qdeclarativecompiler_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-bool QDeclarativeDelayedError::addError(QDeclarativeEnginePrivate *e)
-{
- if (!e) return false;
-
- if (e->inProgressCreations == 0) return false; // Not in construction
-
- if (prevError) return true; // Already in error chain
-
- prevError = &e->erroredBindings;
- nextError = e->erroredBindings;
- e->erroredBindings = this;
- if (nextError) nextError->prevError = &nextError;
-
- return true;
-}
-
-QDeclarativeJavaScriptExpression::QDeclarativeJavaScriptExpression(VTable *v)
-: m_vtable(v)
-{
-}
-
-QDeclarativeJavaScriptExpression::~QDeclarativeJavaScriptExpression()
-{
- clearGuards();
-}
-
-static QDeclarativeJavaScriptExpression::VTable QDeclarativeExpressionPrivate_jsvtable = {
- QDeclarativeExpressionPrivate::expressionIdentifier,
- QDeclarativeExpressionPrivate::expressionChanged
-};
-
-QDeclarativeExpressionPrivate::QDeclarativeExpressionPrivate()
-: QDeclarativeJavaScriptExpression(&QDeclarativeExpressionPrivate_jsvtable),
- expressionFunctionValid(true), expressionFunctionRewritten(false),
- extractExpressionFromFunction(false), line(-1), dataRef(0)
-{
-}
-
-QDeclarativeExpressionPrivate::~QDeclarativeExpressionPrivate()
-{
- qPersistentDispose(v8qmlscope);
- qPersistentDispose(v8function);
- if (dataRef) dataRef->release();
- dataRef = 0;
-}
-
-void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QString &expr,
- QObject *me)
-{
- expression = expr;
-
- QDeclarativeAbstractExpression::setContext(ctxt);
- setScopeObject(me);
- expressionFunctionValid = false;
- expressionFunctionRewritten = false;
-}
-
-void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, v8::Handle<v8::Function> func,
- QObject *me)
-{
- QDeclarativeAbstractExpression::setContext(ctxt);
- setScopeObject(me);
-
- v8function = qPersistentNew<v8::Function>(func);
- setUseSharedContext(false);
- expressionFunctionValid = true;
- expressionFunctionRewritten = false;
- extractExpressionFromFunction = true;
-}
-
-void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QString &expr,
- bool isRewritten, QObject *me, const QString &srcUrl,
- int lineNumber, int columnNumber)
-{
- url = srcUrl;
- line = lineNumber;
- column = columnNumber;
-
- expression = expr;
-
- expressionFunctionValid = false;
- expressionFunctionRewritten = isRewritten;
-
- QDeclarativeAbstractExpression::setContext(ctxt);
- setScopeObject(me);
-}
-
-void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QByteArray &expr,
- bool isRewritten, QObject *me, const QString &srcUrl,
- int lineNumber, int columnNumber)
-{
- url = srcUrl;
- line = lineNumber;
- column = columnNumber;
-
- if (isRewritten) {
- expressionFunctionValid = true;
- expressionFunctionRewritten = true;
- v8function = evalFunction(ctxt, me, expr.constData(), expr.length(),
- srcUrl, lineNumber, &v8qmlscope);
- setUseSharedContext(false);
-
- expressionUtf8 = expr;
- } else {
- expression = QString::fromUtf8(expr);
-
- expressionFunctionValid = false;
- expressionFunctionRewritten = isRewritten;
- }
-
- QDeclarativeAbstractExpression::setContext(ctxt);
- setScopeObject(me);
-}
-
-// Callee owns the persistent handle
-v8::Persistent<v8::Function>
-QDeclarativeExpressionPrivate::evalFunction(QDeclarativeContextData *ctxt, QObject *scope,
- const char *code, int codeLength,
- const QString &filename, int line,
- v8::Persistent<v8::Object> *qmlscope)
-{
- QDeclarativeEngine *engine = ctxt->engine;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
-
- v8::HandleScope handle_scope;
- v8::Context::Scope ctxtscope(ep->v8engine()->context());
-
- v8::TryCatch tc;
- v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
- v8::Local<v8::Script> script = ep->v8engine()->qmlModeCompile(code, codeLength, filename, line);
- if (tc.HasCaught()) {
- QDeclarativeError error;
- error.setDescription(QLatin1String("Exception occurred during function compilation"));
- error.setLine(line);
- error.setUrl(QUrl::fromLocalFile(filename));
- v8::Local<v8::Message> message = tc.Message();
- if (!message.IsEmpty())
- QDeclarativeExpressionPrivate::exceptionToError(message, error);
- ep->warning(error);
- return v8::Persistent<v8::Function>();
- }
- v8::Local<v8::Value> result = script->Run(scopeobject);
- if (tc.HasCaught()) {
- QDeclarativeError error;
- error.setDescription(QLatin1String("Exception occurred during function evaluation"));
- error.setLine(line);
- error.setUrl(QUrl::fromLocalFile(filename));
- v8::Local<v8::Message> message = tc.Message();
- if (!message.IsEmpty())
- QDeclarativeExpressionPrivate::exceptionToError(message, error);
- ep->warning(error);
- return v8::Persistent<v8::Function>();
- }
- if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
- return qPersistentNew<v8::Function>(v8::Local<v8::Function>::Cast(result));
-}
-
-// Callee owns the persistent handle
-v8::Persistent<v8::Function>
-QDeclarativeExpressionPrivate::evalFunction(QDeclarativeContextData *ctxt, QObject *scope,
- const QString &code, const QString &filename, int line,
- v8::Persistent<v8::Object> *qmlscope)
-{
- QDeclarativeEngine *engine = ctxt->engine;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
-
- v8::HandleScope handle_scope;
- v8::Context::Scope ctxtscope(ep->v8engine()->context());
-
- v8::TryCatch tc;
- v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
- v8::Local<v8::Script> script = ep->v8engine()->qmlModeCompile(code, filename, line);
- if (tc.HasCaught()) {
- QDeclarativeError error;
- error.setDescription(QLatin1String("Exception occurred during function compilation"));
- error.setLine(line);
- error.setUrl(QUrl::fromLocalFile(filename));
- v8::Local<v8::Message> message = tc.Message();
- if (!message.IsEmpty())
- QDeclarativeExpressionPrivate::exceptionToError(message, error);
- ep->warning(error);
- return v8::Persistent<v8::Function>();
- }
- v8::Local<v8::Value> result = script->Run(scopeobject);
- if (tc.HasCaught()) {
- QDeclarativeError error;
- error.setDescription(QLatin1String("Exception occurred during function evaluation"));
- error.setLine(line);
- error.setUrl(QUrl::fromLocalFile(filename));
- v8::Local<v8::Message> message = tc.Message();
- if (!message.IsEmpty())
- QDeclarativeExpressionPrivate::exceptionToError(message, error);
- ep->warning(error);
- return v8::Persistent<v8::Function>();
- }
- if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
- return qPersistentNew<v8::Function>(v8::Local<v8::Function>::Cast(result));
-}
-
-QDeclarativeExpression *
-QDeclarativeExpressionPrivate::create(QDeclarativeContextData *ctxt, QObject *object,
- const QString &expr, bool isRewritten,
- const QString &url, int lineNumber, int columnNumber)
-{
- return new QDeclarativeExpression(ctxt, object, expr, isRewritten, url, lineNumber, columnNumber, *new QDeclarativeExpressionPrivate);
-}
-
-/*!
- \class QDeclarativeExpression
- \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 QtQuick 2.0
-
- 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
-*/
-
-/*!
- Create an invalid QDeclarativeExpression.
-
- As the expression will not have an associated QDeclarativeContext, this will be a
- null expression object and its value will always be an invalid QVariant.
- */
-QDeclarativeExpression::QDeclarativeExpression()
-: QObject(*new QDeclarativeExpressionPrivate, 0)
-{
-}
-
-/*! \internal */
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt,
- QObject *object, const QString &expr, bool isRewritten,
- const QString &url, int lineNumber, int columnNumber,
- QDeclarativeExpressionPrivate &dd)
-: QObject(dd, 0)
-{
- Q_D(QDeclarativeExpression);
- d->init(ctxt, expr, isRewritten, object, url, lineNumber, columnNumber);
-}
-
-/*! \internal */
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt,
- QObject *object, const QByteArray &expr,
- bool isRewritten,
- const QString &url, int lineNumber, int columnNumber,
- QDeclarativeExpressionPrivate &dd)
-: QObject(dd, 0)
-{
- Q_D(QDeclarativeExpression);
- d->init(ctxt, expr, isRewritten, object, url, lineNumber, columnNumber);
-}
-
-/*!
- Create a QDeclarativeExpression object that is a child of \a parent.
-
- The \script provides the expression to be evaluated, the context to evaluate it in,
- and the scope object to evaluate it with.
-
- This constructor is functionally equivalent to the following, but in most cases
- is more efficient.
- \code
- QDeclarativeExpression expression(script.context(), script.scopeObject(), script.script(), parent);
- \endcode
-
- \sa QDeclarativeScriptString
-*/
-QDeclarativeExpression::QDeclarativeExpression(const QDeclarativeScriptString &script, QObject *parent)
-: QObject(*new QDeclarativeExpressionPrivate, parent)
-{
- Q_D(QDeclarativeExpression);
- bool defaultConstruction = false;
-
- int id = script.d.data()->bindingId;
- if (id < 0) {
- defaultConstruction = true;
- } else {
- QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(script.context());
-
- QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(script.context()->engine());
- QDeclarativeCompiledData *cdata = 0;
- QDeclarativeTypeData *typeData = 0;
- if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
- typeData = engine->typeLoader.get(ctxtdata->url);
- cdata = typeData->compiledData();
- }
-
- if (cdata)
- d->init(ctxtdata, cdata->primitives.at(id), true, script.scopeObject(),
- cdata->name, script.d.data()->lineNumber, script.d.data()->columnNumber);
- else
- defaultConstruction = true;
-
- if (cdata)
- cdata->release();
- if (typeData)
- typeData->release();
- }
-
- if (defaultConstruction)
- d->init(QDeclarativeContextData::get(script.context()), script.script(), script.scopeObject());
-}
-
-/*!
- Create a QDeclarativeExpression object that is a child of \a parent.
-
- The \a expression JavaScript will be executed in the \a ctxt QDeclarativeContext.
- If specified, the \a scope object's properties will also be in scope during
- the expression's execution.
-*/
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt,
- QObject *scope,
- const QString &expression,
- QObject *parent)
-: QObject(*new QDeclarativeExpressionPrivate, parent)
-{
- Q_D(QDeclarativeExpression);
- d->init(QDeclarativeContextData::get(ctxt), expression, scope);
-}
-
-/*!
- \internal
-*/
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope,
- const QString &expression)
-: QObject(*new QDeclarativeExpressionPrivate, 0)
-{
- Q_D(QDeclarativeExpression);
- d->init(ctxt, expression, scope);
-}
-
-/*! \internal */
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope,
- const QString &expression, QDeclarativeExpressionPrivate &dd)
-: QObject(dd, 0)
-{
- Q_D(QDeclarativeExpression);
- d->init(ctxt, expression, scope);
-}
-
-/*!
- \internal
-
- To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle<v8::Function>.
- For example:
- v8::Handle<v8::Function> function;
- new QDeclarativeExpression(ctxt, scope, &function, ...);
- */
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope, void *functionPtr,
- QDeclarativeExpressionPrivate &dd)
-: QObject(dd, 0)
-{
- v8::Handle<v8::Function> function = *(v8::Handle<v8::Function> *)functionPtr;
-
- Q_D(QDeclarativeExpression);
- d->init(ctxt, function, scope);
-}
-
-/*!
- Destroy the QDeclarativeExpression instance.
-*/
-QDeclarativeExpression::~QDeclarativeExpression()
-{
-}
-
-/*!
- Returns the QDeclarativeEngine this expression is associated with, or 0 if there
- is no association or the QDeclarativeEngine has been destroyed.
-*/
-QDeclarativeEngine *QDeclarativeExpression::engine() const
-{
- Q_D(const QDeclarativeExpression);
- return d->context()?d->context()->engine:0;
-}
-
-/*!
- Returns the QDeclarativeContext this expression is associated with, or 0 if there
- is no association or the QDeclarativeContext has been destroyed.
-*/
-QDeclarativeContext *QDeclarativeExpression::context() const
-{
- Q_D(const QDeclarativeExpression);
- QDeclarativeContextData *data = d->context();
- return data?data->asQDeclarativeContext():0;
-}
-
-/*!
- Returns the expression string.
-*/
-QString QDeclarativeExpression::expression() const
-{
- Q_D(const QDeclarativeExpression);
- if (d->extractExpressionFromFunction && context()->engine()) {
- QV8Engine *v8engine = QDeclarativeEnginePrivate::getV8Engine(context()->engine());
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(v8engine->context());
-
- return v8engine->toString(v8::Handle<v8::Value>(d->v8function));
- } else if (!d->expressionUtf8.isEmpty()) {
- return QString::fromUtf8(d->expressionUtf8);
- } else {
- return d->expression;
- }
-}
-
-/*!
- Set the expression to \a expression.
-*/
-void QDeclarativeExpression::setExpression(const QString &expression)
-{
- Q_D(QDeclarativeExpression);
-
- d->resetNotifyOnValueChanged();
- d->expression = expression;
- d->expressionUtf8.clear();
- d->expressionFunctionValid = false;
- d->expressionFunctionRewritten = false;
- qPersistentDispose(d->v8function);
- qPersistentDispose(d->v8qmlscope);
-}
-
-void QDeclarativeExpressionPrivate::exceptionToError(v8::Handle<v8::Message> message,
- QDeclarativeError &error)
-{
- Q_ASSERT(!message.IsEmpty());
-
- v8::Handle<v8::Value> name = message->GetScriptResourceName();
- v8::Handle<v8::String> description = message->Get();
- int lineNumber = message->GetLineNumber();
-
- v8::Local<v8::String> file = name->IsString()?name->ToString():v8::Local<v8::String>();
- if (file.IsEmpty() || file->Length() == 0)
- error.setUrl(QUrl(QLatin1String("<Unknown File>")));
- else
- error.setUrl(QUrl(QV8Engine::toStringStatic(file)));
-
- error.setLine(lineNumber);
- error.setColumn(-1);
-
- QString qDescription = QV8Engine::toStringStatic(description);
- if (qDescription.startsWith(QLatin1String("Uncaught ")))
- qDescription = qDescription.mid(9 /* strlen("Uncaught ") */);
-
- error.setDescription(qDescription);
-}
-
-void QDeclarativeJavaScriptExpression::setNotifyOnValueChanged(bool v)
-{
- activeGuards.setFlagValue(v);
- if (!v) clearGuards();
-}
-
-void QDeclarativeJavaScriptExpression::resetNotifyOnValueChanged()
-{
- clearGuards();
-}
-
-v8::Local<v8::Value>
-QDeclarativeJavaScriptExpression::evaluate(QDeclarativeContextData *context,
- v8::Handle<v8::Function> function, bool *isUndefined)
-{
- Q_ASSERT(context && context->engine);
-
- if (function.IsEmpty() || function->IsUndefined()) {
- if (isUndefined) *isUndefined = true;
- return v8::Local<v8::Value>();
- }
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine);
-
- Q_ASSERT(notifyOnValueChanged() || activeGuards.isEmpty());
- GuardCapture capture(context->engine, this);
-
- QDeclarativeEnginePrivate::PropertyCapture *lastPropertyCapture = ep->propertyCapture;
- ep->propertyCapture = notifyOnValueChanged()?&capture:0;
-
-
- if (notifyOnValueChanged())
- capture.guards.copyAndClearPrepend(activeGuards);
-
- QDeclarativeContextData *lastSharedContext = 0;
- QObject *lastSharedScope = 0;
-
- bool sharedContext = useSharedContext();
-
- // All code that follows must check with watcher before it accesses data members
- // incase we have been deleted.
- DeleteWatcher watcher(this);
-
- if (sharedContext) {
- lastSharedContext = ep->sharedContext;
- lastSharedScope = ep->sharedScope;
- ep->sharedContext = context;
- ep->sharedScope = scopeObject();
- }
-
- v8::Local<v8::Value> result;
- {
- v8::TryCatch try_catch;
- v8::Handle<v8::Object> This = ep->v8engine()->global();
- if (scopeObject() && requiresThisObject()) {
- v8::Handle<v8::Value> value = ep->v8engine()->newQObject(scopeObject());
- if (value->IsObject()) This = v8::Handle<v8::Object>::Cast(value);
- }
-
- result = function->Call(This, 0, 0);
-
- if (isUndefined)
- *isUndefined = try_catch.HasCaught() || result->IsUndefined();
-
- if (watcher.wasDeleted()) {
- } else if (try_catch.HasCaught()) {
- v8::Context::Scope scope(ep->v8engine()->context());
- v8::Local<v8::Message> message = try_catch.Message();
- if (!message.IsEmpty()) {
- QDeclarativeExpressionPrivate::exceptionToError(message, delayedError()->error);
- } else {
- if (hasDelayedError()) delayedError()->error = QDeclarativeError();
- }
- } else {
- if (hasDelayedError()) delayedError()->error = QDeclarativeError();
- }
- }
-
- if (sharedContext) {
- ep->sharedContext = lastSharedContext;
- ep->sharedScope = lastSharedScope;
- }
-
- if (capture.errorString) {
- for (int ii = 0; ii < capture.errorString->count(); ++ii)
- qWarning("%s", qPrintable(capture.errorString->at(ii)));
- delete capture.errorString;
- capture.errorString = 0;
- }
-
- while (Guard *g = capture.guards.takeFirst())
- g->Delete();
-
- ep->propertyCapture = lastPropertyCapture;
-
- return result;
-}
-
-void QDeclarativeJavaScriptExpression::GuardCapture::captureProperty(QDeclarativeNotifier *n)
-{
- if (expression) {
-
- // Try and find a matching guard
- while (!guards.isEmpty() && !guards.first()->isConnected(n))
- guards.takeFirst()->Delete();
-
- Guard *g = 0;
- if (!guards.isEmpty()) {
- g = guards.takeFirst();
- g->cancelNotify();
- Q_ASSERT(g->isConnected(n));
- } else {
- g = Guard::New(expression, engine);
- g->connect(n);
- }
-
- expression->activeGuards.prepend(g);
- }
-}
-
-void QDeclarativeJavaScriptExpression::GuardCapture::captureProperty(QObject *o, int c, int n)
-{
- if (expression) {
- if (n == -1) {
- if (!errorString) {
- errorString = new QStringList;
- QString preamble = QLatin1String("QDeclarativeExpression: Expression ") +
- expression->m_vtable->expressionIdentifier(expression) +
- QLatin1String(" depends on non-NOTIFYable properties:");
- errorString->append(preamble);
- }
-
- const QMetaObject *metaObj = o->metaObject();
- QMetaProperty metaProp = metaObj->property(c);
-
- QString error = QLatin1String(" ") +
- QString::fromUtf8(metaObj->className()) +
- QLatin1String("::") +
- QString::fromUtf8(metaProp.name());
- errorString->append(error);
- } else {
-
- // Try and find a matching guard
- while (!guards.isEmpty() && !guards.first()->isConnected(o, n))
- guards.takeFirst()->Delete();
-
- Guard *g = 0;
- if (!guards.isEmpty()) {
- g = guards.takeFirst();
- g->cancelNotify();
- Q_ASSERT(g->isConnected(o, n));
- } else {
- g = Guard::New(expression, engine);
- g->connect(o, n);
- }
-
- expression->activeGuards.prepend(g);
- }
- }
-}
-
-void QDeclarativeJavaScriptExpression::clearError()
-{
- if (m_vtable.hasValue()) {
- m_vtable.value().error = QDeclarativeError();
- m_vtable.value().removeError();
- }
-}
-
-QDeclarativeError QDeclarativeJavaScriptExpression::error() const
-{
- if (m_vtable.hasValue()) return m_vtable.constValue()->error;
- else return QDeclarativeError();
-}
-
-QDeclarativeDelayedError *QDeclarativeJavaScriptExpression::delayedError()
-{
- return &m_vtable.value();
-}
-
-void QDeclarativeJavaScriptExpression::clearGuards()
-{
- while (Guard *g = activeGuards.takeFirst())
- g->Delete();
-}
-
-// Must be called with a valid handle scope
-v8::Local<v8::Value> QDeclarativeExpressionPrivate::v8value(QObject *secondaryScope, bool *isUndefined)
-{
- if (!expressionFunctionValid) {
- bool ok = true;
-
- QDeclarativeRewrite::RewriteBinding rewriteBinding;
- rewriteBinding.setName(name);
- QString code;
- if (expressionFunctionRewritten)
- code = expression;
- else
- code = rewriteBinding(expression, &ok);
-
- if (ok) v8function = evalFunction(context(), scopeObject(), code, url, line, &v8qmlscope);
- setUseSharedContext(false);
- expressionFunctionValid = true;
- }
-
-
- if (secondaryScope) {
- v8::Local<v8::Value> result;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context()->engine);
- QObject *restoreSecondaryScope = 0;
- restoreSecondaryScope = ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, secondaryScope);
- result = evaluate(context(), v8function, isUndefined);
- ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, restoreSecondaryScope);
- return result;
- } else {
- return evaluate(context(), v8function, isUndefined);
- }
-}
-
-QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined)
-{
- Q_Q(QDeclarativeExpression);
-
- if (!context() || !context()->isValid()) {
- qWarning("QDeclarativeExpression: Attempted to evaluate an expression in an invalid context");
- return QVariant();
- }
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(q->engine());
- QVariant rv;
-
- ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation.
-
- {
- v8::HandleScope handle_scope;
- v8::Context::Scope context_scope(ep->v8engine()->context());
- v8::Local<v8::Value> result = v8value(secondaryScope, isUndefined);
- rv = ep->v8engine()->toVariant(result, qMetaTypeId<QList<QObject*> >());
- }
-
- ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete.
-
- return rv;
-}
-
-/*!
- Evaulates the expression, returning the result of the evaluation,
- or an invalid QVariant if the expression is invalid or has an error.
-
- \a valueIsUndefined is set to true if the expression resulted in an
- undefined value.
-
- \sa hasError(), error()
-*/
-QVariant QDeclarativeExpression::evaluate(bool *valueIsUndefined)
-{
- Q_D(QDeclarativeExpression);
- return d->value(0, valueIsUndefined);
-}
-
-/*!
-Returns true if the valueChanged() signal is emitted when the expression's evaluated
-value changes.
-*/
-bool QDeclarativeExpression::notifyOnValueChanged() const
-{
- Q_D(const QDeclarativeExpression);
- return d->notifyOnValueChanged();
-}
-
-/*!
- Sets whether the valueChanged() signal is emitted when the
- expression's evaluated value changes.
-
- If \a notifyOnChange is true, the QDeclarativeExpression will
- monitor properties involved in the expression's evaluation, and emit
- QDeclarativeExpression::valueChanged() if they have changed. This
- allows an application to ensure that any value associated with the
- result of the expression remains up to date.
-
- If \a notifyOnChange is false (default), the QDeclarativeExpression
- will not montitor properties involved in the expression's
- evaluation, and QDeclarativeExpression::valueChanged() will never be
- emitted. This is more efficient if an application wants a "one off"
- evaluation of the expression.
-*/
-void QDeclarativeExpression::setNotifyOnValueChanged(bool notifyOnChange)
-{
- Q_D(QDeclarativeExpression);
- d->setNotifyOnValueChanged(notifyOnChange);
-}
-
-/*!
- Returns the source file URL for this expression. The source location must
- have been previously set by calling setSourceLocation().
-*/
-QString QDeclarativeExpression::sourceFile() const
-{
- Q_D(const QDeclarativeExpression);
- return d->url;
-}
-
-/*!
- Returns the source file line number for this expression. The source location
- must have been previously set by calling setSourceLocation().
-*/
-int QDeclarativeExpression::lineNumber() const
-{
- Q_D(const QDeclarativeExpression);
- return d->line;
-}
-
-/*!
- Returns the source file column number for this expression. The source location
- must have been previously set by calling setSourceLocation().
-*/
-int QDeclarativeExpression::columnNumber() const
-{
- Q_D(const QDeclarativeExpression);
- return d->column;
-}
-
-/*!
- Set the location of this expression to \a line of \a url. This information
- is used by the script engine.
-*/
-void QDeclarativeExpression::setSourceLocation(const QString &url, int line, int column)
-{
- Q_D(QDeclarativeExpression);
- d->url = url;
- d->line = line;
- d->column = column;
-}
-
-/*!
- Returns the expression's scope object, if provided, otherwise 0.
-
- In addition to data provided by the expression's QDeclarativeContext, the scope
- object's properties are also in scope during the expression's evaluation.
-*/
-QObject *QDeclarativeExpression::scopeObject() const
-{
- Q_D(const QDeclarativeExpression);
- return d->scopeObject();
-}
-
-/*!
- Returns true if the last call to evaluate() resulted in an error,
- otherwise false.
-
- \sa error(), clearError()
-*/
-bool QDeclarativeExpression::hasError() const
-{
- Q_D(const QDeclarativeExpression);
- return d->hasError();
-}
-
-/*!
- Clear any expression errors. Calls to hasError() following this will
- return false.
-
- \sa hasError(), error()
-*/
-void QDeclarativeExpression::clearError()
-{
- Q_D(QDeclarativeExpression);
- d->clearError();
-}
-
-/*!
- Return any error from the last call to evaluate(). If there was no error,
- this returns an invalid QDeclarativeError instance.
-
- \sa hasError(), clearError()
-*/
-
-QDeclarativeError QDeclarativeExpression::error() const
-{
- Q_D(const QDeclarativeExpression);
- return d->error();
-}
-
-/*!
- \fn void QDeclarativeExpression::valueChanged()
-
- Emitted each time the expression value changes from the last time it was
- evaluated. The expression must have been evaluated at least once (by
- calling QDeclarativeExpression::evaluate()) before this signal will be emitted.
-*/
-
-void QDeclarativeExpressionPrivate::expressionChanged(QDeclarativeJavaScriptExpression *e)
-{
- QDeclarativeExpressionPrivate *This = static_cast<QDeclarativeExpressionPrivate *>(e);
- This->expressionChanged();
-}
-
-void QDeclarativeExpressionPrivate::expressionChanged()
-{
- Q_Q(QDeclarativeExpression);
- emit q->valueChanged();
-}
-
-QString QDeclarativeExpressionPrivate::expressionIdentifier(QDeclarativeJavaScriptExpression *e)
-{
- QDeclarativeExpressionPrivate *This = static_cast<QDeclarativeExpressionPrivate *>(e);
- return QLatin1String("\"") + This->expression + QLatin1String("\"");
-}
-
-QDeclarativeAbstractExpression::QDeclarativeAbstractExpression()
-: m_prevExpression(0), m_nextExpression(0)
-{
-}
-
-QDeclarativeAbstractExpression::~QDeclarativeAbstractExpression()
-{
- if (m_prevExpression) {
- *m_prevExpression = m_nextExpression;
- if (m_nextExpression)
- m_nextExpression->m_prevExpression = m_prevExpression;
- }
-
- if (m_context.isT2())
- m_context.asT2()->_s = 0;
-}
-
-QDeclarativeContextData *QDeclarativeAbstractExpression::context() const
-{
- if (m_context.isT1()) return m_context.asT1();
- else return m_context.asT2()->_c;
-}
-
-void QDeclarativeAbstractExpression::setContext(QDeclarativeContextData *context)
-{
- if (m_prevExpression) {
- *m_prevExpression = m_nextExpression;
- if (m_nextExpression)
- m_nextExpression->m_prevExpression = m_prevExpression;
- m_prevExpression = 0;
- m_nextExpression = 0;
- }
-
- if (m_context.isT1()) m_context = context;
- else m_context.asT2()->_c = context;
-
- if (context) {
- m_nextExpression = context->expressions;
- if (m_nextExpression)
- m_nextExpression->m_prevExpression = &m_nextExpression;
- m_prevExpression = &context->expressions;
- context->expressions = this;
- }
-}
-
-void QDeclarativeAbstractExpression::refresh()
-{
-}
-
-bool QDeclarativeAbstractExpression::isValid() const
-{
- return context() != 0;
-}
-
-QT_END_NAMESPACE
-
-#include <moc_qdeclarativeexpression.cpp>
diff --git a/src/declarative/qml/qdeclarativeexpression.h b/src/declarative/qml/qdeclarativeexpression.h
deleted file mode 100644
index c9ab40854d..0000000000
--- a/src/declarative/qml/qdeclarativeexpression.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEEXPRESSION_H
-#define QDECLARATIVEEXPRESSION_H
-
-#include <QtDeclarative/qdeclarativeerror.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QString;
-class QDeclarativeRefCount;
-class QDeclarativeEngine;
-class QDeclarativeContext;
-class QDeclarativeExpressionPrivate;
-class QDeclarativeContextData;
-class Q_DECLARATIVE_EXPORT QDeclarativeExpression : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeExpression();
- QDeclarativeExpression(QDeclarativeContext *, QObject *, const QString &, QObject * = 0);
- explicit QDeclarativeExpression(const QDeclarativeScriptString &, QObject * = 0);
- virtual ~QDeclarativeExpression();
-
- QDeclarativeEngine *engine() const;
- QDeclarativeContext *context() const;
-
- QString expression() const;
- void setExpression(const QString &);
-
- bool notifyOnValueChanged() const;
- void setNotifyOnValueChanged(bool);
-
- QString sourceFile() const;
- int lineNumber() const;
- int columnNumber() const;
- void setSourceLocation(const QString &fileName, int line, int column = 0);
-
- QObject *scopeObject() const;
-
- bool hasError() const;
- void clearError();
- QDeclarativeError error() const;
-
- QVariant evaluate(bool *valueIsUndefined = 0);
-
-Q_SIGNALS:
- void valueChanged();
-
-protected:
- QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &,
- QDeclarativeExpressionPrivate &dd);
- QDeclarativeExpression(QDeclarativeContextData *, QObject *, void *,
- QDeclarativeExpressionPrivate &dd);
- QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &, bool,
- const QString &, int, int, QDeclarativeExpressionPrivate &dd);
- QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QByteArray &, bool,
- const QString &, int, int, QDeclarativeExpressionPrivate &dd);
-
-private:
- QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &);
-
- Q_DISABLE_COPY(QDeclarativeExpression)
- Q_DECLARE_PRIVATE(QDeclarativeExpression)
- friend class QDeclarativeDebugger;
- friend class QDeclarativeContext;
- friend class QDeclarativeVME;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEEXPRESSION_H
-
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
deleted file mode 100644
index 541a06dba5..0000000000
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ /dev/null
@@ -1,406 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEEXPRESSION_P_H
-#define QDECLARATIVEEXPRESSION_P_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 "qdeclarativeexpression.h"
-
-#include <private/qv8engine_p.h>
-#include <private/qfieldlist_p.h>
-#include <private/qflagpointer_p.h>
-#include <private/qdeletewatcher_p.h>
-#include <private/qdeclarativeguard_p.h>
-#include <private/qpointervaluepair_p.h>
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeAbstractExpression
-{
-public:
- QDeclarativeAbstractExpression();
- virtual ~QDeclarativeAbstractExpression();
-
- bool isValid() const;
-
- QDeclarativeContextData *context() const;
- void setContext(QDeclarativeContextData *);
-
- virtual void refresh();
-
- class DeleteWatcher {
- public:
- inline DeleteWatcher(QDeclarativeAbstractExpression *);
- inline ~DeleteWatcher();
- inline bool wasDeleted() const;
- private:
- friend class QDeclarativeAbstractExpression;
- QDeclarativeContextData *_c;
- QDeclarativeAbstractExpression **_w;
- QDeclarativeAbstractExpression *_s;
- };
-
-private:
- friend class QDeclarativeContext;
- friend class QDeclarativeContextData;
- friend class QDeclarativeContextPrivate;
-
- QBiPointer<QDeclarativeContextData, DeleteWatcher> m_context;
- QDeclarativeAbstractExpression **m_prevExpression;
- QDeclarativeAbstractExpression *m_nextExpression;
-};
-
-class QDeclarativeDelayedError
-{
-public:
- inline QDeclarativeDelayedError() : nextError(0), prevError(0) {}
- inline ~QDeclarativeDelayedError() { removeError(); }
-
- QDeclarativeError error;
-
- bool addError(QDeclarativeEnginePrivate *);
-
- inline void removeError() {
- if (!prevError) return;
- if (nextError) nextError->prevError = prevError;
- *prevError = nextError;
- nextError = 0;
- prevError = 0;
- }
-
-private:
- QDeclarativeDelayedError *nextError;
- QDeclarativeDelayedError **prevError;
-};
-
-class QDeclarativeJavaScriptExpression
-{
-public:
- // Although this looks crazy, we implement our own "vtable" here, rather than relying on
- // C++ virtuals, to save memory. By doing it ourselves, we can overload the storage
- // location that is use for the vtable to also store the rarely used delayed error.
- // If we use C++ virtuals, we can't do this and it consts us an extra sizeof(void *) in
- // memory for every expression.
- struct VTable {
- QString (*expressionIdentifier)(QDeclarativeJavaScriptExpression *);
- void (*expressionChanged)(QDeclarativeJavaScriptExpression *);
- };
-
- QDeclarativeJavaScriptExpression(VTable *vtable);
-
- v8::Local<v8::Value> evaluate(QDeclarativeContextData *, v8::Handle<v8::Function>,
- bool *isUndefined);
-
- inline bool requiresThisObject() const;
- inline void setRequiresThisObject(bool v);
- inline bool useSharedContext() const;
- inline void setUseSharedContext(bool v);
- inline bool notifyOnValueChanged() const;
-
- void setNotifyOnValueChanged(bool v);
- void resetNotifyOnValueChanged();
-
- inline QObject *scopeObject() const;
- inline void setScopeObject(QObject *v);
-
- class DeleteWatcher {
- public:
- inline DeleteWatcher(QDeclarativeJavaScriptExpression *);
- inline ~DeleteWatcher();
- inline bool wasDeleted() const;
- private:
- friend class QDeclarativeJavaScriptExpression;
- QObject *_c;
- QDeclarativeJavaScriptExpression **_w;
- QDeclarativeJavaScriptExpression *_s;
- };
-
- inline bool hasError() const;
- inline bool hasDelayedError() const;
- QDeclarativeError error() const;
- void clearError();
- QDeclarativeDelayedError *delayedError();
-
-protected:
- ~QDeclarativeJavaScriptExpression();
-
-private:
- typedef QDeclarativeJavaScriptExpressionGuard Guard;
- friend class QDeclarativeJavaScriptExpressionGuard;
-
- struct GuardCapture : public QDeclarativeEnginePrivate::PropertyCapture {
- GuardCapture(QDeclarativeEngine *engine, QDeclarativeJavaScriptExpression *e)
- : engine(engine), expression(e), errorString(0) { }
-
- ~GuardCapture() {
- Q_ASSERT(guards.isEmpty());
- Q_ASSERT(errorString == 0);
- }
-
- virtual void captureProperty(QDeclarativeNotifier *);
- virtual void captureProperty(QObject *, int, int);
-
- QDeclarativeEngine *engine;
- QDeclarativeJavaScriptExpression *expression;
- QFieldList<Guard, &Guard::next> guards;
- QStringList *errorString;
- };
-
- QPointerValuePair<VTable, QDeclarativeDelayedError> m_vtable;
-
- // We store some flag bits in the following flag pointers.
- // m_scopeObject:flag1 - requiresThisObject
- // activeGuards:flag1 - notifyOnValueChanged
- // activeGuards:flag2 - useSharedContext
- QBiPointer<QObject, DeleteWatcher> m_scopeObject;
- QForwardFieldList<Guard, &Guard::next> activeGuards;
-
- void clearGuards();
-};
-
-class QDeclarativeExpression;
-class QString;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeExpressionPrivate : public QObjectPrivate, public QDeclarativeJavaScriptExpression, public QDeclarativeAbstractExpression
-{
- Q_DECLARE_PUBLIC(QDeclarativeExpression)
-public:
- QDeclarativeExpressionPrivate();
- ~QDeclarativeExpressionPrivate();
-
- void init(QDeclarativeContextData *, const QString &, QObject *);
- void init(QDeclarativeContextData *, v8::Handle<v8::Function>, QObject *);
- void init(QDeclarativeContextData *, const QString &, bool, QObject *, const QString &, int, int);
- void init(QDeclarativeContextData *, const QByteArray &, bool, QObject *, const QString &, int, int);
-
- QVariant value(QObject *secondaryScope = 0, bool *isUndefined = 0);
-
- v8::Local<v8::Value> v8value(QObject *secondaryScope = 0, bool *isUndefined = 0);
-
- static inline QDeclarativeExpressionPrivate *get(QDeclarativeExpression *expr);
- static inline QDeclarativeExpression *get(QDeclarativeExpressionPrivate *expr);
-
- void _q_notify();
-
- static void exceptionToError(v8::Handle<v8::Message>, QDeclarativeError &);
- static v8::Persistent<v8::Function> evalFunction(QDeclarativeContextData *ctxt, QObject *scope,
- const QString &code, const QString &filename,
- int line,
- v8::Persistent<v8::Object> *qmlscope = 0);
- static v8::Persistent<v8::Function> evalFunction(QDeclarativeContextData *ctxt, QObject *scope,
- const char *code, int codeLength,
- const QString &filename, int line,
- v8::Persistent<v8::Object> *qmlscope = 0);
-
- static QDeclarativeExpression *create(QDeclarativeContextData *, QObject *, const QString &, bool,
- const QString &, int, int);
-
- bool expressionFunctionValid:1;
- bool expressionFunctionRewritten:1;
- bool extractExpressionFromFunction:1;
-
- // "Inherited" from QDeclarativeJavaScriptExpression
- static QString expressionIdentifier(QDeclarativeJavaScriptExpression *);
- static void expressionChanged(QDeclarativeJavaScriptExpression *);
- virtual void expressionChanged();
-
- QString expression;
- QByteArray expressionUtf8;
-
- v8::Persistent<v8::Object> v8qmlscope;
- v8::Persistent<v8::Function> v8function;
-
- QString url; // This is a QString for a reason. QUrls are slooooooow...
- int line;
- int column;
- QString name; //function name, hint for the debugger
-
- QDeclarativeRefCount *dataRef;
-};
-
-QDeclarativeAbstractExpression::DeleteWatcher::DeleteWatcher(QDeclarativeAbstractExpression *e)
-: _c(0), _w(0), _s(e)
-{
- if (e->m_context.isT1()) {
- _w = &_s;
- _c = e->m_context.asT1();
- e->m_context = this;
- } else {
- // Another watcher is already registered
- _w = &e->m_context.asT2()->_s;
- }
-}
-
-QDeclarativeAbstractExpression::DeleteWatcher::~DeleteWatcher()
-{
- Q_ASSERT(*_w == 0 || (*_w == _s && _s->m_context.isT2()));
- if (*_w && _s->m_context.asT2() == this)
- _s->m_context = _c;
-}
-
-bool QDeclarativeAbstractExpression::DeleteWatcher::wasDeleted() const
-{
- return *_w == 0;
-}
-
-QDeclarativeJavaScriptExpression::DeleteWatcher::DeleteWatcher(QDeclarativeJavaScriptExpression *e)
-: _c(0), _w(0), _s(e)
-{
- if (e->m_scopeObject.isT1()) {
- _w = &_s;
- _c = e->m_scopeObject.asT1();
- e->m_scopeObject = this;
- } else {
- // Another watcher is already registered
- _w = &e->m_scopeObject.asT2()->_s;
- }
-}
-
-QDeclarativeJavaScriptExpression::DeleteWatcher::~DeleteWatcher()
-{
- Q_ASSERT(*_w == 0 || (*_w == _s && _s->m_scopeObject.isT2()));
- if (*_w && _s->m_scopeObject.asT2() == this)
- _s->m_scopeObject = _c;
-}
-
-bool QDeclarativeJavaScriptExpression::DeleteWatcher::wasDeleted() const
-{
- return *_w == 0;
-}
-
-bool QDeclarativeJavaScriptExpression::requiresThisObject() const
-{
- return m_scopeObject.flag();
-}
-
-void QDeclarativeJavaScriptExpression::setRequiresThisObject(bool v)
-{
- m_scopeObject.setFlagValue(v);
-}
-
-bool QDeclarativeJavaScriptExpression::useSharedContext() const
-{
- return activeGuards.flag2();
-}
-
-void QDeclarativeJavaScriptExpression::setUseSharedContext(bool v)
-{
- activeGuards.setFlag2Value(v);
-}
-
-bool QDeclarativeJavaScriptExpression::notifyOnValueChanged() const
-{
- return activeGuards.flag();
-}
-
-QObject *QDeclarativeJavaScriptExpression::scopeObject() const
-{
- if (m_scopeObject.isT1()) return m_scopeObject.asT1();
- else return m_scopeObject.asT2()->_c;
-}
-
-void QDeclarativeJavaScriptExpression::setScopeObject(QObject *v)
-{
- if (m_scopeObject.isT1()) m_scopeObject = v;
- else m_scopeObject.asT2()->_c = v;
-}
-
-bool QDeclarativeJavaScriptExpression::hasError() const
-{
- return m_vtable.hasValue() && m_vtable.constValue()->error.isValid();
-}
-
-bool QDeclarativeJavaScriptExpression::hasDelayedError() const
-{
- return m_vtable.hasValue();
-}
-
-QDeclarativeExpressionPrivate *QDeclarativeExpressionPrivate::get(QDeclarativeExpression *expr)
-{
- return static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr));
-}
-
-QDeclarativeExpression *QDeclarativeExpressionPrivate::get(QDeclarativeExpressionPrivate *expr)
-{
- return expr->q_func();
-}
-
-QDeclarativeJavaScriptExpressionGuard::QDeclarativeJavaScriptExpressionGuard(QDeclarativeJavaScriptExpression *e)
-: expression(e), next(0)
-{
- callback = &endpointCallback;
-}
-
-void QDeclarativeJavaScriptExpressionGuard::endpointCallback(QDeclarativeNotifierEndpoint *e)
-{
- QDeclarativeJavaScriptExpression *expression =
- static_cast<QDeclarativeJavaScriptExpressionGuard *>(e)->expression;
-
- expression->m_vtable->expressionChanged(expression);
-}
-
-QDeclarativeJavaScriptExpressionGuard *
-QDeclarativeJavaScriptExpressionGuard::New(QDeclarativeJavaScriptExpression *e,
- QDeclarativeEngine *engine)
-{
- Q_ASSERT(e);
- return QDeclarativeEnginePrivate::get(engine)->jsExpressionGuardPool.New(e);
-}
-
-void QDeclarativeJavaScriptExpressionGuard::Delete()
-{
- QRecyclePool<QDeclarativeJavaScriptExpressionGuard>::Delete(this);
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEEXPRESSION_P_H
diff --git a/src/declarative/qml/qdeclarativeextensioninterface.h b/src/declarative/qml/qdeclarativeextensioninterface.h
deleted file mode 100644
index ce2560cec0..0000000000
--- a/src/declarative/qml/qdeclarativeextensioninterface.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEEXTENSIONINTERFACE_H
-#define QDECLARATIVEEXTENSIONINTERFACE_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeEngine;
-
-class Q_DECLARATIVE_EXPORT QDeclarativeTypesExtensionInterface
-{
-public:
- virtual ~QDeclarativeTypesExtensionInterface() {}
- virtual void registerTypes(const char *uri) = 0;
-};
-
-class Q_DECLARATIVE_EXPORT QDeclarativeExtensionInterface : public QDeclarativeTypesExtensionInterface
-{
-public:
- virtual ~QDeclarativeExtensionInterface() {}
- virtual void initializeEngine(QDeclarativeEngine *engine, const char *uri) = 0;
-};
-
-#define QDeclarativeTypesExtensionInterface_iid "org.qt-project.Qt.QDeclarativeTypesExtensionInterface"
-
-Q_DECLARE_INTERFACE(QDeclarativeTypesExtensionInterface, "org.qt-project.Qt.QDeclarativeTypesExtensionInterface/1.0")
-
-#define QDeclarativeExtensionInterface_iid "org.qt-project.Qt.QDeclarativeExtensionInterface"
-
-Q_DECLARE_INTERFACE(QDeclarativeExtensionInterface, QDeclarativeExtensionInterface_iid)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEEXTENSIONINTERFACE_H
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp
deleted file mode 100644
index f69fa30e0d..0000000000
--- a/src/declarative/qml/qdeclarativeextensionplugin.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeextensionplugin.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \since 4.7
- \class QDeclarativeExtensionPlugin
- \brief The QDeclarativeExtensionPlugin class provides an abstract base for custom QML extension plugins.
-
- \ingroup plugins
-
- 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{Writing a 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.
-
-
- \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 with a specific \l {QML Modules}{module} 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{Writing a 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}
-*/
-
-/*!
- \fn void QDeclarativeExtensionPlugin::registerTypes(const char *uri)
-
- Registers the QML types in the given \a uri. Subclasses should implement
- this to call qmlRegisterType() for all types which are provided by the extension
- plugin.
-
- The \a uri is an identifier for the plugin generated by the QML engine
- based on the name and path of the extension's plugin library.
-*/
-
-/*!
- Constructs a QML extension plugin with the given \a parent.
-
- Note that this constructor is invoked automatically by the
- Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
- explicitly.
-*/
-QDeclarativeExtensionPlugin::QDeclarativeExtensionPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- \internal
- */
-QDeclarativeExtensionPlugin::~QDeclarativeExtensionPlugin()
-{
-}
-
-/*!
- \fn void QDeclarativeExtensionPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
-
- Initializes the extension from the \a uri using the \a engine. Here an application
- plugin might, for example, expose some data or objects to QML,
- as context properties on the engine's root context.
-*/
-
-void QDeclarativeExtensionPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
-{
- Q_UNUSED(engine);
- Q_UNUSED(uri);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.h b/src/declarative/qml/qdeclarativeextensionplugin.h
deleted file mode 100644
index 477e58d83c..0000000000
--- a/src/declarative/qml/qdeclarativeextensionplugin.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEEXTENSIONPLUGIN_H
-#define QDECLARATIVEEXTENSIONPLUGIN_H
-
-#include <QtCore/qplugin.h>
-
-#include <QtDeclarative/qdeclarativeextensioninterface.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeEngine;
-
-class Q_DECLARATIVE_EXPORT QDeclarativeExtensionPlugin : public QObject,
- public QDeclarativeExtensionInterface
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeExtensionInterface)
- Q_INTERFACES(QDeclarativeTypesExtensionInterface)
-public:
- explicit QDeclarativeExtensionPlugin(QObject *parent = 0);
- ~QDeclarativeExtensionPlugin();
-
- virtual void registerTypes(const char *uri) = 0;
- virtual void initializeEngine(QDeclarativeEngine *engine, const char *uri);
-
-private:
- Q_DISABLE_COPY(QDeclarativeExtensionPlugin)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEEXTENSIONPLUGIN_H
diff --git a/src/declarative/qml/qdeclarativeglobal_p.h b/src/declarative/qml/qdeclarativeglobal_p.h
deleted file mode 100644
index 3534a75bc9..0000000000
--- a/src/declarative/qml/qdeclarativeglobal_p.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEGLOBAL_H
-#define QDECLARATIVEGLOBAL_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/QObject>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-#define DEFINE_BOOL_CONFIG_OPTION(name, var) \
- static bool name() \
- { \
- static enum { Yes, No, Unknown } status = Unknown; \
- if (status == Unknown) { \
- QByteArray v = qgetenv(#var); \
- bool value = !v.isEmpty() && v != "0" && v != "false"; \
- if (value) status = Yes; \
- else status = No; \
- } \
- return status == Yes; \
- }
-
-#define FAST_CONNECT(Sender, Signal, Receiver, Method) \
-{ \
- QObject *sender = (Sender); \
- QObject *receiver = (Receiver); \
- const char *signal = (Signal); \
- const char *method = (Method); \
- static int signalIdx = -1; \
- static int methodIdx = -1; \
- if (signalIdx < 0) { \
- if (((int)(*signal) - '0') == QSIGNAL_CODE) \
- signalIdx = sender->metaObject()->indexOfSignal(signal+1); \
- else \
- qWarning("FAST_CONNECT: Invalid signal %s. Please make sure you are using the SIGNAL macro.", signal); \
- } \
- if (methodIdx < 0) { \
- int code = ((int)(*method) - '0'); \
- if (code == QSLOT_CODE) \
- methodIdx = receiver->metaObject()->indexOfSlot(method+1); \
- else if (code == QSIGNAL_CODE) \
- methodIdx = receiver->metaObject()->indexOfSignal(method+1); \
- else \
- qWarning("FAST_CONNECT: Invalid method %s. Please make sure you are using the SIGNAL or SLOT macro.", method); \
- } \
- QMetaObject::connect(sender, signalIdx, receiver, methodIdx, Qt::DirectConnection); \
-}
-
-#define Q_DECLARATIVE_PRIVATE_EXPORT Q_DECLARATIVE_EXPORT
-
-struct QDeclarativeGraphics_DerivedObject : public QObject
-{
- void setParent_noEvent(QObject *parent) {
- bool sce = d_ptr->sendChildEvents;
- d_ptr->sendChildEvents = false;
- setParent(parent);
- d_ptr->sendChildEvents = sce;
- }
-};
-
-/*!
- Returns true if the case of \a fileName is equivalent to the file case of
- \a fileName on disk, and false otherwise.
-
- This is used to ensure that the behavior of QML on a case-insensitive file
- system is the same as on a case-sensitive file system. This function
- performs a "best effort" attempt to determine the real case of the file.
- It may have false positives (say the case is correct when it isn't), but it
- should never have a false negative (say the case is incorrect when it is
- correct).
-*/
-bool QDeclarative_isFileCaseCorrect(const QString &fileName);
-
-/*!
- Makes the \a object a child of \a parent. Note that when using this method,
- neither \a parent nor the object's previous parent (if it had one) will
- receive ChildRemoved or ChildAdded events.
-*/
-inline void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
-{
- static_cast<QDeclarativeGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEGLOBAL_H
diff --git a/src/declarative/qml/qdeclarativeguard_p.h b/src/declarative/qml/qdeclarativeguard_p.h
deleted file mode 100644
index fdd5c016a5..0000000000
--- a/src/declarative/qml/qdeclarativeguard_p.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEGUARD_P_H
-#define QDECLARATIVEGUARD_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. 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>
-#include <private/qdeclarativedata_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeGuardImpl
-{
-public:
- inline QDeclarativeGuardImpl();
- inline QDeclarativeGuardImpl(QObject *);
- inline QDeclarativeGuardImpl(const QDeclarativeGuardImpl &);
- inline ~QDeclarativeGuardImpl();
-
- QObject *o;
- QDeclarativeGuardImpl *next;
- QDeclarativeGuardImpl **prev;
-
- inline void addGuard();
- inline void remGuard();
-};
-
-class QObject;
-template<class T>
-class QDeclarativeGuard : private QDeclarativeGuardImpl
-{
- friend class QDeclarativeData;
-public:
- inline QDeclarativeGuard();
- inline QDeclarativeGuard(T *);
- inline QDeclarativeGuard(const QDeclarativeGuard<T> &);
- inline virtual ~QDeclarativeGuard();
-
- inline QDeclarativeGuard<T> &operator=(const QDeclarativeGuard<T> &o);
- inline QDeclarativeGuard<T> &operator=(T *);
-
- inline T *object() const;
- inline void setObject(T *g);
-
- inline bool isNull() const
- { return !o; }
-
- inline T* operator->() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
- inline T& operator*() const
- { return *static_cast<T*>(const_cast<QObject*>(o)); }
- inline operator T*() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
- inline T* data() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
-
-protected:
- virtual void objectDestroyed(T *) {}
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeGuard<QObject>)
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeGuardImpl::QDeclarativeGuardImpl()
-: o(0), next(0), prev(0)
-{
-}
-
-QDeclarativeGuardImpl::QDeclarativeGuardImpl(QObject *g)
-: o(g), next(0), prev(0)
-{
- if (o) addGuard();
-}
-
-QDeclarativeGuardImpl::QDeclarativeGuardImpl(const QDeclarativeGuardImpl &g)
-: o(g.o), next(0), prev(0)
-{
- if (o) addGuard();
-}
-
-QDeclarativeGuardImpl::~QDeclarativeGuardImpl()
-{
- if (prev) remGuard();
- o = 0;
-}
-
-void QDeclarativeGuardImpl::addGuard()
-{
- Q_ASSERT(!prev);
-
- if (QObjectPrivate::get(o)->wasDeleted)
- return;
-
- QDeclarativeData *data = QDeclarativeData::get(o, true);
- next = data->guards;
- if (next) next->prev = &next;
- data->guards = this;
- prev = &data->guards;
-}
-
-void QDeclarativeGuardImpl::remGuard()
-{
- Q_ASSERT(prev);
-
- if (next) next->prev = prev;
- *prev = next;
- next = 0;
- prev = 0;
-}
-
-template<class T>
-QDeclarativeGuard<T>::QDeclarativeGuard()
-{
-}
-
-template<class T>
-QDeclarativeGuard<T>::QDeclarativeGuard(T *g)
-: QDeclarativeGuardImpl(g)
-{
-}
-
-template<class T>
-QDeclarativeGuard<T>::QDeclarativeGuard(const QDeclarativeGuard<T> &g)
-: QDeclarativeGuardImpl(g)
-{
-}
-
-template<class T>
-QDeclarativeGuard<T>::~QDeclarativeGuard()
-{
-}
-
-template<class T>
-QDeclarativeGuard<T> &QDeclarativeGuard<T>::operator=(const QDeclarativeGuard<T> &g)
-{
- setObject(g.object());
- return *this;
-}
-
-template<class T>
-QDeclarativeGuard<T> &QDeclarativeGuard<T>::operator=(T *g)
-{
- setObject(g);
- return *this;
-}
-
-template<class T>
-T *QDeclarativeGuard<T>::object() const
-{
- return static_cast<T *>(o);
-};
-
-template<class T>
-void QDeclarativeGuard<T>::setObject(T *g)
-{
- if (g != o) {
- if (prev) remGuard();
- o = g;
- if (o) addGuard();
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEGUARD_P_H
diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp
deleted file mode 100644
index f2749fff30..0000000000
--- a/src/declarative/qml/qdeclarativeimageprovider.cpp
+++ /dev/null
@@ -1,334 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeimageprovider.h"
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeImageProviderPrivate
-{
-public:
- QDeclarativeImageProvider::ImageType type;
-};
-
-/*!
- \class QDeclarativeTextureFactory
- \since 5.0
- \brief The QDeclarativeTextureFactory class provides an interface for loading custom textures from QML.
-
- The purpose of the texture factory is to provide a placeholder for a image
- data that can be converted into an OpenGL texture.
-
- Creating a texture directly is not possible as there is rarely an OpenGL context
- available in the thread that is responsible for loading the image data.
- */
-
-QDeclarativeTextureFactory::QDeclarativeTextureFactory()
-{
-}
-
-QDeclarativeTextureFactory::~QDeclarativeTextureFactory()
-{
-}
-
-
-
-/*!
- \fn QSGTexture *QDeclarativeTextureFactory::createTexture() const
-
- This function is called on the scene graph rendering thread to create a QSGTexture
- instance from the factory.
-
- QML will internally cache the returned texture as needed. Each call to this
- function should return a unique instance.
-
- The OpenGL context used for rendering is bound when this function is called.
- */
-
-/*!
- \fn QSize QDeclarativeTextureFactory::textureSize() const
-
- Returns the size of the texture. This function will be called from arbitrary threads
- and should not rely on an OpenGL context bound.
- */
-
-
-/*!
- \class QDeclarativeImageProvider
- \since 4.7
- \brief The QDeclarativeImageProvider class provides an interface for supporting pixmaps and threaded image requests in QML.
-
- QDeclarativeImageProvider is used to provide advanced image loading features
- in QML applications. It allows images in QML to be:
-
- \list
- \o Loaded using QPixmaps rather than actual image files
- \o Loaded asynchronously in a separate thread, if imageType() is \l{QDeclarativeImageProvider::ImageType}{ImageType::Image}
- \endlist
-
- To specify that an image should be loaded by an image provider, use the
- \bold {"image:"} scheme for the URL source of the image, followed by the
- identifiers of the image provider and the requested image. For example:
-
- \qml
- Image { source: "image://myimageprovider/image.png" }
- \endqml
-
- This specifies that the image should be loaded by the image provider named
- "myimageprovider", and the image to be loaded is named "image.png". The QML engine
- invokes the appropriate image provider according to the providers that have
- been registered through QDeclarativeEngine::addImageProvider().
-
- Note that the identifiers are case-insensitive, but the rest of the URL will be passed on with
- preserved case. For example, the below snippet would still specify that the image is loaded by the
- image provider named "myimageprovider", but it would request a different image than the above snippet
- ("Image.png" instead of "image.png").
- \qml
- Image { source: "image://MyImageProvider/Image.png" }
- \endqml
-
- If you want the rest of the URL to be case insensitive, you will have to take care
- of that yourself inside your image provider.
-
- \section2 An example
-
- Here are two images. Their \c source values indicate they should be loaded by
- an image provider named "colors", and the images to be loaded are "yellow"
- and "red", respectively:
-
- \snippet examples/declarative/cppextensions/imageprovider/imageprovider-example.qml 0
-
- When these images are loaded by QML, it looks for a matching image provider
- and calls its requestImage() or requestPixmap() method (depending on its
- imageType()) to load the image. The method is called with the \c id
- parameter set to "yellow" for the first image, and "red" for the second.
-
- Here is an image provider implementation that can load the images
- requested by the above QML. This implementation dynamically
- generates QPixmap images that are filled with the requested color:
-
- \snippet examples/declarative/cppextensions/imageprovider/imageprovider.cpp 0
- \codeline
- \snippet examples/declarative/cppextensions/imageprovider/imageprovider.cpp 1
-
- To make this provider accessible to QML, it is registered with the QML engine
- with a "colors" identifier:
-
- \code
- int main(int argc, char *argv[])
- {
- ...
-
- QDeclarativeEngine engine;
- engine->addImageProvider(QLatin1String("colors"), new ColorPixmapProvider);
-
- ...
- }
- \endcode
-
- Now the images can be successfully loaded in QML:
-
- \image imageprovider.png
-
- A complete example is available in Qt's
- \l {declarative/cppextensions/imageprovider}{examples/declarative/cppextensions/imageprovider}
- directory. Note the example registers the provider via a \l{QDeclarativeExtensionPlugin}{plugin}
- instead of registering it in the application \c main() function as shown above.
-
-
- \section2 Asynchronous image loading
-
- Image providers that support QImage loading automatically include support
- for asychronous loading of images. To enable asynchronous loading for an
- image source, set the \c asynchronous property to \c true for the relevant
- \l Image, \l BorderImage or \l AnimatedImage object. When this is enabled,
- the image request to the provider is run in a low priority thread,
- allowing image loading to be executed in the background, and reducing the
- performance impact on the user interface.
-
- Asynchronous loading is not supported for image providers that provide
- QPixmap rather than QImage values, as pixmaps can only be created in the
- main thread. In this case, if \l {Image::}{asynchronous} is set to
- \c true, the value is ignored and the image is loaded
- synchronously.
-
-
- \section2 Image caching
-
- Images returned by a QDeclarativeImageProvider are automatically cached,
- similar to any image loaded by the QML engine. When an image with a
- "image://" prefix is loaded from cache, requestImage() and requestPixmap()
- will not be called for the relevant image provider. If an image should always
- be fetched from the image provider, and should not be cached at all, set the
- \c cache property to \c false for the relevant \l Image, \l BorderImage or
- \l AnimatedImage object.
-
- \sa QDeclarativeEngine::addImageProvider()
-*/
-
-/*!
- \enum QDeclarativeImageProvider::ImageType
-
- Defines the type of image supported by this image provider.
-
- \value Image The Image Provider provides QImage images. The
- requestImage() method will be called for all image requests.
- \value Pixmap The Image Provider provides QPixmap images. The
- requestPixmap() method will be called for all image requests.
- \value Texture The Image Provider provides QSGTextureProvider based images.
- The requestTexture() method will be called for all image requests. \omitvalue
-*/
-
-/*!
- Creates an image provider that will provide images of the given \a type.
-*/
-QDeclarativeImageProvider::QDeclarativeImageProvider(ImageType type)
- : d(new QDeclarativeImageProviderPrivate)
-{
- d->type = type;
-}
-
-/*!
- Destroys the QDeclarativeImageProvider
-
- \note The destructor of your derived class need to be thread safe.
-*/
-QDeclarativeImageProvider::~QDeclarativeImageProvider()
-{
- delete d;
-}
-
-/*!
- Returns the image type supported by this provider.
-*/
-QDeclarativeImageProvider::ImageType QDeclarativeImageProvider::imageType() const
-{
- return d->type;
-}
-
-/*!
- Implement this method to return the image with \a id. The default
- implementation returns an empty image.
-
- The \a id is the requested image source, with the "image:" scheme and
- provider identifier removed. For example, if the image \l{Image::}{source}
- was "image://myprovider/icons/home", the given \a id would be "icons/home".
-
- The \a requestedSize corresponds to the \l {Image::sourceSize} requested by
- an Image element. If \a requestedSize is a valid size, the image
- returned should be of that size.
-
- In all cases, \a size must be set to the original size of the image. This
- is used to set the \l {Item::}{width} and \l {Item::}{height} of the
- relevant \l Image if these values have not been set explicitly.
-
- \note this method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
-*/
-QImage QDeclarativeImageProvider::requestImage(const QString &id, QSize *size, const QSize& requestedSize)
-{
- Q_UNUSED(id);
- Q_UNUSED(size);
- Q_UNUSED(requestedSize);
- if (d->type == Image)
- qWarning("ImageProvider supports Image type but has not implemented requestImage()");
- return QImage();
-}
-
-/*!
- Implement this method to return the pixmap with \a id. The default
- implementation returns an empty pixmap.
-
- The \a id is the requested image source, with the "image:" scheme and
- provider identifier removed. For example, if the image \l{Image::}{source}
- was "image://myprovider/icons/home", the given \a id would be "icons/home".
-
- The \a requestedSize corresponds to the \l {Image::sourceSize} requested by
- an Image element. If \a requestedSize is a valid size, the image
- returned should be of that size.
-
- In all cases, \a size must be set to the original size of the image. This
- is used to set the \l {Item::}{width} and \l {Item::}{height} of the
- relevant \l Image if these values have not been set explicitly.
-*/
-QPixmap QDeclarativeImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
-{
- Q_UNUSED(id);
- Q_UNUSED(size);
- Q_UNUSED(requestedSize);
- if (d->type == Pixmap)
- qWarning("ImageProvider supports Pixmap type but has not implemented requestPixmap()");
- return QPixmap();
-}
-
-
-/*!
- Implement this method to return the texture with \a id. The default
- implementation returns 0.
-
- The \a id is the requested image source, with the "image:" scheme and
- provider identifier removed. For example, if the image \l{Image::}{source}
- was "image://myprovider/icons/home", the given \a id would be "icons/home".
-
- The \a requestedSize corresponds to the \l {Image::sourceSize} requested by
- an Image element. If \a requestedSize is a valid size, the image
- returned should be of that size.
-
- In all cases, \a size must be set to the original size of the image. This
- is used to set the \l {Item::}{width} and \l {Item::}{height} of the
- relevant \l Image if these values have not been set explicitly.
-
- \note this method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
-*/
-
-QDeclarativeTextureFactory *QDeclarativeImageProvider::requestTexture(const QString &id, QSize *size, const QSize &requestedSize)
-{
- Q_UNUSED(id);
- Q_UNUSED(size);
- Q_UNUSED(requestedSize);
- if (d->type == Texture)
- qWarning("ImageProvider supports Texture type but has not implemented requestTexture()");
- return 0;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qdeclarativeimageprovider.h b/src/declarative/qml/qdeclarativeimageprovider.h
deleted file mode 100644
index 16af45282c..0000000000
--- a/src/declarative/qml/qdeclarativeimageprovider.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEIMAGEPROVIDER_H
-#define QDECLARATIVEIMAGEPROVIDER_H
-
-#include <QtGui/qimage.h>
-#include <QtGui/qpixmap.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeImageProviderPrivate;
-class QSGTexture;
-class QQuickCanvas;
-
-class Q_DECLARATIVE_EXPORT QDeclarativeTextureFactory : public QObject
-{
-public:
- QDeclarativeTextureFactory();
- virtual ~QDeclarativeTextureFactory();
-
- virtual QSGTexture *createTexture(QQuickCanvas *canvas) const = 0;
- virtual QSize textureSize() const = 0;
- virtual int textureByteCount() const = 0;
-};
-
-class Q_DECLARATIVE_EXPORT QDeclarativeImageProvider
-{
-public:
- enum ImageType {
- Image,
- Pixmap,
- Texture,
- Invalid
- };
-
- QDeclarativeImageProvider(ImageType type);
- virtual ~QDeclarativeImageProvider();
-
- ImageType imageType() const;
-
- virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize);
- virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize);
- virtual QDeclarativeTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize);
-
-private:
- QDeclarativeImageProviderPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEIMAGEPROVIDER
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
deleted file mode 100644
index a8d9035079..0000000000
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ /dev/null
@@ -1,1183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeimport_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qpluginloader.h>
-#include <QtCore/qlibraryinfo.h>
-#include <QtDeclarative/qdeclarativeextensioninterface.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativetypenamecache_p.h>
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
-DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
-
-static bool greaterThan(const QString &s1, const QString &s2)
-{
- return s1 > s2;
-}
-
-QString resolveLocalUrl(const QString &url, const QString &relative)
-{
- if (relative.contains(QLatin1Char(':'))) {
- // contains a host name
- return QUrl(url).resolved(QUrl(relative)).toString();
- } else if (relative.isEmpty()) {
- return url;
- } else if (relative.at(0) == QLatin1Char('/') || !url.contains(QLatin1Char('/'))) {
- return relative;
- } else {
- if (relative == QLatin1String("."))
- return url.left(url.lastIndexOf(QLatin1Char('/')) + 1);
- else if (relative.startsWith(QLatin1String("./")))
- return url.left(url.lastIndexOf(QLatin1Char('/')) + 1) + relative.mid(2);
- return url.left(url.lastIndexOf(QLatin1Char('/')) + 1) + relative;
- }
-}
-
-
-
-typedef QMap<QString, QString> StringStringMap;
-Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri
-
-class QDeclarativeImportedNamespace
-{
-public:
- struct Data {
- QString uri;
- QString url;
- int majversion;
- int minversion;
- bool isLibrary;
- QDeclarativeDirComponents qmlDirComponents;
- QDeclarativeDirScripts qmlDirScripts;
- };
- QList<Data> imports;
-
-
- bool find_helper(QDeclarativeTypeLoader *typeLoader, const Data &data, const QString& type, int *vmajor, int *vminor,
- QDeclarativeType** type_return, QString* url_return,
- QString *base = 0, bool *typeRecursionDetected = 0);
- bool find(QDeclarativeTypeLoader *typeLoader, const QString& type, int *vmajor, int *vminor, QDeclarativeType** type_return,
- QString* url_return, QString *base = 0, QList<QDeclarativeError> *errors = 0);
-};
-
-class QDeclarativeImportsPrivate {
-public:
- QDeclarativeImportsPrivate(QDeclarativeTypeLoader *loader);
- ~QDeclarativeImportsPrivate();
-
- bool importExtension(const QString &absoluteFilePath, const QString &uri,
- QDeclarativeImportDatabase *database, QDeclarativeDirComponents* components,
- QDeclarativeDirScripts *scripts,
- QList<QDeclarativeError> *errors);
-
- QString resolvedUri(const QString &dir_arg, QDeclarativeImportDatabase *database);
- bool add(const QDeclarativeDirComponents &qmldircomponentsnetwork,
- const QString& uri_arg, const QString& prefix,
- int vmaj, int vmin, QDeclarativeScript::Import::Type importType,
- QDeclarativeImportDatabase *database, QList<QDeclarativeError> *errors);
- bool find(const QString& type, int *vmajor, int *vminor,
- QDeclarativeType** type_return, QString* url_return, QList<QDeclarativeError> *errors);
-
- QDeclarativeImportedNamespace *findNamespace(const QString& type);
-
- QUrl baseUrl;
- QString base;
- int ref;
-
- QSet<QString> qmlDirFilesForWhichPluginsHaveBeenLoaded;
- QDeclarativeImportedNamespace unqualifiedset;
- QHash<QString,QDeclarativeImportedNamespace* > set;
- QDeclarativeTypeLoader *typeLoader;
-};
-
-/*!
-\class QDeclarativeImports
-\brief The QDeclarativeImports class encapsulates one QML document's import statements.
-\internal
-*/
-QDeclarativeImports::QDeclarativeImports(const QDeclarativeImports &copy)
-: d(copy.d)
-{
- ++d->ref;
-}
-
-QDeclarativeImports &
-QDeclarativeImports::operator =(const QDeclarativeImports &copy)
-{
- ++copy.d->ref;
- if (--d->ref == 0)
- delete d;
- d = copy.d;
- return *this;
-}
-
-QDeclarativeImports::QDeclarativeImports(QDeclarativeTypeLoader *typeLoader)
- : d(new QDeclarativeImportsPrivate(typeLoader))
-{
-}
-
-QDeclarativeImports::~QDeclarativeImports()
-{
- if (--d->ref == 0)
- delete d;
-}
-
-/*!
- Sets the base URL to be used for all relative file imports added.
-*/
-void QDeclarativeImports::setBaseUrl(const QUrl& url, const QString &urlString)
-{
- d->baseUrl = url;
-
- if (urlString.isEmpty()) {
- d->base = url.toString();
- } else {
- //Q_ASSERT(url.toString() == urlString);
- d->base = urlString;
- }
-}
-
-/*!
- Returns the base URL to be used for all relative file imports added.
-*/
-QUrl QDeclarativeImports::baseUrl() const
-{
- return d->baseUrl;
-}
-
-void QDeclarativeImports::populateCache(QDeclarativeTypeNameCache *cache, QDeclarativeEngine *engine) const
-{
- const QDeclarativeImportedNamespace &set = d->unqualifiedset;
-
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
- const QDeclarativeImportedNamespace::Data &data = set.imports.at(ii);
- QDeclarativeTypeModule *module = QDeclarativeMetaType::typeModule(data.uri, data.majversion);
- if (module)
- cache->m_anonymousImports.append(QDeclarativeTypeModuleVersion(module, data.minversion));
- }
-
- for (QHash<QString,QDeclarativeImportedNamespace* >::ConstIterator iter = d->set.begin();
- iter != d->set.end();
- ++iter) {
-
- const QDeclarativeImportedNamespace &set = *iter.value();
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
- const QDeclarativeImportedNamespace::Data &data = set.imports.at(ii);
- QDeclarativeTypeModule *module = QDeclarativeMetaType::typeModule(data.uri, data.majversion);
- if (module) {
- QDeclarativeTypeNameCache::Import &import = cache->m_namedImports[iter.key()];
- import.modules.append(QDeclarativeTypeModuleVersion(module, data.minversion));
- }
-
- QDeclarativeMetaType::ModuleApi moduleApi = QDeclarativeMetaType::moduleApi(data.uri, data.majversion, data.minversion);
- if (moduleApi.script || moduleApi.qobject) {
- QDeclarativeTypeNameCache::Import &import = cache->m_namedImports[iter.key()];
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- import.moduleApi = ep->moduleApiInstance(moduleApi);
- }
- }
- }
-}
-
-QList<QDeclarativeImports::ScriptReference> QDeclarativeImports::resolvedScripts() const
-{
- QList<QDeclarativeImports::ScriptReference> scripts;
-
- const QDeclarativeImportedNamespace &set = d->unqualifiedset;
-
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
- const QDeclarativeImportedNamespace::Data &data = set.imports.at(ii);
-
- foreach (const QDeclarativeDirParser::Script &script, data.qmlDirScripts) {
- ScriptReference ref;
- ref.nameSpace = script.nameSpace;
- ref.location = QUrl(data.url).resolved(QUrl(script.fileName));
- scripts.append(ref);
- }
- }
-
- for (QHash<QString,QDeclarativeImportedNamespace* >::ConstIterator iter = d->set.constBegin();
- iter != d->set.constEnd();
- ++iter) {
- const QDeclarativeImportedNamespace &set = *iter.value();
-
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
- const QDeclarativeImportedNamespace::Data &data = set.imports.at(ii);
-
- foreach (const QDeclarativeDirParser::Script &script, data.qmlDirScripts) {
- ScriptReference ref;
- ref.nameSpace = script.nameSpace;
- ref.qualifier = iter.key();
- ref.location = QUrl(data.url).resolved(QUrl(script.fileName));
- scripts.append(ref);
- }
- }
- }
-
- return scripts;
-}
-
-/*!
- \internal
-
- The given (namespace qualified) \a type is resolved to either
- \list
- \o a QDeclarativeImportedNamespace stored at \a ns_return,
- \o a QDeclarativeType stored at \a type_return, or
- \o a component located at \a url_return.
- \endlist
-
- If any return pointer is 0, the corresponding search is not done.
-
- \sa addImport()
-*/
-bool QDeclarativeImports::resolveType(const QString& type,
- QDeclarativeType** type_return, QString* url_return, int *vmaj, int *vmin,
- QDeclarativeImportedNamespace** ns_return, QList<QDeclarativeError> *errors) const
-{
- QDeclarativeImportedNamespace* ns = d->findNamespace(type);
- if (ns) {
- if (ns_return)
- *ns_return = ns;
- return true;
- }
- if (type_return || url_return) {
- if (d->find(type,vmaj,vmin,type_return,url_return, errors)) {
- if (qmlImportTrace()) {
- if (type_return && *type_return && url_return && !url_return->isEmpty())
- qDebug().nospace() << "QDeclarativeImports(" << qPrintable(baseUrl().toString()) << ")" << "::resolveType: "
- << type << " => " << (*type_return)->typeName() << " " << *url_return;
- if (type_return && *type_return)
- qDebug().nospace() << "QDeclarativeImports(" << qPrintable(baseUrl().toString()) << ")" << "::resolveType: "
- << type << " => " << (*type_return)->typeName();
- if (url_return && !url_return->isEmpty())
- qDebug().nospace() << "QDeclarativeImports(" << qPrintable(baseUrl().toString()) << ")" << "::resolveType: "
- << type << " => " << *url_return;
- }
- return true;
- }
- }
- return false;
-}
-
-/*!
- \internal
-
- Searching \e only in the namespace \a ns (previously returned in a call to
- resolveType(), \a type is found and returned to either
- a QDeclarativeType stored at \a type_return, or
- a component located at \a url_return.
-
- If either return pointer is 0, the corresponding search is not done.
-*/
-bool QDeclarativeImports::resolveType(QDeclarativeImportedNamespace* ns, const QString& type,
- QDeclarativeType** type_return, QString* url_return,
- int *vmaj, int *vmin) const
-{
- return ns->find(d->typeLoader,type,vmaj,vmin,type_return,url_return);
-}
-
-bool QDeclarativeImportedNamespace::find_helper(QDeclarativeTypeLoader *typeLoader, const Data &data, const QString& type, int *vmajor, int *vminor,
- QDeclarativeType** type_return, QString* url_return,
- QString *base, bool *typeRecursionDetected)
-{
- int vmaj = data.majversion;
- int vmin = data.minversion;
-
- if (vmaj >= 0 && vmin >= 0) {
- QString qt = data.uri + QLatin1Char('/') + type;
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(qt,vmaj,vmin);
- if (t) {
- if (vmajor) *vmajor = vmaj;
- if (vminor) *vminor = vmin;
- if (type_return)
- *type_return = t;
- return true;
- }
- }
-
- const QDeclarativeDirComponents &qmldircomponents = data.qmlDirComponents;
- bool typeWasDeclaredInQmldir = false;
- if (!qmldircomponents.isEmpty()) {
- foreach (const QDeclarativeDirParser::Component &c, qmldircomponents) {
- if (c.typeName == type) {
- typeWasDeclaredInQmldir = true;
- // importing version -1 means import ALL versions
- if ((vmaj == -1) || (c.majorVersion == vmaj && vmin >= c.minorVersion)) {
- QString url(data.url + type + QLatin1String(".qml"));
- QString candidate = resolveLocalUrl(url, c.fileName);
- if (c.internal && base) {
- if (resolveLocalUrl(*base, c.fileName) != candidate)
- continue; // failed attempt to access an internal type
- }
- if (base && *base == candidate) {
- if (typeRecursionDetected)
- *typeRecursionDetected = true;
- continue; // no recursion
- }
- if (url_return)
- *url_return = candidate;
- return true;
- }
- }
- }
- }
-
- if (!typeWasDeclaredInQmldir && !data.isLibrary) {
- // XXX search non-files too! (eg. zip files, see QT-524)
- QString url(data.url + type + QLatin1String(".qml"));
- QString file = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
- if (!typeLoader->absoluteFilePath(file).isEmpty()) {
- if (base && *base == url) { // no recursion
- if (typeRecursionDetected)
- *typeRecursionDetected = true;
- } else {
- if (url_return)
- *url_return = url;
- return true;
- }
- }
- }
- return false;
-}
-
-QDeclarativeImportsPrivate::QDeclarativeImportsPrivate(QDeclarativeTypeLoader *loader)
- : ref(1), typeLoader(loader)
-{
-}
-
-QDeclarativeImportsPrivate::~QDeclarativeImportsPrivate()
-{
- foreach (QDeclarativeImportedNamespace* s, set.values())
- delete s;
-}
-
-bool QDeclarativeImportsPrivate::importExtension(const QString &absoluteFilePath, const QString &uri,
- QDeclarativeImportDatabase *database,
- QDeclarativeDirComponents* components,
- QDeclarativeDirScripts* scripts,
- QList<QDeclarativeError> *errors)
-{
- const QDeclarativeDirParser *qmldirParser = typeLoader->qmlDirParser(absoluteFilePath);
- if (qmldirParser->hasError()) {
- if (errors) {
- const QList<QDeclarativeError> qmldirErrors = qmldirParser->errors(uri);
- for (int i = 0; i < qmldirErrors.size(); ++i)
- errors->prepend(qmldirErrors.at(i));
- }
- return false;
- }
-
- if (qmlImportTrace())
- qDebug().nospace() << "QDeclarativeImports(" << qPrintable(base) << "::importExtension: "
- << "loaded " << absoluteFilePath;
-
- if (! qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(absoluteFilePath)) {
- qmlDirFilesForWhichPluginsHaveBeenLoaded.insert(absoluteFilePath);
-
- QString qmldirPath = absoluteFilePath;
- int slash = absoluteFilePath.lastIndexOf(QLatin1Char('/'));
- if (slash > 0)
- qmldirPath.truncate(slash);
- foreach (const QDeclarativeDirParser::Plugin &plugin, qmldirParser->plugins()) {
-
- QString resolvedFilePath = database->resolvePlugin(typeLoader, qmldirPath, plugin.path, plugin.name);
- if (!resolvedFilePath.isEmpty()) {
- if (!database->importPlugin(resolvedFilePath, uri, errors)) {
- if (errors) {
- // XXX TODO: should we leave the import plugin error alone?
- // Here, we pop it off the top and coalesce it into this error's message.
- // The reason is that the lower level may add url and line/column numbering information.
- QDeclarativeError poppedError = errors->takeFirst();
- QDeclarativeError error;
- error.setDescription(QDeclarativeImportDatabase::tr("plugin cannot be loaded for module \"%1\": %2").arg(uri).arg(poppedError.description()));
- error.setUrl(QUrl::fromLocalFile(absoluteFilePath));
- errors->prepend(error);
- }
- return false;
- }
- } else {
- if (errors) {
- QDeclarativeError error;
- error.setDescription(QDeclarativeImportDatabase::tr("module \"%1\" plugin \"%2\" not found").arg(uri).arg(plugin.name));
- error.setUrl(QUrl::fromLocalFile(absoluteFilePath));
- errors->prepend(error);
- }
- return false;
- }
- }
- }
-
- if (components)
- *components = qmldirParser->components();
- if (scripts)
- *scripts = qmldirParser->scripts();
-
- return true;
-}
-
-QString QDeclarativeImportsPrivate::resolvedUri(const QString &dir_arg, QDeclarativeImportDatabase *database)
-{
- QString dir = dir_arg;
- if (dir.endsWith(QLatin1Char('/')) || dir.endsWith(QLatin1Char('\\')))
- dir.chop(1);
-
- QStringList paths = database->fileImportPath;
- qSort(paths.begin(), paths.end(), greaterThan); // Ensure subdirs preceed their parents.
-
- QString stableRelativePath = dir;
- foreach(const QString &path, paths) {
- if (dir.startsWith(path)) {
- stableRelativePath = dir.mid(path.length()+1);
- break;
- }
- }
-
- stableRelativePath.replace(QLatin1Char('\\'), QLatin1Char('/'));
-
- // remove optional versioning in dot notation from uri
- int lastSlash = stableRelativePath.lastIndexOf(QLatin1Char('/'));
- if (lastSlash >= 0) {
- int versionDot = stableRelativePath.indexOf(QLatin1Char('.'), lastSlash);
- if (versionDot >= 0)
- stableRelativePath = stableRelativePath.left(versionDot);
- }
-
- stableRelativePath.replace(QLatin1Char('/'), QLatin1Char('.'));
- return stableRelativePath;
-}
-
-bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomponentsnetwork,
- const QString& uri_arg, const QString& prefix, int vmaj, int vmin,
- QDeclarativeScript::Import::Type importType,
- QDeclarativeImportDatabase *database, QList<QDeclarativeError> *errors)
-{
- static QLatin1String Slash_qmldir("/qmldir");
- static QLatin1Char Slash('/');
-
- QDeclarativeDirComponents qmldircomponents = qmldircomponentsnetwork;
- QDeclarativeDirScripts qmldirscripts;
- QString uri = uri_arg;
- QDeclarativeImportedNamespace *s;
- if (prefix.isEmpty()) {
- s = &unqualifiedset;
- } else {
- s = set.value(prefix);
- if (!s)
- set.insert(prefix,(s=new QDeclarativeImportedNamespace));
- }
- QString url = uri;
- bool versionFound = false;
- if (importType == QDeclarativeScript::Import::Library) {
-
- Q_ASSERT(vmaj >= 0 && vmin >= 0); // Versions are always specified for libraries
-
- url.replace(QLatin1Char('.'), Slash);
- bool found = false;
- QString dir;
- QString qmldir;
-
- // step 1: search for extension with fully encoded version number
- foreach (const QString &p, database->fileImportPath) {
- dir = p+Slash+url;
-
- QFileInfo fi(dir+QString(QLatin1String(".%1.%2")).arg(vmaj).arg(vmin)+QLatin1String("/qmldir"));
- const QString absoluteFilePath = fi.absoluteFilePath();
-
- if (fi.isFile()) {
- found = true;
-
- const QString absolutePath = fi.absolutePath();
- if (absolutePath.at(0) == QLatin1Char(':'))
- url = QLatin1String("qrc://") + absolutePath.mid(1);
- else
- url = QUrl::fromLocalFile(fi.absolutePath()).toString();
- uri = resolvedUri(dir, database);
- if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, &qmldirscripts, errors))
- return false;
- break;
- }
- }
-
- // TODO: Should this search be omitted if found == true?
-
- // step 2: search for extension with encoded version major
- foreach (const QString &p, database->fileImportPath) {
- dir = p+Slash+url;
-
- QFileInfo fi(dir+QString(QLatin1String(".%1")).arg(vmaj)+QLatin1String("/qmldir"));
- const QString absoluteFilePath = fi.absoluteFilePath();
-
- if (fi.isFile()) {
- found = true;
-
- const QString absolutePath = fi.absolutePath();
- if (absolutePath.at(0) == QLatin1Char(':'))
- url = QLatin1String("qrc://") + absolutePath.mid(1);
- else
- url = QUrl::fromLocalFile(fi.absolutePath()).toString();
- uri = resolvedUri(dir, database);
- if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, &qmldirscripts, errors))
- return false;
- break;
- }
- }
-
- if (!found) {
- // step 3: search for extension without version number
-
- foreach (const QString &p, database->fileImportPath) {
- dir = p+Slash+url;
- qmldir = dir+Slash_qmldir;
-
- QString absoluteFilePath = typeLoader->absoluteFilePath(qmldir);
- if (!absoluteFilePath.isEmpty()) {
- found = true;
- QString absolutePath = absoluteFilePath.left(absoluteFilePath.lastIndexOf(Slash)+1);
- if (absolutePath.at(0) == QLatin1Char(':'))
- url = QLatin1String("qrc://") + absolutePath.mid(1);
- else
- url = QUrl::fromLocalFile(absolutePath).toString();
- uri = resolvedUri(dir, database);
- if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, &qmldirscripts, errors))
- return false;
- break;
- }
- }
- }
-
- if (QDeclarativeMetaType::isModule(uri, vmaj, vmin))
- versionFound = true;
-
- if (!versionFound && qmldircomponents.isEmpty() && qmldirscripts.isEmpty()) {
- if (errors) {
- QDeclarativeError error; // we don't set the url or line or column as these will be set by the loader.
- if (QDeclarativeMetaType::isAnyModule(uri))
- error.setDescription(QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin));
- else
- error.setDescription(QDeclarativeImportDatabase::tr("module \"%1\" is not installed").arg(uri_arg));
- errors->prepend(error);
- }
- return false;
- }
- } else {
- if (importType == QDeclarativeScript::Import::File && qmldircomponents.isEmpty()) {
- QString importUrl = resolveLocalUrl(base, uri + Slash_qmldir);
- QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl);
- if (!localFileOrQrc.isEmpty()) {
- QString dir = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(resolveLocalUrl(base, uri));
- if (!typeLoader->directoryExists(dir)) {
- if (errors) {
- QDeclarativeError error; // we don't set the line or column as these will be set by the loader.
- error.setDescription(QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri_arg));
- error.setUrl(QUrl(importUrl));
- errors->prepend(error);
- }
- return false; // local import dirs must exist
- }
- uri = resolvedUri(dir, database);
- if (uri.endsWith(Slash))
- uri.chop(1);
- if (!typeLoader->absoluteFilePath(localFileOrQrc).isEmpty()) {
- if (!importExtension(localFileOrQrc,uri,database,&qmldircomponents,&qmldirscripts,errors))
- return false;
- }
- } else {
- if (prefix.isEmpty()) {
- // directory must at least exist for valid import
- QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(resolveLocalUrl(base, uri));
- if (!typeLoader->directoryExists(localFileOrQrc)) {
- if (errors) {
- QDeclarativeError error; // we don't set the line or column as these will be set by the loader.
- if (localFileOrQrc.isEmpty())
- error.setDescription(QDeclarativeImportDatabase::tr("import \"%1\" has no qmldir and no namespace").arg(uri));
- else
- error.setDescription(QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri));
- error.setUrl(QUrl(importUrl));
- errors->prepend(error);
- }
- return false;
- }
- }
- }
- }
-
- url = resolveLocalUrl(base, url);
- }
-
- if (!versionFound && (vmaj > -1) && (vmin > -1) && !qmldircomponents.isEmpty()) {
- int lowest_min = INT_MAX;
- int highest_min = INT_MIN;
-
- QList<QDeclarativeDirParser::Component>::const_iterator cend = qmldircomponents.constEnd();
- for (QList<QDeclarativeDirParser::Component>::const_iterator cit = qmldircomponents.constBegin(); cit != cend; ++cit) {
- if (cit->majorVersion == vmaj) {
- lowest_min = qMin(lowest_min, cit->minorVersion);
- highest_min = qMax(highest_min, cit->minorVersion);
- }
- }
-
- if (lowest_min > vmin || highest_min < vmin) {
- if (errors) {
- QDeclarativeError error; // we don't set the url or line or column information, as these will be set by the loader.
- error.setDescription(QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin));
- errors->prepend(error);
- }
- return false;
- }
- }
-
- if (!url.endsWith(Slash))
- url += Slash;
-
- QMap<QString, QDeclarativeDirParser::Script> scripts;
-
- if (!qmldirscripts.isEmpty()) {
- // Verify that we haven't imported these scripts already
- QList<QDeclarativeImportedNamespace::Data>::const_iterator end = s->imports.constEnd();
- for (QList<QDeclarativeImportedNamespace::Data>::const_iterator it = s->imports.constBegin(); it != end; ++it) {
- if (it->uri == uri) {
- QDeclarativeError error;
- error.setDescription(QDeclarativeImportDatabase::tr("\"%1\" is ambiguous. Found in %2 and in %3").arg(uri).arg(url).arg(it->url));
- errors->prepend(error);
- return false;
- }
- }
-
- QList<QDeclarativeDirParser::Script>::const_iterator send = qmldirscripts.constEnd();
- for (QList<QDeclarativeDirParser::Script>::const_iterator sit = qmldirscripts.constBegin(); sit != send; ++sit) {
- // Only include scripts that match our requested version
- if (((vmaj == -1) || (sit->majorVersion == vmaj)) &&
- ((vmin == -1) || (sit->minorVersion <= vmin))) {
-
- // Load the highest version that matches
- QMap<QString, QDeclarativeDirParser::Script>::iterator it = scripts.find(sit->nameSpace);
- if (it == scripts.end() || (it->minorVersion < sit->minorVersion)) {
- scripts.insert(sit->nameSpace, *sit);
- }
- }
- }
- }
-
- QDeclarativeImportedNamespace::Data data;
- data.uri = uri;
- data.url = url;
- data.majversion = vmaj;
- data.minversion = vmin;
- data.isLibrary = importType == QDeclarativeScript::Import::Library;
- data.qmlDirComponents = qmldircomponents;
- data.qmlDirScripts = scripts.values();
-
- s->imports.prepend(data);
-
- return true;
-}
-
-bool QDeclarativeImportsPrivate::find(const QString& type, int *vmajor, int *vminor, QDeclarativeType** type_return,
- QString* url_return, QList<QDeclarativeError> *errors)
-{
- QDeclarativeImportedNamespace *s = 0;
- int slash = type.indexOf(QLatin1Char('/'));
- if (slash >= 0) {
- QString namespaceName = type.left(slash);
- s = set.value(namespaceName);
- if (!s) {
- if (errors) {
- QDeclarativeError error;
- error.setDescription(QDeclarativeImportDatabase::tr("- %1 is not a namespace").arg(namespaceName));
- errors->prepend(error);
- }
- return false;
- }
- int nslash = type.indexOf(QLatin1Char('/'),slash+1);
- if (nslash > 0) {
- if (errors) {
- QDeclarativeError error;
- error.setDescription(QDeclarativeImportDatabase::tr("- nested namespaces not allowed"));
- errors->prepend(error);
- }
- return false;
- }
- } else {
- s = &unqualifiedset;
- }
- QString unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
- if (s) {
- if (s->find(typeLoader,unqualifiedtype,vmajor,vminor,type_return,url_return, &base, errors))
- return true;
- if (s->imports.count() == 1 && !s->imports.at(0).isLibrary && url_return && s != &unqualifiedset) {
- // qualified, and only 1 url
- *url_return = resolveLocalUrl(s->imports.at(0).url, unqualifiedtype + QLatin1String(".qml"));
- return true;
- }
- }
-
- return false;
-}
-
-QDeclarativeImportedNamespace *QDeclarativeImportsPrivate::findNamespace(const QString& type)
-{
- return set.value(type);
-}
-
-bool QDeclarativeImportedNamespace::find(QDeclarativeTypeLoader *typeLoader, const QString& type, int *vmajor, int *vminor, QDeclarativeType** type_return,
- QString* url_return, QString *base, QList<QDeclarativeError> *errors)
-{
- bool typeRecursionDetected = false;
- for (int i=0; i<imports.count(); ++i) {
- if (find_helper(typeLoader, imports.at(i), type, vmajor, vminor, type_return, url_return, base, &typeRecursionDetected)) {
- if (qmlCheckTypes()) {
- // check for type clashes
- for (int j = i+1; j<imports.count(); ++j) {
- if (find_helper(typeLoader, imports.at(j), type, vmajor, vminor, 0, 0, base)) {
- if (errors) {
- QString u1 = imports.at(i).url;
- QString u2 = imports.at(j).url;
- if (base) {
- QString b = *base;
- int slash = b.lastIndexOf(QLatin1Char('/'));
- if (slash >= 0) {
- b = b.left(slash+1);
- QString l = b.left(slash);
- if (u1.startsWith(b))
- u1 = u1.mid(b.count());
- else if (u1 == l)
- u1 = QDeclarativeImportDatabase::tr("local directory");
- if (u2.startsWith(b))
- u2 = u2.mid(b.count());
- else if (u2 == l)
- u2 = QDeclarativeImportDatabase::tr("local directory");
- }
- }
-
- QDeclarativeError error;
- if (u1 != u2) {
- error.setDescription(QDeclarativeImportDatabase::tr("is ambiguous. Found in %1 and in %2").arg(u1).arg(u2));
- } else {
- error.setDescription(QDeclarativeImportDatabase::tr("is ambiguous. Found in %1 in version %2.%3 and %4.%5")
- .arg(u1)
- .arg(imports.at(i).majversion).arg(imports.at(i).minversion)
- .arg(imports.at(j).majversion).arg(imports.at(j).minversion));
- }
- errors->prepend(error);
- }
- return false;
- }
- }
- }
- return true;
- }
- }
- if (errors) {
- QDeclarativeError error;
- if (typeRecursionDetected)
- error.setDescription(QDeclarativeImportDatabase::tr("is instantiated recursively"));
- else
- error.setDescription(QDeclarativeImportDatabase::tr("is not a type"));
- errors->prepend(error);
- }
- return false;
-}
-
-/*!
-\class QDeclarativeImportDatabase
-\brief The QDeclarativeImportDatabase class manages the QML imports for a QDeclarativeEngine.
-\internal
-*/
-QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e)
-: engine(e)
-{
- filePluginPath << QLatin1String(".");
-
- // Search order is applicationDirPath(), $QML_IMPORT_PATH, QLibraryInfo::ImportsPath
-
-#ifndef QT_NO_SETTINGS
- QString installImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
- addImportPath(installImportsPath);
-#endif // QT_NO_SETTINGS
-
- // env import paths
- QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
- if (!envImportPath.isEmpty()) {
-#if defined(Q_OS_WIN)
- QLatin1Char pathSep(';');
-#else
- QLatin1Char pathSep(':');
-#endif
- QStringList paths = QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts);
- for (int ii = paths.count() - 1; ii >= 0; --ii)
- addImportPath(paths.at(ii));
- }
-
- addImportPath(QCoreApplication::applicationDirPath());
-}
-
-QDeclarativeImportDatabase::~QDeclarativeImportDatabase()
-{
-}
-
-/*!
- \internal
-
- Adds information to \a imports such that subsequent calls to resolveType()
- will resolve types qualified by \a prefix by considering types found at the given \a uri.
-
- The uri is either a directory (if importType is FileImport), or a URI resolved using paths
- added via addImportPath() (if importType is LibraryImport).
-
- The \a prefix may be empty, in which case the import location is considered for
- unqualified types.
-
- The base URL must already have been set with Import::setBaseUrl().
-*/
-bool QDeclarativeImports::addImport(QDeclarativeImportDatabase *importDb,
- const QString& uri, const QString& prefix, int vmaj, int vmin,
- QDeclarativeScript::Import::Type importType,
- const QDeclarativeDirComponents &qmldircomponentsnetwork,
- QList<QDeclarativeError> *errors)
-{
- if (qmlImportTrace())
- qDebug().nospace() << "QDeclarativeImports(" << qPrintable(baseUrl().toString()) << ")" << "::addImport: "
- << uri << " " << vmaj << '.' << vmin << " "
- << (importType==QDeclarativeScript::Import::Library? "Library" : "File")
- << " as " << prefix;
-
- return d->add(qmldircomponentsnetwork, uri, prefix, vmaj, vmin, importType, importDb, errors);
-}
-
-/*!
- \internal
-
- Returns the result of the merge of \a baseName with \a path, \a suffixes, and \a prefix.
- The \a prefix must contain the dot.
-
- \a qmldirPath is the location of the qmldir file.
- */
-QString QDeclarativeImportDatabase::resolvePlugin(QDeclarativeTypeLoader *typeLoader,
- const QString &qmldirPath, const QString &qmldirPluginPath,
- const QString &baseName, const QStringList &suffixes,
- const QString &prefix)
-{
- QStringList searchPaths = filePluginPath;
- bool qmldirPluginPathIsRelative = QDir::isRelativePath(qmldirPluginPath);
- if (!qmldirPluginPathIsRelative)
- searchPaths.prepend(qmldirPluginPath);
-
- foreach (const QString &pluginPath, searchPaths) {
-
- QString resolvedPath;
- if (pluginPath == QLatin1String(".")) {
- if (qmldirPluginPathIsRelative && !qmldirPluginPath.isEmpty() && qmldirPluginPath != QLatin1String("."))
- resolvedPath = QDir::cleanPath(qmldirPath + QLatin1Char('/') + qmldirPluginPath);
- else
- resolvedPath = qmldirPath;
- } else {
- if (QDir::isRelativePath(pluginPath))
- resolvedPath = QDir::cleanPath(qmldirPath + QLatin1Char('/') + pluginPath);
- else
- resolvedPath = pluginPath;
- }
-
- // hack for resources, should probably go away
- if (resolvedPath.startsWith(QLatin1Char(':')))
- resolvedPath = QCoreApplication::applicationDirPath();
-
- if (!resolvedPath.endsWith(QLatin1Char('/')))
- resolvedPath += QLatin1Char('/');
-
- foreach (const QString &suffix, suffixes) {
- QString pluginFileName = prefix;
-
- pluginFileName += baseName;
- pluginFileName += suffix;
-
- QString absolutePath = typeLoader->absoluteFilePath(resolvedPath + pluginFileName);
- if (!absolutePath.isEmpty())
- return absolutePath;
- }
- }
-
- if (qmlImportTrace())
- qDebug() << "QDeclarativeImportDatabase::resolvePlugin: Could not resolve plugin" << baseName
- << "in" << qmldirPath;
-
- return QString();
-}
-
-/*!
- \internal
-
- Returns the result of the merge of \a baseName with \a dir and the platform suffix.
-
- \table
- \header \i Platform \i Valid suffixes
- \row \i Windows \i \c .dll
- \row \i Unix/Linux \i \c .so
- \row \i AIX \i \c .a
- \row \i HP-UX \i \c .sl, \c .so (HP-UXi)
- \row \i Mac OS X \i \c .dylib, \c .bundle, \c .so
- \endtable
-
- Version number on unix are ignored.
-*/
-QString QDeclarativeImportDatabase::resolvePlugin(QDeclarativeTypeLoader *typeLoader,
- const QString &qmldirPath, const QString &qmldirPluginPath,
- const QString &baseName)
-{
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- return resolvePlugin(typeLoader, qmldirPath, qmldirPluginPath, baseName,
- QStringList()
-# ifdef QT_DEBUG
- << QLatin1String("d.dll") // try a qmake-style debug build first
-# endif
- << QLatin1String(".dll"));
-#else
-
-# if defined(Q_OS_DARWIN)
-
- return resolvePlugin(typeLoader, qmldirPath, qmldirPluginPath, baseName,
- QStringList()
-# ifdef QT_DEBUG
- << QLatin1String("_debug.dylib") // try a qmake-style debug build first
- << QLatin1String(".dylib")
-# else
- << QLatin1String(".dylib")
- << QLatin1String("_debug.dylib") // try a qmake-style debug build after
-# endif
- << QLatin1String(".so")
- << QLatin1String(".bundle"),
- QLatin1String("lib"));
-# else // Generic Unix
- QStringList validSuffixList;
-
-# if defined(Q_OS_HPUX)
-/*
- See "HP-UX Linker and Libraries User's Guide", section "Link-time Differences between PA-RISC and IPF":
- "In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit),
- the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix."
- */
- validSuffixList << QLatin1String(".sl");
-# if defined __ia64
- validSuffixList << QLatin1String(".so");
-# endif
-# elif defined(Q_OS_AIX)
- validSuffixList << QLatin1String(".a") << QLatin1String(".so");
-# elif defined(Q_OS_UNIX)
- validSuffixList << QLatin1String(".so");
-# endif
-
- // Examples of valid library names:
- // libfoo.so
-
- return resolvePlugin(typeLoader, qmldirPath, qmldirPluginPath, baseName, validSuffixList, QLatin1String("lib"));
-# endif
-
-#endif
-}
-
-/*!
- \internal
-*/
-QStringList QDeclarativeImportDatabase::pluginPathList() const
-{
- return filePluginPath;
-}
-
-/*!
- \internal
-*/
-void QDeclarativeImportDatabase::setPluginPathList(const QStringList &paths)
-{
- filePluginPath = paths;
-}
-
-/*!
- \internal
-*/
-void QDeclarativeImportDatabase::addPluginPath(const QString& path)
-{
- if (qmlImportTrace())
- qDebug().nospace() << "QDeclarativeImportDatabase::addPluginPath: " << path;
-
- QUrl url = QUrl(path);
- if (url.isRelative() || url.scheme() == QLatin1String("file")
- || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
- QDir dir = QDir(path);
- filePluginPath.prepend(dir.canonicalPath());
- } else {
- filePluginPath.prepend(path);
- }
-}
-
-/*!
- \internal
-*/
-void QDeclarativeImportDatabase::addImportPath(const QString& path)
-{
- if (qmlImportTrace())
- qDebug().nospace() << "QDeclarativeImportDatabase::addImportPath: " << path;
-
- if (path.isEmpty())
- return;
-
- QUrl url = QUrl(path);
- QString cPath;
-
- if (url.isRelative() || url.scheme() == QLatin1String("file")
- || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
- QDir dir = QDir(path);
- cPath = dir.canonicalPath();
- } else {
- cPath = path;
- cPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
- }
-
- if (!cPath.isEmpty()
- && !fileImportPath.contains(cPath))
- fileImportPath.prepend(cPath);
-}
-
-/*!
- \internal
-*/
-QStringList QDeclarativeImportDatabase::importPathList() const
-{
- return fileImportPath;
-}
-
-/*!
- \internal
-*/
-void QDeclarativeImportDatabase::setImportPathList(const QStringList &paths)
-{
- fileImportPath = paths;
-}
-
-/*!
- \internal
-*/
-bool QDeclarativeImportDatabase::importPlugin(const QString &filePath, const QString &uri, QList<QDeclarativeError> *errors)
-{
- if (qmlImportTrace())
- qDebug().nospace() << "QDeclarativeImportDatabase::importPlugin: " << uri << " from " << filePath;
-
-#ifndef QT_NO_LIBRARY
- QFileInfo fileInfo(filePath);
- const QString absoluteFilePath = fileInfo.absoluteFilePath();
-
- bool engineInitialized = initializedPlugins.contains(absoluteFilePath);
- bool typesRegistered = qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath);
-
- if (typesRegistered) {
- Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath) == uri,
- "QDeclarativeImportDatabase::importExtension",
- "Internal error: Plugin imported previously with different uri");
- }
-
- if (!engineInitialized || !typesRegistered) {
- if (!QDeclarative_isFileCaseCorrect(absoluteFilePath)) {
- if (errors) {
- QDeclarativeError error;
- error.setDescription(tr("File name case mismatch for \"%1\"").arg(absoluteFilePath));
- errors->prepend(error);
- }
- return false;
- }
- QPluginLoader loader(absoluteFilePath);
-
- if (!loader.load()) {
- if (errors) {
- QDeclarativeError error;
- error.setDescription(loader.errorString());
- errors->prepend(error);
- }
- return false;
- }
-
- QObject *instance = loader.instance();
- if (QDeclarativeTypesExtensionInterface *iface = qobject_cast<QDeclarativeExtensionInterface *>(instance)) {
-
- const QByteArray bytes = uri.toUtf8();
- const char *moduleId = bytes.constData();
- if (!typesRegistered) {
-
- // XXX thread this code should probably be protected with a mutex.
- qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, uri);
- iface->registerTypes(moduleId);
- }
- if (!engineInitialized) {
- // things on the engine (eg. adding new global objects) have to be done for every
- // engine.
- // XXX protect against double initialization
- initializedPlugins.insert(absoluteFilePath);
-
- QDeclarativeExtensionInterface *eiface =
- qobject_cast<QDeclarativeExtensionInterface *>(instance);
- if (eiface) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- ep->typeLoader.initializeEngine(eiface, moduleId);
- }
- }
- } else {
- if (errors) {
- QDeclarativeError error;
- error.setDescription(loader.errorString());
- errors->prepend(error);
- }
- return false;
- }
- }
-
- return true;
-#else
- return false;
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeimport_p.h b/src/declarative/qml/qdeclarativeimport_p.h
deleted file mode 100644
index 6dae0f38b9..0000000000
--- a/src/declarative/qml/qdeclarativeimport_p.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEIMPORT_P_H
-#define QDECLARATIVEIMPORT_P_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qset.h>
-#include <QtCore/qstringlist.h>
-#include <private/qdeclarativedirparser_p.h>
-#include <private/qdeclarativescript_p.h>
-#include <private/qdeclarativemetatype_p.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.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeTypeNameCache;
-class QDeclarativeEngine;
-class QDir;
-class QDeclarativeImportedNamespace;
-class QDeclarativeImportsPrivate;
-class QDeclarativeImportDatabase;
-class QDeclarativeTypeLoader;
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_EXPORT QDeclarativeImports
-{
-public:
- QDeclarativeImports(QDeclarativeTypeLoader *);
- QDeclarativeImports(const QDeclarativeImports &);
- ~QDeclarativeImports();
- QDeclarativeImports &operator=(const QDeclarativeImports &);
-
- void setBaseUrl(const QUrl &url, const QString &urlString = QString());
- QUrl baseUrl() const;
-
- bool resolveType(const QString& type,
- QDeclarativeType** type_return, QString* url_return,
- int *version_major, int *version_minor,
- QDeclarativeImportedNamespace** ns_return,
- QList<QDeclarativeError> *errors = 0) const;
- bool resolveType(QDeclarativeImportedNamespace*,
- const QString& type,
- QDeclarativeType** type_return, QString* url_return,
- int *version_major, int *version_minor) const;
-
- bool addImport(QDeclarativeImportDatabase *,
- const QString& uri, const QString& prefix, int vmaj, int vmin,
- QDeclarativeScript::Import::Type importType,
- const QDeclarativeDirComponents &qmldircomponentsnetwork,
- QList<QDeclarativeError> *errors);
-
- void populateCache(QDeclarativeTypeNameCache *cache, QDeclarativeEngine *) const;
-
- struct ScriptReference
- {
- QString nameSpace;
- QString qualifier;
- QUrl location;
- };
-
- QList<ScriptReference> resolvedScripts() const;
-
-private:
- friend class QDeclarativeImportDatabase;
- QDeclarativeImportsPrivate *d;
-};
-
-class QDeclarativeImportDatabase
-{
- Q_DECLARE_TR_FUNCTIONS(QDeclarativeImportDatabase)
-public:
- QDeclarativeImportDatabase(QDeclarativeEngine *);
- ~QDeclarativeImportDatabase();
-
- bool importPlugin(const QString &filePath, const QString &uri, QList<QDeclarativeError> *errors);
-
- QStringList importPathList() const;
- void setImportPathList(const QStringList &paths);
- void addImportPath(const QString& dir);
-
- QStringList pluginPathList() const;
- void setPluginPathList(const QStringList &paths);
- void addPluginPath(const QString& path);
-
-private:
- friend class QDeclarativeImportsPrivate;
- QString resolvePlugin(QDeclarativeTypeLoader *typeLoader,
- const QString &qmldirPath, const QString &qmldirPluginPath,
- const QString &baseName, const QStringList &suffixes,
- const QString &prefix = QString());
- QString resolvePlugin(QDeclarativeTypeLoader *typeLoader,
- const QString &qmldirPath, const QString &qmldirPluginPath,
- const QString &baseName);
-
-
- // XXX thread
- QStringList filePluginPath;
- QStringList fileImportPath;
-
- QSet<QString> initializedPlugins;
- QDeclarativeEngine *engine;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEIMPORT_P_H
-
diff --git a/src/declarative/qml/qdeclarativeincubator.cpp b/src/declarative/qml/qdeclarativeincubator.cpp
deleted file mode 100644
index 6d39fc763a..0000000000
--- a/src/declarative/qml/qdeclarativeincubator.cpp
+++ /dev/null
@@ -1,697 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeincubator.h"
-#include "qdeclarativecomponent.h"
-#include "qdeclarativeincubator_p.h"
-
-#include "qdeclarativecompiler_p.h"
-#include "qdeclarativeexpression_p.h"
-
-// XXX TODO
-// - check that the Component.onCompleted behavior is the same as 4.8 in the synchronous and
-// async if nested cases
-void QDeclarativeEnginePrivate::incubate(QDeclarativeIncubator &i, QDeclarativeContextData *forContext)
-{
- QDeclarativeIncubatorPrivate *p = i.d;
-
- QDeclarativeIncubator::IncubationMode mode = i.incubationMode();
-
- if (!incubationController)
- mode = QDeclarativeIncubator::Synchronous;
-
- if (mode == QDeclarativeIncubator::AsynchronousIfNested) {
- mode = QDeclarativeIncubator::Synchronous;
-
- // Need to find the first constructing context and see if it is asynchronous
- QDeclarativeIncubatorPrivate *parentIncubator = 0;
- QDeclarativeContextData *cctxt = forContext;
- while (cctxt) {
- if (cctxt->activeVMEData) {
- parentIncubator = (QDeclarativeIncubatorPrivate *)cctxt->activeVMEData;
- break;
- }
- cctxt = cctxt->parent;
- }
-
- if (parentIncubator && parentIncubator->isAsynchronous) {
- mode = QDeclarativeIncubator::Asynchronous;
- p->waitingOnMe = parentIncubator;
- parentIncubator->waitingFor.insert(p);
- }
- }
-
- p->isAsynchronous = (mode != QDeclarativeIncubator::Synchronous);
-
- inProgressCreations++;
-
- if (mode == QDeclarativeIncubator::Synchronous) {
- typedef QDeclarativeIncubatorPrivate IP;
- QRecursionWatcher<IP, &IP::recursion> watcher(p);
-
- p->changeStatus(QDeclarativeIncubator::Loading);
-
- if (!watcher.hasRecursed()) {
- QDeclarativeVME::Interrupt i;
- p->incubate(i);
- }
- } else {
- incubatorList.insert(p);
- incubatorCount++;
-
- p->vmeGuard.guard(&p->vme);
- p->changeStatus(QDeclarativeIncubator::Loading);
-
- if (incubationController)
- incubationController->incubatingObjectCountChanged(incubatorCount);
- }
-}
-
-/*!
-Sets the engine's incubation \a controller. The engine can only have one active controller
-and it does not take ownership of it.
-
-\sa incubationController()
-*/
-void QDeclarativeEngine::setIncubationController(QDeclarativeIncubationController *controller)
-{
- Q_D(QDeclarativeEngine);
- if (d->incubationController)
- d->incubationController->d = 0;
- d->incubationController = controller;
- if (controller) controller->d = d;
-}
-
-/*!
-Returns the currently set incubation controller, or 0 if no controller has been set.
-
-\sa setIncubationController()
-*/
-QDeclarativeIncubationController *QDeclarativeEngine::incubationController() const
-{
- Q_D(const QDeclarativeEngine);
- return d->incubationController;
-}
-
-QDeclarativeIncubatorPrivate::QDeclarativeIncubatorPrivate(QDeclarativeIncubator *q,
- QDeclarativeIncubator::IncubationMode m)
-: q(q), status(QDeclarativeIncubator::Null), mode(m), isAsynchronous(false), progress(Execute),
- result(0), component(0), vme(this), waitingOnMe(0)
-{
-}
-
-QDeclarativeIncubatorPrivate::~QDeclarativeIncubatorPrivate()
-{
-}
-
-void QDeclarativeIncubatorPrivate::clear()
-{
- if (next.isInList()) {
- next.remove();
- Q_ASSERT(component);
- QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(component->engine);
- component->release();
- component = 0;
- enginePriv->incubatorCount--;
- QDeclarativeIncubationController *controller = enginePriv->incubationController;
- if (controller)
- controller->incubatingObjectCountChanged(enginePriv->incubatorCount);
- } else if (component) {
- component->release();
- component = 0;
- }
- if (!rootContext.isNull()) {
- rootContext->activeVMEData = 0;
- rootContext = 0;
- }
-
- if (nextWaitingFor.isInList()) {
- Q_ASSERT(waitingOnMe);
- nextWaitingFor.remove();
- waitingOnMe = 0;
- }
-}
-
-/*!
-\class QDeclarativeIncubationController
-\brief QDeclarativeIncubationController instances drive the progress of QDeclarativeIncubators
-
-In order to behave asynchronously and not introduce stutters or freezes in an application,
-the process of creating objects a QDeclarativeIncubators must be driven only during the
-application's idle time. QDeclarativeIncubationController allows the application to control
-exactly when, how often and for how long this processing occurs.
-
-A QDeclarativeIncubationController derived instance should be created and set on a
-QDeclarativeEngine by calling the QDeclarativeEngine::setIncubationController() method.
-Processing is then controlled by calling the QDeclarativeIncubationController::incubateFor()
-or QDeclarativeIncubationController::incubateWhile() methods as dictated by the application's
-requirements.
-
-For example, this is an example of a incubation controller that will incubate for a maximum
-of 5 milliseconds out of every 16 milliseconds.
-
-\code
-class PeriodicIncubationController : public QObject,
- public QDeclarativeIncubationController
-{
-public:
- PeriodicIncubationController() {
- startTimer(16);
- }
-
-protected:
- virtual void timerEvent(QTimerEvent *) {
- incubateFor(5);
- }
-};
-\endcode
-
-Although the previous example would work, it is not optimal. Real world incubation
-controllers should try and maximize the amount of idle time they consume - rather
-than a static amount like 5 milliseconds - while not disturbing the application.
-*/
-
-/*!
-Create a new incubation controller.
-*/
-QDeclarativeIncubationController::QDeclarativeIncubationController()
-: d(0)
-{
-}
-
-/*! \internal */
-QDeclarativeIncubationController::~QDeclarativeIncubationController()
-{
- if (d) QDeclarativeEnginePrivate::get(d)->setIncubationController(0);
- d = 0;
-}
-
-/*!
-Return the QDeclarativeEngine this incubation controller is set on, or 0 if it
-has not been set on any engine.
-*/
-QDeclarativeEngine *QDeclarativeIncubationController::engine() const
-{
- return QDeclarativeEnginePrivate::get(d);
-}
-
-/*!
-Return the number of objects currently incubating.
-*/
-int QDeclarativeIncubationController::incubatingObjectCount() const
-{
- if (d)
- return d->incubatorCount;
- else
- return 0;
-}
-
-/*!
-Called when the number of incubating objects changes. \a incubatingObjectCount is the
-new number of incubating objects.
-
-The default implementation does nothing.
-*/
-void QDeclarativeIncubationController::incubatingObjectCountChanged(int incubatingObjectCount)
-{
- Q_UNUSED(incubatingObjectCount);
-}
-
-void QDeclarativeIncubatorPrivate::incubate(QDeclarativeVME::Interrupt &i)
-{
- if (!component)
- return;
- typedef QDeclarativeIncubatorPrivate IP;
- QRecursionWatcher<IP, &IP::recursion> watcher(this);
-
- QDeclarativeEngine *engine = component->engine;
- QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
-
- bool guardOk = vmeGuard.isOK();
- vmeGuard.clear();
-
- if (!guardOk) {
- QDeclarativeError error;
- error.setUrl(component->url);
- error.setDescription(QDeclarativeComponent::tr("Object destroyed during incubation"));
- errors << error;
- progress = QDeclarativeIncubatorPrivate::Completed;
-
- goto finishIncubate;
- }
-
- if (progress == QDeclarativeIncubatorPrivate::Execute) {
- enginePriv->referenceScarceResources();
- QObject *tresult = vme.execute(&errors, i);
- enginePriv->dereferenceScarceResources();
-
- if (watcher.hasRecursed())
- return;
-
- result = tresult;
- if (errors.isEmpty() && result == 0)
- goto finishIncubate;
-
- if (result) {
- QDeclarativeData *ddata = QDeclarativeData::get(result);
- Q_ASSERT(ddata);
- ddata->indestructible = true;
-
- q->setInitialState(result);
- }
-
- if (watcher.hasRecursed())
- return;
-
- if (errors.isEmpty())
- progress = QDeclarativeIncubatorPrivate::Completing;
- else
- progress = QDeclarativeIncubatorPrivate::Completed;
-
- changeStatus(calculateStatus());
-
- if (watcher.hasRecursed())
- return;
-
- if (i.shouldInterrupt())
- goto finishIncubate;
- }
-
- if (progress == QDeclarativeIncubatorPrivate::Completing) {
- do {
- if (watcher.hasRecursed())
- return;
-
- QDeclarativeContextData *ctxt = vme.complete(i);
- if (ctxt) {
- rootContext = ctxt;
- progress = QDeclarativeIncubatorPrivate::Completed;
- goto finishIncubate;
- }
- } while (!i.shouldInterrupt());
- }
-
-finishIncubate:
- if (progress == QDeclarativeIncubatorPrivate::Completed && waitingFor.isEmpty()) {
- typedef QDeclarativeIncubatorPrivate IP;
-
- QDeclarativeIncubatorPrivate *isWaiting = waitingOnMe;
- clear();
-
- if (isWaiting) {
- QRecursionWatcher<IP, &IP::recursion> watcher(isWaiting);
- changeStatus(calculateStatus());
- if (!watcher.hasRecursed())
- isWaiting->incubate(i);
- } else {
- changeStatus(calculateStatus());
- }
-
- enginePriv->inProgressCreations--;
-
- if (0 == enginePriv->inProgressCreations) {
- while (enginePriv->erroredBindings) {
- enginePriv->warning(enginePriv->erroredBindings->error);
- enginePriv->erroredBindings->removeError();
- }
- }
- } else {
- vmeGuard.guard(&vme);
- }
-}
-
-/*!
-Incubate objects for \a msecs, or until there are no more objects to incubate.
-*/
-void QDeclarativeIncubationController::incubateFor(int msecs)
-{
- if (!d || d->incubatorCount == 0)
- return;
-
- QDeclarativeVME::Interrupt i(msecs * 1000000);
- i.reset();
- do {
- QDeclarativeIncubatorPrivate *p = (QDeclarativeIncubatorPrivate*)d->incubatorList.first();
- p->incubate(i);
- } while (d && d->incubatorCount != 0 && !i.shouldInterrupt());
-}
-
-/*!
-Incubate objects while the bool pointed to by \a flag is true, or until there are no
-more objects to incubate, or up to msecs if msecs is not zero.
-
-Generally this method is used in conjunction with a thread or a UNIX signal that sets
-the bool pointed to by \a flag to false when it wants incubation to be interrupted.
-*/
-void QDeclarativeIncubationController::incubateWhile(volatile bool *flag, int msecs)
-{
- if (!d || d->incubatorCount == 0)
- return;
-
- QDeclarativeVME::Interrupt i(flag, msecs * 1000000);
- i.reset();
- do {
- QDeclarativeIncubatorPrivate *p = (QDeclarativeIncubatorPrivate*)d->incubatorList.first();
- p->incubate(i);
- } while (d && d->incubatorCount != 0 && !i.shouldInterrupt());
-}
-
-/*!
-\class QDeclarativeIncubator
-\brief The QDeclarativeIncubator class allows QML objects to be created asynchronously.
-
-Creating QML objects - like delegates in a view, or a new page in an application - can take
-a noticable amount of time, especially on resource constrained mobile devices. When an
-application uses QDeclarativeComponent::create() directly, the QML object instance is created
-synchronously which, depending on the complexity of the object, can cause noticable pauses or
-stutters in the application.
-
-The use of QDeclarativeIncubator gives more control over the creation of a QML object,
-including allowing it to be created asynchronously using application idle time. The following
-example shows a simple use of QDeclarativeIncubator.
-
-\code
-QDeclarativeIncubator incubator;
-component->create(incubator);
-
-while (incubator.isReady()) {
- QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
-}
-
-QObject *object = incubator.object();
-\endcode
-
-Asynchronous incubators are controlled by a QDeclarativeIncubationController that is
-set on the QDeclarativeEngine, which lets the engine know when the application is idle and
-incubating objects should be processed. If an incubation controller is not set on the
-QDeclarativeEngine, QDeclarativeIncubator creates objects synchronously regardless of the
-specified IncubationMode.
-
-QDeclarativeIncubator supports three incubation modes:
-\list
-\i Synchronous The creation occurs synchronously. That is, once the
-QDeclarativeComponent::create() call returns, the incubator will already be in either the
-Error or Ready state. A synchronous incubator has no real advantage compared to using
-the synchronous creation methods on QDeclarativeComponent directly, but it may simplify an
-application's implementation to use the same API for both synchronous and asynchronous
-creations.
-
-\i Asynchronous (default) The creation occurs asynchronously, assuming a
-QDeclarativeIncubatorController is set on the QDeclarativeEngine.
-
-The incubator will remain in the Loading state until either the creation is complete or an error
-occurs. The statusChanged() callback can be used to be notified of status changes.
-
-Applications should use the Asynchronous incubation mode to create objects that are not needed
-immediately. For example, the ListView element uses Asynchronous incubation to create objects
-that are slightly off screen while the list is being scrolled. If, during asynchronous creation,
-the object is needed immediately the QDeclarativeIncubator::forceCompletion() method can be called
-to complete the creation process synchronously.
-
-\i AsynchronousIfNested The creation will occur asynchronously if part of a nested asynchronous
-creation, or synchronously if not.
-
-In most scenarios where a QML element or component wants the appearance of a synchronous
-instantiation, it should use this mode.
-
-This mode is best explained with an example. When the ListView element is first created, it needs
-to populate itself with an initial set of delegates to show. If the ListView was 400 pixels high,
-and each delegate was 100 pixels high, it would need to create four initial delegate instances. If
-the ListView used the Asynchronous incubation mode, the ListView would always be created empty and
-then, sometime later, the four initial elements would appear.
-
-Conversely, if the ListView was to use the Synchronous incubation mode it would behave correctly
-but it may introduce stutters into the application. As QML would have to stop and instantiate the
-ListView's delegates synchronously, if the ListView was part of a QML component that was being
-instantiated asynchronously this would undo much of the benefit of asynchronous instantiation.
-
-The AsynchronousIfNested mode reconciles this problem. By using AsynchronousIfNested, the ListView
-delegates are instantiated asynchronously if the ListView itself is already part of an asynchronous
-instantiation, and synchronously otherwise. In the case of a nested asynchronous instantiation, the
-outer asynchronous instantiation will not complete until after all the nested instantiations have also
-completed. This ensures that by the time the outer asynchronous instantitation completes, inner
-elements like ListView have already completed loading their initial delegates.
-
-It is almost always incorrect to use the Synchronous incubation mode - elements or components that
-want the appearance of synchronous instantiation, but without the downsides of introducing freezes
-or stutters into the application, should use the AsynchronousIfNested incubation mode.
-\endlist
-*/
-
-/*!
-Create a new incubator with the specified \a mode
-*/
-QDeclarativeIncubator::QDeclarativeIncubator(IncubationMode mode)
-: d(new QDeclarativeIncubatorPrivate(this, mode))
-{
-}
-
-/*! \internal */
-QDeclarativeIncubator::~QDeclarativeIncubator()
-{
- clear();
-
- delete d; d = 0;
-}
-
-/*!
-\enum QDeclarativeIncubator::IncubationMode
-
-Specifies the mode the incubator operates in. Regardless of the incubation mode, a
-QDeclarativeIncubator will behave synchronously if the QDeclarativeEngine does not have
-a QDeclarativeIncubationController set.
-
-\value Asynchronous The object will be created asynchronously.
-\value AsynchronousIfNested If the object is being created in a context that is already part
-of an asynchronous creation, this incubator will join that existing incubation and execute
-asynchronously. The existing incubation will not become Ready until both it and this
-incubation have completed. Otherwise, the incubation will execute synchronously.
-\value Synchronous The object will be created synchronously.
-*/
-
-/*!
-\enum QDeclarativeIncubator::Status
-
-Specifies the status of the QDeclarativeIncubator.
-
-\value Null Incubation is not in progress. Call QDeclarativeComponent::create() to begin incubating.
-\value Ready The object is fully created and can be accessed by calling object().
-\value Loading The object is in the process of being created.
-\value Error An error occurred. The errors can be access by calling errors().
-*/
-
-/*!
-Clears the incubator. Any in-progress incubation is aborted. If the incubator is in the
-Ready state, the created object is \b not deleted.
-*/
-void QDeclarativeIncubator::clear()
-{
- typedef QDeclarativeIncubatorPrivate IP;
- QRecursionWatcher<IP, &IP::recursion> watcher(d);
-
- Status s = status();
-
- if (s == Null)
- return;
-
- QDeclarativeEnginePrivate *enginePriv = 0;
- if (s == Loading) {
- Q_ASSERT(d->component);
- enginePriv = QDeclarativeEnginePrivate::get(d->component->engine);
- if (d->result) d->result->deleteLater();
- d->result = 0;
- }
-
- d->clear();
-
- d->vme.reset();
- d->vmeGuard.clear();
-
- Q_ASSERT(d->component == 0);
- Q_ASSERT(d->waitingOnMe == 0);
- Q_ASSERT(d->waitingFor.isEmpty());
- Q_ASSERT(!d->nextWaitingFor.isInList());
-
- d->errors.clear();
- d->progress = QDeclarativeIncubatorPrivate::Execute;
- d->result = 0;
-
- if (s == Loading) {
- Q_ASSERT(enginePriv);
-
- enginePriv->inProgressCreations--;
- if (0 == enginePriv->inProgressCreations) {
- while (enginePriv->erroredBindings) {
- enginePriv->warning(enginePriv->erroredBindings->error);
- enginePriv->erroredBindings->removeError();
- }
- }
- }
-
- d->changeStatus(Null);
-}
-
-/*!
-Force any in-progress incubation to finish synchronously. Once this call
-returns, the incubator will not be in the Loading state.
-*/
-void QDeclarativeIncubator::forceCompletion()
-{
- QDeclarativeVME::Interrupt i;
- while (Loading == status()) {
- while (Loading == status() && !d->waitingFor.isEmpty())
- static_cast<QDeclarativeIncubatorPrivate *>(d->waitingFor.first())->incubate(i);
- if (Loading == status())
- d->incubate(i);
- }
-}
-
-/*!
-Returns true if the incubator's status() is Null.
-*/
-bool QDeclarativeIncubator::isNull() const
-{
- return status() == Null;
-}
-
-/*!
-Returns true if the incubator's status() is Ready.
-*/
-bool QDeclarativeIncubator::isReady() const
-{
- return status() == Ready;
-}
-
-/*!
-Returns true if the incubator's status() is Error.
-*/
-bool QDeclarativeIncubator::isError() const
-{
- return status() == Error;
-}
-
-/*!
-Returns true if the incubator's status() is Loading.
-*/
-bool QDeclarativeIncubator::isLoading() const
-{
- return status() == Loading;
-}
-
-/*!
-Return the list of errors encountered while incubating the object.
-*/
-QList<QDeclarativeError> QDeclarativeIncubator::errors() const
-{
- return d->errors;
-}
-
-/*!
-Return the incubation mode passed to the QDeclarativeIncubator constructor.
-*/
-QDeclarativeIncubator::IncubationMode QDeclarativeIncubator::incubationMode() const
-{
- return d->mode;
-}
-
-/*!
-Return the current status of the incubator.
-*/
-QDeclarativeIncubator::Status QDeclarativeIncubator::status() const
-{
- return d->status;
-}
-
-/*!
-Return the incubated object if the status is Ready, otherwise 0.
-*/
-QObject *QDeclarativeIncubator::object() const
-{
- if (status() != Ready) return 0;
- else return d->result;
-}
-
-/*!
-Called when the status of the incubator changes. \a status is the new status.
-
-The default implementation does nothing.
-*/
-void QDeclarativeIncubator::statusChanged(Status status)
-{
- Q_UNUSED(status);
-}
-
-/*!
-Called after the object is first created, but before property bindings are
-evaluated and, if applicable, QDeclarativeParserStatus::componentComplete() is
-called. This is equivalent to the point between QDeclarativeComponent::beginCreate()
-and QDeclarativeComponent::endCreate(), and can be used to assign initial values
-to the object's properties.
-
-The default implementation does nothing.
-*/
-void QDeclarativeIncubator::setInitialState(QObject *object)
-{
- Q_UNUSED(object);
-}
-
-void QDeclarativeIncubatorPrivate::changeStatus(QDeclarativeIncubator::Status s)
-{
- if (s == status)
- return;
-
- status = s;
- q->statusChanged(status);
-}
-
-QDeclarativeIncubator::Status QDeclarativeIncubatorPrivate::calculateStatus() const
-{
- if (!errors.isEmpty())
- return QDeclarativeIncubator::Error;
- else if (result && progress == QDeclarativeIncubatorPrivate::Completed &&
- waitingFor.isEmpty())
- return QDeclarativeIncubator::Ready;
- else if (component)
- return QDeclarativeIncubator::Loading;
- else
- return QDeclarativeIncubator::Null;
-}
-
diff --git a/src/declarative/qml/qdeclarativeincubator.h b/src/declarative/qml/qdeclarativeincubator.h
deleted file mode 100644
index dca5c3a6bc..0000000000
--- a/src/declarative/qml/qdeclarativeincubator.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEINCUBATOR_H
-#define QDECLARATIVEINCUBATOR_H
-
-#include <QtDeclarative/qdeclarativeerror.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeEngine;
-
-class QDeclarativeIncubatorPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeIncubator
-{
- Q_DISABLE_COPY(QDeclarativeIncubator)
-public:
- enum IncubationMode {
- Asynchronous,
- AsynchronousIfNested,
- Synchronous
- };
- enum Status {
- Null,
- Ready,
- Loading,
- Error
- };
-
- QDeclarativeIncubator(IncubationMode = Asynchronous);
- virtual ~QDeclarativeIncubator();
-
- void clear();
- void forceCompletion();
-
- bool isNull() const;
- bool isReady() const;
- bool isError() const;
- bool isLoading() const;
-
- QList<QDeclarativeError> errors() const;
-
- IncubationMode incubationMode() const;
-
- Status status() const;
-
- QObject *object() const;
-
-protected:
- virtual void statusChanged(Status);
- virtual void setInitialState(QObject *);
-
-private:
- friend class QDeclarativeComponent;
- friend class QDeclarativeEnginePrivate;
- friend class QDeclarativeIncubatorPrivate;
- QDeclarativeIncubatorPrivate *d;
-};
-
-class QDeclarativeEnginePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeIncubationController
-{
- Q_DISABLE_COPY(QDeclarativeIncubationController)
-public:
- QDeclarativeIncubationController();
- virtual ~QDeclarativeIncubationController();
-
- QDeclarativeEngine *engine() const;
- int incubatingObjectCount() const;
-
- void incubateFor(int msecs);
- void incubateWhile(volatile bool *flag, int msecs=0);
-
-protected:
- virtual void incubatingObjectCountChanged(int);
-
-private:
- friend class QDeclarativeEngine;
- friend class QDeclarativeEnginePrivate;
- friend class QDeclarativeIncubatorPrivate;
- QDeclarativeEnginePrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEINCUBATOR_H
diff --git a/src/declarative/qml/qdeclarativeincubator_p.h b/src/declarative/qml/qdeclarativeincubator_p.h
deleted file mode 100644
index 39ef710a41..0000000000
--- a/src/declarative/qml/qdeclarativeincubator_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEINCUBATOR_P_H
-#define QDECLARATIVEINCUBATOR_P_H
-
-#include <private/qintrusivelist_p.h>
-#include <private/qdeclarativevme_p.h>
-#include <private/qrecursionwatcher_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativecontext_p.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.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeCompiledData;
-class QDeclarativeIncubator;
-class QDeclarativeIncubatorPrivate : public QDeclarativeEnginePrivate::Incubator
-{
-public:
- QDeclarativeIncubatorPrivate(QDeclarativeIncubator *q, QDeclarativeIncubator::IncubationMode m);
- ~QDeclarativeIncubatorPrivate();
-
- QDeclarativeIncubator *q;
-
- QDeclarativeIncubator::Status calculateStatus() const;
- void changeStatus(QDeclarativeIncubator::Status);
- QDeclarativeIncubator::Status status;
-
- QDeclarativeIncubator::IncubationMode mode;
- bool isAsynchronous;
-
- QList<QDeclarativeError> errors;
-
- enum Progress { Execute, Completing, Completed };
- Progress progress;
-
- QDeclarativeGuard<QObject> result;
- QDeclarativeGuardedContextData rootContext;
- QDeclarativeCompiledData *component;
- QDeclarativeVME vme;
- QDeclarativeVMEGuard vmeGuard;
-
- QDeclarativeIncubatorPrivate *waitingOnMe;
- typedef QDeclarativeEnginePrivate::Incubator QIPBase;
- QIntrusiveList<QIPBase, &QIPBase::nextWaitingFor> waitingFor;
-
- QRecursionNode recursion;
-
- void clear();
-
- void incubate(QDeclarativeVME::Interrupt &i);
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEINCUBATOR_P_H
-
diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp
deleted file mode 100644
index 42afbb26f7..0000000000
--- a/src/declarative/qml/qdeclarativeinfo.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeinfo.h"
-
-#include "qdeclarativedata_p.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativemetatype_p.h"
-#include "qdeclarativeengine_p.h"
-
-#include <QCoreApplication>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \fn QDeclarativeInfo qmlInfo(const QObject *object)
- \relates QDeclarativeEngine
-
- Prints warning messages that include the file and line number for the
- specified QML \a object.
-
- When QML types display warning messages, it improves traceability
- if they include the QML file and line number on which the
- particular instance was instantiated.
-
- To include the file and line number, an object must be passed. If
- the file and line number is not available for that instance
- (either it was not instantiated by the QML engine or location
- information is disabled), "unknown location" will be used instead.
-
- For example,
-
- \code
- qmlInfo(object) << tr("component property is a write-once property");
- \endcode
-
- prints
-
- \code
- QML MyCustomType (unknown location): component property is a write-once property
- \endcode
-*/
-
-class QDeclarativeInfoPrivate
-{
-public:
- QDeclarativeInfoPrivate() : ref (1), object(0) {}
-
- int ref;
- const QObject *object;
- QString buffer;
- QList<QDeclarativeError> errors;
-};
-
-QDeclarativeInfo::QDeclarativeInfo(QDeclarativeInfoPrivate *p)
-: QDebug(&p->buffer), d(p)
-{
- nospace();
-}
-
-QDeclarativeInfo::QDeclarativeInfo(const QDeclarativeInfo &other)
-: QDebug(other), d(other.d)
-{
- d->ref++;
-}
-
-QDeclarativeInfo::~QDeclarativeInfo()
-{
- if (0 == --d->ref) {
- QList<QDeclarativeError> errors = d->errors;
-
- QDeclarativeEngine *engine = 0;
-
- if (!d->buffer.isEmpty()) {
- QDeclarativeError error;
-
- QObject *object = const_cast<QObject *>(d->object);
-
- if (object) {
- engine = qmlEngine(d->object);
- QString typeName;
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
- if (type) {
- typeName = type->qmlTypeName();
- int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
- if (lastSlash != -1)
- typeName = typeName.mid(lastSlash+1);
- } else {
- typeName = QString::fromUtf8(object->metaObject()->className());
- int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
- if (marker != -1)
- typeName = typeName.left(marker);
-
- marker = typeName.indexOf(QLatin1String("_QML_"));
- if (marker != -1) {
- typeName = typeName.left(marker);
- typeName += QLatin1Char('*');
- type = QDeclarativeMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
- if (type) {
- typeName = type->qmlTypeName();
- int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
- if (lastSlash != -1)
- typeName = typeName.mid(lastSlash+1);
- }
- }
- }
-
- d->buffer.prepend(QLatin1String("QML ") + typeName + QLatin1String(": "));
-
- QDeclarativeData *ddata = QDeclarativeData::get(object, false);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) {
- error.setUrl(ddata->outerContext->url);
- error.setLine(ddata->lineNumber);
- error.setColumn(ddata->columnNumber);
- }
- }
-
- error.setDescription(d->buffer);
-
- errors.prepend(error);
- }
-
- QDeclarativeEnginePrivate::warning(engine, errors);
-
- delete d;
- }
-}
-
-QDeclarativeInfo qmlInfo(const QObject *me)
-{
- QDeclarativeInfoPrivate *d = new QDeclarativeInfoPrivate;
- d->object = me;
- return QDeclarativeInfo(d);
-}
-
-QDeclarativeInfo qmlInfo(const QObject *me, const QDeclarativeError &error)
-{
- QDeclarativeInfoPrivate *d = new QDeclarativeInfoPrivate;
- d->object = me;
- d->errors << error;
- return QDeclarativeInfo(d);
-}
-
-QDeclarativeInfo qmlInfo(const QObject *me, const QList<QDeclarativeError> &errors)
-{
- QDeclarativeInfoPrivate *d = new QDeclarativeInfoPrivate;
- d->object = me;
- d->errors = errors;
- return QDeclarativeInfo(d);
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinfo.h b/src/declarative/qml/qdeclarativeinfo.h
deleted file mode 100644
index edd56df1a3..0000000000
--- a/src/declarative/qml/qdeclarativeinfo.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEINFO_H
-#define QDECLARATIVEINFO_H
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qurl.h>
-#include <QtDeclarative/qdeclarativeerror.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeInfoPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeInfo : public QDebug
-{
-public:
- QDeclarativeInfo(const QDeclarativeInfo &);
- ~QDeclarativeInfo();
-
- inline QDeclarativeInfo &operator<<(QChar t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(bool t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(char t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(signed short t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(unsigned short t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(signed int t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(unsigned int t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(signed long t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(unsigned long t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(qint64 t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(quint64 t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(float t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(double t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(const char* t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(const QString & t) { QDebug::operator<<(t.toLocal8Bit().constData()); return *this; }
- inline QDeclarativeInfo &operator<<(const QStringRef & t) { return operator<<(t.toString()); }
- inline QDeclarativeInfo &operator<<(const QLatin1String &t) { QDebug::operator<<(t.latin1()); return *this; }
- inline QDeclarativeInfo &operator<<(const QByteArray & t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; }
- inline QDeclarativeInfo &operator<<(QTextStreamFunction f) { QDebug::operator<<(f); return *this; }
- inline QDeclarativeInfo &operator<<(QTextStreamManipulator m) { QDebug::operator<<(m); return *this; }
-#ifndef QT_NO_DEBUG_STREAM
- inline QDeclarativeInfo &operator<<(const QUrl &t) { static_cast<QDebug &>(*this) << t; return *this; }
-#endif
-
-private:
- friend Q_DECLARATIVE_EXPORT QDeclarativeInfo qmlInfo(const QObject *me);
- friend Q_DECLARATIVE_EXPORT QDeclarativeInfo qmlInfo(const QObject *me, const QDeclarativeError &error);
- friend Q_DECLARATIVE_EXPORT QDeclarativeInfo qmlInfo(const QObject *me, const QList<QDeclarativeError> &errors);
-
- QDeclarativeInfo(QDeclarativeInfoPrivate *);
- QDeclarativeInfoPrivate *d;
-};
-
-Q_DECLARATIVE_EXPORT QDeclarativeInfo qmlInfo(const QObject *me);
-Q_DECLARATIVE_EXPORT QDeclarativeInfo qmlInfo(const QObject *me, const QDeclarativeError &error);
-Q_DECLARATIVE_EXPORT QDeclarativeInfo qmlInfo(const QObject *me, const QList<QDeclarativeError> &errors);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEINFO_H
diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp
deleted file mode 100644
index 8c9198007e..0000000000
--- a/src/declarative/qml/qdeclarativeinstruction.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeinstruction_p.h"
-
-#include "qdeclarativecompiler_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
-{
-#ifdef QT_NO_DEBUG_STREAM
- Q_UNUSED(instr)
- Q_UNUSED(idx)
-#else
- switch (instructionType(instr)) {
- case QDeclarativeInstruction::Init:
- qWarning().nospace() << idx << "\t\t" << "INIT\t\t\t" << instr->init.bindingsSize << "\t" << instr->init.parserStatusSize << "\t" << instr->init.contextCache << "\t" << instr->init.compiledBinding;
- break;
- case QDeclarativeInstruction::DeferInit:
- qWarning().nospace() << idx << "\t\t" << "DEFER_INIT\t\t" << instr->deferInit.bindingsSize << "\t" << instr->deferInit.parserStatusSize;
- break;
- case QDeclarativeInstruction::Done:
- qWarning().nospace() << idx << "\t\t" << "DONE";
- break;
- case QDeclarativeInstruction::CreateCppObject:
- qWarning().nospace() << idx << "\t\t" << "CREATECPP\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className;
- break;
- case QDeclarativeInstruction::CreateQMLObject:
- qWarning().nospace() << idx << "\t\t" << "CREATEQML\t\t\t" << instr->createQml.type << "\t" << instr->createQml.bindingBits << "\t\t" << types.at(instr->createQml.type).className;
- break;
- case QDeclarativeInstruction::CompleteQMLObject:
- qWarning().nospace() << idx << "\t\t" << "COMPLETEQML";
- break;
- case QDeclarativeInstruction::CreateSimpleObject:
- qWarning().nospace() << idx << "\t\t" << "CREATE_SIMPLE\t\t" << instr->createSimple.typeSize;
- break;
- case QDeclarativeInstruction::SetId:
- qWarning().nospace() << idx << "\t\t" << "SETID\t\t\t" << instr->setId.value << "\t\t\t" << primitives.at(instr->setId.value);
- break;
- case QDeclarativeInstruction::SetDefault:
- qWarning().nospace() << idx << "\t\t" << "SET_DEFAULT";
- break;
- case QDeclarativeInstruction::CreateComponent:
- qWarning().nospace() << idx << "\t\t" << "CREATE_COMPONENT\t" << instr->createComponent.count;
- break;
- case QDeclarativeInstruction::StoreMetaObject:
- qWarning().nospace() << idx << "\t\t" << "STORE_META\t\t" << instr->storeMeta.data;
- break;
- case QDeclarativeInstruction::StoreFloat:
- qWarning().nospace() << idx << "\t\t" << "STORE_FLOAT\t\t" << instr->storeFloat.propertyIndex << "\t" << instr->storeFloat.value;
- break;
- case QDeclarativeInstruction::StoreDouble:
- qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
- break;
- case QDeclarativeInstruction::StoreDoubleQList:
- qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE_QLIST\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
- break;
- case QDeclarativeInstruction::StoreInteger:
- qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
- break;
- case QDeclarativeInstruction::StoreIntegerQList:
- qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER_QLIST\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
- break;
- case QDeclarativeInstruction::StoreBool:
- qWarning().nospace() << idx << "\t\t" << "STORE_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
- break;
- case QDeclarativeInstruction::StoreBoolQList:
- qWarning().nospace() << idx << "\t\t" << "STORE_BOOL_QLIST\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
- break;
- case QDeclarativeInstruction::StoreString:
- qWarning().nospace() << idx << "\t\t" << "STORE_STRING\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
- break;
- case QDeclarativeInstruction::StoreStringList:
- qWarning().nospace() << idx << "\t\t" << "STORE_STRINGLIST\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
- break;
- case QDeclarativeInstruction::StoreStringQList:
- qWarning().nospace() << idx << "\t\t" << "STORE_STRING_QLIST\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
- break;
- case QDeclarativeInstruction::StoreTrString:
- qWarning().nospace() << idx << "\t\t" << "STORE_TR_STRING\t" << instr->storeTrString.propertyIndex << "\t" << instr->storeTrString.context << "\t" << instr->storeTrString.text << "\t" << instr->storeTrString.comment << "\t" << instr->storeTrString.n;
- break;
- case QDeclarativeInstruction::StoreTrIdString:
- qWarning().nospace() << idx << "\t\t" << "STORE_TRID_STRING\t" << instr->storeTrIdString.propertyIndex << "\t" << instr->storeTrIdString.text << "\t" << instr->storeTrIdString.n;
- break;
- case QDeclarativeInstruction::StoreByteArray:
- qWarning().nospace() << idx << "\t\t" << "STORE_BYTEARRAY" << instr->storeByteArray.propertyIndex << "\t" << instr->storeByteArray.value << "\t\t" << datas.at(instr->storeByteArray.value);
- break;
- case QDeclarativeInstruction::StoreUrl:
- qWarning().nospace() << idx << "\t\t" << "STORE_URL\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << urls.at(instr->storeUrl.value);
- break;
- case QDeclarativeInstruction::StoreUrlQList:
- qWarning().nospace() << idx << "\t\t" << "STORE_URL_QLIST\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << urls.at(instr->storeUrl.value);
- break;
- case QDeclarativeInstruction::StoreColor:
- qWarning().nospace() << idx << "\t\t" << "STORE_COLOR\t\t" << instr->storeColor.propertyIndex << "\t\t\t" << QString::number(instr->storeColor.value, 16);
- break;
- case QDeclarativeInstruction::StoreDate:
- qWarning().nospace() << idx << "\t\t" << "STORE_DATE\t\t" << instr->storeDate.propertyIndex << "\t" << instr->storeDate.value;
- break;
- case QDeclarativeInstruction::StoreTime:
- qWarning().nospace() << idx << "\t\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex;
- break;
- case QDeclarativeInstruction::StoreDateTime:
- qWarning().nospace() << idx << "\t\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex;
- break;
- case QDeclarativeInstruction::StorePoint:
- qWarning().nospace() << idx << "\t\t" << "STORE_POINT\t\t" << instr->storePoint.propertyIndex << "\t" << instr->storePoint.point.xp << "\t" << instr->storePoint.point.yp;
- break;
- case QDeclarativeInstruction::StorePointF:
- qWarning().nospace() << idx << "\t\t" << "STORE_POINTF\t\t" << instr->storePointF.propertyIndex << "\t" << instr->storePointF.point.xp << "\t" << instr->storePointF.point.yp;
- break;
- case QDeclarativeInstruction::StoreSize:
- qWarning().nospace() << idx << "\t\t" << "STORE_SIZE\t\t" << instr->storeSize.propertyIndex << "\t" << instr->storeSize.size.wd << "\t" << instr->storeSize.size.ht;
- break;
- case QDeclarativeInstruction::StoreSizeF:
- qWarning().nospace() << idx << "\t\t" << "STORE_SIZEF\t\t" << instr->storeSizeF.propertyIndex << "\t" << instr->storeSizeF.size.wd << "\t" << instr->storeSizeF.size.ht;
- break;
- case QDeclarativeInstruction::StoreRect:
- qWarning().nospace() << idx << "\t\t" << "STORE_RECT\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.rect.x1 << "\t" << instr->storeRect.rect.y1 << "\t" << instr->storeRect.rect.x2 << "\t" << instr->storeRect.rect.y2;
- break;
- case QDeclarativeInstruction::StoreRectF:
- qWarning().nospace() << idx << "\t\t" << "STORE_RECTF\t\t" << instr->storeRectF.propertyIndex << "\t" << instr->storeRectF.rect.xp << "\t" << instr->storeRectF.rect.yp << "\t" << instr->storeRectF.rect.w << "\t" << instr->storeRectF.rect.h;
- break;
- case QDeclarativeInstruction::StoreVector3D:
- qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR3D\t\t" << instr->storeVector3D.propertyIndex << "\t" << instr->storeVector3D.vector.xp << "\t" << instr->storeVector3D.vector.yp << "\t" << instr->storeVector3D.vector.zp;
- break;
- case QDeclarativeInstruction::StoreVector4D:
- qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR4D\t\t" << instr->storeVector4D.propertyIndex << "\t" << instr->storeVector4D.vector.xp << "\t" << instr->storeVector4D.vector.yp << "\t" << instr->storeVector4D.vector.zp << "\t" << instr->storeVector4D.vector.wp;
- break;
- case QDeclarativeInstruction::StoreVariant:
- qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
- break;
- case QDeclarativeInstruction::StoreVariantInteger:
- qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
- break;
- case QDeclarativeInstruction::StoreVariantDouble:
- qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
- break;
- case QDeclarativeInstruction::StoreVariantBool:
- qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
- break;
- case QDeclarativeInstruction::StoreObject:
- qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
- break;
- case QDeclarativeInstruction::StoreVariantObject:
- qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_OBJECT\t" << instr->storeObject.propertyIndex;
- break;
- case QDeclarativeInstruction::StoreInterface:
- qWarning().nospace() << idx << "\t\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
- break;
- case QDeclarativeInstruction::StoreSignal:
- qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value;
- break;
- case QDeclarativeInstruction::StoreImportedScript:
- qWarning().nospace() << idx << "\t\t" << "STORE_IMPORTED_SCRIPT\t" << instr->storeScript.value;
- break;
- case QDeclarativeInstruction::StoreScriptString:
- qWarning().nospace() << idx << "\t\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope << "\t" << instr->storeScriptString.bindingId;
- break;
- case QDeclarativeInstruction::AssignSignalObject:
- qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal;
- break;
- case QDeclarativeInstruction::AssignCustomType:
- qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type;
- break;
- case QDeclarativeInstruction::InitV8Bindings:
- qWarning().nospace() << idx << "\t\t" << "INIT_V8_BINDING\t" << instr->initV8Bindings.programIndex << "\t" << instr->initV8Bindings.line;
- break;
- case QDeclarativeInstruction::StoreBinding:
- qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
- break;
- case QDeclarativeInstruction::StoreBindingOnAlias:
- qWarning().nospace() << idx << "\t\t" << "STORE_BINDING_ALIAS\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
- break;
- case QDeclarativeInstruction::StoreV4Binding:
- qWarning().nospace() << idx << "\t\t" << "STORE_COMPILED_BINDING\t" << instr->assignV4Binding.property << "\t" << instr->assignV4Binding.value << "\t" << instr->assignV4Binding.context;
- break;
- case QDeclarativeInstruction::StoreV8Binding:
- qWarning().nospace() << idx << "\t\t" << "STORE_V8_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
- break;
- case QDeclarativeInstruction::StoreValueSource:
- qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property.coreIndex << "\t" << instr->assignValueSource.castValue;
- break;
- case QDeclarativeInstruction::StoreValueInterceptor:
- qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property.coreIndex << "\t" << instr->assignValueInterceptor.castValue;
- break;
- case QDeclarativeInstruction::BeginObject:
- qWarning().nospace() << idx << "\t\t" << "BEGIN\t\t\t" << instr->begin.castValue;
- break;
- case QDeclarativeInstruction::StoreObjectQList:
- qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT_QLIST";
- break;
- case QDeclarativeInstruction::AssignObjectList:
- qWarning().nospace() << idx << "\t\t" << "ASSIGN_OBJECT_LIST";
- break;
- case QDeclarativeInstruction::FetchAttached:
- qWarning().nospace() << idx << "\t\t" << "FETCH_ATTACHED\t\t" << instr->fetchAttached.id;
- break;
- case QDeclarativeInstruction::FetchQList:
- qWarning().nospace() << idx << "\t\t" << "FETCH_QLIST\t\t" << instr->fetch.property;
- break;
- case QDeclarativeInstruction::FetchObject:
- qWarning().nospace() << idx << "\t\t" << "FETCH\t\t\t" << instr->fetch.property;
- break;
- case QDeclarativeInstruction::FetchValueType:
- qWarning().nospace() << idx << "\t\t" << "FETCH_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type << "\t" << instr->fetchValue.bindingSkipList;
- break;
- case QDeclarativeInstruction::PopFetchedObject:
- qWarning().nospace() << idx << "\t\t" << "POP";
- break;
- case QDeclarativeInstruction::PopQList:
- qWarning().nospace() << idx << "\t\t" << "POP_QLIST";
- break;
- case QDeclarativeInstruction::PopValueType:
- qWarning().nospace() << idx << "\t\t" << "POP_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
- break;
- case QDeclarativeInstruction::Defer:
- qWarning().nospace() << idx << "\t\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
- break;
- default:
- qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instructionType(instr);
- break;
- }
-#endif // QT_NO_DEBUG_STREAM
-}
-
-int QDeclarativeInstruction::size(Type type)
-{
-#define QML_RETURN_INSTR_SIZE(I, FMT) case I: return QDeclarativeInstructionMeta<(int)I>::Size;
- switch (type) {
- FOR_EACH_QML_INSTR(QML_RETURN_INSTR_SIZE)
- default: return 0;
- }
-#undef QML_RETURN_INSTR_SIZE
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
deleted file mode 100644
index dee712d0dc..0000000000
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ /dev/null
@@ -1,558 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEINSTRUCTION_P_H
-#define QDECLARATIVEINSTRUCTION_P_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 <private/qdeclarativepropertycache_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#define FOR_EACH_QML_INSTR(F) \
- F(Init, init) \
- F(DeferInit, deferInit) \
- F(Done, common) \
- F(CreateCppObject, create) \
- F(CreateQMLObject, createQml) \
- F(CompleteQMLObject, completeQml) \
- F(CreateSimpleObject, createSimple) \
- F(SetId, setId) \
- F(SetDefault, common) \
- F(CreateComponent, createComponent) \
- F(StoreMetaObject, storeMeta) \
- F(StoreVariant, storeString) \
- F(StoreVariantInteger, storeInteger) \
- F(StoreVariantDouble, storeDouble) \
- F(StoreVariantBool, storeBool) \
- F(StoreVar, storeString) \
- F(StoreVarInteger, storeInteger) \
- F(StoreVarDouble, storeDouble) \
- F(StoreVarBool, storeBool) \
- F(StoreString, storeString) \
- F(StoreStringList, storeString) \
- F(StoreStringQList, storeString) \
- F(StoreTrString, storeTrString) \
- F(StoreTrIdString, storeTrIdString) \
- F(StoreByteArray, storeByteArray) \
- F(StoreUrl, storeUrl) \
- F(StoreUrlQList, storeUrl) \
- F(StoreFloat, storeFloat) \
- F(StoreDouble, storeDouble) \
- F(StoreDoubleQList, storeDouble) \
- F(StoreBool, storeBool) \
- F(StoreBoolQList, storeBool) \
- F(StoreInteger, storeInteger) \
- F(StoreIntegerQList, storeInteger) \
- F(StoreColor, storeColor) \
- F(StoreDate, storeDate) \
- F(StoreTime, storeTime) \
- F(StoreDateTime, storeDateTime) \
- F(StorePoint, storePoint) \
- F(StorePointF, storePointF) \
- F(StoreSize, storeSize) \
- F(StoreSizeF, storeSizeF) \
- F(StoreRect, storeRect) \
- F(StoreRectF, storeRectF) \
- F(StoreVector3D, storeVector3D) \
- F(StoreVector4D, storeVector4D) \
- F(StoreObject, storeObject) \
- F(AssignCustomType, assignCustomType) \
- F(AssignSignalObject, assignSignalObject) \
- F(StoreSignal, storeSignal) \
- F(StoreImportedScript, storeScript) \
- F(StoreScriptString, storeScriptString) \
- F(BeginObject, begin) \
- F(InitV8Bindings, initV8Bindings) \
- F(StoreBinding, assignBinding) \
- F(StoreBindingOnAlias, assignBinding) \
- F(StoreV8Binding, assignBinding) \
- F(StoreV4Binding, assignV4Binding) \
- F(StoreValueSource, assignValueSource) \
- F(StoreValueInterceptor, assignValueInterceptor) \
- F(StoreObjectQList, common) \
- F(AssignObjectList, assignObjectList) \
- F(StoreVariantObject, storeObject) \
- F(StoreVarObject, storeObject) \
- F(StoreInterface, storeObject) \
- F(FetchAttached, fetchAttached) \
- F(FetchQList, fetchQmlList) \
- F(FetchObject, fetch) \
- F(PopQList, common) \
- F(Defer, defer) \
- F(PopFetchedObject, common) \
- F(FetchValueType, fetchValue) \
- F(PopValueType, fetchValue)
-
-#if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
-# define QML_THREADED_VME_INTERPRETER
-#endif
-
-#ifdef Q_ALIGNOF
-# define QML_INSTR_ALIGN_MASK (Q_ALIGNOF(QDeclarativeInstruction) - 1)
-#else
-# define QML_INSTR_ALIGN_MASK (sizeof(void *) - 1)
-#endif
-
-#ifdef QML_THREADED_VME_INTERPRETER
-# define QML_INSTR_HEADER void *code;
-#else
-# define QML_INSTR_HEADER quint8 instructionType;
-#endif
-
-#define QML_INSTR_ENUM(I, FMT) I,
-#define QML_INSTR_SIZE(I, FMT) ((sizeof(QDeclarativeInstruction::instr_##FMT) + QML_INSTR_ALIGN_MASK) & ~QML_INSTR_ALIGN_MASK)
-
-class QDeclarativeCompiledData;
-union QDeclarativeInstruction
-{
- enum Type {
- FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
- };
-
- struct instr_common {
- QML_INSTR_HEADER
- };
- struct instr_init {
- QML_INSTR_HEADER
- int bindingsSize;
- int parserStatusSize;
- int contextCache;
- int compiledBinding;
- int objectStackSize;
- int listStackSize;
- };
- struct instr_deferInit {
- QML_INSTR_HEADER
- int bindingsSize;
- int parserStatusSize;
- int objectStackSize;
- int listStackSize;
- };
- struct instr_createQml {
- QML_INSTR_HEADER
- int type;
- int bindingBits;
- bool isRoot;
- };
- struct instr_completeQml {
- QML_INSTR_HEADER
- ushort column;
- ushort line;
- bool isRoot;
- };
- struct instr_create {
- QML_INSTR_HEADER
- int type;
- int data;
- ushort column;
- ushort line;
- bool isRoot;
- };
- struct instr_createSimple {
- QML_INSTR_HEADER
- void (*create)(void *);
- int typeSize;
- int type;
- ushort column;
- ushort line;
- };
- struct instr_storeMeta {
- QML_INSTR_HEADER
- int data;
- int aliasData;
- int propertyCache;
- };
- struct instr_setId {
- QML_INSTR_HEADER
- int value;
- int index;
- };
- struct instr_assignValueSource {
- QML_INSTR_HEADER
- QDeclarativePropertyRawData property;
- int owner;
- int castValue;
- };
- struct instr_assignValueInterceptor {
- QML_INSTR_HEADER
- QDeclarativePropertyRawData property;
- int owner;
- int castValue;
- };
- struct instr_initV8Bindings {
- QML_INSTR_HEADER
- ushort programIndex;
- ushort line;
- };
- struct instr_assignV4Binding {
- QML_INSTR_HEADER
- unsigned int property;
- int value;
- short context;
- short owner;
- bool isRoot;
- ushort line;
- ushort column;
- };
- struct instr_assignBinding {
- QML_INSTR_HEADER
- QDeclarativePropertyRawData property;
- int value;
- short context;
- short owner;
- bool isRoot;
- ushort line;
- ushort column;
- };
- struct instr_fetch {
- QML_INSTR_HEADER
- int property;
- ushort line;
- };
- struct instr_fetchValue {
- QML_INSTR_HEADER
- int property;
- int type;
- quint32 bindingSkipList;
- };
- struct instr_fetchQmlList {
- QML_INSTR_HEADER
- int property;
- int type;
- };
- struct instr_begin {
- QML_INSTR_HEADER
- int castValue;
- };
- struct instr_storeFloat {
- QML_INSTR_HEADER
- int propertyIndex;
- float value;
- };
- struct instr_storeDouble {
- QML_INSTR_HEADER
- int propertyIndex;
- double value;
- };
- struct instr_storeInteger {
- QML_INSTR_HEADER
- int propertyIndex;
- int value;
- };
- struct instr_storeBool {
- QML_INSTR_HEADER
- int propertyIndex;
- bool value;
- };
- struct instr_storeString {
- QML_INSTR_HEADER
- int propertyIndex;
- int value;
- };
- struct instr_storeTrString {
- QML_INSTR_HEADER
- int propertyIndex;
- int context;
- int text;
- int comment;
- int n;
- };
- struct instr_storeTrIdString {
- QML_INSTR_HEADER
- int propertyIndex;
- int text;
- int n;
- };
- struct instr_storeByteArray {
- QML_INSTR_HEADER
- int propertyIndex;
- int value;
- };
- struct instr_storeScriptString {
- QML_INSTR_HEADER
- int propertyIndex;
- int value;
- int scope;
- int bindingId;
- ushort line;
- ushort column;
- };
- struct instr_storeScript {
- QML_INSTR_HEADER
- int value;
- };
- struct instr_storeUrl {
- QML_INSTR_HEADER
- int propertyIndex;
- int value;
- };
- struct instr_storeColor {
- QML_INSTR_HEADER
- int propertyIndex;
- unsigned int value;
- };
- struct instr_storeDate {
- QML_INSTR_HEADER
- int propertyIndex;
- int value;
- };
- struct instr_storeTime {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QTime {
- int mds;
-#if defined(Q_OS_WINCE)
- int startTick;
-#endif
- } time;
- };
- struct instr_storeDateTime {
- QML_INSTR_HEADER
- int propertyIndex;
- int date;
- instr_storeTime::QTime time;
- };
- struct instr_storeRect {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QRect {
- int x1;
- int y1;
- int x2;
- int y2;
- } rect;
- };
- struct instr_storeRectF {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QRectF {
- qreal xp;
- qreal yp;
- qreal w;
- qreal h;
- } rect;
- };
- struct instr_storeObject {
- QML_INSTR_HEADER
- int propertyIndex;
- ushort line;
- };
- struct instr_assignCustomType {
- QML_INSTR_HEADER
- int propertyIndex;
- int primitive;
- int type;
- ushort line;
- };
- struct instr_storeSignal {
- QML_INSTR_HEADER
- int signalIndex;
- int value;
- short context;
- ushort line;
- ushort column;
- };
- struct instr_assignSignalObject {
- QML_INSTR_HEADER
- int signal;
- ushort line;
- };
- struct instr_createComponent {
- QML_INSTR_HEADER
- int count;
- int endLine;
- int metaObject;
- ushort column;
- ushort line;
- bool isRoot;
- };
- struct instr_fetchAttached {
- QML_INSTR_HEADER
- int id;
- ushort line;
- };
- struct instr_defer {
- QML_INSTR_HEADER
- int deferCount;
- };
- struct instr_assignObjectList {
- QML_INSTR_HEADER
- ushort line;
- };
- struct instr_storePoint {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QPoint {
- int xp;
- int yp;
- } point;
- };
- struct instr_storePointF {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QPointF {
- qreal xp;
- qreal yp;
- } point;
- };
- struct instr_storeSize {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QSize {
- int wd;
- int ht;
- } size;
- };
- struct instr_storeSizeF {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QSizeF {
- qreal wd;
- qreal ht;
- } size;
- };
- struct instr_storeVector3D {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QVector3D {
- float xp;
- float yp;
- float zp;
- } vector;
- };
- struct instr_storeVector4D {
- QML_INSTR_HEADER
- int propertyIndex;
- struct QVector4D {
- float xp;
- float yp;
- float zp;
- float wp;
- } vector;
- };
-
- instr_common common;
- instr_init init;
- instr_deferInit deferInit;
- instr_create create;
- instr_createQml createQml;
- instr_completeQml completeQml;
- instr_createSimple createSimple;
- instr_storeMeta storeMeta;
- instr_setId setId;
- instr_assignValueSource assignValueSource;
- instr_assignValueInterceptor assignValueInterceptor;
- instr_initV8Bindings initV8Bindings;
- instr_assignV4Binding assignV4Binding;
- instr_assignBinding assignBinding;
- instr_fetch fetch;
- instr_fetchValue fetchValue;
- instr_fetchQmlList fetchQmlList;
- instr_begin begin;
- instr_storeFloat storeFloat;
- instr_storeDouble storeDouble;
- instr_storeInteger storeInteger;
- instr_storeBool storeBool;
- instr_storeString storeString;
- instr_storeTrString storeTrString;
- instr_storeTrIdString storeTrIdString;
- instr_storeByteArray storeByteArray;
- instr_storeScriptString storeScriptString;
- instr_storeScript storeScript;
- instr_storeUrl storeUrl;
- instr_storeColor storeColor;
- instr_storeDate storeDate;
- instr_storeTime storeTime;
- instr_storeDateTime storeDateTime;
- instr_storePoint storePoint;
- instr_storePointF storePointF;
- instr_storeSize storeSize;
- instr_storeSizeF storeSizeF;
- instr_storeRect storeRect;
- instr_storeRectF storeRectF;
- instr_storeVector3D storeVector3D;
- instr_storeVector4D storeVector4D;
- instr_storeObject storeObject;
- instr_assignCustomType assignCustomType;
- instr_storeSignal storeSignal;
- instr_assignSignalObject assignSignalObject;
- instr_createComponent createComponent;
- instr_fetchAttached fetchAttached;
- instr_defer defer;
- instr_assignObjectList assignObjectList;
-
- static int size(Type type);
-};
-
-template<int N>
-struct QDeclarativeInstructionMeta {
-};
-
-#define QML_INSTR_META_TEMPLATE(I, FMT) \
- template<> struct QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I> { \
- enum { Size = QML_INSTR_SIZE(I, FMT) }; \
- typedef QDeclarativeInstruction::instr_##FMT DataType; \
- static const DataType &data(const QDeclarativeInstruction &instr) { return instr.FMT; } \
- static void setData(QDeclarativeInstruction &instr, const DataType &v) { instr.FMT = v; } \
- };
-FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
-#undef QML_INSTR_META_TEMPLATE
-
-template<int Instr>
-class QDeclarativeInstructionData : public QDeclarativeInstructionMeta<Instr>::DataType
-{
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEINSTRUCTION_P_H
diff --git a/src/declarative/qml/qdeclarativeintegercache.cpp b/src/declarative/qml/qdeclarativeintegercache.cpp
deleted file mode 100644
index 61f6f3c8e1..0000000000
--- a/src/declarative/qml/qdeclarativeintegercache.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeintegercache_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeIntegerCache::QDeclarativeIntegerCache()
-{
-}
-
-QDeclarativeIntegerCache::~QDeclarativeIntegerCache()
-{
-}
-
-QString QDeclarativeIntegerCache::findId(int value) const
-{
- for (StringCache::ConstIterator iter = stringCache.begin();
- iter != stringCache.end(); ++iter) {
- if (iter.value() == value)
- return iter.key();
- }
- return QString();
-}
-
-void QDeclarativeIntegerCache::reserve(int size)
-{
- stringCache.reserve(size);
-}
-
-void QDeclarativeIntegerCache::add(const QString &id, int value)
-{
- Q_ASSERT(!stringCache.contains(id));
-
- stringCache.insert(id, value);
-}
-
-int QDeclarativeIntegerCache::value(const QString &id)
-{
- int *rv = stringCache.value(id);
- return rv?*rv:-1;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeintegercache_p.h b/src/declarative/qml/qdeclarativeintegercache_p.h
deleted file mode 100644
index a40100722e..0000000000
--- a/src/declarative/qml/qdeclarativeintegercache_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEINTEGERCACHE_P_H
-#define QDECLARATIVEINTEGERCACHE_P_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 <private/qdeclarativerefcount_p.h>
-#include <private/qhashedstring_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeType;
-class QDeclarativeEngine;
-class QDeclarativeIntegerCache : public QDeclarativeRefCount
-{
-public:
- QDeclarativeIntegerCache();
- virtual ~QDeclarativeIntegerCache();
-
- inline int count() const;
- void add(const QString &, int);
- void reserve(int);
-
- int value(const QString &);
- inline int value(const QHashedV8String &);
-
- QString findId(int value) const;
-
-private:
- typedef QStringHash<int> StringCache;
- StringCache stringCache;
-};
-
-int QDeclarativeIntegerCache::value(const QHashedV8String &name)
-{
- int *result = stringCache.value(name);
- return result?*result:-1;
-}
-
-int QDeclarativeIntegerCache::count() const
-{
- return stringCache.count();
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEINTEGERCACHE_P_H
-
diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp
deleted file mode 100644
index 128bd0b86f..0000000000
--- a/src/declarative/qml/qdeclarativelist.cpp
+++ /dev/null
@@ -1,417 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativelist.h"
-#include "qdeclarativelist_p.h"
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativeproperty_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeListReferencePrivate::QDeclarativeListReferencePrivate()
-: propertyType(-1), refCount(1)
-{
-}
-
-QDeclarativeListReference QDeclarativeListReferencePrivate::init(const QDeclarativeListProperty<QObject> &prop, int propType, QDeclarativeEngine *engine)
-{
- QDeclarativeListReference rv;
-
- if (!prop.object) return rv;
-
- QDeclarativeEnginePrivate *p = engine?QDeclarativeEnginePrivate::get(engine):0;
-
- int listType = p?p->listType(propType):QDeclarativeMetaType::listType(propType);
- if (listType == -1) return rv;
-
- rv.d = new QDeclarativeListReferencePrivate;
- rv.d->object = prop.object;
- rv.d->elementType = p?p->rawMetaObjectForType(listType):QDeclarativeMetaType::qmlType(listType)->baseMetaObject();
- rv.d->property = prop;
- rv.d->propertyType = propType;
-
- return rv;
-}
-
-void QDeclarativeListReferencePrivate::addref()
-{
- Q_ASSERT(refCount > 0);
- ++refCount;
-}
-
-void QDeclarativeListReferencePrivate::release()
-{
- Q_ASSERT(refCount > 0);
- --refCount;
- if (!refCount)
- delete this;
-}
-
-/*!
-\class QDeclarativeListReference
-\since 4.7
-\module QtDeclarative
-\brief The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties.
-
-QDeclarativeListReference allows C++ programs to read from, and assign values to a QML list property in a
-simple and type safe way. A QDeclarativeListReference can be created by passing an object and property
-name or through a QDeclarativeProperty instance. These two are equivalant:
-
-\code
-QDeclarativeListReference ref1(object, "children");
-
-QDeclarativeProperty ref2(object, "children");
-QDeclarativeListReference ref2 = qvariant_cast<QDeclarativeListReference>(ref2.read());
-\endcode
-
-Not all QML list properties support all operations. A set of methods, canAppend(), canAt(), canClear() and
-canCount() allow programs to query whether an operation is supported on a given property.
-
-QML list properties are typesafe. Only QObject's that derive from the correct base class can be assigned to
-the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported.
-Attempting to add objects of the incorrect type to a list property will fail.
-
-Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure
-that it does not request an out of range element using the count() method before calling at().
-*/
-
-/*!
-Constructs an invalid instance.
-*/
-QDeclarativeListReference::QDeclarativeListReference()
-: d(0)
-{
-}
-
-/*!
-Constructs a QDeclarativeListReference for \a object's \a property. If \a property is not a list
-property, an invalid QDeclarativeListReference is created. If \a object is destroyed after
-the reference is constructed, it will automatically become invalid. That is, it is safe to hold
-QDeclarativeListReference instances even after \a object is deleted.
-
-Passing \a engine is required to access some QML created list properties. If in doubt, and an engine
-is available, pass it.
-*/
-QDeclarativeListReference::QDeclarativeListReference(QObject *object, const char *property, QDeclarativeEngine *engine)
-: d(0)
-{
- if (!object || !property) return;
-
- QDeclarativePropertyData local;
- QDeclarativePropertyData *data =
- QDeclarativePropertyCache::property(engine, object, QLatin1String(property), local);
-
- if (!data || !data->isQList()) return;
-
- QDeclarativeEnginePrivate *p = engine?QDeclarativeEnginePrivate::get(engine):0;
-
- int listType = p?p->listType(data->propType):QDeclarativeMetaType::listType(data->propType);
- if (listType == -1) return;
-
- d = new QDeclarativeListReferencePrivate;
- d->object = object;
- d->elementType = p?p->rawMetaObjectForType(listType):QDeclarativeMetaType::qmlType(listType)->baseMetaObject();
- d->propertyType = data->propType;
-
- void *args[] = { &d->property, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex, args);
-}
-
-/*! \internal */
-QDeclarativeListReference::QDeclarativeListReference(const QDeclarativeListReference &o)
-: d(o.d)
-{
- if (d) d->addref();
-}
-
-/*! \internal */
-QDeclarativeListReference &QDeclarativeListReference::operator=(const QDeclarativeListReference &o)
-{
- if (o.d) o.d->addref();
- if (d) d->release();
- d = o.d;
- return *this;
-}
-
-/*! \internal */
-QDeclarativeListReference::~QDeclarativeListReference()
-{
- if (d) d->release();
-}
-
-/*!
-Returns true if the instance refers to a valid list property, otherwise false.
-*/
-bool QDeclarativeListReference::isValid() const
-{
- return d && d->object;
-}
-
-/*!
-Returns the list property's object. Returns 0 if the reference is invalid.
-*/
-QObject *QDeclarativeListReference::object() const
-{
- if (isValid()) return d->object;
- else return 0;
-}
-
-/*!
-Returns the QMetaObject for the elements stored in the list property. Returns 0 if the reference
-is invalid.
-
-The QMetaObject can be used ahead of time to determine whether a given instance can be added
-to a list.
-*/
-const QMetaObject *QDeclarativeListReference::listElementType() const
-{
- if (isValid()) return d->elementType;
- else return 0;
-}
-
-/*!
-Returns true if the list property can be appended to, otherwise false. Returns false if the
-reference is invalid.
-
-\sa append()
-*/
-bool QDeclarativeListReference::canAppend() const
-{
- return (isValid() && d->property.append);
-}
-
-/*!
-Returns true if the list property can queried by index, otherwise false. Returns false if the
-reference is invalid.
-
-\sa at()
-*/
-bool QDeclarativeListReference::canAt() const
-{
- return (isValid() && d->property.at);
-}
-
-/*!
-Returns true if the list property can be cleared, otherwise false. Returns false if the
-reference is invalid.
-
-\sa clear()
-*/
-bool QDeclarativeListReference::canClear() const
-{
- return (isValid() && d->property.clear);
-}
-
-/*!
-Returns true if the list property can be queried for its element count, otherwise false.
-Returns false if the reference is invalid.
-
-\sa count()
-*/
-bool QDeclarativeListReference::canCount() const
-{
- return (isValid() && d->property.count);
-}
-
-/*!
-Appends \a object to the list. Returns true if the operation succeeded, otherwise false.
-
-\sa canAppend()
-*/
-bool QDeclarativeListReference::append(QObject *object) const
-{
- if (!canAppend()) return false;
-
- if (object && !QDeclarativePropertyPrivate::canConvert(object->metaObject(), d->elementType))
- return false;
-
- d->property.append(&d->property, object);
-
- return true;
-}
-
-/*!
-Returns the list element at \a index, or 0 if the operation failed.
-
-\sa canAt()
-*/
-QObject *QDeclarativeListReference::at(int index) const
-{
- if (!canAt()) return 0;
-
- return d->property.at(&d->property, index);
-}
-
-/*!
-Clears the list. Returns true if the operation succeeded, otherwise false.
-
-\sa canClear()
-*/
-bool QDeclarativeListReference::clear() const
-{
- if (!canClear()) return false;
-
- d->property.clear(&d->property);
-
- return true;
-}
-
-/*!
-Returns the number of objects in the list, or 0 if the operation failed.
-*/
-int QDeclarativeListReference::count() const
-{
- if (!canCount()) return 0;
-
- return d->property.count(&d->property);
-}
-
-/*!
-\class QDeclarativeListProperty
-\since 4.7
-\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.
-The use of a list property from QML looks like this:
-
-\code
-FruitBasket {
- fruit: [
- Apple {},
- Orange{},
- Banana{}
- ]
-}
-\endcode
-
-The QDeclarativeListProperty encapsulates a group of function pointers that represet the
-set of actions QML can perform on the list - adding items, retrieving items and
-clearing the list. In the future, additional operations may be supported. All
-list properties must implement the append operation, but the rest are optional.
-
-To provide a list property, a C++ class must implement the operation callbacks,
-and then return an appropriate QDeclarativeListProperty value from the property getter.
-List properties should have no setter. In the example above, the Q_PROPERTY()
-declarative will look like this:
-
-\code
-Q_PROPERTY(QDeclarativeListProperty<Fruit> fruit READ fruit);
-\endcode
-
-QML list properties are typesafe - in this case \c {Fruit} is a QObject type that
-\c {Apple}, \c {Orange} and \c {Banana} all derive from.
-
-\note QDeclarativeListProperty can only be used for lists of QObject-derived object pointers.
-
-\sa {Object and List Property Types}
-
-*/
-
-/*!
-\fn QDeclarativeListProperty::QDeclarativeListProperty()
-\internal
-*/
-
-/*!
-\fn QDeclarativeListProperty::QDeclarativeListProperty(QObject *object, QList<T *> &list)
-
-Convenience constructor for making a QDeclarativeListProperty value from an existing
-QList \a list. The \a list reference must remain valid for as long as \a object
-exists. \a object must be provided.
-
-Generally this constructor should not be used in production code, as a
-writable QList violates QML's memory management rules. However, this constructor
-can very useful while prototyping.
-*/
-
-/*!
-\fn QDeclarativeListProperty::QDeclarativeListProperty(QObject *object, void *data, AppendFunction append,
- CountFunction count = 0, AtFunction at = 0,
- ClearFunction clear = 0)
-
-Construct a QDeclarativeListProperty from a set of operation functions. An opaque \a data handle
-may be passed which can be accessed from within the operation functions. The list property
-remains valid while \a object exists.
-
-The \a append operation is compulsory and must be provided, while the \a count, \a at and
-\a clear methods are optional.
-*/
-
-/*!
-\typedef QDeclarativeListProperty::AppendFunction
-
-Synonym for \c {void (*)(QDeclarativeListProperty<T> *property, T *value)}.
-
-Append the \a value to the list \a property.
-*/
-
-/*!
-\typedef QDeclarativeListProperty::CountFunction
-
-Synonym for \c {int (*)(QDeclarativeListProperty<T> *property)}.
-
-Return the number of elements in the list \a property.
-*/
-
-/*!
-\fn bool QDeclarativeListProperty::operator==(const QDeclarativeListProperty &other) const
-
-Returns true if this QDeclarativeListProperty is equal to \a other, otherwise false.
-*/
-
-/*!
-\typedef QDeclarativeListProperty::AtFunction
-
-Synonym for \c {T *(*)(QDeclarativeListProperty<T> *property, int index)}.
-
-Return the element at position \a index in the list \a property.
-*/
-
-/*!
-\typedef QDeclarativeListProperty::ClearFunction
-
-Synonym for \c {void (*)(QDeclarativeListProperty<T> *property)}.
-
-Clear the list \a property.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h
deleted file mode 100644
index d1cebd240a..0000000000
--- a/src/declarative/qml/qdeclarativelist.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELIST_H
-#define QDECLARATIVELIST_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QObject;
-struct QMetaObject;
-
-#ifndef QDECLARATIVELISTPROPERTY
-#define QDECLARATIVELISTPROPERTY
-template<typename T>
-class QDeclarativeListProperty {
-public:
- typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*);
- typedef int (*CountFunction)(QDeclarativeListProperty<T> *);
- typedef T *(*AtFunction)(QDeclarativeListProperty<T> *, int);
- typedef void (*ClearFunction)(QDeclarativeListProperty<T> *);
-
- QDeclarativeListProperty()
- : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {}
- QDeclarativeListProperty(QObject *o, QList<T *> &list)
- : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at),
- clear(qlist_clear), dummy1(0), dummy2(0) {}
- QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0,
- ClearFunction r = 0)
- : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {}
-
- bool operator==(const QDeclarativeListProperty &o) const {
- return object == o.object &&
- data == o.data &&
- append == o.append &&
- count == o.count &&
- at == o.at &&
- clear == o.clear;
- }
-
- QObject *object;
- void *data;
-
- AppendFunction append;
-
- CountFunction count;
- AtFunction at;
-
- ClearFunction clear;
-
- void *dummy1;
- void *dummy2;
-
-private:
- static void qlist_append(QDeclarativeListProperty *p, T *v) {
- reinterpret_cast<QList<T *> *>(p->data)->append(v);
- }
- static int qlist_count(QDeclarativeListProperty *p) {
- return reinterpret_cast<QList<T *> *>(p->data)->count();
- }
- static T *qlist_at(QDeclarativeListProperty *p, int idx) {
- return reinterpret_cast<QList<T *> *>(p->data)->at(idx);
- }
- static void qlist_clear(QDeclarativeListProperty *p) {
- return reinterpret_cast<QList<T *> *>(p->data)->clear();
- }
-};
-#endif
-
-class QDeclarativeEngine;
-class QDeclarativeListReferencePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeListReference
-{
-public:
- QDeclarativeListReference();
- QDeclarativeListReference(QObject *, const char *property, QDeclarativeEngine * = 0);
- QDeclarativeListReference(const QDeclarativeListReference &);
- QDeclarativeListReference &operator=(const QDeclarativeListReference &);
- ~QDeclarativeListReference();
-
- bool isValid() const;
-
- QObject *object() const;
- const QMetaObject *listElementType() const;
-
- bool canAppend() const;
- bool canAt() const;
- bool canClear() const;
- bool canCount() const;
-
- bool append(QObject *) const;
- QObject *at(int) const;
- bool clear() const;
- int count() const;
-
-private:
- friend class QDeclarativeListReferencePrivate;
- QDeclarativeListReferencePrivate* d;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeListReference)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVELIST_H
diff --git a/src/declarative/qml/qdeclarativelist_p.h b/src/declarative/qml/qdeclarativelist_p.h
deleted file mode 100644
index 60d4d28558..0000000000
--- a/src/declarative/qml/qdeclarativelist_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELIST_P_H
-#define QDECLARATIVELIST_P_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 "qdeclarativelist.h"
-#include "qdeclarativeguard_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeListReferencePrivate
-{
-public:
- QDeclarativeListReferencePrivate();
-
- static QDeclarativeListReference init(const QDeclarativeListProperty<QObject> &, int, QDeclarativeEngine *);
-
- QDeclarativeGuard<QObject> object;
- const QMetaObject *elementType;
- QDeclarativeListProperty<QObject> property;
- int propertyType;
-
- void addref();
- void release();
- int refCount;
-
- static inline QDeclarativeListReferencePrivate *get(QDeclarativeListReference *ref) {
- return ref->d;
- }
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVELIST_P_H
diff --git a/src/declarative/qml/qdeclarativelistmodel.cpp b/src/declarative/qml/qdeclarativelistmodel.cpp
deleted file mode 100644
index ce7235e548..0000000000
--- a/src/declarative/qml/qdeclarativelistmodel.cpp
+++ /dev/null
@@ -1,2467 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativelistmodel_p_p.h"
-#include "qdeclarativelistmodelworkeragent_p.h"
-#include "qdeclarativeopenmetaobject_p.h"
-#include <private/qdeclarativejsast_p.h>
-#include <private/qdeclarativejsengine_p.h>
-
-#include <private/qdeclarativecustomparser_p.h>
-#include <private/qdeclarativescript_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarativeinfo.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstack.h>
-#include <QXmlStreamReader>
-
-Q_DECLARE_METATYPE(QListModelInterface *)
-
-QT_BEGIN_NAMESPACE
-
-// Set to 1024 as a debugging aid - easier to distinguish uids from indices of elements/models.
-enum { MIN_LISTMODEL_UID = 1024 };
-
-static QAtomicInt uidCounter(MIN_LISTMODEL_UID);
-
-template <typename T>
-static bool isMemoryUsed(const char *mem)
-{
- for (size_t i=0 ; i < sizeof(T) ; ++i) {
- if (mem[i] != 0)
- return true;
- }
-
- return false;
-}
-
-static QString roleTypeName(ListLayout::Role::DataType t)
-{
- QString result;
- const char *roleTypeNames[] = { "String", "Number", "Bool", "List", "QObject", "VariantMap" };
-
- if (t > ListLayout::Role::Invalid && t < ListLayout::Role::MaxDataType)
- result = QString::fromLatin1(roleTypeNames[t]);
-
- return result;
-}
-
-const ListLayout::Role &ListLayout::getRoleOrCreate(const QString &key, Role::DataType type)
-{
- QStringHash<Role *>::Node *node = roleHash.findNode(key);
- if (node) {
- const Role &r = *node->value;
- if (type != r.type)
- qmlInfo(0) << QString::fromLatin1("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type));
- return r;
- }
-
- return createRole(key, type);
-}
-
-const ListLayout::Role &ListLayout::getRoleOrCreate(v8::Handle<v8::String> key, Role::DataType type)
-{
- QHashedV8String hashedKey(key);
- QStringHash<Role *>::Node *node = roleHash.findNode(hashedKey);
- if (node) {
- const Role &r = *node->value;
- if (type != r.type)
- qmlInfo(0) << QString::fromLatin1("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type));
- return r;
- }
-
- QString qkey;
- qkey.resize(key->Length());
- key->Write(reinterpret_cast<uint16_t*>(qkey.data()));
-
- return createRole(qkey, type);
-}
-
-const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::Role::DataType type)
-{
- const int dataSizes[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QDeclarativeGuard<QObject>), sizeof(QVariantMap) };
- const int dataAlignments[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QObject *), sizeof(QVariantMap) };
-
- Role *r = new Role;
- r->name = key;
- r->type = type;
-
- if (type == Role::List) {
- r->subLayout = new ListLayout;
- } else {
- r->subLayout = 0;
- }
-
- int dataSize = dataSizes[type];
- int dataAlignment = dataAlignments[type];
-
- int dataOffset = (currentBlockOffset + dataAlignment-1) & ~(dataAlignment-1);
- if (dataOffset + dataSize > ListElement::BLOCK_SIZE) {
- r->blockIndex = ++currentBlock;
- r->blockOffset = 0;
- currentBlockOffset = dataSize;
- } else {
- r->blockIndex = currentBlock;
- r->blockOffset = dataOffset;
- currentBlockOffset = dataOffset + dataSize;
- }
-
- int roleIndex = roles.count();
- r->index = roleIndex;
-
- roles.append(r);
- roleHash.insert(key, r);
-
- return *r;
-}
-
-ListLayout::ListLayout(const ListLayout *other) : currentBlock(0), currentBlockOffset(0)
-{
- for (int i=0 ; i < other->roles.count() ; ++i) {
- Role *role = new Role(other->roles[i]);
- roles.append(role);
- roleHash.insert(role->name, role);
- }
- currentBlockOffset = other->currentBlockOffset;
- currentBlock = other->currentBlock;
-}
-
-ListLayout::~ListLayout()
-{
- for (int i=0 ; i < roles.count() ; ++i) {
- delete roles[i];
- }
-}
-
-void ListLayout::sync(ListLayout *src, ListLayout *target)
-{
- int roleOffset = target->roles.count();
- int newRoleCount = src->roles.count() - roleOffset;
-
- for (int i=0 ; i < newRoleCount ; ++i) {
- Role *role = new Role(src->roles[roleOffset + i]);
- target->roles.append(role);
- target->roleHash.insert(role->name, role);
- }
-
- target->currentBlockOffset = src->currentBlockOffset;
- target->currentBlock = src->currentBlock;
-}
-
-ListLayout::Role::Role(const Role *other)
-{
- name = other->name;
- type = other->type;
- blockIndex = other->blockIndex;
- blockOffset = other->blockOffset;
- index = other->index;
- if (other->subLayout)
- subLayout = new ListLayout(other->subLayout);
- else
- subLayout = 0;
-}
-
-ListLayout::Role::~Role()
-{
- delete subLayout;
-}
-
-const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QVariant &data)
-{
- Role::DataType type;
-
- switch (data.type()) {
- case QVariant::Double: type = Role::Number; break;
- case QVariant::Int: type = Role::Number; break;
- case QVariant::UserType: type = Role::List; break;
- case QVariant::Bool: type = Role::Bool; break;
- case QVariant::String: type = Role::String; break;
- case QVariant::Map: type = Role::VariantMap; break;
- default: type = Role::Invalid; break;
- }
-
- if (type == Role::Invalid) {
- qmlInfo(0) << "Can't create role for unsupported data type";
- return 0;
- }
-
- return &getRoleOrCreate(key, type);
-}
-
-const ListLayout::Role *ListLayout::getExistingRole(const QString &key)
-{
- Role *r = 0;
- QStringHash<Role *>::Node *node = roleHash.findNode(key);
- if (node)
- r = node->value;
- return r;
-}
-
-const ListLayout::Role *ListLayout::getExistingRole(v8::Handle<v8::String> key)
-{
- Role *r = 0;
- QHashedV8String hashedKey(key);
- QStringHash<Role *>::Node *node = roleHash.findNode(hashedKey);
- if (node)
- r = node->value;
- return r;
-}
-
-ModelObject *ListModel::getOrCreateModelObject(QDeclarativeListModel *model, int elementIndex)
-{
- ListElement *e = elements[elementIndex];
- if (e->m_objectCache == 0) {
- e->m_objectCache = new ModelObject(model, elementIndex);
- }
- return e->m_objectCache;
-}
-
-void ListModel::sync(ListModel *src, ListModel *target, QHash<int, ListModel *> *targetModelHash)
-{
- // Sanity check
- target->m_uid = src->m_uid;
- if (targetModelHash)
- targetModelHash->insert(target->m_uid, target);
-
- // Build hash of elements <-> uid for each of the lists
- QHash<int, ElementSync> elementHash;
- for (int i=0 ; i < target->elements.count() ; ++i) {
- ListElement *e = target->elements.at(i);
- int uid = e->getUid();
- ElementSync sync;
- sync.target = e;
- elementHash.insert(uid, sync);
- }
- for (int i=0 ; i < src->elements.count() ; ++i) {
- ListElement *e = src->elements.at(i);
- int uid = e->getUid();
-
- QHash<int, ElementSync>::iterator it = elementHash.find(uid);
- if (it == elementHash.end()) {
- ElementSync sync;
- sync.src = e;
- elementHash.insert(uid, sync);
- } else {
- ElementSync &sync = it.value();
- sync.src = e;
- }
- }
-
- // Get list of elements that are in the target but no longer in the source. These get deleted first.
- QHash<int, ElementSync>::iterator it = elementHash.begin();
- QHash<int, ElementSync>::iterator end = elementHash.end();
- while (it != end) {
- const ElementSync &s = it.value();
- if (s.src == 0) {
- s.target->destroy(target->m_layout);
- target->elements.removeOne(s.target);
- delete s.target;
- }
- ++it;
- }
-
- // Sync the layouts
- ListLayout::sync(src->m_layout, target->m_layout);
-
- // Clear the target list, and append in correct order from the source
- target->elements.clear();
- for (int i=0 ; i < src->elements.count() ; ++i) {
- ListElement *srcElement = src->elements.at(i);
- it = elementHash.find(srcElement->getUid());
- const ElementSync &s = it.value();
- ListElement *targetElement = s.target;
- if (targetElement == 0) {
- targetElement = new ListElement(srcElement->getUid());
- }
- ListElement::sync(srcElement, src->m_layout, targetElement, target->m_layout, targetModelHash);
- target->elements.append(targetElement);
- }
-
- target->updateCacheIndices();
-
- // Update values stored in target meta objects
- for (int i=0 ; i < target->elements.count() ; ++i) {
- ListElement *e = target->elements[i];
- if (e->m_objectCache)
- e->m_objectCache->updateValues();
- }
-}
-
-ListModel::ListModel(ListLayout *layout, QDeclarativeListModel *modelCache, int uid) : m_layout(layout), m_modelCache(modelCache)
-{
- if (uid == -1)
- uid = uidCounter.fetchAndAddOrdered(1);
- m_uid = uid;
-}
-
-void ListModel::destroy()
-{
- clear();
- m_uid = -1;
- m_layout = 0;
- if (m_modelCache && m_modelCache->m_primary == false)
- delete m_modelCache;
- m_modelCache = 0;
-}
-
-int ListModel::appendElement()
-{
- int elementIndex = elements.count();
- newElement(elementIndex);
- return elementIndex;
-}
-
-void ListModel::insertElement(int index)
-{
- newElement(index);
- updateCacheIndices();
-}
-
-void ListModel::move(int from, int to, int n)
-{
- if (from > to) {
- // Only move forwards - flip if backwards moving
- int tfrom = from;
- int tto = to;
- from = tto;
- to = tto+n;
- n = tfrom-tto;
- }
-
- QPODVector<ListElement *, 4> store;
- for (int i=0 ; i < (to-from) ; ++i)
- store.append(elements[from+n+i]);
- for (int i=0 ; i < n ; ++i)
- store.append(elements[from+i]);
- for (int i=0 ; i < store.count() ; ++i)
- elements[from+i] = store[i];
-
- updateCacheIndices();
-}
-
-void ListModel::newElement(int index)
-{
- ListElement *e = new ListElement;
- elements.insert(index, e);
-}
-
-void ListModel::updateCacheIndices()
-{
- for (int i=0 ; i < elements.count() ; ++i) {
- ListElement *e = elements.at(i);
- if (e->m_objectCache) {
- e->m_objectCache->m_elementIndex = i;
- }
- }
-}
-
-QVariant ListModel::getProperty(int elementIndex, int roleIndex, const QDeclarativeListModel *owner, QV8Engine *eng)
-{
- ListElement *e = elements[elementIndex];
- const ListLayout::Role &r = m_layout->getExistingRole(roleIndex);
- return e->getProperty(r, owner, eng);
-}
-
-ListModel *ListModel::getListProperty(int elementIndex, const ListLayout::Role &role)
-{
- ListElement *e = elements[elementIndex];
- return e->getListProperty(role);
-}
-
-void ListModel::set(int elementIndex, v8::Handle<v8::Object> object, QList<int> *roles, QV8Engine *eng)
-{
- ListElement *e = elements[elementIndex];
-
- v8::Local<v8::Array> propertyNames = object->GetPropertyNames();
- int propertyCount = propertyNames->Length();
-
- for (int i=0 ; i < propertyCount ; ++i) {
- v8::Local<v8::String> propertyName = propertyNames->Get(i)->ToString();
- v8::Local<v8::Value> propertyValue = object->Get(propertyName);
-
- // Check if this key exists yet
- int roleIndex = -1;
-
- // Add the value now
- if (propertyValue->IsString()) {
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String);
- v8::Handle<v8::String> jsString = propertyValue->ToString();
- QString qstr;
- qstr.resize(jsString->Length());
- jsString->Write(reinterpret_cast<uint16_t*>(qstr.data()));
- roleIndex = e->setStringProperty(r, qstr);
- } else if (propertyValue->IsNumber()) {
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number);
- roleIndex = e->setDoubleProperty(r, propertyValue->NumberValue());
- } else if (propertyValue->IsArray()) {
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List);
- ListModel *subModel = new ListModel(r.subLayout, 0, -1);
-
- v8::Handle<v8::Array> subArray = v8::Handle<v8::Array>::Cast(propertyValue);
- int arrayLength = subArray->Length();
- for (int j=0 ; j < arrayLength ; ++j) {
- v8::Handle<v8::Object> subObject = subArray->Get(j)->ToObject();
- subModel->append(subObject, eng);
- }
-
- roleIndex = e->setListProperty(r, subModel);
- } else if (propertyValue->IsBoolean()) {
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool);
- roleIndex = e->setBoolProperty(r, propertyValue->BooleanValue());
- } else if (propertyValue->IsObject()) {
- QV8ObjectResource *r = (QV8ObjectResource *) propertyValue->ToObject()->GetExternalResource();
- if (r && r->resourceType() == QV8ObjectResource::QObjectType) {
- QObject *o = QV8QObjectWrapper::toQObject(r);
- const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);
- if (role.type == ListLayout::Role::QObject)
- roleIndex = e->setQObjectProperty(role, o);
- } else {
- const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::VariantMap);
- if (role.type == ListLayout::Role::VariantMap)
- roleIndex = e->setVariantMapProperty(role, propertyValue->ToObject(), eng);
- }
- } else if (propertyValue.IsEmpty() || propertyValue->IsUndefined() || propertyValue->IsNull()) {
- const ListLayout::Role *r = m_layout->getExistingRole(propertyName);
- if (r)
- e->clearProperty(*r);
- }
-
- if (roleIndex != -1)
- roles->append(roleIndex);
- }
-
- if (e->m_objectCache) {
- e->m_objectCache->updateValues(*roles);
- }
-}
-
-void ListModel::set(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng)
-{
- ListElement *e = elements[elementIndex];
-
- v8::Local<v8::Array> propertyNames = object->GetPropertyNames();
- int propertyCount = propertyNames->Length();
-
- for (int i=0 ; i < propertyCount ; ++i) {
- v8::Local<v8::String> propertyName = propertyNames->Get(i)->ToString();
- v8::Local<v8::Value> propertyValue = object->Get(propertyName);
-
- // Add the value now
- if (propertyValue->IsString()) {
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String);
- if (r.type == ListLayout::Role::String) {
- v8::Handle<v8::String> jsString = propertyValue->ToString();
- QString qstr;
- qstr.resize(jsString->Length());
- jsString->Write(reinterpret_cast<uint16_t*>(qstr.data()));
- e->setStringPropertyFast(r, qstr);
- }
- } else if (propertyValue->IsNumber()) {
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number);
- if (r.type == ListLayout::Role::Number) {
- e->setDoublePropertyFast(r, propertyValue->NumberValue());
- }
- } else if (propertyValue->IsArray()) {
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List);
- if (r.type == ListLayout::Role::List) {
- ListModel *subModel = new ListModel(r.subLayout, 0, -1);
-
- v8::Handle<v8::Array> subArray = v8::Handle<v8::Array>::Cast(propertyValue);
- int arrayLength = subArray->Length();
- for (int j=0 ; j < arrayLength ; ++j) {
- v8::Handle<v8::Object> subObject = subArray->Get(j)->ToObject();
- subModel->append(subObject, eng);
- }
-
- e->setListPropertyFast(r, subModel);
- }
- } else if (propertyValue->IsBoolean()) {
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool);
- if (r.type == ListLayout::Role::Bool) {
- e->setBoolPropertyFast(r, propertyValue->BooleanValue());
- }
- } else if (propertyValue->IsObject()) {
- QV8ObjectResource *r = (QV8ObjectResource *) propertyValue->ToObject()->GetExternalResource();
- if (r && r->resourceType() == QV8ObjectResource::QObjectType) {
- QObject *o = QV8QObjectWrapper::toQObject(r);
- const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);
- if (r.type == ListLayout::Role::QObject)
- e->setQObjectPropertyFast(r, o);
- } else {
- const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::VariantMap);
- if (role.type == ListLayout::Role::VariantMap)
- e->setVariantMapFast(role, propertyValue->ToObject(), eng);
- }
- } else if (propertyValue.IsEmpty() || propertyValue->IsUndefined() || propertyValue->IsNull()) {
- const ListLayout::Role *r = m_layout->getExistingRole(propertyName);
- if (r)
- e->clearProperty(*r);
- }
- }
-}
-
-void ListModel::clear()
-{
- int elementCount = elements.count();
- for (int i=0 ; i < elementCount ; ++i) {
- elements[i]->destroy(m_layout);
- delete elements[i];
- }
- elements.clear();
-}
-
-void ListModel::remove(int index, int count)
-{
- for (int i=0 ; i < count ; ++i) {
- elements[index+i]->destroy(m_layout);
- delete elements[index+i];
- }
- elements.remove(index, count);
- updateCacheIndices();
-}
-
-void ListModel::insert(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng)
-{
- insertElement(elementIndex);
- set(elementIndex, object, eng);
-}
-
-int ListModel::append(v8::Handle<v8::Object> object, QV8Engine *eng)
-{
- int elementIndex = appendElement();
- set(elementIndex, object, eng);
- return elementIndex;
-}
-
-int ListModel::setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data)
-{
- int roleIndex = -1;
-
- if (elementIndex >= 0 && elementIndex < elements.count()) {
- ListElement *e = elements[elementIndex];
-
- const ListLayout::Role *r = m_layout->getRoleOrCreate(key, data);
- if (r) {
- roleIndex = e->setVariantProperty(*r, data);
-
- if (roleIndex != -1 && e->m_objectCache) {
- QList<int> roles;
- roles << roleIndex;
- e->m_objectCache->updateValues(roles);
- }
- }
- }
-
- return roleIndex;
-}
-
-int ListModel::setExistingProperty(int elementIndex, const QString &key, v8::Handle<v8::Value> data, QV8Engine *eng)
-{
- int roleIndex = -1;
-
- if (elementIndex >= 0 && elementIndex < elements.count()) {
- ListElement *e = elements[elementIndex];
- const ListLayout::Role *r = m_layout->getExistingRole(key);
- if (r)
- roleIndex = e->setJsProperty(*r, data, eng);
- }
-
- return roleIndex;
-}
-
-inline char *ListElement::getPropertyMemory(const ListLayout::Role &role)
-{
- ListElement *e = this;
- int blockIndex = 0;
- while (blockIndex < role.blockIndex) {
- if (e->next == 0) {
- e->next = new ListElement;
- e->next->uid = uid;
- }
- e = e->next;
- ++blockIndex;
- }
-
- char *mem = &e->data[role.blockOffset];
- return mem;
-}
-
-QString *ListElement::getStringProperty(const ListLayout::Role &role)
-{
- char *mem = getPropertyMemory(role);
- QString *s = reinterpret_cast<QString *>(mem);
- return s->data_ptr() ? s : 0;
-}
-
-QObject *ListElement::getQObjectProperty(const ListLayout::Role &role)
-{
- char *mem = getPropertyMemory(role);
- QDeclarativeGuard<QObject> *o = reinterpret_cast<QDeclarativeGuard<QObject> *>(mem);
- return o->data();
-}
-
-QVariantMap *ListElement::getVariantMapProperty(const ListLayout::Role &role)
-{
- QVariantMap *map = 0;
-
- char *mem = getPropertyMemory(role);
- if (isMemoryUsed<QVariantMap>(mem))
- map = reinterpret_cast<QVariantMap *>(mem);
-
- return map;
-}
-
-QDeclarativeGuard<QObject> *ListElement::getGuardProperty(const ListLayout::Role &role)
-{
- char *mem = getPropertyMemory(role);
-
- bool existingGuard = false;
- for (size_t i=0 ; i < sizeof(QDeclarativeGuard<QObject>) ; ++i) {
- if (mem[i] != 0) {
- existingGuard = true;
- break;
- }
- }
-
- QDeclarativeGuard<QObject> *o = 0;
-
- if (existingGuard)
- o = reinterpret_cast<QDeclarativeGuard<QObject> *>(mem);
-
- return o;
-}
-
-ListModel *ListElement::getListProperty(const ListLayout::Role &role)
-{
- char *mem = getPropertyMemory(role);
- ListModel **value = reinterpret_cast<ListModel **>(mem);
- return *value;
-}
-
-QVariant ListElement::getProperty(const ListLayout::Role &role, const QDeclarativeListModel *owner, QV8Engine *eng)
-{
- char *mem = getPropertyMemory(role);
-
- QVariant data;
-
- switch (role.type) {
- case ListLayout::Role::Number:
- {
- double *value = reinterpret_cast<double *>(mem);
- data = *value;
- }
- break;
- case ListLayout::Role::String:
- {
- QString *value = reinterpret_cast<QString *>(mem);
- if (value->data_ptr() != 0)
- data = *value;
- }
- break;
- case ListLayout::Role::Bool:
- {
- bool *value = reinterpret_cast<bool *>(mem);
- data = *value;
- }
- break;
- case ListLayout::Role::List:
- {
- ListModel **value = reinterpret_cast<ListModel **>(mem);
- ListModel *model = *value;
-
- if (model) {
- if (model->m_modelCache == 0) {
- model->m_modelCache = new QDeclarativeListModel(owner, model, eng);
- QDeclarativeEngine::setContextForObject(model->m_modelCache, QDeclarativeEngine::contextForObject(owner));
- }
-
- QObject *object = model->m_modelCache;
- data = QVariant::fromValue(object);
- }
- }
- break;
- case ListLayout::Role::QObject:
- {
- QDeclarativeGuard<QObject> *guard = reinterpret_cast<QDeclarativeGuard<QObject> *>(mem);
- QObject *object = guard->data();
- if (object)
- data = QVariant::fromValue(object);
- }
- break;
- case ListLayout::Role::VariantMap:
- {
- if (isMemoryUsed<QVariantMap>(mem)) {
- QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);
- data = *map;
- }
- }
- break;
- default:
- break;
- }
-
- return data;
-}
-
-int ListElement::setStringProperty(const ListLayout::Role &role, const QString &s)
-{
- int roleIndex = -1;
-
- if (role.type == ListLayout::Role::String) {
- char *mem = getPropertyMemory(role);
- QString *c = reinterpret_cast<QString *>(mem);
- bool changed;
- if (c->data_ptr() == 0) {
- new (mem) QString(s);
- changed = true;
- } else {
- changed = c->compare(s) != 0;
- *c = s;
- }
- if (changed)
- roleIndex = role.index;
- }
-
- return roleIndex;
-}
-
-int ListElement::setDoubleProperty(const ListLayout::Role &role, double d)
-{
- int roleIndex = -1;
-
- if (role.type == ListLayout::Role::Number) {
- char *mem = getPropertyMemory(role);
- double *value = new (mem) double;
- bool changed = *value != d;
- *value = d;
- if (changed)
- roleIndex = role.index;
- }
-
- return roleIndex;
-}
-
-int ListElement::setBoolProperty(const ListLayout::Role &role, bool b)
-{
- int roleIndex = -1;
-
- if (role.type == ListLayout::Role::Bool) {
- char *mem = getPropertyMemory(role);
- bool *value = new (mem) bool;
- bool changed = *value != b;
- *value = b;
- if (changed)
- roleIndex = role.index;
- }
-
- return roleIndex;
-}
-
-int ListElement::setListProperty(const ListLayout::Role &role, ListModel *m)
-{
- int roleIndex = -1;
-
- if (role.type == ListLayout::Role::List) {
- char *mem = getPropertyMemory(role);
- ListModel **value = new (mem) ListModel *;
- if (*value) {
- (*value)->destroy();
- delete *value;
- }
- *value = m;
- roleIndex = role.index;
- }
-
- return roleIndex;
-}
-
-int ListElement::setQObjectProperty(const ListLayout::Role &role, QObject *o)
-{
- int roleIndex = -1;
-
- if (role.type == ListLayout::Role::QObject) {
- char *mem = getPropertyMemory(role);
- QDeclarativeGuard<QObject> *g = reinterpret_cast<QDeclarativeGuard<QObject> *>(mem);
- bool existingGuard = false;
- for (size_t i=0 ; i < sizeof(QDeclarativeGuard<QObject>) ; ++i) {
- if (mem[i] != 0) {
- existingGuard = true;
- break;
- }
- }
- bool changed;
- if (existingGuard) {
- changed = g->data() != o;
- g->~QDeclarativeGuard();
- } else {
- changed = true;
- }
- new (mem) QDeclarativeGuard<QObject>(o);
- if (changed)
- roleIndex = role.index;
- }
-
- return roleIndex;
-}
-
-int ListElement::setVariantMapProperty(const ListLayout::Role &role, v8::Handle<v8::Object> o, QV8Engine *eng)
-{
- int roleIndex = -1;
-
- if (role.type == ListLayout::Role::VariantMap) {
- char *mem = getPropertyMemory(role);
- if (isMemoryUsed<QVariantMap>(mem)) {
- QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);
- map->~QMap();
- }
- new (mem) QVariantMap(eng->variantMapFromJS(o));
- roleIndex = role.index;
- }
-
- return roleIndex;
-}
-
-int ListElement::setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m)
-{
- int roleIndex = -1;
-
- if (role.type == ListLayout::Role::VariantMap) {
- char *mem = getPropertyMemory(role);
- if (isMemoryUsed<QVariantMap>(mem)) {
- QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);
- map->~QMap();
- }
- if (m)
- new (mem) QVariantMap(*m);
- else
- new (mem) QVariantMap;
- roleIndex = role.index;
- }
-
- return roleIndex;
-}
-
-void ListElement::setStringPropertyFast(const ListLayout::Role &role, const QString &s)
-{
- char *mem = getPropertyMemory(role);
- new (mem) QString(s);
-}
-
-void ListElement::setDoublePropertyFast(const ListLayout::Role &role, double d)
-{
- char *mem = getPropertyMemory(role);
- double *value = new (mem) double;
- *value = d;
-}
-
-void ListElement::setBoolPropertyFast(const ListLayout::Role &role, bool b)
-{
- char *mem = getPropertyMemory(role);
- bool *value = new (mem) bool;
- *value = b;
-}
-
-void ListElement::setQObjectPropertyFast(const ListLayout::Role &role, QObject *o)
-{
- char *mem = getPropertyMemory(role);
- new (mem) QDeclarativeGuard<QObject>(o);
-}
-
-void ListElement::setListPropertyFast(const ListLayout::Role &role, ListModel *m)
-{
- char *mem = getPropertyMemory(role);
- ListModel **value = new (mem) ListModel *;
- *value = m;
-}
-
-void ListElement::setVariantMapFast(const ListLayout::Role &role, v8::Handle<v8::Object> o, QV8Engine *eng)
-{
- char *mem = getPropertyMemory(role);
- QVariantMap *map = new (mem) QVariantMap;
- *map = eng->variantMapFromJS(o);
-}
-
-void ListElement::clearProperty(const ListLayout::Role &role)
-{
- switch (role.type) {
- case ListLayout::Role::String:
- setStringProperty(role, QString());
- break;
- case ListLayout::Role::Number:
- setDoubleProperty(role, 0.0);
- break;
- case ListLayout::Role::Bool:
- setBoolProperty(role, false);
- break;
- case ListLayout::Role::List:
- setListProperty(role, 0);
- break;
- case ListLayout::Role::QObject:
- setQObjectProperty(role, 0);
- break;
- case ListLayout::Role::VariantMap:
- setVariantMapProperty(role, 0);
- break;
- default:
- break;
- }
-}
-
-ListElement::ListElement()
-{
- m_objectCache = 0;
- uid = uidCounter.fetchAndAddOrdered(1);
- next = 0;
- qMemSet(data, 0, sizeof(data));
-}
-
-ListElement::ListElement(int existingUid)
-{
- m_objectCache = 0;
- uid = existingUid;
- next = 0;
- qMemSet(data, 0, sizeof(data));
-}
-
-ListElement::~ListElement()
-{
- delete next;
-}
-
-void ListElement::sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout, QHash<int, ListModel *> *targetModelHash)
-{
- for (int i=0 ; i < srcLayout->roleCount() ; ++i) {
- const ListLayout::Role &srcRole = srcLayout->getExistingRole(i);
- const ListLayout::Role &targetRole = targetLayout->getExistingRole(i);
-
- switch (srcRole.type) {
- case ListLayout::Role::List:
- {
- ListModel *srcSubModel = src->getListProperty(srcRole);
- ListModel *targetSubModel = target->getListProperty(targetRole);
-
- if (srcSubModel) {
- if (targetSubModel == 0) {
- targetSubModel = new ListModel(targetRole.subLayout, 0, srcSubModel->getUid());
- target->setListPropertyFast(targetRole, targetSubModel);
- }
- ListModel::sync(srcSubModel, targetSubModel, targetModelHash);
- }
- }
- break;
- case ListLayout::Role::QObject:
- {
- QObject *object = src->getQObjectProperty(srcRole);
- target->setQObjectProperty(targetRole, object);
- }
- break;
- case ListLayout::Role::String:
- case ListLayout::Role::Number:
- case ListLayout::Role::Bool:
- {
- QVariant v = src->getProperty(srcRole, 0, 0);
- target->setVariantProperty(targetRole, v);
- }
- case ListLayout::Role::VariantMap:
- {
- QVariantMap *map = src->getVariantMapProperty(srcRole);
- target->setVariantMapProperty(targetRole, map);
- }
- break;
- default:
- break;
- }
- }
-
-}
-
-void ListElement::destroy(ListLayout *layout)
-{
- if (layout) {
- for (int i=0 ; i < layout->roleCount() ; ++i) {
- const ListLayout::Role &r = layout->getExistingRole(i);
-
- switch (r.type) {
- case ListLayout::Role::String:
- {
- QString *string = getStringProperty(r);
- if (string)
- string->~QString();
- }
- break;
- case ListLayout::Role::List:
- {
- ListModel *model = getListProperty(r);
- if (model) {
- model->destroy();
- delete model;
- }
- }
- break;
- case ListLayout::Role::QObject:
- {
- QDeclarativeGuard<QObject> *guard = getGuardProperty(r);
- if (guard)
- guard->~QDeclarativeGuard();
- }
- break;
- case ListLayout::Role::VariantMap:
- {
- QVariantMap *map = getVariantMapProperty(r);
- if (map)
- map->~QMap();
- }
- break;
- default:
- // other types don't need explicit cleanup.
- break;
- }
- }
-
- delete m_objectCache;
- }
-
- if (next)
- next->destroy(0);
- uid = -1;
-}
-
-int ListElement::setVariantProperty(const ListLayout::Role &role, const QVariant &d)
-{
- int roleIndex = -1;
-
- switch (role.type) {
- case ListLayout::Role::Number:
- roleIndex = setDoubleProperty(role, d.toDouble());
- break;
- case ListLayout::Role::String:
- roleIndex = setStringProperty(role, d.toString());
- break;
- case ListLayout::Role::Bool:
- roleIndex = setBoolProperty(role, d.toBool());
- break;
- case ListLayout::Role::List:
- roleIndex = setListProperty(role, d.value<ListModel *>());
- break;
- case ListLayout::Role::VariantMap: {
- QVariantMap map = d.toMap();
- roleIndex = setVariantMapProperty(role, &map);
- }
- break;
- default:
- break;
- }
-
- return roleIndex;
-}
-
-int ListElement::setJsProperty(const ListLayout::Role &role, v8::Handle<v8::Value> d, QV8Engine *eng)
-{
- // Check if this key exists yet
- int roleIndex = -1;
-
- // Add the value now
- if (d->IsString()) {
- v8::Handle<v8::String> jsString = d->ToString();
- QString qstr;
- qstr.resize(jsString->Length());
- jsString->Write(reinterpret_cast<uint16_t*>(qstr.data()));
- roleIndex = setStringProperty(role, qstr);
- } else if (d->IsNumber()) {
- roleIndex = setDoubleProperty(role, d->NumberValue());
- } else if (d->IsArray()) {
- ListModel *subModel = new ListModel(role.subLayout, 0, -1);
- v8::Handle<v8::Array> subArray = v8::Handle<v8::Array>::Cast(d);
- int arrayLength = subArray->Length();
- for (int j=0 ; j < arrayLength ; ++j) {
- v8::Handle<v8::Object> subObject = subArray->Get(j)->ToObject();
- subModel->append(subObject, eng);
- }
- roleIndex = setListProperty(role, subModel);
- } else if (d->IsBoolean()) {
- roleIndex = setBoolProperty(role, d->BooleanValue());
- } else if (d->IsObject()) {
- QV8ObjectResource *r = (QV8ObjectResource *) d->ToObject()->GetExternalResource();
- if (role.type == ListLayout::Role::QObject && r && r->resourceType() == QV8ObjectResource::QObjectType) {
- QObject *o = QV8QObjectWrapper::toQObject(r);
- roleIndex = setQObjectProperty(role, o);
- } else if (role.type == ListLayout::Role::VariantMap) {
- roleIndex = setVariantMapProperty(role, d->ToObject(), eng);
- }
- } else if (d.IsEmpty() || d->IsUndefined() || d->IsNull()) {
- clearProperty(role);
- }
-
- return roleIndex;
-}
-
-ModelObject::ModelObject(QDeclarativeListModel *model, int elementIndex)
-: m_model(model), m_elementIndex(elementIndex), m_meta(new ModelNodeMetaObject(this))
-{
- updateValues();
- setNodeUpdatesEnabled(true);
-}
-
-void ModelObject::updateValues()
-{
- int roleCount = m_model->m_listModel->roleCount();
- for (int i=0 ; i < roleCount ; ++i) {
- const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i);
- QByteArray name = role.name.toUtf8();
- const QVariant &data = m_model->data(m_elementIndex, i);
- setValue(name, data, role.type == ListLayout::Role::List);
- }
-}
-
-void ModelObject::updateValues(const QList<int> &roles)
-{
- int roleCount = roles.count();
- for (int i=0 ; i < roleCount ; ++i) {
- int roleIndex = roles.at(i);
- const ListLayout::Role &role = m_model->m_listModel->getExistingRole(roleIndex);
- QByteArray name = role.name.toUtf8();
- const QVariant &data = m_model->data(m_elementIndex, roleIndex);
- setValue(name, data, role.type == ListLayout::Role::List);
- }
-}
-
-ModelNodeMetaObject::ModelNodeMetaObject(ModelObject *object)
-: QDeclarativeOpenMetaObject(object), m_enabled(false), m_obj(object)
-{
-}
-
-ModelNodeMetaObject::~ModelNodeMetaObject()
-{
-}
-
-void ModelNodeMetaObject::propertyWritten(int index)
-{
- if (!m_enabled)
- return;
-
- QV8Engine *eng = m_obj->m_model->engine();
-
- QString propName = QString::fromUtf8(name(index));
- QVariant value = operator[](index);
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(eng->context());
-
- v8::Handle<v8::Value> v = eng->fromVariant(value);
-
- int roleIndex = m_obj->m_model->m_listModel->setExistingProperty(m_obj->m_elementIndex, propName, v, eng);
- if (roleIndex != -1) {
- QList<int> roles;
- roles << roleIndex;
- m_obj->m_model->emitItemsChanged(m_obj->m_elementIndex, 1, roles);
- }
-}
-
-DynamicRoleModelNode::DynamicRoleModelNode(QDeclarativeListModel *owner, int uid) : m_owner(owner), m_uid(uid), m_meta(new DynamicRoleModelNodeMetaObject(this))
-{
- setNodeUpdatesEnabled(true);
-}
-
-DynamicRoleModelNode *DynamicRoleModelNode::create(const QVariantMap &obj, QDeclarativeListModel *owner)
-{
- DynamicRoleModelNode *object = new DynamicRoleModelNode(owner, uidCounter.fetchAndAddOrdered(1));
- QList<int> roles;
- object->updateValues(obj, roles);
- return object;
-}
-
-void DynamicRoleModelNode::sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target, QHash<int, QDeclarativeListModel *> *targetModelHash)
-{
- for (int i=0 ; i < src->m_meta->count() ; ++i) {
- const QByteArray &name = src->m_meta->name(i);
- QVariant value = src->m_meta->value(i);
-
- QDeclarativeListModel *srcModel = qobject_cast<QDeclarativeListModel *>(value.value<QObject *>());
- QDeclarativeListModel *targetModel = qobject_cast<QDeclarativeListModel *>(target->m_meta->value(i).value<QObject *>());
-
- if (srcModel) {
- if (targetModel == 0)
- targetModel = QDeclarativeListModel::createWithOwner(target->m_owner);
-
- QDeclarativeListModel::sync(srcModel, targetModel, targetModelHash);
-
- QObject *targetModelObject = targetModel;
- value = QVariant::fromValue(targetModelObject);
- } else if (targetModel) {
- delete targetModel;
- }
-
- target->setValue(name, value);
- }
-}
-
-void DynamicRoleModelNode::updateValues(const QVariantMap &object, QList<int> &roles)
-{
- const QList<QString> &keys = object.keys();
-
- QList<QString>::const_iterator it = keys.begin();
- QList<QString>::const_iterator end = keys.end();
-
- while (it != end) {
- const QString &key = *it;
-
- int roleIndex = m_owner->m_roles.indexOf(key);
- if (roleIndex == -1) {
- roleIndex = m_owner->m_roles.count();
- m_owner->m_roles.append(key);
- }
-
- QVariant value = object[key];
-
- if (value.type() == QVariant::List) {
- QDeclarativeListModel *subModel = QDeclarativeListModel::createWithOwner(m_owner);
-
- QVariantList subArray = value.toList();
- QVariantList::const_iterator subIt = subArray.begin();
- QVariantList::const_iterator subEnd = subArray.end();
- while (subIt != subEnd) {
- const QVariantMap &subObject = subIt->toMap();
- subModel->m_modelObjects.append(DynamicRoleModelNode::create(subObject, subModel));
- ++subIt;
- }
-
- QObject *subModelObject = subModel;
- value = QVariant::fromValue(subModelObject);
- }
-
- const QByteArray &keyUtf8 = key.toUtf8();
-
- QDeclarativeListModel *existingModel = qobject_cast<QDeclarativeListModel *>(m_meta->value(keyUtf8).value<QObject *>());
- if (existingModel)
- delete existingModel;
-
- if (m_meta->setValue(keyUtf8, value))
- roles << roleIndex;
-
- ++it;
- }
-}
-
-DynamicRoleModelNodeMetaObject::DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object)
- : QDeclarativeOpenMetaObject(object), m_enabled(false), m_owner(object)
-{
-}
-
-DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject()
-{
- for (int i=0 ; i < count() ; ++i) {
- QDeclarativeListModel *subModel = qobject_cast<QDeclarativeListModel *>(value(i).value<QObject *>());
- if (subModel)
- delete subModel;
- }
-}
-
-void DynamicRoleModelNodeMetaObject::propertyWrite(int index)
-{
- if (!m_enabled)
- return;
-
- QVariant v = value(index);
- QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel *>(v.value<QObject *>());
- if (model)
- delete model;
-}
-
-void DynamicRoleModelNodeMetaObject::propertyWritten(int index)
-{
- if (!m_enabled)
- return;
-
- QDeclarativeListModel *parentModel = m_owner->m_owner;
-
- QVariant v = value(index);
- if (v.type() == QVariant::List) {
- QDeclarativeListModel *subModel = QDeclarativeListModel::createWithOwner(parentModel);
-
- QVariantList subArray = v.toList();
- QVariantList::const_iterator subIt = subArray.begin();
- QVariantList::const_iterator subEnd = subArray.end();
- while (subIt != subEnd) {
- const QVariantMap &subObject = subIt->toMap();
- subModel->m_modelObjects.append(DynamicRoleModelNode::create(subObject, subModel));
- ++subIt;
- }
-
- QObject *subModelObject = subModel;
- v = QVariant::fromValue(subModelObject);
-
- setValue(index, v);
- }
-
- int elementIndex = parentModel->m_modelObjects.indexOf(m_owner);
- int roleIndex = parentModel->m_roles.indexOf(QString::fromLatin1(name(index).constData()));
-
- if (elementIndex != -1 && roleIndex != -1) {
- QList<int> roles;
- roles << roleIndex;
-
- parentModel->emitItemsChanged(elementIndex, 1, roles);
- }
-}
-
-QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListModelData::instructions() const
-{
- return (QDeclarativeListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData));
-}
-
-/*!
- \qmlclass ListModel QDeclarativeListModel
- \inqmlmodule QtQuick 2
- \ingroup qml-working-with-data
- \brief The ListModel element defines a free-form list data source.
-
- The ListModel is a simple container of ListElement definitions, each containing data roles.
- The contents can be defined dynamically, or explicitly in QML.
-
- The number of elements in the model can be obtained from its \l count property.
- A number of familiar methods are also provided to manipulate the contents of the
- model, including append(), insert(), move(), remove() and set(). These methods
- accept dictionaries as their arguments; these are translated to ListElement objects
- by the model.
-
- Elements can be manipulated via the model using the setProperty() method, which
- allows the roles of the specified element to be set and changed.
-
- \section1 Example Usage
-
- The following example shows a ListModel containing three elements, with the roles
- "name" and "cost".
-
- \div {class="float-right"}
- \inlineimage listmodel.png
- \enddiv
-
- \snippet doc/src/snippets/declarative/listmodel.qml 0
-
- \clearfloat
- Roles (properties) in each element must begin with a lower-case letter and
- should be common to all elements in a model. The ListElement documentation
- provides more guidelines for how elements should be defined.
-
- Since the example model contains an \c id property, it can be referenced
- by views, such as the ListView in this example:
-
- \snippet doc/src/snippets/declarative/listmodel-simple.qml 0
- \dots 8
- \snippet doc/src/snippets/declarative/listmodel-simple.qml 1
-
- It is possible for roles to contain list data. In the following example we
- create a list of fruit attributes:
-
- \snippet doc/src/snippets/declarative/listmodel-nested.qml model
-
- The delegate displays all the fruit attributes:
-
- \div {class="float-right"}
- \inlineimage listmodel-nested.png
- \enddiv
-
- \snippet doc/src/snippets/declarative/listmodel-nested.qml delegate
-
- \clearfloat
- \section1 Modifying List Models
-
- The content of a ListModel may be created and modified using the clear(),
- append(), set(), insert() and setProperty() methods. For example:
-
- \snippet doc/src/snippets/declarative/listmodel-modify.qml delegate
-
- Note that when creating content dynamically the set of available properties
- cannot be changed once set. Whatever properties are first added to the model
- are the only permitted properties in the model.
-
- \section1 Using Threaded List Models with WorkerScript
-
- ListModel can be used together with WorkerScript access a list model
- from multiple threads. This is useful if list modifications are
- synchronous and take some time: the list operations can be moved to a
- different thread to avoid blocking of the main GUI thread.
-
- Here is an example that uses WorkerScript to periodically append the
- current time to a list model:
-
- \snippet examples/declarative/threading/threadedlistmodel/timedisplay.qml 0
-
- The included file, \tt dataloader.js, looks like this:
-
- \snippet examples/declarative/threading/threadedlistmodel/dataloader.js 0
-
- The timer in the main example sends messages to the worker script by calling
- \l WorkerScript::sendMessage(). When this message is received,
- \l{WorkerScript::onMessage}{WorkerScript.onMessage()} is invoked in \c dataloader.js,
- which appends the current time to the list model.
-
- Note the call to sync() from the \l{WorkerScript::onMessage}{WorkerScript.onMessage()}
- handler. You must call sync() or else the changes made to the list from the external
- thread will not be reflected in the list model in the main thread.
-
- \sa {qmlmodels}{Data Models}, {declarative/threading/threadedlistmodel}{Threaded ListModel example}, QtDeclarative
-*/
-
-QDeclarativeListModel::QDeclarativeListModel(QObject *parent)
-: QListModelInterface(parent)
-{
- m_mainThread = true;
- m_primary = true;
- m_agent = 0;
- m_uid = uidCounter.fetchAndAddOrdered(1);
- m_dynamicRoles = false;
-
- m_layout = new ListLayout;
- m_listModel = new ListModel(m_layout, this, -1);
-
- m_engine = 0;
-}
-
-QDeclarativeListModel::QDeclarativeListModel(const QDeclarativeListModel *owner, ListModel *data, QV8Engine *eng, QObject *parent)
-: QListModelInterface(parent)
-{
- m_mainThread = owner->m_mainThread;
- m_primary = false;
- m_agent = owner->m_agent;
-
- Q_ASSERT(owner->m_dynamicRoles == false);
- m_dynamicRoles = false;
- m_layout = 0;
- m_listModel = data;
-
- m_engine = eng;
-}
-
-QDeclarativeListModel::QDeclarativeListModel(QDeclarativeListModel *orig, QDeclarativeListModelWorkerAgent *agent)
-: QListModelInterface(agent)
-{
- m_mainThread = false;
- m_primary = true;
- m_agent = agent;
- m_dynamicRoles = orig->m_dynamicRoles;
-
- m_layout = new ListLayout(orig->m_layout);
- m_listModel = new ListModel(m_layout, this, orig->m_listModel->getUid());
-
- if (m_dynamicRoles)
- sync(orig, this, 0);
- else
- ListModel::sync(orig->m_listModel, m_listModel, 0);
-
- m_engine = 0;
-}
-
-QDeclarativeListModel::~QDeclarativeListModel()
-{
- for (int i=0 ; i < m_modelObjects.count() ; ++i)
- delete m_modelObjects[i];
-
- if (m_primary) {
- m_listModel->destroy();
- delete m_listModel;
-
- if (m_mainThread && m_agent) {
- m_agent->modelDestroyed();
- m_agent->release();
- }
- }
-
- m_listModel = 0;
-
- delete m_layout;
- m_layout = 0;
-}
-
-QDeclarativeListModel *QDeclarativeListModel::createWithOwner(QDeclarativeListModel *newOwner)
-{
- QDeclarativeListModel *model = new QDeclarativeListModel;
-
- model->m_mainThread = newOwner->m_mainThread;
- model->m_engine = newOwner->m_engine;
- model->m_agent = newOwner->m_agent;
- model->m_dynamicRoles = newOwner->m_dynamicRoles;
-
- if (model->m_mainThread && model->m_agent)
- model->m_agent->addref();
-
- QDeclarativeEngine::setContextForObject(model, QDeclarativeEngine::contextForObject(newOwner));
-
- return model;
-}
-
-QV8Engine *QDeclarativeListModel::engine() const
-{
- if (m_engine == 0) {
- m_engine = QDeclarativeEnginePrivate::getV8Engine(qmlEngine(this));
- }
-
- return m_engine;
-}
-
-void QDeclarativeListModel::sync(QDeclarativeListModel *src, QDeclarativeListModel *target, QHash<int, QDeclarativeListModel *> *targetModelHash)
-{
- Q_ASSERT(src->m_dynamicRoles && target->m_dynamicRoles);
-
- target->m_uid = src->m_uid;
- if (targetModelHash)
- targetModelHash->insert(target->m_uid, target);
- target->m_roles = src->m_roles;
-
- // Build hash of elements <-> uid for each of the lists
- QHash<int, ElementSync> elementHash;
- for (int i=0 ; i < target->m_modelObjects.count() ; ++i) {
- DynamicRoleModelNode *e = target->m_modelObjects.at(i);
- int uid = e->getUid();
- ElementSync sync;
- sync.target = e;
- elementHash.insert(uid, sync);
- }
- for (int i=0 ; i < src->m_modelObjects.count() ; ++i) {
- DynamicRoleModelNode *e = src->m_modelObjects.at(i);
- int uid = e->getUid();
-
- QHash<int, ElementSync>::iterator it = elementHash.find(uid);
- if (it == elementHash.end()) {
- ElementSync sync;
- sync.src = e;
- elementHash.insert(uid, sync);
- } else {
- ElementSync &sync = it.value();
- sync.src = e;
- }
- }
-
- // Get list of elements that are in the target but no longer in the source. These get deleted first.
- QHash<int, ElementSync>::iterator it = elementHash.begin();
- QHash<int, ElementSync>::iterator end = elementHash.end();
- while (it != end) {
- const ElementSync &s = it.value();
- if (s.src == 0) {
- int targetIndex = target->m_modelObjects.indexOf(s.target);
- target->m_modelObjects.remove(targetIndex, 1);
- delete s.target;
- }
- ++it;
- }
-
- // Clear the target list, and append in correct order from the source
- target->m_modelObjects.clear();
- for (int i=0 ; i < src->m_modelObjects.count() ; ++i) {
- DynamicRoleModelNode *srcElement = src->m_modelObjects.at(i);
- it = elementHash.find(srcElement->getUid());
- const ElementSync &s = it.value();
- DynamicRoleModelNode *targetElement = s.target;
- if (targetElement == 0) {
- targetElement = new DynamicRoleModelNode(target, srcElement->getUid());
- }
- DynamicRoleModelNode::sync(srcElement, targetElement, targetModelHash);
- target->m_modelObjects.append(targetElement);
- }
-}
-
-void QDeclarativeListModel::emitItemsChanged(int index, int count, const QList<int> &roles)
-{
- if (m_mainThread) {
- emit itemsChanged(index, count, roles);
- } else {
- int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
- m_agent->data.changedChange(uid, index, count, roles);
- }
-}
-
-void QDeclarativeListModel::emitItemsRemoved(int index, int count)
-{
- if (m_mainThread) {
- emit itemsRemoved(index, count);
- emit countChanged();
- } else {
- int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
- if (index == 0 && count == this->count())
- m_agent->data.clearChange(uid);
- m_agent->data.removeChange(uid, index, count);
- }
-}
-
-void QDeclarativeListModel::emitItemsInserted(int index, int count)
-{
- if (m_mainThread) {
- emit itemsInserted(index, count);
- emit countChanged();
- } else {
- int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
- m_agent->data.insertChange(uid, index, count);
- }
-}
-
-void QDeclarativeListModel::emitItemsMoved(int from, int to, int n)
-{
- if (m_mainThread) {
- emit itemsMoved(from, to, n);
- } else {
- int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
- m_agent->data.moveChange(uid, from, n, to);
- }
-}
-
-QDeclarativeListModelWorkerAgent *QDeclarativeListModel::agent()
-{
- if (m_agent)
- return m_agent;
-
- m_agent = new QDeclarativeListModelWorkerAgent(this);
- return m_agent;
-}
-
-QList<int> QDeclarativeListModel::roles() const
-{
- QList<int> rolesArray;
-
- if (m_dynamicRoles) {
- for (int i=0 ; i < m_roles.count() ; ++i)
- rolesArray << i;
- } else {
- for (int i=0 ; i < m_listModel->roleCount() ; ++i)
- rolesArray << i;
- }
-
- return rolesArray;
-}
-
-QString QDeclarativeListModel::toString(int role) const
-{
- QString roleName;
-
- if (m_dynamicRoles) {
- roleName = m_roles[role];
- } else {
- const ListLayout::Role &r = m_listModel->getExistingRole(role);
- roleName = r.name;
- }
-
- return roleName;
-}
-
-QVariant QDeclarativeListModel::data(int index, int role) const
-{
- QVariant v;
-
- if (index >= count() || index < 0)
- return v;
-
- if (m_dynamicRoles)
- v = m_modelObjects[index]->getValue(m_roles[role]);
- else
- v = m_listModel->getProperty(index, role, this, engine());
-
- return v;
-}
-
-/*!
- \qmlproperty bool QtQuick2::ListModel::dynamicRoles
-
- By default, the type of a role is fixed the first time
- the role is used. For example, if you create a role called
- "data" and assign a number to it, you can no longer assign
- a string to the "data" role. However, when the dynamicRoles
- property is enabled, the type of a given role is not fixed
- and can be different between elements.
-
- The dynamicRoles property must be set before any data is
- added to the ListModel, and must be set from the main
- thread.
-
- A ListModel that has data statically defined (via the
- ListElement QML syntax) cannot have the dynamicRoles
- property enabled.
-
- There is a significant performance cost to using a
- ListModel with dynamic roles enabled. The cost varies
- from platform to platform but is typically somewhere
- between 4-6x slower than using static role types.
-
- Due to the performance cost of using dynamic roles,
- they are disabled by default.
-*/
-void QDeclarativeListModel::setDynamicRoles(bool enableDynamicRoles)
-{
- if (m_mainThread && m_agent == 0) {
- if (enableDynamicRoles) {
- if (m_layout->roleCount())
- qmlInfo(this) << tr("unable to enable dynamic roles as this model is not empty!");
- else
- m_dynamicRoles = true;
- } else {
- if (m_roles.count()) {
- qmlInfo(this) << tr("unable to enable static roles as this model is not empty!");
- } else {
- m_dynamicRoles = false;
- }
- }
- } else {
- qmlInfo(this) << tr("dynamic role setting must be made from the main thread, before any worker scripts are created");
- }
-}
-
-/*!
- \qmlproperty int QtQuick2::ListModel::count
- The number of data entries in the model.
-*/
-int QDeclarativeListModel::count() const
-{
- int count;
-
- if (m_dynamicRoles)
- count = m_modelObjects.count();
- else {
- count = m_listModel->elementCount();
- }
-
- return count;
-}
-
-/*!
- \qmlmethod QtQuick2::ListModel::clear()
-
- Deletes all content from the model.
-
- \sa append() remove()
-*/
-void QDeclarativeListModel::clear()
-{
- int cleared = count();
-
- if (m_dynamicRoles) {
- for (int i=0 ; i < m_modelObjects.count() ; ++i)
- delete m_modelObjects[i];
- m_modelObjects.clear();
- } else {
- m_listModel->clear();
- }
-
- emitItemsRemoved(0, cleared);
-}
-
-/*!
- \qmlmethod QtQuick2::ListModel::remove(int index, int count = 1)
-
- Deletes the content at \a index from the model.
-
- \sa clear()
-*/
-void QDeclarativeListModel::remove(QDeclarativeV8Function *args)
-{
- int argLength = args->Length();
-
- if (argLength == 1 || argLength == 2) {
- int index = (*args)[0]->Int32Value();
- int removeCount = (argLength == 2 ? ((*args)[1]->Int32Value()) : 1);
-
- if (index < 0 || index+removeCount > count() || removeCount <= 0) {
- qmlInfo(this) << tr("remove: indices [%1 - %2] out of range [0 - %3]").arg(index).arg(index+removeCount).arg(count());
- return;
- }
-
- if (m_dynamicRoles) {
- for (int i=0 ; i < removeCount ; ++i)
- delete m_modelObjects[index+i];
- m_modelObjects.remove(index, removeCount);
- } else {
- m_listModel->remove(index, removeCount);
- }
-
- emitItemsRemoved(index, removeCount);
- } else {
- qmlInfo(this) << tr("remove: incorrect number of arguments");
- }
-}
-
-/*!
- \qmlmethod QtQuick2::ListModel::insert(int index, jsobject dict)
-
- Adds a new item to the list model at position \a index, with the
- values in \a dict.
-
- \code
- fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
- \endcode
-
- The \a index must be to an existing item in the list, or one past
- the end of the list (equivalent to append).
-
- \sa set() append()
-*/
-
-void QDeclarativeListModel::insert(QDeclarativeV8Function *args)
-{
- if (args->Length() == 2) {
-
- v8::Handle<v8::Value> arg0 = (*args)[0];
- int index = arg0->Int32Value();
-
- if (index < 0 || index > count()) {
- qmlInfo(this) << tr("insert: index %1 out of range").arg(index);
- return;
- }
-
- v8::Handle<v8::Value> arg1 = (*args)[1];
-
- if (arg1->IsArray()) {
- v8::Handle<v8::Array> objectArray = v8::Handle<v8::Array>::Cast(arg1);
- int objectArrayLength = objectArray->Length();
- for (int i=0 ; i < objectArrayLength ; ++i) {
- v8::Handle<v8::Object> argObject = objectArray->Get(i)->ToObject();
-
- if (m_dynamicRoles) {
- m_modelObjects.insert(index+i, DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
- } else {
- m_listModel->insert(index+i, argObject, args->engine());
- }
- }
- emitItemsInserted(index, objectArrayLength);
- } else if (arg1->IsObject()) {
- v8::Handle<v8::Object> argObject = arg1->ToObject();
-
- if (m_dynamicRoles) {
- m_modelObjects.insert(index, DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
- } else {
- m_listModel->insert(index, argObject, args->engine());
- }
-
- emitItemsInserted(index, 1);
- } else {
- qmlInfo(this) << tr("insert: value is not an object");
- }
- } else {
- qmlInfo(this) << tr("insert: value is not an object");
- }
-}
-
-/*!
- \qmlmethod QtQuick2::ListModel::move(int from, int to, int n)
-
- Moves \a n items \a from one position \a to another.
-
- The from and to ranges must exist; for example, to move the first 3 items
- to the end of the list:
-
- \code
- fruitModel.move(0, fruitModel.count - 3, 3)
- \endcode
-
- \sa append()
-*/
-void QDeclarativeListModel::move(int from, int to, int n)
-{
- if (n==0 || from==to)
- return;
- if (!canMove(from, to, n)) {
- qmlInfo(this) << tr("move: out of range");
- return;
- }
-
- if (m_dynamicRoles) {
-
- int realFrom = from;
- int realTo = to;
- int realN = n;
-
- if (from > to) {
- // Only move forwards - flip if backwards moving
- int tfrom = from;
- int tto = to;
- realFrom = tto;
- realTo = tto+n;
- realN = tfrom-tto;
- }
-
- QPODVector<DynamicRoleModelNode *, 4> store;
- for (int i=0 ; i < (realTo-realFrom) ; ++i)
- store.append(m_modelObjects[realFrom+realN+i]);
- for (int i=0 ; i < realN ; ++i)
- store.append(m_modelObjects[realFrom+i]);
- for (int i=0 ; i < store.count() ; ++i)
- m_modelObjects[realFrom+i] = store[i];
-
- } else {
- m_listModel->move(from, to, n);
- }
-
- emitItemsMoved(from, to, n);
-}
-
-/*!
- \qmlmethod QtQuick2::ListModel::append(jsobject dict)
-
- Adds a new item to the end of the list model, with the
- values in \a dict.
-
- \code
- fruitModel.append({"cost": 5.95, "name":"Pizza"})
- \endcode
-
- \sa set() remove()
-*/
-void QDeclarativeListModel::append(QDeclarativeV8Function *args)
-{
- if (args->Length() == 1) {
- v8::Handle<v8::Value> arg = (*args)[0];
-
- if (arg->IsArray()) {
- v8::Handle<v8::Array> objectArray = v8::Handle<v8::Array>::Cast(arg);
- int objectArrayLength = objectArray->Length();
-
- int index = count();
- for (int i=0 ; i < objectArrayLength ; ++i) {
- v8::Handle<v8::Object> argObject = objectArray->Get(i)->ToObject();
-
- if (m_dynamicRoles) {
- m_modelObjects.append(DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
- } else {
- m_listModel->append(argObject, args->engine());
- }
- }
-
- emitItemsInserted(index, objectArrayLength);
- } else if (arg->IsObject()) {
- v8::Handle<v8::Object> argObject = arg->ToObject();
-
- int index;
-
- if (m_dynamicRoles) {
- index = m_modelObjects.count();
- m_modelObjects.append(DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
- } else {
- index = m_listModel->append(argObject, args->engine());
- }
-
- emitItemsInserted(index, 1);
- } else {
- qmlInfo(this) << tr("append: value is not an object");
- }
- } else {
- qmlInfo(this) << tr("append: value is not an object");
- }
-}
-
-/*!
- \qmlmethod object QtQuick2::ListModel::get(int index)
-
- Returns the item at \a index in the list model. This allows the item
- data to be accessed or modified from JavaScript:
-
- \code
- Component.onCompleted: {
- fruitModel.append({"cost": 5.95, "name":"Jackfruit"});
- console.log(fruitModel.get(0).cost);
- fruitModel.get(0).cost = 10.95;
- }
- \endcode
-
- The \a index must be an element in the list.
-
- Note that properties of the returned object that are themselves objects
- will also be models, and this get() method is used to access elements:
-
- \code
- fruitModel.append(..., "attributes":
- [{"name":"spikes","value":"7mm"},
- {"name":"color","value":"green"}]);
- fruitModel.get(0).attributes.get(1).value; // == "green"
- \endcode
-
- \warning The returned object is not guaranteed to remain valid. It
- should not be used in \l{Property Binding}{property bindings}.
-
- \sa append()
-*/
-QDeclarativeV8Handle QDeclarativeListModel::get(int index) const
-{
- v8::Handle<v8::Value> result = v8::Undefined();
-
- if (index >= 0 && index < count()) {
- QV8Engine *v8engine = engine();
-
- if (m_dynamicRoles) {
- DynamicRoleModelNode *object = m_modelObjects[index];
- result = v8engine->newQObject(object);
- } else {
- ModelObject *object = m_listModel->getOrCreateModelObject(const_cast<QDeclarativeListModel *>(this), index);
- result = v8engine->newQObject(object);
- }
- }
-
- return QDeclarativeV8Handle::fromHandle(result);
-}
-
-/*!
- \qmlmethod QtQuick2::ListModel::set(int index, jsobject dict)
-
- Changes the item at \a index in the list model with the
- values in \a dict. Properties not appearing in \a dict
- are left unchanged.
-
- \code
- fruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
- \endcode
-
- If \a index is equal to count() then a new item is appended to the
- list. Otherwise, \a index must be an element in the list.
-
- \sa append()
-*/
-void QDeclarativeListModel::set(int index, const QDeclarativeV8Handle &handle)
-{
- v8::Handle<v8::Value> valuemap = handle.toHandle();
-
- if (!valuemap->IsObject() || valuemap->IsArray()) {
- qmlInfo(this) << tr("set: value is not an object");
- return;
- }
- if (index > count() || index < 0) {
- qmlInfo(this) << tr("set: index %1 out of range").arg(index);
- return;
- }
-
- v8::Handle<v8::Object> object = valuemap->ToObject();
-
- if (index == count()) {
-
- if (m_dynamicRoles) {
- m_modelObjects.append(DynamicRoleModelNode::create(engine()->variantMapFromJS(object), this));
- } else {
- m_listModel->insert(index, object, engine());
- }
-
- emitItemsInserted(index, 1);
- } else {
-
- QList<int> roles;
-
- if (m_dynamicRoles) {
- m_modelObjects[index]->updateValues(engine()->variantMapFromJS(object), roles);
- } else {
- m_listModel->set(index, object, &roles, engine());
- }
-
- if (roles.count())
- emitItemsChanged(index, 1, roles);
- }
-}
-
-/*!
- \qmlmethod QtQuick2::ListModel::setProperty(int index, string property, variant value)
-
- Changes the \a property of the item at \a index in the list model to \a value.
-
- \code
- fruitModel.setProperty(3, "cost", 5.95)
- \endcode
-
- The \a index must be an element in the list.
-
- \sa append()
-*/
-void QDeclarativeListModel::setProperty(int index, const QString& property, const QVariant& value)
-{
- if (count() == 0 || index >= count() || index < 0) {
- qmlInfo(this) << tr("set: index %1 out of range").arg(index);
- return;
- }
-
- if (m_dynamicRoles) {
- int roleIndex = m_roles.indexOf(property);
- if (roleIndex == -1) {
- roleIndex = m_roles.count();
- m_roles.append(property);
- }
- if (m_modelObjects[index]->setValue(property.toUtf8(), value)) {
- QList<int> roles;
- roles << roleIndex;
- emitItemsChanged(index, 1, roles);
- }
- } else {
- int roleIndex = m_listModel->setOrCreateProperty(index, property, value);
- if (roleIndex != -1) {
-
- QList<int> roles;
- roles << roleIndex;
-
- emitItemsChanged(index, 1, roles);
- }
- }
-}
-
-/*!
- \qmlmethod QtQuick2::ListModel::sync()
-
- Writes any unsaved changes to the list model after it has been modified
- from a worker script.
-*/
-void QDeclarativeListModel::sync()
-{
- // This is just a dummy method to make it look like sync() exists in
- // ListModel (and not just QDeclarativeListModelWorkerAgent) and to let
- // us document sync().
- qmlInfo(this) << "List sync() can only be called from a WorkerScript";
-}
-
-bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
-{
- QList<QVariant> values = prop.assignedValues();
- for(int ii = 0; ii < values.count(); ++ii) {
- const QVariant &value = values.at(ii);
-
- if(value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
- QDeclarativeCustomParserNode node =
- qvariant_cast<QDeclarativeCustomParserNode>(value);
-
- if (node.name() != listElementTypeName) {
- const QMetaObject *mo = resolveType(node.name());
- if (mo != &QDeclarativeListElement::staticMetaObject) {
- error(node, QDeclarativeListModel::tr("ListElement: cannot contain nested elements"));
- return false;
- }
- listElementTypeName = node.name(); // cache right name for next time
- }
-
- {
- ListInstruction li;
- li.type = ListInstruction::Push;
- li.dataIdx = -1;
- instr << li;
- }
-
- QList<QDeclarativeCustomParserProperty> props = node.properties();
- for(int jj = 0; jj < props.count(); ++jj) {
- const QDeclarativeCustomParserProperty &nodeProp = props.at(jj);
- if (nodeProp.name().isEmpty()) {
- error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot contain nested elements"));
- return false;
- }
- if (nodeProp.name() == QStringLiteral("id")) {
- error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot use reserved \"id\" property"));
- return false;
- }
-
- ListInstruction li;
- int ref = data.count();
- data.append(nodeProp.name().toUtf8());
- data.append('\0');
- li.type = ListInstruction::Set;
- li.dataIdx = ref;
- instr << li;
-
- if(!compileProperty(nodeProp, instr, data))
- return false;
-
- li.type = ListInstruction::Pop;
- li.dataIdx = -1;
- instr << li;
- }
-
- {
- ListInstruction li;
- li.type = ListInstruction::Pop;
- li.dataIdx = -1;
- instr << li;
- }
-
- } else {
-
- QDeclarativeScript::Variant variant =
- qvariant_cast<QDeclarativeScript::Variant>(value);
-
- int ref = data.count();
-
- QByteArray d;
- d += char(variant.type()); // type tag
- if (variant.isString()) {
- d += variant.asString().toUtf8();
- } else if (variant.isNumber()) {
- d += QByteArray::number(variant.asNumber(),'g',20);
- } else if (variant.isBoolean()) {
- d += char(variant.asBoolean());
- } else if (variant.isScript()) {
- if (definesEmptyList(variant.asScript())) {
- d[0] = char(QDeclarativeScript::Variant::Invalid); // marks empty list
- } else {
- QByteArray script = variant.asScript().toUtf8();
- int v = evaluateEnum(script);
- if (v<0) {
- using namespace QDeclarativeJS;
- AST::Node *node = variant.asAST();
- AST::StringLiteral *literal = 0;
- if (AST::CallExpression *callExpr = AST::cast<AST::CallExpression *>(node)) {
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(callExpr->base)) {
- if (idExpr->name == QLatin1String("QT_TR_NOOP") || idExpr->name == QLatin1String("QT_TRID_NOOP")) {
- if (callExpr->arguments && !callExpr->arguments->next)
- literal = AST::cast<AST::StringLiteral *>(callExpr->arguments->expression);
- if (!literal) {
- error(prop, QDeclarativeListModel::tr("ListElement: improperly specified %1").arg(idExpr->name.toString()));
- return false;
- }
- } else if (idExpr->name == QLatin1String("QT_TRANSLATE_NOOP")) {
- if (callExpr->arguments && callExpr->arguments->next && !callExpr->arguments->next->next)
- literal = AST::cast<AST::StringLiteral *>(callExpr->arguments->next->expression);
- if (!literal) {
- error(prop, QDeclarativeListModel::tr("ListElement: improperly specified QT_TRANSLATE_NOOP"));
- return false;
- }
- }
- }
- }
-
- if (literal) {
- d[0] = char(QDeclarativeScript::Variant::String);
- d += literal->value.toUtf8();
- } else {
- error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value"));
- return false;
- }
- } else {
- d[0] = char(QDeclarativeScript::Variant::Number);
- d += QByteArray::number(v);
- }
- }
- }
- d.append('\0');
- data.append(d);
-
- ListInstruction li;
- li.type = ListInstruction::Value;
- li.dataIdx = ref;
- instr << li;
- }
- }
-
- return true;
-}
-
-QByteArray QDeclarativeListModelParser::compile(const QList<QDeclarativeCustomParserProperty> &customProps)
-{
- QList<ListInstruction> instr;
- QByteArray data;
- listElementTypeName = QString(); // unknown
-
- for(int ii = 0; ii < customProps.count(); ++ii) {
- const QDeclarativeCustomParserProperty &prop = customProps.at(ii);
- if(!prop.name().isEmpty()) { // isn't default property
- error(prop, QDeclarativeListModel::tr("ListModel: undefined property '%1'").arg(prop.name()));
- return QByteArray();
- }
-
- if(!compileProperty(prop, instr, data)) {
- return QByteArray();
- }
- }
-
- int size = sizeof(ListModelData) +
- instr.count() * sizeof(ListInstruction) +
- data.count();
-
- QByteArray rv;
- rv.resize(size);
-
- ListModelData *lmd = (ListModelData *)rv.data();
- lmd->dataOffset = sizeof(ListModelData) +
- instr.count() * sizeof(ListInstruction);
- lmd->instrCount = instr.count();
- for (int ii = 0; ii < instr.count(); ++ii)
- lmd->instructions()[ii] = instr.at(ii);
- ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count());
-
- return rv;
-}
-
-void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray &d)
-{
- QDeclarativeListModel *rv = static_cast<QDeclarativeListModel *>(obj);
-
- QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(qmlEngine(rv));
- rv->m_engine = engine;
-
- const ListModelData *lmd = (const ListModelData *)d.constData();
- const char *data = ((const char *)lmd) + lmd->dataOffset;
-
- QStack<DataStackElement> stack;
-
- for (int ii = 0; ii < lmd->instrCount; ++ii) {
- const ListInstruction &instr = lmd->instructions()[ii];
-
- switch(instr.type) {
- case ListInstruction::Push:
- {
- Q_ASSERT(!rv->m_dynamicRoles);
-
- ListModel *subModel = 0;
-
- if (stack.count() == 0) {
- subModel = rv->m_listModel;
- } else {
- const DataStackElement &e0 = stack.at(stack.size() - 1);
- DataStackElement &e1 = stack[stack.size() - 2];
-
- const ListLayout::Role &role = e1.model->getOrCreateListRole(e0.name);
- if (role.type == ListLayout::Role::List) {
- subModel = e1.model->getListProperty(e1.elementIndex, role);
-
- if (subModel == 0) {
- subModel = new ListModel(role.subLayout, 0, -1);
- QVariant vModel = QVariant::fromValue(subModel);
- e1.model->setOrCreateProperty(e1.elementIndex, e0.name, vModel);
- }
- }
- }
-
- DataStackElement e;
- e.model = subModel;
- e.elementIndex = subModel ? subModel->appendElement() : -1;
- stack.push(e);
- }
- break;
-
- case ListInstruction::Pop:
- stack.pop();
- break;
-
- case ListInstruction::Value:
- {
- const DataStackElement &e0 = stack.at(stack.size() - 1);
- DataStackElement &e1 = stack[stack.size() - 2];
-
- QString name = e0.name;
- QVariant value;
-
- switch (QDeclarativeScript::Variant::Type(data[instr.dataIdx])) {
- case QDeclarativeScript::Variant::Invalid:
- {
- const ListLayout::Role &role = e1.model->getOrCreateListRole(e0.name);
- ListModel *emptyModel = new ListModel(role.subLayout, 0, -1);
- value = QVariant::fromValue(emptyModel);
- }
- break;
- case QDeclarativeScript::Variant::Boolean:
- value = bool(data[1 + instr.dataIdx]);
- break;
- case QDeclarativeScript::Variant::Number:
- value = QByteArray(data + 1 + instr.dataIdx).toDouble();
- break;
- case QDeclarativeScript::Variant::String:
- value = QString::fromUtf8(data + 1 + instr.dataIdx);
- break;
- default:
- Q_ASSERT("Format error in ListInstruction");
- }
-
- e1.model->setOrCreateProperty(e1.elementIndex, name, value);
- }
- break;
-
- case ListInstruction::Set:
- {
- DataStackElement e;
- e.name = QString::fromUtf8(data + instr.dataIdx);
- stack.push(e);
- }
- break;
- }
- }
-}
-
-bool QDeclarativeListModelParser::definesEmptyList(const QString &s)
-{
- if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) {
- for (int i=1; i<s.length()-1; i++) {
- if (!s[i].isSpace())
- return false;
- }
- return true;
- }
- return false;
-}
-
-
-/*!
- \qmlclass ListElement QDeclarativeListElement
- \inqmlmodule QtQuick 2
- \ingroup qml-working-with-data
- \brief The ListElement element defines a data item in a ListModel.
-
- List elements are defined inside ListModel definitions, and represent items in a
- list that will be displayed using ListView or \l Repeater items.
-
- List elements are defined like other QML elements except that they contain
- a collection of \e role definitions instead of properties. Using the same
- syntax as property definitions, roles both define how the data is accessed
- and include the data itself.
-
- The names used for roles must begin with a lower-case letter and should be
- common to all elements in a given model. Values must be simple constants; either
- strings (quoted and optionally within a call to QT_TR_NOOP), boolean values
- (true, false), numbers, or enumeration values (such as AlignText.AlignHCenter).
-
- \section1 Referencing Roles
-
- The role names are used by delegates to obtain data from list elements.
- Each role name is accessible in the delegate's scope, and refers to the
- corresponding role in the current element. Where a role name would be
- ambiguous to use, it can be accessed via the \l{ListView::}{model}
- property (e.g., \c{model.cost} instead of \c{cost}).
-
- \section1 Example Usage
-
- The following model defines a series of list elements, each of which
- contain "name" and "cost" roles and their associated values.
-
- \snippet doc/src/snippets/declarative/qml-data-models/listelements.qml model
-
- The delegate obtains the name and cost for each element by simply referring
- to \c name and \c cost:
-
- \snippet doc/src/snippets/declarative/qml-data-models/listelements.qml view
-
- \sa ListModel
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativelistmodel_p.h b/src/declarative/qml/qdeclarativelistmodel_p.h
deleted file mode 100644
index efc2f2fb2c..0000000000
--- a/src/declarative/qml/qdeclarativelistmodel_p.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTMODEL_H
-#define QDECLARATIVELISTMODEL_H
-
-#include <qdeclarative.h>
-#include <private/qdeclarativecustomparser_p.h>
-
-#include <QtCore/QObject>
-#include <QtCore/QStringList>
-#include <QtCore/QHash>
-#include <QtCore/QList>
-#include <QtCore/QVariant>
-#include "qlistmodelinterface_p.h"
-
-#include <private/qv8engine_p.h>
-#include <private/qpodvector_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeListModelWorkerAgent;
-class ListModel;
-class ListLayout;
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeListModel : public QListModelInterface
-{
- Q_OBJECT
- Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_PROPERTY(bool dynamicRoles READ dynamicRoles WRITE setDynamicRoles)
-
-public:
- QDeclarativeListModel(QObject *parent=0);
- ~QDeclarativeListModel();
-
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
- virtual int count() const;
- virtual QVariant data(int index, int role) const;
-
- Q_INVOKABLE void clear();
- Q_INVOKABLE void remove(QDeclarativeV8Function *args);
- Q_INVOKABLE void append(QDeclarativeV8Function *args);
- Q_INVOKABLE void insert(QDeclarativeV8Function *args);
- Q_INVOKABLE QDeclarativeV8Handle get(int index) const;
- Q_INVOKABLE void set(int index, const QDeclarativeV8Handle &);
- Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);
- Q_INVOKABLE void move(int from, int to, int count);
- Q_INVOKABLE void sync();
-
- QDeclarativeListModelWorkerAgent *agent();
-
- bool dynamicRoles() const { return m_dynamicRoles; }
- void setDynamicRoles(bool enableDynamicRoles);
-
-Q_SIGNALS:
- void countChanged();
-
-private:
- friend class QDeclarativeListModelParser;
- friend class QDeclarativeListModelWorkerAgent;
- friend class ModelObject;
- friend class ModelNodeMetaObject;
- friend class ListModel;
- friend class ListElement;
- friend class DynamicRoleModelNode;
- friend class DynamicRoleModelNodeMetaObject;
-
- // Constructs a flat list model for a worker agent
- QDeclarativeListModel(QDeclarativeListModel *orig, QDeclarativeListModelWorkerAgent *agent);
- QDeclarativeListModel(const QDeclarativeListModel *owner, ListModel *data, QV8Engine *eng, QObject *parent=0);
-
- QV8Engine *engine() const;
-
- inline bool canMove(int from, int to, int n) const { return !(from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0); }
-
- QDeclarativeListModelWorkerAgent *m_agent;
- mutable QV8Engine *m_engine;
- bool m_mainThread;
- bool m_primary;
-
- bool m_dynamicRoles;
-
- ListLayout *m_layout;
- ListModel *m_listModel;
-
- QVector<class DynamicRoleModelNode *> m_modelObjects;
- QVector<QString> m_roles;
- int m_uid;
-
- struct ElementSync
- {
- ElementSync() : src(0), target(0) {}
-
- DynamicRoleModelNode *src;
- DynamicRoleModelNode *target;
- };
-
- int getUid() const { return m_uid; }
-
- static void sync(QDeclarativeListModel *src, QDeclarativeListModel *target, QHash<int, QDeclarativeListModel *> *targetModelHash);
- static QDeclarativeListModel *createWithOwner(QDeclarativeListModel *newOwner);
-
- void emitItemsChanged(int index, int count, const QList<int> &roles);
- void emitItemsRemoved(int index, int count);
- void emitItemsInserted(int index, int count);
- void emitItemsMoved(int from, int to, int n);
-};
-
-// ### FIXME
-class QDeclarativeListElement : public QObject
-{
-Q_OBJECT
-};
-
-class QDeclarativeListModelParser : public QDeclarativeCustomParser
-{
-public:
- QDeclarativeListModelParser() : QDeclarativeCustomParser(QDeclarativeCustomParser::AcceptsSignalHandlers) {}
- QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
- void setCustomData(QObject *, const QByteArray &);
-
-private:
- struct ListInstruction
- {
- enum { Push, Pop, Value, Set } type;
- int dataIdx;
- };
- struct ListModelData
- {
- int dataOffset;
- int instrCount;
- ListInstruction *instructions() const;
- };
- bool compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data);
-
- bool definesEmptyList(const QString &);
-
- QString listElementTypeName;
-
- struct DataStackElement
- {
- DataStackElement() : model(0), elementIndex(0) {}
-
- QString name;
- ListModel *model;
- int elementIndex;
- };
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeListModel)
-QML_DECLARE_TYPE(QDeclarativeListElement)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVELISTMODEL_H
diff --git a/src/declarative/qml/qdeclarativelistmodel_p_p.h b/src/declarative/qml/qdeclarativelistmodel_p_p.h
deleted file mode 100644
index 22e19079a6..0000000000
--- a/src/declarative/qml/qdeclarativelistmodel_p_p.h
+++ /dev/null
@@ -1,378 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTMODEL_P_P_H
-#define QDECLARATIVELISTMODEL_P_P_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 "qdeclarativelistmodel_p.h"
-#include <private/qdeclarativeengine_p.h>
-#include "qdeclarativeopenmetaobject_p.h"
-#include <qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class DynamicRoleModelNode;
-
-class DynamicRoleModelNodeMetaObject : public QDeclarativeOpenMetaObject
-{
-public:
- DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object);
- ~DynamicRoleModelNodeMetaObject();
-
- bool m_enabled;
-
-protected:
- void propertyWrite(int index);
- void propertyWritten(int index);
-
-private:
- DynamicRoleModelNode *m_owner;
-};
-
-class DynamicRoleModelNode : public QObject
-{
- Q_OBJECT
-public:
- DynamicRoleModelNode(QDeclarativeListModel *owner, int uid);
-
- static DynamicRoleModelNode *create(const QVariantMap &obj, QDeclarativeListModel *owner);
-
- void updateValues(const QVariantMap &object, QList<int> &roles);
-
- QVariant getValue(const QString &name)
- {
- return m_meta->value(name.toUtf8());
- }
-
- bool setValue(const QByteArray &name, const QVariant &val)
- {
- return m_meta->setValue(name, val);
- }
-
- void setNodeUpdatesEnabled(bool enable)
- {
- m_meta->m_enabled = enable;
- }
-
- int getUid() const
- {
- return m_uid;
- }
-
- static void sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target, QHash<int, QDeclarativeListModel *> *targetModelHash);
-
-private:
- QDeclarativeListModel *m_owner;
- int m_uid;
- DynamicRoleModelNodeMetaObject *m_meta;
-
- friend class DynamicRoleModelNodeMetaObject;
-};
-
-class ModelObject;
-
-class ModelNodeMetaObject : public QDeclarativeOpenMetaObject
-{
-public:
- ModelNodeMetaObject(ModelObject *object);
- ~ModelNodeMetaObject();
-
- bool m_enabled;
-
-protected:
- void propertyWritten(int index);
-
-private:
-
- ModelObject *m_obj;
-};
-
-class ModelObject : public QObject
-{
- Q_OBJECT
-public:
- ModelObject(QDeclarativeListModel *model, int elementIndex);
-
- void setValue(const QByteArray &name, const QVariant &val, bool force)
- {
- if (force) {
- QVariant existingValue = m_meta->value(name);
- if (existingValue.isValid()) {
- (*m_meta)[name] = QVariant();
- }
- }
- m_meta->setValue(name, val);
- }
-
- void setNodeUpdatesEnabled(bool enable)
- {
- m_meta->m_enabled = enable;
- }
-
- void updateValues();
- void updateValues(const QList<int> &roles);
-
- QDeclarativeListModel *m_model;
- int m_elementIndex;
-
-private:
- ModelNodeMetaObject *m_meta;
-};
-
-class ListLayout
-{
-public:
- ListLayout() : currentBlock(0), currentBlockOffset(0) {}
- ListLayout(const ListLayout *other);
- ~ListLayout();
-
- class Role
- {
- public:
-
- Role() : type(Invalid), blockIndex(-1), blockOffset(-1), index(-1), subLayout(0) {}
- explicit Role(const Role *other);
- ~Role();
-
- // This enum must be kept in sync with the roleTypeNames variable in qdeclarativelistmodel.cpp
- enum DataType
- {
- Invalid = -1,
-
- String,
- Number,
- Bool,
- List,
- QObject,
- VariantMap,
-
- MaxDataType
- };
-
- QString name;
- DataType type;
- int blockIndex;
- int blockOffset;
- int index;
- ListLayout *subLayout;
- };
-
- const Role *getRoleOrCreate(const QString &key, const QVariant &data);
- const Role &getRoleOrCreate(v8::Handle<v8::String> key, Role::DataType type);
- const Role &getRoleOrCreate(const QString &key, Role::DataType type);
-
- const Role &getExistingRole(int index) { return *roles.at(index); }
- const Role *getExistingRole(const QString &key);
- const Role *getExistingRole(v8::Handle<v8::String> key);
-
- int roleCount() const { return roles.count(); }
-
- static void sync(ListLayout *src, ListLayout *target);
-
-private:
- const Role &createRole(const QString &key, Role::DataType type);
-
- int currentBlock;
- int currentBlockOffset;
- QVector<Role *> roles;
- QStringHash<Role *> roleHash;
-};
-
-class ListElement
-{
-public:
-
- ListElement();
- ListElement(int existingUid);
- ~ListElement();
-
- static void sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout, QHash<int, ListModel *> *targetModelHash);
-
- enum
- {
- BLOCK_SIZE = 64 - sizeof(int) - sizeof(ListElement *) - sizeof(ModelObject *)
- };
-
-private:
-
- void destroy(ListLayout *layout);
-
- int setVariantProperty(const ListLayout::Role &role, const QVariant &d);
-
- int setJsProperty(const ListLayout::Role &role, v8::Handle<v8::Value> d, QV8Engine *eng);
-
- int setStringProperty(const ListLayout::Role &role, const QString &s);
- int setDoubleProperty(const ListLayout::Role &role, double n);
- int setBoolProperty(const ListLayout::Role &role, bool b);
- int setListProperty(const ListLayout::Role &role, ListModel *m);
- int setQObjectProperty(const ListLayout::Role &role, QObject *o);
- int setVariantMapProperty(const ListLayout::Role &role, v8::Handle<v8::Object> o, QV8Engine *eng);
- int setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m);
-
- void setStringPropertyFast(const ListLayout::Role &role, const QString &s);
- void setDoublePropertyFast(const ListLayout::Role &role, double n);
- void setBoolPropertyFast(const ListLayout::Role &role, bool b);
- void setQObjectPropertyFast(const ListLayout::Role &role, QObject *o);
- void setListPropertyFast(const ListLayout::Role &role, ListModel *m);
- void setVariantMapFast(const ListLayout::Role &role, v8::Handle<v8::Object> o, QV8Engine *eng);
-
- void clearProperty(const ListLayout::Role &role);
-
- QVariant getProperty(const ListLayout::Role &role, const QDeclarativeListModel *owner, QV8Engine *eng);
- ListModel *getListProperty(const ListLayout::Role &role);
- QString *getStringProperty(const ListLayout::Role &role);
- QObject *getQObjectProperty(const ListLayout::Role &role);
- QDeclarativeGuard<QObject> *getGuardProperty(const ListLayout::Role &role);
- QVariantMap *getVariantMapProperty(const ListLayout::Role &role);
-
- inline char *getPropertyMemory(const ListLayout::Role &role);
-
- int getUid() const { return uid; }
-
- char data[BLOCK_SIZE];
- ListElement *next;
-
- int uid;
- ModelObject *m_objectCache;
-
- friend class ListModel;
-};
-
-class ListModel
-{
-public:
-
- ListModel(ListLayout *layout, QDeclarativeListModel *modelCache, int uid);
- ~ListModel() {}
-
- void destroy();
-
- int setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data);
- int setExistingProperty(int uid, const QString &key, v8::Handle<v8::Value> data, QV8Engine *eng);
-
- QVariant getProperty(int elementIndex, int roleIndex, const QDeclarativeListModel *owner, QV8Engine *eng);
- ListModel *getListProperty(int elementIndex, const ListLayout::Role &role);
-
- int roleCount() const
- {
- return m_layout->roleCount();
- }
-
- const ListLayout::Role &getExistingRole(int index)
- {
- return m_layout->getExistingRole(index);
- }
-
- const ListLayout::Role &getOrCreateListRole(const QString &name)
- {
- return m_layout->getRoleOrCreate(name, ListLayout::Role::List);
- }
-
- int elementCount() const
- {
- return elements.count();
- }
-
- void set(int elementIndex, v8::Handle<v8::Object> object, QList<int> *roles, QV8Engine *eng);
- void set(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng);
-
- int append(v8::Handle<v8::Object> object, QV8Engine *eng);
- void insert(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng);
-
- void clear();
- void remove(int index, int count);
-
- int appendElement();
- void insertElement(int index);
-
- void move(int from, int to, int n);
-
- int getUid() const { return m_uid; }
-
- static void sync(ListModel *src, ListModel *target, QHash<int, ListModel *> *srcModelHash);
-
- ModelObject *getOrCreateModelObject(QDeclarativeListModel *model, int elementIndex);
-
-private:
- QPODVector<ListElement *, 4> elements;
- ListLayout *m_layout;
- int m_uid;
-
- QDeclarativeListModel *m_modelCache;
-
- struct ElementSync
- {
- ElementSync() : src(0), target(0) {}
-
- ListElement *src;
- ListElement *target;
- };
-
- void newElement(int index);
-
- void updateCacheIndices();
-
- friend class ListElement;
- friend class QDeclarativeListModelWorkerAgent;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(ListModel *);
-
-QT_END_HEADER
-
-#endif // QDECLARATIVELISTMODEL_P_P_H
-
diff --git a/src/declarative/qml/qdeclarativelistmodelworkeragent.cpp b/src/declarative/qml/qdeclarativelistmodelworkeragent.cpp
deleted file mode 100644
index 51ac460adf..0000000000
--- a/src/declarative/qml/qdeclarativelistmodelworkeragent.cpp
+++ /dev/null
@@ -1,246 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativelistmodelworkeragent_p.h"
-#include "qdeclarativelistmodel_p_p.h"
-#include <private/qdeclarativedata_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <qdeclarativeinfo.h>
-
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdebug.h>
-
-
-QT_BEGIN_NAMESPACE
-
-
-void QDeclarativeListModelWorkerAgent::Data::clearChange(int uid)
-{
- for (int i=0 ; i < changes.count() ; ++i) {
- if (changes[i].modelUid == uid) {
- changes.removeAt(i);
- --i;
- }
- }
-}
-
-void QDeclarativeListModelWorkerAgent::Data::insertChange(int uid, int index, int count)
-{
- Change c = { uid, Change::Inserted, index, count, 0, QList<int>() };
- changes << c;
-}
-
-void QDeclarativeListModelWorkerAgent::Data::removeChange(int uid, int index, int count)
-{
- Change c = { uid, Change::Removed, index, count, 0, QList<int>() };
- changes << c;
-}
-
-void QDeclarativeListModelWorkerAgent::Data::moveChange(int uid, int index, int count, int to)
-{
- Change c = { uid, Change::Moved, index, count, to, QList<int>() };
- changes << c;
-}
-
-void QDeclarativeListModelWorkerAgent::Data::changedChange(int uid, int index, int count, const QList<int> &roles)
-{
- Change c = { uid, Change::Changed, index, count, 0, roles };
- changes << c;
-}
-
-QDeclarativeListModelWorkerAgent::QDeclarativeListModelWorkerAgent(QDeclarativeListModel *model)
-: m_ref(1), m_orig(model), m_copy(new QDeclarativeListModel(model, this))
-{
-}
-
-QDeclarativeListModelWorkerAgent::~QDeclarativeListModelWorkerAgent()
-{
- mutex.lock();
- syncDone.wakeAll();
- mutex.unlock();
-}
-
-void QDeclarativeListModelWorkerAgent::setV8Engine(QV8Engine *eng)
-{
- m_copy->m_engine = eng;
-}
-
-void QDeclarativeListModelWorkerAgent::addref()
-{
- m_ref.ref();
-}
-
-void QDeclarativeListModelWorkerAgent::release()
-{
- bool del = !m_ref.deref();
-
- if (del)
- deleteLater();
-}
-
-void QDeclarativeListModelWorkerAgent::modelDestroyed()
-{
- m_orig = 0;
-}
-
-int QDeclarativeListModelWorkerAgent::count() const
-{
- return m_copy->count();
-}
-
-void QDeclarativeListModelWorkerAgent::clear()
-{
- m_copy->clear();
-}
-
-void QDeclarativeListModelWorkerAgent::remove(QDeclarativeV8Function *args)
-{
- m_copy->remove(args);
-}
-
-void QDeclarativeListModelWorkerAgent::append(QDeclarativeV8Function *args)
-{
- m_copy->append(args);
-}
-
-void QDeclarativeListModelWorkerAgent::insert(QDeclarativeV8Function *args)
-{
- m_copy->insert(args);
-}
-
-QDeclarativeV8Handle QDeclarativeListModelWorkerAgent::get(int index) const
-{
- return m_copy->get(index);
-}
-
-void QDeclarativeListModelWorkerAgent::set(int index, const QDeclarativeV8Handle &value)
-{
- m_copy->set(index, value);
-}
-
-void QDeclarativeListModelWorkerAgent::setProperty(int index, const QString& property, const QVariant& value)
-{
- m_copy->setProperty(index, property, value);
-}
-
-void QDeclarativeListModelWorkerAgent::move(int from, int to, int count)
-{
- m_copy->move(from, to, count);
-}
-
-void QDeclarativeListModelWorkerAgent::sync()
-{
- Sync *s = new Sync;
- s->data = data;
- s->list = m_copy;
- data.changes.clear();
-
- mutex.lock();
- QCoreApplication::postEvent(this, s);
- syncDone.wait(&mutex);
- mutex.unlock();
-}
-
-bool QDeclarativeListModelWorkerAgent::event(QEvent *e)
-{
- if (e->type() == QEvent::User) {
- bool cc = false;
- QMutexLocker locker(&mutex);
- if (m_orig) {
- Sync *s = static_cast<Sync *>(e);
- const QList<Change> &changes = s->data.changes;
-
- cc = m_orig->count() != s->list->count();
-
- QHash<int, QDeclarativeListModel *> targetModelDynamicHash;
- QHash<int, ListModel *> targetModelStaticHash;
-
- Q_ASSERT(m_orig->m_dynamicRoles == s->list->m_dynamicRoles);
- if (m_orig->m_dynamicRoles)
- QDeclarativeListModel::sync(s->list, m_orig, &targetModelDynamicHash);
- else
- ListModel::sync(s->list->m_listModel, m_orig->m_listModel, &targetModelStaticHash);
-
- for (int ii = 0; ii < changes.count(); ++ii) {
- const Change &change = changes.at(ii);
-
- QDeclarativeListModel *model = 0;
- if (m_orig->m_dynamicRoles) {
- model = targetModelDynamicHash.value(change.modelUid);
- } else {
- ListModel *lm = targetModelStaticHash.value(change.modelUid);
- if (lm)
- model = lm->m_modelCache;
- }
-
- if (model) {
- switch (change.type) {
- case Change::Inserted:
- emit model->itemsInserted(change.index, change.count);
- break;
- case Change::Removed:
- emit model->itemsRemoved(change.index, change.count);
- break;
- case Change::Moved:
- emit model->itemsMoved(change.index, change.to, change.count);
- break;
- case Change::Changed:
- emit model->itemsChanged(change.index, change.count, change.roles);
- break;
- }
- }
- }
- }
-
- syncDone.wakeAll();
- locker.unlock();
-
- if (cc)
- emit m_orig->countChanged();
- return true;
- }
-
- return QObject::event(e);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qdeclarativelistmodelworkeragent_p.h b/src/declarative/qml/qdeclarativelistmodelworkeragent_p.h
deleted file mode 100644
index f2c971c1e1..0000000000
--- a/src/declarative/qml/qdeclarativelistmodelworkeragent_p.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTMODELWORKERAGENT_P_H
-#define QDECLARATIVELISTMODELWORKERAGENT_P_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 <qdeclarative.h>
-
-#include <QtGui/qevent.h>
-#include <QMutex>
-#include <QWaitCondition>
-
-#include <private/qv8engine_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeListModel;
-
-class QDeclarativeListModelWorkerAgent : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int count READ count)
-
-public:
- QDeclarativeListModelWorkerAgent(QDeclarativeListModel *);
- ~QDeclarativeListModelWorkerAgent();
- void setV8Engine(QV8Engine *eng);
-
- void addref();
- void release();
-
- int count() const;
-
- Q_INVOKABLE void clear();
- Q_INVOKABLE void remove(QDeclarativeV8Function *args);
- Q_INVOKABLE void append(QDeclarativeV8Function *args);
- Q_INVOKABLE void insert(QDeclarativeV8Function *args);
- Q_INVOKABLE QDeclarativeV8Handle get(int index) const;
- Q_INVOKABLE void set(int index, const QDeclarativeV8Handle &);
- Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);
- Q_INVOKABLE void move(int from, int to, int count);
- Q_INVOKABLE void sync();
-
- struct VariantRef
- {
- VariantRef() : a(0) {}
- VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); }
- VariantRef(QDeclarativeListModelWorkerAgent *_a) : a(_a) { if (a) a->addref(); }
- ~VariantRef() { if (a) a->release(); }
-
- VariantRef &operator=(const VariantRef &o) {
- if (o.a) o.a->addref();
- if (a) a->release(); a = o.a;
- return *this;
- }
-
- QDeclarativeListModelWorkerAgent *a;
- };
- void modelDestroyed();
-protected:
- virtual bool event(QEvent *);
-
-private:
- friend class QDeclarativeWorkerScriptEnginePrivate;
- friend class QDeclarativeListModel;
-
- struct Change
- {
- int modelUid;
- enum { Inserted, Removed, Moved, Changed } type;
- int index; // Inserted/Removed/Moved/Changed
- int count; // Inserted/Removed/Moved/Changed
- int to; // Moved
- QList<int> roles;
- };
-
- struct Data
- {
- QList<Change> changes;
-
- void clearChange(int uid);
- void insertChange(int uid, int index, int count);
- void removeChange(int uid, int index, int count);
- void moveChange(int uid, int index, int count, int to);
- void changedChange(int uid, int index, int count, const QList<int> &roles);
- };
- Data data;
-
- struct Sync : public QEvent {
- Sync() : QEvent(QEvent::User) {}
- Data data;
- QDeclarativeListModel *list;
- };
-
- QAtomicInt m_ref;
- QDeclarativeListModel *m_orig;
- QDeclarativeListModel *m_copy;
- QMutex mutex;
- QWaitCondition syncDone;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeListModelWorkerAgent::VariantRef)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEWORKERSCRIPT_P_H
-
diff --git a/src/declarative/qml/qdeclarativelocale.cpp b/src/declarative/qml/qdeclarativelocale.cpp
deleted file mode 100644
index 103378a9c0..0000000000
--- a/src/declarative/qml/qdeclarativelocale.cpp
+++ /dev/null
@@ -1,1126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativelocale_p.h"
-#include "qdeclarativeengine_p.h"
-#include <private/qdeclarativecontext_p.h>
-#include <private/qjsconverter_impl_p.h>
-#include <QtCore/qnumeric.h>
-#include <QtCore/qdatetime.h>
-
-#include <private/qlocale_p.h>
-#include <private/qlocale_data_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8LocaleDataResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(LocaleDataType)
-public:
- QV8LocaleDataResource(QV8Engine *e) : QV8ObjectResource(e) {}
- QLocale locale;
-};
-
-#define GET_LOCALE_DATA_RESOURCE(OBJECT) \
-QV8LocaleDataResource *r = v8_resource_cast<QV8LocaleDataResource>(OBJECT); \
-if (!r) \
- V8THROW_ERROR("Not a valid Locale object")
-
-static bool isLocaleObject(v8::Handle<v8::Value> val)
-{
- if (!val->IsObject())
- return false;
-
- v8::Handle<v8::Object> localeObj = val->ToObject();
- return localeObj->Has(v8::String::New("nativeLanguageName")); //XXX detect locale object properly
-}
-
-//--------------
-// Date extension
-
-static const char *dateToLocaleStringFunction =
- "(function(toLocaleStringFunc) { "
- " var orig_toLocaleString;"
- " orig_toLocaleString = Date.prototype.toLocaleString;"
- " Date.prototype.toLocaleString = (function() {"
- " var val = toLocaleStringFunc.apply(this, arguments);"
- " if (val == undefined) val = orig_toLocaleString.call(this);"
- " return val;"
- " })"
- "})";
-
-static const char *dateToLocaleTimeStringFunction =
- "(function(toLocaleTimeStringFunc) { "
- " var orig_toLocaleTimeString;"
- " orig_toLocaleTimeString = Date.prototype.toLocaleTimeString;"
- " Date.prototype.toLocaleTimeString = (function() {"
- " var val = toLocaleTimeStringFunc.apply(this, arguments);"
- " if (val == undefined) val = orig_toLocaleTimeString.call(this);"
- " return val;"
- " })"
- "})";
-
-static const char *dateToLocaleDateStringFunction =
- "(function(toLocaleDateStringFunc) { "
- " var orig_toLocaleDateString;"
- " orig_toLocaleDateString = Date.prototype.toLocaleDateString;"
- " Date.prototype.toLocaleDateString = (function() {"
- " var val = toLocaleDateStringFunc.apply(this, arguments);"
- " if (val == undefined) val = orig_toLocaleDateString.call(this);"
- " return val;"
- " })"
- "})";
-
-
-static const char *dateFromLocaleStringFunction =
- "(function(fromLocaleStringFunc) { "
- " Date.fromLocaleString = (function() {"
- " return fromLocaleStringFunc.apply(null, arguments);"
- " })"
- "})";
-
-static const char *dateFromLocaleTimeStringFunction =
- "(function(fromLocaleTimeStringFunc) { "
- " Date.fromLocaleTimeString = (function() {"
- " return fromLocaleTimeStringFunc.apply(null, arguments);"
- " })"
- "})";
-
-static const char *dateFromLocaleDateStringFunction =
- "(function(fromLocaleDateStringFunc) { "
- " Date.fromLocaleDateString = (function() {"
- " return fromLocaleDateStringFunc.apply(null, arguments);"
- " })"
- "})";
-
-
-static void registerFunction(QV8Engine *engine, const char *script, v8::InvocationCallback func)
-{
- v8::Local<v8::Script> registerScript = v8::Script::New(v8::String::New(script), 0, 0, v8::Handle<v8::String>(), v8::Script::NativeMode);
- v8::Local<v8::Value> result = registerScript->Run();
- Q_ASSERT(result->IsFunction());
- v8::Local<v8::Function> registerFunc = v8::Local<v8::Function>::Cast(result);
- v8::Handle<v8::Value> args = V8FUNCTION(func, engine);
- registerFunc->Call(v8::Local<v8::Object>::Cast(registerFunc), 1, &args);
-}
-
-void QDeclarativeDateExtension::registerExtension(QV8Engine *engine)
-{
- registerFunction(engine, dateToLocaleStringFunction, toLocaleString);
- registerFunction(engine, dateToLocaleTimeStringFunction, toLocaleTimeString);
- registerFunction(engine, dateToLocaleDateStringFunction, toLocaleDateString);
- registerFunction(engine, dateFromLocaleStringFunction, fromLocaleString);
- registerFunction(engine, dateFromLocaleTimeStringFunction, fromLocaleTimeString);
- registerFunction(engine, dateFromLocaleDateStringFunction, fromLocaleDateString);
-}
-
-v8::Handle<v8::Value> QDeclarativeDateExtension::toLocaleString(const v8::Arguments& args)
-{
- if (args.Length() > 2)
- return v8::Undefined();
-
- if (!args.This()->IsDate())
- return v8::Undefined();
-
- QDateTime dt = QV8Engine::qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(args.This())->NumberValue());
-
- if (args.Length() == 0) {
- // Use QLocale for standard toLocaleString() function
- QLocale locale;
- return QJSConverter::toString(locale.toString(dt));
- }
-
- if (!isLocaleObject(args[0]))
- return v8::Undefined(); // Use the default Date toLocaleString()
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
-
- QLocale::FormatType enumFormat = QLocale::LongFormat;
- QString formattedDt;
- if (args.Length() == 2) {
- if (args[1]->IsString()) {
- QString format = r->engine->toVariant(args[1], -1).toString();
- formattedDt = r->locale.toString(dt, format);
- } else if (args[1]->IsNumber()) {
- quint32 intFormat = args[1]->ToNumber()->Value();
- QLocale::FormatType format = QLocale::FormatType(intFormat);
- formattedDt = r->locale.toString(dt, format);
- } else {
- V8THROW_ERROR("Locale: Date.toLocaleString(): Invalid datetime format");
- }
- } else {
- formattedDt = r->locale.toString(dt, enumFormat);
- }
-
- return r->engine->toString(formattedDt);
-}
-
-v8::Handle<v8::Value> QDeclarativeDateExtension::toLocaleTimeString(const v8::Arguments& args)
-{
- if (args.Length() > 2)
- return v8::Undefined();
-
- if (!args.This()->IsDate())
- return v8::Undefined();
-
- QDateTime dt = QV8Engine::qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(args.This())->NumberValue());
- QTime time = dt.time();
-
- if (args.Length() == 0) {
- // Use QLocale for standard toLocaleString() function
- QLocale locale;
- return QJSConverter::toString(locale.toString(time));
- }
-
- if (!isLocaleObject(args[0]))
- return v8::Undefined(); // Use the default Date toLocaleTimeString()
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
-
- QLocale::FormatType enumFormat = QLocale::LongFormat;
- QString formattedTime;
- if (args.Length() == 2) {
- if (args[1]->IsString()) {
- QString format = r->engine->toVariant(args[1], -1).toString();
- formattedTime = r->locale.toString(time, format);
- } else if (args[1]->IsNumber()) {
- quint32 intFormat = args[1]->ToNumber()->Value();
- QLocale::FormatType format = QLocale::FormatType(intFormat);
- formattedTime = r->locale.toString(time, format);
- } else {
- V8THROW_ERROR("Locale: Date.toLocaleTimeString(): Invalid time format");
- }
- } else {
- formattedTime = r->locale.toString(time, enumFormat);
- }
-
- return r->engine->toString(formattedTime);
-}
-
-v8::Handle<v8::Value> QDeclarativeDateExtension::toLocaleDateString(const v8::Arguments& args)
-{
- if (args.Length() > 2)
- return v8::Undefined();
-
- if (!args.This()->IsDate())
- return v8::Undefined();
-
- QDateTime dt = QV8Engine::qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(args.This())->NumberValue());
- QDate date = dt.date();
-
- if (args.Length() == 0) {
- // Use QLocale for standard toLocaleString() function
- QLocale locale;
- return QJSConverter::toString(locale.toString(date));
- }
-
- if (!isLocaleObject(args[0]))
- return v8::Undefined(); // Use the default Date toLocaleDateString()
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
-
- QLocale::FormatType enumFormat = QLocale::LongFormat;
- QString formattedDate;
- if (args.Length() == 2) {
- if (args[1]->IsString()) {
- QString format = r->engine->toVariant(args[1], -1).toString();
- formattedDate = r->locale.toString(date, format);
- } else if (args[1]->IsNumber()) {
- quint32 intFormat = args[1]->ToNumber()->Value();
- QLocale::FormatType format = QLocale::FormatType(intFormat);
- formattedDate = r->locale.toString(date, format);
- } else {
- V8THROW_ERROR("Locale: Date.loLocaleDateString(): Invalid date format");
- }
- } else {
- formattedDate = r->locale.toString(date, enumFormat);
- }
-
- return r->engine->toString(formattedDate);
-}
-
-v8::Handle<v8::Value> QDeclarativeDateExtension::fromLocaleString(const v8::Arguments& args)
-{
- if (args.Length() == 1 && args[0]->IsString()) {
- QLocale locale;
- QString dateString = QJSConverter::toString(args[0]->ToString());
- QDateTime dt = locale.toDateTime(dateString);
- return QJSConverter::toDateTime(dt);
- }
-
- if (args.Length() < 1 || args.Length() > 3 || !isLocaleObject(args[0]))
- V8THROW_ERROR("Locale: Date.fromLocaleString(): Invalid arguments");
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
-
- QLocale::FormatType enumFormat = QLocale::LongFormat;
- QDateTime dt;
- QString dateString = r->engine->toString(args[1]->ToString());
- if (args.Length() == 3) {
- if (args[2]->IsString()) {
- QString format = r->engine->toString(args[2]->ToString());
- dt = r->locale.toDateTime(dateString, format);
- } else if (args[2]->IsNumber()) {
- quint32 intFormat = args[2]->ToNumber()->Value();
- QLocale::FormatType format = QLocale::FormatType(intFormat);
- dt = r->locale.toDateTime(dateString, format);
- } else {
- V8THROW_ERROR("Locale: Date.fromLocaleString(): Invalid datetime format");
- }
- } else {
- dt = r->locale.toDateTime(dateString, enumFormat);
- }
-
- return QJSConverter::toDateTime(dt);
-}
-
-v8::Handle<v8::Value> QDeclarativeDateExtension::fromLocaleTimeString(const v8::Arguments& args)
-{
- if (args.Length() == 1 && args[0]->IsString()) {
- QLocale locale;
- QString timeString = QJSConverter::toString(args[0]->ToString());
- QTime time = locale.toTime(timeString);
- QDateTime dt = QDateTime::currentDateTime();
- dt.setTime(time);
- return QJSConverter::toDateTime(dt);
- }
-
- if (args.Length() < 1 || args.Length() > 3 || !isLocaleObject(args[0]))
- V8THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid arguments");
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
-
- QLocale::FormatType enumFormat = QLocale::LongFormat;
- QTime tm;
- QString dateString = r->engine->toString(args[1]->ToString());
- if (args.Length() == 3) {
- if (args[2]->IsString()) {
- QString format = r->engine->toString(args[2]->ToString());
- tm = r->locale.toTime(dateString, format);
- } else if (args[2]->IsNumber()) {
- quint32 intFormat = args[2]->ToNumber()->Value();
- QLocale::FormatType format = QLocale::FormatType(intFormat);
- tm = r->locale.toTime(dateString, format);
- } else {
- V8THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid datetime format");
- }
- } else {
- tm = r->locale.toTime(dateString, enumFormat);
- }
-
- QDateTime dt = QDateTime::currentDateTime();
- dt.setTime(tm);
-
- return QJSConverter::toDateTime(dt);
-}
-
-v8::Handle<v8::Value> QDeclarativeDateExtension::fromLocaleDateString(const v8::Arguments& args)
-{
- if (args.Length() == 1 && args[0]->IsString()) {
- QLocale locale;
- QString dateString = QJSConverter::toString(args[0]->ToString());
- QDate date = locale.toDate(dateString);
- return QJSConverter::toDateTime(QDateTime(date));
- }
-
- if (args.Length() < 1 || args.Length() > 3 || !isLocaleObject(args[0]))
- V8THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid arguments");
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
-
- QLocale::FormatType enumFormat = QLocale::LongFormat;
- QDate dt;
- QString dateString = r->engine->toString(args[1]->ToString());
- if (args.Length() == 3) {
- if (args[2]->IsString()) {
- QString format = r->engine->toString(args[2]->ToString());
- dt = r->locale.toDate(dateString, format);
- } else if (args[2]->IsNumber()) {
- quint32 intFormat = args[2]->ToNumber()->Value();
- QLocale::FormatType format = QLocale::FormatType(intFormat);
- dt = r->locale.toDate(dateString, format);
- } else {
- V8THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid datetime format");
- }
- } else {
- dt = r->locale.toDate(dateString, enumFormat);
- }
-
- return QJSConverter::toDateTime(QDateTime(dt));
-}
-
-//-----------------
-// Number extension
-
-static const char *numberToLocaleStringFunction =
- "(function(toLocaleStringFunc) { "
- " var orig_toLocaleString;"
- " orig_toLocaleString = Number.prototype.toLocaleString;"
- " Number.prototype.toLocaleString = (function() {"
- " var val = toLocaleStringFunc.apply(this, arguments);"
- " if (val == undefined) val = orig_toLocaleString.call(this);"
- " return val;"
- " })"
- "})";
-
-static const char *numberToLocaleCurrencyStringFunction =
- "(function(toLocaleCurrencyStringFunc) { "
- " Number.prototype.toLocaleCurrencyString = (function() {"
- " return toLocaleCurrencyStringFunc.apply(this, arguments);"
- " })"
- "})";
-
-static const char *numberFromLocaleStringFunction =
- "(function(fromLocaleStringFunc) { "
- " Number.fromLocaleString = (function() {"
- " return fromLocaleStringFunc.apply(null, arguments);"
- " })"
- "})";
-
-
-void QDeclarativeNumberExtension::registerExtension(QV8Engine *engine)
-{
- registerFunction(engine, numberToLocaleStringFunction, toLocaleString);
- registerFunction(engine, numberToLocaleCurrencyStringFunction, toLocaleCurrencyString);
- registerFunction(engine, numberFromLocaleStringFunction, fromLocaleString);
-}
-
-v8::Handle<v8::Value> QDeclarativeNumberExtension::toLocaleString(const v8::Arguments& args)
-{
- if (args.Length() > 3)
- V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
-
- double number = args.This()->ToNumber()->Value();
-
- if (args.Length() == 0) {
- // Use QLocale for standard toLocaleString() function
- QLocale locale;
- return QJSConverter::toString(locale.toString(number));
- }
-
- if (!isLocaleObject(args[0]))
- return v8::Undefined(); // Use the default Number toLocaleString()
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
-
- uint16_t format = 'f';
- if (args.Length() > 1) {
- if (!args[1]->IsString())
- V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
- v8::Local<v8::String> fs = args[1]->ToString();
- if (!fs.IsEmpty() && fs->Length())
- format = fs->GetCharacter(0);
- }
- int prec = 2;
- if (args.Length() > 2) {
- if (!args[2]->IsNumber())
- V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
- prec = args[2]->IntegerValue();
- }
-
- return r->engine->toString(r->locale.toString(number, (char)format, prec));
-}
-
-v8::Handle<v8::Value> QDeclarativeNumberExtension::toLocaleCurrencyString(const v8::Arguments& args)
-{
- if (args.Length() > 2)
- V8THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");
-
- double number = args.This()->ToNumber()->Value();
-
- if (args.Length() == 0) {
- // Use QLocale for standard toLocaleString() function
- QLocale locale;
- return QJSConverter::toString(locale.toString(number));
- }
-
- if (!isLocaleObject(args[0]))
- V8THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
-
- QString symbol;
- if (args.Length() > 1) {
- if (!args[1]->IsString())
- V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
- symbol = r->engine->toString(args[1]->ToString());
- }
-
- return r->engine->toString(r->locale.toCurrencyString(number, symbol));
-}
-
-v8::Handle<v8::Value> QDeclarativeNumberExtension::fromLocaleString(const v8::Arguments& args)
-{
- if (args.Length() < 1 || args.Length() > 2)
- V8THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");
-
- int numberIdx = 0;
- QLocale locale;
-
- if (args.Length() == 2) {
- if (!isLocaleObject(args[0]))
- V8THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");
-
- GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
- locale = r->locale;
-
- numberIdx = 1;
- }
-
- v8::Local<v8::String> ns = args[numberIdx]->ToString();
- if (ns.IsEmpty() || ns->Length() == 0)
- return v8::Number::New(Q_QNAN);
-
- bool ok = false;
- double val = locale.toDouble(QJSConverter::toString(ns), &ok);
-
- if (!ok)
- V8THROW_ERROR("Locale: Number.fromLocaleString(): Invalid format")
-
- return v8::Number::New(val);
-}
-
-//--------------
-// Locale object
-
-static v8::Handle<v8::Value> locale_get_firstDayOfWeek(v8::Local<v8::String>, const v8::AccessorInfo &info)
-{
- GET_LOCALE_DATA_RESOURCE(info.This());
- int fdow = int(r->locale.firstDayOfWeek());
- if (fdow == 7)
- fdow = 0; // Qt::Sunday = 7, but Sunday is 0 in JS Date
- return v8::Integer::New(fdow);
-}
-
-static v8::Handle<v8::Value> locale_get_measurementSystem(v8::Local<v8::String>, const v8::AccessorInfo &info)
-{
- GET_LOCALE_DATA_RESOURCE(info.This());
- return v8::Integer::New(r->locale.measurementSystem());
-}
-
-static v8::Handle<v8::Value> locale_get_textDirection(v8::Local<v8::String>, const v8::AccessorInfo &info)
-{
- GET_LOCALE_DATA_RESOURCE(info.This());
- return v8::Integer::New(r->locale.textDirection());
-}
-
-static v8::Handle<v8::Value> locale_get_weekDays(v8::Local<v8::String>, const v8::AccessorInfo &info)
-{
- GET_LOCALE_DATA_RESOURCE(info.This());
-
- QList<Qt::DayOfWeek> days = r->locale.weekdays();
-
- v8::Handle<v8::Array> result = v8::Array::New(days.size());
- for (int i = 0; i < days.size(); ++i) {
- int day = days.at(i);
- if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
- day = 0;
- result->Set(i, v8::Integer::New(day));
- }
-
- return result;
-}
-
-static v8::Handle<v8::Value> locale_get_uiLanguages(v8::Local<v8::String>, const v8::AccessorInfo &info)
-{
- GET_LOCALE_DATA_RESOURCE(info.This());
-
- QStringList langs = r->locale.uiLanguages();
- v8::Handle<v8::Array> result = v8::Array::New(langs.size());
- for (int i = 0; i < langs.size(); ++i) {
- result->Set(i, r->engine->toString(langs.at(i)));
- }
-
- return result;
-}
-
-static v8::Handle<v8::Value> locale_currencySymbol(const v8::Arguments &args)
-{
- GET_LOCALE_DATA_RESOURCE(args.This());
-
- if (args.Length() > 1)
- V8THROW_ERROR("Locale: currencySymbol(): Invalid arguments");
-
- QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol;
- if (args.Length() == 1) {
- quint32 intFormat = args[0]->ToNumber()->Value();
- format = QLocale::CurrencySymbolFormat(intFormat);
- }
-
- return r->engine->toString(r->locale.currencySymbol(format));
-}
-
-#define LOCALE_FORMAT(FUNC) \
-static v8::Handle<v8::Value> locale_ ##FUNC (const v8::Arguments &args) { \
- GET_LOCALE_DATA_RESOURCE(args.This());\
- if (args.Length() > 1) \
- V8THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \
- QLocale::FormatType format = QLocale::LongFormat;\
- if (args.Length() == 1) { \
- quint32 intFormat = args[0]->Uint32Value(); \
- format = QLocale::FormatType(intFormat); \
- } \
- return r->engine->toString(r->locale. FUNC (format)); \
-}
-
-LOCALE_FORMAT(dateTimeFormat)
-LOCALE_FORMAT(timeFormat)
-LOCALE_FORMAT(dateFormat)
-
-// +1 added to idx because JS is 0-based, whereas QLocale months begin at 1.
-#define LOCALE_FORMATTED_MONTHNAME(VARIABLE) \
-static v8::Handle<v8::Value> locale_ ## VARIABLE (const v8::Arguments &args) {\
- GET_LOCALE_DATA_RESOURCE(args.This()); \
- if (args.Length() < 1 || args.Length() > 2) \
- V8THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
- QLocale::FormatType enumFormat = QLocale::LongFormat; \
- int idx = args[0]->IntegerValue() + 1; \
- if (idx < 1 || idx > 12) \
- V8THROW_ERROR("Locale: Invalid month"); \
- QString name; \
- if (args.Length() == 2) { \
- if (args[1]->IsNumber()) { \
- quint32 intFormat = args[1]->IntegerValue(); \
- QLocale::FormatType format = QLocale::FormatType(intFormat); \
- name = r->locale. VARIABLE(idx, format); \
- } else { \
- V8THROW_ERROR("Locale: Invalid datetime format"); \
- } \
- } else { \
- name = r->locale. VARIABLE(idx, enumFormat); \
- } \
- return r->engine->toString(name); \
-}
-
-// 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date
-#define LOCALE_FORMATTED_DAYNAME(VARIABLE) \
-static v8::Handle<v8::Value> locale_ ## VARIABLE (const v8::Arguments &args) {\
- GET_LOCALE_DATA_RESOURCE(args.This()); \
- if (args.Length() < 1 || args.Length() > 2) \
- V8THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
- QLocale::FormatType enumFormat = QLocale::LongFormat; \
- int idx = args[0]->IntegerValue(); \
- if (idx < 0 || idx > 7) \
- V8THROW_ERROR("Locale: Invalid day"); \
- if (idx == 0) idx = 7; \
- QString name; \
- if (args.Length() == 2) { \
- if (args[1]->IsNumber()) { \
- quint32 intFormat = args[1]->ToNumber()->Value(); \
- QLocale::FormatType format = QLocale::FormatType(intFormat); \
- name = r->locale. VARIABLE(idx, format); \
- } else { \
- V8THROW_ERROR("Locale: Invalid datetime format"); \
- } \
- } else { \
- name = r->locale. VARIABLE(idx, enumFormat); \
- } \
- return r->engine->toString(name); \
-}
-
-
-#define LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(FT, VARIABLE, ENGINE) \
- FT->PrototypeTemplate()->Set(v8::String::New( #VARIABLE ), V8FUNCTION(locale_ ## VARIABLE, ENGINE));
-
-LOCALE_FORMATTED_MONTHNAME(monthName)
-LOCALE_FORMATTED_MONTHNAME(standaloneMonthName)
-LOCALE_FORMATTED_DAYNAME(dayName)
-LOCALE_FORMATTED_DAYNAME(standaloneDayName)
-
-#define LOCALE_STRING_PROPERTY(VARIABLE) static v8::Handle<v8::Value> locale_get_ ## VARIABLE (v8::Local<v8::String>, const v8::AccessorInfo &info) \
-{ \
- GET_LOCALE_DATA_RESOURCE(info.This()); \
- return r->engine->toString(r->locale. VARIABLE());\
-}
-
-#define LOCALE_REGISTER_STRING_ACCESSOR(FT, VARIABLE) \
- FT ->PrototypeTemplate()->SetAccessor( v8::String::New( #VARIABLE ), locale_get_ ## VARIABLE )
-
-
-LOCALE_STRING_PROPERTY(name)
-LOCALE_STRING_PROPERTY(nativeLanguageName)
-LOCALE_STRING_PROPERTY(nativeCountryName)
-LOCALE_STRING_PROPERTY(decimalPoint)
-LOCALE_STRING_PROPERTY(groupSeparator)
-LOCALE_STRING_PROPERTY(percent)
-LOCALE_STRING_PROPERTY(zeroDigit)
-LOCALE_STRING_PROPERTY(negativeSign)
-LOCALE_STRING_PROPERTY(positiveSign)
-LOCALE_STRING_PROPERTY(exponential)
-LOCALE_STRING_PROPERTY(amText)
-LOCALE_STRING_PROPERTY(pmText)
-
-class QV8LocaleDataDeletable : public QV8Engine::Deletable
-{
-public:
- QV8LocaleDataDeletable(QV8Engine *engine);
- ~QV8LocaleDataDeletable();
-
- v8::Persistent<v8::Function> constructor;
-};
-
-QV8LocaleDataDeletable::QV8LocaleDataDeletable(QV8Engine *engine)
-{
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetHasExternalResource(true);
-
- LOCALE_REGISTER_STRING_ACCESSOR(ft, name);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, nativeLanguageName);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, nativeCountryName);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, decimalPoint);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, groupSeparator);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, percent);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, zeroDigit);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, negativeSign);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, positiveSign);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, exponential);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, amText);
- LOCALE_REGISTER_STRING_ACCESSOR(ft, pmText);
-
- ft->PrototypeTemplate()->Set(v8::String::New("currencySymbol"), V8FUNCTION(locale_currencySymbol, engine));
-
- ft->PrototypeTemplate()->Set(v8::String::New("dateTimeFormat"), V8FUNCTION(locale_dateTimeFormat, engine));
- ft->PrototypeTemplate()->Set(v8::String::New("dateFormat"), V8FUNCTION(locale_dateFormat, engine));
- ft->PrototypeTemplate()->Set(v8::String::New("timeFormat"), V8FUNCTION(locale_timeFormat, engine));
-
- LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(ft, monthName, engine);
- LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(ft, standaloneMonthName, engine);
- LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(ft, dayName, engine);
- LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(ft, standaloneDayName, engine);
-
- ft->PrototypeTemplate()->SetAccessor(v8::String::New("firstDayOfWeek"), locale_get_firstDayOfWeek);
- ft->PrototypeTemplate()->SetAccessor(v8::String::New("weekDays"), locale_get_weekDays);
- ft->PrototypeTemplate()->SetAccessor(v8::String::New("measurementSystem"), locale_get_measurementSystem);
- ft->PrototypeTemplate()->SetAccessor(v8::String::New("textDirection"), locale_get_textDirection);
- ft->PrototypeTemplate()->SetAccessor(v8::String::New("uiLanguages"), locale_get_uiLanguages);
-
- constructor = qPersistentNew(ft->GetFunction());
-}
-
-QV8LocaleDataDeletable::~QV8LocaleDataDeletable()
-{
- qPersistentDispose(constructor);
-}
-
-V8_DEFINE_EXTENSION(QV8LocaleDataDeletable, localeV8Data);
-
-/*!
- \qmlclass Locale QDeclarativeLocale
- \inqmlmodule QtQuick 2
- \brief The Locale object provides locale specific properties and formatted data.
-
- The Locale object is created via the \l{QML:Qt::locale()}{Qt.locale()} function. It cannot be created
- directly.
-
- The \l{QML:Qt::locale()}{Qt.locale()} function returns a JS Locale object representing the
- locale with the specified name, which has the format
- "language[_territory][.codeset][@modifier]" or "C".
-
- Locale supports the concept of a default locale, which is
- determined from the system's locale settings at application
- startup. If no parameter is passed to Qt.locale() the default
- locale object is returned.
-
- The Locale object provides a number of functions and properties
- providing data for the specified locale.
-
- The Locale object may also be passed to the \l Date and \l Number toLocaleString()
- and fromLocaleString() methods in order to convert to/from strings using
- the specified locale.
-
- This example shows the current date formatted for the German locale:
-
- \code
- import QtQuick 2.0
-
- Text {
- text: "The date is: " + Date().toLocaleString(Qt.locale("de_DE"))
- }
- \endcode
-
- The following example displays the specified number
- in the correct format for the default locale:
-
- \code
- import QtQuick 2.0
-
- Text {
- text: "The value is: " + Number(23443.34).toLocaleString(Qt.locale())
- }
- \endcode
-
- QtQuick Locale's data is based on Common Locale Data Repository v1.8.1.
-
- The double-to-string and string-to-double conversion functions are
- covered by the following licenses:
-
- \legalese
- Copyright (c) 1991 by AT&T.
-
- Permission to use, copy, modify, and distribute this software for any
- purpose without fee is hereby granted, provided that this entire notice
- is included in all copies of any software which is or includes a copy
- or modification of this software and in all copies of the supporting
- documentation for such software.
-
- THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
- REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
- OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
-
- This product includes software developed by the University of
- California, Berkeley and its contributors.
-
- \sa {QtQuick2::Date}{Date} {QtQuick2::Number}{Number}
-*/
-
-QDeclarativeLocale::QDeclarativeLocale()
-{
-}
-
-QDeclarativeLocale::~QDeclarativeLocale()
-{
-}
-
-v8::Handle<v8::Value> QDeclarativeLocale::locale(QV8Engine *v8engine, const QString &locale)
-{
- QV8LocaleDataDeletable *d = localeV8Data(v8engine);
- v8::Local<v8::Object> v8Value = d->constructor->NewInstance();
- QV8LocaleDataResource *r = new QV8LocaleDataResource(v8engine);
- if (locale.isEmpty())
- r->locale = QLocale();
- else
- r->locale = QLocale(locale);
- v8Value->SetExternalResource(r);
-
- return v8Value;
-}
-
-static const char *localeCompareFunction =
- "(function(localeCompareFunc) { "
- " var orig_localeCompare;"
- " orig_localeCompare = String.prototype.localeCompare;"
- " String.prototype.localeCompare = (function() {"
- " var val = localeCompareFunc.apply(this, arguments);"
- " if (val == undefined) val = orig_localeCompare.call(this);"
- " return val;"
- " })"
- "})";
-
-void QDeclarativeLocale::registerStringLocaleCompare(QV8Engine *engine)
-{
- registerFunction(engine, localeCompareFunction, localeCompare);
-}
-
-v8::Handle<v8::Value> QDeclarativeLocale::localeCompare(const v8::Arguments &args)
-{
- if (args.Length() != 1 || (!args[0]->IsString() && !args[0]->IsStringObject()))
- return v8::Undefined();
-
- if (!args.This()->IsString() && !args.This()->IsStringObject())
- return v8::Undefined();
-
- QString thisString = QJSConverter::toString(args.This()->ToString());
- QString thatString = QJSConverter::toString(args[0]->ToString());
-
- return v8::Integer::New(QString::localeAwareCompare(thisString, thatString));
-}
-
-/*!
- \enum QtQuick2::Locale::FormatType
-
- This enumeration describes the types of format that can be used when
- converting Date objects to strings.
-
- \value LongFormat The long version of day and month names; for
- example, returning "January" as a month name.
-
- \value ShortFormat The short version of day and month names; for
- example, returning "Jan" as a month name.
-
- \value NarrowFormat A special version of day and month names for
- use when space is limited; for example, returning "J" as a month
- name. Note that the narrow format might contain the same text for
- different months and days or it can even be an empty string if the
- locale doesn't support narrow names, so you should avoid using it
- for date formatting. Also, for the system locale this format is
- the same as ShortFormat.
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::name
-
- Holds the language and country of this locale as a
- string of the form "language_country", where
- language is a lowercase, two-letter ISO 639 language code,
- and country is an uppercase, two- or three-letter ISO 3166 country code.
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::decimalPoint
-
- Holds the decimal point character of this locale.
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::groupSeparator
-
- Holds the group separator character of this locale.
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::percent
-
- Holds the percent character of this locale.
-*/
-
-
-/*!
- \qmlproperty string QtQuick2::Locale::zeroDigit
-
- Holds Returns the zero digit character of this locale.
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::negativeSign
-
- Holds the negative sign character of this locale.
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::positiveSign
-
- Holds the positive sign character of this locale.
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::exponential
-
- Holds the exponential character of this locale.
-*/
-
-/*!
- \qmlmethod string QtQuick2::Locale::dateTimeFormat(type)
-
- Returns the date time format used for the current locale.
- \a type specifies the FormatType to return.
-
- \sa {QtQuick2::Date}{Date}
-*/
-
-/*!
- \qmlmethod string QtQuick2::Locale::dateFormat(type)
-
- Returns the date format used for the current locale.
- \a type specifies the FormatType to return.
-
- \sa {QtQuick2::Date}{Date}
-*/
-
-/*!
- \qmlmethod string QtQuick2::Locale::timeFormat(type)
-
- Returns the time format used for the current locale.
- \a type specifies the FormatType to return.
-
- \sa {QtQuick2::Date}{Date}
-*/
-
-/*!
- \qmlmethod string QtQuick2::Locale::monthName(month, type)
-
- Returns the localized name of \a month (0-11), in the optional
- \l FortmatType specified by \a type.
-
- \note the QLocale C++ API expects a range of (1-12), however Locale.monthName()
- expects 0-11 as per the JS Date object.
-
- \sa dayName(), standaloneMonthName()
-*/
-
-/*!
- \qmlmethod string QtQuick2::Locale::standaloneMonthName(month, type)
-
- Returns the localized name of \a month (0-11) that is used as a
- standalone text, in the optional \l FormatType specified by \a type.
-
- If the locale information doesn't specify the standalone month
- name then return value is the same as in monthName().
-
- \note the QLocale C++ API expects a range of (1-12), however Locale.standaloneMonthName()
- expects 0-11 as per the JS Date object.
-
- \sa monthName(), standaloneDayName()
-*/
-
-/*!
- \qmlmethod string QtQuick2::Locale::dayName(day, type)
-
- Returns the localized name of the \a day (where 0 represents
- Sunday, 1 represents Monday and so on), in the optional
- \l FormatType specified by \a type.
-
- \sa monthName(), standaloneDayName()
-*/
-
-/*!
- \qmlmethod string QtQuick2::Locale::standaloneDayName(day, type)
-
- Returns the localized name of the \a day (where 0 represents
- Sunday, 1 represents Monday and so on) that is used as a
- standalone text, in the \l FormatType specified by \a type.
-
- If the locale information does not specify the standalone day
- name then return value is the same as in dayName().
-
- \sa dayName(), standaloneMonthName()
-*/
-
-/*!
- \qmlproperty enumeration QtQuick2::Locale::firstDayOfWeek
-
- Holds the first day of the week according to the current locale.
-
- \list
- \o Locale.Sunday = 0
- \o Locale.Monday = 1
- \o Locale.Tuesday = 2
- \o Locale.Wednesday = 3
- \o Locale.Thursday = 4
- \o Locale.Friday = 5
- \o Locale.Saturday = 6
- \endlist
-
- \note that these values match the JS Date API which is different
- from the Qt C++ API where Qt::Sunday = 7.
-*/
-
-/*!
- \qmlproperty Array<int> QtQuick2::Locale::weekDays
-
- Holds an array of days that are considered week days according to the current locale,
- where Sunday is 0 and Saturday is 6.
-
- \sa firstDayOfWeek
-*/
-
-/*!
- \qmlproperty Array<string> QtQuick2::Locale::uiLanguages
-
- Returns an ordered list of locale names for translation purposes in
- preference order.
-
- The return value represents locale names that the user expects to see the
- UI translation in.
-
- The first item in the list is the most preferred one.
-*/
-
-/*!
- \qmlproperty enumeration QtQuick2::Locale::textDirection
-
- Holds the text direction of the language:
- \list
- \o Qt.LeftToRight
- \o Qt.RightToLeft
- \endlist
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::amText
-
- The localized name of the "AM" suffix for times specified using the conventions of the 12-hour clock.
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::pmText
-
- The localized name of the "PM" suffix for times specified using the conventions of the 12-hour clock.
-*/
-
-/*!
- \qmlmethod string QtQuick2::Locale::currencySymbol(format)
-
- Returns the currency symbol for the specified \a format:
- \list
- \o Locale.CurrencyIsoCode a ISO-4217 code of the currency.
- \o Locale.CurrencySymbol a currency symbol.
- \o Locale.CurrencyDisplayName a user readable name of the currency.
- \endlist
- \sa Number::toLocaleCurrencyString()
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::nativeLanguageName
-
- Holds a native name of the language for the locale. For example
- "Schwiizertüütsch" for Swiss-German locale.
-
- \sa nativeCountryName
-*/
-
-/*!
- \qmlproperty string QtQuick2::Locale::nativeCountryName
-
- Holds a native name of the country for the locale. For example
- "España" for Spanish/Spain locale.
-
- \sa nativeLanguageName
-*/
-
-/*!
- \qmlproperty enumeration QtQuick2::Locale::measurementSystem
-
- This property defines which units are used for measurement.
-
- \list
- \o Locale.MetricSystem This value indicates metric units, such as meters,
- centimeters and millimeters.
- \o Locale.ImperialSystem This value indicates imperial units, such as inches and
- miles. There are several distinct imperial systems in the world; this
- value stands for the official United States imperial units.
- \endlist
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativelocale_p.h b/src/declarative/qml/qdeclarativelocale_p.h
deleted file mode 100644
index 98370fbf8a..0000000000
--- a/src/declarative/qml/qdeclarativelocale_p.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELOCALE_H
-#define QDECLARATIVELOCALE_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/qlocale.h>
-#include <QtCore/qobject.h>
-#include <private/qv8engine_p.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeDateExtension
-{
-public:
- static void registerExtension(QV8Engine *engine);
-
-private:
- static v8::Handle<v8::Value> toLocaleString(const v8::Arguments& args);
- static v8::Handle<v8::Value> toLocaleTimeString(const v8::Arguments& args);
- static v8::Handle<v8::Value> toLocaleDateString(const v8::Arguments& args);
- static v8::Handle<v8::Value> fromLocaleString(const v8::Arguments& args);
- static v8::Handle<v8::Value> fromLocaleTimeString(const v8::Arguments& args);
- static v8::Handle<v8::Value> fromLocaleDateString(const v8::Arguments& args);
-};
-
-
-class QDeclarativeNumberExtension
-{
-public:
- static void registerExtension(QV8Engine *engine);
-
-private:
- static v8::Handle<v8::Value> toLocaleString(const v8::Arguments& args);
- static v8::Handle<v8::Value> fromLocaleString(const v8::Arguments& args);
- static v8::Handle<v8::Value> toLocaleCurrencyString(const v8::Arguments& args);
-};
-
-
-class Q_AUTOTEST_EXPORT QDeclarativeLocale
-{
- Q_GADGET
- Q_ENUMS(MeasurementSystem)
- Q_ENUMS(FormatType)
- Q_ENUMS(CurrencySymbolFormat)
- Q_ENUMS(DayOfWeek)
-
-public:
- ~QDeclarativeLocale();
-
- enum MeasurementSystem {
- MetricSystem = QLocale::MetricSystem,
- ImperialSystem = QLocale::ImperialSystem
- };
- enum FormatType {
- LongFormat = QLocale::LongFormat,
- ShortFormat = QLocale::ShortFormat,
- NarrowFormat = QLocale::NarrowFormat
- };
- enum CurrencySymbolFormat {
- CurrencyIsoCode = QLocale::CurrencyIsoCode,
- CurrencySymbol = QLocale::CurrencySymbol,
- CurrencyDisplayName = QLocale::CurrencyDisplayName
- };
- // Qt defines Sunday as 7, but JS Date assigns Sunday 0
- enum DayOfWeek {
- Sunday = 0,
- Monday = Qt::Monday,
- Tuesday = Qt::Tuesday,
- Wednesday = Qt::Wednesday,
- Thursday = Qt::Thursday,
- Friday = Qt::Friday,
- Saturday = Qt::Saturday
- };
-
- static v8::Handle<v8::Value> locale(QV8Engine *v8engine, const QString &lang);
-
- static void registerStringLocaleCompare(QV8Engine *engine);
-
-private:
- QDeclarativeLocale();
-
- static v8::Handle<v8::Value> localeCompare(const v8::Arguments &args);
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
deleted file mode 100644
index ac9d23184f..0000000000
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ /dev/null
@@ -1,1359 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtDeclarative/qdeclarativeprivate.h>
-#include "qdeclarativemetatype_p.h"
-
-#include <private/qdeclarativeproxymetaobject_p.h>
-#include <private/qdeclarativecustomparser_p.h>
-#include <private/qdeclarativeguard_p.h>
-#include <private/qhashedstring_p.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qmetaobject.h>
-#include <QtCore/qbitarray.h>
-#include <QtCore/qreadwritelock.h>
-#include <QtCore/private/qmetaobject_p.h>
-
-#include <qmetatype.h>
-#include <qobjectdefs.h>
-#include <qbytearray.h>
-#include <qreadwritelock.h>
-#include <qstring.h>
-#include <qstringlist.h>
-#include <qvector.h>
-
-#include <ctype.h>
-
-QT_BEGIN_NAMESPACE
-
-struct QDeclarativeMetaTypeData
-{
- QDeclarativeMetaTypeData();
- ~QDeclarativeMetaTypeData();
- QList<QDeclarativeType *> types;
- typedef QHash<int, QDeclarativeType *> Ids;
- Ids idToType;
- typedef QHash<QString, QDeclarativeType *> Names;
- Names nameToType;
- typedef QHash<const QMetaObject *, QDeclarativeType *> MetaObjects;
- MetaObjects metaObjectToType;
- typedef QHash<int, QDeclarativeMetaType::StringConverter> StringConverters;
- StringConverters stringConverters;
-
- struct VersionedUri {
- VersionedUri()
- : majorVersion(0) {}
- VersionedUri(const QString &uri, int majorVersion)
- : uri(uri), majorVersion(majorVersion) {}
- bool operator==(const VersionedUri &other) const {
- return other.majorVersion == majorVersion && other.uri == uri;
- }
- QString uri;
- int majorVersion;
- };
- typedef QHash<VersionedUri, QDeclarativeTypeModule *> TypeModules;
- TypeModules uriToModule;
-
- struct ModuleApiList {
- ModuleApiList() : sorted(true) {}
- QList<QDeclarativeMetaType::ModuleApi> moduleApis;
- bool sorted;
- };
- typedef QHash<QString, ModuleApiList> ModuleApis;
- ModuleApis moduleApis;
- int moduleApiCount;
-
- QBitArray objects;
- QBitArray interfaces;
- QBitArray lists;
-
- QList<QDeclarativePrivate::AutoParentFunction> parentFunctions;
-};
-
-class QDeclarativeTypeModulePrivate
-{
-public:
- QDeclarativeTypeModulePrivate()
- : minMinorVersion(INT_MAX), maxMinorVersion(0) {}
-
- QDeclarativeMetaTypeData::VersionedUri uri;
-
- int minMinorVersion;
- int maxMinorVersion;
-
- void add(QDeclarativeType *);
-
- QStringHash<QList<QDeclarativeType *> > typeHash;
- QList<QDeclarativeType *> types;
-};
-
-Q_GLOBAL_STATIC(QDeclarativeMetaTypeData, metaTypeData)
-Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock)
-
-static uint qHash(const QDeclarativeMetaTypeData::VersionedUri &v)
-{
- return qHash(v.uri) ^ qHash(v.majorVersion);
-}
-
-QDeclarativeMetaTypeData::QDeclarativeMetaTypeData()
-: moduleApiCount(0)
-{
-}
-
-QDeclarativeMetaTypeData::~QDeclarativeMetaTypeData()
-{
- for (int i = 0; i < types.count(); ++i)
- delete types.at(i);
-}
-
-class QDeclarativeTypePrivate
-{
-public:
- QDeclarativeTypePrivate();
-
- void init() const;
- void initEnums() const;
-
- bool m_isInterface : 1;
- const char *m_iid;
- QString m_module;
- QString m_name;
- QString m_elementName;
- int m_version_maj;
- int m_version_min;
- int m_typeId; int m_listId;
- int m_revision;
- mutable bool m_containsRevisionedAttributes;
- mutable QDeclarativeType *m_superType;
-
- int m_allocationSize;
- void (*m_newFunc)(void *);
- QString m_noCreationReason;
-
- const QMetaObject *m_baseMetaObject;
- QDeclarativeAttachedPropertiesFunc m_attachedPropertiesFunc;
- const QMetaObject *m_attachedPropertiesType;
- int m_attachedPropertiesId;
- int m_parserStatusCast;
- int m_propertyValueSourceCast;
- int m_propertyValueInterceptorCast;
- QObject *(*m_extFunc)(QObject *);
- const QMetaObject *m_extMetaObject;
- int m_index;
- QDeclarativeCustomParser *m_customParser;
- mutable volatile bool m_isSetup:1;
- mutable volatile bool m_isEnumSetup:1;
- mutable bool m_haveSuperType:1;
- mutable QList<QDeclarativeProxyMetaObject::ProxyData> m_metaObjects;
- mutable QStringHash<int> m_enums;
-
- static QHash<const QMetaObject *, int> m_attachedPropertyIds;
-};
-
-QHash<const QMetaObject *, int> QDeclarativeTypePrivate::m_attachedPropertyIds;
-
-QDeclarativeTypePrivate::QDeclarativeTypePrivate()
-: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_revision(0), m_containsRevisionedAttributes(false),
- m_superType(0), m_allocationSize(0), m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0),
- m_attachedPropertiesType(0), m_parserStatusCast(-1), m_propertyValueSourceCast(-1),
- m_propertyValueInterceptorCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0),
- m_isSetup(false), m_isEnumSetup(false), m_haveSuperType(false)
-{
-}
-
-
-QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::RegisterInterface &interface)
-: d(new QDeclarativeTypePrivate)
-{
- d->m_isInterface = true;
- d->m_iid = interface.iid;
- d->m_typeId = interface.typeId;
- d->m_listId = interface.listId;
- d->m_newFunc = 0;
- d->m_index = index;
- d->m_isSetup = true;
- d->m_version_maj = 0;
- d->m_version_min = 0;
-}
-
-QDeclarativeType::QDeclarativeType(int index, const QDeclarativePrivate::RegisterType &type)
-: d(new QDeclarativeTypePrivate)
-{
- QString name = QString::fromUtf8(type.uri);
- if (type.uri) name += QLatin1Char('/');
- name += QString::fromUtf8(type.elementName);
-
- d->m_module = QString::fromUtf8(type.uri);
- d->m_name = name;
- d->m_version_maj = type.versionMajor;
- d->m_version_min = type.versionMinor;
- if (type.version >= 1) // revisions added in version 1
- d->m_revision = type.revision;
- d->m_typeId = type.typeId;
- d->m_listId = type.listId;
- d->m_allocationSize = type.objectSize;
- d->m_newFunc = type.create;
- d->m_noCreationReason = type.noCreationReason;
- d->m_baseMetaObject = type.metaObject;
- d->m_attachedPropertiesFunc = type.attachedPropertiesFunction;
- d->m_attachedPropertiesType = type.attachedPropertiesMetaObject;
- if (d->m_attachedPropertiesType) {
- QHash<const QMetaObject *, int>::Iterator iter = d->m_attachedPropertyIds.find(d->m_baseMetaObject);
- if (iter == d->m_attachedPropertyIds.end())
- iter = d->m_attachedPropertyIds.insert(d->m_baseMetaObject, index);
- d->m_attachedPropertiesId = *iter;
- } else {
- d->m_attachedPropertiesId = -1;
- }
- d->m_parserStatusCast = type.parserStatusCast;
- d->m_propertyValueSourceCast = type.valueSourceCast;
- d->m_propertyValueInterceptorCast = type.valueInterceptorCast;
- d->m_extFunc = type.extensionObjectCreate;
- d->m_index = index;
- d->m_customParser = type.customParser;
-
- if (type.extensionMetaObject)
- d->m_extMetaObject = type.extensionMetaObject;
-}
-
-QDeclarativeType::~QDeclarativeType()
-{
- delete d->m_customParser;
- delete d;
-}
-
-QString QDeclarativeType::module() const
-{
- return d->m_module;
-}
-
-int QDeclarativeType::majorVersion() const
-{
- return d->m_version_maj;
-}
-
-int QDeclarativeType::minorVersion() const
-{
- return d->m_version_min;
-}
-
-bool QDeclarativeType::availableInVersion(int vmajor, int vminor) const
-{
- Q_ASSERT(vmajor >= 0 && vminor >= 0);
- return vmajor == d->m_version_maj && vminor >= d->m_version_min;
-}
-
-bool QDeclarativeType::availableInVersion(const QString &module, int vmajor, int vminor) const
-{
- Q_ASSERT(vmajor >= 0 && vminor >= 0);
- return module == d->m_module && vmajor == d->m_version_maj && vminor >= d->m_version_min;
-}
-
-// returns the nearest _registered_ super class
-QDeclarativeType *QDeclarativeType::superType() const
-{
- if (!d->m_haveSuperType) {
- const QMetaObject *mo = d->m_baseMetaObject->superClass();
- while (mo && !d->m_superType) {
- d->m_superType = QDeclarativeMetaType::qmlType(mo, d->m_module, d->m_version_maj, d->m_version_min);
- mo = mo->superClass();
- }
- d->m_haveSuperType = true;
- }
-
- return d->m_superType;
-}
-
-static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
- const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
-{
- // Set classname
- builder.setClassName(ignoreEnd->className());
-
- // Clone Q_CLASSINFO
- for (int ii = mo->classInfoOffset(); ii < mo->classInfoCount(); ++ii) {
- QMetaClassInfo info = mo->classInfo(ii);
-
- int otherIndex = ignoreEnd->indexOfClassInfo(info.name());
- if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) {
- // Skip
- } else {
- builder.addClassInfo(info.name(), info.value());
- }
- }
-
- // Clone Q_PROPERTY
- for (int ii = mo->propertyOffset(); ii < mo->propertyCount(); ++ii) {
- QMetaProperty property = mo->property(ii);
-
- int otherIndex = ignoreEnd->indexOfProperty(property.name());
- if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) {
- builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void"));
- // Skip
- } else {
- builder.addProperty(property);
- }
- }
-
- // Clone Q_METHODS
- for (int ii = mo->methodOffset(); ii < mo->methodCount(); ++ii) {
- QMetaMethod method = mo->method(ii);
-
- // More complex - need to search name
- QByteArray name = method.signature();
- int parenIdx = name.indexOf('(');
- if (parenIdx != -1) name = name.left(parenIdx);
-
-
- bool found = false;
-
- for (int ii = ignoreStart->methodOffset() + ignoreStart->methodCount();
- !found && ii < ignoreEnd->methodOffset() + ignoreEnd->methodCount();
- ++ii) {
-
- QMetaMethod other = ignoreEnd->method(ii);
- QByteArray othername = other.signature();
- int parenIdx = othername.indexOf('(');
- if (parenIdx != -1) othername = othername.left(parenIdx);
-
- found = name == othername;
- }
-
- QMetaMethodBuilder m = builder.addMethod(method);
- if (found) // SKIP
- m.setAccess(QMetaMethod::Private);
- }
-
- // Clone Q_ENUMS
- for (int ii = mo->enumeratorOffset(); ii < mo->enumeratorCount(); ++ii) {
- QMetaEnum enumerator = mo->enumerator(ii);
-
- int otherIndex = ignoreEnd->indexOfEnumerator(enumerator.name());
- if (otherIndex >= ignoreStart->enumeratorOffset() + ignoreStart->enumeratorCount()) {
- // Skip
- } else {
- builder.addEnumerator(enumerator);
- }
- }
-}
-
-static bool isPropertyRevisioned(const QMetaObject *mo, int index)
-{
- int i = index;
- i -= mo->propertyOffset();
- if (i < 0 && mo->d.superdata)
- return isPropertyRevisioned(mo->d.superdata, index);
-
- const QMetaObjectPrivate *mop = reinterpret_cast<const QMetaObjectPrivate*>(mo->d.data);
- if (i >= 0 && i < mop->propertyCount) {
- int handle = mop->propertyData + 3*i;
- int flags = mo->d.data[handle + 2];
-
- return (flags & Revisioned);
- }
-
- return false;
-}
-
-void QDeclarativeTypePrivate::init() const
-{
- if (m_isSetup) return;
-
- QWriteLocker lock(metaTypeDataLock());
- if (m_isSetup)
- return;
-
- // Setup extended meta object
- // XXX - very inefficient
- const QMetaObject *mo = m_baseMetaObject;
- if (m_extFunc) {
- QMetaObjectBuilder builder;
- clone(builder, m_extMetaObject, m_extMetaObject, m_extMetaObject);
- builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
- QMetaObject *mmo = builder.toMetaObject();
- mmo->d.superdata = mo;
- QDeclarativeProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0, 0 };
- m_metaObjects << data;
- }
-
- mo = mo->d.superdata;
- while(mo) {
- QDeclarativeType *t = metaTypeData()->metaObjectToType.value(mo);
- if (t) {
- if (t->d->m_extFunc) {
- QMetaObjectBuilder builder;
- clone(builder, t->d->m_extMetaObject, t->d->m_baseMetaObject, m_baseMetaObject);
- builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
- QMetaObject *mmo = builder.toMetaObject();
- mmo->d.superdata = m_baseMetaObject;
- if (!m_metaObjects.isEmpty())
- m_metaObjects.last().metaObject->d.superdata = mmo;
- QDeclarativeProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0, 0 };
- m_metaObjects << data;
- }
- }
- mo = mo->d.superdata;
- }
-
- for (int ii = 0; ii < m_metaObjects.count(); ++ii) {
- m_metaObjects[ii].propertyOffset =
- m_metaObjects.at(ii).metaObject->propertyOffset();
- m_metaObjects[ii].methodOffset =
- m_metaObjects.at(ii).metaObject->methodOffset();
- }
-
- // Check for revisioned details
- {
- const QMetaObject *mo = 0;
- if (m_metaObjects.isEmpty())
- mo = m_baseMetaObject;
- else
- mo = m_metaObjects.first().metaObject;
-
- for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->propertyCount(); ++ii) {
- if (isPropertyRevisioned(mo, ii))
- m_containsRevisionedAttributes = true;
- }
-
- for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->methodCount(); ++ii) {
- if (mo->method(ii).revision() != 0)
- m_containsRevisionedAttributes = true;
- }
- }
-
- m_isSetup = true;
- lock.unlock();
-}
-
-void QDeclarativeTypePrivate::initEnums() const
-{
- if (m_isEnumSetup) return;
-
- init();
-
- QWriteLocker lock(metaTypeDataLock());
- if (m_isEnumSetup) return;
-
- const QMetaObject *metaObject = m_baseMetaObject;
- for (int ii = 0; ii < metaObject->enumeratorCount(); ++ii) {
-
- QMetaEnum e = metaObject->enumerator(ii);
-
- for (int jj = 0; jj < e.keyCount(); ++jj)
- m_enums.insert(QString::fromUtf8(e.key(jj)), e.value(jj));
- }
-
- m_isEnumSetup = true;
-}
-
-QByteArray QDeclarativeType::typeName() const
-{
- if (d->m_baseMetaObject)
- return d->m_baseMetaObject->className();
- else
- return QByteArray();
-}
-
-const QString &QDeclarativeType::elementName() const
-{
- if (d->m_elementName.isEmpty()) {
- QString n = qmlTypeName();
- int idx = n.lastIndexOf(QLatin1Char('/'));
- d->m_elementName = n.mid(idx + 1);
- }
- return d->m_elementName;
-}
-
-const QString &QDeclarativeType::qmlTypeName() const
-{
- return d->m_name;
-}
-
-QObject *QDeclarativeType::create() const
-{
- d->init();
-
- QObject *rv = (QObject *)operator new(d->m_allocationSize);
- d->m_newFunc(rv);
-
- if (rv && !d->m_metaObjects.isEmpty())
- (void *)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects);
-
- return rv;
-}
-
-void QDeclarativeType::create(QObject **out, void **memory, size_t additionalMemory) const
-{
- d->init();
-
- QObject *rv = (QObject *)operator new(d->m_allocationSize + additionalMemory);
- d->m_newFunc(rv);
-
- if (rv && !d->m_metaObjects.isEmpty())
- (void *)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects);
-
- *out = rv;
- *memory = ((char *)rv) + d->m_allocationSize;
-}
-
-QDeclarativeCustomParser *QDeclarativeType::customParser() const
-{
- return d->m_customParser;
-}
-
-QDeclarativeType::CreateFunc QDeclarativeType::createFunction() const
-{
- return d->m_newFunc;
-}
-
-QString QDeclarativeType::noCreationReason() const
-{
- return d->m_noCreationReason;
-}
-
-int QDeclarativeType::createSize() const
-{
- return d->m_allocationSize;
-}
-
-bool QDeclarativeType::isCreatable() const
-{
- return d->m_newFunc != 0;
-}
-
-bool QDeclarativeType::isExtendedType() const
-{
- d->init();
-
- return !d->m_metaObjects.isEmpty();
-}
-
-bool QDeclarativeType::isInterface() const
-{
- return d->m_isInterface;
-}
-
-int QDeclarativeType::typeId() const
-{
- return d->m_typeId;
-}
-
-int QDeclarativeType::qListTypeId() const
-{
- return d->m_listId;
-}
-
-const QMetaObject *QDeclarativeType::metaObject() const
-{
- d->init();
-
- if (d->m_metaObjects.isEmpty())
- return d->m_baseMetaObject;
- else
- return d->m_metaObjects.first().metaObject;
-
-}
-
-const QMetaObject *QDeclarativeType::baseMetaObject() const
-{
- return d->m_baseMetaObject;
-}
-
-bool QDeclarativeType::containsRevisionedAttributes() const
-{
- d->init();
-
- return d->m_containsRevisionedAttributes;
-}
-
-int QDeclarativeType::metaObjectRevision() const
-{
- return d->m_revision;
-}
-
-QDeclarativeAttachedPropertiesFunc QDeclarativeType::attachedPropertiesFunction() const
-{
- return d->m_attachedPropertiesFunc;
-}
-
-const QMetaObject *QDeclarativeType::attachedPropertiesType() const
-{
- return d->m_attachedPropertiesType;
-}
-
-/*
-This is the id passed to qmlAttachedPropertiesById(). This is different from the index
-for the case that a single class is registered under two or more names (eg. Item in
-Qt 4.7 and QtQuick 1.0).
-*/
-int QDeclarativeType::attachedPropertiesId() const
-{
- return d->m_attachedPropertiesId;
-}
-
-int QDeclarativeType::parserStatusCast() const
-{
- return d->m_parserStatusCast;
-}
-
-int QDeclarativeType::propertyValueSourceCast() const
-{
- return d->m_propertyValueSourceCast;
-}
-
-int QDeclarativeType::propertyValueInterceptorCast() const
-{
- return d->m_propertyValueInterceptorCast;
-}
-
-const char *QDeclarativeType::interfaceIId() const
-{
- return d->m_iid;
-}
-
-int QDeclarativeType::index() const
-{
- return d->m_index;
-}
-
-int QDeclarativeType::enumValue(const QHashedStringRef &name) const
-{
- d->initEnums();
-
- int *rv = d->m_enums.value(name);
- return rv?*rv:-1;
-}
-
-int QDeclarativeType::enumValue(const QHashedV8String &name) const
-{
- d->initEnums();
-
- int *rv = d->m_enums.value(name);
- return rv?*rv:-1;
-}
-
-QDeclarativeTypeModule::QDeclarativeTypeModule()
-: d(new QDeclarativeTypeModulePrivate)
-{
-}
-
-QDeclarativeTypeModule::~QDeclarativeTypeModule()
-{
- delete d; d = 0;
-}
-
-QString QDeclarativeTypeModule::module() const
-{
- return d->uri.uri;
-}
-
-int QDeclarativeTypeModule::majorVersion() const
-{
- return d->uri.majorVersion;
-}
-
-int QDeclarativeTypeModule::minimumMinorVersion() const
-{
- return d->minMinorVersion;
-}
-
-int QDeclarativeTypeModule::maximumMinorVersion() const
-{
- return d->maxMinorVersion;
-}
-
-void QDeclarativeTypeModulePrivate::add(QDeclarativeType *type)
-{
- types << type;
-
- minMinorVersion = qMin(minMinorVersion, type->minorVersion());
- maxMinorVersion = qMax(maxMinorVersion, type->minorVersion());
-
- QList<QDeclarativeType *> &list = typeHash[type->elementName()];
- for (int ii = 0; ii < list.count(); ++ii) {
- if (list.at(ii)->minorVersion() < type->minorVersion()) {
- list.insert(ii, type);
- return;
- }
- }
- list.append(type);
-}
-
-QList<QDeclarativeType *> QDeclarativeTypeModule::types()
-{
- QList<QDeclarativeType *> rv;
- QReadLocker lock(metaTypeDataLock());
- rv = d->types;
- return rv;
-}
-
-QList<QDeclarativeType *> QDeclarativeTypeModule::type(const QString &name)
-{
- QReadLocker lock(metaTypeDataLock());
- QList<QDeclarativeType *> rv;
- for (int ii = 0; ii < d->types.count(); ++ii) {
- if (d->types.at(ii)->elementName() == name)
- rv << d->types.at(ii);
- }
- return rv;
-}
-
-QDeclarativeType *QDeclarativeTypeModule::type(const QHashedStringRef &name, int minor)
-{
- QReadLocker lock(metaTypeDataLock());
-
- QList<QDeclarativeType *> *types = d->typeHash.value(name);
- if (!types) return 0;
-
- for (int ii = 0; ii < types->count(); ++ii)
- if (types->at(ii)->minorVersion() <= minor)
- return types->at(ii);
-
- return 0;
-}
-
-QDeclarativeType *QDeclarativeTypeModule::type(const QHashedV8String &name, int minor)
-{
- QReadLocker lock(metaTypeDataLock());
-
- QList<QDeclarativeType *> *types = d->typeHash.value(name);
- if (!types) return 0;
-
- for (int ii = 0; ii < types->count(); ++ii)
- if (types->at(ii)->minorVersion() <= minor)
- return types->at(ii);
-
- return 0;
-}
-
-
-QDeclarativeTypeModuleVersion::QDeclarativeTypeModuleVersion()
-: m_module(0), m_minor(0)
-{
-}
-
-QDeclarativeTypeModuleVersion::QDeclarativeTypeModuleVersion(QDeclarativeTypeModule *module, int minor)
-: m_module(module), m_minor(minor)
-{
- Q_ASSERT(m_module);
- Q_ASSERT(m_minor >= 0);
-}
-
-QDeclarativeTypeModuleVersion::QDeclarativeTypeModuleVersion(const QDeclarativeTypeModuleVersion &o)
-: m_module(o.m_module), m_minor(o.m_minor)
-{
-}
-
-QDeclarativeTypeModuleVersion &QDeclarativeTypeModuleVersion::operator=(const QDeclarativeTypeModuleVersion &o)
-{
- m_module = o.m_module;
- m_minor = o.m_minor;
- return *this;
-}
-
-QDeclarativeTypeModule *QDeclarativeTypeModuleVersion::module() const
-{
- return m_module;
-}
-
-int QDeclarativeTypeModuleVersion::minorVersion() const
-{
- return m_minor;
-}
-
-QDeclarativeType *QDeclarativeTypeModuleVersion::type(const QHashedStringRef &name) const
-{
- if (m_module) return m_module->type(name, m_minor);
- else return 0;
-}
-
-QDeclarativeType *QDeclarativeTypeModuleVersion::type(const QHashedV8String &name) const
-{
- if (m_module) return m_module->type(name, m_minor);
- else return 0;
-}
-
-
-int registerAutoParentFunction(QDeclarativePrivate::RegisterAutoParent &autoparent)
-{
- QWriteLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- data->parentFunctions.append(autoparent.function);
-
- return data->parentFunctions.count() - 1;
-}
-
-int registerInterface(const QDeclarativePrivate::RegisterInterface &interface)
-{
- if (interface.version > 0)
- qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
-
- QWriteLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- int index = data->types.count();
-
- QDeclarativeType *type = new QDeclarativeType(index, interface);
-
- data->types.append(type);
- data->idToType.insert(type->typeId(), type);
- data->idToType.insert(type->qListTypeId(), type);
- // XXX No insertMulti, so no multi-version interfaces?
- if (!type->qmlTypeName().isEmpty())
- data->nameToType.insert(type->qmlTypeName(), type);
-
- if (data->interfaces.size() <= interface.typeId)
- data->interfaces.resize(interface.typeId + 16);
- if (data->lists.size() <= interface.listId)
- data->lists.resize(interface.listId + 16);
- data->interfaces.setBit(interface.typeId, true);
- data->lists.setBit(interface.listId, true);
-
- return index;
-}
-
-int registerType(const QDeclarativePrivate::RegisterType &type)
-{
- if (type.elementName) {
- for (int ii = 0; type.elementName[ii]; ++ii) {
- if (!isalnum(type.elementName[ii])) {
- qWarning("qmlRegisterType(): Invalid QML element name \"%s\"", type.elementName);
- return -1;
- }
- }
- }
-
- QWriteLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- int index = data->types.count();
-
- QDeclarativeType *dtype = new QDeclarativeType(index, type);
-
- data->types.append(dtype);
- data->idToType.insert(dtype->typeId(), dtype);
- if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
-
- if (!dtype->qmlTypeName().isEmpty())
- data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
-
- data->metaObjectToType.insertMulti(dtype->baseMetaObject(), dtype);
-
- if (data->objects.size() <= type.typeId)
- data->objects.resize(type.typeId + 16);
- if (data->lists.size() <= type.listId)
- data->lists.resize(type.listId + 16);
- data->objects.setBit(type.typeId, true);
- if (type.listId) data->lists.setBit(type.listId, true);
-
- if (type.uri) {
- QString mod = QString::fromUtf8(type.uri);
-
- QDeclarativeMetaTypeData::VersionedUri versionedUri(mod, type.versionMajor);
- QDeclarativeTypeModule *module = data->uriToModule.value(versionedUri);
- if (!module) {
- module = new QDeclarativeTypeModule;
- module->d->uri = versionedUri;
- data->uriToModule.insert(versionedUri, module);
- }
- module->d->add(dtype);
- }
-
- return index;
-}
-
-int registerModuleApi(const QDeclarativePrivate::RegisterModuleApi &api)
-{
- QWriteLocker lock(metaTypeDataLock());
-
- QDeclarativeMetaTypeData *data = metaTypeData();
- QString uri = QString::fromUtf8(api.uri);
- QDeclarativeMetaType::ModuleApi import;
- import.major = api.versionMajor;
- import.minor = api.versionMinor;
- import.script = api.scriptApi;
- import.qobject = api.qobjectApi;
-
- int index = data->moduleApiCount++;
-
- QDeclarativeMetaTypeData::ModuleApis::Iterator iter = data->moduleApis.find(uri);
- if (iter == data->moduleApis.end()) {
- QDeclarativeMetaTypeData::ModuleApiList apis;
- apis.moduleApis << import;
- data->moduleApis.insert(uri, apis);
- } else {
- iter->moduleApis << import;
- iter->sorted = false;
- }
-
- return index;
-}
-
-
-/*
-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));
- } else if (type == ModuleApiRegistration) {
- return registerModuleApi(*reinterpret_cast<RegisterModuleApi *>(data));
- }
- return -1;
-}
-
-/*
- Returns true if a module \a uri of any version is installed.
-*/
-bool QDeclarativeMetaType::isAnyModule(const QString &uri)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- for (QDeclarativeMetaTypeData::TypeModules::ConstIterator iter = data->uriToModule.begin();
- iter != data->uriToModule.end(); ++iter) {
- if ((*iter)->module() == uri)
- return true;
- }
-
- return false;
-}
-
-/*
- Returns true if any type or API has been registered for the given \a module with at least
- versionMajor.versionMinor, or if types have been registered for \a module with at most
- versionMajor.versionMinor.
-
- So if only 4.7 and 4.9 have been registered, 4.7,4.8, and 4.9 are valid, but not 4.6 nor 4.10.
-*/
-bool QDeclarativeMetaType::isModule(const QString &module, int versionMajor, int versionMinor)
-{
- Q_ASSERT(versionMajor >= 0 && versionMinor >= 0);
- QReadLocker lock(metaTypeDataLock());
-
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- // first, check Types
- QDeclarativeTypeModule *tm =
- data->uriToModule.value(QDeclarativeMetaTypeData::VersionedUri(module, versionMajor));
- if (tm && tm->minimumMinorVersion() <= versionMinor && tm->maximumMinorVersion() >= versionMinor)
- return true;
-
- // then, check ModuleApis
- foreach (const QDeclarativeMetaType::ModuleApi &mApi, data->moduleApis.value(module).moduleApis) {
- if (mApi.major == versionMajor && mApi.minor == versionMinor) // XXX is this correct?
- return true;
- }
-
- return false;
-}
-
-QDeclarativeTypeModule *QDeclarativeMetaType::typeModule(const QString &uri, int majorVersion)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- return data->uriToModule.value(QDeclarativeMetaTypeData::VersionedUri(uri, majorVersion));
-}
-
-QList<QDeclarativePrivate::AutoParentFunction> QDeclarativeMetaType::parentFunctions()
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- return data->parentFunctions;
-}
-
-static bool operator<(const QDeclarativeMetaType::ModuleApi &lhs, const QDeclarativeMetaType::ModuleApi &rhs)
-{
- return lhs.major < rhs.major || (lhs.major == rhs.major && lhs.minor < rhs.minor);
-}
-
-QDeclarativeMetaType::ModuleApi
-QDeclarativeMetaType::moduleApi(const QString &uri, int versionMajor, int versionMinor)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- QDeclarativeMetaTypeData::ModuleApis::Iterator iter = data->moduleApis.find(uri);
- if (iter == data->moduleApis.end())
- return ModuleApi();
-
- if (iter->sorted == false) {
- qSort(iter->moduleApis.begin(), iter->moduleApis.end());
- iter->sorted = true;
- }
-
- for (int ii = iter->moduleApis.count() - 1; ii >= 0; --ii) {
- const ModuleApi &import = iter->moduleApis.at(ii);
- if (import.major == versionMajor && import.minor <= versionMinor)
- return import;
- }
-
- return ModuleApi();
-}
-
-QHash<QString, QList<QDeclarativeMetaType::ModuleApi> > QDeclarativeMetaType::moduleApis()
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- QHash<QString, QList<ModuleApi> > moduleApis;
- QHashIterator<QString, QDeclarativeMetaTypeData::ModuleApiList> it(data->moduleApis);
- while (it.hasNext()) {
- it.next();
- moduleApis[it.key()] = it.value().moduleApis;
- }
-
- return moduleApis;
-}
-
-QObject *QDeclarativeMetaType::toQObject(const QVariant &v, bool *ok)
-{
- if (!isQObject(v.userType())) {
- if (ok) *ok = false;
- return 0;
- }
-
- if (ok) *ok = true;
-
- return *(QObject **)v.constData();
-}
-
-bool QDeclarativeMetaType::isQObject(int userType)
-{
- if (userType == QMetaType::QObjectStar)
- return true;
-
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- return userType >= 0 && userType < data->objects.size() && data->objects.testBit(userType);
-}
-
-/*
- Returns the item type for a list of type \a id.
- */
-int QDeclarativeMetaType::listType(int id)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- QDeclarativeType *type = data->idToType.value(id);
- if (type && type->qListTypeId() == id)
- return type->typeId();
- else
- return 0;
-}
-
-int QDeclarativeMetaType::attachedPropertiesFuncId(const QMetaObject *mo)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- QDeclarativeType *type = data->metaObjectToType.value(mo);
- if (type && type->attachedPropertiesFunction())
- return type->attachedPropertiesId();
- else
- return -1;
-}
-
-QDeclarativeAttachedPropertiesFunc QDeclarativeMetaType::attachedPropertiesFuncById(int id)
-{
- if (id < 0)
- return 0;
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- return data->types.at(id)->attachedPropertiesFunction();
-}
-
-QMetaProperty QDeclarativeMetaType::defaultProperty(const QMetaObject *metaObject)
-{
- int idx = metaObject->indexOfClassInfo("DefaultProperty");
- if (-1 == idx)
- return QMetaProperty();
-
- QMetaClassInfo info = metaObject->classInfo(idx);
- if (!info.value())
- return QMetaProperty();
-
- idx = metaObject->indexOfProperty(info.value());
- if (-1 == idx)
- return QMetaProperty();
-
- return metaObject->property(idx);
-}
-
-QMetaProperty QDeclarativeMetaType::defaultProperty(QObject *obj)
-{
- if (!obj)
- return QMetaProperty();
-
- const QMetaObject *metaObject = obj->metaObject();
- return defaultProperty(metaObject);
-}
-
-QMetaMethod QDeclarativeMetaType::defaultMethod(const QMetaObject *metaObject)
-{
- int idx = metaObject->indexOfClassInfo("DefaultMethod");
- if (-1 == idx)
- return QMetaMethod();
-
- QMetaClassInfo info = metaObject->classInfo(idx);
- if (!info.value())
- return QMetaMethod();
-
- idx = metaObject->indexOfMethod(info.value());
- if (-1 == idx)
- return QMetaMethod();
-
- return metaObject->method(idx);
-}
-
-QMetaMethod QDeclarativeMetaType::defaultMethod(QObject *obj)
-{
- if (!obj)
- return QMetaMethod();
-
- const QMetaObject *metaObject = obj->metaObject();
- return defaultMethod(metaObject);
-}
-
-QDeclarativeMetaType::TypeCategory QDeclarativeMetaType::typeCategory(int userType)
-{
- if (userType < 0)
- return Unknown;
- if (userType == QMetaType::QObjectStar)
- return Object;
-
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- if (userType < data->objects.size() && data->objects.testBit(userType))
- return Object;
- else if (userType < data->lists.size() && data->lists.testBit(userType))
- return List;
- else
- return Unknown;
-}
-
-bool QDeclarativeMetaType::isInterface(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- return userType >= 0 && userType < data->interfaces.size() && data->interfaces.testBit(userType);
-}
-
-const char *QDeclarativeMetaType::interfaceIId(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- QDeclarativeType *type = data->idToType.value(userType);
- lock.unlock();
- if (type && type->isInterface() && type->typeId() == userType)
- return type->interfaceIId();
- else
- return 0;
-}
-
-bool QDeclarativeMetaType::isList(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
- return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType);
-}
-
-/*!
- A custom string convertor allows you to specify a function pointer that
- returns a variant of \a type. For example, if you have written your own icon
- class that you want to support as an object property assignable in QML:
-
- \code
- int type = qRegisterMetaType<SuperIcon>("SuperIcon");
- QML::addCustomStringConvertor(type, &SuperIcon::pixmapFromString);
- \endcode
-
- The function pointer must be of the form:
- \code
- QVariant (*StringConverter)(const QString &);
- \endcode
- */
-void QDeclarativeMetaType::registerCustomStringConverter(int type, StringConverter converter)
-{
- QWriteLocker lock(metaTypeDataLock());
-
- QDeclarativeMetaTypeData *data = metaTypeData();
- if (data->stringConverters.contains(type))
- return;
- data->stringConverters.insert(type, converter);
-}
-
-/*!
- Return the custom string converter for \a type, previously installed through
- registerCustomStringConverter()
- */
-QDeclarativeMetaType::StringConverter QDeclarativeMetaType::customStringConverter(int type)
-{
- QReadLocker lock(metaTypeDataLock());
-
- QDeclarativeMetaTypeData *data = metaTypeData();
- return data->stringConverters.value(type);
-}
-
-/*!
- Returns the type (if any) of URI-qualified named \a name in version specified
- by \a version_major and \a version_minor.
-*/
-QDeclarativeType *QDeclarativeMetaType::qmlType(const QString &name, int version_major, int version_minor)
-{
- Q_ASSERT(version_major >= 0 && version_minor >= 0);
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- QDeclarativeMetaTypeData::Names::ConstIterator it = data->nameToType.find(name);
- while (it != data->nameToType.end()) {
- // XXX version_major<0 just a kludge for QDeclarativePropertyPrivate::initProperty
- if (it.key() == name && (version_major<0 || (*it)->availableInVersion(version_major,version_minor)))
- return (*it);
- ++it;
- }
-
- return 0;
-}
-
-/*!
- Returns the type (if any) that corresponds to the \a metaObject. Returns null if no
- type is registered.
-*/
-QDeclarativeType *QDeclarativeMetaType::qmlType(const QMetaObject *metaObject)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- return data->metaObjectToType.value(metaObject);
-}
-
-/*!
- Returns the type (if any) that corresponds to the \a metaObject in version specified
- by \a version_major and \a version_minor in module specified by \a uri. Returns null if no
- type is registered.
-*/
-QDeclarativeType *QDeclarativeMetaType::qmlType(const QMetaObject *metaObject, const QString &module, int version_major, int version_minor)
-{
- Q_ASSERT(version_major >= 0 && version_minor >= 0);
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- QDeclarativeMetaTypeData::MetaObjects::const_iterator it = data->metaObjectToType.find(metaObject);
- while (it != data->metaObjectToType.end() && it.key() == metaObject) {
- QDeclarativeType *t = *it;
- if (version_major < 0 || t->availableInVersion(module, version_major,version_minor))
- return t;
- ++it;
- }
-
- return 0;
-}
-
-/*!
- Returns the type (if any) that corresponds to the QVariant::Type \a userType.
- Returns null if no type is registered.
-*/
-QDeclarativeType *QDeclarativeMetaType::qmlType(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- QDeclarativeType *type = data->idToType.value(userType);
- if (type && type->typeId() == userType)
- return type;
- else
- return 0;
-}
-
-/*!
- Returns the list of registered QML type names.
-*/
-QList<QString> QDeclarativeMetaType::qmlTypeNames()
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- return data->nameToType.keys();
-}
-
-/*!
- Returns the list of registered QML types.
-*/
-QList<QDeclarativeType*> QDeclarativeMetaType::qmlTypes()
-{
- QReadLocker lock(metaTypeDataLock());
- QDeclarativeMetaTypeData *data = metaTypeData();
-
- return data->nameToType.values();
-}
-
-int QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()
-{
- static int id = 0;
- if (!id) {
- id = QMetaType::type("QQuickAnchorLine");
- }
- return id;
-}
-
-QDeclarativeMetaType::CompareFunction QDeclarativeMetaType::anchorLineCompareFunction = 0;
-
-void QDeclarativeMetaType::setQQuickAnchorLineCompareFunction(CompareFunction fun)
-{
- anchorLineCompareFunction = fun;
-}
-
-bool QDeclarativeMetaType::QQuickAnchorLineCompare(const void *p1, const void *p2)
-{
- Q_ASSERT(anchorLineCompareFunction != 0);
- return anchorLineCompareFunction(p1, p2);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
deleted file mode 100644
index b2a6aa40f6..0000000000
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEMETATYPE_P_H
-#define QDECLARATIVEMETATYPE_P_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 "qdeclarative.h"
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qbitarray.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <QtDeclarative/qjsvalue.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeType;
-class QDeclarativeCustomParser;
-class QDeclarativeTypePrivate;
-class QDeclarativeTypeModule;
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeMetaType
-{
-public:
- static QList<QString> qmlTypeNames();
- static QList<QDeclarativeType*> qmlTypes();
-
- static QDeclarativeType *qmlType(const QString &, int, int);
- static QDeclarativeType *qmlType(const QMetaObject *);
- static QDeclarativeType *qmlType(const QMetaObject *metaObject, const QString &module, int version_major, int version_minor);
- static QDeclarativeType *qmlType(int);
-
- static QMetaProperty defaultProperty(const QMetaObject *);
- static QMetaProperty defaultProperty(QObject *);
- static QMetaMethod defaultMethod(const QMetaObject *);
- static QMetaMethod defaultMethod(QObject *);
-
- static bool isQObject(int);
- static QObject *toQObject(const QVariant &, bool *ok = 0);
-
- static int listType(int);
- static int attachedPropertiesFuncId(const QMetaObject *);
- static QDeclarativeAttachedPropertiesFunc attachedPropertiesFuncById(int);
-
- enum TypeCategory { Unknown, Object, List };
- static TypeCategory typeCategory(int);
-
- static bool isInterface(int);
- static const char *interfaceIId(int);
- static bool isList(int);
-
- typedef QVariant (*StringConverter)(const QString &);
- static void registerCustomStringConverter(int, StringConverter);
- static StringConverter customStringConverter(int);
-
- static bool isAnyModule(const QString &uri);
- static bool isModule(const QString &module, int versionMajor, int versionMinor);
- static QDeclarativeTypeModule *typeModule(const QString &uri, int majorVersion);
-
- static QList<QDeclarativePrivate::AutoParentFunction> parentFunctions();
-
- static int QQuickAnchorLineMetaTypeId();
- typedef bool (*CompareFunction)(const void *, const void *);
- static void setQQuickAnchorLineCompareFunction(CompareFunction);
- static bool QQuickAnchorLineCompare(const void *p1, const void *p2);
-
- struct ModuleApiInstance {
- ModuleApiInstance()
- : scriptCallback(0), qobjectCallback(0), qobjectApi(0) {}
-
- QJSValue (*scriptCallback)(QDeclarativeEngine *, QJSEngine *);
- QObject *(*qobjectCallback)(QDeclarativeEngine *, QJSEngine *);
- QJSValue scriptApi;
- QObject *qobjectApi;
- };
- struct ModuleApi {
- inline ModuleApi();
- inline bool operator==(const ModuleApi &) const;
- int major;
- int minor;
- QJSValue (*script)(QDeclarativeEngine *, QJSEngine *);
- QObject *(*qobject)(QDeclarativeEngine *, QJSEngine *);
- };
- static ModuleApi moduleApi(const QString &, int, int);
- static QHash<QString, QList<ModuleApi> > moduleApis();
-
-private:
- static CompareFunction anchorLineCompareFunction;
-};
-
-class QHashedStringRef;
-class QHashedV8String;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeType
-{
-public:
- QByteArray typeName() const;
- const QString &qmlTypeName() const;
- const QString &elementName() const;
-
- QString module() const;
- int majorVersion() const;
- int minorVersion() const;
-
- bool availableInVersion(int vmajor, int vminor) const;
- bool availableInVersion(const QString &module, int vmajor, int vminor) const;
-
- QObject *create() const;
- void create(QObject **, void **, size_t) const;
-
- typedef void (*CreateFunc)(void *);
- CreateFunc createFunction() const;
- int createSize() const;
-
- QDeclarativeCustomParser *customParser() const;
-
- bool isCreatable() const;
- bool isExtendedType() const;
- QString noCreationReason() const;
-
- bool isInterface() const;
- int typeId() const;
- int qListTypeId() const;
-
- const QMetaObject *metaObject() const;
- const QMetaObject *baseMetaObject() const;
- int metaObjectRevision() const;
- bool containsRevisionedAttributes() const;
-
- QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction() const;
- const QMetaObject *attachedPropertiesType() const;
- int attachedPropertiesId() const;
-
- int parserStatusCast() const;
- QVariant fromObject(QObject *) const;
- const char *interfaceIId() const;
- int propertyValueSourceCast() const;
- int propertyValueInterceptorCast() const;
-
- int index() const;
-
- int enumValue(const QHashedStringRef &) const;
- int enumValue(const QHashedV8String &) const;
-private:
- QDeclarativeType *superType() const;
- friend class QDeclarativeTypePrivate;
- friend struct QDeclarativeMetaTypeData;
- friend int registerType(const QDeclarativePrivate::RegisterType &);
- friend int registerInterface(const QDeclarativePrivate::RegisterInterface &);
- QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &);
- QDeclarativeType(int, const QDeclarativePrivate::RegisterType &);
- ~QDeclarativeType();
-
- QDeclarativeTypePrivate *d;
-};
-
-class QDeclarativeTypeModulePrivate;
-class QDeclarativeTypeModule
-{
-public:
- QString module() const;
- int majorVersion() const;
-
- int minimumMinorVersion() const;
- int maximumMinorVersion() const;
-
- QList<QDeclarativeType *> types();
- QList<QDeclarativeType *> type(const QString &);
-
- QDeclarativeType *type(const QHashedStringRef &, int);
- QDeclarativeType *type(const QHashedV8String &, int);
-
-private:
- friend int registerType(const QDeclarativePrivate::RegisterType &);
- QDeclarativeTypeModule();
- ~QDeclarativeTypeModule();
- QDeclarativeTypeModulePrivate *d;
-};
-
-class QDeclarativeTypeModuleVersion
-{
-public:
- QDeclarativeTypeModuleVersion();
- QDeclarativeTypeModuleVersion(QDeclarativeTypeModule *, int);
- QDeclarativeTypeModuleVersion(const QDeclarativeTypeModuleVersion &);
- QDeclarativeTypeModuleVersion &operator=(const QDeclarativeTypeModuleVersion &);
-
- QDeclarativeTypeModule *module() const;
- int minorVersion() const;
-
- QDeclarativeType *type(const QHashedStringRef &) const;
- QDeclarativeType *type(const QHashedV8String &) const;
-
-private:
- QDeclarativeTypeModule *m_module;
- int m_minor;
-};
-
-QDeclarativeMetaType::ModuleApi::ModuleApi()
-{
- major = 0;
- minor = 0;
- script = 0;
- qobject = 0;
-}
-
-bool QDeclarativeMetaType::ModuleApi::operator==(const ModuleApi &other) const
-{
- return major == other.major && minor == other.minor && script == other.script && qobject == other.qobject;
-}
-
-inline uint qHash(const QDeclarativeMetaType::ModuleApi &import)
-{
- return import.major ^ import.minor ^ quintptr(import.script) ^ quintptr(import.qobject);
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEMETATYPE_P_H
-
diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
deleted file mode 100644
index ee8c8c5f71..0000000000
--- a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativenetworkaccessmanagerfactory.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDeclarativeNetworkAccessManagerFactory
- \since 4.7
- \brief The QDeclarativeNetworkAccessManagerFactory class creates QNetworkAccessManager instances for a QML engine.
-
- A QML engine uses QNetworkAccessManager for all network access.
- By implementing a factory, it is possible to provide the QML engine
- with custom QNetworkAccessManager instances with specialized caching,
- proxy and cookies support.
-
- To implement a factory, subclass QDeclarativeNetworkAccessManagerFactory and
- implement the virtual create() method, then assign it to the relevant QML
- engine using QDeclarativeEngine::setNetworkAccessManagerFactory().
-
- Note the QML engine may create QNetworkAccessManager instances
- from multiple threads. Because of this, the implementation of the create()
- method must be \l{Reentrancy and Thread-Safety}{reentrant}. In addition,
- the developer should be careful if the signals of the object to be
- returned from create() are connected to the slots of an object that may
- be created in a different thread:
-
- \list
- \o The QML engine internally handles all requests, and cleans up any
- QNetworkReply objects it creates. Receiving the
- QNetworkAccessManager::finished() signal in another thread may not
- provide the receiver with a valid reply object if it has already
- been deleted.
- \o Authentication details provided to QNetworkAccessManager::authenticationRequired()
- must be provided immediately, so this signal cannot be connected as a
- Qt::QueuedConnection (or as the default Qt::AutoConnection from another
- thread).
- \endlist
-
- For more information about signals and threads, see
- \l {Threads and QObjects} and \l {Signals and Slots Across Threads}.
-
- \sa {declarative/cppextensions/networkaccessmanagerfactory}{NetworkAccessManagerFactory example}
-*/
-
-/*!
- Destroys the factory. The default implementation does nothing.
- */
-QDeclarativeNetworkAccessManagerFactory::~QDeclarativeNetworkAccessManagerFactory()
-{
-}
-
-/*!
- \fn QNetworkAccessManager *QDeclarativeNetworkAccessManagerFactory::create(QObject *parent)
-
- Creates and returns a network access manager with the specified \a parent.
- This method must return a new QNetworkAccessManager instance each time
- it is called.
-
- Note: this method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h
deleted file mode 100644
index 34ffe3fb51..0000000000
--- a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVENETWORKACCESSMANAGERFACTORY_H
-#define QDECLARATIVENETWORKACCESSMANAGERFACTORY_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QNetworkAccessManager;
-class Q_DECLARATIVE_EXPORT QDeclarativeNetworkAccessManagerFactory
-{
-public:
- virtual ~QDeclarativeNetworkAccessManagerFactory();
- virtual QNetworkAccessManager *create(QObject *parent) = 0;
-
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVENETWORKACCESSMANAGERFACTORY_H
diff --git a/src/declarative/qml/qdeclarativenotifier.cpp b/src/declarative/qml/qdeclarativenotifier.cpp
deleted file mode 100644
index 100a42d029..0000000000
--- a/src/declarative/qml/qdeclarativenotifier.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativenotifier_p.h"
-#include "qdeclarativeproperty_p.h"
-
-QT_BEGIN_NAMESPACE
-
-void QDeclarativeNotifier::emitNotify(QDeclarativeNotifierEndpoint *endpoint)
-{
- QDeclarativeNotifierEndpoint **oldDisconnected = endpoint->disconnected;
- endpoint->disconnected = &endpoint;
- endpoint->notifying = 1;
-
- if (endpoint->next)
- emitNotify(endpoint->next);
-
- if (endpoint) {
-
- Q_ASSERT(endpoint->callback);
-
- endpoint->callback(endpoint);
-
- if (endpoint)
- endpoint->disconnected = oldDisconnected;
- }
-
- if (oldDisconnected) *oldDisconnected = endpoint;
- else if (endpoint) endpoint->notifying = 0;
-}
-
-void QDeclarativeNotifierEndpoint::connect(QObject *source, int sourceSignal)
-{
- disconnect();
-
- this->source = source;
- this->sourceSignal = sourceSignal;
- QDeclarativePropertyPrivate::flushSignal(source, sourceSignal);
- QDeclarativeData *ddata = QDeclarativeData::get(source, true);
- ddata->addNotify(sourceSignal, this);
-}
-
-void QDeclarativeNotifierEndpoint::copyAndClear(QDeclarativeNotifierEndpoint &other)
-{
- if (&other == this)
- return;
-
- other.disconnect();
-
- other.callback = callback;
-
- if (!isConnected())
- return;
-
- other.notifier = notifier;
- other.sourceSignal = sourceSignal;
- other.disconnected = disconnected;
- other.notifying = notifying;
- if (other.disconnected) *other.disconnected = &other;
-
- if (next) {
- other.next = next;
- next->prev = &other.next;
- }
- other.prev = prev;
- *other.prev = &other;
-
- prev = 0;
- next = 0;
- disconnected = 0;
- notifier = 0;
- notifying = 0;
- sourceSignal = -1;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h
deleted file mode 100644
index 1e37de8bb6..0000000000
--- a/src/declarative/qml/qdeclarativenotifier_p.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVENOTIFIER_P_H
-#define QDECLARATIVENOTIFIER_P_H
-
-#include "qdeclarativedata_p.h"
-#include "qdeclarativeguard_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeNotifierEndpoint;
-class Q_DECLARATIVE_EXPORT QDeclarativeNotifier
-{
-public:
- inline QDeclarativeNotifier();
- inline ~QDeclarativeNotifier();
- inline void notify();
-
-private:
- friend class QDeclarativeData;
- friend class QDeclarativeNotifierEndpoint;
-
- static void emitNotify(QDeclarativeNotifierEndpoint *);
- QDeclarativeNotifierEndpoint *endpoints;
-};
-
-class QDeclarativeNotifierEndpoint
-{
-public:
- inline QDeclarativeNotifierEndpoint();
- inline ~QDeclarativeNotifierEndpoint();
-
- typedef void (*Callback)(QDeclarativeNotifierEndpoint *);
- Callback callback;
-
- inline bool isConnected();
- inline bool isConnected(QObject *source, int sourceSignal);
- inline bool isConnected(QDeclarativeNotifier *);
-
- void connect(QObject *source, int sourceSignal);
- inline void connect(QDeclarativeNotifier *);
- inline void disconnect();
-
- inline bool isNotifying() const;
- inline void cancelNotify();
-
- void copyAndClear(QDeclarativeNotifierEndpoint &other);
-
-private:
- friend class QDeclarativeData;
- friend class QDeclarativeNotifier;
-
- union {
- QDeclarativeNotifier *notifier;
- QObject *source;
- };
- unsigned int notifying : 1;
- signed int sourceSignal : 31;
- QDeclarativeNotifierEndpoint **disconnected;
- QDeclarativeNotifierEndpoint *next;
- QDeclarativeNotifierEndpoint **prev;
-};
-
-QDeclarativeNotifier::QDeclarativeNotifier()
-: endpoints(0)
-{
-}
-
-QDeclarativeNotifier::~QDeclarativeNotifier()
-{
- QDeclarativeNotifierEndpoint *endpoint = endpoints;
- while (endpoint) {
- QDeclarativeNotifierEndpoint *n = endpoint;
- endpoint = n->next;
-
- n->next = 0;
- n->prev = 0;
- n->notifier = 0;
- n->sourceSignal = -1;
- if (n->disconnected) *n->disconnected = 0;
- n->disconnected = 0;
- }
- endpoints = 0;
-}
-
-void QDeclarativeNotifier::notify()
-{
- if (endpoints) emitNotify(endpoints);
-}
-
-QDeclarativeNotifierEndpoint::QDeclarativeNotifierEndpoint()
-: callback(0), notifier(0), notifying(0), sourceSignal(-1), disconnected(0), next(0), prev(0)
-{
-}
-
-QDeclarativeNotifierEndpoint::~QDeclarativeNotifierEndpoint()
-{
- disconnect();
-}
-
-bool QDeclarativeNotifierEndpoint::isConnected()
-{
- return prev != 0;
-}
-
-bool QDeclarativeNotifierEndpoint::isConnected(QObject *source, int sourceSignal)
-{
- return this->sourceSignal != -1 && this->source == source && this->sourceSignal == sourceSignal;
-}
-
-bool QDeclarativeNotifierEndpoint::isConnected(QDeclarativeNotifier *notifier)
-{
- return sourceSignal == -1 && this->notifier == notifier;
-}
-
-void QDeclarativeNotifierEndpoint::connect(QDeclarativeNotifier *notifier)
-{
- disconnect();
-
- next = notifier->endpoints;
- if (next) { next->prev = &next; }
- notifier->endpoints = this;
- prev = &notifier->endpoints;
- this->notifier = notifier;
-}
-
-void QDeclarativeNotifierEndpoint::disconnect()
-{
- if (next) next->prev = prev;
- if (prev) *prev = next;
- if (disconnected) *disconnected = 0;
- next = 0;
- prev = 0;
- disconnected = 0;
- notifier = 0;
- notifying = 0;
- sourceSignal = -1;
-}
-
-/*!
-Returns true if a notify is in progress. This means that the signal or QDeclarativeNotifier
-that this endpoing is connected to has been triggered, but this endpoint's callback has not
-yet been called.
-
-An in progress notify can be cancelled by calling cancelNotify.
-*/
-bool QDeclarativeNotifierEndpoint::isNotifying() const
-{
- return notifying == 1;
-}
-
-/*!
-Cancel any notifies that are in progress.
-*/
-void QDeclarativeNotifierEndpoint::cancelNotify()
-{
- notifying = 0;
- if (disconnected) {
- *disconnected = 0;
- disconnected = 0;
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVENOTIFIER_P_H
-
diff --git a/src/declarative/qml/qdeclarativenullablevalue_p_p.h b/src/declarative/qml/qdeclarativenullablevalue_p_p.h
deleted file mode 100644
index 9c5aa368a1..0000000000
--- a/src/declarative/qml/qdeclarativenullablevalue_p_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVENULLABLEVALUE_P_H
-#define QDECLARATIVENULLABLEVALUE_P_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.
-//
-
-QT_BEGIN_NAMESPACE
-
-template<typename T>
-struct QDeclarativeNullableValue
-{
- QDeclarativeNullableValue()
- : isNull(true), value(T()) {}
- QDeclarativeNullableValue(const QDeclarativeNullableValue<T> &o)
- : isNull(o.isNull), value(o.value) {}
- QDeclarativeNullableValue(const T &t)
- : isNull(false), value(t) {}
- QDeclarativeNullableValue<T> &operator=(const T &t)
- { isNull = false; value = t; return *this; }
- QDeclarativeNullableValue<T> &operator=(const QDeclarativeNullableValue<T> &o)
- { isNull = o.isNull; value = o.value; return *this; }
- operator T() const { return value; }
-
- void invalidate() { isNull = true; }
- bool isValid() const { return !isNull; }
- bool isNull;
- T value;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVENULLABLEVALUE_P_H
diff --git a/src/declarative/qml/qdeclarativeopenmetaobject.cpp b/src/declarative/qml/qdeclarativeopenmetaobject.cpp
deleted file mode 100644
index ca11d03135..0000000000
--- a/src/declarative/qml/qdeclarativeopenmetaobject.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeopenmetaobject_p.h"
-#include <private/qdeclarativepropertycache_p.h>
-#include <private/qdeclarativedata_p.h>
-#include <private/qmetaobjectbuilder_p.h>
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeOpenMetaObjectTypePrivate
-{
-public:
- QDeclarativeOpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {}
-
- void init(const QMetaObject *metaObj);
-
- int propertyOffset;
- int signalOffset;
- QHash<QByteArray, int> names;
- QMetaObjectBuilder mob;
- QMetaObject *mem;
- QDeclarativePropertyCache *cache;
- QDeclarativeEngine *engine;
- QSet<QDeclarativeOpenMetaObject*> referers;
-};
-
-QDeclarativeOpenMetaObjectType::QDeclarativeOpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine)
- : QDeclarativeCleanup(engine), d(new QDeclarativeOpenMetaObjectTypePrivate)
-{
- d->engine = engine;
- d->init(base);
-}
-
-QDeclarativeOpenMetaObjectType::~QDeclarativeOpenMetaObjectType()
-{
- if (d->mem)
- free(d->mem);
- if (d->cache)
- d->cache->release();
- delete d;
-}
-
-void QDeclarativeOpenMetaObjectType::clear()
-{
- d->engine = 0;
-}
-
-int QDeclarativeOpenMetaObjectType::propertyOffset() const
-{
- return d->propertyOffset;
-}
-
-int QDeclarativeOpenMetaObjectType::signalOffset() const
-{
- return d->signalOffset;
-}
-
-int QDeclarativeOpenMetaObjectType::createProperty(const QByteArray &name)
-{
- int id = d->mob.propertyCount();
- d->mob.addSignal("__" + QByteArray::number(id) + "()");
- QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
- propertyCreated(id, build);
- free(d->mem);
- d->mem = d->mob.toMetaObject();
- d->names.insert(name, id);
- QSet<QDeclarativeOpenMetaObject*>::iterator it = d->referers.begin();
- while (it != d->referers.end()) {
- QDeclarativeOpenMetaObject *omo = *it;
- *static_cast<QMetaObject *>(omo) = *d->mem;
- if (d->cache)
- d->cache->update(d->engine, omo);
- ++it;
- }
-
- return d->propertyOffset + id;
-}
-
-void QDeclarativeOpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder)
-{
- if (d->referers.count())
- (*d->referers.begin())->propertyCreated(id, builder);
-}
-
-void QDeclarativeOpenMetaObjectTypePrivate::init(const QMetaObject *metaObj)
-{
- if (!mem) {
- mob.setSuperClass(metaObj);
- mob.setClassName(metaObj->className());
- mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
-
- mem = mob.toMetaObject();
-
- propertyOffset = mem->propertyOffset();
- signalOffset = mem->methodOffset();
- }
-}
-
-//----------------------------------------------------------------------------
-
-class QDeclarativeOpenMetaObjectPrivate
-{
-public:
- QDeclarativeOpenMetaObjectPrivate(QDeclarativeOpenMetaObject *_q)
- : q(_q), parent(0), type(0), cacheProperties(false) {}
-
- inline QVariant &getData(int idx) {
- while (data.count() <= idx)
- data << QPair<QVariant, bool>(QVariant(), false);
- QPair<QVariant, bool> &prop = data[idx];
- if (!prop.second) {
- prop.first = q->initialValue(idx);
- prop.second = true;
- }
- return prop.first;
- }
-
- inline void writeData(int idx, const QVariant &value) {
- while (data.count() <= idx)
- data << QPair<QVariant, bool>(QVariant(), false);
- QPair<QVariant, bool> &prop = data[idx];
- prop.first = value;
- prop.second = true;
- }
-
- inline bool hasData(int idx) const {
- if (idx >= data.count())
- return false;
- return data[idx].second;
- }
-
- bool autoCreate;
- QDeclarativeOpenMetaObject *q;
- QAbstractDynamicMetaObject *parent;
- QList<QPair<QVariant, bool> > data;
- QObject *object;
- QDeclarativeOpenMetaObjectType *type;
- bool cacheProperties;
-};
-
-QDeclarativeOpenMetaObject::QDeclarativeOpenMetaObject(QObject *obj, bool automatic)
-: d(new QDeclarativeOpenMetaObjectPrivate(this))
-{
- d->autoCreate = automatic;
- d->object = obj;
-
- d->type = new QDeclarativeOpenMetaObjectType(obj->metaObject(), 0);
- d->type->d->referers.insert(this);
-
- QObjectPrivate *op = QObjectPrivate::get(obj);
- d->parent = static_cast<QAbstractDynamicMetaObject *>(op->metaObject);
- *static_cast<QMetaObject *>(this) = *d->type->d->mem;
- op->metaObject = this;
-}
-
-QDeclarativeOpenMetaObject::QDeclarativeOpenMetaObject(QObject *obj, QDeclarativeOpenMetaObjectType *type, bool automatic)
-: d(new QDeclarativeOpenMetaObjectPrivate(this))
-{
- d->autoCreate = automatic;
- d->object = obj;
-
- d->type = type;
- d->type->addref();
- d->type->d->referers.insert(this);
-
- QObjectPrivate *op = QObjectPrivate::get(obj);
- d->parent = static_cast<QAbstractDynamicMetaObject *>(op->metaObject);
- *static_cast<QMetaObject *>(this) = *d->type->d->mem;
- op->metaObject = this;
-}
-
-QDeclarativeOpenMetaObject::~QDeclarativeOpenMetaObject()
-{
- if (d->parent)
- delete d->parent;
- d->type->d->referers.remove(this);
- d->type->release();
- delete d;
-}
-
-QDeclarativeOpenMetaObjectType *QDeclarativeOpenMetaObject::type() const
-{
- return d->type;
-}
-
-int QDeclarativeOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
-{
- if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty)
- && id >= d->type->d->propertyOffset) {
- int propId = id - d->type->d->propertyOffset;
- if (c == QMetaObject::ReadProperty) {
- propertyRead(propId);
- *reinterpret_cast<QVariant *>(a[0]) = d->getData(propId);
- } else if (c == QMetaObject::WriteProperty) {
- if (propId <= d->data.count() || d->data[propId].first != *reinterpret_cast<QVariant *>(a[0])) {
- propertyWrite(propId);
- d->writeData(propId, *reinterpret_cast<QVariant *>(a[0]));
- propertyWritten(propId);
- activate(d->object, d->type->d->signalOffset + propId, 0);
- }
- }
- return -1;
- } else {
- if (d->parent)
- return d->parent->metaCall(c, id, a);
- else
- return d->object->qt_metacall(c, id, a);
- }
-}
-
-QAbstractDynamicMetaObject *QDeclarativeOpenMetaObject::parent() const
-{
- return d->parent;
-}
-
-QVariant QDeclarativeOpenMetaObject::value(int id) const
-{
- return d->getData(id);
-}
-
-void QDeclarativeOpenMetaObject::setValue(int id, const QVariant &value)
-{
- d->writeData(id, value);
- activate(d->object, id + d->type->d->signalOffset, 0);
-}
-
-QVariant QDeclarativeOpenMetaObject::value(const QByteArray &name) const
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
- if (iter == d->type->d->names.end())
- return QVariant();
-
- return d->getData(*iter);
-}
-
-QVariant &QDeclarativeOpenMetaObject::operator[](const QByteArray &name)
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
- Q_ASSERT(iter != d->type->d->names.end());
-
- return d->getData(*iter);
-}
-
-QVariant &QDeclarativeOpenMetaObject::operator[](int id)
-{
- return d->getData(id);
-}
-
-bool QDeclarativeOpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
-
- int id = -1;
- if (iter == d->type->d->names.end()) {
- id = createProperty(name.constData(), "") - d->type->d->propertyOffset;
- } else {
- id = *iter;
- }
-
- if (id >= 0) {
- QVariant &dataVal = d->getData(id);
- if (dataVal == val)
- return false;
-
- dataVal = val;
- activate(d->object, id + d->type->d->signalOffset, 0);
- return true;
- }
-
- return false;
-}
-
-// returns true if this value has been initialized by a call to either value() or setValue()
-bool QDeclarativeOpenMetaObject::hasValue(int id) const
-{
- return d->hasData(id);
-}
-
-void QDeclarativeOpenMetaObject::setCached(bool c)
-{
- if (c == d->cacheProperties || !d->type->d->engine)
- return;
-
- d->cacheProperties = c;
-
- QDeclarativeData *qmldata = QDeclarativeData::get(d->object, true);
- if (d->cacheProperties) {
- if (!d->type->d->cache)
- d->type->d->cache = new QDeclarativePropertyCache(d->type->d->engine, this);
- qmldata->propertyCache = d->type->d->cache;
- d->type->d->cache->addref();
- } else {
- if (d->type->d->cache)
- d->type->d->cache->release();
- qmldata->propertyCache = 0;
- }
-}
-
-
-int QDeclarativeOpenMetaObject::createProperty(const char *name, const char *)
-{
- if (d->autoCreate)
- return d->type->createProperty(name);
- else
- return -1;
-}
-
-void QDeclarativeOpenMetaObject::propertyRead(int)
-{
-}
-
-void QDeclarativeOpenMetaObject::propertyWrite(int)
-{
-}
-
-void QDeclarativeOpenMetaObject::propertyWritten(int)
-{
-}
-
-void QDeclarativeOpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &)
-{
-}
-
-QVariant QDeclarativeOpenMetaObject::initialValue(int)
-{
- return QVariant();
-}
-
-int QDeclarativeOpenMetaObject::count() const
-{
- return d->type->d->names.count();
-}
-
-QByteArray QDeclarativeOpenMetaObject::name(int idx) const
-{
- Q_ASSERT(idx >= 0 && idx < d->type->d->names.count());
-
- return d->type->d->mob.property(idx).name();
-}
-
-QObject *QDeclarativeOpenMetaObject::object() const
-{
- return d->object;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeopenmetaobject_p.h b/src/declarative/qml/qdeclarativeopenmetaobject_p.h
deleted file mode 100644
index b6b17c0984..0000000000
--- a/src/declarative/qml/qdeclarativeopenmetaobject_p.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEOPENMETAOBJECT_H
-#define QDECLARATIVEOPENMETAOBJECT_H
-
-#include <QtCore/QMetaObject>
-#include <QtCore/QObject>
-
-#include <private/qdeclarativerefcount_p.h>
-#include <private/qdeclarativecleanup_p.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qobject_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeEngine;
-class QMetaPropertyBuilder;
-class QDeclarativeOpenMetaObjectTypePrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeOpenMetaObjectType : public QDeclarativeRefCount, public QDeclarativeCleanup
-{
-public:
- QDeclarativeOpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine);
- ~QDeclarativeOpenMetaObjectType();
-
- int createProperty(const QByteArray &name);
-
- int propertyOffset() const;
- int signalOffset() const;
-
-protected:
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
- virtual void clear();
-
-private:
- QDeclarativeOpenMetaObjectTypePrivate *d;
- friend class QDeclarativeOpenMetaObject;
- friend class QDeclarativeOpenMetaObjectPrivate;
-};
-
-class QDeclarativeOpenMetaObjectPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeOpenMetaObject : public QAbstractDynamicMetaObject
-{
-public:
- QDeclarativeOpenMetaObject(QObject *, bool = true);
- QDeclarativeOpenMetaObject(QObject *, QDeclarativeOpenMetaObjectType *, bool = true);
- ~QDeclarativeOpenMetaObject();
-
- QVariant value(const QByteArray &) const;
- bool setValue(const QByteArray &, const QVariant &);
- QVariant value(int) const;
- void setValue(int, const QVariant &);
- QVariant &operator[](const QByteArray &);
- QVariant &operator[](int);
- bool hasValue(int) const;
-
- int count() const;
- QByteArray name(int) const;
-
- QObject *object() const;
- virtual QVariant initialValue(int);
-
- // Be careful - once setCached(true) is called createProperty() is no
- // longer automatically called for new properties.
- void setCached(bool);
-
- QDeclarativeOpenMetaObjectType *type() const;
-
-protected:
- virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
- virtual int createProperty(const char *, const char *);
-
- virtual void propertyRead(int);
- virtual void propertyWrite(int);
- virtual void propertyWritten(int);
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
-
- QAbstractDynamicMetaObject *parent() const;
-
-private:
- QDeclarativeOpenMetaObjectPrivate *d;
- friend class QDeclarativeOpenMetaObjectType;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEOPENMETAOBJECT_H
diff --git a/src/declarative/qml/qdeclarativeparserstatus.cpp b/src/declarative/qml/qdeclarativeparserstatus.cpp
deleted file mode 100644
index 39538b51dd..0000000000
--- a/src/declarative/qml/qdeclarativeparserstatus.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeparserstatus.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDeclarativeParserStatus
- \since 4.7
- \brief The QDeclarativeParserStatus class provides updates on the QML parser state.
-
- QDeclarativeParserStatus provides a mechanism for classes instantiated by
- a QDeclarativeEngine to receive notification at key points in their creation.
-
- This class is often used for optimization purposes, as it allows you to defer an
- expensive operation until after all the properties have been set on an
- object. For example, QML's \l {Text} element uses the parser status
- to defer text layout until all of its properties have been set (we
- don't want to layout when the \c text is assigned, and then relayout
- when the \c font is assigned, and relayout again when the \c width is assigned,
- and so on).
-
- To use QDeclarativeParserStatus, you must inherit both a QObject-derived class
- and QDeclarativeParserStatus, and use the Q_INTERFACES() macro.
-
- \code
- class MyObject : public QObject, public QDeclarativeParserStatus
- {
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-
- public:
- MyObject(QObject *parent = 0);
- ...
- void classBegin();
- void componentComplete();
- }
- \endcode
-*/
-
-/*! \internal */
-QDeclarativeParserStatus::QDeclarativeParserStatus()
-: d(0)
-{
-}
-
-/*! \internal */
-QDeclarativeParserStatus::~QDeclarativeParserStatus()
-{
- if(d)
- (*d) = 0;
-}
-
-/*!
- \fn void QDeclarativeParserStatus::classBegin()
-
- Invoked after class creation, but before any properties have been set.
-*/
-
-/*!
- \fn void QDeclarativeParserStatus::componentComplete()
-
- Invoked after the root component that caused this instantiation has
- completed construction. At this point all static values and binding values
- have been assigned to the class.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeparserstatus.h b/src/declarative/qml/qdeclarativeparserstatus.h
deleted file mode 100644
index d8544310bd..0000000000
--- a/src/declarative/qml/qdeclarativeparserstatus.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPARSERSTATUS_H
-#define QDECLARATIVEPARSERSTATUS_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class Q_DECLARATIVE_EXPORT QDeclarativeParserStatus
-{
-public:
- QDeclarativeParserStatus();
- virtual ~QDeclarativeParserStatus();
-
- virtual void classBegin()=0;
- virtual void componentComplete()=0;
-
-private:
- friend class QDeclarativeVME;
- friend class QDeclarativeComponent;
- friend class QDeclarativeComponentPrivate;
- friend class QDeclarativeEnginePrivate;
- QDeclarativeParserStatus **d;
-};
-Q_DECLARE_INTERFACE(QDeclarativeParserStatus, "com.trolltech.qml.QDeclarativeParserStatus")
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPARSERSTATUS_H
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
deleted file mode 100644
index 3477d469af..0000000000
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#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>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-typedef QObject *(*QDeclarativeAttachedPropertiesFunc)(QObject *);
-
-template <typename TYPE>
-class QDeclarativeTypeInfo
-{
-public:
- enum {
- hasAttachedProperties = 0
- };
-};
-
-
-class QJSValue;
-class QJSEngine;
-class QDeclarativeEngine;
-class QDeclarativeCustomParser;
-namespace QDeclarativePrivate
-{
- void Q_DECLARATIVE_EXPORT qdeclarativeelement_destructor(QObject *);
- template<typename T>
- class QDeclarativeElement : public T
- {
- public:
- virtual ~QDeclarativeElement() {
- QDeclarativePrivate::qdeclarativeelement_destructor(this);
- }
- };
-
- template<typename T>
- void createInto(void *memory) { new (memory) QDeclarativeElement<T>; }
-
- template<typename T>
- QObject *createParent(QObject *p) { return new T(p); }
-
- template<class From, class To, int N>
- struct StaticCastSelectorClass
- {
- static inline int cast() { return -1; }
- };
-
- template<class From, class To>
- struct StaticCastSelectorClass<From, To, sizeof(int)>
- {
- static inline int cast() { return int(reinterpret_cast<quintptr>(static_cast<To *>(reinterpret_cast<From *>(0x10000000)))) - 0x10000000; }
- };
-
- template<class From, class To>
- struct StaticCastSelector
- {
- typedef int yes_type;
- typedef char no_type;
-
- static yes_type check(To *);
- static no_type check(...);
-
- static inline int cast()
- {
- return StaticCastSelectorClass<From, To, sizeof(check(reinterpret_cast<From *>(0)))>::cast();
- }
- };
-
- template <typename T>
- struct has_attachedPropertiesMember
- {
- static bool const value = QDeclarativeTypeInfo<T>::hasAttachedProperties;
- };
-
- template <typename T, bool hasMember>
- class has_attachedPropertiesMethod
- {
- public:
- typedef int yes_type;
- typedef char no_type;
-
- template<typename ReturnType>
- static yes_type check(ReturnType *(*)(QObject *));
- static no_type check(...);
-
- static bool const value = sizeof(check(&T::qmlAttachedProperties)) == sizeof(yes_type);
- };
-
- template <typename T>
- class has_attachedPropertiesMethod<T, false>
- {
- public:
- static bool const value = false;
- };
-
- template<typename T, int N>
- class AttachedPropertySelector
- {
- public:
- static inline QDeclarativeAttachedPropertiesFunc func() { return 0; }
- static inline const QMetaObject *metaObject() { return 0; }
- };
- template<typename T>
- class AttachedPropertySelector<T, 1>
- {
- static inline QObject *attachedProperties(QObject *obj) {
- return T::qmlAttachedProperties(obj);
- }
- template<typename ReturnType>
- static inline const QMetaObject *attachedPropertiesMetaObject(ReturnType *(*)(QObject *)) {
- return &ReturnType::staticMetaObject;
- }
- public:
- static inline QDeclarativeAttachedPropertiesFunc func() {
- return &attachedProperties;
- }
- static inline const QMetaObject *metaObject() {
- return attachedPropertiesMetaObject(&T::qmlAttachedProperties);
- }
- };
-
- template<typename T>
- inline QDeclarativeAttachedPropertiesFunc attachedPropertiesFunc()
- {
- return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::func();
- }
-
- template<typename T>
- inline const QMetaObject *attachedPropertiesMetaObject()
- {
- 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;
-
- int typeId;
- int listId;
- int objectSize;
- void (*create)(void *);
- QString noCreationReason;
-
- const char *uri;
- int versionMajor;
- int versionMinor;
- const char *elementName;
- const QMetaObject *metaObject;
-
- QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction;
- const QMetaObject *attachedPropertiesMetaObject;
-
- int parserStatusCast;
- int valueSourceCast;
- int valueInterceptorCast;
-
- QObject *(*extensionObjectCreate)(QObject *);
- const QMetaObject *extensionMetaObject;
-
- QDeclarativeCustomParser *customParser;
- int revision;
- // If this is extended ensure "version" is bumped!!!
- };
-
- struct RegisterInterface {
- int version;
-
- int typeId;
- int listId;
-
- const char *iid;
- };
-
- struct RegisterAutoParent {
- int version;
-
- AutoParentFunction function;
- };
-
- struct RegisterModuleApi {
- int version;
-
- const char *uri;
- int versionMajor;
- int versionMinor;
-
- QJSValue (*scriptApi)(QDeclarativeEngine *, QJSEngine *);
- QObject *(*qobjectApi)(QDeclarativeEngine *, QJSEngine *);
- };
-
- enum RegistrationType {
- TypeRegistration = 0,
- InterfaceRegistration = 1,
- AutoParentRegistration = 2,
- ModuleApiRegistration = 3
- };
-
- int Q_DECLARATIVE_EXPORT qmlregister(RegistrationType, void *);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPRIVATE_H
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
deleted file mode 100644
index 7ba801d72f..0000000000
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ /dev/null
@@ -1,1917 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeproperty.h"
-#include "qdeclarativeproperty_p.h"
-
-#include "qdeclarative.h"
-#include "qdeclarativebinding_p.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativeboundsignal_p.h"
-#include "qdeclarativeengine.h"
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativedata_p.h"
-#include "qdeclarativestringconverters_p.h"
-#include "qdeclarativelist_p.h"
-#include "qdeclarativecompiler_p.h"
-#include "qdeclarativevmemetaobject_p.h"
-#include "qdeclarativeexpression_p.h"
-
-#include <QStringList>
-#include <QtCore/qdebug.h>
-
-#include <math.h>
-
-Q_DECLARE_METATYPE(QList<int>)
-Q_DECLARE_METATYPE(QList<qreal>)
-Q_DECLARE_METATYPE(QList<bool>)
-Q_DECLARE_METATYPE(QList<QString>)
-Q_DECLARE_METATYPE(QList<QUrl>)
-
-QT_BEGIN_NAMESPACE
-
-/*!
-\class QDeclarativeProperty
-\since 4.7
-\brief The QDeclarativeProperty class abstracts accessing properties on objects created from QML.
-
-As QML uses Qt's meta-type system all of the existing QMetaObject classes can be used to introspect
-and interact with objects created by QML. However, some of the new features provided by QML - such
-as type safety and attached properties - are most easily used through the QDeclarativeProperty class
-that simplifies some of their natural complexity.
-
-Unlike QMetaProperty which represents a property on a class type, QDeclarativeProperty encapsulates
-a property on a specific object instance. To read a property's value, programmers create a
-QDeclarativeProperty instance and call the read() method. Likewise to write a property value the
-write() method is used.
-
-For example, for the following QML code:
-
-\qml
-// MyItem.qml
-import QtQuick 2.0
-
-Text { text: "A bit of text" }
-\endqml
-
-The \l Text object's properties could be accessed using QDeclarativeProperty, like this:
-
-\code
-#include <QDeclarativeProperty>
-#include <QGraphicsObject>
-
-...
-
-QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml"));
-QDeclarativeProperty property(view.rootObject(), "font.pixelSize");
-qWarning() << "Current pixel size:" << property.read().toInt();
-property.write(24);
-qWarning() << "Pixel size should now be 24:" << property.read().toInt();
-\endcode
-*/
-
-/*!
- Create an invalid QDeclarativeProperty.
-*/
-QDeclarativeProperty::QDeclarativeProperty()
-: d(0)
-{
-}
-
-/*! \internal */
-QDeclarativeProperty::~QDeclarativeProperty()
-{
- if (d)
- d->release();
- d = 0;
-}
-
-/*!
- Creates a QDeclarativeProperty for the default property of \a obj. If there is no
- default property, an invalid QDeclarativeProperty will be created.
- */
-QDeclarativeProperty::QDeclarativeProperty(QObject *obj)
-: d(new QDeclarativePropertyPrivate)
-{
- d->initDefault(obj);
-}
-
-/*!
- Creates a QDeclarativeProperty for the default property of \a obj
- using the \l{QDeclarativeContext} {context} \a ctxt. If there is
- no default property, an invalid QDeclarativeProperty will be
- created.
- */
-QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeContext *ctxt)
-: d(new QDeclarativePropertyPrivate)
-{
- d->context = ctxt?QDeclarativeContextData::get(ctxt):0;
- d->engine = ctxt?ctxt->engine():0;
- d->initDefault(obj);
-}
-
-/*!
- Creates a QDeclarativeProperty for the default property of \a obj
- using the environment for instantiating QML components that is
- provided by \a engine. If there is no default property, an
- invalid QDeclarativeProperty will be created.
- */
-QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeEngine *engine)
- : d(new QDeclarativePropertyPrivate)
-{
- d->context = 0;
- d->engine = engine;
- d->initDefault(obj);
-}
-
-/*!
- Initialize from the default property of \a obj
-*/
-void QDeclarativePropertyPrivate::initDefault(QObject *obj)
-{
- if (!obj)
- return;
-
- QMetaProperty p = QDeclarativeMetaType::defaultProperty(obj);
- core.load(p);
- if (core.isValid())
- object = obj;
-}
-
-/*!
- Creates a QDeclarativeProperty for the property \a name of \a obj.
- */
-QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name)
-: d(new QDeclarativePropertyPrivate)
-{
- d->initProperty(obj, name);
- if (!isValid()) d->object = 0;
-}
-
-/*!
- Creates a QDeclarativeProperty for the property \a name of \a obj
- using the \l{QDeclarativeContext} {context} \a ctxt.
-
- Creating a QDeclarativeProperty without a context will render some
- properties - like attached properties - inaccessible.
-*/
-QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeContext *ctxt)
-: d(new QDeclarativePropertyPrivate)
-{
- d->context = ctxt?QDeclarativeContextData::get(ctxt):0;
- d->engine = ctxt?ctxt->engine():0;
- d->initProperty(obj, name);
- if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
-}
-
-/*!
- Creates a QDeclarativeProperty for the property \a name of \a obj
- using the environment for instantiating QML components that is
- provided by \a engine.
- */
-QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeEngine *engine)
-: d(new QDeclarativePropertyPrivate)
-{
- d->context = 0;
- d->engine = engine;
- d->initProperty(obj, name);
- if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
-}
-
-Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes);
-
-QDeclarativePropertyPrivate::QDeclarativePropertyPrivate()
-: context(0), engine(0), object(0), isNameCached(false)
-{
-}
-
-QDeclarativeContextData *QDeclarativePropertyPrivate::effectiveContext() const
-{
- if (context) return context;
- else if (engine) return QDeclarativeContextData::get(engine->rootContext());
- else return 0;
-}
-
-void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name)
-{
- if (!obj) return;
-
- QDeclarativeTypeNameCache *typeNameCache = context?context->imports:0;
-
- QStringList path = name.split(QLatin1Char('.'));
- if (path.isEmpty()) return;
-
- QObject *currentObject = obj;
-
- // Everything up to the last property must be an "object type" property
- for (int ii = 0; ii < path.count() - 1; ++ii) {
- const QString &pathName = path.at(ii);
-
- if (typeNameCache) {
- QDeclarativeTypeNameCache::Result r = typeNameCache->query(pathName);
- if (r.isValid()) {
- if (r.type) {
- QDeclarativeAttachedPropertiesFunc func = r.type->attachedPropertiesFunction();
- if (!func) return; // Not an attachable type
-
- currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(), currentObject);
- if (!currentObject) return; // Something is broken with the attachable type
- } else if (r.importNamespace) {
- if ((ii + 1) == path.count()) return; // No type following the namespace
-
- ++ii; r = typeNameCache->query(path.at(ii), r.importNamespace);
- if (!r.type) return; // Invalid type in namespace
-
- QDeclarativeAttachedPropertiesFunc func = r.type->attachedPropertiesFunction();
- if (!func) return; // Not an attachable type
-
- currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(), currentObject);
- if (!currentObject) return; // Something is broken with the attachable type
-
- } else if (r.scriptIndex != -1) {
- return; // Not a type
- } else {
- Q_ASSERT(!"Unreachable");
- }
- continue;
- }
-
- }
-
- QDeclarativePropertyData local;
- QDeclarativePropertyData *property =
- QDeclarativePropertyCache::property(engine, obj, pathName, local);
-
- if (!property) return; // Not a property
- if (property->isFunction())
- return; // Not an object property
-
- if (ii == (path.count() - 2) && QDeclarativeValueTypeFactory::isValueType(property->propType)) {
- // We're now at a value type property. We can use a global valuetypes array as we
- // never actually use the objects, just look up their properties.
- QObject *typeObject = (*qmlValueTypes())[property->propType];
- if (!typeObject) return; // Not a value type
-
- int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
- if (idx == -1) return; // Value type property does not exist
-
- QMetaProperty vtProp = typeObject->metaObject()->property(idx);
-
- typedef QDeclarativePropertyData PCD;
-
- Q_ASSERT(PCD::flagsForProperty(vtProp) <= PCD::ValueTypeFlagMask);
- Q_ASSERT(vtProp.userType() <= 0xFF);
- Q_ASSERT(idx <= 0xFF);
-
- object = currentObject;
- core = *property;
- core.setFlags(core.getFlags() | PCD::IsValueTypeVirtual);
- core.valueTypeFlags = PCD::flagsForProperty(vtProp);
- core.valueTypePropType = vtProp.userType();
- core.valueTypeCoreIndex = idx;
-
- return;
- } else {
- if (!property->isQObject())
- return; // Not an object property
-
- void *args[] = { &currentObject, 0 };
- QMetaObject::metacall(currentObject, QMetaObject::ReadProperty, property->coreIndex, args);
- if (!currentObject) return; // No value
-
- }
-
- }
-
- const QString &terminal = path.last();
-
- if (terminal.count() >= 3 &&
- terminal.at(0) == QLatin1Char('o') &&
- terminal.at(1) == QLatin1Char('n') &&
- terminal.at(2).isUpper()) {
-
- QString signalName = terminal.mid(2);
- signalName[0] = signalName.at(0).toLower();
-
- QMetaMethod method = findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData());
- if (method.signature()) {
- object = currentObject;
- core.load(method);
- return;
- }
- }
-
- // Property
- QDeclarativePropertyData local;
- QDeclarativePropertyData *property =
- QDeclarativePropertyCache::property(engine, currentObject, terminal, local);
- if (property && !property->isFunction()) {
- object = currentObject;
- core = *property;
- nameCache = terminal;
- isNameCached = true;
- }
-}
-
-/*!
- Create a copy of \a other.
-*/
-QDeclarativeProperty::QDeclarativeProperty(const QDeclarativeProperty &other)
-{
- d = other.d;
- if (d)
- d->addref();
-}
-
-/*!
- \enum QDeclarativeProperty::PropertyTypeCategory
-
- This enum specifies a category of QML property.
-
- \value InvalidCategory The property is invalid, or is a signal property.
- \value List The property is a QDeclarativeListProperty list property
- \value Object The property is a QObject derived type pointer
- \value Normal The property is a normal value property.
- */
-
-/*!
- \enum QDeclarativeProperty::Type
-
- This enum specifies a type of QML property.
-
- \value Invalid The property is invalid.
- \value Property The property is a regular Qt property.
- \value SignalProperty The property is a signal property.
-*/
-
-/*!
- Returns the property category.
-*/
-QDeclarativeProperty::PropertyTypeCategory QDeclarativeProperty::propertyTypeCategory() const
-{
- return d ? d->propertyTypeCategory() : InvalidCategory;
-}
-
-QDeclarativeProperty::PropertyTypeCategory
-QDeclarativePropertyPrivate::propertyTypeCategory() const
-{
- uint type = this->type();
-
- if (isValueType()) {
- return QDeclarativeProperty::Normal;
- } else if (type & QDeclarativeProperty::Property) {
- int type = propertyType();
- if (type == QVariant::Invalid)
- return QDeclarativeProperty::InvalidCategory;
- else if (QDeclarativeValueTypeFactory::isValueType((uint)type))
- return QDeclarativeProperty::Normal;
- else if (core.isQObject())
- return QDeclarativeProperty::Object;
- else if (core.isQList())
- return QDeclarativeProperty::List;
- else
- return QDeclarativeProperty::Normal;
- } else {
- return QDeclarativeProperty::InvalidCategory;
- }
-}
-
-/*!
- Returns the type name of the property, or 0 if the property has no type
- name.
-*/
-const char *QDeclarativeProperty::propertyTypeName() const
-{
- if (!d)
- return 0;
- if (d->isValueType()) {
-
- QDeclarativeEnginePrivate *ep = d->engine?QDeclarativeEnginePrivate::get(d->engine):0;
- QDeclarativeValueType *valueType = 0;
- if (ep) valueType = ep->valueTypes[d->core.propType];
- else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType);
- Q_ASSERT(valueType);
-
- const char *rv = valueType->metaObject()->property(d->core.valueTypeCoreIndex).typeName();
-
- if (!ep) delete valueType;
-
- return rv;
- } else if (d->object && type() & Property && d->core.isValid()) {
- return d->object->metaObject()->property(d->core.coreIndex).typeName();
- } else {
- return 0;
- }
-}
-
-/*!
- Returns true if \a other and this QDeclarativeProperty represent the same
- property.
-*/
-bool QDeclarativeProperty::operator==(const QDeclarativeProperty &other) const
-{
- if (!d || !other.d)
- return false;
- // category is intentially omitted here as it is generated
- // from the other members
- return d->object == other.d->object &&
- d->core.coreIndex == other.d->core.coreIndex &&
- d->core.isValueTypeVirtual() == other.d->core.isValueTypeVirtual() &&
- (!d->core.isValueTypeVirtual() ||
- (d->core.valueTypeCoreIndex == other.d->core.valueTypeCoreIndex &&
- d->core.valueTypePropType == other.d->core.valueTypePropType));
-}
-
-/*!
- Returns the QVariant type of the property, or QVariant::Invalid if the
- property has no QVariant type.
-*/
-int QDeclarativeProperty::propertyType() const
-{
- return d ? d->propertyType() : int(QVariant::Invalid);
-}
-
-bool QDeclarativePropertyPrivate::isValueType() const
-{
- return core.isValueTypeVirtual();
-}
-
-int QDeclarativePropertyPrivate::propertyType() const
-{
- uint type = this->type();
- if (isValueType()) {
- return core.valueTypePropType;
- } else if (type & QDeclarativeProperty::Property) {
- return core.propType;
- } else {
- return QVariant::Invalid;
- }
-}
-
-QDeclarativeProperty::Type QDeclarativePropertyPrivate::type() const
-{
- if (core.isFunction())
- return QDeclarativeProperty::SignalProperty;
- else if (core.isValid())
- return QDeclarativeProperty::Property;
- else
- return QDeclarativeProperty::Invalid;
-}
-
-/*!
- Returns the type of the property.
-*/
-QDeclarativeProperty::Type QDeclarativeProperty::type() const
-{
- return d ? d->type() : Invalid;
-}
-
-/*!
- Returns true if this QDeclarativeProperty represents a regular Qt property.
-*/
-bool QDeclarativeProperty::isProperty() const
-{
- return type() & Property;
-}
-
-/*!
- Returns true if this QDeclarativeProperty represents a QML signal property.
-*/
-bool QDeclarativeProperty::isSignalProperty() const
-{
- return type() & SignalProperty;
-}
-
-/*!
- Returns the QDeclarativeProperty's QObject.
-*/
-QObject *QDeclarativeProperty::object() const
-{
- return d ? d->object : 0;
-}
-
-/*!
- Assign \a other to this QDeclarativeProperty.
-*/
-QDeclarativeProperty &QDeclarativeProperty::operator=(const QDeclarativeProperty &other)
-{
- if (d)
- d->release();
- d = other.d;
- if (d)
- d->addref();
-
- return *this;
-}
-
-/*!
- Returns true if the property is writable, otherwise false.
-*/
-bool QDeclarativeProperty::isWritable() const
-{
- if (!d)
- return false;
- if (!d->object)
- return false;
- if (d->core.isQList()) //list
- return true;
- else if (d->core.isFunction()) //signal handler
- return false;
- else if (d->core.isValid()) //normal property
- return d->core.isWritable();
- else
- return false;
-}
-
-/*!
- Returns true if the property is designable, otherwise false.
-*/
-bool QDeclarativeProperty::isDesignable() const
-{
- if (!d)
- return false;
- if (type() & Property && d->core.isValid() && d->object)
- return d->object->metaObject()->property(d->core.coreIndex).isDesignable();
- else
- return false;
-}
-
-/*!
- Returns true if the property is resettable, otherwise false.
-*/
-bool QDeclarativeProperty::isResettable() const
-{
- if (!d)
- return false;
- if (type() & Property && d->core.isValid() && d->object)
- return d->core.isResettable();
- else
- return false;
-}
-
-/*!
- Returns true if the QDeclarativeProperty refers to a valid property, otherwise
- false.
-*/
-bool QDeclarativeProperty::isValid() const
-{
- if (!d)
- return false;
- return type() != Invalid;
-}
-
-/*!
- Return the name of this QML property.
-*/
-QString QDeclarativeProperty::name() const
-{
- if (!d)
- return QString();
- if (!d->isNameCached) {
- // ###
- if (!d->object) {
- } else if (d->isValueType()) {
- QString rv = d->core.name(d->object) + QLatin1Char('.');
-
- QDeclarativeEnginePrivate *ep = d->engine?QDeclarativeEnginePrivate::get(d->engine):0;
- QDeclarativeValueType *valueType = 0;
- if (ep) valueType = ep->valueTypes[d->core.propType];
- else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType);
- Q_ASSERT(valueType);
-
- const char *vtName = valueType->metaObject()->property(d->core.valueTypeCoreIndex).name();
- rv += QString::fromUtf8(vtName);
-
- if (!ep) delete valueType;
-
- d->nameCache = rv;
- } else if (type() & SignalProperty) {
- QString name = QLatin1String("on") + d->core.name(d->object);
- name[2] = name.at(2).toUpper();
- d->nameCache = name;
- } else {
- d->nameCache = d->core.name(d->object);
- }
- d->isNameCached = true;
- }
-
- return d->nameCache;
-}
-
-/*!
- Returns the \l{QMetaProperty} {Qt property} associated with
- this QML property.
- */
-QMetaProperty QDeclarativeProperty::property() const
-{
- if (!d)
- return QMetaProperty();
- if (type() & Property && d->core.isValid() && d->object)
- return d->object->metaObject()->property(d->core.coreIndex);
- else
- return QMetaProperty();
-}
-
-/*!
- Return the QMetaMethod for this property if it is a SignalProperty,
- otherwise returns an invalid QMetaMethod.
-*/
-QMetaMethod QDeclarativeProperty::method() const
-{
- if (!d)
- return QMetaMethod();
- if (type() & SignalProperty && d->object)
- return d->object->metaObject()->method(d->core.coreIndex);
- else
- return QMetaMethod();
-}
-
-/*!
- Returns the binding associated with this property, or 0 if no binding
- exists.
-*/
-QDeclarativeAbstractBinding *
-QDeclarativePropertyPrivate::binding(const QDeclarativeProperty &that)
-{
- if (!that.d || !that.isProperty() || !that.d->object)
- return 0;
-
- return binding(that.d->object, that.d->core.coreIndex,
- that.d->core.getValueTypeCoreIndex());
-}
-
-/*!
- Set the binding associated with this property to \a newBinding. Returns
- the existing binding (if any), otherwise 0.
-
- \a newBinding will be enabled, and the returned binding (if any) will be
- disabled.
-
- Ownership of \a newBinding transfers to QML. Ownership of the return value
- is assumed by the caller.
-
- \a flags is passed through to the binding and is used for the initial update (when
- the binding sets the initial value, it will use these flags for the write).
-*/
-QDeclarativeAbstractBinding *
-QDeclarativePropertyPrivate::setBinding(const QDeclarativeProperty &that,
- QDeclarativeAbstractBinding *newBinding,
- WriteFlags flags)
-{
- if (!that.d || !that.isProperty() || !that.d->object) {
- if (newBinding)
- newBinding->destroy();
- return 0;
- }
-
- if (newBinding) {
- // In the case that the new binding is provided, we must target the property it
- // is associated with. If we don't do this, retargetBinding() can fail.
- QObject *object = newBinding->object();
- int pi = newBinding->propertyIndex();
-
- int core = pi & 0xFFFFFF;
- int vt = (pi & 0xFF000000)?(pi >> 24):-1;
-
- return setBinding(object, core, vt, newBinding, flags);
- } else {
- return setBinding(that.d->object, that.d->core.coreIndex,
- that.d->core.getValueTypeCoreIndex(),
- newBinding, flags);
- }
-}
-
-QDeclarativeAbstractBinding *
-QDeclarativePropertyPrivate::binding(QObject *object, int coreIndex, int valueTypeIndex)
-{
- QDeclarativeData *data = QDeclarativeData::get(object);
- if (!data)
- return 0;
-
- QDeclarativePropertyData *propertyData =
- data->propertyCache?data->propertyCache->property(coreIndex):0;
- if (propertyData && propertyData->isAlias()) {
- const QDeclarativeVMEMetaObject *vme =
- static_cast<const QDeclarativeVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
-
- QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
- if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex) || aCoreIndex == -1)
- return 0;
-
- // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
- Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
- aValueTypeIndex = (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex;
- return binding(aObject, aCoreIndex, aValueTypeIndex);
- }
-
- if (!data->hasBindingBit(coreIndex))
- return 0;
-
- QDeclarativeAbstractBinding *binding = data->bindings;
- while (binding && binding->propertyIndex() != coreIndex)
- binding = binding->m_nextBinding;
-
- if (binding && valueTypeIndex != -1) {
- if (binding->bindingType() == QDeclarativeAbstractBinding::ValueTypeProxy) {
- int index = coreIndex | (valueTypeIndex << 24);
- binding = static_cast<QDeclarativeValueTypeProxyBinding *>(binding)->binding(index);
- }
- }
-
- return binding;
-}
-
-void QDeclarativePropertyPrivate::findAliasTarget(QObject *object, int bindingIndex,
- QObject **targetObject, int *targetBindingIndex)
-{
- int coreIndex = bindingIndex & 0xFFFFFF;
- int valueTypeIndex = bindingIndex >> 24;
- if (valueTypeIndex == 0) valueTypeIndex = -1;
-
- QDeclarativeData *data = QDeclarativeData::get(object, false);
- if (data) {
- QDeclarativePropertyData *propertyData =
- data->propertyCache?data->propertyCache->property(coreIndex):0;
- if (propertyData && propertyData->isAlias()) {
- const QDeclarativeVMEMetaObject *vme =
- static_cast<const QDeclarativeVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
- QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
- if (vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
- // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
- Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
-
- int aBindingIndex = aCoreIndex;
- if (aValueTypeIndex != -1)
- aBindingIndex |= aValueTypeIndex << 24;
- else if (valueTypeIndex != -1)
- aBindingIndex |= valueTypeIndex << 24;
-
- findAliasTarget(aObject, aBindingIndex, targetObject, targetBindingIndex);
- return;
- }
- }
- }
-
- *targetObject = object;
- *targetBindingIndex = bindingIndex;
-}
-
-QDeclarativeAbstractBinding *
-QDeclarativePropertyPrivate::setBinding(QObject *object, int coreIndex, int valueTypeIndex,
- QDeclarativeAbstractBinding *newBinding, WriteFlags flags)
-{
- QDeclarativeData *data = QDeclarativeData::get(object, 0 != newBinding);
- QDeclarativeAbstractBinding *binding = 0;
-
- if (data) {
- QDeclarativePropertyData *propertyData =
- data->propertyCache?data->propertyCache->property(coreIndex):0;
- if (propertyData && propertyData->isAlias()) {
- const QDeclarativeVMEMetaObject *vme =
- static_cast<const QDeclarativeVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
-
- QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
- if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
- if (newBinding) newBinding->destroy();
- return 0;
- }
-
- // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
- Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
- aValueTypeIndex = (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex;
- return setBinding(aObject, aCoreIndex, aValueTypeIndex, newBinding, flags);
- }
- }
-
- if (data && data->hasBindingBit(coreIndex)) {
- binding = data->bindings;
-
- while (binding && binding->propertyIndex() != coreIndex)
- binding = binding->m_nextBinding;
- }
-
- int index = coreIndex;
- if (valueTypeIndex != -1)
- index |= (valueTypeIndex << 24);
-
- if (binding && valueTypeIndex != -1 && binding->bindingType() == QDeclarativeAbstractBinding::ValueTypeProxy)
- binding = static_cast<QDeclarativeValueTypeProxyBinding *>(binding)->binding(index);
-
- if (binding) {
- binding->removeFromObject();
- binding->setEnabled(false, 0);
- }
-
- if (newBinding) {
- if (newBinding->propertyIndex() != index || newBinding->object() != object)
- newBinding->retargetBinding(object, index);
-
- Q_ASSERT(newBinding->propertyIndex() == index);
- Q_ASSERT(newBinding->object() == object);
-
- newBinding->addToObject();
- newBinding->setEnabled(true, flags);
- }
-
- return binding;
-}
-
-QDeclarativeAbstractBinding *
-QDeclarativePropertyPrivate::setBindingNoEnable(QObject *object, int coreIndex, int valueTypeIndex,
- QDeclarativeAbstractBinding *newBinding)
-{
- QDeclarativeData *data = QDeclarativeData::get(object, 0 != newBinding);
- QDeclarativeAbstractBinding *binding = 0;
-
- if (data) {
- QDeclarativePropertyData *propertyData =
- data->propertyCache?data->propertyCache->property(coreIndex):0;
- if (propertyData && propertyData->isAlias()) {
- const QDeclarativeVMEMetaObject *vme =
- static_cast<const QDeclarativeVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
-
- QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
- if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
- if (newBinding) newBinding->destroy();
- return 0;
- }
-
- // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
- Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
- aValueTypeIndex = (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex;
- return setBindingNoEnable(aObject, aCoreIndex, aValueTypeIndex, newBinding);
- }
- }
-
- if (data && data->hasBindingBit(coreIndex)) {
- binding = data->bindings;
-
- while (binding && binding->propertyIndex() != coreIndex)
- binding = binding->m_nextBinding;
- }
-
- int index = coreIndex;
- if (valueTypeIndex != -1)
- index |= (valueTypeIndex << 24);
-
- if (binding && valueTypeIndex != -1 && binding->bindingType() == QDeclarativeAbstractBinding::ValueTypeProxy)
- binding = static_cast<QDeclarativeValueTypeProxyBinding *>(binding)->binding(index);
-
- if (binding)
- binding->removeFromObject();
-
- if (newBinding) {
- if (newBinding->propertyIndex() != index || newBinding->object() != object)
- newBinding->retargetBinding(object, index);
-
- Q_ASSERT(newBinding->propertyIndex() == index);
- Q_ASSERT(newBinding->object() == object);
-
- newBinding->addToObject();
- }
-
- return binding;
-}
-
-/*!
- Returns the expression associated with this signal property, or 0 if no
- signal expression exists.
-*/
-QDeclarativeExpression *
-QDeclarativePropertyPrivate::signalExpression(const QDeclarativeProperty &that)
-{
- if (!(that.type() & QDeclarativeProperty::SignalProperty))
- return 0;
-
- const QObjectList &children = that.d->object->children();
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QObject *child = children.at(ii);
-
- QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal && signal->index() == that.index())
- return signal->expression();
- }
-
- return 0;
-}
-
-/*!
- Set the signal expression associated with this signal property to \a expr.
- Returns the existing signal expression (if any), otherwise 0.
-
- Ownership of \a expr transfers to QML. Ownership of the return value is
- assumed by the caller.
-*/
-QDeclarativeExpression *
-QDeclarativePropertyPrivate::setSignalExpression(const QDeclarativeProperty &that,
- QDeclarativeExpression *expr)
-{
- if (!(that.type() & QDeclarativeProperty::SignalProperty)) {
- delete expr;
- return 0;
- }
-
- const QObjectList &children = that.d->object->children();
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QObject *child = children.at(ii);
-
- QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal && signal->index() == that.index())
- return signal->setExpression(expr);
- }
-
- if (expr) {
- QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(that.d->object, that.method(), that.d->object);
- return signal->setExpression(expr);
- } else {
- return 0;
- }
-}
-
-/*!
- Returns the property value.
-*/
-QVariant QDeclarativeProperty::read() const
-{
- if (!d)
- return QVariant();
- if (!d->object)
- return QVariant();
-
- if (type() & SignalProperty) {
-
- return QVariant();
-
- } else if (type() & Property) {
-
- return d->readValueProperty();
-
- }
- return QVariant();
-}
-
-/*!
-Return the \a name property value of \a object. This method is equivalent to:
-\code
- QDeclarativeProperty p(object, name);
- p.read();
-\endcode
-*/
-QVariant QDeclarativeProperty::read(QObject *object, const QString &name)
-{
- QDeclarativeProperty p(object, name);
- return p.read();
-}
-
-/*!
- Return the \a name property value of \a object using the
- \l{QDeclarativeContext} {context} \a ctxt. This method is
- equivalent to:
-
- \code
- QDeclarativeProperty p(object, name, context);
- p.read();
- \endcode
-*/
-QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeContext *ctxt)
-{
- QDeclarativeProperty p(object, name, ctxt);
- return p.read();
-}
-
-/*!
-
- Return the \a name property value of \a object using the environment
- for instantiating QML components that is provided by \a engine. .
- This method is equivalent to:
-
- \code
- QDeclarativeProperty p(object, name, engine);
- p.read();
- \endcode
-*/
-QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeEngine *engine)
-{
- QDeclarativeProperty p(object, name, engine);
- return p.read();
-}
-
-QVariant QDeclarativePropertyPrivate::readValueProperty()
-{
- if (isValueType()) {
-
- QDeclarativeEnginePrivate *ep = engine?QDeclarativeEnginePrivate::get(engine):0;
- QDeclarativeValueType *valueType = 0;
- if (ep) valueType = ep->valueTypes[core.propType];
- else valueType = QDeclarativeValueTypeFactory::valueType(core.propType);
- Q_ASSERT(valueType);
-
- valueType->read(object, core.coreIndex);
-
- QVariant rv = valueType->metaObject()->property(core.valueTypeCoreIndex).read(valueType);
-
- if (!ep) delete valueType;
- return rv;
-
- } else if (core.isQList()) {
-
- QDeclarativeListProperty<QObject> prop;
- void *args[] = { &prop, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
- return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine));
-
- } else if (core.isQObject()) {
-
- QObject *rv = 0;
- void *args[] = { &rv, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
- return QVariant::fromValue(rv);
-
- } else {
-
- return object->metaObject()->property(core.coreIndex).read(object.data());
-
- }
-}
-
-static QUrl urlFromUserString(const QByteArray &data)
-{
- QUrl u;
- if (!data.isEmpty())
- {
- // Preserve any valid percent-encoded octets supplied by the source
- u.setEncodedUrl(data, QUrl::TolerantMode);
- }
- return u;
-}
-
-static QUrl urlFromUserString(const QString &data)
-{
- return urlFromUserString(data.toUtf8());
-}
-
-// helper function to allow assignment / binding to QList<QUrl> properties.
-static QVariant resolvedUrlSequence(const QVariant &value, QDeclarativeContextData *context)
-{
- QList<QUrl> urls;
- if (value.userType() == qMetaTypeId<QUrl>()) {
- urls.append(value.toUrl());
- } else if (value.userType() == qMetaTypeId<QString>()) {
- urls.append(urlFromUserString(value.toString()));
- } else if (value.userType() == qMetaTypeId<QByteArray>()) {
- urls.append(urlFromUserString(value.toByteArray()));
- } else if (value.userType() == qMetaTypeId<QList<QUrl> >()) {
- urls = value.value<QList<QUrl> >();
- } else if (value.userType() == qMetaTypeId<QStringList>()) {
- QStringList urlStrings = value.value<QStringList>();
- for (int i = 0; i < urlStrings.size(); ++i)
- urls.append(urlFromUserString(urlStrings.at(i)));
- } else if (value.userType() == qMetaTypeId<QList<QString> >()) {
- QList<QString> urlStrings = value.value<QList<QString> >();
- for (int i = 0; i < urlStrings.size(); ++i)
- urls.append(urlFromUserString(urlStrings.at(i)));
- } // note: QList<QByteArray> is not currently supported.
-
- QList<QUrl> resolvedUrls;
- for (int i = 0; i < urls.size(); ++i) {
- QUrl u = urls.at(i);
- if (context && u.isRelative() && !u.isEmpty())
- u = context->resolvedUrl(u);
- resolvedUrls.append(u);
- }
-
- return QVariant::fromValue<QList<QUrl> >(resolvedUrls);
-}
-
-//writeEnumProperty MIRRORS the relelvant bit of QMetaProperty::write AND MUST BE KEPT IN SYNC!
-bool QDeclarativePropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
-{
- if (!object || !prop.isWritable())
- return false;
-
- QVariant v = value;
- if (prop.isEnumType()) {
- QMetaEnum menum = prop.enumerator();
- if (v.userType() == QVariant::String
-#ifdef QT3_SUPPORT
- || v.userType() == QVariant::CString
-#endif
- ) {
- bool ok;
- if (prop.isFlagType())
- v = QVariant(menum.keysToValue(value.toByteArray(), &ok));
- else
- v = QVariant(menum.keyToValue(value.toByteArray(), &ok));
- if (!ok)
- return false;
- } else if (v.userType() != QVariant::Int && v.userType() != QVariant::UInt) {
- int enumMetaTypeId = QMetaType::type(QByteArray(menum.scope() + QByteArray("::") + menum.name()));
- if ((enumMetaTypeId == 0) || (v.userType() != enumMetaTypeId) || !v.constData())
- return false;
- v = QVariant(*reinterpret_cast<const int *>(v.constData()));
- }
- v.convert(QVariant::Int);
- }
-
- // the status variable is changed by qt_metacall to indicate what it did
- // this feature is currently only used by QtDBus and should not be depended
- // upon. Don't change it without looking into QDBusAbstractInterface first
- // -1 (unchanged): normal qt_metacall, result stored in argv[0]
- // changed: result stored directly in value, return the value of status
- int status = -1;
- void *argv[] = { v.data(), &v, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, idx, argv);
- return status;
-}
-
-bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, WriteFlags flags)
-{
- return writeValueProperty(object, engine, core, value, effectiveContext(), flags);
-}
-
-bool
-QDeclarativePropertyPrivate::writeValueProperty(QObject *object, QDeclarativeEngine *engine,
- const QDeclarativePropertyData &core,
- const QVariant &value,
- QDeclarativeContextData *context, WriteFlags flags)
-{
- // Remove any existing bindings on this property
- if (!(flags & DontRemoveBinding) && object) {
- QDeclarativeAbstractBinding *binding = setBinding(object, core.coreIndex,
- core.getValueTypeCoreIndex(),
- 0, flags);
- if (binding) binding->destroy();
- }
-
- bool rv = false;
- if (core.isValueTypeVirtual()) {
- QDeclarativeEnginePrivate *ep = engine?QDeclarativeEnginePrivate::get(engine):0;
-
- QDeclarativeValueType *writeBack = 0;
- if (ep) {
- writeBack = ep->valueTypes[core.propType];
- } else {
- writeBack = QDeclarativeValueTypeFactory::valueType(core.propType);
- }
-
- writeBack->read(object, core.coreIndex);
-
- QDeclarativePropertyData data = core;
- data.setFlags(QDeclarativePropertyData::Flag(core.valueTypeFlags));
- data.coreIndex = core.valueTypeCoreIndex;
- data.propType = core.valueTypePropType;
-
- rv = write(writeBack, data, value, context, flags);
-
- writeBack->write(object, core.coreIndex, flags);
- if (!ep) delete writeBack;
-
- } else {
-
- rv = write(object, core, value, context, flags);
-
- }
-
- return rv;
-}
-
-bool QDeclarativePropertyPrivate::write(QObject *object,
- const QDeclarativePropertyData &property,
- const QVariant &value, QDeclarativeContextData *context,
- WriteFlags flags)
-{
- int coreIdx = property.coreIndex;
- int status = -1; //for dbus
-
- if (property.isEnum()) {
- QMetaProperty prop = object->metaObject()->property(property.coreIndex);
- QVariant v = value;
- // Enum values come through the script engine as doubles
- if (value.userType() == QVariant::Double) {
- double integral;
- double fractional = modf(value.toDouble(), &integral);
- if (qFuzzyIsNull(fractional))
- v.convert(QVariant::Int);
- }
- return writeEnumProperty(prop, coreIdx, object, v, flags);
- }
-
- int propertyType = property.propType;
- int variantType = value.userType();
-
- QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(context);
-
- if (propertyType == QVariant::Url) {
-
- QUrl u;
- bool found = false;
- if (variantType == QVariant::Url) {
- u = value.toUrl();
- found = true;
- } else if (variantType == QVariant::ByteArray) {
- u = urlFromUserString(value.toByteArray());
- found = true;
- } else if (variantType == QVariant::String) {
- u = urlFromUserString(value.toString());
- found = true;
- }
-
- if (!found)
- return false;
-
- if (context && u.isRelative() && !u.isEmpty())
- u = context->resolvedUrl(u);
- int status = -1;
- void *argv[] = { &u, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv);
-
- } else if (propertyType == qMetaTypeId<QList<QUrl> >()) {
- QList<QUrl> urlSeq = resolvedUrlSequence(value, context).value<QList<QUrl> >();
- int status = -1;
- void *argv[] = { &urlSeq, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv);
- } else if (variantType == propertyType) {
-
- void *a[] = { (void *)value.constData(), 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
-
- } else if (qMetaTypeId<QVariant>() == propertyType) {
-
- void *a[] = { (void *)&value, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
-
- } else if (property.isQObject()) {
-
- const QMetaObject *valMo = rawMetaObjectForType(enginePriv, value.userType());
-
- if (!valMo)
- return false;
-
- QObject *o = *(QObject **)value.constData();
- const QMetaObject *propMo = rawMetaObjectForType(enginePriv, propertyType);
-
- if (o) valMo = o->metaObject();
-
- if (canConvert(valMo, propMo)) {
- void *args[] = { &o, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
- args);
- } else if (!o && canConvert(propMo, valMo)) {
- // In the case of a null QObject, we assign the null if there is
- // any change that the null variant type could be up or down cast to
- // the property type.
- void *args[] = { &o, 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
- args);
- } else {
- return false;
- }
-
- } else if (property.isQList()) {
-
- const QMetaObject *listType = 0;
- if (enginePriv) {
- listType = enginePriv->rawMetaObjectForType(enginePriv->listType(property.propType));
- } else {
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(QDeclarativeMetaType::listType(property.propType));
- if (!type) return false;
- listType = type->baseMetaObject();
- }
- if (!listType) return false;
-
- QDeclarativeListProperty<void> prop;
- void *args[] = { &prop, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, coreIdx, args);
-
- if (!prop.clear) return false;
-
- prop.clear(&prop);
-
- if (value.userType() == qMetaTypeId<QDeclarativeListReference>()) {
- QDeclarativeListReference qdlr = value.value<QDeclarativeListReference>();
-
- for (int ii = 0; ii < qdlr.count(); ++ii) {
- QObject *o = qdlr.at(ii);
- if (o && !canConvert(o->metaObject(), listType))
- o = 0;
- prop.append(&prop, (void *)o);
- }
- } else if (value.userType() == qMetaTypeId<QList<QObject *> >()) {
- const QList<QObject *> &list = qvariant_cast<QList<QObject *> >(value);
-
- for (int ii = 0; ii < list.count(); ++ii) {
- QObject *o = list.at(ii);
- if (o && !canConvert(o->metaObject(), listType))
- o = 0;
- prop.append(&prop, (void *)o);
- }
- } else {
- QObject *o = enginePriv?enginePriv->toQObject(value):QDeclarativeMetaType::toQObject(value);
- if (o && !canConvert(o->metaObject(), listType))
- o = 0;
- prop.append(&prop, (void *)o);
- }
-
- } else {
- Q_ASSERT(variantType != propertyType);
-
- bool ok = false;
- QVariant v;
- if (variantType == QVariant::String)
- v = QDeclarativeStringConverters::variantFromString(value.toString(), propertyType, &ok);
- if (!ok) {
- v = value;
- if (v.convert((QVariant::Type)propertyType)) {
- ok = true;
- } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) {
- QDeclarativeMetaType::StringConverter con = QDeclarativeMetaType::customStringConverter(propertyType);
- if (con) {
- v = con(value.toString());
- if (v.userType() == propertyType)
- ok = true;
- }
- }
- }
- if (!ok) {
- // the only other option is that they are assigning a single value
- // to a sequence type property (eg, an int to a QList<int> property).
- // Note that we've already handled single-value assignment to QList<QUrl> properties.
- if (variantType == QVariant::Int && propertyType == qMetaTypeId<QList<int> >()) {
- QList<int> list;
- list << value.toInt();
- v = QVariant::fromValue<QList<int> >(list);
- ok = true;
- } else if (variantType == QVariant::Double && propertyType == qMetaTypeId<QList<qreal> >()) {
- QList<qreal> list;
- list << value.toReal();
- v = QVariant::fromValue<QList<qreal> >(list);
- ok = true;
- } else if (variantType == QVariant::Bool && propertyType == qMetaTypeId<QList<bool> >()) {
- QList<bool> list;
- list << value.toBool();
- v = QVariant::fromValue<QList<bool> >(list);
- ok = true;
- } else if (variantType == QVariant::String && propertyType == qMetaTypeId<QList<QString> >()) {
- QList<QString> list;
- list << value.toString();
- v = QVariant::fromValue<QList<QString> >(list);
- ok = true;
- } else if (variantType == QVariant::String && propertyType == qMetaTypeId<QStringList>()) {
- QStringList list;
- list << value.toString();
- v = QVariant::fromValue<QStringList>(list);
- ok = true;
- }
- }
-
- if (ok) {
- void *a[] = { (void *)v.constData(), 0, &status, &flags};
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
- } else {
- return false;
- }
- }
-
- return true;
-}
-
-// Returns true if successful, false if an error description was set on expression
-bool QDeclarativePropertyPrivate::writeBinding(QObject *object,
- const QDeclarativePropertyData &core,
- QDeclarativeContextData *context,
- QDeclarativeJavaScriptExpression *expression,
- v8::Handle<v8::Value> result, bool isUndefined,
- WriteFlags flags)
-{
- Q_ASSERT(object);
- Q_ASSERT(core.coreIndex != -1);
-
- QDeclarativeEngine *engine = context->engine;
- QV8Engine *v8engine = QDeclarativeEnginePrivate::getV8Engine(engine);
-
-#define QUICK_STORE(cpptype, conversion) \
- { \
- cpptype o = (conversion); \
- int status = -1; \
- void *argv[] = { &o, 0, &status, &flags }; \
- QMetaObject::metacall(object, QMetaObject::WriteProperty, core.coreIndex, argv); \
- return true; \
- } \
-
-
- if (!isUndefined && !core.isValueTypeVirtual()) {
- switch (core.propType) {
- case QMetaType::Int:
- if (result->IsInt32())
- QUICK_STORE(int, result->Int32Value())
- else if (result->IsNumber())
- QUICK_STORE(int, qRound(result->NumberValue()))
- break;
- case QMetaType::Double:
- if (result->IsNumber())
- QUICK_STORE(double, result->NumberValue())
- break;
- case QMetaType::Float:
- if (result->IsNumber())
- QUICK_STORE(float, result->NumberValue())
- break;
- case QMetaType::QString:
- if (result->IsString())
- QUICK_STORE(QString, v8engine->toString(result))
- break;
- default:
- break;
- }
- }
-#undef QUICK_STORE
-
- int type = core.isValueTypeVirtual()?core.valueTypePropType:core.propType;
-
- QDeclarativeJavaScriptExpression::DeleteWatcher watcher(expression);
-
- QVariant value;
- bool isVmeProperty = core.isVMEProperty();
-
- if (isUndefined) {
- } else if (core.isQList()) {
- value = v8engine->toVariant(result, qMetaTypeId<QList<QObject *> >());
- } else if (result->IsNull() && core.isQObject()) {
- value = QVariant::fromValue((QObject *)0);
- } else if (core.propType == qMetaTypeId<QList<QUrl> >()) {
- value = resolvedUrlSequence(v8engine->toVariant(result, qMetaTypeId<QList<QUrl> >()), context);
- } else if (!isVmeProperty) {
- value = v8engine->toVariant(result, type);
- }
-
- if (expression->hasError()) {
- return false;
- } else if (isUndefined && core.isResettable()) {
- void *args[] = { 0 };
- QMetaObject::metacall(object, QMetaObject::ResetProperty, core.coreIndex, args);
- } else if (isUndefined && type == qMetaTypeId<QVariant>()) {
- writeValueProperty(object, engine, core, QVariant(), context, flags);
- } else if (isUndefined) {
- expression->delayedError()->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(type)));
- return false;
- } else if (result->IsFunction()) {
- expression->delayedError()->error.setDescription(QLatin1String("Unable to assign a function to a property."));
- return false;
- } else if (isVmeProperty) {
- typedef QDeclarativeVMEMetaObject VMEMO;
- VMEMO *vmemo = static_cast<VMEMO *>(const_cast<QMetaObject *>(object->metaObject()));
- vmemo->setVMEProperty(core.coreIndex, result);
- } else if (!writeValueProperty(object, engine, core, value, context, flags)) {
-
- if (watcher.wasDeleted())
- return true;
-
- const char *valueType = 0;
- if (value.userType() == QVariant::Invalid) valueType = "null";
- else valueType = QMetaType::typeName(value.userType());
-
- expression->delayedError()->error.setDescription(QLatin1String("Unable to assign ") +
- QLatin1String(valueType) +
- QLatin1String(" to ") +
- QLatin1String(QMetaType::typeName(type)));
- return false;
- }
-
- return true;
-}
-
-bool QDeclarativePropertyPrivate::writeBinding(const QDeclarativeProperty &that,
- QDeclarativeContextData *context,
- QDeclarativeJavaScriptExpression *expression,
- v8::Handle<v8::Value> result, bool isUndefined,
- WriteFlags flags)
-{
- QDeclarativePropertyPrivate *pp = that.d;
-
- if (!pp)
- return true;
-
- QObject *object = that.object();
- if (!object)
- return true;
-
- return writeBinding(object, pp->core, context, expression, result, isUndefined, flags);
-}
-
-const QMetaObject *QDeclarativePropertyPrivate::rawMetaObjectForType(QDeclarativeEnginePrivate *engine, int userType)
-{
- if (engine) {
- return engine->rawMetaObjectForType(userType);
- } else {
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(userType);
- return type?type->baseMetaObject():0;
- }
-}
-
-/*!
- Sets the property value to \a value and returns true.
- Returns false if the property can't be set because the
- \a value is the wrong type, for example.
- */
-bool QDeclarativeProperty::write(const QVariant &value) const
-{
- return QDeclarativePropertyPrivate::write(*this, value, 0);
-}
-
-/*!
- Writes \a value to the \a name property of \a object. This method
- is equivalent to:
-
- \code
- QDeclarativeProperty p(object, name);
- p.write(value);
- \endcode
-*/
-bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value)
-{
- QDeclarativeProperty p(object, name);
- return p.write(value);
-}
-
-/*!
- Writes \a value to the \a name property of \a object using the
- \l{QDeclarativeContext} {context} \a ctxt. This method is
- equivalent to:
-
- \code
- QDeclarativeProperty p(object, name, ctxt);
- p.write(value);
- \endcode
-*/
-bool QDeclarativeProperty::write(QObject *object,
- const QString &name,
- const QVariant &value,
- QDeclarativeContext *ctxt)
-{
- QDeclarativeProperty p(object, name, ctxt);
- return p.write(value);
-}
-
-/*!
-
- Writes \a value to the \a name property of \a object using the
- environment for instantiating QML components that is provided by
- \a engine. This method is equivalent to:
-
- \code
- QDeclarativeProperty p(object, name, engine);
- p.write(value);
- \endcode
-*/
-bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value,
- QDeclarativeEngine *engine)
-{
- QDeclarativeProperty p(object, name, engine);
- return p.write(value);
-}
-
-/*!
- Resets the property and returns true if the property is
- resettable. If the property is not resettable, nothing happens
- and false is returned.
-*/
-bool QDeclarativeProperty::reset() const
-{
- if (isResettable()) {
- void *args[] = { 0 };
- QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex, args);
- return true;
- } else {
- return false;
- }
-}
-
-bool QDeclarativePropertyPrivate::write(const QDeclarativeProperty &that,
- const QVariant &value, WriteFlags flags)
-{
- if (!that.d)
- return false;
- if (that.d->object && that.type() & QDeclarativeProperty::Property &&
- that.d->core.isValid() && that.isWritable())
- return that.d->writeValueProperty(value, flags);
- else
- return false;
-}
-
-/*!
- Returns true if the property has a change notifier signal, otherwise false.
-*/
-bool QDeclarativeProperty::hasNotifySignal() const
-{
- if (type() & Property && d->object) {
- return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal();
- }
- return false;
-}
-
-/*!
- Returns true if the property needs a change notifier signal for bindings
- to remain upto date, false otherwise.
-
- Some properties, such as attached properties or those whose value never
- changes, do not require a change notifier.
-*/
-bool QDeclarativeProperty::needsNotifySignal() const
-{
- return type() & Property && !property().isConstant();
-}
-
-/*!
- Connects the property's change notifier signal to the
- specified \a method of the \a dest object and returns
- true. Returns false if this metaproperty does not
- represent a regular Qt property or if it has no
- change notifier signal, or if the \a dest object does
- not have the specified \a method.
-*/
-bool QDeclarativeProperty::connectNotifySignal(QObject *dest, int method) const
-{
- if (!(type() & Property) || !d->object)
- return false;
-
- QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
- if (prop.hasNotifySignal()) {
- return QDeclarativePropertyPrivate::connect(d->object, prop.notifySignalIndex(), dest, method, Qt::DirectConnection);
- } else {
- return false;
- }
-}
-
-/*!
- Connects the property's change notifier signal to the
- specified \a slot of the \a dest object and returns
- true. Returns false if this metaproperty does not
- represent a regular Qt property or if it has no
- change notifier signal, or if the \a dest object does
- not have the specified \a slot.
-*/
-bool QDeclarativeProperty::connectNotifySignal(QObject *dest, const char *slot) const
-{
- if (!(type() & Property) || !d->object)
- return false;
-
- QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
- if (prop.hasNotifySignal()) {
- QByteArray signal(QByteArray("2") + prop.notifySignal().signature());
- return QObject::connect(d->object, signal.constData(), dest, slot);
- } else {
- return false;
- }
-}
-
-/*!
- Return the Qt metaobject index of the property.
-*/
-int QDeclarativeProperty::index() const
-{
- return d ? d->core.coreIndex : -1;
-}
-
-int QDeclarativePropertyPrivate::valueTypeCoreIndex(const QDeclarativeProperty &that)
-{
- return that.d ? that.d->core.getValueTypeCoreIndex() : -1;
-}
-
-/*!
- Returns the "property index" for use in bindings. The top 8 bits are the value type
- offset, and 0 otherwise. The bottom 24-bits are the regular property index.
-*/
-int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativeProperty &that)
-{
- if (!that.d)
- return -1;
- return bindingIndex(that.d->core);
-}
-
-int QDeclarativePropertyPrivate::bindingIndex(const QDeclarativePropertyData &that)
-{
- int rv = that.coreIndex;
- if (rv != -1 && that.isValueTypeVirtual())
- rv = rv | (that.valueTypeCoreIndex << 24);
- return rv;
-}
-
-QDeclarativePropertyData
-QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObject, int index,
- const QMetaObject *subObject, int subIndex,
- QDeclarativeEngine *)
-{
- QMetaProperty subProp = subObject->property(subIndex);
-
- QDeclarativePropertyData core;
- core.load(metaObject->property(index));
- core.setFlags(core.getFlags() | QDeclarativePropertyData::IsValueTypeVirtual);
- core.valueTypeFlags = QDeclarativePropertyData::flagsForProperty(subProp);
- core.valueTypeCoreIndex = subIndex;
- core.valueTypePropType = subProp.userType();
-
- return core;
-}
-
-QDeclarativeProperty
-QDeclarativePropertyPrivate::restore(QObject *object, const QDeclarativePropertyData &data,
- QDeclarativeContextData *ctxt)
-{
- QDeclarativeProperty prop;
-
- prop.d = new QDeclarativePropertyPrivate;
- prop.d->object = object;
- prop.d->context = ctxt;
- prop.d->engine = ctxt?ctxt->engine:0;
-
- prop.d->core = data;
-
- return prop;
-}
-
-/*!
- Returns true if lhs and rhs refer to the same metaobject data
-*/
-bool QDeclarativePropertyPrivate::equal(const QMetaObject *lhs, const QMetaObject *rhs)
-{
- return lhs == rhs || (1 && lhs && rhs && lhs->d.stringdata == rhs->d.stringdata);
-}
-
-/*!
- Returns true if from inherits to.
-*/
-bool QDeclarativePropertyPrivate::canConvert(const QMetaObject *from, const QMetaObject *to)
-{
- if (from && to == &QObject::staticMetaObject)
- return true;
-
- while (from) {
- if (equal(from, to))
- return true;
- from = from->superClass();
- }
-
- return false;
-}
-
-/*!
- Return the signal corresponding to \a name
-*/
-QMetaMethod QDeclarativePropertyPrivate::findSignalByName(const QMetaObject *mo, const QByteArray &name)
-{
- Q_ASSERT(mo);
- int methods = mo->methodCount();
- for (int ii = methods - 1; ii >= 2; --ii) { // >= 2 to block the destroyed signal
- QMetaMethod method = mo->method(ii);
- QByteArray methodName = method.signature();
- int idx = methodName.indexOf('(');
- methodName = methodName.left(idx);
-
- if (methodName == name)
- return method;
- }
-
- // If no signal is found, but the signal is of the form "onBlahChanged",
- // return the notify signal for the property "Blah"
- if (name.endsWith("Changed")) {
- QByteArray propName = name.mid(0, name.length() - 7);
- int propIdx = mo->indexOfProperty(propName.constData());
- if (propIdx >= 0) {
- QMetaProperty prop = mo->property(propIdx);
- if (prop.hasNotifySignal())
- return prop.notifySignal();
- }
- }
-
- return QMetaMethod();
-}
-
-static inline int QMetaObject_methods(const QMetaObject *metaObject)
-{
- struct Private
- {
- int revision;
- int className;
- int classInfoCount, classInfoData;
- int methodCount, methodData;
- int propertyCount, propertyData;
- };
-
- return reinterpret_cast<const Private *>(metaObject->d.data)->methodCount;
-}
-
-static inline int QMetaObject_properties(const QMetaObject *metaObject)
-{
- struct Private
- {
- int revision;
- int className;
- int classInfoCount, classInfoData;
- int methodCount, methodData;
- int propertyCount, propertyData;
- };
-
- return reinterpret_cast<const Private *>(metaObject->d.data)->propertyCount;
-}
-
-static inline void flush_vme_signal(const QObject *object, int index)
-{
- QDeclarativeData *data = static_cast<QDeclarativeData *>(QObjectPrivate::get(const_cast<QObject *>(object))->declarativeData);
- if (data && data->propertyCache) {
- QDeclarativePropertyData *property = data->propertyCache->method(index);
-
- if (property && property->isVMESignal()) {
- const QMetaObject *metaObject = object->metaObject();
- int methodOffset = metaObject->methodOffset();
-
- while (methodOffset > index) {
- metaObject = metaObject->d.superdata;
- methodOffset -= QMetaObject_methods(metaObject);
- }
-
- QDeclarativeVMEMetaObject *vme =
- static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(metaObject));
-
- vme->connectAliasSignal(index);
- }
- }
-}
-
-/*!
-Connect \a sender \a signal_index to \a receiver \a method_index with the specified
-\a type and \a types. This behaves identically to QMetaObject::connect() except that
-it connects any lazy "proxy" signal connections set up by QML.
-
-It is possible that this logic should be moved to QMetaObject::connect().
-*/
-bool QDeclarativePropertyPrivate::connect(const QObject *sender, int signal_index,
- const QObject *receiver, int method_index,
- int type, int *types)
-{
- flush_vme_signal(sender, signal_index);
- flush_vme_signal(receiver, method_index);
-
- return QMetaObject::connect(sender, signal_index, receiver, method_index, type, types);
-}
-
-void QDeclarativePropertyPrivate::flushSignal(const QObject *sender, int signal_index)
-{
- flush_vme_signal(sender, signal_index);
-}
-
-/*!
-Return \a metaObject's [super] meta object that provides data for \a property.
-*/
-const QMetaObject *QDeclarativePropertyPrivate::metaObjectForProperty(const QMetaObject *metaObject, int property)
-{
- int propertyOffset = metaObject->propertyOffset();
-
- while (propertyOffset > property) {
- metaObject = metaObject->d.superdata;
- propertyOffset -= QMetaObject_properties(metaObject);
- }
-
- return metaObject;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeproperty.h b/src/declarative/qml/qdeclarativeproperty.h
deleted file mode 100644
index 5012d0065d..0000000000
--- a/src/declarative/qml/qdeclarativeproperty.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROPERTY_H
-#define QDECLARATIVEPROPERTY_H
-
-#include <QtCore/qmetaobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QObject;
-class QVariant;
-class QDeclarativeContext;
-class QDeclarativeEngine;
-
-class QDeclarativePropertyPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeProperty
-{
-public:
- enum PropertyTypeCategory {
- InvalidCategory,
- List,
- Object,
- Normal
- };
-
- enum Type {
- Invalid,
- Property,
- SignalProperty
- };
-
- QDeclarativeProperty();
- ~QDeclarativeProperty();
-
- QDeclarativeProperty(QObject *);
- QDeclarativeProperty(QObject *, QDeclarativeContext *);
- QDeclarativeProperty(QObject *, QDeclarativeEngine *);
-
- QDeclarativeProperty(QObject *, const QString &);
- QDeclarativeProperty(QObject *, const QString &, QDeclarativeContext *);
- QDeclarativeProperty(QObject *, const QString &, QDeclarativeEngine *);
-
- QDeclarativeProperty(const QDeclarativeProperty &);
- QDeclarativeProperty &operator=(const QDeclarativeProperty &);
-
- bool operator==(const QDeclarativeProperty &) const;
-
- Type type() const;
- bool isValid() const;
- bool isProperty() const;
- bool isSignalProperty() const;
-
- int propertyType() const;
- PropertyTypeCategory propertyTypeCategory() const;
- const char *propertyTypeName() const;
-
- QString name() const;
-
- QVariant read() const;
- static QVariant read(QObject *, const QString &);
- static QVariant read(QObject *, const QString &, QDeclarativeContext *);
- static QVariant read(QObject *, const QString &, QDeclarativeEngine *);
-
- bool write(const QVariant &) const;
- static bool write(QObject *, const QString &, const QVariant &);
- static bool write(QObject *, const QString &, const QVariant &, QDeclarativeContext *);
- static bool write(QObject *, const QString &, const QVariant &, QDeclarativeEngine *);
-
- bool reset() const;
-
- bool hasNotifySignal() const;
- bool needsNotifySignal() const;
- bool connectNotifySignal(QObject *dest, const char *slot) const;
- bool connectNotifySignal(QObject *dest, int method) const;
-
- bool isWritable() const;
- bool isDesignable() const;
- bool isResettable() const;
- QObject *object() const;
-
- int index() const;
- QMetaProperty property() const;
- QMetaMethod method() const;
-
-private:
- friend class QDeclarativePropertyPrivate;
- QDeclarativePropertyPrivate *d;
-};
-typedef QList<QDeclarativeProperty> QDeclarativeProperties;
-
-inline uint qHash (const QDeclarativeProperty &key)
-{
- return qHash(key.object()) + qHash(key.name());
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPROPERTY_H
diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h
deleted file mode 100644
index fc106cc463..0000000000
--- a/src/declarative/qml/qdeclarativeproperty_p.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROPERTY_P_H
-#define QDECLARATIVEPROPERTY_P_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 "qdeclarativeproperty.h"
-
-#include <private/qobject_p.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativepropertycache_p.h>
-#include <private/qdeclarativeguard_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeContext;
-class QDeclarativeExpression;
-class QDeclarativeEnginePrivate;
-class QDeclarativeJavaScriptExpression;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePropertyPrivate : public QDeclarativeRefCount
-{
-public:
- enum WriteFlag {
- BypassInterceptor = 0x01,
- DontRemoveBinding = 0x02,
- RemoveBindingOnAliasWrite = 0x04
- };
- Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
-
- QDeclarativeContextData *context;
- QDeclarativeEngine *engine;
- QDeclarativeGuard<QObject> object;
-
- QDeclarativePropertyData core;
-
- bool isNameCached:1;
- QString nameCache;
-
- QDeclarativePropertyPrivate();
-
- inline QDeclarativeContextData *effectiveContext() const;
-
- void initProperty(QObject *obj, const QString &name);
- void initDefault(QObject *obj);
-
- bool isValueType() const;
- int propertyType() const;
- QDeclarativeProperty::Type type() const;
- QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const;
-
- QVariant readValueProperty();
- bool writeValueProperty(const QVariant &, WriteFlags);
-
- static const QMetaObject *rawMetaObjectForType(QDeclarativeEnginePrivate *, int);
- static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
- const QVariant &value, int flags);
- static bool writeValueProperty(QObject *, QDeclarativeEngine *,
- const QDeclarativePropertyData &,
- const QVariant &, QDeclarativeContextData *,
- WriteFlags flags = 0);
- static bool write(QObject *, const QDeclarativePropertyData &, const QVariant &,
- QDeclarativeContextData *, WriteFlags flags = 0);
- static void findAliasTarget(QObject *, int, QObject **, int *);
-
- static QDeclarativeAbstractBinding *setBinding(QObject *, int coreIndex,
- int valueTypeIndex /* -1 */,
- QDeclarativeAbstractBinding *,
- WriteFlags flags = DontRemoveBinding);
- static QDeclarativeAbstractBinding *setBindingNoEnable(QObject *, int coreIndex,
- int valueTypeIndex /* -1 */,
- QDeclarativeAbstractBinding *);
- static QDeclarativeAbstractBinding *binding(QObject *, int coreIndex,
- int valueTypeIndex /* -1 */);
-
- static QDeclarativePropertyData saveValueType(const QMetaObject *, int,
- const QMetaObject *, int,
- QDeclarativeEngine *);
- static QDeclarativeProperty restore(QObject *,
- const QDeclarativePropertyData &,
- QDeclarativeContextData *);
-
- static bool equal(const QMetaObject *, const QMetaObject *);
- static bool canConvert(const QMetaObject *from, const QMetaObject *to);
- static inline QDeclarativePropertyPrivate *get(const QDeclarativeProperty &p) {
- return p.d;
- }
-
- // "Public" (to QML) methods
- static QDeclarativeAbstractBinding *binding(const QDeclarativeProperty &that);
- static QDeclarativeAbstractBinding *setBinding(const QDeclarativeProperty &that,
- QDeclarativeAbstractBinding *,
- WriteFlags flags = DontRemoveBinding);
- static QDeclarativeExpression *signalExpression(const QDeclarativeProperty &that);
- static QDeclarativeExpression *setSignalExpression(const QDeclarativeProperty &that,
- QDeclarativeExpression *) ;
- static bool write(const QDeclarativeProperty &that, const QVariant &, WriteFlags);
- static bool writeBinding(const QDeclarativeProperty &that,
- QDeclarativeContextData *context,
- QDeclarativeJavaScriptExpression *expression,
- v8::Handle<v8::Value> result, bool isUndefined,
- WriteFlags flags);
- static bool writeBinding(QObject *, const QDeclarativePropertyData &,
- QDeclarativeContextData *context,
- QDeclarativeJavaScriptExpression *expression,
- v8::Handle<v8::Value> result, bool isUndefined,
- WriteFlags flags);
- static int valueTypeCoreIndex(const QDeclarativeProperty &that);
- static int bindingIndex(const QDeclarativeProperty &that);
- static int bindingIndex(const QDeclarativePropertyData &that);
- static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
- static bool connect(const QObject *sender, int signal_index,
- const QObject *receiver, int method_index,
- int type = 0, int *types = 0);
- static const QMetaObject *metaObjectForProperty(const QMetaObject *, int);
- static void flushSignal(const QObject *sender, int signal_index);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags)
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEPROPERTY_P_H
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
deleted file mode 100644
index 2d7644a7a8..0000000000
--- a/src/declarative/qml/qdeclarativepropertycache.cpp
+++ /dev/null
@@ -1,891 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepropertycache_p.h"
-
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativebinding_p.h"
-#include <private/qv8engine_p.h>
-
-#include <private/qmetaobject_p.h>
-#include <private/qdeclarativeaccessors_p.h>
-
-#include <QtCore/qdebug.h>
-
-#include <ctype.h> // for toupper
-
-Q_DECLARE_METATYPE(QJSValue)
-Q_DECLARE_METATYPE(QDeclarativeV8Handle);
-
-QT_BEGIN_NAMESPACE
-
-#define Q_INT16_MAX 32767
-
-class QDeclarativePropertyCacheMethodArguments
-{
-public:
- QDeclarativePropertyCacheMethodArguments *next;
- int arguments[0];
-};
-
-// Flags that do *NOT* depend on the property's QMetaProperty::userType() and thus are quick
-// to load
-static QDeclarativePropertyData::Flags fastFlagsForProperty(const QMetaProperty &p)
-{
- QDeclarativePropertyData::Flags flags;
-
- if (p.isConstant())
- flags |= QDeclarativePropertyData::IsConstant;
- if (p.isWritable())
- flags |= QDeclarativePropertyData::IsWritable;
- if (p.isResettable())
- flags |= QDeclarativePropertyData::IsResettable;
- if (p.isFinal())
- flags |= QDeclarativePropertyData::IsFinal;
- if (p.isEnumType())
- flags |= QDeclarativePropertyData::IsEnumType;
-
- return flags;
-}
-
-// Flags that do depend on the property's QMetaProperty::userType() and thus are slow to
-// load
-static QDeclarativePropertyData::Flags flagsForPropertyType(int propType, QDeclarativeEngine *engine)
-{
- Q_ASSERT(propType != -1);
-
- QDeclarativePropertyData::Flags flags;
-
- if (propType == QMetaType::QObjectStar || propType == QMetaType::QWidgetStar) {
- flags |= QDeclarativePropertyData::IsQObjectDerived;
- } else if (propType == QMetaType::QVariant) {
- flags |= QDeclarativePropertyData::IsQVariant;
- } else if (propType < (int)QVariant::UserType) {
- } else if (propType == qMetaTypeId<QDeclarativeBinding *>()) {
- flags |= QDeclarativePropertyData::IsQmlBinding;
- } else if (propType == qMetaTypeId<QJSValue>()) {
- flags |= QDeclarativePropertyData::IsQJSValue;
- } else if (propType == qMetaTypeId<QDeclarativeV8Handle>()) {
- flags |= QDeclarativePropertyData::IsV8Handle;
- } else {
- QDeclarativeMetaType::TypeCategory cat =
- engine ? QDeclarativeEnginePrivate::get(engine)->typeCategory(propType)
- : QDeclarativeMetaType::typeCategory(propType);
-
- if (cat == QDeclarativeMetaType::Object)
- flags |= QDeclarativePropertyData::IsQObjectDerived;
- else if (cat == QDeclarativeMetaType::List)
- flags |= QDeclarativePropertyData::IsQList;
- }
-
- return flags;
-}
-
-static int metaObjectSignalCount(const QMetaObject *metaObject)
-{
- int signalCount = 0;
- for (const QMetaObject *obj = metaObject; obj; obj = obj->superClass())
- signalCount += QMetaObjectPrivate::get(obj)->signalCount;
- return signalCount;
-}
-
-QDeclarativePropertyData::Flags
-QDeclarativePropertyData::flagsForProperty(const QMetaProperty &p, QDeclarativeEngine *engine)
-{
- return fastFlagsForProperty(p) | flagsForPropertyType(p.userType(), engine);
-}
-
-void QDeclarativePropertyData::lazyLoad(const QMetaProperty &p, QDeclarativeEngine *engine)
-{
- Q_UNUSED(engine);
-
- coreIndex = p.propertyIndex();
- notifyIndex = p.notifySignalIndex();
- Q_ASSERT(p.revision() <= Q_INT16_MAX);
- revision = p.revision();
-
- flags = fastFlagsForProperty(p);
-
- int type = p.type();
- if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) {
- propType = type;
- flags |= QDeclarativePropertyData::IsQObjectDerived;
- } else if (type == QMetaType::QVariant) {
- propType = type;
- flags |= QDeclarativePropertyData::IsQVariant;
- } else if (type == QVariant::UserType || type == -1) {
- propTypeName = p.typeName();
- flags |= QDeclarativePropertyData::NotFullyResolved;
- } else {
- propType = type;
- }
-}
-
-void QDeclarativePropertyData::load(const QMetaProperty &p, QDeclarativeEngine *engine)
-{
- propType = p.userType();
- coreIndex = p.propertyIndex();
- notifyIndex = p.notifySignalIndex();
- flags = fastFlagsForProperty(p) | flagsForPropertyType(propType, engine);
- Q_ASSERT(p.revision() <= Q_INT16_MAX);
- revision = p.revision();
-}
-
-void QDeclarativePropertyData::load(const QMetaMethod &m)
-{
- coreIndex = m.methodIndex();
- arguments = 0;
- flags |= IsFunction;
- if (m.methodType() == QMetaMethod::Signal)
- flags |= IsSignal;
- propType = QVariant::Invalid;
-
- const char *returnType = m.typeName();
- if (returnType)
- propType = QMetaType::type(returnType);
-
- const char *signature = m.signature();
- while (*signature != '(') { Q_ASSERT(*signature != 0); ++signature; }
-
- ++signature;
- if (*signature != ')') {
- flags |= HasArguments;
- if (0 == ::strcmp(signature, "QDeclarativeV8Function*)")) {
- flags |= IsV8Function;
- }
- }
-
- Q_ASSERT(m.revision() <= Q_INT16_MAX);
- revision = m.revision();
-}
-
-void QDeclarativePropertyData::lazyLoad(const QMetaMethod &m)
-{
- coreIndex = m.methodIndex();
- arguments = 0;
- flags |= IsFunction;
- if (m.methodType() == QMetaMethod::Signal)
- flags |= IsSignal;
- propType = QVariant::Invalid;
-
- const char *returnType = m.typeName();
- if (returnType && *returnType) {
- propTypeName = returnType;
- flags |= NotFullyResolved;
- }
-
- const char *signature = m.signature();
- while (*signature != '(') { Q_ASSERT(*signature != 0); ++signature; }
-
- ++signature;
- if (*signature != ')') {
- flags |= HasArguments;
- if (0 == ::strcmp(signature, "QDeclarativeV8Function*)")) {
- flags |= IsV8Function;
- }
- }
-
- Q_ASSERT(m.revision() <= Q_INT16_MAX);
- revision = m.revision();
-}
-
-/*!
-Creates a new empty QDeclarativePropertyCache.
-*/
-QDeclarativePropertyCache::QDeclarativePropertyCache(QDeclarativeEngine *e)
-: engine(e), parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
- signalHanderIndexCacheStart(0), metaObject(0), argumentsCache(0)
-{
- Q_ASSERT(engine);
-}
-
-/*!
-Creates a new QDeclarativePropertyCache of \a metaObject.
-*/
-QDeclarativePropertyCache::QDeclarativePropertyCache(QDeclarativeEngine *e, const QMetaObject *metaObject)
-: engine(e), parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
- signalHanderIndexCacheStart(0), metaObject(0), argumentsCache(0)
-{
- Q_ASSERT(engine);
- Q_ASSERT(metaObject);
-
- update(engine, metaObject);
-}
-
-QDeclarativePropertyCache::~QDeclarativePropertyCache()
-{
- clear();
-
- QDeclarativePropertyCacheMethodArguments *args = argumentsCache;
- while (args) {
- QDeclarativePropertyCacheMethodArguments *next = args->next;
- free(args);
- args = next;
- }
-
- // We must clear this prior to releasing the parent incase it is a
- // linked hash
- stringCache.clear();
- if (parent) parent->release();
- parent = 0;
- engine = 0;
-}
-
-void QDeclarativePropertyCache::destroy()
-{
- Q_ASSERT(engine || constructor.IsEmpty());
- if (constructor.IsEmpty())
- delete this;
- else
- QDeclarativeEnginePrivate::deleteInEngineThread(engine, this);
-}
-
-// This is inherited from QDeclarativeCleanup, so it should only clear the things
-// that are tied to the specific QDeclarativeEngine.
-void QDeclarativePropertyCache::clear()
-{
- qPersistentDispose(constructor);
- engine = 0;
-}
-
-QDeclarativePropertyCache *QDeclarativePropertyCache::copy(int reserve)
-{
- QDeclarativePropertyCache *cache = new QDeclarativePropertyCache(engine);
- cache->parent = this;
- cache->parent->addref();
- cache->propertyIndexCacheStart = propertyIndexCache.count() + propertyIndexCacheStart;
- cache->methodIndexCacheStart = methodIndexCache.count() + methodIndexCacheStart;
- cache->signalHanderIndexCacheStart = signalHandlerIndexCache.count() + signalHanderIndexCacheStart;
- cache->stringCache.linkAndReserve(stringCache, reserve);
- cache->allowedRevisionCache = allowedRevisionCache;
- cache->metaObject = metaObject;
-
- // We specifically do *NOT* copy the constructor
-
- return cache;
-}
-
-QDeclarativePropertyCache *QDeclarativePropertyCache::copy()
-{
- return copy(0);
-}
-
-QDeclarativePropertyCache *
-QDeclarativePropertyCache::copyAndAppend(QDeclarativeEngine *engine, const QMetaObject *metaObject,
- QDeclarativePropertyData::Flag propertyFlags,
- QDeclarativePropertyData::Flag methodFlags,
- QDeclarativePropertyData::Flag signalFlags)
-{
- return copyAndAppend(engine, metaObject, -1, propertyFlags, methodFlags, signalFlags);
-}
-
-QDeclarativePropertyCache *
-QDeclarativePropertyCache::copyAndAppend(QDeclarativeEngine *engine, const QMetaObject *metaObject,
- int revision,
- QDeclarativePropertyData::Flag propertyFlags,
- QDeclarativePropertyData::Flag methodFlags,
- QDeclarativePropertyData::Flag signalFlags)
-{
- Q_ASSERT(QMetaObjectPrivate::get(metaObject)->revision >= 4);
-
- // Reserve enough space in the name hash for all the methods (including signals), all the
- // signal handlers and all the properties. This assumes no name clashes, but this is the
- // common case.
- QDeclarativePropertyCache *rv = copy(QMetaObjectPrivate::get(metaObject)->methodCount +
- QMetaObjectPrivate::get(metaObject)->signalCount +
- QMetaObjectPrivate::get(metaObject)->propertyCount);
-
- rv->append(engine, metaObject, revision, propertyFlags, methodFlags, signalFlags);
-
- return rv;
-}
-
-void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaObject *metaObject,
- QDeclarativePropertyData::Flag propertyFlags,
- QDeclarativePropertyData::Flag methodFlags,
- QDeclarativePropertyData::Flag signalFlags)
-{
- append(engine, metaObject, -1, propertyFlags, methodFlags, signalFlags);
-}
-
-void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaObject *metaObject,
- int revision,
- QDeclarativePropertyData::Flag propertyFlags,
- QDeclarativePropertyData::Flag methodFlags,
- QDeclarativePropertyData::Flag signalFlags)
-{
- Q_UNUSED(revision);
- Q_ASSERT(constructor.IsEmpty()); // We should not be appending to an in-use property cache
-
- this->metaObject = metaObject;
-
- bool dynamicMetaObject = isDynamicMetaObject(metaObject);
-
- allowedRevisionCache.append(0);
-
- int methodCount = metaObject->methodCount();
- Q_ASSERT(QMetaObjectPrivate::get(metaObject)->revision >= 4);
- int signalCount = metaObjectSignalCount(metaObject);
- int classInfoCount = QMetaObjectPrivate::get(metaObject)->classInfoCount;
-
- QDeclarativeAccessorProperties::Properties accessorProperties;
-
- // Special case QObject as we don't want to add a qt_HasQmlAccessors classinfo to it
- if (metaObject == &QObject::staticMetaObject) {
- accessorProperties = QDeclarativeAccessorProperties::properties(metaObject);
- } else if (classInfoCount) {
- int classInfoOffset = metaObject->classInfoOffset();
- bool hasFastProperty = false;
- for (int ii = 0; ii < classInfoCount; ++ii) {
- int idx = ii + classInfoOffset;
-
- if (0 == qstrcmp(metaObject->classInfo(idx).name(), "qt_HasQmlAccessors")) {
- hasFastProperty = true;
- break;
- }
- }
-
- if (hasFastProperty) {
- accessorProperties = QDeclarativeAccessorProperties::properties(metaObject);
- if (accessorProperties.count == 0)
- qFatal("QDeclarativePropertyCache: %s has FastProperty class info, but has not "
- "installed property accessors", metaObject->className());
- } else {
-#ifndef QT_NO_DEBUG
- accessorProperties = QDeclarativeAccessorProperties::properties(metaObject);
- if (accessorProperties.count != 0)
- qFatal("QDeclarativePropertyCache: %s has fast property accessors, but is missing "
- "FastProperty class info", metaObject->className());
-#endif
- }
- }
-
- // qMax(defaultMethods, methodOffset) to block the signals and slots of QObject::staticMetaObject
- // incl. destroyed signals, objectNameChanged signal, deleteLater slot, _q_reregisterTimers slot.
- int methodOffset = qMax(QObject::staticMetaObject.methodCount(), metaObject->methodOffset());
- int signalOffset = signalCount - QMetaObjectPrivate::get(metaObject)->signalCount;
-
- // update() should have reserved enough space in the vector that this doesn't cause a realloc
- // and invalidate the stringCache.
- methodIndexCache.resize(methodCount - methodIndexCacheStart);
- signalHandlerIndexCache.resize(signalCount - signalHanderIndexCacheStart);
- int signalHandlerIndex = signalOffset;
- for (int ii = methodOffset; ii < methodCount; ++ii) {
- QMetaMethod m = metaObject->method(ii);
- if (m.access() == QMetaMethod::Private)
- continue;
-
- // Extract method name
- const char *signature = m.signature();
- const char *cptr = signature;
- char utf8 = 0;
- while (*cptr != '(') {
- Q_ASSERT(*cptr != 0);
- utf8 |= *cptr & 0x80;
- ++cptr;
- }
-
- QDeclarativePropertyData *data = &methodIndexCache[ii - methodIndexCacheStart];
- QDeclarativePropertyData *sigdata = 0;
-
- data->lazyLoad(m);
-
- if (data->isSignal())
- data->flags |= signalFlags;
- else
- data->flags |= methodFlags;
-
- if (!dynamicMetaObject)
- data->flags |= QDeclarativePropertyData::IsDirect;
-
- Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX);
- data->metaObjectOffset = allowedRevisionCache.count() - 1;
-
- if (data->isSignal()) {
- sigdata = &signalHandlerIndexCache[signalHandlerIndex - signalHanderIndexCacheStart];
- *sigdata = *data;
- sigdata->flags |= QDeclarativePropertyData::IsSignalHandler;
- }
-
- QDeclarativePropertyData *old = 0;
-
- if (utf8) {
- QHashedString methodName(QString::fromUtf8(signature, cptr - signature));
- if (QDeclarativePropertyData **it = stringCache.value(methodName))
- old = *it;
- stringCache.insert(methodName, data);
-
- if (data->isSignal()) {
- QHashedString on(QStringLiteral("on") % methodName.at(0).toUpper() % methodName.midRef(1));
- stringCache.insert(on, sigdata);
- ++signalHandlerIndex;
- }
- } else {
- QHashedCStringRef methodName(signature, cptr - signature);
- if (QDeclarativePropertyData **it = stringCache.value(methodName))
- old = *it;
- stringCache.insert(methodName, data);
-
- if (data->isSignal()) {
- int length = methodName.length();
-
- QVarLengthArray<char, 128> str(length+3);
- str[0] = 'o';
- str[1] = 'n';
- str[2] = toupper(signature[0]);
- if (length > 1)
- memcpy(&str[3], &signature[1], length - 1);
- str[length + 2] = '\0';
-
- QHashedString on(QString::fromLatin1(str.data()));
- stringCache.insert(on, sigdata);
- ++signalHandlerIndex;
- }
- }
-
- if (old) {
- // We only overload methods in the same class, exactly like C++
- if (old->isFunction() && old->coreIndex >= methodOffset)
- data->flags |= QDeclarativePropertyData::IsOverload;
- data->overrideIndexIsProperty = !old->isFunction();
- data->overrideIndex = old->coreIndex;
- }
- }
-
- int propCount = metaObject->propertyCount();
- int propOffset = metaObject->propertyOffset();
-
- // update() should have reserved enough space in the vector that this doesn't cause a realloc
- // and invalidate the stringCache.
- propertyIndexCache.resize(propCount - propertyIndexCacheStart);
- for (int ii = propOffset; ii < propCount; ++ii) {
- QMetaProperty p = metaObject->property(ii);
- if (!p.isScriptable())
- continue;
-
- const char *str = p.name();
- char utf8 = 0;
- const char *cptr = str;
- while (*cptr != 0) {
- utf8 |= *cptr & 0x80;
- ++cptr;
- }
-
- QDeclarativePropertyData *data = &propertyIndexCache[ii - propertyIndexCacheStart];
-
- data->lazyLoad(p, engine);
- data->flags |= propertyFlags;
-
- if (!dynamicMetaObject)
- data->flags |= QDeclarativePropertyData::IsDirect;
-
- Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX);
- data->metaObjectOffset = allowedRevisionCache.count() - 1;
-
- QDeclarativePropertyData *old = 0;
-
- if (utf8) {
- QHashedString propName(QString::fromUtf8(str, cptr - str));
- if (QDeclarativePropertyData **it = stringCache.value(propName))
- old = *it;
- stringCache.insert(propName, data);
- } else {
- QHashedCStringRef propName(str, cptr - str);
- if (QDeclarativePropertyData **it = stringCache.value(propName))
- old = *it;
- stringCache.insert(propName, data);
- }
-
- QDeclarativeAccessorProperties::Property *accessorProperty = accessorProperties.property(str);
-
- // Fast properties may not be overrides or revisioned
- Q_ASSERT(accessorProperty == 0 || (old == 0 && data->revision == 0));
-
- if (accessorProperty) {
- data->flags |= QDeclarativePropertyData::HasAccessors;
- data->accessors = accessorProperty->accessors;
- data->accessorData = accessorProperty->data;
- } else if (old) {
- data->overrideIndexIsProperty = !old->isFunction();
- data->overrideIndex = old->coreIndex;
- }
- }
-}
-
-void QDeclarativePropertyCache::resolve(QDeclarativePropertyData *data) const
-{
- Q_ASSERT(data->notFullyResolved());
-
- data->propType = QMetaType::type(data->propTypeName);
-
- if (!data->isFunction())
- data->flags |= flagsForPropertyType(data->propType, engine);
-
- data->flags &= ~QDeclarativePropertyData::NotFullyResolved;
-}
-
-void QDeclarativePropertyCache::updateRecur(QDeclarativeEngine *engine, const QMetaObject *metaObject)
-{
- if (!metaObject)
- return;
-
- updateRecur(engine, metaObject->superClass());
-
- append(engine, metaObject);
-}
-
-void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaObject *metaObject)
-{
- Q_ASSERT(engine);
- Q_ASSERT(metaObject);
- Q_ASSERT(stringCache.isEmpty());
-
- // Preallocate enough space in the index caches for all the properties/methods/signals that
- // are not cached in a parent cache so that the caches never need to be reallocated as this
- // would invalidate pointers stored in the stringCache.
- int pc = metaObject->propertyCount();
- int mc = metaObject->methodCount();
- int sc = metaObjectSignalCount(metaObject);
- propertyIndexCache.reserve(pc - propertyIndexCacheStart);
- methodIndexCache.reserve(mc - methodIndexCacheStart);
- signalHandlerIndexCache.reserve(sc - signalHanderIndexCacheStart);
-
- // Reserve enough space in the stringCache for all properties/methods/signals including those
- // cached in a parent cache.
- stringCache.reserve(pc + mc + sc);
-
- updateRecur(engine,metaObject);
-}
-
-QDeclarativePropertyData *
-QDeclarativePropertyCache::property(int index) const
-{
- if (index < 0 || index >= (propertyIndexCacheStart + propertyIndexCache.count()))
- return 0;
-
- if (index < propertyIndexCacheStart)
- return parent->property(index);
-
- QDeclarativePropertyData *rv = const_cast<QDeclarativePropertyData *>(&propertyIndexCache.at(index - propertyIndexCacheStart));
- if (rv->notFullyResolved()) resolve(rv);
- return rv;
-}
-
-QDeclarativePropertyData *
-QDeclarativePropertyCache::method(int index) const
-{
- if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count()))
- return 0;
-
- if (index < methodIndexCacheStart)
- return parent->method(index);
-
- QDeclarativePropertyData *rv = const_cast<QDeclarativePropertyData *>(&methodIndexCache.at(index - methodIndexCacheStart));
- if (rv->notFullyResolved()) resolve(rv);
- return rv;
-}
-
-QDeclarativePropertyData *
-QDeclarativePropertyCache::property(const QHashedStringRef &str) const
-{
- QDeclarativePropertyData **rv = stringCache.value(str);
- if (rv && (*rv)->notFullyResolved()) resolve(*rv);
- return rv?*rv:0;
-}
-
-QDeclarativePropertyData *
-QDeclarativePropertyCache::property(const QHashedCStringRef &str) const
-{
- QDeclarativePropertyData **rv = stringCache.value(str);
- if (rv && (*rv)->notFullyResolved()) resolve(*rv);
- return rv?*rv:0;
-}
-
-QDeclarativePropertyData *
-QDeclarativePropertyCache::property(const QString &str) const
-{
- QDeclarativePropertyData **rv = stringCache.value(str);
- if (rv && (*rv)->notFullyResolved()) resolve(*rv);
- return rv?*rv:0;
-}
-
-QString QDeclarativePropertyData::name(QObject *object)
-{
- if (!object)
- return QString();
-
- return name(object->metaObject());
-}
-
-QString QDeclarativePropertyData::name(const QMetaObject *metaObject)
-{
- if (!metaObject || coreIndex == -1)
- return QString();
-
- if (flags & IsFunction) {
- QMetaMethod m = metaObject->method(coreIndex);
-
- QString name = QString::fromUtf8(m.signature());
- int parenIdx = name.indexOf(QLatin1Char('('));
- if (parenIdx != -1)
- name = name.left(parenIdx);
- return name;
- } else {
- QMetaProperty p = metaObject->property(coreIndex);
- return QString::fromUtf8(p.name());
- }
-}
-
-QStringList QDeclarativePropertyCache::propertyNames() const
-{
- QStringList keys;
- for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter)
- keys.append(iter.key());
- return keys;
-}
-
-static int EnumType(const QMetaObject *meta, const QByteArray &str)
-{
- QByteArray scope;
- QByteArray name;
- int scopeIdx = str.lastIndexOf("::");
- if (scopeIdx != -1) {
- scope = str.left(scopeIdx);
- name = str.mid(scopeIdx + 2);
- } else {
- name = str;
- }
- for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
- QMetaEnum m = meta->enumerator(i);
- if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope)))
- return QVariant::Int;
- }
- return QVariant::Invalid;
-}
-
-// Returns an array of the arguments for method \a index. The first entry in the array
-// is the number of arguments.
-int *QDeclarativePropertyCache::methodParameterTypes(QObject *object, int index,
- QVarLengthArray<int, 9> &dummy,
- QByteArray *unknownTypeError)
-{
- Q_ASSERT(object && index >= 0);
-
- QDeclarativeData *ddata = QDeclarativeData::get(object, false);
-
- if (ddata && ddata->propertyCache) {
- typedef QDeclarativePropertyCacheMethodArguments A;
-
- QDeclarativePropertyCache *c = ddata->propertyCache;
- Q_ASSERT(index < c->methodIndexCacheStart + c->methodIndexCache.count());
-
- while (index < c->methodIndexCacheStart)
- c = c->parent;
-
- QDeclarativePropertyData *rv = const_cast<QDeclarativePropertyData *>(&c->methodIndexCache.at(index - c->methodIndexCacheStart));
-
- if (rv->arguments)
- return static_cast<A *>(rv->arguments)->arguments;
-
- const QMetaObject *metaObject = object->metaObject();
- QMetaMethod m = metaObject->method(index);
- QList<QByteArray> argTypeNames = m.parameterTypes();
-
- A *args = static_cast<A *>(malloc(sizeof(A) + (argTypeNames.count() + 1) * sizeof(int)));
- args->arguments[0] = argTypeNames.count();
-
- for (int ii = 0; ii < argTypeNames.count(); ++ii) {
- int type = QMetaType::type(argTypeNames.at(ii));
- if (type == QVariant::Invalid)
- type = EnumType(object->metaObject(), argTypeNames.at(ii));
- if (type == QVariant::Invalid) {
- if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii);
- free(args);
- return 0;
- }
- args->arguments[ii + 1] = type;
- }
-
- rv->arguments = args;
- args->next = c->argumentsCache;
- c->argumentsCache = args;
- return static_cast<A *>(rv->arguments)->arguments;
-
- } else {
- QMetaMethod m = object->metaObject()->method(index);
- QList<QByteArray> argTypeNames = m.parameterTypes();
- dummy.resize(argTypeNames.count() + 1);
- dummy[0] = argTypeNames.count();
-
- for (int ii = 0; ii < argTypeNames.count(); ++ii) {
- int type = QMetaType::type(argTypeNames.at(ii));
- if (type == QVariant::Invalid)
- type = EnumType(object->metaObject(), argTypeNames.at(ii));
- if (type == QVariant::Invalid) {
- if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii);
- return 0;
- }
- dummy[ii + 1] = type;
- }
-
- return dummy.data();
- }
-}
-
-QDeclarativePropertyData qDeclarativePropertyCacheCreate(const QMetaObject *metaObject,
- const QString &property)
-{
- Q_ASSERT(metaObject);
-
- QDeclarativePropertyData rv;
- {
- const QMetaObject *cmo = metaObject;
- const QByteArray propertyName = property.toUtf8();
- while (cmo) {
- int idx = cmo->indexOfProperty(propertyName);
- if (idx != -1) {
- QMetaProperty p = cmo->property(idx);
- if (p.isScriptable()) {
- rv.load(p);
- return rv;
- } else {
- while (cmo && cmo->propertyOffset() >= idx)
- cmo = cmo->superClass();
- }
- } else {
- cmo = 0;
- }
- }
- }
-
- int methodCount = metaObject->methodCount();
- int defaultMethods = QObject::staticMetaObject.methodCount();
- for (int ii = methodCount - 1; ii >= defaultMethods; --ii) {
- // >=defaultMethods to block the signals and slots of QObject::staticMetaObject
- // incl. destroyed signals, objectNameChanged signal, deleteLater slot, _q_reregisterTimers slot.
- QMetaMethod m = metaObject->method(ii);
- if (m.access() == QMetaMethod::Private)
- continue;
- QString methodName = QString::fromUtf8(m.signature());
-
- int parenIdx = methodName.indexOf(QLatin1Char('('));
- Q_ASSERT(parenIdx != -1);
- QStringRef methodNameRef = methodName.leftRef(parenIdx);
-
- if (methodNameRef == property) {
- rv.load(m);
- return rv;
- }
- }
-
- return rv;
-}
-
-inline const QString &qDeclarativePropertyCacheToString(const QString &string)
-{
- return string;
-}
-
-inline QString qDeclarativePropertyCacheToString(const QHashedV8String &string)
-{
- return QV8Engine::toStringStatic(string.string());
-}
-
-template<typename T>
-QDeclarativePropertyData *
-qDeclarativePropertyCacheProperty(QDeclarativeEngine *engine, QObject *obj,
- const T &name, QDeclarativePropertyData &local)
-{
- QDeclarativePropertyCache *cache = 0;
-
- if (engine) {
- QDeclarativeData *ddata = QDeclarativeData::get(obj);
-
- if (ddata && ddata->propertyCache) {
- cache = ddata->propertyCache;
- } else if (engine) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- cache = ep->cache(obj);
- if (cache) {
- ddata = QDeclarativeData::get(obj, true);
- cache->addref();
- ddata->propertyCache = cache;
- }
- }
- }
-
- QDeclarativePropertyData *rv = 0;
-
- if (cache) {
- rv = cache->property(name);
- } else {
- local = qDeclarativePropertyCacheCreate(obj->metaObject(),
- qDeclarativePropertyCacheToString(name));
- if (local.isValid())
- rv = &local;
- }
-
- return rv;
-}
-
-QDeclarativePropertyData *
-QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj,
- const QHashedV8String &name, QDeclarativePropertyData &local)
-{
- return qDeclarativePropertyCacheProperty<QHashedV8String>(engine, obj, name, local);
-}
-
-QDeclarativePropertyData *
-QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj,
- const QString &name, QDeclarativePropertyData &local)
-{
- return qDeclarativePropertyCacheProperty<QString>(engine, obj, name, local);
-}
-
-static inline const QMetaObjectPrivate *priv(const uint* data)
-{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
-
-bool QDeclarativePropertyCache::isDynamicMetaObject(const QMetaObject *mo)
-{
- return priv(mo->d.data)->revision >= 3 && priv(mo->d.data)->flags & DynamicMetaObject;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
deleted file mode 100644
index 301f70bfe8..0000000000
--- a/src/declarative/qml/qdeclarativepropertycache_p.h
+++ /dev/null
@@ -1,384 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROPERTYCACHE_P_H
-#define QDECLARATIVEPROPERTYCACHE_P_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 <private/qdeclarativerefcount_p.h>
-#include "qdeclarativecleanup_p.h"
-#include "qdeclarativenotifier_p.h"
-
-#include <private/qhashedstring_p.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qvector.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-class QMetaProperty;
-class QV8QObjectWrapper;
-class QDeclarativeEngine;
-class QDeclarativePropertyData;
-class QDeclarativeAccessors;
-class QDeclarativePropertyCacheMethodArguments;
-
-// We have this somewhat awful split between RawData and Data so that RawData can be
-// used in unions. In normal code, you should always use Data which initializes RawData
-// to an invalid state on construction.
-class QDeclarativePropertyRawData
-{
-public:
- enum Flag {
- NoFlags = 0x00000000,
- ValueTypeFlagMask = 0x0000FFFF, // Flags in valueTypeFlags must fit in this mask
-
- // Can apply to all properties, except IsFunction
- IsConstant = 0x00000001, // Has CONST flag
- IsWritable = 0x00000002, // Has WRITE function
- IsResettable = 0x00000004, // Has RESET function
- IsAlias = 0x00000008, // Is a QML alias to another property
- IsFinal = 0x00000010, // Has FINAL flag
- IsDirect = 0x00000020, // Exists on a C++ QMetaObject
- HasAccessors = 0x00000040, // Has property accessors
-
- // These are mutualy exclusive
- IsFunction = 0x00000080, // Is an invokable
- IsQObjectDerived = 0x00000100, // Property type is a QObject* derived type
- IsEnumType = 0x00000200, // Property type is an enum
- IsQList = 0x00000400, // Property type is a QML list
- IsQmlBinding = 0x00000800, // Property type is a QDeclarativeBinding*
- IsQJSValue = 0x00001000, // Property type is a QScriptValue
- IsV8Handle = 0x00002000, // Property type is a QDeclarativeV8Handle
- IsVMEProperty = 0x00004000, // Property type is a "var" property of VMEMO
- IsValueTypeVirtual = 0x00008000, // Property is a value type "virtual" property
- IsQVariant = 0x00010000, // Property is a QVariant
-
- // Apply only to IsFunctions
- IsVMEFunction = 0x00020000, // Function was added by QML
- HasArguments = 0x00040000, // Function takes arguments
- IsSignal = 0x00080000, // Function is a signal
- IsVMESignal = 0x00100000, // Signal was added by QML
- IsV8Function = 0x00200000, // Function takes QDeclarativeV8Function* args
- IsSignalHandler = 0x00400000, // Function is a signal handler
- IsOverload = 0x00800000, // Function is an overload of another function
-
- // Internal QDeclarativePropertyCache flags
- NotFullyResolved = 0x01000000 // True if the type data is to be lazily resolved
- };
- Q_DECLARE_FLAGS(Flags, Flag)
-
- Flags getFlags() const { return Flag(flags); }
- void setFlags(Flags f) { flags = f; }
-
- bool isValid() const { return coreIndex != -1; }
-
- bool isConstant() const { return flags & IsConstant; }
- bool isWritable() const { return flags & IsWritable; }
- bool isResettable() const { return flags & IsResettable; }
- bool isAlias() const { return flags & IsAlias; }
- bool isFinal() const { return flags & IsFinal; }
- bool isDirect() const { return flags & IsDirect; }
- bool hasAccessors() const { return flags & HasAccessors; }
- bool isFunction() const { return flags & IsFunction; }
- bool isQObject() const { return flags & IsQObjectDerived; }
- bool isEnum() const { return flags & IsEnumType; }
- bool isQList() const { return flags & IsQList; }
- bool isQmlBinding() const { return flags & IsQmlBinding; }
- bool isQJSValue() const { return flags & IsQJSValue; }
- bool isV8Handle() const { return flags & IsV8Handle; }
- bool isVMEProperty() const { return flags & IsVMEProperty; }
- bool isValueTypeVirtual() const { return flags & IsValueTypeVirtual; }
- bool isQVariant() const { return flags & IsQVariant; }
- bool isVMEFunction() const { return flags & IsVMEFunction; }
- bool hasArguments() const { return flags & HasArguments; }
- bool isSignal() const { return flags & IsSignal; }
- bool isVMESignal() const { return flags & IsVMESignal; }
- bool isV8Function() const { return flags & IsV8Function; }
- bool isSignalHandler() const { return flags & IsSignalHandler; }
- bool isOverload() const { return flags & IsOverload; }
-
- bool hasOverride() const { return !(flags & IsValueTypeVirtual) &&
- !(flags & HasAccessors) &&
- overrideIndex >= 0; }
- bool hasRevision() const { return !(flags & HasAccessors) && revision != 0; }
-
- // Returns -1 if not a value type virtual property
- inline int getValueTypeCoreIndex() const;
-
- // Returns the "encoded" index for use with bindings. Encoding is:
- // coreIndex | (valueTypeCoreIndex << 24)
- inline int encodedIndex() const;
-
- union {
- int propType; // When !NotFullyResolved
- const char *propTypeName; // When NotFullyResolved
- };
- int coreIndex;
- union {
- int notifyIndex; // When !IsFunction
- void *arguments; // When IsFunction && HasArguments
- };
-
- union {
- struct { // When !HasAccessors
- qint16 revision;
- qint16 metaObjectOffset;
-
- union {
- struct { // When IsValueTypeVirtual
- quint16 valueTypeFlags; // flags of the access property on the value type proxy
- // object
- quint8 valueTypePropType; // The QVariant::Type of access property on the value
- // type proxy object
- quint8 valueTypeCoreIndex; // The prop index of the access property on the value
- // type proxy object
- };
-
- struct { // When !IsValueTypeVirtual
- uint overrideIndexIsProperty : 1;
- signed int overrideIndex : 31;
- };
- };
- };
- struct { // When HasAccessors
- QDeclarativeAccessors *accessors;
- intptr_t accessorData;
- };
- };
-
-private:
- friend class QDeclarativePropertyData;
- friend class QDeclarativePropertyCache;
- quint32 flags;
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyRawData::Flags);
-
-class QDeclarativePropertyData : public QDeclarativePropertyRawData
-{
-public:
- inline QDeclarativePropertyData();
- inline QDeclarativePropertyData(const QDeclarativePropertyRawData &);
-
- inline bool operator==(const QDeclarativePropertyRawData &);
-
- static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine = 0);
- void load(const QMetaProperty &, QDeclarativeEngine *engine = 0);
- void load(const QMetaMethod &);
- QString name(QObject *);
- QString name(const QMetaObject *);
-
-private:
- friend class QDeclarativePropertyCache;
- void lazyLoad(const QMetaProperty &, QDeclarativeEngine *engine = 0);
- void lazyLoad(const QMetaMethod &);
- bool notFullyResolved() const { return flags & NotFullyResolved; }
-};
-
-class Q_DECLARATIVE_EXPORT QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup
-{
-public:
- QDeclarativePropertyCache(QDeclarativeEngine *);
- QDeclarativePropertyCache(QDeclarativeEngine *, const QMetaObject *);
- virtual ~QDeclarativePropertyCache();
-
- void update(QDeclarativeEngine *, const QMetaObject *);
-
- QDeclarativePropertyCache *copy();
-
- QDeclarativePropertyCache *copyAndAppend(QDeclarativeEngine *, const QMetaObject *,
- QDeclarativePropertyData::Flag propertyFlags = QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::Flag methodFlags = QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::Flag signalFlags = QDeclarativePropertyData::NoFlags);
- QDeclarativePropertyCache *copyAndAppend(QDeclarativeEngine *, const QMetaObject *, int revision,
- QDeclarativePropertyData::Flag propertyFlags = QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::Flag methodFlags = QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::Flag signalFlags = QDeclarativePropertyData::NoFlags);
-
- void append(QDeclarativeEngine *, const QMetaObject *,
- QDeclarativePropertyData::Flag propertyFlags = QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::Flag methodFlags = QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::Flag signalFlags = QDeclarativePropertyData::NoFlags);
- void append(QDeclarativeEngine *, const QMetaObject *, int revision,
- QDeclarativePropertyData::Flag propertyFlags = QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::Flag methodFlags = QDeclarativePropertyData::NoFlags,
- QDeclarativePropertyData::Flag signalFlags = QDeclarativePropertyData::NoFlags);
-
- inline QDeclarativePropertyData *property(const QHashedV8String &) const;
- QDeclarativePropertyData *property(const QHashedStringRef &) const;
- QDeclarativePropertyData *property(const QHashedCStringRef &) const;
- QDeclarativePropertyData *property(const QString &) const;
- QDeclarativePropertyData *property(int) const;
- QDeclarativePropertyData *method(int) const;
- QStringList propertyNames() const;
-
- inline QDeclarativePropertyData *overrideData(QDeclarativePropertyData *) const;
- inline bool isAllowedInRevision(QDeclarativePropertyData *) const;
-
- inline QDeclarativeEngine *qmlEngine() const;
- static QDeclarativePropertyData *property(QDeclarativeEngine *, QObject *, const QString &,
- QDeclarativePropertyData &);
- static QDeclarativePropertyData *property(QDeclarativeEngine *, QObject *, const QHashedV8String &,
- QDeclarativePropertyData &);
- static int *methodParameterTypes(QObject *, int index, QVarLengthArray<int, 9> &dummy,
- QByteArray *unknownTypeError);
-
- static bool isDynamicMetaObject(const QMetaObject *);
-protected:
- virtual void destroy();
- virtual void clear();
-
-private:
- friend class QDeclarativeEnginePrivate;
- friend class QV8QObjectWrapper;
-
- inline QDeclarativePropertyCache *copy(int reserve);
-
- // Implemented in v8/qv8qobjectwrapper.cpp
- v8::Local<v8::Object> newQObject(QObject *, QV8Engine *);
-
- typedef QVector<QDeclarativePropertyData> IndexCache;
- typedef QStringHash<QDeclarativePropertyData *> StringCache;
- typedef QVector<int> AllowedRevisionCache;
-
- void resolve(QDeclarativePropertyData *) const;
- void updateRecur(QDeclarativeEngine *, const QMetaObject *);
-
- QDeclarativeEngine *engine;
-
- QDeclarativePropertyCache *parent;
- int propertyIndexCacheStart;
- int methodIndexCacheStart;
- int signalHanderIndexCacheStart;
-
- IndexCache propertyIndexCache;
- IndexCache methodIndexCache;
- IndexCache signalHandlerIndexCache;
- StringCache stringCache;
- AllowedRevisionCache allowedRevisionCache;
- v8::Persistent<v8::Function> constructor;
-
- const QMetaObject *metaObject;
- QDeclarativePropertyCacheMethodArguments *argumentsCache;
-};
-
-QDeclarativePropertyData::QDeclarativePropertyData()
-{
- propType = 0;
- coreIndex = -1;
- notifyIndex = -1;
- overrideIndexIsProperty = false;
- overrideIndex = -1;
- revision = 0;
- metaObjectOffset = -1;
- flags = 0;
-}
-
-QDeclarativePropertyData::QDeclarativePropertyData(const QDeclarativePropertyRawData &d)
-{
- *(static_cast<QDeclarativePropertyRawData *>(this)) = d;
-}
-
-bool QDeclarativePropertyData::operator==(const QDeclarativePropertyRawData &other)
-{
- return flags == other.flags &&
- propType == other.propType &&
- coreIndex == other.coreIndex &&
- notifyIndex == other.notifyIndex &&
- revision == other.revision &&
- (!isValueTypeVirtual() ||
- (valueTypeCoreIndex == other.valueTypeCoreIndex &&
- valueTypePropType == other.valueTypePropType));
-}
-
-int QDeclarativePropertyRawData::getValueTypeCoreIndex() const
-{
- return isValueTypeVirtual()?valueTypeCoreIndex:-1;
-}
-
-int QDeclarativePropertyRawData::encodedIndex() const
-{
- return isValueTypeVirtual()?(coreIndex | (valueTypeCoreIndex << 24)):coreIndex;
-}
-
-QDeclarativePropertyData *
-QDeclarativePropertyCache::overrideData(QDeclarativePropertyData *data) const
-{
- if (!data->hasOverride())
- return 0;
-
- if (data->overrideIndexIsProperty)
- return property(data->overrideIndex);
- else
- return method(data->overrideIndex);
-}
-
-bool QDeclarativePropertyCache::isAllowedInRevision(QDeclarativePropertyData *data) const
-{
- return (data->hasAccessors() || (data->metaObjectOffset == -1 && data->revision == 0)) ||
- (allowedRevisionCache[data->metaObjectOffset] >= data->revision);
-}
-
-QDeclarativeEngine *QDeclarativePropertyCache::qmlEngine() const
-{
- return engine;
-}
-
-QDeclarativePropertyData *QDeclarativePropertyCache::property(const QHashedV8String &str) const
-{
- QDeclarativePropertyData **rv = stringCache.value(str);
- if (rv && (*rv)->notFullyResolved()) resolve(*rv);
- return rv?*rv:0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEPROPERTYCACHE_P_H
diff --git a/src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp b/src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp
deleted file mode 100644
index 4abe5a4e1f..0000000000
--- a/src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepropertyvalueinterceptor_p.h"
-
-#include "qdeclarative.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDeclarativePropertyValueInterceptor
- \brief The QDeclarativePropertyValueInterceptor class is inherited by property interceptors such as Behavior.
- \internal
-
- This class intercepts property writes, allowing for custom handling. For example, Behavior uses this
- interception to provide a default animation for all changes to a property's value.
- */
-
-/*!
- Constructs a QDeclarativePropertyValueInterceptor.
-*/
-QDeclarativePropertyValueInterceptor::QDeclarativePropertyValueInterceptor()
-{
-}
-
-QDeclarativePropertyValueInterceptor::~QDeclarativePropertyValueInterceptor()
-{
-}
-
-/*!
- \fn void QDeclarativePropertyValueInterceptor::setTarget(const QDeclarativeProperty &property)
- Set the target \a property for the value interceptor. This method will
- be called by the QML engine when assigning a value interceptor.
-*/
-
-/*!
- \fn void QDeclarativePropertyValueInterceptor::write(const QVariant &value)
- This method will be called when a new \a value is assigned to the property being intercepted.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h b/src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h
deleted file mode 100644
index 939c45b6d4..0000000000
--- a/src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROPERTYVALUEINTERCEPTOR_P_H
-#define QDECLARATIVEPROPERTYVALUEINTERCEPTOR_P_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/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeProperty;
-class Q_DECLARATIVE_EXPORT QDeclarativePropertyValueInterceptor
-{
-public:
- QDeclarativePropertyValueInterceptor();
- virtual ~QDeclarativePropertyValueInterceptor();
- virtual void setTarget(const QDeclarativeProperty &property) = 0;
- virtual void write(const QVariant &value) = 0;
-};
-
-#define QDeclarativePropertyValueInterceptor_iid "org.qt-project.Qt.QDeclarativePropertyValueInterceptor"
-
-Q_DECLARE_INTERFACE(QDeclarativePropertyValueInterceptor, QDeclarativePropertyValueInterceptor_iid)
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEPROPERTYVALUEINTERCEPTOR_P_H
diff --git a/src/declarative/qml/qdeclarativepropertyvaluesource.cpp b/src/declarative/qml/qdeclarativepropertyvaluesource.cpp
deleted file mode 100644
index 2f91bc388c..0000000000
--- a/src/declarative/qml/qdeclarativepropertyvaluesource.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepropertyvaluesource.h"
-
-#include "qdeclarative.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDeclarativePropertyValueSource
- \brief The QDeclarativePropertyValueSource class is an interface for property value sources such as animations and bindings.
-
- See \l{Property Value Sources} for information on writing custom property
- value sources.
- */
-
-/*!
- Constructs a QDeclarativePropertyValueSource.
-*/
-QDeclarativePropertyValueSource::QDeclarativePropertyValueSource()
-{
-}
-
-/*!
- Destroys the value source.
-*/
-QDeclarativePropertyValueSource::~QDeclarativePropertyValueSource()
-{
-}
-
-/*!
- \fn void QDeclarativePropertyValueSource::setTarget(const QDeclarativeProperty &property)
- Set the target \a property for the value source. This method will
- be called by the QML engine when assigning a value source.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertyvaluesource.h b/src/declarative/qml/qdeclarativepropertyvaluesource.h
deleted file mode 100644
index d345319143..0000000000
--- a/src/declarative/qml/qdeclarativepropertyvaluesource.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROPERTYVALUESOURCE_H
-#define QDECLARATIVEPROPERTYVALUESOURCE_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeProperty;
-class Q_DECLARATIVE_EXPORT QDeclarativePropertyValueSource
-{
-public:
- QDeclarativePropertyValueSource();
- virtual ~QDeclarativePropertyValueSource();
- virtual void setTarget(const QDeclarativeProperty &) = 0;
-};
-
-#define QDeclarativePropertyValueSource_iid "org.qt-project.Qt.QDeclarativePropertyValueSource"
-
-Q_DECLARE_INTERFACE(QDeclarativePropertyValueSource, QDeclarativePropertyValueSource_iid)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPROPERTYVALUESOURCE_H
diff --git a/src/declarative/qml/qdeclarativeproxymetaobject.cpp b/src/declarative/qml/qdeclarativeproxymetaobject.cpp
deleted file mode 100644
index 6c48640da1..0000000000
--- a/src/declarative/qml/qdeclarativeproxymetaobject.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeproxymetaobject_p.h"
-#include "qdeclarativeproperty_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeProxyMetaObject::QDeclarativeProxyMetaObject(QObject *obj, QList<ProxyData> *mList)
-: metaObjects(mList), proxies(0), parent(0), object(obj)
-{
- *static_cast<QMetaObject *>(this) = *metaObjects->first().metaObject;
-
- QObjectPrivate *op = QObjectPrivate::get(obj);
- if (op->metaObject)
- parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject);
-
- op->metaObject = this;
-}
-
-QDeclarativeProxyMetaObject::~QDeclarativeProxyMetaObject()
-{
- if (parent)
- delete parent;
- parent = 0;
-
- if (proxies)
- delete [] proxies;
- proxies = 0;
-}
-
-int QDeclarativeProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
-{
- if ((c == QMetaObject::ReadProperty ||
- c == QMetaObject::WriteProperty) &&
- id >= metaObjects->last().propertyOffset) {
-
- for (int ii = 0; ii < metaObjects->count(); ++ii) {
- const ProxyData &data = metaObjects->at(ii);
- if (id >= data.propertyOffset) {
- if (!proxies) {
- proxies = new QObject*[metaObjects->count()];
- ::memset(proxies, 0,
- sizeof(QObject *) * metaObjects->count());
- }
-
- if (!proxies[ii]) {
- QObject *proxy = data.createFunc(object);
- const QMetaObject *metaObject = proxy->metaObject();
- proxies[ii] = proxy;
-
- int localOffset = data.metaObject->methodOffset();
- int methodOffset = metaObject->methodOffset();
- int methods = metaObject->methodCount() - methodOffset;
-
- // ### - Can this be done more optimally?
- for (int jj = 0; jj < methods; ++jj) {
- QMetaMethod method =
- metaObject->method(jj + methodOffset);
- if (method.methodType() == QMetaMethod::Signal)
- QDeclarativePropertyPrivate::connect(proxy, methodOffset + jj, object, localOffset + jj);
- }
- }
-
- int proxyOffset = proxies[ii]->metaObject()->propertyOffset();
- int proxyId = id - data.propertyOffset + proxyOffset;
-
- return proxies[ii]->qt_metacall(c, proxyId, a);
- }
- }
- } else if (c == QMetaObject::InvokeMetaMethod &&
- id >= metaObjects->last().methodOffset) {
- QMetaMethod m = object->metaObject()->method(id);
- if (m.methodType() == QMetaMethod::Signal) {
- QMetaObject::activate(object, id, a);
- return -1;
- }
- }
-
- if (parent)
- return parent->metaCall(c, id, a);
- else
- return object->qt_metacall(c, id, a);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeproxymetaobject_p.h b/src/declarative/qml/qdeclarativeproxymetaobject_p.h
deleted file mode 100644
index 04c6f93dc3..0000000000
--- a/src/declarative/qml/qdeclarativeproxymetaobject_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROXYMETAOBJECT_P_H
-#define QDECLARATIVEPROXYMETAOBJECT_P_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 <private/qmetaobjectbuilder_p.h>
-#include "qdeclarative.h"
-
-#include <QtCore/QMetaObject>
-#include <QtCore/QObject>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeProxyMetaObject : public QAbstractDynamicMetaObject
-{
-public:
- struct ProxyData {
- typedef QObject *(*CreateFunc)(QObject *);
- QMetaObject *metaObject;
- CreateFunc createFunc;
- int propertyOffset;
- int methodOffset;
- };
-
- QDeclarativeProxyMetaObject(QObject *, QList<ProxyData> *);
- virtual ~QDeclarativeProxyMetaObject();
-
-protected:
- virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
-
-private:
- QList<ProxyData> *metaObjects;
- QObject **proxies;
-
- QAbstractDynamicMetaObject *parent;
- QObject *object;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPROXYMETAOBJECT_P_H
-
diff --git a/src/declarative/qml/qdeclarativerewrite.cpp b/src/declarative/qml/qdeclarativerewrite.cpp
deleted file mode 100644
index 688e75a325..0000000000
--- a/src/declarative/qml/qdeclarativerewrite.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativerewrite_p.h"
-
-#include "qdeclarativeglobal_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(rewriteDump, QML_REWRITE_DUMP);
-
-namespace QDeclarativeRewrite {
-
-static void rewriteStringLiteral(AST::StringLiteral *ast, const QString *code, int startPosition, TextWriter *writer)
-{
- const unsigned position = ast->firstSourceLocation().begin() - startPosition + 1;
- const unsigned length = ast->literalToken.length - 2;
- const QStringRef spell = code->midRef(position, length);
- const int end = spell.size();
- int index = 0;
-
- while (index < end) {
- const QChar ch = spell.at(index++);
-
- if (index < end && ch == QLatin1Char('\\')) {
- int pos = index;
-
- // skip a possibly empty sequence of \r characters
- while (pos < end && spell.at(pos) == QLatin1Char('\r'))
- ++pos;
-
- if (pos < end && spell.at(pos) == QLatin1Char('\n')) {
- // This is a `\' followed by a newline terminator.
- // In this case there's nothing to replace. We keep the code
- // as it is and we resume the searching.
- index = pos + 1; // refresh the index
- }
- } else if (ch == QLatin1Char('\r') || ch == QLatin1Char('\n')) {
- const QString sep = ch == QLatin1Char('\r') ? QLatin1String("\\r") : QLatin1String("\\n");
- const int pos = index - 1;
- QString s = sep;
-
- while (index < end && spell.at(index) == ch) {
- s += sep;
- ++index;
- }
-
- writer->replace(position + pos, index - pos, s);
- }
- }
-}
-
-bool SharedBindingTester::isSharable(const QString &code)
-{
- Engine engine;
- Lexer lexer(&engine);
- Parser parser(&engine);
- lexer.setCode(code, 0);
- parser.parseStatement();
- if (!parser.statement())
- return false;
-
- return isSharable(parser.statement());
-}
-
-bool SharedBindingTester::isSharable(AST::Node *node)
-{
- _sharable = true;
- AST::Node::acceptChild(node, this);
- return _sharable;
-}
-
-QString RewriteBinding::operator()(const QString &code, bool *ok, bool *sharable)
-{
- Engine engine;
- Lexer lexer(&engine);
- Parser parser(&engine);
- lexer.setCode(code, 0);
- parser.parseStatement();
- if (!parser.statement()) {
- if (ok) *ok = false;
- return QString();
- } else {
- if (ok) *ok = true;
- if (sharable) {
- SharedBindingTester tester;
- *sharable = tester.isSharable(parser.statement());
- }
- }
- return rewrite(code, 0, parser.statement());
-}
-
-QString RewriteBinding::operator()(QDeclarativeJS::AST::Node *node, const QString &code, bool *sharable)
-{
- if (!node)
- return code;
-
- if (sharable) {
- SharedBindingTester tester;
- *sharable = tester.isSharable(node);
- }
-
- QDeclarativeJS::AST::ExpressionNode *expression = node->expressionCast();
- QDeclarativeJS::AST::Statement *statement = node->statementCast();
- if(!expression && !statement)
- return code;
-
- TextWriter w;
- _writer = &w;
- _position = expression ? expression->firstSourceLocation().begin() : statement->firstSourceLocation().begin();
- _inLoop = 0;
- _code = &code;
-
- accept(node);
-
- unsigned startOfStatement = 0;
- unsigned endOfStatement = (expression ? expression->lastSourceLocation().end() : statement->lastSourceLocation().end()) - _position;
-
- QString startString = QLatin1String("(function ") + _name + QLatin1String("() { ");
- if (expression)
- startString += QLatin1String("return ");
- _writer->replace(startOfStatement, 0, startString);
- _writer->replace(endOfStatement, 0, QLatin1String(" })"));
-
- if (rewriteDump()) {
- qWarning() << "=============================================================";
- qWarning() << "Rewrote:";
- qWarning() << qPrintable(code);
- }
-
- QString codeCopy = code;
- w.write(&codeCopy);
-
- if (rewriteDump()) {
- qWarning() << "To:";
- qWarning() << qPrintable(codeCopy);
- qWarning() << "=============================================================";
- }
-
- return codeCopy;
-}
-
-void RewriteBinding::accept(AST::Node *node)
-{
- AST::Node::acceptChild(node, this);
-}
-
-QString RewriteBinding::rewrite(QString code, unsigned position,
- AST::Statement *node)
-{
- TextWriter w;
- _writer = &w;
- _position = position;
- _inLoop = 0;
- _code = &code;
-
- accept(node);
-
- unsigned startOfStatement = node->firstSourceLocation().begin() - _position;
- unsigned endOfStatement = node->lastSourceLocation().end() - _position;
-
- _writer->replace(startOfStatement, 0, QLatin1String("(function ") + _name + QLatin1String("() { "));
- _writer->replace(endOfStatement, 0, QLatin1String(" })"));
-
- if (rewriteDump()) {
- qWarning() << "=============================================================";
- qWarning() << "Rewrote:";
- qWarning() << qPrintable(code);
- }
-
- w.write(&code);
-
- if (rewriteDump()) {
- qWarning() << "To:";
- qWarning() << qPrintable(code);
- qWarning() << "=============================================================";
- }
-
- return code;
-}
-
-bool RewriteBinding::visit(AST::Block *ast)
-{
- for (AST::StatementList *it = ast->statements; it; it = it->next) {
- if (! it->next) {
- // we need to rewrite only the last statement of a block.
- accept(it->statement);
- }
- }
-
- return false;
-}
-
-bool RewriteBinding::visit(AST::ExpressionStatement *ast)
-{
- if (! _inLoop) {
- unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position;
- _writer->replace(startOfExpressionStatement, 0, QLatin1String("return "));
- }
-
- return false;
-}
-
-bool RewriteBinding::visit(AST::StringLiteral *ast)
-{
- rewriteStringLiteral(ast, _code, _position, _writer);
- return false;
-}
-
-bool RewriteBinding::visit(AST::DoWhileStatement *)
-{
- ++_inLoop;
- return true;
-}
-
-void RewriteBinding::endVisit(AST::DoWhileStatement *)
-{
- --_inLoop;
-}
-
-bool RewriteBinding::visit(AST::WhileStatement *)
-{
- ++_inLoop;
- return true;
-}
-
-void RewriteBinding::endVisit(AST::WhileStatement *)
-{
- --_inLoop;
-}
-
-bool RewriteBinding::visit(AST::ForStatement *)
-{
- ++_inLoop;
- return true;
-}
-
-void RewriteBinding::endVisit(AST::ForStatement *)
-{
- --_inLoop;
-}
-
-bool RewriteBinding::visit(AST::LocalForStatement *)
-{
- ++_inLoop;
- return true;
-}
-
-void RewriteBinding::endVisit(AST::LocalForStatement *)
-{
- --_inLoop;
-}
-
-bool RewriteBinding::visit(AST::ForEachStatement *)
-{
- ++_inLoop;
- return true;
-}
-
-void RewriteBinding::endVisit(AST::ForEachStatement *)
-{
- --_inLoop;
-}
-
-bool RewriteBinding::visit(AST::LocalForEachStatement *)
-{
- ++_inLoop;
- return true;
-}
-
-void RewriteBinding::endVisit(AST::LocalForEachStatement *)
-{
- --_inLoop;
-}
-
-bool RewriteBinding::visit(AST::CaseBlock *ast)
-{
- // Process the initial sequence of the case clauses.
- for (AST::CaseClauses *it = ast->clauses; it; it = it->next) {
- // Return the value of the last statement in the block, if this is the last `case clause'
- // of the switch statement.
- bool returnTheValueOfLastStatement = (it->next == 0) && (ast->defaultClause == 0) && (ast->moreClauses == 0);
-
- if (AST::CaseClause *clause = it->clause) {
- accept(clause->expression);
- rewriteCaseStatements(clause->statements, returnTheValueOfLastStatement);
- }
- }
-
- // Process the default case clause
- if (ast->defaultClause) {
- // Return the value of the last statement in the block, if this is the last `case clause'
- // of the switch statement.
- bool rewriteTheLastStatement = (ast->moreClauses == 0);
-
- rewriteCaseStatements(ast->defaultClause->statements, rewriteTheLastStatement);
- }
-
- // Process trailing `case clauses'
- for (AST::CaseClauses *it = ast->moreClauses; it; it = it->next) {
- // Return the value of the last statement in the block, if this is the last `case clause'
- // of the switch statement.
- bool returnTheValueOfLastStatement = (it->next == 0);
-
- if (AST::CaseClause *clause = it->clause) {
- accept(clause->expression);
- rewriteCaseStatements(clause->statements, returnTheValueOfLastStatement);
- }
- }
-
- return false;
-}
-
-void RewriteBinding::rewriteCaseStatements(AST::StatementList *statements, bool rewriteTheLastStatement)
-{
- for (AST::StatementList *it = statements; it; it = it->next) {
- if (it->next && AST::cast<AST::BreakStatement *>(it->next->statement) != 0) {
- // The value of the first statement followed by a `break'.
- accept(it->statement);
- break;
- } else if (!it->next) {
- if (rewriteTheLastStatement)
- accept(it->statement);
- else if (AST::Block *block = AST::cast<AST::Block *>(it->statement))
- rewriteCaseStatements(block->statements, rewriteTheLastStatement);
- }
- }
-}
-
-RewriteSignalHandler::RewriteSignalHandler()
- : _writer(0)
- , _code(0)
- , _position(0)
-{
-}
-
-void RewriteSignalHandler::accept(AST::Node *node)
-{
- AST::Node::acceptChild(node, this);
-}
-
-bool RewriteSignalHandler::visit(AST::StringLiteral *ast)
-{
- rewriteStringLiteral(ast, _code, _position, _writer);
- return false;
-}
-
-QString RewriteSignalHandler::operator()(QDeclarativeJS::AST::Node *node, const QString &code, const QString &name)
-{
- if (rewriteDump()) {
- qWarning() << "=============================================================";
- qWarning() << "Rewrote:";
- qWarning() << qPrintable(code);
- }
-
- QDeclarativeJS::AST::ExpressionNode *expression = node->expressionCast();
- QDeclarativeJS::AST::Statement *statement = node->statementCast();
- if (!expression && !statement)
- return code;
-
- TextWriter w;
- _writer = &w;
- _code = &code;
-
- _position = expression ? expression->firstSourceLocation().begin() : statement->firstSourceLocation().begin();
- accept(node);
-
- QString rewritten = code;
- w.write(&rewritten);
-
- rewritten = QStringLiteral("(function ") + name + QStringLiteral("() { ") + rewritten + QStringLiteral(" })");
-
- if (rewriteDump()) {
- qWarning() << "To:";
- qWarning() << qPrintable(rewritten);
- qWarning() << "=============================================================";
- }
-
- return rewritten;
-}
-
-} // namespace QDeclarativeRewrite
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativerewrite_p.h b/src/declarative/qml/qdeclarativerewrite_p.h
deleted file mode 100644
index 7d73e6a132..0000000000
--- a/src/declarative/qml/qdeclarativerewrite_p.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEREWRITE_P_H
-#define QDECLARATIVEREWRITE_P_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 <private/textwriter_p.h>
-#include <private/qdeclarativejslexer_p.h>
-#include <private/qdeclarativejsparser_p.h>
-#include <private/qdeclarativejsmemorypool_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QDeclarativeRewrite {
-using namespace QDeclarativeJS;
-
-class SharedBindingTester : protected AST::Visitor
-{
- bool _sharable;
-public:
- bool isSharable(const QString &code);
- bool isSharable(AST::Node *Node);
-
- virtual bool visit(AST::FunctionDeclaration *) { _sharable = false; return false; }
- virtual bool visit(AST::FunctionExpression *) { _sharable = false; return false; }
- virtual bool visit(AST::CallExpression *) { _sharable = false; return false; }
-};
-
-class RewriteBinding: protected AST::Visitor
-{
- unsigned _position;
- TextWriter *_writer;
- QString _name;
- const QString *_code;
-
-public:
- QString operator()(const QString &code, bool *ok = 0, bool *sharable = 0);
- QString operator()(QDeclarativeJS::AST::Node *node, const QString &code, bool *sharable = 0);
-
- //name of the function: used for the debugger
- void setName(const QString &name) { _name = name; }
-
-protected:
- using AST::Visitor::visit;
-
- void accept(AST::Node *node);
- QString rewrite(QString code, unsigned position, AST::Statement *node);
- void rewriteCaseStatements(AST::StatementList *statements, bool rewriteTheLastStatement);
-
- virtual bool visit(AST::StringLiteral *ast);
- virtual bool visit(AST::Block *ast);
- virtual bool visit(AST::ExpressionStatement *ast);
-
- virtual bool visit(AST::DoWhileStatement *ast);
- virtual void endVisit(AST::DoWhileStatement *ast);
-
- virtual bool visit(AST::WhileStatement *ast);
- virtual void endVisit(AST::WhileStatement *ast);
-
- virtual bool visit(AST::ForStatement *ast);
- virtual void endVisit(AST::ForStatement *ast);
-
- virtual bool visit(AST::LocalForStatement *ast);
- virtual void endVisit(AST::LocalForStatement *ast);
-
- virtual bool visit(AST::ForEachStatement *ast);
- virtual void endVisit(AST::ForEachStatement *ast);
-
- virtual bool visit(AST::LocalForEachStatement *ast);
- virtual void endVisit(AST::LocalForEachStatement *ast);
-
- virtual bool visit(AST::CaseBlock *ast);
-
-private:
- int _inLoop;
-};
-
-class RewriteSignalHandler: protected AST::Visitor
-{
- TextWriter *_writer;
- const QString *_code;
- int _position;
-
-public:
- RewriteSignalHandler();
- QString operator()(QDeclarativeJS::AST::Node *node, const QString &code, const QString &name);
-
-protected:
- void rewriteMultilineStrings(QString &code);
-
- using AST::Visitor::visit;
- void accept(AST::Node *node);
- virtual bool visit(AST::StringLiteral *ast);
-};
-
-} // namespace QDeclarativeRewrite
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEREWRITE_P_H
-
diff --git a/src/declarative/qml/qdeclarativescript.cpp b/src/declarative/qml/qdeclarativescript.cpp
deleted file mode 100644
index 7a2247fac0..0000000000
--- a/src/declarative/qml/qdeclarativescript.cpp
+++ /dev/null
@@ -1,1700 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativescript_p.h"
-
-#include "parser/qdeclarativejsengine_p.h"
-#include "parser/qdeclarativejsparser_p.h"
-#include "parser/qdeclarativejslexer_p.h"
-#include "parser/qdeclarativejsmemorypool_p.h"
-#include "parser/qdeclarativejsastvisitor_p.h"
-#include "parser/qdeclarativejsast_p.h"
-#include <private/qdeclarativerewrite_p.h>
-
-#include <QStack>
-#include <QCoreApplication>
-#include <QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QDeclarativeJS;
-using namespace QDeclarativeScript;
-
-//
-// Parser IR classes
-//
-QDeclarativeScript::Object::Object()
-: type(-1), idIndex(-1), metatype(0), synthCache(0), defaultProperty(0), parserStatusCast(-1),
- componentCompileState(0), nextAliasingObject(0), nextIdObject(0)
-{
-}
-
-QDeclarativeScript::Object::~Object()
-{
- if (synthCache) synthCache->release();
-}
-
-void Object::setBindingBit(int b)
-{
- while (bindingBitmask.size() < 4 * (1 + b / 32))
- bindingBitmask.append(char(0));
-
- quint32 *bits = (quint32 *)bindingBitmask.data();
- bits[b / 32] |= (1 << (b % 32));
-}
-
-const QMetaObject *Object::metaObject() const
-{
- if (!metadata.isEmpty() && metatype)
- return &extObject;
- else
- return metatype;
-}
-
-QDeclarativeScript::Property *Object::getDefaultProperty()
-{
- if (!defaultProperty) {
- defaultProperty = pool()->New<Property>();
- defaultProperty->parent = this;
- }
- return defaultProperty;
-}
-
-void QDeclarativeScript::Object::addValueProperty(Property *p)
-{
- valueProperties.append(p);
-}
-
-void QDeclarativeScript::Object::addSignalProperty(Property *p)
-{
- signalProperties.append(p);
-}
-
-void QDeclarativeScript::Object::addAttachedProperty(Property *p)
-{
- attachedProperties.append(p);
-}
-
-void QDeclarativeScript::Object::addGroupedProperty(Property *p)
-{
- groupedProperties.append(p);
-}
-
-void QDeclarativeScript::Object::addValueTypeProperty(Property *p)
-{
- valueTypeProperties.append(p);
-}
-
-void QDeclarativeScript::Object::addScriptStringProperty(Property *p)
-{
- scriptStringProperties.append(p);
-}
-
-// This lookup is optimized for missing, and having to create a new property.
-Property *QDeclarativeScript::Object::getProperty(const QHashedStringRef &name, bool create)
-{
- if (create) {
- quint32 h = name.hash();
- if (propertiesHashField.testAndSet(h)) {
- for (Property *p = properties.first(); p; p = properties.next(p)) {
- if (p->name() == name)
- return p;
- }
- }
-
- Property *property = pool()->New<Property>();
- property->parent = this;
- property->_name = name;
- property->isDefault = false;
- properties.prepend(property);
- return property;
- } else {
- for (Property *p = properties.first(); p; p = properties.next(p)) {
- if (p->name() == name)
- return p;
- }
- }
-
- return 0;
-}
-
-Property *QDeclarativeScript::Object::getProperty(const QStringRef &name, bool create)
-{
- return getProperty(QHashedStringRef(name), create);
-}
-
-Property *QDeclarativeScript::Object::getProperty(const QString &name, bool create)
-{
- for (Property *p = properties.first(); p; p = properties.next(p)) {
- if (p->name() == name)
- return p;
- }
-
- if (create) {
- Property *property = pool()->New<Property>();
- property->parent = this;
- property->_name = QStringRef(pool()->NewString(name));
- propertiesHashField.testAndSet(property->_name.hash());
- property->isDefault = false;
- properties.prepend(property);
- return property;
- } else {
- return 0;
- }
-}
-
-QDeclarativeScript::Object::DynamicProperty::DynamicProperty()
-: isDefaultProperty(false), isReadOnly(false), type(Variant), defaultValue(0), nextProperty(0),
- resolvedCustomTypeName(0)
-{
-}
-
-QDeclarativeScript::Object::DynamicSignal::DynamicSignal()
-: nextSignal(0)
-{
-}
-
-// Returns length in utf8 bytes
-int QDeclarativeScript::Object::DynamicSignal::parameterTypesLength() const
-{
- int rv = 0;
- for (int ii = 0; ii < parameterTypes.count(); ++ii)
- rv += parameterTypes.at(ii).length();
- return rv;
-}
-
-// Returns length in utf8 bytes
-int QDeclarativeScript::Object::DynamicSignal::parameterNamesLength() const
-{
- int rv = 0;
- for (int ii = 0; ii < parameterNames.count(); ++ii)
- rv += parameterNames.at(ii).utf8length();
- return rv;
-}
-
-QDeclarativeScript::Object::DynamicSlot::DynamicSlot()
-: nextSlot(0)
-{
-}
-
-int QDeclarativeScript::Object::DynamicSlot::parameterNamesLength() const
-{
- int rv = 0;
- for (int ii = 0; ii < parameterNames.count(); ++ii)
- rv += parameterNames.at(ii).length();
- return rv;
-}
-
-QDeclarativeScript::Property::Property()
-: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false),
- isValueTypeSubProperty(false), isAlias(false), isReadOnlyDeclaration(false),
- scriptStringScope(-1), nextMainProperty(0), nextProperty(0)
-{
-}
-
-QDeclarativeScript::Object *QDeclarativeScript::Property::getValue(const LocationSpan &l)
-{
- if (!value) { value = pool()->New<Object>(); value->location = l; }
- return value;
-}
-
-void QDeclarativeScript::Property::addValue(Value *v)
-{
- values.append(v);
-}
-
-void QDeclarativeScript::Property::addOnValue(Value *v)
-{
- onValues.append(v);
-}
-
-bool QDeclarativeScript::Property::isEmpty() const
-{
- return !value && values.isEmpty() && onValues.isEmpty();
-}
-
-QDeclarativeScript::Value::Value()
-: type(Unknown), object(0), bindingReference(0), nextValue(0)
-{
-}
-
-QDeclarativeScript::Variant::Variant()
-: t(Invalid)
-{
-}
-
-QDeclarativeScript::Variant::Variant(const Variant &o)
-: t(o.t), d(o.d), asWritten(o.asWritten)
-{
-}
-
-QDeclarativeScript::Variant::Variant(bool v)
-: t(Boolean), b(v)
-{
-}
-
-QDeclarativeScript::Variant::Variant(double v, const QStringRef &asWritten)
-: t(Number), d(v), asWritten(asWritten)
-{
-}
-
-QDeclarativeScript::Variant::Variant(QDeclarativeJS::AST::StringLiteral *v)
-: t(String), l(v)
-{
-}
-
-QDeclarativeScript::Variant::Variant(const QStringRef &asWritten, QDeclarativeJS::AST::Node *n)
-: t(Script), n(n), asWritten(asWritten)
-{
-}
-
-QDeclarativeScript::Variant &QDeclarativeScript::Variant::operator=(const Variant &o)
-{
- t = o.t;
- d = o.d;
- asWritten = o.asWritten;
- return *this;
-}
-
-QDeclarativeScript::Variant::Type QDeclarativeScript::Variant::type() const
-{
- return t;
-}
-
-bool QDeclarativeScript::Variant::asBoolean() const
-{
- return b;
-}
-
-QString QDeclarativeScript::Variant::asString() const
-{
- if (t == String) {
- return l->value.toString();
- } else {
- return asWritten.toString();
- }
-}
-
-double QDeclarativeScript::Variant::asNumber() const
-{
- return d;
-}
-
-//reverse of Lexer::singleEscape()
-QString escapedString(const QString &string)
-{
- QString tmp = QLatin1String("\"");
- for (int i = 0; i < string.length(); ++i) {
- const QChar &c = string.at(i);
- switch(c.unicode()) {
- case 0x08:
- tmp += QLatin1String("\\b");
- break;
- case 0x09:
- tmp += QLatin1String("\\t");
- break;
- case 0x0A:
- tmp += QLatin1String("\\n");
- break;
- case 0x0B:
- tmp += QLatin1String("\\v");
- break;
- case 0x0C:
- tmp += QLatin1String("\\f");
- break;
- case 0x0D:
- tmp += QLatin1String("\\r");
- break;
- case 0x22:
- tmp += QLatin1String("\\\"");
- break;
- case 0x27:
- tmp += QLatin1String("\\\'");
- break;
- case 0x5C:
- tmp += QLatin1String("\\\\");
- break;
- default:
- tmp += c;
- break;
- }
- }
- tmp += QLatin1Char('\"');
- return tmp;
-}
-
-QString QDeclarativeScript::Variant::asScript() const
-{
- switch(type()) {
- default:
- case Invalid:
- return QString();
- case Boolean:
- return b?QLatin1String("true"):QLatin1String("false");
- case Number:
- if (asWritten.isEmpty())
- return QString::number(d);
- else
- return asWritten.toString();
- case String:
- return escapedString(asString());
- case Script:
- if (AST::IdentifierExpression *i = AST::cast<AST::IdentifierExpression *>(n)) {
- return i->name.toString();
- } else
- return asWritten.toString();
- }
-}
-
-QDeclarativeJS::AST::Node *QDeclarativeScript::Variant::asAST() const
-{
- if (type() == Script)
- return n;
- else
- return 0;
-}
-
-bool QDeclarativeScript::Variant::isStringList() const
-{
- if (isString())
- return true;
-
- if (type() != Script || !n)
- return false;
-
- AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
- if (!array)
- return false;
-
- AST::ElementList *elements = array->elements;
-
- while (elements) {
-
- if (!AST::cast<AST::StringLiteral *>(elements->expression))
- return false;
-
- elements = elements->next;
- }
-
- return true;
-}
-
-QStringList QDeclarativeScript::Variant::asStringList() const
-{
- QStringList rv;
- if (isString()) {
- rv << asString();
- return rv;
- }
-
- AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
- if (!array)
- return rv;
-
- AST::ElementList *elements = array->elements;
- while (elements) {
-
- AST::StringLiteral *string = AST::cast<AST::StringLiteral *>(elements->expression);
- if (!string)
- return QStringList();
- rv.append(string->value.toString());
-
- elements = elements->next;
- }
-
- return rv;
-}
-
-//
-// Actual parser classes
-//
-void QDeclarativeScript::Import::extractVersion(int *maj, int *min) const
-{
- *maj = -1; *min = -1;
-
- if (!version.isEmpty()) {
- int dot = version.indexOf(QLatin1Char('.'));
- if (dot < 0) {
- *maj = version.toInt();
- *min = 0;
- } else {
- *maj = version.left(dot).toInt();
- *min = version.mid(dot+1).toInt();
- }
- }
-}
-
-namespace {
-
-class ProcessAST: protected AST::Visitor
-{
- struct State {
- State() : object(0), property(0) {}
- State(QDeclarativeScript::Object *o) : object(o), property(0) {}
- State(QDeclarativeScript::Object *o, Property *p) : object(o), property(p) {}
-
- QDeclarativeScript::Object *object;
- Property *property;
- };
-
- struct StateStack : public QStack<State>
- {
- void pushObject(QDeclarativeScript::Object *obj)
- {
- push(State(obj));
- }
-
- void pushProperty(const QString &name, const LocationSpan &location)
- {
- const State &state = top();
- if (state.property) {
- State s(state.property->getValue(location),
- state.property->getValue(location)->getProperty(name));
- s.property->location = location;
- push(s);
- } else {
- State s(state.object, state.object->getProperty(name));
-
- s.property->location = location;
- push(s);
- }
- }
-
- void pushProperty(const QStringRef &name, const LocationSpan &location)
- {
- const State &state = top();
- if (state.property) {
- State s(state.property->getValue(location),
- state.property->getValue(location)->getProperty(name));
- s.property->location = location;
- push(s);
- } else {
- State s(state.object, state.object->getProperty(name));
-
- s.property->location = location;
- push(s);
- }
- }
- };
-
-public:
- ProcessAST(QDeclarativeScript::Parser *parser);
- virtual ~ProcessAST();
-
- void operator()(const QString &code, AST::Node *node);
-
-protected:
-
- QDeclarativeScript::Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
- const QString &objectType,
- AST::SourceLocation typeLocation,
- LocationSpan location,
- AST::UiObjectInitializer *initializer = 0);
-
- QDeclarativeScript::Variant getVariant(AST::Statement *stmt);
- QDeclarativeScript::Variant getVariant(AST::ExpressionNode *expr);
-
- LocationSpan location(AST::SourceLocation start, AST::SourceLocation end);
- LocationSpan location(AST::UiQualifiedId *);
-
- using AST::Visitor::visit;
- using AST::Visitor::endVisit;
-
- virtual bool visit(AST::UiProgram *node);
- virtual bool visit(AST::UiImport *node);
- virtual bool visit(AST::UiObjectDefinition *node);
- virtual bool visit(AST::UiPublicMember *node);
- virtual bool visit(AST::UiObjectBinding *node);
-
- virtual bool visit(AST::UiScriptBinding *node);
- virtual bool visit(AST::UiArrayBinding *node);
- virtual bool visit(AST::UiSourceElement *node);
-
- void accept(AST::Node *node);
-
- QString asString(AST::UiQualifiedId *node) const;
-
- const State state() const;
- QDeclarativeScript::Object *currentObject() const;
- Property *currentProperty() const;
-
- QString qualifiedNameId() const;
-
- QString textAt(const AST::SourceLocation &loc) const
- { return _contents->mid(loc.offset, loc.length); }
-
- QStringRef textRefAt(const AST::SourceLocation &loc) const
- { return QStringRef(_contents, loc.offset, loc.length); }
-
- QString textAt(const AST::SourceLocation &first,
- const AST::SourceLocation &last) const
- { return _contents->mid(first.offset, last.offset + last.length - first.offset); }
-
- QStringRef textRefAt(const AST::SourceLocation &first,
- const AST::SourceLocation &last) const
- { return QStringRef(_contents, first.offset, last.offset + last.length - first.offset); }
-
- QString asString(AST::ExpressionNode *expr)
- {
- if (! expr)
- return QString();
-
- return textAt(expr->firstSourceLocation(), expr->lastSourceLocation());
- }
-
- QStringRef asStringRef(AST::ExpressionNode *expr)
- {
- if (! expr)
- return QStringRef();
-
- return textRefAt(expr->firstSourceLocation(), expr->lastSourceLocation());
- }
-
- QString asString(AST::Statement *stmt)
- {
- if (! stmt)
- return QString();
-
- QString s = textAt(stmt->firstSourceLocation(), stmt->lastSourceLocation());
- s += QLatin1Char('\n');
- return s;
- }
-
- QStringRef asStringRef(AST::Statement *stmt)
- {
- if (! stmt)
- return QStringRef();
-
- return textRefAt(stmt->firstSourceLocation(), stmt->lastSourceLocation());
- }
-
-private:
- QDeclarativeScript::Parser *_parser;
- StateStack _stateStack;
- QStringList _scope;
- const QString *_contents;
-};
-
-ProcessAST::ProcessAST(QDeclarativeScript::Parser *parser)
- : _parser(parser)
-{
-}
-
-ProcessAST::~ProcessAST()
-{
-}
-
-void ProcessAST::operator()(const QString &code, AST::Node *node)
-{
- _contents = &code;
- accept(node);
-}
-
-void ProcessAST::accept(AST::Node *node)
-{
- AST::Node::acceptChild(node, this);
-}
-
-const ProcessAST::State ProcessAST::state() const
-{
- if (_stateStack.isEmpty())
- return State();
-
- return _stateStack.back();
-}
-
-QDeclarativeScript::Object *ProcessAST::currentObject() const
-{
- return state().object;
-}
-
-Property *ProcessAST::currentProperty() const
-{
- return state().property;
-}
-
-QString ProcessAST::qualifiedNameId() const
-{
- return _scope.join(QLatin1String("/"));
-}
-
-QString ProcessAST::asString(AST::UiQualifiedId *node) const
-{
- QString s;
-
- for (AST::UiQualifiedId *it = node; it; it = it->next) {
- s.append(it->name.toString());
-
- if (it->next)
- s.append(QLatin1Char('.'));
- }
-
- return s;
-}
-
-QDeclarativeScript::Object *
-ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
- bool onAssignment,
- const QString &objectType,
- AST::SourceLocation typeLocation,
- LocationSpan location,
- AST::UiObjectInitializer *initializer)
-{
- int lastTypeDot = objectType.lastIndexOf(QLatin1Char('.'));
-
- // With no preceding qualification, first char is at (-1 + 1) == 0
- bool isType = !objectType.isEmpty() && objectType.at(lastTypeDot+1).isUpper();
-
- int propertyCount = 0;
- for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
- ++propertyCount;
- _stateStack.pushProperty(name->name,
- this->location(name));
- }
-
- if (!onAssignment && propertyCount && currentProperty() && !currentProperty()->values.isEmpty()) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
- error.setLine(this->location(propertyName).start.line);
- error.setColumn(this->location(propertyName).start.column);
- _parser->_errors << error;
- return 0;
- }
-
- if (!isType) {
-
- // Is the identifier qualified by a namespace?
- int namespaceLength = 0;
- if (lastTypeDot > 0) {
- const QString qualifier(objectType.left(lastTypeDot));
-
- for (int ii = 0; ii < _parser->_imports.count(); ++ii) {
- const QDeclarativeScript::Import &import = _parser->_imports.at(ii);
- if (import.qualifier == qualifier) {
- // The qualifier is a namespace - expect a type here
- namespaceLength = qualifier.length() + 1;
- break;
- }
- }
- }
-
- if (propertyCount || !currentObject() || namespaceLength) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Expected type name"));
- error.setLine(typeLocation.startLine);
- error.setColumn(typeLocation.startColumn + namespaceLength);
- _parser->_errors << error;
- return 0;
- }
-
- LocationSpan loc = ProcessAST::location(typeLocation, typeLocation);
- if (propertyName)
- loc = ProcessAST::location(propertyName);
-
- _stateStack.pushProperty(objectType, loc);
- accept(initializer);
- _stateStack.pop();
-
- return 0;
-
- } else {
- // Class
-
- QString resolvableObjectType = objectType;
- if (lastTypeDot >= 0)
- resolvableObjectType.replace(QLatin1Char('.'),QLatin1Char('/'));
-
- QDeclarativeScript::Object *obj = _parser->_pool.New<QDeclarativeScript::Object>();
-
- QDeclarativeScript::TypeReference *typeRef = _parser->findOrCreateType(resolvableObjectType);
- obj->type = typeRef->id;
-
- typeRef->refObjects.append(obj);
-
- // XXX this doesn't do anything (_scope never builds up)
- _scope.append(resolvableObjectType);
- obj->typeName = qualifiedNameId();
- _scope.removeLast();
-
- obj->location = location;
-
- if (propertyCount) {
- Property *prop = currentProperty();
- QDeclarativeScript::Value *v = _parser->_pool.New<QDeclarativeScript::Value>();
- v->object = obj;
- v->location = obj->location;
- if (onAssignment)
- prop->addOnValue(v);
- else
- prop->addValue(v);
-
- while (propertyCount--)
- _stateStack.pop();
-
- } else {
-
- if (! _parser->tree()) {
- _parser->setTree(obj);
- } else {
- const State state = _stateStack.top();
- QDeclarativeScript::Value *v = _parser->_pool.New<QDeclarativeScript::Value>();
- v->object = obj;
- v->location = obj->location;
- if (state.property) {
- state.property->addValue(v);
- } else {
- Property *defaultProp = state.object->getDefaultProperty();
- if (defaultProp->location.start.line == -1) {
- defaultProp->location = v->location;
- defaultProp->location.end = defaultProp->location.start;
- defaultProp->location.range.length = 0;
- }
- defaultProp->addValue(v);
- }
- }
- }
-
- _stateStack.pushObject(obj);
- accept(initializer);
- _stateStack.pop();
-
- return obj;
- }
-}
-
-LocationSpan ProcessAST::location(AST::UiQualifiedId *id)
-{
- return location(id->identifierToken, id->identifierToken);
-}
-
-LocationSpan ProcessAST::location(AST::SourceLocation start, AST::SourceLocation end)
-{
- LocationSpan rv;
- rv.start.line = start.startLine;
- rv.start.column = start.startColumn;
- rv.end.line = end.startLine;
- rv.end.column = end.startColumn + end.length - 1;
- rv.range.offset = start.offset;
- rv.range.length = end.offset + end.length - start.offset;
- return rv;
-}
-
-// UiProgram: UiImportListOpt UiObjectMemberList ;
-bool ProcessAST::visit(AST::UiProgram *node)
-{
- accept(node->imports);
- accept(node->members->member);
- return false;
-}
-
-// UiImport: T_IMPORT T_STRING_LITERAL ;
-bool ProcessAST::visit(AST::UiImport *node)
-{
- QString uri;
- QDeclarativeScript::Import import;
-
- if (!node->fileName.isNull()) {
- uri = node->fileName.toString();
-
- if (uri.endsWith(QLatin1String(".js"))) {
- import.type = QDeclarativeScript::Import::Script;
- } else {
- import.type = QDeclarativeScript::Import::File;
- }
- } else {
- import.type = QDeclarativeScript::Import::Library;
- uri = asString(node->importUri);
- }
-
- AST::SourceLocation startLoc = node->importToken;
- AST::SourceLocation endLoc = node->semicolonToken;
-
- // Qualifier
- if (!node->importId.isNull()) {
- import.qualifier = node->importId.toString();
- if (!import.qualifier.at(0).isUpper()) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Invalid import qualifier ID"));
- error.setLine(node->importIdToken.startLine);
- error.setColumn(node->importIdToken.startColumn);
- _parser->_errors << error;
- return false;
- }
- if (import.qualifier == QLatin1String("Qt")) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Reserved name \"Qt\" cannot be used as an qualifier"));
- error.setLine(node->importIdToken.startLine);
- error.setColumn(node->importIdToken.startColumn);
- _parser->_errors << error;
- return false;
- }
-
- // Check for script qualifier clashes
- bool isScript = import.type == QDeclarativeScript::Import::Script;
- for (int ii = 0; ii < _parser->_imports.count(); ++ii) {
- const QDeclarativeScript::Import &other = _parser->_imports.at(ii);
- bool otherIsScript = other.type == QDeclarativeScript::Import::Script;
-
- if ((isScript || otherIsScript) && import.qualifier == other.qualifier) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Script import qualifiers must be unique."));
- error.setLine(node->importIdToken.startLine);
- error.setColumn(node->importIdToken.startColumn);
- _parser->_errors << error;
- return false;
- }
- }
-
- } else if (import.type == QDeclarativeScript::Import::Script) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Script import requires a qualifier"));
- error.setLine(node->fileNameToken.startLine);
- error.setColumn(node->fileNameToken.startColumn);
- _parser->_errors << error;
- return false;
- }
-
- if (node->versionToken.isValid()) {
- import.version = textAt(node->versionToken);
- } else if (import.type == QDeclarativeScript::Import::Library) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Library import requires a version"));
- error.setLine(node->importIdToken.startLine);
- error.setColumn(node->importIdToken.startColumn);
- _parser->_errors << error;
- return false;
- }
-
-
- import.location = location(startLoc, endLoc);
- import.uri = uri;
-
- _parser->_imports << import;
-
- return false;
-}
-
-bool ProcessAST::visit(AST::UiPublicMember *node)
-{
- static const struct TypeNameToType {
- const char *name;
- int nameLength;
- Object::DynamicProperty::Type type;
- const char *qtName;
- int qtNameLength;
- } propTypeNameToTypes[] = {
- { "int", strlen("int"), Object::DynamicProperty::Int, "int", strlen("int") },
- { "bool", strlen("bool"), Object::DynamicProperty::Bool, "bool", strlen("bool") },
- { "double", strlen("double"), Object::DynamicProperty::Real, "double", strlen("double") },
- { "real", strlen("real"), Object::DynamicProperty::Real, "qreal", strlen("qreal") },
- { "string", strlen("string"), Object::DynamicProperty::String, "QString", strlen("QString") },
- { "url", strlen("url"), Object::DynamicProperty::Url, "QUrl", strlen("QUrl") },
- { "color", strlen("color"), Object::DynamicProperty::Color, "QColor", strlen("QColor") },
- // Internally QTime, QDate and QDateTime are all supported.
- // To be more consistent with JavaScript we expose only
- // QDateTime as it matches closely with the Date JS type.
- // We also call it "date" to match.
- // { "time", strlen("time"), Object::DynamicProperty::Time, "QTime", strlen("QTime") },
- // { "date", strlen("date"), Object::DynamicProperty::Date, "QDate", strlen("QDate") },
- { "date", strlen("date"), Object::DynamicProperty::DateTime, "QDateTime", strlen("QDateTime") },
- { "variant", strlen("variant"), Object::DynamicProperty::Variant, "QVariant", strlen("QVariant") },
- { "var", strlen("var"), Object::DynamicProperty::Var, "QVariant", strlen("QVariant") }
- };
- static const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) /
- sizeof(propTypeNameToTypes[0]);
-
- if(node->type == AST::UiPublicMember::Signal) {
- Object::DynamicSignal *signal = _parser->_pool.New<Object::DynamicSignal>();
- signal->name = node->name;
-
- AST::UiParameterList *p = node->parameters;
- int paramLength = 0;
- while (p) { paramLength++; p = p->next; }
- p = node->parameters;
-
- if (paramLength) {
- signal->parameterTypes = _parser->_pool.NewRawList<QHashedCStringRef>(paramLength);
- signal->parameterNames = _parser->_pool.NewRawList<QHashedStringRef>(paramLength);
- }
-
- int index = 0;
- while (p) {
- const QStringRef &memberType = p->type;
-
- const TypeNameToType *type = 0;
- for(int typeIndex = 0; typeIndex < propTypeNameToTypesCount; ++typeIndex) {
- const TypeNameToType *t = propTypeNameToTypes + typeIndex;
- if (t->nameLength == memberType.length() &&
- QHashedString::compare(memberType.constData(), t->name, t->nameLength)) {
- type = t;
- break;
- }
- }
-
- if (!type) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Expected parameter type"));
- error.setLine(node->typeToken.startLine);
- error.setColumn(node->typeToken.startColumn);
- _parser->_errors << error;
- return false;
- }
-
- signal->parameterTypes[index] = QHashedCStringRef(type->qtName, type->qtNameLength);
- signal->parameterNames[index] = QHashedStringRef(p->name);
- p = p->next;
- index++;
- }
-
- signal->location = location(node->typeToken, node->semicolonToken);
- _stateStack.top().object->dynamicSignals.append(signal);
- } else {
- const QStringRef &memberType = node->memberType;
- const QStringRef &name = node->name;
-
- bool typeFound = false;
- Object::DynamicProperty::Type type;
-
- if ((unsigned)memberType.length() == strlen("alias") &&
- QHashedString::compare(memberType.constData(), "alias", strlen("alias"))) {
- type = Object::DynamicProperty::Alias;
- typeFound = true;
- }
-
- for(int ii = 0; !typeFound && ii < propTypeNameToTypesCount; ++ii) {
- const TypeNameToType *t = propTypeNameToTypes + ii;
- if (t->nameLength == memberType.length() &&
- QHashedString::compare(memberType.constData(), t->name, t->nameLength)) {
- type = t->type;
- typeFound = true;
- }
- }
-
- if (!typeFound && memberType.at(0).isUpper()) {
- const QStringRef &typeModifier = node->typeModifier;
-
- if (typeModifier.isEmpty()) {
- type = Object::DynamicProperty::Custom;
- } else if((unsigned)typeModifier.length() == strlen("list") &&
- QHashedString::compare(typeModifier.constData(), "list", strlen("list"))) {
- type = Object::DynamicProperty::CustomList;
- } else {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Invalid property type modifier"));
- error.setLine(node->typeModifierToken.startLine);
- error.setColumn(node->typeModifierToken.startColumn);
- _parser->_errors << error;
- return false;
- }
- typeFound = true;
- } else if (!node->typeModifier.isNull()) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Unexpected property type modifier"));
- error.setLine(node->typeModifierToken.startLine);
- error.setColumn(node->typeModifierToken.startColumn);
- _parser->_errors << error;
- return false;
- }
-
- if(!typeFound) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Expected property type"));
- error.setLine(node->typeToken.startLine);
- error.setColumn(node->typeToken.startColumn);
- _parser->_errors << error;
- return false;
- }
-
- Object::DynamicProperty *property = _parser->_pool.New<Object::DynamicProperty>();
- property->isDefaultProperty = node->isDefaultMember;
- property->isReadOnly = node->isReadonlyMember;
- property->type = type;
- property->nameLocation.line = node->identifierToken.startLine;
- property->nameLocation.column = node->identifierToken.startColumn;
- if (type >= Object::DynamicProperty::Custom) {
- QDeclarativeScript::TypeReference *typeRef =
- _parser->findOrCreateType(memberType.toString());
- typeRef->refObjects.append(_stateStack.top().object);
- property->customType = memberType;
- }
-
- property->name = QHashedStringRef(name);
- property->location = location(node->firstSourceLocation(),
- node->lastSourceLocation());
-
- if (node->statement) { // default value
- property->defaultValue = _parser->_pool.New<Property>();
- property->defaultValue->parent = _stateStack.top().object;
- property->defaultValue->location =
- location(node->statement->firstSourceLocation(),
- node->statement->lastSourceLocation());
- QDeclarativeScript::Value *value = _parser->_pool.New<QDeclarativeScript::Value>();
- value->location = location(node->statement->firstSourceLocation(),
- node->statement->lastSourceLocation());
- value->value = getVariant(node->statement);
- property->defaultValue->values.append(value);
- }
-
- _stateStack.top().object->dynamicProperties.append(property);
-
- // process QML-like initializers (e.g. property Object o: Object {})
- accept(node->binding);
- }
-
- return false;
-}
-
-
-// UiObjectMember: UiQualifiedId UiObjectInitializer ;
-bool ProcessAST::visit(AST::UiObjectDefinition *node)
-{
- LocationSpan l = location(node->firstSourceLocation(),
- node->lastSourceLocation());
-
- const QString objectType = asString(node->qualifiedTypeNameId);
- const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken;
-
- defineObjectBinding(/*propertyName = */ 0, false, objectType,
- typeLocation, l, node->initializer);
-
- return false;
-}
-
-
-// UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
-bool ProcessAST::visit(AST::UiObjectBinding *node)
-{
- LocationSpan l = location(node->qualifiedTypeNameId->identifierToken,
- node->initializer->rbraceToken);
-
- const QString objectType = asString(node->qualifiedTypeNameId);
- const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken;
-
- defineObjectBinding(node->qualifiedId, node->hasOnToken, objectType,
- typeLocation, l, node->initializer);
-
- return false;
-}
-
-QDeclarativeScript::Variant ProcessAST::getVariant(AST::Statement *stmt)
-{
- if (stmt) {
- if (AST::ExpressionStatement *exprStmt = AST::cast<AST::ExpressionStatement *>(stmt))
- return getVariant(exprStmt->expression);
-
- return QDeclarativeScript::Variant(asStringRef(stmt), stmt);
- }
-
- return QDeclarativeScript::Variant();
-}
-
-QDeclarativeScript::Variant ProcessAST::getVariant(AST::ExpressionNode *expr)
-{
- if (AST::StringLiteral *lit = AST::cast<AST::StringLiteral *>(expr)) {
- return QDeclarativeScript::Variant(lit);
- } else if (expr->kind == AST::Node::Kind_TrueLiteral) {
- return QDeclarativeScript::Variant(true);
- } else if (expr->kind == AST::Node::Kind_FalseLiteral) {
- return QDeclarativeScript::Variant(false);
- } else if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(expr)) {
- return QDeclarativeScript::Variant(lit->value, asStringRef(expr));
- } else {
-
- if (AST::UnaryMinusExpression *unaryMinus = AST::cast<AST::UnaryMinusExpression *>(expr)) {
- if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(unaryMinus->expression)) {
- return QDeclarativeScript::Variant(-lit->value, asStringRef(expr));
- }
- }
-
- return QDeclarativeScript::Variant(asStringRef(expr), expr);
- }
-}
-
-
-// UiObjectMember: UiQualifiedId T_COLON Statement ;
-bool ProcessAST::visit(AST::UiScriptBinding *node)
-{
- int propertyCount = 0;
- AST::UiQualifiedId *propertyName = node->qualifiedId;
- for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
- ++propertyCount;
- _stateStack.pushProperty(name->name,
- location(name));
- }
-
- Property *prop = currentProperty();
-
- if (!prop->values.isEmpty()) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
- error.setLine(this->location(propertyName).start.line);
- error.setColumn(this->location(propertyName).start.column);
- _parser->_errors << error;
- return 0;
- }
-
- QDeclarativeScript::Variant primitive;
-
- if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) {
- primitive = getVariant(stmt->expression);
- } else { // do binding
- primitive = QDeclarativeScript::Variant(asStringRef(node->statement), node->statement);
- }
-
- prop->location.range.length = prop->location.range.offset + prop->location.range.length - node->qualifiedId->identifierToken.offset;
- prop->location.range.offset = node->qualifiedId->identifierToken.offset;
- QDeclarativeScript::Value *v = _parser->_pool.New<QDeclarativeScript::Value>();
- v->value = primitive;
- v->location = location(node->statement->firstSourceLocation(),
- node->statement->lastSourceLocation());
-
- prop->addValue(v);
-
- while (propertyCount--)
- _stateStack.pop();
-
- return false;
-}
-
-// UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
-bool ProcessAST::visit(AST::UiArrayBinding *node)
-{
- int propertyCount = 0;
- AST::UiQualifiedId *propertyName = node->qualifiedId;
- for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
- ++propertyCount;
- _stateStack.pushProperty(name->name,
- location(name));
- }
-
- Property* prop = currentProperty();
-
- if (!prop->values.isEmpty()) {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
- error.setLine(this->location(propertyName).start.line);
- error.setColumn(this->location(propertyName).start.column);
- _parser->_errors << error;
- return false;
- }
-
- accept(node->members);
-
- // For the DOM, store the position of the T_LBRACKET upto the T_RBRACKET as the range:
- prop->listValueRange.offset = node->lbracketToken.offset;
- prop->listValueRange.length = node->rbracketToken.offset + node->rbracketToken.length - node->lbracketToken.offset;
-
- while (propertyCount--)
- _stateStack.pop();
-
- return false;
-}
-
-bool ProcessAST::visit(AST::UiSourceElement *node)
-{
- QDeclarativeScript::Object *obj = currentObject();
-
- if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
-
- Object::DynamicSlot *slot = _parser->_pool.New<Object::DynamicSlot>();
- slot->location = location(funDecl->identifierToken, funDecl->lastSourceLocation());
-
- AST::FormalParameterList *f = funDecl->formals;
- while (f) {
- slot->parameterNames << f->name.toUtf8();
- f = f->next;
- }
-
- AST::SourceLocation loc = funDecl->rparenToken;
- loc.offset = loc.end();
- loc.startColumn += 1;
- QString body = textAt(loc, funDecl->rbraceToken);
- slot->name = funDecl->name;
- slot->body = body;
- obj->dynamicSlots.append(slot);
-
- } else {
- QDeclarativeError error;
- error.setDescription(QCoreApplication::translate("QDeclarativeParser","JavaScript declaration outside Script element"));
- error.setLine(node->firstSourceLocation().startLine);
- error.setColumn(node->firstSourceLocation().startColumn);
- _parser->_errors << error;
- }
- return false;
-}
-
-} // end of anonymous namespace
-
-
-QDeclarativeScript::Parser::Parser()
-: root(0), data(0)
-{
-
-}
-
-QDeclarativeScript::Parser::~Parser()
-{
- clear();
-}
-
-namespace QDeclarativeScript {
-class ParserJsASTData
-{
-public:
- ParserJsASTData(const QString &filename)
- : filename(filename) {}
-
- QString filename;
- Engine engine;
-};
-}
-
-bool QDeclarativeScript::Parser::parse(const QByteArray &qmldata, const QUrl &url,
- const QString &urlString)
-{
- clear();
-
- if (urlString.isEmpty()) {
- _scriptFile = url.toString();
- } else {
- // Q_ASSERT(urlString == url.toString());
- _scriptFile = urlString;
- }
-
- QTextStream stream(qmldata, QIODevice::ReadOnly);
-#ifndef QT_NO_TEXTCODEC
- stream.setCodec("UTF-8");
-#endif
- QString *code = _pool.NewString(stream.readAll());
-
- data = new QDeclarativeScript::ParserJsASTData(_scriptFile);
-
- Lexer lexer(&data->engine);
- lexer.setCode(*code, /*line = */ 1);
-
- QDeclarativeJS::Parser parser(&data->engine);
-
- if (! parser.parse() || !_errors.isEmpty()) {
-
- // Extract errors from the parser
- foreach (const DiagnosticMessage &m, parser.diagnosticMessages()) {
-
- if (m.isWarning())
- continue;
-
- QDeclarativeError error;
- error.setUrl(url);
- error.setDescription(m.message);
- error.setLine(m.loc.startLine);
- error.setColumn(m.loc.startColumn);
- _errors << error;
-
- }
- }
-
- if (_errors.isEmpty()) {
- ProcessAST process(this);
- process(*code, parser.ast());
-
- // Set the url for process errors
- for(int ii = 0; ii < _errors.count(); ++ii)
- _errors[ii].setUrl(url);
- }
-
- return _errors.isEmpty();
-}
-
-QList<QDeclarativeScript::TypeReference*> QDeclarativeScript::Parser::referencedTypes() const
-{
- return _refTypes;
-}
-
-QDeclarativeScript::Object *QDeclarativeScript::Parser::tree() const
-{
- return root;
-}
-
-QList<QDeclarativeScript::Import> QDeclarativeScript::Parser::imports() const
-{
- return _imports;
-}
-
-QList<QDeclarativeError> QDeclarativeScript::Parser::errors() const
-{
- return _errors;
-}
-
-static void replaceWithSpace(QString &str, int idx, int n)
-{
- QChar *data = str.data() + idx;
- const QChar space(QLatin1Char(' '));
- for (int ii = 0; ii < n; ++ii)
- *data++ = space;
-}
-
-static QDeclarativeScript::LocationSpan
-locationFromLexer(const QDeclarativeJS::Lexer &lex, int startLine, int startColumn, int startOffset)
-{
- QDeclarativeScript::LocationSpan l;
-
- l.start.line = startLine; l.start.column = startColumn;
- l.end.line = lex.tokenEndLine(); l.end.column = lex.tokenEndColumn();
- l.range.offset = startOffset;
- l.range.length = lex.tokenOffset() + lex.tokenLength() - startOffset;
-
- return l;
-}
-
-/*
-Searches for ".pragma <value>" declarations within \a script. Currently supported pragmas
-are:
- library
-*/
-QDeclarativeScript::Object::ScriptBlock::Pragmas QDeclarativeScript::Parser::extractPragmas(QString &script)
-{
- QDeclarativeScript::Object::ScriptBlock::Pragmas rv = QDeclarativeScript::Object::ScriptBlock::None;
-
- const QString pragma(QLatin1String("pragma"));
- const QString library(QLatin1String("library"));
-
- QDeclarativeJS::Lexer l(0);
- l.setCode(script, 0);
-
- int token = l.lex();
-
- while (true) {
- if (token != QDeclarativeJSGrammar::T_DOT)
- return rv;
-
- int startOffset = l.tokenOffset();
- int startLine = l.tokenStartLine();
-
- token = l.lex();
-
- if (token != QDeclarativeJSGrammar::T_IDENTIFIER ||
- l.tokenStartLine() != startLine ||
- script.mid(l.tokenOffset(), l.tokenLength()) != pragma)
- return rv;
-
- token = l.lex();
-
- if (token != QDeclarativeJSGrammar::T_IDENTIFIER ||
- l.tokenStartLine() != startLine)
- return rv;
-
- QString pragmaValue = script.mid(l.tokenOffset(), l.tokenLength());
- int endOffset = l.tokenLength() + l.tokenOffset();
-
- token = l.lex();
- if (l.tokenStartLine() == startLine)
- return rv;
-
- if (pragmaValue == library) {
- rv |= QDeclarativeScript::Object::ScriptBlock::Shared;
- replaceWithSpace(script, startOffset, endOffset - startOffset);
- } else {
- return rv;
- }
- }
- return rv;
-}
-
-#define CHECK_LINE if (l.tokenStartLine() != startLine) return rv;
-#define CHECK_TOKEN(t) if (token != QDeclarativeJSGrammar:: t) return rv;
-
-static const int uriTokens[] = {
- QDeclarativeJSGrammar::T_IDENTIFIER,
- QDeclarativeJSGrammar::T_PROPERTY,
- QDeclarativeJSGrammar::T_SIGNAL,
- QDeclarativeJSGrammar::T_READONLY,
- QDeclarativeJSGrammar::T_ON,
- QDeclarativeJSGrammar::T_BREAK,
- QDeclarativeJSGrammar::T_CASE,
- QDeclarativeJSGrammar::T_CATCH,
- QDeclarativeJSGrammar::T_CONTINUE,
- QDeclarativeJSGrammar::T_DEFAULT,
- QDeclarativeJSGrammar::T_DELETE,
- QDeclarativeJSGrammar::T_DO,
- QDeclarativeJSGrammar::T_ELSE,
- QDeclarativeJSGrammar::T_FALSE,
- QDeclarativeJSGrammar::T_FINALLY,
- QDeclarativeJSGrammar::T_FOR,
- QDeclarativeJSGrammar::T_FUNCTION,
- QDeclarativeJSGrammar::T_IF,
- QDeclarativeJSGrammar::T_IN,
- QDeclarativeJSGrammar::T_INSTANCEOF,
- QDeclarativeJSGrammar::T_NEW,
- QDeclarativeJSGrammar::T_NULL,
- QDeclarativeJSGrammar::T_RETURN,
- QDeclarativeJSGrammar::T_SWITCH,
- QDeclarativeJSGrammar::T_THIS,
- QDeclarativeJSGrammar::T_THROW,
- QDeclarativeJSGrammar::T_TRUE,
- QDeclarativeJSGrammar::T_TRY,
- QDeclarativeJSGrammar::T_TYPEOF,
- QDeclarativeJSGrammar::T_VAR,
- QDeclarativeJSGrammar::T_VOID,
- QDeclarativeJSGrammar::T_WHILE,
- QDeclarativeJSGrammar::T_CONST,
- QDeclarativeJSGrammar::T_DEBUGGER,
- QDeclarativeJSGrammar::T_RESERVED_WORD,
- QDeclarativeJSGrammar::T_WITH,
-
- QDeclarativeJSGrammar::EOF_SYMBOL
-};
-static inline bool isUriToken(int token)
-{
- const int *current = uriTokens;
- while (*current != QDeclarativeJSGrammar::EOF_SYMBOL) {
- if (*current == token)
- return true;
- ++current;
- }
- return false;
-}
-
-QDeclarativeScript::Parser::JavaScriptMetaData QDeclarativeScript::Parser::extractMetaData(QString &script)
-{
- JavaScriptMetaData rv;
-
- QDeclarativeScript::Object::ScriptBlock::Pragmas &pragmas = rv.pragmas;
-
- const QString pragma(QLatin1String("pragma"));
- const QString js(QLatin1String(".js"));
- const QString library(QLatin1String("library"));
-
- QDeclarativeJS::Lexer l(0);
- l.setCode(script, 0);
-
- int token = l.lex();
-
- while (true) {
- if (token != QDeclarativeJSGrammar::T_DOT)
- return rv;
-
- int startOffset = l.tokenOffset();
- int startLine = l.tokenStartLine();
- int startColumn = l.tokenStartColumn();
-
- token = l.lex();
-
- CHECK_LINE;
-
- if (token == QDeclarativeJSGrammar::T_IMPORT) {
-
- // .import <URI> <Version> as <Identifier>
- // .import <file.js> as <Identifier>
-
- token = l.lex();
-
- CHECK_LINE;
-
- if (token == QDeclarativeJSGrammar::T_STRING_LITERAL) {
-
- QString file = l.tokenText();
-
- if (!file.endsWith(js))
- return rv;
-
- token = l.lex();
-
- CHECK_TOKEN(T_AS);
- CHECK_LINE;
-
- token = l.lex();
-
- CHECK_TOKEN(T_IDENTIFIER);
- CHECK_LINE;
-
- int endOffset = l.tokenLength() + l.tokenOffset();
-
- QString importId = script.mid(l.tokenOffset(), l.tokenLength());
-
- if (!importId.at(0).isUpper())
- return rv;
-
- QDeclarativeScript::LocationSpan location =
- locationFromLexer(l, startLine, startColumn, startOffset);
-
- token = l.lex();
- if (l.tokenStartLine() == startLine)
- return rv;
-
- replaceWithSpace(script, startOffset, endOffset - startOffset);
-
- Import import;
- import.type = Import::Script;
- import.uri = file;
- import.qualifier = importId;
- import.location = location;
-
- rv.imports << import;
- } else {
- // URI
- QString uri;
- QString version;
-
- while (true) {
- if (!isUriToken(token))
- return rv;
-
- uri.append(l.tokenText());
-
- token = l.lex();
- CHECK_LINE;
- if (token != QDeclarativeJSGrammar::T_DOT)
- break;
-
- uri.append(QLatin1Char('.'));
-
- token = l.lex();
- CHECK_LINE;
- }
-
- CHECK_TOKEN(T_NUMERIC_LITERAL);
- version = script.mid(l.tokenOffset(), l.tokenLength());
-
- token = l.lex();
-
- CHECK_TOKEN(T_AS);
- CHECK_LINE;
-
- token = l.lex();
-
- CHECK_TOKEN(T_IDENTIFIER);
- CHECK_LINE;
-
- int endOffset = l.tokenLength() + l.tokenOffset();
-
- QString importId = script.mid(l.tokenOffset(), l.tokenLength());
-
- if (!importId.at(0).isUpper())
- return rv;
-
- QDeclarativeScript::LocationSpan location =
- locationFromLexer(l, startLine, startColumn, startOffset);
-
- token = l.lex();
- if (l.tokenStartLine() == startLine)
- return rv;
-
- replaceWithSpace(script, startOffset, endOffset - startOffset);
-
- Import import;
- import.type = Import::Library;
- import.uri = uri;
- import.version = version;
- import.qualifier = importId;
- import.location = location;
-
- rv.imports << import;
- }
-
- } else if (token == QDeclarativeJSGrammar::T_IDENTIFIER &&
- script.mid(l.tokenOffset(), l.tokenLength()) == pragma) {
-
- token = l.lex();
-
- CHECK_TOKEN(T_IDENTIFIER);
- CHECK_LINE;
-
- QString pragmaValue = script.mid(l.tokenOffset(), l.tokenLength());
- int endOffset = l.tokenLength() + l.tokenOffset();
-
- if (pragmaValue == library) {
- pragmas |= QDeclarativeScript::Object::ScriptBlock::Shared;
- replaceWithSpace(script, startOffset, endOffset - startOffset);
- } else {
- return rv;
- }
-
- token = l.lex();
- if (l.tokenStartLine() == startLine)
- return rv;
-
- } else {
- return rv;
- }
- }
- return rv;
-}
-
-void QDeclarativeScript::Parser::clear()
-{
- _imports.clear();
- qDeleteAll(_refTypes);
- _refTypes.clear();
- _errors.clear();
-
- if (data) {
- delete data;
- data = 0;
- }
-
- _pool.clear();
-}
-
-QDeclarativeScript::TypeReference *QDeclarativeScript::Parser::findOrCreateType(const QString &name)
-{
- TypeReference *type = 0;
- int i = 0;
- for (; i < _refTypes.size(); ++i) {
- if (_refTypes.at(i)->name == name) {
- type = _refTypes.at(i);
- break;
- }
- }
- if (!type) {
- type = new TypeReference(i, name);
- _refTypes.append(type);
- }
-
- return type;
-}
-
-void QDeclarativeScript::Parser::setTree(QDeclarativeScript::Object *tree)
-{
- Q_ASSERT(! root);
-
- root = tree;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativescript_p.h b/src/declarative/qml/qdeclarativescript_p.h
deleted file mode 100644
index 86fc1c5bfd..0000000000
--- a/src/declarative/qml/qdeclarativescript_p.h
+++ /dev/null
@@ -1,533 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QDECLARATIVESCRIPT_P_H
-#define QDECLARATIVESCRIPT_P_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 <QtDeclarative/qdeclarativeerror.h>
-
-#include <private/qfieldlist_p.h>
-#include <private/qhashfield_p.h>
-#include <private/qfastmetabuilder_p.h>
-#include <private/qdeclarativepool_p.h>
-#include <private/qdeclarativepropertycache_p.h>
-
-#include <QtCore/QList>
-#include <QtCore/QUrl>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QByteArray;
-class QDeclarativePropertyCache;
-namespace QDeclarativeJS { namespace AST { class Node; class StringLiteral; } }
-namespace QDeclarativeCompilerTypes { struct BindingReference; struct ComponentCompileState; }
-
-namespace QDeclarativeScript {
-
-struct Location
-{
- Location() : line(-1), column(-1) {}
- int line;
- int column;
-
- inline bool operator<(const Location &other) {
- return line < other.line ||
- (line == other.line && column < other.column);
- }
-};
-
-struct LocationRange
-{
- LocationRange() : offset(0), length(0) {}
- quint32 offset;
- quint32 length;
-};
-
-struct LocationSpan
-{
- Location start;
- Location end;
- LocationRange range;
-
- bool operator<(LocationSpan &o) const {
- return (start.line < o.start.line) ||
- (start.line == o.start.line && start.column < o.start.column);
- }
-};
-
-class Import
-{
-public:
- Import() : type(Library) {}
-
- enum Type { Library, File, Script };
- Type type;
-
- QString uri;
- QString qualifier;
- QString version;
-
- void extractVersion(int *maj, int *min) const;
-
- QDeclarativeScript::LocationSpan location;
-};
-
-class Object;
-class TypeReference
-{
-public:
- TypeReference(int typeId, const QString &typeName) : id(typeId), name(typeName) {}
-
- int id;
- // type as it has been referenced in Qml
- QString name;
- // objects in parse tree referencing the type
- QList<QDeclarativeScript::Object*> refObjects;
-};
-
-class Object;
-class Property;
-
-class Q_DECLARATIVE_EXPORT Variant
-{
-public:
- enum Type {
- Invalid,
- Boolean,
- Number,
- String,
- Script
- };
-
- Variant();
- Variant(const Variant &);
- explicit Variant(bool);
- explicit Variant(double, const QStringRef &asWritten = QStringRef());
- explicit Variant(QDeclarativeJS::AST::StringLiteral *);
- explicit Variant(const QStringRef &asWritten, QDeclarativeJS::AST::Node *);
- Variant &operator=(const Variant &);
-
- Type type() const;
-
- bool isBoolean() const { return type() == Boolean; }
- bool isNumber() const { return type() == Number; }
- bool isString() const { return type() == String; }
- bool isScript() const { return type() == Script; }
- bool isStringList() const;
-
- bool asBoolean() const;
- QString asString() const;
- double asNumber() const;
- QString asScript() const;
- QDeclarativeJS::AST::Node *asAST() const;
- QStringList asStringList() const;
-
-private:
- Type t;
- union {
- bool b;
- double d;
- QDeclarativeJS::AST::StringLiteral *l;
- QDeclarativeJS::AST::Node *n;
- };
- QStringRef asWritten;
-};
-
-class Value : public QDeclarativePool::POD
-{
-public:
- Value();
-
- enum Type {
- // The type of this value assignment is not yet known
- Unknown,
- // This is used as a literal property assignment
- Literal,
- // This is used as a property binding assignment
- PropertyBinding,
- // This is used as a QDeclarativePropertyValueSource assignment
- ValueSource,
- // This is used as a QDeclarativePropertyValueInterceptor assignment
- ValueInterceptor,
- // This is used as a property QObject assignment
- CreatedObject,
- // This is used as a signal object assignment
- SignalObject,
- // This is used as a signal expression assignment
- SignalExpression,
- // This is used as an id assignment only
- Id
- };
- Type type;
-
- // ### Temporary (for id only)
- QString primitive() const { return value.isString() ? value.asString() : value.asScript(); }
-
- // Primitive value
- Variant value;
- // Object value
- Object *object;
-
- LocationSpan location;
-
- // Used by compiler
- union {
- QDeclarativeCompilerTypes::BindingReference *bindingReference;
- int signalExpressionContextStack;
- };
-
- // Used in Property::ValueList lists
- Value *nextValue;
-};
-
-class Property : public QDeclarativePool::POD
-{
-public:
- Property();
-
- // The Object to which this property is attached
- Object *parent;
-
- Object *getValue(const LocationSpan &);
- void addValue(Value *v);
- void addOnValue(Value *v);
-
- // The QVariant::Type of the property, or 0 (QVariant::Invalid) if
- // unknown.
- int type;
- // The metaobject index of this property, or -1 if unknown.
- int index;
- // The core data in the case of a regular property.
- // XXX This has to be a value now as the synthCache may change during
- // compilation which invalidates pointers. We should fix this.
- QDeclarativePropertyData core;
-
- // Returns true if this is an empty property - both value and values
- // are unset.
- bool isEmpty() const;
-
- typedef QFieldList<Value, &Value::nextValue> ValueList;
- // The list of values assigned to this property. Content in values
- // and value are mutually exclusive
- ValueList values;
- // The list of values assigned to this property using the "on" syntax
- ValueList onValues;
- // The accessed property. This is used to represent dot properties.
- // Content in value and values are mutually exclusive.
- Object *value;
- // The property name
- const QHashedStringRef &name() const { return _name; }
- void setName(const QString &n) { _name = QHashedStringRef(pool()->NewString(n)); }
- void setName(const QHashedStringRef &n) { _name = n; }
- // True if this property was accessed as the default property.
- bool isDefault;
- // True if the setting of this property will be deferred. Set by the
- // QDeclarativeCompiler
- bool isDeferred;
- // True if this property is a value-type pseudo-property
- bool isValueTypeSubProperty;
- // True if this property is a property alias. Set by the
- // QDeclarativeCompiler
- bool isAlias;
- // True if this is a readonly property declaration
- bool isReadOnlyDeclaration;
-
- // Used for scriptStringProperties
- int scriptStringScope;
-
- LocationSpan location;
- LocationRange listValueRange;
-
- // Used in Object::MainPropertyList
- Property *nextMainProperty;
-
- // Used in Object::PropertyList lists
- Property *nextProperty;
-
-private:
- friend class Object;
- QHashedStringRef _name;
-};
-
-class Object : public QDeclarativePool::Class
-{
-public:
- Object();
- virtual ~Object();
-
- // Type of the object. The integer is an index into the
- // QDeclarativeCompiledData::types array, or -1 if the object is a property
- // group.
- int type;
-
- // The fully-qualified name of this type
- QString typeName;
- // The id assigned to the object (if any). Set by the QDeclarativeCompiler
- QString id;
- // The id index assigned to the object (if any). Set by the QDeclarativeCompiler
- int idIndex;
- // Custom parsed data
- QByteArray custom;
- // Bit mask of the properties assigned bindings
- QByteArray bindingBitmask;
- void setBindingBit(int);
- // Returns the metaobject for this type, or 0 if not available.
- // Internally selectd between the metatype and extObject variables
- const QMetaObject *metaObject() const;
-
- // The compile time metaobject for this type
- const QMetaObject *metatype;
- // The synthesized metaobject, if QML added signals or properties to
- // this type. Otherwise null
- QAbstractDynamicMetaObject extObject;
- QByteArray metadata; // Generated by compiler
- QByteArray synthdata; // Generated by compiler
- QDeclarativePropertyCache *synthCache; // Generated by compiler
-
- Property *getDefaultProperty();
- // name ptr must be guarenteed to remain valid
- Property *getProperty(const QHashedStringRef &name, bool create=true);
- Property *getProperty(const QStringRef &name, bool create=true);
- Property *getProperty(const QString &name, bool create=true);
-
- Property *defaultProperty;
-
- typedef QFieldList<Property, &Property::nextMainProperty> MainPropertyList;
- MainPropertyList properties;
- QHashField propertiesHashField;
-
- // Output of the compilation phase (these properties continue to exist
- // in either the defaultProperty or properties members too)
- void addValueProperty(Property *);
- void addSignalProperty(Property *);
- void addAttachedProperty(Property *);
- void addGroupedProperty(Property *);
- void addValueTypeProperty(Property *);
- void addScriptStringProperty(Property *);
-
- typedef QFieldList<Property, &Property::nextProperty> PropertyList;
- PropertyList valueProperties;
- PropertyList signalProperties;
- PropertyList attachedProperties;
- PropertyList groupedProperties;
- PropertyList valueTypeProperties;
- PropertyList scriptStringProperties;
-
- // Script blocks that were nested under this object
- struct ScriptBlock {
- enum Pragma {
- None = 0x00000000,
- Shared = 0x00000001
- };
- Q_DECLARE_FLAGS(Pragmas, Pragma)
-
- QString code;
- QString file;
- Pragmas pragmas;
- };
-
- // The bytes to cast instances by to get to the QDeclarativeParserStatus
- // interface. -1 indicates the type doesn't support this interface.
- // Set by the QDeclarativeCompiler.
- int parserStatusCast;
-
- LocationSpan location;
-
- struct DynamicProperty : public QDeclarativePool::POD
- {
- DynamicProperty();
-
- enum Type { Var, Variant, Int, Bool, Real, String, Url, Color,
- Time, Date, DateTime, Alias, Custom, CustomList };
-
- quint32 isDefaultProperty:1;
- quint32 isReadOnly:1;
-
- Type type;
-
- QHashedStringRef customType;
- QHashedStringRef name;
- QDeclarativeScript::Property *defaultValue;
- LocationSpan location;
- Location nameLocation;
-
- // Used by Object::DynamicPropertyList
- DynamicProperty *nextProperty;
-
- // Used by the compiler
- QByteArray *resolvedCustomTypeName;
- QFastMetaBuilder::StringRef typeRef;
- QFastMetaBuilder::StringRef nameRef;
- QFastMetaBuilder::StringRef changedSignatureRef;
- };
-
- struct DynamicSignal : public QDeclarativePool::POD
- {
- DynamicSignal();
-
- QHashedStringRef name;
- QDeclarativePool::List<QHashedCStringRef> parameterTypes;
- QDeclarativePool::List<QHashedStringRef> parameterNames;
-
- int parameterTypesLength() const;
- int parameterNamesLength() const;
-
- // Used by Object::DynamicSignalList
- DynamicSignal *nextSignal;
-
- // Used by the compiler
- QFastMetaBuilder::StringRef signatureRef;
- QFastMetaBuilder::StringRef parameterNamesRef;
- LocationSpan location;
- };
-
- struct DynamicSlot : public QDeclarativePool::Class
- {
- DynamicSlot();
-
- QHashedStringRef name;
- QString body;
- QList<QByteArray> parameterNames;
- LocationSpan location;
-
- int parameterNamesLength() const;
-
- // Used by Object::DynamicSlotList
- DynamicSlot *nextSlot;
-
- // Used by the compiler
- QFastMetaBuilder::StringRef signatureRef;
- QFastMetaBuilder::StringRef parameterNamesRef;
- };
-
- // The list of dynamic properties
- typedef QFieldList<DynamicProperty, &DynamicProperty::nextProperty> DynamicPropertyList;
- DynamicPropertyList dynamicProperties;
- // The list of dynamic signals
- typedef QFieldList<DynamicSignal, &DynamicSignal::nextSignal> DynamicSignalList;
- DynamicSignalList dynamicSignals;
- // The list of dynamic slots
- typedef QFieldList<DynamicSlot, &DynamicSlot::nextSlot> DynamicSlotList;
- DynamicSlotList dynamicSlots;
-
- // Used by compiler
- QDeclarativeCompilerTypes::ComponentCompileState *componentCompileState;
-
- // Used by ComponentCompileState::AliasingObjectsList
- Object *nextAliasingObject;
- // Used by ComponentComppileState::IdList
- Object *nextIdObject;
-};
-
-class ParserJsASTData;
-class Q_AUTOTEST_EXPORT Parser
-{
-public:
- Parser();
- ~Parser();
-
- bool parse(const QByteArray &data, const QUrl &url = QUrl(),
- const QString &urlString = QString());
-
- QList<TypeReference*> referencedTypes() const;
-
- QDeclarativeScript::Object *tree() const;
- QList<Import> imports() const;
-
- void clear();
-
- QList<QDeclarativeError> errors() const;
-
- class JavaScriptMetaData {
- public:
- JavaScriptMetaData()
- : pragmas(QDeclarativeScript::Object::ScriptBlock::None) {}
-
- QDeclarativeScript::Object::ScriptBlock::Pragmas pragmas;
- QList<Import> imports;
- };
-
- static QDeclarativeScript::Object::ScriptBlock::Pragmas extractPragmas(QString &);
- static JavaScriptMetaData extractMetaData(QString &);
-
-
-// ### private:
- TypeReference *findOrCreateType(const QString &name);
- void setTree(QDeclarativeScript::Object *tree);
-
- void setScriptFile(const QString &filename) {_scriptFile = filename; }
- QString scriptFile() const { return _scriptFile; }
-
-// ### private:
- QList<QDeclarativeError> _errors;
-
- QDeclarativePool _pool;
- QDeclarativeScript::Object *root;
- QList<Import> _imports;
- QList<TypeReference*> _refTypes;
- QString _scriptFile;
- ParserJsASTData *data;
-};
-
-}
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeScript::Object::ScriptBlock::Pragmas);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeScript::Variant)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESCRIPT_P_H
diff --git a/src/declarative/qml/qdeclarativescriptstring.cpp b/src/declarative/qml/qdeclarativescriptstring.cpp
deleted file mode 100644
index b409908902..0000000000
--- a/src/declarative/qml/qdeclarativescriptstring.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativescriptstring.h"
-#include "qdeclarativescriptstring_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
-\class QDeclarativeScriptString
-\since 4.7
-\brief The QDeclarativeScriptString class encapsulates a script and its context.
-
-QDeclarativeScriptString is used to create QObject properties that accept a script "assignment" from QML.
-
-Normally, the following QML would result in a binding being established for the \c script
-property; i.e. \c script would be assigned the value obtained from running \c {myObj.value = Math.max(myValue, 100)}
-
-\qml
-MyType {
- script: myObj.value = Math.max(myValue, 100)
-}
-\endqml
-
-If instead the property had a type of QDeclarativeScriptString,
-the script itself -- \e {myObj.value = Math.max(myValue, 100)} -- would be passed to the \c script property
-and the class could choose how to handle it. Typically, the class will evaluate
-the script at some later time using a QDeclarativeExpression.
-
-\code
-QDeclarativeExpression expr(scriptString);
-expr.evaluate();
-\endcode
-
-\sa QDeclarativeExpression
-*/
-
-/*!
-Constructs an empty instance.
-*/
-QDeclarativeScriptString::QDeclarativeScriptString()
-: d(new QDeclarativeScriptStringPrivate)
-{
-}
-
-/*!
-Copies \a other.
-*/
-QDeclarativeScriptString::QDeclarativeScriptString(const QDeclarativeScriptString &other)
-: d(other.d)
-{
-}
-
-/*!
-\internal
-*/
-QDeclarativeScriptString::~QDeclarativeScriptString()
-{
-}
-
-/*!
-Assigns \a other to this.
-*/
-QDeclarativeScriptString &QDeclarativeScriptString::operator=(const QDeclarativeScriptString &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
-Returns the context for the script.
-*/
-QDeclarativeContext *QDeclarativeScriptString::context() const
-{
- return d->context;
-}
-
-/*!
-Sets the \a context for the script.
-*/
-void QDeclarativeScriptString::setContext(QDeclarativeContext *context)
-{
- d->context = context;
-}
-
-/*!
-Returns the scope object for the script.
-*/
-QObject *QDeclarativeScriptString::scopeObject() const
-{
- return d->scope;
-}
-
-/*!
-Sets the scope \a object for the script.
-*/
-void QDeclarativeScriptString::setScopeObject(QObject *object)
-{
- d->scope = object;
-}
-
-/*!
-Returns the script text.
-*/
-QString QDeclarativeScriptString::script() const
-{
- return d->script;
-}
-
-/*!
-Sets the \a script text.
-*/
-void QDeclarativeScriptString::setScript(const QString &script)
-{
- d->script = script;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qdeclarativescriptstring.h b/src/declarative/qml/qdeclarativescriptstring.h
deleted file mode 100644
index 86357c8cb4..0000000000
--- a/src/declarative/qml/qdeclarativescriptstring.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESCRIPTSTRING_H
-#define QDECLARATIVESCRIPTSTRING_H
-
-#include <QtCore/qstring.h>
-#include <QtCore/qshareddata.h>
-#include <QtCore/qmetatype.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QObject;
-class QDeclarativeContext;
-class QDeclarativeScriptStringPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeScriptString
-{
-public:
- QDeclarativeScriptString();
- QDeclarativeScriptString(const QDeclarativeScriptString &);
- ~QDeclarativeScriptString();
-
- QDeclarativeScriptString &operator=(const QDeclarativeScriptString &);
-
- QDeclarativeContext *context() const;
- void setContext(QDeclarativeContext *);
-
- QObject *scopeObject() const;
- void setScopeObject(QObject *);
-
- QString script() const;
- void setScript(const QString &);
-
-private:
- QSharedDataPointer<QDeclarativeScriptStringPrivate> d;
-
- friend class QDeclarativeVME;
- friend class QDeclarativeExpression;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarativeScriptString)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESCRIPTSTRING_H
-
diff --git a/src/declarative/qml/qdeclarativescriptstring_p.h b/src/declarative/qml/qdeclarativescriptstring_p.h
deleted file mode 100644
index 5f8c1e6c10..0000000000
--- a/src/declarative/qml/qdeclarativescriptstring_p.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESCRIPTSTRING_P_H
-#define QDECLARATIVESCRIPTSTRING_P_H
-
-#include <QtDeclarative/qdeclarativecontext.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeScriptStringPrivate : public QSharedData
-{
-public:
- QDeclarativeScriptStringPrivate() : context(0), scope(0), bindingId(-1), lineNumber(-1), columnNumber(-1) {}
-
- QDeclarativeContext *context;
- QObject *scope;
- QString script;
- int bindingId;
- int lineNumber;
- int columnNumber;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVESCRIPTSTRING_P_H
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp
deleted file mode 100644
index ce35a63727..0000000000
--- a/src/declarative/qml/qdeclarativestringconverters.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativestringconverters_p.h"
-
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qdatetime.h>
-
-QT_BEGIN_NAMESPACE
-
-static uchar fromHex(const uchar c, const uchar c2)
-{
- uchar rv = 0;
- if (c >= '0' && c <= '9')
- rv += (c - '0') * 16;
- else if (c >= 'A' && c <= 'F')
- rv += (c - 'A' + 10) * 16;
- else if (c >= 'a' && c <= 'f')
- rv += (c - 'a' + 10) * 16;
-
- if (c2 >= '0' && c2 <= '9')
- rv += (c2 - '0');
- else if (c2 >= 'A' && c2 <= 'F')
- rv += (c2 - 'A' + 10);
- else if (c2 >= 'a' && c2 <= 'f')
- rv += (c2 - 'a' + 10);
-
- return rv;
-}
-
-static uchar fromHex(const QString &s, int idx)
-{
- uchar c = s.at(idx).toAscii();
- uchar c2 = s.at(idx + 1).toAscii();
- return fromHex(c, c2);
-}
-
-QVariant QDeclarativeStringConverters::variantFromString(const QString &s)
-{
- if (s.isEmpty())
- return QVariant(s);
- bool ok = false;
- QRectF r = rectFFromString(s, &ok);
- if (ok) return QVariant(r);
- QColor c = colorFromString(s, &ok);
- if (ok) return QVariant(c);
- QPointF p = pointFFromString(s, &ok);
- if (ok) return QVariant(p);
- QSizeF sz = sizeFFromString(s, &ok);
- if (ok) return QVariant(sz);
- QVector3D v = vector3DFromString(s, &ok);
- if (ok) return QVariant::fromValue(v);
- QVector4D v4 = vector4DFromString(s, &ok);
- if (ok) return QVariant::fromValue(v4);
-
- return QVariant(s);
-}
-
-QVariant QDeclarativeStringConverters::variantFromString(const QString &s, int preferredType, bool *ok)
-{
- switch (preferredType) {
- case QMetaType::Int:
- return QVariant(int(qRound(s.toDouble(ok))));
- case QMetaType::UInt:
- return QVariant(uint(qRound(s.toDouble(ok))));
- case QMetaType::QColor:
- return QVariant::fromValue(colorFromString(s, ok));
-#ifndef QT_NO_DATESTRING
- case QMetaType::QDate:
- return QVariant::fromValue(dateFromString(s, ok));
- case QMetaType::QTime:
- return QVariant::fromValue(timeFromString(s, ok));
- case QMetaType::QDateTime:
- return QVariant::fromValue(dateTimeFromString(s, ok));
-#endif // QT_NO_DATESTRING
- case QMetaType::QPointF:
- return QVariant::fromValue(pointFFromString(s, ok));
- case QMetaType::QPoint:
- return QVariant::fromValue(pointFFromString(s, ok).toPoint());
- case QMetaType::QSizeF:
- return QVariant::fromValue(sizeFFromString(s, ok));
- case QMetaType::QSize:
- return QVariant::fromValue(sizeFFromString(s, ok).toSize());
- case QMetaType::QRectF:
- return QVariant::fromValue(rectFFromString(s, ok));
- case QMetaType::QRect:
- return QVariant::fromValue(rectFFromString(s, ok).toRect());
- case QMetaType::QVector3D:
- return QVariant::fromValue(vector3DFromString(s, ok));
- case QMetaType::QVector4D:
- return QVariant::fromValue(vector4DFromString(s, ok));
- default:
- if (ok) *ok = false;
- return QVariant();
- }
-}
-
-QColor QDeclarativeStringConverters::colorFromString(const QString &s, bool *ok)
-{
- if (s.length() == 9 && s.startsWith(QLatin1Char('#'))) {
- uchar a = fromHex(s, 1);
- uchar r = fromHex(s, 3);
- uchar g = fromHex(s, 5);
- uchar b = fromHex(s, 7);
- if (ok) *ok = true;
- return QColor(r, g, b, a);
- } else {
- QColor rv(s);
- if (ok) *ok = rv.isValid();
- return rv;
- }
-}
-
-#ifndef QT_NO_DATESTRING
-QDate QDeclarativeStringConverters::dateFromString(const QString &s, bool *ok)
-{
- QDate d = QDate::fromString(s, Qt::ISODate);
- if (ok) *ok = d.isValid();
- return d;
-}
-
-QTime QDeclarativeStringConverters::timeFromString(const QString &s, bool *ok)
-{
- QTime t = QTime::fromString(s, Qt::ISODate);
- if (ok) *ok = t.isValid();
- return t;
-}
-
-QDateTime QDeclarativeStringConverters::dateTimeFromString(const QString &s, bool *ok)
-{
- QDateTime d = QDateTime::fromString(s, Qt::ISODate);
- if (ok) *ok = d.isValid();
- return d;
-}
-#endif // QT_NO_DATESTRING
-
-//expects input of "x,y"
-QPointF QDeclarativeStringConverters::pointFFromString(const QString &s, bool *ok)
-{
- if (s.count(QLatin1Char(',')) != 1) {
- if (ok)
- *ok = false;
- return QPointF();
- }
-
- bool xGood, yGood;
- int index = s.indexOf(QLatin1Char(','));
- qreal xCoord = s.left(index).toDouble(&xGood);
- qreal yCoord = s.mid(index+1).toDouble(&yGood);
- if (!xGood || !yGood) {
- if (ok)
- *ok = false;
- return QPointF();
- }
-
- if (ok)
- *ok = true;
- return QPointF(xCoord, yCoord);
-}
-
-//expects input of "widthxheight"
-QSizeF QDeclarativeStringConverters::sizeFFromString(const QString &s, bool *ok)
-{
- if (s.count(QLatin1Char('x')) != 1) {
- if (ok)
- *ok = false;
- return QSizeF();
- }
-
- bool wGood, hGood;
- int index = s.indexOf(QLatin1Char('x'));
- qreal width = s.left(index).toDouble(&wGood);
- qreal height = s.mid(index+1).toDouble(&hGood);
- if (!wGood || !hGood) {
- if (ok)
- *ok = false;
- return QSizeF();
- }
-
- if (ok)
- *ok = true;
- return QSizeF(width, height);
-}
-
-//expects input of "x,y,widthxheight" //### use space instead of second comma?
-QRectF QDeclarativeStringConverters::rectFFromString(const QString &s, bool *ok)
-{
- if (s.count(QLatin1Char(',')) != 2 || s.count(QLatin1Char('x')) != 1) {
- if (ok)
- *ok = false;
- return QRectF();
- }
-
- bool xGood, yGood, wGood, hGood;
- int index = s.indexOf(QLatin1Char(','));
- qreal x = s.left(index).toDouble(&xGood);
- int index2 = s.indexOf(QLatin1Char(','), index+1);
- qreal y = s.mid(index+1, index2-index-1).toDouble(&yGood);
- index = s.indexOf(QLatin1Char('x'), index2+1);
- qreal width = s.mid(index2+1, index-index2-1).toDouble(&wGood);
- qreal height = s.mid(index+1).toDouble(&hGood);
- if (!xGood || !yGood || !wGood || !hGood) {
- if (ok)
- *ok = false;
- return QRectF();
- }
-
- if (ok)
- *ok = true;
- return QRectF(x, y, width, height);
-}
-
-//expects input of "x,y,z"
-QVector3D QDeclarativeStringConverters::vector3DFromString(const QString &s, bool *ok)
-{
- if (s.count(QLatin1Char(',')) != 2) {
- if (ok)
- *ok = false;
- return QVector3D();
- }
-
- bool xGood, yGood, zGood;
- int index = s.indexOf(QLatin1Char(','));
- int index2 = s.indexOf(QLatin1Char(','), index+1);
- qreal xCoord = s.left(index).toDouble(&xGood);
- qreal yCoord = s.mid(index+1, index2-index-1).toDouble(&yGood);
- qreal zCoord = s.mid(index2+1).toDouble(&zGood);
- if (!xGood || !yGood || !zGood) {
- if (ok)
- *ok = false;
- return QVector3D();
- }
-
- if (ok)
- *ok = true;
- return QVector3D(xCoord, yCoord, zCoord);
-}
-
-//expects input of "x,y,z,w"
-QVector4D QDeclarativeStringConverters::vector4DFromString(const QString &s, bool *ok)
-{
- if (s.count(QLatin1Char(',')) != 3) {
- if (ok)
- *ok = false;
- return QVector4D();
- }
-
- bool xGood, yGood, zGood, wGood;
- int index = s.indexOf(QLatin1Char(','));
- int index2 = s.indexOf(QLatin1Char(','), index+1);
- int index3 = s.indexOf(QLatin1Char(','), index2+1);
- qreal xCoord = s.left(index).toDouble(&xGood);
- qreal yCoord = s.mid(index+1, index2-index-1).toDouble(&yGood);
- qreal zCoord = s.mid(index2+1, index3-index2-1).toDouble(&zGood);
- qreal wCoord = s.mid(index3+1).toDouble(&wGood);
- if (!xGood || !yGood || !zGood || !wGood) {
- if (ok)
- *ok = false;
- return QVector4D();
- }
-
- if (ok)
- *ok = true;
- return QVector4D(xCoord, yCoord, zCoord, wCoord);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativestringconverters_p.h b/src/declarative/qml/qdeclarativestringconverters_p.h
deleted file mode 100644
index c9a83b6be8..0000000000
--- a/src/declarative/qml/qdeclarativestringconverters_p.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTRINGCONVERTERS_P_H
-#define QDECLARATIVESTRINGCONVERTERS_P_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>
-
-#include <private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QColor;
-class QPointF;
-class QSizeF;
-class QRectF;
-class QString;
-class QByteArray;
-class QVector3D;
-class QVector4D;
-
-// XXX - Bauhaus currently uses these methods which is why they're exported
-namespace QDeclarativeStringConverters
-{
- QVariant Q_DECLARATIVE_PRIVATE_EXPORT variantFromString(const QString &);
- QVariant Q_DECLARATIVE_PRIVATE_EXPORT variantFromString(const QString &, int preferredType, bool *ok = 0);
-
- QColor Q_DECLARATIVE_PRIVATE_EXPORT colorFromString(const QString &, bool *ok = 0);
-#ifndef QT_NO_DATESTRING
- QDate Q_DECLARATIVE_PRIVATE_EXPORT dateFromString(const QString &, bool *ok = 0);
- QTime Q_DECLARATIVE_PRIVATE_EXPORT timeFromString(const QString &, bool *ok = 0);
- QDateTime Q_DECLARATIVE_PRIVATE_EXPORT dateTimeFromString(const QString &, bool *ok = 0);
-#endif
- QPointF Q_DECLARATIVE_PRIVATE_EXPORT pointFFromString(const QString &, bool *ok = 0);
- QSizeF Q_DECLARATIVE_PRIVATE_EXPORT sizeFFromString(const QString &, bool *ok = 0);
- QRectF Q_DECLARATIVE_PRIVATE_EXPORT rectFFromString(const QString &, bool *ok = 0);
- QVector3D Q_DECLARATIVE_PRIVATE_EXPORT vector3DFromString(const QString &, bool *ok = 0);
- QVector4D Q_DECLARATIVE_PRIVATE_EXPORT vector4DFromString(const QString &, bool *ok = 0);
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVESTRINGCONVERTERS_P_H
diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp
deleted file mode 100644
index 92dac182c7..0000000000
--- a/src/declarative/qml/qdeclarativetypeloader.cpp
+++ /dev/null
@@ -1,1926 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetypeloader_p.h"
-
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativethread_p.h>
-#include <private/qdeclarativecompiler_p.h>
-#include <private/qdeclarativecomponent_p.h>
-#include <private/qdeclarativeprofilerservice_p.h>
-
-#include <QtCore/qdir.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qthread.h>
-#include <QtCore/qdiriterator.h>
-#include <QtCore/qwaitcondition.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeextensioninterface.h>
-
-#if defined (Q_OS_UNIX)
-#include <sys/types.h>
-#include <dirent.h>
-#endif
-
-// #define DATABLOB_DEBUG
-
-#ifdef DATABLOB_DEBUG
-
-#define ASSERT_MAINTHREAD() do { if(m_thread->isThisThread()) qFatal("QDeclarativeDataLoader: Caller not in main thread"); } while(false)
-#define ASSERT_LOADTHREAD() do { if(!m_thread->isThisThread()) qFatal("QDeclarativeDataLoader: Caller not in load thread"); } while(false)
-#define ASSERT_CALLBACK() do { if(!m_manager || !m_manager->m_thread->isThisThread()) qFatal("QDeclarativeDataBlob: An API call was made outside a callback"); } while(false)
-
-#else
-
-#define ASSERT_MAINTHREAD()
-#define ASSERT_LOADTHREAD()
-#define ASSERT_CALLBACK()
-
-#endif
-
-QT_BEGIN_NAMESPACE
-
-// This is a lame object that we need to ensure that slots connected to
-// QNetworkReply get called in the correct thread (the loader thread).
-// As QDeclarativeDataLoader lives in the main thread, and we can't use
-// Qt::DirectConnection connections from a QNetworkReply (because then
-// sender() wont work), we need to insert this object in the middle.
-class QDeclarativeDataLoaderNetworkReplyProxy : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeDataLoaderNetworkReplyProxy(QDeclarativeDataLoader *l);
-
-public slots:
- void finished();
- void downloadProgress(qint64, qint64);
-
-private:
- QDeclarativeDataLoader *l;
-};
-
-class QDeclarativeDataLoaderThread : public QDeclarativeThread
-{
- typedef QDeclarativeDataLoaderThread This;
-
-public:
- QDeclarativeDataLoaderThread(QDeclarativeDataLoader *loader);
- QNetworkAccessManager *networkAccessManager() const;
- QDeclarativeDataLoaderNetworkReplyProxy *networkReplyProxy() const;
-
- void load(QDeclarativeDataBlob *b);
- void loadAsync(QDeclarativeDataBlob *b);
- void loadWithStaticData(QDeclarativeDataBlob *b, const QByteArray &);
- void loadWithStaticDataAsync(QDeclarativeDataBlob *b, const QByteArray &);
- void callCompleted(QDeclarativeDataBlob *b);
- void callDownloadProgressChanged(QDeclarativeDataBlob *b, qreal p);
- void initializeEngine(QDeclarativeExtensionInterface *, const char *);
-
-protected:
- virtual void shutdownThread();
-
-private:
- void loadThread(QDeclarativeDataBlob *b);
- void loadWithStaticDataThread(QDeclarativeDataBlob *b, const QByteArray &);
- void callCompletedMain(QDeclarativeDataBlob *b);
- void callDownloadProgressChangedMain(QDeclarativeDataBlob *b, qreal p);
- void initializeEngineMain(QDeclarativeExtensionInterface *iface, const char *uri);
-
- QDeclarativeDataLoader *m_loader;
- mutable QNetworkAccessManager *m_networkAccessManager;
- mutable QDeclarativeDataLoaderNetworkReplyProxy *m_networkReplyProxy;
-};
-
-
-QDeclarativeDataLoaderNetworkReplyProxy::QDeclarativeDataLoaderNetworkReplyProxy(QDeclarativeDataLoader *l)
-: l(l)
-{
-}
-
-void QDeclarativeDataLoaderNetworkReplyProxy::finished()
-{
- Q_ASSERT(sender());
- Q_ASSERT(qobject_cast<QNetworkReply *>(sender()));
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
- l->networkReplyFinished(reply);
-}
-
-void QDeclarativeDataLoaderNetworkReplyProxy::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
-{
- Q_ASSERT(sender());
- Q_ASSERT(qobject_cast<QNetworkReply *>(sender()));
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
- l->networkReplyProgress(reply, bytesReceived, bytesTotal);
-}
-
-/*
-Returns the set of QML files in path (qmldir, *.qml, *.js). The caller
-is responsible for deleting the returned data.
-Returns 0 if the directory does not exist.
-*/
-#if defined (Q_OS_UNIX) && !defined(Q_OS_DARWIN)
-static QStringHash<bool> *qmlFilesInDirectory(const QString &path)
-{
- QByteArray name(QFile::encodeName(path));
- DIR *dd = opendir(name);
- if (!dd)
- return 0;
-
- struct dirent *result;
- union {
- struct dirent d;
- char b[offsetof (struct dirent, d_name) + NAME_MAX + 1];
- } u;
-
- QStringHash<bool> *files = new QStringHash<bool>;
- while (readdir_r(dd, &u.d, &result) == 0 && result != 0) {
- if (!strcmp(u.d.d_name, "qmldir")) {
- files->insert(QLatin1String("qmldir"), true);
- continue;
- }
- int len = strlen(u.d.d_name);
- if (len < 4)
- continue;
- if (!strcmp(u.d.d_name+len-4, ".qml") || !strcmp(u.d.d_name+len-3, ".js"))
- files->insert(QFile::decodeName(u.d.d_name), true);
-#if defined(Q_OS_DARWIN)
- else if ((len > 6 && !strcmp(u.d.d_name+len-6, ".dylib")) || !strcmp(u.d.d_name+len-3, ".so")
- || (len > 7 && !strcmp(u.d.d_name+len-7, ".bundle")))
- files->insert(QFile::decodeName(u.d.d_name), true);
-#else // Unix
- else if (!strcmp(u.d.d_name+len-3, ".so") || !strcmp(u.d.d_name+len-3, ".sl"))
- files->insert(QFile::decodeName(u.d.d_name), true);
-#endif
- }
-
- closedir(dd);
- return files;
-}
-#else
-static QStringHash<bool> *qmlFilesInDirectory(const QString &path)
-{
- QDirIterator dir(path, QDir::Files);
- if (!dir.hasNext())
- return 0;
- QStringHash<bool> *files = new QStringHash<bool>;
- while (dir.hasNext()) {
- dir.next();
- QString fileName = dir.fileName();
- if (fileName == QLatin1String("qmldir")
- || fileName.endsWith(QLatin1String(".qml"))
- || fileName.endsWith(QLatin1String(".js"))
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- || fileName.endsWith(QLatin1String(".dll"))
-#elif defined(Q_OS_DARWIN)
- || fileName.endsWith(QLatin1String(".dylib"))
- || fileName.endsWith(QLatin1String(".so"))
- || fileName.endsWith(QLatin1String(".bundle"))
-#else // Unix
- || fileName.endsWith(QLatin1String(".so"))
- || fileName.endsWith(QLatin1String(".sl"))
-#endif
- ) {
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
- fileName = fileName.toLower();
-#endif
- files->insert(fileName, true);
- }
- }
- return files;
-}
-#endif
-
-
-/*!
-\class QDeclarativeDataBlob
-\brief The QDeclarativeDataBlob encapsulates a data request that can be issued to a QDeclarativeDataLoader.
-\internal
-
-QDeclarativeDataBlob's are loaded by a QDeclarativeDataLoader. The user creates the QDeclarativeDataBlob
-and then calls QDeclarativeDataLoader::load() or QDeclarativeDataLoader::loadWithStaticData() to load it.
-The QDeclarativeDataLoader invokes callbacks on the QDeclarativeDataBlob as data becomes available.
-*/
-
-/*!
-\enum QDeclarativeDataBlob::Status
-
-This enum describes the status of the data blob.
-
-\list
-\o Null The blob has not yet been loaded by a QDeclarativeDataLoader
-\o Loading The blob is loading network data. The QDeclarativeDataBlob::setData() callback has not yet been
-invoked or has not yet returned.
-\o WaitingForDependencies The blob is waiting for dependencies to be done before continueing. This status
-only occurs after the QDeclarativeDataBlob::setData() callback has been made, and when the blob has outstanding
-dependencies.
-\o Complete The blob's data has been loaded and all dependencies are done.
-\o Error An error has been set on this blob.
-\endlist
-*/
-
-/*!
-\enum QDeclarativeDataBlob::Type
-
-This enum describes the type of the data blob.
-
-\list
-\o QmlFile This is a QDeclarativeTypeData
-\o JavaScriptFile This is a QDeclarativeScriptData
-\o QmldirFile This is a QDeclarativeQmldirData
-\endlist
-*/
-
-/*!
-Create a new QDeclarativeDataBlob for \a url and of the provided \a type.
-*/
-QDeclarativeDataBlob::QDeclarativeDataBlob(const QUrl &url, Type type)
-: m_type(type), m_url(url), m_finalUrl(url), m_manager(0), m_redirectCount(0),
- m_inCallback(false), m_isDone(false)
-{
-}
-
-/*! \internal */
-QDeclarativeDataBlob::~QDeclarativeDataBlob()
-{
- Q_ASSERT(m_waitingOnMe.isEmpty());
-
- cancelAllWaitingFor();
-}
-
-/*!
-Returns the type provided to the constructor.
-*/
-QDeclarativeDataBlob::Type QDeclarativeDataBlob::type() const
-{
- return m_type;
-}
-
-/*!
-Returns the blob's status.
-*/
-QDeclarativeDataBlob::Status QDeclarativeDataBlob::status() const
-{
- return m_data.status();
-}
-
-/*!
-Returns true if the status is Null.
-*/
-bool QDeclarativeDataBlob::isNull() const
-{
- return status() == Null;
-}
-
-/*!
-Returns true if the status is Loading.
-*/
-bool QDeclarativeDataBlob::isLoading() const
-{
- return status() == Loading;
-}
-
-/*!
-Returns true if the status is WaitingForDependencies.
-*/
-bool QDeclarativeDataBlob::isWaiting() const
-{
- return status() == WaitingForDependencies;
-}
-
-/*!
-Returns true if the status is Complete.
-*/
-bool QDeclarativeDataBlob::isComplete() const
-{
- return status() == Complete;
-}
-
-/*!
-Returns true if the status is Error.
-*/
-bool QDeclarativeDataBlob::isError() const
-{
- return status() == Error;
-}
-
-/*!
-Returns true if the status is Complete or Error.
-*/
-bool QDeclarativeDataBlob::isCompleteOrError() const
-{
- Status s = status();
- return s == Error || s == Complete;
-}
-
-/*!
-Returns the data download progress from 0 to 1.
-*/
-qreal QDeclarativeDataBlob::progress() const
-{
- quint8 p = m_data.progress();
- if (p == 0xFF) return 1.;
- else return qreal(p) / qreal(0xFF);
-}
-
-/*!
-Returns the blob url passed to the constructor. If a network redirect
-happens while fetching the data, this url remains the same.
-
-\sa finalUrl()
-*/
-QUrl QDeclarativeDataBlob::url() const
-{
- return m_url;
-}
-
-/*!
-Returns the final url of the data. Initially this is the same as
-url(), but if a network redirect happens while fetching the data, this url
-is updated to reflect the new location.
-
-May only be called from the load thread, or after the blob isCompleteOrError().
-*/
-QUrl QDeclarativeDataBlob::finalUrl() const
-{
- Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread()));
- return m_finalUrl;
-}
-
-/*!
-Returns the finalUrl() as a string.
-*/
-QString QDeclarativeDataBlob::finalUrlString() const
-{
- Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread()));
- if (m_finalUrlString.isEmpty())
- m_finalUrlString = m_finalUrl.toString();
-
- return m_finalUrlString;
-}
-
-/*!
-Return the errors on this blob.
-
-May only be called from the load thread, or after the blob isCompleteOrError().
-*/
-QList<QDeclarativeError> QDeclarativeDataBlob::errors() const
-{
- Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread()));
- return m_errors;
-}
-
-/*!
-Mark this blob as having \a errors.
-
-All outstanding dependencies will be cancelled. Requests to add new dependencies
-will be ignored. Entry into the Error state is irreversable.
-
-The setError() method may only be called from within a QDeclarativeDataBlob callback.
-*/
-void QDeclarativeDataBlob::setError(const QDeclarativeError &errors)
-{
- ASSERT_CALLBACK();
-
- QList<QDeclarativeError> l;
- l << errors;
- setError(l);
-}
-
-/*!
-\overload
-*/
-void QDeclarativeDataBlob::setError(const QList<QDeclarativeError> &errors)
-{
- ASSERT_CALLBACK();
-
- Q_ASSERT(status() != Error);
- Q_ASSERT(m_errors.isEmpty());
-
- m_errors = errors; // Must be set before the m_data fence
- m_data.setStatus(Error);
-
- cancelAllWaitingFor();
-
- if (!m_inCallback)
- tryDone();
-}
-
-/*!
-Wait for \a blob to become complete or to error. If \a blob is already
-complete or in error, or this blob is already complete, this has no effect.
-
-The setError() method may only be called from within a QDeclarativeDataBlob callback.
-*/
-void QDeclarativeDataBlob::addDependency(QDeclarativeDataBlob *blob)
-{
- ASSERT_CALLBACK();
-
- Q_ASSERT(status() != Null);
-
- if (!blob ||
- blob->status() == Error || blob->status() == Complete ||
- status() == Error || status() == Complete || m_isDone ||
- m_waitingFor.contains(blob))
- return;
-
- blob->addref();
-
- m_data.setStatus(WaitingForDependencies);
-
- m_waitingFor.append(blob);
- blob->m_waitingOnMe.append(this);
-}
-
-/*!
-\fn void QDeclarativeDataBlob::dataReceived(const QByteArray &data)
-
-Invoked when data for the blob is received. Implementors should use this callback
-to determine a blob's dependencies. Within this callback you may call setError()
-or addDependency().
-*/
-
-/*!
-Invoked once data has either been received or a network error occurred, and all
-dependencies are complete.
-
-You can set an error in this method, but you cannot add new dependencies. Implementors
-should use this callback to finalize processing of data.
-
-The default implementation does nothing.
-
-XXX Rename processData() or some such to avoid confusion between done() (processing thread)
-and completed() (main thread)
-*/
-void QDeclarativeDataBlob::done()
-{
-}
-
-/*!
-Invoked if there is a network error while fetching this blob.
-
-The default implementation sets an appropriate QDeclarativeError.
-*/
-void QDeclarativeDataBlob::networkError(QNetworkReply::NetworkError networkError)
-{
- Q_UNUSED(networkError);
-
- QDeclarativeError error;
- error.setUrl(m_finalUrl);
-
- const char *errorString = 0;
- switch (networkError) {
- default:
- errorString = "Network error";
- break;
- case QNetworkReply::ConnectionRefusedError:
- errorString = "Connection refused";
- break;
- case QNetworkReply::RemoteHostClosedError:
- errorString = "Remote host closed the connection";
- break;
- case QNetworkReply::HostNotFoundError:
- errorString = "Host not found";
- break;
- case QNetworkReply::TimeoutError:
- errorString = "Timeout";
- break;
- case QNetworkReply::ProxyConnectionRefusedError:
- case QNetworkReply::ProxyConnectionClosedError:
- case QNetworkReply::ProxyNotFoundError:
- case QNetworkReply::ProxyTimeoutError:
- case QNetworkReply::ProxyAuthenticationRequiredError:
- case QNetworkReply::UnknownProxyError:
- errorString = "Proxy error";
- break;
- case QNetworkReply::ContentAccessDenied:
- errorString = "Access denied";
- break;
- case QNetworkReply::ContentNotFoundError:
- errorString = "File not found";
- break;
- case QNetworkReply::AuthenticationRequiredError:
- errorString = "Authentication required";
- break;
- };
-
- error.setDescription(QLatin1String(errorString));
-
- setError(error);
-}
-
-/*!
-Called if \a blob, which was previously waited for, has an error.
-
-The default implementation does nothing.
-*/
-void QDeclarativeDataBlob::dependencyError(QDeclarativeDataBlob *blob)
-{
- Q_UNUSED(blob);
-}
-
-/*!
-Called if \a blob, which was previously waited for, has completed.
-
-The default implementation does nothing.
-*/
-void QDeclarativeDataBlob::dependencyComplete(QDeclarativeDataBlob *blob)
-{
- Q_UNUSED(blob);
-}
-
-/*!
-Called when all blobs waited for have completed. This occurs regardless of
-whether they are in error, or complete state.
-
-The default implementation does nothing.
-*/
-void QDeclarativeDataBlob::allDependenciesDone()
-{
-}
-
-/*!
-Called when the download progress of this blob changes. \a progress goes
-from 0 to 1.
-
-This callback is only invoked if an asynchronous load for this blob is
-made. An asynchronous load is one in which the Asynchronous mode is
-specified explicitly, or one that is implicitly delayed due to a network
-operation.
-
-The default implementation does nothing.
-*/
-void QDeclarativeDataBlob::downloadProgressChanged(qreal progress)
-{
- Q_UNUSED(progress);
-}
-
-/*!
-Invoked on the main thread sometime after done() was called on the load thread.
-
-You cannot modify the blobs state at all in this callback and cannot depend on the
-order or timeliness of these callbacks. Implementors should use this callback to notify
-dependencies on the main thread that the blob is done and not a lot else.
-
-This callback is only invoked if an asynchronous load for this blob is
-made. An asynchronous load is one in which the Asynchronous mode is
-specified explicitly, or one that is implicitly delayed due to a network
-operation.
-
-The default implementation does nothing.
-*/
-void QDeclarativeDataBlob::completed()
-{
-}
-
-
-void QDeclarativeDataBlob::tryDone()
-{
- if (status() != Loading && m_waitingFor.isEmpty() && !m_isDone) {
- m_isDone = true;
- addref();
-
-#ifdef DATABLOB_DEBUG
- qWarning("QDeclarativeDataBlob::done() %s", qPrintable(url().toString()));
-#endif
- done();
-
- if (status() != Error)
- m_data.setStatus(Complete);
-
- notifyAllWaitingOnMe();
-
- // Locking is not required here, as anyone expecting callbacks must
- // already be protected against the blob being completed (as set above);
- if (m_data.isAsync()) {
-#ifdef DATABLOB_DEBUG
- qWarning("QDeclarativeDataBlob: Dispatching completed");
-#endif
- m_manager->m_thread->callCompleted(this);
- }
-
- release();
- }
-}
-
-void QDeclarativeDataBlob::cancelAllWaitingFor()
-{
- while (m_waitingFor.count()) {
- QDeclarativeDataBlob *blob = m_waitingFor.takeLast();
-
- Q_ASSERT(blob->m_waitingOnMe.contains(this));
-
- blob->m_waitingOnMe.removeOne(this);
-
- blob->release();
- }
-}
-
-void QDeclarativeDataBlob::notifyAllWaitingOnMe()
-{
- while (m_waitingOnMe.count()) {
- QDeclarativeDataBlob *blob = m_waitingOnMe.takeLast();
-
- Q_ASSERT(blob->m_waitingFor.contains(this));
-
- blob->notifyComplete(this);
- }
-}
-
-void QDeclarativeDataBlob::notifyComplete(QDeclarativeDataBlob *blob)
-{
- Q_ASSERT(m_waitingFor.contains(blob));
- Q_ASSERT(blob->status() == Error || blob->status() == Complete);
-
- m_inCallback = true;
-
- if (blob->status() == Error) {
- dependencyError(blob);
- } else if (blob->status() == Complete) {
- dependencyComplete(blob);
- }
-
- m_waitingFor.removeOne(blob);
- blob->release();
-
- if (!isError() && m_waitingFor.isEmpty())
- allDependenciesDone();
-
- m_inCallback = false;
-
- tryDone();
-}
-
-#define TD_STATUS_MASK 0x0000FFFF
-#define TD_STATUS_SHIFT 0
-#define TD_PROGRESS_MASK 0x00FF0000
-#define TD_PROGRESS_SHIFT 16
-#define TD_ASYNC_MASK 0x80000000
-
-QDeclarativeDataBlob::ThreadData::ThreadData()
-: _p(0)
-{
-}
-
-QDeclarativeDataBlob::Status QDeclarativeDataBlob::ThreadData::status() const
-{
- return QDeclarativeDataBlob::Status((_p.load() & TD_STATUS_MASK) >> TD_STATUS_SHIFT);
-}
-
-void QDeclarativeDataBlob::ThreadData::setStatus(QDeclarativeDataBlob::Status status)
-{
- while (true) {
- int d = _p.load();
- int nd = (d & ~TD_STATUS_MASK) | ((status << TD_STATUS_SHIFT) & TD_STATUS_MASK);
- if (d == nd || _p.testAndSetOrdered(d, nd)) return;
- }
-}
-
-bool QDeclarativeDataBlob::ThreadData::isAsync() const
-{
- return _p.load() & TD_ASYNC_MASK;
-}
-
-void QDeclarativeDataBlob::ThreadData::setIsAsync(bool v)
-{
- while (true) {
- int d = _p.load();
- int nd = (d & ~TD_ASYNC_MASK) | (v?TD_ASYNC_MASK:0);
- if (d == nd || _p.testAndSetOrdered(d, nd)) return;
- }
-}
-
-quint8 QDeclarativeDataBlob::ThreadData::progress() const
-{
- return quint8((_p.load() & TD_PROGRESS_MASK) >> TD_PROGRESS_SHIFT);
-}
-
-void QDeclarativeDataBlob::ThreadData::setProgress(quint8 v)
-{
- while (true) {
- int d = _p.load();
- int nd = (d & ~TD_PROGRESS_MASK) | ((v << TD_PROGRESS_SHIFT) & TD_PROGRESS_MASK);
- if (d == nd || _p.testAndSetOrdered(d, nd)) return;
- }
-}
-
-QDeclarativeDataLoaderThread::QDeclarativeDataLoaderThread(QDeclarativeDataLoader *loader)
-: m_loader(loader), m_networkAccessManager(0), m_networkReplyProxy(0)
-{
-}
-
-QNetworkAccessManager *QDeclarativeDataLoaderThread::networkAccessManager() const
-{
- Q_ASSERT(isThisThread());
- if (!m_networkAccessManager) {
- m_networkAccessManager = QDeclarativeEnginePrivate::get(m_loader->engine())->createNetworkAccessManager(0);
- m_networkReplyProxy = new QDeclarativeDataLoaderNetworkReplyProxy(m_loader);
- }
-
- return m_networkAccessManager;
-}
-
-QDeclarativeDataLoaderNetworkReplyProxy *QDeclarativeDataLoaderThread::networkReplyProxy() const
-{
- Q_ASSERT(isThisThread());
- Q_ASSERT(m_networkReplyProxy); // Must call networkAccessManager() first
- return m_networkReplyProxy;
-}
-
-void QDeclarativeDataLoaderThread::load(QDeclarativeDataBlob *b)
-{
- b->addref();
- callMethodInThread(&This::loadThread, b);
-}
-
-void QDeclarativeDataLoaderThread::loadAsync(QDeclarativeDataBlob *b)
-{
- b->addref();
- postMethodToThread(&This::loadThread, b);
-}
-
-void QDeclarativeDataLoaderThread::loadWithStaticData(QDeclarativeDataBlob *b, const QByteArray &d)
-{
- b->addref();
- callMethodInThread(&This::loadWithStaticDataThread, b, d);
-}
-
-void QDeclarativeDataLoaderThread::loadWithStaticDataAsync(QDeclarativeDataBlob *b, const QByteArray &d)
-{
- b->addref();
- postMethodToThread(&This::loadWithStaticDataThread, b, d);
-}
-
-void QDeclarativeDataLoaderThread::callCompleted(QDeclarativeDataBlob *b)
-{
- b->addref();
- postMethodToMain(&This::callCompletedMain, b);
-}
-
-void QDeclarativeDataLoaderThread::callDownloadProgressChanged(QDeclarativeDataBlob *b, qreal p)
-{
- b->addref();
- postMethodToMain(&This::callDownloadProgressChangedMain, b, p);
-}
-
-void QDeclarativeDataLoaderThread::initializeEngine(QDeclarativeExtensionInterface *iface,
- const char *uri)
-{
- callMethodInMain(&This::initializeEngineMain, iface, uri);
-}
-
-void QDeclarativeDataLoaderThread::shutdownThread()
-{
- delete m_networkAccessManager;
- m_networkAccessManager = 0;
- delete m_networkReplyProxy;
- m_networkReplyProxy = 0;
-}
-
-void QDeclarativeDataLoaderThread::loadThread(QDeclarativeDataBlob *b)
-{
- m_loader->loadThread(b);
- b->release();
-}
-
-void QDeclarativeDataLoaderThread::loadWithStaticDataThread(QDeclarativeDataBlob *b, const QByteArray &d)
-{
- m_loader->loadWithStaticDataThread(b, d);
- b->release();
-}
-
-void QDeclarativeDataLoaderThread::callCompletedMain(QDeclarativeDataBlob *b)
-{
-#ifdef DATABLOB_DEBUG
- qWarning("QDeclarativeDataLoaderThread: %s completed() callback", qPrintable(b->url().toString()));
-#endif
- b->completed();
- b->release();
-}
-
-void QDeclarativeDataLoaderThread::callDownloadProgressChangedMain(QDeclarativeDataBlob *b, qreal p)
-{
-#ifdef DATABLOB_DEBUG
- qWarning("QDeclarativeDataLoaderThread: %s downloadProgressChanged(%f) callback",
- qPrintable(b->url().toString()), p);
-#endif
- b->downloadProgressChanged(p);
- b->release();
-}
-
-void QDeclarativeDataLoaderThread::initializeEngineMain(QDeclarativeExtensionInterface *iface,
- const char *uri)
-{
- Q_ASSERT(m_loader->engine()->thread() == QThread::currentThread());
- iface->initializeEngine(m_loader->engine(), uri);
-}
-
-/*!
-\class QDeclarativeDataLoader
-\brief The QDeclarativeDataLoader class abstracts loading files and their dependencies over the network.
-\internal
-
-The QDeclarativeDataLoader class is provided for the exclusive use of the QDeclarativeTypeLoader class.
-
-Clients create QDeclarativeDataBlob instances and submit them to the QDeclarativeDataLoader class
-through the QDeclarativeDataLoader::load() or QDeclarativeDataLoader::loadWithStaticData() methods.
-The loader then fetches the data over the network or from the local file system in an efficient way.
-QDeclarativeDataBlob is an abstract class, so should always be specialized.
-
-Once data is received, the QDeclarativeDataBlob::dataReceived() method is invoked on the blob. The
-derived class should use this callback to process the received data. Processing of the data can
-result in an error being set (QDeclarativeDataBlob::setError()), or one or more dependencies being
-created (QDeclarativeDataBlob::addDependency()). Dependencies are other QDeclarativeDataBlob's that
-are required before processing can fully complete.
-
-To complete processing, the QDeclarativeDataBlob::done() callback is invoked. done() is called when
-one of these three preconditions are met.
-
-\list 1
-\o The QDeclarativeDataBlob has no dependencies.
-\o The QDeclarativeDataBlob has an error set.
-\o All the QDeclarativeDataBlob's dependencies are themselves "done()".
-\endlist
-
-Thus QDeclarativeDataBlob::done() will always eventually be called, even if the blob has an error set.
-*/
-
-/*!
-Create a new QDeclarativeDataLoader for \a engine.
-*/
-QDeclarativeDataLoader::QDeclarativeDataLoader(QDeclarativeEngine *engine)
-: m_engine(engine), m_thread(new QDeclarativeDataLoaderThread(this))
-{
-}
-
-/*! \internal */
-QDeclarativeDataLoader::~QDeclarativeDataLoader()
-{
- for (NetworkReplies::Iterator iter = m_networkReplies.begin(); iter != m_networkReplies.end(); ++iter)
- (*iter)->release();
-
- m_thread->shutdown();
- delete m_thread;
-}
-
-void QDeclarativeDataLoader::lock()
-{
- m_thread->lock();
-}
-
-void QDeclarativeDataLoader::unlock()
-{
- m_thread->unlock();
-}
-
-/*!
-Load the provided \a blob from the network or filesystem.
-
-The loader must be locked.
-*/
-void QDeclarativeDataLoader::load(QDeclarativeDataBlob *blob, Mode mode)
-{
-#ifdef DATABLOB_DEBUG
- qWarning("QDeclarativeDataLoader::load(%s): %s thread", qPrintable(blob->m_url.toString()),
- m_thread->isThisThread()?"Compile":"Engine");
-#endif
-
- Q_ASSERT(blob->status() == QDeclarativeDataBlob::Null);
- Q_ASSERT(blob->m_manager == 0);
-
- blob->m_data.setStatus(QDeclarativeDataBlob::Loading);
- blob->m_manager = this;
-
- if (m_thread->isThisThread()) {
- unlock();
- loadThread(blob);
- lock();
- } else if (mode == PreferSynchronous) {
- unlock();
- m_thread->load(blob);
- lock();
- if (!blob->isCompleteOrError())
- blob->m_data.setIsAsync(true);
- } else {
- Q_ASSERT(mode == Asynchronous);
- blob->m_data.setIsAsync(true);
- unlock();
- m_thread->loadAsync(blob);
- lock();
- }
-}
-
-/*!
-Load the provided \a blob with \a data. The blob's URL is not used by the data loader in this case.
-
-The loader must be locked.
-*/
-void QDeclarativeDataLoader::loadWithStaticData(QDeclarativeDataBlob *blob, const QByteArray &data, Mode mode)
-{
-#ifdef DATABLOB_DEBUG
- qWarning("QDeclarativeDataLoader::loadWithStaticData(%s, data): %s thread", qPrintable(blob->m_url.toString()),
- m_thread->isThisThread()?"Compile":"Engine");
-#endif
-
- Q_ASSERT(blob->status() == QDeclarativeDataBlob::Null);
- Q_ASSERT(blob->m_manager == 0);
-
- blob->m_data.setStatus(QDeclarativeDataBlob::Loading);
- blob->m_manager = this;
-
- if (m_thread->isThisThread()) {
- unlock();
- loadWithStaticDataThread(blob, data);
- lock();
- } else if (mode == PreferSynchronous) {
- unlock();
- m_thread->loadWithStaticData(blob, data);
- lock();
- if (!blob->isCompleteOrError())
- blob->m_data.setIsAsync(true);
- } else {
- Q_ASSERT(mode == Asynchronous);
- blob->m_data.setIsAsync(true);
- unlock();
- m_thread->loadWithStaticDataAsync(blob, data);
- lock();
- }
-}
-
-void QDeclarativeDataLoader::loadWithStaticDataThread(QDeclarativeDataBlob *blob, const QByteArray &data)
-{
- ASSERT_LOADTHREAD();
-
- setData(blob, data);
-}
-
-void QDeclarativeDataLoader::loadThread(QDeclarativeDataBlob *blob)
-{
- ASSERT_LOADTHREAD();
-
- if (blob->m_url.isEmpty()) {
- QDeclarativeError error;
- error.setDescription(QLatin1String("Invalid null URL"));
- blob->setError(error);
- return;
- }
-
- QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(blob->m_url);
-
- if (!lf.isEmpty()) {
- if (!QDeclarative_isFileCaseCorrect(lf)) {
- QDeclarativeError error;
- error.setUrl(blob->m_url);
- error.setDescription(QLatin1String("File name case mismatch"));
- blob->setError(error);
- return;
- }
- QFile file(lf);
- if (file.open(QFile::ReadOnly)) {
- QByteArray data = file.readAll();
-
- blob->m_data.setProgress(0xFF);
- if (blob->m_data.isAsync())
- m_thread->callDownloadProgressChanged(blob, 1.);
-
- setData(blob, data);
- } else {
- blob->networkError(QNetworkReply::ContentNotFoundError);
- }
-
- } else {
-
- QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(blob->m_url));
- QObject *nrp = m_thread->networkReplyProxy();
- QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
- nrp, SLOT(downloadProgress(qint64,qint64)));
- QObject::connect(reply, SIGNAL(finished()),
- nrp, SLOT(finished()));
- m_networkReplies.insert(reply, blob);
-
- blob->addref();
- }
-}
-
-#define DATALOADER_MAXIMUM_REDIRECT_RECURSION 16
-
-void QDeclarativeDataLoader::networkReplyFinished(QNetworkReply *reply)
-{
- Q_ASSERT(m_thread->isThisThread());
-
- reply->deleteLater();
-
- QDeclarativeDataBlob *blob = m_networkReplies.take(reply);
-
- Q_ASSERT(blob);
-
- blob->m_redirectCount++;
-
- if (blob->m_redirectCount < DATALOADER_MAXIMUM_REDIRECT_RECURSION) {
- QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- QUrl url = reply->url().resolved(redirect.toUrl());
- blob->m_finalUrl = url;
-
- QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(url));
- QObject *nrp = m_thread->networkReplyProxy();
- QObject::connect(reply, SIGNAL(finished()), nrp, SLOT(finished()));
- m_networkReplies.insert(reply, blob);
- return;
- }
- }
-
- if (reply->error()) {
- blob->networkError(reply->error());
- } else {
- QByteArray data = reply->readAll();
- setData(blob, data);
- }
-
- blob->release();
-}
-
-void QDeclarativeDataLoader::networkReplyProgress(QNetworkReply *reply,
- qint64 bytesReceived, qint64 bytesTotal)
-{
- Q_ASSERT(m_thread->isThisThread());
-
- QDeclarativeDataBlob *blob = m_networkReplies.value(reply);
-
- Q_ASSERT(blob);
-
- if (bytesTotal != 0) {
- quint8 progress = 0xFF * (qreal(bytesReceived) / qreal(bytesTotal));
- blob->m_data.setProgress(progress);
- if (blob->m_data.isAsync())
- m_thread->callDownloadProgressChanged(blob, blob->m_data.progress());
- }
-}
-
-/*!
-Return the QDeclarativeEngine associated with this loader
-*/
-QDeclarativeEngine *QDeclarativeDataLoader::engine() const
-{
- return m_engine;
-}
-
-/*!
-Call the initializeEngine() method on \a iface. Used by QDeclarativeImportDatabase to ensure it
-gets called in the correct thread.
-*/
-void QDeclarativeDataLoader::initializeEngine(QDeclarativeExtensionInterface *iface,
- const char *uri)
-{
- Q_ASSERT(m_thread->isThisThread() || engine()->thread() == QThread::currentThread());
-
- if (m_thread->isThisThread()) {
- m_thread->initializeEngine(iface, uri);
- } else {
- Q_ASSERT(engine()->thread() == QThread::currentThread());
- iface->initializeEngine(engine(), uri);
- }
-}
-
-
-void QDeclarativeDataLoader::setData(QDeclarativeDataBlob *blob, const QByteArray &data)
-{
- blob->m_inCallback = true;
-
- blob->dataReceived(data);
-
- if (!blob->isError() && !blob->isWaiting())
- blob->allDependenciesDone();
-
- if (blob->status() != QDeclarativeDataBlob::Error)
- blob->m_data.setStatus(QDeclarativeDataBlob::WaitingForDependencies);
-
- blob->m_inCallback = false;
-
- blob->tryDone();
-}
-
-/*!
-Constructs a new type loader that uses the given \a engine.
-*/
-QDeclarativeTypeLoader::QDeclarativeTypeLoader(QDeclarativeEngine *engine)
-: QDeclarativeDataLoader(engine)
-{
-}
-
-/*!
-Destroys the type loader, first clearing the cache of any information about
-loaded files.
-*/
-QDeclarativeTypeLoader::~QDeclarativeTypeLoader()
-{
- clearCache();
-}
-
-/*!
-\enum QDeclarativeTypeLoader::Option
-
-This enum defines the options that control the way type data is handled.
-
-\value None The default value, indicating that no other options
- are enabled.
-\value PreserveParser The parser used to handle the type data is preserved
- after the data has been parsed.
-*/
-
-/*!
-Returns a QDeclarativeTypeData for the specified \a url. The QDeclarativeTypeData may be cached.
-*/
-QDeclarativeTypeData *QDeclarativeTypeLoader::get(const QUrl &url)
-{
- Q_ASSERT(!url.isRelative() &&
- (QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url).isEmpty() ||
- !QDir::isRelativePath(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url))));
-
- lock();
-
- QDeclarativeTypeData *typeData = m_typeCache.value(url);
-
- if (!typeData) {
- typeData = new QDeclarativeTypeData(url, None, this);
- m_typeCache.insert(url, typeData);
- QDeclarativeDataLoader::load(typeData);
- }
-
- typeData->addref();
-
- unlock();
-
- return typeData;
-}
-
-/*!
-Returns a QDeclarativeTypeData for the given \a data with the provided base \a url. The
-QDeclarativeTypeData will not be cached.
-
-The specified \a options control how the loader handles type data.
-*/
-QDeclarativeTypeData *QDeclarativeTypeLoader::get(const QByteArray &data, const QUrl &url, Options options)
-{
- lock();
-
- QDeclarativeTypeData *typeData = new QDeclarativeTypeData(url, options, this);
- QDeclarativeDataLoader::loadWithStaticData(typeData, data);
-
- unlock();
-
- return typeData;
-}
-
-/*!
-Return a QDeclarativeScriptBlob for \a url. The QDeclarativeScriptData may be cached.
-*/
-QDeclarativeScriptBlob *QDeclarativeTypeLoader::getScript(const QUrl &url)
-{
- Q_ASSERT(!url.isRelative() &&
- (QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url).isEmpty() ||
- !QDir::isRelativePath(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url))));
-
- lock();
-
- QDeclarativeScriptBlob *scriptBlob = m_scriptCache.value(url);
-
- if (!scriptBlob) {
- scriptBlob = new QDeclarativeScriptBlob(url, this);
- m_scriptCache.insert(url, scriptBlob);
- QDeclarativeDataLoader::load(scriptBlob);
- }
-
- scriptBlob->addref();
-
- unlock();
-
- return scriptBlob;
-}
-
-/*!
-Returns a QDeclarativeQmldirData for \a url. The QDeclarativeQmldirData may be cached.
-*/
-QDeclarativeQmldirData *QDeclarativeTypeLoader::getQmldir(const QUrl &url)
-{
- Q_ASSERT(!url.isRelative() &&
- (QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url).isEmpty() ||
- !QDir::isRelativePath(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url))));
-
- lock();
-
- QDeclarativeQmldirData *qmldirData = m_qmldirCache.value(url);
-
- if (!qmldirData) {
- qmldirData = new QDeclarativeQmldirData(url);
- m_qmldirCache.insert(url, qmldirData);
- QDeclarativeDataLoader::load(qmldirData);
- }
-
- qmldirData->addref();
-
- unlock();
-
- return qmldirData;
-}
-
-/*!
-Returns the absolute filename of path via a directory cache for files named
-"qmldir", "*.qml", "*.js", and plugins.
-Returns a empty string if the path does not exist.
-*/
-QString QDeclarativeTypeLoader::absoluteFilePath(const QString &path)
-{
- if (path.isEmpty())
- return QString();
- if (path.at(0) == QLatin1Char(':')) {
- // qrc resource
- QFileInfo fileInfo(path);
- return fileInfo.isFile() ? fileInfo.absoluteFilePath() : QString();
- }
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
- QString lowPath = path.toLower();
- int lastSlash = lowPath.lastIndexOf(QLatin1Char('/'));
- QString dirPath = lowPath.left(lastSlash);
-#else
- int lastSlash = path.lastIndexOf(QLatin1Char('/'));
- QStringRef dirPath(&path, 0, lastSlash);
-#endif
-
- StringSet **fileSet = m_importDirCache.value(QHashedStringRef(dirPath.constData(), dirPath.length()));
- if (!fileSet) {
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
- QHashedString dirPathString(dirPath);
-#else
- QHashedString dirPathString(dirPath.toString());
-#endif
- StringSet *files = qmlFilesInDirectory(dirPathString);
- m_importDirCache.insert(dirPathString, files);
- fileSet = m_importDirCache.value(dirPathString);
- }
- if (!(*fileSet))
- return QString();
-
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
- QString absoluteFilePath = (*fileSet)->contains(QHashedStringRef(lowPath.constData()+lastSlash+1, lowPath.length()-lastSlash-1)) ? path : QString();
-#else
- QString absoluteFilePath = (*fileSet)->contains(QHashedStringRef(path.constData()+lastSlash+1, path.length()-lastSlash-1)) ? path : QString();
-#endif
- if (absoluteFilePath.length() > 2 && absoluteFilePath.at(0) != QLatin1Char('/') && absoluteFilePath.at(1) != QLatin1Char(':'))
- absoluteFilePath = QFileInfo(absoluteFilePath).absoluteFilePath();
-
- return absoluteFilePath;
-}
-
-/*!
-Returns true if the path is a directory via a directory cache. Cache is
-shared with absoluteFilePath().
-*/
-bool QDeclarativeTypeLoader::directoryExists(const QString &path)
-{
- if (path.isEmpty())
- return false;
- if (path.at(0) == QLatin1Char(':')) {
- // qrc resource
- QFileInfo fileInfo(path);
- return fileInfo.exists() && fileInfo.isDir();
- }
-
- int length = path.length();
- if (path.endsWith(QLatin1Char('/')))
- --length;
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
- QString dirPath = path.left(length).toLower();
-#else
- QStringRef dirPath(&path, 0, length);
-#endif
-
- StringSet **fileSet = m_importDirCache.value(QHashedStringRef(dirPath.constData(), dirPath.length()));
- if (!fileSet) {
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
- QHashedString dirPathString(dirPath);
-#else
- QHashedString dirPathString(dirPath.toString());
-#endif
- StringSet *files = qmlFilesInDirectory(dirPathString);
- m_importDirCache.insert(dirPathString, files);
- fileSet = m_importDirCache.value(dirPathString);
- }
-
- return (*fileSet);
-}
-
-
-/*!
-Return a QDeclarativeDirParser for absoluteFilePath. The QDeclarativeDirParser may be cached.
-*/
-const QDeclarativeDirParser *QDeclarativeTypeLoader::qmlDirParser(const QString &absoluteFilePath)
-{
- QDeclarativeDirParser *qmldirParser;
- QDeclarativeDirParser **val = m_importQmlDirCache.value(absoluteFilePath);
- if (!val) {
- qmldirParser = new QDeclarativeDirParser;
- qmldirParser->setFileSource(absoluteFilePath);
- qmldirParser->setUrl(QUrl::fromLocalFile(absoluteFilePath));
- qmldirParser->parse();
- m_importQmlDirCache.insert(absoluteFilePath, qmldirParser);
- } else {
- qmldirParser = *val;
- }
-
- return qmldirParser;
-}
-
-
-/*!
-Clears cached information about loaded files, including any type data, scripts
-and qmldir information.
-*/
-void QDeclarativeTypeLoader::clearCache()
-{
- for (TypeCache::Iterator iter = m_typeCache.begin(); iter != m_typeCache.end(); ++iter)
- (*iter)->release();
- for (ScriptCache::Iterator iter = m_scriptCache.begin(); iter != m_scriptCache.end(); ++iter)
- (*iter)->release();
- for (QmldirCache::Iterator iter = m_qmldirCache.begin(); iter != m_qmldirCache.end(); ++iter)
- (*iter)->release();
- qDeleteAll(m_importDirCache);
- qDeleteAll(m_importQmlDirCache);
-
- m_typeCache.clear();
- m_scriptCache.clear();
- m_qmldirCache.clear();
- m_importDirCache.clear();
- m_importQmlDirCache.clear();
-}
-
-
-QDeclarativeTypeData::QDeclarativeTypeData(const QUrl &url, QDeclarativeTypeLoader::Options options,
- QDeclarativeTypeLoader *manager)
-: QDeclarativeDataBlob(url, QmlFile), m_options(options), m_imports(manager), m_typesResolved(false),
- m_compiledData(0), m_typeLoader(manager)
-{
-}
-
-QDeclarativeTypeData::~QDeclarativeTypeData()
-{
- for (int ii = 0; ii < m_scripts.count(); ++ii)
- m_scripts.at(ii).script->release();
- for (int ii = 0; ii < m_qmldirs.count(); ++ii)
- m_qmldirs.at(ii)->release();
- for (int ii = 0; ii < m_types.count(); ++ii)
- if (m_types.at(ii).typeData) m_types.at(ii).typeData->release();
- if (m_compiledData)
- m_compiledData->release();
-}
-
-QDeclarativeTypeLoader *QDeclarativeTypeData::typeLoader() const
-{
- return m_typeLoader;
-}
-
-const QDeclarativeImports &QDeclarativeTypeData::imports() const
-{
- return m_imports;
-}
-
-const QDeclarativeScript::Parser &QDeclarativeTypeData::parser() const
-{
- return scriptParser;
-}
-
-const QList<QDeclarativeTypeData::TypeReference> &QDeclarativeTypeData::resolvedTypes() const
-{
- return m_types;
-}
-
-const QList<QDeclarativeTypeData::ScriptReference> &QDeclarativeTypeData::resolvedScripts() const
-{
- return m_scripts;
-}
-
-const QSet<QString> &QDeclarativeTypeData::namespaces() const
-{
- return m_namespaces;
-}
-
-QDeclarativeCompiledData *QDeclarativeTypeData::compiledData() const
-{
- if (m_compiledData)
- m_compiledData->addref();
-
- return m_compiledData;
-}
-
-void QDeclarativeTypeData::registerCallback(TypeDataCallback *callback)
-{
- Q_ASSERT(!m_callbacks.contains(callback));
- m_callbacks.append(callback);
-}
-
-void QDeclarativeTypeData::unregisterCallback(TypeDataCallback *callback)
-{
- Q_ASSERT(m_callbacks.contains(callback));
- m_callbacks.removeOne(callback);
- Q_ASSERT(!m_callbacks.contains(callback));
-}
-
-void QDeclarativeTypeData::done()
-{
- // Check all script dependencies for errors
- for (int ii = 0; !isError() && ii < m_scripts.count(); ++ii) {
- const ScriptReference &script = m_scripts.at(ii);
- Q_ASSERT(script.script->isCompleteOrError());
- if (script.script->isError()) {
- QList<QDeclarativeError> errors = script.script->errors();
- QDeclarativeError error;
- error.setUrl(finalUrl());
- error.setLine(script.location.line);
- error.setColumn(script.location.column);
- error.setDescription(QDeclarativeTypeLoader::tr("Script %1 unavailable").arg(script.script->url().toString()));
- errors.prepend(error);
- setError(errors);
- }
- }
-
- // Check all type dependencies for errors
- for (int ii = 0; !isError() && ii < m_types.count(); ++ii) {
- const TypeReference &type = m_types.at(ii);
- Q_ASSERT(!type.typeData || type.typeData->isCompleteOrError());
- if (type.typeData && type.typeData->isError()) {
- QString typeName = scriptParser.referencedTypes().at(ii)->name;
-
- QList<QDeclarativeError> errors = type.typeData->errors();
- QDeclarativeError error;
- error.setUrl(finalUrl());
- error.setLine(type.location.line);
- error.setColumn(type.location.column);
- error.setDescription(QDeclarativeTypeLoader::tr("Type %1 unavailable").arg(typeName));
- errors.prepend(error);
- setError(errors);
- }
- }
-
- // Compile component
- if (!isError())
- compile();
-
- if (!(m_options & QDeclarativeTypeLoader::PreserveParser))
- scriptParser.clear();
-}
-
-void QDeclarativeTypeData::completed()
-{
- // Notify callbacks
- while (!m_callbacks.isEmpty()) {
- TypeDataCallback *callback = m_callbacks.takeFirst();
- callback->typeDataReady(this);
- }
-}
-
-void QDeclarativeTypeData::dataReceived(const QByteArray &data)
-{
- if (!scriptParser.parse(data, finalUrl(), finalUrlString())) {
- setError(scriptParser.errors());
- return;
- }
-
- m_imports.setBaseUrl(finalUrl(), finalUrlString());
-
- foreach (const QDeclarativeScript::Import &import, scriptParser.imports()) {
- if (import.type == QDeclarativeScript::Import::File && import.qualifier.isEmpty()) {
- QUrl importUrl = finalUrl().resolved(QUrl(import.uri + QLatin1String("/qmldir")));
- if (QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty()) {
- QDeclarativeQmldirData *data = typeLoader()->getQmldir(importUrl);
- addDependency(data);
- m_qmldirs << data;
- }
- } else if (import.type == QDeclarativeScript::Import::Script) {
- QUrl scriptUrl = finalUrl().resolved(QUrl(import.uri));
- QDeclarativeScriptBlob *blob = typeLoader()->getScript(scriptUrl);
- addDependency(blob);
-
- ScriptReference ref;
- ref.location = import.location.start;
- ref.qualifier = import.qualifier;
- ref.script = blob;
- m_scripts << ref;
-
- }
- }
-
- if (!finalUrl().scheme().isEmpty()) {
- QUrl importUrl = finalUrl().resolved(QUrl(QLatin1String("qmldir")));
- if (QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty()) {
- QDeclarativeQmldirData *data = typeLoader()->getQmldir(importUrl);
- addDependency(data);
- m_qmldirs << data;
- }
- }
-}
-
-void QDeclarativeTypeData::allDependenciesDone()
-{
- if (!m_typesResolved) {
- resolveTypes();
- m_typesResolved = true;
- }
-}
-
-void QDeclarativeTypeData::downloadProgressChanged(qreal p)
-{
- for (int ii = 0; ii < m_callbacks.count(); ++ii) {
- TypeDataCallback *callback = m_callbacks.at(ii);
- callback->typeDataProgress(this, p);
- }
-}
-
-void QDeclarativeTypeData::compile()
-{
- Q_ASSERT(m_compiledData == 0);
-
- m_compiledData = new QDeclarativeCompiledData(typeLoader()->engine());
- m_compiledData->url = finalUrl();
- m_compiledData->name = finalUrlString();
-
- QDeclarativeCompilingProfiler prof(m_compiledData->name);
-
- QDeclarativeCompiler compiler(&scriptParser._pool);
- if (!compiler.compile(typeLoader()->engine(), this, m_compiledData)) {
- setError(compiler.errors());
- m_compiledData->release();
- m_compiledData = 0;
- }
-}
-
-void QDeclarativeTypeData::resolveTypes()
-{
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(m_typeLoader->engine());
- QDeclarativeImportDatabase *importDatabase = &ep->importDatabase;
-
- // For local urls, add an implicit import "." as first (most overridden) lookup.
- // This will also trigger the loading of the qmldir and the import of any native
- // types from available plugins.
- QList<QDeclarativeError> errors;
- if (QDeclarativeQmldirData *qmldir = qmldirForUrl(finalUrl().resolved(QUrl(QLatin1String("./qmldir"))))) {
- m_imports.addImport(importDatabase, QLatin1String("."),
- QString(), -1, -1, QDeclarativeScript::Import::File,
- qmldir->dirComponents(), &errors);
- } else {
- m_imports.addImport(importDatabase, QLatin1String("."),
- QString(), -1, -1, QDeclarativeScript::Import::File,
- QDeclarativeDirComponents(), &errors);
- }
-
- // remove any errors which are due to the implicit import which aren't real errors.
- // for example, if the implicitly included qmldir file doesn't exist, that is not an error.
- QList<QDeclarativeError> realErrors;
- for (int i = 0; i < errors.size(); ++i) {
- if (errors.at(i).description() != QDeclarativeImportDatabase::tr("import \".\" has no qmldir and no namespace")
- && errors.at(i).description() != QDeclarativeImportDatabase::tr("\".\": no such directory")) {
- realErrors.prepend(errors.at(i)); // this is a real error.
- }
- }
-
- // report any real errors which occurred during plugin loading or qmldir parsing.
- if (!realErrors.isEmpty()) {
- setError(realErrors);
- return;
- }
-
- foreach (const QDeclarativeScript::Import &import, scriptParser.imports()) {
- QDeclarativeDirComponents qmldircomponentsnetwork;
- if (import.type == QDeclarativeScript::Import::Script)
- continue;
-
- if (import.type == QDeclarativeScript::Import::File && import.qualifier.isEmpty()) {
- QUrl qmldirUrl = finalUrl().resolved(QUrl(import.uri + QLatin1String("/qmldir")));
- if (QDeclarativeQmldirData *qmldir = qmldirForUrl(qmldirUrl))
- qmldircomponentsnetwork = qmldir->dirComponents();
- }
-
- int vmaj = -1;
- int vmin = -1;
- import.extractVersion(&vmaj, &vmin);
-
- QList<QDeclarativeError> errors;
- if (!m_imports.addImport(importDatabase, import.uri, import.qualifier,
- vmaj, vmin, import.type, qmldircomponentsnetwork, &errors)) {
- QDeclarativeError error;
- if (errors.size()) {
- error = errors.takeFirst();
- } else {
- // this should not be possible!
- // Description should come from error provided by addImport() function.
- error.setDescription(QDeclarativeTypeLoader::tr("Unreported error adding script import to import database"));
- }
- error.setUrl(m_imports.baseUrl());
- error.setLine(import.location.start.line);
- error.setColumn(import.location.start.column);
- errors.prepend(error); // put it back on the list after filling out information.
-
- setError(errors);
- return;
- }
- }
-
- // Add any imported scripts to our resolved set
- foreach (const QDeclarativeImports::ScriptReference &script, m_imports.resolvedScripts())
- {
- QDeclarativeScriptBlob *blob = typeLoader()->getScript(script.location);
- addDependency(blob);
-
- ScriptReference ref;
- //ref.location = ...
- ref.qualifier = script.nameSpace;
- if (!script.qualifier.isEmpty())
- {
- ref.qualifier.prepend(script.qualifier + QLatin1Char('.'));
-
- // Add a reference to the enclosing namespace
- m_namespaces.insert(script.qualifier);
- }
-
- ref.script = blob;
- m_scripts << ref;
- }
-
- foreach (QDeclarativeScript::TypeReference *parserRef, scriptParser.referencedTypes()) {
- TypeReference ref;
-
- QString url;
- int majorVersion;
- int minorVersion;
- QDeclarativeImportedNamespace *typeNamespace = 0;
- QList<QDeclarativeError> errors;
-
- if (!m_imports.resolveType(parserRef->name, &ref.type, &url, &majorVersion, &minorVersion,
- &typeNamespace, &errors) || typeNamespace) {
- // Known to not be a type:
- // - known to be a namespace (Namespace {})
- // - type with unknown namespace (UnknownNamespace.SomeType {})
- QDeclarativeError error;
- QString userTypeName = parserRef->name;
- userTypeName.replace(QLatin1Char('/'),QLatin1Char('.'));
- if (typeNamespace) {
- error.setDescription(QDeclarativeTypeLoader::tr("Namespace %1 cannot be used as a type").arg(userTypeName));
- } else {
- if (errors.size()) {
- error = errors.takeFirst();
- } else {
- // this should not be possible!
- // Description should come from error provided by addImport() function.
- error.setDescription(QDeclarativeTypeLoader::tr("Unreported error adding script import to import database"));
- }
- error.setUrl(m_imports.baseUrl());
- error.setDescription(QDeclarativeTypeLoader::tr("%1 %2").arg(userTypeName).arg(error.description()));
- }
-
- if (!parserRef->refObjects.isEmpty()) {
- QDeclarativeScript::Object *obj = parserRef->refObjects.first();
- error.setLine(obj->location.start.line);
- error.setColumn(obj->location.start.column);
- }
-
- errors.prepend(error);
- setError(errors);
- return;
- }
-
- if (ref.type) {
- ref.majorVersion = majorVersion;
- ref.minorVersion = minorVersion;
- } else {
- ref.typeData = typeLoader()->get(QUrl(url));
- addDependency(ref.typeData);
- }
-
- if (parserRef->refObjects.count())
- ref.location = parserRef->refObjects.first()->location.start;
-
- m_types << ref;
- }
-}
-
-QDeclarativeQmldirData *QDeclarativeTypeData::qmldirForUrl(const QUrl &url)
-{
- for (int ii = 0; ii < m_qmldirs.count(); ++ii) {
- if (m_qmldirs.at(ii)->url() == url)
- return m_qmldirs.at(ii);
- }
- return 0;
-}
-
-QDeclarativeScriptData::QDeclarativeScriptData()
-: importCache(0), pragmas(QDeclarativeScript::Object::ScriptBlock::None), m_loaded(false)
-{
-}
-
-QDeclarativeScriptData::~QDeclarativeScriptData()
-{
-}
-
-void QDeclarativeScriptData::clear()
-{
- if (importCache) {
- importCache->release();
- importCache = 0;
- }
-
- for (int ii = 0; ii < scripts.count(); ++ii)
- scripts.at(ii)->release();
- scripts.clear();
-
- qPersistentDispose(m_program);
- qPersistentDispose(m_value);
-
- // An addref() was made when the QDeclarativeCleanup was added to the engine.
- release();
-}
-
-QDeclarativeScriptBlob::QDeclarativeScriptBlob(const QUrl &url, QDeclarativeTypeLoader *loader)
-: QDeclarativeDataBlob(url, JavaScriptFile), m_pragmas(QDeclarativeScript::Object::ScriptBlock::None),
- m_imports(loader), m_scriptData(0), m_typeLoader(loader)
-{
-}
-
-QDeclarativeScriptBlob::~QDeclarativeScriptBlob()
-{
- if (m_scriptData) {
- m_scriptData->release();
- m_scriptData = 0;
- }
-}
-
-QDeclarativeScript::Object::ScriptBlock::Pragmas QDeclarativeScriptBlob::pragmas() const
-{
- return m_pragmas;
-}
-
-QDeclarativeTypeLoader *QDeclarativeScriptBlob::typeLoader() const
-{
- return m_typeLoader;
-}
-
-const QDeclarativeImports &QDeclarativeScriptBlob::imports() const
-{
- return m_imports;
-}
-
-QDeclarativeScriptData *QDeclarativeScriptBlob::scriptData() const
-{
- return m_scriptData;
-}
-
-void QDeclarativeScriptBlob::dataReceived(const QByteArray &data)
-{
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(m_typeLoader->engine());
- QDeclarativeImportDatabase *importDatabase = &ep->importDatabase;
-
- m_source = QString::fromUtf8(data);
-
- QDeclarativeScript::Parser::JavaScriptMetaData metadata =
- QDeclarativeScript::Parser::extractMetaData(m_source);
-
- m_imports.setBaseUrl(finalUrl(), finalUrlString());
-
- m_pragmas = metadata.pragmas;
-
- foreach (const QDeclarativeScript::Import &import, metadata.imports) {
- Q_ASSERT(import.type != QDeclarativeScript::Import::File);
-
- if (import.type == QDeclarativeScript::Import::Script) {
- QUrl scriptUrl = finalUrl().resolved(QUrl(import.uri));
- QDeclarativeScriptBlob *blob = typeLoader()->getScript(scriptUrl);
- addDependency(blob);
-
- ScriptReference ref;
- ref.location = import.location.start;
- ref.qualifier = import.qualifier;
- ref.script = blob;
- m_scripts << ref;
- } else {
- Q_ASSERT(import.type == QDeclarativeScript::Import::Library);
- int vmaj = -1;
- int vmin = -1;
- import.extractVersion(&vmaj, &vmin);
-
- QList<QDeclarativeError> errors;
- if (!m_imports.addImport(importDatabase, import.uri, import.qualifier, vmaj, vmin,
- import.type, QDeclarativeDirComponents(), &errors)) {
- QDeclarativeError error = errors.takeFirst();
- // description should be set by addImport().
- error.setUrl(m_imports.baseUrl());
- error.setLine(import.location.start.line);
- error.setColumn(import.location.start.column);
- errors.prepend(error);
-
- setError(errors);
- return;
- }
- }
- }
-}
-
-void QDeclarativeScriptBlob::done()
-{
- // Check all script dependencies for errors
- for (int ii = 0; !isError() && ii < m_scripts.count(); ++ii) {
- const ScriptReference &script = m_scripts.at(ii);
- Q_ASSERT(script.script->isCompleteOrError());
- if (script.script->isError()) {
- QList<QDeclarativeError> errors = script.script->errors();
- QDeclarativeError error;
- error.setUrl(finalUrl());
- error.setLine(script.location.line);
- error.setColumn(script.location.column);
- error.setDescription(typeLoader()->tr("Script %1 unavailable").arg(script.script->url().toString()));
- errors.prepend(error);
- setError(errors);
- }
- }
-
- if (isError())
- return;
-
- QDeclarativeEngine *engine = typeLoader()->engine();
- m_scriptData = new QDeclarativeScriptData();
- m_scriptData->url = finalUrl();
- m_scriptData->urlString = finalUrlString();
- m_scriptData->importCache = new QDeclarativeTypeNameCache();
-
- for (int ii = 0; !isError() && ii < m_scripts.count(); ++ii) {
- const ScriptReference &script = m_scripts.at(ii);
-
- m_scriptData->scripts.append(script.script);
- m_scriptData->importCache->add(script.qualifier, ii);
- }
-
- m_imports.populateCache(m_scriptData->importCache, engine);
-
- m_scriptData->pragmas = m_pragmas;
- m_scriptData->m_programSource = m_source.toUtf8();
- m_source.clear();
-}
-
-QDeclarativeQmldirData::QDeclarativeQmldirData(const QUrl &url)
-: QDeclarativeDataBlob(url, QmldirFile)
-{
-}
-
-const QDeclarativeDirComponents &QDeclarativeQmldirData::dirComponents() const
-{
- return m_components;
-}
-
-void QDeclarativeQmldirData::dataReceived(const QByteArray &data)
-{
- QDeclarativeDirParser parser;
- parser.setSource(QString::fromUtf8(data));
- parser.parse();
- m_components = parser.components();
-}
-
-QT_END_NAMESPACE
-
-#include "qdeclarativetypeloader.moc"
diff --git a/src/declarative/qml/qdeclarativetypeloader_p.h b/src/declarative/qml/qdeclarativetypeloader_p.h
deleted file mode 100644
index 7b35fea916..0000000000
--- a/src/declarative/qml/qdeclarativetypeloader_p.h
+++ /dev/null
@@ -1,435 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETYPELOADER_P_H
-#define QDECLARATIVETYPELOADER_P_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/qobject.h>
-#include <QtCore/qatomic.h>
-#include <QtNetwork/qnetworkreply.h>
-#include <QtDeclarative/qdeclarativeerror.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <private/qv8_p.h>
-#include <private/qhashedstring_p.h>
-#include <private/qdeclarativescript_p.h>
-#include <private/qdeclarativeimport_p.h>
-#include <private/qdeclarativecleanup_p.h>
-#include <private/qdeclarativedirparser_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeScriptData;
-class QDeclarativeScriptBlob;
-class QDeclarativeQmldirData;
-class QDeclarativeTypeLoader;
-class QDeclarativeCompiledData;
-class QDeclarativeComponentPrivate;
-class QDeclarativeTypeData;
-class QDeclarativeDataLoader;
-class QDeclarativeExtensionInterface;
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDataBlob : public QDeclarativeRefCount
-{
-public:
- enum Status {
- Null, // Prior to QDeclarativeDataLoader::load()
- Loading, // Prior to data being received and dataReceived() being called
- WaitingForDependencies, // While there are outstanding addDependency()s
- Complete, // Finished
- Error // Error
- };
-
- enum Type {
- QmlFile,
- JavaScriptFile,
- QmldirFile
- };
-
- QDeclarativeDataBlob(const QUrl &, Type);
- virtual ~QDeclarativeDataBlob();
-
- Type type() const;
-
- Status status() const;
- bool isNull() const;
- bool isLoading() const;
- bool isWaiting() const;
- bool isComplete() const;
- bool isError() const;
- bool isCompleteOrError() const;
-
- qreal progress() const;
-
- QUrl url() const;
- QUrl finalUrl() const;
- QString finalUrlString() const;
-
- QList<QDeclarativeError> errors() const;
-
-protected:
- // Can be called from within callbacks
- void setError(const QDeclarativeError &);
- void setError(const QList<QDeclarativeError> &errors);
- void addDependency(QDeclarativeDataBlob *);
-
- // Callbacks made in load thread
- virtual void dataReceived(const QByteArray &) = 0;
- virtual void done();
- virtual void networkError(QNetworkReply::NetworkError);
- virtual void dependencyError(QDeclarativeDataBlob *);
- virtual void dependencyComplete(QDeclarativeDataBlob *);
- virtual void allDependenciesDone();
-
- // Callbacks made in main thread
- virtual void downloadProgressChanged(qreal);
- virtual void completed();
-private:
- friend class QDeclarativeDataLoader;
- friend class QDeclarativeDataLoaderThread;
-
- void tryDone();
- void cancelAllWaitingFor();
- void notifyAllWaitingOnMe();
- void notifyComplete(QDeclarativeDataBlob *);
-
- struct ThreadData {
- inline ThreadData();
- inline QDeclarativeDataBlob::Status status() const;
- inline void setStatus(QDeclarativeDataBlob::Status);
- inline bool isAsync() const;
- inline void setIsAsync(bool);
- inline quint8 progress() const;
- inline void setProgress(quint8);
-
- private:
- QAtomicInt _p;
- };
- ThreadData m_data;
-
- // m_errors should *always* be written before the status is set to Error.
- // We use the status change as a memory fence around m_errors so that locking
- // isn't required. Once the status is set to Error (or Complete), m_errors
- // cannot be changed.
- QList<QDeclarativeError> m_errors;
-
- Type m_type;
-
- QUrl m_url;
- QUrl m_finalUrl;
- mutable QString m_finalUrlString;
-
- // List of QDeclarativeDataBlob's that are waiting for me to complete.
- QList<QDeclarativeDataBlob *> m_waitingOnMe;
-
- // List of QDeclarativeDataBlob's that I am waiting for to complete.
- QList<QDeclarativeDataBlob *> m_waitingFor;
-
- // Manager that is currently fetching data for me
- QDeclarativeDataLoader *m_manager;
- int m_redirectCount:30;
- bool m_inCallback:1;
- bool m_isDone:1;
-};
-
-class QDeclarativeDataLoaderThread;
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDataLoader
-{
-public:
- QDeclarativeDataLoader(QDeclarativeEngine *);
- ~QDeclarativeDataLoader();
-
- void lock();
- void unlock();
-
- bool isConcurrent() const { return true; }
-
- enum Mode { PreferSynchronous, Asynchronous };
-
- void load(QDeclarativeDataBlob *, Mode = PreferSynchronous);
- void loadWithStaticData(QDeclarativeDataBlob *, const QByteArray &, Mode = PreferSynchronous);
-
- QDeclarativeEngine *engine() const;
- void initializeEngine(QDeclarativeExtensionInterface *, const char *);
-
-private:
- friend class QDeclarativeDataBlob;
- friend class QDeclarativeDataLoaderThread;
- friend class QDeclarativeDataLoaderNetworkReplyProxy;
-
- void loadThread(QDeclarativeDataBlob *);
- void loadWithStaticDataThread(QDeclarativeDataBlob *, const QByteArray &);
- void networkReplyFinished(QNetworkReply *);
- void networkReplyProgress(QNetworkReply *, qint64, qint64);
-
- typedef QHash<QNetworkReply *, QDeclarativeDataBlob *> NetworkReplies;
-
- void setData(QDeclarativeDataBlob *, const QByteArray &);
-
- QDeclarativeEngine *m_engine;
- QDeclarativeDataLoaderThread *m_thread;
- NetworkReplies m_networkReplies;
-};
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeTypeLoader : public QDeclarativeDataLoader
-{
- Q_DECLARE_TR_FUNCTIONS(QDeclarativeTypeLoader)
-public:
- QDeclarativeTypeLoader(QDeclarativeEngine *);
- ~QDeclarativeTypeLoader();
-
- enum Option {
- None,
- PreserveParser
- };
- Q_DECLARE_FLAGS(Options, Option)
-
- QDeclarativeTypeData *get(const QUrl &url);
- QDeclarativeTypeData *get(const QByteArray &, const QUrl &url, Options = None);
- void clearCache();
-
- QDeclarativeScriptBlob *getScript(const QUrl &);
- QDeclarativeQmldirData *getQmldir(const QUrl &);
-
- QString absoluteFilePath(const QString &path);
- bool directoryExists(const QString &path);
- const QDeclarativeDirParser *qmlDirParser(const QString &absoluteFilePath);
-private:
- typedef QHash<QUrl, QDeclarativeTypeData *> TypeCache;
- typedef QHash<QUrl, QDeclarativeScriptBlob *> ScriptCache;
- typedef QHash<QUrl, QDeclarativeQmldirData *> QmldirCache;
- typedef QStringHash<bool> StringSet;
- typedef QStringHash<StringSet*> ImportDirCache;
- typedef QStringHash<QDeclarativeDirParser*> ImportQmlDirCache;
-
- TypeCache m_typeCache;
- ScriptCache m_scriptCache;
- QmldirCache m_qmldirCache;
- ImportDirCache m_importDirCache;
- ImportQmlDirCache m_importQmlDirCache;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeTypeLoader::Options)
-
-class Q_AUTOTEST_EXPORT QDeclarativeTypeData : public QDeclarativeDataBlob
-{
-public:
- struct TypeReference
- {
- TypeReference() : type(0), majorVersion(0), minorVersion(0), typeData(0) {}
-
- QDeclarativeScript::Location location;
- QDeclarativeType *type;
- int majorVersion;
- int minorVersion;
- QDeclarativeTypeData *typeData;
- };
-
- struct ScriptReference
- {
- ScriptReference() : script(0) {}
-
- QDeclarativeScript::Location location;
- QString qualifier;
- QDeclarativeScriptBlob *script;
- };
-
- QDeclarativeTypeData(const QUrl &, QDeclarativeTypeLoader::Options, QDeclarativeTypeLoader *);
- ~QDeclarativeTypeData();
-
- QDeclarativeTypeLoader *typeLoader() const;
-
- const QDeclarativeImports &imports() const;
- const QDeclarativeScript::Parser &parser() const;
-
- const QList<TypeReference> &resolvedTypes() const;
- const QList<ScriptReference> &resolvedScripts() const;
- const QSet<QString> &namespaces() const;
-
- QDeclarativeCompiledData *compiledData() const;
-
- // Used by QDeclarativeComponent to get notifications
- struct TypeDataCallback {
- ~TypeDataCallback() {}
- virtual void typeDataProgress(QDeclarativeTypeData *, qreal) {}
- virtual void typeDataReady(QDeclarativeTypeData *) {}
- };
- void registerCallback(TypeDataCallback *);
- void unregisterCallback(TypeDataCallback *);
-
-protected:
- virtual void done();
- virtual void completed();
- virtual void dataReceived(const QByteArray &);
- virtual void allDependenciesDone();
- virtual void downloadProgressChanged(qreal);
-
-private:
- void resolveTypes();
- void compile();
-
- QDeclarativeTypeLoader::Options m_options;
-
- QDeclarativeQmldirData *qmldirForUrl(const QUrl &);
-
- QDeclarativeScript::Parser scriptParser;
- QDeclarativeImports m_imports;
-
- QList<ScriptReference> m_scripts;
- QList<QDeclarativeQmldirData *> m_qmldirs;
-
- QSet<QString> m_namespaces;
-
- QList<TypeReference> m_types;
- bool m_typesResolved:1;
-
- QDeclarativeCompiledData *m_compiledData;
-
- QList<TypeDataCallback *> m_callbacks;
-
- QDeclarativeTypeLoader *m_typeLoader;
-};
-
-// QDeclarativeScriptData instances are created, uninitialized, by the loader in the
-// load thread. The first time they are used by the VME, they are initialized which
-// creates their v8 objects and they are referenced and added to the engine's cleanup
-// list. During QDeclarativeCleanup::clear() all v8 resources are destroyed, and the
-// reference that was created is released but final deletion only occurs once all the
-// references as released. This is all intended to ensure that the v8 resources are
-// only created and destroyed in the main thread :)
-class Q_AUTOTEST_EXPORT QDeclarativeScriptData : public QDeclarativeCleanup,
- public QDeclarativeRefCount
-{
-public:
- QDeclarativeScriptData();
- ~QDeclarativeScriptData();
-
- QUrl url;
- QString urlString;
- QDeclarativeTypeNameCache *importCache;
- QList<QDeclarativeScriptBlob *> scripts;
- QDeclarativeScript::Object::ScriptBlock::Pragmas pragmas;
-
- bool isInitialized() const { return hasEngine(); }
- void initialize(QDeclarativeEngine *);
-
-protected:
- virtual void clear(); // From QDeclarativeCleanup
-
-private:
- friend class QDeclarativeVME;
- friend class QDeclarativeScriptBlob;
-
- bool m_loaded;
- QByteArray m_programSource;
- v8::Persistent<v8::Script> m_program;
- v8::Persistent<v8::Object> m_value;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeScriptBlob : public QDeclarativeDataBlob
-{
-public:
- QDeclarativeScriptBlob(const QUrl &, QDeclarativeTypeLoader *);
- ~QDeclarativeScriptBlob();
-
- struct ScriptReference
- {
- ScriptReference() : script(0) {}
-
- QDeclarativeScript::Location location;
- QString qualifier;
- QDeclarativeScriptBlob *script;
- };
-
- QDeclarativeScript::Object::ScriptBlock::Pragmas pragmas() const;
-
- QDeclarativeTypeLoader *typeLoader() const;
- const QDeclarativeImports &imports() const;
-
- QDeclarativeScriptData *scriptData() const;
-
-protected:
- virtual void dataReceived(const QByteArray &);
- virtual void done();
-
-private:
- QDeclarativeScript::Object::ScriptBlock::Pragmas m_pragmas;
- QString m_source;
-
- QDeclarativeImports m_imports;
- QList<ScriptReference> m_scripts;
- QDeclarativeScriptData *m_scriptData;
-
- QDeclarativeTypeLoader *m_typeLoader;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeQmldirData : public QDeclarativeDataBlob
-{
-public:
- QDeclarativeQmldirData(const QUrl &);
-
- const QDeclarativeDirComponents &dirComponents() const;
-
-protected:
- virtual void dataReceived(const QByteArray &);
-
-private:
- QDeclarativeDirComponents m_components;
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVETYPELOADER_P_H
diff --git a/src/declarative/qml/qdeclarativetypenamecache.cpp b/src/declarative/qml/qdeclarativetypenamecache.cpp
deleted file mode 100644
index 9d433d4472..0000000000
--- a/src/declarative/qml/qdeclarativetypenamecache.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetypenamecache_p.h"
-
-#include "qdeclarativeengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeTypeNameCache::QDeclarativeTypeNameCache()
-{
-}
-
-QDeclarativeTypeNameCache::~QDeclarativeTypeNameCache()
-{
-}
-
-void QDeclarativeTypeNameCache::add(const QHashedString &name, int importedScriptIndex, const QHashedString &nameSpace)
-{
- Import import;
- import.scriptIndex = importedScriptIndex;
-
- if (nameSpace.length() != 0) {
- Import *i = m_namedImports.value(nameSpace);
- Q_ASSERT(i != 0);
- m_namespacedImports[i].insert(name, import);
- return;
- }
-
- if (m_namedImports.contains(name))
- return;
-
- m_namedImports.insert(name, import);
-}
-
-QDeclarativeTypeNameCache::Result QDeclarativeTypeNameCache::query(const QHashedStringRef &name)
-{
- Result result = query(m_namedImports, name);
-
- if (!result.isValid())
- result = typeSearch(m_anonymousImports, name);
-
- return result;
-}
-
-QDeclarativeTypeNameCache::Result QDeclarativeTypeNameCache::query(const QHashedStringRef &name,
- const void *importNamespace)
-{
- Q_ASSERT(importNamespace);
- const Import *i = static_cast<const Import *>(importNamespace);
- Q_ASSERT(i->scriptIndex == -1);
-
- return typeSearch(i->modules, name);
-}
-
-QDeclarativeTypeNameCache::Result QDeclarativeTypeNameCache::query(const QHashedV8String &name)
-{
- Result result = query(m_namedImports, name);
-
- if (!result.isValid())
- result = typeSearch(m_anonymousImports, name);
-
- return result;
-}
-
-QDeclarativeTypeNameCache::Result QDeclarativeTypeNameCache::query(const QHashedV8String &name, const void *importNamespace)
-{
- Q_ASSERT(importNamespace);
- const Import *i = static_cast<const Import *>(importNamespace);
- Q_ASSERT(i->scriptIndex == -1);
-
- QMap<const Import *, QStringHash<Import> >::const_iterator it = m_namespacedImports.find(i);
- if (it != m_namespacedImports.constEnd())
- return query(*it, name);
-
- return typeSearch(i->modules, name);
-}
-
-QDeclarativeMetaType::ModuleApiInstance *QDeclarativeTypeNameCache::moduleApi(const void *importNamespace)
-{
- Q_ASSERT(importNamespace);
- const Import *i = static_cast<const Import *>(importNamespace);
- Q_ASSERT(i->scriptIndex == -1);
-
- return i->moduleApi;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qdeclarativetypenamecache_p.h b/src/declarative/qml/qdeclarativetypenamecache_p.h
deleted file mode 100644
index 9cf52f9d72..0000000000
--- a/src/declarative/qml/qdeclarativetypenamecache_p.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETYPENAMECACHE_P_H
-#define QDECLARATIVETYPENAMECACHE_P_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 <private/qdeclarativerefcount_p.h>
-#include "qdeclarativecleanup_p.h"
-#include "qdeclarativemetatype_p.h"
-
-#include <private/qhashedstring_p.h>
-
-#include <QtCore/qvector.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeType;
-class QDeclarativeEngine;
-class QDeclarativeTypeNameCache : public QDeclarativeRefCount
-{
-public:
- QDeclarativeTypeNameCache();
- virtual ~QDeclarativeTypeNameCache();
-
- inline bool isEmpty() const;
-
- void add(const QHashedString &name, int sciptIndex = -1, const QHashedString &nameSpace = QHashedString());
-
- struct Result {
- inline Result();
- inline Result(const void *importNamespace);
- inline Result(QDeclarativeType *type);
- inline Result(int scriptIndex);
- inline Result(const Result &);
-
- inline bool isValid() const;
-
- QDeclarativeType *type;
- const void *importNamespace;
- int scriptIndex;
- };
- Result query(const QHashedStringRef &);
- Result query(const QHashedStringRef &, const void *importNamespace);
- Result query(const QHashedV8String &);
- Result query(const QHashedV8String &, const void *importNamespace);
- QDeclarativeMetaType::ModuleApiInstance *moduleApi(const void *importNamespace);
-
-private:
- friend class QDeclarativeImports;
-
- struct Import {
- inline Import();
- // Imported module
- QDeclarativeMetaType::ModuleApiInstance *moduleApi;
- QVector<QDeclarativeTypeModuleVersion> modules;
-
- // Or, imported script
- int scriptIndex;
- };
-
- template<typename Key>
- Result query(const QStringHash<Import> &imports, Key key)
- {
- Import *i = imports.value(key);
- if (i) {
- if (i->scriptIndex != -1) {
- return Result(i->scriptIndex);
- } else {
- return Result(static_cast<const void *>(i));
- }
- }
-
- return Result();
- }
-
- template<typename Key>
- Result typeSearch(const QVector<QDeclarativeTypeModuleVersion> &modules, Key key)
- {
- QVector<QDeclarativeTypeModuleVersion>::const_iterator end = modules.constEnd();
- for (QVector<QDeclarativeTypeModuleVersion>::const_iterator it = modules.constBegin(); it != end; ++it) {
- if (QDeclarativeType *type = it->type(key))
- return Result(type);
- }
-
- return Result();
- }
-
- QStringHash<Import> m_namedImports;
- QMap<const Import *, QStringHash<Import> > m_namespacedImports;
- QVector<QDeclarativeTypeModuleVersion> m_anonymousImports;
-
- QDeclarativeEngine *engine;
-};
-
-QDeclarativeTypeNameCache::Result::Result()
-: type(0), importNamespace(0), scriptIndex(-1)
-{
-}
-
-QDeclarativeTypeNameCache::Result::Result(const void *importNamespace)
-: type(0), importNamespace(importNamespace), scriptIndex(-1)
-{
-}
-
-QDeclarativeTypeNameCache::Result::Result(QDeclarativeType *type)
-: type(type), importNamespace(0), scriptIndex(-1)
-{
-}
-
-QDeclarativeTypeNameCache::Result::Result(int scriptIndex)
-: type(0), importNamespace(0), scriptIndex(scriptIndex)
-{
-}
-
-QDeclarativeTypeNameCache::Result::Result(const Result &o)
-: type(o.type), importNamespace(o.importNamespace), scriptIndex(o.scriptIndex)
-{
-}
-
-bool QDeclarativeTypeNameCache::Result::isValid() const
-{
- return type || importNamespace || scriptIndex != -1;
-}
-
-QDeclarativeTypeNameCache::Import::Import()
-: moduleApi(0), scriptIndex(-1)
-{
-}
-
-bool QDeclarativeTypeNameCache::isEmpty() const
-{
- return m_namedImports.isEmpty() && m_anonymousImports.isEmpty();
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVETYPENAMECACHE_P_H
-
diff --git a/src/declarative/qml/qdeclarativetypenotavailable.cpp b/src/declarative/qml/qdeclarativetypenotavailable.cpp
deleted file mode 100644
index ed24b4e8be..0000000000
--- a/src/declarative/qml/qdeclarativetypenotavailable.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetypenotavailable_p.h"
-
-QT_BEGIN_NAMESPACE
-
-int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
-{
- return qmlRegisterUncreatableType<QDeclarativeTypeNotAvailable>(uri,versionMajor,versionMinor,qmlName,message);
-}
-
-QDeclarativeTypeNotAvailable::QDeclarativeTypeNotAvailable() { }
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativetypenotavailable_p.h b/src/declarative/qml/qdeclarativetypenotavailable_p.h
deleted file mode 100644
index 05ed6fd5ff..0000000000
--- a/src/declarative/qml/qdeclarativetypenotavailable_p.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETYPENOTAVAILABLE_H
-#define QDECLARATIVETYPENOTAVAILABLE_H
-
-#include <qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeTypeNotAvailable : public QObject {
- Q_OBJECT
-public:
- QDeclarativeTypeNotAvailable();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeTypeNotAvailable)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVETYPENOTAVAILABLE_H
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
deleted file mode 100644
index 6dd3a84dc9..0000000000
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ /dev/null
@@ -1,868 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativevaluetype_p.h"
-
-#include "qdeclarativemetatype_p.h"
-#include <private/qfont_p.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-template<typename T>
-int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
-{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
-
- QDeclarativePrivate::RegisterType type = {
- 0,
-
- qRegisterMetaType<T *>(pointerName.constData()), 0, 0, 0,
-
- QString(),
-
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
-
- 0, 0,
-
- 0, 0, 0,
-
- 0, 0,
-
- 0,
- 0
- };
-
- return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
-}
-
-QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
-{
- // ### Optimize
- for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
- valueTypes[ii] = valueType(ii);
-}
-
-QDeclarativeValueTypeFactory::~QDeclarativeValueTypeFactory()
-{
- for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
- delete valueTypes[ii];
-}
-
-bool QDeclarativeValueTypeFactory::isValueType(int idx)
-{
- if ((uint)idx < QVariant::UserType
- && idx != QVariant::StringList
- && idx != QMetaType::QObjectStar
- && idx != QMetaType::QWidgetStar
- && idx != QMetaType::VoidStar
- && idx != QMetaType::QVariant) {
- return true;
- }
- return false;
-}
-
-void QDeclarativeValueTypeFactory::registerBaseTypes(const char *uri, int versionMajor, int versionMinor)
-{
- qmlRegisterValueTypeEnums<QDeclarativeEasingValueType>(uri, versionMajor, versionMinor, "Easing");
- qmlRegisterValueTypeEnums<QDeclarativeFontValueType>(uri, versionMajor, versionMinor, "Font");
-}
-
-void QDeclarativeValueTypeFactory::registerValueTypes()
-{
- registerBaseTypes("QtQuick", 2, 0);
-}
-
-QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
-{
- QDeclarativeValueType *rv = 0;
-
- switch (t) {
- case QVariant::Point:
- rv = new QDeclarativePointValueType;
- break;
- case QVariant::PointF:
- rv = new QDeclarativePointFValueType;
- break;
- case QVariant::Size:
- rv = new QDeclarativeSizeValueType;
- break;
- case QVariant::SizeF:
- rv = new QDeclarativeSizeFValueType;
- break;
- case QVariant::Rect:
- rv = new QDeclarativeRectValueType;
- break;
- case QVariant::RectF:
- rv = new QDeclarativeRectFValueType;
- break;
- case QVariant::Vector2D:
- rv = new QDeclarativeVector2DValueType;
- break;
- case QVariant::Vector3D:
- rv = new QDeclarativeVector3DValueType;
- break;
- case QVariant::Vector4D:
- rv = new QDeclarativeVector4DValueType;
- break;
- case QVariant::Quaternion:
- rv = new QDeclarativeQuaternionValueType;
- break;
- case QVariant::Matrix4x4:
- rv = new QDeclarativeMatrix4x4ValueType;
- break;
- case QVariant::EasingCurve:
- rv = new QDeclarativeEasingValueType;
- break;
- case QVariant::Font:
- rv = new QDeclarativeFontValueType;
- break;
- case QVariant::Color:
- rv = new QDeclarativeColorValueType;
- break;
- default:
- break;
- }
-
- Q_ASSERT(!rv || rv->metaObject()->propertyCount() < 32);
- return rv;
-}
-
-QDeclarativeValueType::QDeclarativeValueType(QObject *parent)
-: QObject(parent)
-{
-}
-
-#define QML_VALUETYPE_READWRITE(name, cpptype, var) \
- QDeclarative ## name ## ValueType::QDeclarative ## name ## ValueType(QObject *parent) \
- : QDeclarativeValueType(parent) \
- { \
- } \
- void QDeclarative ## name ## ValueType::read(QObject *obj, int idx) \
- { \
- void *a[] = { &var, 0 }; \
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); \
- onLoad(); \
- } \
- void QDeclarative ## name ## ValueType::write(QObject *obj, int idx, \
- QDeclarativePropertyPrivate::WriteFlags flags) \
- { \
- int status = -1; \
- void *a[] = { &var, 0, &status, &flags }; \
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); \
- } \
- bool QDeclarative ## name ## ValueType::isEqual(const QVariant &value) const \
- { \
- return QVariant(var) == value; \
- } \
- QVariant QDeclarative ## name ## ValueType::value() \
- { \
- return QVariant(var); \
- } \
- void QDeclarative ## name ## ValueType::setValue(const QVariant &value) \
- { \
- var = qvariant_cast<cpptype>(value); \
- onLoad(); \
- }
-
-QML_VALUETYPE_READWRITE(PointF, QPointF, point);
-QML_VALUETYPE_READWRITE(Point, QPoint, point);
-QML_VALUETYPE_READWRITE(SizeF, QSizeF, size);
-QML_VALUETYPE_READWRITE(Size, QSize, size);
-QML_VALUETYPE_READWRITE(RectF, QRectF, rect);
-QML_VALUETYPE_READWRITE(Rect, QRect, rect);
-QML_VALUETYPE_READWRITE(Vector2D, QVector2D, vector);
-QML_VALUETYPE_READWRITE(Vector3D, QVector3D, vector);
-QML_VALUETYPE_READWRITE(Vector4D, QVector4D, vector);
-QML_VALUETYPE_READWRITE(Quaternion, QQuaternion, quaternion);
-QML_VALUETYPE_READWRITE(Matrix4x4, QMatrix4x4, matrix);
-QML_VALUETYPE_READWRITE(Easing, QEasingCurve, easing);
-QML_VALUETYPE_READWRITE(Font, QFont, font);
-QML_VALUETYPE_READWRITE(Color, QColor, color);
-
-QString QDeclarativePointFValueType::toString() const
-{
- return QString(QLatin1String("QPointF(%1, %2)")).arg(point.x()).arg(point.y());
-}
-
-qreal QDeclarativePointFValueType::x() const
-{
- return point.x();
-}
-
-qreal QDeclarativePointFValueType::y() const
-{
- return point.y();
-}
-
-void QDeclarativePointFValueType::setX(qreal x)
-{
- point.setX(x);
-}
-
-void QDeclarativePointFValueType::setY(qreal y)
-{
- point.setY(y);
-}
-
-QString QDeclarativePointValueType::toString() const
-{
- return QString(QLatin1String("QPoint(%1, %2)")).arg(point.x()).arg(point.y());
-}
-
-int QDeclarativePointValueType::x() const
-{
- return point.x();
-}
-
-int QDeclarativePointValueType::y() const
-{
- return point.y();
-}
-
-void QDeclarativePointValueType::setX(int x)
-{
- point.setX(x);
-}
-
-void QDeclarativePointValueType::setY(int y)
-{
- point.setY(y);
-}
-
-QString QDeclarativeSizeFValueType::toString() const
-{
- return QString(QLatin1String("QSizeF(%1, %2)")).arg(size.width()).arg(size.height());
-}
-
-qreal QDeclarativeSizeFValueType::width() const
-{
- return size.width();
-}
-
-qreal QDeclarativeSizeFValueType::height() const
-{
- return size.height();
-}
-
-void QDeclarativeSizeFValueType::setWidth(qreal w)
-{
- size.setWidth(w);
-}
-
-void QDeclarativeSizeFValueType::setHeight(qreal h)
-{
- size.setHeight(h);
-}
-
-QString QDeclarativeSizeValueType::toString() const
-{
- return QString(QLatin1String("QSize(%1, %2)")).arg(size.width()).arg(size.height());
-}
-
-int QDeclarativeSizeValueType::width() const
-{
- return size.width();
-}
-
-int QDeclarativeSizeValueType::height() const
-{
- return size.height();
-}
-
-void QDeclarativeSizeValueType::setWidth(int w)
-{
- size.setWidth(w);
-}
-
-void QDeclarativeSizeValueType::setHeight(int h)
-{
- size.setHeight(h);
-}
-
-QString QDeclarativeRectFValueType::toString() const
-{
- return QString(QLatin1String("QRectF(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
-}
-
-qreal QDeclarativeRectFValueType::x() const
-{
- return rect.x();
-}
-
-qreal QDeclarativeRectFValueType::y() const
-{
- return rect.y();
-}
-
-void QDeclarativeRectFValueType::setX(qreal x)
-{
- rect.moveLeft(x);
-}
-
-void QDeclarativeRectFValueType::setY(qreal y)
-{
- rect.moveTop(y);
-}
-
-qreal QDeclarativeRectFValueType::width() const
-{
- return rect.width();
-}
-
-qreal QDeclarativeRectFValueType::height() const
-{
- return rect.height();
-}
-
-void QDeclarativeRectFValueType::setWidth(qreal w)
-{
- rect.setWidth(w);
-}
-
-void QDeclarativeRectFValueType::setHeight(qreal h)
-{
- rect.setHeight(h);
-}
-
-QString QDeclarativeRectValueType::toString() const
-{
- return QString(QLatin1String("QRect(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
-}
-
-int QDeclarativeRectValueType::x() const
-{
- return rect.x();
-}
-
-int QDeclarativeRectValueType::y() const
-{
- return rect.y();
-}
-
-void QDeclarativeRectValueType::setX(int x)
-{
- rect.moveLeft(x);
-}
-
-void QDeclarativeRectValueType::setY(int y)
-{
- rect.moveTop(y);
-}
-
-int QDeclarativeRectValueType::width() const
-{
- return rect.width();
-}
-
-int QDeclarativeRectValueType::height() const
-{
- return rect.height();
-}
-
-void QDeclarativeRectValueType::setWidth(int w)
-{
- rect.setWidth(w);
-}
-
-void QDeclarativeRectValueType::setHeight(int h)
-{
- rect.setHeight(h);
-}
-
-QString QDeclarativeVector2DValueType::toString() const
-{
- return QString(QLatin1String("QVector2D(%1, %2)")).arg(vector.x()).arg(vector.y());
-}
-
-qreal QDeclarativeVector2DValueType::x() const
-{
- return vector.x();
-}
-
-qreal QDeclarativeVector2DValueType::y() const
-{
- return vector.y();
-}
-
-void QDeclarativeVector2DValueType::setX(qreal x)
-{
- vector.setX(x);
-}
-
-void QDeclarativeVector2DValueType::setY(qreal y)
-{
- vector.setY(y);
-}
-
-QString QDeclarativeVector3DValueType::toString() const
-{
- return QString(QLatin1String("QVector3D(%1, %2, %3)")).arg(vector.x()).arg(vector.y()).arg(vector.z());
-}
-
-qreal QDeclarativeVector3DValueType::x() const
-{
- return vector.x();
-}
-
-qreal QDeclarativeVector3DValueType::y() const
-{
- return vector.y();
-}
-
-qreal QDeclarativeVector3DValueType::z() const
-{
- return vector.z();
-}
-
-void QDeclarativeVector3DValueType::setX(qreal x)
-{
- vector.setX(x);
-}
-
-void QDeclarativeVector3DValueType::setY(qreal y)
-{
- vector.setY(y);
-}
-
-void QDeclarativeVector3DValueType::setZ(qreal z)
-{
- vector.setZ(z);
-}
-
-QString QDeclarativeVector4DValueType::toString() const
-{
- return QString(QLatin1String("QVector4D(%1, %2, %3, %4)")).arg(vector.x()).arg(vector.y()).arg(vector.z()).arg(vector.w());
-}
-
-qreal QDeclarativeVector4DValueType::x() const
-{
- return vector.x();
-}
-
-qreal QDeclarativeVector4DValueType::y() const
-{
- return vector.y();
-}
-
-qreal QDeclarativeVector4DValueType::z() const
-{
- return vector.z();
-}
-
-qreal QDeclarativeVector4DValueType::w() const
-{
- return vector.w();
-}
-
-void QDeclarativeVector4DValueType::setX(qreal x)
-{
- vector.setX(x);
-}
-
-void QDeclarativeVector4DValueType::setY(qreal y)
-{
- vector.setY(y);
-}
-
-void QDeclarativeVector4DValueType::setZ(qreal z)
-{
- vector.setZ(z);
-}
-
-void QDeclarativeVector4DValueType::setW(qreal w)
-{
- vector.setW(w);
-}
-
-QString QDeclarativeQuaternionValueType::toString() const
-{
- return QString(QLatin1String("QQuaternion(%1, %2, %3, %4)")).arg(quaternion.scalar()).arg(quaternion.x()).arg(quaternion.y()).arg(quaternion.z());
-}
-
-qreal QDeclarativeQuaternionValueType::scalar() const
-{
- return quaternion.scalar();
-}
-
-qreal QDeclarativeQuaternionValueType::x() const
-{
- return quaternion.x();
-}
-
-qreal QDeclarativeQuaternionValueType::y() const
-{
- return quaternion.y();
-}
-
-qreal QDeclarativeQuaternionValueType::z() const
-{
- return quaternion.z();
-}
-
-void QDeclarativeQuaternionValueType::setScalar(qreal scalar)
-{
- quaternion.setScalar(scalar);
-}
-
-void QDeclarativeQuaternionValueType::setX(qreal x)
-{
- quaternion.setX(x);
-}
-
-void QDeclarativeQuaternionValueType::setY(qreal y)
-{
- quaternion.setY(y);
-}
-
-void QDeclarativeQuaternionValueType::setZ(qreal z)
-{
- quaternion.setZ(z);
-}
-
-QString QDeclarativeMatrix4x4ValueType::toString() const
-{
- return QString(QLatin1String("QMatrix4x4(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16)"))
- .arg(matrix(0, 0)).arg(matrix(0, 1)).arg(matrix(0, 2)).arg(matrix(0, 3))
- .arg(matrix(1, 0)).arg(matrix(1, 1)).arg(matrix(1, 2)).arg(matrix(1, 3))
- .arg(matrix(2, 0)).arg(matrix(2, 1)).arg(matrix(2, 2)).arg(matrix(2, 3))
- .arg(matrix(3, 0)).arg(matrix(3, 1)).arg(matrix(3, 2)).arg(matrix(3, 3));
-}
-
-QString QDeclarativeEasingValueType::toString() const
-{
- return QString(QLatin1String("QEasingCurve(%1, %2, %3, %4)")).arg(easing.type()).arg(easing.amplitude()).arg(easing.overshoot()).arg(easing.period());
-}
-
-QDeclarativeEasingValueType::Type QDeclarativeEasingValueType::type() const
-{
- return (QDeclarativeEasingValueType::Type)easing.type();
-}
-
-qreal QDeclarativeEasingValueType::amplitude() const
-{
- return easing.amplitude();
-}
-
-qreal QDeclarativeEasingValueType::overshoot() const
-{
- return easing.overshoot();
-}
-
-qreal QDeclarativeEasingValueType::period() const
-{
- return easing.period();
-}
-
-void QDeclarativeEasingValueType::setType(QDeclarativeEasingValueType::Type type)
-{
- easing.setType((QEasingCurve::Type)type);
-}
-
-void QDeclarativeEasingValueType::setAmplitude(qreal amplitude)
-{
- easing.setAmplitude(amplitude);
-}
-
-void QDeclarativeEasingValueType::setOvershoot(qreal overshoot)
-{
- easing.setOvershoot(overshoot);
-}
-
-void QDeclarativeEasingValueType::setPeriod(qreal period)
-{
- easing.setPeriod(period);
-}
-
-void QDeclarativeEasingValueType::setBezierCurve(const QVariantList &customCurveVariant)
-{
- if (customCurveVariant.isEmpty())
- return;
-
- QVariantList variantList = customCurveVariant;
- if ((variantList.count() % 6) == 0) {
- bool allRealsOk = true;
- QList<qreal> reals;
- for (int i = 0; i < variantList.count(); i++) {
- bool ok;
- const qreal real = variantList.at(i).toReal(&ok);
- reals.append(real);
- if (!ok)
- allRealsOk = false;
- }
- if (allRealsOk) {
- QEasingCurve newEasingCurve(QEasingCurve::BezierSpline);
- for (int i = 0; i < reals.count() / 6; i++) {
- const qreal c1x = reals.at(i * 6);
- const qreal c1y = reals.at(i * 6 + 1);
- const qreal c2x = reals.at(i * 6 + 2);
- const qreal c2y = reals.at(i * 6 + 3);
- const qreal c3x = reals.at(i * 6 + 4);
- const qreal c3y = reals.at(i * 6 + 5);
-
- const QPointF c1(c1x, c1y);
- const QPointF c2(c2x, c2y);
- const QPointF c3(c3x, c3y);
-
- newEasingCurve.addCubicBezierSegment(c1, c2, c3);
- easing = newEasingCurve;
- }
- }
- }
-}
-
-QVariantList QDeclarativeEasingValueType::bezierCurve() const
-{
- QVariantList rv;
- QList<QPointF> points = easing.cubicBezierSpline();
- for (int ii = 0; ii < points.count(); ++ii)
- rv << QVariant(points.at(ii).x()) << QVariant(points.at(ii).y());
- return rv;
-}
-
-void QDeclarativeFontValueType::onLoad()
-{
- pixelSizeSet = false;
- pointSizeSet = false;
-}
-
-QString QDeclarativeFontValueType::toString() const
-{
- return QString(QLatin1String("QFont(%1)")).arg(font.toString());
-}
-
-QString QDeclarativeFontValueType::family() const
-{
- return font.family();
-}
-
-void QDeclarativeFontValueType::setFamily(const QString &family)
-{
- font.setFamily(family);
-}
-
-bool QDeclarativeFontValueType::bold() const
-{
- return font.bold();
-}
-
-void QDeclarativeFontValueType::setBold(bool b)
-{
- font.setBold(b);
-}
-
-QDeclarativeFontValueType::FontWeight QDeclarativeFontValueType::weight() const
-{
- return (QDeclarativeFontValueType::FontWeight)font.weight();
-}
-
-void QDeclarativeFontValueType::setWeight(QDeclarativeFontValueType::FontWeight w)
-{
- font.setWeight((QFont::Weight)w);
-}
-
-bool QDeclarativeFontValueType::italic() const
-{
- return font.italic();
-}
-
-void QDeclarativeFontValueType::setItalic(bool b)
-{
- font.setItalic(b);
-}
-
-bool QDeclarativeFontValueType::underline() const
-{
- return font.underline();
-}
-
-void QDeclarativeFontValueType::setUnderline(bool b)
-{
- font.setUnderline(b);
-}
-
-bool QDeclarativeFontValueType::overline() const
-{
- return font.overline();
-}
-
-void QDeclarativeFontValueType::setOverline(bool b)
-{
- font.setOverline(b);
-}
-
-bool QDeclarativeFontValueType::strikeout() const
-{
- return font.strikeOut();
-}
-
-void QDeclarativeFontValueType::setStrikeout(bool b)
-{
- font.setStrikeOut(b);
-}
-
-qreal QDeclarativeFontValueType::pointSize() const
-{
- if (font.pointSizeF() == -1) {
- if (dpi.isNull)
- dpi = qt_defaultDpi();
- return font.pixelSize() * qreal(72.) / qreal(dpi);
- }
- return font.pointSizeF();
-}
-
-void QDeclarativeFontValueType::setPointSize(qreal size)
-{
- if (pixelSizeSet) {
- qWarning() << "Both point size and pixel size set. Using pixel size.";
- return;
- }
-
- if (size >= 0.0) {
- pointSizeSet = true;
- font.setPointSizeF(size);
- } else {
- pointSizeSet = false;
- }
-}
-
-int QDeclarativeFontValueType::pixelSize() const
-{
- if (font.pixelSize() == -1) {
- if (dpi.isNull)
- dpi = qt_defaultDpi();
- return (font.pointSizeF() * dpi) / qreal(72.);
- }
- return font.pixelSize();
-}
-
-void QDeclarativeFontValueType::setPixelSize(int size)
-{
- if (size >0) {
- if (pointSizeSet)
- qWarning() << "Both point size and pixel size set. Using pixel size.";
- font.setPixelSize(size);
- pixelSizeSet = true;
- } else {
- pixelSizeSet = false;
- }
-}
-
-QDeclarativeFontValueType::Capitalization QDeclarativeFontValueType::capitalization() const
-{
- return (QDeclarativeFontValueType::Capitalization)font.capitalization();
-}
-
-void QDeclarativeFontValueType::setCapitalization(QDeclarativeFontValueType::Capitalization c)
-{
- font.setCapitalization((QFont::Capitalization)c);
-}
-
-qreal QDeclarativeFontValueType::letterSpacing() const
-{
- return font.letterSpacing();
-}
-
-void QDeclarativeFontValueType::setLetterSpacing(qreal size)
-{
- font.setLetterSpacing(QFont::AbsoluteSpacing, size);
-}
-
-qreal QDeclarativeFontValueType::wordSpacing() const
-{
- return font.wordSpacing();
-}
-
-void QDeclarativeFontValueType::setWordSpacing(qreal size)
-{
- font.setWordSpacing(size);
-}
-
-QString QDeclarativeColorValueType::toString() const
-{
- // special case - to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
- return QVariant(color).toString();
-}
-
-qreal QDeclarativeColorValueType::r() const
-{
- return color.redF();
-}
-
-qreal QDeclarativeColorValueType::g() const
-{
- return color.greenF();
-}
-
-qreal QDeclarativeColorValueType::b() const
-{
- return color.blueF();
-}
-
-qreal QDeclarativeColorValueType::a() const
-{
- return color.alphaF();
-}
-
-void QDeclarativeColorValueType::setR(qreal r)
-{
- color.setRedF(r);
-}
-
-void QDeclarativeColorValueType::setG(qreal g)
-{
- color.setGreenF(g);
-}
-
-void QDeclarativeColorValueType::setB(qreal b)
-{
- color.setBlueF(b);
-}
-
-void QDeclarativeColorValueType::setA(qreal a)
-{
- color.setAlphaF(a);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
deleted file mode 100644
index be4c4c2e6d..0000000000
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ /dev/null
@@ -1,635 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEVALUETYPE_P_H
-#define QDECLARATIVEVALUETYPE_P_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 "qdeclarativeproperty.h"
-#include "qdeclarativeproperty_p.h"
-#include "qdeclarativenullablevalue_p_p.h"
-
-#include <QtCore/qobject.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qeasingcurve.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qvector2d.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-#include <QtGui/qmatrix4x4.h>
-#include <QtGui/qquaternion.h>
-#include <QtGui/qfont.h>
-#include <QtGui/qcolor.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeValueType : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeValueType(QObject *parent = 0);
- virtual void read(QObject *, int) = 0;
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags flags) = 0;
- virtual QVariant value() = 0;
- virtual void setValue(const QVariant &) = 0;
-
- virtual QString toString() const = 0;
- virtual bool isEqual(const QVariant &value) const = 0;
-
- inline void onLoad();
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeValueTypeFactory
-{
-public:
- QDeclarativeValueTypeFactory();
- ~QDeclarativeValueTypeFactory();
- static bool isValueType(int);
- static QDeclarativeValueType *valueType(int);
-
- static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor);
- static void registerValueTypes();
-
- QDeclarativeValueType *operator[](int idx) const {
- if (idx >= (int)QVariant::UserType) return 0;
- else return valueTypes[idx];
- }
-
-private:
- QDeclarativeValueType *valueTypes[QVariant::UserType - 1];
-};
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePointFValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_OBJECT
-public:
- QDeclarativePointFValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal x() const;
- qreal y() const;
- void setX(qreal);
- void setY(qreal);
-
-private:
- QPointF point;
-};
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePointValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(int x READ x WRITE setX)
- Q_PROPERTY(int y READ y WRITE setY)
- Q_OBJECT
-public:
- QDeclarativePointValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- int x() const;
- int y() const;
- void setX(int);
- void setY(int);
-
-private:
- QPoint point;
-};
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeSizeFValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal width READ width WRITE setWidth)
- Q_PROPERTY(qreal height READ height WRITE setHeight)
- Q_OBJECT
-public:
- QDeclarativeSizeFValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal width() const;
- qreal height() const;
- void setWidth(qreal);
- void setHeight(qreal);
-
-private:
- QSizeF size;
-};
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeSizeValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(int width READ width WRITE setWidth)
- Q_PROPERTY(int height READ height WRITE setHeight)
- Q_OBJECT
-public:
- QDeclarativeSizeValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- int width() const;
- int height() const;
- void setWidth(int);
- void setHeight(int);
-
-private:
- QSize size;
-};
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeRectFValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal width READ width WRITE setWidth)
- Q_PROPERTY(qreal height READ height WRITE setHeight)
- Q_OBJECT
-public:
- QDeclarativeRectFValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal x() const;
- qreal y() const;
- void setX(qreal);
- void setY(qreal);
-
- qreal width() const;
- qreal height() const;
- void setWidth(qreal);
- void setHeight(qreal);
-
-private:
- QRectF rect;
-};
-
-// Exported for QtQuick1
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeRectValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(int x READ x WRITE setX)
- Q_PROPERTY(int y READ y WRITE setY)
- Q_PROPERTY(int width READ width WRITE setWidth)
- Q_PROPERTY(int height READ height WRITE setHeight)
- Q_OBJECT
-public:
- QDeclarativeRectValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- int x() const;
- int y() const;
- void setX(int);
- void setY(int);
-
- int width() const;
- int height() const;
- void setWidth(int);
- void setHeight(int);
-
-private:
- QRect rect;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeVector2DValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_OBJECT
-public:
- QDeclarativeVector2DValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal x() const;
- qreal y() const;
- void setX(qreal);
- void setY(qreal);
-
-private:
- QVector2D vector;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeVector3DValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal z READ z WRITE setZ)
- Q_OBJECT
-public:
- QDeclarativeVector3DValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal x() const;
- qreal y() const;
- qreal z() const;
- void setX(qreal);
- void setY(qreal);
- void setZ(qreal);
-
-private:
- QVector3D vector;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeVector4DValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal z READ z WRITE setZ)
- Q_PROPERTY(qreal w READ w WRITE setW)
- Q_OBJECT
-public:
- QDeclarativeVector4DValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal x() const;
- qreal y() const;
- qreal z() const;
- qreal w() const;
- void setX(qreal);
- void setY(qreal);
- void setZ(qreal);
- void setW(qreal);
-
-private:
- QVector4D vector;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeQuaternionValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal scalar READ scalar WRITE setScalar)
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal z READ z WRITE setZ)
- Q_OBJECT
-public:
- QDeclarativeQuaternionValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal scalar() const;
- qreal x() const;
- qreal y() const;
- qreal z() const;
- void setScalar(qreal);
- void setX(qreal);
- void setY(qreal);
- void setZ(qreal);
-
-private:
- QQuaternion quaternion;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeMatrix4x4ValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal m11 READ m11 WRITE setM11)
- Q_PROPERTY(qreal m12 READ m12 WRITE setM12)
- Q_PROPERTY(qreal m13 READ m13 WRITE setM13)
- Q_PROPERTY(qreal m14 READ m14 WRITE setM14)
- Q_PROPERTY(qreal m21 READ m21 WRITE setM21)
- Q_PROPERTY(qreal m22 READ m22 WRITE setM22)
- Q_PROPERTY(qreal m23 READ m23 WRITE setM23)
- Q_PROPERTY(qreal m24 READ m24 WRITE setM24)
- Q_PROPERTY(qreal m31 READ m31 WRITE setM31)
- Q_PROPERTY(qreal m32 READ m32 WRITE setM32)
- Q_PROPERTY(qreal m33 READ m33 WRITE setM33)
- Q_PROPERTY(qreal m34 READ m34 WRITE setM34)
- Q_PROPERTY(qreal m41 READ m41 WRITE setM41)
- Q_PROPERTY(qreal m42 READ m42 WRITE setM42)
- Q_PROPERTY(qreal m43 READ m43 WRITE setM43)
- Q_PROPERTY(qreal m44 READ m44 WRITE setM44)
- Q_OBJECT
-public:
- QDeclarativeMatrix4x4ValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal m11() const { return matrix(0, 0); }
- qreal m12() const { return matrix(0, 1); }
- qreal m13() const { return matrix(0, 2); }
- qreal m14() const { return matrix(0, 3); }
- qreal m21() const { return matrix(1, 0); }
- qreal m22() const { return matrix(1, 1); }
- qreal m23() const { return matrix(1, 2); }
- qreal m24() const { return matrix(1, 3); }
- qreal m31() const { return matrix(2, 0); }
- qreal m32() const { return matrix(2, 1); }
- qreal m33() const { return matrix(2, 2); }
- qreal m34() const { return matrix(2, 3); }
- qreal m41() const { return matrix(3, 0); }
- qreal m42() const { return matrix(3, 1); }
- qreal m43() const { return matrix(3, 2); }
- qreal m44() const { return matrix(3, 3); }
-
- void setM11(qreal value) { matrix(0, 0) = value; }
- void setM12(qreal value) { matrix(0, 1) = value; }
- void setM13(qreal value) { matrix(0, 2) = value; }
- void setM14(qreal value) { matrix(0, 3) = value; }
- void setM21(qreal value) { matrix(1, 0) = value; }
- void setM22(qreal value) { matrix(1, 1) = value; }
- void setM23(qreal value) { matrix(1, 2) = value; }
- void setM24(qreal value) { matrix(1, 3) = value; }
- void setM31(qreal value) { matrix(2, 0) = value; }
- void setM32(qreal value) { matrix(2, 1) = value; }
- void setM33(qreal value) { matrix(2, 2) = value; }
- void setM34(qreal value) { matrix(2, 3) = value; }
- void setM41(qreal value) { matrix(3, 0) = value; }
- void setM42(qreal value) { matrix(3, 1) = value; }
- void setM43(qreal value) { matrix(3, 2) = value; }
- void setM44(qreal value) { matrix(3, 3) = value; }
-
-private:
- QMatrix4x4 matrix;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEasingValueType : public QDeclarativeValueType
-{
- Q_OBJECT
- Q_ENUMS(Type)
-
- Q_PROPERTY(QDeclarativeEasingValueType::Type type READ type WRITE setType)
- Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude)
- Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot)
- Q_PROPERTY(qreal period READ period WRITE setPeriod)
- Q_PROPERTY(QVariantList bezierCurve READ bezierCurve WRITE setBezierCurve)
-public:
- enum Type {
- Linear = QEasingCurve::Linear,
- InQuad = QEasingCurve::InQuad, OutQuad = QEasingCurve::OutQuad,
- InOutQuad = QEasingCurve::InOutQuad, OutInQuad = QEasingCurve::OutInQuad,
- InCubic = QEasingCurve::InCubic, OutCubic = QEasingCurve::OutCubic,
- InOutCubic = QEasingCurve::InOutCubic, OutInCubic = QEasingCurve::OutInCubic,
- InQuart = QEasingCurve::InQuart, OutQuart = QEasingCurve::OutQuart,
- InOutQuart = QEasingCurve::InOutQuart, OutInQuart = QEasingCurve::OutInQuart,
- InQuint = QEasingCurve::InQuint, OutQuint = QEasingCurve::OutQuint,
- InOutQuint = QEasingCurve::InOutQuint, OutInQuint = QEasingCurve::OutInQuint,
- InSine = QEasingCurve::InSine, OutSine = QEasingCurve::OutSine,
- InOutSine = QEasingCurve::InOutSine, OutInSine = QEasingCurve::OutInSine,
- InExpo = QEasingCurve::InExpo, OutExpo = QEasingCurve::OutExpo,
- InOutExpo = QEasingCurve::InOutExpo, OutInExpo = QEasingCurve::OutInExpo,
- InCirc = QEasingCurve::InCirc, OutCirc = QEasingCurve::OutCirc,
- InOutCirc = QEasingCurve::InOutCirc, OutInCirc = QEasingCurve::OutInCirc,
- InElastic = QEasingCurve::InElastic, OutElastic = QEasingCurve::OutElastic,
- InOutElastic = QEasingCurve::InOutElastic, OutInElastic = QEasingCurve::OutInElastic,
- InBack = QEasingCurve::InBack, OutBack = QEasingCurve::OutBack,
- InOutBack = QEasingCurve::InOutBack, OutInBack = QEasingCurve::OutInBack,
- InBounce = QEasingCurve::InBounce, OutBounce = QEasingCurve::OutBounce,
- InOutBounce = QEasingCurve::InOutBounce, OutInBounce = QEasingCurve::OutInBounce,
- InCurve = QEasingCurve::InCurve, OutCurve = QEasingCurve::OutCurve,
- SineCurve = QEasingCurve::SineCurve, CosineCurve = QEasingCurve::CosineCurve,
- Bezier = QEasingCurve::BezierSpline
- };
-
- QDeclarativeEasingValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- Type type() const;
- qreal amplitude() const;
- qreal overshoot() const;
- qreal period() const;
- void setType(Type);
- void setAmplitude(qreal);
- void setOvershoot(qreal);
- void setPeriod(qreal);
- void setBezierCurve(const QVariantList &);
- QVariantList bezierCurve() const;
-
-
-private:
- QEasingCurve easing;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeFontValueType : public QDeclarativeValueType
-{
- Q_OBJECT
- Q_ENUMS(FontWeight)
- Q_ENUMS(Capitalization)
-
- Q_PROPERTY(QString family READ family WRITE setFamily)
- Q_PROPERTY(bool bold READ bold WRITE setBold)
- Q_PROPERTY(FontWeight weight READ weight WRITE setWeight)
- Q_PROPERTY(bool italic READ italic WRITE setItalic)
- Q_PROPERTY(bool underline READ underline WRITE setUnderline)
- Q_PROPERTY(bool overline READ overline WRITE setOverline)
- Q_PROPERTY(bool strikeout READ strikeout WRITE setStrikeout)
- Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize)
- Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize)
- Q_PROPERTY(Capitalization capitalization READ capitalization WRITE setCapitalization)
- Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing)
- Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing)
-
-public:
- enum FontWeight { Light = QFont::Light,
- Normal = QFont::Normal,
- DemiBold = QFont::DemiBold,
- Bold = QFont::Bold,
- Black = QFont::Black };
- enum Capitalization { MixedCase = QFont::MixedCase,
- AllUppercase = QFont::AllUppercase,
- AllLowercase = QFont::AllLowercase,
- SmallCaps = QFont::SmallCaps,
- Capitalize = QFont::Capitalize };
-
- QDeclarativeFontValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- QString family() const;
- void setFamily(const QString &);
-
- bool bold() const;
- void setBold(bool b);
-
- FontWeight weight() const;
- void setWeight(FontWeight);
-
- bool italic() const;
- void setItalic(bool b);
-
- bool underline() const;
- void setUnderline(bool b);
-
- bool overline() const;
- void setOverline(bool b);
-
- bool strikeout() const;
- void setStrikeout(bool b);
-
- qreal pointSize() const;
- void setPointSize(qreal size);
-
- int pixelSize() const;
- void setPixelSize(int size);
-
- Capitalization capitalization() const;
- void setCapitalization(Capitalization);
-
- qreal letterSpacing() const;
- void setLetterSpacing(qreal spacing);
-
- qreal wordSpacing() const;
- void setWordSpacing(qreal spacing);
-
- void onLoad();
-private:
- QFont font;
- bool pixelSizeSet;
- bool pointSizeSet;
- mutable QDeclarativeNullableValue<int> dpi;
-};
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeColorValueType : public QDeclarativeValueType
-{
- Q_PROPERTY(qreal r READ r WRITE setR)
- Q_PROPERTY(qreal g READ g WRITE setG)
- Q_PROPERTY(qreal b READ b WRITE setB)
- Q_PROPERTY(qreal a READ a WRITE setA)
- Q_OBJECT
-public:
- QDeclarativeColorValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
- virtual QVariant value();
- virtual void setValue(const QVariant &value);
- virtual QString toString() const;
- virtual bool isEqual(const QVariant &value) const;
-
- qreal r() const;
- qreal g() const;
- qreal b() const;
- qreal a() const;
- void setR(qreal);
- void setG(qreal);
- void setB(qreal);
- void setA(qreal);
-
-private:
- QColor color;
-};
-
-void QDeclarativeValueType::onLoad()
-{
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEVALUETYPE_P_H
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
deleted file mode 100644
index 254ae5de43..0000000000
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ /dev/null
@@ -1,1370 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativevme_p.h"
-
-#include "qdeclarativecompiler_p.h"
-#include "qdeclarativeboundsignal_p.h"
-#include "qdeclarativestringconverters_p.h"
-#include <private/qmetaobjectbuilder_p.h>
-#include <private/qfastmetabuilder_p.h>
-#include "qdeclarativedata_p.h"
-#include "qdeclarative.h"
-#include "qdeclarativecustomparser_p.h"
-#include "qdeclarativeengine.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarativecomponent.h"
-#include "qdeclarativecomponentattached_p.h"
-#include "qdeclarativebinding_p.h"
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativecomponent_p.h"
-#include "qdeclarativevmemetaobject_p.h"
-#include "qdeclarativebinding_p_p.h"
-#include "qdeclarativecontext_p.h"
-#include <private/qv4bindings_p.h>
-#include <private/qv8bindings_p.h>
-#include "qdeclarativeglobal_p.h"
-#include <private/qfinitestack_p.h>
-#include "qdeclarativescriptstring.h"
-#include "qdeclarativescriptstring_p.h"
-#include "qdeclarativepropertyvalueinterceptor_p.h"
-
-#include <QStack>
-#include <QColor>
-#include <QPointF>
-#include <QSizeF>
-#include <QRectF>
-#include <QtCore/qdebug.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtDeclarative/qjsvalue.h>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QDeclarativeVMETypes;
-
-#define VME_EXCEPTION(desc, line) \
- { \
- QDeclarativeError error; \
- error.setDescription(desc.trimmed()); \
- error.setLine(line); \
- error.setUrl(COMP->url); \
- *errors << error; \
- goto exceptionExit; \
- }
-
-void QDeclarativeVME::init(QDeclarativeContextData *ctxt, QDeclarativeCompiledData *comp, int start,
- QDeclarativeContextData *creation)
-{
- Q_ASSERT(ctxt);
- Q_ASSERT(comp);
-
- if (start == -1) {
- start = 0;
- } else {
- creationContext = creation;
- }
-
- State initState;
- initState.context = ctxt;
- initState.compiledData = comp;
- initState.instructionStream = comp->bytecode.constData() + start;
- states.push(initState);
-
- typedef QDeclarativeInstruction I;
- I *i = (I *)initState.instructionStream;
-
- Q_ASSERT(comp->instructionType(i) == I::Init);
-
- objects.allocate(i->init.objectStackSize);
- lists.allocate(i->init.listStackSize);
- bindValues.allocate(i->init.bindingsSize);
- parserStatus.allocate(i->init.parserStatusSize);
-
-#ifdef QML_ENABLE_TRACE
- parserStatusData.allocate(i->init.parserStatusSize);
- rootComponent = comp;
-#endif
-
- rootContext = 0;
- engine = ctxt->engine;
-}
-
-bool QDeclarativeVME::initDeferred(QObject *object)
-{
- QDeclarativeData *data = QDeclarativeData::get(object);
-
- if (!data || !data->context || !data->deferredComponent)
- return false;
-
- QDeclarativeContextData *ctxt = data->context;
- QDeclarativeCompiledData *comp = data->deferredComponent;
- int start = data->deferredIdx;
-
- State initState;
- initState.flags = State::Deferred;
- initState.context = ctxt;
- initState.compiledData = comp;
- initState.instructionStream = comp->bytecode.constData() + start;
- states.push(initState);
-
- typedef QDeclarativeInstruction I;
- I *i = (I *)initState.instructionStream;
-
- Q_ASSERT(comp->instructionType(i) == I::DeferInit);
-
- objects.allocate(i->deferInit.objectStackSize);
- lists.allocate(i->deferInit.listStackSize);
- bindValues.allocate(i->deferInit.bindingsSize);
- parserStatus.allocate(i->deferInit.parserStatusSize);
-
- objects.push(object);
-
-#ifdef QML_ENABLE_TRACE
- parserStatusData.allocate(i->deferInit.parserStatusSize);
- rootComponent = comp;
-#endif
-
- rootContext = 0;
- engine = ctxt->engine;
-
- return true;
-}
-
-namespace {
-struct ActiveVMERestorer
-{
- ActiveVMERestorer(QDeclarativeVME *me, QDeclarativeEnginePrivate *ep)
- : ep(ep), oldVME(ep->activeVME) { ep->activeVME = me; }
- ~ActiveVMERestorer() { ep->activeVME = oldVME; }
-
- QDeclarativeEnginePrivate *ep;
- QDeclarativeVME *oldVME;
-};
-}
-
-QObject *QDeclarativeVME::execute(QList<QDeclarativeError> *errors, const Interrupt &interrupt)
-{
- Q_ASSERT(states.count() >= 1);
-
-#ifdef QML_ENABLE_TRACE
- QDeclarativeTrace trace("VME Execute");
- trace.addDetail("URL", rootComponent->url);
-#endif
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(states.at(0).context->engine);
-
- ActiveVMERestorer restore(this, ep);
-
- QObject *rv = run(errors, interrupt);
-
- return rv;
-}
-
-inline bool fastHasBinding(QObject *o, int index)
-{
- QDeclarativeData *ddata = static_cast<QDeclarativeData *>(QObjectPrivate::get(o)->declarativeData);
-
- return ddata && (ddata->bindingBitsSize > index) &&
- (ddata->bindingBits[index / 32] & (1 << (index % 32)));
-}
-
-static void removeBindingOnProperty(QObject *o, int index)
-{
- QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::setBinding(o, index, -1, 0);
- if (binding) binding->destroy();
-}
-
-static QVariant variantFromString(const QString &string)
-{
- return QDeclarativeStringConverters::variantFromString(string);
-}
-
-// XXX we probably need some form of "work count" here to prevent us checking this
-// for every instruction.
-#define QML_BEGIN_INSTR_COMMON(I) { \
- const QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::DataType &instr = QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::data(*genericInstr); \
- INSTRUCTIONSTREAM += QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::Size; \
- Q_UNUSED(instr);
-
-#ifdef QML_THREADED_VME_INTERPRETER
-# define QML_BEGIN_INSTR(I) op_##I: \
- QML_BEGIN_INSTR_COMMON(I)
-
-# define QML_NEXT_INSTR(I) { \
- if (watcher.hasRecursed()) return 0; \
- genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(INSTRUCTIONSTREAM); \
- goto *genericInstr->common.code; \
- }
-
-# define QML_END_INSTR(I) } \
- if (watcher.hasRecursed()) return 0; \
- genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(INSTRUCTIONSTREAM); \
- if (interrupt.shouldInterrupt()) return 0; \
- goto *genericInstr->common.code;
-
-#else
-# define QML_BEGIN_INSTR(I) \
- case QDeclarativeInstruction::I: \
- QML_BEGIN_INSTR_COMMON(I)
-
-# define QML_NEXT_INSTR(I) { \
- if (watcher.hasRecursed()) return 0; \
- break; \
- }
-
-# define QML_END_INSTR(I) \
- if (watcher.hasRecursed() || interrupt.shouldInterrupt()) return 0; \
- } break;
-#endif
-
-#define QML_STORE_VALUE(name, cpptype, value) \
- QML_BEGIN_INSTR(name) \
- cpptype v = value; \
- void *a[] = { (void *)&v, 0, &status, &flags }; \
- QObject *target = objects.top(); \
- CLEAN_PROPERTY(target, instr.propertyIndex); \
- QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
- QML_END_INSTR(name)
-
-#define QML_STORE_LIST(name, cpptype, value) \
- QML_BEGIN_INSTR(name) \
- cpptype v; \
- v.append(value); \
- void *a[] = { (void *)&v, 0, &status, &flags }; \
- QObject *target = objects.top(); \
- CLEAN_PROPERTY(target, instr.propertyIndex); \
- QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
- QML_END_INSTR(name)
-
-#define QML_STORE_VAR(name, value) \
- QML_BEGIN_INSTR(name) \
- v8::Handle<v8::Value> v8value = value; \
- QObject *target = objects.top(); \
- CLEAN_PROPERTY(target, instr.propertyIndex); \
- QMetaObject *mo = const_cast<QMetaObject *>(target->metaObject()); \
- QDeclarativeVMEMetaObject *vmemo = static_cast<QDeclarativeVMEMetaObject *>(mo); \
- vmemo->setVMEProperty(instr.propertyIndex, v8value); \
- QML_END_INSTR(name)
-
-#define QML_STORE_POINTER(name, value) \
- QML_BEGIN_INSTR(name) \
- void *a[] = { (void *)value, 0, &status, &flags }; \
- QObject *target = objects.top(); \
- CLEAN_PROPERTY(target, instr.propertyIndex); \
- QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
- QML_END_INSTR(name)
-
-#define CLEAN_PROPERTY(o, index) \
- if (fastHasBinding(o, index)) \
- removeBindingOnProperty(o, index)
-
-QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors,
- const Interrupt &interrupt
-#ifdef QML_THREADED_VME_INTERPRETER
- , void ***storeJumpTable
-#endif
- )
-{
-#ifdef QML_THREADED_VME_INTERPRETER
- if (storeJumpTable) {
-#define QML_INSTR_ADDR(I, FMT) &&op_##I,
- static void *jumpTable[] = {
- FOR_EACH_QML_INSTR(QML_INSTR_ADDR)
- };
-#undef QML_INSTR_ADDR
- *storeJumpTable = jumpTable;
- return 0;
- }
-#endif
- Q_ASSERT(errors->isEmpty());
- Q_ASSERT(states.count() >= 1);
-
- QDeclarativeEngine *engine = states.at(0).context->engine;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
-
- // Need a v8 handle scope and execution context for StoreVar instructions.
- v8::HandleScope handleScope;
- v8::Context::Scope contextScope(ep->v8engine()->context());
-
- int status = -1; // needed for dbus
- QDeclarativePropertyPrivate::WriteFlags flags = QDeclarativePropertyPrivate::BypassInterceptor |
- QDeclarativePropertyPrivate::RemoveBindingOnAliasWrite;
-
- QRecursionWatcher<QDeclarativeVME, &QDeclarativeVME::recursion> watcher(this);
-
-#define COMP states.top().compiledData
-#define CTXT states.top().context
-#define INSTRUCTIONSTREAM states.top().instructionStream
-#define BINDINGSKIPLIST states.top().bindingSkipList
-
-#define TYPES COMP->types
-#define PRIMITIVES COMP->primitives
-#define DATAS COMP->datas
-#define PROGRAMS COMP->programs
-#define PROPERTYCACHES COMP->propertyCaches
-#define SCRIPTS COMP->scripts
-#define URLS COMP->urls
-
-#ifdef QML_THREADED_VME_INTERPRETER
- const QDeclarativeInstruction *genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(INSTRUCTIONSTREAM);
- goto *genericInstr->common.code;
-#else
- for (;;) {
- const QDeclarativeInstruction *genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(INSTRUCTIONSTREAM);
-
- switch (genericInstr->common.instructionType) {
-#endif
-
- // Store a created object in a property. These all pop from the objects stack.
- QML_STORE_VALUE(StoreObject, QObject *, objects.pop());
- QML_STORE_VALUE(StoreVariantObject, QVariant, QVariant::fromValue(objects.pop()));
- QML_STORE_VAR(StoreVarObject, ep->v8engine()->newQObject(objects.pop()));
-
- // Store a literal value in a corresponding property
- QML_STORE_VALUE(StoreFloat, float, instr.value);
- QML_STORE_VALUE(StoreDouble, double, instr.value);
- QML_STORE_VALUE(StoreBool, bool, instr.value);
- QML_STORE_VALUE(StoreInteger, int, instr.value);
- QML_STORE_VALUE(StoreColor, QColor, QColor::fromRgba(instr.value));
- QML_STORE_VALUE(StoreDate, QDate, QDate::fromJulianDay(instr.value));
- QML_STORE_VALUE(StoreDateTime, QDateTime,
- QDateTime(QDate::fromJulianDay(instr.date), *(QTime *)&instr.time));
- QML_STORE_POINTER(StoreTime, (QTime *)&instr.time);
- QML_STORE_POINTER(StorePoint, (QPoint *)&instr.point);
- QML_STORE_POINTER(StorePointF, (QPointF *)&instr.point);
- QML_STORE_POINTER(StoreSize, (QSize *)&instr.size);
- QML_STORE_POINTER(StoreSizeF, (QSizeF *)&instr.size);
- QML_STORE_POINTER(StoreRect, (QRect *)&instr.rect);
- QML_STORE_POINTER(StoreRectF, (QRectF *)&instr.rect);
- QML_STORE_POINTER(StoreVector3D, (QVector3D *)&instr.vector);
- QML_STORE_POINTER(StoreVector4D, (QVector4D *)&instr.vector);
- QML_STORE_POINTER(StoreString, &PRIMITIVES.at(instr.value));
- QML_STORE_POINTER(StoreByteArray, &DATAS.at(instr.value));
- QML_STORE_POINTER(StoreUrl, &URLS.at(instr.value));
- QML_STORE_VALUE(StoreTrString, QString,
- QCoreApplication::translate(DATAS.at(instr.context).constData(),
- DATAS.at(instr.text).constData(),
- DATAS.at(instr.comment).constData(),
- QCoreApplication::UnicodeUTF8,
- instr.n));
- QML_STORE_VALUE(StoreTrIdString, QString, qtTrId(DATAS.at(instr.text).constData(), instr.n));
-
- // Store a literal value in a QList
- QML_STORE_LIST(StoreStringList, QStringList, PRIMITIVES.at(instr.value));
- QML_STORE_LIST(StoreStringQList, QList<QString>, PRIMITIVES.at(instr.value));
- QML_STORE_LIST(StoreUrlQList, QList<QUrl>, URLS.at(instr.value));
- QML_STORE_LIST(StoreDoubleQList, QList<double>, instr.value);
- QML_STORE_LIST(StoreBoolQList, QList<bool>, instr.value);
- QML_STORE_LIST(StoreIntegerQList, QList<int>, instr.value);
-
- // Store a literal value in a QVariant property
- QML_STORE_VALUE(StoreVariant, QVariant, variantFromString(PRIMITIVES.at(instr.value)));
- QML_STORE_VALUE(StoreVariantInteger, QVariant, QVariant(instr.value));
- QML_STORE_VALUE(StoreVariantDouble, QVariant, QVariant(instr.value));
- QML_STORE_VALUE(StoreVariantBool, QVariant, QVariant(instr.value));
-
- // Store a literal value in a var property.
- // We deliberately do not use string converters here
- QML_STORE_VAR(StoreVar, ep->v8engine()->fromVariant(PRIMITIVES.at(instr.value)));
- QML_STORE_VAR(StoreVarInteger, v8::Integer::New(instr.value));
- QML_STORE_VAR(StoreVarDouble, v8::Number::New(instr.value));
- QML_STORE_VAR(StoreVarBool, v8::Boolean::New(instr.value));
-
-
- QML_BEGIN_INSTR(Init)
- // Ensure that the compiled data has been initialized
- if (!COMP->isInitialized()) COMP->initialize(engine);
-
- QDeclarativeContextData *parentCtxt = CTXT;
- CTXT = new QDeclarativeContextData;
- CTXT->isInternal = true;
- CTXT->url = COMP->url;
- CTXT->urlString = COMP->name;
- CTXT->imports = COMP->importCache;
- CTXT->imports->addref();
- CTXT->setParent(parentCtxt);
- if (instr.contextCache != -1)
- CTXT->setIdPropertyData(COMP->contextCaches.at(instr.contextCache));
- if (instr.compiledBinding != -1) {
- const char *v4data = DATAS.at(instr.compiledBinding).constData();
- CTXT->v4bindings = new QV4Bindings(v4data, CTXT, COMP);
- }
- if (states.count() == 1) {
- rootContext = CTXT;
- rootContext->activeVMEData = data;
- }
- if (states.count() == 1 && !creationContext.isNull()) {
- // A component that is logically created within another component instance shares the
- // same instances of script imports. For example:
- //
- // import QtQuick 2.0
- // import "test.js" as Test
- // ListView {
- // model: Test.getModel()
- // delegate: Component {
- // Text { text: Test.getValue(index); }
- // }
- // }
- //
- // Has the same "Test" instance. To implement this, we simply copy the v8 handles into
- // the inner context. We have to create a fresh persistent handle for each to prevent
- // double dispose. It is possible we could do this more efficiently using some form of
- // referencing instead.
- CTXT->importedScripts = creationContext->importedScripts;
- for (int ii = 0; ii < CTXT->importedScripts.count(); ++ii)
- CTXT->importedScripts[ii] = qPersistentNew<v8::Object>(CTXT->importedScripts[ii]);
- }
- QML_END_INSTR(Init)
-
- QML_BEGIN_INSTR(DeferInit)
- QML_END_INSTR(DeferInit)
-
- QML_BEGIN_INSTR(Done)
- states.pop();
-
- if (states.isEmpty())
- goto normalExit;
- QML_END_INSTR(Done)
-
- QML_BEGIN_INSTR(CreateQMLObject)
- const QDeclarativeCompiledData::TypeReference &type = TYPES.at(instr.type);
- Q_ASSERT(type.component);
-
- states.push(State());
-
- State *cState = &states[states.count() - 2];
- State *nState = &states[states.count() - 1];
-
- nState->context = cState->context;
- nState->compiledData = type.component;
- nState->instructionStream = type.component->bytecode.constData();
-
- if (instr.bindingBits != -1) {
- const QByteArray &bits = cState->compiledData->datas.at(instr.bindingBits);
- nState->bindingSkipList = QBitField((const quint32*)bits.constData(),
- bits.size() * 8);
- }
- if (instr.isRoot)
- nState->bindingSkipList = nState->bindingSkipList.united(cState->bindingSkipList);
-
- // As the state in the state stack changed, execution will continue in the new program.
- QML_END_INSTR(CreateQMLObject)
-
- QML_BEGIN_INSTR(CompleteQMLObject)
- QObject *o = objects.top();
-
- QDeclarativeData *ddata = QDeclarativeData::get(o);
- Q_ASSERT(ddata);
-
- if (instr.isRoot) {
- if (ddata->context) {
- Q_ASSERT(ddata->context != CTXT);
- Q_ASSERT(ddata->outerContext);
- Q_ASSERT(ddata->outerContext != CTXT);
- QDeclarativeContextData *c = ddata->context;
- while (c->linkedContext) c = c->linkedContext;
- c->linkedContext = CTXT;
- } else {
- CTXT->addObject(o);
- }
-
- ddata->ownContext = true;
- } else if (!ddata->context) {
- CTXT->addObject(o);
- }
-
- ddata->setImplicitDestructible();
- ddata->outerContext = CTXT;
- ddata->lineNumber = instr.line;
- ddata->columnNumber = instr.column;
- QML_END_INSTR(CompleteQMLObject)
-
- QML_BEGIN_INSTR(CreateCppObject)
- const QDeclarativeCompiledData::TypeReference &type = TYPES.at(instr.type);
- Q_ASSERT(type.type);
-
- QObject *o = 0;
- void *memory = 0;
- type.type->create(&o, &memory, sizeof(QDeclarativeData));
- QDeclarativeData *ddata = new (memory) QDeclarativeData;
- ddata->ownMemory = false;
- QObjectPrivate::get(o)->declarativeData = ddata;
-
- if (type.typePropertyCache && !ddata->propertyCache) {
- ddata->propertyCache = type.typePropertyCache;
- ddata->propertyCache->addref();
- }
-
- if (!o)
- VME_EXCEPTION(tr("Unable to create object of type %1").arg(type.className), instr.line);
-
- if (instr.isRoot) {
- if (ddata->context) {
- Q_ASSERT(ddata->context != CTXT);
- Q_ASSERT(ddata->outerContext);
- Q_ASSERT(ddata->outerContext != CTXT);
- QDeclarativeContextData *c = ddata->context;
- while (c->linkedContext) c = c->linkedContext;
- c->linkedContext = CTXT;
- } else {
- CTXT->addObject(o);
- }
-
- ddata->ownContext = true;
- } else if (!ddata->context) {
- CTXT->addObject(o);
- }
-
- ddata->setImplicitDestructible();
- ddata->outerContext = CTXT;
- ddata->lineNumber = instr.line;
- ddata->columnNumber = instr.column;
-
- if (instr.data != -1) {
- QDeclarativeCustomParser *customParser =
- TYPES.at(instr.type).type->customParser();
- customParser->setCustomData(o, DATAS.at(instr.data));
- }
- if (!objects.isEmpty()) {
- QObject *parent = objects.top();
-#if 0 // ### refactor
- if (o->isWidgetType() && parent->isWidgetType())
- static_cast<QWidget*>(o)->setParent(static_cast<QWidget*>(parent));
- else
-#endif
- QDeclarative_setParent_noEvent(o, parent);
- }
- objects.push(o);
- QML_END_INSTR(CreateCppObject)
-
- QML_BEGIN_INSTR(CreateSimpleObject)
- QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QDeclarativeData));
- ::memset(o, 0, instr.typeSize + sizeof(QDeclarativeData));
- instr.create(o);
-
- QDeclarativeData *ddata = (QDeclarativeData *)(((const char *)o) + instr.typeSize);
- const QDeclarativeCompiledData::TypeReference &ref = TYPES.at(instr.type);
- if (!ddata->propertyCache && ref.typePropertyCache) {
- ddata->propertyCache = ref.typePropertyCache;
- ddata->propertyCache->addref();
- }
- ddata->lineNumber = instr.line;
- ddata->columnNumber = instr.column;
-
- QObjectPrivate::get(o)->declarativeData = ddata;
- ddata->context = ddata->outerContext = CTXT;
- ddata->nextContextObject = CTXT->contextObjects;
- if (ddata->nextContextObject)
- ddata->nextContextObject->prevContextObject = &ddata->nextContextObject;
- ddata->prevContextObject = &CTXT->contextObjects;
- CTXT->contextObjects = ddata;
-
- QObject *parent = objects.top();
- QDeclarative_setParent_noEvent(o, parent);
-
- objects.push(o);
- QML_END_INSTR(CreateSimpleObject)
-
- QML_BEGIN_INSTR(SetId)
- QObject *target = objects.top();
- CTXT->setIdProperty(instr.index, target);
- QML_END_INSTR(SetId)
-
- QML_BEGIN_INSTR(SetDefault)
- CTXT->contextObject = objects.top();
- QML_END_INSTR(SetDefault)
-
- QML_BEGIN_INSTR(CreateComponent)
- QDeclarativeComponent *qcomp =
- new QDeclarativeComponent(CTXT->engine, COMP, INSTRUCTIONSTREAM - COMP->bytecode.constData(),
- objects.isEmpty() ? 0 : objects.top());
-
- QDeclarativeData *ddata = QDeclarativeData::get(qcomp, true);
- Q_ASSERT(ddata);
-
- CTXT->addObject(qcomp);
-
- if (instr.isRoot)
- ddata->ownContext = true;
-
- ddata->setImplicitDestructible();
- ddata->outerContext = CTXT;
- ddata->lineNumber = instr.line;
- ddata->columnNumber = instr.column;
-
- QDeclarativeComponentPrivate::get(qcomp)->creationContext = CTXT;
-
- objects.push(qcomp);
- INSTRUCTIONSTREAM += instr.count;
- QML_END_INSTR(CreateComponent)
-
- QML_BEGIN_INSTR(StoreMetaObject)
- QObject *target = objects.top();
-
- QMetaObject mo;
- const QByteArray &metadata = DATAS.at(instr.data);
- QFastMetaBuilder::fromData(&mo, 0, metadata);
-
- const QDeclarativeVMEMetaData *data =
- (const QDeclarativeVMEMetaData *)DATAS.at(instr.aliasData).constData();
-
- (void)new QDeclarativeVMEMetaObject(target, &mo, data, COMP);
-
- if (instr.propertyCache != -1) {
- QDeclarativeData *ddata = QDeclarativeData::get(target, true);
- if (ddata->propertyCache) ddata->propertyCache->release();
- ddata->propertyCache = PROPERTYCACHES.at(instr.propertyCache);
- ddata->propertyCache->addref();
- }
- QML_END_INSTR(StoreMetaObject)
-
- QML_BEGIN_INSTR(AssignCustomType)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- const QString &primitive = PRIMITIVES.at(instr.primitive);
- int type = instr.type;
- QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
- QVariant v = (*converter)(primitive);
-
- QMetaProperty prop =
- target->metaObject()->property(instr.propertyIndex);
- if (v.isNull() || ((int)prop.type() != type && prop.userType() != type))
- VME_EXCEPTION(tr("Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name())), instr.line);
-
- void *a[] = { (void *)v.data(), 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(AssignCustomType)
-
- QML_BEGIN_INSTR(AssignSignalObject)
- // XXX optimize
-
- QObject *assign = objects.pop();
- QObject *target = objects.top();
- int sigIdx = instr.signal;
- const QString &pr = PRIMITIVES.at(sigIdx);
-
- QDeclarativeProperty prop(target, pr);
- if (prop.type() & QDeclarativeProperty::SignalProperty) {
-
- QMetaMethod method = QDeclarativeMetaType::defaultMethod(assign);
- if (method.signature() == 0)
- VME_EXCEPTION(tr("Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className())), instr.line);
-
- if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature()))
- VME_EXCEPTION(tr("Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature())), instr.line);
-
- QDeclarativePropertyPrivate::connect(target, prop.index(), assign, method.methodIndex());
-
- } else {
- VME_EXCEPTION(tr("Cannot assign an object to signal property %1").arg(pr), instr.line);
- }
-
-
- QML_END_INSTR(AssignSignalObject)
-
- QML_BEGIN_INSTR(StoreSignal)
- QObject *target = objects.top();
- QObject *context = objects.at(objects.count() - 1 - instr.context);
-
- QMetaMethod signal = target->metaObject()->method(instr.signalIndex);
-
- QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
- QDeclarativeExpression *expr =
- new QDeclarativeExpression(CTXT, context, DATAS.at(instr.value), true, COMP->name, instr.line, instr.column, *new QDeclarativeExpressionPrivate);
- bs->setExpression(expr);
- QML_END_INSTR(StoreSignal)
-
- QML_BEGIN_INSTR(StoreImportedScript)
- CTXT->importedScripts << run(CTXT, SCRIPTS.at(instr.value));
- QML_END_INSTR(StoreImportedScript)
-
- QML_BEGIN_INSTR(StoreScriptString)
- QObject *target = objects.top();
- QObject *scope = objects.at(objects.count() - 1 - instr.scope);
- QDeclarativeScriptString ss;
- ss.setContext(CTXT->asQDeclarativeContext());
- ss.setScopeObject(scope);
- ss.setScript(PRIMITIVES.at(instr.value));
- ss.d.data()->bindingId = instr.bindingId;
- ss.d.data()->lineNumber = instr.line;
- ss.d.data()->columnNumber = instr.column;
-
- void *a[] = { &ss, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreScriptString)
-
- QML_BEGIN_INSTR(BeginObject)
- QObject *target = objects.top();
- QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>(target) + instr.castValue);
- parserStatus.push(status);
-#ifdef QML_ENABLE_TRACE
- Q_ASSERT(QObjectPrivate::get(target)->declarativeData);
- parserStatusData.push(static_cast<QDeclarativeData *>(QObjectPrivate::get(target)->declarativeData));
-#endif
- status->d = &parserStatus.top();
-
- status->classBegin();
- QML_END_INSTR(BeginObject)
-
- QML_BEGIN_INSTR(InitV8Bindings)
- CTXT->v8bindings = new QV8Bindings(&PROGRAMS[instr.programIndex], instr.line, CTXT);
- QML_END_INSTR(InitV8Bindings)
-
- QML_BEGIN_INSTR(StoreBinding)
- QObject *target =
- objects.at(objects.count() - 1 - instr.owner);
- QObject *context =
- objects.at(objects.count() - 1 - instr.context);
-
- if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
- QML_NEXT_INSTR(StoreBinding);
-
- QDeclarativeBinding *bind = new QDeclarativeBinding(PRIMITIVES.at(instr.value), true,
- context, CTXT, COMP->name, instr.line,
- instr.column);
- bindValues.push(bind);
- bind->m_mePtr = &bindValues.top();
- bind->setTarget(target, instr.property, CTXT);
-
- typedef QDeclarativePropertyPrivate QDPP;
- Q_ASSERT(bind->propertyIndex() == QDPP::bindingIndex(instr.property));
- Q_ASSERT(bind->object() == target);
-
- bind->addToObject();
- QML_END_INSTR(StoreBinding)
-
- QML_BEGIN_INSTR(StoreBindingOnAlias)
- QObject *target =
- objects.at(objects.count() - 1 - instr.owner);
- QObject *context =
- objects.at(objects.count() - 1 - instr.context);
-
- if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
- QML_NEXT_INSTR(StoreBindingOnAlias);
-
- QDeclarativeBinding *bind = new QDeclarativeBinding(PRIMITIVES.at(instr.value), true,
- context, CTXT, COMP->name, instr.line,
- instr.column);
- bindValues.push(bind);
- bind->m_mePtr = &bindValues.top();
- bind->setTarget(target, instr.property, CTXT);
-
- QDeclarativeAbstractBinding *old =
- QDeclarativePropertyPrivate::setBindingNoEnable(target, instr.property.coreIndex,
- instr.property.getValueTypeCoreIndex(),
- bind);
- if (old) { old->destroy(); }
- QML_END_INSTR(StoreBindingOnAlias)
-
- QML_BEGIN_INSTR(StoreV4Binding)
- QObject *target =
- objects.at(objects.count() - 1 - instr.owner);
- QObject *scope =
- objects.at(objects.count() - 1 - instr.context);
-
- int property = instr.property;
- if (instr.isRoot && BINDINGSKIPLIST.testBit(property & 0xFFFF))
- QML_NEXT_INSTR(StoreV4Binding);
-
- QDeclarativeAbstractBinding *binding =
- CTXT->v4bindings->configBinding(instr.value, target, scope, property,
- instr.line, instr.column);
- bindValues.push(binding);
- binding->m_mePtr = &bindValues.top();
-
- Q_ASSERT(binding->propertyIndex() == property);
- Q_ASSERT(binding->object() == target);
-
- binding->addToObject();
- QML_END_INSTR(StoreV4Binding)
-
- QML_BEGIN_INSTR(StoreV8Binding)
- QObject *target =
- objects.at(objects.count() - 1 - instr.owner);
- QObject *scope =
- objects.at(objects.count() - 1 - instr.context);
-
- if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
- QML_NEXT_INSTR(StoreV8Binding);
-
- QDeclarativeAbstractBinding *binding = CTXT->v8bindings->configBinding(target, scope,
- &instr);
- if (binding) {
- bindValues.push(binding);
- binding->m_mePtr = &bindValues.top();
-
- typedef QDeclarativePropertyPrivate QDPP;
- Q_ASSERT(binding->propertyIndex() == QDPP::bindingIndex(instr.property));
- Q_ASSERT(binding->object() == target);
-
- binding->addToObject();
- }
- QML_END_INSTR(StoreV8Binding)
-
- QML_BEGIN_INSTR(StoreValueSource)
- QObject *obj = objects.pop();
- QDeclarativePropertyValueSource *vs = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.castValue);
- QObject *target = objects.at(objects.count() - 1 - instr.owner);
-
- obj->setParent(target);
- vs->setTarget(QDeclarativePropertyPrivate::restore(target, instr.property, CTXT));
- QML_END_INSTR(StoreValueSource)
-
- QML_BEGIN_INSTR(StoreValueInterceptor)
- QObject *obj = objects.pop();
- QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.castValue);
- QObject *target = objects.at(objects.count() - 1 - instr.owner);
- QDeclarativeProperty prop =
- QDeclarativePropertyPrivate::restore(target, instr.property, CTXT);
- obj->setParent(target);
- vi->setTarget(prop);
- QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
- mo->registerInterceptor(prop.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi);
- QML_END_INSTR(StoreValueInterceptor)
-
- QML_BEGIN_INSTR(StoreObjectQList)
- QObject *assign = objects.pop();
-
- const List &list = lists.top();
- list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, assign);
- QML_END_INSTR(StoreObjectQList)
-
- QML_BEGIN_INSTR(AssignObjectList)
- // This is only used for assigning interfaces
- QObject *assign = objects.pop();
- const List &list = lists.top();
-
- int type = list.type;
-
- void *ptr = 0;
-
- const char *iid = QDeclarativeMetaType::interfaceIId(type);
- if (iid)
- ptr = assign->qt_metacast(iid);
- if (!ptr)
- VME_EXCEPTION(tr("Cannot assign object to list"), instr.line);
-
-
- list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, ptr);
- QML_END_INSTR(AssignObjectList)
-
- QML_BEGIN_INSTR(StoreInterface)
- QObject *assign = objects.pop();
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- int coreIdx = instr.propertyIndex;
- QMetaProperty prop = target->metaObject()->property(coreIdx);
- int t = prop.userType();
- const char *iid = QDeclarativeMetaType::interfaceIId(t);
- bool ok = false;
- if (iid) {
- void *ptr = assign->qt_metacast(iid);
- if (ptr) {
- void *a[] = { &ptr, 0, &status, &flags };
- QMetaObject::metacall(target,
- QMetaObject::WriteProperty,
- coreIdx, a);
- ok = true;
- }
- }
-
- if (!ok)
- VME_EXCEPTION(tr("Cannot assign object to interface property"), instr.line);
- QML_END_INSTR(StoreInterface)
-
- QML_BEGIN_INSTR(FetchAttached)
- QObject *target = objects.top();
-
- QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.id, target);
-
- if (!qmlObject)
- VME_EXCEPTION(tr("Unable to create attached object"), instr.line);
-
- objects.push(qmlObject);
- QML_END_INSTR(FetchAttached)
-
- QML_BEGIN_INSTR(FetchQList)
- QObject *target = objects.top();
-
- lists.push(List(instr.type));
-
- void *a[1];
- a[0] = (void *)&(lists.top().qListProperty);
- QMetaObject::metacall(target, QMetaObject::ReadProperty,
- instr.property, a);
- QML_END_INSTR(FetchQList)
-
- QML_BEGIN_INSTR(FetchObject)
- QObject *target = objects.top();
-
- QObject *obj = 0;
- // NOTE: This assumes a cast to QObject does not alter the
- // object pointer
- void *a[1];
- a[0] = &obj;
- QMetaObject::metacall(target, QMetaObject::ReadProperty,
- instr.property, a);
-
- if (!obj)
- VME_EXCEPTION(tr("Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.property).name())), instr.line);
-
- objects.push(obj);
- QML_END_INSTR(FetchObject)
-
- QML_BEGIN_INSTR(PopQList)
- lists.pop();
- QML_END_INSTR(PopQList)
-
- QML_BEGIN_INSTR(Defer)
- if (instr.deferCount) {
- QObject *target = objects.top();
- QDeclarativeData *data =
- QDeclarativeData::get(target, true);
- COMP->addref();
- data->deferredComponent = COMP;
- data->deferredIdx = INSTRUCTIONSTREAM - COMP->bytecode.constData();
- INSTRUCTIONSTREAM += instr.deferCount;
- }
- QML_END_INSTR(Defer)
-
- QML_BEGIN_INSTR(PopFetchedObject)
- objects.pop();
- QML_END_INSTR(PopFetchedObject)
-
- QML_BEGIN_INSTR(FetchValueType)
- QObject *target = objects.top();
-
- if (instr.bindingSkipList != 0) {
- // Possibly need to clear bindings
- QDeclarativeData *targetData = QDeclarativeData::get(target);
- if (targetData) {
- QDeclarativeAbstractBinding *binding =
- QDeclarativePropertyPrivate::binding(target, instr.property, -1);
-
- if (binding && binding->bindingType() != QDeclarativeAbstractBinding::ValueTypeProxy) {
- QDeclarativePropertyPrivate::setBinding(target, instr.property, -1, 0);
- binding->destroy();
- } else if (binding) {
- QDeclarativeValueTypeProxyBinding *proxy =
- static_cast<QDeclarativeValueTypeProxyBinding *>(binding);
- proxy->removeBindings(instr.bindingSkipList);
- }
- }
- }
-
- QDeclarativeValueType *valueHandler = ep->valueTypes[instr.type];
- valueHandler->read(target, instr.property);
- objects.push(valueHandler);
- QML_END_INSTR(FetchValueType)
-
- QML_BEGIN_INSTR(PopValueType)
- QDeclarativeValueType *valueHandler =
- static_cast<QDeclarativeValueType *>(objects.pop());
- QObject *target = objects.top();
- valueHandler->write(target, instr.property, QDeclarativePropertyPrivate::BypassInterceptor);
- QML_END_INSTR(PopValueType)
-
-#ifdef QML_THREADED_VME_INTERPRETER
- // nothing to do
-#else
- default:
- qFatal("QDeclarativeCompiledData: Internal error - unknown instruction %d", genericInstr->common.instructionType);
- break;
- }
- }
-#endif
-
-exceptionExit:
- Q_ASSERT(!states.isEmpty());
- Q_ASSERT(!errors->isEmpty());
-
- reset();
-
- return 0;
-
-normalExit:
- Q_ASSERT(objects.count() == 1);
-
- QObject *rv = objects.top();
-
- objects.deallocate();
- lists.deallocate();
- states.clear();
-
- return rv;
-}
-
-void QDeclarativeVME::reset()
-{
- Q_ASSERT(!states.isEmpty() || objects.isEmpty());
-
- QRecursionWatcher<QDeclarativeVME, &QDeclarativeVME::recursion> watcher(this);
-
- if (!objects.isEmpty() && !(states.at(0).flags & State::Deferred))
- delete objects.at(0);
-
- if (!rootContext.isNull())
- rootContext->activeVMEData = 0;
-
- // Remove the QDeclarativeParserStatus and QDeclarativeAbstractBinding back pointers
- blank(parserStatus);
- blank(bindValues);
-
- while (componentAttached) {
- QDeclarativeComponentAttached *a = componentAttached;
- a->rem();
- }
-
- engine = 0;
- objects.deallocate();
- lists.deallocate();
- bindValues.deallocate();
- parserStatus.deallocate();
-#ifdef QML_ENABLE_TRACE
- parserStatusData.deallocate();
-#endif
- finalizeCallbacks.clear();
- states.clear();
- rootContext = 0;
- creationContext = 0;
-}
-
-// Must be called with a handle scope and context
-void QDeclarativeScriptData::initialize(QDeclarativeEngine *engine)
-{
- Q_ASSERT(m_program.IsEmpty());
- Q_ASSERT(engine);
- Q_ASSERT(!hasEngine());
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- QV8Engine *v8engine = ep->v8engine();
-
- // If compilation throws an error, a surrounding v8::TryCatch will record it.
- v8::Local<v8::Script> program = v8engine->qmlModeCompile(m_programSource.constData(),
- m_programSource.length(), urlString, 1);
- if (program.IsEmpty())
- return;
-
- m_program = qPersistentNew<v8::Script>(program);
- m_programSource.clear(); // We don't need this anymore
-
- addToEngine(engine);
-
- addref();
-}
-
-v8::Persistent<v8::Object> QDeclarativeVME::run(QDeclarativeContextData *parentCtxt, QDeclarativeScriptData *script)
-{
- if (script->m_loaded)
- return qPersistentNew<v8::Object>(script->m_value);
-
- Q_ASSERT(parentCtxt && parentCtxt->engine);
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(parentCtxt->engine);
- QV8Engine *v8engine = ep->v8engine();
-
- bool shared = script->pragmas & QDeclarativeScript::Object::ScriptBlock::Shared;
-
- QDeclarativeContextData *effectiveCtxt = parentCtxt;
- if (shared)
- effectiveCtxt = 0;
-
- // Create the script context if required
- QDeclarativeContextData *ctxt = new QDeclarativeContextData;
- ctxt->isInternal = true;
- ctxt->isJSContext = true;
- if (shared)
- ctxt->isPragmaLibraryContext = true;
- else
- ctxt->isPragmaLibraryContext = parentCtxt->isPragmaLibraryContext;
- ctxt->url = script->url;
- ctxt->urlString = script->urlString;
-
- // For backward compatibility, if there are no imports, we need to use the
- // imports from the parent context. See QTBUG-17518.
- if (!script->importCache->isEmpty()) {
- ctxt->imports = script->importCache;
- } else if (effectiveCtxt) {
- ctxt->imports = effectiveCtxt->imports;
- ctxt->importedScripts = effectiveCtxt->importedScripts;
- for (int ii = 0; ii < ctxt->importedScripts.count(); ++ii)
- ctxt->importedScripts[ii] = qPersistentNew<v8::Object>(ctxt->importedScripts[ii]);
- }
-
- if (ctxt->imports) {
- ctxt->imports->addref();
- }
-
- if (effectiveCtxt) {
- ctxt->setParent(effectiveCtxt, true);
- } else {
- ctxt->engine = parentCtxt->engine; // Fix for QTBUG-21620
- }
-
- for (int ii = 0; ii < script->scripts.count(); ++ii) {
- ctxt->importedScripts << run(ctxt, script->scripts.at(ii)->scriptData());
- }
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(v8engine->context());
-
- v8::TryCatch try_catch;
- if (!script->isInitialized())
- script->initialize(parentCtxt->engine);
-
- v8::Local<v8::Object> qmlglobal = v8engine->qmlScope(ctxt, 0);
-
- if (!script->m_program.IsEmpty()) {
- script->m_program->Run(qmlglobal);
- } else {
- // Compilation failed.
- Q_ASSERT(try_catch.HasCaught());
- }
-
- v8::Persistent<v8::Object> rv;
-
- if (try_catch.HasCaught()) {
- v8::Local<v8::Message> message = try_catch.Message();
- if (!message.IsEmpty()) {
- QDeclarativeError error;
- QDeclarativeExpressionPrivate::exceptionToError(message, error);
- ep->warning(error);
- }
- }
-
- rv = qPersistentNew<v8::Object>(qmlglobal);
- if (shared) {
- script->m_value = qPersistentNew<v8::Object>(qmlglobal);
- script->m_loaded = true;
- }
-
- return rv;
-}
-
-#ifdef QML_THREADED_VME_INTERPRETER
-void **QDeclarativeVME::instructionJumpTable()
-{
- static void **jumpTable = 0;
- if (!jumpTable) {
- QDeclarativeVME dummy;
- QDeclarativeVME::Interrupt i;
- dummy.run(0, i, &jumpTable);
- }
- return jumpTable;
-}
-#endif
-
-QDeclarativeContextData *QDeclarativeVME::complete(const Interrupt &interrupt)
-{
- Q_ASSERT(engine ||
- (bindValues.isEmpty() &&
- parserStatus.isEmpty() &&
- componentAttached == 0 &&
- rootContext.isNull() &&
- finalizeCallbacks.isEmpty()));
-
- if (!engine)
- return 0;
-
- QDeclarativeTrace trace("VME Complete");
-#ifdef QML_ENABLE_TRACE
- trace.addDetail("URL", rootComponent->url);
-#endif
-
- ActiveVMERestorer restore(this, QDeclarativeEnginePrivate::get(engine));
- QRecursionWatcher<QDeclarativeVME, &QDeclarativeVME::recursion> watcher(this);
-
- {
- QDeclarativeTrace trace("VME Binding Enable");
- trace.event("begin binding eval");
- while (!bindValues.isEmpty()) {
- QDeclarativeAbstractBinding *b = bindValues.pop();
-
- if(b) {
- b->m_mePtr = 0;
- b->setEnabled(true, QDeclarativePropertyPrivate::BypassInterceptor |
- QDeclarativePropertyPrivate::DontRemoveBinding);
- }
-
- if (watcher.hasRecursed() || interrupt.shouldInterrupt())
- return 0;
- }
- bindValues.deallocate();
- }
-
- {
- QDeclarativeTrace trace("VME Component Complete");
- while (!parserStatus.isEmpty()) {
- QDeclarativeParserStatus *status = parserStatus.pop();
-#ifdef QML_ENABLE_TRACE
- QDeclarativeData *data = parserStatusData.pop();
-#endif
-
- if (status && status->d) {
- status->d = 0;
-#ifdef QML_ENABLE_TRACE
- QDeclarativeTrace trace("Component complete");
- trace.addDetail("URL", data->outerContext->url);
- trace.addDetail("Line", data->lineNumber);
-#endif
- status->componentComplete();
- }
-
- if (watcher.hasRecursed() || interrupt.shouldInterrupt())
- return 0;
- }
- parserStatus.deallocate();
- }
-
- {
- QDeclarativeTrace trace("VME Finalize Callbacks");
- for (int ii = 0; ii < finalizeCallbacks.count(); ++ii) {
- QDeclarativeEnginePrivate::FinalizeCallback callback = finalizeCallbacks.at(ii);
- QObject *obj = callback.first;
- if (obj) {
- void *args[] = { 0 };
- QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, callback.second, args);
- }
- if (watcher.hasRecursed())
- return 0;
- }
- finalizeCallbacks.clear();
- }
-
- {
- QDeclarativeTrace trace("VME Component.onCompleted Callbacks");
- while (componentAttached) {
- QDeclarativeComponentAttached *a = componentAttached;
- a->rem();
- QDeclarativeData *d = QDeclarativeData::get(a->parent());
- Q_ASSERT(d);
- Q_ASSERT(d->context);
- a->add(&d->context->componentAttached);
- emit a->completed();
-
- if (watcher.hasRecursed() || interrupt.shouldInterrupt())
- return 0;
- }
- }
-
- QDeclarativeContextData *rv = rootContext;
-
- reset();
-
- if (rv) rv->activeVMEData = data;
-
- return rv;
-}
-
-void QDeclarativeVME::blank(QFiniteStack<QDeclarativeAbstractBinding *> &bs)
-{
- for (int ii = 0; ii < bs.count(); ++ii) {
- QDeclarativeAbstractBinding *b = bs.at(ii);
- if (b) b->m_mePtr = 0;
- }
-}
-
-void QDeclarativeVME::blank(QFiniteStack<QDeclarativeParserStatus *> &pss)
-{
- for (int ii = 0; ii < pss.count(); ++ii) {
- QDeclarativeParserStatus *ps = pss.at(ii);
- if(ps) ps->d = 0;
- }
-}
-
-QDeclarativeVMEGuard::QDeclarativeVMEGuard()
-: m_objectCount(0), m_objects(0), m_contextCount(0), m_contexts(0)
-{
-}
-
-QDeclarativeVMEGuard::~QDeclarativeVMEGuard()
-{
- clear();
-}
-
-void QDeclarativeVMEGuard::guard(QDeclarativeVME *vme)
-{
- clear();
-
- m_objectCount = vme->objects.count();
- m_objects = new QDeclarativeGuard<QObject>[m_objectCount];
- for (int ii = 0; ii < m_objectCount; ++ii)
- m_objects[ii] = vme->objects[ii];
-
- m_contextCount = (vme->rootContext.isNull()?0:1) + vme->states.count();
- m_contexts = new QDeclarativeGuardedContextData[m_contextCount];
- for (int ii = 0; ii < vme->states.count(); ++ii)
- m_contexts[ii] = vme->states.at(ii).context;
- if (!vme->rootContext.isNull())
- m_contexts[m_contextCount - 1] = vme->rootContext.contextData();
-}
-
-void QDeclarativeVMEGuard::clear()
-{
- delete [] m_objects;
- delete [] m_contexts;
-
- m_objectCount = 0;
- m_objects = 0;
- m_contextCount = 0;
- m_contexts = 0;
-}
-
-bool QDeclarativeVMEGuard::isOK() const
-{
- for (int ii = 0; ii < m_objectCount; ++ii)
- if (m_objects[ii].isNull())
- return false;
-
- for (int ii = 0; ii < m_contextCount; ++ii)
- if (m_contexts[ii].isNull())
- return false;
-
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativevme_p.h b/src/declarative/qml/qdeclarativevme_p.h
deleted file mode 100644
index 1f2f861314..0000000000
--- a/src/declarative/qml/qdeclarativevme_p.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEVME_P_H
-#define QDECLARATIVEVME_P_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 "qdeclarativeerror.h"
-#include <private/qbitfield_p.h>
-#include "qdeclarativeinstruction_p.h"
-#include <private/qrecursionwatcher_p.h>
-
-#include <QtCore/QStack>
-#include <QtCore/QString>
-#include <QtCore/qelapsedtimer.h>
-#include <QtCore/qcoreapplication.h>
-
-#include <private/qv8_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qfinitestack_p.h>
-
-#include <private/qdeclarativetrace_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-class QJSValue;
-class QDeclarativeScriptData;
-class QDeclarativeCompiledData;
-class QDeclarativeCompiledData;
-class QDeclarativeContextData;
-
-namespace QDeclarativeVMETypes {
- struct List
- {
- List() : type(0) {}
- List(int t) : type(t) {}
-
- int type;
- QDeclarativeListProperty<void> qListProperty;
- };
-}
-Q_DECLARE_TYPEINFO(QDeclarativeVMETypes::List, Q_PRIMITIVE_TYPE | Q_MOVABLE_TYPE);
-
-class QDeclarativeVME
-{
- Q_DECLARE_TR_FUNCTIONS(QDeclarativeVME)
-public:
- class Interrupt {
- public:
- inline Interrupt();
- inline Interrupt(volatile bool *runWhile, int nsecs=0);
- inline Interrupt(int nsecs);
-
- inline void reset();
- inline bool shouldInterrupt() const;
- private:
- enum Mode { None, Time, Flag };
- Mode mode;
- struct {
- QElapsedTimer timer;
- int nsecs;
- };
- volatile bool *runWhile;
- };
-
- QDeclarativeVME() : data(0), componentAttached(0) {}
- QDeclarativeVME(void *data) : data(data), componentAttached(0) {}
-
- void *data;
- QDeclarativeComponentAttached *componentAttached;
- QList<QDeclarativeEnginePrivate::FinalizeCallback> finalizeCallbacks;
-
- void init(QDeclarativeContextData *, QDeclarativeCompiledData *, int start,
- QDeclarativeContextData * = 0);
- bool initDeferred(QObject *);
- void reset();
-
- QObject *execute(QList<QDeclarativeError> *errors, const Interrupt & = Interrupt());
- QDeclarativeContextData *complete(const Interrupt & = Interrupt());
-
-private:
- friend class QDeclarativeVMEGuard;
-
- QObject *run(QList<QDeclarativeError> *errors, const Interrupt &
-#ifdef QML_THREADED_VME_INTERPRETER
- , void ***storeJumpTable = 0
-#endif
- );
- v8::Persistent<v8::Object> run(QDeclarativeContextData *, QDeclarativeScriptData *);
-
-#ifdef QML_THREADED_VME_INTERPRETER
- static void **instructionJumpTable();
- friend class QDeclarativeCompiledData;
-#endif
-
- QDeclarativeEngine *engine;
- QRecursionNode recursion;
-
-#ifdef QML_ENABLE_TRACE
- QDeclarativeCompiledData *rootComponent;
-#endif
-
- QFiniteStack<QObject *> objects;
- QFiniteStack<QDeclarativeVMETypes::List> lists;
-
- QFiniteStack<QDeclarativeAbstractBinding *> bindValues;
- QFiniteStack<QDeclarativeParserStatus *> parserStatus;
-#ifdef QML_ENABLE_TRACE
- QFiniteStack<QDeclarativeData *> parserStatusData;
-#endif
-
- QDeclarativeGuardedContextData rootContext;
- QDeclarativeGuardedContextData creationContext;
-
- struct State {
- enum Flag { Deferred = 0x00000001 };
-
- State() : flags(0), context(0), compiledData(0), instructionStream(0) {}
- quint32 flags;
- QDeclarativeContextData *context;
- QDeclarativeCompiledData *compiledData;
- const char *instructionStream;
- QBitField bindingSkipList;
- };
-
- QStack<State> states;
-
- static void blank(QFiniteStack<QDeclarativeParserStatus *> &);
- static void blank(QFiniteStack<QDeclarativeAbstractBinding *> &);
-};
-
-// Used to check that a QDeclarativeVME that is interrupted mid-execution
-// is still valid. Checks all the objects and contexts have not been
-// deleted.
-class QDeclarativeVMEGuard
-{
-public:
- QDeclarativeVMEGuard();
- ~QDeclarativeVMEGuard();
-
- void guard(QDeclarativeVME *);
- void clear();
-
- bool isOK() const;
-
-private:
- int m_objectCount;
- QDeclarativeGuard<QObject> *m_objects;
- int m_contextCount;
- QDeclarativeGuardedContextData *m_contexts;
-};
-
-QDeclarativeVME::Interrupt::Interrupt()
- : mode(None), nsecs(0), runWhile(0)
-{
-}
-
-QDeclarativeVME::Interrupt::Interrupt(volatile bool *runWhile, int nsecs)
- : mode(Flag), nsecs(nsecs), runWhile(runWhile)
-{
-}
-
-QDeclarativeVME::Interrupt::Interrupt(int nsecs)
- : mode(Time), nsecs(nsecs), runWhile(0)
-{
-}
-
-void QDeclarativeVME::Interrupt::reset()
-{
- if (mode == Time || nsecs)
- timer.start();
-}
-
-bool QDeclarativeVME::Interrupt::shouldInterrupt() const
-{
- if (mode == None) {
- return false;
- } else if (mode == Time) {
- return timer.nsecsElapsed() > nsecs;
- } else if (mode == Flag) {
- return !*runWhile || (nsecs && timer.nsecsElapsed() > nsecs);
- } else {
- return false;
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEVME_P_H
diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp
deleted file mode 100644
index f7361eb2ce..0000000000
--- a/src/declarative/qml/qdeclarativevmemetaobject.cpp
+++ /dev/null
@@ -1,1110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativevmemetaobject_p.h"
-
-
-#include "qdeclarative.h"
-#include <private/qdeclarativerefcount_p.h>
-#include "qdeclarativeexpression.h"
-#include "qdeclarativeexpression_p.h"
-#include "qdeclarativecontext_p.h"
-#include "qdeclarativebinding_p.h"
-#include "qdeclarativepropertyvalueinterceptor_p.h"
-
-#include <private/qv8variantresource_p.h>
-
-Q_DECLARE_METATYPE(QJSValue);
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeVMEVariant
-{
-public:
- inline QDeclarativeVMEVariant();
- inline ~QDeclarativeVMEVariant();
-
- inline const void *dataPtr() const;
- inline void *dataPtr();
- inline int dataType() const;
-
- inline QObject *asQObject();
- inline const QVariant &asQVariant();
- inline int asInt();
- inline bool asBool();
- inline double asDouble();
- inline const QString &asQString();
- inline const QUrl &asQUrl();
- inline const QColor &asQColor();
- inline const QTime &asQTime();
- inline const QDate &asQDate();
- inline const QDateTime &asQDateTime();
- inline const QJSValue &asQJSValue();
-
- inline void setValue(QObject *);
- inline void setValue(const QVariant &);
- inline void setValue(int);
- inline void setValue(bool);
- inline void setValue(double);
- inline void setValue(const QString &);
- inline void setValue(const QUrl &);
- inline void setValue(const QColor &);
- inline void setValue(const QTime &);
- inline void setValue(const QDate &);
- inline void setValue(const QDateTime &);
- inline void setValue(const QJSValue &);
-private:
- int type;
- void *data[4]; // Large enough to hold all types
-
- inline void cleanup();
-};
-
-class QDeclarativeVMEMetaObjectEndpoint : public QDeclarativeNotifierEndpoint
-{
-public:
- QDeclarativeVMEMetaObjectEndpoint();
- static void vmecallback(QDeclarativeNotifierEndpoint *);
- void tryConnect();
-
- QFlagPointer<QDeclarativeVMEMetaObject> metaObject;
-};
-
-
-QDeclarativeVMEVariant::QDeclarativeVMEVariant()
-: type(QVariant::Invalid)
-{
-}
-
-QDeclarativeVMEVariant::~QDeclarativeVMEVariant()
-{
- cleanup();
-}
-
-void QDeclarativeVMEVariant::cleanup()
-{
- if (type == QVariant::Invalid) {
- } else if (type == QMetaType::Int ||
- type == QMetaType::Bool ||
- type == QMetaType::Double) {
- type = QVariant::Invalid;
- } else if (type == QMetaType::QObjectStar) {
- ((QDeclarativeGuard<QObject>*)dataPtr())->~QDeclarativeGuard<QObject>();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QString) {
- ((QString *)dataPtr())->~QString();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QUrl) {
- ((QUrl *)dataPtr())->~QUrl();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QColor) {
- ((QColor *)dataPtr())->~QColor();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QTime) {
- ((QTime *)dataPtr())->~QTime();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QDate) {
- ((QDate *)dataPtr())->~QDate();
- type = QVariant::Invalid;
- } else if (type == QMetaType::QDateTime) {
- ((QDateTime *)dataPtr())->~QDateTime();
- type = QVariant::Invalid;
- } else if (type == qMetaTypeId<QVariant>()) {
- ((QVariant *)dataPtr())->~QVariant();
- type = QVariant::Invalid;
- } else if (type == qMetaTypeId<QJSValue>()) {
- ((QJSValue *)dataPtr())->~QJSValue();
- type = QVariant::Invalid;
- }
-
-}
-
-int QDeclarativeVMEVariant::dataType() const
-{
- return type;
-}
-
-const void *QDeclarativeVMEVariant::dataPtr() const
-{
- return &data;
-}
-
-void *QDeclarativeVMEVariant::dataPtr()
-{
- return &data;
-}
-
-QObject *QDeclarativeVMEVariant::asQObject()
-{
- if (type != QMetaType::QObjectStar)
- setValue((QObject *)0);
-
- return *(QDeclarativeGuard<QObject> *)(dataPtr());
-}
-
-const QVariant &QDeclarativeVMEVariant::asQVariant()
-{
- if (type != QMetaType::QVariant)
- setValue(QVariant());
-
- return *(QVariant *)(dataPtr());
-}
-
-int QDeclarativeVMEVariant::asInt()
-{
- if (type != QMetaType::Int)
- setValue(int(0));
-
- return *(int *)(dataPtr());
-}
-
-bool QDeclarativeVMEVariant::asBool()
-{
- if (type != QMetaType::Bool)
- setValue(bool(false));
-
- return *(bool *)(dataPtr());
-}
-
-double QDeclarativeVMEVariant::asDouble()
-{
- if (type != QMetaType::Double)
- setValue(double(0));
-
- return *(double *)(dataPtr());
-}
-
-const QString &QDeclarativeVMEVariant::asQString()
-{
- if (type != QMetaType::QString)
- setValue(QString());
-
- return *(QString *)(dataPtr());
-}
-
-const QUrl &QDeclarativeVMEVariant::asQUrl()
-{
- if (type != QMetaType::QUrl)
- setValue(QUrl());
-
- return *(QUrl *)(dataPtr());
-}
-
-const QColor &QDeclarativeVMEVariant::asQColor()
-{
- if (type != QMetaType::QColor)
- setValue(QColor());
-
- return *(QColor *)(dataPtr());
-}
-
-const QTime &QDeclarativeVMEVariant::asQTime()
-{
- if (type != QMetaType::QTime)
- setValue(QTime());
-
- return *(QTime *)(dataPtr());
-}
-
-const QDate &QDeclarativeVMEVariant::asQDate()
-{
- if (type != QMetaType::QDate)
- setValue(QDate());
-
- return *(QDate *)(dataPtr());
-}
-
-const QDateTime &QDeclarativeVMEVariant::asQDateTime()
-{
- if (type != QMetaType::QDateTime)
- setValue(QDateTime());
-
- return *(QDateTime *)(dataPtr());
-}
-
-const QJSValue &QDeclarativeVMEVariant::asQJSValue()
-{
- if (type != qMetaTypeId<QJSValue>())
- setValue(QJSValue());
-
- return *(QJSValue *)(dataPtr());
-}
-
-void QDeclarativeVMEVariant::setValue(QObject *v)
-{
- if (type != QMetaType::QObjectStar) {
- cleanup();
- type = QMetaType::QObjectStar;
- new (dataPtr()) QDeclarativeGuard<QObject>();
- }
- *(QDeclarativeGuard<QObject>*)(dataPtr()) = v;
-}
-
-void QDeclarativeVMEVariant::setValue(const QVariant &v)
-{
- if (type != qMetaTypeId<QVariant>()) {
- cleanup();
- type = qMetaTypeId<QVariant>();
- new (dataPtr()) QVariant(v);
- } else {
- *(QVariant *)(dataPtr()) = v;
- }
-}
-
-void QDeclarativeVMEVariant::setValue(int v)
-{
- if (type != QMetaType::Int) {
- cleanup();
- type = QMetaType::Int;
- }
- *(int *)(dataPtr()) = v;
-}
-
-void QDeclarativeVMEVariant::setValue(bool v)
-{
- if (type != QMetaType::Bool) {
- cleanup();
- type = QMetaType::Bool;
- }
- *(bool *)(dataPtr()) = v;
-}
-
-void QDeclarativeVMEVariant::setValue(double v)
-{
- if (type != QMetaType::Double) {
- cleanup();
- type = QMetaType::Double;
- }
- *(double *)(dataPtr()) = v;
-}
-
-void QDeclarativeVMEVariant::setValue(const QString &v)
-{
- if (type != QMetaType::QString) {
- cleanup();
- type = QMetaType::QString;
- new (dataPtr()) QString(v);
- } else {
- *(QString *)(dataPtr()) = v;
- }
-}
-
-void QDeclarativeVMEVariant::setValue(const QUrl &v)
-{
- if (type != QMetaType::QUrl) {
- cleanup();
- type = QMetaType::QUrl;
- new (dataPtr()) QUrl(v);
- } else {
- *(QUrl *)(dataPtr()) = v;
- }
-}
-
-void QDeclarativeVMEVariant::setValue(const QColor &v)
-{
- if (type != QMetaType::QColor) {
- cleanup();
- type = QMetaType::QColor;
- new (dataPtr()) QColor(v);
- } else {
- *(QColor *)(dataPtr()) = v;
- }
-}
-
-void QDeclarativeVMEVariant::setValue(const QTime &v)
-{
- if (type != QMetaType::QTime) {
- cleanup();
- type = QMetaType::QTime;
- new (dataPtr()) QTime(v);
- } else {
- *(QTime *)(dataPtr()) = v;
- }
-}
-
-void QDeclarativeVMEVariant::setValue(const QDate &v)
-{
- if (type != QMetaType::QDate) {
- cleanup();
- type = QMetaType::QDate;
- new (dataPtr()) QDate(v);
- } else {
- *(QDate *)(dataPtr()) = v;
- }
-}
-
-void QDeclarativeVMEVariant::setValue(const QDateTime &v)
-{
- if (type != QMetaType::QDateTime) {
- cleanup();
- type = QMetaType::QDateTime;
- new (dataPtr()) QDateTime(v);
- } else {
- *(QDateTime *)(dataPtr()) = v;
- }
-}
-
-void QDeclarativeVMEVariant::setValue(const QJSValue &v)
-{
- if (type != qMetaTypeId<QJSValue>()) {
- cleanup();
- type = qMetaTypeId<QJSValue>();
- new (dataPtr()) QJSValue(v);
- } else {
- *(QJSValue *)(dataPtr()) = v;
- }
-}
-
-QDeclarativeVMEMetaObjectEndpoint::QDeclarativeVMEMetaObjectEndpoint()
-{
- callback = &vmecallback;
-}
-
-void QDeclarativeVMEMetaObjectEndpoint::vmecallback(QDeclarativeNotifierEndpoint *e)
-{
- QDeclarativeVMEMetaObjectEndpoint *vmee = static_cast<QDeclarativeVMEMetaObjectEndpoint*>(e);
- vmee->tryConnect();
-}
-
-void QDeclarativeVMEMetaObjectEndpoint::tryConnect()
-{
- int aliasId = this - metaObject->aliasEndpoints;
-
- if (metaObject.flag()) {
- // This is actually notify
- int sigIdx = metaObject->methodOffset + aliasId + metaObject->metaData->propertyCount;
- QMetaObject::activate(metaObject->object, sigIdx, 0);
- } else {
- QDeclarativeVMEMetaData::AliasData *d = metaObject->metaData->aliasData() + aliasId;
- if (!d->isObjectAlias()) {
- QDeclarativeContextData *ctxt = metaObject->ctxt;
- QObject *target = ctxt->idValues[d->contextIdx].data();
- if (!target)
- return;
-
- QMetaProperty prop = target->metaObject()->property(d->propertyIndex());
- if (prop.hasNotifySignal())
- connect(target, prop.notifySignalIndex());
- }
-
- metaObject.setFlag();
- }
-}
-
-QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(QObject *obj,
- const QMetaObject *other,
- const QDeclarativeVMEMetaData *meta,
- QDeclarativeCompiledData *cdata)
-: QV8GCCallback::Node(GcPrologueCallback), object(obj), compiledData(cdata),
- ctxt(QDeclarativeData::get(obj, true)->outerContext), metaData(meta), data(0),
- aliasEndpoints(0), firstVarPropertyIndex(-1), varPropertiesInitialized(false),
- v8methods(0), parent(0)
-{
- compiledData->addref();
-
- *static_cast<QMetaObject *>(this) = *other;
- this->d.superdata = obj->metaObject();
-
- QObjectPrivate *op = QObjectPrivate::get(obj);
- if (op->metaObject)
- parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject);
- op->metaObject = this;
-
- propOffset = QAbstractDynamicMetaObject::propertyOffset();
- methodOffset = QAbstractDynamicMetaObject::methodOffset();
-
- data = new QDeclarativeVMEVariant[metaData->propertyCount - metaData->varPropertyCount];
-
- aConnected.resize(metaData->aliasCount);
- int list_type = qMetaTypeId<QDeclarativeListProperty<QObject> >();
-
- // ### Optimize
- for (int ii = 0; ii < metaData->propertyCount - metaData->varPropertyCount; ++ii) {
- int t = (metaData->propertyData() + ii)->propertyType;
- if (t == list_type) {
- listProperties.append(List(methodOffset + ii));
- data[ii].setValue(listProperties.count() - 1);
- }
- }
-
- firstVarPropertyIndex = metaData->propertyCount - metaData->varPropertyCount;
- if (metaData->varPropertyCount)
- QV8GCCallback::addGcCallbackNode(this);
-}
-
-QDeclarativeVMEMetaObject::~QDeclarativeVMEMetaObject()
-{
- compiledData->release();
- delete parent;
- delete [] data;
- delete [] aliasEndpoints;
-
- for (int ii = 0; v8methods && ii < metaData->methodCount; ++ii) {
- qPersistentDispose(v8methods[ii]);
- }
- delete [] v8methods;
-
- if (metaData->varPropertyCount)
- qPersistentDispose(varProperties); // if not weak, will not have been cleaned up by the callback.
-}
-
-int QDeclarativeVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
-{
- int id = _id;
- if(c == QMetaObject::WriteProperty) {
- int flags = *reinterpret_cast<int*>(a[3]);
- if (!(flags & QDeclarativePropertyPrivate::BypassInterceptor)
- && !aInterceptors.isEmpty()
- && aInterceptors.testBit(id)) {
- QPair<int, QDeclarativePropertyValueInterceptor*> pair = interceptors.value(id);
- int valueIndex = pair.first;
- QDeclarativePropertyValueInterceptor *vi = pair.second;
- int type = property(id).userType();
-
- if (type != QVariant::Invalid) {
- if (valueIndex != -1) {
- QDeclarativeEnginePrivate *ep = ctxt?QDeclarativeEnginePrivate::get(ctxt->engine):0;
- QDeclarativeValueType *valueType = 0;
- if (ep) valueType = ep->valueTypes[type];
- else valueType = QDeclarativeValueTypeFactory::valueType(type);
- Q_ASSERT(valueType);
-
- valueType->setValue(QVariant(type, a[0]));
- QMetaProperty valueProp = valueType->metaObject()->property(valueIndex);
- vi->write(valueProp.read(valueType));
-
- if (!ep) delete valueType;
- return -1;
- } else {
- vi->write(QVariant(type, a[0]));
- return -1;
- }
- }
- }
- }
- if (c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty || c == QMetaObject::ResetProperty) {
- if (id >= propOffset) {
- id -= propOffset;
-
- if (id < metaData->propertyCount) {
- int t = (metaData->propertyData() + id)->propertyType;
- bool needActivate = false;
-
- if (id >= firstVarPropertyIndex) {
- Q_ASSERT(t == QMetaType::QVariant);
- // the context can be null if accessing var properties from cpp after re-parenting an item.
- QDeclarativeEnginePrivate *ep = (ctxt == 0 || ctxt->engine == 0) ? 0 : QDeclarativeEnginePrivate::get(ctxt->engine);
- QV8Engine *v8e = (ep == 0) ? 0 : ep->v8engine();
- if (v8e) {
- v8::HandleScope handleScope;
- v8::Context::Scope contextScope(v8e->context());
- if (c == QMetaObject::ReadProperty) {
- *reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id);
- } else if (c == QMetaObject::WriteProperty) {
- writeProperty(id, *reinterpret_cast<QVariant *>(a[0]));
- }
- } else if (c == QMetaObject::ReadProperty) {
- // if the context was disposed, we just return an invalid variant from read.
- *reinterpret_cast<QVariant *>(a[0]) = QVariant();
- }
-
- } else {
-
- if (c == QMetaObject::ReadProperty) {
- switch(t) {
- case QVariant::Int:
- *reinterpret_cast<int *>(a[0]) = data[id].asInt();
- break;
- case QVariant::Bool:
- *reinterpret_cast<bool *>(a[0]) = data[id].asBool();
- break;
- case QVariant::Double:
- *reinterpret_cast<double *>(a[0]) = data[id].asDouble();
- break;
- case QVariant::String:
- *reinterpret_cast<QString *>(a[0]) = data[id].asQString();
- break;
- case QVariant::Url:
- *reinterpret_cast<QUrl *>(a[0]) = data[id].asQUrl();
- break;
- case QVariant::Color:
- *reinterpret_cast<QColor *>(a[0]) = data[id].asQColor();
- break;
- case QVariant::Date:
- *reinterpret_cast<QDate *>(a[0]) = data[id].asQDate();
- break;
- case QVariant::DateTime:
- *reinterpret_cast<QDateTime *>(a[0]) = data[id].asQDateTime();
- break;
- case QMetaType::QObjectStar:
- *reinterpret_cast<QObject **>(a[0]) = data[id].asQObject();
- break;
- case QMetaType::QVariant:
- *reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id);
- break;
- default:
- break;
- }
- if (t == qMetaTypeId<QDeclarativeListProperty<QObject> >()) {
- int listIndex = data[id].asInt();
- const List *list = &listProperties.at(listIndex);
- *reinterpret_cast<QDeclarativeListProperty<QObject> *>(a[0]) =
- QDeclarativeListProperty<QObject>(object, (void *)list,
- list_append, list_count, list_at,
- list_clear);
- }
-
- } else if (c == QMetaObject::WriteProperty) {
-
- switch(t) {
- case QVariant::Int:
- needActivate = *reinterpret_cast<int *>(a[0]) != data[id].asInt();
- data[id].setValue(*reinterpret_cast<int *>(a[0]));
- break;
- case QVariant::Bool:
- needActivate = *reinterpret_cast<bool *>(a[0]) != data[id].asBool();
- data[id].setValue(*reinterpret_cast<bool *>(a[0]));
- break;
- case QVariant::Double:
- needActivate = *reinterpret_cast<double *>(a[0]) != data[id].asDouble();
- data[id].setValue(*reinterpret_cast<double *>(a[0]));
- break;
- case QVariant::String:
- needActivate = *reinterpret_cast<QString *>(a[0]) != data[id].asQString();
- data[id].setValue(*reinterpret_cast<QString *>(a[0]));
- break;
- case QVariant::Url:
- needActivate = *reinterpret_cast<QUrl *>(a[0]) != data[id].asQUrl();
- data[id].setValue(*reinterpret_cast<QUrl *>(a[0]));
- break;
- case QVariant::Color:
- needActivate = *reinterpret_cast<QColor *>(a[0]) != data[id].asQColor();
- data[id].setValue(*reinterpret_cast<QColor *>(a[0]));
- break;
- case QVariant::Date:
- needActivate = *reinterpret_cast<QDate *>(a[0]) != data[id].asQDate();
- data[id].setValue(*reinterpret_cast<QDate *>(a[0]));
- break;
- case QVariant::DateTime:
- needActivate = *reinterpret_cast<QDateTime *>(a[0]) != data[id].asQDateTime();
- data[id].setValue(*reinterpret_cast<QDateTime *>(a[0]));
- break;
- case QMetaType::QObjectStar:
- needActivate = *reinterpret_cast<QObject **>(a[0]) != data[id].asQObject();
- data[id].setValue(*reinterpret_cast<QObject **>(a[0]));
- break;
- case QMetaType::QVariant:
- writeProperty(id, *reinterpret_cast<QVariant *>(a[0]));
- break;
- default:
- break;
- }
- }
-
- }
-
- if (c == QMetaObject::WriteProperty && needActivate) {
- activate(object, methodOffset + id, 0);
- }
-
- return -1;
- }
-
- id -= metaData->propertyCount;
-
- if (id < metaData->aliasCount) {
-
- QDeclarativeVMEMetaData::AliasData *d = metaData->aliasData() + id;
-
- if (d->flags & QML_ALIAS_FLAG_PTR && c == QMetaObject::ReadProperty)
- *reinterpret_cast<void **>(a[0]) = 0;
-
- if (!ctxt) return -1;
-
- QDeclarativeContext *context = ctxt->asQDeclarativeContext();
- QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(context);
-
- QObject *target = ctxtPriv->data->idValues[d->contextIdx].data();
- if (!target)
- return -1;
-
- connectAlias(id);
-
- if (d->isObjectAlias()) {
- *reinterpret_cast<QObject **>(a[0]) = target;
- return -1;
- }
-
- // Remove binding (if any) on write
- if(c == QMetaObject::WriteProperty) {
- int flags = *reinterpret_cast<int*>(a[3]);
- if (flags & QDeclarativePropertyPrivate::RemoveBindingOnAliasWrite) {
- QDeclarativeData *targetData = QDeclarativeData::get(target);
- if (targetData && targetData->hasBindingBit(d->propertyIndex())) {
- QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::setBinding(target, d->propertyIndex(), d->isValueTypeAlias()?d->valueTypeIndex():-1, 0);
- if (binding) binding->destroy();
- }
- }
- }
-
- if (d->isValueTypeAlias()) {
- // Value type property
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(ctxt->engine);
-
- QDeclarativeValueType *valueType = ep->valueTypes[d->valueType()];
- Q_ASSERT(valueType);
-
- valueType->read(target, d->propertyIndex());
- int rv = QMetaObject::metacall(valueType, c, d->valueTypeIndex(), a);
-
- if (c == QMetaObject::WriteProperty)
- valueType->write(target, d->propertyIndex(), 0x00);
-
- return rv;
-
- } else {
- return QMetaObject::metacall(target, c, d->propertyIndex(), a);
- }
-
- }
- return -1;
-
- }
-
- } else if(c == QMetaObject::InvokeMetaMethod) {
-
- if (id >= methodOffset) {
-
- id -= methodOffset;
- int plainSignals = metaData->signalCount + metaData->propertyCount +
- metaData->aliasCount;
- if (id < plainSignals) {
- QMetaObject::activate(object, _id, a);
- return -1;
- }
-
- id -= plainSignals;
-
- if (id < metaData->methodCount) {
- if (!ctxt->engine)
- return -1; // We can't run the method
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(ctxt->engine);
- ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation.
-
- v8::Handle<v8::Function> function = method(id);
- if (function.IsEmpty()) {
- // The function was not compiled. There are some exceptional cases which the
- // expression rewriter does not rewrite properly (e.g., \r-terminated lines
- // are not rewritten correctly but this bug is deemed out-of-scope to fix for
- // performance reasons; see QTBUG-24064) and thus compilation will have failed.
- QDeclarativeError e;
- e.setDescription(QString(QLatin1String("Exception occurred during compilation of function: %1")).
- arg(QLatin1String(QMetaObject::method(_id).signature())));
- ep->warning(e);
- return -1; // The dynamic method with that id is not available.
- }
-
- QDeclarativeVMEMetaData::MethodData *data = metaData->methodData() + id;
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(ep->v8engine()->context());
- v8::Handle<v8::Value> *args = 0;
-
- if (data->parameterCount) {
- args = new v8::Handle<v8::Value>[data->parameterCount];
- for (int ii = 0; ii < data->parameterCount; ++ii)
- args[ii] = ep->v8engine()->fromVariant(*(QVariant *)a[ii + 1]);
- }
-
- v8::TryCatch try_catch;
-
- v8::Local<v8::Value> result = function->Call(ep->v8engine()->global(), data->parameterCount, args);
-
- QVariant rv;
- if (try_catch.HasCaught()) {
- QDeclarativeError error;
- QDeclarativeExpressionPrivate::exceptionToError(try_catch.Message(), error);
- if (error.isValid())
- ep->warning(error);
- if (a[0]) *(QVariant *)a[0] = QVariant();
- } else {
- if (a[0]) *(QVariant *)a[0] = ep->v8engine()->toVariant(result, 0);
- }
-
- ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete.
- return -1;
- }
- return -1;
- }
- }
-
- if (parent)
- return parent->metaCall(c, _id, a);
- else
- return object->qt_metacall(c, _id, a);
-}
-
-v8::Handle<v8::Function> QDeclarativeVMEMetaObject::method(int index)
-{
- if (!v8methods)
- v8methods = new v8::Persistent<v8::Function>[metaData->methodCount];
-
- if (v8methods[index].IsEmpty()) {
- QDeclarativeVMEMetaData::MethodData *data = metaData->methodData() + index;
-
- const char *body = ((const char*)metaData) + data->bodyOffset;
- int bodyLength = data->bodyLength;
-
- // XXX We should evaluate all methods in a single big script block to
- // improve the call time between dynamic methods defined on the same
- // object
- v8methods[index] = QDeclarativeExpressionPrivate::evalFunction(ctxt, object, body,
- bodyLength,
- ctxt->urlString,
- data->lineNumber);
- }
-
- return v8methods[index];
-}
-
-v8::Handle<v8::Value> QDeclarativeVMEMetaObject::readVarProperty(int id)
-{
- Q_ASSERT(id >= firstVarPropertyIndex);
-
- ensureVarPropertiesAllocated();
- return varProperties->Get(id - firstVarPropertyIndex);
-}
-
-QVariant QDeclarativeVMEMetaObject::readPropertyAsVariant(int id)
-{
- if (id >= firstVarPropertyIndex) {
- ensureVarPropertiesAllocated();
- return QDeclarativeEnginePrivate::get(ctxt->engine)->v8engine()->toVariant(varProperties->Get(id - firstVarPropertyIndex), -1);
- } else {
- if (data[id].dataType() == QMetaType::QObjectStar) {
- return QVariant::fromValue(data[id].asQObject());
- } else {
- return data[id].asQVariant();
- }
- }
-}
-
-void QDeclarativeVMEMetaObject::writeVarProperty(int id, v8::Handle<v8::Value> value)
-{
- Q_ASSERT(id >= firstVarPropertyIndex);
- ensureVarPropertiesAllocated();
-
- // Importantly, if the current value is a scarce resource, we need to ensure that it
- // gets automatically released by the engine if no other references to it exist.
- v8::Local<v8::Value> oldv = varProperties->Get(id - firstVarPropertyIndex);
- if (oldv->IsObject()) {
- QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(v8::Handle<v8::Object>::Cast(oldv));
- if (r) {
- r->removeVmePropertyReference();
- }
- }
-
- // And, if the new value is a scarce resource, we need to ensure that it does not get
- // automatically released by the engine until no other references to it exist.
- if (value->IsObject()) {
- QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(v8::Handle<v8::Object>::Cast(value));
- if (r) {
- r->addVmePropertyReference();
- }
- }
-
- // Write the value and emit change signal as appropriate.
- varProperties->Set(id - firstVarPropertyIndex, value);
- activate(object, methodOffset + id, 0);
-}
-
-void QDeclarativeVMEMetaObject::writeProperty(int id, const QVariant &value)
-{
- if (id >= firstVarPropertyIndex) {
- ensureVarPropertiesAllocated();
-
- // Importantly, if the current value is a scarce resource, we need to ensure that it
- // gets automatically released by the engine if no other references to it exist.
- v8::Local<v8::Value> oldv = varProperties->Get(id - firstVarPropertyIndex);
- if (oldv->IsObject()) {
- QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(v8::Handle<v8::Object>::Cast(oldv));
- if (r) {
- r->removeVmePropertyReference();
- }
- }
-
- // And, if the new value is a scarce resource, we need to ensure that it does not get
- // automatically released by the engine until no other references to it exist.
- v8::Handle<v8::Value> newv = QDeclarativeEnginePrivate::get(ctxt->engine)->v8engine()->fromVariant(value);
- if (newv->IsObject()) {
- QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(v8::Handle<v8::Object>::Cast(newv));
- if (r) {
- r->addVmePropertyReference();
- }
- }
-
- // Write the value and emit change signal as appropriate.
- QVariant currentValue = readPropertyAsVariant(id);
- varProperties->Set(id - firstVarPropertyIndex, newv);
- if ((currentValue.userType() != value.userType() || currentValue != value))
- activate(object, methodOffset + id, 0);
- } else {
- bool needActivate = false;
- if (value.userType() == QMetaType::QObjectStar) {
- QObject *o = qvariant_cast<QObject *>(value);
- needActivate = (data[id].dataType() != QMetaType::QObjectStar || data[id].asQObject() != o);
- data[id].setValue(qvariant_cast<QObject *>(value));
- } else {
- needActivate = (data[id].dataType() != qMetaTypeId<QVariant>() ||
- data[id].asQVariant().userType() != value.userType() ||
- data[id].asQVariant() != value);
- data[id].setValue(value);
- }
-
- if (needActivate)
- activate(object, methodOffset + id, 0);
- }
-}
-
-void QDeclarativeVMEMetaObject::listChanged(int id)
-{
- activate(object, methodOffset + id, 0);
-}
-
-void QDeclarativeVMEMetaObject::list_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
-{
- List *list = static_cast<List *>(prop->data);
- list->append(o);
- QMetaObject::activate(prop->object, list->notifyIndex, 0);
-}
-
-int QDeclarativeVMEMetaObject::list_count(QDeclarativeListProperty<QObject> *prop)
-{
- return static_cast<List *>(prop->data)->count();
-}
-
-QObject *QDeclarativeVMEMetaObject::list_at(QDeclarativeListProperty<QObject> *prop, int index)
-{
- return static_cast<List *>(prop->data)->at(index);
-}
-
-void QDeclarativeVMEMetaObject::list_clear(QDeclarativeListProperty<QObject> *prop)
-{
- List *list = static_cast<List *>(prop->data);
- list->clear();
- QMetaObject::activate(prop->object, list->notifyIndex, 0);
-}
-
-void QDeclarativeVMEMetaObject::registerInterceptor(int index, int valueIndex, QDeclarativePropertyValueInterceptor *interceptor)
-{
- if (aInterceptors.isEmpty())
- aInterceptors.resize(propertyCount() + metaData->propertyCount);
- aInterceptors.setBit(index);
- interceptors.insert(index, qMakePair(valueIndex, interceptor));
-}
-
-int QDeclarativeVMEMetaObject::vmeMethodLineNumber(int index)
-{
- if (index < methodOffset) {
- Q_ASSERT(parent);
- return static_cast<QDeclarativeVMEMetaObject *>(parent)->vmeMethodLineNumber(index);
- }
-
- int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
- Q_ASSERT(index >= (methodOffset + plainSignals) && index < (methodOffset + plainSignals + metaData->methodCount));
-
- int rawIndex = index - methodOffset - plainSignals;
-
- QDeclarativeVMEMetaData::MethodData *data = metaData->methodData() + rawIndex;
- return data->lineNumber;
-}
-
-v8::Handle<v8::Function> QDeclarativeVMEMetaObject::vmeMethod(int index)
-{
- if (index < methodOffset) {
- Q_ASSERT(parent);
- return static_cast<QDeclarativeVMEMetaObject *>(parent)->vmeMethod(index);
- }
- int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
- Q_ASSERT(index >= (methodOffset + plainSignals) && index < (methodOffset + plainSignals + metaData->methodCount));
- return method(index - methodOffset - plainSignals);
-}
-
-// Used by debugger
-void QDeclarativeVMEMetaObject::setVmeMethod(int index, v8::Persistent<v8::Function> value)
-{
- if (index < methodOffset) {
- Q_ASSERT(parent);
- return static_cast<QDeclarativeVMEMetaObject *>(parent)->setVmeMethod(index, value);
- }
- int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
- Q_ASSERT(index >= (methodOffset + plainSignals) && index < (methodOffset + plainSignals + metaData->methodCount));
-
- if (!v8methods)
- v8methods = new v8::Persistent<v8::Function>[metaData->methodCount];
-
- int methodIndex = index - methodOffset - plainSignals;
- if (!v8methods[methodIndex].IsEmpty())
- qPersistentDispose(v8methods[methodIndex]);
- v8methods[methodIndex] = value;
-}
-
-v8::Handle<v8::Value> QDeclarativeVMEMetaObject::vmeProperty(int index)
-{
- if (index < propOffset) {
- Q_ASSERT(parent);
- return static_cast<QDeclarativeVMEMetaObject *>(parent)->vmeProperty(index);
- }
- return readVarProperty(index - propOffset);
-}
-
-void QDeclarativeVMEMetaObject::setVMEProperty(int index, v8::Handle<v8::Value> v)
-{
- if (index < propOffset) {
- Q_ASSERT(parent);
- static_cast<QDeclarativeVMEMetaObject *>(parent)->setVMEProperty(index, v);
- return;
- }
- return writeVarProperty(index - propOffset, v);
-}
-
-void QDeclarativeVMEMetaObject::ensureVarPropertiesAllocated()
-{
- if (!varPropertiesInitialized)
- allocateVarPropertiesArray();
-}
-
-// see also: QV8GCCallback::garbageCollectorPrologueCallback()
-void QDeclarativeVMEMetaObject::allocateVarPropertiesArray()
-{
- v8::HandleScope handleScope;
- v8::Context::Scope cs(QDeclarativeEnginePrivate::get(ctxt->engine)->v8engine()->context());
- varProperties = qPersistentNew(v8::Array::New(metaData->varPropertyCount));
- varProperties.MakeWeak(static_cast<void*>(this), VarPropertiesWeakReferenceCallback);
- varPropertiesInitialized = true;
-}
-
-/*
- The "var" properties are stored in a v8::Array which will be strong persistent if the object has cpp-ownership
- and the root QObject in the parent chain does not have JS-ownership. In the weak persistent handle case,
- this callback will dispose the handle when the v8object which owns the lifetime of the var properties array
- is cleared as a result of all other handles to that v8object being released.
- See QV8GCCallback::garbageCollectorPrologueCallback() for more information.
- */
-void QDeclarativeVMEMetaObject::VarPropertiesWeakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter)
-{
- QDeclarativeVMEMetaObject *vmemo = static_cast<QDeclarativeVMEMetaObject*>(parameter);
- Q_ASSERT(vmemo);
- qPersistentDispose(object);
- vmemo->varProperties.Clear();
-}
-
-void QDeclarativeVMEMetaObject::GcPrologueCallback(QV8GCCallback::Node *node)
-{
- QDeclarativeVMEMetaObject *vmemo = static_cast<QDeclarativeVMEMetaObject*>(node);
- Q_ASSERT(vmemo);
- if (!vmemo->varPropertiesInitialized || vmemo->varProperties.IsEmpty() || !vmemo->ctxt || !vmemo->ctxt->engine)
- return;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(vmemo->ctxt->engine);
- ep->v8engine()->addRelationshipForGC(vmemo->object, vmemo->varProperties);
-}
-
-bool QDeclarativeVMEMetaObject::aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const
-{
- Q_ASSERT(index >= propOffset + metaData->propertyCount);
-
- *target = 0;
- *coreIndex = -1;
- *valueTypeIndex = -1;
-
- if (!ctxt)
- return false;
-
- QDeclarativeVMEMetaData::AliasData *d = metaData->aliasData() + (index - propOffset - metaData->propertyCount);
- QDeclarativeContext *context = ctxt->asQDeclarativeContext();
- QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(context);
-
- *target = ctxtPriv->data->idValues[d->contextIdx].data();
- if (!*target)
- return false;
-
- if (d->isObjectAlias()) {
- } else if (d->isValueTypeAlias()) {
- *coreIndex = d->propertyIndex();
- *valueTypeIndex = d->valueTypeIndex();
- } else {
- *coreIndex = d->propertyIndex();
- }
-
- return true;
-}
-
-void QDeclarativeVMEMetaObject::connectAlias(int aliasId)
-{
- if (!aConnected.testBit(aliasId)) {
-
- if (!aliasEndpoints)
- aliasEndpoints = new QDeclarativeVMEMetaObjectEndpoint[metaData->aliasCount];
-
- aConnected.setBit(aliasId);
-
- QDeclarativeVMEMetaData::AliasData *d = metaData->aliasData() + aliasId;
-
- QDeclarativeVMEMetaObjectEndpoint *endpoint = aliasEndpoints + aliasId;
- endpoint->metaObject = this;
-
- endpoint->connect(&ctxt->idValues[d->contextIdx].bindings);
-
- endpoint->tryConnect();
- }
-}
-
-void QDeclarativeVMEMetaObject::connectAliasSignal(int index)
-{
- int aliasId = (index - methodOffset) - metaData->propertyCount;
- if (aliasId < 0 || aliasId >= metaData->aliasCount)
- return;
-
- connectAlias(aliasId);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativevmemetaobject_p.h b/src/declarative/qml/qdeclarativevmemetaobject_p.h
deleted file mode 100644
index a8b7c4c359..0000000000
--- a/src/declarative/qml/qdeclarativevmemetaobject_p.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEVMEMETAOBJECT_P_H
-#define QDECLARATIVEVMEMETAOBJECT_P_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 "qdeclarative.h"
-
-#include <QtCore/QMetaObject>
-#include <QtCore/QBitArray>
-#include <QtCore/QPair>
-#include <QtGui/QColor>
-#include <QtCore/QDate>
-#include <QtCore/qlist.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-#include "qdeclarativeguard_p.h"
-#include "qdeclarativecompiler_p.h"
-#include "qdeclarativecontext_p.h"
-
-#include <private/qv8engine_p.h>
-
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#define QML_ALIAS_FLAG_PTR 0x00000001
-
-struct QDeclarativeVMEMetaData
-{
- short varPropertyCount;
- short propertyCount;
- short aliasCount;
- short signalCount;
- short methodCount;
- short dummyForAlignment; // Add padding to ensure that the following
- // AliasData/PropertyData/MethodData is int aligned.
-
- struct AliasData {
- int contextIdx;
- int propertyIdx;
- int flags;
-
- bool isObjectAlias() const {
- return propertyIdx == -1;
- }
- bool isPropertyAlias() const {
- return !isObjectAlias() && !(propertyIdx & 0xFF000000);
- }
- bool isValueTypeAlias() const {
- return !isObjectAlias() && (propertyIdx & 0xFF000000);
- }
- int propertyIndex() const {
- return propertyIdx & 0x0000FFFF;
- }
- int valueTypeIndex() const {
- return (propertyIdx & 0x00FF0000) >> 16;
- }
- int valueType() const {
- return ((unsigned int)propertyIdx) >> 24;
- }
- };
-
- struct PropertyData {
- int propertyType;
- };
-
- struct MethodData {
- int parameterCount;
- int bodyOffset;
- int bodyLength;
- int lineNumber;
- };
-
- PropertyData *propertyData() const {
- return (PropertyData *)(((const char *)this) + sizeof(QDeclarativeVMEMetaData));
- }
-
- AliasData *aliasData() const {
- return (AliasData *)(propertyData() + propertyCount);
- }
-
- MethodData *methodData() const {
- return (MethodData *)(aliasData() + aliasCount);
- }
-};
-
-class QV8QObjectWrapper;
-class QDeclarativeVMEVariant;
-class QDeclarativeRefCount;
-class QDeclarativeVMEMetaObjectEndpoint;
-class Q_AUTOTEST_EXPORT QDeclarativeVMEMetaObject : public QAbstractDynamicMetaObject,
- public QV8GCCallback::Node
-{
-public:
- QDeclarativeVMEMetaObject(QObject *obj, const QMetaObject *other, const QDeclarativeVMEMetaData *data,
- QDeclarativeCompiledData *compiledData);
- ~QDeclarativeVMEMetaObject();
-
- bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const;
- void registerInterceptor(int index, int valueIndex, QDeclarativePropertyValueInterceptor *interceptor);
- v8::Handle<v8::Function> vmeMethod(int index);
- int vmeMethodLineNumber(int index);
- void setVmeMethod(int index, v8::Persistent<v8::Function>);
- v8::Handle<v8::Value> vmeProperty(int index);
- void setVMEProperty(int index, v8::Handle<v8::Value> v);
-
- void connectAliasSignal(int index);
-
-protected:
- virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
-
-private:
- friend class QDeclarativeVMEMetaObjectEndpoint;
-
- QObject *object;
- QDeclarativeCompiledData *compiledData;
- QDeclarativeGuardedContextData ctxt;
-
- const QDeclarativeVMEMetaData *metaData;
- int propOffset;
- int methodOffset;
-
- QDeclarativeVMEVariant *data;
- QDeclarativeVMEMetaObjectEndpoint *aliasEndpoints;
-
- v8::Persistent<v8::Array> varProperties;
- int firstVarPropertyIndex;
- bool varPropertiesInitialized;
- static void VarPropertiesWeakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter);
- static void GcPrologueCallback(QV8GCCallback::Node *node);
- inline void allocateVarPropertiesArray();
- inline void ensureVarPropertiesAllocated();
-
- void connectAlias(int aliasId);
- QBitArray aConnected;
- QBitArray aInterceptors;
- QHash<int, QPair<int, QDeclarativePropertyValueInterceptor*> > interceptors;
-
- v8::Persistent<v8::Function> *v8methods;
- v8::Handle<v8::Function> method(int);
-
- v8::Handle<v8::Value> readVarProperty(int);
- void writeVarProperty(int, v8::Handle<v8::Value>);
- QVariant readPropertyAsVariant(int);
- void writeProperty(int, const QVariant &);
-
- QAbstractDynamicMetaObject *parent;
-
- void listChanged(int);
- class List : public QList<QObject*>
- {
- public:
- List(int lpi) : notifyIndex(lpi) {}
- int notifyIndex;
- };
- QList<List> listProperties;
-
- static void list_append(QDeclarativeListProperty<QObject> *, QObject *);
- static int list_count(QDeclarativeListProperty<QObject> *);
- static QObject *list_at(QDeclarativeListProperty<QObject> *, int);
- static void list_clear(QDeclarativeListProperty<QObject> *);
-
- friend class QV8GCCallback;
- friend class QV8QObjectWrapper;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEVMEMETAOBJECT_P_H
diff --git a/src/declarative/qml/qdeclarativewatcher.cpp b/src/declarative/qml/qdeclarativewatcher.cpp
deleted file mode 100644
index 1136134499..0000000000
--- a/src/declarative/qml/qdeclarativewatcher.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativewatcher_p.h"
-
-#include "qdeclarativeexpression.h"
-#include "qdeclarativecontext.h"
-#include "qdeclarative.h"
-
-#include <private/qdeclarativedebugservice_p.h>
-#include "qdeclarativeproperty_p.h"
-#include "qdeclarativevaluetype_p.h"
-
-#include <QtCore/qmetaobject.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeWatchProxy : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeWatchProxy(int id,
- QObject *object,
- int debugId,
- const QMetaProperty &prop,
- QDeclarativeWatcher *parent = 0);
-
- QDeclarativeWatchProxy(int id,
- QDeclarativeExpression *exp,
- int debugId,
- QDeclarativeWatcher *parent = 0);
-
-public slots:
- void notifyValueChanged();
-
-private:
- friend class QDeclarativeWatcher;
- int m_id;
- QDeclarativeWatcher *m_watch;
- QObject *m_object;
- int m_debugId;
- QMetaProperty m_property;
-
- QDeclarativeExpression *m_expr;
-};
-
-QDeclarativeWatchProxy::QDeclarativeWatchProxy(int id,
- QDeclarativeExpression *exp,
- int debugId,
- QDeclarativeWatcher *parent)
-: QObject(parent), m_id(id), m_watch(parent), m_object(0), m_debugId(debugId), m_expr(exp)
-{
- QObject::connect(m_expr, SIGNAL(valueChanged()), this, SLOT(notifyValueChanged()));
-}
-
-QDeclarativeWatchProxy::QDeclarativeWatchProxy(int id,
- QObject *object,
- int debugId,
- const QMetaProperty &prop,
- QDeclarativeWatcher *parent)
-: QObject(parent), m_id(id), m_watch(parent), m_object(object), m_debugId(debugId), m_property(prop), m_expr(0)
-{
- static int refreshIdx = -1;
- if(refreshIdx == -1)
- refreshIdx = QDeclarativeWatchProxy::staticMetaObject.indexOfMethod("notifyValueChanged()");
-
- if (prop.hasNotifySignal())
- QDeclarativePropertyPrivate::connect(m_object, prop.notifySignalIndex(), this, refreshIdx);
-}
-
-void QDeclarativeWatchProxy::notifyValueChanged()
-{
- QVariant v;
- if (m_expr)
- v = m_expr->evaluate();
- else if (QDeclarativeValueTypeFactory::isValueType(m_property.userType()))
- v = m_property.read(m_object);
-
- emit m_watch->propertyChanged(m_id, m_debugId, m_property, v);
-}
-
-
-QDeclarativeWatcher::QDeclarativeWatcher(QObject *parent)
- : QObject(parent)
-{
-}
-
-bool QDeclarativeWatcher::addWatch(int id, quint32 debugId)
-{
- QObject *object = QDeclarativeDebugService::objectForId(debugId);
- if (object) {
- int propCount = object->metaObject()->propertyCount();
- for (int ii=0; ii<propCount; ii++)
- addPropertyWatch(id, object, debugId, object->metaObject()->property(ii));
- return true;
- }
- return false;
-}
-
-bool QDeclarativeWatcher::addWatch(int id, quint32 debugId, const QByteArray &property)
-{
- QObject *object = QDeclarativeDebugService::objectForId(debugId);
- if (object) {
- int index = object->metaObject()->indexOfProperty(property.constData());
- if (index >= 0) {
- addPropertyWatch(id, object, debugId, object->metaObject()->property(index));
- return true;
- }
- }
- return false;
-}
-
-bool QDeclarativeWatcher::addWatch(int id, quint32 objectId, const QString &expr)
-{
- QObject *object = QDeclarativeDebugService::objectForId(objectId);
- QDeclarativeContext *context = qmlContext(object);
- if (context) {
- QDeclarativeExpression *exprObj = new QDeclarativeExpression(context, object, expr);
- exprObj->setNotifyOnValueChanged(true);
- QDeclarativeWatchProxy *proxy = new QDeclarativeWatchProxy(id, exprObj, objectId, this);
- exprObj->setParent(proxy);
- m_proxies[id].append(proxy);
- proxy->notifyValueChanged();
- return true;
- }
- return false;
-}
-
-void QDeclarativeWatcher::removeWatch(int id)
-{
- if (!m_proxies.contains(id))
- return;
-
- QList<QPointer<QDeclarativeWatchProxy> > proxies = m_proxies.take(id);
- qDeleteAll(proxies);
-}
-
-void QDeclarativeWatcher::addPropertyWatch(int id, QObject *object, quint32 debugId, const QMetaProperty &property)
-{
- QDeclarativeWatchProxy *proxy = new QDeclarativeWatchProxy(id, object, debugId, property, this);
- m_proxies[id].append(proxy);
-
- proxy->notifyValueChanged();
-}
-
-QT_END_NAMESPACE
-
-#include <qdeclarativewatcher.moc>
diff --git a/src/declarative/qml/qdeclarativewatcher_p.h b/src/declarative/qml/qdeclarativewatcher_p.h
deleted file mode 100644
index 54b348664c..0000000000
--- a/src/declarative/qml/qdeclarativewatcher_p.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEWATCHER_P_H
-#define QDECLARATIVEWATCHER_P_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/qobject.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qpair.h>
-#include <QtCore/qhash.h>
-#include <QtCore/qset.h>
-#include <QtCore/qpointer.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeWatchProxy;
-class QDeclarativeExpression;
-class QDeclarativeContext;
-class QMetaProperty;
-
-class QDeclarativeWatcher : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeWatcher(QObject * = 0);
-
- bool addWatch(int id, quint32 objectId);
- bool addWatch(int id, quint32 objectId, const QByteArray &property);
- bool addWatch(int id, quint32 objectId, const QString &expr);
-
- void removeWatch(int id);
-
-Q_SIGNALS:
- void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
-
-private:
- friend class QDeclarativeWatchProxy;
- void addPropertyWatch(int id, QObject *object, quint32 objectId, const QMetaProperty &property);
-
- QHash<int, QList<QPointer<QDeclarativeWatchProxy> > > m_proxies;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEWATCHER_P_H
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
deleted file mode 100644
index 53283113b6..0000000000
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ /dev/null
@@ -1,730 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeworkerscript_p.h"
-#include "qdeclarativelistmodel_p.h"
-#include "qdeclarativelistmodelworkeragent_p.h"
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativeexpression_p.h"
-
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdebug.h>
-#include <QtDeclarative/qjsengine.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qwaitcondition.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qdatetime.h>
-#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include "qdeclarativenetworkaccessmanagerfactory.h"
-
-#include <private/qv8engine_p.h>
-#include <private/qv8worker_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class WorkerDataEvent : public QEvent
-{
-public:
- enum Type { WorkerData = QEvent::User };
-
- WorkerDataEvent(int workerId, const QByteArray &data);
- virtual ~WorkerDataEvent();
-
- int workerId() const;
- QByteArray data() const;
-
-private:
- int m_id;
- QByteArray m_data;
-};
-
-class WorkerLoadEvent : public QEvent
-{
-public:
- enum Type { WorkerLoad = WorkerDataEvent::WorkerData + 1 };
-
- WorkerLoadEvent(int workerId, const QUrl &url);
-
- int workerId() const;
- QUrl url() const;
-
-private:
- int m_id;
- QUrl m_url;
-};
-
-class WorkerRemoveEvent : public QEvent
-{
-public:
- enum Type { WorkerRemove = WorkerLoadEvent::WorkerLoad + 1 };
-
- WorkerRemoveEvent(int workerId);
-
- int workerId() const;
-
-private:
- int m_id;
-};
-
-class WorkerErrorEvent : public QEvent
-{
-public:
- enum Type { WorkerError = WorkerRemoveEvent::WorkerRemove + 1 };
-
- WorkerErrorEvent(const QDeclarativeError &error);
-
- QDeclarativeError error() const;
-
-private:
- QDeclarativeError m_error;
-};
-
-class QDeclarativeWorkerScriptEnginePrivate : public QObject
-{
- Q_OBJECT
-public:
- enum WorkerEventTypes {
- WorkerDestroyEvent = QEvent::User + 100
- };
-
- QDeclarativeWorkerScriptEnginePrivate(QDeclarativeEngine *eng);
-
- class WorkerEngine : public QV8Engine
- {
- public:
- WorkerEngine(QDeclarativeWorkerScriptEnginePrivate *parent);
- ~WorkerEngine();
-
- void init();
- virtual QNetworkAccessManager *networkAccessManager();
-
- QDeclarativeWorkerScriptEnginePrivate *p;
-
- v8::Local<v8::Function> sendFunction(int id);
- void callOnMessage(v8::Handle<v8::Object> object, v8::Handle<v8::Value> arg);
- private:
- v8::Persistent<v8::Function> onmessage;
- v8::Persistent<v8::Function> createsend;
- QNetworkAccessManager *accessManager;
- };
-
- WorkerEngine *workerEngine;
- static QDeclarativeWorkerScriptEnginePrivate *get(QV8Engine *e) {
- return static_cast<WorkerEngine *>(e)->p;
- }
-
- QDeclarativeEngine *qmlengine;
-
- QMutex m_lock;
- QWaitCondition m_wait;
-
- struct WorkerScript {
- WorkerScript();
- ~WorkerScript();
-
- int id;
- QUrl source;
- bool initialized;
- QDeclarativeWorkerScript *owner;
- v8::Persistent<v8::Object> object;
- };
-
- QHash<int, WorkerScript *> workers;
- v8::Handle<v8::Object> getWorker(WorkerScript *);
-
- int m_nextId;
-
- static v8::Handle<v8::Value> sendMessage(const v8::Arguments &args);
-
-signals:
- void stopThread();
-
-protected:
- virtual bool event(QEvent *);
-
-private:
- void processMessage(int, const QByteArray &);
- void processLoad(int, const QUrl &);
- void reportScriptException(WorkerScript *, const QDeclarativeError &error);
-};
-
-QDeclarativeWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QDeclarativeWorkerScriptEnginePrivate *parent)
-: QV8Engine(0), p(parent), accessManager(0)
-{
-}
-
-QDeclarativeWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine()
-{
- qPersistentDispose(createsend);
- qPersistentDispose(onmessage);
- delete accessManager;
-}
-
-void QDeclarativeWorkerScriptEnginePrivate::WorkerEngine::init()
-{
- initDeclarativeGlobalObject();
-#define CALL_ONMESSAGE_SCRIPT \
- "(function(object, message) { "\
- "var isfunction = false; "\
- "try { "\
- "isfunction = object.WorkerScript.onMessage instanceof Function; "\
- "} catch (e) {}" \
- "if (isfunction) "\
- "object.WorkerScript.onMessage(message); "\
- "})"
-
-#define SEND_MESSAGE_CREATE_SCRIPT \
- "(function(method, engine) { "\
- "return (function(id) { "\
- "return (function(message) { "\
- "if (arguments.length) method(engine, id, message); "\
- "}); "\
- "}); "\
- "})"
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(context());
-
- {
- v8::Local<v8::Script> onmessagescript = v8::Script::New(v8::String::New(CALL_ONMESSAGE_SCRIPT));
- onmessage = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(onmessagescript->Run()));
- }
- {
- v8::Local<v8::Script> createsendscript = v8::Script::New(v8::String::New(SEND_MESSAGE_CREATE_SCRIPT));
- v8::Local<v8::Function> createsendconstructor = v8::Local<v8::Function>::Cast(createsendscript->Run());
-
- v8::Handle<v8::Value> args[] = {
- V8FUNCTION(QDeclarativeWorkerScriptEnginePrivate::sendMessage, this)
- };
- v8::Local<v8::Value> createsendvalue = createsendconstructor->Call(global(), 1, args);
-
- createsend = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(createsendvalue));
- }
-}
-
-// Requires handle and context scope
-v8::Local<v8::Function> QDeclarativeWorkerScriptEnginePrivate::WorkerEngine::sendFunction(int id)
-{
- v8::Handle<v8::Value> args[] = { v8::Integer::New(id) };
- return v8::Local<v8::Function>::Cast(createsend->Call(global(), 1, args));
-}
-
-// Requires handle and context scope
-void QDeclarativeWorkerScriptEnginePrivate::WorkerEngine::callOnMessage(v8::Handle<v8::Object> object,
- v8::Handle<v8::Value> arg)
-{
- v8::Handle<v8::Value> args[] = { object, arg };
- onmessage->Call(global(), 2, args);
-}
-
-QNetworkAccessManager *QDeclarativeWorkerScriptEnginePrivate::WorkerEngine::networkAccessManager()
-{
- if (!accessManager) {
- if (p->qmlengine && p->qmlengine->networkAccessManagerFactory()) {
- accessManager = p->qmlengine->networkAccessManagerFactory()->create(p);
- } else {
- accessManager = new QNetworkAccessManager(p);
- }
- }
- return accessManager;
-}
-
-QDeclarativeWorkerScriptEnginePrivate::QDeclarativeWorkerScriptEnginePrivate(QDeclarativeEngine *engine)
-: workerEngine(0), qmlengine(engine), m_nextId(0)
-{
-}
-
-v8::Handle<v8::Value> QDeclarativeWorkerScriptEnginePrivate::sendMessage(const v8::Arguments &args)
-{
- WorkerEngine *engine = (WorkerEngine*)V8ENGINE();
-
- int id = args[1]->Int32Value();
-
- QByteArray data = QV8Worker::serialize(args[2], engine);
-
- QMutexLocker(&engine->p->m_lock);
- WorkerScript *script = engine->p->workers.value(id);
- if (!script)
- return v8::Undefined();
-
- if (script->owner)
- QCoreApplication::postEvent(script->owner, new WorkerDataEvent(0, data));
-
- return v8::Undefined();
-}
-
-// Requires handle scope and context scope
-v8::Handle<v8::Object> QDeclarativeWorkerScriptEnginePrivate::getWorker(WorkerScript *script)
-{
- if (!script->initialized) {
- script->initialized = true;
-
- script->object = qPersistentNew<v8::Object>(workerEngine->contextWrapper()->urlScope(script->source));
-
- workerEngine->contextWrapper()->setReadOnly(script->object, false);
-
- v8::Local<v8::Object> api = v8::Object::New();
- api->Set(v8::String::New("sendMessage"), workerEngine->sendFunction(script->id));
-
- script->object->Set(v8::String::New("WorkerScript"), api);
-
- workerEngine->contextWrapper()->setReadOnly(script->object, true);
- }
-
- return script->object;
-}
-
-bool QDeclarativeWorkerScriptEnginePrivate::event(QEvent *event)
-{
- if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
- WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
- processMessage(workerEvent->workerId(), workerEvent->data());
- return true;
- } else if (event->type() == (QEvent::Type)WorkerLoadEvent::WorkerLoad) {
- WorkerLoadEvent *workerEvent = static_cast<WorkerLoadEvent *>(event);
- processLoad(workerEvent->workerId(), workerEvent->url());
- return true;
- } else if (event->type() == (QEvent::Type)WorkerDestroyEvent) {
- emit stopThread();
- return true;
- } else if (event->type() == (QEvent::Type)WorkerRemoveEvent::WorkerRemove) {
- WorkerRemoveEvent *workerEvent = static_cast<WorkerRemoveEvent *>(event);
- workers.remove(workerEvent->workerId());
- return true;
- } else {
- return QObject::event(event);
- }
-}
-
-void QDeclarativeWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &data)
-{
- WorkerScript *script = workers.value(id);
- if (!script)
- return;
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(workerEngine->context());
-
- v8::Handle<v8::Value> value = QV8Worker::deserialize(data, workerEngine);
-
- v8::TryCatch tc;
- workerEngine->callOnMessage(script->object, value);
-
- if (tc.HasCaught()) {
- QDeclarativeError error;
- QDeclarativeExpressionPrivate::exceptionToError(tc.Message(), error);
- reportScriptException(script, error);
- }
-}
-
-void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
-{
- if (url.isRelative())
- return;
-
- QString fileName = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
-
- QFile f(fileName);
- if (f.open(QIODevice::ReadOnly)) {
- QByteArray data = f.readAll();
- QString sourceCode = QString::fromUtf8(data);
- QDeclarativeScript::Parser::extractPragmas(sourceCode);
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(workerEngine->context());
-
- WorkerScript *script = workers.value(id);
- if (!script)
- return;
- script->source = url;
- v8::Handle<v8::Object> activation = getWorker(script);
- if (activation.IsEmpty())
- return;
-
- // XXX ???
- // workerEngine->baseUrl = url;
-
- v8::TryCatch tc;
- v8::Local<v8::Script> program = workerEngine->qmlModeCompile(sourceCode, url.toString());
-
- if (!tc.HasCaught())
- program->Run(activation);
-
- if (tc.HasCaught()) {
- QDeclarativeError error;
- QDeclarativeExpressionPrivate::exceptionToError(tc.Message(), error);
- reportScriptException(script, error);
- }
- } else {
- qWarning().nospace() << "WorkerScript: Cannot find source file " << url.toString();
- }
-}
-
-void QDeclarativeWorkerScriptEnginePrivate::reportScriptException(WorkerScript *script,
- const QDeclarativeError &error)
-{
- QDeclarativeWorkerScriptEnginePrivate *p = QDeclarativeWorkerScriptEnginePrivate::get(workerEngine);
-
- QMutexLocker(&p->m_lock);
- if (script->owner)
- QCoreApplication::postEvent(script->owner, new WorkerErrorEvent(error));
-}
-
-WorkerDataEvent::WorkerDataEvent(int workerId, const QByteArray &data)
-: QEvent((QEvent::Type)WorkerData), m_id(workerId), m_data(data)
-{
-}
-
-WorkerDataEvent::~WorkerDataEvent()
-{
-}
-
-int WorkerDataEvent::workerId() const
-{
- return m_id;
-}
-
-QByteArray WorkerDataEvent::data() const
-{
- return m_data;
-}
-
-WorkerLoadEvent::WorkerLoadEvent(int workerId, const QUrl &url)
-: QEvent((QEvent::Type)WorkerLoad), m_id(workerId), m_url(url)
-{
-}
-
-int WorkerLoadEvent::workerId() const
-{
- return m_id;
-}
-
-QUrl WorkerLoadEvent::url() const
-{
- return m_url;
-}
-
-WorkerRemoveEvent::WorkerRemoveEvent(int workerId)
-: QEvent((QEvent::Type)WorkerRemove), m_id(workerId)
-{
-}
-
-int WorkerRemoveEvent::workerId() const
-{
- return m_id;
-}
-
-WorkerErrorEvent::WorkerErrorEvent(const QDeclarativeError &error)
-: QEvent((QEvent::Type)WorkerError), m_error(error)
-{
-}
-
-QDeclarativeError WorkerErrorEvent::error() const
-{
- return m_error;
-}
-
-QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(QDeclarativeEngine *parent)
-: QThread(parent), d(new QDeclarativeWorkerScriptEnginePrivate(parent))
-{
- d->m_lock.lock();
- connect(d, SIGNAL(stopThread()), this, SLOT(quit()), Qt::DirectConnection);
- start(QThread::LowestPriority);
- d->m_wait.wait(&d->m_lock);
- d->moveToThread(this);
- d->m_lock.unlock();
-}
-
-QDeclarativeWorkerScriptEngine::~QDeclarativeWorkerScriptEngine()
-{
- d->m_lock.lock();
- QCoreApplication::postEvent(d, new QEvent((QEvent::Type)QDeclarativeWorkerScriptEnginePrivate::WorkerDestroyEvent));
- d->m_lock.unlock();
-
- //We have to force to cleanup the main thread's event queue here
- //to make sure the main GUI release all pending locks/wait conditions which
- //some worker script/agent are waiting for (QDeclarativeListModelWorkerAgent::sync() for example).
- QCoreApplication::processEvents();
- wait();
- d->deleteLater();
-}
-
-QDeclarativeWorkerScriptEnginePrivate::WorkerScript::WorkerScript()
-: id(-1), initialized(false), owner(0)
-{
-}
-
-QDeclarativeWorkerScriptEnginePrivate::WorkerScript::~WorkerScript()
-{
- qPersistentDispose(object);
-}
-
-int QDeclarativeWorkerScriptEngine::registerWorkerScript(QDeclarativeWorkerScript *owner)
-{
- typedef QDeclarativeWorkerScriptEnginePrivate::WorkerScript WorkerScript;
- WorkerScript *script = new WorkerScript;
-
- script->id = d->m_nextId++;
- script->owner = owner;
-
- d->m_lock.lock();
- d->workers.insert(script->id, script);
- d->m_lock.unlock();
-
- return script->id;
-}
-
-void QDeclarativeWorkerScriptEngine::removeWorkerScript(int id)
-{
- QDeclarativeWorkerScriptEnginePrivate::WorkerScript* script = d->workers.value(id);
- if (script) {
- script->owner = 0;
- QCoreApplication::postEvent(d, new WorkerRemoveEvent(id));
- }
-}
-
-void QDeclarativeWorkerScriptEngine::executeUrl(int id, const QUrl &url)
-{
- QCoreApplication::postEvent(d, new WorkerLoadEvent(id, url));
-}
-
-void QDeclarativeWorkerScriptEngine::sendMessage(int id, const QByteArray &data)
-{
- QCoreApplication::postEvent(d, new WorkerDataEvent(id, data));
-}
-
-void QDeclarativeWorkerScriptEngine::run()
-{
- d->m_lock.lock();
-
- d->workerEngine = new QDeclarativeWorkerScriptEnginePrivate::WorkerEngine(d);
- d->workerEngine->init();
-
- d->m_wait.wakeAll();
-
- d->m_lock.unlock();
-
- exec();
-
- qDeleteAll(d->workers);
- d->workers.clear();
-
- delete d->workerEngine; d->workerEngine = 0;
-}
-
-
-/*!
- \qmlclass WorkerScript QDeclarativeWorkerScript
- \ingroup qml-utility-elements
- \brief The WorkerScript element enables the use of threads in QML.
-
- Use WorkerScript to run operations in a new thread.
- This is useful for running operations in the background so
- that the main GUI thread is not blocked.
-
- Messages can be passed between the new thread and the parent thread
- using \l sendMessage() and the \l {WorkerScript::onMessage}{onMessage()} handler.
-
- An example:
-
- \snippet doc/src/snippets/declarative/workerscript.qml 0
-
- The above worker script specifies a JavaScript file, "script.js", that handles
- the operations to be performed in the new thread. Here is \c script.js:
-
- \quotefile doc/src/snippets/declarative/script.js
-
- When the user clicks anywhere within the rectangle, \c sendMessage() is
- called, triggering the \tt WorkerScript.onMessage() handler in
- \tt script.js. This in turn sends a reply message that is then received
- by the \tt onMessage() handler of \tt myWorker.
-
-
- \section3 Restrictions
-
- Since the \c WorkerScript.onMessage() function is run in a separate thread, the
- JavaScript file is evaluated in a context separate from the main QML engine. This means
- that unlike an ordinary JavaScript file that is imported into QML, the \c script.js
- in the above example cannot access the properties, methods or other attributes
- of the QML item, nor can it access any context properties set on the QML object
- through QDeclarativeContext.
-
- Additionally, there are restrictions on the types of values that can be passed to and
- from the worker script. See the sendMessage() documentation for details.
-
- \sa {declarative/threading/workerscript}{WorkerScript example},
- {declarative/threading/threadedlistmodel}{Threaded ListModel example}
-*/
-QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent)
-: QObject(parent), m_engine(0), m_scriptId(-1), m_componentComplete(true)
-{
-}
-
-QDeclarativeWorkerScript::~QDeclarativeWorkerScript()
-{
- if (m_scriptId != -1) m_engine->removeWorkerScript(m_scriptId);
-}
-
-/*!
- \qmlproperty url WorkerScript::source
-
- This holds the url of the JavaScript file that implements the
- \tt WorkerScript.onMessage() handler for threaded operations.
-*/
-QUrl QDeclarativeWorkerScript::source() const
-{
- return m_source;
-}
-
-void QDeclarativeWorkerScript::setSource(const QUrl &source)
-{
- if (m_source == source)
- return;
-
- m_source = source;
-
- if (engine())
- m_engine->executeUrl(m_scriptId, m_source);
-
- emit sourceChanged();
-}
-
-/*!
- \qmlmethod WorkerScript::sendMessage(jsobject message)
-
- Sends the given \a message to a worker script handler in another
- thread. The other worker script handler can receive this message
- through the onMessage() handler.
-
- The \c message object may only contain values of the following
- types:
-
- \list
- \o boolean, number, string
- \o JavaScript objects and arrays
- \o ListModel objects (any other type of QObject* is not allowed)
- \endlist
-
- All objects and arrays are copied to the \c message. With the exception
- of ListModel objects, any modifications by the other thread to an object
- passed in \c message will not be reflected in the original object.
-*/
-void QDeclarativeWorkerScript::sendMessage(QDeclarativeV8Function *args)
-{
- if (!engine()) {
- qWarning("QDeclarativeWorkerScript: Attempt to send message before WorkerScript establishment");
- return;
- }
-
- v8::Handle<v8::Value> argument = v8::Undefined();
- if (args->Length() != 0)
- argument = (*args)[0];
-
- m_engine->sendMessage(m_scriptId, QV8Worker::serialize(argument, args->engine()));
-}
-
-void QDeclarativeWorkerScript::classBegin()
-{
- m_componentComplete = false;
-}
-
-QDeclarativeWorkerScriptEngine *QDeclarativeWorkerScript::engine()
-{
- if (m_engine) return m_engine;
- if (m_componentComplete) {
- QDeclarativeEngine *engine = qmlEngine(this);
- if (!engine) {
- qWarning("QDeclarativeWorkerScript: engine() called without qmlEngine() set");
- return 0;
- }
-
- m_engine = QDeclarativeEnginePrivate::get(engine)->getWorkerScriptEngine();
- m_scriptId = m_engine->registerWorkerScript(this);
-
- if (m_source.isValid())
- m_engine->executeUrl(m_scriptId, m_source);
-
- return m_engine;
- }
- return 0;
-}
-
-void QDeclarativeWorkerScript::componentComplete()
-{
- m_componentComplete = true;
- engine(); // Get it started now.
-}
-
-/*!
- \qmlsignal WorkerScript::onMessage(jsobject msg)
-
- This handler is called when a message \a msg is received from a worker
- script in another thread through a call to sendMessage().
-*/
-
-bool QDeclarativeWorkerScript::event(QEvent *event)
-{
- if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
- QDeclarativeEngine *engine = qmlEngine(this);
- if (engine) {
- WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
- QV8Engine *v8engine = QDeclarativeEnginePrivate::get(engine)->v8engine();
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(v8engine->context());
- v8::Handle<v8::Value> value = QV8Worker::deserialize(workerEvent->data(), v8engine);
- emit message(QDeclarativeV8Handle::fromHandle(value));
- }
- return true;
- } else if (event->type() == (QEvent::Type)WorkerErrorEvent::WorkerError) {
- WorkerErrorEvent *workerEvent = static_cast<WorkerErrorEvent *>(event);
- QDeclarativeEnginePrivate::warning(qmlEngine(this), workerEvent->error());
- return true;
- } else {
- return QObject::event(event);
- }
-}
-
-QT_END_NAMESPACE
-
-#include <qdeclarativeworkerscript.moc>
-
diff --git a/src/declarative/qml/qdeclarativeworkerscript_p.h b/src/declarative/qml/qdeclarativeworkerscript_p.h
deleted file mode 100644
index 192251f8ac..0000000000
--- a/src/declarative/qml/qdeclarativeworkerscript_p.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEWORKERSCRIPT_P_H
-#define QDECLARATIVEWORKERSCRIPT_P_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 "qdeclarative.h"
-#include "qdeclarativeparserstatus.h"
-
-#include <QtCore/qthread.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeWorkerScript;
-class QDeclarativeWorkerScriptEnginePrivate;
-class QDeclarativeWorkerScriptEngine : public QThread
-{
-Q_OBJECT
-public:
- QDeclarativeWorkerScriptEngine(QDeclarativeEngine *parent = 0);
- virtual ~QDeclarativeWorkerScriptEngine();
-
- int registerWorkerScript(QDeclarativeWorkerScript *);
- void removeWorkerScript(int);
- void executeUrl(int, const QUrl &);
- void sendMessage(int, const QByteArray &);
-
-protected:
- virtual void run();
-
-private:
- QDeclarativeWorkerScriptEnginePrivate *d;
-};
-
-class QDeclarativeV8Function;
-class QDeclarativeV8Handle;
-class Q_AUTOTEST_EXPORT QDeclarativeWorkerScript : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
-
- Q_INTERFACES(QDeclarativeParserStatus)
-public:
- QDeclarativeWorkerScript(QObject *parent = 0);
- virtual ~QDeclarativeWorkerScript();
-
- QUrl source() const;
- void setSource(const QUrl &);
-
-public slots:
- void sendMessage(QDeclarativeV8Function*);
-
-signals:
- void sourceChanged();
- void message(const QDeclarativeV8Handle &messageObject);
-
-protected:
- virtual void classBegin();
- virtual void componentComplete();
- virtual bool event(QEvent *);
-
-private:
- QDeclarativeWorkerScriptEngine *engine();
- QDeclarativeWorkerScriptEngine *m_engine;
- int m_scriptId;
- QUrl m_source;
- bool m_componentComplete;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeWorkerScript)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEWORKERSCRIPT_P_H
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
deleted file mode 100644
index c439948513..0000000000
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ /dev/null
@@ -1,1797 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativexmlhttprequest_p.h"
-
-#include <private/qv8engine_p.h>
-
-#include "qdeclarativeengine.h"
-#include "qdeclarativeengine_p.h"
-#include <private/qdeclarativerefcount_p.h>
-#include "qdeclarativeengine_p.h"
-#include "qdeclarativeexpression_p.h"
-#include "qdeclarativeglobal_p.h"
-#include <private/qv8domerrors_p.h>
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtDeclarative/qjsengine.h>
-#include <QtNetwork/qnetworkreply.h>
-#include <QtCore/qtextcodec.h>
-#include <QtCore/qxmlstream.h>
-#include <QtCore/qstack.h>
-#include <QtCore/qdebug.h>
-
-#include <QtCore/QStringBuilder>
-
-#ifndef QT_NO_XMLSTREAMREADER
-
-#define V8THROW_REFERENCE(string) { \
- v8::ThrowException(v8::Exception::ReferenceError(v8::String::New(string))); \
- return v8::Handle<v8::Value>(); \
-}
-
-#define D(arg) (arg)->release()
-#define A(arg) (arg)->addref()
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(xhrDump, QML_XHR_DUMP);
-
-struct QDeclarativeXMLHttpRequestData {
- QDeclarativeXMLHttpRequestData();
- ~QDeclarativeXMLHttpRequestData();
-
- v8::Persistent<v8::Function> nodeFunction;
-
- v8::Persistent<v8::Object> namedNodeMapPrototype;
- v8::Persistent<v8::Object> nodeListPrototype;
- v8::Persistent<v8::Object> nodePrototype;
- v8::Persistent<v8::Object> elementPrototype;
- v8::Persistent<v8::Object> attrPrototype;
- v8::Persistent<v8::Object> characterDataPrototype;
- v8::Persistent<v8::Object> textPrototype;
- v8::Persistent<v8::Object> cdataPrototype;
- v8::Persistent<v8::Object> documentPrototype;
-
- v8::Local<v8::Object> newNode();
-};
-
-static inline QDeclarativeXMLHttpRequestData *xhrdata(QV8Engine *engine)
-{
- return (QDeclarativeXMLHttpRequestData *)engine->xmlHttpRequestData();
-}
-
-QDeclarativeXMLHttpRequestData::QDeclarativeXMLHttpRequestData()
-{
-}
-
-QDeclarativeXMLHttpRequestData::~QDeclarativeXMLHttpRequestData()
-{
- qPersistentDispose(nodeFunction);
- qPersistentDispose(namedNodeMapPrototype);
- qPersistentDispose(nodeListPrototype);
- qPersistentDispose(nodePrototype);
- qPersistentDispose(elementPrototype);
- qPersistentDispose(attrPrototype);
- qPersistentDispose(characterDataPrototype);
- qPersistentDispose(textPrototype);
- qPersistentDispose(cdataPrototype);
- qPersistentDispose(documentPrototype);
-}
-
-v8::Local<v8::Object> QDeclarativeXMLHttpRequestData::newNode()
-{
- if (nodeFunction.IsEmpty()) {
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetHasExternalResource(true);
- nodeFunction = qPersistentNew<v8::Function>(ft->GetFunction());
- }
-
- return nodeFunction->NewInstance();
-}
-
-namespace {
-
-class DocumentImpl;
-class NodeImpl
-{
-public:
- NodeImpl() : type(Element), document(0), parent(0) {}
- virtual ~NodeImpl() {
- for (int ii = 0; ii < children.count(); ++ii)
- delete children.at(ii);
- for (int ii = 0; ii < attributes.count(); ++ii)
- delete attributes.at(ii);
- }
-
- // These numbers are copied from the Node IDL definition
- enum Type {
- Attr = 2,
- CDATA = 4,
- Comment = 8,
- Document = 9,
- DocumentFragment = 11,
- DocumentType = 10,
- Element = 1,
- Entity = 6,
- EntityReference = 5,
- Notation = 12,
- ProcessingInstruction = 7,
- Text = 3
- };
- Type type;
-
- QString namespaceUri;
- QString name;
-
- QString data;
-
- void addref();
- void release();
-
- DocumentImpl *document;
- NodeImpl *parent;
-
- QList<NodeImpl *> children;
- QList<NodeImpl *> attributes;
-};
-
-class DocumentImpl : public QDeclarativeRefCount, public NodeImpl
-{
-public:
- DocumentImpl() : root(0) { type = Document; }
- virtual ~DocumentImpl() {
- if (root) delete root;
- }
-
- QString version;
- QString encoding;
- bool isStandalone;
-
- NodeImpl *root;
-
- void addref() { QDeclarativeRefCount::addref(); }
- void release() { QDeclarativeRefCount::release(); }
-};
-
-class NamedNodeMap
-{
-public:
- // JS API
- static v8::Handle<v8::Value> length(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> indexed(uint32_t index, const v8::AccessorInfo& info);
- static v8::Handle<v8::Value> named(v8::Local<v8::String> property, const v8::AccessorInfo& args);
-
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
- static v8::Handle<v8::Value> create(QV8Engine *, NodeImpl *, QList<NodeImpl *> *);
-};
-
-class NodeList
-{
-public:
- // JS API
- static v8::Handle<v8::Value> length(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> indexed(uint32_t index, const v8::AccessorInfo& info);
-
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
- static v8::Handle<v8::Value> create(QV8Engine *, NodeImpl *);
-};
-
-class Node
-{
-public:
- // JS API
- static v8::Handle<v8::Value> nodeName(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> nodeValue(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> nodeType(v8::Local<v8::String>, const v8::AccessorInfo& args);
-
- static v8::Handle<v8::Value> parentNode(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> childNodes(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> firstChild(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> lastChild(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> previousSibling(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> nextSibling(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> attributes(v8::Local<v8::String>, const v8::AccessorInfo& args);
-
- //static v8::Handle<v8::Value> ownerDocument(v8::Local<v8::String>, const v8::AccessorInfo& args);
- //static v8::Handle<v8::Value> namespaceURI(v8::Local<v8::String>, const v8::AccessorInfo& args);
- //static v8::Handle<v8::Value> prefix(v8::Local<v8::String>, const v8::AccessorInfo& args);
- //static v8::Handle<v8::Value> localName(v8::Local<v8::String>, const v8::AccessorInfo& args);
- //static v8::Handle<v8::Value> baseURI(v8::Local<v8::String>, const v8::AccessorInfo& args);
- //static v8::Handle<v8::Value> textContent(v8::Local<v8::String>, const v8::AccessorInfo& args);
-
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
- static v8::Handle<v8::Value> create(QV8Engine *, NodeImpl *);
-
- Node();
- Node(const Node &o);
- ~Node();
- bool isNull() const;
-
- NodeImpl *d;
-
-private:
- Node &operator=(const Node &);
-};
-
-class Element : public Node
-{
-public:
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
-};
-
-class Attr : public Node
-{
-public:
- // JS API
- static v8::Handle<v8::Value> name(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> specified(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> value(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> ownerElement(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> schemaTypeInfo(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> isId(v8::Local<v8::String>, const v8::AccessorInfo& args);
-
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
-};
-
-class CharacterData : public Node
-{
-public:
- // JS API
- static v8::Handle<v8::Value> length(v8::Local<v8::String>, const v8::AccessorInfo& args);
-
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
-};
-
-class Text : public CharacterData
-{
-public:
- // JS API
- static v8::Handle<v8::Value> isElementContentWhitespace(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> wholeText(v8::Local<v8::String>, const v8::AccessorInfo& args);
-
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
-};
-
-class CDATA : public Text
-{
-public:
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
-};
-
-class Document : public Node
-{
-public:
- // JS API
- static v8::Handle<v8::Value> xmlVersion(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> xmlEncoding(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> xmlStandalone(v8::Local<v8::String>, const v8::AccessorInfo& args);
- static v8::Handle<v8::Value> documentElement(v8::Local<v8::String>, const v8::AccessorInfo& args);
-
- // C++ API
- static v8::Handle<v8::Object> prototype(QV8Engine *);
- static v8::Handle<v8::Value> load(QV8Engine *engine, const QByteArray &data);
-};
-
-}
-
-class QDeclarativeDOMNodeResource : public QV8ObjectResource, public Node
-{
- V8_RESOURCE_TYPE(DOMNodeType);
-public:
- QDeclarativeDOMNodeResource(QV8Engine *e);
-
- QList<NodeImpl *> *list; // Only used in NamedNodeMap
-};
-
-QDeclarativeDOMNodeResource::QDeclarativeDOMNodeResource(QV8Engine *e)
-: QV8ObjectResource(e), list(0)
-{
-}
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(Node)
-Q_DECLARE_METATYPE(NodeList)
-Q_DECLARE_METATYPE(NamedNodeMap)
-
-QT_BEGIN_NAMESPACE
-
-void NodeImpl::addref()
-{
- A(document);
-}
-
-void NodeImpl::release()
-{
- D(document);
-}
-
-v8::Handle<v8::Value> Node::nodeName(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- switch (r->d->type) {
- case NodeImpl::Document:
- return v8::String::New("#document");
- case NodeImpl::CDATA:
- return v8::String::New("#cdata-section");
- case NodeImpl::Text:
- return v8::String::New("#text");
- default:
- return engine->toString(r->d->name);
- }
-}
-
-v8::Handle<v8::Value> Node::nodeValue(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if (r->d->type == NodeImpl::Document ||
- r->d->type == NodeImpl::DocumentFragment ||
- r->d->type == NodeImpl::DocumentType ||
- r->d->type == NodeImpl::Element ||
- r->d->type == NodeImpl::Entity ||
- r->d->type == NodeImpl::EntityReference ||
- r->d->type == NodeImpl::Notation)
- return v8::Null();
-
- return engine->toString(r->d->data);
-}
-
-v8::Handle<v8::Value> Node::nodeType(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- return v8::Integer::New(r->d->type);
-}
-
-v8::Handle<v8::Value> Node::parentNode(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if (r->d->parent) return Node::create(engine, r->d->parent);
- else return v8::Null();
-}
-
-v8::Handle<v8::Value> Node::childNodes(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- return NodeList::create(engine, r->d);
-}
-
-v8::Handle<v8::Value> Node::firstChild(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if (r->d->children.isEmpty()) return v8::Null();
- else return Node::create(engine, r->d->children.first());
-}
-
-v8::Handle<v8::Value> Node::lastChild(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if (r->d->children.isEmpty()) return v8::Null();
- else return Node::create(engine, r->d->children.last());
-}
-
-v8::Handle<v8::Value> Node::previousSibling(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if (!r->d->parent) return v8::Null();
-
- for (int ii = 0; ii < r->d->parent->children.count(); ++ii) {
- if (r->d->parent->children.at(ii) == r->d) {
- if (ii == 0) return v8::Null();
- else return Node::create(engine, r->d->parent->children.at(ii - 1));
- }
- }
-
- return v8::Null();
-}
-
-v8::Handle<v8::Value> Node::nextSibling(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if (!r->d->parent) return v8::Null();
-
- for (int ii = 0; ii < r->d->parent->children.count(); ++ii) {
- if (r->d->parent->children.at(ii) == r->d) {
- if ((ii + 1) == r->d->parent->children.count()) return v8::Null();
- else return Node::create(engine, r->d->parent->children.at(ii + 1));
- }
- }
-
- return v8::Null();
-}
-
-v8::Handle<v8::Value> Node::attributes(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if (r->d->type != NodeImpl::Element)
- return v8::Null();
- else
- return NamedNodeMap::create(engine, r->d, &r->d->attributes);
-}
-
-v8::Handle<v8::Object> Node::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->nodePrototype.IsEmpty()) {
- d->nodePrototype = qPersistentNew<v8::Object>(v8::Object::New());
- d->nodePrototype->SetAccessor(v8::String::New("nodeName"), nodeName,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("nodeValue"), nodeValue,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("nodeType"), nodeType,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("parentNode"), parentNode,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("childNodes"), childNodes,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("firstChild"), firstChild,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("lastChild"), lastChild,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("previousSibling"), previousSibling,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("nextSibling"), nextSibling,
- 0, v8::External::Wrap(engine));
- d->nodePrototype->SetAccessor(v8::String::New("attributes"), attributes,
- 0, v8::External::Wrap(engine));
- engine->freezeObject(d->nodePrototype);
- }
- return d->nodePrototype;
-}
-
-v8::Handle<v8::Value> Node::create(QV8Engine *engine, NodeImpl *data)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- v8::Local<v8::Object> instance = d->newNode();
-
- switch (data->type) {
- case NodeImpl::Attr:
- instance->SetPrototype(Attr::prototype(engine));
- break;
- case NodeImpl::Comment:
- case NodeImpl::Document:
- case NodeImpl::DocumentFragment:
- case NodeImpl::DocumentType:
- case NodeImpl::Entity:
- case NodeImpl::EntityReference:
- case NodeImpl::Notation:
- case NodeImpl::ProcessingInstruction:
- return v8::Undefined();
- case NodeImpl::CDATA:
- instance->SetPrototype(CDATA::prototype(engine));
- break;
- case NodeImpl::Text:
- instance->SetPrototype(Text::prototype(engine));
- break;
- case NodeImpl::Element:
- instance->SetPrototype(Element::prototype(engine));
- break;
- }
-
- QDeclarativeDOMNodeResource *r = new QDeclarativeDOMNodeResource(engine);
- r->d = data;
- if (data) A(data);
- instance->SetExternalResource(r);
-
- return instance;
-}
-
-v8::Handle<v8::Object> Element::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->elementPrototype.IsEmpty()) {
- d->elementPrototype = qPersistentNew<v8::Object>(v8::Object::New());
- d->elementPrototype->SetPrototype(Node::prototype(engine));
- d->elementPrototype->SetAccessor(v8::String::New("tagName"), nodeName,
- 0, v8::External::Wrap(engine));
- engine->freezeObject(d->elementPrototype);
- }
- return d->elementPrototype;
-}
-
-v8::Handle<v8::Object> Attr::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->attrPrototype.IsEmpty()) {
- d->attrPrototype = qPersistentNew<v8::Object>(v8::Object::New());
- d->attrPrototype->SetPrototype(Node::prototype(engine));
- d->attrPrototype->SetAccessor(v8::String::New("name"), name,
- 0, v8::External::Wrap(engine));
- d->attrPrototype->SetAccessor(v8::String::New("value"), value,
- 0, v8::External::Wrap(engine));
- d->attrPrototype->SetAccessor(v8::String::New("ownerElement"), ownerElement,
- 0, v8::External::Wrap(engine));
- engine->freezeObject(d->attrPrototype);
- }
- return d->attrPrototype;
-}
-
-v8::Handle<v8::Value> Attr::name(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- return engine->toString(r->d->name);
-}
-
-v8::Handle<v8::Value> Attr::value(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- return engine->toString(r->d->data);
-}
-
-v8::Handle<v8::Value> Attr::ownerElement(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- return Node::create(engine, r->d->parent);
-}
-
-v8::Handle<v8::Value> CharacterData::length(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
- Q_UNUSED(engine)
- return v8::Integer::New(r->d->data.length());
-}
-
-v8::Handle<v8::Object> CharacterData::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->characterDataPrototype.IsEmpty()) {
- d->characterDataPrototype = qPersistentNew<v8::Object>(v8::Object::New());
- d->characterDataPrototype->SetPrototype(Node::prototype(engine));
- d->characterDataPrototype->SetAccessor(v8::String::New("data"), nodeValue,
- 0, v8::External::Wrap(engine));
- d->characterDataPrototype->SetAccessor(v8::String::New("length"), length,
- 0, v8::External::Wrap(engine));
- engine->freezeObject(d->characterDataPrototype);
- }
- return d->characterDataPrototype;
-}
-
-v8::Handle<v8::Value> Text::isElementContentWhitespace(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
- Q_UNUSED(engine)
- return v8::Boolean::New(r->d->data.trimmed().isEmpty());
-}
-
-v8::Handle<v8::Value> Text::wholeText(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- return engine->toString(r->d->data);
-}
-
-v8::Handle<v8::Object> Text::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->textPrototype.IsEmpty()) {
- d->textPrototype = qPersistentNew<v8::Object>(v8::Object::New());
- d->textPrototype->SetPrototype(CharacterData::prototype(engine));
- d->textPrototype->SetAccessor(v8::String::New("isElementContentWhitespace"), isElementContentWhitespace,
- 0, v8::External::Wrap(engine));
- d->textPrototype->SetAccessor(v8::String::New("wholeText"), wholeText,
- 0, v8::External::Wrap(engine));
- engine->freezeObject(d->textPrototype);
- }
- return d->textPrototype;
-}
-
-v8::Handle<v8::Object> CDATA::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->cdataPrototype.IsEmpty()) {
- d->cdataPrototype = qPersistentNew<v8::Object>(v8::Object::New());
- d->cdataPrototype->SetPrototype(Text::prototype(engine));
- engine->freezeObject(d->cdataPrototype);
- }
- return d->cdataPrototype;
-}
-
-v8::Handle<v8::Object> Document::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->documentPrototype.IsEmpty()) {
- d->documentPrototype = qPersistentNew<v8::Object>(v8::Object::New());
- d->documentPrototype->SetPrototype(Node::prototype(engine));
- d->documentPrototype->SetAccessor(v8::String::New("xmlVersion"), xmlVersion,
- 0, v8::External::Wrap(engine));
- d->documentPrototype->SetAccessor(v8::String::New("xmlEncoding"), xmlEncoding,
- 0, v8::External::Wrap(engine));
- d->documentPrototype->SetAccessor(v8::String::New("xmlStandalone"), xmlStandalone,
- 0, v8::External::Wrap(engine));
- d->documentPrototype->SetAccessor(v8::String::New("documentElement"), documentElement,
- 0, v8::External::Wrap(engine));
- engine->freezeObject(d->documentPrototype);
- }
- return d->documentPrototype;
-}
-
-v8::Handle<v8::Value> Document::load(QV8Engine *engine, const QByteArray &data)
-{
- Q_ASSERT(engine);
-
- DocumentImpl *document = 0;
- QStack<NodeImpl *> nodeStack;
-
- QXmlStreamReader reader(data);
-
- while (!reader.atEnd()) {
- switch (reader.readNext()) {
- case QXmlStreamReader::NoToken:
- break;
- case QXmlStreamReader::Invalid:
- break;
- case QXmlStreamReader::StartDocument:
- Q_ASSERT(!document);
- document = new DocumentImpl;
- document->document = document;
- document->version = reader.documentVersion().toString();
- document->encoding = reader.documentEncoding().toString();
- document->isStandalone = reader.isStandaloneDocument();
- break;
- case QXmlStreamReader::EndDocument:
- break;
- case QXmlStreamReader::StartElement:
- {
- Q_ASSERT(document);
- NodeImpl *node = new NodeImpl;
- node->document = document;
- node->namespaceUri = reader.namespaceUri().toString();
- node->name = reader.name().toString();
- if (nodeStack.isEmpty()) {
- document->root = node;
- } else {
- node->parent = nodeStack.top();
- node->parent->children.append(node);
- }
- nodeStack.append(node);
-
- foreach (const QXmlStreamAttribute &a, reader.attributes()) {
- NodeImpl *attr = new NodeImpl;
- attr->document = document;
- attr->type = NodeImpl::Attr;
- attr->namespaceUri = a.namespaceUri().toString();
- attr->name = a.name().toString();
- attr->data = a.value().toString();
- attr->parent = node;
- node->attributes.append(attr);
- }
- }
- break;
- case QXmlStreamReader::EndElement:
- nodeStack.pop();
- break;
- case QXmlStreamReader::Characters:
- {
- NodeImpl *node = new NodeImpl;
- node->document = document;
- node->type = reader.isCDATA()?NodeImpl::CDATA:NodeImpl::Text;
- node->parent = nodeStack.top();
- node->parent->children.append(node);
- node->data = reader.text().toString();
- }
- break;
- case QXmlStreamReader::Comment:
- break;
- case QXmlStreamReader::DTD:
- break;
- case QXmlStreamReader::EntityReference:
- break;
- case QXmlStreamReader::ProcessingInstruction:
- break;
- }
- }
-
- if (!document || reader.hasError()) {
- if (document) D(document);
- return v8::Null();
- }
-
- v8::Local<v8::Object> instance = xhrdata(engine)->newNode();
- QDeclarativeDOMNodeResource *r = new QDeclarativeDOMNodeResource(engine);
- r->d = document;
- instance->SetExternalResource(r);
- instance->SetPrototype(Document::prototype(engine));
- return instance;
-}
-
-Node::Node()
-: d(0)
-{
-}
-
-Node::Node(const Node &o)
-: d(o.d)
-{
- if (d) A(d);
-}
-
-Node::~Node()
-{
- if (d) D(d);
-}
-
-bool Node::isNull() const
-{
- return d == 0;
-}
-
-v8::Handle<v8::Value> NamedNodeMap::length(v8::Local<v8::String>, const v8::AccessorInfo &args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
- Q_UNUSED(engine)
- return v8::Integer::New(r->list->count());
-}
-
-v8::Handle<v8::Value> NamedNodeMap::indexed(uint32_t index, const v8::AccessorInfo& args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r || !r->list) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if ((int)index < r->list->count()) {
- return Node::create(engine, r->list->at(index));
- } else {
- return v8::Undefined();
- }
-}
-
-v8::Handle<v8::Value> NamedNodeMap::named(v8::Local<v8::String> property, const v8::AccessorInfo& args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r || !r->list) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- QString str = engine->toString(property);
- for (int ii = 0; ii < r->list->count(); ++ii) {
- if (r->list->at(ii)->name == str) {
- return Node::create(engine, r->list->at(ii));
- }
- }
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Object> NamedNodeMap::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->namedNodeMapPrototype.IsEmpty()) {
- v8::Local<v8::ObjectTemplate> ot = v8::ObjectTemplate::New();
- ot->SetAccessor(v8::String::New("length"), length, 0, v8::External::Wrap(engine));
- ot->SetIndexedPropertyHandler(indexed, 0, 0, 0, 0, v8::External::Wrap(engine));
- ot->SetFallbackPropertyHandler(named, 0, 0, 0, 0, v8::External::Wrap(engine));
- d->namedNodeMapPrototype = qPersistentNew<v8::Object>(ot->NewInstance());
- engine->freezeObject(d->namedNodeMapPrototype);
- }
- return d->namedNodeMapPrototype;
-}
-
-v8::Handle<v8::Value> NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, QList<NodeImpl *> *list)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- v8::Local<v8::Object> instance = d->newNode();
- instance->SetPrototype(NamedNodeMap::prototype(engine));
- QDeclarativeDOMNodeResource *r = new QDeclarativeDOMNodeResource(engine);
- r->d = data;
- r->list = list;
- if (data) A(data);
- instance->SetExternalResource(r);
- return instance;
-}
-
-v8::Handle<v8::Value> NodeList::indexed(uint32_t index, const v8::AccessorInfo& args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- if ((int)index < r->d->children.count()) {
- return Node::create(engine, r->d->children.at(index));
- } else {
- return v8::Undefined();
- }
-}
-
-v8::Handle<v8::Value> NodeList::length(v8::Local<v8::String>, const v8::AccessorInfo& args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
- Q_UNUSED(engine)
- return v8::Integer::New(r->d->children.count());
-}
-
-v8::Handle<v8::Object> NodeList::prototype(QV8Engine *engine)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- if (d->nodeListPrototype.IsEmpty()) {
- v8::Local<v8::ObjectTemplate> ot = v8::ObjectTemplate::New();
- ot->SetAccessor(v8::String::New("length"), length, 0, v8::External::Wrap(engine));
- ot->SetIndexedPropertyHandler(indexed, 0, 0, 0, 0, v8::External::Wrap(engine));
- d->nodeListPrototype = qPersistentNew<v8::Object>(ot->NewInstance());
- engine->freezeObject(d->nodeListPrototype);
- }
- return d->nodeListPrototype;
-}
-
-v8::Handle<v8::Value> NodeList::create(QV8Engine *engine, NodeImpl *data)
-{
- QDeclarativeXMLHttpRequestData *d = xhrdata(engine);
- v8::Local<v8::Object> instance = d->newNode();
- instance->SetPrototype(NodeList::prototype(engine));
- QDeclarativeDOMNodeResource *r = new QDeclarativeDOMNodeResource(engine);
- r->d = data;
- if (data) A(data);
- instance->SetExternalResource(r);
- return instance;
-}
-
-v8::Handle<v8::Value> Document::documentElement(v8::Local<v8::String>, const v8::AccessorInfo& args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r || r->d->type != NodeImpl::Document) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- return Node::create(engine, static_cast<DocumentImpl *>(r->d)->root);
-}
-
-v8::Handle<v8::Value> Document::xmlStandalone(v8::Local<v8::String>, const v8::AccessorInfo& args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r || r->d->type != NodeImpl::Document) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
- Q_UNUSED(engine)
- return v8::Boolean::New(static_cast<DocumentImpl *>(r->d)->isStandalone);
-}
-
-v8::Handle<v8::Value> Document::xmlVersion(v8::Local<v8::String>, const v8::AccessorInfo& args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r || r->d->type != NodeImpl::Document) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- return engine->toString(static_cast<DocumentImpl *>(r->d)->version);
-}
-
-v8::Handle<v8::Value> Document::xmlEncoding(v8::Local<v8::String>, const v8::AccessorInfo& args)
-{
- QDeclarativeDOMNodeResource *r = v8_resource_cast<QDeclarativeDOMNodeResource>(args.This());
- if (!r || r->d->type != NodeImpl::Document) return v8::Undefined();
- QV8Engine *engine = V8ENGINE();
-
- return engine->toString(static_cast<DocumentImpl *>(r->d)->encoding);
-}
-
-class QDeclarativeXMLHttpRequest : public QObject, public QV8ObjectResource
-{
-Q_OBJECT
-V8_RESOURCE_TYPE(XMLHttpRequestType)
-public:
- enum State { Unsent = 0,
- Opened = 1, HeadersReceived = 2,
- Loading = 3, Done = 4 };
-
- QDeclarativeXMLHttpRequest(QV8Engine *engine, QNetworkAccessManager *manager);
- virtual ~QDeclarativeXMLHttpRequest();
-
- bool sendFlag() const;
- bool errorFlag() const;
- quint32 readyState() const;
- int replyStatus() const;
- QString replyStatusText() const;
-
- v8::Handle<v8::Value> open(v8::Handle<v8::Object> me, const QString &, const QUrl &);
- v8::Handle<v8::Value> send(v8::Handle<v8::Object> me, const QByteArray &);
- v8::Handle<v8::Value> abort(v8::Handle<v8::Object> me);
-
- void addHeader(const QString &, const QString &);
- QString header(const QString &name);
- QString headers();
-
-
- QString responseBody();
- const QByteArray & rawResponseBody() const;
- bool receivedXml() const;
-private slots:
- void downloadProgress(qint64);
- void error(QNetworkReply::NetworkError);
- void finished();
-
-private:
- void requestFromUrl(const QUrl &url);
-
- State m_state;
- bool m_errorFlag;
- bool m_sendFlag;
- QString m_method;
- QUrl m_url;
- QByteArray m_responseEntityBody;
- QByteArray m_data;
- int m_redirectCount;
-
- typedef QPair<QByteArray, QByteArray> HeaderPair;
- typedef QList<HeaderPair> HeadersList;
- HeadersList m_headersList;
- void fillHeadersList();
-
- bool m_gotXml;
- QByteArray m_mime;
- QByteArray m_charset;
- QTextCodec *m_textCodec;
-#ifndef QT_NO_TEXTCODEC
- QTextCodec* findTextCodec() const;
-#endif
- void readEncoding();
-
- v8::Handle<v8::Object> getMe() const;
- void setMe(v8::Handle<v8::Object> me);
- v8::Persistent<v8::Object> m_me;
-
- void dispatchCallback(v8::Handle<v8::Object> me);
- void printError(v8::Handle<v8::Message>);
-
- int m_status;
- QString m_statusText;
- QNetworkRequest m_request;
- QDeclarativeGuard<QNetworkReply> m_network;
- void destroyNetwork();
-
- QNetworkAccessManager *m_nam;
- QNetworkAccessManager *networkAccessManager() { return m_nam; }
-};
-
-QDeclarativeXMLHttpRequest::QDeclarativeXMLHttpRequest(QV8Engine *engine, QNetworkAccessManager *manager)
-: QV8ObjectResource(engine), m_state(Unsent), m_errorFlag(false), m_sendFlag(false),
- m_redirectCount(0), m_gotXml(false), m_textCodec(0), m_network(0), m_nam(manager)
-{
-}
-
-QDeclarativeXMLHttpRequest::~QDeclarativeXMLHttpRequest()
-{
- destroyNetwork();
-}
-
-bool QDeclarativeXMLHttpRequest::sendFlag() const
-{
- return m_sendFlag;
-}
-
-bool QDeclarativeXMLHttpRequest::errorFlag() const
-{
- return m_errorFlag;
-}
-
-quint32 QDeclarativeXMLHttpRequest::readyState() const
-{
- return m_state;
-}
-
-int QDeclarativeXMLHttpRequest::replyStatus() const
-{
- return m_status;
-}
-
-QString QDeclarativeXMLHttpRequest::replyStatusText() const
-{
- return m_statusText;
-}
-
-v8::Handle<v8::Value> QDeclarativeXMLHttpRequest::open(v8::Handle<v8::Object> me, const QString &method,
- const QUrl &url)
-{
- destroyNetwork();
- m_sendFlag = false;
- m_errorFlag = false;
- m_responseEntityBody = QByteArray();
- m_method = method;
- m_url = url;
- m_state = Opened;
- dispatchCallback(me);
- return v8::Undefined();
-}
-
-void QDeclarativeXMLHttpRequest::addHeader(const QString &name, const QString &value)
-{
- QByteArray utfname = name.toUtf8();
-
- if (m_request.hasRawHeader(utfname)) {
- m_request.setRawHeader(utfname, m_request.rawHeader(utfname) + ',' + value.toUtf8());
- } else {
- m_request.setRawHeader(utfname, value.toUtf8());
- }
-}
-
-QString QDeclarativeXMLHttpRequest::header(const QString &name)
-{
- QByteArray utfname = name.toLower().toUtf8();
-
- foreach (const HeaderPair &header, m_headersList) {
- if (header.first == utfname)
- return QString::fromUtf8(header.second);
- }
- return QString();
-}
-
-QString QDeclarativeXMLHttpRequest::headers()
-{
- QString ret;
-
- foreach (const HeaderPair &header, m_headersList) {
- if (ret.length())
- ret.append(QLatin1String("\r\n"));
- ret = ret % QString::fromUtf8(header.first) % QLatin1String(": ")
- % QString::fromUtf8(header.second);
- }
- return ret;
-}
-
-void QDeclarativeXMLHttpRequest::fillHeadersList()
-{
- QList<QByteArray> headerList = m_network->rawHeaderList();
-
- m_headersList.clear();
- foreach (const QByteArray &header, headerList) {
- HeaderPair pair (header.toLower(), m_network->rawHeader(header));
- if (pair.first == "set-cookie" ||
- pair.first == "set-cookie2")
- continue;
-
- m_headersList << pair;
- }
-}
-
-void QDeclarativeXMLHttpRequest::requestFromUrl(const QUrl &url)
-{
- QNetworkRequest request = m_request;
- request.setUrl(url);
- if(m_method == QLatin1String("POST") ||
- m_method == QLatin1String("PUT")) {
- QVariant var = request.header(QNetworkRequest::ContentTypeHeader);
- if (var.isValid()) {
- QString str = var.toString();
- int charsetIdx = str.indexOf(QLatin1String("charset="));
- if (charsetIdx == -1) {
- // No charset - append
- if (!str.isEmpty()) str.append(QLatin1Char(';'));
- str.append(QLatin1String("charset=UTF-8"));
- } else {
- charsetIdx += 8;
- int n = 0;
- int semiColon = str.indexOf(QLatin1Char(';'), charsetIdx);
- if (semiColon == -1) {
- n = str.length() - charsetIdx;
- } else {
- n = semiColon - charsetIdx;
- }
-
- str.replace(charsetIdx, n, QLatin1String("UTF-8"));
- }
- request.setHeader(QNetworkRequest::ContentTypeHeader, str);
- } else {
- request.setHeader(QNetworkRequest::ContentTypeHeader,
- QLatin1String("text/plain;charset=UTF-8"));
- }
- }
-
- if (xhrDump()) {
- qWarning().nospace() << "XMLHttpRequest: " << qPrintable(m_method) << " " << qPrintable(url.toString());
- if (!m_data.isEmpty()) {
- qWarning().nospace() << " "
- << qPrintable(QString::fromUtf8(m_data));
- }
- }
-
- if (m_method == QLatin1String("GET"))
- m_network = networkAccessManager()->get(request);
- else if (m_method == QLatin1String("HEAD"))
- m_network = networkAccessManager()->head(request);
- else if (m_method == QLatin1String("POST"))
- m_network = networkAccessManager()->post(request, m_data);
- else if (m_method == QLatin1String("PUT"))
- m_network = networkAccessManager()->put(request, m_data);
- else if (m_method == QLatin1String("DELETE"))
- m_network = networkAccessManager()->deleteResource(request);
-
- QObject::connect(m_network, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(downloadProgress(qint64)));
- QObject::connect(m_network, SIGNAL(error(QNetworkReply::NetworkError)),
- this, SLOT(error(QNetworkReply::NetworkError)));
- QObject::connect(m_network, SIGNAL(finished()),
- this, SLOT(finished()));
-}
-
-v8::Handle<v8::Value> QDeclarativeXMLHttpRequest::send(v8::Handle<v8::Object> me, const QByteArray &data)
-{
- m_errorFlag = false;
- m_sendFlag = true;
- m_redirectCount = 0;
- m_data = data;
-
- setMe(me);
-
- requestFromUrl(m_url);
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> QDeclarativeXMLHttpRequest::abort(v8::Handle<v8::Object> me)
-{
- destroyNetwork();
- m_responseEntityBody = QByteArray();
- m_errorFlag = true;
- m_request = QNetworkRequest();
-
- if (!(m_state == Unsent ||
- (m_state == Opened && !m_sendFlag) ||
- m_state == Done)) {
-
- m_state = Done;
- m_sendFlag = false;
- dispatchCallback(me);
- }
-
- m_state = Unsent;
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Object> QDeclarativeXMLHttpRequest::getMe() const
-{
- return m_me;
-}
-
-void QDeclarativeXMLHttpRequest::setMe(v8::Handle<v8::Object> me)
-{
- qPersistentDispose(m_me);
-
- if (!me.IsEmpty())
- m_me = qPersistentNew<v8::Object>(me);
-}
-
-void QDeclarativeXMLHttpRequest::downloadProgress(qint64 bytes)
-{
- v8::HandleScope handle_scope;
-
- Q_UNUSED(bytes)
- m_status =
- m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- m_statusText =
- QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
-
- // ### We assume if this is called the headers are now available
- if (m_state < HeadersReceived) {
- m_state = HeadersReceived;
- fillHeadersList ();
- v8::TryCatch tc;
- dispatchCallback(m_me);
- if (tc.HasCaught()) printError(tc.Message());
- }
-
- bool wasEmpty = m_responseEntityBody.isEmpty();
- m_responseEntityBody.append(m_network->readAll());
- if (wasEmpty && !m_responseEntityBody.isEmpty()) {
- m_state = Loading;
- v8::TryCatch tc;
- dispatchCallback(m_me);
- if (tc.HasCaught()) printError(tc.Message());
- }
-}
-
-static const char *errorToString(QNetworkReply::NetworkError error)
-{
- int idx = QNetworkReply::staticMetaObject.indexOfEnumerator("NetworkError");
- if (idx == -1) return "EnumLookupFailed";
-
- QMetaEnum e = QNetworkReply::staticMetaObject.enumerator(idx);
-
- const char *name = e.valueToKey(error);
- if (!name) return "EnumLookupFailed";
- else return name;
-}
-
-void QDeclarativeXMLHttpRequest::error(QNetworkReply::NetworkError error)
-{
- v8::HandleScope handle_scope;
-
- Q_UNUSED(error)
- m_status =
- m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- m_statusText =
- QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
-
- m_responseEntityBody = QByteArray();
-
- m_request = QNetworkRequest();
- m_data.clear();
- destroyNetwork();
-
- if (xhrDump()) {
- qWarning().nospace() << "XMLHttpRequest: ERROR " << qPrintable(m_url.toString());
- qWarning().nospace() << " " << error << " " << errorToString(error) << " " << m_statusText;
- }
-
- if (error == QNetworkReply::ContentAccessDenied ||
- error == QNetworkReply::ContentOperationNotPermittedError ||
- error == QNetworkReply::ContentNotFoundError ||
- error == QNetworkReply::AuthenticationRequiredError ||
- error == QNetworkReply::ContentReSendError ||
- error == QNetworkReply::UnknownContentError) {
- m_state = Loading;
- v8::TryCatch tc;
- dispatchCallback(m_me);
- if (tc.HasCaught()) printError(tc.Message());
- } else {
- m_errorFlag = true;
- }
-
- m_state = Done;
-
- v8::TryCatch tc;
- dispatchCallback(m_me);
- if (tc.HasCaught()) printError(tc.Message());
-}
-
-#define XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION 15
-void QDeclarativeXMLHttpRequest::finished()
-{
- v8::HandleScope handle_scope;
-
- m_redirectCount++;
- if (m_redirectCount < XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION) {
- QVariant redirect = m_network->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- QUrl url = m_network->url().resolved(redirect.toUrl());
- destroyNetwork();
- requestFromUrl(url);
- return;
- }
- }
-
- m_status =
- m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- m_statusText =
- QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
-
- if (m_state < HeadersReceived) {
- m_state = HeadersReceived;
- fillHeadersList ();
- v8::TryCatch tc;
- dispatchCallback(m_me);
- if (tc.HasCaught()) printError(tc.Message());
- }
- m_responseEntityBody.append(m_network->readAll());
- readEncoding();
-
- if (xhrDump()) {
- qWarning().nospace() << "XMLHttpRequest: RESPONSE " << qPrintable(m_url.toString());
- if (!m_responseEntityBody.isEmpty()) {
- qWarning().nospace() << " "
- << qPrintable(QString::fromUtf8(m_responseEntityBody));
- }
- }
-
-
- m_data.clear();
- destroyNetwork();
- if (m_state < Loading) {
- m_state = Loading;
- v8::TryCatch tc;
- dispatchCallback(m_me);
- if (tc.HasCaught()) printError(tc.Message());
- }
- m_state = Done;
-
- v8::TryCatch tc;
- dispatchCallback(m_me);
- if (tc.HasCaught()) printError(tc.Message());
-
- setMe(v8::Handle<v8::Object>());
-}
-
-
-void QDeclarativeXMLHttpRequest::readEncoding()
-{
- foreach (const HeaderPair &header, m_headersList) {
- if (header.first == "content-type") {
- int separatorIdx = header.second.indexOf(';');
- if (separatorIdx == -1) {
- m_mime == header.second;
- } else {
- m_mime = header.second.mid(0, separatorIdx);
- int charsetIdx = header.second.indexOf("charset=");
- if (charsetIdx != -1) {
- charsetIdx += 8;
- separatorIdx = header.second.indexOf(';', charsetIdx);
- m_charset = header.second.mid(charsetIdx, separatorIdx >= 0 ? separatorIdx : header.second.length());
- }
- }
- break;
- }
- }
-
- if (m_mime.isEmpty() || m_mime == "text/xml" || m_mime == "application/xml" || m_mime.endsWith("+xml"))
- m_gotXml = true;
-}
-
-bool QDeclarativeXMLHttpRequest::receivedXml() const
-{
- return m_gotXml;
-}
-
-
-#ifndef QT_NO_TEXTCODEC
-QTextCodec* QDeclarativeXMLHttpRequest::findTextCodec() const
-{
- QTextCodec *codec = 0;
-
- if (!m_charset.isEmpty())
- codec = QTextCodec::codecForName(m_charset);
-
- if (!codec && m_gotXml) {
- QXmlStreamReader reader(m_responseEntityBody);
- reader.readNext();
- codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
- }
-
- if (!codec && m_mime == "text/html")
- codec = QTextCodec::codecForHtml(m_responseEntityBody, 0);
-
- if (!codec)
- codec = QTextCodec::codecForUtfText(m_responseEntityBody, 0);
-
- if (!codec)
- codec = QTextCodec::codecForName("UTF-8");
- return codec;
-}
-#endif
-
-
-QString QDeclarativeXMLHttpRequest::responseBody()
-{
-#ifndef QT_NO_TEXTCODEC
- if (!m_textCodec)
- m_textCodec = findTextCodec();
- if (m_textCodec)
- return m_textCodec->toUnicode(m_responseEntityBody);
-#endif
-
- return QString::fromUtf8(m_responseEntityBody);
-}
-
-const QByteArray &QDeclarativeXMLHttpRequest::rawResponseBody() const
-{
- return m_responseEntityBody;
-}
-
-// Requires a TryCatch scope
-void QDeclarativeXMLHttpRequest::dispatchCallback(v8::Handle<v8::Object> me)
-{
- v8::Local<v8::Value> callback = me->Get(v8::String::New("onreadystatechange"));
- if (callback->IsFunction()) {
- v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(callback);
-
- f->Call(me, 0, 0);
- }
-}
-
-// Must have a handle scope
-void QDeclarativeXMLHttpRequest::printError(v8::Handle<v8::Message> message)
-{
- v8::Context::Scope scope(engine->context());
-
- QDeclarativeError error;
- QDeclarativeExpressionPrivate::exceptionToError(message, error);
- QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate::get(engine->engine()), error);
-}
-
-void QDeclarativeXMLHttpRequest::destroyNetwork()
-{
- if (m_network) {
- m_network->disconnect();
- m_network->deleteLater();
- m_network = 0;
- }
-}
-
-// XMLHttpRequest methods
-static v8::Handle<v8::Value> qmlxmlhttprequest_open(const v8::Arguments &args)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(args.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (args.Length() < 2 || args.Length() > 5)
- V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
-
- QV8Engine *engine = r->engine;
-
- // Argument 0 - Method
- QString method = engine->toString(args[0]).toUpper();
- if (method != QLatin1String("GET") &&
- method != QLatin1String("PUT") &&
- method != QLatin1String("HEAD") &&
- method != QLatin1String("POST") &&
- method != QLatin1String("DELETE"))
- V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type");
-
- // Argument 1 - URL
- QUrl url = QUrl::fromEncoded(engine->toString(args[1]).toUtf8());
-
- if (url.isRelative())
- url = engine->callingContext()->resolvedUrl(url);
-
- // Argument 2 - async (optional)
- if (args.Length() > 2 && !args[2]->BooleanValue())
- V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported");
-
- // Argument 3/4 - user/pass (optional)
- QString username, password;
- if (args.Length() > 3)
- username = engine->toString(args[3]);
- if (args.Length() > 4)
- password = engine->toString(args[4]);
-
- // Clear the fragment (if any)
- url.setFragment(QString());
-
- // Set username/password
- if (!username.isNull()) url.setUserName(username);
- if (!password.isNull()) url.setPassword(password);
-
- return r->open(args.This(), method, url);
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_setRequestHeader(const v8::Arguments &args)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(args.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (args.Length() != 2)
- V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
-
- if (r->readyState() != QDeclarativeXMLHttpRequest::Opened || r->sendFlag())
- V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
-
- QV8Engine *engine = r->engine;
-
- QString name = engine->toString(args[0]);
- QString value = engine->toString(args[1]);
-
- // ### Check that name and value are well formed
-
- QString nameUpper = name.toUpper();
- if (nameUpper == QLatin1String("ACCEPT-CHARSET") ||
- nameUpper == QLatin1String("ACCEPT-ENCODING") ||
- nameUpper == QLatin1String("CONNECTION") ||
- nameUpper == QLatin1String("CONTENT-LENGTH") ||
- nameUpper == QLatin1String("COOKIE") ||
- nameUpper == QLatin1String("COOKIE2") ||
- nameUpper == QLatin1String("CONTENT-TRANSFER-ENCODING") ||
- nameUpper == QLatin1String("DATE") ||
- nameUpper == QLatin1String("EXPECT") ||
- nameUpper == QLatin1String("HOST") ||
- nameUpper == QLatin1String("KEEP-ALIVE") ||
- nameUpper == QLatin1String("REFERER") ||
- nameUpper == QLatin1String("TE") ||
- nameUpper == QLatin1String("TRAILER") ||
- nameUpper == QLatin1String("TRANSFER-ENCODING") ||
- nameUpper == QLatin1String("UPGRADE") ||
- nameUpper == QLatin1String("USER-AGENT") ||
- nameUpper == QLatin1String("VIA") ||
- nameUpper.startsWith(QLatin1String("PROXY-")) ||
- nameUpper.startsWith(QLatin1String("SEC-")))
- return v8::Undefined();
-
- r->addHeader(name, value);
-
- return v8::Undefined();
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_send(const v8::Arguments &args)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(args.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- QV8Engine *engine = r->engine;
-
- if (r->readyState() != QDeclarativeXMLHttpRequest::Opened ||
- r->sendFlag())
- V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
-
- QByteArray data;
- if (args.Length() > 0)
- data = engine->toString(args[0]).toUtf8();
-
- return r->send(args.This(), data);
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_abort(const v8::Arguments &args)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(args.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- return r->abort(args.This());
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_getResponseHeader(const v8::Arguments &args)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(args.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- QV8Engine *engine = r->engine;
-
- if (args.Length() != 1)
- V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
-
- if (r->readyState() != QDeclarativeXMLHttpRequest::Loading &&
- r->readyState() != QDeclarativeXMLHttpRequest::Done &&
- r->readyState() != QDeclarativeXMLHttpRequest::HeadersReceived)
- V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
-
- return engine->toString(r->header(engine->toString(args[0])));
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_getAllResponseHeaders(const v8::Arguments &args)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(args.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- QV8Engine *engine = r->engine;
-
- if (args.Length() != 0)
- V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
-
- if (r->readyState() != QDeclarativeXMLHttpRequest::Loading &&
- r->readyState() != QDeclarativeXMLHttpRequest::Done &&
- r->readyState() != QDeclarativeXMLHttpRequest::HeadersReceived)
- V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
-
- return engine->toString(r->headers());
-}
-
-// XMLHttpRequest properties
-static v8::Handle<v8::Value> qmlxmlhttprequest_readyState(v8::Local<v8::String> /* property */,
- const v8::AccessorInfo& info)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(info.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- return v8::Integer::NewFromUnsigned(r->readyState());
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_status(v8::Local<v8::String> /* property */,
- const v8::AccessorInfo& info)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(info.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (r->readyState() == QDeclarativeXMLHttpRequest::Unsent ||
- r->readyState() == QDeclarativeXMLHttpRequest::Opened)
- V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
-
- if (r->errorFlag())
- return v8::Integer::New(0);
- else
- return v8::Integer::New(r->replyStatus());
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_statusText(v8::Local<v8::String> /* property */,
- const v8::AccessorInfo& info)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(info.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- QV8Engine *engine = r->engine;
-
- if (r->readyState() == QDeclarativeXMLHttpRequest::Unsent ||
- r->readyState() == QDeclarativeXMLHttpRequest::Opened)
- V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
-
- if (r->errorFlag())
- return engine->toString(QString());
- else
- return engine->toString(r->replyStatusText());
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_responseText(v8::Local<v8::String> /* property */,
- const v8::AccessorInfo& info)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(info.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- QV8Engine *engine = r->engine;
-
- if (r->readyState() != QDeclarativeXMLHttpRequest::Loading &&
- r->readyState() != QDeclarativeXMLHttpRequest::Done)
- return engine->toString(QString());
- else
- return engine->toString(r->responseBody());
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_responseXML(v8::Local<v8::String> /* property */,
- const v8::AccessorInfo& info)
-{
- QDeclarativeXMLHttpRequest *r = v8_resource_cast<QDeclarativeXMLHttpRequest>(info.This());
- if (!r)
- V8THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (!r->receivedXml() ||
- (r->readyState() != QDeclarativeXMLHttpRequest::Loading &&
- r->readyState() != QDeclarativeXMLHttpRequest::Done)) {
- return v8::Null();
- } else {
- return Document::load(r->engine, r->rawResponseBody());
- }
-}
-
-static v8::Handle<v8::Value> qmlxmlhttprequest_new(const v8::Arguments &args)
-{
- if (args.IsConstructCall()) {
- QV8Engine *engine = V8ENGINE();
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine->engine());
- Q_UNUSED(ep)
- QDeclarativeXMLHttpRequest *r = new QDeclarativeXMLHttpRequest(engine, engine->networkAccessManager());
- args.This()->SetExternalResource(r);
-
- return args.This();
- } else {
- return v8::Undefined();
- }
-}
-
-#define NEWFUNCTION(function) v8::FunctionTemplate::New(function)->GetFunction()
-
-void qt_rem_qmlxmlhttprequest(QV8Engine * /* engine */, void *d)
-{
- QDeclarativeXMLHttpRequestData *data = (QDeclarativeXMLHttpRequestData *)d;
- delete data;
-}
-
-void *qt_add_qmlxmlhttprequest(QV8Engine *engine)
-{
- v8::PropertyAttribute attributes = (v8::PropertyAttribute)(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
-
- // XMLHttpRequest
- v8::Local<v8::FunctionTemplate> xmlhttprequest = v8::FunctionTemplate::New(qmlxmlhttprequest_new,
- v8::External::Wrap(engine));
- xmlhttprequest->InstanceTemplate()->SetHasExternalResource(true);
-
- // Methods
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("open"), NEWFUNCTION(qmlxmlhttprequest_open), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("setRequestHeader"), NEWFUNCTION(qmlxmlhttprequest_setRequestHeader), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("send"), NEWFUNCTION(qmlxmlhttprequest_send), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("abort"), NEWFUNCTION(qmlxmlhttprequest_abort), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("getResponseHeader"), NEWFUNCTION(qmlxmlhttprequest_getResponseHeader), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("getAllResponseHeaders"), NEWFUNCTION(qmlxmlhttprequest_getAllResponseHeaders), attributes);
-
- // Read-only properties
- xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("readyState"), qmlxmlhttprequest_readyState, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
- xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("status"),qmlxmlhttprequest_status, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
- xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("statusText"),qmlxmlhttprequest_statusText, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
- xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("responseText"),qmlxmlhttprequest_responseText, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
- xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("responseXML"),qmlxmlhttprequest_responseXML, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
-
- // State values
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("UNSENT"), v8::Integer::New(0), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("OPENED"), v8::Integer::New(1), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("HEADERS_RECEIVED"), v8::Integer::New(2), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("LOADING"), v8::Integer::New(3), attributes);
- xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("DONE"), v8::Integer::New(4), attributes);
-
- // Constructor
- xmlhttprequest->Set(v8::String::New("UNSENT"), v8::Integer::New(0), attributes);
- xmlhttprequest->Set(v8::String::New("OPENED"), v8::Integer::New(1), attributes);
- xmlhttprequest->Set(v8::String::New("HEADERS_RECEIVED"), v8::Integer::New(2), attributes);
- xmlhttprequest->Set(v8::String::New("LOADING"), v8::Integer::New(3), attributes);
- xmlhttprequest->Set(v8::String::New("DONE"), v8::Integer::New(4), attributes);
- engine->global()->Set(v8::String::New("XMLHttpRequest"), xmlhttprequest->GetFunction());
-
- QDeclarativeXMLHttpRequestData *data = new QDeclarativeXMLHttpRequestData;
- return data;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_XMLSTREAMREADER
-
-#include <qdeclarativexmlhttprequest.moc>
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest_p.h b/src/declarative/qml/qdeclarativexmlhttprequest_p.h
deleted file mode 100644
index 3177a7a3be..0000000000
--- a/src/declarative/qml/qdeclarativexmlhttprequest_p.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEXMLHTTPREQUEST_P_H
-#define QDECLARATIVEXMLHTTPREQUEST_P_H
-
-#include <QtDeclarative/qjsengine.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>
-
-#ifndef QT_NO_XMLSTREAMREADER
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-
-void *qt_add_qmlxmlhttprequest(QV8Engine *engine);
-void qt_rem_qmlxmlhttprequest(QV8Engine *engine, void *);
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_XMLSTREAMREADER
-
-#endif // QDECLARATIVEXMLHTTPREQUEST_P_H
-
diff --git a/src/declarative/qml/qlistmodelinterface.cpp b/src/declarative/qml/qlistmodelinterface.cpp
deleted file mode 100644
index 32d8ee60b7..0000000000
--- a/src/declarative/qml/qlistmodelinterface.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclaractive module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlistmodelinterface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- \class QListModelInterface
- \brief The QListModelInterface class can be subclassed to provide C++ models to QDeclarativeGraphics Views
-
- This class is comprised primarily of pure virtual functions which
- you must implement in a subclass. You can then use the subclass
- as a model for a QDeclarativeGraphics view, such as a QDeclarativeListView.
-*/
-
-/*! \fn QListModelInterface::QListModelInterface(QObject *parent)
- Constructs a QListModelInterface with the specified \a parent.
-*/
-
- /*! \fn QListModelInterface::QListModelInterface(QObjectPrivate &dd, QObject *parent)
-
- \internal
- */
-
-/*! \fn QListModelInterface::~QListModelInterface()
- The destructor is virtual.
- */
-
-/*! \fn int QListModelInterface::count() const
- Returns the number of data entries in the model.
-*/
-
-/*! \fn QVariant QListModelInterface::data(int index, int role) const
- Returns the data at the given \a index for the specified \a roles.
-*/
-
-/*! \fn QList<int> QListModelInterface::roles() const
- Returns the list of roles for which the list model interface
- provides data.
-*/
-
-/*! \fn QString QListModelInterface::toString(int role) const
- Returns a string description of the specified \a role.
-*/
-
-/*! \fn void QListModelInterface::itemsInserted(int index, int count)
- Emit this signal when \a count items are inserted at \a index.
- */
-
-/*! \fn void QListModelInterface::itemsRemoved(int index, int count)
- Emit this signal when \a count items are removed at \a index.
- */
-
-/*! \fn void QListModelInterface::itemsMoved(int from, int to, int count)
- Emit this signal when \a count items are moved from index \a from
- to index \a to.
- */
-
-/*! \fn void QListModelInterface::itemsChanged(int index, int count, const QList<int> &roles)
- Emit this signal when \a count items at \a index have had their
- \a roles changed.
- */
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qlistmodelinterface_p.h b/src/declarative/qml/qlistmodelinterface_p.h
deleted file mode 100644
index d653699dff..0000000000
--- a/src/declarative/qml/qlistmodelinterface_p.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLISTMODELINTERFACE_H
-#define QLISTMODELINTERFACE_H
-
-#include <QtCore/QHash>
-#include <QtCore/QVariant>
-
-#include <private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class Q_DECLARATIVE_PRIVATE_EXPORT QListModelInterface : public QObject
-{
- Q_OBJECT
- public:
- QListModelInterface(QObject *parent = 0) : QObject(parent) {}
- virtual ~QListModelInterface() {}
-
- virtual int count() const = 0;
- virtual QVariant data(int index, int role) const = 0;
-
- virtual QList<int> roles() const = 0;
- virtual QString toString(int role) const = 0;
-
- Q_SIGNALS:
- void itemsInserted(int index, int count);
- void itemsRemoved(int index, int count);
- void itemsMoved(int from, int to, int count);
- void itemsChanged(int index, int count, const QList<int> &roles);
-
- protected:
- QListModelInterface(QObjectPrivate &dd, QObject *parent)
- : QObject(dd, parent) {}
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif //QTREEMODELINTERFACE_H
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
deleted file mode 100644
index 8b03028c34..0000000000
--- a/src/declarative/qml/qml.pri
+++ /dev/null
@@ -1,125 +0,0 @@
-SOURCES += \
- $$PWD/qdeclarativeapplication.cpp \
- $$PWD/qdeclarativeinstruction.cpp \
- $$PWD/qdeclarativelistmodel.cpp \
- $$PWD/qdeclarativelistmodelworkeragent.cpp \
- $$PWD/qdeclarativeopenmetaobject.cpp \
- $$PWD/qdeclarativevmemetaobject.cpp \
- $$PWD/qdeclarativeengine.cpp \
- $$PWD/qdeclarativeexpression.cpp \
- $$PWD/qdeclarativebinding.cpp \
- $$PWD/qdeclarativeproperty.cpp \
- $$PWD/qdeclarativecomponent.cpp \
- $$PWD/qdeclarativeincubator.cpp \
- $$PWD/qdeclarativecontext.cpp \
- $$PWD/qdeclarativecustomparser.cpp \
- $$PWD/qdeclarativepropertyvaluesource.cpp \
- $$PWD/qdeclarativepropertyvalueinterceptor.cpp \
- $$PWD/qdeclarativeproxymetaobject.cpp \
- $$PWD/qdeclarativevme.cpp \
- $$PWD/qdeclarativecompiler.cpp \
- $$PWD/qdeclarativecompileddata.cpp \
- $$PWD/qdeclarativeboundsignal.cpp \
- $$PWD/qdeclarativemetatype.cpp \
- $$PWD/qdeclarativestringconverters.cpp \
- $$PWD/qdeclarativeparserstatus.cpp \
- $$PWD/qdeclarativetypeloader.cpp \
- $$PWD/qdeclarativeinfo.cpp \
- $$PWD/qdeclarativeerror.cpp \
- $$PWD/qdeclarativescript.cpp \
- $$PWD/qdeclarativerewrite.cpp \
- $$PWD/qdeclarativevaluetype.cpp \
- $$PWD/qdeclarativeaccessors.cpp \
- $$PWD/qdeclarativexmlhttprequest.cpp \
- $$PWD/qdeclarativewatcher.cpp \
- $$PWD/qdeclarativecleanup.cpp \
- $$PWD/qdeclarativepropertycache.cpp \
- $$PWD/qdeclarativenotifier.cpp \
- $$PWD/qdeclarativeintegercache.cpp \
- $$PWD/qdeclarativetypenotavailable.cpp \
- $$PWD/qdeclarativetypenamecache.cpp \
- $$PWD/qdeclarativescriptstring.cpp \
- $$PWD/qdeclarativeworkerscript.cpp \
- $$PWD/qdeclarativeimageprovider.cpp \
- $$PWD/qdeclarativenetworkaccessmanagerfactory.cpp \
- $$PWD/qdeclarativedirparser.cpp \
- $$PWD/qdeclarativeextensionplugin.cpp \
- $$PWD/qdeclarativeimport.cpp \
- $$PWD/qdeclarativelist.cpp \
- $$PWD/qdeclarativelocale.cpp \
- $$PWD/qlistmodelinterface.cpp
-
-HEADERS += \
- $$PWD/qdeclarativeglobal_p.h \
- $$PWD/qdeclarativeinstruction_p.h \
- $$PWD/qdeclarativelistmodel_p.h\
- $$PWD/qdeclarativelistmodel_p_p.h\
- $$PWD/qdeclarativelistmodelworkeragent_p.h \
- $$PWD/qdeclarativeopenmetaobject_p.h \
- $$PWD/qdeclarativevmemetaobject_p.h \
- $$PWD/qdeclarative.h \
- $$PWD/qdeclarativeapplication_p.h \
- $$PWD/qdeclarativebinding_p.h \
- $$PWD/qdeclarativebinding_p_p.h \
- $$PWD/qdeclarativeproperty.h \
- $$PWD/qdeclarativecomponent.h \
- $$PWD/qdeclarativecomponent_p.h \
- $$PWD/qdeclarativeincubator.h \
- $$PWD/qdeclarativeincubator_p.h \
- $$PWD/qdeclarativecustomparser_p.h \
- $$PWD/qdeclarativecustomparser_p_p.h \
- $$PWD/qdeclarativepropertyvaluesource.h \
- $$PWD/qdeclarativepropertyvalueinterceptor_p.h \
- $$PWD/qdeclarativeboundsignal_p.h \
- $$PWD/qdeclarativeparserstatus.h \
- $$PWD/qdeclarativeproxymetaobject_p.h \
- $$PWD/qdeclarativevme_p.h \
- $$PWD/qdeclarativecompiler_p.h \
- $$PWD/qdeclarativeengine_p.h \
- $$PWD/qdeclarativeexpression_p.h \
- $$PWD/qdeclarativeprivate.h \
- $$PWD/qdeclarativemetatype_p.h \
- $$PWD/qdeclarativeengine.h \
- $$PWD/qdeclarativecontext.h \
- $$PWD/qdeclarativeexpression.h \
- $$PWD/qdeclarativestringconverters_p.h \
- $$PWD/qdeclarativeinfo.h \
- $$PWD/qdeclarativeproperty_p.h \
- $$PWD/qdeclarativecontext_p.h \
- $$PWD/qdeclarativetypeloader_p.h \
- $$PWD/qdeclarativelist.h \
- $$PWD/qdeclarativelist_p.h \
- $$PWD/qdeclarativedata_p.h \
- $$PWD/qdeclarativeerror.h \
- $$PWD/qdeclarativescript_p.h \
- $$PWD/qdeclarativerewrite_p.h \
- $$PWD/qdeclarativevaluetype_p.h \
- $$PWD/qdeclarativeaccessors_p.h \
- $$PWD/qdeclarativexmlhttprequest_p.h \
- $$PWD/qdeclarativewatcher_p.h \
- $$PWD/qdeclarativecleanup_p.h \
- $$PWD/qdeclarativepropertycache_p.h \
- $$PWD/qdeclarativenotifier_p.h \
- $$PWD/qdeclarativeintegercache_p.h \
- $$PWD/qdeclarativetypenotavailable_p.h \
- $$PWD/qdeclarativetypenamecache_p.h \
- $$PWD/qdeclarativescriptstring.h \
- $$PWD/qdeclarativeworkerscript_p.h \
- $$PWD/qdeclarativeguard_p.h \
- $$PWD/qdeclarativeimageprovider.h \
- $$PWD/qdeclarativenetworkaccessmanagerfactory.h \
- $$PWD/qdeclarativedirparser_p.h \
- $$PWD/qdeclarativeextensioninterface.h \
- $$PWD/qdeclarativeimport_p.h \
- $$PWD/qdeclarativeextensionplugin.h \
- $$PWD/qdeclarativenullablevalue_p_p.h \
- $$PWD/qdeclarativescriptstring_p.h \
- $$PWD/qdeclarativelocale_p.h \
- $$PWD/qlistmodelinterface_p.h \
- $$PWD/qdeclarativecomponentattached_p.h
-
-include(parser/parser.pri)
-include(rewriter/rewriter.pri)
-include(ftw/ftw.pri)
-include(v4/v4.pri)
-include(v8/v8.pri)
diff --git a/src/declarative/qml/rewriter/textwriter.cpp b/src/declarative/qml/rewriter/textwriter.cpp
deleted file mode 100644
index 5cf5c0388e..0000000000
--- a/src/declarative/qml/rewriter/textwriter.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "textwriter_p.h"
-
-QT_QML_BEGIN_NAMESPACE
-
-using namespace QDeclarativeJS;
-
-TextWriter::TextWriter()
- :string(0), cursor(0)
-{
-}
-
-static bool overlaps(int posA, int lengthA, int posB, int lengthB) {
- return (posA < posB + lengthB && posA + lengthA > posB + lengthB)
- || (posA < posB && posA + lengthA > posB);
-}
-
-bool TextWriter::hasOverlap(int pos, int length)
-{
- {
- QListIterator<Replace> i(replaceList);
- while (i.hasNext()) {
- const Replace &cmd = i.next();
- if (overlaps(pos, length, cmd.pos, cmd.length))
- return true;
- }
- }
- {
- QListIterator<Move> i(moveList);
- while (i.hasNext()) {
- const Move &cmd = i.next();
- if (overlaps(pos, length, cmd.pos, cmd.length))
- return true;
- }
- return false;
- }
-}
-
-bool TextWriter::hasMoveInto(int pos, int length)
-{
- QListIterator<Move> i(moveList);
- while (i.hasNext()) {
- const Move &cmd = i.next();
- if (cmd.to >= pos && cmd.to < pos + length)
- return true;
- }
- return false;
-}
-
-void TextWriter::replace(int pos, int length, const QString &replacement)
-{
- Q_ASSERT(!hasOverlap(pos, length));
- Q_ASSERT(!hasMoveInto(pos, length));
-
- Replace cmd;
- cmd.pos = pos;
- cmd.length = length;
- cmd.replacement = replacement;
- replaceList += cmd;
-}
-
-void TextWriter::move(int pos, int length, int to)
-{
- Q_ASSERT(!hasOverlap(pos, length));
-
- Move cmd;
- cmd.pos = pos;
- cmd.length = length;
- cmd.to = to;
- moveList += cmd;
-}
-
-void TextWriter::doReplace(const Replace &replace)
-{
- int diff = replace.replacement.size() - replace.length;
- {
- QMutableListIterator<Replace> i(replaceList);
- while (i.hasNext()) {
- Replace &c = i.next();
- if (replace.pos < c.pos)
- c.pos += diff;
- else if (replace.pos + replace.length < c.pos + c.length)
- c.length += diff;
- }
- }
- {
- QMutableListIterator<Move> i(moveList);
- while (i.hasNext()) {
- Move &c = i.next();
- if (replace.pos < c.pos)
- c.pos += diff;
- else if (replace.pos + replace.length < c.pos + c.length)
- c.length += diff;
-
- if (replace.pos < c.to)
- c.to += diff;
- }
- }
-
- if (string) {
- string->replace(replace.pos, replace.length, replace.replacement);
- } else if (cursor) {
- cursor->setPosition(replace.pos);
- cursor->setPosition(replace.pos + replace.length, QTextCursor::KeepAnchor);
- cursor->insertText(replace.replacement);
- }
-}
-
-void TextWriter::doMove(const Move &move)
-{
- QString text;
- if (string) {
- text = string->mid(move.pos, move.length);
- } else if (cursor) {
- cursor->setPosition(move.pos);
- cursor->setPosition(move.pos + move.length, QTextCursor::KeepAnchor);
- text = cursor->selectedText();
- }
-
- Replace cut;
- cut.pos = move.pos;
- cut.length = move.length;
- Replace paste;
- paste.pos = move.to;
- paste.length = 0;
- paste.replacement = text;
-
- replaceList.append(cut);
- replaceList.append(paste);
-
- Replace cmd;
- while (!replaceList.isEmpty()) {
- cmd = replaceList.first();
- replaceList.removeFirst();
- doReplace(cmd);
- }
-}
-
-void TextWriter::write(QString *s)
-{
- string = s;
- write_helper();
- string = 0;
-}
-
-void TextWriter::write(QTextCursor *textCursor)
-{
- cursor = textCursor;
- write_helper();
- cursor = 0;
-}
-
-void TextWriter::write_helper()
-{
- if (cursor)
- cursor->beginEditBlock();
- {
- Replace cmd;
- while (!replaceList.isEmpty()) {
- cmd = replaceList.first();
- replaceList.removeFirst();
- doReplace(cmd);
- }
- }
- {
- Move cmd;
- while (!moveList.isEmpty()) {
- cmd = moveList.first();
- moveList.removeFirst();
- doMove(cmd);
- }
- }
- if (cursor)
- cursor->endEditBlock();
-}
-
-QT_QML_END_NAMESPACE
diff --git a/src/declarative/qml/rewriter/textwriter_p.h b/src/declarative/qml/rewriter/textwriter_p.h
deleted file mode 100644
index aae9271c1a..0000000000
--- a/src/declarative/qml/rewriter/textwriter_p.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TEXTWRITER_H
-#define TEXTWRITER_H
-
-#include <private/qdeclarativejsglobal_p.h>
-
-#include <QtCore/QString>
-#include <QtCore/QList>
-#include <QtGui/QTextCursor>
-
-QT_BEGIN_HEADER
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-class TextWriter
-{
- QString *string;
- QTextCursor *cursor;
-
- struct Replace {
- int pos;
- int length;
- QString replacement;
- };
-
- QList<Replace> replaceList;
-
- struct Move {
- int pos;
- int length;
- int to;
- };
-
- QList<Move> moveList;
-
- bool hasOverlap(int pos, int length);
- bool hasMoveInto(int pos, int length);
-
- void doReplace(const Replace &replace);
- void doMove(const Move &move);
-
- void write_helper();
-
-public:
- TextWriter();
-
- void replace(int pos, int length, const QString &replacement);
- void move(int pos, int length, int to);
-
- void write(QString *s);
- void write(QTextCursor *textCursor);
-
-};
-
-} // end of namespace QDeclarativeJS
-
-QT_QML_END_NAMESPACE
-QT_END_HEADER
-
-#endif // TEXTWRITER_H
diff --git a/src/declarative/qml/v4/qv4bindings.cpp b/src/declarative/qml/v4/qv4bindings.cpp
deleted file mode 100644
index ecd18cd73f..0000000000
--- a/src/declarative/qml/v4/qv4bindings.cpp
+++ /dev/null
@@ -1,1615 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// #define REGISTER_CLEANUP_DEBUG
-
-#include "qv4bindings_p.h"
-#include "qv4program_p.h"
-#include "qv4compiler_p.h"
-#include "qv4compiler_p_p.h"
-
-#include <private/qdeclarativeaccessors_p.h>
-#include <private/qdeclarativeprofilerservice_p.h>
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativetrace_p.h>
-#include <private/qdeclarativestringconverters_p.h>
-
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include <QtCore/qnumeric.h>
-#include <QtCore/qmath.h>
-#include <math.h> // ::fmod
-
-QT_BEGIN_NAMESPACE
-
-using namespace QDeclarativeJS;
-
-namespace {
-struct Register {
- typedef QDeclarativeRegisterType Type;
-
- void setUndefined() { dataType = UndefinedType; }
- void setNaN() { setqreal(qSNaN()); }
- bool isUndefined() const { return dataType == UndefinedType; }
-
- void setQObject(QObject *o) { qobjectValue = o; dataType = QObjectStarType; }
- QObject *getQObject() const { return qobjectValue; }
-
- void setqreal(qreal v) { qrealValue = v; dataType = QRealType; }
- qreal getqreal() const { return qrealValue; }
- qreal &getqrealref() { return qrealValue; }
-
- void setint(int v) { intValue = v; dataType = IntType; }
- int getint() const { return intValue; }
- int &getintref() { return intValue; }
-
- void setbool(bool v) { boolValue = v; dataType = BoolType; }
- bool getbool() const { return boolValue; }
- bool &getboolref() { return boolValue; }
-
- QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); }
- QString *getstringptr() { return (QString *)typeDataPtr(); }
- QUrl *geturlptr() { return (QUrl *)typeDataPtr(); }
- QColor *getcolorptr() { return (QColor *)typeDataPtr(); }
- const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); }
- const QString *getstringptr() const { return (QString *)typeDataPtr(); }
- const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); }
- const QColor *getcolorptr() const { return (QColor *)typeDataPtr(); }
-
- void *typeDataPtr() { return (void *)&data; }
- void *typeMemory() { return (void *)data; }
- const void *typeDataPtr() const { return (void *)&data; }
- const void *typeMemory() const { return (void *)data; }
-
- Type gettype() const { return dataType; }
- void settype(Type t) { dataType = t; }
-
- Type dataType; // Type of data
- union {
- QObject *qobjectValue;
- qreal qrealValue;
- int intValue;
- bool boolValue;
- void *data[sizeof(QVariant)];
- qint64 q_for_alignment_1;
- double q_for_alignment_2;
- };
-
- inline void cleanup();
- inline void cleanupString();
- inline void cleanupUrl();
- inline void cleanupColor();
- inline void cleanupVariant();
-
- inline void copy(const Register &other);
- inline void init(Type type);
-#ifdef REGISTER_CLEANUP_DEBUG
- Register() {
- type = 0;
- }
-
- ~Register() {
- if (dataType >= FirstCleanupType)
- qWarning("Register leaked of type %d", dataType);
- }
-#endif
-};
-
-void Register::cleanup()
-{
- if (dataType >= FirstCleanupType) {
- if (dataType == QStringType) {
- getstringptr()->~QString();
- } else if (dataType == QUrlType) {
- geturlptr()->~QUrl();
- } else if (dataType == QColorType) {
- getcolorptr()->~QColor();
- } else if (dataType == QVariantType) {
- getvariantptr()->~QVariant();
- }
- }
- setUndefined();
-}
-
-void Register::cleanupString()
-{
- getstringptr()->~QString();
- setUndefined();
-}
-
-void Register::cleanupUrl()
-{
- geturlptr()->~QUrl();
- setUndefined();
-}
-
-void Register::cleanupColor()
-{
- getcolorptr()->~QColor();
- setUndefined();
-}
-
-void Register::cleanupVariant()
-{
- getvariantptr()->~QVariant();
- setUndefined();
-}
-
-void Register::copy(const Register &other)
-{
- *this = other;
- if (other.dataType >= FirstCleanupType) {
- if (other.dataType == QStringType)
- new (getstringptr()) QString(*other.getstringptr());
- else if (other.dataType == QUrlType)
- new (geturlptr()) QUrl(*other.geturlptr());
- else if (other.dataType == QColorType)
- new (getcolorptr()) QColor(*other.getcolorptr());
- else if (other.dataType == QVariantType)
- new (getvariantptr()) QVariant(*other.getvariantptr());
- }
-}
-
-void Register::init(Type type)
-{
- dataType = type;
- if (dataType >= FirstCleanupType) {
- if (dataType == QStringType)
- new (getstringptr()) QString();
- else if (dataType == QUrlType)
- new (geturlptr()) QUrl();
- else if (dataType == QColorType)
- new (getcolorptr()) QColor();
- else if (dataType == QVariantType)
- new (getvariantptr()) QVariant();
- }
-}
-
-} // end of anonymous namespace
-
-QV4Bindings::QV4Bindings(const char *programData,
- QDeclarativeContextData *context,
- QDeclarativeRefCount *ref)
-: subscriptions(0), program(0), dataRef(0), bindings(0)
-{
- program = (QV4Program *)programData;
- dataRef = ref;
- if (dataRef) dataRef->addref();
-
- if (program) {
- subscriptions = new Subscription[program->subscriptions];
- bindings = new Binding[program->bindings];
-
- QDeclarativeAbstractExpression::setContext(context);
- }
-}
-
-QV4Bindings::~QV4Bindings()
-{
- delete [] bindings;
- delete [] subscriptions; subscriptions = 0;
- if (dataRef) dataRef->release();
-}
-
-QDeclarativeAbstractBinding *QV4Bindings::configBinding(int index, QObject *target,
- QObject *scope, int property,
- int line, int column)
-{
- Binding *rv = bindings + index;
-
- rv->index = index;
- rv->property = property;
- rv->target = target;
- rv->scope = scope;
- rv->line = line;
- rv->column = column;
- rv->parent = this;
-
- addref(); // This is decremented in Binding::destroy()
-
- return rv;
-}
-
-void QV4Bindings::Binding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags)
-{
- if (enabled != e) {
- enabled = e;
-
- if (e) update(flags);
- }
-}
-
-void QV4Bindings::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags)
-{
- parent->run(this, flags);
-}
-
-void QV4Bindings::Binding::destroy()
-{
- enabled = false;
- removeFromObject();
- clear();
- removeError();
- parent->release();
-}
-
-int QV4Bindings::Binding::propertyIndex() const
-{
- //mask out the type information set for value types
- return property & 0xFF00FFFF;
-}
-
-QObject *QV4Bindings::Binding::object() const
-{
- return target;
-}
-
-void QV4Bindings::Subscription::subscriptionCallback(QDeclarativeNotifierEndpoint *e)
-{
- Subscription *s = static_cast<Subscription *>(e);
- s->bindings->subscriptionNotify(s->method);
-}
-
-void QV4Bindings::subscriptionNotify(int id)
-{
- QV4Program::BindingReferenceList *list = program->signalTable(id);
-
- for (quint32 ii = 0; ii < list->count; ++ii) {
- QV4Program::BindingReference *bindingRef = list->bindings + ii;
-
- Binding *binding = bindings + bindingRef->binding;
-
- if (binding->executedBlocks & bindingRef->blockMask) {
- run(binding, QDeclarativePropertyPrivate::DontRemoveBinding);
- }
- }
-}
-
-void QV4Bindings::run(Binding *binding, QDeclarativePropertyPrivate::WriteFlags flags)
-{
- if (!binding->enabled)
- return;
-
- QDeclarativeContextData *context = QDeclarativeAbstractExpression::context();
- if (!context || !context->isValid())
- return;
-
- QDeclarativeTrace trace("V4 Binding Update");
- trace.addDetail("URL", context->url);
- trace.addDetail("Line", binding->line);
- trace.addDetail("Column", binding->column);
-
- QDeclarativeBindingProfiler prof(context->urlString, binding->line, binding->column);
-
- if (binding->updating) {
- QString name;
- if (binding->property & 0xFFFF0000) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine);
-
- QDeclarativeValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
- Q_ASSERT(vt);
-
- name = QLatin1String(binding->target->metaObject()->property(binding->property & 0xFFFF).name());
- name.append(QLatin1String("."));
- name.append(QLatin1String(vt->metaObject()->property(binding->property >> 24).name()));
- } else {
- name = QLatin1String(binding->target->metaObject()->property(binding->property).name());
- }
- qmlInfo(binding->target) << tr("Binding loop detected for property \"%1\"").arg(name);
- return;
- }
-
- binding->updating = true;
- if (binding->property & 0xFFFF0000) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine);
-
- QDeclarativeValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
- Q_ASSERT(vt);
- vt->read(binding->target, binding->property & 0xFFFF);
-
- QObject *target = vt;
- run(binding->index, binding->executedBlocks, context, binding, binding->scope, target, flags);
-
- vt->write(binding->target, binding->property & 0xFFFF, flags);
- } else {
- run(binding->index, binding->executedBlocks, context, binding, binding->scope, binding->target, flags);
- }
- binding->updating = false;
-}
-
-
-void QV4Bindings::unsubscribe(int subIndex)
-{
- Subscription *sub = (subscriptions + subIndex);
- sub->disconnect();
-}
-
-void QV4Bindings::subscribeId(QDeclarativeContextData *p, int idIndex, int subIndex)
-{
- unsubscribe(subIndex);
-
- if (p->idValues[idIndex]) {
- Subscription *sub = (subscriptions + subIndex);
- sub->bindings = this;
- sub->method = subIndex;
- sub->connect(&p->idValues[idIndex].bindings);
- }
-}
-
-void QV4Bindings::subscribe(QObject *o, int notifyIndex, int subIndex)
-{
- Subscription *sub = (subscriptions + subIndex);
- if (sub->isConnected(o, notifyIndex))
- return;
- sub->bindings = this;
- sub->method = subIndex;
- if (o)
- sub->connect(o, notifyIndex);
- else
- sub->disconnect();
-}
-
-// Conversion functions - these MUST match the QtScript expression path
-inline static qreal toReal(Register *reg, int type, bool *ok = 0)
-{
- if (ok) *ok = true;
-
- if (type == QMetaType::QReal) {
- return reg->getqreal();
- } else if (type == qMetaTypeId<QVariant>()) {
- return reg->getvariantptr()->toReal();
- } else {
- if (ok) *ok = false;
- return 0;
- }
-}
-
-inline static QString toString(Register *reg, int type, bool *ok = 0)
-{
- if (ok) *ok = true;
-
- if (type == QMetaType::QReal) {
- return QString::number(reg->getqreal());
- } else if (type == QMetaType::Int) {
- return QString::number(reg->getint());
- } else if (type == qMetaTypeId<QVariant>()) {
- return reg->getvariantptr()->toString();
- } else if (type == QMetaType::QString) {
- return *reg->getstringptr();
- } else {
- if (ok) *ok = false;
- return QString();
- }
-}
-
-inline static bool toBool(Register *reg, int type, bool *ok = 0)
-{
- if (ok) *ok = true;
-
- if (type == QMetaType::Bool) {
- return reg->getbool();
- } else if (type == qMetaTypeId<QVariant>()) {
- return reg->getvariantptr()->toBool();
- } else {
- if (ok) *ok = false;
- return false;
- }
-}
-
-inline static QUrl toUrl(Register *reg, int type, QDeclarativeContextData *context, bool *ok = 0)
-{
- if (ok) *ok = true;
-
- QUrl base;
- if (type == qMetaTypeId<QVariant>()) {
- QVariant *var = reg->getvariantptr();
- int vt = var->type();
- if (vt == QVariant::Url) {
- base = var->toUrl();
- } else if (vt == QVariant::ByteArray) {
- // Preserve any valid percent-encoded octets supplied by the source
- base.setEncodedUrl(var->toByteArray(), QUrl::TolerantMode);
- } else if (vt == QVariant::String) {
- base.setEncodedUrl(var->toString().toUtf8(), QUrl::TolerantMode);
- } else {
- if (ok) *ok = false;
- return QUrl();
- }
- } else if (type == QMetaType::QString) {
- base.setEncodedUrl(reg->getstringptr()->toUtf8(), QUrl::TolerantMode);
- } else {
- if (ok) *ok = false;
- return QUrl();
- }
-
- if (!base.isEmpty() && base.isRelative())
- return context->url.resolved(base);
- else
- return base;
-}
-
-static bool testCompareVariants(const QVariant &qtscriptRaw, const QVariant &v4)
-{
- QVariant qtscript = qtscriptRaw;
-
- if (qtscript.userType() == v4.userType()) {
- } else if (qtscript.canConvert((QVariant::Type)v4.userType())) {
- qtscript.convert((QVariant::Type)v4.userType());
- } else if (qtscript.userType() == QVariant::Invalid && v4.userType() == QMetaType::QObjectStar) {
- qtscript = qVariantFromValue<QObject *>(0);
- } else {
- return false;
- }
-
- int type = qtscript.userType();
-
- if (type == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) {
- return QDeclarativeMetaType::QQuickAnchorLineCompare(qtscript.constData(), v4.constData());
- } else if (type == QMetaType::Double) {
-
- double la = qvariant_cast<double>(qtscript);
- double lr = qvariant_cast<double>(v4);
-
- return la == lr || (qIsNaN(la) && qIsNaN(lr));
-
- } else if (type == QMetaType::Float) {
-
- float la = qvariant_cast<float>(qtscript);
- float lr = qvariant_cast<float>(v4);
-
- return la == lr || (qIsNaN(la) && qIsNaN(lr));
-
- } else {
- return qtscript == v4;
- }
-}
-
-QByteArray testResultToString(const QVariant &result, bool undefined)
-{
- if (undefined) {
- return "undefined";
- } else {
- QString rv;
- QDebug d(&rv);
- d << result;
- return rv.toUtf8();
- }
-}
-
-static void testBindingResult(const QString &binding, int line, int column,
- QDeclarativeContextData *context, QObject *scope,
- const Register &result, int resultType)
-{
- QDeclarativeExpression expression(context->asQDeclarativeContext(), scope, binding);
- bool isUndefined = false;
- QVariant value = expression.evaluate(&isUndefined);
-
- bool iserror = false;
- QByteArray qtscriptResult;
- QByteArray v4Result;
-
- if (expression.hasError()) {
- iserror = true;
- qtscriptResult = "exception";
- } else {
- qtscriptResult = testResultToString(value, isUndefined);
- }
-
- if (isUndefined && result.isUndefined()) {
- return;
- } else if(isUndefined != result.isUndefined()) {
- iserror = true;
- }
-
- QVariant v4value;
- if (!result.isUndefined()) {
- switch (resultType) {
- case QMetaType::QString:
- v4value = *result.getstringptr();
- break;
- case QMetaType::QUrl:
- v4value = *result.geturlptr();
- break;
- case QMetaType::QObjectStar:
- v4value = qVariantFromValue<QObject *>(result.getQObject());
- break;
- case QMetaType::Bool:
- v4value = result.getbool();
- break;
- case QMetaType::Int:
- v4value = result.getint();
- break;
- case QMetaType::QReal:
- v4value = result.getqreal();
- break;
- default:
- if (resultType == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) {
- v4value = QVariant(QDeclarativeMetaType::QQuickAnchorLineMetaTypeId(), result.typeDataPtr());
- } else {
- iserror = true;
- v4Result = "Unknown V4 type";
- }
- }
- }
- if (v4Result.isEmpty())
- v4Result = testResultToString(v4value, result.isUndefined());
-
- if (!testCompareVariants(value, v4value))
- iserror = true;
-
- if (iserror) {
- qWarning().nospace() << "QV4: Optimization error @" << context->url.toString().toUtf8().constData() << ":" << line << ":" << column;
-
- qWarning().nospace() << " Binding: " << binding;
- qWarning().nospace() << " QtScript: " << qtscriptResult.constData();
- qWarning().nospace() << " V4: " << v4Result.constData();
- }
-}
-
-static void testBindingException(const QString &binding, int line, int column,
- QDeclarativeContextData *context, QObject *scope)
-{
- QDeclarativeExpression expression(context->asQDeclarativeContext(), scope, binding);
- bool isUndefined = false;
- QVariant value = expression.evaluate(&isUndefined);
-
- if (!expression.hasError()) {
- QByteArray qtscriptResult = testResultToString(value, isUndefined);
- qWarning().nospace() << "QV4: Optimization error @" << context->url.toString().toUtf8().constData() << ":" << line << ":" << column;
- qWarning().nospace() << " Binding: " << binding;
- qWarning().nospace() << " QtScript: " << qtscriptResult.constData();
- qWarning().nospace() << " V4: exception";
- }
-}
-
-static void throwException(int id, QDeclarativeDelayedError *error,
- QV4Program *program, QDeclarativeContextData *context,
- const QString &description = QString())
-{
- error->error.setUrl(context->url);
- if (description.isEmpty())
- error->error.setDescription(QLatin1String("TypeError: Result of expression is not an object"));
- else
- error->error.setDescription(description);
- if (id != 0xFF) {
- quint64 e = *((quint64 *)(program->data() + program->exceptionDataOffset) + id);
- error->error.setLine((e >> 32) & 0xFFFFFFFF);
- error->error.setColumn(e & 0xFFFFFFFF);
- } else {
- error->error.setLine(-1);
- error->error.setColumn(-1);
- }
- if (!context->engine || !error->addError(QDeclarativeEnginePrivate::get(context->engine)))
- QDeclarativeEnginePrivate::warning(context->engine, error->error);
-}
-
-const qreal QV4Bindings::D32 = 4294967296.0;
-
-qint32 QV4Bindings::toInt32(qreal n)
-{
- if (qIsNaN(n) || qIsInf(n) || (n == 0))
- return 0;
-
- double sign = (n < 0) ? -1.0 : 1.0;
- qreal abs_n = fabs(n);
-
- n = ::fmod(sign * ::floor(abs_n), D32);
- const double D31 = D32 / 2.0;
-
- if (sign == -1 && n < -D31)
- n += D32;
-
- else if (sign != -1 && n >= D31)
- n -= D32;
-
- return qint32 (n);
-}
-
-inline quint32 QV4Bindings::toUint32(qreal n)
-{
- if (qIsNaN(n) || qIsInf(n) || (n == 0))
- return 0;
-
- double sign = (n < 0) ? -1.0 : 1.0;
- qreal abs_n = fabs(n);
-
- n = ::fmod(sign * ::floor(abs_n), D32);
-
- if (n < 0)
- n += D32;
-
- return quint32 (n);
-}
-
-#define THROW_EXCEPTION_STR(id, str) { \
- if (testBinding) testBindingException(*testBindingSource, bindingLine, bindingColumn, context, scope); \
- throwException((id), error, program, context, (str)); \
- goto exceptionExit; \
-}
-
-#define THROW_EXCEPTION(id) THROW_EXCEPTION_STR(id, QString())
-
-#define MARK_REGISTER(reg) cleanupRegisterMask |= (1 << (reg))
-#define MARK_CLEAN_REGISTER(reg) cleanupRegisterMask &= ~(1 << (reg))
-
-#define STRING_REGISTER(reg) { \
- registers[(reg)].settype(QStringType); \
- MARK_REGISTER(reg); \
-}
-
-#define URL_REGISTER(reg) { \
- registers[(reg)].settype(QUrlType); \
- MARK_REGISTER(reg); \
-}
-
-#define COLOR_REGISTER(reg) { \
- registers[(reg)].settype(QColorType); \
- MARK_REGISTER(reg); \
-}
-
-#define VARIANT_REGISTER(reg) { \
- registers[(reg)].settype(QVariantType); \
- MARK_REGISTER(reg); \
-}
-
-#ifdef QML_THREADED_INTERPRETER
-void **QV4Bindings::getDecodeInstrTable()
-{
- static void **decode_instr;
- if (!decode_instr) {
- QV4Bindings *dummy = new QV4Bindings(0, 0, 0);
- quint32 executedBlocks = 0;
- dummy->run(0, executedBlocks, 0, 0, 0, 0,
- QDeclarativePropertyPrivate::BypassInterceptor,
- &decode_instr);
- dummy->release();
- }
- return decode_instr;
-}
-#endif
-
-void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
- QDeclarativeContextData *context, QDeclarativeDelayedError *error,
- QObject *scope, QObject *output,
- QDeclarativePropertyPrivate::WriteFlags storeFlags
-#ifdef QML_THREADED_INTERPRETER
- ,void ***table
-#endif
- )
-{
-#ifdef QML_THREADED_INTERPRETER
- if (table) {
- static void *decode_instr[] = {
- FOR_EACH_V4_INSTR(QML_V4_INSTR_ADDR)
- };
-
- *table = decode_instr;
- return;
- }
-#endif
-
-
- error->removeError();
-
- Register registers[32];
- quint32 cleanupRegisterMask = 0;
-
- executedBlocks = 0;
-
- const char *code = program->instructions();
- code += instrIndex * QML_V4_INSTR_SIZE(Jump, jump);
- const V4Instr *instr = reinterpret_cast<const V4Instr *>(code);
-
- const char *data = program->data();
-
- QString *testBindingSource = 0;
- bool testBinding = false;
- int bindingLine = 0;
- int bindingColumn = 0;
-
-#ifdef QML_THREADED_INTERPRETER
- goto *instr->common.code;
-#else
- for (;;) {
- switch (instr->common.type) {
-#endif
-
- QML_V4_BEGIN_INSTR(Noop, common)
- QML_V4_END_INSTR(Noop, common)
-
- QML_V4_BEGIN_INSTR(BindingId, id)
- bindingLine = instr->id.line;
- bindingColumn = instr->id.column;
- QML_V4_END_INSTR(BindingId, id)
-
- QML_V4_BEGIN_INSTR(SubscribeId, subscribeop)
- subscribeId(context, instr->subscribeop.index, instr->subscribeop.offset);
- QML_V4_END_INSTR(SubscribeId, subscribeop)
-
- QML_V4_BEGIN_INSTR(Subscribe, subscribeop)
- {
- QObject *o = 0;
- const Register &object = registers[instr->subscribeop.reg];
- if (!object.isUndefined()) o = object.getQObject();
- subscribe(o, instr->subscribeop.index, instr->subscribeop.offset);
- }
- QML_V4_END_INSTR(Subscribe, subscribeop)
-
- QML_V4_BEGIN_INSTR(FetchAndSubscribe, fetchAndSubscribe)
- {
- Register &reg = registers[instr->fetchAndSubscribe.reg];
-
- if (reg.isUndefined())
- THROW_EXCEPTION(instr->fetchAndSubscribe.exceptionId);
-
- QObject *object = reg.getQObject();
- if (!object) {
- reg.setUndefined();
- } else {
- int subIdx = instr->fetchAndSubscribe.subscription;
- Subscription *sub = 0;
- if (subIdx != -1) {
- sub = (subscriptions + subIdx);
- sub->bindings = this;
- sub->method = subIdx;
- }
- reg.init((Register::Type)instr->fetchAndSubscribe.valueType);
- if (instr->fetchAndSubscribe.valueType >= FirstCleanupType)
- MARK_REGISTER(instr->fetchAndSubscribe.reg);
- QDeclarativeAccessors *accessors = instr->fetchAndSubscribe.property.accessors;
- accessors->read(object, instr->fetchAndSubscribe.property.accessorData,
- reg.typeDataPtr());
-
- if (accessors->notifier) {
- QDeclarativeNotifier *notifier = 0;
- accessors->notifier(object, instr->fetchAndSubscribe.property.accessorData, &notifier);
- if (notifier) sub->connect(notifier);
- } else if (instr->fetchAndSubscribe.property.notifyIndex != -1) {
- sub->connect(object, instr->fetchAndSubscribe.property.notifyIndex);
- }
- }
- }
- QML_V4_END_INSTR(FetchAndSubscribe, fetchAndSubscribe)
-
- QML_V4_BEGIN_INSTR(LoadId, load)
- registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
- QML_V4_END_INSTR(LoadId, load)
-
- QML_V4_BEGIN_INSTR(LoadScope, load)
- registers[instr->load.reg].setQObject(scope);
- QML_V4_END_INSTR(LoadScope, load)
-
- QML_V4_BEGIN_INSTR(LoadRoot, load)
- registers[instr->load.reg].setQObject(context->contextObject);
- QML_V4_END_INSTR(LoadRoot, load)
-
- QML_V4_BEGIN_INSTR(LoadAttached, attached)
- {
- const Register &input = registers[instr->attached.reg];
- Register &output = registers[instr->attached.output];
- if (input.isUndefined())
- THROW_EXCEPTION(instr->attached.exceptionId);
-
- QObject *object = registers[instr->attached.reg].getQObject();
- if (!object) {
- output.setUndefined();
- } else {
- QObject *attached = qmlAttachedPropertiesObjectById(instr->attached.id, input.getQObject(), true);
- Q_ASSERT(attached);
- output.setQObject(attached);
- }
- }
- QML_V4_END_INSTR(LoadAttached, attached)
-
- QML_V4_BEGIN_INSTR(UnaryNot, unaryop)
- {
- registers[instr->unaryop.output].setbool(!registers[instr->unaryop.src].getbool());
- }
- QML_V4_END_INSTR(UnaryNot, unaryop)
-
- QML_V4_BEGIN_INSTR(UnaryMinusReal, unaryop)
- {
- registers[instr->unaryop.output].setqreal(-registers[instr->unaryop.src].getqreal());
- }
- QML_V4_END_INSTR(UnaryMinusReal, unaryop)
-
- QML_V4_BEGIN_INSTR(UnaryMinusInt, unaryop)
- {
- registers[instr->unaryop.output].setint(-registers[instr->unaryop.src].getint());
- }
- QML_V4_END_INSTR(UnaryMinusInt, unaryop)
-
- QML_V4_BEGIN_INSTR(UnaryPlusReal, unaryop)
- {
- registers[instr->unaryop.output].setqreal(+registers[instr->unaryop.src].getqreal());
- }
- QML_V4_END_INSTR(UnaryPlusReal, unaryop)
-
- QML_V4_BEGIN_INSTR(UnaryPlusInt, unaryop)
- {
- registers[instr->unaryop.output].setint(+registers[instr->unaryop.src].getint());
- }
- QML_V4_END_INSTR(UnaryPlusInt, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToInt, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setint(src.getbool());
- }
- QML_V4_END_INSTR(ConvertBoolToInt, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToReal, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setqreal(src.getbool());
- }
- QML_V4_END_INSTR(ConvertBoolToReal, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getstringptr()) QString(QLatin1String(src.getbool() ? "true" : "false"));
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertBoolToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setbool(src.getint());
- }
- QML_V4_END_INSTR(ConvertIntToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToReal, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setqreal(qreal(src.getint()));
- }
- QML_V4_END_INSTR(ConvertIntToReal, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getstringptr()) QString(QString::number(src.getint()));
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertIntToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertRealToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setbool(src.getqreal() != 0);
- }
- QML_V4_END_INSTR(ConvertRealToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertRealToInt, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setint(toInt32(src.getqreal()));
- }
- QML_V4_END_INSTR(ConvertRealToInt, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertRealToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getstringptr()) QString(QString::number(src.getqreal()));
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertRealToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
- // Ideally we should just call the methods in the QScript namespace directly.
- QJSValue tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- output.setbool(tmp.toBool());
- }
- }
- QML_V4_END_INSTR(ConvertStringToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToInt, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
- // Ideally we should just call the methods in the QScript namespace directly.
- QJSValue tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- output.setint(tmp.toInt());
- }
- }
- QML_V4_END_INSTR(ConvertStringToInt, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToReal, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
- // Ideally we should just call the methods in the QScript namespace directly.
- QJSValue tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- output.setqreal(tmp.toNumber());
- }
- }
- QML_V4_END_INSTR(ConvertStringToReal, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToUrl, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QString tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- QUrl *urlPtr = output.geturlptr();
- new (urlPtr) QUrl();
- urlPtr->setEncodedUrl(tmp.toUtf8(), QUrl::TolerantMode);
-
- URL_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToColor, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QString tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- QColor *colorPtr = output.getcolorptr();
- new (colorPtr) QColor(QDeclarativeStringConverters::colorFromString(tmp));
-
- COLOR_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertUrlToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupUrl();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- output.setbool(!tmp.isEmpty());
- }
- }
- QML_V4_END_INSTR(ConvertUrlToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertUrlToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupUrl();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.getstringptr()) QString(tmp.toString());
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertUrlToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertColorToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- // for compatibility with color behavior in v8, always true
- output.setbool(true);
- }
- }
- QML_V4_END_INSTR(ConvertColorToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertColorToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QColor tmp(*src.getcolorptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupColor();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- // to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
- new (output.getstringptr()) QString(QVariant(tmp).toString());
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertColorToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ResolveUrl, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- *output.geturlptr() = context->resolvedUrl(tmp);
- } else {
- new (output.geturlptr()) QUrl(context->resolvedUrl(tmp));
- URL_REGISTER(instr->unaryop.output);
- }
- }
- }
- QML_V4_END_INSTR(ResolveUrl, unaryop)
-
- QML_V4_BEGIN_INSTR(MathSinReal, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setqreal(qSin(src.getqreal()));
- }
- QML_V4_END_INSTR(MathSinReal, unaryop)
-
- QML_V4_BEGIN_INSTR(MathCosReal, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setqreal(qCos(src.getqreal()));
- }
- QML_V4_END_INSTR(MathCosReal, unaryop)
-
- QML_V4_BEGIN_INSTR(MathRoundReal, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setint(qRound(src.getqreal()));
- }
- QML_V4_END_INSTR(MathRoundReal, unaryop)
-
- QML_V4_BEGIN_INSTR(MathFloorReal, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setint(qFloor(src.getqreal()));
- }
- QML_V4_END_INSTR(MathFloorReal, unaryop)
-
- QML_V4_BEGIN_INSTR(MathPIReal, unaryop)
- {
- static const qreal qmlPI = 2.0 * qAsin(1.0);
- Register &output = registers[instr->unaryop.output];
- output.setqreal(qmlPI);
- }
- QML_V4_END_INSTR(MathPIReal, unaryop)
-
- QML_V4_BEGIN_INSTR(LoadReal, real_value)
- registers[instr->real_value.reg].setqreal(instr->real_value.value);
- QML_V4_END_INSTR(LoadReal, real_value)
-
- QML_V4_BEGIN_INSTR(LoadInt, int_value)
- registers[instr->int_value.reg].setint(instr->int_value.value);
- QML_V4_END_INSTR(LoadInt, int_value)
-
- QML_V4_BEGIN_INSTR(LoadBool, bool_value)
- registers[instr->bool_value.reg].setbool(instr->bool_value.value);
- QML_V4_END_INSTR(LoadBool, bool_value)
-
- QML_V4_BEGIN_INSTR(LoadString, string_value)
- {
- Register &output = registers[instr->string_value.reg];
- QChar *string = (QChar *)(data + instr->string_value.offset);
- new (output.getstringptr()) QString(string, instr->string_value.length);
- STRING_REGISTER(instr->string_value.reg);
- }
- QML_V4_END_INSTR(LoadString, string_value)
-
- QML_V4_BEGIN_INSTR(EnableV4Test, string_value)
- {
- testBindingSource = new QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
- testBinding = true;
- }
- QML_V4_END_INSTR(String, string_value)
-
- QML_V4_BEGIN_INSTR(BitAndInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() &
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(BitAndInt, binaryop)
-
- QML_V4_BEGIN_INSTR(BitOrInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() |
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(BitAndInt, binaryop)
-
- QML_V4_BEGIN_INSTR(BitXorInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() ^
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(BitXorInt, binaryop)
-
- QML_V4_BEGIN_INSTR(AddReal, binaryop)
- {
- registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() +
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(AddReal, binaryop)
-
- QML_V4_BEGIN_INSTR(AddString, binaryop)
- {
- QString &string = *registers[instr->binaryop.output].getstringptr();
- if (instr->binaryop.output == instr->binaryop.left) {
- string += registers[instr->binaryop.right].getstringptr();
- } else {
- string = *registers[instr->binaryop.left].getstringptr() +
- *registers[instr->binaryop.right].getstringptr();
- }
- }
- QML_V4_END_INSTR(AddString, binaryop)
-
- QML_V4_BEGIN_INSTR(SubReal, binaryop)
- {
- registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() -
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(SubReal, binaryop)
-
- QML_V4_BEGIN_INSTR(MulReal, binaryop)
- {
- registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() *
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(MulReal, binaryop)
-
- QML_V4_BEGIN_INSTR(DivReal, binaryop)
- {
- registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() /
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(DivReal, binaryop)
-
- QML_V4_BEGIN_INSTR(ModReal, binaryop)
- {
- Register &target = registers[instr->binaryop.output];
- const Register &left = registers[instr->binaryop.left];
- const Register &right = registers[instr->binaryop.right];
- if (QMetaType::QReal == QMetaType::Float)
- target.setqreal(::fmodf(left.getqreal(), right.getqreal()));
- else
- target.setqreal(::fmod(left.getqreal(), right.getqreal()));
- }
- QML_V4_END_INSTR(ModInt, binaryop)
-
- QML_V4_BEGIN_INSTR(LShiftInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() <<
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(LShiftInt, binaryop)
-
- QML_V4_BEGIN_INSTR(RShiftInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() >>
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(RShiftInt, binaryop)
-
- QML_V4_BEGIN_INSTR(URShiftInt, binaryop)
- {
- registers[instr->binaryop.output].setint((unsigned)registers[instr->binaryop.left].getint() >>
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(URShiftInt, binaryop)
-
- QML_V4_BEGIN_INSTR(GtReal, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() >
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(GtReal, binaryop)
-
- QML_V4_BEGIN_INSTR(LtReal, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() <
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(LtReal, binaryop)
-
- QML_V4_BEGIN_INSTR(GeReal, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() >=
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(GeReal, binaryop)
-
- QML_V4_BEGIN_INSTR(LeReal, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() <=
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(LeReal, binaryop)
-
- QML_V4_BEGIN_INSTR(EqualReal, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() ==
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(EqualReal, binaryop)
-
- QML_V4_BEGIN_INSTR(NotEqualReal, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() !=
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(NotEqualReal, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictEqualReal, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() ==
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(StrictEqualReal, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictNotEqualReal, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() !=
- registers[instr->binaryop.right].getqreal());
- }
- QML_V4_END_INSTR(StrictNotEqualReal, binaryop)
-
- QML_V4_BEGIN_INSTR(GtString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a > b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(GtString, binaryop)
-
- QML_V4_BEGIN_INSTR(LtString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a < b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(LtString, binaryop)
-
- QML_V4_BEGIN_INSTR(GeString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a >= b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(GeString, binaryop)
-
- QML_V4_BEGIN_INSTR(LeString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a <= b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(LeString, binaryop)
-
- QML_V4_BEGIN_INSTR(EqualString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a == b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(EqualString, binaryop)
-
- QML_V4_BEGIN_INSTR(NotEqualString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a != b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(NotEqualString, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictEqualString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a == b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(StrictEqualString, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictNotEqualString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a != b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(StrictNotEqualString, binaryop)
-
- QML_V4_BEGIN_INSTR(NewString, construct)
- {
- Register &output = registers[instr->construct.reg];
- new (output.getstringptr()) QString;
- STRING_REGISTER(instr->construct.reg);
- }
- QML_V4_END_INSTR(NewString, construct)
-
- QML_V4_BEGIN_INSTR(NewUrl, construct)
- {
- Register &output = registers[instr->construct.reg];
- new (output.geturlptr()) QUrl;
- URL_REGISTER(instr->construct.reg);
- }
- QML_V4_END_INSTR(NewUrl, construct)
-
- QML_V4_BEGIN_INSTR(Fetch, fetch)
- {
- Register &reg = registers[instr->fetch.reg];
-
- if (reg.isUndefined())
- THROW_EXCEPTION(instr->fetch.exceptionId);
-
- QObject *object = reg.getQObject();
- if (!object) {
- THROW_EXCEPTION(instr->fetch.exceptionId);
- } else {
- reg.init((Register::Type)instr->fetch.valueType);
- if (instr->fetch.valueType >= FirstCleanupType)
- MARK_REGISTER(instr->fetch.reg);
- void *argv[] = { reg.typeDataPtr(), 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
- }
- }
- QML_V4_END_INSTR(Fetch, fetch)
-
- QML_V4_BEGIN_INSTR(TestV4Store, storetest)
- {
- Register &data = registers[instr->storetest.reg];
- testBindingResult(*testBindingSource, bindingLine, bindingColumn, context,
- scope, data, instr->storetest.regType);
- }
- QML_V4_END_INSTR(TestV4Store, storetest)
-
- QML_V4_BEGIN_INSTR(Store, store)
- {
- Register &data = registers[instr->store.reg];
-
- if (data.isUndefined())
- THROW_EXCEPTION_STR(instr->store.exceptionId, QLatin1String("Unable to assign undefined value"));
-
- int status = -1;
- void *argv[] = { data.typeDataPtr(), 0, &status, &storeFlags };
- QMetaObject::metacall(output, QMetaObject::WriteProperty,
- instr->store.index, argv);
-
- goto programExit;
- }
- QML_V4_END_INSTR(Store, store)
-
- QML_V4_BEGIN_INSTR(Copy, copy)
- registers[instr->copy.reg].copy(registers[instr->copy.src]);
- if (registers[instr->copy.reg].gettype() >= FirstCleanupType)
- MARK_REGISTER(instr->copy.reg);
- QML_V4_END_INSTR(Copy, copy)
-
- QML_V4_BEGIN_INSTR(Jump, jump)
- if (instr->jump.reg == -1 || !registers[instr->jump.reg].getbool())
- code += instr->jump.count;
- QML_V4_END_INSTR(Jump, jump)
-
- QML_V4_BEGIN_INSTR(BranchTrue, branchop)
- if (registers[instr->branchop.reg].getbool())
- code += instr->branchop.offset;
- QML_V4_END_INSTR(BranchTrue, branchop)
-
- QML_V4_BEGIN_INSTR(BranchFalse, branchop)
- if (! registers[instr->branchop.reg].getbool())
- code += instr->branchop.offset;
- QML_V4_END_INSTR(BranchFalse, branchop)
-
- QML_V4_BEGIN_INSTR(Branch, branchop)
- code += instr->branchop.offset;
- QML_V4_END_INSTR(Branch, branchop)
-
- QML_V4_BEGIN_INSTR(Block, blockop)
- executedBlocks |= instr->blockop.block;
- QML_V4_END_INSTR(Block, blockop)
-
- // XXX not applicable in v8
- QML_V4_BEGIN_INSTR(InitString, initstring)
-// if (!identifiers[instr->initstring.offset].identifier) {
-// quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
-// QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
-
-// QString str = QString::fromRawData(strdata, len);
-
-// // identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
-// }
- QML_V4_END_INSTR(InitString, initstring)
-
- QML_V4_BEGIN_INSTR(CleanupRegister, cleanup)
- registers[instr->cleanup.reg].cleanup();
- QML_V4_END_INSTR(CleanupRegister, cleanup)
-
-#ifdef QML_THREADED_INTERPRETER
- // nothing to do
-#else
- default:
- qFatal("QV4: Unknown instruction %d encountered.", instr->common.type);
- break;
- } // switch
-
- } // while
-#endif
-
- Q_ASSERT(!"Unreachable code reached");
-
-programExit:
-exceptionExit:
- delete testBindingSource;
-
- int reg = 0;
- while (cleanupRegisterMask) {
- if (cleanupRegisterMask & 0x1)
- registers[reg].cleanup();
-
- reg++;
- cleanupRegisterMask >>= 1;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v4/qv4bindings_p.h b/src/declarative/qml/v4/qv4bindings_p.h
deleted file mode 100644
index a447481a4c..0000000000
--- a/src/declarative/qml/v4/qv4bindings_p.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4BINDINGS_P_H
-#define QV4BINDINGS_P_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 "private/qdeclarativeexpression_p.h"
-#include "private/qdeclarativebinding_p.h"
-#include "private/qv4instruction_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-struct QV4Program;
-class QV4Bindings : public QDeclarativeAbstractExpression,
- public QDeclarativeRefCount
-{
- Q_DECLARE_TR_FUNCTIONS(QV4Bindings)
-public:
- QV4Bindings(const char *program, QDeclarativeContextData *context,
- QDeclarativeRefCount *);
- virtual ~QV4Bindings();
-
- QDeclarativeAbstractBinding *configBinding(int index, QObject *target,
- QObject *scope, int property,
- int line, int column);
-
-#ifdef QML_THREADED_INTERPRETER
- static void **getDecodeInstrTable();
-#endif
-
-private:
- Q_DISABLE_COPY(QV4Bindings)
-
- struct Binding : public QDeclarativeAbstractBinding, public QDeclarativeDelayedError {
- Binding() : enabled(false), updating(0), property(0),
- scope(0), target(0), executedBlocks(0), parent(0) {}
-
- // Inherited from QDeclarativeAbstractBinding
- virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags);
- virtual void update(QDeclarativePropertyPrivate::WriteFlags flags);
- virtual void destroy();
- virtual int propertyIndex() const;
- virtual QObject *object() const;
-
- int index:30;
- bool enabled:1;
- bool updating:1;
- // Encoding of property is coreIndex | (propType << 16) | (valueTypeIndex << 24)
- // propType and valueTypeIndex are only set if the property is a value type property
- int property;
- QObject *scope;
- int line;
- int column;
- QObject *target;
- quint32 executedBlocks;
-
- QV4Bindings *parent;
- };
-
- class Subscription : public QDeclarativeNotifierEndpoint
- {
- public:
- Subscription() : bindings(0), method(-1) { callback = &subscriptionCallback; }
- static void subscriptionCallback(QDeclarativeNotifierEndpoint *e);
- QV4Bindings *bindings;
- int method;
- };
- friend class Subscription;
-
- Subscription *subscriptions;
-
- void subscriptionNotify(int);
- void run(Binding *, QDeclarativePropertyPrivate::WriteFlags flags);
-
- QV4Program *program;
- QDeclarativeRefCount *dataRef;
- Binding *bindings;
-
- void init();
- void run(int instr, quint32 &executedBlocks, QDeclarativeContextData *context,
- QDeclarativeDelayedError *error, QObject *scope, QObject *output,
- QDeclarativePropertyPrivate::WriteFlags storeFlags
-#ifdef QML_THREADED_INTERPRETER
- , void ***decode_instr = 0
-#endif
- );
-
-
- inline void unsubscribe(int subIndex);
- inline void subscribeId(QDeclarativeContextData *p, int idIndex, int subIndex);
- inline void subscribe(QObject *o, int notifyIndex, int subIndex);
-
- inline static qint32 toInt32(qreal n);
- static const qreal D32;
- static quint32 toUint32(qreal n);
-
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV4BINDINGS_P_H
-
diff --git a/src/declarative/qml/v4/qv4compiler.cpp b/src/declarative/qml/v4/qv4compiler.cpp
deleted file mode 100644
index 0a0269d903..0000000000
--- a/src/declarative/qml/v4/qv4compiler.cpp
+++ /dev/null
@@ -1,1419 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4compiler_p.h"
-#include "qv4compiler_p_p.h"
-#include "qv4program_p.h"
-#include "qv4ir_p.h"
-#include "qv4irbuilder_p.h"
-
-#include <private/qdeclarativejsast_p.h>
-#include <private/qdeclarativeaccessors_p.h>
-#include <private/qdeclarativejsengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(bindingsDump, QML_BINDINGS_DUMP)
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableOptimizer, QML_DISABLE_OPTIMIZER)
-DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL)
-DEFINE_BOOL_CONFIG_OPTION(qmlVerboseCompiler, QML_VERBOSE_COMPILER)
-DEFINE_BOOL_CONFIG_OPTION(qmlBindingsTestEnv, QML_BINDINGS_TEST)
-
-static bool qmlBindingsTest = false;
-static bool qmlEnableV4 = true;
-
-using namespace QDeclarativeJS;
-QV4CompilerPrivate::QV4CompilerPrivate()
- : _function(0) , _block(0) , _discarded(false), registerCount(0)
-{
-}
-
-//
-// tracing
-//
-void QV4CompilerPrivate::trace(int line, int column)
-{
- bytecode.clear();
-
- this->currentReg = _function->tempCount;
- this->registerCount = qMax(this->registerCount, this->currentReg);
-
- foreach (IR::BasicBlock *bb, _function->basicBlocks) {
- if (! bb->isTerminated() && (bb->index + 1) < _function->basicBlocks.size())
- bb->JUMP(_function->basicBlocks.at(bb->index + 1));
- }
-
- QVector<IR::BasicBlock *> blocks;
- trace(&blocks);
- currentBlockMask = 0x00000001;
-
-
- for (int i = 0; !_discarded && i < blocks.size(); ++i) {
- IR::BasicBlock *block = blocks.at(i);
- IR::BasicBlock *next = i + 1 < blocks.size() ? blocks.at(i + 1) : 0;
- if (IR::Stmt *terminator = block->terminator()) {
- if (IR::CJump *cj = terminator->asCJump()) {
- if (cj->iffalse != next) {
- IR::Jump *jump = _function->pool->New<IR::Jump>();
- jump->init(cj->iffalse);
- block->statements.append(jump);
- }
- } else if (IR::Jump *j = terminator->asJump()) {
- if (j->target == next) {
- block->statements.resize(block->statements.size() - 1);
- }
- }
- }
-
- block->offset = bytecode.size();
-
- if (bytecode.isEmpty()) {
- if (qmlBindingsTest || bindingsDump()) {
- Instr::BindingId id;
- id.column = column;
- id.line = line;
- gen(id);
- }
-
- if (qmlBindingsTest) {
- QString str = expression->expression.asScript();
- QByteArray strdata((const char *)str.constData(), str.length() * sizeof(QChar));
- int offset = data.count();
- data += strdata;
-
- Instr::EnableV4Test test;
- test.reg = 0;
- test.offset = offset;
- test.length = str.length();
- gen(test);
- }
- }
-
- bool usic = false;
- int patchesCount = patches.count();
- qSwap(usedSubscriptionIdsChanged, usic);
-
- int blockopIndex = bytecode.size();
- Instr::Block blockop;
- blockop.block = currentBlockMask;
- gen(blockop);
-
- foreach (IR::Stmt *s, block->statements) {
- if (! _discarded)
- s->accept(this);
- }
-
- qSwap(usedSubscriptionIdsChanged, usic);
-
- if (usic) {
- if (currentBlockMask == 0x80000000) {
- discard();
- return;
- }
- currentBlockMask <<= 1;
- } else if (! _discarded) {
- const int adjust = bytecode.remove(blockopIndex);
- // Correct patches
- for (int ii = patchesCount; ii < patches.count(); ++ii)
- patches[ii].offset -= adjust;
- }
- }
-
-#ifdef DEBUG_IR_STRUCTURE
- IR::IRDump dump;
- for (int i = 0; i < blocks.size(); ++i) {
- dump.basicblock(blocks.at(i));
- }
-#endif
-
-
- if (! _discarded) {
- // back patching
- foreach (const Patch &patch, patches) {
- V4Instr &instr = bytecode[patch.offset];
- int size = V4Instr::size(instructionType(&instr));
- instr.branchop.offset = patch.block->offset - patch.offset - size;
- }
-
- patches.clear();
- }
-}
-
-void QV4CompilerPrivate::trace(QVector<IR::BasicBlock *> *blocks)
-{
- for (int i = 0; i < _function->basicBlocks.size(); ++i) {
- IR::BasicBlock *block = _function->basicBlocks.at(i);
-
- while (! blocks->contains(block)) {
- blocks->append(block);
-
- if (IR::Stmt *terminator = block->terminator()) {
- if (IR::CJump *cj = terminator->asCJump())
- block = cj->iffalse;
- else if (IR::Jump *j = terminator->asJump())
- block = j->target;
- }
- }
- }
-}
-
-void QV4CompilerPrivate::traceExpression(IR::Expr *e, quint8 r)
-{
- if (!e) {
- discard();
- } else {
- qSwap(currentReg, r);
- e->accept(this);
- qSwap(currentReg, r);
- }
-}
-
-//
-// expressions
-//
-void QV4CompilerPrivate::visitConst(IR::Const *e)
-{
- switch (e->type) {
- case IR::BoolType: {
- Instr::LoadBool i;
- i.reg = currentReg;
- i.value = e->value;
- gen(i);
- } break;
-
- case IR::IntType: {
- Instr::LoadInt i;
- i.reg = currentReg;
- i.value = e->value;
- gen(i);
- } break;
-
- case IR::RealType: {
- Instr::LoadReal i;
- i.reg = currentReg;
- i.value = e->value;
- gen(i);
- } break;
-
- default:
- if (qmlVerboseCompiler())
- qWarning() << Q_FUNC_INFO << "unexpected type";
- discard();
- }
-}
-
-void QV4CompilerPrivate::visitString(IR::String *e)
-{
- registerLiteralString(currentReg, e->value);
-}
-
-void QV4CompilerPrivate::visitName(IR::Name *e)
-{
- if (e->base) {
- // fetch the object and store it in reg.
- traceExpression(e->base, currentReg);
- } else {
- _subscribeName.clear();
- }
-
- if (e->storage == IR::Name::RootStorage) {
-
- Instr::LoadRoot instr;
- instr.reg = currentReg;
- gen(instr);
-
- if (e->symbol == IR::Name::IdObject) {
- // The ID is a reference to the root object
- return;
- }
-
- } else if (e->storage == IR::Name::ScopeStorage) {
-
- Instr::LoadScope instr;
- instr.reg = currentReg;
- gen(instr);
-
- _subscribeName << contextName();
-
- } else if (e->storage == IR::Name::IdStorage) {
-
- Instr::LoadId instr;
- instr.reg = currentReg;
- instr.index = e->idObject->idIndex;
- gen(instr);
-
- _subscribeName << QLatin1String("$$$ID_") + *e->id;
-
- if (blockNeedsSubscription(_subscribeName)) {
- Instr::SubscribeId sub;
- sub.reg = currentReg;
- sub.offset = subscriptionIndex(_subscribeName);
- sub.index = instr.index;
- gen(sub);
- }
-
- return;
- } else {
- // No action needed
- }
-
- switch (e->symbol) {
- case IR::Name::Unbound:
- case IR::Name::IdObject:
- case IR::Name::Slot:
- case IR::Name::Object: {
- Q_ASSERT(!"Unreachable");
- discard();
- } break;
-
- case IR::Name::AttachType: {
- _subscribeName << *e->id;
-
- Instr::LoadAttached attached;
- attached.output = currentReg;
- attached.reg = currentReg;
- attached.exceptionId = exceptionId(e->line, e->column);
- if (e->declarativeType->attachedPropertiesId() == -1)
- discard();
- attached.id = e->declarativeType->attachedPropertiesId();
- gen(attached);
- } break;
-
- case IR::Name::Property: {
- _subscribeName << *e->id;
-
- if (e->property->coreIndex == -1) {
- QMetaProperty prop;
- e->property->load(prop, QDeclarativeEnginePrivate::get(engine));
- }
-
- const int propTy = e->property->propType;
- QDeclarativeRegisterType regType;
-
- switch (propTy) {
- case QMetaType::QReal:
- regType = QRealType;
- break;
- case QMetaType::Bool:
- regType = BoolType;
- break;
- case QMetaType::Int:
- regType = IntType;
- break;
- case QMetaType::QString:
- regType = QStringType;
- break;
- case QMetaType::QUrl:
- regType = QUrlType;
- break;
- case QMetaType::QColor:
- regType = QColorType;
- break;
-
- default:
- if (propTy == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) {
- regType = PODValueType;
- } else if (QDeclarativeMetaType::isQObject(propTy)) {
- regType = QObjectStarType;
- } else {
- if (qmlVerboseCompiler())
- qWarning() << "Discard unsupported property type:" << QMetaType::typeName(propTy);
- discard(); // Unsupported type
- return;
- }
-
- break;
- } // switch
-
- if (e->property->hasAccessors()) {
- Instr::FetchAndSubscribe fetch;
- fetch.reg = currentReg;
- fetch.subscription = subscriptionIndex(_subscribeName);
- fetch.exceptionId = exceptionId(e->line, e->column);
- fetch.valueType = regType;
- fetch.property = *e->property;
- gen(fetch);
- } else {
- if (blockNeedsSubscription(_subscribeName) && e->property->notifyIndex != -1) {
- Instr::Subscribe sub;
- sub.reg = currentReg;
- sub.offset = subscriptionIndex(_subscribeName);
- sub.index = e->property->notifyIndex;
- gen(sub);
- }
-
- Instr::Fetch fetch;
- fetch.reg = currentReg;
- fetch.index = e->property->coreIndex;
- fetch.exceptionId = exceptionId(e->line, e->column);
- fetch.valueType = regType;
- gen(fetch);
- }
-
- } break;
- } // switch
-}
-
-void QV4CompilerPrivate::visitTemp(IR::Temp *e)
-{
- if (currentReg != e->index) {
- Instr::Copy i;
- i.reg = currentReg;
- i.src = e->index;
- gen(i);
- }
-}
-
-void QV4CompilerPrivate::visitUnop(IR::Unop *e)
-{
- quint8 src = currentReg;
-
- if (IR::Temp *temp = e->expr->asTemp()) {
- src = temp->index;
- } else {
- traceExpression(e->expr, src);
- }
-
- switch (e->op) {
- case IR::OpInvalid:
- Q_ASSERT(!"unreachable");
- break;
-
- case IR::OpIfTrue:
- convertToBool(e->expr, src);
- if (src != currentReg) {
- Instr::Copy i;
- i.reg = currentReg;
- i.src = src;
- gen(i);
- }
- break;
-
- case IR::OpNot: {
- Instr::UnaryNot i;
- convertToBool(e->expr, src);
- i.output = currentReg;
- i.src = src;
- gen(i);
- } break;
-
- case IR::OpUMinus:
- if (e->expr->type == IR::RealType) {
- Instr::UnaryMinusReal i;
- i.output = currentReg;
- i.src = src;
- gen(i);
- } else if (e->expr->type == IR::IntType) {
- convertToReal(e->expr, currentReg);
- Instr::UnaryMinusReal i;
- i.output = currentReg;
- i.src = src;
- gen(i);
- } else {
- discard();
- }
- break;
-
- case IR::OpUPlus:
- if (e->expr->type == IR::RealType) {
- Instr::UnaryPlusReal i;
- i.output = currentReg;
- i.src = src;
- gen(i);
- } else if (e->expr->type == IR::IntType) {
- convertToReal(e->expr, currentReg);
- Instr::UnaryPlusReal i;
- i.output = currentReg;
- i.src = src;
- gen(i);
- } else {
- discard();
- }
- break;
-
- case IR::OpCompl:
- // TODO
- discard();
- break;
-
- case IR::OpBitAnd:
- case IR::OpBitOr:
- case IR::OpBitXor:
- case IR::OpAdd:
- case IR::OpSub:
- case IR::OpMul:
- case IR::OpDiv:
- case IR::OpMod:
- case IR::OpLShift:
- case IR::OpRShift:
- case IR::OpURShift:
- case IR::OpGt:
- case IR::OpLt:
- case IR::OpGe:
- case IR::OpLe:
- case IR::OpEqual:
- case IR::OpNotEqual:
- case IR::OpStrictEqual:
- case IR::OpStrictNotEqual:
- case IR::OpAnd:
- case IR::OpOr:
- Q_ASSERT(!"unreachable");
- break;
- } // switch
-}
-
-void QV4CompilerPrivate::convertToReal(IR::Expr *expr, int reg)
-{
- if (expr->type == IR::RealType)
- return;
-
- switch (expr->type) {
- case IR::BoolType: {
- Instr::ConvertBoolToReal i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- case IR::IntType: {
- Instr::ConvertIntToReal i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- case IR::RealType:
- // nothing to do
- return;
-
- default:
- discard();
- break;
- } // switch
-}
-
-void QV4CompilerPrivate::convertToInt(IR::Expr *expr, int reg)
-{
- if (expr->type == IR::IntType)
- return;
-
- switch (expr->type) {
- case IR::BoolType: {
- Instr::ConvertBoolToInt i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- case IR::IntType:
- // nothing to do
- return;
-
- case IR::RealType: {
- Instr::ConvertRealToInt i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- default:
- discard();
- break;
- } // switch
-}
-
-void QV4CompilerPrivate::convertToBool(IR::Expr *expr, int reg)
-{
- if (expr->type == IR::BoolType)
- return;
-
- switch (expr->type) {
- case IR::BoolType:
- // nothing to do
- break;
-
- case IR::IntType: {
- Instr::ConvertIntToBool i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- case IR::RealType: {
- Instr::ConvertRealToBool i;
- i.output = i.src = reg;
- gen(i);
- } return;
-
- case IR::StringType: {
- Instr::ConvertStringToBool i;
- i.output = i.src = reg;
- gen(i);
- } return;
-
- case IR::ColorType: {
- Instr::ConvertColorToBool i;
- i.output = i.src = reg;
- gen(i);
- } return;
-
- default:
- discard();
- break;
- } // switch
-}
-
-quint8 QV4CompilerPrivate::instructionOpcode(IR::Binop *e)
-{
- switch (e->op) {
- case IR::OpInvalid:
- return V4Instr::Noop;
-
- case IR::OpIfTrue:
- case IR::OpNot:
- case IR::OpUMinus:
- case IR::OpUPlus:
- case IR::OpCompl:
- return V4Instr::Noop;
-
- case IR::OpBitAnd:
- return V4Instr::BitAndInt;
-
- case IR::OpBitOr:
- return V4Instr::BitOrInt;
-
- case IR::OpBitXor:
- return V4Instr::BitXorInt;
-
- case IR::OpAdd:
- if (e->type == IR::StringType)
- return V4Instr::AddString;
- return V4Instr::AddReal;
-
- case IR::OpSub:
- return V4Instr::SubReal;
-
- case IR::OpMul:
- return V4Instr::MulReal;
-
- case IR::OpDiv:
- return V4Instr::DivReal;
-
- case IR::OpMod:
- return V4Instr::ModReal;
-
- case IR::OpLShift:
- return V4Instr::LShiftInt;
-
- case IR::OpRShift:
- return V4Instr::RShiftInt;
-
- case IR::OpURShift:
- return V4Instr::URShiftInt;
-
- case IR::OpGt:
- if (e->left->type == IR::StringType)
- return V4Instr::GtString;
- return V4Instr::GtReal;
-
- case IR::OpLt:
- if (e->left->type == IR::StringType)
- return V4Instr::LtString;
- return V4Instr::LtReal;
-
- case IR::OpGe:
- if (e->left->type == IR::StringType)
- return V4Instr::GeString;
- return V4Instr::GeReal;
-
- case IR::OpLe:
- if (e->left->type == IR::StringType)
- return V4Instr::LeString;
- return V4Instr::LeReal;
-
- case IR::OpEqual:
- if (e->left->type == IR::StringType)
- return V4Instr::EqualString;
- return V4Instr::EqualReal;
-
- case IR::OpNotEqual:
- if (e->left->type == IR::StringType)
- return V4Instr::NotEqualString;
- return V4Instr::NotEqualReal;
-
- case IR::OpStrictEqual:
- if (e->left->type == IR::StringType)
- return V4Instr::StrictEqualString;
- return V4Instr::StrictEqualReal;
-
- case IR::OpStrictNotEqual:
- if (e->left->type == IR::StringType)
- return V4Instr::StrictNotEqualString;
- return V4Instr::StrictNotEqualReal;
-
- case IR::OpAnd:
- case IR::OpOr:
- return V4Instr::Noop;
-
- } // switch
-
- return V4Instr::Noop;
-}
-
-void QV4CompilerPrivate::visitBinop(IR::Binop *e)
-{
- int left = currentReg;
- int right = currentReg + 1;
-
- if (e->left->asTemp() && e->type != IR::StringType) // Not sure if the e->type != String test is needed
- left = e->left->asTemp()->index;
- else
- traceExpression(e->left, left);
-
- if (IR::Temp *t = e->right->asTemp())
- right = t->index;
- else
- traceExpression(e->right, right);
-
- if (e->left->type != e->right->type) {
- if (qmlVerboseCompiler())
- qWarning().nospace() << "invalid operands to binary operator " << IR::binaryOperator(e->op)
- << "(`" << IR::binaryOperator(e->left->type)
- << "' and `"
- << IR::binaryOperator(e->right->type)
- << "'";
- discard();
- return;
- }
-
- switch (e->op) {
- case IR::OpInvalid:
- discard();
- break;
-
- // unary
- case IR::OpIfTrue:
- case IR::OpNot:
- case IR::OpUMinus:
- case IR::OpUPlus:
- case IR::OpCompl:
- discard();
- break;
-
- case IR::OpBitAnd:
- case IR::OpBitOr:
- case IR::OpBitXor:
- case IR::OpLShift:
- case IR::OpRShift:
- case IR::OpURShift:
- convertToInt(e->left, left);
- convertToInt(e->right, right);
- break;
-
- case IR::OpAdd:
- if (e->type != IR::StringType) {
- convertToReal(e->left, left);
- convertToReal(e->right, right);
- }
- break;
-
- case IR::OpSub:
- case IR::OpMul:
- case IR::OpDiv:
- case IR::OpMod:
- convertToReal(e->left, left);
- convertToReal(e->right, right);
- break;
-
- case IR::OpGt:
- case IR::OpLt:
- case IR::OpGe:
- case IR::OpLe:
- case IR::OpEqual:
- case IR::OpNotEqual:
- case IR::OpStrictEqual:
- case IR::OpStrictNotEqual:
- if (e->left->type != IR::StringType) {
- convertToReal(e->left, left);
- convertToReal(e->right, right);
- }
- break;
-
- case IR::OpAnd:
- case IR::OpOr:
- discard(); // ### unreachable
- break;
- } // switch
-
- const quint8 opcode = instructionOpcode(e);
- if (opcode != V4Instr::Noop) {
- V4Instr instr;
- instr.binaryop.output = currentReg;
- instr.binaryop.left = left;
- instr.binaryop.right = right;
- gen(static_cast<V4Instr::Type>(opcode), instr);
- }
-}
-
-void QV4CompilerPrivate::visitCall(IR::Call *call)
-{
- if (IR::Name *name = call->base->asName()) {
- IR::Expr *arg = call->onlyArgument();
- if (arg != 0 && arg->type == IR::RealType) {
- traceExpression(arg, currentReg);
-
- switch (name->builtin) {
- case IR::NoBuiltinSymbol:
- break;
-
- case IR::MathSinBultinFunction: {
- Instr::MathSinReal i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathCosBultinFunction: {
- Instr::MathCosReal i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathRoundBultinFunction: {
- Instr::MathRoundReal i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathFloorBultinFunction: {
- Instr::MathFloorReal i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathPIBuiltinConstant:
- break;
- } // switch
- }
- }
-
- if (qmlVerboseCompiler())
- qWarning() << "TODO:" << Q_FUNC_INFO << __LINE__;
- discard();
-}
-
-
-//
-// statements
-//
-void QV4CompilerPrivate::visitExp(IR::Exp *s)
-{
- traceExpression(s->expr, currentReg);
-}
-
-void QV4CompilerPrivate::visitMove(IR::Move *s)
-{
- IR::Temp *target = s->target->asTemp();
- Q_ASSERT(target != 0);
-
- quint8 dest = target->index;
-
- if (target->type != s->source->type) {
- quint8 src = dest;
-
- if (IR::Temp *t = s->source->asTemp())
- src = t->index;
- else
- traceExpression(s->source, dest);
-
- V4Instr::Type opcode = V4Instr::Noop;
- IR::Type targetTy = s->target->type;
- IR::Type sourceTy = s->source->type;
-
- if (sourceTy == IR::UrlType) {
- switch (targetTy) {
- case IR::BoolType:
- case IR::StringType:
- // nothing to do. V4 will generate optimized
- // url-to-xxx conversions.
- break;
- default: {
- // generate a UrlToString conversion and fix
- // the type of the source expression.
- V4Instr conv;
- conv.unaryop.output = V4Instr::ConvertUrlToString;
- conv.unaryop.src = src;
- gen(opcode, conv);
-
- sourceTy = IR::StringType;
- break;
- }
- } // switch
- }
-
- if (targetTy == IR::BoolType) {
- switch (sourceTy) {
- case IR::IntType: opcode = V4Instr::ConvertIntToBool; break;
- case IR::RealType: opcode = V4Instr::ConvertRealToBool; break;
- case IR::StringType: opcode = V4Instr::ConvertStringToBool; break;
- case IR::UrlType: opcode = V4Instr::ConvertUrlToBool; break;
- case IR::ColorType: opcode = V4Instr::ConvertColorToBool; break;
- default: break;
- } // switch
- } else if (targetTy == IR::IntType) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToInt; break;
- case IR::RealType: {
- if (s->isMoveForReturn)
- opcode = V4Instr::MathRoundReal;
- else
- opcode = V4Instr::ConvertRealToInt;
- break;
- }
- case IR::StringType: opcode = V4Instr::ConvertStringToInt; break;
- default: break;
- } // switch
- } else if (targetTy == IR::RealType) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToReal; break;
- case IR::IntType: opcode = V4Instr::ConvertIntToReal; break;
- case IR::StringType: opcode = V4Instr::ConvertStringToReal; break;
- default: break;
- } // switch
- } else if (targetTy == IR::StringType) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToString; break;
- case IR::IntType: opcode = V4Instr::ConvertIntToString; break;
- case IR::RealType: opcode = V4Instr::ConvertRealToString; break;
- case IR::UrlType: opcode = V4Instr::ConvertUrlToString; break;
- case IR::ColorType: opcode = V4Instr::ConvertColorToString; break;
- default: break;
- } // switch
- } else if (targetTy == IR::UrlType) {
- V4Instr convToString;
- convToString.unaryop.output = dest;
- convToString.unaryop.src = src;
-
- // try to convert the source expression to a string.
- switch (sourceTy) {
- case IR::BoolType: gen(V4Instr::ConvertBoolToString, convToString); sourceTy = IR::StringType; break;
- case IR::IntType: gen(V4Instr::ConvertIntToString, convToString); sourceTy = IR::StringType; break;
- case IR::RealType: gen(V4Instr::ConvertRealToString, convToString); sourceTy = IR::StringType; break;
- case IR::ColorType: gen(V4Instr::ConvertColorToString, convToString); sourceTy = IR::StringType; break;
- default: break;
- } // switch
-
- if (sourceTy == IR::StringType)
- opcode = V4Instr::ConvertStringToUrl;
- } else if (targetTy == IR::ColorType) {
- switch (sourceTy) {
- case IR::StringType: opcode = V4Instr::ConvertStringToColor; break;
- default: break;
- } // switch
- }
- if (opcode != V4Instr::Noop) {
- V4Instr conv;
- conv.unaryop.output = dest;
- conv.unaryop.src = src;
- gen(opcode, conv);
-
- if (s->isMoveForReturn && opcode == V4Instr::ConvertStringToUrl) {
- V4Instr resolveUrl;
- resolveUrl.unaryop.output = dest;
- resolveUrl.unaryop.src = dest;
- gen(V4Instr::ResolveUrl, resolveUrl);
- }
- } else {
- discard();
- }
- } else {
- traceExpression(s->source, dest);
- }
-}
-
-void QV4CompilerPrivate::visitJump(IR::Jump *s)
-{
- patches.append(Patch(s->target, bytecode.size()));
-
- Instr::Branch i;
- i.offset = 0; // ### backpatch
- gen(i);
-}
-
-void QV4CompilerPrivate::visitCJump(IR::CJump *s)
-{
- traceExpression(s->cond, currentReg);
-
- patches.append(Patch(s->iftrue, bytecode.size()));
-
- Instr::BranchTrue i;
- i.reg = currentReg;
- i.offset = 0; // ### backpatch
- gen(i);
-}
-
-void QV4CompilerPrivate::visitRet(IR::Ret *s)
-{
- Q_ASSERT(s->expr != 0);
-
- int storeReg = currentReg;
-
- if (IR::Temp *temp = s->expr->asTemp()) {
- storeReg = temp->index;
- } else {
- traceExpression(s->expr, storeReg);
- }
-
- if (qmlBindingsTest) {
- Instr::TestV4Store test;
- test.reg = storeReg;
- switch (s->type) {
- case IR::StringType:
- test.regType = QMetaType::QString;
- break;
- case IR::UrlType:
- test.regType = QMetaType::QUrl;
- break;
- case IR::ColorType:
- test.regType = QMetaType::QColor;
- break;
- case IR::SGAnchorLineType:
- test.regType = QDeclarativeMetaType::QQuickAnchorLineMetaTypeId();
- break;
- case IR::ObjectType:
- test.regType = QMetaType::QObjectStar;
- break;
- case IR::BoolType:
- test.regType = QMetaType::Bool;
- break;
- case IR::IntType:
- test.regType = QMetaType::Int;
- break;
- case IR::RealType:
- test.regType = QMetaType::QReal;
- break;
- default:
- discard();
- return;
- }
- gen(test);
- }
-
- Instr::Store store;
- store.output = 0;
- store.index = expression->property->index;
- store.reg = storeReg;
- store.exceptionId = exceptionId(s->line, s->column);
- gen(store);
-}
-
-void QV4Compiler::dump(const QByteArray &programData)
-{
- const QV4Program *program = (const QV4Program *)programData.constData();
-
- qWarning() << "Program.bindings:" << program->bindings;
- qWarning() << "Program.dataLength:" << program->dataLength;
- qWarning() << "Program.subscriptions:" << program->subscriptions;
- qWarning() << "Program.indentifiers:" << program->identifiers;
-
- const int programSize = program->instructionCount;
- const char *start = program->instructions();
- const char *end = start + programSize;
- Bytecode bc;
- bc.dump(start, end);
-}
-
-/*!
-Clear the state associated with attempting to compile a specific binding.
-This does not clear the global "committed binding" states.
-*/
-void QV4CompilerPrivate::resetInstanceState()
-{
- data = committed.data;
- exceptions = committed.exceptions;
- usedSubscriptionIds.clear();
- subscriptionIds = committed.subscriptionIds;
- registeredStrings = committed.registeredStrings;
- bytecode.clear();
- patches.clear();
- pool.clear();
- currentReg = 0;
-}
-
-/*!
-Mark the last compile as successful, and add it to the "committed data"
-section.
-
-Returns the index for the committed binding.
-*/
-int QV4CompilerPrivate::commitCompile()
-{
- int rv = committed.count();
- committed.offsets << committed.bytecode.count();
- committed.dependencies << usedSubscriptionIds;
- committed.bytecode.append(bytecode.constData(), bytecode.size());
- committed.data = data;
- committed.exceptions = exceptions;
- committed.subscriptionIds = subscriptionIds;
- committed.registeredStrings = registeredStrings;
- return rv;
-}
-
-bool QV4CompilerPrivate::compile(QDeclarativeJS::AST::Node *node)
-{
- resetInstanceState();
-
- if (expression->property->type == -1)
- return false;
-
- AST::SourceLocation location;
- if (AST::ExpressionNode *astExpression = node->expressionCast()) {
- location = astExpression->firstSourceLocation();
- } else if (AST::Statement *astStatement = node->statementCast()) {
- if (AST::Block *block = AST::cast<AST::Block *>(astStatement))
- location = block->lbraceToken;
- else if (AST::IfStatement *ifStmt = AST::cast<AST::IfStatement *>(astStatement))
- location = ifStmt->ifToken;
- else
- return false;
- } else {
- return false;
- }
-
- IR::Function thisFunction(&pool), *function = &thisFunction;
-
- QV4IRBuilder irBuilder(expression, engine);
- if (!irBuilder(function, node))
- return false;
-
- bool discarded = false;
- qSwap(_discarded, discarded);
- qSwap(_function, function);
- trace(location.startLine, location.startColumn);
- qSwap(_function, function);
- qSwap(_discarded, discarded);
-
- if (qmlVerboseCompiler()) {
- QTextStream qerr(stderr, QIODevice::WriteOnly);
- if (discarded)
- qerr << "======== TODO ====== " << endl;
- else
- qerr << "==================== " << endl;
- qerr << "\tline: " << location.startLine
- << "\tcolumn: " << location.startColumn
- << endl;
- foreach (IR::BasicBlock *bb, function->basicBlocks)
- bb->dump(qerr);
- qerr << endl;
- }
-
- if (discarded || subscriptionIds.count() > 0xFFFF || registeredStrings.count() > 0xFFFF || registerCount > 31)
- return false;
-
- return true;
-}
-
-// Returns a reg
-int QV4CompilerPrivate::registerLiteralString(quint8 reg, const QStringRef &str)
-{
- // ### string cleanup
-
- QByteArray strdata((const char *)str.constData(), str.length() * sizeof(QChar));
- int offset = data.count();
- data += strdata;
-
- Instr::LoadString string;
- string.reg = reg;
- string.offset = offset;
- string.length = str.length();
- gen(string);
-
- return reg;
-}
-
-// Returns an identifier offset
-int QV4CompilerPrivate::registerString(const QString &string)
-{
- Q_ASSERT(!string.isEmpty());
-
- QPair<int, int> *iter = registeredStrings.value(string);
-
- if (!iter) {
- quint32 len = string.length();
- QByteArray lendata((const char *)&len, sizeof(quint32));
- QByteArray strdata((const char *)string.constData(), string.length() * sizeof(QChar));
- strdata.prepend(lendata);
- int rv = data.count();
- data += strdata;
-
- iter = &registeredStrings[string];
- *iter = qMakePair(registeredStrings.count(), rv);
- }
-
- Instr::InitString reg;
- reg.offset = iter->first;
- reg.dataIdx = iter->second;
- gen(reg);
- return reg.offset;
-}
-
-/*!
-Returns true if the current expression has not already subscribed to \a sub in currentBlockMask.
-*/
-bool QV4CompilerPrivate::blockNeedsSubscription(const QStringList &sub)
-{
- QString str = sub.join(QLatin1String("."));
-
- int *iter = subscriptionIds.value(str);
- if (!iter)
- return true;
-
- quint32 *uiter = usedSubscriptionIds.value(*iter);
- if (!uiter)
- return true;
- else
- return !(*uiter & currentBlockMask);
-}
-
-int QV4CompilerPrivate::subscriptionIndex(const QStringList &sub)
-{
- QString str = sub.join(QLatin1String("."));
- int *iter = subscriptionIds.value(str);
- if (!iter) {
- int count = subscriptionIds.count();
- iter = &subscriptionIds[str];
- *iter = count;
- }
- quint32 &u = usedSubscriptionIds[*iter];
- if (!(u & currentBlockMask)) {
- u |= currentBlockMask;
- usedSubscriptionIdsChanged = true;
- }
- return *iter;
-}
-
-quint32 QV4CompilerPrivate::subscriptionBlockMask(const QStringList &sub)
-{
- QString str = sub.join(QLatin1String("."));
-
- int *iter = subscriptionIds.value(str);
- Q_ASSERT(iter != 0);
-
- quint32 *uiter = usedSubscriptionIds.value(*iter);
- Q_ASSERT(uiter != 0);
-
- return *uiter;
-}
-
-quint8 QV4CompilerPrivate::exceptionId(quint32 line, quint32 column)
-{
- quint8 rv = 0xFF;
- if (exceptions.count() < 0xFF) {
- rv = (quint8)exceptions.count();
- quint64 e = line;
- e <<= 32;
- e |= column;
- exceptions.append(e);
- }
- return rv;
-}
-
-quint8 QV4CompilerPrivate::exceptionId(QDeclarativeJS::AST::ExpressionNode *n)
-{
- quint8 rv = 0xFF;
- if (n && exceptions.count() < 0xFF) {
- QDeclarativeJS::AST::SourceLocation l = n->firstSourceLocation();
- rv = exceptionId(l.startLine, l.startColumn);
- }
- return rv;
-}
-
-QV4Compiler::QV4Compiler()
-: d(new QV4CompilerPrivate)
-{
- qmlBindingsTest |= qmlBindingsTestEnv();
-}
-
-QV4Compiler::~QV4Compiler()
-{
- delete d; d = 0;
-}
-
-/*
-Returns true if any bindings were compiled.
-*/
-bool QV4Compiler::isValid() const
-{
- return !d->committed.bytecode.isEmpty();
-}
-
-/*
--1 on failure, otherwise the binding index to use.
-*/
-int QV4Compiler::compile(const Expression &expression, QDeclarativeEnginePrivate *engine)
-{
- if (!expression.expression.asAST()) return false;
-
- if (!qmlExperimental() && expression.property->isValueTypeSubProperty)
- return -1;
-
- if (qmlDisableOptimizer() || !qmlEnableV4)
- return -1;
-
- d->expression = &expression;
- d->engine = engine;
-
- if (d->compile(expression.expression.asAST())) {
- return d->commitCompile();
- } else {
- return -1;
- }
-}
-
-QByteArray QV4CompilerPrivate::buildSignalTable() const
-{
- QHash<int, QList<QPair<int, quint32> > > table;
-
- for (int ii = 0; ii < committed.count(); ++ii) {
- const QDeclarativeAssociationList<int, quint32> &deps = committed.dependencies.at(ii);
- for (QDeclarativeAssociationList<int, quint32>::const_iterator iter = deps.begin(); iter != deps.end(); ++iter)
- table[iter->first].append(qMakePair(ii, iter->second));
- }
-
- QVector<quint32> header;
- QVector<quint32> data;
- for (int ii = 0; ii < committed.subscriptionIds.count(); ++ii) {
- header.append(committed.subscriptionIds.count() + data.count());
- const QList<QPair<int, quint32> > &bindings = table[ii];
- data.append(bindings.count());
- for (int jj = 0; jj < bindings.count(); ++jj) {
- data.append(bindings.at(jj).first);
- data.append(bindings.at(jj).second);
- }
- }
- header << data;
-
- return QByteArray((const char *)header.constData(), header.count() * sizeof(quint32));
-}
-
-QByteArray QV4CompilerPrivate::buildExceptionData() const
-{
- QByteArray rv;
- rv.resize(committed.exceptions.count() * sizeof(quint64));
- ::memcpy(rv.data(), committed.exceptions.constData(), rv.size());
- return rv;
-}
-
-/*
-Returns the compiled program.
-*/
-QByteArray QV4Compiler::program() const
-{
- QByteArray programData;
-
- if (isValid()) {
- QV4Program prog;
- prog.bindings = d->committed.count();
-
- Bytecode bc;
- QV4CompilerPrivate::Instr::Jump jump;
- jump.reg = -1;
-
- for (int ii = 0; ii < d->committed.count(); ++ii) {
- jump.count = d->committed.count() - ii - 1;
- jump.count*= V4InstrMeta<V4Instr::Jump>::Size;
- jump.count+= d->committed.offsets.at(ii);
- bc.append(jump);
- }
-
-
- QByteArray bytecode;
- bytecode.reserve(bc.size() + d->committed.bytecode.size());
- bytecode.append(bc.constData(), bc.size());
- bytecode.append(d->committed.bytecode.constData(), d->committed.bytecode.size());
-
- QByteArray data = d->committed.data;
- while (data.count() % 4) data.append('\0');
- prog.signalTableOffset = data.count();
- data += d->buildSignalTable();
- while (data.count() % 4) data.append('\0');
- prog.exceptionDataOffset = data.count();
- data += d->buildExceptionData();
-
- prog.dataLength = 4 * ((data.size() + 3) / 4);
- prog.subscriptions = d->committed.subscriptionIds.count();
- prog.identifiers = d->committed.registeredStrings.count();
- prog.instructionCount = bytecode.count();
- int size = sizeof(QV4Program) + bytecode.count();
- size += prog.dataLength;
-
- programData.resize(size);
- memcpy(programData.data(), &prog, sizeof(QV4Program));
- if (prog.dataLength)
- memcpy((char *)((QV4Program *)programData.data())->data(), data.constData(),
- data.size());
- memcpy((char *)((QV4Program *)programData.data())->instructions(), bytecode.constData(),
- bytecode.count());
- }
-
- if (bindingsDump()) {
- qWarning().nospace() << "Subscription slots:";
-
- for (QDeclarativeAssociationList<QString, int>::ConstIterator iter = d->committed.subscriptionIds.begin();
- iter != d->committed.subscriptionIds.end();
- ++iter) {
- qWarning().nospace() << " " << iter->first << "\t-> " << iter->second;
- }
-
- QV4Compiler::dump(programData);
- }
-
- return programData;
-}
-
-void QV4Compiler::enableBindingsTest(bool e)
-{
- if (e)
- qmlBindingsTest = true;
- else
- qmlBindingsTest = qmlBindingsTestEnv();
-}
-
-void QV4Compiler::enableV4(bool e)
-{
- qmlEnableV4 = e;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v4/qv4compiler_p.h b/src/declarative/qml/v4/qv4compiler_p.h
deleted file mode 100644
index 99d5569b6a..0000000000
--- a/src/declarative/qml/v4/qv4compiler_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4COMPILER_P_H
-#define QV4COMPILER_P_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 <private/qdeclarativeexpression_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativecompiler_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeTypeNameCache;
-class QV4CompilerPrivate;
-class Q_AUTOTEST_EXPORT QV4Compiler
-{
-public:
- QV4Compiler();
- ~QV4Compiler();
-
- // Returns true if bindings were compiled
- bool isValid() const;
-
- struct Expression
- {
- Expression(const QDeclarativeImports &imp) : imports(imp) {}
- QDeclarativeScript::Object *component;
- QDeclarativeScript::Object *context;
- QDeclarativeScript::Property *property;
- QDeclarativeScript::Variant expression;
- QDeclarativeCompilerTypes::IdList *ids;
- QDeclarativeTypeNameCache *importCache;
- QDeclarativeImports imports;
- };
-
- // -1 on failure, otherwise the binding index to use
- int compile(const Expression &, QDeclarativeEnginePrivate *);
-
- // Returns the compiled program
- QByteArray program() const;
-
- static void dump(const QByteArray &);
- static void enableBindingsTest(bool);
- static void enableV4(bool);
-private:
- QV4CompilerPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV4COMPILER_P_H
-
diff --git a/src/declarative/qml/v4/qv4compiler_p_p.h b/src/declarative/qml/v4/qv4compiler_p_p.h
deleted file mode 100644
index c43140663e..0000000000
--- a/src/declarative/qml/v4/qv4compiler_p_p.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4COMPILER_P_P_H
-#define QV4COMPILER_P_P_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 "qv4instruction_p.h"
-#include "qv4ir_p.h"
-#include <private/qdeclarativescript_p.h>
-#include <private/qdeclarativeimport_p.h>
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-template <typename _Key, typename _Value>
-class QDeclarativeAssociationList
-{
-public:
- typedef QVarLengthArray<QPair<_Key, _Value>, 8> Container;
- typedef typename Container::const_iterator const_iterator;
- typedef typename Container::const_iterator ConstIterator;
-
- const_iterator begin() const { return _container.begin(); }
- const_iterator end() const { return _container.end(); }
- int count() const { return _container.count(); }
- void clear() { _container.clear(); }
-
- _Value *value(const _Key &key) {
- for (int i = 0; i < _container.size(); ++i) {
- QPair<_Key, _Value> &p = _container[i];
- if (p.first == key)
- return &p.second;
- }
- return 0;
- }
-
- _Value &operator[](const _Key &key) {
- for (int i = 0; i < _container.size(); ++i) {
- QPair<_Key, _Value> &p = _container[i];
- if (p.first == key)
- return p.second;
- }
- int index = _container.size();
- _container.append(qMakePair(key, _Value()));
- return _container[index].second;
- }
-
- void insert(const _Key &key, _Value &value) {
- for (int i = 0; i < _container.size(); ++i) {
- QPair<_Key, _Value> &p = _container[i];
- if (p.first == key) {
- p.second = value;
- return;
- }
- }
- _container.append(qMakePair(key, value));
- }
-
-private:
- Container _container;
-};
-
-class QV4CompilerPrivate: protected QDeclarativeJS::IR::ExprVisitor,
- protected QDeclarativeJS::IR::StmtVisitor
-{
-public:
- QV4CompilerPrivate();
-
- void resetInstanceState();
- int commitCompile();
-
- const QV4Compiler::Expression *expression;
- QDeclarativeEnginePrivate *engine;
-
- QString contextName() const { return QLatin1String("$$$SCOPE_") + QString::number((quintptr)expression->context, 16); }
-
- bool compile(QDeclarativeJS::AST::Node *);
-
- int registerLiteralString(quint8 reg, const QStringRef &);
- int registerString(const QString &);
- QDeclarativeAssociationList<QString, QPair<int, int> > registeredStrings;
- QByteArray data;
-
- bool blockNeedsSubscription(const QStringList &);
- int subscriptionIndex(const QStringList &);
- quint32 subscriptionBlockMask(const QStringList &);
-
- quint8 exceptionId(quint32 line, quint32 column);
- quint8 exceptionId(QDeclarativeJS::AST::ExpressionNode *);
- QVector<quint64> exceptions;
-
- QDeclarativeAssociationList<int, quint32> usedSubscriptionIds;
-
- QDeclarativeAssociationList<QString, int> subscriptionIds;
- QDeclarativeJS::Bytecode bytecode;
-
- // back patching
- struct Patch {
- QDeclarativeJS::IR::BasicBlock *block; // the basic block
- int offset; // the index of the instruction to patch
- Patch(QDeclarativeJS::IR::BasicBlock *block = 0, int index = -1)
- : block(block), offset(index) {}
- };
- QVector<Patch> patches;
- QDeclarativePool pool;
-
- // Committed binding data
- struct {
- QList<int> offsets;
- QList<QDeclarativeAssociationList<int, quint32> > dependencies;
-
- //QDeclarativeJS::Bytecode bytecode;
- QByteArray bytecode;
- QByteArray data;
- QDeclarativeAssociationList<QString, int> subscriptionIds;
- QVector<quint64> exceptions;
-
- QDeclarativeAssociationList<QString, QPair<int, int> > registeredStrings;
-
- int count() const { return offsets.count(); }
- } committed;
-
- QByteArray buildSignalTable() const;
- QByteArray buildExceptionData() const;
-
- void convertToReal(QDeclarativeJS::IR::Expr *expr, int reg);
- void convertToInt(QDeclarativeJS::IR::Expr *expr, int reg);
- void convertToBool(QDeclarativeJS::IR::Expr *expr, int reg);
- quint8 instructionOpcode(QDeclarativeJS::IR::Binop *e);
-
- struct Instr {
-#define QML_V4_INSTR_DATA_TYPEDEF(I, FMT) typedef QDeclarativeJS::V4InstrData<QDeclarativeJS::V4Instr::I> I;
- FOR_EACH_V4_INSTR(QML_V4_INSTR_DATA_TYPEDEF)
-#undef QML_v4_INSTR_DATA_TYPEDEF
- private:
- Instr();
- };
-
-protected:
- //
- // tracing
- //
- void trace(int line, int column);
- void trace(QVector<QDeclarativeJS::IR::BasicBlock *> *blocks);
- void traceExpression(QDeclarativeJS::IR::Expr *e, quint8 r);
-
- template <int Instr>
- inline void gen(const QDeclarativeJS::V4InstrData<Instr> &i)
- { bytecode.append(i); }
- inline void gen(QDeclarativeJS::V4Instr::Type type, QDeclarativeJS::V4Instr &instr)
- { bytecode.append(type, instr); }
-
- inline QDeclarativeJS::V4Instr::Type instructionType(const QDeclarativeJS::V4Instr *i) const
- { return bytecode.instructionType(i); }
-
- //
- // expressions
- //
- virtual void visitConst(QDeclarativeJS::IR::Const *e);
- virtual void visitString(QDeclarativeJS::IR::String *e);
- virtual void visitName(QDeclarativeJS::IR::Name *e);
- virtual void visitTemp(QDeclarativeJS::IR::Temp *e);
- virtual void visitUnop(QDeclarativeJS::IR::Unop *e);
- virtual void visitBinop(QDeclarativeJS::IR::Binop *e);
- virtual void visitCall(QDeclarativeJS::IR::Call *e);
-
- //
- // statements
- //
- virtual void visitExp(QDeclarativeJS::IR::Exp *s);
- virtual void visitMove(QDeclarativeJS::IR::Move *s);
- virtual void visitJump(QDeclarativeJS::IR::Jump *s);
- virtual void visitCJump(QDeclarativeJS::IR::CJump *s);
- virtual void visitRet(QDeclarativeJS::IR::Ret *s);
-
-private:
- QStringList _subscribeName;
- QDeclarativeJS::IR::Function *_function;
- QDeclarativeJS::IR::BasicBlock *_block;
- void discard() { _discarded = true; }
- bool _discarded;
- quint8 currentReg;
- quint8 registerCount;
-
- bool usedSubscriptionIdsChanged;
- quint32 currentBlockMask;
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV4COMPILER_P_P_H
-
diff --git a/src/declarative/qml/v4/qv4instruction.cpp b/src/declarative/qml/v4/qv4instruction.cpp
deleted file mode 100644
index e9213f5e3f..0000000000
--- a/src/declarative/qml/v4/qv4instruction.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4instruction_p.h"
-#include "qv4bindings_p.h"
-
-#include <QtCore/qdebug.h>
-#include <private/qdeclarativeglobal_p.h>
-
-// Define this to do a test dump of all the instructions at startup. This is
-// helpful to test that each instruction's Instr::dump() case uses the correct
-// number of tabs etc and otherwise looks correct.
-// #define DEBUG_INSTR_DUMP
-
-QT_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-#ifdef DEBUG_INSTR_DUMP
-static struct DumpInstrAtStartup {
- DumpInstrAtStartup() {
- Bytecode bc;
-#define DUMP_INSTR_AT_STARTUP(I, FMT) { V4InstrData<V4Instr::I> i; bc.append(i); }
- FOR_EACH_V4_INSTR(DUMP_INSTR_AT_STARTUP);
-#undef DUMP_INSTR_AT_STARTUP
- const char *start = bc.constData();
- const char *end = start + bc.size();
- bc.dump(start, end);
- }
-} dump_instr_at_startup;
-#endif
-
-int V4Instr::size(Type type)
-{
-#define V4_RETURN_INSTR_SIZE(I, FMT) case I: return QML_V4_INSTR_SIZE(I, FMT);
- switch (type) {
- FOR_EACH_V4_INSTR(V4_RETURN_INSTR_SIZE)
- }
-#undef V4_RETURN_INSTR_SIZE
- return 0;
-}
-
-void Bytecode::dump(const V4Instr *i, int address) const
-{
- QByteArray leading;
- if (address != -1) {
- leading = QByteArray::number(address);
- leading.prepend(QByteArray(8 - leading.count(), ' '));
- leading.append("\t");
- }
-
-#define INSTR_DUMP qWarning().nospace() << leading.constData()
-
- switch (instructionType(i)) {
- case V4Instr::Noop:
- INSTR_DUMP << "\t" << "Noop";
- break;
- case V4Instr::BindingId:
- INSTR_DUMP << i->id.line << ":" << i->id.column << ":";
- break;
- case V4Instr::Subscribe:
- INSTR_DUMP << "\t" << "Subscribe" << "\t\t" << "Object_Reg(" << i->subscribeop.reg << ") Notify_Signal(" << i->subscribeop.index << ") -> Subscribe_Slot(" << i->subscribeop.offset << ")";
- break;
- case V4Instr::SubscribeId:
- INSTR_DUMP << "\t" << "SubscribeId" << "\t\t" << "Id_Offset(" << i->subscribeop.index << ") -> Subscribe_Slot(" << i->subscribeop.offset << ")";
- break;
- case V4Instr::FetchAndSubscribe:
- INSTR_DUMP << "\t" << "FetchAndSubscribe" << "\t" << "Object_Reg(" << i->fetchAndSubscribe.reg << ") Fast_Accessor(" << i->fetchAndSubscribe.property.accessors << ") -> Output_Reg(" << i->fetchAndSubscribe.reg << ") Subscription_Slot(" << i->fetchAndSubscribe.subscription << ")";
- break;
- case V4Instr::LoadId:
- INSTR_DUMP << "\t" << "LoadId" << "\t\t\t" << "Id_Offset(" << i->load.index << ") -> Output_Reg(" << i->load.reg << ")";
- break;
- case V4Instr::LoadScope:
- INSTR_DUMP << "\t" << "LoadScope" << "\t\t" << "-> Output_Reg(" << i->load.reg << ")";
- break;
- case V4Instr::LoadRoot:
- INSTR_DUMP << "\t" << "LoadRoot" << "\t\t" << "-> Output_Reg(" << i->load.reg << ")";
- break;
- case V4Instr::LoadAttached:
- INSTR_DUMP << "\t" << "LoadAttached" << "\t\t" << "Object_Reg(" << i->attached.reg << ") Attached_Index(" << i->attached.id << ") -> Output_Reg(" << i->attached.output << ")";
- break;
- case V4Instr::UnaryNot:
- INSTR_DUMP << "\t" << "UnaryNot" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::UnaryMinusReal:
- INSTR_DUMP << "\t" << "UnaryMinusReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::UnaryMinusInt:
- INSTR_DUMP << "\t" << "UnaryMinusInt" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::UnaryPlusReal:
- INSTR_DUMP << "\t" << "UnaryPlusReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::UnaryPlusInt:
- INSTR_DUMP << "\t" << "UnaryPlusInt" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertBoolToInt:
- INSTR_DUMP << "\t" << "ConvertBoolToInt" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertBoolToReal:
- INSTR_DUMP << "\t" << "ConvertBoolToReal" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertBoolToString:
- INSTR_DUMP << "\t" << "ConvertBoolToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertIntToBool:
- INSTR_DUMP << "\t" << "ConvertIntToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertIntToReal:
- INSTR_DUMP << "\t" << "ConvertIntToReal" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertIntToString:
- INSTR_DUMP << "\t" << "ConvertIntToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertRealToBool:
- INSTR_DUMP << "\t" << "ConvertRealToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertRealToInt:
- INSTR_DUMP << "\t" << "ConvertRealToInt" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertRealToString:
- INSTR_DUMP << "\t" << "ConvertRealToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertStringToBool:
- INSTR_DUMP << "\t" << "ConvertStringToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertStringToInt:
- INSTR_DUMP << "\t" << "ConvertStringToInt" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertStringToReal:
- INSTR_DUMP << "\t" << "ConvertStringToReal" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertStringToUrl:
- INSTR_DUMP << "\t" << "ConvertStringToUrl" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertStringToColor:
- INSTR_DUMP << "\t" << "ConvertStringToColor" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertUrlToBool:
- INSTR_DUMP << "\t" << "ConvertUrlToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertUrlToString:
- INSTR_DUMP << "\t" << "ConvertUrlToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertColorToBool:
- INSTR_DUMP << "\t" << "ConvertColorToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ConvertColorToString:
- INSTR_DUMP << "\t" << "ConvertColorToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::ResolveUrl:
- INSTR_DUMP << "\t" << "ResolveUrl" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::MathSinReal:
- INSTR_DUMP << "\t" << "MathSinReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::MathCosReal:
- INSTR_DUMP << "\t" << "MathCosReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::MathRoundReal:
- INSTR_DUMP << "\t" << "MathRoundReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::MathFloorReal:
- INSTR_DUMP << "\t" << "MathFloorReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::MathPIReal:
- INSTR_DUMP << "\t" << "MathPIReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
- break;
- case V4Instr::LoadReal:
- INSTR_DUMP << "\t" << "LoadReal" << "\t\t" << "Constant(" << i->real_value.value << ") -> Output_Reg(" << i->real_value.reg << ")";
- break;
- case V4Instr::LoadInt:
- INSTR_DUMP << "\t" << "LoadInt" << "\t\t\t" << "Constant(" << i->int_value.value << ") -> Output_Reg(" << i->int_value.reg << ")";
- break;
- case V4Instr::LoadBool:
- INSTR_DUMP << "\t" << "LoadBool" << "\t\t" << "Constant(" << i->bool_value.value << ") -> Output_Reg(" << i->bool_value.reg << ")";
- break;
- case V4Instr::LoadString:
- INSTR_DUMP << "\t" << "LoadString" << "\t\t" << "String_DataIndex(" << i->string_value.offset << ") String_Length(" << i->string_value.length << ") -> Output_Register(" << i->string_value.reg << ")";
- break;
- case V4Instr::EnableV4Test:
- INSTR_DUMP << "\t" << "EnableV4Test" << "\t\t" << "String_DataIndex(" << i->string_value.offset << ") String_Length(" << i->string_value.length << ")";
- break;
- case V4Instr::TestV4Store:
- INSTR_DUMP << "\t" << "TestV4Store" << "\t\t" << "Input_Reg(" << i->storetest.reg << ") Reg_Type(" << i->storetest.regType << ")";
- break;
- case V4Instr::BitAndInt:
- INSTR_DUMP << "\t" << "BitAndInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::BitOrInt:
- INSTR_DUMP << "\t" << "BitOrInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::BitXorInt:
- INSTR_DUMP << "\t" << "BitXorInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::AddReal:
- INSTR_DUMP << "\t" << "AddReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::AddString:
- INSTR_DUMP << "\t" << "AddString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::SubReal:
- INSTR_DUMP << "\t" << "SubReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::MulReal:
- INSTR_DUMP << "\t" << "MulReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::DivReal:
- INSTR_DUMP << "\t" << "DivReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::ModReal:
- INSTR_DUMP << "\t" << "ModReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::LShiftInt:
- INSTR_DUMP << "\t" << "LShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::RShiftInt:
- INSTR_DUMP << "\t" << "RShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::URShiftInt:
- INSTR_DUMP << "\t" << "URShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::GtReal:
- INSTR_DUMP << "\t" << "GtReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::LtReal:
- INSTR_DUMP << "\t" << "LtReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::GeReal:
- INSTR_DUMP << "\t" << "GeReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::LeReal:
- INSTR_DUMP << "\t" << "LeReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::EqualReal:
- INSTR_DUMP << "\t" << "EqualReal" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::NotEqualReal:
- INSTR_DUMP << "\t" << "NotEqualReal" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::StrictEqualReal:
- INSTR_DUMP << "\t" << "StrictEqualReal" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::StrictNotEqualReal:
- INSTR_DUMP << "\t" << "StrictNotEqualReal" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::GtString:
- INSTR_DUMP << "\t" << "GtString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::LtString:
- INSTR_DUMP << "\t" << "LtString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::GeString:
- INSTR_DUMP << "\t" << "GeString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::LeString:
- INSTR_DUMP << "\t" << "LeString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::EqualString:
- INSTR_DUMP << "\t" << "EqualString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::NotEqualString:
- INSTR_DUMP << "\t" << "NotEqualString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::StrictEqualString:
- INSTR_DUMP << "\t" << "StrictEqualString" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::StrictNotEqualString:
- INSTR_DUMP << "\t" << "StrictNotEqualString" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
- break;
- case V4Instr::NewString:
- INSTR_DUMP << "\t" << "NewString" << "\t\t" << "Register(" << i->construct.reg << ")";
- break;
- case V4Instr::NewUrl:
- INSTR_DUMP << "\t" << "NewUrl" << "\t\t\t" << "Register(" << i->construct.reg << ")";
- break;
- case V4Instr::CleanupRegister:
- INSTR_DUMP << "\t" << "CleanupRegister" << "\t\t" << "Register(" << i->cleanup.reg << ")";
- break;
- case V4Instr::Fetch:
- INSTR_DUMP << "\t" << "Fetch" << "\t\t\t" << "Object_Reg(" << i->fetch.reg << ") Property_Index(" << i->fetch.index << ") -> Output_Reg(" << i->fetch.reg << ")";
- break;
- case V4Instr::Store:
- INSTR_DUMP << "\t" << "Store" << "\t\t\t" << "Input_Reg(" << i->store.reg << ") -> Object_Reg(" << i->store.output << ") Property_Index(" << i->store.index << ")";
- break;
- case V4Instr::Copy:
- INSTR_DUMP << "\t" << "Copy" << "\t\t\t" << "Input_Reg(" << i->copy.src << ") -> Output_Reg(" << i->copy.reg << ")";
- break;
- case V4Instr::Jump:
- if (i->jump.reg != -1) {
- INSTR_DUMP << "\t" << "Jump" << "\t\t\t" << "Address(" << (address + size() + i->jump.count) << ") [if false == Input_Reg(" << i->jump.reg << ")]";
- } else {
- INSTR_DUMP << "\t" << "Jump" << "\t\t\t" << "Address(" << (address + size() + i->jump.count) << ")";
- }
- break;
- case V4Instr::BranchFalse:
- INSTR_DUMP << "\t" << "BranchFalse" << "\t\t" << "Address(" << (address + size() + i->branchop.offset) << ") [if false == Input_Reg(" << i->branchop.reg << ")]";
- break;
- case V4Instr::BranchTrue:
- INSTR_DUMP << "\t" << "BranchTrue" << "\t\t" << "Address(" << (address + size() + i->branchop.offset) << ") [if true == Input_Reg(" << i->branchop.reg << ")]";
- break;
- case V4Instr::Branch:
- INSTR_DUMP << "\t" << "Branch" << "\t\t\t" << "Address(" << (address + size() + i->branchop.offset) << ")";
- break;
- case V4Instr::InitString:
- INSTR_DUMP << "\t" << "InitString" << "\t\t" << "String_DataIndex(" << i->initstring.dataIdx << ") -> String_Slot(" << i->initstring.offset << ")";
- break;
- case V4Instr::Block:
- INSTR_DUMP << "\t" << "Block" << "\t\t\t" << "Mask(" << QByteArray::number(i->blockop.block, 16).constData() << ")";
- break;
- default:
- INSTR_DUMP << "\t" << "Unknown";
- break;
- }
-}
-
-void Bytecode::dump(const char *start, const char *end) const
-{
- const char *code = start;
- while (code < end) {
- const V4Instr *instr = reinterpret_cast<const V4Instr *>(code);
- dump(instr, code - start);
- code += V4Instr::size(instructionType(instr));
- }
-}
-
-Bytecode::Bytecode()
-{
-#ifdef QML_THREADED_INTERPRETER
- decodeInstr = QV4Bindings::getDecodeInstrTable();
-#endif
-}
-
-V4Instr::Type Bytecode::instructionType(const V4Instr *instr) const
-{
-#ifdef QML_THREADED_INTERPRETER
- void *code = instr->common.code;
-
-# define CHECK_V4_INSTR_CODE(I, FMT) \
- if (decodeInstr[static_cast<int>(V4Instr::I)] == code) \
- return V4Instr::I;
-
- FOR_EACH_V4_INSTR(CHECK_V4_INSTR_CODE)
- Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid instruction address");
- return static_cast<V4Instr::Type>(0);
-# undef CHECK_V4_INSTR_CODE
-#else
- return static_cast<V4Instr::Type>(instr->common.type);
-#endif
-
-}
-
-void Bytecode::append(V4Instr::Type type, V4Instr &instr)
-{
-#ifdef QML_THREADED_INTERPRETER
- instr.common.code = decodeInstr[static_cast<int>(type)];
-#else
- instr.common.type = type;
-#endif
- d.append(reinterpret_cast<const char *>(&instr), V4Instr::size(type));
-}
-
-int Bytecode::remove(int offset)
-{
- const V4Instr *instr = reinterpret_cast<const V4Instr *>(d.begin() + offset);
- const int instrSize = V4Instr::size(instructionType(instr));
- d.remove(offset, instrSize);
- return instrSize;
-}
-
-const V4Instr &Bytecode::operator[](int offset) const
-{
- return *(reinterpret_cast<const V4Instr *>(d.begin() + offset));
-}
-
-V4Instr &Bytecode::operator[](int offset)
-{
- return *(reinterpret_cast<V4Instr *>(d.begin() + offset));
-}
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v4/qv4instruction_p.h b/src/declarative/qml/v4/qv4instruction_p.h
deleted file mode 100644
index d243d3fb9d..0000000000
--- a/src/declarative/qml/v4/qv4instruction_p.h
+++ /dev/null
@@ -1,435 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4INSTRUCTION_P_H
-#define QV4INSTRUCTION_P_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/qbytearray.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qvarlengtharray.h>
-
-#include <private/qdeclarativepropertycache_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-#define FOR_EACH_V4_INSTR(F) \
- F(Noop, common) \
- F(BindingId, id) \
- F(Subscribe, subscribeop) \
- F(SubscribeId, subscribeop) \
- F(FetchAndSubscribe, fetchAndSubscribe) \
- F(LoadId, load) \
- F(LoadScope, load) \
- F(LoadRoot, load) \
- F(LoadAttached, attached) \
- F(UnaryNot, unaryop) \
- F(UnaryMinusReal, unaryop) \
- F(UnaryMinusInt, unaryop) \
- F(UnaryPlusReal, unaryop) \
- F(UnaryPlusInt, unaryop) \
- F(ConvertBoolToInt, unaryop) \
- F(ConvertBoolToReal, unaryop) \
- F(ConvertBoolToString, unaryop) \
- F(ConvertIntToBool, unaryop) \
- F(ConvertIntToReal, unaryop) \
- F(ConvertIntToString, unaryop) \
- F(ConvertRealToBool, unaryop) \
- F(ConvertRealToInt, unaryop) \
- F(ConvertRealToString, unaryop) \
- F(ConvertStringToBool, unaryop) \
- F(ConvertStringToInt, unaryop) \
- F(ConvertStringToReal, unaryop) \
- F(ConvertStringToUrl, unaryop) \
- F(ConvertStringToColor, unaryop) \
- F(ConvertUrlToBool, unaryop) \
- F(ConvertUrlToString, unaryop) \
- F(ConvertColorToBool, unaryop) \
- F(ConvertColorToString, unaryop) \
- F(ResolveUrl, unaryop) \
- F(MathSinReal, unaryop) \
- F(MathCosReal, unaryop) \
- F(MathRoundReal, unaryop) \
- F(MathFloorReal, unaryop) \
- F(MathPIReal, unaryop) \
- F(LoadReal, real_value) \
- F(LoadInt, int_value) \
- F(LoadBool, bool_value) \
- F(LoadString, string_value) \
- F(EnableV4Test, string_value) \
- F(TestV4Store, storetest) \
- F(BitAndInt, binaryop) \
- F(BitOrInt, binaryop) \
- F(BitXorInt, binaryop) \
- F(AddReal, binaryop) \
- F(AddString, binaryop) \
- F(SubReal, binaryop) \
- F(MulReal, binaryop) \
- F(DivReal, binaryop) \
- F(ModReal, binaryop) \
- F(LShiftInt, binaryop) \
- F(RShiftInt, binaryop) \
- F(URShiftInt, binaryop) \
- F(GtReal, binaryop) \
- F(LtReal, binaryop) \
- F(GeReal, binaryop) \
- F(LeReal, binaryop) \
- F(EqualReal, binaryop) \
- F(NotEqualReal, binaryop) \
- F(StrictEqualReal, binaryop) \
- F(StrictNotEqualReal, binaryop) \
- F(GtString, binaryop) \
- F(LtString, binaryop) \
- F(GeString, binaryop) \
- F(LeString, binaryop) \
- F(EqualString, binaryop) \
- F(NotEqualString, binaryop) \
- F(StrictEqualString, binaryop) \
- F(StrictNotEqualString, binaryop) \
- F(NewString, construct) \
- F(NewUrl, construct) \
- F(CleanupRegister, cleanup) \
- F(Copy, copy) \
- F(Fetch, fetch) \
- F(Store, store) \
- F(Jump, jump) \
- F(BranchTrue, branchop) \
- F(BranchFalse, branchop) \
- F(Branch, branchop) \
- F(Block, blockop) \
- /* Speculative property resolution */ \
- F(InitString, initstring)
-
-#if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
-# define QML_THREADED_INTERPRETER
-#endif
-
-#ifdef Q_ALIGNOF
-# define QML_V4_INSTR_ALIGN_MASK (Q_ALIGNOF(V4Instr) - 1)
-#else
-# define QML_V4_INSTR_ALIGN_MASK (sizeof(void *) - 1)
-#endif
-
-#define QML_V4_INSTR_ENUM(I, FMT) I,
-#define QML_V4_INSTR_ADDR(I, FMT) &&op_##I,
-#define QML_V4_INSTR_SIZE(I, FMT) ((sizeof(V4Instr::instr_##FMT) + QML_V4_INSTR_ALIGN_MASK) & ~QML_V4_INSTR_ALIGN_MASK)
-
-#ifdef QML_THREADED_INTERPRETER
-# define QML_V4_BEGIN_INSTR(I,FMT) op_##I:
-# define QML_V4_END_INSTR(I,FMT) code += QML_V4_INSTR_SIZE(I, FMT); instr = (const V4Instr *) code; goto *instr->common.code;
-# define QML_V4_INSTR_HEADER void *code;
-#else
-# define QML_V4_BEGIN_INSTR(I,FMT) case V4Instr::I:
-# define QML_V4_END_INSTR(I,FMT) code += QML_V4_INSTR_SIZE(I, FMT); instr = (const V4Instr *) code; break;
-# define QML_V4_INSTR_HEADER quint8 type;
-#endif
-
-class QObject;
-class QDeclarativeNotifier;
-
-namespace QDeclarativeJS {
-
-union V4Instr {
- enum Type {
- FOR_EACH_V4_INSTR(QML_V4_INSTR_ENUM)
- };
-
- static int size(Type type);
-
- struct instr_common {
- QML_V4_INSTR_HEADER
- };
-
- struct instr_id {
- QML_V4_INSTR_HEADER
- quint16 column;
- quint32 line;
- };
-
- struct instr_init {
- QML_V4_INSTR_HEADER
- quint16 subscriptions;
- quint16 identifiers;
- };
-
- struct instr_subscribeop {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint16 offset;
- quint32 index;
- };
-
- struct instr_load {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint32 index;
- };
-
- struct instr_attached {
- QML_V4_INSTR_HEADER
- qint8 output;
- qint8 reg;
- quint8 exceptionId;
- quint32 id;
- };
-
- struct instr_store {
- QML_V4_INSTR_HEADER
- qint8 output;
- qint8 reg;
- quint8 exceptionId;
- quint32 index;
- };
-
- struct instr_storetest {
- QML_V4_INSTR_HEADER
- qint8 reg;
- qint32 regType;
- };
-
- struct instr_fetchAndSubscribe {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint8 exceptionId;
- quint8 valueType;
- quint16 subscription;
- QDeclarativePropertyRawData property;
- };
-
- struct instr_fetch{
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint8 exceptionId;
- quint8 valueType;
- quint32 index;
- };
-
- struct instr_copy {
- QML_V4_INSTR_HEADER
- qint8 reg;
- qint8 src;
- };
-
- struct instr_construct {
- QML_V4_INSTR_HEADER
- qint8 reg;
- };
-
- struct instr_real_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- qreal value; // XXX Makes the instruction 12 bytes
- };
-
- struct instr_int_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- int value;
- };
-
- struct instr_bool_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- bool value;
- };
-
- struct instr_string_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint16 length;
- quint32 offset;
- };
-
- struct instr_binaryop {
- QML_V4_INSTR_HEADER
- qint8 output;
- qint8 left;
- qint8 right;
- };
-
- struct instr_unaryop {
- QML_V4_INSTR_HEADER
- qint8 output;
- qint8 src;
- };
-
- struct instr_jump {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint32 count;
- };
-
- struct instr_find {
- QML_V4_INSTR_HEADER
- qint8 reg;
- qint8 src;
- quint8 exceptionId;
- quint16 name;
- quint16 subscribeIndex;
- };
-
- struct instr_cleanup {
- QML_V4_INSTR_HEADER
- qint8 reg;
- };
-
- struct instr_initstring {
- QML_V4_INSTR_HEADER
- quint16 offset;
- quint32 dataIdx;
- };
-
- struct instr_branchop {
- QML_V4_INSTR_HEADER
- quint8 reg;
- qint16 offset;
- };
-
- struct instr_blockop {
- QML_V4_INSTR_HEADER
- quint32 block;
- };
-
- instr_common common;
- instr_id id;
- instr_init init;
- instr_subscribeop subscribeop;
- instr_load load;
- instr_attached attached;
- instr_store store;
- instr_storetest storetest;
- instr_fetchAndSubscribe fetchAndSubscribe;
- instr_fetch fetch;
- instr_copy copy;
- instr_construct construct;
- instr_real_value real_value;
- instr_int_value int_value;
- instr_bool_value bool_value;
- instr_string_value string_value;
- instr_binaryop binaryop;
- instr_unaryop unaryop;
- instr_jump jump;
- instr_find find;
- instr_cleanup cleanup;
- instr_initstring initstring;
- instr_branchop branchop;
- instr_blockop blockop;
-};
-
-template<int N>
-struct V4InstrMeta {
-};
-
-#define QML_V4_INSTR_META_TEMPLATE(I, FMT) \
- template<> struct V4InstrMeta<(int)V4Instr::I> { \
- enum { Size = QML_V4_INSTR_SIZE(I, FMT) }; \
- typedef V4Instr::instr_##FMT DataType; \
- static const DataType &data(const V4Instr &instr) { return instr.FMT; } \
- static void setData(V4Instr &instr, const DataType &v) { instr.FMT = v; } \
- };
-FOR_EACH_V4_INSTR(QML_V4_INSTR_META_TEMPLATE);
-#undef QML_V4_INSTR_META_TEMPLATE
-
-template<int Instr>
-class V4InstrData : public V4InstrMeta<Instr>::DataType
-{
-};
-
-class Bytecode
-{
- Q_DISABLE_COPY(Bytecode)
-
-public:
- Bytecode();
-
- const char *constData() const { return d.constData(); }
- int size() const { return d.size(); }
- int count() const { return d.count(); }
- void clear() { d.clear(); }
- bool isEmpty() const { return d.isEmpty(); }
- V4Instr::Type instructionType(const V4Instr *instr) const;
-
- template <int Instr>
- void append(const V4InstrData<Instr> &data)
- {
- V4Instr genericInstr;
- V4InstrMeta<Instr>::setData(genericInstr, data);
- return append(static_cast<V4Instr::Type>(Instr), genericInstr);
- }
- void append(V4Instr::Type type, V4Instr &instr);
-
- int remove(int index);
-
- const V4Instr &operator[](int offset) const;
- V4Instr &operator[](int offset);
-
- void dump(const char *start, const char *end) const;
-
-private:
- void dump(const V4Instr *instr, int = -1) const;
-
- QVarLengthArray<char, 4 * 1024> d;
-#ifdef QML_THREADED_INTERPRETER
- void **decodeInstr;
-#endif
-};
-
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV4INSTRUCTION_P_H
-
diff --git a/src/declarative/qml/v4/qv4ir.cpp b/src/declarative/qml/v4/qv4ir.cpp
deleted file mode 100644
index 6a30e93227..0000000000
--- a/src/declarative/qml/v4/qv4ir.cpp
+++ /dev/null
@@ -1,883 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4ir_p.h"
-
-#include <QtCore/qtextstream.h>
-#include <QtCore/qdebug.h>
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-namespace IR {
-
-inline const char *typeName(Type t)
-{
- switch (t) {
- case InvalidType: return "invalid";
- case UndefinedType: return "undefined";
- case NullType: return "null";
- case VoidType: return "void";
- case StringType: return "string";
- case UrlType: return "url";
- case ColorType: return "color";
- case SGAnchorLineType: return "SGAnchorLine";
- case AttachType: return "AttachType";
- case ObjectType: return "object";
- case BoolType: return "bool";
- case IntType: return "int";
- case RealType: return "qreal";
- case RealNaNType: return "NaN";
- default: return "invalid";
- }
-}
-
-inline bool isNumberType(IR::Type ty)
-{
- return ty >= IR::FirstNumberType;
-}
-
-inline bool isStringType(IR::Type ty)
-{
- return ty == IR::StringType || ty == IR::UrlType || ty == IR::ColorType;
-}
-
-IR::Type maxType(IR::Type left, IR::Type right)
-{
- if (isStringType(left) && isStringType(right)) {
- // String promotions (url to string) are more specific than
- // identity conversions (AKA left == right). That's because
- // we want to ensure we convert urls to strings in binary
- // expressions.
- return IR::StringType;
- } else if (left == right)
- return left;
- else if (isNumberType(left) && isNumberType(right))
- return qMax(left, right);
- else if ((isNumberType(left) && isStringType(right)) ||
- (isNumberType(right) && isStringType(left)))
- return IR::StringType;
- else
- return IR::InvalidType;
-}
-
-
-const char *opname(AluOp op)
-{
- switch (op) {
- case OpInvalid: return "?";
-
- case OpIfTrue: return "(bool)";
- case OpNot: return "!";
- case OpUMinus: return "-";
- case OpUPlus: return "+";
- case OpCompl: return "~";
-
- case OpBitAnd: return "&";
- case OpBitOr: return "|";
- case OpBitXor: return "^";
-
- case OpAdd: return "+";
- case OpSub: return "-";
- case OpMul: return "*";
- case OpDiv: return "/";
- case OpMod: return "%";
-
- case OpLShift: return "<<";
- case OpRShift: return ">>";
- case OpURShift: return ">>>";
-
- case OpGt: return ">";
- case OpLt: return "<";
- case OpGe: return ">=";
- case OpLe: return "<=";
- case OpEqual: return "==";
- case OpNotEqual: return "!=";
- case OpStrictEqual: return "===";
- case OpStrictNotEqual: return "!==";
-
- case OpAnd: return "&&";
- case OpOr: return "||";
-
- default: return "?";
-
- } // switch
-}
-
-AluOp binaryOperator(int op)
-{
- switch (static_cast<QSOperator::Op>(op)) {
- case QSOperator::Add: return OpAdd;
- case QSOperator::And: return OpAnd;
- case QSOperator::BitAnd: return OpBitAnd;
- case QSOperator::BitOr: return OpBitOr;
- case QSOperator::BitXor: return OpBitXor;
- case QSOperator::Div: return OpDiv;
- case QSOperator::Equal: return OpEqual;
- case QSOperator::Ge: return OpGe;
- case QSOperator::Gt: return OpGt;
- case QSOperator::Le: return OpLe;
- case QSOperator::LShift: return OpLShift;
- case QSOperator::Lt: return OpLt;
- case QSOperator::Mod: return OpMod;
- case QSOperator::Mul: return OpMul;
- case QSOperator::NotEqual: return OpNotEqual;
- case QSOperator::Or: return OpOr;
- case QSOperator::RShift: return OpRShift;
- case QSOperator::StrictEqual: return OpStrictEqual;
- case QSOperator::StrictNotEqual: return OpStrictNotEqual;
- case QSOperator::Sub: return OpSub;
- case QSOperator::URShift: return OpURShift;
- default: return OpInvalid;
- }
-}
-
-void Const::dump(QTextStream &out)
-{
- out << value;
-}
-
-void String::dump(QTextStream &out)
-{
- out << '"' << escape(value) << '"';
-}
-
-QString String::escape(const QStringRef &s)
-{
- QString r;
- for (int i = 0; i < s.length(); ++i) {
- const QChar ch = s.at(i);
- if (ch == QLatin1Char('\n'))
- r += QLatin1String("\\n");
- else if (ch == QLatin1Char('\r'))
- r += QLatin1String("\\r");
- else if (ch == QLatin1Char('\\'))
- r += QLatin1String("\\\\");
- else if (ch == QLatin1Char('"'))
- r += QLatin1String("\\\"");
- else if (ch == QLatin1Char('\''))
- r += QLatin1String("\\'");
- else
- r += ch;
- }
- return r;
-}
-
-void Name::init(Name *base, Type type, const QString *id, Symbol symbol, quint32 line, quint32 column)
-{
- this->type = type;
- this->base = base;
- this->id = id;
- this->symbol = symbol;
- this->ptr = 0;
- this->property = 0;
- this->storage = MemberStorage;
- this->builtin = NoBuiltinSymbol;
- this->line = line;
- this->column = column;
-
- if (id->length() == 8 && *id == QLatin1String("Math.sin")) {
- builtin = MathSinBultinFunction;
- } else if (id->length() == 8 && *id == QLatin1String("Math.cos")) {
- builtin = MathCosBultinFunction;
- } else if (id->length() == 10 && *id == QLatin1String("Math.round")) {
- builtin = MathRoundBultinFunction;
- } else if (id->length() == 10 && *id == QLatin1String("Math.floor)")) {
- builtin = MathFloorBultinFunction;
- } else if (id->length() == 7 && *id == QLatin1String("Math.PI")) {
- builtin = MathPIBuiltinConstant;
- this->type = RealType;
- }
-}
-
-void Name::dump(QTextStream &out)
-{
- if (base) {
- base->dump(out);
- out << '.';
- }
-
- out << *id;
-}
-
-void Temp::dump(QTextStream &out)
-{
- out << 't' << index;
-}
-
-void Unop::dump(QTextStream &out)
-{
- out << opname(op);
- expr->dump(out);
-}
-
-Type Unop::typeForOp(AluOp op, Expr *expr)
-{
- switch (op) {
- case OpIfTrue: return BoolType;
- case OpNot: return BoolType;
-
- case OpUMinus:
- case OpUPlus:
- case OpCompl:
- return maxType(expr->type, RealType);
-
- default:
- break;
- }
-
- return InvalidType;
-}
-
-void Binop::dump(QTextStream &out)
-{
- left->dump(out);
- out << ' ' << opname(op) << ' ';
- right->dump(out);
-}
-
-Type Binop::typeForOp(AluOp op, Expr *left, Expr *right)
-{
- if (! (left && right))
- return InvalidType;
-
- switch (op) {
- case OpInvalid:
- return InvalidType;
-
- // unary operators
- case OpIfTrue:
- case OpNot:
- case OpUMinus:
- case OpUPlus:
- case OpCompl:
- return InvalidType;
-
- // bit fields
- case OpBitAnd:
- case OpBitOr:
- case OpBitXor:
- return IntType;
-
- case OpAdd:
- if (left->type == StringType)
- return StringType;
- return RealType;
-
- case OpSub:
- case OpMul:
- case OpDiv:
- case OpMod:
- return RealType;
-
- case OpLShift:
- case OpRShift:
- case OpURShift:
- return IntType;
-
- case OpAnd:
- case OpOr:
- return BoolType;
-
- case OpGt:
- case OpLt:
- case OpGe:
- case OpLe:
- case OpEqual:
- case OpNotEqual:
- case OpStrictEqual:
- case OpStrictNotEqual:
- return BoolType;
- } // switch
-
- return InvalidType;
-}
-
-void Call::dump(QTextStream &out)
-{
- base->dump(out);
- out << '(';
- for (ExprList *it = args; it; it = it->next) {
- if (it != args)
- out << ", ";
- it->expr->dump(out);
- }
- out << ')';
-}
-
-Type Call::typeForFunction(Expr *base)
-{
- if (! base)
- return InvalidType;
-
- if (Name *name = base->asName()) {
- switch (name->builtin) {
- case MathSinBultinFunction:
- case MathCosBultinFunction:
- return RealType;
-
- case MathRoundBultinFunction:
- case MathFloorBultinFunction:
- return IntType;
-
- case NoBuiltinSymbol:
- case MathPIBuiltinConstant:
- break;
- }
- } // switch
-
- return InvalidType;
-}
-
-void Exp::dump(QTextStream &out, Mode)
-{
- out << "(void) ";
- expr->dump(out);
- out << ';';
-}
-
-void Move::dump(QTextStream &out, Mode)
-{
- target->dump(out);
- out << " = ";
- if (source->type != target->type)
- out << typeName(source->type) << "_to_" << typeName(target->type) << '(';
- source->dump(out);
- if (source->type != target->type)
- out << ')';
- out << ';';
-}
-
-void Jump::dump(QTextStream &out, Mode mode)
-{
- Q_UNUSED(mode);
- out << "goto " << 'L' << target << ';';
-}
-
-void CJump::dump(QTextStream &out, Mode mode)
-{
- Q_UNUSED(mode);
- out << "if (";
- cond->dump(out);
- out << ") goto " << 'L' << iftrue << "; else goto " << 'L' << iffalse << ';';
-}
-
-void Ret::dump(QTextStream &out, Mode)
-{
- out << "return";
- if (expr) {
- out << ' ';
- expr->dump(out);
- }
- out << ';';
-}
-
-Function::~Function()
-{
- qDeleteAll(basicBlocks);
-}
-
-QString *Function::newString(const QString &text)
-{
- return pool->NewString(text);
-}
-
-BasicBlock *Function::newBasicBlock()
-{
- const int index = basicBlocks.size();
- return i(new BasicBlock(this, index));
-}
-
-void Function::dump(QTextStream &out)
-{
- out << "function () {" << endl;
- foreach (BasicBlock *bb, basicBlocks) {
- bb->dump(out);
- }
- out << '}' << endl;
-}
-
-Temp *BasicBlock::TEMP(Type type, int index)
-{
- Temp *e = function->pool->New<Temp>();
- e->init(type, index);
- return e;
-}
-
-Temp *BasicBlock::TEMP(Type type)
-{
- return TEMP(type, function->tempCount++);
-}
-
-Expr *BasicBlock::CONST(double value)
-{
- return CONST(IR::RealType, value);
-}
-
-Expr *BasicBlock::CONST(Type type, double value)
-{
- Const *e = function->pool->New<Const>();
- e->init(type, value);
- return e;
-}
-
-Expr *BasicBlock::STRING(const QStringRef &value)
-{
- String *e = function->pool->New<String>();
- e->init(value);
- return e;
-}
-
-Name *BasicBlock::NAME(const QString &id, quint32 line, quint32 column)
-{
- return NAME(0, id, line, column);
-}
-
-Name *BasicBlock::NAME(Name *base, const QString &id, quint32 line, quint32 column)
-{
- Name *e = function->pool->New<Name>();
- e->init(base, InvalidType,
- function->newString(id),
- Name::Unbound, line, column);
- return e;
-}
-
-Name *BasicBlock::SYMBOL(Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, Name::Storage storage,
- quint32 line, quint32 column)
-{
- Name *name = SYMBOL(/*base = */ 0, type, id, meta, property, line, column);
- name->storage = storage;
- return name;
-}
-
-Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, Name::Storage storage,
- quint32 line, quint32 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(base, type, function->newString(id),
- Name::Property, line, column);
- name->meta = meta;
- name->property = property;
- name->storage = storage;
- return name;
-}
-
-Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property,
- quint32 line, quint32 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(base, type, function->newString(id),
- Name::Property, line, column);
- name->meta = meta;
- name->property = property;
- return name;
-}
-
-Name *BasicBlock::ID_OBJECT(const QString &id, const QDeclarativeScript::Object *object, quint32 line, quint32 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(/*base = */ 0, IR::ObjectType,
- function->newString(id),
- Name::IdObject, line, column);
- name->idObject = object;
- name->property = 0;
- name->storage = Name::IdStorage;
- return name;
-}
-
-Name *BasicBlock::ATTACH_TYPE(const QString &id, const QDeclarativeType *attachType, Name::Storage storage,
- quint32 line, quint32 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(/*base = */ 0, IR::AttachType,
- function->newString(id),
- Name::AttachType, line, column);
- name->declarativeType = attachType;
- name->storage = storage;
- return name;
-}
-
-
-Expr *BasicBlock::UNOP(AluOp op, Expr *expr)
-{
- Unop *e = function->pool->New<Unop>();
- e->init(op, expr);
- return e;
-}
-
-Expr *BasicBlock::BINOP(AluOp op, Expr *left, Expr *right)
-{
- if (left && right) {
- if (Const *c1 = left->asConst()) {
- if (Const *c2 = right->asConst()) {
- switch (op) {
- case OpAdd: return CONST(c1->value + c2->value);
- case OpAnd: return CONST(c1->value ? c2->value : 0);
- case OpBitAnd: return CONST(int(c1->value) & int(c2->value));
- case OpBitOr: return CONST(int(c1->value) | int(c2->value));
- case OpBitXor: return CONST(int(c1->value) ^ int(c2->value));
- case OpDiv: return CONST(c1->value / c2->value);
- case OpEqual: return CONST(c1->value == c2->value);
- case OpGe: return CONST(c1->value >= c2->value);
- case OpGt: return CONST(c1->value > c2->value);
- case OpLe: return CONST(c1->value <= c2->value);
- case OpLShift: return CONST(int(c1->value) << int(c2->value));
- case OpLt: return CONST(c1->value < c2->value);
- case OpMod: return CONST(::fmod(c1->value, c2->value));
- case OpMul: return CONST(c1->value * c2->value);
- case OpNotEqual: return CONST(c1->value != c2->value);
- case OpOr: return CONST(c1->value ? c1->value : c2->value);
- case OpRShift: return CONST(int(c1->value) >> int(c2->value));
- case OpStrictEqual: return CONST(c1->value == c2->value);
- case OpStrictNotEqual: return CONST(c1->value != c2->value);
- case OpSub: return CONST(c1->value - c2->value);
- case OpURShift: return CONST(unsigned(c1->value) >> int(c2->value));
-
- case OpIfTrue: // unary ops
- case OpNot:
- case OpUMinus:
- case OpUPlus:
- case OpCompl:
- case OpInvalid:
- break;
- }
- }
- }
- }
-
- Binop *e = function->pool->New<Binop>();
- e->init(op, left, right);
- return e;
-}
-
-Expr *BasicBlock::CALL(Expr *base, ExprList *args)
-{
- Call *e = function->pool->New<Call>();
- e->init(base, args);
- return e;
-}
-
-Stmt *BasicBlock::EXP(Expr *expr)
-{
- Exp *s = function->pool->New<Exp>();
- s->init(expr);
- statements.append(s);
- return s;
-}
-
-Stmt *BasicBlock::MOVE(Expr *target, Expr *source, bool isMoveForReturn)
-{
- Move *s = function->pool->New<Move>();
- s->init(target, source, isMoveForReturn);
- statements.append(s);
- return s;
-}
-
-Stmt *BasicBlock::JUMP(BasicBlock *target)
-{
- if (isTerminated())
- return 0;
-
- Jump *s = function->pool->New<Jump>();
- s->init(target);
- statements.append(s);
- return s;
-}
-
-Stmt *BasicBlock::CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
-{
- if (isTerminated())
- return 0;
-
- CJump *s = function->pool->New<CJump>();
- s->init(cond, iftrue, iffalse);
- statements.append(s);
- return s;
-}
-
-Stmt *BasicBlock::RET(Expr *expr, Type type, quint32 line, quint32 column)
-{
- if (isTerminated())
- return 0;
-
- Ret *s = function->pool->New<Ret>();
- s->init(expr, type, line, column);
- statements.append(s);
- return s;
-}
-
-void BasicBlock::dump(QTextStream &out)
-{
- out << 'L' << this << ':' << endl;
- foreach (Stmt *s, statements) {
- out << '\t';
- s->dump(out);
- out << endl;
- }
-}
-
-#ifdef DEBUG_IR_STRUCTURE
-
-static const char *symbolname(Name::Symbol s)
-{
- switch (s) {
- case Name::Unbound:
- return "Unbound";
- case Name::IdObject:
- return "IdObject";
- case Name::AttachType:
- return "AttachType";
- case Name::Object:
- return "Object";
- case Name::Property:
- return "Property";
- case Name::Slot:
- return "Slot";
- default:
- Q_ASSERT(!"Unreachable");
- return "Unknown";
- }
-}
-
-static const char *storagename(Name::Storage s)
-{
- switch (s) {
- case Name::MemberStorage:
- return "MemberStorage";
- case Name::IdStorage:
- return "IdStorage";
- case Name::RootStorage:
- return "RootStorage";
- case Name::ScopeStorage:
- return "ScopeStorage";
- default:
- Q_ASSERT(!"Unreachable");
- return "UnknownStorage";
- }
-}
-
-IRDump::IRDump()
-: indentSize(0)
-{
-}
-
-void IRDump::inc()
-{
- indentSize++;
- indentData = QByteArray(indentSize * 4, ' ');
-}
-
-void IRDump::dec()
-{
- indentSize--;
- indentData = QByteArray(indentSize * 4, ' ');
-}
-
-void IRDump::dec();
-
-void IRDump::expression(QDeclarativeJS::IR::Expr *e)
-{
- inc();
-
- e->accept(this);
-
- dec();
-}
-
-void IRDump::basicblock(QDeclarativeJS::IR::BasicBlock *b)
-{
- inc();
-
- qWarning().nospace() << indent() << "BasicBlock " << b << " {";
- for (int ii = 0; ii < b->statements.count(); ++ii) {
- statement(b->statements.at(ii));
- if (ii != (b->statements.count() - 1))
- qWarning();
- }
- qWarning().nospace() << indent() << "}";
-
- dec();
-}
-
-void IRDump::statement(QDeclarativeJS::IR::Stmt *s)
-{
- inc();
-
- s->accept(this);
-
- dec();
-}
-
-void IRDump::function(QDeclarativeJS::IR::Function *f)
-{
- inc();
-
- qWarning().nospace() << indent() << "Function {";
- for (int ii = 0; ii < f->basicBlocks.count(); ++ii) {
- basicblock(f->basicBlocks.at(ii));
- }
- qWarning().nospace() << indent() << "}";
-
- dec();
-}
-
-const char *IRDump::indent()
-{
- return indentData.constData();
-}
-
-void IRDump::visitConst(QDeclarativeJS::IR::Const *e)
-{
- qWarning().nospace() << indent() << "Const:Expr { type: " << typeName(e->type) << ", value: " << e->value << "}";
-}
-
-void IRDump::visitString(QDeclarativeJS::IR::String *e)
-{
- qWarning().nospace() << indent() << "String:Expr { type: " << typeName(e->type) << ", value: " << e->value << "}";
-}
-
-static void namedumprecur(QDeclarativeJS::IR::Name *e, const char *indent)
-{
- if (e->base) namedumprecur(e->base, indent);
- qWarning().nospace() << indent << " { type: " << typeName(e->type) << ", symbol: " << symbolname(e->symbol) << ", storage: " << storagename(e->storage) << ", id: " << e->id << "}";
-}
-
-void IRDump::visitName(QDeclarativeJS::IR::Name *e)
-{
- qWarning().nospace() << indent() << "Name:Expr {";
- namedumprecur(e, indent());
- qWarning().nospace() << indent() << "}";
-}
-
-void IRDump::visitTemp(QDeclarativeJS::IR::Temp *e)
-{
- qWarning().nospace() << indent() << "Temp:Expr { type: " << typeName(e->type) << ", index: " << e->index << " }";
-}
-
-void IRDump::visitUnop(QDeclarativeJS::IR::Unop *e)
-{
- qWarning().nospace() << indent() << "Unop:Expr { ";
- qWarning().nospace() << indent() << " type: " << typeName(e->type) << ", op: " << opname(e->op);
- qWarning().nospace() << indent() << " expr: {";
- expression(e->expr);
- qWarning().nospace() << indent() << " }";
- qWarning().nospace() << indent() << "}";
-}
-
-void IRDump::visitBinop(QDeclarativeJS::IR::Binop *e)
-{
- qWarning().nospace() << indent() << "Binop:Expr { ";
- qWarning().nospace() << indent() << " type: " << typeName(e->type) << ", op: " << opname(e->op);
- qWarning().nospace() << indent() << " left: {";
- inc();
- expression(e->left);
- dec();
- qWarning().nospace() << indent() << " },";
- qWarning().nospace() << indent() << " right: {";
- inc();
- expression(e->right);
- dec();
- qWarning().nospace() << indent() << " }";
- qWarning().nospace() << indent() << "}";
-}
-
-void IRDump::visitCall(QDeclarativeJS::IR::Call *e)
-{
- Q_UNUSED(e);
- qWarning().nospace() << indent() << "Exp::Call { }";
-}
-
-void IRDump::visitExp(QDeclarativeJS::IR::Exp *s)
-{
- qWarning().nospace() << indent() << "Exp:Stmt {";
- expression(s->expr);
- qWarning().nospace() << indent() << "}";
-}
-
-void IRDump::visitMove(QDeclarativeJS::IR::Move *s)
-{
- qWarning().nospace() << indent() << "Move:Stmt {";
- qWarning().nospace() << indent() << " isMoveForReturn: " << s->isMoveForReturn;
- qWarning().nospace() << indent() << " target: {";
- inc();
- expression(s->target);
- dec();
- qWarning().nospace() << indent() << " },";
- qWarning().nospace() << indent() << " source: {";
- inc();
- expression(s->source);
- dec();
- qWarning().nospace() << indent() << " }";
- qWarning().nospace() << indent() << "}";
-}
-
-void IRDump::visitJump(QDeclarativeJS::IR::Jump *s)
-{
- qWarning().nospace() << indent() << "Jump:Stmt { BasicBlock(" << s->target << ") }";
-}
-
-void IRDump::visitCJump(QDeclarativeJS::IR::CJump *s)
-{
- qWarning().nospace() << indent() << "CJump:Stmt {";
- qWarning().nospace() << indent() << " cond: {";
- inc();
- expression(s->cond);
- dec();
- qWarning().nospace() << indent() << " }";
- qWarning().nospace() << indent() << " iftrue: BasicBlock(" << s->iftrue << ")";
- qWarning().nospace() << indent() << " iffalse: BasicBlock(" << s->iffalse << ")";
- qWarning().nospace() << indent() << "}";
-}
-
-void IRDump::visitRet(QDeclarativeJS::IR::Ret *s)
-{
- qWarning().nospace() << indent() << "Ret:Stmt {";
- qWarning().nospace() << indent() << " type: " << typeName(s->type);
- expression(s->expr);
- qWarning().nospace() << indent() << "}";
-}
-#endif
-
-} // end of namespace IR
-} // end of namespace QDeclarativeJS
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v4/qv4ir_p.h b/src/declarative/qml/v4/qv4ir_p.h
deleted file mode 100644
index f6aae06f44..0000000000
--- a/src/declarative/qml/v4/qv4ir_p.h
+++ /dev/null
@@ -1,605 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4IR_P_H
-#define QV4IR_P_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 <private/qdeclarativejsast_p.h>
-#include <private/qdeclarativejsengine_p.h>
-#include <private/qdeclarativescript_p.h>
-#include <private/qdeclarativeimport_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qv4compiler_p.h>
-
-#include <private/qdeclarativepool_p.h>
-#include <QtCore/qvarlengtharray.h>
-
-// #define DEBUG_IR_STRUCTURE
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QTextStream;
-class QDeclarativeType;
-
-namespace QDeclarativeJS {
-
-namespace IR {
-
-struct BasicBlock;
-struct Function;
-
-struct Stmt;
-struct Expr;
-
-// expressions
-struct Const;
-struct String;
-struct Name;
-struct Temp;
-struct Unop;
-struct Binop;
-struct Call;
-
-// statements
-struct Exp;
-struct Move;
-struct Jump;
-struct CJump;
-struct Ret;
-
-enum AluOp {
- OpInvalid = 0,
-
- OpIfTrue,
- OpNot,
- OpUMinus,
- OpUPlus,
- OpCompl,
-
- OpBitAnd,
- OpBitOr,
- OpBitXor,
-
- OpAdd,
- OpSub,
- OpMul,
- OpDiv,
- OpMod,
-
- OpLShift,
- OpRShift,
- OpURShift,
-
- OpGt,
- OpLt,
- OpGe,
- OpLe,
- OpEqual,
- OpNotEqual,
- OpStrictEqual,
- OpStrictNotEqual,
-
- OpAnd,
- OpOr
-};
-AluOp binaryOperator(int op);
-
-enum Type {
- InvalidType,
- UndefinedType,
- NullType,
- VoidType,
- StringType,
- UrlType,
- ColorType,
- SGAnchorLineType,
- AttachType,
- ObjectType,
-
- FirstNumberType,
- BoolType = FirstNumberType,
- IntType,
- RealType,
- RealNaNType
-};
-Type maxType(IR::Type left, IR::Type right);
-
-struct ExprVisitor {
- virtual ~ExprVisitor() {}
- virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitName(Name *) {}
- virtual void visitTemp(Temp *) {}
- virtual void visitUnop(Unop *) {}
- virtual void visitBinop(Binop *) {}
- virtual void visitCall(Call *) {}
-};
-
-struct StmtVisitor {
- virtual ~StmtVisitor() {}
- virtual void visitExp(Exp *) {}
- virtual void visitMove(Move *) {}
- virtual void visitJump(Jump *) {}
- virtual void visitCJump(CJump *) {}
- virtual void visitRet(Ret *) {}
-};
-
-struct Expr: QDeclarativePool::POD {
- Type type;
-
- Expr(): type(InvalidType) {}
- virtual ~Expr() {}
- virtual void accept(ExprVisitor *) = 0;
- virtual Const *asConst() { return 0; }
- virtual String *asString() { return 0; }
- virtual Name *asName() { return 0; }
- virtual Temp *asTemp() { return 0; }
- virtual Unop *asUnop() { return 0; }
- virtual Binop *asBinop() { return 0; }
- virtual Call *asCall() { return 0; }
- virtual void dump(QTextStream &out) = 0;
-};
-
-struct ExprList: QDeclarativePool::POD {
- Expr *expr;
- ExprList *next;
-
- void init(Expr *expr, ExprList *next = 0)
- {
- this->expr = expr;
- this->next = next;
- }
-};
-
-struct Const: Expr {
- double value;
-
- void init(Type type, double value)
- {
- this->type = type;
- this->value = value;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitConst(this); }
- virtual Const *asConst() { return this; }
-
- virtual void dump(QTextStream &out);
-};
-
-struct String: Expr {
- QStringRef value;
-
- void init(const QStringRef &value)
- {
- this->type = StringType;
- this->value = value;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitString(this); }
- virtual String *asString() { return this; }
-
- virtual void dump(QTextStream &out);
- static QString escape(const QStringRef &s);
-};
-
-enum BuiltinSymbol {
- NoBuiltinSymbol,
- MathSinBultinFunction,
- MathCosBultinFunction,
- MathRoundBultinFunction,
- MathFloorBultinFunction,
-
- MathPIBuiltinConstant
-};
-
-struct Name: Expr {
- enum Symbol {
- Unbound,
- IdObject, // This is a load of a id object. Storage will always be IdStorage
- AttachType, // This is a load of an attached object
- Object, // XXX what is this for?
- Property, // This is a load of a regular property
- Slot // XXX what is this for?
- };
-
- enum Storage {
- MemberStorage, // This is a property of a previously fetched object
- IdStorage, // This is a load of a id object. Symbol will always be IdObject
- RootStorage, // This is a property of the root object
- ScopeStorage // This is a property of the scope object
- };
-
- Name *base;
- const QString *id;
- Symbol symbol;
- union {
- void *ptr;
- const QMetaObject *meta;
- const QDeclarativeType *declarativeType;
- const QDeclarativeScript::Object *idObject;
- };
- QDeclarativePropertyData *property;
- Storage storage;
- BuiltinSymbol builtin;
- quint32 line;
- quint32 column;
-
- void init(Name *base, Type type, const QString *id, Symbol symbol, quint32 line, quint32 column);
-
- inline bool is(Symbol s) const { return s == symbol; }
- inline bool isNot(Symbol s) const { return s != symbol; }
-
- virtual void accept(ExprVisitor *v) { v->visitName(this); }
- virtual Name *asName() { return this; }
-
- virtual void dump(QTextStream &out);
-};
-
-struct Temp: Expr {
- int index;
-
- void init(Type type, int index)
- {
- this->type = type;
- this->index = index;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitTemp(this); }
- virtual Temp *asTemp() { return this; }
-
- virtual void dump(QTextStream &out);
-};
-
-struct Unop: Expr {
- AluOp op;
- Expr *expr;
-
- void init(AluOp op, Expr *expr)
- {
- this->type = this->typeForOp(op, expr);
- this->op = op;
- this->expr = expr;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitUnop(this); }
- virtual Unop *asUnop() { return this; }
-
- virtual void dump(QTextStream &out);
-
-private:
- static Type typeForOp(AluOp op, Expr *expr);
-};
-
-struct Binop: Expr {
- AluOp op;
- Expr *left;
- Expr *right;
-
- void init(AluOp op, Expr *left, Expr *right)
- {
- this->type = typeForOp(op, left, right);
- this->op = op;
- this->left = left;
- this->right = right;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitBinop(this); }
- virtual Binop *asBinop() { return this; }
-
- virtual void dump(QTextStream &out);
-
-private:
- static Type typeForOp(AluOp op, Expr *left, Expr *right);
-};
-
-struct Call: Expr {
- Expr *base;
- ExprList *args;
-
- void init(Expr *base, ExprList *args)
- {
- this->type = typeForFunction(base);
- this->base = base;
- this->args = args;
- }
-
- Expr *onlyArgument() const {
- if (args && ! args->next)
- return args->expr;
- return 0;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitCall(this); }
- virtual Call *asCall() { return this; }
-
- virtual void dump(QTextStream &out);
-
-private:
- static Type typeForFunction(Expr *base);
-};
-
-struct Stmt: QDeclarativePool::POD {
- enum Mode {
- HIR,
- MIR
- };
-
- virtual ~Stmt() {}
- virtual Stmt *asTerminator() { return 0; }
-
- virtual void accept(StmtVisitor *) = 0;
- virtual Exp *asExp() { return 0; }
- virtual Move *asMove() { return 0; }
- virtual Jump *asJump() { return 0; }
- virtual CJump *asCJump() { return 0; }
- virtual Ret *asRet() { return 0; }
- virtual void dump(QTextStream &out, Mode mode = HIR) = 0;
-};
-
-struct Exp: Stmt {
- Expr *expr;
-
- void init(Expr *expr)
- {
- this->expr = expr;
- }
-
- virtual void accept(StmtVisitor *v) { v->visitExp(this); }
- virtual Exp *asExp() { return this; }
-
- virtual void dump(QTextStream &out, Mode);
-};
-
-struct Move: Stmt {
- Expr *target;
- Expr *source;
- bool isMoveForReturn;
-
- void init(Expr *target, Expr *source, bool isMoveForReturn)
- {
- this->target = target;
- this->source = source;
- this->isMoveForReturn = isMoveForReturn;
- }
-
- virtual void accept(StmtVisitor *v) { v->visitMove(this); }
- virtual Move *asMove() { return this; }
-
- virtual void dump(QTextStream &out, Mode);
-};
-
-struct Jump: Stmt {
- BasicBlock *target;
-
- void init(BasicBlock *target)
- {
- this->target = target;
- }
-
- virtual Stmt *asTerminator() { return this; }
-
- virtual void accept(StmtVisitor *v) { v->visitJump(this); }
- virtual Jump *asJump() { return this; }
-
- virtual void dump(QTextStream &out, Mode mode);
-};
-
-struct CJump: Stmt {
- Expr *cond;
- BasicBlock *iftrue;
- BasicBlock *iffalse;
-
- void init(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
- {
- this->cond = cond;
- this->iftrue = iftrue;
- this->iffalse = iffalse;
- }
-
- virtual Stmt *asTerminator() { return this; }
-
- virtual void accept(StmtVisitor *v) { v->visitCJump(this); }
- virtual CJump *asCJump() { return this; }
-
- virtual void dump(QTextStream &out, Mode mode);
-};
-
-struct Ret: Stmt {
- Expr *expr;
- Type type;
- quint32 line;
- quint32 column;
-
- void init(Expr *expr, Type type, quint32 line, quint32 column)
- {
- this->expr = expr;
- this->type = type;
- this->line = line;
- this->column = column;
- }
-
- virtual Stmt *asTerminator() { return this; }
-
- virtual void accept(StmtVisitor *v) { v->visitRet(this); }
- virtual Ret *asRet() { return this; }
-
- virtual void dump(QTextStream &out, Mode);
-};
-
-struct Function {
- QDeclarativePool *pool;
- QVarLengthArray<BasicBlock *, 8> basicBlocks;
- int tempCount;
-
- Function(QDeclarativePool *pool)
- : pool(pool), tempCount(0) {}
-
- ~Function();
-
- BasicBlock *newBasicBlock();
- QString *newString(const QString &text);
-
- inline BasicBlock *i(BasicBlock *block) { basicBlocks.append(block); return block; }
-
- virtual void dump(QTextStream &out);
-};
-
-struct BasicBlock {
- Function *function;
- int index;
- int offset;
- QVarLengthArray<Stmt *, 32> statements;
-
- BasicBlock(Function *function, int index): function(function), index(index), offset(-1) {}
- ~BasicBlock() {}
-
- template <typename Instr> inline Instr i(Instr i) { statements.append(i); return i; }
-
- inline bool isEmpty() const {
- return statements.isEmpty();
- }
-
- inline Stmt *terminator() const {
- if (! statements.isEmpty() && statements.at(statements.size() - 1)->asTerminator() != 0)
- return statements.at(statements.size() - 1);
- return 0;
- }
-
- inline bool isTerminated() const {
- if (terminator() != 0)
- return true;
- return false;
- }
-
- Temp *TEMP(Type type, int index);
- Temp *TEMP(Type type);
-
- Expr *CONST(double value);
- Expr *CONST(Type type, double value);
- Expr *STRING(const QStringRef &value);
-
- Name *NAME(const QString &id, quint32 line, quint32 column);
- Name *NAME(Name *base, const QString &id, quint32 line, quint32 column);
- Name *SYMBOL(Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, Name::Storage storage, quint32 line, quint32 column);
- Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, quint32 line, quint32 column);
- Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, Name::Storage storage, quint32 line, quint32 column);
- Name *ID_OBJECT(const QString &id, const QDeclarativeScript::Object *object, quint32 line, quint32 column);
- Name *ATTACH_TYPE(const QString &id, const QDeclarativeType *attachType, Name::Storage storage, quint32 line, quint32 column);
-
- Expr *UNOP(AluOp op, Expr *expr);
- Expr *BINOP(AluOp op, Expr *left, Expr *right);
- Expr *CALL(Expr *base, ExprList *args);
-
- Stmt *EXP(Expr *expr);
- Stmt *MOVE(Expr *target, Expr *source, bool = false);
-
- Stmt *JUMP(BasicBlock *target);
- Stmt *CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse);
- Stmt *RET(Expr *expr, Type type, quint32 line, quint32 column);
-
- virtual void dump(QTextStream &out);
-};
-
-#ifdef DEBUG_IR_STRUCTURE
-struct IRDump : public ExprVisitor,
- public StmtVisitor
-{
-public:
- IRDump();
-
- void expression(QDeclarativeJS::IR::Expr *);
- void basicblock(QDeclarativeJS::IR::BasicBlock *);
- void statement(QDeclarativeJS::IR::Stmt *);
- void function(QDeclarativeJS::IR::Function *);
-protected:
-
- const char *indent();
-
- //
- // expressions
- //
- virtual void visitConst(QDeclarativeJS::IR::Const *e);
- virtual void visitString(QDeclarativeJS::IR::String *e);
- virtual void visitName(QDeclarativeJS::IR::Name *e);
- virtual void visitTemp(QDeclarativeJS::IR::Temp *e);
- virtual void visitUnop(QDeclarativeJS::IR::Unop *e);
- virtual void visitBinop(QDeclarativeJS::IR::Binop *e);
- virtual void visitCall(QDeclarativeJS::IR::Call *e);
-
- //
- // statements
- //
- virtual void visitExp(QDeclarativeJS::IR::Exp *s);
- virtual void visitMove(QDeclarativeJS::IR::Move *s);
- virtual void visitJump(QDeclarativeJS::IR::Jump *s);
- virtual void visitCJump(QDeclarativeJS::IR::CJump *s);
- virtual void visitRet(QDeclarativeJS::IR::Ret *s);
-
-private:
- int indentSize;
- QByteArray indentData;
- void inc();
- void dec();
-};
-#endif
-
-} // end of namespace IR
-
-} // end of namespace QDeclarativeJS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV4IR_P_H
diff --git a/src/declarative/qml/v4/qv4irbuilder.cpp b/src/declarative/qml/v4/qv4irbuilder.cpp
deleted file mode 100644
index e9f02b0c2f..0000000000
--- a/src/declarative/qml/v4/qv4irbuilder.cpp
+++ /dev/null
@@ -1,1305 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4irbuilder_p.h"
-#include "qv4compiler_p_p.h"
-
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativetypenamecache_p.h>
-
-DEFINE_BOOL_CONFIG_OPTION(qmlVerboseCompiler, QML_VERBOSE_COMPILER)
-
-QT_BEGIN_NAMESPACE
-
-using namespace QDeclarativeJS;
-
-static IR::Type irTypeFromVariantType(int t, QDeclarativeEnginePrivate *engine, const QMetaObject * /* meta */)
-{
- switch (t) {
- case QMetaType::Bool:
- return IR::BoolType;
-
- case QMetaType::Int:
- return IR::IntType;
-
- case QMetaType::QReal:
- return IR::RealType;
-
- case QMetaType::QString:
- return IR::StringType;
-
- case QMetaType::QUrl:
- return IR::UrlType;
-
- case QMetaType::QColor:
- return IR::ColorType;
-
- default:
- if (t == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) {
- return IR::SGAnchorLineType;
- } else if (engine->metaObjectForType(t)) {
- return IR::ObjectType;
- }
-
- return IR::InvalidType;
- }
-}
-
-QV4IRBuilder::QV4IRBuilder(const QV4Compiler::Expression *expr,
- QDeclarativeEnginePrivate *engine)
-: m_expression(expr), m_engine(engine), _function(0), _block(0), _discard(false)
-{
-}
-
-bool QV4IRBuilder::operator()(QDeclarativeJS::IR::Function *function,
- QDeclarativeJS::AST::Node *ast)
-{
- bool discarded = false;
-
- IR::BasicBlock *block = function->newBasicBlock();
-
- qSwap(_discard, discarded);
- qSwap(_function, function);
- qSwap(_block, block);
-
- ExprResult r;
- AST::SourceLocation location;
- if (AST::ExpressionNode *asExpr = ast->expressionCast()) {
- r = expression(asExpr);
- location = asExpr->firstSourceLocation();
- } else if (AST::Statement *asStmt = ast->statementCast()) {
- r = statement(asStmt);
- location = asStmt->firstSourceLocation();
- }
-
- //_block->MOVE(_block->TEMP(IR::InvalidType), r.code);
- if (r.code) {
- const QMetaObject *m = 0;
- const IR::Type targetType = irTypeFromVariantType(m_expression->property->type, m_engine, m);
- if (targetType != r.type()) {
- IR::Expr *x = _block->TEMP(targetType);
- _block->MOVE(x, r, true);
- r.code = x;
- }
- _block->RET(r.code, targetType, location.startLine, location.startColumn);
- }
-
- qSwap(_block, block);
- qSwap(_function, function);
- qSwap(_discard, discarded);
-
- return !discarded;
-}
-
-bool QV4IRBuilder::buildName(QList<QStringRef> &name,
- AST::Node *node,
- QList<AST::ExpressionNode *> *nodes)
-{
- if (node->kind == AST::Node::Kind_IdentifierExpression) {
- name << static_cast<AST::IdentifierExpression*>(node)->name;
- if (nodes) *nodes << static_cast<AST::IdentifierExpression*>(node);
- } else if (node->kind == AST::Node::Kind_FieldMemberExpression) {
- AST::FieldMemberExpression *expr =
- static_cast<AST::FieldMemberExpression *>(node);
-
- if (!buildName(name, expr->base, nodes))
- return false;
-
- name << expr->name;
- if (nodes) *nodes << expr;
- } else {
- return false;
- }
-
- return true;
-}
-
-void QV4IRBuilder::discard()
-{
- _discard = true;
-}
-
-QV4IRBuilder::ExprResult
-QV4IRBuilder::expression(AST::ExpressionNode *ast)
-{
- ExprResult r;
- if (ast) {
- qSwap(_expr, r);
- accept(ast);
- qSwap(_expr, r);
-
- if (r.is(IR::InvalidType))
- discard();
- else {
- Q_ASSERT(r.hint == r.format);
- }
- }
-
- return r;
-}
-
-void QV4IRBuilder::condition(AST::ExpressionNode *ast, IR::BasicBlock *iftrue, IR::BasicBlock *iffalse)
-{
- if (! ast)
- return;
- ExprResult r(iftrue, iffalse);
- qSwap(_expr, r);
- accept(ast);
- qSwap(_expr, r);
-
- if (r.format != ExprResult::cx) {
- if (! r.code)
- discard();
-
- Q_ASSERT(r.hint == ExprResult::cx);
- Q_ASSERT(r.format == ExprResult::ex);
-
- if (r.type() != IR::BoolType) {
- IR::Temp *t = _block->TEMP(IR::BoolType);
- _block->MOVE(t, r);
- r = t;
- }
-
- _block->CJUMP(_block->UNOP(IR::OpIfTrue, r), iftrue, iffalse);
- }
-}
-
-QV4IRBuilder::ExprResult
-QV4IRBuilder::statement(AST::Statement *ast)
-{
- ExprResult r;
- if (ast) {
- qSwap(_expr, r);
- accept(ast);
- qSwap(_expr, r);
-
- if (r.is(IR::InvalidType))
- discard();
- else {
- Q_ASSERT(r.hint == r.format);
- }
- }
-
- return r;
-}
-
-void QV4IRBuilder::sourceElement(AST::SourceElement *ast)
-{
- accept(ast);
-}
-
-void QV4IRBuilder::implicitCvt(ExprResult &expr, IR::Type type)
-{
- if (expr.type() == type)
- return; // nothing to do
-
- IR::Expr *x = _block->TEMP(type);
- _block->MOVE(x, expr.code);
- expr.code = x;
-}
-
-// QML
-bool QV4IRBuilder::visit(AST::UiProgram *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiImportList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiImport *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiPublicMember *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiSourceElement *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiObjectDefinition *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiObjectInitializer *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiObjectBinding *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiScriptBinding *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiArrayBinding *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiObjectMemberList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiArrayMemberList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiQualifiedId *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-
-// JS
-bool QV4IRBuilder::visit(AST::Program *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::SourceElements *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FunctionSourceElement *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::StatementSourceElement *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-// object literals
-bool QV4IRBuilder::visit(AST::PropertyNameAndValueList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::IdentifierPropertyName *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::StringLiteralPropertyName *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NumericLiteralPropertyName *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-
-// array literals
-bool QV4IRBuilder::visit(AST::ElementList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::Elision *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-
-// function calls
-bool QV4IRBuilder::visit(AST::ArgumentList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-// expressions
-bool QV4IRBuilder::visit(AST::ObjectLiteral *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ArrayLiteral *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ThisExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::IdentifierExpression *ast)
-{
- const quint32 line = ast->identifierToken.startLine;
- const quint32 column = ast->identifierToken.startColumn;
-
- const QString name = ast->name.toString();
-
- if (name.at(0) == QLatin1Char('u') && name.length() == 9 && name == QLatin1String("undefined")) {
- _expr.code = _block->CONST(IR::UndefinedType, 0); // ### undefined value
- } else if (m_engine->v8engine()->illegalNames().contains(name) ) {
- if (qmlVerboseCompiler()) qWarning() << "*** illegal symbol:" << name;
- return false;
- } else if (const QDeclarativeScript::Object *obj = m_expression->ids->value(name)) {
- IR::Name *code = _block->ID_OBJECT(name, obj, line, column);
- if (obj == m_expression->component)
- code->storage = IR::Name::RootStorage;
- _expr.code = code;
- } else {
-
- QDeclarativeTypeNameCache::Result r = m_expression->importCache->query(name);
- if (r.isValid()) {
- if (r.type) {
- _expr.code = _block->ATTACH_TYPE(name, r.type, IR::Name::ScopeStorage, line, column);
- }
- // We don't support anything else
- } else {
- bool found = false;
-
- if (m_expression->context != m_expression->component) {
- // RootStorage is more efficient than ScopeStorage, so prefer that if they are the same
- QDeclarativePropertyCache *cache = m_expression->context->synthCache;
- const QMetaObject *metaObject = m_expression->context->metaObject();
- if (!cache) cache = m_engine->cache(metaObject);
-
- QDeclarativePropertyData *data = cache->property(name);
-
- if (data && data->hasRevision()) {
- if (qmlVerboseCompiler())
- qWarning() << "*** versioned symbol:" << name;
- discard();
- return false;
- }
-
- if (data && !data->isFunction()) {
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject);
- _expr.code = _block->SYMBOL(irType, name, metaObject, data, IR::Name::ScopeStorage, line, column);
- found = true;
- }
- }
-
- if (!found) {
- QDeclarativePropertyCache *cache = m_expression->component->synthCache;
- const QMetaObject *metaObject = m_expression->component->metaObject();
- if (!cache) cache = m_engine->cache(metaObject);
-
- QDeclarativePropertyData *data = cache->property(name);
-
- if (data && data->hasRevision()) {
- if (qmlVerboseCompiler())
- qWarning() << "*** versioned symbol:" << name;
- discard();
- return false;
- }
-
- if (data && !data->isFunction()) {
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject);
- _expr.code = _block->SYMBOL(irType, name, metaObject, data, IR::Name::RootStorage, line, column);
- found = true;
- }
- }
-
- if (!found && qmlVerboseCompiler())
- qWarning() << "*** unknown symbol:" << name;
- }
- }
-
- if (_expr.code && _expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
-
- if (_expr.type() != IR::BoolType) {
- IR::Temp *t = _block->TEMP(IR::BoolType);
- _block->MOVE(t, _expr);
- _expr.code = t;
- }
-
- _block->CJUMP(_expr.code, _expr.iftrue, _expr.iffalse);
- _expr.code = 0;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NullExpression *)
-{
- // ### TODO: cx format
- _expr.code = _block->CONST(IR::NullType, 0);
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::TrueLiteral *)
-{
- // ### TODO: cx format
- _expr.code = _block->CONST(IR::BoolType, 1);
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FalseLiteral *)
-{
- // ### TODO: cx format
- _expr.code = _block->CONST(IR::BoolType, 0);
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::StringLiteral *ast)
-{
- // ### TODO: cx format
- _expr.code = _block->STRING(ast->value);
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NumericLiteral *ast)
-{
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
- _block->JUMP(ast->value ? _expr.iftrue : _expr.iffalse);
- } else {
- _expr.code = _block->CONST(ast->value);
- }
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::RegExpLiteral *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NestedExpression *)
-{
- return true; // the value of the nested expression
-}
-
-bool QV4IRBuilder::visit(AST::ArrayMemberExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast)
-{
- if (IR::Expr *left = expression(ast->base)) {
- if (IR::Name *baseName = left->asName()) {
- const quint32 line = ast->identifierToken.startLine;
- const quint32 column = ast->identifierToken.startColumn;
-
- QString name = ast->name.toString();
-
- switch(baseName->symbol) {
- case IR::Name::Unbound:
- break;
-
- case IR::Name::AttachType:
- if (name.at(0).isUpper()) {
- QByteArray utf8Name = name.toUtf8();
- const char *enumName = utf8Name.constData();
-
- const QMetaObject *meta = baseName->declarativeType->metaObject();
- bool found = false;
- for (int ii = 0; !found && ii < meta->enumeratorCount(); ++ii) {
- QMetaEnum e = meta->enumerator(ii);
- for (int jj = 0; !found && jj < e.keyCount(); ++jj) {
- if (0 == strcmp(e.key(jj), enumName)) {
- found = true;
- _expr.code = _block->CONST(IR::IntType, e.value(jj));
- }
- }
- }
-
- if (!found && qmlVerboseCompiler())
- qWarning() << "*** unresolved enum:"
- << (*baseName->id + QLatin1String(".") + ast->name.toString());
- } else if(const QMetaObject *attachedMeta = baseName->declarativeType->attachedPropertiesType()) {
- QDeclarativePropertyCache *cache = m_engine->cache(attachedMeta);
- QDeclarativePropertyData *data = cache->property(name);
-
- if (!data || data->isFunction())
- return false; // Don't support methods (or non-existing properties ;)
-
- if(!data->isFinal()) {
- if (qmlVerboseCompiler())
- qWarning() << "*** non-final attached property:"
- << (*baseName->id + QLatin1String(".") + ast->name.toString());
- return false; // We don't know enough about this property
- }
-
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine, attachedMeta);
- _expr.code = _block->SYMBOL(baseName, irType, name, attachedMeta, data, line, column);
- }
- break;
-
- case IR::Name::IdObject: {
- const QDeclarativeScript::Object *idObject = baseName->idObject;
- QDeclarativePropertyCache *cache =
- idObject->synthCache?idObject->synthCache:m_engine->cache(idObject->metaObject());
-
- QDeclarativePropertyData *data = cache->property(name);
-
- if (!data || data->isFunction())
- return false; // Don't support methods (or non-existing properties ;)
-
- if (data->hasRevision()) {
- if (qmlVerboseCompiler())
- qWarning() << "*** versioned symbol:" << name;
- discard();
- return false;
- }
-
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine, idObject->metaObject());
- _expr.code = _block->SYMBOL(baseName, irType, name,
- idObject->metaObject(), data, line, column);
- }
- break;
-
- case IR::Name::Property:
- if (baseName->type == IR::ObjectType && baseName->meta && baseName->property->isFinal()) {
- QDeclarativePropertyCache *cache = m_engine->cache(baseName->meta);
- if (!cache)
- return false;
-
- if (QDeclarativePropertyData *data = cache->property(name)) {
- if (!data->isFinal()) {
- if (qmlVerboseCompiler())
- qWarning() << "*** non-final property access:"
- << (*baseName->id + QLatin1String(".") + ast->name.toString());
- return false; // We don't know enough about this property
- }
-
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine, baseName->meta);
- _expr.code = _block->SYMBOL(baseName, irType, name,
- baseName->meta, data, line, column);
- }
- }
- break;
-
- case IR::Name::Object:
- case IR::Name::Slot:
- break;
- }
- }
- }
-
- return false;
-}
-
-bool QV4IRBuilder::preVisit(AST::Node *)
-{
- return ! _discard;
-}
-
-bool QV4IRBuilder::visit(AST::NewMemberExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NewExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::CallExpression *ast)
-{
- QList<QStringRef> names;
- QList<AST::ExpressionNode *> nameNodes;
-
- names.reserve(4);
- nameNodes.reserve(4);
-
- if (buildName(names, ast->base, &nameNodes)) {
- //ExprResult base = expression(ast->base);
- QString id;
- for (int i = 0; i < names.size(); ++i) {
- if (! i)
- id += QLatin1Char('.');
- id += names.at(i);
- }
- const AST::SourceLocation loc = nameNodes.last()->firstSourceLocation();
- IR::Expr *base = _block->NAME(id, loc.startLine, loc.startColumn);
-
- IR::ExprList *args = 0, **argsInserter = &args;
- for (AST::ArgumentList *it = ast->arguments; it; it = it->next) {
- IR::Expr *arg = expression(it->expression);
- *argsInserter = _function->pool->New<IR::ExprList>();
- (*argsInserter)->init(arg);
- argsInserter = &(*argsInserter)->next;
- }
-
- IR::Temp *r = _block->TEMP(IR::InvalidType);
- IR::Expr *call = _block->CALL(base, args);
- _block->MOVE(r, call);
- r->type = call->type;
- _expr.code = r;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PostIncrementExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PostDecrementExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::DeleteExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::VoidExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::TypeOfExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PreIncrementExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PreDecrementExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UnaryPlusExpression *ast)
-{
- ExprResult expr = expression(ast->expression);
- if (expr.isNot(IR::InvalidType)) {
- if (expr.code->asConst() != 0) {
- _expr = expr;
- return false;
- }
-
- IR::Expr *code = _block->UNOP(IR::OpUPlus, expr);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr, code);
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UnaryMinusExpression *ast)
-{
- ExprResult expr = expression(ast->expression);
- if (expr.isNot(IR::InvalidType)) {
- if (IR::Const *c = expr.code->asConst()) {
- _expr = expr;
- _expr.code = _block->CONST(-c->value);
- return false;
- }
-
- IR::Expr *code = _block->UNOP(IR::OpUMinus, expr);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr, code);
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::TildeExpression *ast)
-{
- ExprResult expr = expression(ast->expression);
- if (expr.isNot(IR::InvalidType)) {
- if (IR::Const *c = expr.code->asConst()) {
- _expr = expr;
- _expr.code = _block->CONST(~int(c->value));
- return false;
- }
- IR::Expr *code = _block->UNOP(IR::OpCompl, expr);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr, code);
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NotExpression *ast)
-{
- ExprResult expr = expression(ast->expression);
-
- if (expr.isNot(IR::InvalidType)) {
- if (IR::Const *c = expr.code->asConst()) {
- _expr = expr;
- _expr.code = _block->CONST(!c->value);
- return false;
- }
-
- IR::Expr *code = _block->UNOP(IR::OpNot, expr);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr, code);
-
- } else if (expr.hint == ExprResult::cx) {
- expr.format = ExprResult::cx;
- _block->CJUMP(_block->UNOP(IR::OpNot, expr), _expr.iftrue, _expr.iffalse);
- return false;
- }
-
- return false;
-}
-
-void QV4IRBuilder::binop(AST::BinaryExpression *ast, ExprResult left, ExprResult right)
-{
- if (IR::Type t = maxType(left.type(), right.type())) {
- implicitCvt(left, t);
- implicitCvt(right, t);
-
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
- _block->CJUMP(_block->BINOP(IR::binaryOperator(ast->op), left, right), _expr.iftrue, _expr.iffalse);
- } else {
- IR::Expr *code = _block->BINOP(IR::binaryOperator(ast->op), left, right);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr.code, code);
- }
- }
-}
-
-bool QV4IRBuilder::visit(AST::BinaryExpression *ast)
-{
- switch (ast->op) {
- case QSOperator::And: {
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
-
- Q_ASSERT(_expr.iffalse != 0);
- Q_ASSERT(_expr.iftrue != 0);
-
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- condition(ast->left, iftrue, _expr.iffalse);
-
- _block = iftrue;
- condition(ast->right, _expr.iftrue, _expr.iffalse);
- } else {
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- IR::BasicBlock *iffalse = _function->newBasicBlock();
- IR::BasicBlock *endif = _function->newBasicBlock();
-
- condition(ast->left, iftrue, iffalse);
-
- IR::Temp *r = _block->TEMP(IR::InvalidType);
-
- _block = iffalse;
- _block->MOVE(r, _block->CONST(0)); // ### use the right null value
- _block->JUMP(endif);
-
- _block = iftrue;
- ExprResult right = expression(ast->right);
- _block->MOVE(r, right);
- _block->JUMP(endif);
-
- _block = endif;
-
- r->type = right.type(); // ### not exactly, it can be IR::BoolType.
- _expr.code = r;
- }
- } break;
-
- case QSOperator::Or: {
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- IR::BasicBlock *endif = _function->newBasicBlock();
-
- ExprResult left = expression(ast->left);
- IR::Temp *r = _block->TEMP(left.type());
- _block->MOVE(r, left);
-
- IR::Expr *cond = r;
- if (r->type != IR::BoolType) {
- cond = _block->TEMP(IR::BoolType);
- _block->MOVE(cond, r);
- }
-
- _block->CJUMP(_block->UNOP(IR::OpNot, cond), iftrue, endif);
-
- _block = iftrue;
- ExprResult right = expression(ast->right);
- _block->MOVE(r, right);
- _block->JUMP(endif);
-
- if (left.type() != right.type())
- discard();
-
- _expr.code = r;
-
- _block = endif;
- } break;
-
- case QSOperator::Lt:
- case QSOperator::Gt:
- case QSOperator::Le:
- case QSOperator::Ge: {
- ExprResult left = expression(ast->left);
- ExprResult right = expression(ast->right);
- if (left.type() == IR::StringType && right.type() == IR::StringType) {
- binop(ast, left, right);
- } else if (left.isValid() && right.isValid()) {
- implicitCvt(left, IR::RealType);
- implicitCvt(right, IR::RealType);
- binop(ast, left, right);
- }
- } break;
-
- case QSOperator::NotEqual:
- case QSOperator::Equal: {
- ExprResult left = expression(ast->left);
- ExprResult right = expression(ast->right);
- if ((left.type() == IR::NullType || left.type() == IR::UndefinedType) &&
- (right.type() == IR::NullType || right.type() == IR::UndefinedType)) {
- const bool isEq = ast->op == QSOperator::Equal;
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
- _block->JUMP(isEq ? _expr.iftrue : _expr.iffalse);
- } else {
- _expr.code = _block->CONST(IR::BoolType, isEq ? 1 : 0);
- }
- } else if ((left.type() == IR::StringType && right.type() >= IR::FirstNumberType) ||
- (left.type() >= IR::FirstNumberType && right.type() == IR::StringType)) {
- implicitCvt(left, IR::RealType);
- implicitCvt(right, IR::RealType);
- binop(ast, left, right);
- } else if (left.type() == IR::BoolType || right.type() == IR::BoolType) {
- implicitCvt(left, IR::BoolType);
- implicitCvt(right, IR::BoolType);
- } else if (left.isValid() && right.isValid()) {
- binop(ast, left, right);
- }
- } break;
-
- case QSOperator::StrictEqual:
- case QSOperator::StrictNotEqual: {
- ExprResult left = expression(ast->left);
- ExprResult right = expression(ast->right);
- if (left.type() == right.type()) {
- binop(ast, left, right);
- } else if (left.type() >= IR::BoolType && right.type() >= IR::BoolType) {
- // left and right have numeric type (int or real)
- binop(ast, left, right);
- } else if (left.isValid() && right.isValid()) {
- const bool isEq = ast->op == QSOperator::StrictEqual;
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
- _block->JUMP(isEq ? _expr.iftrue : _expr.iffalse);
- } else {
- _expr.code = _block->CONST(IR::BoolType, isEq ? 1 : 0);
- }
- }
- } break;
-
- case QSOperator::BitAnd:
- case QSOperator::BitOr:
- case QSOperator::BitXor:
- case QSOperator::LShift:
- case QSOperator::RShift:
- case QSOperator::URShift: {
- ExprResult left = expression(ast->left);
- if (left.is(IR::InvalidType))
- return false;
-
- ExprResult right = expression(ast->right);
- if (right.is(IR::InvalidType))
- return false;
-
- implicitCvt(left, IR::IntType);
- implicitCvt(right, IR::IntType);
-
- IR::Expr *code = _block->BINOP(IR::binaryOperator(ast->op), left, right);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr.code, code);
-
- } break;
-
- case QSOperator::Add: {
- ExprResult left = expression(ast->left);
- if (left.is(IR::InvalidType))
- return false;
-
- ExprResult right = expression(ast->right);
- if (right.is(IR::InvalidType))
- return false;
-
- if (left.isPrimitive() && right.isPrimitive()) {
- if (left.type() == IR::StringType || right.type() == IR::StringType) {
- implicitCvt(left, IR::StringType);
- implicitCvt(right, IR::StringType);
- }
- binop(ast, left, right);
- }
- } break;
-
- case QSOperator::Div:
- case QSOperator::Mod:
- case QSOperator::Mul:
- case QSOperator::Sub: {
- ExprResult left = expression(ast->left);
- if (left.is(IR::InvalidType))
- return false;
-
- ExprResult right = expression(ast->right);
- if (right.is(IR::InvalidType))
- return false;
-
- IR::Type t = maxType(left.type(), right.type());
- if (t >= IR::FirstNumberType) {
- implicitCvt(left, IR::RealType);
- implicitCvt(right, IR::RealType);
-
- IR::Expr *code = _block->BINOP(IR::binaryOperator(ast->op), left, right);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr.code, code);
- }
- } break;
-
- case QSOperator::In:
- case QSOperator::InstanceOf:
- case QSOperator::Assign:
- case QSOperator::InplaceAnd:
- case QSOperator::InplaceSub:
- case QSOperator::InplaceDiv:
- case QSOperator::InplaceAdd:
- case QSOperator::InplaceLeftShift:
- case QSOperator::InplaceMod:
- case QSOperator::InplaceMul:
- case QSOperator::InplaceOr:
- case QSOperator::InplaceRightShift:
- case QSOperator::InplaceURightShift:
- case QSOperator::InplaceXor:
- // yup, we don't do those.
- break;
- } // switch
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ConditionalExpression *ast)
-{
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- IR::BasicBlock *iffalse = _function->newBasicBlock();
- IR::BasicBlock *endif = _function->newBasicBlock();
-
- condition(ast->expression, iftrue, iffalse);
-
- IR::Temp *r = _block->TEMP(IR::InvalidType);
-
- qSwap(_block, iftrue);
- ExprResult ok = expression(ast->ok);
- _block->MOVE(r, ok);
- _block->JUMP(endif);
- qSwap(_block, iftrue);
-
- qSwap(_block, iffalse);
- ExprResult ko = expression(ast->ko);
- _block->MOVE(r, ko);
- _block->JUMP(endif);
- qSwap(_block, iffalse);
-
- r->type = maxType(ok.type(), ko.type());
- _expr.code = r;
-
- _block = endif;
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::Expression *ast)
-{
- _block->EXP(expression(ast->left));
- _expr = expression(ast->right);
-
- return false;
-}
-
-
-// statements
-bool QV4IRBuilder::visit(AST::Block *ast)
-{
- if (ast->statements && ! ast->statements->next) {
- // we have one and only one statement
- accept(ast->statements->statement);
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::StatementList *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::VariableStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::VariableDeclarationList *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::VariableDeclaration *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::EmptyStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ExpressionStatement *ast)
-{
- if (ast->expression) {
- // return the value of this expression
- return true;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::IfStatement *ast)
-{
- if (! ast->ko) {
- // This is an if statement without an else branch.
- discard();
- } else {
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- IR::BasicBlock *iffalse = _function->newBasicBlock();
- IR::BasicBlock *endif = _function->newBasicBlock();
-
- condition(ast->expression, iftrue, iffalse);
-
- IR::Temp *r = _block->TEMP(IR::InvalidType);
-
- qSwap(_block, iftrue);
- ExprResult ok = statement(ast->ok);
- _block->MOVE(r, ok);
- _block->JUMP(endif);
- qSwap(_block, iftrue);
-
- qSwap(_block, iffalse);
- ExprResult ko = statement(ast->ko);
- _block->MOVE(r, ko);
- _block->JUMP(endif);
- qSwap(_block, iffalse);
-
- r->type = maxType(ok.type(), ko.type());
- _expr.code = r;
-
- _block = endif;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::DoWhileStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::WhileStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ForStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::LocalForStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ForEachStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::LocalForEachStatement *)
-{
- discard();
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ContinueStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::BreakStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ReturnStatement *ast)
-{
- if (ast->expression) {
- // return the value of the expression
- return true;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::WithStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::SwitchStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::CaseBlock *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::CaseClauses *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::CaseClause *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::DefaultClause *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::LabelledStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ThrowStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::TryStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::Catch *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::Finally *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FunctionDeclaration *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FunctionExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FormalParameterList *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FunctionBody *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::DebuggerStatement *)
-{
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v4/qv4irbuilder_p.h b/src/declarative/qml/v4/qv4irbuilder_p.h
deleted file mode 100644
index c0c7ff874c..0000000000
--- a/src/declarative/qml/v4/qv4irbuilder_p.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4IRBUILDER_P_H
-#define QV4IRBUILDER_P_H
-
-#include <QtCore/qglobal.h>
-
-#include "qv4ir_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QV4IRBuilder : public QDeclarativeJS::AST::Visitor
-{
-public:
- QV4IRBuilder(const QV4Compiler::Expression *, QDeclarativeEnginePrivate *);
-
- bool operator()(QDeclarativeJS::IR::Function *, QDeclarativeJS::AST::Node *);
-
-protected:
- struct ExprResult {
- enum Format {
- ex, // expression
- cx // condition
- };
-
- QDeclarativeJS::IR::Expr *code;
- QDeclarativeJS::IR::BasicBlock *iftrue;
- QDeclarativeJS::IR::BasicBlock *iffalse;
- Format hint; // requested format
- Format format; // instruction format
-
- ExprResult(QDeclarativeJS::IR::Expr *expr = 0)
- : code(expr), iftrue(0), iffalse(0), hint(ex), format(ex) {}
-
- ExprResult(QDeclarativeJS::IR::BasicBlock *iftrue, QDeclarativeJS::IR::BasicBlock *iffalse)
- : code(0), iftrue(iftrue), iffalse(iffalse), hint(cx), format(ex) {}
-
- inline QDeclarativeJS::IR::Type type() const { return code ? code->type : QDeclarativeJS::IR::InvalidType; }
-
- inline QDeclarativeJS::IR::Expr *get() const { return code; }
- inline operator QDeclarativeJS::IR::Expr *() const { return get(); }
- inline QDeclarativeJS::IR::Expr *operator->() const { return get(); }
- inline bool isValid() const { return code ? code->type != QDeclarativeJS::IR::InvalidType : false; }
- inline bool is(QDeclarativeJS::IR::Type t) const { return type() == t; }
- inline bool isNot(QDeclarativeJS::IR::Type t) const { return type() != t; }
-
- bool isPrimitive() const {
- switch (type()) {
- case QDeclarativeJS::IR::UndefinedType: // ### TODO
- case QDeclarativeJS::IR::NullType: // ### TODO
- case QDeclarativeJS::IR::UrlType: // ### TODO
- return false;
-
- case QDeclarativeJS::IR::StringType:
- case QDeclarativeJS::IR::BoolType:
- case QDeclarativeJS::IR::IntType:
- case QDeclarativeJS::IR::RealType:
- case QDeclarativeJS::IR::RealNaNType:
- return true;
-
- default:
- return false;
- } // switch
- }
- };
-
- inline void accept(QDeclarativeJS::AST::Node *ast) { QDeclarativeJS::AST::Node::accept(ast, this); }
-
- ExprResult expression(QDeclarativeJS::AST::ExpressionNode *ast);
- ExprResult statement(QDeclarativeJS::AST::Statement *ast);
- void sourceElement(QDeclarativeJS::AST::SourceElement *ast);
- void condition(QDeclarativeJS::AST::ExpressionNode *ast, QDeclarativeJS::IR::BasicBlock *iftrue, QDeclarativeJS::IR::BasicBlock *iffalse);
- void binop(QDeclarativeJS::AST::BinaryExpression *ast, ExprResult left, ExprResult right);
-
- void implicitCvt(ExprResult &expr, QDeclarativeJS::IR::Type type);
-
- virtual bool preVisit(QDeclarativeJS::AST::Node *ast);
-
- // QML
- virtual bool visit(QDeclarativeJS::AST::UiProgram *ast);
- virtual bool visit(QDeclarativeJS::AST::UiImportList *ast);
- virtual bool visit(QDeclarativeJS::AST::UiImport *ast);
- virtual bool visit(QDeclarativeJS::AST::UiPublicMember *ast);
- virtual bool visit(QDeclarativeJS::AST::UiSourceElement *ast);
- virtual bool visit(QDeclarativeJS::AST::UiObjectDefinition *ast);
- virtual bool visit(QDeclarativeJS::AST::UiObjectInitializer *ast);
- virtual bool visit(QDeclarativeJS::AST::UiObjectBinding *ast);
- virtual bool visit(QDeclarativeJS::AST::UiScriptBinding *ast);
- virtual bool visit(QDeclarativeJS::AST::UiArrayBinding *ast);
- virtual bool visit(QDeclarativeJS::AST::UiObjectMemberList *ast);
- virtual bool visit(QDeclarativeJS::AST::UiArrayMemberList *ast);
- virtual bool visit(QDeclarativeJS::AST::UiQualifiedId *ast);
-
- // JS
- virtual bool visit(QDeclarativeJS::AST::Program *ast);
- virtual bool visit(QDeclarativeJS::AST::SourceElements *ast);
- virtual bool visit(QDeclarativeJS::AST::FunctionSourceElement *ast);
- virtual bool visit(QDeclarativeJS::AST::StatementSourceElement *ast);
-
- // object literals
- virtual bool visit(QDeclarativeJS::AST::PropertyNameAndValueList *ast);
- virtual bool visit(QDeclarativeJS::AST::IdentifierPropertyName *ast);
- virtual bool visit(QDeclarativeJS::AST::StringLiteralPropertyName *ast);
- virtual bool visit(QDeclarativeJS::AST::NumericLiteralPropertyName *ast);
-
- // array literals
- virtual bool visit(QDeclarativeJS::AST::ElementList *ast);
- virtual bool visit(QDeclarativeJS::AST::Elision *ast);
-
- // function calls
- virtual bool visit(QDeclarativeJS::AST::ArgumentList *ast);
-
- // expressions
- virtual bool visit(QDeclarativeJS::AST::ObjectLiteral *ast);
- virtual bool visit(QDeclarativeJS::AST::ArrayLiteral *ast);
- virtual bool visit(QDeclarativeJS::AST::ThisExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::IdentifierExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::NullExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::TrueLiteral *ast);
- virtual bool visit(QDeclarativeJS::AST::FalseLiteral *ast);
- virtual bool visit(QDeclarativeJS::AST::StringLiteral *ast);
- virtual bool visit(QDeclarativeJS::AST::NumericLiteral *ast);
- virtual bool visit(QDeclarativeJS::AST::RegExpLiteral *ast);
- virtual bool visit(QDeclarativeJS::AST::NestedExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::ArrayMemberExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::FieldMemberExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::NewMemberExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::NewExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::CallExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::PostIncrementExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::PostDecrementExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::DeleteExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::VoidExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::TypeOfExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::PreIncrementExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::PreDecrementExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::UnaryPlusExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::UnaryMinusExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::TildeExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::NotExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::BinaryExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::ConditionalExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::Expression *ast);
-
- // statements
- virtual bool visit(QDeclarativeJS::AST::Block *ast);
- virtual bool visit(QDeclarativeJS::AST::StatementList *ast);
- virtual bool visit(QDeclarativeJS::AST::VariableStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::VariableDeclarationList *ast);
- virtual bool visit(QDeclarativeJS::AST::VariableDeclaration *ast);
- virtual bool visit(QDeclarativeJS::AST::EmptyStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::ExpressionStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::IfStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::DoWhileStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::WhileStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::ForStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::LocalForStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::ForEachStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::LocalForEachStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::ContinueStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::BreakStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::ReturnStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::WithStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::SwitchStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::CaseBlock *ast);
- virtual bool visit(QDeclarativeJS::AST::CaseClauses *ast);
- virtual bool visit(QDeclarativeJS::AST::CaseClause *ast);
- virtual bool visit(QDeclarativeJS::AST::DefaultClause *ast);
- virtual bool visit(QDeclarativeJS::AST::LabelledStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::ThrowStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::TryStatement *ast);
- virtual bool visit(QDeclarativeJS::AST::Catch *ast);
- virtual bool visit(QDeclarativeJS::AST::Finally *ast);
- virtual bool visit(QDeclarativeJS::AST::FunctionDeclaration *ast);
- virtual bool visit(QDeclarativeJS::AST::FunctionExpression *ast);
- virtual bool visit(QDeclarativeJS::AST::FormalParameterList *ast);
- virtual bool visit(QDeclarativeJS::AST::FunctionBody *ast);
- virtual bool visit(QDeclarativeJS::AST::DebuggerStatement *ast);
-
-private:
- bool buildName(QList<QStringRef> &name, QDeclarativeJS::AST::Node *node,
- QList<QDeclarativeJS::AST::ExpressionNode *> *nodes);
- void discard();
-
- const QV4Compiler::Expression *m_expression;
- QDeclarativeEnginePrivate *m_engine;
-
- QDeclarativeJS::IR::Function *_function;
- QDeclarativeJS::IR::BasicBlock *_block;
- bool _discard;
-
- ExprResult _expr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV4IRBUILDER_P_H
diff --git a/src/declarative/qml/v4/qv4program_p.h b/src/declarative/qml/v4/qv4program_p.h
deleted file mode 100644
index 6792ccb783..0000000000
--- a/src/declarative/qml/v4/qv4program_p.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4PROGRAM_P_H
-#define QV4PROGRAM_P_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 "qv4instruction_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-struct QV4Program {
- quint32 bindings;
- quint32 dataLength;
- quint32 signalTableOffset;
- quint32 exceptionDataOffset;
- quint16 subscriptions;
- quint16 identifiers;
- quint16 instructionCount;
-
- struct BindingReference {
- quint32 binding;
- quint32 blockMask;
- };
-
- struct BindingReferenceList {
- quint32 count;
- BindingReference bindings[];
- };
-
- inline const char *data() const;
- inline const char *instructions() const;
- inline BindingReferenceList *signalTable(int signalIndex) const;
-};
-
-enum QDeclarativeRegisterType {
- UndefinedType,
- QObjectStarType,
- QRealType,
- IntType,
- BoolType,
-
- PODValueType,
-
- FirstCleanupType,
- QStringType = FirstCleanupType,
- QUrlType,
- QVariantType,
- QColorType
-};
-
-const char *QV4Program::data() const
-{
- return ((const char *)this) + sizeof(QV4Program);
-}
-
-const char *QV4Program::instructions() const
-{
- return (const char *)(data() + dataLength);
-}
-
-QV4Program::BindingReferenceList *QV4Program::signalTable(int signalIndex) const
-{
- quint32 *signalTable = (quint32 *)(data() + signalTableOffset);
- return (BindingReferenceList *)(signalTable + signalTable[signalIndex]);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV4PROGRAM_P_H
-
diff --git a/src/declarative/qml/v8/notes.txt b/src/declarative/qml/v8/notes.txt
deleted file mode 100644
index ff5a289b7c..0000000000
--- a/src/declarative/qml/v8/notes.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Removed backwards compatible imports - QTBUG-17518
-
-autotest print() taking objects that don't ToString()
-autotest QDeclarativeV8Function
diff --git a/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp b/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp
deleted file mode 100644
index d338508d09..0000000000
--- a/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp
+++ /dev/null
@@ -1,1321 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativebuiltinfunctions_p.h"
-
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativecomponent_p.h>
-#include <private/qdeclarativestringconverters_p.h>
-#include <private/qdeclarativelocale_p.h>
-#include <private/qv8engine_p.h>
-#include <private/qjsconverter_impl_p.h>
-
-#include <private/qv8profilerservice_p.h>
-#include <private/qdeclarativeprofilerservice_p.h>
-
-#include <QtCore/qstring.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qcryptographichash.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qcoreapplication.h>
-
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-#include <QtGui/qdesktopservices.h>
-#include <QtGui/qfontdatabase.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QDeclarativeBuiltinFunctions {
-
-enum ConsoleLogTypes {
- Log,
- Warn,
- Error
-};
-
-static void jsContext(v8::Handle<v8::Value> *file, int *line, v8::Handle<v8::Value> *function) {
- v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(1);
- if (stackTrace->GetFrameCount()) {
- v8::Local<v8::StackFrame> frame = stackTrace->GetFrame(0);
- *file = frame->GetScriptName();
- *line = frame->GetLineNumber();
- *function = frame->GetFunctionName();
- }
-}
-
-static QString jsStack() {
- QStringList stackFrames;
-
- //The v8 default is currently 10 stack frames.
- v8::Handle<v8::StackTrace> stackTrace =
- v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kOverview);
- int stackCount = stackTrace->GetFrameCount();
-
- for (int i = 0; i < stackCount; i++) {
- v8::Local<v8::StackFrame> frame = stackTrace->GetFrame(i);
- v8::Handle<v8::String> function(frame->GetFunctionName());
- v8::Handle<v8::String> script(frame->GetScriptName());
- int lineNumber = frame->GetLineNumber();
- int columnNumber = frame->GetColumn();
-
- QString stackFrame =
- QString::fromLatin1("%1 (%2:%3:%4)").arg(QJSConverter::toString(function),
- QJSConverter::toString(script),
- QString::number(lineNumber),
- QString::number(columnNumber));
- stackFrames.append(stackFrame);
- }
- return stackFrames.join(QLatin1String("\n"));
-}
-
-v8::Handle<v8::Value> console(ConsoleLogTypes logType, const v8::Arguments &args,
- bool printStack = false)
-{
- v8::HandleScope handleScope;
-
- QString result;
- for (int i = 0; i < args.Length(); ++i) {
- if (i != 0)
- result.append(QLatin1Char(' '));
-
- v8::Local<v8::Value> value = args[i];
- //Check for Object Type
- if (value->IsObject() && !value->IsFunction()
- && !value->IsArray() && !value->IsDate()
- && !value->IsRegExp()) {
- result.append(QLatin1String("Object"));
- } else {
- v8::Local<v8::String> jsstr = value->ToString();
- QString tmp = V8ENGINE()->toString(jsstr);
- if (value->IsArray())
- result.append(QString::fromLatin1("[%1]").arg(tmp));
- else
- result.append(tmp);
- }
- }
-
- if (printStack) {
- result.append(QLatin1String("\n"));
- result.append(jsStack());
- }
-
- v8::Handle<v8::Value> fileHandle;
- v8::Handle<v8::Value> functionHandle;
- int line;
-
- jsContext(&fileHandle, &line, &functionHandle);
-
- switch (logType) {
- case Log:
- QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
- *v8::String::AsciiValue(functionHandle)).debug("%s", qPrintable(result));
- break;
- case Warn:
- QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
- *v8::String::AsciiValue(functionHandle)).warning("%s", qPrintable(result));
- break;
- case Error:
- QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
- *v8::String::AsciiValue(functionHandle)).critical("%s", qPrintable(result));
- break;
- default:
- break;
- }
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> gc(const v8::Arguments &args)
-{
- Q_UNUSED(args);
- QV8Engine::gc();
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> consoleError(const v8::Arguments &args)
-{
- return console(Error, args);
-}
-
-v8::Handle<v8::Value> consoleLog(const v8::Arguments &args)
-{
- //console.log
- //console.debug
- //console.info
- //print
- return console(Log, args);
-}
-
-v8::Handle<v8::Value> consoleProfile(const v8::Arguments &args)
-{
- //DeclarativeDebugTrace cannot handle nested profiling
- //although v8 can handle several profiling at once,
- //we do not allow that. Hence, we pass an empty(default) title
- Q_UNUSED(args);
- QString title;
-
-
-
- v8::Handle<v8::Value> file;
- v8::Handle<v8::Value> function;
- int line;
- jsContext(&file, &line, &function);
-
- if (QDeclarativeProfilerService::startProfiling()) {
- QV8ProfilerService::instance()->startProfiling(title);
-
- QMessageLogger(*v8::String::AsciiValue(file), line,
- *v8::String::AsciiValue(function)).debug("Profiling started.");
- } else {
- QMessageLogger(*v8::String::AsciiValue(file), line,
- *v8::String::AsciiValue(function)).warning(
- "Profiling is already in progress. First, end current profiling session.");
- }
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> consoleProfileEnd(const v8::Arguments &args)
-{
- //DeclarativeDebugTrace cannot handle nested profiling
- //although v8 can handle several profiling at once,
- //we do not allow that. Hence, we pass an empty(default) title
- Q_UNUSED(args);
- QString title;
-
- v8::Handle<v8::Value> file;
- v8::Handle<v8::Value> function;
- int line;
- jsContext(&file, &line, &function);
-
- if (QDeclarativeProfilerService::stopProfiling()) {
- QV8ProfilerService *profiler = QV8ProfilerService::instance();
- profiler->stopProfiling(title);
- QDeclarativeProfilerService::sendProfilingData();
- profiler->sendProfilingData();
-
- QMessageLogger(*v8::String::AsciiValue(file), line,
- *v8::String::AsciiValue(function)).debug("Profiling ended.");
- } else {
- QMessageLogger(*v8::String::AsciiValue(file), line,
- *v8::String::AsciiValue(function)).warning("Profiling was not started.");
- }
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> consoleTime(const v8::Arguments &args)
-{
- if (args.Length() != 1)
- V8THROW_ERROR("console.time(): Invalid arguments");
- QString name = V8ENGINE()->toString(args[0]);
- V8ENGINE()->startTimer(name);
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> consoleTimeEnd(const v8::Arguments &args)
-{
- if (args.Length() != 1)
- V8THROW_ERROR("console.time(): Invalid arguments");
- QString name = V8ENGINE()->toString(args[0]);
- bool wasRunning;
- qint64 elapsed = V8ENGINE()->stopTimer(name, &wasRunning);
- if (wasRunning) {
- qDebug("%s: %llims", qPrintable(name), elapsed);
- }
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> consoleCount(const v8::Arguments &args)
-{
- // first argument: name to print. Ignore any additional arguments
- QString name;
- if (args.Length() > 0)
- name = V8ENGINE()->toString(args[0]);
-
- v8::Handle<v8::StackTrace> stackTrace =
- v8::StackTrace::CurrentStackTrace(1, v8::StackTrace::kOverview);
-
- if (stackTrace->GetFrameCount()) {
- v8::Local<v8::StackFrame> frame = stackTrace->GetFrame(0);
-
- QString scriptName = V8ENGINE()->toString(frame->GetScriptName());
- QString functionName = V8ENGINE()->toString(frame->GetFunctionName());
- int line = frame->GetLineNumber();
- int column = frame->GetColumn();
-
- int value = V8ENGINE()->consoleCountHelper(scriptName, line, column);
- QString message = name + QLatin1String(": ") + QString::number(value);
-
- QMessageLogger(qPrintable(scriptName), line,
- qPrintable(functionName)).debug("%s", qPrintable(message));
- }
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> consoleTrace(const v8::Arguments &args)
-{
- if (args.Length() != 0)
- V8THROW_ERROR("console.trace(): Invalid arguments");
-
- QString stack = jsStack();
-
- v8::Handle<v8::Value> file;
- v8::Handle<v8::Value> function;
- int line;
- jsContext(&file, &line, &function);
-
- QMessageLogger(*v8::String::AsciiValue(file), line, *v8::String::AsciiValue(function)).debug(
- "%s", qPrintable(stack));
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> consoleWarn(const v8::Arguments &args)
-{
- return console(Warn, args);
-}
-
-v8::Handle<v8::Value> consoleAssert(const v8::Arguments &args)
-{
- if (args.Length() == 0)
- V8THROW_ERROR("console.assert(): Missing argument");
-
- if (!args[0]->ToBoolean()->Value()) {
- QString message;
- for (int i = 1; i < args.Length(); ++i) {
- if (i != 1)
- message.append(QLatin1Char(' '));
-
- v8::Local<v8::Value> value = args[i];
- message.append(V8ENGINE()->toString(value->ToString()));
- }
-
- QString stack = jsStack();
-
- v8::Handle<v8::Value> file;
- v8::Handle<v8::Value> function;
- int line;
- jsContext(&file, &line, &function);
-
- QMessageLogger(*v8::String::AsciiValue(file), line, *v8::String::AsciiValue(function)).critical(
- "%s\n%s", qPrintable(message), qPrintable(stack));
-
- }
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> consoleException(const v8::Arguments &args)
-{
- if (args.Length() == 0)
- V8THROW_ERROR("console.exception(): Missing argument");
-
- console(Error, args, true);
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> stringArg(const v8::Arguments &args)
-{
- QString value = V8ENGINE()->toString(args.This()->ToString());
- if (args.Length() != 1)
- V8THROW_ERROR("String.arg(): Invalid arguments");
-
- v8::Handle<v8::Value> arg = args[0];
- if (arg->IsUint32())
- return V8ENGINE()->toString(value.arg(arg->Uint32Value()));
- else if (arg->IsInt32())
- return V8ENGINE()->toString(value.arg(arg->Int32Value()));
- else if (arg->IsNumber())
- return V8ENGINE()->toString(value.arg(arg->NumberValue()));
- else if (arg->IsBoolean())
- return V8ENGINE()->toString(value.arg(arg->BooleanValue()));
-
- return V8ENGINE()->toString(value.arg(V8ENGINE()->toString(arg)));
-}
-
-/*!
-\qmlmethod bool Qt::isQtObject(object)
-Returns true if \c object is a valid reference to a Qt or QML object, otherwise false.
-*/
-v8::Handle<v8::Value> isQtObject(const v8::Arguments &args)
-{
- if (args.Length() == 0)
- return v8::Boolean::New(false);
-
- return v8::Boolean::New(0 != V8ENGINE()->toQObject(args[0]));
-}
-
-/*!
-\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
-
-Returns a color with the specified \c red, \c green, \c blue and \c alpha components.
-All components should be in the range 0-1 inclusive.
-*/
-v8::Handle<v8::Value> rgba(const v8::Arguments &args)
-{
- int argCount = args.Length();
- if (argCount < 3 || argCount > 4)
- V8THROW_ERROR("Qt.rgba(): Invalid arguments");
-
- double r = args[0]->NumberValue();
- double g = args[1]->NumberValue();
- double b = args[2]->NumberValue();
- double a = (argCount == 4) ? args[3]->NumberValue() : 1;
-
- if (r < 0.0) r=0.0;
- if (r > 1.0) r=1.0;
- if (g < 0.0) g=0.0;
- if (g > 1.0) g=1.0;
- if (b < 0.0) b=0.0;
- if (b > 1.0) b=1.0;
- if (a < 0.0) a=0.0;
- if (a > 1.0) a=1.0;
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(QColor::fromRgbF(r, g, b, a)));
-}
-
-/*!
-\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha)
-
-Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
-All components should be in the range 0-1 inclusive.
-*/
-v8::Handle<v8::Value> hsla(const v8::Arguments &args)
-{
- int argCount = args.Length();
- if (argCount < 3 || argCount > 4)
- V8THROW_ERROR("Qt.hsla(): Invalid arguments");
-
- double h = args[0]->NumberValue();
- double s = args[1]->NumberValue();
- double l = args[2]->NumberValue();
- double a = (argCount == 4) ? args[3]->NumberValue() : 1;
-
- if (h < 0.0) h=0.0;
- if (h > 1.0) h=1.0;
- if (s < 0.0) s=0.0;
- if (s > 1.0) s=1.0;
- if (l < 0.0) l=0.0;
- if (l > 1.0) l=1.0;
- if (a < 0.0) a=0.0;
- if (a > 1.0) a=1.0;
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(QColor::fromHslF(h, s, l, a)));
-}
-
-/*!
-\qmlmethod rect Qt::rect(int x, int y, int width, int height)
-
-Returns a \c rect with the top-left corner at \c x, \c y and the specified \c width and \c height.
-
-The returned object has \c x, \c y, \c width and \c height attributes with the given values.
-*/
-v8::Handle<v8::Value> rect(const v8::Arguments &args)
-{
- if (args.Length() != 4)
- V8THROW_ERROR("Qt.rect(): Invalid arguments");
-
- double x = args[0]->NumberValue();
- double y = args[1]->NumberValue();
- double w = args[2]->NumberValue();
- double h = args[3]->NumberValue();
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(QRectF(x, y, w, h)));
-}
-
-/*!
-\qmlmethod point Qt::point(int x, int y)
-Returns a Point with the specified \c x and \c y coordinates.
-*/
-v8::Handle<v8::Value> point(const v8::Arguments &args)
-{
- if (args.Length() != 2)
- V8THROW_ERROR("Qt.point(): Invalid arguments");
-
- double x = args[0]->ToNumber()->Value();
- double y = args[1]->ToNumber()->Value();
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(QPointF(x, y)));
-}
-
-/*!
-\qmlmethod Qt::size(int width, int height)
-Returns a Size with the specified \c width and \c height.
-*/
-v8::Handle<v8::Value> size(const v8::Arguments &args)
-{
- if (args.Length() != 2)
- V8THROW_ERROR("Qt.size(): Invalid arguments");
-
- double w = args[0]->ToNumber()->Value();
- double h = args[1]->ToNumber()->Value();
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(QSizeF(w, h)));
-}
-
-/*!
-\qmlmethod Qt::vector3d(real x, real y, real z)
-Returns a Vector3D with the specified \c x, \c y and \c z.
-*/
-v8::Handle<v8::Value> vector3d(const v8::Arguments &args)
-{
- if (args.Length() != 3)
- V8THROW_ERROR("Qt.vector(): Invalid arguments");
-
- double x = args[0]->ToNumber()->Value();
- double y = args[1]->ToNumber()->Value();
- double z = args[2]->ToNumber()->Value();
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(QVector3D(x, y, z)));
-}
-
-/*!
-\qmlmethod Qt::vector4d(real x, real y, real z, real w)
-Returns a Vector4D with the specified \c x, \c y, \c z and \c w.
-*/
-v8::Handle<v8::Value> vector4d(const v8::Arguments &args)
-{
- if (args.Length() != 4)
- V8THROW_ERROR("Qt.vector4d(): Invalid arguments");
-
- double x = args[0]->NumberValue();
- double y = args[1]->NumberValue();
- double z = args[2]->NumberValue();
- double w = args[3]->NumberValue();
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(QVector4D(x, y, z, w)));
-}
-
-/*!
-\qmlmethod color Qt::lighter(color baseColor, real factor)
-Returns a color lighter than \c baseColor by the \c factor provided.
-
-If the factor is greater than 1.0, this functions returns a lighter color.
-Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0,
-the return color is darker, but we recommend using the Qt.darker() function for this purpose.
-If the factor is 0 or negative, the return value is unspecified.
-
-The function converts the current RGB color to HSV, multiplies the value (V) component
-by factor and converts the color back to RGB.
-
-If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5).
-*/
-v8::Handle<v8::Value> lighter(const v8::Arguments &args)
-{
- if (args.Length() != 1 && args.Length() != 2)
- V8THROW_ERROR("Qt.lighter(): Invalid arguments");
-
- QColor color;
- QVariant v = V8ENGINE()->toVariant(args[0], -1);
- if (v.userType() == QVariant::Color) {
- color = v.value<QColor>();
- } else if (v.userType() == QVariant::String) {
- bool ok = false;
- color = QDeclarativeStringConverters::colorFromString(v.toString(), &ok);
- if (!ok) {
- return v8::Null();
- }
- } else {
- return v8::Null();
- }
-
- qreal factor = 1.5;
- if (args.Length() == 2)
- factor = args[1]->ToNumber()->Value();
-
- color = color.lighter(int(qRound(factor*100.)));
- return V8ENGINE()->fromVariant(QVariant::fromValue(color));
-}
-
-/*!
-\qmlmethod color Qt::darker(color baseColor, real factor)
-Returns a color darker than \c baseColor by the \c factor provided.
-
-If the factor is greater than 1.0, this function returns a darker color.
-Setting factor to 3.0 returns a color that has one-third the brightness.
-If the factor is less than 1.0, the return color is lighter, but we recommend using
-the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return
-value is unspecified.
-
-The function converts the current RGB color to HSV, divides the value (V) component
-by factor and converts the color back to RGB.
-
-If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0).
-*/
-v8::Handle<v8::Value> darker(const v8::Arguments &args)
-{
- if (args.Length() != 1 && args.Length() != 2)
- V8THROW_ERROR("Qt.darker(): Invalid arguments");
-
- QColor color;
- QVariant v = V8ENGINE()->toVariant(args[0], -1);
- if (v.userType() == QVariant::Color) {
- color = v.value<QColor>();
- } else if (v.userType() == QVariant::String) {
- bool ok = false;
- color = QDeclarativeStringConverters::colorFromString(v.toString(), &ok);
- if (!ok) {
- return v8::Null();
- }
- } else {
- return v8::Null();
- }
-
- qreal factor = 2.0;
- if (args.Length() == 2)
- factor = args[1]->ToNumber()->Value();
-
- color = color.darker(int(qRound(factor*100.)));
- return V8ENGINE()->fromVariant(QVariant::fromValue(color));
-}
-
-/*!
- \qmlmethod color Qt::tint(color baseColor, color tintColor)
- This function allows tinting one color with another.
-
- The tint color should usually be mostly transparent, or you will not be
- able to see the underlying color. The below example provides a slight red
- tint by having the tint color be pure red which is only 1/16th opaque.
-
- \qml
- Item {
- Rectangle {
- x: 0; width: 80; height: 80
- color: "lightsteelblue"
- }
- Rectangle {
- x: 100; width: 80; height: 80
- color: Qt.tint("lightsteelblue", "#10FF0000")
- }
- }
- \endqml
- \image declarative-rect_tint.png
-
- Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color.
-*/
-v8::Handle<v8::Value> tint(const v8::Arguments &args)
-{
- if (args.Length() != 2)
- V8THROW_ERROR("Qt.tint(): Invalid arguments");
-
- // base color
- QColor color;
- QVariant v = V8ENGINE()->toVariant(args[0], -1);
- if (v.userType() == QVariant::Color) {
- color = v.value<QColor>();
- } else if (v.userType() == QVariant::String) {
- bool ok = false;
- color = QDeclarativeStringConverters::colorFromString(v.toString(), &ok);
- if (!ok) {
- return v8::Null();
- }
- } else {
- return v8::Null();
- }
-
- // tint color
- QColor tintColor;
- v = V8ENGINE()->toVariant(args[1], -1);
- if (v.userType() == QVariant::Color) {
- tintColor = v.value<QColor>();
- } else if (v.userType() == QVariant::String) {
- bool ok = false;
- tintColor = QDeclarativeStringConverters::colorFromString(v.toString(), &ok);
- if (!ok) {
- return v8::Null();
- }
- } else {
- return v8::Null();
- }
-
- // tint the base color and return the final color
- QColor finalColor;
- int a = tintColor.alpha();
- if (a == 0xFF)
- finalColor = tintColor;
- else if (a == 0x00)
- finalColor = color;
- else {
- qreal a = tintColor.alphaF();
- qreal inv_a = 1.0 - a;
-
- finalColor.setRgbF(tintColor.redF() * a + color.redF() * inv_a,
- tintColor.greenF() * a + color.greenF() * inv_a,
- tintColor.blueF() * a + color.blueF() * inv_a,
- a + inv_a * color.alphaF());
- }
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(finalColor));
-}
-
-/*!
-\qmlmethod string Qt::formatDate(datetime date, variant format)
-
-Returns a string representation of \c date, optionally formatted according
-to \c format.
-
-The \a date parameter may be a JavaScript \c Date object, a \l{date}{date}
-property, a QDate, or QDateTime value. The \a format parameter may be any of
-the possible format values as described for
-\l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}.
-
-If \a format is not specified, \a date is formatted using
-\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}.
-
-\sa Locale
-*/
-v8::Handle<v8::Value> formatDate(const v8::Arguments &args)
-{
- if (args.Length() < 1 || args.Length() > 2)
- V8THROW_ERROR("Qt.formatDate(): Invalid arguments");
-
- Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
- QDate date = V8ENGINE()->toVariant(args[0], -1).toDateTime().date();
- QString formattedDate;
- if (args.Length() == 2) {
- if (args[1]->IsString()) {
- QString format = V8ENGINE()->toVariant(args[1], -1).toString();
- formattedDate = date.toString(format);
- } else if (args[1]->IsNumber()) {
- quint32 intFormat = args[1]->ToNumber()->Value();
- Qt::DateFormat format = Qt::DateFormat(intFormat);
- formattedDate = date.toString(format);
- } else {
- V8THROW_ERROR("Qt.formatDate(): Invalid date format");
- }
- } else {
- formattedDate = date.toString(enumFormat);
- }
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(formattedDate));
-}
-
-/*!
-\qmlmethod string Qt::formatTime(datetime time, variant format)
-
-Returns a string representation of \c time, optionally formatted according to
-\c format.
-
-The \a time parameter may be a JavaScript \c Date object, a QTime, or QDateTime
-value. The \a format parameter may be any of the possible format values as
-described for \l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}.
-
-If \a format is not specified, \a time is formatted using
-\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}.
-
-\sa Locale
-*/
-v8::Handle<v8::Value> formatTime(const v8::Arguments &args)
-{
- if (args.Length() < 1 || args.Length() > 2)
- V8THROW_ERROR("Qt.formatTime(): Invalid arguments");
-
- QVariant argVariant = V8ENGINE()->toVariant(args[0], -1);
- QTime time;
- if (args[0]->IsDate() || (argVariant.type() == QVariant::String))
- time = argVariant.toDateTime().time();
- else // if (argVariant.type() == QVariant::Time), or invalid.
- time = argVariant.toTime();
-
- Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
- QString formattedTime;
- if (args.Length() == 2) {
- if (args[1]->IsString()) {
- QString format = V8ENGINE()->toVariant(args[1], -1).toString();
- formattedTime = time.toString(format);
- } else if (args[1]->IsNumber()) {
- quint32 intFormat = args[1]->ToNumber()->Value();
- Qt::DateFormat format = Qt::DateFormat(intFormat);
- formattedTime = time.toString(format);
- } else {
- V8THROW_ERROR("Qt.formatTime(): Invalid time format");
- }
- } else {
- formattedTime = time.toString(enumFormat);
- }
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(formattedTime));
-}
-
-/*!
-\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format)
-
-Returns a string representation of \c datetime, optionally formatted according to
-\c format.
-
-The \a date parameter may be a JavaScript \c Date object, a \l{date}{date}
-property, a QDate, QTime, or QDateTime value.
-
-If \a format is not provided, \a dateTime is formatted using
-\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}. Otherwise,
-\a format should be either:
-
-\list
-\o One of the Qt::DateFormat enumeration values, such as
- \c Qt.DefaultLocaleShortDate or \c Qt.ISODate
-\o A string that specifies the format of the returned string, as detailed below.
-\endlist
-
-If \a format specifies a format string, it should use the following expressions
-to specify the date:
-
- \table
- \header \i Expression \i Output
- \row \i d \i the day as number without a leading zero (1 to 31)
- \row \i dd \i the day as number with a leading zero (01 to 31)
- \row \i ddd
- \i the abbreviated localized day name (e.g. 'Mon' to 'Sun').
- Uses QDate::shortDayName().
- \row \i dddd
- \i the long localized day name (e.g. 'Monday' to 'Qt::Sunday').
- Uses QDate::longDayName().
- \row \i M \i the month as number without a leading zero (1-12)
- \row \i MM \i the month as number with a leading zero (01-12)
- \row \i MMM
- \i the abbreviated localized month name (e.g. 'Jan' to 'Dec').
- Uses QDate::shortMonthName().
- \row \i MMMM
- \i the long localized month name (e.g. 'January' to 'December').
- Uses QDate::longMonthName().
- \row \i yy \i the year as two digit number (00-99)
- \row \i yyyy \i the year as four digit number
- \endtable
-
-In addition the following expressions can be used to specify the time:
-
- \table
- \header \i Expression \i Output
- \row \i h
- \i the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
- \row \i hh
- \i the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
- \row \i m \i the minute without a leading zero (0 to 59)
- \row \i mm \i the minute with a leading zero (00 to 59)
- \row \i s \i the second without a leading zero (0 to 59)
- \row \i ss \i the second with a leading zero (00 to 59)
- \row \i z \i the milliseconds without leading zeroes (0 to 999)
- \row \i zzz \i the milliseconds with leading zeroes (000 to 999)
- \row \i AP
- \i use AM/PM display. \e AP will be replaced by either "AM" or "PM".
- \row \i ap
- \i use am/pm display. \e ap will be replaced by either "am" or "pm".
- \endtable
-
- All other input characters will be ignored. Any sequence of characters that
- are enclosed in single quotes will be treated as text and not be used as an
- expression. Two consecutive single quotes ("''") are replaced by a single quote
- in the output.
-
-For example, if the following date/time value was specified:
-
- \code
- // 21 May 2001 14:13:09
- var dateTime = new Date(2001, 5, 21, 14, 13, 09)
- \endcode
-
-This \a dateTime value could be passed to \c Qt.formatDateTime(),
-\l {QML:Qt::formatDate()}{Qt.formatDate()} or \l {QML:Qt::formatTime()}{Qt.formatTime()}
-with the \a format values below to produce the following results:
-
- \table
- \header \i Format \i Result
- \row \i "dd.MM.yyyy" \i 21.05.2001
- \row \i "ddd MMMM d yy" \i Tue May 21 01
- \row \i "hh:mm:ss.zzz" \i 14:13:09.042
- \row \i "h:m:s ap" \i 2:13:9 pm
- \endtable
-
- \sa Locale
-*/
-v8::Handle<v8::Value> formatDateTime(const v8::Arguments &args)
-{
- if (args.Length() < 1 || args.Length() > 2)
- V8THROW_ERROR("Qt.formatDateTime(): Invalid arguments");
-
- Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
- QDateTime dt = V8ENGINE()->toVariant(args[0], -1).toDateTime();
- QString formattedDt;
- if (args.Length() == 2) {
- if (args[1]->IsString()) {
- QString format = V8ENGINE()->toVariant(args[1], -1).toString();
- formattedDt = dt.toString(format);
- } else if (args[1]->IsNumber()) {
- quint32 intFormat = args[1]->ToNumber()->Value();
- Qt::DateFormat format = Qt::DateFormat(intFormat);
- formattedDt = dt.toString(format);
- } else {
- V8THROW_ERROR("Qt.formatDateTime(): Invalid datetime format");
- }
- } else {
- formattedDt = dt.toString(enumFormat);
- }
-
- return V8ENGINE()->fromVariant(QVariant::fromValue(formattedDt));
-}
-
-/*!
-\qmlmethod bool Qt::openUrlExternally(url target)
-Attempts to open the specified \c target url in an external application, based on the user's desktop preferences. Returns true if it succeeds, and false otherwise.
-*/
-v8::Handle<v8::Value> openUrlExternally(const v8::Arguments &args)
-{
- if (args.Length() != 1)
- return V8ENGINE()->fromVariant(false);
-
- bool ret = false;
-#ifndef QT_NO_DESKTOPSERVICES
- ret = QDesktopServices::openUrl(V8ENGINE()->toVariant(resolvedUrl(args), -1).toUrl());
-#endif
- return V8ENGINE()->fromVariant(ret);
-}
-
-/*!
- \qmlmethod url Qt::resolvedUrl(url url)
- Returns \a url resolved relative to the URL of the caller.
-*/
-v8::Handle<v8::Value> resolvedUrl(const v8::Arguments &args)
-{
- QUrl url = V8ENGINE()->toVariant(args[0], -1).toUrl();
- QDeclarativeEngine *e = V8ENGINE()->engine();
- QDeclarativeEnginePrivate *p = 0;
- if (e) p = QDeclarativeEnginePrivate::get(e);
- if (p) {
- QDeclarativeContextData *ctxt = V8ENGINE()->callingContext();
- if (ctxt)
- return V8ENGINE()->toString(ctxt->resolvedUrl(url).toString());
- else
- return V8ENGINE()->toString(url.toString());
- }
-
- return V8ENGINE()->toString(e->baseUrl().resolved(url).toString());
-}
-
-/*!
-\qmlmethod list<string> Qt::fontFamilies()
-Returns a list of the font families available to the application.
-*/
-v8::Handle<v8::Value> fontFamilies(const v8::Arguments &args)
-{
- if (args.Length() != 0)
- V8THROW_ERROR("Qt.fontFamilies(): Invalid arguments");
-
- QFontDatabase database;
- return V8ENGINE()->fromVariant(database.families());
-}
-
-/*!
-\qmlmethod string Qt::md5(data)
-Returns a hex string of the md5 hash of \c data.
-*/
-v8::Handle<v8::Value> md5(const v8::Arguments &args)
-{
- if (args.Length() != 1)
- V8THROW_ERROR("Qt.md5(): Invalid arguments");
-
- QByteArray data = V8ENGINE()->toString(args[0]->ToString()).toUtf8();
- QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5);
- return V8ENGINE()->toString(QLatin1String(result.toHex()));
-}
-
-/*!
-\qmlmethod string Qt::btoa(data)
-Binary to ASCII - this function returns a base64 encoding of \c data.
-*/
-v8::Handle<v8::Value> btoa(const v8::Arguments &args)
-{
- if (args.Length() != 1)
- V8THROW_ERROR("Qt.btoa(): Invalid arguments");
-
- QByteArray data = V8ENGINE()->toString(args[0]->ToString()).toUtf8();
-
- return V8ENGINE()->toString(QLatin1String(data.toBase64()));
-}
-
-/*!
-\qmlmethod string Qt::atob(data)
-ASCII to binary - this function returns a base64 decoding of \c data.
-*/
-v8::Handle<v8::Value> atob(const v8::Arguments &args)
-{
- if (args.Length() != 1)
- V8THROW_ERROR("Qt.atob(): Invalid arguments");
-
- QByteArray data = V8ENGINE()->toString(args[0]->ToString()).toUtf8();
-
- return V8ENGINE()->toString(QLatin1String(QByteArray::fromBase64(data)));
-}
-
-/*!
-\qmlmethod Qt::quit()
-This function causes the QDeclarativeEngine::quit() signal to be emitted.
-Within the \l {QML Viewer}, this causes the launcher application to exit;
-to quit a C++ application when this method is called, connect the
-QDeclarativeEngine::quit() signal to the QCoreApplication::quit() slot.
-*/
-v8::Handle<v8::Value> quit(const v8::Arguments &args)
-{
- QDeclarativeEnginePrivate::get(V8ENGINE()->engine())->sendQuit();
- return v8::Undefined();
-}
-
-/*!
-\qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath)
-
-Returns a new object created from the given \a string of QML which will have the specified \a parent,
-or \c null if there was an error in creating the object.
-
-If \a filepath is specified, it will be used for error reporting for the created object.
-
-Example (where \c parentItem is the id of an existing QML item):
-
-\snippet doc/src/snippets/declarative/createQmlObject.qml 0
-
-In the case of an error, a QtScript Error object is thrown. This object has an additional property,
-\c qmlErrors, which is an array of the errors encountered.
-Each object in this array has the members \c lineNumber, \c columnNumber, \c fileName and \c message.
-For example, if the above snippet had misspelled color as 'colro' then the array would contain an object like the following:
-{ "lineNumber" : 1, "columnNumber" : 32, "fileName" : "dynamicSnippet1", "message" : "Cannot assign to non-existent property \"colro\""}.
-
-Note that this function returns immediately, and therefore may not work if
-the \a qml string loads new components (that is, external QML files that have not yet been loaded).
-If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead.
-
-See \l {Dynamic Object Management in QML} for more information on using this function.
-*/
-v8::Handle<v8::Value> createQmlObject(const v8::Arguments &args)
-{
- if (args.Length() < 2 || args.Length() > 3)
- V8THROW_ERROR("Qt.createQmlObject(): Invalid arguments");
-
- struct Error {
- static v8::Local<v8::Value> create(QV8Engine *engine, const QList<QDeclarativeError> &errors) {
- QString errorstr = QLatin1String("Qt.createQmlObject(): failed to create object: ");
-
- v8::Local<v8::Array> qmlerrors = v8::Array::New(errors.count());
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QDeclarativeError &error = errors.at(ii);
- errorstr += QLatin1String("\n ") + error.toString();
- v8::Local<v8::Object> qmlerror = v8::Object::New();
- qmlerror->Set(v8::String::New("lineNumber"), v8::Integer::New(error.line()));
- qmlerror->Set(v8::String::New("columnNumber"), v8::Integer::New(error.column()));
- qmlerror->Set(v8::String::New("fileName"), engine->toString(error.url().toString()));
- qmlerror->Set(v8::String::New("message"), engine->toString(error.description()));
- qmlerrors->Set(ii, qmlerror);
- }
-
- v8::Local<v8::Value> error = v8::Exception::Error(engine->toString(errorstr));
- v8::Local<v8::Object> errorObject = error->ToObject();
- errorObject->Set(v8::String::New("qmlErrors"), qmlerrors);
- return error;
- }
- };
-
- QV8Engine *v8engine = V8ENGINE();
- QDeclarativeEngine *engine = v8engine->engine();
-
- QDeclarativeContextData *context = v8engine->callingContext();
- QDeclarativeContext *effectiveContext = 0;
- if (context->isPragmaLibraryContext)
- effectiveContext = engine->rootContext();
- else
- effectiveContext = context->asQDeclarativeContext();
- Q_ASSERT(context && effectiveContext);
-
- QString qml = v8engine->toString(args[0]->ToString());
- if (qml.isEmpty())
- return v8::Null();
-
- QUrl url;
- if (args.Length() > 2)
- url = QUrl(v8engine->toString(args[2]->ToString()));
- else
- url = QUrl(QLatin1String("inline"));
-
- if (url.isValid() && url.isRelative())
- url = context->resolvedUrl(url);
-
- QObject *parentArg = v8engine->toQObject(args[1]);
- if (!parentArg)
- V8THROW_ERROR("Qt.createQmlObject(): Missing parent object");
-
- QDeclarativeComponent component(engine);
- component.setData(qml.toUtf8(), url);
-
- if (component.isError()) {
- v8::ThrowException(Error::create(v8engine, component.errors()));
- return v8::Undefined();
- }
-
- if (!component.isReady())
- V8THROW_ERROR("Qt.createQmlObject(): Component is not ready");
-
- QObject *obj = component.beginCreate(effectiveContext);
- if (obj) {
- QDeclarativeData::get(obj, true)->setImplicitDestructible();
-
- obj->setParent(parentArg);
-
- QList<QDeclarativePrivate::AutoParentFunction> functions = QDeclarativeMetaType::parentFunctions();
- for (int ii = 0; ii < functions.count(); ++ii) {
- if (QDeclarativePrivate::Parented == functions.at(ii)(obj, parentArg))
- break;
- }
- }
- component.completeCreate();
-
- if (component.isError()) {
- v8::ThrowException(Error::create(v8engine, component.errors()));
- return v8::Undefined();
- }
-
- Q_ASSERT(obj);
-
- return v8engine->newQObject(obj);
-}
-
-/*!
-\qmlmethod object Qt::createComponent(url)
-
-Returns a \l Component object created using the QML file at the specified \a url,
-or \c null if an empty string was given.
-
-The returned component's \l Component::status property indicates whether the
-component was successfully created. If the status is \c Component.Error,
-see \l Component::errorString() for an error description.
-
-Call \l {Component::createObject()}{Component.createObject()} on the returned
-component to create an object instance of the component.
-
-For example:
-
-\snippet doc/src/snippets/declarative/createComponent-simple.qml 0
-
-See \l {Dynamic Object Management in QML} for more information on using this function.
-
-To create a QML object from an arbitrary string of QML (instead of a file),
-use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}.
-*/
-v8::Handle<v8::Value> createComponent(const v8::Arguments &args)
-{
- if (args.Length() != 1)
- V8THROW_ERROR("Qt.createComponent(): Invalid arguments");
-
- QV8Engine *v8engine = V8ENGINE();
- QDeclarativeEngine *engine = v8engine->engine();
-
- QDeclarativeContextData *context = v8engine->callingContext();
- QDeclarativeContextData *effectiveContext = context;
- if (context->isPragmaLibraryContext)
- effectiveContext = 0;
- Q_ASSERT(context);
-
- QString arg = v8engine->toString(args[0]->ToString());
- if (arg.isEmpty())
- return v8::Null();
-
- QUrl url = context->resolvedUrl(QUrl(arg));
- QDeclarativeComponent *c = new QDeclarativeComponent(engine, url, engine);
- QDeclarativeComponentPrivate::get(c)->creationContext = effectiveContext;
- QDeclarativeData::get(c, true)->setImplicitDestructible();
- return v8engine->newQObject(c);
-}
-
-v8::Handle<v8::Value> qsTranslate(const v8::Arguments &args)
-{
- if (args.Length() < 2)
- V8THROW_ERROR("qsTranslate() requires at least two arguments");
- if (!args[0]->IsString())
- V8THROW_ERROR("qsTranslate(): first argument (context) must be a string");
- if (!args[1]->IsString())
- V8THROW_ERROR("qsTranslate(): second argument (text) must be a string");
- if ((args.Length() > 2) && !args[2]->IsString())
- V8THROW_ERROR("qsTranslate(): third argument (comment) must be a string");
- if ((args.Length() > 3) && !args[3]->IsString())
- V8THROW_ERROR("qsTranslate(): fourth argument (encoding) must be a string");
-
- QV8Engine *v8engine = V8ENGINE();
- QString context = v8engine->toString(args[0]);
- QString text = v8engine->toString(args[1]);
- QString comment;
- if (args.Length() > 2) comment = v8engine->toString(args[2]);
-
- QCoreApplication::Encoding encoding = QCoreApplication::UnicodeUTF8;
- if (args.Length() > 3) {
- QString encStr = v8engine->toString(args[3]);
- if (encStr == QLatin1String("CodecForTr")) {
- encoding = QCoreApplication::CodecForTr;
- } else if (encStr == QLatin1String("UnicodeUTF8")) {
- encoding = QCoreApplication::UnicodeUTF8;
- } else {
- QString msg = QString::fromLatin1("qsTranslate(): invalid encoding '%0'").arg(encStr);
- V8THROW_ERROR((uint16_t *)msg.constData());
- }
- }
-
- int n = -1;
- if (args.Length() > 4)
- n = args[4]->Int32Value();
-
- QString result = QCoreApplication::translate(context.toUtf8().constData(),
- text.toUtf8().constData(),
- comment.toUtf8().constData(),
- encoding, n);
-
- return v8engine->toString(result);
-}
-
-v8::Handle<v8::Value> qsTranslateNoOp(const v8::Arguments &args)
-{
- if (args.Length() < 2)
- return v8::Undefined();
- return args[1];
-}
-
-v8::Handle<v8::Value> qsTr(const v8::Arguments &args)
-{
- if (args.Length() < 1)
- V8THROW_ERROR("qsTr() requires at least one argument");
- if (!args[0]->IsString())
- V8THROW_ERROR("qsTr(): first argument (text) must be a string");
- if ((args.Length() > 1) && !args[1]->IsString())
- V8THROW_ERROR("qsTr(): second argument (comment) must be a string");
- if ((args.Length() > 2) && !args[2]->IsNumber())
- V8THROW_ERROR("qsTr(): third argument (n) must be a number");
-
- QV8Engine *v8engine = V8ENGINE();
- QDeclarativeContextData *ctxt = v8engine->callingContext();
-
- QString path = ctxt->url.toString();
- int lastSlash = path.lastIndexOf(QLatin1Char('/'));
- QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, path.length()-lastSlash-5) : QString();
-
- QString text = v8engine->toString(args[0]);
- QString comment;
- if (args.Length() > 1)
- comment = v8engine->toString(args[1]);
- int n = -1;
- if (args.Length() > 2)
- n = args[2]->Int32Value();
-
- QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(),
- comment.toUtf8().constData(), QCoreApplication::UnicodeUTF8, n);
-
- return v8engine->toString(result);
-}
-
-v8::Handle<v8::Value> qsTrNoOp(const v8::Arguments &args)
-{
- if (args.Length() < 1)
- return v8::Undefined();
- return args[0];
-}
-
-v8::Handle<v8::Value> qsTrId(const v8::Arguments &args)
-{
- if (args.Length() < 1)
- V8THROW_ERROR("qsTrId() requires at least one argument");
- if (!args[0]->IsString())
- V8THROW_TYPE("qsTrId(): first argument (id) must be a string");
- if (args.Length() > 1 && !args[1]->IsNumber())
- V8THROW_TYPE("qsTrId(): second argument (n) must be a number");
-
- int n = -1;
- if (args.Length() > 1)
- n = args[1]->Int32Value();
-
- QV8Engine *v8engine = V8ENGINE();
- return v8engine->toString(qtTrId(v8engine->toString(args[0]).toUtf8().constData(), n));
-}
-
-v8::Handle<v8::Value> qsTrIdNoOp(const v8::Arguments &args)
-{
- if (args.Length() < 1)
- return v8::Undefined();
- return args[0];
-}
-
-
-/*!
- \qmlmethod Qt::locale(name)
-
- Returns a JS object representing the locale with the specified
- name, which has the format "language[_territory][.codeset][@modifier]"
- or "C", where:
-
- \list
- \o language is a lowercase, two-letter, ISO 639 language code,
- \o territory is an uppercase, two-letter, ISO 3166 country code,
- \o and codeset and modifier are ignored.
- \endlist
-
- If the string violates the locale format, or language is not a
- valid ISO 369 code, the "C" locale is used instead. If country
- is not present, or is not a valid ISO 3166 code, the most
- appropriate country is chosen for the specified language.
-
- \sa QtQuick2::Locale
-*/
-v8::Handle<v8::Value> locale(const v8::Arguments &args)
-{
- QString code;
- if (args.Length() > 1)
- V8THROW_ERROR("locale() requires 0 or 1 argument");
- if (args.Length() == 1 && !args[0]->IsString())
- V8THROW_TYPE("locale(): argument (locale code) must be a string");
-
- QV8Engine *v8engine = V8ENGINE();
- if (args.Length() == 1)
- code = v8engine->toString(args[0]);
-
- return QDeclarativeLocale::locale(v8engine, code);
-}
-
-} // namespace QDeclarativeBuiltinFunctions
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qdeclarativebuiltinfunctions_p.h b/src/declarative/qml/v8/qdeclarativebuiltinfunctions_p.h
deleted file mode 100644
index d5780dc70d..0000000000
--- a/src/declarative/qml/v8/qdeclarativebuiltinfunctions_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEBUILTINFUNCTIONS_P_H
-#define QDECLARATIVEBUILTINFUNCTIONS_P_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 <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QDeclarativeBuiltinFunctions
-{
-v8::Handle<v8::Value> gc(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleError(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleLog(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleProfile(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleProfileEnd(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleTime(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleTimeEnd(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleCount(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleTrace(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleWarn(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleAssert(const v8::Arguments &args);
-v8::Handle<v8::Value> consoleException(const v8::Arguments &args);
-v8::Handle<v8::Value> isQtObject(const v8::Arguments &args);
-v8::Handle<v8::Value> rgba(const v8::Arguments &args);
-v8::Handle<v8::Value> hsla(const v8::Arguments &args);
-v8::Handle<v8::Value> rect(const v8::Arguments &args);
-v8::Handle<v8::Value> point(const v8::Arguments &args);
-v8::Handle<v8::Value> size(const v8::Arguments &args);
-v8::Handle<v8::Value> vector3d(const v8::Arguments &args);
-v8::Handle<v8::Value> vector4d(const v8::Arguments &args);
-v8::Handle<v8::Value> lighter(const v8::Arguments &args);
-v8::Handle<v8::Value> darker(const v8::Arguments &args);
-v8::Handle<v8::Value> tint(const v8::Arguments &args);
-v8::Handle<v8::Value> formatDate(const v8::Arguments &args);
-v8::Handle<v8::Value> formatTime(const v8::Arguments &args);
-v8::Handle<v8::Value> formatDateTime(const v8::Arguments &args);
-v8::Handle<v8::Value> openUrlExternally(const v8::Arguments &args);
-v8::Handle<v8::Value> fontFamilies(const v8::Arguments &args);
-v8::Handle<v8::Value> md5(const v8::Arguments &args);
-v8::Handle<v8::Value> btoa(const v8::Arguments &args);
-v8::Handle<v8::Value> atob(const v8::Arguments &args);
-v8::Handle<v8::Value> quit(const v8::Arguments &args);
-v8::Handle<v8::Value> resolvedUrl(const v8::Arguments &args);
-v8::Handle<v8::Value> createQmlObject(const v8::Arguments &args);
-v8::Handle<v8::Value> createComponent(const v8::Arguments &args);
-v8::Handle<v8::Value> qsTranslate(const v8::Arguments &args);
-v8::Handle<v8::Value> qsTranslateNoOp(const v8::Arguments &args);
-v8::Handle<v8::Value> qsTr(const v8::Arguments &args);
-v8::Handle<v8::Value> qsTrNoOp(const v8::Arguments &args);
-v8::Handle<v8::Value> qsTrId(const v8::Arguments &args);
-v8::Handle<v8::Value> qsTrIdNoOp(const v8::Arguments &args);
-v8::Handle<v8::Value> stringArg(const v8::Arguments &args);
-v8::Handle<v8::Value> locale(const v8::Arguments &args);
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEBUILTINFUNCTIONS_P_H
diff --git a/src/declarative/qml/v8/qjsconverter_impl_p.h b/src/declarative/qml/v8/qjsconverter_impl_p.h
deleted file mode 100644
index 018c0441a2..0000000000
--- a/src/declarative/qml/v8/qjsconverter_impl_p.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qjsconverter_p.h"
-
-#ifndef QJSCONVERTER_IMPL_P_H
-#define QJSCONVERTER_IMPL_P_H
-
-QT_BEGIN_NAMESPACE
-
-extern char *qdtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **digits_str);
-Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
-
-
-quint32 QJSConverter::toArrayIndex(const QString& string)
-{
- // FIXME this function should be exported by JSC C API.
- bool ok;
- quint32 idx = string.toUInt(&ok);
- if (!ok || toString(idx) != string)
- idx = 0xffffffff;
-
- return idx;
-}
-
-QString QJSConverter::toString(v8::Handle<v8::String> jsString)
-{
- if (jsString.IsEmpty())
- return QString();
- QString qstr;
- qstr.resize(jsString->Length());
- jsString->Write(reinterpret_cast<uint16_t*>(qstr.data()));
- return qstr;
-}
-
-v8::Local<v8::String> QJSConverter::toString(const QString& string)
-{
- return v8::String::New(reinterpret_cast<const uint16_t*>(string.data()), string.size());
-}
-
-QString QJSConverter::toString(double value)
-{
- // FIXME this should be easier. The ideal fix is to create
- // a new function in V8 API which could cover the functionality.
-
- if (qIsNaN(value))
- return QString::fromLatin1("NaN");
- if (qIsInf(value))
- return QString::fromLatin1(value < 0 ? "-Infinity" : "Infinity");
- if (!value)
- return QString::fromLatin1("0");
-
- QVarLengthArray<char, 25> buf;
- int decpt;
- int sign;
- char* result = 0;
- char* endresult;
- (void)qdtoa(value, 0, 0, &decpt, &sign, &endresult, &result);
-
- if (!result)
- return QString();
-
- int resultLen = endresult - result;
- if (decpt <= 0 && decpt > -6) {
- buf.resize(-decpt + 2 + sign);
- qMemSet(buf.data(), '0', -decpt + 2 + sign);
- if (sign) // fix the sign.
- buf[0] = '-';
- buf[sign + 1] = '.';
- buf.append(result, resultLen);
- } else {
- if (sign)
- buf.append('-');
- int length = buf.size() - sign + resultLen;
- if (decpt <= 21 && decpt > 0) {
- if (length <= decpt) {
- const char* zeros = "0000000000000000000000000";
- buf.append(result, resultLen);
- buf.append(zeros, decpt - length);
- } else {
- buf.append(result, decpt);
- buf.append('.');
- buf.append(result + decpt, resultLen - decpt);
- }
- } else if (result[0] >= '0' && result[0] <= '9') {
- if (length > 1) {
- buf.append(result, 1);
- buf.append('.');
- buf.append(result + 1, resultLen - 1);
- } else
- buf.append(result, resultLen);
- buf.append('e');
- buf.append(decpt >= 0 ? '+' : '-');
- int e = qAbs(decpt - 1);
- if (e >= 100)
- buf.append('0' + e / 100);
- if (e >= 10)
- buf.append('0' + (e % 100) / 10);
- buf.append('0' + e % 10);
- }
- }
- free(result);
- buf.append(0);
- return QString::fromLatin1(buf.constData());
-}
-
-// return a mask of v8::PropertyAttribute that may also contains QScriptValue::PropertyGetter or QScriptValue::PropertySetter
-uint QJSConverter::toPropertyAttributes(const QFlags<QJSValuePrivate::PropertyFlag>& flags)
-{
- uint attr = 0;
- if (flags.testFlag(QJSValuePrivate::ReadOnly))
- attr |= v8::ReadOnly;
- if (flags.testFlag(QJSValuePrivate::Undeletable))
- attr |= v8::DontDelete;
- if (flags.testFlag(QJSValuePrivate::SkipInEnumeration))
- attr |= v8::DontEnum;
- // if (flags.testFlag(QScriptValue::PropertyGetter))
- // attr |= QScriptValue::PropertyGetter;
- // if (flags.testFlag(QScriptValue::PropertySetter))
- // attr |= QScriptValue::PropertySetter;
- return attr;
-}
-
-// Converts a JS RegExp to a QRegExp.
-// The conversion is not 100% exact since ECMA regexp and QRegExp
-// have different semantics/flags, but we try to do our best.
-QRegExp QJSConverter::toRegExp(v8::Handle<v8::RegExp> jsRegExp)
-{
- QString pattern = QJSConverter::toString(jsRegExp->GetSource());
- Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive;
- if (jsRegExp->GetFlags() & v8::RegExp::kIgnoreCase)
- caseSensitivity = Qt::CaseInsensitive;
- return QRegExp(pattern, caseSensitivity, QRegExp::RegExp2);
-}
-
-// Converts a QRegExp to a JS RegExp.
-// The conversion is not 100% exact since ECMA regexp and QRegExp
-// have different semantics/flags, but we try to do our best.
-v8::Local<v8::RegExp> QJSConverter::toRegExp(const QRegExp &re)
-{
- // Convert the pattern to a ECMAScript pattern.
- QString pattern = qt_regexp_toCanonical(re.pattern(), re.patternSyntax());
- if (re.isMinimal()) {
- QString ecmaPattern;
- int len = pattern.length();
- ecmaPattern.reserve(len);
- int i = 0;
- const QChar *wc = pattern.unicode();
- bool inBracket = false;
- while (i < len) {
- QChar c = wc[i++];
- ecmaPattern += c;
- switch (c.unicode()) {
- case '?':
- case '+':
- case '*':
- case '}':
- if (!inBracket)
- ecmaPattern += QLatin1Char('?');
- break;
- case '\\':
- if (i < len)
- ecmaPattern += wc[i++];
- break;
- case '[':
- inBracket = true;
- break;
- case ']':
- inBracket = false;
- break;
- default:
- break;
- }
- }
- pattern = ecmaPattern;
- }
-
- int flags = v8::RegExp::kNone;
- if (re.caseSensitivity() == Qt::CaseInsensitive)
- flags |= v8::RegExp::kIgnoreCase;
-
- return v8::RegExp::New(QJSConverter::toString(pattern), static_cast<v8::RegExp::Flags>(flags));
-}
-
-// Converts a QStringList to JS.
-// The result is a new Array object with length equal to the length
-// of the QStringList, and the elements being the QStringList's
-// elements converted to JS Strings.
-v8::Local<v8::Array> QJSConverter::toStringList(const QStringList &lst)
-{
- v8::Local<v8::Array> result = v8::Array::New(lst.size());
- for (int i = 0; i < lst.size(); ++i)
- result->Set(i, toString(lst.at(i)));
- return result;
-}
-
-// Converts a JS Array object to a QStringList.
-// The result is a QStringList with length equal to the length
-// of the JS Array, and elements being the JS Array's elements
-// converted to QStrings.
-QStringList QJSConverter::toStringList(v8::Handle<v8::Array> jsArray)
-{
- QStringList result;
- uint32_t length = jsArray->Length();
- for (uint32_t i = 0; i < length; ++i)
- result.append(toString(jsArray->Get(i)->ToString()));
- return result;
-}
-
-
-// Converts a JS Date to a QDateTime.
-QDateTime QJSConverter::toDateTime(v8::Handle<v8::Date> jsDate)
-{
- return QDateTime::fromMSecsSinceEpoch(jsDate->NumberValue());
-}
-
-// Converts a QDateTime to a JS Date.
-v8::Local<v8::Value> QJSConverter::toDateTime(const QDateTime &dt)
-{
- double date;
- if (!dt.isValid())
- date = qSNaN();
- else
- date = dt.toMSecsSinceEpoch();
- return v8::Date::New(date);
-}
-
-QT_END_NAMESPACE
-
-#endif // QJSCONVERTER_IMPL_P_H
diff --git a/src/declarative/qml/v8/qjsconverter_p.h b/src/declarative/qml/v8/qjsconverter_p.h
deleted file mode 100644
index 12ec9350e4..0000000000
--- a/src/declarative/qml/v8/qjsconverter_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QJSCONVERTER_P_H
-#define QJSCONVERTER_P_H
-
-#include "qjsvalue_p.h"
-#include <QtCore/qglobal.h>
-#include <QtCore/qnumeric.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qregexp.h>
-#include <QtCore/qdatetime.h>
-
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*
- \internal
- \class QJSConverter
- QJSValue and QJSEngine helper class. This class's responsibility is to convert values
- between JS values and Qt/C++ values.
-
- This is a nice way to inline these functions in both QJSValue and QJSEngine.
-*/
-class QJSConverter {
-public:
- static inline quint32 toArrayIndex(const QString& string);
-
- static inline QString toString(v8::Handle<v8::String> jsString);
- static inline v8::Local<v8::String> toString(const QString& string);
- static inline QString toString(double value);
-
- enum {
- PropertyAttributeMask = v8::ReadOnly | v8::DontDelete | v8::DontEnum,
- };
- // return a mask of v8::PropertyAttribute that may also contains QScriptValue::PropertyGetter or QScriptValue::PropertySetter
- static inline uint toPropertyAttributes(const QFlags<QJSValuePrivate::PropertyFlag>& flags);
-
- // Converts a JS RegExp to a QRegExp.
- // The conversion is not 100% exact since ECMA regexp and QRegExp
- // have different semantics/flags, but we try to do our best.
- static inline QRegExp toRegExp(v8::Handle<v8::RegExp> jsRegExp);
-
- // Converts a QRegExp to a JS RegExp.
- // The conversion is not 100% exact since ECMA regexp and QRegExp
- // have different semantics/flags, but we try to do our best.
- static inline v8::Local<v8::RegExp> toRegExp(const QRegExp &re);
-
- // Converts a QStringList to JS.
- // The result is a new Array object with length equal to the length
- // of the QStringList, and the elements being the QStringList's
- // elements converted to JS Strings.
- static inline v8::Local<v8::Array> toStringList(const QStringList &lst);
-
- // Converts a JS Array object to a QStringList.
- // The result is a QStringList with length equal to the length
- // of the JS Array, and elements being the JS Array's elements
- // converted to QStrings.
- static inline QStringList toStringList(v8::Handle<v8::Array> jsArray);
-
- // Converts a JS Date to a QDateTime.
- static inline QDateTime toDateTime(v8::Handle<v8::Date> jsDate);
-
- // Converts a QDateTime to a JS Date.
- static inline v8::Local<v8::Value> toDateTime(const QDateTime &dt);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/v8/qjsengine.h b/src/declarative/qml/v8/qjsengine.h
deleted file mode 100644
index 884435f4e2..0000000000
--- a/src/declarative/qml/v8/qjsengine.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QJSENGINE_H
-#define QJSENGINE_H
-
-#include <QtCore/qmetatype.h>
-
-#include <QtCore/qvariant.h>
-#include <QtCore/qsharedpointer.h>
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qjsvalue.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QV8Engine;
-
-template <typename T>
-inline T qjsvalue_cast(const QJSValue &);
-
-class QJSEnginePrivate;
-class Q_DECLARATIVE_EXPORT QJSEngine
- : public QObject
-{
- Q_OBJECT
-public:
-#ifdef QT_DEPRECATED
- enum ContextOwnership {
- AdoptCurrentContext,
- CreateNewContext
- };
- QT_DEPRECATED explicit QJSEngine(ContextOwnership ownership);
-#endif
-
- QJSEngine();
- explicit QJSEngine(QObject *parent);
- virtual ~QJSEngine();
-
- QJSValue globalObject() const;
-
- QJSValue evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
-
- QJSValue newObject();
- QJSValue newArray(uint length = 0);
-
- QJSValue newQObject(QObject *object);
-
- template <typename T>
- inline QJSValue toScriptValue(const T &value)
- {
- return create(qMetaTypeId<T>(), &value);
- }
- template <typename T>
- inline T fromScriptValue(const QJSValue &value)
- {
- return qjsvalue_cast<T>(value);
- }
-
- void collectGarbage();
-
- QV8Engine *handle() const { return d; }
-
-#ifdef QT_DEPRECATED
- QT_DEPRECATED bool hasUncaughtException() const;
- QT_DEPRECATED QJSValue uncaughtException() const;
- QT_DEPRECATED void clearExceptions();
-#endif
-
-Q_SIGNALS:
- void signalHandlerException(const QJSValue &exception);
-
-private:
- QJSValue create(int type, const void *ptr);
-
- static bool convertV2(const QJSValue &value, int type, void *ptr);
-
- friend inline bool qjsvalue_cast_helper(const QJSValue &, int, void *);
-
-protected:
- QJSEngine(QJSEnginePrivate &dd, QObject *parent = 0);
-
-private:
- QV8Engine *d;
- Q_DISABLE_COPY(QJSEngine)
- Q_DECLARE_PRIVATE(QJSEngine)
- friend class QV8Engine;
-};
-
-inline bool qjsvalue_cast_helper(const QJSValue &value, int type, void *ptr)
-{
- return QJSEngine::convertV2(value, type, ptr);
-}
-
-template<typename T>
-T qjsvalue_cast(const QJSValue &value)
-{
- T t;
- const int id = qMetaTypeId<T>();
-
- if (qjsvalue_cast_helper(value, id, &t))
- return t;
- else if (value.isVariant())
- return qvariant_cast<T>(value.toVariant());
-
- return T();
-}
-
-template <>
-inline QVariant qjsvalue_cast<QVariant>(const QJSValue &value)
-{
- return value.toVariant();
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QJSENGINE_H
diff --git a/src/declarative/qml/v8/qjsengine_p.h b/src/declarative/qml/v8/qjsengine_p.h
deleted file mode 100644
index fb66e94499..0000000000
--- a/src/declarative/qml/v8/qjsengine_p.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QJSENGINE_P_H
-#define QJSENGINE_P_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/private/qobject_p.h>
-#include "qjsengine.h"
-
-
-QT_BEGIN_NAMESPACE
-
-
-class QJSEnginePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QJSEngine)
-
-public:
- static QJSEnginePrivate* get(QJSEngine*e) { return e->d_func(); }
-
- QJSEnginePrivate() {}
-};
-
-QT_END_NAMESPACE
-
-#endif // QJSENGINE_P_H
diff --git a/src/declarative/qml/v8/qjsvalue.h b/src/declarative/qml/v8/qjsvalue.h
deleted file mode 100644
index 5d915db9af..0000000000
--- a/src/declarative/qml/v8/qjsvalue.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QJSVALUE_H
-#define QJSVALUE_H
-
-#include <QtCore/qstring.h>
-
-#include <QtCore/qlist.h>
-#include <QtCore/qsharedpointer.h>
-#include <QtCore/qshareddata.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QJSValue;
-class QJSEngine;
-class QVariant;
-class QObject;
-struct QMetaObject;
-class QDateTime;
-
-typedef QList<QJSValue> QJSValueList;
-
-class QJSValuePrivate;
-struct QScriptValuePrivatePointerDeleter;
-template <class T> class QScriptPassPointer;
-
-class Q_DECLARATIVE_EXPORT QJSValue
-{
-public:
- enum SpecialValue {
- NullValue,
- UndefinedValue
- };
-
-public:
- QJSValue(SpecialValue value = UndefinedValue);
- ~QJSValue();
- QJSValue(const QJSValue &other);
-
- QJSValue(bool value);
- QJSValue(int value);
- QJSValue(uint value);
- QJSValue(double value);
- QJSValue(const QString &value);
- QJSValue(const QLatin1String &value);
-#ifndef QT_NO_CAST_FROM_ASCII
- QT_ASCII_CAST_WARN QJSValue(const char *str);
-#endif
-
- QJSValue &operator=(const QJSValue &other);
-
- bool isBool() const;
- bool isNumber() const;
- bool isNull() const;
- bool isString() const;
- bool isUndefined() const;
- bool isVariant() const;
- bool isQObject() const;
- bool isObject() const;
- bool isDate() const;
- bool isRegExp() const;
- bool isArray() const;
- bool isError() const;
-
- QString toString() const;
- double toNumber() const;
- qint32 toInt() const;
- quint32 toUInt() const;
- bool toBool() const;
- QVariant toVariant() const;
- QObject *toQObject() const;
- QDateTime toDateTime() const;
-
- bool equals(const QJSValue &other) const;
- bool strictlyEquals(const QJSValue &other) const;
-
- QJSValue prototype() const;
- void setPrototype(const QJSValue &prototype);
-
- QJSValue property(const QString &name) const;
- void setProperty(const QString &name, const QJSValue &value);
-
- bool hasProperty(const QString &name) const;
- bool hasOwnProperty(const QString &name) const;
-
- QJSValue property(quint32 arrayIndex) const;
- void setProperty(quint32 arrayIndex, const QJSValue &value);
-
- bool deleteProperty(const QString &name);
-
- bool isCallable() const;
- QJSValue call(const QJSValueList &args = QJSValueList());
- QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args = QJSValueList());
- QJSValue callAsConstructor(const QJSValueList &args = QJSValueList());
-
-#ifdef QT_DEPRECATED
- QT_DEPRECATED QJSEngine *engine() const;
-#endif
-
-private:
- // force compile error, prevent QJSValue(bool) to be called
-
- QJSValue(void *) Q_DECL_EQ_DELETE;
-
- QJSValue(QJSValuePrivate*);
- QJSValue(QScriptPassPointer<QJSValuePrivate>);
-
-private:
- QExplicitlySharedDataPointer<QJSValuePrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QJSValue)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/qml/v8/qjsvalue_impl_p.h b/src/declarative/qml/v8/qjsvalue_impl_p.h
deleted file mode 100644
index 0b0cd0759a..0000000000
--- a/src/declarative/qml/v8/qjsvalue_impl_p.h
+++ /dev/null
@@ -1,995 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// 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.
-//
-
-#ifndef QJSVALUE_IMPL_P_H
-#define QJSVALUE_IMPL_P_H
-
-#include "qjsconverter_p.h"
-#include "qjsvalue_p.h"
-#include "qv8engine_p.h"
-#include "qscriptisolate_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QJSValuePrivate* QJSValuePrivate::get(const QJSValue& q) { Q_ASSERT(q.d_ptr.data()); return q.d_ptr.data(); }
-
-QJSValue QJSValuePrivate::get(const QJSValuePrivate* d)
-{
- Q_ASSERT(d);
- return QJSValue(const_cast<QJSValuePrivate*>(d));
-}
-
-QJSValue QJSValuePrivate::get(QScriptPassPointer<QJSValuePrivate> d)
-{
- Q_ASSERT(d);
- return QJSValue(d);
-}
-
-QJSValue QJSValuePrivate::get(QJSValuePrivate* d)
-{
- Q_ASSERT(d);
- return QJSValue(d);
-}
-
-QJSValuePrivate::QJSValuePrivate(bool value)
- : m_engine(0), m_state(CBool), u(value)
-{
-}
-
-QJSValuePrivate::QJSValuePrivate(int value)
- : m_engine(0), m_state(CNumber), u(value)
-{
-}
-
-QJSValuePrivate::QJSValuePrivate(uint value)
- : m_engine(0), m_state(CNumber), u(value)
-{
-}
-
-QJSValuePrivate::QJSValuePrivate(double value)
- : m_engine(0), m_state(CNumber), u(value)
-{
-}
-
-QJSValuePrivate::QJSValuePrivate(const QString& value)
- : m_engine(0), m_state(CString), u(new QString(value))
-{
-}
-
-QJSValuePrivate::QJSValuePrivate(QJSValue::SpecialValue value)
- : m_engine(0), m_state(value == QJSValue::NullValue ? CNull : CUndefined)
-{
-}
-
-QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, bool value)
- : m_engine(engine), m_state(JSValue)
-{
- Q_ASSERT(engine);
- v8::HandleScope handleScope;
- m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
- m_engine->registerValue(this);
-}
-
-QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, int value)
- : m_engine(engine), m_state(JSValue)
-{
- Q_ASSERT(engine);
- v8::HandleScope handleScope;
- m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
- m_engine->registerValue(this);
-}
-
-QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, uint value)
- : m_engine(engine), m_state(JSValue)
-{
- Q_ASSERT(engine);
- v8::HandleScope handleScope;
- m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
- m_engine->registerValue(this);
-}
-
-QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, double value)
- : m_engine(engine), m_state(JSValue)
-{
- Q_ASSERT(engine);
- v8::HandleScope handleScope;
- m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
- m_engine->registerValue(this);
-}
-
-QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, const QString& value)
- : m_engine(engine), m_state(JSValue)
-{
- Q_ASSERT(engine);
- v8::HandleScope handleScope;
- m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
- m_engine->registerValue(this);
-}
-
-QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, QJSValue::SpecialValue value)
- : m_engine(engine), m_state(JSValue)
-{
- Q_ASSERT(engine);
- v8::HandleScope handleScope;
- m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
- m_engine->registerValue(this);
-}
-
-QJSValuePrivate::QJSValuePrivate(QV8Engine *engine, v8::Handle<v8::Value> value)
- : m_engine(engine), m_state(JSValue), m_value(v8::Persistent<v8::Value>::New(value))
-{
- Q_ASSERT(engine);
- // It shouldn't happen, v8 shows errors by returning an empty handler. This is important debug
- // information and it can't be simply ignored.
- Q_ASSERT(!value.IsEmpty());
- m_engine->registerValue(this);
-}
-
-QJSValuePrivate::~QJSValuePrivate()
-{
- if (isJSBased()) {
- m_engine->unregisterValue(this);
- QScriptIsolate api(m_engine);
- m_value.Dispose();
- } else if (isStringBased()) {
- delete u.m_string;
- }
-}
-
-bool QJSValuePrivate::toBool() const
-{
- switch (m_state) {
- case JSValue:
- {
- v8::HandleScope scope;
- return m_value->ToBoolean()->Value();
- }
- case CNumber:
- return !(qIsNaN(u.m_number) || !u.m_number);
- case CBool:
- return u.m_bool;
- case CNull:
- case CUndefined:
- return false;
- case CString:
- return u.m_string->length();
- }
-
- Q_ASSERT_X(false, "toBool()", "Not all states are included in the previous switch statement.");
- return false; // Avoid compiler warning.
-}
-
-double QJSValuePrivate::toNumber() const
-{
- switch (m_state) {
- case JSValue:
- {
- v8::HandleScope scope;
- return m_value->ToNumber()->Value();
- }
- case CNumber:
- return u.m_number;
- case CBool:
- return u.m_bool ? 1 : 0;
- case CNull:
- case CUndefined:
- return qQNaN();
- case CString:
- bool ok;
- double result = u.m_string->toDouble(&ok);
- if (ok)
- return result;
- result = u.m_string->toInt(&ok, 0); // Try other bases.
- if (ok)
- return result;
- if (*u.m_string == QLatin1String("Infinity"))
- return qInf();
- if (*u.m_string == QLatin1String("-Infinity"))
- return -qInf();
- return u.m_string->length() ? qQNaN() : 0;
- }
-
- Q_ASSERT_X(false, "toNumber()", "Not all states are included in the previous switch statement.");
- return 0; // Avoid compiler warning.
-}
-
-QString QJSValuePrivate::toString() const
-{
- switch (m_state) {
- case CBool:
- return u.m_bool ? QString::fromLatin1("true") : QString::fromLatin1("false");
- case CString:
- return *u.m_string;
- case CNumber:
- return QJSConverter::toString(u.m_number);
- case CNull:
- return QString::fromLatin1("null");
- case CUndefined:
- return QString::fromLatin1("undefined");
- case JSValue:
- Q_ASSERT(!m_value.IsEmpty());
- v8::HandleScope handleScope;
- v8::TryCatch tryCatch;
- v8::Local<v8::String> result = m_value->ToString();
- if (result.IsEmpty()) {
- result = tryCatch.Exception()->ToString();
- m_engine->setException(tryCatch.Exception(), tryCatch.Message());
- }
- return QJSConverter::toString(result);
- }
-
- Q_ASSERT_X(false, "toString()", "Not all states are included in the previous switch statement.");
- return QString(); // Avoid compiler warning.
-}
-
-QVariant QJSValuePrivate::toVariant() const
-{
- switch (m_state) {
- case CBool:
- return QVariant(u.m_bool);
- case CString:
- return QVariant(*u.m_string);
- case CNumber:
- return QVariant(u.m_number);
- case CNull:
- return QVariant();
- case CUndefined:
- return QVariant();
- case JSValue:
- break;
- }
-
- Q_ASSERT(m_state == JSValue);
- Q_ASSERT(!m_value.IsEmpty());
- Q_ASSERT(m_engine);
-
- v8::HandleScope handleScope;
- return m_engine->variantFromJS(m_value);
-}
-
-inline QDateTime QJSValuePrivate::toDataTime() const
-{
- if (!isDate())
- return QDateTime();
-
- v8::HandleScope handleScope;
- return QJSConverter::toDateTime(v8::Handle<v8::Date>::Cast(m_value));
-
-}
-
-QObject* QJSValuePrivate::toQObject() const
-{
- if (!isJSBased())
- return 0;
-
- v8::HandleScope handleScope;
- return engine()->qtObjectFromJS(m_value);
-}
-
-double QJSValuePrivate::toInteger() const
-{
- double result = toNumber();
- if (qIsNaN(result))
- return 0;
- if (qIsInf(result))
- return result;
-
- // Must use floor explicitly rather than qFloor here. On some
- // platforms qFloor will cast the value to a single precision float and use
- // floorf() which results in test failures.
- return (result > 0) ? floor(result) : -1 * floor(-result);
-}
-
-qint32 QJSValuePrivate::toInt32() const
-{
- double result = toInteger();
- // Orginaly it should look like that (result == 0 || qIsInf(result) || qIsNaN(result)), but
- // some of these operation are invoked in toInteger subcall.
- if (qIsInf(result))
- return 0;
- return result;
-}
-
-quint32 QJSValuePrivate::toUInt32() const
-{
- double result = toInteger();
- // Orginaly it should look like that (result == 0 || qIsInf(result) || qIsNaN(result)), but
- // some of these operation are invoked in toInteger subcall.
- if (qIsInf(result))
- return 0;
-
- // The explicit casts are required to avoid undefined behaviour. For example, casting
- // a negative double directly to an unsigned int on ARM NEON FPU results in the value
- // being set to zero. Casting to a signed int first ensures well defined behaviour.
- return (quint32) (qint32) result;
-}
-
-quint16 QJSValuePrivate::toUInt16() const
-{
- return toInt32();
-}
-
-inline bool QJSValuePrivate::isArray() const
-{
- return isJSBased() && m_value->IsArray();
-}
-
-inline bool QJSValuePrivate::isBool() const
-{
- return m_state == CBool || (isJSBased() && m_value->IsBoolean());
-}
-
-inline bool QJSValuePrivate::isCallable() const
-{
- if (isFunction())
- return true;
- if (isObject()) {
- // Our C++ wrappers register function handlers but not always act as callables.
- return v8::Object::Cast(*m_value)->IsCallable();
- }
- return false;
-}
-
-inline bool QJSValuePrivate::isError() const
-{
- if (!isJSBased())
- return false;
- v8::HandleScope handleScope;
- return m_value->IsError();
-}
-
-inline bool QJSValuePrivate::isFunction() const
-{
- return isJSBased() && m_value->IsFunction();
-}
-
-inline bool QJSValuePrivate::isNull() const
-{
- return m_state == CNull || (isJSBased() && m_value->IsNull());
-}
-
-inline bool QJSValuePrivate::isNumber() const
-{
- return m_state == CNumber || (isJSBased() && m_value->IsNumber());
-}
-
-inline bool QJSValuePrivate::isObject() const
-{
- return isJSBased() && m_value->IsObject();
-}
-
-inline bool QJSValuePrivate::isString() const
-{
- return m_state == CString || (isJSBased() && m_value->IsString());
-}
-
-inline bool QJSValuePrivate::isUndefined() const
-{
- return m_state == CUndefined || (isJSBased() && m_value->IsUndefined());
-}
-
-inline bool QJSValuePrivate::isVariant() const
-{
- return isJSBased() && m_engine->isVariant(m_value);
-}
-
-bool QJSValuePrivate::isDate() const
-{
- return (isJSBased() && m_value->IsDate());
-}
-
-bool QJSValuePrivate::isRegExp() const
-{
- return (isJSBased() && m_value->IsRegExp());
-}
-
-bool QJSValuePrivate::isQObject() const
-{
- return isJSBased() && engine()->isQObject(m_value);
-}
-
-inline bool QJSValuePrivate::equals(QJSValuePrivate* other)
-{
- if (!isJSBased() && !other->isJSBased()) {
- switch (m_state) {
- case CNull:
- case CUndefined:
- return other->isUndefined() || other->isNull();
- case CNumber:
- switch (other->m_state) {
- case CBool:
- case CString:
- return u.m_number == other->toNumber();
- case CNumber:
- return u.m_number == other->u.m_number;
- default:
- return false;
- }
- case CBool:
- switch (other->m_state) {
- case CBool:
- return u.m_bool == other->u.m_bool;
- case CNumber:
- return toNumber() == other->u.m_number;
- case CString:
- return toNumber() == other->toNumber();
- default:
- return false;
- }
- case CString:
- switch (other->m_state) {
- case CBool:
- return toNumber() == other->toNumber();
- case CNumber:
- return toNumber() == other->u.m_number;
- case CString:
- return *u.m_string == *other->u.m_string;
- default:
- return false;
- }
- default:
- Q_ASSERT_X(false, "QJSValue::equals", "Not all states are included in the previous switch statement.");
- }
- }
-
- v8::HandleScope handleScope;
- if (isJSBased() && !other->isJSBased()) {
- if (!other->assignEngine(engine())) {
- qWarning("QJSValue::equals: cannot compare to a value created in a different engine");
- return false;
- }
- } else if (!isJSBased() && other->isJSBased()) {
- if (!assignEngine(other->engine())) {
- qWarning("QJSValue::equals: cannot compare to a value created in a different engine");
- return false;
- }
- }
-
- Q_ASSERT(this->engine() && other->engine());
- if (this->engine() != other->engine()) {
- qWarning("QJSValue::equals: cannot compare to a value created in a different engine");
- return false;
- }
- return m_value->Equals(other->m_value);
-}
-
-inline bool QJSValuePrivate::strictlyEquals(QJSValuePrivate* other)
-{
- if (isJSBased()) {
- // We can't compare these two values without binding to the same engine.
- if (!other->isJSBased()) {
- if (other->assignEngine(engine()))
- return m_value->StrictEquals(other->m_value);
- return false;
- }
- if (other->engine() != engine()) {
- qWarning("QJSValue::strictlyEquals: cannot compare to a value created in a different engine");
- return false;
- }
- return m_value->StrictEquals(other->m_value);
- }
- if (isStringBased()) {
- if (other->isStringBased())
- return *u.m_string == *(other->u.m_string);
- if (other->isJSBased()) {
- assignEngine(other->engine());
- return m_value->StrictEquals(other->m_value);
- }
- }
- if (isNumberBased()) {
- if (other->isJSBased()) {
- assignEngine(other->engine());
- return m_value->StrictEquals(other->m_value);
- }
- if (m_state != other->m_state)
- return false;
- if (m_state == CNumber)
- return u.m_number == other->u.m_number;
- Q_ASSERT(m_state == CBool);
- return u.m_bool == other->u.m_bool;
- }
-
- return (isUndefined() && other->isUndefined())
- || (isNull() && other->isNull());
-}
-
-inline bool QJSValuePrivate::lessThan(QJSValuePrivate *other) const
-{
- if (engine() != other->engine() && engine() && other->engine()) {
- qWarning("QJSValue::lessThan: cannot compare to a value created in a different engine");
- return false;
- }
-
- if (isString() && other->isString())
- return toString() < other->toString();
-
- if (isObject() || other->isObject()) {
- v8::HandleScope handleScope;
- QV8Engine *eng = m_engine ? engine() : other->engine();
- // FIXME: lessThan can throw an exception which will be dropped by this code:
- Q_ASSERT(eng);
- eng->saveException();
- QScriptSharedDataPointer<QJSValuePrivate> cmp(eng->evaluate(QString::fromLatin1("(function(a,b){return a<b})")));
- Q_ASSERT(cmp->isFunction());
- v8::Handle<v8::Value> args[2];
- cmp->prepareArgumentsForCall(args, QJSValueList() << QJSValuePrivate::get(this) << QJSValuePrivate::get(other));
- QScriptSharedDataPointer<QJSValuePrivate> resultValue(cmp->call(0, 2, args));
- bool result = resultValue->toBool();
- eng->restoreException();
- return result;
- }
-
- double nthis = toNumber();
- double nother = other->toNumber();
- if (qIsNaN(nthis) || qIsNaN(nother)) {
- // Should return undefined in ECMA standard.
- return false;
- }
- return nthis < nother;
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::prototype() const
-{
- if (isObject()) {
- v8::HandleScope handleScope;
- return new QJSValuePrivate(engine(), v8::Handle<v8::Object>::Cast(m_value)->GetPrototype());
- }
- return new QJSValuePrivate();
-}
-
-inline void QJSValuePrivate::setPrototype(QJSValuePrivate* prototype)
-{
- if (isObject() && (prototype->isObject() || prototype->isNull())) {
- if (engine() != prototype->engine()) {
- if (prototype->engine()) {
- qWarning("QJSValue::setPrototype() failed: cannot set a prototype created in a different engine");
- return;
- }
- prototype->assignEngine(engine());
- }
- v8::HandleScope handleScope;
- if (!v8::Handle<v8::Object>::Cast(m_value)->SetPrototype(*prototype))
- qWarning("QJSValue::setPrototype() failed: cyclic prototype value");
- }
-}
-
-inline void QJSValuePrivate::setProperty(const QString& name, QJSValuePrivate* value, uint attribs)
-{
- if (!isObject())
- return;
- v8::HandleScope handleScope;
- setProperty(QJSConverter::toString(name), value, attribs);
-}
-
-inline void QJSValuePrivate::setProperty(v8::Handle<v8::String> name, QJSValuePrivate* value, uint attribs)
-{
- if (!isObject())
- return;
-
- if (!value->isJSBased())
- value->assignEngine(engine());
-
- if (engine() != value->engine()) {
- qWarning("QJSValue::setProperty(%s) failed: "
- "cannot set value created in a different engine",
- qPrintable(QJSConverter::toString(name)));
- return;
- }
-
- v8::TryCatch tryCatch;
-// if (attribs & (QJSValue::PropertyGetter | QJSValue::PropertySetter)) {
-// engine()->originalGlobalObject()->defineGetterOrSetter(*this, name, value->m_value, attribs);
-// } else {
- v8::Object::Cast(*m_value)->Set(name, value->m_value, v8::PropertyAttribute(attribs & QJSConverter::PropertyAttributeMask));
-// }
- if (tryCatch.HasCaught())
- engine()->setException(tryCatch.Exception(), tryCatch.Message());
-}
-
-inline void QJSValuePrivate::setProperty(quint32 index, QJSValuePrivate* value, uint attribs)
-{
- // FIXME this method should by integrated with other overloads to use the same code patch.
- // for now it is not possible as v8 doesn't allow to set property attributes using index based api.
-
- if (!isObject())
- return;
-
- if (attribs) {
- // FIXME we dont need to convert index to a string.
- //Object::Set(int,value) do not take attributes.
- setProperty(QString::number(index), value, attribs);
- return;
- }
-
- if (!value->isJSBased())
- value->assignEngine(engine());
-
- if (engine() != value->engine()) {
- qWarning("QJSValue::setProperty() failed: cannot set value created in a different engine");
- return;
- }
-
- v8::HandleScope handleScope;
- v8::TryCatch tryCatch;
- v8::Object::Cast(*m_value)->Set(index, value->m_value);
- if (tryCatch.HasCaught())
- engine()->setException(tryCatch.Exception(), tryCatch.Message());
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(const QString& name) const
-{
- if (!isObject())
- return new QJSValuePrivate();
- if (!name.length())
- return new QJSValuePrivate(engine());
-
- v8::HandleScope handleScope;
- return property(QJSConverter::toString(name));
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(v8::Handle<v8::String> name) const
-{
- Q_ASSERT(!name.IsEmpty());
- if (!isObject())
- return new QJSValuePrivate();
- return property<>(name);
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(quint32 index) const
-{
- if (!isObject())
- return new QJSValuePrivate();
- return property<>(index);
-}
-
-template<typename T>
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(T name) const
-{
- Q_ASSERT(isObject());
- v8::HandleScope handleScope;
- v8::Handle<v8::Object> self(v8::Object::Cast(*m_value));
-
- v8::TryCatch tryCatch;
- v8::Handle<v8::Value> result = self->Get(name);
- if (tryCatch.HasCaught()) {
- result = tryCatch.Exception();
- engine()->setException(result, tryCatch.Message());
- return new QJSValuePrivate(engine(), result);
- }
- if (result.IsEmpty())
- return new QJSValuePrivate(engine());
- return new QJSValuePrivate(engine(), result);
-}
-
-inline bool QJSValuePrivate::deleteProperty(const QString& name)
-{
- if (!isObject())
- return false;
-
- v8::HandleScope handleScope;
- v8::Handle<v8::Object> self(v8::Handle<v8::Object>::Cast(m_value));
- return self->Delete(QJSConverter::toString(name));
-}
-
-inline bool QJSValuePrivate::hasProperty(const QString &name) const
-{
- if (!isObject())
- return false;
-
- v8::HandleScope handleScope;
- v8::Handle<v8::Object> self(v8::Handle<v8::Object>::Cast(m_value));
- return self->Has(QJSConverter::toString(name));
-}
-
-inline bool QJSValuePrivate::hasOwnProperty(const QString &name) const
-{
- if (!isObject())
- return false;
-
- v8::HandleScope handleScope;
- v8::Handle<v8::Object> self(v8::Handle<v8::Object>::Cast(m_value));
- return self->HasOwnProperty(QJSConverter::toString(name));
-}
-
-inline QJSValuePrivate::PropertyFlags QJSValuePrivate::propertyFlags(const QString& name) const
-{
- if (!isObject())
- return QJSValuePrivate::PropertyFlags(0);
-
- v8::HandleScope handleScope;
- return engine()->getPropertyFlags(v8::Handle<v8::Object>::Cast(m_value), QJSConverter::toString(name));
-}
-
-inline QJSValuePrivate::PropertyFlags QJSValuePrivate::propertyFlags(v8::Handle<v8::String> name) const
-{
- if (!isObject())
- return QJSValuePrivate::PropertyFlags(0);
-
- v8::HandleScope handleScope;
- return engine()->getPropertyFlags(v8::Handle<v8::Object>::Cast(m_value), name);
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::call(QJSValuePrivate* thisObject, const QJSValueList& args)
-{
- if (!isCallable())
- return new QJSValuePrivate();
-
- v8::HandleScope handleScope;
-
- // Convert all arguments and bind to the engine.
- int argc = args.size();
- QVarLengthArray<v8::Handle<v8::Value>, 8> argv(argc);
- if (!prepareArgumentsForCall(argv.data(), args)) {
- qWarning("QJSValue::call() failed: cannot call function with argument created in a different engine");
- return new QJSValuePrivate(engine());
- }
-
- return call(thisObject, argc, argv.data());
-}
-
-QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::call(QJSValuePrivate* thisObject, int argc, v8::Handle<v8::Value> *argv)
-{
- QV8Engine *e = engine();
-
- v8::Handle<v8::Object> recv;
-
- if (!thisObject || !thisObject->isObject()) {
- recv = v8::Handle<v8::Object>(v8::Object::Cast(*e->global()));
- } else {
- if (!thisObject->assignEngine(e)) {
- qWarning("QJSValue::call() failed: cannot call function with thisObject created in a different engine");
- return new QJSValuePrivate(engine());
- }
-
- recv = v8::Handle<v8::Object>(v8::Object::Cast(*thisObject->m_value));
- }
-
- if (argc < 0) {
- v8::Local<v8::Value> exeption = v8::Exception::TypeError(v8::String::New("Arguments must be an array"));
- e->setException(exeption);
- return new QJSValuePrivate(e, exeption);
- }
-
- v8::TryCatch tryCatch;
- v8::Handle<v8::Value> result = v8::Object::Cast(*m_value)->CallAsFunction(recv, argc, argv);
-
- if (result.IsEmpty()) {
- result = tryCatch.Exception();
- // TODO: figure out why v8 doesn't always produce an exception value.
- //Q_ASSERT(!result.IsEmpty());
- if (result.IsEmpty())
- result = v8::Exception::Error(v8::String::New("missing exception value"));
- e->setException(result, tryCatch.Message());
- }
-
- return new QJSValuePrivate(e, result);
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::callAsConstructor(int argc, v8::Handle<v8::Value> *argv)
-{
- QV8Engine *e = engine();
-
- if (argc < 0) {
- v8::Local<v8::Value> exeption = v8::Exception::TypeError(v8::String::New("Arguments must be an array"));
- e->setException(exeption);
- return new QJSValuePrivate(e, exeption);
- }
-
- v8::TryCatch tryCatch;
- v8::Handle<v8::Value> result = v8::Object::Cast(*m_value)->CallAsConstructor(argc, argv);
-
- if (result.IsEmpty()) {
- result = tryCatch.Exception();
- e->setException(result, tryCatch.Message());
- }
-
- return new QJSValuePrivate(e, result);
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::callAsConstructor(const QJSValueList& args)
-{
- if (!isCallable())
- return new QJSValuePrivate();
-
- v8::HandleScope handleScope;
-
- // Convert all arguments and bind to the engine.
- int argc = args.size();
- QVarLengthArray<v8::Handle<v8::Value>, 8> argv(argc);
- if (!prepareArgumentsForCall(argv.data(), args)) {
- qWarning("QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine");
- return new QJSValuePrivate(engine());
- }
-
- return callAsConstructor(argc, argv.data());
-}
-
-/*! \internal
- * Make sure this value is associated with a v8 value belonging to this engine.
- * If the value belongs to another engine, returns false.
- */
-bool QJSValuePrivate::assignEngine(QV8Engine* engine)
-{
- Q_ASSERT(engine);
- v8::HandleScope handleScope;
- switch (m_state) {
- case CBool:
- m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(u.m_bool));
- break;
- case CString:
- m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(*u.m_string));
- delete u.m_string;
- break;
- case CNumber:
- m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(u.m_number));
- break;
- case CNull:
- m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(QJSValue::NullValue));
- break;
- case CUndefined:
- m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(QJSValue::UndefinedValue));
- break;
- default:
- if (this->engine() == engine)
- return true;
- else if (!isJSBased())
- Q_ASSERT_X(!isJSBased(), "assignEngine()", "Not all states are included in the previous switch statement.");
- else
- qWarning("JSValue can't be rassigned to an another engine.");
- return false;
- }
- m_engine = engine;
- m_state = JSValue;
-
- m_engine->registerValue(this);
- return true;
-}
-
-/*!
- \internal
- Invalidates this value (makes it undefined).
-
- Does not remove the value from the engine's list of
- registered values; that's the responsibility of the caller.
-*/
-void QJSValuePrivate::invalidate()
-{
- if (isJSBased()) {
- m_value.Dispose();
- m_value.Clear();
- } else if (isStringBased()) {
- delete u.m_string;
- }
- m_engine = 0;
- m_state = CUndefined;
-}
-
-QV8Engine* QJSValuePrivate::engine() const
-{
- return m_engine;
-}
-
-inline QJSValuePrivate::operator v8::Handle<v8::Value>() const
-{
- Q_ASSERT(isJSBased());
- return m_value;
-}
-
-inline QJSValuePrivate::operator v8::Handle<v8::Object>() const
-{
- Q_ASSERT(isObject());
- return v8::Handle<v8::Object>::Cast(m_value);
-}
-
-/*!
- * Return a v8::Handle, assign to the engine if needed.
- */
-v8::Handle<v8::Value> QJSValuePrivate::asV8Value(QV8Engine* engine)
-{
- if (!m_engine) {
- if (!assignEngine(engine))
- return v8::Handle<v8::Value>();
- }
- Q_ASSERT(isJSBased());
- return m_value;
-}
-
-/*!
- \internal
- Returns true if QSV have an engine associated.
-*/
-bool QJSValuePrivate::isJSBased() const
-{
-#ifndef QT_NO_DEBUG
- // internals check.
- if (m_state >= JSValue)
- Q_ASSERT(!m_value.IsEmpty());
- else
- Q_ASSERT(m_value.IsEmpty());
-#endif
- return m_state >= JSValue;
-}
-
-/*!
- \internal
- Returns true if current value of QSV is placed in m_number.
-*/
-bool QJSValuePrivate::isNumberBased() const { return m_state == CNumber || m_state == CBool; }
-
-/*!
- \internal
- Returns true if current value of QSV is placed in m_string.
-*/
-bool QJSValuePrivate::isStringBased() const { return m_state == CString; }
-
-/*!
- \internal
- Converts arguments and bind them to the engine.
- \attention argv should be big enough
-*/
-inline bool QJSValuePrivate::prepareArgumentsForCall(v8::Handle<v8::Value> argv[], const QJSValueList& args) const
-{
- QJSValueList::const_iterator i = args.constBegin();
- for (int j = 0; i != args.constEnd(); j++, i++) {
- QJSValuePrivate* value = QJSValuePrivate::get(*i);
- if ((value->isJSBased() && engine() != value->engine())
- || (!value->isJSBased() && !value->assignEngine(engine())))
- // Different engines are not allowed!
- return false;
- argv[j] = *value;
- }
- return true;
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/v8/qjsvalue_p.h b/src/declarative/qml/v8/qjsvalue_p.h
deleted file mode 100644
index 3275f47b85..0000000000
--- a/src/declarative/qml/v8/qjsvalue_p.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// 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.
-//
-
-#ifndef QJSVALUE_P_H
-#define QJSVALUE_P_H
-
-#include <private/qv8_p.h>
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qmath.h>
-#include <QtCore/qvarlengtharray.h>
-#include <qdebug.h>
-
-#include <private/qintrusivelist_p.h>
-#include "qscriptshareddata_p.h"
-#include "qjsvalue.h"
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-
-/*!
- \internal
- \class QJSValuePrivate
-*/
-class QJSValuePrivate
- : public QSharedData
-{
-public:
- enum PropertyFlag {
- ReadOnly = 0x00000001,
- Undeletable = 0x00000002,
- SkipInEnumeration = 0x00000004
- };
- Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)
-
- inline static QJSValuePrivate* get(const QJSValue& q);
- inline static QJSValue get(const QJSValuePrivate* d);
- inline static QJSValue get(QJSValuePrivate* d);
- inline static QJSValue get(QScriptPassPointer<QJSValuePrivate> d);
- inline ~QJSValuePrivate();
-
- inline QJSValuePrivate(bool value);
- inline QJSValuePrivate(int value);
- inline QJSValuePrivate(uint value);
- inline QJSValuePrivate(double value);
- inline QJSValuePrivate(const QString& value);
- inline QJSValuePrivate(QJSValue::SpecialValue value = QJSValue::UndefinedValue);
-
- inline QJSValuePrivate(QV8Engine *engine, bool value);
- inline QJSValuePrivate(QV8Engine *engine, int value);
- inline QJSValuePrivate(QV8Engine *engine, uint value);
- inline QJSValuePrivate(QV8Engine *engine, double value);
- inline QJSValuePrivate(QV8Engine *engine, const QString& value);
- inline QJSValuePrivate(QV8Engine *engine, QJSValue::SpecialValue value = QJSValue::UndefinedValue);
- inline QJSValuePrivate(QV8Engine *engine, v8::Handle<v8::Value>);
- inline void invalidate();
-
- inline bool toBool() const;
- inline double toNumber() const;
- inline QString toString() const;
- inline double toInteger() const;
- inline qint32 toInt32() const;
- inline quint32 toUInt32() const;
- inline quint16 toUInt16() const;
- inline QDateTime toDataTime() const;
- inline QObject *toQObject() const;
- inline QVariant toVariant() const;
-
- inline bool isArray() const;
- inline bool isBool() const;
- inline bool isCallable() const;
- inline bool isError() const;
- inline bool isFunction() const;
- inline bool isNull() const;
- inline bool isNumber() const;
- inline bool isObject() const;
- inline bool isString() const;
- inline bool isUndefined() const;
- inline bool isVariant() const;
- inline bool isDate() const;
- inline bool isRegExp() const;
- inline bool isQObject() const;
-
- inline bool equals(QJSValuePrivate* other);
- inline bool strictlyEquals(QJSValuePrivate* other);
- inline bool lessThan(QJSValuePrivate *other) const;
-
- inline QScriptPassPointer<QJSValuePrivate> prototype() const;
- inline void setPrototype(QJSValuePrivate* prototype);
-
- inline void setProperty(const QString &name, QJSValuePrivate *value, uint attribs = 0);
- inline void setProperty(v8::Handle<v8::String> name, QJSValuePrivate *value, uint attribs = 0);
- inline void setProperty(quint32 index, QJSValuePrivate* value, uint attribs = 0);
- inline QScriptPassPointer<QJSValuePrivate> property(const QString& name) const;
- inline QScriptPassPointer<QJSValuePrivate> property(v8::Handle<v8::String> name) const;
- inline QScriptPassPointer<QJSValuePrivate> property(quint32 index) const;
- template<typename T>
- inline QScriptPassPointer<QJSValuePrivate> property(T name) const;
- inline bool deleteProperty(const QString& name);
- inline bool hasProperty(const QString &name) const;
- inline bool hasOwnProperty(const QString &name) const;
- inline PropertyFlags propertyFlags(const QString& name) const;
- inline PropertyFlags propertyFlags(v8::Handle<v8::String> name) const;
-
- inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, const QJSValueList& args);
- inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, const QJSValue& arguments);
- inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, int argc, v8::Handle< v8::Value >* argv);
- inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(int argc, v8::Handle<v8::Value> *argv);
- inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(const QJSValueList& args);
- inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(const QJSValue& arguments);
-
- inline bool assignEngine(QV8Engine *engine);
- inline QV8Engine *engine() const;
-
- inline operator v8::Handle<v8::Value>() const;
- inline operator v8::Handle<v8::Object>() const;
- inline v8::Handle<v8::Value> asV8Value(QV8Engine *engine);
-private:
- QIntrusiveListNode m_node;
- QV8Engine *m_engine;
-
- // Please, update class documentation when you change the enum.
- enum State {
- CString = 0x1000,
- CNumber,
- CBool,
- CNull,
- CUndefined,
- JSValue = 0x2000, // V8 values are equal or higher then this value.
- // JSPrimitive,
- // JSObject
- } m_state;
-
- union CValue {
- bool m_bool;
- double m_number;
- QString* m_string;
-
- CValue() : m_number(0) {}
- CValue(bool value) : m_bool(value) {}
- CValue(int number) : m_number(number) {}
- CValue(uint number) : m_number(number) {}
- CValue(double number) : m_number(number) {}
- CValue(QString* string) : m_string(string) {}
- } u;
- // v8::Persistent is not a POD, so can't be part of the union.
- v8::Persistent<v8::Value> m_value;
-
- Q_DISABLE_COPY(QJSValuePrivate)
- inline bool isJSBased() const;
- inline bool isNumberBased() const;
- inline bool isStringBased() const;
- inline bool prepareArgumentsForCall(v8::Handle<v8::Value> argv[], const QJSValueList& arguments) const;
-
- friend class QV8Engine;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QJSValuePrivate::PropertyFlags)
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/v8/qjsvalueiterator.h b/src/declarative/qml/v8/qjsvalueiterator.h
deleted file mode 100644
index 5e2c3d4561..0000000000
--- a/src/declarative/qml/v8/qjsvalueiterator.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCRIPTVALUEITERATOR_H
-#define QSCRIPTVALUEITERATOR_H
-
-#include <QtDeclarative/qjsvalue.h>
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QString;
-
-class QJSValueIteratorPrivate;
-class Q_DECLARATIVE_EXPORT QJSValueIterator
-{
-public:
- QJSValueIterator(const QJSValue &value);
- ~QJSValueIterator();
-
- bool hasNext() const;
- bool next();
-
- QString name() const;
-
- QJSValue value() const;
- QJSValueIterator& operator=(QJSValue &value);
-
-private:
- QScopedPointer<QJSValueIteratorPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QJSValueIterator)
- Q_DISABLE_COPY(QJSValueIterator)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCRIPTVALUEITERATOR_H
diff --git a/src/declarative/qml/v8/qjsvalueiterator_impl_p.h b/src/declarative/qml/v8/qjsvalueiterator_impl_p.h
deleted file mode 100644
index 9a265e8d48..0000000000
--- a/src/declarative/qml/v8/qjsvalueiterator_impl_p.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QJSVALUEITERATOR_IMPL_P_H
-#define QJSVALUEITERATOR_IMPL_P_H
-
-#include "qjsvalueiterator_p.h"
-#include <private/qv8engine_p.h>
-#include "qjsconverter_p.h"
-
-inline QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValuePrivate* value)
- : m_object(const_cast<QJSValuePrivate*>(value))
- , m_index(0)
- , m_count(0)
-{
- Q_ASSERT(value);
- QV8Engine *engine = m_object->engine();
- if (!m_object->isObject())
- m_object = 0;
- else {
- QScriptIsolate api(engine, QScriptIsolate::NotNullEngine);
- v8::HandleScope scope;
-
- v8::Handle<v8::Value> tmp = *value;
- v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(tmp);
- v8::Local<v8::Array> names;
-
- // FIXME we need newer V8!
- //names = obj->GetOwnPropertyNames();
- names = engine->getOwnPropertyNames(obj);
- m_names = v8::Persistent<v8::Array>::New(names);
- m_count = names->Length();
-
- engine->registerValueIterator(this);
- }
-}
-
-inline QJSValueIteratorPrivate::~QJSValueIteratorPrivate()
-{
- if (isValid()) {
- engine()->unregisterValueIterator(this);
- m_names.Dispose();
- }
-}
-
-inline void QJSValueIteratorPrivate::invalidate()
-{
- m_names.Dispose();
- m_object.reset();
- m_index = 0;
- m_count = 0;
-}
-
-inline bool QJSValueIteratorPrivate::hasNext() const
-{
- return isValid() ? m_index < m_count : false;
-}
-
-inline bool QJSValueIteratorPrivate::next()
-{
- if (hasNext()) {
- ++m_index;
- return true;
- }
- return false;
-}
-
-inline QString QJSValueIteratorPrivate::name() const
-{
- if (!isValid())
- return QString();
-
- v8::HandleScope handleScope;
- return QJSConverter::toString(m_names->Get(m_index - 1)->ToString());
-}
-
-inline QScriptPassPointer<QJSValuePrivate> QJSValueIteratorPrivate::value() const
-{
- if (!isValid())
- return new QJSValuePrivate();
-
- v8::HandleScope handleScope;
- return m_object->property(m_names->Get(m_index - 1)->ToString());
-}
-
-inline bool QJSValueIteratorPrivate::isValid() const
-{
- bool result = m_object ? !m_object->isUndefined() : false;
- // We know that if this object is still valid then it is an object
- // if this assumption is not correct then some other logic in this class
- // have to be changed too.
- Q_ASSERT(!result || m_object->isObject());
- return result;
-}
-
-inline QV8Engine* QJSValueIteratorPrivate::engine() const
-{
- return m_object ? m_object->engine() : 0;
-}
-
-#endif // QJSVALUEITERATOR_IMPL_P_H
diff --git a/src/declarative/qml/v8/qjsvalueiterator_p.h b/src/declarative/qml/v8/qjsvalueiterator_p.h
deleted file mode 100644
index 1bfa5cb165..0000000000
--- a/src/declarative/qml/v8/qjsvalueiterator_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QJSVALUEITERATOR_P_H
-#define QJSVALUEITERATOR_P_H
-
-#include <private/qintrusivelist_p.h>
-#include "qjsvalue_p.h"
-
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-
-class QJSValueIteratorPrivate
-{
-public:
- inline QJSValueIteratorPrivate(const QJSValuePrivate* value);
- inline ~QJSValueIteratorPrivate();
-
- inline bool hasNext() const;
- inline bool next();
-
- inline QString name() const;
-
- inline QScriptPassPointer<QJSValuePrivate> value() const;
-
- inline bool isValid() const;
- inline QV8Engine* engine() const;
-
- inline void invalidate();
-private:
- Q_DISABLE_COPY(QJSValueIteratorPrivate)
-
- QIntrusiveListNode m_node;
- QScriptSharedDataPointer<QJSValuePrivate> m_object;
- v8::Persistent<v8::Array> m_names;
- uint32_t m_index;
- uint32_t m_count;
-
- friend class QV8Engine;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QJSVALUEITERATOR_P_H
diff --git a/src/declarative/qml/v8/qscript_impl_p.h b/src/declarative/qml/v8/qscript_impl_p.h
deleted file mode 100644
index 1868fbc0de..0000000000
--- a/src/declarative/qml/v8/qscript_impl_p.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// 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.
-//
-
-#ifndef QSCRIPT_IMPL_P_H
-#define QSCRIPT_IMPL_P_H
-
-#include "qv8engine_impl_p.h"
-#include "qjsvalue_impl_p.h"
-#include "qjsvalueiterator_impl_p.h"
-#include "qjsconverter_impl_p.h"
-
-#endif //QSCRIPT_IMPL_P_H
diff --git a/src/declarative/qml/v8/qscriptisolate_p.h b/src/declarative/qml/v8/qscriptisolate_p.h
deleted file mode 100644
index 9adce9f8ab..0000000000
--- a/src/declarative/qml/v8/qscriptisolate_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef APIPREAMBLE_P_H
-#define APIPREAMBLE_P_H
-
-#include <private/qv8_p.h>
-#include "qv8engine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/**
- \internal
- Class used to switch to the right isolate. It does the same thing as v8::Isolate::Scope but
- it checks for a null engine.
- \attention We decided to put context switching "up" which means that it should be as high
- as possible on call stack. And it should be switched at most once per public API function call.
-*/
-class QScriptIsolate {
-public:
- // OperationMode was introduced to reduce number of checking for a null engine pointer. If we
- // know that given pointer is not null than we should pass NotNullEngine as constructor argument
- // that would nicely remove checking on compilation time.
- enum OperationMode {Default, NotNullEngine};
- inline QScriptIsolate(const QV8Engine *engine, const OperationMode mode = Default)
- : m_engine(engine)
- , m_mode(mode)
- {
- if (m_mode == NotNullEngine || m_engine) {
- Q_ASSERT(m_engine);
- m_engine->context()->Enter();
- }
- }
-
- inline ~QScriptIsolate()
- {
- if (m_mode == NotNullEngine || m_engine) {
- m_engine->context()->Exit();
- }
- }
-
-private:
- Q_DISABLE_COPY(QScriptIsolate);
- const QV8Engine *m_engine;
- const OperationMode m_mode;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // APIPREAMBLE_P_H
diff --git a/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h b/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h
deleted file mode 100644
index 9a656a4ca1..0000000000
--- a/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCRIPTORIGINALGLOBALOBJECT_P_H
-#define QSCRIPTORIGINALGLOBALOBJECT_P_H
-
-#include "QtCore/qglobal.h"
-#include "qjsvalue_p.h"
-
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-
-/*!
- \internal
- This class is a workaround for missing V8 API functionality. This class keeps all important
- properties of an original (default) global object, so we can use it even if the global object was
- changed.
-
- FIXME this class is a container for workarounds :-) it should be replaced by proper API calls.
-
- The class have to be created on the QV8Engine creation time (before any change got applied to
- global object).
-
- \attention All methods (apart from constructor) assumes that a context and a scope are prepared correctly.
-*/
-class QScriptOriginalGlobalObject
-{
-public:
- inline QScriptOriginalGlobalObject() {}
- inline void init(v8::Handle<v8::Context> context);
- inline void destroy();
-
- inline QJSValuePrivate::PropertyFlags getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property);
- inline v8::Local<v8::Object> getOwnPropertyDescriptor(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property) const;
- inline bool strictlyEquals(v8::Handle<v8::Object> object);
-private:
- Q_DISABLE_COPY(QScriptOriginalGlobalObject)
-
- // Copy of constructors and prototypes used in isType functions.
- v8::Persistent<v8::Function> m_ownPropertyDescriptor;
- v8::Persistent<v8::Object> m_globalObject;
-};
-
-void QScriptOriginalGlobalObject::init(v8::Handle<v8::Context> context)
-{
- // Please notice that engine is not fully initialized at this point.
-
- v8::Context::Scope contextScope(context);
-
- v8::HandleScope scope;
-
- m_globalObject = v8::Persistent<v8::Object>::New(context->Global());
-
- v8::Local<v8::Object> objectConstructor = m_globalObject->Get(v8::String::New("Object"))->ToObject();
- Q_ASSERT(objectConstructor->IsObject());
- { // Initialize m_ownPropertyDescriptor.
- v8::Local<v8::Value> ownPropertyDescriptor = objectConstructor->Get(v8::String::New("getOwnPropertyDescriptor"));
- Q_ASSERT(!ownPropertyDescriptor.IsEmpty());
- m_ownPropertyDescriptor = v8::Persistent<v8::Function>::New(v8::Local<v8::Function>::Cast(ownPropertyDescriptor));
- }
-}
-
-/*!
- \internal
- QScriptOriginalGlobalObject lives as long as QV8Engine that keeps it. In ~QSEP
- the v8 context is removed, so we need to remove our handlers before. to break this dependency
- destroy method should be called before or insight QSEP destructor.
-*/
-inline void QScriptOriginalGlobalObject::destroy()
-{
- m_ownPropertyDescriptor.Dispose();
- m_globalObject.Dispose();
- // After this line this instance is unusable.
-}
-
-inline QJSValuePrivate::PropertyFlags QScriptOriginalGlobalObject::getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property)
-{
- Q_ASSERT(object->IsObject());
- Q_ASSERT(!property.IsEmpty());
- v8::Local<v8::Object> descriptor = getOwnPropertyDescriptor(object, property);
- if (descriptor.IsEmpty()) {
-// // Property isn't owned by this object.
-// if (!(mode & QScriptValue::ResolvePrototype))
-// return 0;
- v8::Local<v8::Value> prototype = object->GetPrototype();
- if (prototype->IsNull())
- return 0;
- return getPropertyFlags(v8::Local<v8::Object>::Cast(prototype), property);
- }
- v8::Local<v8::String> writableName = v8::String::New("writable");
- v8::Local<v8::String> configurableName = v8::String::New("configurable");
- v8::Local<v8::String> enumerableName = v8::String::New("enumerable");
-// v8::Local<v8::String> getName = v8::String::New("get");
-// v8::Local<v8::String> setName = v8::String::New("set");
-
- unsigned flags = 0;
-
- if (!descriptor->Get(configurableName)->BooleanValue())
- flags |= QJSValuePrivate::Undeletable;
- if (!descriptor->Get(enumerableName)->BooleanValue())
- flags |= QJSValuePrivate::SkipInEnumeration;
-
- //"writable" is only a property of the descriptor if it is not an accessor
- if (descriptor->Has(writableName)) {
- if (!descriptor->Get(writableName)->BooleanValue())
- flags |= QJSValuePrivate::ReadOnly;
- } else {
-// if (descriptor->Get(getName)->IsObject())
-// flags |= QScriptValue::PropertyGetter;
-// if (descriptor->Get(setName)->IsObject())
-// flags |= QScriptValue::PropertySetter;
- }
-
- return QJSValuePrivate::PropertyFlag(flags);
-}
-
-inline v8::Local<v8::Object> QScriptOriginalGlobalObject::getOwnPropertyDescriptor(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property) const
-{
- Q_ASSERT(object->IsObject());
- Q_ASSERT(!property.IsEmpty());
- // FIXME do we need try catch here?
- v8::Handle<v8::Value> argv[] = {object, property};
- v8::Local<v8::Value> descriptor = m_ownPropertyDescriptor->Call(m_globalObject, /* argc */ 2, argv);
- if (descriptor.IsEmpty() || !descriptor->IsObject())
- return v8::Local<v8::Object>();
- return v8::Local<v8::Object>::Cast(descriptor);
-}
-
-inline bool QScriptOriginalGlobalObject::strictlyEquals(v8::Handle<v8::Object> object)
-{
- return m_globalObject->GetPrototype()->StrictEquals(object);
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/qml/v8/qscriptshareddata_p.h b/src/declarative/qml/v8/qscriptshareddata_p.h
deleted file mode 100644
index 4dd56798f1..0000000000
--- a/src/declarative/qml/v8/qscriptshareddata_p.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// 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.
-//
-
-#ifndef QSCRIPTSHAREDDATA_P_H
-#define QSCRIPTSHAREDDATA_P_H
-
-#include "qglobal.h"
-#include "qshareddata.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- This class should have the same interface as the QSharedData, but implementation doesn't
- need to be thread safe, so atomic ref count was replaced by normal integer value.
-*/
-class QScriptSharedData
-{
-public:
- class ReferenceCounter {
- // FIXME shouldn't it be uint or something longer?
- mutable int m_ref;
- ReferenceCounter(int ref) : m_ref(ref) {}
- ~ReferenceCounter() { Q_ASSERT_X(!m_ref, Q_FUNC_INFO, "Memory problem found"); }
- public:
- bool ref() { return ++m_ref; }
- bool deref() { return --m_ref; }
- friend class QScriptSharedData;
- };
-
- ReferenceCounter ref;
- inline QScriptSharedData() : ref(0) { }
-
-private:
- Q_DISABLE_COPY(QScriptSharedData)
-};
-
-
-template <class T> class QScriptPassPointer;
-
-// FIXME: that could be reimplemented to not check for a null value.
-template<class T>
-class QScriptSharedDataPointer : public QExplicitlySharedDataPointer<T>
-{
-public:
- inline QScriptSharedDataPointer() {}
- explicit QScriptSharedDataPointer(QScriptPassPointer<T> data) : QExplicitlySharedDataPointer<T>(data.give()) {}
- explicit QScriptSharedDataPointer(T *data) : QExplicitlySharedDataPointer<T>(data) {}
-
- inline QScriptSharedDataPointer<T> &operator=(const QScriptPassPointer<T> &other)
- {
- this->QExplicitlySharedDataPointer<T>::operator =(other.give());
- return *this;
- }
- inline QScriptSharedDataPointer<T> &operator=(T *other)
- {
- this->QExplicitlySharedDataPointer<T>::operator =(other);
- return *this;
- }
-};
-
-// FIXME: that could be reimplemented to not check for a null value.
-template <class T>
-class QScriptPassPointer {
-public:
- QScriptPassPointer(T *data) : m_ptr(data) {}
- inline QScriptPassPointer() { m_ptr = 0; }
- inline QScriptPassPointer(const QScriptPassPointer<T> &other) : m_ptr(other.give()) {}
- inline ~QScriptPassPointer() { Q_ASSERT_X(!m_ptr, Q_FUNC_INFO, "Ownership of the QScriptPassPointer hasn't been taken"); }
-
- inline T &operator*() const { return *m_ptr; }
- inline T *operator->() { return m_ptr; }
- inline T *operator->() const { return m_ptr; }
- inline T *data() const { return m_ptr; }
- inline const T *constData() const { return m_ptr; }
-
- inline bool operator==(const QScriptPassPointer<T> &other) const { return m_ptr == other.m_ptr; }
- inline bool operator!=(const QScriptPassPointer<T> &other) const { return m_ptr != other.m_ptr; }
- inline bool operator==(const QScriptSharedDataPointer<T> &other) const { return m_ptr == other.m_ptr; }
- inline bool operator!=(const QScriptSharedDataPointer<T> &other) const { return m_ptr != other.m_ptr; }
- inline bool operator==(const T *ptr) const { return m_ptr == ptr; }
- inline bool operator!=(const T *ptr) const { return m_ptr != ptr; }
-
- inline operator bool () const { return m_ptr != 0; }
- inline bool operator!() const { return !m_ptr; }
-
- inline QScriptPassPointer<T> & operator=(const QScriptPassPointer<T> &other)
- {
- if (other.m_ptr != m_ptr) {
- if (m_ptr)
- delete m_ptr;
- m_ptr = other.give();
- }
- return *this;
- }
-
- inline QScriptPassPointer &operator=(T *other)
- {
- if (other != m_ptr) {
- if (m_ptr)
- delete m_ptr;
- m_ptr = other;
- }
- return *this;
- }
-
- inline T* give() const
- {
- T* result = m_ptr;
- m_ptr = 0;
- return result;
- }
-
-private:
- mutable T* m_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QSCRIPTSHAREDDATA_P_H
diff --git a/src/declarative/qml/v8/qscripttools_p.h b/src/declarative/qml/v8/qscripttools_p.h
deleted file mode 100644
index 5b142d3900..0000000000
--- a/src/declarative/qml/v8/qscripttools_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// 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.
-//
-
-
-#ifndef QSCRIPTTOOLS_P_H
-#define QSCRIPTTOOLS_P_H
-
-#include <private/qintrusivelist_p.h>
-
-QT_BEGIN_NAMESPACE
-
-template<class N, QIntrusiveListNode N::*member>
-class QScriptIntrusiveList : public QIntrusiveList<N, member>
-{
-public:
- inline void insert(N *n);
- inline void remove(N *n);
-};
-
-template<class N, QIntrusiveListNode N::*member>
-void QScriptIntrusiveList<N, member>::insert(N *n)
-{
- Q_ASSERT_X(!this->contains(n), Q_FUNC_INFO, "Can't insert a value which is in the list already");
- Q_ASSERT_X(!(n->*member).isInList(), Q_FUNC_INFO, "Can't insert a value which is in another list");
- QIntrusiveList<N, member>::insert(n);
-}
-
-template<class N, QIntrusiveListNode N::*member>
-void QScriptIntrusiveList<N, member>::remove(N *n)
-{
- Q_ASSERT_X(this->contains(n), Q_FUNC_INFO, "Can't remove a value which is not in the list");
- QIntrusiveList<N, member>::remove(n);
-}
-
-QT_END_NAMESPACE
-
-#endif //QSCRIPTTOOLS_P_H
diff --git a/src/declarative/qml/v8/qv8_p.h b/src/declarative/qml/v8/qv8_p.h
deleted file mode 100644
index 13867bdfc8..0000000000
--- a/src/declarative/qml/v8/qv8_p.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/v8.h>
diff --git a/src/declarative/qml/v8/qv8bindings.cpp b/src/declarative/qml/v8/qv8bindings.cpp
deleted file mode 100644
index 439ba1e1a4..0000000000
--- a/src/declarative/qml/v8/qv8bindings.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8bindings_p.h"
-
-#include <private/qv8_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativecompiler_p.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativebinding_p_p.h>
-#include <private/qdeclarativeexpression_p.h>
-#include <private/qobject_p.h>
-#include <private/qdeclarativetrace_p.h>
-#include <private/qdeclarativeprofilerservice_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static QDeclarativeJavaScriptExpression::VTable QV8Bindings_Binding_jsvtable = {
- QV8Bindings::Binding::expressionIdentifier,
- QV8Bindings::Binding::expressionChanged
-};
-
-QV8Bindings::Binding::Binding()
-: QDeclarativeJavaScriptExpression(&QV8Bindings_Binding_jsvtable), target(0), parent(0)
-{
-}
-
-void QV8Bindings::Binding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags)
-{
- if (enabledFlag() != e) {
- setEnabledFlag(e);
-
- if (e) update(flags);
- }
-}
-
-void QV8Bindings::refresh()
-{
- int count = functions()->Length();
- for (int ii = 0; ii < count; ++ii)
- bindings[ii].refresh();
-}
-
-void QV8Bindings::Binding::refresh()
-{
- update();
-}
-
-int QV8Bindings::Binding::propertyIndex() const
-{
- return instruction->property.encodedIndex();
-}
-
-QObject *QV8Bindings::Binding::object() const
-{
- return target;
-}
-
-void QV8Bindings::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags)
-{
- if (!enabledFlag())
- return;
-
- QDeclarativeTrace trace("V8 Binding Update");
- trace.addDetail("URL", parent->url());
- trace.addDetail("Line", instruction->line);
- trace.addDetail("Column", instruction->column);
-
- QDeclarativeBindingProfiler prof(parent->urlString(), instruction->line, instruction->column);
-
- QDeclarativeContextData *context = parent->context();
- if (!context || !context->isValid())
- return;
-
- if (!updatingFlag()) {
- setUpdatingFlag(true);
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine);
-
- bool isUndefined = false;
-
- DeleteWatcher watcher(this);
- ep->referenceScarceResources();
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(ep->v8engine()->context());
- v8::Local<v8::Value> result =
- evaluate(context,
- v8::Handle<v8::Function>::Cast(parent->functions()->Get(instruction->value)),
- &isUndefined);
-
- trace.event("writing V8 result");
- bool needsErrorData = false;
- if (!watcher.wasDeleted() && !hasError()) {
- typedef QDeclarativePropertyPrivate PP;
- needsErrorData = !PP::writeBinding(target, instruction->property, context, this, result,
- isUndefined, flags);
- }
-
- if (!watcher.wasDeleted()) {
-
- if (needsErrorData) {
- QUrl url = parent->url();
- if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
-
- delayedError()->error.setUrl(url);
- delayedError()->error.setLine(instruction->line);
- delayedError()->error.setColumn(-1);
- }
-
- if (hasError()) {
- if (!delayedError()->addError(ep)) ep->warning(delayedError()->error);
- } else {
- clearError();
- }
-
- setUpdatingFlag(false);
- }
-
- ep->dereferenceScarceResources();
-
- } else {
- QDeclarativeProperty p = QDeclarativePropertyPrivate::restore(target, instruction->property,
- context);
- QDeclarativeBindingPrivate::printBindingLoopError(p);
- }
-}
-
-QString QV8Bindings::Binding::expressionIdentifier(QDeclarativeJavaScriptExpression *e)
-{
- Binding *This = static_cast<Binding *>(e);
- return This->parent->urlString() + QLatin1String(":") +
- QString::number(This->instruction->line);
-}
-
-void QV8Bindings::Binding::expressionChanged(QDeclarativeJavaScriptExpression *e)
-{
- Binding *This = static_cast<Binding *>(e);
- This->update(QDeclarativePropertyPrivate::DontRemoveBinding);
-}
-
-void QV8Bindings::Binding::destroy()
-{
- setEnabledFlag(false);
- removeFromObject();
- clear();
- clearError();
- parent->release();
-}
-
-QV8Bindings::QV8Bindings(QDeclarativeCompiledData::V8Program *program,
- int line,
- QDeclarativeContextData *context)
-: program(program), bindings(0), refCount(1)
-{
- program->cdata->addref();
-
- QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(context->engine);
-
- if (program->bindings.IsEmpty()) {
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- v8::Local<v8::Script> script;
- bool compileFailed = false;
- {
- v8::TryCatch try_catch;
- const QByteArray &source = program->program;
- script = engine->qmlModeCompile(source.constData(), source.length(),
- program->cdata->name, line);
- if (try_catch.HasCaught()) {
- // The binding was not compiled. There are some exceptional cases which the
- // expression rewriter does not rewrite properly (e.g., \r-terminated lines
- // are not rewritten correctly but this bug is demed out-of-scope to fix for
- // performance reasons; see QTBUG-24064).
- compileFailed = true;
- QDeclarativeError error;
- error.setDescription(QString(QLatin1String("Exception occurred during compilation of binding at line: %1")).arg(line));
- v8::Local<v8::Message> message = try_catch.Message();
- if (!message.IsEmpty())
- QDeclarativeExpressionPrivate::exceptionToError(message, error);
- QDeclarativeEnginePrivate::get(engine->engine())->warning(error);
- program->bindings = qPersistentNew(v8::Array::New());
- }
- }
-
- if (!compileFailed) {
- v8::Local<v8::Value> result = script->Run(engine->contextWrapper()->sharedContext());
- if (result->IsArray()) {
- program->bindings = qPersistentNew(v8::Local<v8::Array>::Cast(result));
- program->program.clear(); // We don't need the source anymore
- }
- }
- }
-
- int bindingsCount = functions()->Length();
- if (bindingsCount) bindings = new QV8Bindings::Binding[bindingsCount];
-
- setContext(context);
-}
-
-QV8Bindings::~QV8Bindings()
-{
- program->cdata->release();
- program = 0;
-
- delete [] bindings;
- bindings = 0;
-}
-
-QDeclarativeAbstractBinding *
-QV8Bindings::configBinding(QObject *target, QObject *scope,
- const QDeclarativeInstruction::instr_assignBinding *i)
-{
- if (!bindings) // initialization failed.
- return 0;
-
- QV8Bindings::Binding *rv = bindings + i->value;
-
- rv->instruction = i;
- rv->target = target;
- rv->setScopeObject(scope);
- rv->setUseSharedContext(true);
- rv->setNotifyOnValueChanged(true);
- rv->parent = this;
-
- addref(); // This is decremented in Binding::destroy()
-
- return rv;
-}
-
-const QUrl &QV8Bindings::url() const
-{
- return program->cdata->url;
-}
-
-const QString &QV8Bindings::urlString() const
-{
- return program->cdata->name;
-}
-
-v8::Persistent<v8::Array> &QV8Bindings::functions() const
-{
- return program->bindings;
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8bindings_p.h b/src/declarative/qml/v8/qv8bindings_p.h
deleted file mode 100644
index 14de2d1705..0000000000
--- a/src/declarative/qml/v8/qv8bindings_p.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8BINDINGS_P_H
-#define QV8BINDINGS_P_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 <private/qdeclarativepropertycache_p.h>
-#include <private/qdeclarativeinstruction_p.h>
-#include <private/qdeclarativeexpression_p.h>
-#include <private/qdeclarativecompiler_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <private/qflagpointer_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeCompiledData;
-
-class QV8BindingsPrivate;
-class QV8Bindings : public QDeclarativeAbstractExpression
-{
-public:
- QV8Bindings(QDeclarativeCompiledData::V8Program *,
- int line,
- QDeclarativeContextData *context);
- virtual ~QV8Bindings();
-
- QDeclarativeAbstractBinding *configBinding(QObject *target, QObject *scope,
- const QDeclarativeInstruction::instr_assignBinding *);
-
- // Inherited from QDeclarativeAbstractExpression
- virtual void refresh();
-
- struct Binding : public QDeclarativeJavaScriptExpression,
- public QDeclarativeAbstractBinding {
- Binding();
-
- void update() { QDeclarativeAbstractBinding::update(); }
- void refresh();
-
- // "Inherited" from QDeclarativeJavaScriptExpression
- static QString expressionIdentifier(QDeclarativeJavaScriptExpression *);
- static void expressionChanged(QDeclarativeJavaScriptExpression *);
-
- // Inherited from QDeclarativeAbstractBinding
- virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags);
- virtual void update(QDeclarativePropertyPrivate::WriteFlags flags);
- virtual void destroy();
- virtual int propertyIndex() const;
- virtual QObject *object() const;
-
- QObject *target;
- QV8Bindings *parent;
-
- // To save memory, we store flags inside the instruction pointer.
- // flag1: enabled
- // flag2: updating
- QFlagPointer<const QDeclarativeInstruction::instr_assignBinding> instruction;
-
- inline bool enabledFlag() const { return instruction.flag(); }
- inline void setEnabledFlag(bool v) { instruction.setFlagValue(v); }
- inline bool updatingFlag() const { return instruction.flag2(); }
- inline void setUpdatingFlag(bool v) { instruction.setFlag2Value(v); }
- };
-
- inline void addref();
- inline void release();
-
-private:
- Q_DISABLE_COPY(QV8Bindings)
-
- const QUrl &url() const;
- const QString &urlString() const;
- v8::Persistent<v8::Array> &functions() const;
-
- QDeclarativeCompiledData::V8Program *program;
- Binding *bindings;
- int refCount;
-};
-
-void QV8Bindings::addref()
-{
- ++refCount;
-}
-
-void QV8Bindings::release()
-{
- if (0 == --refCount)
- delete this;
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV8BINDINGS_P_H
-
-
diff --git a/src/declarative/qml/v8/qv8contextwrapper.cpp b/src/declarative/qml/v8/qv8contextwrapper.cpp
deleted file mode 100644
index 8b7fbe8941..0000000000
--- a/src/declarative/qml/v8/qv8contextwrapper.cpp
+++ /dev/null
@@ -1,455 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8contextwrapper_p.h"
-#include "qv8engine_p.h"
-
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativecontext_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static QString internal(QLatin1String("You've stumbled onto an internal implementation detail "
- "that should never have been exposed."));
-
-class QV8ContextResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(ContextType);
-
-public:
- QV8ContextResource(QV8Engine *engine, QDeclarativeContextData *context, QObject *scopeObject);
- ~QV8ContextResource();
-
- inline QDeclarativeContextData *getContext() const;
- inline QObject *getScopeObject() const;
-
- quint32 isSharedContext:1;
- quint32 hasSubContexts:1;
- quint32 readOnly:1;
- quint32 dummy:29;
-
- QObject *secondaryScope;
-
- // This is a pretty horrible hack, and an abuse of external strings. When we create a
- // sub-context (a context created by a Qt.include() in an external javascript file),
- // we pass a specially crafted SubContext external string as the v8::Script::Data() to
- // the script, which contains a pointer to the context. We can then access the
- // v8::Script::Data() later on to resolve names and URLs against the sub-context instead
- // of the main outer context.
- struct SubContext : public v8::String::ExternalStringResource {
- SubContext(QDeclarativeContextData *context) : context(context) {}
- QDeclarativeGuardedContextData context;
-
- virtual const uint16_t* data() const { return (const uint16_t *)internal.constData(); }
- virtual size_t length() const { return internal.length(); }
- };
-
-private:
- QDeclarativeGuardedContextData context;
- QDeclarativeGuard<QObject> scopeObject;
-
-};
-
-QV8ContextResource::QV8ContextResource(QV8Engine *engine, QDeclarativeContextData *context, QObject *scopeObject)
-: QV8ObjectResource(engine), isSharedContext(false), hasSubContexts(false), readOnly(true),
- secondaryScope(0), context(context), scopeObject(scopeObject)
-{
-}
-
-QV8ContextResource::~QV8ContextResource()
-{
- if (context && context->isJSContext)
- context->destroy();
-}
-
-// Returns the scope object
-QObject *QV8ContextResource::getScopeObject() const
-{
- if (isSharedContext)
- return QDeclarativeEnginePrivate::get(engine->engine())->sharedScope;
- else
- return scopeObject;
-}
-
-// Returns the context, including resolving a subcontext
-QDeclarativeContextData *QV8ContextResource::getContext() const
-{
- if (isSharedContext)
- return QDeclarativeEnginePrivate::get(engine->engine())->sharedContext;
-
- if (!hasSubContexts)
- return context;
-
- v8::Local<v8::Value> callingdata = v8::Context::GetCallingScriptData();
- if (callingdata.IsEmpty() || !callingdata->IsString())
- return context;
-
- v8::Local<v8::String> callingstring = callingdata->ToString();
- Q_ASSERT(callingstring->IsExternal());
- Q_ASSERT(callingstring->GetExternalStringResource());
-
- SubContext *sc = static_cast<SubContext *>(callingstring->GetExternalStringResource());
- return sc->context;
-}
-
-QV8ContextWrapper::QV8ContextWrapper()
-: m_engine(0)
-{
-}
-
-QV8ContextWrapper::~QV8ContextWrapper()
-{
-}
-
-void QV8ContextWrapper::destroy()
-{
- qPersistentDispose(m_sharedContext);
- qPersistentDispose(m_urlConstructor);
- qPersistentDispose(m_constructor);
-}
-
-void QV8ContextWrapper::init(QV8Engine *engine)
-{
- m_engine = engine;
- {
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
- }
- {
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->InstanceTemplate()->SetFallbackPropertyHandler(NullGetter, NullSetter);
- m_urlConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
- }
- {
- v8::Local<v8::Object> sharedContext = m_constructor->NewInstance();
- QV8ContextResource *r = new QV8ContextResource(engine, 0, 0);
- r->isSharedContext = true;
- sharedContext->SetExternalResource(r);
- m_sharedContext = qPersistentNew<v8::Object>(sharedContext);
- }
-}
-
-v8::Local<v8::Object> QV8ContextWrapper::qmlScope(QDeclarativeContextData *ctxt, QObject *scope)
-{
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- QV8ContextResource *r = new QV8ContextResource(m_engine, ctxt, scope);
- rv->SetExternalResource(r);
- return rv;
-}
-
-v8::Local<v8::Object> QV8ContextWrapper::urlScope(const QUrl &url)
-{
- QDeclarativeContextData *context = new QDeclarativeContextData;
- context->url = url;
- context->isInternal = true;
- context->isJSContext = true;
-
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv = m_urlConstructor->NewInstance();
- QV8ContextResource *r = new QV8ContextResource(m_engine, context, 0);
- rv->SetExternalResource(r);
- return rv;
-}
-
-void QV8ContextWrapper::setReadOnly(v8::Handle<v8::Object> qmlglobal, bool readOnly)
-{
- QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(qmlglobal);
- Q_ASSERT(resource);
- resource->readOnly = readOnly;
-}
-
-void QV8ContextWrapper::addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script> script,
- QDeclarativeContextData *ctxt)
-{
- QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(qmlglobal);
- Q_ASSERT(resource);
- resource->hasSubContexts = true;
- script->SetData(v8::String::NewExternal(new QV8ContextResource::SubContext(ctxt)));
-}
-
-QObject *QV8ContextWrapper::setSecondaryScope(v8::Handle<v8::Object> ctxt, QObject *scope)
-{
- QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(ctxt);
- if (!resource) return 0;
-
- QObject *rv = resource->secondaryScope;
- resource->secondaryScope = scope;
- return rv;
-}
-
-QDeclarativeContextData *QV8ContextWrapper::callingContext()
-{
- v8::Local<v8::Object> qmlglobal = v8::Context::GetCallingQmlGlobal();
- if (qmlglobal.IsEmpty()) return 0;
-
- QV8ContextResource *r = v8_resource_cast<QV8ContextResource>(qmlglobal);
- return r?r->getContext():0;
-}
-
-QDeclarativeContextData *QV8ContextWrapper::context(v8::Handle<v8::Value> value)
-{
- if (!value->IsObject())
- return 0;
-
- v8::Handle<v8::Object> qmlglobal = v8::Handle<v8::Object>::Cast(value);
- QV8ContextResource *r = v8_resource_cast<QV8ContextResource>(qmlglobal);
- return r?r->getContext():0;
-}
-
-v8::Handle<v8::Value> QV8ContextWrapper::NullGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
-
- QV8Engine *engine = resource->engine;
-
- QString error = QLatin1String("Can't find variable: ") + engine->toString(property);
- v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
-
- // Its possible we could delay the calculation of the "actual" context (in the case
- // of sub contexts) until it is definately needed.
- QDeclarativeContextData *context = resource->getContext();
- QDeclarativeContextData *expressionContext = context;
-
- if (!context)
- return v8::Undefined();
-
- if (v8::Context::GetCallingQmlGlobal() != info.This())
- return v8::Handle<v8::Value>();
-
- // Search type (attached property/enum/imported scripts) names
- // Secondary scope object
- // while (context) {
- // Search context properties
- // Search scope object
- // Search context object
- // context = context->parent
- // }
-
- QV8Engine *engine = resource->engine;
-
- QObject *scopeObject = resource->getScopeObject();
-
- QHashedV8String propertystring(property);
-
- if (context->imports && QV8Engine::startsWithUpper(property)) {
- // Search for attached properties, enums and imported scripts
- QDeclarativeTypeNameCache::Result r = context->imports->query(propertystring);
-
- if (r.isValid()) {
- if (r.scriptIndex != -1) {
- int index = r.scriptIndex;
- if (index < context->importedScripts.count())
- return context->importedScripts.at(index);
- else
- return v8::Undefined();
- } else if (r.type) {
- return engine->typeWrapper()->newObject(scopeObject, r.type);
- } else if (r.importNamespace) {
- return engine->typeWrapper()->newObject(scopeObject, context->imports, r.importNamespace);
- }
- Q_ASSERT(!"Unreachable");
- }
-
- // Fall through
- }
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine->engine());
- QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
-
- if (resource->secondaryScope) {
- v8::Handle<v8::Value> result = qobjectWrapper->getProperty(resource->secondaryScope, propertystring,
- QV8QObjectWrapper::IgnoreRevision);
- if (!result.IsEmpty()) return result;
- }
-
- while (context) {
- // Search context properties
- if (context->propertyNames) {
- int propertyIdx = context->propertyNames->value(propertystring);
-
- if (propertyIdx != -1) {
-
- if (propertyIdx < context->idValueCount) {
-
- ep->captureProperty(&context->idValues[propertyIdx].bindings);
- return engine->newQObject(context->idValues[propertyIdx]);
- } else {
-
- QDeclarativeContextPrivate *cp = context->asQDeclarativeContextPrivate();
-
- ep->captureProperty(context->asQDeclarativeContext(), -1,
- propertyIdx + cp->notifyIndex);
-
- const QVariant &value = cp->propertyValues.at(propertyIdx);
- if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
- QDeclarativeListProperty<QObject> prop(context->asQDeclarativeContext(), (void*)propertyIdx,
- 0,
- QDeclarativeContextPrivate::context_count,
- QDeclarativeContextPrivate::context_at);
- return engine->listWrapper()->newList(prop, qMetaTypeId<QDeclarativeListProperty<QObject> >());
- } else {
- return engine->fromVariant(cp->propertyValues.at(propertyIdx));
- }
- }
- }
- }
-
- // Search scope object
- if (scopeObject) {
- v8::Handle<v8::Value> result = qobjectWrapper->getProperty(scopeObject, propertystring,
- QV8QObjectWrapper::CheckRevision);
- if (!result.IsEmpty()) return result;
- }
- scopeObject = 0;
-
-
- // Search context object
- if (context->contextObject) {
- v8::Handle<v8::Value> result = qobjectWrapper->getProperty(context->contextObject, propertystring,
- QV8QObjectWrapper::CheckRevision);
- if (!result.IsEmpty()) return result;
- }
-
- context = context->parent;
- }
-
- expressionContext->unresolvedNames = true;
-
- QString error = QLatin1String("Can't find variable: ") + engine->toString(property);
- v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> QV8ContextWrapper::NullSetter(v8::Local<v8::String> property,
- v8::Local<v8::Value>,
- const v8::AccessorInfo &info)
-{
- QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
-
- QV8Engine *engine = resource->engine;
-
- if (!resource->readOnly) {
- return v8::Handle<v8::Value>();
- } else {
- QString error = QLatin1String("Invalid write to global property \"") + engine->toString(property) +
- QLatin1String("\"");
- v8::ThrowException(v8::Exception::Error(engine->toString(error)));
- return v8::Handle<v8::Value>();
- }
-}
-
-v8::Handle<v8::Value> QV8ContextWrapper::Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info)
-{
- QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
-
- // Its possible we could delay the calculation of the "actual" context (in the case
- // of sub contexts) until it is definately needed.
- QDeclarativeContextData *context = resource->getContext();
- QDeclarativeContextData *expressionContext = context;
-
- if (!context)
- return v8::Undefined();
-
- if (v8::Context::GetCallingQmlGlobal() != info.This())
- return v8::Handle<v8::Value>();
-
- // See QV8ContextWrapper::Getter for resolution order
-
- QV8Engine *engine = resource->engine;
- QObject *scopeObject = resource->getScopeObject();
-
- QHashedV8String propertystring(property);
-
- QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
-
- // Search scope object
- if (resource->secondaryScope &&
- qobjectWrapper->setProperty(resource->secondaryScope, propertystring, value,
- QV8QObjectWrapper::IgnoreRevision))
- return value;
-
- while (context) {
- // Search context properties
- if (context->propertyNames && -1 != context->propertyNames->value(propertystring))
- return value;
-
- // Search scope object
- if (scopeObject &&
- qobjectWrapper->setProperty(scopeObject, propertystring, value, QV8QObjectWrapper::CheckRevision))
- return value;
- scopeObject = 0;
-
- // Search context object
- if (context->contextObject &&
- qobjectWrapper->setProperty(context->contextObject, propertystring, value,
- QV8QObjectWrapper::CheckRevision))
- return value;
-
- context = context->parent;
- }
-
- expressionContext->unresolvedNames = true;
-
- if (!resource->readOnly) {
- return v8::Handle<v8::Value>();
- } else {
- QString error = QLatin1String("Invalid write to global property \"") + engine->toString(property) +
- QLatin1String("\"");
- v8::ThrowException(v8::Exception::Error(engine->toString(error)));
- return v8::Undefined();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8contextwrapper_p.h b/src/declarative/qml/v8/qv8contextwrapper_p.h
deleted file mode 100644
index eabbc15f15..0000000000
--- a/src/declarative/qml/v8/qv8contextwrapper_p.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8CONTEXTWRAPPER_P_H
-#define QV8CONTEXTWRAPPER_P_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 <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QUrl;
-class QObject;
-class QV8Engine;
-class QDeclarativeContextData;
-class QV8ContextWrapper
-{
-public:
- QV8ContextWrapper();
- ~QV8ContextWrapper();
-
- void init(QV8Engine *);
- void destroy();
-
- v8::Local<v8::Object> qmlScope(QDeclarativeContextData *ctxt, QObject *scope);
- v8::Local<v8::Object> urlScope(const QUrl &);
-
- void setReadOnly(v8::Handle<v8::Object>, bool);
-
- void addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script>,
- QDeclarativeContextData *ctxt);
-
- // XXX We only use the secondary scope to pass the "arguments" of the signal to
- // on<SignalName> properties. Instead of doing this we should rewrite the
- // JavaScript closure function to accept these arguments as named parameters.
- // To keep backwards compatibility we have to check that the argument names are
- // not members of the QV8Engine::illegalNames() set.
- QObject *setSecondaryScope(v8::Handle<v8::Object>, QObject *);
-
- QDeclarativeContextData *callingContext();
- QDeclarativeContextData *context(v8::Handle<v8::Value>);
-
- inline v8::Handle<v8::Object> sharedContext() const;
-
-private:
- static v8::Handle<v8::Value> NullGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> NullSetter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info);
-
- QV8Engine *m_engine;
- v8::Persistent<v8::Function> m_constructor;
- v8::Persistent<v8::Function> m_urlConstructor;
- v8::Persistent<v8::Object> m_sharedContext;
-};
-
-v8::Handle<v8::Object> QV8ContextWrapper::sharedContext() const
-{
- return m_sharedContext;
-}
-
-QT_END_NAMESPACE
-
-#endif // QV8CONTEXTWRAPPER_P_H
-
diff --git a/src/declarative/qml/v8/qv8debug_p.h b/src/declarative/qml/v8/qv8debug_p.h
deleted file mode 100644
index cf1d945712..0000000000
--- a/src/declarative/qml/v8/qv8debug_p.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/v8-debug.h>
diff --git a/src/declarative/qml/v8/qv8domerrors.cpp b/src/declarative/qml/v8/qv8domerrors.cpp
deleted file mode 100644
index 2f340e736f..0000000000
--- a/src/declarative/qml/v8/qv8domerrors.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8domerrors_p.h"
-#include "qv8engine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-void qt_add_domexceptions(QV8Engine *engine)
-{
- // DOM Exception
- v8::PropertyAttribute attributes = (v8::PropertyAttribute)(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
-
- v8::Local<v8::Object> domexception = v8::Object::New();
- domexception->Set(v8::String::New("INDEX_SIZE_ERR"), v8::Integer::New(DOMEXCEPTION_INDEX_SIZE_ERR), attributes);
- domexception->Set(v8::String::New("DOMSTRING_SIZE_ERR"), v8::Integer::New(DOMEXCEPTION_DOMSTRING_SIZE_ERR), attributes);
- domexception->Set(v8::String::New("HIERARCHY_REQUEST_ERR"), v8::Integer::New(DOMEXCEPTION_HIERARCHY_REQUEST_ERR), attributes);
- domexception->Set(v8::String::New("WRONG_DOCUMENT_ERR"), v8::Integer::New(DOMEXCEPTION_WRONG_DOCUMENT_ERR), attributes);
- domexception->Set(v8::String::New("INVALID_CHARACTER_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_CHARACTER_ERR), attributes);
- domexception->Set(v8::String::New("NO_DATA_ALLOWED_ERR"), v8::Integer::New(DOMEXCEPTION_NO_DATA_ALLOWED_ERR), attributes);
- domexception->Set(v8::String::New("NO_MODIFICATION_ALLOWED_ERR"), v8::Integer::New(DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR), attributes);
- domexception->Set(v8::String::New("NOT_FOUND_ERR"), v8::Integer::New(DOMEXCEPTION_NOT_FOUND_ERR), attributes);
- domexception->Set(v8::String::New("NOT_SUPPORTED_ERR"), v8::Integer::New(DOMEXCEPTION_NOT_SUPPORTED_ERR), attributes);
- domexception->Set(v8::String::New("INUSE_ATTRIBUTE_ERR"), v8::Integer::New(DOMEXCEPTION_INUSE_ATTRIBUTE_ERR), attributes);
- domexception->Set(v8::String::New("INVALID_STATE_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_STATE_ERR), attributes);
- domexception->Set(v8::String::New("SYNTAX_ERR"), v8::Integer::New(DOMEXCEPTION_SYNTAX_ERR), attributes);
- domexception->Set(v8::String::New("INVALID_MODIFICATION_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_MODIFICATION_ERR), attributes);
- domexception->Set(v8::String::New("NAMESPACE_ERR"), v8::Integer::New(DOMEXCEPTION_NAMESPACE_ERR), attributes);
- domexception->Set(v8::String::New("INVALID_ACCESS_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_ACCESS_ERR), attributes);
- domexception->Set(v8::String::New("VALIDATION_ERR"), v8::Integer::New(DOMEXCEPTION_VALIDATION_ERR), attributes);
- domexception->Set(v8::String::New("TYPE_MISMATCH_ERR"), v8::Integer::New(DOMEXCEPTION_TYPE_MISMATCH_ERR), attributes);
- engine->global()->Set(v8::String::New("DOMException"), domexception);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8domerrors_p.h b/src/declarative/qml/v8/qv8domerrors_p.h
deleted file mode 100644
index 5131f960f1..0000000000
--- a/src/declarative/qml/v8/qv8domerrors_p.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8DOMERRORS_P_H
-#define QV8DOMERRORS_P_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>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-// From DOM-Level-3-Core spec
-// http://www.w3.org/TR/DOM-Level-3-Core/core.html
-#define DOMEXCEPTION_INDEX_SIZE_ERR 1
-#define DOMEXCEPTION_DOMSTRING_SIZE_ERR 2
-#define DOMEXCEPTION_HIERARCHY_REQUEST_ERR 3
-#define DOMEXCEPTION_WRONG_DOCUMENT_ERR 4
-#define DOMEXCEPTION_INVALID_CHARACTER_ERR 5
-#define DOMEXCEPTION_NO_DATA_ALLOWED_ERR 6
-#define DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR 7
-#define DOMEXCEPTION_NOT_FOUND_ERR 8
-#define DOMEXCEPTION_NOT_SUPPORTED_ERR 9
-#define DOMEXCEPTION_INUSE_ATTRIBUTE_ERR 10
-#define DOMEXCEPTION_INVALID_STATE_ERR 11
-#define DOMEXCEPTION_SYNTAX_ERR 12
-#define DOMEXCEPTION_INVALID_MODIFICATION_ERR 13
-#define DOMEXCEPTION_NAMESPACE_ERR 14
-#define DOMEXCEPTION_INVALID_ACCESS_ERR 15
-#define DOMEXCEPTION_VALIDATION_ERR 16
-#define DOMEXCEPTION_TYPE_MISMATCH_ERR 17
-
-#define V8THROW_DOM(error, string) { \
- v8::Local<v8::Value> v = v8::Exception::Error(v8::String::New(string)); \
- v->ToObject()->Set(v8::String::New("code"), v8::Integer::New(error)); \
- v8::ThrowException(v); \
- return v8::Handle<v8::Value>(); \
-}
-class QV8Engine;
-void qt_add_domexceptions(QV8Engine *engine);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV8DOMERRORS_P_H
diff --git a/src/declarative/qml/v8/qv8engine.cpp b/src/declarative/qml/v8/qv8engine.cpp
deleted file mode 100644
index 70e6528f0a..0000000000
--- a/src/declarative/qml/v8/qv8engine.cpp
+++ /dev/null
@@ -1,1600 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8engine_p.h"
-
-#include <QtGui/QGuiApplication>
-
-#include "qv8contextwrapper_p.h"
-#include "qv8valuetypewrapper_p.h"
-#include "qv8sequencewrapper_p.h"
-#include "qv8include_p.h"
-#include "qjsengine_p.h"
-#include "../../../3rdparty/javascriptcore/DateMath.h"
-
-#include <private/qdeclarativebuiltinfunctions_p.h>
-#include <private/qdeclarativelist_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativeapplication_p.h>
-#include <private/qdeclarativexmlhttprequest_p.h>
-#include <private/qdeclarativelocale_p.h>
-
-#include "qscript_impl_p.h"
-#include "qv8domerrors_p.h"
-#include "qv8sqlerrors_p.h"
-
-
-Q_DECLARE_METATYPE(QJSValue)
-Q_DECLARE_METATYPE(QList<int>)
-
-
-// XXX TODO: Need to check all the global functions will also work in a worker script where the
-// QDeclarativeEngine is not available
-QT_BEGIN_NAMESPACE
-
-static bool ObjectComparisonCallback(v8::Local<v8::Object> lhs, v8::Local<v8::Object> rhs)
-{
- if (lhs == rhs)
- return true;
-
- if (lhs.IsEmpty() || rhs.IsEmpty())
- return false;
-
- QV8ObjectResource *lhsr = static_cast<QV8ObjectResource*>(lhs->GetExternalResource());
- QV8ObjectResource *rhsr = static_cast<QV8ObjectResource*>(rhs->GetExternalResource());
-
- if (lhsr && rhsr) {
- Q_ASSERT(lhsr->engine == rhsr->engine);
- QV8ObjectResource::ResourceType lhst = lhsr->resourceType();
- QV8ObjectResource::ResourceType rhst = rhsr->resourceType();
-
- switch (lhst) {
- case QV8ObjectResource::ValueTypeType:
- // a value type might be equal to a variant or another value type
- if (rhst == QV8ObjectResource::ValueTypeType) {
- return lhsr->engine->valueTypeWrapper()->isEqual(lhsr, lhsr->engine->valueTypeWrapper()->toVariant(rhsr));
- } else if (rhst == QV8ObjectResource::VariantType) {
- return lhsr->engine->valueTypeWrapper()->isEqual(lhsr, lhsr->engine->variantWrapper()->toVariant(rhsr));
- }
- break;
- case QV8ObjectResource::VariantType:
- // a variant might be equal to a value type or other variant.
- if (rhst == QV8ObjectResource::VariantType) {
- return lhsr->engine->variantWrapper()->toVariant(lhsr) ==
- lhsr->engine->variantWrapper()->toVariant(rhsr);
- } else if (rhst == QV8ObjectResource::ValueTypeType) {
- return rhsr->engine->valueTypeWrapper()->isEqual(rhsr, rhsr->engine->variantWrapper()->toVariant(lhsr));
- }
- break;
- case QV8ObjectResource::SequenceType:
- // a sequence might be equal to itself.
- if (rhst == QV8ObjectResource::SequenceType) {
- return lhsr->engine->sequenceWrapper()->isEqual(lhsr, rhsr);
- }
- break;
- default:
- break;
- }
- }
-
- return false;
-}
-
-
-QV8Engine::QV8Engine(QJSEngine* qq, QJSEngine::ContextOwnership ownership)
- : q(qq)
- , m_engine(0)
- , m_ownsV8Context(ownership == QJSEngine::CreateNewContext)
- , m_xmlHttpRequestData(0)
- , m_listModelData(0)
-{
- qMetaTypeId<QJSValue>();
- qMetaTypeId<QList<int> >();
-
- QByteArray v8args = qgetenv("V8ARGS");
- // change default v8 behaviour to not relocate breakpoints across lines
- if (!v8args.contains("breakpoint_relocation"))
- v8args.append(" --nobreakpoint_relocation");
- v8::V8::SetFlagsFromString(v8args.constData(), v8args.length());
-
- ensurePerThreadIsolate();
-
- v8::HandleScope handle_scope;
- m_context = (ownership == QJSEngine::CreateNewContext) ? v8::Context::New() : v8::Persistent<v8::Context>::New(v8::Context::GetCurrent());
- qPersistentRegister(m_context);
- m_originalGlobalObject.init(m_context);
- v8::Context::Scope context_scope(m_context);
-
- v8::V8::SetUserObjectComparisonCallbackFunction(ObjectComparisonCallback);
- QV8GCCallback::registerGcPrologueCallback();
- m_strongReferencer = qPersistentNew(v8::Object::New());
-
- m_stringWrapper.init();
- m_contextWrapper.init(this);
- m_qobjectWrapper.init(this);
- m_typeWrapper.init(this);
- m_listWrapper.init(this);
- m_variantWrapper.init(this);
- m_valueTypeWrapper.init(this);
- m_sequenceWrapper.init(this);
-
- {
- v8::Handle<v8::Value> v = global()->Get(v8::String::New("Object"))->ToObject()->Get(v8::String::New("getOwnPropertyNames"));
- m_getOwnPropertyNames = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(v));
- }
-}
-
-QV8Engine::~QV8Engine()
-{
- Q_ASSERT_X(v8::Isolate::GetCurrent(), "QV8Engine::~QV8Engine()", "called after v8::Isolate has exited");
- for (int ii = 0; ii < m_extensionData.count(); ++ii)
- delete m_extensionData[ii];
- m_extensionData.clear();
-
- qt_rem_qmlxmlhttprequest(this, m_xmlHttpRequestData);
- m_xmlHttpRequestData = 0;
- delete m_listModelData;
- m_listModelData = 0;
-
- qPersistentDispose(m_freezeObject);
- qPersistentDispose(m_getOwnPropertyNames);
-
- invalidateAllValues();
- clearExceptions();
-
- qPersistentDispose(m_strongReferencer);
-
- m_sequenceWrapper.destroy();
- m_valueTypeWrapper.destroy();
- m_variantWrapper.destroy();
- m_listWrapper.destroy();
- m_typeWrapper.destroy();
- m_qobjectWrapper.destroy();
- m_contextWrapper.destroy();
- m_stringWrapper.destroy();
-
- m_originalGlobalObject.destroy();
-
- if (m_ownsV8Context)
- qPersistentDispose(m_context);
-}
-
-QString QV8Engine::toStringStatic(v8::Handle<v8::Value> jsstr)
-{
- return toStringStatic(jsstr->ToString());
-}
-
-QString QV8Engine::toStringStatic(v8::Handle<v8::String> jsstr)
-{
- QString qstr;
- qstr.resize(jsstr->Length());
- jsstr->Write((uint16_t*)qstr.data());
- return qstr;
-}
-
-QVariant QV8Engine::toVariant(v8::Handle<v8::Value> value, int typeHint)
-{
- if (value.IsEmpty())
- return QVariant();
-
- if (typeHint == QVariant::Bool)
- return QVariant(value->BooleanValue());
-
- if (value->IsObject()) {
- QV8ObjectResource *r = (QV8ObjectResource *)value->ToObject()->GetExternalResource();
- if (r) {
- switch (r->resourceType()) {
- case QV8ObjectResource::Context2DStyleType:
- case QV8ObjectResource::Context2DPixelArrayType:
- case QV8ObjectResource::SignalHandlerType:
- case QV8ObjectResource::IncubatorType:
- case QV8ObjectResource::VisualDataItemType:
- case QV8ObjectResource::ContextType:
- case QV8ObjectResource::XMLHttpRequestType:
- case QV8ObjectResource::DOMNodeType:
- case QV8ObjectResource::SQLDatabaseType:
- case QV8ObjectResource::ListModelType:
- case QV8ObjectResource::Context2DType:
- case QV8ObjectResource::ParticleDataType:
- case QV8ObjectResource::LocaleDataType:
- return QVariant();
- case QV8ObjectResource::TypeType:
- return m_typeWrapper.toVariant(r);
- case QV8ObjectResource::QObjectType:
- return qVariantFromValue<QObject *>(m_qobjectWrapper.toQObject(r));
- case QV8ObjectResource::ListType:
- return m_listWrapper.toVariant(r);
- case QV8ObjectResource::VariantType:
- return m_variantWrapper.toVariant(r);
- case QV8ObjectResource::ValueTypeType:
- return m_valueTypeWrapper.toVariant(r);
- case QV8ObjectResource::SequenceType:
- return m_sequenceWrapper.toVariant(r);
- }
- }
- }
-
- if (value->IsArray()) {
- v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
- if (typeHint == qMetaTypeId<QList<QObject *> >()) {
- QList<QObject *> list;
- uint32_t length = array->Length();
- for (uint32_t ii = 0; ii < length; ++ii) {
- v8::Local<v8::Value> arrayItem = array->Get(ii);
- if (arrayItem->IsObject()) {
- list << toQObject(arrayItem->ToObject());
- } else {
- list << 0;
- }
- }
-
- return qVariantFromValue<QList<QObject*> >(list);
- }
-
- bool succeeded = false;
- QVariant retn = m_sequenceWrapper.toVariant(array, typeHint, &succeeded);
- if (succeeded)
- return retn;
- }
-
- return toBasicVariant(value);
-}
-
-static v8::Handle<v8::Array> arrayFromStringList(QV8Engine *engine, const QStringList &list)
-{
- v8::Context::Scope scope(engine->context());
- v8::Local<v8::Array> result = v8::Array::New(list.count());
- for (int ii = 0; ii < list.count(); ++ii)
- result->Set(ii, engine->toString(list.at(ii)));
- return result;
-}
-
-static v8::Handle<v8::Array> arrayFromVariantList(QV8Engine *engine, const QVariantList &list)
-{
- v8::Context::Scope scope(engine->context());
- v8::Local<v8::Array> result = v8::Array::New(list.count());
- for (int ii = 0; ii < list.count(); ++ii)
- result->Set(ii, engine->fromVariant(list.at(ii)));
- return result;
-}
-
-static v8::Handle<v8::Object> objectFromVariantMap(QV8Engine *engine, const QVariantMap &map)
-{
- v8::Context::Scope scope(engine->context());
- v8::Local<v8::Object> object = v8::Object::New();
- for (QVariantMap::ConstIterator iter = map.begin(); iter != map.end(); ++iter)
- object->Set(engine->toString(iter.key()), engine->fromVariant(iter.value()));
- return object;
-}
-
-Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
-
-v8::Handle<v8::Value> QV8Engine::fromVariant(const QVariant &variant)
-{
- int type = variant.userType();
- const void *ptr = variant.constData();
-
- if (type < QMetaType::User) {
- switch (QMetaType::Type(type)) {
- case QMetaType::Void:
- return v8::Undefined();
- case QMetaType::Bool:
- return v8::Boolean::New(*reinterpret_cast<const bool*>(ptr));
- case QMetaType::Int:
- return v8::Integer::New(*reinterpret_cast<const int*>(ptr));
- case QMetaType::UInt:
- return v8::Integer::NewFromUnsigned(*reinterpret_cast<const uint*>(ptr));
- case QMetaType::LongLong:
- return v8::Number::New(*reinterpret_cast<const qlonglong*>(ptr));
- case QMetaType::ULongLong:
- return v8::Number::New(*reinterpret_cast<const qulonglong*>(ptr));
- case QMetaType::Double:
- return v8::Number::New(*reinterpret_cast<const double*>(ptr));
- case QMetaType::QString:
- return m_stringWrapper.toString(*reinterpret_cast<const QString*>(ptr));
- case QMetaType::Float:
- return v8::Number::New(*reinterpret_cast<const float*>(ptr));
- case QMetaType::Short:
- return v8::Integer::New(*reinterpret_cast<const short*>(ptr));
- case QMetaType::UShort:
- return v8::Integer::NewFromUnsigned(*reinterpret_cast<const unsigned short*>(ptr));
- case QMetaType::Char:
- return v8::Integer::New(*reinterpret_cast<const char*>(ptr));
- case QMetaType::UChar:
- return v8::Integer::NewFromUnsigned(*reinterpret_cast<const unsigned char*>(ptr));
- case QMetaType::QChar:
- return v8::Integer::New((*reinterpret_cast<const QChar*>(ptr)).unicode());
- case QMetaType::QDateTime:
- return v8::Date::New(qtDateTimeToJsDate(*reinterpret_cast<const QDateTime *>(ptr)));
- case QMetaType::QDate:
- return v8::Date::New(qtDateTimeToJsDate(QDateTime(*reinterpret_cast<const QDate *>(ptr))));
- case QMetaType::QTime:
- return v8::Date::New(qtDateTimeToJsDate(QDateTime(QDate(1970,1,1), *reinterpret_cast<const QTime *>(ptr))));
- case QMetaType::QRegExp:
- return QJSConverter::toRegExp(*reinterpret_cast<const QRegExp *>(ptr));
- case QMetaType::QObjectStar:
- case QMetaType::QWidgetStar:
- return newQObject(*reinterpret_cast<QObject* const *>(ptr));
- case QMetaType::QStringList:
- {
- bool succeeded = false;
- v8::Handle<v8::Value> retn = m_sequenceWrapper.fromVariant(variant, &succeeded);
- if (succeeded)
- return retn;
- return arrayFromStringList(this, *reinterpret_cast<const QStringList *>(ptr));
- }
- case QMetaType::QVariantList:
- return arrayFromVariantList(this, *reinterpret_cast<const QVariantList *>(ptr));
- case QMetaType::QVariantMap:
- return objectFromVariantMap(this, *reinterpret_cast<const QVariantMap *>(ptr));
-
- default:
- break;
- }
-
- if (m_engine) {
- if (QDeclarativeValueType *vt = QDeclarativeEnginePrivate::get(m_engine)->valueTypes[type])
- return m_valueTypeWrapper.newValueType(variant, vt);
- }
-
- } else {
- if (type == qMetaTypeId<QDeclarativeListReference>()) {
- typedef QDeclarativeListReferencePrivate QDLRP;
- QDLRP *p = QDLRP::get((QDeclarativeListReference*)ptr);
- if (p->object) {
- return m_listWrapper.newList(p->property, p->propertyType);
- } else {
- return v8::Null();
- }
- } else if (type == qMetaTypeId<QJSValue>()) {
- const QJSValue *value = reinterpret_cast<const QJSValue *>(ptr);
- QJSValuePrivate *valuep = QJSValuePrivate::get(*value);
- if (valuep->assignEngine(this))
- return v8::Local<v8::Value>::New(*valuep);
- } else if (type == qMetaTypeId<QList<QObject *> >()) {
- // XXX Can this be made more by using Array as a prototype and implementing
- // directly against QList<QObject*>?
- const QList<QObject *> &list = *(QList<QObject *>*)ptr;
- v8::Local<v8::Array> array = v8::Array::New(list.count());
- for (int ii = 0; ii < list.count(); ++ii)
- array->Set(ii, newQObject(list.at(ii)));
- return array;
- }
-
- bool objOk;
- QObject *obj = QDeclarativeMetaType::toQObject(variant, &objOk);
- if (objOk)
- return newQObject(obj);
-
- bool succeeded = false;
- v8::Handle<v8::Value> retn = m_sequenceWrapper.fromVariant(variant, &succeeded);
- if (succeeded)
- return retn;
- }
-
- // XXX TODO: To be compatible, we still need to handle:
- // + QObjectList
- // + QList<int>
-
- return m_variantWrapper.newVariant(variant);
-}
-
-// A handle scope and context must be entered
-v8::Local<v8::Script> QV8Engine::qmlModeCompile(const QString &source,
- const QString &fileName,
- int lineNumber)
-{
- v8::Local<v8::String> v8source = m_stringWrapper.toString(source);
- v8::Local<v8::String> v8fileName = m_stringWrapper.toString(fileName);
-
- v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1));
-
- v8::Local<v8::Script> script = v8::Script::Compile(v8source, &origin, 0, v8::Handle<v8::String>(),
- v8::Script::QmlMode);
-
- return script;
-}
-
-// A handle scope and context must be entered.
-// source can be either ascii or utf8.
-v8::Local<v8::Script> QV8Engine::qmlModeCompile(const char *source, int sourceLength,
- const QString &fileName,
- int lineNumber)
-{
- if (sourceLength == -1)
- sourceLength = strlen(source);
-
- v8::Local<v8::String> v8source = v8::String::New(source, sourceLength);
- v8::Local<v8::String> v8fileName = m_stringWrapper.toString(fileName);
-
- v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1));
-
- v8::Local<v8::Script> script = v8::Script::Compile(v8source, &origin, 0, v8::Handle<v8::String>(),
- v8::Script::QmlMode);
-
- return script;
-}
-
-QNetworkAccessManager *QV8Engine::networkAccessManager()
-{
- return QDeclarativeEnginePrivate::get(m_engine)->getNetworkAccessManager();
-}
-
-const QStringHash<bool> &QV8Engine::illegalNames() const
-{
- return m_illegalNames;
-}
-
-// Requires a handle scope
-v8::Local<v8::Array> QV8Engine::getOwnPropertyNames(v8::Handle<v8::Object> o)
-{
- // FIXME Newer v8 have API for this function
- v8::TryCatch tc;
- v8::Handle<v8::Value> args[] = { o };
- v8::Local<v8::Value> r = m_getOwnPropertyNames->Call(global(), 1, args);
- if (tc.HasCaught())
- return v8::Array::New();
- else
- return v8::Local<v8::Array>::Cast(r);
-}
-
-QDeclarativeContextData *QV8Engine::callingContext()
-{
- return m_contextWrapper.callingContext();
-}
-
-// Converts a JS value to a QVariant.
-// Null, Undefined -> QVariant() (invalid)
-// Boolean -> QVariant(bool)
-// Number -> QVariant(double)
-// String -> QVariant(QString)
-// Array -> QVariantList(...)
-// Date -> QVariant(QDateTime)
-// RegExp -> QVariant(QRegExp)
-// [Any other object] -> QVariantMap(...)
-QVariant QV8Engine::toBasicVariant(v8::Handle<v8::Value> value)
-{
- if (value->IsNull() || value->IsUndefined())
- return QVariant();
- if (value->IsBoolean())
- return value->ToBoolean()->Value();
- if (value->IsInt32())
- return value->ToInt32()->Value();
- if (value->IsNumber())
- return value->ToNumber()->Value();
- if (value->IsString())
- return m_stringWrapper.toString(value->ToString());
- if (value->IsDate())
- return qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(value)->NumberValue());
- // NOTE: since we convert QTime to JS Date, round trip will change the variant type (to QDateTime)!
-
- Q_ASSERT(value->IsObject());
-
- if (value->IsRegExp()) {
- v8::Context::Scope scope(context());
- return QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(value));
- }
- if (value->IsArray()) {
- v8::Context::Scope scope(context());
- QVariantList rv;
-
- v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
- int length = array->Length();
- for (int ii = 0; ii < length; ++ii)
- rv << toVariant(array->Get(ii), -1);
- return rv;
- }
- if (!value->IsFunction()) {
- v8::Context::Scope scope(context());
- v8::Handle<v8::Object> object = value->ToObject();
- return variantMapFromJS(object);
- }
-
- return QVariant();
-}
-
-
-
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-
-struct StaticQtMetaObject : public QObject
-{
- static const QMetaObject *get()
- { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
-};
-
-void QV8Engine::initializeGlobal(v8::Handle<v8::Object> global)
-{
- using namespace QDeclarativeBuiltinFunctions;
-
- v8::Local<v8::Object> console = v8::Object::New();
- v8::Local<v8::Function> consoleLogFn = V8FUNCTION(consoleLog, this);
-
- console->Set(v8::String::New("debug"), consoleLogFn);
- console->Set(v8::String::New("log"), consoleLogFn);
- console->Set(v8::String::New("info"), consoleLogFn);
- console->Set(v8::String::New("warn"), V8FUNCTION(consoleWarn, this));
- console->Set(v8::String::New("error"), V8FUNCTION(consoleError, this));
- console->Set(v8::String::New("assert"), V8FUNCTION(consoleAssert, this));
-
- console->Set(v8::String::New("count"), V8FUNCTION(consoleCount, this));
- console->Set(v8::String::New("profile"), V8FUNCTION(consoleProfile, this));
- console->Set(v8::String::New("profileEnd"), V8FUNCTION(consoleProfileEnd, this));
- console->Set(v8::String::New("time"), V8FUNCTION(consoleTime, this));
- console->Set(v8::String::New("timeEnd"), V8FUNCTION(consoleTimeEnd, this));
- console->Set(v8::String::New("trace"), V8FUNCTION(consoleTrace, this));
- console->Set(v8::String::New("exception"), V8FUNCTION(consoleException, this));
-
- v8::Local<v8::Object> qt = v8::Object::New();
-
- // Set all the enums from the "Qt" namespace
- const QMetaObject *qtMetaObject = StaticQtMetaObject::get();
- for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) {
- QMetaEnum enumerator = qtMetaObject->enumerator(ii);
- for (int jj = 0; jj < enumerator.keyCount(); ++jj) {
- qt->Set(v8::String::New(enumerator.key(jj)), v8::Integer::New(enumerator.value(jj)));
- }
- }
- qt->Set(v8::String::New("Asynchronous"), v8::Integer::New(0));
- qt->Set(v8::String::New("Synchronous"), v8::Integer::New(1));
-
- qt->Set(v8::String::New("include"), V8FUNCTION(QV8Include::include, this));
- qt->Set(v8::String::New("isQtObject"), V8FUNCTION(isQtObject, this));
- qt->Set(v8::String::New("rgba"), V8FUNCTION(rgba, this));
- qt->Set(v8::String::New("hsla"), V8FUNCTION(hsla, this));
- qt->Set(v8::String::New("rect"), V8FUNCTION(rect, this));
- qt->Set(v8::String::New("point"), V8FUNCTION(point, this));
- qt->Set(v8::String::New("size"), V8FUNCTION(size, this));
- qt->Set(v8::String::New("vector3d"), V8FUNCTION(vector3d, this));
- qt->Set(v8::String::New("vector4d"), V8FUNCTION(vector4d, this));
-
- qt->Set(v8::String::New("formatDate"), V8FUNCTION(formatDate, this));
- qt->Set(v8::String::New("formatTime"), V8FUNCTION(formatTime, this));
- qt->Set(v8::String::New("formatDateTime"), V8FUNCTION(formatDateTime, this));
-
- qt->Set(v8::String::New("openUrlExternally"), V8FUNCTION(openUrlExternally, this));
- qt->Set(v8::String::New("fontFamilies"), V8FUNCTION(fontFamilies, this));
- qt->Set(v8::String::New("md5"), V8FUNCTION(md5, this));
- qt->Set(v8::String::New("btoa"), V8FUNCTION(btoa, this));
- qt->Set(v8::String::New("atob"), V8FUNCTION(atob, this));
- qt->Set(v8::String::New("resolvedUrl"), V8FUNCTION(resolvedUrl, this));
- qt->Set(v8::String::New("locale"), V8FUNCTION(locale, this));
-
- if (m_engine) {
- qt->Set(v8::String::New("application"), newQObject(new QDeclarativeApplication(m_engine)));
- qt->Set(v8::String::New("inputMethod"), newQObject(qGuiApp->inputMethod(), CppOwnership));
- qt->Set(v8::String::New("lighter"), V8FUNCTION(lighter, this));
- qt->Set(v8::String::New("darker"), V8FUNCTION(darker, this));
- qt->Set(v8::String::New("tint"), V8FUNCTION(tint, this));
- qt->Set(v8::String::New("quit"), V8FUNCTION(quit, this));
- qt->Set(v8::String::New("createQmlObject"), V8FUNCTION(createQmlObject, this));
- qt->Set(v8::String::New("createComponent"), V8FUNCTION(createComponent, this));
- }
-
- global->Set(v8::String::New("qsTranslate"), V8FUNCTION(qsTranslate, this));
- global->Set(v8::String::New("QT_TRANSLATE_NOOP"), V8FUNCTION(qsTranslateNoOp, this));
- global->Set(v8::String::New("qsTr"), V8FUNCTION(qsTr, this));
- global->Set(v8::String::New("QT_TR_NOOP"), V8FUNCTION(qsTrNoOp, this));
- global->Set(v8::String::New("qsTrId"), V8FUNCTION(qsTrId, this));
- global->Set(v8::String::New("QT_TRID_NOOP"), V8FUNCTION(qsTrIdNoOp, this));
-
- global->Set(v8::String::New("print"), consoleLogFn);
- global->Set(v8::String::New("console"), console);
- global->Set(v8::String::New("Qt"), qt);
- global->Set(v8::String::New("gc"), V8FUNCTION(QDeclarativeBuiltinFunctions::gc, this));
-
- {
-#define STRING_ARG "(function(stringArg) { "\
- " String.prototype.arg = (function() {"\
- " return stringArg.apply(this, arguments);"\
- " })"\
- "})"
-
- v8::Local<v8::Script> registerArg = v8::Script::New(v8::String::New(STRING_ARG), 0, 0, v8::Handle<v8::String>(), v8::Script::NativeMode);
- v8::Local<v8::Value> result = registerArg->Run();
- Q_ASSERT(result->IsFunction());
- v8::Local<v8::Function> registerArgFunc = v8::Local<v8::Function>::Cast(result);
- v8::Handle<v8::Value> args = V8FUNCTION(stringArg, this);
- registerArgFunc->Call(v8::Local<v8::Object>::Cast(registerArgFunc), 1, &args);
-#undef STRING_ARG
- }
-
- QDeclarativeLocale::registerStringLocaleCompare(this);
- QDeclarativeDateExtension::registerExtension(this);
- QDeclarativeNumberExtension::registerExtension(this);
-
- qt_add_domexceptions(this);
- m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(this);
-
- qt_add_sqlexceptions(this);
-
- {
- v8::Handle<v8::Value> args[] = { global };
- v8::Local<v8::Value> names = m_getOwnPropertyNames->Call(global, 1, args);
- v8::Local<v8::Array> namesArray = v8::Local<v8::Array>::Cast(names);
- for (quint32 ii = 0; ii < namesArray->Length(); ++ii)
- m_illegalNames.insert(toString(namesArray->Get(ii)), true);
- }
-
- {
-#define FREEZE_SOURCE "(function freeze_recur(obj) { "\
- " if (Qt.isQtObject(obj)) return;"\
- " if (obj != Function.connect && obj != Function.disconnect && "\
- " obj instanceof Object) {"\
- " var properties = Object.getOwnPropertyNames(obj);"\
- " for (var prop in properties) { "\
- " if (prop == \"connect\" || prop == \"disconnect\") {"\
- " Object.freeze(obj[prop]); "\
- " continue;"\
- " }"\
- " freeze_recur(obj[prop]);"\
- " }"\
- " }"\
- " if (obj instanceof Object) {"\
- " Object.freeze(obj);"\
- " }"\
- "})"
-
- v8::Local<v8::Script> freeze = v8::Script::New(v8::String::New(FREEZE_SOURCE));
- v8::Local<v8::Value> result = freeze->Run();
- Q_ASSERT(result->IsFunction());
- m_freezeObject = qPersistentNew(v8::Local<v8::Function>::Cast(result));
-#undef FREEZE_SOURCE
- }
-}
-
-void QV8Engine::freezeObject(v8::Handle<v8::Value> value)
-{
- v8::Handle<v8::Value> args[] = { value };
- m_freezeObject->Call(global(), 1, args);
-}
-
-void QV8Engine::gc()
-{
- v8::V8::LowMemoryNotification();
- while (!v8::V8::IdleNotification()) {}
-}
-
-#ifdef QML_GLOBAL_HANDLE_DEBUGGING
-#include <QtCore/qthreadstorage.h>
-static QThreadStorage<QSet<void *> *> QV8Engine_activeHandles;
-
-void QV8Engine::registerHandle(void *handle)
-{
- if (!handle) {
- qWarning("Attempting to register a null handle");
- return;
- }
-
- if (!QV8Engine_activeHandles.hasLocalData())
- QV8Engine_activeHandles.setLocalData(new QSet<void *>);
-
- if (QV8Engine_activeHandles.localData()->contains(handle)) {
- qFatal("Handle %p already alive", handle);
- } else {
- QV8Engine_activeHandles.localData()->insert(handle);
- }
-}
-
-void QV8Engine::releaseHandle(void *handle)
-{
- if (!handle)
- return;
-
- if (!QV8Engine_activeHandles.hasLocalData())
- QV8Engine_activeHandles.setLocalData(new QSet<void *>);
-
- if (QV8Engine_activeHandles.localData()->contains(handle)) {
- QV8Engine_activeHandles.localData()->remove(handle);
- } else {
- qFatal("Handle %p already dead", handle);
- }
-}
-#endif
-
-struct QV8EngineRegistrationData
-{
- QV8EngineRegistrationData() : extensionCount(0) {}
-
- QMutex mutex;
- int extensionCount;
-};
-Q_GLOBAL_STATIC(QV8EngineRegistrationData, registrationData);
-
-QMutex *QV8Engine::registrationMutex()
-{
- return &registrationData()->mutex;
-}
-
-int QV8Engine::registerExtension()
-{
- return registrationData()->extensionCount++;
-}
-
-void QV8Engine::setExtensionData(int index, Deletable *data)
-{
- if (m_extensionData.count() <= index)
- m_extensionData.resize(index + 1);
-
- if (m_extensionData.at(index))
- delete m_extensionData.at(index);
-
- m_extensionData[index] = data;
-}
-
-double QV8Engine::qtDateTimeToJsDate(const QDateTime &dt)
-{
- // from QScriptEngine::DateTimeToMs()
- if (!dt.isValid()) {
- return qSNaN();
- }
- QDateTime utc = dt.toUTC();
- QDate date = utc.date();
- QTime time = utc.time();
- QV8DateConverter::JSC::GregorianDateTime tm;
- tm.year = date.year() - 1900;
- tm.month = date.month() - 1;
- tm.monthDay = date.day();
- tm.weekDay = date.dayOfWeek();
- tm.yearDay = date.dayOfYear();
- tm.hour = time.hour();
- tm.minute = time.minute();
- tm.second = time.second();
- return QV8DateConverter::JSC::gregorianDateTimeToMS(tm, time.msec());
-}
-
-v8::Persistent<v8::Object> *QV8Engine::findOwnerAndStrength(QObject *object, bool *shouldBeStrong)
-{
- QObject *parent = object->parent();
- if (!parent) {
- // if the object has JS ownership, the object's v8object owns the lifetime of the persistent value.
- if (QDeclarativeEngine::objectOwnership(object) == QDeclarativeEngine::JavaScriptOwnership) {
- *shouldBeStrong = false;
- return &(QDeclarativeData::get(object)->v8object);
- }
-
- // no parent, and has CPP ownership - doesn't have an implicit parent.
- *shouldBeStrong = true;
- return 0;
- }
-
- // if it is owned by CPP, it's root parent may still be owned by JS.
- // in that case, the owner of the persistent handle is the root parent's v8object.
- while (parent->parent())
- parent = parent->parent();
-
- if (QDeclarativeEngine::objectOwnership(parent) == QDeclarativeEngine::JavaScriptOwnership) {
- // root parent is owned by JS. It's v8object owns the persistent value in question.
- *shouldBeStrong = false;
- return &(QDeclarativeData::get(parent)->v8object);
- } else {
- // root parent has CPP ownership. The persistent value should not be made weak.
- *shouldBeStrong = true;
- return 0;
- }
-}
-
-QDateTime QV8Engine::qtDateTimeFromJsDate(double jsDate)
-{
- // from QScriptEngine::MsToDateTime()
- if (qIsNaN(jsDate))
- return QDateTime();
- QV8DateConverter::JSC::GregorianDateTime tm;
- QV8DateConverter::JSC::msToGregorianDateTime(jsDate, tm);
-
- // from QScriptEngine::MsFromTime()
- int ms = int(::fmod(jsDate, 1000.0));
- if (ms < 0)
- ms += int(1000.0);
-
- QDateTime convertedUTC = QDateTime(QDate(tm.year + 1900, tm.month + 1, tm.monthDay),
- QTime(tm.hour, tm.minute, tm.second, ms), Qt::UTC);
- return convertedUTC.toLocalTime();
-}
-
-void QV8Engine::addRelationshipForGC(QObject *object, v8::Persistent<v8::Value> handle)
-{
- if (handle.IsEmpty())
- return;
-
- bool handleShouldBeStrong = false;
- v8::Persistent<v8::Object> *implicitOwner = findOwnerAndStrength(object, &handleShouldBeStrong);
- if (handleShouldBeStrong) {
- v8::V8::AddImplicitReferences(m_strongReferencer, &handle, 1);
- } else if (!implicitOwner->IsEmpty()) {
- v8::V8::AddImplicitReferences(*implicitOwner, &handle, 1);
- }
-}
-
-void QV8Engine::addRelationshipForGC(QObject *object, QObject *other)
-{
- bool handleShouldBeStrong = false;
- v8::Persistent<v8::Object> *implicitOwner = findOwnerAndStrength(object, &handleShouldBeStrong);
- v8::Persistent<v8::Value> handle = QDeclarativeData::get(other, true)->v8object;
- if (handleShouldBeStrong) {
- v8::V8::AddImplicitReferences(m_strongReferencer, &handle, 1);
- } else if (!implicitOwner->IsEmpty()) {
- v8::V8::AddImplicitReferences(*implicitOwner, &handle, 1);
- }
-}
-
-static QThreadStorage<QV8Engine::ThreadData*> perThreadEngineData;
-
-bool QV8Engine::hasThreadData()
-{
- return perThreadEngineData.hasLocalData();
-}
-
-QV8Engine::ThreadData *QV8Engine::threadData()
-{
- Q_ASSERT(perThreadEngineData.hasLocalData());
- return perThreadEngineData.localData();
-}
-
-void QV8Engine::ensurePerThreadIsolate()
-{
- if (!perThreadEngineData.hasLocalData())
- perThreadEngineData.setLocalData(new ThreadData);
-}
-
-void QV8Engine::initDeclarativeGlobalObject()
-{
- v8::HandleScope handels;
- v8::Context::Scope contextScope(m_context);
- initializeGlobal(m_context->Global());
- freezeObject(m_context->Global());
-}
-
-void QV8Engine::setEngine(QDeclarativeEngine *engine)
-{
- m_engine = engine;
- initDeclarativeGlobalObject();
-}
-
-void QV8Engine::setException(v8::Handle<v8::Value> value, v8::Handle<v8::Message> msg)
-{
- m_exception.set(value, msg);
-}
-
-v8::Handle<v8::Value> QV8Engine::throwException(v8::Handle<v8::Value> value)
-{
- setException(value);
- v8::ThrowException(value);
- return value;
-}
-
-void QV8Engine::clearExceptions()
-{
- m_exception.clear();
-}
-
-v8::Handle<v8::Value> QV8Engine::uncaughtException() const
-{
- if (!hasUncaughtException())
- return v8::Handle<v8::Value>();
- return m_exception;
-}
-
-bool QV8Engine::hasUncaughtException() const
-{
- return m_exception;
-}
-
-int QV8Engine::uncaughtExceptionLineNumber() const
-{
- return m_exception.lineNumber();
-}
-
-QStringList QV8Engine::uncaughtExceptionBacktrace() const
-{
- return m_exception.backtrace();
-}
-
-/*!
- \internal
- Save the current exception on stack so it can be set again later.
- \sa QV8Engine::restoreException
-*/
-void QV8Engine::saveException()
-{
- m_exception.push();
-}
-
-/*!
- \internal
- Load a saved exception from stack. Current exception, if exists will be dropped
- \sa QV8Engine::saveException
-*/
-void QV8Engine::restoreException()
-{
- m_exception.pop();
-}
-
-QV8Engine::Exception::Exception() {}
-
-QV8Engine::Exception::~Exception()
-{
- Q_ASSERT_X(m_stack.isEmpty(), Q_FUNC_INFO, "Some saved exceptions left. Asymetric pop/push found.");
- clear();
-}
-
-void QV8Engine::Exception::set(v8::Handle<v8::Value> value, v8::Handle<v8::Message> message)
-{
- Q_ASSERT_X(!value.IsEmpty(), Q_FUNC_INFO, "Throwing an empty value handle is highly suspected");
- clear();
- m_value = v8::Persistent<v8::Value>::New(value);
- m_message = v8::Persistent<v8::Message>::New(message);
-}
-
-void QV8Engine::Exception::clear()
-{
- m_value.Dispose();
- m_value.Clear();
- m_message.Dispose();
- m_message.Clear();
-}
-
-QV8Engine::Exception::operator bool() const
-{
- return !m_value.IsEmpty();
-}
-
-QV8Engine::Exception::operator v8::Handle<v8::Value>() const
-{
- Q_ASSERT(*this);
- return m_value;
-}
-
-int QV8Engine::Exception::lineNumber() const
-{
- if (m_message.IsEmpty())
- return -1;
- return m_message->GetLineNumber();
-}
-
-QStringList QV8Engine::Exception::backtrace() const
-{
- if (m_message.IsEmpty())
- return QStringList();
-
- QStringList backtrace;
- v8::Handle<v8::StackTrace> trace = m_message->GetStackTrace();
- if (trace.IsEmpty())
- // FIXME it should not happen (SetCaptureStackTraceForUncaughtExceptions is called).
- return QStringList();
-
- for (int i = 0; i < trace->GetFrameCount(); ++i) {
- v8::Local<v8::StackFrame> frame = trace->GetFrame(i);
- backtrace.append(QJSConverter::toString(frame->GetFunctionName()));
- backtrace.append(QJSConverter::toString(frame->GetFunctionName()));
- backtrace.append(QString::fromAscii("()@"));
- backtrace.append(QJSConverter::toString(frame->GetScriptName()));
- backtrace.append(QString::fromAscii(":"));
- backtrace.append(QString::number(frame->GetLineNumber()));
- }
- return backtrace;
-}
-
-void QV8Engine::Exception::push()
-{
- m_stack.push(qMakePair(m_value, m_message));
- m_value.Clear();
- m_message.Clear();
-}
-
-void QV8Engine::Exception::pop()
-{
- Q_ASSERT_X(!m_stack.empty(), Q_FUNC_INFO, "Attempt to load unsaved exception found");
- ValueMessagePair pair = m_stack.pop();
- clear();
- m_value = pair.first;
- m_message = pair.second;
-}
-
-
-// Converts a QVariantList to JS.
-// The result is a new Array object with length equal to the length
-// of the QVariantList, and the elements being the QVariantList's
-// elements converted to JS, recursively.
-v8::Local<v8::Array> QV8Engine::variantListToJS(const QVariantList &lst)
-{
- v8::Local<v8::Array> result = v8::Array::New(lst.size());
- for (int i = 0; i < lst.size(); ++i)
- result->Set(i, variantToJS(lst.at(i)));
- return result;
-}
-
-// Converts a JS Array object to a QVariantList.
-// The result is a QVariantList with length equal to the length
-// of the JS Array, and elements being the JS Array's elements
-// converted to QVariants, recursively.
-QVariantList QV8Engine::variantListFromJS(v8::Handle<v8::Array> jsArray)
-{
- QVariantList result;
- int hash = jsArray->GetIdentityHash();
- if (visitedConversionObjects.contains(hash))
- return result; // Avoid recursion.
- v8::HandleScope handleScope;
- visitedConversionObjects.insert(hash);
- uint32_t length = jsArray->Length();
- for (uint32_t i = 0; i < length; ++i)
- result.append(variantFromJS(jsArray->Get(i)));
- visitedConversionObjects.remove(hash);
- return result;
-}
-
-// Converts a QVariantMap to JS.
-// The result is a new Object object with property names being
-// the keys of the QVariantMap, and values being the values of
-// the QVariantMap converted to JS, recursively.
-v8::Local<v8::Object> QV8Engine::variantMapToJS(const QVariantMap &vmap)
-{
- v8::Local<v8::Object> result = v8::Object::New();
- QVariantMap::const_iterator it;
- for (it = vmap.constBegin(); it != vmap.constEnd(); ++it)
- result->Set(QJSConverter::toString(it.key()), variantToJS(it.value()));
- return result;
-}
-
-// Converts a JS Object to a QVariantMap.
-// The result is a QVariantMap with keys being the property names
-// of the object, and values being the values of the JS object's
-// properties converted to QVariants, recursively.
-QVariantMap QV8Engine::variantMapFromJS(v8::Handle<v8::Object> jsObject)
-{
- QVariantMap result;
-
- v8::HandleScope handleScope;
- v8::Handle<v8::Array> propertyNames = jsObject->GetPropertyNames();
- uint32_t length = propertyNames->Length();
- if (length == 0)
- return result;
-
- int hash = jsObject->GetIdentityHash();
- if (visitedConversionObjects.contains(hash))
- return result; // Avoid recursion.
-
- visitedConversionObjects.insert(hash);
- // TODO: Only object's own property names. Include non-enumerable properties.
- for (uint32_t i = 0; i < length; ++i) {
- v8::Handle<v8::Value> name = propertyNames->Get(i);
- result.insert(QJSConverter::toString(name->ToString()), variantFromJS(jsObject->Get(name)));
- }
- visitedConversionObjects.remove(hash);
- return result;
-}
-
-// Converts the meta-type defined by the given type and data to JS.
-// Returns the value if conversion succeeded, an empty handle otherwise.
-v8::Handle<v8::Value> QV8Engine::metaTypeToJS(int type, const void *data)
-{
- Q_ASSERT(data != 0);
- v8::Handle<v8::Value> result;
-
- // check if it's one of the types we know
- switch (QMetaType::Type(type)) {
- case QMetaType::Void:
- return v8::Undefined();
- case QMetaType::Bool:
- return v8::Boolean::New(*reinterpret_cast<const bool*>(data));
- case QMetaType::Int:
- return v8::Int32::New(*reinterpret_cast<const int*>(data));
- case QMetaType::UInt:
- return v8::Uint32::New(*reinterpret_cast<const uint*>(data));
- case QMetaType::LongLong:
- return v8::Number::New(double(*reinterpret_cast<const qlonglong*>(data)));
- case QMetaType::ULongLong:
-#if defined(Q_OS_WIN) && defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 12008804
-#pragma message("** NOTE: You need the Visual Studio Processor Pack to compile support for 64bit unsigned integers.")
- return v8::Number::New(double((qlonglong)*reinterpret_cast<const qulonglong*>(data)));
-#elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
- return v8::Number::New(double((qlonglong)*reinterpret_cast<const qulonglong*>(data)));
-#else
- return v8::Number::New(double(*reinterpret_cast<const qulonglong*>(data)));
-#endif
- case QMetaType::Double:
- return v8::Number::New(double(*reinterpret_cast<const double*>(data)));
- case QMetaType::QString:
- return QJSConverter::toString(*reinterpret_cast<const QString*>(data));
- case QMetaType::Float:
- return v8::Number::New(*reinterpret_cast<const float*>(data));
- case QMetaType::Short:
- return v8::Int32::New(*reinterpret_cast<const short*>(data));
- case QMetaType::UShort:
- return v8::Uint32::New(*reinterpret_cast<const unsigned short*>(data));
- case QMetaType::Char:
- return v8::Int32::New(*reinterpret_cast<const char*>(data));
- case QMetaType::UChar:
- return v8::Uint32::New(*reinterpret_cast<const unsigned char*>(data));
- case QMetaType::QChar:
- return v8::Uint32::New((*reinterpret_cast<const QChar*>(data)).unicode());
- case QMetaType::QStringList:
- result = QJSConverter::toStringList(*reinterpret_cast<const QStringList *>(data));
- break;
- case QMetaType::QVariantList:
- result = variantListToJS(*reinterpret_cast<const QVariantList *>(data));
- break;
- case QMetaType::QVariantMap:
- result = variantMapToJS(*reinterpret_cast<const QVariantMap *>(data));
- break;
- case QMetaType::QDateTime:
- result = QJSConverter::toDateTime(*reinterpret_cast<const QDateTime *>(data));
- break;
- case QMetaType::QDate:
- result = QJSConverter::toDateTime(QDateTime(*reinterpret_cast<const QDate *>(data)));
- break;
- case QMetaType::QRegExp:
- result = QJSConverter::toRegExp(*reinterpret_cast<const QRegExp *>(data));
- break;
- case QMetaType::QObjectStar:
- case QMetaType::QWidgetStar:
- result = newQObject(*reinterpret_cast<QObject* const *>(data));
- break;
- case QMetaType::QVariant:
- result = variantToJS(*reinterpret_cast<const QVariant*>(data));
- break;
- default:
- if (type == qMetaTypeId<QJSValue>()) {
- return QJSValuePrivate::get(*reinterpret_cast<const QJSValue*>(data))->asV8Value(this);
- } else {
- QByteArray typeName = QMetaType::typeName(type);
- if (typeName.endsWith('*') && !*reinterpret_cast<void* const *>(data)) {
- return v8::Null();
- } else {
- // Fall back to wrapping in a QVariant.
- result = newVariant(QVariant(type, data));
- }
- }
- }
- return result;
-}
-
-// Converts a JS value to a meta-type.
-// data must point to a place that can store a value of the given type.
-// Returns true if conversion succeeded, false otherwise.
-bool QV8Engine::metaTypeFromJS(v8::Handle<v8::Value> value, int type, void *data) {
- // check if it's one of the types we know
- switch (QMetaType::Type(type)) {
- case QMetaType::Bool:
- *reinterpret_cast<bool*>(data) = value->ToBoolean()->Value();
- return true;
- case QMetaType::Int:
- *reinterpret_cast<int*>(data) = value->ToInt32()->Value();
- return true;
- case QMetaType::UInt:
- *reinterpret_cast<uint*>(data) = value->ToUint32()->Value();
- return true;
- case QMetaType::LongLong:
- *reinterpret_cast<qlonglong*>(data) = qlonglong(value->ToInteger()->Value());
- return true;
- case QMetaType::ULongLong:
- *reinterpret_cast<qulonglong*>(data) = qulonglong(value->ToInteger()->Value());
- return true;
- case QMetaType::Double:
- *reinterpret_cast<double*>(data) = value->ToNumber()->Value();
- return true;
- case QMetaType::QString:
- if (value->IsUndefined() || value->IsNull())
- *reinterpret_cast<QString*>(data) = QString();
- else
- *reinterpret_cast<QString*>(data) = QJSConverter::toString(value->ToString());
- return true;
- case QMetaType::Float:
- *reinterpret_cast<float*>(data) = value->ToNumber()->Value();
- return true;
- case QMetaType::Short:
- *reinterpret_cast<short*>(data) = short(value->ToInt32()->Value());
- return true;
- case QMetaType::UShort:
- *reinterpret_cast<unsigned short*>(data) = ushort(value->ToInt32()->Value()); // ### QScript::ToUInt16()
- return true;
- case QMetaType::Char:
- *reinterpret_cast<char*>(data) = char(value->ToInt32()->Value());
- return true;
- case QMetaType::UChar:
- *reinterpret_cast<unsigned char*>(data) = (unsigned char)(value->ToInt32()->Value());
- return true;
- case QMetaType::QChar:
- if (value->IsString()) {
- QString str = QJSConverter::toString(v8::Handle<v8::String>::Cast(value));
- *reinterpret_cast<QChar*>(data) = str.isEmpty() ? QChar() : str.at(0);
- } else {
- *reinterpret_cast<QChar*>(data) = QChar(ushort(value->ToInt32()->Value())); // ### QScript::ToUInt16()
- }
- return true;
- case QMetaType::QDateTime:
- if (value->IsDate()) {
- *reinterpret_cast<QDateTime *>(data) = QJSConverter::toDateTime(v8::Handle<v8::Date>::Cast(value));
- return true;
- } break;
- case QMetaType::QDate:
- if (value->IsDate()) {
- *reinterpret_cast<QDate *>(data) = QJSConverter::toDateTime(v8::Handle<v8::Date>::Cast(value)).date();
- return true;
- } break;
- case QMetaType::QRegExp:
- if (value->IsRegExp()) {
- *reinterpret_cast<QRegExp *>(data) = QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(value));
- return true;
- } break;
- case QMetaType::QObjectStar:
- if (isQObject(value) || value->IsNull()) {
- *reinterpret_cast<QObject* *>(data) = qtObjectFromJS(value);
- return true;
- } break;
- case QMetaType::QWidgetStar:
- if (isQObject(value) || value->IsNull()) {
- QObject *qo = qtObjectFromJS(value);
- if (!qo || qo->isWidgetType()) {
- *reinterpret_cast<QWidget* *>(data) = reinterpret_cast<QWidget*>(qo);
- return true;
- }
- } break;
- case QMetaType::QStringList:
- if (value->IsArray()) {
- *reinterpret_cast<QStringList *>(data) = QJSConverter::toStringList(v8::Handle<v8::Array>::Cast(value));
- return true;
- } break;
- case QMetaType::QVariantList:
- if (value->IsArray()) {
- *reinterpret_cast<QVariantList *>(data) = variantListFromJS(v8::Handle<v8::Array>::Cast(value));
- return true;
- } break;
- case QMetaType::QVariantMap:
- if (value->IsObject()) {
- *reinterpret_cast<QVariantMap *>(data) = variantMapFromJS(v8::Handle<v8::Object>::Cast(value));
- return true;
- } break;
- case QMetaType::QVariant:
- *reinterpret_cast<QVariant*>(data) = variantFromJS(value);
- return true;
- default:
- ;
- }
-
-#if 0
- if (isQtVariant(value)) {
- const QVariant &var = variantValue(value);
- // ### Enable once constructInPlace() is in qt master.
- if (var.userType() == type) {
- QMetaType::constructInPlace(type, data, var.constData());
- return true;
- }
- if (var.canConvert(QVariant::Type(type))) {
- QVariant vv = var;
- vv.convert(QVariant::Type(type));
- Q_ASSERT(vv.userType() == type);
- QMetaType::constructInPlace(type, data, vv.constData());
- return true;
- }
-
- }
-#endif
-
- // Try to use magic; for compatibility with qscriptvalue_cast.
-
- QByteArray name = QMetaType::typeName(type);
- if (convertToNativeQObject(value, name, reinterpret_cast<void* *>(data)))
- return true;
- if (isVariant(value) && name.endsWith('*')) {
- int valueType = QMetaType::type(name.left(name.size()-1));
- QVariant &var = variantValue(value);
- if (valueType == var.userType()) {
- // We have T t, T* is requested, so return &t.
- *reinterpret_cast<void* *>(data) = var.data();
- return true;
- } else {
- // Look in the prototype chain.
- v8::Handle<v8::Value> proto = value->ToObject()->GetPrototype();
- while (proto->IsObject()) {
- bool canCast = false;
- if (isVariant(proto)) {
- canCast = (type == variantValue(proto).userType())
- || (valueType && (valueType == variantValue(proto).userType()));
- }
- else if (isQObject(proto)) {
- QByteArray className = name.left(name.size()-1);
- if (QObject *qobject = qtObjectFromJS(proto))
- canCast = qobject->qt_metacast(className) != 0;
- }
- if (canCast) {
- QByteArray varTypeName = QMetaType::typeName(var.userType());
- if (varTypeName.endsWith('*'))
- *reinterpret_cast<void* *>(data) = *reinterpret_cast<void* *>(var.data());
- else
- *reinterpret_cast<void* *>(data) = var.data();
- return true;
- }
- proto = proto->ToObject()->GetPrototype();
- }
- }
- } else if (value->IsNull() && name.endsWith('*')) {
- *reinterpret_cast<void* *>(data) = 0;
- return true;
- } else if (type == qMetaTypeId<QJSValue>()) {
- *reinterpret_cast<QJSValue*>(data) = QJSValuePrivate::get(new QJSValuePrivate(this, value));
- return true;
- }
-
- return false;
-}
-
-// Converts a QVariant to JS.
-v8::Handle<v8::Value> QV8Engine::variantToJS(const QVariant &value)
-{
- return metaTypeToJS(value.userType(), value.constData());
-}
-
-// Converts a JS value to a QVariant.
-// Null, Undefined -> QVariant() (invalid)
-// Boolean -> QVariant(bool)
-// Number -> QVariant(double)
-// String -> QVariant(QString)
-// Array -> QVariantList(...)
-// Date -> QVariant(QDateTime)
-// RegExp -> QVariant(QRegExp)
-// [Any other object] -> QVariantMap(...)
-QVariant QV8Engine::variantFromJS(v8::Handle<v8::Value> value)
-{
- Q_ASSERT(!value.IsEmpty());
- if (value->IsNull() || value->IsUndefined())
- return QVariant();
- if (value->IsBoolean())
- return value->ToBoolean()->Value();
- if (value->IsInt32())
- return value->ToInt32()->Value();
- if (value->IsNumber())
- return value->ToNumber()->Value();
- if (value->IsString())
- return QJSConverter::toString(value->ToString());
- Q_ASSERT(value->IsObject());
- if (value->IsArray())
- return variantListFromJS(v8::Handle<v8::Array>::Cast(value));
- if (value->IsDate())
- return QJSConverter::toDateTime(v8::Handle<v8::Date>::Cast(value));
- if (value->IsRegExp())
- return QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(value));
- if (isVariant(value))
- return variantValue(value);
- if (isQObject(value))
- return qVariantFromValue(qtObjectFromJS(value));
- return variantMapFromJS(value->ToObject());
-}
-
-bool QV8Engine::convertToNativeQObject(v8::Handle<v8::Value> value,
- const QByteArray &targetType,
- void **result)
-{
- if (!targetType.endsWith('*'))
- return false;
- if (QObject *qobject = qtObjectFromJS(value)) {
- int start = targetType.startsWith("const ") ? 6 : 0;
- QByteArray className = targetType.mid(start, targetType.size()-start-1);
- if (void *instance = qobject->qt_metacast(className)) {
- *result = instance;
- return true;
- }
- }
- return false;
-}
-
-QObject *QV8Engine::qtObjectFromJS(v8::Handle<v8::Value> value)
-{
- if (!value->IsObject())
- return 0;
-
- QV8ObjectResource *r = (QV8ObjectResource *)value->ToObject()->GetExternalResource();
- if (!r)
- return 0;
- QV8ObjectResource::ResourceType type = r->resourceType();
- if (type == QV8ObjectResource::QObjectType)
- return qobjectWrapper()->toQObject(r);
- else if (type == QV8ObjectResource::VariantType) {
- QVariant variant = variantWrapper()->toVariant(r);
- int type = variant.userType();
- if ((type == QMetaType::QObjectStar) || (type == QMetaType::QWidgetStar))
- return *reinterpret_cast<QObject* const *>(variant.constData());
- }
- return 0;
-}
-
-
-QVariant &QV8Engine::variantValue(v8::Handle<v8::Value> value)
-{
- return variantWrapper()->variantValue(value);
-}
-
-// Creates a QVariant wrapper object.
-v8::Local<v8::Object> QV8Engine::newVariant(const QVariant &value)
-{
- return variantWrapper()->newVariant(value);
-}
-
-QScriptPassPointer<QJSValuePrivate> QV8Engine::evaluate(v8::Handle<v8::Script> script, v8::TryCatch& tryCatch)
-{
- v8::HandleScope handleScope;
-
- clearExceptions();
- if (script.IsEmpty()) {
- v8::Handle<v8::Value> exception = tryCatch.Exception();
- if (exception.IsEmpty()) {
- // This is possible on syntax errors like { a:12, b:21 } <- missing "(", ")" around expression.
- return new QJSValuePrivate(this);
- }
- setException(exception, tryCatch.Message());
- return new QJSValuePrivate(this, exception);
- }
- v8::Handle<v8::Value> result;
- result = script->Run();
- if (result.IsEmpty()) {
- v8::Handle<v8::Value> exception = tryCatch.Exception();
- // TODO: figure out why v8 doesn't always produce an exception value
- //Q_ASSERT(!exception.IsEmpty());
- if (exception.IsEmpty())
- exception = v8::Exception::Error(v8::String::New("missing exception value"));
- setException(exception, tryCatch.Message());
- return new QJSValuePrivate(this, exception);
- }
- return new QJSValuePrivate(this, result);
-}
-
-QJSValue QV8Engine::scriptValueFromInternal(v8::Handle<v8::Value> value) const
-{
- if (value.IsEmpty())
- return QJSValuePrivate::get(new QJSValuePrivate(const_cast<QV8Engine*>(this)));
- return QJSValuePrivate::get(new QJSValuePrivate(const_cast<QV8Engine*>(this), value));
-}
-
-QScriptPassPointer<QJSValuePrivate> QV8Engine::newArray(uint length)
-{
- return new QJSValuePrivate(this, v8::Array::New(length));
-}
-
-void QV8Engine::emitSignalHandlerException()
-{
- emit q->signalHandlerException(scriptValueFromInternal(uncaughtException()));
-}
-
-void QV8Engine::startTimer(const QString &timerName)
-{
- if (!m_time.isValid())
- m_time.start();
- m_startedTimers[timerName] = m_time.elapsed();
-}
-
-qint64 QV8Engine::stopTimer(const QString &timerName, bool *wasRunning)
-{
- if (!m_startedTimers.contains(timerName)) {
- *wasRunning = false;
- return 0;
- }
- *wasRunning = true;
- qint64 startedAt = m_startedTimers.take(timerName);
- return m_time.elapsed() - startedAt;
-}
-
-int QV8Engine::consoleCountHelper(const QString &file, int line, int column)
-{
- const QString key = file + QString::number(line) + QString::number(column);
- int number = m_consoleCount.value(key, 0);
- number++;
- m_consoleCount.insert(key, number);
- return number;
-}
-
-void QV8GCCallback::registerGcPrologueCallback()
-{
- QV8Engine::ThreadData *td = QV8Engine::threadData();
- if (!td->gcPrologueCallbackRegistered) {
- td->gcPrologueCallbackRegistered = true;
- v8::V8::AddGCPrologueCallback(QV8GCCallback::garbageCollectorPrologueCallback, v8::kGCTypeMarkSweepCompact);
- }
-}
-
-QV8GCCallback::Node::Node(PrologueCallback callback)
- : prologueCallback(callback)
-{
-}
-
-QV8GCCallback::Node::~Node()
-{
- node.remove();
-}
-
-/*
- Ensure that each persistent handle is strong if it has CPP ownership
- and has no implicitly JS owned object owner in its parent chain, and
- weak otherwise.
-
- Any weak handle whose parent object is still alive will have an implicit
- reference (between the parent and the handle) added, so that it will
- not be collected.
-
- Note that this callback is registered only for kGCTypeMarkSweepCompact
- collection cycles, as it is during collection cycles of that type
- in which weak persistent handle callbacks are called when required.
- */
-void QV8GCCallback::garbageCollectorPrologueCallback(v8::GCType, v8::GCCallbackFlags)
-{
- if (!QV8Engine::hasThreadData())
- return;
-
- QV8Engine::ThreadData *td = QV8Engine::threadData();
- QV8GCCallback::Node *currNode = td->gcCallbackNodes.first();
-
- while (currNode) {
- // The client which adds itself to the list is responsible
- // for maintaining the correct implicit references in the
- // specified callback.
- currNode->prologueCallback(currNode);
- currNode = td->gcCallbackNodes.next(currNode);
- }
-}
-
-void QV8GCCallback::addGcCallbackNode(QV8GCCallback::Node *node)
-{
- QV8Engine::ThreadData *td = QV8Engine::threadData();
- td->gcCallbackNodes.insert(node);
-}
-
-QV8Engine::ThreadData::ThreadData()
- : gcPrologueCallbackRegistered(false)
-{
- if (!v8::Isolate::GetCurrent()) {
- isolate = v8::Isolate::New();
- isolate->Enter();
- } else {
- isolate = 0;
- }
-}
-
-QV8Engine::ThreadData::~ThreadData()
-{
- if (isolate) {
- isolate->Exit();
- isolate->Dispose();
- isolate = 0;
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/v8/qv8engine_impl_p.h b/src/declarative/qml/v8/qv8engine_impl_p.h
deleted file mode 100644
index ea8a0b1076..0000000000
--- a/src/declarative/qml/v8/qv8engine_impl_p.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8ENGINE_IMPL_P_H
-#define QV8ENGINE_IMPL_P_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 "qv8engine_p.h"
-#include "qjsvalue_p.h"
-#include "qjsconverter_p.h"
-#include "qjsvalueiterator_p.h"
-
-QT_BEGIN_NAMESPACE
-
-inline v8::Handle<v8::Value> QV8Engine::makeJSValue(bool value)
-{
- return value ? v8::True() : v8::False();
-}
-
-inline v8::Local<v8::Value> QV8Engine::makeJSValue(int value)
-{
- return v8::Integer::New(value);
-}
-
-inline v8::Local<v8::Value> QV8Engine::makeJSValue(uint value)
-{
- return v8::Integer::NewFromUnsigned(value);
-}
-
-inline v8::Local<v8::Value> QV8Engine::makeJSValue(double value)
-{
- return v8::Number::New(value);
-}
-
-inline v8::Handle<v8::Value> QV8Engine::makeJSValue(QJSValue::SpecialValue value) {
- if (value == QJSValue::NullValue)
- return v8::Null();
- return v8::Undefined();
-}
-
-inline v8::Local<v8::Value> QV8Engine::makeJSValue(const QString &value)
-{
- return QJSConverter::toString(value);
-}
-
-class QtScriptBagCleaner
-{
-public:
- template<class T>
- void operator () (T* value) const
- {
- value->reinitialize();
- }
- void operator () (QJSValueIteratorPrivate *iterator) const
- {
- iterator->invalidate();
- }
-};
-
-inline void QV8Engine::registerValue(QJSValuePrivate *data)
-{
- m_values.insert(data);
-}
-
-inline void QV8Engine::unregisterValue(QJSValuePrivate *data)
-{
- m_values.remove(data);
-}
-
-inline void QV8Engine::invalidateAllValues()
-{
- ValueList::iterator it;
- for (it = m_values.begin(); it != m_values.end(); it = it.erase())
- (*it)->invalidate();
- Q_ASSERT(m_values.isEmpty());
-}
-
-inline void QV8Engine::registerValueIterator(QJSValueIteratorPrivate *data)
-{
- m_valueIterators.insert(data);
-}
-
-inline void QV8Engine::unregisterValueIterator(QJSValueIteratorPrivate *data)
-{
- m_valueIterators.remove(data);
-}
-
-inline void QV8Engine::invalidateAllIterators()
-{
- ValueIteratorList::iterator it;
- for (it = m_valueIterators.begin(); it != m_valueIterators.end(); it = it.erase())
- (*it)->invalidate();
- Q_ASSERT(m_valueIterators.isEmpty());
-}
-
-/*!
- \internal
- \note property can be index (v8::Integer) or a property (v8::String) name, according to ECMA script
- property would be converted to a string.
-*/
-inline QJSValuePrivate::PropertyFlags QV8Engine::getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property)
-{
- QJSValuePrivate::PropertyFlags flags = m_originalGlobalObject.getPropertyFlags(object, property);
- return flags;
-}
-
-QScriptPassPointer<QJSValuePrivate> QV8Engine::evaluate(const QString& program, const QString& fileName, int lineNumber)
-{
- v8::TryCatch tryCatch;
- v8::ScriptOrigin scriptOrigin(QJSConverter::toString(fileName), v8::Integer::New(lineNumber - 1));
- v8::Handle<v8::Script> script;
- script = v8::Script::Compile(QJSConverter::toString(program), &scriptOrigin);
- if (script.IsEmpty()) {
- // TODO: Why don't we get the exception, as with Script::Compile()?
- // Q_ASSERT(tryCatch.HasCaught());
- v8::Handle<v8::Value> error = v8::Exception::SyntaxError(v8::String::New(""));
- setException(error);
- return new QJSValuePrivate(this, error);
- }
- return evaluate(script, tryCatch);
-}
-
-QT_END_NAMESPACE
-
-#endif // QV8ENGINE_IMPL_P_H
diff --git a/src/declarative/qml/v8/qv8engine_p.h b/src/declarative/qml/v8/qv8engine_p.h
deleted file mode 100644
index 4bfb991eae..0000000000
--- a/src/declarative/qml/v8/qv8engine_p.h
+++ /dev/null
@@ -1,631 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEV8ENGINE_P_H
-#define QDECLARATIVEV8ENGINE_P_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>
-#include <QtCore/qset.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qstack.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/QElapsedTimer>
-#include <QtCore/QThreadStorage>
-
-#include <private/qv8_p.h>
-#include <qjsengine.h>
-#include <qjsvalue.h>
-#include "qjsvalue_p.h"
-#include "qjsvalueiterator_p.h"
-#include "qscriptoriginalglobalobject_p.h"
-#include "qscripttools_p.h"
-
-#include <private/qdeclarativepropertycache_p.h>
-
-#include "qv8contextwrapper_p.h"
-#include "qv8qobjectwrapper_p.h"
-#include "qv8stringwrapper_p.h"
-#include "qv8typewrapper_p.h"
-#include "qv8listwrapper_p.h"
-#include "qv8variantwrapper_p.h"
-#include "qv8valuetypewrapper_p.h"
-#include "qv8sequencewrapper_p.h"
-
-QT_BEGIN_NAMESPACE
-
-
-// Uncomment the following line to enable global handle debugging. When enabled, all the persistent
-// handles allocated using qPersistentNew() (or registered with qPersistentRegsiter()) and disposed
-// with qPersistentDispose() are tracked. If you try and do something illegal, like double disposing
-// a handle, qFatal() is called.
-// #define QML_GLOBAL_HANDLE_DEBUGGING
-
-#define V8_RESOURCE_TYPE(resourcetype) \
-public: \
- enum { V8ResourceType = QV8ObjectResource:: resourcetype }; \
- virtual QV8ObjectResource::ResourceType resourceType() const { return QV8ObjectResource:: resourcetype; } \
-private:
-
-#define V8ENGINE() ((QV8Engine *)v8::External::Unwrap(args.Data()))
-#define V8FUNCTION(function, engine) v8::FunctionTemplate::New(function, v8::External::Wrap((QV8Engine*)engine))->GetFunction()
-#define V8THROW_ERROR(string) { \
- v8::ThrowException(v8::Exception::Error(v8::String::New(string))); \
- return v8::Handle<v8::Value>(); \
-}
-#define V8THROW_TYPE(string) { \
- v8::ThrowException(v8::Exception::TypeError(v8::String::New(string))); \
- return v8::Handle<v8::Value>(); \
-}
-#define V8ENGINE_ACCESSOR() ((QV8Engine *)v8::External::Unwrap(info.Data()));
-#define V8THROW_ERROR_SETTER(string) { \
- v8::ThrowException(v8::Exception::Error(v8::String::New(string))); \
- return; \
-}
-
-#define V8_DEFINE_EXTENSION(dataclass, datafunction) \
- static inline dataclass *datafunction(QV8Engine *engine) \
- { \
- static int extensionId = -1; \
- if (extensionId == -1) { \
- QV8Engine::registrationMutex()->lock(); \
- if (extensionId == -1) \
- extensionId = QV8Engine::registerExtension(); \
- QV8Engine::registrationMutex()->unlock(); \
- } \
- dataclass *rv = (dataclass *)engine->extensionData(extensionId); \
- if (!rv) { \
- rv = new dataclass(engine); \
- engine->setExtensionData(extensionId, rv); \
- } \
- return rv; \
- } \
-
-
-class QV8Engine;
-class QV8ObjectResource : public v8::Object::ExternalResource
-{
-public:
- QV8ObjectResource(QV8Engine *engine) : engine(engine) { Q_ASSERT(engine); }
- enum ResourceType { ContextType, QObjectType, TypeType, ListType, VariantType,
- ValueTypeType, XMLHttpRequestType, DOMNodeType, SQLDatabaseType,
- ListModelType, Context2DType, Context2DStyleType, Context2DPixelArrayType,
- ParticleDataType, SignalHandlerType, IncubatorType, VisualDataItemType,
- SequenceType, LocaleDataType };
- virtual ResourceType resourceType() const = 0;
-
- QV8Engine *engine;
-};
-
-template<class T>
-inline T *v8_resource_cast(v8::Handle<v8::Object> object) {
- QV8ObjectResource *resource = static_cast<QV8ObjectResource *>(object->GetExternalResource());
- return (resource && (quint32)resource->resourceType() == (quint32)T::V8ResourceType)?static_cast<T *>(resource):0;
-}
-
-template<class T>
-inline T *v8_resource_check(v8::Handle<v8::Object> object) {
- T *resource = static_cast<T *>(object->GetExternalResource());
- Q_ASSERT(resource && resource->resourceType() == (quint32)T::V8ResourceType);
- return resource;
-}
-
-// Used to allow a QObject method take and return raw V8 handles without having to expose
-// v8 in the public API.
-// Use like this:
-// class MyClass : public QObject {
-// Q_OBJECT
-// ...
-// Q_INVOKABLE void myMethod(QDeclarativeV8Function*);
-// };
-// The QDeclarativeV8Function - and consequently the arguments and return value - only remains
-// valid during the call. If the return value isn't set within myMethod(), the will return
-// undefined.
-class QV8Engine;
-class QDeclarativeV8Function
-{
-public:
- int Length() const { return _ac; }
- v8::Local<v8::Value> operator[](int idx) { return (*_a)->Get(idx); }
- QDeclarativeContextData *context() { return _c; }
- v8::Handle<v8::Object> qmlGlobal() { return *_g; }
- void returnValue(v8::Handle<v8::Value> rv) { *_r = rv; }
- QV8Engine *engine() const { return _e; }
-private:
- friend class QV8QObjectWrapper;
- QDeclarativeV8Function();
- QDeclarativeV8Function(const QDeclarativeV8Function &);
- QDeclarativeV8Function &operator=(const QDeclarativeV8Function &);
-
- QDeclarativeV8Function(int length, v8::Handle<v8::Object> &args,
- v8::Handle<v8::Value> &rv, v8::Handle<v8::Object> &global,
- QDeclarativeContextData *c, QV8Engine *e)
- : _ac(length), _a(&args), _r(&rv), _g(&global), _c(c), _e(e) {}
-
- int _ac;
- v8::Handle<v8::Object> *_a;
- v8::Handle<v8::Value> *_r;
- v8::Handle<v8::Object> *_g;
- QDeclarativeContextData *_c;
- QV8Engine *_e;
-};
-
-class QDeclarativeV8Handle
-{
-public:
- QDeclarativeV8Handle() : d(0) {}
- QDeclarativeV8Handle(const QDeclarativeV8Handle &other) : d(other.d) {}
- QDeclarativeV8Handle &operator=(const QDeclarativeV8Handle &other) { d = other.d; return *this; }
-
- static QDeclarativeV8Handle fromHandle(v8::Handle<v8::Value> h) {
- return QDeclarativeV8Handle(*h);
- }
- v8::Handle<v8::Value> toHandle() const {
- return v8::Handle<v8::Value>((v8::Value *)d);
- }
-private:
- QDeclarativeV8Handle(void *d) : d(d) {}
- void *d;
-};
-
-class QObject;
-class QDeclarativeEngine;
-class QDeclarativeValueType;
-class QNetworkAccessManager;
-class QDeclarativeContextData;
-
-class Q_AUTOTEST_EXPORT QV8GCCallback
-{
-private:
- class ThreadData;
-public:
- static void garbageCollectorPrologueCallback(v8::GCType, v8::GCCallbackFlags);
- static void registerGcPrologueCallback();
-
- class Q_AUTOTEST_EXPORT Node {
- public:
- typedef void (*PrologueCallback)(Node *node);
- Node(PrologueCallback callback);
- ~Node();
-
- QIntrusiveListNode node;
- PrologueCallback prologueCallback;
- };
-
- static void addGcCallbackNode(Node *node);
-};
-
-class Q_DECLARATIVE_EXPORT QV8Engine
-{
-public:
- static QV8Engine* get(QJSEngine* q) { Q_ASSERT(q); return q->handle(); }
- static QJSEngine* get(QV8Engine* d) { Q_ASSERT(d); return d->q; }
-
- QV8Engine(QJSEngine* qq,QJSEngine::ContextOwnership ownership = QJSEngine::CreateNewContext);
- virtual ~QV8Engine();
-
- // This enum should be in sync with QDeclarativeEngine::ObjectOwnership
- enum ObjectOwnership { CppOwnership, JavaScriptOwnership };
-
- struct Deletable {
- virtual ~Deletable() {}
- };
-
- class Exception
- {
- typedef QPair<v8::Persistent<v8::Value>, v8::Persistent<v8::Message> > ValueMessagePair;
-
- v8::Persistent<v8::Value> m_value;
- v8::Persistent<v8::Message> m_message;
- QStack<ValueMessagePair> m_stack;
-
- Q_DISABLE_COPY(Exception)
- public:
- inline Exception();
- inline ~Exception();
- inline void set(v8::Handle<v8::Value> value, v8::Handle<v8::Message> message);
- inline void clear();
- inline operator bool() const;
- inline operator v8::Handle<v8::Value>() const;
- inline int lineNumber() const;
- inline QStringList backtrace() const;
-
- inline void push();
- inline void pop();
- };
-
- void initDeclarativeGlobalObject();
- void setEngine(QDeclarativeEngine *engine);
- QDeclarativeEngine *engine() { return m_engine; }
- v8::Local<v8::Object> global() { return m_context->Global(); }
- v8::Handle<v8::Context> context() const { return m_context; }
-
- inline void registerValue(QJSValuePrivate *data);
- inline void unregisterValue(QJSValuePrivate *data);
- inline void invalidateAllValues();
-
- inline void registerValueIterator(QJSValueIteratorPrivate *data);
- inline void unregisterValueIterator(QJSValueIteratorPrivate *data);
- inline void invalidateAllIterators();
-
- QV8ContextWrapper *contextWrapper() { return &m_contextWrapper; }
- QV8QObjectWrapper *qobjectWrapper() { return &m_qobjectWrapper; }
- QV8TypeWrapper *typeWrapper() { return &m_typeWrapper; }
- QV8ListWrapper *listWrapper() { return &m_listWrapper; }
- QV8VariantWrapper *variantWrapper() { return &m_variantWrapper; }
- QV8ValueTypeWrapper *valueTypeWrapper() { return &m_valueTypeWrapper; }
- QV8SequenceWrapper *sequenceWrapper() { return &m_sequenceWrapper; }
-
- void *xmlHttpRequestData() { return m_xmlHttpRequestData; }
-
- Deletable *listModelData() { return m_listModelData; }
- void setListModelData(Deletable *d) { if (m_listModelData) delete m_listModelData; m_listModelData = d; }
-
- QDeclarativeContextData *callingContext();
-
- v8::Local<v8::Array> getOwnPropertyNames(v8::Handle<v8::Object>);
- inline QJSValuePrivate::PropertyFlags getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property);
- void freezeObject(v8::Handle<v8::Value>);
-
- inline QString toString(v8::Handle<v8::Value> string);
- inline QString toString(v8::Handle<v8::String> string);
- static QString toStringStatic(v8::Handle<v8::Value>);
- static QString toStringStatic(v8::Handle<v8::String>);
- static inline bool startsWithUpper(v8::Handle<v8::String>);
-
- QVariant toVariant(v8::Handle<v8::Value>, int typeHint);
- v8::Handle<v8::Value> fromVariant(const QVariant &);
- inline bool isVariant(v8::Handle<v8::Value>);
-
- // Compile \a source (from \a fileName at \a lineNumber) in QML mode
- v8::Local<v8::Script> qmlModeCompile(const QString &source,
- const QString &fileName = QString(),
- int lineNumber = 1);
- v8::Local<v8::Script> qmlModeCompile(const char *source, int sourceLength = -1,
- const QString &fileName = QString(),
- int lineNumber = 1);
-
- // Return the QML global "scope" object for the \a ctxt context and \a scope object.
- inline v8::Local<v8::Object> qmlScope(QDeclarativeContextData *ctxt, QObject *scope);
-
- // Return a JS wrapper for the given QObject \a object
- inline v8::Handle<v8::Value> newQObject(QObject *object);
- inline v8::Handle<v8::Value> newQObject(QObject *object, const ObjectOwnership ownership);
- inline bool isQObject(v8::Handle<v8::Value>);
- inline QObject *toQObject(v8::Handle<v8::Value>);
-
- // Return a JS string for the given QString \a string
- inline v8::Local<v8::String> toString(const QString &string);
-
- // Create a new value type object
- inline v8::Handle<v8::Value> newValueType(QObject *, int coreIndex, QDeclarativeValueType *);
- inline v8::Handle<v8::Value> newValueType(const QVariant &, QDeclarativeValueType *);
-
- // Create a new sequence type object
- inline v8::Handle<v8::Value> newSequence(int sequenceType, QObject *, int coreIndex, bool *succeeded);
-
- // Create a new QVariant object. This doesn't examine the type of the variant, but always returns
- // a QVariant wrapper
- inline v8::Handle<v8::Value> newQVariant(const QVariant &);
-
- // Return the network access manager for this engine. By default this returns the network
- // access manager of the QDeclarativeEngine. It is overridden in the case of a threaded v8
- // instance (like in WorkerScript).
- virtual QNetworkAccessManager *networkAccessManager();
-
- // Return the list of illegal id names (the names of the properties on the global object)
- const QStringHash<bool> &illegalNames() const;
-
- inline void collectGarbage() { gc(); }
- static void gc();
-
- void clearExceptions();
- void setException(v8::Handle<v8::Value> value, v8::Handle<v8::Message> message = v8::Handle<v8::Message>());
- v8::Handle<v8::Value> throwException(v8::Handle<v8::Value> value);
- bool hasUncaughtException() const;
- int uncaughtExceptionLineNumber() const;
- QStringList uncaughtExceptionBacktrace() const;
- v8::Handle<v8::Value> uncaughtException() const;
- void saveException();
- void restoreException();
-
-#ifdef QML_GLOBAL_HANDLE_DEBUGGING
- // Used for handle debugging
- static void registerHandle(void *);
- static void releaseHandle(void *);
-#endif
-
- static QMutex *registrationMutex();
- static int registerExtension();
-
- inline Deletable *extensionData(int) const;
- void setExtensionData(int, Deletable *);
-
- inline v8::Handle<v8::Value> makeJSValue(bool value);
- inline v8::Local<v8::Value> makeJSValue(int value);
- inline v8::Local<v8::Value> makeJSValue(uint value);
- inline v8::Local<v8::Value> makeJSValue(double value);
- inline v8::Handle<v8::Value> makeJSValue(QJSValue::SpecialValue value);
- inline v8::Local<v8::Value> makeJSValue(const QString &value);
-
- inline QScriptPassPointer<QJSValuePrivate> evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
- QScriptPassPointer<QJSValuePrivate> evaluate(v8::Handle<v8::Script> script, v8::TryCatch& tryCatch);
-
- QScriptPassPointer<QJSValuePrivate> newArray(uint length);
- v8::Local<v8::Object> newVariant(const QVariant &variant);
-
- v8::Local<v8::Array> variantListToJS(const QVariantList &lst);
- QVariantList variantListFromJS(v8::Handle<v8::Array> jsArray);
-
- v8::Local<v8::Object> variantMapToJS(const QVariantMap &vmap);
- QVariantMap variantMapFromJS(v8::Handle<v8::Object> jsObject);
-
- v8::Handle<v8::Value> variantToJS(const QVariant &value);
- QVariant variantFromJS(v8::Handle<v8::Value> value);
-
- v8::Handle<v8::Value> metaTypeToJS(int type, const void *data);
- bool metaTypeFromJS(v8::Handle<v8::Value> value, int type, void *data);
-
- bool convertToNativeQObject(v8::Handle<v8::Value> value,
- const QByteArray &targetType,
- void **result);
-
- QVariant &variantValue(v8::Handle<v8::Value> value);
-
- QJSValue scriptValueFromInternal(v8::Handle<v8::Value>) const;
-
- void emitSignalHandlerException();
-
- // used for console.time(), console.timeEnd()
- void startTimer(const QString &timerName);
- qint64 stopTimer(const QString &timerName, bool *wasRunning);
-
- // used for console.count()
- int consoleCountHelper(const QString &file, int line, int column);
-
- QObject *qtObjectFromJS(v8::Handle<v8::Value> value);
- QSet<int> visitedConversionObjects;
-
- static QDateTime qtDateTimeFromJsDate(double jsDate);
-
- void addRelationshipForGC(QObject *object, v8::Persistent<v8::Value> handle);
- void addRelationshipForGC(QObject *object, QObject *other);
-
- struct ThreadData {
- ThreadData();
- ~ThreadData();
- v8::Isolate* isolate;
- bool gcPrologueCallbackRegistered;
- QIntrusiveList<QV8GCCallback::Node, &QV8GCCallback::Node::node> gcCallbackNodes;
- };
-
- static bool hasThreadData();
- static ThreadData* threadData();
- static void ensurePerThreadIsolate();
-
- v8::Persistent<v8::Object> m_strongReferencer;
-
-protected:
- QJSEngine* q;
- QDeclarativeEngine *m_engine;
- bool m_ownsV8Context;
- v8::Persistent<v8::Context> m_context;
- QScriptOriginalGlobalObject m_originalGlobalObject;
-
- QV8StringWrapper m_stringWrapper;
- QV8ContextWrapper m_contextWrapper;
- QV8QObjectWrapper m_qobjectWrapper;
- QV8TypeWrapper m_typeWrapper;
- QV8ListWrapper m_listWrapper;
- QV8VariantWrapper m_variantWrapper;
- QV8ValueTypeWrapper m_valueTypeWrapper;
- QV8SequenceWrapper m_sequenceWrapper;
-
- v8::Persistent<v8::Function> m_getOwnPropertyNames;
- v8::Persistent<v8::Function> m_freezeObject;
-
- void *m_xmlHttpRequestData;
-
- QVector<Deletable *> m_extensionData;
- Deletable *m_listModelData;
-
- QStringHash<bool> m_illegalNames;
-
- Exception m_exception;
-
- QElapsedTimer m_time;
- QHash<QString, qint64> m_startedTimers;
-
- QHash<QString, quint32> m_consoleCount;
-
- QVariant toBasicVariant(v8::Handle<v8::Value>);
-
- void initializeGlobal(v8::Handle<v8::Object>);
-
- double qtDateTimeToJsDate(const QDateTime &dt);
-
-private:
- static v8::Persistent<v8::Object> *findOwnerAndStrength(QObject *object, bool *shouldBeStrong);
-
- typedef QScriptIntrusiveList<QJSValuePrivate, &QJSValuePrivate::m_node> ValueList;
- ValueList m_values;
- typedef QScriptIntrusiveList<QJSValueIteratorPrivate, &QJSValueIteratorPrivate::m_node> ValueIteratorList;
- ValueIteratorList m_valueIterators;
-
- Q_DISABLE_COPY(QV8Engine)
-};
-
-// Allocate a new Persistent handle. *ALL* persistent handles in QML must be allocated
-// using this method.
-template<class T>
-v8::Persistent<T> qPersistentNew(v8::Handle<T> that)
-{
- v8::Persistent<T> rv = v8::Persistent<T>::New(that);
-#ifdef QML_GLOBAL_HANDLE_DEBUGGING
- QV8Engine::registerHandle(*rv);
-#endif
- return rv;
-}
-
-// Register a Persistent handle that was returned to you by V8 (such as by
-// v8::Context::New). This allows us to do handle tracking on these handles too.
-template<class T>
-void qPersistentRegister(v8::Persistent<T> handle)
-{
-#ifdef QML_GLOBAL_HANDLE_DEBUGGING
- QV8Engine::registerHandle(*handle);
-#else
- Q_UNUSED(handle);
-#endif
-}
-
-// Dispose and clear a persistent handle. *ALL* persistent handles in QML must be
-// disposed using this method.
-template<class T>
-void qPersistentDispose(v8::Persistent<T> &that)
-{
-#ifdef QML_GLOBAL_HANDLE_DEBUGGING
- QV8Engine::releaseHandle(*that);
-#endif
- that.Dispose();
- that.Clear();
-}
-
-QString QV8Engine::toString(v8::Handle<v8::Value> string)
-{
- return m_stringWrapper.toString(string->ToString());
-}
-
-QString QV8Engine::toString(v8::Handle<v8::String> string)
-{
- return m_stringWrapper.toString(string);
-}
-
-bool QV8Engine::isVariant(v8::Handle<v8::Value> value)
-{
- return m_variantWrapper.isVariant(value);
-}
-
-v8::Local<v8::Object> QV8Engine::qmlScope(QDeclarativeContextData *ctxt, QObject *scope)
-{
- return m_contextWrapper.qmlScope(ctxt, scope);
-}
-
-bool QV8Engine::isQObject(v8::Handle<v8::Value> obj)
-{
- return obj->IsObject()?m_qobjectWrapper.isQObject(v8::Handle<v8::Object>::Cast(obj)):false;
-}
-
-QObject *QV8Engine::toQObject(v8::Handle<v8::Value> obj)
-{
- return obj->IsObject()?m_qobjectWrapper.toQObject(v8::Handle<v8::Object>::Cast(obj)):0;
-}
-
-v8::Handle<v8::Value> QV8Engine::newQObject(QObject *object)
-{
- return m_qobjectWrapper.newQObject(object);
-}
-
-v8::Handle<v8::Value> QV8Engine::newQObject(QObject *object, const ObjectOwnership ownership)
-{
- if (!object)
- return v8::Null();
-
- v8::Handle<v8::Value> result = newQObject(object);
- QDeclarativeData *ddata = QDeclarativeData::get(object, true);
- if (ownership == JavaScriptOwnership && ddata) {
- ddata->indestructible = false;
- ddata->explicitIndestructibleSet = true;
- }
- return result;
-}
-
-v8::Local<v8::String> QV8Engine::toString(const QString &string)
-{
- return m_stringWrapper.toString(string);
-}
-
-v8::Handle<v8::Value> QV8Engine::newValueType(QObject *object, int property, QDeclarativeValueType *type)
-{
- return m_valueTypeWrapper.newValueType(object, property, type);
-}
-
-v8::Handle<v8::Value> QV8Engine::newValueType(const QVariant &value, QDeclarativeValueType *type)
-{
- return m_valueTypeWrapper.newValueType(value, type);
-}
-
-v8::Handle<v8::Value> QV8Engine::newSequence(int sequenceType, QObject *object, int property, bool *succeeded)
-{
- return m_sequenceWrapper.newSequence(sequenceType, object, property, succeeded);
-}
-
-// XXX Can this be made more optimal? It is called prior to resolving each and every
-// unqualified name in QV8ContextWrapper.
-bool QV8Engine::startsWithUpper(v8::Handle<v8::String> string)
-{
- uint16_t c = string->GetCharacter(0);
- return (c >= 'A' && c <= 'Z') ||
- (c > 127 && QChar::category(c) == QChar::Letter_Uppercase);
-}
-
-QV8Engine::Deletable *QV8Engine::extensionData(int index) const
-{
- if (index < m_extensionData.count())
- return m_extensionData[index];
- else
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEV8ENGINE_P_H
diff --git a/src/declarative/qml/v8/qv8include.cpp b/src/declarative/qml/v8/qv8include.cpp
deleted file mode 100644
index 116baee0e2..0000000000
--- a/src/declarative/qml/v8/qv8include.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8include_p.h"
-
-#include <QtDeclarative/qjsengine.h>
-#include <QtNetwork/qnetworkrequest.h>
-#include <QtNetwork/qnetworkreply.h>
-#include <QtCore/qfile.h>
-
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QV8Include::QV8Include(const QUrl &url, QV8Engine *engine, QDeclarativeContextData *context,
- v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Function> callback)
-: m_engine(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0), m_context(context)
-{
- m_qmlglobal = qPersistentNew<v8::Object>(qmlglobal);
- if (!callback.IsEmpty())
- m_callbackFunction = qPersistentNew<v8::Function>(callback);
-
- m_resultObject = qPersistentNew<v8::Object>(resultValue());
-
- m_network = engine->networkAccessManager();
-
- QNetworkRequest request;
- request.setUrl(url);
-
- m_reply = m_network->get(request);
- QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
-}
-
-QV8Include::~QV8Include()
-{
- delete m_reply; m_reply = 0;
- qPersistentDispose(m_callbackFunction);
- qPersistentDispose(m_resultObject);
-}
-
-v8::Local<v8::Object> QV8Include::resultValue(Status status)
-{
- // XXX It seems inefficient to create this object from scratch each time.
- v8::Local<v8::Object> result = v8::Object::New();
- result->Set(v8::String::New("OK"), v8::Integer::New(Ok));
- result->Set(v8::String::New("LOADING"), v8::Integer::New(Loading));
- result->Set(v8::String::New("NETWORK_ERROR"), v8::Integer::New(NetworkError));
- result->Set(v8::String::New("EXCEPTION"), v8::Integer::New(Exception));
-
- result->Set(v8::String::New("status"), v8::Integer::New(status));
-
- return result;
-}
-
-void QV8Include::callback(QV8Engine *engine, v8::Handle<v8::Function> callback, v8::Handle<v8::Object> status)
-{
- if (!callback.IsEmpty()) {
- v8::Handle<v8::Value> args[] = { status };
- v8::TryCatch tc;
- callback->Call(engine->global(), 1, args);
- }
-}
-
-v8::Handle<v8::Object> QV8Include::result()
-{
- return m_resultObject;
-}
-
-#define INCLUDE_MAXIMUM_REDIRECT_RECURSION 15
-void QV8Include::finished()
-{
- m_redirectCount++;
-
- if (m_redirectCount < INCLUDE_MAXIMUM_REDIRECT_RECURSION) {
- QVariant redirect = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- m_url = m_url.resolved(redirect.toUrl());
- delete m_reply;
-
- QNetworkRequest request;
- request.setUrl(m_url);
-
- m_reply = m_network->get(request);
- QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
- return;
- }
- }
-
- v8::HandleScope handle_scope;
-
- if (m_reply->error() == QNetworkReply::NoError) {
- QByteArray data = m_reply->readAll();
-
- QString code = QString::fromUtf8(data);
- QDeclarativeScript::Parser::extractPragmas(code);
-
- QDeclarativeContextData *importContext = new QDeclarativeContextData;
- importContext->isInternal = true;
- importContext->isJSContext = true;
- importContext->url = m_url;
- importContext->isPragmaLibraryContext = m_context->isPragmaLibraryContext;
- importContext->setParent(m_context, true);
-
- v8::Context::Scope ctxtscope(m_engine->context());
- v8::TryCatch try_catch;
-
- v8::Local<v8::Script> script = m_engine->qmlModeCompile(code, m_url.toString());
-
- if (!try_catch.HasCaught()) {
- m_engine->contextWrapper()->addSubContext(m_qmlglobal, script, importContext);
- script->Run(m_qmlglobal);
- }
-
- if (try_catch.HasCaught()) {
- m_resultObject->Set(v8::String::New("status"), v8::Integer::New(Exception));
- m_resultObject->Set(v8::String::New("exception"), try_catch.Exception());
- } else {
- m_resultObject->Set(v8::String::New("status"), v8::Integer::New(Ok));
- }
- } else {
- m_resultObject->Set(v8::String::New("status"), v8::Integer::New(NetworkError));
- }
-
- callback(m_engine, m_callbackFunction, m_resultObject);
-
- disconnect();
- deleteLater();
-}
-
-/*
- Documented in qv8engine.cpp
-*/
-v8::Handle<v8::Value> QV8Include::include(const v8::Arguments &args)
-{
- if (args.Length() == 0)
- return v8::Undefined();
-
- QV8Engine *engine = V8ENGINE();
- QDeclarativeContextData *context = engine->callingContext();
-
- if (!context || !context->isJSContext)
- V8THROW_ERROR("Qt.include(): Can only be called from JavaScript files");
-
- QUrl url(context->resolvedUrl(QUrl(engine->toString(args[0]->ToString()))));
-
- v8::Local<v8::Function> callbackFunction;
- if (args.Length() >= 2 && args[1]->IsFunction())
- callbackFunction = v8::Local<v8::Function>::Cast(args[1]);
-
- QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
-
- v8::Local<v8::Object> result;
-
- if (localFile.isEmpty()) {
-
- QV8Include *i = new QV8Include(url, engine, context,
- v8::Context::GetCallingQmlGlobal(),
- callbackFunction);
- result = v8::Local<v8::Object>::New(i->result());
-
- } else {
-
- QFile f(localFile);
-
- if (f.open(QIODevice::ReadOnly)) {
- QByteArray data = f.readAll();
- QString code = QString::fromUtf8(data);
- QDeclarativeScript::Parser::extractPragmas(code);
-
- QDeclarativeContextData *importContext = new QDeclarativeContextData;
- importContext->isInternal = true;
- importContext->isJSContext = true;
- importContext->url = url;
- importContext->setParent(context, true);
-
- v8::TryCatch try_catch;
-
- v8::Local<v8::Script> script = engine->qmlModeCompile(code, url.toString());
-
- if (!try_catch.HasCaught()) {
- v8::Local<v8::Object> qmlglobal = v8::Context::GetCallingQmlGlobal();
- engine->contextWrapper()->addSubContext(qmlglobal, script, importContext);
- script->Run(qmlglobal);
- }
-
- if (try_catch.HasCaught()) {
- result = resultValue(Exception);
- result->Set(v8::String::New("exception"), try_catch.Exception());
- } else {
- result = resultValue(Ok);
- }
-
- } else {
- result = resultValue(NetworkError);
- }
-
- callback(engine, callbackFunction, result);
- }
-
- if (result.IsEmpty())
- return v8::Undefined();
- else
- return result;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8include_p.h b/src/declarative/qml/v8/qv8include_p.h
deleted file mode 100644
index 89ff2967ed..0000000000
--- a/src/declarative/qml/v8/qv8include_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8INCLUDE_P_H
-#define QV8INCLUDE_P_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/qobject.h>
-#include <QtCore/qurl.h>
-
-#include <private/qdeclarativecontext_p.h>
-#include <private/qdeclarativeguard_p.h>
-
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-class QNetworkAccessManager;
-class QNetworkReply;
-class QV8Engine;
-class QV8Include : public QObject
-{
- Q_OBJECT
-public:
- enum Status {
- Ok = 0,
- Loading = 1,
- NetworkError = 2,
- Exception = 3
- };
-
- static v8::Handle<v8::Value> include(const v8::Arguments &args);
-
-private slots:
- void finished();
-
-private:
- QV8Include(const QUrl &, QV8Engine *, QDeclarativeContextData *,
- v8::Handle<v8::Object>, v8::Handle<v8::Function>);
- ~QV8Include();
-
- v8::Handle<v8::Object> result();
-
- static v8::Local<v8::Object> resultValue(Status status = Loading);
- static void callback(QV8Engine *engine, v8::Handle<v8::Function> callback, v8::Handle<v8::Object> status);
-
- QV8Engine *m_engine;
- QNetworkAccessManager *m_network;
- QDeclarativeGuard<QNetworkReply> m_reply;
-
- QUrl m_url;
- int m_redirectCount;
-
- v8::Persistent<v8::Function> m_callbackFunction;
- v8::Persistent<v8::Object> m_resultObject;
-
- QDeclarativeGuardedContextData m_context;
- v8::Persistent<v8::Object> m_qmlglobal;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV8INCLUDE_P_H
-
diff --git a/src/declarative/qml/v8/qv8listwrapper.cpp b/src/declarative/qml/v8/qv8listwrapper.cpp
deleted file mode 100644
index 08b548aa08..0000000000
--- a/src/declarative/qml/v8/qv8listwrapper.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8listwrapper_p.h"
-#include "qv8engine_p.h"
-#include <private/qdeclarativelist_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8ListResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(ListType);
-public:
- QV8ListResource(QV8Engine *engine) : QV8ObjectResource(engine) {}
-
- QDeclarativeGuard<QObject> object;
- QDeclarativeListProperty<QObject> property;
- int propertyType;
-};
-
-QV8ListWrapper::QV8ListWrapper()
-: m_engine(0)
-{
-}
-
-QV8ListWrapper::~QV8ListWrapper()
-{
-}
-
-void QV8ListWrapper::init(QV8Engine *engine)
-{
- m_engine = engine;
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter, 0, 0, Enumerator);
- ft->InstanceTemplate()->SetIndexedPropertyHandler(IndexedGetter);
- ft->InstanceTemplate()->SetAccessor(v8::String::New("length"), LengthGetter, 0,
- v8::Handle<v8::Value>(), v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum));
- ft->InstanceTemplate()->SetHasExternalResource(true);
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
-}
-
-void QV8ListWrapper::destroy()
-{
- qPersistentDispose(m_constructor);
-}
-
-v8::Handle<v8::Value> QV8ListWrapper::newList(QObject *object, int propId, int propType)
-{
- if (!object || propId == -1)
- return v8::Null();
-
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- QV8ListResource *r = new QV8ListResource(m_engine);
- r->object = object;
- r->propertyType = propType;
- void *args[] = { &r->property, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, propId, args);
- rv->SetExternalResource(r);
- return rv;
-}
-
-v8::Handle<v8::Value> QV8ListWrapper::newList(const QDeclarativeListProperty<QObject> &prop, int propType)
-{
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- QV8ListResource *r = new QV8ListResource(m_engine);
- r->object = prop.object;
- r->property = prop;
- r->propertyType = propType;
- rv->SetExternalResource(r);
- return rv;
-}
-
-QVariant QV8ListWrapper::toVariant(v8::Handle<v8::Object> obj)
-{
- QV8ListResource *resource = v8_resource_cast<QV8ListResource>(obj);
- if (resource) return toVariant(resource);
- else return QVariant();
-}
-
-QVariant QV8ListWrapper::toVariant(QV8ObjectResource *r)
-{
- Q_ASSERT(r->resourceType() == QV8ObjectResource::ListType);
- QV8ListResource *resource = static_cast<QV8ListResource *>(r);
-
- if (!resource->object)
- return QVariant();
-
- return QVariant::fromValue(QDeclarativeListReferencePrivate::init(resource->property, resource->propertyType,
- m_engine->engine()));
-}
-
-v8::Handle<v8::Value> QV8ListWrapper::Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- Q_UNUSED(info);
- return v8::Handle<v8::Value>();
-}
-
-v8::Handle<v8::Value> QV8ListWrapper::Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- Q_UNUSED(info);
- return value;
-}
-
-v8::Handle<v8::Value> QV8ListWrapper::IndexedGetter(uint32_t index, const v8::AccessorInfo &info)
-{
- QV8ListResource *resource = v8_resource_cast<QV8ListResource>(info.This());
-
- if (!resource || resource->object.isNull()) return v8::Undefined();
-
- quint32 count = resource->property.count?resource->property.count(&resource->property):0;
- if (index < count && resource->property.at) {
- return resource->engine->newQObject(resource->property.at(&resource->property, index));
- } else {
- return v8::Undefined();
- }
-}
-
-v8::Handle<v8::Value> QV8ListWrapper::LengthGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
-
- QV8ListResource *resource = v8_resource_cast<QV8ListResource>(info.This());
-
- if (!resource || resource->object.isNull()) return v8::Undefined();
-
- quint32 count = resource->property.count?resource->property.count(&resource->property):0;
-
- return v8::Integer::NewFromUnsigned(count);
-}
-
-v8::Handle<v8::Array> QV8ListWrapper::Enumerator(const v8::AccessorInfo &info)
-{
- QV8ListResource *resource = v8_resource_cast<QV8ListResource>(info.This());
-
- if (!resource || resource->object.isNull()) return v8::Array::New();
-
- quint32 count = resource->property.count?resource->property.count(&resource->property):0;
-
- v8::Local<v8::Array> rv = v8::Array::New(count);
-
- for (uint ii = 0; ii < count; ++ii)
- rv->Set(ii, v8::Number::New(ii));
-
- return rv;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8listwrapper_p.h b/src/declarative/qml/v8/qv8listwrapper_p.h
deleted file mode 100644
index 891e84de65..0000000000
--- a/src/declarative/qml/v8/qv8listwrapper_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8LISTWRAPPER_P_H
-#define QV8LISTWRAPPER_P_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 <QtDeclarative/qdeclarativelist.h>
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-class QV8ObjectResource;
-class QV8ListWrapper
-{
-public:
- QV8ListWrapper();
- ~QV8ListWrapper();
-
- void init(QV8Engine *);
- void destroy();
-
- v8::Handle<v8::Value> newList(QObject *, int, int);
- v8::Handle<v8::Value> newList(const QDeclarativeListProperty<QObject> &, int);
- QVariant toVariant(v8::Handle<v8::Object>);
- QVariant toVariant(QV8ObjectResource *);
-
-private:
- static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> IndexedGetter(uint32_t index,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> LengthGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo &info);
-
- QV8Engine *m_engine;
- v8::Persistent<v8::Function> m_constructor;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV8LISTWRAPPER_P_H
-
diff --git a/src/declarative/qml/v8/qv8profiler_p.h b/src/declarative/qml/v8/qv8profiler_p.h
deleted file mode 100644
index 4aba9ecdb5..0000000000
--- a/src/declarative/qml/v8/qv8profiler_p.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/v8-profiler.h>
diff --git a/src/declarative/qml/v8/qv8qobjectwrapper.cpp b/src/declarative/qml/v8/qv8qobjectwrapper.cpp
deleted file mode 100644
index 9c4e07ae4f..0000000000
--- a/src/declarative/qml/v8/qv8qobjectwrapper.cpp
+++ /dev/null
@@ -1,2113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8qobjectwrapper_p.h"
-#include "qv8contextwrapper_p.h"
-#include "qv8engine_p.h"
-
-#include <private/qdeclarativeguard_p.h>
-#include <private/qdeclarativepropertycache_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativevmemetaobject_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <private/qjsvalue_p.h>
-#include <private/qscript_impl_p.h>
-#include <private/qdeclarativeaccessors_p.h>
-#include <private/qdeclarativeexpression_p.h>
-
-#include <QtDeclarative/qjsvalue.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qatomic.h>
-
-Q_DECLARE_METATYPE(QJSValue);
-Q_DECLARE_METATYPE(QDeclarativeV8Handle);
-
-QT_BEGIN_NAMESPACE
-
-#if defined(__GNUC__)
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
-// The code in this file does not violate strict aliasing, but GCC thinks it does
-// so turn off the warnings for us to have a clean build
-# pragma GCC diagnostic ignored "-Wstrict-aliasing"
-# endif
-#endif
-
-#define QOBJECT_TOSTRING_INDEX -2
-#define QOBJECT_DESTROY_INDEX -3
-
-// XXX TODO: Need to review all calls to QDeclarativeEngine *engine() to confirm QObjects work
-// correctly in a worker thread
-
-class QV8QObjectResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(QObjectType);
-
-public:
- QV8QObjectResource(QV8Engine *engine, QObject *object);
-
- QDeclarativeGuard<QObject> object;
-};
-
-class QV8QObjectInstance : public QDeclarativeGuard<QObject>
-{
-public:
- QV8QObjectInstance(QObject *o, QV8QObjectWrapper *w)
- : QDeclarativeGuard<QObject>(o), wrapper(w)
- {
- }
-
- ~QV8QObjectInstance()
- {
- qPersistentDispose(v8object);
- }
-
- virtual void objectDestroyed(QObject *o)
- {
- if (wrapper)
- wrapper->m_taintedObjects.remove(o);
- delete this;
- }
-
- v8::Persistent<v8::Object> v8object;
- QV8QObjectWrapper *wrapper;
-};
-
-class QV8SignalHandlerResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(SignalHandlerType)
-public:
- QV8SignalHandlerResource(QV8Engine *engine, QObject *object, int index);
-
- QDeclarativeGuard<QObject> object;
- int index;
-};
-
-namespace {
-
-template<typename A, typename B, typename C, typename D, typename E>
-class MaxSizeOf5 {
- template<typename Z, typename X>
- struct SMax {
- static const size_t Size = sizeof(Z) > sizeof(X) ? sizeof(Z) : sizeof(X);
- };
-public:
- static const size_t Size = SMax<A, SMax<B, SMax<C, SMax<D, E> > > >::Size;
-};
-
-struct CallArgument {
- inline CallArgument();
- inline ~CallArgument();
- inline void *dataPtr();
-
- inline void initAsType(int type);
- inline void fromValue(int type, QV8Engine *, v8::Handle<v8::Value>);
- inline v8::Handle<v8::Value> toValue(QV8Engine *);
-
-private:
- CallArgument(const CallArgument &);
-
- inline void cleanup();
-
- union {
- float floatValue;
- double doubleValue;
- quint32 intValue;
- bool boolValue;
- QObject *qobjectPtr;
-
- char allocData[MaxSizeOf5<QVariant,
- QString,
- QList<QObject *>,
- QJSValue,
- QDeclarativeV8Handle>::Size];
- qint64 q_for_alignment;
- };
-
- // Pointers to allocData
- union {
- QString *qstringPtr;
- QVariant *qvariantPtr;
- QList<QObject *> *qlistPtr;
- QJSValue *qjsValuePtr;
- QDeclarativeV8Handle *handlePtr;
- };
-
- int type;
-};
-}
-
-QV8QObjectResource::QV8QObjectResource(QV8Engine *engine, QObject *object)
-: QV8ObjectResource(engine), object(object)
-{
-}
-
-QV8SignalHandlerResource::QV8SignalHandlerResource(QV8Engine *engine, QObject *object, int index)
-: QV8ObjectResource(engine), object(object), index(index)
-{
-}
-
-static QAtomicInt objectIdCounter(1);
-
-QV8QObjectWrapper::QV8QObjectWrapper()
-: m_engine(0), m_id(objectIdCounter.fetchAndAddOrdered(1))
-{
-}
-
-QV8QObjectWrapper::~QV8QObjectWrapper()
-{
- for (TaintedHash::Iterator iter = m_taintedObjects.begin();
- iter != m_taintedObjects.end();
- ++iter) {
- (*iter)->wrapper = 0;
- }
- m_taintedObjects.clear();
-}
-
-void QV8QObjectWrapper::destroy()
-{
- qDeleteAll(m_connections);
- m_connections.clear();
-
- qPersistentDispose(m_hiddenObject);
- qPersistentDispose(m_destroySymbol);
- qPersistentDispose(m_toStringSymbol);
- qPersistentDispose(m_signalHandlerConstructor);
- qPersistentDispose(m_methodConstructor);
- qPersistentDispose(m_constructor);
-}
-
-struct ReadAccessor {
- static inline void Indirect(QObject *object, const QDeclarativePropertyData &property,
- void *output, QDeclarativeNotifier **n)
- {
- Q_ASSERT(n == 0);
- Q_UNUSED(n);
-
- void *args[] = { output, 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, property.coreIndex, args);
- }
-
- static inline void Direct(QObject *object, const QDeclarativePropertyData &property,
- void *output, QDeclarativeNotifier **n)
- {
- Q_ASSERT(n == 0);
- Q_UNUSED(n);
-
- void *args[] = { output, 0 };
- object->qt_metacall(QMetaObject::ReadProperty, property.coreIndex, args);
- }
-
- static inline void Accessor(QObject *object, const QDeclarativePropertyData &property,
- void *output, QDeclarativeNotifier **n)
- {
- Q_ASSERT(property.accessors);
-
- property.accessors->read(object, property.accessorData, output);
- if (n) property.accessors->notifier(object, property.accessorData, n);
- }
-};
-
-static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, int v)
-{ return v8::Integer::New(v); }
-static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, uint v)
-{ return v8::Integer::NewFromUnsigned(v); }
-static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, bool v)
-{ return v8::Boolean::New(v); }
-static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *e, const QString &v)
-{ return e->toString(v); }
-static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, float v)
-{ return v8::Number::New(v); }
-static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, double v)
-{ return v8::Number::New(v); }
-static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *e, QObject *v)
-{ return e->newQObject(v); }
-
-template<typename T, void (*ReadFunction)(QObject *, const QDeclarativePropertyData &,
- void *, QDeclarativeNotifier **)>
-static v8::Handle<v8::Value> GenericValueGetter(v8::Local<v8::String>, const v8::AccessorInfo &info)
-{
- v8::Handle<v8::Object> This = info.This();
- QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(This);
-
- QObject *object = resource->object;
- if (!object) return v8::Undefined();
-
- QDeclarativePropertyData *property =
- (QDeclarativePropertyData *)v8::External::Unwrap(info.Data());
-
- QDeclarativeEngine *engine = resource->engine->engine();
- QDeclarativeEnginePrivate *ep = engine?QDeclarativeEnginePrivate::get(engine):0;
-
- T value = T();
-
- if (ep && ep->propertyCapture) {
- if (ReadFunction == ReadAccessor::Accessor && property->accessors->notifier) {
- QDeclarativeNotifier *notifier = 0;
- ReadFunction(object, *property, &value, &notifier);
- if (notifier) ep->captureProperty(notifier);
- } else if (!property->isConstant()) {
- ep->captureProperty(object, property->coreIndex, property->notifyIndex);
- ReadFunction(object, *property, &value, 0);
- } else {
- ReadFunction(object, *property, &value, 0);
- }
- } else {
- ReadFunction(object, *property, &value, 0);
- }
-
- return valueToHandle(resource->engine, value);
-}
-
-#define FAST_GETTER_FUNCTION(property, cpptype) \
- (property->hasAccessors()?((v8::AccessorGetter)GenericValueGetter<cpptype, &ReadAccessor::Accessor>):(property->isDirect()?((v8::AccessorGetter)GenericValueGetter<cpptype, &ReadAccessor::Direct>):((v8::AccessorGetter)GenericValueGetter<cpptype, &ReadAccessor::Indirect>)))
-
-static quint32 toStringHash = -1;
-static quint32 destroyHash = -1;
-
-void QV8QObjectWrapper::init(QV8Engine *engine)
-{
- m_engine = engine;
-
- m_toStringSymbol = qPersistentNew<v8::String>(v8::String::NewSymbol("toString"));
- m_destroySymbol = qPersistentNew<v8::String>(v8::String::NewSymbol("destroy"));
- m_hiddenObject = qPersistentNew<v8::Object>(v8::Object::New());
-
- m_toStringString = QHashedV8String(m_toStringSymbol);
- m_destroyString = QHashedV8String(m_destroySymbol);
-
- toStringHash = m_toStringString.hash();
- destroyHash = m_destroyString.hash();
-
- {
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter, Query, 0, Enumerator);
- ft->InstanceTemplate()->SetHasExternalResource(true);
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
- }
- {
- v8::ScriptOrigin origin(m_hiddenObject); // Hack to allow us to identify these functions
-#define CREATE_FUNCTION_SOURCE \
- "(function(method) { "\
- "return (function(object, data, qmlglobal) { "\
- "return (function() { "\
- "return method(object, data, qmlglobal, arguments.length, arguments); "\
- "});"\
- "});"\
- "})"
- v8::Local<v8::Script> script = v8::Script::New(v8::String::New(CREATE_FUNCTION_SOURCE), &origin, 0,
- v8::Handle<v8::String>(), v8::Script::NativeMode);
-#undef CREATE_FUNCTION_SOURCE
- v8::Local<v8::Function> fn = v8::Local<v8::Function>::Cast(script->Run());
- v8::Handle<v8::Value> invokeFn = v8::FunctionTemplate::New(Invoke)->GetFunction();
- v8::Handle<v8::Value> args[] = { invokeFn };
- v8::Local<v8::Function> createFn = v8::Local<v8::Function>::Cast(fn->Call(engine->global(), 1, args));
- m_methodConstructor = qPersistentNew<v8::Function>(createFn);
- }
-
- v8::Local<v8::Function> connect = V8FUNCTION(Connect, engine);
- v8::Local<v8::Function> disconnect = V8FUNCTION(Disconnect, engine);
-
- {
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->PrototypeTemplate()->Set(v8::String::New("connect"), connect, v8::DontEnum);
- ft->PrototypeTemplate()->Set(v8::String::New("disconnect"), disconnect, v8::DontEnum);
- m_signalHandlerConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
- }
-
- {
- v8::Local<v8::Object> prototype = engine->global()->Get(v8::String::New("Function"))->ToObject()->Get(v8::String::New("prototype"))->ToObject();
- prototype->Set(v8::String::New("connect"), connect, v8::DontEnum);
- prototype->Set(v8::String::New("disconnect"), disconnect, v8::DontEnum);
- }
-}
-
-bool QV8QObjectWrapper::isQObject(v8::Handle<v8::Object> obj)
-{
- return v8_resource_cast<QV8QObjectResource>(obj) != 0;
-}
-
-QObject *QV8QObjectWrapper::toQObject(v8::Handle<v8::Object> obj)
-{
- QV8QObjectResource *r = v8_resource_cast<QV8QObjectResource>(obj);
- return r?r->object:0;
-}
-
-// r *MUST* be a QV8ObjectResource (r->type() == QV8ObjectResource::QObjectType)
-QObject *QV8QObjectWrapper::toQObject(QV8ObjectResource *r)
-{
- Q_ASSERT(r->resourceType() == QV8ObjectResource::QObjectType);
- return static_cast<QV8QObjectResource *>(r)->object;
-}
-
-// Load value properties
-template<void (*ReadFunction)(QObject *, const QDeclarativePropertyData &,
- void *, QDeclarativeNotifier **)>
-static v8::Handle<v8::Value> LoadProperty(QV8Engine *engine, QObject *object,
- const QDeclarativePropertyData &property,
- QDeclarativeNotifier **notifier)
-{
- Q_ASSERT(!property.isFunction());
-
- if (property.isQObject()) {
- QObject *rv = 0;
- ReadFunction(object, property, &rv, notifier);
- return engine->newQObject(rv);
- } else if (property.isQList()) {
- return engine->listWrapper()->newList(object, property.coreIndex, property.propType);
- } else if (property.propType == QMetaType::QReal) {
- qreal v = 0;
- ReadFunction(object, property, &v, notifier);
- return valueToHandle(engine, v);
- } else if (property.propType == QMetaType::Int || property.isEnum()) {
- int v = 0;
- ReadFunction(object, property, &v, notifier);
- return valueToHandle(engine, v);
- } else if (property.propType == QMetaType::Bool) {
- bool v = false;
- ReadFunction(object, property, &v, notifier);
- return valueToHandle(engine, v);
- } else if (property.propType == QMetaType::QString) {
- QString v;
- ReadFunction(object, property, &v, notifier);
- return valueToHandle(engine, v);
- } else if (property.propType == QMetaType::UInt) {
- uint v = 0;
- ReadFunction(object, property, &v, notifier);
- return valueToHandle(engine, v);
- } else if (property.propType == QMetaType::Float) {
- float v = 0;
- ReadFunction(object, property, &v, notifier);
- return valueToHandle(engine, v);
- } else if (property.propType == QMetaType::Double) {
- double v = 0;
- ReadFunction(object, property, &v, notifier);
- return valueToHandle(engine, v);
- } else if (property.isV8Handle()) {
- QDeclarativeV8Handle handle;
- ReadFunction(object, property, &handle, notifier);
- return handle.toHandle();
- } else if (property.isQVariant()) {
- QVariant v;
- ReadFunction(object, property, &v, notifier);
- return engine->fromVariant(v);
- } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)
- && engine->engine()) {
- Q_ASSERT(notifier == 0);
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine->engine());
- QDeclarativeValueType *valueType = ep->valueTypes[property.propType];
- if (valueType)
- return engine->newValueType(object, property.coreIndex, valueType);
- } else {
- Q_ASSERT(notifier == 0);
-
- // see if it's a sequence type
- bool succeeded = false;
- v8::Handle<v8::Value> retn = engine->newSequence(property.propType, object, property.coreIndex,
- &succeeded);
- if (succeeded)
- return retn;
- }
-
- if (property.propType == QVariant::Invalid) {
- QMetaProperty p = object->metaObject()->property(property.coreIndex);
- qWarning("QMetaProperty::read: Unable to handle unregistered datatype '%s' for property "
- "'%s::%s'", p.typeName(), object->metaObject()->className(), p.name());
- return v8::Undefined();
- } else {
- QVariant v(property.propType, (void *)0);
- ReadFunction(object, property, v.data(), notifier);
- return engine->fromVariant(v);
- }
-}
-
-v8::Handle<v8::Value> QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject *object,
- v8::Handle<v8::Value> *objectHandle,
- const QHashedV8String &property,
- QV8QObjectWrapper::RevisionMode revisionMode)
-{
- // XXX More recent versions of V8 introduced "Callable" objects. It is possible that these
- // will be a faster way of creating QObject method objects.
- struct MethodClosure {
- static v8::Handle<v8::Value> create(QV8Engine *engine, QObject *object,
- v8::Handle<v8::Value> *objectHandle,
- int index) {
- v8::Handle<v8::Value> argv[] = {
- objectHandle?*objectHandle:engine->newQObject(object),
- v8::Integer::New(index)
- };
- return engine->qobjectWrapper()->m_methodConstructor->Call(engine->global(), 2, argv);
- }
- static v8::Handle<v8::Value> createWithGlobal(QV8Engine *engine, QObject *object,
- v8::Handle<v8::Value> *objectHandle,
- int index) {
- v8::Handle<v8::Value> argv[] = {
- objectHandle?*objectHandle:engine->newQObject(object),
- v8::Integer::New(index),
- v8::Context::GetCallingQmlGlobal()
- };
- return engine->qobjectWrapper()->m_methodConstructor->Call(engine->global(), 3, argv);
- }
- };
-
- {
- // Comparing the hash first actually makes a measurable difference here, at least on x86
- quint32 hash = property.hash();
- if (hash == toStringHash && engine->qobjectWrapper()->m_toStringString == property) {
- return MethodClosure::create(engine, object, objectHandle, QOBJECT_TOSTRING_INDEX);
- } else if (hash == destroyHash && engine->qobjectWrapper()->m_destroyString == property) {
- return MethodClosure::create(engine, object, objectHandle, QOBJECT_DESTROY_INDEX);
- }
- }
-
- QDeclarativePropertyData local;
- QDeclarativePropertyData *result = 0;
- {
- QDeclarativeData *ddata = QDeclarativeData::get(object, false);
- if (ddata && ddata->propertyCache)
- result = ddata->propertyCache->property(property);
- else
- result = QDeclarativePropertyCache::property(engine->engine(), object, property, local);
- }
-
- if (!result)
- return v8::Handle<v8::Value>();
-
- if (revisionMode == QV8QObjectWrapper::CheckRevision && result->hasRevision()) {
- QDeclarativeData *ddata = QDeclarativeData::get(object);
- if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result))
- return v8::Handle<v8::Value>();
- }
-
- if (result->isFunction()) {
- if (result->isVMEFunction()) {
- return ((QDeclarativeVMEMetaObject *)(object->metaObject()))->vmeMethod(result->coreIndex);
- } else if (result->isV8Function()) {
- return MethodClosure::createWithGlobal(engine, object, objectHandle, result->coreIndex);
- } else if (result->isSignalHandler()) {
- v8::Local<v8::Object> handler = engine->qobjectWrapper()->m_signalHandlerConstructor->NewInstance();
- QV8SignalHandlerResource *r = new QV8SignalHandlerResource(engine, object, result->coreIndex);
- handler->SetExternalResource(r);
- return handler;
- } else {
- return MethodClosure::create(engine, object, objectHandle, result->coreIndex);
- }
- }
-
- QDeclarativeEnginePrivate *ep =
- engine->engine()?QDeclarativeEnginePrivate::get(engine->engine()):0;
-
- if (result->hasAccessors()) {
- QDeclarativeNotifier *n = 0;
- QDeclarativeNotifier **nptr = 0;
-
- if (ep && ep->propertyCapture && result->accessors->notifier)
- nptr = &n;
-
- v8::Handle<v8::Value> rv = LoadProperty<ReadAccessor::Accessor>(engine, object, *result, nptr);
-
- if (result->accessors->notifier) {
- if (n) ep->captureProperty(n);
- } else {
- ep->captureProperty(object, result->coreIndex, result->notifyIndex);
- }
-
- return rv;
- }
-
- if (ep && !result->isConstant()) {
-
- if (result->coreIndex == 0)
- ep->captureProperty(QDeclarativeData::get(object, true)->objectNameNotifier());
- else
- ep->captureProperty(object, result->coreIndex, result->notifyIndex);
- }
-
- if (result->isVMEProperty()) {
- typedef QDeclarativeVMEMetaObject VMEMO;
- VMEMO *vmemo = const_cast<VMEMO *>(static_cast<const VMEMO *>(object->metaObject()));
- return vmemo->vmeProperty(result->coreIndex);
- } else if (result->isDirect()) {
- return LoadProperty<ReadAccessor::Direct>(engine, object, *result, 0);
- } else {
- return LoadProperty<ReadAccessor::Indirect>(engine, object, *result, 0);
- }
-}
-
-// Setter for writable properties. Shared between the interceptor and fast property accessor
-static inline void StoreProperty(QV8Engine *engine, QObject *object, QDeclarativePropertyData *property,
- v8::Handle<v8::Value> value)
-{
- QDeclarativeBinding *newBinding = 0;
-
- if (value->IsFunction()) {
- QDeclarativeContextData *context = engine->callingContext();
- v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
-
- v8::Local<v8::StackTrace> trace =
- v8::StackTrace::CurrentStackTrace(1, (v8::StackTrace::StackTraceOptions)(v8::StackTrace::kLineNumber |
- v8::StackTrace::kScriptName));
- v8::Local<v8::StackFrame> frame = trace->GetFrame(0);
- int lineNumber = frame->GetLineNumber();
- int columNumber = frame->GetColumn();
- QString url = engine->toString(frame->GetScriptName());
-
- newBinding = new QDeclarativeBinding(&function, object, context);
- newBinding->setSourceLocation(url, lineNumber, columNumber);
- newBinding->setTarget(object, *property, context);
- newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
- QDeclarativeBinding::RequiresThisObject);
- }
-
- QDeclarativeAbstractBinding *oldBinding =
- QDeclarativePropertyPrivate::setBinding(object, property->coreIndex, -1, newBinding);
- if (oldBinding)
- oldBinding->destroy();
-
-#define PROPERTY_STORE(cpptype, value) \
- cpptype o = value; \
- int status = -1; \
- int flags = 0; \
- void *argv[] = { &o, 0, &status, &flags }; \
- QMetaObject::metacall(object, QMetaObject::WriteProperty, property->coreIndex, argv);
-
-
- if (value->IsNull() && property->isQObject()) {
- PROPERTY_STORE(QObject*, 0);
- } else if (value->IsUndefined() && property->isResettable()) {
- void *a[] = { 0 };
- QMetaObject::metacall(object, QMetaObject::ResetProperty, property->coreIndex, a);
- } else if (value->IsUndefined() && property->propType == qMetaTypeId<QVariant>()) {
- PROPERTY_STORE(QVariant, QVariant());
- } else if (value->IsUndefined()) {
- QString error = QLatin1String("Cannot assign [undefined] to ") +
- QLatin1String(QMetaType::typeName(property->propType));
- v8::ThrowException(v8::Exception::Error(engine->toString(error)));
- } else if (value->IsFunction()) {
- // this is handled by the binding creation above
- } else if (property->propType == QMetaType::Int && value->IsNumber()) {
- PROPERTY_STORE(int, qRound(value->ToNumber()->Value()));
- } else if (property->propType == QMetaType::QReal && value->IsNumber()) {
- PROPERTY_STORE(qreal, qreal(value->ToNumber()->Value()));
- } else if (property->propType == QMetaType::Float && value->IsNumber()) {
- PROPERTY_STORE(float, float(value->ToNumber()->Value()));
- } else if (property->propType == QMetaType::Double && value->IsNumber()) {
- PROPERTY_STORE(double, double(value->ToNumber()->Value()));
- } else if (property->propType == QMetaType::QString && value->IsString()) {
- PROPERTY_STORE(QString, engine->toString(value->ToString()));
- } else if (property->isVMEProperty()) {
- static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(object->metaObject()))->setVMEProperty(property->coreIndex, value);
- } else {
- QVariant v;
- if (property->isQList())
- v = engine->toVariant(value, qMetaTypeId<QList<QObject *> >());
- else
- v = engine->toVariant(value, property->propType);
-
- QDeclarativeContextData *context = engine->callingContext();
- if (!QDeclarativePropertyPrivate::write(object, *property, v, context)) {
- const char *valueType = 0;
- if (v.userType() == QVariant::Invalid) valueType = "null";
- else valueType = QMetaType::typeName(v.userType());
-
- QString error = QLatin1String("Cannot assign ") +
- QLatin1String(valueType) +
- QLatin1String(" to ") +
- QLatin1String(QMetaType::typeName(property->propType));
- v8::ThrowException(v8::Exception::Error(engine->toString(error)));
- }
- }
-}
-
-bool QV8QObjectWrapper::SetProperty(QV8Engine *engine, QObject *object, const QHashedV8String &property,
- v8::Handle<v8::Value> value, QV8QObjectWrapper::RevisionMode revisionMode)
-{
- if (engine->qobjectWrapper()->m_toStringString == property ||
- engine->qobjectWrapper()->m_destroyString == property)
- return true;
-
- QDeclarativePropertyData local;
- QDeclarativePropertyData *result = 0;
- result = QDeclarativePropertyCache::property(engine->engine(), object, property, local);
-
- if (!result)
- return false;
-
- if (revisionMode == QV8QObjectWrapper::CheckRevision && result->hasRevision()) {
- QDeclarativeData *ddata = QDeclarativeData::get(object);
- if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result))
- return false;
- }
-
- if (!result->isWritable() && !result->isQList()) {
- QString error = QLatin1String("Cannot assign to read-only property \"") +
- engine->toString(property.string()) + QLatin1Char('\"');
- v8::ThrowException(v8::Exception::Error(engine->toString(error)));
- return true;
- }
-
- StoreProperty(engine, object, result, value);
-
- return true;
-}
-
-v8::Handle<v8::Value> QV8QObjectWrapper::Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
-
- if (resource->object.isNull())
- return v8::Handle<v8::Value>();
-
- QObject *object = resource->object;
-
- QHashedV8String propertystring(property);
-
- QV8Engine *v8engine = resource->engine;
- v8::Handle<v8::Value> This = info.This();
- v8::Handle<v8::Value> result = GetProperty(v8engine, object, &This, propertystring,
- QV8QObjectWrapper::IgnoreRevision);
- if (!result.IsEmpty())
- return result;
-
- if (QV8Engine::startsWithUpper(property)) {
- // Check for attached properties
- QDeclarativeContextData *context = v8engine->callingContext();
-
- if (context && context->imports) {
- QDeclarativeTypeNameCache::Result r = context->imports->query(propertystring);
-
- if (r.isValid()) {
- if (r.scriptIndex != -1) {
- return v8::Undefined();
- } else if (r.type) {
- return v8engine->typeWrapper()->newObject(object, r.type, QV8TypeWrapper::ExcludeEnums);
- } else if (r.importNamespace) {
- return v8engine->typeWrapper()->newObject(object, context->imports, r.importNamespace,
- QV8TypeWrapper::ExcludeEnums);
- }
- Q_ASSERT(!"Unreachable");
- }
- }
- }
-
- return v8::Handle<v8::Value>();
-}
-
-v8::Handle<v8::Value> QV8QObjectWrapper::Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info)
-{
- QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
-
- if (resource->object.isNull())
- return value;
-
- QObject *object = resource->object;
-
- QHashedV8String propertystring(property);
-
- QV8Engine *v8engine = resource->engine;
- bool result = SetProperty(v8engine, object, propertystring, value, QV8QObjectWrapper::IgnoreRevision);
-
- if (!result) {
- QString error = QLatin1String("Cannot assign to non-existent property \"") +
- v8engine->toString(property) + QLatin1Char('\"');
- v8::ThrowException(v8::Exception::Error(v8engine->toString(error)));
- return value;
- }
-
- return value;
-}
-
-v8::Handle<v8::Integer> QV8QObjectWrapper::Query(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
-
- if (resource->object.isNull())
- return v8::Handle<v8::Integer>();
-
- QV8Engine *engine = resource->engine;
- QObject *object = resource->object;
-
- QHashedV8String propertystring(property);
-
- QDeclarativePropertyData local;
- QDeclarativePropertyData *result = 0;
- result = QDeclarativePropertyCache::property(engine->engine(), object, propertystring, local);
-
- if (!result)
- return v8::Handle<v8::Integer>();
- else if (!result->isWritable() && !result->isQList())
- return v8::Integer::New(v8::ReadOnly | v8::DontDelete);
- else
- return v8::Integer::New(v8::DontDelete);
-}
-
-v8::Handle<v8::Array> QV8QObjectWrapper::Enumerator(const v8::AccessorInfo &info)
-{
- QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
-
- if (resource->object.isNull())
- return v8::Array::New();
-
- QObject *object = resource->object;
-
- QStringList result;
-
- QDeclarativeEnginePrivate *ep = resource->engine->engine()
- ? QDeclarativeEnginePrivate::get(resource->engine->engine())
- : 0;
-
- QDeclarativePropertyCache *cache = 0;
- QDeclarativeData *ddata = QDeclarativeData::get(object);
- if (ddata)
- cache = ddata->propertyCache;
-
- if (!cache) {
- cache = ep ? ep->cache(object) : 0;
- if (cache) {
- if (ddata) { cache->addref(); ddata->propertyCache = cache; }
- } else {
- // Not cachable - fall back to QMetaObject (eg. dynamic meta object)
- const QMetaObject *mo = object->metaObject();
- int pc = mo->propertyCount();
- int po = mo->propertyOffset();
- for (int i=po; i<pc; ++i)
- result << QString::fromUtf8(mo->property(i).name());
- }
- } else {
- result = cache->propertyNames();
- }
-
- v8::Local<v8::Array> rv = v8::Array::New(result.count());
-
- for (int ii = 0; ii < result.count(); ++ii)
- rv->Set(ii, resource->engine->toString(result.at(ii)));
-
- return rv;
-}
-
-static void FastValueSetter(v8::Local<v8::String>, v8::Local<v8::Value> value,
- const v8::AccessorInfo& info)
-{
- QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
-
- if (resource->object.isNull())
- return;
-
- QObject *object = resource->object;
-
- QDeclarativePropertyData *property =
- (QDeclarativePropertyData *)v8::External::Unwrap(info.Data());
-
- int index = property->coreIndex;
-
- QDeclarativeData *ddata = QDeclarativeData::get(object, false);
- Q_ASSERT(ddata);
- Q_ASSERT(ddata->propertyCache);
-
- QDeclarativePropertyData *pdata = ddata->propertyCache->property(index);
- Q_ASSERT(pdata);
-
- Q_ASSERT(pdata->isWritable() || pdata->isQList());
-
- StoreProperty(resource->engine, object, pdata, value);
-}
-
-static void FastValueSetterReadOnly(v8::Local<v8::String> property, v8::Local<v8::Value>,
- const v8::AccessorInfo& info)
-{
- QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
-
- if (resource->object.isNull())
- return;
-
- QV8Engine *v8engine = resource->engine;
-
- QString error = QLatin1String("Cannot assign to read-only property \"") +
- v8engine->toString(property) + QLatin1Char('\"');
- v8::ThrowException(v8::Exception::Error(v8engine->toString(error)));
-}
-
-static void WeakQObjectReferenceCallback(v8::Persistent<v8::Value> handle, void *)
-{
- Q_ASSERT(handle->IsObject());
-
- QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(handle->ToObject());
-
- Q_ASSERT(resource);
-
- QObject *object = resource->object;
- if (object) {
- QDeclarativeData *ddata = QDeclarativeData::get(object, false);
- if (ddata) {
- ddata->v8object.Clear();
- if (!object->parent() && !ddata->indestructible)
- object->deleteLater();
- }
- }
-
- qPersistentDispose(handle);
-}
-
-static void WeakQObjectInstanceCallback(v8::Persistent<v8::Value> handle, void *data)
-{
- QV8QObjectInstance *instance = (QV8QObjectInstance *)data;
- instance->v8object.Clear();
- qPersistentDispose(handle);
-}
-
-v8::Local<v8::Object> QDeclarativePropertyCache::newQObject(QObject *object, QV8Engine *engine)
-{
- Q_ASSERT(object);
- Q_ASSERT(this->engine);
-
- Q_ASSERT(QDeclarativeData::get(object, false));
- Q_ASSERT(QDeclarativeData::get(object, false)->propertyCache == this);
-
- // Setup constructor
- if (constructor.IsEmpty()) {
- v8::Local<v8::FunctionTemplate> ft;
-
- QString toString = QLatin1String("toString");
- QString destroy = QLatin1String("destroy");
-
- // As we use hash linking, it is possible that iterating over the values can give duplicates.
- // To combat this, we must unique'ify our properties.
- StringCache uniqueHash;
- if (stringCache.isLinked())
- uniqueHash.reserve(stringCache.count());
-
- // XXX TODO: Enables fast property accessors. These more than double the property access
- // performance, but the cost of setting up this structure hasn't been measured so
- // its not guarenteed that this is a win overall. We need to try and measure the cost.
- for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter) {
- if (stringCache.isLinked()) {
- if (uniqueHash.contains(iter))
- continue;
- uniqueHash.insert(iter);
- }
-
- QDeclarativePropertyData *property = *iter;
- if (property->notFullyResolved()) resolve(property);
-
- if (property->isFunction())
- continue;
-
- v8::AccessorGetter fastgetter = 0;
- v8::AccessorSetter fastsetter = FastValueSetter;
- if (!property->isWritable())
- fastsetter = FastValueSetterReadOnly;
-
- if (property->isQObject())
- fastgetter = FAST_GETTER_FUNCTION(property, QObject*);
- else if (property->propType == QMetaType::Int || property->isEnum())
- fastgetter = FAST_GETTER_FUNCTION(property, int);
- else if (property->propType == QMetaType::Bool)
- fastgetter = FAST_GETTER_FUNCTION(property, bool);
- else if (property->propType == QMetaType::QString)
- fastgetter = FAST_GETTER_FUNCTION(property, QString);
- else if (property->propType == QMetaType::UInt)
- fastgetter = FAST_GETTER_FUNCTION(property, uint);
- else if (property->propType == QMetaType::Float)
- fastgetter = FAST_GETTER_FUNCTION(property, float);
- else if (property->propType == QMetaType::Double)
- fastgetter = FAST_GETTER_FUNCTION(property, double);
-
- if (fastgetter) {
- QString name = iter.key();
- if (name == toString || name == destroy)
- continue;
-
- if (ft.IsEmpty()) {
- ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetFallbackPropertyHandler(QV8QObjectWrapper::Getter,
- QV8QObjectWrapper::Setter,
- QV8QObjectWrapper::Query,
- 0,
- QV8QObjectWrapper::Enumerator);
- ft->InstanceTemplate()->SetHasExternalResource(true);
- }
-
- // We wrap the raw QDeclarativePropertyData pointer here. This is safe as the
- // pointer will remain valid at least as long as the lifetime of any QObject's of
- // this type and the property accessor checks if the object is 0 (deleted) before
- // dereferencing the pointer.
- ft->InstanceTemplate()->SetAccessor(engine->toString(name), fastgetter, fastsetter,
- v8::External::Wrap(property));
- }
- }
-
- if (ft.IsEmpty()) {
- constructor = qPersistentNew<v8::Function>(engine->qobjectWrapper()->m_constructor);
- } else {
- ft->InstanceTemplate()->SetFallbackPropertyHandler(QV8QObjectWrapper::Getter,
- QV8QObjectWrapper::Setter,
- QV8QObjectWrapper::Query,
- 0,
- QV8QObjectWrapper::Enumerator);
- ft->InstanceTemplate()->SetHasExternalResource(true);
- constructor = qPersistentNew<v8::Function>(ft->GetFunction());
- }
-
- QDeclarativeCleanup::addToEngine(this->engine);
- }
-
- v8::Local<v8::Object> result = constructor->NewInstance();
- QV8QObjectResource *r = new QV8QObjectResource(engine, object);
- result->SetExternalResource(r);
- return result;
-}
-
-v8::Local<v8::Object> QV8QObjectWrapper::newQObject(QObject *object, QDeclarativeData *ddata, QV8Engine *engine)
-{
- v8::Local<v8::Object> rv;
-
- if (!ddata->propertyCache && engine->engine()) {
- ddata->propertyCache = QDeclarativeEnginePrivate::get(engine->engine())->cache(object);
- if (ddata->propertyCache) ddata->propertyCache->addref();
- }
-
- if (ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine->engine()) {
- rv = ddata->propertyCache->newQObject(object, engine);
- } else {
- // XXX NewInstance() should be optimized
- rv = m_constructor->NewInstance();
- QV8QObjectResource *r = new QV8QObjectResource(engine, object);
- rv->SetExternalResource(r);
- }
-
- return rv;
-}
-
-/*
-As V8 doesn't support an equality callback, for QObject's we have to return exactly the same
-V8 handle for subsequent calls to newQObject for the same QObject. To do this we have a two
-pronged strategy:
- 1. If there is no current outstanding V8 handle to the QObject, we create one and store a
- persistent handle in QDeclarativeData::v8object. We mark the QV8QObjectWrapper that
- "owns" this handle by setting the QDeclarativeData::v8objectid to the id of this
- QV8QObjectWrapper.
- 2. If another QV8QObjectWrapper has create the handle in QDeclarativeData::v8object we create
- an entry in the m_taintedObject hash where we store the handle and mark the object as
- "tainted" in the QDeclarativeData::hasTaintedV8Object flag.
-We have to mark the object as tainted to ensure that we search our m_taintedObject hash even
-in the case that the original QV8QObjectWrapper owner of QDeclarativeData::v8object has
-released the handle.
-*/
-v8::Handle<v8::Value> QV8QObjectWrapper::newQObject(QObject *object)
-{
- if (!object)
- return v8::Null();
-
- if (QObjectPrivate::get(object)->wasDeleted)
- return v8::Undefined();
-
- QDeclarativeData *ddata = QDeclarativeData::get(object, true);
-
- if (!ddata)
- return v8::Undefined();
-
- if (ddata->v8objectid == m_id && !ddata->v8object.IsEmpty()) {
- // We own the v8object
- return v8::Local<v8::Object>::New(ddata->v8object);
- } else if (ddata->v8object.IsEmpty() &&
- (ddata->v8objectid == m_id || // We own the QObject
- ddata->v8objectid == 0 || // No one owns the QObject
- !ddata->hasTaintedV8Object)) { // Someone else has used the QObject, but it isn't tainted
-
- v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
- ddata->v8object = qPersistentNew<v8::Object>(rv);
- ddata->v8object.MakeWeak(0, WeakQObjectReferenceCallback);
- ddata->v8objectid = m_id;
- return rv;
-
- } else {
- // If this object is tainted, we have to check to see if it is in our
- // tainted object list
- TaintedHash::Iterator iter =
- ddata->hasTaintedV8Object?m_taintedObjects.find(object):m_taintedObjects.end();
- bool found = iter != m_taintedObjects.end();
-
- // If our tainted handle doesn't exist or has been collected, and there isn't
- // a handle in the ddata, we can assume ownership of the ddata->v8object
- if ((!found || (*iter)->v8object.IsEmpty()) && ddata->v8object.IsEmpty()) {
- v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
- ddata->v8object = qPersistentNew<v8::Object>(rv);
- ddata->v8object.MakeWeak(0, WeakQObjectReferenceCallback);
- ddata->v8objectid = m_id;
-
- if (found) {
- delete (*iter);
- m_taintedObjects.erase(iter);
- }
-
- return rv;
- } else if (!found) {
- QV8QObjectInstance *instance = new QV8QObjectInstance(object, this);
- iter = m_taintedObjects.insert(object, instance);
- ddata->hasTaintedV8Object = true;
- }
-
- if ((*iter)->v8object.IsEmpty()) {
- v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
- (*iter)->v8object = qPersistentNew<v8::Object>(rv);
- (*iter)->v8object.MakeWeak((*iter), WeakQObjectInstanceCallback);
- }
-
- return v8::Local<v8::Object>::New((*iter)->v8object);
- }
-}
-
-QPair<QObject *, int> QV8QObjectWrapper::ExtractQtSignal(QV8Engine *engine, v8::Handle<v8::Object> object)
-{
- if (object->IsFunction())
- return ExtractQtMethod(engine, v8::Handle<v8::Function>::Cast(object));
-
- if (QV8SignalHandlerResource *resource = v8_resource_cast<QV8SignalHandlerResource>(object))
- return qMakePair(resource->object.data(), resource->index);
-
- return qMakePair((QObject *)0, -1);
-}
-
-QPair<QObject *, int> QV8QObjectWrapper::ExtractQtMethod(QV8Engine *engine, v8::Handle<v8::Function> function)
-{
- v8::ScriptOrigin origin = function->GetScriptOrigin();
- if (origin.ResourceName()->StrictEquals(engine->qobjectWrapper()->m_hiddenObject)) {
-
- // This is one of our special QObject method wrappers
- v8::Handle<v8::Value> args[] = { engine->qobjectWrapper()->m_hiddenObject };
- v8::Local<v8::Value> data = function->Call(engine->global(), 1, args);
-
- if (data->IsArray()) {
- v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(data);
- return qMakePair(engine->toQObject(array->Get(0)), array->Get(1)->Int32Value());
- }
-
- // In theory this can't fall through, but I suppose V8 might run out of memory or something
- }
-
- return qMakePair((QObject *)0, -1);
-}
-
-class QV8QObjectConnectionList : public QObject, public QDeclarativeGuard<QObject>
-{
-public:
- QV8QObjectConnectionList(QObject *object, QV8Engine *engine);
- ~QV8QObjectConnectionList();
-
- struct Connection {
- Connection()
- : needsDestroy(false) {}
- Connection(const Connection &other)
- : thisObject(other.thisObject), function(other.function), needsDestroy(false) {}
- Connection &operator=(const Connection &other) {
- thisObject = other.thisObject;
- function = other.function;
- needsDestroy = other.needsDestroy;
- return *this;
- }
-
- v8::Persistent<v8::Object> thisObject;
- v8::Persistent<v8::Function> function;
-
- void dispose() {
- qPersistentDispose(thisObject);
- qPersistentDispose(function);
- }
-
- bool needsDestroy;
- };
-
- struct ConnectionList : public QList<Connection> {
- ConnectionList() : connectionsInUse(0), connectionsNeedClean(false) {}
- int connectionsInUse;
- bool connectionsNeedClean;
- };
-
- QV8Engine *engine;
-
- typedef QHash<int, ConnectionList> SlotHash;
- SlotHash slotHash;
- bool needsDestroy;
- int inUse;
-
- virtual void objectDestroyed(QObject *);
- virtual int qt_metacall(QMetaObject::Call, int, void **);
-};
-
-QV8QObjectConnectionList::QV8QObjectConnectionList(QObject *object, QV8Engine *engine)
-: QDeclarativeGuard<QObject>(object), engine(engine), needsDestroy(false), inUse(0)
-{
-}
-
-QV8QObjectConnectionList::~QV8QObjectConnectionList()
-{
- for (SlotHash::Iterator iter = slotHash.begin(); iter != slotHash.end(); ++iter) {
- QList<Connection> &connections = *iter;
- for (int ii = 0; ii < connections.count(); ++ii) {
- qPersistentDispose(connections[ii].thisObject);
- qPersistentDispose(connections[ii].function);
- }
- }
- slotHash.clear();
-}
-
-void QV8QObjectConnectionList::objectDestroyed(QObject *object)
-{
- engine->qobjectWrapper()->m_connections.remove(object);
-
- if (inUse)
- needsDestroy = true;
- else
- delete this;
-}
-
-int QV8QObjectConnectionList::qt_metacall(QMetaObject::Call method, int index, void **metaArgs)
-{
- if (method == QMetaObject::InvokeMetaMethod) {
- SlotHash::Iterator iter = slotHash.find(index);
- if (iter == slotHash.end())
- return -1;
- ConnectionList &connectionList = *iter;
- if (connectionList.isEmpty())
- return -1;
-
- inUse++;
-
- connectionList.connectionsInUse++;
-
- QList<Connection> connections = connectionList;
-
- QVarLengthArray<int, 9> dummy;
- int *argsTypes = QDeclarativePropertyCache::methodParameterTypes(data(), index, dummy, 0);
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- int argCount = argsTypes?argsTypes[0]:0;
- QVarLengthArray<v8::Handle<v8::Value>, 9> args(argCount);
-
- for (int ii = 0; ii < argCount; ++ii) {
- int type = argsTypes[ii + 1];
- if (type == qMetaTypeId<QVariant>()) {
- args[ii] = engine->fromVariant(*((QVariant *)metaArgs[ii + 1]));
- } else {
- args[ii] = engine->fromVariant(QVariant(type, metaArgs[ii + 1]));
- }
- }
-
- for (int ii = 0; ii < connections.count(); ++ii) {
- Connection &connection = connections[ii];
- if (connection.needsDestroy)
- continue;
-
- v8::TryCatch try_catch;
- if (connection.thisObject.IsEmpty()) {
- connection.function->Call(engine->global(), argCount, args.data());
- } else {
- connection.function->Call(connection.thisObject, argCount, args.data());
- }
-
- if (try_catch.HasCaught()) {
- QDeclarativeError error;
- error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(engine->toString(connection.function->GetName())));
- v8::Local<v8::Message> message = try_catch.Message();
- if (!message.IsEmpty())
- QDeclarativeExpressionPrivate::exceptionToError(message, error);
- QDeclarativeEnginePrivate::get(engine->engine())->warning(error);
- }
- }
-
- connectionList.connectionsInUse--;
- if (connectionList.connectionsInUse == 0 && connectionList.connectionsNeedClean) {
- for (QList<Connection>::Iterator iter = connectionList.begin();
- iter != connectionList.end(); ) {
- if (iter->needsDestroy) {
- iter->dispose();
- iter = connectionList.erase(iter);
- } else {
- ++iter;
- }
- }
- }
-
- inUse--;
- if (inUse == 0 && needsDestroy)
- delete this;
- }
-
- return -1;
-}
-
-v8::Handle<v8::Value> QV8QObjectWrapper::Connect(const v8::Arguments &args)
-{
- if (args.Length() == 0)
- V8THROW_ERROR("Function.prototype.connect: no arguments given");
-
- QV8Engine *engine = V8ENGINE();
-
- QPair<QObject *, int> signalInfo = ExtractQtSignal(engine, args.This());
- QObject *signalObject = signalInfo.first;
- int signalIndex = signalInfo.second;
-
- if (signalIndex == -1)
- V8THROW_ERROR("Function.prototype.connect: this object is not a signal");
-
- if (!signalObject)
- V8THROW_ERROR("Function.prototype.connect: cannot connect to deleted QObject");
-
- if (signalIndex < 0 || signalObject->metaObject()->method(signalIndex).methodType() != QMetaMethod::Signal)
- V8THROW_ERROR("Function.prototype.connect: this object is not a signal");
-
- v8::Local<v8::Value> functionValue;
- v8::Local<v8::Value> functionThisValue;
-
- if (args.Length() == 1) {
- functionValue = args[0];
- } else {
- functionThisValue = args[0];
- functionValue = args[1];
- }
-
- if (!functionValue->IsFunction())
- V8THROW_ERROR("Function.prototype.connect: target is not a function");
-
- if (!functionThisValue.IsEmpty() && !functionThisValue->IsObject())
- V8THROW_ERROR("Function.prototype.connect: target this is not an object");
-
- QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
- QHash<QObject *, QV8QObjectConnectionList *> &connections = qobjectWrapper->m_connections;
- QHash<QObject *, QV8QObjectConnectionList *>::Iterator iter = connections.find(signalObject);
- if (iter == connections.end())
- iter = connections.insert(signalObject, new QV8QObjectConnectionList(signalObject, engine));
-
- QV8QObjectConnectionList *connectionList = *iter;
- QV8QObjectConnectionList::SlotHash::Iterator slotIter = connectionList->slotHash.find(signalIndex);
- if (slotIter == connectionList->slotHash.end()) {
- slotIter = connectionList->slotHash.insert(signalIndex, QV8QObjectConnectionList::ConnectionList());
- QMetaObject::connect(signalObject, signalIndex, connectionList, signalIndex);
- }
-
- QV8QObjectConnectionList::Connection connection;
- if (!functionThisValue.IsEmpty())
- connection.thisObject = qPersistentNew<v8::Object>(functionThisValue->ToObject());
- connection.function = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(functionValue));
-
- slotIter->append(connection);
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> QV8QObjectWrapper::Disconnect(const v8::Arguments &args)
-{
- if (args.Length() == 0)
- V8THROW_ERROR("Function.prototype.disconnect: no arguments given");
-
- QV8Engine *engine = V8ENGINE();
-
- QPair<QObject *, int> signalInfo = ExtractQtSignal(engine, args.This());
- QObject *signalObject = signalInfo.first;
- int signalIndex = signalInfo.second;
-
- if (signalIndex == -1)
- V8THROW_ERROR("Function.prototype.disconnect: this object is not a signal");
-
- if (!signalObject)
- V8THROW_ERROR("Function.prototype.disconnect: cannot disconnect from deleted QObject");
-
- if (signalIndex < 0 || signalObject->metaObject()->method(signalIndex).methodType() != QMetaMethod::Signal)
- V8THROW_ERROR("Function.prototype.disconnect: this object is not a signal");
-
- v8::Local<v8::Value> functionValue;
- v8::Local<v8::Value> functionThisValue;
-
- if (args.Length() == 1) {
- functionValue = args[0];
- } else {
- functionThisValue = args[0];
- functionValue = args[1];
- }
-
- if (!functionValue->IsFunction())
- V8THROW_ERROR("Function.prototype.disconnect: target is not a function");
-
- if (!functionThisValue.IsEmpty() && !functionThisValue->IsObject())
- V8THROW_ERROR("Function.prototype.disconnect: target this is not an object");
-
- QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
- QHash<QObject *, QV8QObjectConnectionList *> &connectionsList = qobjectWrapper->m_connections;
- QHash<QObject *, QV8QObjectConnectionList *>::Iterator iter = connectionsList.find(signalObject);
- if (iter == connectionsList.end())
- return v8::Undefined(); // Nothing to disconnect from
-
- QV8QObjectConnectionList *connectionList = *iter;
- QV8QObjectConnectionList::SlotHash::Iterator slotIter = connectionList->slotHash.find(signalIndex);
- if (slotIter == connectionList->slotHash.end())
- return v8::Undefined(); // Nothing to disconnect from
-
- QV8QObjectConnectionList::ConnectionList &connections = *slotIter;
-
- v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionValue);
- QPair<QObject *, int> functionData = ExtractQtMethod(engine, function);
-
- if (functionData.second != -1) {
- // This is a QObject function wrapper
- for (int ii = 0; ii < connections.count(); ++ii) {
- QV8QObjectConnectionList::Connection &connection = connections[ii];
-
- if (connection.thisObject.IsEmpty() == functionThisValue.IsEmpty() &&
- (connection.thisObject.IsEmpty() || connection.thisObject->StrictEquals(functionThisValue))) {
-
- QPair<QObject *, int> connectedFunctionData = ExtractQtMethod(engine, connection.function);
- if (connectedFunctionData == functionData) {
- // Match!
- if (connections.connectionsInUse) {
- connection.needsDestroy = true;
- connections.connectionsNeedClean = true;
- } else {
- connection.dispose();
- connections.removeAt(ii);
- }
- return v8::Undefined();
- }
- }
- }
-
- } else {
- // This is a normal JS function
- for (int ii = 0; ii < connections.count(); ++ii) {
- QV8QObjectConnectionList::Connection &connection = connections[ii];
- if (connection.function->StrictEquals(function) &&
- connection.thisObject.IsEmpty() == functionThisValue.IsEmpty() &&
- (connection.thisObject.IsEmpty() || connection.thisObject->StrictEquals(functionThisValue))) {
- // Match!
- if (connections.connectionsInUse) {
- connection.needsDestroy = true;
- connections.connectionsNeedClean = true;
- } else {
- connection.dispose();
- connections.removeAt(ii);
- }
- return v8::Undefined();
- }
- }
- }
-
- return v8::Undefined();
-}
-
-/*!
- \fn v8::Handle<v8::Value> QV8QObjectWrapper::getProperty(QObject *object, const QHashedV8String &property, QV8QObjectWrapper::RevisionMode revisionMode)
-
- Get the \a property of \a object. Returns an empty handle if the property doesn't exist.
-
- Only searches for real properties of \a object (including methods), not attached properties etc.
-*/
-
-/*
- \fn bool QV8QObjectWrapper::setProperty(QObject *object, const QHashedV8String &property, v8::Handle<v8::Value> value, RevisionMode revisionMode)
-
- Set the \a property of \a object to \a value.
-
- Returns true if the property was "set" - even if this results in an exception being thrown -
- and false if the object has no such property.
-
- Only searches for real properties of \a object (including methods), not attached properties etc.
-*/
-
-namespace {
-struct CallArgs
-{
- CallArgs(int length, v8::Handle<v8::Object> *args) : _length(length), _args(args) {}
- int Length() const { return _length; }
- v8::Local<v8::Value> operator[](int idx) { return (*_args)->Get(idx); }
-
-private:
- int _length;
- v8::Handle<v8::Object> *_args;
-};
-}
-
-static v8::Handle<v8::Value> CallMethod(QObject *object, int index, int returnType, int argCount,
- int *argTypes, QV8Engine *engine, CallArgs &callArgs)
-{
- if (argCount > 0) {
-
- QVarLengthArray<CallArgument, 9> args(argCount + 1);
- args[0].initAsType(returnType);
-
- for (int ii = 0; ii < argCount; ++ii)
- args[ii + 1].fromValue(argTypes[ii], engine, callArgs[ii]);
-
- QVarLengthArray<void *, 9> argData(args.count());
- for (int ii = 0; ii < args.count(); ++ii)
- argData[ii] = args[ii].dataPtr();
-
- QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, argData.data());
-
- return args[0].toValue(engine);
-
- } else if (returnType != 0) {
-
- CallArgument arg;
- arg.initAsType(returnType);
-
- void *args[] = { arg.dataPtr() };
-
- QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, args);
-
- return arg.toValue(engine);
-
- } else {
-
- void *args[] = { 0 };
- QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, args);
- return v8::Undefined();
-
- }
-}
-
-/*!
- Returns the match score for converting \a actual to be of type \a conversionType. A
- zero score means "perfect match" whereas a higher score is worse.
-
- The conversion table is copied out of the QtScript callQtMethod() function.
-*/
-static int MatchScore(v8::Handle<v8::Value> actual, int conversionType)
-{
- if (actual->IsNumber()) {
- switch (conversionType) {
- case QMetaType::Double:
- return 0;
- case QMetaType::Float:
- return 1;
- case QMetaType::LongLong:
- case QMetaType::ULongLong:
- return 2;
- case QMetaType::Long:
- case QMetaType::ULong:
- return 3;
- case QMetaType::Int:
- case QMetaType::UInt:
- return 4;
- case QMetaType::Short:
- case QMetaType::UShort:
- return 5;
- break;
- case QMetaType::Char:
- case QMetaType::UChar:
- return 6;
- default:
- return 10;
- }
- } else if (actual->IsString()) {
- switch (conversionType) {
- case QMetaType::QString:
- return 0;
- default:
- return 10;
- }
- } else if (actual->IsBoolean()) {
- switch (conversionType) {
- case QMetaType::Bool:
- return 0;
- default:
- return 10;
- }
- } else if (actual->IsDate()) {
- switch (conversionType) {
- case QMetaType::QDateTime:
- return 0;
- case QMetaType::QDate:
- return 1;
- case QMetaType::QTime:
- return 2;
- default:
- return 10;
- }
- } else if (actual->IsRegExp()) {
- switch (conversionType) {
- case QMetaType::QRegExp:
- return 0;
- default:
- return 10;
- }
- } else if (actual->IsArray()) {
- switch (conversionType) {
- case QMetaType::QStringList:
- case QMetaType::QVariantList:
- return 5;
- default:
- return 10;
- }
- } else if (actual->IsNull()) {
- switch (conversionType) {
- case QMetaType::VoidStar:
- case QMetaType::QObjectStar:
- return 0;
- default: {
- const char *typeName = QMetaType::typeName(conversionType);
- if (typeName && typeName[strlen(typeName) - 1] == '*')
- return 0;
- else
- return 10;
- }
- }
- } else if (actual->IsObject()) {
- v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(actual);
-
- QV8ObjectResource *r = static_cast<QV8ObjectResource *>(obj->GetExternalResource());
- if (r && r->resourceType() == QV8ObjectResource::QObjectType) {
- switch (conversionType) {
- case QMetaType::QObjectStar:
- return 0;
- default:
- return 10;
- }
- } else if (r && r->resourceType() == QV8ObjectResource::VariantType) {
- if (conversionType == qMetaTypeId<QVariant>())
- return 0;
- else if (r->engine->toVariant(actual, -1).userType() == conversionType)
- return 0;
- else
- return 10;
- } else {
- return 10;
- }
-
- } else {
- return 10;
- }
-}
-
-static inline int QMetaObject_methods(const QMetaObject *metaObject)
-{
- struct Private
- {
- int revision;
- int className;
- int classInfoCount, classInfoData;
- int methodCount, methodData;
- };
-
- return reinterpret_cast<const Private *>(metaObject->d.data)->methodCount;
-}
-
-static QByteArray QMetaMethod_name(const QMetaMethod &m)
-{
- QByteArray sig = m.signature();
- int paren = sig.indexOf('(');
- if (paren == -1)
- return sig;
- else
- return sig.left(paren);
-}
-
-/*!
-Returns the next related method, if one, or 0.
-*/
-static const QDeclarativePropertyData * RelatedMethod(QObject *object,
- const QDeclarativePropertyData *current,
- QDeclarativePropertyData &dummy)
-{
- QDeclarativePropertyCache *cache = QDeclarativeData::get(object)->propertyCache;
- if (!current->isOverload())
- return 0;
-
- Q_ASSERT(!current->overrideIndexIsProperty);
-
- if (cache) {
- return cache->method(current->overrideIndex);
- } else {
- const QMetaObject *mo = object->metaObject();
- int methodOffset = mo->methodCount() - QMetaObject_methods(mo);
-
- while (methodOffset > current->overrideIndex) {
- mo = mo->superClass();
- methodOffset -= QMetaObject_methods(mo);
- }
-
- QMetaMethod method = mo->method(current->overrideIndex);
- dummy.load(method);
-
- // Look for overloaded methods
- QByteArray methodName = QMetaMethod_name(method);
- for (int ii = current->overrideIndex - 1; ii >= methodOffset; --ii) {
- if (methodName == QMetaMethod_name(mo->method(ii))) {
- dummy.setFlags(dummy.getFlags() | QDeclarativePropertyData::IsOverload);
- dummy.overrideIndexIsProperty = 0;
- dummy.overrideIndex = ii;
- return &dummy;
- }
- }
-
- return &dummy;
- }
-}
-
-static v8::Handle<v8::Value> CallPrecise(QObject *object, const QDeclarativePropertyData &data,
- QV8Engine *engine, CallArgs &callArgs)
-{
- if (data.hasArguments()) {
-
- int *args = 0;
- QVarLengthArray<int, 9> dummy;
- QByteArray unknownTypeError;
-
- args = QDeclarativePropertyCache::methodParameterTypes(object, data.coreIndex, dummy,
- &unknownTypeError);
-
- if (!args) {
- QString typeName = QString::fromLatin1(unknownTypeError);
- QString error = QString::fromLatin1("Unknown method parameter type: %1").arg(typeName);
- v8::ThrowException(v8::Exception::Error(engine->toString(error)));
- return v8::Handle<v8::Value>();
- }
-
- if (args[0] > callArgs.Length()) {
- QString error = QLatin1String("Insufficient arguments");
- v8::ThrowException(v8::Exception::Error(engine->toString(error)));
- return v8::Handle<v8::Value>();
- }
-
- return CallMethod(object, data.coreIndex, data.propType, args[0], args + 1, engine, callArgs);
-
- } else {
-
- return CallMethod(object, data.coreIndex, data.propType, 0, 0, engine, callArgs);
-
- }
-}
-
-/*!
-Resolve the overloaded method to call. The algorithm works conceptually like this:
- 1. Resolve the set of overloads it is *possible* to call.
- Impossible overloads include those that have too many parameters or have parameters
- of unknown type.
- 2. Filter the set of overloads to only contain those with the closest number of
- parameters.
- For example, if we are called with 3 parameters and there are 2 overloads that
- take 2 parameters and one that takes 3, eliminate the 2 parameter overloads.
- 3. Find the best remaining overload based on its match score.
- If two or more overloads have the same match score, call the last one. The match
- score is constructed by adding the matchScore() result for each of the parameters.
-*/
-static v8::Handle<v8::Value> CallOverloaded(QObject *object, const QDeclarativePropertyData &data,
- QV8Engine *engine, CallArgs &callArgs)
-{
- int argumentCount = callArgs.Length();
-
- const QDeclarativePropertyData *best = 0;
- int bestParameterScore = INT_MAX;
- int bestMatchScore = INT_MAX;
-
- QDeclarativePropertyData dummy;
- const QDeclarativePropertyData *attempt = &data;
-
- do {
- QVarLengthArray<int, 9> dummy;
- int methodArgumentCount = 0;
- int *methodArgTypes = 0;
- if (attempt->hasArguments()) {
- typedef QDeclarativePropertyCache PC;
- int *args = PC::methodParameterTypes(object, attempt->coreIndex, dummy, 0);
- if (!args) // Must be an unknown argument
- continue;
-
- methodArgumentCount = args[0];
- methodArgTypes = args + 1;
- }
-
- if (methodArgumentCount > argumentCount)
- continue; // We don't have sufficient arguments to call this method
-
- int methodParameterScore = argumentCount - methodArgumentCount;
- if (methodParameterScore > bestParameterScore)
- continue; // We already have a better option
-
- int methodMatchScore = 0;
- for (int ii = 0; ii < methodArgumentCount; ++ii)
- methodMatchScore += MatchScore(callArgs[ii], methodArgTypes[ii]);
-
- if (bestParameterScore > methodParameterScore || bestMatchScore > methodMatchScore) {
- best = attempt;
- bestParameterScore = methodParameterScore;
- bestMatchScore = methodMatchScore;
- }
-
- if (bestParameterScore == 0 && bestMatchScore == 0)
- break; // We can't get better than that
-
- } while((attempt = RelatedMethod(object, attempt, dummy)) != 0);
-
- if (best) {
- return CallPrecise(object, *best, engine, callArgs);
- } else {
- QString error = QLatin1String("Unable to determine callable overload. Candidates are:");
- const QDeclarativePropertyData *candidate = &data;
- while (candidate) {
- error += QLatin1String("\n ") +
- QString::fromUtf8(object->metaObject()->method(candidate->coreIndex).signature());
- candidate = RelatedMethod(object, candidate, dummy);
- }
-
- v8::ThrowException(v8::Exception::Error(engine->toString(error)));
- return v8::Handle<v8::Value>();
- }
-}
-
-static v8::Handle<v8::Value> ToString(QV8Engine *engine, QObject *object, int, v8::Handle<v8::Object>)
-{
- QString result;
- if (object) {
- QString objectName = object->objectName();
-
- result += QString::fromUtf8(object->metaObject()->className());
- result += QLatin1String("(0x");
- result += QString::number((quintptr)object,16);
-
- if (!objectName.isEmpty()) {
- result += QLatin1String(", \"");
- result += objectName;
- result += QLatin1Char('\"');
- }
-
- result += QLatin1Char(')');
- } else {
- result = QLatin1String("null");
- }
-
- return engine->toString(result);
-}
-
-static v8::Handle<v8::Value> Destroy(QV8Engine *, QObject *object, int argCount, v8::Handle<v8::Object> args)
-{
- QDeclarativeData *ddata = QDeclarativeData::get(object, false);
- if (!ddata || ddata->indestructible) {
- const char *error = "Invalid attempt to destroy() an indestructible object";
- v8::ThrowException(v8::Exception::Error(v8::String::New(error)));
- return v8::Undefined();
- }
-
- int delay = 0;
- if (argCount > 0)
- delay = args->Get(0)->Uint32Value();
-
- if (delay > 0)
- QTimer::singleShot(delay, object, SLOT(deleteLater()));
- else
- object->deleteLater();
-
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> QV8QObjectWrapper::Invoke(const v8::Arguments &args)
-{
- // object, index, qmlglobal, argCount, args
- Q_ASSERT(args.Length() == 5);
- Q_ASSERT(args[0]->IsObject());
-
- QV8QObjectResource *resource = v8_resource_cast<QV8QObjectResource>(args[0]->ToObject());
-
- if (!resource)
- return v8::Undefined();
-
- int argCount = args[3]->Int32Value();
- v8::Handle<v8::Object> arguments = v8::Handle<v8::Object>::Cast(args[4]);
-
- // Special hack to return info about this closure.
- if (argCount == 1 && arguments->Get(0)->StrictEquals(resource->engine->qobjectWrapper()->m_hiddenObject)) {
- v8::Local<v8::Array> data = v8::Array::New(2);
- data->Set(0, args[0]);
- data->Set(1, args[1]);
- return data;
- }
-
- QObject *object = resource->object;
- int index = args[1]->Int32Value();
-
- if (!object)
- return v8::Undefined();
-
- if (index < 0) {
- // Builtin functions
- if (index == QOBJECT_TOSTRING_INDEX) {
- return ToString(resource->engine, object, argCount, arguments);
- } else if (index == QOBJECT_DESTROY_INDEX) {
- return Destroy(resource->engine, object, argCount, arguments);
- } else {
- return v8::Undefined();
- }
- }
-
- QDeclarativePropertyData method;
-
- if (QDeclarativeData *ddata = static_cast<QDeclarativeData *>(QObjectPrivate::get(object)->declarativeData)) {
- if (ddata->propertyCache) {
- QDeclarativePropertyData *d = ddata->propertyCache->method(index);
- if (!d)
- return v8::Undefined();
- method = *d;
- }
- }
-
- if (method.coreIndex == -1) {
- method.load(object->metaObject()->method(index));
-
- if (method.coreIndex == -1)
- return v8::Undefined();
- }
-
- if (method.isV8Function()) {
- v8::Handle<v8::Value> rv;
- v8::Handle<v8::Object> qmlglobal = args[2]->ToObject();
-
- QDeclarativeV8Function func(argCount, arguments, rv, qmlglobal,
- resource->engine->contextWrapper()->context(qmlglobal),
- resource->engine);
- QDeclarativeV8Function *funcptr = &func;
-
- void *args[] = { 0, &funcptr };
- QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, method.coreIndex, args);
-
- if (rv.IsEmpty()) return v8::Undefined();
- return rv;
- }
-
- CallArgs callArgs(argCount, &arguments);
- if (!method.isOverload()) {
- return CallPrecise(object, method, resource->engine, callArgs);
- } else {
- return CallOverloaded(object, method, resource->engine, callArgs);
- }
-}
-
-CallArgument::CallArgument()
-: type(QVariant::Invalid)
-{
-}
-
-CallArgument::~CallArgument()
-{
- cleanup();
-}
-
-void CallArgument::cleanup()
-{
- if (type == QMetaType::QString) {
- qstringPtr->~QString();
- } else if (type == -1 || type == QMetaType::QVariant) {
- qvariantPtr->~QVariant();
- } else if (type == qMetaTypeId<QJSValue>()) {
- qjsValuePtr->~QJSValue();
- } else if (type == qMetaTypeId<QList<QObject *> >()) {
- qlistPtr->~QList<QObject *>();
- }
-}
-
-void *CallArgument::dataPtr()
-{
- if (type == -1)
- return qvariantPtr->data();
- else
- return (void *)&allocData;
-}
-
-void CallArgument::initAsType(int callType)
-{
- if (type != 0) { cleanup(); type = 0; }
- if (callType == 0) return;
-
- if (callType == qMetaTypeId<QJSValue>()) {
- qjsValuePtr = new (&allocData) QJSValue();
- type = callType;
- } else if (callType == QMetaType::Int ||
- callType == QMetaType::UInt ||
- callType == QMetaType::Bool ||
- callType == QMetaType::Double ||
- callType == QMetaType::Float) {
- type = callType;
- } else if (callType == QMetaType::QObjectStar) {
- qobjectPtr = 0;
- type = callType;
- } else if (callType == QMetaType::QString) {
- qstringPtr = new (&allocData) QString();
- type = callType;
- } else if (callType == QMetaType::QVariant) {
- type = callType;
- qvariantPtr = new (&allocData) QVariant();
- } else if (callType == qMetaTypeId<QList<QObject *> >()) {
- type = callType;
- qlistPtr = new (&allocData) QList<QObject *>();
- } else if (callType == qMetaTypeId<QDeclarativeV8Handle>()) {
- type = callType;
- handlePtr = new (&allocData) QDeclarativeV8Handle;
- } else {
- type = -1;
- qvariantPtr = new (&allocData) QVariant(callType, (void *)0);
- }
-}
-
-void CallArgument::fromValue(int callType, QV8Engine *engine, v8::Handle<v8::Value> value)
-{
- if (type != 0) { cleanup(); type = 0; }
-
- if (callType == qMetaTypeId<QJSValue>()) {
- qjsValuePtr = new (&allocData) QJSValue(QJSValuePrivate::get(new QJSValuePrivate(engine, value)));
- type = qMetaTypeId<QJSValue>();
- } else if (callType == QMetaType::Int) {
- intValue = quint32(value->Int32Value());
- type = callType;
- } else if (callType == QMetaType::UInt) {
- intValue = quint32(value->Uint32Value());
- type = callType;
- } else if (callType == QMetaType::Bool) {
- boolValue = value->BooleanValue();
- type = callType;
- } else if (callType == QMetaType::Double) {
- doubleValue = double(value->NumberValue());
- type = callType;
- } else if (callType == QMetaType::Float) {
- floatValue = float(value->NumberValue());
- type = callType;
- } else if (callType == QMetaType::QString) {
- if (value->IsNull() || value->IsUndefined())
- qstringPtr = new (&allocData) QString();
- else
- qstringPtr = new (&allocData) QString(engine->toString(value->ToString()));
- type = callType;
- } else if (callType == QMetaType::QObjectStar) {
- qobjectPtr = engine->toQObject(value);
- type = callType;
- } else if (callType == qMetaTypeId<QVariant>()) {
- qvariantPtr = new (&allocData) QVariant(engine->toVariant(value, -1));
- type = callType;
- } else if (callType == qMetaTypeId<QList<QObject*> >()) {
- qlistPtr = new (&allocData) QList<QObject *>();
- if (value->IsArray()) {
- v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
- uint32_t length = array->Length();
- for (uint32_t ii = 0; ii < length; ++ii)
- qlistPtr->append(engine->toQObject(array->Get(ii)));
- } else {
- qlistPtr->append(engine->toQObject(value));
- }
- type = callType;
- } else if (callType == qMetaTypeId<QDeclarativeV8Handle>()) {
- handlePtr = new (&allocData) QDeclarativeV8Handle(QDeclarativeV8Handle::fromHandle(value));
- type = callType;
- } else {
- qvariantPtr = new (&allocData) QVariant();
- type = -1;
-
- QDeclarativeEnginePrivate *ep = engine->engine() ? QDeclarativeEnginePrivate::get(engine->engine()) : 0;
- QVariant v = engine->toVariant(value, -1);
-
- if (v.userType() == callType) {
- *qvariantPtr = v;
- } else if (v.canConvert((QVariant::Type)callType)) {
- *qvariantPtr = v;
- qvariantPtr->convert((QVariant::Type)callType);
- } else if (const QMetaObject *mo = ep ? ep->rawMetaObjectForType(callType) : 0) {
- QObject *obj = ep->toQObject(v);
-
- if (obj) {
- const QMetaObject *objMo = obj->metaObject();
- while (objMo && objMo != mo) objMo = objMo->superClass();
- if (!objMo) obj = 0;
- }
-
- *qvariantPtr = QVariant(callType, &obj);
- } else {
- *qvariantPtr = QVariant(callType, (void *)0);
- }
- }
-}
-
-v8::Handle<v8::Value> CallArgument::toValue(QV8Engine *engine)
-{
- if (type == qMetaTypeId<QJSValue>()) {
- return QJSValuePrivate::get(*qjsValuePtr)->asV8Value(engine);
- } else if (type == QMetaType::Int) {
- return v8::Integer::New(int(intValue));
- } else if (type == QMetaType::UInt) {
- return v8::Integer::NewFromUnsigned(intValue);
- } else if (type == QMetaType::Bool) {
- return v8::Boolean::New(boolValue);
- } else if (type == QMetaType::Double) {
- return v8::Number::New(doubleValue);
- } else if (type == QMetaType::Float) {
- return v8::Number::New(floatValue);
- } else if (type == QMetaType::QString) {
- return engine->toString(*qstringPtr);
- } else if (type == QMetaType::QObjectStar) {
- QObject *object = qobjectPtr;
- if (object)
- QDeclarativeData::get(object, true)->setImplicitDestructible();
- return engine->newQObject(object);
- } else if (type == qMetaTypeId<QList<QObject *> >()) {
- // XXX Can this be made more by using Array as a prototype and implementing
- // directly against QList<QObject*>?
- QList<QObject *> &list = *qlistPtr;
- v8::Local<v8::Array> array = v8::Array::New(list.count());
- for (int ii = 0; ii < list.count(); ++ii)
- array->Set(ii, engine->newQObject(list.at(ii)));
- return array;
- } else if (type == qMetaTypeId<QDeclarativeV8Handle>()) {
- return handlePtr->toHandle();
- } else if (type == -1 || type == qMetaTypeId<QVariant>()) {
- QVariant value = *qvariantPtr;
- v8::Handle<v8::Value> rv = engine->fromVariant(value);
- if (QObject *object = engine->toQObject(rv))
- QDeclarativeData::get(object, true)->setImplicitDestructible();
- return rv;
- } else {
- return v8::Undefined();
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/v8/qv8qobjectwrapper_p.h b/src/declarative/qml/v8/qv8qobjectwrapper_p.h
deleted file mode 100644
index c029285d08..0000000000
--- a/src/declarative/qml/v8/qv8qobjectwrapper_p.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8QOBJECTWRAPPER_P_H
-#define QV8QOBJECTWRAPPER_P_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/qmetatype.h>
-#include <QtCore/qpair.h>
-#include <QtCore/qhash.h>
-#include <private/qv8_p.h>
-#include <private/qhashedstring_p.h>
-#include <private/qdeclarativedata_p.h>
-#include <private/qdeclarativepropertycache_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-class QV8Engine;
-class QDeclarativeData;
-class QV8ObjectResource;
-class QV8QObjectInstance;
-class QV8QObjectConnectionList;
-class QDeclarativePropertyCache;
-class Q_DECLARATIVE_EXPORT QV8QObjectWrapper
-{
-public:
- QV8QObjectWrapper();
- ~QV8QObjectWrapper();
-
- void init(QV8Engine *);
- void destroy();
-
- v8::Handle<v8::Value> newQObject(QObject *object);
- bool isQObject(v8::Handle<v8::Object>);
- QObject *toQObject(v8::Handle<v8::Object>);
- static QObject *toQObject(QV8ObjectResource *);
-
- enum RevisionMode { IgnoreRevision, CheckRevision };
- inline v8::Handle<v8::Value> getProperty(QObject *, const QHashedV8String &, RevisionMode);
- inline bool setProperty(QObject *, const QHashedV8String &, v8::Handle<v8::Value>, RevisionMode);
-
-private:
- friend class QDeclarativePropertyCache;
- friend class QV8QObjectConnectionList;
- friend class QV8QObjectInstance;
-
- v8::Local<v8::Object> newQObject(QObject *, QDeclarativeData *, QV8Engine *);
- static v8::Handle<v8::Value> GetProperty(QV8Engine *, QObject *, v8::Handle<v8::Value> *,
- const QHashedV8String &, QV8QObjectWrapper::RevisionMode);
- static bool SetProperty(QV8Engine *, QObject *, const QHashedV8String &,
- v8::Handle<v8::Value>, QV8QObjectWrapper::RevisionMode);
- static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Integer> Query(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Connect(const v8::Arguments &args);
- static v8::Handle<v8::Value> Disconnect(const v8::Arguments &args);
- static v8::Handle<v8::Value> Invoke(const v8::Arguments &args);
- static QPair<QObject *, int> ExtractQtMethod(QV8Engine *, v8::Handle<v8::Function>);
- static QPair<QObject *, int> ExtractQtSignal(QV8Engine *, v8::Handle<v8::Object>);
-
- QV8Engine *m_engine;
- quint32 m_id;
- v8::Persistent<v8::Function> m_constructor;
- v8::Persistent<v8::Function> m_methodConstructor;
- v8::Persistent<v8::Function> m_signalHandlerConstructor;
- v8::Persistent<v8::String> m_toStringSymbol;
- v8::Persistent<v8::String> m_destroySymbol;
- QHashedV8String m_toStringString;
- QHashedV8String m_destroyString;
- v8::Persistent<v8::Object> m_hiddenObject;
- QHash<QObject *, QV8QObjectConnectionList *> m_connections;
- typedef QHash<QObject *, QV8QObjectInstance *> TaintedHash;
- TaintedHash m_taintedObjects;
-};
-
-v8::Handle<v8::Value> QV8QObjectWrapper::getProperty(QObject *object, const QHashedV8String &string,
- RevisionMode mode)
-{
- QDeclarativeData *dd = QDeclarativeData::get(object, false);
- if (!dd || !dd->propertyCache || m_toStringString == string || m_destroyString == string ||
- dd->propertyCache->property(string)) {
- return GetProperty(m_engine, object, 0, string, mode);
- } else {
- return v8::Handle<v8::Value>();
- }
-}
-
-bool QV8QObjectWrapper::setProperty(QObject *object, const QHashedV8String &string,
- v8::Handle<v8::Value> value, RevisionMode mode)
-{
- QDeclarativeData *dd = QDeclarativeData::get(object, false);
- if (!dd || !dd->propertyCache || m_toStringString == string || m_destroyString == string ||
- dd->propertyCache->property(string)) {
- return SetProperty(m_engine, object, string, value, mode);
- } else {
- return false;
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // QV8QOBJECTWRAPPER_P_H
-
-
diff --git a/src/declarative/qml/v8/qv8sequencewrapper.cpp b/src/declarative/qml/v8/qv8sequencewrapper.cpp
deleted file mode 100644
index 7d7184e83d..0000000000
--- a/src/declarative/qml/v8/qv8sequencewrapper.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtDeclarative/qdeclarative.h>
-
-#include "qv8sequencewrapper_p.h"
-#include "qv8sequencewrapper_p_p.h"
-#include "qv8engine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QV8SequenceWrapper::QV8SequenceWrapper()
- : m_engine(0)
-{
-}
-
-QV8SequenceWrapper::~QV8SequenceWrapper()
-{
-}
-
-#define REGISTER_QML_SEQUENCE_METATYPE(unused, unused2, SequenceType, unused3) qRegisterMetaType<SequenceType>();
-void QV8SequenceWrapper::init(QV8Engine *engine)
-{
- FOREACH_QML_SEQUENCE_TYPE(REGISTER_QML_SEQUENCE_METATYPE)
-
- m_engine = engine;
- m_toString = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ToString)->GetFunction());
- m_valueOf = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ValueOf)->GetFunction());
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
- ft->InstanceTemplate()->SetIndexedPropertyHandler(IndexedGetter, IndexedSetter, 0, IndexedDeleter, IndexedEnumerator);
- ft->InstanceTemplate()->SetAccessor(v8::String::New("length"), LengthGetter, LengthSetter,
- v8::Handle<v8::Value>(), v8::DEFAULT,
- v8::PropertyAttribute(v8::DontDelete | v8::DontEnum));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
- m_toString, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("valueOf"), ValueOfGetter, 0,
- m_valueOf, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum));
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
-}
-#undef REGISTER_QML_SEQUENCE_METATYPE
-
-void QV8SequenceWrapper::destroy()
-{
- qPersistentDispose(m_toString);
- qPersistentDispose(m_valueOf);
- qPersistentDispose(m_constructor);
-}
-
-bool QV8SequenceWrapper::isEqual(QV8ObjectResource *lhs, QV8ObjectResource *rhs)
-{
- Q_ASSERT(lhs && rhs && lhs->resourceType() == QV8ObjectResource::SequenceType && rhs->resourceType() == QV8ObjectResource::SequenceType);
- QV8SequenceResource *lr = static_cast<QV8SequenceResource *>(lhs);
- QV8SequenceResource *rr = static_cast<QV8SequenceResource *>(rhs);
- return lr->isEqual(rr);
-}
-
-quint32 QV8SequenceWrapper::sequenceLength(QV8ObjectResource *r)
-{
- Q_ASSERT(r->resourceType() == QV8ObjectResource::SequenceType);
- QV8SequenceResource *sr = static_cast<QV8SequenceResource *>(r);
- Q_ASSERT(sr);
- return sr->lengthGetter();
-}
-
-#define NEW_REFERENCE_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \
- if (sequenceType == qMetaTypeId<SequenceType>()) { \
- r = new QV8##ElementTypeName##SequenceResource(m_engine, object, propertyIndex); \
- } else
-
-v8::Local<v8::Object> QV8SequenceWrapper::newSequence(int sequenceType, QObject *object, int propertyIndex, bool *succeeded)
-{
- // This function is called when the property is a QObject Q_PROPERTY of
- // the given sequence type. Internally we store a typed-sequence
- // (as well as object ptr + property index for updated-read and write-back)
- // and so access/mutate avoids variant conversion.
- *succeeded = true;
- QV8SequenceResource *r = 0;
- FOREACH_QML_SEQUENCE_TYPE(NEW_REFERENCE_SEQUENCE) { /* else */ *succeeded = false; return v8::Local<v8::Object>(); }
-
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- rv->SetExternalResource(r);
- rv->SetPrototype(v8::Array::New(1)->GetPrototype());
- return rv;
-}
-#undef NEW_REFERENCE_SEQUENCE
-
-#define NEW_COPY_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \
- if (sequenceType == qMetaTypeId<SequenceType>()) { \
- r = new QV8##ElementTypeName##SequenceResource(m_engine, v.value<SequenceType>()); \
- } else
-
-v8::Local<v8::Object> QV8SequenceWrapper::fromVariant(const QVariant& v, bool *succeeded)
-{
- // This function is called when assigning a sequence value to a normal JS var
- // in a JS block. Internally, we store a sequence of the specified type.
- // Access and mutation is extremely fast since it will not need to modify any
- // QObject property.
- int sequenceType = v.userType();
- *succeeded = true;
- QV8SequenceResource *r = 0;
- FOREACH_QML_SEQUENCE_TYPE(NEW_COPY_SEQUENCE) { /* else */ *succeeded = false; return v8::Local<v8::Object>(); }
-
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- rv->SetExternalResource(r);
- rv->SetPrototype(v8::Array::New(1)->GetPrototype());
- return rv;
-}
-#undef NEW_COPY_SEQUENCE
-
-QVariant QV8SequenceWrapper::toVariant(QV8ObjectResource *r)
-{
- Q_ASSERT(r->resourceType() == QV8ObjectResource::SequenceType);
- QV8SequenceResource *resource = static_cast<QV8SequenceResource *>(r);
- return resource->toVariant();
-}
-
-#define SEQUENCE_TO_VARIANT(ElementType, ElementTypeName, SequenceType, unused) \
- if (typeHint == qMetaTypeId<SequenceType>()) { \
- return QV8##ElementTypeName##SequenceResource::toVariant(m_engine, array, length, succeeded); \
- } else
-
-QVariant QV8SequenceWrapper::toVariant(v8::Handle<v8::Array> array, int typeHint, bool *succeeded)
-{
- *succeeded = true;
- uint32_t length = array->Length();
- FOREACH_QML_SEQUENCE_TYPE(SEQUENCE_TO_VARIANT) { /* else */ *succeeded = false; return QVariant(); }
-}
-#undef SEQUENCE_TO_VARIANT
-
-v8::Handle<v8::Value> QV8SequenceWrapper::IndexedSetter(quint32 index, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
-{
- QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
- Q_ASSERT(sr);
- return sr->indexedSetter(index, value);
-}
-
-v8::Handle<v8::Value> QV8SequenceWrapper::IndexedGetter(quint32 index, const v8::AccessorInfo &info)
-{
- QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
- Q_ASSERT(sr);
- return sr->indexedGetter(index);
-}
-
-v8::Handle<v8::Boolean> QV8SequenceWrapper::IndexedDeleter(quint32 index, const v8::AccessorInfo &info)
-{
- QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
- Q_ASSERT(sr);
- return sr->indexedDeleter(index);
-}
-
-v8::Handle<v8::Array> QV8SequenceWrapper::IndexedEnumerator(const v8::AccessorInfo &info)
-{
- QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
- Q_ASSERT(sr);
- return sr->indexedEnumerator();
-}
-
-v8::Handle<v8::Value> QV8SequenceWrapper::LengthGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
- Q_ASSERT(sr);
- return v8::Integer::NewFromUnsigned(sr->lengthGetter());
-}
-
-void QV8SequenceWrapper::LengthSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
- Q_ASSERT(sr);
- sr->lengthSetter(value);
-}
-
-v8::Handle<v8::Value> QV8SequenceWrapper::ToStringGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- return info.Data();
-}
-
-v8::Handle<v8::Value> QV8SequenceWrapper::ValueOfGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- return info.Data();
-}
-
-v8::Handle<v8::Value> QV8SequenceWrapper::ToString(const v8::Arguments &args)
-{
- QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(args.This());
- Q_ASSERT(sr);
- return sr->toString();
-}
-
-v8::Handle<v8::Value> QV8SequenceWrapper::ValueOf(const v8::Arguments &args)
-{
- QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(args.This());
- Q_ASSERT(sr);
- v8::Handle<v8::Value> tostringValue = sr->toString();
- if (!tostringValue.IsEmpty())
- return tostringValue;
- return v8::Integer::NewFromUnsigned(sr->lengthGetter());
-}
-
-v8::Handle<v8::Value> QV8SequenceWrapper::Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- Q_UNUSED(info);
- return v8::Handle<v8::Value>();
-}
-
-v8::Handle<v8::Value> QV8SequenceWrapper::Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- Q_UNUSED(info);
- return value;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8sequencewrapper_p.h b/src/declarative/qml/v8/qv8sequencewrapper_p.h
deleted file mode 100644
index fae21d0b88..0000000000
--- a/src/declarative/qml/v8/qv8sequencewrapper_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8SEQUENCEWRAPPER_P_H
-#define QV8SEQUENCEWRAPPER_P_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>
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-class QV8ObjectResource;
-class QV8SequenceWrapper
-{
-public:
- QV8SequenceWrapper();
- ~QV8SequenceWrapper();
-
- void init(QV8Engine *);
- void destroy();
-
- bool isEqual(QV8ObjectResource *lhs, const QVariant &rhs);
- bool isEqual(QV8ObjectResource *lhs, QV8ObjectResource *rhs);
- quint32 sequenceLength(QV8ObjectResource *);
-
- v8::Local<v8::Object> newSequence(int sequenceTypeId, QObject *object, int propertyIndex, bool *succeeded);
- v8::Local<v8::Object> fromVariant(const QVariant& v, bool *succeeded);
- QVariant toVariant(QV8ObjectResource *);
- QVariant toVariant(v8::Handle<v8::Array> array, int typeHint, bool *succeeded);
-
-private:
- QV8Engine *m_engine;
-
- v8::Persistent<v8::Function> m_constructor;
- v8::Persistent<v8::Function> m_toString;
- v8::Persistent<v8::Function> m_valueOf;
-
- static v8::Handle<v8::Value> IndexedGetter(quint32 index, const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> IndexedSetter(quint32 index, v8::Local<v8::Value> value, const v8::AccessorInfo &info);
- static v8::Handle<v8::Boolean> IndexedDeleter(quint32 index, const v8::AccessorInfo &info);
- static v8::Handle<v8::Array> IndexedEnumerator(const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> LengthGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
- static void LengthSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> ToStringGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> ToString(const v8::Arguments &args);
- static v8::Handle<v8::Value> ValueOfGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> ValueOf(const v8::Arguments &args);
- static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo &info);
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QV8SEQUENCEWRAPPER_P_H
diff --git a/src/declarative/qml/v8/qv8sequencewrapper_p_p.h b/src/declarative/qml/v8/qv8sequencewrapper_p_p.h
deleted file mode 100644
index 41cdcaa8b7..0000000000
--- a/src/declarative/qml/v8/qv8sequencewrapper_p_p.h
+++ /dev/null
@@ -1,503 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8SEQUENCEWRAPPER_P_P_H
-#define QV8SEQUENCEWRAPPER_P_P_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 <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativemetatype_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- \class QV8SequenceResource
- \brief The abstract base class of the external resource used in sequence type objects
-
- Every sequence type object returned by QV8SequenceWrapper::fromVariant() or
- QV8SequenceWrapper::newSequence() has a type-specific QV8SequenceResource which
- contains the type name, the meta type ids of the sequence and sequence element
- types, as well as either the sequence data (copy) or object pointer and property
- index (reference) data associated with the sequence.
- */
-class QV8SequenceResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(SequenceType);
-
-public:
- virtual ~QV8SequenceResource() {}
-
- enum ObjectType { Reference, Copy };
-
- virtual QVariant toVariant() = 0;
- virtual bool isEqual(const QV8SequenceResource *v) = 0;
-
- virtual quint32 lengthGetter() = 0;
- virtual void lengthSetter(v8::Handle<v8::Value> value) = 0;
- virtual v8::Handle<v8::Value> indexedSetter(quint32 index, v8::Handle<v8::Value> value) = 0;
- virtual v8::Handle<v8::Value> indexedGetter(quint32 index) = 0;
- virtual v8::Handle<v8::Boolean> indexedDeleter(quint32 index) = 0;
- virtual v8::Handle<v8::Array> indexedEnumerator() = 0;
- virtual v8::Handle<v8::Value> toString() = 0;
-
- ObjectType objectType;
- QByteArray typeName;
- int sequenceMetaTypeId;
- int elementMetaTypeId;
-
-protected:
- QV8SequenceResource(QV8Engine *engine, ObjectType type, const QByteArray &name, int sequenceId, int elementId)
- : QV8ObjectResource(engine), objectType(type), typeName(name), sequenceMetaTypeId(sequenceId), elementMetaTypeId(elementId)
- {
- }
-};
-
-// helper function to generate valid warnings if errors occur during sequence operations.
-static void generateWarning(QV8Engine *engine, const QString& description)
-{
- if (!engine)
- return;
- v8::Local<v8::StackTrace> currStack = v8::StackTrace::CurrentStackTrace(1);
- if (currStack.IsEmpty())
- return;
- v8::Local<v8::StackFrame> currFrame = currStack->GetFrame(0);
- if (currFrame.IsEmpty())
- return;
-
- QDeclarativeError retn;
- retn.setDescription(description);
- retn.setLine(currFrame->GetLineNumber());
- retn.setUrl(QUrl(engine->toString(currFrame->GetScriptName())));
- QDeclarativeEnginePrivate::warning(engine->engine(), retn);
-}
-
-
-static int convertV8ValueToInt(QV8Engine *, v8::Handle<v8::Value> v)
-{
- return v->Int32Value();
-}
-
-static v8::Handle<v8::Value> convertIntToV8Value(QV8Engine *, int v)
-{
- return v8::Integer::New(v);
-}
-
-static QString convertIntToString(QV8Engine *, int v)
-{
- return QString::number(v);
-}
-
-static qreal convertV8ValueToReal(QV8Engine *, v8::Handle<v8::Value> v)
-{
- return v->NumberValue();
-}
-
-static v8::Handle<v8::Value> convertRealToV8Value(QV8Engine *, qreal v)
-{
- return v8::Number::New(v);
-}
-
-static QString convertRealToString(QV8Engine *, qreal v)
-{
- return QString::number(v);
-}
-
-static bool convertV8ValueToBool(QV8Engine *, v8::Handle<v8::Value> v)
-{
- return v->BooleanValue();
-}
-
-static v8::Handle<v8::Value> convertBoolToV8Value(QV8Engine *, bool v)
-{
- return v8::Boolean::New(v);
-}
-
-static QString convertBoolToString(QV8Engine *, bool v)
-{
- if (v)
- return QLatin1String("true");
- return QLatin1String("false");
-}
-
-static QString convertV8ValueToString(QV8Engine *e, v8::Handle<v8::Value> v)
-{
- return e->toString(v->ToString());
-}
-
-static v8::Handle<v8::Value> convertStringToV8Value(QV8Engine *e, const QString &v)
-{
- return e->toString(v);
-}
-
-static QString convertStringToString(QV8Engine *, const QString &v)
-{
- return v;
-}
-
-static QString convertV8ValueToQString(QV8Engine *e, v8::Handle<v8::Value> v)
-{
- return e->toString(v->ToString());
-}
-
-static v8::Handle<v8::Value> convertQStringToV8Value(QV8Engine *e, const QString &v)
-{
- return e->toString(v);
-}
-
-static QString convertQStringToString(QV8Engine *, const QString &v)
-{
- return v;
-}
-
-static QUrl convertV8ValueToUrl(QV8Engine *e, v8::Handle<v8::Value> v)
-{
- QUrl u;
- u.setEncodedUrl(e->toString(v->ToString()).toUtf8(), QUrl::TolerantMode);
- return u;
-}
-
-static v8::Handle<v8::Value> convertUrlToV8Value(QV8Engine *e, const QUrl &v)
-{
- return e->toString(QLatin1String(v.toEncoded().data()));
-}
-
-static QString convertUrlToString(QV8Engine *, const QUrl &v)
-{
- return v.toString();
-}
-
-
-/*
- \internal
- \class QV8<Type>SequenceResource
- \brief The external resource used in sequence type objects
-
- Every sequence type object returned by QV8SequenceWrapper::newSequence() has
- a QV8<Type>SequenceResource which contains a property index and a pointer
- to the object which contains the property.
-
- Every sequence type object returned by QV8SequenceWrapper::fromVariant() has
- a QV8<Type>SequenceResource which contains a copy of the sequence value.
- Operations on the sequence are implemented directly in terms of that sequence data.
-
- There exists one QV8<Type>SequenceResource instance for every JavaScript Object
- (sequence) instance returned from QV8SequenceWrapper::newSequence() or
- QV8SequenceWrapper::fromVariant().
- */
-
-// F(elementType, elementTypeName, sequenceType, defaultValue)
-#define FOREACH_QML_SEQUENCE_TYPE(F) \
- F(int, Int, QList<int>, 0) \
- F(qreal, Real, QList<qreal>, 0.0) \
- F(bool, Bool, QList<bool>, false) \
- F(QString, String, QList<QString>, QString()) \
- F(QString, QString, QStringList, QString()) \
- F(QUrl, Url, QList<QUrl>, QUrl())
-
-#define QML_SEQUENCE_TYPE_RESOURCE(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue, ConversionToV8fn, ConversionFromV8fn, ToStringfn) \
- QT_END_NAMESPACE \
- Q_DECLARE_METATYPE(SequenceType) \
- QT_BEGIN_NAMESPACE \
- class QV8##SequenceElementTypeName##SequenceResource : public QV8SequenceResource { \
- public:\
- QV8##SequenceElementTypeName##SequenceResource(QV8Engine *engine, QObject *obj, int propIdx) \
- : QV8SequenceResource(engine, QV8SequenceResource::Reference, #SequenceType, qMetaTypeId<SequenceType>(), qMetaTypeId<SequenceElementType>()) \
- , object(obj), propertyIndex(propIdx) \
- { \
- } \
- QV8##SequenceElementTypeName##SequenceResource(QV8Engine *engine, const SequenceType &value) \
- : QV8SequenceResource(engine, QV8SequenceResource::Copy, #SequenceType, qMetaTypeId<SequenceType>(), qMetaTypeId<SequenceElementType>()) \
- , object(0), propertyIndex(-1), c(value) \
- { \
- } \
- ~QV8##SequenceElementTypeName##SequenceResource() \
- { \
- } \
- static QVariant toVariant(QV8Engine *e, v8::Handle<v8::Array> array, uint32_t length, bool *succeeded) \
- { \
- SequenceType list; \
- for (uint32_t ii = 0; ii < length; ++ii) { \
- list.append(ConversionFromV8fn(e, array->Get(ii))); \
- } \
- *succeeded = true; \
- return QVariant::fromValue<SequenceType>(list); \
- } \
- QVariant toVariant() \
- { \
- if (objectType == QV8SequenceResource::Reference) { \
- if (!object) \
- return QVariant(); \
- loadReference(); \
- } \
- return QVariant::fromValue<SequenceType>(c); \
- } \
- bool isEqual(const QV8SequenceResource *v) \
- { \
- /* Note: two different sequences can never be equal (even if they */ \
- /* contain the same elements in the same order) in order to */ \
- /* maintain JavaScript semantics. However, if they both reference */ \
- /* the same QObject+propertyIndex, they are equal. */ \
- if (objectType == QV8SequenceResource::Reference && v->objectType == QV8SequenceResource::Reference) { \
- if (sequenceMetaTypeId == v->sequenceMetaTypeId) { \
- const QV8##SequenceElementTypeName##SequenceResource *rhs = static_cast<const QV8##SequenceElementTypeName##SequenceResource *>(v); \
- return (object != 0 && object == rhs->object && propertyIndex == rhs->propertyIndex); \
- } \
- } else if (objectType == QV8SequenceResource::Copy && v->objectType == QV8SequenceResource::Copy) { \
- if (sequenceMetaTypeId == v->sequenceMetaTypeId) { \
- const QV8##SequenceElementTypeName##SequenceResource *rhs = static_cast<const QV8##SequenceElementTypeName##SequenceResource *>(v); \
- return (this == rhs); \
- } \
- } \
- return false; \
- } \
- quint32 lengthGetter() \
- { \
- if (objectType == QV8SequenceResource::Reference) { \
- if (!object) \
- return 0; \
- loadReference(); \
- } \
- return static_cast<quint32>(c.count()); \
- } \
- void lengthSetter(v8::Handle<v8::Value> value) \
- { \
- /* Get the new required length */ \
- if (value.IsEmpty() || !value->IsUint32()) \
- return; \
- quint32 newLength = value->Uint32Value(); \
- /* Qt containers have int (rather than uint) allowable indexes. */ \
- if (newLength > INT_MAX) { \
- generateWarning(engine, QLatin1String("Index out of range during length set")); \
- return; \
- } \
- /* Read the sequence from the QObject property if we're a reference */ \
- if (objectType == QV8SequenceResource::Reference) { \
- if (!object) \
- return; \
- loadReference(); \
- } \
- /* Determine whether we need to modify the sequence */ \
- qint32 newCount = static_cast<qint32>(newLength); \
- qint32 count = c.count(); \
- if (newCount == count) { \
- return; \
- } else if (newCount > count) { \
- /* according to ECMA262r3 we need to insert */ \
- /* undefined values increasing length to newLength. */ \
- /* We cannot, so we insert default-values instead. */ \
- while (newCount > count++) { \
- QT_TRY { \
- c.append(DefaultValue); \
- } QT_CATCH (std::bad_alloc &exception) { \
- generateWarning(engine, QString(QLatin1String(exception.what()) \
- + QLatin1String(" during length set"))); \
- return; /* failed; don't write back any result. */ \
- } \
- } \
- } else { \
- /* according to ECMA262r3 we need to remove */ \
- /* elements until the sequence is the required length. */ \
- while (newCount < count) { \
- count--; \
- c.removeAt(count); \
- } \
- } \
- /* write back if required. */ \
- if (objectType == QV8SequenceResource::Reference) { \
- /* write back. already checked that object is non-null, so skip that check here. */ \
- storeReference(); \
- } \
- return; \
- } \
- v8::Handle<v8::Value> indexedSetter(quint32 index, v8::Handle<v8::Value> value) \
- { \
- /* Qt containers have int (rather than uint) allowable indexes. */ \
- if (index > INT_MAX) { \
- generateWarning(engine, QLatin1String("Index out of range during indexed set")); \
- return v8::Undefined(); \
- } \
- if (objectType == QV8SequenceResource::Reference) { \
- if (!object) \
- return v8::Undefined(); \
- loadReference(); \
- } \
- /* modify the sequence */ \
- SequenceElementType elementValue = ConversionFromV8fn(engine, value); \
- qint32 count = c.count(); \
- qint32 signedIdx = static_cast<qint32>(index); \
- if (signedIdx == count) { \
- c.append(elementValue); \
- } else if (signedIdx < count) { \
- c[index] = elementValue; \
- } else { \
- /* according to ECMA262r3 we need to insert */ \
- /* the value at the given index, increasing length to index+1. */ \
- QT_TRY { \
- while (signedIdx > count++) { \
- c.append(DefaultValue); \
- } \
- c.append(elementValue); \
- } QT_CATCH (std::bad_alloc &exception) { \
- generateWarning(engine, QString(QLatin1String(exception.what()) \
- + QLatin1String(" during indexed set"))); \
- return v8::Undefined(); /* failed; don't write back any result. */ \
- } \
- } \
- /* write back. already checked that object is non-null, so skip that check here. */ \
- if (objectType == QV8SequenceResource::Reference) \
- storeReference(); \
- return value; \
- } \
- v8::Handle<v8::Value> indexedGetter(quint32 index) \
- { \
- /* Qt containers have int (rather than uint) allowable indexes. */ \
- if (index > INT_MAX) { \
- generateWarning(engine, QLatin1String("Index out of range during indexed get")); \
- return v8::Undefined(); \
- } \
- if (objectType == QV8SequenceResource::Reference) { \
- if (!object) \
- return v8::Undefined(); \
- loadReference(); \
- } \
- qint32 count = c.count(); \
- qint32 signedIdx = static_cast<qint32>(index); \
- if (signedIdx < count) \
- return ConversionToV8fn(engine, c.at(signedIdx)); \
- return v8::Undefined(); \
- } \
- v8::Handle<v8::Boolean> indexedDeleter(quint32 index) \
- { \
- /* Qt containers have int (rather than uint) allowable indexes. */ \
- if (index > INT_MAX) \
- return v8::Boolean::New(false); \
- /* Read in the sequence from the QObject */ \
- if (objectType == QV8SequenceResource::Reference) { \
- if (!object) \
- return v8::Boolean::New(false); \
- loadReference(); \
- } \
- qint32 signedIdx = static_cast<qint32>(index); \
- if (signedIdx < c.count()) { \
- /* according to ECMA262r3 it should be Undefined, */ \
- /* but we cannot, so we insert a default-value instead. */ \
- c.replace(signedIdx, DefaultValue); \
- if (objectType == QV8SequenceResource::Reference) { \
- /* write back. already checked that object is non-null, so skip that check here. */ \
- storeReference(); \
- } \
- return v8::Boolean::New(true); \
- } \
- return v8::Boolean::New(false); \
- } \
- v8::Handle<v8::Array> indexedEnumerator() \
- { \
- if (objectType == QV8SequenceResource::Reference) { \
- if (!object) \
- return v8::Handle<v8::Array>(); \
- loadReference(); \
- } \
- qint32 count = c.count(); \
- v8::Local<v8::Array> retn = v8::Array::New(count); \
- for (qint32 i = 0; i < count; ++i) { \
- retn->Set(static_cast<quint32>(i), v8::Integer::NewFromUnsigned(static_cast<quint32>(i))); \
- } \
- return retn; \
- } \
- v8::Handle<v8::Value> toString() \
- { \
- if (objectType == QV8SequenceResource::Reference) { \
- if (!object) \
- return v8::Undefined(); \
- loadReference(); \
- } \
- QString str; \
- qint32 count = c.count(); \
- for (qint32 i = 0; i < count; ++i) { \
- str += QString(QLatin1String("%1,")).arg(ToStringfn(engine, c[i])); \
- } \
- str.chop(1); \
- return engine->toString(str); \
- } \
- void loadReference() \
- { \
- Q_ASSERT(object); \
- Q_ASSERT(objectType == QV8SequenceResource::Reference); \
- void *a[] = { &c, 0 }; \
- QMetaObject::metacall(object, QMetaObject::ReadProperty, propertyIndex, a); \
- } \
- void storeReference() \
- { \
- Q_ASSERT(object); \
- Q_ASSERT(objectType == QV8SequenceResource::Reference); \
- int status = -1; \
- QDeclarativePropertyPrivate::WriteFlags flags = \
- QDeclarativePropertyPrivate::DontRemoveBinding; \
- void *a[] = { &c, 0, &status, &flags }; \
- QMetaObject::metacall(object, QMetaObject::WriteProperty, propertyIndex, a); \
- } \
- private: \
- QDeclarativeGuard<QObject> object; \
- int propertyIndex; \
- SequenceType c; \
- };
-
-#define GENERATE_QML_SEQUENCE_TYPE_RESOURCE(ElementType, ElementTypeName, SequenceType, DefaultValue) \
- QML_SEQUENCE_TYPE_RESOURCE(ElementType, ElementTypeName, SequenceType, DefaultValue, convert##ElementTypeName##ToV8Value, convertV8ValueTo##ElementTypeName, convert##ElementTypeName##ToString)
-
-FOREACH_QML_SEQUENCE_TYPE(GENERATE_QML_SEQUENCE_TYPE_RESOURCE)
-#undef GENERATE_QML_SEQUENCE_TYPE_RESOURCE
-#undef QML_SEQUENCE_TYPE_RESOURCE
-
-QT_END_NAMESPACE
-
-#endif // QV8SEQUENCEWRAPPER_P_P_H
diff --git a/src/declarative/qml/v8/qv8sqlerrors.cpp b/src/declarative/qml/v8/qv8sqlerrors.cpp
deleted file mode 100644
index f5e868650e..0000000000
--- a/src/declarative/qml/v8/qv8sqlerrors.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8sqlerrors_p.h"
-#include "qv8engine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-void qt_add_sqlexceptions(QV8Engine *engine)
-{
- // SQL Exception
- v8::PropertyAttribute attributes = (v8::PropertyAttribute)(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
-
- v8::Local<v8::Object> sqlexception = v8::Object::New();
- sqlexception->Set(v8::String::New("UNKNOWN_ERR"), v8::Integer::New(SQLEXCEPTION_UNKNOWN_ERR), attributes);
- sqlexception->Set(v8::String::New("DATABASE_ERR"), v8::Integer::New(SQLEXCEPTION_DATABASE_ERR), attributes);
- sqlexception->Set(v8::String::New("VERSION_ERR"), v8::Integer::New(SQLEXCEPTION_VERSION_ERR), attributes);
- sqlexception->Set(v8::String::New("TOO_LARGE_ERR"), v8::Integer::New(SQLEXCEPTION_TOO_LARGE_ERR), attributes);
- sqlexception->Set(v8::String::New("QUOTA_ERR"), v8::Integer::New(SQLEXCEPTION_QUOTA_ERR), attributes);
- sqlexception->Set(v8::String::New("SYNTAX_ERR"), v8::Integer::New(SQLEXCEPTION_SYNTAX_ERR), attributes);
- sqlexception->Set(v8::String::New("CONSTRAINT_ERR"), v8::Integer::New(SQLEXCEPTION_CONSTRAINT_ERR), attributes);
- sqlexception->Set(v8::String::New("TIMEOUT_ERR"), v8::Integer::New(SQLEXCEPTION_TIMEOUT_ERR), attributes);
- engine->global()->Set(v8::String::New("SQLException"), sqlexception);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8sqlerrors_p.h b/src/declarative/qml/v8/qv8sqlerrors_p.h
deleted file mode 100644
index 8f4668cedd..0000000000
--- a/src/declarative/qml/v8/qv8sqlerrors_p.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8SQLERRORS_P_H
-#define QV8SQLERRORS_P_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>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-#define SQLEXCEPTION_UNKNOWN_ERR 1
-#define SQLEXCEPTION_DATABASE_ERR 2
-#define SQLEXCEPTION_VERSION_ERR 3
-#define SQLEXCEPTION_TOO_LARGE_ERR 4
-#define SQLEXCEPTION_QUOTA_ERR 5
-#define SQLEXCEPTION_SYNTAX_ERR 6
-#define SQLEXCEPTION_CONSTRAINT_ERR 7
-#define SQLEXCEPTION_TIMEOUT_ERR 8
-
-class QV8Engine;
-void qt_add_sqlexceptions(QV8Engine *engine);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QV8SQLERRORS_P_H
diff --git a/src/declarative/qml/v8/qv8stringwrapper.cpp b/src/declarative/qml/v8/qv8stringwrapper.cpp
deleted file mode 100644
index bff932150d..0000000000
--- a/src/declarative/qml/v8/qv8stringwrapper.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8stringwrapper_p.h"
-#include "qjsconverter_p.h"
-#include "qjsconverter_impl_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QV8StringWrapper::QV8StringWrapper()
-{
-}
-
-QV8StringWrapper::~QV8StringWrapper()
-{
-}
-
-void QV8StringWrapper::init()
-{
-}
-
-void QV8StringWrapper::destroy()
-{
-}
-
-v8::Local<v8::String> QV8StringWrapper::toString(const QString &qstr)
-{
- return QJSConverter::toString(qstr);
-}
-
-QString QV8StringWrapper::toString(v8::Handle<v8::String> jsstr)
-{
- if (jsstr.IsEmpty()) {
- return QString();
- } else {
- return QJSConverter::toString(jsstr);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8stringwrapper_p.h b/src/declarative/qml/v8/qv8stringwrapper_p.h
deleted file mode 100644
index 89fd5448d7..0000000000
--- a/src/declarative/qml/v8/qv8stringwrapper_p.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEV8STRINGWRAPPER_P_H
-#define QDECLARATIVEV8STRINGWRAPPER_P_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/qstring.h>
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_DECLARATIVE_EXPORT QV8StringWrapper
-{
-public:
- QV8StringWrapper();
- ~QV8StringWrapper();
-
- void init();
- void destroy();
-
- v8::Local<v8::String> toString(const QString &);
- QString toString(v8::Handle<v8::String>);
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEV8STRINGWRAPPER_P_H
diff --git a/src/declarative/qml/v8/qv8typewrapper.cpp b/src/declarative/qml/v8/qv8typewrapper.cpp
deleted file mode 100644
index d9060be309..0000000000
--- a/src/declarative/qml/v8/qv8typewrapper.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8contextwrapper_p.h"
-#include "qv8engine_p.h"
-
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativecontext_p.h>
-
-#include <private/qjsvalue_p.h>
-#include <private/qscript_impl_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8TypeResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(TypeType);
-
-public:
- QV8TypeResource(QV8Engine *engine);
- virtual ~QV8TypeResource();
-
- QV8TypeWrapper::TypeNameMode mode;
-
- QDeclarativeGuard<QObject> object;
-
- QDeclarativeType *type;
- QDeclarativeTypeNameCache *typeNamespace;
- const void *importNamespace;
-};
-
-QV8TypeResource::QV8TypeResource(QV8Engine *engine)
-: QV8ObjectResource(engine), mode(QV8TypeWrapper::IncludeEnums), type(0), typeNamespace(0), importNamespace(0)
-{
-}
-
-QV8TypeResource::~QV8TypeResource()
-{
- if (typeNamespace) typeNamespace->release();
-}
-
-QV8TypeWrapper::QV8TypeWrapper()
-: m_engine(0)
-{
-}
-
-QV8TypeWrapper::~QV8TypeWrapper()
-{
-}
-
-void QV8TypeWrapper::destroy()
-{
- qPersistentDispose(m_constructor);
-}
-
-void QV8TypeWrapper::init(QV8Engine *engine)
-{
- m_engine = engine;
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetNamedPropertyHandler(Getter, Setter);
- ft->InstanceTemplate()->SetHasExternalResource(true);
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
-}
-
-// Returns a type wrapper for type t on o. This allows access of enums, and attached properties.
-v8::Local<v8::Object> QV8TypeWrapper::newObject(QObject *o, QDeclarativeType *t, TypeNameMode mode)
-{
- Q_ASSERT(t);
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- QV8TypeResource *r = new QV8TypeResource(m_engine);
- r->mode = mode; r->object = o; r->type = t;
- rv->SetExternalResource(r);
- return rv;
-}
-
-// Returns a type wrapper for importNamespace (of t) on o. This allows nested resolution of a type in a
-// namespace.
-v8::Local<v8::Object> QV8TypeWrapper::newObject(QObject *o, QDeclarativeTypeNameCache *t,
- const void *importNamespace, TypeNameMode mode)
-{
- Q_ASSERT(t);
- Q_ASSERT(importNamespace);
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- QV8TypeResource *r = new QV8TypeResource(m_engine);
- t->addref();
- r->mode = mode; r->object = o; r->typeNamespace = t; r->importNamespace = importNamespace;
- rv->SetExternalResource(r);
- return rv;
-}
-
-QVariant QV8TypeWrapper::toVariant(QV8ObjectResource *r)
-{
- Q_ASSERT(r->resourceType() == QV8ObjectResource::TypeType);
- QV8TypeResource *resource = static_cast<QV8TypeResource *>(r);
- QV8Engine *v8engine = resource->engine;
-
- if (resource->typeNamespace) {
- if (QDeclarativeMetaType::ModuleApiInstance *moduleApi = resource->typeNamespace->moduleApi(resource->importNamespace)) {
- if (moduleApi->scriptCallback) {
- moduleApi->scriptApi = moduleApi->scriptCallback(v8engine->engine(), v8engine->engine());
- moduleApi->scriptCallback = 0;
- moduleApi->qobjectCallback = 0;
- } else if (moduleApi->qobjectCallback) {
- moduleApi->qobjectApi = moduleApi->qobjectCallback(v8engine->engine(), v8engine->engine());
- moduleApi->scriptCallback = 0;
- moduleApi->qobjectCallback = 0;
- }
-
- if (moduleApi->qobjectApi) {
- return QVariant::fromValue<QObject*>(moduleApi->qobjectApi);
- }
- }
- }
-
- // only QObject Module API can be converted to a variant.
- return QVariant();
-}
-
-v8::Handle<v8::Value> QV8TypeWrapper::Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- QV8TypeResource *resource = v8_resource_cast<QV8TypeResource>(info.This());
-
- if (!resource)
- return v8::Undefined();
-
- QV8Engine *v8engine = resource->engine;
- QObject *object = resource->object;
-
- QHashedV8String propertystring(property);
-
- if (resource->type) {
- QDeclarativeType *type = resource->type;
-
- if (QV8Engine::startsWithUpper(property)) {
- int value = type->enumValue(propertystring);
- if (-1 != value)
- return v8::Integer::New(value);
-
- // Fall through to return empty handle
-
- } else if (resource->object) {
- QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
- if (ao)
- return v8engine->qobjectWrapper()->getProperty(ao, propertystring,
- QV8QObjectWrapper::IgnoreRevision);
-
- // Fall through to return empty handle
- }
-
- // Fall through to return empty handle
-
- } else if (resource->typeNamespace) {
- Q_ASSERT(resource->importNamespace);
- QDeclarativeTypeNameCache::Result r = resource->typeNamespace->query(propertystring,
- resource->importNamespace);
-
- if (r.isValid()) {
- if (r.type) {
- return v8engine->typeWrapper()->newObject(object, r.type, resource->mode);
- } else if (r.scriptIndex != -1) {
- int index = r.scriptIndex;
- QDeclarativeContextData *context = v8engine->callingContext();
- if (index < context->importedScripts.count())
- return context->importedScripts.at(index);
- }
-
- return v8::Undefined();
- } else if (QDeclarativeMetaType::ModuleApiInstance *moduleApi = resource->typeNamespace->moduleApi(resource->importNamespace)) {
-
- if (moduleApi->scriptCallback) {
- moduleApi->scriptApi = moduleApi->scriptCallback(v8engine->engine(), v8engine->engine());
- moduleApi->scriptCallback = 0;
- moduleApi->qobjectCallback = 0;
- } else if (moduleApi->qobjectCallback) {
- moduleApi->qobjectApi = moduleApi->qobjectCallback(v8engine->engine(), v8engine->engine());
- moduleApi->scriptCallback = 0;
- moduleApi->qobjectCallback = 0;
- }
-
- if (moduleApi->qobjectApi) {
- // check for enum value
- if (QV8Engine::startsWithUpper(property)) {
- if (resource->mode == IncludeEnums) {
- QString name = v8engine->toString(property);
-
- // ### Optimize
- QByteArray enumName = name.toUtf8();
- const QMetaObject *metaObject = moduleApi->qobjectApi->metaObject();
- for (int ii = metaObject->enumeratorCount() - 1; ii >= 0; --ii) {
- QMetaEnum e = metaObject->enumerator(ii);
- bool ok;
- int value = e.keyToValue(enumName.constData(), &ok);
- if (ok)
- return v8::Integer::New(value);
- }
- }
- }
-
- // check for property.
- v8::Handle<v8::Value> rv = v8engine->qobjectWrapper()->getProperty(moduleApi->qobjectApi, propertystring, QV8QObjectWrapper::IgnoreRevision);
- return rv;
- } else if (!moduleApi->scriptApi.isUndefined()) {
- // NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable.
- QJSValuePrivate *apiprivate = QJSValuePrivate::get(moduleApi->scriptApi);
- QScopedPointer<QJSValuePrivate> propertyValue(apiprivate->property(property).give());
- return propertyValue->asV8Value(v8engine);
- } else {
- return v8::Handle<v8::Value>();
- }
- }
-
- // Fall through to return empty handle
-
- } else {
- Q_ASSERT(!"Unreachable");
- }
-
- return v8::Handle<v8::Value>();
-}
-
-v8::Handle<v8::Value> QV8TypeWrapper::Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info)
-{
- QV8TypeResource *resource = v8_resource_cast<QV8TypeResource>(info.This());
-
- if (!resource)
- return value;
-
- QV8Engine *v8engine = resource->engine;
-
- QHashedV8String propertystring(property);
-
- if (resource->type && resource->object) {
- QDeclarativeType *type = resource->type;
- QObject *object = resource->object;
- QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
- if (ao)
- v8engine->qobjectWrapper()->setProperty(ao, propertystring, value,
- QV8QObjectWrapper::IgnoreRevision);
- } else if (resource->typeNamespace) {
- if (QDeclarativeMetaType::ModuleApiInstance *moduleApi = resource->typeNamespace->moduleApi(resource->importNamespace)) {
- if (moduleApi->scriptCallback) {
- moduleApi->scriptApi = moduleApi->scriptCallback(v8engine->engine(), v8engine->engine());
- moduleApi->scriptCallback = 0;
- moduleApi->qobjectCallback = 0;
- } else if (moduleApi->qobjectCallback) {
- moduleApi->qobjectApi = moduleApi->qobjectCallback(v8engine->engine(), v8engine->engine());
- moduleApi->scriptCallback = 0;
- moduleApi->qobjectCallback = 0;
- }
-
- if (moduleApi->qobjectApi) {
- v8engine->qobjectWrapper()->setProperty(moduleApi->qobjectApi, propertystring, value,
- QV8QObjectWrapper::IgnoreRevision);
- } else if (!moduleApi->scriptApi.isUndefined()) {
- QScopedPointer<QJSValuePrivate> setvalp(new QJSValuePrivate(v8engine, value));
- QJSValuePrivate *apiprivate = QJSValuePrivate::get(moduleApi->scriptApi);
- if (apiprivate->propertyFlags(property) & QJSValuePrivate::ReadOnly) {
- QString error = QLatin1String("Cannot assign to read-only property \"") +
- v8engine->toString(property) + QLatin1Char('\"');
- v8::ThrowException(v8::Exception::Error(v8engine->toString(error)));
- } else {
- apiprivate->setProperty(property, setvalp.data());
- }
- }
- }
- }
-
- return value;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8typewrapper_p.h b/src/declarative/qml/v8/qv8typewrapper_p.h
deleted file mode 100644
index d30dbfbc24..0000000000
--- a/src/declarative/qml/v8/qv8typewrapper_p.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8TYPEWRAPPER_P_H
-#define QV8TYPEWRAPPER_P_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 <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-class QV8Engine;
-class QDeclarativeType;
-class QDeclarativeTypeNameCache;
-class QV8TypeWrapper
-{
-public:
- QV8TypeWrapper();
- ~QV8TypeWrapper();
-
- void init(QV8Engine *);
- void destroy();
-
- enum TypeNameMode { IncludeEnums, ExcludeEnums };
- v8::Local<v8::Object> newObject(QObject *, QDeclarativeType *, TypeNameMode = IncludeEnums);
- v8::Local<v8::Object> newObject(QObject *, QDeclarativeTypeNameCache *, const void *,
- TypeNameMode = IncludeEnums);
- QVariant toVariant(QV8ObjectResource *);
-
-private:
- static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info);
-
- QV8Engine *m_engine;
- v8::Persistent<v8::Function> m_constructor;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV8TYPEWRAPPER_P_H
-
diff --git a/src/declarative/qml/v8/qv8valuetypewrapper.cpp b/src/declarative/qml/v8/qv8valuetypewrapper.cpp
deleted file mode 100644
index 7da3d8a2dc..0000000000
--- a/src/declarative/qml/v8/qv8valuetypewrapper.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8valuetypewrapper_p.h"
-#include "qv8engine_p.h"
-
-#include <private/qdeclarativevaluetype_p.h>
-#include <private/qdeclarativebinding_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8ValueTypeResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(ValueTypeType);
-
-public:
- enum ObjectType { Reference, Copy };
-
- QV8ValueTypeResource(QV8Engine *engine, ObjectType objectType);
-
- ObjectType objectType;
- QDeclarativeValueType *type;
-};
-
-class QV8ValueTypeReferenceResource : public QV8ValueTypeResource
-{
-public:
- QV8ValueTypeReferenceResource(QV8Engine *engine);
-
- QDeclarativeGuard<QObject> object;
- int property;
-};
-
-class QV8ValueTypeCopyResource : public QV8ValueTypeResource
-{
-public:
- QV8ValueTypeCopyResource(QV8Engine *engine);
-
- QVariant value;
-};
-
-QV8ValueTypeResource::QV8ValueTypeResource(QV8Engine *engine, ObjectType objectType)
-: QV8ObjectResource(engine), objectType(objectType)
-{
-}
-
-QV8ValueTypeReferenceResource::QV8ValueTypeReferenceResource(QV8Engine *engine)
-: QV8ValueTypeResource(engine, Reference)
-{
-}
-
-QV8ValueTypeCopyResource::QV8ValueTypeCopyResource(QV8Engine *engine)
-: QV8ValueTypeResource(engine, Copy)
-{
-}
-
-QV8ValueTypeWrapper::QV8ValueTypeWrapper()
-: m_engine(0)
-{
-}
-
-QV8ValueTypeWrapper::~QV8ValueTypeWrapper()
-{
-}
-
-void QV8ValueTypeWrapper::destroy()
-{
- qPersistentDispose(m_toString);
- qPersistentDispose(m_constructor);
- qPersistentDispose(m_toStringSymbol);
-}
-
-static quint32 toStringHash = -1;
-
-void QV8ValueTypeWrapper::init(QV8Engine *engine)
-{
- m_engine = engine;
- m_toString = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ToString)->GetFunction());
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetNamedPropertyHandler(Getter, Setter);
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
- ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
- m_toString, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
-
- m_toStringSymbol = qPersistentNew<v8::String>(v8::String::NewSymbol("toString"));
- m_toStringString = QHashedV8String(m_toStringSymbol);
- toStringHash = m_toStringString.hash();
-}
-
-v8::Local<v8::Object> QV8ValueTypeWrapper::newValueType(QObject *object, int property, QDeclarativeValueType *type)
-{
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- QV8ValueTypeReferenceResource *r = new QV8ValueTypeReferenceResource(m_engine);
- r->type = type; r->object = object; r->property = property;
- rv->SetExternalResource(r);
- return rv;
-}
-
-v8::Local<v8::Object> QV8ValueTypeWrapper::newValueType(const QVariant &value, QDeclarativeValueType *type)
-{
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv = m_constructor->NewInstance();
- QV8ValueTypeCopyResource *r = new QV8ValueTypeCopyResource(m_engine);
- r->type = type; r->value = value;
- rv->SetExternalResource(r);
- return rv;
-}
-
-QVariant QV8ValueTypeWrapper::toVariant(v8::Handle<v8::Object> obj)
-{
- QV8ValueTypeResource *r = v8_resource_cast<QV8ValueTypeResource>(obj);
- if (r) return toVariant(r);
- else return QVariant();
-}
-
-QVariant QV8ValueTypeWrapper::toVariant(QV8ObjectResource *r)
-{
- Q_ASSERT(r->resourceType() == QV8ObjectResource::ValueTypeType);
- QV8ValueTypeResource *resource = static_cast<QV8ValueTypeResource *>(r);
-
- if (resource->objectType == QV8ValueTypeResource::Reference) {
- QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(resource);
-
- if (reference->object) {
- reference->type->read(reference->object, reference->property);
- return reference->type->value();
- } else {
- return QVariant();
- }
-
- } else {
- Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
-
- QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
-
- return copy->value;
- }
-}
-
-bool QV8ValueTypeWrapper::isEqual(QV8ObjectResource *r, const QVariant& value)
-{
- Q_ASSERT(r->resourceType() == QV8ObjectResource::ValueTypeType);
- QV8ValueTypeResource *resource = static_cast<QV8ValueTypeResource *>(r);
-
- if (resource->objectType == QV8ValueTypeResource::Reference) {
- QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(resource);
- if (reference->object) {
- reference->type->read(reference->object, reference->property);
- return reference->type->isEqual(value);
- } else {
- return false;
- }
- } else {
- Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
- QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
- return (value == copy->value);
- }
-}
-
-v8::Handle<v8::Value> QV8ValueTypeWrapper::ToStringGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- return info.Data();
-}
-
-v8::Handle<v8::Value> QV8ValueTypeWrapper::ToString(const v8::Arguments &args)
-{
- QV8ValueTypeResource *resource = v8_resource_cast<QV8ValueTypeResource>(args.This());
- if (resource) {
- if (resource->objectType == QV8ValueTypeResource::Reference) {
- QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(resource);
- if (reference->object) {
- reference->type->read(reference->object, reference->property);
- return resource->engine->toString(resource->type->toString());
- } else {
- return v8::Undefined();
- }
- } else {
- Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
- QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
- QString result = copy->value.toString();
- if (result.isEmpty() && !copy->value.canConvert(QVariant::String)) {
- result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(copy->value.typeName()));
- }
- return resource->engine->toString(result);
- }
- } else {
- return v8::Undefined();
- }
-}
-
-v8::Handle<v8::Value> QV8ValueTypeWrapper::Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- QV8ValueTypeResource *r = v8_resource_cast<QV8ValueTypeResource>(info.This());
- if (!r) return v8::Handle<v8::Value>();
-
- QHashedV8String propertystring(property);
-
- {
- // Comparing the hash first actually makes a measurable difference here, at least on x86
- quint32 hash = propertystring.hash();
- if (hash == toStringHash &&
- r->engine->valueTypeWrapper()->m_toStringString == propertystring) {
- return r->engine->valueTypeWrapper()->m_toString;
- }
- }
-
- QDeclarativePropertyData local;
- QDeclarativePropertyData *result = 0;
- {
- QDeclarativeData *ddata = QDeclarativeData::get(r->type, false);
- if (ddata && ddata->propertyCache)
- result = ddata->propertyCache->property(propertystring);
- else
- result = QDeclarativePropertyCache::property(r->engine->engine(), r->type,
- propertystring, local);
- }
-
- if (!result)
- return v8::Handle<v8::Value>();
-
- if (r->objectType == QV8ValueTypeResource::Reference) {
- QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(r);
-
- if (!reference->object)
- return v8::Handle<v8::Value>();
-
- r->type->read(reference->object, reference->property);
- } else {
- Q_ASSERT(r->objectType == QV8ValueTypeResource::Copy);
-
- QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(r);
-
- r->type->setValue(copy->value);
- }
-
-#define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \
- if (result->propType == metatype) { \
- cpptype v; \
- void *args[] = { &v, 0 }; \
- r->type->qt_metacall(QMetaObject::ReadProperty, result->coreIndex, args); \
- return constructor(v); \
- }
-
- // These four types are the most common used by the value type wrappers
- VALUE_TYPE_LOAD(QMetaType::QReal, qreal, v8::Number::New);
- VALUE_TYPE_LOAD(QMetaType::Int, int, v8::Integer::New);
- VALUE_TYPE_LOAD(QMetaType::QString, QString, r->engine->toString);
- VALUE_TYPE_LOAD(QMetaType::Bool, bool, v8::Boolean::New);
-
- QVariant v(result->propType, (void *)0);
- void *args[] = { v.data(), 0 };
- r->type->qt_metacall(QMetaObject::ReadProperty, result->coreIndex, args);
- return r->engine->fromVariant(v);
-#undef VALUE_TYPE_ACCESSOR
-}
-
-v8::Handle<v8::Value> QV8ValueTypeWrapper::Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info)
-{
- QV8ValueTypeResource *r = v8_resource_cast<QV8ValueTypeResource>(info.This());
- if (!r) return value;
-
- QByteArray propName = r->engine->toString(property).toUtf8();
- int index = r->type->metaObject()->indexOfProperty(propName.constData());
- if (index == -1)
- return value;
-
- if (r->objectType == QV8ValueTypeResource::Reference) {
- QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(r);
-
- if (!reference->object ||
- !reference->object->metaObject()->property(reference->property).isWritable())
- return value;
-
- r->type->read(reference->object, reference->property);
- QMetaProperty p = r->type->metaObject()->property(index);
-
- QDeclarativeBinding *newBinding = 0;
-
- if (value->IsFunction()) {
- QDeclarativeContextData *context = r->engine->callingContext();
- v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
-
- QDeclarativePropertyData cacheData;
- cacheData.setFlags(QDeclarativePropertyData::IsWritable |
- QDeclarativePropertyData::IsValueTypeVirtual);
- cacheData.propType = reference->object->metaObject()->property(reference->property).userType();
- cacheData.coreIndex = reference->property;
- cacheData.valueTypeFlags = 0;
- cacheData.valueTypeCoreIndex = index;
- cacheData.valueTypePropType = p.userType();
-
- v8::Local<v8::StackTrace> trace =
- v8::StackTrace::CurrentStackTrace(1,
- (v8::StackTrace::StackTraceOptions)(v8::StackTrace::kLineNumber |
- v8::StackTrace::kScriptName));
- v8::Local<v8::StackFrame> frame = trace->GetFrame(0);
- int lineNumber = frame->GetLineNumber();
- int columnNumber = frame->GetColumn();
- QString url = r->engine->toString(frame->GetScriptName());
-
- newBinding = new QDeclarativeBinding(&function, reference->object, context);
- newBinding->setSourceLocation(url, lineNumber, columnNumber);
- newBinding->setTarget(reference->object, cacheData, context);
- newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
- QDeclarativeBinding::RequiresThisObject);
- }
-
- QDeclarativeAbstractBinding *oldBinding =
- QDeclarativePropertyPrivate::setBinding(reference->object, reference->property, index, newBinding);
- if (oldBinding)
- oldBinding->destroy();
-
- if (!value->IsFunction()) {
- QVariant v = r->engine->toVariant(value, -1);
-
- if (p.isEnumType() && (QMetaType::Type)v.type() == QMetaType::Double)
- v = v.toInt();
-
- p.write(reference->type, v);
-
- reference->type->write(reference->object, reference->property, 0);
- }
-
- } else {
- Q_ASSERT(r->objectType == QV8ValueTypeResource::Copy);
-
- QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(r);
-
- QVariant v = r->engine->toVariant(value, -1);
-
- r->type->setValue(copy->value);
- QMetaProperty p = r->type->metaObject()->property(index);
- p.write(r->type, v);
- copy->value = r->type->value();
- }
-
- return value;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8valuetypewrapper_p.h b/src/declarative/qml/v8/qv8valuetypewrapper_p.h
deleted file mode 100644
index 09f6e7def3..0000000000
--- a/src/declarative/qml/v8/qv8valuetypewrapper_p.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8VALUETYPEWRAPPER_P_H
-#define QV8VALUETYPEWRAPPER_P_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 <QtDeclarative/qdeclarativelist.h>
-#include <private/qv8_p.h>
-#include <private/qhashedstring_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-class QV8ObjectResource;
-class QDeclarativeValueType;
-class QV8ValueTypeWrapper
-{
-public:
- QV8ValueTypeWrapper();
- ~QV8ValueTypeWrapper();
-
- void init(QV8Engine *);
- void destroy();
-
- v8::Local<v8::Object> newValueType(QObject *, int, QDeclarativeValueType *);
- v8::Local<v8::Object> newValueType(const QVariant &, QDeclarativeValueType *);
-
- QVariant toVariant(v8::Handle<v8::Object>);
- QVariant toVariant(QV8ObjectResource *);
-
- static bool isEqual(QV8ObjectResource *, const QVariant& value);
-
-private:
- static v8::Handle<v8::Value> ToStringGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> ToString(const v8::Arguments &args);
- static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info);
-
- QV8Engine *m_engine;
- v8::Persistent<v8::Function> m_constructor;
- v8::Persistent<v8::Function> m_toString;
- v8::Persistent<v8::String> m_toStringSymbol;
- QHashedV8String m_toStringString;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV8VALUETYPEWRAPPER_P_H
-
-
diff --git a/src/declarative/qml/v8/qv8variantresource_p.h b/src/declarative/qml/v8/qv8variantresource_p.h
deleted file mode 100644
index dd8664ff15..0000000000
--- a/src/declarative/qml/v8/qv8variantresource_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8VARIANTRESOURCE_P_H
-#define QV8VARIANTRESOURCE_P_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 <private/qv8_p.h>
-#include <private/qv8engine_p.h>
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8VariantResource : public QV8ObjectResource,
- public QDeclarativeEnginePrivate::ScarceResourceData
-{
- V8_RESOURCE_TYPE(VariantType)
-
-public:
- QV8VariantResource(QV8Engine *engine, const QVariant &data);
-
- void addVmePropertyReference();
- void removeVmePropertyReference();
-
- bool m_isScarceResource;
- int m_vmePropertyReferenceCount;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV8VARIANTRESOURCE_P_H
-
diff --git a/src/declarative/qml/v8/qv8variantwrapper.cpp b/src/declarative/qml/v8/qv8variantwrapper.cpp
deleted file mode 100644
index cd9d09e451..0000000000
--- a/src/declarative/qml/v8/qv8variantwrapper.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8variantwrapper_p.h"
-#include "qv8variantresource_p.h"
-#include "qv8engine_p.h"
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QV8VariantResource::QV8VariantResource(QV8Engine *engine, const QVariant &data)
-: QV8ObjectResource(engine), QDeclarativeEnginePrivate::ScarceResourceData(data), m_isScarceResource(false), m_vmePropertyReferenceCount(0)
-{
-}
-
-void QV8VariantResource::addVmePropertyReference()
-{
- if (m_isScarceResource && ++m_vmePropertyReferenceCount == 1) {
- // remove from the ep->scarceResources list
- // since it is now no longer eligible to be
- // released automatically by the engine.
- node.remove();
- }
-}
-
-void QV8VariantResource::removeVmePropertyReference()
-{
- if (m_isScarceResource && --m_vmePropertyReferenceCount == 0) {
- // and add to the ep->scarceResources list
- // since it is now eligible to be released
- // automatically by the engine.
- QDeclarativeEnginePrivate::get(engine->engine())->scarceResources.insert(this);
- }
-}
-
-QV8VariantWrapper::QV8VariantWrapper()
-: m_engine(0)
-{
-}
-
-QV8VariantWrapper::~QV8VariantWrapper()
-{
-}
-
-void QV8VariantWrapper::init(QV8Engine *engine)
-{
- m_engine = engine;
- m_toString = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ToString)->GetFunction());
- m_valueOf = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ValueOf)->GetFunction());
-
- {
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
- ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
- m_toString, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("valueOf"), ValueOfGetter, 0,
- m_valueOf, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
- }
- {
- m_preserve = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(Preserve)->GetFunction());
- m_destroy = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(Destroy)->GetFunction());
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
- ft->InstanceTemplate()->SetAccessor(v8::String::New("preserve"), PreserveGetter, 0,
- m_preserve, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("destroy"), DestroyGetter, 0,
- m_destroy, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
- m_toString, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("valueOf"), ValueOfGetter, 0,
- m_valueOf, v8::DEFAULT,
- v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
- m_scarceConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
- }
-
-}
-
-void QV8VariantWrapper::destroy()
-{
- qPersistentDispose(m_valueOf);
- qPersistentDispose(m_toString);
- qPersistentDispose(m_destroy);
- qPersistentDispose(m_preserve);
- qPersistentDispose(m_scarceConstructor);
- qPersistentDispose(m_constructor);
-}
-
-v8::Local<v8::Object> QV8VariantWrapper::newVariant(const QVariant &value)
-{
- bool scarceResource = value.type() == QVariant::Pixmap ||
- value.type() == QVariant::Image;
-
- // XXX NewInstance() should be optimized
- v8::Local<v8::Object> rv;
- QV8VariantResource *r = new QV8VariantResource(m_engine, value);
-
- if (scarceResource) {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(m_engine->engine());
- Q_ASSERT(ep->scarceResourcesRefCount);
- rv = m_scarceConstructor->NewInstance();
- r->m_isScarceResource = true;
- ep->scarceResources.insert(r);
- } else {
- rv = m_constructor->NewInstance();
- }
-
- rv->SetExternalResource(r);
- return rv;
-}
-
-bool QV8VariantWrapper::isVariant(v8::Handle<v8::Value> value)
-{
- return value->IsObject() && v8_resource_cast<QV8VariantResource>(value->ToObject());
-}
-
-QVariant QV8VariantWrapper::toVariant(v8::Handle<v8::Object> obj)
-{
- QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(obj);
- return r?r->data:QVariant();
-}
-
-QVariant QV8VariantWrapper::toVariant(QV8ObjectResource *r)
-{
- Q_ASSERT(r->resourceType() == QV8ObjectResource::VariantType);
- return static_cast<QV8VariantResource *>(r)->data;
-}
-
-QVariant &QV8VariantWrapper::variantValue(v8::Handle<v8::Value> value)
-{
- Q_ASSERT(isVariant(value));
- QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(value->ToObject());
- return static_cast<QV8VariantResource *>(r)->data;
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::Getter(v8::Local<v8::String> /* property */,
- const v8::AccessorInfo & /* info */)
-{
- return v8::Handle<v8::Value>();
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::Setter(v8::Local<v8::String> /* property */,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo & /* info */)
-{
- return value;
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::PreserveGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- return info.Data();
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::DestroyGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- return info.Data();
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::ToStringGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- return info.Data();
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::ValueOfGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
-{
- Q_UNUSED(property);
- return info.Data();
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::Preserve(const v8::Arguments &args)
-{
- QV8VariantResource *resource = v8_resource_cast<QV8VariantResource>(args.This());
- if (resource) {
- resource->node.remove();
- }
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::Destroy(const v8::Arguments &args)
-{
- QV8VariantResource *resource = v8_resource_cast<QV8VariantResource>(args.This());
- if (resource) {
- resource->data = QVariant();
- resource->node.remove();
- }
- return v8::Undefined();
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::ToString(const v8::Arguments &args)
-{
- QV8VariantResource *resource = v8_resource_cast<QV8VariantResource>(args.This());
- if (resource) {
- QString result = resource->data.toString();
- if (result.isEmpty() && !resource->data.canConvert(QVariant::String))
- result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(resource->data.typeName()));
- return resource->engine->toString(result);
- } else {
- return v8::Undefined();
- }
-}
-
-v8::Handle<v8::Value> QV8VariantWrapper::ValueOf(const v8::Arguments &args)
-{
- QV8VariantResource *resource = v8_resource_cast<QV8VariantResource>(args.This());
- if (resource) {
- QVariant v = resource->data;
- switch (v.type()) {
- case QVariant::Invalid:
- return v8::Undefined();
- case QVariant::String:
- return resource->engine->toString(v.toString());
- case QVariant::Int:
- case QVariant::Double:
- case QVariant::UInt:
- return v8::Number::New(v.toDouble());
- case QVariant::Bool:
- return v8::Boolean::New(v.toBool());
- default:
- break;
- }
- }
- return args.This();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/v8/qv8variantwrapper_p.h b/src/declarative/qml/v8/qv8variantwrapper_p.h
deleted file mode 100644
index 578acf01c8..0000000000
--- a/src/declarative/qml/v8/qv8variantwrapper_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8VARIANTWRAPPER_P_H
-#define QV8VARIANTWRAPPER_P_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 <QtDeclarative/qdeclarativelist.h>
-#include <private/qv8_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QV8Engine;
-class QV8ObjectResource;
-class QV8VariantWrapper
-{
-public:
- QV8VariantWrapper();
- ~QV8VariantWrapper();
-
- void init(QV8Engine *);
- void destroy();
-
- v8::Local<v8::Object> newVariant(const QVariant &);
- bool isVariant(v8::Handle<v8::Value>);
- static QVariant toVariant(v8::Handle<v8::Object>);
- static QVariant toVariant(QV8ObjectResource *);
- QVariant &variantValue(v8::Handle<v8::Value>);
-
-private:
- static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> PreserveGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> DestroyGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> ToStringGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> ValueOfGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info);
- static v8::Handle<v8::Value> Preserve(const v8::Arguments &args);
- static v8::Handle<v8::Value> Destroy(const v8::Arguments &args);
- static v8::Handle<v8::Value> ToString(const v8::Arguments &args);
- static v8::Handle<v8::Value> ValueOf(const v8::Arguments &args);
-
- QV8Engine *m_engine;
- v8::Persistent<v8::Function> m_constructor;
- v8::Persistent<v8::Function> m_scarceConstructor;
- v8::Persistent<v8::Function> m_preserve;
- v8::Persistent<v8::Function> m_destroy;
- v8::Persistent<v8::Function> m_toString;
- v8::Persistent<v8::Function> m_valueOf;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV8VARIANTWRAPPER_P_H
-
diff --git a/src/declarative/qml/v8/qv8worker.cpp b/src/declarative/qml/v8/qv8worker.cpp
deleted file mode 100644
index 90c8b8441d..0000000000
--- a/src/declarative/qml/v8/qv8worker.cpp
+++ /dev/null
@@ -1,392 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv8worker_p.h"
-
-#include <private/qdeclarativelistmodel_p.h>
-#include <private/qdeclarativelistmodelworkeragent_p.h>
-
-QT_BEGIN_NAMESPACE
-
-// We allow the following JavaScript types to be passed between the main and
-// the secondary thread:
-// + undefined
-// + null
-// + Boolean
-// + String
-// + Function
-// + Array
-// + "Simple" Objects
-// + Number
-// + Date
-// + RegExp
-// <quint8 type><quint24 size><data>
-
-enum Type {
- WorkerUndefined,
- WorkerNull,
- WorkerTrue,
- WorkerFalse,
- WorkerString,
- WorkerFunction,
- WorkerArray,
- WorkerObject,
- WorkerInt32,
- WorkerUint32,
- WorkerNumber,
- WorkerDate,
- WorkerRegexp,
- WorkerListModel,
- WorkerSequence
-};
-
-static inline quint32 valueheader(Type type, quint32 size = 0)
-{
- return quint8(type) << 24 | (size & 0xFFFFFF);
-}
-
-static inline Type headertype(quint32 header)
-{
- return (Type)(header >> 24);
-}
-
-static inline quint32 headersize(quint32 header)
-{
- return header & 0xFFFFFF;
-}
-
-static inline void push(QByteArray &data, quint32 value)
-{
- data.append((const char *)&value, sizeof(quint32));
-}
-
-static inline void push(QByteArray &data, double value)
-{
- data.append((const char *)&value, sizeof(double));
-}
-
-static inline void push(QByteArray &data, void *ptr)
-{
- data.append((const char *)&ptr, sizeof(void *));
-}
-
-static inline void reserve(QByteArray &data, int extra)
-{
- data.reserve(data.size() + extra);
-}
-
-static inline quint32 popUint32(const char *&data)
-{
- quint32 rv = *((quint32 *)data);
- data += sizeof(quint32);
- return rv;
-}
-
-static inline double popDouble(const char *&data)
-{
- double rv = *((double *)data);
- data += sizeof(double);
- return rv;
-}
-
-static inline void *popPtr(const char *&data)
-{
- void *rv = *((void **)data);
- data += sizeof(void *);
- return rv;
-}
-
-// XXX TODO: Check that worker script is exception safe in the case of
-// serialization/deserialization failures
-
-#define ALIGN(size) (((size) + 3) & ~3)
-void QV8Worker::serialize(QByteArray &data, v8::Handle<v8::Value> v, QV8Engine *engine)
-{
- if (v.IsEmpty()) {
- } else if (v->IsUndefined()) {
- push(data, valueheader(WorkerUndefined));
- } else if (v->IsNull()) {
- push(data, valueheader(WorkerNull));
- } else if (v->IsTrue()) {
- push(data, valueheader(WorkerTrue));
- } else if (v->IsFalse()) {
- push(data, valueheader(WorkerFalse));
- } else if (v->IsString()) {
- v8::Handle<v8::String> string = v->ToString();
- int length = string->Length() + 1;
- if (length > 0xFFFFFF) {
- push(data, valueheader(WorkerUndefined));
- return;
- }
- int utf16size = ALIGN(length * sizeof(uint16_t));
-
- reserve(data, utf16size + sizeof(quint32));
- push(data, valueheader(WorkerString, length));
-
- int offset = data.size();
- data.resize(data.size() + utf16size);
- char *buffer = data.data() + offset;
-
- string->Write((uint16_t*)buffer);
- } else if (v->IsFunction()) {
- // XXX TODO: Implement passing function objects between the main and
- // worker scripts
- push(data, valueheader(WorkerUndefined));
- } else if (v->IsArray()) {
- v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(v);
- uint32_t length = array->Length();
- if (length > 0xFFFFFF) {
- push(data, valueheader(WorkerUndefined));
- return;
- }
- reserve(data, sizeof(quint32) + length * sizeof(quint32));
- push(data, valueheader(WorkerArray, length));
- for (uint32_t ii = 0; ii < length; ++ii)
- serialize(data, array->Get(ii), engine);
- } else if (v->IsInt32()) {
- reserve(data, 2 * sizeof(quint32));
- push(data, valueheader(WorkerInt32));
- push(data, (quint32)v->Int32Value());
- } else if (v->IsUint32()) {
- reserve(data, 2 * sizeof(quint32));
- push(data, valueheader(WorkerUint32));
- push(data, v->Uint32Value());
- } else if (v->IsNumber()) {
- reserve(data, sizeof(quint32) + sizeof(double));
- push(data, valueheader(WorkerNumber));
- push(data, v->NumberValue());
- } else if (v->IsDate()) {
- reserve(data, sizeof(quint32) + sizeof(double));
- push(data, valueheader(WorkerDate));
- push(data, v8::Handle<v8::Date>::Cast(v)->NumberValue());
- } else if (v->IsRegExp()) {
- v8::Handle<v8::RegExp> regexp = v8::Handle<v8::RegExp>::Cast(v);
- quint32 flags = regexp->GetFlags();
- v8::Local<v8::String> source = regexp->GetSource();
-
- int length = source->Length() + 1;
- if (length > 0xFFFFFF) {
- push(data, valueheader(WorkerUndefined));
- return;
- }
- int utf16size = ALIGN(length * sizeof(uint16_t));
-
- reserve(data, sizeof(quint32) + utf16size);
- push(data, valueheader(WorkerRegexp, flags));
- push(data, (quint32)length);
- int offset = data.size();
- data.resize(data.size() + utf16size);
- char *buffer = data.data() + offset;
-
- source->Write((uint16_t*)buffer);
- } else if (v->IsObject() && !v->ToObject()->GetExternalResource()) {
- v8::Handle<v8::Object> object = v->ToObject();
- v8::Local<v8::Array> properties = engine->getOwnPropertyNames(object);
- quint32 length = properties->Length();
- if (length > 0xFFFFFF) {
- push(data, valueheader(WorkerUndefined));
- return;
- }
- push(data, valueheader(WorkerObject, length));
- v8::TryCatch tc;
- for (quint32 ii = 0; ii < length; ++ii) {
- v8::Local<v8::String> str = properties->Get(ii)->ToString();
- serialize(data, str, engine);
-
- v8::Local<v8::Value> val = object->Get(str);
- if (tc.HasCaught()) {
- serialize(data, v8::Undefined(), engine);
- tc.Reset();
- } else {
- serialize(data, val, engine);
- }
- }
- } else if (engine->isQObject(v)) {
- // XXX TODO: Generalize passing objects between the main thread and worker scripts so
- // that others can trivially plug in their elements.
- QDeclarativeListModel *lm = qobject_cast<QDeclarativeListModel *>(engine->toQObject(v));
- if (lm && lm->agent()) {
- QDeclarativeListModelWorkerAgent *agent = lm->agent();
- agent->addref();
- push(data, valueheader(WorkerListModel));
- push(data, (void *)agent);
- return;
- }
- // No other QObject's are allowed to be sent
- push(data, valueheader(WorkerUndefined));
- } else {
- // we can convert sequences, but not other types with external data.
- if (v->IsObject()) {
- v8::Handle<v8::Object> seqObj = v->ToObject();
- QV8ObjectResource *r = static_cast<QV8ObjectResource *>(seqObj->GetExternalResource());
- if (r->resourceType() == QV8ObjectResource::SequenceType) {
- QVariant sequenceVariant = engine->sequenceWrapper()->toVariant(r);
- if (!sequenceVariant.isNull()) {
- // valid sequence. we generate a length (sequence length + 1 for the sequence type)
- uint32_t seqLength = engine->sequenceWrapper()->sequenceLength(r);
- uint32_t length = seqLength + 1;
- if (length > 0xFFFFFF) {
- push(data, valueheader(WorkerUndefined));
- return;
- }
- reserve(data, sizeof(quint32) + length * sizeof(quint32));
- push(data, valueheader(WorkerSequence, length));
- serialize(data, v8::Integer::New(sequenceVariant.userType()), engine); // sequence type
- for (uint32_t ii = 0; ii < seqLength; ++ii) {
- serialize(data, seqObj->Get(ii), engine); // sequence elements
- }
-
- return;
- }
- }
- }
-
- // not a sequence.
- push(data, valueheader(WorkerUndefined));
- }
-}
-
-v8::Handle<v8::Value> QV8Worker::deserialize(const char *&data, QV8Engine *engine)
-{
- quint32 header = popUint32(data);
- Type type = headertype(header);
-
- switch (type) {
- case WorkerUndefined:
- return v8::Undefined();
- case WorkerNull:
- return v8::Null();
- case WorkerTrue:
- return v8::True();
- case WorkerFalse:
- return v8::False();
- case WorkerString:
- {
- quint32 size = headersize(header);
- v8::Local<v8::String> string = v8::String::New((uint16_t*)data, size - 1);
- data += ALIGN(size * sizeof(uint16_t));
- return string;
- }
- case WorkerFunction:
- Q_ASSERT(!"Unreachable");
- break;
- case WorkerArray:
- {
- quint32 size = headersize(header);
- v8::Local<v8::Array> array = v8::Array::New(size);
- for (quint32 ii = 0; ii < size; ++ii) {
- array->Set(ii, deserialize(data, engine));
- }
- return array;
- }
- case WorkerObject:
- {
- quint32 size = headersize(header);
- v8::Local<v8::Object> o = v8::Object::New();
- for (quint32 ii = 0; ii < size; ++ii) {
- v8::Handle<v8::Value> name = deserialize(data, engine);
- v8::Handle<v8::Value> value = deserialize(data, engine);
- o->Set(name, value);
- }
- return o;
- }
- case WorkerInt32:
- return v8::Integer::New((qint32)popUint32(data));
- case WorkerUint32:
- return v8::Integer::NewFromUnsigned(popUint32(data));
- case WorkerNumber:
- return v8::Number::New(popDouble(data));
- case WorkerDate:
- return v8::Date::New(popDouble(data));
- case WorkerRegexp:
- {
- quint32 flags = headersize(header);
- quint32 length = popUint32(data);
- v8::Local<v8::String> source = v8::String::New((uint16_t*)data, length - 1);
- data += ALIGN(length * sizeof(uint16_t));
- return v8::RegExp::New(source, (v8::RegExp::Flags)flags);
- }
- case WorkerListModel:
- {
- void *ptr = popPtr(data);
- QDeclarativeListModelWorkerAgent *agent = (QDeclarativeListModelWorkerAgent *)ptr;
- v8::Handle<v8::Value> rv = engine->newQObject(agent);
- if (rv->IsObject()) {
- QDeclarativeListModelWorkerAgent::VariantRef ref(agent);
- QVariant var = qVariantFromValue(ref);
- rv->ToObject()->SetHiddenValue(v8::String::New("qml::ref"), engine->fromVariant(var));
- }
- agent->release();
- agent->setV8Engine(engine);
- return rv;
- }
- case WorkerSequence:
- {
- bool succeeded = false;
- quint32 length = headersize(header);
- quint32 seqLength = length - 1;
- int sequenceType = deserialize(data, engine)->Int32Value();
- v8::Local<v8::Array> array = v8::Array::New(seqLength);
- for (quint32 ii = 0; ii < seqLength; ++ii)
- array->Set(ii, deserialize(data, engine));
- QVariant seqVariant = engine->sequenceWrapper()->toVariant(array, sequenceType, &succeeded);
- return engine->sequenceWrapper()->fromVariant(seqVariant, &succeeded);
- }
- }
- Q_ASSERT(!"Unreachable");
- return v8::Undefined();
-}
-
-QByteArray QV8Worker::serialize(v8::Handle<v8::Value> value, QV8Engine *engine)
-{
- QByteArray rv;
- serialize(rv, value, engine);
- return rv;
-}
-
-v8::Handle<v8::Value> QV8Worker::deserialize(const QByteArray &data, QV8Engine *engine)
-{
- const char *stream = data.constData();
- return deserialize(stream, engine);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/v8/qv8worker_p.h b/src/declarative/qml/v8/qv8worker_p.h
deleted file mode 100644
index f920446b27..0000000000
--- a/src/declarative/qml/v8/qv8worker_p.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV8WORKER_P_H
-#define QV8WORKER_P_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 "qv8engine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QV8Worker {
-public:
- struct SavedData {
- };
-
- static QByteArray serialize(v8::Handle<v8::Value>, QV8Engine *);
- static v8::Handle<v8::Value> deserialize(const QByteArray &, QV8Engine *);
-
-private:
- static void serialize(QByteArray &, v8::Handle<v8::Value>, QV8Engine *);
- static v8::Handle<v8::Value> deserialize(const char *&, QV8Engine *);
-};
-
-QT_END_NAMESPACE
-
-#endif // QV8WORKER_P_H
diff --git a/src/declarative/qml/v8/v8.pri b/src/declarative/qml/v8/v8.pri
deleted file mode 100644
index 72416c4dbb..0000000000
--- a/src/declarative/qml/v8/v8.pri
+++ /dev/null
@@ -1,45 +0,0 @@
-INCLUDEPATH += $$PWD/../../../3rdparty/javascriptcore
-
-include(script.pri)
-
-HEADERS += \
- $$PWD/qv8_p.h \
- $$PWD/qv8debug_p.h \
- $$PWD/qv8profiler_p.h \
- $$PWD/qv8stringwrapper_p.h \
- $$PWD/qv8engine_p.h \
- $$PWD/qv8sequencewrapper_p.h \
- $$PWD/qv8sequencewrapper_p_p.h \
- $$PWD/qv8contextwrapper_p.h \
- $$PWD/qv8qobjectwrapper_p.h \
- $$PWD/qv8typewrapper_p.h \
- $$PWD/qv8listwrapper_p.h \
- $$PWD/qv8variantwrapper_p.h \
- $$PWD/qv8variantresource_p.h \
- $$PWD/qv8valuetypewrapper_p.h \
- $$PWD/qv8include_p.h \
- $$PWD/qv8worker_p.h \
- $$PWD/qv8bindings_p.h \
- $$PWD/../../../3rdparty/javascriptcore/DateMath.h \
- $$PWD/qv8engine_impl_p.h \
- $$PWD/qv8domerrors_p.h \
- $$PWD/qv8sqlerrors_p.h \
- $$PWD/qdeclarativebuiltinfunctions_p.h
-
-SOURCES += \
- $$PWD/qv8stringwrapper.cpp \
- $$PWD/qv8engine.cpp \
- $$PWD/qv8sequencewrapper.cpp \
- $$PWD/qv8contextwrapper.cpp \
- $$PWD/qv8qobjectwrapper.cpp \
- $$PWD/qv8typewrapper.cpp \
- $$PWD/qv8listwrapper.cpp \
- $$PWD/qv8variantwrapper.cpp \
- $$PWD/qv8valuetypewrapper.cpp \
- $$PWD/qv8include.cpp \
- $$PWD/qv8worker.cpp \
- $$PWD/qv8bindings.cpp \
- $$PWD/../../../3rdparty/javascriptcore/DateMath.cpp \
- $$PWD/qv8domerrors.cpp \
- $$PWD/qv8sqlerrors.cpp \
- $$PWD/qdeclarativebuiltinfunctions.cpp \ No newline at end of file
diff --git a/src/declarative/util/qdeclarativepropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp
deleted file mode 100644
index 8ec1517017..0000000000
--- a/src/declarative/util/qdeclarativepropertymap.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepropertymap.h"
-
-#include <private/qmetaobjectbuilder_p.h>
-#include <private/qdeclarativeopenmetaobject_p.h>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-//QDeclarativePropertyMapMetaObject lets us listen for changes coming from QML
-//so we can emit the changed signal.
-class QDeclarativePropertyMapMetaObject : public QDeclarativeOpenMetaObject
-{
-public:
- QDeclarativePropertyMapMetaObject(QDeclarativePropertyMap *obj, QDeclarativePropertyMapPrivate *objPriv);
-
-protected:
- virtual void propertyWritten(int index);
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
- virtual int createProperty(const char *, const char *);
-private:
- QDeclarativePropertyMap *map;
- QDeclarativePropertyMapPrivate *priv;
-};
-
-class QDeclarativePropertyMapPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativePropertyMap)
-public:
- QDeclarativePropertyMapMetaObject *mo;
- QStringList keys;
- void emitChanged(const QString &key, const QVariant &value);
- bool validKeyName(const QString& name);
-};
-
-bool QDeclarativePropertyMapPrivate::validKeyName(const QString& name)
-{
- //The following strings shouldn't be used as property names
- return name != QLatin1String("keys")
- && name != QLatin1String("valueChanged")
- && name != QLatin1String("QObject")
- && name != QLatin1String("destroyed")
- && name != QLatin1String("deleteLater");
-}
-
-void QDeclarativePropertyMapPrivate::emitChanged(const QString &key, const QVariant &value)
-{
- Q_Q(QDeclarativePropertyMap);
- emit q->valueChanged(key, value);
-}
-
-QDeclarativePropertyMapMetaObject::QDeclarativePropertyMapMetaObject(QDeclarativePropertyMap *obj, QDeclarativePropertyMapPrivate *objPriv) : QDeclarativeOpenMetaObject(obj)
-{
- map = obj;
- priv = objPriv;
-}
-
-void QDeclarativePropertyMapMetaObject::propertyWritten(int index)
-{
- priv->emitChanged(QString::fromUtf8(name(index)), operator[](index));
-}
-
-void QDeclarativePropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilder &b)
-{
- priv->keys.append(QString::fromUtf8(b.name()));
-}
-
-int QDeclarativePropertyMapMetaObject::createProperty(const char *name, const char *value)
-{
- if (!priv->validKeyName(QString::fromUtf8(name)))
- return -1;
- return QDeclarativeOpenMetaObject::createProperty(name, value);
-}
-
-/*!
- \class QDeclarativePropertyMap
- \brief The QDeclarativePropertyMap class allows you to set key-value pairs that can be used in QML bindings.
-
- QDeclarativePropertyMap provides a convenient way to expose domain data to the UI layer.
- The following example shows how you might declare data in C++ and then
- access it in QML.
-
- In the C++ file:
- \code
- // create our data
- QDeclarativePropertyMap ownerData;
- ownerData.insert("name", QVariant(QString("John Smith")));
- ownerData.insert("phone", QVariant(QString("555-5555")));
-
- // expose it to the UI layer
- QDeclarativeView view;
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("owner", &ownerData);
-
- view.setSource(QUrl::fromLocalFile("main.qml"));
- view.show();
- \endcode
-
- Then, in \c main.qml:
- \code
- Text { text: owner.name + " " + owner.phone }
- \endcode
-
- The binding is dynamic - whenever a key's value is updated, anything bound to that
- key will be updated as well.
-
- To detect value changes made in the UI layer you can connect to the valueChanged() signal.
- However, note that valueChanged() is \bold NOT emitted when changes are made by calling insert()
- or clear() - it is only emitted when a value is updated from QML.
-
- \note It is not possible to remove keys from the map; once a key has been added, you can only
- modify or clear its associated value.
-*/
-
-/*!
- Constructs a bindable map with parent object \a parent.
-*/
-QDeclarativePropertyMap::QDeclarativePropertyMap(QObject *parent)
-: QObject(*(new QDeclarativePropertyMapPrivate), parent)
-{
- Q_D(QDeclarativePropertyMap);
- d->mo = new QDeclarativePropertyMapMetaObject(this, d);
-}
-
-/*!
- Destroys the bindable map.
-*/
-QDeclarativePropertyMap::~QDeclarativePropertyMap()
-{
-}
-
-/*!
- Clears the value (if any) associated with \a key.
-*/
-void QDeclarativePropertyMap::clear(const QString &key)
-{
- Q_D(QDeclarativePropertyMap);
- d->mo->setValue(key.toUtf8(), QVariant());
-}
-
-/*!
- Returns the value associated with \a key.
-
- If no value has been set for this key (or if the value has been cleared),
- an invalid QVariant is returned.
-*/
-QVariant QDeclarativePropertyMap::value(const QString &key) const
-{
- Q_D(const QDeclarativePropertyMap);
- return d->mo->value(key.toUtf8());
-}
-
-/*!
- Sets the value associated with \a key to \a value.
-
- If the key doesn't exist, it is automatically created.
-*/
-void QDeclarativePropertyMap::insert(const QString &key, const QVariant &value)
-{
- Q_D(QDeclarativePropertyMap);
-
- if (d->validKeyName(key)) {
- d->mo->setValue(key.toUtf8(), value);
- } else {
- qWarning() << "Creating property with name"
- << key
- << "is not permitted, conflicts with internal symbols.";
- }
-}
-
-/*!
- Returns the list of keys.
-
- Keys that have been cleared will still appear in this list, even though their
- associated values are invalid QVariants.
-*/
-QStringList QDeclarativePropertyMap::keys() const
-{
- Q_D(const QDeclarativePropertyMap);
- return d->keys;
-}
-
-/*!
- \overload
-
- Same as size().
-*/
-int QDeclarativePropertyMap::count() const
-{
- Q_D(const QDeclarativePropertyMap);
- return d->keys.count();
-}
-
-/*!
- Returns the number of keys in the map.
-
- \sa isEmpty(), count()
-*/
-int QDeclarativePropertyMap::size() const
-{
- Q_D(const QDeclarativePropertyMap);
- return d->keys.size();
-}
-
-/*!
- Returns true if the map contains no keys; otherwise returns
- false.
-
- \sa size()
-*/
-bool QDeclarativePropertyMap::isEmpty() const
-{
- Q_D(const QDeclarativePropertyMap);
- return d->keys.isEmpty();
-}
-
-/*!
- Returns true if the map contains \a key.
-
- \sa size()
-*/
-bool QDeclarativePropertyMap::contains(const QString &key) const
-{
- Q_D(const QDeclarativePropertyMap);
- return d->keys.contains(key);
-}
-
-/*!
- Returns the value associated with the key \a key as a modifiable
- reference.
-
- If the map contains no item with key \a key, the function inserts
- an invalid QVariant into the map with key \a key, and
- returns a reference to it.
-
- \sa insert(), value()
-*/
-QVariant &QDeclarativePropertyMap::operator[](const QString &key)
-{
- //### optimize
- Q_D(QDeclarativePropertyMap);
- QByteArray utf8key = key.toUtf8();
- if (!d->keys.contains(key))
- insert(key, QVariant());//force creation -- needed below
-
- return (*(d->mo))[utf8key];
-}
-
-/*!
- \overload
-
- Same as value().
-*/
-QVariant QDeclarativePropertyMap::operator[](const QString &key) const
-{
- return value(key);
-}
-
-/*!
- \fn void QDeclarativePropertyMap::valueChanged(const QString &key, const QVariant &value)
- This signal is emitted whenever one of the values in the map is changed. \a key
- is the key corresponding to the \a value that was changed.
-
- \note valueChanged() is \bold NOT emitted when changes are made by calling insert()
- or clear() - it is only emitted when a value is updated from QML.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativepropertymap.h b/src/declarative/util/qdeclarativepropertymap.h
deleted file mode 100644
index 3a2ce7b33d..0000000000
--- a/src/declarative/util/qdeclarativepropertymap.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROPERTYMAP_H
-#define QDECLARATIVEPROPERTYMAP_H
-
-#include <QtCore/QObject>
-#include <QtCore/QHash>
-#include <QtCore/QStringList>
-#include <QtCore/QVariant>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativePropertyMapPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativePropertyMap : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativePropertyMap(QObject *parent = 0);
- virtual ~QDeclarativePropertyMap();
-
- QVariant value(const QString &key) const;
- void insert(const QString &key, const QVariant &value);
- void clear(const QString &key);
-
- Q_INVOKABLE QStringList keys() const;
-
- int count() const;
- int size() const;
- bool isEmpty() const;
- bool contains(const QString &key) const;
-
- QVariant &operator[](const QString &key);
- QVariant operator[](const QString &key) const;
-
-Q_SIGNALS:
- void valueChanged(const QString &key, const QVariant &value);
-
-private:
- Q_DECLARE_PRIVATE(QDeclarativePropertyMap)
- Q_DISABLE_COPY(QDeclarativePropertyMap)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
deleted file mode 100644
index 01d4247ff8..0000000000
--- a/src/declarative/util/util.pri
+++ /dev/null
@@ -1,5 +0,0 @@
-SOURCES += \
- $$PWD/qdeclarativepropertymap.cpp
-
-HEADERS += \
- $$PWD/qdeclarativepropertymap.h
diff --git a/src/imports/folderlistmodel/folderlistmodel.pro b/src/imports/folderlistmodel/folderlistmodel.pro
index 9727b513e6..592d8375c8 100644
--- a/src/imports/folderlistmodel/folderlistmodel.pro
+++ b/src/imports/folderlistmodel/folderlistmodel.pro
@@ -2,15 +2,15 @@ TARGET = qmlfolderlistmodelplugin
TARGETPATH = Qt/labs/folderlistmodel
include(../qimportbase.pri)
-QT += declarative
+QT += qml
-SOURCES += qdeclarativefolderlistmodel.cpp plugin.cpp \
+SOURCES += qquickfolderlistmodel.cpp plugin.cpp \
fileinfothread.cpp
-HEADERS += qdeclarativefolderlistmodel.h \
+HEADERS += qquickfolderlistmodel.h \
fileproperty_p.h \
fileinfothread_p.h
-DESTDIR = $$QT.declarative.imports/$$TARGETPATH
+DESTDIR = $$QT.qml.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
qmldir.files += $$PWD/qmldir
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index 767f8f6c68..bc904512a8 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -39,25 +39,25 @@
**
****************************************************************************/
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
-#include "qdeclarativefolderlistmodel.h"
+#include "qquickfolderlistmodel.h"
QT_BEGIN_NAMESPACE
//![class decl]
-class QmlFolderListModelPlugin : public QDeclarativeExtensionPlugin
+class QmlFolderListModelPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "folderlistmodel.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "folderlistmodel.json")
public:
virtual void registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel"));
#ifndef QT_NO_DIRMODEL
- qmlRegisterType<QDeclarativeFolderListModel>(uri,1,0,"FolderListModel");
+ qmlRegisterType<QQuickFolderListModel>(uri,1,0,"FolderListModel");
#endif
}
};
diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
deleted file mode 100644
index fa1a181e1f..0000000000
--- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
+++ /dev/null
@@ -1,697 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//![code]
-#include "qdeclarativefolderlistmodel.h"
-#include "fileinfothread_p.h"
-#include "fileproperty_p.h"
-#include <QDebug>
-#include <qdeclarativecontext.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeFolderListModelPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeFolderListModel)
-
-public:
- QDeclarativeFolderListModelPrivate(QDeclarativeFolderListModel *q)
- : q_ptr(q),
- sortField(QDeclarativeFolderListModel::Name), sortReversed(false), showDirs(true), showDirsFirst(false), showDots(false), showOnlyReadable(false)
- {
- nameFilters << QLatin1String("*");
- }
-
-
- QDeclarativeFolderListModel *q_ptr;
- QUrl currentDir;
- QUrl rootDir;
- FileInfoThread fileInfoThread;
- QList<FileProperty> data;
- QHash<int, QByteArray> roleNames;
- QDeclarativeFolderListModel::SortField sortField;
- QStringList nameFilters;
- bool sortReversed;
- bool showDirs;
- bool showDirsFirst;
- bool showDots;
- bool showOnlyReadable;
-
- ~QDeclarativeFolderListModelPrivate() {}
- void init();
- void updateSorting();
-
- // private slots
- void _q_directoryChanged(const QString &directory, const QList<FileProperty> &list);
- void _q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex);
- void _q_sortFinished(const QList<FileProperty> &list);
-};
-
-
-void QDeclarativeFolderListModelPrivate::init()
-{
- Q_Q(QDeclarativeFolderListModel);
- qRegisterMetaType<QList<FileProperty> >("QList<FileProperty>");
- q->connect(&fileInfoThread, SIGNAL(directoryChanged(QString, QList<FileProperty>)),
- q, SLOT(_q_directoryChanged(QString, QList<FileProperty>)));
- q->connect(&fileInfoThread, SIGNAL(directoryUpdated(QString, QList<FileProperty>, int, int)),
- q, SLOT(_q_directoryUpdated(QString, QList<FileProperty>, int, int)));
- q->connect(&fileInfoThread, SIGNAL(sortFinished(QList<FileProperty>)),
- q, SLOT(_q_sortFinished(QList<FileProperty>)));
-}
-
-
-void QDeclarativeFolderListModelPrivate::updateSorting()
-{
- Q_Q(QDeclarativeFolderListModel);
-
- QDir::SortFlags flags = 0;
-
- switch (sortField) {
- case QDeclarativeFolderListModel::Unsorted:
- flags |= QDir::Unsorted;
- break;
- case QDeclarativeFolderListModel::Name:
- flags |= QDir::Name;
- break;
- case QDeclarativeFolderListModel::Time:
- flags |= QDir::Time;
- break;
- case QDeclarativeFolderListModel::Size:
- flags |= QDir::Size;
- break;
- case QDeclarativeFolderListModel::Type:
- flags |= QDir::Type;
- break;
- default:
- break;
- }
-
- emit q->layoutAboutToBeChanged();
-
- if (sortReversed)
- flags |= QDir::Reversed;
-
- fileInfoThread.setSortFlags(flags);
-}
-
-void QDeclarativeFolderListModelPrivate::_q_directoryChanged(const QString &directory, const QList<FileProperty> &list)
-{
- Q_Q(QDeclarativeFolderListModel);
- Q_UNUSED(directory);
-
- data = list;
- q->endResetModel();
- emit q->rowCountChanged();
- emit q->folderChanged();
-}
-
-
-void QDeclarativeFolderListModelPrivate::_q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex)
-{
- Q_Q(QDeclarativeFolderListModel);
- Q_UNUSED(directory);
-
- QModelIndex parent;
- if (data.size() > list.size()) {
- //File(s) removed. Since I do not know how many
- //or where I need to update the whole list from the first item.
- data = list;
- q->beginRemoveRows(parent, fromIndex, toIndex);
- q->endRemoveRows();
- q->beginInsertRows(parent, fromIndex, list.size()-1);
- q->endInsertRows();
- emit q->rowCountChanged();
- } else if (data.size() < list.size()) {
- //qDebug() << "File added. FromIndex: " << fromIndex << " toIndex: " << toIndex << " list size: " << list.size();
- //File(s) added. Calculate how many and insert
- //from the first changed one.
- toIndex = fromIndex + (list.size() - data.size()-1);
- q->beginInsertRows(parent, fromIndex, toIndex);
- q->endInsertRows();
- data = list;
- emit q->rowCountChanged();
- QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0);
- QModelIndex modelIndexTo = q->createIndex(toIndex, 0);
- emit q->dataChanged(modelIndexFrom, modelIndexTo);
- } else {
- //qDebug() << "File has been updated";
- QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0);
- QModelIndex modelIndexTo = q->createIndex(toIndex, 0);
- data = list;
- emit q->dataChanged(modelIndexFrom, modelIndexTo);
- }
-}
-
-void QDeclarativeFolderListModelPrivate::_q_sortFinished(const QList<FileProperty> &list)
-{
- Q_Q(QDeclarativeFolderListModel);
-
- QModelIndex parent;
- q->beginRemoveRows(parent, 0, data.size()-1);
- data.clear();
- q->endRemoveRows();
-
- q->beginInsertRows(parent, 0, list.size()-1);
- data = list;
- q->endInsertRows();
-}
-
-
-/*!
- \qmlclass FolderListModel QDeclarativeFolderListModel
- \ingroup qml-working-with-data
- \brief The FolderListModel provides a model of the contents of a file system folder.
-
- FolderListModel provides access to information about the contents of a folder
- in the local file system, exposing a list of files to views and other data components.
-
- \note This type is made available by importing the \c Qt.labs.folderlistmodel module.
- \e{Elements in the Qt.labs module are not guaranteed to remain compatible
- in future versions.}
-
- \bold{import Qt.labs.folderlistmodel 1.0}
-
- The \l folder property specifies the folder to access. Information about the
- files and directories in the folder is supplied via the model's interface.
- Components access names and paths via the following roles:
-
- \list
- \o \c fileName
- \o \c filePath
- \o \c fileBaseName
- \o \c fileSuffix
- \o \c fileSize
- \o \c fileModified
- \o \c fileAccessed
- \o \c fileIsDir
- \endlist
-
- Additionally a file entry can be differentiated from a folder entry via the
- isFolder() method.
-
- \section1 Filtering
-
- Various properties can be set to filter the number of files and directories
- exposed by the model.
-
- The \l nameFilters property can be set to contain a list of wildcard filters
- that are applied to names of files and directories, causing only those that
- match the filters to be exposed.
-
- Directories can be included or excluded using the \l showDirs property, and
- navigation directories can also be excluded by setting the \l showDotAndDotDot
- property to false.
-
- It is sometimes useful to limit the files and directories exposed to those
- that the user can access. The \l showOnlyReadable property can be set to
- enable this feature.
-
- \section1 Example Usage
-
- The following example shows a FolderListModel being used to provide a list
- of QML files in a \l ListView:
-
- \snippet doc/src/snippets/declarative/folderlistmodel.qml 0
-
- \section1 Path Separators
-
- Qt uses "/" as a universal directory separator in the same way that "/" is
- used as a path separator in URLs. If you always use "/" as a directory
- separator, Qt will translate your paths to conform to the underlying
- operating system.
-
- \sa {QML Data Models}
-*/
-
-QDeclarativeFolderListModel::QDeclarativeFolderListModel(QObject *parent)
- : QAbstractListModel(parent), d_ptr(new QDeclarativeFolderListModelPrivate(this))
-{
- Q_D(QDeclarativeFolderListModel);
- d->roleNames[FileNameRole] = "fileName";
- d->roleNames[FilePathRole] = "filePath";
- d->roleNames[FileBaseNameRole] = "fileBaseName";
- d->roleNames[FileSuffixRole] = "fileSuffix";
- d->roleNames[FileSizeRole] = "fileSize";
- d->roleNames[FileLastModifiedRole] = "fileModified";
- d->roleNames[FileLastReadRole] = "fileAccessed";
- d->roleNames[FileIsDirRole] = "fileIsDir";
- setRoleNames(d->roleNames);
-
- d->init();
-}
-
-QDeclarativeFolderListModel::~QDeclarativeFolderListModel()
-{
-}
-
-QVariant QDeclarativeFolderListModel::data(const QModelIndex &index, int role) const
-{
- Q_D(const QDeclarativeFolderListModel);
- QVariant rv;
-
- if (index.row() >= d->data.size())
- return rv;
-
- switch (role)
- {
- case FileNameRole:
- rv = d->data.at(index.row()).fileName();
- break;
- case FilePathRole:
- rv = d->data.at(index.row()).filePath();
- break;
- case FileBaseNameRole:
- rv = d->data.at(index.row()).baseName();
- break;
- case FileSuffixRole:
- rv = d->data.at(index.row()).suffix();
- break;
- case FileSizeRole:
- rv = d->data.at(index.row()).size();
- break;
- case FileLastModifiedRole:
- rv = d->data.at(index.row()).lastModified().date().toString(Qt::ISODate) + " " + d->data.at(index.row()).lastModified().time().toString();
- break;
- case FileLastReadRole:
- rv = d->data.at(index.row()).lastRead().date().toString(Qt::ISODate) + " " + d->data.at(index.row()).lastRead().time().toString();
- break;
- case FileIsDirRole:
- rv = d->data.at(index.row()).isDir();
- break;
- default:
- break;
- }
- return rv;
-}
-
-/*!
- \qmlproperty int FolderListModel::count
-
- Returns the number of items in the current folder that match the
- filter criteria.
-*/
-int QDeclarativeFolderListModel::rowCount(const QModelIndex &parent) const
-{
- Q_D(const QDeclarativeFolderListModel);
- Q_UNUSED(parent);
- return d->data.size();
-}
-
-QModelIndex QDeclarativeFolderListModel::index(int row, int , const QModelIndex &) const
-{
- return createIndex(row, 0);
-}
-
-/*!
- \qmlproperty string FolderListModel::folder
-
- The \a folder property holds a URL for the folder that the model is
- currently providing.
-
- The value is a URL expressed as a string, and must be a \c file: or \c qrc:
- URL, or a relative URL.
-
- By default, the value is an invalid URL.
-*/
-QUrl QDeclarativeFolderListModel::folder() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->currentDir;
-}
-
-void QDeclarativeFolderListModel::setFolder(const QUrl &folder)
-{
- Q_D(QDeclarativeFolderListModel);
-
- if (folder == d->currentDir)
- return;
-
- QString resolvedPath = QDir::cleanPath(folder.path());
-
- beginResetModel();
-
- //Remove the old path for the file system watcher
- if (!d->currentDir.isEmpty())
- d->fileInfoThread.removePath(d->currentDir.path());
-
- d->currentDir = folder;
-
- QFileInfo info(resolvedPath);
- if (!info.exists() || !info.isDir()) {
- d->data.clear();
- endResetModel();
- emit rowCountChanged();
- return;
- }
-
- d->fileInfoThread.setPath(resolvedPath);
-}
-
-
-/*!
- \qmlproperty string QDeclarativeFolderListModel::rootFolder
-
- When the rootFolder is set, then this folder will
- be threated as the root in the file system, so that
- you can only travers sub folders from this rootFolder.
-*/
-QUrl QDeclarativeFolderListModel::rootFolder() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->rootDir;
-}
-
-void QDeclarativeFolderListModel::setRootFolder(const QUrl &path)
-{
- Q_D(QDeclarativeFolderListModel);
-
- if (path.isEmpty())
- return;
-
- QString resolvedPath = QDir::cleanPath(path.path());
-
- QFileInfo info(resolvedPath);
- if (!info.exists() || !info.isDir())
- return;
-
- d->fileInfoThread.setRootPath(resolvedPath);
- d->rootDir = path;
-}
-
-
-/*!
- \qmlproperty url FolderListModel::parentFolder
-
- Returns the URL of the parent of of the current \l folder.
-*/
-QUrl QDeclarativeFolderListModel::parentFolder() const
-{
- Q_D(const QDeclarativeFolderListModel);
-
- QString localFile = d->currentDir.toLocalFile();
- if (!localFile.isEmpty()) {
- QDir dir(localFile);
-#if defined(Q_OS_WIN)
- if (dir.isRoot())
- dir.setPath("");
- else
-#endif
- dir.cdUp();
- localFile = dir.path();
- } else {
- int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/'));
- if (pos == -1)
- return QUrl();
- localFile = d->currentDir.path().left(pos);
- }
- return QUrl::fromLocalFile(localFile);
-}
-
-/*!
- \qmlproperty list<string> FolderListModel::nameFilters
-
- The \a nameFilters property contains a list of file name filters.
- The filters may include the ? and * wildcards.
-
- The example below filters on PNG and JPEG files:
-
- \qml
- FolderListModel {
- nameFilters: [ "*.png", "*.jpg" ]
- }
- \endqml
-
- \note Directories are not excluded by filters.
-*/
-QStringList QDeclarativeFolderListModel::nameFilters() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->nameFilters;
-}
-
-void QDeclarativeFolderListModel::setNameFilters(const QStringList &filters)
-{
- Q_D(QDeclarativeFolderListModel);
- d->fileInfoThread.setNameFilters(filters);
- d->nameFilters = filters;
-}
-
-void QDeclarativeFolderListModel::classBegin()
-{
-}
-
-void QDeclarativeFolderListModel::componentComplete()
-{
- Q_D(QDeclarativeFolderListModel);
-
- if (!d->currentDir.isValid() || d->currentDir.toLocalFile().isEmpty() || !QDir().exists(d->currentDir.toLocalFile()))
- setFolder(QUrl(QLatin1String("file://")+QDir::currentPath()));
-}
-
-/*!
- \qmlproperty enumeration FolderListModel::sortField
-
- The \a sortField property contains field to use for sorting. sortField
- may be one of:
- \list
- \o Unsorted - no sorting is applied.
- \o Name - sort by filename
- \o LastModified - sort by time modified
- \o Size - sort by file size
- \o Type - sort by file type (extension)
- \endlist
-
- \sa sortReversed
-*/
-QDeclarativeFolderListModel::SortField QDeclarativeFolderListModel::sortField() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->sortField;
-}
-
-void QDeclarativeFolderListModel::setSortField(SortField field)
-{
- Q_D(QDeclarativeFolderListModel);
- if (field != d->sortField) {
- d->sortField = field;
- d->updateSorting();
- }
-}
-
-int QDeclarativeFolderListModel::roleFromString(const QString &roleName) const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->roleNames.key(roleName.toLatin1(), -1);
-}
-
-/*!
- \qmlproperty bool FolderListModel::sortReversed
-
- If set to true, reverses the sort order. The default is false.
-
- \sa sortField
-*/
-bool QDeclarativeFolderListModel::sortReversed() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->sortReversed;
-}
-
-void QDeclarativeFolderListModel::setSortReversed(bool rev)
-{
- Q_D(QDeclarativeFolderListModel);
-
- if (rev != d->sortReversed) {
- d->sortReversed = rev;
- d->updateSorting();
- }
-}
-
-/*!
- \qmlmethod bool FolderListModel::isFolder(int index)
-
- Returns true if the entry \a index is a folder; otherwise
- returns false.
-*/
-bool QDeclarativeFolderListModel::isFolder(int index) const
-{
- if (index != -1) {
- QModelIndex idx = createIndex(index, 0);
- if (idx.isValid()) {
- QVariant var = data(idx, FileIsDirRole);
- if (var.isValid())
- return var.toBool();
- }
- }
- return false;
-}
-
-/*!
- \qmlproperty bool FolderListModel::showDirs
-
- If true, directories are included in the model; otherwise only files
- are included.
-
- By default, this property is true.
-
- Note that the nameFilters are not applied to directories.
-
- \sa showDotAndDotDot
-*/
-bool QDeclarativeFolderListModel::showDirs() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->showDirs;
-}
-
-void QDeclarativeFolderListModel::setShowDirs(bool on)
-{
- Q_D(QDeclarativeFolderListModel);
-
- d->fileInfoThread.setShowDirs(on);
- d->showDirs = on;
-}
-
-/*!
- \qmlproperty bool FolderListModel::showDirsFirst
-
- If true, if directories are included in the model they will
- always be shown first, then the files.
-
- By default, this property is false.
-
-*/
-bool QDeclarativeFolderListModel::showDirsFirst() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->showDirsFirst;
-}
-
-void QDeclarativeFolderListModel::setShowDirsFirst(bool on)
-{
- Q_D(QDeclarativeFolderListModel);
-
- d->fileInfoThread.setShowDirsFirst(on);
- d->showDirsFirst = on;
-}
-
-
-/*!
- \qmlproperty bool FolderListModel::showDotAndDotDot
-
- If true, the "." and ".." directories are included in the model; otherwise
- they are excluded.
-
- By default, this property is false.
-
- \sa showDirs
-*/
-bool QDeclarativeFolderListModel::showDotAndDotDot() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->showDots;
-}
-
-void QDeclarativeFolderListModel::setShowDotAndDotDot(bool on)
-{
- Q_D(QDeclarativeFolderListModel);
-
- if (on != d->showDots) {
- d->fileInfoThread.setShowDotDot(on);
- }
-}
-
-/*!
- \qmlproperty bool FolderListModel::showOnlyReadable
-
- If true, only readable files and directories are shown; otherwise all files
- and directories are shown.
-
- By default, this property is false.
-
- \sa showDirs
-*/
-bool QDeclarativeFolderListModel::showOnlyReadable() const
-{
- Q_D(const QDeclarativeFolderListModel);
- return d->showOnlyReadable;
-}
-
-void QDeclarativeFolderListModel::setShowOnlyReadable(bool on)
-{
- Q_D(QDeclarativeFolderListModel);
-
- if (on != d->showOnlyReadable) {
- d->fileInfoThread.setShowOnlyReadable(on);
- }
-}
-
-/*!
- \qmlmethod QVariant QDeclarativeFolderListModel::get(int idx, const QString &property) const
-
- Get the folder property for the given index. The following properties
- are available.
-
- \list
- \o \c fileName
- \o \c filePath
- \o \c fileBaseName
- \o \c fileSuffix
- \o \c fileSize
- \o \c fileModified
- \o \c fileAccessed
- \o \c fileIsDir
- \endlist
-*/
-QVariant QDeclarativeFolderListModel::get(int idx, const QString &property) const
-{
- int role = roleFromString(property);
- if (role >= 0 && idx >= 0)
- return data(index(idx, 0), role);
- else
- return QVariant();
-}
-
-#include "moc_qdeclarativefolderlistmodel.cpp"
-
-//![code]
-QT_END_NAMESPACE
diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h
deleted file mode 100644
index 27a7bc00a1..0000000000
--- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEFOLDERLISTMODEL_H
-#define QDECLARATIVEFOLDERLISTMODEL_H
-
-#include <qdeclarative.h>
-#include <QStringList>
-#include <QUrl>
-#include <QAbstractListModel>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeContext;
-class QModelIndex;
-
-class QDeclarativeFolderListModelPrivate;
-
-//![class begin]
-class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-//![class begin]
-
-//![class props]
- Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
- Q_PROPERTY(QUrl rootFolder READ rootFolder WRITE setRootFolder)
- Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged)
- Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
- Q_PROPERTY(SortField sortField READ sortField WRITE setSortField)
- Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed)
- Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs)
- Q_PROPERTY(bool showDirsFirst READ showDirsFirst WRITE setShowDirsFirst)
- Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
- Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
- Q_PROPERTY(int count READ count NOTIFY rowCountChanged)
-//![class props]
-
-//![abslistmodel]
-public:
- QDeclarativeFolderListModel(QObject *parent = 0);
- ~QDeclarativeFolderListModel();
-
- enum Roles {
- FileNameRole = Qt::UserRole + 1,
- FilePathRole = Qt::UserRole + 2,
- FileBaseNameRole = Qt::UserRole + 3,
- FileSuffixRole = Qt::UserRole + 4,
- FileSizeRole = Qt::UserRole + 5,
- FileLastModifiedRole = Qt::UserRole + 6,
- FileLastReadRole = Qt::UserRole +7,
- FileIsDirRole = Qt::UserRole + 8
- };
-
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-//![abslistmodel]
-
-//![count]
- int count() const { return rowCount(QModelIndex()); }
-//![count]
-
-//![prop funcs]
- QUrl folder() const;
- void setFolder(const QUrl &folder);
- QUrl rootFolder() const;
- void setRootFolder(const QUrl &path);
-
- QUrl parentFolder() const;
-
- QStringList nameFilters() const;
- void setNameFilters(const QStringList &filters);
-
- enum SortField { Unsorted, Name, Time, Size, Type };
- SortField sortField() const;
- void setSortField(SortField field);
- Q_ENUMS(SortField)
-
- bool sortReversed() const;
- void setSortReversed(bool rev);
-
- bool showDirs() const;
- void setShowDirs(bool showDirs);
- bool showDirsFirst() const;
- void setShowDirsFirst(bool showDirsFirst);
- bool showDotAndDotDot() const;
- void setShowDotAndDotDot(bool on);
- bool showOnlyReadable() const;
- void setShowOnlyReadable(bool on);
-//![prop funcs]
-
- Q_INVOKABLE bool isFolder(int index) const;
- Q_INVOKABLE QVariant get(int idx, const QString &property) const;
-
-//![parserstatus]
- virtual void classBegin();
- virtual void componentComplete();
-//![parserstatus]
-
- int roleFromString(const QString &roleName) const;
-
-//![notifier]
-Q_SIGNALS:
- void folderChanged();
- void rowCountChanged() const;
-//![notifier]
-
-//![class end]
-
-
-private:
- Q_DISABLE_COPY(QDeclarativeFolderListModel)
- Q_DECLARE_PRIVATE(QDeclarativeFolderListModel)
- QScopedPointer<QDeclarativeFolderListModelPrivate> d_ptr;
-
- Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &directory, const QList<FileProperty> &list))
- Q_PRIVATE_SLOT(d_func(), void _q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex))
- Q_PRIVATE_SLOT(d_func(), void _q_sortFinished(const QList<FileProperty> &list))
-};
-//![class end]
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEFOLDERLISTMODEL_H
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
new file mode 100644
index 0000000000..d68d7af6d4
--- /dev/null
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -0,0 +1,697 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![code]
+#include "qquickfolderlistmodel.h"
+#include "fileinfothread_p.h"
+#include "fileproperty_p.h"
+#include <QDebug>
+#include <qqmlcontext.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickFolderListModelPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickFolderListModel)
+
+public:
+ QQuickFolderListModelPrivate(QQuickFolderListModel *q)
+ : q_ptr(q),
+ sortField(QQuickFolderListModel::Name), sortReversed(false), showDirs(true), showDirsFirst(false), showDots(false), showOnlyReadable(false)
+ {
+ nameFilters << QLatin1String("*");
+ }
+
+
+ QQuickFolderListModel *q_ptr;
+ QUrl currentDir;
+ QUrl rootDir;
+ FileInfoThread fileInfoThread;
+ QList<FileProperty> data;
+ QHash<int, QByteArray> roleNames;
+ QQuickFolderListModel::SortField sortField;
+ QStringList nameFilters;
+ bool sortReversed;
+ bool showDirs;
+ bool showDirsFirst;
+ bool showDots;
+ bool showOnlyReadable;
+
+ ~QQuickFolderListModelPrivate() {}
+ void init();
+ void updateSorting();
+
+ // private slots
+ void _q_directoryChanged(const QString &directory, const QList<FileProperty> &list);
+ void _q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex);
+ void _q_sortFinished(const QList<FileProperty> &list);
+};
+
+
+void QQuickFolderListModelPrivate::init()
+{
+ Q_Q(QQuickFolderListModel);
+ qRegisterMetaType<QList<FileProperty> >("QList<FileProperty>");
+ q->connect(&fileInfoThread, SIGNAL(directoryChanged(QString, QList<FileProperty>)),
+ q, SLOT(_q_directoryChanged(QString, QList<FileProperty>)));
+ q->connect(&fileInfoThread, SIGNAL(directoryUpdated(QString, QList<FileProperty>, int, int)),
+ q, SLOT(_q_directoryUpdated(QString, QList<FileProperty>, int, int)));
+ q->connect(&fileInfoThread, SIGNAL(sortFinished(QList<FileProperty>)),
+ q, SLOT(_q_sortFinished(QList<FileProperty>)));
+}
+
+
+void QQuickFolderListModelPrivate::updateSorting()
+{
+ Q_Q(QQuickFolderListModel);
+
+ QDir::SortFlags flags = 0;
+
+ switch (sortField) {
+ case QQuickFolderListModel::Unsorted:
+ flags |= QDir::Unsorted;
+ break;
+ case QQuickFolderListModel::Name:
+ flags |= QDir::Name;
+ break;
+ case QQuickFolderListModel::Time:
+ flags |= QDir::Time;
+ break;
+ case QQuickFolderListModel::Size:
+ flags |= QDir::Size;
+ break;
+ case QQuickFolderListModel::Type:
+ flags |= QDir::Type;
+ break;
+ default:
+ break;
+ }
+
+ emit q->layoutAboutToBeChanged();
+
+ if (sortReversed)
+ flags |= QDir::Reversed;
+
+ fileInfoThread.setSortFlags(flags);
+}
+
+void QQuickFolderListModelPrivate::_q_directoryChanged(const QString &directory, const QList<FileProperty> &list)
+{
+ Q_Q(QQuickFolderListModel);
+ Q_UNUSED(directory);
+
+ data = list;
+ q->endResetModel();
+ emit q->rowCountChanged();
+ emit q->folderChanged();
+}
+
+
+void QQuickFolderListModelPrivate::_q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex)
+{
+ Q_Q(QQuickFolderListModel);
+ Q_UNUSED(directory);
+
+ QModelIndex parent;
+ if (data.size() > list.size()) {
+ //File(s) removed. Since I do not know how many
+ //or where I need to update the whole list from the first item.
+ data = list;
+ q->beginRemoveRows(parent, fromIndex, toIndex);
+ q->endRemoveRows();
+ q->beginInsertRows(parent, fromIndex, list.size()-1);
+ q->endInsertRows();
+ emit q->rowCountChanged();
+ } else if (data.size() < list.size()) {
+ //qDebug() << "File added. FromIndex: " << fromIndex << " toIndex: " << toIndex << " list size: " << list.size();
+ //File(s) added. Calculate how many and insert
+ //from the first changed one.
+ toIndex = fromIndex + (list.size() - data.size()-1);
+ q->beginInsertRows(parent, fromIndex, toIndex);
+ q->endInsertRows();
+ data = list;
+ emit q->rowCountChanged();
+ QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0);
+ QModelIndex modelIndexTo = q->createIndex(toIndex, 0);
+ emit q->dataChanged(modelIndexFrom, modelIndexTo);
+ } else {
+ //qDebug() << "File has been updated";
+ QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0);
+ QModelIndex modelIndexTo = q->createIndex(toIndex, 0);
+ data = list;
+ emit q->dataChanged(modelIndexFrom, modelIndexTo);
+ }
+}
+
+void QQuickFolderListModelPrivate::_q_sortFinished(const QList<FileProperty> &list)
+{
+ Q_Q(QQuickFolderListModel);
+
+ QModelIndex parent;
+ q->beginRemoveRows(parent, 0, data.size()-1);
+ data.clear();
+ q->endRemoveRows();
+
+ q->beginInsertRows(parent, 0, list.size()-1);
+ data = list;
+ q->endInsertRows();
+}
+
+
+/*!
+ \qmlclass FolderListModel QQuickFolderListModel
+ \ingroup qml-working-with-data
+ \brief The FolderListModel provides a model of the contents of a file system folder.
+
+ FolderListModel provides access to information about the contents of a folder
+ in the local file system, exposing a list of files to views and other data components.
+
+ \note This type is made available by importing the \c Qt.labs.folderlistmodel module.
+ \e{Elements in the Qt.labs module are not guaranteed to remain compatible
+ in future versions.}
+
+ \bold{import Qt.labs.folderlistmodel 1.0}
+
+ The \l folder property specifies the folder to access. Information about the
+ files and directories in the folder is supplied via the model's interface.
+ Components access names and paths via the following roles:
+
+ \list
+ \o \c fileName
+ \o \c filePath
+ \o \c fileBaseName
+ \o \c fileSuffix
+ \o \c fileSize
+ \o \c fileModified
+ \o \c fileAccessed
+ \o \c fileIsDir
+ \endlist
+
+ Additionally a file entry can be differentiated from a folder entry via the
+ isFolder() method.
+
+ \section1 Filtering
+
+ Various properties can be set to filter the number of files and directories
+ exposed by the model.
+
+ The \l nameFilters property can be set to contain a list of wildcard filters
+ that are applied to names of files and directories, causing only those that
+ match the filters to be exposed.
+
+ Directories can be included or excluded using the \l showDirs property, and
+ navigation directories can also be excluded by setting the \l showDotAndDotDot
+ property to false.
+
+ It is sometimes useful to limit the files and directories exposed to those
+ that the user can access. The \l showOnlyReadable property can be set to
+ enable this feature.
+
+ \section1 Example Usage
+
+ The following example shows a FolderListModel being used to provide a list
+ of QML files in a \l ListView:
+
+ \snippet doc/src/snippets/qml/folderlistmodel.qml 0
+
+ \section1 Path Separators
+
+ Qt uses "/" as a universal directory separator in the same way that "/" is
+ used as a path separator in URLs. If you always use "/" as a directory
+ separator, Qt will translate your paths to conform to the underlying
+ operating system.
+
+ \sa {QML Data Models}
+*/
+
+QQuickFolderListModel::QQuickFolderListModel(QObject *parent)
+ : QAbstractListModel(parent), d_ptr(new QQuickFolderListModelPrivate(this))
+{
+ Q_D(QQuickFolderListModel);
+ d->roleNames[FileNameRole] = "fileName";
+ d->roleNames[FilePathRole] = "filePath";
+ d->roleNames[FileBaseNameRole] = "fileBaseName";
+ d->roleNames[FileSuffixRole] = "fileSuffix";
+ d->roleNames[FileSizeRole] = "fileSize";
+ d->roleNames[FileLastModifiedRole] = "fileModified";
+ d->roleNames[FileLastReadRole] = "fileAccessed";
+ d->roleNames[FileIsDirRole] = "fileIsDir";
+ setRoleNames(d->roleNames);
+
+ d->init();
+}
+
+QQuickFolderListModel::~QQuickFolderListModel()
+{
+}
+
+QVariant QQuickFolderListModel::data(const QModelIndex &index, int role) const
+{
+ Q_D(const QQuickFolderListModel);
+ QVariant rv;
+
+ if (index.row() >= d->data.size())
+ return rv;
+
+ switch (role)
+ {
+ case FileNameRole:
+ rv = d->data.at(index.row()).fileName();
+ break;
+ case FilePathRole:
+ rv = d->data.at(index.row()).filePath();
+ break;
+ case FileBaseNameRole:
+ rv = d->data.at(index.row()).baseName();
+ break;
+ case FileSuffixRole:
+ rv = d->data.at(index.row()).suffix();
+ break;
+ case FileSizeRole:
+ rv = d->data.at(index.row()).size();
+ break;
+ case FileLastModifiedRole:
+ rv = d->data.at(index.row()).lastModified().date().toString(Qt::ISODate) + " " + d->data.at(index.row()).lastModified().time().toString();
+ break;
+ case FileLastReadRole:
+ rv = d->data.at(index.row()).lastRead().date().toString(Qt::ISODate) + " " + d->data.at(index.row()).lastRead().time().toString();
+ break;
+ case FileIsDirRole:
+ rv = d->data.at(index.row()).isDir();
+ break;
+ default:
+ break;
+ }
+ return rv;
+}
+
+/*!
+ \qmlproperty int FolderListModel::count
+
+ Returns the number of items in the current folder that match the
+ filter criteria.
+*/
+int QQuickFolderListModel::rowCount(const QModelIndex &parent) const
+{
+ Q_D(const QQuickFolderListModel);
+ Q_UNUSED(parent);
+ return d->data.size();
+}
+
+QModelIndex QQuickFolderListModel::index(int row, int , const QModelIndex &) const
+{
+ return createIndex(row, 0);
+}
+
+/*!
+ \qmlproperty string FolderListModel::folder
+
+ The \a folder property holds a URL for the folder that the model is
+ currently providing.
+
+ The value is a URL expressed as a string, and must be a \c file: or \c qrc:
+ URL, or a relative URL.
+
+ By default, the value is an invalid URL.
+*/
+QUrl QQuickFolderListModel::folder() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->currentDir;
+}
+
+void QQuickFolderListModel::setFolder(const QUrl &folder)
+{
+ Q_D(QQuickFolderListModel);
+
+ if (folder == d->currentDir)
+ return;
+
+ QString resolvedPath = QDir::cleanPath(folder.path());
+
+ beginResetModel();
+
+ //Remove the old path for the file system watcher
+ if (!d->currentDir.isEmpty())
+ d->fileInfoThread.removePath(d->currentDir.path());
+
+ d->currentDir = folder;
+
+ QFileInfo info(resolvedPath);
+ if (!info.exists() || !info.isDir()) {
+ d->data.clear();
+ endResetModel();
+ emit rowCountChanged();
+ return;
+ }
+
+ d->fileInfoThread.setPath(resolvedPath);
+}
+
+
+/*!
+ \qmlproperty string QQuickFolderListModel::rootFolder
+
+ When the rootFolder is set, then this folder will
+ be threated as the root in the file system, so that
+ you can only travers sub folders from this rootFolder.
+*/
+QUrl QQuickFolderListModel::rootFolder() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->rootDir;
+}
+
+void QQuickFolderListModel::setRootFolder(const QUrl &path)
+{
+ Q_D(QQuickFolderListModel);
+
+ if (path.isEmpty())
+ return;
+
+ QString resolvedPath = QDir::cleanPath(path.path());
+
+ QFileInfo info(resolvedPath);
+ if (!info.exists() || !info.isDir())
+ return;
+
+ d->fileInfoThread.setRootPath(resolvedPath);
+ d->rootDir = path;
+}
+
+
+/*!
+ \qmlproperty url FolderListModel::parentFolder
+
+ Returns the URL of the parent of of the current \l folder.
+*/
+QUrl QQuickFolderListModel::parentFolder() const
+{
+ Q_D(const QQuickFolderListModel);
+
+ QString localFile = d->currentDir.toLocalFile();
+ if (!localFile.isEmpty()) {
+ QDir dir(localFile);
+#if defined(Q_OS_WIN)
+ if (dir.isRoot())
+ dir.setPath("");
+ else
+#endif
+ dir.cdUp();
+ localFile = dir.path();
+ } else {
+ int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/'));
+ if (pos == -1)
+ return QUrl();
+ localFile = d->currentDir.path().left(pos);
+ }
+ return QUrl::fromLocalFile(localFile);
+}
+
+/*!
+ \qmlproperty list<string> FolderListModel::nameFilters
+
+ The \a nameFilters property contains a list of file name filters.
+ The filters may include the ? and * wildcards.
+
+ The example below filters on PNG and JPEG files:
+
+ \qml
+ FolderListModel {
+ nameFilters: [ "*.png", "*.jpg" ]
+ }
+ \endqml
+
+ \note Directories are not excluded by filters.
+*/
+QStringList QQuickFolderListModel::nameFilters() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->nameFilters;
+}
+
+void QQuickFolderListModel::setNameFilters(const QStringList &filters)
+{
+ Q_D(QQuickFolderListModel);
+ d->fileInfoThread.setNameFilters(filters);
+ d->nameFilters = filters;
+}
+
+void QQuickFolderListModel::classBegin()
+{
+}
+
+void QQuickFolderListModel::componentComplete()
+{
+ Q_D(QQuickFolderListModel);
+
+ if (!d->currentDir.isValid() || d->currentDir.toLocalFile().isEmpty() || !QDir().exists(d->currentDir.toLocalFile()))
+ setFolder(QUrl(QLatin1String("file://")+QDir::currentPath()));
+}
+
+/*!
+ \qmlproperty enumeration FolderListModel::sortField
+
+ The \a sortField property contains field to use for sorting. sortField
+ may be one of:
+ \list
+ \o Unsorted - no sorting is applied.
+ \o Name - sort by filename
+ \o LastModified - sort by time modified
+ \o Size - sort by file size
+ \o Type - sort by file type (extension)
+ \endlist
+
+ \sa sortReversed
+*/
+QQuickFolderListModel::SortField QQuickFolderListModel::sortField() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->sortField;
+}
+
+void QQuickFolderListModel::setSortField(SortField field)
+{
+ Q_D(QQuickFolderListModel);
+ if (field != d->sortField) {
+ d->sortField = field;
+ d->updateSorting();
+ }
+}
+
+int QQuickFolderListModel::roleFromString(const QString &roleName) const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->roleNames.key(roleName.toLatin1(), -1);
+}
+
+/*!
+ \qmlproperty bool FolderListModel::sortReversed
+
+ If set to true, reverses the sort order. The default is false.
+
+ \sa sortField
+*/
+bool QQuickFolderListModel::sortReversed() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->sortReversed;
+}
+
+void QQuickFolderListModel::setSortReversed(bool rev)
+{
+ Q_D(QQuickFolderListModel);
+
+ if (rev != d->sortReversed) {
+ d->sortReversed = rev;
+ d->updateSorting();
+ }
+}
+
+/*!
+ \qmlmethod bool FolderListModel::isFolder(int index)
+
+ Returns true if the entry \a index is a folder; otherwise
+ returns false.
+*/
+bool QQuickFolderListModel::isFolder(int index) const
+{
+ if (index != -1) {
+ QModelIndex idx = createIndex(index, 0);
+ if (idx.isValid()) {
+ QVariant var = data(idx, FileIsDirRole);
+ if (var.isValid())
+ return var.toBool();
+ }
+ }
+ return false;
+}
+
+/*!
+ \qmlproperty bool FolderListModel::showDirs
+
+ If true, directories are included in the model; otherwise only files
+ are included.
+
+ By default, this property is true.
+
+ Note that the nameFilters are not applied to directories.
+
+ \sa showDotAndDotDot
+*/
+bool QQuickFolderListModel::showDirs() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->showDirs;
+}
+
+void QQuickFolderListModel::setShowDirs(bool on)
+{
+ Q_D(QQuickFolderListModel);
+
+ d->fileInfoThread.setShowDirs(on);
+ d->showDirs = on;
+}
+
+/*!
+ \qmlproperty bool FolderListModel::showDirsFirst
+
+ If true, if directories are included in the model they will
+ always be shown first, then the files.
+
+ By default, this property is false.
+
+*/
+bool QQuickFolderListModel::showDirsFirst() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->showDirsFirst;
+}
+
+void QQuickFolderListModel::setShowDirsFirst(bool on)
+{
+ Q_D(QQuickFolderListModel);
+
+ d->fileInfoThread.setShowDirsFirst(on);
+ d->showDirsFirst = on;
+}
+
+
+/*!
+ \qmlproperty bool FolderListModel::showDotAndDotDot
+
+ If true, the "." and ".." directories are included in the model; otherwise
+ they are excluded.
+
+ By default, this property is false.
+
+ \sa showDirs
+*/
+bool QQuickFolderListModel::showDotAndDotDot() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->showDots;
+}
+
+void QQuickFolderListModel::setShowDotAndDotDot(bool on)
+{
+ Q_D(QQuickFolderListModel);
+
+ if (on != d->showDots) {
+ d->fileInfoThread.setShowDotDot(on);
+ }
+}
+
+/*!
+ \qmlproperty bool FolderListModel::showOnlyReadable
+
+ If true, only readable files and directories are shown; otherwise all files
+ and directories are shown.
+
+ By default, this property is false.
+
+ \sa showDirs
+*/
+bool QQuickFolderListModel::showOnlyReadable() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->showOnlyReadable;
+}
+
+void QQuickFolderListModel::setShowOnlyReadable(bool on)
+{
+ Q_D(QQuickFolderListModel);
+
+ if (on != d->showOnlyReadable) {
+ d->fileInfoThread.setShowOnlyReadable(on);
+ }
+}
+
+/*!
+ \qmlmethod QVariant QQuickFolderListModel::get(int idx, const QString &property) const
+
+ Get the folder property for the given index. The following properties
+ are available.
+
+ \list
+ \o \c fileName
+ \o \c filePath
+ \o \c fileBaseName
+ \o \c fileSuffix
+ \o \c fileSize
+ \o \c fileModified
+ \o \c fileAccessed
+ \o \c fileIsDir
+ \endlist
+*/
+QVariant QQuickFolderListModel::get(int idx, const QString &property) const
+{
+ int role = roleFromString(property);
+ if (role >= 0 && idx >= 0)
+ return data(index(idx, 0), role);
+ else
+ return QVariant();
+}
+
+#include "moc_qquickfolderlistmodel.cpp"
+
+//![code]
+QT_END_NAMESPACE
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.h b/src/imports/folderlistmodel/qquickfolderlistmodel.h
new file mode 100644
index 0000000000..830a30b146
--- /dev/null
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKFOLDERLISTMODEL_H
+#define QQUICKFOLDERLISTMODEL_H
+
+#include <qqml.h>
+#include <QStringList>
+#include <QUrl>
+#include <QAbstractListModel>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlContext;
+class QModelIndex;
+
+class QQuickFolderListModelPrivate;
+
+//![class begin]
+class QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+//![class begin]
+
+//![class props]
+ Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
+ Q_PROPERTY(QUrl rootFolder READ rootFolder WRITE setRootFolder)
+ Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged)
+ Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
+ Q_PROPERTY(SortField sortField READ sortField WRITE setSortField)
+ Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed)
+ Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs)
+ Q_PROPERTY(bool showDirsFirst READ showDirsFirst WRITE setShowDirsFirst)
+ Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
+ Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
+ Q_PROPERTY(int count READ count NOTIFY rowCountChanged)
+//![class props]
+
+//![abslistmodel]
+public:
+ QQuickFolderListModel(QObject *parent = 0);
+ ~QQuickFolderListModel();
+
+ enum Roles {
+ FileNameRole = Qt::UserRole + 1,
+ FilePathRole = Qt::UserRole + 2,
+ FileBaseNameRole = Qt::UserRole + 3,
+ FileSuffixRole = Qt::UserRole + 4,
+ FileSizeRole = Qt::UserRole + 5,
+ FileLastModifiedRole = Qt::UserRole + 6,
+ FileLastReadRole = Qt::UserRole +7,
+ FileIsDirRole = Qt::UserRole + 8
+ };
+
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+//![abslistmodel]
+
+//![count]
+ int count() const { return rowCount(QModelIndex()); }
+//![count]
+
+//![prop funcs]
+ QUrl folder() const;
+ void setFolder(const QUrl &folder);
+ QUrl rootFolder() const;
+ void setRootFolder(const QUrl &path);
+
+ QUrl parentFolder() const;
+
+ QStringList nameFilters() const;
+ void setNameFilters(const QStringList &filters);
+
+ enum SortField { Unsorted, Name, Time, Size, Type };
+ SortField sortField() const;
+ void setSortField(SortField field);
+ Q_ENUMS(SortField)
+
+ bool sortReversed() const;
+ void setSortReversed(bool rev);
+
+ bool showDirs() const;
+ void setShowDirs(bool showDirs);
+ bool showDirsFirst() const;
+ void setShowDirsFirst(bool showDirsFirst);
+ bool showDotAndDotDot() const;
+ void setShowDotAndDotDot(bool on);
+ bool showOnlyReadable() const;
+ void setShowOnlyReadable(bool on);
+//![prop funcs]
+
+ Q_INVOKABLE bool isFolder(int index) const;
+ Q_INVOKABLE QVariant get(int idx, const QString &property) const;
+
+//![parserstatus]
+ virtual void classBegin();
+ virtual void componentComplete();
+//![parserstatus]
+
+ int roleFromString(const QString &roleName) const;
+
+//![notifier]
+Q_SIGNALS:
+ void folderChanged();
+ void rowCountChanged() const;
+//![notifier]
+
+//![class end]
+
+
+private:
+ Q_DISABLE_COPY(QQuickFolderListModel)
+ Q_DECLARE_PRIVATE(QQuickFolderListModel)
+ QScopedPointer<QQuickFolderListModelPrivate> d_ptr;
+
+ Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &directory, const QList<FileProperty> &list))
+ Q_PRIVATE_SLOT(d_func(), void _q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex))
+ Q_PRIVATE_SLOT(d_func(), void _q_sortFinished(const QList<FileProperty> &list))
+};
+//![class end]
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQUICKFOLDERLISTMODEL_H
diff --git a/src/imports/localstorage/localstorage.pro b/src/imports/localstorage/localstorage.pro
index 5164e8870d..fa1718dd68 100644
--- a/src/imports/localstorage/localstorage.pro
+++ b/src/imports/localstorage/localstorage.pro
@@ -2,13 +2,13 @@ TARGET = qmllocalstorageplugin
TARGETPATH = QtQuick/LocalStorage
include(../qimportbase.pri)
-QT += sql declarative declarative-private v8-private core-private
+QT += sql qml qml-private v8-private core-private
SOURCES += plugin.cpp
OTHER_FILES += localstorage.json
-DESTDIR = $$QT.declarative.imports/$$TARGETPATH
+DESTDIR = $$QT.qml.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
qmldir.files += $$PWD/qmldir
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 0ab47c1428..7c55225ed1 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -39,9 +39,9 @@
**
****************************************************************************/
#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <private/qdeclarativeengine_p.h>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <private/qqmlengine_p.h>
#include <QDebug>
#include <private/qv8engine_p.h>
#include <QtSql/qsqldatabase.h>
@@ -83,18 +83,18 @@
return; \
}
-class QDeclarativeSqlDatabaseData : public QV8Engine::Deletable
+class QQmlSqlDatabaseData : public QV8Engine::Deletable
{
public:
- QDeclarativeSqlDatabaseData(QV8Engine *engine);
- ~QDeclarativeSqlDatabaseData();
+ QQmlSqlDatabaseData(QV8Engine *engine);
+ ~QQmlSqlDatabaseData();
v8::Persistent<v8::Function> constructor;
v8::Persistent<v8::Function> queryConstructor;
v8::Persistent<v8::Function> rowsConstructor;
};
-V8_DEFINE_EXTENSION(QDeclarativeSqlDatabaseData, databaseData)
+V8_DEFINE_EXTENSION(QQmlSqlDatabaseData, databaseData)
class QV8SqlDatabaseResource : public QV8ObjectResource
{
@@ -167,7 +167,7 @@ static void qmlsqldatabase_rows_setForwardOnly(v8::Local<v8::String> /* property
r->query.setForwardOnly(value->BooleanValue());
}
-QDeclarativeSqlDatabaseData::~QDeclarativeSqlDatabaseData()
+QQmlSqlDatabaseData::~QQmlSqlDatabaseData()
{
qPersistentDispose(constructor);
qPersistentDispose(queryConstructor);
@@ -239,14 +239,14 @@ static v8::Handle<v8::Value> qmlsqldatabase_executeSql(const v8::Arguments& args
QV8Engine *engine = r->engine;
if (!r->inTransaction)
- V8THROW_SQL(SQLEXCEPTION_DATABASE_ERR,QDeclarativeEngine::tr("executeSql called outside transaction()"));
+ V8THROW_SQL(SQLEXCEPTION_DATABASE_ERR,QQmlEngine::tr("executeSql called outside transaction()"));
QSqlDatabase db = r->database;
QString sql = engine->toString(args[0]);
if (r->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) {
- V8THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QDeclarativeEngine::tr("Read-only Transaction"));
+ V8THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction"));
}
QSqlQuery query(db);
@@ -316,7 +316,7 @@ static v8::Handle<v8::Value> qmlsqldatabase_changeVersion(const v8::Arguments& a
v8::Handle<v8::Value> callback = args[2];
if (from_version != r->version)
- V8THROW_SQL(SQLEXCEPTION_VERSION_ERR, QDeclarativeEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(r->version));
+ V8THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(r->version));
v8::Local<v8::Object> instance = databaseData(engine)->queryConstructor->NewInstance();
QV8SqlDatabaseResource *r2 = new QV8SqlDatabaseResource(engine);
@@ -341,7 +341,7 @@ static v8::Handle<v8::Value> qmlsqldatabase_changeVersion(const v8::Arguments& a
return v8::Handle<v8::Value>();
} else if (!db.commit()) {
db.rollback();
- V8THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QDeclarativeEngine::tr("SQL transaction failed"));
+ V8THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QQmlEngine::tr("SQL transaction failed"));
} else {
ok = true;
}
@@ -369,7 +369,7 @@ static v8::Handle<v8::Value> qmlsqldatabase_transaction_shared(const v8::Argumen
QV8Engine *engine = r->engine;
if (args.Length() == 0 || !args[0]->IsFunction())
- V8THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QDeclarativeEngine::tr("transaction: missing callback"));
+ V8THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QQmlEngine::tr("transaction: missing callback"));
QSqlDatabase db = r->database;
v8::Handle<v8::Function> callback = v8::Handle<v8::Function>::Cast(args[0]);
@@ -410,7 +410,7 @@ static v8::Handle<v8::Value> qmlsqldatabase_read_transaction(const v8::Arguments
return qmlsqldatabase_transaction_shared(args, true);
}
-QDeclarativeSqlDatabaseData::QDeclarativeSqlDatabaseData(QV8Engine *engine)
+QQmlSqlDatabaseData::QQmlSqlDatabaseData(QV8Engine *engine)
{
{
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
@@ -460,7 +460,7 @@ through the data.
These databases are user-specific and QML-specific, but accessible to all QML applications.
They are stored in the \c Databases subdirectory
-of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases.
+of QQmlEngine::offlineStoragePath(), currently as SQLite databases.
Database connections are automatically closed during Javascript garbage collection.
@@ -549,7 +549,7 @@ public:
~QQuickLocalStorage() {
}
- Q_INVOKABLE void openDatabaseSync(QDeclarativeV8Function* args);
+ Q_INVOKABLE void openDatabaseSync(QQmlV8Function* args);
};
/*!
@@ -563,7 +563,7 @@ public:
* \c callback is an optional parameter, which is invoked if the database has not yet been created.
* \return the database object
*/
-void QQuickLocalStorage::openDatabaseSync(QDeclarativeV8Function *args)
+void QQuickLocalStorage::openDatabaseSync(QQmlV8Function *args)
{
#ifndef QT_NO_SETTINGS
QV8Engine *engine = args->engine();
@@ -592,7 +592,7 @@ void QQuickLocalStorage::openDatabaseSync(QDeclarativeV8Function *args)
database = QSqlDatabase::database(dbid);
version = ini.value(QLatin1String("Version")).toString();
if (version != dbversion && !dbversion.isEmpty() && !version.isEmpty())
- V8THROW_SQL_VOID(SQLEXCEPTION_VERSION_ERR, QDeclarativeEngine::tr("SQL: database version mismatch"));
+ V8THROW_SQL_VOID(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("SQL: database version mismatch"));
} else {
created = !QFile::exists(basename+QLatin1String(".sqlite"));
database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid);
@@ -607,7 +607,7 @@ void QQuickLocalStorage::openDatabaseSync(QDeclarativeV8Function *args)
} else {
if (!dbversion.isEmpty() && ini.value(QLatin1String("Version")) != dbversion) {
// Incompatible
- V8THROW_SQL_VOID(SQLEXCEPTION_VERSION_ERR,QDeclarativeEngine::tr("SQL: database version mismatch"));
+ V8THROW_SQL_VOID(SQLEXCEPTION_VERSION_ERR,QQmlEngine::tr("SQL: database version mismatch"));
}
version = ini.value(QLatin1String("Version")).toString();
}
@@ -639,7 +639,7 @@ void QQuickLocalStorage::openDatabaseSync(QDeclarativeV8Function *args)
#endif // QT_NO_SETTINGS
}
-static QObject *module_api_factory(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
+static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
@@ -648,13 +648,13 @@ static QObject *module_api_factory(QDeclarativeEngine *engine, QJSEngine *script
return api;
}
-class QDeclarativeLocalStoragePlugin : public QDeclarativeExtensionPlugin
+class QQmlLocalStoragePlugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "localstorage.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "localstorage.json")
public:
- QDeclarativeLocalStoragePlugin()
+ QQmlLocalStoragePlugin()
{
}
diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri
index 110d145e94..ab54e4b1b9 100644
--- a/src/imports/qimportbase.pri
+++ b/src/imports/qimportbase.pri
@@ -14,7 +14,7 @@ isEmpty(TARGET) {
QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir
copy2build.input = QMLDIRFILE
-copy2build.output = $$QT.declarative.imports/$$TARGETPATH/qmldir
+copy2build.output = $$QT.qml.imports/$$TARGETPATH/qmldir
!contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS
copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
copy2build.name = COPY ${QMAKE_FILE_IN}
diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp
index 808d5196b2..2cb70a4fd3 100644
--- a/src/imports/qtquick2/plugin.cpp
+++ b/src/imports/qtquick2/plugin.cpp
@@ -39,23 +39,23 @@
**
****************************************************************************/
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtQml/qqmlextensionplugin.h>
#include <private/qtquick2_p.h>
QT_BEGIN_NAMESPACE
//![class decl]
-class QtQuick2Plugin : public QDeclarativeExtensionPlugin
+class QtQuick2Plugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface/1.0")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
virtual void registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick"));
Q_UNUSED(uri);
- QDeclarativeQtQuick2Module::defineModule();
+ QQmlQtQuick2Module::defineModule();
}
};
//![class decl]
diff --git a/src/imports/qtquick2/qtquick2.pro b/src/imports/qtquick2/qtquick2.pro
index 3f76abd87f..3a95c5fd21 100644
--- a/src/imports/qtquick2/qtquick2.pro
+++ b/src/imports/qtquick2/qtquick2.pro
@@ -5,12 +5,12 @@ include(../qimportbase.pri)
SOURCES += \
plugin.cpp
-QT += quick-private declarative-private
+QT += quick-private qml-private
OTHER_FILES += \
qmldir
-DESTDIR = $$QT.declarative.imports/$$TARGETPATH
+DESTDIR = $$QT.qml.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
qmldir.files += $$PWD/qmldir
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp
index ec32d7c9ab..6473d216c7 100644
--- a/src/imports/testlib/main.cpp
+++ b/src/imports/testlib/main.cpp
@@ -39,15 +39,15 @@
**
****************************************************************************/
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtDeclarative/qjsengine.h>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qjsvalue.h>
+#include <QtQml/qjsengine.h>
#include "QtQuickTest/private/quicktestresult_p.h"
#include "QtQuickTest/private/quicktestevent_p.h"
#include "private/qtestoptions_p.h"
#include "QtQuick/qquickitem.h"
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
+#include <QtQml/private/qqmlengine_p.h>
QML_DECLARE_TYPE(QuickTestResult)
QML_DECLARE_TYPE(QuickTestEvent)
@@ -81,15 +81,15 @@ Q_SIGNALS:
void wrapperChanged();
public Q_SLOTS:
- QDeclarativeV8Handle typeName(const QVariant& v) const
+ QQmlV8Handle typeName(const QVariant& v) const
{
QString name(v.typeName());
//qDebug() << "type:" << name << " string value:" << v.toString() << " value:" << v;
if (v.canConvert<QObject*>()) {
- QDeclarativeType *type = 0;
+ QQmlType *type = 0;
const QMetaObject *mo = v.value<QObject*>()->metaObject();
while (!type && mo) {
- type = QDeclarativeMetaType::qmlType(mo);
+ type = QQmlMetaType::qmlType(mo);
mo = mo->superClass();
}
if (type) {
@@ -97,22 +97,22 @@ public Q_SLOTS:
}
}
- return QDeclarativeV8Handle::fromHandle(v8::String::New(name.toUtf8()));
+ return QQmlV8Handle::fromHandle(v8::String::New(name.toUtf8()));
}
bool compare(const QVariant& act, const QVariant& exp) const {
return act == exp;
}
- QDeclarativeV8Handle callerFile(int frameIndex = 0) const
+ QQmlV8Handle callerFile(int frameIndex = 0) const
{
v8::Local<v8::StackTrace> stacks = v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed);
int count = stacks->GetFrameCount();
if (count >= frameIndex + 1) {
v8::Local<v8::StackFrame> frame = stacks->GetFrame(frameIndex + 1);
- return QDeclarativeV8Handle::fromHandle(frame->GetScriptNameOrSourceURL());
+ return QQmlV8Handle::fromHandle(frame->GetScriptNameOrSourceURL());
}
- return QDeclarativeV8Handle();
+ return QQmlV8Handle();
}
int callerLine(int frameIndex = 0) const
{
@@ -132,10 +132,10 @@ QML_DECLARE_TYPE(QuickTestUtil)
QT_BEGIN_NAMESPACE
-class QTestQmlModule : public QDeclarativeExtensionPlugin
+class QTestQmlModule : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "testlib.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "testlib.json")
public:
virtual void registerTypes(const char *uri)
@@ -146,7 +146,7 @@ public:
qmlRegisterType<QuickTestUtil>(uri,1,0,"TestUtil");
}
- void initializeEngine(QDeclarativeEngine *, const char *)
+ void initializeEngine(QQmlEngine *, const char *)
{
}
};
diff --git a/src/imports/testlib/signalspy.h b/src/imports/testlib/signalspy.h
index 6b5166d8e0..6542203ce4 100644
--- a/src/imports/testlib/signalspy.h
+++ b/src/imports/testlib/signalspy.h
@@ -44,20 +44,20 @@
// This is a dummy header for defining the interface of "SignalSpy.qml" to qdoc.
-#include <QtDeclarative/qdeclarativeitem.h>
+#include <QtQuick/qquickitem.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class SignalSpy : public QDeclarativeItem
+class SignalSpy : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString signalName READ signalName WRITE signalName NOTIFY signalNameChanged)
Q_PROPERTY(int count READ count countChanged)
public:
- SignalSpy(QDeclarativeItem *parent) : QDeclarativeItem(parent) {}
+ SignalSpy(QQuickItem *parent) : QQuickItem(parent) {}
~SignalSpy()
QObject *target() const;
diff --git a/src/imports/testlib/testcase.h b/src/imports/testlib/testcase.h
index 1793cca0f2..e7758ec9df 100644
--- a/src/imports/testlib/testcase.h
+++ b/src/imports/testlib/testcase.h
@@ -44,13 +44,13 @@
// This is a dummy header for defining the interface of "TestCase.qml" to qdoc.
-#include <QtDeclarative/qdeclarativeitem.h>
+#include <QtQuick/qquickitem.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class TestCase : public QDeclarativeItem
+class TestCase : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
@@ -60,7 +60,7 @@ class TestCase : public QDeclarativeItem
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
Q_PROPERTY(bool windowShown READ windowShown NOTIFY windowShownChanged)
public:
- TestCase(QDeclarativeItem *parent) : QDeclarativeItem(parent) {}
+ TestCase(QQuickItem *parent) : QQuickItem(parent) {}
~TestCase()
QString name() const;
diff --git a/src/imports/testlib/testlib.pro b/src/imports/testlib/testlib.pro
index 7e8f601468..dfb23cea0c 100644
--- a/src/imports/testlib/testlib.pro
+++ b/src/imports/testlib/testlib.pro
@@ -4,13 +4,13 @@ include(../qimportbase.pri)
CONFIG += qt plugin
-QT += declarative quick qmltest qmltest-private v8-private declarative-private core-private testlib
+QT += qml quick qmltest qmltest-private v8-private qml-private core-private testlib
SOURCES += main.cpp
OTHER_FILES += testlib.json
-DESTDIR = $$QT.declarative.imports/$$TARGETPATH
+DESTDIR = $$QT.qml.imports/$$TARGETPATH
target.path += $$[QT_INSTALL_IMPORTS]/QtTest
OTHER_IMPORT_FILES = \
@@ -24,7 +24,7 @@ otherImportFiles.files += $$OTHER_IMPORT_FILES
otherImportFiles.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
copy2build.input = OTHER_IMPORT_FILES
-copy2build.output = $$QT.declarative.imports/$$TARGETPATH/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
+copy2build.output = $$QT.qml.imports/$$TARGETPATH/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
INSTALLS += target otherImportFiles
diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp
index 07f59b846a..58253492e1 100644
--- a/src/imports/xmllistmodel/plugin.cpp
+++ b/src/imports/xmllistmodel/plugin.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -39,24 +39,24 @@
**
****************************************************************************/
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
-#include "qdeclarativexmllistmodel_p.h"
+#include "qqmlxmllistmodel_p.h"
QT_BEGIN_NAMESPACE
-class QmlXmlListModelPlugin : public QDeclarativeExtensionPlugin
+class QmlXmlListModelPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "xmllistmodel.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "xmllistmodel.json")
public:
virtual void registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.XmlListModel"));
- qmlRegisterType<QDeclarativeXmlListModel>(uri,2,0,"XmlListModel");
- qmlRegisterType<QDeclarativeXmlListModelRole>(uri,2,0,"XmlRole");
+ qmlRegisterType<QQuickXmlListModel>(uri,2,0,"XmlListModel");
+ qmlRegisterType<QQuickXmlListModelRole>(uri,2,0,"XmlRole");
}
};
diff --git a/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp b/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp
deleted file mode 100644
index db7fec2c97..0000000000
--- a/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp
+++ /dev/null
@@ -1,1160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativexmllistmodel_p.h"
-
-#include <qdeclarativecontext.h>
-#include <private/qdeclarativeengine_p.h>
-
-#include <QDebug>
-#include <QStringList>
-#include <QMap>
-#include <QThread>
-#include <QXmlQuery>
-#include <QXmlResultItems>
-#include <QXmlNodeModelIndex>
-#include <QBuffer>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QTimer>
-#include <QMutex>
-
-#include <private/qobject_p.h>
-
-Q_DECLARE_METATYPE(QDeclarativeXmlQueryResult)
-
-QT_BEGIN_NAMESPACE
-
-
-typedef QPair<int, int> QDeclarativeXmlListRange;
-
-#define XMLLISTMODEL_CLEAR_ID 0
-
-/*!
- \qmlclass XmlRole QDeclarativeXmlListModelRole
- \inqmlmodule QtQuick 2
- \ingroup qml-working-with-data
- \brief The XmlRole element allows you to specify a role for an XmlListModel.
-
- \sa {QtDeclarative}
-*/
-
-/*!
- \qmlproperty string QtQuick2::XmlRole::name
-
- The name for the role. This name is used to access the model data for this role.
-
- For example, the following model has a role named "title", which can be accessed
- from the view's delegate:
-
- \qml
- XmlListModel {
- id: xmlModel
- // ...
- XmlRole {
- name: "title"
- query: "title/string()"
- }
- }
- \endqml
-
- \qml
- ListView {
- model: xmlModel
- delegate: Text { text: title }
- }
- \endqml
-*/
-
-/*!
- \qmlproperty string QtQuick2::XmlRole::query
- The relative XPath expression query for this role. The query must be relative; it cannot start
- with a '/'.
-
- For example, if there is an XML document like this:
-
- \quotefile doc/src/snippets/declarative/xmlrole.xml
- Here are some valid XPath expressions for XmlRole queries on this document:
-
- \snippet doc/src/snippets/declarative/xmlrole.qml 0
- \dots 4
- \snippet doc/src/snippets/declarative/xmlrole.qml 1
-
- See the \l{http://www.w3.org/TR/xpath20/}{W3C XPath 2.0 specification} for more information.
-*/
-
-/*!
- \qmlproperty bool QtQuick2::XmlRole::isKey
- Defines whether this is a key role.
- Key roles are used to to determine whether a set of values should
- be updated or added to the XML list model when XmlListModel::reload()
- is called.
-
- \sa XmlListModel
-*/
-
-struct XmlQueryJob
-{
- int queryId;
- QByteArray data;
- QString query;
- QString namespaces;
- QStringList roleQueries;
- QList<void*> roleQueryErrorId; // the ptr to send back if there is an error
- QStringList keyRoleQueries;
- QStringList keyRoleResultsCache;
- QString prefix;
-};
-
-
-class QDeclarativeXmlQueryEngine;
-class QDeclarativeXmlQueryThreadObject : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeXmlQueryThreadObject(QDeclarativeXmlQueryEngine *);
-
- void processJobs();
- virtual bool event(QEvent *e);
-
-private:
- QDeclarativeXmlQueryEngine *m_queryEngine;
-};
-
-
-class QDeclarativeXmlQueryEngine : public QThread
-{
- Q_OBJECT
-public:
- QDeclarativeXmlQueryEngine(QDeclarativeEngine *eng);
- ~QDeclarativeXmlQueryEngine();
-
- int doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarativeXmlListModelRole *>* roleObjects, QStringList keyRoleResultsCache);
- void abort(int id);
-
- void processJobs();
-
- static QDeclarativeXmlQueryEngine *instance(QDeclarativeEngine *engine);
-
-signals:
- void queryCompleted(const QDeclarativeXmlQueryResult &);
- void error(void*, const QString&);
-
-protected:
- void run();
-
-private:
- void processQuery(XmlQueryJob *job);
- void doQueryJob(XmlQueryJob *job, QDeclarativeXmlQueryResult *currentResult);
- void doSubQueryJob(XmlQueryJob *job, QDeclarativeXmlQueryResult *currentResult);
- void getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const;
- void addIndexToRangeList(QList<QDeclarativeXmlListRange> *ranges, int index) const;
-
- QMutex m_mutex;
- QDeclarativeXmlQueryThreadObject *m_threadObject;
- QList<XmlQueryJob> m_jobs;
- QSet<int> m_cancelledJobs;
- QAtomicInt m_queryIds;
-
- QDeclarativeEngine *m_engine;
- QObject *m_eventLoopQuitHack;
-
- static QHash<QDeclarativeEngine *,QDeclarativeXmlQueryEngine*> queryEngines;
- static QMutex queryEnginesMutex;
-};
-QHash<QDeclarativeEngine *,QDeclarativeXmlQueryEngine*> QDeclarativeXmlQueryEngine::queryEngines;
-QMutex QDeclarativeXmlQueryEngine::queryEnginesMutex;
-
-
-QDeclarativeXmlQueryThreadObject::QDeclarativeXmlQueryThreadObject(QDeclarativeXmlQueryEngine *e)
- : m_queryEngine(e)
-{
-}
-
-void QDeclarativeXmlQueryThreadObject::processJobs()
-{
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
-}
-
-bool QDeclarativeXmlQueryThreadObject::event(QEvent *e)
-{
- if (e->type() == QEvent::User) {
- m_queryEngine->processJobs();
- return true;
- } else {
- return QObject::event(e);
- }
-}
-
-
-
-QDeclarativeXmlQueryEngine::QDeclarativeXmlQueryEngine(QDeclarativeEngine *eng)
-: QThread(eng), m_threadObject(0), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1), m_engine(eng), m_eventLoopQuitHack(0)
-{
- qRegisterMetaType<QDeclarativeXmlQueryResult>("QDeclarativeXmlQueryResult");
-
- m_eventLoopQuitHack = new QObject;
- m_eventLoopQuitHack->moveToThread(this);
- connect(m_eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection);
- start(QThread::IdlePriority);
-}
-
-QDeclarativeXmlQueryEngine::~QDeclarativeXmlQueryEngine()
-{
- queryEnginesMutex.lock();
- queryEngines.remove(m_engine);
- queryEnginesMutex.unlock();
-
- m_eventLoopQuitHack->deleteLater();
- wait();
-}
-
-int QDeclarativeXmlQueryEngine::doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarativeXmlListModelRole *>* roleObjects, QStringList keyRoleResultsCache) {
- {
- QMutexLocker m1(&m_mutex);
- m_queryIds.ref();
- if (m_queryIds.load() <= 0)
- m_queryIds.store(1);
- }
-
- XmlQueryJob job;
- job.queryId = m_queryIds.load();
- job.data = data;
- job.query = QLatin1String("doc($src)") + query;
- job.namespaces = namespaces;
- job.keyRoleResultsCache = keyRoleResultsCache;
-
- for (int i=0; i<roleObjects->count(); i++) {
- if (!roleObjects->at(i)->isValid()) {
- job.roleQueries << QString();
- continue;
- }
- job.roleQueries << roleObjects->at(i)->query();
- job.roleQueryErrorId << static_cast<void*>(roleObjects->at(i));
- if (roleObjects->at(i)->isKey())
- job.keyRoleQueries << job.roleQueries.last();
- }
-
- {
- QMutexLocker ml(&m_mutex);
- m_jobs.append(job);
- if (m_threadObject)
- m_threadObject->processJobs();
- }
-
- return job.queryId;
-}
-
-void QDeclarativeXmlQueryEngine::abort(int id)
-{
- QMutexLocker ml(&m_mutex);
- if (id != -1)
- m_cancelledJobs.insert(id);
-}
-
-void QDeclarativeXmlQueryEngine::run()
-{
- m_mutex.lock();
- m_threadObject = new QDeclarativeXmlQueryThreadObject(this);
- m_mutex.unlock();
-
- processJobs();
- exec();
-
- delete m_threadObject;
- m_threadObject = 0;
-}
-
-void QDeclarativeXmlQueryEngine::processJobs()
-{
- QMutexLocker locker(&m_mutex);
-
- while (true) {
- if (m_jobs.isEmpty())
- return;
-
- XmlQueryJob currentJob = m_jobs.takeLast();
- while (m_cancelledJobs.remove(currentJob.queryId)) {
- if (m_jobs.isEmpty())
- return;
- currentJob = m_jobs.takeLast();
- }
-
- locker.unlock();
- processQuery(&currentJob);
- locker.relock();
- }
-}
-
-QDeclarativeXmlQueryEngine *QDeclarativeXmlQueryEngine::instance(QDeclarativeEngine *engine)
-{
- queryEnginesMutex.lock();
- QDeclarativeXmlQueryEngine *queryEng = queryEngines.value(engine);
- if (!queryEng) {
- queryEng = new QDeclarativeXmlQueryEngine(engine);
- queryEngines.insert(engine, queryEng);
- }
- queryEnginesMutex.unlock();
-
- return queryEng;
-}
-
-void QDeclarativeXmlQueryEngine::processQuery(XmlQueryJob *job)
-{
- QDeclarativeXmlQueryResult result;
- result.queryId = job->queryId;
- doQueryJob(job, &result);
- doSubQueryJob(job, &result);
-
- {
- QMutexLocker ml(&m_mutex);
- if (m_cancelledJobs.contains(job->queryId)) {
- m_cancelledJobs.remove(job->queryId);
- } else {
- emit queryCompleted(result);
- }
- }
-}
-
-void QDeclarativeXmlQueryEngine::doQueryJob(XmlQueryJob *currentJob, QDeclarativeXmlQueryResult *currentResult)
-{
- Q_ASSERT(currentJob->queryId != -1);
-
- QString r;
- QXmlQuery query;
- QBuffer buffer(&currentJob->data);
- buffer.open(QIODevice::ReadOnly);
- query.bindVariable(QLatin1String("src"), &buffer);
- query.setQuery(currentJob->namespaces + currentJob->query);
- query.evaluateTo(&r);
-
- //always need a single root element
- QByteArray xml = "<dummy:items xmlns:dummy=\"http://qtsotware.com/dummy\">\n" + r.toUtf8() + "</dummy:items>";
- QBuffer b(&xml);
- b.open(QIODevice::ReadOnly);
-
- QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + currentJob->namespaces;
- QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
- currentJob->query.mid(currentJob->query.lastIndexOf(QLatin1Char('/')));
-
- //figure out how many items we are dealing with
- int count = -1;
- {
- QXmlResultItems result;
- QXmlQuery countquery;
- countquery.bindVariable(QLatin1String("inputDocument"), &b);
- countquery.setQuery(namespaces + QLatin1String("count(") + prefix + QLatin1Char(')'));
- countquery.evaluateTo(&result);
- QXmlItem item(result.next());
- if (item.isAtomicValue())
- count = item.toAtomicValue().toInt();
- }
-
- currentJob->data = xml;
- currentJob->prefix = namespaces + prefix + QLatin1Char('/');
- currentResult->size = (count > 0 ? count : 0);
-}
-
-void QDeclarativeXmlQueryEngine::getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const
-{
- const QStringList &keysQueries = currentJob.keyRoleQueries;
- QString keysQuery;
- if (keysQueries.count() == 1)
- keysQuery = currentJob.prefix + keysQueries[0];
- else if (keysQueries.count() > 1)
- keysQuery = currentJob.prefix + QLatin1String("concat(") + keysQueries.join(QLatin1String(",")) + QLatin1String(")");
-
- if (!keysQuery.isEmpty()) {
- query->setQuery(keysQuery);
- QXmlResultItems resultItems;
- query->evaluateTo(&resultItems);
- QXmlItem item(resultItems.next());
- while (!item.isNull()) {
- values->append(item.toAtomicValue().toString());
- item = resultItems.next();
- }
- }
-}
-
-void QDeclarativeXmlQueryEngine::addIndexToRangeList(QList<QDeclarativeXmlListRange> *ranges, int index) const {
- if (ranges->isEmpty())
- ranges->append(qMakePair(index, 1));
- else if (ranges->last().first + ranges->last().second == index)
- ranges->last().second += 1;
- else
- ranges->append(qMakePair(index, 1));
-}
-
-void QDeclarativeXmlQueryEngine::doSubQueryJob(XmlQueryJob *currentJob, QDeclarativeXmlQueryResult *currentResult)
-{
- Q_ASSERT(currentJob->queryId != -1);
-
- QBuffer b(&currentJob->data);
- b.open(QIODevice::ReadOnly);
-
- QXmlQuery subquery;
- subquery.bindVariable(QLatin1String("inputDocument"), &b);
-
- QStringList keyRoleResults;
- getValuesOfKeyRoles(*currentJob, &keyRoleResults, &subquery);
-
- // See if any values of key roles have been inserted or removed.
-
- if (currentJob->keyRoleResultsCache.isEmpty()) {
- currentResult->inserted << qMakePair(0, currentResult->size);
- } else {
- if (keyRoleResults != currentJob->keyRoleResultsCache) {
- QStringList temp;
- for (int i=0; i<currentJob->keyRoleResultsCache.count(); i++) {
- if (!keyRoleResults.contains(currentJob->keyRoleResultsCache[i]))
- addIndexToRangeList(&currentResult->removed, i);
- else
- temp << currentJob->keyRoleResultsCache[i];
- }
- for (int i=0; i<keyRoleResults.count(); i++) {
- if (temp.count() == i || keyRoleResults[i] != temp[i]) {
- temp.insert(i, keyRoleResults[i]);
- addIndexToRangeList(&currentResult->inserted, i);
- }
- }
- }
- }
- currentResult->keyRoleResultsCache = keyRoleResults;
-
- // Get the new values for each role.
- //### we might be able to condense even further (query for everything in one go)
- const QStringList &queries = currentJob->roleQueries;
- for (int i = 0; i < queries.size(); ++i) {
- QList<QVariant> resultList;
- if (!queries[i].isEmpty()) {
- subquery.setQuery(currentJob->prefix + QLatin1String("(let $v := string(") + queries[i] + QLatin1String(") return if ($v) then ") + queries[i] + QLatin1String(" else \"\")"));
- if (subquery.isValid()) {
- QXmlResultItems resultItems;
- subquery.evaluateTo(&resultItems);
- QXmlItem item(resultItems.next());
- while (!item.isNull()) {
- resultList << item.toAtomicValue(); //### we used to trim strings
- item = resultItems.next();
- }
- } else {
- emit error(currentJob->roleQueryErrorId.at(i), queries[i]);
- }
- }
- //### should warn here if things have gone wrong.
- while (resultList.count() < currentResult->size)
- resultList << QVariant();
- currentResult->data << resultList;
- b.seek(0);
- }
-
- //this method is much slower, but works better for incremental loading
- /*for (int j = 0; j < m_size; ++j) {
- QList<QVariant> resultList;
- for (int i = 0; i < m_roleObjects->size(); ++i) {
- QDeclarativeXmlListModelRole *role = m_roleObjects->at(i);
- subquery.setQuery(m_prefix.arg(j+1) + role->query());
- if (role->isStringList()) {
- QStringList data;
- subquery.evaluateTo(&data);
- resultList << QVariant(data);
- //qDebug() << data;
- } else {
- QString s;
- subquery.evaluateTo(&s);
- if (role->isCData()) {
- //un-escape
- s.replace(QLatin1String("&lt;"), QLatin1String("<"));
- s.replace(QLatin1String("&gt;"), QLatin1String(">"));
- s.replace(QLatin1String("&amp;"), QLatin1String("&"));
- }
- resultList << s.trimmed();
- //qDebug() << s;
- }
- b.seek(0);
- }
- m_modelData << resultList;
- }*/
-}
-
-class QDeclarativeXmlListModelPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeXmlListModel)
-public:
- QDeclarativeXmlListModelPrivate()
- : isComponentComplete(true), size(-1), highestRole(Qt::UserRole)
- , reply(0), status(QDeclarativeXmlListModel::Null), progress(0.0)
- , queryId(-1), roleObjects(), redirectCount(0) {}
-
-
- void notifyQueryStarted(bool remoteSource) {
- Q_Q(QDeclarativeXmlListModel);
- progress = remoteSource ? 0.0 : 1.0;
- status = QDeclarativeXmlListModel::Loading;
- errorString.clear();
- emit q->progressChanged(progress);
- emit q->statusChanged(status);
- }
-
- void deleteReply() {
- Q_Q(QDeclarativeXmlListModel);
- if (reply) {
- QObject::disconnect(reply, 0, q, 0);
- reply->deleteLater();
- reply = 0;
- }
- }
-
- bool isComponentComplete;
- QUrl src;
- QString xml;
- QString query;
- QString namespaces;
- int size;
- QList<int> roles;
- QStringList roleNames;
- int highestRole;
-
- QNetworkReply *reply;
- QDeclarativeXmlListModel::Status status;
- QString errorString;
- qreal progress;
- int queryId;
- QStringList keyRoleResultsCache;
- QList<QDeclarativeXmlListModelRole *> roleObjects;
-
- static void append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role);
- static void clear_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list);
- QList<QList<QVariant> > data;
- int redirectCount;
-};
-
-
-void QDeclarativeXmlListModelPrivate::append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role)
-{
- QDeclarativeXmlListModel *_this = qobject_cast<QDeclarativeXmlListModel *>(list->object);
- if (_this && role) {
- int i = _this->d_func()->roleObjects.count();
- _this->d_func()->roleObjects.append(role);
- if (_this->d_func()->roleNames.contains(role->name())) {
- qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name());
- return;
- }
- _this->d_func()->roles.insert(i, _this->d_func()->highestRole);
- _this->d_func()->roleNames.insert(i, role->name());
- ++_this->d_func()->highestRole;
- }
-}
-
-//### clear needs to invalidate any cached data (in data table) as well
-// (and the model should emit the appropriate signals)
-void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list)
-{
- QDeclarativeXmlListModel *_this = static_cast<QDeclarativeXmlListModel *>(list->object);
- _this->d_func()->roles.clear();
- _this->d_func()->roleNames.clear();
- _this->d_func()->roleObjects.clear();
-}
-
-/*!
- \qmlclass XmlListModel QDeclarativeXmlListModel
- \inqmlmodule QtQuick 2
- \ingroup qml-working-with-data
- \brief The XmlListModel element is used to specify a read-only model using XPath expressions.
-
- XmlListModel is used to create a read-only model from XML data. It can be used as a data source
- for view elements (such as ListView, PathView, GridView) and other elements that interact with model
- data (such as \l Repeater).
-
- For example, if there is a XML document at http://www.mysite.com/feed.xml like this:
-
- \code
- <?xml version="1.0" encoding="utf-8"?>
- <rss version="2.0">
- ...
- <channel>
- <item>
- <title>A blog post</title>
- <pubDate>Sat, 07 Sep 2010 10:00:01 GMT</pubDate>
- </item>
- <item>
- <title>Another blog post</title>
- <pubDate>Sat, 07 Sep 2010 15:35:01 GMT</pubDate>
- </item>
- </channel>
- </rss>
- \endcode
-
- A XmlListModel could create a model from this data, like this:
-
- \qml
- import QtQuick 2.0
-
- XmlListModel {
- id: xmlModel
- source: "http://www.mysite.com/feed.xml"
- query: "/rss/channel/item"
-
- XmlRole { name: "title"; query: "title/string()" }
- XmlRole { name: "pubDate"; query: "pubDate/string()" }
- }
- \endqml
-
- The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate
- a model item for each \c <item> in the XML document.
-
- The XmlRole objects define the
- model item attributes. Here, each model item will have \c title and \c pubDate
- attributes that match the \c title and \c pubDate values of its corresponding \c <item>.
- (See \l XmlRole::query for more examples of valid XPath expressions for XmlRole.)
-
- The model could be used in a ListView, like this:
-
- \qml
- ListView {
- width: 180; height: 300
- model: xmlModel
- delegate: Text { text: title + ": " + pubDate }
- }
- \endqml
-
- \image qml-xmllistmodel-example.png
-
- The XmlListModel data is loaded asynchronously, and \l status
- 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.
-
-
- \section2 Using key XML roles
-
- You can define certain roles as "keys" so that when reload() is called,
- the model will only add and refresh data that contains new values for
- these keys.
-
- For example, if above role for "pubDate" was defined like this instead:
-
- \qml
- XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true }
- \endqml
-
- Then when reload() is called, the model will only add and reload
- items with a "pubDate" value that is not already
- present in the model.
-
- This is useful when displaying the contents of XML documents that
- are incrementally updated (such as RSS feeds) to avoid repainting the
- entire contents of a model in a view.
-
- If multiple key roles are specified, the model only adds and reload items
- with a combined value of all key roles that is not already present in
- the model.
-
- \sa {RSS News}
-*/
-
-QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
- : QListModelInterface(*(new QDeclarativeXmlListModelPrivate), parent)
-{
-}
-
-QDeclarativeXmlListModel::~QDeclarativeXmlListModel()
-{
-}
-
-/*!
- \qmlproperty list<XmlRole> QtQuick2::XmlListModel::roles
-
- The roles to make available for this model.
-*/
-QDeclarativeListProperty<QDeclarativeXmlListModelRole> QDeclarativeXmlListModel::roleObjects()
-{
- Q_D(QDeclarativeXmlListModel);
- QDeclarativeListProperty<QDeclarativeXmlListModelRole> list(this, d->roleObjects);
- list.append = &QDeclarativeXmlListModelPrivate::append_role;
- list.clear = &QDeclarativeXmlListModelPrivate::clear_role;
- return list;
-}
-
-QHash<int,QVariant> QDeclarativeXmlListModel::data(int index, const QList<int> &roles) const
-{
- Q_D(const QDeclarativeXmlListModel);
- QHash<int, QVariant> rv;
- for (int i = 0; i < roles.size(); ++i) {
- int role = roles.at(i);
- int roleIndex = d->roles.indexOf(role);
- rv.insert(role, roleIndex == -1 ? QVariant() : d->data.value(roleIndex).value(index));
- }
- return rv;
-}
-
-QVariant QDeclarativeXmlListModel::data(int index, int role) const
-{
- Q_D(const QDeclarativeXmlListModel);
- int roleIndex = d->roles.indexOf(role);
- return (roleIndex == -1) ? QVariant() : d->data.value(roleIndex).value(index);
-}
-
-/*!
- \qmlproperty int QtQuick2::XmlListModel::count
- The number of data entries in the model.
-*/
-int QDeclarativeXmlListModel::count() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->size;
-}
-
-QList<int> QDeclarativeXmlListModel::roles() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->roles;
-}
-
-QString QDeclarativeXmlListModel::toString(int role) const
-{
- Q_D(const QDeclarativeXmlListModel);
- int index = d->roles.indexOf(role);
- if (index == -1)
- return QString();
- return d->roleNames.at(index);
-}
-
-/*!
- \qmlproperty url QtQuick2::XmlListModel::source
- The location of the XML data source.
-
- If both \c source and \l xml are set, \l xml is used.
-*/
-QUrl QDeclarativeXmlListModel::source() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->src;
-}
-
-void QDeclarativeXmlListModel::setSource(const QUrl &src)
-{
- Q_D(QDeclarativeXmlListModel);
- if (d->src != src) {
- d->src = src;
- if (d->xml.isEmpty()) // src is only used if d->xml is not set
- reload();
- emit sourceChanged();
- }
-}
-
-/*!
- \qmlproperty string QtQuick2::XmlListModel::xml
- This property holds the XML data for this model, if set.
-
- The text is assumed to be UTF-8 encoded.
-
- If both \l source and \c xml are set, \c xml is used.
-*/
-QString QDeclarativeXmlListModel::xml() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->xml;
-}
-
-void QDeclarativeXmlListModel::setXml(const QString &xml)
-{
- Q_D(QDeclarativeXmlListModel);
- if (d->xml != xml) {
- d->xml = xml;
- reload();
- emit xmlChanged();
- }
-}
-
-/*!
- \qmlproperty string QtQuick2::XmlListModel::query
- An absolute XPath query representing the base query for creating model items
- from this model's XmlRole objects. The query should start with '/' or '//'.
-*/
-QString QDeclarativeXmlListModel::query() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->query;
-}
-
-void QDeclarativeXmlListModel::setQuery(const QString &query)
-{
- Q_D(QDeclarativeXmlListModel);
- if (!query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << QCoreApplication::translate("QDeclarativeXmlRoleList", "An XmlListModel query must start with '/' or \"//\"");
- return;
- }
-
- if (d->query != query) {
- d->query = query;
- reload();
- emit queryChanged();
- }
-}
-
-/*!
- \qmlproperty string QtQuick2::XmlListModel::namespaceDeclarations
- The namespace declarations to be used in the XPath queries.
-
- The namespaces should be declared as in XQuery. For example, if a requested document
- at http://mysite.com/feed.xml uses the namespace "http://www.w3.org/2005/Atom",
- this can be declared as the default namespace:
-
- \qml
- XmlListModel {
- source: "http://mysite.com/feed.xml"
- query: "/feed/entry"
- namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
-
- XmlRole { name: "title"; query: "title/string()" }
- }
- \endqml
-*/
-QString QDeclarativeXmlListModel::namespaceDeclarations() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->namespaces;
-}
-
-void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarations)
-{
- Q_D(QDeclarativeXmlListModel);
- if (d->namespaces != declarations) {
- d->namespaces = declarations;
- reload();
- emit namespaceDeclarationsChanged();
- }
-}
-
-/*!
- \qmlmethod object QtQuick2::XmlListModel::get(int index)
-
- Returns the item at \a index in the model.
-
- For example, for a model like this:
-
- \qml
- XmlListModel {
- id: model
- source: "http://mysite.com/feed.xml"
- query: "/feed/entry"
- XmlRole { name: "title"; query: "title/string()" }
- }
- \endqml
-
- This will access the \c title value for the first item in the model:
-
- \js
- var title = model.get(0).title;
- \endjs
-*/
-QDeclarativeV8Handle QDeclarativeXmlListModel::get(int index) const
-{
- // Must be called with a context and handle scope
- Q_D(const QDeclarativeXmlListModel);
-
- if (index < 0 || index >= count())
- return QDeclarativeV8Handle::fromHandle(v8::Undefined());
-
- QDeclarativeEngine *engine = qmlContext(this)->engine();
- QV8Engine *v8engine = QDeclarativeEnginePrivate::getV8Engine(engine);
- v8::Local<v8::Object> rv = v8::Object::New();
- for (int ii = 0; ii < d->roleObjects.count(); ++ii)
- rv->Set(v8engine->toString(d->roleObjects[ii]->name()),
- v8engine->fromVariant(d->data.value(ii).value(index)));
-
- return QDeclarativeV8Handle::fromHandle(rv);
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::XmlListModel::status
- Specifies the model loading status, which can be one of the following:
-
- \list
- \o XmlListModel.Null - No XML data has been set for this model.
- \o XmlListModel.Ready - The XML data has been loaded into the model.
- \o XmlListModel.Loading - The model is in the process of reading and loading XML data.
- \o XmlListModel.Error - An error occurred while the model was loading. See errorString() for details
- about the error.
- \endlist
-
- \sa progress
-
-*/
-QDeclarativeXmlListModel::Status QDeclarativeXmlListModel::status() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->status;
-}
-
-/*!
- \qmlproperty real QtQuick2::XmlListModel::progress
-
- This indicates the current progress of the downloading of the XML data
- source. This value ranges from 0.0 (no data downloaded) to
- 1.0 (all data downloaded). If the XML data is not from a remote source,
- the progress becomes 1.0 as soon as the data is read.
-
- Note that when the progress is 1.0, the XML data has been downloaded, but
- it is yet to be loaded into the model at this point. Use the status
- property to find out when the XML data has been read and loaded into
- the model.
-
- \sa status, source
-*/
-qreal QDeclarativeXmlListModel::progress() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->progress;
-}
-
-/*!
- \qmlmethod void QtQuick2::XmlListModel::errorString()
-
- Returns a string description of the last error that occurred
- if \l status is XmlListModel::Error.
-*/
-QString QDeclarativeXmlListModel::errorString() const
-{
- Q_D(const QDeclarativeXmlListModel);
- return d->errorString;
-}
-
-void QDeclarativeXmlListModel::classBegin()
-{
- Q_D(QDeclarativeXmlListModel);
- d->isComponentComplete = false;
-
- QDeclarativeXmlQueryEngine *queryEngine = QDeclarativeXmlQueryEngine::instance(qmlEngine(this));
- connect(queryEngine, SIGNAL(queryCompleted(QDeclarativeXmlQueryResult)),
- SLOT(queryCompleted(QDeclarativeXmlQueryResult)));
- connect(queryEngine, SIGNAL(error(void*,QString)),
- SLOT(queryError(void*,QString)));
-}
-
-void QDeclarativeXmlListModel::componentComplete()
-{
- Q_D(QDeclarativeXmlListModel);
- d->isComponentComplete = true;
- reload();
-}
-
-/*!
- \qmlmethod QtQuick2::XmlListModel::reload()
-
- Reloads the model.
-
- If no key roles have been specified, all existing model
- data is removed, and the model is rebuilt from scratch.
-
- Otherwise, items are only added if the model does not already
- contain items with matching key role values.
-
- \sa {Using key XML roles}, XmlRole::isKey
-*/
-void QDeclarativeXmlListModel::reload()
-{
- Q_D(QDeclarativeXmlListModel);
-
- if (!d->isComponentComplete)
- return;
-
- QDeclarativeXmlQueryEngine::instance(qmlEngine(this))->abort(d->queryId);
- d->queryId = -1;
-
- if (d->size < 0)
- d->size = 0;
-
- if (d->reply) {
- d->reply->abort();
- d->deleteReply();
- }
-
- if (!d->xml.isEmpty()) {
- d->queryId = QDeclarativeXmlQueryEngine::instance(qmlEngine(this))->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache);
- d->notifyQueryStarted(false);
-
- } else if (d->src.isEmpty()) {
- d->queryId = XMLLISTMODEL_CLEAR_ID;
- d->notifyQueryStarted(false);
- QTimer::singleShot(0, this, SLOT(dataCleared()));
-
- } else {
- d->notifyQueryStarted(true);
- QNetworkRequest req(d->src);
- req.setRawHeader("Accept", "application/xml,*/*");
- d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
- QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
- QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
- }
-}
-
-#define XMLLISTMODEL_MAX_REDIRECT 16
-
-void QDeclarativeXmlListModel::requestFinished()
-{
- Q_D(QDeclarativeXmlListModel);
-
- d->redirectCount++;
- if (d->redirectCount < XMLLISTMODEL_MAX_REDIRECT) {
- QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- QUrl url = d->reply->url().resolved(redirect.toUrl());
- d->deleteReply();
- setSource(url);
- return;
- }
- }
- d->redirectCount = 0;
-
- if (d->reply->error() != QNetworkReply::NoError) {
- d->errorString = d->reply->errorString();
- d->deleteReply();
-
- int count = this->count();
- d->data.clear();
- d->size = 0;
- if (count > 0) {
- emit itemsRemoved(0, count);
- emit countChanged();
- }
-
- d->status = Error;
- d->queryId = -1;
- emit statusChanged(d->status);
- } else {
- QByteArray data = d->reply->readAll();
- if (data.isEmpty()) {
- d->queryId = XMLLISTMODEL_CLEAR_ID;
- QTimer::singleShot(0, this, SLOT(dataCleared()));
- } else {
- d->queryId = QDeclarativeXmlQueryEngine::instance(qmlEngine(this))->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache);
- }
- d->deleteReply();
-
- d->progress = 1.0;
- emit progressChanged(d->progress);
- }
-}
-
-void QDeclarativeXmlListModel::requestProgress(qint64 received, qint64 total)
-{
- Q_D(QDeclarativeXmlListModel);
- if (d->status == Loading && total > 0) {
- d->progress = qreal(received)/total;
- emit progressChanged(d->progress);
- }
-}
-
-void QDeclarativeXmlListModel::dataCleared()
-{
- Q_D(QDeclarativeXmlListModel);
- QDeclarativeXmlQueryResult r;
- r.queryId = XMLLISTMODEL_CLEAR_ID;
- r.size = 0;
- r.removed << qMakePair(0, count());
- r.keyRoleResultsCache = d->keyRoleResultsCache;
- queryCompleted(r);
-}
-
-void QDeclarativeXmlListModel::queryError(void* object, const QString& error)
-{
- // Be extra careful, object may no longer exist, it's just an ID.
- Q_D(QDeclarativeXmlListModel);
- for (int i=0; i<d->roleObjects.count(); i++) {
- if (d->roleObjects.at(i) == static_cast<QDeclarativeXmlListModelRole*>(object)) {
- qmlInfo(d->roleObjects.at(i)) << QObject::tr("invalid query: \"%1\"").arg(error);
- return;
- }
- }
- qmlInfo(this) << QObject::tr("invalid query: \"%1\"").arg(error);
-}
-
-void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult &result)
-{
- Q_D(QDeclarativeXmlListModel);
- if (result.queryId != d->queryId)
- return;
-
- int origCount = d->size;
- bool sizeChanged = result.size != d->size;
-
- d->size = result.size;
- d->data = result.data;
- d->keyRoleResultsCache = result.keyRoleResultsCache;
- if (d->src.isEmpty() && d->xml.isEmpty())
- d->status = Null;
- else
- d->status = Ready;
- d->errorString.clear();
- d->queryId = -1;
-
- bool hasKeys = false;
- for (int i=0; i<d->roleObjects.count(); i++) {
- if (d->roleObjects[i]->isKey()) {
- hasKeys = true;
- break;
- }
- }
- if (!hasKeys) {
- if (!(origCount == 0 && d->size == 0)) {
- emit itemsRemoved(0, origCount);
- emit itemsInserted(0, d->size);
- emit countChanged();
- }
-
- } else {
- for (int i=0; i<result.removed.count(); i++)
- emit itemsRemoved(result.removed[i].first, result.removed[i].second);
- for (int i=0; i<result.inserted.count(); i++)
- emit itemsInserted(result.inserted[i].first, result.inserted[i].second);
-
- if (sizeChanged)
- emit countChanged();
- }
-
- emit statusChanged(d->status);
-}
-
-QT_END_NAMESPACE
-
-#include <qdeclarativexmllistmodel.moc>
diff --git a/src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h b/src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h
deleted file mode 100644
index f34591d0a3..0000000000
--- a/src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEXMLLISTMODEL_H
-#define QDECLARATIVEXMLLISTMODEL_H
-
-#include <qdeclarative.h>
-#include <qdeclarativeinfo.h>
-
-#include <QtCore/qurl.h>
-#include <QtCore/qstringlist.h>
-
-#include <private/qlistmodelinterface_p.h>
-#include <private/qv8engine_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeContext;
-class QDeclarativeXmlListModelRole;
-class QDeclarativeXmlListModelPrivate;
-
-struct QDeclarativeXmlQueryResult {
- int queryId;
- int size;
- QList<QList<QVariant> > data;
- QList<QPair<int, int> > inserted;
- QList<QPair<int, int> > removed;
- QStringList keyRoleResultsCache;
-};
-
-class QDeclarativeXmlListModel : public QListModelInterface, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_ENUMS(Status)
-
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QString xml READ xml WRITE setXml NOTIFY xmlChanged)
- Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
- Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations NOTIFY namespaceDeclarationsChanged)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeXmlListModelRole> roles READ roleObjects)
- Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_CLASSINFO("DefaultProperty", "roles")
-
-public:
- QDeclarativeXmlListModel(QObject *parent = 0);
- ~QDeclarativeXmlListModel();
-
- virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
- virtual QVariant data(int index, int role) const;
- virtual int count() const;
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
-
- QDeclarativeListProperty<QDeclarativeXmlListModelRole> roleObjects();
-
- QUrl source() const;
- void setSource(const QUrl&);
-
- QString xml() const;
- void setXml(const QString&);
-
- QString query() const;
- void setQuery(const QString&);
-
- QString namespaceDeclarations() const;
- void setNamespaceDeclarations(const QString&);
-
- Q_INVOKABLE QDeclarativeV8Handle get(int index) const;
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
- qreal progress() const;
-
- Q_INVOKABLE QString errorString() const;
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void statusChanged(QDeclarativeXmlListModel::Status);
- void progressChanged(qreal progress);
- void countChanged();
- void sourceChanged();
- void xmlChanged();
- void queryChanged();
- void namespaceDeclarationsChanged();
-
-public Q_SLOTS:
- // ### need to use/expose Expiry to guess when to call this?
- // ### property to auto-call this on reasonable Expiry?
- // ### LastModified/Age also useful to guess.
- // ### Probably also applies to other network-requesting types.
- void reload();
-
-private Q_SLOTS:
- void requestFinished();
- void requestProgress(qint64,qint64);
- void dataCleared();
- void queryCompleted(const QDeclarativeXmlQueryResult &);
- void queryError(void* object, const QString& error);
-
-private:
- Q_DECLARE_PRIVATE(QDeclarativeXmlListModel)
- Q_DISABLE_COPY(QDeclarativeXmlListModel)
-};
-
-class QDeclarativeXmlListModelRole : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
- Q_PROPERTY(bool isKey READ isKey WRITE setIsKey NOTIFY isKeyChanged)
-public:
- QDeclarativeXmlListModelRole() : m_isKey(false) {}
- ~QDeclarativeXmlListModelRole() {}
-
- QString name() const { return m_name; }
- void setName(const QString &name) {
- if (name == m_name)
- return;
- m_name = name;
- emit nameChanged();
- }
-
- QString query() const { return m_query; }
- void setQuery(const QString &query)
- {
- if (query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << tr("An XmlRole query must not start with '/'");
- return;
- }
- if (m_query == query)
- return;
- m_query = query;
- emit queryChanged();
- }
-
- bool isKey() const { return m_isKey; }
- void setIsKey(bool b) {
- if (m_isKey == b)
- return;
- m_isKey = b;
- emit isKeyChanged();
- }
-
- bool isValid() {
- return !m_name.isEmpty() && !m_query.isEmpty();
- }
-
-Q_SIGNALS:
- void nameChanged();
- void queryChanged();
- void isKeyChanged();
-
-private:
- QString m_name;
- QString m_query;
- bool m_isKey;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeXmlListModel)
-QML_DECLARE_TYPE(QDeclarativeXmlListModelRole)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEXMLLISTMODEL_H
diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
new file mode 100644
index 0000000000..1377859b5e
--- /dev/null
+++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
@@ -0,0 +1,1160 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlxmllistmodel_p.h"
+
+#include <qqmlcontext.h>
+#include <private/qqmlengine_p.h>
+
+#include <QDebug>
+#include <QStringList>
+#include <QMap>
+#include <QThread>
+#include <QXmlQuery>
+#include <QXmlResultItems>
+#include <QXmlNodeModelIndex>
+#include <QBuffer>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QTimer>
+#include <QMutex>
+
+#include <private/qobject_p.h>
+
+Q_DECLARE_METATYPE(QQuickXmlQueryResult)
+
+QT_BEGIN_NAMESPACE
+
+
+typedef QPair<int, int> QQuickXmlListRange;
+
+#define XMLLISTMODEL_CLEAR_ID 0
+
+/*!
+ \qmlclass XmlRole QQuickXmlListModelRole
+ \inqmlmodule QtQuick 2
+ \ingroup qml-working-with-data
+ \brief The XmlRole element allows you to specify a role for an XmlListModel.
+
+ \sa {QtQml}
+*/
+
+/*!
+ \qmlproperty string QtQuick2::XmlRole::name
+
+ The name for the role. This name is used to access the model data for this role.
+
+ For example, the following model has a role named "title", which can be accessed
+ from the view's delegate:
+
+ \qml
+ XmlListModel {
+ id: xmlModel
+ // ...
+ XmlRole {
+ name: "title"
+ query: "title/string()"
+ }
+ }
+ \endqml
+
+ \qml
+ ListView {
+ model: xmlModel
+ delegate: Text { text: title }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlproperty string QtQuick2::XmlRole::query
+ The relative XPath expression query for this role. The query must be relative; it cannot start
+ with a '/'.
+
+ For example, if there is an XML document like this:
+
+ \quotefile doc/src/snippets/qml/xmlrole.xml
+ Here are some valid XPath expressions for XmlRole queries on this document:
+
+ \snippet doc/src/snippets/qml/xmlrole.qml 0
+ \dots 4
+ \snippet doc/src/snippets/qml/xmlrole.qml 1
+
+ See the \l{http://www.w3.org/TR/xpath20/}{W3C XPath 2.0 specification} for more information.
+*/
+
+/*!
+ \qmlproperty bool QtQuick2::XmlRole::isKey
+ Defines whether this is a key role.
+ Key roles are used to to determine whether a set of values should
+ be updated or added to the XML list model when XmlListModel::reload()
+ is called.
+
+ \sa XmlListModel
+*/
+
+struct XmlQueryJob
+{
+ int queryId;
+ QByteArray data;
+ QString query;
+ QString namespaces;
+ QStringList roleQueries;
+ QList<void*> roleQueryErrorId; // the ptr to send back if there is an error
+ QStringList keyRoleQueries;
+ QStringList keyRoleResultsCache;
+ QString prefix;
+};
+
+
+class QQuickXmlQueryEngine;
+class QQuickXmlQueryThreadObject : public QObject
+{
+ Q_OBJECT
+public:
+ QQuickXmlQueryThreadObject(QQuickXmlQueryEngine *);
+
+ void processJobs();
+ virtual bool event(QEvent *e);
+
+private:
+ QQuickXmlQueryEngine *m_queryEngine;
+};
+
+
+class QQuickXmlQueryEngine : public QThread
+{
+ Q_OBJECT
+public:
+ QQuickXmlQueryEngine(QQmlEngine *eng);
+ ~QQuickXmlQueryEngine();
+
+ int doQuery(QString query, QString namespaces, QByteArray data, QList<QQuickXmlListModelRole *>* roleObjects, QStringList keyRoleResultsCache);
+ void abort(int id);
+
+ void processJobs();
+
+ static QQuickXmlQueryEngine *instance(QQmlEngine *engine);
+
+signals:
+ void queryCompleted(const QQuickXmlQueryResult &);
+ void error(void*, const QString&);
+
+protected:
+ void run();
+
+private:
+ void processQuery(XmlQueryJob *job);
+ void doQueryJob(XmlQueryJob *job, QQuickXmlQueryResult *currentResult);
+ void doSubQueryJob(XmlQueryJob *job, QQuickXmlQueryResult *currentResult);
+ void getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const;
+ void addIndexToRangeList(QList<QQuickXmlListRange> *ranges, int index) const;
+
+ QMutex m_mutex;
+ QQuickXmlQueryThreadObject *m_threadObject;
+ QList<XmlQueryJob> m_jobs;
+ QSet<int> m_cancelledJobs;
+ QAtomicInt m_queryIds;
+
+ QQmlEngine *m_engine;
+ QObject *m_eventLoopQuitHack;
+
+ static QHash<QQmlEngine *,QQuickXmlQueryEngine*> queryEngines;
+ static QMutex queryEnginesMutex;
+};
+QHash<QQmlEngine *,QQuickXmlQueryEngine*> QQuickXmlQueryEngine::queryEngines;
+QMutex QQuickXmlQueryEngine::queryEnginesMutex;
+
+
+QQuickXmlQueryThreadObject::QQuickXmlQueryThreadObject(QQuickXmlQueryEngine *e)
+ : m_queryEngine(e)
+{
+}
+
+void QQuickXmlQueryThreadObject::processJobs()
+{
+ QCoreApplication::postEvent(this, new QEvent(QEvent::User));
+}
+
+bool QQuickXmlQueryThreadObject::event(QEvent *e)
+{
+ if (e->type() == QEvent::User) {
+ m_queryEngine->processJobs();
+ return true;
+ } else {
+ return QObject::event(e);
+ }
+}
+
+
+
+QQuickXmlQueryEngine::QQuickXmlQueryEngine(QQmlEngine *eng)
+: QThread(eng), m_threadObject(0), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1), m_engine(eng), m_eventLoopQuitHack(0)
+{
+ qRegisterMetaType<QQuickXmlQueryResult>("QQuickXmlQueryResult");
+
+ m_eventLoopQuitHack = new QObject;
+ m_eventLoopQuitHack->moveToThread(this);
+ connect(m_eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection);
+ start(QThread::IdlePriority);
+}
+
+QQuickXmlQueryEngine::~QQuickXmlQueryEngine()
+{
+ queryEnginesMutex.lock();
+ queryEngines.remove(m_engine);
+ queryEnginesMutex.unlock();
+
+ m_eventLoopQuitHack->deleteLater();
+ wait();
+}
+
+int QQuickXmlQueryEngine::doQuery(QString query, QString namespaces, QByteArray data, QList<QQuickXmlListModelRole *>* roleObjects, QStringList keyRoleResultsCache) {
+ {
+ QMutexLocker m1(&m_mutex);
+ m_queryIds.ref();
+ if (m_queryIds.load() <= 0)
+ m_queryIds.store(1);
+ }
+
+ XmlQueryJob job;
+ job.queryId = m_queryIds.load();
+ job.data = data;
+ job.query = QLatin1String("doc($src)") + query;
+ job.namespaces = namespaces;
+ job.keyRoleResultsCache = keyRoleResultsCache;
+
+ for (int i=0; i<roleObjects->count(); i++) {
+ if (!roleObjects->at(i)->isValid()) {
+ job.roleQueries << QString();
+ continue;
+ }
+ job.roleQueries << roleObjects->at(i)->query();
+ job.roleQueryErrorId << static_cast<void*>(roleObjects->at(i));
+ if (roleObjects->at(i)->isKey())
+ job.keyRoleQueries << job.roleQueries.last();
+ }
+
+ {
+ QMutexLocker ml(&m_mutex);
+ m_jobs.append(job);
+ if (m_threadObject)
+ m_threadObject->processJobs();
+ }
+
+ return job.queryId;
+}
+
+void QQuickXmlQueryEngine::abort(int id)
+{
+ QMutexLocker ml(&m_mutex);
+ if (id != -1)
+ m_cancelledJobs.insert(id);
+}
+
+void QQuickXmlQueryEngine::run()
+{
+ m_mutex.lock();
+ m_threadObject = new QQuickXmlQueryThreadObject(this);
+ m_mutex.unlock();
+
+ processJobs();
+ exec();
+
+ delete m_threadObject;
+ m_threadObject = 0;
+}
+
+void QQuickXmlQueryEngine::processJobs()
+{
+ QMutexLocker locker(&m_mutex);
+
+ while (true) {
+ if (m_jobs.isEmpty())
+ return;
+
+ XmlQueryJob currentJob = m_jobs.takeLast();
+ while (m_cancelledJobs.remove(currentJob.queryId)) {
+ if (m_jobs.isEmpty())
+ return;
+ currentJob = m_jobs.takeLast();
+ }
+
+ locker.unlock();
+ processQuery(&currentJob);
+ locker.relock();
+ }
+}
+
+QQuickXmlQueryEngine *QQuickXmlQueryEngine::instance(QQmlEngine *engine)
+{
+ queryEnginesMutex.lock();
+ QQuickXmlQueryEngine *queryEng = queryEngines.value(engine);
+ if (!queryEng) {
+ queryEng = new QQuickXmlQueryEngine(engine);
+ queryEngines.insert(engine, queryEng);
+ }
+ queryEnginesMutex.unlock();
+
+ return queryEng;
+}
+
+void QQuickXmlQueryEngine::processQuery(XmlQueryJob *job)
+{
+ QQuickXmlQueryResult result;
+ result.queryId = job->queryId;
+ doQueryJob(job, &result);
+ doSubQueryJob(job, &result);
+
+ {
+ QMutexLocker ml(&m_mutex);
+ if (m_cancelledJobs.contains(job->queryId)) {
+ m_cancelledJobs.remove(job->queryId);
+ } else {
+ emit queryCompleted(result);
+ }
+ }
+}
+
+void QQuickXmlQueryEngine::doQueryJob(XmlQueryJob *currentJob, QQuickXmlQueryResult *currentResult)
+{
+ Q_ASSERT(currentJob->queryId != -1);
+
+ QString r;
+ QXmlQuery query;
+ QBuffer buffer(&currentJob->data);
+ buffer.open(QIODevice::ReadOnly);
+ query.bindVariable(QLatin1String("src"), &buffer);
+ query.setQuery(currentJob->namespaces + currentJob->query);
+ query.evaluateTo(&r);
+
+ //always need a single root element
+ QByteArray xml = "<dummy:items xmlns:dummy=\"http://qtsotware.com/dummy\">\n" + r.toUtf8() + "</dummy:items>";
+ QBuffer b(&xml);
+ b.open(QIODevice::ReadOnly);
+
+ QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + currentJob->namespaces;
+ QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
+ currentJob->query.mid(currentJob->query.lastIndexOf(QLatin1Char('/')));
+
+ //figure out how many items we are dealing with
+ int count = -1;
+ {
+ QXmlResultItems result;
+ QXmlQuery countquery;
+ countquery.bindVariable(QLatin1String("inputDocument"), &b);
+ countquery.setQuery(namespaces + QLatin1String("count(") + prefix + QLatin1Char(')'));
+ countquery.evaluateTo(&result);
+ QXmlItem item(result.next());
+ if (item.isAtomicValue())
+ count = item.toAtomicValue().toInt();
+ }
+
+ currentJob->data = xml;
+ currentJob->prefix = namespaces + prefix + QLatin1Char('/');
+ currentResult->size = (count > 0 ? count : 0);
+}
+
+void QQuickXmlQueryEngine::getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const
+{
+ const QStringList &keysQueries = currentJob.keyRoleQueries;
+ QString keysQuery;
+ if (keysQueries.count() == 1)
+ keysQuery = currentJob.prefix + keysQueries[0];
+ else if (keysQueries.count() > 1)
+ keysQuery = currentJob.prefix + QLatin1String("concat(") + keysQueries.join(QLatin1String(",")) + QLatin1String(")");
+
+ if (!keysQuery.isEmpty()) {
+ query->setQuery(keysQuery);
+ QXmlResultItems resultItems;
+ query->evaluateTo(&resultItems);
+ QXmlItem item(resultItems.next());
+ while (!item.isNull()) {
+ values->append(item.toAtomicValue().toString());
+ item = resultItems.next();
+ }
+ }
+}
+
+void QQuickXmlQueryEngine::addIndexToRangeList(QList<QQuickXmlListRange> *ranges, int index) const {
+ if (ranges->isEmpty())
+ ranges->append(qMakePair(index, 1));
+ else if (ranges->last().first + ranges->last().second == index)
+ ranges->last().second += 1;
+ else
+ ranges->append(qMakePair(index, 1));
+}
+
+void QQuickXmlQueryEngine::doSubQueryJob(XmlQueryJob *currentJob, QQuickXmlQueryResult *currentResult)
+{
+ Q_ASSERT(currentJob->queryId != -1);
+
+ QBuffer b(&currentJob->data);
+ b.open(QIODevice::ReadOnly);
+
+ QXmlQuery subquery;
+ subquery.bindVariable(QLatin1String("inputDocument"), &b);
+
+ QStringList keyRoleResults;
+ getValuesOfKeyRoles(*currentJob, &keyRoleResults, &subquery);
+
+ // See if any values of key roles have been inserted or removed.
+
+ if (currentJob->keyRoleResultsCache.isEmpty()) {
+ currentResult->inserted << qMakePair(0, currentResult->size);
+ } else {
+ if (keyRoleResults != currentJob->keyRoleResultsCache) {
+ QStringList temp;
+ for (int i=0; i<currentJob->keyRoleResultsCache.count(); i++) {
+ if (!keyRoleResults.contains(currentJob->keyRoleResultsCache[i]))
+ addIndexToRangeList(&currentResult->removed, i);
+ else
+ temp << currentJob->keyRoleResultsCache[i];
+ }
+ for (int i=0; i<keyRoleResults.count(); i++) {
+ if (temp.count() == i || keyRoleResults[i] != temp[i]) {
+ temp.insert(i, keyRoleResults[i]);
+ addIndexToRangeList(&currentResult->inserted, i);
+ }
+ }
+ }
+ }
+ currentResult->keyRoleResultsCache = keyRoleResults;
+
+ // Get the new values for each role.
+ //### we might be able to condense even further (query for everything in one go)
+ const QStringList &queries = currentJob->roleQueries;
+ for (int i = 0; i < queries.size(); ++i) {
+ QList<QVariant> resultList;
+ if (!queries[i].isEmpty()) {
+ subquery.setQuery(currentJob->prefix + QLatin1String("(let $v := string(") + queries[i] + QLatin1String(") return if ($v) then ") + queries[i] + QLatin1String(" else \"\")"));
+ if (subquery.isValid()) {
+ QXmlResultItems resultItems;
+ subquery.evaluateTo(&resultItems);
+ QXmlItem item(resultItems.next());
+ while (!item.isNull()) {
+ resultList << item.toAtomicValue(); //### we used to trim strings
+ item = resultItems.next();
+ }
+ } else {
+ emit error(currentJob->roleQueryErrorId.at(i), queries[i]);
+ }
+ }
+ //### should warn here if things have gone wrong.
+ while (resultList.count() < currentResult->size)
+ resultList << QVariant();
+ currentResult->data << resultList;
+ b.seek(0);
+ }
+
+ //this method is much slower, but works better for incremental loading
+ /*for (int j = 0; j < m_size; ++j) {
+ QList<QVariant> resultList;
+ for (int i = 0; i < m_roleObjects->size(); ++i) {
+ QQuickXmlListModelRole *role = m_roleObjects->at(i);
+ subquery.setQuery(m_prefix.arg(j+1) + role->query());
+ if (role->isStringList()) {
+ QStringList data;
+ subquery.evaluateTo(&data);
+ resultList << QVariant(data);
+ //qDebug() << data;
+ } else {
+ QString s;
+ subquery.evaluateTo(&s);
+ if (role->isCData()) {
+ //un-escape
+ s.replace(QLatin1String("&lt;"), QLatin1String("<"));
+ s.replace(QLatin1String("&gt;"), QLatin1String(">"));
+ s.replace(QLatin1String("&amp;"), QLatin1String("&"));
+ }
+ resultList << s.trimmed();
+ //qDebug() << s;
+ }
+ b.seek(0);
+ }
+ m_modelData << resultList;
+ }*/
+}
+
+class QQuickXmlListModelPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickXmlListModel)
+public:
+ QQuickXmlListModelPrivate()
+ : isComponentComplete(true), size(-1), highestRole(Qt::UserRole)
+ , reply(0), status(QQuickXmlListModel::Null), progress(0.0)
+ , queryId(-1), roleObjects(), redirectCount(0) {}
+
+
+ void notifyQueryStarted(bool remoteSource) {
+ Q_Q(QQuickXmlListModel);
+ progress = remoteSource ? 0.0 : 1.0;
+ status = QQuickXmlListModel::Loading;
+ errorString.clear();
+ emit q->progressChanged(progress);
+ emit q->statusChanged(status);
+ }
+
+ void deleteReply() {
+ Q_Q(QQuickXmlListModel);
+ if (reply) {
+ QObject::disconnect(reply, 0, q, 0);
+ reply->deleteLater();
+ reply = 0;
+ }
+ }
+
+ bool isComponentComplete;
+ QUrl src;
+ QString xml;
+ QString query;
+ QString namespaces;
+ int size;
+ QList<int> roles;
+ QStringList roleNames;
+ int highestRole;
+
+ QNetworkReply *reply;
+ QQuickXmlListModel::Status status;
+ QString errorString;
+ qreal progress;
+ int queryId;
+ QStringList keyRoleResultsCache;
+ QList<QQuickXmlListModelRole *> roleObjects;
+
+ static void append_role(QQmlListProperty<QQuickXmlListModelRole> *list, QQuickXmlListModelRole *role);
+ static void clear_role(QQmlListProperty<QQuickXmlListModelRole> *list);
+ QList<QList<QVariant> > data;
+ int redirectCount;
+};
+
+
+void QQuickXmlListModelPrivate::append_role(QQmlListProperty<QQuickXmlListModelRole> *list, QQuickXmlListModelRole *role)
+{
+ QQuickXmlListModel *_this = qobject_cast<QQuickXmlListModel *>(list->object);
+ if (_this && role) {
+ int i = _this->d_func()->roleObjects.count();
+ _this->d_func()->roleObjects.append(role);
+ if (_this->d_func()->roleNames.contains(role->name())) {
+ qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name());
+ return;
+ }
+ _this->d_func()->roles.insert(i, _this->d_func()->highestRole);
+ _this->d_func()->roleNames.insert(i, role->name());
+ ++_this->d_func()->highestRole;
+ }
+}
+
+//### clear needs to invalidate any cached data (in data table) as well
+// (and the model should emit the appropriate signals)
+void QQuickXmlListModelPrivate::clear_role(QQmlListProperty<QQuickXmlListModelRole> *list)
+{
+ QQuickXmlListModel *_this = static_cast<QQuickXmlListModel *>(list->object);
+ _this->d_func()->roles.clear();
+ _this->d_func()->roleNames.clear();
+ _this->d_func()->roleObjects.clear();
+}
+
+/*!
+ \qmlclass XmlListModel QQuickXmlListModel
+ \inqmlmodule QtQuick 2
+ \ingroup qml-working-with-data
+ \brief The XmlListModel element is used to specify a read-only model using XPath expressions.
+
+ XmlListModel is used to create a read-only model from XML data. It can be used as a data source
+ for view elements (such as ListView, PathView, GridView) and other elements that interact with model
+ data (such as \l Repeater).
+
+ For example, if there is a XML document at http://www.mysite.com/feed.xml like this:
+
+ \code
+ <?xml version="1.0" encoding="utf-8"?>
+ <rss version="2.0">
+ ...
+ <channel>
+ <item>
+ <title>A blog post</title>
+ <pubDate>Sat, 07 Sep 2010 10:00:01 GMT</pubDate>
+ </item>
+ <item>
+ <title>Another blog post</title>
+ <pubDate>Sat, 07 Sep 2010 15:35:01 GMT</pubDate>
+ </item>
+ </channel>
+ </rss>
+ \endcode
+
+ A XmlListModel could create a model from this data, like this:
+
+ \qml
+ import QtQuick 2.0
+
+ XmlListModel {
+ id: xmlModel
+ source: "http://www.mysite.com/feed.xml"
+ query: "/rss/channel/item"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "pubDate"; query: "pubDate/string()" }
+ }
+ \endqml
+
+ The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate
+ a model item for each \c <item> in the XML document.
+
+ The XmlRole objects define the
+ model item attributes. Here, each model item will have \c title and \c pubDate
+ attributes that match the \c title and \c pubDate values of its corresponding \c <item>.
+ (See \l XmlRole::query for more examples of valid XPath expressions for XmlRole.)
+
+ The model could be used in a ListView, like this:
+
+ \qml
+ ListView {
+ width: 180; height: 300
+ model: xmlModel
+ delegate: Text { text: title + ": " + pubDate }
+ }
+ \endqml
+
+ \image qml-xmllistmodel-example.png
+
+ The XmlListModel data is loaded asynchronously, and \l status
+ 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.
+
+
+ \section2 Using key XML roles
+
+ You can define certain roles as "keys" so that when reload() is called,
+ the model will only add and refresh data that contains new values for
+ these keys.
+
+ For example, if above role for "pubDate" was defined like this instead:
+
+ \qml
+ XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true }
+ \endqml
+
+ Then when reload() is called, the model will only add and reload
+ items with a "pubDate" value that is not already
+ present in the model.
+
+ This is useful when displaying the contents of XML documents that
+ are incrementally updated (such as RSS feeds) to avoid repainting the
+ entire contents of a model in a view.
+
+ If multiple key roles are specified, the model only adds and reload items
+ with a combined value of all key roles that is not already present in
+ the model.
+
+ \sa {RSS News}
+*/
+
+QQuickXmlListModel::QQuickXmlListModel(QObject *parent)
+ : QListModelInterface(*(new QQuickXmlListModelPrivate), parent)
+{
+}
+
+QQuickXmlListModel::~QQuickXmlListModel()
+{
+}
+
+/*!
+ \qmlproperty list<XmlRole> QtQuick2::XmlListModel::roles
+
+ The roles to make available for this model.
+*/
+QQmlListProperty<QQuickXmlListModelRole> QQuickXmlListModel::roleObjects()
+{
+ Q_D(QQuickXmlListModel);
+ QQmlListProperty<QQuickXmlListModelRole> list(this, d->roleObjects);
+ list.append = &QQuickXmlListModelPrivate::append_role;
+ list.clear = &QQuickXmlListModelPrivate::clear_role;
+ return list;
+}
+
+QHash<int,QVariant> QQuickXmlListModel::data(int index, const QList<int> &roles) const
+{
+ Q_D(const QQuickXmlListModel);
+ QHash<int, QVariant> rv;
+ for (int i = 0; i < roles.size(); ++i) {
+ int role = roles.at(i);
+ int roleIndex = d->roles.indexOf(role);
+ rv.insert(role, roleIndex == -1 ? QVariant() : d->data.value(roleIndex).value(index));
+ }
+ return rv;
+}
+
+QVariant QQuickXmlListModel::data(int index, int role) const
+{
+ Q_D(const QQuickXmlListModel);
+ int roleIndex = d->roles.indexOf(role);
+ return (roleIndex == -1) ? QVariant() : d->data.value(roleIndex).value(index);
+}
+
+/*!
+ \qmlproperty int QtQuick2::XmlListModel::count
+ The number of data entries in the model.
+*/
+int QQuickXmlListModel::count() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->size;
+}
+
+QList<int> QQuickXmlListModel::roles() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->roles;
+}
+
+QString QQuickXmlListModel::toString(int role) const
+{
+ Q_D(const QQuickXmlListModel);
+ int index = d->roles.indexOf(role);
+ if (index == -1)
+ return QString();
+ return d->roleNames.at(index);
+}
+
+/*!
+ \qmlproperty url QtQuick2::XmlListModel::source
+ The location of the XML data source.
+
+ If both \c source and \l xml are set, \l xml is used.
+*/
+QUrl QQuickXmlListModel::source() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->src;
+}
+
+void QQuickXmlListModel::setSource(const QUrl &src)
+{
+ Q_D(QQuickXmlListModel);
+ if (d->src != src) {
+ d->src = src;
+ if (d->xml.isEmpty()) // src is only used if d->xml is not set
+ reload();
+ emit sourceChanged();
+ }
+}
+
+/*!
+ \qmlproperty string QtQuick2::XmlListModel::xml
+ This property holds the XML data for this model, if set.
+
+ The text is assumed to be UTF-8 encoded.
+
+ If both \l source and \c xml are set, \c xml is used.
+*/
+QString QQuickXmlListModel::xml() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->xml;
+}
+
+void QQuickXmlListModel::setXml(const QString &xml)
+{
+ Q_D(QQuickXmlListModel);
+ if (d->xml != xml) {
+ d->xml = xml;
+ reload();
+ emit xmlChanged();
+ }
+}
+
+/*!
+ \qmlproperty string QtQuick2::XmlListModel::query
+ An absolute XPath query representing the base query for creating model items
+ from this model's XmlRole objects. The query should start with '/' or '//'.
+*/
+QString QQuickXmlListModel::query() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->query;
+}
+
+void QQuickXmlListModel::setQuery(const QString &query)
+{
+ Q_D(QQuickXmlListModel);
+ if (!query.startsWith(QLatin1Char('/'))) {
+ qmlInfo(this) << QCoreApplication::translate("QQuickXmlRoleList", "An XmlListModel query must start with '/' or \"//\"");
+ return;
+ }
+
+ if (d->query != query) {
+ d->query = query;
+ reload();
+ emit queryChanged();
+ }
+}
+
+/*!
+ \qmlproperty string QtQuick2::XmlListModel::namespaceDeclarations
+ The namespace declarations to be used in the XPath queries.
+
+ The namespaces should be declared as in XQuery. For example, if a requested document
+ at http://mysite.com/feed.xml uses the namespace "http://www.w3.org/2005/Atom",
+ this can be declared as the default namespace:
+
+ \qml
+ XmlListModel {
+ source: "http://mysite.com/feed.xml"
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ }
+ \endqml
+*/
+QString QQuickXmlListModel::namespaceDeclarations() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->namespaces;
+}
+
+void QQuickXmlListModel::setNamespaceDeclarations(const QString &declarations)
+{
+ Q_D(QQuickXmlListModel);
+ if (d->namespaces != declarations) {
+ d->namespaces = declarations;
+ reload();
+ emit namespaceDeclarationsChanged();
+ }
+}
+
+/*!
+ \qmlmethod object QtQuick2::XmlListModel::get(int index)
+
+ Returns the item at \a index in the model.
+
+ For example, for a model like this:
+
+ \qml
+ XmlListModel {
+ id: model
+ source: "http://mysite.com/feed.xml"
+ query: "/feed/entry"
+ XmlRole { name: "title"; query: "title/string()" }
+ }
+ \endqml
+
+ This will access the \c title value for the first item in the model:
+
+ \js
+ var title = model.get(0).title;
+ \endjs
+*/
+QQmlV8Handle QQuickXmlListModel::get(int index) const
+{
+ // Must be called with a context and handle scope
+ Q_D(const QQuickXmlListModel);
+
+ if (index < 0 || index >= count())
+ return QQmlV8Handle::fromHandle(v8::Undefined());
+
+ QQmlEngine *engine = qmlContext(this)->engine();
+ QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine);
+ v8::Local<v8::Object> rv = v8::Object::New();
+ for (int ii = 0; ii < d->roleObjects.count(); ++ii)
+ rv->Set(v8engine->toString(d->roleObjects[ii]->name()),
+ v8engine->fromVariant(d->data.value(ii).value(index)));
+
+ return QQmlV8Handle::fromHandle(rv);
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::XmlListModel::status
+ Specifies the model loading status, which can be one of the following:
+
+ \list
+ \o XmlListModel.Null - No XML data has been set for this model.
+ \o XmlListModel.Ready - The XML data has been loaded into the model.
+ \o XmlListModel.Loading - The model is in the process of reading and loading XML data.
+ \o XmlListModel.Error - An error occurred while the model was loading. See errorString() for details
+ about the error.
+ \endlist
+
+ \sa progress
+
+*/
+QQuickXmlListModel::Status QQuickXmlListModel::status() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->status;
+}
+
+/*!
+ \qmlproperty real QtQuick2::XmlListModel::progress
+
+ This indicates the current progress of the downloading of the XML data
+ source. This value ranges from 0.0 (no data downloaded) to
+ 1.0 (all data downloaded). If the XML data is not from a remote source,
+ the progress becomes 1.0 as soon as the data is read.
+
+ Note that when the progress is 1.0, the XML data has been downloaded, but
+ it is yet to be loaded into the model at this point. Use the status
+ property to find out when the XML data has been read and loaded into
+ the model.
+
+ \sa status, source
+*/
+qreal QQuickXmlListModel::progress() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->progress;
+}
+
+/*!
+ \qmlmethod void QtQuick2::XmlListModel::errorString()
+
+ Returns a string description of the last error that occurred
+ if \l status is XmlListModel::Error.
+*/
+QString QQuickXmlListModel::errorString() const
+{
+ Q_D(const QQuickXmlListModel);
+ return d->errorString;
+}
+
+void QQuickXmlListModel::classBegin()
+{
+ Q_D(QQuickXmlListModel);
+ d->isComponentComplete = false;
+
+ QQuickXmlQueryEngine *queryEngine = QQuickXmlQueryEngine::instance(qmlEngine(this));
+ connect(queryEngine, SIGNAL(queryCompleted(QQuickXmlQueryResult)),
+ SLOT(queryCompleted(QQuickXmlQueryResult)));
+ connect(queryEngine, SIGNAL(error(void*,QString)),
+ SLOT(queryError(void*,QString)));
+}
+
+void QQuickXmlListModel::componentComplete()
+{
+ Q_D(QQuickXmlListModel);
+ d->isComponentComplete = true;
+ reload();
+}
+
+/*!
+ \qmlmethod QtQuick2::XmlListModel::reload()
+
+ Reloads the model.
+
+ If no key roles have been specified, all existing model
+ data is removed, and the model is rebuilt from scratch.
+
+ Otherwise, items are only added if the model does not already
+ contain items with matching key role values.
+
+ \sa {Using key XML roles}, XmlRole::isKey
+*/
+void QQuickXmlListModel::reload()
+{
+ Q_D(QQuickXmlListModel);
+
+ if (!d->isComponentComplete)
+ return;
+
+ QQuickXmlQueryEngine::instance(qmlEngine(this))->abort(d->queryId);
+ d->queryId = -1;
+
+ if (d->size < 0)
+ d->size = 0;
+
+ if (d->reply) {
+ d->reply->abort();
+ d->deleteReply();
+ }
+
+ if (!d->xml.isEmpty()) {
+ d->queryId = QQuickXmlQueryEngine::instance(qmlEngine(this))->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache);
+ d->notifyQueryStarted(false);
+
+ } else if (d->src.isEmpty()) {
+ d->queryId = XMLLISTMODEL_CLEAR_ID;
+ d->notifyQueryStarted(false);
+ QTimer::singleShot(0, this, SLOT(dataCleared()));
+
+ } else {
+ d->notifyQueryStarted(true);
+ QNetworkRequest req(d->src);
+ req.setRawHeader("Accept", "application/xml,*/*");
+ d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
+ QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ }
+}
+
+#define XMLLISTMODEL_MAX_REDIRECT 16
+
+void QQuickXmlListModel::requestFinished()
+{
+ Q_D(QQuickXmlListModel);
+
+ d->redirectCount++;
+ if (d->redirectCount < XMLLISTMODEL_MAX_REDIRECT) {
+ QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = d->reply->url().resolved(redirect.toUrl());
+ d->deleteReply();
+ setSource(url);
+ return;
+ }
+ }
+ d->redirectCount = 0;
+
+ if (d->reply->error() != QNetworkReply::NoError) {
+ d->errorString = d->reply->errorString();
+ d->deleteReply();
+
+ int count = this->count();
+ d->data.clear();
+ d->size = 0;
+ if (count > 0) {
+ emit itemsRemoved(0, count);
+ emit countChanged();
+ }
+
+ d->status = Error;
+ d->queryId = -1;
+ emit statusChanged(d->status);
+ } else {
+ QByteArray data = d->reply->readAll();
+ if (data.isEmpty()) {
+ d->queryId = XMLLISTMODEL_CLEAR_ID;
+ QTimer::singleShot(0, this, SLOT(dataCleared()));
+ } else {
+ d->queryId = QQuickXmlQueryEngine::instance(qmlEngine(this))->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache);
+ }
+ d->deleteReply();
+
+ d->progress = 1.0;
+ emit progressChanged(d->progress);
+ }
+}
+
+void QQuickXmlListModel::requestProgress(qint64 received, qint64 total)
+{
+ Q_D(QQuickXmlListModel);
+ if (d->status == Loading && total > 0) {
+ d->progress = qreal(received)/total;
+ emit progressChanged(d->progress);
+ }
+}
+
+void QQuickXmlListModel::dataCleared()
+{
+ Q_D(QQuickXmlListModel);
+ QQuickXmlQueryResult r;
+ r.queryId = XMLLISTMODEL_CLEAR_ID;
+ r.size = 0;
+ r.removed << qMakePair(0, count());
+ r.keyRoleResultsCache = d->keyRoleResultsCache;
+ queryCompleted(r);
+}
+
+void QQuickXmlListModel::queryError(void* object, const QString& error)
+{
+ // Be extra careful, object may no longer exist, it's just an ID.
+ Q_D(QQuickXmlListModel);
+ for (int i=0; i<d->roleObjects.count(); i++) {
+ if (d->roleObjects.at(i) == static_cast<QQuickXmlListModelRole*>(object)) {
+ qmlInfo(d->roleObjects.at(i)) << QObject::tr("invalid query: \"%1\"").arg(error);
+ return;
+ }
+ }
+ qmlInfo(this) << QObject::tr("invalid query: \"%1\"").arg(error);
+}
+
+void QQuickXmlListModel::queryCompleted(const QQuickXmlQueryResult &result)
+{
+ Q_D(QQuickXmlListModel);
+ if (result.queryId != d->queryId)
+ return;
+
+ int origCount = d->size;
+ bool sizeChanged = result.size != d->size;
+
+ d->size = result.size;
+ d->data = result.data;
+ d->keyRoleResultsCache = result.keyRoleResultsCache;
+ if (d->src.isEmpty() && d->xml.isEmpty())
+ d->status = Null;
+ else
+ d->status = Ready;
+ d->errorString.clear();
+ d->queryId = -1;
+
+ bool hasKeys = false;
+ for (int i=0; i<d->roleObjects.count(); i++) {
+ if (d->roleObjects[i]->isKey()) {
+ hasKeys = true;
+ break;
+ }
+ }
+ if (!hasKeys) {
+ if (!(origCount == 0 && d->size == 0)) {
+ emit itemsRemoved(0, origCount);
+ emit itemsInserted(0, d->size);
+ emit countChanged();
+ }
+
+ } else {
+ for (int i=0; i<result.removed.count(); i++)
+ emit itemsRemoved(result.removed[i].first, result.removed[i].second);
+ for (int i=0; i<result.inserted.count(); i++)
+ emit itemsInserted(result.inserted[i].first, result.inserted[i].second);
+
+ if (sizeChanged)
+ emit countChanged();
+ }
+
+ emit statusChanged(d->status);
+}
+
+QT_END_NAMESPACE
+
+#include <qqmlxmllistmodel.moc>
diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel_p.h b/src/imports/xmllistmodel/qqmlxmllistmodel_p.h
new file mode 100644
index 0000000000..5bc4c7b494
--- /dev/null
+++ b/src/imports/xmllistmodel/qqmlxmllistmodel_p.h
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKXMLLISTMODEL_H
+#define QQUICKXMLLISTMODEL_H
+
+#include <qqml.h>
+#include <qqmlinfo.h>
+
+#include <QtCore/qurl.h>
+#include <QtCore/qstringlist.h>
+
+#include <private/qlistmodelinterface_p.h>
+#include <private/qv8engine_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlContext;
+class QQuickXmlListModelRole;
+class QQuickXmlListModelPrivate;
+
+struct QQuickXmlQueryResult {
+ int queryId;
+ int size;
+ QList<QList<QVariant> > data;
+ QList<QPair<int, int> > inserted;
+ QList<QPair<int, int> > removed;
+ QStringList keyRoleResultsCache;
+};
+
+class QQuickXmlListModel : public QListModelInterface, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_ENUMS(Status)
+
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QString xml READ xml WRITE setXml NOTIFY xmlChanged)
+ Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
+ Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations NOTIFY namespaceDeclarationsChanged)
+ Q_PROPERTY(QQmlListProperty<QQuickXmlListModelRole> roles READ roleObjects)
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+ Q_CLASSINFO("DefaultProperty", "roles")
+
+public:
+ QQuickXmlListModel(QObject *parent = 0);
+ ~QQuickXmlListModel();
+
+ virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
+ virtual QVariant data(int index, int role) const;
+ virtual int count() const;
+ virtual QList<int> roles() const;
+ virtual QString toString(int role) const;
+
+ QQmlListProperty<QQuickXmlListModelRole> roleObjects();
+
+ QUrl source() const;
+ void setSource(const QUrl&);
+
+ QString xml() const;
+ void setXml(const QString&);
+
+ QString query() const;
+ void setQuery(const QString&);
+
+ QString namespaceDeclarations() const;
+ void setNamespaceDeclarations(const QString&);
+
+ Q_INVOKABLE QQmlV8Handle get(int index) const;
+
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+ qreal progress() const;
+
+ Q_INVOKABLE QString errorString() const;
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+Q_SIGNALS:
+ void statusChanged(QQuickXmlListModel::Status);
+ void progressChanged(qreal progress);
+ void countChanged();
+ void sourceChanged();
+ void xmlChanged();
+ void queryChanged();
+ void namespaceDeclarationsChanged();
+
+public Q_SLOTS:
+ // ### need to use/expose Expiry to guess when to call this?
+ // ### property to auto-call this on reasonable Expiry?
+ // ### LastModified/Age also useful to guess.
+ // ### Probably also applies to other network-requesting types.
+ void reload();
+
+private Q_SLOTS:
+ void requestFinished();
+ void requestProgress(qint64,qint64);
+ void dataCleared();
+ void queryCompleted(const QQuickXmlQueryResult &);
+ void queryError(void* object, const QString& error);
+
+private:
+ Q_DECLARE_PRIVATE(QQuickXmlListModel)
+ Q_DISABLE_COPY(QQuickXmlListModel)
+};
+
+class QQuickXmlListModelRole : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
+ Q_PROPERTY(bool isKey READ isKey WRITE setIsKey NOTIFY isKeyChanged)
+public:
+ QQuickXmlListModelRole() : m_isKey(false) {}
+ ~QQuickXmlListModelRole() {}
+
+ QString name() const { return m_name; }
+ void setName(const QString &name) {
+ if (name == m_name)
+ return;
+ m_name = name;
+ emit nameChanged();
+ }
+
+ QString query() const { return m_query; }
+ void setQuery(const QString &query)
+ {
+ if (query.startsWith(QLatin1Char('/'))) {
+ qmlInfo(this) << tr("An XmlRole query must not start with '/'");
+ return;
+ }
+ if (m_query == query)
+ return;
+ m_query = query;
+ emit queryChanged();
+ }
+
+ bool isKey() const { return m_isKey; }
+ void setIsKey(bool b) {
+ if (m_isKey == b)
+ return;
+ m_isKey = b;
+ emit isKeyChanged();
+ }
+
+ bool isValid() {
+ return !m_name.isEmpty() && !m_query.isEmpty();
+ }
+
+Q_SIGNALS:
+ void nameChanged();
+ void queryChanged();
+ void isKeyChanged();
+
+private:
+ QString m_name;
+ QString m_query;
+ bool m_isKey;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickXmlListModel)
+QML_DECLARE_TYPE(QQuickXmlListModelRole)
+
+QT_END_HEADER
+
+#endif // QQUICKXMLLISTMODEL_H
diff --git a/src/imports/xmllistmodel/xmllistmodel.pro b/src/imports/xmllistmodel/xmllistmodel.pro
index d8121e8db8..8c056e8448 100644
--- a/src/imports/xmllistmodel/xmllistmodel.pro
+++ b/src/imports/xmllistmodel/xmllistmodel.pro
@@ -2,12 +2,12 @@ TARGET = qmlxmllistmodelplugin
TARGETPATH = QtQuick/XmlListModel
include(../qimportbase.pri)
-QT += network declarative xmlpatterns declarative-private v8-private core-private
+QT += network qml xmlpatterns qml-private v8-private core-private
-SOURCES += qdeclarativexmllistmodel.cpp plugin.cpp
-HEADERS += qdeclarativexmllistmodel_p.h
+SOURCES += qqmlxmllistmodel.cpp plugin.cpp
+HEADERS += qqmlxmllistmodel_p.h
-DESTDIR = $$QT.declarative.imports/$$TARGETPATH
+DESTDIR = $$QT.qml.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
qmldir.files += $$PWD/qmldir
diff --git a/src/plugins/accessible/quick/main.cpp b/src/plugins/accessible/quick/main.cpp
index af9555c690..6ff3d5db9e 100644
--- a/src/plugins/accessible/quick/main.cpp
+++ b/src/plugins/accessible/quick/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,7 +40,7 @@
****************************************************************************/
-#include "qdeclarativeaccessible.h"
+#include "qqmlaccessible.h"
#include "qaccessiblequickview.h"
#include "qaccessiblequickitem.h"
diff --git a/src/plugins/accessible/quick/qaccessiblequickitem.cpp b/src/plugins/accessible/quick/qaccessiblequickitem.cpp
index 806a0f50c8..78e7ca86ef 100644
--- a/src/plugins/accessible/quick/qaccessiblequickitem.cpp
+++ b/src/plugins/accessible/quick/qaccessiblequickitem.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -47,7 +47,7 @@
QT_BEGIN_NAMESPACE
QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
- : QDeclarativeAccessible(item)
+ : QQmlAccessible(item)
{
}
diff --git a/src/plugins/accessible/quick/qaccessiblequickitem.h b/src/plugins/accessible/quick/qaccessiblequickitem.h
index a283f853fd..5c19666f32 100644
--- a/src/plugins/accessible/quick/qaccessiblequickitem.h
+++ b/src/plugins/accessible/quick/qaccessiblequickitem.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,13 +44,13 @@
#include <QtQuick/QQuickItem>
#include <QtQuick/QQuickView>
-#include "qdeclarativeaccessible.h"
+#include "qqmlaccessible.h"
QT_BEGIN_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY
-class QAccessibleQuickItem : public QDeclarativeAccessible
+class QAccessibleQuickItem : public QQmlAccessible
{
public:
QAccessibleQuickItem(QQuickItem *item);
diff --git a/src/plugins/accessible/quick/qaccessiblequickview.cpp b/src/plugins/accessible/quick/qaccessiblequickview.cpp
index 05f0b8eed9..042d8dcf06 100644
--- a/src/plugins/accessible/quick/qaccessiblequickview.cpp
+++ b/src/plugins/accessible/quick/qaccessiblequickview.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,7 +45,7 @@
#include <QtQuick/private/qquickitem_p.h>
#include "qaccessiblequickitem.h"
-#include "qdeclarativeaccessible.h"
+#include "qqmlaccessible.h"
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/quick/qaccessiblequickview.h b/src/plugins/accessible/quick/qaccessiblequickview.h
index 66c8a52168..3ad87df937 100644
--- a/src/plugins/accessible/quick/qaccessiblequickview.h
+++ b/src/plugins/accessible/quick/qaccessiblequickview.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/accessible/quick/quick.pro b/src/plugins/accessible/quick/quick.pro
index add275a815..213d2e889b 100644
--- a/src/plugins/accessible/quick/quick.pro
+++ b/src/plugins/accessible/quick/quick.pro
@@ -4,7 +4,7 @@ TARGET = qtaccessiblequick
load(qt_plugin)
include ($$PWD/../shared/qaccessiblebase.pri)
-QT += core-private gui-private v8-private declarative-private quick-private
+QT += core-private gui-private v8-private qml-private quick-private
DESTDIR = $$QT.gui.plugins/accessible
QTDIR_build:REQUIRES += "contains(QT_CONFIG, accessibility)"
diff --git a/src/plugins/accessible/shared/qaccessiblebase.pri b/src/plugins/accessible/shared/qaccessiblebase.pri
index 8c82705443..56a8a1c9ef 100644
--- a/src/plugins/accessible/shared/qaccessiblebase.pri
+++ b/src/plugins/accessible/shared/qaccessiblebase.pri
@@ -3,5 +3,5 @@ INSTALLS += target
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
-SOURCES += $$PWD/qdeclarativeaccessible.cpp
-HEADERS += $$PWD/qdeclarativeaccessible.h
+SOURCES += $$PWD/qqmlaccessible.cpp
+HEADERS += $$PWD/qqmlaccessible.h
diff --git a/src/plugins/accessible/shared/qdeclarativeaccessible.cpp b/src/plugins/accessible/shared/qdeclarativeaccessible.cpp
deleted file mode 100644
index a063dd043d..0000000000
--- a/src/plugins/accessible/shared/qdeclarativeaccessible.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qnamespace.h>
-#include "qdeclarativeaccessible.h"
-
-#ifndef QT_NO_ACCESSIBILITY
-
-QT_BEGIN_NAMESPACE
-
-
-QString Q_GUI_EXPORT qTextBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset, const QString& text);
-QString Q_GUI_EXPORT qTextAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset, const QString& text);
-QString Q_GUI_EXPORT qTextAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset, const QString& text);
-
-QDeclarativeAccessible::QDeclarativeAccessible(QObject *object)
- :QAccessibleObject(object)
-{
-}
-
-QDeclarativeAccessible::~QDeclarativeAccessible()
-{
-}
-
-QAccessibleInterface *QDeclarativeAccessible::childAt(int x, int y) const
-{
- // Note that this function will disregard stacking order.
- // (QAccessibleQuickView::childAt() does this correctly and more efficient)
-
- // If the item clips its children, we can return early if the coordinate is outside its rect
- if (clipsChildren()) {
- if (!rect().contains(x, y))
- return 0;
- }
-
- for (int i = childCount() - 1; i >= 0; --i) {
- QAccessibleInterface *childIface = child(i);
- if (childIface && !childIface->state().invisible) {
- if (childIface->rect().contains(x, y))
- return childIface;
- }
- delete childIface;
- }
- return 0;
-}
-
-QAccessible::State QDeclarativeAccessible::state() const
-{
- QAccessible::State state;
-
- //QRect viewRect(QPoint(0, 0), m_implementation->size());
- //QRect itemRect(m_item->scenePos().toPoint(), m_item->boundingRect().size().toSize());
-
- QRect viewRect_ = viewRect();
- QRect itemRect = rect();
-
- // qDebug() << "viewRect" << viewRect << "itemRect" << itemRect;
- // error case:
- if (viewRect_.isNull() || itemRect.isNull()) {
- state.invisible = true;
- }
-
- if (!viewRect_.intersects(itemRect)) {
- state.offscreen = true;
- // state.invisible = true; // no set at this point to ease development
- }
-
- if (!object()->property("visible").toBool() || qFuzzyIsNull(object()->property("opacity").toDouble())) {
- state.invisible = true;
- }
-
- if ((role() == QAccessible::CheckBox || role() == QAccessible::RadioButton) && object()->property("checked").toBool()) {
- state.checked = true;
- }
-
- if (role() == QAccessible::EditableText)
- state.focusable = true;
-
- //qDebug() << "state?" << m_item->property("state").toString() << m_item->property("status").toString() << m_item->property("visible").toString();
-
- return state;
-}
-
-QStringList QDeclarativeAccessible::actionNames() const
-{
- QStringList actions;
- switch (role()) {
- case QAccessible::PushButton:
- actions << QAccessibleActionInterface::pressAction();
- break;
- case QAccessible::RadioButton:
- case QAccessible::CheckBox:
- actions << QAccessibleActionInterface::checkAction();
- break;
- default:
- break;
- }
- return actions;
-}
-
-void QDeclarativeAccessible::doAction(const QString &actionName)
-{
- if (role() == QAccessible::PushButton && actionName == QAccessibleActionInterface::pressAction()) {
- QMetaObject::invokeMethod(object(), "accessibleAction");
- }
- if ((role() == QAccessible::CheckBox || role() == QAccessible::RadioButton) && actionName == QAccessibleActionInterface::checkAction()) {
- bool checked = object()->property("checked").toBool();
- object()->setProperty("checked", QVariant(!checked));
- }
-}
-
-QStringList QDeclarativeAccessible::keyBindingsForAction(const QString &actionName) const
-{
- Q_UNUSED(actionName)
- return QStringList();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/shared/qdeclarativeaccessible.h b/src/plugins/accessible/shared/qdeclarativeaccessible.h
deleted file mode 100644
index 924e454fc9..0000000000
--- a/src/plugins/accessible/shared/qdeclarativeaccessible.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEACCESSIBLE_H
-#define QDECLARATIVEACCESSIBLE_H
-
-#include <QtGui/qaccessibleobject.h>
-#include <QtGui/qaccessible2.h>
-//#include <QtQuick1/qdeclarativeview.h>
-//#include <QtQuick1/qdeclarativeitem.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-
-//#include <private/qdeclarativeaccessible_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_ACCESSIBILITY
-
-/*
- -- Declarative Accessibility Overview. --
-
- * Item interface classes:
- QAccessibleDeclarativeItem for QtQuick1
- QAccessibleQuickItem for for QtQuick2
- Common base class: QDeclarativeAccessible
-
- * View interface classes.
-
- These are the root of the QML accessible tree and connects it to the widget hierarchy.
-
- QAccessbileDeclarativeView is the root for the QGraphicsView implementation
- QAccessbileQuickView is the root for the SceneGraph implementation
-
-*/
-class QDeclarativeAccessible: public QAccessibleObject, public QAccessibleActionInterface
-{
-public:
- ~QDeclarativeAccessible();
-
- virtual QRect viewRect() const = 0;
- QAccessibleInterface *childAt(int, int) const;
- QAccessible::State state() const;
-
- QStringList actionNames() const;
- void doAction(const QString &actionName);
- QStringList keyBindingsForAction(const QString &actionName) const;
-
-protected:
- virtual bool clipsChildren() const = 0;
- // For subclasses, use instantiateObject factory method outside the class.
- QDeclarativeAccessible(QObject *object);
-};
-
-#endif // QT_NO_ACCESSIBILITY
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEACCESSIBLE_H
diff --git a/src/plugins/accessible/shared/qqmlaccessible.cpp b/src/plugins/accessible/shared/qqmlaccessible.cpp
new file mode 100644
index 0000000000..1818ebebfe
--- /dev/null
+++ b/src/plugins/accessible/shared/qqmlaccessible.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qnamespace.h>
+#include "qqmlaccessible.h"
+
+#ifndef QT_NO_ACCESSIBILITY
+
+QT_BEGIN_NAMESPACE
+
+
+QString Q_GUI_EXPORT qTextBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset, const QString& text);
+QString Q_GUI_EXPORT qTextAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset, const QString& text);
+QString Q_GUI_EXPORT qTextAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset, const QString& text);
+
+QQmlAccessible::QQmlAccessible(QObject *object)
+ :QAccessibleObject(object)
+{
+}
+
+QQmlAccessible::~QQmlAccessible()
+{
+}
+
+QAccessibleInterface *QQmlAccessible::childAt(int x, int y) const
+{
+ // Note that this function will disregard stacking order.
+ // (QAccessibleQuickView::childAt() does this correctly and more efficient)
+
+ // If the item clips its children, we can return early if the coordinate is outside its rect
+ if (clipsChildren()) {
+ if (!rect().contains(x, y))
+ return 0;
+ }
+
+ for (int i = childCount() - 1; i >= 0; --i) {
+ QAccessibleInterface *childIface = child(i);
+ if (childIface && !childIface->state().invisible) {
+ if (childIface->rect().contains(x, y))
+ return childIface;
+ }
+ delete childIface;
+ }
+ return 0;
+}
+
+QAccessible::State QQmlAccessible::state() const
+{
+ QAccessible::State state;
+
+ //QRect viewRect(QPoint(0, 0), m_implementation->size());
+ //QRect itemRect(m_item->scenePos().toPoint(), m_item->boundingRect().size().toSize());
+
+ QRect viewRect_ = viewRect();
+ QRect itemRect = rect();
+
+ // qDebug() << "viewRect" << viewRect << "itemRect" << itemRect;
+ // error case:
+ if (viewRect_.isNull() || itemRect.isNull()) {
+ state.invisible = true;
+ }
+
+ if (!viewRect_.intersects(itemRect)) {
+ state.offscreen = true;
+ // state.invisible = true; // no set at this point to ease development
+ }
+
+ if (!object()->property("visible").toBool() || qFuzzyIsNull(object()->property("opacity").toDouble())) {
+ state.invisible = true;
+ }
+
+ if ((role() == QAccessible::CheckBox || role() == QAccessible::RadioButton) && object()->property("checked").toBool()) {
+ state.checked = true;
+ }
+
+ if (role() == QAccessible::EditableText)
+ state.focusable = true;
+
+ //qDebug() << "state?" << m_item->property("state").toString() << m_item->property("status").toString() << m_item->property("visible").toString();
+
+ return state;
+}
+
+QStringList QQmlAccessible::actionNames() const
+{
+ QStringList actions;
+ switch (role()) {
+ case QAccessible::PushButton:
+ actions << QAccessibleActionInterface::pressAction();
+ break;
+ case QAccessible::RadioButton:
+ case QAccessible::CheckBox:
+ actions << QAccessibleActionInterface::checkAction();
+ break;
+ default:
+ break;
+ }
+ return actions;
+}
+
+void QQmlAccessible::doAction(const QString &actionName)
+{
+ if (role() == QAccessible::PushButton && actionName == QAccessibleActionInterface::pressAction()) {
+ QMetaObject::invokeMethod(object(), "accessibleAction");
+ }
+ if ((role() == QAccessible::CheckBox || role() == QAccessible::RadioButton) && actionName == QAccessibleActionInterface::checkAction()) {
+ bool checked = object()->property("checked").toBool();
+ object()->setProperty("checked", QVariant(!checked));
+ }
+}
+
+QStringList QQmlAccessible::keyBindingsForAction(const QString &actionName) const
+{
+ Q_UNUSED(actionName)
+ return QStringList();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/shared/qqmlaccessible.h b/src/plugins/accessible/shared/qqmlaccessible.h
new file mode 100644
index 0000000000..570a3c8c40
--- /dev/null
+++ b/src/plugins/accessible/shared/qqmlaccessible.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLACCESSIBLE_H
+#define QQMLACCESSIBLE_H
+
+#include <QtGui/qaccessibleobject.h>
+#include <QtGui/qaccessible2.h>
+//#include <QtQuick1/qdeclarativeview.h>
+//#include <QtQuick1/qdeclarativeitem.h>
+#include <QtQml/qqmlproperty.h>
+
+//#include <private/qdeclarativeaccessible_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACCESSIBILITY
+
+/*
+ -- Declarative Accessibility Overview. --
+
+ * Item interface classes:
+ QAccessibleDeclarativeItem for QtQuick1
+ QAccessibleQuickItem for for QtQuick2
+ Common base class: QQmlAccessible
+
+ * View interface classes.
+
+ These are the root of the QML accessible tree and connects it to the widget hierarchy.
+
+ QAccessbileDeclarativeView is the root for the QGraphicsView implementation
+ QAccessbileQuickView is the root for the SceneGraph implementation
+
+*/
+class QQmlAccessible: public QAccessibleObject, public QAccessibleActionInterface
+{
+public:
+ ~QQmlAccessible();
+
+ virtual QRect viewRect() const = 0;
+ QAccessibleInterface *childAt(int, int) const;
+ QAccessible::State state() const;
+
+ QStringList actionNames() const;
+ void doAction(const QString &actionName);
+ QStringList keyBindingsForAction(const QString &actionName) const;
+
+protected:
+ virtual bool clipsChildren() const = 0;
+ // For subclasses, use instantiateObject factory method outside the class.
+ QQmlAccessible(QObject *object);
+};
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+#endif // QQMLACCESSIBLE_H
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro b/src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro
index c1ca2a5ef9..6f973bcc18 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro
+++ b/src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro
@@ -1,10 +1,10 @@
TARGET = qmldbg_ost
-QT += declarative network
+QT += qml network
load(qt_plugin)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling
-QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)"
+QTDIR_build:REQUIRES += "contains(QT_CONFIG, qml)"
SOURCES += \
qmlostplugin.cpp \
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp
index d4d9629334..9bd68e7401 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp
+++ b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#include "qmlostplugin.h"
#include "qostdevice.h"
-#include <private/qdeclarativedebugserver_p.h>
+#include <private/qqmldebugserver_p.h>
#include <private/qpacketprotocol_p.h>
QT_BEGIN_NAMESPACE
@@ -55,7 +55,7 @@ public:
QOstDevice *ost;
QPacketProtocol *protocol;
- QDeclarativeDebugServer *debugServer;
+ QQmlDebugServer *debugServer;
};
QmlOstPluginPrivate::QmlOstPluginPrivate() :
@@ -75,7 +75,7 @@ QmlOstPlugin::~QmlOstPlugin()
delete d_ptr;
}
-void QmlOstPlugin::setServer(QDeclarativeDebugServer *server)
+void QmlOstPlugin::setServer(QQmlDebugServer *server)
{
Q_D(QmlOstPlugin);
d->debugServer = server;
@@ -127,12 +127,12 @@ void QmlOstPlugin::setPort(int port, bool block)
if (!ok) {
if (d->ost->errorString().length())
qDebug("Error from QOstDevice: %s", qPrintable(d->ost->errorString()));
- qWarning("QDeclarativeDebugServer: Unable to listen on OST"); // This message is part of the signalling - do not change the format!
+ qWarning("QQmlDebugServer: Unable to listen on OST"); // This message is part of the signalling - do not change the format!
return;
}
d->protocol = new QPacketProtocol(d->ost, this);
QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
- qWarning("QDeclarativeDebugServer: Waiting for connection via OST"); // This message is part of the signalling - do not change the format!
+ qWarning("QQmlDebugServer: Waiting for connection via OST"); // This message is part of the signalling - do not change the format!
}
void QmlOstPlugin::readyRead()
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h
index 1bbba93b94..41c3a07f25 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h
+++ b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,26 +43,26 @@
#define QMLOSTPLUGIN_H
#include <QtWidgets/QStylePlugin>
-#include <QtDeclarative/private/qdeclarativedebugserverconnection_p.h>
+#include <QtQml/private/qqmldebugserverconnection_p.h>
QT_BEGIN_NAMESPACE
-class QDeclarativeDebugServer;
+class QQmlDebugServer;
class QmlOstPluginPrivate;
-class QmlOstPlugin : public QObject, public QDeclarativeDebugServerConnection
+class QmlOstPlugin : public QObject, public QQmlDebugServerConnection
{
Q_OBJECT
Q_DECLARE_PRIVATE(QmlOstPlugin)
Q_DISABLE_COPY(QmlOstPlugin)
- Q_INTERFACES(QDeclarativeDebugServerConnection)
+ Q_INTERFACES(QQmlDebugServerConnection)
public:
QmlOstPlugin();
~QmlOstPlugin();
- void setServer(QDeclarativeDebugServer *server);
+ void setServer(QQmlDebugServer *server);
void setPort(int port, bool bock);
bool isConnected() const;
diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp
index 289418cd83..2c557ac3cc 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp
+++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h
index 609a71897b..4b645f9c8e 100644
--- a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h
+++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/qmldbg_ost/usbostcomm.h b/src/plugins/qmltooling/qmldbg_ost/usbostcomm.h
index 246e162aee..b9bf53fbd2 100644
--- a/src/plugins/qmltooling/qmldbg_ost/usbostcomm.h
+++ b/src/plugins/qmltooling/qmldbg_ost/usbostcomm.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp
index e0662da590..bb4048ee92 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h
index 82096c6abd..1b1f10c8bb 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro b/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro
index 24efee8725..f0514134d1 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro
@@ -1,11 +1,11 @@
load(qt_module)
TARGET = qmldbg_qtquick2
-QT += declarative-private quick-private core-private gui-private opengl-private v8-private
+QT += qml-private quick-private core-private gui-private opengl-private v8-private
load(qt_plugin)
-DESTDIR = $$QT.declarative.plugins/qmltooling
+DESTDIR = $$QT.qml.plugins/qmltooling
INCLUDEPATH *= $$PWD $$PWD/../shared
@@ -24,7 +24,7 @@ HEADERS += \
qquickviewinspector.h \
../shared/abstracttool.h \
../shared/abstractviewinspector.h \
- ../shared/qdeclarativeinspectorprotocol.h \
+ ../shared/qqmlinspectorprotocol.h \
../shared/qmlinspectorconstants.h
OTHER_FILES += qtquick2plugin.json
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp
index b146c6e846..200c66ee35 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -41,7 +41,7 @@
#include "qquickviewinspector.h"
-#include "qdeclarativeinspectorprotocol.h"
+#include "qqmlinspectorprotocol.h"
#include "highlight.h"
#include "selectiontool.h"
@@ -206,7 +206,7 @@ void QQuickViewInspector::setWindowFlags(Qt::WindowFlags flags)
w->setVisible(true);
}
-QDeclarativeEngine *QQuickViewInspector::declarativeEngine() const
+QQmlEngine *QQuickViewInspector::declarativeEngine() const
{
return m_view->engine();
}
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h
index 07c38b1d5e..fbc3c17b87 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -71,7 +71,7 @@ public:
void changeTool(InspectorProtocol::Tool tool);
Qt::WindowFlags windowFlags() const;
void setWindowFlags(Qt::WindowFlags flags);
- QDeclarativeEngine *declarativeEngine() const;
+ QQmlEngine *declarativeEngine() const;
QQuickView *view() const { return m_view; }
QQuickItem *overlay() const { return m_overlay; }
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp
index 1245a7e690..16dfaed597 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,7 +43,7 @@
#include "qquickviewinspector.h"
#include <QtCore/qplugin.h>
-#include <QtDeclarative/private/qdeclarativeinspectorservice_p.h>
+#include <QtQml/private/qqmlinspectorservice_p.h>
#include <QtQuick/QQuickView>
namespace QmlJSDebugger {
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h
index f6f668d6b4..6c3f3d6943 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -39,11 +39,11 @@
**
****************************************************************************/
-#ifndef QDECLARATIVEINSPECTORPLUGIN_H
-#define QDECLARATIVEINSPECTORPLUGIN_H
+#ifndef QTQUICK2PLUGINPLUGIN_H
+#define QTQUICK2PLUGINPLUGIN_H
#include <QtCore/QPointer>
-#include <QtDeclarative/private/qdeclarativeinspectorinterface_p.h>
+#include <QtQml/private/qqmlinspectorinterface_p.h>
namespace QmlJSDebugger {
@@ -51,18 +51,18 @@ class AbstractViewInspector;
namespace QtQuick2 {
-class QtQuick2Plugin : public QObject, public QDeclarativeInspectorInterface
+class QtQuick2Plugin : public QObject, public QQmlInspectorInterface
{
Q_OBJECT
Q_DISABLE_COPY(QtQuick2Plugin)
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeInspectorInterface" FILE "qtquick2plugin.json")
- Q_INTERFACES(QDeclarativeInspectorInterface)
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlInspectorInterface" FILE "qtquick2plugin.json")
+ Q_INTERFACES(QQmlInspectorInterface)
public:
QtQuick2Plugin();
~QtQuick2Plugin();
- // QDeclarativeInspectorInterface
+ // QQmlInspectorInterface
bool canHandleView(QObject *view);
void activate(QObject *view);
void deactivate();
@@ -75,4 +75,4 @@ private:
} // namespace QtQuick2
} // namespace QmlJSDebugger
-#endif // QDECLARATIVEINSPECTORPLUGIN_H
+#endif // QTQUICK2PLUGINPLUGIN_H
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.cpp
index efa079dcf1..5ad102a92d 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.cpp
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.h b/src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.h
index 7767317abe..c2aa26a1a7 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.h
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/selectiontool.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
index 075cc49ae5..0c5e196b18 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
+++ b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
@@ -1,12 +1,12 @@
load(qt_module)
TARGET = qmldbg_tcp
-QT += declarative-private network
+QT += qml-private network
load(qt_plugin)
-DESTDIR = $$QT.declarative.plugins/qmltooling
-QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)"
+DESTDIR = $$QT.qml.plugins/qmltooling
+QTDIR_build:REQUIRES += "contains(QT_CONFIG, qml)"
SOURCES += \
qtcpserverconnection.cpp
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
index 216c2c30b1..1c5ec37512 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,7 +45,7 @@
#include <QtNetwork/qtcpserver.h>
#include <QtNetwork/qtcpsocket.h>
-#include <private/qdeclarativedebugserver_p.h>
+#include <private/qqmldebugserver_p.h>
#include <private/qpacketprotocol_p.h>
QT_BEGIN_NAMESPACE
@@ -60,7 +60,7 @@ public:
QPacketProtocol *protocol;
QTcpServer *tcpServer;
- QDeclarativeDebugServer *debugServer;
+ QQmlDebugServer *debugServer;
};
QTcpServerConnectionPrivate::QTcpServerConnectionPrivate() :
@@ -84,7 +84,7 @@ QTcpServerConnection::~QTcpServerConnection()
delete d_ptr;
}
-void QTcpServerConnection::setServer(QDeclarativeDebugServer *server)
+void QTcpServerConnection::setServer(QQmlDebugServer *server)
{
Q_D(QTcpServerConnection);
d->debugServer = server;
@@ -147,9 +147,9 @@ void QTcpServerConnection::listen()
d->tcpServer = new QTcpServer(this);
QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
if (d->tcpServer->listen(QHostAddress::Any, d->port))
- qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port);
+ qWarning("QQmlDebugServer: Waiting for connection on port %d...", d->port);
else
- qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port);
+ qWarning("QQmlDebugServer: Unable to listen on port %d", d->port);
}
@@ -170,7 +170,7 @@ void QTcpServerConnection::newConnection()
Q_D(QTcpServerConnection);
if (d->socket && d->socket->peerPort()) {
- qWarning("QDeclarativeDebugServer: Another client is already connected");
+ qWarning("QQmlDebugServer: Another client is already connected");
QTcpSocket *faultyConnection = d->tcpServer->nextPendingConnection();
delete faultyConnection;
return;
@@ -190,7 +190,7 @@ void QTcpServerConnection::newConnection()
void QTcpServerConnection::invalidPacket()
{
- qWarning("QDeclarativeDebugServer: Received a corrupted packet! Giving up ...");
+ qWarning("QQmlDebugServer: Received a corrupted packet! Giving up ...");
}
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
index 1154a0aa25..e81c9f7f0f 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,25 +43,25 @@
#define QTCPSERVERCONNECTION_H
#include <QtWidgets/QStylePlugin>
-#include <QtDeclarative/private/qdeclarativedebugserverconnection_p.h>
+#include <QtQml/private/qqmldebugserverconnection_p.h>
QT_BEGIN_NAMESPACE
-class QDeclarativeDebugServer;
+class QQmlDebugServer;
class QTcpServerConnectionPrivate;
-class QTcpServerConnection : public QObject, public QDeclarativeDebugServerConnection
+class QTcpServerConnection : public QObject, public QQmlDebugServerConnection
{
Q_OBJECT
Q_DECLARE_PRIVATE(QTcpServerConnection)
Q_DISABLE_COPY(QTcpServerConnection)
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeDebugServerConnection" FILE "qtcpserverconnection.json")
- Q_INTERFACES(QDeclarativeDebugServerConnection)
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlDebugServerConnection" FILE "qtcpserverconnection.json")
+ Q_INTERFACES(QQmlDebugServerConnection)
public:
QTcpServerConnection();
~QTcpServerConnection();
- void setServer(QDeclarativeDebugServer *server);
+ void setServer(QQmlDebugServer *server);
void setPort(int port, bool bock);
bool isConnected() const;
diff --git a/src/plugins/qmltooling/shared/abstracttool.cpp b/src/plugins/qmltooling/shared/abstracttool.cpp
index 0565537cca..69e468bd92 100644
--- a/src/plugins/qmltooling/shared/abstracttool.cpp
+++ b/src/plugins/qmltooling/shared/abstracttool.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/shared/abstracttool.h b/src/plugins/qmltooling/shared/abstracttool.h
index e21e3be1f8..35817064e2 100644
--- a/src/plugins/qmltooling/shared/abstracttool.h
+++ b/src/plugins/qmltooling/shared/abstracttool.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/plugins/qmltooling/shared/abstractviewinspector.cpp b/src/plugins/qmltooling/shared/abstractviewinspector.cpp
index cfa0f441cd..33e47d270d 100644
--- a/src/plugins/qmltooling/shared/abstractviewinspector.cpp
+++ b/src/plugins/qmltooling/shared/abstractviewinspector.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,12 +42,12 @@
#include "abstractviewinspector.h"
#include "abstracttool.h"
-#include "qdeclarativeinspectorprotocol.h"
+#include "qqmlinspectorprotocol.h"
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QtDeclarative/QDeclarativeComponent>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlComponent>
#include <QtCore/private/qabstractanimation_p.h>
-#include <QtDeclarative/private/qdeclarativeinspectorservice_p.h>
+#include <QtQml/private/qqmlinspectorservice_p.h>
#include <QtGui/QMouseEvent>
@@ -61,7 +61,7 @@ AbstractViewInspector::AbstractViewInspector(QObject *parent) :
m_designModeBehavior(false),
m_animationPaused(false),
m_slowDownFactor(1.0),
- m_debugService(QDeclarativeInspectorService::instance())
+ m_debugService(QQmlInspectorService::instance())
{
}
@@ -78,8 +78,8 @@ void AbstractViewInspector::createQmlObject(const QString &qml, QObject *parent,
imports += QLatin1Char('\n');
}
- QDeclarativeContext *parentContext = declarativeEngine()->contextForObject(parent);
- QDeclarativeComponent component(declarativeEngine());
+ QQmlContext *parentContext = declarativeEngine()->contextForObject(parent);
+ QQmlComponent component(declarativeEngine());
QByteArray constructedQml = QString(imports + qml).toLatin1();
component.setData(constructedQml, QUrl::fromLocalFile(filename));
@@ -316,7 +316,7 @@ void AbstractViewInspector::handleMessage(const QByteArray &message)
for (int i = 0; i < itemCount; ++i) {
int debugId = -1;
ds >> debugId;
- if (QObject *obj = QDeclarativeDebugService::objectForId(debugId))
+ if (QObject *obj = QQmlDebugService::objectForId(debugId))
selectedObjects << obj;
}
@@ -363,22 +363,22 @@ void AbstractViewInspector::handleMessage(const QByteArray &message)
QString filename;
QStringList imports;
ds >> qml >> parentId >> imports >> filename;
- createQmlObject(qml, QDeclarativeDebugService::objectForId(parentId),
+ createQmlObject(qml, QQmlDebugService::objectForId(parentId),
imports, filename);
break;
}
case InspectorProtocol::DestroyObject: {
int debugId;
ds >> debugId;
- if (QObject *obj = QDeclarativeDebugService::objectForId(debugId))
+ if (QObject *obj = QQmlDebugService::objectForId(debugId))
obj->deleteLater();
break;
}
case InspectorProtocol::MoveObject: {
int debugId, newParent;
ds >> debugId >> newParent;
- reparentQmlObject(QDeclarativeDebugService::objectForId(debugId),
- QDeclarativeDebugService::objectForId(newParent));
+ reparentQmlObject(QQmlDebugService::objectForId(debugId),
+ QQmlDebugService::objectForId(newParent));
break;
}
case InspectorProtocol::ObjectIdList: {
@@ -424,7 +424,7 @@ void AbstractViewInspector::sendCurrentObjects(const QList<QObject*> &objects)
<< objects.length();
foreach (QObject *object, objects) {
- int id = QDeclarativeDebugService::idForObject(object);
+ int id = QQmlDebugService::idForObject(object);
ds << id;
}
@@ -497,7 +497,7 @@ void AbstractViewInspector::sendColorChanged(const QColor &color)
QString AbstractViewInspector::idStringForObject(QObject *obj) const
{
- const int id = QDeclarativeDebugService::idForObject(obj);
+ const int id = QQmlDebugService::idForObject(obj);
return m_stringIdForObjectId.value(id);
}
diff --git a/src/plugins/qmltooling/shared/abstractviewinspector.h b/src/plugins/qmltooling/shared/abstractviewinspector.h
index 741013239f..0dacc92233 100644
--- a/src/plugins/qmltooling/shared/abstractviewinspector.h
+++ b/src/plugins/qmltooling/shared/abstractviewinspector.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -47,12 +47,12 @@
#include <QtCore/QStringList>
#include <QtGui/QColor>
-#include "qdeclarativeinspectorprotocol.h"
+#include "qqmlinspectorprotocol.h"
#include "qmlinspectorconstants.h"
QT_BEGIN_NAMESPACE
-class QDeclarativeEngine;
-class QDeclarativeInspectorService;
+class QQmlEngine;
+class QQmlInspectorService;
class QKeyEvent;
class QMouseEvent;
class QWheelEvent;
@@ -63,7 +63,7 @@ namespace QmlJSDebugger {
class AbstractTool;
/*
- * The common code between QQuickView and QDeclarativeView inspectors lives here,
+ * The common code between QQuickView and QQuickView inspectors lives here,
*/
class AbstractViewInspector : public QObject
{
@@ -100,7 +100,7 @@ public:
virtual void changeTool(InspectorProtocol::Tool tool) = 0;
virtual Qt::WindowFlags windowFlags() const = 0;
virtual void setWindowFlags(Qt::WindowFlags flags) = 0;
- virtual QDeclarativeEngine *declarativeEngine() const = 0;
+ virtual QQmlEngine *declarativeEngine() const = 0;
signals:
void designModeBehaviorChanged(bool inDesignMode);
@@ -159,7 +159,7 @@ private:
qreal m_slowDownFactor;
QHash<int, QString> m_stringIdForObjectId;
- QDeclarativeInspectorService *m_debugService;
+ QQmlInspectorService *m_debugService;
};
} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/shared/qdeclarativeinspectorprotocol.h b/src/plugins/qmltooling/shared/qdeclarativeinspectorprotocol.h
deleted file mode 100644
index 4c833b99dc..0000000000
--- a/src/plugins/qmltooling/shared/qdeclarativeinspectorprotocol.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEINSPECTORPROTOCOL_H
-#define QDECLARATIVEINSPECTORPROTOCOL_H
-
-#include <QtCore/QDebug>
-#include <QtCore/QMetaType>
-#include <QtCore/QMetaEnum>
-#include <QtCore/QObject>
-
-namespace QmlJSDebugger {
-
-class InspectorProtocol : public QObject
-{
- Q_OBJECT
- Q_ENUMS(Message Tool)
-
-public:
- enum Message {
- AnimationSpeedChanged = 0,
- AnimationPausedChanged = 19, // highest value
- ChangeTool = 1,
- ClearComponentCache = 2,
- ColorChanged = 3,
- CreateObject = 5,
- CurrentObjectsChanged = 6,
- DestroyObject = 7,
- MoveObject = 8,
- ObjectIdList = 9,
- Reload = 10,
- Reloaded = 11,
- SetAnimationSpeed = 12,
- SetAnimationPaused = 18,
- SetCurrentObjects = 14,
- SetDesignMode = 15,
- ShowAppOnTop = 16,
- ToolChanged = 17
- };
-
- enum Tool {
- ColorPickerTool,
- SelectMarqueeTool,
- SelectTool,
- ZoomTool
- };
-
- static inline QString toString(Message message)
- {
- return QLatin1String(staticMetaObject.enumerator(0).valueToKey(message));
- }
-
- static inline QString toString(Tool tool)
- {
- return QLatin1String(staticMetaObject.enumerator(1).valueToKey(tool));
- }
-};
-
-inline QDataStream & operator<< (QDataStream &stream, InspectorProtocol::Message message)
-{
- return stream << static_cast<quint32>(message);
-}
-
-inline QDataStream & operator>> (QDataStream &stream, InspectorProtocol::Message &message)
-{
- quint32 i;
- stream >> i;
- message = static_cast<InspectorProtocol::Message>(i);
- return stream;
-}
-
-inline QDebug operator<< (QDebug dbg, InspectorProtocol::Message message)
-{
- dbg << InspectorProtocol::toString(message);
- return dbg;
-}
-
-inline QDataStream & operator<< (QDataStream &stream, InspectorProtocol::Tool tool)
-{
- return stream << static_cast<quint32>(tool);
-}
-
-inline QDataStream & operator>> (QDataStream &stream, InspectorProtocol::Tool &tool)
-{
- quint32 i;
- stream >> i;
- tool = static_cast<InspectorProtocol::Tool>(i);
- return stream;
-}
-
-inline QDebug operator<< (QDebug dbg, InspectorProtocol::Tool tool)
-{
- dbg << InspectorProtocol::toString(tool);
- return dbg;
-}
-
-} // namespace QmlJSDebugger
-
-#endif // QDECLARATIVEINSPECTORPROTOCOL_H
diff --git a/src/plugins/qmltooling/shared/qmlinspectorconstants.h b/src/plugins/qmltooling/shared/qmlinspectorconstants.h
index 1b25486bb6..e5a0ee5450 100644
--- a/src/plugins/qmltooling/shared/qmlinspectorconstants.h
+++ b/src/plugins/qmltooling/shared/qmlinspectorconstants.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef QMLINSPECTORCONSTANTS_H
#define QMLINSPECTORCONSTANTS_H
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
+#include <QtQml/private/qqmlglobal_p.h>
namespace QmlJSDebugger {
namespace Constants {
diff --git a/src/plugins/qmltooling/shared/qqmlinspectorprotocol.h b/src/plugins/qmltooling/shared/qqmlinspectorprotocol.h
new file mode 100644
index 0000000000..63772aa8e4
--- /dev/null
+++ b/src/plugins/qmltooling/shared/qqmlinspectorprotocol.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLINSPECTORPROTOCOL_H
+#define QQMLINSPECTORPROTOCOL_H
+
+#include <QtCore/QDebug>
+#include <QtCore/QMetaType>
+#include <QtCore/QMetaEnum>
+#include <QtCore/QObject>
+
+namespace QmlJSDebugger {
+
+class InspectorProtocol : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(Message Tool)
+
+public:
+ enum Message {
+ AnimationSpeedChanged = 0,
+ AnimationPausedChanged = 19, // highest value
+ ChangeTool = 1,
+ ClearComponentCache = 2,
+ ColorChanged = 3,
+ CreateObject = 5,
+ CurrentObjectsChanged = 6,
+ DestroyObject = 7,
+ MoveObject = 8,
+ ObjectIdList = 9,
+ Reload = 10,
+ Reloaded = 11,
+ SetAnimationSpeed = 12,
+ SetAnimationPaused = 18,
+ SetCurrentObjects = 14,
+ SetDesignMode = 15,
+ ShowAppOnTop = 16,
+ ToolChanged = 17
+ };
+
+ enum Tool {
+ ColorPickerTool,
+ SelectMarqueeTool,
+ SelectTool,
+ ZoomTool
+ };
+
+ static inline QString toString(Message message)
+ {
+ return QLatin1String(staticMetaObject.enumerator(0).valueToKey(message));
+ }
+
+ static inline QString toString(Tool tool)
+ {
+ return QLatin1String(staticMetaObject.enumerator(1).valueToKey(tool));
+ }
+};
+
+inline QDataStream & operator<< (QDataStream &stream, InspectorProtocol::Message message)
+{
+ return stream << static_cast<quint32>(message);
+}
+
+inline QDataStream & operator>> (QDataStream &stream, InspectorProtocol::Message &message)
+{
+ quint32 i;
+ stream >> i;
+ message = static_cast<InspectorProtocol::Message>(i);
+ return stream;
+}
+
+inline QDebug operator<< (QDebug dbg, InspectorProtocol::Message message)
+{
+ dbg << InspectorProtocol::toString(message);
+ return dbg;
+}
+
+inline QDataStream & operator<< (QDataStream &stream, InspectorProtocol::Tool tool)
+{
+ return stream << static_cast<quint32>(tool);
+}
+
+inline QDataStream & operator>> (QDataStream &stream, InspectorProtocol::Tool &tool)
+{
+ quint32 i;
+ stream >> i;
+ tool = static_cast<InspectorProtocol::Tool>(i);
+ return stream;
+}
+
+inline QDebug operator<< (QDebug dbg, InspectorProtocol::Tool tool)
+{
+ dbg << InspectorProtocol::toString(tool);
+ return dbg;
+}
+
+} // namespace QmlJSDebugger
+
+#endif // QQMLINSPECTORPROTOCOL_H
diff --git a/src/declarative/animations/animations.pri b/src/qml/animations/animations.pri
index 01ac25af46..01ac25af46 100644
--- a/src/declarative/animations/animations.pri
+++ b/src/qml/animations/animations.pri
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp
new file mode 100644
index 0000000000..2bfc66fea0
--- /dev/null
+++ b/src/qml/animations/qabstractanimationjob.cpp
@@ -0,0 +1,544 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qthreadstorage.h>
+
+#include "private/qabstractanimationjob_p.h"
+#include "private/qanimationgroupjob_p.h"
+#include "private/qanimationjobutil_p.h"
+
+#define DEFAULT_TIMER_INTERVAL 16
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_THREAD
+Q_GLOBAL_STATIC(QThreadStorage<QQmlAnimationTimer *>, animationTimer)
+#endif
+
+QQmlAnimationTimer::QQmlAnimationTimer() :
+ QAbstractAnimationTimer(), lastTick(0), lastDelta(0),
+ currentAnimationIdx(0), insideTick(false),
+ startAnimationPending(false), stopTimerPending(false),
+ runningLeafAnimations(0)
+{
+}
+
+QQmlAnimationTimer *QQmlAnimationTimer::instance(bool create)
+{
+ QQmlAnimationTimer *inst;
+#ifndef QT_NO_THREAD
+ if (create && !animationTimer()->hasLocalData()) {
+ inst = new QQmlAnimationTimer;
+ animationTimer()->setLocalData(inst);
+ } else {
+ inst = animationTimer() ? animationTimer()->localData() : 0;
+ }
+#else
+ static QAnimationTimer unifiedTimer;
+ inst = &unifiedTimer;
+#endif
+ return inst;
+}
+
+QQmlAnimationTimer *QQmlAnimationTimer::instance()
+{
+ return instance(true);
+}
+
+void QQmlAnimationTimer::ensureTimerUpdate()
+{
+ QQmlAnimationTimer *inst = QQmlAnimationTimer::instance(false);
+ QUnifiedTimer *instU = QUnifiedTimer::instance(false);
+ if (instU && inst && inst->isPaused)
+ instU->updateAnimationTimers(-1);
+}
+
+void QQmlAnimationTimer::updateAnimationsTime(qint64 delta)
+{
+ //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations
+ if (insideTick)
+ return;
+
+ lastTick += delta;
+ lastDelta = delta;
+
+ //we make sure we only call update time if the time has actually changed
+ //it might happen in some cases that the time doesn't change because events are delayed
+ //when the CPU load is high
+ if (delta) {
+ insideTick = true;
+ for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
+ QAbstractAnimationJob *animation = animations.at(currentAnimationIdx);
+ int elapsed = animation->m_totalCurrentTime
+ + (animation->direction() == QAbstractAnimationJob::Forward ? delta : -delta);
+ animation->setCurrentTime(elapsed);
+ }
+ insideTick = false;
+ currentAnimationIdx = 0;
+ }
+}
+
+void QQmlAnimationTimer::updateAnimationTimer()
+{
+ QQmlAnimationTimer *inst = QQmlAnimationTimer::instance(false);
+ if (inst)
+ inst->restartAnimationTimer();
+}
+
+void QQmlAnimationTimer::restartAnimationTimer()
+{
+ if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty())
+ QUnifiedTimer::pauseAnimationTimer(this, closestPauseAnimationTimeToFinish());
+ else if (isPaused)
+ QUnifiedTimer::resumeAnimationTimer(this);
+ else if (!isRegistered)
+ QUnifiedTimer::startAnimationTimer(this);
+}
+
+void QQmlAnimationTimer::startAnimations()
+{
+ startAnimationPending = false;
+ //force timer to update, which prevents large deltas for our newly added animations
+ if (!animations.isEmpty())
+ QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime();
+
+ //we transfer the waiting animations into the "really running" state
+ animations += animationsToStart;
+ animationsToStart.clear();
+ if (!animations.isEmpty())
+ restartAnimationTimer();
+}
+
+void QQmlAnimationTimer::stopTimer()
+{
+ stopTimerPending = false;
+ if (animations.isEmpty()) {
+ QUnifiedTimer::resumeAnimationTimer(this);
+ QUnifiedTimer::stopAnimationTimer(this);
+ // invalidate the start reference time
+ lastTick = 0;
+ lastDelta = 0;
+ }
+}
+
+void QQmlAnimationTimer::registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel)
+{
+ QQmlAnimationTimer *inst = instance(true); //we create the instance if needed
+ inst->registerRunningAnimation(animation);
+ if (isTopLevel) {
+ Q_ASSERT(!animation->m_hasRegisteredTimer);
+ animation->m_hasRegisteredTimer = true;
+ inst->animationsToStart << animation;
+ if (!inst->startAnimationPending) {
+ inst->startAnimationPending = true;
+ QMetaObject::invokeMethod(inst, "startAnimations", Qt::QueuedConnection);
+ }
+ }
+}
+
+void QQmlAnimationTimer::unregisterAnimation(QAbstractAnimationJob *animation)
+{
+ QQmlAnimationTimer *inst = QQmlAnimationTimer::instance(false);
+ if (inst) {
+ //at this point the unified timer should have been created
+ //but it might also have been already destroyed in case the application is shutting down
+
+ inst->unregisterRunningAnimation(animation);
+
+ if (!animation->m_hasRegisteredTimer)
+ return;
+
+ int idx = inst->animations.indexOf(animation);
+ if (idx != -1) {
+ inst->animations.removeAt(idx);
+ // this is needed if we unregister an animation while its running
+ if (idx <= inst->currentAnimationIdx)
+ --inst->currentAnimationIdx;
+
+ if (inst->animations.isEmpty() && !inst->stopTimerPending) {
+ inst->stopTimerPending = true;
+ QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection);
+ }
+ } else {
+ inst->animationsToStart.removeOne(animation);
+ }
+ }
+ animation->m_hasRegisteredTimer = false;
+}
+
+void QQmlAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animation)
+{
+ if (animation->m_isGroup)
+ return;
+
+ if (animation->m_isPause) {
+ runningPauseAnimations << animation;
+ } else
+ runningLeafAnimations++;
+}
+
+void QQmlAnimationTimer::unregisterRunningAnimation(QAbstractAnimationJob *animation)
+{
+ if (animation->m_isGroup)
+ return;
+
+ if (animation->m_isPause)
+ runningPauseAnimations.removeOne(animation);
+ else
+ runningLeafAnimations--;
+ Q_ASSERT(runningLeafAnimations >= 0);
+}
+
+int QQmlAnimationTimer::closestPauseAnimationTimeToFinish()
+{
+ int closestTimeToFinish = INT_MAX;
+ for (int i = 0; i < runningPauseAnimations.size(); ++i) {
+ QAbstractAnimationJob *animation = runningPauseAnimations.at(i);
+ int timeToFinish;
+
+ if (animation->direction() == QAbstractAnimationJob::Forward)
+ timeToFinish = animation->duration() - animation->currentLoopTime();
+ else
+ timeToFinish = animation->currentLoopTime();
+
+ if (timeToFinish < closestTimeToFinish)
+ closestTimeToFinish = timeToFinish;
+ }
+ return closestTimeToFinish;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+QAbstractAnimationJob::QAbstractAnimationJob()
+ : m_isPause(false)
+ , m_isGroup(false)
+ , m_loopCount(1)
+ , m_group(0)
+ , m_direction(QAbstractAnimationJob::Forward)
+ , m_state(QAbstractAnimationJob::Stopped)
+ , m_totalCurrentTime(0)
+ , m_currentTime(0)
+ , m_currentLoop(0)
+ , m_hasRegisteredTimer(false)
+ , m_uncontrolledFinishTime(-1)
+ , m_wasDeleted(0)
+ , m_nextSibling(0)
+ , m_previousSibling(0)
+{
+}
+
+QAbstractAnimationJob::~QAbstractAnimationJob()
+{
+ if (m_wasDeleted)
+ *m_wasDeleted = true;
+
+ //we can't call stop here. Otherwise we get pure virtual calls
+ if (m_state != Stopped) {
+ State oldState = m_state;
+ m_state = Stopped;
+ stateChanged(oldState, m_state);
+ if (oldState == Running)
+ QQmlAnimationTimer::unregisterAnimation(this);
+ }
+
+ if (m_group)
+ m_group->removeAnimation(this);
+}
+
+void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState)
+{
+ if (m_state == newState)
+ return;
+
+ if (m_loopCount == 0)
+ return;
+
+ State oldState = m_state;
+ int oldCurrentTime = m_currentTime;
+ int oldCurrentLoop = m_currentLoop;
+ Direction oldDirection = m_direction;
+
+ // check if we should Rewind
+ if ((newState == Paused || newState == Running) && oldState == Stopped) {
+ //here we reset the time if needed
+ //we don't call setCurrentTime because this might change the way the animation
+ //behaves: changing the state or changing the current value
+ m_totalCurrentTime = m_currentTime = (m_direction == Forward) ?
+ 0 : (m_loopCount == -1 ? duration() : totalDuration());
+ }
+
+ m_state = newState;
+ //(un)registration of the animation must always happen before calls to
+ //virtual function (updateState) to ensure a correct state of the timer
+ bool isTopLevel = !m_group || m_group->isStopped();
+ if (oldState == Running) {
+ if (newState == Paused && m_hasRegisteredTimer)
+ QQmlAnimationTimer::ensureTimerUpdate();
+ //the animation, is not running any more
+ QQmlAnimationTimer::unregisterAnimation(this);
+ } else if (newState == Running) {
+ QQmlAnimationTimer::registerAnimation(this, isTopLevel);
+ }
+
+ //starting an animation qualifies as a top level loop change
+ if (newState == Running && oldState == Stopped && !m_group)
+ topLevelAnimationLoopChanged();
+
+ RETURN_IF_DELETED(updateState(newState, oldState));
+
+ if (newState != m_state) //this is to be safe if updateState changes the state
+ return;
+
+ // Notify state change
+ stateChanged(newState, oldState);
+ if (newState != m_state) //this is to be safe if updateState changes the state
+ return;
+
+ switch (m_state) {
+ case Paused:
+ break;
+ case Running:
+ {
+ // this ensures that the value is updated now that the animation is running
+ if (oldState == Stopped) {
+ if (isTopLevel) {
+ // currentTime needs to be updated if pauseTimer is active
+ QQmlAnimationTimer::ensureTimerUpdate();
+ setCurrentTime(m_totalCurrentTime);
+ }
+ }
+ }
+ break;
+ case Stopped:
+ // Leave running state.
+ int dura = duration();
+
+ if (dura == -1 || m_loopCount < 0
+ || (oldDirection == Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * m_loopCount))
+ || (oldDirection == Backward && oldCurrentTime == 0)) {
+ finished();
+ }
+ break;
+ }
+}
+
+void QAbstractAnimationJob::setDirection(Direction direction)
+{
+ if (m_direction == direction)
+ return;
+
+ if (m_state == Stopped) {
+ if (m_direction == Backward) {
+ m_currentTime = duration();
+ m_currentLoop = m_loopCount - 1;
+ } else {
+ m_currentTime = 0;
+ m_currentLoop = 0;
+ }
+ }
+
+ // the commands order below is important: first we need to setCurrentTime with the old direction,
+ // then update the direction on this and all children and finally restart the pauseTimer if needed
+ if (m_hasRegisteredTimer)
+ QQmlAnimationTimer::ensureTimerUpdate();
+
+ m_direction = direction;
+ updateDirection(direction);
+
+ if (m_hasRegisteredTimer)
+ // needed to update the timer interval in case of a pause animation
+ QQmlAnimationTimer::updateAnimationTimer();
+}
+
+void QAbstractAnimationJob::setLoopCount(int loopCount)
+{
+ m_loopCount = loopCount;
+}
+
+int QAbstractAnimationJob::totalDuration() const
+{
+ int dura = duration();
+ if (dura <= 0)
+ return dura;
+ int loopcount = loopCount();
+ if (loopcount < 0)
+ return -1;
+ return dura * loopcount;
+}
+
+void QAbstractAnimationJob::setCurrentTime(int msecs)
+{
+ msecs = qMax(msecs, 0);
+ // Calculate new time and loop.
+ int dura = duration();
+ int totalDura = dura <= 0 ? dura : ((m_loopCount < 0) ? -1 : dura * m_loopCount);
+ if (totalDura != -1)
+ msecs = qMin(totalDura, msecs);
+ m_totalCurrentTime = msecs;
+
+ // Update new values.
+ int oldLoop = m_currentLoop;
+ m_currentLoop = ((dura <= 0) ? 0 : (msecs / dura));
+ if (m_currentLoop == m_loopCount) {
+ //we're at the end
+ m_currentTime = qMax(0, dura);
+ m_currentLoop = qMax(0, m_loopCount - 1);
+ } else {
+ if (m_direction == Forward) {
+ m_currentTime = (dura <= 0) ? msecs : (msecs % dura);
+ } else {
+ m_currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1;
+ if (m_currentTime == dura)
+ --m_currentLoop;
+ }
+ }
+
+ if (m_currentLoop != oldLoop && !m_group) //### verify Running as well?
+ topLevelAnimationLoopChanged();
+
+ RETURN_IF_DELETED(updateCurrentTime(m_currentTime));
+
+ if (m_currentLoop != oldLoop)
+ currentLoopChanged(m_currentLoop);
+
+ // All animations are responsible for stopping the animation when their
+ // own end state is reached; in this case the animation is time driven,
+ // and has reached the end.
+ if ((m_direction == Forward && m_totalCurrentTime == totalDura)
+ || (m_direction == Backward && m_totalCurrentTime == 0)) {
+ stop();
+ }
+}
+
+void QAbstractAnimationJob::start()
+{
+ if (m_state == Running)
+ return;
+ setState(Running);
+}
+
+void QAbstractAnimationJob::stop()
+{
+ if (m_state == Stopped)
+ return;
+ setState(Stopped);
+}
+
+void QAbstractAnimationJob::pause()
+{
+ if (m_state == Stopped) {
+ qWarning("QAbstractAnimationJob::pause: Cannot pause a stopped animation");
+ return;
+ }
+
+ setState(Paused);
+}
+
+void QAbstractAnimationJob::resume()
+{
+ if (m_state != Paused) {
+ qWarning("QAbstractAnimationJob::resume: "
+ "Cannot resume an animation that is not paused");
+ return;
+ }
+ setState(Running);
+}
+
+void QAbstractAnimationJob::updateState(QAbstractAnimationJob::State newState,
+ QAbstractAnimationJob::State oldState)
+{
+ Q_UNUSED(oldState);
+ Q_UNUSED(newState);
+}
+
+void QAbstractAnimationJob::updateDirection(QAbstractAnimationJob::Direction direction)
+{
+ Q_UNUSED(direction);
+}
+
+void QAbstractAnimationJob::finished()
+{
+ //TODO: update this code so it is valid to delete the animation in animationFinished
+ for (int i = 0; i < changeListeners.count(); ++i) {
+ const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i);
+ if (change.types & QAbstractAnimationJob::Completion)
+ change.listener->animationFinished(this);
+ }
+
+ if (m_group && (duration() == -1 || loopCount() < 0)) {
+ //this is an uncontrolled animation, need to notify the group animation we are finished
+ m_group->uncontrolledAnimationFinished(this);
+ }
+}
+
+void QAbstractAnimationJob::stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState)
+{
+ for (int i = 0; i < changeListeners.count(); ++i) {
+ const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i);
+ if (change.types & QAbstractAnimationJob::StateChange)
+ change.listener->animationStateChanged(this, newState, oldState);
+ }
+}
+
+void QAbstractAnimationJob::currentLoopChanged(int currentLoop)
+{
+ Q_UNUSED(currentLoop);
+ for (int i = 0; i < changeListeners.count(); ++i) {
+ const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i);
+ if (change.types & QAbstractAnimationJob::CurrentLoop)
+ change.listener->animationCurrentLoopChanged(this);
+ }
+}
+
+void QAbstractAnimationJob::addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes changes)
+{
+ changeListeners.append(ChangeListener(listener, changes));
+}
+
+void QAbstractAnimationJob::removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes changes)
+{
+ changeListeners.removeOne(ChangeListener(listener, changes));
+}
+
+
+QT_END_NAMESPACE
+
+//#include "moc_qabstractanimation2_p.cpp"
diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h
new file mode 100644
index 0000000000..f00090cb30
--- /dev/null
+++ b/src/qml/animations/qabstractanimationjob_p.h
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTANIMATIONJOB_P_H
+#define QABSTRACTANIMATIONJOB_P_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/QObject>
+#include <QtCore/private/qabstractanimation_p.h>
+#include "private/qpodvector_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Qml)
+
+class QAnimationGroupJob;
+class QAnimationJobChangeListener;
+class Q_QML_EXPORT QAbstractAnimationJob
+{
+ Q_DISABLE_COPY(QAbstractAnimationJob)
+public:
+ enum Direction {
+ Forward,
+ Backward
+ };
+
+ enum State {
+ Stopped,
+ Paused,
+ Running
+ };
+
+ QAbstractAnimationJob();
+ virtual ~QAbstractAnimationJob();
+
+ //definition
+ inline QAnimationGroupJob *group() const {return m_group;}
+
+ inline int loopCount() const {return m_loopCount;}
+ void setLoopCount(int loopCount);
+
+ int totalDuration() const;
+ virtual int duration() const {return 0;}
+
+ inline QAbstractAnimationJob::Direction direction() const {return m_direction;}
+ void setDirection(QAbstractAnimationJob::Direction direction);
+
+ //state
+ inline int currentTime() const {return m_totalCurrentTime;}
+ inline int currentLoopTime() const {return m_currentTime;}
+ inline int currentLoop() const {return m_currentLoop;}
+ inline QAbstractAnimationJob::State state() const {return m_state;}
+ inline bool isRunning() { return m_state == Running; }
+ inline bool isStopped() { return m_state == Stopped; }
+ inline bool isPaused() { return m_state == Paused; }
+
+ void setCurrentTime(int msecs);
+
+ void start();
+ void pause();
+ void resume();
+ void stop();
+
+ enum ChangeType {
+ Completion = 0x01,
+ StateChange = 0x02,
+ CurrentLoop = 0x04
+ };
+ Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
+
+ void addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes);
+ void removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes);
+
+ QAbstractAnimationJob *nextSibling() const { return m_nextSibling; }
+ QAbstractAnimationJob *previousSibling() const { return m_previousSibling; }
+
+protected:
+ virtual void updateCurrentTime(int) {}
+ virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+ virtual void updateDirection(QAbstractAnimationJob::Direction direction);
+ virtual void topLevelAnimationLoopChanged() {}
+
+ void setState(QAbstractAnimationJob::State state);
+
+ void finished();
+ void stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+ void currentLoopChanged(int currentLoop);
+ void directionChanged(QAbstractAnimationJob::Direction);
+
+ //definition
+ bool m_isPause;
+ bool m_isGroup;
+ int m_loopCount;
+ QAnimationGroupJob *m_group;
+ QAbstractAnimationJob::Direction m_direction;
+
+ //state
+ QAbstractAnimationJob::State m_state;
+ int m_totalCurrentTime;
+ int m_currentTime;
+ int m_currentLoop;
+ bool m_hasRegisteredTimer;
+ //records the finish time for an uncontrolled animation (used by animation groups)
+ int m_uncontrolledFinishTime;
+ bool *m_wasDeleted;
+
+ struct ChangeListener {
+ ChangeListener(QAnimationJobChangeListener *l, QAbstractAnimationJob::ChangeTypes t) : listener(l), types(t) {}
+ QAnimationJobChangeListener *listener;
+ QAbstractAnimationJob::ChangeTypes types;
+ bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
+ };
+ QPODVector<ChangeListener,4> changeListeners;
+
+ QAbstractAnimationJob *m_nextSibling;
+ QAbstractAnimationJob *m_previousSibling;
+
+ friend class QQmlAnimationTimer;
+ friend class QAnimationGroupJob;
+};
+
+class Q_AUTOTEST_EXPORT QAnimationJobChangeListener
+{
+public:
+ virtual void animationFinished(QAbstractAnimationJob *) {}
+ virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) {}
+ virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) {}
+};
+
+class Q_QML_EXPORT QQmlAnimationTimer : public QAbstractAnimationTimer
+{
+ Q_OBJECT
+private:
+ QQmlAnimationTimer();
+
+public:
+ static QQmlAnimationTimer *instance();
+ static QQmlAnimationTimer *instance(bool create);
+
+ static void registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel);
+ static void unregisterAnimation(QAbstractAnimationJob *animation);
+
+ /*
+ this is used for updating the currentTime of all animations in case the pause
+ timer is active or, otherwise, only of the animation passed as parameter.
+ */
+ static void ensureTimerUpdate();
+
+ /*
+ this will evaluate the need of restarting the pause timer in case there is still
+ some pause animations running.
+ */
+ static void updateAnimationTimer();
+
+ void restartAnimationTimer();
+ void updateAnimationsTime(qint64 timeStep);
+
+ int currentDelta() { return lastDelta; }
+
+ //useful for profiling/debugging
+ int runningAnimationCount() { return animations.count(); }
+
+private Q_SLOTS:
+ void startAnimations();
+ void stopTimer();
+
+private:
+ qint64 lastTick;
+ int lastDelta;
+ int currentAnimationIdx;
+ bool insideTick;
+ bool startAnimationPending;
+ bool stopTimerPending;
+
+ QList<QAbstractAnimationJob*> animations, animationsToStart;
+
+ // this is the count of running animations that are not a group neither a pause animation
+ int runningLeafAnimations;
+ QList<QAbstractAnimationJob*> runningPauseAnimations;
+
+ void registerRunningAnimation(QAbstractAnimationJob *animation);
+ void unregisterRunningAnimation(QAbstractAnimationJob *animation);
+
+ int closestPauseAnimationTimeToFinish();
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractAnimationJob::ChangeTypes)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTANIMATIONJOB_P_H
diff --git a/src/qml/animations/qanimationgroupjob.cpp b/src/qml/animations/qanimationgroupjob.cpp
new file mode 100644
index 0000000000..83b2192313
--- /dev/null
+++ b/src/qml/animations/qanimationgroupjob.cpp
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qanimationgroupjob_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QAnimationGroupJob::QAnimationGroupJob()
+ : QAbstractAnimationJob(), m_firstChild(0), m_lastChild(0)
+{
+ m_isGroup = true;
+}
+
+QAnimationGroupJob::~QAnimationGroupJob()
+{
+ while (firstChild() != 0)
+ delete firstChild();
+}
+
+void QAnimationGroupJob::topLevelAnimationLoopChanged()
+{
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
+ animation->topLevelAnimationLoopChanged();
+}
+
+void QAnimationGroupJob::appendAnimation(QAbstractAnimationJob *animation)
+{
+ if (QAnimationGroupJob *oldGroup = animation->m_group)
+ oldGroup->removeAnimation(animation);
+
+ Q_ASSERT(!animation->previousSibling() && !animation->nextSibling());
+
+ if (m_lastChild)
+ m_lastChild->m_nextSibling = animation;
+ else
+ m_firstChild = animation;
+ animation->m_previousSibling = m_lastChild;
+ m_lastChild = animation;
+
+ animation->m_group = this;
+ animationInserted(animation);
+}
+
+void QAnimationGroupJob::prependAnimation(QAbstractAnimationJob *animation)
+{
+ if (QAnimationGroupJob *oldGroup = animation->m_group)
+ oldGroup->removeAnimation(animation);
+
+ Q_ASSERT(!previousSibling() && !nextSibling());
+
+ if (m_firstChild)
+ m_firstChild->m_previousSibling = animation;
+ else
+ m_lastChild = animation;
+ animation->m_nextSibling = m_firstChild;
+ m_firstChild = animation;
+
+ animation->m_group = this;
+ animationInserted(animation);
+}
+
+void QAnimationGroupJob::removeAnimation(QAbstractAnimationJob *animation)
+{
+ Q_ASSERT(animation);
+ Q_ASSERT(animation->m_group == this);
+ QAbstractAnimationJob *prev = animation->previousSibling();
+ QAbstractAnimationJob *next = animation->nextSibling();
+
+ if (prev)
+ prev->m_nextSibling = next;
+ else
+ m_firstChild = next;
+
+ if (next)
+ next->m_previousSibling = prev;
+ else
+ m_lastChild = prev;
+
+ animation->m_previousSibling = 0;
+ animation->m_nextSibling = 0;
+
+ animation->m_group = 0;
+ animationRemoved(animation, prev, next);
+}
+
+void QAnimationGroupJob::clear()
+{
+ //### should this remove and delete, or just remove?
+ while (firstChild() != 0)
+ delete firstChild(); //removeAnimation(firstChild());
+}
+
+void QAnimationGroupJob::resetUncontrolledAnimationsFinishTime()
+{
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ if (animation->duration() == -1 || animation->loopCount() < 0) {
+ resetUncontrolledAnimationFinishTime(animation);
+ }
+ }
+}
+
+void QAnimationGroupJob::resetUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim)
+{
+ setUncontrolledAnimationFinishTime(anim, -1);
+}
+
+void QAnimationGroupJob::setUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim, int time)
+{
+ anim->m_uncontrolledFinishTime = time;
+}
+
+void QAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation)
+{
+ Q_UNUSED(animation);
+}
+
+void QAnimationGroupJob::animationRemoved(QAbstractAnimationJob* anim, QAbstractAnimationJob* , QAbstractAnimationJob* )
+{
+ resetUncontrolledAnimationFinishTime(anim);
+ if (!firstChild()) {
+ m_currentTime = 0;
+ stop();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/animations/qanimationgroupjob_p.h b/src/qml/animations/qanimationgroupjob_p.h
new file mode 100644
index 0000000000..303dc898d9
--- /dev/null
+++ b/src/qml/animations/qanimationgroupjob_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QANIMATIONGROUPJOB_P_H
+#define QANIMATIONGROUPJOB_P_H
+
+#include "private/qabstractanimationjob_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Qml)
+
+class Q_QML_EXPORT QAnimationGroupJob : public QAbstractAnimationJob
+{
+ Q_DISABLE_COPY(QAnimationGroupJob)
+public:
+ QAnimationGroupJob();
+ ~QAnimationGroupJob();
+
+ void appendAnimation(QAbstractAnimationJob *animation);
+ void prependAnimation(QAbstractAnimationJob *animation);
+ void removeAnimation(QAbstractAnimationJob *animation);
+
+ QAbstractAnimationJob *firstChild() const { return m_firstChild; }
+ QAbstractAnimationJob *lastChild() const { return m_lastChild; }
+
+ void clear();
+
+ //called by QAbstractAnimationJob
+ virtual void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
+protected:
+ void topLevelAnimationLoopChanged();
+
+ virtual void animationInserted(QAbstractAnimationJob*) { }
+ virtual void animationRemoved(QAbstractAnimationJob*, QAbstractAnimationJob*, QAbstractAnimationJob*);
+
+ //TODO: confirm location of these (should any be moved into QAbstractAnimationJob?)
+ void resetUncontrolledAnimationsFinishTime();
+ void resetUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim);
+ int uncontrolledAnimationFinishTime(QAbstractAnimationJob *anim) const { return anim->m_uncontrolledFinishTime; }
+ void setUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim, int time);
+
+private:
+ //definition
+ QAbstractAnimationJob *m_firstChild;
+ QAbstractAnimationJob *m_lastChild;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QANIMATIONGROUPJOB_P_H
diff --git a/src/qml/animations/qanimationjobutil_p.h b/src/qml/animations/qanimationjobutil_p.h
new file mode 100644
index 0000000000..c891b8725d
--- /dev/null
+++ b/src/qml/animations/qanimationjobutil_p.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QANIMATIONJOBUTIL_P_H
+#define QANIMATIONJOBUTIL_P_H
+
+#define RETURN_IF_DELETED(func) \
+{ \
+ bool *prevWasDeleted = m_wasDeleted; \
+ bool wasDeleted = false; \
+ m_wasDeleted = &wasDeleted; \
+ func; \
+ if (wasDeleted) { \
+ if (prevWasDeleted) \
+ *prevWasDeleted = true; \
+ return; \
+ } \
+ m_wasDeleted = prevWasDeleted; \
+}
+
+#endif // QANIMATIONJOBUTIL_P_H
diff --git a/src/qml/animations/qparallelanimationgroupjob.cpp b/src/qml/animations/qparallelanimationgroupjob.cpp
new file mode 100644
index 0000000000..0472c959f4
--- /dev/null
+++ b/src/qml/animations/qparallelanimationgroupjob.cpp
@@ -0,0 +1,227 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qparallelanimationgroupjob_p.h"
+#include "private/qanimationjobutil_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QParallelAnimationGroupJob::QParallelAnimationGroupJob()
+ : QAnimationGroupJob()
+ , m_previousLoop(0)
+ , m_previousCurrentTime(0)
+{
+}
+
+QParallelAnimationGroupJob::~QParallelAnimationGroupJob()
+{
+}
+
+int QParallelAnimationGroupJob::duration() const
+{
+ int ret = 0;
+
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ int currentDuration = animation->totalDuration();
+ //this takes care of the case where a parallel animation group has controlled and uncontrolled
+ //animations, and the uncontrolled stop before the controlled
+ if (currentDuration == -1)
+ currentDuration = uncontrolledAnimationFinishTime(animation);
+ if (currentDuration == -1)
+ return -1; // Undetermined length
+
+ ret = qMax(ret, currentDuration);
+ }
+
+ return ret;
+}
+
+void QParallelAnimationGroupJob::updateCurrentTime(int /*currentTime*/)
+{
+ if (!firstChild())
+ return;
+
+ if (m_currentLoop > m_previousLoop) {
+ // simulate completion of the loop
+ int dura = duration();
+ if (dura > 0) {
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ if (!animation->isStopped())
+ RETURN_IF_DELETED(animation->setCurrentTime(dura)); // will stop
+ }
+ }
+ } else if (m_currentLoop < m_previousLoop) {
+ // simulate completion of the loop seeking backwards
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ //we need to make sure the animation is in the right state
+ //and then rewind it
+ applyGroupState(animation);
+ RETURN_IF_DELETED(animation->setCurrentTime(0));
+ animation->stop();
+ }
+ }
+
+ // finally move into the actual time of the current loop
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ const int dura = animation->totalDuration();
+ //if the loopcount is bigger we should always start all animations
+ if (m_currentLoop > m_previousLoop
+ //if we're at the end of the animation, we need to start it if it wasn't already started in this loop
+ //this happens in Backward direction where not all animations are started at the same time
+ || shouldAnimationStart(animation, m_previousCurrentTime > dura /*startIfAtEnd*/)) {
+ applyGroupState(animation);
+ }
+
+ if (animation->state() == state()) {
+ RETURN_IF_DELETED(animation->setCurrentTime(m_currentTime));
+ if (dura > 0 && m_currentTime > dura)
+ animation->stop();
+ }
+ }
+ m_previousLoop = m_currentLoop;
+ m_previousCurrentTime = m_currentTime;
+}
+
+void QParallelAnimationGroupJob::updateState(QAbstractAnimationJob::State newState,
+ QAbstractAnimationJob::State oldState)
+{
+ QAnimationGroupJob::updateState(newState, oldState);
+
+ switch (newState) {
+ case Stopped:
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
+ animation->stop();
+ break;
+ case Paused:
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
+ if (animation->isRunning())
+ animation->pause();
+ break;
+ case Running:
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ if (oldState == Stopped)
+ animation->stop();
+ resetUncontrolledAnimationFinishTime(animation);
+ animation->setDirection(m_direction);
+ if (shouldAnimationStart(animation, oldState == Stopped))
+ animation->start();
+ }
+ break;
+ }
+}
+
+bool QParallelAnimationGroupJob::shouldAnimationStart(QAbstractAnimationJob *animation, bool startIfAtEnd) const
+{
+ const int dura = animation->totalDuration();
+
+ if (dura == -1)
+ return uncontrolledAnimationFinishTime(animation) == -1;
+
+ if (startIfAtEnd)
+ return m_currentTime <= dura;
+ if (m_direction == Forward)
+ return m_currentTime < dura;
+ else //direction == Backward
+ return m_currentTime && m_currentTime <= dura;
+}
+
+void QParallelAnimationGroupJob::applyGroupState(QAbstractAnimationJob *animation)
+{
+ switch (m_state)
+ {
+ case Running:
+ animation->start();
+ break;
+ case Paused:
+ animation->pause();
+ break;
+ case Stopped:
+ default:
+ break;
+ }
+}
+
+void QParallelAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direction direction)
+{
+ //we need to update the direction of the current animation
+ if (!isStopped()) {
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ animation->setDirection(direction);
+ }
+ } else {
+ if (direction == Forward) {
+ m_previousLoop = 0;
+ m_previousCurrentTime = 0;
+ } else {
+ // Looping backwards with loopCount == -1 does not really work well...
+ m_previousLoop = (m_loopCount == -1 ? 0 : m_loopCount - 1);
+ m_previousCurrentTime = duration();
+ }
+ }
+}
+
+void QParallelAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation)
+{
+ Q_ASSERT(animation && (animation->duration() == -1 || animation->loopCount() < 0));
+ int uncontrolledRunningCount = 0;
+
+ for (QAbstractAnimationJob *child = firstChild(); child; child = child->nextSibling()) {
+ if (child == animation) {
+ setUncontrolledAnimationFinishTime(animation, animation->currentTime());
+ } else if (child->duration() == -1 || child->loopCount() < 0) {
+ if (uncontrolledAnimationFinishTime(child) == -1)
+ ++uncontrolledRunningCount;
+ }
+ }
+
+ if (uncontrolledRunningCount > 0)
+ return;
+
+ int maxDuration = 0;
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
+ maxDuration = qMax(maxDuration, animation->totalDuration());
+
+ if (m_currentTime >= maxDuration)
+ stop();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/animations/qparallelanimationgroupjob_p.h b/src/qml/animations/qparallelanimationgroupjob_p.h
new file mode 100644
index 0000000000..d77a8c84f9
--- /dev/null
+++ b/src/qml/animations/qparallelanimationgroupjob_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPARALLELANIMATIONGROUPJOB_P_H
+#define QPARALLELANIMATIONGROUPJOB_P_H
+
+#include "private/qanimationgroupjob_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Qml)
+
+class Q_QML_EXPORT QParallelAnimationGroupJob : public QAnimationGroupJob
+{
+ Q_DISABLE_COPY(QParallelAnimationGroupJob)
+public:
+ QParallelAnimationGroupJob();
+ ~QParallelAnimationGroupJob();
+
+ int duration() const;
+
+protected:
+ void updateCurrentTime(int currentTime);
+ void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+ void updateDirection(QAbstractAnimationJob::Direction direction);
+ void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
+
+private:
+ bool shouldAnimationStart(QAbstractAnimationJob *animation, bool startIfAtEnd) const;
+ void applyGroupState(QAbstractAnimationJob *animation);
+
+ //state
+ int m_previousLoop;
+ int m_previousCurrentTime;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPARALLELANIMATIONGROUPJOB_P_H
diff --git a/src/qml/animations/qpauseanimationjob.cpp b/src/qml/animations/qpauseanimationjob.cpp
new file mode 100644
index 0000000000..40bcef7e89
--- /dev/null
+++ b/src/qml/animations/qpauseanimationjob.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qpauseanimationjob_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QPauseAnimationJob::QPauseAnimationJob(int duration)
+ : QAbstractAnimationJob()
+ , m_duration(duration)
+{
+ m_isPause = true;
+}
+
+QPauseAnimationJob::~QPauseAnimationJob()
+{
+}
+
+int QPauseAnimationJob::duration() const
+{
+ return m_duration;
+}
+
+void QPauseAnimationJob::setDuration(int msecs)
+{
+ m_duration = msecs;
+}
+
+void QPauseAnimationJob::updateCurrentTime(int)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/animations/qpauseanimationjob_p.h b/src/qml/animations/qpauseanimationjob_p.h
new file mode 100644
index 0000000000..82462be101
--- /dev/null
+++ b/src/qml/animations/qpauseanimationjob_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPAUSEANIMATIONJOB_P_H
+#define QPAUSEANIMATIONJOB_P_H
+
+#include <private/qanimationgroupjob_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Qml)
+
+class Q_QML_EXPORT QPauseAnimationJob : public QAbstractAnimationJob
+{
+ Q_DISABLE_COPY(QPauseAnimationJob)
+public:
+ explicit QPauseAnimationJob(int duration = 250);
+ ~QPauseAnimationJob();
+
+ int duration() const;
+ void setDuration(int msecs);
+
+protected:
+ void updateCurrentTime(int);
+
+private:
+ //definition
+ int m_duration;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPAUSEANIMATIONJOB_P_H
diff --git a/src/qml/animations/qsequentialanimationgroupjob.cpp b/src/qml/animations/qsequentialanimationgroupjob.cpp
new file mode 100644
index 0000000000..12cce39fbc
--- /dev/null
+++ b/src/qml/animations/qsequentialanimationgroupjob.cpp
@@ -0,0 +1,388 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qsequentialanimationgroupjob_p.h"
+#include "private/qpauseanimationjob_p.h"
+#include "private/qanimationjobutil_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QSequentialAnimationGroupJob::QSequentialAnimationGroupJob()
+ : QAnimationGroupJob()
+ , m_currentAnimation(0)
+ , m_previousLoop(0)
+{
+}
+
+QSequentialAnimationGroupJob::~QSequentialAnimationGroupJob()
+{
+}
+
+bool QSequentialAnimationGroupJob::atEnd() const
+{
+ // we try to detect if we're at the end of the group
+ //this is true if the following conditions are true:
+ // 1. we're in the last loop
+ // 2. the direction is forward
+ // 3. the current animation is the last one
+ // 4. the current animation has reached its end
+ const int animTotalCurrentTime = m_currentAnimation->currentTime();
+ return (m_currentLoop == m_loopCount - 1
+ && m_direction == Forward
+ && !m_currentAnimation->nextSibling()
+ && animTotalCurrentTime == animationActualTotalDuration(m_currentAnimation));
+}
+
+int QSequentialAnimationGroupJob::animationActualTotalDuration(QAbstractAnimationJob *anim) const
+{
+ int ret = anim->totalDuration();
+ if (ret == -1)
+ ret = uncontrolledAnimationFinishTime(anim); //we can try the actual duration there
+ return ret;
+}
+
+QSequentialAnimationGroupJob::AnimationIndex QSequentialAnimationGroupJob::indexForCurrentTime() const
+{
+ Q_ASSERT(firstChild());
+
+ AnimationIndex ret;
+ QAbstractAnimationJob *anim = 0;
+ int duration = 0;
+
+ for (anim = firstChild(); anim; anim = anim->nextSibling()) {
+ duration = animationActualTotalDuration(anim);
+
+ // 'animation' is the current animation if one of these reasons is true:
+ // 1. it's duration is undefined
+ // 2. it ends after msecs
+ // 3. it is the last animation (this can happen in case there is at least 1 uncontrolled animation)
+ // 4. it ends exactly in msecs and the direction is backwards
+ if (duration == -1 || m_currentTime < (ret.timeOffset + duration)
+ || (m_currentTime == (ret.timeOffset + duration) && m_direction == QAbstractAnimationJob::Backward)) {
+ ret.animation = anim;
+ return ret;
+ }
+
+ if (anim == m_currentAnimation)
+ ret.afterCurrent = true;
+
+ // 'animation' has a non-null defined duration and is not the one at time 'msecs'.
+ ret.timeOffset += duration;
+ }
+
+ // this can only happen when one of those conditions is true:
+ // 1. the duration of the group is undefined and we passed its actual duration
+ // 2. there are only 0-duration animations in the group
+ ret.timeOffset -= duration;
+ ret.animation = lastChild();
+ return ret;
+}
+
+void QSequentialAnimationGroupJob::restart()
+{
+ // restarting the group by making the first/last animation the current one
+ if (m_direction == Forward) {
+ m_previousLoop = 0;
+ if (m_currentAnimation == firstChild())
+ activateCurrentAnimation();
+ else
+ setCurrentAnimation(firstChild());
+ }
+ else { // direction == Backward
+ m_previousLoop = m_loopCount - 1;
+ if (m_currentAnimation == lastChild())
+ activateCurrentAnimation();
+ else
+ setCurrentAnimation(lastChild());
+ }
+}
+
+void QSequentialAnimationGroupJob::advanceForwards(const AnimationIndex &newAnimationIndex)
+{
+ if (m_previousLoop < m_currentLoop) {
+ // we need to fast forward to the end
+ for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = anim->nextSibling()) {
+ setCurrentAnimation(anim, true);
+ RETURN_IF_DELETED(anim->setCurrentTime(animationActualTotalDuration(anim)));
+ }
+ // this will make sure the current animation is reset to the beginning
+ if (firstChild() && !firstChild()->nextSibling()) //count == 1
+ // we need to force activation because setCurrentAnimation will have no effect
+ activateCurrentAnimation();
+ else
+ setCurrentAnimation(firstChild(), true);
+ }
+
+ // and now we need to fast forward from the current position to
+ for (QAbstractAnimationJob *anim = m_currentAnimation; anim && anim != newAnimationIndex.animation; anim = anim->nextSibling()) { //### WRONG,
+ setCurrentAnimation(anim, true);
+ RETURN_IF_DELETED(anim->setCurrentTime(animationActualTotalDuration(anim)));
+ }
+ // setting the new current animation will happen later
+}
+
+void QSequentialAnimationGroupJob::rewindForwards(const AnimationIndex &newAnimationIndex)
+{
+ if (m_previousLoop > m_currentLoop) {
+ // we need to fast rewind to the beginning
+ for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = anim->previousSibling()) {
+ setCurrentAnimation(anim, true);
+ RETURN_IF_DELETED(anim->setCurrentTime(0));
+ }
+ // this will make sure the current animation is reset to the end
+ if (lastChild() && !lastChild()->previousSibling()) //count == 1
+ // we need to force activation because setCurrentAnimation will have no effect
+ activateCurrentAnimation();
+ else {
+ setCurrentAnimation(lastChild(), true);
+ }
+ }
+
+ // and now we need to fast rewind from the current position to
+ for (QAbstractAnimationJob *anim = m_currentAnimation; anim && anim != newAnimationIndex.animation; anim = anim->previousSibling()) {
+ setCurrentAnimation(anim, true);
+ RETURN_IF_DELETED(anim->setCurrentTime(0));
+ }
+ // setting the new current animation will happen later
+}
+
+int QSequentialAnimationGroupJob::duration() const
+{
+ int ret = 0;
+
+ for (QAbstractAnimationJob *anim = firstChild(); anim; anim = anim->nextSibling()) {
+ const int currentDuration = anim->totalDuration();
+ if (currentDuration == -1)
+ return -1; // Undetermined length
+
+ ret += currentDuration;
+ }
+
+ return ret;
+}
+
+void QSequentialAnimationGroupJob::updateCurrentTime(int currentTime)
+{
+ if (!m_currentAnimation)
+ return;
+
+ const QSequentialAnimationGroupJob::AnimationIndex newAnimationIndex = indexForCurrentTime();
+
+ // newAnimationIndex.index is the new current animation
+ if (m_previousLoop < m_currentLoop
+ || (m_previousLoop == m_currentLoop && m_currentAnimation != newAnimationIndex.animation && newAnimationIndex.afterCurrent)) {
+ // advancing with forward direction is the same as rewinding with backwards direction
+ RETURN_IF_DELETED(advanceForwards(newAnimationIndex));
+ } else if (m_previousLoop > m_currentLoop
+ || (m_previousLoop == m_currentLoop && m_currentAnimation != newAnimationIndex.animation && !newAnimationIndex.afterCurrent)) {
+ // rewinding with forward direction is the same as advancing with backwards direction
+ RETURN_IF_DELETED(rewindForwards(newAnimationIndex));
+ }
+
+ setCurrentAnimation(newAnimationIndex.animation);
+
+ const int newCurrentTime = currentTime - newAnimationIndex.timeOffset;
+
+ if (m_currentAnimation) {
+ RETURN_IF_DELETED(m_currentAnimation->setCurrentTime(newCurrentTime));
+ if (atEnd()) {
+ //we make sure that we don't exceed the duration here
+ m_currentTime += m_currentAnimation->currentTime() - newCurrentTime;
+ stop();
+ }
+ } else {
+ //the only case where currentAnimation could be null
+ //is when all animations have been removed
+ Q_ASSERT(!firstChild());
+ m_currentTime = 0;
+ stop();
+ }
+
+ m_previousLoop = m_currentLoop;
+}
+
+void QSequentialAnimationGroupJob::updateState(QAbstractAnimationJob::State newState,
+ QAbstractAnimationJob::State oldState)
+{
+ QAnimationGroupJob::updateState(newState, oldState);
+
+ if (!m_currentAnimation)
+ return;
+
+ switch (newState) {
+ case Stopped:
+ m_currentAnimation->stop();
+ break;
+ case Paused:
+ if (oldState == m_currentAnimation->state() && oldState == Running)
+ m_currentAnimation->pause();
+ else
+ restart();
+ break;
+ case Running:
+ if (oldState == m_currentAnimation->state() && oldState == Paused)
+ m_currentAnimation->start();
+ else
+ restart();
+ break;
+ }
+}
+
+void QSequentialAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direction direction)
+{
+ // we need to update the direction of the current animation
+ if (!isStopped() && m_currentAnimation)
+ m_currentAnimation->setDirection(direction);
+}
+
+void QSequentialAnimationGroupJob::setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate)
+{
+ if (!anim) {
+ Q_ASSERT(!firstChild());
+ m_currentAnimation = 0;
+ return;
+ }
+
+ if (anim == m_currentAnimation)
+ return;
+
+ // stop the old current animation
+ if (m_currentAnimation)
+ m_currentAnimation->stop();
+
+ m_currentAnimation = anim;
+
+ activateCurrentAnimation(intermediate);
+}
+
+void QSequentialAnimationGroupJob::activateCurrentAnimation(bool intermediate)
+{
+ if (!m_currentAnimation || isStopped())
+ return;
+
+ m_currentAnimation->stop();
+
+ // we ensure the direction is consistent with the group's direction
+ m_currentAnimation->setDirection(m_direction);
+
+ // reset the finish time of the animation if it is uncontrolled
+ if (m_currentAnimation->totalDuration() == -1)
+ resetUncontrolledAnimationFinishTime(m_currentAnimation);
+
+ m_currentAnimation->start();
+ if (!intermediate && isPaused())
+ m_currentAnimation->pause();
+}
+
+void QSequentialAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation)
+{
+ Q_UNUSED(animation);
+ Q_ASSERT(animation == m_currentAnimation);
+
+ setUncontrolledAnimationFinishTime(m_currentAnimation, m_currentAnimation->currentTime());
+
+ if ((m_direction == Forward && m_currentAnimation == lastChild())
+ || (m_direction == Backward && m_currentAnimation == firstChild())) {
+ // we don't handle looping of a group with undefined duration
+ stop();
+ } else if (m_direction == Forward) {
+ // set the current animation to be the next one
+ setCurrentAnimation(m_currentAnimation->nextSibling());
+ } else {
+ // set the current animation to be the previous one
+ setCurrentAnimation(m_currentAnimation->previousSibling());
+ }
+}
+
+void QSequentialAnimationGroupJob::animationInserted(QAbstractAnimationJob *anim)
+{
+ if (m_currentAnimation == 0)
+ setCurrentAnimation(firstChild()); // initialize the current animation
+
+ if (m_currentAnimation == anim->nextSibling()
+ && m_currentAnimation->currentTime() == 0 && m_currentAnimation->currentLoop() == 0) {
+ //in this case we simply insert the animation before the current one has actually started
+ setCurrentAnimation(anim);
+ }
+
+// TODO
+// if (index < m_currentAnimationIndex || m_currentLoop != 0) {
+// qWarning("QSequentialGroup::insertAnimation only supports to add animations after the current one.");
+// return; //we're not affected because it is added after the current one
+// }
+}
+
+void QSequentialAnimationGroupJob::animationRemoved(QAbstractAnimationJob *anim, QAbstractAnimationJob *prev, QAbstractAnimationJob *next)
+{
+ QAnimationGroupJob::animationRemoved(anim, prev, next);
+
+ Q_ASSERT(m_currentAnimation); // currentAnimation should always be set
+
+ bool removingCurrent = anim == m_currentAnimation;
+ if (removingCurrent) {
+ if (next)
+ setCurrentAnimation(next); //let's try to take the next one
+ else if (prev)
+ setCurrentAnimation(prev);
+ else// case all animations were removed
+ setCurrentAnimation(0);
+ }
+
+ // duration of the previous animations up to the current animation
+ m_currentTime = 0;
+ for (QAbstractAnimationJob *anim = firstChild(); anim; anim = anim->nextSibling()) {
+ if (anim == m_currentAnimation)
+ break;
+ m_currentTime += animationActualTotalDuration(anim);
+
+ }
+
+ if (!removingCurrent) {
+ //the current animation is not the one being removed
+ //so we add its current time to the current time of this group
+ m_currentTime += m_currentAnimation->currentTime();
+ }
+
+ //let's also update the total current time
+ m_totalCurrentTime = m_currentTime + m_loopCount * duration();
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/animations/qsequentialanimationgroupjob_p.h b/src/qml/animations/qsequentialanimationgroupjob_p.h
new file mode 100644
index 0000000000..b406d04f6f
--- /dev/null
+++ b/src/qml/animations/qsequentialanimationgroupjob_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSEQUENTIALANIMATIONGROUPJOB_P_H
+#define QSEQUENTIALANIMATIONGROUPJOB_P_H
+
+#include <private/qanimationgroupjob_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Qml)
+
+class QPauseAnimationJob;
+class Q_QML_EXPORT QSequentialAnimationGroupJob : public QAnimationGroupJob
+{
+ Q_DISABLE_COPY(QSequentialAnimationGroupJob)
+public:
+ QSequentialAnimationGroupJob();
+ ~QSequentialAnimationGroupJob();
+
+ int duration() const;
+
+ QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; }
+
+protected:
+ void updateCurrentTime(int);
+ void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+ void updateDirection(QAbstractAnimationJob::Direction direction);
+ void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
+
+private:
+ struct AnimationIndex
+ {
+ AnimationIndex() : afterCurrent(false), timeOffset(0), animation(0) {}
+ // AnimationIndex points to the animation at timeOffset, skipping 0 duration animations.
+ // Note that the index semantic is slightly different depending on the direction.
+ bool afterCurrent; //whether animation is before or after m_currentAnimation //TODO: make enum Before/After/Same
+ int timeOffset; // time offset when the animation at index starts.
+ QAbstractAnimationJob *animation; //points to the animation at timeOffset
+ };
+
+ int animationActualTotalDuration(QAbstractAnimationJob *anim) const;
+ AnimationIndex indexForCurrentTime() const;
+
+ void setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate = false);
+ void activateCurrentAnimation(bool intermediate = false);
+
+ void animationInserted(QAbstractAnimationJob *anim);
+ void animationRemoved(QAbstractAnimationJob *anim,QAbstractAnimationJob*,QAbstractAnimationJob*);
+
+ bool atEnd() const;
+
+ void restart();
+
+ // handle time changes
+ void rewindForwards(const AnimationIndex &newAnimationIndex);
+ void advanceForwards(const AnimationIndex &newAnimationIndex);
+
+ //state
+ QAbstractAnimationJob *m_currentAnimation;
+ int m_previousLoop;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QSEQUENTIALANIMATIONGROUPJOB_P_H
diff --git a/src/qml/debugger/debugger.pri b/src/qml/debugger/debugger.pri
new file mode 100644
index 0000000000..10ca9706c4
--- /dev/null
+++ b/src/qml/debugger/debugger.pri
@@ -0,0 +1,32 @@
+SOURCES += \
+ $$PWD/qpacketprotocol.cpp \
+ $$PWD/qqmldebugservice.cpp \
+ $$PWD/qqmldebugclient.cpp \
+ $$PWD/qqmlenginedebug.cpp \
+ $$PWD/qqmlprofilerservice.cpp \
+ $$PWD/qqmldebughelper.cpp \
+ $$PWD/qqmldebugserver.cpp \
+ $$PWD/qqmlinspectorservice.cpp \
+ $$PWD/qv8debugservice.cpp \
+ $$PWD/qv8profilerservice.cpp \
+ $$PWD/qqmlenginedebugservice.cpp \
+ $$PWD/qdebugmessageservice.cpp
+
+HEADERS += \
+ $$PWD/qpacketprotocol_p.h \
+ $$PWD/qqmldebugservice_p.h \
+ $$PWD/qqmldebugservice_p_p.h \
+ $$PWD/qqmldebugclient_p.h \
+ $$PWD/qqmlenginedebug_p.h \
+ $$PWD/qqmlprofilerservice_p.h \
+ $$PWD/qqmldebughelper_p.h \
+ $$PWD/qqmldebugserver_p.h \
+ $$PWD/qqmldebugserverconnection_p.h \
+ $$PWD/qqmldebugstatesdelegate_p.h \
+ $$PWD/qqmlinspectorservice_p.h \
+ $$PWD/qqmlinspectorinterface_p.h \
+ $$PWD/qv8debugservice_p.h \
+ $$PWD/qv8profilerservice_p.h \
+ $$PWD/qqmlenginedebugservice_p.h \
+ $$PWD/qqmldebug.h \
+ $$PWD/qdebugmessageservice_p.h
diff --git a/src/qml/debugger/qdebugmessageservice.cpp b/src/qml/debugger/qdebugmessageservice.cpp
new file mode 100644
index 0000000000..dcaa514cd7
--- /dev/null
+++ b/src/qml/debugger/qdebugmessageservice.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdebugmessageservice_p.h"
+#include "qqmldebugservice_p_p.h"
+
+#include <QDataStream>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QDebugMessageService, qmlDebugMessageService)
+
+void DebugMessageHandler(QtMsgType type, const QMessageLogContext &ctxt,
+ const char *buf)
+{
+ QDebugMessageService::instance()->sendDebugMessage(type, ctxt, buf);
+}
+
+class QDebugMessageServicePrivate : public QQmlDebugServicePrivate
+{
+public:
+ QDebugMessageServicePrivate()
+ : oldMsgHandler(0)
+ , prevState(QQmlDebugService::NotConnected)
+ {
+ }
+
+ QMessageHandler oldMsgHandler;
+ QQmlDebugService::State prevState;
+};
+
+QDebugMessageService::QDebugMessageService(QObject *parent) :
+ QQmlDebugService(*(new QDebugMessageServicePrivate()),
+ QLatin1String("DebugMessages"), 2, parent)
+{
+ Q_D(QDebugMessageService);
+
+ registerService();
+ if (state() == Enabled) {
+ d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler);
+ d->prevState = Enabled;
+ }
+}
+
+QDebugMessageService *QDebugMessageService::instance()
+{
+ return qmlDebugMessageService();
+}
+
+void QDebugMessageService::sendDebugMessage(QtMsgType type,
+ const QMessageLogContext &ctxt,
+ const char *buf)
+{
+ Q_D(QDebugMessageService);
+
+ //We do not want to alter the message handling mechanism
+ //We just eavesdrop and forward the messages to a port
+ //only if a client is connected to it.
+ QByteArray message;
+ QDataStream ws(&message, QIODevice::WriteOnly);
+ ws << QByteArray("MESSAGE") << type << QString::fromLocal8Bit(buf).toUtf8();
+ ws << QString::fromLatin1(ctxt.file).toUtf8();
+ ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8();
+
+ sendMessage(message);
+ if (d->oldMsgHandler)
+ (*d->oldMsgHandler)(type, ctxt, buf);
+}
+
+void QDebugMessageService::stateChanged(State state)
+{
+ Q_D(QDebugMessageService);
+
+ if (state != Enabled && d->prevState == Enabled) {
+ QMessageHandler handler = qInstallMessageHandler(d->oldMsgHandler);
+ // has our handler been overwritten in between?
+ if (handler != DebugMessageHandler)
+ qInstallMessageHandler(handler);
+
+ } else if (state == Enabled && d->prevState != Enabled) {
+ d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler);
+
+ }
+
+ d->prevState = state;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qdebugmessageservice_p.h b/src/qml/debugger/qdebugmessageservice_p.h
new file mode 100644
index 0000000000..88b918e217
--- /dev/null
+++ b/src/qml/debugger/qdebugmessageservice_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDEBUGMESSAGESERVICE_P_H
+#define QDEBUGMESSAGESERVICE_P_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 "qqmldebugservice_p.h"
+
+#include <QtCore/qlogging.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Qml)
+
+class QDebugMessageServicePrivate;
+
+class QDebugMessageService : public QQmlDebugService
+{
+ Q_OBJECT
+public:
+ QDebugMessageService(QObject *parent = 0);
+
+ static QDebugMessageService *instance();
+
+ void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt,
+ const char *buf);
+
+protected:
+ void stateChanged(State);
+
+private:
+ Q_DISABLE_COPY(QDebugMessageService)
+ Q_DECLARE_PRIVATE(QDebugMessageService)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDEBUGMESSAGESERVICE_P_H
diff --git a/src/qml/debugger/qpacketprotocol.cpp b/src/qml/debugger/qpacketprotocol.cpp
new file mode 100644
index 0000000000..978054a238
--- /dev/null
+++ b/src/qml/debugger/qpacketprotocol.cpp
@@ -0,0 +1,550 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qpacketprotocol_p.h"
+
+#include <QtCore/QBuffer>
+#include <QtCore/QElapsedTimer>
+
+QT_BEGIN_NAMESPACE
+
+static const unsigned int MAX_PACKET_SIZE = 0x7FFFFFFF;
+
+/*!
+ \class QPacketProtocol
+ \internal
+
+ \brief The QPacketProtocol class encapsulates communicating discrete packets
+ across fragmented IO channels, such as TCP sockets.
+
+ QPacketProtocol makes it simple to send arbitrary sized data "packets" across
+ fragmented transports such as TCP and UDP.
+
+ As transmission boundaries are not respected, sending packets over protocols
+ like TCP frequently involves "stitching" them back together at the receiver.
+ QPacketProtocol makes this easier by performing this task for you. Packet
+ data sent using QPacketProtocol is prepended with a 4-byte size header
+ allowing the receiving QPacketProtocol to buffer the packet internally until
+ it has all been received. QPacketProtocol does not perform any sanity
+ checking on the size or on the data, so this class should only be used in
+ prototyping or trusted situations where DOS attacks are unlikely.
+
+ QPacketProtocol does not perform any communications itself. Instead it can
+ operate on any QIODevice that supports the QIODevice::readyRead() signal. A
+ logical "packet" is encapsulated by the companion QPacket class. The
+ following example shows two ways to send data using QPacketProtocol. The
+ transmitted data is equivalent in both.
+
+ \code
+ QTcpSocket socket;
+ // ... connect socket ...
+
+ QPacketProtocol protocol(&socket);
+
+ // Send packet the quick way
+ protocol.send() << "Hello world" << 123;
+
+ // Send packet the longer way
+ QPacket packet;
+ packet << "Hello world" << 123;
+ protocol.send(packet);
+ \endcode
+
+ Likewise, the following shows how to read data from QPacketProtocol, assuming
+ that the QPacketProtocol::readyRead() signal has been emitted.
+
+ \code
+ // ... QPacketProtocol::readyRead() is emitted ...
+
+ int a;
+ QByteArray b;
+
+ // Receive packet the quick way
+ protocol.read() >> a >> b;
+
+ // Receive packet the longer way
+ QPacket packet = protocol.read();
+ p >> a >> b;
+ \endcode
+
+ \ingroup io
+ \sa QPacket
+*/
+
+class QPacketProtocolPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev)
+ : QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
+ waitingForPacket(false), dev(_dev)
+ {
+ Q_ASSERT(4 == sizeof(qint32));
+
+ QObject::connect(this, SIGNAL(readyRead()),
+ parent, SIGNAL(readyRead()));
+ QObject::connect(this, SIGNAL(packetWritten()),
+ parent, SIGNAL(packetWritten()));
+ QObject::connect(this, SIGNAL(invalidPacket()),
+ parent, SIGNAL(invalidPacket()));
+ QObject::connect(dev, SIGNAL(readyRead()),
+ this, SLOT(readyToRead()));
+ QObject::connect(dev, SIGNAL(aboutToClose()),
+ this, SLOT(aboutToClose()));
+ QObject::connect(dev, SIGNAL(bytesWritten(qint64)),
+ this, SLOT(bytesWritten(qint64)));
+ }
+
+Q_SIGNALS:
+ void readyRead();
+ void packetWritten();
+ void invalidPacket();
+
+public Q_SLOTS:
+ void aboutToClose()
+ {
+ inProgress.clear();
+ sendingPackets.clear();
+ inProgressSize = -1;
+ }
+
+ void bytesWritten(qint64 bytes)
+ {
+ Q_ASSERT(!sendingPackets.isEmpty());
+
+ while (bytes) {
+ if (sendingPackets.at(0) > bytes) {
+ sendingPackets[0] -= bytes;
+ bytes = 0;
+ } else {
+ bytes -= sendingPackets.at(0);
+ sendingPackets.removeFirst();
+ emit packetWritten();
+ }
+ }
+ }
+
+ void readyToRead()
+ {
+ while (true) {
+ // Need to get trailing data
+ if (-1 == inProgressSize) {
+ // We need a size header of sizeof(qint32)
+ if (sizeof(qint32) > (uint)dev->bytesAvailable())
+ return;
+
+ // Read size header
+ int read = dev->read((char *)&inProgressSize, sizeof(qint32));
+ Q_ASSERT(read == sizeof(qint32));
+ Q_UNUSED(read);
+
+ // Check sizing constraints
+ if (inProgressSize > maxPacketSize) {
+ QObject::disconnect(dev, SIGNAL(readyRead()),
+ this, SLOT(readyToRead()));
+ QObject::disconnect(dev, SIGNAL(aboutToClose()),
+ this, SLOT(aboutToClose()));
+ QObject::disconnect(dev, SIGNAL(bytesWritten(qint64)),
+ this, SLOT(bytesWritten(qint64)));
+ dev = 0;
+ emit invalidPacket();
+ return;
+ }
+
+ inProgressSize -= sizeof(qint32);
+ } else {
+ inProgress.append(dev->read(inProgressSize - inProgress.size()));
+
+ if (inProgressSize == inProgress.size()) {
+ // Packet has arrived!
+ packets.append(inProgress);
+ inProgressSize = -1;
+ inProgress.clear();
+
+ waitingForPacket = false;
+ emit readyRead();
+ } else
+ return;
+ }
+ }
+ }
+
+public:
+ QList<qint64> sendingPackets;
+ QList<QByteArray> packets;
+ QByteArray inProgress;
+ qint32 inProgressSize;
+ qint32 maxPacketSize;
+ bool waitingForPacket;
+ QIODevice *dev;
+};
+
+/*!
+ Construct a QPacketProtocol instance that works on \a dev with the
+ specified \a parent.
+ */
+QPacketProtocol::QPacketProtocol(QIODevice *dev, QObject *parent)
+ : QObject(parent), d(new QPacketProtocolPrivate(this, dev))
+{
+ Q_ASSERT(dev);
+}
+
+/*!
+ Destroys the QPacketProtocol instance.
+ */
+QPacketProtocol::~QPacketProtocol()
+{
+}
+
+/*!
+ Returns the maximum packet size allowed. By default this is
+ 2,147,483,647 bytes.
+
+ If a packet claiming to be larger than the maximum packet size is received,
+ the QPacketProtocol::invalidPacket() signal is emitted.
+
+ \sa QPacketProtocol::setMaximumPacketSize()
+ */
+qint32 QPacketProtocol::maximumPacketSize() const
+{
+ return d->maxPacketSize;
+}
+
+/*!
+ Sets the maximum allowable packet size to \a max.
+
+ \sa QPacketProtocol::maximumPacketSize()
+ */
+qint32 QPacketProtocol::setMaximumPacketSize(qint32 max)
+{
+ if (max > (signed)sizeof(qint32))
+ d->maxPacketSize = max;
+ return d->maxPacketSize;
+}
+
+/*!
+ Returns a streamable object that is transmitted on destruction. For example
+
+ \code
+ protocol.send() << "Hello world" << 123;
+ \endcode
+
+ will send a packet containing "Hello world" and 123. To construct more
+ complex packets, explicitly construct a QPacket instance.
+ */
+QPacketAutoSend QPacketProtocol::send()
+{
+ return QPacketAutoSend(this);
+}
+
+/*!
+ \fn void QPacketProtocol::send(const QPacket & packet)
+
+ Transmit the \a packet.
+ */
+void QPacketProtocol::send(const QPacket & p)
+{
+ if (p.b.isEmpty())
+ return; // We don't send empty packets
+
+ qint64 sendSize = p.b.size() + sizeof(qint32);
+
+ d->sendingPackets.append(sendSize);
+ qint32 sendSize32 = sendSize;
+ qint64 writeBytes = d->dev->write((char *)&sendSize32, sizeof(qint32));
+ Q_ASSERT(writeBytes == sizeof(qint32));
+ writeBytes = d->dev->write(p.b);
+ Q_ASSERT(writeBytes == p.b.size());
+}
+
+/*!
+ Returns the number of received packets yet to be read.
+ */
+qint64 QPacketProtocol::packetsAvailable() const
+{
+ return d->packets.count();
+}
+
+/*!
+ Discard any unread packets.
+ */
+void QPacketProtocol::clear()
+{
+ d->packets.clear();
+}
+
+/*!
+ Return the next unread packet, or an invalid QPacket instance if no packets
+ are available. This method does NOT block.
+ */
+QPacket QPacketProtocol::read()
+{
+ if (0 == d->packets.count())
+ return QPacket();
+
+ QPacket rv(d->packets.at(0));
+ d->packets.removeFirst();
+ return rv;
+}
+
+/*
+ Returns the difference between msecs and elapsed. If msecs is -1,
+ however, -1 is returned.
+*/
+static int qt_timeout_value(int msecs, int elapsed)
+{
+ if (msecs == -1)
+ return -1;
+
+ int timeout = msecs - elapsed;
+ return timeout < 0 ? 0 : timeout;
+}
+
+/*!
+ This function locks until a new packet is available for reading and the
+ \l{QIODevice::}{readyRead()} signal has been emitted. The function
+ will timeout after \a msecs milliseconds; the default timeout is
+ 30000 milliseconds.
+
+ The function returns true if the readyRead() signal is emitted and
+ there is new data available for reading; otherwise it returns false
+ (if an error occurred or the operation timed out).
+ */
+
+bool QPacketProtocol::waitForReadyRead(int msecs)
+{
+ if (!d->packets.isEmpty())
+ return true;
+
+ QElapsedTimer stopWatch;
+ stopWatch.start();
+
+ d->waitingForPacket = true;
+ do {
+ if (!d->dev->waitForReadyRead(msecs))
+ return false;
+ if (!d->waitingForPacket)
+ return true;
+ msecs = qt_timeout_value(msecs, stopWatch.elapsed());
+ } while (true);
+}
+
+/*!
+ Return the QIODevice passed to the QPacketProtocol constructor.
+*/
+QIODevice *QPacketProtocol::device()
+{
+ return d->dev;
+}
+
+/*!
+ \fn void QPacketProtocol::readyRead()
+
+ Emitted whenever a new packet is received. Applications may use
+ QPacketProtocol::read() to retrieve this packet.
+ */
+
+/*!
+ \fn void QPacketProtocol::invalidPacket()
+
+ A packet larger than the maximum allowable packet size was received. The
+ packet will be discarded and, as it indicates corruption in the protocol, no
+ further packets will be received.
+ */
+
+/*!
+ \fn void QPacketProtocol::packetWritten()
+
+ Emitted each time a packet is completing written to the device. This signal
+ may be used for communications flow control.
+ */
+
+/*!
+ \class QPacket
+ \internal
+
+ \brief The QPacket class encapsulates an unfragmentable packet of data to be
+ transmitted by QPacketProtocol.
+
+ The QPacket class works together with QPacketProtocol to make it simple to
+ send arbitrary sized data "packets" across fragmented transports such as TCP
+ and UDP.
+
+ QPacket provides a QDataStream interface to an unfragmentable packet.
+ Applications should construct a QPacket, propagate it with data and then
+ transmit it over a QPacketProtocol instance. For example:
+ \code
+ QPacketProtocol protocol(...);
+
+ QPacket myPacket;
+ myPacket << "Hello world!" << 123;
+ protocol.send(myPacket);
+ \endcode
+
+ As long as both ends of the connection are using the QPacketProtocol class,
+ the data within this packet will be delivered unfragmented at the other end,
+ ready for extraction.
+
+ \code
+ QByteArray greeting;
+ int count;
+
+ QPacket myPacket = protocol.read();
+
+ myPacket >> greeting >> count;
+ \endcode
+
+ Only packets returned from QPacketProtocol::read() may be read from. QPacket
+ instances constructed by directly by applications are for transmission only
+ and are considered "write only". Attempting to read data from them will
+ result in undefined behavior.
+
+ \ingroup io
+ \sa QPacketProtocol
+ */
+
+/*!
+ Constructs an empty write-only packet.
+ */
+QPacket::QPacket()
+ : QDataStream(), buf(0)
+{
+ buf = new QBuffer(&b);
+ buf->open(QIODevice::WriteOnly);
+ setDevice(buf);
+ setVersion(QDataStream::Qt_4_7);
+}
+
+/*!
+ Destroys the QPacket instance.
+ */
+QPacket::~QPacket()
+{
+ if (buf) {
+ delete buf;
+ buf = 0;
+ }
+}
+
+/*!
+ Creates a copy of \a other. The initial stream positions are shared, but the
+ two packets are otherwise independent.
+ */
+QPacket::QPacket(const QPacket & other)
+ : QDataStream(), b(other.b), buf(0)
+{
+ buf = new QBuffer(&b);
+ buf->open(other.buf->openMode());
+ setDevice(buf);
+}
+
+/*!
+ \internal
+ */
+QPacket::QPacket(const QByteArray & ba)
+ : QDataStream(), b(ba), buf(0)
+{
+ buf = new QBuffer(&b);
+ buf->open(QIODevice::ReadOnly);
+ setDevice(buf);
+}
+
+/*!
+ Returns true if this packet is empty - that is, contains no data.
+ */
+bool QPacket::isEmpty() const
+{
+ return b.isEmpty();
+}
+
+/*!
+ Returns raw packet data.
+ */
+QByteArray QPacket::data() const
+{
+ return b;
+}
+
+/*!
+ Clears data in the packet. This is useful for reusing one writable packet.
+ For example
+ \code
+ QPacketProtocol protocol(...);
+
+ QPacket packet;
+
+ packet << "Hello world!" << 123;
+ protocol.send(packet);
+
+ packet.clear();
+ packet << "Goodbyte world!" << 789;
+ protocol.send(packet);
+ \endcode
+ */
+void QPacket::clear()
+{
+ QBuffer::OpenMode oldMode = buf->openMode();
+ buf->close();
+ b.clear();
+ buf->setBuffer(&b); // reset QBuffer internals with new size of b.
+ buf->open(oldMode);
+}
+
+/*!
+ \class QPacketAutoSend
+ \internal
+
+ \internal
+ */
+QPacketAutoSend::QPacketAutoSend(QPacketProtocol *_p)
+ : QPacket(), p(_p)
+{
+}
+
+QPacketAutoSend::~QPacketAutoSend()
+{
+ if (!b.isEmpty())
+ p->send(*this);
+}
+
+QT_END_NAMESPACE
+
+#include <qpacketprotocol.moc>
diff --git a/src/qml/debugger/qpacketprotocol_p.h b/src/qml/debugger/qpacketprotocol_p.h
new file mode 100644
index 0000000000..c6123d2836
--- /dev/null
+++ b/src/qml/debugger/qpacketprotocol_p.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPACKETPROTOCOL_H
+#define QPACKETPROTOCOL_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/qobject.h>
+#include <QtCore/qdatastream.h>
+
+#include <private/qtqmlglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QIODevice;
+class QBuffer;
+class QPacket;
+class QPacketAutoSend;
+class QPacketProtocolPrivate;
+
+class Q_QML_PRIVATE_EXPORT QPacketProtocol : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QPacketProtocol(QIODevice *dev, QObject *parent = 0);
+ virtual ~QPacketProtocol();
+
+ qint32 maximumPacketSize() const;
+ qint32 setMaximumPacketSize(qint32);
+
+ QPacketAutoSend send();
+ void send(const QPacket &);
+
+ qint64 packetsAvailable() const;
+ QPacket read();
+
+ bool waitForReadyRead(int msecs = 3000);
+
+ void clear();
+
+ QIODevice *device();
+
+Q_SIGNALS:
+ void readyRead();
+ void invalidPacket();
+ void packetWritten();
+
+private:
+ QPacketProtocolPrivate *d;
+};
+
+
+class Q_QML_PRIVATE_EXPORT QPacket : public QDataStream
+{
+public:
+ QPacket();
+ QPacket(const QPacket &);
+ virtual ~QPacket();
+
+ void clear();
+ bool isEmpty() const;
+ QByteArray data() const;
+
+protected:
+ friend class QPacketProtocol;
+ QPacket(const QByteArray &ba);
+ QByteArray b;
+ QBuffer *buf;
+};
+
+class Q_QML_PRIVATE_EXPORT QPacketAutoSend : public QPacket
+{
+public:
+ virtual ~QPacketAutoSend();
+
+private:
+ friend class QPacketProtocol;
+ QPacketAutoSend(QPacketProtocol *);
+ QPacketProtocol *p;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/qml/debugger/qqmldebug.h b/src/qml/debugger/qqmldebug.h
new file mode 100644
index 0000000000..8036032150
--- /dev/null
+++ b/src/qml/debugger/qqmldebug.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDEBUG_H
+#define QQMLDEBUG_H
+
+#include <QtQml/qtqmlglobal.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+struct Q_QML_EXPORT QQmlDebuggingEnabler
+{
+ QQmlDebuggingEnabler();
+};
+
+// Execute code in constructor before first QQmlEngine is instantiated
+#if defined(QT_DECLARATIVE_DEBUG)
+static QQmlDebuggingEnabler qmlEnableDebuggingHelper;
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLDEBUG_H
diff --git a/src/qml/debugger/qqmldebugclient.cpp b/src/qml/debugger/qqmldebugclient.cpp
new file mode 100644
index 0000000000..12276b48fa
--- /dev/null
+++ b/src/qml/debugger/qqmldebugclient.cpp
@@ -0,0 +1,421 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebugclient_p.h"
+
+#include "qpacketprotocol_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+#include <QtNetwork/qnetworkproxy.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+const int protocolVersion = 1;
+const QString serverId = QLatin1String("QQmlDebugServer");
+const QString clientId = QLatin1String("QQmlDebugClient");
+
+class QQmlDebugClientPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlDebugClient)
+public:
+ QQmlDebugClientPrivate();
+
+ QString name;
+ QQmlDebugConnection *connection;
+};
+
+class QQmlDebugConnectionPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlDebugConnectionPrivate(QQmlDebugConnection *c);
+ QQmlDebugConnection *q;
+ QPacketProtocol *protocol;
+ QIODevice *device;
+
+ bool gotHello;
+ QHash <QString, float> serverPlugins;
+ QHash<QString, QQmlDebugClient *> plugins;
+
+ void advertisePlugins();
+ void connectDeviceSignals();
+
+public Q_SLOTS:
+ void connected();
+ void readyRead();
+ void deviceAboutToClose();
+};
+
+QQmlDebugConnectionPrivate::QQmlDebugConnectionPrivate(QQmlDebugConnection *c)
+ : QObject(c), q(c), protocol(0), device(0), gotHello(false)
+{
+ protocol = new QPacketProtocol(q, this);
+ QObject::connect(c, SIGNAL(connected()), this, SLOT(connected()));
+ QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
+}
+
+void QQmlDebugConnectionPrivate::advertisePlugins()
+{
+ if (!q->isConnected())
+ return;
+
+ QPacket pack;
+ pack << serverId << 1 << plugins.keys();
+ protocol->send(pack);
+ q->flush();
+}
+
+void QQmlDebugConnectionPrivate::connected()
+{
+ QPacket pack;
+ pack << serverId << 0 << protocolVersion << plugins.keys();
+ protocol->send(pack);
+ q->flush();
+}
+
+void QQmlDebugConnectionPrivate::readyRead()
+{
+ if (!gotHello) {
+ QPacket pack = protocol->read();
+ QString name;
+
+ pack >> name;
+
+ bool validHello = false;
+ if (name == clientId) {
+ int op = -1;
+ pack >> op;
+ if (op == 0) {
+ int version = -1;
+ pack >> version;
+ if (version == protocolVersion) {
+ QStringList pluginNames;
+ QList<float> pluginVersions;
+ pack >> pluginNames;
+ if (!pack.isEmpty())
+ pack >> pluginVersions;
+
+ const int pluginNamesSize = pluginNames.size();
+ const int pluginVersionsSize = pluginVersions.size();
+ for (int i = 0; i < pluginNamesSize; ++i) {
+ float pluginVersion = 1.0;
+ if (i < pluginVersionsSize)
+ pluginVersion = pluginVersions.at(i);
+ serverPlugins.insert(pluginNames.at(i), pluginVersion);
+ }
+
+ validHello = true;
+ }
+ }
+ }
+
+ if (!validHello) {
+ qWarning("QQmlDebugConnection: Invalid hello message");
+ QObject::disconnect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
+ return;
+ }
+ gotHello = true;
+
+ QHash<QString, QQmlDebugClient *>::Iterator iter = plugins.begin();
+ for (; iter != plugins.end(); ++iter) {
+ QQmlDebugClient::State newState = QQmlDebugClient::Unavailable;
+ if (serverPlugins.contains(iter.key()))
+ newState = QQmlDebugClient::Enabled;
+ iter.value()->stateChanged(newState);
+ }
+ }
+
+ while (protocol->packetsAvailable()) {
+ QPacket pack = protocol->read();
+ QString name;
+ pack >> name;
+
+ if (name == clientId) {
+ int op = -1;
+ pack >> op;
+
+ if (op == 1) {
+ // Service Discovery
+ QHash<QString, float> oldServerPlugins = serverPlugins;
+ serverPlugins.clear();
+
+ QStringList pluginNames;
+ QList<float> pluginVersions;
+ pack >> pluginNames;
+ if (!pack.isEmpty())
+ pack >> pluginVersions;
+
+ const int pluginNamesSize = pluginNames.size();
+ const int pluginVersionsSize = pluginVersions.size();
+ for (int i = 0; i < pluginNamesSize; ++i) {
+ float pluginVersion = 1.0;
+ if (i < pluginVersionsSize)
+ pluginVersion = pluginVersions.at(i);
+ serverPlugins.insert(pluginNames.at(i), pluginVersion);
+ }
+
+ QHash<QString, QQmlDebugClient *>::Iterator iter = plugins.begin();
+ for (; iter != plugins.end(); ++iter) {
+ const QString pluginName = iter.key();
+ QQmlDebugClient::State newSate = QQmlDebugClient::Unavailable;
+ if (serverPlugins.contains(pluginName))
+ newSate = QQmlDebugClient::Enabled;
+
+ if (oldServerPlugins.contains(pluginName)
+ != serverPlugins.contains(pluginName)) {
+ iter.value()->stateChanged(newSate);
+ }
+ }
+ } else {
+ qWarning() << "QQmlDebugConnection: Unknown control message id" << op;
+ }
+ } else {
+ QByteArray message;
+ pack >> message;
+
+ QHash<QString, QQmlDebugClient *>::Iterator iter =
+ plugins.find(name);
+ if (iter == plugins.end()) {
+ qWarning() << "QQmlDebugConnection: Message received for missing plugin" << name;
+ } else {
+ (*iter)->messageReceived(message);
+ }
+ }
+ }
+}
+
+void QQmlDebugConnectionPrivate::deviceAboutToClose()
+{
+ // This is nasty syntax but we want to emit our own aboutToClose signal (by calling QIODevice::close())
+ // without calling the underlying device close fn as that would cause an infinite loop
+ q->QIODevice::close();
+}
+
+QQmlDebugConnection::QQmlDebugConnection(QObject *parent)
+ : QIODevice(parent), d(new QQmlDebugConnectionPrivate(this))
+{
+}
+
+QQmlDebugConnection::~QQmlDebugConnection()
+{
+ QHash<QString, QQmlDebugClient*>::iterator iter = d->plugins.begin();
+ for (; iter != d->plugins.end(); ++iter) {
+ iter.value()->d_func()->connection = 0;
+ iter.value()->stateChanged(QQmlDebugClient::NotConnected);
+ }
+}
+
+bool QQmlDebugConnection::isConnected() const
+{
+ return state() == QAbstractSocket::ConnectedState;
+}
+
+qint64 QQmlDebugConnection::readData(char *data, qint64 maxSize)
+{
+ return d->device->read(data, maxSize);
+}
+
+qint64 QQmlDebugConnection::writeData(const char *data, qint64 maxSize)
+{
+ return d->device->write(data, maxSize);
+}
+
+qint64 QQmlDebugConnection::bytesAvailable() const
+{
+ return d->device->bytesAvailable();
+}
+
+bool QQmlDebugConnection::isSequential() const
+{
+ return true;
+}
+
+void QQmlDebugConnection::close()
+{
+ if (isOpen()) {
+ QIODevice::close();
+ d->device->close();
+ emit stateChanged(QAbstractSocket::UnconnectedState);
+
+ QHash<QString, QQmlDebugClient*>::iterator iter = d->plugins.begin();
+ for (; iter != d->plugins.end(); ++iter) {
+ iter.value()->stateChanged(QQmlDebugClient::NotConnected);
+ }
+ }
+}
+
+bool QQmlDebugConnection::waitForConnected(int msecs)
+{
+ QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
+ if (socket)
+ return socket->waitForConnected(msecs);
+ return false;
+}
+
+QAbstractSocket::SocketState QQmlDebugConnection::state() const
+{
+ QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
+ if (socket)
+ return socket->state();
+
+ return QAbstractSocket::UnconnectedState;
+}
+
+void QQmlDebugConnection::flush()
+{
+ QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
+ if (socket) {
+ socket->flush();
+ return;
+ }
+}
+
+void QQmlDebugConnection::connectToHost(const QString &hostName, quint16 port)
+{
+ QTcpSocket *socket = new QTcpSocket(d);
+ socket->setProxy(QNetworkProxy::NoProxy);
+ d->device = socket;
+ d->connectDeviceSignals();
+ d->gotHello = false;
+ connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError)));
+ connect(socket, SIGNAL(connected()), this, SIGNAL(connected()));
+ socket->connectToHost(hostName, port);
+ QIODevice::open(ReadWrite | Unbuffered);
+}
+
+void QQmlDebugConnectionPrivate::connectDeviceSignals()
+{
+ connect(device, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)));
+ connect(device, SIGNAL(readyRead()), q, SIGNAL(readyRead()));
+ connect(device, SIGNAL(aboutToClose()), this, SLOT(deviceAboutToClose()));
+}
+
+//
+
+QQmlDebugClientPrivate::QQmlDebugClientPrivate()
+ : connection(0)
+{
+}
+
+QQmlDebugClient::QQmlDebugClient(const QString &name,
+ QQmlDebugConnection *parent)
+ : QObject(*(new QQmlDebugClientPrivate), parent)
+{
+ Q_D(QQmlDebugClient);
+ d->name = name;
+ d->connection = parent;
+
+ if (!d->connection)
+ return;
+
+ if (d->connection->d->plugins.contains(name)) {
+ qWarning() << "QQmlDebugClient: Conflicting plugin name" << name;
+ d->connection = 0;
+ } else {
+ d->connection->d->plugins.insert(name, this);
+ d->connection->d->advertisePlugins();
+ }
+}
+
+QQmlDebugClient::~QQmlDebugClient()
+{
+ Q_D(QQmlDebugClient);
+ if (d->connection && d->connection->d) {
+ d->connection->d->plugins.remove(d->name);
+ d->connection->d->advertisePlugins();
+ }
+}
+
+QString QQmlDebugClient::name() const
+{
+ Q_D(const QQmlDebugClient);
+ return d->name;
+}
+
+float QQmlDebugClient::serviceVersion() const
+{
+ Q_D(const QQmlDebugClient);
+ if (d->connection->d->serverPlugins.contains(d->name))
+ return d->connection->d->serverPlugins.value(d->name);
+ return -1;
+}
+
+QQmlDebugClient::State QQmlDebugClient::state() const
+{
+ Q_D(const QQmlDebugClient);
+ if (!d->connection
+ || !d->connection->isConnected()
+ || !d->connection->d->gotHello)
+ return NotConnected;
+
+ if (d->connection->d->serverPlugins.contains(d->name))
+ return Enabled;
+
+ return Unavailable;
+}
+
+void QQmlDebugClient::sendMessage(const QByteArray &message)
+{
+ Q_D(QQmlDebugClient);
+ if (state() != Enabled)
+ return;
+
+ QPacket pack;
+ pack << d->name << message;
+ d->connection->d->protocol->send(pack);
+ d->connection->flush();
+}
+
+void QQmlDebugClient::stateChanged(State)
+{
+}
+
+void QQmlDebugClient::messageReceived(const QByteArray &)
+{
+}
+
+QT_END_NAMESPACE
+
+#include <qqmldebugclient.moc>
diff --git a/src/qml/debugger/qqmldebugclient_p.h b/src/qml/debugger/qqmldebugclient_p.h
new file mode 100644
index 0000000000..064e15cf49
--- /dev/null
+++ b/src/qml/debugger/qqmldebugclient_p.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDEBUGCLIENT_H
+#define QQMLDEBUGCLIENT_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 <QtNetwork/qtcpsocket.h>
+
+#include <private/qtqmlglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlDebugConnectionPrivate;
+class Q_QML_PRIVATE_EXPORT QQmlDebugConnection : public QIODevice
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(QQmlDebugConnection)
+public:
+ QQmlDebugConnection(QObject * = 0);
+ ~QQmlDebugConnection();
+
+ void connectToHost(const QString &hostName, quint16 port);
+
+ qint64 bytesAvailable() const;
+ bool isConnected() const;
+ QAbstractSocket::SocketState state() const;
+ void flush();
+ bool isSequential() const;
+ void close();
+ bool waitForConnected(int msecs = 30000);
+
+signals:
+ void connected();
+ void stateChanged(QAbstractSocket::SocketState socketState);
+ void error(QAbstractSocket::SocketError socketError);
+
+protected:
+ qint64 readData(char *data, qint64 maxSize);
+ qint64 writeData(const char *data, qint64 maxSize);
+
+private:
+ QQmlDebugConnectionPrivate *d;
+ friend class QQmlDebugClient;
+ friend class QQmlDebugClientPrivate;
+};
+
+class QQmlDebugClientPrivate;
+class Q_QML_PRIVATE_EXPORT QQmlDebugClient : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQmlDebugClient)
+ Q_DISABLE_COPY(QQmlDebugClient)
+
+public:
+ enum State { NotConnected, Unavailable, Enabled };
+
+ QQmlDebugClient(const QString &, QQmlDebugConnection *parent);
+ ~QQmlDebugClient();
+
+ QString name() const;
+ float serviceVersion() const;
+ State state() const;
+
+ virtual void sendMessage(const QByteArray &);
+
+protected:
+ virtual void stateChanged(State);
+ virtual void messageReceived(const QByteArray &);
+
+private:
+ friend class QQmlDebugConnection;
+ friend class QQmlDebugConnectionPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLDEBUGCLIENT_H
diff --git a/src/qml/debugger/qqmldebughelper.cpp b/src/qml/debugger/qqmldebughelper.cpp
new file mode 100644
index 0000000000..7158b3609d
--- /dev/null
+++ b/src/qml/debugger/qqmldebughelper.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebughelper_p.h"
+
+#include <QtCore/QAbstractAnimation>
+#include <QtQml/QJSEngine>
+
+#include <private/qqmlengine_p.h>
+#include <private/qabstractanimation_p.h>
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+void QQmlDebugHelper::setAnimationSlowDownFactor(qreal factor)
+{
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setSlowModeEnabled(factor != 1.0);
+ timer->setSlowdownFactor(factor);
+}
+
+void QQmlDebugHelper::enableDebugging() {
+ qWarning("QQmlDebugHelper::enableDebugging() is deprecated! Add CONFIG += declarative_debug to your .pro file instead.");
+#ifndef QQML_NO_DEBUG_PROTOCOL
+ if (!QQmlEnginePrivate::qml_debugging_enabled) {
+ qWarning("Qml debugging is enabled. Only use this in a safe environment!");
+ }
+ QQmlEnginePrivate::qml_debugging_enabled = true;
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmldebughelper_p.h b/src/qml/debugger/qqmldebughelper_p.h
new file mode 100644
index 0000000000..5d2bcc2be0
--- /dev/null
+++ b/src/qml/debugger/qqmldebughelper_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDEBUGHELPER_P_H
+#define QQMLDEBUGHELPER_P_H
+
+#include <private/qtqmlglobal_p.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.
+//
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+
+#ifndef QT_BUILD_QML_LIB
+#warning Use of this header file is deprecated! Add CONFIG += declarative_debug to your .pro file instead.
+#endif
+
+// Helper methods to access private API through a stable interface
+// This is used in the qmljsdebugger library of QtCreator.
+class Q_QML_EXPORT QQmlDebugHelper
+{
+public:
+ static void setAnimationSlowDownFactor(qreal factor);
+
+ // Enables remote debugging functionality
+ // Only use this for debugging in a safe environment!
+ static void enableDebugging();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLDEBUGHELPER_P_H
diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp
new file mode 100644
index 0000000000..8d5c597a78
--- /dev/null
+++ b/src/qml/debugger/qqmldebugserver.cpp
@@ -0,0 +1,540 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebugserver_p.h"
+#include "qqmldebugservice_p.h"
+#include "qqmldebugservice_p_p.h"
+#include <private/qqmlengine_p.h>
+#include <private/qqmlglobal_p.h>
+
+#include <QtCore/QDir>
+#include <QtCore/QPluginLoader>
+#include <QtCore/QStringList>
+#include <QtCore/qwaitcondition.h>
+
+#include <private/qobject_p.h>
+#include <private/qcoreapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ QQmlDebug Protocol (Version 1):
+
+ handshake:
+ 1. Client sends
+ "QQmlDebugServer" 0 version pluginNames
+ version: an int representing the highest protocol version the client knows
+ pluginNames: plugins available on client side
+ 2. Server sends
+ "QQmlDebugClient" 0 version pluginNames pluginVersions
+ version: an int representing the highest protocol version the client & server know
+ pluginNames: plugins available on server side. plugins both in the client and server message are enabled.
+ client plugin advertisement
+ 1. Client sends
+ "QQmlDebugServer" 1 pluginNames
+ server plugin advertisement
+ 1. Server sends
+ "QQmlDebugClient" 1 pluginNames pluginVersions
+ plugin communication:
+ Everything send with a header different to "QQmlDebugServer" is sent to the appropriate plugin.
+ */
+
+const int protocolVersion = 1;
+
+// print detailed information about loading of plugins
+DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE)
+
+class QQmlDebugServerThread;
+
+class QQmlDebugServerPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlDebugServer)
+public:
+ QQmlDebugServerPrivate();
+
+ void advertisePlugins();
+ QQmlDebugServerConnection *loadConnectionPlugin(const QString &pluginName);
+
+ QQmlDebugServerConnection *connection;
+ QHash<QString, QQmlDebugService *> plugins;
+ mutable QReadWriteLock pluginsLock;
+ QStringList clientPlugins;
+ bool gotHello;
+
+ QMutex messageArrivedMutex;
+ QWaitCondition messageArrivedCondition;
+ QStringList waitingForMessageNames;
+ QQmlDebugServerThread *thread;
+ QPluginLoader loader;
+
+private:
+ // private slot
+ void _q_sendMessages(const QList<QByteArray> &messages);
+};
+
+class QQmlDebugServerThread : public QThread
+{
+public:
+ void setPluginName(const QString &pluginName) {
+ m_pluginName = pluginName;
+ }
+
+ void setPort(int port, bool block) {
+ m_port = port;
+ m_block = block;
+ }
+
+ void run();
+
+private:
+ QString m_pluginName;
+ int m_port;
+ bool m_block;
+};
+
+QQmlDebugServerPrivate::QQmlDebugServerPrivate() :
+ connection(0),
+ gotHello(false),
+ thread(0)
+{
+ // used in _q_sendMessages
+ qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>");
+}
+
+void QQmlDebugServerPrivate::advertisePlugins()
+{
+ Q_Q(QQmlDebugServer);
+
+ if (!gotHello)
+ return;
+
+ QByteArray message;
+ {
+ QDataStream out(&message, QIODevice::WriteOnly);
+ QStringList pluginNames;
+ QList<float> pluginVersions;
+ foreach (QQmlDebugService *service, plugins.values()) {
+ pluginNames << service->name();
+ pluginVersions << service->version();
+ }
+ out << QString(QLatin1String("QQmlDebugClient")) << 1 << pluginNames << pluginVersions;
+ }
+
+ QMetaObject::invokeMethod(q, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList<QByteArray>, QList<QByteArray>() << message));
+}
+
+QQmlDebugServerConnection *QQmlDebugServerPrivate::loadConnectionPlugin(
+ const QString &pluginName)
+{
+#ifndef QT_NO_LIBRARY
+ QStringList pluginCandidates;
+ const QStringList paths = QCoreApplication::libraryPaths();
+ foreach (const QString &libPath, paths) {
+ const QDir dir(libPath + QLatin1String("/qmltooling"));
+ if (dir.exists()) {
+ QStringList plugins(dir.entryList(QDir::Files));
+ foreach (const QString &pluginPath, plugins) {
+ if (QFileInfo(pluginPath).fileName().contains(pluginName))
+ pluginCandidates << dir.absoluteFilePath(pluginPath);
+ }
+ }
+ }
+
+ foreach (const QString &pluginPath, pluginCandidates) {
+ if (qmlDebugVerbose())
+ qDebug() << "QQmlDebugServer: Trying to load plugin " << pluginPath << "...";
+
+ loader.setFileName(pluginPath);
+ if (!loader.load()) {
+ if (qmlDebugVerbose())
+ qDebug() << "QQmlDebugServer: Error while loading: " << loader.errorString();
+ continue;
+ }
+ if (QObject *instance = loader.instance())
+ connection = qobject_cast<QQmlDebugServerConnection*>(instance);
+
+ if (connection) {
+ if (qmlDebugVerbose())
+ qDebug() << "QQmlDebugServer: Plugin successfully loaded.";
+
+ return connection;
+ }
+
+ if (qmlDebugVerbose())
+ qDebug() << "QQmlDebugServer: Plugin does not implement interface QQmlDebugServerConnection.";
+
+ loader.unload();
+ }
+#endif
+ return 0;
+}
+
+void QQmlDebugServerThread::run()
+{
+ QQmlDebugServer *server = QQmlDebugServer::instance();
+ QQmlDebugServerConnection *connection
+ = server->d_func()->loadConnectionPlugin(m_pluginName);
+ if (connection) {
+ connection->setServer(QQmlDebugServer::instance());
+ connection->setPort(m_port, m_block);
+ } else {
+ QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
+ qWarning() << QString::fromAscii("QQmlDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Remote debugger plugin has not been found.").arg(appD->qmljsDebugArgumentsString());
+ }
+
+ exec();
+
+ // make sure events still waiting are processed
+ QEventLoop eventLoop;
+ eventLoop.processEvents(QEventLoop::AllEvents);
+}
+
+bool QQmlDebugServer::hasDebuggingClient() const
+{
+ Q_D(const QQmlDebugServer);
+ return d->connection
+ && d->connection->isConnected()
+ && d->gotHello;
+}
+
+static QQmlDebugServer *qQmlDebugServer = 0;
+
+
+static void cleanup()
+{
+ delete qQmlDebugServer;
+ qQmlDebugServer = 0;
+}
+
+QQmlDebugServer *QQmlDebugServer::instance()
+{
+ static bool commandLineTested = false;
+
+ if (!commandLineTested) {
+ commandLineTested = true;
+
+ QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
+#ifndef QQML_NO_DEBUG_PROTOCOL
+ // ### remove port definition when protocol is changed
+ int port = 0;
+ bool block = false;
+ bool ok = false;
+
+ // format: qmljsdebugger=port:3768[,block] OR qmljsdebugger=ost[,block]
+ if (!appD->qmljsDebugArgumentsString().isEmpty()) {
+ if (!QQmlEnginePrivate::qml_debugging_enabled) {
+ qWarning() << QString::fromLatin1(
+ "QQmlDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Debugging has not been enabled.").arg(
+ appD->qmljsDebugArgumentsString());
+ return 0;
+ }
+
+ QString pluginName;
+ if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) {
+ int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(','));
+ port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok);
+ pluginName = QLatin1String("qmldbg_tcp");
+ } else if (appD->qmljsDebugArgumentsString().contains(QLatin1String("ost"))) {
+ pluginName = QLatin1String("qmldbg_ost");
+ ok = true;
+ }
+
+ block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block"));
+
+ if (ok) {
+ qQmlDebugServer = new QQmlDebugServer();
+ QQmlDebugServerThread *thread = new QQmlDebugServerThread;
+ qQmlDebugServer->d_func()->thread = thread;
+ qQmlDebugServer->moveToThread(thread);
+ thread->setPluginName(pluginName);
+ thread->setPort(port, block);
+ thread->start();
+
+ if (block) {
+ QQmlDebugServerPrivate *d = qQmlDebugServer->d_func();
+ d->messageArrivedMutex.lock();
+ d->messageArrivedCondition.wait(&d->messageArrivedMutex);
+ d->messageArrivedMutex.unlock();
+ }
+
+ } else {
+ qWarning() << QString::fromLatin1(
+ "QQmlDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Format is -qmljsdebugger=port:<port>[,block]").arg(
+ appD->qmljsDebugArgumentsString());
+ }
+ }
+#else
+ if (!appD->qmljsDebugArgumentsString().isEmpty()) {
+ qWarning() << QString::fromLatin1(
+ "QQmlDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "QtQml is not configured for debugging.").arg(
+ appD->qmljsDebugArgumentsString());
+ }
+#endif
+ }
+
+ return qQmlDebugServer;
+}
+
+QQmlDebugServer::QQmlDebugServer()
+ : QObject(*(new QQmlDebugServerPrivate))
+{
+ qAddPostRoutine(cleanup);
+}
+
+QQmlDebugServer::~QQmlDebugServer()
+{
+ Q_D(QQmlDebugServer);
+
+ QReadLocker(&d->pluginsLock);
+ {
+ foreach (QQmlDebugService *service, d->plugins.values()) {
+ service->stateAboutToBeChanged(QQmlDebugService::NotConnected);
+ service->d_func()->server = 0;
+ service->d_func()->state = QQmlDebugService::NotConnected;
+ service->stateChanged(QQmlDebugService::NotConnected);
+ }
+ }
+
+ if (d->thread) {
+ d->thread->exit();
+ d->thread->wait();
+ delete d->thread;
+ }
+ delete d->connection;
+}
+
+void QQmlDebugServer::receiveMessage(const QByteArray &message)
+{
+ Q_D(QQmlDebugServer);
+
+ QDataStream in(message);
+
+ QString name;
+
+ in >> name;
+ if (name == QLatin1String("QQmlDebugServer")) {
+ int op = -1;
+ in >> op;
+ if (op == 0) {
+ int version;
+ in >> version >> d->clientPlugins;
+
+ // Send the hello answer immediately, since it needs to arrive before
+ // the plugins below start sending messages.
+ QByteArray helloAnswer;
+ {
+ QDataStream out(&helloAnswer, QIODevice::WriteOnly);
+ QStringList pluginNames;
+ QList<float> pluginVersions;
+ foreach (QQmlDebugService *service, d->plugins.values()) {
+ pluginNames << service->name();
+ pluginVersions << service->version();
+ }
+
+ out << QString(QLatin1String("QQmlDebugClient")) << 0 << protocolVersion << pluginNames << pluginVersions;
+ }
+ d->connection->send(QList<QByteArray>() << helloAnswer);
+
+ d->gotHello = true;
+
+ QReadLocker(&d->pluginsLock);
+ QHash<QString, QQmlDebugService*>::ConstIterator iter = d->plugins.constBegin();
+ for (; iter != d->plugins.constEnd(); ++iter) {
+ QQmlDebugService::State newState = QQmlDebugService::Unavailable;
+ if (d->clientPlugins.contains(iter.key()))
+ newState = QQmlDebugService::Enabled;
+ iter.value()->d_func()->state = newState;
+ iter.value()->stateChanged(newState);
+ }
+
+ qWarning("QQmlDebugServer: Connection established");
+ d->messageArrivedCondition.wakeAll();
+
+ } else if (op == 1) {
+
+ // Service Discovery
+ QStringList oldClientPlugins = d->clientPlugins;
+ in >> d->clientPlugins;
+
+ QReadLocker(&d->pluginsLock);
+ QHash<QString, QQmlDebugService*>::ConstIterator iter = d->plugins.constBegin();
+ for (; iter != d->plugins.constEnd(); ++iter) {
+ const QString pluginName = iter.key();
+ QQmlDebugService::State newState = QQmlDebugService::Unavailable;
+ if (d->clientPlugins.contains(pluginName))
+ newState = QQmlDebugService::Enabled;
+
+ if (oldClientPlugins.contains(pluginName)
+ != d->clientPlugins.contains(pluginName)) {
+ iter.value()->d_func()->state = newState;
+ iter.value()->stateChanged(newState);
+ }
+ }
+
+ } else {
+ qWarning("QQmlDebugServer: Invalid control message %d", op);
+ d->connection->disconnect();
+ return;
+ }
+
+ } else {
+ if (d->gotHello) {
+ QByteArray message;
+ in >> message;
+
+ QReadLocker(&d->pluginsLock);
+ QHash<QString, QQmlDebugService *>::Iterator iter = d->plugins.find(name);
+ if (iter == d->plugins.end()) {
+ qWarning() << "QQmlDebugServer: Message received for missing plugin" << name;
+ } else {
+ (*iter)->messageReceived(message);
+
+ if (d->waitingForMessageNames.removeOne(name))
+ d->messageArrivedCondition.wakeAll();
+ }
+ } else {
+ qWarning("QQmlDebugServer: Invalid hello message");
+ }
+
+ }
+}
+
+void QQmlDebugServerPrivate::_q_sendMessages(const QList<QByteArray> &messages)
+{
+ if (connection)
+ connection->send(messages);
+}
+
+QList<QQmlDebugService*> QQmlDebugServer::services() const
+{
+ const Q_D(QQmlDebugServer);
+ QReadLocker(&d->pluginsLock);
+ return d->plugins.values();
+}
+
+QStringList QQmlDebugServer::serviceNames() const
+{
+ const Q_D(QQmlDebugServer);
+ QReadLocker(&d->pluginsLock);
+ return d->plugins.keys();
+}
+
+bool QQmlDebugServer::addService(QQmlDebugService *service)
+{
+ Q_D(QQmlDebugServer);
+ {
+ QWriteLocker(&d->pluginsLock);
+ if (!service || d->plugins.contains(service->name()))
+ return false;
+ d->plugins.insert(service->name(), service);
+ }
+ {
+ QReadLocker(&d->pluginsLock);
+ d->advertisePlugins();
+ QQmlDebugService::State newState = QQmlDebugService::Unavailable;
+ if (d->clientPlugins.contains(service->name()))
+ newState = QQmlDebugService::Enabled;
+ service->d_func()->state = newState;
+ }
+ return true;
+}
+
+bool QQmlDebugServer::removeService(QQmlDebugService *service)
+{
+ Q_D(QQmlDebugServer);
+ {
+ QWriteLocker(&d->pluginsLock);
+ if (!service || !d->plugins.contains(service->name()))
+ return false;
+ d->plugins.remove(service->name());
+ }
+ {
+ QReadLocker(&d->pluginsLock);
+ QQmlDebugService::State newState = QQmlDebugService::NotConnected;
+ service->stateAboutToBeChanged(newState);
+ d->advertisePlugins();
+ service->d_func()->server = 0;
+ service->d_func()->state = newState;
+ service->stateChanged(newState);
+ }
+
+ return true;
+}
+
+void QQmlDebugServer::sendMessages(QQmlDebugService *service,
+ const QList<QByteArray> &messages)
+{
+ QList<QByteArray> prefixedMessages;
+ foreach (const QByteArray &message, messages) {
+ QByteArray prefixed;
+ QDataStream out(&prefixed, QIODevice::WriteOnly);
+ out << service->name() << message;
+ prefixedMessages << prefixed;
+ }
+
+ QMetaObject::invokeMethod(this, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList<QByteArray>, prefixedMessages));
+}
+
+bool QQmlDebugServer::waitForMessage(QQmlDebugService *service)
+{
+ Q_D(QQmlDebugServer);
+ QReadLocker(&d->pluginsLock);
+
+ if (!service
+ || !d->plugins.contains(service->name()))
+ return false;
+
+ d->messageArrivedMutex.lock();
+ d->waitingForMessageNames << service->name();
+ do {
+ d->messageArrivedCondition.wait(&d->messageArrivedMutex);
+ } while (d->waitingForMessageNames.contains(service->name()));
+ d->messageArrivedMutex.unlock();
+ return true;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qqmldebugserver_p.cpp"
diff --git a/src/qml/debugger/qqmldebugserver_p.h b/src/qml/debugger/qqmldebugserver_p.h
new file mode 100644
index 0000000000..9c6b5435c8
--- /dev/null
+++ b/src/qml/debugger/qqmldebugserver_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDEBUGSERVER_H
+#define QQMLDEBUGSERVER_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <private/qqmldebugserverconnection_p.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.
+//
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlDebugService;
+
+class QQmlDebugServerPrivate;
+class Q_QML_EXPORT QQmlDebugServer : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQmlDebugServer)
+ Q_DISABLE_COPY(QQmlDebugServer)
+public:
+ ~QQmlDebugServer();
+
+ static QQmlDebugServer *instance();
+
+ void setConnection(QQmlDebugServerConnection *connection);
+
+ bool hasDebuggingClient() const;
+
+ QList<QQmlDebugService*> services() const;
+ QStringList serviceNames() const;
+
+
+ bool addService(QQmlDebugService *service);
+ bool removeService(QQmlDebugService *service);
+
+ void receiveMessage(const QByteArray &message);
+
+ bool waitForMessage(QQmlDebugService *service);
+ void sendMessages(QQmlDebugService *service, const QList<QByteArray> &messages);
+
+private:
+ friend class QQmlDebugService;
+ friend class QQmlDebugServicePrivate;
+ friend class QQmlDebugServerThread;
+ QQmlDebugServer();
+ Q_PRIVATE_SLOT(d_func(), void _q_sendMessages(QList<QByteArray>))
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLDEBUGSERVICE_H
diff --git a/src/qml/debugger/qqmldebugserverconnection_p.h b/src/qml/debugger/qqmldebugserverconnection_p.h
new file mode 100644
index 0000000000..ab9e7bd73f
--- /dev/null
+++ b/src/qml/debugger/qqmldebugserverconnection_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDEBUGSERVERCONNECTION_H
+#define QQMLDEBUGSERVERCONNECTION_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <private/qqmlglobal_p.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.
+//
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlDebugServer;
+class Q_QML_EXPORT QQmlDebugServerConnection
+{
+public:
+ QQmlDebugServerConnection() {}
+ virtual ~QQmlDebugServerConnection() {}
+
+ virtual void setServer(QQmlDebugServer *server) = 0;
+ virtual void setPort(int port, bool bock) = 0;
+ virtual bool isConnected() const = 0;
+ virtual void send(const QList<QByteArray> &messages) = 0;
+ virtual void disconnect() = 0;
+ virtual bool waitForMessage() = 0;
+};
+
+#define QQmlDebugServerConnection_iid "org.qt-project.Qt.QQmlDebugServerConnection"
+
+Q_DECLARE_INTERFACE(QQmlDebugServerConnection, QQmlDebugServerConnection_iid)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLDEBUGSERVERCONNECTION_H
diff --git a/src/qml/debugger/qqmldebugservice.cpp b/src/qml/debugger/qqmldebugservice.cpp
new file mode 100644
index 0000000000..9eb9489566
--- /dev/null
+++ b/src/qml/debugger/qqmldebugservice.cpp
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebugservice_p.h"
+#include "qqmldebugservice_p_p.h"
+#include "qqmldebugserver_p.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QStringList>
+
+QT_BEGIN_NAMESPACE
+
+QQmlDebugServicePrivate::QQmlDebugServicePrivate()
+ : server(0)
+{
+}
+
+QQmlDebugService::QQmlDebugService(const QString &name, float version, QObject *parent)
+ : QObject(*(new QQmlDebugServicePrivate), parent)
+{
+ Q_D(QQmlDebugService);
+ d->name = name;
+ d->version = version;
+ d->server = QQmlDebugServer::instance();
+ d->state = QQmlDebugService::NotConnected;
+
+
+}
+
+QQmlDebugService::QQmlDebugService(QQmlDebugServicePrivate &dd,
+ const QString &name, float version, QObject *parent)
+ : QObject(dd, parent)
+{
+ Q_D(QQmlDebugService);
+ d->name = name;
+ d->version = version;
+ d->server = QQmlDebugServer::instance();
+ d->state = QQmlDebugService::NotConnected;
+}
+
+/**
+ Registers the service. This should be called in the constructor of the inherited class. From
+ then on the service might get asynchronous calls to messageReceived().
+ */
+QQmlDebugService::State QQmlDebugService::registerService()
+{
+ Q_D(QQmlDebugService);
+ if (!d->server)
+ return NotConnected;
+
+ if (d->server->serviceNames().contains(d->name)) {
+ qWarning() << "QQmlDebugService: Conflicting plugin name" << d->name;
+ d->server = 0;
+ } else {
+ d->server->addService(this);
+ }
+ return state();
+}
+
+QQmlDebugService::~QQmlDebugService()
+{
+ Q_D(const QQmlDebugService);
+ if (d->server) {
+ d->server->removeService(this);
+ }
+}
+
+QString QQmlDebugService::name() const
+{
+ Q_D(const QQmlDebugService);
+ return d->name;
+}
+
+float QQmlDebugService::version() const
+{
+ Q_D(const QQmlDebugService);
+ return d->version;
+}
+
+QQmlDebugService::State QQmlDebugService::state() const
+{
+ Q_D(const QQmlDebugService);
+ return d->state;
+}
+
+namespace {
+
+struct ObjectReference
+{
+ QPointer<QObject> object;
+ int id;
+};
+
+struct ObjectReferenceHash
+{
+ ObjectReferenceHash() : nextId(0) {}
+
+ QHash<QObject *, ObjectReference> objects;
+ QHash<int, QObject *> ids;
+
+ int nextId;
+};
+
+}
+Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash);
+
+
+/*!
+ Returns a unique id for \a object. Calling this method multiple times
+ for the same object will return the same id.
+*/
+int QQmlDebugService::idForObject(QObject *object)
+{
+ if (!object)
+ return -1;
+
+ ObjectReferenceHash *hash = objectReferenceHash();
+ QHash<QObject *, ObjectReference>::Iterator iter =
+ hash->objects.find(object);
+
+ if (iter == hash->objects.end()) {
+ int id = hash->nextId++;
+
+ hash->ids.insert(id, object);
+ iter = hash->objects.insert(object, ObjectReference());
+ iter->object = object;
+ iter->id = id;
+ } else if (iter->object != object) {
+ int id = hash->nextId++;
+
+ hash->ids.remove(iter->id);
+
+ hash->ids.insert(id, object);
+ iter->object = object;
+ iter->id = id;
+ }
+ return iter->id;
+}
+
+/*!
+ Returns the object for unique \a id. If the object has not previously been
+ assigned an id, through idForObject(), then 0 is returned. If the object
+ has been destroyed, 0 is returned.
+*/
+QObject *QQmlDebugService::objectForId(int id)
+{
+ ObjectReferenceHash *hash = objectReferenceHash();
+
+ QHash<int, QObject *>::Iterator iter = hash->ids.find(id);
+ if (iter == hash->ids.end())
+ return 0;
+
+
+ QHash<QObject *, ObjectReference>::Iterator objIter =
+ hash->objects.find(*iter);
+ Q_ASSERT(objIter != hash->objects.end());
+
+ if (objIter->object == 0) {
+ hash->ids.erase(iter);
+ hash->objects.erase(objIter);
+ return 0;
+ } else {
+ return *iter;
+ }
+}
+
+bool QQmlDebugService::isDebuggingEnabled()
+{
+ return QQmlDebugServer::instance() != 0;
+}
+
+bool QQmlDebugService::hasDebuggingClient()
+{
+ return QQmlDebugServer::instance() != 0
+ && QQmlDebugServer::instance()->hasDebuggingClient();
+}
+
+QString QQmlDebugService::objectToString(QObject *obj)
+{
+ if(!obj)
+ return QLatin1String("NULL");
+
+ QString objectName = obj->objectName();
+ if(objectName.isEmpty())
+ objectName = QLatin1String("<unnamed>");
+
+ QString rv = QString::fromUtf8(obj->metaObject()->className()) +
+ QLatin1String(": ") + objectName;
+
+ return rv;
+}
+
+void QQmlDebugService::sendMessage(const QByteArray &message)
+{
+ sendMessages(QList<QByteArray>() << message);
+}
+
+void QQmlDebugService::sendMessages(const QList<QByteArray> &messages)
+{
+ Q_D(QQmlDebugService);
+
+ if (state() != Enabled)
+ return;
+
+ d->server->sendMessages(this, messages);
+}
+
+bool QQmlDebugService::waitForMessage()
+{
+ Q_D(QQmlDebugService);
+
+ if (state() != Enabled)
+ return false;
+
+ return d->server->waitForMessage(this);
+}
+
+void QQmlDebugService::stateAboutToBeChanged(State)
+{
+}
+
+void QQmlDebugService::stateChanged(State)
+{
+}
+
+void QQmlDebugService::messageReceived(const QByteArray &)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmldebugservice_p.h b/src/qml/debugger/qqmldebugservice_p.h
new file mode 100644
index 0000000000..f19b64f42b
--- /dev/null
+++ b/src/qml/debugger/qqmldebugservice_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDEBUGSERVICE_H
+#define QQMLDEBUGSERVICE_H
+
+#include <QtCore/qobject.h>
+
+#include <private/qtqmlglobal_p.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.
+//
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlDebugServicePrivate;
+class Q_QML_PRIVATE_EXPORT QQmlDebugService : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQmlDebugService)
+ Q_DISABLE_COPY(QQmlDebugService)
+
+public:
+ explicit QQmlDebugService(const QString &, float version, QObject *parent = 0);
+ ~QQmlDebugService();
+
+ QString name() const;
+ float version() const;
+
+ enum State { NotConnected, Unavailable, Enabled };
+ State state() const;
+
+ void sendMessage(const QByteArray &);
+ void sendMessages(const QList<QByteArray> &);
+ bool waitForMessage();
+
+ static int idForObject(QObject *);
+ static QObject *objectForId(int);
+
+ static QString objectToString(QObject *obj);
+
+ static bool isDebuggingEnabled();
+ static bool hasDebuggingClient();
+
+protected:
+ QQmlDebugService(QQmlDebugServicePrivate &dd, const QString &name, float version, QObject *parent = 0);
+
+ State registerService();
+
+ virtual void stateAboutToBeChanged(State);
+ virtual void stateChanged(State);
+ virtual void messageReceived(const QByteArray &);
+
+private:
+ friend class QQmlDebugServer;
+ friend class QQmlDebugServerPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLDEBUGSERVICE_H
+
diff --git a/src/qml/debugger/qqmldebugservice_p_p.h b/src/qml/debugger/qqmldebugservice_p_p.h
new file mode 100644
index 0000000000..c066e41fe6
--- /dev/null
+++ b/src/qml/debugger/qqmldebugservice_p_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDEBUGSERVICE_P_H
+#define QQMLDEBUGSERVICE_P_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 <private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlDebugServer;
+
+class QQmlDebugServicePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlDebugService)
+public:
+ QQmlDebugServicePrivate();
+
+ QString name;
+ float version;
+ QQmlDebugServer *server;
+ QQmlDebugService::State state;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLDEBUGSERVICE_P_H
diff --git a/src/qml/debugger/qqmldebugstatesdelegate_p.h b/src/qml/debugger/qqmldebugstatesdelegate_p.h
new file mode 100644
index 0000000000..6e3cc978f2
--- /dev/null
+++ b/src/qml/debugger/qqmldebugstatesdelegate_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDEBUGSTATESDELEGATE_P_H
+#define QQMLDEBUGSTATESDELEGATE_P_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 <QtQml/qtqmlglobal.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlContext;
+class QQmlProperty;
+class QObject;
+class QString;
+class QVariant;
+
+class QQmlDebugStatesDelegate
+{
+protected:
+ QQmlDebugStatesDelegate() {}
+
+public:
+ virtual ~QQmlDebugStatesDelegate() {}
+
+ virtual void buildStatesList(QQmlContext *ctxt, bool cleanList) = 0;
+ virtual void updateBinding(QQmlContext *context,
+ const QQmlProperty &property,
+ const QVariant &expression, bool isLiteralValue,
+ const QString &fileName, int line, int column,
+ bool *inBaseState) = 0;
+ virtual bool setBindingForInvalidProperty(QObject *object,
+ const QString &propertyName,
+ const QVariant &expression,
+ bool isLiteralValue) = 0;
+ virtual void resetBindingForInvalidProperty(QObject *object,
+ const QString &propertyName) = 0;
+
+private:
+ Q_DISABLE_COPY(QQmlDebugStatesDelegate)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLDEBUGSTATESDELEGATE_P_H
diff --git a/src/qml/debugger/qqmlenginedebug.cpp b/src/qml/debugger/qqmlenginedebug.cpp
new file mode 100644
index 0000000000..597e7aeb04
--- /dev/null
+++ b/src/qml/debugger/qqmlenginedebug.cpp
@@ -0,0 +1,1072 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlenginedebug_p.h"
+
+#include "qqmldebugclient_p.h"
+
+#include "qqmlenginedebugservice_p.h"
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngineDebugClient : public QQmlDebugClient
+{
+public:
+ QQmlEngineDebugClient(QQmlDebugConnection *client, QQmlEngineDebugPrivate *p);
+
+protected:
+ virtual void stateChanged(State state);
+ virtual void messageReceived(const QByteArray &);
+
+private:
+ QQmlEngineDebugPrivate *priv;
+ friend class QQmlEngineDebugPrivate;
+};
+
+class QQmlEngineDebugPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlEngineDebug)
+public:
+ QQmlEngineDebugPrivate(QQmlDebugConnection *);
+ ~QQmlEngineDebugPrivate();
+
+ void stateChanged(QQmlEngineDebug::State status);
+ void message(const QByteArray &);
+
+ QQmlEngineDebugClient *client;
+ int nextId;
+ int getId();
+
+ void decode(QDataStream &, QQmlDebugContextReference &);
+ void decode(QDataStream &, QQmlDebugObjectReference &, bool simple);
+
+ static void remove(QQmlEngineDebug *, QQmlDebugEnginesQuery *);
+ static void remove(QQmlEngineDebug *, QQmlDebugRootContextQuery *);
+ static void remove(QQmlEngineDebug *, QQmlDebugObjectQuery *);
+ static void remove(QQmlEngineDebug *, QQmlDebugExpressionQuery *);
+ static void remove(QQmlEngineDebug *, QQmlDebugWatch *);
+
+ QHash<int, QQmlDebugEnginesQuery *> enginesQuery;
+ QHash<int, QQmlDebugRootContextQuery *> rootContextQuery;
+ QHash<int, QQmlDebugObjectQuery *> objectQuery;
+ QHash<int, QQmlDebugExpressionQuery *> expressionQuery;
+
+ QHash<int, QQmlDebugWatch *> watched;
+};
+
+QQmlEngineDebugClient::QQmlEngineDebugClient(QQmlDebugConnection *client,
+ QQmlEngineDebugPrivate *p)
+ : QQmlDebugClient(QLatin1String("QQmlEngine"), client), priv(p)
+{
+}
+
+void QQmlEngineDebugClient::stateChanged(State status)
+{
+ if (priv)
+ priv->stateChanged(static_cast<QQmlEngineDebug::State>(status));
+}
+
+void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
+{
+ if (priv)
+ priv->message(data);
+}
+
+QQmlEngineDebugPrivate::QQmlEngineDebugPrivate(QQmlDebugConnection *c)
+ : client(new QQmlEngineDebugClient(c, this)), nextId(0)
+{
+}
+
+QQmlEngineDebugPrivate::~QQmlEngineDebugPrivate()
+{
+ if (client)
+ client->priv = 0;
+ delete client;
+
+ QHash<int, QQmlDebugEnginesQuery*>::iterator enginesIter = enginesQuery.begin();
+ for (; enginesIter != enginesQuery.end(); ++enginesIter) {
+ enginesIter.value()->m_client = 0;
+ if (enginesIter.value()->state() == QQmlDebugQuery::Waiting)
+ enginesIter.value()->setState(QQmlDebugQuery::Error);
+ }
+
+ QHash<int, QQmlDebugRootContextQuery*>::iterator rootContextIter = rootContextQuery.begin();
+ for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) {
+ rootContextIter.value()->m_client = 0;
+ if (rootContextIter.value()->state() == QQmlDebugQuery::Waiting)
+ rootContextIter.value()->setState(QQmlDebugQuery::Error);
+ }
+
+ QHash<int, QQmlDebugObjectQuery*>::iterator objectIter = objectQuery.begin();
+ for (; objectIter != objectQuery.end(); ++objectIter) {
+ objectIter.value()->m_client = 0;
+ if (objectIter.value()->state() == QQmlDebugQuery::Waiting)
+ objectIter.value()->setState(QQmlDebugQuery::Error);
+ }
+
+ QHash<int, QQmlDebugExpressionQuery*>::iterator exprIter = expressionQuery.begin();
+ for (; exprIter != expressionQuery.end(); ++exprIter) {
+ exprIter.value()->m_client = 0;
+ if (exprIter.value()->state() == QQmlDebugQuery::Waiting)
+ exprIter.value()->setState(QQmlDebugQuery::Error);
+ }
+
+ QHash<int, QQmlDebugWatch*>::iterator watchIter = watched.begin();
+ for (; watchIter != watched.end(); ++watchIter) {
+ watchIter.value()->m_client = 0;
+ watchIter.value()->setState(QQmlDebugWatch::Dead);
+ }
+}
+
+int QQmlEngineDebugPrivate::getId()
+{
+ return nextId++;
+}
+
+void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugEnginesQuery *q)
+{
+ if (c && q) {
+ QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->enginesQuery.remove(q->m_queryId);
+ }
+}
+
+void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c,
+ QQmlDebugRootContextQuery *q)
+{
+ if (c && q) {
+ QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->rootContextQuery.remove(q->m_queryId);
+ }
+}
+
+void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugObjectQuery *q)
+{
+ if (c && q) {
+ QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->objectQuery.remove(q->m_queryId);
+ }
+}
+
+void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugExpressionQuery *q)
+{
+ if (c && q) {
+ QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->expressionQuery.remove(q->m_queryId);
+ }
+}
+
+void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugWatch *w)
+{
+ if (c && w) {
+ QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
+ p->watched.remove(w->m_queryId);
+ }
+}
+
+void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugObjectReference &o,
+ bool simple)
+{
+ QQmlEngineDebugService::QQmlObjectData data;
+ ds >> data;
+ o.m_debugId = data.objectId;
+ o.m_class = data.objectType;
+ o.m_idString = data.idString;
+ o.m_name = data.objectName;
+ o.m_source.m_url = data.url;
+ o.m_source.m_lineNumber = data.lineNumber;
+ o.m_source.m_columnNumber = data.columnNumber;
+ o.m_contextDebugId = data.contextId;
+
+ if (simple)
+ return;
+
+ int childCount;
+ bool recur;
+ ds >> childCount >> recur;
+
+ for (int ii = 0; ii < childCount; ++ii) {
+ o.m_children.append(QQmlDebugObjectReference());
+ decode(ds, o.m_children.last(), !recur);
+ }
+
+ int propCount;
+ ds >> propCount;
+
+ for (int ii = 0; ii < propCount; ++ii) {
+ QQmlEngineDebugService::QQmlObjectProperty data;
+ ds >> data;
+ QQmlDebugPropertyReference prop;
+ prop.m_objectDebugId = o.m_debugId;
+ prop.m_name = data.name;
+ prop.m_binding = data.binding;
+ prop.m_hasNotifySignal = data.hasNotifySignal;
+ prop.m_valueTypeName = data.valueTypeName;
+ switch (data.type) {
+ case QQmlEngineDebugService::QQmlObjectProperty::Basic:
+ case QQmlEngineDebugService::QQmlObjectProperty::List:
+ case QQmlEngineDebugService::QQmlObjectProperty::SignalProperty:
+ {
+ prop.m_value = data.value;
+ break;
+ }
+ case QQmlEngineDebugService::QQmlObjectProperty::Object:
+ {
+ QQmlDebugObjectReference obj;
+ obj.m_debugId = prop.m_value.toInt();
+ prop.m_value = QVariant::fromValue(obj);
+ break;
+ }
+ case QQmlEngineDebugService::QQmlObjectProperty::Unknown:
+ break;
+ }
+ o.m_properties << prop;
+ }
+}
+
+void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugContextReference &c)
+{
+ ds >> c.m_name >> c.m_debugId;
+
+ int contextCount;
+ ds >> contextCount;
+
+ for (int ii = 0; ii < contextCount; ++ii) {
+ c.m_contexts.append(QQmlDebugContextReference());
+ decode(ds, c.m_contexts.last());
+ }
+
+ int objectCount;
+ ds >> objectCount;
+
+ for (int ii = 0; ii < objectCount; ++ii) {
+ QQmlDebugObjectReference obj;
+ decode(ds, obj, true);
+
+ obj.m_contextDebugId = c.m_debugId;
+ c.m_objects << obj;
+ }
+}
+
+void QQmlEngineDebugPrivate::stateChanged(QQmlEngineDebug::State status)
+{
+ emit q_func()->stateChanged(status);
+}
+
+void QQmlEngineDebugPrivate::message(const QByteArray &data)
+{
+ QDataStream ds(data);
+
+ QByteArray type;
+ ds >> type;
+
+ //qDebug() << "QQmlEngineDebugPrivate::message()" << type;
+
+ if (type == "LIST_ENGINES_R") {
+ int queryId;
+ ds >> queryId;
+
+ QQmlDebugEnginesQuery *query = enginesQuery.value(queryId);
+ if (!query)
+ return;
+ enginesQuery.remove(queryId);
+
+ int count;
+ ds >> count;
+
+ for (int ii = 0; ii < count; ++ii) {
+ QQmlDebugEngineReference ref;
+ ds >> ref.m_name;
+ ds >> ref.m_debugId;
+ query->m_engines << ref;
+ }
+
+ query->m_client = 0;
+ query->setState(QQmlDebugQuery::Completed);
+ } else if (type == "LIST_OBJECTS_R") {
+ int queryId;
+ ds >> queryId;
+
+ QQmlDebugRootContextQuery *query = rootContextQuery.value(queryId);
+ if (!query)
+ return;
+ rootContextQuery.remove(queryId);
+
+ if (!ds.atEnd())
+ decode(ds, query->m_context);
+
+ query->m_client = 0;
+ query->setState(QQmlDebugQuery::Completed);
+ } else if (type == "FETCH_OBJECT_R") {
+ int queryId;
+ ds >> queryId;
+
+ QQmlDebugObjectQuery *query = objectQuery.value(queryId);
+ if (!query)
+ return;
+ objectQuery.remove(queryId);
+
+ if (!ds.atEnd())
+ decode(ds, query->m_object, false);
+
+ query->m_client = 0;
+ query->setState(QQmlDebugQuery::Completed);
+ } else if (type == "EVAL_EXPRESSION_R") {
+ int queryId;
+ QVariant result;
+ ds >> queryId >> result;
+
+ QQmlDebugExpressionQuery *query = expressionQuery.value(queryId);
+ if (!query)
+ return;
+ expressionQuery.remove(queryId);
+
+ query->m_result = result;
+ query->m_client = 0;
+ query->setState(QQmlDebugQuery::Completed);
+ } else if (type == "WATCH_PROPERTY_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QQmlDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive);
+ } else if (type == "WATCH_OBJECT_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QQmlDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive);
+ } else if (type == "WATCH_EXPR_OBJECT_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QQmlDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive);
+ } else if (type == "UPDATE_WATCH") {
+ int queryId;
+ int debugId;
+ QByteArray name;
+ QVariant value;
+ ds >> queryId >> debugId >> name >> value;
+
+ QQmlDebugWatch *watch = watched.value(queryId, 0);
+ if (!watch)
+ return;
+ emit watch->valueChanged(name, value);
+ } else if (type == "OBJECT_CREATED") {
+ emit q_func()->newObjects();
+ }
+}
+
+QQmlEngineDebug::QQmlEngineDebug(QQmlDebugConnection *client, QObject *parent)
+ : QObject(*(new QQmlEngineDebugPrivate(client)), parent)
+{
+}
+
+QQmlEngineDebug::~QQmlEngineDebug()
+{
+}
+
+QQmlEngineDebug::State QQmlEngineDebug::state() const
+{
+ Q_D(const QQmlEngineDebug);
+
+ return static_cast<QQmlEngineDebug::State>(d->client->state());
+}
+
+QQmlDebugPropertyWatch *QQmlEngineDebug::addWatch(const QQmlDebugPropertyReference &property, QObject *parent)
+{
+ Q_D(QQmlEngineDebug);
+
+ QQmlDebugPropertyWatch *watch = new QQmlDebugPropertyWatch(parent);
+ if (d->client->state() == QQmlDebugClient::Enabled) {
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_client = this;
+ watch->m_objectDebugId = property.objectDebugId();
+ watch->m_name = property.name();
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8();
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QQmlDebugWatch::Dead;
+ }
+
+ return watch;
+}
+
+QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugContextReference &, const QString &, QObject *)
+{
+ qWarning("QQmlEngineDebug::addWatch(): Not implemented");
+ return 0;
+}
+
+QQmlDebugObjectExpressionWatch *QQmlEngineDebug::addWatch(const QQmlDebugObjectReference &object, const QString &expr, QObject *parent)
+{
+ Q_D(QQmlEngineDebug);
+ QQmlDebugObjectExpressionWatch *watch = new QQmlDebugObjectExpressionWatch(parent);
+ if (d->client->state() == QQmlDebugClient::Enabled) {
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_client = this;
+ watch->m_objectDebugId = object.debugId();
+ watch->m_expr = expr;
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr;
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QQmlDebugWatch::Dead;
+ }
+ return watch;
+}
+
+QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugObjectReference &object, QObject *parent)
+{
+ Q_D(QQmlEngineDebug);
+
+ QQmlDebugWatch *watch = new QQmlDebugWatch(parent);
+ if (d->client->state() == QQmlDebugClient::Enabled) {
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_client = this;
+ watch->m_objectDebugId = object.debugId();
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId();
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QQmlDebugWatch::Dead;
+ }
+
+ return watch;
+}
+
+QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugFileReference &, QObject *)
+{
+ qWarning("QQmlEngineDebug::addWatch(): Not implemented");
+ return 0;
+}
+
+void QQmlEngineDebug::removeWatch(QQmlDebugWatch *watch)
+{
+ Q_D(QQmlEngineDebug);
+
+ if (!watch || !watch->m_client)
+ return;
+
+ watch->m_client = 0;
+ watch->setState(QQmlDebugWatch::Inactive);
+
+ d->watched.remove(watch->queryId());
+
+ if (d->client && d->client->state() == QQmlDebugClient::Enabled) {
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("NO_WATCH") << watch->queryId();
+ d->client->sendMessage(message);
+ }
+}
+
+QQmlDebugEnginesQuery *QQmlEngineDebug::queryAvailableEngines(QObject *parent)
+{
+ Q_D(QQmlEngineDebug);
+
+ QQmlDebugEnginesQuery *query = new QQmlDebugEnginesQuery(parent);
+ if (d->client->state() == QQmlDebugClient::Enabled) {
+ query->m_client = this;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->enginesQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("LIST_ENGINES") << queryId;
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QQmlDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QQmlDebugRootContextQuery *QQmlEngineDebug::queryRootContexts(const QQmlDebugEngineReference &engine, QObject *parent)
+{
+ Q_D(QQmlEngineDebug);
+
+ QQmlDebugRootContextQuery *query = new QQmlDebugRootContextQuery(parent);
+ if (d->client->state() == QQmlDebugClient::Enabled && engine.debugId() != -1) {
+ query->m_client = this;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->rootContextQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId();
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QQmlDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QQmlDebugObjectQuery *QQmlEngineDebug::queryObject(const QQmlDebugObjectReference &object, QObject *parent)
+{
+ Q_D(QQmlEngineDebug);
+
+ QQmlDebugObjectQuery *query = new QQmlDebugObjectQuery(parent);
+ if (d->client->state() == QQmlDebugClient::Enabled && object.debugId() != -1) {
+ query->m_client = this;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->objectQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
+ << false << true;
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QQmlDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QQmlDebugObjectQuery *QQmlEngineDebug::queryObjectRecursive(const QQmlDebugObjectReference &object, QObject *parent)
+{
+ Q_D(QQmlEngineDebug);
+
+ QQmlDebugObjectQuery *query = new QQmlDebugObjectQuery(parent);
+ if (d->client->state() == QQmlDebugClient::Enabled && object.debugId() != -1) {
+ query->m_client = this;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->objectQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
+ << true << true;
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QQmlDebugQuery::Error;
+ }
+
+ return query;
+}
+
+QQmlDebugExpressionQuery *QQmlEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent)
+{
+ Q_D(QQmlEngineDebug);
+
+ QQmlDebugExpressionQuery *query = new QQmlDebugExpressionQuery(parent);
+ if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ query->m_client = this;
+ query->m_expr = expr;
+ int queryId = d->getId();
+ query->m_queryId = queryId;
+ d->expressionQuery.insert(queryId, query);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr;
+ d->client->sendMessage(message);
+ } else {
+ query->m_state = QQmlDebugQuery::Error;
+ }
+
+ return query;
+}
+
+bool QQmlEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName,
+ const QVariant &bindingExpression,
+ bool isLiteralValue,
+ QString source, int line)
+{
+ Q_D(QQmlEngineDebug);
+
+ if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line;
+ d->client->sendMessage(message);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool QQmlEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName)
+{
+ Q_D(QQmlEngineDebug);
+
+ if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName;
+ d->client->sendMessage(message);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool QQmlEngineDebug::setMethodBody(int objectDebugId, const QString &methodName,
+ const QString &methodBody)
+{
+ Q_D(QQmlEngineDebug);
+
+ if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody;
+ d->client->sendMessage(message);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+QQmlDebugWatch::QQmlDebugWatch(QObject *parent)
+ : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1)
+{
+}
+
+QQmlDebugWatch::~QQmlDebugWatch()
+{
+ if (m_client && m_queryId != -1)
+ QQmlEngineDebugPrivate::remove(m_client, this);
+}
+
+int QQmlDebugWatch::queryId() const
+{
+ return m_queryId;
+}
+
+int QQmlDebugWatch::objectDebugId() const
+{
+ return m_objectDebugId;
+}
+
+QQmlDebugWatch::State QQmlDebugWatch::state() const
+{
+ return m_state;
+}
+
+void QQmlDebugWatch::setState(State s)
+{
+ if (m_state == s)
+ return;
+ m_state = s;
+ emit stateChanged(m_state);
+}
+
+QQmlDebugPropertyWatch::QQmlDebugPropertyWatch(QObject *parent)
+ : QQmlDebugWatch(parent)
+{
+}
+
+QString QQmlDebugPropertyWatch::name() const
+{
+ return m_name;
+}
+
+
+QQmlDebugObjectExpressionWatch::QQmlDebugObjectExpressionWatch(QObject *parent)
+ : QQmlDebugWatch(parent)
+{
+}
+
+QString QQmlDebugObjectExpressionWatch::expression() const
+{
+ return m_expr;
+}
+
+
+QQmlDebugQuery::QQmlDebugQuery(QObject *parent)
+ : QObject(parent), m_state(Waiting)
+{
+}
+
+QQmlDebugQuery::State QQmlDebugQuery::state() const
+{
+ return m_state;
+}
+
+bool QQmlDebugQuery::isWaiting() const
+{
+ return m_state == Waiting;
+}
+
+void QQmlDebugQuery::setState(State s)
+{
+ if (m_state == s)
+ return;
+ m_state = s;
+ emit stateChanged(m_state);
+}
+
+QQmlDebugEnginesQuery::QQmlDebugEnginesQuery(QObject *parent)
+ : QQmlDebugQuery(parent), m_client(0), m_queryId(-1)
+{
+}
+
+QQmlDebugEnginesQuery::~QQmlDebugEnginesQuery()
+{
+ if (m_client && m_queryId != -1)
+ QQmlEngineDebugPrivate::remove(m_client, this);
+}
+
+QList<QQmlDebugEngineReference> QQmlDebugEnginesQuery::engines() const
+{
+ return m_engines;
+}
+
+QQmlDebugRootContextQuery::QQmlDebugRootContextQuery(QObject *parent)
+ : QQmlDebugQuery(parent), m_client(0), m_queryId(-1)
+{
+}
+
+QQmlDebugRootContextQuery::~QQmlDebugRootContextQuery()
+{
+ if (m_client && m_queryId != -1)
+ QQmlEngineDebugPrivate::remove(m_client, this);
+}
+
+QQmlDebugContextReference QQmlDebugRootContextQuery::rootContext() const
+{
+ return m_context;
+}
+
+QQmlDebugObjectQuery::QQmlDebugObjectQuery(QObject *parent)
+ : QQmlDebugQuery(parent), m_client(0), m_queryId(-1)
+{
+}
+
+QQmlDebugObjectQuery::~QQmlDebugObjectQuery()
+{
+ if (m_client && m_queryId != -1)
+ QQmlEngineDebugPrivate::remove(m_client, this);
+}
+
+QQmlDebugObjectReference QQmlDebugObjectQuery::object() const
+{
+ return m_object;
+}
+
+QQmlDebugExpressionQuery::QQmlDebugExpressionQuery(QObject *parent)
+ : QQmlDebugQuery(parent), m_client(0), m_queryId(-1)
+{
+}
+
+QQmlDebugExpressionQuery::~QQmlDebugExpressionQuery()
+{
+ if (m_client && m_queryId != -1)
+ QQmlEngineDebugPrivate::remove(m_client, this);
+}
+
+QVariant QQmlDebugExpressionQuery::expression() const
+{
+ return m_expr;
+}
+
+QVariant QQmlDebugExpressionQuery::result() const
+{
+ return m_result;
+}
+
+QQmlDebugEngineReference::QQmlDebugEngineReference()
+ : m_debugId(-1)
+{
+}
+
+QQmlDebugEngineReference::QQmlDebugEngineReference(int debugId)
+ : m_debugId(debugId)
+{
+}
+
+QQmlDebugEngineReference::QQmlDebugEngineReference(const QQmlDebugEngineReference &o)
+ : m_debugId(o.m_debugId), m_name(o.m_name)
+{
+}
+
+QQmlDebugEngineReference &
+QQmlDebugEngineReference::operator=(const QQmlDebugEngineReference &o)
+{
+ m_debugId = o.m_debugId; m_name = o.m_name;
+ return *this;
+}
+
+int QQmlDebugEngineReference::debugId() const
+{
+ return m_debugId;
+}
+
+QString QQmlDebugEngineReference::name() const
+{
+ return m_name;
+}
+
+QQmlDebugObjectReference::QQmlDebugObjectReference()
+ : m_debugId(-1), m_contextDebugId(-1)
+{
+}
+
+QQmlDebugObjectReference::QQmlDebugObjectReference(int debugId)
+ : m_debugId(debugId), m_contextDebugId(-1)
+{
+}
+
+QQmlDebugObjectReference::QQmlDebugObjectReference(const QQmlDebugObjectReference &o)
+ : m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString),
+ m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId),
+ m_properties(o.m_properties), m_children(o.m_children)
+{
+}
+
+QQmlDebugObjectReference &
+QQmlDebugObjectReference::operator=(const QQmlDebugObjectReference &o)
+{
+ m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString;
+ m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
+ m_properties = o.m_properties; m_children = o.m_children;
+ return *this;
+}
+
+int QQmlDebugObjectReference::debugId() const
+{
+ return m_debugId;
+}
+
+QString QQmlDebugObjectReference::className() const
+{
+ return m_class;
+}
+
+QString QQmlDebugObjectReference::idString() const
+{
+ return m_idString;
+}
+
+QString QQmlDebugObjectReference::name() const
+{
+ return m_name;
+}
+
+QQmlDebugFileReference QQmlDebugObjectReference::source() const
+{
+ return m_source;
+}
+
+int QQmlDebugObjectReference::contextDebugId() const
+{
+ return m_contextDebugId;
+}
+
+QList<QQmlDebugPropertyReference> QQmlDebugObjectReference::properties() const
+{
+ return m_properties;
+}
+
+QList<QQmlDebugObjectReference> QQmlDebugObjectReference::children() const
+{
+ return m_children;
+}
+
+QQmlDebugContextReference::QQmlDebugContextReference()
+ : m_debugId(-1)
+{
+}
+
+QQmlDebugContextReference::QQmlDebugContextReference(const QQmlDebugContextReference &o)
+ : m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts)
+{
+}
+
+QQmlDebugContextReference &QQmlDebugContextReference::operator=(const QQmlDebugContextReference &o)
+{
+ m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects;
+ m_contexts = o.m_contexts;
+ return *this;
+}
+
+int QQmlDebugContextReference::debugId() const
+{
+ return m_debugId;
+}
+
+QString QQmlDebugContextReference::name() const
+{
+ return m_name;
+}
+
+QList<QQmlDebugObjectReference> QQmlDebugContextReference::objects() const
+{
+ return m_objects;
+}
+
+QList<QQmlDebugContextReference> QQmlDebugContextReference::contexts() const
+{
+ return m_contexts;
+}
+
+QQmlDebugFileReference::QQmlDebugFileReference()
+ : m_lineNumber(-1), m_columnNumber(-1)
+{
+}
+
+QQmlDebugFileReference::QQmlDebugFileReference(const QQmlDebugFileReference &o)
+ : m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber)
+{
+}
+
+QQmlDebugFileReference &QQmlDebugFileReference::operator=(const QQmlDebugFileReference &o)
+{
+ m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber;
+ return *this;
+}
+
+QUrl QQmlDebugFileReference::url() const
+{
+ return m_url;
+}
+
+void QQmlDebugFileReference::setUrl(const QUrl &u)
+{
+ m_url = u;
+}
+
+int QQmlDebugFileReference::lineNumber() const
+{
+ return m_lineNumber;
+}
+
+void QQmlDebugFileReference::setLineNumber(int l)
+{
+ m_lineNumber = l;
+}
+
+int QQmlDebugFileReference::columnNumber() const
+{
+ return m_columnNumber;
+}
+
+void QQmlDebugFileReference::setColumnNumber(int c)
+{
+ m_columnNumber = c;
+}
+
+QQmlDebugPropertyReference::QQmlDebugPropertyReference()
+ : m_objectDebugId(-1), m_hasNotifySignal(false)
+{
+}
+
+QQmlDebugPropertyReference::QQmlDebugPropertyReference(const QQmlDebugPropertyReference &o)
+ : m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value),
+ m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding),
+ m_hasNotifySignal(o.m_hasNotifySignal)
+{
+}
+
+QQmlDebugPropertyReference &QQmlDebugPropertyReference::operator=(const QQmlDebugPropertyReference &o)
+{
+ m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value;
+ m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding;
+ m_hasNotifySignal = o.m_hasNotifySignal;
+ return *this;
+}
+
+int QQmlDebugPropertyReference::objectDebugId() const
+{
+ return m_objectDebugId;
+}
+
+QString QQmlDebugPropertyReference::name() const
+{
+ return m_name;
+}
+
+QString QQmlDebugPropertyReference::valueTypeName() const
+{
+ return m_valueTypeName;
+}
+
+QVariant QQmlDebugPropertyReference::value() const
+{
+ return m_value;
+}
+
+QString QQmlDebugPropertyReference::binding() const
+{
+ return m_binding;
+}
+
+bool QQmlDebugPropertyReference::hasNotifySignal() const
+{
+ return m_hasNotifySignal;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/debugger/qqmlenginedebug_p.h b/src/qml/debugger/qqmlenginedebug_p.h
new file mode 100644
index 0000000000..0562d8755b
--- /dev/null
+++ b/src/qml/debugger/qqmlenginedebug_p.h
@@ -0,0 +1,397 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLENGINEDEBUG_H
+#define QQMLENGINEDEBUG_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/qobject.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+
+#include <private/qtqmlglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlDebugConnection;
+class QQmlDebugWatch;
+class QQmlDebugPropertyWatch;
+class QQmlDebugObjectExpressionWatch;
+class QQmlDebugEnginesQuery;
+class QQmlDebugRootContextQuery;
+class QQmlDebugObjectQuery;
+class QQmlDebugExpressionQuery;
+class QQmlDebugPropertyReference;
+class QQmlDebugContextReference;
+class QQmlDebugObjectReference;
+class QQmlDebugFileReference;
+class QQmlDebugEngineReference;
+class QQmlEngineDebugPrivate;
+class Q_QML_PRIVATE_EXPORT QQmlEngineDebug : public QObject
+{
+ Q_OBJECT
+public:
+ enum State { NotConnected, Unavailable, Enabled };
+
+ explicit QQmlEngineDebug(QQmlDebugConnection *, QObject * = 0);
+ ~QQmlEngineDebug();
+
+ State state() const;
+
+ QQmlDebugPropertyWatch *addWatch(const QQmlDebugPropertyReference &,
+ QObject *parent = 0);
+ QQmlDebugWatch *addWatch(const QQmlDebugContextReference &, const QString &,
+ QObject *parent = 0);
+ QQmlDebugObjectExpressionWatch *addWatch(const QQmlDebugObjectReference &, const QString &,
+ QObject *parent = 0);
+ QQmlDebugWatch *addWatch(const QQmlDebugObjectReference &,
+ QObject *parent = 0);
+ QQmlDebugWatch *addWatch(const QQmlDebugFileReference &,
+ QObject *parent = 0);
+
+ void removeWatch(QQmlDebugWatch *watch);
+
+ QQmlDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
+ QQmlDebugRootContextQuery *queryRootContexts(const QQmlDebugEngineReference &,
+ QObject *parent = 0);
+ QQmlDebugObjectQuery *queryObject(const QQmlDebugObjectReference &,
+ QObject *parent = 0);
+ QQmlDebugObjectQuery *queryObjectRecursive(const QQmlDebugObjectReference &,
+ QObject *parent = 0);
+ QQmlDebugExpressionQuery *queryExpressionResult(int objectDebugId,
+ const QString &expr,
+ QObject *parent = 0);
+ bool setBindingForObject(int objectDebugId, const QString &propertyName,
+ const QVariant &bindingExpression, bool isLiteralValue,
+ QString source = QString(), int line = -1);
+ bool resetBindingForObject(int objectDebugId, const QString &propertyName);
+ bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
+
+Q_SIGNALS:
+ void newObjects();
+ void stateChanged(State state);
+
+private:
+ Q_DECLARE_PRIVATE(QQmlEngineDebug)
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugWatch : public QObject
+{
+ Q_OBJECT
+public:
+ enum State { Waiting, Active, Inactive, Dead };
+
+ QQmlDebugWatch(QObject *);
+ ~QQmlDebugWatch();
+
+ int queryId() const;
+ int objectDebugId() const;
+ State state() const;
+
+Q_SIGNALS:
+ void stateChanged(QQmlDebugWatch::State);
+ //void objectChanged(int, const QQmlDebugObjectReference &);
+ //void valueChanged(int, const QVariant &);
+
+ // Server sends value as string if it is a user-type variant
+ void valueChanged(const QByteArray &name, const QVariant &value);
+
+private:
+ friend class QQmlEngineDebug;
+ friend class QQmlEngineDebugPrivate;
+ void setState(State);
+ State m_state;
+ int m_queryId;
+ QQmlEngineDebug *m_client;
+ int m_objectDebugId;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugPropertyWatch : public QQmlDebugWatch
+{
+ Q_OBJECT
+public:
+ QQmlDebugPropertyWatch(QObject *parent);
+
+ QString name() const;
+
+private:
+ friend class QQmlEngineDebug;
+ QString m_name;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugObjectExpressionWatch : public QQmlDebugWatch
+{
+ Q_OBJECT
+public:
+ QQmlDebugObjectExpressionWatch(QObject *parent);
+
+ QString expression() const;
+
+private:
+ friend class QQmlEngineDebug;
+ QString m_expr;
+ int m_debugId;
+};
+
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugQuery : public QObject
+{
+ Q_OBJECT
+public:
+ enum State { Waiting, Error, Completed };
+
+ State state() const;
+ bool isWaiting() const;
+
+Q_SIGNALS:
+ void stateChanged(QQmlDebugQuery::State);
+
+protected:
+ QQmlDebugQuery(QObject *);
+
+private:
+ friend class QQmlEngineDebug;
+ friend class QQmlEngineDebugPrivate;
+ void setState(State);
+ State m_state;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugFileReference
+{
+public:
+ QQmlDebugFileReference();
+ QQmlDebugFileReference(const QQmlDebugFileReference &);
+ QQmlDebugFileReference &operator=(const QQmlDebugFileReference &);
+
+ QUrl url() const;
+ void setUrl(const QUrl &);
+ int lineNumber() const;
+ void setLineNumber(int);
+ int columnNumber() const;
+ void setColumnNumber(int);
+
+private:
+ friend class QQmlEngineDebugPrivate;
+ QUrl m_url;
+ int m_lineNumber;
+ int m_columnNumber;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugEngineReference
+{
+public:
+ QQmlDebugEngineReference();
+ QQmlDebugEngineReference(int);
+ QQmlDebugEngineReference(const QQmlDebugEngineReference &);
+ QQmlDebugEngineReference &operator=(const QQmlDebugEngineReference &);
+
+ int debugId() const;
+ QString name() const;
+
+private:
+ friend class QQmlEngineDebugPrivate;
+ int m_debugId;
+ QString m_name;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugObjectReference
+{
+public:
+ QQmlDebugObjectReference();
+ QQmlDebugObjectReference(int);
+ QQmlDebugObjectReference(const QQmlDebugObjectReference &);
+ QQmlDebugObjectReference &operator=(const QQmlDebugObjectReference &);
+
+ int debugId() const;
+ QString className() const;
+ QString idString() const;
+ QString name() const;
+
+ QQmlDebugFileReference source() const;
+ int contextDebugId() const;
+
+ QList<QQmlDebugPropertyReference> properties() const;
+ QList<QQmlDebugObjectReference> children() const;
+
+private:
+ friend class QQmlEngineDebugPrivate;
+ int m_debugId;
+ QString m_class;
+ QString m_idString;
+ QString m_name;
+ QQmlDebugFileReference m_source;
+ int m_contextDebugId;
+ QList<QQmlDebugPropertyReference> m_properties;
+ QList<QQmlDebugObjectReference> m_children;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugContextReference
+{
+public:
+ QQmlDebugContextReference();
+ QQmlDebugContextReference(const QQmlDebugContextReference &);
+ QQmlDebugContextReference &operator=(const QQmlDebugContextReference &);
+
+ int debugId() const;
+ QString name() const;
+
+ QList<QQmlDebugObjectReference> objects() const;
+ QList<QQmlDebugContextReference> contexts() const;
+
+private:
+ friend class QQmlEngineDebugPrivate;
+ int m_debugId;
+ QString m_name;
+ QList<QQmlDebugObjectReference> m_objects;
+ QList<QQmlDebugContextReference> m_contexts;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugPropertyReference
+{
+public:
+ QQmlDebugPropertyReference();
+ QQmlDebugPropertyReference(const QQmlDebugPropertyReference &);
+ QQmlDebugPropertyReference &operator=(const QQmlDebugPropertyReference &);
+
+ int objectDebugId() const;
+ QString name() const;
+ QVariant value() const;
+ QString valueTypeName() const;
+ QString binding() const;
+ bool hasNotifySignal() const;
+
+private:
+ friend class QQmlEngineDebugPrivate;
+ int m_objectDebugId;
+ QString m_name;
+ QVariant m_value;
+ QString m_valueTypeName;
+ QString m_binding;
+ bool m_hasNotifySignal;
+};
+
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugEnginesQuery : public QQmlDebugQuery
+{
+ Q_OBJECT
+public:
+ virtual ~QQmlDebugEnginesQuery();
+ QList<QQmlDebugEngineReference> engines() const;
+private:
+ friend class QQmlEngineDebug;
+ friend class QQmlEngineDebugPrivate;
+ QQmlDebugEnginesQuery(QObject *);
+ QQmlEngineDebug *m_client;
+ int m_queryId;
+ QList<QQmlDebugEngineReference> m_engines;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugRootContextQuery : public QQmlDebugQuery
+{
+ Q_OBJECT
+public:
+ virtual ~QQmlDebugRootContextQuery();
+ QQmlDebugContextReference rootContext() const;
+private:
+ friend class QQmlEngineDebug;
+ friend class QQmlEngineDebugPrivate;
+ QQmlDebugRootContextQuery(QObject *);
+ QQmlEngineDebug *m_client;
+ int m_queryId;
+ QQmlDebugContextReference m_context;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugObjectQuery : public QQmlDebugQuery
+{
+ Q_OBJECT
+public:
+ virtual ~QQmlDebugObjectQuery();
+ QQmlDebugObjectReference object() const;
+private:
+ friend class QQmlEngineDebug;
+ friend class QQmlEngineDebugPrivate;
+ QQmlDebugObjectQuery(QObject *);
+ QQmlEngineDebug *m_client;
+ int m_queryId;
+ QQmlDebugObjectReference m_object;
+
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDebugExpressionQuery : public QQmlDebugQuery
+{
+ Q_OBJECT
+public:
+ virtual ~QQmlDebugExpressionQuery();
+ QVariant expression() const;
+ QVariant result() const;
+private:
+ friend class QQmlEngineDebug;
+ friend class QQmlEngineDebugPrivate;
+ QQmlDebugExpressionQuery(QObject *);
+ QQmlEngineDebug *m_client;
+ int m_queryId;
+ QVariant m_expr;
+ QVariant m_result;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlDebugEngineReference)
+Q_DECLARE_METATYPE(QQmlDebugObjectReference)
+Q_DECLARE_METATYPE(QQmlDebugContextReference)
+Q_DECLARE_METATYPE(QQmlDebugPropertyReference)
+
+QT_END_HEADER
+
+#endif // QQMLENGINEDEBUG_H
diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp
new file mode 100644
index 0000000000..be2e826bdf
--- /dev/null
+++ b/src/qml/debugger/qqmlenginedebugservice.cpp
@@ -0,0 +1,733 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlenginedebugservice_p.h"
+
+#include "qqmldebugstatesdelegate_p.h"
+#include <private/qqmlboundsignal_p.h>
+#include <qqmlengine.h>
+#include <private/qqmlmetatype_p.h>
+#include <qqmlproperty.h>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlcontext_p.h>
+#include <private/qqmlwatcher_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <private/qqmlvmemetaobject_p.h>
+#include <private/qqmlexpression_p.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QQmlEngineDebugService, qmlEngineDebugService);
+
+QQmlEngineDebugService *QQmlEngineDebugService::instance()
+{
+ return qmlEngineDebugService();
+}
+
+QQmlEngineDebugService::QQmlEngineDebugService(QObject *parent)
+ : QQmlDebugService(QLatin1String("QQmlEngine"), 1, parent),
+ m_watch(new QQmlWatcher(this)),
+ m_statesDelegate(0)
+{
+ QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)),
+ this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant)));
+
+ registerService();
+}
+
+QQmlEngineDebugService::~QQmlEngineDebugService()
+{
+ delete m_statesDelegate;
+}
+
+QDataStream &operator<<(QDataStream &ds,
+ const QQmlEngineDebugService::QQmlObjectData &data)
+{
+ ds << data.url << data.lineNumber << data.columnNumber << data.idString
+ << data.objectName << data.objectType << data.objectId << data.contextId;
+ return ds;
+}
+
+QDataStream &operator>>(QDataStream &ds,
+ QQmlEngineDebugService::QQmlObjectData &data)
+{
+ ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
+ >> data.objectName >> data.objectType >> data.objectId >> data.contextId;
+ return ds;
+}
+
+QDataStream &operator<<(QDataStream &ds,
+ const QQmlEngineDebugService::QQmlObjectProperty &data)
+{
+ ds << (int)data.type << data.name << data.value << data.valueTypeName
+ << data.binding << data.hasNotifySignal;
+ return ds;
+}
+
+QDataStream &operator>>(QDataStream &ds,
+ QQmlEngineDebugService::QQmlObjectProperty &data)
+{
+ int type;
+ ds >> type >> data.name >> data.value >> data.valueTypeName
+ >> data.binding >> data.hasNotifySignal;
+ data.type = (QQmlEngineDebugService::QQmlObjectProperty::Type)type;
+ return ds;
+}
+
+static inline bool isSignalPropertyName(const QString &signalName)
+{
+ // see QmlCompiler::isSignalPropertyName
+ return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) &&
+ signalName.at(2).isLetter() && signalName.at(2).isUpper();
+}
+
+static bool hasValidSignal(QObject *object, const QString &propertyName)
+{
+ if (!isSignalPropertyName(propertyName))
+ return false;
+
+ QString signalName = propertyName.mid(2);
+ signalName[0] = signalName.at(0).toLower();
+
+ int sigIdx = QQmlPropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex();
+
+ if (sigIdx == -1)
+ return false;
+
+ return true;
+}
+
+QQmlEngineDebugService::QQmlObjectProperty
+QQmlEngineDebugService::propertyData(QObject *obj, int propIdx)
+{
+ QQmlObjectProperty rv;
+
+ QMetaProperty prop = obj->metaObject()->property(propIdx);
+
+ rv.type = QQmlObjectProperty::Unknown;
+ rv.valueTypeName = QString::fromUtf8(prop.typeName());
+ rv.name = QString::fromUtf8(prop.name());
+ rv.hasNotifySignal = prop.hasNotifySignal();
+ QQmlAbstractBinding *binding =
+ QQmlPropertyPrivate::binding(QQmlProperty(obj, rv.name));
+ if (binding)
+ rv.binding = binding->expression();
+
+ if (QQmlValueTypeFactory::isValueType(prop.userType())) {
+ rv.type = QQmlObjectProperty::Basic;
+ } else if (QQmlMetaType::isQObject(prop.userType())) {
+ rv.type = QQmlObjectProperty::Object;
+ } else if (QQmlMetaType::isList(prop.userType())) {
+ rv.type = QQmlObjectProperty::List;
+ }
+
+ QVariant value;
+ if (rv.type != QQmlObjectProperty::Unknown && prop.userType() != 0) {
+ value = prop.read(obj);
+ }
+ rv.value = valueContents(value);
+
+ return rv;
+}
+
+QVariant QQmlEngineDebugService::valueContents(const QVariant &value) const
+{
+ int userType = value.userType();
+
+ //QObject * is not streamable.
+ //Convert all such instances to a String value
+
+ if (value.type() == QVariant::List) {
+ QVariantList contents;
+ QVariantList list = value.toList();
+ int count = list.size();
+ for (int i = 0; i < count; i++)
+ contents << valueContents(list.at(i));
+ return contents;
+ }
+
+ if (value.type() == QVariant::Map) {
+ QVariantMap contents;
+ QMapIterator<QString, QVariant> i(value.toMap());
+ while (i.hasNext()) {
+ i.next();
+ contents.insert(i.key(), valueContents(i.value()));
+ }
+ return contents;
+ }
+
+ if (QQmlValueTypeFactory::isValueType(userType))
+ return value;
+
+ if (QQmlMetaType::isQObject(userType)) {
+ QObject *o = QQmlMetaType::toQObject(value);
+ if (o) {
+ QString name = o->objectName();
+ if (name.isEmpty())
+ name = QLatin1String("<unnamed object>");
+ return name;
+ }
+ }
+
+ return QLatin1String("<unknown value>");
+}
+
+void QQmlEngineDebugService::buildObjectDump(QDataStream &message,
+ QObject *object, bool recur, bool dumpProperties)
+{
+ message << objectData(object);
+
+ QObjectList children = object->children();
+
+ int childrenCount = children.count();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ if (qobject_cast<QQmlContext*>(children[ii]) || QQmlBoundSignal::cast(children[ii]))
+ --childrenCount;
+ }
+
+ message << childrenCount << recur;
+
+ QList<QQmlObjectProperty> fakeProperties;
+
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+ if (qobject_cast<QQmlContext*>(child))
+ continue;
+ QQmlBoundSignal *signal = QQmlBoundSignal::cast(child);
+ if (signal) {
+ if (!dumpProperties)
+ continue;
+ QQmlObjectProperty prop;
+ prop.type = QQmlObjectProperty::SignalProperty;
+ prop.hasNotifySignal = false;
+ QQmlExpression *expr = signal->expression();
+ if (expr) {
+ prop.value = expr->expression();
+ QObject *scope = expr->scopeObject();
+ if (scope) {
+ QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature());
+ int lparen = sig.indexOf(QLatin1Char('('));
+ if (lparen >= 0) {
+ QString methodName = sig.mid(0, lparen);
+ prop.name = QLatin1String("on") + methodName[0].toUpper()
+ + methodName.mid(1);
+ }
+ }
+ }
+ fakeProperties << prop;
+ } else {
+ if (recur)
+ buildObjectDump(message, child, recur, dumpProperties);
+ else
+ message << objectData(child);
+ }
+ }
+
+ if (!dumpProperties) {
+ message << 0;
+ return;
+ }
+
+ QList<int> propertyIndexes;
+ for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) {
+ if (object->metaObject()->property(ii).isScriptable())
+ propertyIndexes << ii;
+ }
+
+ message << propertyIndexes.size() + fakeProperties.count();
+
+ for (int ii = 0; ii < propertyIndexes.size(); ++ii)
+ message << propertyData(object, propertyIndexes.at(ii));
+
+ for (int ii = 0; ii < fakeProperties.count(); ++ii)
+ message << fakeProperties[ii];
+}
+
+void QQmlEngineDebugService::prepareDeferredObjects(QObject *obj)
+{
+ qmlExecuteDeferred(obj);
+
+ QObjectList children = obj->children();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+ prepareDeferredObjects(child);
+ }
+
+}
+
+void QQmlEngineDebugService::buildObjectList(QDataStream &message, QQmlContext *ctxt)
+{
+ QQmlContextData *p = QQmlContextData::get(ctxt);
+
+ QString ctxtName = ctxt->objectName();
+ int ctxtId = QQmlDebugService::idForObject(ctxt);
+
+ message << ctxtName << ctxtId;
+
+ int count = 0;
+
+ QQmlContextData *child = p->childContexts;
+ while (child) {
+ ++count;
+ child = child->nextChild;
+ }
+
+ message << count;
+
+ child = p->childContexts;
+ while (child) {
+ buildObjectList(message, child->asQQmlContext());
+ child = child->nextChild;
+ }
+
+ // Clean deleted objects
+ QQmlContextPrivate *ctxtPriv = QQmlContextPrivate::get(ctxt);
+ for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
+ if (!ctxtPriv->instances.at(ii)) {
+ ctxtPriv->instances.removeAt(ii);
+ --ii;
+ }
+ }
+
+ message << ctxtPriv->instances.count();
+ for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
+ message << objectData(ctxtPriv->instances.at(ii));
+ }
+}
+
+void QQmlEngineDebugService::buildStatesList(QQmlContext *ctxt, bool cleanList)
+{
+ if (m_statesDelegate)
+ m_statesDelegate->buildStatesList(ctxt, cleanList);
+}
+
+QQmlEngineDebugService::QQmlObjectData
+QQmlEngineDebugService::objectData(QObject *object)
+{
+ QQmlData *ddata = QQmlData::get(object);
+ QQmlObjectData rv;
+ if (ddata && ddata->outerContext) {
+ rv.url = ddata->outerContext->url;
+ rv.lineNumber = ddata->lineNumber;
+ rv.columnNumber = ddata->columnNumber;
+ } else {
+ rv.lineNumber = -1;
+ rv.columnNumber = -1;
+ }
+
+ QQmlContext *context = qmlContext(object);
+ if (context) {
+ QQmlContextData *cdata = QQmlContextData::get(context);
+ if (cdata)
+ rv.idString = cdata->findObjectId(object);
+ }
+
+ rv.objectName = object->objectName();
+ rv.objectId = QQmlDebugService::idForObject(object);
+ rv.contextId = QQmlDebugService::idForObject(qmlContext(object));
+
+ QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
+ if (type) {
+ QString typeName = type->qmlTypeName();
+ int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
+ rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1);
+ } else {
+ rv.objectType = QString::fromUtf8(object->metaObject()->className());
+ int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_"));
+ if (marker != -1)
+ rv.objectType = rv.objectType.left(marker);
+ }
+
+ return rv;
+}
+
+void QQmlEngineDebugService::messageReceived(const QByteArray &message)
+{
+ QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message));
+}
+
+void QQmlEngineDebugService::processMessage(const QByteArray &message)
+{
+ QDataStream ds(message);
+
+ QByteArray type;
+ ds >> type;
+
+ if (type == "LIST_ENGINES") {
+ int queryId;
+ ds >> queryId;
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("LIST_ENGINES_R");
+ rs << queryId << m_engines.count();
+
+ for (int ii = 0; ii < m_engines.count(); ++ii) {
+ QQmlEngine *engine = m_engines.at(ii);
+
+ QString engineName = engine->objectName();
+ int engineId = QQmlDebugService::idForObject(engine);
+
+ rs << engineName << engineId;
+ }
+
+ sendMessage(reply);
+ } else if (type == "LIST_OBJECTS") {
+ int queryId;
+ int engineId = -1;
+ ds >> queryId >> engineId;
+
+ QQmlEngine *engine =
+ qobject_cast<QQmlEngine *>(QQmlDebugService::objectForId(engineId));
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("LIST_OBJECTS_R") << queryId;
+
+ if (engine) {
+ buildObjectList(rs, engine->rootContext());
+ buildStatesList(engine->rootContext(), true);
+ }
+
+ sendMessage(reply);
+ } else if (type == "FETCH_OBJECT") {
+ int queryId;
+ int objectId;
+ bool recurse;
+ bool dumpProperties = true;
+
+ ds >> queryId >> objectId >> recurse >> dumpProperties;
+
+ QObject *object = QQmlDebugService::objectForId(objectId);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("FETCH_OBJECT_R") << queryId;
+
+ if (object) {
+ if (recurse)
+ prepareDeferredObjects(object);
+ buildObjectDump(rs, object, recurse, dumpProperties);
+ }
+
+ sendMessage(reply);
+ } else if (type == "WATCH_OBJECT") {
+ int queryId;
+ int objectId;
+
+ ds >> queryId >> objectId;
+ bool ok = m_watch->addWatch(queryId, objectId);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("WATCH_OBJECT_R") << queryId << ok;
+
+ sendMessage(reply);
+ } else if (type == "WATCH_PROPERTY") {
+ int queryId;
+ int objectId;
+ QByteArray property;
+
+ ds >> queryId >> objectId >> property;
+ bool ok = m_watch->addWatch(queryId, objectId, property);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok;
+
+ sendMessage(reply);
+ } else if (type == "WATCH_EXPR_OBJECT") {
+ int queryId;
+ int debugId;
+ QString expr;
+
+ ds >> queryId >> debugId >> expr;
+ bool ok = m_watch->addWatch(queryId, debugId, expr);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok;
+ sendMessage(reply);
+ } else if (type == "NO_WATCH") {
+ int queryId;
+
+ ds >> queryId;
+ m_watch->removeWatch(queryId);
+ } else if (type == "EVAL_EXPRESSION") {
+ int queryId;
+ int objectId;
+ QString expr;
+
+ ds >> queryId >> objectId >> expr;
+
+ QObject *object = QQmlDebugService::objectForId(objectId);
+ QQmlContext *context = qmlContext(object);
+ QVariant result;
+ if (object && context) {
+ QQmlExpression exprObj(context, object, expr);
+ bool undefined = false;
+ QVariant value = exprObj.evaluate(&undefined);
+ if (undefined)
+ result = QLatin1String("<undefined>");
+ else
+ result = valueContents(value);
+ } else {
+ result = QLatin1String("<unknown context>");
+ }
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result;
+
+ sendMessage(reply);
+ } else if (type == "SET_BINDING") {
+ int objectId;
+ QString propertyName;
+ QVariant expr;
+ bool isLiteralValue;
+ QString filename;
+ int line;
+ ds >> objectId >> propertyName >> expr >> isLiteralValue;
+ if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2
+ ds >> filename >> line;
+ }
+ setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
+ } else if (type == "RESET_BINDING") {
+ int objectId;
+ QString propertyName;
+ ds >> objectId >> propertyName;
+ resetBinding(objectId, propertyName);
+ } else if (type == "SET_METHOD_BODY") {
+ int objectId;
+ QString methodName;
+ QString methodBody;
+ ds >> objectId >> methodName >> methodBody;
+ setMethodBody(objectId, methodName, methodBody);
+ }
+}
+
+void QQmlEngineDebugService::setBinding(int objectId,
+ const QString &propertyName,
+ const QVariant &expression,
+ bool isLiteralValue,
+ QString filename,
+ int line,
+ int column)
+{
+ QObject *object = objectForId(objectId);
+ QQmlContext *context = qmlContext(object);
+
+ if (object && context) {
+ QQmlProperty property(object, propertyName, context);
+ if (property.isValid()) {
+
+ bool inBaseState = true;
+ if (m_statesDelegate) {
+ m_statesDelegate->updateBinding(context, property, expression, isLiteralValue,
+ filename, line, column, &inBaseState);
+ }
+
+ if (inBaseState) {
+ if (isLiteralValue) {
+ property.write(expression);
+ } else if (hasValidSignal(object, propertyName)) {
+ QQmlExpression *qmlExpression = new QQmlExpression(context, object, expression.toString());
+ QQmlPropertyPrivate::setSignalExpression(property, qmlExpression);
+ qmlExpression->setSourceLocation(filename, line, column);
+ } else if (property.isProperty()) {
+ QQmlBinding *binding = new QQmlBinding(expression.toString(), object, context);
+ binding->setTarget(property);
+ binding->setSourceLocation(filename, line, column);
+ binding->setNotifyOnValueChanged(true);
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::setBinding(property, binding);
+ if (oldBinding)
+ oldBinding->destroy();
+ binding->update();
+ } else {
+ qWarning() << "QQmlEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
+ }
+ }
+
+ } else {
+ // not a valid property
+ bool ok = false;
+ if (m_statesDelegate)
+ ok = m_statesDelegate->setBindingForInvalidProperty(object, propertyName, expression, isLiteralValue);
+ if (!ok)
+ qWarning() << "QQmlEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
+ }
+ }
+}
+
+void QQmlEngineDebugService::resetBinding(int objectId, const QString &propertyName)
+{
+ QObject *object = objectForId(objectId);
+ QQmlContext *context = qmlContext(object);
+
+ if (object && context) {
+ if (object->property(propertyName.toLatin1()).isValid()) {
+ QQmlProperty property(object, propertyName);
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(property);
+ if (oldBinding) {
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::setBinding(property, 0);
+ if (oldBinding)
+ oldBinding->destroy();
+ }
+ if (property.isResettable()) {
+ // Note: this will reset the property in any case, without regard to states
+ // Right now almost no QQuickItem has reset methods for its properties (with the
+ // notable exception of QQuickAnchors), so this is not a big issue
+ // later on, setBinding does take states into account
+ property.reset();
+ } else {
+ // overwrite with default value
+ if (QQmlType *objType = QQmlMetaType::qmlType(object->metaObject())) {
+ if (QObject *emptyObject = objType->create()) {
+ if (emptyObject->property(propertyName.toLatin1()).isValid()) {
+ QVariant defaultValue = QQmlProperty(emptyObject, propertyName).read();
+ if (defaultValue.isValid()) {
+ setBinding(objectId, propertyName, defaultValue, true);
+ }
+ }
+ delete emptyObject;
+ }
+ }
+ }
+ } else if (hasValidSignal(object, propertyName)) {
+ QQmlProperty property(object, propertyName, context);
+ QQmlPropertyPrivate::setSignalExpression(property, 0);
+ } else {
+ if (m_statesDelegate)
+ m_statesDelegate->resetBindingForInvalidProperty(object, propertyName);
+ }
+ }
+}
+
+void QQmlEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body)
+{
+ QObject *object = objectForId(objectId);
+ QQmlContext *context = qmlContext(object);
+ if (!object || !context || !context->engine())
+ return;
+ QQmlContextData *contextData = QQmlContextData::get(context);
+ if (!contextData)
+ return;
+
+ QQmlPropertyData dummy;
+ QQmlPropertyData *prop =
+ QQmlPropertyCache::property(context->engine(), object, method, dummy);
+
+ if (!prop || !prop->isVMEFunction())
+ return;
+
+ QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex);
+ QList<QByteArray> paramNames = metaMethod.parameterNames();
+
+ QString paramStr;
+ for (int ii = 0; ii < paramNames.count(); ++ii) {
+ if (ii != 0) paramStr.append(QLatin1String(","));
+ paramStr.append(QString::fromUtf8(paramNames.at(ii)));
+ }
+
+ QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr +
+ QLatin1String(") {");
+ jsfunction += body;
+ jsfunction += QLatin1String("\n})");
+
+ QQmlVMEMetaObject *vmeMetaObject =
+ static_cast<QQmlVMEMetaObject*>(QObjectPrivate::get(object)->metaObject);
+ Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this
+
+ int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
+ vmeMetaObject->setVmeMethod(prop->coreIndex, QQmlExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
+}
+
+void QQmlEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+
+ rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value);
+
+ sendMessage(reply);
+}
+
+void QQmlEngineDebugService::addEngine(QQmlEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(!m_engines.contains(engine));
+
+ m_engines.append(engine);
+}
+
+void QQmlEngineDebugService::remEngine(QQmlEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(m_engines.contains(engine));
+
+ m_engines.removeAll(engine);
+}
+
+void QQmlEngineDebugService::objectCreated(QQmlEngine *engine, QObject *object)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(m_engines.contains(engine));
+
+ int engineId = QQmlDebugService::idForObject(engine);
+ int objectId = QQmlDebugService::idForObject(object);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+
+ rs << QByteArray("OBJECT_CREATED") << engineId << objectId;
+ sendMessage(reply);
+}
+
+void QQmlEngineDebugService::setStatesDelegate(QQmlDebugStatesDelegate *delegate)
+{
+ m_statesDelegate = delegate;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmlenginedebugservice_p.h b/src/qml/debugger/qqmlenginedebugservice_p.h
new file mode 100644
index 0000000000..1a92801fcc
--- /dev/null
+++ b/src/qml/debugger/qqmlenginedebugservice_p.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLENGINEDEBUGSERVICE_P_H
+#define QQMLENGINEDEBUGSERVICE_P_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 <private/qqmldebugservice_p.h>
+
+#include <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+class QQmlContext;
+class QQmlWatcher;
+class QDataStream;
+class QQmlDebugStatesDelegate;
+
+class Q_QML_PRIVATE_EXPORT QQmlEngineDebugService : public QQmlDebugService
+{
+ Q_OBJECT
+public:
+ QQmlEngineDebugService(QObject * = 0);
+ ~QQmlEngineDebugService();
+
+ struct QQmlObjectData {
+ QUrl url;
+ int lineNumber;
+ int columnNumber;
+ QString idString;
+ QString objectName;
+ QString objectType;
+ int objectId;
+ int contextId;
+ };
+
+ struct QQmlObjectProperty {
+ enum Type { Unknown, Basic, Object, List, SignalProperty };
+ Type type;
+ QString name;
+ QVariant value;
+ QString valueTypeName;
+ QString binding;
+ bool hasNotifySignal;
+ };
+
+ void addEngine(QQmlEngine *);
+ void remEngine(QQmlEngine *);
+ void objectCreated(QQmlEngine *, QObject *);
+
+ void setStatesDelegate(QQmlDebugStatesDelegate *);
+
+ static QQmlEngineDebugService *instance();
+
+protected:
+ virtual void messageReceived(const QByteArray &);
+
+private Q_SLOTS:
+ void processMessage(const QByteArray &msg);
+ void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
+
+private:
+ void prepareDeferredObjects(QObject *);
+ void buildObjectList(QDataStream &, QQmlContext *);
+ void buildObjectDump(QDataStream &, QObject *, bool, bool);
+ void buildStatesList(QQmlContext *, bool);
+ QQmlObjectData objectData(QObject *);
+ QQmlObjectProperty propertyData(QObject *, int);
+ QVariant valueContents(const QVariant &defaultValue) const;
+ void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1, int column = 0);
+ void resetBinding(int objectId, const QString &propertyName);
+ void setMethodBody(int objectId, const QString &method, const QString &body);
+
+ QList<QQmlEngine *> m_engines;
+ QQmlWatcher *m_watch;
+ QQmlDebugStatesDelegate *m_statesDelegate;
+};
+Q_QML_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QQmlEngineDebugService::QQmlObjectData &);
+Q_QML_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QQmlEngineDebugService::QQmlObjectData &);
+Q_QML_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QQmlEngineDebugService::QQmlObjectProperty &);
+Q_QML_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QQmlEngineDebugService::QQmlObjectProperty &);
+
+QT_END_NAMESPACE
+
+#endif // QQMLENGINEDEBUGSERVICE_P_H
+
diff --git a/src/qml/debugger/qqmlinspectorinterface_p.h b/src/qml/debugger/qqmlinspectorinterface_p.h
new file mode 100644
index 0000000000..5b015d36df
--- /dev/null
+++ b/src/qml/debugger/qqmlinspectorinterface_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLINSPECTORINTERFACE_H
+#define QQMLINSPECTORINTERFACE_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 <QtQml/qtqmlglobal.h>
+#include <private/qqmlglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class Q_QML_EXPORT QQmlInspectorInterface
+{
+public:
+ QQmlInspectorInterface() {}
+ virtual ~QQmlInspectorInterface() {}
+
+ virtual bool canHandleView(QObject *view) = 0;
+
+ virtual void activate(QObject *view) = 0;
+ virtual void deactivate() = 0;
+
+ virtual void clientMessage(const QByteArray &message) = 0;
+};
+
+#define QQmlInspectorInterface_iid "org.qt-project.Qt.QQmlInspectorInterface"
+
+Q_DECLARE_INTERFACE(QQmlInspectorInterface, QQmlInspectorInterface_iid)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLINSPECTORINTERFACE_H
diff --git a/src/qml/debugger/qqmlinspectorservice.cpp b/src/qml/debugger/qqmlinspectorservice.cpp
new file mode 100644
index 0000000000..508d12eefa
--- /dev/null
+++ b/src/qml/debugger/qqmlinspectorservice.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlinspectorservice_p.h"
+#include "qqmlinspectorinterface_p.h"
+#include "qqmldebugserver_p.h"
+
+#include <private/qqmlglobal_p.h>
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QPluginLoader>
+
+// print detailed information about loading of plugins
+DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE)
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QQmlInspectorService, serviceInstance)
+
+QQmlInspectorService::QQmlInspectorService()
+ : QQmlDebugService(QLatin1String("QQmlObserverMode"), 1)
+ , m_currentInspectorPlugin(0)
+{
+ registerService();
+}
+
+QQmlInspectorService *QQmlInspectorService::instance()
+{
+ return serviceInstance();
+}
+
+void QQmlInspectorService::addView(QObject *view)
+{
+ m_views.append(view);
+ updateState();
+}
+
+void QQmlInspectorService::removeView(QObject *view)
+{
+ m_views.removeAll(view);
+ updateState();
+}
+
+void QQmlInspectorService::sendMessage(const QByteArray &message)
+{
+ if (state() != Enabled)
+ return;
+
+ QQmlDebugService::sendMessage(message);
+}
+
+void QQmlInspectorService::stateChanged(State /*state*/)
+{
+ QMetaObject::invokeMethod(this, "updateState", Qt::QueuedConnection);
+}
+
+void QQmlInspectorService::updateState()
+{
+ if (m_views.isEmpty()) {
+ if (m_currentInspectorPlugin) {
+ m_currentInspectorPlugin->deactivate();
+ m_currentInspectorPlugin = 0;
+ }
+ return;
+ }
+
+ if (state() == Enabled) {
+ if (m_inspectorPlugins.isEmpty())
+ loadInspectorPlugins();
+
+ if (m_inspectorPlugins.isEmpty()) {
+ qWarning() << "QQmlInspector: No plugins found.";
+ QQmlDebugServer::instance()->removeService(this);
+ return;
+ }
+
+ foreach (QQmlInspectorInterface *inspector, m_inspectorPlugins) {
+ if (inspector->canHandleView(m_views.first())) {
+ m_currentInspectorPlugin = inspector;
+ break;
+ }
+ }
+
+ if (!m_currentInspectorPlugin) {
+ qWarning() << "QQmlInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'.";
+ return;
+ }
+ m_currentInspectorPlugin->activate(m_views.first());
+ } else {
+ if (m_currentInspectorPlugin) {
+ m_currentInspectorPlugin->deactivate();
+ m_currentInspectorPlugin = 0;
+ }
+ }
+}
+
+void QQmlInspectorService::messageReceived(const QByteArray &message)
+{
+ QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message));
+}
+
+void QQmlInspectorService::processMessage(const QByteArray &message)
+{
+ if (m_currentInspectorPlugin)
+ m_currentInspectorPlugin->clientMessage(message);
+}
+
+void QQmlInspectorService::loadInspectorPlugins()
+{
+ QStringList pluginCandidates;
+ const QStringList paths = QCoreApplication::libraryPaths();
+ foreach (const QString &libPath, paths) {
+ const QDir dir(libPath + QLatin1String("/qmltooling"));
+ if (dir.exists())
+ foreach (const QString &pluginPath, dir.entryList(QDir::Files))
+ pluginCandidates << dir.absoluteFilePath(pluginPath);
+ }
+
+ foreach (const QString &pluginPath, pluginCandidates) {
+ if (qmlDebugVerbose())
+ qDebug() << "QQmlInspector: Trying to load plugin " << pluginPath << "...";
+
+ QPluginLoader loader(pluginPath);
+ if (!loader.load()) {
+ if (qmlDebugVerbose())
+ qDebug() << "QQmlInspector: Error while loading: " << loader.errorString();
+
+ continue;
+ }
+
+ QQmlInspectorInterface *inspector =
+ qobject_cast<QQmlInspectorInterface*>(loader.instance());
+ if (inspector) {
+ if (qmlDebugVerbose())
+ qDebug() << "QQmlInspector: Plugin successfully loaded.";
+ m_inspectorPlugins << inspector;
+ } else {
+ if (qmlDebugVerbose())
+ qDebug() << "QQmlInspector: Plugin does not implement interface QQmlInspectorInterface.";
+
+ loader.unload();
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmlinspectorservice_p.h b/src/qml/debugger/qqmlinspectorservice_p.h
new file mode 100644
index 0000000000..557dc38aa8
--- /dev/null
+++ b/src/qml/debugger/qqmlinspectorservice_p.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLINSPECTORSERVICE_H
+#define QQMLINSPECTORSERVICE_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 "qqmldebugservice_p.h"
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/QList>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlInspectorInterface;
+
+class Q_QML_EXPORT QQmlInspectorService : public QQmlDebugService
+{
+ Q_OBJECT
+
+public:
+ QQmlInspectorService();
+ static QQmlInspectorService *instance();
+
+ void addView(QObject *);
+ void removeView(QObject *);
+
+ void sendMessage(const QByteArray &message);
+
+protected:
+ virtual void stateChanged(State state);
+ virtual void messageReceived(const QByteArray &);
+
+private slots:
+ void processMessage(const QByteArray &message);
+ void updateState();
+
+private:
+ void loadInspectorPlugins();
+
+ QList<QObject*> m_views;
+ QQmlInspectorInterface *m_currentInspectorPlugin;
+ QList<QQmlInspectorInterface*> m_inspectorPlugins;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLINSPECTORSERVICE_H
diff --git a/src/qml/debugger/qqmlprofilerservice.cpp b/src/qml/debugger/qqmlprofilerservice.cpp
new file mode 100644
index 0000000000..2731d2046b
--- /dev/null
+++ b/src/qml/debugger/qqmlprofilerservice.cpp
@@ -0,0 +1,315 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlprofilerservice_p.h"
+
+#include <QtCore/qdatastream.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qcoreapplication.h>
+
+// this contains QUnifiedTimer
+#include <private/qabstractanimation_p.h>
+
+QT_BEGIN_NAMESPACE
+
+// instance will be set, unset in constructor. Allows static methods to be inlined.
+QQmlProfilerService *QQmlProfilerService::instance = 0;
+Q_GLOBAL_STATIC(QQmlProfilerService, profilerInstance)
+
+
+// convert to a QByteArray that can be sent to the debug client
+// use of QDataStream can skew results
+// (see tst_qqmldebugtrace::trace() benchmark)
+QByteArray QQmlProfilerData::toByteArray() const
+{
+ QByteArray data;
+ //### using QDataStream is relatively expensive
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << time << messageType << detailType;
+ if (messageType == (int)QQmlProfilerService::RangeData)
+ ds << detailData;
+ if (messageType == (int)QQmlProfilerService::RangeLocation)
+ ds << detailData << line << column;
+ if (messageType == (int)QQmlProfilerService::Event &&
+ detailType == (int)QQmlProfilerService::AnimationFrame)
+ ds << framerate << animationcount;
+ return data;
+}
+
+QQmlProfilerService::QQmlProfilerService()
+ : QQmlDebugService(QLatin1String("CanvasFrameRate"), 1),
+ m_enabled(false), m_messageReceived(false)
+{
+ m_timer.start();
+
+ if (registerService() == Enabled) {
+ // wait for first message indicating whether to trace or not
+ while (!m_messageReceived)
+ waitForMessage();
+
+ QUnifiedTimer::instance()->registerProfilerCallback( &animationFrame );
+ }
+}
+
+QQmlProfilerService::~QQmlProfilerService()
+{
+ instance = 0;
+}
+
+void QQmlProfilerService::initialize()
+{
+ // just make sure that the service is properly registered
+ instance = profilerInstance();
+}
+
+bool QQmlProfilerService::startProfiling()
+{
+ return profilerInstance()->startProfilingImpl();
+}
+
+bool QQmlProfilerService::stopProfiling()
+{
+ return profilerInstance()->stopProfilingImpl();
+}
+
+void QQmlProfilerService::sendStartedProfilingMessage()
+{
+ profilerInstance()->sendStartedProfilingMessageImpl();
+}
+
+void QQmlProfilerService::addEvent(EventType t)
+{
+ profilerInstance()->addEventImpl(t);
+}
+
+void QQmlProfilerService::animationFrame(qint64 delta)
+{
+ profilerInstance()->animationFrameImpl(delta);
+}
+
+void QQmlProfilerService::sendProfilingData()
+{
+ profilerInstance()->sendMessages();
+}
+
+bool QQmlProfilerService::startProfilingImpl()
+{
+ bool success = false;
+ if (!profilingEnabled()) {
+ setProfilingEnabled(true);
+ sendStartedProfilingMessageImpl();
+ success = true;
+ }
+ return success;
+}
+
+bool QQmlProfilerService::stopProfilingImpl()
+{
+ bool success = false;
+ if (profilingEnabled()) {
+ addEventImpl(EndTrace);
+ setProfilingEnabled(false);
+ success = true;
+ }
+ return success;
+}
+
+void QQmlProfilerService::sendStartedProfilingMessageImpl()
+{
+ if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
+ return;
+
+ QQmlProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)StartTrace, QString(), -1, -1, 0, 0};
+ QQmlDebugService::sendMessage(ed.toByteArray());
+}
+
+void QQmlProfilerService::addEventImpl(EventType event)
+{
+ if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
+ return;
+
+ QQmlProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)event, QString(), -1, -1, 0, 0};
+ processMessage(ed);
+}
+
+void QQmlProfilerService::startRange(RangeType range)
+{
+ if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
+ return;
+
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeStart, (int)range, QString(), -1, -1, 0, 0};
+ processMessage(rd);
+}
+
+void QQmlProfilerService::rangeData(RangeType range, const QString &rData)
+{
+ if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
+ return;
+
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData, -1, -1, 0, 0};
+ processMessage(rd);
+}
+
+void QQmlProfilerService::rangeData(RangeType range, const QUrl &rData)
+{
+ if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
+ return;
+
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData.toString(QUrl::FormattingOption(0x100)), -1, -1, 0, 0};
+ processMessage(rd);
+}
+
+void QQmlProfilerService::rangeLocation(RangeType range, const QString &fileName, int line, int column)
+{
+ if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
+ return;
+
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName, line, column, 0, 0};
+ processMessage(rd);
+}
+
+void QQmlProfilerService::rangeLocation(RangeType range, const QUrl &fileName, int line, int column)
+{
+ if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
+ return;
+
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName.toString(QUrl::FormattingOption(0x100)), line, column, 0, 0};
+ processMessage(rd);
+}
+
+void QQmlProfilerService::endRange(RangeType range)
+{
+ if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
+ return;
+
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeEnd, (int)range, QString(), -1, -1, 0, 0};
+ processMessage(rd);
+}
+
+void QQmlProfilerService::animationFrameImpl(qint64 delta)
+{
+ Q_ASSERT(QQmlDebugService::isDebuggingEnabled());
+ if (!m_enabled)
+ return;
+
+ int animCount = QUnifiedTimer::instance()->runningAnimationCount();
+
+ if (animCount > 0 && delta > 0) {
+ // trim fps to integer
+ int fps = 1000 / delta;
+ QQmlProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)AnimationFrame, QString(), -1, -1, fps, animCount};
+ processMessage(ed);
+ }
+}
+
+/*
+ Either send the message directly, or queue up
+ a list of messages to send later (via sendMessages)
+*/
+void QQmlProfilerService::processMessage(const QQmlProfilerData &message)
+{
+ QMutexLocker locker(&m_mutex);
+ m_data.append(message);
+}
+
+bool QQmlProfilerService::profilingEnabled()
+{
+ return m_enabled;
+}
+
+void QQmlProfilerService::setProfilingEnabled(bool enable)
+{
+ m_enabled = enable;
+}
+
+/*
+ Send the messages queued up by processMessage
+*/
+void QQmlProfilerService::sendMessages()
+{
+ QMutexLocker locker(&m_mutex);
+ QList<QByteArray> messages;
+ for (int i = 0; i < m_data.count(); ++i)
+ messages << m_data.at(i).toByteArray();
+ m_data.clear();
+
+ //indicate completion
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (qint64)-1 << (int)Complete;
+ messages << data;
+
+ QQmlDebugService::sendMessages(messages);
+}
+
+void QQmlProfilerService::stateAboutToBeChanged(QQmlDebugService::State newState)
+{
+ if (state() == newState)
+ return;
+
+ if (state() == Enabled
+ && m_enabled) {
+ stopProfilingImpl();
+ sendMessages();
+ }
+}
+
+void QQmlProfilerService::messageReceived(const QByteArray &message)
+{
+ QByteArray rwData = message;
+ QDataStream stream(&rwData, QIODevice::ReadOnly);
+
+ bool enabled;
+ stream >> enabled;
+
+ m_messageReceived = true;
+
+ if (enabled) {
+ startProfilingImpl();
+ } else {
+ if (stopProfilingImpl())
+ sendMessages();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h
new file mode 100644
index 0000000000..7a708456ba
--- /dev/null
+++ b/src/qml/debugger/qqmlprofilerservice_p.h
@@ -0,0 +1,303 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROFILERSERVICE_P_H
+#define QQMLPROFILERSERVICE_P_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 <private/qqmldebugservice_p.h>
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qelapsedtimer.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qstringbuilder.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+struct Q_AUTOTEST_EXPORT QQmlProfilerData
+{
+ qint64 time;
+ int messageType;
+ int detailType;
+
+ //###
+ QString detailData; //used by RangeData and RangeLocation
+ int line; //used by RangeLocation
+ int column; //used by RangeLocation
+ int framerate; //used by animation events
+ int animationcount; //used by animation events
+
+ QByteArray toByteArray() const;
+};
+
+Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_MOVABLE_TYPE);
+
+class QUrl;
+class QQmlEngine;
+
+
+class Q_QML_EXPORT QQmlProfilerService : public QQmlDebugService
+{
+public:
+ enum Message {
+ Event,
+ RangeStart,
+ RangeData,
+ RangeLocation,
+ RangeEnd,
+ Complete, // end of transmission
+
+ MaximumMessage
+ };
+
+ enum EventType {
+ FramePaint,
+ Mouse,
+ Key,
+ AnimationFrame,
+ EndTrace,
+ StartTrace,
+
+ MaximumEventType
+ };
+
+ enum RangeType {
+ Painting,
+ Compiling,
+ Creating,
+ Binding, //running a binding
+ HandlingSignal, //running a signal handler
+
+ MaximumRangeType
+ };
+
+ static void initialize();
+
+ static bool startProfiling();
+ static bool stopProfiling();
+ static void sendStartedProfilingMessage();
+ static void addEvent(EventType);
+ static void animationFrame(qint64);
+
+ static void sendProfilingData();
+
+ QQmlProfilerService();
+ ~QQmlProfilerService();
+
+protected:
+ virtual void stateAboutToBeChanged(State state);
+ virtual void messageReceived(const QByteArray &);
+
+private:
+ bool startProfilingImpl();
+ bool stopProfilingImpl();
+ void sendStartedProfilingMessageImpl();
+ void addEventImpl(EventType);
+ void animationFrameImpl(qint64);
+
+ void startRange(RangeType);
+ void rangeData(RangeType, const QString &);
+ void rangeData(RangeType, const QUrl &);
+ void rangeLocation(RangeType, const QString &, int, int);
+ void rangeLocation(RangeType, const QUrl &, int, int);
+ void endRange(RangeType);
+
+
+ bool profilingEnabled();
+ void setProfilingEnabled(bool enable);
+ void sendMessages();
+ void processMessage(const QQmlProfilerData &);
+
+private:
+ QElapsedTimer m_timer;
+ bool m_enabled;
+ bool m_messageReceived;
+ QVector<QQmlProfilerData> m_data;
+ QMutex m_mutex;
+
+ static QQmlProfilerService *instance;
+
+ friend struct QQmlBindingProfiler;
+ friend struct QQmlHandlingSignalProfiler;
+ friend struct QQmlObjectCreatingProfiler;
+ friend struct QQmlCompilingProfiler;
+};
+
+//
+// RAII helper structs
+//
+
+struct QQmlBindingProfiler {
+ QQmlBindingProfiler(const QString &url, int line, int column)
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ? instance->profilingEnabled() : false;
+ if (enabled) {
+ instance->startRange(QQmlProfilerService::Binding);
+ instance->rangeLocation(QQmlProfilerService::Binding, url, line, column);
+ }
+ }
+
+ ~QQmlBindingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Binding);
+ }
+
+ void addDetail(const QString &details)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(QQmlProfilerService::Binding,
+ details);
+ }
+\
+ bool enabled;
+};
+
+struct QQmlHandlingSignalProfiler {
+ QQmlHandlingSignalProfiler()
+ {
+ enabled = QQmlProfilerService::instance
+ ? QQmlProfilerService::instance->profilingEnabled() : false;
+ if (enabled) {
+ QQmlProfilerService::instance->startRange(
+ QQmlProfilerService::HandlingSignal);
+ }
+ }
+
+ void setSignalInfo(const QString &name, const QString &expression)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(
+ QQmlProfilerService::HandlingSignal,
+ name % QLatin1String(": ") % expression);
+ }
+
+ void setLocation(const QString &file, int line, int column)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeLocation(
+ QQmlProfilerService::HandlingSignal, file, line, column);
+ }
+
+ ~QQmlHandlingSignalProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(
+ QQmlProfilerService::HandlingSignal);
+ }
+
+ bool enabled;
+};
+
+struct QQmlObjectCreatingProfiler {
+ QQmlObjectCreatingProfiler()
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ if (enabled)
+ instance->startRange(QQmlProfilerService::Creating);
+ }
+
+ void setTypeName(const QString &typeName)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(
+ QQmlProfilerService::Creating, typeName);
+ }
+
+ void setLocation(const QUrl &url, int line, int column)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeLocation(
+ QQmlProfilerService::Creating, url, line, column);
+ }
+
+ ~QQmlObjectCreatingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating);
+ }
+
+ bool enabled;
+};
+
+struct QQmlCompilingProfiler {
+ QQmlCompilingProfiler(const QString &name)
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ if (enabled) {
+ instance->startRange(QQmlProfilerService::Compiling);
+ instance->rangeLocation(QQmlProfilerService::Compiling, name, 1, 1);
+ instance->rangeData(QQmlProfilerService::Compiling, name);
+ }
+ }
+
+ ~QQmlCompilingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Compiling);
+ }
+
+ bool enabled;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLPROFILERSERVICE_P_H
+
diff --git a/src/qml/debugger/qv8debugservice.cpp b/src/qml/debugger/qv8debugservice.cpp
new file mode 100644
index 0000000000..ee60bff742
--- /dev/null
+++ b/src/qml/debugger/qv8debugservice.cpp
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8debugservice_p.h"
+#include "qqmldebugservice_p_p.h"
+#include <private/qjsconverter_impl_p.h>
+#include <private/qv8engine_p.h>
+
+#include <QtCore/QHash>
+#include <QtCore/QFileInfo>
+#include <QtCore/QMutex>
+
+//V8 DEBUG SERVICE PROTOCOL
+// <HEADER><COMMAND><DATA>
+// <HEADER> : "V8DEBUG"
+// <COMMAND> : ["connect", "disconnect", "interrupt",
+// "v8request", "v8message", "breakonsignal",
+// "breakaftercompile"]
+// <DATA> : connect, disconnect, interrupt: empty
+// v8request, v8message: <JSONrequest_string>
+// breakonsignal: <signalname_string><enabled_bool>
+// breakaftercompile: <enabled_bool>
+
+const char *V8_DEBUGGER_KEY_VERSION = "version";
+const char *V8_DEBUGGER_KEY_CONNECT = "connect";
+const char *V8_DEBUGGER_KEY_INTERRUPT = "interrupt";
+const char *V8_DEBUGGER_KEY_DISCONNECT = "disconnect";
+const char *V8_DEBUGGER_KEY_REQUEST = "v8request";
+const char *V8_DEBUGGER_KEY_V8MESSAGE = "v8message";
+const char *V8_DEBUGGER_KEY_BREAK_ON_SIGNAL = "breakonsignal";
+const char *V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE = "breakaftercompile";
+
+QT_BEGIN_NAMESPACE
+
+struct SignalHandlerData
+{
+ QString functionName;
+ bool enabled;
+};
+
+Q_GLOBAL_STATIC(QV8DebugService, v8ServiceInstance)
+
+// DebugMessageHandler will call back already when the QV8DebugService constructor is
+// running, we therefore need a plain pointer.
+static QV8DebugService *v8ServiceInstancePtr = 0;
+
+void DebugMessageDispatchHandler()
+{
+ QMetaObject::invokeMethod(v8ServiceInstancePtr, "processDebugMessages", Qt::QueuedConnection);
+}
+
+void DebugMessageHandler(const v8::Debug::Message& message)
+{
+ v8::DebugEvent event = message.GetEvent();
+
+ if (event != v8::Break && event != v8::Exception &&
+ event != v8::AfterCompile && event != v8::BeforeCompile)
+ return;
+ v8ServiceInstancePtr->debugMessageHandler(QJSConverter::toString(message.GetJSON()), event);
+}
+
+class QV8DebugServicePrivate : public QQmlDebugServicePrivate
+{
+public:
+ QV8DebugServicePrivate()
+ : connectReceived(false)
+ , breakAfterCompile(false)
+ , engine(0)
+ {
+ }
+
+ void initializeDebuggerThread();
+
+ static QByteArray packMessage(const QString &type, const QString &message = QString());
+
+ bool connectReceived;
+ bool breakAfterCompile;
+ QMutex initializeMutex;
+ QStringList breakOnSignals;
+ const QV8Engine *engine;
+};
+
+QV8DebugService::QV8DebugService(QObject *parent)
+ : QQmlDebugService(*(new QV8DebugServicePrivate()),
+ QLatin1String("V8Debugger"), 2, parent)
+{
+ Q_D(QV8DebugService);
+ v8ServiceInstancePtr = this;
+ // wait for stateChanged() -> initialize()
+ d->initializeMutex.lock();
+ if (registerService() == Enabled) {
+ init();
+ // ,block mode, client attached
+ while (!d->connectReceived) {
+ waitForMessage();
+ }
+ } else {
+ d->initializeMutex.unlock();
+ }
+}
+
+QV8DebugService::~QV8DebugService()
+{
+}
+
+QV8DebugService *QV8DebugService::instance()
+{
+ return v8ServiceInstance();
+}
+
+void QV8DebugService::initialize(const QV8Engine *engine)
+{
+ // just make sure that the service is properly registered
+ v8ServiceInstance()->setEngine(engine);
+}
+
+void QV8DebugService::setEngine(const QV8Engine *engine)
+{
+ Q_D(QV8DebugService);
+
+ d->engine = engine;
+}
+
+void QV8DebugService::debugMessageHandler(const QString &message, const v8::DebugEvent &event)
+{
+ Q_D(QV8DebugService);
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_V8MESSAGE), message));
+ if (event == v8::AfterCompile && d->breakAfterCompile)
+ scheduledDebugBreak(true);
+}
+
+void QV8DebugService::signalEmitted(const QString &signal)
+{
+ //This function is only called by QQmlBoundSignal
+ //only if there is a slot connected to the signal. Hence, there
+ //is no need for additional check.
+ Q_D(QV8DebugService);
+
+ //Parse just the name and remove the class info
+ //Normalize to Lower case.
+ QString signalName = signal.left(signal.indexOf(QLatin1String("("))).toLower();
+
+ foreach (const QString &signal, d->breakOnSignals) {
+ if (signal == signalName) {
+ scheduledDebugBreak(true);
+ break;
+ }
+ }
+}
+
+// executed in the gui thread
+void QV8DebugService::init()
+{
+ Q_D(QV8DebugService);
+ v8::Debug::SetMessageHandler2(DebugMessageHandler);
+ v8::Debug::SetDebugMessageDispatchHandler(DebugMessageDispatchHandler);
+ d->initializeMutex.unlock();
+}
+
+// executed in the gui thread
+void QV8DebugService::scheduledDebugBreak(bool schedule)
+{
+ if (schedule)
+ v8::Debug::DebugBreak();
+ else
+ v8::Debug::CancelDebugBreak();
+}
+
+// executed in the debugger thread
+void QV8DebugService::stateChanged(QQmlDebugService::State newState)
+{
+ Q_D(QV8DebugService);
+ if (newState == Enabled) {
+ // execute in GUI thread
+ d->initializeMutex.lock();
+ QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
+ }
+}
+
+// executed in the debugger thread
+void QV8DebugService::messageReceived(const QByteArray &message)
+{
+ Q_D(QV8DebugService);
+
+ QDataStream ds(message);
+ QByteArray header;
+ ds >> header;
+
+ if (header == "V8DEBUG") {
+ QByteArray command;
+ QByteArray data;
+ ds >> command >> data;
+
+ if (command == V8_DEBUGGER_KEY_CONNECT) {
+ QMutexLocker locker(&d->initializeMutex);
+ d->connectReceived = true;
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_CONNECT)));
+
+ } else if (command == V8_DEBUGGER_KEY_INTERRUPT) {
+ // break has to be executed in gui thread
+ QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, true));
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_INTERRUPT)));
+
+ } else if (command == V8_DEBUGGER_KEY_DISCONNECT) {
+ // cancel break has to be executed in gui thread
+ QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, false));
+ sendDebugMessage(QString::fromUtf8(data));
+
+ } else if (command == V8_DEBUGGER_KEY_REQUEST) {
+ sendDebugMessage(QString::fromUtf8(data));
+
+ } else if (command == V8_DEBUGGER_KEY_BREAK_ON_SIGNAL) {
+ QDataStream rs(data);
+ QByteArray signal;
+ bool enabled;
+ rs >> signal >> enabled;
+ //Normalize to lower case.
+ QString signalName(QString::fromUtf8(signal).toLower());
+ if (enabled)
+ d->breakOnSignals.append(signalName);
+ else
+ d->breakOnSignals.removeOne(signalName);
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_ON_SIGNAL)));
+
+ } else if (command == V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE) {
+ QDataStream rs(data);
+ rs >> d->breakAfterCompile;
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE)));
+
+ }
+ }
+}
+
+void QV8DebugService::sendDebugMessage(const QString &message)
+{
+ v8::Debug::SendCommand(message.utf16(), message.size());
+}
+
+void QV8DebugService::processDebugMessages()
+{
+ Q_D(QV8DebugService);
+ v8::HandleScope handleScope;
+ v8::Context::Scope contextScope(d->engine->context());
+ v8::Debug::ProcessDebugMessages();
+}
+
+QByteArray QV8DebugServicePrivate::packMessage(const QString &type, const QString &message)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd("V8DEBUG");
+ rs << cmd << type.toUtf8() << message.toUtf8();
+ return reply;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qv8debugservice_p.h b/src/qml/debugger/qv8debugservice_p.h
new file mode 100644
index 0000000000..8ff4adc778
--- /dev/null
+++ b/src/qml/debugger/qv8debugservice_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8DEBUGSERVICE_P_H
+#define QV8DEBUGSERVICE_P_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 "qqmldebugservice_p.h"
+#include <private/qv8debug_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QV8Engine;
+class QV8DebugServicePrivate;
+
+class QV8DebugService : public QQmlDebugService
+{
+ Q_OBJECT
+public:
+ QV8DebugService(QObject *parent = 0);
+ ~QV8DebugService();
+
+ static QV8DebugService *instance();
+ static void initialize(const QV8Engine *engine);
+
+ void debugMessageHandler(const QString &message, const v8::DebugEvent &event);
+
+ void signalEmitted(const QString &signal);
+
+public slots:
+ void processDebugMessages();
+
+private slots:
+ void scheduledDebugBreak(bool schedule);
+ void sendDebugMessage(const QString &message);
+ void init();
+
+protected:
+ void stateChanged(State newState);
+ void messageReceived(const QByteArray &);
+
+private:
+ void setEngine(const QV8Engine *engine);
+
+private:
+ Q_DISABLE_COPY(QV8DebugService)
+ Q_DECLARE_PRIVATE(QV8DebugService)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV8DEBUGSERVICE_P_H
diff --git a/src/qml/debugger/qv8profilerservice.cpp b/src/qml/debugger/qv8profilerservice.cpp
new file mode 100644
index 0000000000..6473a2f4fb
--- /dev/null
+++ b/src/qml/debugger/qv8profilerservice.cpp
@@ -0,0 +1,301 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8profilerservice_p.h"
+#include "qqmldebugservice_p_p.h"
+#include "private/qjsconverter_impl_p.h"
+#include <private/qv8profiler_p.h>
+
+#include <QtCore/QHash>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QV8ProfilerService, v8ProfilerInstance)
+
+class DebugServiceOutputStream : public v8::OutputStream
+{
+ QQmlDebugService &_service;
+public:
+ DebugServiceOutputStream(QQmlDebugService &service)
+ : v8::OutputStream(),
+ _service(service) {}
+ void EndOfStream() {}
+ WriteResult WriteAsciiChunk(char *rawData, int size)
+ {
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << QV8ProfilerService::V8SnapshotChunk << QByteArray(rawData, size);
+ _service.sendMessage(data);
+ return kContinue;
+ }
+};
+
+// convert to a QByteArray that can be sent to the debug client
+QByteArray QV8ProfilerData::toByteArray() const
+{
+ QByteArray data;
+ //### using QDataStream is relatively expensive
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << messageType << filename << functionname << lineNumber << totalTime << selfTime << treeLevel;
+
+ return data;
+}
+
+class QV8ProfilerServicePrivate : public QQmlDebugServicePrivate
+{
+ Q_DECLARE_PUBLIC(QV8ProfilerService)
+
+public:
+ QV8ProfilerServicePrivate()
+ :initialized(false)
+ {
+ }
+
+ void takeSnapshot(v8::HeapSnapshot::Type);
+
+ void printProfileTree(const v8::CpuProfileNode *node, int level = 0);
+ void sendMessages();
+
+ QList<QV8ProfilerData> m_data;
+
+ bool initialized;
+ QList<QString> m_ongoing;
+};
+
+QV8ProfilerService::QV8ProfilerService(QObject *parent)
+ : QQmlDebugService(*(new QV8ProfilerServicePrivate()), QLatin1String("V8Profiler"), 1, parent)
+{
+ Q_D(QV8ProfilerService);
+
+ if (registerService() == Enabled) {
+ // ,block mode, client attached
+ while (!d->initialized)
+ waitForMessage();
+ }
+}
+
+QV8ProfilerService::~QV8ProfilerService()
+{
+}
+
+QV8ProfilerService *QV8ProfilerService::instance()
+{
+ return v8ProfilerInstance();
+}
+
+void QV8ProfilerService::initialize()
+{
+ // just make sure that the service is properly registered
+ v8ProfilerInstance();
+}
+
+void QV8ProfilerService::stateAboutToBeChanged(QQmlDebugService::State newState)
+{
+ Q_D(QV8ProfilerService);
+
+ if (state() == newState)
+ return;
+
+ if (state() == Enabled) {
+ foreach (const QString &title, d->m_ongoing)
+ QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, title));
+ sendProfilingData();
+ }
+}
+
+void QV8ProfilerService::messageReceived(const QByteArray &message)
+{
+ Q_D(QV8ProfilerService);
+
+ QDataStream ds(message);
+ QByteArray command;
+ QByteArray option;
+ QByteArray title;
+ ds >> command >> option;
+
+ if (command == "V8PROFILER") {
+ ds >> title;
+ QString titleStr = QString::fromUtf8(title);
+ if (option == "start") {
+ QMetaObject::invokeMethod(this, "startProfiling", Qt::QueuedConnection, Q_ARG(QString, titleStr));
+ } else if (option == "stop" && d->initialized) {
+ QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, titleStr));
+ QMetaObject::invokeMethod(this, "sendProfilingData", Qt::QueuedConnection);
+ }
+ d->initialized = true;
+ }
+
+ if (command == "V8SNAPSHOT") {
+ if (option == "full")
+ QMetaObject::invokeMethod(this, "takeSnapshot", Qt::QueuedConnection);
+ else if (option == "delete") {
+ QMetaObject::invokeMethod(this, "deleteSnapshots", Qt::QueuedConnection);
+ }
+ }
+
+ QQmlDebugService::messageReceived(message);
+}
+
+void QV8ProfilerService::startProfiling(const QString &title)
+{
+ Q_D(QV8ProfilerService);
+ // Start Profiling
+
+ if (d->m_ongoing.contains(title))
+ return;
+
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::String> v8title = v8::String::New(reinterpret_cast<const uint16_t*>(title.data()), title.size());
+ v8::CpuProfiler::StartProfiling(v8title);
+
+ d->m_ongoing.append(title);
+
+ // indicate profiling started
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)QV8ProfilerService::V8Started;
+
+ sendMessage(data);
+}
+
+void QV8ProfilerService::stopProfiling(const QString &title)
+{
+ Q_D(QV8ProfilerService);
+ // Stop profiling
+
+ if (!d->m_ongoing.contains(title))
+ return;
+ d->m_ongoing.removeOne(title);
+
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::String> v8title = v8::String::New(reinterpret_cast<const uint16_t*>(title.data()), title.size());
+ const v8::CpuProfile *cpuProfile = v8::CpuProfiler::StopProfiling(v8title);
+ if (cpuProfile) {
+ // can happen at start
+ const v8::CpuProfileNode *rootNode = cpuProfile->GetTopDownRoot();
+ d->printProfileTree(rootNode);
+ } else {
+ // indicate completion, even without data
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)QV8ProfilerService::V8Complete;
+
+ sendMessage(data);
+ }
+}
+
+void QV8ProfilerService::takeSnapshot()
+{
+ Q_D(QV8ProfilerService);
+ d->takeSnapshot(v8::HeapSnapshot::kFull);
+}
+
+void QV8ProfilerService::deleteSnapshots()
+{
+ v8::HeapProfiler::DeleteAllSnapshots();
+}
+
+void QV8ProfilerService::sendProfilingData()
+{
+ Q_D(QV8ProfilerService);
+ // Send messages to client
+ d->sendMessages();
+}
+
+void QV8ProfilerServicePrivate::printProfileTree(const v8::CpuProfileNode *node, int level)
+{
+ for (int index = 0 ; index < node->GetChildrenCount() ; index++) {
+ const v8::CpuProfileNode* childNode = node->GetChild(index);
+ QString scriptResourceName = QJSConverter::toString(childNode->GetScriptResourceName());
+ if (scriptResourceName.length() > 0) {
+
+ QV8ProfilerData rd = {(int)QV8ProfilerService::V8Entry, scriptResourceName,
+ QJSConverter::toString(childNode->GetFunctionName()),
+ childNode->GetLineNumber(), childNode->GetTotalTime(), childNode->GetSelfTime(), level};
+ m_data.append(rd);
+
+ // different nodes might have common children: fix at client side
+ if (childNode->GetChildrenCount() > 0) {
+ printProfileTree(childNode, level+1);
+ }
+ }
+ }
+}
+
+void QV8ProfilerServicePrivate::takeSnapshot(v8::HeapSnapshot::Type snapshotType)
+{
+ Q_Q(QV8ProfilerService);
+
+ v8::HandleScope scope;
+ v8::Local<v8::String> title = v8::String::New("");
+
+ DebugServiceOutputStream outputStream(*q);
+ const v8::HeapSnapshot *snapshot = v8::HeapProfiler::TakeSnapshot(title, snapshotType);
+ snapshot->Serialize(&outputStream, v8::HeapSnapshot::kJSON);
+
+ //indicate completion
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)QV8ProfilerService::V8SnapshotComplete;
+
+ q->sendMessage(data);
+}
+
+void QV8ProfilerServicePrivate::sendMessages()
+{
+ Q_Q(QV8ProfilerService);
+
+ QList<QByteArray> messages;
+ for (int i = 0; i < m_data.count(); ++i)
+ messages << m_data.at(i).toByteArray();
+ q->sendMessages(messages);
+ m_data.clear();
+
+ //indicate completion
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)QV8ProfilerService::V8Complete;
+
+ q->sendMessage(data);
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qv8profilerservice_p.h b/src/qml/debugger/qv8profilerservice_p.h
new file mode 100644
index 0000000000..b706d1762a
--- /dev/null
+++ b/src/qml/debugger/qv8profilerservice_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8PROFILERSERVICE_P_H
+#define QV8PROFILERSERVICE_P_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 <private/qqmldebugservice_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+struct Q_AUTOTEST_EXPORT QV8ProfilerData
+{
+ int messageType;
+ QString filename;
+ QString functionname;
+ int lineNumber;
+ double totalTime;
+ double selfTime;
+ int treeLevel;
+
+ QByteArray toByteArray() const;
+};
+
+class QQmlEngine;
+class QV8ProfilerServicePrivate;
+
+class Q_AUTOTEST_EXPORT QV8ProfilerService : public QQmlDebugService
+{
+ Q_OBJECT
+public:
+ enum MessageType {
+ V8Entry,
+ V8Complete,
+ V8SnapshotChunk,
+ V8SnapshotComplete,
+ V8Started,
+
+ V8MaximumMessage
+ };
+
+ QV8ProfilerService(QObject *parent = 0);
+ ~QV8ProfilerService();
+
+ static QV8ProfilerService *instance();
+ static void initialize();
+
+public slots:
+ void startProfiling(const QString &title);
+ void stopProfiling(const QString &title);
+ void takeSnapshot();
+ void deleteSnapshots();
+
+ void sendProfilingData();
+
+protected:
+ void stateAboutToBeChanged(State state);
+ void messageReceived(const QByteArray &);
+
+private:
+ Q_DISABLE_COPY(QV8ProfilerService)
+ Q_DECLARE_PRIVATE(QV8ProfilerService)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV8PROFILERSERVICE_P_H
diff --git a/src/qml/qml.pro b/src/qml/qml.pro
new file mode 100644
index 0000000000..0bbfc9ff74
--- /dev/null
+++ b/src/qml/qml.pro
@@ -0,0 +1,37 @@
+load(qt_module)
+
+TARGET = QtQml
+QPRO_PWD = $$PWD
+
+CONFIG += module
+MODULE_PRI += ../../modules/qt_qml.pri
+
+QT = core-private gui gui-private network v8-private
+
+DEFINES += QT_BUILD_QML_LIB QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES
+
+win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
+win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS
+solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
+
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+
+exists("qqml_enable_gcov") {
+ QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors
+ LIBS += -lgcov
+}
+
+load(qt_module_config)
+
+HEADERS += qtqmlversion.h \
+ qtqmlglobal.h \
+ qtqmlglobal_p.h
+
+#INCLUDEPATH -= $$QMAKE_INCDIR_QT/$$TARGET
+#DESTDIR=.
+
+#modules
+include(util/util.pri)
+include(qml/qml.pri)
+include(debugger/debugger.pri)
+include(animations/animations.pri)
diff --git a/src/qml/qml/ftw/ftw.pri b/src/qml/qml/ftw/ftw.pri
new file mode 100644
index 0000000000..f2fec4e2dd
--- /dev/null
+++ b/src/qml/qml/ftw/ftw.pri
@@ -0,0 +1,29 @@
+HEADERS += \
+ $$PWD/qbitfield_p.h \
+ $$PWD/qintrusivelist_p.h \
+ $$PWD/qpodvector_p.h \
+ $$PWD/qhashedstring_p.h \
+ $$PWD/qqmlrefcount_p.h \
+ $$PWD/qqmlpool_p.h \
+ $$PWD/qfieldlist_p.h \
+ $$PWD/qfastmetabuilder_p.h \
+ $$PWD/qhashfield_p.h \
+ $$PWD/qqmlthread_p.h \
+ $$PWD/qfinitestack_p.h \
+ $$PWD/qrecursionwatcher_p.h \
+ $$PWD/qdeletewatcher_p.h \
+ $$PWD/qrecyclepool_p.h \
+ $$PWD/qflagpointer_p.h \
+ $$PWD/qqmltrace_p.h \
+ $$PWD/qpointervaluepair_p.h \
+ $$PWD/qlazilyallocated_p.h \
+
+SOURCES += \
+ $$PWD/qintrusivelist.cpp \
+ $$PWD/qhashedstring.cpp \
+ $$PWD/qqmlpool.cpp \
+ $$PWD/qfastmetabuilder.cpp \
+ $$PWD/qqmlthread.cpp \
+ $$PWD/qqmltrace.cpp \
+
+contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
diff --git a/src/qml/qml/ftw/qbitfield_p.h b/src/qml/qml/ftw/qbitfield_p.h
new file mode 100644
index 0000000000..75f80dd896
--- /dev/null
+++ b/src/qml/qml/ftw/qbitfield_p.h
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBITFIELD_P_H
+#define QBITFIELD_P_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>
+
+QT_BEGIN_NAMESPACE
+
+class QBitField
+{
+public:
+ inline QBitField();
+ inline QBitField(const quint32 *, int bits);
+ inline QBitField(const QBitField &);
+ inline ~QBitField();
+
+ inline QBitField &operator=(const QBitField &);
+
+ inline quint32 size() const;
+ inline QBitField united(const QBitField &);
+ inline bool testBit(int) const;
+
+private:
+ quint32 bits:31;
+ quint32 *ownData;
+ const quint32 *data;
+};
+
+QBitField::QBitField()
+: bits(0), ownData(0), data(0)
+{
+}
+
+QBitField::QBitField(const quint32 *bitData, int bitCount)
+: bits((quint32)bitCount), ownData(0), data(bitData)
+{
+}
+
+QBitField::QBitField(const QBitField &other)
+: bits(other.bits), ownData(other.ownData), data(other.data)
+{
+ if (ownData)
+ ++(*ownData);
+}
+
+QBitField::~QBitField()
+{
+ if (ownData)
+ if(0 == --(*ownData)) delete [] ownData;
+}
+
+QBitField &QBitField::operator=(const QBitField &other)
+{
+ if (other.data == data)
+ return *this;
+
+ if (ownData)
+ if(0 == --(*ownData)) delete [] ownData;
+
+ bits = other.bits;
+ ownData = other.ownData;
+ data = other.data;
+
+ if (ownData)
+ ++(*ownData);
+
+ return *this;
+}
+
+inline quint32 QBitField::size() const
+{
+ return bits;
+}
+
+QBitField QBitField::united(const QBitField &o)
+{
+ if (o.bits == 0) {
+ return *this;
+ } else if (bits == 0) {
+ return o;
+ } else {
+ int max = (bits > o.bits)?bits:o.bits;
+ int length = (max + 31) / 32;
+ QBitField rv;
+ rv.bits = max;
+ rv.ownData = new quint32[length + 1];
+ *(rv.ownData) = 1;
+ rv.data = rv.ownData + 1;
+ if (bits > o.bits) {
+ ::memcpy((quint32 *)rv.data, data, length * sizeof(quint32));
+ for (quint32 ii = 0; ii < (o.bits + quint32(31)) / 32; ++ii)
+ ((quint32 *)rv.data)[ii] |= o.data[ii];
+ } else {
+ ::memcpy((quint32 *)rv.data, o.data, length * sizeof(quint32));
+ for (quint32 ii = 0; ii < (bits + quint32(31)) / 32; ++ii)
+ ((quint32 *)rv.data)[ii] |= data[ii];
+ }
+ return rv;
+ }
+}
+
+bool QBitField::testBit(int b) const
+{
+ Q_ASSERT(b >= 0);
+ if ((quint32)b < bits) {
+ return data[b / 32] & (1 << (b % 32));
+ } else {
+ return false;
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QBITFIELD_P_H
diff --git a/src/qml/qml/ftw/qdeletewatcher_p.h b/src/qml/qml/ftw/qdeletewatcher_p.h
new file mode 100644
index 0000000000..9f7b100429
--- /dev/null
+++ b/src/qml/qml/ftw/qdeletewatcher_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDELETEWATCHER_P_H
+#define QDELETEWATCHER_P_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>
+
+QT_BEGIN_NAMESPACE
+
+class QDeleteWatchable
+{
+public:
+ inline QDeleteWatchable();
+ inline ~QDeleteWatchable();
+private:
+ friend class QDeleteWatcher;
+ bool *_w;
+};
+
+class QDeleteWatcher {
+public:
+ inline QDeleteWatcher(QDeleteWatchable *data);
+ inline ~QDeleteWatcher();
+ inline bool wasDeleted() const;
+private:
+ void *operator new(size_t);
+ bool *_w;
+ bool _s;
+ QDeleteWatchable *m_d;
+};
+
+QDeleteWatchable::QDeleteWatchable()
+: _w(0)
+{
+}
+
+QDeleteWatchable::~QDeleteWatchable()
+{
+ if (_w) *_w = true;
+}
+
+QDeleteWatcher::QDeleteWatcher(QDeleteWatchable *data)
+: _s(false), m_d(data)
+{
+ if (!m_d->_w)
+ m_d->_w = &_s;
+ _w = m_d->_w;
+}
+
+QDeleteWatcher::~QDeleteWatcher()
+{
+ if (false == *_w && &_s == m_d->_w)
+ m_d->_w = 0;
+}
+
+bool QDeleteWatcher::wasDeleted() const
+{
+ return *_w;
+}
+
+QT_END_NAMESPACE
+
+#endif // QDELETEWATCHER_P_H
diff --git a/src/qml/qml/ftw/qfastmetabuilder.cpp b/src/qml/qml/ftw/qfastmetabuilder.cpp
new file mode 100644
index 0000000000..02f50911ea
--- /dev/null
+++ b/src/qml/qml/ftw/qfastmetabuilder.cpp
@@ -0,0 +1,313 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfastmetabuilder_p.h"
+
+#include <QtCore/qmetaobject.h>
+#include <private/qobject_p.h>
+#include <private/qmetaobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QFastMetaBuilderHeader
+{
+ int fieldCount;
+};
+
+#define FMBHEADER_FIELD_COUNT 1
+
+#define HEADER_FIELD_COUNT 14
+#define CLASSINFO_FIELD_COUNT 2
+#define METHOD_FIELD_COUNT 5
+#define PROPERTY_FIELD_COUNT 3
+#define PROPERTY_NOTIFY_FIELD_COUNT 1
+
+static inline uint *fieldPointer(QByteArray &data)
+{ return reinterpret_cast<uint *>(data.data()) + FMBHEADER_FIELD_COUNT; }
+
+static inline const uint *fieldPointer(const QByteArray &data)
+{ return reinterpret_cast<const uint *>(data.constData()) + FMBHEADER_FIELD_COUNT; }
+
+static inline QMetaObjectPrivate *priv(QByteArray &data)
+{ return reinterpret_cast<QMetaObjectPrivate*>(fieldPointer(data)); }
+
+static inline const QMetaObjectPrivate *priv(const QByteArray &data)
+{ return reinterpret_cast<const QMetaObjectPrivate*>(fieldPointer(data)); }
+
+static inline QFastMetaBuilderHeader *header(QByteArray &data)
+{ return reinterpret_cast<QFastMetaBuilderHeader*>(data.data()); }
+
+static inline const QFastMetaBuilderHeader *header(const QByteArray &data)
+{ return reinterpret_cast<const QFastMetaBuilderHeader*>(data.constData()); }
+
+QFastMetaBuilder::QFastMetaBuilder()
+: m_zeroPtr(0), m_stringData(0), m_stringDataLength(0), m_stringDataAllocated(0)
+{
+}
+
+QFastMetaBuilder::~QFastMetaBuilder()
+{
+}
+
+QFastMetaBuilder::StringRef QFastMetaBuilder::init(int classNameLength,
+ int propertyCount, int methodCount,
+ int signalCount, int classInfoCount)
+{
+ Q_ASSERT(m_data.isEmpty());
+ Q_ASSERT(classNameLength > 0);
+ Q_ASSERT(propertyCount >= 0);
+ Q_ASSERT(methodCount >= 0);
+ Q_ASSERT(signalCount >= 0);
+ Q_ASSERT(classInfoCount >= 0);
+
+ int fieldCount = FMBHEADER_FIELD_COUNT +
+ HEADER_FIELD_COUNT +
+ propertyCount * (PROPERTY_FIELD_COUNT + PROPERTY_NOTIFY_FIELD_COUNT) +
+ methodCount * (METHOD_FIELD_COUNT) +
+ signalCount * (METHOD_FIELD_COUNT) +
+ classInfoCount * CLASSINFO_FIELD_COUNT;
+
+ m_data.resize(fieldCount * sizeof(uint) + classNameLength + 1);
+ m_stringData = m_data.data() + m_data.size() - classNameLength - 1;
+ m_stringDataLength = classNameLength + 1;
+ m_stringDataAllocated = classNameLength + 1;
+ m_stringData[classNameLength] = 0;
+ m_zeroPtr = classNameLength;
+
+ header(m_data)->fieldCount = fieldCount;
+
+ QMetaObjectPrivate *p = priv(m_data);
+
+ int dataIndex = HEADER_FIELD_COUNT;
+
+ p->revision = 6;
+ p->className = 0;
+
+ // Class infos
+ p->classInfoCount = classInfoCount;
+ if (p->classInfoCount) {
+ p->classInfoData = dataIndex;
+ dataIndex += p->classInfoCount * CLASSINFO_FIELD_COUNT;
+ } else {
+ p->classInfoData = 0;
+ }
+
+ // Methods
+ p->methodCount = methodCount + signalCount;
+ if (p->methodCount) {
+ p->methodData = dataIndex;
+ dataIndex += p->methodCount * METHOD_FIELD_COUNT;
+ } else {
+ p->methodData = 0;
+ }
+ p->signalCount = signalCount;
+
+ // Properties
+ p->propertyCount = propertyCount;
+ if (p->propertyCount) {
+ p->propertyData = dataIndex;
+ dataIndex += p->propertyCount * (PROPERTY_FIELD_COUNT + PROPERTY_NOTIFY_FIELD_COUNT);
+ } else {
+ p->propertyData = 0;
+ }
+
+ // Flags
+ p->flags = DynamicMetaObject; // Always dynamic
+
+ // Enums and constructors not supported
+ p->enumeratorCount = 0;
+ p->enumeratorData = 0;
+ p->constructorCount = 0;
+ p->constructorData = 0;
+
+ StringRef className;
+ className._b = this;
+ className._o = 0;
+ className._l = classNameLength;
+ return className;
+}
+
+// Allocate a string of \a length. \a length should *not* include the null terminator.
+QFastMetaBuilder::StringRef QFastMetaBuilder::newString(int length)
+{
+ Q_ASSERT(length > 0);
+
+ StringRef sr;
+ sr._b = this;
+ sr._o = m_stringDataLength;
+ sr._l = length;
+
+ m_stringDataLength += length + 1 /* for null terminator */;
+
+ return sr;
+}
+
+void QFastMetaBuilder::setClassInfo(int index, const StringRef &key, const StringRef &value)
+{
+ Q_ASSERT(!m_data.isEmpty());
+ Q_ASSERT(!key.isEmpty() && !value.isEmpty());
+
+ QMetaObjectPrivate *p = priv(m_data);
+ Q_ASSERT(index < p->classInfoCount);
+
+ uint *ptr = fieldPointer(m_data) + p->classInfoData + index * CLASSINFO_FIELD_COUNT;
+ // classinfo: key, value
+ ptr[0] = key.offset(); ptr[1] = value.offset();
+}
+
+void QFastMetaBuilder::setProperty(int index, const StringRef &name, const StringRef &type,
+ QMetaType::Type mtype, PropertyFlag flags, int notifySignal)
+{
+ Q_ASSERT(!m_data.isEmpty());
+ Q_ASSERT(!name.isEmpty() && !type.isEmpty());
+
+ QMetaObjectPrivate *p = priv(m_data);
+ Q_ASSERT(index < p->propertyCount);
+
+ uint *ptr = fieldPointer(m_data) + p->propertyData + index * PROPERTY_FIELD_COUNT;
+ // properties: name, type, flags
+ ptr[0] = name.offset();
+ ptr[1] = type.offset();
+ if (notifySignal == -1) {
+ ptr[2] = mtype << 24;
+ ptr[2] |= flags | Scriptable | Readable;
+ *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = 0;
+ } else {
+ ptr[2] = mtype << 24;
+ ptr[2] |= flags | Scriptable | Readable | Notify;
+ *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = notifySignal;
+ }
+}
+
+void QFastMetaBuilder::setProperty(int index, const StringRef &name, const StringRef &type,
+ QFastMetaBuilder::PropertyFlag flags, int notifySignal)
+{
+ Q_ASSERT(!m_data.isEmpty());
+ Q_ASSERT(!name.isEmpty() && !type.isEmpty());
+
+ QMetaObjectPrivate *p = priv(m_data);
+ Q_ASSERT(index < p->propertyCount);
+
+ uint *ptr = fieldPointer(m_data) + p->propertyData + index * PROPERTY_FIELD_COUNT;
+ // properties: name, type, flags
+ ptr[0] = name.offset();
+ ptr[1] = type.offset();
+ if (notifySignal == -1) {
+ ptr[2] = flags | Scriptable | Readable;
+ *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = 0;
+ } else {
+ ptr[2] = flags | Scriptable | Readable | Notify;
+ *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = notifySignal;
+ }
+}
+
+void QFastMetaBuilder::setSignal(int index, const StringRef &signature,
+ const StringRef &parameterNames,
+ const StringRef &type)
+{
+ Q_ASSERT(!m_data.isEmpty());
+ Q_ASSERT(!signature.isEmpty());
+
+ QMetaObjectPrivate *p = priv(m_data);
+ int mindex = metaObjectIndexForSignal(index);
+
+ uint *ptr = fieldPointer(m_data) + p->methodData + mindex * METHOD_FIELD_COUNT;
+ // methods: signature, parameters, type, tag, flags
+ ptr[0] = signature.offset();
+ ptr[1] = parameterNames.isEmpty()?m_zeroPtr:parameterNames.offset();
+ ptr[2] = type.isEmpty()?m_zeroPtr:type.offset();
+ ptr[3] = m_zeroPtr;
+ ptr[4] = AccessProtected | MethodSignal;
+}
+
+void QFastMetaBuilder::setMethod(int index, const StringRef &signature,
+ const StringRef &parameterNames,
+ const StringRef &type)
+{
+ Q_ASSERT(!m_data.isEmpty());
+ Q_ASSERT(!signature.isEmpty());
+
+ QMetaObjectPrivate *p = priv(m_data);
+ int mindex = metaObjectIndexForMethod(index);
+
+ uint *ptr = fieldPointer(m_data) + p->methodData + mindex * METHOD_FIELD_COUNT;
+ // methods: signature, parameters, type, tag, flags
+ ptr[0] = signature.offset();
+ ptr[1] = parameterNames.isEmpty()?m_zeroPtr:parameterNames.offset();
+ ptr[2] = type.isEmpty()?m_zeroPtr:type.offset();
+ ptr[3] = m_zeroPtr;
+ ptr[4] = AccessProtected | MethodSlot;
+}
+
+int QFastMetaBuilder::metaObjectIndexForSignal(int index) const
+{
+ Q_ASSERT(!m_data.isEmpty());
+ Q_ASSERT(index < priv(m_data)->signalCount);
+ return index;
+}
+
+int QFastMetaBuilder::metaObjectIndexForMethod(int index) const
+{
+ Q_ASSERT(!m_data.isEmpty());
+
+ const QMetaObjectPrivate *p = priv(m_data);
+ Q_ASSERT(index < (p->methodCount - p->signalCount));
+ return index + p->signalCount;
+}
+
+void QFastMetaBuilder::allocateStringData()
+{
+ if (m_stringDataAllocated < m_stringDataLength) {
+ m_data.resize(m_data.size() + m_stringDataLength - m_stringDataAllocated);
+ m_stringDataAllocated = m_stringDataLength;
+ m_stringData = m_data.data() + header(m_data)->fieldCount * sizeof(uint);
+ }
+}
+
+void QFastMetaBuilder::fromData(QMetaObject *output, const QMetaObject *parent, const QByteArray &data)
+{
+ output->d.superdata = parent;
+ output->d.stringdata = data.constData() + header(data)->fieldCount * sizeof(uint);
+ output->d.data = fieldPointer(data);
+ output->d.extradata = 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/ftw/qfastmetabuilder_p.h b/src/qml/qml/ftw/qfastmetabuilder_p.h
new file mode 100644
index 0000000000..c1f6a3de5c
--- /dev/null
+++ b/src/qml/qml/ftw/qfastmetabuilder_p.h
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFASTMETABUILDER_P_H
+#define QFASTMETABUILDER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of moc. This header file may change from version to version without notice,
+// or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qmetatype.h>
+#include <QtCore/qmetaobject.h>
+
+#include <private/qhashedstring_p.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QMetaObject;
+class QFastMetaBuilder
+{
+public:
+ QFastMetaBuilder();
+ ~QFastMetaBuilder();
+
+ struct StringRef {
+ public:
+ inline StringRef();
+ inline StringRef(const StringRef &);
+ inline StringRef &operator=(const StringRef &);
+
+ inline void load(const QHashedStringRef &);
+ inline void load(const QByteArray &);
+ inline void load(const char *);
+
+ inline bool isEmpty() const;
+ inline QFastMetaBuilder *builder() const;
+ inline int offset() const;
+ inline char *data();
+ inline int length() const;
+ private:
+ friend class QFastMetaBuilder;
+
+ QFastMetaBuilder *_b;
+ int _o;
+ int _l;
+ };
+ StringRef newString(int length);
+
+ // Returns class name
+ StringRef init(int classNameLength,
+ int propertyCount, int methodCount,
+ int signalCount, int classInfoCount);
+
+ void setClassInfo(int index, const StringRef &key, const StringRef &value);
+
+ enum PropertyFlag {
+ None = 0x00000000,
+ Writable = 0x00000002,
+ Resettable = 0x00000004,
+ Constant = 0x00000400,
+ Final = 0x00000800
+ };
+ // void setProperty(int index, const StringRef &name, QMetaType::Type type, int notifySignal = -1);
+ void setProperty(int index, const StringRef &name, const StringRef &type,
+ QMetaType::Type mtype, PropertyFlag flags, int notifySignal = -1);
+ void setProperty(int index, const StringRef &name, const StringRef &type,
+ PropertyFlag flags, int notifySignal = -1);
+ void setMethod(int index, const StringRef &signature,
+ const StringRef &parameterNames = StringRef(),
+ const StringRef &type = StringRef());
+ void setSignal(int index, const StringRef &signature,
+ const StringRef &parameterNames = StringRef(),
+ const StringRef &type = StringRef());
+
+ int metaObjectIndexForSignal(int) const;
+ int metaObjectIndexForMethod(int) const;
+
+ QByteArray toData() const { return m_data; }
+ static void fromData(QMetaObject *, const QMetaObject *parent, const QByteArray &);
+private:
+ friend struct StringRef;
+
+ QByteArray m_data;
+ int m_zeroPtr;
+
+ void allocateStringData();
+ char *m_stringData;
+ int m_stringDataLength;
+ int m_stringDataAllocated;
+};
+
+QFastMetaBuilder::StringRef::StringRef()
+: _b(0), _o(0), _l(0)
+{
+}
+
+QFastMetaBuilder::StringRef::StringRef(const StringRef &o)
+: _b(o._b), _o(o._o), _l(o._l)
+{
+}
+
+QFastMetaBuilder::StringRef &QFastMetaBuilder::StringRef::operator=(const StringRef &o)
+{
+ _b = o._b;
+ _o = o._o;
+ _l = o._l;
+ return *this;
+}
+
+bool QFastMetaBuilder::StringRef::isEmpty() const
+{
+ return _l == 0;
+}
+
+QFastMetaBuilder *QFastMetaBuilder::StringRef::builder() const
+{
+ return _b;
+}
+
+int QFastMetaBuilder::StringRef::offset() const
+{
+ return _o;
+}
+
+char *QFastMetaBuilder::StringRef::data()
+{
+ Q_ASSERT(_b);
+ if (_b->m_stringDataLength != _b->m_stringDataAllocated)
+ _b->allocateStringData();
+ return _b->m_stringData + _o;
+}
+
+int QFastMetaBuilder::StringRef::length() const
+{
+ return _l;
+}
+
+void QFastMetaBuilder::StringRef::load(const QHashedStringRef &str)
+{
+ Q_ASSERT(str.utf8length() == _l);
+ str.writeUtf8(data());
+ *(data() + _l) = 0;
+}
+
+void QFastMetaBuilder::StringRef::load(const QByteArray &str)
+{
+ Q_ASSERT(str.length() == _l);
+ strcpy(data(), str.constData());
+}
+
+void QFastMetaBuilder::StringRef::load(const char *str)
+{
+ Q_ASSERT(strlen(str) == (uint)_l);
+ strcpy(data(), str);
+}
+
+QT_END_NAMESPACE
+
+#endif // QFASTMETABUILDER_P_H
+
diff --git a/src/qml/qml/ftw/qfieldlist_p.h b/src/qml/qml/ftw/qfieldlist_p.h
new file mode 100644
index 0000000000..da5074b3cd
--- /dev/null
+++ b/src/qml/qml/ftw/qfieldlist_p.h
@@ -0,0 +1,426 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFIELDLIST_P_H
+#define QFIELDLIST_P_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 <private/qflagpointer_p.h>
+
+// QForwardFieldList is a super simple linked list that can only prepend
+template<class N, N *N::*nextMember>
+class QForwardFieldList
+{
+public:
+ inline QForwardFieldList();
+ inline N *first() const;
+ inline N *takeFirst();
+
+ inline void prepend(N *);
+
+ inline bool isEmpty() const;
+ inline bool isOne() const;
+ inline bool isMany() const;
+
+ static inline N *next(N *v);
+
+ inline bool flag() const;
+ inline void setFlag();
+ inline void clearFlag();
+ inline void setFlagValue(bool);
+
+ inline bool flag2() const;
+ inline void setFlag2();
+ inline void clearFlag2();
+ inline void setFlag2Value(bool);
+private:
+ QFlagPointer<N> _first;
+};
+
+// QFieldList is a simple linked list, that can append and prepend and also
+// maintains a count
+template<class N, N *N::*nextMember>
+class QFieldList
+{
+public:
+ inline QFieldList();
+ inline N *first() const;
+ inline N *takeFirst();
+
+ inline void append(N *);
+ inline void prepend(N *);
+
+ inline bool isEmpty() const;
+ inline bool isOne() const;
+ inline bool isMany() const;
+ inline int count() const;
+
+ inline void append(QFieldList<N, nextMember> &);
+ inline void prepend(QFieldList<N, nextMember> &);
+ inline void insertAfter(N *, QFieldList<N, nextMember> &);
+
+ inline void copyAndClear(QFieldList<N, nextMember> &);
+ inline void copyAndClearAppend(QForwardFieldList<N, nextMember> &);
+ inline void copyAndClearPrepend(QForwardFieldList<N, nextMember> &);
+
+ static inline N *next(N *v);
+
+ inline bool flag() const;
+ inline void setFlag();
+ inline void clearFlag();
+ inline void setFlagValue(bool);
+private:
+ N *_first;
+ N *_last;
+ quint32 _flag:1;
+ quint32 _count:31;
+};
+
+template<class N, N *N::*nextMember>
+QForwardFieldList<N, nextMember>::QForwardFieldList()
+{
+}
+
+template<class N, N *N::*nextMember>
+N *QForwardFieldList<N, nextMember>::first() const
+{
+ return *_first;
+}
+
+template<class N, N *N::*nextMember>
+N *QForwardFieldList<N, nextMember>::takeFirst()
+{
+ N *value = *_first;
+ if (value) {
+ _first = next(value);
+ value->*nextMember = 0;
+ }
+ return value;
+}
+
+template<class N, N *N::*nextMember>
+void QForwardFieldList<N, nextMember>::prepend(N *v)
+{
+ Q_ASSERT(v->*nextMember == 0);
+ v->*nextMember = *_first;
+ _first = v;
+}
+
+template<class N, N *N::*nextMember>
+bool QForwardFieldList<N, nextMember>::isEmpty() const
+{
+ return _first.isNull();
+}
+
+template<class N, N *N::*nextMember>
+bool QForwardFieldList<N, nextMember>::isOne() const
+{
+ return *_first && _first->*nextMember == 0;
+}
+
+template<class N, N *N::*nextMember>
+bool QForwardFieldList<N, nextMember>::isMany() const
+{
+ return *_first && _first->*nextMember != 0;
+}
+
+template<class N, N *N::*nextMember>
+N *QForwardFieldList<N, nextMember>::next(N *v)
+{
+ Q_ASSERT(v);
+ return v->*nextMember;
+}
+
+template<class N, N *N::*nextMember>
+bool QForwardFieldList<N, nextMember>::flag() const
+{
+ return _first.flag();
+}
+
+template<class N, N *N::*nextMember>
+void QForwardFieldList<N, nextMember>::setFlag()
+{
+ _first.setFlag();
+}
+
+template<class N, N *N::*nextMember>
+void QForwardFieldList<N, nextMember>::clearFlag()
+{
+ _first.clearFlag();
+}
+
+template<class N, N *N::*nextMember>
+void QForwardFieldList<N, nextMember>::setFlagValue(bool v)
+{
+ _first.setFlagValue(v);
+}
+
+template<class N, N *N::*nextMember>
+bool QForwardFieldList<N, nextMember>::flag2() const
+{
+ return _first.flag2();
+}
+
+template<class N, N *N::*nextMember>
+void QForwardFieldList<N, nextMember>::setFlag2()
+{
+ _first.setFlag2();
+}
+
+template<class N, N *N::*nextMember>
+void QForwardFieldList<N, nextMember>::clearFlag2()
+{
+ _first.clearFlag2();
+}
+
+template<class N, N *N::*nextMember>
+void QForwardFieldList<N, nextMember>::setFlag2Value(bool v)
+{
+ _first.setFlag2Value(v);
+}
+
+template<class N, N *N::*nextMember>
+QFieldList<N, nextMember>::QFieldList()
+: _first(0), _last(0), _flag(0), _count(0)
+{
+}
+
+template<class N, N *N::*nextMember>
+N *QFieldList<N, nextMember>::first() const
+{
+ return _first;
+}
+
+template<class N, N *N::*nextMember>
+N *QFieldList<N, nextMember>::takeFirst()
+{
+ N *value = _first;
+ if (value) {
+ _first = next(value);
+ if (_last == value) {
+ Q_ASSERT(_first == 0);
+ _last = 0;
+ }
+ value->*nextMember = 0;
+ --_count;
+ }
+ return value;
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::append(N *v)
+{
+ Q_ASSERT(v->*nextMember == 0);
+ if (isEmpty()) {
+ _first = v;
+ _last = v;
+ } else {
+ _last->*nextMember = v;
+ _last = v;
+ }
+ ++_count;
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::prepend(N *v)
+{
+ Q_ASSERT(v->*nextMember == 0);
+ if (isEmpty()) {
+ _first = v;
+ _last = v;
+ } else {
+ v->*nextMember = _first;
+ _first = v;
+ }
+ ++_count;
+}
+
+template<class N, N *N::*nextMember>
+bool QFieldList<N, nextMember>::isEmpty() const
+{
+ return _count == 0;
+}
+
+template<class N, N *N::*nextMember>
+bool QFieldList<N, nextMember>::isOne() const
+{
+ return _count == 1;
+}
+
+template<class N, N *N::*nextMember>
+bool QFieldList<N, nextMember>::isMany() const
+{
+ return _count > 1;
+}
+
+template<class N, N *N::*nextMember>
+int QFieldList<N, nextMember>::count() const
+{
+ return _count;
+}
+
+template<class N, N *N::*nextMember>
+N *QFieldList<N, nextMember>::next(N *v)
+{
+ Q_ASSERT(v);
+ return v->*nextMember;
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::append(QFieldList<N, nextMember> &o)
+{
+ if (!o.isEmpty()) {
+ if (isEmpty()) {
+ _first = o._first;
+ _last = o._last;
+ _count = o._count;
+ } else {
+ _last->*nextMember = o._first;
+ _last = o._last;
+ _count += o._count;
+ }
+ o._first = o._last = 0; o._count = 0;
+ }
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::prepend(QFieldList<N, nextMember> &o)
+{
+ if (!o.isEmpty()) {
+ if (isEmpty()) {
+ _first = o._first;
+ _last = o._last;
+ _count = o._count;
+ } else {
+ o._last->*nextMember = _first;
+ _first = o._first;
+ _count += o._count;
+ }
+ o._first = o._last = 0; o._count = 0;
+ }
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::insertAfter(N *after, QFieldList<N, nextMember> &o)
+{
+ if (after == 0) {
+ prepend(o);
+ } else if (after == _last) {
+ append(o);
+ } else if (!o.isEmpty()) {
+ if (isEmpty()) {
+ _first = o._first;
+ _last = o._last;
+ _count = o._count;
+ } else {
+ o._last->*nextMember = after->*nextMember;
+ after->*nextMember = o._first;
+ _count += o._count;
+ }
+ o._first = o._last = 0; o._count = 0;
+ }
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::copyAndClear(QFieldList<N, nextMember> &o)
+{
+ _first = o._first;
+ _last = o._last;
+ _count = o._count;
+ o._first = o._last = 0;
+ o._count = 0;
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::copyAndClearAppend(QForwardFieldList<N, nextMember> &o)
+{
+ _first = 0;
+ _last = 0;
+ _count = 0;
+ while (N *n = o.takeFirst()) append(n);
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::copyAndClearPrepend(QForwardFieldList<N, nextMember> &o)
+{
+ _first = 0;
+ _last = 0;
+ _count = 0;
+ while (N *n = o.takeFirst()) prepend(n);
+}
+
+template<class N, N *N::*nextMember>
+bool QFieldList<N, nextMember>::flag() const
+{
+ return _flag;
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::setFlag()
+{
+ _flag = true;
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::clearFlag()
+{
+ _flag = false;
+}
+
+template<class N, N *N::*nextMember>
+void QFieldList<N, nextMember>::setFlagValue(bool v)
+{
+ _flag = v;
+}
+
+#endif // QFIELDLIST_P_H
diff --git a/src/qml/qml/ftw/qfinitestack_p.h b/src/qml/qml/ftw/qfinitestack_p.h
new file mode 100644
index 0000000000..c5a9fbaedb
--- /dev/null
+++ b/src/qml/qml/ftw/qfinitestack_p.h
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFINITESTACK_P_H
+#define QFINITESTACK_P_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>
+
+QT_BEGIN_NAMESPACE
+
+template<typename T>
+struct QFiniteStack {
+ inline QFiniteStack();
+ inline ~QFiniteStack();
+
+ inline void deallocate();
+ inline void allocate(int size);
+
+ inline bool isEmpty() const;
+ inline const T &top() const;
+ inline T &top();
+ inline void push(const T &o);
+ inline T pop();
+ inline int count() const;
+ inline const T &at(int index) const;
+ inline T &operator[](int index);
+private:
+ T *_array;
+ int _alloc;
+ int _size;
+};
+
+template<typename T>
+QFiniteStack<T>::QFiniteStack()
+: _array(0), _alloc(0), _size(0)
+{
+}
+
+template<typename T>
+QFiniteStack<T>::~QFiniteStack()
+{
+ deallocate();
+}
+
+template<typename T>
+bool QFiniteStack<T>::isEmpty() const
+{
+ return _size == 0;
+}
+
+template<typename T>
+const T &QFiniteStack<T>::top() const
+{
+ return _array[_size - 1];
+}
+
+template<typename T>
+T &QFiniteStack<T>::top()
+{
+ return _array[_size - 1];
+}
+
+template<typename T>
+void QFiniteStack<T>::push(const T &o)
+{
+ if (QTypeInfo<T>::isComplex) {
+ new (_array + _size++) T(o);
+ } else {
+ _array[_size++] = o;
+ }
+}
+
+template<typename T>
+T QFiniteStack<T>::pop()
+{
+ --_size;
+
+ if (QTypeInfo<T>::isComplex) {
+ T rv = _array[_size];
+ (_array + _size)->~T();
+ return rv;
+ } else {
+ return _array[_size];
+ }
+}
+
+template<typename T>
+int QFiniteStack<T>::count() const
+{
+ return _size;
+}
+
+template<typename T>
+const T &QFiniteStack<T>::at(int index) const
+{
+ return _array[index];
+}
+
+template<typename T>
+T &QFiniteStack<T>::operator[](int index)
+{
+ return _array[index];
+}
+
+template<typename T>
+void QFiniteStack<T>::allocate(int size)
+{
+ Q_ASSERT(_array == 0);
+ Q_ASSERT(_alloc == 0);
+ Q_ASSERT(_size == 0);
+
+ if (!size) return;
+
+ _array = (T *)qMalloc(size * sizeof(T));
+ _alloc = size;
+}
+
+template<typename T>
+void QFiniteStack<T>::deallocate()
+{
+ if (QTypeInfo<T>::isComplex) {
+ T *i = _array + _size;
+ while (i != _array)
+ (--i)->~T();
+ }
+
+ qFree(_array);
+
+ _array = 0;
+ _alloc = 0;
+ _size = 0;
+}
+
+QT_END_NAMESPACE
+
+#endif // QFINITESTACK_P_H
+
diff --git a/src/qml/qml/ftw/qflagpointer_p.h b/src/qml/qml/ftw/qflagpointer_p.h
new file mode 100644
index 0000000000..a4b20d9e2a
--- /dev/null
+++ b/src/qml/qml/ftw/qflagpointer_p.h
@@ -0,0 +1,338 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFLAGPOINTER_P_H
+#define QFLAGPOINTER_P_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>
+
+QT_BEGIN_NAMESPACE
+
+template<typename T>
+class QFlagPointer {
+public:
+ inline QFlagPointer();
+ inline QFlagPointer(T *);
+ inline QFlagPointer(const QFlagPointer<T> &o);
+
+ inline bool isNull() const;
+
+ inline bool flag() const;
+ inline void setFlag();
+ inline void clearFlag();
+ inline void setFlagValue(bool);
+
+ inline bool flag2() const;
+ inline void setFlag2();
+ inline void clearFlag2();
+ inline void setFlag2Value(bool);
+
+ inline QFlagPointer<T> &operator=(const QFlagPointer &o);
+ inline QFlagPointer<T> &operator=(T *);
+
+ inline T *operator->() const;
+ inline T *operator*() const;
+
+private:
+ quintptr ptr_value;
+
+ static const quintptr FlagBit = 0x1;
+ static const quintptr Flag2Bit = 0x2;
+ static const quintptr FlagsMask = FlagBit | Flag2Bit;
+};
+
+template<typename T, typename T2>
+class QBiPointer {
+public:
+ inline QBiPointer();
+ inline QBiPointer(T *);
+ inline QBiPointer(T2 *);
+ inline QBiPointer(const QBiPointer<T, T2> &o);
+
+ inline bool isNull() const;
+ inline bool isT1() const;
+ inline bool isT2() const;
+
+ inline bool flag() const;
+ inline void setFlag();
+ inline void clearFlag();
+ inline void setFlagValue(bool);
+
+ inline QBiPointer<T, T2> &operator=(const QBiPointer<T, T2> &o);
+ inline QBiPointer<T, T2> &operator=(T *);
+ inline QBiPointer<T, T2> &operator=(T2 *);
+
+ inline T *asT1() const;
+ inline T2 *asT2() const;
+
+private:
+ quintptr ptr_value;
+
+ static const quintptr FlagBit = 0x1;
+ static const quintptr Flag2Bit = 0x2;
+ static const quintptr FlagsMask = FlagBit | Flag2Bit;
+};
+
+template<typename T>
+QFlagPointer<T>::QFlagPointer()
+: ptr_value(0)
+{
+}
+
+template<typename T>
+QFlagPointer<T>::QFlagPointer(T *v)
+: ptr_value(quintptr(v))
+{
+ Q_ASSERT((ptr_value & FlagsMask) == 0);
+}
+
+template<typename T>
+QFlagPointer<T>::QFlagPointer(const QFlagPointer<T> &o)
+: ptr_value(o.ptr_value)
+{
+}
+
+template<typename T>
+bool QFlagPointer<T>::isNull() const
+{
+ return 0 == (ptr_value & (~FlagsMask));
+}
+
+template<typename T>
+bool QFlagPointer<T>::flag() const
+{
+ return ptr_value & FlagBit;
+}
+
+template<typename T>
+void QFlagPointer<T>::setFlag()
+{
+ ptr_value |= FlagBit;
+}
+
+template<typename T>
+void QFlagPointer<T>::clearFlag()
+{
+ ptr_value &= ~FlagBit;
+}
+
+template<typename T>
+void QFlagPointer<T>::setFlagValue(bool v)
+{
+ if (v) setFlag();
+ else clearFlag();
+}
+
+template<typename T>
+bool QFlagPointer<T>::flag2() const
+{
+ return ptr_value & Flag2Bit;
+}
+
+template<typename T>
+void QFlagPointer<T>::setFlag2()
+{
+ ptr_value|= Flag2Bit;
+}
+
+template<typename T>
+void QFlagPointer<T>::clearFlag2()
+{
+ ptr_value &= ~Flag2Bit;
+}
+
+template<typename T>
+void QFlagPointer<T>::setFlag2Value(bool v)
+{
+ if (v) setFlag2();
+ else clearFlag2();
+}
+
+template<typename T>
+QFlagPointer<T> &QFlagPointer<T>::operator=(const QFlagPointer &o)
+{
+ ptr_value = o.ptr_value;
+ return *this;
+}
+
+template<typename T>
+QFlagPointer<T> &QFlagPointer<T>::operator=(T *o)
+{
+ Q_ASSERT((quintptr(o) & FlagsMask) == 0);
+
+ ptr_value = quintptr(o) | (ptr_value & FlagsMask);
+ return *this;
+}
+
+template<typename T>
+T *QFlagPointer<T>::operator->() const
+{
+ return (T *)(ptr_value & ~FlagsMask);
+}
+
+template<typename T>
+T *QFlagPointer<T>::operator*() const
+{
+ return (T *)(ptr_value & ~FlagsMask);
+}
+
+template<typename T, typename T2>
+QBiPointer<T, T2>::QBiPointer()
+: ptr_value(0)
+{
+}
+
+template<typename T, typename T2>
+QBiPointer<T, T2>::QBiPointer(T *v)
+: ptr_value(quintptr(v))
+{
+ Q_ASSERT((quintptr(v) & FlagsMask) == 0);
+}
+
+template<typename T, typename T2>
+QBiPointer<T, T2>::QBiPointer(T2 *v)
+: ptr_value(quintptr(v) | Flag2Bit)
+{
+ Q_ASSERT((quintptr(v) & FlagsMask) == 0);
+}
+
+template<typename T, typename T2>
+QBiPointer<T, T2>::QBiPointer(const QBiPointer<T, T2> &o)
+: ptr_value(o.ptr_value)
+{
+}
+
+template<typename T, typename T2>
+bool QBiPointer<T, T2>::isNull() const
+{
+ return 0 == (ptr_value & (~FlagsMask));
+}
+
+template<typename T, typename T2>
+bool QBiPointer<T, T2>::isT1() const
+{
+ return !(ptr_value & Flag2Bit);
+}
+
+template<typename T, typename T2>
+bool QBiPointer<T, T2>::isT2() const
+{
+ return ptr_value & Flag2Bit;
+}
+
+template<typename T, typename T2>
+bool QBiPointer<T, T2>::flag() const
+{
+ return ptr_value & FlagBit;
+}
+
+template<typename T, typename T2>
+void QBiPointer<T, T2>::setFlag()
+{
+ ptr_value |= FlagBit;
+}
+
+template<typename T, typename T2>
+void QBiPointer<T, T2>::clearFlag()
+{
+ ptr_value &= ~FlagBit;
+}
+
+template<typename T, typename T2>
+void QBiPointer<T, T2>::setFlagValue(bool v)
+{
+ if (v) setFlag();
+ else clearFlag();
+}
+
+template<typename T, typename T2>
+QBiPointer<T, T2> &QBiPointer<T, T2>::operator=(const QBiPointer<T, T2> &o)
+{
+ ptr_value = o.ptr_value;
+ return *this;
+}
+
+template<typename T, typename T2>
+QBiPointer<T, T2> &QBiPointer<T, T2>::operator=(T *o)
+{
+ Q_ASSERT((quintptr(o) & FlagsMask) == 0);
+
+ ptr_value = quintptr(o) | (ptr_value & FlagBit);
+ return *this;
+}
+
+template<typename T, typename T2>
+QBiPointer<T, T2> &QBiPointer<T, T2>::operator=(T2 *o)
+{
+ Q_ASSERT((quintptr(o) & FlagsMask) == 0);
+
+ ptr_value = quintptr(o) | (ptr_value & FlagBit) | Flag2Bit;
+ return *this;
+}
+
+template<typename T, typename T2>
+T *QBiPointer<T, T2>::asT1() const
+{
+ Q_ASSERT(isT1());
+ return (T *)(ptr_value & ~FlagsMask);
+}
+
+template<typename T, typename T2>
+T2 *QBiPointer<T, T2>::asT2() const
+{
+ Q_ASSERT(isT2());
+ return (T2 *)(ptr_value & ~FlagsMask);
+}
+
+QT_END_NAMESPACE
+
+#endif // QFLAGPOINTER_P_H
diff --git a/src/qml/qml/ftw/qhashedstring.cpp b/src/qml/qml/ftw/qhashedstring.cpp
new file mode 100644
index 0000000000..1f09d50ed3
--- /dev/null
+++ b/src/qml/qml/ftw/qhashedstring.cpp
@@ -0,0 +1,490 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qhashedstring_p.h"
+
+// This is a reimplementation of V8's string hash algorithm. It is significantly
+// faster to do it here than call into V8, but it adds the maintainence burden of
+// ensuring that the two hashes are identical. We Q_ASSERT() that the two return
+// the same value. If these asserts start to fail, the hash code needs to be
+// synced with V8.
+namespace String {
+ static const int kMaxArrayIndexSize = 10;
+ static const int kMaxHashCalcLength = 16383;
+ static const int kNofHashBitFields = 2;
+ static const int kHashShift = kNofHashBitFields;
+ static const int kIsNotArrayIndexMask = 1 << 1;
+ static const int kArrayIndexValueBits = 24;
+ static const int kArrayIndexHashLengthShift = kArrayIndexValueBits + kNofHashBitFields;
+ static const int kMaxCachedArrayIndexLength = 7;
+};
+
+template <typename schar>
+uint32_t calculateHash(const schar* chars, int length) {
+ if (length > String::kMaxHashCalcLength) {
+ // V8 trivial hash
+ return (length << String::kHashShift) | String::kIsNotArrayIndexMask;
+ }
+
+ uint32_t raw_running_hash = 0;
+ uint32_t array_index = 0;
+ bool is_array_index = (0 < length && length <= String::kMaxArrayIndexSize);
+ bool is_first_char = true;
+
+ int ii = 0;
+ for (;is_array_index && ii < length; ++ii) {
+ quint32 c = *chars++;
+
+ raw_running_hash += c;
+ raw_running_hash += (raw_running_hash << 10);
+ raw_running_hash ^= (raw_running_hash >> 6);
+
+ if (c < '0' || c > '9') {
+ is_array_index = false;
+ } else {
+ int d = c - '0';
+ if (is_first_char) {
+ is_first_char = false;
+ if (c == '0' && length > 1) {
+ is_array_index = false;
+ continue;
+ }
+ }
+ if (array_index > 429496729U - ((d + 2) >> 3)) {
+ is_array_index = false;
+ } else {
+ array_index = array_index * 10 + d;
+ }
+ }
+ }
+
+ for (;ii < length; ++ii) {
+ raw_running_hash += *chars++;
+ raw_running_hash += (raw_running_hash << 10);
+ raw_running_hash ^= (raw_running_hash >> 6);
+ }
+
+ if (is_array_index) {
+ array_index <<= String::kHashShift;
+ array_index |= length << String::kArrayIndexHashLengthShift;
+ return array_index;
+ } else {
+ raw_running_hash += (raw_running_hash << 3);
+ raw_running_hash ^= (raw_running_hash >> 11);
+ raw_running_hash += (raw_running_hash << 15);
+ if (raw_running_hash == 0) {
+ raw_running_hash = 27;
+ }
+
+ return (raw_running_hash << String::kHashShift) | String::kIsNotArrayIndexMask;
+ }
+}
+
+inline quint32 stringHash(const QChar* data, int length)
+{
+ quint32 rv = calculateHash<quint16>((quint16*)data, length) >> String::kHashShift;
+ Q_ASSERT(rv == v8::String::ComputeHash((uint16_t*)data, length));
+ return rv;
+}
+
+inline quint32 stringHash(const char *data, int length)
+{
+ quint32 rv = calculateHash<quint8>((quint8*)data, length) >> String::kHashShift;
+ Q_ASSERT(rv == v8::String::ComputeHash((char *)data, length));
+ return rv;
+}
+
+void QHashedString::computeHash() const
+{
+ m_hash = stringHash(constData(), length());
+}
+
+void QHashedStringRef::computeHash() const
+{
+ m_hash = stringHash(m_data, m_length);
+}
+
+void QHashedCStringRef::computeHash() const
+{
+ m_hash = stringHash(m_data, m_length);
+}
+
+/*
+ A QHash has initially around pow(2, MinNumBits) buckets. For
+ example, if MinNumBits is 4, it has 17 buckets.
+*/
+const int MinNumBits = 4;
+
+/*
+ The prime_deltas array is a table of selected prime values, even
+ though it doesn't look like one. The primes we are using are 1,
+ 2, 5, 11, 17, 37, 67, 131, 257, ..., i.e. primes in the immediate
+ surrounding of a power of two.
+
+ The primeForNumBits() function returns the prime associated to a
+ power of two. For example, primeForNumBits(8) returns 257.
+*/
+
+static const uchar prime_deltas[] = {
+ 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3,
+ 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0
+};
+
+static inline int primeForNumBits(int numBits)
+{
+ return (1 << numBits) + prime_deltas[numBits];
+}
+
+void QStringHashData::rehashToSize(int size, IteratorData first,
+ IteratorData (*Iterate)(const IteratorData &),
+ QStringHashNode *skip)
+{
+ short bits = qMax(MinNumBits, (int)numBits);
+ while (primeForNumBits(bits) < size) bits++;
+
+ if (bits > numBits)
+ rehashToBits(bits, first, Iterate, skip);
+}
+
+void QStringHashData::rehashToBits(short bits, IteratorData first,
+ IteratorData (*Iterate)(const IteratorData &),
+ QStringHashNode *skip)
+{
+ numBits = qMax(MinNumBits, (int)bits);
+
+ int nb = primeForNumBits(numBits);
+ if (nb == numBuckets && buckets)
+ return;
+
+ numBuckets = nb;
+
+#ifdef QSTRINGHASH_LINK_DEBUG
+ if (linkCount)
+ qFatal("QStringHash: Illegal attempt to rehash a linked hash.");
+#endif
+
+ delete [] buckets;
+ buckets = new QStringHashNode *[numBuckets];
+ ::memset(buckets, 0, sizeof(QStringHashNode *) * numBuckets);
+
+ IteratorData nodeList = first;
+ while (nodeList.n) {
+ if (nodeList.n != skip) {
+ int bucket = nodeList.n->hash % numBuckets;
+ nodeList.n->next = buckets[bucket];
+ buckets[bucket] = nodeList.n;
+ }
+
+ nodeList = Iterate(nodeList);
+ }
+}
+
+// Copy of QString's qMemCompare
+bool QHashedString::compare(const QChar *lhs, const QChar *rhs, int length)
+{
+ Q_ASSERT(lhs && rhs);
+ const quint16 *a = (const quint16 *)lhs;
+ const quint16 *b = (const quint16 *)rhs;
+
+ if (a == b || !length)
+ return true;
+
+ register union {
+ const quint16 *w;
+ const quint32 *d;
+ quintptr value;
+ } sa, sb;
+ sa.w = a;
+ sb.w = b;
+
+ // check alignment
+ if ((sa.value & 2) == (sb.value & 2)) {
+ // both addresses have the same alignment
+ if (sa.value & 2) {
+ // both addresses are not aligned to 4-bytes boundaries
+ // compare the first character
+ if (*sa.w != *sb.w)
+ return false;
+ --length;
+ ++sa.w;
+ ++sb.w;
+
+ // now both addresses are 4-bytes aligned
+ }
+
+ // both addresses are 4-bytes aligned
+ // do a fast 32-bit comparison
+ register const quint32 *e = sa.d + (length >> 1);
+ for ( ; sa.d != e; ++sa.d, ++sb.d) {
+ if (*sa.d != *sb.d)
+ return false;
+ }
+
+ // do we have a tail?
+ return (length & 1) ? *sa.w == *sb.w : true;
+ } else {
+ // one of the addresses isn't 4-byte aligned but the other is
+ register const quint16 *e = sa.w + length;
+ for ( ; sa.w != e; ++sa.w, ++sb.w) {
+ if (*sa.w != *sb.w)
+ return false;
+ }
+ }
+ return true;
+}
+
+// Unicode stuff
+static inline bool isUnicodeNonCharacter(uint ucs4)
+{
+ // Unicode has a couple of "non-characters" that one can use internally,
+ // but are not allowed to be used for text interchange.
+ //
+ // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF,
+ // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and
+ // U+FDEF (inclusive)
+
+ return (ucs4 & 0xfffe) == 0xfffe
+ || (ucs4 - 0xfdd0U) < 16;
+}
+
+static int utf8LengthFromUtf16(const QChar *uc, int len)
+{
+ int length = 0;
+
+ int surrogate_high = -1;
+
+ const QChar *ch = uc;
+ int invalid = 0;
+
+ const QChar *end = ch + len;
+ while (ch < end) {
+ uint u = ch->unicode();
+ if (surrogate_high >= 0) {
+ if (u >= 0xdc00 && u < 0xe000) {
+ u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000;
+ surrogate_high = -1;
+ } else {
+ // high surrogate without low
+ ++ch;
+ ++invalid;
+ surrogate_high = -1;
+ continue;
+ }
+ } else if (u >= 0xdc00 && u < 0xe000) {
+ // low surrogate without high
+ ++ch;
+ ++invalid;
+ continue;
+ } else if (u >= 0xd800 && u < 0xdc00) {
+ surrogate_high = u;
+ ++ch;
+ continue;
+ }
+
+ if (u < 0x80) {
+ ++length;
+ } else {
+ if (u < 0x0800) {
+ ++length;
+ } else {
+ // is it one of the Unicode non-characters?
+ if (isUnicodeNonCharacter(u)) {
+ ++length;
+ ++ch;
+ ++invalid;
+ continue;
+ }
+
+ if (u > 0xffff) {
+ ++length;
+ ++length;
+ } else {
+ ++length;
+ }
+ ++length;
+ }
+ ++length;
+ }
+ ++ch;
+ }
+
+ return length;
+}
+
+// Writes the utf8 version of uc to output. uc is of length len.
+// There must be at least utf8LengthFromUtf16(uc, len) bytes in output.
+// A null terminator is not written.
+static void utf8FromUtf16(char *output, const QChar *uc, int len)
+{
+ uchar replacement = '?';
+ int surrogate_high = -1;
+
+ uchar* cursor = (uchar*)output;
+ const QChar *ch = uc;
+ int invalid = 0;
+
+ const QChar *end = ch + len;
+ while (ch < end) {
+ uint u = ch->unicode();
+ if (surrogate_high >= 0) {
+ if (u >= 0xdc00 && u < 0xe000) {
+ u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000;
+ surrogate_high = -1;
+ } else {
+ // high surrogate without low
+ *cursor = replacement;
+ ++ch;
+ ++invalid;
+ surrogate_high = -1;
+ continue;
+ }
+ } else if (u >= 0xdc00 && u < 0xe000) {
+ // low surrogate without high
+ *cursor = replacement;
+ ++ch;
+ ++invalid;
+ continue;
+ } else if (u >= 0xd800 && u < 0xdc00) {
+ surrogate_high = u;
+ ++ch;
+ continue;
+ }
+
+ if (u < 0x80) {
+ *cursor++ = (uchar)u;
+ } else {
+ if (u < 0x0800) {
+ *cursor++ = 0xc0 | ((uchar) (u >> 6));
+ } else {
+ // is it one of the Unicode non-characters?
+ if (isUnicodeNonCharacter(u)) {
+ *cursor++ = replacement;
+ ++ch;
+ ++invalid;
+ continue;
+ }
+
+ if (u > 0xffff) {
+ *cursor++ = 0xf0 | ((uchar) (u >> 18));
+ *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f);
+ } else {
+ *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f);
+ }
+ *cursor++ = 0x80 | (((uchar) (u >> 6)) & 0x3f);
+ }
+ *cursor++ = 0x80 | ((uchar) (u&0x3f));
+ }
+ ++ch;
+ }
+}
+
+void QHashedStringRef::computeUtf8Length() const
+{
+ if (m_length)
+ m_utf8length = utf8LengthFromUtf16(m_data, m_length);
+ else
+ m_utf8length = 0;
+}
+
+QHashedStringRef QHashedStringRef::mid(int offset, int length) const
+{
+ Q_ASSERT(offset < m_length);
+ return QHashedStringRef(m_data + offset,
+ (length == -1 || (offset + length) > m_length)?(m_length - offset):length);
+}
+
+bool QHashedStringRef::endsWith(const QString &s) const
+{
+ return s.length() < m_length &&
+ QHashedString::compare(s.constData(), m_data + m_length - s.length(), s.length());
+}
+
+bool QHashedStringRef::startsWith(const QString &s) const
+{
+ return s.length() < m_length &&
+ QHashedString::compare(s.constData(), m_data, s.length());
+}
+
+QString QHashedStringRef::toString() const
+{
+ if (m_length == 0)
+ return QString();
+ return QString(m_data, m_length);
+}
+
+QByteArray QHashedStringRef::toUtf8() const
+{
+ if (m_length == 0)
+ return QByteArray();
+
+ QByteArray result;
+ result.resize(utf8length());
+ writeUtf8(result.data());
+ return result;
+}
+
+void QHashedStringRef::writeUtf8(char *output) const
+{
+ if (m_length) {
+ int ulen = utf8length();
+ if (ulen == m_length) {
+ // Must be a latin1 string
+ uchar *o = (uchar *)output;
+ const QChar *c = m_data;
+ while (ulen--)
+ *o++ = (uchar)((*c++).unicode());
+ } else {
+ utf8FromUtf16(output, m_data, m_length);
+ }
+ }
+}
+
+QString QHashedCStringRef::toUtf16() const
+{
+ if (m_length == 0)
+ return QString();
+
+ QString rv;
+ rv.resize(m_length);
+ writeUtf16((uint16_t*)rv.data());
+ return rv;
+}
+
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
new file mode 100644
index 0000000000..f575285ff6
--- /dev/null
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -0,0 +1,1418 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QHASHEDSTRING_P_H
+#define QHASHEDSTRING_P_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/qstring.h>
+#include <private/qv8_p.h>
+
+#include <private/qflagpointer_p.h>
+
+QT_BEGIN_NAMESPACE
+
+// Enable this to debug hash linking assumptions.
+// #define QSTRINGHASH_LINK_DEBUG
+
+class QHashedStringRef;
+class Q_AUTOTEST_EXPORT QHashedString : public QString
+{
+public:
+ inline QHashedString();
+ inline QHashedString(const QString &string);
+ inline QHashedString(const QString &string, quint32);
+ inline QHashedString(const QHashedString &string);
+
+ inline QHashedString &operator=(const QHashedString &string);
+ inline bool operator==(const QHashedString &string) const;
+ inline bool operator==(const QHashedStringRef &string) const;
+
+ inline quint32 hash() const;
+ inline quint32 existingHash() const;
+
+ static inline bool isUpper(const QChar &);
+
+ static bool compare(const QChar *lhs, const QChar *rhs, int length);
+ static inline bool compare(const QChar *lhs, const char *rhs, int length);
+ static inline bool compare(const char *lhs, const char *rhs, int length);
+private:
+ friend class QHashedStringRef;
+ friend class QStringHashNode;
+
+ void computeHash() const;
+ mutable quint32 m_hash;
+};
+
+class Q_AUTOTEST_EXPORT QHashedV8String
+{
+public:
+ inline QHashedV8String();
+ explicit inline QHashedV8String(v8::Handle<v8::String>);
+ inline QHashedV8String(const QHashedV8String &string);
+ inline QHashedV8String &operator=(const QHashedV8String &other);
+
+ inline bool operator==(const QHashedV8String &string);
+
+ inline quint32 hash() const;
+ inline int length() const;
+ inline quint32 symbolId() const;
+
+ inline v8::Handle<v8::String> string() const;
+
+ inline QString toString() const;
+
+private:
+ v8::String::CompleteHashData m_hash;
+ v8::Handle<v8::String> m_string;
+};
+
+class QHashedCStringRef;
+class Q_AUTOTEST_EXPORT QHashedStringRef
+{
+public:
+ inline QHashedStringRef();
+ inline QHashedStringRef(const QString &);
+ inline QHashedStringRef(const QStringRef &);
+ inline QHashedStringRef(const QChar *, int);
+ inline QHashedStringRef(const QChar *, int, quint32);
+ inline QHashedStringRef(const QHashedString &);
+ inline QHashedStringRef(const QHashedStringRef &);
+ inline QHashedStringRef &operator=(const QHashedStringRef &);
+
+ inline bool operator==(const QString &string) const;
+ inline bool operator==(const QHashedString &string) const;
+ inline bool operator==(const QHashedStringRef &string) const;
+ inline bool operator==(const QHashedCStringRef &string) const;
+ inline bool operator!=(const QString &string) const;
+ inline bool operator!=(const QHashedString &string) const;
+ inline bool operator!=(const QHashedStringRef &string) const;
+ inline bool operator!=(const QHashedCStringRef &string) const;
+
+ inline quint32 hash() const;
+
+ inline const QChar &at(int) const;
+ inline const QChar *constData() const;
+ bool startsWith(const QString &) const;
+ bool endsWith(const QString &) const;
+ QHashedStringRef mid(int, int) const;
+
+ inline bool isEmpty() const;
+ inline int length() const;
+ inline bool startsWithUpper() const;
+
+ QString toString() const;
+
+ inline int utf8length() const;
+ QByteArray toUtf8() const;
+ void writeUtf8(char *) const;
+private:
+ friend class QHashedString;
+
+ void computeHash() const;
+ void computeUtf8Length() const;
+
+ const QChar *m_data;
+ int m_length;
+ mutable int m_utf8length;
+ mutable quint32 m_hash;
+};
+
+class Q_AUTOTEST_EXPORT QHashedCStringRef
+{
+public:
+ inline QHashedCStringRef();
+ inline QHashedCStringRef(const char *, int);
+ inline QHashedCStringRef(const char *, int, quint32);
+ inline QHashedCStringRef(const QHashedCStringRef &);
+
+ inline quint32 hash() const;
+
+ inline const char *constData() const;
+ inline int length() const;
+
+ QString toUtf16() const;
+ inline int utf16length() const;
+ inline void writeUtf16(QChar *) const;
+ inline void writeUtf16(uint16_t *) const;
+private:
+ friend class QHashedStringRef;
+
+ void computeHash() const;
+
+ const char *m_data;
+ int m_length;
+ mutable quint32 m_hash;
+};
+
+class QStringHashData;
+class Q_AUTOTEST_EXPORT QStringHashNode
+{
+public:
+ QStringHashNode()
+ : length(0), hash(0), symbolId(0), ckey(0)
+ {
+ }
+
+ QStringHashNode(const QHashedString &key)
+ : length(key.length()), hash(key.hash()), symbolId(0)
+ {
+ strData = const_cast<QHashedString &>(key).data_ptr();
+ setQString(true);
+ strData->ref.ref();
+ }
+
+ QStringHashNode(const QHashedCStringRef &key)
+ : length(key.length()), hash(key.hash()), symbolId(0), ckey(key.constData())
+ {
+ }
+
+ QStringHashNode(const QStringHashNode &o)
+ : length(o.length), hash(o.hash), symbolId(o.symbolId), ckey(o.ckey)
+ {
+ setQString(o.isQString());
+ if (isQString()) { strData->ref.ref(); }
+ }
+
+ ~QStringHashNode()
+ {
+ if (isQString()) { if (!strData->ref.deref()) free(strData); }
+ }
+
+ QFlagPointer<QStringHashNode> next;
+
+ qint32 length;
+ quint32 hash;
+ quint32 symbolId;
+
+ union {
+ const char *ckey;
+ QStringData *strData;
+ };
+
+ bool isQString() const { return next.flag(); }
+ void setQString(bool v) { if (v) next.setFlag(); else next.clearFlag(); }
+
+ inline char *cStrData() const { return (char *)ckey; }
+ inline uint16_t *utf16Data() const { return (uint16_t *)strData->data(); }
+
+ inline bool equals(v8::Handle<v8::String> string) {
+ return isQString()?string->Equals(utf16Data(), length):
+ string->Equals(cStrData(), length);
+ }
+
+ inline bool symbolEquals(const QHashedV8String &string) {
+ Q_ASSERT(string.symbolId() != 0);
+ return length == string.length() && hash == string.hash() &&
+ (string.symbolId() == symbolId || equals(string.string()));
+ }
+
+ inline bool equals(const QHashedV8String &string) {
+ return length == string.length() && hash == string.hash() &&
+ equals(string.string());
+ }
+
+ inline bool equals(const QHashedStringRef &string) {
+ return length == string.length() &&
+ hash == string.hash() &&
+ (isQString()?QHashedString::compare(string.constData(), (QChar *)utf16Data(), length):
+ QHashedString::compare(string.constData(), cStrData(), length));
+ }
+
+ inline bool equals(const QHashedCStringRef &string) {
+ return length == string.length() &&
+ hash == string.hash() &&
+ (isQString()?QHashedString::compare((QChar *)utf16Data(), string.constData(), length):
+ QHashedString::compare(string.constData(), cStrData(), length));
+ }
+};
+
+class Q_AUTOTEST_EXPORT QStringHashData
+{
+public:
+ QStringHashData()
+ : buckets(0), numBuckets(0), size(0), numBits(0)
+#ifdef QSTRINGHASH_LINK_DEBUG
+ , linkCount(0)
+#endif
+ {}
+
+ QStringHashNode **buckets;
+ int numBuckets;
+ int size;
+ short numBits;
+#ifdef QSTRINGHASH_LINK_DEBUG
+ int linkCount;
+#endif
+
+ struct IteratorData {
+ IteratorData() : n(0), p(0) {}
+ QStringHashNode *n;
+ void *p;
+ };
+ void rehashToBits(short, IteratorData, IteratorData (*Iterate)(const IteratorData &),
+ QStringHashNode *skip = 0);
+ void rehashToSize(int, IteratorData, IteratorData (*Iterate)(const IteratorData &),
+ QStringHashNode *skip = 0);
+
+private:
+ QStringHashData(const QStringHashData &);
+ QStringHashData &operator=(const QStringHashData &);
+};
+
+template<class T>
+class QStringHash
+{
+public:
+ struct Node : public QStringHashNode {
+ Node(const QHashedString &key, const T &value) : QStringHashNode(key), value(value) {}
+ Node(const QHashedCStringRef &key, const T &value) : QStringHashNode(key), value(value) {}
+ Node(const Node &o) : QStringHashNode(o), value(o.value) {}
+ Node() {}
+ T value;
+ };
+ struct NewedNode : public Node {
+ NewedNode(const QHashedString &key, const T &value) : Node(key, value), nextNewed(0) {}
+ NewedNode(const QHashedCStringRef &key, const T &value) : Node(key, value), nextNewed(0) {}
+ NewedNode(const Node &o) : Node(o), nextNewed(0) {}
+ NewedNode *nextNewed;
+ };
+ struct ReservedNodePool
+ {
+ ReservedNodePool() : count(0), used(0), nodes(0) {}
+ ~ReservedNodePool() { delete [] nodes; }
+ int count;
+ int used;
+ Node *nodes;
+ };
+
+ QStringHashData data;
+ NewedNode *newedNodes;
+ ReservedNodePool *nodePool;
+ const QStringHash<T> *link;
+
+ inline Node *findNode(const QString &) const;
+ inline Node *findNode(const QHashedString &) const;
+ inline Node *findNode(const QHashedStringRef &) const;
+ inline Node *findNode(const QHashedCStringRef &) const;
+ inline Node *findNode(const QHashedV8String &) const;
+ inline Node *findSymbolNode(const QHashedV8String &) const;
+ inline Node *createNode(const Node &o);
+ inline Node *createNode(const QHashedString &, const T &);
+ inline Node *createNode(const QHashedCStringRef &, const T &);
+
+ inline Node *takeNode(const QHashedString &key, const T &value);
+ inline Node *takeNode(const QHashedCStringRef &key, const T &value);
+ inline Node *takeNode(const Node &o);
+
+ inline void copy(const QStringHash<T> &);
+
+ inline QStringHashData::IteratorData iterateFirst() const;
+ static inline QStringHashData::IteratorData iterateNext(const QStringHashData::IteratorData &);
+
+public:
+ inline QStringHash();
+ inline QStringHash(const QStringHash &);
+ inline ~QStringHash();
+
+ QStringHash &operator=(const QStringHash<T> &);
+
+ void copyAndReserve(const QStringHash<T> &other, int additionalReserve);
+ void linkAndReserve(const QStringHash<T> &other, int additionalReserve);
+
+ inline bool isEmpty() const;
+ inline void clear();
+ inline int count() const;
+
+ inline int numBuckets() const;
+ inline bool isLinked() const;
+
+ class ConstIterator {
+ public:
+ inline ConstIterator();
+ inline ConstIterator(const QStringHashData::IteratorData &);
+
+ inline ConstIterator &operator++();
+
+ inline bool operator==(const ConstIterator &o) const;
+ inline bool operator!=(const ConstIterator &o) const;
+
+ inline QHashedString key() const;
+ inline const T &value() const;
+ inline const T &operator*() const;
+
+ inline Node *node() const;
+ private:
+ QStringHashData::IteratorData d;
+ };
+
+ inline void insert(const QString &, const T &);
+ inline void insert(const QHashedString &, const T &);
+ inline void insert(const QHashedStringRef &, const T &);
+ inline void insert(const QHashedCStringRef &, const T &);
+ inline void insert(const ConstIterator &);
+
+ inline T *value(const QString &) const;
+ inline T *value(const QHashedString &) const;
+ inline T *value(const QHashedStringRef &) const;
+ inline T *value(const QHashedV8String &) const;
+ inline T *value(const QHashedCStringRef &) const;
+ inline T *value(const ConstIterator &) const;
+
+ inline bool contains(const QString &) const;
+ inline bool contains(const QHashedString &) const;
+ inline bool contains(const QHashedStringRef &) const;
+ inline bool contains(const QHashedCStringRef &) const;
+ inline bool contains(const ConstIterator &) const;
+
+ inline T &operator[](const QString &);
+ inline T &operator[](const QHashedString &);
+ inline T &operator[](const QHashedStringRef &);
+ inline T &operator[](const QHashedCStringRef &);
+
+ inline ConstIterator begin() const;
+ inline ConstIterator end() const;
+
+ inline void reserve(int);
+};
+
+template<class T>
+QStringHash<T>::QStringHash()
+: newedNodes(0), nodePool(0), link(0)
+{
+}
+
+template<class T>
+QStringHash<T>::QStringHash(const QStringHash<T> &other)
+: newedNodes(0), nodePool(0), link(0)
+{
+ data.numBits = other.data.numBits;
+ data.size = other.data.size;
+ reserve(other.count());
+ copy(other);
+}
+
+template<class T>
+QStringHash<T> &QStringHash<T>::operator=(const QStringHash<T> &other)
+{
+ if (&other == this)
+ return *this;
+
+ clear();
+
+ data.numBits = other.data.numBits;
+ data.size = other.data.size;
+ reserve(other.count());
+ copy(other);
+
+ return *this;
+}
+
+template<class T>
+void QStringHash<T>::copyAndReserve(const QStringHash<T> &other, int additionalReserve)
+{
+ clear();
+ data.numBits = other.data.numBits;
+ reserve(other.count() + additionalReserve);
+ copy(other);
+}
+
+template<class T>
+void QStringHash<T>::linkAndReserve(const QStringHash<T> &other, int additionalReserve)
+{
+ clear();
+
+ if (other.count()) {
+ data.size = other.data.size;
+ data.rehashToSize(other.count() + additionalReserve, iterateFirst(), iterateNext);
+
+ if (data.numBuckets == other.data.numBuckets) {
+ nodePool = new ReservedNodePool;
+ nodePool->count = additionalReserve;
+ nodePool->used = 0;
+ nodePool->nodes = new Node[additionalReserve];
+
+#ifdef QSTRINGHASH_LINK_DEBUG
+ data.linkCount++;
+ const_cast<QStringHash<T>&>(other).data.linkCount++;
+#endif
+
+ for (int ii = 0; ii < data.numBuckets; ++ii) {
+ data.buckets[ii] = 0;
+ Node *n = (Node *)other.data.buckets[ii];
+ data.buckets[ii] = n;
+ }
+
+ link = &other;
+ return;
+ }
+
+ data.size = 0;
+ }
+
+ data.numBits = other.data.numBits;
+ reserve(other.count() + additionalReserve);
+ copy(other);
+}
+
+template<class T>
+QStringHash<T>::~QStringHash()
+{
+ clear();
+}
+
+template<class T>
+void QStringHash<T>::clear()
+{
+#ifdef QSTRINGHASH_LINK_DEBUG
+ if (link) {
+ data.linkCount--;
+ const_cast<QStringHash<T> *>(link)->data.linkCount--;
+ }
+
+ if (data.linkCount)
+ qFatal("QStringHash: Illegal attempt to clear a linked hash.");
+#endif
+
+ // Delete the individually allocated nodes
+ NewedNode *n = newedNodes;
+ while (n) {
+ NewedNode *c = n;
+ n = c->nextNewed;
+ delete c;
+ }
+ // Delete the pool allocated nodes
+ if (nodePool) delete nodePool;
+ delete [] data.buckets;
+
+ data.buckets = 0;
+ data.numBuckets = 0;
+ data.numBits = 0;
+ data.size = 0;
+
+ newedNodes = 0;
+ nodePool = 0;
+ link = 0;
+}
+
+template<class T>
+bool QStringHash<T>::isEmpty() const
+{
+ return data.size== 0;
+}
+
+template<class T>
+int QStringHash<T>::count() const
+{
+ return data.size;
+}
+
+template<class T>
+int QStringHash<T>::numBuckets() const
+{
+ return data.numBuckets;
+}
+
+template<class T>
+bool QStringHash<T>::isLinked() const
+{
+ return link != 0;
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::takeNode(const QHashedString &key, const T &value)
+{
+ if (nodePool && nodePool->used != nodePool->count) {
+ Node *rv = nodePool->nodes + nodePool->used++;
+ rv->length = key.length();
+ rv->hash = key.hash();
+ rv->strData = const_cast<QHashedString &>(key).data_ptr();
+ rv->strData->ref.ref();
+ rv->setQString(true);
+ rv->value = value;
+ return rv;
+ } else {
+ NewedNode *rv = new NewedNode(key, value);
+ rv->nextNewed = newedNodes;
+ newedNodes = rv;
+ return rv;
+ }
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::takeNode(const QHashedCStringRef &key, const T &value)
+{
+ if (nodePool && nodePool->used != nodePool->count) {
+ Node *rv = nodePool->nodes + nodePool->used++;
+ rv->length = key.length();
+ rv->hash = key.hash();
+ rv->ckey = key.constData();
+ rv->value = value;
+ return rv;
+ } else {
+ NewedNode *rv = new NewedNode(key, value);
+ rv->nextNewed = newedNodes;
+ newedNodes = rv;
+ return rv;
+ }
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::takeNode(const Node &o)
+{
+ if (nodePool && nodePool->used != nodePool->count) {
+ Node *rv = nodePool->nodes + nodePool->used++;
+ rv->length = o.length;
+ rv->hash = o.hash;
+ if (o.isQString()) {
+ rv->strData = o.strData;
+ rv->strData->ref.ref();
+ rv->setQString(true);
+ } else {
+ rv->ckey = o.ckey;
+ }
+ rv->symbolId = o.symbolId;
+ rv->value = o.value;
+ return rv;
+ } else {
+ NewedNode *rv = new NewedNode(o);
+ rv->nextNewed = newedNodes;
+ newedNodes = rv;
+ return rv;
+ }
+}
+
+template<class T>
+void QStringHash<T>::copy(const QStringHash<T> &other)
+{
+ Q_ASSERT(data.size == 0);
+
+ data.size = other.data.size;
+
+ // Ensure buckets array is created
+ data.rehashToBits(data.numBits, iterateFirst(), iterateNext);
+
+ if (other.link) {
+ for (ConstIterator iter = other.begin(); iter != other.end(); ++iter) {
+ Node *o = iter.node();
+ Node *n = o->isQString()?findNode(QHashedStringRef((QChar *)o->strData->data(), o->length, o->hash)):
+ findNode(QHashedCStringRef(o->ckey, o->length, o->hash));
+ if (!n) {
+ Node *mynode = takeNode(*o);
+ int bucket = mynode->hash % data.numBuckets;
+ mynode->next = data.buckets[bucket];
+ data.buckets[bucket] = mynode;
+ }
+ }
+ } else {
+ for (ConstIterator iter = other.begin(); iter != other.end(); ++iter) {
+ Node *o = iter.node();
+ Node *mynode = takeNode(*o);
+ int bucket = mynode->hash % data.numBuckets;
+ mynode->next = data.buckets[bucket];
+ data.buckets[bucket] = mynode;
+ }
+ }
+}
+
+template<class T>
+QStringHashData::IteratorData
+QStringHash<T>::iterateNext(const QStringHashData::IteratorData &d)
+{
+ QStringHash<T> *This = (QStringHash<T> *)d.p;
+ Node *node = (Node *)d.n;
+
+ if (This->nodePool && node >= This->nodePool->nodes &&
+ node < (This->nodePool->nodes + This->nodePool->used)) {
+ node--;
+ if (node < This->nodePool->nodes)
+ node = 0;
+ } else {
+ NewedNode *nn = (NewedNode *)node;
+ node = nn->nextNewed;
+
+ if (node == 0 && This->nodePool && This->nodePool->used)
+ node = This->nodePool->nodes + This->nodePool->used - 1;
+ }
+
+ if (node == 0 && This->link)
+ return This->link->iterateFirst();
+
+ QStringHashData::IteratorData rv;
+ rv.n = node;
+ rv.p = d.p;
+ return rv;
+}
+
+template<class T>
+QStringHashData::IteratorData QStringHash<T>::iterateFirst() const
+{
+ Node *n = 0;
+ if (newedNodes)
+ n = newedNodes;
+ else if (nodePool && nodePool->used)
+ n = nodePool->nodes + nodePool->used - 1;
+
+ if (n == 0 && link)
+ return link->iterateFirst();
+
+ QStringHashData::IteratorData rv;
+ rv.n = n;
+ rv.p = const_cast<QStringHash<T> *>(this);
+ return rv;
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::createNode(const Node &o)
+{
+ Node *n = takeNode(o);
+
+ if (data.size >= data.numBuckets)
+ data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n);
+
+ int bucket = n->hash % data.numBuckets;
+ n->next = data.buckets[bucket];
+ data.buckets[bucket] = n;
+
+ data.size++;
+
+ return n;
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::createNode(const QHashedString &key, const T &value)
+{
+ Node *n = takeNode(key, value);
+
+ if (data.size >= data.numBuckets)
+ data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n);
+
+ int bucket = key.hash() % data.numBuckets;
+ n->next = data.buckets[bucket];
+ data.buckets[bucket] = n;
+
+ data.size++;
+
+ return n;
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::createNode(const QHashedCStringRef &key, const T &value)
+{
+ Node *n = takeNode(key, value);
+
+ if (data.size >= data.numBuckets)
+ data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n);
+
+ int bucket = key.hash() % data.numBuckets;
+ n->next = data.buckets[bucket];
+ data.buckets[bucket] = n;
+
+ data.size++;
+
+ return n;
+}
+
+template<class T>
+void QStringHash<T>::insert(const QString &key, const T &value)
+{
+ QHashedStringRef ch(key);
+ // If this is a linked hash, we can't rely on owning the node, so we always
+ // create a new one.
+ Node *n = link?0:findNode(key);
+ if (n) n->value = value;
+ else createNode(QHashedString(key, ch.hash()), value);
+}
+
+template<class T>
+void QStringHash<T>::insert(const QHashedString &key, const T &value)
+{
+ // If this is a linked hash, we can't rely on owning the node, so we always
+ // create a new one.
+ Node *n = link?0:findNode(key);
+ if (n) n->value = value;
+ else createNode(key, value);
+}
+
+template<class T>
+void QStringHash<T>::insert(const QHashedStringRef &key, const T &value)
+{
+ // If this is a linked hash, we can't rely on owning the node, so we always
+ // create a new one.
+ Node *n = link?0:findNode(key);
+ if (n) n->value = value;
+ else createNode(key, value);
+}
+
+template<class T>
+void QStringHash<T>::insert(const QHashedCStringRef &key, const T &value)
+{
+ // If this is a linked hash, we can't rely on owning the node, so we always
+ // create a new one.
+ Node *n = link?0:findNode(key);
+ if (n) n->value = value;
+ else createNode(key, value);
+}
+
+template<class T>
+void QStringHash<T>::insert(const ConstIterator &key)
+{
+ // If this is a linked hash, we can't rely on owning the node, so we always
+ // create a new one.
+ if (key.node()->isQString()) {
+ QHashedStringRef str((QChar *)key.node()->strData->data(), key.node()->length,
+ key.node()->hash);
+
+ Node *n = link?0:findNode(str);
+ if (n) n->value = key.node()->value;
+ else createNode(*key.node());
+ } else {
+ QHashedCStringRef str(key.node()->ckey, key.node()->length, key.node()->hash);
+
+ Node *n = link?0:findNode(str);
+ if (n) n->value = key.node()->value;
+ else createNode(str, key.node()->value);
+ }
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::findNode(const QString &string) const
+{
+ return findNode(QHashedStringRef(string));
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedString &string) const
+{
+ return findNode(QHashedStringRef(string.constData(), string.length(), string.hash()));
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedStringRef &string) const
+{
+ QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0;
+ while (node && !node->equals(string))
+ node = (*node->next);
+
+ return (Node *)node;
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedCStringRef &string) const
+{
+ QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0;
+ while (node && !node->equals(string))
+ node = (*node->next);
+
+ return (Node *)node;
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedV8String &string) const
+{
+ QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0;
+ while (node && !node->equals(string))
+ node = (*node->next);
+
+ return (Node *)node;
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::findSymbolNode(const QHashedV8String &string) const
+{
+ Q_ASSERT(string.symbolId() != 0);
+
+ QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0;
+ while (node && !node->symbolEquals(string))
+ node = (*node->next);
+
+ if (node)
+ node->symbolId = string.symbolId();
+
+ return (Node *)node;
+}
+
+template<class T>
+T *QStringHash<T>::value(const QString &key) const
+{
+ Node *n = findNode(key);
+ return n?&n->value:0;
+}
+
+template<class T>
+T *QStringHash<T>::value(const QHashedString &key) const
+{
+ Node *n = findNode(key);
+ return n?&n->value:0;
+}
+
+template<class T>
+T *QStringHash<T>::value(const QHashedStringRef &key) const
+{
+ Node *n = findNode(key);
+ return n?&n->value:0;
+}
+
+template<class T>
+T *QStringHash<T>::value(const QHashedCStringRef &key) const
+{
+ Node *n = findNode(key);
+ return n?&n->value:0;
+}
+
+template<class T>
+T *QStringHash<T>::value(const ConstIterator &iter) const
+{
+ Node *n = iter.node();
+ if (n->isQString())
+ return value(QHashedStringRef((QChar *)n->strData->data(), n->length, n->hash));
+ else
+ return value(QHashedCStringRef(n->ckey, n->length, n->hash));
+}
+
+template<class T>
+T *QStringHash<T>::value(const QHashedV8String &string) const
+{
+ Node *n = string.symbolId()?findSymbolNode(string):findNode(string);
+ return n?&n->value:0;
+}
+
+template<class T>
+bool QStringHash<T>::contains(const QString &s) const
+{
+ return 0 != value(s);
+}
+
+template<class T>
+bool QStringHash<T>::contains(const QHashedString &s) const
+{
+ return 0 != value(s);
+}
+
+template<class T>
+bool QStringHash<T>::contains(const QHashedStringRef &s) const
+{
+ return 0 != value(s);
+}
+
+template<class T>
+bool QStringHash<T>::contains(const QHashedCStringRef &s) const
+{
+ return 0 != value(s);
+}
+
+template<class T>
+bool QStringHash<T>::contains(const ConstIterator &s) const
+{
+ return 0 != value(s);
+}
+
+template<class T>
+T &QStringHash<T>::operator[](const QString &key)
+{
+ QHashedStringRef cs(key);
+ Node *n = findNode(cs);
+ if (n) return n->value;
+ else return createNode(QHashedString(key, cs.hash()), T())->value;
+}
+
+template<class T>
+T &QStringHash<T>::operator[](const QHashedString &key)
+{
+ Node *n = findNode(key);
+ if (n) return n->value;
+ else return createNode(key, T())->value;
+}
+
+template<class T>
+T &QStringHash<T>::operator[](const QHashedStringRef &key)
+{
+ Node *n = findNode(key);
+ if (n) return n->value;
+ else return createNode(key, T())->value;
+}
+
+template<class T>
+T &QStringHash<T>::operator[](const QHashedCStringRef &key)
+{
+ Node *n = findNode(key);
+ if (n) return n->value;
+ else return createNode(key, T())->value;
+}
+
+template<class T>
+void QStringHash<T>::reserve(int n)
+{
+ if (nodePool || 0 == n)
+ return;
+
+ nodePool = new ReservedNodePool;
+ nodePool->count = n;
+ nodePool->used = 0;
+ nodePool->nodes = new Node[n];
+
+ data.rehashToSize(n, iterateFirst(), iterateNext);
+}
+
+template<class T>
+QStringHash<T>::ConstIterator::ConstIterator()
+{
+}
+
+template<class T>
+QStringHash<T>::ConstIterator::ConstIterator(const QStringHashData::IteratorData &d)
+: d(d)
+{
+}
+
+template<class T>
+typename QStringHash<T>::ConstIterator &QStringHash<T>::ConstIterator::operator++()
+{
+ d = QStringHash<T>::iterateNext(d);
+ return *this;
+}
+
+template<class T>
+bool QStringHash<T>::ConstIterator::operator==(const ConstIterator &o) const
+{
+ return d.n == o.d.n;
+}
+
+template<class T>
+bool QStringHash<T>::ConstIterator::operator!=(const ConstIterator &o) const
+{
+ return d.n != o.d.n;
+}
+
+template<class T>
+QHashedString QStringHash<T>::ConstIterator::key() const
+{
+ Node *n = (Node *)d.n;
+ if (n->isQString()) {
+ return QHashedString(QString((QChar *)n->strData->data(), n->length), n->hash);
+ } else {
+ return QHashedString(QString::fromLatin1(n->ckey, n->length), n->hash);
+ }
+}
+template<class T>
+const T &QStringHash<T>::ConstIterator::value() const
+{
+ Node *n = (Node *)d.n;
+ return n->value;
+}
+
+template<class T>
+const T &QStringHash<T>::ConstIterator::operator*() const
+{
+ Node *n = (Node *)d.n;
+ return n->value;
+}
+
+template<class T>
+typename QStringHash<T>::Node *QStringHash<T>::ConstIterator::node() const
+{
+ Node *n = (Node *)d.n;
+ return n;
+}
+
+template<class T>
+typename QStringHash<T>::ConstIterator QStringHash<T>::begin() const
+{
+ return ConstIterator(iterateFirst());
+}
+
+template<class T>
+typename QStringHash<T>::ConstIterator QStringHash<T>::end() const
+{
+ return ConstIterator();
+}
+
+inline uint qHash(const QHashedString &string)
+{
+ return uint(string.hash());
+}
+
+inline uint qHash(const QHashedStringRef &string)
+{
+ return uint(string.hash());
+}
+
+QHashedString::QHashedString()
+: QString(), m_hash(0)
+{
+}
+
+QHashedString::QHashedString(const QString &string)
+: QString(string), m_hash(0)
+{
+}
+
+QHashedString::QHashedString(const QString &string, quint32 hash)
+: QString(string), m_hash(hash)
+{
+}
+
+QHashedString::QHashedString(const QHashedString &string)
+: QString(string), m_hash(string.m_hash)
+{
+}
+
+QHashedString &QHashedString::operator=(const QHashedString &string)
+{
+ static_cast<QString &>(*this) = string;
+ m_hash = string.m_hash;
+ return *this;
+}
+
+bool QHashedString::operator==(const QHashedString &string) const
+{
+ return (string.m_hash == m_hash || !string.m_hash || !m_hash) &&
+ static_cast<const QString &>(*this) == static_cast<const QString &>(string);
+}
+
+bool QHashedString::operator==(const QHashedStringRef &string) const
+{
+ return length() == string.m_length &&
+ (string.m_hash == m_hash || !string.m_hash || !m_hash) &&
+ QHashedString::compare(constData(), string.m_data, string.m_length);
+}
+
+quint32 QHashedString::hash() const
+{
+ if (!m_hash) computeHash();
+ return m_hash;
+}
+
+quint32 QHashedString::existingHash() const
+{
+ return m_hash;
+}
+
+bool QHashedString::isUpper(const QChar &qc)
+{
+ ushort c = qc.unicode();
+ // Optimize for _, a-z and A-Z.
+ return ((c != '_' ) && (!(c >= 'a' && c <= 'z')) &&
+ ((c >= 'A' && c <= 'Z') || QChar::category(c) == QChar::Letter_Uppercase));
+}
+
+QHashedV8String::QHashedV8String()
+{
+}
+
+QHashedV8String::QHashedV8String(v8::Handle<v8::String> string)
+: m_hash(string->CompleteHash()), m_string(string)
+{
+ Q_ASSERT(!m_string.IsEmpty());
+}
+
+QHashedV8String::QHashedV8String(const QHashedV8String &string)
+: m_hash(string.m_hash), m_string(string.m_string)
+{
+}
+
+QHashedV8String &QHashedV8String::operator=(const QHashedV8String &other)
+{
+ m_hash = other.m_hash;
+ m_string = other.m_string;
+ return *this;
+}
+
+bool QHashedV8String::operator==(const QHashedV8String &string)
+{
+ return m_hash.hash == string.m_hash.hash && m_hash.length == string.m_hash.length &&
+ m_string.IsEmpty() == m_string.IsEmpty() &&
+ (m_string.IsEmpty() || m_string->StrictEquals(string.m_string));
+}
+
+quint32 QHashedV8String::hash() const
+{
+ return m_hash.hash;
+}
+
+int QHashedV8String::length() const
+{
+ return m_hash.length;
+}
+
+quint32 QHashedV8String::symbolId() const
+{
+ return m_hash.symbol_id;
+}
+
+v8::Handle<v8::String> QHashedV8String::string() const
+{
+ return m_string;
+}
+
+QString QHashedV8String::toString() const
+{
+ QString result;
+ result.reserve(m_hash.length);
+
+ for (int i = 0; i < m_hash.length; ++i)
+ result.append(m_string->GetCharacter(i));
+
+ return result;
+}
+
+QHashedStringRef::QHashedStringRef()
+: m_data(0), m_length(0), m_utf8length(-1), m_hash(0)
+{
+}
+
+QHashedStringRef::QHashedStringRef(const QString &str)
+: m_data(str.constData()), m_length(str.length()), m_utf8length(0), m_hash(0)
+{
+}
+
+QHashedStringRef::QHashedStringRef(const QStringRef &str)
+: m_data(str.constData()), m_length(str.length()), m_utf8length(0), m_hash(0)
+{
+}
+
+QHashedStringRef::QHashedStringRef(const QChar *data, int length)
+: m_data(data), m_length(length), m_utf8length(0), m_hash(0)
+{
+}
+
+QHashedStringRef::QHashedStringRef(const QChar *data, int length, quint32 hash)
+: m_data(data), m_length(length), m_utf8length(0), m_hash(hash)
+{
+}
+
+QHashedStringRef::QHashedStringRef(const QHashedString &string)
+: m_data(string.constData()), m_length(string.length()), m_utf8length(0), m_hash(string.m_hash)
+{
+}
+
+QHashedStringRef::QHashedStringRef(const QHashedStringRef &string)
+: m_data(string.m_data), m_length(string.m_length), m_utf8length(string.m_utf8length),
+ m_hash(string.m_hash)
+{
+}
+
+QHashedStringRef &QHashedStringRef::operator=(const QHashedStringRef &o)
+{
+ m_data = o.m_data;
+ m_length = o.m_length;
+ m_utf8length = o.m_utf8length;
+ m_hash = o.m_hash;
+ return *this;
+}
+
+bool QHashedStringRef::operator==(const QString &string) const
+{
+ return m_length == string.length() &&
+ QHashedString::compare(string.constData(), m_data, m_length);
+}
+
+bool QHashedStringRef::operator==(const QHashedString &string) const
+{
+ return m_length == string.length() &&
+ (m_hash == string.m_hash || !m_hash || !string.m_hash) &&
+ QHashedString::compare(string.constData(), m_data, m_length);
+}
+
+bool QHashedStringRef::operator==(const QHashedStringRef &string) const
+{
+ return m_length == string.m_length &&
+ (m_hash == string.m_hash || !m_hash || !string.m_hash) &&
+ QHashedString::compare(string.m_data, m_data, m_length);
+}
+
+bool QHashedStringRef::operator==(const QHashedCStringRef &string) const
+{
+ return m_length == string.m_length &&
+ (m_hash == string.m_hash || !m_hash || !string.m_hash) &&
+ QHashedString::compare(m_data, string.m_data, m_length);
+}
+
+bool QHashedStringRef::operator!=(const QString &string) const
+{
+ return m_length != string.length() ||
+ !QHashedString::compare(string.constData(), m_data, m_length);
+}
+
+bool QHashedStringRef::operator!=(const QHashedString &string) const
+{
+ return m_length != string.length() ||
+ (m_hash != string.m_hash && m_hash && string.m_hash) ||
+ !QHashedString::compare(string.constData(), m_data, m_length);
+}
+
+bool QHashedStringRef::operator!=(const QHashedStringRef &string) const
+{
+ return m_length != string.m_length ||
+ (m_hash != string.m_hash && m_hash && string.m_hash) ||
+ QHashedString::compare(string.m_data, m_data, m_length);
+}
+
+bool QHashedStringRef::operator!=(const QHashedCStringRef &string) const
+{
+ return m_length != string.m_length ||
+ (m_hash != string.m_hash && m_hash && string.m_hash) ||
+ QHashedString::compare(m_data, string.m_data, m_length);
+}
+
+const QChar &QHashedStringRef::at(int index) const
+{
+ Q_ASSERT(index < m_length);
+ return m_data[index];
+}
+
+const QChar *QHashedStringRef::constData() const
+{
+ return m_data;
+}
+
+bool QHashedStringRef::isEmpty() const
+{
+ return m_length == 0;
+}
+
+int QHashedStringRef::length() const
+{
+ return m_length;
+}
+
+int QHashedStringRef::utf8length() const
+{
+ if (m_utf8length < m_length)
+ computeUtf8Length();
+ return m_utf8length;
+}
+
+bool QHashedStringRef::startsWithUpper() const
+{
+ if (m_length < 1) return false;
+ return QHashedString::isUpper(m_data[0]);
+}
+
+quint32 QHashedStringRef::hash() const
+{
+ if (!m_hash) computeHash();
+ return m_hash;
+}
+
+QHashedCStringRef::QHashedCStringRef()
+: m_data(0), m_length(0), m_hash(0)
+{
+}
+
+QHashedCStringRef::QHashedCStringRef(const char *data, int length)
+: m_data(data), m_length(length), m_hash(0)
+{
+}
+
+QHashedCStringRef::QHashedCStringRef(const char *data, int length, quint32 hash)
+: m_data(data), m_length(length), m_hash(hash)
+{
+}
+
+QHashedCStringRef::QHashedCStringRef(const QHashedCStringRef &o)
+: m_data(o.m_data), m_length(o.m_length), m_hash(o.m_hash)
+{
+}
+
+quint32 QHashedCStringRef::hash() const
+{
+ if (!m_hash) computeHash();
+ return m_hash;
+}
+
+const char *QHashedCStringRef::constData() const
+{
+ return m_data;
+}
+
+int QHashedCStringRef::length() const
+{
+ return m_length;
+}
+
+int QHashedCStringRef::utf16length() const
+{
+ return m_length;
+}
+
+void QHashedCStringRef::writeUtf16(QChar *output) const
+{
+ writeUtf16((uint16_t *)output);
+}
+
+void QHashedCStringRef::writeUtf16(uint16_t *output) const
+{
+ int l = m_length;
+ const char *d = m_data;
+ while (l--)
+ *output++ = *d++;
+}
+
+bool QHashedString::compare(const QChar *lhs, const char *rhs, int length)
+{
+ Q_ASSERT(lhs && rhs);
+ const quint16 *l = (const quint16*)lhs;
+ while (length--)
+ if (*l++ != *rhs++) return false;
+ return true;
+}
+
+bool QHashedString::compare(const char *lhs, const char *rhs, int length)
+{
+ Q_ASSERT(lhs && rhs);
+ return 0 == ::memcmp(lhs, rhs, length);
+}
+
+QT_END_NAMESPACE
+
+#endif // QHASHEDSTRING_P_H
diff --git a/src/qml/qml/ftw/qhashfield_p.h b/src/qml/qml/ftw/qhashfield_p.h
new file mode 100644
index 0000000000..46df9a176c
--- /dev/null
+++ b/src/qml/qml/ftw/qhashfield_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QHASHFIELD_P_H
+#define QHASHFIELD_P_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>
+
+QT_BEGIN_NAMESPACE
+
+// QHashField can be used for doing coarse grained set testing, in
+// cases where you do not expect the set to contain the item. For
+// example where you would write:
+// QSet<QString> strings;
+// for (int ii = 0; ii < mystrings.count(); ++ii) {
+// if (strings.contains(mystrings.at(ii)))
+// qFatal("Duplication!");
+// strings.insert(mystrings);
+// }
+// You may write:
+// QHashField strings;
+// for (int ii = 0; ii < mystrings.count(); ++ii) {
+// if (strings.testAndSet(qHash(mystrings.at(ii)))) {
+// // The string *might* be duplicated
+// for (int jj = 0; jj < ii; ++jj) {
+// if (mystrings.at(ii) == mystrings.at(jj))
+// qFatal("Duplication!");
+// }
+// }
+// }
+// For small lists of things, where the hash is cheap to calculate
+// and you don't expect duplication this will be much faster.
+class QHashField {
+public:
+ inline QHashField();
+
+ inline void clear();
+
+ inline bool test(quint32 hash);
+ inline bool testAndSet(quint32 hash);
+private:
+ quint32 m_field;
+};
+
+QHashField::QHashField()
+: m_field(0)
+{
+}
+
+void QHashField::clear()
+{
+ m_field = 0;
+}
+
+bool QHashField::test(quint32 hash)
+{
+ return m_field & (1 << (hash % 31));
+}
+
+bool QHashField::testAndSet(quint32 hash)
+{
+ quint32 mask = 1 << (hash % 31);
+ bool rv = m_field & mask;
+ m_field |= mask;
+ return rv;
+}
+
+QT_END_NAMESPACE
+
+#endif // QHASHFIELD_P_H
diff --git a/src/qml/qml/ftw/qintrusivelist.cpp b/src/qml/qml/ftw/qintrusivelist.cpp
new file mode 100644
index 0000000000..5a1624f1f4
--- /dev/null
+++ b/src/qml/qml/ftw/qintrusivelist.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qintrusivelist_p.h"
+
+/*!
+\class QIntrusiveList
+\brief The QIntrusiveList class is a template class that provides a list of objects using static storage.
+\internal
+
+QIntrusiveList creates a linked list of objects. Adding and removing objects from the
+QIntrusiveList is a constant time operation and is very quick. The list performs no memory
+allocations, but does require the objects being added to the list to contain a QIntrusiveListNode
+instance for the list's use. Even so, for small lists QIntrusiveList uses less memory than Qt's
+other list classes.
+
+As QIntrusiveList uses storage inside the objects in the list, each object can only be in one
+list at a time. Objects are inserted by the insert() method. If the object is already
+in a list (including the one it is being inserted into) it is first removed, and then inserted
+at the head of the list. QIntrusiveList is a last-in-first-out list. That is, following an
+insert() the inserted object becomes the list's first() object.
+
+\code
+struct MyObject {
+ MyObject(int value) : value(value) {}
+
+ int value;
+ QIntrusiveListNode node;
+};
+typedef QIntrusiveList<MyObject, &MyObject::node> MyObjectList;
+
+void foo() {
+ MyObjectList list;
+
+ MyObject m0(0);
+ MyObject m1(1);
+ MyObject m2(2);
+
+ list.insert(&m0);
+ list.insert(&m1);
+ list.insert(&m2);
+
+ // QIntrusiveList is LIFO, so will print: 2... 1... 0...
+ for (MyObjectList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ qWarning() << iter->value;
+ }
+}
+\endcode
+*/
+
+
+/*!
+\fn QIntrusiveList::QIntrusiveList();
+
+Construct an empty list.
+*/
+
+/*!
+\fn QIntrusiveList::~QIntrusiveList();
+
+Destroy the list. All entries are removed.
+*/
+
+/*!
+\fn void QIntrusiveList::insert(N *object);
+
+Insert \a object into the list. If \a object is a member of this, or another list, it will be
+removed and inserted at the head of this list.
+*/
+
+/*!
+\fn void QIntrusiveList::remove(N *object);
+
+Remove \a object from the list. \a object must not be null.
+*/
+
+/*!
+\fn bool QIntrusiveList::contains(N *object) const
+
+Returns true if the list contains \a object; otherwise returns false.
+*/
+
+/*!
+\fn N *QIntrusiveList::first() const
+
+Returns the first entry in this list, or null if the list is empty.
+*/
+
+/*!
+\fn N *QIntrusiveList::next(N *current)
+
+Returns the next object after \a current, or null if \a current is the last object. \a current cannot be null.
+*/
+
+/*!
+\fn iterator QIntrusiveList::begin()
+
+Returns an STL-style interator pointing to the first item in the list.
+
+\sa end()
+*/
+
+/*!
+\fn iterator QIntrusiveList::end()
+
+Returns an STL-style iterator pointing to the imaginary item after the last item in the list.
+
+\sa begin()
+*/
+
+/*!
+iterator &QInplacelist::iterator::erase()
+
+Remove the current object from the list, and return an iterator to the next element.
+*/
+
+
+/*!
+\fn QIntrusiveListNode::QIntrusiveListNode()
+
+Create a QIntrusiveListNode.
+*/
+
+/*!
+\fn QIntrusiveListNode::~QIntrusiveListNode()
+
+Destroy the QIntrusiveListNode. If the node is in a list, it is removed.
+*/
+
+/*!
+\fn void QIntrusiveListNode::remove()
+
+If in a list, remove this node otherwise do nothing.
+*/
+
+/*!
+\fn bool QIntrusiveListNode::isInList() const
+
+Returns true if this node is in a list, false otherwise.
+*/
+
diff --git a/src/qml/qml/ftw/qintrusivelist_p.h b/src/qml/qml/ftw/qintrusivelist_p.h
new file mode 100644
index 0000000000..489b02d656
--- /dev/null
+++ b/src/qml/qml/ftw/qintrusivelist_p.h
@@ -0,0 +1,274 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QINTRUSIVELIST_P_H
+#define QINTRUSIVELIST_P_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>
+
+QT_BEGIN_NAMESPACE
+
+class QIntrusiveListNode;
+template<class N, QIntrusiveListNode N::*member>
+class QIntrusiveList
+{
+public:
+ inline QIntrusiveList();
+ inline ~QIntrusiveList();
+
+ inline bool isEmpty() const;
+ inline void insert(N *n);
+ inline void remove(N *n);
+ inline bool contains(N *) const;
+
+ class iterator {
+ public:
+ inline iterator();
+ inline iterator(N *value);
+
+ inline N *operator*() const;
+ inline N *operator->() const;
+ inline bool operator==(const iterator &other) const;
+ inline bool operator!=(const iterator &other) const;
+ inline iterator &operator++();
+
+ inline iterator &erase();
+
+ private:
+ N *_value;
+ };
+ typedef iterator Iterator;
+
+ inline N *first() const;
+ static inline N *next(N *current);
+
+ inline iterator begin();
+ inline iterator end();
+
+private:
+ static inline N *nodeToN(QIntrusiveListNode *node);
+
+ QIntrusiveListNode *__first;
+};
+
+class QIntrusiveListNode
+{
+public:
+ inline QIntrusiveListNode();
+ inline ~QIntrusiveListNode();
+
+ inline void remove();
+ inline bool isInList() const;
+
+ QIntrusiveListNode *_next;
+ QIntrusiveListNode**_prev;
+};
+
+template<class N, QIntrusiveListNode N::*member>
+QIntrusiveList<N, member>::iterator::iterator()
+: _value(0)
+{
+}
+
+template<class N, QIntrusiveListNode N::*member>
+QIntrusiveList<N, member>::iterator::iterator(N *value)
+: _value(value)
+{
+}
+
+template<class N, QIntrusiveListNode N::*member>
+N *QIntrusiveList<N, member>::iterator::operator*() const
+{
+ return _value;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+N *QIntrusiveList<N, member>::iterator::operator->() const
+{
+ return _value;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+bool QIntrusiveList<N, member>::iterator::operator==(const iterator &other) const
+{
+ return other._value == _value;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+bool QIntrusiveList<N, member>::iterator::operator!=(const iterator &other) const
+{
+ return other._value != _value;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+typename QIntrusiveList<N, member>::iterator &QIntrusiveList<N, member>::iterator::operator++()
+{
+ _value = QIntrusiveList<N, member>::next(_value);
+ return *this;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+typename QIntrusiveList<N, member>::iterator &QIntrusiveList<N, member>::iterator::erase()
+{
+ N *old = _value;
+ _value = QIntrusiveList<N, member>::next(_value);
+ (old->*member).remove();
+ return *this;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+QIntrusiveList<N, member>::QIntrusiveList()
+: __first(0)
+{
+}
+
+template<class N, QIntrusiveListNode N::*member>
+QIntrusiveList<N, member>::~QIntrusiveList()
+{
+ while (__first) __first->remove();
+}
+
+template<class N, QIntrusiveListNode N::*member>
+bool QIntrusiveList<N, member>::isEmpty() const
+{
+ return __first == 0;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+void QIntrusiveList<N, member>::insert(N *n)
+{
+ QIntrusiveListNode *nnode = &(n->*member);
+ nnode->remove();
+
+ nnode->_next = __first;
+ if (nnode->_next) nnode->_next->_prev = &nnode->_next;
+ __first = nnode;
+ nnode->_prev = &__first;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+void QIntrusiveList<N, member>::remove(N *n)
+{
+ QIntrusiveListNode *nnode = &(n->*member);
+ nnode->remove();
+}
+
+template<class N, QIntrusiveListNode N::*member>
+bool QIntrusiveList<N, member>::contains(N *n) const
+{
+ QIntrusiveListNode *nnode = __first;
+ while (nnode) {
+ if (nodeToN(nnode) == n)
+ return true;
+ nnode = nnode->_next;
+ }
+ return false;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+N *QIntrusiveList<N, member>::first() const
+{
+ return __first?nodeToN(__first):0;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+N *QIntrusiveList<N, member>::next(N *current)
+{
+ QIntrusiveListNode *nextnode = (current->*member)._next;
+ N *nextstruct = nextnode?nodeToN(nextnode):0;
+ return nextstruct;
+}
+
+template<class N, QIntrusiveListNode N::*member>
+typename QIntrusiveList<N, member>::iterator QIntrusiveList<N, member>::begin()
+{
+ return __first?iterator(nodeToN(__first)):iterator();
+}
+
+template<class N, QIntrusiveListNode N::*member>
+typename QIntrusiveList<N, member>::iterator QIntrusiveList<N, member>::end()
+{
+ return iterator();
+}
+
+template<class N, QIntrusiveListNode N::*member>
+N *QIntrusiveList<N, member>::nodeToN(QIntrusiveListNode *node)
+{
+ return (N *)((char *)node - ((char *)&(((N *)0)->*member) - (char *)0));
+}
+
+QIntrusiveListNode::QIntrusiveListNode()
+: _next(0), _prev(0)
+{
+}
+
+QIntrusiveListNode::~QIntrusiveListNode()
+{
+ remove();
+}
+
+void QIntrusiveListNode::remove()
+{
+ if (_prev) *_prev = _next;
+ if (_next) _next->_prev = _prev;
+ _prev = 0;
+ _next = 0;
+}
+
+bool QIntrusiveListNode::isInList() const
+{
+ return _prev != 0;
+}
+
+QT_END_NAMESPACE
+
+#endif // QINTRUSIVELIST_P_H
diff --git a/src/qml/qml/ftw/qlazilyallocated_p.h b/src/qml/qml/ftw/qlazilyallocated_p.h
new file mode 100644
index 0000000000..960d84d5e7
--- /dev/null
+++ b/src/qml/qml/ftw/qlazilyallocated_p.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLAZILYALLOCATED_P_H
+#define QLAZILYALLOCATED_P_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 <private/qflagpointer_p.h>
+
+QT_BEGIN_NAMESPACE
+
+template<typename T>
+class QLazilyAllocated {
+public:
+ inline QLazilyAllocated();
+ inline ~QLazilyAllocated();
+
+ inline bool isAllocated() const;
+
+ inline T *operator->() const;
+
+ inline T &value();
+ inline const T &value() const;
+
+ inline bool flag() const;
+ inline void setFlag();
+ inline void clearFlag();
+ inline void setFlagValue(bool);
+private:
+ mutable QFlagPointer<T> d;
+};
+
+template<typename T>
+QLazilyAllocated<T>::QLazilyAllocated()
+{
+}
+
+template<typename T>
+QLazilyAllocated<T>::~QLazilyAllocated()
+{
+ delete *d;
+}
+
+template<typename T>
+bool QLazilyAllocated<T>::isAllocated() const
+{
+ return !d.isNull();
+}
+
+template<typename T>
+T &QLazilyAllocated<T>::value()
+{
+ if (d.isNull()) d = new T;
+ return *(*d);
+}
+
+template<typename T>
+const T &QLazilyAllocated<T>::value() const
+{
+ if (d.isNull()) d = new T;
+ return *(*d);
+}
+
+template<typename T>
+T *QLazilyAllocated<T>::operator->() const
+{
+ return *d;
+}
+
+template<typename T>
+bool QLazilyAllocated<T>::flag() const
+{
+ return d.flag();
+}
+
+template<typename T>
+void QLazilyAllocated<T>::setFlag()
+{
+ d.setFlag();
+}
+
+template<typename T>
+void QLazilyAllocated<T>::clearFlag()
+{
+ d.clearFlag();
+}
+
+template<typename T>
+void QLazilyAllocated<T>::setFlagValue(bool v)
+{
+ d.setFlagValue(v);
+}
+
+QT_END_NAMESPACE
+
+#endif // QLAZILYALLOCATED_P_H
diff --git a/src/qml/qml/ftw/qpodvector_p.h b/src/qml/qml/ftw/qpodvector_p.h
new file mode 100644
index 0000000000..c96692667a
--- /dev/null
+++ b/src/qml/qml/ftw/qpodvector_p.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPODVECTOR_P_H
+#define QPODVECTOR_P_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 <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+template<class T, int Increment=1024>
+class QPODVector
+{
+public:
+ QPODVector()
+ : m_count(0), m_capacity(0), m_data(0) {}
+ ~QPODVector() { if (m_data) ::free(m_data); }
+
+ const T &at(int idx) const {
+ return m_data[idx];
+ }
+
+ T &operator[](int idx) {
+ return m_data[idx];
+ }
+
+ void clear() {
+ m_count = 0;
+ }
+
+ void prepend(const T &v) {
+ insert(0, v);
+ }
+
+ void append(const T &v) {
+ insert(m_count, v);
+ }
+
+ void insert(int idx, const T &v) {
+ if (m_count == m_capacity) {
+ m_capacity += Increment;
+ m_data = (T *)realloc(m_data, m_capacity * sizeof(T));
+ }
+ int moveCount = m_count - idx;
+ if (moveCount)
+ ::memmove(m_data + idx + 1, m_data + idx, moveCount * sizeof(T));
+ m_count++;
+ m_data[idx] = v;
+ }
+
+ void reserve(int count) {
+ if (count >= m_capacity) {
+ m_capacity = (count + (Increment-1)) & (0xFFFFFFFF - Increment + 1);
+ m_data = (T *)realloc(m_data, m_capacity * sizeof(T));
+ }
+ }
+
+ void insertBlank(int idx, int count) {
+ int newSize = m_count + count;
+ reserve(newSize);
+ int moveCount = m_count - idx;
+ if (moveCount)
+ ::memmove(m_data + idx + count, m_data + idx,
+ moveCount * sizeof(T));
+ m_count = newSize;
+ }
+
+ void remove(int idx, int count = 1) {
+ int moveCount = m_count - (idx + count);
+ if (moveCount)
+ ::memmove(m_data + idx, m_data + idx + count,
+ moveCount * sizeof(T));
+ m_count -= count;
+ }
+
+ void removeOne(const T &v) {
+ int idx = 0;
+ while (idx < m_count) {
+ if (m_data[idx] == v) {
+ remove(idx);
+ return;
+ }
+ ++idx;
+ }
+ }
+
+ int find(const T &v) {
+ for (int idx = 0; idx < m_count; ++idx)
+ if (m_data[idx] == v)
+ return idx;
+ return -1;
+ }
+
+ bool contains(const T &v) {
+ return find(v) != -1;
+ }
+
+ int count() const {
+ return m_count;
+ }
+
+ void copyAndClear(QPODVector<T,Increment> &other) {
+ if (other.m_data) ::free(other.m_data);
+ other.m_count = m_count;
+ other.m_capacity = m_capacity;
+ other.m_data = m_data;
+ m_count = 0;
+ m_capacity = 0;
+ m_data = 0;
+ }
+
+ QPODVector<T,Increment> &operator<<(const T &v) { append(v); return *this; }
+private:
+ QPODVector(const QPODVector &);
+ QPODVector &operator=(const QPODVector &);
+ int m_count;
+ int m_capacity;
+ T *m_data;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/qml/ftw/qpointervaluepair_p.h b/src/qml/qml/ftw/qpointervaluepair_p.h
new file mode 100644
index 0000000000..7b0caf49bc
--- /dev/null
+++ b/src/qml/qml/ftw/qpointervaluepair_p.h
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPOINTERVALUEPAIR_P_H
+#define QPOINTERVALUEPAIR_P_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 <private/qflagpointer_p.h>
+
+QT_BEGIN_NAMESPACE
+
+// QPointerValuePair is intended to help reduce the memory consumption of a class.
+// In the common case, QPointerValuePair behaves like a pointer. In this mode, it
+// consumes the same memory as a regular pointer.
+// Additionally, QPointerValuePair can store an arbitrary value type in *addition*
+// to the pointer. In this case, it uses slightly more memory than the pointer and
+// value type combined.
+// Consequently, this class is most useful in cases where a pointer is always stored
+// and a value type is rarely stored.
+template<typename P, typename V>
+class QPointerValuePair {
+public:
+ inline QPointerValuePair();
+ inline QPointerValuePair(P *);
+ inline ~QPointerValuePair();
+
+ inline bool isNull() const;
+
+ inline bool flag() const;
+ inline void setFlag();
+ inline void clearFlag();
+ inline void setFlagValue(bool);
+
+ inline QPointerValuePair<P, V> &operator=(P *);
+
+ inline P *operator->() const;
+ inline P *operator*() const;
+
+ inline bool hasValue() const;
+ inline V &value();
+ inline const V *constValue() const;
+
+private:
+ struct Value { P *pointer; V value; };
+ QBiPointer<P, Value> d;
+};
+
+template<typename P, typename V>
+QPointerValuePair<P, V>::QPointerValuePair()
+{
+}
+
+template<typename P, typename V>
+QPointerValuePair<P, V>::QPointerValuePair(P *p)
+: d(p)
+{
+}
+
+template<typename P, typename V>
+QPointerValuePair<P, V>::~QPointerValuePair()
+{
+ if (d.isT2()) delete d.asT2();
+}
+
+template<typename P, typename V>
+bool QPointerValuePair<P, V>::isNull() const
+{
+ if (d.isT1()) return 0 == d.asT1();
+ else return d.asT2()->pointer == 0;
+}
+
+template<typename P, typename V>
+bool QPointerValuePair<P, V>::flag() const
+{
+ return d.flag();
+}
+
+template<typename P, typename V>
+void QPointerValuePair<P, V>::setFlag()
+{
+ d.setFlag();
+}
+
+template<typename P, typename V>
+void QPointerValuePair<P, V>::clearFlag()
+{
+ d.clearFlag();
+}
+
+template<typename P, typename V>
+void QPointerValuePair<P, V>::setFlagValue(bool v)
+{
+ d.setFlagValue(v);
+}
+
+template<typename P, typename V>
+QPointerValuePair<P, V> &QPointerValuePair<P, V>::operator=(P *o)
+{
+ if (d.isT1()) d = o;
+ else d.asT2()->pointer = o;
+ return *this;
+}
+
+template<typename P, typename V>
+P *QPointerValuePair<P, V>::operator->() const
+{
+ if (d.isT1()) return d.asT1();
+ else return d.asT2()->pointer;
+}
+
+template<typename P, typename V>
+P *QPointerValuePair<P, V>::operator*() const
+{
+ if (d.isT1()) return d.asT1();
+ else return d.asT2()->pointer;
+}
+
+template<typename P, typename V>
+bool QPointerValuePair<P, V>::hasValue() const
+{
+ return d.isT2();
+}
+
+template<typename P, typename V>
+V &QPointerValuePair<P, V>::value()
+{
+ if (d.isT1()) {
+ P *p = d.asT1();
+ Value *value = new Value;
+ value->pointer = p;
+ d = value;
+ }
+
+ return d.asT2()->value;
+}
+
+// Will return null if hasValue() == false
+template<typename P, typename V>
+const V *QPointerValuePair<P, V>::constValue() const
+{
+ if (d.isT2()) return &d.asT2()->value;
+ else return 0;
+}
+
+QT_END_NAMESPACE
+
+#endif // QPOINTERVALUEPAIR_P_H
diff --git a/src/qml/qml/ftw/qqmlpool.cpp b/src/qml/qml/ftw/qqmlpool.cpp
new file mode 100644
index 0000000000..6fd11d4b1e
--- /dev/null
+++ b/src/qml/qml/ftw/qqmlpool.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpool_p.h"
+
+// #define POOL_DEBUG
+
+QT_BEGIN_NAMESPACE
+
+void QQmlPool::newpage()
+{
+#ifdef POOL_DEBUG
+ qWarning("QQmlPool: Allocating page");
+#endif
+
+ Page *page = (Page *)malloc(sizeof(Page));
+ page->header.next = _page;
+ page->header.free = page->memory;
+ _page = page;
+}
+
+void QQmlPool::clear()
+{
+#ifdef POOL_DEBUG
+ int count = 0;
+#endif
+
+ Class *c = _classList;
+ while (c) {
+ Class *n = c->_next;
+ c->_destroy(c);
+#ifdef POOL_DEBUG
+ ++count;
+#endif
+ c = n;
+ }
+
+#ifdef POOL_DEBUG
+ qWarning("QQmlPool: Destroyed %d objects", count);
+#endif
+
+ Page *p = _page;
+ while (p) {
+ Page *n = p->header.next;
+ free(p);
+ p = n;
+ }
+
+ _classList = 0;
+ _page = 0;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/ftw/qqmlpool_p.h b/src/qml/qml/ftw/qqmlpool_p.h
new file mode 100644
index 0000000000..e4fa03ce34
--- /dev/null
+++ b/src/qml/qml/ftw/qqmlpool_p.h
@@ -0,0 +1,278 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPOOL_P_H
+#define QQMLPOOL_P_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 <QtQml/qtqmlglobal.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qurl.h>
+
+QT_BEGIN_NAMESPACE
+
+// Exported for QtQuick1
+class Q_QML_EXPORT QQmlPool
+{
+public:
+ // The class has a destructor that needs to be called
+ class Class {
+ public:
+ inline QQmlPool *pool() const;
+
+ private:
+ void *operator new(size_t);
+ void *operator new(size_t, void *m) { return m; }
+ friend class QQmlPool;
+
+ QQmlPool *_pool;
+ Class *_next;
+ void (*_destroy)(Class *);
+ };
+
+ // The class is plain old data and no destructor needs to
+ // be called
+ class POD {
+ public:
+ inline QQmlPool *pool() const;
+
+ private:
+ void *operator new(size_t);
+ void *operator new(size_t, void *m) { return m; }
+ friend class QQmlPool;
+
+ QQmlPool *_pool;
+ };
+
+ inline QQmlPool();
+ inline ~QQmlPool();
+
+ void clear();
+
+ template<typename T>
+ inline T *New();
+ template<typename T>
+ inline T *NewRaw();
+ template<typename T>
+ inline T *NewRawArray(int length);
+
+ inline QString *NewString(const QString &);
+ inline QByteArray *NewByteArray(const QByteArray &);
+ inline QUrl *NewUrl(const QUrl &);
+
+ template<typename T>
+ struct List {
+ List() : m_length(0), m_data(0) {}
+ List(const List &o) : m_length(o.m_length), m_data(o.m_data) {}
+ List &operator=(const List &o) {
+ m_length = o.m_length;
+ m_data = o.m_data;
+ return *this;
+ }
+
+ int count() const {
+ return m_length;
+ }
+ int length() const {
+ return m_length;
+ }
+ const T &at(int index) const {
+ Q_ASSERT(index < m_length);
+ return m_data[index];
+ };
+ T &operator[](int index) {
+ Q_ASSERT(index < m_length);
+ return m_data[index];
+ };
+ private:
+ friend class QQmlPool;
+ List(T *d, int l) : m_length(l), m_data(d) {}
+ int m_length;
+ T *m_data;
+ };
+
+ template<typename T>
+ inline List<T> NewRawList(int length);
+
+private:
+ struct StringClass : public QString, public Class {
+ };
+ struct ByteArrayClass : public QByteArray, public Class {
+ };
+ struct UrlClass : public QUrl, public Class {
+ };
+
+ inline void *allocate(int size);
+ void newpage();
+
+ template<typename T>
+ inline void initialize(POD *);
+ template<typename T>
+ inline void initialize(Class *);
+ template<typename T>
+ static void destroy(Class *c);
+
+ struct Page {
+ struct Header {
+ Page *next;
+ char *free;
+ } header;
+
+ static const int pageSize = 4 * 4096 - sizeof(Header);
+
+ char memory[pageSize];
+ };
+
+ Page *_page;
+ Class *_classList;
+};
+
+QQmlPool::QQmlPool()
+: _page(0), _classList(0)
+{
+}
+
+QQmlPool::~QQmlPool()
+{
+ clear();
+}
+
+template<typename T>
+T *QQmlPool::New()
+{
+ T *rv = new (allocate(sizeof(T))) T;
+ initialize<T>(rv);
+ rv->_pool = this;
+ return rv;
+}
+
+template<typename T>
+T *QQmlPool::NewRaw()
+{
+ return (T*)allocate(sizeof(T));
+}
+
+template<typename T>
+T *QQmlPool::NewRawArray(int length)
+{
+ return (T*)allocate(length * sizeof(T));
+}
+
+template<typename T>
+QQmlPool::List<T> QQmlPool::NewRawList(int length)
+{
+ return List<T>(NewRawArray<T>(length), length);
+}
+
+QString *QQmlPool::NewString(const QString &s)
+{
+ QString *rv = New<StringClass>();
+ *rv = s;
+ return rv;
+}
+
+QByteArray *QQmlPool::NewByteArray(const QByteArray &s)
+{
+ QByteArray *rv = New<ByteArrayClass>();
+ *rv = s;
+ return rv;
+}
+
+QUrl *QQmlPool::NewUrl(const QUrl &s)
+{
+ QUrl *rv = New<UrlClass>();
+ *rv = s;
+ return rv;
+}
+
+void *QQmlPool::allocate(int size)
+{
+ if (!_page || (_page->header.free + size) > (_page->memory + Page::pageSize))
+ newpage();
+
+ void *rv = _page->header.free;
+ _page->header.free += size + ((8 - size) & 7); // ensure 8 byte alignment;
+ return rv;
+}
+
+template<typename T>
+void QQmlPool::initialize(QQmlPool::POD *)
+{
+}
+
+template<typename T>
+void QQmlPool::initialize(QQmlPool::Class *c)
+{
+ c->_next = _classList;
+ c->_destroy = &destroy<T>;
+ _classList = c;
+}
+
+template<typename T>
+void QQmlPool::destroy(Class *c)
+{
+ static_cast<T *>(c)->~T();
+}
+
+QQmlPool *QQmlPool::Class::pool() const
+{
+ return _pool;
+}
+
+QQmlPool *QQmlPool::POD::pool() const
+{
+ return _pool;
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLPOOL_P_H
+
diff --git a/src/qml/qml/ftw/qqmlrefcount_p.h b/src/qml/qml/ftw/qqmlrefcount_p.h
new file mode 100644
index 0000000000..497f4ecc0f
--- /dev/null
+++ b/src/qml/qml/ftw/qqmlrefcount_p.h
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLREFCOUNT_P_H
+#define QQMLREFCOUNT_P_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/qatomic.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlRefCount
+{
+public:
+ inline QQmlRefCount();
+ inline virtual ~QQmlRefCount();
+ inline void addref();
+ inline void release();
+
+protected:
+ inline virtual void destroy();
+
+private:
+ QAtomicInt refCount;
+};
+
+template<class T>
+class QQmlRefPointer
+{
+public:
+ inline QQmlRefPointer();
+ inline QQmlRefPointer(T *);
+ inline QQmlRefPointer(const QQmlRefPointer<T> &);
+ inline ~QQmlRefPointer();
+
+ inline QQmlRefPointer<T> &operator=(const QQmlRefPointer<T> &o);
+ inline QQmlRefPointer<T> &operator=(T *);
+
+ inline bool isNull() const { return !o; }
+
+ inline T* operator->() const { return o; }
+ inline T& operator*() const { return *o; }
+ inline operator T*() const { return o; }
+ inline T* data() const { return o; }
+
+ inline QQmlRefPointer<T> &take(T *);
+
+private:
+ T *o;
+};
+
+QQmlRefCount::QQmlRefCount()
+: refCount(1)
+{
+}
+
+QQmlRefCount::~QQmlRefCount()
+{
+ Q_ASSERT(refCount.load() == 0);
+}
+
+void QQmlRefCount::addref()
+{
+ Q_ASSERT(refCount.load() > 0);
+ refCount.ref();
+}
+
+void QQmlRefCount::release()
+{
+ Q_ASSERT(refCount.load() > 0);
+ if (!refCount.deref())
+ destroy();
+}
+
+void QQmlRefCount::destroy()
+{
+ delete this;
+}
+
+template<class T>
+QQmlRefPointer<T>::QQmlRefPointer()
+: o(0)
+{
+}
+
+template<class T>
+QQmlRefPointer<T>::QQmlRefPointer(T *o)
+: o(o)
+{
+ if (o) o->addref();
+}
+
+template<class T>
+QQmlRefPointer<T>::QQmlRefPointer(const QQmlRefPointer<T> &other)
+: o(other.o)
+{
+ if (o) o->addref();
+}
+
+template<class T>
+QQmlRefPointer<T>::~QQmlRefPointer()
+{
+ if (o) o->release();
+}
+
+template<class T>
+QQmlRefPointer<T> &QQmlRefPointer<T>::operator=(const QQmlRefPointer<T> &other)
+{
+ if (other.o) other.o->addref();
+ if (o) o->release();
+ o = other.o;
+ return *this;
+}
+
+template<class T>
+QQmlRefPointer<T> &QQmlRefPointer<T>::operator=(T *other)
+{
+ if (other) other->addref();
+ if (o) o->release();
+ o = other;
+ return *this;
+}
+
+/*!
+Takes ownership of \a other. take() does *not* add a reference, as it assumes ownership
+of the callers reference of other.
+*/
+template<class T>
+QQmlRefPointer<T> &QQmlRefPointer<T>::take(T *other)
+{
+ if (o) o->release();
+ o = other;
+ return *this;
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLREFCOUNT_P_H
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
new file mode 100644
index 0000000000..423012b934
--- /dev/null
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -0,0 +1,359 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlthread_p.h"
+
+#include <private/qfieldlist_p.h>
+
+#include <QtCore/qmutex.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qwaitcondition.h>
+#include <QtCore/qcoreapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlThreadPrivate : public QThread
+{
+public:
+ QQmlThreadPrivate(QQmlThread *);
+ QQmlThread *q;
+
+ virtual void run();
+
+ inline void lock() { _mutex.lock(); }
+ inline void unlock() { _mutex.unlock(); }
+ inline void wait() { _wait.wait(&_mutex); }
+ inline void wakeOne() { _wait.wakeOne(); }
+ inline void wakeAll() { _wait.wakeAll(); }
+
+ quint32 m_threadProcessing:1; // Set when the thread is processing messages
+ quint32 m_mainProcessing:1; // Set when the main thread is processing messages
+ quint32 m_shutdown:1; // Set by main thread to request a shutdown
+ quint32 m_mainThreadWaiting:1; // Set by main thread if it is waiting for the message queue to empty
+
+ typedef QFieldList<QQmlThread::Message, &QQmlThread::Message::next> MessageList;
+ MessageList threadList;
+ MessageList mainList;
+
+ QQmlThread::Message *mainSync;
+
+ void triggerMainEvent();
+ void triggerThreadEvent();
+
+ void mainEvent();
+ void threadEvent();
+
+protected:
+ virtual bool event(QEvent *);
+
+private:
+ struct MainObject : public QObject {
+ MainObject(QQmlThreadPrivate *p);
+ virtual bool event(QEvent *e);
+ QQmlThreadPrivate *p;
+ };
+ MainObject m_mainObject;
+
+ QMutex _mutex;
+ QWaitCondition _wait;
+};
+
+QQmlThreadPrivate::MainObject::MainObject(QQmlThreadPrivate *p)
+: p(p)
+{
+}
+
+// Trigger mainEvent in main thread. Must be called from thread.
+void QQmlThreadPrivate::triggerMainEvent()
+{
+ Q_ASSERT(q->isThisThread());
+ QCoreApplication::postEvent(&m_mainObject, new QEvent(QEvent::User));
+}
+
+// Trigger even in thread. Must be called from main thread.
+void QQmlThreadPrivate::triggerThreadEvent()
+{
+ Q_ASSERT(!q->isThisThread());
+ QCoreApplication::postEvent(this, new QEvent(QEvent::User));
+}
+
+bool QQmlThreadPrivate::MainObject::event(QEvent *e)
+{
+ if (e->type() == QEvent::User)
+ p->mainEvent();
+ return QObject::event(e);
+}
+
+QQmlThreadPrivate::QQmlThreadPrivate(QQmlThread *q)
+: q(q), m_threadProcessing(false), m_mainProcessing(false), m_shutdown(false),
+ m_mainThreadWaiting(false), mainSync(0), m_mainObject(this)
+{
+}
+
+bool QQmlThreadPrivate::event(QEvent *e)
+{
+ if (e->type() == QEvent::User)
+ threadEvent();
+ return QThread::event(e);
+}
+
+void QQmlThreadPrivate::run()
+{
+ lock();
+
+ wakeOne();
+
+ unlock();
+
+ q->startupThread();
+ exec();
+}
+
+void QQmlThreadPrivate::mainEvent()
+{
+ lock();
+
+ m_mainProcessing = true;
+
+ while (!mainList.isEmpty() || mainSync) {
+ bool isSync = mainSync != 0;
+ QQmlThread::Message *message = isSync?mainSync:mainList.takeFirst();
+ unlock();
+
+ message->call(q);
+ delete message;
+
+ lock();
+
+ if (isSync) {
+ mainSync = 0;
+ wakeOne();
+ }
+ }
+
+ m_mainProcessing = false;
+
+ unlock();
+}
+
+void QQmlThreadPrivate::threadEvent()
+{
+ lock();
+
+ if (m_shutdown) {
+ quit();
+ wakeOne();
+ unlock();
+ q->shutdownThread();
+ } else {
+ m_threadProcessing = true;
+
+ while (!threadList.isEmpty()) {
+ QQmlThread::Message *message = threadList.first();
+
+ unlock();
+
+ message->call(q);
+
+ lock();
+
+ delete threadList.takeFirst();
+ }
+
+ wakeOne();
+
+ m_threadProcessing = false;
+
+ unlock();
+ }
+}
+
+QQmlThread::QQmlThread()
+: d(new QQmlThreadPrivate(this))
+{
+ d->lock();
+ d->start();
+ d->wait();
+ d->unlock();
+ d->moveToThread(d);
+
+}
+
+QQmlThread::~QQmlThread()
+{
+ delete d;
+}
+
+void QQmlThread::shutdown()
+{
+ d->lock();
+ Q_ASSERT(!d->m_shutdown);
+ d->m_shutdown = true;
+ if (d->threadList.isEmpty() && d->m_threadProcessing == false)
+ d->triggerThreadEvent();
+ d->wait();
+ d->unlock();
+ d->QThread::wait();
+}
+
+void QQmlThread::lock()
+{
+ d->lock();
+}
+
+void QQmlThread::unlock()
+{
+ d->unlock();
+}
+
+void QQmlThread::wakeOne()
+{
+ d->wakeOne();
+}
+
+void QQmlThread::wakeAll()
+{
+ d->wakeAll();
+}
+
+void QQmlThread::wait()
+{
+ d->wait();
+}
+
+bool QQmlThread::isThisThread() const
+{
+ return QThread::currentThread() == d;
+}
+
+QThread *QQmlThread::thread() const
+{
+ return const_cast<QThread *>(static_cast<const QThread *>(d));
+}
+
+// Called when the thread starts. Do startup stuff in here.
+void QQmlThread::startupThread()
+{
+}
+
+// Called when the thread shuts down. Do cleanup in here.
+void QQmlThread::shutdownThread()
+{
+}
+
+void QQmlThread::internalCallMethodInThread(Message *message)
+{
+ Q_ASSERT(!isThisThread());
+ d->lock();
+ Q_ASSERT(d->m_mainThreadWaiting == false);
+
+ bool wasEmpty = d->threadList.isEmpty();
+ d->threadList.append(message);
+ if (wasEmpty && d->m_threadProcessing == false)
+ d->triggerThreadEvent();
+
+ d->m_mainThreadWaiting = true;
+
+ do {
+ if (d->mainSync) {
+ QQmlThread::Message *message = d->mainSync;
+ unlock();
+ message->call(this);
+ delete message;
+ lock();
+ d->mainSync = 0;
+ wakeOne();
+ } else {
+ d->wait();
+ }
+ } while (d->mainSync || !d->threadList.isEmpty());
+
+ d->m_mainThreadWaiting = false;
+ d->unlock();
+}
+
+void QQmlThread::internalCallMethodInMain(Message *message)
+{
+ Q_ASSERT(isThisThread());
+
+ d->lock();
+
+ Q_ASSERT(d->mainSync == 0);
+ d->mainSync = message;
+
+ if (d->m_mainThreadWaiting) {
+ d->wakeOne();
+ } else if (d->m_mainProcessing) {
+ // Do nothing - it is already looping
+ } else {
+ d->triggerMainEvent();
+ }
+
+ while (d->mainSync && !d->m_shutdown)
+ d->wait();
+
+ d->unlock();
+}
+
+void QQmlThread::internalPostMethodToThread(Message *message)
+{
+ Q_ASSERT(!isThisThread());
+ d->lock();
+ bool wasEmpty = d->threadList.isEmpty();
+ d->threadList.append(message);
+ if (wasEmpty && d->m_threadProcessing == false)
+ d->triggerThreadEvent();
+ d->unlock();
+}
+
+void QQmlThread::internalPostMethodToMain(Message *message)
+{
+ Q_ASSERT(isThisThread());
+ d->lock();
+ bool wasEmpty = d->mainList.isEmpty();
+ d->mainList.append(message);
+ if (wasEmpty && d->m_mainProcessing == false)
+ d->triggerMainEvent();
+ d->unlock();
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/ftw/qqmlthread_p.h b/src/qml/qml/ftw/qqmlthread_p.h
new file mode 100644
index 0000000000..8a0ec6ceaa
--- /dev/null
+++ b/src/qml/qml/ftw/qqmlthread_p.h
@@ -0,0 +1,318 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLTHREAD_P_H
+#define QQMLTHREAD_P_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 <private/qintrusivelist_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QThread;
+
+class QQmlThreadPrivate;
+class QQmlThread
+{
+public:
+ QQmlThread();
+ virtual ~QQmlThread();
+ void shutdown();
+
+ void lock();
+ void unlock();
+ void wakeOne();
+ void wakeAll();
+ void wait();
+
+ QThread *thread() const;
+ bool isThisThread() const;
+
+ // Synchronously invoke a method in the thread
+ template<class O>
+ inline void callMethodInThread(void (O::*Member)());
+ template<typename T, class V, class O>
+ inline void callMethodInThread(void (O::*Member)(V), const T &);
+ template<typename T, typename T2, class V, class V2, class O>
+ inline void callMethodInThread(void (O::*Member)(V, V2), const T &, const T2 &);
+
+ // Synchronously invoke a method in the main thread. If the main thread is
+ // blocked in a callMethodInThread() call, the call is made from within that
+ // call.
+ template<class O>
+ inline void callMethodInMain(void (O::*Member)());
+ template<typename T, class V, class O>
+ inline void callMethodInMain(void (O::*Member)(V), const T &);
+ template<typename T, typename T2, class V, class V2, class O>
+ inline void callMethodInMain(void (O::*Member)(V, V2), const T &, const T2 &);
+
+ // Asynchronously invoke a method in the thread.
+ template<class O>
+ inline void postMethodToThread(void (O::*Member)());
+ template<typename T, class V, class O>
+ inline void postMethodToThread(void (O::*Member)(V), const T &);
+ template<typename T, typename T2, class V, class V2, class O>
+ inline void postMethodToThread(void (O::*Member)(V, V2), const T &, const T2 &);
+
+ // Asynchronously invoke a method in the main thread.
+ template<class O>
+ inline void postMethodToMain(void (O::*Member)());
+ template<typename T, class V, class O>
+ inline void postMethodToMain(void (O::*Member)(V), const T &);
+ template<typename T, typename T2, class V, class V2, class O>
+ inline void postMethodToMain(void (O::*Member)(V, V2), const T &, const T2 &);
+
+protected:
+ virtual void startupThread();
+ virtual void shutdownThread();
+
+private:
+ friend class QQmlThreadPrivate;
+
+ struct Message {
+ Message() : next(0) {}
+ virtual ~Message() {}
+ Message *next;
+ virtual void call(QQmlThread *) = 0;
+ };
+ void internalCallMethodInThread(Message *);
+ void internalCallMethodInMain(Message *);
+ void internalPostMethodToThread(Message *);
+ void internalPostMethodToMain(Message *);
+ QQmlThreadPrivate *d;
+};
+
+template<class O>
+void QQmlThread::callMethodInThread(void (O::*Member)())
+{
+ struct I : public Message {
+ void (O::*Member)();
+ I(void (O::*Member)()) : Member(Member) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)();
+ }
+ };
+ internalCallMethodInThread(new I(Member));
+}
+
+template<typename T, class V, class O>
+void QQmlThread::callMethodInThread(void (O::*Member)(V), const T &arg)
+{
+ struct I : public Message {
+ void (O::*Member)(V);
+ T arg;
+ I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)(arg);
+ }
+ };
+ internalCallMethodInThread(new I(Member, arg));
+}
+
+template<typename T, typename T2, class V, class V2, class O>
+void QQmlThread::callMethodInThread(void (O::*Member)(V, V2), const T &arg, const T2 &arg2)
+{
+ struct I : public Message {
+ void (O::*Member)(V, V2);
+ T arg;
+ T2 arg2;
+ I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)(arg, arg2);
+ }
+ };
+ internalCallMethodInThread(new I(Member, arg, arg2));
+}
+
+template<class O>
+void QQmlThread::callMethodInMain(void (O::*Member)())
+{
+ struct I : public Message {
+ void (O::*Member)();
+ I(void (O::*Member)()) : Member(Member) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)();
+ }
+ };
+ internalCallMethodInMain(new I(Member));
+}
+
+template<typename T, class V, class O>
+void QQmlThread::callMethodInMain(void (O::*Member)(V), const T &arg)
+{
+ struct I : public Message {
+ void (O::*Member)(V);
+ T arg;
+ I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)(arg);
+ }
+ };
+ internalCallMethodInMain(new I(Member, arg));
+}
+
+template<typename T, typename T2, class V, class V2, class O>
+void QQmlThread::callMethodInMain(void (O::*Member)(V, V2), const T &arg, const T2 &arg2)
+{
+ struct I : public Message {
+ void (O::*Member)(V, V2);
+ T arg;
+ T2 arg2;
+ I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)(arg, arg2);
+ }
+ };
+ internalCallMethodInMain(new I(Member, arg, arg2));
+}
+
+template<class O>
+void QQmlThread::postMethodToThread(void (O::*Member)())
+{
+ struct I : public Message {
+ void (O::*Member)();
+ I(void (O::*Member)()) : Member(Member) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)();
+ }
+ };
+ internalPostMethodToThread(new I(Member));
+}
+
+template<typename T, class V, class O>
+void QQmlThread::postMethodToThread(void (O::*Member)(V), const T &arg)
+{
+ struct I : public Message {
+ void (O::*Member)(V);
+ T arg;
+ I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)(arg);
+ }
+ };
+ internalPostMethodToThread(new I(Member, arg));
+}
+
+template<typename T, typename T2, class V, class V2, class O>
+void QQmlThread::postMethodToThread(void (O::*Member)(V, V2), const T &arg, const T2 &arg2)
+{
+ struct I : public Message {
+ void (O::*Member)(V, V2);
+ T arg;
+ T2 arg2;
+ I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)(arg, arg2);
+ }
+ };
+ internalPostMethodToThread(new I(Member, arg, arg2));
+}
+
+template<class O>
+void QQmlThread::postMethodToMain(void (O::*Member)())
+{
+ struct I : public Message {
+ void (O::*Member)();
+ I(void (O::*Member)()) : Member(Member) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)();
+ }
+ };
+ internalPostMethodToMain(new I(Member));
+}
+
+template<typename T, class V, class O>
+void QQmlThread::postMethodToMain(void (O::*Member)(V), const T &arg)
+{
+ struct I : public Message {
+ void (O::*Member)(V);
+ T arg;
+ I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)(arg);
+ }
+ };
+ internalPostMethodToMain(new I(Member, arg));
+}
+
+template<typename T, typename T2, class V, class V2, class O>
+void QQmlThread::postMethodToMain(void (O::*Member)(V, V2), const T &arg, const T2 &arg2)
+{
+ struct I : public Message {
+ void (O::*Member)(V, V2);
+ T arg;
+ T2 arg2;
+ I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
+ virtual void call(QQmlThread *thread) {
+ O *me = static_cast<O *>(thread);
+ (me->*Member)(arg, arg2);
+ }
+ };
+ internalPostMethodToMain(new I(Member, arg, arg2));
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLTHREAD_P_H
diff --git a/src/qml/qml/ftw/qqmltrace.cpp b/src/qml/qml/ftw/qqmltrace.cpp
new file mode 100644
index 0000000000..e044dc654f
--- /dev/null
+++ b/src/qml/qml/ftw/qqmltrace.cpp
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmltrace_p.h"
+
+#ifdef QML_ENABLE_TRACE
+#include <stdio.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QML_ENABLE_TRACE
+
+QQmlTrace::Pool QQmlTrace::logPool;
+QQmlTrace::Entry *QQmlTrace::first = 0;
+QQmlTrace::Entry *QQmlTrace::last = 0;
+
+static qint64 toNsecs(QQmlTrace::TimeType time)
+{
+#ifdef Q_OS_MAC
+ static mach_timebase_info_data_t info = {0,0};
+ if (info.denom == 0)
+ mach_timebase_info(&info);
+ return time * info.numer / info.denom;
+#else
+ qint64 rv = time.tv_sec * 1000000000 + time.tv_nsec;
+ return rv;
+#endif
+}
+
+QQmlTrace::Pool::Pool()
+{
+ first = New<Entry>();
+ last = first;
+}
+
+QQmlTrace::Pool::~Pool()
+{
+ char buffer[128];
+ sprintf(buffer, "qml.%d.log", ::getpid());
+ FILE *out = fopen(buffer, "w");
+ if (!out) {
+ fprintf (stderr, "QML Log: Could not open %s\n", buffer);
+ return;
+ } else {
+ fprintf (stderr, "QML Log: Writing log to %s\n", buffer);
+ }
+
+ QQmlTrace::Entry *cur = QQmlTrace::first;
+ QByteArray indent;
+ int depth = -1;
+
+ qint64 firstTime = -1;
+
+ while (cur) {
+
+ switch (cur->type) {
+ case QQmlTrace::Entry::RangeStart: {
+ RangeStart *rs = static_cast<QQmlTrace::RangeStart *>(cur);
+
+ qint64 nsecs = toNsecs(rs->time);
+
+ if (firstTime == -1)
+ firstTime = nsecs;
+
+ nsecs -= firstTime;
+
+ depth++;
+ indent = QByteArray(depth * 4, ' ');
+ fprintf(out, "%s%s @%lld (%lld ns)\n", indent.constData(),
+ rs->description, nsecs, toNsecs(rs->end->time) - nsecs - firstTime);
+ } break;
+ case QQmlTrace::Entry::RangeEnd:
+ depth--;
+ indent = QByteArray(depth * 4, ' ');
+ break;
+ case QQmlTrace::Entry::Detail:
+ fprintf(out, "%s %s\n", indent.constData(),
+ static_cast<QQmlTrace::Detail *>(cur)->description);
+ break;
+ case QQmlTrace::Entry::IntDetail:
+ fprintf(out, "%s %s: %d\n", indent.constData(),
+ static_cast<QQmlTrace::Detail *>(cur)->description,
+ static_cast<QQmlTrace::IntDetail *>(cur)->value);
+ break;
+ case QQmlTrace::Entry::StringDetail: {
+ QByteArray vLatin1 = static_cast<QQmlTrace::StringDetail *>(cur)->value->toLatin1();
+ fprintf(out, "%s %s: %s\n", indent.constData(),
+ static_cast<QQmlTrace::Detail *>(cur)->description,
+ vLatin1.constData());
+ } break;
+ case QQmlTrace::Entry::UrlDetail: {
+ QByteArray vLatin1 = static_cast<QQmlTrace::UrlDetail *>(cur)->value->toString().toLatin1();
+ fprintf(out, "%s %s: %s\n", indent.constData(),
+ static_cast<QQmlTrace::Detail *>(cur)->description,
+ vLatin1.constData());
+ } break;
+ case QQmlTrace::Entry::Event: {
+ Event *ev = static_cast<QQmlTrace::Event *>(cur);
+ qint64 nsecs = toNsecs(ev->time) - firstTime;
+ fprintf(out, "%s + %s @%lld +%lld ns\n", indent.constData(),
+ ev->description, nsecs, nsecs - (toNsecs(ev->start->time) - firstTime));
+ } break;
+ case QQmlTrace::Entry::Null:
+ default:
+ break;
+ }
+ cur = cur->next;
+ }
+ fclose(out);
+}
+
+#endif
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/ftw/qqmltrace_p.h b/src/qml/qml/ftw/qqmltrace_p.h
new file mode 100644
index 0000000000..965baff3a3
--- /dev/null
+++ b/src/qml/qml/ftw/qqmltrace_p.h
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLTRACE_P_H
+#define QQMLTRACE_P_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 <private/qqmlpool_p.h>
+
+// #define QML_ENABLE_TRACE
+
+#if defined(QML_ENABLE_TRACE) && defined(Q_OS_MAC)
+#include <mach/mach_time.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QUrl;
+class QQmlTrace
+{
+public:
+ inline QQmlTrace(const char *desc);
+ inline ~QQmlTrace();
+
+ inline void addDetail(const char *);
+ inline void addDetail(const char *, int);
+ inline void addDetail(const char *, const QString &);
+ inline void addDetail(const char *, const QUrl &);
+
+ inline void event(const char *desc);
+
+#ifdef QML_ENABLE_TRACE
+
+#ifdef Q_OS_MAC
+ typedef uint64_t TimeType;
+#else
+ typedef timespec TimeType;
+#endif
+
+ struct Entry : public QQmlPool::POD {
+ enum Type { Null, RangeStart, RangeEnd, Detail, IntDetail, StringDetail, UrlDetail, Event };
+ inline Entry();
+ inline Entry(Type);
+ Type type;
+ Entry *next;
+ };
+ struct RangeEnd : public Entry {
+ inline RangeEnd();
+ TimeType time;
+ };
+ struct RangeStart : public Entry {
+ inline RangeStart();
+ const char *description;
+ TimeType time;
+ QQmlTrace::RangeEnd *end;
+ };
+ struct Detail : public Entry {
+ inline Detail();
+ inline Detail(Type t);
+ const char *description;
+ };
+ struct IntDetail : public Detail {
+ inline IntDetail();
+ int value;
+ };
+ struct StringDetail : public Detail {
+ inline StringDetail();
+ QString *value;
+ };
+ struct UrlDetail : public Detail {
+ inline UrlDetail();
+ QUrl *value;
+ };
+ struct Event : public Entry {
+ inline Event();
+ const char *description;
+ TimeType time;
+ QQmlTrace::RangeStart *start;
+ };
+
+ struct Pool : public QQmlPool {
+ Pool();
+ ~Pool();
+ };
+
+ static Pool logPool;
+ static Entry *first;
+ static Entry *last;
+
+private:
+ RangeStart *start;
+
+ static TimeType gettime() {
+#ifdef Q_OS_MAC
+ return mach_absolute_time();
+#else
+ TimeType ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts;
+#endif
+ }
+#endif
+};
+
+#ifdef QML_ENABLE_TRACE
+QQmlTrace::Entry::Entry()
+: type(Null), next(0)
+{
+}
+
+QQmlTrace::Entry::Entry(Type type)
+: type(type), next(0)
+{
+ QQmlTrace::last->next = this;
+ QQmlTrace::last = this;
+}
+
+QQmlTrace::RangeEnd::RangeEnd()
+: QQmlTrace::Entry(QQmlTrace::Entry::RangeEnd),
+ time(gettime())
+{
+}
+
+QQmlTrace::RangeStart::RangeStart()
+: QQmlTrace::Entry(QQmlTrace::Entry::RangeStart),
+ description(0), time(gettime())
+{
+}
+
+QQmlTrace::Detail::Detail()
+: QQmlTrace::Entry(QQmlTrace::Entry::Detail),
+ description(0)
+{
+}
+
+QQmlTrace::Detail::Detail(Type type)
+: QQmlTrace::Entry(type), description(0)
+{
+}
+
+QQmlTrace::IntDetail::IntDetail()
+: QQmlTrace::Detail(QQmlTrace::Entry::IntDetail),
+ value(0)
+{
+}
+
+QQmlTrace::StringDetail::StringDetail()
+: QQmlTrace::Detail(QQmlTrace::Entry::StringDetail),
+ value(0)
+{
+}
+
+QQmlTrace::UrlDetail::UrlDetail()
+: QQmlTrace::Detail(QQmlTrace::Entry::UrlDetail),
+ value(0)
+{
+}
+
+QQmlTrace::Event::Event()
+: QQmlTrace::Entry(QQmlTrace::Entry::Event),
+ description(0), time(gettime()), start(0)
+{
+}
+#endif
+
+QQmlTrace::QQmlTrace(const char *desc)
+{
+#ifdef QML_ENABLE_TRACE
+ RangeStart *e = logPool.New<RangeStart>();
+ e->description = desc;
+ e->end = 0;
+ start = e;
+#else
+ Q_UNUSED(desc);
+#endif
+}
+
+QQmlTrace::~QQmlTrace()
+{
+#ifdef QML_ENABLE_TRACE
+ RangeEnd *e = logPool.New<RangeEnd>();
+ start->end = e;
+#endif
+}
+
+void QQmlTrace::addDetail(const char *desc)
+{
+#ifdef QML_ENABLE_TRACE
+ Detail *e = logPool.New<Detail>();
+ e->description = desc;
+#else
+ Q_UNUSED(desc);
+#endif
+}
+
+void QQmlTrace::addDetail(const char *desc, int v)
+{
+#ifdef QML_ENABLE_TRACE
+ IntDetail *e = logPool.New<IntDetail>();
+ e->description = desc;
+ e->value = v;
+#else
+ Q_UNUSED(desc);
+ Q_UNUSED(v);
+#endif
+}
+
+void QQmlTrace::addDetail(const char *desc, const QString &v)
+{
+#ifdef QML_ENABLE_TRACE
+ StringDetail *e = logPool.New<StringDetail>();
+ e->description = desc;
+ e->value = logPool.NewString(v);
+#else
+ Q_UNUSED(desc);
+ Q_UNUSED(v);
+#endif
+}
+
+void QQmlTrace::addDetail(const char *desc, const QUrl &v)
+{
+#ifdef QML_ENABLE_TRACE
+ UrlDetail *e = logPool.New<UrlDetail>();
+ e->description = desc;
+ e->value = logPool.NewUrl(v);
+#else
+ Q_UNUSED(desc);
+ Q_UNUSED(v);
+#endif
+}
+
+void QQmlTrace::event(const char *desc)
+{
+#ifdef QML_ENABLE_TRACE
+ Event *e = logPool.New<Event>();
+ e->start = start;
+ e->description = desc;
+#else
+ Q_UNUSED(desc);
+#endif
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLTRACE_P_H
diff --git a/src/qml/qml/ftw/qrecursionwatcher_p.h b/src/qml/qml/ftw/qrecursionwatcher_p.h
new file mode 100644
index 0000000000..16886edf12
--- /dev/null
+++ b/src/qml/qml/ftw/qrecursionwatcher_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QRECURSIONWATCHER_P_H
+#define QRECURSIONWATCHER_P_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>
+
+QT_BEGIN_NAMESPACE
+
+class QRecursionNode;
+class QRecursionNode {
+public:
+ inline QRecursionNode();
+ bool *_r;
+};
+
+template<class T, QRecursionNode T::*Node>
+class QRecursionWatcher {
+public:
+ inline QRecursionWatcher(T *);
+ inline ~QRecursionWatcher();
+ inline bool hasRecursed() const;
+private:
+ T *_t;
+ bool _r;
+};
+
+QRecursionNode::QRecursionNode()
+: _r(0)
+{
+}
+
+template<class T, QRecursionNode T::*Node>
+QRecursionWatcher<T, Node>::QRecursionWatcher(T *t)
+: _t(t), _r(false)
+{
+ if ((_t->*Node)._r) *(_t->*Node)._r = true;
+ (_t->*Node)._r = &_r;
+}
+
+template<class T, QRecursionNode T::*Node>
+QRecursionWatcher<T, Node>::~QRecursionWatcher()
+{
+ if ((_t->*Node)._r == &_r) (_t->*Node)._r = 0;
+}
+
+template<class T, QRecursionNode T::*Node>
+bool QRecursionWatcher<T, Node>::hasRecursed() const
+{
+ return _r;
+}
+
+QT_END_NAMESPACE
+
+#endif // QRECURSIONWATCHER_P_H
diff --git a/src/qml/qml/ftw/qrecyclepool_p.h b/src/qml/qml/ftw/qrecyclepool_p.h
new file mode 100644
index 0000000000..8d0f060ab3
--- /dev/null
+++ b/src/qml/qml/ftw/qrecyclepool_p.h
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QRECYCLEPOOL_P_H
+#define QRECYCLEPOOL_P_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.
+//
+
+QT_BEGIN_NAMESPACE
+
+#define QRECYCLEPOOLCOOKIE 0x33218ADF
+
+template<typename T, int Step>
+class QRecyclePoolPrivate
+{
+public:
+ QRecyclePoolPrivate()
+ : recyclePoolHold(true), outstandingItems(0), cookie(QRECYCLEPOOLCOOKIE),
+ currentPage(0), nextAllocated(0)
+ {
+ }
+
+ bool recyclePoolHold;
+ int outstandingItems;
+ quint32 cookie;
+
+ struct PoolType : public T {
+ union {
+ QRecyclePoolPrivate<T, Step> *pool;
+ PoolType *nextAllocated;
+ };
+ };
+
+ struct Page {
+ Page *nextPage;
+ unsigned int free;
+ union {
+ char array[Step * sizeof(PoolType)];
+ qint64 q_for_alignment_1;
+ double q_for_alignment_2;
+ };
+ };
+
+ Page *currentPage;
+ PoolType *nextAllocated;
+
+ inline T *allocate();
+ static inline void dispose(T *);
+ inline void releaseIfPossible();
+};
+
+template<typename T, int Step = 1024>
+class QRecyclePool
+{
+public:
+ inline QRecyclePool();
+ inline ~QRecyclePool();
+
+ inline T *New();
+ template<typename T1>
+ inline T *New(const T1 &);
+ template<typename T1>
+ inline T *New(T1 &);
+
+ static inline void Delete(T *);
+
+private:
+ QRecyclePoolPrivate<T, Step> *d;
+};
+
+template<typename T, int Step>
+QRecyclePool<T, Step>::QRecyclePool()
+: d(new QRecyclePoolPrivate<T, Step>())
+{
+}
+
+template<typename T, int Step>
+QRecyclePool<T, Step>::~QRecyclePool()
+{
+ d->recyclePoolHold = false;
+ d->releaseIfPossible();
+}
+
+template<typename T, int Step>
+T *QRecyclePool<T, Step>::New()
+{
+ T *rv = d->allocate();
+ new (rv) T;
+ return rv;
+}
+
+template<typename T, int Step>
+template<typename T1>
+T *QRecyclePool<T, Step>::New(const T1 &a)
+{
+ T *rv = d->allocate();
+ new (rv) T(a);
+ return rv;
+}
+
+template<typename T, int Step>
+template<typename T1>
+T *QRecyclePool<T, Step>::New(T1 &a)
+{
+ T *rv = d->allocate();
+ new (rv) T(a);
+ return rv;
+}
+
+template<typename T, int Step>
+void QRecyclePool<T, Step>::Delete(T *t)
+{
+ t->~T();
+ QRecyclePoolPrivate<T, Step>::dispose(t);
+}
+
+template<typename T, int Step>
+void QRecyclePoolPrivate<T, Step>::releaseIfPossible()
+{
+ if (recyclePoolHold || outstandingItems)
+ return;
+
+ Page *p = currentPage;
+ while (p) {
+ Page *n = p->nextPage;
+ qFree(p);
+ p = n;
+ }
+
+ delete this;
+}
+
+template<typename T, int Step>
+T *QRecyclePoolPrivate<T, Step>::allocate()
+{
+ PoolType *rv = 0;
+ if (nextAllocated) {
+ rv = nextAllocated;
+ nextAllocated = rv->nextAllocated;
+ } else if (currentPage && currentPage->free) {
+ rv = (PoolType *)(currentPage->array + (Step - currentPage->free) * sizeof(PoolType));
+ currentPage->free--;
+ } else {
+ Page *p = (Page *)qMalloc(sizeof(Page));
+ p->nextPage = currentPage;
+ p->free = Step;
+ currentPage = p;
+
+ rv = (PoolType *)currentPage->array;
+ currentPage->free--;
+ }
+
+ rv->pool = this;
+ ++outstandingItems;
+ return rv;
+}
+
+template<typename T, int Step>
+void QRecyclePoolPrivate<T, Step>::dispose(T *t)
+{
+ PoolType *pt = static_cast<PoolType *>(t);
+ Q_ASSERT(pt->pool && pt->pool->cookie == QRECYCLEPOOLCOOKIE);
+
+ QRecyclePoolPrivate<T, Step> *This = pt->pool;
+ pt->nextAllocated = This->nextAllocated;
+ This->nextAllocated = pt;
+ --This->outstandingItems;
+ This->releaseIfPossible();
+}
+
+QT_END_NAMESPACE
+
+#endif // QRECYCLEPOOL_P_H
diff --git a/src/qml/qml/parser/parser.pri b/src/qml/qml/parser/parser.pri
new file mode 100644
index 0000000000..6be85ba85a
--- /dev/null
+++ b/src/qml/qml/parser/parser.pri
@@ -0,0 +1,19 @@
+HEADERS += \
+ $$PWD/qqmljsast_p.h \
+ $$PWD/qqmljsastfwd_p.h \
+ $$PWD/qqmljsastvisitor_p.h \
+ $$PWD/qqmljsengine_p.h \
+ $$PWD/qqmljsgrammar_p.h \
+ $$PWD/qqmljslexer_p.h \
+ $$PWD/qqmljsmemorypool_p.h \
+ $$PWD/qqmljsparser_p.h \
+ $$PWD/qqmljsglobal_p.h \
+ $$PWD/qqmljskeywords_p.h
+
+SOURCES += \
+ $$PWD/qqmljsast.cpp \
+ $$PWD/qqmljsastvisitor.cpp \
+ $$PWD/qqmljsengine_p.cpp \
+ $$PWD/qqmljsgrammar.cpp \
+ $$PWD/qqmljslexer.cpp \
+ $$PWD/qqmljsparser.cpp
diff --git a/src/qml/qml/parser/qqmljs.g b/src/qml/qml/parser/qqmljs.g
new file mode 100644
index 0000000000..746fcb24df
--- /dev/null
+++ b/src/qml/qml/parser/qqmljs.g
@@ -0,0 +1,3016 @@
+----------------------------------------------------------------------------
+--
+-- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+-- Contact: http://www.qt-project.org/
+--
+-- This file is part of the QtQml module of the Qt Toolkit.
+--
+-- $QT_BEGIN_LICENSE:LGPL-ONLY$
+-- GNU Lesser General Public License Usage
+-- 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.
+--
+-- If you have questions regarding the use of this file, please contact
+-- us via http://www.qt-project.org/.
+--
+-- $QT_END_LICENSE$
+--
+----------------------------------------------------------------------------
+
+%parser QQmlJSGrammar
+%decl qqmljsparser_p.h
+%impl qdeclarativejsparser.cpp
+%expect 2
+%expect-rr 2
+
+%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
+%token T_BREAK "break" T_CASE "case" T_CATCH "catch"
+%token T_COLON ":" T_COMMA "," T_CONTINUE "continue"
+%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/"
+%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "."
+%token T_ELSE "else" T_EQ "=" T_EQ_EQ "=="
+%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for"
+%token T_FUNCTION "function" T_GE ">=" T_GT ">"
+%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>"
+%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if"
+%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{"
+%token T_LBRACKET "[" T_LE "<=" T_LPAREN "("
+%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<="
+%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--"
+%token T_NEW "new" T_NOT "!" T_NOT_EQ "!="
+%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|"
+%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+"
+%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?"
+%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%"
+%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")"
+%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*"
+%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal"
+%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly"
+%token T_SWITCH "switch" T_THIS "this" T_THROW "throw"
+%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof"
+%token T_VAR "var" T_VOID "void" T_WHILE "while"
+%token T_WITH "with" T_XOR "^" T_XOR_EQ "^="
+%token T_NULL "null" T_TRUE "true" T_FALSE "false"
+%token T_CONST "const"
+%token T_DEBUGGER "debugger"
+%token T_RESERVED_WORD "reserved word"
+%token T_MULTILINE_STRING_LITERAL "multiline string literal"
+%token T_COMMENT "comment"
+
+--- context keywords.
+%token T_PUBLIC "public"
+%token T_IMPORT "import"
+%token T_AS "as"
+%token T_ON "on"
+
+%token T_ERROR
+
+--- feed tokens
+%token T_FEED_UI_PROGRAM
+%token T_FEED_UI_OBJECT_MEMBER
+%token T_FEED_JS_STATEMENT
+%token T_FEED_JS_EXPRESSION
+%token T_FEED_JS_SOURCE_ELEMENT
+%token T_FEED_JS_PROGRAM
+
+%nonassoc SHIFT_THERE
+%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY
+%nonassoc REDUCE_HERE
+
+%start TopLevel
+
+/./****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtDebug>
+#include <QtCore/QCoreApplication>
+
+#include <string.h>
+
+#include "qqmljsengine_p.h"
+#include "qqmljslexer_p.h"
+#include "qqmljsast_p.h"
+#include "qqmljsmemorypool_p.h"
+
+./
+
+/:/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+//
+// 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.
+//
+
+//
+// This file is automatically generated from qmljs.g.
+// Changes will be lost.
+//
+
+#ifndef QDECLARATIVEJSPARSER_P_H
+#define QDECLARATIVEJSPARSER_P_H
+
+#include "qqmljsglobal_p.h"
+#include "qqmljsgrammar_p.h"
+#include "qqmljsast_p.h"
+#include "qqmljsengine_p.h"
+
+#include <QtCore/QList>
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+class Engine;
+
+class QML_PARSER_EXPORT Parser: protected $table
+{
+public:
+ union Value {
+ int ival;
+ double dval;
+ AST::ArgumentList *ArgumentList;
+ AST::CaseBlock *CaseBlock;
+ AST::CaseClause *CaseClause;
+ AST::CaseClauses *CaseClauses;
+ AST::Catch *Catch;
+ AST::DefaultClause *DefaultClause;
+ AST::ElementList *ElementList;
+ AST::Elision *Elision;
+ AST::ExpressionNode *Expression;
+ AST::Finally *Finally;
+ AST::FormalParameterList *FormalParameterList;
+ AST::FunctionBody *FunctionBody;
+ AST::FunctionDeclaration *FunctionDeclaration;
+ AST::Node *Node;
+ AST::PropertyName *PropertyName;
+ AST::PropertyNameAndValueList *PropertyNameAndValueList;
+ AST::SourceElement *SourceElement;
+ AST::SourceElements *SourceElements;
+ AST::Statement *Statement;
+ AST::StatementList *StatementList;
+ AST::Block *Block;
+ AST::VariableDeclaration *VariableDeclaration;
+ AST::VariableDeclarationList *VariableDeclarationList;
+
+ AST::UiProgram *UiProgram;
+ AST::UiImportList *UiImportList;
+ AST::UiImport *UiImport;
+ AST::UiParameterList *UiParameterList;
+ AST::UiPublicMember *UiPublicMember;
+ AST::UiObjectDefinition *UiObjectDefinition;
+ AST::UiObjectInitializer *UiObjectInitializer;
+ AST::UiObjectBinding *UiObjectBinding;
+ AST::UiScriptBinding *UiScriptBinding;
+ AST::UiArrayBinding *UiArrayBinding;
+ AST::UiObjectMember *UiObjectMember;
+ AST::UiObjectMemberList *UiObjectMemberList;
+ AST::UiArrayMemberList *UiArrayMemberList;
+ AST::UiQualifiedId *UiQualifiedId;
+ };
+
+public:
+ Parser(Engine *engine);
+ ~Parser();
+
+ // parse a UI program
+ bool parse() { return parse(T_FEED_UI_PROGRAM); }
+ bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
+ bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
+ bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
+ bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
+ bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
+
+ AST::UiProgram *ast() const
+ { return AST::cast<AST::UiProgram *>(program); }
+
+ AST::Statement *statement() const
+ {
+ if (! program)
+ return 0;
+
+ return program->statementCast();
+ }
+
+ AST::ExpressionNode *expression() const
+ {
+ if (! program)
+ return 0;
+
+ return program->expressionCast();
+ }
+
+ AST::UiObjectMember *uiObjectMember() const
+ {
+ if (! program)
+ return 0;
+
+ return program->uiObjectMemberCast();
+ }
+
+ AST::Node *rootNode() const
+ { return program; }
+
+ QList<DiagnosticMessage> diagnosticMessages() const
+ { return diagnostic_messages; }
+
+ inline DiagnosticMessage diagnosticMessage() const
+ {
+ foreach (const DiagnosticMessage &d, diagnostic_messages) {
+ if (! d.kind == DiagnosticMessage::Warning)
+ return d;
+ }
+
+ return DiagnosticMessage();
+ }
+
+ inline QString errorMessage() const
+ { return diagnosticMessage().message; }
+
+ inline int errorLineNumber() const
+ { return diagnosticMessage().loc.startLine; }
+
+ inline int errorColumnNumber() const
+ { return diagnosticMessage().loc.startColumn; }
+
+protected:
+ bool parse(int startToken);
+
+ void reallocateStack();
+
+ inline Value &sym(int index)
+ { return sym_stack [tos + index - 1]; }
+
+ inline QStringRef &stringRef(int index)
+ { return string_stack [tos + index - 1]; }
+
+ inline AST::SourceLocation &loc(int index)
+ { return location_stack [tos + index - 1]; }
+
+ AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
+
+protected:
+ Engine *driver;
+ MemoryPool *pool;
+ int tos;
+ int stack_size;
+ Value *sym_stack;
+ int *state_stack;
+ AST::SourceLocation *location_stack;
+ QStringRef *string_stack;
+
+ AST::Node *program;
+
+ // error recovery
+ enum { TOKEN_BUFFER_SIZE = 3 };
+
+ struct SavedToken {
+ int token;
+ double dval;
+ AST::SourceLocation loc;
+ QStringRef spell;
+ };
+
+ double yylval;
+ QStringRef yytokenspell;
+ AST::SourceLocation yylloc;
+ AST::SourceLocation yyprevlloc;
+
+ SavedToken token_buffer[TOKEN_BUFFER_SIZE];
+ SavedToken *first_token;
+ SavedToken *last_token;
+
+ QList<DiagnosticMessage> diagnostic_messages;
+};
+
+} // end of namespace QQmlJS
+
+
+:/
+
+
+/.
+
+#include "qqmljsparser_p.h"
+#include <QVarLengthArray>
+
+//
+// This file is automatically generated from qmljs.g.
+// Changes will be lost.
+//
+
+using namespace QQmlJS;
+
+QT_QML_BEGIN_NAMESPACE
+
+void Parser::reallocateStack()
+{
+ if (! stack_size)
+ stack_size = 128;
+ else
+ stack_size <<= 1;
+
+ sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
+ state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
+ location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
+ string_stack = reinterpret_cast<QStringRef*> (realloc(string_stack, stack_size * sizeof(QStringRef)));
+}
+
+Parser::Parser(Engine *engine):
+ driver(engine),
+ pool(engine->pool()),
+ tos(0),
+ stack_size(0),
+ sym_stack(0),
+ state_stack(0),
+ location_stack(0),
+ string_stack(0),
+ first_token(0),
+ last_token(0)
+{
+}
+
+Parser::~Parser()
+{
+ if (stack_size) {
+ free(sym_stack);
+ free(state_stack);
+ free(location_stack);
+ free(string_stack);
+ }
+}
+
+static inline AST::SourceLocation location(Lexer *lexer)
+{
+ AST::SourceLocation loc;
+ loc.offset = lexer->tokenOffset();
+ loc.length = lexer->tokenLength();
+ loc.startLine = lexer->tokenStartLine();
+ loc.startColumn = lexer->tokenStartColumn();
+ return loc;
+}
+
+AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
+{
+ QVarLengthArray<QStringRef, 4> nameIds;
+ QVarLengthArray<AST::SourceLocation, 4> locations;
+
+ AST::ExpressionNode *it = expr;
+ while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
+ nameIds.append(m->name);
+ locations.append(m->identifierToken);
+ it = m->base;
+ }
+
+ if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
+ AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name);
+ q->identifierToken = idExpr->identifierToken;
+
+ AST::UiQualifiedId *currentId = q;
+ for (int i = nameIds.size() - 1; i != -1; --i) {
+ currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]);
+ currentId->identifierToken = locations[i];
+ }
+
+ return currentId->finish();
+ }
+
+ return 0;
+}
+
+bool Parser::parse(int startToken)
+{
+ Lexer *lexer = driver->lexer();
+ bool hadErrors = false;
+ int yytoken = -1;
+ int action = 0;
+
+ token_buffer[0].token = startToken;
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
+
+ tos = -1;
+ program = 0;
+
+ do {
+ if (++tos == stack_size)
+ reallocateStack();
+
+ state_stack[tos] = action;
+
+ _Lcheck_token:
+ if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
+ yyprevlloc = yylloc;
+
+ if (first_token == last_token) {
+ yytoken = lexer->lex();
+ yylval = lexer->tokenValue();
+ yytokenspell = lexer->tokenSpell();
+ yylloc = location(lexer);
+ } else {
+ yytoken = first_token->token;
+ yylval = first_token->dval;
+ yytokenspell = first_token->spell;
+ yylloc = first_token->loc;
+ ++first_token;
+ }
+ }
+
+ action = t_action(action, yytoken);
+ if (action > 0) {
+ if (action != ACCEPT_STATE) {
+ yytoken = -1;
+ sym(1).dval = yylval;
+ stringRef(1) = yytokenspell;
+ loc(1) = yylloc;
+ } else {
+ --tos;
+ return ! hadErrors;
+ }
+ } else if (action < 0) {
+ const int r = -action - 1;
+ tos -= rhs[r];
+
+ switch (r) {
+./
+
+--------------------------------------------------------------------------------------------------------
+-- Declarative UI
+--------------------------------------------------------------------------------------------------------
+
+TopLevel: T_FEED_UI_PROGRAM UiProgram ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_STATEMENT Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_EXPRESSION Expression ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_PROGRAM Program ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+UiProgram: UiImportListOpt UiRootMember ;
+/.
+case $rule_number: {
+ sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList,
+ sym(2).UiObjectMemberList->finish());
+} break;
+./
+
+UiImportListOpt: Empty ;
+UiImportListOpt: UiImportList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).UiImportList->finish();
+} break;
+./
+
+UiImportList: UiImport ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport);
+} break;
+./
+
+UiImportList: UiImportList UiImport ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport);
+} break;
+./
+
+ImportId: MemberExpression ;
+
+UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ;
+UiImport: UiImportHead T_SEMICOLON ;
+/.
+case $rule_number: {
+ sym(1).UiImport->semicolonToken = loc(2);
+} break;
+./
+
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ;
+UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ;
+/.
+case $rule_number: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->semicolonToken = loc(3);
+} break;
+./
+
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->asToken = loc(3);
+ sym(1).UiImport->importIdToken = loc(4);
+ sym(1).UiImport->importId = stringRef(4);
+ sym(1).UiImport->semicolonToken = loc(5);
+} break;
+./
+
+UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ sym(1).UiImport->asToken = loc(2);
+ sym(1).UiImport->importIdToken = loc(3);
+ sym(1).UiImport->importId = stringRef(3);
+ sym(1).UiImport->semicolonToken = loc(4);
+} break;
+./
+
+
+UiImportHead: T_IMPORT ImportId ;
+/.
+case $rule_number: {
+ AST::UiImport *node = 0;
+
+ if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
+ node = new (pool) AST::UiImport(importIdLiteral->value);
+ node->fileNameToken = loc(2);
+ } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
+ node = new (pool) AST::UiImport(qualifiedId);
+ node->fileNameToken = loc(2);
+ }
+
+ sym(1).Node = node;
+
+ if (node) {
+ node->importToken = loc(1);
+ } else {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id or a string literal")));
+
+ return false; // ### remove me
+ }
+} break;
+./
+
+Empty: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+UiRootMember: UiObjectDefinition ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
+} break;
+./
+
+UiObjectMemberList: UiObjectMember ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
+} break;
+./
+
+UiObjectMemberList: UiObjectMemberList UiObjectMember ;
+/.
+case $rule_number: {
+ AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList(
+ sym(1).UiObjectMemberList, sym(2).UiObjectMember);
+ sym(1).Node = node;
+} break;
+./
+
+UiArrayMemberList: UiObjectDefinition ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember);
+} break;
+./
+
+UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ;
+/.
+case $rule_number: {
+ AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList(
+ sym(1).UiArrayMemberList, sym(3).UiObjectMember);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectInitializer: T_LBRACE T_RBRACE ;
+/.
+case $rule_number: {
+ AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ;
+/.
+case $rule_number: {
+ AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectDefinition: UiQualifiedId UiObjectInitializer ;
+/.
+case $rule_number: {
+ AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId,
+ sym(2).UiObjectInitializer);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: UiObjectDefinition ;
+
+UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding(
+ sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
+ node->colonToken = loc(2);
+ node->lbracketToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
+/.
+case $rule_number: {
+ AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
+ sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ;
+/.
+case $rule_number: {
+ AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
+ sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ node->hasOnToken = true;
+ sym(1).Node = node;
+} break;
+./
+
+UiScriptStatement: Block ;
+UiScriptStatement: EmptyStatement ;
+UiScriptStatement: ExpressionStatement ;
+UiScriptStatement: IfStatement ;
+UiScriptStatement: WithStatement ;
+UiScriptStatement: SwitchStatement ;
+UiScriptStatement: TryStatement ;
+
+UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ;
+/.
+case $rule_number:
+{
+ AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding(
+ sym(1).UiQualifiedId, sym(3).Statement);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiPropertyType: T_VAR ;
+UiPropertyType: T_RESERVED_WORD ;
+UiPropertyType: T_IDENTIFIER ;
+
+UiParameterListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+UiParameterListOpt: UiParameterList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).UiParameterList->finish ();
+} break;
+./
+
+UiParameterList: UiPropertyType JsIdentifier ;
+/.
+case $rule_number: {
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2));
+ node->propertyTypeToken = loc(1);
+ node->identifierToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
+/.
+case $rule_number: {
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
+ node->commaToken = loc(2);
+ node->identifierToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->parameters = sym(4).UiParameterList;
+ node->semicolonToken = loc(6);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
+ node->typeModifier = stringRef(2);
+ node->propertyToken = loc(1);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->semicolonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4));
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->semicolonToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3),
+ sym(5).Statement);
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
+ sym(6).Statement);
+ node->isReadonlyMember = true;
+ node->readonlyToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
+ sym(6).Statement);
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
+ node->typeModifier = stringRef(2);
+ node->propertyToken = loc(1);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->semicolonToken = loc(7); // insert a fake ';' before ':'
+
+ AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6));
+ propertyName->identifierToken = loc(6);
+ propertyName->next = 0;
+
+ AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(
+ propertyName, sym(9).UiArrayMemberList->finish());
+ binding->colonToken = loc(7);
+ binding->lbracketToken = loc(8);
+ binding->rbracketToken = loc(10);
+
+ node->binding = binding;
+
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->semicolonToken = loc(4); // insert a fake ';' before ':'
+
+ AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3));
+ propertyName->identifierToken = loc(3);
+ propertyName->next = 0;
+
+ AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
+ propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer);
+ binding->colonToken = loc(4);
+
+ node->binding = binding;
+
+ sym(1).Node = node;
+} break;
+./
+
+UiObjectMember: FunctionDeclaration ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
+} break;
+./
+
+UiObjectMember: VariableStatement ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
+} break;
+./
+
+JsIdentifier: T_IDENTIFIER;
+
+JsIdentifier: T_PROPERTY ;
+JsIdentifier: T_SIGNAL ;
+JsIdentifier: T_READONLY ;
+JsIdentifier: T_ON ;
+
+--------------------------------------------------------------------------------------------------------
+-- Expressions
+--------------------------------------------------------------------------------------------------------
+
+PrimaryExpression: T_THIS ;
+/.
+case $rule_number: {
+ AST::ThisExpression *node = new (pool) AST::ThisExpression();
+ node->thisToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: JsIdentifier ;
+/.
+case $rule_number: {
+ AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_NULL ;
+/.
+case $rule_number: {
+ AST::NullExpression *node = new (pool) AST::NullExpression();
+ node->nullToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_TRUE ;
+/.
+case $rule_number: {
+ AST::TrueLiteral *node = new (pool) AST::TrueLiteral();
+ node->trueToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_FALSE ;
+/.
+case $rule_number: {
+ AST::FalseLiteral *node = new (pool) AST::FalseLiteral();
+ node->falseToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_NUMERIC_LITERAL ;
+/.
+case $rule_number: {
+ AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_MULTILINE_STRING_LITERAL ;
+/.case $rule_number:./
+
+PrimaryExpression: T_STRING_LITERAL ;
+/.
+case $rule_number: {
+ AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1));
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_DIVIDE_ ;
+/:
+#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number
+:/
+/.
+case $rule_number: {
+ bool rx = lexer->scanRegExp(Lexer::NoPrefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false; // ### remove me
+ }
+
+ loc(1).length = lexer->tokenLength();
+ yylloc = loc(1); // adjust the location of the current token
+
+ AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
+ driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_DIVIDE_EQ ;
+/:
+#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number
+:/
+/.
+case $rule_number: {
+ bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false;
+ }
+
+ loc(1).length = lexer->tokenLength();
+ yylloc = loc(1); // adjust the location of the current token
+
+ AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
+ driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0);
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET Elision T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
+ (AST::Elision *) 0);
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
+ sym(4).Elision->finish());
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+-- PrimaryExpression: T_LBRACE T_RBRACE ;
+-- /.
+-- case $rule_number: {
+-- sym(1).Node = new (pool) AST::ObjectLiteral();
+-- } break;
+-- ./
+
+PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::ObjectLiteral *node = 0;
+ if (sym(2).Node)
+ node = new (pool) AST::ObjectLiteral(
+ sym(2).PropertyNameAndValueList->finish ());
+ else
+ node = new (pool) AST::ObjectLiteral();
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ;
+/.
+case $rule_number: {
+ AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
+ sym(2).PropertyNameAndValueList->finish ());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+PrimaryExpression: T_LPAREN Expression T_RPAREN ;
+/.
+case $rule_number: {
+ AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression);
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+UiQualifiedId: MemberExpression ;
+/.
+case $rule_number: {
+ if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
+ QLatin1String("Ignored annotation")));
+
+ sym(1).Expression = mem->base;
+ }
+
+ if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
+ sym(1).UiQualifiedId = qualifiedId;
+ } else {
+ sym(1).UiQualifiedId = 0;
+
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id")));
+
+ return false; // ### recover
+ }
+} break;
+./
+
+ElementList: AssignmentExpression ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression);
+} break;
+./
+
+ElementList: Elision AssignmentExpression ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression);
+} break;
+./
+
+ElementList: ElementList T_COMMA AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList,
+ (AST::Elision *) 0, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ElementList: ElementList T_COMMA Elision AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(),
+ sym(4).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+Elision: T_COMMA ;
+/.
+case $rule_number: {
+ AST::Elision *node = new (pool) AST::Elision();
+ node->commaToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+Elision: Elision T_COMMA ;
+/.
+case $rule_number: {
+ AST::Elision *node = new (pool) AST::Elision(sym(1).Elision);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
+ sym(1).PropertyName, sym(3).Expression);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
+ sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
+ node->commaToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: T_IDENTIFIER %prec SHIFT_THERE ;
+/.
+case $rule_number: {
+ AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: T_SIGNAL ;
+/.case $rule_number:./
+
+PropertyName: T_PROPERTY ;
+/.
+case $rule_number: {
+ AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: T_STRING_LITERAL ;
+/.
+case $rule_number: {
+ AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: T_NUMERIC_LITERAL ;
+/.
+case $rule_number: {
+ AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+PropertyName: ReservedIdentifier ;
+/.
+case $rule_number: {
+ AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+ReservedIdentifier: T_BREAK ;
+ReservedIdentifier: T_CASE ;
+ReservedIdentifier: T_CATCH ;
+ReservedIdentifier: T_CONTINUE ;
+ReservedIdentifier: T_DEFAULT ;
+ReservedIdentifier: T_DELETE ;
+ReservedIdentifier: T_DO ;
+ReservedIdentifier: T_ELSE ;
+ReservedIdentifier: T_FALSE ;
+ReservedIdentifier: T_FINALLY ;
+ReservedIdentifier: T_FOR ;
+ReservedIdentifier: T_FUNCTION ;
+ReservedIdentifier: T_IF ;
+ReservedIdentifier: T_IN ;
+ReservedIdentifier: T_INSTANCEOF ;
+ReservedIdentifier: T_NEW ;
+ReservedIdentifier: T_NULL ;
+ReservedIdentifier: T_RETURN ;
+ReservedIdentifier: T_SWITCH ;
+ReservedIdentifier: T_THIS ;
+ReservedIdentifier: T_THROW ;
+ReservedIdentifier: T_TRUE ;
+ReservedIdentifier: T_TRY ;
+ReservedIdentifier: T_TYPEOF ;
+ReservedIdentifier: T_VAR ;
+ReservedIdentifier: T_VOID ;
+ReservedIdentifier: T_WHILE ;
+ReservedIdentifier: T_CONST ;
+ReservedIdentifier: T_DEBUGGER ;
+ReservedIdentifier: T_RESERVED_WORD ;
+ReservedIdentifier: T_WITH ;
+
+PropertyIdentifier: JsIdentifier ;
+PropertyIdentifier: ReservedIdentifier ;
+
+MemberExpression: PrimaryExpression ;
+MemberExpression: FunctionExpression ;
+
+MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+MemberExpression: MemberExpression T_DOT PropertyIdentifier ;
+/.
+case $rule_number: {
+ AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+/.
+case $rule_number: {
+ AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList);
+ node->newToken = loc(1);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+NewExpression: MemberExpression ;
+
+NewExpression: T_NEW NewExpression ;
+/.
+case $rule_number: {
+ AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression);
+ node->newToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+/.
+case $rule_number: {
+ AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+/.
+case $rule_number: {
+ AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ;
+/.
+case $rule_number: {
+ AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+CallExpression: CallExpression T_DOT PropertyIdentifier ;
+/.
+case $rule_number: {
+ AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+ArgumentListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+ArgumentListOpt: ArgumentList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).ArgumentList->finish();
+} break;
+./
+
+ArgumentList: AssignmentExpression ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression);
+} break;
+./
+
+ArgumentList: ArgumentList T_COMMA AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LeftHandSideExpression: NewExpression ;
+LeftHandSideExpression: CallExpression ;
+PostfixExpression: LeftHandSideExpression ;
+
+PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ;
+/.
+case $rule_number: {
+ AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression);
+ node->incrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ;
+/.
+case $rule_number: {
+ AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression);
+ node->decrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: PostfixExpression ;
+
+UnaryExpression: T_DELETE UnaryExpression ;
+/.
+case $rule_number: {
+ AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression);
+ node->deleteToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_VOID UnaryExpression ;
+/.
+case $rule_number: {
+ AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression);
+ node->voidToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_TYPEOF UnaryExpression ;
+/.
+case $rule_number: {
+ AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression);
+ node->typeofToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_PLUS_PLUS UnaryExpression ;
+/.
+case $rule_number: {
+ AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression);
+ node->incrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_MINUS_MINUS UnaryExpression ;
+/.
+case $rule_number: {
+ AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression);
+ node->decrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_PLUS UnaryExpression ;
+/.
+case $rule_number: {
+ AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression);
+ node->plusToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_MINUS UnaryExpression ;
+/.
+case $rule_number: {
+ AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression);
+ node->minusToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_TILDE UnaryExpression ;
+/.
+case $rule_number: {
+ AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression);
+ node->tildeToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UnaryExpression: T_NOT UnaryExpression ;
+/.
+case $rule_number: {
+ AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression);
+ node->notToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+MultiplicativeExpression: UnaryExpression ;
+
+MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Mul, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Div, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Mod, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+AdditiveExpression: MultiplicativeExpression ;
+
+AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Add, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Sub, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ShiftExpression: AdditiveExpression ;
+
+ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::LShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::RShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::URShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: ShiftExpression ;
+
+RelationalExpression: RelationalExpression T_LT ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Lt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_GT ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Gt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_LE ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Le, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_GE ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Ge, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::InstanceOf, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpression: RelationalExpression T_IN ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::In, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: ShiftExpression ;
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Lt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Gt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Le, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Ge, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::InstanceOf, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpression: RelationalExpression ;
+
+EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Equal, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::NotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::StrictEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::StrictNotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpressionNotIn: RelationalExpressionNotIn ;
+
+EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Equal, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::NotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::StrictEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::StrictNotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseANDExpression: EqualityExpression ;
+
+BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseANDExpressionNotIn: EqualityExpressionNotIn ;
+
+BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseXORExpression: BitwiseANDExpression ;
+
+BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ;
+
+BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseORExpression: BitwiseXORExpression ;
+
+BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ;
+
+BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LogicalANDExpression: BitwiseORExpression ;
+
+LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ;
+
+LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LogicalORExpression: LogicalANDExpression ;
+
+LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LogicalORExpressionNotIn: LogicalANDExpressionNotIn ;
+
+LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ConditionalExpression: LogicalORExpression ;
+
+ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
+ sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+ConditionalExpressionNotIn: LogicalORExpressionNotIn ;
+
+ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
+ sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+AssignmentExpression: ConditionalExpression ;
+
+AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+AssignmentExpressionNotIn: ConditionalExpressionNotIn ;
+
+AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+AssignmentOperator: T_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::Assign;
+} break;
+./
+
+AssignmentOperator: T_STAR_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceMul;
+} break;
+./
+
+AssignmentOperator: T_DIVIDE_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceDiv;
+} break;
+./
+
+AssignmentOperator: T_REMAINDER_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceMod;
+} break;
+./
+
+AssignmentOperator: T_PLUS_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceAdd;
+} break;
+./
+
+AssignmentOperator: T_MINUS_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceSub;
+} break;
+./
+
+AssignmentOperator: T_LT_LT_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceLeftShift;
+} break;
+./
+
+AssignmentOperator: T_GT_GT_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceRightShift;
+} break;
+./
+
+AssignmentOperator: T_GT_GT_GT_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceURightShift;
+} break;
+./
+
+AssignmentOperator: T_AND_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceAnd;
+} break;
+./
+
+AssignmentOperator: T_XOR_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceXor;
+} break;
+./
+
+AssignmentOperator: T_OR_EQ ;
+/.
+case $rule_number: {
+ sym(1).ival = QSOperator::InplaceOr;
+} break;
+./
+
+Expression: AssignmentExpression ;
+
+Expression: Expression T_COMMA AssignmentExpression ;
+/.
+case $rule_number: {
+ AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ExpressionOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+ExpressionOpt: Expression ;
+
+ExpressionNotIn: AssignmentExpressionNotIn ;
+
+ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ;
+/.
+case $rule_number: {
+ AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ExpressionNotInOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+ExpressionNotInOpt: ExpressionNotIn ;
+
+Statement: Block ;
+Statement: VariableStatement ;
+Statement: EmptyStatement ;
+Statement: ExpressionStatement ;
+Statement: IfStatement ;
+Statement: IterationStatement ;
+Statement: ContinueStatement ;
+Statement: BreakStatement ;
+Statement: ReturnStatement ;
+Statement: WithStatement ;
+Statement: LabelledStatement ;
+Statement: SwitchStatement ;
+Statement: ThrowStatement ;
+Statement: TryStatement ;
+Statement: DebuggerStatement ;
+
+
+Block: T_LBRACE StatementListOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::Block *node = new (pool) AST::Block(sym(2).StatementList);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+StatementList: Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::StatementList(sym(1).Statement);
+} break;
+./
+
+StatementList: StatementList Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement);
+} break;
+./
+
+StatementListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+StatementListOpt: StatementList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).StatementList->finish ();
+} break;
+./
+
+VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::VariableStatement *node = new (pool) AST::VariableStatement(
+ sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
+ node->declarationKindToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+VariableDeclarationKind: T_CONST ;
+/.
+case $rule_number: {
+ sym(1).ival = T_CONST;
+} break;
+./
+
+VariableDeclarationKind: T_VAR ;
+/.
+case $rule_number: {
+ sym(1).ival = T_VAR;
+} break;
+./
+
+VariableDeclarationList: VariableDeclaration ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
+} break;
+./
+
+VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ;
+/.
+case $rule_number: {
+ AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList(
+ sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+VariableDeclarationListNotIn: VariableDeclarationNotIn ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
+} break;
+./
+
+VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+} break;
+./
+
+VariableDeclaration: JsIdentifier InitialiserOpt ;
+/.
+case $rule_number: {
+ AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ;
+/.
+case $rule_number: {
+ AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+Initialiser: T_EQ AssignmentExpression ;
+/.
+case $rule_number: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+./
+
+InitialiserOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+InitialiserOpt: Initialiser ;
+
+InitialiserNotIn: T_EQ AssignmentExpressionNotIn ;
+/.
+case $rule_number: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+./
+
+InitialiserNotInOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+InitialiserNotInOpt: InitialiserNotIn ;
+
+EmptyStatement: T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::EmptyStatement *node = new (pool) AST::EmptyStatement();
+ node->semicolonToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ExpressionStatement: Expression T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ;
+/.
+case $rule_number: {
+ AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->elseToken = loc(6);
+ sym(1).Node = node;
+} break;
+./
+
+IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+
+IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
+ node->doToken = loc(1);
+ node->whileToken = loc(3);
+ node->lparenToken = loc(4);
+ node->rparenToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
+ node->whileToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression,
+ sym(5).Expression, sym(7).Expression, sym(9).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->firstSemicolonToken = loc(4);
+ node->secondSemicolonToken = loc(6);
+ node->rparenToken = loc(8);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
+ sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
+ sym(8).Expression, sym(10).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->varToken = loc(3);
+ node->firstSemicolonToken = loc(5);
+ node->secondSemicolonToken = loc(7);
+ node->rparenToken = loc(9);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression,
+ sym(5).Expression, sym(7).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->inToken = loc(4);
+ node->rparenToken = loc(6);
+ sym(1).Node = node;
+} break;
+./
+
+IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement(
+ sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->varToken = loc(3);
+ node->inToken = loc(5);
+ node->rparenToken = loc(7);
+ sym(1).Node = node;
+} break;
+./
+
+ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ContinueStatement: T_CONTINUE T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
+ node->continueToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
+ node->continueToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+BreakStatement: T_BREAK T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
+ node->breakToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
+ node->breakToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
+ node->returnToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ;
+/.
+case $rule_number: {
+ AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
+ node->withToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ;
+/.
+case $rule_number: {
+ AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
+ node->switchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(5);
+ sym(1).Node = node;
+} break;
+./
+
+CaseClauses: CaseClause ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
+} break;
+./
+
+CaseClauses: CaseClauses CaseClause ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
+} break;
+./
+
+CaseClausesOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+CaseClausesOpt: CaseClauses ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).CaseClauses->finish ();
+} break;
+./
+
+CaseClause: T_CASE Expression T_COLON StatementListOpt ;
+/.
+case $rule_number: {
+ AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
+ node->caseToken = loc(1);
+ node->colonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+DefaultClause: T_DEFAULT T_COLON StatementListOpt ;
+/.
+case $rule_number: {
+ AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
+ node->defaultToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LabelledStatement: T_SIGNAL T_COLON Statement ;
+/.case $rule_number:./
+
+LabelledStatement: T_PROPERTY T_COLON Statement ;
+/.
+case $rule_number: {
+ AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+LabelledStatement: T_IDENTIFIER T_COLON Statement ;
+/.
+case $rule_number: {
+ AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+ThrowStatement: T_THROW Expression T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
+ node->throwToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+TryStatement: T_TRY Block Catch ;
+/.
+case $rule_number: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+TryStatement: T_TRY Block Finally ;
+/.
+case $rule_number: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+TryStatement: T_TRY Block Catch Finally ;
+/.
+case $rule_number: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ;
+/.
+case $rule_number: {
+ AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
+ node->catchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->identifierToken = loc(3);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+./
+
+Finally: T_FINALLY Block ;
+/.
+case $rule_number: {
+ AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
+ node->finallyToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
+DebuggerStatement: T_DEBUGGER T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
+ node->debuggerToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+./
+
+FunctionDeclaration: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
+ node->functionToken = loc(1);
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+} break;
+./
+
+FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+/.
+case $rule_number: {
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
+ node->functionToken = loc(1);
+ if (! stringRef(2).isNull())
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+} break;
+./
+
+FormalParameterList: JsIdentifier ;
+/.
+case $rule_number: {
+ AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+FormalParameterList: FormalParameterList T_COMMA JsIdentifier ;
+/.
+case $rule_number: {
+ AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3));
+ node->commaToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
+
+FormalParameterListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+FormalParameterListOpt: FormalParameterList ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(1).FormalParameterList->finish ();
+} break;
+./
+
+FunctionBodyOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+FunctionBodyOpt: FunctionBody ;
+
+FunctionBody: SourceElements ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ());
+} break;
+./
+
+Program: Empty ;
+
+Program: SourceElements ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ());
+} break;
+./
+
+SourceElements: SourceElement ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement);
+} break;
+./
+
+SourceElements: SourceElements SourceElement ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement);
+} break;
+./
+
+SourceElement: Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement);
+} break;
+./
+
+SourceElement: FunctionDeclaration ;
+/.
+case $rule_number: {
+ sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration);
+} break;
+./
+
+IdentifierOpt: ;
+/.
+case $rule_number: {
+ stringRef(1) = QStringRef();
+} break;
+./
+
+IdentifierOpt: JsIdentifier ;
+
+PropertyNameAndValueListOpt: ;
+/.
+case $rule_number: {
+ sym(1).Node = 0;
+} break;
+./
+
+PropertyNameAndValueListOpt: PropertyNameAndValueList ;
+
+/.
+ } // switch
+ action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
+ } // if
+ } while (action != 0);
+
+ if (first_token == last_token) {
+ const int errorState = state_stack[tos];
+
+ // automatic insertion of `;'
+ if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) {
+ SavedToken &tk = token_buffer[0];
+ tk.token = yytoken;
+ tk.dval = yylval;
+ tk.spell = yytokenspell;
+ tk.loc = yylloc;
+
+ yylloc = yyprevlloc;
+ yylloc.offset += yylloc.length;
+ yylloc.startColumn += yylloc.length;
+ yylloc.length = 0;
+
+ //const QString msg = qApp->translate("QQmlParser", "Missing `;'");
+ //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
+
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
+
+ yytoken = T_SEMICOLON;
+ yylval = 0;
+
+ action = errorState;
+
+ goto _Lcheck_token;
+ }
+
+ hadErrors = true;
+
+ token_buffer[0].token = yytoken;
+ token_buffer[0].dval = yylval;
+ token_buffer[0].spell = yytokenspell;
+ token_buffer[0].loc = yylloc;
+
+ token_buffer[1].token = yytoken = lexer->lex();
+ token_buffer[1].dval = yylval = lexer->tokenValue();
+ token_buffer[1].spell = yytokenspell = lexer->tokenSpell();
+ token_buffer[1].loc = yylloc = location(lexer);
+
+ if (t_action(errorState, yytoken)) {
+ QString msg;
+ int token = token_buffer[0].token;
+ if (token < 0 || token >= TERMINAL_COUNT)
+ msg = qApp->translate("QQmlParser", "Syntax error");
+ else
+ msg = qApp->translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+
+ static int tokens[] = {
+ T_PLUS,
+ T_EQ,
+
+ T_COMMA,
+ T_COLON,
+ T_SEMICOLON,
+
+ T_RPAREN, T_RBRACKET, T_RBRACE,
+
+ T_NUMERIC_LITERAL,
+ T_IDENTIFIER,
+
+ T_LPAREN, T_LBRACKET, T_LBRACE,
+
+ EOF_SYMBOL
+ };
+
+ for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
+ int a = t_action(errorState, *tk);
+ if (a > 0 && t_action(a, yytoken)) {
+ const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ yytoken = *tk;
+ yylval = 0;
+ yylloc = token_buffer[0].loc;
+ yylloc.length = 0;
+
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[2];
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+ }
+
+ for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
+ if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
+ tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
+ tk == T_FEED_JS_SOURCE_ELEMENT)
+ continue;
+
+ int a = t_action(errorState, tk);
+ if (a > 0 && t_action(a, yytoken)) {
+ const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ yytoken = tk;
+ yylval = 0;
+ yylloc = token_buffer[0].loc;
+ yylloc.length = 0;
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+ }
+
+ const QString msg = qApp->translate("QQmlParser", "Syntax error");
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+ }
+
+ return false;
+}
+
+QT_QML_END_NAMESPACE
+
+
+./
+/:
+QT_QML_END_NAMESPACE
+
+
+
+#endif // QDECLARATIVEJSPARSER_P_H
+:/
diff --git a/src/qml/qml/parser/qqmljsast.cpp b/src/qml/qml/parser/qqmljsast.cpp
new file mode 100644
index 0000000000..d0b984fc9e
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsast.cpp
@@ -0,0 +1,931 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmljsast_p.h"
+
+#include "qqmljsastvisitor_p.h"
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS { namespace AST {
+
+void Node::accept(Visitor *visitor)
+{
+ if (visitor->preVisit(this)) {
+ accept0(visitor);
+ }
+ visitor->postVisit(this);
+}
+
+void Node::accept(Node *node, Visitor *visitor)
+{
+ if (node)
+ node->accept(visitor);
+}
+
+ExpressionNode *Node::expressionCast()
+{
+ return 0;
+}
+
+BinaryExpression *Node::binaryExpressionCast()
+{
+ return 0;
+}
+
+Statement *Node::statementCast()
+{
+ return 0;
+}
+
+UiObjectMember *Node::uiObjectMemberCast()
+{
+ return 0;
+}
+
+ExpressionNode *ExpressionNode::expressionCast()
+{
+ return this;
+}
+
+BinaryExpression *BinaryExpression::binaryExpressionCast()
+{
+ return this;
+}
+
+Statement *Statement::statementCast()
+{
+ return this;
+}
+
+UiObjectMember *UiObjectMember::uiObjectMemberCast()
+{
+ return this;
+}
+
+void NestedExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+ visitor->endVisit(this);
+}
+
+void ThisExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void IdentifierExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void NullExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void TrueLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void FalseLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void StringLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void NumericLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void RegExpLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void ArrayLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(elements, visitor);
+ accept(elision, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ObjectLiteral::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(properties, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ElementList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (ElementList *it = this; it; it = it->next) {
+ accept(it->elision, visitor);
+ accept(it->expression, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void Elision::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ // ###
+ }
+
+ visitor->endVisit(this);
+}
+
+void PropertyNameAndValueList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (PropertyNameAndValueList *it = this; it; it = it->next) {
+ accept(it->name, visitor);
+ accept(it->value, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void IdentifierPropertyName::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void StringLiteralPropertyName::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void NumericLiteralPropertyName::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void ArrayMemberExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FieldMemberExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void NewMemberExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ accept(arguments, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void NewExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void CallExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ accept(arguments, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ArgumentList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (ArgumentList *it = this; it; it = it->next) {
+ accept(it->expression, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void PostIncrementExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PostDecrementExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void DeleteExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void VoidExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void TypeOfExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PreIncrementExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PreDecrementExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UnaryPlusExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UnaryMinusExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void TildeExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void NotExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void BinaryExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(left, visitor);
+ accept(right, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ConditionalExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(ok, visitor);
+ accept(ko, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Expression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(left, visitor);
+ accept(right, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Block::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void StatementList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (StatementList *it = this; it; it = it->next) {
+ accept(it->statement, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void VariableStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(declarations, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void VariableDeclarationList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (VariableDeclarationList *it = this; it; it = it->next) {
+ accept(it->declaration, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void VariableDeclaration::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void EmptyStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void ExpressionStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void IfStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(ok, visitor);
+ accept(ko, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void DoWhileStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void WhileStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ForStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(initialiser, visitor);
+ accept(condition, visitor);
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void LocalForStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(declarations, visitor);
+ accept(condition, visitor);
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ForEachStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(initialiser, visitor);
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void LocalForEachStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(declaration, visitor);
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ContinueStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void BreakStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void ReturnStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void WithStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void SwitchStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(block, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void CaseBlock::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(clauses, visitor);
+ accept(defaultClause, visitor);
+ accept(moreClauses, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void CaseClauses::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (CaseClauses *it = this; it; it = it->next) {
+ accept(it->clause, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void CaseClause::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ accept(statements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void DefaultClause::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void LabelledStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ThrowStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void TryStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ accept(catchExpression, visitor);
+ accept(finallyExpression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Catch::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Finally::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FunctionDeclaration::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(formals, visitor);
+ accept(body, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FunctionExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(formals, visitor);
+ accept(body, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FormalParameterList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ // ###
+ }
+
+ visitor->endVisit(this);
+}
+
+void FunctionBody::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(elements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void Program::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(elements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void SourceElements::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (SourceElements *it = this; it; it = it->next) {
+ accept(it->element, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void FunctionSourceElement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(declaration, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void StatementSourceElement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void DebuggerStatement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiProgram::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(imports, visitor);
+ accept(members, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiPublicMember::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(statement, visitor);
+ accept(binding, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiObjectDefinition::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedTypeNameId, visitor);
+ accept(initializer, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiObjectInitializer::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(members, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiObjectBinding::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedId, visitor);
+ accept(qualifiedTypeNameId, visitor);
+ accept(initializer, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiScriptBinding::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedId, visitor);
+ accept(statement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiArrayBinding::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedId, visitor);
+ accept(members, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiObjectMemberList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (UiObjectMemberList *it = this; it; it = it->next)
+ accept(it->member, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiArrayMemberList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (UiArrayMemberList *it = this; it; it = it->next)
+ accept(it->member, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiQualifiedId::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiImport::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(importUri, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiImportList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(import, visitor);
+ accept(next, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiSourceElement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(sourceElement, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+} } // namespace QQmlJS::AST
+
+QT_QML_END_NAMESPACE
+
+
diff --git a/src/qml/qml/parser/qqmljsast_p.h b/src/qml/qml/parser/qqmljsast_p.h
new file mode 100644
index 0000000000..f85eb4ca5f
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsast_p.h
@@ -0,0 +1,2640 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLJSAST_P_H
+#define QQMLJSAST_P_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 "qqmljsastvisitor_p.h"
+#include "qqmljsglobal_p.h"
+#include "qqmljsmemorypool_p.h"
+
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+#define QQMLJS_DECLARE_AST_NODE(name) \
+ enum { K = Kind_##name };
+
+namespace QSOperator // ### rename
+{
+
+enum Op {
+ Add,
+ And,
+ InplaceAnd,
+ Assign,
+ BitAnd,
+ BitOr,
+ BitXor,
+ InplaceSub,
+ Div,
+ InplaceDiv,
+ Equal,
+ Ge,
+ Gt,
+ In,
+ InplaceAdd,
+ InstanceOf,
+ Le,
+ LShift,
+ InplaceLeftShift,
+ Lt,
+ Mod,
+ InplaceMod,
+ Mul,
+ InplaceMul,
+ NotEqual,
+ Or,
+ InplaceOr,
+ RShift,
+ InplaceRightShift,
+ StrictEqual,
+ StrictNotEqual,
+ Sub,
+ URShift,
+ InplaceURightShift,
+ InplaceXor
+};
+
+} // namespace QSOperator
+
+namespace QQmlJS {
+
+namespace AST {
+
+template <typename _T1, typename _T2>
+_T1 cast(_T2 *ast)
+{
+ if (ast && ast->kind == static_cast<_T1>(0)->K)
+ return static_cast<_T1>(ast);
+
+ return 0;
+}
+
+class QML_PARSER_EXPORT Node: public Managed
+{
+public:
+ enum Kind {
+ Kind_Undefined,
+
+ Kind_ArgumentList,
+ Kind_ArrayLiteral,
+ Kind_ArrayMemberExpression,
+ Kind_BinaryExpression,
+ Kind_Block,
+ Kind_BreakStatement,
+ Kind_CallExpression,
+ Kind_CaseBlock,
+ Kind_CaseClause,
+ Kind_CaseClauses,
+ Kind_Catch,
+ Kind_ConditionalExpression,
+ Kind_ContinueStatement,
+ Kind_DebuggerStatement,
+ Kind_DefaultClause,
+ Kind_DeleteExpression,
+ Kind_DoWhileStatement,
+ Kind_ElementList,
+ Kind_Elision,
+ Kind_EmptyStatement,
+ Kind_Expression,
+ Kind_ExpressionStatement,
+ Kind_FalseLiteral,
+ Kind_FieldMemberExpression,
+ Kind_Finally,
+ Kind_ForEachStatement,
+ Kind_ForStatement,
+ Kind_FormalParameterList,
+ Kind_FunctionBody,
+ Kind_FunctionDeclaration,
+ Kind_FunctionExpression,
+ Kind_FunctionSourceElement,
+ Kind_IdentifierExpression,
+ Kind_IdentifierPropertyName,
+ Kind_IfStatement,
+ Kind_LabelledStatement,
+ Kind_LocalForEachStatement,
+ Kind_LocalForStatement,
+ Kind_NewExpression,
+ Kind_NewMemberExpression,
+ Kind_NotExpression,
+ Kind_NullExpression,
+ Kind_NumericLiteral,
+ Kind_NumericLiteralPropertyName,
+ Kind_ObjectLiteral,
+ Kind_PostDecrementExpression,
+ Kind_PostIncrementExpression,
+ Kind_PreDecrementExpression,
+ Kind_PreIncrementExpression,
+ Kind_Program,
+ Kind_PropertyName,
+ Kind_PropertyNameAndValueList,
+ Kind_RegExpLiteral,
+ Kind_ReturnStatement,
+ Kind_SourceElement,
+ Kind_SourceElements,
+ Kind_StatementList,
+ Kind_StatementSourceElement,
+ Kind_StringLiteral,
+ Kind_StringLiteralPropertyName,
+ Kind_SwitchStatement,
+ Kind_ThisExpression,
+ Kind_ThrowStatement,
+ Kind_TildeExpression,
+ Kind_TrueLiteral,
+ Kind_TryStatement,
+ Kind_TypeOfExpression,
+ Kind_UnaryMinusExpression,
+ Kind_UnaryPlusExpression,
+ Kind_VariableDeclaration,
+ Kind_VariableDeclarationList,
+ Kind_VariableStatement,
+ Kind_VoidExpression,
+ Kind_WhileStatement,
+ Kind_WithStatement,
+ Kind_NestedExpression,
+
+ Kind_UiArrayBinding,
+ Kind_UiImport,
+ Kind_UiImportList,
+ Kind_UiObjectBinding,
+ Kind_UiObjectDefinition,
+ Kind_UiObjectInitializer,
+ Kind_UiObjectMemberList,
+ Kind_UiArrayMemberList,
+ Kind_UiProgram,
+ Kind_UiParameterList,
+ Kind_UiPublicMember,
+ Kind_UiQualifiedId,
+ Kind_UiScriptBinding,
+ Kind_UiSourceElement
+ };
+
+ inline Node()
+ : kind(Kind_Undefined) {}
+
+ // NOTE: node destructors are never called,
+ // instead we block free the memory
+ // (see the NodePool class)
+ virtual ~Node() {}
+
+ virtual ExpressionNode *expressionCast();
+ virtual BinaryExpression *binaryExpressionCast();
+ virtual Statement *statementCast();
+ virtual UiObjectMember *uiObjectMemberCast();
+
+ void accept(Visitor *visitor);
+ static void accept(Node *node, Visitor *visitor);
+
+ inline static void acceptChild(Node *node, Visitor *visitor)
+ { return accept(node, visitor); } // ### remove
+
+ virtual void accept0(Visitor *visitor) = 0;
+ virtual SourceLocation firstSourceLocation() const = 0;
+ virtual SourceLocation lastSourceLocation() const = 0;
+
+// attributes
+ int kind;
+};
+
+class QML_PARSER_EXPORT ExpressionNode: public Node
+{
+public:
+ ExpressionNode() {}
+
+ virtual ExpressionNode *expressionCast();
+};
+
+class QML_PARSER_EXPORT Statement: public Node
+{
+public:
+ Statement() {}
+
+ virtual Statement *statementCast();
+};
+
+class QML_PARSER_EXPORT NestedExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(NestedExpression)
+
+ NestedExpression(ExpressionNode *expression)
+ : expression(expression)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lparenToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rparenToken; }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ThisExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ThisExpression)
+
+ ThisExpression() { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return thisToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return thisToken; }
+
+// attributes
+ SourceLocation thisToken;
+};
+
+class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(IdentifierExpression)
+
+ IdentifierExpression(const QStringRef &n):
+ name (n) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return identifierToken; }
+
+// attributes
+ QStringRef name;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT NullExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(NullExpression)
+
+ NullExpression() { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return nullToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return nullToken; }
+
+// attributes
+ SourceLocation nullToken;
+};
+
+class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(TrueLiteral)
+
+ TrueLiteral() { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return trueToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return trueToken; }
+
+// attributes
+ SourceLocation trueToken;
+};
+
+class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(FalseLiteral)
+
+ FalseLiteral() { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return falseToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return falseToken; }
+
+// attributes
+ SourceLocation falseToken;
+};
+
+class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(NumericLiteral)
+
+ NumericLiteral(double v):
+ value(v) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return literalToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return literalToken; }
+
+// attributes:
+ double value;
+ SourceLocation literalToken;
+};
+
+class QML_PARSER_EXPORT StringLiteral: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(StringLiteral)
+
+ StringLiteral(const QStringRef &v):
+ value (v) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return literalToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return literalToken; }
+
+// attributes:
+ QStringRef value;
+ SourceLocation literalToken;
+};
+
+class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(RegExpLiteral)
+
+ RegExpLiteral(const QStringRef &p, int f):
+ pattern (p), flags (f) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return literalToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return literalToken; }
+
+// attributes:
+ QStringRef pattern;
+ int flags;
+ SourceLocation literalToken;
+};
+
+class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ArrayLiteral)
+
+ ArrayLiteral(Elision *e):
+ elements (0), elision (e)
+ { kind = K; }
+
+ ArrayLiteral(ElementList *elts):
+ elements (elts), elision (0)
+ { kind = K; }
+
+ ArrayLiteral(ElementList *elts, Elision *e):
+ elements (elts), elision (e)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lbracketToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbracketToken; }
+
+// attributes
+ ElementList *elements;
+ Elision *elision;
+ SourceLocation lbracketToken;
+ SourceLocation commaToken;
+ SourceLocation rbracketToken;
+};
+
+class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ObjectLiteral)
+
+ ObjectLiteral():
+ properties (0) { kind = K; }
+
+ ObjectLiteral(PropertyNameAndValueList *plist):
+ properties (plist) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lbraceToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbraceToken; }
+
+// attributes
+ PropertyNameAndValueList *properties;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT Elision: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(Elision)
+
+ Elision():
+ next (this) { kind = K; }
+
+ Elision(Elision *previous)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return commaToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : commaToken; }
+
+ inline Elision *finish ()
+ {
+ Elision *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ Elision *next;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT ElementList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ElementList)
+
+ ElementList(Elision *e, ExpressionNode *expr):
+ elision (e), expression (expr), next (this)
+ { kind = K; }
+
+ ElementList(ElementList *previous, Elision *e, ExpressionNode *expr):
+ elision (e), expression (expr)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ inline ElementList *finish ()
+ {
+ ElementList *front = next;
+ next = 0;
+ return front;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (elision)
+ return elision->firstSourceLocation();
+ return expression->firstSourceLocation();
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (next)
+ return next->lastSourceLocation();
+ return expression->lastSourceLocation();
+ }
+
+// attributes
+ Elision *elision;
+ ExpressionNode *expression;
+ ElementList *next;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT PropertyName: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(PropertyName)
+
+ PropertyName() { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return propertyNameToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return propertyNameToken; }
+
+// attributes
+ SourceLocation propertyNameToken;
+};
+
+class QML_PARSER_EXPORT PropertyNameAndValueList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(PropertyNameAndValueList)
+
+ PropertyNameAndValueList(PropertyName *n, ExpressionNode *v):
+ name (n), value (v), next (this)
+ { kind = K; }
+
+ PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v):
+ name (n), value (v)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return name->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (next)
+ return next->lastSourceLocation();
+ return value->lastSourceLocation();
+ }
+
+ inline PropertyNameAndValueList *finish ()
+ {
+ PropertyNameAndValueList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ PropertyName *name;
+ ExpressionNode *value;
+ PropertyNameAndValueList *next;
+ SourceLocation colonToken;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
+
+ IdentifierPropertyName(const QStringRef &n):
+ id (n) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ QStringRef id;
+};
+
+class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
+
+ StringLiteralPropertyName(const QStringRef &n):
+ id (n) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ QStringRef id;
+};
+
+class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(NumericLiteralPropertyName)
+
+ NumericLiteralPropertyName(double n):
+ id (n) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ double id;
+};
+
+class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ArrayMemberExpression)
+
+ ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e):
+ base (b), expression (e)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbracketToken; }
+
+// attributes
+ ExpressionNode *base;
+ ExpressionNode *expression;
+ SourceLocation lbracketToken;
+ SourceLocation rbracketToken;
+};
+
+class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(FieldMemberExpression)
+
+ FieldMemberExpression(ExpressionNode *b, const QStringRef &n):
+ base (b), name (n)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return identifierToken; }
+
+ // attributes
+ ExpressionNode *base;
+ QStringRef name;
+ SourceLocation dotToken;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(NewMemberExpression)
+
+ NewMemberExpression(ExpressionNode *b, ArgumentList *a):
+ base (b), arguments (a)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return newToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rparenToken; }
+
+ // attributes
+ ExpressionNode *base;
+ ArgumentList *arguments;
+ SourceLocation newToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT NewExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(NewExpression)
+
+ NewExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return newToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation newToken;
+};
+
+class QML_PARSER_EXPORT CallExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(CallExpression)
+
+ CallExpression(ExpressionNode *b, ArgumentList *a):
+ base (b), arguments (a)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rparenToken; }
+
+// attributes
+ ExpressionNode *base;
+ ArgumentList *arguments;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ArgumentList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ArgumentList)
+
+ ArgumentList(ExpressionNode *e):
+ expression (e), next (this)
+ { kind = K; }
+
+ ArgumentList(ArgumentList *previous, ExpressionNode *e):
+ expression (e)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return expression->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (next)
+ return next->lastSourceLocation();
+ return expression->lastSourceLocation();
+ }
+
+ inline ArgumentList *finish ()
+ {
+ ArgumentList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ ExpressionNode *expression;
+ ArgumentList *next;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(PostIncrementExpression)
+
+ PostIncrementExpression(ExpressionNode *b):
+ base (b) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return incrementToken; }
+
+// attributes
+ ExpressionNode *base;
+ SourceLocation incrementToken;
+};
+
+class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(PostDecrementExpression)
+
+ PostDecrementExpression(ExpressionNode *b):
+ base (b) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return base->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return decrementToken; }
+
+// attributes
+ ExpressionNode *base;
+ SourceLocation decrementToken;
+};
+
+class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(DeleteExpression)
+
+ DeleteExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return deleteToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation deleteToken;
+};
+
+class QML_PARSER_EXPORT VoidExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(VoidExpression)
+
+ VoidExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return voidToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation voidToken;
+};
+
+class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(TypeOfExpression)
+
+ TypeOfExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return typeofToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation typeofToken;
+};
+
+class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(PreIncrementExpression)
+
+ PreIncrementExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return incrementToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation incrementToken;
+};
+
+class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(PreDecrementExpression)
+
+ PreDecrementExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return decrementToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation decrementToken;
+};
+
+class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UnaryPlusExpression)
+
+ UnaryPlusExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return plusToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation plusToken;
+};
+
+class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UnaryMinusExpression)
+
+ UnaryMinusExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return minusToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation minusToken;
+};
+
+class QML_PARSER_EXPORT TildeExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(TildeExpression)
+
+ TildeExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return tildeToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation tildeToken;
+};
+
+class QML_PARSER_EXPORT NotExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(NotExpression)
+
+ NotExpression(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return notToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation notToken;
+};
+
+class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(BinaryExpression)
+
+ BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r):
+ left (l), op (o), right (r)
+ { kind = K; }
+
+ virtual BinaryExpression *binaryExpressionCast();
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return left->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return right->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *left;
+ int op;
+ ExpressionNode *right;
+ SourceLocation operatorToken;
+};
+
+class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ConditionalExpression)
+
+ ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f):
+ expression (e), ok (t), ko (f)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return expression->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return ko->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ ExpressionNode *ok;
+ ExpressionNode *ko;
+ SourceLocation questionToken;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(Expression)
+
+ Expression(ExpressionNode *l, ExpressionNode *r):
+ left (l), right (r) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return left->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return right->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *left;
+ ExpressionNode *right;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT Block: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(Block)
+
+ Block(StatementList *slist):
+ statements (slist) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lbraceToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbraceToken; }
+
+ // attributes
+ StatementList *statements;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT StatementList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(StatementList)
+
+ StatementList(Statement *stmt):
+ statement (stmt), next (this)
+ { kind = K; }
+
+ StatementList(StatementList *previous, Statement *stmt):
+ statement (stmt)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return statement->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : statement->lastSourceLocation(); }
+
+ inline StatementList *finish ()
+ {
+ StatementList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ Statement *statement;
+ StatementList *next;
+};
+
+class QML_PARSER_EXPORT VariableStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(VariableStatement)
+
+ VariableStatement(VariableDeclarationList *vlist):
+ declarations (vlist)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return declarationKindToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ VariableDeclarationList *declarations;
+ SourceLocation declarationKindToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT VariableDeclaration: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(VariableDeclaration)
+
+ VariableDeclaration(const QStringRef &n, ExpressionNode *e):
+ name (n), expression (e), readOnly(false)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return expression ? expression->lastSourceLocation() : identifierToken; }
+
+// attributes
+ QStringRef name;
+ ExpressionNode *expression;
+ bool readOnly;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT VariableDeclarationList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(VariableDeclarationList)
+
+ VariableDeclarationList(VariableDeclaration *decl):
+ declaration (decl), next (this)
+ { kind = K; }
+
+ VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl):
+ declaration (decl)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return declaration->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (next)
+ return next->lastSourceLocation();
+ return declaration->lastSourceLocation();
+ }
+
+ inline VariableDeclarationList *finish (bool readOnly)
+ {
+ VariableDeclarationList *front = next;
+ next = 0;
+ if (readOnly) {
+ VariableDeclarationList *vdl;
+ for (vdl = front; vdl != 0; vdl = vdl->next)
+ vdl->declaration->readOnly = true;
+ }
+ return front;
+ }
+
+// attributes
+ VariableDeclaration *declaration;
+ VariableDeclarationList *next;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT EmptyStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(EmptyStatement)
+
+ EmptyStatement() { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return semicolonToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT ExpressionStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ExpressionStatement)
+
+ ExpressionStatement(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return expression->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT IfStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(IfStatement)
+
+ IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0):
+ expression (e), ok (t), ko (f)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return ifToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (ko)
+ return ko->lastSourceLocation();
+
+ return ok->lastSourceLocation();
+ }
+
+// attributes
+ ExpressionNode *expression;
+ Statement *ok;
+ Statement *ko;
+ SourceLocation ifToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+ SourceLocation elseToken;
+};
+
+class QML_PARSER_EXPORT DoWhileStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(DoWhileStatement)
+
+ DoWhileStatement(Statement *stmt, ExpressionNode *e):
+ statement (stmt), expression (e)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return doToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ Statement *statement;
+ ExpressionNode *expression;
+ SourceLocation doToken;
+ SourceLocation whileToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT WhileStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(WhileStatement)
+
+ WhileStatement(ExpressionNode *e, Statement *stmt):
+ expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return whileToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation whileToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ForStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ForStatement)
+
+ ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
+ initialiser (i), condition (c), expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return forToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *initialiser;
+ ExpressionNode *condition;
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation forToken;
+ SourceLocation lparenToken;
+ SourceLocation firstSemicolonToken;
+ SourceLocation secondSemicolonToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT LocalForStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(LocalForStatement)
+
+ LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
+ declarations (vlist), condition (c), expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return forToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ VariableDeclarationList *declarations;
+ ExpressionNode *condition;
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation forToken;
+ SourceLocation lparenToken;
+ SourceLocation varToken;
+ SourceLocation firstSemicolonToken;
+ SourceLocation secondSemicolonToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ForEachStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ForEachStatement)
+
+ ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt):
+ initialiser (i), expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return forToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *initialiser;
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation forToken;
+ SourceLocation lparenToken;
+ SourceLocation inToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT LocalForEachStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(LocalForEachStatement)
+
+ LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt):
+ declaration (v), expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return forToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ VariableDeclaration *declaration;
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation forToken;
+ SourceLocation lparenToken;
+ SourceLocation varToken;
+ SourceLocation inToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT ContinueStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ContinueStatement)
+
+ ContinueStatement(const QStringRef &l = QStringRef()):
+ label (l) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return continueToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ QStringRef label;
+ SourceLocation continueToken;
+ SourceLocation identifierToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT BreakStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(BreakStatement)
+
+ BreakStatement(const QStringRef &l):
+ label (l) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return breakToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+ // attributes
+ QStringRef label;
+ SourceLocation breakToken;
+ SourceLocation identifierToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT ReturnStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ReturnStatement)
+
+ ReturnStatement(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return returnToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ ExpressionNode *expression;
+ SourceLocation returnToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT WithStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(WithStatement)
+
+ WithStatement(ExpressionNode *e, Statement *stmt):
+ expression (e), statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return withToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+ Statement *statement;
+ SourceLocation withToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT CaseBlock: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(CaseBlock)
+
+ CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0):
+ clauses (c), defaultClause (d), moreClauses (r)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lbraceToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbraceToken; }
+
+// attributes
+ CaseClauses *clauses;
+ DefaultClause *defaultClause;
+ CaseClauses *moreClauses;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT SwitchStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(SwitchStatement)
+
+ SwitchStatement(ExpressionNode *e, CaseBlock *b):
+ expression (e), block (b)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return switchToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return block->rbraceToken; }
+
+// attributes
+ ExpressionNode *expression;
+ CaseBlock *block;
+ SourceLocation switchToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT CaseClause: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(CaseClause)
+
+ CaseClause(ExpressionNode *e, StatementList *slist):
+ expression (e), statements (slist)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return caseToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statements ? statements->lastSourceLocation() : colonToken; }
+
+// attributes
+ ExpressionNode *expression;
+ StatementList *statements;
+ SourceLocation caseToken;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT CaseClauses: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(CaseClauses)
+
+ CaseClauses(CaseClause *c):
+ clause (c), next (this)
+ { kind = K; }
+
+ CaseClauses(CaseClauses *previous, CaseClause *c):
+ clause (c)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return clause->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : clause->lastSourceLocation(); }
+
+ inline CaseClauses *finish ()
+ {
+ CaseClauses *front = next;
+ next = 0;
+ return front;
+ }
+
+//attributes
+ CaseClause *clause;
+ CaseClauses *next;
+};
+
+class QML_PARSER_EXPORT DefaultClause: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(DefaultClause)
+
+ DefaultClause(StatementList *slist):
+ statements (slist)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return defaultToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statements ? statements->lastSourceLocation() : colonToken; }
+
+// attributes
+ StatementList *statements;
+ SourceLocation defaultToken;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT LabelledStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(LabelledStatement)
+
+ LabelledStatement(const QStringRef &l, Statement *stmt):
+ label (l), statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ QStringRef label;
+ Statement *statement;
+ SourceLocation identifierToken;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT ThrowStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ThrowStatement)
+
+ ThrowStatement(ExpressionNode *e):
+ expression (e) { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return throwToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+ // attributes
+ ExpressionNode *expression;
+ SourceLocation throwToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT Catch: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(Catch)
+
+ Catch(const QStringRef &n, Block *stmt):
+ name (n), statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return catchToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ QStringRef name;
+ Block *statement;
+ SourceLocation catchToken;
+ SourceLocation lparenToken;
+ SourceLocation identifierToken;
+ SourceLocation rparenToken;
+};
+
+class QML_PARSER_EXPORT Finally: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(Finally)
+
+ Finally(Block *stmt):
+ statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return finallyToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement ? statement->lastSourceLocation() : finallyToken; }
+
+// attributes
+ Block *statement;
+ SourceLocation finallyToken;
+};
+
+class QML_PARSER_EXPORT TryStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(TryStatement)
+
+ TryStatement(Statement *stmt, Catch *c, Finally *f):
+ statement (stmt), catchExpression (c), finallyExpression (f)
+ { kind = K; }
+
+ TryStatement(Statement *stmt, Finally *f):
+ statement (stmt), catchExpression (0), finallyExpression (f)
+ { kind = K; }
+
+ TryStatement(Statement *stmt, Catch *c):
+ statement (stmt), catchExpression (c), finallyExpression (0)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return tryToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (finallyExpression)
+ return finallyExpression->statement->rbraceToken;
+ else if (catchExpression)
+ return catchExpression->statement->rbraceToken;
+
+ return statement->lastSourceLocation();
+ }
+
+// attributes
+ Statement *statement;
+ Catch *catchExpression;
+ Finally *finallyExpression;
+ SourceLocation tryToken;
+};
+
+class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(FunctionExpression)
+
+ FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b):
+ name (n), formals (f), body (b)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return functionToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbraceToken; }
+
+// attributes
+ QStringRef name;
+ FormalParameterList *formals;
+ FunctionBody *body;
+ SourceLocation functionToken;
+ SourceLocation identifierToken;
+ SourceLocation lparenToken;
+ SourceLocation rparenToken;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(FunctionDeclaration)
+
+ FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b):
+ FunctionExpression(n, f, b)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+};
+
+class QML_PARSER_EXPORT FormalParameterList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(FormalParameterList)
+
+ FormalParameterList(const QStringRef &n):
+ name (n), next (this)
+ { kind = K; }
+
+ FormalParameterList(FormalParameterList *previous, const QStringRef &n):
+ name (n)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : identifierToken; }
+
+ inline FormalParameterList *finish ()
+ {
+ FormalParameterList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ QStringRef name;
+ FormalParameterList *next;
+ SourceLocation commaToken;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT SourceElement: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(SourceElement)
+
+ inline SourceElement()
+ { kind = K; }
+};
+
+class QML_PARSER_EXPORT SourceElements: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(SourceElements)
+
+ SourceElements(SourceElement *elt):
+ element (elt), next (this)
+ { kind = K; }
+
+ SourceElements(SourceElements *previous, SourceElement *elt):
+ element (elt)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return element->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
+
+ inline SourceElements *finish ()
+ {
+ SourceElements *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ SourceElement *element;
+ SourceElements *next;
+};
+
+class QML_PARSER_EXPORT FunctionBody: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(FunctionBody)
+
+ FunctionBody(SourceElements *elts):
+ elements (elts)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return elements ? elements->firstSourceLocation() : SourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return elements ? elements->lastSourceLocation() : SourceLocation(); }
+
+// attributes
+ SourceElements *elements;
+};
+
+class QML_PARSER_EXPORT Program: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(Program)
+
+ Program(SourceElements *elts):
+ elements (elts)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return elements ? elements->firstSourceLocation() : SourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return elements ? elements->lastSourceLocation() : SourceLocation(); }
+
+// attributes
+ SourceElements *elements;
+};
+
+class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(FunctionSourceElement)
+
+ FunctionSourceElement(FunctionDeclaration *f):
+ declaration (f)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return declaration->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return declaration->lastSourceLocation(); }
+
+// attributes
+ FunctionDeclaration *declaration;
+};
+
+class QML_PARSER_EXPORT StatementSourceElement: public SourceElement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(StatementSourceElement)
+
+ StatementSourceElement(Statement *stmt):
+ statement (stmt)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return statement->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+// attributes
+ Statement *statement;
+};
+
+class QML_PARSER_EXPORT DebuggerStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(DebuggerStatement)
+
+ DebuggerStatement()
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return debuggerToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ SourceLocation debuggerToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT UiQualifiedId: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiQualifiedId)
+
+ UiQualifiedId(const QStringRef &name)
+ : next(this), name(name)
+ { kind = K; }
+
+ UiQualifiedId(UiQualifiedId *previous, const QStringRef &name)
+ : name(name)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ UiQualifiedId *finish()
+ {
+ UiQualifiedId *head = next;
+ next = 0;
+ return head;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : identifierToken; }
+
+// attributes
+ UiQualifiedId *next;
+ QStringRef name;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT UiImport: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiImport)
+
+ UiImport(const QStringRef &fileName)
+ : fileName(fileName), importUri(0)
+ { kind = K; }
+
+ UiImport(UiQualifiedId *uri)
+ : importUri(uri)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return importToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return semicolonToken; }
+
+// attributes
+ QStringRef fileName;
+ UiQualifiedId *importUri;
+ QStringRef importId;
+ SourceLocation importToken;
+ SourceLocation fileNameToken;
+ SourceLocation versionToken;
+ SourceLocation asToken;
+ SourceLocation importIdToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT UiImportList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiImportList)
+
+ UiImportList(UiImport *import)
+ : import(import),
+ next(this)
+ { kind = K; }
+
+ UiImportList(UiImportList *previous, UiImport *import)
+ : import(import)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ UiImportList *finish()
+ {
+ UiImportList *head = next;
+ next = 0;
+ return head;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return import->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : import->lastSourceLocation(); }
+
+// attributes
+ UiImport *import;
+ UiImportList *next;
+};
+
+class QML_PARSER_EXPORT UiObjectMember: public Node
+{
+public:
+ virtual SourceLocation firstSourceLocation() const = 0;
+ virtual SourceLocation lastSourceLocation() const = 0;
+
+ virtual UiObjectMember *uiObjectMemberCast();
+};
+
+class QML_PARSER_EXPORT UiObjectMemberList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiObjectMemberList)
+
+ UiObjectMemberList(UiObjectMember *member)
+ : next(this), member(member)
+ { kind = K; }
+
+ UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member)
+ : member(member)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return member->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
+
+ UiObjectMemberList *finish()
+ {
+ UiObjectMemberList *head = next;
+ next = 0;
+ return head;
+ }
+
+// attributes
+ UiObjectMemberList *next;
+ UiObjectMember *member;
+};
+
+class QML_PARSER_EXPORT UiProgram: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiProgram)
+
+ UiProgram(UiImportList *imports, UiObjectMemberList *members)
+ : imports(imports), members(members)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (imports)
+ return imports->firstSourceLocation();
+ else if (members)
+ return members->firstSourceLocation();
+ return SourceLocation();
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (members)
+ return members->lastSourceLocation();
+ else if (imports)
+ return imports->lastSourceLocation();
+ return SourceLocation();
+ }
+
+// attributes
+ UiImportList *imports;
+ UiObjectMemberList *members;
+};
+
+class QML_PARSER_EXPORT UiArrayMemberList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiArrayMemberList)
+
+ UiArrayMemberList(UiObjectMember *member)
+ : next(this), member(member)
+ { kind = K; }
+
+ UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member)
+ : member(member)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return member->firstSourceLocation(); }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
+
+ UiArrayMemberList *finish()
+ {
+ UiArrayMemberList *head = next;
+ next = 0;
+ return head;
+ }
+
+// attributes
+ UiArrayMemberList *next;
+ UiObjectMember *member;
+ SourceLocation commaToken;
+};
+
+class QML_PARSER_EXPORT UiObjectInitializer: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiObjectInitializer)
+
+ UiObjectInitializer(UiObjectMemberList *members)
+ : members(members)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return lbraceToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbraceToken; }
+
+// attributes
+ SourceLocation lbraceToken;
+ UiObjectMemberList *members;
+ SourceLocation rbraceToken;
+};
+
+class QML_PARSER_EXPORT UiParameterList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiParameterList)
+
+ UiParameterList(const QStringRef &t, const QStringRef &n):
+ type (t), name (n), next (this)
+ { kind = K; }
+
+ UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n):
+ type (t), name (n)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ virtual void accept0(Visitor *) {}
+
+ virtual SourceLocation firstSourceLocation() const
+ { return propertyTypeToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return next ? next->lastSourceLocation() : identifierToken; }
+
+ inline UiParameterList *finish ()
+ {
+ UiParameterList *front = next;
+ next = 0;
+ return front;
+ }
+
+// attributes
+ QStringRef type;
+ QStringRef name;
+ UiParameterList *next;
+ SourceLocation commaToken;
+ SourceLocation propertyTypeToken;
+ SourceLocation identifierToken;
+};
+
+class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiPublicMember)
+
+ UiPublicMember(const QStringRef &memberType,
+ const QStringRef &name)
+ : type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
+ { kind = K; }
+
+ UiPublicMember(const QStringRef &memberType,
+ const QStringRef &name,
+ Statement *statement)
+ : type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (defaultToken.isValid())
+ return defaultToken;
+ else if (readonlyToken.isValid())
+ return readonlyToken;
+
+ return propertyToken;
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (binding)
+ return binding->lastSourceLocation();
+ if (statement)
+ return statement->lastSourceLocation();
+
+ return semicolonToken;
+ }
+
+// attributes
+ enum { Signal, Property } type;
+ QStringRef typeModifier;
+ QStringRef memberType;
+ QStringRef name;
+ Statement *statement; // initialized with a JS expression
+ UiObjectMember *binding; // initialized with a QML object or array.
+ bool isDefaultMember;
+ bool isReadonlyMember;
+ UiParameterList *parameters;
+ SourceLocation defaultToken;
+ SourceLocation readonlyToken;
+ SourceLocation propertyToken;
+ SourceLocation typeModifierToken;
+ SourceLocation typeToken;
+ SourceLocation identifierToken;
+ SourceLocation colonToken;
+ SourceLocation semicolonToken;
+};
+
+class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiObjectDefinition)
+
+ UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId,
+ UiObjectInitializer *initializer)
+ : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
+ { kind = K; }
+
+ virtual void accept0(Visitor *visitor);
+
+ virtual SourceLocation firstSourceLocation() const
+ { return qualifiedTypeNameId->identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return initializer->rbraceToken; }
+
+// attributes
+ UiQualifiedId *qualifiedTypeNameId;
+ UiObjectInitializer *initializer;
+};
+
+class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiSourceElement)
+
+ UiSourceElement(Node *sourceElement)
+ : sourceElement(sourceElement)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
+ return funDecl->firstSourceLocation();
+ else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
+ return varStmt->firstSourceLocation();
+
+ return SourceLocation();
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ {
+ if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
+ return funDecl->lastSourceLocation();
+ else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
+ return varStmt->lastSourceLocation();
+
+ return SourceLocation();
+ }
+
+ virtual void accept0(Visitor *visitor);
+
+
+// attributes
+ Node *sourceElement;
+};
+
+class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiObjectBinding)
+
+ UiObjectBinding(UiQualifiedId *qualifiedId,
+ UiQualifiedId *qualifiedTypeNameId,
+ UiObjectInitializer *initializer)
+ : qualifiedId(qualifiedId),
+ qualifiedTypeNameId(qualifiedTypeNameId),
+ initializer(initializer),
+ hasOnToken(false)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (hasOnToken && qualifiedTypeNameId)
+ return qualifiedTypeNameId->identifierToken;
+
+ return qualifiedId->identifierToken;
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return initializer->rbraceToken; }
+
+ virtual void accept0(Visitor *visitor);
+
+
+// attributes
+ UiQualifiedId *qualifiedId;
+ UiQualifiedId *qualifiedTypeNameId;
+ UiObjectInitializer *initializer;
+ SourceLocation colonToken;
+ bool hasOnToken;
+};
+
+class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiScriptBinding)
+
+ UiScriptBinding(UiQualifiedId *qualifiedId,
+ Statement *statement)
+ : qualifiedId(qualifiedId),
+ statement(statement)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return qualifiedId->identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return statement->lastSourceLocation(); }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiQualifiedId *qualifiedId;
+ Statement *statement;
+ SourceLocation colonToken;
+};
+
+class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiArrayBinding)
+
+ UiArrayBinding(UiQualifiedId *qualifiedId,
+ UiArrayMemberList *members)
+ : qualifiedId(qualifiedId),
+ members(members)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ { return qualifiedId->identifierToken; }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return rbracketToken; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiQualifiedId *qualifiedId;
+ UiArrayMemberList *members;
+ SourceLocation colonToken;
+ SourceLocation lbracketToken;
+ SourceLocation rbracketToken;
+};
+
+} } // namespace AST
+
+
+
+QT_QML_END_NAMESPACE
+
+#endif
diff --git a/src/qml/qml/parser/qqmljsastfwd_p.h b/src/qml/qml/parser/qqmljsastfwd_p.h
new file mode 100644
index 0000000000..dec1cbc599
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsastfwd_p.h
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLJSAST_FWD_P_H
+#define QQMLJSAST_FWD_P_H
+
+#include "qqmljsglobal_p.h"
+
+#include <QtCore/qglobal.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.
+//
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS { namespace AST {
+
+class SourceLocation
+{
+public:
+ SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
+ : offset(offset), length(length),
+ startLine(line), startColumn(column)
+ { }
+
+ bool isValid() const { return length != 0; }
+
+ quint32 begin() const { return offset; }
+ quint32 end() const { return offset + length; }
+
+// attributes
+ // ### encode
+ quint32 offset;
+ quint32 length;
+ quint32 startLine;
+ quint32 startColumn;
+};
+
+class Visitor;
+class Node;
+class ExpressionNode;
+class Statement;
+class ThisExpression;
+class IdentifierExpression;
+class NullExpression;
+class TrueLiteral;
+class FalseLiteral;
+class NumericLiteral;
+class StringLiteral;
+class RegExpLiteral;
+class ArrayLiteral;
+class ObjectLiteral;
+class ElementList;
+class Elision;
+class PropertyNameAndValueList;
+class PropertyName;
+class IdentifierPropertyName;
+class StringLiteralPropertyName;
+class NumericLiteralPropertyName;
+class ArrayMemberExpression;
+class FieldMemberExpression;
+class NewMemberExpression;
+class NewExpression;
+class CallExpression;
+class ArgumentList;
+class PostIncrementExpression;
+class PostDecrementExpression;
+class DeleteExpression;
+class VoidExpression;
+class TypeOfExpression;
+class PreIncrementExpression;
+class PreDecrementExpression;
+class UnaryPlusExpression;
+class UnaryMinusExpression;
+class TildeExpression;
+class NotExpression;
+class BinaryExpression;
+class ConditionalExpression;
+class Expression; // ### rename
+class Block;
+class StatementList;
+class VariableStatement;
+class VariableDeclarationList;
+class VariableDeclaration;
+class EmptyStatement;
+class ExpressionStatement;
+class IfStatement;
+class DoWhileStatement;
+class WhileStatement;
+class ForStatement;
+class LocalForStatement;
+class ForEachStatement;
+class LocalForEachStatement;
+class ContinueStatement;
+class BreakStatement;
+class ReturnStatement;
+class WithStatement;
+class SwitchStatement;
+class CaseBlock;
+class CaseClauses;
+class CaseClause;
+class DefaultClause;
+class LabelledStatement;
+class ThrowStatement;
+class TryStatement;
+class Catch;
+class Finally;
+class FunctionDeclaration;
+class FunctionExpression;
+class FormalParameterList;
+class FunctionBody;
+class Program;
+class SourceElements;
+class SourceElement;
+class FunctionSourceElement;
+class StatementSourceElement;
+class DebuggerStatement;
+class NestedExpression;
+
+// ui elements
+class UiProgram;
+class UiImportList;
+class UiImport;
+class UiPublicMember;
+class UiObjectDefinition;
+class UiObjectInitializer;
+class UiObjectBinding;
+class UiScriptBinding;
+class UiSourceElement;
+class UiArrayBinding;
+class UiObjectMember;
+class UiObjectMemberList;
+class UiArrayMemberList;
+class UiQualifiedId;
+
+} } // namespace AST
+
+QT_QML_END_NAMESPACE
+
+#endif
diff --git a/src/qml/qml/parser/qqmljsastvisitor.cpp b/src/qml/qml/parser/qqmljsastvisitor.cpp
new file mode 100644
index 0000000000..2d854dc735
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsastvisitor.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmljsastvisitor_p.h"
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS { namespace AST {
+
+Visitor::Visitor()
+{
+}
+
+Visitor::~Visitor()
+{
+}
+
+} } // namespace QQmlJS::AST
+
+QT_QML_END_NAMESPACE
diff --git a/src/qml/qml/parser/qqmljsastvisitor_p.h b/src/qml/qml/parser/qqmljsastvisitor_p.h
new file mode 100644
index 0000000000..991580309d
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsastvisitor_p.h
@@ -0,0 +1,329 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLJSASTVISITOR_P_H
+#define QQMLJSASTVISITOR_P_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 "qqmljsastfwd_p.h"
+#include "qqmljsglobal_p.h"
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS { namespace AST {
+
+class QML_PARSER_EXPORT Visitor
+{
+public:
+ Visitor();
+ virtual ~Visitor();
+
+ virtual bool preVisit(Node *) { return true; }
+ virtual void postVisit(Node *) {}
+
+ // Ui
+ virtual bool visit(UiProgram *) { return true; }
+ virtual bool visit(UiImportList *) { return true; }
+ virtual bool visit(UiImport *) { return true; }
+ virtual bool visit(UiPublicMember *) { return true; }
+ virtual bool visit(UiSourceElement *) { return true; }
+ virtual bool visit(UiObjectDefinition *) { return true; }
+ virtual bool visit(UiObjectInitializer *) { return true; }
+ virtual bool visit(UiObjectBinding *) { return true; }
+ virtual bool visit(UiScriptBinding *) { return true; }
+ virtual bool visit(UiArrayBinding *) { return true; }
+ virtual bool visit(UiObjectMemberList *) { return true; }
+ virtual bool visit(UiArrayMemberList *) { return true; }
+ virtual bool visit(UiQualifiedId *) { return true; }
+
+ virtual void endVisit(UiProgram *) {}
+ virtual void endVisit(UiImportList *) {}
+ virtual void endVisit(UiImport *) {}
+ virtual void endVisit(UiPublicMember *) {}
+ virtual void endVisit(UiSourceElement *) {}
+ virtual void endVisit(UiObjectDefinition *) {}
+ virtual void endVisit(UiObjectInitializer *) {}
+ virtual void endVisit(UiObjectBinding *) {}
+ virtual void endVisit(UiScriptBinding *) {}
+ virtual void endVisit(UiArrayBinding *) {}
+ virtual void endVisit(UiObjectMemberList *) {}
+ virtual void endVisit(UiArrayMemberList *) {}
+ virtual void endVisit(UiQualifiedId *) {}
+
+ // QQmlJS
+ virtual bool visit(ThisExpression *) { return true; }
+ virtual void endVisit(ThisExpression *) {}
+
+ virtual bool visit(IdentifierExpression *) { return true; }
+ virtual void endVisit(IdentifierExpression *) {}
+
+ virtual bool visit(NullExpression *) { return true; }
+ virtual void endVisit(NullExpression *) {}
+
+ virtual bool visit(TrueLiteral *) { return true; }
+ virtual void endVisit(TrueLiteral *) {}
+
+ virtual bool visit(FalseLiteral *) { return true; }
+ virtual void endVisit(FalseLiteral *) {}
+
+ virtual bool visit(StringLiteral *) { return true; }
+ virtual void endVisit(StringLiteral *) {}
+
+ virtual bool visit(NumericLiteral *) { return true; }
+ virtual void endVisit(NumericLiteral *) {}
+
+ virtual bool visit(RegExpLiteral *) { return true; }
+ virtual void endVisit(RegExpLiteral *) {}
+
+ virtual bool visit(ArrayLiteral *) { return true; }
+ virtual void endVisit(ArrayLiteral *) {}
+
+ virtual bool visit(ObjectLiteral *) { return true; }
+ virtual void endVisit(ObjectLiteral *) {}
+
+ virtual bool visit(ElementList *) { return true; }
+ virtual void endVisit(ElementList *) {}
+
+ virtual bool visit(Elision *) { return true; }
+ virtual void endVisit(Elision *) {}
+
+ virtual bool visit(PropertyNameAndValueList *) { return true; }
+ virtual void endVisit(PropertyNameAndValueList *) {}
+
+ virtual bool visit(NestedExpression *) { return true; }
+ virtual void endVisit(NestedExpression *) {}
+
+ virtual bool visit(IdentifierPropertyName *) { return true; }
+ virtual void endVisit(IdentifierPropertyName *) {}
+
+ virtual bool visit(StringLiteralPropertyName *) { return true; }
+ virtual void endVisit(StringLiteralPropertyName *) {}
+
+ virtual bool visit(NumericLiteralPropertyName *) { return true; }
+ virtual void endVisit(NumericLiteralPropertyName *) {}
+
+ virtual bool visit(ArrayMemberExpression *) { return true; }
+ virtual void endVisit(ArrayMemberExpression *) {}
+
+ virtual bool visit(FieldMemberExpression *) { return true; }
+ virtual void endVisit(FieldMemberExpression *) {}
+
+ virtual bool visit(NewMemberExpression *) { return true; }
+ virtual void endVisit(NewMemberExpression *) {}
+
+ virtual bool visit(NewExpression *) { return true; }
+ virtual void endVisit(NewExpression *) {}
+
+ virtual bool visit(CallExpression *) { return true; }
+ virtual void endVisit(CallExpression *) {}
+
+ virtual bool visit(ArgumentList *) { return true; }
+ virtual void endVisit(ArgumentList *) {}
+
+ virtual bool visit(PostIncrementExpression *) { return true; }
+ virtual void endVisit(PostIncrementExpression *) {}
+
+ virtual bool visit(PostDecrementExpression *) { return true; }
+ virtual void endVisit(PostDecrementExpression *) {}
+
+ virtual bool visit(DeleteExpression *) { return true; }
+ virtual void endVisit(DeleteExpression *) {}
+
+ virtual bool visit(VoidExpression *) { return true; }
+ virtual void endVisit(VoidExpression *) {}
+
+ virtual bool visit(TypeOfExpression *) { return true; }
+ virtual void endVisit(TypeOfExpression *) {}
+
+ virtual bool visit(PreIncrementExpression *) { return true; }
+ virtual void endVisit(PreIncrementExpression *) {}
+
+ virtual bool visit(PreDecrementExpression *) { return true; }
+ virtual void endVisit(PreDecrementExpression *) {}
+
+ virtual bool visit(UnaryPlusExpression *) { return true; }
+ virtual void endVisit(UnaryPlusExpression *) {}
+
+ virtual bool visit(UnaryMinusExpression *) { return true; }
+ virtual void endVisit(UnaryMinusExpression *) {}
+
+ virtual bool visit(TildeExpression *) { return true; }
+ virtual void endVisit(TildeExpression *) {}
+
+ virtual bool visit(NotExpression *) { return true; }
+ virtual void endVisit(NotExpression *) {}
+
+ virtual bool visit(BinaryExpression *) { return true; }
+ virtual void endVisit(BinaryExpression *) {}
+
+ virtual bool visit(ConditionalExpression *) { return true; }
+ virtual void endVisit(ConditionalExpression *) {}
+
+ virtual bool visit(Expression *) { return true; }
+ virtual void endVisit(Expression *) {}
+
+ virtual bool visit(Block *) { return true; }
+ virtual void endVisit(Block *) {}
+
+ virtual bool visit(StatementList *) { return true; }
+ virtual void endVisit(StatementList *) {}
+
+ virtual bool visit(VariableStatement *) { return true; }
+ virtual void endVisit(VariableStatement *) {}
+
+ virtual bool visit(VariableDeclarationList *) { return true; }
+ virtual void endVisit(VariableDeclarationList *) {}
+
+ virtual bool visit(VariableDeclaration *) { return true; }
+ virtual void endVisit(VariableDeclaration *) {}
+
+ virtual bool visit(EmptyStatement *) { return true; }
+ virtual void endVisit(EmptyStatement *) {}
+
+ virtual bool visit(ExpressionStatement *) { return true; }
+ virtual void endVisit(ExpressionStatement *) {}
+
+ virtual bool visit(IfStatement *) { return true; }
+ virtual void endVisit(IfStatement *) {}
+
+ virtual bool visit(DoWhileStatement *) { return true; }
+ virtual void endVisit(DoWhileStatement *) {}
+
+ virtual bool visit(WhileStatement *) { return true; }
+ virtual void endVisit(WhileStatement *) {}
+
+ virtual bool visit(ForStatement *) { return true; }
+ virtual void endVisit(ForStatement *) {}
+
+ virtual bool visit(LocalForStatement *) { return true; }
+ virtual void endVisit(LocalForStatement *) {}
+
+ virtual bool visit(ForEachStatement *) { return true; }
+ virtual void endVisit(ForEachStatement *) {}
+
+ virtual bool visit(LocalForEachStatement *) { return true; }
+ virtual void endVisit(LocalForEachStatement *) {}
+
+ virtual bool visit(ContinueStatement *) { return true; }
+ virtual void endVisit(ContinueStatement *) {}
+
+ virtual bool visit(BreakStatement *) { return true; }
+ virtual void endVisit(BreakStatement *) {}
+
+ virtual bool visit(ReturnStatement *) { return true; }
+ virtual void endVisit(ReturnStatement *) {}
+
+ virtual bool visit(WithStatement *) { return true; }
+ virtual void endVisit(WithStatement *) {}
+
+ virtual bool visit(SwitchStatement *) { return true; }
+ virtual void endVisit(SwitchStatement *) {}
+
+ virtual bool visit(CaseBlock *) { return true; }
+ virtual void endVisit(CaseBlock *) {}
+
+ virtual bool visit(CaseClauses *) { return true; }
+ virtual void endVisit(CaseClauses *) {}
+
+ virtual bool visit(CaseClause *) { return true; }
+ virtual void endVisit(CaseClause *) {}
+
+ virtual bool visit(DefaultClause *) { return true; }
+ virtual void endVisit(DefaultClause *) {}
+
+ virtual bool visit(LabelledStatement *) { return true; }
+ virtual void endVisit(LabelledStatement *) {}
+
+ virtual bool visit(ThrowStatement *) { return true; }
+ virtual void endVisit(ThrowStatement *) {}
+
+ virtual bool visit(TryStatement *) { return true; }
+ virtual void endVisit(TryStatement *) {}
+
+ virtual bool visit(Catch *) { return true; }
+ virtual void endVisit(Catch *) {}
+
+ virtual bool visit(Finally *) { return true; }
+ virtual void endVisit(Finally *) {}
+
+ virtual bool visit(FunctionDeclaration *) { return true; }
+ virtual void endVisit(FunctionDeclaration *) {}
+
+ virtual bool visit(FunctionExpression *) { return true; }
+ virtual void endVisit(FunctionExpression *) {}
+
+ virtual bool visit(FormalParameterList *) { return true; }
+ virtual void endVisit(FormalParameterList *) {}
+
+ virtual bool visit(FunctionBody *) { return true; }
+ virtual void endVisit(FunctionBody *) {}
+
+ virtual bool visit(Program *) { return true; }
+ virtual void endVisit(Program *) {}
+
+ virtual bool visit(SourceElements *) { return true; }
+ virtual void endVisit(SourceElements *) {}
+
+ virtual bool visit(FunctionSourceElement *) { return true; }
+ virtual void endVisit(FunctionSourceElement *) {}
+
+ virtual bool visit(StatementSourceElement *) { return true; }
+ virtual void endVisit(StatementSourceElement *) {}
+
+ virtual bool visit(DebuggerStatement *) { return true; }
+ virtual void endVisit(DebuggerStatement *) {}
+};
+
+} } // namespace AST
+
+QT_QML_END_NAMESPACE
+
+#endif // QQMLJSASTVISITOR_P_H
diff --git a/src/qml/qml/parser/qqmljsengine_p.cpp b/src/qml/qml/parser/qqmljsengine_p.cpp
new file mode 100644
index 0000000000..459ba8d7dc
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsengine_p.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmljsengine_p.h"
+#include "qqmljsglobal_p.h"
+
+#include <qnumeric.h>
+#include <QHash>
+#include <QDebug>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+static int toDigit(char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return c - '0';
+ else if ((c >= 'a') && (c <= 'z'))
+ return 10 + c - 'a';
+ else if ((c >= 'A') && (c <= 'Z'))
+ return 10 + c - 'A';
+ return -1;
+}
+
+double integerFromString(const char *buf, int size, int radix)
+{
+ if (size == 0)
+ return qSNaN();
+
+ double sign = 1.0;
+ int i = 0;
+ if (buf[0] == '+') {
+ ++i;
+ } else if (buf[0] == '-') {
+ sign = -1.0;
+ ++i;
+ }
+
+ if (((size-i) >= 2) && (buf[i] == '0')) {
+ if (((buf[i+1] == 'x') || (buf[i+1] == 'X'))
+ && (radix < 34)) {
+ if ((radix != 0) && (radix != 16))
+ return 0;
+ radix = 16;
+ i += 2;
+ } else {
+ if (radix == 0) {
+ radix = 8;
+ ++i;
+ }
+ }
+ } else if (radix == 0) {
+ radix = 10;
+ }
+
+ int j = i;
+ for ( ; i < size; ++i) {
+ int d = toDigit(buf[i]);
+ if ((d == -1) || (d >= radix))
+ break;
+ }
+ double result;
+ if (j == i) {
+ if (!qstrcmp(buf, "Infinity"))
+ result = qInf();
+ else
+ result = qSNaN();
+ } else {
+ result = 0;
+ double multiplier = 1;
+ for (--i ; i >= j; --i, multiplier *= radix)
+ result += toDigit(buf[i]) * multiplier;
+ }
+ result *= sign;
+ return result;
+}
+
+double integerFromString(const QString &str, int radix)
+{
+ QByteArray ba = str.trimmed().toLatin1();
+ return integerFromString(ba.constData(), ba.size(), radix);
+}
+
+
+Engine::Engine()
+ : _lexer(0)
+{ }
+
+Engine::~Engine()
+{ }
+
+void Engine::setCode(const QString &code)
+{ _code = code; }
+
+void Engine::addComment(int pos, int len, int line, int col)
+{ if (len > 0) _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col)); }
+
+QList<QQmlJS::AST::SourceLocation> Engine::comments() const
+{ return _comments; }
+
+Lexer *Engine::lexer() const
+{ return _lexer; }
+
+void Engine::setLexer(Lexer *lexer)
+{ _lexer = lexer; }
+
+MemoryPool *Engine::pool()
+{ return &_pool; }
+
+QStringRef Engine::newStringRef(const QString &text)
+{
+ const int pos = _extraCode.length();
+ _extraCode += text;
+ return _extraCode.midRef(pos, text.length());
+}
+
+QStringRef Engine::newStringRef(const QChar *chars, int size)
+{ return newStringRef(QString(chars, size)); }
+
+} // end of namespace QQmlJS
+
+QT_QML_END_NAMESPACE
diff --git a/src/qml/qml/parser/qqmljsengine_p.h b/src/qml/qml/parser/qqmljsengine_p.h
new file mode 100644
index 0000000000..3cb78de4eb
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsengine_p.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLJSENGINE_P_H
+#define QQMLJSENGINE_P_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 "qqmljsglobal_p.h"
+#include "qqmljsastfwd_p.h"
+#include "qqmljsmemorypool_p.h"
+
+#include <QString>
+#include <QSet>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+class Lexer;
+class MemoryPool;
+
+class QML_PARSER_EXPORT DiagnosticMessage
+{
+public:
+ enum Kind { Warning, Error };
+
+ DiagnosticMessage()
+ : kind(Error) {}
+
+ DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
+ : kind(kind), loc(loc), message(message) {}
+
+ bool isWarning() const
+ { return kind == Warning; }
+
+ bool isError() const
+ { return kind == Error; }
+
+ Kind kind;
+ AST::SourceLocation loc;
+ QString message;
+};
+
+class QML_PARSER_EXPORT Engine
+{
+ Lexer *_lexer;
+ MemoryPool _pool;
+ QList<AST::SourceLocation> _comments;
+ QString _extraCode;
+ QString _code;
+
+public:
+ Engine();
+ ~Engine();
+
+ void setCode(const QString &code);
+
+ void addComment(int pos, int len, int line, int col);
+ QList<AST::SourceLocation> comments() const;
+
+ Lexer *lexer() const;
+ void setLexer(Lexer *lexer);
+
+ MemoryPool *pool();
+
+ inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); }
+
+ QStringRef newStringRef(const QString &s);
+ QStringRef newStringRef(const QChar *chars, int size);
+};
+
+double integerFromString(const char *buf, int size, int radix);
+
+} // end of namespace QQmlJS
+
+QT_QML_END_NAMESPACE
+
+#endif // QQMLJSENGINE_P_H
diff --git a/src/qml/qml/parser/qqmljsglobal_p.h b/src/qml/qml/parser/qqmljsglobal_p.h
new file mode 100644
index 0000000000..81c90310ad
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsglobal_p.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QQMLJSGLOBAL_P_H
+#define QQMLJSGLOBAL_P_H
+
+#include <QtCore/qglobal.h>
+
+#ifdef QT_CREATOR
+# define QT_QML_BEGIN_NAMESPACE
+# define QT_QML_END_NAMESPACE
+
+# ifdef QDECLARATIVEJS_BUILD_DIR
+# define QML_PARSER_EXPORT Q_DECL_EXPORT
+# elif QML_BUILD_STATIC_LIB
+# define QML_PARSER_EXPORT
+# else
+# define QML_PARSER_EXPORT Q_DECL_IMPORT
+# endif // QQMLJS_BUILD_DIR
+
+#else // !QT_CREATOR
+# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
+# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
+# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB)
+ // QmlDevTools is a static library
+# define QML_PARSER_EXPORT
+# else
+# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT
+# endif
+#endif // QT_CREATOR
+
+#endif // QQMLJSGLOBAL_P_H
diff --git a/src/qml/qml/parser/qqmljsgrammar.cpp b/src/qml/qml/parser/qqmljsgrammar.cpp
new file mode 100644
index 0000000000..f69f809ee3
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsgrammar.cpp
@@ -0,0 +1,1013 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This file was generated by qlalr - DO NOT EDIT!
+#include "qqmljsgrammar_p.h"
+
+QT_BEGIN_NAMESPACE
+
+const char *const QQmlJSGrammar::spell [] = {
+ "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ",", "continue",
+ "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===",
+ "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier",
+ "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=",
+ "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=",
+ "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return",
+ ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch",
+ "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^",
+ "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", "public",
+ "import", "as", "on", 0, 0, 0, 0, 0, 0, 0,
+ 0, 0};
+
+const short QQmlJSGrammar::lhs [] = {
+ 102, 102, 102, 102, 102, 102, 103, 109, 109, 112,
+ 112, 114, 113, 113, 113, 113, 113, 113, 113, 113,
+ 116, 111, 110, 119, 119, 120, 120, 121, 121, 118,
+ 107, 107, 107, 107, 123, 123, 123, 123, 123, 123,
+ 123, 107, 131, 131, 131, 132, 132, 133, 133, 107,
+ 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
+ 107, 107, 107, 107, 107, 107, 117, 117, 117, 117,
+ 117, 136, 136, 136, 136, 136, 136, 136, 136, 136,
+ 136, 136, 136, 136, 136, 136, 136, 136, 136, 122,
+ 138, 138, 138, 138, 137, 137, 140, 140, 142, 142,
+ 142, 142, 142, 142, 143, 143, 143, 143, 143, 143,
+ 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
+ 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
+ 143, 143, 143, 143, 143, 144, 144, 115, 115, 115,
+ 115, 115, 147, 147, 148, 148, 148, 148, 146, 146,
+ 149, 149, 150, 150, 151, 151, 151, 152, 152, 152,
+ 152, 152, 152, 152, 152, 152, 152, 153, 153, 153,
+ 153, 154, 154, 154, 155, 155, 155, 155, 156, 156,
+ 156, 156, 156, 156, 156, 157, 157, 157, 157, 157,
+ 157, 158, 158, 158, 158, 158, 159, 159, 159, 159,
+ 159, 160, 160, 161, 161, 162, 162, 163, 163, 164,
+ 164, 165, 165, 166, 166, 167, 167, 168, 168, 169,
+ 169, 170, 170, 171, 171, 141, 141, 172, 172, 173,
+ 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
+ 173, 105, 105, 174, 174, 175, 175, 176, 176, 104,
+ 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
+ 104, 104, 104, 104, 124, 185, 185, 184, 184, 135,
+ 135, 186, 186, 187, 187, 189, 189, 188, 190, 193,
+ 191, 191, 194, 192, 192, 125, 126, 126, 127, 127,
+ 177, 177, 177, 177, 177, 177, 177, 178, 178, 178,
+ 178, 179, 179, 179, 179, 180, 180, 128, 129, 195,
+ 195, 198, 198, 196, 196, 199, 197, 181, 181, 181,
+ 182, 182, 130, 130, 130, 200, 201, 183, 183, 134,
+ 145, 205, 205, 202, 202, 203, 203, 206, 108, 108,
+ 207, 207, 106, 106, 204, 204, 139, 139, 208};
+
+const short QQmlJSGrammar::rhs [] = {
+ 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
+ 2, 1, 2, 2, 3, 3, 5, 5, 4, 4,
+ 2, 0, 1, 1, 2, 1, 3, 2, 3, 2,
+ 1, 5, 4, 4, 1, 1, 1, 1, 1, 1,
+ 1, 3, 1, 1, 1, 0, 1, 2, 4, 6,
+ 6, 3, 3, 7, 7, 4, 4, 5, 5, 5,
+ 6, 6, 10, 6, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 3, 3, 4, 5, 3, 4, 3, 1,
+ 1, 2, 3, 4, 1, 2, 3, 5, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4,
+ 3, 5, 1, 2, 4, 4, 4, 3, 0, 1,
+ 1, 3, 1, 1, 1, 2, 2, 1, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 1, 3, 3,
+ 3, 1, 3, 3, 1, 3, 3, 3, 1, 3,
+ 3, 3, 3, 3, 3, 1, 3, 3, 3, 3,
+ 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
+ 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
+ 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
+ 3, 1, 5, 1, 5, 1, 3, 1, 3, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 3, 0, 1, 1, 3, 0, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 3, 1, 2, 0, 1, 3,
+ 3, 1, 1, 1, 3, 1, 3, 2, 2, 2,
+ 0, 1, 2, 0, 1, 1, 2, 2, 7, 5,
+ 7, 7, 5, 9, 10, 7, 8, 2, 2, 3,
+ 3, 2, 2, 3, 3, 3, 3, 5, 5, 3,
+ 5, 1, 2, 0, 1, 4, 3, 3, 3, 3,
+ 3, 3, 3, 3, 4, 5, 2, 2, 2, 8,
+ 8, 1, 3, 0, 1, 0, 1, 1, 1, 1,
+ 1, 2, 1, 1, 0, 1, 0, 1, 2};
+
+const short QQmlJSGrammar::action_default [] = {
+ 0, 0, 22, 0, 0, 0, 22, 0, 175, 242,
+ 206, 214, 210, 154, 226, 202, 3, 139, 73, 155,
+ 218, 222, 143, 172, 153, 158, 138, 192, 179, 0,
+ 80, 81, 76, 345, 67, 347, 0, 0, 0, 0,
+ 78, 0, 0, 74, 77, 71, 0, 0, 68, 70,
+ 69, 79, 72, 0, 75, 0, 0, 168, 0, 0,
+ 155, 174, 157, 156, 0, 0, 0, 170, 171, 169,
+ 173, 0, 203, 0, 0, 0, 0, 193, 0, 0,
+ 0, 0, 0, 0, 183, 0, 0, 0, 177, 178,
+ 176, 181, 185, 184, 182, 180, 195, 194, 196, 0,
+ 211, 0, 207, 0, 0, 149, 136, 148, 137, 105,
+ 106, 107, 132, 108, 133, 109, 110, 111, 112, 113,
+ 114, 115, 116, 117, 118, 119, 120, 121, 134, 122,
+ 123, 124, 125, 126, 127, 128, 129, 130, 131, 135,
+ 0, 0, 147, 243, 150, 0, 151, 0, 152, 146,
+ 0, 239, 232, 230, 237, 238, 236, 235, 241, 234,
+ 233, 231, 240, 227, 0, 215, 0, 0, 219, 0,
+ 0, 223, 0, 0, 149, 141, 0, 140, 0, 145,
+ 159, 0, 346, 334, 335, 0, 332, 0, 333, 0,
+ 336, 250, 257, 256, 264, 252, 0, 253, 337, 0,
+ 344, 254, 255, 260, 258, 341, 338, 343, 261, 0,
+ 272, 0, 0, 0, 0, 345, 67, 0, 347, 68,
+ 244, 286, 69, 0, 0, 0, 273, 0, 0, 262,
+ 263, 0, 251, 259, 287, 288, 331, 342, 0, 302,
+ 303, 304, 305, 0, 298, 299, 300, 301, 328, 329,
+ 0, 0, 0, 0, 0, 291, 292, 248, 246, 208,
+ 216, 212, 228, 204, 249, 0, 155, 220, 224, 197,
+ 186, 0, 0, 205, 0, 0, 0, 0, 198, 0,
+ 0, 0, 0, 0, 190, 188, 191, 189, 187, 200,
+ 199, 201, 0, 213, 0, 209, 0, 247, 155, 0,
+ 229, 244, 245, 0, 244, 0, 0, 294, 0, 0,
+ 0, 296, 0, 217, 0, 0, 221, 0, 0, 225,
+ 284, 0, 276, 285, 279, 0, 283, 0, 244, 277,
+ 0, 244, 0, 0, 295, 0, 0, 0, 297, 346,
+ 334, 0, 0, 336, 0, 330, 0, 320, 0, 0,
+ 0, 290, 0, 289, 0, 348, 0, 104, 266, 269,
+ 0, 105, 272, 108, 133, 110, 111, 76, 115, 116,
+ 67, 117, 120, 74, 77, 68, 244, 69, 79, 123,
+ 72, 125, 75, 127, 128, 273, 130, 131, 135, 0,
+ 97, 0, 0, 99, 103, 101, 88, 100, 102, 0,
+ 98, 87, 267, 265, 143, 144, 149, 0, 142, 0,
+ 319, 0, 306, 307, 0, 318, 0, 0, 0, 309,
+ 314, 312, 315, 0, 0, 313, 314, 0, 310, 0,
+ 311, 268, 317, 0, 268, 316, 0, 321, 322, 0,
+ 268, 323, 324, 0, 0, 325, 0, 0, 0, 326,
+ 327, 161, 160, 0, 0, 0, 293, 0, 0, 0,
+ 308, 281, 274, 0, 282, 278, 0, 280, 270, 0,
+ 271, 275, 91, 0, 0, 95, 82, 0, 84, 93,
+ 0, 85, 94, 96, 86, 92, 83, 0, 89, 165,
+ 163, 167, 164, 162, 166, 339, 6, 340, 4, 2,
+ 65, 90, 0, 0, 68, 70, 69, 31, 5, 0,
+ 66, 0, 45, 44, 43, 0, 0, 58, 0, 59,
+ 35, 36, 37, 38, 40, 41, 62, 39, 0, 45,
+ 0, 0, 0, 0, 0, 54, 0, 55, 0, 0,
+ 26, 0, 0, 63, 27, 0, 30, 28, 24, 0,
+ 29, 25, 0, 56, 0, 57, 143, 0, 60, 64,
+ 0, 0, 0, 0, 61, 0, 52, 46, 53, 47,
+ 0, 0, 0, 0, 49, 0, 50, 51, 48, 0,
+ 0, 143, 268, 0, 0, 42, 105, 272, 108, 133,
+ 110, 111, 76, 115, 116, 67, 117, 120, 74, 77,
+ 68, 244, 69, 79, 123, 72, 125, 75, 127, 128,
+ 273, 130, 131, 135, 0, 32, 33, 0, 34, 8,
+ 0, 10, 0, 9, 0, 1, 21, 12, 0, 13,
+ 0, 14, 0, 19, 20, 0, 15, 16, 0, 17,
+ 18, 11, 23, 7, 349};
+
+const short QQmlJSGrammar::goto_default [] = {
+ 7, 625, 207, 196, 205, 508, 496, 624, 643, 495,
+ 623, 621, 626, 22, 622, 18, 507, 549, 539, 546,
+ 541, 526, 191, 195, 197, 201, 233, 208, 230, 530,
+ 570, 569, 200, 232, 26, 474, 473, 356, 355, 9,
+ 354, 357, 107, 17, 145, 24, 13, 144, 19, 25,
+ 57, 23, 8, 28, 27, 269, 15, 263, 10, 259,
+ 12, 261, 11, 260, 20, 267, 21, 268, 14, 262,
+ 258, 299, 411, 264, 265, 202, 193, 192, 204, 203,
+ 229, 194, 360, 359, 231, 463, 462, 321, 322, 465,
+ 324, 464, 323, 419, 423, 426, 422, 421, 441, 442,
+ 185, 199, 181, 184, 198, 206, 0};
+
+const short QQmlJSGrammar::action_index [] = {
+ 404, 1275, 2411, 2411, 2509, 1000, 68, 92, 90, -102,
+ 88, 62, 60, 256, -102, 298, 86, -102, -102, 638,
+ 83, 134, 172, 219, -102, -102, -102, 454, 194, 1275,
+ -102, -102, -102, 381, -102, 2215, 1555, 1275, 1275, 1275,
+ -102, 790, 1275, -102, -102, -102, 1275, 1275, -102, -102,
+ -102, -102, -102, 1275, -102, 1275, 1275, -102, 1275, 1275,
+ 102, 217, -102, -102, 1275, 1275, 1275, -102, -102, -102,
+ 204, 1275, 304, 1275, 1275, 1275, 1275, 539, 1275, 1275,
+ 1275, 1275, 1275, 1275, 308, 1275, 1275, 1275, 103, 131,
+ 135, 308, 210, 225, 216, 308, 444, 390, 434, 1275,
+ 82, 1275, 100, 2117, 1275, 1275, -102, -102, -102, -102,
+ -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
+ -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
+ -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
+ 139, 1275, -102, -102, 91, 10, -102, 1275, -102, -102,
+ 1275, -102, -102, -102, -102, -102, -102, -102, -102, -102,
+ -102, -102, -102, -102, 1275, 26, 1275, 1275, 69, 66,
+ 1275, -102, 2117, 1275, 1275, -102, 97, -102, 44, -102,
+ -102, 67, -102, 297, 78, 24, -102, 291, -102, 36,
+ 2411, -102, -102, -102, -102, -102, 234, -102, -102, 12,
+ -102, -102, -102, -102, -102, -102, 2411, -102, -102, 464,
+ -102, 461, 115, 2509, 42, 381, 58, 46, 2705, 70,
+ 1275, -102, 74, 57, 1275, 65, -102, 59, 61, -102,
+ -102, 367, -102, -102, -102, -102, -102, -102, 106, -102,
+ -102, -102, -102, 87, -102, -102, -102, -102, -102, -102,
+ 56, 55, 1275, 99, 84, -102, -102, 1461, -102, 75,
+ 48, 52, -102, 306, 72, 53, 579, 77, 110, 370,
+ 230, 381, 1275, 286, 1275, 1275, 1275, 1275, 380, 1275,
+ 1275, 1275, 1275, 1275, 184, 169, 166, 190, 198, 460,
+ 363, 353, 1275, 50, 1275, 63, 1275, -102, 638, 1275,
+ -102, 1275, 64, 39, 1275, 30, 2509, -102, 1275, 173,
+ 2509, -102, 1275, 79, 1275, 1275, 81, 80, 1275, -102,
+ 71, 149, 32, -102, -102, 1275, -102, 381, 1275, -102,
+ 73, 1275, 76, 2509, -102, 1275, 142, 2509, -102, -16,
+ 381, -42, -12, 2411, -39, -102, 2509, -102, 1275, 154,
+ 2509, 14, 2509, -102, 20, 16, -32, -102, -102, 2509,
+ -51, 519, -4, 511, 136, 1275, 2509, -2, -35, 395,
+ -1, -27, 908, 4, 6, -102, 1370, -102, 0, -36,
+ 27, 1275, 47, 22, 1275, 45, 1275, 21, 17, 1275,
+ -102, 2313, 144, -102, -102, -102, -102, -102, -102, 1275,
+ -102, -102, -102, -102, 274, -102, 1275, -21, -102, 2509,
+ -102, 138, -102, -102, 2509, -102, 1275, 132, 5, -102,
+ 40, -102, 41, 101, 1275, -102, 38, 34, -102, -38,
+ -102, 2509, -102, 105, 2509, -102, 245, -102, -102, 96,
+ 2509, 11, -102, -7, -11, -102, 352, 8, 18, -102,
+ -102, -102, -102, 1275, 129, 2509, -102, 1275, 130, 2509,
+ -102, 49, -102, 226, -102, -102, 1275, -102, -102, 362,
+ -102, -102, -102, 107, 1837, -102, -102, 1649, -102, -102,
+ 1743, -102, -102, -102, -102, -102, -102, 114, -102, -102,
+ -102, -102, -102, -102, -102, -102, -102, 2411, -102, -102,
+ -102, 94, 9, 818, 189, -10, 31, -102, -102, 223,
+ -102, 191, -102, -102, -102, 300, 178, -102, 1928, -102,
+ -102, -102, -102, -102, -102, -102, -102, -102, 257, -25,
+ 381, 195, -22, 305, 240, -102, -6, -102, 818, 127,
+ -102, -18, 818, -102, -102, 1184, -102, -102, -102, 1092,
+ -102, -102, 237, -102, 1928, -102, 294, -8, -102, -102,
+ 176, 381, 19, 1928, -102, 165, -102, 174, -102, 2,
+ -52, 381, 183, 381, -102, 117, -102, -102, -102, 2019,
+ 880, 285, 2607, 1555, 3, -102, 522, 35, 453, 108,
+ 1275, 2509, 51, 23, 475, 54, -17, 700, 7, 43,
+ -102, 1370, -102, 28, -3, 33, 1275, 37, 15, 1275,
+ 25, 1275, 1, 13, 124, -102, -102, 29, -102, -102,
+ 728, -102, 250, -43, 627, -102, -102, 231, 372, -102,
+ 222, -102, 111, -102, -102, 381, -102, -102, 104, -102,
+ -102, -102, -102, -102, -102,
+
+ -107, 9, -103, 2, 5, 266, 1, -107, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, -39,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, 86,
+ -107, -107, -107, 8, -107, -107, -22, 19, 71, 174,
+ -107, 186, 171, -107, -107, -107, 184, 178, -107, -107,
+ -107, -107, -107, 144, -107, 124, 150, -107, 165, 161,
+ -107, -107, -107, -107, 156, 160, 157, -107, -107, -107,
+ -107, 147, -107, 142, 135, 179, 166, -107, 177, 170,
+ 117, 72, 134, 92, -107, 75, 94, 66, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, 181,
+ -107, 106, -107, 143, 78, 55, -107, -107, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, -5, -107, -107, -107, -107, -107, 54, -107, -107,
+ 51, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, -107, -107, -107, 114, -107, 113, 38, -107, -107,
+ 41, -107, 231, 63, 112, -107, -107, -107, -107, -107,
+ -107, -107, -107, 30, -107, -107, -107, 52, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, -107, -107, -107, -107, -107, 36, -107, -107, 45,
+ -107, 42, -107, 40, -107, 80, -107, -107, 77, -107,
+ 88, -107, -107, -107, 83, 74, -107, -107, -107, -107,
+ -107, -10, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, -107, 23, -107, -107, -107, -107, 100, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, 4, 223, -107, 230, 236, 222, 205, -107, 127,
+ 125, 115, 96, 102, -107, -107, -107, -107, -107, -107,
+ -107, -107, 234, -107, 215, -107, 199, -107, -107, 197,
+ -107, 190, -107, -107, 163, -107, 90, -107, 0, -107,
+ -1, -107, 203, -107, 189, 211, -107, -107, 195, -107,
+ -107, -107, -107, -107, -107, 191, -107, 98, 119, -107,
+ -107, 95, -107, 81, -107, 79, -107, 82, -107, -107,
+ 101, -107, -107, -16, -107, -107, 53, -107, 46, -107,
+ 57, -107, 59, -107, -107, -107, -107, -107, -107, 35,
+ -107, 33, -107, 39, -107, 89, 67, -107, -107, 58,
+ -107, -107, 84, -107, -107, -107, 73, -107, -107, -107,
+ -107, 65, -107, 43, 93, -107, 109, -107, -107, 49,
+ -107, 47, -107, -107, -107, -107, -107, -107, -107, 50,
+ -107, -107, -107, -107, -107, -107, 108, -107, -107, 61,
+ -107, -107, -107, -107, 62, -107, 68, -107, -107, -107,
+ -107, -107, -23, -107, 69, -107, -19, -107, -107, -107,
+ -107, 97, -107, -107, 99, -107, -107, -107, -107, -107,
+ 60, -61, -107, -107, 34, -107, 37, -107, 29, -107,
+ -107, -107, -107, 32, -107, 76, -107, 44, -107, 56,
+ -107, -107, -107, -107, -107, -107, 31, -107, -107, 116,
+ -107, -107, -107, -107, -6, -107, -107, 70, -107, -107,
+ 64, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -107, -107, -107, -107, -107, -107, -107, 193, -107, -107,
+ -107, -107, -107, 7, -107, -107, -107, -107, -107, -107,
+ -107, -20, -107, -107, -107, -7, -107, -107, 290, -107,
+ -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+ -2, -25, -107, -15, -107, -107, -107, -107, 172, -107,
+ -107, -107, 287, -107, -107, 288, -107, -107, -107, 291,
+ -107, -107, -107, -107, 336, -107, -107, 20, -107, -107,
+ 15, 3, -107, 304, -107, -107, -107, 24, -107, -107,
+ -107, 28, 21, 26, -107, -107, -107, -107, -107, 320,
+ 104, -107, 13, 381, -3, -107, 6, -107, 10, -107,
+ 167, 22, -107, -107, 12, -107, -107, 87, -107, -107,
+ -107, 25, -107, -107, -107, -107, 11, -107, 14, 85,
+ -107, 121, -107, -107, -107, -107, -107, 27, -107, -107,
+ 17, -107, -107, 18, 91, -107, -107, -107, 16, -107,
+ -107, -107, -107, -107, -107, -4, -107, -107, -107, -107,
+ -107, -107, -107, -107, -107};
+
+const short QQmlJSGrammar::action_info [] = {
+ 416, 257, 533, -132, 403, -113, 346, -102, 575, 348,
+ 572, -121, 531, -103, -121, 545, 345, 430, 342, 348,
+ 340, 343, 440, 401, 391, 545, 563, 389, 538, 446,
+ 352, 444, -129, 416, -124, -102, 545, 453, 420, 408,
+ -124, 431, -132, 424, -126, 424, 424, 620, 440, 457,
+ -103, 440, -129, 457, -126, 440, 560, 453, -113, 257,
+ 565, 346, 545, 335, 272, 346, 466, 236, 448, 190,
+ 149, 164, 141, 170, 99, 511, 272, 409, 257, 312,
+ 296, 414, 348, 312, 189, 164, 187, 318, 325, 71,
+ 306, 252, 644, 416, 141, 453, 292, 457, 440, 147,
+ 304, 71, 443, 183, 179, 141, 0, 141, 0, 172,
+ 99, 427, 434, 141, 301, 477, 444, 0, 0, 0,
+ 0, 0, 141, 0, 0, 0, 0, 292, 173, 294,
+ 58, 294, 542, 251, 331, 542, 333, 141, 141, 101,
+ 141, 59, 0, 58, 62, 256, 255, 141, 247, 246,
+ 141, 399, 0, 177, 59, 63, 428, 327, 620, 254,
+ 314, 101, 141, 478, 315, 640, 639, 242, 241, 249,
+ 248, 58, 634, 633, 488, 58, 249, 248, 577, 576,
+ 615, 141, 59, 543, 166, 518, 59, 172, 167, 455,
+ 459, 85, 418, 86, 85, 142, 86, 249, 248, 413,
+ 412, 567, 337, 512, 87, 512, 173, 87, 174, 85,
+ 328, 86, 512, 0, 350, 85, 64, 86, 529, 85,
+ 512, 86, 87, 85, 512, 86, 568, 566, 87, 64,
+ 579, 64, 87, 310, 469, 85, 87, 86, 0, 519,
+ 517, 85, 141, 86, 554, 0, 172, 536, 87, 514,
+ 85, 514, 86, 141, 87, 85, 545, 86, 514, 0,
+ 513, 65, 513, 87, 514, 173, 514, 66, 87, 513,
+ 514, 103, 172, 0, 65, 513, 65, 513, 0, 0,
+ 66, 513, 66, 637, 636, 0, 0, 470, 468, 172,
+ 104, 173, 105, 406, 0, 235, 234, 630, 555, 553,
+ 172, 537, 535, 0, 274, 275, 438, 437, 173, 172,
+ 406, 631, 629, 635, 0, 580, 73, 74, -90, 173,
+ 34, 174, 73, 74, 274, 275, 34, -90, 173, 34,
+ 174, 276, 277, 85, 34, 86, 0, 0, 0, 0,
+ 0, 628, 0, 75, 76, 0, 87, 0, 0, 75,
+ 76, 276, 277, 0, 0, 0, 0, 48, 50, 49,
+ 0, 0, 0, 48, 50, 49, 48, 50, 49, 0,
+ 0, 48, 50, 49, 0, 0, 279, 280, 0, 0,
+ 0, 34, 0, 45, 0, 281, 279, 280, 282, 45,
+ 283, 34, 45, 279, 280, 281, 34, 45, 282, 0,
+ 283, 34, 281, 279, 280, 282, 0, 283, 0, 0,
+ 34, 0, 281, 78, 79, 282, 0, 283, 48, 50,
+ 49, 80, 81, 0, 34, 82, 0, 83, 48, 50,
+ 49, -345, 0, 48, 50, 49, 0, 0, 48, 50,
+ 49, 0, 0, 0, 45, 0, 0, 48, 50, 49,
+ 0, 0, 0, 0, 45, 0, 0, 78, 79, 45,
+ 0, 48, 50, 49, 45, 80, 81, 78, 79, 82,
+ 0, 83, 0, 45, 0, 80, 81, 78, 79, 82,
+ 0, 83, 34, 279, 280, 80, 81, 45, 0, 82,
+ 34, 83, 281, 34, 0, 282, 0, 283, 6, 5,
+ 4, 1, 3, 2, 34, 0, 0, 0, 0, 0,
+ 0, -345, 0, 0, 245, 244, 0, 0, 0, 48,
+ 50, 49, 245, 244, 0, 240, 239, 48, 50, 49,
+ 48, 50, 49, 0, 0, 0, 0, 0, 0, 0,
+ 34, 48, 50, 49, 0, 45, 0, 0, 34, 0,
+ 0, 34, 0, 45, 0, 0, 45, 0, 0, 0,
+ 0, 0, 78, 79, 0, 0, 0, 45, 0, 0,
+ 80, 81, 245, 244, 82, 0, 83, 48, 50, 49,
+ 240, 239, 151, 240, 239, 48, 50, 49, 48, 50,
+ 49, 0, 152, 0, 0, 0, 153, 0, 0, 0,
+ 0, 0, 0, 45, 0, 154, 0, 155, 0, 0,
+ 308, 45, 0, 0, 45, 0, 0, 0, 156, 0,
+ 157, 62, 0, 0, 0, 0, 0, 0, 158, 0,
+ 0, 159, 63, 0, 0, 0, 0, 160, 0, 30,
+ 31, 151, 0, 161, 0, 0, 0, 0, 0, 33,
+ 0, 152, 0, 0, 0, 153, 34, 0, 0, 162,
+ 35, 36, 0, 37, 154, 0, 155, 0, 0, 0,
+ 503, 0, 0, 0, 44, 0, 0, 156, 0, 157,
+ 62, 0, 0, 0, 0, 0, 0, 158, 0, 0,
+ 159, 63, 51, 48, 50, 49, 160, 52, 0, 0,
+ 0, 0, 161, 0, 0, 0, 0, 0, 43, 54,
+ 32, 0, 30, 31, 40, 0, 0, 0, 162, 45,
+ 0, 0, 33, 0, 0, 0, 0, 0, 0, 34,
+ 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
+ 30, 31, 0, 41, 0, 0, 0, 44, 0, 0,
+ 33, 0, 0, 0, 0, 0, 0, 34, 0, 0,
+ 0, 35, 36, 0, 37, 51, 48, 50, 49, 0,
+ 52, 503, 0, 0, 0, 44, 0, 0, 0, 0,
+ 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
+ 0, 0, 45, 51, 48, 50, 49, 0, 52, 0,
+ 0, 0, 30, 31, 0, 0, 0, 0, 0, 43,
+ 54, 32, 33, 0, 0, 40, 0, 0, 0, 34,
+ 45, 0, 0, 35, 36, 0, 37, 0, 0, 0,
+ 30, 31, 0, 41, 0, 0, 0, 44, 0, 0,
+ 33, 0, 0, 0, 0, 0, 0, 34, 0, 0,
+ 0, 35, 36, 0, 37, 51, 48, 50, 49, 0,
+ 52, 503, 0, 0, 0, 44, 0, 0, 0, 0,
+ 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
+ 0, 0, 45, 51, 48, 50, 49, 0, 52, 0,
+ 0, 0, 30, 31, 0, 0, 0, 0, 0, 43,
+ 54, 32, 33, 0, 0, 40, 0, 0, 0, 34,
+ 45, 0, 0, 35, 36, 0, 37, 0, 0, 0,
+ 30, 31, 0, 503, 0, 0, 0, 44, 0, 0,
+ 33, 0, 0, 0, 0, 0, 0, 34, 0, 0,
+ 0, 35, 36, 0, 37, 51, 48, 50, 49, 0,
+ 52, 41, 0, 0, 0, 44, 0, 0, 0, 0,
+ 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
+ 0, 0, 45, 51, 48, 50, 49, 0, 52, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 43,
+ 54, 32, 0, 0, 0, 40, 0, 0, 0, 0,
+ 45, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 502, 0, 30, 31, 0, 0, 0, 0, 0, 0,
+ 0, 0, 215, 0, 0, 0, 0, 0, 0, 34,
+ 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
+ 0, 0, 0, 503, 0, 0, 0, 44, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 51, 504, 506, 505, 0,
+ 52, 0, 0, 0, 0, 226, 0, 0, 0, 0,
+ 0, 43, 54, 32, 210, 0, 0, 40, 0, 0,
+ 0, 0, 45, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 502, 0, 30, 31, 0, 0, 0, 0,
+ 0, 0, 0, 0, 215, 0, 0, 0, 0, 0,
+ 0, 34, 0, 0, 0, 35, 36, 0, 37, 0,
+ 0, 0, 0, 0, 0, 503, 0, 0, 0, 44,
+ 0, 0, 0, 0, 0, 0, 0, 550, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 51, 504, 506,
+ 505, 0, 52, 0, 0, 0, 0, 226, 0, 0,
+ 0, 0, 0, 43, 54, 32, 210, 0, 0, 40,
+ 0, 0, 0, 0, 45, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 502, 0, 30, 31, 0, 0,
+ 0, 0, 0, 0, 0, 0, 215, 0, 0, 0,
+ 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
+ 37, 0, 0, 0, 0, 0, 0, 503, 0, 0,
+ 0, 44, 0, 0, 0, 0, 0, 0, 0, 547,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 51,
+ 504, 506, 505, 0, 52, 0, 0, 0, 0, 226,
+ 0, 0, 0, 0, 0, 43, 54, 32, 210, 0,
+ 0, 40, 0, 0, 0, 0, 45, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 29, 30, 31, 0,
+ 0, 0, 0, 0, 0, 0, 0, 33, 0, 0,
+ 0, 0, 0, 0, 34, 0, 0, 0, 35, 36,
+ 0, 37, 0, 0, 0, 38, 0, 39, 41, 42,
+ 0, 0, 44, 0, 0, 0, 46, 0, 47, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 51, 48, 50, 49, 0, 52, 0, 53, 0, 55,
+ 0, 56, 0, 0, 0, 0, 43, 54, 32, 0,
+ 0, 0, 40, 0, 0, 0, 0, 45, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, -122, 0, 0,
+ 0, 29, 30, 31, 0, 0, 0, 0, 0, 0,
+ 0, 0, 33, 0, 0, 0, 0, 0, 0, 34,
+ 0, 0, 0, 35, 36, 0, 37, 0, 0, 0,
+ 38, 0, 39, 41, 42, 0, 0, 44, 0, 0,
+ 0, 46, 0, 47, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 51, 48, 50, 49, 0,
+ 52, 0, 53, 0, 55, 0, 56, 0, 0, 0,
+ 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
+ 0, 0, 45, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 29, 30, 31, 0, 0, 0, 0, 0,
+ 0, 0, 0, 33, 0, 0, 0, 0, 0, 0,
+ 34, 0, 0, 0, 35, 36, 0, 37, 0, 0,
+ 0, 38, 0, 39, 41, 42, 0, 0, 44, 0,
+ 0, 0, 46, 0, 47, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 51, 48, 50, 49,
+ 0, 52, 0, 53, 0, 55, 271, 56, 0, 0,
+ 0, 0, 43, 54, 32, 0, 0, 0, 40, 0,
+ 0, 0, 0, 45, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 475, 0, 0, 29, 30, 31, 0,
+ 0, 0, 0, 0, 0, 0, 0, 33, 0, 0,
+ 0, 0, 0, 0, 34, 0, 0, 0, 35, 36,
+ 0, 37, 0, 0, 0, 38, 0, 39, 41, 42,
+ 0, 0, 44, 0, 0, 0, 46, 0, 47, 0,
+ 0, 476, 0, 0, 0, 0, 0, 0, 0, 0,
+ 51, 48, 50, 49, 0, 52, 0, 53, 0, 55,
+ 0, 56, 0, 0, 0, 0, 43, 54, 32, 0,
+ 0, 0, 40, 0, 0, 0, 0, 45, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 475, 0, 0,
+ 29, 30, 31, 0, 0, 0, 0, 0, 0, 0,
+ 0, 33, 0, 0, 0, 0, 0, 0, 34, 0,
+ 0, 0, 35, 36, 0, 37, 0, 0, 0, 38,
+ 0, 39, 41, 42, 0, 0, 44, 0, 0, 0,
+ 46, 0, 47, 0, 0, 481, 0, 0, 0, 0,
+ 0, 0, 0, 0, 51, 48, 50, 49, 0, 52,
+ 0, 53, 0, 55, 0, 56, 0, 0, 0, 0,
+ 43, 54, 32, 0, 0, 0, 40, 0, 0, 0,
+ 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 483, 0, 0, 29, 30, 31, 0, 0, 0,
+ 0, 0, 0, 0, 0, 33, 0, 0, 0, 0,
+ 0, 0, 34, 0, 0, 0, 35, 36, 0, 37,
+ 0, 0, 0, 38, 0, 39, 41, 42, 0, 0,
+ 44, 0, 0, 0, 46, 0, 47, 0, 0, 484,
+ 0, 0, 0, 0, 0, 0, 0, 0, 51, 48,
+ 50, 49, 0, 52, 0, 53, 0, 55, 0, 56,
+ 0, 0, 0, 0, 43, 54, 32, 0, 0, 0,
+ 40, 0, 0, 0, 0, 45, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 483, 0, 0, 29, 30,
+ 31, 0, 0, 0, 0, 0, 0, 0, 0, 33,
+ 0, 0, 0, 0, 0, 0, 34, 0, 0, 0,
+ 35, 36, 0, 37, 0, 0, 0, 38, 0, 39,
+ 41, 42, 0, 0, 44, 0, 0, 0, 46, 0,
+ 47, 0, 0, 486, 0, 0, 0, 0, 0, 0,
+ 0, 0, 51, 48, 50, 49, 0, 52, 0, 53,
+ 0, 55, 0, 56, 0, 0, 0, 0, 43, 54,
+ 32, 0, 0, 0, 40, 0, 0, 0, 0, 45,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
+ 30, 31, 0, 0, 0, 0, 0, 0, 0, 0,
+ 33, 0, 0, 0, 0, 0, 0, 34, 217, 0,
+ 0, 218, 36, 0, 37, 0, 0, 0, 38, 0,
+ 39, 41, 42, 0, 0, 44, 0, 0, 0, 46,
+ 0, 47, 0, 0, 0, 0, 0, 0, 0, 221,
+ 0, 0, 0, 51, 48, 50, 49, 223, 52, 0,
+ 53, 225, 55, 0, 56, 0, 228, 0, 0, 43,
+ 54, 32, 0, 0, 0, 40, 0, 0, 0, 0,
+ 45, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 29, 30, 31, 0, 0, 0, 0, 0, 0, 0,
+ 0, 33, 0, 0, 0, 0, 0, 0, 34, 217,
+ 0, 0, 582, 583, 0, 37, 0, 0, 0, 38,
+ 0, 39, 41, 42, 0, 0, 44, 0, 0, 0,
+ 46, 0, 47, 0, 0, 0, 0, 0, 0, 0,
+ 221, 0, 0, 0, 51, 48, 50, 49, 223, 52,
+ 0, 53, 225, 55, 0, 56, 0, 228, 0, 0,
+ 43, 54, 32, 0, 0, 0, 40, 0, 0, 0,
+ 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 109, 110, 111, 0, 0, 113, 115, 116, 0,
+ 0, 117, 0, 118, 0, 0, 0, 120, 121, 122,
+ 0, 0, 0, 0, 0, 0, 34, 123, 124, 125,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 126, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 129, 0, 0, 0,
+ 0, 0, 0, 48, 50, 49, 130, 131, 132, 0,
+ 134, 135, 136, 137, 138, 139, 0, 0, 127, 133,
+ 119, 112, 114, 128, 0, 0, 0, 0, 0, 45,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 109,
+ 110, 111, 0, 0, 113, 115, 116, 0, 0, 117,
+ 0, 118, 0, 0, 0, 120, 121, 122, 0, 0,
+ 0, 0, 0, 0, 393, 123, 124, 125, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 126, 0,
+ 0, 0, 394, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 129, 0, 0, 0, 0, 0,
+ 398, 395, 397, 0, 130, 131, 132, 0, 134, 135,
+ 136, 137, 138, 139, 0, 0, 127, 133, 119, 112,
+ 114, 128, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 109, 110, 111,
+ 0, 0, 113, 115, 116, 0, 0, 117, 0, 118,
+ 0, 0, 0, 120, 121, 122, 0, 0, 0, 0,
+ 0, 0, 393, 123, 124, 125, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 126, 0, 0, 0,
+ 394, 0, 0, 0, 0, 0, 0, 0, 396, 0,
+ 0, 0, 129, 0, 0, 0, 0, 0, 398, 395,
+ 397, 0, 130, 131, 132, 0, 134, 135, 136, 137,
+ 138, 139, 0, 0, 127, 133, 119, 112, 114, 128,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 209, 0, 0, 0, 0,
+ 211, 0, 29, 30, 31, 213, 0, 0, 0, 0,
+ 0, 0, 214, 215, 0, 0, 0, 0, 0, 0,
+ 216, 217, 0, 0, 218, 36, 0, 37, 0, 0,
+ 0, 38, 0, 39, 41, 42, 0, 0, 44, 0,
+ 0, 0, 46, 0, 47, 0, 0, 0, 0, 0,
+ 220, 0, 221, 0, 0, 0, 51, 219, 222, 49,
+ 223, 52, 224, 53, 225, 55, 226, 56, 227, 228,
+ 0, 0, 43, 54, 32, 210, 212, 0, 40, 0,
+ 0, 0, 0, 45, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 209, 0, 0, 0, 0, 211, 0,
+ 29, 30, 31, 213, 0, 0, 0, 0, 0, 0,
+ 214, 33, 0, 0, 0, 0, 0, 0, 216, 217,
+ 0, 0, 218, 36, 0, 37, 0, 0, 0, 38,
+ 0, 39, 41, 42, 0, 0, 44, 0, 0, 0,
+ 46, 0, 47, 0, 0, 0, 0, 0, 220, 0,
+ 221, 0, 0, 0, 51, 219, 222, 49, 223, 52,
+ 224, 53, 225, 55, 226, 56, 227, 228, 0, 0,
+ 43, 54, 32, 210, 212, 0, 40, 0, 0, 0,
+ 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 586, 110, 111, 0, 0, 588, 115, 590, 30,
+ 31, 591, 0, 118, 0, 0, 0, 120, 593, 594,
+ 0, 0, 0, 0, 0, 0, 595, 596, 124, 125,
+ 218, 36, 0, 37, 0, 0, 0, 38, 0, 39,
+ 597, 42, 0, 0, 599, 0, 0, 0, 46, 0,
+ 47, 0, 0, 0, 0, 0, 601, 0, 221, 0,
+ 0, 0, 603, 600, 602, 49, 604, 605, 606, 53,
+ 608, 609, 610, 611, 612, 613, 0, 0, 598, 607,
+ 592, 587, 589, 128, 40, 0, 0, 0, 0, 45,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 361,
+ 110, 111, 0, 0, 363, 115, 365, 30, 31, 366,
+ 0, 118, 0, 0, 0, 120, 368, 369, 0, 0,
+ 0, 0, 0, 0, 370, 371, 124, 125, 218, 36,
+ 0, 37, 0, 0, 0, 38, 0, 39, 372, 42,
+ 0, 0, 374, 0, 0, 0, 46, 0, 47, 0,
+ -268, 0, 0, 0, 376, 0, 221, 0, 0, 0,
+ 378, 375, 377, 49, 379, 380, 381, 53, 383, 384,
+ 385, 386, 387, 388, 0, 0, 373, 382, 367, 362,
+ 364, 128, 40, 0, 0, 0, 0, 45, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+
+ 534, 311, 497, 309, 532, 461, 498, 499, 516, 515,
+ 619, 638, 16, 552, 436, 358, 616, 472, 562, 320,
+ 528, 238, 487, 182, 250, 243, 253, 182, 302, 641,
+ 627, 632, 150, 485, 143, 454, 439, 402, 445, 559,
+ 237, 574, 250, 578, 561, 186, 618, 458, 238, 349,
+ 573, 449, 447, 571, 243, 347, 450, 243, 460, 351,
+ 238, 353, 358, 410, 415, 439, 176, 188, 436, 250,
+ 467, 417, 433, 182, 425, 429, 302, 169, 456, 358,
+ 171, 140, 336, 334, 338, 344, 436, 392, 390, 400,
+ 163, 302, 307, 148, 146, 339, 439, 404, 302, 358,
+ 404, 358, 0, 482, 501, 480, 0, 642, 0, 479,
+ 0, 0, 0, 320, 60, 0, 186, 501, 90, 60,
+ 60, 489, 302, 60, 617, 93, 0, 88, 0, 405,
+ 0, 461, 405, 60, 60, 451, 180, 60, 0, 180,
+ 60, 60, 60, 451, 60, 95, 89, 146, 266, 287,
+ 60, 146, 407, 270, 60, 288, 178, 60, 106, 452,
+ 0, 60, 60, 60, 102, 60, 302, 332, 286, 60,
+ 92, 452, 60, 60, 451, 60, 165, 168, 285, 432,
+ 284, 435, 60, 60, 108, 501, 329, 94, 540, 96,
+ 60, 330, 60, 302, 494, 60, 77, 237, 60, 404,
+ 452, 341, 471, 72, 60, 60, 67, 69, 60, 60,
+ 68, 0, 70, 60, 60, 60, 61, 180, 60, 60,
+ 98, 491, 60, 91, 490, 60, 60, 60, 493, 60,
+ 84, 405, 60, 97, 492, 305, 0, 60, 0, 298,
+ 0, 100, 270, 298, 270, 298, 106, 298, 270, 0,
+ 270, 60, 270, 60, 316, 0, 270, 0, 270, 298,
+ 291, 326, 303, 60, 270, 319, 313, 300, 270, 297,
+ 60, 60, 108, 175, 295, 270, 270, 290, 60, 501,
+ 273, 317, 60, 270, 60, 278, 509, 270, 0, 270,
+ 0, 289, 0, 548, 0, 293, 551, 0, 500, 510,
+ 501, 501, 0, 544, 501, 0, 0, 0, 509, 0,
+ 0, 509, 520, 521, 522, 523, 527, 524, 525, 0,
+ 500, 510, 0, 500, 510, 564, 520, 521, 522, 523,
+ 527, 524, 525, 581, 0, 0, 0, 0, 0, 0,
+ 584, 585, 520, 521, 522, 523, 527, 524, 525, 556,
+ 0, 0, 0, 0, 0, 0, 557, 558, 520, 521,
+ 522, 523, 527, 524, 525, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 556, 0, 0, 540, 0, 614,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 472, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0};
+
+const short QQmlJSGrammar::action_check [] = {
+ 36, 36, 24, 7, 55, 7, 7, 7, 60, 36,
+ 8, 7, 37, 7, 7, 33, 55, 55, 60, 36,
+ 36, 33, 33, 55, 8, 33, 7, 7, 34, 36,
+ 16, 20, 7, 36, 7, 7, 33, 36, 33, 60,
+ 7, 7, 7, 5, 7, 5, 5, 90, 33, 36,
+ 7, 33, 7, 36, 7, 33, 66, 36, 7, 36,
+ 29, 7, 33, 31, 1, 7, 17, 55, 60, 33,
+ 60, 2, 8, 7, 48, 66, 1, 7, 36, 2,
+ 8, 7, 36, 2, 60, 2, 8, 7, 17, 1,
+ 60, 36, 0, 36, 8, 36, 48, 36, 33, 8,
+ 61, 1, 6, 36, 60, 8, -1, 8, -1, 15,
+ 48, 10, 7, 8, 61, 8, 20, -1, -1, -1,
+ -1, -1, 8, -1, -1, -1, -1, 48, 34, 79,
+ 40, 79, 8, 77, 61, 8, 60, 8, 8, 79,
+ 8, 51, -1, 40, 42, 61, 62, 8, 61, 62,
+ 8, 7, -1, 56, 51, 53, 55, 8, 90, 60,
+ 50, 79, 8, 56, 54, 61, 62, 61, 62, 61,
+ 62, 40, 61, 62, 60, 40, 61, 62, 61, 62,
+ 56, 8, 51, 56, 50, 7, 51, 15, 54, 60,
+ 60, 25, 60, 27, 25, 56, 27, 61, 62, 61,
+ 62, 36, 60, 29, 38, 29, 34, 38, 36, 25,
+ 61, 27, 29, -1, 60, 25, 12, 27, 29, 25,
+ 29, 27, 38, 25, 29, 27, 61, 62, 38, 12,
+ 7, 12, 38, 60, 8, 25, 38, 27, -1, 61,
+ 62, 25, 8, 27, 7, -1, 15, 7, 38, 75,
+ 25, 75, 27, 8, 38, 25, 33, 27, 75, -1,
+ 86, 57, 86, 38, 75, 34, 75, 63, 38, 86,
+ 75, 15, 15, -1, 57, 86, 57, 86, -1, -1,
+ 63, 86, 63, 61, 62, -1, -1, 61, 62, 15,
+ 34, 34, 36, 36, -1, 61, 62, 47, 61, 62,
+ 15, 61, 62, -1, 18, 19, 61, 62, 34, 15,
+ 36, 61, 62, 91, -1, 92, 18, 19, 33, 34,
+ 29, 36, 18, 19, 18, 19, 29, 33, 34, 29,
+ 36, 45, 46, 25, 29, 27, -1, -1, -1, -1,
+ -1, 91, -1, 45, 46, -1, 38, -1, -1, 45,
+ 46, 45, 46, -1, -1, -1, -1, 66, 67, 68,
+ -1, -1, -1, 66, 67, 68, 66, 67, 68, -1,
+ -1, 66, 67, 68, -1, -1, 23, 24, -1, -1,
+ -1, 29, -1, 92, -1, 32, 23, 24, 35, 92,
+ 37, 29, 92, 23, 24, 32, 29, 92, 35, -1,
+ 37, 29, 32, 23, 24, 35, -1, 37, -1, -1,
+ 29, -1, 32, 23, 24, 35, -1, 37, 66, 67,
+ 68, 31, 32, -1, 29, 35, -1, 37, 66, 67,
+ 68, 36, -1, 66, 67, 68, -1, -1, 66, 67,
+ 68, -1, -1, -1, 92, -1, -1, 66, 67, 68,
+ -1, -1, -1, -1, 92, -1, -1, 23, 24, 92,
+ -1, 66, 67, 68, 92, 31, 32, 23, 24, 35,
+ -1, 37, -1, 92, -1, 31, 32, 23, 24, 35,
+ -1, 37, 29, 23, 24, 31, 32, 92, -1, 35,
+ 29, 37, 32, 29, -1, 35, -1, 37, 94, 95,
+ 96, 97, 98, 99, 29, -1, -1, -1, -1, -1,
+ -1, 36, -1, -1, 61, 62, -1, -1, -1, 66,
+ 67, 68, 61, 62, -1, 61, 62, 66, 67, 68,
+ 66, 67, 68, -1, -1, -1, -1, -1, -1, -1,
+ 29, 66, 67, 68, -1, 92, -1, -1, 29, -1,
+ -1, 29, -1, 92, -1, -1, 92, -1, -1, -1,
+ -1, -1, 23, 24, -1, -1, -1, 92, -1, -1,
+ 31, 32, 61, 62, 35, -1, 37, 66, 67, 68,
+ 61, 62, 3, 61, 62, 66, 67, 68, 66, 67,
+ 68, -1, 13, -1, -1, -1, 17, -1, -1, -1,
+ -1, -1, -1, 92, -1, 26, -1, 28, -1, -1,
+ 31, 92, -1, -1, 92, -1, -1, -1, 39, -1,
+ 41, 42, -1, -1, -1, -1, -1, -1, 49, -1,
+ -1, 52, 53, -1, -1, -1, -1, 58, -1, 12,
+ 13, 3, -1, 64, -1, -1, -1, -1, -1, 22,
+ -1, 13, -1, -1, -1, 17, 29, -1, -1, 80,
+ 33, 34, -1, 36, 26, -1, 28, -1, -1, -1,
+ 43, -1, -1, -1, 47, -1, -1, 39, -1, 41,
+ 42, -1, -1, -1, -1, -1, -1, 49, -1, -1,
+ 52, 53, 65, 66, 67, 68, 58, 70, -1, -1,
+ -1, -1, 64, -1, -1, -1, -1, -1, 81, 82,
+ 83, -1, 12, 13, 87, -1, -1, -1, 80, 92,
+ -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
+ -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
+ 12, 13, -1, 43, -1, -1, -1, 47, -1, -1,
+ 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
+ -1, 33, 34, -1, 36, 65, 66, 67, 68, -1,
+ 70, 43, -1, -1, -1, 47, -1, -1, -1, -1,
+ -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
+ -1, -1, 92, 65, 66, 67, 68, -1, 70, -1,
+ -1, -1, 12, 13, -1, -1, -1, -1, -1, 81,
+ 82, 83, 22, -1, -1, 87, -1, -1, -1, 29,
+ 92, -1, -1, 33, 34, -1, 36, -1, -1, -1,
+ 12, 13, -1, 43, -1, -1, -1, 47, -1, -1,
+ 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
+ -1, 33, 34, -1, 36, 65, 66, 67, 68, -1,
+ 70, 43, -1, -1, -1, 47, -1, -1, -1, -1,
+ -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
+ -1, -1, 92, 65, 66, 67, 68, -1, 70, -1,
+ -1, -1, 12, 13, -1, -1, -1, -1, -1, 81,
+ 82, 83, 22, -1, -1, 87, -1, -1, -1, 29,
+ 92, -1, -1, 33, 34, -1, 36, -1, -1, -1,
+ 12, 13, -1, 43, -1, -1, -1, 47, -1, -1,
+ 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
+ -1, 33, 34, -1, 36, 65, 66, 67, 68, -1,
+ 70, 43, -1, -1, -1, 47, -1, -1, -1, -1,
+ -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
+ -1, -1, 92, 65, 66, 67, 68, -1, 70, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 81,
+ 82, 83, -1, -1, -1, 87, -1, -1, -1, -1,
+ 92, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 10, -1, 12, 13, -1, -1, -1, -1, -1, -1,
+ -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
+ -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
+ -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
+ 70, -1, -1, -1, -1, 75, -1, -1, -1, -1,
+ -1, 81, 82, 83, 84, -1, -1, 87, -1, -1,
+ -1, -1, 92, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 10, -1, 12, 13, -1, -1, -1, -1,
+ -1, -1, -1, -1, 22, -1, -1, -1, -1, -1,
+ -1, 29, -1, -1, -1, 33, 34, -1, 36, -1,
+ -1, -1, -1, -1, -1, 43, -1, -1, -1, 47,
+ -1, -1, -1, -1, -1, -1, -1, 55, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,
+ 68, -1, 70, -1, -1, -1, -1, 75, -1, -1,
+ -1, -1, -1, 81, 82, 83, 84, -1, -1, 87,
+ -1, -1, -1, -1, 92, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 10, -1, 12, 13, -1, -1,
+ -1, -1, -1, -1, -1, -1, 22, -1, -1, -1,
+ -1, -1, -1, 29, -1, -1, -1, 33, 34, -1,
+ 36, -1, -1, -1, -1, -1, -1, 43, -1, -1,
+ -1, 47, -1, -1, -1, -1, -1, -1, -1, 55,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 65,
+ 66, 67, 68, -1, 70, -1, -1, -1, -1, 75,
+ -1, -1, -1, -1, -1, 81, 82, 83, 84, -1,
+ -1, 87, -1, -1, -1, -1, 92, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 11, 12, 13, -1,
+ -1, -1, -1, -1, -1, -1, -1, 22, -1, -1,
+ -1, -1, -1, -1, 29, -1, -1, -1, 33, 34,
+ -1, 36, -1, -1, -1, 40, -1, 42, 43, 44,
+ -1, -1, 47, -1, -1, -1, 51, -1, 53, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 65, 66, 67, 68, -1, 70, -1, 72, -1, 74,
+ -1, 76, -1, -1, -1, -1, 81, 82, 83, -1,
+ -1, -1, 87, -1, -1, -1, -1, 92, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 7, -1, -1,
+ -1, 11, 12, 13, -1, -1, -1, -1, -1, -1,
+ -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
+ -1, -1, -1, 33, 34, -1, 36, -1, -1, -1,
+ 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
+ -1, 51, -1, 53, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 65, 66, 67, 68, -1,
+ 70, -1, 72, -1, 74, -1, 76, -1, -1, -1,
+ -1, 81, 82, 83, -1, -1, -1, 87, -1, -1,
+ -1, -1, 92, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 11, 12, 13, -1, -1, -1, -1, -1,
+ -1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
+ 29, -1, -1, -1, 33, 34, -1, 36, -1, -1,
+ -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
+ -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 65, 66, 67, 68,
+ -1, 70, -1, 72, -1, 74, 75, 76, -1, -1,
+ -1, -1, 81, 82, 83, -1, -1, -1, 87, -1,
+ -1, -1, -1, 92, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 8, -1, -1, 11, 12, 13, -1,
+ -1, -1, -1, -1, -1, -1, -1, 22, -1, -1,
+ -1, -1, -1, -1, 29, -1, -1, -1, 33, 34,
+ -1, 36, -1, -1, -1, 40, -1, 42, 43, 44,
+ -1, -1, 47, -1, -1, -1, 51, -1, 53, -1,
+ -1, 56, -1, -1, -1, -1, -1, -1, -1, -1,
+ 65, 66, 67, 68, -1, 70, -1, 72, -1, 74,
+ -1, 76, -1, -1, -1, -1, 81, 82, 83, -1,
+ -1, -1, 87, -1, -1, -1, -1, 92, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 8, -1, -1,
+ 11, 12, 13, -1, -1, -1, -1, -1, -1, -1,
+ -1, 22, -1, -1, -1, -1, -1, -1, 29, -1,
+ -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
+ -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
+ 51, -1, 53, -1, -1, 56, -1, -1, -1, -1,
+ -1, -1, -1, -1, 65, 66, 67, 68, -1, 70,
+ -1, 72, -1, 74, -1, 76, -1, -1, -1, -1,
+ 81, 82, 83, -1, -1, -1, 87, -1, -1, -1,
+ -1, 92, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 8, -1, -1, 11, 12, 13, -1, -1, -1,
+ -1, -1, -1, -1, -1, 22, -1, -1, -1, -1,
+ -1, -1, 29, -1, -1, -1, 33, 34, -1, 36,
+ -1, -1, -1, 40, -1, 42, 43, 44, -1, -1,
+ 47, -1, -1, -1, 51, -1, 53, -1, -1, 56,
+ -1, -1, -1, -1, -1, -1, -1, -1, 65, 66,
+ 67, 68, -1, 70, -1, 72, -1, 74, -1, 76,
+ -1, -1, -1, -1, 81, 82, 83, -1, -1, -1,
+ 87, -1, -1, -1, -1, 92, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 8, -1, -1, 11, 12,
+ 13, -1, -1, -1, -1, -1, -1, -1, -1, 22,
+ -1, -1, -1, -1, -1, -1, 29, -1, -1, -1,
+ 33, 34, -1, 36, -1, -1, -1, 40, -1, 42,
+ 43, 44, -1, -1, 47, -1, -1, -1, 51, -1,
+ 53, -1, -1, 56, -1, -1, -1, -1, -1, -1,
+ -1, -1, 65, 66, 67, 68, -1, 70, -1, 72,
+ -1, 74, -1, 76, -1, -1, -1, -1, 81, 82,
+ 83, -1, -1, -1, 87, -1, -1, -1, -1, 92,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 11,
+ 12, 13, -1, -1, -1, -1, -1, -1, -1, -1,
+ 22, -1, -1, -1, -1, -1, -1, 29, 30, -1,
+ -1, 33, 34, -1, 36, -1, -1, -1, 40, -1,
+ 42, 43, 44, -1, -1, 47, -1, -1, -1, 51,
+ -1, 53, -1, -1, -1, -1, -1, -1, -1, 61,
+ -1, -1, -1, 65, 66, 67, 68, 69, 70, -1,
+ 72, 73, 74, -1, 76, -1, 78, -1, -1, 81,
+ 82, 83, -1, -1, -1, 87, -1, -1, -1, -1,
+ 92, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 11, 12, 13, -1, -1, -1, -1, -1, -1, -1,
+ -1, 22, -1, -1, -1, -1, -1, -1, 29, 30,
+ -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
+ -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
+ 51, -1, 53, -1, -1, -1, -1, -1, -1, -1,
+ 61, -1, -1, -1, 65, 66, 67, 68, 69, 70,
+ -1, 72, 73, 74, -1, 76, -1, 78, -1, -1,
+ 81, 82, 83, -1, -1, -1, 87, -1, -1, -1,
+ -1, 92, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 4, 5, 6, -1, -1, 9, 10, 11, -1,
+ -1, 14, -1, 16, -1, -1, -1, 20, 21, 22,
+ -1, -1, -1, -1, -1, -1, 29, 30, 31, 32,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 43, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
+ -1, -1, -1, 66, 67, 68, 69, 70, 71, -1,
+ 73, 74, 75, 76, 77, 78, -1, -1, 81, 82,
+ 83, 84, 85, 86, -1, -1, -1, -1, -1, 92,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
+ 5, 6, -1, -1, 9, 10, 11, -1, -1, 14,
+ -1, 16, -1, -1, -1, 20, 21, 22, -1, -1,
+ -1, -1, -1, -1, 29, 30, 31, 32, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 43, -1,
+ -1, -1, 47, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
+ 65, 66, 67, -1, 69, 70, 71, -1, 73, 74,
+ 75, 76, 77, 78, -1, -1, 81, 82, 83, 84,
+ 85, 86, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 4, 5, 6,
+ -1, -1, 9, 10, 11, -1, -1, 14, -1, 16,
+ -1, -1, -1, 20, 21, 22, -1, -1, -1, -1,
+ -1, -1, 29, 30, 31, 32, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 43, -1, -1, -1,
+ 47, -1, -1, -1, -1, -1, -1, -1, 55, -1,
+ -1, -1, 59, -1, -1, -1, -1, -1, 65, 66,
+ 67, -1, 69, 70, 71, -1, 73, 74, 75, 76,
+ 77, 78, -1, -1, 81, 82, 83, 84, 85, 86,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 4, -1, -1, -1, -1,
+ 9, -1, 11, 12, 13, 14, -1, -1, -1, -1,
+ -1, -1, 21, 22, -1, -1, -1, -1, -1, -1,
+ 29, 30, -1, -1, 33, 34, -1, 36, -1, -1,
+ -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
+ -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
+ 59, -1, 61, -1, -1, -1, 65, 66, 67, 68,
+ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
+ -1, -1, 81, 82, 83, 84, 85, -1, 87, -1,
+ -1, -1, -1, 92, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 4, -1, -1, -1, -1, 9, -1,
+ 11, 12, 13, 14, -1, -1, -1, -1, -1, -1,
+ 21, 22, -1, -1, -1, -1, -1, -1, 29, 30,
+ -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
+ -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
+ 51, -1, 53, -1, -1, -1, -1, -1, 59, -1,
+ 61, -1, -1, -1, 65, 66, 67, 68, 69, 70,
+ 71, 72, 73, 74, 75, 76, 77, 78, -1, -1,
+ 81, 82, 83, 84, 85, -1, 87, -1, -1, -1,
+ -1, 92, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 4, 5, 6, -1, -1, 9, 10, 11, 12,
+ 13, 14, -1, 16, -1, -1, -1, 20, 21, 22,
+ -1, -1, -1, -1, -1, -1, 29, 30, 31, 32,
+ 33, 34, -1, 36, -1, -1, -1, 40, -1, 42,
+ 43, 44, -1, -1, 47, -1, -1, -1, 51, -1,
+ 53, -1, -1, -1, -1, -1, 59, -1, 61, -1,
+ -1, -1, 65, 66, 67, 68, 69, 70, 71, 72,
+ 73, 74, 75, 76, 77, 78, -1, -1, 81, 82,
+ 83, 84, 85, 86, 87, -1, -1, -1, -1, 92,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
+ 5, 6, -1, -1, 9, 10, 11, 12, 13, 14,
+ -1, 16, -1, -1, -1, 20, 21, 22, -1, -1,
+ -1, -1, -1, -1, 29, 30, 31, 32, 33, 34,
+ -1, 36, -1, -1, -1, 40, -1, 42, 43, 44,
+ -1, -1, 47, -1, -1, -1, 51, -1, 53, -1,
+ 55, -1, -1, -1, 59, -1, 61, -1, -1, -1,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, -1, -1, 81, 82, 83, 84,
+ 85, 86, 87, -1, -1, -1, -1, 92, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+
+ 15, 2, 105, 3, 29, 15, 4, 2, 15, 29,
+ 9, 15, 3, 15, 3, 2, 19, 39, 15, 15,
+ 13, 15, 3, 15, 2, 15, 3, 15, 3, 11,
+ 13, 15, 71, 39, 39, 3, 22, 2, 99, 19,
+ 4, 15, 2, 15, 29, 15, 19, 3, 15, 3,
+ 29, 22, 15, 29, 15, 2, 22, 15, 2, 2,
+ 15, 2, 2, 2, 2, 22, 3, 15, 3, 2,
+ 39, 3, 3, 15, 97, 94, 3, 39, 2, 2,
+ 39, 3, 3, 2, 2, 101, 3, 40, 39, 39,
+ 39, 3, 2, 39, 39, 15, 22, 13, 3, 2,
+ 13, 2, -1, 39, 13, 35, -1, 16, -1, 39,
+ -1, -1, -1, 15, 48, -1, 15, 13, 52, 48,
+ 48, 50, 3, 48, 20, 53, -1, 52, -1, 45,
+ -1, 15, 45, 48, 48, 50, 50, 48, -1, 50,
+ 48, 48, 48, 50, 48, 53, 52, 39, 48, 53,
+ 48, 39, 44, 53, 48, 53, 44, 48, 15, 50,
+ -1, 48, 48, 48, 58, 48, 3, 72, 53, 48,
+ 53, 50, 48, 48, 50, 48, 62, 64, 53, 82,
+ 53, 82, 48, 48, 41, 13, 88, 53, 16, 54,
+ 48, 72, 48, 3, 50, 48, 54, 4, 48, 13,
+ 50, 100, 86, 56, 48, 48, 50, 50, 48, 48,
+ 50, -1, 51, 48, 48, 48, 51, 50, 48, 48,
+ 54, 50, 48, 53, 50, 48, 48, 48, 50, 48,
+ 53, 45, 48, 54, 50, 72, -1, 48, -1, 48,
+ -1, 60, 53, 48, 53, 48, 15, 48, 53, -1,
+ 53, 48, 53, 48, 65, -1, 53, -1, 53, 48,
+ 55, 70, 72, 48, 53, 70, 63, 70, 53, 70,
+ 48, 48, 41, 42, 59, 53, 53, 55, 48, 13,
+ 57, 70, 48, 53, 48, 55, 20, 53, -1, 53,
+ -1, 55, -1, 5, -1, 61, 5, -1, 32, 33,
+ 13, 13, -1, 16, 13, -1, -1, -1, 20, -1,
+ -1, 20, 22, 23, 24, 25, 26, 27, 28, -1,
+ 32, 33, -1, 32, 33, 21, 22, 23, 24, 25,
+ 26, 27, 28, 13, -1, -1, -1, -1, -1, -1,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 13,
+ -1, -1, -1, -1, -1, -1, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, -1, 18,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1};
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/parser/qqmljsgrammar_p.h b/src/qml/qml/parser/qqmljsgrammar_p.h
new file mode 100644
index 0000000000..455391a862
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsgrammar_p.h
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+// This file was generated by qlalr - DO NOT EDIT!
+#ifndef QQMLJSGRAMMAR_P_H
+#define QQMLJSGRAMMAR_P_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlJSGrammar
+{
+public:
+ enum VariousConstants {
+ EOF_SYMBOL = 0,
+ REDUCE_HERE = 101,
+ SHIFT_THERE = 100,
+ T_AND = 1,
+ T_AND_AND = 2,
+ T_AND_EQ = 3,
+ T_AS = 91,
+ T_AUTOMATIC_SEMICOLON = 62,
+ T_BREAK = 4,
+ T_CASE = 5,
+ T_CATCH = 6,
+ T_COLON = 7,
+ T_COMMA = 8,
+ T_COMMENT = 88,
+ T_CONST = 84,
+ T_CONTINUE = 9,
+ T_DEBUGGER = 85,
+ T_DEFAULT = 10,
+ T_DELETE = 11,
+ T_DIVIDE_ = 12,
+ T_DIVIDE_EQ = 13,
+ T_DO = 14,
+ T_DOT = 15,
+ T_ELSE = 16,
+ T_EQ = 17,
+ T_EQ_EQ = 18,
+ T_EQ_EQ_EQ = 19,
+ T_ERROR = 93,
+ T_FALSE = 83,
+ T_FEED_JS_EXPRESSION = 97,
+ T_FEED_JS_PROGRAM = 99,
+ T_FEED_JS_SOURCE_ELEMENT = 98,
+ T_FEED_JS_STATEMENT = 96,
+ T_FEED_UI_OBJECT_MEMBER = 95,
+ T_FEED_UI_PROGRAM = 94,
+ T_FINALLY = 20,
+ T_FOR = 21,
+ T_FUNCTION = 22,
+ T_GE = 23,
+ T_GT = 24,
+ T_GT_GT = 25,
+ T_GT_GT_EQ = 26,
+ T_GT_GT_GT = 27,
+ T_GT_GT_GT_EQ = 28,
+ T_IDENTIFIER = 29,
+ T_IF = 30,
+ T_IMPORT = 90,
+ T_IN = 31,
+ T_INSTANCEOF = 32,
+ T_LBRACE = 33,
+ T_LBRACKET = 34,
+ T_LE = 35,
+ T_LPAREN = 36,
+ T_LT = 37,
+ T_LT_LT = 38,
+ T_LT_LT_EQ = 39,
+ T_MINUS = 40,
+ T_MINUS_EQ = 41,
+ T_MINUS_MINUS = 42,
+ T_MULTILINE_STRING_LITERAL = 87,
+ T_NEW = 43,
+ T_NOT = 44,
+ T_NOT_EQ = 45,
+ T_NOT_EQ_EQ = 46,
+ T_NULL = 81,
+ T_NUMERIC_LITERAL = 47,
+ T_ON = 92,
+ T_OR = 48,
+ T_OR_EQ = 49,
+ T_OR_OR = 50,
+ T_PLUS = 51,
+ T_PLUS_EQ = 52,
+ T_PLUS_PLUS = 53,
+ T_PROPERTY = 66,
+ T_PUBLIC = 89,
+ T_QUESTION = 54,
+ T_RBRACE = 55,
+ T_RBRACKET = 56,
+ T_READONLY = 68,
+ T_REMAINDER = 57,
+ T_REMAINDER_EQ = 58,
+ T_RESERVED_WORD = 86,
+ T_RETURN = 59,
+ T_RPAREN = 60,
+ T_SEMICOLON = 61,
+ T_SIGNAL = 67,
+ T_STAR = 63,
+ T_STAR_EQ = 64,
+ T_STRING_LITERAL = 65,
+ T_SWITCH = 69,
+ T_THIS = 70,
+ T_THROW = 71,
+ T_TILDE = 72,
+ T_TRUE = 82,
+ T_TRY = 73,
+ T_TYPEOF = 74,
+ T_VAR = 75,
+ T_VOID = 76,
+ T_WHILE = 77,
+ T_WITH = 78,
+ T_XOR = 79,
+ T_XOR_EQ = 80,
+
+ ACCEPT_STATE = 644,
+ RULE_COUNT = 349,
+ STATE_COUNT = 645,
+ TERMINAL_COUNT = 102,
+ NON_TERMINAL_COUNT = 107,
+
+ GOTO_INDEX_OFFSET = 645,
+ GOTO_INFO_OFFSET = 2807,
+ GOTO_CHECK_OFFSET = 2807
+ };
+
+ static const char *const spell [];
+ static const short lhs [];
+ static const short rhs [];
+ static const short goto_default [];
+ static const short action_default [];
+ static const short action_index [];
+ static const short action_info [];
+ static const short action_check [];
+
+ static inline int nt_action (int state, int nt)
+ {
+ const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;
+ if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)
+ return goto_default [nt];
+
+ return action_info [GOTO_INFO_OFFSET + yyn];
+ }
+
+ static inline int t_action (int state, int token)
+ {
+ const int yyn = action_index [state] + token;
+
+ if (yyn < 0 || action_check [yyn] != token)
+ return - action_default [state];
+
+ return action_info [yyn];
+ }
+};
+
+
+QT_END_NAMESPACE
+#endif // QQMLJSGRAMMAR_P_H
+
diff --git a/src/qml/qml/parser/qqmljskeywords_p.h b/src/qml/qml/parser/qqmljskeywords_p.h
new file mode 100644
index 0000000000..bbcc4855a3
--- /dev/null
+++ b/src/qml/qml/parser/qqmljskeywords_p.h
@@ -0,0 +1,860 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLJSKEYWORDS_P_H
+#define QQMLJSKEYWORDS_P_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.
+//
+
+static inline int classify2(const QChar *s, bool qmlMode) {
+ if (s[0].unicode() == 'a') {
+ if (s[1].unicode() == 's') {
+ return qmlMode ? Lexer::T_AS : Lexer::T_RESERVED_WORD;
+ }
+ }
+ else if (s[0].unicode() == 'd') {
+ if (s[1].unicode() == 'o') {
+ return Lexer::T_DO;
+ }
+ }
+ else if (s[0].unicode() == 'i') {
+ if (s[1].unicode() == 'f') {
+ return Lexer::T_IF;
+ }
+ else if (s[1].unicode() == 'n') {
+ return Lexer::T_IN;
+ }
+ }
+ else if (qmlMode && s[0].unicode() == 'o') {
+ if (s[1].unicode() == 'n') {
+ return Lexer::T_ON;
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify3(const QChar *s, bool /*qmlMode*/) {
+ if (s[0].unicode() == 'f') {
+ if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 'r') {
+ return Lexer::T_FOR;
+ }
+ }
+ }
+ else if (s[0].unicode() == 'i') {
+ if (s[1].unicode() == 'n') {
+ if (s[2].unicode() == 't') {
+ return Lexer::T_INT;
+ }
+ }
+ }
+ else if (s[0].unicode() == 'n') {
+ if (s[1].unicode() == 'e') {
+ if (s[2].unicode() == 'w') {
+ return Lexer::T_NEW;
+ }
+ }
+ }
+ else if (s[0].unicode() == 't') {
+ if (s[1].unicode() == 'r') {
+ if (s[2].unicode() == 'y') {
+ return Lexer::T_TRY;
+ }
+ }
+ }
+ else if (s[0].unicode() == 'v') {
+ if (s[1].unicode() == 'a') {
+ if (s[2].unicode() == 'r') {
+ return Lexer::T_VAR;
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify4(const QChar *s, bool /*qmlMode*/) {
+ if (s[0].unicode() == 'b') {
+ if (s[1].unicode() == 'y') {
+ if (s[2].unicode() == 't') {
+ if (s[3].unicode() == 'e') {
+ return Lexer::T_BYTE;
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'c') {
+ if (s[1].unicode() == 'a') {
+ if (s[2].unicode() == 's') {
+ if (s[3].unicode() == 'e') {
+ return Lexer::T_CASE;
+ }
+ }
+ }
+ else if (s[1].unicode() == 'h') {
+ if (s[2].unicode() == 'a') {
+ if (s[3].unicode() == 'r') {
+ return Lexer::T_CHAR;
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'e') {
+ if (s[1].unicode() == 'l') {
+ if (s[2].unicode() == 's') {
+ if (s[3].unicode() == 'e') {
+ return Lexer::T_ELSE;
+ }
+ }
+ }
+ else if (s[1].unicode() == 'n') {
+ if (s[2].unicode() == 'u') {
+ if (s[3].unicode() == 'm') {
+ return Lexer::T_ENUM;
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'g') {
+ if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 't') {
+ if (s[3].unicode() == 'o') {
+ return Lexer::T_GOTO;
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'l') {
+ if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 'n') {
+ if (s[3].unicode() == 'g') {
+ return Lexer::T_LONG;
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'n') {
+ if (s[1].unicode() == 'u') {
+ if (s[2].unicode() == 'l') {
+ if (s[3].unicode() == 'l') {
+ return Lexer::T_NULL;
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 't') {
+ if (s[1].unicode() == 'h') {
+ if (s[2].unicode() == 'i') {
+ if (s[3].unicode() == 's') {
+ return Lexer::T_THIS;
+ }
+ }
+ }
+ else if (s[1].unicode() == 'r') {
+ if (s[2].unicode() == 'u') {
+ if (s[3].unicode() == 'e') {
+ return Lexer::T_TRUE;
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'v') {
+ if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 'i') {
+ if (s[3].unicode() == 'd') {
+ return Lexer::T_VOID;
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'w') {
+ if (s[1].unicode() == 'i') {
+ if (s[2].unicode() == 't') {
+ if (s[3].unicode() == 'h') {
+ return Lexer::T_WITH;
+ }
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify5(const QChar *s, bool /*qmlMode*/) {
+ if (s[0].unicode() == 'b') {
+ if (s[1].unicode() == 'r') {
+ if (s[2].unicode() == 'e') {
+ if (s[3].unicode() == 'a') {
+ if (s[4].unicode() == 'k') {
+ return Lexer::T_BREAK;
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'c') {
+ if (s[1].unicode() == 'a') {
+ if (s[2].unicode() == 't') {
+ if (s[3].unicode() == 'c') {
+ if (s[4].unicode() == 'h') {
+ return Lexer::T_CATCH;
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'l') {
+ if (s[2].unicode() == 'a') {
+ if (s[3].unicode() == 's') {
+ if (s[4].unicode() == 's') {
+ return Lexer::T_CLASS;
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 'n') {
+ if (s[3].unicode() == 's') {
+ if (s[4].unicode() == 't') {
+ return Lexer::T_CONST;
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'f') {
+ if (s[1].unicode() == 'a') {
+ if (s[2].unicode() == 'l') {
+ if (s[3].unicode() == 's') {
+ if (s[4].unicode() == 'e') {
+ return Lexer::T_FALSE;
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'i') {
+ if (s[2].unicode() == 'n') {
+ if (s[3].unicode() == 'a') {
+ if (s[4].unicode() == 'l') {
+ return Lexer::T_FINAL;
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'l') {
+ if (s[2].unicode() == 'o') {
+ if (s[3].unicode() == 'a') {
+ if (s[4].unicode() == 't') {
+ return Lexer::T_FLOAT;
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 's') {
+ if (s[1].unicode() == 'h') {
+ if (s[2].unicode() == 'o') {
+ if (s[3].unicode() == 'r') {
+ if (s[4].unicode() == 't') {
+ return Lexer::T_SHORT;
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'u') {
+ if (s[2].unicode() == 'p') {
+ if (s[3].unicode() == 'e') {
+ if (s[4].unicode() == 'r') {
+ return Lexer::T_SUPER;
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 't') {
+ if (s[1].unicode() == 'h') {
+ if (s[2].unicode() == 'r') {
+ if (s[3].unicode() == 'o') {
+ if (s[4].unicode() == 'w') {
+ return Lexer::T_THROW;
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'w') {
+ if (s[1].unicode() == 'h') {
+ if (s[2].unicode() == 'i') {
+ if (s[3].unicode() == 'l') {
+ if (s[4].unicode() == 'e') {
+ return Lexer::T_WHILE;
+ }
+ }
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify6(const QChar *s, bool qmlMode) {
+ if (s[0].unicode() == 'd') {
+ if (s[1].unicode() == 'e') {
+ if (s[2].unicode() == 'l') {
+ if (s[3].unicode() == 'e') {
+ if (s[4].unicode() == 't') {
+ if (s[5].unicode() == 'e') {
+ return Lexer::T_DELETE;
+ }
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 'u') {
+ if (s[3].unicode() == 'b') {
+ if (s[4].unicode() == 'l') {
+ if (s[5].unicode() == 'e') {
+ return Lexer::T_DOUBLE;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'e') {
+ if (s[1].unicode() == 'x') {
+ if (s[2].unicode() == 'p') {
+ if (s[3].unicode() == 'o') {
+ if (s[4].unicode() == 'r') {
+ if (s[5].unicode() == 't') {
+ return Lexer::T_EXPORT;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'i') {
+ if (s[1].unicode() == 'm') {
+ if (s[2].unicode() == 'p') {
+ if (s[3].unicode() == 'o') {
+ if (s[4].unicode() == 'r') {
+ if (s[5].unicode() == 't') {
+ return qmlMode ? Lexer::T_IMPORT : Lexer::T_RESERVED_WORD;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'n') {
+ if (s[1].unicode() == 'a') {
+ if (s[2].unicode() == 't') {
+ if (s[3].unicode() == 'i') {
+ if (s[4].unicode() == 'v') {
+ if (s[5].unicode() == 'e') {
+ return Lexer::T_NATIVE;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'p') {
+ if (s[1].unicode() == 'u') {
+ if (s[2].unicode() == 'b') {
+ if (s[3].unicode() == 'l') {
+ if (s[4].unicode() == 'i') {
+ if (s[5].unicode() == 'c') {
+ return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'r') {
+ if (s[1].unicode() == 'e') {
+ if (s[2].unicode() == 't') {
+ if (s[3].unicode() == 'u') {
+ if (s[4].unicode() == 'r') {
+ if (s[5].unicode() == 'n') {
+ return Lexer::T_RETURN;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 's') {
+ if (qmlMode && s[1].unicode() == 'i') {
+ if (s[2].unicode() == 'g') {
+ if (s[3].unicode() == 'n') {
+ if (s[4].unicode() == 'a') {
+ if (s[5].unicode() == 'l') {
+ return Lexer::T_SIGNAL;
+ }
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 't') {
+ if (s[2].unicode() == 'a') {
+ if (s[3].unicode() == 't') {
+ if (s[4].unicode() == 'i') {
+ if (s[5].unicode() == 'c') {
+ return Lexer::T_STATIC;
+ }
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'w') {
+ if (s[2].unicode() == 'i') {
+ if (s[3].unicode() == 't') {
+ if (s[4].unicode() == 'c') {
+ if (s[5].unicode() == 'h') {
+ return Lexer::T_SWITCH;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 't') {
+ if (s[1].unicode() == 'h') {
+ if (s[2].unicode() == 'r') {
+ if (s[3].unicode() == 'o') {
+ if (s[4].unicode() == 'w') {
+ if (s[5].unicode() == 's') {
+ return Lexer::T_THROWS;
+ }
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'y') {
+ if (s[2].unicode() == 'p') {
+ if (s[3].unicode() == 'e') {
+ if (s[4].unicode() == 'o') {
+ if (s[5].unicode() == 'f') {
+ return Lexer::T_TYPEOF;
+ }
+ }
+ }
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify7(const QChar *s, bool /*qmlMode*/) {
+ if (s[0].unicode() == 'b') {
+ if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 'o') {
+ if (s[3].unicode() == 'l') {
+ if (s[4].unicode() == 'e') {
+ if (s[5].unicode() == 'a') {
+ if (s[6].unicode() == 'n') {
+ return Lexer::T_BOOLEAN;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'd') {
+ if (s[1].unicode() == 'e') {
+ if (s[2].unicode() == 'f') {
+ if (s[3].unicode() == 'a') {
+ if (s[4].unicode() == 'u') {
+ if (s[5].unicode() == 'l') {
+ if (s[6].unicode() == 't') {
+ return Lexer::T_DEFAULT;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'e') {
+ if (s[1].unicode() == 'x') {
+ if (s[2].unicode() == 't') {
+ if (s[3].unicode() == 'e') {
+ if (s[4].unicode() == 'n') {
+ if (s[5].unicode() == 'd') {
+ if (s[6].unicode() == 's') {
+ return Lexer::T_EXTENDS;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'f') {
+ if (s[1].unicode() == 'i') {
+ if (s[2].unicode() == 'n') {
+ if (s[3].unicode() == 'a') {
+ if (s[4].unicode() == 'l') {
+ if (s[5].unicode() == 'l') {
+ if (s[6].unicode() == 'y') {
+ return Lexer::T_FINALLY;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'p') {
+ if (s[1].unicode() == 'a') {
+ if (s[2].unicode() == 'c') {
+ if (s[3].unicode() == 'k') {
+ if (s[4].unicode() == 'a') {
+ if (s[5].unicode() == 'g') {
+ if (s[6].unicode() == 'e') {
+ return Lexer::T_PACKAGE;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'r') {
+ if (s[2].unicode() == 'i') {
+ if (s[3].unicode() == 'v') {
+ if (s[4].unicode() == 'a') {
+ if (s[5].unicode() == 't') {
+ if (s[6].unicode() == 'e') {
+ return Lexer::T_PRIVATE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify8(const QChar *s, bool qmlMode) {
+ if (s[0].unicode() == 'a') {
+ if (s[1].unicode() == 'b') {
+ if (s[2].unicode() == 's') {
+ if (s[3].unicode() == 't') {
+ if (s[4].unicode() == 'r') {
+ if (s[5].unicode() == 'a') {
+ if (s[6].unicode() == 'c') {
+ if (s[7].unicode() == 't') {
+ return Lexer::T_ABSTRACT;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'c') {
+ if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 'n') {
+ if (s[3].unicode() == 't') {
+ if (s[4].unicode() == 'i') {
+ if (s[5].unicode() == 'n') {
+ if (s[6].unicode() == 'u') {
+ if (s[7].unicode() == 'e') {
+ return Lexer::T_CONTINUE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'd') {
+ if (s[1].unicode() == 'e') {
+ if (s[2].unicode() == 'b') {
+ if (s[3].unicode() == 'u') {
+ if (s[4].unicode() == 'g') {
+ if (s[5].unicode() == 'g') {
+ if (s[6].unicode() == 'e') {
+ if (s[7].unicode() == 'r') {
+ return Lexer::T_DEBUGGER;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'f') {
+ if (s[1].unicode() == 'u') {
+ if (s[2].unicode() == 'n') {
+ if (s[3].unicode() == 'c') {
+ if (s[4].unicode() == 't') {
+ if (s[5].unicode() == 'i') {
+ if (s[6].unicode() == 'o') {
+ if (s[7].unicode() == 'n') {
+ return Lexer::T_FUNCTION;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (qmlMode && s[0].unicode() == 'p') {
+ if (s[1].unicode() == 'r') {
+ if (s[2].unicode() == 'o') {
+ if (s[3].unicode() == 'p') {
+ if (s[4].unicode() == 'e') {
+ if (s[5].unicode() == 'r') {
+ if (s[6].unicode() == 't') {
+ if (s[7].unicode() == 'y') {
+ return Lexer::T_PROPERTY;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (qmlMode && s[0].unicode() == 'r') {
+ if (s[1].unicode() == 'e') {
+ if (s[2].unicode() == 'a') {
+ if (s[3].unicode() == 'd') {
+ if (s[4].unicode() == 'o') {
+ if (s[5].unicode() == 'n') {
+ if (s[6].unicode() == 'l') {
+ if (s[7].unicode() == 'y') {
+ return Lexer::T_READONLY;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'v') {
+ if (s[1].unicode() == 'o') {
+ if (s[2].unicode() == 'l') {
+ if (s[3].unicode() == 'a') {
+ if (s[4].unicode() == 't') {
+ if (s[5].unicode() == 'i') {
+ if (s[6].unicode() == 'l') {
+ if (s[7].unicode() == 'e') {
+ return Lexer::T_VOLATILE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify9(const QChar *s, bool /*qmlMode*/) {
+ if (s[0].unicode() == 'i') {
+ if (s[1].unicode() == 'n') {
+ if (s[2].unicode() == 't') {
+ if (s[3].unicode() == 'e') {
+ if (s[4].unicode() == 'r') {
+ if (s[5].unicode() == 'f') {
+ if (s[6].unicode() == 'a') {
+ if (s[7].unicode() == 'c') {
+ if (s[8].unicode() == 'e') {
+ return Lexer::T_INTERFACE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'p') {
+ if (s[1].unicode() == 'r') {
+ if (s[2].unicode() == 'o') {
+ if (s[3].unicode() == 't') {
+ if (s[4].unicode() == 'e') {
+ if (s[5].unicode() == 'c') {
+ if (s[6].unicode() == 't') {
+ if (s[7].unicode() == 'e') {
+ if (s[8].unicode() == 'd') {
+ return Lexer::T_PROTECTED;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 't') {
+ if (s[1].unicode() == 'r') {
+ if (s[2].unicode() == 'a') {
+ if (s[3].unicode() == 'n') {
+ if (s[4].unicode() == 's') {
+ if (s[5].unicode() == 'i') {
+ if (s[6].unicode() == 'e') {
+ if (s[7].unicode() == 'n') {
+ if (s[8].unicode() == 't') {
+ return Lexer::T_TRANSIENT;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify10(const QChar *s, bool /*qmlMode*/) {
+ if (s[0].unicode() == 'i') {
+ if (s[1].unicode() == 'm') {
+ if (s[2].unicode() == 'p') {
+ if (s[3].unicode() == 'l') {
+ if (s[4].unicode() == 'e') {
+ if (s[5].unicode() == 'm') {
+ if (s[6].unicode() == 'e') {
+ if (s[7].unicode() == 'n') {
+ if (s[8].unicode() == 't') {
+ if (s[9].unicode() == 's') {
+ return Lexer::T_IMPLEMENTS;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[1].unicode() == 'n') {
+ if (s[2].unicode() == 's') {
+ if (s[3].unicode() == 't') {
+ if (s[4].unicode() == 'a') {
+ if (s[5].unicode() == 'n') {
+ if (s[6].unicode() == 'c') {
+ if (s[7].unicode() == 'e') {
+ if (s[8].unicode() == 'o') {
+ if (s[9].unicode() == 'f') {
+ return Lexer::T_INSTANCEOF;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+static inline int classify12(const QChar *s, bool /*qmlMode*/) {
+ if (s[0].unicode() == 's') {
+ if (s[1].unicode() == 'y') {
+ if (s[2].unicode() == 'n') {
+ if (s[3].unicode() == 'c') {
+ if (s[4].unicode() == 'h') {
+ if (s[5].unicode() == 'r') {
+ if (s[6].unicode() == 'o') {
+ if (s[7].unicode() == 'n') {
+ if (s[8].unicode() == 'i') {
+ if (s[9].unicode() == 'z') {
+ if (s[10].unicode() == 'e') {
+ if (s[11].unicode() == 'd') {
+ return Lexer::T_SYNCHRONIZED;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return Lexer::T_IDENTIFIER;
+}
+
+int Lexer::classify(const QChar *s, int n, bool qmlMode) {
+ switch (n) {
+ case 2: return classify2(s, qmlMode);
+ case 3: return classify3(s, qmlMode);
+ case 4: return classify4(s, qmlMode);
+ case 5: return classify5(s, qmlMode);
+ case 6: return classify6(s, qmlMode);
+ case 7: return classify7(s, qmlMode);
+ case 8: return classify8(s, qmlMode);
+ case 9: return classify9(s, qmlMode);
+ case 10: return classify10(s, qmlMode);
+ case 12: return classify12(s, qmlMode);
+ default: return Lexer::T_IDENTIFIER;
+ } // switch
+}
+
+#endif // QQMLJSKEYWORDS_P_H
diff --git a/src/qml/qml/parser/qqmljslexer.cpp b/src/qml/qml/parser/qqmljslexer.cpp
new file mode 100644
index 0000000000..c34fc81163
--- /dev/null
+++ b/src/qml/qml/parser/qqmljslexer.cpp
@@ -0,0 +1,1166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmljslexer_p.h"
+#include "qqmljsengine_p.h"
+#include "qqmljsmemorypool_p.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QVarLengthArray>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
+QT_END_NAMESPACE
+
+using namespace QQmlJS;
+
+static int regExpFlagFromChar(const QChar &ch)
+{
+ switch (ch.unicode()) {
+ case 'g': return Lexer::RegExp_Global;
+ case 'i': return Lexer::RegExp_IgnoreCase;
+ case 'm': return Lexer::RegExp_Multiline;
+ }
+ return 0;
+}
+
+static unsigned char convertHex(ushort c)
+{
+ if (c >= '0' && c <= '9')
+ return (c - '0');
+ else if (c >= 'a' && c <= 'f')
+ return (c - 'a' + 10);
+ else
+ return (c - 'A' + 10);
+}
+
+static QChar convertHex(QChar c1, QChar c2)
+{
+ return QChar((convertHex(c1.unicode()) << 4) + convertHex(c2.unicode()));
+}
+
+static QChar convertUnicode(QChar c1, QChar c2, QChar c3, QChar c4)
+{
+ return QChar((convertHex(c3.unicode()) << 4) + convertHex(c4.unicode()),
+ (convertHex(c1.unicode()) << 4) + convertHex(c2.unicode()));
+}
+
+Lexer::Lexer(Engine *engine)
+ : _engine(engine)
+ , _codePtr(0)
+ , _lastLinePtr(0)
+ , _tokenLinePtr(0)
+ , _tokenStartPtr(0)
+ , _char(QLatin1Char('\n'))
+ , _errorCode(NoError)
+ , _currentLineNumber(0)
+ , _tokenValue(0)
+ , _parenthesesState(IgnoreParentheses)
+ , _parenthesesCount(0)
+ , _stackToken(-1)
+ , _patternFlags(0)
+ , _tokenKind(0)
+ , _tokenLength(0)
+ , _tokenLine(0)
+ , _validTokenText(false)
+ , _prohibitAutomaticSemicolon(false)
+ , _restrictedKeyword(false)
+ , _terminator(false)
+ , _followsClosingBrace(false)
+ , _delimited(true)
+ , _qmlMode(true)
+{
+ if (engine)
+ engine->setLexer(this);
+}
+
+bool Lexer::qmlMode() const
+{
+ return _qmlMode;
+}
+
+QString Lexer::code() const
+{
+ return _code;
+}
+
+void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
+{
+ if (_engine)
+ _engine->setCode(code);
+
+ _qmlMode = qmlMode;
+ _code = code;
+ _tokenText.clear();
+ _tokenText.reserve(1024);
+ _errorMessage.clear();
+ _tokenSpell = QStringRef();
+
+ _codePtr = code.unicode();
+ _lastLinePtr = _codePtr;
+ _tokenLinePtr = _codePtr;
+ _tokenStartPtr = _codePtr;
+
+ _char = QLatin1Char('\n');
+ _errorCode = NoError;
+
+ _currentLineNumber = lineno;
+ _tokenValue = 0;
+
+ // parentheses state
+ _parenthesesState = IgnoreParentheses;
+ _parenthesesCount = 0;
+
+ _stackToken = -1;
+
+ _patternFlags = 0;
+ _tokenLength = 0;
+ _tokenLine = lineno;
+
+ _validTokenText = false;
+ _prohibitAutomaticSemicolon = false;
+ _restrictedKeyword = false;
+ _terminator = false;
+ _followsClosingBrace = false;
+ _delimited = true;
+}
+
+void Lexer::scanChar()
+{
+ _char = *_codePtr++;
+
+ if (_char == QLatin1Char('\n')) {
+ _lastLinePtr = _codePtr; // points to the first character after the newline
+ ++_currentLineNumber;
+ }
+}
+
+int Lexer::lex()
+{
+ const int previousTokenKind = _tokenKind;
+
+ _tokenSpell = QStringRef();
+ _tokenKind = scanToken();
+ _tokenLength = _codePtr - _tokenStartPtr - 1;
+
+ _delimited = false;
+ _restrictedKeyword = false;
+ _followsClosingBrace = (previousTokenKind == T_RBRACE);
+
+ // update the flags
+ switch (_tokenKind) {
+ case T_LBRACE:
+ case T_SEMICOLON:
+ case T_COLON:
+ _delimited = true;
+ break;
+
+ case T_IF:
+ case T_FOR:
+ case T_WHILE:
+ case T_WITH:
+ _parenthesesState = CountParentheses;
+ _parenthesesCount = 0;
+ break;
+
+ case T_DO:
+ _parenthesesState = BalancedParentheses;
+ break;
+
+ case T_CONTINUE:
+ case T_BREAK:
+ case T_RETURN:
+ case T_THROW:
+ _restrictedKeyword = true;
+ break;
+ } // switch
+
+ // update the parentheses state
+ switch (_parenthesesState) {
+ case IgnoreParentheses:
+ break;
+
+ case CountParentheses:
+ if (_tokenKind == T_RPAREN) {
+ --_parenthesesCount;
+ if (_parenthesesCount == 0)
+ _parenthesesState = BalancedParentheses;
+ } else if (_tokenKind == T_LPAREN) {
+ ++_parenthesesCount;
+ }
+ break;
+
+ case BalancedParentheses:
+ _parenthesesState = IgnoreParentheses;
+ break;
+ } // switch
+
+ return _tokenKind;
+}
+
+bool Lexer::isUnicodeEscapeSequence(const QChar *chars)
+{
+ if (isHexDigit(chars[0]) && isHexDigit(chars[1]) && isHexDigit(chars[2]) && isHexDigit(chars[3]))
+ return true;
+
+ return false;
+}
+
+QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok)
+{
+ if (_char == QLatin1Char('u') && isUnicodeEscapeSequence(&_codePtr[0])) {
+ scanChar(); // skip u
+
+ const QChar c1 = _char;
+ scanChar();
+
+ const QChar c2 = _char;
+ scanChar();
+
+ const QChar c3 = _char;
+ scanChar();
+
+ const QChar c4 = _char;
+ scanChar();
+
+ if (ok)
+ *ok = true;
+
+ return convertUnicode(c1, c2, c3, c4);
+ }
+
+ *ok = false;
+ return QChar();
+}
+
+int Lexer::scanToken()
+{
+ if (_stackToken != -1) {
+ int tk = _stackToken;
+ _stackToken = -1;
+ return tk;
+ }
+
+ _terminator = false;
+
+again:
+ _validTokenText = false;
+ _tokenLinePtr = _lastLinePtr;
+
+ while (_char.isSpace()) {
+ if (_char == QLatin1Char('\n')) {
+ _tokenLinePtr = _codePtr;
+
+ if (_restrictedKeyword) {
+ // automatic semicolon insertion
+ _tokenLine = _currentLineNumber;
+ _tokenStartPtr = _codePtr - 1; // ### TODO: insert it before the optional \r sequence.
+ return T_SEMICOLON;
+ } else {
+ _terminator = true;
+ syncProhibitAutomaticSemicolon();
+ }
+ }
+
+ scanChar();
+ }
+
+ _tokenStartPtr = _codePtr - 1;
+ _tokenLine = _currentLineNumber;
+
+ if (_char.isNull())
+ return EOF_SYMBOL;
+
+ const QChar ch = _char;
+ scanChar();
+
+ switch (ch.unicode()) {
+ case '~': return T_TILDE;
+ case '}': return T_RBRACE;
+
+ case '|':
+ if (_char == QLatin1Char('|')) {
+ scanChar();
+ return T_OR_OR;
+ } else if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_OR_EQ;
+ }
+ return T_OR;
+
+ case '{': return T_LBRACE;
+
+ case '^':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_XOR_EQ;
+ }
+ return T_XOR;
+
+ case ']': return T_RBRACKET;
+ case '[': return T_LBRACKET;
+ case '?': return T_QUESTION;
+
+ case '>':
+ if (_char == QLatin1Char('>')) {
+ scanChar();
+ if (_char == QLatin1Char('>')) {
+ scanChar();
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_GT_GT_GT_EQ;
+ }
+ return T_GT_GT_GT;
+ } else if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_GT_GT_EQ;
+ }
+ return T_GT_GT;
+ } else if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_GE;
+ }
+ return T_GT;
+
+ case '=':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_EQ_EQ_EQ;
+ }
+ return T_EQ_EQ;
+ }
+ return T_EQ;
+
+ case '<':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_LE;
+ } else if (_char == QLatin1Char('<')) {
+ scanChar();
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_LT_LT_EQ;
+ }
+ return T_LT_LT;
+ }
+ return T_LT;
+
+ case ';': return T_SEMICOLON;
+ case ':': return T_COLON;
+
+ case '/':
+ if (_char == QLatin1Char('*')) {
+ scanChar();
+ while (!_char.isNull()) {
+ if (_char == QLatin1Char('*')) {
+ scanChar();
+ if (_char == QLatin1Char('/')) {
+ scanChar();
+
+ if (_engine) {
+ _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 4,
+ tokenStartLine(), tokenStartColumn() + 2);
+ }
+
+ goto again;
+ }
+ } else {
+ scanChar();
+ }
+ }
+ } else if (_char == QLatin1Char('/')) {
+ while (!_char.isNull() && _char != QLatin1Char('\n')) {
+ scanChar();
+ }
+ if (_engine) {
+ _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 2,
+ tokenStartLine(), tokenStartColumn() + 2);
+ }
+ goto again;
+ } if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_DIVIDE_EQ;
+ }
+ return T_DIVIDE_;
+
+ case '.':
+ if (_char.isDigit()) {
+ QVarLengthArray<char,32> chars;
+
+ chars.append(ch.unicode()); // append the `.'
+
+ while (_char.isDigit()) {
+ chars.append(_char.unicode());
+ scanChar();
+ }
+
+ if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
+ if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
+ _codePtr[1].isDigit())) {
+
+ chars.append(_char.unicode());
+ scanChar(); // consume `e'
+
+ if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
+ chars.append(_char.unicode());
+ scanChar(); // consume the sign
+ }
+
+ while (_char.isDigit()) {
+ chars.append(_char.unicode());
+ scanChar();
+ }
+ }
+ }
+
+ chars.append('\0');
+
+ const char *begin = chars.constData();
+ const char *end = 0;
+ bool ok = false;
+
+ _tokenValue = qstrtod(begin, &end, &ok);
+
+ if (end - begin != chars.size() - 1) {
+ _errorCode = IllegalExponentIndicator;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal syntax for exponential number");
+ return T_ERROR;
+ }
+
+ return T_NUMERIC_LITERAL;
+ }
+ return T_DOT;
+
+ case '-':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_MINUS_EQ;
+ } else if (_char == QLatin1Char('-')) {
+ scanChar();
+
+ if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) {
+ _stackToken = T_MINUS_MINUS;
+ return T_SEMICOLON;
+ }
+
+ return T_MINUS_MINUS;
+ }
+ return T_MINUS;
+
+ case ',': return T_COMMA;
+
+ case '+':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_PLUS_EQ;
+ } else if (_char == QLatin1Char('+')) {
+ scanChar();
+
+ if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) {
+ _stackToken = T_PLUS_PLUS;
+ return T_SEMICOLON;
+ }
+
+ return T_PLUS_PLUS;
+ }
+ return T_PLUS;
+
+ case '*':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_STAR_EQ;
+ }
+ return T_STAR;
+
+ case ')': return T_RPAREN;
+ case '(': return T_LPAREN;
+
+ case '&':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_AND_EQ;
+ } else if (_char == QLatin1Char('&')) {
+ scanChar();
+ return T_AND_AND;
+ }
+ return T_AND;
+
+ case '%':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_REMAINDER_EQ;
+ }
+ return T_REMAINDER;
+
+ case '!':
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_NOT_EQ_EQ;
+ }
+ return T_NOT_EQ;
+ }
+ return T_NOT;
+
+ case '\'':
+ case '"': {
+ const QChar quote = ch;
+ bool multilineStringLiteral = false;
+
+ const QChar *startCode = _codePtr;
+
+ if (_engine) {
+ while (!_char.isNull()) {
+ if (_char == QLatin1Char('\n') || _char == QLatin1Char('\\')) {
+ break;
+ } else if (_char == quote) {
+ _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);
+ scanChar();
+
+ return T_STRING_LITERAL;
+ }
+ scanChar();
+ }
+ }
+
+ _validTokenText = true;
+ _tokenText.resize(0);
+ startCode--;
+ while (startCode != _codePtr - 1)
+ _tokenText += *startCode++;
+
+ while (! _char.isNull()) {
+ if (_char == QLatin1Char('\n')) {
+ multilineStringLiteral = true;
+ _tokenText += _char;
+ scanChar();
+ } else if (_char == quote) {
+ scanChar();
+
+ if (_engine)
+ _tokenSpell = _engine->newStringRef(_tokenText);
+
+ return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL;
+ } else if (_char == QLatin1Char('\\')) {
+ scanChar();
+
+ QChar u;
+ bool ok = false;
+
+ switch (_char.unicode()) {
+ // unicode escape sequence
+ case 'u':
+ u = decodeUnicodeEscapeCharacter(&ok);
+ if (! ok)
+ u = _char;
+ break;
+
+ // hex escape sequence
+ case 'x':
+ case 'X':
+ if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) {
+ scanChar();
+
+ const QChar c1 = _char;
+ scanChar();
+
+ const QChar c2 = _char;
+ scanChar();
+
+ u = convertHex(c1, c2);
+ } else {
+ u = _char;
+ }
+ break;
+
+ // single character escape sequence
+ case '\\': u = QLatin1Char('\\'); scanChar(); break;
+ case '\'': u = QLatin1Char('\''); scanChar(); break;
+ case '\"': u = QLatin1Char('\"'); scanChar(); break;
+ case 'b': u = QLatin1Char('\b'); scanChar(); break;
+ case 'f': u = QLatin1Char('\f'); scanChar(); break;
+ case 'n': u = QLatin1Char('\n'); scanChar(); break;
+ case 'r': u = QLatin1Char('\r'); scanChar(); break;
+ case 't': u = QLatin1Char('\t'); scanChar(); break;
+ case 'v': u = QLatin1Char('\v'); scanChar(); break;
+
+ case '0':
+ if (! _codePtr[1].isDigit()) {
+ scanChar();
+ u = QLatin1Char('\0');
+ } else {
+ // ### parse deprecated octal escape sequence ?
+ u = _char;
+ }
+ break;
+
+ case '\r':
+ while (_char == QLatin1Char('\r'))
+ scanChar();
+
+ if (_char == QLatin1Char('\n')) {
+ u = _char;
+ scanChar();
+ } else {
+ u = QLatin1Char('\n');
+ }
+
+ break;
+
+ case '\n':
+ u = _char;
+ scanChar();
+ break;
+
+ default:
+ // non escape character
+ u = _char;
+ scanChar();
+ }
+
+ _tokenText += u;
+ } else {
+ _tokenText += _char;
+ scanChar();
+ }
+ }
+
+ _errorCode = UnclosedStringLiteral;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Unclosed string at end of line");
+ return T_ERROR;
+ }
+
+ default:
+ if (ch.isLetter() || ch == QLatin1Char('$') || ch == QLatin1Char('_') || (ch == QLatin1Char('\\') && _char == QLatin1Char('u'))) {
+ bool identifierWithEscapeChars = false;
+ if (ch == QLatin1Char('\\')) {
+ identifierWithEscapeChars = true;
+ _tokenText.resize(0);
+ bool ok = false;
+ _tokenText += decodeUnicodeEscapeCharacter(&ok);
+ _validTokenText = true;
+ if (! ok) {
+ _errorCode = IllegalUnicodeEscapeSequence;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
+ return T_ERROR;
+ }
+ }
+ while (true) {
+ if (_char.isLetterOrNumber() || _char == QLatin1Char('$') || _char == QLatin1Char('_')) {
+ if (identifierWithEscapeChars)
+ _tokenText += _char;
+
+ scanChar();
+ } else if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) {
+ if (! identifierWithEscapeChars) {
+ identifierWithEscapeChars = true;
+ _tokenText.resize(0);
+ _tokenText.insert(0, _tokenStartPtr, _codePtr - _tokenStartPtr - 1);
+ _validTokenText = true;
+ }
+
+ scanChar(); // skip '\\'
+ bool ok = false;
+ _tokenText += decodeUnicodeEscapeCharacter(&ok);
+ if (! ok) {
+ _errorCode = IllegalUnicodeEscapeSequence;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
+ return T_ERROR;
+ }
+ } else {
+ _tokenLength = _codePtr - _tokenStartPtr - 1;
+
+ int kind = T_IDENTIFIER;
+
+ if (! identifierWithEscapeChars)
+ kind = classify(_tokenStartPtr, _tokenLength, _qmlMode);
+
+ if (_engine) {
+ if (kind == T_IDENTIFIER && identifierWithEscapeChars)
+ _tokenSpell = _engine->newStringRef(_tokenText);
+ else
+ _tokenSpell = _engine->midRef(_tokenStartPtr - _code.unicode(), _tokenLength);
+ }
+
+ return kind;
+ }
+ }
+ } else if (ch.isDigit()) {
+ if (ch != QLatin1Char('0')) {
+ double integer = ch.unicode() - '0';
+
+ QChar n = _char;
+ const QChar *code = _codePtr;
+ while (n.isDigit()) {
+ integer = integer * 10 + (n.unicode() - '0');
+ n = *code++;
+ }
+
+ if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) {
+ if (code != _codePtr) {
+ _codePtr = code - 1;
+ scanChar();
+ }
+ _tokenValue = integer;
+ return T_NUMERIC_LITERAL;
+ }
+ }
+
+ QVarLengthArray<char,32> chars;
+ chars.append(ch.unicode());
+
+ if (ch == QLatin1Char('0') && (_char == QLatin1Char('x') || _char == QLatin1Char('X'))) {
+ // parse hex integer literal
+
+ chars.append(_char.unicode());
+ scanChar(); // consume `x'
+
+ while (isHexDigit(_char)) {
+ chars.append(_char.unicode());
+ scanChar();
+ }
+
+ _tokenValue = integerFromString(chars.constData(), chars.size(), 16);
+ return T_NUMERIC_LITERAL;
+ }
+
+ // decimal integer literal
+ while (_char.isDigit()) {
+ chars.append(_char.unicode());
+ scanChar(); // consume the digit
+ }
+
+ if (_char == QLatin1Char('.')) {
+ chars.append(_char.unicode());
+ scanChar(); // consume `.'
+
+ while (_char.isDigit()) {
+ chars.append(_char.unicode());
+ scanChar();
+ }
+
+ if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
+ if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
+ _codePtr[1].isDigit())) {
+
+ chars.append(_char.unicode());
+ scanChar(); // consume `e'
+
+ if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
+ chars.append(_char.unicode());
+ scanChar(); // consume the sign
+ }
+
+ while (_char.isDigit()) {
+ chars.append(_char.unicode());
+ scanChar();
+ }
+ }
+ }
+ } else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
+ if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
+ _codePtr[1].isDigit())) {
+
+ chars.append(_char.unicode());
+ scanChar(); // consume `e'
+
+ if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
+ chars.append(_char.unicode());
+ scanChar(); // consume the sign
+ }
+
+ while (_char.isDigit()) {
+ chars.append(_char.unicode());
+ scanChar();
+ }
+ }
+ }
+
+ chars.append('\0');
+
+ const char *begin = chars.constData();
+ const char *end = 0;
+ bool ok = false;
+
+ _tokenValue = qstrtod(begin, &end, &ok);
+
+ if (end - begin != chars.size() - 1) {
+ _errorCode = IllegalExponentIndicator;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal syntax for exponential number");
+ return T_ERROR;
+ }
+
+ return T_NUMERIC_LITERAL;
+ }
+
+ break;
+ }
+
+ return T_ERROR;
+}
+
+bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
+{
+ _tokenText.resize(0);
+ _validTokenText = true;
+ _patternFlags = 0;
+
+ if (prefix == EqualPrefix)
+ _tokenText += QLatin1Char('=');
+
+ while (true) {
+ switch (_char.unicode()) {
+ case 0: // eof
+ case '\n': case '\r': // line terminator
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression literal");
+ return false;
+
+ case '/':
+ scanChar();
+
+ // scan the flags
+ _patternFlags = 0;
+ while (isIdentLetter(_char)) {
+ int flag = regExpFlagFromChar(_char);
+ if (flag == 0) {
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Invalid regular expression flag '%0'")
+ .arg(QChar(_char));
+ return false;
+ }
+ _patternFlags |= flag;
+ scanChar();
+ }
+
+ _tokenLength = _codePtr - _tokenStartPtr - 1;
+ return true;
+
+ case '\\':
+ // regular expression backslash sequence
+ _tokenText += _char;
+ scanChar();
+
+ if (_char.isNull() || isLineTerminator()) {
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence");
+ return false;
+ }
+
+ _tokenText += _char;
+ scanChar();
+ break;
+
+ case '[':
+ // regular expression class
+ _tokenText += _char;
+ scanChar();
+
+ while (! _char.isNull() && ! isLineTerminator()) {
+ if (_char == QLatin1Char(']'))
+ break;
+ else if (_char == QLatin1Char('\\')) {
+ // regular expression backslash sequence
+ _tokenText += _char;
+ scanChar();
+
+ if (_char.isNull() || isLineTerminator()) {
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence");
+ return false;
+ }
+
+ _tokenText += _char;
+ scanChar();
+ } else {
+ _tokenText += _char;
+ scanChar();
+ }
+ }
+
+ if (_char != QLatin1Char(']')) {
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression class");
+ return false;
+ }
+
+ _tokenText += _char;
+ scanChar(); // skip ]
+ break;
+
+ default:
+ _tokenText += _char;
+ scanChar();
+ } // switch
+ } // while
+
+ return false;
+}
+
+bool Lexer::isLineTerminator() const
+{
+ return (_char == QLatin1Char('\n') || _char == QLatin1Char('\r'));
+}
+
+bool Lexer::isIdentLetter(QChar ch)
+{
+ // ASCII-biased, since all reserved words are ASCII, aand hence the
+ // bulk of content to be parsed.
+ if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z'))
+ || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z'))
+ || ch == QLatin1Char('$')
+ || ch == QLatin1Char('_'))
+ return true;
+ if (ch.unicode() < 128)
+ return false;
+ return ch.isLetterOrNumber();
+}
+
+bool Lexer::isDecimalDigit(ushort c)
+{
+ return (c >= '0' && c <= '9');
+}
+
+bool Lexer::isHexDigit(QChar c)
+{
+ return ((c >= QLatin1Char('0') && c <= QLatin1Char('9'))
+ || (c >= QLatin1Char('a') && c <= QLatin1Char('f'))
+ || (c >= QLatin1Char('A') && c <= QLatin1Char('F')));
+}
+
+bool Lexer::isOctalDigit(ushort c)
+{
+ return (c >= '0' && c <= '7');
+}
+
+int Lexer::tokenKind() const
+{
+ return _tokenKind;
+}
+
+int Lexer::tokenOffset() const
+{
+ return _tokenStartPtr - _code.unicode();
+}
+
+int Lexer::tokenLength() const
+{
+ return _tokenLength;
+}
+
+int Lexer::tokenStartLine() const
+{
+ return _tokenLine;
+}
+
+int Lexer::tokenStartColumn() const
+{
+ return _tokenStartPtr - _tokenLinePtr + 1;
+}
+
+int Lexer::tokenEndLine() const
+{
+ return _currentLineNumber;
+}
+
+int Lexer::tokenEndColumn() const
+{
+ return _codePtr - _lastLinePtr;
+}
+
+QStringRef Lexer::tokenSpell() const
+{
+ return _tokenSpell;
+}
+
+double Lexer::tokenValue() const
+{
+ return _tokenValue;
+}
+
+QString Lexer::tokenText() const
+{
+ if (_validTokenText)
+ return _tokenText;
+
+ if (_tokenKind == T_STRING_LITERAL)
+ return QString(_tokenStartPtr + 1, _tokenLength - 2);
+
+ return QString(_tokenStartPtr, _tokenLength);
+}
+
+Lexer::Error Lexer::errorCode() const
+{
+ return _errorCode;
+}
+
+QString Lexer::errorMessage() const
+{
+ return _errorMessage;
+}
+
+void Lexer::syncProhibitAutomaticSemicolon()
+{
+ if (_parenthesesState == BalancedParentheses) {
+ // we have seen something like "if (foo)", which means we should
+ // never insert an automatic semicolon at this point, since it would
+ // then be expanded into an empty statement (ECMA-262 7.9.1)
+ _prohibitAutomaticSemicolon = true;
+ _parenthesesState = IgnoreParentheses;
+ } else {
+ _prohibitAutomaticSemicolon = false;
+ }
+}
+
+bool Lexer::prevTerminator() const
+{
+ return _terminator;
+}
+
+bool Lexer::followsClosingBrace() const
+{
+ return _followsClosingBrace;
+}
+
+bool Lexer::canInsertAutomaticSemicolon(int token) const
+{
+ return token == T_RBRACE
+ || token == EOF_SYMBOL
+ || _terminator
+ || _followsClosingBrace;
+}
+
+bool Lexer::scanDirectives(Directives *directives)
+{
+ if (_qmlMode) {
+ // the directives are a Javascript-only extension.
+ return false;
+ }
+
+ lex(); // fetch the first token
+
+ if (_tokenKind != T_DOT)
+ return true;
+
+ do {
+ lex(); // skip T_DOT
+
+ const int lineNumber = tokenStartLine();
+
+ if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD))
+ return false; // expected a valid QML/JS directive
+
+ const QString directiveName = tokenText();
+
+ if (! (directiveName == QLatin1String("pragma") ||
+ directiveName == QLatin1String("import")))
+ return false; // not a valid directive name
+
+ // it must be a pragma or an import directive.
+ if (directiveName == QLatin1String("pragma")) {
+ // .pragma library
+ if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library")))
+ return false; // expected `library
+
+ // we found a .pragma library directive
+ directives->pragmaLibrary();
+
+ } else {
+ Q_ASSERT(directiveName == QLatin1String("import"));
+ lex(); // skip .import
+
+ QString pathOrUri;
+ QString version;
+ bool fileImport = false; // file or uri import
+
+ if (_tokenKind == T_STRING_LITERAL) {
+ // .import T_STRING_LITERAL as T_IDENTIFIER
+
+ fileImport = true;
+ pathOrUri = tokenText();
+
+ } else if (_tokenKind == T_IDENTIFIER) {
+ // .import T_IDENTIFIER (. T_IDENTIFIER)* T_NUMERIC_LITERAL as T_IDENTIFIER
+
+ pathOrUri = tokenText();
+
+ lex(); // skip the first T_IDENTIFIER
+ for (; _tokenKind == T_DOT; lex()) {
+ if (lex() != T_IDENTIFIER)
+ return false;
+
+ pathOrUri += QLatin1Char('.');
+ pathOrUri += tokenText();
+ }
+
+ if (_tokenKind != T_NUMERIC_LITERAL)
+ return false; // expected the module version number
+
+ version = tokenText();
+ }
+
+ //
+ // recognize the mandatory `as' followed by the module name
+ //
+ if (! (lex() == T_RESERVED_WORD && tokenText() == QLatin1String("as")))
+ return false; // expected `as'
+
+ if (lex() != T_IDENTIFIER)
+ return false; // expected module name
+
+ const QString module = tokenText();
+
+ if (fileImport)
+ directives->importFile(pathOrUri, module);
+ else
+ directives->importModule(pathOrUri, version, module);
+ }
+
+ if (tokenStartLine() != lineNumber)
+ return false; // the directives cannot span over multiple lines
+
+ // fetch the first token after the .pragma/.import directive
+ lex();
+ } while (_tokenKind == T_DOT);
+
+ return true;
+}
+
+#include "qqmljskeywords_p.h"
diff --git a/src/qml/qml/parser/qqmljslexer_p.h b/src/qml/qml/parser/qqmljslexer_p.h
new file mode 100644
index 0000000000..6b51852f5f
--- /dev/null
+++ b/src/qml/qml/parser/qqmljslexer_p.h
@@ -0,0 +1,248 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLJSLEXER_P_H
+#define QQMLJSLEXER_P_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 "qqmljsglobal_p.h"
+#include "qqmljsgrammar_p.h"
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+class Engine;
+
+class QML_PARSER_EXPORT Directives {
+public:
+ virtual ~Directives() {}
+
+ virtual void pragmaLibrary()
+ {
+ }
+
+ virtual void importFile(const QString &jsfile, const QString &module)
+ {
+ Q_UNUSED(jsfile);
+ Q_UNUSED(module);
+ }
+
+ virtual void importModule(const QString &uri, const QString &version, const QString &module)
+ {
+ Q_UNUSED(uri);
+ Q_UNUSED(version);
+ Q_UNUSED(module);
+ }
+};
+
+class QML_PARSER_EXPORT Lexer: public QQmlJSGrammar
+{
+public:
+ enum {
+ T_ABSTRACT = T_RESERVED_WORD,
+ T_BOOLEAN = T_RESERVED_WORD,
+ T_BYTE = T_RESERVED_WORD,
+ T_CHAR = T_RESERVED_WORD,
+ T_CLASS = T_RESERVED_WORD,
+ T_DOUBLE = T_RESERVED_WORD,
+ T_ENUM = T_RESERVED_WORD,
+ T_EXPORT = T_RESERVED_WORD,
+ T_EXTENDS = T_RESERVED_WORD,
+ T_FINAL = T_RESERVED_WORD,
+ T_FLOAT = T_RESERVED_WORD,
+ T_GOTO = T_RESERVED_WORD,
+ T_IMPLEMENTS = T_RESERVED_WORD,
+ T_INT = T_RESERVED_WORD,
+ T_INTERFACE = T_RESERVED_WORD,
+ T_LET = T_RESERVED_WORD,
+ T_LONG = T_RESERVED_WORD,
+ T_NATIVE = T_RESERVED_WORD,
+ T_PACKAGE = T_RESERVED_WORD,
+ T_PRIVATE = T_RESERVED_WORD,
+ T_PROTECTED = T_RESERVED_WORD,
+ T_SHORT = T_RESERVED_WORD,
+ T_STATIC = T_RESERVED_WORD,
+ T_SUPER = T_RESERVED_WORD,
+ T_SYNCHRONIZED = T_RESERVED_WORD,
+ T_THROWS = T_RESERVED_WORD,
+ T_TRANSIENT = T_RESERVED_WORD,
+ T_VOLATILE = T_RESERVED_WORD,
+ T_YIELD = T_RESERVED_WORD
+ };
+
+ enum Error {
+ NoError,
+ IllegalCharacter,
+ UnclosedStringLiteral,
+ IllegalEscapeSequence,
+ IllegalUnicodeEscapeSequence,
+ UnclosedComment,
+ IllegalExponentIndicator,
+ IllegalIdentifier
+ };
+
+ enum RegExpBodyPrefix {
+ NoPrefix,
+ EqualPrefix
+ };
+
+ enum RegExpFlag {
+ RegExp_Global = 0x01,
+ RegExp_IgnoreCase = 0x02,
+ RegExp_Multiline = 0x04
+ };
+
+public:
+ Lexer(Engine *engine);
+
+ bool qmlMode() const;
+
+ QString code() const;
+ void setCode(const QString &code, int lineno, bool qmlMode = true);
+
+ int lex();
+
+ bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix);
+ bool scanDirectives(Directives *directives);
+
+ int regExpFlags() const { return _patternFlags; }
+ QString regExpPattern() const { return _tokenText; }
+
+ int tokenKind() const;
+ int tokenOffset() const;
+ int tokenLength() const;
+
+ int tokenStartLine() const;
+ int tokenStartColumn() const;
+
+ int tokenEndLine() const;
+ int tokenEndColumn() const;
+
+ QStringRef tokenSpell() const;
+ double tokenValue() const;
+ QString tokenText() const;
+
+ Error errorCode() const;
+ QString errorMessage() const;
+
+ bool prevTerminator() const;
+ bool followsClosingBrace() const;
+ bool canInsertAutomaticSemicolon(int token) const;
+
+ enum ParenthesesState {
+ IgnoreParentheses,
+ CountParentheses,
+ BalancedParentheses
+ };
+
+protected:
+ int classify(const QChar *s, int n, bool qmlMode);
+
+private:
+ inline void scanChar();
+ int scanToken();
+
+ bool isLineTerminator() const;
+ static bool isIdentLetter(QChar c);
+ static bool isDecimalDigit(ushort c);
+ static bool isHexDigit(QChar c);
+ static bool isOctalDigit(ushort c);
+ static bool isUnicodeEscapeSequence(const QChar *chars);
+
+ void syncProhibitAutomaticSemicolon();
+ QChar decodeUnicodeEscapeCharacter(bool *ok);
+
+private:
+ Engine *_engine;
+
+ QString _code;
+ QString _tokenText;
+ QString _errorMessage;
+ QStringRef _tokenSpell;
+
+ const QChar *_codePtr;
+ const QChar *_lastLinePtr;
+ const QChar *_tokenLinePtr;
+ const QChar *_tokenStartPtr;
+
+ QChar _char;
+ Error _errorCode;
+
+ int _currentLineNumber;
+ double _tokenValue;
+
+ // parentheses state
+ ParenthesesState _parenthesesState;
+ int _parenthesesCount;
+
+ int _stackToken;
+
+ int _patternFlags;
+ int _tokenKind;
+ int _tokenLength;
+ int _tokenLine;
+
+ bool _validTokenText;
+ bool _prohibitAutomaticSemicolon;
+ bool _restrictedKeyword;
+ bool _terminator;
+ bool _followsClosingBrace;
+ bool _delimited;
+ bool _qmlMode;
+};
+
+} // end of namespace QQmlJS
+
+QT_QML_END_NAMESPACE
+
+#endif // LEXER_H
diff --git a/src/qml/qml/parser/qqmljsmemorypool_p.h b/src/qml/qml/parser/qqmljsmemorypool_p.h
new file mode 100644
index 0000000000..fd52fd25e4
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsmemorypool_p.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLJSMEMORYPOOL_P_H
+#define QQMLJSMEMORYPOOL_P_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 "qqmljsglobal_p.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qshareddata.h>
+#include <QtCore/qdebug.h>
+
+#include <cstring>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+class QML_PARSER_EXPORT MemoryPool : public QSharedData
+{
+ MemoryPool(const MemoryPool &other);
+ void operator =(const MemoryPool &other);
+
+public:
+ MemoryPool()
+ : _blocks(0),
+ _allocatedBlocks(0),
+ _blockCount(-1),
+ _ptr(0),
+ _end(0)
+ { }
+
+ ~MemoryPool()
+ {
+ if (_blocks) {
+ for (int i = 0; i < _allocatedBlocks; ++i) {
+ if (char *b = _blocks[i])
+ qFree(b);
+ }
+
+ qFree(_blocks);
+ }
+ }
+
+ inline void *allocate(size_t size)
+ {
+ size = (size + 7) & ~7;
+ if (_ptr && (_ptr + size < _end)) {
+ void *addr = _ptr;
+ _ptr += size;
+ return addr;
+ }
+ return allocate_helper(size);
+ }
+
+ void reset()
+ {
+ _blockCount = -1;
+ _ptr = _end = 0;
+ }
+
+private:
+ void *allocate_helper(size_t size)
+ {
+ Q_ASSERT(size < BLOCK_SIZE);
+
+ if (++_blockCount == _allocatedBlocks) {
+ if (! _allocatedBlocks)
+ _allocatedBlocks = DEFAULT_BLOCK_COUNT;
+ else
+ _allocatedBlocks *= 2;
+
+ _blocks = (char **) qRealloc(_blocks, sizeof(char *) * _allocatedBlocks);
+
+ for (int index = _blockCount; index < _allocatedBlocks; ++index)
+ _blocks[index] = 0;
+ }
+
+ char *&block = _blocks[_blockCount];
+
+ if (! block)
+ block = (char *) qMalloc(BLOCK_SIZE);
+
+ _ptr = block;
+ _end = _ptr + BLOCK_SIZE;
+
+ void *addr = _ptr;
+ _ptr += size;
+ return addr;
+ }
+
+private:
+ char **_blocks;
+ int _allocatedBlocks;
+ int _blockCount;
+ char *_ptr;
+ char *_end;
+
+ enum
+ {
+ BLOCK_SIZE = 8 * 1024,
+ DEFAULT_BLOCK_COUNT = 8
+ };
+};
+
+class QML_PARSER_EXPORT Managed
+{
+ Managed(const Managed &other);
+ void operator = (const Managed &other);
+
+public:
+ Managed() {}
+ ~Managed() {}
+
+ void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); }
+ void operator delete(void *) {}
+ void operator delete(void *, MemoryPool *) {}
+};
+
+} // namespace QQmlJS
+
+QT_QML_END_NAMESPACE
+
+#endif
diff --git a/src/qml/qml/parser/qqmljsparser.cpp b/src/qml/qml/parser/qqmljsparser.cpp
new file mode 100644
index 0000000000..bc89b2ac84
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsparser.cpp
@@ -0,0 +1,1812 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtDebug>
+#include <QtCore/QCoreApplication>
+
+#include <string.h>
+
+#include "qqmljsengine_p.h"
+#include "qqmljslexer_p.h"
+#include "qqmljsast_p.h"
+#include "qqmljsmemorypool_p.h"
+
+
+
+#include "qqmljsparser_p.h"
+#include <QVarLengthArray>
+
+//
+// This file is automatically generated from qmljs.g.
+// Changes will be lost.
+//
+
+using namespace QQmlJS;
+
+QT_QML_BEGIN_NAMESPACE
+
+void Parser::reallocateStack()
+{
+ if (! stack_size)
+ stack_size = 128;
+ else
+ stack_size <<= 1;
+
+ sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
+ state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
+ location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
+ string_stack = reinterpret_cast<QStringRef*> (realloc(string_stack, stack_size * sizeof(QStringRef)));
+}
+
+Parser::Parser(Engine *engine):
+ driver(engine),
+ pool(engine->pool()),
+ tos(0),
+ stack_size(0),
+ sym_stack(0),
+ state_stack(0),
+ location_stack(0),
+ string_stack(0),
+ first_token(0),
+ last_token(0)
+{
+}
+
+Parser::~Parser()
+{
+ if (stack_size) {
+ free(sym_stack);
+ free(state_stack);
+ free(location_stack);
+ free(string_stack);
+ }
+}
+
+static inline AST::SourceLocation location(Lexer *lexer)
+{
+ AST::SourceLocation loc;
+ loc.offset = lexer->tokenOffset();
+ loc.length = lexer->tokenLength();
+ loc.startLine = lexer->tokenStartLine();
+ loc.startColumn = lexer->tokenStartColumn();
+ return loc;
+}
+
+AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
+{
+ QVarLengthArray<QStringRef, 4> nameIds;
+ QVarLengthArray<AST::SourceLocation, 4> locations;
+
+ AST::ExpressionNode *it = expr;
+ while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
+ nameIds.append(m->name);
+ locations.append(m->identifierToken);
+ it = m->base;
+ }
+
+ if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
+ AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name);
+ q->identifierToken = idExpr->identifierToken;
+
+ AST::UiQualifiedId *currentId = q;
+ for (int i = nameIds.size() - 1; i != -1; --i) {
+ currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]);
+ currentId->identifierToken = locations[i];
+ }
+
+ return currentId->finish();
+ }
+
+ return 0;
+}
+
+bool Parser::parse(int startToken)
+{
+ Lexer *lexer = driver->lexer();
+ bool hadErrors = false;
+ int yytoken = -1;
+ int action = 0;
+
+ token_buffer[0].token = startToken;
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
+
+ tos = -1;
+ program = 0;
+
+ do {
+ if (++tos == stack_size)
+ reallocateStack();
+
+ state_stack[tos] = action;
+
+ _Lcheck_token:
+ if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
+ yyprevlloc = yylloc;
+
+ if (first_token == last_token) {
+ yytoken = lexer->lex();
+ yylval = lexer->tokenValue();
+ yytokenspell = lexer->tokenSpell();
+ yylloc = location(lexer);
+ } else {
+ yytoken = first_token->token;
+ yylval = first_token->dval;
+ yytokenspell = first_token->spell;
+ yylloc = first_token->loc;
+ ++first_token;
+ }
+ }
+
+ action = t_action(action, yytoken);
+ if (action > 0) {
+ if (action != ACCEPT_STATE) {
+ yytoken = -1;
+ sym(1).dval = yylval;
+ stringRef(1) = yytokenspell;
+ loc(1) = yylloc;
+ } else {
+ --tos;
+ return ! hadErrors;
+ }
+ } else if (action < 0) {
+ const int r = -action - 1;
+ tos -= rhs[r];
+
+ switch (r) {
+
+case 0: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 1: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 2: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 3: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 4: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 5: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+
+case 6: {
+ sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList,
+ sym(2).UiObjectMemberList->finish());
+} break;
+
+case 8: {
+ sym(1).Node = sym(1).UiImportList->finish();
+} break;
+
+case 9: {
+ sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport);
+} break;
+
+case 10: {
+ sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport);
+} break;
+
+case 13: {
+ sym(1).UiImport->semicolonToken = loc(2);
+} break;
+
+case 15: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->semicolonToken = loc(3);
+} break;
+
+case 17: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->asToken = loc(3);
+ sym(1).UiImport->importIdToken = loc(4);
+ sym(1).UiImport->importId = stringRef(4);
+ sym(1).UiImport->semicolonToken = loc(5);
+} break;
+
+case 19: {
+ sym(1).UiImport->asToken = loc(2);
+ sym(1).UiImport->importIdToken = loc(3);
+ sym(1).UiImport->importId = stringRef(3);
+ sym(1).UiImport->semicolonToken = loc(4);
+} break;
+
+case 20: {
+ AST::UiImport *node = 0;
+
+ if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
+ node = new (pool) AST::UiImport(importIdLiteral->value);
+ node->fileNameToken = loc(2);
+ } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
+ node = new (pool) AST::UiImport(qualifiedId);
+ node->fileNameToken = loc(2);
+ }
+
+ sym(1).Node = node;
+
+ if (node) {
+ node->importToken = loc(1);
+ } else {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id or a string literal")));
+
+ return false; // ### remove me
+ }
+} break;
+
+case 21: {
+ sym(1).Node = 0;
+} break;
+
+case 22: {
+ sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
+} break;
+
+case 23: {
+ sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
+} break;
+
+case 24: {
+ AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList(
+ sym(1).UiObjectMemberList, sym(2).UiObjectMember);
+ sym(1).Node = node;
+} break;
+
+case 25: {
+ sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember);
+} break;
+
+case 26: {
+ AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList(
+ sym(1).UiArrayMemberList, sym(3).UiObjectMember);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 27: {
+ AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 28: {
+ AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 29: {
+ AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId,
+ sym(2).UiObjectInitializer);
+ sym(1).Node = node;
+} break;
+
+case 31: {
+ AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding(
+ sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
+ node->colonToken = loc(2);
+ node->lbracketToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 32: {
+ AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
+ sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 33: {
+ AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
+ sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ node->hasOnToken = true;
+ sym(1).Node = node;
+} break;
+
+case 41:
+{
+ AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding(
+ sym(1).UiQualifiedId, sym(3).Statement);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 45: {
+ sym(1).Node = 0;
+} break;
+
+case 46: {
+ sym(1).Node = sym(1).UiParameterList->finish ();
+} break;
+
+case 47: {
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2));
+ node->propertyTypeToken = loc(1);
+ node->identifierToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 48: {
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
+ node->commaToken = loc(2);
+ node->identifierToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 50: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->parameters = sym(4).UiParameterList;
+ node->semicolonToken = loc(6);
+ sym(1).Node = node;
+} break;
+
+case 52: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 54: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
+ node->typeModifier = stringRef(2);
+ node->propertyToken = loc(1);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+
+case 56: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->semicolonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 58: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4));
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->semicolonToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 59: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3),
+ sym(5).Statement);
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 60: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
+ sym(6).Statement);
+ node->isReadonlyMember = true;
+ node->readonlyToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 61: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
+ sym(6).Statement);
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 62: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
+ node->typeModifier = stringRef(2);
+ node->propertyToken = loc(1);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->semicolonToken = loc(7); // insert a fake ';' before ':'
+
+ AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6));
+ propertyName->identifierToken = loc(6);
+ propertyName->next = 0;
+
+ AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(
+ propertyName, sym(9).UiArrayMemberList->finish());
+ binding->colonToken = loc(7);
+ binding->lbracketToken = loc(8);
+ binding->rbracketToken = loc(10);
+
+ node->binding = binding;
+
+ sym(1).Node = node;
+} break;
+
+case 63: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->semicolonToken = loc(4); // insert a fake ';' before ':'
+
+ AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3));
+ propertyName->identifierToken = loc(3);
+ propertyName->next = 0;
+
+ AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
+ propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer);
+ binding->colonToken = loc(4);
+
+ node->binding = binding;
+
+ sym(1).Node = node;
+} break;
+
+case 64: {
+ sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
+} break;
+
+case 65: {
+ sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
+} break;
+
+case 71: {
+ AST::ThisExpression *node = new (pool) AST::ThisExpression();
+ node->thisToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 72: {
+ AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 73: {
+ AST::NullExpression *node = new (pool) AST::NullExpression();
+ node->nullToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 74: {
+ AST::TrueLiteral *node = new (pool) AST::TrueLiteral();
+ node->trueToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 75: {
+ AST::FalseLiteral *node = new (pool) AST::FalseLiteral();
+ node->falseToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 76: {
+ AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+case 77:
+case 78: {
+ AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1));
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 79: {
+ bool rx = lexer->scanRegExp(Lexer::NoPrefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false; // ### remove me
+ }
+
+ loc(1).length = lexer->tokenLength();
+ yylloc = loc(1); // adjust the location of the current token
+
+ AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
+ driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 80: {
+ bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false;
+ }
+
+ loc(1).length = lexer->tokenLength();
+ yylloc = loc(1); // adjust the location of the current token
+
+ AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
+ driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 81: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0);
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 82: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 83: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 84: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
+ (AST::Elision *) 0);
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 85: {
+ AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
+ sym(4).Elision->finish());
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 86: {
+ AST::ObjectLiteral *node = 0;
+ if (sym(2).Node)
+ node = new (pool) AST::ObjectLiteral(
+ sym(2).PropertyNameAndValueList->finish ());
+ else
+ node = new (pool) AST::ObjectLiteral();
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 87: {
+ AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
+ sym(2).PropertyNameAndValueList->finish ());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 88: {
+ AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression);
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 89: {
+ if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
+ QLatin1String("Ignored annotation")));
+
+ sym(1).Expression = mem->base;
+ }
+
+ if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
+ sym(1).UiQualifiedId = qualifiedId;
+ } else {
+ sym(1).UiQualifiedId = 0;
+
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id")));
+
+ return false; // ### recover
+ }
+} break;
+
+case 90: {
+ sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression);
+} break;
+
+case 91: {
+ sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression);
+} break;
+
+case 92: {
+ AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList,
+ (AST::Elision *) 0, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 93: {
+ AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(),
+ sym(4).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 94: {
+ AST::Elision *node = new (pool) AST::Elision();
+ node->commaToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 95: {
+ AST::Elision *node = new (pool) AST::Elision(sym(1).Elision);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 96: {
+ AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
+ sym(1).PropertyName, sym(3).Expression);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 97: {
+ AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList(
+ sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
+ node->commaToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 98: {
+ AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+case 99:
+case 100: {
+ AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 101: {
+ AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 102: {
+ AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 103: {
+ AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 139: {
+ AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 140: {
+ AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 141: {
+ AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList);
+ node->newToken = loc(1);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 143: {
+ AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression);
+ node->newToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 144: {
+ AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 145: {
+ AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 146: {
+ AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 147: {
+ AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 148: {
+ sym(1).Node = 0;
+} break;
+
+case 149: {
+ sym(1).Node = sym(1).ArgumentList->finish();
+} break;
+
+case 150: {
+ sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression);
+} break;
+
+case 151: {
+ AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 155: {
+ AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression);
+ node->incrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 156: {
+ AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression);
+ node->decrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 158: {
+ AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression);
+ node->deleteToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 159: {
+ AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression);
+ node->voidToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 160: {
+ AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression);
+ node->typeofToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 161: {
+ AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression);
+ node->incrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 162: {
+ AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression);
+ node->decrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 163: {
+ AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression);
+ node->plusToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 164: {
+ AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression);
+ node->minusToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 165: {
+ AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression);
+ node->tildeToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 166: {
+ AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression);
+ node->notToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 168: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Mul, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 169: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Div, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 170: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Mod, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 172: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Add, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 173: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Sub, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 175: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::LShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 176: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::RShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 177: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::URShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 179: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Lt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 180: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Gt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 181: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Le, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 182: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Ge, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 183: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::InstanceOf, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 184: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::In, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 186: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Lt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 187: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Gt, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 188: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Le, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 189: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Ge, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 190: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::InstanceOf, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 192: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Equal, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 193: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::NotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 194: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::StrictEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 195: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::StrictNotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 197: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Equal, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 198: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::NotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 199: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::StrictEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 200: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::StrictNotEqual, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 202: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 204: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 206: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 208: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 210: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 212: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 214: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 216: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 218: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 220: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 222: {
+ AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
+ sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 224: {
+ AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
+ sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 226: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 228: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 229: {
+ sym(1).ival = QSOperator::Assign;
+} break;
+
+case 230: {
+ sym(1).ival = QSOperator::InplaceMul;
+} break;
+
+case 231: {
+ sym(1).ival = QSOperator::InplaceDiv;
+} break;
+
+case 232: {
+ sym(1).ival = QSOperator::InplaceMod;
+} break;
+
+case 233: {
+ sym(1).ival = QSOperator::InplaceAdd;
+} break;
+
+case 234: {
+ sym(1).ival = QSOperator::InplaceSub;
+} break;
+
+case 235: {
+ sym(1).ival = QSOperator::InplaceLeftShift;
+} break;
+
+case 236: {
+ sym(1).ival = QSOperator::InplaceRightShift;
+} break;
+
+case 237: {
+ sym(1).ival = QSOperator::InplaceURightShift;
+} break;
+
+case 238: {
+ sym(1).ival = QSOperator::InplaceAnd;
+} break;
+
+case 239: {
+ sym(1).ival = QSOperator::InplaceXor;
+} break;
+
+case 240: {
+ sym(1).ival = QSOperator::InplaceOr;
+} break;
+
+case 242: {
+ AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 243: {
+ sym(1).Node = 0;
+} break;
+
+case 246: {
+ AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 247: {
+ sym(1).Node = 0;
+} break;
+
+case 264: {
+ AST::Block *node = new (pool) AST::Block(sym(2).StatementList);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 265: {
+ sym(1).Node = new (pool) AST::StatementList(sym(1).Statement);
+} break;
+
+case 266: {
+ sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement);
+} break;
+
+case 267: {
+ sym(1).Node = 0;
+} break;
+
+case 268: {
+ sym(1).Node = sym(1).StatementList->finish ();
+} break;
+
+case 270: {
+ AST::VariableStatement *node = new (pool) AST::VariableStatement(
+ sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
+ node->declarationKindToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 271: {
+ sym(1).ival = T_CONST;
+} break;
+
+case 272: {
+ sym(1).ival = T_VAR;
+} break;
+
+case 273: {
+ sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
+} break;
+
+case 274: {
+ AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList(
+ sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 275: {
+ sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
+} break;
+
+case 276: {
+ sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+} break;
+
+case 277: {
+ AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 278: {
+ AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 279: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+
+case 280: {
+ sym(1).Node = 0;
+} break;
+
+case 282: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+
+case 283: {
+ sym(1).Node = 0;
+} break;
+
+case 285: {
+ AST::EmptyStatement *node = new (pool) AST::EmptyStatement();
+ node->semicolonToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 287: {
+ AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 288: {
+ AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->elseToken = loc(6);
+ sym(1).Node = node;
+} break;
+
+case 289: {
+ AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 291: {
+ AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
+ node->doToken = loc(1);
+ node->whileToken = loc(3);
+ node->lparenToken = loc(4);
+ node->rparenToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+} break;
+
+case 292: {
+ AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
+ node->whileToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 293: {
+ AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression,
+ sym(5).Expression, sym(7).Expression, sym(9).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->firstSemicolonToken = loc(4);
+ node->secondSemicolonToken = loc(6);
+ node->rparenToken = loc(8);
+ sym(1).Node = node;
+} break;
+
+case 294: {
+ AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
+ sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
+ sym(8).Expression, sym(10).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->varToken = loc(3);
+ node->firstSemicolonToken = loc(5);
+ node->secondSemicolonToken = loc(7);
+ node->rparenToken = loc(9);
+ sym(1).Node = node;
+} break;
+
+case 295: {
+ AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression,
+ sym(5).Expression, sym(7).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->inToken = loc(4);
+ node->rparenToken = loc(6);
+ sym(1).Node = node;
+} break;
+
+case 296: {
+ AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement(
+ sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->varToken = loc(3);
+ node->inToken = loc(5);
+ node->rparenToken = loc(7);
+ sym(1).Node = node;
+} break;
+
+case 298: {
+ AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
+ node->continueToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 300: {
+ AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
+ node->continueToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 302: {
+ AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
+ node->breakToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 304: {
+ AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
+ node->breakToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 306: {
+ AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
+ node->returnToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 307: {
+ AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
+ node->withToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 308: {
+ AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
+ node->switchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 309: {
+ AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 310: {
+ AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(5);
+ sym(1).Node = node;
+} break;
+
+case 311: {
+ sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
+} break;
+
+case 312: {
+ sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
+} break;
+
+case 313: {
+ sym(1).Node = 0;
+} break;
+
+case 314: {
+ sym(1).Node = sym(1).CaseClauses->finish ();
+} break;
+
+case 315: {
+ AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
+ node->caseToken = loc(1);
+ node->colonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 316: {
+ AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
+ node->defaultToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+case 317:
+case 318: {
+ AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 319: {
+ AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 321: {
+ AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
+ node->throwToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 322: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 323: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 324: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 325: {
+ AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
+ node->catchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->identifierToken = loc(3);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+} break;
+
+case 326: {
+ AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
+ node->finallyToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 328: {
+ AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
+ node->debuggerToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 329: {
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
+ node->functionToken = loc(1);
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+} break;
+
+case 330: {
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
+ node->functionToken = loc(1);
+ if (! stringRef(2).isNull())
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+} break;
+
+case 331: {
+ AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 332: {
+ AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3));
+ node->commaToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+
+case 333: {
+ sym(1).Node = 0;
+} break;
+
+case 334: {
+ sym(1).Node = sym(1).FormalParameterList->finish ();
+} break;
+
+case 335: {
+ sym(1).Node = 0;
+} break;
+
+case 337: {
+ sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ());
+} break;
+
+case 339: {
+ sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ());
+} break;
+
+case 340: {
+ sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement);
+} break;
+
+case 341: {
+ sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement);
+} break;
+
+case 342: {
+ sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement);
+} break;
+
+case 343: {
+ sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration);
+} break;
+
+case 344: {
+ stringRef(1) = QStringRef();
+} break;
+
+case 346: {
+ sym(1).Node = 0;
+} break;
+
+ } // switch
+ action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
+ } // if
+ } while (action != 0);
+
+ if (first_token == last_token) {
+ const int errorState = state_stack[tos];
+
+ // automatic insertion of `;'
+ if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) {
+ SavedToken &tk = token_buffer[0];
+ tk.token = yytoken;
+ tk.dval = yylval;
+ tk.spell = yytokenspell;
+ tk.loc = yylloc;
+
+ yylloc = yyprevlloc;
+ yylloc.offset += yylloc.length;
+ yylloc.startColumn += yylloc.length;
+ yylloc.length = 0;
+
+ //const QString msg = qApp->translate("QQmlParser", "Missing `;'");
+ //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
+
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
+
+ yytoken = T_SEMICOLON;
+ yylval = 0;
+
+ action = errorState;
+
+ goto _Lcheck_token;
+ }
+
+ hadErrors = true;
+
+ token_buffer[0].token = yytoken;
+ token_buffer[0].dval = yylval;
+ token_buffer[0].spell = yytokenspell;
+ token_buffer[0].loc = yylloc;
+
+ token_buffer[1].token = yytoken = lexer->lex();
+ token_buffer[1].dval = yylval = lexer->tokenValue();
+ token_buffer[1].spell = yytokenspell = lexer->tokenSpell();
+ token_buffer[1].loc = yylloc = location(lexer);
+
+ if (t_action(errorState, yytoken)) {
+ QString msg;
+ int token = token_buffer[0].token;
+ if (token < 0 || token >= TERMINAL_COUNT)
+ msg = qApp->translate("QQmlParser", "Syntax error");
+ else
+ msg = qApp->translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+
+ static int tokens[] = {
+ T_PLUS,
+ T_EQ,
+
+ T_COMMA,
+ T_COLON,
+ T_SEMICOLON,
+
+ T_RPAREN, T_RBRACKET, T_RBRACE,
+
+ T_NUMERIC_LITERAL,
+ T_IDENTIFIER,
+
+ T_LPAREN, T_LBRACKET, T_LBRACE,
+
+ EOF_SYMBOL
+ };
+
+ for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
+ int a = t_action(errorState, *tk);
+ if (a > 0 && t_action(a, yytoken)) {
+ const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ yytoken = *tk;
+ yylval = 0;
+ yylloc = token_buffer[0].loc;
+ yylloc.length = 0;
+
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[2];
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+ }
+
+ for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
+ if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
+ tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
+ tk == T_FEED_JS_SOURCE_ELEMENT)
+ continue;
+
+ int a = t_action(errorState, tk);
+ if (a > 0 && t_action(a, yytoken)) {
+ const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+
+ yytoken = tk;
+ yylval = 0;
+ yylloc = token_buffer[0].loc;
+ yylloc.length = 0;
+
+ action = errorState;
+ goto _Lcheck_token;
+ }
+ }
+
+ const QString msg = qApp->translate("QQmlParser", "Syntax error");
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
+ }
+
+ return false;
+}
+
+QT_QML_END_NAMESPACE
+
+
diff --git a/src/qml/qml/parser/qqmljsparser_p.h b/src/qml/qml/parser/qqmljsparser_p.h
new file mode 100644
index 0000000000..ad532c32c7
--- /dev/null
+++ b/src/qml/qml/parser/qqmljsparser_p.h
@@ -0,0 +1,248 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+//
+// 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.
+//
+
+//
+// This file is automatically generated from qmljs.g.
+// Changes will be lost.
+//
+
+#ifndef QQMLJSPARSER_P_H
+#define QQMLJSPARSER_P_H
+
+#include "qqmljsglobal_p.h"
+#include "qqmljsgrammar_p.h"
+#include "qqmljsast_p.h"
+#include "qqmljsengine_p.h"
+
+#include <QtCore/QList>
+#include <QtCore/QString>
+
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+class Engine;
+
+class QML_PARSER_EXPORT Parser: protected QQmlJSGrammar
+{
+public:
+ union Value {
+ int ival;
+ double dval;
+ AST::ArgumentList *ArgumentList;
+ AST::CaseBlock *CaseBlock;
+ AST::CaseClause *CaseClause;
+ AST::CaseClauses *CaseClauses;
+ AST::Catch *Catch;
+ AST::DefaultClause *DefaultClause;
+ AST::ElementList *ElementList;
+ AST::Elision *Elision;
+ AST::ExpressionNode *Expression;
+ AST::Finally *Finally;
+ AST::FormalParameterList *FormalParameterList;
+ AST::FunctionBody *FunctionBody;
+ AST::FunctionDeclaration *FunctionDeclaration;
+ AST::Node *Node;
+ AST::PropertyName *PropertyName;
+ AST::PropertyNameAndValueList *PropertyNameAndValueList;
+ AST::SourceElement *SourceElement;
+ AST::SourceElements *SourceElements;
+ AST::Statement *Statement;
+ AST::StatementList *StatementList;
+ AST::Block *Block;
+ AST::VariableDeclaration *VariableDeclaration;
+ AST::VariableDeclarationList *VariableDeclarationList;
+
+ AST::UiProgram *UiProgram;
+ AST::UiImportList *UiImportList;
+ AST::UiImport *UiImport;
+ AST::UiParameterList *UiParameterList;
+ AST::UiPublicMember *UiPublicMember;
+ AST::UiObjectDefinition *UiObjectDefinition;
+ AST::UiObjectInitializer *UiObjectInitializer;
+ AST::UiObjectBinding *UiObjectBinding;
+ AST::UiScriptBinding *UiScriptBinding;
+ AST::UiArrayBinding *UiArrayBinding;
+ AST::UiObjectMember *UiObjectMember;
+ AST::UiObjectMemberList *UiObjectMemberList;
+ AST::UiArrayMemberList *UiArrayMemberList;
+ AST::UiQualifiedId *UiQualifiedId;
+ };
+
+public:
+ Parser(Engine *engine);
+ ~Parser();
+
+ // parse a UI program
+ bool parse() { return parse(T_FEED_UI_PROGRAM); }
+ bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
+ bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
+ bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
+ bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
+ bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
+
+ AST::UiProgram *ast() const
+ { return AST::cast<AST::UiProgram *>(program); }
+
+ AST::Statement *statement() const
+ {
+ if (! program)
+ return 0;
+
+ return program->statementCast();
+ }
+
+ AST::ExpressionNode *expression() const
+ {
+ if (! program)
+ return 0;
+
+ return program->expressionCast();
+ }
+
+ AST::UiObjectMember *uiObjectMember() const
+ {
+ if (! program)
+ return 0;
+
+ return program->uiObjectMemberCast();
+ }
+
+ AST::Node *rootNode() const
+ { return program; }
+
+ QList<DiagnosticMessage> diagnosticMessages() const
+ { return diagnostic_messages; }
+
+ inline DiagnosticMessage diagnosticMessage() const
+ {
+ foreach (const DiagnosticMessage &d, diagnostic_messages) {
+ if (! d.kind == DiagnosticMessage::Warning)
+ return d;
+ }
+
+ return DiagnosticMessage();
+ }
+
+ inline QString errorMessage() const
+ { return diagnosticMessage().message; }
+
+ inline int errorLineNumber() const
+ { return diagnosticMessage().loc.startLine; }
+
+ inline int errorColumnNumber() const
+ { return diagnosticMessage().loc.startColumn; }
+
+protected:
+ bool parse(int startToken);
+
+ void reallocateStack();
+
+ inline Value &sym(int index)
+ { return sym_stack [tos + index - 1]; }
+
+ inline QStringRef &stringRef(int index)
+ { return string_stack [tos + index - 1]; }
+
+ inline AST::SourceLocation &loc(int index)
+ { return location_stack [tos + index - 1]; }
+
+ AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
+
+protected:
+ Engine *driver;
+ MemoryPool *pool;
+ int tos;
+ int stack_size;
+ Value *sym_stack;
+ int *state_stack;
+ AST::SourceLocation *location_stack;
+ QStringRef *string_stack;
+
+ AST::Node *program;
+
+ // error recovery
+ enum { TOKEN_BUFFER_SIZE = 3 };
+
+ struct SavedToken {
+ int token;
+ double dval;
+ AST::SourceLocation loc;
+ QStringRef spell;
+ };
+
+ double yylval;
+ QStringRef yytokenspell;
+ AST::SourceLocation yylloc;
+ AST::SourceLocation yyprevlloc;
+
+ SavedToken token_buffer[TOKEN_BUFFER_SIZE];
+ SavedToken *first_token;
+ SavedToken *last_token;
+
+ QList<DiagnosticMessage> diagnostic_messages;
+};
+
+} // end of namespace QQmlJS
+
+
+
+#define J_SCRIPT_REGEXPLITERAL_RULE1 79
+
+#define J_SCRIPT_REGEXPLITERAL_RULE2 80
+
+QT_QML_END_NAMESPACE
+
+
+
+#endif // QQMLJSPARSER_P_H
diff --git a/src/qml/qml/qlistmodelinterface.cpp b/src/qml/qml/qlistmodelinterface.cpp
new file mode 100644
index 0000000000..3ea0d3f155
--- /dev/null
+++ b/src/qml/qml/qlistmodelinterface.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtDeclaractive module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlistmodelinterface_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+ \class QListModelInterface
+ \brief The QListModelInterface class can be subclassed to provide C++ models to QQuickGraphics Views
+
+ This class is comprised primarily of pure virtual functions which
+ you must implement in a subclass. You can then use the subclass
+ as a model for a QQuickGraphics view, such as a QQuickListView.
+*/
+
+/*! \fn QListModelInterface::QListModelInterface(QObject *parent)
+ Constructs a QListModelInterface with the specified \a parent.
+*/
+
+ /*! \fn QListModelInterface::QListModelInterface(QObjectPrivate &dd, QObject *parent)
+
+ \internal
+ */
+
+/*! \fn QListModelInterface::~QListModelInterface()
+ The destructor is virtual.
+ */
+
+/*! \fn int QListModelInterface::count() const
+ Returns the number of data entries in the model.
+*/
+
+/*! \fn QVariant QListModelInterface::data(int index, int role) const
+ Returns the data at the given \a index for the specified \a roles.
+*/
+
+/*! \fn QList<int> QListModelInterface::roles() const
+ Returns the list of roles for which the list model interface
+ provides data.
+*/
+
+/*! \fn QString QListModelInterface::toString(int role) const
+ Returns a string description of the specified \a role.
+*/
+
+/*! \fn void QListModelInterface::itemsInserted(int index, int count)
+ Emit this signal when \a count items are inserted at \a index.
+ */
+
+/*! \fn void QListModelInterface::itemsRemoved(int index, int count)
+ Emit this signal when \a count items are removed at \a index.
+ */
+
+/*! \fn void QListModelInterface::itemsMoved(int from, int to, int count)
+ Emit this signal when \a count items are moved from index \a from
+ to index \a to.
+ */
+
+/*! \fn void QListModelInterface::itemsChanged(int index, int count, const QList<int> &roles)
+ Emit this signal when \a count items at \a index have had their
+ \a roles changed.
+ */
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qlistmodelinterface_p.h b/src/qml/qml/qlistmodelinterface_p.h
new file mode 100644
index 0000000000..c644ce88e6
--- /dev/null
+++ b/src/qml/qml/qlistmodelinterface_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLISTMODELINTERFACE_H
+#define QLISTMODELINTERFACE_H
+
+#include <QtCore/QHash>
+#include <QtCore/QVariant>
+
+#include <private/qtqmlglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class Q_QML_PRIVATE_EXPORT QListModelInterface : public QObject
+{
+ Q_OBJECT
+ public:
+ QListModelInterface(QObject *parent = 0) : QObject(parent) {}
+ virtual ~QListModelInterface() {}
+
+ virtual int count() const = 0;
+ virtual QVariant data(int index, int role) const = 0;
+
+ virtual QList<int> roles() const = 0;
+ virtual QString toString(int role) const = 0;
+
+ Q_SIGNALS:
+ void itemsInserted(int index, int count);
+ void itemsRemoved(int index, int count);
+ void itemsMoved(int from, int to, int count);
+ void itemsChanged(int index, int count, const QList<int> &roles);
+
+ protected:
+ QListModelInterface(QObjectPrivate &dd, QObject *parent)
+ : QObject(dd, parent) {}
+};
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+#endif //QTREEMODELINTERFACE_H
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
new file mode 100644
index 0000000000..0ce7c7ed5c
--- /dev/null
+++ b/src/qml/qml/qml.pri
@@ -0,0 +1,125 @@
+SOURCES += \
+ $$PWD/qquickapplication.cpp \
+ $$PWD/qqmlinstruction.cpp \
+ $$PWD/qquicklistmodel.cpp \
+ $$PWD/qquicklistmodelworkeragent.cpp \
+ $$PWD/qqmlopenmetaobject.cpp \
+ $$PWD/qqmlvmemetaobject.cpp \
+ $$PWD/qqmlengine.cpp \
+ $$PWD/qqmlexpression.cpp \
+ $$PWD/qqmlbinding.cpp \
+ $$PWD/qqmlproperty.cpp \
+ $$PWD/qqmlcomponent.cpp \
+ $$PWD/qqmlincubator.cpp \
+ $$PWD/qqmlcontext.cpp \
+ $$PWD/qqmlcustomparser.cpp \
+ $$PWD/qqmlpropertyvaluesource.cpp \
+ $$PWD/qqmlpropertyvalueinterceptor.cpp \
+ $$PWD/qqmlproxymetaobject.cpp \
+ $$PWD/qqmlvme.cpp \
+ $$PWD/qqmlcompiler.cpp \
+ $$PWD/qqmlcompileddata.cpp \
+ $$PWD/qqmlboundsignal.cpp \
+ $$PWD/qqmlmetatype.cpp \
+ $$PWD/qqmlstringconverters.cpp \
+ $$PWD/qqmlparserstatus.cpp \
+ $$PWD/qqmltypeloader.cpp \
+ $$PWD/qqmlinfo.cpp \
+ $$PWD/qqmlerror.cpp \
+ $$PWD/qqmlscript.cpp \
+ $$PWD/qqmlrewrite.cpp \
+ $$PWD/qqmlvaluetype.cpp \
+ $$PWD/qqmlaccessors.cpp \
+ $$PWD/qqmlxmlhttprequest.cpp \
+ $$PWD/qqmlwatcher.cpp \
+ $$PWD/qqmlcleanup.cpp \
+ $$PWD/qqmlpropertycache.cpp \
+ $$PWD/qqmlnotifier.cpp \
+ $$PWD/qqmlintegercache.cpp \
+ $$PWD/qqmltypenotavailable.cpp \
+ $$PWD/qqmltypenamecache.cpp \
+ $$PWD/qqmlscriptstring.cpp \
+ $$PWD/qquickworkerscript.cpp \
+ $$PWD/qqmlimageprovider.cpp \
+ $$PWD/qqmlnetworkaccessmanagerfactory.cpp \
+ $$PWD/qqmldirparser.cpp \
+ $$PWD/qqmlextensionplugin.cpp \
+ $$PWD/qqmlimport.cpp \
+ $$PWD/qqmllist.cpp \
+ $$PWD/qqmllocale.cpp \
+ $$PWD/qlistmodelinterface.cpp
+
+HEADERS += \
+ $$PWD/qqmlglobal_p.h \
+ $$PWD/qqmlinstruction_p.h \
+ $$PWD/qquicklistmodel_p.h\
+ $$PWD/qquicklistmodel_p_p.h\
+ $$PWD/qquicklistmodelworkeragent_p.h \
+ $$PWD/qqmlopenmetaobject_p.h \
+ $$PWD/qqmlvmemetaobject_p.h \
+ $$PWD/qqml.h \
+ $$PWD/qquickapplication_p.h \
+ $$PWD/qqmlbinding_p.h \
+ $$PWD/qqmlbinding_p_p.h \
+ $$PWD/qqmlproperty.h \
+ $$PWD/qqmlcomponent.h \
+ $$PWD/qqmlcomponent_p.h \
+ $$PWD/qqmlincubator.h \
+ $$PWD/qqmlincubator_p.h \
+ $$PWD/qqmlcustomparser_p.h \
+ $$PWD/qqmlcustomparser_p_p.h \
+ $$PWD/qqmlpropertyvaluesource.h \
+ $$PWD/qqmlpropertyvalueinterceptor_p.h \
+ $$PWD/qqmlboundsignal_p.h \
+ $$PWD/qqmlparserstatus.h \
+ $$PWD/qqmlproxymetaobject_p.h \
+ $$PWD/qqmlvme_p.h \
+ $$PWD/qqmlcompiler_p.h \
+ $$PWD/qqmlengine_p.h \
+ $$PWD/qqmlexpression_p.h \
+ $$PWD/qqmlprivate.h \
+ $$PWD/qqmlmetatype_p.h \
+ $$PWD/qqmlengine.h \
+ $$PWD/qqmlcontext.h \
+ $$PWD/qqmlexpression.h \
+ $$PWD/qqmlstringconverters_p.h \
+ $$PWD/qqmlinfo.h \
+ $$PWD/qqmlproperty_p.h \
+ $$PWD/qqmlcontext_p.h \
+ $$PWD/qqmltypeloader_p.h \
+ $$PWD/qqmllist.h \
+ $$PWD/qqmllist_p.h \
+ $$PWD/qqmldata_p.h \
+ $$PWD/qqmlerror.h \
+ $$PWD/qqmlscript_p.h \
+ $$PWD/qqmlrewrite_p.h \
+ $$PWD/qqmlvaluetype_p.h \
+ $$PWD/qqmlaccessors_p.h \
+ $$PWD/qqmlxmlhttprequest_p.h \
+ $$PWD/qqmlwatcher_p.h \
+ $$PWD/qqmlcleanup_p.h \
+ $$PWD/qqmlpropertycache_p.h \
+ $$PWD/qqmlnotifier_p.h \
+ $$PWD/qqmlintegercache_p.h \
+ $$PWD/qqmltypenotavailable_p.h \
+ $$PWD/qqmltypenamecache_p.h \
+ $$PWD/qqmlscriptstring.h \
+ $$PWD/qquickworkerscript_p.h \
+ $$PWD/qqmlguard_p.h \
+ $$PWD/qqmlimageprovider.h \
+ $$PWD/qqmlnetworkaccessmanagerfactory.h \
+ $$PWD/qqmldirparser_p.h \
+ $$PWD/qqmlextensioninterface.h \
+ $$PWD/qqmlimport_p.h \
+ $$PWD/qqmlextensionplugin.h \
+ $$PWD/qqmlnullablevalue_p_p.h \
+ $$PWD/qqmlscriptstring_p.h \
+ $$PWD/qqmllocale_p.h \
+ $$PWD/qlistmodelinterface_p.h \
+ $$PWD/qqmlcomponentattached_p.h
+
+include(parser/parser.pri)
+include(rewriter/rewriter.pri)
+include(ftw/ftw.pri)
+include(v4/v4.pri)
+include(v8/v8.pri)
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
new file mode 100644
index 0000000000..32da2c616e
--- /dev/null
+++ b/src/qml/qml/qqml.h
@@ -0,0 +1,451 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQML_H
+#define QQML_H
+
+#include <QtQml/qqmlprivate.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqmlpropertyvaluesource.h>
+#include <QtQml/qqmllist.h>
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_HEADER
+
+#define QML_VERSION 0x020000
+#define QML_VERSION_STR "2.0"
+
+#define QML_DECLARE_TYPE(TYPE) \
+ Q_DECLARE_METATYPE(TYPE *) \
+ Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
+
+#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \
+ Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
+
+#define QML_DECLARE_INTERFACE(INTERFACE) \
+ QML_DECLARE_TYPE(INTERFACE)
+
+#define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \
+ QML_DECLARE_TYPE_HASMETATYPE(INTERFACE)
+
+enum { /* TYPEINFO flags */
+ QML_HAS_ATTACHED_PROPERTIES = 0x01
+};
+
+#define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \
+QT_BEGIN_NAMESPACE \
+template <> \
+class QQmlTypeInfo<TYPE > \
+{ \
+public: \
+ enum { \
+ hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \
+ }; \
+}; \
+QT_END_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlPropertyValueInterceptor;
+
+template<typename T>
+int qmlRegisterType()
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlPrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+ 0, 0,
+ QString(),
+
+ 0, 0, 0, 0, &T::staticMetaObject,
+
+ QQmlPrivate::attachedPropertiesFunc<T>(),
+ QQmlPrivate::attachedPropertiesMetaObject<T>(),
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0,
+ 0
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+int Q_QML_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message);
+
+template<typename T>
+int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlPrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+ 0, 0,
+ reason,
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QQmlPrivate::attachedPropertiesFunc<T>(),
+ QQmlPrivate::attachedPropertiesMetaObject<T>(),
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0,
+ 0
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+template<typename T>
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlPrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+ sizeof(T), QQmlPrivate::createInto<T>,
+ QString(),
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QQmlPrivate::attachedPropertiesFunc<T>(),
+ QQmlPrivate::attachedPropertiesMetaObject<T>(),
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0,
+ 0
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+template<typename T, int metaObjectRevision>
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlPrivate::RegisterType type = {
+ 1,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+ sizeof(T), QQmlPrivate::createInto<T>,
+ QString(),
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QQmlPrivate::attachedPropertiesFunc<T>(),
+ QQmlPrivate::attachedPropertiesMetaObject<T>(),
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0,
+ metaObjectRevision
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+template<typename T, int metaObjectRevision>
+int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlPrivate::RegisterType type = {
+ 1,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+ sizeof(T), QQmlPrivate::createInto<T>,
+ QString(),
+
+ uri, versionMajor, versionMinor, 0, &T::staticMetaObject,
+
+ QQmlPrivate::attachedPropertiesFunc<T>(),
+ QQmlPrivate::attachedPropertiesMetaObject<T>(),
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0,
+ metaObjectRevision
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+
+template<typename T, typename E>
+int qmlRegisterExtendedType()
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlPrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+ 0, 0,
+ QString(),
+
+ 0, 0, 0, 0, &T::staticMetaObject,
+
+ QQmlPrivate::attachedPropertiesFunc<T>(),
+ QQmlPrivate::attachedPropertiesMetaObject<T>(),
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ QQmlPrivate::createParent<E>, &E::staticMetaObject,
+
+ 0,
+ 0
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+template<typename T, typename E>
+int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
+ const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
+ if (!attached) {
+ attached = QQmlPrivate::attachedPropertiesFunc<T>();
+ attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<T>();
+ }
+
+ QQmlPrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+ sizeof(T), QQmlPrivate::createInto<T>,
+ QString(),
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ attached,
+ attachedMetaObject,
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ QQmlPrivate::createParent<E>, &E::staticMetaObject,
+
+ 0,
+ 0
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+template<typename T>
+int qmlRegisterInterface(const char *typeName)
+{
+ QByteArray name(typeName);
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlPrivate::RegisterInterface qmlInterface = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+
+ qobject_interface_iid<T *>()
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::InterfaceRegistration, &qmlInterface);
+}
+
+template<typename T>
+int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName, QQmlCustomParser *parser)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QQmlListProperty<" + name + ">");
+
+ QQmlPrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QQmlListProperty<T> >(listName.constData()),
+ sizeof(T), QQmlPrivate::createInto<T>,
+ QString(),
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QQmlPrivate::attachedPropertiesFunc<T>(),
+ QQmlPrivate::attachedPropertiesMetaObject<T>(),
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ parser,
+ 0
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+class QQmlContext;
+class QQmlEngine;
+class QJSValue;
+class QJSEngine;
+Q_QML_EXPORT void qmlExecuteDeferred(QObject *);
+Q_QML_EXPORT QQmlContext *qmlContext(const QObject *);
+Q_QML_EXPORT QQmlEngine *qmlEngine(const QObject *);
+Q_QML_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true);
+Q_QML_EXPORT QObject *qmlAttachedPropertiesObject(int *, const QObject *, const QMetaObject *, bool create);
+
+template<typename T>
+QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
+{
+ static int idx = -1;
+ return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create);
+}
+
+// For the use of QtQuick1 module
+Q_QML_EXPORT void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor);
+
+inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor,
+ QJSValue (*callback)(QQmlEngine *, QJSEngine *))
+{
+ QQmlPrivate::RegisterModuleApi api = {
+ 0,
+
+ uri, versionMajor, versionMinor,
+
+ callback, 0
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::ModuleApiRegistration, &api);
+}
+
+inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor,
+ QObject *(*callback)(QQmlEngine *, QJSEngine *))
+{
+ QQmlPrivate::RegisterModuleApi api = {
+ 0,
+
+ uri, versionMajor, versionMinor,
+
+ 0, callback
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::ModuleApiRegistration, &api);
+}
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QObject)
+Q_DECLARE_METATYPE(QVariant)
+
+QT_END_HEADER
+
+#endif // QQML_H
diff --git a/src/qml/qml/qqmlaccessors.cpp b/src/qml/qml/qqmlaccessors.cpp
new file mode 100644
index 0000000000..ceb4f44789
--- /dev/null
+++ b/src/qml/qml/qqmlaccessors.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlaccessors_p.h"
+
+#include "qqmldata_p.h"
+#include "qqmlnotifier_p.h"
+
+QT_BEGIN_NAMESPACE
+
+struct AccessorProperties {
+ AccessorProperties();
+
+ QReadWriteLock lock;
+ QHash<const QMetaObject *, QQmlAccessorProperties::Properties> properties;
+};
+
+Q_GLOBAL_STATIC(AccessorProperties, accessorProperties)
+
+QML_PRIVATE_ACCESSOR(QObject, QString, objectName, objectName)
+
+static void QObject_objectNameNotifier(QObject *object, intptr_t, QQmlNotifier **notifier)
+{
+ *notifier = QQmlData::get(object, true)->objectNameNotifier();
+}
+
+static QQmlAccessors QObject_objectName = { QObject_objectNameRead,
+ QObject_objectNameNotifier };
+
+QML_DECLARE_PROPERTIES(QObject) {
+ { QML_PROPERTY_NAME(objectName), 0, &QObject_objectName }
+};
+
+static void buildNameMask(QQmlAccessorProperties::Properties &properties)
+{
+ quint32 mask = 0;
+
+ for (int ii = 0; ii < properties.count; ++ii) {
+ Q_ASSERT(strlen(properties.properties[ii].name) == properties.properties[ii].nameLength);
+ Q_ASSERT(properties.properties[ii].nameLength > 0);
+
+ mask |= (1 << qMin(31U, properties.properties[ii].nameLength - 1));
+ }
+
+ properties.nameMask = mask;
+}
+
+AccessorProperties::AccessorProperties()
+{
+ // Pre-seed QObject::objectName accessor
+ typedef QQmlAccessorProperties::Properties P;
+ properties.insert(&QObject::staticMetaObject,
+ P(qqml_accessor_properties_QObject,
+ sizeof(qqml_accessor_properties_QObject) /
+ sizeof(QQmlAccessorProperties::Property)));
+}
+
+QQmlAccessorProperties::Properties::Properties(Property *properties, int count)
+: count(count), properties(properties)
+{
+ buildNameMask(*this);
+}
+
+QQmlAccessorProperties::Properties
+QQmlAccessorProperties::properties(const QMetaObject *mo)
+{
+ AccessorProperties *This = accessorProperties();
+
+ QReadLocker lock(&This->lock);
+ return This->properties.value(mo);
+}
+
+void QQmlAccessorProperties::registerProperties(const QMetaObject *mo, int count,
+ Property *props)
+{
+ Q_ASSERT(count > 0);
+
+ Properties properties(props, count);
+
+ AccessorProperties *This = accessorProperties();
+
+ QWriteLocker lock(&This->lock);
+
+ Q_ASSERT(!This->properties.contains(mo) || This->properties.value(mo) == properties);
+
+ This->properties.insert(mo, properties);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlaccessors_p.h b/src/qml/qml/qqmlaccessors_p.h
new file mode 100644
index 0000000000..a603bede9f
--- /dev/null
+++ b/src/qml/qml/qqmlaccessors_p.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLACCESSORS_P_H
+#define QQMLACCESSORS_P_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qhash.h>
+#include <QtCore/QReadWriteLock>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+class QQmlNotifier;
+
+// QML "accessor properties" allow V4 and V8 to bypass Qt's meta system to read and, more
+// importantly, subscribe to properties directly. Any property that is primarily read
+// from bindings is a candidate for inclusion as an accessor property.
+//
+// To define accessor properties, use the QML_DECLARE_PROPERTIES() and QML_DEFINE_PROPERTIES()
+// macros. The QML_DECLARE_PROPERTIES() macro is used to specify the properties, and the
+// QML_DEFINE_PROPERTIES() macro to register the properties with the
+// QQmlAccessorProperties singleton.
+//
+// A class with accessor properties must also add the Q_CLASSINFO("qt_HasQmlAccessors", "true")
+// tag to its declaration. This is essential for QML to maintain internal consistency,
+// and forgetting to do so will probably cause your application to qFatal() with a
+// helpful reminder of this requirement.
+//
+// It is important that QML_DEFINE_PROPERTIES() has been called before QML ever sees
+// the type with the accessor properties. As QML_DEFINE_PROPERTIES() is idempotent, it is
+// recommended to call it in the type's constructor as well as when the type is registered
+// as a QML element (if it ever is). QML_DEFINE_PROPERTIES() is a very cheap operation
+// if registration has already occurred.
+
+#define QML_DECLARE_PROPERTIES(type) \
+ static volatile bool qqml_accessor_properties_isregistered_ ## type = false; \
+ static QQmlAccessorProperties::Property qqml_accessor_properties_ ## type[] =
+
+#define QML_DEFINE_PROPERTIES(type) \
+ do { \
+ if (!qqml_accessor_properties_isregistered_ ## type) { \
+ int count = sizeof(qqml_accessor_properties_ ## type) / \
+ sizeof(QQmlAccessorProperties::Property); \
+ QQmlAccessorProperties::registerProperties(&type::staticMetaObject, count, \
+ qqml_accessor_properties_ ## type);\
+ qqml_accessor_properties_isregistered_ ## type = true; \
+ } \
+ } while (false);
+
+#define QML_PRIVATE_ACCESSOR(clazz, cpptype, name, variable) \
+ static void clazz ## _ ## name ## Read(QObject *o, intptr_t, void *rv) \
+ { \
+ clazz ## Private *d = clazz ## Private::get(static_cast<clazz *>(o)); \
+ *static_cast<cpptype *>(rv) = d->variable; \
+ }
+
+#define QML_PROPERTY_NAME(name) #name, sizeof #name - 1
+
+class QQmlAccessors
+{
+public:
+ void (*read)(QObject *object, intptr_t property, void *output);
+ void (*notifier)(QObject *object, intptr_t property, QQmlNotifier **notifier);
+};
+
+namespace QQmlAccessorProperties {
+ struct Property {
+ const char *name;
+ unsigned int nameLength;
+ intptr_t data;
+ QQmlAccessors *accessors;
+ };
+
+ struct Properties {
+ inline Properties();
+ Properties(Property *, int);
+
+ bool operator==(const Properties &o) const {
+ return count == o.count && properties == o.properties;
+ }
+
+ inline Property *property(const char *name);
+
+ int count;
+ Property *properties;
+ quint32 nameMask;
+ };
+
+ Properties properties(const QMetaObject *);
+ void Q_QML_EXPORT registerProperties(const QMetaObject *, int, Property *);
+};
+
+QQmlAccessorProperties::Property *
+QQmlAccessorProperties::Properties::property(const char *name)
+{
+ if (count == 0)
+ return 0;
+
+ unsigned int length = strlen(name);
+
+ Q_ASSERT(length);
+
+ if (nameMask & (1 << qMin(31U, length - 1))) {
+
+ for (int ii = 0; ii < count; ++ii) {
+ if (properties[ii].nameLength == length && 0 == qstrcmp(name, properties[ii].name))
+ return &properties[ii];
+ }
+
+ }
+
+ return 0;
+}
+
+QQmlAccessorProperties::Properties::Properties()
+: count(0), properties(0), nameMask(0)
+{
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLACCESSORS_P_H
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
new file mode 100644
index 0000000000..a19644fb3e
--- /dev/null
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -0,0 +1,551 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlbinding_p.h"
+#include "qqmlbinding_p_p.h"
+
+#include "qqml.h"
+#include "qqmlcontext.h"
+#include "qqmlinfo.h"
+#include "qqmlcompiler_p.h"
+#include "qqmldata_p.h"
+#include <private/qqmlprofilerservice_p.h>
+#include <private/qqmltrace_p.h>
+
+#include <QVariant>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QQmlAbstractBinding::QQmlAbstractBinding()
+: m_prevBinding(0), m_nextBinding(0)
+{
+}
+
+QQmlAbstractBinding::~QQmlAbstractBinding()
+{
+ Q_ASSERT(m_prevBinding == 0);
+ Q_ASSERT(*m_mePtr == 0);
+}
+
+/*!
+Destroy the binding. Use this instead of calling delete.
+
+Bindings are free to implement their own memory management, so the delete operator is not
+necessarily safe. The default implementation clears the binding, removes it from the object
+and calls delete.
+*/
+void QQmlAbstractBinding::destroy()
+{
+ removeFromObject();
+ clear();
+
+ delete this;
+}
+
+/*!
+Add this binding to \a object.
+
+This transfers ownership of the binding to the object, marks the object's property as
+being bound.
+
+However, it does not enable the binding itself or call update() on it.
+*/
+void QQmlAbstractBinding::addToObject()
+{
+ Q_ASSERT(!m_prevBinding);
+
+ QObject *obj = object();
+ Q_ASSERT(obj);
+
+ int index = propertyIndex();
+
+ QQmlData *data = QQmlData::get(obj, true);
+
+ if (index & 0xFF000000) {
+ // Value type
+
+ int coreIndex = index & 0xFFFFFF;
+
+ // Find the value type proxy (if there is one)
+ QQmlValueTypeProxyBinding *proxy = 0;
+ if (data->hasBindingBit(coreIndex)) {
+ QQmlAbstractBinding *b = data->bindings;
+ while (b && b->propertyIndex() != coreIndex)
+ b = b->m_nextBinding;
+ Q_ASSERT(b && b->bindingType() == QQmlAbstractBinding::ValueTypeProxy);
+ proxy = static_cast<QQmlValueTypeProxyBinding *>(b);
+ }
+
+ if (!proxy) {
+ proxy = new QQmlValueTypeProxyBinding(obj, coreIndex);
+
+ Q_ASSERT(proxy->propertyIndex() == coreIndex);
+ Q_ASSERT(proxy->object() == obj);
+
+ proxy->addToObject();
+ }
+
+ m_nextBinding = proxy->m_bindings;
+ if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding;
+ m_prevBinding = &proxy->m_bindings;
+ proxy->m_bindings = this;
+
+ } else {
+ m_nextBinding = data->bindings;
+ if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding;
+ m_prevBinding = &data->bindings;
+ data->bindings = this;
+
+ data->setBindingBit(obj, index);
+ }
+}
+
+/*!
+Remove the binding from the object.
+*/
+void QQmlAbstractBinding::removeFromObject()
+{
+ if (m_prevBinding) {
+ int index = propertyIndex();
+
+ *m_prevBinding = m_nextBinding;
+ if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding;
+ m_prevBinding = 0;
+ m_nextBinding = 0;
+
+ if (index & 0xFF000000) {
+ // Value type - we don't remove the proxy from the object. It will sit their happily
+ // doing nothing until it is removed by a write, a binding change or it is reused
+ // to hold more sub-bindings.
+ } else if (QObject *obj = object()) {
+ QQmlData *data = QQmlData::get(obj, false);
+ if (data) data->clearBindingBit(index);
+ }
+ }
+}
+
+static void bindingDummyDeleter(QQmlAbstractBinding *)
+{
+}
+
+QQmlAbstractBinding::Pointer QQmlAbstractBinding::weakPointer()
+{
+ if (m_mePtr.value().isNull())
+ m_mePtr.value() = QSharedPointer<QQmlAbstractBinding>(this, bindingDummyDeleter);
+
+ return m_mePtr.value().toWeakRef();
+}
+
+void QQmlAbstractBinding::clear()
+{
+ if (!m_mePtr.isNull()) {
+ **m_mePtr = 0;
+ m_mePtr = 0;
+ }
+}
+
+void QQmlAbstractBinding::retargetBinding(QObject *, int)
+{
+ qFatal("QQmlAbstractBinding::retargetBinding() called on illegal binding.");
+}
+
+QString QQmlAbstractBinding::expression() const
+{
+ return QLatin1String("<Unknown>");
+}
+
+void QQmlAbstractBinding::setEnabled(bool enabled, QQmlPropertyPrivate::WriteFlags flags)
+{
+ if (enabled) update(flags);
+}
+
+QQmlBinding::Identifier QQmlBinding::Invalid = -1;
+
+void QQmlBindingPrivate::refresh()
+{
+ Q_Q(QQmlBinding);
+ q->update();
+}
+
+QQmlBindingPrivate::QQmlBindingPrivate()
+: updating(false), enabled(false), target(), targetProperty(0)
+{
+}
+
+QQmlBindingPrivate::~QQmlBindingPrivate()
+{
+}
+
+QQmlBinding *
+QQmlBinding::createBinding(Identifier id, QObject *obj, QQmlContext *ctxt,
+ const QString &url, int lineNumber, QObject *parent)
+{
+ if (id < 0)
+ return 0;
+
+ QQmlContextData *ctxtdata = QQmlContextData::get(ctxt);
+
+ QQmlEnginePrivate *engine = QQmlEnginePrivate::get(ctxt->engine());
+ QQmlCompiledData *cdata = 0;
+ QQmlTypeData *typeData = 0;
+ if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
+ typeData = engine->typeLoader.get(ctxtdata->url);
+ cdata = typeData->compiledData();
+ }
+ QQmlBinding *rv = cdata ? new QQmlBinding(cdata->primitives.at(id), true, obj, ctxtdata, url, lineNumber, 0, parent) : 0;
+ if (cdata)
+ cdata->release();
+ if (typeData)
+ typeData->release();
+ return rv;
+}
+
+QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContext *ctxt,
+ QObject *parent)
+: QQmlExpression(QQmlContextData::get(ctxt), obj, str, *new QQmlBindingPrivate)
+{
+ setParent(parent);
+ setNotifyOnValueChanged(true);
+}
+
+QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt,
+ QObject *parent)
+: QQmlExpression(ctxt, obj, str, *new QQmlBindingPrivate)
+{
+ setParent(parent);
+ setNotifyOnValueChanged(true);
+}
+
+QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj,
+ QQmlContextData *ctxt,
+ const QString &url, int lineNumber, int columnNumber,
+ QObject *parent)
+: QQmlExpression(ctxt, obj, str, isRewritten, url, lineNumber, columnNumber, *new QQmlBindingPrivate)
+{
+ setParent(parent);
+ setNotifyOnValueChanged(true);
+}
+
+/*!
+ \internal
+
+ To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle<v8::Function>.
+ For example:
+ v8::Handle<v8::Function> function;
+ new QQmlBinding(&function, scope, ctxt);
+ */
+QQmlBinding::QQmlBinding(void *functionPtr, QObject *obj, QQmlContextData *ctxt,
+ QObject *parent)
+: QQmlExpression(ctxt, obj, functionPtr, *new QQmlBindingPrivate)
+{
+ setParent(parent);
+ setNotifyOnValueChanged(true);
+}
+
+QQmlBinding::~QQmlBinding()
+{
+}
+
+void QQmlBinding::setTarget(const QQmlProperty &prop)
+{
+ Q_D(QQmlBinding);
+ d->property = prop;
+ d->target = d->property.object();
+ d->targetProperty = QQmlPropertyPrivate::get(d->property)->core.encodedIndex();
+
+ update();
+}
+
+void QQmlBinding::setTarget(QObject *object,
+ const QQmlPropertyData &core,
+ QQmlContextData *ctxt)
+{
+ Q_D(QQmlBinding);
+ d->property = QQmlPropertyPrivate::restore(object, core, ctxt);
+ d->target = d->property.object();
+ d->targetProperty = QQmlPropertyPrivate::get(d->property)->core.encodedIndex();
+
+ update();
+}
+
+QQmlProperty QQmlBinding::property() const
+{
+ Q_D(const QQmlBinding);
+ return d->property;
+}
+
+void QQmlBinding::setEvaluateFlags(EvaluateFlags flags)
+{
+ Q_D(QQmlBinding);
+ d->setRequiresThisObject(flags & RequiresThisObject);
+}
+
+QQmlBinding::EvaluateFlags QQmlBinding::evaluateFlags() const
+{
+ Q_D(const QQmlBinding);
+ return d->requiresThisObject()?RequiresThisObject:None;
+}
+
+void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags)
+{
+ Q_D(QQmlBinding);
+
+ if (!d->enabled || !d->context() || !d->context()->isValid())
+ return;
+
+ QQmlTrace trace("General Binding Update");
+ trace.addDetail("URL", d->url);
+ trace.addDetail("Line", d->line);
+ trace.addDetail("Column", d->columnNumber);
+
+ if (!d->updating) {
+ QQmlBindingProfiler prof(d->url, d->line, d->column);
+ prof.addDetail(expression());
+ d->updating = true;
+
+ QQmlAbstractExpression::DeleteWatcher watcher(d);
+
+ if (d->property.propertyType() == qMetaTypeId<QQmlBinding *>()) {
+
+ int idx = d->property.index();
+ Q_ASSERT(idx != -1);
+
+ QQmlBinding *t = this;
+ int status = -1;
+ void *a[] = { &t, 0, &status, &flags };
+ QMetaObject::metacall(d->property.object(),
+ QMetaObject::WriteProperty,
+ idx, a);
+
+ } else {
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(d->context()->engine);
+ ep->referenceScarceResources();
+
+ bool isUndefined = false;
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(ep->v8engine()->context());
+ v8::Local<v8::Value> result = d->v8value(0, &isUndefined);
+
+ trace.event("writing binding result");
+
+ bool needsErrorData = false;
+ if (!watcher.wasDeleted() && !d->hasError())
+ needsErrorData = !QQmlPropertyPrivate::writeBinding(d->property, d->context(),
+ d, result,
+ isUndefined, flags);
+
+ if (!watcher.wasDeleted()) {
+
+ if (needsErrorData) {
+ QUrl url = QUrl(d->url);
+ int line = d->line;
+ if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
+
+ d->delayedError()->error.setUrl(url);
+ d->delayedError()->error.setLine(line);
+ d->delayedError()->error.setColumn(-1);
+ }
+
+ if (d->hasError()) {
+ if (!d->delayedError()->addError(ep)) ep->warning(this->error());
+ } else {
+ d->clearError();
+ }
+
+ }
+
+ ep->dereferenceScarceResources();
+ }
+
+ if (!watcher.wasDeleted())
+ d->updating = false;
+ } else {
+ QQmlBindingPrivate::printBindingLoopError(d->property);
+ }
+}
+
+void QQmlBindingPrivate::printBindingLoopError(QQmlProperty &prop)
+{
+ qmlInfo(prop.object()) << QQmlBinding::tr("Binding loop detected for property \"%1\"").arg(prop.name());
+}
+
+void QQmlBindingPrivate::expressionChanged()
+{
+ Q_Q(QQmlBinding);
+ q->update();
+}
+
+void QQmlBinding::setEnabled(bool e, QQmlPropertyPrivate::WriteFlags flags)
+{
+ Q_D(QQmlBinding);
+ d->enabled = e;
+ setNotifyOnValueChanged(e);
+
+ if (e)
+ update(flags);
+}
+
+bool QQmlBinding::enabled() const
+{
+ Q_D(const QQmlBinding);
+
+ return d->enabled;
+}
+
+QString QQmlBinding::expression() const
+{
+ return QQmlExpression::expression();
+}
+
+int QQmlBinding::propertyIndex() const
+{
+ Q_D(const QQmlBinding);
+ return d->targetProperty;
+}
+
+QObject *QQmlBinding::object() const
+{
+ Q_D(const QQmlBinding);
+ return d->target;
+}
+
+void QQmlBinding::retargetBinding(QObject *t, int i)
+{
+ Q_D(QQmlBinding);
+ d->target = t;
+ d->targetProperty = i;
+}
+
+QQmlValueTypeProxyBinding::QQmlValueTypeProxyBinding(QObject *o, int index)
+: m_object(o), m_index(index), m_bindings(0)
+{
+}
+
+QQmlValueTypeProxyBinding::~QQmlValueTypeProxyBinding()
+{
+ while (m_bindings) {
+ QQmlAbstractBinding *binding = m_bindings;
+ binding->setEnabled(false, 0);
+ binding->destroy();
+ }
+}
+
+void QQmlValueTypeProxyBinding::setEnabled(bool e, QQmlPropertyPrivate::WriteFlags flags)
+{
+ if (e) {
+ QQmlAbstractBinding *bindings = m_bindings;
+ recursiveEnable(bindings, flags);
+ } else {
+ QQmlAbstractBinding *bindings = m_bindings;
+ recursiveDisable(bindings);
+ }
+}
+
+void QQmlValueTypeProxyBinding::recursiveEnable(QQmlAbstractBinding *b, QQmlPropertyPrivate::WriteFlags flags)
+{
+ if (!b)
+ return;
+
+ recursiveEnable(b->m_nextBinding, flags);
+
+ if (b)
+ b->setEnabled(true, flags);
+}
+
+void QQmlValueTypeProxyBinding::recursiveDisable(QQmlAbstractBinding *b)
+{
+ if (!b)
+ return;
+
+ recursiveDisable(b->m_nextBinding);
+
+ if (b)
+ b->setEnabled(false, 0);
+}
+
+void QQmlValueTypeProxyBinding::update(QQmlPropertyPrivate::WriteFlags)
+{
+}
+
+QQmlAbstractBinding *QQmlValueTypeProxyBinding::binding(int propertyIndex)
+{
+ QQmlAbstractBinding *binding = m_bindings;
+
+ while (binding && binding->propertyIndex() != propertyIndex)
+ binding = binding->m_nextBinding;
+
+ return binding;
+}
+
+/*!
+Removes a collection of bindings, corresponding to the set bits in \a mask.
+*/
+void QQmlValueTypeProxyBinding::removeBindings(quint32 mask)
+{
+ QQmlAbstractBinding *binding = m_bindings;
+ while (binding) {
+ if (mask & (1 << (binding->propertyIndex() >> 24))) {
+ QQmlAbstractBinding *remove = binding;
+ binding = remove->m_nextBinding;
+ *remove->m_prevBinding = remove->m_nextBinding;
+ if (remove->m_nextBinding) remove->m_nextBinding->m_prevBinding = remove->m_prevBinding;
+ remove->m_prevBinding = 0;
+ remove->m_nextBinding = 0;
+ remove->destroy();
+ } else {
+ binding = binding->m_nextBinding;
+ }
+ }
+}
+
+int QQmlValueTypeProxyBinding::propertyIndex() const
+{
+ return m_index;
+}
+
+QObject *QQmlValueTypeProxyBinding::object() const
+{
+ return m_object;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
new file mode 100644
index 0000000000..33823d7e7e
--- /dev/null
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLBINDING_P_H
+#define QQMLBINDING_P_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 "qqml.h"
+#include "qqmlpropertyvaluesource.h"
+#include "qqmlexpression.h"
+#include "qqmlproperty.h"
+#include "qqmlproperty_p.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QMetaProperty>
+
+#include <private/qpointervaluepair_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QML_PRIVATE_EXPORT QQmlAbstractBinding
+{
+public:
+ typedef QWeakPointer<QQmlAbstractBinding> Pointer;
+
+ QQmlAbstractBinding();
+
+ virtual void destroy();
+
+ virtual QString expression() const;
+
+ enum Type { PropertyBinding, ValueTypeProxy };
+ virtual Type bindingType() const { return PropertyBinding; }
+
+ // Should return the encoded property index for the binding. Should return this value
+ // even if the binding is not enabled or added to an object.
+ // Encoding is: coreIndex | (valueTypeIndex << 24)
+ virtual int propertyIndex() const = 0;
+ // Should return the object for the binding. Should return this object even if the
+ // binding is not enabled or added to the object.
+ virtual QObject *object() const = 0;
+
+ void setEnabled(bool e) { setEnabled(e, QQmlPropertyPrivate::DontRemoveBinding); }
+ virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags) = 0;
+
+ void update() { update(QQmlPropertyPrivate::DontRemoveBinding); }
+ virtual void update(QQmlPropertyPrivate::WriteFlags) = 0;
+
+ void addToObject();
+ void removeFromObject();
+
+ static inline Pointer getPointer(QQmlAbstractBinding *p);
+
+protected:
+ virtual ~QQmlAbstractBinding();
+ void clear();
+
+ // Called by QQmlPropertyPrivate to "move" a binding to a different property.
+ // This is only used for alias properties, and only used by QQmlBinding not
+ // V8 or V4 bindings. The default implementation qFatal()'s to ensure that the
+ // method is never called for V4 or V8 bindings.
+ virtual void retargetBinding(QObject *, int);
+private:
+ Pointer weakPointer();
+
+ friend class QQmlData;
+ friend class QQmlComponentPrivate;
+ friend class QQmlValueTypeProxyBinding;
+ friend class QQmlPropertyPrivate;
+ friend class QQmlVME;
+ friend class QtSharedPointer::ExternalRefCount<QQmlAbstractBinding>;
+
+ typedef QSharedPointer<QQmlAbstractBinding> SharedPointer;
+ // To save memory, we also store the rarely used weakPointer() instance in here
+ QPointerValuePair<QQmlAbstractBinding*, SharedPointer> m_mePtr;
+
+ QQmlAbstractBinding **m_prevBinding;
+ QQmlAbstractBinding *m_nextBinding;
+};
+
+class QQmlValueTypeProxyBinding : public QQmlAbstractBinding
+{
+public:
+ QQmlValueTypeProxyBinding(QObject *o, int coreIndex);
+
+ virtual Type bindingType() const { return ValueTypeProxy; }
+
+ virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags);
+ virtual void update(QQmlPropertyPrivate::WriteFlags);
+ virtual int propertyIndex() const;
+ virtual QObject *object() const;
+
+ QQmlAbstractBinding *binding(int propertyIndex);
+
+ void removeBindings(quint32 mask);
+
+protected:
+ ~QQmlValueTypeProxyBinding();
+
+private:
+ void recursiveEnable(QQmlAbstractBinding *, QQmlPropertyPrivate::WriteFlags);
+ void recursiveDisable(QQmlAbstractBinding *);
+
+ friend class QQmlAbstractBinding;
+ QObject *m_object;
+ int m_index;
+ QQmlAbstractBinding *m_bindings;
+};
+
+class QQmlContext;
+class QQmlBindingPrivate;
+class Q_QML_PRIVATE_EXPORT QQmlBinding : public QQmlExpression,
+ public QQmlAbstractBinding
+{
+Q_OBJECT
+public:
+ enum EvaluateFlag { None = 0x00, RequiresThisObject = 0x01 };
+ Q_DECLARE_FLAGS(EvaluateFlags, EvaluateFlag)
+
+ QQmlBinding(const QString &, QObject *, QQmlContext *, QObject *parent=0);
+ QQmlBinding(const QString &, QObject *, QQmlContextData *, QObject *parent=0);
+ QQmlBinding(const QString &, bool isRewritten, QObject *, QQmlContextData *,
+ const QString &url, int lineNumber, int columnNumber = 0, QObject *parent=0);
+ QQmlBinding(void *, QObject *, QQmlContextData *, QObject *parent=0);
+
+ void setTarget(const QQmlProperty &);
+ void setTarget(QObject *, const QQmlPropertyData &, QQmlContextData *);
+ QQmlProperty property() const;
+
+ void setEvaluateFlags(EvaluateFlags flags);
+ EvaluateFlags evaluateFlags() const;
+
+ bool enabled() const;
+
+ // Inherited from QQmlAbstractBinding
+ virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags flags);
+ virtual void update(QQmlPropertyPrivate::WriteFlags flags);
+ virtual QString expression() const;
+ virtual int propertyIndex() const;
+ virtual QObject *object() const;
+ virtual void retargetBinding(QObject *, int);
+
+ typedef int Identifier;
+ static Identifier Invalid;
+ static QQmlBinding *createBinding(Identifier, QObject *, QQmlContext *,
+ const QString &, int, QObject *parent=0);
+
+
+public Q_SLOTS:
+ void update() { update(QQmlPropertyPrivate::DontRemoveBinding); }
+
+protected:
+ ~QQmlBinding();
+
+private:
+ Q_DECLARE_PRIVATE(QQmlBinding)
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlBinding::EvaluateFlags)
+
+QQmlAbstractBinding::Pointer
+QQmlAbstractBinding::getPointer(QQmlAbstractBinding *p)
+{
+ return p ? p->weakPointer() : Pointer();
+}
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlBinding*)
+
+#endif // QQMLBINDING_P_H
diff --git a/src/qml/qml/qqmlbinding_p_p.h b/src/qml/qml/qqmlbinding_p_p.h
new file mode 100644
index 0000000000..b53c903916
--- /dev/null
+++ b/src/qml/qml/qqmlbinding_p_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLBINDING_P_P_H
+#define QQMLBINDING_P_P_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 "qqmlbinding_p.h"
+
+#include "qqmlproperty.h"
+#include "qqmlexpression_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQmlBindingPrivate : public QQmlExpressionPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlBinding)
+public:
+ QQmlBindingPrivate();
+ ~QQmlBindingPrivate();
+
+ virtual void expressionChanged();
+
+ static void printBindingLoopError(QQmlProperty &prop);
+
+protected:
+ virtual void refresh();
+
+private:
+ bool updating:1;
+ bool enabled:1;
+ int columnNumber;
+ QQmlProperty property;
+
+ QObject *target;
+ int targetProperty;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLBINDING_P_P_H
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
new file mode 100644
index 0000000000..ca6b13e7f8
--- /dev/null
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -0,0 +1,305 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlboundsignal_p.h"
+
+#include <private/qmetaobjectbuilder_p.h>
+#include "qqmlengine_p.h"
+#include "qqmlexpression_p.h"
+#include "qqmlcontext_p.h"
+#include "qqmlmetatype_p.h"
+#include "qqml.h"
+#include "qqmlcontext.h"
+#include "qqmlglobal_p.h"
+#include <private/qqmlprofilerservice_p.h>
+#include <private/qv8debugservice_p.h>
+
+#include <QtCore/qstringbuilder.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlBoundSignalParameters : public QObject
+{
+Q_OBJECT
+public:
+ QQmlBoundSignalParameters(const QMetaMethod &, QObject * = 0);
+ ~QQmlBoundSignalParameters();
+
+ void setValues(void **);
+ void clearValues();
+
+private:
+ friend class MetaObject;
+ int metaCall(QMetaObject::Call, int _id, void **);
+ struct MetaObject : public QAbstractDynamicMetaObject {
+ MetaObject(QQmlBoundSignalParameters *b)
+ : parent(b) {}
+
+ int metaCall(QMetaObject::Call c, int id, void **a) {
+ return parent->metaCall(c, id, a);
+ }
+ QQmlBoundSignalParameters *parent;
+ };
+
+ int *types;
+ void **values;
+ QMetaObject *myMetaObject;
+};
+
+static int evaluateIdx = -1;
+
+QQmlAbstractBoundSignal::QQmlAbstractBoundSignal(QObject *parent)
+: QObject(parent)
+{
+}
+
+QQmlAbstractBoundSignal::~QQmlAbstractBoundSignal()
+{
+}
+
+QQmlBoundSignal::QQmlBoundSignal(QObject *scope, const QMetaMethod &signal,
+ QObject *parent)
+: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0)
+{
+ // This is thread safe. Although it may be updated by two threads, they
+ // will both set it to the same value - so the worst thing that can happen
+ // is that they both do the work to figure it out. Boo hoo.
+ if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
+
+ QQml_setParent_noEvent(this, parent);
+ QQmlPropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
+}
+
+QQmlBoundSignal::QQmlBoundSignal(QQmlContext *ctxt, const QString &val,
+ QObject *scope, const QMetaMethod &signal,
+ QObject *parent)
+: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0)
+{
+ // This is thread safe. Although it may be updated by two threads, they
+ // will both set it to the same value - so the worst thing that can happen
+ // is that they both do the work to figure it out. Boo hoo.
+ if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
+
+ QQml_setParent_noEvent(this, parent);
+ QQmlPropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
+
+ m_expression = new QQmlExpression(ctxt, scope, val);
+}
+
+QQmlBoundSignal::~QQmlBoundSignal()
+{
+ delete m_expression;
+ m_expression = 0;
+}
+
+int QQmlBoundSignal::index() const
+{
+ return m_signal.methodIndex();
+}
+
+/*!
+ Returns the signal expression.
+*/
+QQmlExpression *QQmlBoundSignal::expression() const
+{
+ return m_expression;
+}
+
+/*!
+ Sets the signal expression to \a e. Returns the current signal expression,
+ or null if there is no signal expression.
+
+ The QQmlBoundSignal instance takes ownership of \a e. The caller is
+ assumes ownership of the returned QQmlExpression.
+*/
+QQmlExpression *QQmlBoundSignal::setExpression(QQmlExpression *e)
+{
+ QQmlExpression *rv = m_expression;
+ m_expression = e;
+ if (m_expression) m_expression->setNotifyOnValueChanged(false);
+ return rv;
+}
+
+QQmlBoundSignal *QQmlBoundSignal::cast(QObject *o)
+{
+ QQmlAbstractBoundSignal *s = qobject_cast<QQmlAbstractBoundSignal*>(o);
+ return static_cast<QQmlBoundSignal *>(s);
+}
+
+int QQmlBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
+{
+ if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) {
+ if (!m_expression)
+ return -1;
+
+ if (QQmlDebugService::isDebuggingEnabled())
+ QV8DebugService::instance()->signalEmitted(QString::fromAscii(m_signal.signature()));
+
+ QQmlHandlingSignalProfiler prof;
+ if (prof.enabled) {
+ prof.setSignalInfo(QString::fromLatin1(m_signal.signature()),
+ m_expression->expression());
+ prof.setLocation(m_expression->sourceFile(), m_expression->lineNumber(),
+ m_expression->columnNumber());
+ }
+
+ m_isEvaluating = true;
+ if (!m_paramsValid) {
+ if (!m_signal.parameterTypes().isEmpty())
+ m_params = new QQmlBoundSignalParameters(m_signal, this);
+ m_paramsValid = true;
+ }
+
+ if (m_params) m_params->setValues(a);
+ if (m_expression && m_expression->engine()) {
+ QQmlExpressionPrivate::get(m_expression)->value(m_params);
+ if (m_expression && m_expression->hasError())
+ QQmlEnginePrivate::warning(m_expression->engine(), m_expression->error());
+ }
+ if (m_params) m_params->clearValues();
+ m_isEvaluating = false;
+ return -1;
+ } else {
+ return QObject::qt_metacall(c, id, a);
+ }
+}
+
+QQmlBoundSignalParameters::QQmlBoundSignalParameters(const QMetaMethod &method,
+ QObject *parent)
+: QObject(parent), types(0), values(0)
+{
+ MetaObject *mo = new MetaObject(this);
+
+ // ### Optimize!
+ QMetaObjectBuilder mob;
+ mob.setSuperClass(&QQmlBoundSignalParameters::staticMetaObject);
+ mob.setClassName("QQmlBoundSignalParameters");
+
+ QList<QByteArray> paramTypes = method.parameterTypes();
+ QList<QByteArray> paramNames = method.parameterNames();
+ types = new int[paramTypes.count()];
+ for (int ii = 0; ii < paramTypes.count(); ++ii) {
+ const QByteArray &type = paramTypes.at(ii);
+ const QByteArray &name = paramNames.at(ii);
+
+ if (name.isEmpty() || type.isEmpty()) {
+ types[ii] = 0;
+ continue;
+ }
+
+ QVariant::Type t = (QVariant::Type)QMetaType::type(type.constData());
+ if (QQmlMetaType::isQObject(t)) {
+ types[ii] = QMetaType::QObjectStar;
+ QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*");
+ prop.setWritable(false);
+ } else {
+ QByteArray propType = type;
+ if (t >= QVariant::UserType || t == QVariant::Invalid) {
+ QByteArray scope;
+ QByteArray name;
+ int scopeIdx = propType.lastIndexOf("::");
+ if (scopeIdx != -1) {
+ scope = propType.left(scopeIdx);
+ name = propType.mid(scopeIdx + 2);
+ } else {
+ name = propType;
+ }
+ const QMetaObject *meta;
+ if (scope == "Qt")
+ meta = &QObject::staticQtMetaObject;
+ else
+ meta = parent->parent()->metaObject(); //### assumes parent->parent()
+ for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
+ QMetaEnum m = meta->enumerator(i);
+ if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) {
+ t = QVariant::Int;
+ propType = "int";
+ break;
+ }
+ }
+ }
+ types[ii] = t;
+ QMetaPropertyBuilder prop = mob.addProperty(name, propType);
+ prop.setWritable(false);
+ }
+ }
+ myMetaObject = mob.toMetaObject();
+ *static_cast<QMetaObject *>(mo) = *myMetaObject;
+
+ d_ptr->metaObject = mo;
+}
+
+QQmlBoundSignalParameters::~QQmlBoundSignalParameters()
+{
+ delete [] types;
+ free(myMetaObject);
+}
+
+void QQmlBoundSignalParameters::setValues(void **v)
+{
+ values = v;
+}
+
+void QQmlBoundSignalParameters::clearValues()
+{
+ values = 0;
+}
+
+int QQmlBoundSignalParameters::metaCall(QMetaObject::Call c, int id, void **a)
+{
+ if (!values)
+ return -1;
+
+ if (c == QMetaObject::ReadProperty && id >= 1) {
+ int t = types[id - 1];
+ void *p = a[0];
+ QMetaType::destruct(t, p);
+ QMetaType::construct(t, p, values[id]);
+ return -1;
+ } else {
+ return qt_metacall(c, id, a);
+ }
+}
+
+QT_END_NAMESPACE
+
+#include <qqmlboundsignal.moc>
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
new file mode 100644
index 0000000000..11386159cb
--- /dev/null
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLBOUNDSIGNAL_P_H
+#define QQMLBOUNDSIGNAL_P_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 "qqmlexpression.h"
+
+#include <QtCore/qmetaobject.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QML_EXPORT QQmlAbstractBoundSignal : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlAbstractBoundSignal(QObject *parent = 0);
+ virtual ~QQmlAbstractBoundSignal() = 0;
+};
+
+class QQmlBoundSignalParameters;
+class Q_QML_EXPORT QQmlBoundSignal : public QQmlAbstractBoundSignal
+{
+public:
+ QQmlBoundSignal(QObject *scope, const QMetaMethod &signal, QObject *parent);
+ QQmlBoundSignal(QQmlContext *ctxt, const QString &val, QObject *scope,
+ const QMetaMethod &signal, QObject *parent);
+ virtual ~QQmlBoundSignal();
+
+ int index() const;
+
+ QQmlExpression *expression() const;
+ QQmlExpression *setExpression(QQmlExpression *);
+
+ bool isEvaluating() const { return m_isEvaluating; }
+
+ static QQmlBoundSignal *cast(QObject *);
+
+protected:
+ virtual int qt_metacall(QMetaObject::Call c, int id, void **a);
+
+private:
+ QQmlExpression *m_expression;
+ QMetaMethod m_signal;
+ bool m_paramsValid : 1;
+ bool m_isEvaluating : 1;
+ QQmlBoundSignalParameters *m_params;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLBOUNDSIGNAL_P_H
diff --git a/src/qml/qml/qqmlcleanup.cpp b/src/qml/qml/qqmlcleanup.cpp
new file mode 100644
index 0000000000..21ea02ee17
--- /dev/null
+++ b/src/qml/qml/qqmlcleanup.cpp
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlcleanup_p.h"
+
+#include "qqmlengine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+\internal
+\class QQmlCleanup
+\brief The QQmlCleanup provides a callback when a QQmlEngine is deleted.
+
+Any object that needs cleanup to occur before the QQmlEngine's V8 engine is
+destroyed should inherit from QQmlCleanup. The clear() virtual method will be
+called by QQmlEngine just before it destroys the context.
+*/
+
+
+/*
+Create a QQmlCleanup that is not associated with any engine.
+*/
+QQmlCleanup::QQmlCleanup()
+: prev(0), next(0), engine(0)
+{
+}
+
+/*!
+Create a QQmlCleanup for \a engine
+*/
+QQmlCleanup::QQmlCleanup(QQmlEngine *engine)
+: prev(0), next(0), engine(0)
+{
+ if (!engine)
+ return;
+
+ addToEngine(engine);
+}
+
+/*!
+Adds this object to \a engine's cleanup list. hasEngine() must be false
+before calling this method.
+*/
+void QQmlCleanup::addToEngine(QQmlEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(QQmlEnginePrivate::isEngineThread(engine));
+
+ this->engine = engine;
+
+ QQmlEnginePrivate *p = QQmlEnginePrivate::get(engine);
+
+ if (p->cleanup) next = p->cleanup;
+ p->cleanup = this;
+ prev = &p->cleanup;
+ if (next) next->prev = &next;
+}
+
+/*!
+\fn bool QQmlCleanup::hasEngine() const
+
+Returns true if this QQmlCleanup is associated with an engine, otherwise false.
+*/
+
+/*!
+\internal
+*/
+QQmlCleanup::~QQmlCleanup()
+{
+ Q_ASSERT(!prev || engine);
+ Q_ASSERT(!prev || QQmlEnginePrivate::isEngineThread(engine));
+
+ if (prev) *prev = next;
+ if (next) next->prev = prev;
+ prev = 0;
+ next = 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcleanup_p.h b/src/qml/qml/qqmlcleanup_p.h
new file mode 100644
index 0000000000..2b7747d630
--- /dev/null
+++ b/src/qml/qml/qqmlcleanup_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCLEANUP_P_H
+#define QQMLCLEANUP_P_H
+
+#include <QtQml/qtqmlglobal.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.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+
+// Exported for QtQuick1
+class Q_QML_EXPORT QQmlCleanup
+{
+public:
+ QQmlCleanup();
+ QQmlCleanup(QQmlEngine *);
+ virtual ~QQmlCleanup();
+
+ bool hasEngine() const { return prev != 0; }
+ void addToEngine(QQmlEngine *);
+protected:
+ virtual void clear() = 0;
+
+private:
+ friend class QQmlEnginePrivate;
+ QQmlCleanup **prev;
+ QQmlCleanup *next;
+
+ // Only used for asserts
+ QQmlEngine *engine;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLCLEANUP_P_H
+
diff --git a/src/qml/qml/qqmlcompileddata.cpp b/src/qml/qml/qqmlcompileddata.cpp
new file mode 100644
index 0000000000..6a68784219
--- /dev/null
+++ b/src/qml/qml/qqmlcompileddata.cpp
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlcompiler_p.h"
+#include "qqmlengine.h"
+#include "qqmlcomponent.h"
+#include "qqmlcomponent_p.h"
+#include "qqmlcontext.h"
+#include "qqmlcontext_p.h"
+#ifdef QML_THREADED_VME_INTERPRETER
+#include "qqmlvme_p.h"
+#endif
+
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+int QQmlCompiledData::pack(const char *data, size_t size)
+{
+ const char *p = packData.constData();
+ unsigned int ps = packData.size();
+
+ for (unsigned int ii = 0; (ii + size) <= ps; ii += sizeof(int)) {
+ if (0 == ::memcmp(p + ii, data, size))
+ return ii;
+ }
+
+ int rv = packData.size();
+ packData.append(data, size);
+ return rv;
+}
+
+int QQmlCompiledData::indexForString(const QString &data)
+{
+ int idx = primitives.indexOf(data);
+ if (idx == -1) {
+ idx = primitives.count();
+ primitives << data;
+ }
+ return idx;
+}
+
+int QQmlCompiledData::indexForByteArray(const QByteArray &data)
+{
+ int idx = datas.indexOf(data);
+ if (idx == -1) {
+ idx = datas.count();
+ datas << data;
+ }
+ return idx;
+}
+
+int QQmlCompiledData::indexForUrl(const QUrl &data)
+{
+ int idx = urls.indexOf(data);
+ if (idx == -1) {
+ idx = urls.count();
+ urls << data;
+ }
+ return idx;
+}
+
+QQmlCompiledData::QQmlCompiledData(QQmlEngine *engine)
+: engine(engine), importCache(0), root(0), rootPropertyCache(0)
+{
+ Q_ASSERT(engine);
+
+ bytecode.reserve(1024);
+}
+
+void QQmlCompiledData::destroy()
+{
+ if (engine && hasEngine())
+ QQmlEnginePrivate::deleteInEngineThread(engine, this);
+ else
+ delete this;
+}
+
+QQmlCompiledData::~QQmlCompiledData()
+{
+ clear();
+
+ for (int ii = 0; ii < types.count(); ++ii) {
+ if (types.at(ii).component)
+ types.at(ii).component->release();
+ if (types.at(ii).typePropertyCache)
+ types.at(ii).typePropertyCache->release();
+ }
+
+ for (int ii = 0; ii < propertyCaches.count(); ++ii)
+ propertyCaches.at(ii)->release();
+
+ for (int ii = 0; ii < contextCaches.count(); ++ii)
+ contextCaches.at(ii)->release();
+
+ for (int ii = 0; ii < scripts.count(); ++ii)
+ scripts.at(ii)->release();
+
+ if (importCache)
+ importCache->release();
+
+ if (rootPropertyCache)
+ rootPropertyCache->release();
+}
+
+void QQmlCompiledData::clear()
+{
+ for (int ii = 0; ii < programs.count(); ++ii)
+ qPersistentDispose(programs[ii].bindings);
+}
+
+const QMetaObject *QQmlCompiledData::TypeReference::metaObject() const
+{
+ if (type) {
+ return type->metaObject();
+ } else {
+ Q_ASSERT(component);
+ return component->root;
+ }
+}
+
+/*!
+Returns the property cache, if one alread exists. The cache is not referenced.
+*/
+QQmlPropertyCache *QQmlCompiledData::TypeReference::propertyCache() const
+{
+ if (type)
+ return typePropertyCache;
+ else
+ return component->rootPropertyCache;
+}
+
+/*!
+Returns the property cache, creating one if it doesn't already exist. The cache is not referenced.
+*/
+QQmlPropertyCache *QQmlCompiledData::TypeReference::createPropertyCache(QQmlEngine *engine)
+{
+ if (typePropertyCache) {
+ return typePropertyCache;
+ } else if (type) {
+ typePropertyCache = QQmlEnginePrivate::get(engine)->cache(type->metaObject());
+ typePropertyCache->addref();
+ return typePropertyCache;
+ } else {
+ return component->rootPropertyCache;
+ }
+}
+
+
+void QQmlCompiledData::dumpInstructions()
+{
+ if (!name.isEmpty())
+ qWarning() << name;
+ qWarning().nospace() << "Index\tOperation\t\tData1\tData2\tData3\tComments";
+ qWarning().nospace() << "-------------------------------------------------------------------------------";
+
+ const char *instructionStream = bytecode.constData();
+ const char *endInstructionStream = bytecode.constData() + bytecode.size();
+
+ int instructionCount = 0;
+ while (instructionStream < endInstructionStream) {
+ QQmlInstruction *instr = (QQmlInstruction *)instructionStream;
+ dump(instr, instructionCount);
+ instructionStream += QQmlInstruction::size(instructionType(instr));
+ instructionCount++;
+ }
+
+ qWarning().nospace() << "-------------------------------------------------------------------------------";
+}
+
+int QQmlCompiledData::addInstructionHelper(QQmlInstruction::Type type, QQmlInstruction &instr)
+{
+#ifdef QML_THREADED_VME_INTERPRETER
+ instr.common.code = QQmlVME::instructionJumpTable()[static_cast<int>(type)];
+#else
+ instr.common.instructionType = type;
+#endif
+ int ptrOffset = bytecode.size();
+ int size = QQmlInstruction::size(type);
+ if (bytecode.capacity() <= bytecode.size() + size)
+ bytecode.reserve(bytecode.size() + size + 512);
+ bytecode.append(reinterpret_cast<const char *>(&instr), size);
+ return ptrOffset;
+}
+
+int QQmlCompiledData::nextInstructionIndex()
+{
+ return bytecode.size();
+}
+
+QQmlInstruction *QQmlCompiledData::instruction(int index)
+{
+ return (QQmlInstruction *)(bytecode.constData() + index);
+}
+
+QQmlInstruction::Type QQmlCompiledData::instructionType(const QQmlInstruction *instr)
+{
+#ifdef QML_THREADED_VME_INTERPRETER
+ void **jumpTable = QQmlVME::instructionJumpTable();
+ void *code = instr->common.code;
+
+# define QML_CHECK_INSTR_CODE(I, FMT) \
+ if (jumpTable[static_cast<int>(QQmlInstruction::I)] == code) \
+ return QQmlInstruction::I;
+
+ FOR_EACH_QML_INSTR(QML_CHECK_INSTR_CODE)
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid instruction address");
+ return static_cast<QQmlInstruction::Type>(0);
+# undef QML_CHECK_INSTR_CODE
+#else
+ return static_cast<QQmlInstruction::Type>(instr->common.instructionType);
+#endif
+}
+
+void QQmlCompiledData::initialize(QQmlEngine *engine)
+{
+ Q_ASSERT(!hasEngine());
+ QQmlCleanup::addToEngine(engine);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
new file mode 100644
index 0000000000..23c4adc7b4
--- /dev/null
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -0,0 +1,3904 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlcompiler_p.h"
+
+#include "qqmlpropertyvaluesource.h"
+#include "qqmlcomponent.h"
+#include <private/qmetaobjectbuilder_p.h>
+#include <private/qfastmetabuilder_p.h>
+#include "qqmlstringconverters_p.h"
+#include "qqmlengine_p.h"
+#include "qqmlengine.h"
+#include "qqmlcontext.h"
+#include "qqmlmetatype_p.h"
+#include "qqmlcustomparser_p_p.h"
+#include "qqmlcontext_p.h"
+#include "qqmlcomponent_p.h"
+#include <private/qqmljsast_p.h>
+#include "qqmlvmemetaobject_p.h"
+#include "qqmlexpression_p.h"
+#include "qqmlproperty_p.h"
+#include "qqmlrewrite_p.h"
+#include "qqmlscriptstring.h"
+#include "qqmlglobal_p.h"
+#include "qqmlbinding_p.h"
+#include <private/qv4compiler_p.h>
+
+#include <QColor>
+#include <QDebug>
+#include <QPointF>
+#include <QSizeF>
+#include <QRectF>
+#include <QAtomicInt>
+#include <QtCore/qdebug.h>
+#include <QtCore/qdatetime.h>
+
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QList<qreal>)
+Q_DECLARE_METATYPE(QList<bool>)
+Q_DECLARE_METATYPE(QList<QString>)
+Q_DECLARE_METATYPE(QList<QUrl>)
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
+DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATS);
+
+using namespace QQmlJS;
+using namespace QQmlScript;
+using namespace QQmlCompilerTypes;
+
+static QString id_string(QLatin1String("id"));
+static QString on_string(QLatin1String("on"));
+static QString Changed_string(QLatin1String("Changed"));
+static QString Component_string(QLatin1String("Component"));
+static QString Component_import_string(QLatin1String("QML/Component"));
+static QString qsTr_string(QLatin1String("qsTr"));
+static QString qsTrId_string(QLatin1String("qsTrId"));
+
+/*!
+ Instantiate a new QQmlCompiler.
+*/
+QQmlCompiler::QQmlCompiler(QQmlPool *pool)
+: pool(pool), output(0), engine(0), unitRoot(0), unit(0), cachedComponentTypeRef(-1),
+ cachedTranslationContextIndex(-1), componentStats(0)
+{
+ if (compilerStatDump())
+ componentStats = pool->New<ComponentStats>();
+}
+
+/*!
+ Returns true if the last call to compile() caused errors.
+
+ \sa errors()
+*/
+bool QQmlCompiler::isError() const
+{
+ return !exceptions.isEmpty();
+}
+
+/*!
+ Return the list of errors from the last call to compile(), or an empty list
+ if there were no errors.
+*/
+QList<QQmlError> QQmlCompiler::errors() const
+{
+ return exceptions;
+}
+
+/*!
+ Returns true if \a name refers to an attached property, false otherwise.
+
+ Attached property names are those that start with a capital letter.
+*/
+bool QQmlCompiler::isAttachedPropertyName(const QString &name)
+{
+ return isAttachedPropertyName(QHashedStringRef(&name));
+}
+
+bool QQmlCompiler::isAttachedPropertyName(const QHashedStringRef &name)
+{
+ return !name.isEmpty() && name.at(0).isUpper();
+}
+
+/*!
+ Returns true if \a name refers to a signal property, false otherwise.
+
+ Signal property names are those that start with "on", followed by a first
+ character which is either a capital letter or one or more underscores followed
+ by a capital letter, which is then followed by other allowed characters.
+
+ Note that although ECMA-262r3 supports dollarsigns and escaped unicode
+ character codes in property names, for simplicity and performance reasons
+ QML only supports letters, numbers and underscores.
+*/
+bool QQmlCompiler::isSignalPropertyName(const QString &name)
+{
+ return isSignalPropertyName(QStringRef(&name));
+}
+
+bool QQmlCompiler::isSignalPropertyName(const QHashedStringRef &name)
+{
+ if (name.length() < 3) return false;
+ if (!name.startsWith(on_string)) return false;
+ int ns = name.length();
+ for (int i = 2; i < ns; ++i) {
+ const QChar curr = name.at(i);
+ if (curr.unicode() == '_') continue;
+ if (curr.isUpper()) return true;
+ return false;
+ }
+ return false; // consists solely of underscores - invalid.
+}
+
+/*!
+ \macro COMPILE_EXCEPTION
+ \internal
+ Inserts an error into the QQmlCompiler error list, and returns false
+ (failure).
+
+ \a token is used to source the error line and column, and \a desc is the
+ error itself. \a desc can be an expression that can be piped into QDebug.
+
+ For example:
+
+ \code
+ COMPILE_EXCEPTION(property, tr("Error for property \"%1\"").arg(property->name));
+ \endcode
+*/
+#define COMPILE_EXCEPTION_LOCATION(line, column, desc) \
+ { \
+ QQmlError error; \
+ error.setUrl(output->url); \
+ error.setLine(line); \
+ error.setColumn(column); \
+ error.setDescription(desc.trimmed()); \
+ exceptions << error; \
+ return false; \
+ }
+
+#define COMPILE_EXCEPTION(token, desc) \
+ COMPILE_EXCEPTION_LOCATION((token)->location.start.line, (token)->location.start.column, desc)
+
+/*!
+ \macro COMPILE_CHECK
+ \internal
+ Returns false if \a is false, otherwise does nothing.
+*/
+#define COMPILE_CHECK(a) \
+ { \
+ if (!a) return false; \
+ }
+
+/*!
+ Returns true if literal \a v can be assigned to property \a prop, otherwise
+ false.
+
+ This test corresponds to action taken by genLiteralAssignment(). Any change
+ made here, must have a corresponding action in genLiteralAssigment().
+*/
+bool QQmlCompiler::testLiteralAssignment(QQmlScript::Property *prop,
+ QQmlScript::Value *v)
+{
+ const QQmlScript::Variant &value = v->value;
+
+ if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration)
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
+
+ if (prop->core.isEnum()) {
+ QMetaProperty p = prop->parent->metaObject()->property(prop->index);
+ int enumValue;
+ bool ok;
+ if (p.isFlagType()) {
+ enumValue = p.enumerator().keysToValue(value.asString().toUtf8().constData(), &ok);
+ } else
+ enumValue = p.enumerator().keyToValue(value.asString().toUtf8().constData(), &ok);
+
+ if (!ok)
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: unknown enumeration"));
+
+ v->value = QQmlScript::Variant((double)enumValue);
+ return true;
+ }
+
+ int type = prop->type;
+
+ switch(type) {
+ case QMetaType::QVariant:
+ break;
+ case QVariant::String:
+ if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string expected"));
+ break;
+ case QVariant::StringList: // we expect a string literal. A string list is not a literal assignment.
+ if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string or string list expected"));
+ break;
+ case QVariant::ByteArray:
+ if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: byte array expected"));
+ break;
+ case QVariant::Url:
+ if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: url expected"));
+ break;
+ case QVariant::RegExp:
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: regular expression expected; use /pattern/ syntax"));
+ break;
+ case QVariant::UInt:
+ {
+ bool ok = v->value.isNumber();
+ if (ok) {
+ double n = v->value.asNumber();
+ if (double(uint(n)) != n)
+ ok = false;
+ }
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected"));
+ }
+ break;
+ case QVariant::Int:
+ {
+ bool ok = v->value.isNumber();
+ if (ok) {
+ double n = v->value.asNumber();
+ if (double(int(n)) != n)
+ ok = false;
+ }
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected"));
+ }
+ break;
+ case QMetaType::Float:
+ 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: number expected"));
+ break;
+ case QVariant::Color:
+ {
+ bool ok;
+ QQmlStringConverters::colorFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: color expected"));
+ }
+ break;
+#ifndef QT_NO_DATESTRING
+ case QVariant::Date:
+ {
+ bool ok;
+ QQmlStringConverters::dateFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: date expected"));
+ }
+ break;
+ case QVariant::Time:
+ {
+ bool ok;
+ QQmlStringConverters::timeFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: time expected"));
+ }
+ break;
+ case QVariant::DateTime:
+ {
+ bool ok;
+ QQmlStringConverters::dateTimeFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: datetime expected"));
+ }
+ break;
+#endif // QT_NO_DATESTRING
+ case QVariant::Point:
+ case QVariant::PointF:
+ {
+ bool ok;
+ QQmlStringConverters::pointFFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: point expected"));
+ }
+ break;
+ case QVariant::Size:
+ case QVariant::SizeF:
+ {
+ bool ok;
+ QQmlStringConverters::sizeFFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: size expected"));
+ }
+ break;
+ case QVariant::Rect:
+ case QVariant::RectF:
+ {
+ bool ok;
+ QQmlStringConverters::rectFFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: rect expected"));
+ }
+ break;
+ case QVariant::Bool:
+ {
+ if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: boolean expected"));
+ }
+ break;
+ case QVariant::Vector3D:
+ {
+ bool ok;
+ QQmlStringConverters::vector3DFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 3D vector expected"));
+ }
+ break;
+ case QVariant::Vector4D:
+ {
+ bool ok;
+ QQmlStringConverters::vector4DFromString(value.asString(), &ok);
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 4D vector expected"));
+ }
+ break;
+ default:
+ {
+ // check if assigning a literal value to a list property.
+ // in each case, check the singular, since an Array of the specified type
+ // will not go via this literal assignment codepath.
+ if (type == qMetaTypeId<QList<qreal> >()) {
+ if (!v->value.isNumber()) {
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: real or array of reals expected"));
+ }
+ break;
+ } else if (type == qMetaTypeId<QList<int> >()) {
+ bool ok = v->value.isNumber();
+ if (ok) {
+ double n = v->value.asNumber();
+ if (double(int(n)) != n)
+ ok = false;
+ }
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int or array of ints expected"));
+ break;
+ } else if (type == qMetaTypeId<QList<bool> >()) {
+ if (!v->value.isBoolean()) {
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: bool or array of bools expected"));
+ }
+ break;
+ } else if (type == qMetaTypeId<QList<QString> >()) { // we expect a string literal. A string list is not a literal assignment.
+ if (!v->value.isString()) {
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: string or array of strings expected"));
+ }
+ break;
+ } else if (type == qMetaTypeId<QList<QUrl> >()) {
+ if (!v->value.isString()) {
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: url or array of urls expected"));
+ }
+ break;
+ }
+
+ // otherwise, check for existence of string converter to custom type
+ QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(type);
+ if (!converter)
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName((QVariant::Type)type))));
+ }
+ break;
+ }
+ return true;
+}
+
+static QUrl urlFromUserString(const QString &data)
+{
+ QUrl u;
+ // Preserve any valid percent-encoded octets supplied by the source
+ u.setEncodedUrl(data.toUtf8(), QUrl::TolerantMode);
+ return u;
+}
+
+/*!
+ Generate a store instruction for assigning literal \a v to property \a prop.
+
+ Any literal assignment that is approved in testLiteralAssignment() must have
+ a corresponding action in this method.
+*/
+void QQmlCompiler::genLiteralAssignment(QQmlScript::Property *prop,
+ QQmlScript::Value *v)
+{
+ if (prop->core.isEnum()) {
+ Q_ASSERT(v->value.isNumber());
+ // Preresolved value
+ int value = (int)v->value.asNumber();
+
+ Instruction::StoreInteger instr;
+ instr.propertyIndex = prop->index;
+ instr.value = value;
+ output->addInstruction(instr);
+ return;
+ }
+
+ int type = prop->type;
+ switch(type) {
+ case QMetaType::QVariant:
+ {
+ if (v->value.isNumber()) {
+ double n = v->value.asNumber();
+ if (double(int(n)) == n) {
+ if (prop->core.isVMEProperty()) {
+ Instruction::StoreVarInteger instr;
+ instr.propertyIndex = prop->index;
+ instr.value = int(n);
+ output->addInstruction(instr);
+ } else {
+ Instruction::StoreVariantInteger instr;
+ instr.propertyIndex = prop->index;
+ instr.value = int(n);
+ output->addInstruction(instr);
+ }
+ } else {
+ if (prop->core.isVMEProperty()) {
+ Instruction::StoreVarDouble instr;
+ instr.propertyIndex = prop->index;
+ instr.value = n;
+ output->addInstruction(instr);
+ } else {
+ Instruction::StoreVariantDouble instr;
+ instr.propertyIndex = prop->index;
+ instr.value = n;
+ output->addInstruction(instr);
+ }
+ }
+ } else if (v->value.isBoolean()) {
+ if (prop->core.isVMEProperty()) {
+ Instruction::StoreVarBool instr;
+ instr.propertyIndex = prop->index;
+ instr.value = v->value.asBoolean();
+ output->addInstruction(instr);
+ } else {
+ Instruction::StoreVariantBool instr;
+ instr.propertyIndex = prop->index;
+ instr.value = v->value.asBoolean();
+ output->addInstruction(instr);
+ }
+ } else {
+ if (prop->core.isVMEProperty()) {
+ Instruction::StoreVar instr;
+ instr.propertyIndex = prop->index;
+ instr.value = output->indexForString(v->value.asString());
+ output->addInstruction(instr);
+ } else {
+ Instruction::StoreVariant instr;
+ instr.propertyIndex = prop->index;
+ instr.value = output->indexForString(v->value.asString());
+ output->addInstruction(instr);
+ }
+ }
+ }
+ break;
+ case QVariant::String:
+ {
+ Instruction::StoreString instr;
+ instr.propertyIndex = prop->index;
+ instr.value = output->indexForString(v->value.asString());
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::StringList:
+ {
+ Instruction::StoreStringList instr;
+ instr.propertyIndex = prop->index;
+ instr.value = output->indexForString(v->value.asString());
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::ByteArray:
+ {
+ Instruction::StoreByteArray instr;
+ instr.propertyIndex = prop->index;
+ instr.value = output->indexForByteArray(v->value.asString().toLatin1());
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Url:
+ {
+ Instruction::StoreUrl instr;
+ QString string = v->value.asString();
+ QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string));
+ instr.propertyIndex = prop->index;
+ instr.value = output->indexForUrl(u);
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::UInt:
+ {
+ Instruction::StoreInteger instr;
+ instr.propertyIndex = prop->index;
+ instr.value = uint(v->value.asNumber());
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Int:
+ {
+ Instruction::StoreInteger instr;
+ instr.propertyIndex = prop->index;
+ instr.value = int(v->value.asNumber());
+ output->addInstruction(instr);
+ }
+ break;
+ case QMetaType::Float:
+ {
+ Instruction::StoreFloat instr;
+ instr.propertyIndex = prop->index;
+ instr.value = float(v->value.asNumber());
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Double:
+ {
+ Instruction::StoreDouble instr;
+ instr.propertyIndex = prop->index;
+ instr.value = v->value.asNumber();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Color:
+ {
+ Instruction::StoreColor instr;
+ QColor c = QQmlStringConverters::colorFromString(v->value.asString());
+ instr.propertyIndex = prop->index;
+ instr.value = c.rgba();
+ output->addInstruction(instr);
+ }
+ break;
+#ifndef QT_NO_DATESTRING
+ case QVariant::Date:
+ {
+ Instruction::StoreDate instr;
+ QDate d = QQmlStringConverters::dateFromString(v->value.asString());
+ instr.propertyIndex = prop->index;
+ instr.value = d.toJulianDay();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Time:
+ {
+ Instruction::StoreTime instr;
+ QTime time = QQmlStringConverters::timeFromString(v->value.asString());
+ instr.propertyIndex = prop->index;
+ Q_ASSERT(sizeof(instr.time) == sizeof(QTime));
+ ::memcpy(&instr.time, &time, sizeof(QTime));
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::DateTime:
+ {
+ Instruction::StoreDateTime instr;
+ QDateTime dateTime = QQmlStringConverters::dateTimeFromString(v->value.asString());
+ QTime time = dateTime.time();
+ instr.propertyIndex = prop->index;
+ instr.date = dateTime.date().toJulianDay();
+ Q_ASSERT(sizeof(instr.time) == sizeof(QTime));
+ ::memcpy(&instr.time, &time, sizeof(QTime));
+ output->addInstruction(instr);
+ }
+ break;
+#endif // QT_NO_DATESTRING
+ case QVariant::Point:
+ {
+ Instruction::StorePoint instr;
+ bool ok;
+ QPoint point = QQmlStringConverters::pointFFromString(v->value.asString(), &ok).toPoint();
+ instr.propertyIndex = prop->index;
+ instr.point.xp = point.x();
+ instr.point.yp = point.y();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::PointF:
+ {
+ Instruction::StorePointF instr;
+ bool ok;
+ QPointF point = QQmlStringConverters::pointFFromString(v->value.asString(), &ok);
+ instr.propertyIndex = prop->index;
+ instr.point.xp = point.x();
+ instr.point.yp = point.y();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Size:
+ {
+ Instruction::StoreSize instr;
+ bool ok;
+ QSize size = QQmlStringConverters::sizeFFromString(v->value.asString(), &ok).toSize();
+ instr.propertyIndex = prop->index;
+ instr.size.wd = size.width();
+ instr.size.ht = size.height();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::SizeF:
+ {
+ Instruction::StoreSizeF instr;
+ bool ok;
+ QSizeF size = QQmlStringConverters::sizeFFromString(v->value.asString(), &ok);
+ instr.propertyIndex = prop->index;
+ instr.size.wd = size.width();
+ instr.size.ht = size.height();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Rect:
+ {
+ Instruction::StoreRect instr;
+ bool ok;
+ QRect rect = QQmlStringConverters::rectFFromString(v->value.asString(), &ok).toRect();
+ instr.propertyIndex = prop->index;
+ instr.rect.x1 = rect.left();
+ instr.rect.y1 = rect.top();
+ instr.rect.x2 = rect.right();
+ instr.rect.y2 = rect.bottom();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::RectF:
+ {
+ Instruction::StoreRectF instr;
+ bool ok;
+ QRectF rect = QQmlStringConverters::rectFFromString(v->value.asString(), &ok);
+ instr.propertyIndex = prop->index;
+ instr.rect.xp = rect.left();
+ instr.rect.yp = rect.top();
+ instr.rect.w = rect.width();
+ instr.rect.h = rect.height();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Bool:
+ {
+ Instruction::StoreBool instr;
+ bool b = v->value.asBoolean();
+ instr.propertyIndex = prop->index;
+ instr.value = b;
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Vector3D:
+ {
+ Instruction::StoreVector3D instr;
+ bool ok;
+ QVector3D vector = QQmlStringConverters::vector3DFromString(v->value.asString(), &ok);
+ instr.propertyIndex = prop->index;
+ instr.vector.xp = vector.x();
+ instr.vector.yp = vector.y();
+ instr.vector.zp = vector.z();
+ output->addInstruction(instr);
+ }
+ break;
+ case QVariant::Vector4D:
+ {
+ Instruction::StoreVector4D instr;
+ bool ok;
+ QVector4D vector = QQmlStringConverters::vector4DFromString(v->value.asString(), &ok);
+ instr.propertyIndex = prop->index;
+ instr.vector.xp = vector.x();
+ instr.vector.yp = vector.y();
+ instr.vector.zp = vector.z();
+ instr.vector.wp = vector.w();
+ output->addInstruction(instr);
+ }
+ break;
+ default:
+ {
+ // generate single literal value assignment to a list property if required
+ if (type == qMetaTypeId<QList<qreal> >()) {
+ Instruction::StoreDoubleQList instr;
+ instr.propertyIndex = prop->index;
+ instr.value = v->value.asNumber();
+ output->addInstruction(instr);
+ break;
+ } else if (type == qMetaTypeId<QList<int> >()) {
+ Instruction::StoreIntegerQList instr;
+ instr.propertyIndex = prop->index;
+ instr.value = int(v->value.asNumber());
+ output->addInstruction(instr);
+ break;
+ } else if (type == qMetaTypeId<QList<bool> >()) {
+ Instruction::StoreBoolQList instr;
+ bool b = v->value.asBoolean();
+ instr.propertyIndex = prop->index;
+ instr.value = b;
+ output->addInstruction(instr);
+ break;
+ } else if (type == qMetaTypeId<QList<QUrl> >()) {
+ Instruction::StoreUrlQList instr;
+ QString string = v->value.asString();
+ QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string));
+ instr.propertyIndex = prop->index;
+ instr.value = output->indexForUrl(u);
+ output->addInstruction(instr);
+ break;
+ } else if (type == qMetaTypeId<QList<QString> >()) {
+ Instruction::StoreStringQList instr;
+ instr.propertyIndex = prop->index;
+ instr.value = output->indexForString(v->value.asString());
+ output->addInstruction(instr);
+ break;
+ }
+
+ // otherwise, generate custom type literal assignment
+ Instruction::AssignCustomType instr;
+ instr.propertyIndex = prop->index;
+ instr.primitive = output->indexForString(v->value.asString());
+ instr.type = type;
+ output->addInstruction(instr);
+ }
+ break;
+ }
+}
+
+/*!
+ Resets data by clearing the lists that the QQmlCompiler modifies.
+*/
+void QQmlCompiler::reset(QQmlCompiledData *data)
+{
+ data->types.clear();
+ data->primitives.clear();
+ data->datas.clear();
+ data->bytecode.resize(0);
+}
+
+/*!
+ Compile \a unit, and store the output in \a out. \a engine is the QQmlEngine
+ with which the QQmlCompiledData will be associated.
+
+ Returns true on success, false on failure. On failure, the compile errors
+ are available from errors().
+
+ If the environment variant QML_COMPILER_DUMP is set
+ (eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr
+ on a successful compiler.
+*/
+bool QQmlCompiler::compile(QQmlEngine *engine,
+ QQmlTypeData *unit,
+ QQmlCompiledData *out)
+{
+ exceptions.clear();
+
+ Q_ASSERT(out);
+ reset(out);
+
+ QQmlScript::Object *root = unit->parser().tree();
+ Q_ASSERT(root);
+
+ this->engine = engine;
+ this->enginePrivate = QQmlEnginePrivate::get(engine);
+ this->unit = unit;
+ this->unitRoot = root;
+ this->output = out;
+
+ // Compile types
+ const QList<QQmlTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
+ QList<QQmlScript::TypeReference *> referencedTypes = unit->parser().referencedTypes();
+
+ for (int ii = 0; ii < resolvedTypes.count(); ++ii) {
+ QQmlCompiledData::TypeReference ref;
+
+ const QQmlTypeData::TypeReference &tref = resolvedTypes.at(ii);
+ QQmlScript::TypeReference *parserRef = referencedTypes.at(ii);
+
+ if (tref.type) {
+ ref.type = tref.type;
+ if (!ref.type->isCreatable()) {
+ QString err = ref.type->noCreationReason();
+ if (err.isEmpty())
+ err = tr( "Element is not creatable.");
+ COMPILE_EXCEPTION(parserRef->refObjects.first(), err);
+ }
+
+ if (ref.type->containsRevisionedAttributes()) {
+ QQmlError cacheError;
+ ref.typePropertyCache = enginePrivate->cache(ref.type, resolvedTypes.at(ii).minorVersion,
+ cacheError);
+ if (!ref.typePropertyCache)
+ COMPILE_EXCEPTION(parserRef->refObjects.first(), cacheError.description());
+ ref.typePropertyCache->addref();
+ }
+
+ } else if (tref.typeData) {
+ ref.component = tref.typeData->compiledData();
+ }
+ ref.className = parserRef->name;
+ out->types << ref;
+ }
+
+ compileTree(root);
+
+ if (!isError()) {
+ if (compilerDump())
+ out->dumpInstructions();
+ if (componentStats)
+ dumpStats();
+ Q_ASSERT(out->rootPropertyCache);
+ } else {
+ reset(out);
+ }
+
+ compileState = 0;
+ output = 0;
+ this->engine = 0;
+ this->enginePrivate = 0;
+ this->unit = 0;
+ this->cachedComponentTypeRef = -1;
+ this->cachedTranslationContextIndex = -1;
+ this->unitRoot = 0;
+
+ return !isError();
+}
+
+void QQmlCompiler::compileTree(QQmlScript::Object *tree)
+{
+ compileState = pool->New<ComponentCompileState>();
+
+ compileState->root = tree;
+ if (componentStats)
+ componentStats->componentStat.lineNumber = tree->location.start.line;
+
+ // We generate the importCache before we build the tree so that
+ // it can be used in the binding compiler. Given we "expect" the
+ // QML compilation to succeed, this isn't a waste.
+ output->importCache = new QQmlTypeNameCache();
+ foreach (const QString &ns, unit->namespaces()) {
+ output->importCache->add(ns);
+ }
+
+ int scriptIndex = 0;
+ foreach (const QQmlTypeData::ScriptReference &script, unit->resolvedScripts()) {
+ QString qualifier = script.qualifier;
+ QString enclosingNamespace;
+
+ const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.'));
+ if (lastDotIndex != -1) {
+ enclosingNamespace = qualifier.left(lastDotIndex);
+ qualifier = qualifier.mid(lastDotIndex+1);
+ }
+
+ output->importCache->add(qualifier, scriptIndex++, enclosingNamespace);
+ }
+
+ unit->imports().populateCache(output->importCache, engine);
+
+ if (!buildObject(tree, BindingContext()) || !completeComponentBuild())
+ return;
+
+ Instruction::Init init;
+ init.bindingsSize = compileState->totalBindingsCount;
+ init.parserStatusSize = compileState->parserStatusCount;
+ init.contextCache = genContextCache();
+ init.objectStackSize = compileState->objectDepth.maxDepth();
+ init.listStackSize = compileState->listDepth.maxDepth();
+ if (compileState->compiledBindingData.isEmpty())
+ init.compiledBinding = -1;
+ else
+ init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData);
+ output->addInstruction(init);
+
+ foreach (const QQmlTypeData::ScriptReference &script, unit->resolvedScripts()) {
+ Instruction::StoreImportedScript import;
+ import.value = output->scripts.count();
+
+ QQmlScriptData *scriptData = script.script->scriptData();
+ scriptData->addref();
+ output->scripts << scriptData;
+ output->addInstruction(import);
+ }
+
+ if (!compileState->v8BindingProgram.isEmpty()) {
+ Instruction::InitV8Bindings bindings;
+ int index = output->programs.count();
+
+ typedef QQmlCompiledData::V8Program V8Program;
+ output->programs.append(V8Program(compileState->v8BindingProgram, output));
+
+ bindings.programIndex = index;
+ bindings.line = compileState->v8BindingProgramLine;
+ output->addInstruction(bindings);
+ }
+
+ genObject(tree);
+
+ Instruction::SetDefault def;
+ output->addInstruction(def);
+
+ Instruction::Done done;
+ output->addInstruction(done);
+
+ Q_ASSERT(tree->metatype);
+
+ if (tree->metadata.isEmpty()) {
+ output->root = tree->metatype;
+ } else {
+ static_cast<QMetaObject &>(output->rootData) = *tree->metaObject();
+ output->root = &output->rootData;
+ }
+ if (!tree->metadata.isEmpty())
+ enginePrivate->registerCompositeType(output);
+}
+
+static bool QStringList_contains(const QStringList &list, const QHashedStringRef &string)
+{
+ for (int ii = 0; ii < list.count(); ++ii)
+ if (string == list.at(ii))
+ return true;
+
+ return false;
+}
+
+bool QQmlCompiler::buildObject(QQmlScript::Object *obj, const BindingContext &ctxt)
+{
+ if (componentStats)
+ componentStats->componentStat.objects++;
+
+ Q_ASSERT (obj->type != -1);
+ const QQmlCompiledData::TypeReference &tr = output->types.at(obj->type);
+ obj->metatype = tr.metaObject();
+
+ if (tr.type)
+ obj->typeName = tr.type->qmlTypeName();
+
+ // This object is a "Component" element
+ if (tr.type && obj->metatype == &QQmlComponent::staticMetaObject) {
+ COMPILE_CHECK(buildComponent(obj, ctxt));
+ return true;
+ }
+
+ if (tr.component) {
+ typedef QQmlInstruction I;
+ const I *init = ((const I *)tr.component->bytecode.constData());
+ Q_ASSERT(init && tr.component->instructionType(init) == QQmlInstruction::Init);
+
+ // Adjust stack depths to include nested components
+ compileState->objectDepth.pushPop(init->init.objectStackSize);
+ compileState->listDepth.pushPop(init->init.listStackSize);
+ compileState->parserStatusCount += init->init.parserStatusSize;
+ compileState->totalBindingsCount += init->init.bindingsSize;
+ }
+
+ compileState->objectDepth.push();
+
+ // Object instantiations reset the binding context
+ BindingContext objCtxt(obj);
+
+ // Create the synthesized meta object, ignoring aliases
+ COMPILE_CHECK(checkDynamicMeta(obj));
+ COMPILE_CHECK(mergeDynamicMetaProperties(obj));
+ COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases));
+
+ // Find the native type and check for the QQmlParserStatus interface
+ QQmlType *type = toQmlType(obj);
+ Q_ASSERT(type);
+ obj->parserStatusCast = type->parserStatusCast();
+ if (obj->parserStatusCast != -1)
+ compileState->parserStatusCount++;
+
+ // Check if this is a custom parser type. Custom parser types allow
+ // assignments to non-existent properties. These assignments are then
+ // compiled by the type.
+ bool isCustomParser = output->types.at(obj->type).type &&
+ output->types.at(obj->type).type->customParser() != 0;
+ QList<QQmlCustomParserProperty> customProps;
+
+ // Fetch the list of deferred properties
+ QStringList deferredList = deferredProperties(obj);
+
+ // Must do id property first. This is to ensure that the id given to any
+ // id reference created matches the order in which the objects are
+ // instantiated
+ for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
+ if (prop->name() == id_string) {
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ break;
+ }
+ }
+
+ // Merge
+ Property *defaultProperty = 0;
+ Property *skipProperty = 0;
+ if (obj->defaultProperty) {
+ defaultProperty = obj->defaultProperty;
+
+ Property *explicitProperty = 0;
+
+ const QMetaObject *mo = obj->metatype;
+ int idx = mo->indexOfClassInfo("DefaultProperty");
+ if (idx != -1) {
+ QMetaClassInfo info = mo->classInfo(idx);
+ const char *p = info.value();
+ if (p) {
+ int plen = 0;
+ char ord = 0;
+ while (char c = p[plen++]) { ord |= c; };
+ --plen;
+
+ if (ord & 0x80) {
+ // Utf8 - unoptimal, but seldom hit
+ QString *s = pool->NewString(QString::fromUtf8(p, plen));
+ QHashedStringRef r(*s);
+
+ if (obj->propertiesHashField.test(r.hash())) {
+ for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) {
+ if (ep->name() == r) {
+ explicitProperty = ep;
+ break;
+ }
+ }
+ }
+
+ if (!explicitProperty)
+ defaultProperty->setName(r);
+
+ } else {
+ QHashedCStringRef r(p, plen);
+
+ if (obj->propertiesHashField.test(r.hash())) {
+ for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) {
+ if (ep->name() == r) {
+ explicitProperty = ep;
+ break;
+ }
+ }
+ }
+
+ if (!explicitProperty) {
+ // Set the default property name
+ QChar *buffer = pool->NewRawArray<QChar>(r.length());
+ r.writeUtf16(buffer);
+ defaultProperty->setName(QHashedStringRef(buffer, r.length(), r.hash()));
+ }
+ }
+ }
+ }
+
+ if (explicitProperty && !explicitProperty->value && !explicitProperty->values.isEmpty()) {
+
+ skipProperty = explicitProperty; // We merge the values into defaultProperty
+
+ // Find the correct insertion point
+ Value *insertPos = 0;
+
+ for (Value *v = defaultProperty->values.first(); v; v = Property::ValueList::next(v)) {
+ if (!(v->location.start < explicitProperty->values.first()->location.start))
+ break;
+ insertPos = v;
+ }
+
+ defaultProperty->values.insertAfter(insertPos, explicitProperty->values);
+ }
+ }
+
+ QQmlCustomParser *cp = 0;
+ if (isCustomParser)
+ cp = output->types.at(obj->type).type->customParser();
+
+ // Build all explicit properties specified
+ for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
+
+ if (prop == skipProperty)
+ continue;
+ if (prop->name() == id_string)
+ continue;
+
+ bool canDefer = false;
+ if (isCustomParser) {
+ if (doesPropertyExist(prop, obj) &&
+ (!(cp->flags() & QQmlCustomParser::AcceptsAttachedProperties) ||
+ !isAttachedPropertyName(prop->name()))) {
+ int ids = compileState->ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState->ids.count();
+ } else if (isSignalPropertyName(prop->name()) &&
+ (cp->flags() & QQmlCustomParser::AcceptsSignalHandlers)) {
+ COMPILE_CHECK(buildSignal(prop,obj,objCtxt));
+ } else {
+ customProps << QQmlCustomParserNodePrivate::fromProperty(prop);
+ }
+ } else {
+ if (isSignalPropertyName(prop->name())) {
+ COMPILE_CHECK(buildSignal(prop,obj,objCtxt));
+ } else {
+ int ids = compileState->ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState->ids.count();
+ }
+ }
+
+ if (canDefer && !deferredList.isEmpty() && QStringList_contains(deferredList, prop->name()))
+ prop->isDeferred = true;
+
+ }
+
+ // Build the default property
+ if (defaultProperty) {
+ Property *prop = defaultProperty;
+
+ bool canDefer = false;
+ if (isCustomParser) {
+ if (doesPropertyExist(prop, obj)) {
+ int ids = compileState->ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState->ids.count();
+ } else {
+ customProps << QQmlCustomParserNodePrivate::fromProperty(prop);
+ }
+ } else {
+ int ids = compileState->ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState->ids.count();
+ }
+
+ if (canDefer && !deferredList.isEmpty() && QStringList_contains(deferredList, prop->name()))
+ prop->isDeferred = true;
+ }
+
+ // Compile custom parser parts
+ if (isCustomParser && !customProps.isEmpty()) {
+ cp->clearErrors();
+ cp->compiler = this;
+ cp->object = obj;
+ obj->custom = cp->compile(customProps);
+ cp->compiler = 0;
+ cp->object = 0;
+ foreach (QQmlError err, cp->errors()) {
+ err.setUrl(output->url);
+ exceptions << err;
+ }
+ }
+
+ compileState->objectDepth.pop();
+
+ return true;
+}
+
+void QQmlCompiler::genObject(QQmlScript::Object *obj)
+{
+ QQmlCompiledData::TypeReference &tr = output->types[obj->type];
+ if (tr.type && obj->metatype == &QQmlComponent::staticMetaObject) {
+ genComponent(obj);
+ return;
+ }
+
+ // Create the object
+ if (obj->custom.isEmpty() && output->types.at(obj->type).type &&
+ !output->types.at(obj->type).type->isExtendedType() && obj != compileState->root) {
+
+ Instruction::CreateSimpleObject create;
+ create.create = output->types.at(obj->type).type->createFunction();
+ create.typeSize = output->types.at(obj->type).type->createSize();
+ create.type = obj->type;
+ create.line = obj->location.start.line;
+ create.column = obj->location.start.column;
+ output->addInstruction(create);
+
+ } else {
+
+ if (output->types.at(obj->type).type) {
+ Instruction::CreateCppObject create;
+ create.line = obj->location.start.line;
+ create.column = obj->location.start.column;
+ create.data = -1;
+ if (!obj->custom.isEmpty())
+ create.data = output->indexForByteArray(obj->custom);
+ create.type = obj->type;
+ create.isRoot = (compileState->root == obj);
+ output->addInstruction(create);
+ } else {
+ Instruction::CreateQMLObject create;
+ create.type = obj->type;
+ create.isRoot = (compileState->root == obj);
+
+ if (!obj->bindingBitmask.isEmpty()) {
+ Q_ASSERT(obj->bindingBitmask.size() % 4 == 0);
+ create.bindingBits = output->indexForByteArray(obj->bindingBitmask);
+ } else {
+ create.bindingBits = -1;
+ }
+ output->addInstruction(create);
+
+ Instruction::CompleteQMLObject complete;
+ complete.line = obj->location.start.line;
+ complete.column = obj->location.start.column;
+ complete.isRoot = (compileState->root == obj);
+ output->addInstruction(complete);
+ }
+ }
+
+ // Setup the synthesized meta object if necessary
+ if (!obj->metadata.isEmpty()) {
+ Instruction::StoreMetaObject meta;
+ meta.data = output->indexForByteArray(obj->metadata);
+ meta.aliasData = output->indexForByteArray(obj->synthdata);
+ meta.propertyCache = output->propertyCaches.count();
+
+ QQmlPropertyCache *propertyCache = obj->synthCache;
+ Q_ASSERT(propertyCache);
+ propertyCache->addref();
+
+ // Add flag for alias properties
+ if (!obj->synthdata.isEmpty()) {
+ const QQmlVMEMetaData *vmeMetaData =
+ reinterpret_cast<const QQmlVMEMetaData *>(obj->synthdata.constData());
+ for (int ii = 0; ii < vmeMetaData->aliasCount; ++ii) {
+ int index = obj->metaObject()->propertyOffset() + vmeMetaData->propertyCount + ii;
+ QQmlPropertyData *data = propertyCache->property(index);
+ data->setFlags(data->getFlags() | QQmlPropertyData::IsAlias);
+ }
+ }
+
+ if (obj == unitRoot) {
+ propertyCache->addref();
+ output->rootPropertyCache = propertyCache;
+ }
+
+ output->propertyCaches << propertyCache;
+ output->addInstruction(meta);
+ } else if (obj == unitRoot) {
+ output->rootPropertyCache = tr.createPropertyCache(engine);
+ output->rootPropertyCache->addref();
+ }
+
+ // Set the object id
+ if (!obj->id.isEmpty()) {
+ Instruction::SetId id;
+ id.value = output->indexForString(obj->id);
+ id.index = obj->idIndex;
+ output->addInstruction(id);
+ }
+
+ // Begin the class
+ if (tr.type && obj->parserStatusCast != -1) {
+ Instruction::BeginObject begin;
+ begin.castValue = obj->parserStatusCast;
+ output->addInstruction(begin);
+ }
+
+ genObjectBody(obj);
+}
+
+void QQmlCompiler::genObjectBody(QQmlScript::Object *obj)
+{
+ for (Property *prop = obj->scriptStringProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ Q_ASSERT(prop->scriptStringScope != -1);
+ const QString &script = prop->values.first()->value.asScript();
+ Instruction::StoreScriptString ss;
+ ss.propertyIndex = prop->index;
+ ss.value = output->indexForString(script);
+ ss.scope = prop->scriptStringScope;
+// ss.bindingId = rewriteBinding(script, prop->name());
+ ss.bindingId = rewriteBinding(prop->values.first()->value, QString()); // XXX
+ ss.line = prop->location.start.line;
+ ss.column = prop->location.start.column;
+ output->addInstruction(ss);
+ }
+
+ bool seenDefer = false;
+ for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ if (prop->isDeferred) {
+ seenDefer = true;
+ continue;
+ }
+ if (!prop->isAlias)
+ genValueProperty(prop, obj);
+ }
+ if (seenDefer) {
+ Instruction::Defer defer;
+ defer.deferCount = 0;
+ int deferIdx = output->addInstruction(defer);
+ int nextInstructionIndex = output->nextInstructionIndex();
+
+ Instruction::DeferInit dinit;
+ // XXX - these are now massive over allocations
+ dinit.bindingsSize = compileState->totalBindingsCount;
+ dinit.parserStatusSize = compileState->parserStatusCount;
+ dinit.objectStackSize = compileState->objectDepth.maxDepth();
+ dinit.listStackSize = compileState->listDepth.maxDepth();
+ output->addInstruction(dinit);
+
+ for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ if (!prop->isDeferred)
+ continue;
+ genValueProperty(prop, obj);
+ }
+
+ Instruction::Done done;
+ output->addInstruction(done);
+
+ output->instruction(deferIdx)->defer.deferCount = output->nextInstructionIndex() - nextInstructionIndex;
+ }
+
+ for (Property *prop = obj->signalProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+
+ QQmlScript::Value *v = prop->values.first();
+
+ if (v->type == Value::SignalObject) {
+
+ genObject(v->object);
+
+ Instruction::AssignSignalObject assign;
+ assign.line = v->location.start.line;
+ assign.signal = output->indexForString(prop->name().toString());
+ output->addInstruction(assign);
+
+ } else if (v->type == Value::SignalExpression) {
+
+ Instruction::StoreSignal store;
+ store.signalIndex = prop->index;
+ const QString &rewrite = rewriteSignalHandler(v->value, prop->name().toString());
+ store.value = output->indexForByteArray(rewrite.toUtf8());
+ store.context = v->signalExpressionContextStack;
+ store.line = v->location.start.line;
+ store.column = v->location.start.column;
+ output->addInstruction(store);
+
+ }
+
+ }
+
+ for (Property *prop = obj->attachedProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ Instruction::FetchAttached fetch;
+ fetch.id = prop->index;
+ fetch.line = prop->location.start.line;
+ output->addInstruction(fetch);
+
+ genObjectBody(prop->value);
+
+ Instruction::PopFetchedObject pop;
+ output->addInstruction(pop);
+ }
+
+ for (Property *prop = obj->groupedProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ Instruction::FetchObject fetch;
+ fetch.property = prop->index;
+ fetch.line = prop->location.start.line;
+ output->addInstruction(fetch);
+
+ if (!prop->value->metadata.isEmpty()) {
+ Instruction::StoreMetaObject meta;
+ meta.data = output->indexForByteArray(prop->value->metadata);
+ meta.aliasData = output->indexForByteArray(prop->value->synthdata);
+ meta.propertyCache = -1;
+ output->addInstruction(meta);
+ }
+
+ genObjectBody(prop->value);
+
+ Instruction::PopFetchedObject pop;
+ output->addInstruction(pop);
+ }
+
+ for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ if (!prop->isAlias)
+ genValueTypeProperty(obj, prop);
+ }
+
+ for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ if (prop->isDeferred)
+ continue;
+ if (prop->isAlias)
+ genValueProperty(prop, obj);
+ }
+
+ for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ if (prop->isAlias)
+ genValueTypeProperty(obj, prop);
+ }
+}
+
+void QQmlCompiler::genValueTypeProperty(QQmlScript::Object *obj,QQmlScript::Property *prop)
+{
+ Instruction::FetchValueType fetch;
+ fetch.property = prop->index;
+ fetch.type = prop->type;
+ fetch.bindingSkipList = 0;
+
+ if (obj->type == -1 || output->types.at(obj->type).component) {
+ // We only have to do this if this is a composite type. If it is a builtin
+ // type it can't possibly already have bindings that need to be cleared.
+ for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) {
+ if (!vprop->values.isEmpty()) {
+ Q_ASSERT(vprop->index >= 0 && vprop->index < 32);
+ fetch.bindingSkipList |= (1 << vprop->index);
+ }
+ }
+ }
+
+ output->addInstruction(fetch);
+
+ for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) {
+ genPropertyAssignment(vprop, prop->value, prop);
+ }
+
+ Instruction::PopValueType pop;
+ pop.property = prop->index;
+ pop.type = prop->type;
+ pop.bindingSkipList = 0;
+ output->addInstruction(pop);
+}
+
+void QQmlCompiler::genComponent(QQmlScript::Object *obj)
+{
+ QQmlScript::Object *root = obj->defaultProperty->values.first()->object;
+ Q_ASSERT(root);
+
+ Instruction::CreateComponent create;
+ create.line = root->location.start.line;
+ create.column = root->location.start.column;
+ create.endLine = root->location.end.line;
+ create.isRoot = (compileState->root == obj);
+ int createInstruction = output->addInstruction(create);
+ int nextInstructionIndex = output->nextInstructionIndex();
+
+ ComponentCompileState *oldCompileState = compileState;
+ compileState = componentState(root);
+
+ Instruction::Init init;
+ init.bindingsSize = compileState->totalBindingsCount;
+ init.parserStatusSize = compileState->parserStatusCount;
+ init.contextCache = genContextCache();
+ init.objectStackSize = compileState->objectDepth.maxDepth();
+ init.listStackSize = compileState->listDepth.maxDepth();
+ if (compileState->compiledBindingData.isEmpty())
+ init.compiledBinding = -1;
+ else
+ init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData);
+ output->addInstruction(init);
+
+ if (!compileState->v8BindingProgram.isEmpty()) {
+ Instruction::InitV8Bindings bindings;
+ int index = output->programs.count();
+
+ typedef QQmlCompiledData::V8Program V8Program;
+ output->programs.append(V8Program(compileState->v8BindingProgram, output));
+
+ bindings.programIndex = index;
+ bindings.line = compileState->v8BindingProgramLine;
+ output->addInstruction(bindings);
+ }
+
+ genObject(root);
+
+ Instruction::SetDefault def;
+ output->addInstruction(def);
+
+ Instruction::Done done;
+ output->addInstruction(done);
+
+ output->instruction(createInstruction)->createComponent.count =
+ output->nextInstructionIndex() - nextInstructionIndex;
+
+ compileState = oldCompileState;
+
+ if (!obj->id.isEmpty()) {
+ Instruction::SetId id;
+ id.value = output->indexForString(obj->id);
+ id.index = obj->idIndex;
+ output->addInstruction(id);
+ }
+
+ if (obj == unitRoot) {
+ output->rootPropertyCache = output->types[obj->type].createPropertyCache(engine);
+ output->rootPropertyCache->addref();
+ }
+}
+
+bool QQmlCompiler::buildComponent(QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ // The special "Component" element can only have the id property and a
+ // default property, that actually defines the component's tree
+
+ compileState->objectDepth.push();
+
+ // Find, check and set the "id" property (if any)
+ Property *idProp = 0;
+ if (obj->properties.isMany() ||
+ (obj->properties.isOne() && obj->properties.first()->name() != id_string))
+ COMPILE_EXCEPTION(obj->properties.first(), tr("Component elements may not contain properties other than id"));
+
+ if (!obj->properties.isEmpty())
+ idProp = obj->properties.first();
+
+ if (idProp) {
+ if (idProp->value || idProp->values.isMany() || idProp->values.first()->object)
+ COMPILE_EXCEPTION(idProp, tr("Invalid component id specification"));
+ COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()))
+
+ QString idVal = idProp->values.first()->primitive();
+
+ if (compileState->ids.value(idVal))
+ COMPILE_EXCEPTION(idProp, tr("id is not unique"));
+
+ obj->id = idVal;
+ addId(idVal, obj);
+ }
+
+ // Check the Component tree is well formed
+ if (obj->defaultProperty &&
+ (obj->defaultProperty->value || obj->defaultProperty->values.isMany() ||
+ (obj->defaultProperty->values.isOne() && !obj->defaultProperty->values.first()->object)))
+ COMPILE_EXCEPTION(obj, tr("Invalid component body specification"));
+
+ if (!obj->dynamicProperties.isEmpty())
+ COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new properties."));
+ if (!obj->dynamicSignals.isEmpty())
+ COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new signals."));
+ if (!obj->dynamicSlots.isEmpty())
+ COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new functions."));
+
+ QQmlScript::Object *root = 0;
+ if (obj->defaultProperty && !obj->defaultProperty->values.isEmpty())
+ root = obj->defaultProperty->values.first()->object;
+
+ if (!root)
+ COMPILE_EXCEPTION(obj, tr("Cannot create empty component specification"));
+
+ // Build the component tree
+ COMPILE_CHECK(buildComponentFromRoot(root, ctxt));
+
+ compileState->objectDepth.pop();
+
+ return true;
+}
+
+bool QQmlCompiler::buildComponentFromRoot(QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ ComponentCompileState *oldComponentCompileState = compileState;
+ compileState = pool->New<ComponentCompileState>();
+ compileState->root = obj;
+ compileState->nested = true;
+
+ if (componentStats) {
+ ComponentStat oldComponentStat = componentStats->componentStat;
+
+ componentStats->componentStat = ComponentStat();
+ componentStats->componentStat.lineNumber = obj->location.start.line;
+
+ if (obj)
+ COMPILE_CHECK(buildObject(obj, ctxt));
+
+ COMPILE_CHECK(completeComponentBuild());
+
+ componentStats->componentStat = oldComponentStat;
+ } else {
+ if (obj)
+ COMPILE_CHECK(buildObject(obj, ctxt));
+
+ COMPILE_CHECK(completeComponentBuild());
+ }
+
+ compileState = oldComponentCompileState;
+
+ return true;
+}
+
+
+// Build a sub-object. A sub-object is one that was not created directly by
+// QML - such as a grouped property object, or an attached object. Sub-object's
+// can't have an id, involve a custom parser, have attached properties etc.
+bool QQmlCompiler::buildSubObject(QQmlScript::Object *obj, const BindingContext &ctxt)
+{
+ Q_ASSERT(obj->metatype);
+ Q_ASSERT(!obj->defaultProperty);
+ Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
+ // sub-context
+
+ for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
+ if (isSignalPropertyName(prop->name())) {
+ COMPILE_CHECK(buildSignal(prop, obj, ctxt));
+ } else {
+ COMPILE_CHECK(buildProperty(prop, obj, ctxt));
+ }
+ }
+
+ return true;
+}
+
+int QQmlCompiler::componentTypeRef()
+{
+ if (cachedComponentTypeRef == -1) {
+ QQmlType *t = QQmlMetaType::qmlType(Component_import_string,1,0);
+ for (int ii = output->types.count() - 1; ii >= 0; --ii) {
+ if (output->types.at(ii).type == t) {
+ cachedComponentTypeRef = ii;
+ return ii;
+ }
+ }
+ QQmlCompiledData::TypeReference ref;
+ ref.className = Component_string;
+ ref.type = t;
+ output->types << ref;
+ cachedComponentTypeRef = output->types.count() - 1;
+ }
+ return cachedComponentTypeRef;
+}
+
+int QQmlCompiler::translationContextIndex()
+{
+ if (cachedTranslationContextIndex == -1) {
+ // This code must match that in the qsTr() implementation
+ const QString &path = output->name;
+ int lastSlash = path.lastIndexOf(QLatin1Char('/'));
+ QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, path.length()-lastSlash-5) :
+ QString();
+ QByteArray contextUtf8 = context.toUtf8();
+ cachedTranslationContextIndex = output->indexForByteArray(contextUtf8);
+ }
+ return cachedTranslationContextIndex;
+}
+
+bool QQmlCompiler::buildSignal(QQmlScript::Property *prop, QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(obj->metaObject());
+
+ const QHashedStringRef &propName = prop->name();
+
+ Q_ASSERT(propName.startsWith(on_string));
+ QString name = propName.mid(2, -1).toString();
+
+ // Note that the property name could start with any alpha or '_' or '$' character,
+ // so we need to do the lower-casing of the first alpha character.
+ for (int firstAlphaIndex = 0; firstAlphaIndex < name.size(); ++firstAlphaIndex) {
+ if (name.at(firstAlphaIndex).isUpper()) {
+ name[firstAlphaIndex] = name.at(firstAlphaIndex).toLower();
+ break;
+ }
+ }
+
+ bool notInRevision = false;
+
+ QQmlPropertyData *sig = signal(obj, QStringRef(&name), &notInRevision);
+
+ if (sig == 0) {
+
+ if (notInRevision && 0 == property(obj, propName, 0)) {
+ Q_ASSERT(obj->type != -1);
+ const QList<QQmlTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
+ const QQmlTypeData::TypeReference &type = resolvedTypes.at(obj->type);
+ if (type.type) {
+ COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion));
+ } else {
+ COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(elementName(obj)).arg(prop->name().toString()));
+ }
+ }
+
+ // If the "on<Signal>" name doesn't resolve into a signal, try it as a
+ // property.
+ COMPILE_CHECK(buildProperty(prop, obj, ctxt));
+
+ } else {
+
+ if (prop->value || !prop->values.isOne())
+ COMPILE_EXCEPTION(prop, tr("Incorrectly specified signal assignment"));
+
+ prop->index = sig->coreIndex;
+ prop->core = *sig;
+
+ obj->addSignalProperty(prop);
+
+ if (prop->values.first()->object) {
+ COMPILE_CHECK(buildObject(prop->values.first()->object, ctxt));
+ prop->values.first()->type = Value::SignalObject;
+ } else {
+ prop->values.first()->type = Value::SignalExpression;
+
+ if (!prop->values.first()->value.isScript())
+ COMPILE_EXCEPTION(prop, tr("Cannot assign a value to a signal (expecting a script to be run)"));
+
+ QString script = prop->values.first()->value.asScript().trimmed();
+ if (script.isEmpty())
+ COMPILE_EXCEPTION(prop, tr("Empty signal assignment"));
+
+ prop->values.first()->signalExpressionContextStack = ctxt.stack;
+ }
+ }
+
+ return true;
+}
+
+
+/*!
+ Returns true if (value) property \a prop exists on obj, false otherwise.
+*/
+bool QQmlCompiler::doesPropertyExist(QQmlScript::Property *prop,
+ QQmlScript::Object *obj)
+{
+ if (prop->name().isEmpty())
+ return false;
+ if(isAttachedPropertyName(prop->name()) || prop->name() == id_string)
+ return true;
+
+ return property(obj, prop->name()) != 0;
+}
+
+bool QQmlCompiler::buildProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ if (prop->isEmpty())
+ COMPILE_EXCEPTION(prop, tr("Empty property assignment"));
+
+ const QMetaObject *metaObject = obj->metaObject();
+ Q_ASSERT(metaObject);
+
+ if (isAttachedPropertyName(prop->name())) {
+ // Setup attached property data
+
+ if (ctxt.isSubContext()) {
+ // Attached properties cannot be used on sub-objects. Sub-objects
+ // always exist in a binding sub-context, which is what we test
+ // for here.
+ COMPILE_EXCEPTION(prop, tr("Attached properties cannot be used here"));
+ }
+
+ QQmlType *type = 0;
+ QQmlImportedNamespace *typeNamespace = 0;
+ unit->imports().resolveType(prop->name().toString(), &type, 0, 0, 0, &typeNamespace);
+
+ if (typeNamespace) {
+ COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj,
+ ctxt));
+ return true;
+ } else if (!type || !type->attachedPropertiesType()) {
+ COMPILE_EXCEPTION(prop, tr("Non-existent attached object"));
+ }
+
+ if (!prop->value)
+ COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment"));
+
+ Q_ASSERT(type->attachedPropertiesFunction());
+ prop->index = type->attachedPropertiesId();
+ prop->value->metatype = type->attachedPropertiesType();
+ } else {
+ // Setup regular property data
+ bool notInRevision = false;
+ QQmlPropertyData *d =
+ prop->name().isEmpty()?0:property(obj, prop->name(), &notInRevision);
+
+ if (d == 0 && notInRevision) {
+ const QList<QQmlTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes();
+ const QQmlTypeData::TypeReference &type = resolvedTypes.at(obj->type);
+ if (type.type) {
+ COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion));
+ } else {
+ COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(elementName(obj)).arg(prop->name().toString()));
+ }
+ } else if (d) {
+ prop->index = d->coreIndex;
+ prop->core = *d;
+ } else if (prop->isDefault) {
+ QMetaProperty p = QQmlMetaType::defaultProperty(metaObject);
+ QQmlPropertyData defaultPropertyData;
+ defaultPropertyData.load(p, engine);
+ if (p.name())
+ prop->setName(QLatin1String(p.name()));
+ prop->core = defaultPropertyData;
+ prop->index = prop->core.coreIndex;
+ }
+
+ // We can't error here as the "id" property does not require a
+ // successful index resolution
+ if (prop->index != -1)
+ prop->type = prop->core.propType;
+
+ // Check if this is an alias
+ if (prop->index != -1 &&
+ prop->parent &&
+ prop->parent->type != -1 &&
+ output->types.at(prop->parent->type).component) {
+
+ QQmlPropertyCache *cache = output->types.at(prop->parent->type).component->rootPropertyCache;
+ if (cache && cache->property(prop->index) && cache->property(prop->index)->isAlias())
+ prop->isAlias = true;
+ }
+
+ if (prop->index != -1 && !prop->values.isEmpty())
+ prop->parent->setBindingBit(prop->index);
+ }
+
+ if (!prop->isDefault && prop->name() == id_string && !ctxt.isSubContext()) {
+
+ // The magic "id" behavior doesn't apply when "id" is resolved as a
+ // default property or to sub-objects (which are always in binding
+ // sub-contexts)
+ COMPILE_CHECK(buildIdProperty(prop, obj));
+ if (prop->type == QVariant::String &&
+ prop->values.first()->value.isString())
+ COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
+
+ } else if (isAttachedPropertyName(prop->name())) {
+
+ COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
+
+ } else if (prop->index == -1) {
+
+ if (prop->isDefault) {
+ COMPILE_EXCEPTION(prop->values.first(), tr("Cannot assign to non-existent default property"));
+ } else {
+ COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString()));
+ }
+
+ } else if (prop->value) {
+
+ COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt));
+
+ } else if (prop->core.isQList()) {
+
+ COMPILE_CHECK(buildListProperty(prop, obj, ctxt));
+
+ } else if (prop->type == qMetaTypeId<QQmlScriptString>()) {
+
+ COMPILE_CHECK(buildScriptStringProperty(prop, obj, ctxt));
+
+ } else {
+
+ COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
+
+ }
+
+ return true;
+}
+
+bool QQmlCompiler::buildPropertyInNamespace(QQmlImportedNamespace *ns,
+ QQmlScript::Property *nsProp,
+ QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ if (!nsProp->value)
+ COMPILE_EXCEPTION(nsProp, tr("Invalid use of namespace"));
+
+ for (Property *prop = nsProp->value->properties.first(); prop; prop = nsProp->value->properties.next(prop)) {
+
+ if (!isAttachedPropertyName(prop->name()))
+ COMPILE_EXCEPTION(prop, tr("Not an attached property name"));
+
+ // Setup attached property data
+
+ QQmlType *type = 0;
+ unit->imports().resolveType(ns, prop->name().toString(), &type, 0, 0, 0);
+
+ if (!type || !type->attachedPropertiesType())
+ COMPILE_EXCEPTION(prop, tr("Non-existent attached object"));
+
+ if (!prop->value)
+ COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment"));
+
+ Q_ASSERT(type->attachedPropertiesFunction());
+ prop->index = type->index();
+ prop->value->metatype = type->attachedPropertiesType();
+
+ COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
+ }
+
+ return true;
+}
+
+void QQmlCompiler::genValueProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj)
+{
+ if (prop->core.isQList()) {
+ genListProperty(prop, obj);
+ } else {
+ genPropertyAssignment(prop, obj);
+ }
+}
+
+void QQmlCompiler::genListProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj)
+{
+ int listType = enginePrivate->listType(prop->type);
+
+ Instruction::FetchQList fetch;
+ fetch.property = prop->index;
+ bool listTypeIsInterface = QQmlMetaType::isInterface(listType);
+ fetch.type = listType;
+ output->addInstruction(fetch);
+
+ for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+
+ if (v->type == Value::CreatedObject) {
+
+ genObject(v->object);
+ if (listTypeIsInterface) {
+ Instruction::AssignObjectList assign;
+ assign.line = prop->location.start.line;
+ output->addInstruction(assign);
+ } else {
+ Instruction::StoreObjectQList store;
+ output->addInstruction(store);
+ }
+
+ } else if (v->type == Value::PropertyBinding) {
+
+ genBindingAssignment(v, prop, obj);
+
+ }
+
+ }
+
+ Instruction::PopQList pop;
+ output->addInstruction(pop);
+}
+
+void QQmlCompiler::genPropertyAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Property *valueTypeProperty)
+{
+ for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+
+ Q_ASSERT(v->type == Value::CreatedObject ||
+ v->type == Value::PropertyBinding ||
+ v->type == Value::Literal);
+
+ if (v->type == Value::CreatedObject) {
+
+ genObject(v->object);
+
+ if (QQmlMetaType::isInterface(prop->type)) {
+
+ Instruction::StoreInterface store;
+ store.line = v->object->location.start.line;
+ store.propertyIndex = prop->index;
+ output->addInstruction(store);
+
+ } else if (prop->type == QMetaType::QVariant) {
+
+ if (prop->core.isVMEProperty()) {
+ Instruction::StoreVarObject store;
+ store.line = v->object->location.start.line;
+ store.propertyIndex = prop->index;
+ output->addInstruction(store);
+ } else {
+ Instruction::StoreVariantObject store;
+ store.line = v->object->location.start.line;
+ store.propertyIndex = prop->index;
+ output->addInstruction(store);
+ }
+
+
+ } else {
+
+ Instruction::StoreObject store;
+ store.line = v->object->location.start.line;
+ store.propertyIndex = prop->index;
+ output->addInstruction(store);
+
+ }
+ } else if (v->type == Value::PropertyBinding) {
+
+ genBindingAssignment(v, prop, obj, valueTypeProperty);
+
+ } else if (v->type == Value::Literal) {
+
+ genLiteralAssignment(prop, v);
+
+ }
+
+ }
+
+ for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
+
+ Q_ASSERT(v->type == Value::ValueSource ||
+ v->type == Value::ValueInterceptor);
+
+ if (v->type == Value::ValueSource) {
+ genObject(v->object);
+
+ Instruction::StoreValueSource store;
+ if (valueTypeProperty) {
+ store.property = genValueTypeData(prop, valueTypeProperty);
+ store.owner = 1;
+ } else {
+ store.property = prop->core;
+ store.owner = 0;
+ }
+ QQmlType *valueType = toQmlType(v->object);
+ store.castValue = valueType->propertyValueSourceCast();
+ output->addInstruction(store);
+
+ } else if (v->type == Value::ValueInterceptor) {
+ genObject(v->object);
+
+ Instruction::StoreValueInterceptor store;
+ if (valueTypeProperty) {
+ store.property = genValueTypeData(prop, valueTypeProperty);
+ store.owner = 1;
+ } else {
+ store.property = prop->core;
+ store.owner = 0;
+ }
+ QQmlType *valueType = toQmlType(v->object);
+ store.castValue = valueType->propertyValueInterceptorCast();
+ output->addInstruction(store);
+ }
+
+ }
+}
+
+bool QQmlCompiler::buildIdProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj)
+{
+ if (prop->value ||
+ prop->values.isMany() ||
+ prop->values.first()->object)
+ COMPILE_EXCEPTION(prop, tr("Invalid use of id property"));
+
+ QQmlScript::Value *idValue = prop->values.first();
+ QString val = idValue->primitive();
+
+ COMPILE_CHECK(checkValidId(idValue, val));
+
+ if (compileState->ids.value(val))
+ COMPILE_EXCEPTION(prop, tr("id is not unique"));
+
+ prop->values.first()->type = Value::Id;
+
+ obj->id = val;
+ addId(val, obj);
+
+ return true;
+}
+
+void QQmlCompiler::addId(const QString &id, QQmlScript::Object *obj)
+{
+ Q_UNUSED(id);
+ Q_ASSERT(!compileState->ids.value(id));
+ Q_ASSERT(obj->id == id);
+ obj->idIndex = compileState->ids.count();
+ compileState->ids.append(obj);
+}
+
+void QQmlCompiler::addBindingReference(JSBindingReference *ref)
+{
+ Q_ASSERT(ref->value && !ref->value->bindingReference);
+ ref->value->bindingReference = ref;
+ compileState->totalBindingsCount++;
+ compileState->bindings.prepend(ref);
+}
+
+void QQmlCompiler::saveComponentState()
+{
+ Q_ASSERT(compileState->root);
+ Q_ASSERT(compileState->root->componentCompileState == 0);
+
+ compileState->root->componentCompileState = compileState;
+
+ if (componentStats)
+ componentStats->savedComponentStats.append(componentStats->componentStat);
+}
+
+QQmlCompilerTypes::ComponentCompileState *
+QQmlCompiler::componentState(QQmlScript::Object *obj)
+{
+ Q_ASSERT(obj->componentCompileState);
+ return obj->componentCompileState;
+}
+
+// Build attached property object. In this example,
+// Text {
+// GridView.row: 10
+// }
+// GridView is an attached property object.
+bool QQmlCompiler::buildAttachedProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->value);
+ Q_ASSERT(prop->index != -1); // This is set in buildProperty()
+
+ compileState->objectDepth.push();
+
+ obj->addAttachedProperty(prop);
+
+ COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
+
+ compileState->objectDepth.pop();
+
+ return true;
+}
+
+
+// Build "grouped" properties. In this example:
+// Text {
+// font.pointSize: 12
+// font.family: "Helvetica"
+// }
+// font is a nested property. pointSize and family are not.
+bool QQmlCompiler::buildGroupedProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->type != 0);
+ Q_ASSERT(prop->index != -1);
+
+ if (QQmlValueTypeFactory::isValueType(prop->type)) {
+ if (prop->type >= 0 && enginePrivate->valueTypes[prop->type]) {
+
+ if (!prop->values.isEmpty()) {
+ if (prop->values.first()->location < prop->value->location) {
+ COMPILE_EXCEPTION(prop->value, tr( "Property has already been assigned a value"));
+ } else {
+ COMPILE_EXCEPTION(prop->values.first(), tr( "Property has already been assigned a value"));
+ }
+ }
+
+ if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) {
+ COMPILE_EXCEPTION(prop, tr( "Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
+ }
+
+
+ if (prop->isAlias) {
+ for (Property *vtProp = prop->value->properties.first(); vtProp; vtProp = prop->value->properties.next(vtProp)) {
+ vtProp->isAlias = true;
+ }
+ }
+
+ COMPILE_CHECK(buildValueTypeProperty(enginePrivate->valueTypes[prop->type],
+ prop->value, obj, ctxt.incr()));
+ obj->addValueTypeProperty(prop);
+ } else {
+ COMPILE_EXCEPTION(prop, tr("Invalid grouped property access"));
+ }
+
+ } else {
+ // Load the nested property's meta type
+ prop->value->metatype = enginePrivate->metaObjectForType(prop->type);
+ if (!prop->value->metatype)
+ COMPILE_EXCEPTION(prop, tr("Invalid grouped property access"));
+
+ if (!prop->values.isEmpty())
+ COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign a value directly to a grouped property"));
+
+ obj->addGroupedProperty(prop);
+
+ compileState->objectDepth.push();
+
+ COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
+
+ compileState->objectDepth.pop();
+ }
+
+ return true;
+}
+
+bool QQmlCompiler::buildValueTypeProperty(QObject *type,
+ QQmlScript::Object *obj,
+ QQmlScript::Object *baseObj,
+ const BindingContext &ctxt)
+{
+ compileState->objectDepth.push();
+
+ if (obj->defaultProperty)
+ COMPILE_EXCEPTION(obj, tr("Invalid property use"));
+ obj->metatype = type->metaObject();
+
+ for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
+
+ QQmlPropertyData *d = property(obj, prop->name());
+ if (d == 0)
+ COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString()));
+
+ prop->index = d->coreIndex;
+ prop->type = d->propType;
+ prop->core = *d;
+ prop->isValueTypeSubProperty = true;
+
+ if (prop->value)
+ COMPILE_EXCEPTION(prop, tr("Property assignment expected"));
+
+ if (prop->values.isMany()) {
+ COMPILE_EXCEPTION(prop, tr("Single property assignment expected"));
+ } else if (!prop->values.isEmpty()) {
+ QQmlScript::Value *value = prop->values.first();
+
+ if (value->object) {
+ COMPILE_EXCEPTION(prop, tr("Unexpected object assignment"));
+ } else if (value->value.isScript()) {
+ // ### Check for writability
+
+ //optimization for <Type>.<EnumValue> enum assignments
+ bool isEnumAssignment = false;
+
+ if (prop->core.isEnum())
+ COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, value, &isEnumAssignment));
+
+ if (isEnumAssignment) {
+ value->type = Value::Literal;
+ } else {
+ JSBindingReference *reference = pool->New<JSBindingReference>();
+ reference->expression = value->value;
+ reference->property = prop;
+ reference->value = value;
+ reference->bindingContext = ctxt;
+ reference->bindingContext.owner++;
+ addBindingReference(reference);
+ value->type = Value::PropertyBinding;
+ }
+ } else {
+ COMPILE_CHECK(testLiteralAssignment(prop, value));
+ value->type = Value::Literal;
+ }
+ }
+
+ for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
+ Q_ASSERT(v->object);
+
+ COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt));
+ }
+
+ obj->addValueProperty(prop);
+ }
+
+ compileState->objectDepth.pop();
+
+ return true;
+}
+
+// Build assignments to QML lists. QML lists are properties of type
+// QQmlListProperty<T>. List properties can accept a list of
+// objects, or a single binding.
+bool QQmlCompiler::buildListProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->core.isQList());
+
+ compileState->listDepth.push();
+
+ int t = prop->type;
+
+ obj->addValueProperty(prop);
+
+ int listType = enginePrivate->listType(t);
+ bool listTypeIsInterface = QQmlMetaType::isInterface(listType);
+
+ bool assignedBinding = false;
+ for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+ if (v->object) {
+ v->type = Value::CreatedObject;
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ // We check object coercian here. We check interface assignment
+ // at runtime.
+ if (!listTypeIsInterface) {
+ if (!canCoerce(listType, v->object)) {
+ COMPILE_EXCEPTION(v, tr("Cannot assign object to list"));
+ }
+ }
+
+ } else if (v->value.isScript()) {
+ if (assignedBinding)
+ COMPILE_EXCEPTION(v, tr("Can only assign one binding to lists"));
+
+ assignedBinding = true;
+ COMPILE_CHECK(buildBinding(v, prop, ctxt));
+ v->type = Value::PropertyBinding;
+ } else {
+ COMPILE_EXCEPTION(v, tr("Cannot assign primitives to lists"));
+ }
+ }
+
+ compileState->listDepth.pop();
+
+ return true;
+}
+
+// Compiles an assignment to a QQmlScriptString property
+bool QQmlCompiler::buildScriptStringProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ if (prop->values.isMany())
+ COMPILE_EXCEPTION(prop->values.first()->nextValue, tr( "Cannot assign multiple values to a script property"));
+
+ if (prop->values.first()->object)
+ COMPILE_EXCEPTION(prop->values.first(), tr( "Invalid property assignment: script expected"));
+
+ prop->scriptStringScope = ctxt.stack;
+ obj->addScriptStringProperty(prop);
+
+ return true;
+}
+
+// Compile regular property assignments of the form "property: <value>"
+bool QQmlCompiler::buildPropertyAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const BindingContext &ctxt)
+{
+ obj->addValueProperty(prop);
+
+ if (prop->values.isMany())
+ COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign multiple values to a singular property") );
+
+ for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+ if (v->object) {
+
+ COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
+
+ } else {
+
+ COMPILE_CHECK(buildPropertyLiteralAssignment(prop, obj, v, ctxt));
+
+ }
+ }
+
+ for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
+ Q_ASSERT(v->object);
+ COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt));
+ }
+
+ return true;
+}
+
+// Compile assigning a single object instance to a regular property
+bool QQmlCompiler::buildPropertyObjectAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Value *v,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+ Q_ASSERT(v->object->type != -1);
+
+ if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration)
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
+
+ if (QQmlMetaType::isInterface(prop->type)) {
+
+ // Assigning an object to an interface ptr property
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ v->type = Value::CreatedObject;
+
+ } else if (prop->type == QMetaType::QVariant) {
+
+ // Assigning an object to a QVariant
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ v->type = Value::CreatedObject;
+ } else {
+ // Normally buildObject() will set this up, but we need the static
+ // meta object earlier to test for assignability. It doesn't matter
+ // that there may still be outstanding synthesized meta object changes
+ // on this type, as they are not relevant for assignability testing
+ v->object->metatype = output->types.at(v->object->type).metaObject();
+ Q_ASSERT(v->object->metaObject());
+
+ // We want to raw metaObject here as the raw metaobject is the
+ // actual property type before we applied any extensions that might
+ // effect the properties on the type, but don't effect assignability
+ const QMetaObject *propertyMetaObject = enginePrivate->rawMetaObjectForType(prop->type);
+
+ // Will be true if the assgned type inherits propertyMetaObject
+ bool isAssignable = false;
+ // Determine isAssignable value
+ if (propertyMetaObject) {
+ const QMetaObject *c = v->object->metatype;
+ while(c) {
+ isAssignable |= (QQmlPropertyPrivate::equal(c, propertyMetaObject));
+ c = c->superClass();
+ }
+ }
+
+ if (isAssignable) {
+ // Simple assignment
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ v->type = Value::CreatedObject;
+ } else if (propertyMetaObject == &QQmlComponent::staticMetaObject) {
+ // Automatic "Component" insertion
+ QQmlScript::Object *root = v->object;
+ QQmlScript::Object *component = pool->New<Object>();
+ component->type = componentTypeRef();
+ component->typeName = QStringLiteral("Qt/Component");
+ component->metatype = &QQmlComponent::staticMetaObject;
+ component->location = root->location;
+ QQmlScript::Value *componentValue = pool->New<Value>();
+ componentValue->object = root;
+ component->getDefaultProperty()->addValue(componentValue);
+ v->object = component;
+ COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
+ } else {
+ COMPILE_EXCEPTION(v->object, tr("Cannot assign object to property"));
+ }
+ }
+
+ return true;
+}
+
+// Compile assigning a single object instance to a regular property using the "on" syntax.
+//
+// For example:
+// Item {
+// NumberAnimation on x { }
+// }
+bool QQmlCompiler::buildPropertyOnAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Object *baseObj,
+ QQmlScript::Value *v,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+ Q_ASSERT(v->object->type != -1);
+
+ Q_UNUSED(obj);
+
+ if (!prop->core.isWritable())
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
+
+
+ // Normally buildObject() will set this up, but we need the static
+ // meta object earlier to test for assignability. It doesn't matter
+ // that there may still be outstanding synthesized meta object changes
+ // on this type, as they are not relevant for assignability testing
+ v->object->metatype = output->types.at(v->object->type).metaObject();
+ Q_ASSERT(v->object->metaObject());
+
+ // Will be true if the assigned type inherits QQmlPropertyValueSource
+ bool isPropertyValue = false;
+ // Will be true if the assigned type inherits QQmlPropertyValueInterceptor
+ bool isPropertyInterceptor = false;
+ if (QQmlType *valueType = toQmlType(v->object)) {
+ isPropertyValue = valueType->propertyValueSourceCast() != -1;
+ isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1;
+ }
+
+ if (isPropertyValue || isPropertyInterceptor) {
+ // Assign as a property value source
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ if (isPropertyInterceptor && prop->parent->synthdata.isEmpty())
+ buildDynamicMeta(baseObj, ForceCreation);
+ v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
+ } else {
+ COMPILE_EXCEPTION(v, tr("\"%1\" cannot operate on \"%2\"").arg(v->object->typeName).arg(prop->name().toString()));
+ }
+
+ return true;
+}
+
+// Compile assigning a literal or binding to a regular property
+bool QQmlCompiler::buildPropertyLiteralAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Value *v,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+
+ if (v->value.isScript()) {
+
+ //optimization for <Type>.<EnumValue> enum assignments
+ if (prop->core.isEnum()) {
+ bool isEnumAssignment = false;
+ COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, v, &isEnumAssignment));
+ if (isEnumAssignment) {
+ v->type = Value::Literal;
+ return true;
+ }
+ }
+
+ // Test for other binding optimizations
+ if (!buildLiteralBinding(v, prop, ctxt))
+ COMPILE_CHECK(buildBinding(v, prop, ctxt));
+
+ v->type = Value::PropertyBinding;
+
+ } else {
+
+ COMPILE_CHECK(testLiteralAssignment(prop, v));
+
+ v->type = Value::Literal;
+ }
+
+ return true;
+}
+
+bool QQmlCompiler::testQualifiedEnumAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Value *v,
+ bool *isAssignment)
+{
+ *isAssignment = false;
+ if (!prop->core.isEnum())
+ return true;
+
+ QMetaProperty mprop = obj->metaObject()->property(prop->index);
+
+ if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration)
+ COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
+
+ QString string = v->value.asString();
+ if (!string.at(0).isUpper())
+ return true;
+
+ QStringList parts = string.split(QLatin1Char('.'));
+ if (parts.count() != 2)
+ return true;
+
+ QString typeName = parts.at(0);
+ QQmlType *type = 0;
+ unit->imports().resolveType(typeName, &type, 0, 0, 0, 0);
+
+ //handle enums on value types (where obj->typeName is empty)
+ QString objTypeName = obj->typeName;
+ if (objTypeName.isEmpty()) {
+ QQmlType *objType = toQmlType(obj);
+ if (objType)
+ objTypeName = objType->qmlTypeName();
+ }
+
+ if (!type)
+ return true;
+
+ QString enumValue = parts.at(1);
+ int value;
+ bool ok;
+
+ if (objTypeName == type->qmlTypeName()) {
+ // When these two match, we can short cut the search
+ if (mprop.isFlagType()) {
+ value = mprop.enumerator().keysToValue(enumValue.toUtf8().constData(), &ok);
+ } else {
+ value = mprop.enumerator().keyToValue(enumValue.toUtf8().constData(), &ok);
+ }
+ } else {
+ // Otherwise we have to search the whole type
+ // This matches the logic in QV8TypeWrapper
+ QByteArray enumName = enumValue.toUtf8();
+ const QMetaObject *metaObject = type->baseMetaObject();
+ ok = false;
+ for (int ii = metaObject->enumeratorCount() - 1; !ok && ii >= 0; --ii) {
+ QMetaEnum e = metaObject->enumerator(ii);
+ value = e.keyToValue(enumName.constData(), &ok);
+ }
+ }
+
+ if (!ok)
+ return true;
+
+ v->type = Value::Literal;
+ v->value = QQmlScript::Variant((double)value);
+ *isAssignment = true;
+
+ return true;
+}
+
+struct StaticQtMetaObject : public QObject
+{
+ static const QMetaObject *get()
+ { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
+};
+
+// Similar logic to above, but not knowing target property.
+int QQmlCompiler::evaluateEnum(const QByteArray& script) const
+{
+ int dot = script.indexOf('.');
+ if (dot > 0) {
+ const QByteArray &scope = script.left(dot);
+ QQmlType *type = 0;
+ unit->imports().resolveType(QString::fromUtf8(script.left(dot)), &type, 0, 0, 0, 0);
+ if (!type && scope != "Qt")
+ return -1;
+ const QMetaObject *mo = type ? type->metaObject() : StaticQtMetaObject::get();
+ const char *key = script.constData() + dot+1;
+ int i = mo->enumeratorCount();
+ while (i--) {
+ bool ok;
+ int v = mo->enumerator(i).keyToValue(key, &ok);
+ if (ok)
+ return v;
+ }
+ }
+ return -1;
+}
+
+const QMetaObject *QQmlCompiler::resolveType(const QString& name) const
+{
+ QQmlType *qmltype = 0;
+ if (!unit->imports().resolveType(name, &qmltype, 0, 0, 0, 0))
+ return 0;
+ if (!qmltype)
+ return 0;
+ return qmltype->metaObject();
+}
+
+// similar to logic of completeComponentBuild, but also sticks data
+// into primitives at the end
+int QQmlCompiler::rewriteBinding(const QQmlScript::Variant& value, const QString& name)
+{
+ QQmlRewrite::RewriteBinding rewriteBinding;
+ rewriteBinding.setName(QLatin1Char('$') + name.mid(name.lastIndexOf(QLatin1Char('.')) + 1));
+
+ QString rewrite = rewriteBinding(value.asAST(), value.asScript(), 0);
+
+ return output->indexForString(rewrite);
+}
+
+QString QQmlCompiler::rewriteSignalHandler(const QQmlScript::Variant& value, const QString &name)
+{
+ QQmlRewrite::RewriteSignalHandler rewriteSignalHandler;
+ return rewriteSignalHandler(value.asAST(), value.asScript(), name);
+}
+
+// Ensures that the dynamic meta specification on obj is valid
+bool QQmlCompiler::checkDynamicMeta(QQmlScript::Object *obj)
+{
+ bool seenDefaultProperty = false;
+
+ // We use a coarse grain, 31 bit hash to check if there are duplicates.
+ // Calculating the hash for the names is not a waste as we have to test
+ // them against the illegalNames set anyway.
+ QHashField propNames;
+ QHashField methodNames;
+
+ // Check properties
+ for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
+ const QQmlScript::Object::DynamicProperty &prop = *p;
+
+ if (prop.isDefaultProperty) {
+ if (seenDefaultProperty)
+ COMPILE_EXCEPTION(&prop, tr("Duplicate default property"));
+ seenDefaultProperty = true;
+ }
+
+ if (propNames.testAndSet(prop.name.hash())) {
+ for (Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p;
+ p2 = obj->dynamicProperties.next(p2)) {
+ if (p2->name == prop.name) {
+ COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line,
+ prop.nameLocation.column,
+ tr("Duplicate property name"));
+ }
+ }
+ }
+
+ if (prop.name.at(0).isUpper()) {
+ COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line,
+ prop.nameLocation.column,
+ tr("Property names cannot begin with an upper case letter"));
+ }
+
+ if (enginePrivate->v8engine()->illegalNames().contains(prop.name)) {
+ COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line,
+ prop.nameLocation.column,
+ tr("Illegal property name"));
+ }
+ }
+
+ for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
+ const QQmlScript::Object::DynamicSignal &currSig = *s;
+
+ if (methodNames.testAndSet(currSig.name.hash())) {
+ for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2 != s;
+ s2 = obj->dynamicSignals.next(s2)) {
+ if (s2->name == currSig.name)
+ COMPILE_EXCEPTION(&currSig, tr("Duplicate signal name"));
+ }
+ }
+
+ if (currSig.name.at(0).isUpper())
+ COMPILE_EXCEPTION(&currSig, tr("Signal names cannot begin with an upper case letter"));
+ if (enginePrivate->v8engine()->illegalNames().contains(currSig.name))
+ COMPILE_EXCEPTION(&currSig, tr("Illegal signal name"));
+ }
+
+ for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
+ const QQmlScript::Object::DynamicSlot &currSlot = *s;
+
+ if (methodNames.testAndSet(currSlot.name.hash())) {
+ for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2;
+ s2 = obj->dynamicSignals.next(s2)) {
+ if (s2->name == currSlot.name)
+ COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name"));
+ }
+ for (Object::DynamicSlot *s2 = obj->dynamicSlots.first(); s2 != s;
+ s2 = obj->dynamicSlots.next(s2)) {
+ if (s2->name == currSlot.name)
+ COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name"));
+ }
+ }
+
+ if (currSlot.name.at(0).isUpper())
+ COMPILE_EXCEPTION(&currSlot, tr("Method names cannot begin with an upper case letter"));
+ if (enginePrivate->v8engine()->illegalNames().contains(currSlot.name))
+ COMPILE_EXCEPTION(&currSlot, tr("Illegal method name"));
+ }
+
+ return true;
+}
+
+bool QQmlCompiler::mergeDynamicMetaProperties(QQmlScript::Object *obj)
+{
+ for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
+ p = obj->dynamicProperties.next(p)) {
+
+ if (!p->defaultValue || p->type == Object::DynamicProperty::Alias)
+ continue;
+
+ Property *property = 0;
+ if (p->isDefaultProperty) {
+ property = obj->getDefaultProperty();
+ } else {
+ property = obj->getProperty(p->name);
+ if (!property->values.isEmpty())
+ COMPILE_EXCEPTION(property, tr("Property value set multiple times"));
+ }
+
+ if (p->isReadOnly)
+ property->isReadOnlyDeclaration = true;
+
+ if (property->value)
+ COMPILE_EXCEPTION(property, tr("Invalid property nesting"));
+
+ property->values.append(p->defaultValue->values);
+ }
+ return true;
+}
+
+Q_GLOBAL_STATIC(QAtomicInt, classIndexCounter)
+
+bool QQmlCompiler::buildDynamicMeta(QQmlScript::Object *obj, DynamicMetaMode mode)
+{
+ Q_ASSERT(obj);
+ Q_ASSERT(obj->metatype);
+
+ if (mode != ForceCreation &&
+ obj->dynamicProperties.isEmpty() &&
+ obj->dynamicSignals.isEmpty() &&
+ obj->dynamicSlots.isEmpty())
+ return true;
+
+ bool resolveAlias = (mode == ResolveAliases);
+
+ const Object::DynamicProperty *defaultProperty = 0;
+ int aliasCount = 0;
+ int varPropCount = 0;
+ int totalPropCount = 0;
+ int firstPropertyVarIndex = 0;
+
+ for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
+
+ if (p->type == Object::DynamicProperty::Alias)
+ aliasCount++;
+ if (p->type == Object::DynamicProperty::Var)
+ varPropCount++;
+
+ if (p->isDefaultProperty &&
+ (resolveAlias || p->type != Object::DynamicProperty::Alias))
+ defaultProperty = p;
+
+ if (!resolveAlias) {
+ // No point doing this for both the alias and non alias cases
+ QQmlPropertyData *d = property(obj, p->name);
+ if (d && d->isFinal())
+ COMPILE_EXCEPTION(p, tr("Cannot override FINAL property"));
+ }
+ }
+
+ bool buildData = resolveAlias || aliasCount == 0;
+
+ QByteArray dynamicData;
+ if (buildData) {
+ typedef QQmlVMEMetaData VMD;
+
+ dynamicData = QByteArray(sizeof(QQmlVMEMetaData) +
+ (obj->dynamicProperties.count() - aliasCount) * sizeof(VMD::PropertyData) +
+ obj->dynamicSlots.count() * sizeof(VMD::MethodData) +
+ aliasCount * sizeof(VMD::AliasData), 0);
+ }
+
+ int uniqueClassId = classIndexCounter()->fetchAndAddRelaxed(1);
+
+ QByteArray newClassName = obj->metatype->className();
+ newClassName.append("_QML_");
+ newClassName.append(QByteArray::number(uniqueClassId));
+
+ if (compileState->root == obj && !compileState->nested) {
+ QString path = output->url.path();
+ int lastSlash = path.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash > -1) {
+ QString nameBase = path.mid(lastSlash + 1, path.length()-lastSlash-5);
+ if (!nameBase.isEmpty() && nameBase.at(0).isUpper())
+ newClassName = nameBase.toUtf8() + "_QMLTYPE_" + QByteArray::number(uniqueClassId);
+ }
+ }
+
+ QFastMetaBuilder builder;
+ QFastMetaBuilder::StringRef classNameRef = builder.init(newClassName.length(),
+ obj->dynamicProperties.count() - (resolveAlias?0:aliasCount),
+ obj->dynamicSlots.count(),
+ obj->dynamicSignals.count() + obj->dynamicProperties.count(),
+ defaultProperty?1:0);
+
+ struct TypeData {
+ Object::DynamicProperty::Type dtype;
+ int metaType;
+ const char *cppType;
+ } builtinTypes[] = {
+ { Object::DynamicProperty::Var, QMetaType::QVariant, "QVariant" },
+ { Object::DynamicProperty::Variant, QMetaType::QVariant, "QVariant" },
+ { Object::DynamicProperty::Int, QMetaType::Int, "int" },
+ { Object::DynamicProperty::Bool, QMetaType::Bool, "bool" },
+ { Object::DynamicProperty::Real, QMetaType::Double, "double" },
+ { Object::DynamicProperty::String, QMetaType::QString, "QString" },
+ { Object::DynamicProperty::Url, QMetaType::QUrl, "QUrl" },
+ { Object::DynamicProperty::Color, QMetaType::QColor, "QColor" },
+ { Object::DynamicProperty::Time, QMetaType::QTime, "QTime" },
+ { Object::DynamicProperty::Date, QMetaType::QDate, "QDate" },
+ { Object::DynamicProperty::DateTime, QMetaType::QDateTime, "QDateTime" },
+ };
+ static const int builtinTypeCount = sizeof(builtinTypes) / sizeof(TypeData);
+ QFastMetaBuilder::StringRef typeRefs[builtinTypeCount];
+
+ // Reserve dynamic properties
+ if (obj->dynamicProperties.count()) {
+ typedef QQmlVMEMetaData VMD;
+
+ int effectivePropertyIndex = 0;
+ for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
+
+ // Reserve space for name
+ p->nameRef = builder.newString(p->name.utf8length());
+
+ int propertyType = 0;
+ bool readonly = false;
+ QFastMetaBuilder::StringRef typeRef;
+
+ if (p->type == Object::DynamicProperty::Alias) {
+ continue;
+ } else if (p->type < builtinTypeCount) {
+ Q_ASSERT(builtinTypes[p->type].dtype == p->type);
+ propertyType = builtinTypes[p->type].metaType;
+ if (typeRefs[p->type].isEmpty())
+ typeRefs[p->type] = builder.newString(strlen(builtinTypes[p->type].cppType));
+ typeRef = typeRefs[p->type];
+
+ } else {
+ Q_ASSERT(p->type == Object::DynamicProperty::CustomList ||
+ p->type == Object::DynamicProperty::Custom);
+
+ // XXX don't double resolve this in the case of an alias run
+
+ QByteArray customTypeName;
+ QQmlType *qmltype = 0;
+ QString url;
+ if (!unit->imports().resolveType(p->customType.toString(), &qmltype, &url, 0, 0, 0))
+ COMPILE_EXCEPTION(p, tr("Invalid property type"));
+
+ if (!qmltype) {
+ QQmlTypeData *tdata = enginePrivate->typeLoader.get(QUrl(url));
+ Q_ASSERT(tdata);
+ Q_ASSERT(tdata->isComplete());
+
+ QQmlCompiledData *data = tdata->compiledData();
+ customTypeName = data->root->className();
+ data->release();
+ tdata->release();
+ } else {
+ customTypeName = qmltype->typeName();
+ }
+
+ if (p->type == Object::DynamicProperty::Custom) {
+ customTypeName += '*';
+ propertyType = QMetaType::QObjectStar;
+ } else {
+ readonly = true;
+ customTypeName = QByteArray("QQmlListProperty<") + customTypeName + QByteArray(">");
+ propertyType = qMetaTypeId<QQmlListProperty<QObject> >();
+ }
+
+ p->resolvedCustomTypeName = pool->NewByteArray(customTypeName);
+ p->typeRef = builder.newString(customTypeName.length());
+ typeRef = p->typeRef;
+ }
+
+ if (p->type == Object::DynamicProperty::Var)
+ continue;
+
+ if (p->isReadOnly)
+ readonly = true;
+
+ if (buildData) {
+ VMD *vmd = (QQmlVMEMetaData *)dynamicData.data();
+ vmd->propertyCount++;
+ (vmd->propertyData() + effectivePropertyIndex)->propertyType = propertyType;
+ }
+
+ if (p->type < builtinTypeCount)
+ builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef, (QMetaType::Type)propertyType,
+ readonly?QFastMetaBuilder::None:QFastMetaBuilder::Writable,
+ effectivePropertyIndex);
+ else
+ builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef,
+ readonly?QFastMetaBuilder::None:QFastMetaBuilder::Writable,
+ effectivePropertyIndex);
+
+ p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()"));
+ builder.setSignal(effectivePropertyIndex, p->changedSignatureRef);
+
+ effectivePropertyIndex++;
+ }
+
+ if (varPropCount) {
+ VMD *vmd = (QQmlVMEMetaData *)dynamicData.data();
+ if (buildData)
+ vmd->varPropertyCount = varPropCount;
+ firstPropertyVarIndex = effectivePropertyIndex;
+ totalPropCount = varPropCount + effectivePropertyIndex;
+ for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
+ if (p->type == Object::DynamicProperty::Var) {
+ QFastMetaBuilder::StringRef typeRef = typeRefs[p->type];
+ if (buildData) {
+ vmd->propertyCount++;
+ (vmd->propertyData() + effectivePropertyIndex)->propertyType = QMetaType::QVariant;
+ }
+
+ builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef,
+ QMetaType::QVariant,
+ p->isReadOnly?QFastMetaBuilder::None:QFastMetaBuilder::Writable,
+ effectivePropertyIndex);
+
+ p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()"));
+ builder.setSignal(effectivePropertyIndex, p->changedSignatureRef);
+
+ effectivePropertyIndex++;
+ }
+ }
+ }
+
+ if (aliasCount) {
+ int aliasIndex = 0;
+ for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
+ if (p->type == Object::DynamicProperty::Alias) {
+ if (resolveAlias) {
+ Q_ASSERT(buildData);
+ ((QQmlVMEMetaData *)dynamicData.data())->aliasCount++;
+ COMPILE_CHECK(compileAlias(builder, dynamicData, obj, effectivePropertyIndex,
+ aliasIndex, *p));
+ }
+ // Even if we aren't resolving the alias, we need a fake signal so that the
+ // metaobject remains consistent across the resolve and non-resolve alias runs
+ p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()"));
+ builder.setSignal(effectivePropertyIndex, p->changedSignatureRef);
+ effectivePropertyIndex++;
+ aliasIndex++;
+ }
+ }
+ }
+ }
+
+ // Reserve default property
+ QFastMetaBuilder::StringRef defPropRef;
+ if (defaultProperty) {
+ defPropRef = builder.newString(strlen("DefaultProperty"));
+ builder.setClassInfo(0, defPropRef, defaultProperty->nameRef);
+ }
+
+ // Reserve dynamic signals
+ int signalIndex = 0;
+ for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
+
+ int paramCount = s->parameterNames.count();
+
+ int signatureSize = s->name.utf8length() + 2 /* paren */;
+ int namesSize = 0;
+ if (paramCount) signatureSize += s->parameterTypesLength() + (paramCount - 1) /* commas */;
+ if (paramCount) namesSize += s->parameterNamesLength() + (paramCount - 1) /* commas */;
+
+ s->signatureRef = builder.newString(signatureSize);
+ if (namesSize) s->parameterNamesRef = builder.newString(namesSize);
+
+ if (buildData)
+ ((QQmlVMEMetaData *)dynamicData.data())->signalCount++;
+
+ builder.setSignal(signalIndex + obj->dynamicProperties.count(), s->signatureRef, s->parameterNamesRef);
+ ++signalIndex;
+ }
+
+ // Reserve dynamic slots
+ if (obj->dynamicSlots.count()) {
+
+ // Allocate QVariant string
+ if (typeRefs[0].isEmpty())
+ typeRefs[0] = builder.newString(strlen(builtinTypes[0].cppType));
+
+ typedef QQmlVMEMetaData VMD;
+
+ int methodIndex = 0;
+ for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
+ int paramCount = s->parameterNames.count();
+
+ int signatureSize = s->name.utf8length() + 2 /* paren */;
+ int namesSize = 0;
+ if (paramCount) signatureSize += (paramCount * strlen("QVariant") + (paramCount - 1));
+ if (paramCount) namesSize += s->parameterNamesLength() + (paramCount - 1 /* commas */);
+
+ s->signatureRef = builder.newString(signatureSize);
+ if (namesSize) s->parameterNamesRef = builder.newString(namesSize);
+
+ builder.setMethod(methodIndex, s->signatureRef, s->parameterNamesRef, typeRefs[0]);
+
+ if (buildData) {
+ QString funcScript;
+ funcScript.reserve(strlen("(function ") + s->name.length() + 1 /* lparen */ +
+ namesSize + 1 /* rparen */ + s->body.length() + 1 /* rparen */);
+ funcScript = QLatin1String("(function ") + s->name.toString() + QLatin1Char('(');
+ for (int jj = 0; jj < paramCount; ++jj) {
+ if (jj) funcScript.append(QLatin1Char(','));
+ funcScript.append(QLatin1String(s->parameterNames.at(jj)));
+ }
+ funcScript += QLatin1Char(')') + s->body + QLatin1Char(')');
+
+ QByteArray utf8 = funcScript.toUtf8();
+ VMD::MethodData methodData = { s->parameterNames.count(), 0,
+ utf8.length(),
+ s->location.start.line };
+
+ VMD *vmd = (QQmlVMEMetaData *)dynamicData.data();
+ vmd->methodCount++;
+
+ VMD::MethodData &md = *(vmd->methodData() + methodIndex);
+ md = methodData;
+ md.bodyOffset = dynamicData.size();
+
+ dynamicData.append((const char *)utf8.constData(), utf8.length());
+ }
+
+
+ methodIndex++;
+ }
+ }
+
+ // Now allocate used builtin types
+ for (int ii = 0; ii < builtinTypeCount; ++ii) {
+ if (!typeRefs[ii].isEmpty())
+ typeRefs[ii].load(builtinTypes[ii].cppType);
+ }
+
+ // Now allocate properties
+ for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
+
+ char *d = p->changedSignatureRef.data();
+ p->name.writeUtf8(d);
+ strcpy(d + p->name.utf8length(), "Changed()");
+
+ if (p->type == Object::DynamicProperty::Alias && !resolveAlias)
+ continue;
+
+ p->nameRef.load(p->name);
+
+ if (p->type >= builtinTypeCount) {
+ Q_ASSERT(p->resolvedCustomTypeName);
+ p->typeRef.load(*p->resolvedCustomTypeName);
+ }
+ }
+
+ // Allocate default property if necessary
+ if (defaultProperty)
+ strcpy(defPropRef.data(), "DefaultProperty");
+
+ // Now allocate signals
+ for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
+
+ char *d = s->signatureRef.data();
+ char *d2 = s->parameterNamesRef.isEmpty()?0:s->parameterNamesRef.data();
+ s->name.writeUtf8(d); d += s->name.utf8length();
+ *d++ = '(';
+
+ for (int jj = 0; jj < s->parameterNames.count(); ++jj) {
+ if (jj != 0) { *d++ = ','; *d2++ = ','; }
+ strcpy(d, s->parameterTypes.at(jj).constData());
+ d += s->parameterTypes.at(jj).length();
+ s->parameterNames.at(jj).writeUtf8(d2);
+ d2 += s->parameterNames.at(jj).utf8length();
+ }
+ *d++ = ')';
+ *d = 0;
+ if (d2) *d2 = 0;
+ }
+
+ // Now allocate methods
+ for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
+ char *d = s->signatureRef.data();
+ char *d2 = s->parameterNamesRef.isEmpty()?0:s->parameterNamesRef.data();
+ s->name.writeUtf8(d); d += s->name.utf8length();
+ *d++ = '(';
+ for (int jj = 0; jj < s->parameterNames.count(); ++jj) {
+ if (jj != 0) { *d++ = ','; *d2++ = ','; }
+ strcpy(d, "QVariant");
+ d += strlen("QVariant");
+ strcpy(d2, s->parameterNames.at(jj).constData());
+ d2 += s->parameterNames.at(jj).length();
+ }
+ *d++ = ')';
+ *d = 0;
+ if (d2) *d2 = 0;
+ }
+
+ // Now allocate class name
+ classNameRef.load(newClassName);
+
+ obj->metadata = builder.toData();
+ builder.fromData(&obj->extObject, obj->metatype, obj->metadata);
+
+ if (mode == IgnoreAliases && aliasCount)
+ compileState->aliasingObjects.append(obj);
+
+ obj->synthdata = dynamicData;
+
+ if (obj->synthCache) {
+ obj->synthCache->release();
+ obj->synthCache = 0;
+ }
+
+ if (obj->type != -1) {
+ QQmlPropertyCache *superCache = output->types[obj->type].createPropertyCache(engine);
+ QQmlPropertyCache *cache =
+ superCache->copyAndAppend(engine, &obj->extObject,
+ QQmlPropertyData::NoFlags,
+ QQmlPropertyData::IsVMEFunction,
+ QQmlPropertyData::IsVMESignal);
+
+ // now we modify the flags appropriately for var properties.
+ int propertyOffset = obj->extObject.propertyOffset();
+ QQmlPropertyData *currPropData = 0;
+ for (int pvi = firstPropertyVarIndex; pvi < totalPropCount; ++pvi) {
+ currPropData = cache->property(pvi + propertyOffset);
+ currPropData->setFlags(currPropData->getFlags() | QQmlPropertyData::IsVMEProperty);
+ }
+
+ obj->synthCache = cache;
+ }
+
+ return true;
+}
+
+bool QQmlCompiler::checkValidId(QQmlScript::Value *v, const QString &val)
+{
+ if (val.isEmpty())
+ COMPILE_EXCEPTION(v, tr( "Invalid empty ID"));
+
+ QChar ch = val.at(0);
+ if (ch.isLetter() && !ch.isLower())
+ COMPILE_EXCEPTION(v, tr( "IDs cannot start with an uppercase letter"));
+
+ QChar u(QLatin1Char('_'));
+ if (!ch.isLetter() && ch != u)
+ COMPILE_EXCEPTION(v, tr( "IDs must start with a letter or underscore"));
+
+ for (int ii = 1; ii < val.count(); ++ii) {
+ ch = val.at(ii);
+ if (!ch.isLetterOrNumber() && ch != u)
+ COMPILE_EXCEPTION(v, tr( "IDs must contain only letters, numbers, and underscores"));
+ }
+
+ if (enginePrivate->v8engine()->illegalNames().contains(val))
+ COMPILE_EXCEPTION(v, tr( "ID illegally masks global JavaScript property"));
+
+ return true;
+}
+
+#include <private/qqmljsparser_p.h>
+
+static QStringList astNodeToStringList(QQmlJS::AST::Node *node)
+{
+ if (node->kind == QQmlJS::AST::Node::Kind_IdentifierExpression) {
+ QString name =
+ static_cast<QQmlJS::AST::IdentifierExpression *>(node)->name.toString();
+ return QStringList() << name;
+ } else if (node->kind == QQmlJS::AST::Node::Kind_FieldMemberExpression) {
+ QQmlJS::AST::FieldMemberExpression *expr = static_cast<QQmlJS::AST::FieldMemberExpression *>(node);
+
+ QStringList rv = astNodeToStringList(expr->base);
+ if (rv.isEmpty())
+ return rv;
+ rv.append(expr->name.toString());
+ return rv;
+ }
+ return QStringList();
+}
+
+bool QQmlCompiler::compileAlias(QFastMetaBuilder &builder,
+ QByteArray &data,
+ QQmlScript::Object *obj,
+ int propIndex, int aliasIndex,
+ Object::DynamicProperty &prop)
+{
+ if (!prop.defaultValue)
+ COMPILE_EXCEPTION(obj, tr("No property alias location"));
+
+ if (!prop.defaultValue->values.isOne() ||
+ prop.defaultValue->values.first()->object ||
+ !prop.defaultValue->values.first()->value.isScript())
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
+
+ QQmlJS::AST::Node *node = prop.defaultValue->values.first()->value.asAST();
+ if (!node)
+ COMPILE_EXCEPTION(obj, tr("No property alias location")); // ### Can this happen?
+
+ QStringList alias = astNodeToStringList(node);
+
+ if (alias.count() < 1 || alias.count() > 3)
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>"));
+
+ QQmlScript::Object *idObject = compileState->ids.value(alias.at(0));
+ if (!idObject)
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0)));
+
+ QByteArray typeName;
+
+ int propIdx = -1;
+ int flags = 0;
+ int type = 0;
+ bool writable = false;
+ bool resettable = false;
+ if (alias.count() == 2 || alias.count() == 3) {
+ propIdx = indexOfProperty(idObject, alias.at(1));
+
+ if (-1 == propIdx) {
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
+ } else if (propIdx > 0xFFFF) {
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Alias property exceeds alias bounds"));
+ }
+
+ QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx);
+ if (!aliasProperty.isScriptable())
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
+
+ writable = aliasProperty.isWritable() && !prop.isReadOnly;
+ resettable = aliasProperty.isResettable() && !prop.isReadOnly;
+
+ if (aliasProperty.type() < QVariant::UserType
+ || uint(aliasProperty.type()) == QMetaType::QVariant)
+ type = aliasProperty.type();
+
+ if (alias.count() == 3) {
+ QQmlValueType *valueType = enginePrivate->valueTypes[aliasProperty.type()];
+ if (!valueType)
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
+
+ propIdx |= ((unsigned int)aliasProperty.type()) << 24;
+
+ int valueTypeIndex = valueType->metaObject()->indexOfProperty(alias.at(2).toUtf8().constData());
+ if (valueTypeIndex == -1)
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
+ Q_ASSERT(valueTypeIndex <= 0xFF);
+
+ aliasProperty = valueType->metaObject()->property(valueTypeIndex);
+ propIdx |= (valueTypeIndex << 16);
+
+ // update the property type
+ type = aliasProperty.type();
+ if (type >= (int)QVariant::UserType)
+ type = 0;
+ }
+
+ if (aliasProperty.isEnumType())
+ typeName = "int"; // Avoid introducing a dependency on the aliased metaobject
+ else
+ typeName = aliasProperty.typeName();
+ } else {
+ Q_ASSERT(idObject->type != -1); // How else did it get an id?
+
+ const QQmlCompiledData::TypeReference &ref = output->types.at(idObject->type);
+ if (ref.type)
+ typeName = ref.type->typeName();
+ else
+ typeName = ref.component->root->className();
+
+ typeName += '*';
+ }
+
+ if (typeName.endsWith('*'))
+ flags |= QML_ALIAS_FLAG_PTR;
+
+ QQmlVMEMetaData::AliasData aliasData = { idObject->idIndex, propIdx, flags };
+
+ typedef QQmlVMEMetaData VMD;
+ VMD *vmd = (QQmlVMEMetaData *)data.data();
+ *(vmd->aliasData() + aliasIndex) = aliasData;
+
+ prop.nameRef = builder.newString(prop.name.utf8length());
+ prop.resolvedCustomTypeName = pool->NewByteArray(typeName);
+ prop.typeRef = builder.newString(typeName.length());
+
+ int propertyFlags = 0;
+ if (writable)
+ propertyFlags |= QFastMetaBuilder::Writable;
+ if (resettable)
+ propertyFlags |= QFastMetaBuilder::Resettable;
+
+ builder.setProperty(propIndex, prop.nameRef, prop.typeRef, (QMetaType::Type)type,
+ (QFastMetaBuilder::PropertyFlag)propertyFlags,
+ propIndex);
+
+ return true;
+}
+
+bool QQmlCompiler::buildBinding(QQmlScript::Value *value,
+ QQmlScript::Property *prop,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+ Q_ASSERT(prop->parent);
+ Q_ASSERT(prop->parent->metaObject());
+
+ if (!prop->core.isWritable() && !prop->core.isQList() && !prop->isReadOnlyDeclaration)
+ COMPILE_EXCEPTION(prop, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString()));
+
+ JSBindingReference *reference = pool->New<JSBindingReference>();
+ reference->expression = value->value;
+ reference->property = prop;
+ reference->value = value;
+ reference->bindingContext = ctxt;
+ addBindingReference(reference);
+
+ return true;
+}
+
+bool QQmlCompiler::buildLiteralBinding(QQmlScript::Value *v,
+ QQmlScript::Property *prop,
+ const QQmlCompilerTypes::BindingContext &)
+{
+ Q_ASSERT(v->value.isScript());
+
+ if (!prop->core.isWritable())
+ return false;
+
+ AST::Node *binding = v->value.asAST();
+
+ if (prop->type == QVariant::String) {
+ if (AST::CallExpression *e = AST::cast<AST::CallExpression *>(binding)) {
+ if (AST::IdentifierExpression *i = AST::cast<AST::IdentifierExpression *>(e->base)) {
+ if (i->name == qsTrId_string) {
+ AST::ArgumentList *arg1 = e->arguments?e->arguments:0;
+ AST::ArgumentList *arg2 = arg1?arg1->next:0;
+
+ if (arg1 && arg1->expression->kind == AST::Node::Kind_StringLiteral &&
+ (!arg2 || arg2->expression->kind == AST::Node::Kind_NumericLiteral) &&
+ (!arg2 || !arg2->next)) {
+
+ QStringRef text;
+ int n = -1;
+
+ text = AST::cast<AST::StringLiteral *>(arg1->expression)->value;
+ if (arg2) n = (int)AST::cast<AST::NumericLiteral *>(arg2->expression)->value;
+
+ TrBindingReference *reference = pool->New<TrBindingReference>();
+ reference->dataType = BindingReference::TrId;
+ reference->text = text;
+ reference->n = n;
+ v->bindingReference = reference;
+ return true;
+ }
+
+ } else if (i->name == qsTr_string) {
+
+ AST::ArgumentList *arg1 = e->arguments?e->arguments:0;
+ AST::ArgumentList *arg2 = arg1?arg1->next:0;
+ AST::ArgumentList *arg3 = arg2?arg2->next:0;
+
+ if (arg1 && arg1->expression->kind == AST::Node::Kind_StringLiteral &&
+ (!arg2 || arg2->expression->kind == AST::Node::Kind_StringLiteral) &&
+ (!arg3 || arg3->expression->kind == AST::Node::Kind_NumericLiteral) &&
+ (!arg3 || !arg3->next)) {
+
+ QStringRef text;
+ QStringRef comment;
+ int n = -1;
+
+ text = AST::cast<AST::StringLiteral *>(arg1->expression)->value;
+ if (arg2) comment = AST::cast<AST::StringLiteral *>(arg2->expression)->value;
+ if (arg3) n = (int)AST::cast<AST::NumericLiteral *>(arg3->expression)->value;
+
+ TrBindingReference *reference = pool->New<TrBindingReference>();
+ reference->dataType = BindingReference::Tr;
+ reference->text = text;
+ reference->comment = comment;
+ reference->n = n;
+ v->bindingReference = reference;
+ return true;
+ }
+
+ }
+ }
+ }
+
+ }
+
+ return false;
+}
+
+void QQmlCompiler::genBindingAssignment(QQmlScript::Value *binding,
+ QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Property *valueTypeProperty)
+{
+ Q_UNUSED(obj);
+ Q_ASSERT(binding->bindingReference);
+
+ const BindingReference &ref = *binding->bindingReference;
+ if (ref.dataType == BindingReference::TrId) {
+ const TrBindingReference &tr = static_cast<const TrBindingReference &>(ref);
+
+ Instruction::StoreTrIdString store;
+ store.propertyIndex = prop->core.coreIndex;
+ store.text = output->indexForByteArray(tr.text.toUtf8());
+ store.n = tr.n;
+ output->addInstruction(store);
+ } else if (ref.dataType == BindingReference::Tr) {
+ const TrBindingReference &tr = static_cast<const TrBindingReference &>(ref);
+
+ Instruction::StoreTrString store;
+ store.propertyIndex = prop->core.coreIndex;
+ store.context = translationContextIndex();
+ store.text = output->indexForByteArray(tr.text.toUtf8());
+ store.comment = output->indexForByteArray(tr.comment.toUtf8());
+ store.n = tr.n;
+ output->addInstruction(store);
+ } else if (ref.dataType == BindingReference::V4) {
+ const JSBindingReference &js = static_cast<const JSBindingReference &>(ref);
+
+ Instruction::StoreV4Binding store;
+ store.value = js.compiledIndex;
+ store.context = js.bindingContext.stack;
+ store.owner = js.bindingContext.owner;
+ if (valueTypeProperty) {
+ store.property = (valueTypeProperty->index & 0xFFFF) |
+ ((valueTypeProperty->type & 0xFF)) << 16 |
+ ((prop->index & 0xFF) << 24);
+ store.isRoot = (compileState->root == valueTypeProperty->parent);
+ } else {
+ store.property = prop->index;
+ store.isRoot = (compileState->root == obj);
+ }
+ store.line = binding->location.start.line;
+ store.column = binding->location.start.column;
+ output->addInstruction(store);
+ } else if (ref.dataType == BindingReference::V8) {
+ const JSBindingReference &js = static_cast<const JSBindingReference &>(ref);
+
+ Instruction::StoreV8Binding store;
+ store.value = js.compiledIndex;
+ store.context = js.bindingContext.stack;
+ store.owner = js.bindingContext.owner;
+ if (valueTypeProperty) {
+ store.isRoot = (compileState->root == valueTypeProperty->parent);
+ } else {
+ store.isRoot = (compileState->root == obj);
+ }
+ store.line = binding->location.start.line;
+ store.column = binding->location.start.column;
+
+ Q_ASSERT(js.bindingContext.owner == 0 ||
+ (js.bindingContext.owner != 0 && valueTypeProperty));
+ if (js.bindingContext.owner) {
+ store.property = genValueTypeData(prop, valueTypeProperty);
+ } else {
+ store.property = prop->core;
+ }
+
+ output->addInstruction(store);
+ } else if (ref.dataType == BindingReference::QtScript) {
+ const JSBindingReference &js = static_cast<const JSBindingReference &>(ref);
+
+ QQmlInstruction store;
+ store.assignBinding.value = output->indexForString(js.rewrittenExpression);
+ store.assignBinding.context = js.bindingContext.stack;
+ store.assignBinding.owner = js.bindingContext.owner;
+ store.assignBinding.line = binding->location.start.line;
+ store.assignBinding.column = binding->location.start.column;
+
+ if (valueTypeProperty) {
+ store.assignBinding.isRoot = (compileState->root == valueTypeProperty->parent);
+ } else {
+ store.assignBinding.isRoot = (compileState->root == obj);
+ }
+
+ Q_ASSERT(js.bindingContext.owner == 0 ||
+ (js.bindingContext.owner != 0 && valueTypeProperty));
+ if (js.bindingContext.owner) {
+ store.assignBinding.property = genValueTypeData(prop, valueTypeProperty);
+ } else {
+ store.assignBinding.property = prop->core;
+ }
+ output->addInstructionHelper(
+ !prop->isAlias ? QQmlInstruction::StoreBinding
+ : QQmlInstruction::StoreBindingOnAlias
+ , store);
+ } else {
+ Q_ASSERT(!"Unhandled BindingReference::DataType type");
+ }
+}
+
+int QQmlCompiler::genContextCache()
+{
+ if (compileState->ids.count() == 0)
+ return -1;
+
+ QQmlIntegerCache *cache = new QQmlIntegerCache();
+ cache->reserve(compileState->ids.count());
+ for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o))
+ cache->add(o->id, o->idIndex);
+
+ output->contextCaches.append(cache);
+ return output->contextCaches.count() - 1;
+}
+
+QQmlPropertyData
+QQmlCompiler::genValueTypeData(QQmlScript::Property *valueTypeProp,
+ QQmlScript::Property *prop)
+{
+ typedef QQmlPropertyPrivate QDPP;
+ return QDPP::saveValueType(prop->parent->metaObject(), prop->index,
+ enginePrivate->valueTypes[prop->type]->metaObject(),
+ valueTypeProp->index, engine);
+}
+
+bool QQmlCompiler::completeComponentBuild()
+{
+ if (componentStats)
+ componentStats->componentStat.ids = compileState->ids.count();
+
+ for (Object *aliasObject = compileState->aliasingObjects.first(); aliasObject;
+ aliasObject = compileState->aliasingObjects.next(aliasObject))
+ COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
+
+ QV4Compiler::Expression expr(unit->imports());
+ expr.component = compileState->root;
+ expr.ids = &compileState->ids;
+ expr.importCache = output->importCache;
+
+ QV4Compiler bindingCompiler;
+
+ QList<JSBindingReference*> sharedBindings;
+
+ for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) {
+
+ JSBindingReference &binding = *b;
+
+ // ### We don't currently optimize for bindings on alias's - because
+ // of the solution to QTBUG-13719
+ if (!binding.property->isAlias) {
+ expr.context = binding.bindingContext.object;
+ expr.property = binding.property;
+ expr.expression = binding.expression;
+
+ int index = bindingCompiler.compile(expr, enginePrivate);
+ if (index != -1) {
+ binding.dataType = BindingReference::V4;
+ binding.compiledIndex = index;
+ if (componentStats)
+ componentStats->componentStat.optimizedBindings.append(b->value->location);
+ continue;
+ }
+ }
+
+ // Pre-rewrite the expression
+ QString expression = binding.expression.asScript();
+
+ QQmlRewrite::RewriteBinding rewriteBinding;
+ rewriteBinding.setName(QLatin1Char('$')+binding.property->name().toString());
+ bool isSharable = false;
+ binding.rewrittenExpression = rewriteBinding(binding.expression.asAST(), expression, &isSharable);
+
+ if (isSharable && !binding.property->isAlias /* See above re alias */ &&
+ binding.property->type != qMetaTypeId<QQmlBinding*>()) {
+ binding.dataType = BindingReference::V8;
+ sharedBindings.append(b);
+
+ if (componentStats)
+ componentStats->componentStat.sharedBindings.append(b->value->location);
+ } else {
+ binding.dataType = BindingReference::QtScript;
+
+ if (componentStats)
+ componentStats->componentStat.scriptBindings.append(b->value->location);
+ }
+ }
+
+ if (!sharedBindings.isEmpty()) {
+ struct Sort {
+ static bool lt(const JSBindingReference *lhs, const JSBindingReference *rhs)
+ {
+ return lhs->value->location.start.line < rhs->value->location.start.line;
+ }
+ };
+
+ qSort(sharedBindings.begin(), sharedBindings.end(), Sort::lt);
+
+ int startLineNumber = sharedBindings.at(0)->value->location.start.line;
+ int lineNumber = startLineNumber;
+
+ QByteArray functionArray("[", 1);
+ for (int ii = 0; ii < sharedBindings.count(); ++ii) {
+
+ JSBindingReference *reference = sharedBindings.at(ii);
+ QQmlScript::Value *value = reference->value;
+ const QString &expression = reference->rewrittenExpression;
+
+ if (ii != 0) functionArray.append(",", 1);
+
+ while (lineNumber < value->location.start.line) {
+ lineNumber++;
+ functionArray.append("\n", 1);
+ }
+
+ functionArray += expression.toUtf8();
+ lineNumber += expression.count(QLatin1Char('\n'));
+ reference->compiledIndex = ii;
+ }
+ functionArray.append("]", 1);
+
+ compileState->v8BindingProgram = functionArray;
+ compileState->v8BindingProgramLine = startLineNumber;
+ }
+
+ if (bindingCompiler.isValid())
+ compileState->compiledBindingData = bindingCompiler.program();
+
+ // Check pop()'s matched push()'s
+ Q_ASSERT(compileState->objectDepth.depth() == 0);
+ Q_ASSERT(compileState->listDepth.depth() == 0);
+
+ saveComponentState();
+
+ return true;
+}
+
+void QQmlCompiler::dumpStats()
+{
+ Q_ASSERT(componentStats);
+ qWarning().nospace() << "QML Document: " << output->url.toString();
+ for (int ii = 0; ii < componentStats->savedComponentStats.count(); ++ii) {
+ const ComponentStat &stat = componentStats->savedComponentStats.at(ii);
+ qWarning().nospace() << " Component Line " << stat.lineNumber;
+ qWarning().nospace() << " Total Objects: " << stat.objects;
+ qWarning().nospace() << " IDs Used: " << stat.ids;
+ qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings.count();
+
+ {
+ QByteArray output;
+ for (int ii = 0; ii < stat.optimizedBindings.count(); ++ii) {
+ if (0 == (ii % 10)) {
+ if (ii) output.append("\n");
+ output.append(" ");
+ }
+
+ output.append("(");
+ output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.line));
+ output.append(":");
+ output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.column));
+ output.append(") ");
+ }
+ if (!output.isEmpty())
+ qWarning().nospace() << output.constData();
+ }
+
+ qWarning().nospace() << " Shared Bindings: " << stat.sharedBindings.count();
+ {
+ QByteArray output;
+ for (int ii = 0; ii < stat.sharedBindings.count(); ++ii) {
+ if (0 == (ii % 10)) {
+ if (ii) output.append("\n");
+ output.append(" ");
+ }
+
+ output.append("(");
+ output.append(QByteArray::number(stat.sharedBindings.at(ii).start.line));
+ output.append(":");
+ output.append(QByteArray::number(stat.sharedBindings.at(ii).start.column));
+ output.append(") ");
+ }
+ if (!output.isEmpty())
+ qWarning().nospace() << output.constData();
+ }
+
+ qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings.count();
+ {
+ QByteArray output;
+ for (int ii = 0; ii < stat.scriptBindings.count(); ++ii) {
+ if (0 == (ii % 10)) {
+ if (ii) output.append("\n");
+ output.append(" ");
+ }
+
+ output.append("(");
+ output.append(QByteArray::number(stat.scriptBindings.at(ii).start.line));
+ output.append(":");
+ output.append(QByteArray::number(stat.scriptBindings.at(ii).start.column));
+ output.append(") ");
+ }
+ if (!output.isEmpty())
+ qWarning().nospace() << output.constData();
+ }
+ }
+}
+
+/*!
+ Returns true if from can be assigned to a (QObject) property of type
+ to.
+*/
+bool QQmlCompiler::canCoerce(int to, QQmlScript::Object *from)
+{
+ const QMetaObject *toMo = enginePrivate->rawMetaObjectForType(to);
+ const QMetaObject *fromMo = from->metaObject();
+
+ while (fromMo) {
+ if (QQmlPropertyPrivate::equal(fromMo, toMo))
+ return true;
+ fromMo = fromMo->superClass();
+ }
+ return false;
+}
+
+/*!
+ Returns the element name, as written in the QML file, for o.
+*/
+QString QQmlCompiler::elementName(QQmlScript::Object *o)
+{
+ Q_ASSERT(o);
+ if (o->type != -1) {
+ return output->types.at(o->type).className;
+ } else {
+ return QString();
+ }
+}
+
+QQmlType *QQmlCompiler::toQmlType(QQmlScript::Object *from)
+{
+ // ### Optimize
+ const QMetaObject *mo = from->metatype;
+ QQmlType *type = 0;
+ while (!type && mo) {
+ type = QQmlMetaType::qmlType(mo);
+ mo = mo->superClass();
+ }
+ return type;
+}
+
+QStringList QQmlCompiler::deferredProperties(QQmlScript::Object *obj)
+{
+ const QMetaObject *mo = obj->metatype;
+
+ int idx = mo->indexOfClassInfo("DeferredPropertyNames");
+ if (idx == -1)
+ return QStringList();
+
+ QMetaClassInfo classInfo = mo->classInfo(idx);
+ QStringList rv = QString::fromUtf8(classInfo.value()).split(QLatin1Char(','));
+ return rv;
+}
+
+QQmlPropertyData *
+QQmlCompiler::property(QQmlScript::Object *object, int index)
+{
+ QQmlPropertyCache *cache = 0;
+
+ if (object->synthCache)
+ cache = object->synthCache;
+ else if (object->type != -1)
+ cache = output->types[object->type].createPropertyCache(engine);
+ else
+ cache = QQmlEnginePrivate::get(engine)->cache(object->metaObject());
+
+ return cache->property(index);
+}
+
+QQmlPropertyData *
+QQmlCompiler::property(QQmlScript::Object *object, const QHashedStringRef &name, bool *notInRevision)
+{
+ if (notInRevision) *notInRevision = false;
+
+ QQmlPropertyCache *cache = 0;
+
+ if (object->synthCache)
+ cache = object->synthCache;
+ else if (object->type != -1)
+ cache = output->types[object->type].createPropertyCache(engine);
+ else
+ cache = QQmlEnginePrivate::get(engine)->cache(object->metaObject());
+
+ QQmlPropertyData *d = cache->property(name);
+
+ // Find the first property
+ while (d && d->isFunction())
+ d = cache->overrideData(d);
+
+ if (d && !cache->isAllowedInRevision(d)) {
+ if (notInRevision) *notInRevision = true;
+ return 0;
+ } else {
+ return d;
+ }
+}
+
+// This code must match the semantics of QQmlPropertyPrivate::findSignalByName
+QQmlPropertyData *
+QQmlCompiler::signal(QQmlScript::Object *object, const QHashedStringRef &name, bool *notInRevision)
+{
+ if (notInRevision) *notInRevision = false;
+
+ QQmlPropertyCache *cache = 0;
+
+ if (object->synthCache)
+ cache = object->synthCache;
+ else if (object->type != -1)
+ cache = output->types[object->type].createPropertyCache(engine);
+ else
+ cache = QQmlEnginePrivate::get(engine)->cache(object->metaObject());
+
+
+ QQmlPropertyData *d = cache->property(name);
+ if (notInRevision) *notInRevision = false;
+
+ while (d && !(d->isFunction()))
+ d = cache->overrideData(d);
+
+ if (d && !cache->isAllowedInRevision(d)) {
+ if (notInRevision) *notInRevision = true;
+ return 0;
+ } else if (d) {
+ return d;
+ }
+
+ if (name.endsWith(Changed_string)) {
+ QHashedStringRef propName = name.mid(0, name.length() - Changed_string.length());
+
+ d = property(object, propName, notInRevision);
+ if (d)
+ return cache->method(d->notifyIndex);
+ }
+
+ return 0;
+}
+
+// This code must match the semantics of QQmlPropertyPrivate::findSignalByName
+int QQmlCompiler::indexOfSignal(QQmlScript::Object *object, const QString &name,
+ bool *notInRevision)
+{
+ QQmlPropertyData *d = signal(object, QStringRef(&name), notInRevision);
+ return d?d->coreIndex:-1;
+}
+
+int QQmlCompiler::indexOfProperty(QQmlScript::Object *object, const QString &name,
+ bool *notInRevision)
+{
+ return indexOfProperty(object, QStringRef(&name), notInRevision);
+}
+
+int QQmlCompiler::indexOfProperty(QQmlScript::Object *object, const QHashedStringRef &name,
+ bool *notInRevision)
+{
+ QQmlPropertyData *d = property(object, name, notInRevision);
+ return d?d->coreIndex:-1;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h
new file mode 100644
index 0000000000..3b6fdf1473
--- /dev/null
+++ b/src/qml/qml/qqmlcompiler_p.h
@@ -0,0 +1,467 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCOMPILER_P_H
+#define QQMLCOMPILER_P_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 "qqml.h"
+#include "qqmlerror.h"
+#include <private/qv8_p.h>
+#include "qqmlinstruction_p.h"
+#include "qqmlscript_p.h"
+#include "qqmlengine_p.h"
+#include <private/qbitfield_p.h>
+#include "qqmlpropertycache_p.h"
+#include "qqmlintegercache_p.h"
+#include "qqmltypenamecache_p.h"
+#include "qqmltypeloader_p.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qset.h>
+#include <QtCore/QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+class QQmlComponent;
+class QQmlContext;
+class QQmlContextData;
+
+class Q_AUTOTEST_EXPORT QQmlCompiledData : public QQmlRefCount,
+ public QQmlCleanup
+{
+public:
+ QQmlCompiledData(QQmlEngine *engine);
+ virtual ~QQmlCompiledData();
+
+ QQmlEngine *engine;
+
+ QString name;
+ QUrl url;
+ QQmlTypeNameCache *importCache;
+
+ struct TypeReference
+ {
+ TypeReference()
+ : type(0), typePropertyCache(0), component(0) {}
+
+ QString className;
+ QQmlType *type;
+ QQmlPropertyCache *typePropertyCache;
+ QQmlCompiledData *component;
+
+ const QMetaObject *metaObject() const;
+ QQmlPropertyCache *propertyCache() const;
+ QQmlPropertyCache *createPropertyCache(QQmlEngine *);
+ };
+ QList<TypeReference> types;
+
+ struct V8Program {
+ V8Program(const QByteArray &p, QQmlCompiledData *c)
+ : program(p), cdata(c) {}
+
+ QByteArray program;
+ v8::Persistent<v8::Array> bindings;
+ QQmlCompiledData *cdata;
+ };
+
+ QList<V8Program> programs;
+
+ const QMetaObject *root;
+ QAbstractDynamicMetaObject rootData;
+ QQmlPropertyCache *rootPropertyCache;
+ QList<QString> primitives;
+ QList<QByteArray> datas;
+ QByteArray bytecode;
+ QList<QQmlPropertyCache *> propertyCaches;
+ QList<QQmlIntegerCache *> contextCaches;
+ QList<QQmlScriptData *> scripts;
+ QList<QUrl> urls;
+
+ struct Instruction {
+#define QML_INSTR_DATA_TYPEDEF(I, FMT) typedef QQmlInstructionData<QQmlInstruction::I> I;
+ FOR_EACH_QML_INSTR(QML_INSTR_DATA_TYPEDEF)
+#undef QML_INSTR_DATA_TYPEDEF
+ private:
+ Instruction();
+ };
+
+ void dumpInstructions();
+
+ template <int Instr>
+ int addInstruction(const QQmlInstructionData<Instr> &data)
+ {
+ QQmlInstruction genericInstr;
+ QQmlInstructionMeta<Instr>::setData(genericInstr, data);
+ return addInstructionHelper(static_cast<QQmlInstruction::Type>(Instr), genericInstr);
+ }
+ int nextInstructionIndex();
+ QQmlInstruction *instruction(int index);
+ QQmlInstruction::Type instructionType(const QQmlInstruction *instr);
+
+ bool isInitialized() const { return hasEngine(); }
+ void initialize(QQmlEngine *);
+
+protected:
+ virtual void destroy(); // From QQmlRefCount
+ virtual void clear(); // From QQmlCleanup
+
+private:
+ friend class QQmlCompiler;
+
+ int addInstructionHelper(QQmlInstruction::Type type, QQmlInstruction &instr);
+ void dump(QQmlInstruction *, int idx = -1);
+ QQmlCompiledData(const QQmlCompiledData &other);
+ QQmlCompiledData &operator=(const QQmlCompiledData &other);
+ QByteArray packData;
+ int pack(const char *, size_t);
+
+ int indexForString(const QString &);
+ int indexForByteArray(const QByteArray &);
+ int indexForUrl(const QUrl &);
+};
+
+namespace QQmlCompilerTypes {
+ struct BindingContext
+ {
+ BindingContext()
+ : stack(0), owner(0), object(0) {}
+ BindingContext(QQmlScript::Object *o)
+ : stack(0), owner(0), object(o) {}
+ BindingContext incr() const {
+ BindingContext rv(object);
+ rv.stack = stack + 1;
+ return rv;
+ }
+ bool isSubContext() const { return stack != 0; }
+ int stack;
+ int owner;
+ QQmlScript::Object *object;
+ };
+
+ struct BindingReference
+ {
+ enum DataType { QtScript, V4, V8,
+ Tr, TrId };
+ DataType dataType;
+ };
+
+ struct JSBindingReference : public QQmlPool::Class,
+ public BindingReference
+ {
+ JSBindingReference() : nextReference(0) {}
+
+ QQmlScript::Variant expression;
+ QQmlScript::Property *property;
+ QQmlScript::Value *value;
+
+ int compiledIndex;
+
+ QString rewrittenExpression;
+ BindingContext bindingContext;
+
+ JSBindingReference *nextReference;
+ };
+
+ struct TrBindingReference : public QQmlPool::POD,
+ public BindingReference
+ {
+ QStringRef text;
+ QStringRef comment;
+ int n;
+ };
+
+ struct IdList : public QFieldList<QQmlScript::Object,
+ &QQmlScript::Object::nextIdObject>
+ {
+ QQmlScript::Object *value(const QString &id) const {
+ for (QQmlScript::Object *o = first(); o; o = next(o)) {
+ if (o->id == id)
+ return o;
+ }
+ return 0;
+ }
+ };
+
+ struct DepthStack {
+ DepthStack() : _depth(0), _maxDepth(0) {}
+ DepthStack(const DepthStack &o) : _depth(o._depth), _maxDepth(o._maxDepth) {}
+ DepthStack &operator=(const DepthStack &o) { _depth = o._depth; _maxDepth = o._maxDepth; return *this; }
+
+ int depth() const { return _depth; }
+ int maxDepth() const { return _maxDepth; }
+
+ void push() { ++_depth; _maxDepth = qMax(_depth, _maxDepth); }
+ void pop() { --_depth; Q_ASSERT(_depth >= 0); Q_ASSERT(_maxDepth > _depth); }
+
+ void pushPop(int count) { _maxDepth = qMax(_depth + count, _maxDepth); }
+ private:
+ int _depth;
+ int _maxDepth;
+ };
+
+ // Contains all the incremental compiler state about a component. As
+ // a single QML file can have multiple components defined, there may be
+ // more than one of these for each compile
+ struct ComponentCompileState : public QQmlPool::Class
+ {
+ ComponentCompileState()
+ : parserStatusCount(0), totalBindingsCount(0), pushedProperties(0), nested(false),
+ v8BindingProgramLine(-1), root(0) {}
+
+ IdList ids;
+ int parserStatusCount;
+ int totalBindingsCount;
+ int pushedProperties;
+ bool nested;
+
+ QByteArray compiledBindingData;
+ QByteArray v8BindingProgram;
+ int v8BindingProgramLine;
+
+ DepthStack objectDepth;
+ DepthStack listDepth;
+
+ typedef QQmlCompilerTypes::JSBindingReference B;
+ typedef QFieldList<B, &B::nextReference> JSBindingReferenceList;
+ JSBindingReferenceList bindings;
+ typedef QQmlScript::Object O;
+ typedef QFieldList<O, &O::nextAliasingObject> AliasingObjectsList;
+ AliasingObjectsList aliasingObjects;
+ QQmlScript::Object *root;
+ };
+};
+
+class QMetaObjectBuilder;
+class Q_AUTOTEST_EXPORT QQmlCompiler
+{
+ Q_DECLARE_TR_FUNCTIONS(QQmlCompiler)
+public:
+ QQmlCompiler(QQmlPool *);
+
+ bool compile(QQmlEngine *, QQmlTypeData *, QQmlCompiledData *);
+
+ bool isError() const;
+ QList<QQmlError> errors() const;
+
+ static bool isAttachedPropertyName(const QString &);
+ static bool isSignalPropertyName(const QString &);
+ static bool isAttachedPropertyName(const QHashedStringRef &);
+ static bool isSignalPropertyName(const QHashedStringRef &);
+
+ int evaluateEnum(const QByteArray& script) const; // for QQmlCustomParser::evaluateEnum
+ const QMetaObject *resolveType(const QString& name) const; // for QQmlCustomParser::resolveType
+ int rewriteBinding(const QQmlScript::Variant& value, const QString& name); // for QQmlCustomParser::rewriteBinding
+ QString rewriteSignalHandler(const QQmlScript::Variant& value, const QString &name); // for QQmlCustomParser::rewriteSignalHandler
+
+private:
+ typedef QQmlCompiledData::Instruction Instruction;
+
+ static void reset(QQmlCompiledData *);
+
+ void compileTree(QQmlScript::Object *tree);
+
+
+ bool buildObject(QQmlScript::Object *obj, const QQmlCompilerTypes::BindingContext &);
+ bool buildComponent(QQmlScript::Object *obj, const QQmlCompilerTypes::BindingContext &);
+ bool buildSubObject(QQmlScript::Object *obj, const QQmlCompilerTypes::BindingContext &);
+ bool buildSignal(QQmlScript::Property *prop, QQmlScript::Object *obj,
+ const QQmlCompilerTypes::BindingContext &);
+ bool buildProperty(QQmlScript::Property *prop, QQmlScript::Object *obj,
+ const QQmlCompilerTypes::BindingContext &);
+ bool buildPropertyInNamespace(QQmlImportedNamespace *ns,
+ QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const QQmlCompilerTypes::BindingContext &);
+ bool buildIdProperty(QQmlScript::Property *prop, QQmlScript::Object *obj);
+ bool buildAttachedProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildGroupedProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildValueTypeProperty(QObject *type,
+ QQmlScript::Object *obj,
+ QQmlScript::Object *baseObj,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildListProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildScriptStringProperty(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildPropertyAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildPropertyObjectAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Value *value,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildPropertyOnAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Object *baseObj,
+ QQmlScript::Value *value,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildPropertyLiteralAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Value *value,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool doesPropertyExist(QQmlScript::Property *prop, QQmlScript::Object *obj);
+ bool testLiteralAssignment(QQmlScript::Property *prop,
+ QQmlScript::Value *value);
+ bool testQualifiedEnumAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Value *value,
+ bool *isAssignment);
+ enum DynamicMetaMode { IgnoreAliases, ResolveAliases, ForceCreation };
+ bool mergeDynamicMetaProperties(QQmlScript::Object *obj);
+ bool buildDynamicMeta(QQmlScript::Object *obj, DynamicMetaMode mode);
+ bool checkDynamicMeta(QQmlScript::Object *obj);
+ bool buildBinding(QQmlScript::Value *, QQmlScript::Property *prop,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildLiteralBinding(QQmlScript::Value *, QQmlScript::Property *prop,
+ const QQmlCompilerTypes::BindingContext &ctxt);
+ bool buildComponentFromRoot(QQmlScript::Object *obj, const QQmlCompilerTypes::BindingContext &);
+ bool compileAlias(QFastMetaBuilder &,
+ QByteArray &data,
+ QQmlScript::Object *obj,
+ int propIndex, int aliasIndex,
+ QQmlScript::Object::DynamicProperty &);
+ bool completeComponentBuild();
+ bool checkValidId(QQmlScript::Value *, const QString &);
+
+
+ void genObject(QQmlScript::Object *obj);
+ void genObjectBody(QQmlScript::Object *obj);
+ void genValueTypeProperty(QQmlScript::Object *obj,QQmlScript::Property *);
+ void genComponent(QQmlScript::Object *obj);
+ void genValueProperty(QQmlScript::Property *prop, QQmlScript::Object *obj);
+ void genListProperty(QQmlScript::Property *prop, QQmlScript::Object *obj);
+ void genPropertyAssignment(QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Property *valueTypeProperty = 0);
+ void genLiteralAssignment(QQmlScript::Property *prop,
+ QQmlScript::Value *value);
+ void genBindingAssignment(QQmlScript::Value *binding,
+ QQmlScript::Property *prop,
+ QQmlScript::Object *obj,
+ QQmlScript::Property *valueTypeProperty = 0);
+ int genContextCache();
+
+ QQmlPropertyData genValueTypeData(QQmlScript::Property *prop,
+ QQmlScript::Property *valueTypeProp);
+
+ int componentTypeRef();
+ int translationContextIndex();
+
+ static QQmlType *toQmlType(QQmlScript::Object *from);
+ bool canCoerce(int to, QQmlScript::Object *from);
+
+ QString elementName(QQmlScript::Object *);
+
+ QStringList deferredProperties(QQmlScript::Object *);
+
+ QQmlPropertyData *property(QQmlScript::Object *, int);
+ QQmlPropertyData *property(QQmlScript::Object *, const QHashedStringRef &,
+ bool *notInRevision = 0);
+ QQmlPropertyData *signal(QQmlScript::Object *, const QHashedStringRef &,
+ bool *notInRevision = 0);
+ int indexOfProperty(QQmlScript::Object *, const QHashedStringRef &, bool *notInRevision = 0);
+ int indexOfProperty(QQmlScript::Object *, const QString &, bool *notInRevision = 0);
+ int indexOfSignal(QQmlScript::Object *, const QString &, bool *notInRevision = 0);
+
+ void addId(const QString &, QQmlScript::Object *);
+
+ void dumpStats();
+
+ void addBindingReference(QQmlCompilerTypes::JSBindingReference *);
+
+ QQmlCompilerTypes::ComponentCompileState *compileState;
+
+ QQmlPool *pool;
+
+ QQmlCompilerTypes::ComponentCompileState *componentState(QQmlScript::Object *);
+ void saveComponentState();
+
+ QList<QQmlError> exceptions;
+ QQmlCompiledData *output;
+ QQmlEngine *engine;
+ QQmlEnginePrivate *enginePrivate;
+ QQmlScript::Object *unitRoot;
+ QQmlTypeData *unit;
+ int cachedComponentTypeRef;
+ int cachedTranslationContextIndex;
+
+ // Compiler component statistics. Only collected if QML_COMPILER_STATS=1
+ struct ComponentStat
+ {
+ ComponentStat() : ids(0), objects(0) {}
+
+ int lineNumber;
+
+ int ids;
+ QList<QQmlScript::LocationSpan> scriptBindings;
+ QList<QQmlScript::LocationSpan> sharedBindings;
+ QList<QQmlScript::LocationSpan> optimizedBindings;
+ int objects;
+ };
+ struct ComponentStats : public QQmlPool::Class
+ {
+ ComponentStat componentStat;
+ QList<ComponentStat> savedComponentStats;
+ };
+ ComponentStats *componentStats;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLCOMPILER_P_H
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
new file mode 100644
index 0000000000..5dd8fc8ae9
--- /dev/null
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -0,0 +1,1352 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlcomponent.h"
+#include "qqmlcomponent_p.h"
+#include "qqmlcomponentattached_p.h"
+
+#include "qqmlcompiler_p.h"
+#include "qqmlcontext_p.h"
+#include "qqmlengine_p.h"
+#include "qqmlvme_p.h"
+#include "qqml.h"
+#include "qqmlengine.h"
+#include "qqmlbinding_p.h"
+#include "qqmlbinding_p_p.h"
+#include "qqmlglobal_p.h"
+#include "qqmlscript_p.h"
+#include <private/qqmlprofilerservice_p.h>
+#include <private/qqmlenginedebugservice_p.h>
+#include "qqmlincubator.h"
+#include "qqmlincubator_p.h"
+
+#include <private/qv8engine_p.h>
+#include <private/qv8include_p.h>
+
+#include <QStack>
+#include <QStringList>
+#include <QtCore/qdebug.h>
+#include <qqmlinfo.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlComponentExtension : public QV8Engine::Deletable
+{
+public:
+ QQmlComponentExtension(QV8Engine *);
+ virtual ~QQmlComponentExtension();
+
+ v8::Persistent<v8::Function> incubationConstructor;
+ v8::Persistent<v8::Script> initialProperties;
+ v8::Persistent<v8::Function> forceCompletion;
+};
+V8_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension);
+
+/*
+ Try to do what's necessary for a reasonable display of the type
+ name, but no more (just enough for the client to do more extensive cleanup).
+
+ Should only be called when debugging is enabled.
+*/
+static inline QString buildTypeNameForDebug(const QMetaObject *metaObject)
+{
+ static const QString qmlMarker(QLatin1String("_QML"));
+ static const QChar underscore(QLatin1Char('_'));
+ static const QChar asterisk(QLatin1Char('*'));
+ QQmlType *type = QQmlMetaType::qmlType(metaObject);
+ QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(metaObject->className());
+ if (!type) {
+ //### optimize further?
+ int marker = typeName.indexOf(qmlMarker);
+ if (marker != -1 && marker < typeName.count() - 1) {
+ if (typeName[marker + 1] == underscore) {
+ const QString className = typeName.left(marker) + asterisk;
+ type = QQmlMetaType::qmlType(QMetaType::type(className.toUtf8()));
+ if (type)
+ typeName = type->qmlTypeName();
+ }
+ }
+ }
+ return typeName;
+}
+
+/*!
+ \class QQmlComponent
+ \since 4.7
+ \brief The QQmlComponent 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 QQmlComponent instance can be created from a QML file.
+ For example, if there is a \c main.qml file like this:
+
+ \qml
+ import QtQuick 2.0
+
+ 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
+ QQmlEngine *engine = new QQmlEngine;
+ QQmlComponent component(engine, QUrl::fromLocalFile("main.qml"));
+
+ QObject *myObject = component.create();
+ QQuickItem *item = qobject_cast<QQuickItem*>(myObject);
+ int width = item->width(); // width = 200
+ \endcode
+
+
+ \section2 Network Components
+
+ If the URL passed to QQmlComponent is a network resource, or if the QML document references a
+ network resource, the QQmlComponent has to fetch the network data before it is able to create
+ objects. In this case, the QQmlComponent will have a \l {QQmlComponent::Loading}{Loading}
+ \l {QQmlComponent::status()}{status}. An application will have to wait until the component
+ is \l {QQmlComponent::Ready}{Ready} before calling \l {QQmlComponent::create()}.
+
+ The following example shows how to load a QML file from a network resource. After creating
+ the QQmlComponent, it tests whether the component is loading. If it is, it connects to the
+ QQmlComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method
+ directly. Note that QQmlComponent::isLoading() may be false for a network component if the
+ component has been cached and is ready immediately.
+
+ \code
+ MyApplication::MyApplication()
+ {
+ // ...
+ component = new QQmlComponent(engine, QUrl("http://www.example.com/main.qml"));
+ if (component->isLoading())
+ QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)),
+ this, SLOT(continueLoading()));
+ else
+ continueLoading();
+ }
+
+ void MyApplication::continueLoading()
+ {
+ if (component->isError()) {
+ qWarning() << component->errors();
+ } else {
+ QObject *myObject = component->create();
+ }
+ }
+ \endcode
+
+ \sa {Using QML Bindings in C++ Applications}, {Integrating QML Code with Existing Qt UI Code}
+*/
+
+/*!
+ \qmlclass Component QQmlComponent
+ \ingroup qml-utility-elements
+ \since 4.7
+ \brief The Component element encapsulates a QML component definition.
+
+ Components are reusable, encapsulated QML elements with well-defined interfaces.
+
+ Components are often defined by \l {qdeclarativedocuments.html}{component files} -
+ that is, \c .qml files. The \e Component element essentially allows QML components
+ to be defined inline, within a \l {QML Document}{QML document}, rather than as a separate QML 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.
+ It contains a single item, a \l Rectangle:
+
+ \snippet doc/src/snippets/qml/component.qml 0
+
+ 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 QML
+ file, and is not loaded until requested (in this case, by the
+ two \l Loader objects).
+
+ Defining a \c Component is similar to defining a \l {QML Document}{QML document}.
+ A QML document has a single top-level item that defines the behaviors and
+ properties of that component, and cannot define properties or behaviors outside
+ of that top-level item. In the same way, a \c Component definition contains a single
+ top level item (which in the above example is a \l Rectangle) and cannot define any
+ data outside of this item, with the exception of an \e id (which in the above example
+ is \e redSquare).
+
+ The \c Component element is commonly used to provide graphical components
+ for views. For example, the ListView::delegate property requires a \c Component
+ to specify how each list item is to be displayed.
+
+ \c Component objects can also be created dynamically using
+ \l{QML:Qt::createComponent()}{Qt.createComponent()}.
+*/
+
+/*!
+ \qmlattachedsignal Component::onCompleted()
+
+ Emitted after component "startup" has completed. This can be used to
+ execute script code at startup, once the full QML environment has been
+ established.
+
+ The \c {Component::onCompleted} attached property can be applied to
+ any element. The order of running the \c onCompleted scripts is
+ undefined.
+
+ \qml
+ Rectangle {
+ Component.onCompleted: console.log("Completed Running!")
+ Rectangle {
+ Component.onCompleted: console.log("Nested Completed Running!")
+ }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlattachedsignal Component::onDestruction()
+
+ Emitted as the component begins destruction. This can be used to undo
+ work done in the onCompleted signal, or other imperative code in your
+ application.
+
+ The \c {Component::onDestruction} attached property can be applied to
+ any element. However, it applies to the destruction of the component as
+ a whole, and not the destruction of the specific object. The order of
+ running the \c onDestruction scripts is undefined.
+
+ \qml
+ Rectangle {
+ Component.onDestruction: console.log("Destruction Beginning!")
+ Rectangle {
+ Component.onDestruction: console.log("Nested Destruction Beginning!")
+ }
+ }
+ \endqml
+
+ \sa QtQml
+*/
+
+/*!
+ \enum QQmlComponent::Status
+
+ Specifies the loading status of the QQmlComponent.
+
+ \value Null This QQmlComponent has no data. Call loadUrl() or setData() to add QML content.
+ \value Ready This QQmlComponent is ready and create() may be called.
+ \value Loading This QQmlComponent is loading network data.
+ \value Error An error has occurred. Call errors() to retrieve a list of \{QQmlError}{errors}.
+*/
+
+void QQmlComponentPrivate::typeDataReady(QQmlTypeData *)
+{
+ Q_Q(QQmlComponent);
+
+ Q_ASSERT(typeData);
+
+ fromTypeData(typeData);
+ typeData = 0;
+
+ emit q->statusChanged(q->status());
+}
+
+void QQmlComponentPrivate::typeDataProgress(QQmlTypeData *, qreal p)
+{
+ Q_Q(QQmlComponent);
+
+ progress = p;
+
+ emit q->progressChanged(p);
+}
+
+void QQmlComponentPrivate::fromTypeData(QQmlTypeData *data)
+{
+ url = data->finalUrl();
+ QQmlCompiledData *c = data->compiledData();
+
+ if (!c) {
+ Q_ASSERT(data->isError());
+ state.errors = data->errors();
+ } else {
+ cc = c;
+ }
+
+ data->release();
+}
+
+void QQmlComponentPrivate::clear()
+{
+ if (typeData) {
+ typeData->unregisterCallback(this);
+ typeData->release();
+ typeData = 0;
+ }
+
+ if (cc) {
+ cc->release();
+ cc = 0;
+ }
+}
+
+/*!
+ \internal
+*/
+QQmlComponent::QQmlComponent(QObject *parent)
+ : QObject(*(new QQmlComponentPrivate), parent)
+{
+}
+
+/*!
+ Destruct the QQmlComponent.
+*/
+QQmlComponent::~QQmlComponent()
+{
+ Q_D(QQmlComponent);
+
+ if (d->state.completePending) {
+ qWarning("QQmlComponent: Component destroyed while completion pending");
+ d->completeCreate();
+ }
+
+ if (d->typeData) {
+ d->typeData->unregisterCallback(d);
+ d->typeData->release();
+ }
+ if (d->cc)
+ d->cc->release();
+}
+
+/*!
+ \qmlproperty enumeration Component::status
+ This property holds the status of component loading. It can be one of:
+ \list
+ \o Component.Null - no data is available for the component
+ \o Component.Ready - the component has been loaded, and can be used to create instances.
+ \o Component.Loading - the component is currently being loaded
+ \o Component.Error - an error occurred while loading the component.
+ Calling errorString() will provide a human-readable description of any errors.
+ \endlist
+ */
+
+/*!
+ \property QQmlComponent::status
+ The component's current \l{QQmlComponent::Status} {status}.
+ */
+QQmlComponent::Status QQmlComponent::status() const
+{
+ Q_D(const QQmlComponent);
+
+ if (d->typeData)
+ return Loading;
+ else if (!d->state.errors.isEmpty())
+ return Error;
+ else if (d->engine && d->cc)
+ return Ready;
+ else
+ return Null;
+}
+
+/*!
+ Returns true if status() == QQmlComponent::Null.
+*/
+bool QQmlComponent::isNull() const
+{
+ return status() == Null;
+}
+
+/*!
+ Returns true if status() == QQmlComponent::Ready.
+*/
+bool QQmlComponent::isReady() const
+{
+ return status() == Ready;
+}
+
+/*!
+ Returns true if status() == QQmlComponent::Error.
+*/
+bool QQmlComponent::isError() const
+{
+ return status() == Error;
+}
+
+/*!
+ Returns true if status() == QQmlComponent::Loading.
+*/
+bool QQmlComponent::isLoading() const
+{
+ return status() == Loading;
+}
+
+/*!
+ \qmlproperty real Component::progress
+ The progress of loading the component, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+*/
+
+/*!
+ \property QQmlComponent::progress
+ The progress of loading the component, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+*/
+qreal QQmlComponent::progress() const
+{
+ Q_D(const QQmlComponent);
+ return d->progress;
+}
+
+/*!
+ \fn void QQmlComponent::progressChanged(qreal progress)
+
+ Emitted whenever the component's loading progress changes. \a progress will be the
+ current progress between 0.0 (nothing loaded) and 1.0 (finished).
+*/
+
+/*!
+ \fn void QQmlComponent::statusChanged(QQmlComponent::Status status)
+
+ Emitted whenever the component's status changes. \a status will be the
+ new status.
+*/
+
+/*!
+ Create a QQmlComponent with no data and give it the specified
+ \a engine and \a parent. Set the data with setData().
+*/
+QQmlComponent::QQmlComponent(QQmlEngine *engine, QObject *parent)
+ : QObject(*(new QQmlComponentPrivate), parent)
+{
+ Q_D(QQmlComponent);
+ d->engine = engine;
+}
+
+/*!
+ Create a QQmlComponent from the given \a url and give it the
+ specified \a parent and \a engine.
+
+ Ensure that the URL provided is full and correct, in particular, use
+ \l QUrl::fromLocalFile() when loading a file from the local filesystem.
+
+ \sa loadUrl()
+*/
+QQmlComponent::QQmlComponent(QQmlEngine *engine, const QUrl &url, QObject *parent)
+: QObject(*(new QQmlComponentPrivate), parent)
+{
+ Q_D(QQmlComponent);
+ d->engine = engine;
+ loadUrl(url);
+}
+
+/*!
+ Create a QQmlComponent from the given \a fileName and give it the specified
+ \a parent and \a engine.
+
+ \sa loadUrl()
+*/
+QQmlComponent::QQmlComponent(QQmlEngine *engine, const QString &fileName,
+ QObject *parent)
+: QObject(*(new QQmlComponentPrivate), parent)
+{
+ Q_D(QQmlComponent);
+ d->engine = engine;
+ loadUrl(d->engine->baseUrl().resolved(QUrl::fromLocalFile(fileName)));
+}
+
+/*!
+ \internal
+*/
+QQmlComponent::QQmlComponent(QQmlEngine *engine, QQmlCompiledData *cc, int start, QObject *parent)
+ : QObject(*(new QQmlComponentPrivate), parent)
+{
+ Q_D(QQmlComponent);
+ d->engine = engine;
+ d->cc = cc;
+ cc->addref();
+ d->start = start;
+ d->url = cc->url;
+ d->progress = 1.0;
+}
+
+/*!
+ Sets the QQmlComponent to use the given QML \a data. If \a url
+ is provided, it is used to set the component name and to provide
+ a base path for items resolved by this component.
+*/
+void QQmlComponent::setData(const QByteArray &data, const QUrl &url)
+{
+ Q_D(QQmlComponent);
+
+ d->clear();
+
+ d->url = url;
+
+ QQmlTypeData *typeData = QQmlEnginePrivate::get(d->engine)->typeLoader.get(data, url);
+
+ if (typeData->isCompleteOrError()) {
+ d->fromTypeData(typeData);
+ } else {
+ d->typeData = typeData;
+ d->typeData->registerCallback(d);
+ }
+
+ d->progress = 1.0;
+ emit statusChanged(status());
+ emit progressChanged(d->progress);
+}
+
+/*!
+Returns the QQmlContext the component was created in. This is only
+valid for components created directly from QML.
+*/
+QQmlContext *QQmlComponent::creationContext() const
+{
+ Q_D(const QQmlComponent);
+ if(d->creationContext)
+ return d->creationContext->asQQmlContext();
+
+ return qmlContext(this);
+}
+
+/*!
+ Load the QQmlComponent from the provided \a url.
+
+ Ensure that the URL provided is full and correct, in particular, use
+ \l QUrl::fromLocalFile() when loading a file from the local filesystem.
+*/
+void QQmlComponent::loadUrl(const QUrl &url)
+{
+ Q_D(QQmlComponent);
+
+ d->clear();
+
+ if ((url.isRelative() && !url.isEmpty())
+ || url.scheme() == QLatin1String("file")) // Workaround QTBUG-11929
+ d->url = d->engine->baseUrl().resolved(url);
+ else
+ d->url = url;
+
+ if (url.isEmpty()) {
+ QQmlError error;
+ error.setDescription(tr("Invalid empty URL"));
+ d->state.errors << error;
+ return;
+ }
+
+ QQmlTypeData *data = QQmlEnginePrivate::get(d->engine)->typeLoader.get(d->url);
+
+ if (data->isCompleteOrError()) {
+ d->fromTypeData(data);
+ d->progress = 1.0;
+ } else {
+ d->typeData = data;
+ d->typeData->registerCallback(d);
+ d->progress = data->progress();
+ }
+
+ emit statusChanged(status());
+ emit progressChanged(d->progress);
+}
+
+/*!
+ Return the list of errors that occurred during the last compile or create
+ operation. An empty list is returned if isError() is not set.
+*/
+QList<QQmlError> QQmlComponent::errors() const
+{
+ Q_D(const QQmlComponent);
+ if (isError())
+ return d->state.errors;
+ else
+ return QList<QQmlError>();
+}
+
+/*!
+ \qmlmethod string Component::errorString()
+
+ Returns a human-readable description of any errors.
+
+ The string includes the file, location, and description of each error.
+ If multiple errors are present they are separated by a newline character.
+
+ If no errors are present, an empty string is returned.
+*/
+
+/*!
+ \internal
+ errorString is only meant as a way to get the errors in script
+*/
+QString QQmlComponent::errorString() const
+{
+ Q_D(const QQmlComponent);
+ QString ret;
+ if(!isError())
+ return ret;
+ foreach(const QQmlError &e, d->state.errors) {
+ ret += e.url().toString() + QLatin1Char(':') +
+ QString::number(e.line()) + QLatin1Char(' ') +
+ e.description() + QLatin1Char('\n');
+ }
+ return ret;
+}
+
+/*!
+ \qmlproperty url Component::url
+ The component URL. This is the URL that was used to construct the component.
+*/
+
+/*!
+ \property QQmlComponent::url
+ The component URL. This is the URL passed to either the constructor,
+ or the loadUrl() or setData() methods.
+*/
+QUrl QQmlComponent::url() const
+{
+ Q_D(const QQmlComponent);
+ return d->url;
+}
+
+/*!
+ \internal
+*/
+QQmlComponent::QQmlComponent(QQmlComponentPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
+/*!
+ Create an object instance from this component. Returns 0 if creation
+ failed. \a context specifies the context within which to create the object
+ instance.
+
+ If \a context is 0 (the default), it will create the instance in the
+ engine' s \l {QQmlEngine::rootContext()}{root context}.
+*/
+QObject *QQmlComponent::create(QQmlContext *context)
+{
+ Q_D(QQmlComponent);
+
+ if (!context)
+ context = d->engine->rootContext();
+
+ QObject *rv = beginCreate(context);
+ completeCreate();
+ return rv;
+}
+
+/*!
+ This method provides more advanced control over component instance creation.
+ In general, programmers should use QQmlComponent::create() to create a
+ component.
+
+ Create an object instance from this component. Returns 0 if creation
+ failed. \a publicContext specifies the context within which to create the object
+ instance.
+
+ When QQmlComponent constructs an instance, it occurs in three steps:
+ \list 1
+ \i The object hierarchy is created, and constant values are assigned.
+ \i Property bindings are evaluated for the the first time.
+ \i If applicable, QQmlParserStatus::componentComplete() is called on objects.
+ \endlist
+ QQmlComponent::beginCreate() differs from QQmlComponent::create() in that it
+ only performs step 1. QQmlComponent::completeCreate() must be called to
+ complete steps 2 and 3.
+
+ This breaking point is sometimes useful when using attached properties to
+ communicate information to an instantiated component, as it allows their
+ initial values to be configured before property bindings take effect.
+*/
+QObject *QQmlComponent::beginCreate(QQmlContext *publicContext)
+{
+ Q_D(QQmlComponent);
+
+ Q_ASSERT(publicContext);
+ QQmlContextData *context = QQmlContextData::get(publicContext);
+
+ return d->beginCreate(context);
+}
+
+QObject *
+QQmlComponentPrivate::beginCreate(QQmlContextData *context)
+{
+ Q_Q(QQmlComponent);
+ if (!context) {
+ qWarning("QQmlComponent: Cannot create a component in a null context");
+ return 0;
+ }
+
+ if (!context->isValid()) {
+ qWarning("QQmlComponent: Cannot create a component in an invalid context");
+ return 0;
+ }
+
+ if (context->engine != engine) {
+ qWarning("QQmlComponent: Must create component in context from the same QQmlEngine");
+ return 0;
+ }
+
+ if (state.completePending) {
+ qWarning("QQmlComponent: Cannot create new component instance before completing the previous");
+ return 0;
+ }
+
+ if (!q->isReady()) {
+ qWarning("QQmlComponent: Component is not ready");
+ return 0;
+ }
+
+ QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine);
+
+ if (enginePriv->inProgressCreations == 0) {
+ // only track root, since further ones might not be properly nested
+ profiler = new QQmlObjectCreatingProfiler();
+ }
+
+ enginePriv->inProgressCreations++;
+ state.errors.clear();
+ state.completePending = true;
+
+ enginePriv->referenceScarceResources();
+ state.vme.init(context, cc, start, creationContext);
+ QObject *rv = state.vme.execute(&state.errors);
+ enginePriv->dereferenceScarceResources();
+
+ if (rv) {
+ QQmlData *ddata = QQmlData::get(rv);
+ Q_ASSERT(ddata);
+ ddata->indestructible = true;
+ }
+
+ if (enginePriv->isDebugging && rv) {
+ if (!context->isInternal)
+ context->asQQmlContextPrivate()->instances.append(rv);
+ QQmlEngineDebugService::instance()->objectCreated(engine, rv);
+
+ if (profiler && profiler->enabled) {
+ profiler->setTypeName(buildTypeNameForDebug(rv->metaObject()));
+ QQmlData *data = QQmlData::get(rv);
+ Q_ASSERT(data);
+ profiler->setLocation(cc->url, data->lineNumber, data->columnNumber);
+ }
+ }
+
+ return rv;
+}
+
+void QQmlComponentPrivate::beginDeferred(QQmlEnginePrivate *enginePriv,
+ QObject *object, ConstructionState *state)
+{
+ enginePriv->inProgressCreations++;
+ state->errors.clear();
+ state->completePending = true;
+
+ state->vme.initDeferred(object);
+ state->vme.execute(&state->errors);
+}
+
+void QQmlComponentPrivate::complete(QQmlEnginePrivate *enginePriv, ConstructionState *state)
+{
+ if (state->completePending) {
+ state->vme.complete();
+
+ state->completePending = false;
+
+ enginePriv->inProgressCreations--;
+
+ if (0 == enginePriv->inProgressCreations) {
+ while (enginePriv->erroredBindings) {
+ enginePriv->warning(enginePriv->erroredBindings->error);
+ enginePriv->erroredBindings->removeError();
+ }
+ }
+ }
+}
+
+/*!
+ This method provides more advanced control over component instance creation.
+ In general, programmers should use QQmlComponent::create() to create a
+ component.
+
+ Complete a component creation begin with QQmlComponent::beginCreate().
+*/
+void QQmlComponent::completeCreate()
+{
+ Q_D(QQmlComponent);
+
+ d->completeCreate();
+}
+
+void QQmlComponentPrivate::completeCreate()
+{
+ if (state.completePending) {
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+ complete(ep, &state);
+
+ delete profiler;
+ profiler = 0;
+ }
+}
+
+QQmlComponentAttached::QQmlComponentAttached(QObject *parent)
+: QObject(parent), prev(0), next(0)
+{
+}
+
+QQmlComponentAttached::~QQmlComponentAttached()
+{
+ if (prev) *prev = next;
+ if (next) next->prev = prev;
+ prev = 0;
+ next = 0;
+}
+
+/*!
+ \internal
+*/
+QQmlComponentAttached *QQmlComponent::qmlAttachedProperties(QObject *obj)
+{
+ QQmlComponentAttached *a = new QQmlComponentAttached(obj);
+
+ QQmlEngine *engine = qmlEngine(obj);
+ if (!engine)
+ return a;
+
+ if (QQmlEnginePrivate::get(engine)->activeVME) { // XXX should only be allowed during begin
+ QQmlEnginePrivate *p = QQmlEnginePrivate::get(engine);
+ a->add(&p->activeVME->componentAttached);
+ } else {
+ QQmlData *d = QQmlData::get(obj);
+ Q_ASSERT(d);
+ Q_ASSERT(d->context);
+ a->add(&d->context->componentAttached);
+ }
+
+ return a;
+}
+
+void QQmlComponent::create(QQmlIncubator &i, QQmlContext *context,
+ QQmlContext *forContext)
+{
+ Q_D(QQmlComponent);
+
+ if (!context)
+ context = d->engine->rootContext();
+
+ QQmlContextData *contextData = QQmlContextData::get(context);
+ QQmlContextData *forContextData = contextData;
+ if (forContext) forContextData = QQmlContextData::get(forContext);
+
+ if (!contextData->isValid()) {
+ qWarning("QQmlComponent: Cannot create a component in an invalid context");
+ return;
+ }
+
+ if (contextData->engine != d->engine) {
+ qWarning("QQmlComponent: Must create component in context from the same QQmlEngine");
+ return;
+ }
+
+ if (!isReady()) {
+ qWarning("QQmlComponent: Component is not ready");
+ return;
+ }
+
+ i.clear();
+ QQmlIncubatorPrivate *p = i.d;
+
+ QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(d->engine);
+
+ p->component = d->cc; p->component->addref();
+ p->vme.init(contextData, d->cc, d->start, d->creationContext);
+
+ enginePriv->incubate(i, forContextData);
+}
+
+class QV8IncubatorResource : public QV8ObjectResource,
+ public QQmlIncubator
+{
+V8_RESOURCE_TYPE(IncubatorType)
+public:
+ QV8IncubatorResource(QV8Engine *engine, IncubationMode = Asynchronous);
+
+ static v8::Handle<v8::Value> StatusChangedGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo& info);
+ static v8::Handle<v8::Value> StatusGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo& info);
+ static v8::Handle<v8::Value> ObjectGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo& info);
+ static v8::Handle<v8::Value> ForceCompletionGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo& info);
+ static v8::Handle<v8::Value> ForceCompletion(const v8::Arguments &args);
+
+ static void StatusChangedSetter(v8::Local<v8::String>, v8::Local<v8::Value> value,
+ const v8::AccessorInfo& info);
+
+ void dispose();
+
+ v8::Persistent<v8::Object> me;
+ QQmlGuard<QObject> parent;
+ v8::Persistent<v8::Value> valuemap;
+ v8::Persistent<v8::Object> qmlGlobal;
+protected:
+ virtual void statusChanged(Status);
+ virtual void setInitialState(QObject *);
+};
+
+static void QQmlComponent_setQmlParent(QObject *me, QObject *parent)
+{
+ if (parent) {
+ me->setParent(parent);
+ typedef QQmlPrivate::AutoParentFunction APF;
+ QList<APF> functions = QQmlMetaType::parentFunctions();
+
+ bool needParent = false;
+ for (int ii = 0; ii < functions.count(); ++ii) {
+ QQmlPrivate::AutoParentResult res = functions.at(ii)(me, parent);
+ if (res == QQmlPrivate::Parented) {
+ needParent = false;
+ break;
+ } else if (res == QQmlPrivate::IncompatibleParent) {
+ needParent = true;
+ }
+ }
+ if (needParent)
+ qWarning("QQmlComponent: Created graphical object was not "
+ "placed in the graphics scene.");
+ }
+}
+
+/*!
+ \qmlmethod object Component::createObject(Item parent, object properties)
+
+ Creates and returns an object instance of this component that will have
+ the given \a parent and \a properties. The \a properties argument is optional.
+ Returns null if object creation fails.
+
+ The object will be created in the same context as the one in which the component
+ was created. This function will always return null when called on components
+ which were not created in QML.
+
+ If you wish to create an object without setting a parent, specify \c null for
+ the \a parent value. Note that if the returned object is to be displayed, you
+ must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent}
+ property, or else the object will not be visible.
+
+ If a \a parent is not provided to createObject(), a reference to the returned object must be held so that
+ it is not destroyed by the garbage collector. This is true regardless of whether \l{Item::parent} is set afterwards,
+ since setting the Item parent does not change object ownership; only the graphical parent is changed.
+
+ As of QtQuick 1.1, this method accepts an optional \a properties argument that specifies a
+ map of initial property values for the created object. These values are applied before object
+ creation is finalized. (This is more efficient than setting property values after object creation,
+ particularly where large sets of property values are defined, and also allows property bindings
+ to be set up before the object is created.)
+
+ The \a properties argument is specified as a map of property-value items. For example, the code
+ below creates an object with initial \c x and \c y values of 100 and 200, respectively:
+
+ \js
+ var component = Qt.createComponent("Button.qml");
+ if (component.status == Component.Ready)
+ component.createObject(parent, {"x": 100, "y": 100});
+ \endjs
+
+ Dynamically created instances can be deleted with the \c destroy() method.
+ See \l {Dynamic Object Management in QML} for more information.
+*/
+void QQmlComponent::createObject(QQmlV8Function *args)
+{
+ Q_D(QQmlComponent);
+ Q_ASSERT(d->engine);
+ Q_ASSERT(args);
+
+ QObject *parent = 0;
+ v8::Local<v8::Object> valuemap;
+
+ if (args->Length() >= 1)
+ parent = args->engine()->toQObject((*args)[0]);
+
+ if (args->Length() >= 2) {
+ v8::Local<v8::Value> v = (*args)[1];
+ if (!v->IsObject() || v->IsArray()) {
+ qmlInfo(this) << tr("createObject: value is not an object");
+ args->returnValue(v8::Null());
+ return;
+ }
+ valuemap = v8::Local<v8::Object>::Cast(v);
+ }
+
+ QV8Engine *v8engine = args->engine();
+
+ QQmlContext *ctxt = creationContext();
+ if (!ctxt) ctxt = d->engine->rootContext();
+
+ QObject *rv = beginCreate(ctxt);
+
+ if (!rv) {
+ args->returnValue(v8::Null());
+ return;
+ }
+
+ QQmlComponent_setQmlParent(rv, parent);
+
+ v8::Handle<v8::Value> ov = v8engine->newQObject(rv);
+ Q_ASSERT(ov->IsObject());
+ v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(ov);
+
+ if (!valuemap.IsEmpty()) {
+ QQmlComponentExtension *e = componentExtension(v8engine);
+ // Try catch isn't needed as the function itself is loaded with try/catch
+ v8::Handle<v8::Value> function = e->initialProperties->Run(args->qmlGlobal());
+ v8::Handle<v8::Value> args[] = { object, valuemap };
+ v8::Handle<v8::Function>::Cast(function)->Call(v8engine->global(), 2, args);
+ }
+
+ d->completeCreate();
+
+ Q_ASSERT(QQmlData::get(rv));
+ QQmlData::get(rv)->setImplicitDestructible();
+
+ if (!rv)
+ args->returnValue(v8::Null());
+ else
+ args->returnValue(object);
+}
+
+/*!
+ \qmlmethod object Component::incubateObject(Item parent, object properties, enum mode)
+
+ Creates an incubator for instance of this component. Incubators allow new component
+ instances to be instantiated asynchronously and not cause freezes in the UI.
+
+ The \a parent argument specifies the parent the created instance will have. Omitting the
+ parameter or passing null will create anobject with no parent. In this case, a reference
+ to the created object must be maintained by the application of the object will eventually
+ be garbage collected.
+
+ The \a properties argument is specified as a map of property-value items which will be
+ set on the created object during its construction. \a mode may be Qt.Synchronous or
+ Qt.Asynchronous and controls whether the instance is created synchronously or asynchronously.
+ The default is asynchronously. In some circumstances, even if Qt.Synchronous is specified,
+ the incubator may create the object asynchronously. This happens if the component calling
+ incubateObject() is itself being created asynchronously.
+
+ All three arguments are optional.
+
+ If successful, the method returns an incubator, otherwise null. The incubator has the following
+ properties:
+
+ \list
+ \i status The status of the incubator. Valid values are Component.Ready, Component.Loading and
+ Component.Error.
+ \i object The created object instance. Will only be available once the incubator is in the
+ Ready status.
+ \i onStatusChanged Specifies a callback function to be invoked when the status changes. The
+ status is passed as a parameter to the callback.
+ \i forceCompletion() Call to complete incubation synchronously.
+ \endlist
+
+ The following example demonstrates how to use an incubator:
+
+ \js
+ var component = Qt.createComponent("Button.qml");
+
+ var incubator = component.incubateObject(parent, { x: 10, y: 10 });
+ if (incubator.status != Component.Ready) {
+ incubator.onStatusChanged = function(status) {
+ if (status == Component.Ready) {
+ print ("Object", incubator.object, "is now ready!");
+ }
+ }
+ } else {
+ print ("Object", incubator.object, "is ready immediately!");
+ }
+ \endjs
+*/
+
+void QQmlComponent::incubateObject(QQmlV8Function *args)
+{
+ Q_D(QQmlComponent);
+ Q_ASSERT(d->engine);
+ Q_UNUSED(d);
+ Q_ASSERT(args);
+
+ QObject *parent = 0;
+ v8::Local<v8::Object> valuemap;
+ QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous;
+
+ if (args->Length() >= 1)
+ parent = args->engine()->toQObject((*args)[0]);
+
+ if (args->Length() >= 2) {
+ v8::Local<v8::Value> v = (*args)[1];
+ if (v->IsNull()) {
+ } else if (!v->IsObject() || v->IsArray()) {
+ qmlInfo(this) << tr("createObject: value is not an object");
+ args->returnValue(v8::Null());
+ return;
+ } else {
+ valuemap = v8::Local<v8::Object>::Cast(v);
+ }
+ }
+
+ if (args->Length() >= 3) {
+ quint32 v = (*args)[2]->Uint32Value();
+ if (v == 0)
+ mode = QQmlIncubator::Asynchronous;
+ else if (v == 1)
+ mode = QQmlIncubator::AsynchronousIfNested;
+ }
+
+ QQmlComponentExtension *e = componentExtension(args->engine());
+
+ QV8IncubatorResource *r = new QV8IncubatorResource(args->engine(), mode);
+ v8::Local<v8::Object> o = e->incubationConstructor->NewInstance();
+ o->SetExternalResource(r);
+
+ if (!valuemap.IsEmpty()) {
+ r->valuemap = qPersistentNew(valuemap);
+ r->qmlGlobal = qPersistentNew(args->qmlGlobal());
+ }
+ r->parent = parent;
+ r->me = qPersistentNew(o);
+
+ create(*r, creationContext());
+
+ if (r->status() == QQmlIncubator::Null) {
+ r->dispose();
+ args->returnValue(v8::Null());
+ } else {
+ args->returnValue(o);
+ }
+}
+
+// XXX used by QSGLoader
+void QQmlComponentPrivate::initializeObjectWithInitialProperties(v8::Handle<v8::Object> qmlGlobal, v8::Handle<v8::Object> valuemap, QObject *toCreate)
+{
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+ QV8Engine *v8engine = ep->v8engine();
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(v8engine->context());
+ v8::Handle<v8::Value> ov = v8engine->newQObject(toCreate);
+ Q_ASSERT(ov->IsObject());
+ v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(ov);
+
+ if (!valuemap.IsEmpty()) {
+ QQmlComponentExtension *e = componentExtension(v8engine);
+ // Try catch isn't needed as the function itself is loaded with try/catch
+ v8::Handle<v8::Value> function = e->initialProperties->Run(qmlGlobal);
+ v8::Handle<v8::Value> args[] = { object, valuemap };
+ v8::Handle<v8::Function>::Cast(function)->Call(v8engine->global(), 2, args);
+ }
+
+ QQmlData *ddata = QQmlData::get(toCreate);
+ Q_ASSERT(ddata);
+ ddata->setImplicitDestructible();
+}
+
+
+QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine)
+{
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+
+ forceCompletion = qPersistentNew(V8FUNCTION(QV8IncubatorResource::ForceCompletion, engine));
+
+ {
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->InstanceTemplate()->SetInternalFieldCount(1);
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("onStatusChanged"),
+ QV8IncubatorResource::StatusChangedGetter,
+ QV8IncubatorResource::StatusChangedSetter);
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("status"),
+ QV8IncubatorResource::StatusGetter);
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("object"),
+ QV8IncubatorResource::ObjectGetter);
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("forceCompletion"),
+ QV8IncubatorResource::ForceCompletionGetter);
+ incubationConstructor = qPersistentNew(ft->GetFunction());
+ }
+
+ {
+#define INITIALPROPERTIES_SOURCE \
+ "(function(object, values) {"\
+ "try {"\
+ "for(var property in values) {" \
+ "try {"\
+ "var properties = property.split(\".\");"\
+ "var o = object;"\
+ "for (var ii = 0; ii < properties.length - 1; ++ii) {"\
+ "o = o[properties[ii]];"\
+ "}"\
+ "o[properties[properties.length - 1]] = values[property];"\
+ "} catch(e) {}"\
+ "}"\
+ "} catch(e) {}"\
+ "})"
+ initialProperties = qPersistentNew(engine->qmlModeCompile(QLatin1String(INITIALPROPERTIES_SOURCE)));
+#undef INITIALPROPERTIES_SOURCE
+ }
+}
+
+v8::Handle<v8::Value> QV8IncubatorResource::ObjectGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo& info)
+{
+ QV8IncubatorResource *r = v8_resource_check<QV8IncubatorResource>(info.This());
+ return r->engine->newQObject(r->object());
+}
+
+v8::Handle<v8::Value> QV8IncubatorResource::ForceCompletionGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo& info)
+{
+ QV8IncubatorResource *r = v8_resource_check<QV8IncubatorResource>(info.This());
+ return componentExtension(r->engine)->forceCompletion;
+}
+
+v8::Handle<v8::Value> QV8IncubatorResource::ForceCompletion(const v8::Arguments &args)
+{
+ QV8IncubatorResource *r = v8_resource_cast<QV8IncubatorResource>(args.This());
+ if (!r)
+ V8THROW_TYPE("Not an incubator object");
+
+ r->forceCompletion();
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> QV8IncubatorResource::StatusGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo& info)
+{
+ QV8IncubatorResource *r = v8_resource_check<QV8IncubatorResource>(info.This());
+ return v8::Integer::NewFromUnsigned(r->status());
+}
+
+v8::Handle<v8::Value> QV8IncubatorResource::StatusChangedGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo& info)
+{
+ return info.This()->GetInternalField(0);
+}
+
+void QV8IncubatorResource::StatusChangedSetter(v8::Local<v8::String>, v8::Local<v8::Value> value,
+ const v8::AccessorInfo& info)
+{
+ info.This()->SetInternalField(0, value);
+}
+
+QQmlComponentExtension::~QQmlComponentExtension()
+{
+ qPersistentDispose(incubationConstructor);
+ qPersistentDispose(initialProperties);
+ qPersistentDispose(forceCompletion);
+}
+
+QV8IncubatorResource::QV8IncubatorResource(QV8Engine *engine, IncubationMode m)
+: QV8ObjectResource(engine), QQmlIncubator(m)
+{
+}
+
+void QV8IncubatorResource::setInitialState(QObject *o)
+{
+ QQmlComponent_setQmlParent(o, parent);
+
+ if (!valuemap.IsEmpty()) {
+ QQmlComponentExtension *e = componentExtension(engine);
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+
+ v8::Handle<v8::Value> function = e->initialProperties->Run(qmlGlobal);
+ v8::Handle<v8::Value> args[] = { engine->newQObject(o), valuemap };
+ v8::Handle<v8::Function>::Cast(function)->Call(engine->global(), 2, args);
+
+ qPersistentDispose(valuemap);
+ qPersistentDispose(qmlGlobal);
+ }
+}
+
+void QV8IncubatorResource::dispose()
+{
+ qPersistentDispose(valuemap);
+ qPersistentDispose(qmlGlobal);
+ // No further status changes are forthcoming, so we no long need a self reference
+ qPersistentDispose(me);
+}
+
+void QV8IncubatorResource::statusChanged(Status s)
+{
+ if (s == Ready) {
+ Q_ASSERT(QQmlData::get(object()));
+ QQmlData::get(object())->setImplicitDestructible();
+ }
+
+ if (!me.IsEmpty()) { // Will be false in synchronous mode
+ v8::HandleScope scope;
+ v8::Local<v8::Value> callback = me->GetInternalField(0);
+
+ if (!callback.IsEmpty() && !callback->IsUndefined()) {
+
+ if (callback->IsFunction()) {
+ v8::Context::Scope context_scope(engine->context());
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(callback);
+ v8::Handle<v8::Value> args[] = { v8::Integer::NewFromUnsigned(s) };
+ v8::TryCatch tc;
+ f->Call(me, 1, args);
+ if (tc.HasCaught()) {
+ QQmlError error;
+ QQmlExpressionPrivate::exceptionToError(tc.Message(), error);
+ QQmlEnginePrivate::warning(QQmlEnginePrivate::get(engine->engine()),
+ error);
+ }
+ }
+ }
+ }
+
+ if (s == Ready || s == Error)
+ dispose();
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h
new file mode 100644
index 0000000000..1265fb1c7d
--- /dev/null
+++ b/src/qml/qml/qqmlcomponent.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCOMPONENT_H
+#define QQMLCOMPONENT_H
+
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlerror.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstring.h>
+#include <QtQml/qjsvalue.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QByteArray;
+class QQmlEngine;
+class QQmlComponent;
+class QQmlIncubator;
+class QQmlV8Function;
+class QQmlCompiledData;
+class QQmlComponentPrivate;
+class QQmlComponentAttached;
+
+class Q_QML_EXPORT QQmlComponent : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQmlComponent)
+
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(QUrl url READ url CONSTANT)
+
+public:
+ QQmlComponent(QObject *parent = 0);
+ QQmlComponent(QQmlEngine *, QObject *parent=0);
+ QQmlComponent(QQmlEngine *, const QString &fileName, QObject *parent = 0);
+ QQmlComponent(QQmlEngine *, const QUrl &url, QObject *parent = 0);
+ virtual ~QQmlComponent();
+
+ Q_ENUMS(Status)
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+
+ bool isNull() const;
+ bool isReady() const;
+ bool isError() const;
+ bool isLoading() const;
+
+ QList<QQmlError> errors() const;
+ Q_INVOKABLE QString errorString() const;
+
+ qreal progress() const;
+
+ QUrl url() const;
+
+ virtual QObject *create(QQmlContext *context = 0);
+ virtual QObject *beginCreate(QQmlContext *);
+ virtual void completeCreate();
+
+ void create(QQmlIncubator &, QQmlContext *context = 0,
+ QQmlContext *forContext = 0);
+
+ QQmlContext *creationContext() const;
+
+ static QQmlComponentAttached *qmlAttachedProperties(QObject *);
+
+public Q_SLOTS:
+ void loadUrl(const QUrl &url);
+ void setData(const QByteArray &, const QUrl &baseUrl);
+
+Q_SIGNALS:
+ void statusChanged(QQmlComponent::Status);
+ void progressChanged(qreal);
+
+protected:
+ QQmlComponent(QQmlComponentPrivate &dd, QObject* parent);
+ Q_INVOKABLE void createObject(QQmlV8Function *);
+ Q_INVOKABLE void incubateObject(QQmlV8Function *);
+
+private:
+ QQmlComponent(QQmlEngine *, QQmlCompiledData *, int, QObject *parent);
+
+ Q_DISABLE_COPY(QQmlComponent)
+ friend class QQmlVME;
+ friend class QQmlTypeData;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlComponent::Status)
+QML_DECLARE_TYPE(QQmlComponent)
+QML_DECLARE_TYPEINFO(QQmlComponent, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif // QQMLCOMPONENT_H
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
new file mode 100644
index 0000000000..b03dd68936
--- /dev/null
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCOMPONENT_P_H
+#define QQMLCOMPONENT_P_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 "qqmlcomponent.h"
+
+#include <private/qv8_p.h>
+#include "qqmlengine_p.h"
+#include "qqmltypeloader_p.h"
+#include <private/qbitfield_p.h>
+#include "qqmlvme_p.h"
+#include "qqmlerror.h"
+#include "qqml.h"
+#include "../debugger/qqmlprofilerservice_p.h"
+
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QList>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+
+class QQmlComponent;
+class QQmlEngine;
+class QQmlCompiledData;
+
+class QQmlComponentAttached;
+class Q_QML_PRIVATE_EXPORT QQmlComponentPrivate : public QObjectPrivate, public QQmlTypeData::TypeDataCallback
+{
+ Q_DECLARE_PUBLIC(QQmlComponent)
+
+public:
+ QQmlComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0), profiler(0) {}
+
+ QObject *beginCreate(QQmlContextData *);
+ void completeCreate();
+ void initializeObjectWithInitialProperties(v8::Handle<v8::Object> qmlGlobal, v8::Handle<v8::Object> valuemap, QObject *toCreate);
+
+ QQmlTypeData *typeData;
+ virtual void typeDataReady(QQmlTypeData *);
+ virtual void typeDataProgress(QQmlTypeData *, qreal);
+
+ void fromTypeData(QQmlTypeData *data);
+
+ QUrl url;
+ qreal progress;
+
+ int start;
+ QQmlCompiledData *cc;
+
+ struct ConstructionState {
+ ConstructionState() : completePending(false) {}
+
+ QQmlVME vme;
+ QList<QQmlError> errors;
+ bool completePending;
+ };
+ ConstructionState state;
+
+ static void beginDeferred(QQmlEnginePrivate *enginePriv, QObject *object,
+ ConstructionState *state);
+ static void complete(QQmlEnginePrivate *enginePriv, ConstructionState *state);
+
+ QQmlEngine *engine;
+ QQmlGuardedContextData creationContext;
+ QQmlObjectCreatingProfiler *profiler;
+
+ void clear();
+
+ static QQmlComponentPrivate *get(QQmlComponent *c) {
+ return static_cast<QQmlComponentPrivate *>(QObjectPrivate::get(c));
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLCOMPONENT_P_H
diff --git a/src/qml/qml/qqmlcomponentattached_p.h b/src/qml/qml/qqmlcomponentattached_p.h
new file mode 100644
index 0000000000..09d111c227
--- /dev/null
+++ b/src/qml/qml/qqmlcomponentattached_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCOMPONENTATTACHED_P_H
+#define QQMLCOMPONENTATTACHED_P_H
+
+#include <QtQml/qqml.h>
+#include <QtCore/QObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class Q_AUTOTEST_EXPORT QQmlComponentAttached : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlComponentAttached(QObject *parent = 0);
+ ~QQmlComponentAttached();
+
+ void add(QQmlComponentAttached **a) {
+ prev = a; next = *a; *a = this;
+ if (next) next->prev = &next;
+ }
+ void rem() {
+ if (next) next->prev = prev;
+ *prev = next;
+ next = 0; prev = 0;
+ }
+ QQmlComponentAttached **prev;
+ QQmlComponentAttached *next;
+
+Q_SIGNALS:
+ void completed();
+ void destruction();
+
+private:
+ friend class QQmlVME;
+ friend class QQmlContextData;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLCOMPONENTATTACHED_P_H
diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp
new file mode 100644
index 0000000000..38acc0b0c3
--- /dev/null
+++ b/src/qml/qml/qqmlcontext.cpp
@@ -0,0 +1,811 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlcontext.h"
+#include "qqmlcontext_p.h"
+#include "qqmlcomponentattached_p.h"
+
+#include "qqmlcomponent_p.h"
+#include "qqmlexpression_p.h"
+#include "qqmlengine_p.h"
+#include "qqmlengine.h"
+#include "qqmlinfo.h"
+#include <private/qv4bindings_p.h>
+#include <private/qv8bindings_p.h>
+
+#include <qjsengine.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QQmlContextPrivate::QQmlContextPrivate()
+: data(0), notifyIndex(-1)
+{
+}
+
+/*!
+ \class QQmlContext
+ \since 4.7
+ \brief The QQmlContext class defines a context within a QML engine.
+ \mainclass
+
+ Contexts allow data to be exposed to the QML components instantiated by the
+ QML engine.
+
+ Each QQmlContext contains a set of properties, distinct from its QObject
+ properties, that allow data to be explicitly bound to a context by name. The
+ context properties are defined and updated by calling
+ QQmlContext::setContextProperty(). The following example shows a Qt model
+ being bound to a context and then accessed from a QML file.
+
+ \code
+ QQmlEngine engine;
+ QStringListModel modelData;
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ context->setContextProperty("myModel", &modelData);
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl());
+ QObject *window = component.create(context);
+ \endcode
+
+ Note it is the responsibility of the creator to delete any QQmlContext it
+ constructs. If the \c context object in the example is no longer needed when the
+ \c window component instance is destroyed, the \c context must be destroyed explicitly.
+ The simplest way to ensure this is to set \c window as the parent of \c context.
+
+ To simplify binding and maintaining larger data sets, a context object can be set
+ on a QQmlContext. All the properties of the context object are available
+ by name in the context, as though they were all individually added through calls
+ to QQmlContext::setContextProperty(). Changes to the property's values are
+ detected through the property's notify signal. Setting a context object is both
+ faster and easier than manually adding and maintaing context property values.
+
+ The following example has the same effect as the previous one, but it uses a context
+ object.
+
+ \code
+ class MyDataSet : ... {
+ ...
+ Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged)
+ ...
+ };
+
+ MyDataSet myDataSet;
+ QQmlEngine engine;
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ context->setContextObject(&myDataSet);
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl());
+ component.create(context);
+ \endcode
+
+ All properties added explicitly by QQmlContext::setContextProperty() take
+ precedence over the context object's properties.
+
+ \section2 The Context Hierarchy
+
+ Contexts form a hierarchy. The root of this hierarchy is the QML engine's
+ \l {QQmlEngine::rootContext()}{root context}. Child contexts inherit
+ the context properties of their parents; if a child context sets a context property
+ that already exists in its parent, the new context property overrides that of the
+ parent.
+
+ The following example defines two contexts - \c context1 and \c context2. The
+ second context overrides the "b" context property inherited from the first with a
+ new value.
+
+ \code
+ QQmlEngine engine;
+ QQmlContext *context1 = new QQmlContext(engine.rootContext());
+ QQmlContext *context2 = new QQmlContext(context1);
+
+ context1->setContextProperty("a", 12);
+ context1->setContextProperty("b", 12);
+
+ context2->setContextProperty("b", 15);
+ \endcode
+
+ While QML objects instantiated in a context are not strictly owned by that
+ context, their bindings are. If a context is destroyed, the property bindings of
+ outstanding QML objects will stop evaluating.
+
+ \warning Setting the context object or adding new context properties after an object
+ 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 Bindings in C++ Applications}
+*/
+
+/*! \internal */
+QQmlContext::QQmlContext(QQmlEngine *e, bool)
+: QObject(*(new QQmlContextPrivate))
+{
+ Q_D(QQmlContext);
+ d->data = new QQmlContextData(this);
+
+ d->data->engine = e;
+}
+
+/*!
+ Create a new QQmlContext as a child of \a engine's root context, and the
+ QObject \a parent.
+*/
+QQmlContext::QQmlContext(QQmlEngine *engine, QObject *parent)
+: QObject(*(new QQmlContextPrivate), parent)
+{
+ Q_D(QQmlContext);
+ d->data = new QQmlContextData(this);
+
+ d->data->setParent(engine?QQmlContextData::get(engine->rootContext()):0);
+}
+
+/*!
+ Create a new QQmlContext with the given \a parentContext, and the
+ QObject \a parent.
+*/
+QQmlContext::QQmlContext(QQmlContext *parentContext, QObject *parent)
+: QObject(*(new QQmlContextPrivate), parent)
+{
+ Q_D(QQmlContext);
+ d->data = new QQmlContextData(this);
+
+ d->data->setParent(parentContext?QQmlContextData::get(parentContext):0);
+}
+
+/*!
+ \internal
+*/
+QQmlContext::QQmlContext(QQmlContextData *data)
+: QObject(*(new QQmlContextPrivate), 0)
+{
+ Q_D(QQmlContext);
+ d->data = data;
+}
+
+/*!
+ Destroys the QQmlContext.
+
+ Any expressions, or sub-contexts dependent on this context will be
+ invalidated, but not destroyed (unless they are parented to the QQmlContext
+ object).
+ */
+QQmlContext::~QQmlContext()
+{
+ Q_D(QQmlContext);
+
+ if (!d->data->isInternal)
+ d->data->destroy();
+}
+
+/*!
+ Returns whether the context is valid.
+
+ To be valid, a context must have a engine, and it's contextObject(), if any,
+ must not have been deleted.
+*/
+bool QQmlContext::isValid() const
+{
+ Q_D(const QQmlContext);
+ return d->data && d->data->isValid();
+}
+
+/*!
+ Return the context's QQmlEngine, or 0 if the context has no QQmlEngine or the
+ QQmlEngine was destroyed.
+*/
+QQmlEngine *QQmlContext::engine() const
+{
+ Q_D(const QQmlContext);
+ return d->data->engine;
+}
+
+/*!
+ Return the context's parent QQmlContext, or 0 if this context has no
+ parent or if the parent has been destroyed.
+*/
+QQmlContext *QQmlContext::parentContext() const
+{
+ Q_D(const QQmlContext);
+ return d->data->parent?d->data->parent->asQQmlContext():0;
+}
+
+/*!
+ Return the context object, or 0 if there is no context object.
+*/
+QObject *QQmlContext::contextObject() const
+{
+ Q_D(const QQmlContext);
+ return d->data->contextObject;
+}
+
+/*!
+ Set the context \a object.
+*/
+void QQmlContext::setContextObject(QObject *object)
+{
+ Q_D(QQmlContext);
+
+ QQmlContextData *data = d->data;
+
+ if (data->isInternal) {
+ qWarning("QQmlContext: Cannot set context object for internal context.");
+ return;
+ }
+
+ if (!isValid()) {
+ qWarning("QQmlContext: Cannot set context object on invalid context.");
+ return;
+ }
+
+ data->contextObject = object;
+}
+
+/*!
+ Set a the \a value of the \a name property on this context.
+*/
+void QQmlContext::setContextProperty(const QString &name, const QVariant &value)
+{
+ Q_D(QQmlContext);
+ if (d->notifyIndex == -1)
+ d->notifyIndex = this->metaObject()->methodCount();
+
+ QQmlContextData *data = d->data;
+
+ if (data->isInternal) {
+ qWarning("QQmlContext: Cannot set property on internal context.");
+ return;
+ }
+
+ if (!isValid()) {
+ qWarning("QQmlContext: Cannot set property on invalid context.");
+ return;
+ }
+
+ if (data->engine) {
+ bool ok;
+ QObject *o = QQmlEnginePrivate::get(data->engine)->toQObject(value, &ok);
+ if (ok) {
+ setContextProperty(name, o);
+ return;
+ }
+ }
+
+ if (!data->propertyNames) data->propertyNames = new QQmlIntegerCache();
+
+ int idx = data->propertyNames->value(name);
+ if (idx == -1) {
+ data->propertyNames->add(name, data->idValueCount + d->propertyValues.count());
+ d->propertyValues.append(value);
+
+ data->refreshExpressions();
+ } else {
+ d->propertyValues[idx] = value;
+ QMetaObject::activate(this, idx + d->notifyIndex, 0);
+ }
+}
+
+/*!
+ Set the \a value of the \a name property on this context.
+
+ QQmlContext does \bold not take ownership of \a value.
+*/
+void QQmlContext::setContextProperty(const QString &name, QObject *value)
+{
+ Q_D(QQmlContext);
+ if (d->notifyIndex == -1)
+ d->notifyIndex = this->metaObject()->methodCount();
+
+ QQmlContextData *data = d->data;
+
+ if (data->isInternal) {
+ qWarning("QQmlContext: Cannot set property on internal context.");
+ return;
+ }
+
+ if (!isValid()) {
+ qWarning("QQmlContext: Cannot set property on invalid context.");
+ return;
+ }
+
+ if (!data->propertyNames) data->propertyNames = new QQmlIntegerCache();
+ int idx = data->propertyNames->value(name);
+
+ if (idx == -1) {
+ data->propertyNames->add(name, data->idValueCount + d->propertyValues.count());
+ d->propertyValues.append(QVariant::fromValue(value));
+
+ data->refreshExpressions();
+ } else {
+ d->propertyValues[idx] = QVariant::fromValue(value);
+ QMetaObject::activate(this, idx + d->notifyIndex, 0);
+ }
+}
+
+/*!
+ Returns the value of the \a name property for this context
+ as a QVariant.
+ */
+QVariant QQmlContext::contextProperty(const QString &name) const
+{
+ Q_D(const QQmlContext);
+ QVariant value;
+ int idx = -1;
+
+ QQmlContextData *data = d->data;
+
+ if (data->propertyNames)
+ idx = data->propertyNames->value(name);
+
+ if (idx == -1) {
+ QByteArray utf8Name = name.toUtf8();
+ if (data->contextObject) {
+ QObject *obj = data->contextObject;
+ QQmlPropertyData local;
+ QQmlPropertyData *property =
+ QQmlPropertyCache::property(data->engine, obj, name, local);
+
+ if (property) value = obj->metaObject()->property(property->coreIndex).read(obj);
+ }
+ if (!value.isValid() && parentContext())
+ value = parentContext()->contextProperty(name);
+ } else {
+ if (idx >= d->propertyValues.count())
+ value = QVariant::fromValue(data->idValues[idx - d->propertyValues.count()].data());
+ else
+ value = d->propertyValues[idx];
+ }
+
+ return value;
+}
+
+/*!
+Returns the name of \a object in this context, or an empty string if \a object
+is not named in the context. Objects are named by setContextProperty(), or by ids in
+the case of QML created contexts.
+
+If the object has multiple names, the first is returned.
+*/
+QString QQmlContext::nameForObject(QObject *object) const
+{
+ Q_D(const QQmlContext);
+
+ return d->data->findObjectId(object);
+}
+
+/*!
+ Resolves the URL \a src relative to the URL of the
+ containing component.
+
+ \sa QQmlEngine::baseUrl(), setBaseUrl()
+*/
+QUrl QQmlContext::resolvedUrl(const QUrl &src)
+{
+ Q_D(QQmlContext);
+ return d->data->resolvedUrl(src);
+}
+
+QUrl QQmlContextData::resolvedUrl(const QUrl &src)
+{
+ QQmlContextData *ctxt = this;
+
+ if (src.isRelative() && !src.isEmpty()) {
+ if (ctxt) {
+ while(ctxt) {
+ if(ctxt->url.isValid())
+ break;
+ else
+ ctxt = ctxt->parent;
+ }
+
+ if (ctxt)
+ return ctxt->url.resolved(src);
+ else if (engine)
+ return engine->baseUrl().resolved(src);
+ }
+ return QUrl();
+ } else {
+ return src;
+ }
+}
+
+
+/*!
+ Explicitly sets the url resolvedUrl() will use for relative references to \a baseUrl.
+
+ Calling this function will override the url of the containing
+ component used by default.
+
+ \sa resolvedUrl()
+*/
+void QQmlContext::setBaseUrl(const QUrl &baseUrl)
+{
+ Q_D(QQmlContext);
+
+ d->data->url = baseUrl;
+ d->data->urlString = baseUrl.toString();
+}
+
+/*!
+ Returns the base url of the component, or the containing component
+ if none is set.
+*/
+QUrl QQmlContext::baseUrl() const
+{
+ Q_D(const QQmlContext);
+ const QQmlContextData* data = d->data;
+ while (data && data->url.isEmpty())
+ data = data->parent;
+
+ if (data)
+ return data->url;
+ else
+ return QUrl();
+}
+
+int QQmlContextPrivate::context_count(QQmlListProperty<QObject> *prop)
+{
+ QQmlContext *context = static_cast<QQmlContext*>(prop->object);
+ QQmlContextPrivate *d = QQmlContextPrivate::get(context);
+ int contextProperty = (int)(quintptr)prop->data;
+
+ if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId<QList<QObject*> >()) {
+ return 0;
+ } else {
+ return ((const QList<QObject> *)d->propertyValues.at(contextProperty).constData())->count();
+ }
+}
+
+QObject *QQmlContextPrivate::context_at(QQmlListProperty<QObject> *prop, int index)
+{
+ QQmlContext *context = static_cast<QQmlContext*>(prop->object);
+ QQmlContextPrivate *d = QQmlContextPrivate::get(context);
+ int contextProperty = (int)(quintptr)prop->data;
+
+ if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId<QList<QObject*> >()) {
+ return 0;
+ } else {
+ return ((const QList<QObject*> *)d->propertyValues.at(contextProperty).constData())->at(index);
+ }
+}
+
+
+QQmlContextData::QQmlContextData()
+: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false),
+ isPragmaLibraryContext(false), unresolvedNames(false), publicContext(0), activeVMEData(0),
+ propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
+ expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0),
+ componentAttached(0), v4bindings(0), v8bindings(0)
+{
+}
+
+QQmlContextData::QQmlContextData(QQmlContext *ctxt)
+: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false),
+ isPragmaLibraryContext(false), unresolvedNames(false), publicContext(ctxt), activeVMEData(0),
+ propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
+ expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0),
+ componentAttached(0), v4bindings(0), v8bindings(0)
+{
+}
+
+void QQmlContextData::invalidate()
+{
+ while (componentAttached) {
+ QQmlComponentAttached *a = componentAttached;
+ componentAttached = a->next;
+ if (componentAttached) componentAttached->prev = &componentAttached;
+
+ a->next = 0;
+ a->prev = 0;
+
+ emit a->destruction();
+ }
+
+ while (childContexts) {
+ if (childContexts->ownedByParent) {
+ childContexts->destroy();
+ } else {
+ childContexts->invalidate();
+ }
+ }
+
+ if (prevChild) {
+ *prevChild = nextChild;
+ if (nextChild) nextChild->prevChild = prevChild;
+ nextChild = 0;
+ prevChild = 0;
+ }
+
+ engine = 0;
+ parent = 0;
+}
+
+void QQmlContextData::clearContext()
+{
+ if (engine) {
+ while (componentAttached) {
+ QQmlComponentAttached *a = componentAttached;
+ componentAttached = a->next;
+ if (componentAttached) componentAttached->prev = &componentAttached;
+
+ a->next = 0;
+ a->prev = 0;
+
+ emit a->destruction();
+ }
+ }
+
+ QQmlAbstractExpression *expression = expressions;
+ while (expression) {
+ QQmlAbstractExpression *nextExpression = expression->m_nextExpression;
+
+ expression->m_prevExpression = 0;
+ expression->m_nextExpression = 0;
+
+ expression->setContext(0);
+
+ expression = nextExpression;
+ }
+ expressions = 0;
+}
+
+void QQmlContextData::destroy()
+{
+ if (linkedContext)
+ linkedContext->destroy();
+
+ if (engine) invalidate();
+
+ clearContext();
+
+ while (contextObjects) {
+ QQmlData *co = contextObjects;
+ contextObjects = contextObjects->nextContextObject;
+
+ co->context = 0;
+ co->outerContext = 0;
+ co->nextContextObject = 0;
+ co->prevContextObject = 0;
+ }
+
+ QQmlGuardedContextData *contextGuard = contextGuards;
+ while (contextGuard) {
+ QQmlGuardedContextData *next = contextGuard->m_next;
+ contextGuard->m_next = 0;
+ contextGuard->m_prev = 0;
+ contextGuard->m_contextData = 0;
+ contextGuard = next;
+ }
+ contextGuards = 0;
+
+ if (propertyNames)
+ propertyNames->release();
+
+ if (imports)
+ imports->release();
+
+ if (v4bindings)
+ v4bindings->release();
+
+ if (v8bindings)
+ v8bindings->release();
+
+ for (int ii = 0; ii < importedScripts.count(); ++ii) {
+ qPersistentDispose(importedScripts[ii]);
+ }
+
+ delete [] idValues;
+
+ if (isInternal)
+ delete publicContext;
+
+ delete this;
+}
+
+void QQmlContextData::setParent(QQmlContextData *p, bool parentTakesOwnership)
+{
+ if (p) {
+ parent = p;
+ engine = p->engine;
+ nextChild = p->childContexts;
+ if (nextChild) nextChild->prevChild = &nextChild;
+ prevChild = &p->childContexts;
+ p->childContexts = this;
+ ownedByParent = parentTakesOwnership;
+ }
+}
+
+void QQmlContextData::refreshExpressionsRecursive(QQmlAbstractExpression *expression)
+{
+ QQmlAbstractExpression::DeleteWatcher w(expression);
+
+ if (expression->m_nextExpression)
+ refreshExpressionsRecursive(expression->m_nextExpression);
+
+ if (!w.wasDeleted())
+ expression->refresh();
+}
+
+static inline bool expressions_to_run(QQmlContextData *ctxt, bool isGlobalRefresh)
+{
+ return ctxt->expressions && (!isGlobalRefresh || ctxt->unresolvedNames);
+}
+
+void QQmlContextData::refreshExpressionsRecursive(bool isGlobal)
+{
+ // For efficiency, we try and minimize the number of guards we have to create
+ if (expressions_to_run(this, isGlobal) && (nextChild || childContexts)) {
+ QQmlGuardedContextData guard(this);
+
+ if (childContexts)
+ childContexts->refreshExpressionsRecursive(isGlobal);
+
+ if (guard.isNull()) return;
+
+ if (nextChild)
+ nextChild->refreshExpressionsRecursive(isGlobal);
+
+ if (guard.isNull()) return;
+
+ if (expressions_to_run(this, isGlobal))
+ refreshExpressionsRecursive(expressions);
+
+ } else if (expressions_to_run(this, isGlobal)) {
+
+ refreshExpressionsRecursive(expressions);
+
+ } else if (nextChild && childContexts) {
+
+ QQmlGuardedContextData guard(this);
+
+ childContexts->refreshExpressionsRecursive(isGlobal);
+
+ if (!guard.isNull() && nextChild)
+ nextChild->refreshExpressionsRecursive(isGlobal);
+
+ } else if (nextChild) {
+
+ nextChild->refreshExpressionsRecursive(isGlobal);
+
+ } else if (childContexts) {
+
+ childContexts->refreshExpressionsRecursive(isGlobal);
+
+ }
+}
+
+// Refreshes all expressions that could possibly depend on this context. Refreshing flushes all
+// context-tree dependent caches in the expressions, and should occur every time the context tree
+// *structure* (not values) changes.
+void QQmlContextData::refreshExpressions()
+{
+ bool isGlobal = (parent == 0);
+
+ // For efficiency, we try and minimize the number of guards we have to create
+ if (expressions_to_run(this, isGlobal) && childContexts) {
+ QQmlGuardedContextData guard(this);
+
+ childContexts->refreshExpressionsRecursive(isGlobal);
+
+ if (!guard.isNull() && expressions_to_run(this, isGlobal))
+ refreshExpressionsRecursive(expressions);
+
+ } else if (expressions_to_run(this, isGlobal)) {
+
+ refreshExpressionsRecursive(expressions);
+
+ } else if (childContexts) {
+
+ childContexts->refreshExpressionsRecursive(isGlobal);
+
+ }
+}
+
+void QQmlContextData::addObject(QObject *o)
+{
+ QQmlData *data = QQmlData::get(o, true);
+
+ Q_ASSERT(data->context == 0);
+
+ data->context = this;
+ data->outerContext = this;
+
+ data->nextContextObject = contextObjects;
+ if (data->nextContextObject)
+ data->nextContextObject->prevContextObject = &data->nextContextObject;
+ data->prevContextObject = &contextObjects;
+ contextObjects = data;
+}
+
+void QQmlContextData::setIdProperty(int idx, QObject *obj)
+{
+ idValues[idx] = obj;
+ idValues[idx].context = this;
+}
+
+void QQmlContextData::setIdPropertyData(QQmlIntegerCache *data)
+{
+ Q_ASSERT(!propertyNames);
+ propertyNames = data;
+ propertyNames->addref();
+
+ idValueCount = data->count();
+ idValues = new ContextGuard[idValueCount];
+}
+
+QString QQmlContextData::findObjectId(const QObject *obj) const
+{
+ if (!propertyNames)
+ return QString();
+
+ for (int ii = 0; ii < idValueCount; ii++) {
+ if (idValues[ii] == obj)
+ return propertyNames->findId(ii);
+ }
+
+ if (publicContext) {
+ QQmlContextPrivate *p = QQmlContextPrivate::get(publicContext);
+ for (int ii = 0; ii < p->propertyValues.count(); ++ii)
+ if (p->propertyValues.at(ii) == QVariant::fromValue((QObject *)obj))
+ return propertyNames->findId(ii);
+ }
+
+ if (linkedContext)
+ return linkedContext->findObjectId(obj);
+ return QString();
+}
+
+QQmlContext *QQmlContextData::asQQmlContext()
+{
+ if (!publicContext)
+ publicContext = new QQmlContext(this);
+ return publicContext;
+}
+
+QQmlContextPrivate *QQmlContextData::asQQmlContextPrivate()
+{
+ return QQmlContextPrivate::get(asQQmlContext());
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcontext.h b/src/qml/qml/qqmlcontext.h
new file mode 100644
index 0000000000..f6d8aa1d3a
--- /dev/null
+++ b/src/qml/qml/qqmlcontext.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCONTEXT_H
+#define QQMLCONTEXT_H
+
+#include <QtCore/qurl.h>
+#include <QtCore/qobject.h>
+#include <QtQml/qjsvalue.h>
+#include <QtCore/qmetatype.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QString;
+class QQmlEngine;
+class QQmlRefCount;
+class QQmlContextPrivate;
+class QQmlCompositeTypeData;
+class QQmlContextData;
+
+class Q_QML_EXPORT QQmlContext : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQmlContext)
+
+public:
+ QQmlContext(QQmlEngine *parent, QObject *objParent=0);
+ QQmlContext(QQmlContext *parent, QObject *objParent=0);
+ virtual ~QQmlContext();
+
+ bool isValid() const;
+
+ QQmlEngine *engine() const;
+ QQmlContext *parentContext() const;
+
+ QObject *contextObject() const;
+ void setContextObject(QObject *);
+
+ QVariant contextProperty(const QString &) const;
+ void setContextProperty(const QString &, QObject *);
+ void setContextProperty(const QString &, const QVariant &);
+
+ QString nameForObject(QObject *) const;
+
+ QUrl resolvedUrl(const QUrl &);
+
+ void setBaseUrl(const QUrl &);
+ QUrl baseUrl() const;
+
+private:
+ friend class QQmlVME;
+ friend class QQmlEngine;
+ friend class QQmlEnginePrivate;
+ friend class QQmlExpression;
+ friend class QQmlExpressionPrivate;
+ friend class QQmlComponent;
+ friend class QQmlComponentPrivate;
+ friend class QQmlScriptPrivate;
+ friend class QQmlBoundSignalProxy;
+ friend class QQmlContextData;
+ QQmlContext(QQmlContextData *);
+ QQmlContext(QQmlEngine *, bool);
+ Q_DISABLE_COPY(QQmlContext)
+};
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QList<QObject*>)
+
+QT_END_HEADER
+
+#endif // QQMLCONTEXT_H
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h
new file mode 100644
index 0000000000..d10543bde5
--- /dev/null
+++ b/src/qml/qml/qqmlcontext_p.h
@@ -0,0 +1,334 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCONTEXT_P_H
+#define QQMLCONTEXT_P_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 "qqmlcontext.h"
+
+#include "qqmldata_p.h"
+#include "qqmlintegercache_p.h"
+#include "qqmltypenamecache_p.h"
+#include "qqmlnotifier_p.h"
+#include "qqmllist.h"
+#include "qqmlscript_p.h"
+
+#include <QtCore/qhash.h>
+#include <QtQml/qjsvalue.h>
+#include <QtCore/qset.h>
+
+#include <private/qobject_p.h>
+#include <private/qflagpointer_p.h>
+#include <private/qqmlguard_p.h>
+
+#include <private/qv8_p.h>
+
+
+QT_BEGIN_NAMESPACE
+
+class QV8Bindings;
+class QQmlContext;
+class QQmlExpression;
+class QQmlEngine;
+class QQmlExpression;
+class QQmlExpressionPrivate;
+class QQmlAbstractExpression;
+class QV4Bindings;
+class QQmlContextData;
+
+class QQmlContextPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlContext)
+public:
+ QQmlContextPrivate();
+
+ QQmlContextData *data;
+
+ QList<QVariant> propertyValues;
+ int notifyIndex;
+
+ static QQmlContextPrivate *get(QQmlContext *context) {
+ return static_cast<QQmlContextPrivate *>(QObjectPrivate::get(context));
+ }
+ static QQmlContext *get(QQmlContextPrivate *context) {
+ return static_cast<QQmlContext *>(context->q_func());
+ }
+
+ // Only used for debugging
+ QList<QPointer<QObject> > instances;
+
+ static int context_count(QQmlListProperty<QObject> *);
+ static QObject *context_at(QQmlListProperty<QObject> *, int);
+};
+
+class QQmlVME;
+class QQmlComponentAttached;
+class QQmlGuardedContextData;
+class Q_QML_EXPORT QQmlContextData
+{
+public:
+ QQmlContextData();
+ QQmlContextData(QQmlContext *);
+ void clearContext();
+ void destroy();
+ void invalidate();
+
+ inline bool isValid() const {
+ return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted);
+ }
+
+ // My parent context and engine
+ QQmlContextData *parent;
+ QQmlEngine *engine;
+
+ void setParent(QQmlContextData *, bool parentTakesOwnership = false);
+ void refreshExpressions();
+
+ void addObject(QObject *);
+
+ QUrl resolvedUrl(const QUrl &);
+
+ // My containing QQmlContext. If isInternal is true this owns publicContext.
+ // If internal is false publicContext owns this.
+ QQmlContext *asQQmlContext();
+ QQmlContextPrivate *asQQmlContextPrivate();
+ quint32 isInternal:1;
+ quint32 ownedByParent:1; // unrelated to isInternal; parent context deletes children if true.
+ quint32 isJSContext:1;
+ quint32 isPragmaLibraryContext:1;
+ quint32 unresolvedNames:1; // True if expressions in this context failed to resolve a toplevel name
+ quint32 dummy:28;
+ QQmlContext *publicContext;
+
+ // VME data that is constructing this context if any
+ void *activeVMEData;
+
+ // Property name cache
+ QQmlIntegerCache *propertyNames;
+
+ // Context object
+ QObject *contextObject;
+
+ // Any script blocks that exist on this context
+ QList<v8::Persistent<v8::Object> > importedScripts;
+
+ // Context base url
+ QUrl url;
+ QString urlString;
+
+ // List of imports that apply to this context
+ QQmlTypeNameCache *imports;
+
+ // My children
+ QQmlContextData *childContexts;
+
+ // My peers in parent's childContexts list
+ QQmlContextData *nextChild;
+ QQmlContextData **prevChild;
+
+ // Expressions that use this context
+ QQmlAbstractExpression *expressions;
+
+ // Doubly-linked list of objects that are owned by this context
+ QQmlData *contextObjects;
+
+ // Doubly-linked list of context guards (XXX merge with contextObjects)
+ QQmlGuardedContextData *contextGuards;
+
+ // id guards
+ struct ContextGuard : public QQmlGuard<QObject>
+ {
+ inline ContextGuard();
+ inline ContextGuard &operator=(QObject *obj);
+ inline void objectDestroyed(QObject *);
+
+ inline bool wasSet() const;
+
+ QFlagPointer<QQmlContextData> context;
+ QQmlNotifier bindings;
+ };
+ ContextGuard *idValues;
+ int idValueCount;
+ void setIdProperty(int, QObject *);
+ void setIdPropertyData(QQmlIntegerCache *);
+
+ // Linked contexts. this owns linkedContext.
+ QQmlContextData *linkedContext;
+
+ // Linked list of uses of the Component attached property in this
+ // context
+ QQmlComponentAttached *componentAttached;
+
+ // Optimized binding objects. Needed for deferred properties.
+ QV4Bindings *v4bindings;
+ QV8Bindings *v8bindings;
+
+ // Return the outermost id for obj, if any.
+ QString findObjectId(const QObject *obj) const;
+
+ static QQmlContextData *get(QQmlContext *context) {
+ return QQmlContextPrivate::get(context)->data;
+ }
+
+private:
+ void refreshExpressionsRecursive(bool isGlobal);
+ void refreshExpressionsRecursive(QQmlAbstractExpression *);
+ ~QQmlContextData() {}
+};
+
+class QQmlGuardedContextData
+{
+public:
+ inline QQmlGuardedContextData();
+ inline QQmlGuardedContextData(QQmlContextData *);
+ inline ~QQmlGuardedContextData();
+
+ inline QQmlContextData *contextData();
+ inline void setContextData(QQmlContextData *);
+
+ inline bool isNull() const { return !m_contextData; }
+
+ inline operator QQmlContextData*() const { return m_contextData; }
+ inline QQmlContextData* operator->() const { return m_contextData; }
+ inline QQmlGuardedContextData &operator=(QQmlContextData *d);
+
+private:
+ QQmlGuardedContextData &operator=(const QQmlGuardedContextData &);
+ QQmlGuardedContextData(const QQmlGuardedContextData &);
+ friend class QQmlContextData;
+
+ inline void clear();
+
+ QQmlContextData *m_contextData;
+ QQmlGuardedContextData *m_next;
+ QQmlGuardedContextData **m_prev;
+};
+
+QQmlGuardedContextData::QQmlGuardedContextData()
+: m_contextData(0), m_next(0), m_prev(0)
+{
+}
+
+QQmlGuardedContextData::QQmlGuardedContextData(QQmlContextData *data)
+: m_contextData(0), m_next(0), m_prev(0)
+{
+ setContextData(data);
+}
+
+QQmlGuardedContextData::~QQmlGuardedContextData()
+{
+ clear();
+}
+
+void QQmlGuardedContextData::setContextData(QQmlContextData *contextData)
+{
+ clear();
+
+ if (contextData) {
+ m_contextData = contextData;
+ m_next = contextData->contextGuards;
+ if (m_next) m_next->m_prev = &m_next;
+ m_prev = &contextData->contextGuards;
+ contextData->contextGuards = this;
+ }
+}
+
+QQmlContextData *QQmlGuardedContextData::contextData()
+{
+ return m_contextData;
+}
+
+void QQmlGuardedContextData::clear()
+{
+ if (m_prev) {
+ *m_prev = m_next;
+ if (m_next) m_next->m_prev = m_prev;
+ m_contextData = 0;
+ m_next = 0;
+ m_prev = 0;
+ }
+}
+
+QQmlGuardedContextData &
+QQmlGuardedContextData::operator=(QQmlContextData *d)
+{
+ setContextData(d);
+ return *this;
+}
+
+QQmlContextData::ContextGuard::ContextGuard()
+: context(0)
+{
+}
+
+QQmlContextData::ContextGuard &QQmlContextData::ContextGuard::operator=(QObject *obj)
+{
+ QQmlGuard<QObject>::operator=(obj);
+ context.setFlag();
+ bindings.notify(); // For alias connections
+ return *this;
+}
+
+void QQmlContextData::ContextGuard::objectDestroyed(QObject *)
+{
+ if (context->contextObject && !QObjectPrivate::get(context->contextObject)->wasDeleted)
+ bindings.notify();
+}
+
+bool QQmlContextData::ContextGuard::wasSet() const
+{
+ return context.flag();
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLCONTEXT_P_H
diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp
new file mode 100644
index 0000000000..f888b61e7d
--- /dev/null
+++ b/src/qml/qml/qqmlcustomparser.cpp
@@ -0,0 +1,319 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlcustomparser_p.h"
+#include "qqmlcustomparser_p_p.h"
+
+#include "qqmlcompiler_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QQmlScript;
+
+/*!
+ \class QQmlCustomParser
+ \brief The QQmlCustomParser class allows you to add new arbitrary types to QML.
+ \internal
+
+ By subclassing QQmlCustomParser, you can add a parser for
+ building a particular type.
+
+ The subclass must implement compile() and setCustomData(), and register
+ itself in the meta type system by calling the macro:
+
+ \code
+ QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass)
+ \endcode
+*/
+
+/*
+ \fn QByteArray QQmlCustomParser::compile(const QList<QQmlCustomParserProperty> & properties)
+
+ The custom parser processes \a properties, and returns
+ a QByteArray containing data meaningful only to the
+ custom parser; the type engine will pass this same data to
+ setCustomData() when making an instance of the data.
+
+ Errors must be reported via the error() functions.
+
+ The QByteArray may be cached between executions of the system, so
+ it must contain correctly-serialized data (not, for example,
+ pointers to stack objects).
+*/
+
+/*
+ \fn void QQmlCustomParser::setCustomData(QObject *object, const QByteArray &data)
+
+ This function sets \a object to have the properties defined
+ by \a data, which is a block of data previously returned by a call
+ to compile().
+
+ Errors should be reported using qmlInfo(object).
+
+ The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE.
+*/
+
+QQmlCustomParserNode
+QQmlCustomParserNodePrivate::fromObject(QQmlScript::Object *root)
+{
+ QQmlCustomParserNode rootNode;
+ rootNode.d->name = root->typeName;
+ rootNode.d->location = root->location.start;
+
+ for (Property *p = root->properties.first(); p; p = root->properties.next(p)) {
+ rootNode.d->properties << fromProperty(p);
+ }
+
+ if (root->defaultProperty)
+ rootNode.d->properties << fromProperty(root->defaultProperty);
+
+ return rootNode;
+}
+
+QQmlCustomParserProperty
+QQmlCustomParserNodePrivate::fromProperty(QQmlScript::Property *p)
+{
+ QQmlCustomParserProperty prop;
+ prop.d->name = p->name().toString();
+ prop.d->isList = p->values.isMany();
+ prop.d->location = p->location.start;
+
+ if (p->value) {
+ QQmlCustomParserNode node = fromObject(p->value);
+ QList<QQmlCustomParserProperty> props = node.properties();
+ for (int ii = 0; ii < props.count(); ++ii)
+ prop.d->values << QVariant::fromValue(props.at(ii));
+ } else {
+ for (QQmlScript::Value *v = p->values.first(); v; v = p->values.next(v)) {
+ v->type = QQmlScript::Value::Literal;
+
+ if(v->object) {
+ QQmlCustomParserNode node = fromObject(v->object);
+ prop.d->values << QVariant::fromValue(node);
+ } else {
+ prop.d->values << QVariant::fromValue(v->value);
+ }
+
+ }
+ }
+
+ return prop;
+}
+
+QQmlCustomParserNode::QQmlCustomParserNode()
+: d(new QQmlCustomParserNodePrivate)
+{
+}
+
+QQmlCustomParserNode::QQmlCustomParserNode(const QQmlCustomParserNode &other)
+: d(new QQmlCustomParserNodePrivate)
+{
+ *this = other;
+}
+
+QQmlCustomParserNode &QQmlCustomParserNode::operator=(const QQmlCustomParserNode &other)
+{
+ d->name = other.d->name;
+ d->properties = other.d->properties;
+ d->location = other.d->location;
+ return *this;
+}
+
+QQmlCustomParserNode::~QQmlCustomParserNode()
+{
+ delete d; d = 0;
+}
+
+QString QQmlCustomParserNode::name() const
+{
+ return d->name;
+}
+
+QList<QQmlCustomParserProperty> QQmlCustomParserNode::properties() const
+{
+ return d->properties;
+}
+
+QQmlScript::Location QQmlCustomParserNode::location() const
+{
+ return d->location;
+}
+
+QQmlCustomParserProperty::QQmlCustomParserProperty()
+: d(new QQmlCustomParserPropertyPrivate)
+{
+}
+
+QQmlCustomParserProperty::QQmlCustomParserProperty(const QQmlCustomParserProperty &other)
+: d(new QQmlCustomParserPropertyPrivate)
+{
+ *this = other;
+}
+
+QQmlCustomParserProperty &QQmlCustomParserProperty::operator=(const QQmlCustomParserProperty &other)
+{
+ d->name = other.d->name;
+ d->isList = other.d->isList;
+ d->values = other.d->values;
+ d->location = other.d->location;
+ return *this;
+}
+
+QQmlCustomParserProperty::~QQmlCustomParserProperty()
+{
+ delete d; d = 0;
+}
+
+QString QQmlCustomParserProperty::name() const
+{
+ return d->name;
+}
+
+bool QQmlCustomParserProperty::isList() const
+{
+ return d->isList;
+}
+
+QQmlScript::Location QQmlCustomParserProperty::location() const
+{
+ return d->location;
+}
+
+QList<QVariant> QQmlCustomParserProperty::assignedValues() const
+{
+ return d->values;
+}
+
+void QQmlCustomParser::clearErrors()
+{
+ exceptions.clear();
+}
+
+/*!
+ Reports an error with the given \a description.
+
+ This can only be used during the compile() step. For errors during setCustomData(), use qmlInfo().
+
+ An error is generated referring to the position of the element in the source file.
+*/
+void QQmlCustomParser::error(const QString& description)
+{
+ Q_ASSERT(object);
+ QQmlError error;
+ QString exceptionDescription;
+ error.setLine(object->location.start.line);
+ error.setColumn(object->location.start.column);
+ error.setDescription(description);
+ exceptions << error;
+}
+
+/*!
+ Reports an error in parsing \a prop, with the given \a description.
+
+ An error is generated referring to the position of \a node in the source file.
+*/
+void QQmlCustomParser::error(const QQmlCustomParserProperty& prop, const QString& description)
+{
+ QQmlError error;
+ QString exceptionDescription;
+ error.setLine(prop.location().line);
+ error.setColumn(prop.location().column);
+ error.setDescription(description);
+ exceptions << error;
+}
+
+/*!
+ Reports an error in parsing \a node, with the given \a description.
+
+ An error is generated referring to the position of \a node in the source file.
+*/
+void QQmlCustomParser::error(const QQmlCustomParserNode& node, const QString& description)
+{
+ QQmlError error;
+ QString exceptionDescription;
+ error.setLine(node.location().line);
+ error.setColumn(node.location().column);
+ error.setDescription(description);
+ exceptions << error;
+}
+
+/*!
+ If \a script is a simply enum expression (eg. Text.AlignLeft),
+ returns the integer equivalent (eg. 1).
+
+ Otherwise, returns -1.
+*/
+int QQmlCustomParser::evaluateEnum(const QByteArray& script) const
+{
+ return compiler->evaluateEnum(script);
+}
+
+/*!
+ Resolves \a name to a type, or 0 if it is not a type. This can be used
+ to type-check object nodes.
+*/
+const QMetaObject *QQmlCustomParser::resolveType(const QString& name) const
+{
+ return compiler->resolveType(name);
+}
+
+/*!
+ Rewrites \a value and returns an identifier that can be
+ used to construct the binding later. \a name
+ is used as the name of the rewritten function.
+*/
+QQmlBinding::Identifier QQmlCustomParser::rewriteBinding(const QQmlScript::Variant &value, const QString& name)
+{
+ return compiler->rewriteBinding(value, name);
+}
+
+/*!
+ Returns a rewritten \a handler. \a name
+ is used as the name of the rewritten function.
+*/
+QString QQmlCustomParser::rewriteSignalHandler(const QQmlScript::Variant &value, const QString &name)
+{
+ return compiler->rewriteSignalHandler(value , name);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcustomparser_p.h b/src/qml/qml/qqmlcustomparser_p.h
new file mode 100644
index 0000000000..ecc4bae4c3
--- /dev/null
+++ b/src/qml/qml/qqmlcustomparser_p.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCUSTOMPARSER_H
+#define QQMLCUSTOMPARSER_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 "qqmlmetatype_p.h"
+#include "qqmlerror.h"
+#include "qqmlscript_p.h"
+#include "qqmlbinding_p.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qxmlstream.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlCompiler;
+
+class QQmlCustomParserPropertyPrivate;
+class Q_QML_EXPORT QQmlCustomParserProperty
+{
+public:
+ QQmlCustomParserProperty();
+ QQmlCustomParserProperty(const QQmlCustomParserProperty &);
+ QQmlCustomParserProperty &operator=(const QQmlCustomParserProperty &);
+ ~QQmlCustomParserProperty();
+
+ QString name() const;
+ QQmlScript::Location location() const;
+
+ bool isList() const;
+ // Will be one of QQmlScript::Variant, QQmlCustomParserProperty or
+ // QQmlCustomParserNode
+ QList<QVariant> assignedValues() const;
+
+private:
+ friend class QQmlCustomParserNodePrivate;
+ friend class QQmlCustomParserPropertyPrivate;
+ QQmlCustomParserPropertyPrivate *d;
+};
+
+class QQmlCustomParserNodePrivate;
+class Q_QML_EXPORT QQmlCustomParserNode
+{
+public:
+ QQmlCustomParserNode();
+ QQmlCustomParserNode(const QQmlCustomParserNode &);
+ QQmlCustomParserNode &operator=(const QQmlCustomParserNode &);
+ ~QQmlCustomParserNode();
+
+ QString name() const;
+ QQmlScript::Location location() const;
+
+ QList<QQmlCustomParserProperty> properties() const;
+
+private:
+ friend class QQmlCustomParserNodePrivate;
+ QQmlCustomParserNodePrivate *d;
+};
+
+class Q_QML_EXPORT QQmlCustomParser
+{
+public:
+ enum Flag {
+ NoFlag = 0x00000000,
+ AcceptsAttachedProperties = 0x00000001,
+ AcceptsSignalHandlers = 0x00000002
+ };
+ Q_DECLARE_FLAGS(Flags, Flag)
+
+ QQmlCustomParser() : compiler(0), object(0), m_flags(NoFlag) {}
+ QQmlCustomParser(Flags f) : compiler(0), object(0), m_flags(f) {}
+ virtual ~QQmlCustomParser() {}
+
+ void clearErrors();
+ Flags flags() const { return m_flags; }
+
+ virtual QByteArray compile(const QList<QQmlCustomParserProperty> &)=0;
+ virtual void setCustomData(QObject *, const QByteArray &)=0;
+
+ QList<QQmlError> errors() const { return exceptions; }
+
+protected:
+ void error(const QString& description);
+ void error(const QQmlCustomParserProperty&, const QString& description);
+ void error(const QQmlCustomParserNode&, const QString& description);
+
+ int evaluateEnum(const QByteArray&) const;
+
+ const QMetaObject *resolveType(const QString&) const;
+
+ QQmlBinding::Identifier rewriteBinding(const QQmlScript::Variant&, const QString&);
+ QString rewriteSignalHandler(const QQmlScript::Variant&, const QString&);
+
+private:
+ QList<QQmlError> exceptions;
+ QQmlCompiler *compiler;
+ QQmlScript::Object *object;
+ Flags m_flags;
+ friend class QQmlCompiler;
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlCustomParser::Flags);
+
+#if 0
+#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
+ qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)
+#endif
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlCustomParserProperty)
+Q_DECLARE_METATYPE(QQmlCustomParserNode)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/qml/qml/qqmlcustomparser_p_p.h b/src/qml/qml/qqmlcustomparser_p_p.h
new file mode 100644
index 0000000000..c861f9e944
--- /dev/null
+++ b/src/qml/qml/qqmlcustomparser_p_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLCUSTOMPARSER_P_H
+#define QQMLCUSTOMPARSER_P_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 "qqmlcustomparser_p.h"
+
+#include "qqmlscript_p.h"
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlCustomParserNodePrivate
+{
+public:
+ QString name;
+ QList<QQmlCustomParserProperty> properties;
+ QQmlScript::Location location;
+
+ static QQmlCustomParserNode fromObject(QQmlScript::Object *);
+ static QQmlCustomParserProperty fromProperty(QQmlScript::Property *);
+};
+
+class QQmlCustomParserPropertyPrivate
+{
+public:
+ QQmlCustomParserPropertyPrivate()
+ : isList(false) {}
+
+ QString name;
+ bool isList;
+ QQmlScript::Location location;
+ QList<QVariant> values;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLCUSTOMPARSER_P_H
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
new file mode 100644
index 0000000000..e4ba44583d
--- /dev/null
+++ b/src/qml/qml/qqmldata_p.h
@@ -0,0 +1,207 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDATA_P_H
+#define QQMLDATA_P_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 <private/qtqmlglobal_p.h>
+#include <private/qobject_p.h>
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+template <class Key, class T> class QHash;
+class QQmlGuardImpl;
+class QQmlCompiledData;
+class QQmlAbstractBinding;
+class QQmlContext;
+class QQmlPropertyCache;
+class QQmlContextData;
+class QQmlNotifier;
+class QQmlDataExtended;
+class QQmlNotifierEndpoint;
+// This class is structured in such a way, that simply zero'ing it is the
+// default state for elemental object allocations. This is crucial in the
+// workings of the QQmlInstruction::CreateSimpleObject instruction.
+// Don't change anything here without first considering that case!
+class Q_QML_EXPORT QQmlData : public QAbstractDeclarativeData
+{
+public:
+ QQmlData()
+ : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false),
+ hasTaintedV8Object(false), notifyList(0), context(0), outerContext(0), bindings(0),
+ nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0),
+ lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), v8objectid(0),
+ propertyCache(0), guards(0), extendedData(0) {
+ init();
+ }
+
+ static inline void init() {
+ QAbstractDeclarativeData::destroyed = destroyed;
+ QAbstractDeclarativeData::parentChanged = parentChanged;
+ QAbstractDeclarativeData::objectNameChanged = objectNameChanged;
+ QAbstractDeclarativeData::signalEmitted = signalEmitted;
+ }
+
+ static void destroyed(QAbstractDeclarativeData *, QObject *);
+ static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *);
+ static void objectNameChanged(QAbstractDeclarativeData *, QObject *);
+ static void signalEmitted(QAbstractDeclarativeData *, QObject *, int, void **);
+
+ void destroyed(QObject *);
+ void parentChanged(QObject *, QObject *);
+ void objectNameChanged(QObject *);
+
+ void setImplicitDestructible() {
+ if (!explicitIndestructibleSet) indestructible = false;
+ }
+
+ quint32 ownMemory:1;
+ quint32 ownContext:1;
+ quint32 indestructible:1;
+ quint32 explicitIndestructibleSet:1;
+ quint32 hasTaintedV8Object:1;
+ quint32 dummy:27;
+
+ struct NotifyList {
+ quint64 connectionMask;
+
+ quint16 maximumTodoIndex;
+ quint16 notifiesSize;
+
+ QQmlNotifierEndpoint *todo;
+ QQmlNotifierEndpoint**notifies;
+ void layout();
+ private:
+ void layout(QQmlNotifierEndpoint*);
+ };
+ NotifyList *notifyList;
+
+ inline QQmlNotifierEndpoint *notify(int index);
+ void addNotify(int index, QQmlNotifierEndpoint *);
+
+ // The context that created the C++ object
+ QQmlContextData *context;
+ // The outermost context in which this object lives
+ QQmlContextData *outerContext;
+
+ QQmlAbstractBinding *bindings;
+
+ // Linked list for QQmlContext::contextObjects
+ QQmlData *nextContextObject;
+ QQmlData**prevContextObject;
+
+ int bindingBitsSize;
+ quint32 *bindingBits;
+ bool hasBindingBit(int) const;
+ void clearBindingBit(int);
+ void setBindingBit(QObject *obj, int);
+
+ ushort lineNumber;
+ ushort columnNumber;
+
+ QQmlCompiledData *deferredComponent; // Can't this be found from the context?
+ unsigned int deferredIdx;
+
+ quint32 v8objectid;
+ v8::Persistent<v8::Object> v8object;
+
+ QQmlPropertyCache *propertyCache;
+
+ QQmlGuardImpl *guards;
+
+ static QQmlData *get(const QObject *object, bool create = false) {
+ QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
+ if (priv->wasDeleted) {
+ Q_ASSERT(!create);
+ return 0;
+ } else if (priv->declarativeData) {
+ return static_cast<QQmlData *>(priv->declarativeData);
+ } else if (create) {
+ priv->declarativeData = new QQmlData;
+ return static_cast<QQmlData *>(priv->declarativeData);
+ } else {
+ return 0;
+ }
+ }
+
+ bool hasExtendedData() const { return extendedData != 0; }
+ QQmlNotifier *objectNameNotifier() const;
+ QHash<int, QObject *> *attachedProperties() const;
+
+private:
+ // For objectNameNotifier and attachedProperties
+ mutable QQmlDataExtended *extendedData;
+};
+
+QQmlNotifierEndpoint *QQmlData::notify(int index)
+{
+ Q_ASSERT(index <= 0xFFFF);
+
+ if (!notifyList || !(notifyList->connectionMask & (1ULL << quint64(index % 64)))) {
+ return 0;
+ } else if (index < notifyList->notifiesSize) {
+ return notifyList->notifies[index];
+ } else if (index <= notifyList->maximumTodoIndex) {
+ notifyList->layout();
+ }
+
+ if (index < notifyList->notifiesSize) {
+ return notifyList->notifies[index];
+ } else {
+ return 0;
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLDATA_P_H
diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp
new file mode 100644
index 0000000000..7b99214f04
--- /dev/null
+++ b/src/qml/qml/qqmldirparser.cpp
@@ -0,0 +1,298 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldirparser_p.h"
+#include "qqmlerror.h"
+#include "qqmlglobal_p.h"
+
+#include <QtCore/QTextStream>
+#include <QtCore/QFile>
+#include <QtCore/QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QQmlDirParser::QQmlDirParser()
+ : _isParsed(false)
+{
+}
+
+QQmlDirParser::~QQmlDirParser()
+{
+}
+
+QUrl QQmlDirParser::url() const
+{
+ return _url;
+}
+
+void QQmlDirParser::setUrl(const QUrl &url)
+{
+ _url = url;
+}
+
+QString QQmlDirParser::fileSource() const
+{
+ return _filePathSouce;
+}
+
+void QQmlDirParser::setFileSource(const QString &filePath)
+{
+ _filePathSouce = filePath;
+}
+
+QString QQmlDirParser::source() const
+{
+ return _source;
+}
+
+void QQmlDirParser::setSource(const QString &source)
+{
+ _isParsed = false;
+ _source = source;
+}
+
+bool QQmlDirParser::isParsed() const
+{
+ return _isParsed;
+}
+
+bool QQmlDirParser::parse()
+{
+ if (_isParsed)
+ return true;
+
+ _isParsed = true;
+ _errors.clear();
+ _plugins.clear();
+ _components.clear();
+ _scripts.clear();
+
+ if (_source.isEmpty() && !_filePathSouce.isEmpty()) {
+ QFile file(_filePathSouce);
+ if (!QQml_isFileCaseCorrect(_filePathSouce)) {
+ QQmlError error;
+ error.setDescription(QString::fromUtf8("cannot load module \"$$URI$$\": File name case mismatch for \"%1\"").arg(_filePathSouce));
+ _errors.prepend(error);
+ return false;
+ } else if (file.open(QFile::ReadOnly)) {
+ _source = QString::fromUtf8(file.readAll());
+ } else {
+ QQmlError error;
+ error.setDescription(QString::fromUtf8("module \"$$URI$$\" definition \"%1\" not readable").arg(_filePathSouce));
+ _errors.prepend(error);
+ return false;
+ }
+ }
+
+ QTextStream stream(&_source);
+ int lineNumber = 0;
+
+ forever {
+ ++lineNumber;
+
+ const QString line = stream.readLine();
+ if (line.isNull())
+ break;
+
+ QString sections[3];
+ int sectionCount = 0;
+
+ int index = 0;
+ const int length = line.length();
+
+ while (index != length) {
+ const QChar ch = line.at(index);
+
+ if (ch.isSpace()) {
+ do { ++index; }
+ while (index != length && line.at(index).isSpace());
+
+ } else if (ch == QLatin1Char('#')) {
+ // recognized a comment
+ break;
+
+ } else {
+ const int start = index;
+
+ do { ++index; }
+ while (index != length && !line.at(index).isSpace());
+
+ const QString lexeme = line.mid(start, index - start);
+
+ if (sectionCount >= 3) {
+ reportError(lineNumber, start, QLatin1String("unexpected token"));
+
+ } else {
+ sections[sectionCount++] = lexeme;
+ }
+ }
+ }
+
+ if (sectionCount == 0) {
+ continue; // no sections, no party.
+
+ } else if (sections[0] == QLatin1String("plugin")) {
+ if (sectionCount < 2) {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1));
+
+ continue;
+ }
+
+ const Plugin entry(sections[1], sections[2]);
+
+ _plugins.append(entry);
+
+ } else if (sections[0] == QLatin1String("internal")) {
+ if (sectionCount != 3) {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
+ continue;
+ }
+ Component entry(sections[1], sections[2], -1, -1);
+ entry.internal = true;
+ _components.append(entry);
+ } else if (sections[0] == QLatin1String("typeinfo")) {
+ if (sectionCount != 2) {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
+ continue;
+ }
+#ifdef QT_CREATOR
+ TypeInfo typeInfo(sections[1]);
+ _typeInfos.append(typeInfo);
+#endif
+
+ } else if (sectionCount == 2) {
+ // No version specified (should only be used for relative qmldir files)
+ const Component entry(sections[0], sections[1], -1, -1);
+ _components.append(entry);
+ } else if (sectionCount == 3) {
+ const QString &version = sections[1];
+ const int dotIndex = version.indexOf(QLatin1Char('.'));
+
+ if (dotIndex == -1) {
+ reportError(lineNumber, -1, QLatin1String("expected '.'"));
+ } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) {
+ reportError(lineNumber, -1, QLatin1String("unexpected '.'"));
+ } else {
+ bool validVersionNumber = false;
+ const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber);
+
+ if (validVersionNumber) {
+ const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber);
+
+ if (validVersionNumber) {
+ const QString &fileName = sections[2];
+
+ if (fileName.endsWith(QLatin1String(".js"))) {
+ // A 'js' extension indicates a namespaced script import
+ const Script entry(sections[0], fileName, majorVersion, minorVersion);
+ _scripts.append(entry);
+ } else {
+ const Component entry(sections[0], fileName, majorVersion, minorVersion);
+ _components.append(entry);
+ }
+ }
+ }
+ }
+ } else {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount));
+ }
+ }
+
+ return hasError();
+}
+
+void QQmlDirParser::reportError(int line, int column, const QString &description)
+{
+ QQmlError error;
+ error.setUrl(_url);
+ error.setLine(line);
+ error.setColumn(column);
+ error.setDescription(description);
+ _errors.append(error);
+}
+
+bool QQmlDirParser::hasError() const
+{
+ if (! _errors.isEmpty())
+ return true;
+
+ return false;
+}
+
+QList<QQmlError> QQmlDirParser::errors(const QString &uri) const
+{
+ QList<QQmlError> errors = _errors;
+ for (int i = 0; i < errors.size(); ++i) {
+ QQmlError &e = errors[i];
+ QString description = e.description();
+ description.replace(QLatin1String("$$URI$$"), uri);
+ e.setDescription(description);
+ }
+ return errors;
+}
+
+QList<QQmlDirParser::Plugin> QQmlDirParser::plugins() const
+{
+ return _plugins;
+}
+
+QList<QQmlDirParser::Component> QQmlDirParser::components() const
+{
+ return _components;
+}
+
+QList<QQmlDirParser::Script> QQmlDirParser::scripts() const
+{
+ return _scripts;
+}
+
+#ifdef QT_CREATOR
+QList<QQmlDirParser::TypeInfo> QQmlDirParser::typeInfos() const
+{
+ return _typeInfos;
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qml/qqmldirparser_p.h
new file mode 100644
index 0000000000..8c681309ac
--- /dev/null
+++ b/src/qml/qml/qqmldirparser_p.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDIRPARSER_P_H
+#define QQMLDIRPARSER_P_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/QUrl>
+#include <QtCore/QHash>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlError;
+class QQmlDirParser
+{
+ Q_DISABLE_COPY(QQmlDirParser)
+
+public:
+ QQmlDirParser();
+ ~QQmlDirParser();
+
+ QUrl url() const;
+ void setUrl(const QUrl &url);
+
+ QString fileSource() const;
+ void setFileSource(const QString &filePath);
+
+ QString source() const;
+ void setSource(const QString &source);
+
+ bool isParsed() const;
+ bool parse();
+
+ bool hasError() const;
+ QList<QQmlError> errors(const QString &uri) const;
+
+ struct Plugin
+ {
+ Plugin() {}
+
+ Plugin(const QString &name, const QString &path)
+ : name(name), path(path) {}
+
+ QString name;
+ QString path;
+ };
+
+ struct Component
+ {
+ Component()
+ : majorVersion(0), minorVersion(0), internal(false) {}
+
+ Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
+ : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
+ internal(false) {}
+
+ QString typeName;
+ QString fileName;
+ int majorVersion;
+ int minorVersion;
+ bool internal;
+ };
+
+ struct Script
+ {
+ Script()
+ : majorVersion(0), minorVersion(0) {}
+
+ Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion)
+ : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
+
+ QString nameSpace;
+ QString fileName;
+ int majorVersion;
+ int minorVersion;
+ };
+
+ QList<Component> components() const;
+ QList<Script> scripts() const;
+ QList<Plugin> plugins() const;
+
+#ifdef QT_CREATOR
+ struct TypeInfo
+ {
+ TypeInfo() {}
+ TypeInfo(const QString &fileName)
+ : fileName(fileName) {}
+
+ QString fileName;
+ };
+
+ QList<TypeInfo> typeInfos() const;
+#endif
+
+private:
+ void reportError(int line, int column, const QString &message);
+
+private:
+ QList<QQmlError> _errors;
+ QUrl _url;
+ QString _source;
+ QString _filePathSouce;
+ QList<Component> _components;
+ QList<Script> _scripts;
+ QList<Plugin> _plugins;
+#ifdef QT_CREATOR
+ QList<TypeInfo> _typeInfos;
+#endif
+ unsigned _isParsed: 1;
+};
+
+typedef QList<QQmlDirParser::Component> QQmlDirComponents;
+typedef QList<QQmlDirParser::Script> QQmlDirScripts;
+
+
+QT_END_NAMESPACE
+
+#endif // QQMLDIRPARSER_P_H
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
new file mode 100644
index 0000000000..ee5a0c954e
--- /dev/null
+++ b/src/qml/qml/qqmlengine.cpp
@@ -0,0 +1,1854 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlengine_p.h"
+#include "qqmlengine.h"
+#include "qqmlcomponentattached_p.h"
+
+#include "qqmlcontext_p.h"
+#include "qqmlcompiler_p.h"
+#include "qqml.h"
+#include "qqmlcontext.h"
+#include "qqmlexpression.h"
+#include "qqmlcomponent.h"
+#include "qqmlbinding_p_p.h"
+#include "qqmlvme_p.h"
+#include <private/qqmlenginedebugservice_p.h>
+#include "qqmlstringconverters_p.h"
+#include "qqmlxmlhttprequest_p.h"
+#include "qqmlscriptstring.h"
+#include "qqmlglobal_p.h"
+#include "qquicklistmodel_p.h"
+#include "qquickworkerscript_p.h"
+#include "qqmlcomponent_p.h"
+#include "qqmlnetworkaccessmanagerfactory.h"
+#include "qqmlimageprovider.h"
+#include "qqmldirparser_p.h"
+#include "qqmlextensioninterface.h"
+#include "qqmllist_p.h"
+#include "qqmltypenamecache_p.h"
+#include "qqmlnotifier_p.h"
+#include <private/qqmlprofilerservice_p.h>
+#include <private/qquickapplication_p.h>
+#include <private/qv8debugservice_p.h>
+#include <private/qdebugmessageservice_p.h>
+#include "qqmlincubator.h"
+#include <private/qv8profilerservice_p.h>
+
+#include <QtCore/qstandardpaths.h>
+#include <QtCore/qsettings.h>
+
+#include <QtCore/qmetaobject.h>
+#include <QNetworkAccessManager>
+#include <QDebug>
+#include <QMetaObject>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qmutex.h>
+#include <QtNetwork/qnetworkconfigmanager.h>
+
+#include <private/qobject_p.h>
+
+#include <private/qqmllocale_p.h>
+
+#ifdef Q_OS_WIN // for %APPDATA%
+#include <qt_windows.h>
+#include <qlibrary.h>
+#include <windows.h>
+
+#define CSIDL_APPDATA 0x001a // <username>\Application Data
+#endif
+
+Q_DECLARE_METATYPE(QQmlProperty)
+
+QT_BEGIN_NAMESPACE
+
+void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor)
+{
+ QQmlEnginePrivate::registerBaseTypes(uri, versionMajor, versionMinor);
+ QQmlValueTypeFactory::registerBaseTypes(uri, versionMajor, versionMinor);
+}
+
+/*!
+ \qmlclass QtObject QObject
+ \ingroup qml-utility-elements
+ \since 4.7
+ \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 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/qml/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 QtObject::objectName
+ 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 QtQuick 2.0
+
+ Item {
+ width: 200; height: 200
+
+ Rectangle {
+ anchors.fill: parent
+ color: "red"
+ objectName: "myRect"
+ }
+ }
+ \endqml
+
+ \code
+ // main.cpp
+
+ QQuickView view;
+ view.setSource(QUrl::fromLocalFile("MyRect.qml"));
+ view.show();
+
+ QQuickItem *item = view.rootObject()->findChild<QQuickItem*>("myRect");
+ if (item)
+ item->setProperty("color", QColor(Qt::yellow));
+ \endcode
+*/
+
+bool QQmlEnginePrivate::qml_debugging_enabled = false;
+
+void QQmlEnginePrivate::registerBaseTypes(const char *uri, int versionMajor, int versionMinor)
+{
+ qmlRegisterType<QQmlComponent>(uri,versionMajor,versionMinor,"Component");
+ qmlRegisterType<QObject>(uri,versionMajor,versionMinor,"QtObject");
+ qmlRegisterType<QQuickListElement>(uri, versionMajor, versionMinor,"ListElement");
+ qmlRegisterCustomType<QQuickListModel>(uri, versionMajor, versionMinor,"ListModel", new QQuickListModelParser);
+ qmlRegisterType<QQuickWorkerScript>(uri,versionMajor,versionMinor,"WorkerScript");
+}
+
+void QQmlEnginePrivate::defineModule()
+{
+ registerBaseTypes("QtQuick", 2, 0);
+ qmlRegisterType<QQmlBinding>();
+ qmlRegisterUncreatableType<QQuickApplication>("QtQuick",2,0,"Application", QQuickApplication::tr("Application is an abstract class"));
+ qmlRegisterUncreatableType<QQmlLocale>("QtQuick",2,0,"Locale",QQmlEngine::tr("Locale cannot be instantiated. Use Qt.locale()"));
+}
+
+/*!
+\qmlclass Qt QQmlEnginePrivate
+ \ingroup qml-utility-elements
+\brief The QML global Qt object provides useful enums and functions from Qt.
+
+\keyword QmlGlobalQtObject
+
+\brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files.
+
+The \c Qt object is a global object with utility functions, properties and enums.
+
+It is not instantiable; to use it, call the members of the global \c Qt object directly.
+For example:
+
+\qml
+import QtQuick 2.0
+
+Text {
+ color: Qt.rgba(1, 0, 0, 1)
+ text: Qt.md5("hello, world")
+}
+\endqml
+
+
+\section1 Enums
+
+The Qt object contains the enums available in the \l {Qt Namespace}. For example, you can access
+the \l Qt::LeftButton and \l Qt::RightButton enum values as \c Qt.LeftButton and \c Qt.RightButton.
+
+
+\section1 Types
+The Qt object also contains helper functions for creating objects of specific
+data types. This is primarily useful when setting the properties of an item
+when the property has one of the following types:
+
+\list
+\o \c color - use \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::hsla()}{Qt.hsla()}, \l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()}
+\o \c rect - use \l{Qt::rect()}{Qt.rect()}
+\o \c point - use \l{Qt::point()}{Qt.point()}
+\o \c size - use \l{Qt::size()}{Qt.size()}
+\o \c vector3d - use \l{Qt::vector3d()}{Qt.vector3d()}
+\endlist
+
+There are also string based constructors for these types. See \l{qdeclarativebasictypes.html}{QML Basic Types} for more information.
+
+\section1 Date/Time Formatters
+
+The Qt object contains several functions for formatting QDateTime, QDate and QTime values.
+
+\list
+ \o \l{Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)}
+ \o \l{Qt::formatDate}{string Qt.formatDate(datetime date, variant format)}
+ \o \l{Qt::formatTime}{string Qt.formatTime(datetime date, variant format)}
+\endlist
+
+The format specification is described at \l{Qt::formatDateTime}{Qt.formatDateTime}.
+
+
+\section1 Dynamic Object Creation
+The following functions on the global object allow you to dynamically create QML
+items from files or strings. See \l{Dynamic Object Management in QML} for an overview
+of their use.
+
+\list
+ \o \l{Qt::createComponent()}{object Qt.createComponent(url)}
+ \o \l{Qt::createQmlObject()}{object Qt.createQmlObject(string qml, object parent, string filepath)}
+\endlist
+*/
+
+
+/*!
+ \qmlproperty object Qt::application
+ \since QtQuick 1.1
+
+ The \c application object provides access to global application state
+ properties shared by many QML components.
+
+ Its properties are:
+
+ \table
+ \row
+ \o \c application.active
+ \o
+ This read-only property indicates whether the application is the top-most and focused
+ application, and the user is able to interact with the application. The property
+ is false when the application is in the background, the device keylock or screen
+ saver is active, the screen backlight is turned off, or the global system dialog
+ is being displayed on top of the application. It can be used for stopping and
+ pausing animations, timers and active processing of data in order to save device
+ battery power and free device memory and processor load when the application is not
+ active.
+
+ \row
+ \o \c application.layoutDirection
+ \o
+ This read-only property can be used to query the default layout direction of the
+ application. On system start-up, the default layout direction depends on the
+ application's language. The property has a value of \c Qt.RightToLeft in locales
+ where text and graphic elements are read from right to left, and \c Qt.LeftToRight
+ where the reading direction flows from left to right. You can bind to this
+ property to customize your application layouts to support both layout directions.
+
+ Possible values are:
+
+ \list
+ \o Qt.LeftToRight - Text and graphics elements should be positioned
+ from left to right.
+ \o Qt.RightToLeft - Text and graphics elements should be positioned
+ from right to left.
+ \endlist
+
+ \row
+ \o \c application.inputPanel
+ \o
+ This read-only property allows access to application's QInputPanel object
+ and all its properties and slots. See the QInputPanel documentation for
+ further details. Deprecated in favor of Qt.InputMethod
+ \endtable
+
+ The following example uses the \c application object to indicate
+ whether the application is currently active:
+
+ \snippet doc/src/snippets/qml/application.qml document
+
+ \qmlproperty object Qt::inputMethod
+ \since QtQuick 2.0
+
+ The \c inputMethod object allows access to application's QInputMethod object
+ and all its properties and slots. See the QInputMethod documentation for
+ further details.
+*/
+
+
+/*!
+\qmlmethod object Qt::include(string url, jsobject callback)
+
+Includes another JavaScript file. This method can only be used from within JavaScript files,
+and not regular QML files.
+
+This imports all functions from \a url into the current script's namespace.
+
+Qt.include() returns an object that describes the status of the operation. The object has
+a single property, \c {status}, that is set to one of the following values:
+
+\table
+\header \o Symbol \o Value \o Description
+\row \o result.OK \o 0 \o The include completed successfully.
+\row \o result.LOADING \o 1 \o Data is being loaded from the network.
+\row \o result.NETWORK_ERROR \o 2 \o A network error occurred while fetching the url.
+\row \o result.EXCEPTION \o 3 \o A JavaScript exception occurred while executing the included code.
+An additional \c exception property will be set in this case.
+\endtable
+
+The \c status property will be updated as the operation progresses.
+
+If provided, \a callback is invoked when the operation completes. The callback is passed
+the same object as is returned from the Qt.include() call.
+*/
+// Qt.include() is implemented in qv8include.cpp
+
+
+QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
+: propertyCapture(0), rootContext(0), isDebugging(false),
+ outputWarningsToStdErr(true), sharedContext(0), sharedScope(0),
+ cleanup(0), erroredBindings(0), inProgressCreations(0),
+ workerScriptEngine(0), activeVME(0),
+ networkAccessManager(0), networkAccessManagerFactory(0),
+ scarceResourcesRefCount(0), typeLoader(e), importDatabase(e), uniqueId(1),
+ incubatorCount(0), incubationController(0), mutex(QMutex::Recursive)
+{
+}
+
+QQmlEnginePrivate::~QQmlEnginePrivate()
+{
+ if (inProgressCreations)
+ qWarning() << QQmlEngine::tr("There are still \"%1\" items in the process of being created at engine destruction.").arg(inProgressCreations);
+
+ while (cleanup) {
+ QQmlCleanup *c = cleanup;
+ cleanup = c->next;
+ if (cleanup) cleanup->prev = &cleanup;
+ c->next = 0;
+ c->prev = 0;
+ c->clear();
+ }
+
+ doDeleteInEngineThread();
+
+ if (incubationController) incubationController->d = 0;
+ incubationController = 0;
+
+ delete rootContext;
+ rootContext = 0;
+
+ for(QHash<int, QQmlCompiledData*>::ConstIterator iter = m_compositeTypes.constBegin(); iter != m_compositeTypes.constEnd(); ++iter)
+ (*iter)->release();
+ for(QHash<const QMetaObject *, QQmlPropertyCache *>::Iterator iter = propertyCache.begin(); iter != propertyCache.end(); ++iter)
+ (*iter)->release();
+ for(QHash<QPair<QQmlType *, int>, QQmlPropertyCache *>::Iterator iter = typePropertyCache.begin(); iter != typePropertyCache.end(); ++iter)
+ (*iter)->release();
+ for(QHash<QQmlMetaType::ModuleApi, QQmlMetaType::ModuleApiInstance *>::Iterator iter = moduleApiInstances.begin(); iter != moduleApiInstances.end(); ++iter) {
+ delete (*iter)->qobjectApi;
+ delete *iter;
+ }
+}
+
+void QQmlPrivate::qdeclarativeelement_destructor(QObject *o)
+{
+ QObjectPrivate *p = QObjectPrivate::get(o);
+ if (p->declarativeData) {
+ QQmlData *d = static_cast<QQmlData*>(p->declarativeData);
+ if (d->ownContext && d->context) {
+ d->context->destroy();
+ d->context = 0;
+ }
+ }
+}
+
+void QQmlData::destroyed(QAbstractDeclarativeData *d, QObject *o)
+{
+ static_cast<QQmlData *>(d)->destroyed(o);
+}
+
+void QQmlData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p)
+{
+ static_cast<QQmlData *>(d)->parentChanged(o, p);
+}
+
+void QQmlData::objectNameChanged(QAbstractDeclarativeData *d, QObject *o)
+{
+ static_cast<QQmlData *>(d)->objectNameChanged(o);
+}
+
+void QQmlData::signalEmitted(QAbstractDeclarativeData *, QObject *object, int index, void **)
+{
+ QQmlData *ddata = QQmlData::get(object, false);
+ if (!ddata) return; // Probably being deleted
+
+ QQmlNotifierEndpoint *ep = ddata->notify(index);
+ if (ep) QQmlNotifier::emitNotify(ep);
+}
+
+void QQmlEnginePrivate::init()
+{
+ Q_Q(QQmlEngine);
+
+ static bool firstTime = true;
+ if (firstTime) {
+ qmlRegisterType<QQmlComponent>("QML", 1, 0, "Component");
+
+ firstTime = false;
+ }
+
+ qRegisterMetaType<QVariant>("QVariant");
+ qRegisterMetaType<QQmlScriptString>("QQmlScriptString");
+ qRegisterMetaType<QJSValue>("QJSValue");
+ qRegisterMetaType<QQmlComponent::Status>("QQmlComponent::Status");
+ qRegisterMetaType<QList<QObject*> >("QList<QObject*>");
+ qRegisterMetaType<QList<int> >("QList<int>");
+ qRegisterMetaType<QQmlV8Handle>("QQmlV8Handle");
+
+ QQmlData::init();
+
+ v8engine()->setEngine(q);
+
+ rootContext = new QQmlContext(q,true);
+
+ if (QCoreApplication::instance()->thread() == q->thread() &&
+ QQmlEngineDebugService::isDebuggingEnabled()) {
+ isDebugging = true;
+ QQmlEngineDebugService::instance()->addEngine(q);
+ QV8DebugService::initialize(v8engine());
+ QV8ProfilerService::initialize();
+ QQmlProfilerService::initialize();
+ QDebugMessageService::instance();
+ }
+
+ QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+ offlineStoragePath = dataLocation.replace(QLatin1Char('/'), QDir::separator()) +
+ QDir::separator() + QLatin1String("QML") +
+ QDir::separator() + QLatin1String("OfflineStorage");
+}
+
+QQuickWorkerScriptEngine *QQmlEnginePrivate::getWorkerScriptEngine()
+{
+ Q_Q(QQmlEngine);
+ if (!workerScriptEngine)
+ workerScriptEngine = new QQuickWorkerScriptEngine(q);
+ return workerScriptEngine;
+}
+
+/*!
+ \class QQmlEngine
+ \since 4.7
+ \brief The QQmlEngine class provides an environment for instantiating QML components.
+ \mainclass
+
+ Each QML component is instantiated in a QQmlContext.
+ QQmlContext's are essential for passing data to QML
+ components. In QML, contexts are arranged hierarchically and this
+ hierarchy is managed by the QQmlEngine.
+
+ Prior to creating any QML components, an application must have
+ created a QQmlEngine to gain access to a QML context. The
+ following example shows how to create a simple Text item.
+
+ \code
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nText { text: \"Hello world!\" }", QUrl());
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+
+ //add item to view, etc
+ ...
+ \endcode
+
+ In this case, the Text item will be created in the engine's
+ \l {QQmlEngine::rootContext()}{root context}.
+
+ \sa QQmlComponent QQmlContext
+*/
+
+/*!
+ Create a new QQmlEngine with the given \a parent.
+*/
+QQmlEngine::QQmlEngine(QObject *parent)
+: QJSEngine(*new QQmlEnginePrivate(this), parent)
+{
+ Q_D(QQmlEngine);
+ d->init();
+}
+
+/*!
+ Destroys the QQmlEngine.
+
+ Any QQmlContext's created on this engine will be
+ invalidated, but not destroyed (unless they are parented to the
+ QQmlEngine object).
+*/
+QQmlEngine::~QQmlEngine()
+{
+ Q_D(QQmlEngine);
+ if (d->isDebugging) {
+ QQmlEngineDebugService::instance()->remEngine(this);
+ }
+
+ // if we are the parent of any of the qobject module api instances,
+ // we need to remove them from our internal list, in order to prevent
+ // a segfault in engine private dtor.
+ QList<QQmlMetaType::ModuleApi> keys = d->moduleApiInstances.keys();
+ QObject *currQObjectApi = 0;
+ QQmlMetaType::ModuleApiInstance *currInstance = 0;
+ foreach (const QQmlMetaType::ModuleApi &key, keys) {
+ currInstance = d->moduleApiInstances.value(key);
+ currQObjectApi = currInstance->qobjectApi;
+ if (this->children().contains(currQObjectApi)) {
+ delete currQObjectApi;
+ delete currInstance;
+ d->moduleApiInstances.remove(key);
+ }
+ }
+
+ // ensure we clean up QObjects with JS ownership
+ d->v8engine()->gc();
+
+ if (d->incubationController)
+ d->incubationController->d = 0;
+}
+
+/*! \fn void QQmlEngine::quit()
+ This signal is emitted when the QML loaded by the engine would like to quit.
+ */
+
+/*! \fn void QQmlEngine::warnings(const QList<QQmlError> &warnings)
+ This signal is emitted when \a warnings messages are generated by QML.
+ */
+
+/*!
+ Clears the engine's internal component cache.
+
+ Normally the QQmlEngine caches components loaded from qml
+ files. This method clears this cache and forces the component to be
+ reloaded.
+ */
+void QQmlEngine::clearComponentCache()
+{
+ Q_D(QQmlEngine);
+ d->typeLoader.clearCache();
+}
+
+/*!
+ Returns the engine's root context.
+
+ The root context is automatically created by the QQmlEngine.
+ Data that should be available to all QML component instances
+ instantiated by the engine should be put in the root context.
+
+ Additional data that should only be available to a subset of
+ component instances should be added to sub-contexts parented to the
+ root context.
+*/
+QQmlContext *QQmlEngine::rootContext() const
+{
+ Q_D(const QQmlEngine);
+ return d->rootContext;
+}
+
+/*!
+ Sets the \a factory to use for creating QNetworkAccessManager(s).
+
+ QNetworkAccessManager is used for all network access by QML. By
+ implementing a factory it is possible to create custom
+ QNetworkAccessManager with specialized caching, proxy and cookie
+ support.
+
+ The factory must be set before executing the engine.
+*/
+void QQmlEngine::setNetworkAccessManagerFactory(QQmlNetworkAccessManagerFactory *factory)
+{
+ Q_D(QQmlEngine);
+ QMutexLocker locker(&d->mutex);
+ d->networkAccessManagerFactory = factory;
+}
+
+/*!
+ Returns the current QQmlNetworkAccessManagerFactory.
+
+ \sa setNetworkAccessManagerFactory()
+*/
+QQmlNetworkAccessManagerFactory *QQmlEngine::networkAccessManagerFactory() const
+{
+ Q_D(const QQmlEngine);
+ return d->networkAccessManagerFactory;
+}
+
+void QQmlEnginePrivate::registerFinalizeCallback(QObject *obj, int index)
+{
+ if (activeVME) {
+ activeVME->finalizeCallbacks.append(qMakePair(QQmlGuard<QObject>(obj), index));
+ } else {
+ void *args[] = { 0 };
+ QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, args);
+ }
+}
+
+QNetworkAccessManager *QQmlEnginePrivate::createNetworkAccessManager(QObject *parent) const
+{
+ QMutexLocker locker(&mutex);
+ QNetworkAccessManager *nam;
+ if (networkAccessManagerFactory) {
+ nam = networkAccessManagerFactory->create(parent);
+ } else {
+ nam = new QNetworkAccessManager(parent);
+ }
+
+ return nam;
+}
+
+QNetworkAccessManager *QQmlEnginePrivate::getNetworkAccessManager() const
+{
+ Q_Q(const QQmlEngine);
+ if (!networkAccessManager)
+ networkAccessManager = createNetworkAccessManager(const_cast<QQmlEngine*>(q));
+ return networkAccessManager;
+}
+
+/*!
+ Returns a common QNetworkAccessManager which can be used by any QML
+ element instantiated by this engine.
+
+ If a QQmlNetworkAccessManagerFactory has been set and a
+ QNetworkAccessManager has not yet been created, the
+ QQmlNetworkAccessManagerFactory will be used to create the
+ QNetworkAccessManager; otherwise the returned QNetworkAccessManager
+ will have no proxy or cache set.
+
+ \sa setNetworkAccessManagerFactory()
+*/
+QNetworkAccessManager *QQmlEngine::networkAccessManager() const
+{
+ Q_D(const QQmlEngine);
+ return d->getNetworkAccessManager();
+}
+
+/*!
+
+ Sets the \a provider to use for images requested via the \e
+ image: url scheme, with host \a providerId. The QQmlEngine
+ takes ownership of \a provider.
+
+ Image providers enable support for pixmap and threaded image
+ requests. See the QQmlImageProvider documentation for details on
+ implementing and using image providers.
+
+ All required image providers should be added to the engine before any
+ QML sources files are loaded.
+
+ \sa removeImageProvider()
+*/
+void QQmlEngine::addImageProvider(const QString &providerId, QQmlImageProvider *provider)
+{
+ Q_D(QQmlEngine);
+ QMutexLocker locker(&d->mutex);
+ d->imageProviders.insert(providerId.toLower(), QSharedPointer<QQmlImageProvider>(provider));
+}
+
+/*!
+ Returns the QQmlImageProvider set for \a providerId.
+
+ Returns the provider if it was found; otherwise returns 0.
+*/
+QQmlImageProvider *QQmlEngine::imageProvider(const QString &providerId) const
+{
+ Q_D(const QQmlEngine);
+ QMutexLocker locker(&d->mutex);
+ return d->imageProviders.value(providerId).data();
+}
+
+/*!
+ Removes the QQmlImageProvider for \a providerId.
+
+ \sa addImageProvider()
+*/
+void QQmlEngine::removeImageProvider(const QString &providerId)
+{
+ Q_D(QQmlEngine);
+ QMutexLocker locker(&d->mutex);
+ d->imageProviders.take(providerId);
+}
+
+QQmlImageProvider::ImageType QQmlEnginePrivate::getImageProviderType(const QUrl &url)
+{
+ QMutexLocker locker(&mutex);
+ QSharedPointer<QQmlImageProvider> provider = imageProviders.value(url.host());
+ locker.unlock();
+ if (provider)
+ return provider->imageType();
+ return QQmlImageProvider::Invalid;
+}
+
+QQuickTextureFactory *QQmlEnginePrivate::getTextureFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
+{
+ QMutexLocker locker(&mutex);
+ QSharedPointer<QQmlImageProvider> provider = imageProviders.value(url.host());
+ locker.unlock();
+ if (provider) {
+ QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1);
+ return provider->requestTexture(imageId, size, req_size);
+ }
+ return 0;
+}
+
+QImage QQmlEnginePrivate::getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
+{
+ QMutexLocker locker(&mutex);
+ QImage image;
+ QSharedPointer<QQmlImageProvider> provider = imageProviders.value(url.host());
+ locker.unlock();
+ if (provider) {
+ QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1);
+ image = provider->requestImage(imageId, size, req_size);
+ }
+ return image;
+}
+
+QPixmap QQmlEnginePrivate::getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
+{
+ QMutexLocker locker(&mutex);
+ QPixmap pixmap;
+ QSharedPointer<QQmlImageProvider> provider = imageProviders.value(url.host());
+ locker.unlock();
+ if (provider) {
+ QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1);
+ pixmap = provider->requestPixmap(imageId, size, req_size);
+ }
+ return pixmap;
+}
+
+/*!
+ Return the base URL for this engine. The base URL is only used to
+ resolve components when a relative URL is passed to the
+ QQmlComponent constructor.
+
+ If a base URL has not been explicitly set, this method returns the
+ application's current working directory.
+
+ \sa setBaseUrl()
+*/
+QUrl QQmlEngine::baseUrl() const
+{
+ Q_D(const QQmlEngine);
+ if (d->baseUrl.isEmpty()) {
+ return QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
+ } else {
+ return d->baseUrl;
+ }
+}
+
+/*!
+ Set the base URL for this engine to \a url.
+
+ \sa baseUrl()
+*/
+void QQmlEngine::setBaseUrl(const QUrl &url)
+{
+ Q_D(QQmlEngine);
+ d->baseUrl = url;
+}
+
+/*!
+ Returns true if warning messages will be output to stderr in addition
+ to being emitted by the warnings() signal, otherwise false.
+
+ The default value is true.
+*/
+bool QQmlEngine::outputWarningsToStandardError() const
+{
+ Q_D(const QQmlEngine);
+ return d->outputWarningsToStdErr;
+}
+
+/*!
+ Set whether warning messages will be output to stderr to \a enabled.
+
+ If \a enabled is true, any warning messages generated by QML will be
+ output to stderr and emitted by the warnings() signal. If \a enabled
+ is false, on the warnings() signal will be emitted. This allows
+ applications to handle warning output themselves.
+
+ The default value is true.
+*/
+void QQmlEngine::setOutputWarningsToStandardError(bool enabled)
+{
+ Q_D(QQmlEngine);
+ d->outputWarningsToStdErr = enabled;
+}
+
+/*!
+ Attempt to free unused memory.
+*/
+void QQmlEngine::collectGarbage()
+{
+ QV8Engine::gc();
+}
+
+/*!
+ Returns the QQmlContext for the \a object, or 0 if no
+ context has been set.
+
+ When the QQmlEngine instantiates a QObject, the context is
+ set automatically.
+ */
+QQmlContext *QQmlEngine::contextForObject(const QObject *object)
+{
+ if(!object)
+ return 0;
+
+ QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
+
+ QQmlData *data =
+ static_cast<QQmlData *>(priv->declarativeData);
+
+ if (!data)
+ return 0;
+ else if (data->outerContext)
+ return data->outerContext->asQQmlContext();
+ else
+ return 0;
+}
+
+/*!
+ Sets the QQmlContext for the \a object to \a context.
+ If the \a object already has a context, a warning is
+ output, but the context is not changed.
+
+ When the QQmlEngine instantiates a QObject, the context is
+ set automatically.
+ */
+void QQmlEngine::setContextForObject(QObject *object, QQmlContext *context)
+{
+ if (!object || !context)
+ return;
+
+ QQmlData *data = QQmlData::get(object, true);
+ if (data->context) {
+ qWarning("QQmlEngine::setContextForObject(): Object already has a QQmlContext");
+ return;
+ }
+
+ QQmlContextData *contextData = QQmlContextData::get(context);
+ contextData->addObject(object);
+}
+
+/*!
+ \enum QQmlEngine::ObjectOwnership
+
+ Ownership controls whether or not QML automatically destroys the
+ QObject when the object is garbage collected by the JavaScript
+ engine. The two ownership options are:
+
+ \value CppOwnership The object is owned by C++ code, and will
+ never be deleted by QML. The JavaScript destroy() method cannot be
+ used on objects with CppOwnership. This option is similar to
+ QScriptEngine::QtOwnership.
+
+ \value JavaScriptOwnership The object is owned by JavaScript.
+ When the object is returned to QML as the return value of a method
+ call or property access, QML will delete the object if there are no
+ remaining JavaScript references to it and it has no
+ QObject::parent(). This option is similar to
+ QScriptEngine::ScriptOwnership.
+
+ Generally an application doesn't need to set an object's ownership
+ explicitly. QML uses a heuristic to set the default object
+ ownership. By default, an object that is created by QML has
+ JavaScriptOwnership. The exception to this are the root objects
+ created by calling QQmlComponent::create() or
+ QQmlComponent::beginCreate() which have CppOwnership by
+ default. The ownership of these root-level objects is considered to
+ have been transferred to the C++ caller.
+
+ Objects not-created by QML have CppOwnership by default. The
+ exception to this is objects returned from a C++ method call. The
+ ownership of these objects is passed to JavaScript.
+
+ Calling setObjectOwnership() overrides the default ownership
+ heuristic used by QML.
+*/
+
+/*!
+ Sets the \a ownership of \a object.
+*/
+void QQmlEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership)
+{
+ if (!object)
+ return;
+
+ QQmlData *ddata = QQmlData::get(object, true);
+ if (!ddata)
+ return;
+
+ ddata->indestructible = (ownership == CppOwnership)?true:false;
+ ddata->explicitIndestructibleSet = true;
+}
+
+/*!
+ Returns the ownership of \a object.
+*/
+QQmlEngine::ObjectOwnership QQmlEngine::objectOwnership(QObject *object)
+{
+ if (!object)
+ return CppOwnership;
+
+ QQmlData *ddata = QQmlData::get(object, false);
+ if (!ddata)
+ return CppOwnership;
+ else
+ return ddata->indestructible?CppOwnership:JavaScriptOwnership;
+}
+
+bool QQmlEngine::event(QEvent *e)
+{
+ Q_D(QQmlEngine);
+ if (e->type() == QEvent::User)
+ d->doDeleteInEngineThread();
+
+ return QJSEngine::event(e);
+}
+
+void QQmlEnginePrivate::doDeleteInEngineThread()
+{
+ QFieldList<Deletable, &Deletable::next> list;
+ mutex.lock();
+ list.copyAndClear(toDeleteInEngineThread);
+ mutex.unlock();
+
+ while (Deletable *d = list.takeFirst())
+ delete d;
+}
+
+Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
+{
+ QQmlData *data = QQmlData::get(object);
+
+ if (data && data->deferredComponent) {
+ QQmlObjectCreatingProfiler prof;
+ if (prof.enabled) {
+ QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
+ prof.setTypeName(type ? type->qmlTypeName()
+ : QString::fromUtf8(object->metaObject()->className()));
+ if (data->outerContext)
+ prof.setLocation(data->outerContext->url, data->lineNumber, data->columnNumber);
+ }
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine);
+
+ QQmlComponentPrivate::ConstructionState state;
+ QQmlComponentPrivate::beginDeferred(ep, object, &state);
+
+ data->deferredComponent->release();
+ data->deferredComponent = 0;
+
+ QQmlComponentPrivate::complete(ep, &state);
+ }
+}
+
+QQmlContext *qmlContext(const QObject *obj)
+{
+ return QQmlEngine::contextForObject(obj);
+}
+
+QQmlEngine *qmlEngine(const QObject *obj)
+{
+ QQmlData *data = QQmlData::get(obj, false);
+ if (!data || !data->context)
+ return 0;
+ return data->context->engine;
+}
+
+QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create)
+{
+ QQmlData *data = QQmlData::get(object);
+ if (!data)
+ return 0; // Attached properties are only on objects created by QML
+
+ QObject *rv = data->hasExtendedData()?data->attachedProperties()->value(id):0;
+ if (rv || !create)
+ return rv;
+
+ QQmlAttachedPropertiesFunc pf = QQmlMetaType::attachedPropertiesFuncById(id);
+ if (!pf)
+ return 0;
+
+ rv = pf(const_cast<QObject *>(object));
+
+ if (rv)
+ data->attachedProperties()->insert(id, rv);
+
+ return rv;
+}
+
+QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
+ const QMetaObject *attachedMetaObject, bool create)
+{
+ if (*idCache == -1)
+ *idCache = QQmlMetaType::attachedPropertiesFuncId(attachedMetaObject);
+
+ if (*idCache == -1 || !object)
+ return 0;
+
+ return qmlAttachedPropertiesObjectById(*idCache, object, create);
+}
+
+QQmlDebuggingEnabler::QQmlDebuggingEnabler()
+{
+#ifndef QQML_NO_DEBUG_PROTOCOL
+ if (!QQmlEnginePrivate::qml_debugging_enabled) {
+ qWarning("Qml debugging is enabled. Only use this in a safe environment!");
+ }
+ QQmlEnginePrivate::qml_debugging_enabled = true;
+#endif
+}
+
+
+class QQmlDataExtended {
+public:
+ QQmlDataExtended();
+ ~QQmlDataExtended();
+
+ QHash<int, QObject *> attachedProperties;
+ QQmlNotifier objectNameNotifier;
+};
+
+QQmlDataExtended::QQmlDataExtended()
+{
+}
+
+QQmlDataExtended::~QQmlDataExtended()
+{
+}
+
+void QQmlData::NotifyList::layout(QQmlNotifierEndpoint *endpoint)
+{
+ if (endpoint->next)
+ layout(endpoint->next);
+
+ int index = endpoint->sourceSignal;
+ index = qMin(index, 0xFFFF - 1);
+
+ endpoint->next = notifies[index];
+ if (endpoint->next) endpoint->next->prev = &endpoint->next;
+ endpoint->prev = &notifies[index];
+ notifies[index] = endpoint;
+}
+
+void QQmlData::NotifyList::layout()
+{
+ Q_ASSERT(maximumTodoIndex >= notifiesSize);
+
+ if (todo) {
+ QQmlNotifierEndpoint **old = notifies;
+ const int reallocSize = (maximumTodoIndex + 1) * sizeof(QQmlNotifierEndpoint*);
+ notifies = (QQmlNotifierEndpoint**)realloc(notifies, reallocSize);
+ const int memsetSize = (maximumTodoIndex - notifiesSize + 1) *
+ sizeof(QQmlNotifierEndpoint*);
+ memset(notifies + notifiesSize, 0, memsetSize);
+
+ if (notifies != old) {
+ for (int ii = 0; ii < notifiesSize; ++ii)
+ if (notifies[ii])
+ notifies[ii]->prev = &notifies[ii];
+ }
+
+ notifiesSize = maximumTodoIndex + 1;
+
+ layout(todo);
+ }
+
+ maximumTodoIndex = 0;
+ todo = 0;
+}
+
+void QQmlData::addNotify(int index, QQmlNotifierEndpoint *endpoint)
+{
+ if (!notifyList) {
+ notifyList = (NotifyList *)malloc(sizeof(NotifyList));
+ notifyList->connectionMask = 0;
+ notifyList->maximumTodoIndex = 0;
+ notifyList->notifiesSize = 0;
+ notifyList->todo = 0;
+ notifyList->notifies = 0;
+ }
+
+ Q_ASSERT(!endpoint->isConnected());
+
+ index = qMin(index, 0xFFFF - 1);
+ notifyList->connectionMask |= (1ULL << quint64(index % 64));
+
+ if (index < notifyList->notifiesSize) {
+
+ endpoint->next = notifyList->notifies[index];
+ if (endpoint->next) endpoint->next->prev = &endpoint->next;
+ endpoint->prev = &notifyList->notifies[index];
+ notifyList->notifies[index] = endpoint;
+
+ } else {
+ notifyList->maximumTodoIndex = qMax(int(notifyList->maximumTodoIndex), index);
+
+ endpoint->next = notifyList->todo;
+ if (endpoint->next) endpoint->next->prev = &endpoint->next;
+ endpoint->prev = &notifyList->todo;
+ notifyList->todo = endpoint;
+ }
+}
+
+QQmlNotifier *QQmlData::objectNameNotifier() const
+{
+ if (!extendedData) extendedData = new QQmlDataExtended;
+ return &extendedData->objectNameNotifier;
+}
+
+QHash<int, QObject *> *QQmlData::attachedProperties() const
+{
+ if (!extendedData) extendedData = new QQmlDataExtended;
+ return &extendedData->attachedProperties;
+}
+
+void QQmlData::destroyed(QObject *object)
+{
+ if (deferredComponent)
+ deferredComponent->release();
+
+ if (nextContextObject)
+ nextContextObject->prevContextObject = prevContextObject;
+ if (prevContextObject)
+ *prevContextObject = nextContextObject;
+
+ QQmlAbstractBinding *binding = bindings;
+ while (binding) {
+ QQmlAbstractBinding *next = binding->m_nextBinding;
+ binding->m_prevBinding = 0;
+ binding->m_nextBinding = 0;
+ binding->destroy();
+ binding = next;
+ }
+
+ if (bindingBits)
+ free(bindingBits);
+
+ if (propertyCache)
+ propertyCache->release();
+
+ if (ownContext && context)
+ context->destroy();
+
+ while (guards) {
+ QQmlGuard<QObject> *guard = static_cast<QQmlGuard<QObject> *>(guards);
+ *guard = (QObject *)0;
+ guard->objectDestroyed(object);
+ }
+
+ if (notifyList) {
+ while (notifyList->todo)
+ notifyList->todo->disconnect();
+ for (int ii = 0; ii < notifyList->notifiesSize; ++ii) {
+ while (QQmlNotifierEndpoint *ep = notifyList->notifies[ii])
+ ep->disconnect();
+ }
+ free(notifyList->notifies);
+ free(notifyList);
+ }
+
+ if (extendedData)
+ delete extendedData;
+
+ v8object.Clear(); // The WeakReference handler will clean the actual handle
+
+ if (ownMemory)
+ delete this;
+}
+
+void QQmlData::parentChanged(QObject *object, QObject *parent)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(parent);
+}
+
+void QQmlData::objectNameChanged(QObject *)
+{
+ if (extendedData) objectNameNotifier()->notify();
+}
+
+bool QQmlData::hasBindingBit(int bit) const
+{
+ if (bindingBitsSize > bit)
+ return bindingBits[bit / 32] & (1 << (bit % 32));
+ else
+ return false;
+}
+
+void QQmlData::clearBindingBit(int bit)
+{
+ if (bindingBitsSize > bit)
+ bindingBits[bit / 32] &= ~(1 << (bit % 32));
+}
+
+void QQmlData::setBindingBit(QObject *obj, int bit)
+{
+ if (bindingBitsSize <= bit) {
+ int props = obj->metaObject()->propertyCount();
+ Q_ASSERT(bit < props);
+
+ int arraySize = (props + 31) / 32;
+ int oldArraySize = bindingBitsSize / 32;
+
+ bindingBits = (quint32 *)realloc(bindingBits,
+ arraySize * sizeof(quint32));
+
+ memset(bindingBits + oldArraySize,
+ 0x00,
+ sizeof(quint32) * (arraySize - oldArraySize));
+
+ bindingBitsSize = arraySize * 32;
+ }
+
+ bindingBits[bit / 32] |= (1 << (bit % 32));
+}
+
+QString QQmlEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
+{
+ if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
+ if (url.authority().isEmpty())
+ return QLatin1Char(':') + url.path();
+ return QString();
+ }
+ return url.toLocalFile();
+}
+
+
+static QString toLocalFile(const QString &url)
+{
+ if (!url.startsWith(QLatin1String("file://"), Qt::CaseInsensitive))
+ return QString();
+
+ QString file = url.mid(7);
+
+ //XXX TODO: handle windows hostnames: "//servername/path/to/file.txt"
+
+ // magic for drives on windows
+ if (file.length() > 2 && file.at(0) == QLatin1Char('/') && file.at(2) == QLatin1Char(':'))
+ file.remove(0, 1);
+
+ return file;
+}
+
+QString QQmlEnginePrivate::urlToLocalFileOrQrc(const QString& url)
+{
+ if (url.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive)) {
+ if (url.length() > 4)
+ return QLatin1Char(':') + url.mid(4);
+ return QString();
+ }
+
+ return toLocalFile(url);
+}
+
+void QQmlEnginePrivate::sendQuit()
+{
+ Q_Q(QQmlEngine);
+ emit q->quit();
+ if (q->receivers(SIGNAL(quit())) == 0) {
+ qWarning("Signal QQmlEngine::quit() emitted, but no receivers connected to handle it.");
+ }
+}
+
+static void dumpwarning(const QQmlError &error)
+{
+ qWarning().nospace() << qPrintable(error.toString());
+}
+
+static void dumpwarning(const QList<QQmlError> &errors)
+{
+ for (int ii = 0; ii < errors.count(); ++ii)
+ dumpwarning(errors.at(ii));
+}
+
+void QQmlEnginePrivate::warning(const QQmlError &error)
+{
+ Q_Q(QQmlEngine);
+ q->warnings(QList<QQmlError>() << error);
+ if (outputWarningsToStdErr)
+ dumpwarning(error);
+}
+
+void QQmlEnginePrivate::warning(const QList<QQmlError> &errors)
+{
+ Q_Q(QQmlEngine);
+ q->warnings(errors);
+ if (outputWarningsToStdErr)
+ dumpwarning(errors);
+}
+
+void QQmlEnginePrivate::warning(QQmlEngine *engine, const QQmlError &error)
+{
+ if (engine)
+ QQmlEnginePrivate::get(engine)->warning(error);
+ else
+ dumpwarning(error);
+}
+
+void QQmlEnginePrivate::warning(QQmlEngine *engine, const QList<QQmlError> &error)
+{
+ if (engine)
+ QQmlEnginePrivate::get(engine)->warning(error);
+ else
+ dumpwarning(error);
+}
+
+void QQmlEnginePrivate::warning(QQmlEnginePrivate *engine, const QQmlError &error)
+{
+ if (engine)
+ engine->warning(error);
+ else
+ dumpwarning(error);
+}
+
+void QQmlEnginePrivate::warning(QQmlEnginePrivate *engine, const QList<QQmlError> &error)
+{
+ if (engine)
+ engine->warning(error);
+ else
+ dumpwarning(error);
+}
+
+/*
+ This function should be called prior to evaluation of any js expression,
+ so that scarce resources are not freed prematurely (eg, if there is a
+ nested javascript expression).
+ */
+void QQmlEnginePrivate::referenceScarceResources()
+{
+ scarceResourcesRefCount += 1;
+}
+
+/*
+ This function should be called after evaluation of the js expression is
+ complete, and so the scarce resources may be freed safely.
+ */
+void QQmlEnginePrivate::dereferenceScarceResources()
+{
+ Q_ASSERT(scarceResourcesRefCount > 0);
+ scarceResourcesRefCount -= 1;
+
+ // if the refcount is zero, then evaluation of the "top level"
+ // expression must have completed. We can safely release the
+ // scarce resources.
+ if (scarceResourcesRefCount == 0) {
+ // iterate through the list and release them all.
+ // note that the actual SRD is owned by the JS engine,
+ // so we cannot delete the SRD; but we can free the
+ // memory used by the variant in the SRD.
+ while (ScarceResourceData *sr = scarceResources.first()) {
+ sr->data = QVariant();
+ scarceResources.remove(sr);
+ }
+ }
+}
+
+/*!
+ Adds \a path as a directory where the engine searches for
+ installed modules in a URL-based directory structure.
+ The \a path may be a local filesystem directory or a URL.
+
+ The newly added \a path will be first in the importPathList().
+
+ \sa setImportPathList(), {QML Modules}
+*/
+void QQmlEngine::addImportPath(const QString& path)
+{
+ Q_D(QQmlEngine);
+ d->importDatabase.addImportPath(path);
+}
+
+/*!
+ Returns the list of directories where the engine searches for
+ installed modules in a URL-based directory structure.
+
+ For example, if \c /opt/MyApp/lib/imports is in the path, then QML that
+ imports \c com.mycompany.Feature will cause the QQmlEngine to look
+ in \c /opt/MyApp/lib/imports/com/mycompany/Feature/ for the components
+ provided by that module. A \c qmldir file is required for defining the
+ type version mapping and possibly QML extensions plugins.
+
+ By default, the list contains the directory of the application executable,
+ paths specified in the \c QML_IMPORT_PATH environment variable,
+ and the builtin \c ImportsPath from QLibraryInfo.
+
+ \sa addImportPath() setImportPathList()
+*/
+QStringList QQmlEngine::importPathList() const
+{
+ Q_D(const QQmlEngine);
+ return d->importDatabase.importPathList();
+}
+
+/*!
+ Sets \a paths as the list of directories where the engine searches for
+ installed modules in a URL-based directory structure.
+
+ By default, the list contains the directory of the application executable,
+ paths specified in the \c QML_IMPORT_PATH environment variable,
+ and the builtin \c ImportsPath from QLibraryInfo.
+
+ \sa importPathList() addImportPath()
+ */
+void QQmlEngine::setImportPathList(const QStringList &paths)
+{
+ Q_D(QQmlEngine);
+ d->importDatabase.setImportPathList(paths);
+}
+
+
+/*!
+ Adds \a path as a directory where the engine searches for
+ native plugins for imported modules (referenced in the \c qmldir file).
+
+ By default, the list contains only \c ., i.e. the engine searches
+ in the directory of the \c qmldir file itself.
+
+ The newly added \a path will be first in the pluginPathList().
+
+ \sa setPluginPathList()
+*/
+void QQmlEngine::addPluginPath(const QString& path)
+{
+ Q_D(QQmlEngine);
+ d->importDatabase.addPluginPath(path);
+}
+
+
+/*!
+ Returns the list of directories where the engine searches for
+ native plugins for imported modules (referenced in the \c qmldir file).
+
+ By default, the list contains only \c ., i.e. the engine searches
+ in the directory of the \c qmldir file itself.
+
+ \sa addPluginPath() setPluginPathList()
+*/
+QStringList QQmlEngine::pluginPathList() const
+{
+ Q_D(const QQmlEngine);
+ return d->importDatabase.pluginPathList();
+}
+
+/*!
+ Sets the list of directories where the engine searches for
+ native plugins for imported modules (referenced in the \c qmldir file)
+ to \a paths.
+
+ By default, the list contains only \c ., i.e. the engine searches
+ in the directory of the \c qmldir file itself.
+
+ \sa pluginPathList() addPluginPath()
+ */
+void QQmlEngine::setPluginPathList(const QStringList &paths)
+{
+ Q_D(QQmlEngine);
+ d->importDatabase.setPluginPathList(paths);
+}
+
+/*!
+ Imports the plugin named \a filePath with the \a uri provided.
+ Returns true if the plugin was successfully imported; otherwise returns false.
+
+ On failure and if non-null, the \a errors list will have any errors which occurred prepended to it.
+
+ The plugin has to be a Qt plugin which implements the QQmlExtensionPlugin interface.
+*/
+bool QQmlEngine::importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors)
+{
+ Q_D(QQmlEngine);
+ return d->importDatabase.importPlugin(filePath, uri, errors);
+}
+
+/*!
+ Imports the plugin named \a filePath with the \a uri provided.
+ Returns true if the plugin was successfully imported; otherwise returns false.
+
+ On failure and if non-null, *\a errorString will be set to a message describing the failure.
+
+ The plugin has to be a Qt plugin which implements the QQmlExtensionPlugin interface.
+*/
+bool QQmlEngine::importPlugin(const QString &filePath, const QString &uri, QString *errorString)
+{
+ Q_D(QQmlEngine);
+ QList<QQmlError> errors;
+ bool retn = d->importDatabase.importPlugin(filePath, uri, &errors);
+ if (!errors.isEmpty()) {
+ QString builtError;
+ for (int i = 0; i < errors.size(); ++i) {
+ builtError = QString(QLatin1String("%1\n %2"))
+ .arg(builtError)
+ .arg(errors.at(i).toString());
+ }
+ *errorString = builtError;
+ }
+ return retn;
+}
+
+/*!
+ \property QQmlEngine::offlineStoragePath
+ \brief the directory for storing offline user data
+
+ Returns the directory where SQL and other offline
+ storage is placed.
+
+ QQuickWebView and the SQL databases created with openDatabase()
+ are stored here.
+
+ The default is QML/OfflineStorage in the platform-standard
+ user application data directory.
+
+ Note that the path may not currently exist on the filesystem, so
+ callers wanting to \e create new files at this location should create
+ it first - see QDir::mkpath().
+*/
+void QQmlEngine::setOfflineStoragePath(const QString& dir)
+{
+ Q_D(QQmlEngine);
+ d->offlineStoragePath = dir;
+}
+
+QString QQmlEngine::offlineStoragePath() const
+{
+ Q_D(const QQmlEngine);
+ return d->offlineStoragePath;
+}
+
+static void voidptr_destructor(void *v)
+{
+ void **ptr = (void **)v;
+ delete ptr;
+}
+
+static void *voidptr_constructor(const void *v)
+{
+ if (!v) {
+ return new void*;
+ } else {
+ return new void*(*(void **)v);
+ }
+}
+
+QQmlPropertyCache *QQmlEnginePrivate::createCache(const QMetaObject *mo)
+{
+ Q_Q(QQmlEngine);
+
+ if (!mo->superClass()) {
+ QQmlPropertyCache *rv = new QQmlPropertyCache(q, mo);
+ propertyCache.insert(mo, rv);
+ return rv;
+ } else {
+ QQmlPropertyCache *super = cache(mo->superClass());
+ QQmlPropertyCache *rv = super->copyAndAppend(q, mo);
+ propertyCache.insert(mo, rv);
+ return rv;
+ }
+}
+
+QQmlPropertyCache *QQmlEnginePrivate::createCache(QQmlType *type, int minorVersion,
+ QQmlError &error)
+{
+ QList<QQmlType *> types;
+
+ int maxMinorVersion = 0;
+
+ const QMetaObject *metaObject = type->metaObject();
+
+ while (metaObject) {
+ QQmlType *t = QQmlMetaType::qmlType(metaObject, type->module(),
+ type->majorVersion(), minorVersion);
+ if (t) {
+ maxMinorVersion = qMax(maxMinorVersion, t->minorVersion());
+ types << t;
+ } else {
+ types << 0;
+ }
+
+ metaObject = metaObject->superClass();
+ }
+
+ if (QQmlPropertyCache *c = typePropertyCache.value(qMakePair(type, maxMinorVersion))) {
+ c->addref();
+ typePropertyCache.insert(qMakePair(type, minorVersion), c);
+ return c;
+ }
+
+ QQmlPropertyCache *raw = cache(type->metaObject());
+
+ bool hasCopied = false;
+
+ for (int ii = 0; ii < types.count(); ++ii) {
+ QQmlType *currentType = types.at(ii);
+ if (!currentType)
+ continue;
+
+ int rev = currentType->metaObjectRevision();
+ int moIndex = types.count() - 1 - ii;
+
+ if (raw->allowedRevisionCache[moIndex] != rev) {
+ if (!hasCopied) {
+ raw = raw->copy();
+ hasCopied = true;
+ }
+ raw->allowedRevisionCache[moIndex] = rev;
+ }
+ }
+
+ // Test revision compatibility - the basic rule is:
+ // * Anything that is excluded, cannot overload something that is not excluded *
+
+ // Signals override:
+ // * other signals and methods of the same name.
+ // * properties named on<Signal Name>
+ // * automatic <property name>Changed notify signals
+
+ // Methods override:
+ // * other methods of the same name
+
+ // Properties override:
+ // * other elements of the same name
+
+ bool overloadError = false;
+ QString overloadName;
+
+#if 0
+ for (QQmlPropertyCache::StringCache::ConstIterator iter = raw->stringCache.begin();
+ !overloadError && iter != raw->stringCache.end();
+ ++iter) {
+
+ QQmlPropertyData *d = *iter;
+ if (raw->isAllowedInRevision(d))
+ continue; // Not excluded - no problems
+
+ // check that a regular "name" overload isn't happening
+ QQmlPropertyData *current = d;
+ while (!overloadError && current) {
+ current = d->overrideData(current);
+ if (current && raw->isAllowedInRevision(current))
+ overloadError = true;
+ }
+ }
+#endif
+
+ if (overloadError) {
+ if (hasCopied) raw->release();
+
+ error.setDescription(QLatin1String("Type ") + type->qmlTypeName() + QLatin1String(" ") + QString::number(type->majorVersion()) + QLatin1String(".") + QString::number(minorVersion) + QLatin1String(" contains an illegal property \"") + overloadName + QLatin1String("\". This is an error in the type's implementation."));
+ return 0;
+ }
+
+ if (!hasCopied) raw->addref();
+ typePropertyCache.insert(qMakePair(type, minorVersion), raw);
+
+ if (minorVersion != maxMinorVersion) {
+ raw->addref();
+ typePropertyCache.insert(qMakePair(type, maxMinorVersion), raw);
+ }
+
+ return raw;
+}
+
+QQmlMetaType::ModuleApiInstance *
+QQmlEnginePrivate::moduleApiInstance(const QQmlMetaType::ModuleApi &module)
+{
+ Locker locker(this);
+
+ QQmlMetaType::ModuleApiInstance *a = moduleApiInstances.value(module);
+ if (!a) {
+ a = new QQmlMetaType::ModuleApiInstance;
+ a->scriptCallback = module.script;
+ a->qobjectCallback = module.qobject;
+ moduleApiInstances.insert(module, a);
+ }
+
+ return a;
+}
+
+bool QQmlEnginePrivate::isQObject(int t)
+{
+ Locker locker(this);
+ return m_compositeTypes.contains(t) || QQmlMetaType::isQObject(t);
+}
+
+QObject *QQmlEnginePrivate::toQObject(const QVariant &v, bool *ok) const
+{
+ Locker locker(this);
+ int t = v.userType();
+ if (t == QMetaType::QObjectStar || m_compositeTypes.contains(t)) {
+ if (ok) *ok = true;
+ return *(QObject **)(v.constData());
+ } else {
+ return QQmlMetaType::toQObject(v, ok);
+ }
+}
+
+QQmlMetaType::TypeCategory QQmlEnginePrivate::typeCategory(int t) const
+{
+ Locker locker(this);
+ if (m_compositeTypes.contains(t))
+ return QQmlMetaType::Object;
+ else if (m_qmlLists.contains(t))
+ return QQmlMetaType::List;
+ else
+ return QQmlMetaType::typeCategory(t);
+}
+
+bool QQmlEnginePrivate::isList(int t) const
+{
+ Locker locker(this);
+ return m_qmlLists.contains(t) || QQmlMetaType::isList(t);
+}
+
+int QQmlEnginePrivate::listType(int t) const
+{
+ Locker locker(this);
+ QHash<int, int>::ConstIterator iter = m_qmlLists.find(t);
+ if (iter != m_qmlLists.end())
+ return *iter;
+ else
+ return QQmlMetaType::listType(t);
+}
+
+const QMetaObject *QQmlEnginePrivate::rawMetaObjectForType(int t) const
+{
+ Locker locker(this);
+ QHash<int, QQmlCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
+ if (iter != m_compositeTypes.end()) {
+ return (*iter)->root;
+ } else {
+ QQmlType *type = QQmlMetaType::qmlType(t);
+ return type?type->baseMetaObject():0;
+ }
+}
+
+const QMetaObject *QQmlEnginePrivate::metaObjectForType(int t) const
+{
+ Locker locker(this);
+ QHash<int, QQmlCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
+ if (iter != m_compositeTypes.end()) {
+ return (*iter)->root;
+ } else {
+ QQmlType *type = QQmlMetaType::qmlType(t);
+ return type?type->metaObject():0;
+ }
+}
+
+void QQmlEnginePrivate::registerCompositeType(QQmlCompiledData *data)
+{
+ QByteArray name = data->root->className();
+
+ QByteArray ptr = name + '*';
+ QByteArray lst = "QQmlListProperty<" + name + '>';
+
+ int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor,
+ voidptr_constructor);
+ int lst_type = QMetaType::registerType(lst.constData(), voidptr_destructor,
+ voidptr_constructor);
+
+ data->addref();
+
+ Locker locker(this);
+ m_qmlLists.insert(lst_type, ptr_type);
+ m_compositeTypes.insert(ptr_type, data);
+}
+
+bool QQml_isFileCaseCorrect(const QString &fileName)
+{
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
+ QFileInfo info(fileName);
+ const QString absolute = info.absoluteFilePath();
+
+#if defined(Q_OS_MAC)
+ const QString canonical = info.canonicalFilePath();
+#elif defined(Q_OS_WIN)
+ wchar_t buffer[1024];
+
+ DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024);
+ if (rv == 0 || rv >= 1024) return true;
+ rv = ::GetLongPathName(buffer, buffer, 1024);
+ if (rv == 0 || rv >= 1024) return true;
+
+ const QString canonical = QString::fromWCharArray(buffer);
+#endif
+
+ const int absoluteLength = absolute.length();
+ const int canonicalLength = canonical.length();
+
+ const int length = qMin(absoluteLength, canonicalLength);
+ for (int ii = 0; ii < length; ++ii) {
+ const QChar &a = absolute.at(absoluteLength - 1 - ii);
+ const QChar &c = canonical.at(canonicalLength - 1 - ii);
+
+ if (a.toLower() != c.toLower())
+ return true;
+ if (a != c)
+ return false;
+ }
+#else
+ Q_UNUSED(fileName)
+#endif
+ return true;
+}
+
+/*!
+ \fn QQmlEngine *qmlEngine(const QObject *object)
+ \relates QQmlEngine
+
+ Returns the QQmlEngine associated with \a object, if any. This is equivalent to
+ QQmlEngine::contextForObject(object)->engine(), but more efficient.
+*/
+
+/*!
+ \fn QQmlContext *qmlContext(const QObject *object)
+ \relates QQmlEngine
+
+ Returns the QQmlContext associated with \a object, if any. This is equivalent to
+ QQmlEngine::contextForObject(object).
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h
new file mode 100644
index 0000000000..04ac61c05b
--- /dev/null
+++ b/src/qml/qml/qqmlengine.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLENGINE_H
+#define QQMLENGINE_H
+
+#include <QtCore/qurl.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qmap.h>
+#include <QtQml/qjsengine.h>
+#include <QtQml/qqmlerror.h>
+#include <QtQml/qqmldebug.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlComponent;
+class QQmlEnginePrivate;
+class QQmlImportsPrivate;
+class QQmlExpression;
+class QQmlContext;
+class QQmlType;
+class QUrl;
+class QScriptContext;
+class QQmlImageProvider;
+class QNetworkAccessManager;
+class QQmlNetworkAccessManagerFactory;
+class QQmlIncubationController;
+class Q_QML_EXPORT QQmlEngine : public QJSEngine
+{
+ Q_PROPERTY(QString offlineStoragePath READ offlineStoragePath WRITE setOfflineStoragePath)
+ Q_OBJECT
+public:
+ QQmlEngine(QObject *p = 0);
+ virtual ~QQmlEngine();
+
+ QQmlContext *rootContext() const;
+
+ void clearComponentCache();
+
+ QStringList importPathList() const;
+ void setImportPathList(const QStringList &paths);
+ void addImportPath(const QString& dir);
+
+ QStringList pluginPathList() const;
+ void setPluginPathList(const QStringList &paths);
+ void addPluginPath(const QString& dir);
+
+ bool importPlugin(const QString &filePath, const QString &uri, QString *errorString); // XXX: Qt 5: Remove this function
+ bool importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors);
+
+ void setNetworkAccessManagerFactory(QQmlNetworkAccessManagerFactory *);
+ QQmlNetworkAccessManagerFactory *networkAccessManagerFactory() const;
+
+ QNetworkAccessManager *networkAccessManager() const;
+
+ void addImageProvider(const QString &id, QQmlImageProvider *);
+ QQmlImageProvider *imageProvider(const QString &id) const;
+ void removeImageProvider(const QString &id);
+
+ void setIncubationController(QQmlIncubationController *);
+ QQmlIncubationController *incubationController() const;
+
+ void setOfflineStoragePath(const QString& dir);
+ QString offlineStoragePath() const;
+
+ QUrl baseUrl() const;
+ void setBaseUrl(const QUrl &);
+
+ bool outputWarningsToStandardError() const;
+ void setOutputWarningsToStandardError(bool);
+
+ void collectGarbage();
+
+ static QQmlContext *contextForObject(const QObject *);
+ static void setContextForObject(QObject *, QQmlContext *);
+
+ enum ObjectOwnership { CppOwnership, JavaScriptOwnership };
+ static void setObjectOwnership(QObject *, ObjectOwnership);
+ static ObjectOwnership objectOwnership(QObject *);
+
+protected:
+ virtual bool event(QEvent *);
+
+Q_SIGNALS:
+ void quit();
+ void warnings(const QList<QQmlError> &warnings);
+
+private:
+ Q_DISABLE_COPY(QQmlEngine)
+ Q_DECLARE_PRIVATE(QQmlEngine)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLENGINE_H
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
new file mode 100644
index 0000000000..db834489ba
--- /dev/null
+++ b/src/qml/qml/qqmlengine_p.h
@@ -0,0 +1,522 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLENGINE_P_H
+#define QQMLENGINE_P_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 "qqmlengine.h"
+
+#include "qqmltypeloader_p.h"
+#include "qqmlimport_p.h"
+#include <private/qpodvector_p.h>
+#include "qqml.h"
+#include "qqmlvaluetype_p.h"
+#include "qqmlcontext.h"
+#include "qqmlcontext_p.h"
+#include "qqmlexpression.h"
+#include "qqmlimageprovider.h"
+#include "qqmlproperty_p.h"
+#include "qqmlpropertycache_p.h"
+#include "qqmlmetatype_p.h"
+#include "qqmldirparser_p.h"
+#include <private/qintrusivelist_p.h>
+#include <private/qrecyclepool_p.h>
+
+#include <QtCore/qlist.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qthread.h>
+
+#include <private/qobject_p.h>
+
+#include <private/qv8engine_p.h>
+#include <private/qjsengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlContext;
+class QQmlEngine;
+class QQmlContextPrivate;
+class QQmlExpression;
+class QQmlImportDatabase;
+class QNetworkReply;
+class QNetworkAccessManager;
+class QQmlNetworkAccessManagerFactory;
+class QQmlAbstractBinding;
+class QQmlTypeNameCache;
+class QQmlComponentAttached;
+class QQmlCleanup;
+class QQmlDelayedError;
+class QQuickWorkerScriptEngine;
+class QQmlVME;
+class QDir;
+class QQmlIncubator;
+
+// This needs to be declared here so that the pool for it can live in QQmlEnginePrivate.
+// The inline method definitions are in qqmlexpression_p.h
+class QQmlJavaScriptExpressionGuard : public QQmlNotifierEndpoint
+{
+public:
+ inline QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *);
+
+ static inline void endpointCallback(QQmlNotifierEndpoint *);
+ static inline QQmlJavaScriptExpressionGuard *New(QQmlJavaScriptExpression *e,
+ QQmlEngine *engine);
+ inline void Delete();
+
+ QQmlJavaScriptExpression *expression;
+ QQmlJavaScriptExpressionGuard *next;
+};
+
+class Q_QML_EXPORT QQmlEnginePrivate : public QJSEnginePrivate
+{
+ Q_DECLARE_PUBLIC(QQmlEngine)
+public:
+ QQmlEnginePrivate(QQmlEngine *);
+ ~QQmlEnginePrivate();
+
+ void init();
+
+ class PropertyCapture {
+ public:
+ inline virtual ~PropertyCapture() {}
+ virtual void captureProperty(QQmlNotifier *) = 0;
+ virtual void captureProperty(QObject *, int, int) = 0;
+ };
+
+ PropertyCapture *propertyCapture;
+ inline void captureProperty(QQmlNotifier *);
+ inline void captureProperty(QObject *, int, int);
+
+ QRecyclePool<QQmlJavaScriptExpressionGuard> jsExpressionGuardPool;
+
+ QQmlContext *rootContext;
+ bool isDebugging;
+
+ bool outputWarningsToStdErr;
+
+ QQmlContextData *sharedContext;
+ QObject *sharedScope;
+
+ // Registered cleanup handlers
+ QQmlCleanup *cleanup;
+
+ // Bindings that have had errors during startup
+ QQmlDelayedError *erroredBindings;
+ int inProgressCreations;
+
+ QV8Engine *v8engine() const { return q_func()->handle(); }
+
+ QQuickWorkerScriptEngine *getWorkerScriptEngine();
+ QQuickWorkerScriptEngine *workerScriptEngine;
+
+ QUrl baseUrl;
+
+ typedef QPair<QQmlGuard<QObject>,int> FinalizeCallback;
+ void registerFinalizeCallback(QObject *obj, int index);
+
+ QQmlVME *activeVME;
+
+ QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
+ QNetworkAccessManager *getNetworkAccessManager() const;
+ mutable QNetworkAccessManager *networkAccessManager;
+ mutable QQmlNetworkAccessManagerFactory *networkAccessManagerFactory;
+
+ QHash<QString,QSharedPointer<QQmlImageProvider> > imageProviders;
+ QQmlImageProvider::ImageType getImageProviderType(const QUrl &url);
+ QQuickTextureFactory *getTextureFromProvider(const QUrl &url, QSize *size, const QSize& req_size);
+ QImage getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size);
+ QPixmap getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size);
+
+ // Scarce resources are "exceptionally high cost" QVariant types where allowing the
+ // normal JavaScript GC to clean them up is likely to lead to out-of-memory or other
+ // out-of-resource situations. When such a resource is passed into JavaScript we
+ // add it to the scarceResources list and it is destroyed when we return from the
+ // JavaScript execution that created it. The user can prevent this behavior by
+ // calling preserve() on the object which removes it from this scarceResource list.
+ class ScarceResourceData {
+ public:
+ ScarceResourceData(const QVariant &data) : data(data) {}
+ QVariant data;
+ QIntrusiveListNode node;
+ };
+ QIntrusiveList<ScarceResourceData, &ScarceResourceData::node> scarceResources;
+ int scarceResourcesRefCount;
+ void referenceScarceResources();
+ void dereferenceScarceResources();
+
+ QQmlTypeLoader typeLoader;
+ QQmlImportDatabase importDatabase;
+
+ QString offlineStoragePath;
+
+ mutable quint32 uniqueId;
+ inline quint32 getUniqueId() const {
+ return uniqueId++;
+ }
+
+ QQmlValueTypeFactory valueTypes;
+
+ // Unfortunate workaround to avoid a circular dependency between
+ // qqmlengine_p.h and qqmlincubator_p.h
+ struct Incubator {
+ QIntrusiveListNode next;
+ // Unfortunate workaround for MSVC
+ QIntrusiveListNode nextWaitingFor;
+ };
+ QIntrusiveList<Incubator, &Incubator::next> incubatorList;
+ unsigned int incubatorCount;
+ QQmlIncubationController *incubationController;
+ void incubate(QQmlIncubator &, QQmlContextData *);
+
+ // These methods may be called from any thread
+ inline bool isEngineThread() const;
+ inline static bool isEngineThread(const QQmlEngine *);
+ template<typename T>
+ inline void deleteInEngineThread(T *);
+ template<typename T>
+ inline static void deleteInEngineThread(QQmlEngine *, T *);
+
+ // These methods may be called from the loader thread
+ QQmlMetaType::ModuleApiInstance *moduleApiInstance(const QQmlMetaType::ModuleApi &module);
+
+ // These methods may be called from the loader thread
+ inline QQmlPropertyCache *cache(QObject *obj);
+ inline QQmlPropertyCache *cache(const QMetaObject *);
+ inline QQmlPropertyCache *cache(QQmlType *, int, QQmlError &error);
+
+ // These methods may be called from the loader thread
+ bool isQObject(int);
+ QObject *toQObject(const QVariant &, bool *ok = 0) const;
+ QQmlMetaType::TypeCategory typeCategory(int) const;
+ bool isList(int) const;
+ int listType(int) const;
+ const QMetaObject *rawMetaObjectForType(int) const;
+ const QMetaObject *metaObjectForType(int) const;
+ void registerCompositeType(QQmlCompiledData *);
+
+ void sendQuit();
+ void warning(const QQmlError &);
+ void warning(const QList<QQmlError> &);
+ static void warning(QQmlEngine *, const QQmlError &);
+ static void warning(QQmlEngine *, const QList<QQmlError> &);
+ static void warning(QQmlEnginePrivate *, const QQmlError &);
+ static void warning(QQmlEnginePrivate *, const QList<QQmlError> &);
+
+ inline static QV8Engine *getV8Engine(QQmlEngine *e);
+ inline static QQmlEnginePrivate *get(QQmlEngine *e);
+ inline static const QQmlEnginePrivate *get(const QQmlEngine *e);
+ inline static QQmlEnginePrivate *get(QQmlContext *c);
+ inline static QQmlEnginePrivate *get(QQmlContextData *c);
+ inline static QQmlEngine *get(QQmlEnginePrivate *p);
+
+ static QString urlToLocalFileOrQrc(const QUrl& url);
+ static QString urlToLocalFileOrQrc(const QString& url);
+
+ static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor);
+ static void defineModule();
+
+ static bool qml_debugging_enabled;
+
+ mutable QMutex mutex;
+
+private:
+ // Locker locks the QQmlEnginePrivate data structures for read and write, if necessary.
+ // Currently, locking is only necessary if the threaded loader is running concurrently. If it is
+ // either idle, or is running with the main thread blocked, no locking is necessary. This way
+ // we only pay for locking when we have to.
+ // Consequently, this class should only be used to protect simple accesses or modifications of the
+ // QQmlEnginePrivate structures or operations that can be guarenteed not to start activity
+ // on the loader thread.
+ // The Locker API is identical to QMutexLocker. Locker reuses the QQmlEnginePrivate::mutex
+ // QMutex instance and multiple Lockers are recursive in the same thread.
+ class Locker
+ {
+ public:
+ inline Locker(const QQmlEngine *);
+ inline Locker(const QQmlEnginePrivate *);
+ inline ~Locker();
+
+ inline void unlock();
+ inline void relock();
+
+ private:
+ const QQmlEnginePrivate *m_ep;
+ quint32 m_locked:1;
+ };
+
+ // Must be called locked
+ QQmlPropertyCache *createCache(const QMetaObject *);
+ QQmlPropertyCache *createCache(QQmlType *, int, QQmlError &error);
+
+ // These members must be protected by a QQmlEnginePrivate::Locker as they are required by
+ // the threaded loader. Only access them through their respective accessor methods.
+ QHash<QQmlMetaType::ModuleApi, QQmlMetaType::ModuleApiInstance *> moduleApiInstances;
+ QHash<const QMetaObject *, QQmlPropertyCache *> propertyCache;
+ QHash<QPair<QQmlType *, int>, QQmlPropertyCache *> typePropertyCache;
+ QHash<int, int> m_qmlLists;
+ QHash<int, QQmlCompiledData *> m_compositeTypes;
+
+ // These members is protected by the full QQmlEnginePrivate::mutex mutex
+ struct Deletable { Deletable():next(0) {} virtual ~Deletable() {} Deletable *next; };
+ QFieldList<Deletable, &Deletable::next> toDeleteInEngineThread;
+ void doDeleteInEngineThread();
+};
+
+QQmlEnginePrivate::Locker::Locker(const QQmlEngine *e)
+: m_ep(QQmlEnginePrivate::get(e))
+{
+ relock();
+}
+
+QQmlEnginePrivate::Locker::Locker(const QQmlEnginePrivate *e)
+: m_ep(e), m_locked(false)
+{
+ relock();
+}
+
+QQmlEnginePrivate::Locker::~Locker()
+{
+ unlock();
+}
+
+void QQmlEnginePrivate::Locker::unlock()
+{
+ if (m_locked) {
+ m_ep->mutex.unlock();
+ m_locked = false;
+ }
+}
+
+void QQmlEnginePrivate::Locker::relock()
+{
+ Q_ASSERT(!m_locked);
+ if (m_ep->typeLoader.isConcurrent()) {
+ m_ep->mutex.lock();
+ m_locked = true;
+ }
+}
+
+/*!
+Returns true if the calling thread is the QQmlEngine thread.
+*/
+bool QQmlEnginePrivate::isEngineThread() const
+{
+ Q_Q(const QQmlEngine);
+ return QThread::currentThread() == q->thread();
+}
+
+/*!
+Returns true if the calling thread is the QQmlEngine \a engine thread.
+*/
+bool QQmlEnginePrivate::isEngineThread(const QQmlEngine *engine)
+{
+ Q_ASSERT(engine);
+ return QQmlEnginePrivate::get(engine)->isEngineThread();
+}
+
+/*!
+Delete \a value in the engine thread. If the calling thread is the engine
+thread, \a value will be deleted immediately.
+
+This method should be used for *any* type that has resources that need to
+be freed in the engine thread. This is generally types that use V8 handles.
+As there is some small overhead in checking the current thread, it is best
+practice to check if any V8 handles actually need to be freed and delete
+the instance directly if not.
+*/
+template<typename T>
+void QQmlEnginePrivate::deleteInEngineThread(T *value)
+{
+ Q_Q(QQmlEngine);
+
+ Q_ASSERT(value);
+ if (isEngineThread()) {
+ delete value;
+ } else {
+ struct I : public Deletable {
+ I(T *value) : value(value) {}
+ ~I() { delete value; }
+ T *value;
+ };
+ I *i = new I(value);
+ mutex.lock();
+ bool wasEmpty = toDeleteInEngineThread.isEmpty();
+ toDeleteInEngineThread.append(i);
+ mutex.unlock();
+ if (wasEmpty)
+ QCoreApplication::postEvent(q, new QEvent(QEvent::User));
+ }
+}
+
+/*!
+Delete \a value in the \a engine thread. If the calling thread is the engine
+thread, \a value will be deleted immediately.
+*/
+template<typename T>
+void QQmlEnginePrivate::deleteInEngineThread(QQmlEngine *engine, T *value)
+{
+ Q_ASSERT(engine);
+ QQmlEnginePrivate::get(engine)->deleteInEngineThread<T>(value);
+}
+
+/*!
+Returns a QQmlPropertyCache for \a obj if one is available.
+
+If \a obj is null, being deleted or contains a dynamic meta object 0
+is returned.
+
+The returned cache is not referenced, so if it is to be stored, call addref().
+
+XXX thread There is a potential future race condition in this and all the cache()
+functions. As the QQmlPropertyCache is returned unreferenced, when called
+from the loader thread, it is possible that the cache will have been dereferenced
+and deleted before the loader thread has a chance to use or reference it. This
+can't currently happen as the cache holds a reference to the
+QQmlPropertyCache until the QQmlEngine is destroyed.
+*/
+QQmlPropertyCache *QQmlEnginePrivate::cache(QObject *obj)
+{
+ if (!obj || QObjectPrivate::get(obj)->metaObject || QObjectPrivate::get(obj)->wasDeleted)
+ return 0;
+
+ Locker locker(this);
+ const QMetaObject *mo = obj->metaObject();
+ QQmlPropertyCache *rv = propertyCache.value(mo);
+ if (!rv) rv = createCache(mo);
+ return rv;
+}
+
+/*!
+Returns a QQmlPropertyCache for \a metaObject.
+
+As the cache is persisted for the life of the engine, \a metaObject must be
+a static "compile time" meta-object, or a meta-object that is otherwise known to
+exist for the lifetime of the QQmlEngine.
+
+The returned cache is not referenced, so if it is to be stored, call addref().
+*/
+QQmlPropertyCache *QQmlEnginePrivate::cache(const QMetaObject *metaObject)
+{
+ Q_ASSERT(metaObject);
+
+ Locker locker(this);
+ QQmlPropertyCache *rv = propertyCache.value(metaObject);
+ if (!rv) rv = createCache(metaObject);
+ return rv;
+}
+
+/*!
+Returns a QQmlPropertyCache for \a type with \a minorVersion.
+
+The returned cache is not referenced, so if it is to be stored, call addref().
+*/
+QQmlPropertyCache *QQmlEnginePrivate::cache(QQmlType *type, int minorVersion, QQmlError &error)
+{
+ Q_ASSERT(type);
+
+ if (minorVersion == -1 || !type->containsRevisionedAttributes())
+ return cache(type->metaObject());
+
+ Locker locker(this);
+ QQmlPropertyCache *rv = typePropertyCache.value(qMakePair(type, minorVersion));
+ if (!rv) rv = createCache(type, minorVersion, error);
+ return rv;
+}
+
+QV8Engine *QQmlEnginePrivate::getV8Engine(QQmlEngine *e)
+{
+ return e->d_func()->v8engine();
+}
+
+QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlEngine *e)
+{
+ return e->d_func();
+}
+
+const QQmlEnginePrivate *QQmlEnginePrivate::get(const QQmlEngine *e)
+{
+ return e->d_func();
+}
+
+QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContext *c)
+{
+ return (c && c->engine()) ? QQmlEnginePrivate::get(c->engine()) : 0;
+}
+
+QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContextData *c)
+{
+ return (c && c->engine) ? QQmlEnginePrivate::get(c->engine) : 0;
+}
+
+QQmlEngine *QQmlEnginePrivate::get(QQmlEnginePrivate *p)
+{
+ return p->q_func();
+}
+
+void QQmlEnginePrivate::captureProperty(QQmlNotifier *n)
+{
+ if (propertyCapture)
+ propertyCapture->captureProperty(n);
+}
+
+void QQmlEnginePrivate::captureProperty(QObject *o, int c, int n)
+{
+ if (propertyCapture)
+ propertyCapture->captureProperty(o, c, n);
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLENGINE_P_H
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp
new file mode 100644
index 0000000000..79424913f8
--- /dev/null
+++ b/src/qml/qml/qqmlerror.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlerror.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QQmlError
+ \since 4.7
+ \brief The QQmlError class encapsulates a QML error.
+
+ QQmlError includes a textual description of the error, as well
+ as location information (the file, line, and column). The toString()
+ method creates a single-line, human-readable string containing all of
+ this information, for example:
+ \code
+ file:///home/user/test.qml:7:8: Invalid property assignment: double expected
+ \endcode
+
+ You can use qDebug() or qWarning() to output errors to the console. This method
+ will attempt to open the file indicated by the error
+ and include additional contextual information.
+ \code
+ file:///home/user/test.qml:7:8: Invalid property assignment: double expected
+ y: "hello"
+ ^
+ \endcode
+
+ \sa QQuickView::errors(), QQmlComponent::errors()
+*/
+class QQmlErrorPrivate
+{
+public:
+ QQmlErrorPrivate();
+
+ QUrl url;
+ QString description;
+ int line;
+ int column;
+};
+
+QQmlErrorPrivate::QQmlErrorPrivate()
+: line(-1), column(-1)
+{
+}
+
+/*!
+ Creates an empty error object.
+*/
+QQmlError::QQmlError()
+: d(0)
+{
+}
+
+/*!
+ Creates a copy of \a other.
+*/
+QQmlError::QQmlError(const QQmlError &other)
+: d(0)
+{
+ *this = other;
+}
+
+/*!
+ Assigns \a other to this error object.
+*/
+QQmlError &QQmlError::operator=(const QQmlError &other)
+{
+ if (!other.d) {
+ delete d;
+ d = 0;
+ } else {
+ if (!d) d = new QQmlErrorPrivate;
+ d->url = other.d->url;
+ d->description = other.d->description;
+ d->line = other.d->line;
+ d->column = other.d->column;
+ }
+ return *this;
+}
+
+/*!
+ \internal
+*/
+QQmlError::~QQmlError()
+{
+ delete d; d = 0;
+}
+
+/*!
+ Returns true if this error is valid, otherwise false.
+*/
+bool QQmlError::isValid() const
+{
+ return d != 0;
+}
+
+/*!
+ Returns the url for the file that caused this error.
+*/
+QUrl QQmlError::url() const
+{
+ if (d) return d->url;
+ else return QUrl();
+}
+
+/*!
+ Sets the \a url for the file that caused this error.
+*/
+void QQmlError::setUrl(const QUrl &url)
+{
+ if (!d) d = new QQmlErrorPrivate;
+ d->url = url;
+}
+
+/*!
+ Returns the error description.
+*/
+QString QQmlError::description() const
+{
+ if (d) return d->description;
+ else return QString();
+}
+
+/*!
+ Sets the error \a description.
+*/
+void QQmlError::setDescription(const QString &description)
+{
+ if (!d) d = new QQmlErrorPrivate;
+ d->description = description;
+}
+
+/*!
+ Returns the error line number.
+*/
+int QQmlError::line() const
+{
+ if (d) return d->line;
+ else return -1;
+}
+
+/*!
+ Sets the error \a line number.
+*/
+void QQmlError::setLine(int line)
+{
+ if (!d) d = new QQmlErrorPrivate;
+ d->line = line;
+}
+
+/*!
+ Returns the error column number.
+*/
+int QQmlError::column() const
+{
+ if (d) return d->column;
+ else return -1;
+}
+
+/*!
+ Sets the error \a column number.
+*/
+void QQmlError::setColumn(int column)
+{
+ if (!d) d = new QQmlErrorPrivate;
+ d->column = column;
+}
+
+/*!
+ Returns the error as a human readable string.
+*/
+QString QQmlError::toString() const
+{
+ QString rv;
+ if (url().isEmpty()) {
+ rv = QLatin1String("<Unknown File>");
+ } else if (line() != -1) {
+ rv = url().toString() + QLatin1Char(':') + QString::number(line());
+ if(column() != -1)
+ rv += QLatin1Char(':') + QString::number(column());
+ } else {
+ rv = url().toString();
+ }
+
+ rv += QLatin1String(": ") + description();
+
+ return rv;
+}
+
+/*!
+ \relates QQmlError
+ \fn QDebug operator<<(QDebug debug, const QQmlError &error)
+
+ Outputs a human readable version of \a error to \a debug.
+*/
+
+QDebug operator<<(QDebug debug, const QQmlError &error)
+{
+ debug << qPrintable(error.toString());
+
+ QUrl url = error.url();
+
+ if (error.line() > 0 && url.scheme() == QLatin1String("file")) {
+ QString file = url.toLocalFile();
+ QFile f(file);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QTextStream stream(data, QIODevice::ReadOnly);
+#ifndef QT_NO_TEXTCODEC
+ stream.setCodec("UTF-8");
+#endif
+ const QString code = stream.readAll();
+ const QStringList lines = code.split(QLatin1Char('\n'));
+
+ if (lines.count() >= error.line()) {
+ const QString &line = lines.at(error.line() - 1);
+ debug << "\n " << qPrintable(line);
+
+ if(error.column() > 0) {
+ int column = qMax(0, error.column() - 1);
+ column = qMin(column, line.length());
+
+ QByteArray ind;
+ ind.reserve(column);
+ for (int i = 0; i < column; ++i) {
+ const QChar ch = line.at(i);
+ if (ch.isSpace())
+ ind.append(ch.unicode());
+ else
+ ind.append(' ');
+ }
+ ind.append('^');
+ debug << "\n " << ind.constData();
+ }
+ }
+ }
+ }
+ return debug;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlerror.h b/src/qml/qml/qqmlerror.h
new file mode 100644
index 0000000000..3c148549d0
--- /dev/null
+++ b/src/qml/qml/qqmlerror.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLERROR_H
+#define QQMLERROR_H
+
+#include <QtQml/qtqmlglobal.h>
+
+#include <QtCore/qurl.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QDebug;
+class QQmlErrorPrivate;
+class Q_QML_EXPORT QQmlError
+{
+public:
+ QQmlError();
+ QQmlError(const QQmlError &);
+ QQmlError &operator=(const QQmlError &);
+ ~QQmlError();
+
+ bool isValid() const;
+
+ QUrl url() const;
+ void setUrl(const QUrl &);
+ QString description() const;
+ void setDescription(const QString &);
+ int line() const;
+ void setLine(int);
+ int column() const;
+ void setColumn(int);
+
+ QString toString() const;
+private:
+ QQmlErrorPrivate *d;
+};
+
+QDebug Q_QML_EXPORT operator<<(QDebug debug, const QQmlError &error);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLERROR_H
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
new file mode 100644
index 0000000000..ecdbf21d4b
--- /dev/null
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -0,0 +1,982 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlexpression.h"
+#include "qqmlexpression_p.h"
+
+#include "qqmlengine_p.h"
+#include "qqmlcontext_p.h"
+#include "qqmlrewrite_p.h"
+#include "qqmlscriptstring_p.h"
+#include "qqmlcompiler_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+bool QQmlDelayedError::addError(QQmlEnginePrivate *e)
+{
+ if (!e) return false;
+
+ if (e->inProgressCreations == 0) return false; // Not in construction
+
+ if (prevError) return true; // Already in error chain
+
+ prevError = &e->erroredBindings;
+ nextError = e->erroredBindings;
+ e->erroredBindings = this;
+ if (nextError) nextError->prevError = &nextError;
+
+ return true;
+}
+
+QQmlJavaScriptExpression::QQmlJavaScriptExpression(VTable *v)
+: m_vtable(v)
+{
+}
+
+QQmlJavaScriptExpression::~QQmlJavaScriptExpression()
+{
+ clearGuards();
+}
+
+static QQmlJavaScriptExpression::VTable QQmlExpressionPrivate_jsvtable = {
+ QQmlExpressionPrivate::expressionIdentifier,
+ QQmlExpressionPrivate::expressionChanged
+};
+
+QQmlExpressionPrivate::QQmlExpressionPrivate()
+: QQmlJavaScriptExpression(&QQmlExpressionPrivate_jsvtable),
+ expressionFunctionValid(true), expressionFunctionRewritten(false),
+ extractExpressionFromFunction(false), line(-1), dataRef(0)
+{
+}
+
+QQmlExpressionPrivate::~QQmlExpressionPrivate()
+{
+ qPersistentDispose(v8qmlscope);
+ qPersistentDispose(v8function);
+ if (dataRef) dataRef->release();
+ dataRef = 0;
+}
+
+void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr,
+ QObject *me)
+{
+ expression = expr;
+
+ QQmlAbstractExpression::setContext(ctxt);
+ setScopeObject(me);
+ expressionFunctionValid = false;
+ expressionFunctionRewritten = false;
+}
+
+void QQmlExpressionPrivate::init(QQmlContextData *ctxt, v8::Handle<v8::Function> func,
+ QObject *me)
+{
+ QQmlAbstractExpression::setContext(ctxt);
+ setScopeObject(me);
+
+ v8function = qPersistentNew<v8::Function>(func);
+ setUseSharedContext(false);
+ expressionFunctionValid = true;
+ expressionFunctionRewritten = false;
+ extractExpressionFromFunction = true;
+}
+
+void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr,
+ bool isRewritten, QObject *me, const QString &srcUrl,
+ int lineNumber, int columnNumber)
+{
+ url = srcUrl;
+ line = lineNumber;
+ column = columnNumber;
+
+ expression = expr;
+
+ expressionFunctionValid = false;
+ expressionFunctionRewritten = isRewritten;
+
+ QQmlAbstractExpression::setContext(ctxt);
+ setScopeObject(me);
+}
+
+void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QByteArray &expr,
+ bool isRewritten, QObject *me, const QString &srcUrl,
+ int lineNumber, int columnNumber)
+{
+ url = srcUrl;
+ line = lineNumber;
+ column = columnNumber;
+
+ if (isRewritten) {
+ expressionFunctionValid = true;
+ expressionFunctionRewritten = true;
+ v8function = evalFunction(ctxt, me, expr.constData(), expr.length(),
+ srcUrl, lineNumber, &v8qmlscope);
+ setUseSharedContext(false);
+
+ expressionUtf8 = expr;
+ } else {
+ expression = QString::fromUtf8(expr);
+
+ expressionFunctionValid = false;
+ expressionFunctionRewritten = isRewritten;
+ }
+
+ QQmlAbstractExpression::setContext(ctxt);
+ setScopeObject(me);
+}
+
+// Callee owns the persistent handle
+v8::Persistent<v8::Function>
+QQmlExpressionPrivate::evalFunction(QQmlContextData *ctxt, QObject *scope,
+ const char *code, int codeLength,
+ const QString &filename, int line,
+ v8::Persistent<v8::Object> *qmlscope)
+{
+ QQmlEngine *engine = ctxt->engine;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope ctxtscope(ep->v8engine()->context());
+
+ v8::TryCatch tc;
+ v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
+ v8::Local<v8::Script> script = ep->v8engine()->qmlModeCompile(code, codeLength, filename, line);
+ if (tc.HasCaught()) {
+ QQmlError error;
+ error.setDescription(QLatin1String("Exception occurred during function compilation"));
+ error.setLine(line);
+ error.setUrl(QUrl::fromLocalFile(filename));
+ v8::Local<v8::Message> message = tc.Message();
+ if (!message.IsEmpty())
+ QQmlExpressionPrivate::exceptionToError(message, error);
+ ep->warning(error);
+ return v8::Persistent<v8::Function>();
+ }
+ v8::Local<v8::Value> result = script->Run(scopeobject);
+ if (tc.HasCaught()) {
+ QQmlError error;
+ error.setDescription(QLatin1String("Exception occurred during function evaluation"));
+ error.setLine(line);
+ error.setUrl(QUrl::fromLocalFile(filename));
+ v8::Local<v8::Message> message = tc.Message();
+ if (!message.IsEmpty())
+ QQmlExpressionPrivate::exceptionToError(message, error);
+ ep->warning(error);
+ return v8::Persistent<v8::Function>();
+ }
+ if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
+ return qPersistentNew<v8::Function>(v8::Local<v8::Function>::Cast(result));
+}
+
+// Callee owns the persistent handle
+v8::Persistent<v8::Function>
+QQmlExpressionPrivate::evalFunction(QQmlContextData *ctxt, QObject *scope,
+ const QString &code, const QString &filename, int line,
+ v8::Persistent<v8::Object> *qmlscope)
+{
+ QQmlEngine *engine = ctxt->engine;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope ctxtscope(ep->v8engine()->context());
+
+ v8::TryCatch tc;
+ v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
+ v8::Local<v8::Script> script = ep->v8engine()->qmlModeCompile(code, filename, line);
+ if (tc.HasCaught()) {
+ QQmlError error;
+ error.setDescription(QLatin1String("Exception occurred during function compilation"));
+ error.setLine(line);
+ error.setUrl(QUrl::fromLocalFile(filename));
+ v8::Local<v8::Message> message = tc.Message();
+ if (!message.IsEmpty())
+ QQmlExpressionPrivate::exceptionToError(message, error);
+ ep->warning(error);
+ return v8::Persistent<v8::Function>();
+ }
+ v8::Local<v8::Value> result = script->Run(scopeobject);
+ if (tc.HasCaught()) {
+ QQmlError error;
+ error.setDescription(QLatin1String("Exception occurred during function evaluation"));
+ error.setLine(line);
+ error.setUrl(QUrl::fromLocalFile(filename));
+ v8::Local<v8::Message> message = tc.Message();
+ if (!message.IsEmpty())
+ QQmlExpressionPrivate::exceptionToError(message, error);
+ ep->warning(error);
+ return v8::Persistent<v8::Function>();
+ }
+ if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
+ return qPersistentNew<v8::Function>(v8::Local<v8::Function>::Cast(result));
+}
+
+QQmlExpression *
+QQmlExpressionPrivate::create(QQmlContextData *ctxt, QObject *object,
+ const QString &expr, bool isRewritten,
+ const QString &url, int lineNumber, int columnNumber)
+{
+ return new QQmlExpression(ctxt, object, expr, isRewritten, url, lineNumber, columnNumber, *new QQmlExpressionPrivate);
+}
+
+/*!
+ \class QQmlExpression
+ \since 4.7
+ \brief The QQmlExpression class evaluates JavaScript in a QML context.
+
+ For example, given a file \c main.qml like this:
+
+ \qml
+ import QtQuick 2.0
+
+ Item {
+ width: 200; height: 200
+ }
+ \endqml
+
+ The following code evaluates a JavaScript expression in the context of the
+ above QML:
+
+ \code
+ QQmlEngine *engine = new QQmlEngine;
+ QQmlComponent component(engine, QUrl::fromLocalFile("main.qml"));
+
+ QObject *myObject = component.create();
+ QQmlExpression *expr = new QQmlExpression(engine->rootContext(), myObject, "width * 2");
+ int result = expr->evaluate().toInt(); // result = 400
+ \endcode
+*/
+
+/*!
+ Create an invalid QQmlExpression.
+
+ As the expression will not have an associated QQmlContext, this will be a
+ null expression object and its value will always be an invalid QVariant.
+ */
+QQmlExpression::QQmlExpression()
+: QObject(*new QQmlExpressionPrivate, 0)
+{
+}
+
+/*! \internal */
+QQmlExpression::QQmlExpression(QQmlContextData *ctxt,
+ QObject *object, const QString &expr, bool isRewritten,
+ const QString &url, int lineNumber, int columnNumber,
+ QQmlExpressionPrivate &dd)
+: QObject(dd, 0)
+{
+ Q_D(QQmlExpression);
+ d->init(ctxt, expr, isRewritten, object, url, lineNumber, columnNumber);
+}
+
+/*! \internal */
+QQmlExpression::QQmlExpression(QQmlContextData *ctxt,
+ QObject *object, const QByteArray &expr,
+ bool isRewritten,
+ const QString &url, int lineNumber, int columnNumber,
+ QQmlExpressionPrivate &dd)
+: QObject(dd, 0)
+{
+ Q_D(QQmlExpression);
+ d->init(ctxt, expr, isRewritten, object, url, lineNumber, columnNumber);
+}
+
+/*!
+ Create a QQmlExpression object that is a child of \a parent.
+
+ The \script provides the expression to be evaluated, the context to evaluate it in,
+ and the scope object to evaluate it with.
+
+ This constructor is functionally equivalent to the following, but in most cases
+ is more efficient.
+ \code
+ QQmlExpression expression(script.context(), script.scopeObject(), script.script(), parent);
+ \endcode
+
+ \sa QQmlScriptString
+*/
+QQmlExpression::QQmlExpression(const QQmlScriptString &script, QObject *parent)
+: QObject(*new QQmlExpressionPrivate, parent)
+{
+ Q_D(QQmlExpression);
+ bool defaultConstruction = false;
+
+ int id = script.d.data()->bindingId;
+ if (id < 0) {
+ defaultConstruction = true;
+ } else {
+ QQmlContextData *ctxtdata = QQmlContextData::get(script.context());
+
+ QQmlEnginePrivate *engine = QQmlEnginePrivate::get(script.context()->engine());
+ QQmlCompiledData *cdata = 0;
+ QQmlTypeData *typeData = 0;
+ if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
+ typeData = engine->typeLoader.get(ctxtdata->url);
+ cdata = typeData->compiledData();
+ }
+
+ if (cdata)
+ d->init(ctxtdata, cdata->primitives.at(id), true, script.scopeObject(),
+ cdata->name, script.d.data()->lineNumber, script.d.data()->columnNumber);
+ else
+ defaultConstruction = true;
+
+ if (cdata)
+ cdata->release();
+ if (typeData)
+ typeData->release();
+ }
+
+ if (defaultConstruction)
+ d->init(QQmlContextData::get(script.context()), script.script(), script.scopeObject());
+}
+
+/*!
+ Create a QQmlExpression object that is a child of \a parent.
+
+ The \a expression JavaScript will be executed in the \a ctxt QQmlContext.
+ If specified, the \a scope object's properties will also be in scope during
+ the expression's execution.
+*/
+QQmlExpression::QQmlExpression(QQmlContext *ctxt,
+ QObject *scope,
+ const QString &expression,
+ QObject *parent)
+: QObject(*new QQmlExpressionPrivate, parent)
+{
+ Q_D(QQmlExpression);
+ d->init(QQmlContextData::get(ctxt), expression, scope);
+}
+
+/*!
+ \internal
+*/
+QQmlExpression::QQmlExpression(QQmlContextData *ctxt, QObject *scope,
+ const QString &expression)
+: QObject(*new QQmlExpressionPrivate, 0)
+{
+ Q_D(QQmlExpression);
+ d->init(ctxt, expression, scope);
+}
+
+/*! \internal */
+QQmlExpression::QQmlExpression(QQmlContextData *ctxt, QObject *scope,
+ const QString &expression, QQmlExpressionPrivate &dd)
+: QObject(dd, 0)
+{
+ Q_D(QQmlExpression);
+ d->init(ctxt, expression, scope);
+}
+
+/*!
+ \internal
+
+ To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle<v8::Function>.
+ For example:
+ v8::Handle<v8::Function> function;
+ new QQmlExpression(ctxt, scope, &function, ...);
+ */
+QQmlExpression::QQmlExpression(QQmlContextData *ctxt, QObject *scope, void *functionPtr,
+ QQmlExpressionPrivate &dd)
+: QObject(dd, 0)
+{
+ v8::Handle<v8::Function> function = *(v8::Handle<v8::Function> *)functionPtr;
+
+ Q_D(QQmlExpression);
+ d->init(ctxt, function, scope);
+}
+
+/*!
+ Destroy the QQmlExpression instance.
+*/
+QQmlExpression::~QQmlExpression()
+{
+}
+
+/*!
+ Returns the QQmlEngine this expression is associated with, or 0 if there
+ is no association or the QQmlEngine has been destroyed.
+*/
+QQmlEngine *QQmlExpression::engine() const
+{
+ Q_D(const QQmlExpression);
+ return d->context()?d->context()->engine:0;
+}
+
+/*!
+ Returns the QQmlContext this expression is associated with, or 0 if there
+ is no association or the QQmlContext has been destroyed.
+*/
+QQmlContext *QQmlExpression::context() const
+{
+ Q_D(const QQmlExpression);
+ QQmlContextData *data = d->context();
+ return data?data->asQQmlContext():0;
+}
+
+/*!
+ Returns the expression string.
+*/
+QString QQmlExpression::expression() const
+{
+ Q_D(const QQmlExpression);
+ if (d->extractExpressionFromFunction && context()->engine()) {
+ QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(context()->engine());
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(v8engine->context());
+
+ return v8engine->toString(v8::Handle<v8::Value>(d->v8function));
+ } else if (!d->expressionUtf8.isEmpty()) {
+ return QString::fromUtf8(d->expressionUtf8);
+ } else {
+ return d->expression;
+ }
+}
+
+/*!
+ Set the expression to \a expression.
+*/
+void QQmlExpression::setExpression(const QString &expression)
+{
+ Q_D(QQmlExpression);
+
+ d->resetNotifyOnValueChanged();
+ d->expression = expression;
+ d->expressionUtf8.clear();
+ d->expressionFunctionValid = false;
+ d->expressionFunctionRewritten = false;
+ qPersistentDispose(d->v8function);
+ qPersistentDispose(d->v8qmlscope);
+}
+
+void QQmlExpressionPrivate::exceptionToError(v8::Handle<v8::Message> message,
+ QQmlError &error)
+{
+ Q_ASSERT(!message.IsEmpty());
+
+ v8::Handle<v8::Value> name = message->GetScriptResourceName();
+ v8::Handle<v8::String> description = message->Get();
+ int lineNumber = message->GetLineNumber();
+
+ v8::Local<v8::String> file = name->IsString()?name->ToString():v8::Local<v8::String>();
+ if (file.IsEmpty() || file->Length() == 0)
+ error.setUrl(QUrl(QLatin1String("<Unknown File>")));
+ else
+ error.setUrl(QUrl(QV8Engine::toStringStatic(file)));
+
+ error.setLine(lineNumber);
+ error.setColumn(-1);
+
+ QString qDescription = QV8Engine::toStringStatic(description);
+ if (qDescription.startsWith(QLatin1String("Uncaught ")))
+ qDescription = qDescription.mid(9 /* strlen("Uncaught ") */);
+
+ error.setDescription(qDescription);
+}
+
+void QQmlJavaScriptExpression::setNotifyOnValueChanged(bool v)
+{
+ activeGuards.setFlagValue(v);
+ if (!v) clearGuards();
+}
+
+void QQmlJavaScriptExpression::resetNotifyOnValueChanged()
+{
+ clearGuards();
+}
+
+v8::Local<v8::Value>
+QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
+ v8::Handle<v8::Function> function, bool *isUndefined)
+{
+ Q_ASSERT(context && context->engine);
+
+ if (function.IsEmpty() || function->IsUndefined()) {
+ if (isUndefined) *isUndefined = true;
+ return v8::Local<v8::Value>();
+ }
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
+
+ Q_ASSERT(notifyOnValueChanged() || activeGuards.isEmpty());
+ GuardCapture capture(context->engine, this);
+
+ QQmlEnginePrivate::PropertyCapture *lastPropertyCapture = ep->propertyCapture;
+ ep->propertyCapture = notifyOnValueChanged()?&capture:0;
+
+
+ if (notifyOnValueChanged())
+ capture.guards.copyAndClearPrepend(activeGuards);
+
+ QQmlContextData *lastSharedContext = 0;
+ QObject *lastSharedScope = 0;
+
+ bool sharedContext = useSharedContext();
+
+ // All code that follows must check with watcher before it accesses data members
+ // incase we have been deleted.
+ DeleteWatcher watcher(this);
+
+ if (sharedContext) {
+ lastSharedContext = ep->sharedContext;
+ lastSharedScope = ep->sharedScope;
+ ep->sharedContext = context;
+ ep->sharedScope = scopeObject();
+ }
+
+ v8::Local<v8::Value> result;
+ {
+ v8::TryCatch try_catch;
+ v8::Handle<v8::Object> This = ep->v8engine()->global();
+ if (scopeObject() && requiresThisObject()) {
+ v8::Handle<v8::Value> value = ep->v8engine()->newQObject(scopeObject());
+ if (value->IsObject()) This = v8::Handle<v8::Object>::Cast(value);
+ }
+
+ result = function->Call(This, 0, 0);
+
+ if (isUndefined)
+ *isUndefined = try_catch.HasCaught() || result->IsUndefined();
+
+ if (watcher.wasDeleted()) {
+ } else if (try_catch.HasCaught()) {
+ v8::Context::Scope scope(ep->v8engine()->context());
+ v8::Local<v8::Message> message = try_catch.Message();
+ if (!message.IsEmpty()) {
+ QQmlExpressionPrivate::exceptionToError(message, delayedError()->error);
+ } else {
+ if (hasDelayedError()) delayedError()->error = QQmlError();
+ }
+ } else {
+ if (hasDelayedError()) delayedError()->error = QQmlError();
+ }
+ }
+
+ if (sharedContext) {
+ ep->sharedContext = lastSharedContext;
+ ep->sharedScope = lastSharedScope;
+ }
+
+ if (capture.errorString) {
+ for (int ii = 0; ii < capture.errorString->count(); ++ii)
+ qWarning("%s", qPrintable(capture.errorString->at(ii)));
+ delete capture.errorString;
+ capture.errorString = 0;
+ }
+
+ while (Guard *g = capture.guards.takeFirst())
+ g->Delete();
+
+ ep->propertyCapture = lastPropertyCapture;
+
+ return result;
+}
+
+void QQmlJavaScriptExpression::GuardCapture::captureProperty(QQmlNotifier *n)
+{
+ if (expression) {
+
+ // Try and find a matching guard
+ while (!guards.isEmpty() && !guards.first()->isConnected(n))
+ guards.takeFirst()->Delete();
+
+ Guard *g = 0;
+ if (!guards.isEmpty()) {
+ g = guards.takeFirst();
+ g->cancelNotify();
+ Q_ASSERT(g->isConnected(n));
+ } else {
+ g = Guard::New(expression, engine);
+ g->connect(n);
+ }
+
+ expression->activeGuards.prepend(g);
+ }
+}
+
+void QQmlJavaScriptExpression::GuardCapture::captureProperty(QObject *o, int c, int n)
+{
+ if (expression) {
+ if (n == -1) {
+ if (!errorString) {
+ errorString = new QStringList;
+ QString preamble = QLatin1String("QQmlExpression: Expression ") +
+ expression->m_vtable->expressionIdentifier(expression) +
+ QLatin1String(" depends on non-NOTIFYable properties:");
+ errorString->append(preamble);
+ }
+
+ const QMetaObject *metaObj = o->metaObject();
+ QMetaProperty metaProp = metaObj->property(c);
+
+ QString error = QLatin1String(" ") +
+ QString::fromUtf8(metaObj->className()) +
+ QLatin1String("::") +
+ QString::fromUtf8(metaProp.name());
+ errorString->append(error);
+ } else {
+
+ // Try and find a matching guard
+ while (!guards.isEmpty() && !guards.first()->isConnected(o, n))
+ guards.takeFirst()->Delete();
+
+ Guard *g = 0;
+ if (!guards.isEmpty()) {
+ g = guards.takeFirst();
+ g->cancelNotify();
+ Q_ASSERT(g->isConnected(o, n));
+ } else {
+ g = Guard::New(expression, engine);
+ g->connect(o, n);
+ }
+
+ expression->activeGuards.prepend(g);
+ }
+ }
+}
+
+void QQmlJavaScriptExpression::clearError()
+{
+ if (m_vtable.hasValue()) {
+ m_vtable.value().error = QQmlError();
+ m_vtable.value().removeError();
+ }
+}
+
+QQmlError QQmlJavaScriptExpression::error() const
+{
+ if (m_vtable.hasValue()) return m_vtable.constValue()->error;
+ else return QQmlError();
+}
+
+QQmlDelayedError *QQmlJavaScriptExpression::delayedError()
+{
+ return &m_vtable.value();
+}
+
+void QQmlJavaScriptExpression::clearGuards()
+{
+ while (Guard *g = activeGuards.takeFirst())
+ g->Delete();
+}
+
+// Must be called with a valid handle scope
+v8::Local<v8::Value> QQmlExpressionPrivate::v8value(QObject *secondaryScope, bool *isUndefined)
+{
+ if (!expressionFunctionValid) {
+ bool ok = true;
+
+ QQmlRewrite::RewriteBinding rewriteBinding;
+ rewriteBinding.setName(name);
+ QString code;
+ if (expressionFunctionRewritten)
+ code = expression;
+ else
+ code = rewriteBinding(expression, &ok);
+
+ if (ok) v8function = evalFunction(context(), scopeObject(), code, url, line, &v8qmlscope);
+ setUseSharedContext(false);
+ expressionFunctionValid = true;
+ }
+
+
+ if (secondaryScope) {
+ v8::Local<v8::Value> result;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
+ QObject *restoreSecondaryScope = 0;
+ restoreSecondaryScope = ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, secondaryScope);
+ result = evaluate(context(), v8function, isUndefined);
+ ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, restoreSecondaryScope);
+ return result;
+ } else {
+ return evaluate(context(), v8function, isUndefined);
+ }
+}
+
+QVariant QQmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined)
+{
+ Q_Q(QQmlExpression);
+
+ if (!context() || !context()->isValid()) {
+ qWarning("QQmlExpression: Attempted to evaluate an expression in an invalid context");
+ return QVariant();
+ }
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(q->engine());
+ QVariant rv;
+
+ ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation.
+
+ {
+ v8::HandleScope handle_scope;
+ v8::Context::Scope context_scope(ep->v8engine()->context());
+ v8::Local<v8::Value> result = v8value(secondaryScope, isUndefined);
+ rv = ep->v8engine()->toVariant(result, qMetaTypeId<QList<QObject*> >());
+ }
+
+ ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete.
+
+ return rv;
+}
+
+/*!
+ Evaulates the expression, returning the result of the evaluation,
+ or an invalid QVariant if the expression is invalid or has an error.
+
+ \a valueIsUndefined is set to true if the expression resulted in an
+ undefined value.
+
+ \sa hasError(), error()
+*/
+QVariant QQmlExpression::evaluate(bool *valueIsUndefined)
+{
+ Q_D(QQmlExpression);
+ return d->value(0, valueIsUndefined);
+}
+
+/*!
+Returns true if the valueChanged() signal is emitted when the expression's evaluated
+value changes.
+*/
+bool QQmlExpression::notifyOnValueChanged() const
+{
+ Q_D(const QQmlExpression);
+ return d->notifyOnValueChanged();
+}
+
+/*!
+ Sets whether the valueChanged() signal is emitted when the
+ expression's evaluated value changes.
+
+ If \a notifyOnChange is true, the QQmlExpression will
+ monitor properties involved in the expression's evaluation, and emit
+ QQmlExpression::valueChanged() if they have changed. This
+ allows an application to ensure that any value associated with the
+ result of the expression remains up to date.
+
+ If \a notifyOnChange is false (default), the QQmlExpression
+ will not montitor properties involved in the expression's
+ evaluation, and QQmlExpression::valueChanged() will never be
+ emitted. This is more efficient if an application wants a "one off"
+ evaluation of the expression.
+*/
+void QQmlExpression::setNotifyOnValueChanged(bool notifyOnChange)
+{
+ Q_D(QQmlExpression);
+ d->setNotifyOnValueChanged(notifyOnChange);
+}
+
+/*!
+ Returns the source file URL for this expression. The source location must
+ have been previously set by calling setSourceLocation().
+*/
+QString QQmlExpression::sourceFile() const
+{
+ Q_D(const QQmlExpression);
+ return d->url;
+}
+
+/*!
+ Returns the source file line number for this expression. The source location
+ must have been previously set by calling setSourceLocation().
+*/
+int QQmlExpression::lineNumber() const
+{
+ Q_D(const QQmlExpression);
+ return d->line;
+}
+
+/*!
+ Returns the source file column number for this expression. The source location
+ must have been previously set by calling setSourceLocation().
+*/
+int QQmlExpression::columnNumber() const
+{
+ Q_D(const QQmlExpression);
+ return d->column;
+}
+
+/*!
+ Set the location of this expression to \a line of \a url. This information
+ is used by the script engine.
+*/
+void QQmlExpression::setSourceLocation(const QString &url, int line, int column)
+{
+ Q_D(QQmlExpression);
+ d->url = url;
+ d->line = line;
+ d->column = column;
+}
+
+/*!
+ Returns the expression's scope object, if provided, otherwise 0.
+
+ In addition to data provided by the expression's QQmlContext, the scope
+ object's properties are also in scope during the expression's evaluation.
+*/
+QObject *QQmlExpression::scopeObject() const
+{
+ Q_D(const QQmlExpression);
+ return d->scopeObject();
+}
+
+/*!
+ Returns true if the last call to evaluate() resulted in an error,
+ otherwise false.
+
+ \sa error(), clearError()
+*/
+bool QQmlExpression::hasError() const
+{
+ Q_D(const QQmlExpression);
+ return d->hasError();
+}
+
+/*!
+ Clear any expression errors. Calls to hasError() following this will
+ return false.
+
+ \sa hasError(), error()
+*/
+void QQmlExpression::clearError()
+{
+ Q_D(QQmlExpression);
+ d->clearError();
+}
+
+/*!
+ Return any error from the last call to evaluate(). If there was no error,
+ this returns an invalid QQmlError instance.
+
+ \sa hasError(), clearError()
+*/
+
+QQmlError QQmlExpression::error() const
+{
+ Q_D(const QQmlExpression);
+ return d->error();
+}
+
+/*!
+ \fn void QQmlExpression::valueChanged()
+
+ Emitted each time the expression value changes from the last time it was
+ evaluated. The expression must have been evaluated at least once (by
+ calling QQmlExpression::evaluate()) before this signal will be emitted.
+*/
+
+void QQmlExpressionPrivate::expressionChanged(QQmlJavaScriptExpression *e)
+{
+ QQmlExpressionPrivate *This = static_cast<QQmlExpressionPrivate *>(e);
+ This->expressionChanged();
+}
+
+void QQmlExpressionPrivate::expressionChanged()
+{
+ Q_Q(QQmlExpression);
+ emit q->valueChanged();
+}
+
+QString QQmlExpressionPrivate::expressionIdentifier(QQmlJavaScriptExpression *e)
+{
+ QQmlExpressionPrivate *This = static_cast<QQmlExpressionPrivate *>(e);
+ return QLatin1String("\"") + This->expression + QLatin1String("\"");
+}
+
+QQmlAbstractExpression::QQmlAbstractExpression()
+: m_prevExpression(0), m_nextExpression(0)
+{
+}
+
+QQmlAbstractExpression::~QQmlAbstractExpression()
+{
+ if (m_prevExpression) {
+ *m_prevExpression = m_nextExpression;
+ if (m_nextExpression)
+ m_nextExpression->m_prevExpression = m_prevExpression;
+ }
+
+ if (m_context.isT2())
+ m_context.asT2()->_s = 0;
+}
+
+QQmlContextData *QQmlAbstractExpression::context() const
+{
+ if (m_context.isT1()) return m_context.asT1();
+ else return m_context.asT2()->_c;
+}
+
+void QQmlAbstractExpression::setContext(QQmlContextData *context)
+{
+ if (m_prevExpression) {
+ *m_prevExpression = m_nextExpression;
+ if (m_nextExpression)
+ m_nextExpression->m_prevExpression = m_prevExpression;
+ m_prevExpression = 0;
+ m_nextExpression = 0;
+ }
+
+ if (m_context.isT1()) m_context = context;
+ else m_context.asT2()->_c = context;
+
+ if (context) {
+ m_nextExpression = context->expressions;
+ if (m_nextExpression)
+ m_nextExpression->m_prevExpression = &m_nextExpression;
+ m_prevExpression = &context->expressions;
+ context->expressions = this;
+ }
+}
+
+void QQmlAbstractExpression::refresh()
+{
+}
+
+bool QQmlAbstractExpression::isValid() const
+{
+ return context() != 0;
+}
+
+QT_END_NAMESPACE
+
+#include <moc_qqmlexpression.cpp>
diff --git a/src/qml/qml/qqmlexpression.h b/src/qml/qml/qqmlexpression.h
new file mode 100644
index 0000000000..4044546fbf
--- /dev/null
+++ b/src/qml/qml/qqmlexpression.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLEXPRESSION_H
+#define QQMLEXPRESSION_H
+
+#include <QtQml/qqmlerror.h>
+#include <QtQml/qqmlscriptstring.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QString;
+class QQmlRefCount;
+class QQmlEngine;
+class QQmlContext;
+class QQmlExpressionPrivate;
+class QQmlContextData;
+class Q_QML_EXPORT QQmlExpression : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlExpression();
+ QQmlExpression(QQmlContext *, QObject *, const QString &, QObject * = 0);
+ explicit QQmlExpression(const QQmlScriptString &, QObject * = 0);
+ virtual ~QQmlExpression();
+
+ QQmlEngine *engine() const;
+ QQmlContext *context() const;
+
+ QString expression() const;
+ void setExpression(const QString &);
+
+ bool notifyOnValueChanged() const;
+ void setNotifyOnValueChanged(bool);
+
+ QString sourceFile() const;
+ int lineNumber() const;
+ int columnNumber() const;
+ void setSourceLocation(const QString &fileName, int line, int column = 0);
+
+ QObject *scopeObject() const;
+
+ bool hasError() const;
+ void clearError();
+ QQmlError error() const;
+
+ QVariant evaluate(bool *valueIsUndefined = 0);
+
+Q_SIGNALS:
+ void valueChanged();
+
+protected:
+ QQmlExpression(QQmlContextData *, QObject *, const QString &,
+ QQmlExpressionPrivate &dd);
+ QQmlExpression(QQmlContextData *, QObject *, void *,
+ QQmlExpressionPrivate &dd);
+ QQmlExpression(QQmlContextData *, QObject *, const QString &, bool,
+ const QString &, int, int, QQmlExpressionPrivate &dd);
+ QQmlExpression(QQmlContextData *, QObject *, const QByteArray &, bool,
+ const QString &, int, int, QQmlExpressionPrivate &dd);
+
+private:
+ QQmlExpression(QQmlContextData *, QObject *, const QString &);
+
+ Q_DISABLE_COPY(QQmlExpression)
+ Q_DECLARE_PRIVATE(QQmlExpression)
+ friend class QQmlDebugger;
+ friend class QQmlContext;
+ friend class QQmlVME;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLEXPRESSION_H
+
diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h
new file mode 100644
index 0000000000..deca29ab60
--- /dev/null
+++ b/src/qml/qml/qqmlexpression_p.h
@@ -0,0 +1,406 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLEXPRESSION_P_H
+#define QQMLEXPRESSION_P_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 "qqmlexpression.h"
+
+#include <private/qv8engine_p.h>
+#include <private/qfieldlist_p.h>
+#include <private/qflagpointer_p.h>
+#include <private/qdeletewatcher_p.h>
+#include <private/qqmlguard_p.h>
+#include <private/qpointervaluepair_p.h>
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlAbstractExpression
+{
+public:
+ QQmlAbstractExpression();
+ virtual ~QQmlAbstractExpression();
+
+ bool isValid() const;
+
+ QQmlContextData *context() const;
+ void setContext(QQmlContextData *);
+
+ virtual void refresh();
+
+ class DeleteWatcher {
+ public:
+ inline DeleteWatcher(QQmlAbstractExpression *);
+ inline ~DeleteWatcher();
+ inline bool wasDeleted() const;
+ private:
+ friend class QQmlAbstractExpression;
+ QQmlContextData *_c;
+ QQmlAbstractExpression **_w;
+ QQmlAbstractExpression *_s;
+ };
+
+private:
+ friend class QQmlContext;
+ friend class QQmlContextData;
+ friend class QQmlContextPrivate;
+
+ QBiPointer<QQmlContextData, DeleteWatcher> m_context;
+ QQmlAbstractExpression **m_prevExpression;
+ QQmlAbstractExpression *m_nextExpression;
+};
+
+class QQmlDelayedError
+{
+public:
+ inline QQmlDelayedError() : nextError(0), prevError(0) {}
+ inline ~QQmlDelayedError() { removeError(); }
+
+ QQmlError error;
+
+ bool addError(QQmlEnginePrivate *);
+
+ inline void removeError() {
+ if (!prevError) return;
+ if (nextError) nextError->prevError = prevError;
+ *prevError = nextError;
+ nextError = 0;
+ prevError = 0;
+ }
+
+private:
+ QQmlDelayedError *nextError;
+ QQmlDelayedError **prevError;
+};
+
+class QQmlJavaScriptExpression
+{
+public:
+ // Although this looks crazy, we implement our own "vtable" here, rather than relying on
+ // C++ virtuals, to save memory. By doing it ourselves, we can overload the storage
+ // location that is use for the vtable to also store the rarely used delayed error.
+ // If we use C++ virtuals, we can't do this and it consts us an extra sizeof(void *) in
+ // memory for every expression.
+ struct VTable {
+ QString (*expressionIdentifier)(QQmlJavaScriptExpression *);
+ void (*expressionChanged)(QQmlJavaScriptExpression *);
+ };
+
+ QQmlJavaScriptExpression(VTable *vtable);
+
+ v8::Local<v8::Value> evaluate(QQmlContextData *, v8::Handle<v8::Function>,
+ bool *isUndefined);
+
+ inline bool requiresThisObject() const;
+ inline void setRequiresThisObject(bool v);
+ inline bool useSharedContext() const;
+ inline void setUseSharedContext(bool v);
+ inline bool notifyOnValueChanged() const;
+
+ void setNotifyOnValueChanged(bool v);
+ void resetNotifyOnValueChanged();
+
+ inline QObject *scopeObject() const;
+ inline void setScopeObject(QObject *v);
+
+ class DeleteWatcher {
+ public:
+ inline DeleteWatcher(QQmlJavaScriptExpression *);
+ inline ~DeleteWatcher();
+ inline bool wasDeleted() const;
+ private:
+ friend class QQmlJavaScriptExpression;
+ QObject *_c;
+ QQmlJavaScriptExpression **_w;
+ QQmlJavaScriptExpression *_s;
+ };
+
+ inline bool hasError() const;
+ inline bool hasDelayedError() const;
+ QQmlError error() const;
+ void clearError();
+ QQmlDelayedError *delayedError();
+
+protected:
+ ~QQmlJavaScriptExpression();
+
+private:
+ typedef QQmlJavaScriptExpressionGuard Guard;
+ friend class QQmlJavaScriptExpressionGuard;
+
+ struct GuardCapture : public QQmlEnginePrivate::PropertyCapture {
+ GuardCapture(QQmlEngine *engine, QQmlJavaScriptExpression *e)
+ : engine(engine), expression(e), errorString(0) { }
+
+ ~GuardCapture() {
+ Q_ASSERT(guards.isEmpty());
+ Q_ASSERT(errorString == 0);
+ }
+
+ virtual void captureProperty(QQmlNotifier *);
+ virtual void captureProperty(QObject *, int, int);
+
+ QQmlEngine *engine;
+ QQmlJavaScriptExpression *expression;
+ QFieldList<Guard, &Guard::next> guards;
+ QStringList *errorString;
+ };
+
+ QPointerValuePair<VTable, QQmlDelayedError> m_vtable;
+
+ // We store some flag bits in the following flag pointers.
+ // m_scopeObject:flag1 - requiresThisObject
+ // activeGuards:flag1 - notifyOnValueChanged
+ // activeGuards:flag2 - useSharedContext
+ QBiPointer<QObject, DeleteWatcher> m_scopeObject;
+ QForwardFieldList<Guard, &Guard::next> activeGuards;
+
+ void clearGuards();
+};
+
+class QQmlExpression;
+class QString;
+class Q_QML_PRIVATE_EXPORT QQmlExpressionPrivate : public QObjectPrivate, public QQmlJavaScriptExpression, public QQmlAbstractExpression
+{
+ Q_DECLARE_PUBLIC(QQmlExpression)
+public:
+ QQmlExpressionPrivate();
+ ~QQmlExpressionPrivate();
+
+ void init(QQmlContextData *, const QString &, QObject *);
+ void init(QQmlContextData *, v8::Handle<v8::Function>, QObject *);
+ void init(QQmlContextData *, const QString &, bool, QObject *, const QString &, int, int);
+ void init(QQmlContextData *, const QByteArray &, bool, QObject *, const QString &, int, int);
+
+ QVariant value(QObject *secondaryScope = 0, bool *isUndefined = 0);
+
+ v8::Local<v8::Value> v8value(QObject *secondaryScope = 0, bool *isUndefined = 0);
+
+ static inline QQmlExpressionPrivate *get(QQmlExpression *expr);
+ static inline QQmlExpression *get(QQmlExpressionPrivate *expr);
+
+ void _q_notify();
+
+ static void exceptionToError(v8::Handle<v8::Message>, QQmlError &);
+ static v8::Persistent<v8::Function> evalFunction(QQmlContextData *ctxt, QObject *scope,
+ const QString &code, const QString &filename,
+ int line,
+ v8::Persistent<v8::Object> *qmlscope = 0);
+ static v8::Persistent<v8::Function> evalFunction(QQmlContextData *ctxt, QObject *scope,
+ const char *code, int codeLength,
+ const QString &filename, int line,
+ v8::Persistent<v8::Object> *qmlscope = 0);
+
+ static QQmlExpression *create(QQmlContextData *, QObject *, const QString &, bool,
+ const QString &, int, int);
+
+ bool expressionFunctionValid:1;
+ bool expressionFunctionRewritten:1;
+ bool extractExpressionFromFunction:1;
+
+ // "Inherited" from QQmlJavaScriptExpression
+ static QString expressionIdentifier(QQmlJavaScriptExpression *);
+ static void expressionChanged(QQmlJavaScriptExpression *);
+ virtual void expressionChanged();
+
+ QString expression;
+ QByteArray expressionUtf8;
+
+ v8::Persistent<v8::Object> v8qmlscope;
+ v8::Persistent<v8::Function> v8function;
+
+ QString url; // This is a QString for a reason. QUrls are slooooooow...
+ int line;
+ int column;
+ QString name; //function name, hint for the debugger
+
+ QQmlRefCount *dataRef;
+};
+
+QQmlAbstractExpression::DeleteWatcher::DeleteWatcher(QQmlAbstractExpression *e)
+: _c(0), _w(0), _s(e)
+{
+ if (e->m_context.isT1()) {
+ _w = &_s;
+ _c = e->m_context.asT1();
+ e->m_context = this;
+ } else {
+ // Another watcher is already registered
+ _w = &e->m_context.asT2()->_s;
+ }
+}
+
+QQmlAbstractExpression::DeleteWatcher::~DeleteWatcher()
+{
+ Q_ASSERT(*_w == 0 || (*_w == _s && _s->m_context.isT2()));
+ if (*_w && _s->m_context.asT2() == this)
+ _s->m_context = _c;
+}
+
+bool QQmlAbstractExpression::DeleteWatcher::wasDeleted() const
+{
+ return *_w == 0;
+}
+
+QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e)
+: _c(0), _w(0), _s(e)
+{
+ if (e->m_scopeObject.isT1()) {
+ _w = &_s;
+ _c = e->m_scopeObject.asT1();
+ e->m_scopeObject = this;
+ } else {
+ // Another watcher is already registered
+ _w = &e->m_scopeObject.asT2()->_s;
+ }
+}
+
+QQmlJavaScriptExpression::DeleteWatcher::~DeleteWatcher()
+{
+ Q_ASSERT(*_w == 0 || (*_w == _s && _s->m_scopeObject.isT2()));
+ if (*_w && _s->m_scopeObject.asT2() == this)
+ _s->m_scopeObject = _c;
+}
+
+bool QQmlJavaScriptExpression::DeleteWatcher::wasDeleted() const
+{
+ return *_w == 0;
+}
+
+bool QQmlJavaScriptExpression::requiresThisObject() const
+{
+ return m_scopeObject.flag();
+}
+
+void QQmlJavaScriptExpression::setRequiresThisObject(bool v)
+{
+ m_scopeObject.setFlagValue(v);
+}
+
+bool QQmlJavaScriptExpression::useSharedContext() const
+{
+ return activeGuards.flag2();
+}
+
+void QQmlJavaScriptExpression::setUseSharedContext(bool v)
+{
+ activeGuards.setFlag2Value(v);
+}
+
+bool QQmlJavaScriptExpression::notifyOnValueChanged() const
+{
+ return activeGuards.flag();
+}
+
+QObject *QQmlJavaScriptExpression::scopeObject() const
+{
+ if (m_scopeObject.isT1()) return m_scopeObject.asT1();
+ else return m_scopeObject.asT2()->_c;
+}
+
+void QQmlJavaScriptExpression::setScopeObject(QObject *v)
+{
+ if (m_scopeObject.isT1()) m_scopeObject = v;
+ else m_scopeObject.asT2()->_c = v;
+}
+
+bool QQmlJavaScriptExpression::hasError() const
+{
+ return m_vtable.hasValue() && m_vtable.constValue()->error.isValid();
+}
+
+bool QQmlJavaScriptExpression::hasDelayedError() const
+{
+ return m_vtable.hasValue();
+}
+
+QQmlExpressionPrivate *QQmlExpressionPrivate::get(QQmlExpression *expr)
+{
+ return static_cast<QQmlExpressionPrivate *>(QObjectPrivate::get(expr));
+}
+
+QQmlExpression *QQmlExpressionPrivate::get(QQmlExpressionPrivate *expr)
+{
+ return expr->q_func();
+}
+
+QQmlJavaScriptExpressionGuard::QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *e)
+: expression(e), next(0)
+{
+ callback = &endpointCallback;
+}
+
+void QQmlJavaScriptExpressionGuard::endpointCallback(QQmlNotifierEndpoint *e)
+{
+ QQmlJavaScriptExpression *expression =
+ static_cast<QQmlJavaScriptExpressionGuard *>(e)->expression;
+
+ expression->m_vtable->expressionChanged(expression);
+}
+
+QQmlJavaScriptExpressionGuard *
+QQmlJavaScriptExpressionGuard::New(QQmlJavaScriptExpression *e,
+ QQmlEngine *engine)
+{
+ Q_ASSERT(e);
+ return QQmlEnginePrivate::get(engine)->jsExpressionGuardPool.New(e);
+}
+
+void QQmlJavaScriptExpressionGuard::Delete()
+{
+ QRecyclePool<QQmlJavaScriptExpressionGuard>::Delete(this);
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLEXPRESSION_P_H
diff --git a/src/qml/qml/qqmlextensioninterface.h b/src/qml/qml/qqmlextensioninterface.h
new file mode 100644
index 0000000000..194319431d
--- /dev/null
+++ b/src/qml/qml/qqmlextensioninterface.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLEXTENSIONINTERFACE_H
+#define QQMLEXTENSIONINTERFACE_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlEngine;
+
+class Q_QML_EXPORT QQmlTypesExtensionInterface
+{
+public:
+ virtual ~QQmlTypesExtensionInterface() {}
+ virtual void registerTypes(const char *uri) = 0;
+};
+
+class Q_QML_EXPORT QQmlExtensionInterface : public QQmlTypesExtensionInterface
+{
+public:
+ virtual ~QQmlExtensionInterface() {}
+ virtual void initializeEngine(QQmlEngine *engine, const char *uri) = 0;
+};
+
+#define QQmlTypesExtensionInterface_iid "org.qt-project.Qt.QQmlTypesExtensionInterface"
+
+Q_DECLARE_INTERFACE(QQmlTypesExtensionInterface, "org.qt-project.Qt.QQmlTypesExtensionInterface/1.0")
+
+#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface"
+
+Q_DECLARE_INTERFACE(QQmlExtensionInterface, QQmlExtensionInterface_iid)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLEXTENSIONINTERFACE_H
diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp
new file mode 100644
index 0000000000..c3d8f0b34f
--- /dev/null
+++ b/src/qml/qml/qqmlextensionplugin.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlextensionplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \since 4.7
+ \class QQmlExtensionPlugin
+ \brief The QQmlExtensionPlugin class provides an abstract base for custom QML extension plugins.
+
+ \ingroup plugins
+
+ QQmlExtensionPlugin 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 QQmlExtensionPlugin, 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{Writing a 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.
+
+
+ \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 with a specific \l {QML Modules}{module} 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{Writing a 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 QQmlEngine::importPlugin(), {How to Create Qt Plugins}
+*/
+
+/*!
+ \fn void QQmlExtensionPlugin::registerTypes(const char *uri)
+
+ Registers the QML types in the given \a uri. Subclasses should implement
+ this to call qmlRegisterType() for all types which are provided by the extension
+ plugin.
+
+ The \a uri is an identifier for the plugin generated by the QML engine
+ based on the name and path of the extension's plugin library.
+*/
+
+/*!
+ Constructs a QML extension plugin with the given \a parent.
+
+ Note that this constructor is invoked automatically by the
+ Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
+ explicitly.
+*/
+QQmlExtensionPlugin::QQmlExtensionPlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+/*!
+ \internal
+ */
+QQmlExtensionPlugin::~QQmlExtensionPlugin()
+{
+}
+
+/*!
+ \fn void QQmlExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
+
+ Initializes the extension from the \a uri using the \a engine. Here an application
+ plugin might, for example, expose some data or objects to QML,
+ as context properties on the engine's root context.
+*/
+
+void QQmlExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
+{
+ Q_UNUSED(engine);
+ Q_UNUSED(uri);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h
new file mode 100644
index 0000000000..91a9e95869
--- /dev/null
+++ b/src/qml/qml/qqmlextensionplugin.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLEXTENSIONPLUGIN_H
+#define QQMLEXTENSIONPLUGIN_H
+
+#include <QtCore/qplugin.h>
+
+#include <QtQml/qqmlextensioninterface.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlEngine;
+
+class Q_QML_EXPORT QQmlExtensionPlugin : public QObject,
+ public QQmlExtensionInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlExtensionInterface)
+ Q_INTERFACES(QQmlTypesExtensionInterface)
+public:
+ explicit QQmlExtensionPlugin(QObject *parent = 0);
+ ~QQmlExtensionPlugin();
+
+ virtual void registerTypes(const char *uri) = 0;
+ virtual void initializeEngine(QQmlEngine *engine, const char *uri);
+
+private:
+ Q_DISABLE_COPY(QQmlExtensionPlugin)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLEXTENSIONPLUGIN_H
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h
new file mode 100644
index 0000000000..c41b823e60
--- /dev/null
+++ b/src/qml/qml/qqmlglobal_p.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLGLOBAL_H
+#define QQMLGLOBAL_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/QObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+#define DEFINE_BOOL_CONFIG_OPTION(name, var) \
+ static bool name() \
+ { \
+ static enum { Yes, No, Unknown } status = Unknown; \
+ if (status == Unknown) { \
+ QByteArray v = qgetenv(#var); \
+ bool value = !v.isEmpty() && v != "0" && v != "false"; \
+ if (value) status = Yes; \
+ else status = No; \
+ } \
+ return status == Yes; \
+ }
+
+#define FAST_CONNECT(Sender, Signal, Receiver, Method) \
+{ \
+ QObject *sender = (Sender); \
+ QObject *receiver = (Receiver); \
+ const char *signal = (Signal); \
+ const char *method = (Method); \
+ static int signalIdx = -1; \
+ static int methodIdx = -1; \
+ if (signalIdx < 0) { \
+ if (((int)(*signal) - '0') == QSIGNAL_CODE) \
+ signalIdx = sender->metaObject()->indexOfSignal(signal+1); \
+ else \
+ qWarning("FAST_CONNECT: Invalid signal %s. Please make sure you are using the SIGNAL macro.", signal); \
+ } \
+ if (methodIdx < 0) { \
+ int code = ((int)(*method) - '0'); \
+ if (code == QSLOT_CODE) \
+ methodIdx = receiver->metaObject()->indexOfSlot(method+1); \
+ else if (code == QSIGNAL_CODE) \
+ methodIdx = receiver->metaObject()->indexOfSignal(method+1); \
+ else \
+ qWarning("FAST_CONNECT: Invalid method %s. Please make sure you are using the SIGNAL or SLOT macro.", method); \
+ } \
+ QMetaObject::connect(sender, signalIdx, receiver, methodIdx, Qt::DirectConnection); \
+}
+
+struct QQmlGraphics_DerivedObject : public QObject
+{
+ void setParent_noEvent(QObject *parent) {
+ bool sce = d_ptr->sendChildEvents;
+ d_ptr->sendChildEvents = false;
+ setParent(parent);
+ d_ptr->sendChildEvents = sce;
+ }
+};
+
+/*!
+ Returns true if the case of \a fileName is equivalent to the file case of
+ \a fileName on disk, and false otherwise.
+
+ This is used to ensure that the behavior of QML on a case-insensitive file
+ system is the same as on a case-sensitive file system. This function
+ performs a "best effort" attempt to determine the real case of the file.
+ It may have false positives (say the case is correct when it isn't), but it
+ should never have a false negative (say the case is incorrect when it is
+ correct).
+*/
+bool QQml_isFileCaseCorrect(const QString &fileName);
+
+/*!
+ Makes the \a object a child of \a parent. Note that when using this method,
+ neither \a parent nor the object's previous parent (if it had one) will
+ receive ChildRemoved or ChildAdded events.
+*/
+inline void QQml_setParent_noEvent(QObject *object, QObject *parent)
+{
+ static_cast<QQmlGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLGLOBAL_H
diff --git a/src/qml/qml/qqmlguard_p.h b/src/qml/qml/qqmlguard_p.h
new file mode 100644
index 0000000000..b4e7408fae
--- /dev/null
+++ b/src/qml/qml/qqmlguard_p.h
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLGUARD_P_H
+#define QQMLGUARD_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. 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>
+#include <private/qqmldata_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlGuardImpl
+{
+public:
+ inline QQmlGuardImpl();
+ inline QQmlGuardImpl(QObject *);
+ inline QQmlGuardImpl(const QQmlGuardImpl &);
+ inline ~QQmlGuardImpl();
+
+ QObject *o;
+ QQmlGuardImpl *next;
+ QQmlGuardImpl **prev;
+
+ inline void addGuard();
+ inline void remGuard();
+};
+
+class QObject;
+template<class T>
+class QQmlGuard : private QQmlGuardImpl
+{
+ friend class QQmlData;
+public:
+ inline QQmlGuard();
+ inline QQmlGuard(T *);
+ inline QQmlGuard(const QQmlGuard<T> &);
+ inline virtual ~QQmlGuard();
+
+ inline QQmlGuard<T> &operator=(const QQmlGuard<T> &o);
+ inline QQmlGuard<T> &operator=(T *);
+
+ inline T *object() const;
+ inline void setObject(T *g);
+
+ inline bool isNull() const
+ { return !o; }
+
+ inline T* operator->() const
+ { return static_cast<T*>(const_cast<QObject*>(o)); }
+ inline T& operator*() const
+ { return *static_cast<T*>(const_cast<QObject*>(o)); }
+ inline operator T*() const
+ { return static_cast<T*>(const_cast<QObject*>(o)); }
+ inline T* data() const
+ { return static_cast<T*>(const_cast<QObject*>(o)); }
+
+protected:
+ virtual void objectDestroyed(T *) {}
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlGuard<QObject>)
+
+QT_BEGIN_NAMESPACE
+
+QQmlGuardImpl::QQmlGuardImpl()
+: o(0), next(0), prev(0)
+{
+}
+
+QQmlGuardImpl::QQmlGuardImpl(QObject *g)
+: o(g), next(0), prev(0)
+{
+ if (o) addGuard();
+}
+
+QQmlGuardImpl::QQmlGuardImpl(const QQmlGuardImpl &g)
+: o(g.o), next(0), prev(0)
+{
+ if (o) addGuard();
+}
+
+QQmlGuardImpl::~QQmlGuardImpl()
+{
+ if (prev) remGuard();
+ o = 0;
+}
+
+void QQmlGuardImpl::addGuard()
+{
+ Q_ASSERT(!prev);
+
+ if (QObjectPrivate::get(o)->wasDeleted)
+ return;
+
+ QQmlData *data = QQmlData::get(o, true);
+ next = data->guards;
+ if (next) next->prev = &next;
+ data->guards = this;
+ prev = &data->guards;
+}
+
+void QQmlGuardImpl::remGuard()
+{
+ Q_ASSERT(prev);
+
+ if (next) next->prev = prev;
+ *prev = next;
+ next = 0;
+ prev = 0;
+}
+
+template<class T>
+QQmlGuard<T>::QQmlGuard()
+{
+}
+
+template<class T>
+QQmlGuard<T>::QQmlGuard(T *g)
+: QQmlGuardImpl(g)
+{
+}
+
+template<class T>
+QQmlGuard<T>::QQmlGuard(const QQmlGuard<T> &g)
+: QQmlGuardImpl(g)
+{
+}
+
+template<class T>
+QQmlGuard<T>::~QQmlGuard()
+{
+}
+
+template<class T>
+QQmlGuard<T> &QQmlGuard<T>::operator=(const QQmlGuard<T> &g)
+{
+ setObject(g.object());
+ return *this;
+}
+
+template<class T>
+QQmlGuard<T> &QQmlGuard<T>::operator=(T *g)
+{
+ setObject(g);
+ return *this;
+}
+
+template<class T>
+T *QQmlGuard<T>::object() const
+{
+ return static_cast<T *>(o);
+};
+
+template<class T>
+void QQmlGuard<T>::setObject(T *g)
+{
+ if (g != o) {
+ if (prev) remGuard();
+ o = g;
+ if (o) addGuard();
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLGUARD_P_H
diff --git a/src/qml/qml/qqmlimageprovider.cpp b/src/qml/qml/qqmlimageprovider.cpp
new file mode 100644
index 0000000000..863093033a
--- /dev/null
+++ b/src/qml/qml/qqmlimageprovider.cpp
@@ -0,0 +1,334 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlimageprovider.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQmlImageProviderPrivate
+{
+public:
+ QQmlImageProvider::ImageType type;
+};
+
+/*!
+ \class QQuickTextureFactory
+ \since 5.0
+ \brief The QQuickTextureFactory class provides an interface for loading custom textures from QML.
+
+ The purpose of the texture factory is to provide a placeholder for a image
+ data that can be converted into an OpenGL texture.
+
+ Creating a texture directly is not possible as there is rarely an OpenGL context
+ available in the thread that is responsible for loading the image data.
+ */
+
+QQuickTextureFactory::QQuickTextureFactory()
+{
+}
+
+QQuickTextureFactory::~QQuickTextureFactory()
+{
+}
+
+
+
+/*!
+ \fn QSGTexture *QQuickTextureFactory::createTexture() const
+
+ This function is called on the scene graph rendering thread to create a QSGTexture
+ instance from the factory.
+
+ QML will internally cache the returned texture as needed. Each call to this
+ function should return a unique instance.
+
+ The OpenGL context used for rendering is bound when this function is called.
+ */
+
+/*!
+ \fn QSize QQuickTextureFactory::textureSize() const
+
+ Returns the size of the texture. This function will be called from arbitrary threads
+ and should not rely on an OpenGL context bound.
+ */
+
+
+/*!
+ \class QQmlImageProvider
+ \since 4.7
+ \brief The QQmlImageProvider class provides an interface for supporting pixmaps and threaded image requests in QML.
+
+ QQmlImageProvider is used to provide advanced image loading features
+ in QML applications. It allows images in QML to be:
+
+ \list
+ \o Loaded using QPixmaps rather than actual image files
+ \o Loaded asynchronously in a separate thread, if imageType() is \l{QQmlImageProvider::ImageType}{ImageType::Image}
+ \endlist
+
+ To specify that an image should be loaded by an image provider, use the
+ \bold {"image:"} scheme for the URL source of the image, followed by the
+ identifiers of the image provider and the requested image. For example:
+
+ \qml
+ Image { source: "image://myimageprovider/image.png" }
+ \endqml
+
+ This specifies that the image should be loaded by the image provider named
+ "myimageprovider", and the image to be loaded is named "image.png". The QML engine
+ invokes the appropriate image provider according to the providers that have
+ been registered through QQmlEngine::addImageProvider().
+
+ Note that the identifiers are case-insensitive, but the rest of the URL will be passed on with
+ preserved case. For example, the below snippet would still specify that the image is loaded by the
+ image provider named "myimageprovider", but it would request a different image than the above snippet
+ ("Image.png" instead of "image.png").
+ \qml
+ Image { source: "image://MyImageProvider/Image.png" }
+ \endqml
+
+ If you want the rest of the URL to be case insensitive, you will have to take care
+ of that yourself inside your image provider.
+
+ \section2 An example
+
+ Here are two images. Their \c source values indicate they should be loaded by
+ an image provider named "colors", and the images to be loaded are "yellow"
+ and "red", respectively:
+
+ \snippet examples/declarative/cppextensions/imageprovider/imageprovider-example.qml 0
+
+ When these images are loaded by QML, it looks for a matching image provider
+ and calls its requestImage() or requestPixmap() method (depending on its
+ imageType()) to load the image. The method is called with the \c id
+ parameter set to "yellow" for the first image, and "red" for the second.
+
+ Here is an image provider implementation that can load the images
+ requested by the above QML. This implementation dynamically
+ generates QPixmap images that are filled with the requested color:
+
+ \snippet examples/declarative/cppextensions/imageprovider/imageprovider.cpp 0
+ \codeline
+ \snippet examples/declarative/cppextensions/imageprovider/imageprovider.cpp 1
+
+ To make this provider accessible to QML, it is registered with the QML engine
+ with a "colors" identifier:
+
+ \code
+ int main(int argc, char *argv[])
+ {
+ ...
+
+ QQmlEngine engine;
+ engine->addImageProvider(QLatin1String("colors"), new ColorPixmapProvider);
+
+ ...
+ }
+ \endcode
+
+ Now the images can be successfully loaded in QML:
+
+ \image imageprovider.png
+
+ A complete example is available in Qt's
+ \l {declarative/cppextensions/imageprovider}{examples/declarative/cppextensions/imageprovider}
+ directory. Note the example registers the provider via a \l{QQmlExtensionPlugin}{plugin}
+ instead of registering it in the application \c main() function as shown above.
+
+
+ \section2 Asynchronous image loading
+
+ Image providers that support QImage loading automatically include support
+ for asychronous loading of images. To enable asynchronous loading for an
+ image source, set the \c asynchronous property to \c true for the relevant
+ \l Image, \l BorderImage or \l AnimatedImage object. When this is enabled,
+ the image request to the provider is run in a low priority thread,
+ allowing image loading to be executed in the background, and reducing the
+ performance impact on the user interface.
+
+ Asynchronous loading is not supported for image providers that provide
+ QPixmap rather than QImage values, as pixmaps can only be created in the
+ main thread. In this case, if \l {Image::}{asynchronous} is set to
+ \c true, the value is ignored and the image is loaded
+ synchronously.
+
+
+ \section2 Image caching
+
+ Images returned by a QQmlImageProvider are automatically cached,
+ similar to any image loaded by the QML engine. When an image with a
+ "image://" prefix is loaded from cache, requestImage() and requestPixmap()
+ will not be called for the relevant image provider. If an image should always
+ be fetched from the image provider, and should not be cached at all, set the
+ \c cache property to \c false for the relevant \l Image, \l BorderImage or
+ \l AnimatedImage object.
+
+ \sa QQmlEngine::addImageProvider()
+*/
+
+/*!
+ \enum QQmlImageProvider::ImageType
+
+ Defines the type of image supported by this image provider.
+
+ \value Image The Image Provider provides QImage images. The
+ requestImage() method will be called for all image requests.
+ \value Pixmap The Image Provider provides QPixmap images. The
+ requestPixmap() method will be called for all image requests.
+ \value Texture The Image Provider provides QSGTextureProvider based images.
+ The requestTexture() method will be called for all image requests. \omitvalue
+*/
+
+/*!
+ Creates an image provider that will provide images of the given \a type.
+*/
+QQmlImageProvider::QQmlImageProvider(ImageType type)
+ : d(new QQmlImageProviderPrivate)
+{
+ d->type = type;
+}
+
+/*!
+ Destroys the QQmlImageProvider
+
+ \note The destructor of your derived class need to be thread safe.
+*/
+QQmlImageProvider::~QQmlImageProvider()
+{
+ delete d;
+}
+
+/*!
+ Returns the image type supported by this provider.
+*/
+QQmlImageProvider::ImageType QQmlImageProvider::imageType() const
+{
+ return d->type;
+}
+
+/*!
+ Implement this method to return the image with \a id. The default
+ implementation returns an empty image.
+
+ The \a id is the requested image source, with the "image:" scheme and
+ provider identifier removed. For example, if the image \l{Image::}{source}
+ was "image://myprovider/icons/home", the given \a id would be "icons/home".
+
+ The \a requestedSize corresponds to the \l {Image::sourceSize} requested by
+ an Image element. If \a requestedSize is a valid size, the image
+ returned should be of that size.
+
+ In all cases, \a size must be set to the original size of the image. This
+ is used to set the \l {Item::}{width} and \l {Item::}{height} of the
+ relevant \l Image if these values have not been set explicitly.
+
+ \note this method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+*/
+QImage QQmlImageProvider::requestImage(const QString &id, QSize *size, const QSize& requestedSize)
+{
+ Q_UNUSED(id);
+ Q_UNUSED(size);
+ Q_UNUSED(requestedSize);
+ if (d->type == Image)
+ qWarning("ImageProvider supports Image type but has not implemented requestImage()");
+ return QImage();
+}
+
+/*!
+ Implement this method to return the pixmap with \a id. The default
+ implementation returns an empty pixmap.
+
+ The \a id is the requested image source, with the "image:" scheme and
+ provider identifier removed. For example, if the image \l{Image::}{source}
+ was "image://myprovider/icons/home", the given \a id would be "icons/home".
+
+ The \a requestedSize corresponds to the \l {Image::sourceSize} requested by
+ an Image element. If \a requestedSize is a valid size, the image
+ returned should be of that size.
+
+ In all cases, \a size must be set to the original size of the image. This
+ is used to set the \l {Item::}{width} and \l {Item::}{height} of the
+ relevant \l Image if these values have not been set explicitly.
+*/
+QPixmap QQmlImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
+{
+ Q_UNUSED(id);
+ Q_UNUSED(size);
+ Q_UNUSED(requestedSize);
+ if (d->type == Pixmap)
+ qWarning("ImageProvider supports Pixmap type but has not implemented requestPixmap()");
+ return QPixmap();
+}
+
+
+/*!
+ Implement this method to return the texture with \a id. The default
+ implementation returns 0.
+
+ The \a id is the requested image source, with the "image:" scheme and
+ provider identifier removed. For example, if the image \l{Image::}{source}
+ was "image://myprovider/icons/home", the given \a id would be "icons/home".
+
+ The \a requestedSize corresponds to the \l {Image::sourceSize} requested by
+ an Image element. If \a requestedSize is a valid size, the image
+ returned should be of that size.
+
+ In all cases, \a size must be set to the original size of the image. This
+ is used to set the \l {Item::}{width} and \l {Item::}{height} of the
+ relevant \l Image if these values have not been set explicitly.
+
+ \note this method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+*/
+
+QQuickTextureFactory *QQmlImageProvider::requestTexture(const QString &id, QSize *size, const QSize &requestedSize)
+{
+ Q_UNUSED(id);
+ Q_UNUSED(size);
+ Q_UNUSED(requestedSize);
+ if (d->type == Texture)
+ qWarning("ImageProvider supports Texture type but has not implemented requestTexture()");
+ return 0;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/qqmlimageprovider.h b/src/qml/qml/qqmlimageprovider.h
new file mode 100644
index 0000000000..fe06925123
--- /dev/null
+++ b/src/qml/qml/qqmlimageprovider.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLIMAGEPROVIDER_H
+#define QQMLIMAGEPROVIDER_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtGui/qimage.h>
+#include <QtGui/qpixmap.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlImageProviderPrivate;
+class QSGTexture;
+class QQuickCanvas;
+
+class Q_QML_EXPORT QQuickTextureFactory : public QObject
+{
+public:
+ QQuickTextureFactory();
+ virtual ~QQuickTextureFactory();
+
+ virtual QSGTexture *createTexture(QQuickCanvas *canvas) const = 0;
+ virtual QSize textureSize() const = 0;
+ virtual int textureByteCount() const = 0;
+};
+
+class Q_QML_EXPORT QQmlImageProvider
+{
+public:
+ enum ImageType {
+ Image,
+ Pixmap,
+ Texture,
+ Invalid
+ };
+
+ QQmlImageProvider(ImageType type);
+ virtual ~QQmlImageProvider();
+
+ ImageType imageType() const;
+
+ virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize);
+ virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize);
+ virtual QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize);
+
+private:
+ QQmlImageProviderPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLIMAGEPROVIDER
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
new file mode 100644
index 0000000000..6e74536fa3
--- /dev/null
+++ b/src/qml/qml/qqmlimport.cpp
@@ -0,0 +1,1183 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlimport_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qpluginloader.h>
+#include <QtCore/qlibraryinfo.h>
+#include <QtQml/qqmlextensioninterface.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmltypenamecache_p.h>
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
+DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
+
+static bool greaterThan(const QString &s1, const QString &s2)
+{
+ return s1 > s2;
+}
+
+QString resolveLocalUrl(const QString &url, const QString &relative)
+{
+ if (relative.contains(QLatin1Char(':'))) {
+ // contains a host name
+ return QUrl(url).resolved(QUrl(relative)).toString();
+ } else if (relative.isEmpty()) {
+ return url;
+ } else if (relative.at(0) == QLatin1Char('/') || !url.contains(QLatin1Char('/'))) {
+ return relative;
+ } else {
+ if (relative == QLatin1String("."))
+ return url.left(url.lastIndexOf(QLatin1Char('/')) + 1);
+ else if (relative.startsWith(QLatin1String("./")))
+ return url.left(url.lastIndexOf(QLatin1Char('/')) + 1) + relative.mid(2);
+ return url.left(url.lastIndexOf(QLatin1Char('/')) + 1) + relative;
+ }
+}
+
+
+
+typedef QMap<QString, QString> StringStringMap;
+Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri
+
+class QQmlImportedNamespace
+{
+public:
+ struct Data {
+ QString uri;
+ QString url;
+ int majversion;
+ int minversion;
+ bool isLibrary;
+ QQmlDirComponents qmlDirComponents;
+ QQmlDirScripts qmlDirScripts;
+ };
+ QList<Data> imports;
+
+
+ bool find_helper(QQmlTypeLoader *typeLoader, const Data &data, const QString& type, int *vmajor, int *vminor,
+ QQmlType** type_return, QString* url_return,
+ QString *base = 0, bool *typeRecursionDetected = 0);
+ bool find(QQmlTypeLoader *typeLoader, const QString& type, int *vmajor, int *vminor, QQmlType** type_return,
+ QString* url_return, QString *base = 0, QList<QQmlError> *errors = 0);
+};
+
+class QQmlImportsPrivate {
+public:
+ QQmlImportsPrivate(QQmlTypeLoader *loader);
+ ~QQmlImportsPrivate();
+
+ bool importExtension(const QString &absoluteFilePath, const QString &uri,
+ QQmlImportDatabase *database, QQmlDirComponents* components,
+ QQmlDirScripts *scripts,
+ QList<QQmlError> *errors);
+
+ QString resolvedUri(const QString &dir_arg, QQmlImportDatabase *database);
+ bool add(const QQmlDirComponents &qmldircomponentsnetwork,
+ const QString& uri_arg, const QString& prefix,
+ int vmaj, int vmin, QQmlScript::Import::Type importType,
+ QQmlImportDatabase *database, QList<QQmlError> *errors);
+ bool find(const QString& type, int *vmajor, int *vminor,
+ QQmlType** type_return, QString* url_return, QList<QQmlError> *errors);
+
+ QQmlImportedNamespace *findNamespace(const QString& type);
+
+ QUrl baseUrl;
+ QString base;
+ int ref;
+
+ QSet<QString> qmlDirFilesForWhichPluginsHaveBeenLoaded;
+ QQmlImportedNamespace unqualifiedset;
+ QHash<QString,QQmlImportedNamespace* > set;
+ QQmlTypeLoader *typeLoader;
+};
+
+/*!
+\class QQmlImports
+\brief The QQmlImports class encapsulates one QML document's import statements.
+\internal
+*/
+QQmlImports::QQmlImports(const QQmlImports &copy)
+: d(copy.d)
+{
+ ++d->ref;
+}
+
+QQmlImports &
+QQmlImports::operator =(const QQmlImports &copy)
+{
+ ++copy.d->ref;
+ if (--d->ref == 0)
+ delete d;
+ d = copy.d;
+ return *this;
+}
+
+QQmlImports::QQmlImports(QQmlTypeLoader *typeLoader)
+ : d(new QQmlImportsPrivate(typeLoader))
+{
+}
+
+QQmlImports::~QQmlImports()
+{
+ if (--d->ref == 0)
+ delete d;
+}
+
+/*!
+ Sets the base URL to be used for all relative file imports added.
+*/
+void QQmlImports::setBaseUrl(const QUrl& url, const QString &urlString)
+{
+ d->baseUrl = url;
+
+ if (urlString.isEmpty()) {
+ d->base = url.toString();
+ } else {
+ //Q_ASSERT(url.toString() == urlString);
+ d->base = urlString;
+ }
+}
+
+/*!
+ Returns the base URL to be used for all relative file imports added.
+*/
+QUrl QQmlImports::baseUrl() const
+{
+ return d->baseUrl;
+}
+
+void QQmlImports::populateCache(QQmlTypeNameCache *cache, QQmlEngine *engine) const
+{
+ const QQmlImportedNamespace &set = d->unqualifiedset;
+
+ for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ const QQmlImportedNamespace::Data &data = set.imports.at(ii);
+ QQmlTypeModule *module = QQmlMetaType::typeModule(data.uri, data.majversion);
+ if (module)
+ cache->m_anonymousImports.append(QQmlTypeModuleVersion(module, data.minversion));
+ }
+
+ for (QHash<QString,QQmlImportedNamespace* >::ConstIterator iter = d->set.begin();
+ iter != d->set.end();
+ ++iter) {
+
+ const QQmlImportedNamespace &set = *iter.value();
+ for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ const QQmlImportedNamespace::Data &data = set.imports.at(ii);
+ QQmlTypeModule *module = QQmlMetaType::typeModule(data.uri, data.majversion);
+ if (module) {
+ QQmlTypeNameCache::Import &import = cache->m_namedImports[iter.key()];
+ import.modules.append(QQmlTypeModuleVersion(module, data.minversion));
+ }
+
+ QQmlMetaType::ModuleApi moduleApi = QQmlMetaType::moduleApi(data.uri, data.majversion, data.minversion);
+ if (moduleApi.script || moduleApi.qobject) {
+ QQmlTypeNameCache::Import &import = cache->m_namedImports[iter.key()];
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+ import.moduleApi = ep->moduleApiInstance(moduleApi);
+ }
+ }
+ }
+}
+
+QList<QQmlImports::ScriptReference> QQmlImports::resolvedScripts() const
+{
+ QList<QQmlImports::ScriptReference> scripts;
+
+ const QQmlImportedNamespace &set = d->unqualifiedset;
+
+ for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ const QQmlImportedNamespace::Data &data = set.imports.at(ii);
+
+ foreach (const QQmlDirParser::Script &script, data.qmlDirScripts) {
+ ScriptReference ref;
+ ref.nameSpace = script.nameSpace;
+ ref.location = QUrl(data.url).resolved(QUrl(script.fileName));
+ scripts.append(ref);
+ }
+ }
+
+ for (QHash<QString,QQmlImportedNamespace* >::ConstIterator iter = d->set.constBegin();
+ iter != d->set.constEnd();
+ ++iter) {
+ const QQmlImportedNamespace &set = *iter.value();
+
+ for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ const QQmlImportedNamespace::Data &data = set.imports.at(ii);
+
+ foreach (const QQmlDirParser::Script &script, data.qmlDirScripts) {
+ ScriptReference ref;
+ ref.nameSpace = script.nameSpace;
+ ref.qualifier = iter.key();
+ ref.location = QUrl(data.url).resolved(QUrl(script.fileName));
+ scripts.append(ref);
+ }
+ }
+ }
+
+ return scripts;
+}
+
+/*!
+ \internal
+
+ The given (namespace qualified) \a type is resolved to either
+ \list
+ \o a QQmlImportedNamespace stored at \a ns_return,
+ \o a QQmlType stored at \a type_return, or
+ \o a component located at \a url_return.
+ \endlist
+
+ If any return pointer is 0, the corresponding search is not done.
+
+ \sa addImport()
+*/
+bool QQmlImports::resolveType(const QString& type,
+ QQmlType** type_return, QString* url_return, int *vmaj, int *vmin,
+ QQmlImportedNamespace** ns_return, QList<QQmlError> *errors) const
+{
+ QQmlImportedNamespace* ns = d->findNamespace(type);
+ if (ns) {
+ if (ns_return)
+ *ns_return = ns;
+ return true;
+ }
+ if (type_return || url_return) {
+ if (d->find(type,vmaj,vmin,type_return,url_return, errors)) {
+ if (qmlImportTrace()) {
+ if (type_return && *type_return && url_return && !url_return->isEmpty())
+ qDebug().nospace() << "QQmlImports(" << qPrintable(baseUrl().toString()) << ")" << "::resolveType: "
+ << type << " => " << (*type_return)->typeName() << " " << *url_return;
+ if (type_return && *type_return)
+ qDebug().nospace() << "QQmlImports(" << qPrintable(baseUrl().toString()) << ")" << "::resolveType: "
+ << type << " => " << (*type_return)->typeName();
+ if (url_return && !url_return->isEmpty())
+ qDebug().nospace() << "QQmlImports(" << qPrintable(baseUrl().toString()) << ")" << "::resolveType: "
+ << type << " => " << *url_return;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+/*!
+ \internal
+
+ Searching \e only in the namespace \a ns (previously returned in a call to
+ resolveType(), \a type is found and returned to either
+ a QQmlType stored at \a type_return, or
+ a component located at \a url_return.
+
+ If either return pointer is 0, the corresponding search is not done.
+*/
+bool QQmlImports::resolveType(QQmlImportedNamespace* ns, const QString& type,
+ QQmlType** type_return, QString* url_return,
+ int *vmaj, int *vmin) const
+{
+ return ns->find(d->typeLoader,type,vmaj,vmin,type_return,url_return);
+}
+
+bool QQmlImportedNamespace::find_helper(QQmlTypeLoader *typeLoader, const Data &data, const QString& type, int *vmajor, int *vminor,
+ QQmlType** type_return, QString* url_return,
+ QString *base, bool *typeRecursionDetected)
+{
+ int vmaj = data.majversion;
+ int vmin = data.minversion;
+
+ if (vmaj >= 0 && vmin >= 0) {
+ QString qt = data.uri + QLatin1Char('/') + type;
+ QQmlType *t = QQmlMetaType::qmlType(qt,vmaj,vmin);
+ if (t) {
+ if (vmajor) *vmajor = vmaj;
+ if (vminor) *vminor = vmin;
+ if (type_return)
+ *type_return = t;
+ return true;
+ }
+ }
+
+ const QQmlDirComponents &qmldircomponents = data.qmlDirComponents;
+ bool typeWasDeclaredInQmldir = false;
+ if (!qmldircomponents.isEmpty()) {
+ foreach (const QQmlDirParser::Component &c, qmldircomponents) {
+ if (c.typeName == type) {
+ typeWasDeclaredInQmldir = true;
+ // importing version -1 means import ALL versions
+ if ((vmaj == -1) || (c.majorVersion == vmaj && vmin >= c.minorVersion)) {
+ QString url(data.url + type + QLatin1String(".qml"));
+ QString candidate = resolveLocalUrl(url, c.fileName);
+ if (c.internal && base) {
+ if (resolveLocalUrl(*base, c.fileName) != candidate)
+ continue; // failed attempt to access an internal type
+ }
+ if (base && *base == candidate) {
+ if (typeRecursionDetected)
+ *typeRecursionDetected = true;
+ continue; // no recursion
+ }
+ if (url_return)
+ *url_return = candidate;
+ return true;
+ }
+ }
+ }
+ }
+
+ if (!typeWasDeclaredInQmldir && !data.isLibrary) {
+ // XXX search non-files too! (eg. zip files, see QT-524)
+ QString url(data.url + type + QLatin1String(".qml"));
+ QString file = QQmlEnginePrivate::urlToLocalFileOrQrc(url);
+ if (!typeLoader->absoluteFilePath(file).isEmpty()) {
+ if (base && *base == url) { // no recursion
+ if (typeRecursionDetected)
+ *typeRecursionDetected = true;
+ } else {
+ if (url_return)
+ *url_return = url;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+QQmlImportsPrivate::QQmlImportsPrivate(QQmlTypeLoader *loader)
+ : ref(1), typeLoader(loader)
+{
+}
+
+QQmlImportsPrivate::~QQmlImportsPrivate()
+{
+ foreach (QQmlImportedNamespace* s, set.values())
+ delete s;
+}
+
+bool QQmlImportsPrivate::importExtension(const QString &absoluteFilePath, const QString &uri,
+ QQmlImportDatabase *database,
+ QQmlDirComponents* components,
+ QQmlDirScripts* scripts,
+ QList<QQmlError> *errors)
+{
+ const QQmlDirParser *qmldirParser = typeLoader->qmlDirParser(absoluteFilePath);
+ if (qmldirParser->hasError()) {
+ if (errors) {
+ const QList<QQmlError> qmldirErrors = qmldirParser->errors(uri);
+ for (int i = 0; i < qmldirErrors.size(); ++i)
+ errors->prepend(qmldirErrors.at(i));
+ }
+ return false;
+ }
+
+ if (qmlImportTrace())
+ qDebug().nospace() << "QQmlImports(" << qPrintable(base) << "::importExtension: "
+ << "loaded " << absoluteFilePath;
+
+ if (! qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(absoluteFilePath)) {
+ qmlDirFilesForWhichPluginsHaveBeenLoaded.insert(absoluteFilePath);
+
+ QString qmldirPath = absoluteFilePath;
+ int slash = absoluteFilePath.lastIndexOf(QLatin1Char('/'));
+ if (slash > 0)
+ qmldirPath.truncate(slash);
+ foreach (const QQmlDirParser::Plugin &plugin, qmldirParser->plugins()) {
+
+ QString resolvedFilePath = database->resolvePlugin(typeLoader, qmldirPath, plugin.path, plugin.name);
+ if (!resolvedFilePath.isEmpty()) {
+ if (!database->importPlugin(resolvedFilePath, uri, errors)) {
+ if (errors) {
+ // XXX TODO: should we leave the import plugin error alone?
+ // Here, we pop it off the top and coalesce it into this error's message.
+ // The reason is that the lower level may add url and line/column numbering information.
+ QQmlError poppedError = errors->takeFirst();
+ QQmlError error;
+ error.setDescription(QQmlImportDatabase::tr("plugin cannot be loaded for module \"%1\": %2").arg(uri).arg(poppedError.description()));
+ error.setUrl(QUrl::fromLocalFile(absoluteFilePath));
+ errors->prepend(error);
+ }
+ return false;
+ }
+ } else {
+ if (errors) {
+ QQmlError error;
+ error.setDescription(QQmlImportDatabase::tr("module \"%1\" plugin \"%2\" not found").arg(uri).arg(plugin.name));
+ error.setUrl(QUrl::fromLocalFile(absoluteFilePath));
+ errors->prepend(error);
+ }
+ return false;
+ }
+ }
+ }
+
+ if (components)
+ *components = qmldirParser->components();
+ if (scripts)
+ *scripts = qmldirParser->scripts();
+
+ return true;
+}
+
+QString QQmlImportsPrivate::resolvedUri(const QString &dir_arg, QQmlImportDatabase *database)
+{
+ QString dir = dir_arg;
+ if (dir.endsWith(QLatin1Char('/')) || dir.endsWith(QLatin1Char('\\')))
+ dir.chop(1);
+
+ QStringList paths = database->fileImportPath;
+ qSort(paths.begin(), paths.end(), greaterThan); // Ensure subdirs preceed their parents.
+
+ QString stableRelativePath = dir;
+ foreach(const QString &path, paths) {
+ if (dir.startsWith(path)) {
+ stableRelativePath = dir.mid(path.length()+1);
+ break;
+ }
+ }
+
+ stableRelativePath.replace(QLatin1Char('\\'), QLatin1Char('/'));
+
+ // remove optional versioning in dot notation from uri
+ int lastSlash = stableRelativePath.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash >= 0) {
+ int versionDot = stableRelativePath.indexOf(QLatin1Char('.'), lastSlash);
+ if (versionDot >= 0)
+ stableRelativePath = stableRelativePath.left(versionDot);
+ }
+
+ stableRelativePath.replace(QLatin1Char('/'), QLatin1Char('.'));
+ return stableRelativePath;
+}
+
+bool QQmlImportsPrivate::add(const QQmlDirComponents &qmldircomponentsnetwork,
+ const QString& uri_arg, const QString& prefix, int vmaj, int vmin,
+ QQmlScript::Import::Type importType,
+ QQmlImportDatabase *database, QList<QQmlError> *errors)
+{
+ static QLatin1String Slash_qmldir("/qmldir");
+ static QLatin1Char Slash('/');
+
+ QQmlDirComponents qmldircomponents = qmldircomponentsnetwork;
+ QQmlDirScripts qmldirscripts;
+ QString uri = uri_arg;
+ QQmlImportedNamespace *s;
+ if (prefix.isEmpty()) {
+ s = &unqualifiedset;
+ } else {
+ s = set.value(prefix);
+ if (!s)
+ set.insert(prefix,(s=new QQmlImportedNamespace));
+ }
+ QString url = uri;
+ bool versionFound = false;
+ if (importType == QQmlScript::Import::Library) {
+
+ Q_ASSERT(vmaj >= 0 && vmin >= 0); // Versions are always specified for libraries
+
+ url.replace(QLatin1Char('.'), Slash);
+ bool found = false;
+ QString dir;
+ QString qmldir;
+
+ // step 1: search for extension with fully encoded version number
+ foreach (const QString &p, database->fileImportPath) {
+ dir = p+Slash+url;
+
+ QFileInfo fi(dir+QString(QLatin1String(".%1.%2")).arg(vmaj).arg(vmin)+QLatin1String("/qmldir"));
+ const QString absoluteFilePath = fi.absoluteFilePath();
+
+ if (fi.isFile()) {
+ found = true;
+
+ const QString absolutePath = fi.absolutePath();
+ if (absolutePath.at(0) == QLatin1Char(':'))
+ url = QLatin1String("qrc://") + absolutePath.mid(1);
+ else
+ url = QUrl::fromLocalFile(fi.absolutePath()).toString();
+ uri = resolvedUri(dir, database);
+ if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, &qmldirscripts, errors))
+ return false;
+ break;
+ }
+ }
+
+ // TODO: Should this search be omitted if found == true?
+
+ // step 2: search for extension with encoded version major
+ foreach (const QString &p, database->fileImportPath) {
+ dir = p+Slash+url;
+
+ QFileInfo fi(dir+QString(QLatin1String(".%1")).arg(vmaj)+QLatin1String("/qmldir"));
+ const QString absoluteFilePath = fi.absoluteFilePath();
+
+ if (fi.isFile()) {
+ found = true;
+
+ const QString absolutePath = fi.absolutePath();
+ if (absolutePath.at(0) == QLatin1Char(':'))
+ url = QLatin1String("qrc://") + absolutePath.mid(1);
+ else
+ url = QUrl::fromLocalFile(fi.absolutePath()).toString();
+ uri = resolvedUri(dir, database);
+ if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, &qmldirscripts, errors))
+ return false;
+ break;
+ }
+ }
+
+ if (!found) {
+ // step 3: search for extension without version number
+
+ foreach (const QString &p, database->fileImportPath) {
+ dir = p+Slash+url;
+ qmldir = dir+Slash_qmldir;
+
+ QString absoluteFilePath = typeLoader->absoluteFilePath(qmldir);
+ if (!absoluteFilePath.isEmpty()) {
+ found = true;
+ QString absolutePath = absoluteFilePath.left(absoluteFilePath.lastIndexOf(Slash)+1);
+ if (absolutePath.at(0) == QLatin1Char(':'))
+ url = QLatin1String("qrc://") + absolutePath.mid(1);
+ else
+ url = QUrl::fromLocalFile(absolutePath).toString();
+ uri = resolvedUri(dir, database);
+ if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, &qmldirscripts, errors))
+ return false;
+ break;
+ }
+ }
+ }
+
+ if (QQmlMetaType::isModule(uri, vmaj, vmin))
+ versionFound = true;
+
+ if (!versionFound && qmldircomponents.isEmpty() && qmldirscripts.isEmpty()) {
+ if (errors) {
+ QQmlError error; // we don't set the url or line or column as these will be set by the loader.
+ if (QQmlMetaType::isAnyModule(uri))
+ error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin));
+ else
+ error.setDescription(QQmlImportDatabase::tr("module \"%1\" is not installed").arg(uri_arg));
+ errors->prepend(error);
+ }
+ return false;
+ }
+ } else {
+ if (importType == QQmlScript::Import::File && qmldircomponents.isEmpty()) {
+ QString importUrl = resolveLocalUrl(base, uri + Slash_qmldir);
+ QString localFileOrQrc = QQmlEnginePrivate::urlToLocalFileOrQrc(importUrl);
+ if (!localFileOrQrc.isEmpty()) {
+ QString dir = QQmlEnginePrivate::urlToLocalFileOrQrc(resolveLocalUrl(base, uri));
+ if (!typeLoader->directoryExists(dir)) {
+ if (errors) {
+ QQmlError error; // we don't set the line or column as these will be set by the loader.
+ error.setDescription(QQmlImportDatabase::tr("\"%1\": no such directory").arg(uri_arg));
+ error.setUrl(QUrl(importUrl));
+ errors->prepend(error);
+ }
+ return false; // local import dirs must exist
+ }
+ uri = resolvedUri(dir, database);
+ if (uri.endsWith(Slash))
+ uri.chop(1);
+ if (!typeLoader->absoluteFilePath(localFileOrQrc).isEmpty()) {
+ if (!importExtension(localFileOrQrc,uri,database,&qmldircomponents,&qmldirscripts,errors))
+ return false;
+ }
+ } else {
+ if (prefix.isEmpty()) {
+ // directory must at least exist for valid import
+ QString localFileOrQrc = QQmlEnginePrivate::urlToLocalFileOrQrc(resolveLocalUrl(base, uri));
+ if (!typeLoader->directoryExists(localFileOrQrc)) {
+ if (errors) {
+ QQmlError error; // we don't set the line or column as these will be set by the loader.
+ if (localFileOrQrc.isEmpty())
+ error.setDescription(QQmlImportDatabase::tr("import \"%1\" has no qmldir and no namespace").arg(uri));
+ else
+ error.setDescription(QQmlImportDatabase::tr("\"%1\": no such directory").arg(uri));
+ error.setUrl(QUrl(importUrl));
+ errors->prepend(error);
+ }
+ return false;
+ }
+ }
+ }
+ }
+
+ url = resolveLocalUrl(base, url);
+ }
+
+ if (!versionFound && (vmaj > -1) && (vmin > -1) && !qmldircomponents.isEmpty()) {
+ int lowest_min = INT_MAX;
+ int highest_min = INT_MIN;
+
+ QList<QQmlDirParser::Component>::const_iterator cend = qmldircomponents.constEnd();
+ for (QList<QQmlDirParser::Component>::const_iterator cit = qmldircomponents.constBegin(); cit != cend; ++cit) {
+ if (cit->majorVersion == vmaj) {
+ lowest_min = qMin(lowest_min, cit->minorVersion);
+ highest_min = qMax(highest_min, cit->minorVersion);
+ }
+ }
+
+ if (lowest_min > vmin || highest_min < vmin) {
+ if (errors) {
+ QQmlError error; // we don't set the url or line or column information, as these will be set by the loader.
+ error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin));
+ errors->prepend(error);
+ }
+ return false;
+ }
+ }
+
+ if (!url.endsWith(Slash))
+ url += Slash;
+
+ QMap<QString, QQmlDirParser::Script> scripts;
+
+ if (!qmldirscripts.isEmpty()) {
+ // Verify that we haven't imported these scripts already
+ QList<QQmlImportedNamespace::Data>::const_iterator end = s->imports.constEnd();
+ for (QList<QQmlImportedNamespace::Data>::const_iterator it = s->imports.constBegin(); it != end; ++it) {
+ if (it->uri == uri) {
+ QQmlError error;
+ error.setDescription(QQmlImportDatabase::tr("\"%1\" is ambiguous. Found in %2 and in %3").arg(uri).arg(url).arg(it->url));
+ errors->prepend(error);
+ return false;
+ }
+ }
+
+ QList<QQmlDirParser::Script>::const_iterator send = qmldirscripts.constEnd();
+ for (QList<QQmlDirParser::Script>::const_iterator sit = qmldirscripts.constBegin(); sit != send; ++sit) {
+ // Only include scripts that match our requested version
+ if (((vmaj == -1) || (sit->majorVersion == vmaj)) &&
+ ((vmin == -1) || (sit->minorVersion <= vmin))) {
+
+ // Load the highest version that matches
+ QMap<QString, QQmlDirParser::Script>::iterator it = scripts.find(sit->nameSpace);
+ if (it == scripts.end() || (it->minorVersion < sit->minorVersion)) {
+ scripts.insert(sit->nameSpace, *sit);
+ }
+ }
+ }
+ }
+
+ QQmlImportedNamespace::Data data;
+ data.uri = uri;
+ data.url = url;
+ data.majversion = vmaj;
+ data.minversion = vmin;
+ data.isLibrary = importType == QQmlScript::Import::Library;
+ data.qmlDirComponents = qmldircomponents;
+ data.qmlDirScripts = scripts.values();
+
+ s->imports.prepend(data);
+
+ return true;
+}
+
+bool QQmlImportsPrivate::find(const QString& type, int *vmajor, int *vminor, QQmlType** type_return,
+ QString* url_return, QList<QQmlError> *errors)
+{
+ QQmlImportedNamespace *s = 0;
+ int slash = type.indexOf(QLatin1Char('/'));
+ if (slash >= 0) {
+ QString namespaceName = type.left(slash);
+ s = set.value(namespaceName);
+ if (!s) {
+ if (errors) {
+ QQmlError error;
+ error.setDescription(QQmlImportDatabase::tr("- %1 is not a namespace").arg(namespaceName));
+ errors->prepend(error);
+ }
+ return false;
+ }
+ int nslash = type.indexOf(QLatin1Char('/'),slash+1);
+ if (nslash > 0) {
+ if (errors) {
+ QQmlError error;
+ error.setDescription(QQmlImportDatabase::tr("- nested namespaces not allowed"));
+ errors->prepend(error);
+ }
+ return false;
+ }
+ } else {
+ s = &unqualifiedset;
+ }
+ QString unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
+ if (s) {
+ if (s->find(typeLoader,unqualifiedtype,vmajor,vminor,type_return,url_return, &base, errors))
+ return true;
+ if (s->imports.count() == 1 && !s->imports.at(0).isLibrary && url_return && s != &unqualifiedset) {
+ // qualified, and only 1 url
+ *url_return = resolveLocalUrl(s->imports.at(0).url, unqualifiedtype + QLatin1String(".qml"));
+ return true;
+ }
+ }
+
+ return false;
+}
+
+QQmlImportedNamespace *QQmlImportsPrivate::findNamespace(const QString& type)
+{
+ return set.value(type);
+}
+
+bool QQmlImportedNamespace::find(QQmlTypeLoader *typeLoader, const QString& type, int *vmajor, int *vminor, QQmlType** type_return,
+ QString* url_return, QString *base, QList<QQmlError> *errors)
+{
+ bool typeRecursionDetected = false;
+ for (int i=0; i<imports.count(); ++i) {
+ if (find_helper(typeLoader, imports.at(i), type, vmajor, vminor, type_return, url_return, base, &typeRecursionDetected)) {
+ if (qmlCheckTypes()) {
+ // check for type clashes
+ for (int j = i+1; j<imports.count(); ++j) {
+ if (find_helper(typeLoader, imports.at(j), type, vmajor, vminor, 0, 0, base)) {
+ if (errors) {
+ QString u1 = imports.at(i).url;
+ QString u2 = imports.at(j).url;
+ if (base) {
+ QString b = *base;
+ int slash = b.lastIndexOf(QLatin1Char('/'));
+ if (slash >= 0) {
+ b = b.left(slash+1);
+ QString l = b.left(slash);
+ if (u1.startsWith(b))
+ u1 = u1.mid(b.count());
+ else if (u1 == l)
+ u1 = QQmlImportDatabase::tr("local directory");
+ if (u2.startsWith(b))
+ u2 = u2.mid(b.count());
+ else if (u2 == l)
+ u2 = QQmlImportDatabase::tr("local directory");
+ }
+ }
+
+ QQmlError error;
+ if (u1 != u2) {
+ error.setDescription(QQmlImportDatabase::tr("is ambiguous. Found in %1 and in %2").arg(u1).arg(u2));
+ } else {
+ error.setDescription(QQmlImportDatabase::tr("is ambiguous. Found in %1 in version %2.%3 and %4.%5")
+ .arg(u1)
+ .arg(imports.at(i).majversion).arg(imports.at(i).minversion)
+ .arg(imports.at(j).majversion).arg(imports.at(j).minversion));
+ }
+ errors->prepend(error);
+ }
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ }
+ if (errors) {
+ QQmlError error;
+ if (typeRecursionDetected)
+ error.setDescription(QQmlImportDatabase::tr("is instantiated recursively"));
+ else
+ error.setDescription(QQmlImportDatabase::tr("is not a type"));
+ errors->prepend(error);
+ }
+ return false;
+}
+
+/*!
+\class QQmlImportDatabase
+\brief The QQmlImportDatabase class manages the QML imports for a QQmlEngine.
+\internal
+*/
+QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
+: engine(e)
+{
+ filePluginPath << QLatin1String(".");
+
+ // Search order is applicationDirPath(), $QML_IMPORT_PATH, QLibraryInfo::ImportsPath
+
+#ifndef QT_NO_SETTINGS
+ QString installImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
+ addImportPath(installImportsPath);
+#endif // QT_NO_SETTINGS
+
+ // env import paths
+ QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
+ if (!envImportPath.isEmpty()) {
+#if defined(Q_OS_WIN)
+ QLatin1Char pathSep(';');
+#else
+ QLatin1Char pathSep(':');
+#endif
+ QStringList paths = QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts);
+ for (int ii = paths.count() - 1; ii >= 0; --ii)
+ addImportPath(paths.at(ii));
+ }
+
+ addImportPath(QCoreApplication::applicationDirPath());
+}
+
+QQmlImportDatabase::~QQmlImportDatabase()
+{
+}
+
+/*!
+ \internal
+
+ Adds information to \a imports such that subsequent calls to resolveType()
+ will resolve types qualified by \a prefix by considering types found at the given \a uri.
+
+ The uri is either a directory (if importType is FileImport), or a URI resolved using paths
+ added via addImportPath() (if importType is LibraryImport).
+
+ The \a prefix may be empty, in which case the import location is considered for
+ unqualified types.
+
+ The base URL must already have been set with Import::setBaseUrl().
+*/
+bool QQmlImports::addImport(QQmlImportDatabase *importDb,
+ const QString& uri, const QString& prefix, int vmaj, int vmin,
+ QQmlScript::Import::Type importType,
+ const QQmlDirComponents &qmldircomponentsnetwork,
+ QList<QQmlError> *errors)
+{
+ if (qmlImportTrace())
+ qDebug().nospace() << "QQmlImports(" << qPrintable(baseUrl().toString()) << ")" << "::addImport: "
+ << uri << " " << vmaj << '.' << vmin << " "
+ << (importType==QQmlScript::Import::Library? "Library" : "File")
+ << " as " << prefix;
+
+ return d->add(qmldircomponentsnetwork, uri, prefix, vmaj, vmin, importType, importDb, errors);
+}
+
+/*!
+ \internal
+
+ Returns the result of the merge of \a baseName with \a path, \a suffixes, and \a prefix.
+ The \a prefix must contain the dot.
+
+ \a qmldirPath is the location of the qmldir file.
+ */
+QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader,
+ const QString &qmldirPath, const QString &qmldirPluginPath,
+ const QString &baseName, const QStringList &suffixes,
+ const QString &prefix)
+{
+ QStringList searchPaths = filePluginPath;
+ bool qmldirPluginPathIsRelative = QDir::isRelativePath(qmldirPluginPath);
+ if (!qmldirPluginPathIsRelative)
+ searchPaths.prepend(qmldirPluginPath);
+
+ foreach (const QString &pluginPath, searchPaths) {
+
+ QString resolvedPath;
+ if (pluginPath == QLatin1String(".")) {
+ if (qmldirPluginPathIsRelative && !qmldirPluginPath.isEmpty() && qmldirPluginPath != QLatin1String("."))
+ resolvedPath = QDir::cleanPath(qmldirPath + QLatin1Char('/') + qmldirPluginPath);
+ else
+ resolvedPath = qmldirPath;
+ } else {
+ if (QDir::isRelativePath(pluginPath))
+ resolvedPath = QDir::cleanPath(qmldirPath + QLatin1Char('/') + pluginPath);
+ else
+ resolvedPath = pluginPath;
+ }
+
+ // hack for resources, should probably go away
+ if (resolvedPath.startsWith(QLatin1Char(':')))
+ resolvedPath = QCoreApplication::applicationDirPath();
+
+ if (!resolvedPath.endsWith(QLatin1Char('/')))
+ resolvedPath += QLatin1Char('/');
+
+ foreach (const QString &suffix, suffixes) {
+ QString pluginFileName = prefix;
+
+ pluginFileName += baseName;
+ pluginFileName += suffix;
+
+ QString absolutePath = typeLoader->absoluteFilePath(resolvedPath + pluginFileName);
+ if (!absolutePath.isEmpty())
+ return absolutePath;
+ }
+ }
+
+ if (qmlImportTrace())
+ qDebug() << "QQmlImportDatabase::resolvePlugin: Could not resolve plugin" << baseName
+ << "in" << qmldirPath;
+
+ return QString();
+}
+
+/*!
+ \internal
+
+ Returns the result of the merge of \a baseName with \a dir and the platform suffix.
+
+ \table
+ \header \i Platform \i Valid suffixes
+ \row \i Windows \i \c .dll
+ \row \i Unix/Linux \i \c .so
+ \row \i AIX \i \c .a
+ \row \i HP-UX \i \c .sl, \c .so (HP-UXi)
+ \row \i Mac OS X \i \c .dylib, \c .bundle, \c .so
+ \endtable
+
+ Version number on unix are ignored.
+*/
+QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader,
+ const QString &qmldirPath, const QString &qmldirPluginPath,
+ const QString &baseName)
+{
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+ return resolvePlugin(typeLoader, qmldirPath, qmldirPluginPath, baseName,
+ QStringList()
+# ifdef QT_DEBUG
+ << QLatin1String("d.dll") // try a qmake-style debug build first
+# endif
+ << QLatin1String(".dll"));
+#else
+
+# if defined(Q_OS_DARWIN)
+
+ return resolvePlugin(typeLoader, qmldirPath, qmldirPluginPath, baseName,
+ QStringList()
+# ifdef QT_DEBUG
+ << QLatin1String("_debug.dylib") // try a qmake-style debug build first
+ << QLatin1String(".dylib")
+# else
+ << QLatin1String(".dylib")
+ << QLatin1String("_debug.dylib") // try a qmake-style debug build after
+# endif
+ << QLatin1String(".so")
+ << QLatin1String(".bundle"),
+ QLatin1String("lib"));
+# else // Generic Unix
+ QStringList validSuffixList;
+
+# if defined(Q_OS_HPUX)
+/*
+ See "HP-UX Linker and Libraries User's Guide", section "Link-time Differences between PA-RISC and IPF":
+ "In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit),
+ the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix."
+ */
+ validSuffixList << QLatin1String(".sl");
+# if defined __ia64
+ validSuffixList << QLatin1String(".so");
+# endif
+# elif defined(Q_OS_AIX)
+ validSuffixList << QLatin1String(".a") << QLatin1String(".so");
+# elif defined(Q_OS_UNIX)
+ validSuffixList << QLatin1String(".so");
+# endif
+
+ // Examples of valid library names:
+ // libfoo.so
+
+ return resolvePlugin(typeLoader, qmldirPath, qmldirPluginPath, baseName, validSuffixList, QLatin1String("lib"));
+# endif
+
+#endif
+}
+
+/*!
+ \internal
+*/
+QStringList QQmlImportDatabase::pluginPathList() const
+{
+ return filePluginPath;
+}
+
+/*!
+ \internal
+*/
+void QQmlImportDatabase::setPluginPathList(const QStringList &paths)
+{
+ filePluginPath = paths;
+}
+
+/*!
+ \internal
+*/
+void QQmlImportDatabase::addPluginPath(const QString& path)
+{
+ if (qmlImportTrace())
+ qDebug().nospace() << "QQmlImportDatabase::addPluginPath: " << path;
+
+ QUrl url = QUrl(path);
+ if (url.isRelative() || url.scheme() == QLatin1String("file")
+ || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
+ QDir dir = QDir(path);
+ filePluginPath.prepend(dir.canonicalPath());
+ } else {
+ filePluginPath.prepend(path);
+ }
+}
+
+/*!
+ \internal
+*/
+void QQmlImportDatabase::addImportPath(const QString& path)
+{
+ if (qmlImportTrace())
+ qDebug().nospace() << "QQmlImportDatabase::addImportPath: " << path;
+
+ if (path.isEmpty())
+ return;
+
+ QUrl url = QUrl(path);
+ QString cPath;
+
+ if (url.isRelative() || url.scheme() == QLatin1String("file")
+ || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
+ QDir dir = QDir(path);
+ cPath = dir.canonicalPath();
+ } else {
+ cPath = path;
+ cPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
+ }
+
+ if (!cPath.isEmpty()
+ && !fileImportPath.contains(cPath))
+ fileImportPath.prepend(cPath);
+}
+
+/*!
+ \internal
+*/
+QStringList QQmlImportDatabase::importPathList() const
+{
+ return fileImportPath;
+}
+
+/*!
+ \internal
+*/
+void QQmlImportDatabase::setImportPathList(const QStringList &paths)
+{
+ fileImportPath = paths;
+}
+
+/*!
+ \internal
+*/
+bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors)
+{
+ if (qmlImportTrace())
+ qDebug().nospace() << "QQmlImportDatabase::importPlugin: " << uri << " from " << filePath;
+
+#ifndef QT_NO_LIBRARY
+ QFileInfo fileInfo(filePath);
+ const QString absoluteFilePath = fileInfo.absoluteFilePath();
+
+ bool engineInitialized = initializedPlugins.contains(absoluteFilePath);
+ bool typesRegistered = qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath);
+
+ if (typesRegistered) {
+ Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath) == uri,
+ "QQmlImportDatabase::importExtension",
+ "Internal error: Plugin imported previously with different uri");
+ }
+
+ if (!engineInitialized || !typesRegistered) {
+ if (!QQml_isFileCaseCorrect(absoluteFilePath)) {
+ if (errors) {
+ QQmlError error;
+ error.setDescription(tr("File name case mismatch for \"%1\"").arg(absoluteFilePath));
+ errors->prepend(error);
+ }
+ return false;
+ }
+ QPluginLoader loader(absoluteFilePath);
+
+ if (!loader.load()) {
+ if (errors) {
+ QQmlError error;
+ error.setDescription(loader.errorString());
+ errors->prepend(error);
+ }
+ return false;
+ }
+
+ QObject *instance = loader.instance();
+ if (QQmlTypesExtensionInterface *iface = qobject_cast<QQmlExtensionInterface *>(instance)) {
+
+ const QByteArray bytes = uri.toUtf8();
+ const char *moduleId = bytes.constData();
+ if (!typesRegistered) {
+
+ // XXX thread this code should probably be protected with a mutex.
+ qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, uri);
+ iface->registerTypes(moduleId);
+ }
+ if (!engineInitialized) {
+ // things on the engine (eg. adding new global objects) have to be done for every
+ // engine.
+ // XXX protect against double initialization
+ initializedPlugins.insert(absoluteFilePath);
+
+ QQmlExtensionInterface *eiface =
+ qobject_cast<QQmlExtensionInterface *>(instance);
+ if (eiface) {
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+ ep->typeLoader.initializeEngine(eiface, moduleId);
+ }
+ }
+ } else {
+ if (errors) {
+ QQmlError error;
+ error.setDescription(loader.errorString());
+ errors->prepend(error);
+ }
+ return false;
+ }
+ }
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h
new file mode 100644
index 0000000000..ff19510525
--- /dev/null
+++ b/src/qml/qml/qqmlimport_p.h
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLIMPORT_P_H
+#define QQMLIMPORT_P_H
+
+#include <QtCore/qurl.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qset.h>
+#include <QtCore/qstringlist.h>
+#include <private/qqmldirparser_p.h>
+#include <private/qqmlscript_p.h>
+#include <private/qqmlmetatype_p.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.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QQmlTypeNameCache;
+class QQmlEngine;
+class QDir;
+class QQmlImportedNamespace;
+class QQmlImportsPrivate;
+class QQmlImportDatabase;
+class QQmlTypeLoader;
+
+// Exported for QtQuick1
+class Q_QML_EXPORT QQmlImports
+{
+public:
+ QQmlImports(QQmlTypeLoader *);
+ QQmlImports(const QQmlImports &);
+ ~QQmlImports();
+ QQmlImports &operator=(const QQmlImports &);
+
+ void setBaseUrl(const QUrl &url, const QString &urlString = QString());
+ QUrl baseUrl() const;
+
+ bool resolveType(const QString& type,
+ QQmlType** type_return, QString* url_return,
+ int *version_major, int *version_minor,
+ QQmlImportedNamespace** ns_return,
+ QList<QQmlError> *errors = 0) const;
+ bool resolveType(QQmlImportedNamespace*,
+ const QString& type,
+ QQmlType** type_return, QString* url_return,
+ int *version_major, int *version_minor) const;
+
+ bool addImport(QQmlImportDatabase *,
+ const QString& uri, const QString& prefix, int vmaj, int vmin,
+ QQmlScript::Import::Type importType,
+ const QQmlDirComponents &qmldircomponentsnetwork,
+ QList<QQmlError> *errors);
+
+ void populateCache(QQmlTypeNameCache *cache, QQmlEngine *) const;
+
+ struct ScriptReference
+ {
+ QString nameSpace;
+ QString qualifier;
+ QUrl location;
+ };
+
+ QList<ScriptReference> resolvedScripts() const;
+
+private:
+ friend class QQmlImportDatabase;
+ QQmlImportsPrivate *d;
+};
+
+class QQmlImportDatabase
+{
+ Q_DECLARE_TR_FUNCTIONS(QQmlImportDatabase)
+public:
+ QQmlImportDatabase(QQmlEngine *);
+ ~QQmlImportDatabase();
+
+ bool importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors);
+
+ QStringList importPathList() const;
+ void setImportPathList(const QStringList &paths);
+ void addImportPath(const QString& dir);
+
+ QStringList pluginPathList() const;
+ void setPluginPathList(const QStringList &paths);
+ void addPluginPath(const QString& path);
+
+private:
+ friend class QQmlImportsPrivate;
+ QString resolvePlugin(QQmlTypeLoader *typeLoader,
+ const QString &qmldirPath, const QString &qmldirPluginPath,
+ const QString &baseName, const QStringList &suffixes,
+ const QString &prefix = QString());
+ QString resolvePlugin(QQmlTypeLoader *typeLoader,
+ const QString &qmldirPath, const QString &qmldirPluginPath,
+ const QString &baseName);
+
+
+ // XXX thread
+ QStringList filePluginPath;
+ QStringList fileImportPath;
+
+ QSet<QString> initializedPlugins;
+ QQmlEngine *engine;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLIMPORT_P_H
+
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
new file mode 100644
index 0000000000..834d4bbb97
--- /dev/null
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -0,0 +1,697 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlincubator.h"
+#include "qqmlcomponent.h"
+#include "qqmlincubator_p.h"
+
+#include "qqmlcompiler_p.h"
+#include "qqmlexpression_p.h"
+
+// XXX TODO
+// - check that the Component.onCompleted behavior is the same as 4.8 in the synchronous and
+// async if nested cases
+void QQmlEnginePrivate::incubate(QQmlIncubator &i, QQmlContextData *forContext)
+{
+ QQmlIncubatorPrivate *p = i.d;
+
+ QQmlIncubator::IncubationMode mode = i.incubationMode();
+
+ if (!incubationController)
+ mode = QQmlIncubator::Synchronous;
+
+ if (mode == QQmlIncubator::AsynchronousIfNested) {
+ mode = QQmlIncubator::Synchronous;
+
+ // Need to find the first constructing context and see if it is asynchronous
+ QQmlIncubatorPrivate *parentIncubator = 0;
+ QQmlContextData *cctxt = forContext;
+ while (cctxt) {
+ if (cctxt->activeVMEData) {
+ parentIncubator = (QQmlIncubatorPrivate *)cctxt->activeVMEData;
+ break;
+ }
+ cctxt = cctxt->parent;
+ }
+
+ if (parentIncubator && parentIncubator->isAsynchronous) {
+ mode = QQmlIncubator::Asynchronous;
+ p->waitingOnMe = parentIncubator;
+ parentIncubator->waitingFor.insert(p);
+ }
+ }
+
+ p->isAsynchronous = (mode != QQmlIncubator::Synchronous);
+
+ inProgressCreations++;
+
+ if (mode == QQmlIncubator::Synchronous) {
+ typedef QQmlIncubatorPrivate IP;
+ QRecursionWatcher<IP, &IP::recursion> watcher(p);
+
+ p->changeStatus(QQmlIncubator::Loading);
+
+ if (!watcher.hasRecursed()) {
+ QQmlVME::Interrupt i;
+ p->incubate(i);
+ }
+ } else {
+ incubatorList.insert(p);
+ incubatorCount++;
+
+ p->vmeGuard.guard(&p->vme);
+ p->changeStatus(QQmlIncubator::Loading);
+
+ if (incubationController)
+ incubationController->incubatingObjectCountChanged(incubatorCount);
+ }
+}
+
+/*!
+Sets the engine's incubation \a controller. The engine can only have one active controller
+and it does not take ownership of it.
+
+\sa incubationController()
+*/
+void QQmlEngine::setIncubationController(QQmlIncubationController *controller)
+{
+ Q_D(QQmlEngine);
+ if (d->incubationController)
+ d->incubationController->d = 0;
+ d->incubationController = controller;
+ if (controller) controller->d = d;
+}
+
+/*!
+Returns the currently set incubation controller, or 0 if no controller has been set.
+
+\sa setIncubationController()
+*/
+QQmlIncubationController *QQmlEngine::incubationController() const
+{
+ Q_D(const QQmlEngine);
+ return d->incubationController;
+}
+
+QQmlIncubatorPrivate::QQmlIncubatorPrivate(QQmlIncubator *q,
+ QQmlIncubator::IncubationMode m)
+: q(q), status(QQmlIncubator::Null), mode(m), isAsynchronous(false), progress(Execute),
+ result(0), component(0), vme(this), waitingOnMe(0)
+{
+}
+
+QQmlIncubatorPrivate::~QQmlIncubatorPrivate()
+{
+}
+
+void QQmlIncubatorPrivate::clear()
+{
+ if (next.isInList()) {
+ next.remove();
+ Q_ASSERT(component);
+ QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(component->engine);
+ component->release();
+ component = 0;
+ enginePriv->incubatorCount--;
+ QQmlIncubationController *controller = enginePriv->incubationController;
+ if (controller)
+ controller->incubatingObjectCountChanged(enginePriv->incubatorCount);
+ } else if (component) {
+ component->release();
+ component = 0;
+ }
+ if (!rootContext.isNull()) {
+ rootContext->activeVMEData = 0;
+ rootContext = 0;
+ }
+
+ if (nextWaitingFor.isInList()) {
+ Q_ASSERT(waitingOnMe);
+ nextWaitingFor.remove();
+ waitingOnMe = 0;
+ }
+}
+
+/*!
+\class QQmlIncubationController
+\brief QQmlIncubationController instances drive the progress of QQmlIncubators
+
+In order to behave asynchronously and not introduce stutters or freezes in an application,
+the process of creating objects a QQmlIncubators must be driven only during the
+application's idle time. QQmlIncubationController allows the application to control
+exactly when, how often and for how long this processing occurs.
+
+A QQmlIncubationController derived instance should be created and set on a
+QQmlEngine by calling the QQmlEngine::setIncubationController() method.
+Processing is then controlled by calling the QQmlIncubationController::incubateFor()
+or QQmlIncubationController::incubateWhile() methods as dictated by the application's
+requirements.
+
+For example, this is an example of a incubation controller that will incubate for a maximum
+of 5 milliseconds out of every 16 milliseconds.
+
+\code
+class PeriodicIncubationController : public QObject,
+ public QQmlIncubationController
+{
+public:
+ PeriodicIncubationController() {
+ startTimer(16);
+ }
+
+protected:
+ virtual void timerEvent(QTimerEvent *) {
+ incubateFor(5);
+ }
+};
+\endcode
+
+Although the previous example would work, it is not optimal. Real world incubation
+controllers should try and maximize the amount of idle time they consume - rather
+than a static amount like 5 milliseconds - while not disturbing the application.
+*/
+
+/*!
+Create a new incubation controller.
+*/
+QQmlIncubationController::QQmlIncubationController()
+: d(0)
+{
+}
+
+/*! \internal */
+QQmlIncubationController::~QQmlIncubationController()
+{
+ if (d) QQmlEnginePrivate::get(d)->setIncubationController(0);
+ d = 0;
+}
+
+/*!
+Return the QQmlEngine this incubation controller is set on, or 0 if it
+has not been set on any engine.
+*/
+QQmlEngine *QQmlIncubationController::engine() const
+{
+ return QQmlEnginePrivate::get(d);
+}
+
+/*!
+Return the number of objects currently incubating.
+*/
+int QQmlIncubationController::incubatingObjectCount() const
+{
+ if (d)
+ return d->incubatorCount;
+ else
+ return 0;
+}
+
+/*!
+Called when the number of incubating objects changes. \a incubatingObjectCount is the
+new number of incubating objects.
+
+The default implementation does nothing.
+*/
+void QQmlIncubationController::incubatingObjectCountChanged(int incubatingObjectCount)
+{
+ Q_UNUSED(incubatingObjectCount);
+}
+
+void QQmlIncubatorPrivate::incubate(QQmlVME::Interrupt &i)
+{
+ if (!component)
+ return;
+ typedef QQmlIncubatorPrivate IP;
+ QRecursionWatcher<IP, &IP::recursion> watcher(this);
+
+ QQmlEngine *engine = component->engine;
+ QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine);
+
+ bool guardOk = vmeGuard.isOK();
+ vmeGuard.clear();
+
+ if (!guardOk) {
+ QQmlError error;
+ error.setUrl(component->url);
+ error.setDescription(QQmlComponent::tr("Object destroyed during incubation"));
+ errors << error;
+ progress = QQmlIncubatorPrivate::Completed;
+
+ goto finishIncubate;
+ }
+
+ if (progress == QQmlIncubatorPrivate::Execute) {
+ enginePriv->referenceScarceResources();
+ QObject *tresult = vme.execute(&errors, i);
+ enginePriv->dereferenceScarceResources();
+
+ if (watcher.hasRecursed())
+ return;
+
+ result = tresult;
+ if (errors.isEmpty() && result == 0)
+ goto finishIncubate;
+
+ if (result) {
+ QQmlData *ddata = QQmlData::get(result);
+ Q_ASSERT(ddata);
+ ddata->indestructible = true;
+
+ q->setInitialState(result);
+ }
+
+ if (watcher.hasRecursed())
+ return;
+
+ if (errors.isEmpty())
+ progress = QQmlIncubatorPrivate::Completing;
+ else
+ progress = QQmlIncubatorPrivate::Completed;
+
+ changeStatus(calculateStatus());
+
+ if (watcher.hasRecursed())
+ return;
+
+ if (i.shouldInterrupt())
+ goto finishIncubate;
+ }
+
+ if (progress == QQmlIncubatorPrivate::Completing) {
+ do {
+ if (watcher.hasRecursed())
+ return;
+
+ QQmlContextData *ctxt = vme.complete(i);
+ if (ctxt) {
+ rootContext = ctxt;
+ progress = QQmlIncubatorPrivate::Completed;
+ goto finishIncubate;
+ }
+ } while (!i.shouldInterrupt());
+ }
+
+finishIncubate:
+ if (progress == QQmlIncubatorPrivate::Completed && waitingFor.isEmpty()) {
+ typedef QQmlIncubatorPrivate IP;
+
+ QQmlIncubatorPrivate *isWaiting = waitingOnMe;
+ clear();
+
+ if (isWaiting) {
+ QRecursionWatcher<IP, &IP::recursion> watcher(isWaiting);
+ changeStatus(calculateStatus());
+ if (!watcher.hasRecursed())
+ isWaiting->incubate(i);
+ } else {
+ changeStatus(calculateStatus());
+ }
+
+ enginePriv->inProgressCreations--;
+
+ if (0 == enginePriv->inProgressCreations) {
+ while (enginePriv->erroredBindings) {
+ enginePriv->warning(enginePriv->erroredBindings->error);
+ enginePriv->erroredBindings->removeError();
+ }
+ }
+ } else {
+ vmeGuard.guard(&vme);
+ }
+}
+
+/*!
+Incubate objects for \a msecs, or until there are no more objects to incubate.
+*/
+void QQmlIncubationController::incubateFor(int msecs)
+{
+ if (!d || d->incubatorCount == 0)
+ return;
+
+ QQmlVME::Interrupt i(msecs * 1000000);
+ i.reset();
+ do {
+ QQmlIncubatorPrivate *p = (QQmlIncubatorPrivate*)d->incubatorList.first();
+ p->incubate(i);
+ } while (d && d->incubatorCount != 0 && !i.shouldInterrupt());
+}
+
+/*!
+Incubate objects while the bool pointed to by \a flag is true, or until there are no
+more objects to incubate, or up to msecs if msecs is not zero.
+
+Generally this method is used in conjunction with a thread or a UNIX signal that sets
+the bool pointed to by \a flag to false when it wants incubation to be interrupted.
+*/
+void QQmlIncubationController::incubateWhile(volatile bool *flag, int msecs)
+{
+ if (!d || d->incubatorCount == 0)
+ return;
+
+ QQmlVME::Interrupt i(flag, msecs * 1000000);
+ i.reset();
+ do {
+ QQmlIncubatorPrivate *p = (QQmlIncubatorPrivate*)d->incubatorList.first();
+ p->incubate(i);
+ } while (d && d->incubatorCount != 0 && !i.shouldInterrupt());
+}
+
+/*!
+\class QQmlIncubator
+\brief The QQmlIncubator class allows QML objects to be created asynchronously.
+
+Creating QML objects - like delegates in a view, or a new page in an application - can take
+a noticable amount of time, especially on resource constrained mobile devices. When an
+application uses QQmlComponent::create() directly, the QML object instance is created
+synchronously which, depending on the complexity of the object, can cause noticable pauses or
+stutters in the application.
+
+The use of QQmlIncubator gives more control over the creation of a QML object,
+including allowing it to be created asynchronously using application idle time. The following
+example shows a simple use of QQmlIncubator.
+
+\code
+QQmlIncubator incubator;
+component->create(incubator);
+
+while (incubator.isReady()) {
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
+}
+
+QObject *object = incubator.object();
+\endcode
+
+Asynchronous incubators are controlled by a QQmlIncubationController that is
+set on the QQmlEngine, which lets the engine know when the application is idle and
+incubating objects should be processed. If an incubation controller is not set on the
+QQmlEngine, QQmlIncubator creates objects synchronously regardless of the
+specified IncubationMode.
+
+QQmlIncubator supports three incubation modes:
+\list
+\i Synchronous The creation occurs synchronously. That is, once the
+QQmlComponent::create() call returns, the incubator will already be in either the
+Error or Ready state. A synchronous incubator has no real advantage compared to using
+the synchronous creation methods on QQmlComponent directly, but it may simplify an
+application's implementation to use the same API for both synchronous and asynchronous
+creations.
+
+\i Asynchronous (default) The creation occurs asynchronously, assuming a
+QQmlIncubatorController is set on the QQmlEngine.
+
+The incubator will remain in the Loading state until either the creation is complete or an error
+occurs. The statusChanged() callback can be used to be notified of status changes.
+
+Applications should use the Asynchronous incubation mode to create objects that are not needed
+immediately. For example, the ListView element uses Asynchronous incubation to create objects
+that are slightly off screen while the list is being scrolled. If, during asynchronous creation,
+the object is needed immediately the QQmlIncubator::forceCompletion() method can be called
+to complete the creation process synchronously.
+
+\i AsynchronousIfNested The creation will occur asynchronously if part of a nested asynchronous
+creation, or synchronously if not.
+
+In most scenarios where a QML element or component wants the appearance of a synchronous
+instantiation, it should use this mode.
+
+This mode is best explained with an example. When the ListView element is first created, it needs
+to populate itself with an initial set of delegates to show. If the ListView was 400 pixels high,
+and each delegate was 100 pixels high, it would need to create four initial delegate instances. If
+the ListView used the Asynchronous incubation mode, the ListView would always be created empty and
+then, sometime later, the four initial elements would appear.
+
+Conversely, if the ListView was to use the Synchronous incubation mode it would behave correctly
+but it may introduce stutters into the application. As QML would have to stop and instantiate the
+ListView's delegates synchronously, if the ListView was part of a QML component that was being
+instantiated asynchronously this would undo much of the benefit of asynchronous instantiation.
+
+The AsynchronousIfNested mode reconciles this problem. By using AsynchronousIfNested, the ListView
+delegates are instantiated asynchronously if the ListView itself is already part of an asynchronous
+instantiation, and synchronously otherwise. In the case of a nested asynchronous instantiation, the
+outer asynchronous instantiation will not complete until after all the nested instantiations have also
+completed. This ensures that by the time the outer asynchronous instantitation completes, inner
+elements like ListView have already completed loading their initial delegates.
+
+It is almost always incorrect to use the Synchronous incubation mode - elements or components that
+want the appearance of synchronous instantiation, but without the downsides of introducing freezes
+or stutters into the application, should use the AsynchronousIfNested incubation mode.
+\endlist
+*/
+
+/*!
+Create a new incubator with the specified \a mode
+*/
+QQmlIncubator::QQmlIncubator(IncubationMode mode)
+: d(new QQmlIncubatorPrivate(this, mode))
+{
+}
+
+/*! \internal */
+QQmlIncubator::~QQmlIncubator()
+{
+ clear();
+
+ delete d; d = 0;
+}
+
+/*!
+\enum QQmlIncubator::IncubationMode
+
+Specifies the mode the incubator operates in. Regardless of the incubation mode, a
+QQmlIncubator will behave synchronously if the QQmlEngine does not have
+a QQmlIncubationController set.
+
+\value Asynchronous The object will be created asynchronously.
+\value AsynchronousIfNested If the object is being created in a context that is already part
+of an asynchronous creation, this incubator will join that existing incubation and execute
+asynchronously. The existing incubation will not become Ready until both it and this
+incubation have completed. Otherwise, the incubation will execute synchronously.
+\value Synchronous The object will be created synchronously.
+*/
+
+/*!
+\enum QQmlIncubator::Status
+
+Specifies the status of the QQmlIncubator.
+
+\value Null Incubation is not in progress. Call QQmlComponent::create() to begin incubating.
+\value Ready The object is fully created and can be accessed by calling object().
+\value Loading The object is in the process of being created.
+\value Error An error occurred. The errors can be access by calling errors().
+*/
+
+/*!
+Clears the incubator. Any in-progress incubation is aborted. If the incubator is in the
+Ready state, the created object is \b not deleted.
+*/
+void QQmlIncubator::clear()
+{
+ typedef QQmlIncubatorPrivate IP;
+ QRecursionWatcher<IP, &IP::recursion> watcher(d);
+
+ Status s = status();
+
+ if (s == Null)
+ return;
+
+ QQmlEnginePrivate *enginePriv = 0;
+ if (s == Loading) {
+ Q_ASSERT(d->component);
+ enginePriv = QQmlEnginePrivate::get(d->component->engine);
+ if (d->result) d->result->deleteLater();
+ d->result = 0;
+ }
+
+ d->clear();
+
+ d->vme.reset();
+ d->vmeGuard.clear();
+
+ Q_ASSERT(d->component == 0);
+ Q_ASSERT(d->waitingOnMe == 0);
+ Q_ASSERT(d->waitingFor.isEmpty());
+ Q_ASSERT(!d->nextWaitingFor.isInList());
+
+ d->errors.clear();
+ d->progress = QQmlIncubatorPrivate::Execute;
+ d->result = 0;
+
+ if (s == Loading) {
+ Q_ASSERT(enginePriv);
+
+ enginePriv->inProgressCreations--;
+ if (0 == enginePriv->inProgressCreations) {
+ while (enginePriv->erroredBindings) {
+ enginePriv->warning(enginePriv->erroredBindings->error);
+ enginePriv->erroredBindings->removeError();
+ }
+ }
+ }
+
+ d->changeStatus(Null);
+}
+
+/*!
+Force any in-progress incubation to finish synchronously. Once this call
+returns, the incubator will not be in the Loading state.
+*/
+void QQmlIncubator::forceCompletion()
+{
+ QQmlVME::Interrupt i;
+ while (Loading == status()) {
+ while (Loading == status() && !d->waitingFor.isEmpty())
+ static_cast<QQmlIncubatorPrivate *>(d->waitingFor.first())->incubate(i);
+ if (Loading == status())
+ d->incubate(i);
+ }
+}
+
+/*!
+Returns true if the incubator's status() is Null.
+*/
+bool QQmlIncubator::isNull() const
+{
+ return status() == Null;
+}
+
+/*!
+Returns true if the incubator's status() is Ready.
+*/
+bool QQmlIncubator::isReady() const
+{
+ return status() == Ready;
+}
+
+/*!
+Returns true if the incubator's status() is Error.
+*/
+bool QQmlIncubator::isError() const
+{
+ return status() == Error;
+}
+
+/*!
+Returns true if the incubator's status() is Loading.
+*/
+bool QQmlIncubator::isLoading() const
+{
+ return status() == Loading;
+}
+
+/*!
+Return the list of errors encountered while incubating the object.
+*/
+QList<QQmlError> QQmlIncubator::errors() const
+{
+ return d->errors;
+}
+
+/*!
+Return the incubation mode passed to the QQmlIncubator constructor.
+*/
+QQmlIncubator::IncubationMode QQmlIncubator::incubationMode() const
+{
+ return d->mode;
+}
+
+/*!
+Return the current status of the incubator.
+*/
+QQmlIncubator::Status QQmlIncubator::status() const
+{
+ return d->status;
+}
+
+/*!
+Return the incubated object if the status is Ready, otherwise 0.
+*/
+QObject *QQmlIncubator::object() const
+{
+ if (status() != Ready) return 0;
+ else return d->result;
+}
+
+/*!
+Called when the status of the incubator changes. \a status is the new status.
+
+The default implementation does nothing.
+*/
+void QQmlIncubator::statusChanged(Status status)
+{
+ Q_UNUSED(status);
+}
+
+/*!
+Called after the object is first created, but before property bindings are
+evaluated and, if applicable, QQmlParserStatus::componentComplete() is
+called. This is equivalent to the point between QQmlComponent::beginCreate()
+and QQmlComponent::endCreate(), and can be used to assign initial values
+to the object's properties.
+
+The default implementation does nothing.
+*/
+void QQmlIncubator::setInitialState(QObject *object)
+{
+ Q_UNUSED(object);
+}
+
+void QQmlIncubatorPrivate::changeStatus(QQmlIncubator::Status s)
+{
+ if (s == status)
+ return;
+
+ status = s;
+ q->statusChanged(status);
+}
+
+QQmlIncubator::Status QQmlIncubatorPrivate::calculateStatus() const
+{
+ if (!errors.isEmpty())
+ return QQmlIncubator::Error;
+ else if (result && progress == QQmlIncubatorPrivate::Completed &&
+ waitingFor.isEmpty())
+ return QQmlIncubator::Ready;
+ else if (component)
+ return QQmlIncubator::Loading;
+ else
+ return QQmlIncubator::Null;
+}
+
diff --git a/src/qml/qml/qqmlincubator.h b/src/qml/qml/qqmlincubator.h
new file mode 100644
index 0000000000..2fb2aaf2f1
--- /dev/null
+++ b/src/qml/qml/qqmlincubator.h
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLINCUBATOR_H
+#define QQMLINCUBATOR_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtQml/qqmlerror.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlEngine;
+
+class QQmlIncubatorPrivate;
+class Q_QML_EXPORT QQmlIncubator
+{
+ Q_DISABLE_COPY(QQmlIncubator)
+public:
+ enum IncubationMode {
+ Asynchronous,
+ AsynchronousIfNested,
+ Synchronous
+ };
+ enum Status {
+ Null,
+ Ready,
+ Loading,
+ Error
+ };
+
+ QQmlIncubator(IncubationMode = Asynchronous);
+ virtual ~QQmlIncubator();
+
+ void clear();
+ void forceCompletion();
+
+ bool isNull() const;
+ bool isReady() const;
+ bool isError() const;
+ bool isLoading() const;
+
+ QList<QQmlError> errors() const;
+
+ IncubationMode incubationMode() const;
+
+ Status status() const;
+
+ QObject *object() const;
+
+protected:
+ virtual void statusChanged(Status);
+ virtual void setInitialState(QObject *);
+
+private:
+ friend class QQmlComponent;
+ friend class QQmlEnginePrivate;
+ friend class QQmlIncubatorPrivate;
+ QQmlIncubatorPrivate *d;
+};
+
+class QQmlEnginePrivate;
+class Q_QML_EXPORT QQmlIncubationController
+{
+ Q_DISABLE_COPY(QQmlIncubationController)
+public:
+ QQmlIncubationController();
+ virtual ~QQmlIncubationController();
+
+ QQmlEngine *engine() const;
+ int incubatingObjectCount() const;
+
+ void incubateFor(int msecs);
+ void incubateWhile(volatile bool *flag, int msecs=0);
+
+protected:
+ virtual void incubatingObjectCountChanged(int);
+
+private:
+ friend class QQmlEngine;
+ friend class QQmlEnginePrivate;
+ friend class QQmlIncubatorPrivate;
+ QQmlEnginePrivate *d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLINCUBATOR_H
diff --git a/src/qml/qml/qqmlincubator_p.h b/src/qml/qml/qqmlincubator_p.h
new file mode 100644
index 0000000000..0dec34a8d5
--- /dev/null
+++ b/src/qml/qml/qqmlincubator_p.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLINCUBATOR_P_H
+#define QQMLINCUBATOR_P_H
+
+#include <private/qintrusivelist_p.h>
+#include <private/qqmlvme_p.h>
+#include <private/qrecursionwatcher_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qqmlcontext_p.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.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QQmlCompiledData;
+class QQmlIncubator;
+class QQmlIncubatorPrivate : public QQmlEnginePrivate::Incubator
+{
+public:
+ QQmlIncubatorPrivate(QQmlIncubator *q, QQmlIncubator::IncubationMode m);
+ ~QQmlIncubatorPrivate();
+
+ QQmlIncubator *q;
+
+ QQmlIncubator::Status calculateStatus() const;
+ void changeStatus(QQmlIncubator::Status);
+ QQmlIncubator::Status status;
+
+ QQmlIncubator::IncubationMode mode;
+ bool isAsynchronous;
+
+ QList<QQmlError> errors;
+
+ enum Progress { Execute, Completing, Completed };
+ Progress progress;
+
+ QQmlGuard<QObject> result;
+ QQmlGuardedContextData rootContext;
+ QQmlCompiledData *component;
+ QQmlVME vme;
+ QQmlVMEGuard vmeGuard;
+
+ QQmlIncubatorPrivate *waitingOnMe;
+ typedef QQmlEnginePrivate::Incubator QIPBase;
+ QIntrusiveList<QIPBase, &QIPBase::nextWaitingFor> waitingFor;
+
+ QRecursionNode recursion;
+
+ void clear();
+
+ void incubate(QQmlVME::Interrupt &i);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLINCUBATOR_P_H
+
diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp
new file mode 100644
index 0000000000..53145737d8
--- /dev/null
+++ b/src/qml/qml/qqmlinfo.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlinfo.h"
+
+#include "qqmldata_p.h"
+#include "qqmlcontext.h"
+#include "qqmlcontext_p.h"
+#include "qqmlmetatype_p.h"
+#include "qqmlengine_p.h"
+
+#include <QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \fn QQmlInfo qmlInfo(const QObject *object)
+ \relates QQmlEngine
+
+ Prints warning messages that include the file and line number for the
+ specified QML \a object.
+
+ When QML types display warning messages, it improves traceability
+ if they include the QML file and line number on which the
+ particular instance was instantiated.
+
+ To include the file and line number, an object must be passed. If
+ the file and line number is not available for that instance
+ (either it was not instantiated by the QML engine or location
+ information is disabled), "unknown location" will be used instead.
+
+ For example,
+
+ \code
+ qmlInfo(object) << tr("component property is a write-once property");
+ \endcode
+
+ prints
+
+ \code
+ QML MyCustomType (unknown location): component property is a write-once property
+ \endcode
+*/
+
+class QQmlInfoPrivate
+{
+public:
+ QQmlInfoPrivate() : ref (1), object(0) {}
+
+ int ref;
+ const QObject *object;
+ QString buffer;
+ QList<QQmlError> errors;
+};
+
+QQmlInfo::QQmlInfo(QQmlInfoPrivate *p)
+: QDebug(&p->buffer), d(p)
+{
+ nospace();
+}
+
+QQmlInfo::QQmlInfo(const QQmlInfo &other)
+: QDebug(other), d(other.d)
+{
+ d->ref++;
+}
+
+QQmlInfo::~QQmlInfo()
+{
+ if (0 == --d->ref) {
+ QList<QQmlError> errors = d->errors;
+
+ QQmlEngine *engine = 0;
+
+ if (!d->buffer.isEmpty()) {
+ QQmlError error;
+
+ QObject *object = const_cast<QObject *>(d->object);
+
+ if (object) {
+ engine = qmlEngine(d->object);
+ QString typeName;
+ QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
+ if (type) {
+ typeName = type->qmlTypeName();
+ int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash != -1)
+ typeName = typeName.mid(lastSlash+1);
+ } else {
+ typeName = QString::fromUtf8(object->metaObject()->className());
+ int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
+ if (marker != -1)
+ typeName = typeName.left(marker);
+
+ marker = typeName.indexOf(QLatin1String("_QML_"));
+ if (marker != -1) {
+ typeName = typeName.left(marker);
+ typeName += QLatin1Char('*');
+ type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
+ if (type) {
+ typeName = type->qmlTypeName();
+ int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash != -1)
+ typeName = typeName.mid(lastSlash+1);
+ }
+ }
+ }
+
+ d->buffer.prepend(QLatin1String("QML ") + typeName + QLatin1String(": "));
+
+ QQmlData *ddata = QQmlData::get(object, false);
+ if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) {
+ error.setUrl(ddata->outerContext->url);
+ error.setLine(ddata->lineNumber);
+ error.setColumn(ddata->columnNumber);
+ }
+ }
+
+ error.setDescription(d->buffer);
+
+ errors.prepend(error);
+ }
+
+ QQmlEnginePrivate::warning(engine, errors);
+
+ delete d;
+ }
+}
+
+QQmlInfo qmlInfo(const QObject *me)
+{
+ QQmlInfoPrivate *d = new QQmlInfoPrivate;
+ d->object = me;
+ return QQmlInfo(d);
+}
+
+QQmlInfo qmlInfo(const QObject *me, const QQmlError &error)
+{
+ QQmlInfoPrivate *d = new QQmlInfoPrivate;
+ d->object = me;
+ d->errors << error;
+ return QQmlInfo(d);
+}
+
+QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors)
+{
+ QQmlInfoPrivate *d = new QQmlInfoPrivate;
+ d->object = me;
+ d->errors = errors;
+ return QQmlInfo(d);
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlinfo.h b/src/qml/qml/qqmlinfo.h
new file mode 100644
index 0000000000..92d6d72e8b
--- /dev/null
+++ b/src/qml/qml/qqmlinfo.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLINFO_H
+#define QQMLINFO_H
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qurl.h>
+#include <QtQml/qqmlerror.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlInfoPrivate;
+class Q_QML_EXPORT QQmlInfo : public QDebug
+{
+public:
+ QQmlInfo(const QQmlInfo &);
+ ~QQmlInfo();
+
+ inline QQmlInfo &operator<<(QChar t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(bool t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(char t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(signed short t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(unsigned short t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(signed int t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(unsigned int t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(signed long t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(unsigned long t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(qint64 t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(quint64 t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(float t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(double t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(const char* t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(const QString & t) { QDebug::operator<<(t.toLocal8Bit().constData()); return *this; }
+ inline QQmlInfo &operator<<(const QStringRef & t) { return operator<<(t.toString()); }
+ inline QQmlInfo &operator<<(const QLatin1String &t) { QDebug::operator<<(t.latin1()); return *this; }
+ inline QQmlInfo &operator<<(const QByteArray & t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; }
+ inline QQmlInfo &operator<<(QTextStreamFunction f) { QDebug::operator<<(f); return *this; }
+ inline QQmlInfo &operator<<(QTextStreamManipulator m) { QDebug::operator<<(m); return *this; }
+#ifndef QT_NO_DEBUG_STREAM
+ inline QQmlInfo &operator<<(const QUrl &t) { static_cast<QDebug &>(*this) << t; return *this; }
+#endif
+
+private:
+ friend Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me);
+ friend Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QQmlError &error);
+ friend Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors);
+
+ QQmlInfo(QQmlInfoPrivate *);
+ QQmlInfoPrivate *d;
+};
+
+Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me);
+Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QQmlError &error);
+Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLINFO_H
diff --git a/src/qml/qml/qqmlinstruction.cpp b/src/qml/qml/qqmlinstruction.cpp
new file mode 100644
index 0000000000..b37117e69b
--- /dev/null
+++ b/src/qml/qml/qqmlinstruction.cpp
@@ -0,0 +1,278 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlinstruction_p.h"
+
+#include "qqmlcompiler_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+void QQmlCompiledData::dump(QQmlInstruction *instr, int idx)
+{
+#ifdef QT_NO_DEBUG_STREAM
+ Q_UNUSED(instr)
+ Q_UNUSED(idx)
+#else
+ switch (instructionType(instr)) {
+ case QQmlInstruction::Init:
+ qWarning().nospace() << idx << "\t\t" << "INIT\t\t\t" << instr->init.bindingsSize << "\t" << instr->init.parserStatusSize << "\t" << instr->init.contextCache << "\t" << instr->init.compiledBinding;
+ break;
+ case QQmlInstruction::DeferInit:
+ qWarning().nospace() << idx << "\t\t" << "DEFER_INIT\t\t" << instr->deferInit.bindingsSize << "\t" << instr->deferInit.parserStatusSize;
+ break;
+ case QQmlInstruction::Done:
+ qWarning().nospace() << idx << "\t\t" << "DONE";
+ break;
+ case QQmlInstruction::CreateCppObject:
+ qWarning().nospace() << idx << "\t\t" << "CREATECPP\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className;
+ break;
+ case QQmlInstruction::CreateQMLObject:
+ qWarning().nospace() << idx << "\t\t" << "CREATEQML\t\t\t" << instr->createQml.type << "\t" << instr->createQml.bindingBits << "\t\t" << types.at(instr->createQml.type).className;
+ break;
+ case QQmlInstruction::CompleteQMLObject:
+ qWarning().nospace() << idx << "\t\t" << "COMPLETEQML";
+ break;
+ case QQmlInstruction::CreateSimpleObject:
+ qWarning().nospace() << idx << "\t\t" << "CREATE_SIMPLE\t\t" << instr->createSimple.typeSize;
+ break;
+ case QQmlInstruction::SetId:
+ qWarning().nospace() << idx << "\t\t" << "SETID\t\t\t" << instr->setId.value << "\t\t\t" << primitives.at(instr->setId.value);
+ break;
+ case QQmlInstruction::SetDefault:
+ qWarning().nospace() << idx << "\t\t" << "SET_DEFAULT";
+ break;
+ case QQmlInstruction::CreateComponent:
+ qWarning().nospace() << idx << "\t\t" << "CREATE_COMPONENT\t" << instr->createComponent.count;
+ break;
+ case QQmlInstruction::StoreMetaObject:
+ qWarning().nospace() << idx << "\t\t" << "STORE_META\t\t" << instr->storeMeta.data;
+ break;
+ case QQmlInstruction::StoreFloat:
+ qWarning().nospace() << idx << "\t\t" << "STORE_FLOAT\t\t" << instr->storeFloat.propertyIndex << "\t" << instr->storeFloat.value;
+ break;
+ case QQmlInstruction::StoreDouble:
+ qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
+ break;
+ case QQmlInstruction::StoreDoubleQList:
+ qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE_QLIST\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
+ break;
+ case QQmlInstruction::StoreInteger:
+ qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
+ break;
+ case QQmlInstruction::StoreIntegerQList:
+ qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER_QLIST\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
+ break;
+ case QQmlInstruction::StoreBool:
+ qWarning().nospace() << idx << "\t\t" << "STORE_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
+ break;
+ case QQmlInstruction::StoreBoolQList:
+ qWarning().nospace() << idx << "\t\t" << "STORE_BOOL_QLIST\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
+ break;
+ case QQmlInstruction::StoreString:
+ qWarning().nospace() << idx << "\t\t" << "STORE_STRING\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
+ break;
+ case QQmlInstruction::StoreStringList:
+ qWarning().nospace() << idx << "\t\t" << "STORE_STRINGLIST\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
+ break;
+ case QQmlInstruction::StoreStringQList:
+ qWarning().nospace() << idx << "\t\t" << "STORE_STRING_QLIST\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
+ break;
+ case QQmlInstruction::StoreTrString:
+ qWarning().nospace() << idx << "\t\t" << "STORE_TR_STRING\t" << instr->storeTrString.propertyIndex << "\t" << instr->storeTrString.context << "\t" << instr->storeTrString.text << "\t" << instr->storeTrString.comment << "\t" << instr->storeTrString.n;
+ break;
+ case QQmlInstruction::StoreTrIdString:
+ qWarning().nospace() << idx << "\t\t" << "STORE_TRID_STRING\t" << instr->storeTrIdString.propertyIndex << "\t" << instr->storeTrIdString.text << "\t" << instr->storeTrIdString.n;
+ break;
+ case QQmlInstruction::StoreByteArray:
+ qWarning().nospace() << idx << "\t\t" << "STORE_BYTEARRAY" << instr->storeByteArray.propertyIndex << "\t" << instr->storeByteArray.value << "\t\t" << datas.at(instr->storeByteArray.value);
+ break;
+ case QQmlInstruction::StoreUrl:
+ qWarning().nospace() << idx << "\t\t" << "STORE_URL\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << urls.at(instr->storeUrl.value);
+ break;
+ case QQmlInstruction::StoreUrlQList:
+ qWarning().nospace() << idx << "\t\t" << "STORE_URL_QLIST\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << urls.at(instr->storeUrl.value);
+ break;
+ case QQmlInstruction::StoreColor:
+ qWarning().nospace() << idx << "\t\t" << "STORE_COLOR\t\t" << instr->storeColor.propertyIndex << "\t\t\t" << QString::number(instr->storeColor.value, 16);
+ break;
+ case QQmlInstruction::StoreDate:
+ qWarning().nospace() << idx << "\t\t" << "STORE_DATE\t\t" << instr->storeDate.propertyIndex << "\t" << instr->storeDate.value;
+ break;
+ case QQmlInstruction::StoreTime:
+ qWarning().nospace() << idx << "\t\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex;
+ break;
+ case QQmlInstruction::StoreDateTime:
+ qWarning().nospace() << idx << "\t\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex;
+ break;
+ case QQmlInstruction::StorePoint:
+ qWarning().nospace() << idx << "\t\t" << "STORE_POINT\t\t" << instr->storePoint.propertyIndex << "\t" << instr->storePoint.point.xp << "\t" << instr->storePoint.point.yp;
+ break;
+ case QQmlInstruction::StorePointF:
+ qWarning().nospace() << idx << "\t\t" << "STORE_POINTF\t\t" << instr->storePointF.propertyIndex << "\t" << instr->storePointF.point.xp << "\t" << instr->storePointF.point.yp;
+ break;
+ case QQmlInstruction::StoreSize:
+ qWarning().nospace() << idx << "\t\t" << "STORE_SIZE\t\t" << instr->storeSize.propertyIndex << "\t" << instr->storeSize.size.wd << "\t" << instr->storeSize.size.ht;
+ break;
+ case QQmlInstruction::StoreSizeF:
+ qWarning().nospace() << idx << "\t\t" << "STORE_SIZEF\t\t" << instr->storeSizeF.propertyIndex << "\t" << instr->storeSizeF.size.wd << "\t" << instr->storeSizeF.size.ht;
+ break;
+ case QQmlInstruction::StoreRect:
+ qWarning().nospace() << idx << "\t\t" << "STORE_RECT\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.rect.x1 << "\t" << instr->storeRect.rect.y1 << "\t" << instr->storeRect.rect.x2 << "\t" << instr->storeRect.rect.y2;
+ break;
+ case QQmlInstruction::StoreRectF:
+ qWarning().nospace() << idx << "\t\t" << "STORE_RECTF\t\t" << instr->storeRectF.propertyIndex << "\t" << instr->storeRectF.rect.xp << "\t" << instr->storeRectF.rect.yp << "\t" << instr->storeRectF.rect.w << "\t" << instr->storeRectF.rect.h;
+ break;
+ case QQmlInstruction::StoreVector3D:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR3D\t\t" << instr->storeVector3D.propertyIndex << "\t" << instr->storeVector3D.vector.xp << "\t" << instr->storeVector3D.vector.yp << "\t" << instr->storeVector3D.vector.zp;
+ break;
+ case QQmlInstruction::StoreVector4D:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR4D\t\t" << instr->storeVector4D.propertyIndex << "\t" << instr->storeVector4D.vector.xp << "\t" << instr->storeVector4D.vector.yp << "\t" << instr->storeVector4D.vector.zp << "\t" << instr->storeVector4D.vector.wp;
+ break;
+ case QQmlInstruction::StoreVariant:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
+ break;
+ case QQmlInstruction::StoreVariantInteger:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
+ break;
+ case QQmlInstruction::StoreVariantDouble:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
+ break;
+ case QQmlInstruction::StoreVariantBool:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
+ break;
+ case QQmlInstruction::StoreObject:
+ qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
+ break;
+ case QQmlInstruction::StoreVariantObject:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_OBJECT\t" << instr->storeObject.propertyIndex;
+ break;
+ case QQmlInstruction::StoreInterface:
+ qWarning().nospace() << idx << "\t\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
+ break;
+ case QQmlInstruction::StoreSignal:
+ qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value;
+ break;
+ case QQmlInstruction::StoreImportedScript:
+ qWarning().nospace() << idx << "\t\t" << "STORE_IMPORTED_SCRIPT\t" << instr->storeScript.value;
+ break;
+ case QQmlInstruction::StoreScriptString:
+ qWarning().nospace() << idx << "\t\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope << "\t" << instr->storeScriptString.bindingId;
+ break;
+ case QQmlInstruction::AssignSignalObject:
+ qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal;
+ break;
+ case QQmlInstruction::AssignCustomType:
+ qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type;
+ break;
+ case QQmlInstruction::InitV8Bindings:
+ qWarning().nospace() << idx << "\t\t" << "INIT_V8_BINDING\t" << instr->initV8Bindings.programIndex << "\t" << instr->initV8Bindings.line;
+ break;
+ case QQmlInstruction::StoreBinding:
+ qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+ break;
+ case QQmlInstruction::StoreBindingOnAlias:
+ qWarning().nospace() << idx << "\t\t" << "STORE_BINDING_ALIAS\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+ break;
+ case QQmlInstruction::StoreV4Binding:
+ qWarning().nospace() << idx << "\t\t" << "STORE_COMPILED_BINDING\t" << instr->assignV4Binding.property << "\t" << instr->assignV4Binding.value << "\t" << instr->assignV4Binding.context;
+ break;
+ case QQmlInstruction::StoreV8Binding:
+ qWarning().nospace() << idx << "\t\t" << "STORE_V8_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
+ break;
+ case QQmlInstruction::StoreValueSource:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property.coreIndex << "\t" << instr->assignValueSource.castValue;
+ break;
+ case QQmlInstruction::StoreValueInterceptor:
+ qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property.coreIndex << "\t" << instr->assignValueInterceptor.castValue;
+ break;
+ case QQmlInstruction::BeginObject:
+ qWarning().nospace() << idx << "\t\t" << "BEGIN\t\t\t" << instr->begin.castValue;
+ break;
+ case QQmlInstruction::StoreObjectQList:
+ qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT_QLIST";
+ break;
+ case QQmlInstruction::AssignObjectList:
+ qWarning().nospace() << idx << "\t\t" << "ASSIGN_OBJECT_LIST";
+ break;
+ case QQmlInstruction::FetchAttached:
+ qWarning().nospace() << idx << "\t\t" << "FETCH_ATTACHED\t\t" << instr->fetchAttached.id;
+ break;
+ case QQmlInstruction::FetchQList:
+ qWarning().nospace() << idx << "\t\t" << "FETCH_QLIST\t\t" << instr->fetch.property;
+ break;
+ case QQmlInstruction::FetchObject:
+ qWarning().nospace() << idx << "\t\t" << "FETCH\t\t\t" << instr->fetch.property;
+ break;
+ case QQmlInstruction::FetchValueType:
+ qWarning().nospace() << idx << "\t\t" << "FETCH_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type << "\t" << instr->fetchValue.bindingSkipList;
+ break;
+ case QQmlInstruction::PopFetchedObject:
+ qWarning().nospace() << idx << "\t\t" << "POP";
+ break;
+ case QQmlInstruction::PopQList:
+ qWarning().nospace() << idx << "\t\t" << "POP_QLIST";
+ break;
+ case QQmlInstruction::PopValueType:
+ qWarning().nospace() << idx << "\t\t" << "POP_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
+ break;
+ case QQmlInstruction::Defer:
+ qWarning().nospace() << idx << "\t\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
+ break;
+ default:
+ qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instructionType(instr);
+ break;
+ }
+#endif // QT_NO_DEBUG_STREAM
+}
+
+int QQmlInstruction::size(Type type)
+{
+#define QML_RETURN_INSTR_SIZE(I, FMT) case I: return QQmlInstructionMeta<(int)I>::Size;
+ switch (type) {
+ FOR_EACH_QML_INSTR(QML_RETURN_INSTR_SIZE)
+ default: return 0;
+ }
+#undef QML_RETURN_INSTR_SIZE
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlinstruction_p.h b/src/qml/qml/qqmlinstruction_p.h
new file mode 100644
index 0000000000..b7533aca68
--- /dev/null
+++ b/src/qml/qml/qqmlinstruction_p.h
@@ -0,0 +1,558 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLINSTRUCTION_P_H
+#define QQMLINSTRUCTION_P_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 <private/qqmlpropertycache_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#define FOR_EACH_QML_INSTR(F) \
+ F(Init, init) \
+ F(DeferInit, deferInit) \
+ F(Done, common) \
+ F(CreateCppObject, create) \
+ F(CreateQMLObject, createQml) \
+ F(CompleteQMLObject, completeQml) \
+ F(CreateSimpleObject, createSimple) \
+ F(SetId, setId) \
+ F(SetDefault, common) \
+ F(CreateComponent, createComponent) \
+ F(StoreMetaObject, storeMeta) \
+ F(StoreVariant, storeString) \
+ F(StoreVariantInteger, storeInteger) \
+ F(StoreVariantDouble, storeDouble) \
+ F(StoreVariantBool, storeBool) \
+ F(StoreVar, storeString) \
+ F(StoreVarInteger, storeInteger) \
+ F(StoreVarDouble, storeDouble) \
+ F(StoreVarBool, storeBool) \
+ F(StoreString, storeString) \
+ F(StoreStringList, storeString) \
+ F(StoreStringQList, storeString) \
+ F(StoreTrString, storeTrString) \
+ F(StoreTrIdString, storeTrIdString) \
+ F(StoreByteArray, storeByteArray) \
+ F(StoreUrl, storeUrl) \
+ F(StoreUrlQList, storeUrl) \
+ F(StoreFloat, storeFloat) \
+ F(StoreDouble, storeDouble) \
+ F(StoreDoubleQList, storeDouble) \
+ F(StoreBool, storeBool) \
+ F(StoreBoolQList, storeBool) \
+ F(StoreInteger, storeInteger) \
+ F(StoreIntegerQList, storeInteger) \
+ F(StoreColor, storeColor) \
+ F(StoreDate, storeDate) \
+ F(StoreTime, storeTime) \
+ F(StoreDateTime, storeDateTime) \
+ F(StorePoint, storePoint) \
+ F(StorePointF, storePointF) \
+ F(StoreSize, storeSize) \
+ F(StoreSizeF, storeSizeF) \
+ F(StoreRect, storeRect) \
+ F(StoreRectF, storeRectF) \
+ F(StoreVector3D, storeVector3D) \
+ F(StoreVector4D, storeVector4D) \
+ F(StoreObject, storeObject) \
+ F(AssignCustomType, assignCustomType) \
+ F(AssignSignalObject, assignSignalObject) \
+ F(StoreSignal, storeSignal) \
+ F(StoreImportedScript, storeScript) \
+ F(StoreScriptString, storeScriptString) \
+ F(BeginObject, begin) \
+ F(InitV8Bindings, initV8Bindings) \
+ F(StoreBinding, assignBinding) \
+ F(StoreBindingOnAlias, assignBinding) \
+ F(StoreV8Binding, assignBinding) \
+ F(StoreV4Binding, assignV4Binding) \
+ F(StoreValueSource, assignValueSource) \
+ F(StoreValueInterceptor, assignValueInterceptor) \
+ F(StoreObjectQList, common) \
+ F(AssignObjectList, assignObjectList) \
+ F(StoreVariantObject, storeObject) \
+ F(StoreVarObject, storeObject) \
+ F(StoreInterface, storeObject) \
+ F(FetchAttached, fetchAttached) \
+ F(FetchQList, fetchQmlList) \
+ F(FetchObject, fetch) \
+ F(PopQList, common) \
+ F(Defer, defer) \
+ F(PopFetchedObject, common) \
+ F(FetchValueType, fetchValue) \
+ F(PopValueType, fetchValue)
+
+#if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
+# define QML_THREADED_VME_INTERPRETER
+#endif
+
+#ifdef Q_ALIGNOF
+# define QML_INSTR_ALIGN_MASK (Q_ALIGNOF(QQmlInstruction) - 1)
+#else
+# define QML_INSTR_ALIGN_MASK (sizeof(void *) - 1)
+#endif
+
+#ifdef QML_THREADED_VME_INTERPRETER
+# define QML_INSTR_HEADER void *code;
+#else
+# define QML_INSTR_HEADER quint8 instructionType;
+#endif
+
+#define QML_INSTR_ENUM(I, FMT) I,
+#define QML_INSTR_SIZE(I, FMT) ((sizeof(QQmlInstruction::instr_##FMT) + QML_INSTR_ALIGN_MASK) & ~QML_INSTR_ALIGN_MASK)
+
+class QQmlCompiledData;
+union QQmlInstruction
+{
+ enum Type {
+ FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
+ };
+
+ struct instr_common {
+ QML_INSTR_HEADER
+ };
+ struct instr_init {
+ QML_INSTR_HEADER
+ int bindingsSize;
+ int parserStatusSize;
+ int contextCache;
+ int compiledBinding;
+ int objectStackSize;
+ int listStackSize;
+ };
+ struct instr_deferInit {
+ QML_INSTR_HEADER
+ int bindingsSize;
+ int parserStatusSize;
+ int objectStackSize;
+ int listStackSize;
+ };
+ struct instr_createQml {
+ QML_INSTR_HEADER
+ int type;
+ int bindingBits;
+ bool isRoot;
+ };
+ struct instr_completeQml {
+ QML_INSTR_HEADER
+ ushort column;
+ ushort line;
+ bool isRoot;
+ };
+ struct instr_create {
+ QML_INSTR_HEADER
+ int type;
+ int data;
+ ushort column;
+ ushort line;
+ bool isRoot;
+ };
+ struct instr_createSimple {
+ QML_INSTR_HEADER
+ void (*create)(void *);
+ int typeSize;
+ int type;
+ ushort column;
+ ushort line;
+ };
+ struct instr_storeMeta {
+ QML_INSTR_HEADER
+ int data;
+ int aliasData;
+ int propertyCache;
+ };
+ struct instr_setId {
+ QML_INSTR_HEADER
+ int value;
+ int index;
+ };
+ struct instr_assignValueSource {
+ QML_INSTR_HEADER
+ QQmlPropertyRawData property;
+ int owner;
+ int castValue;
+ };
+ struct instr_assignValueInterceptor {
+ QML_INSTR_HEADER
+ QQmlPropertyRawData property;
+ int owner;
+ int castValue;
+ };
+ struct instr_initV8Bindings {
+ QML_INSTR_HEADER
+ ushort programIndex;
+ ushort line;
+ };
+ struct instr_assignV4Binding {
+ QML_INSTR_HEADER
+ unsigned int property;
+ int value;
+ short context;
+ short owner;
+ bool isRoot;
+ ushort line;
+ ushort column;
+ };
+ struct instr_assignBinding {
+ QML_INSTR_HEADER
+ QQmlPropertyRawData property;
+ int value;
+ short context;
+ short owner;
+ bool isRoot;
+ ushort line;
+ ushort column;
+ };
+ struct instr_fetch {
+ QML_INSTR_HEADER
+ int property;
+ ushort line;
+ };
+ struct instr_fetchValue {
+ QML_INSTR_HEADER
+ int property;
+ int type;
+ quint32 bindingSkipList;
+ };
+ struct instr_fetchQmlList {
+ QML_INSTR_HEADER
+ int property;
+ int type;
+ };
+ struct instr_begin {
+ QML_INSTR_HEADER
+ int castValue;
+ };
+ struct instr_storeFloat {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ float value;
+ };
+ struct instr_storeDouble {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ double value;
+ };
+ struct instr_storeInteger {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int value;
+ };
+ struct instr_storeBool {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ bool value;
+ };
+ struct instr_storeString {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int value;
+ };
+ struct instr_storeTrString {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int context;
+ int text;
+ int comment;
+ int n;
+ };
+ struct instr_storeTrIdString {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int text;
+ int n;
+ };
+ struct instr_storeByteArray {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int value;
+ };
+ struct instr_storeScriptString {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int value;
+ int scope;
+ int bindingId;
+ ushort line;
+ ushort column;
+ };
+ struct instr_storeScript {
+ QML_INSTR_HEADER
+ int value;
+ };
+ struct instr_storeUrl {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int value;
+ };
+ struct instr_storeColor {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ unsigned int value;
+ };
+ struct instr_storeDate {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int value;
+ };
+ struct instr_storeTime {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QTime {
+ int mds;
+#if defined(Q_OS_WINCE)
+ int startTick;
+#endif
+ } time;
+ };
+ struct instr_storeDateTime {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int date;
+ instr_storeTime::QTime time;
+ };
+ struct instr_storeRect {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QRect {
+ int x1;
+ int y1;
+ int x2;
+ int y2;
+ } rect;
+ };
+ struct instr_storeRectF {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QRectF {
+ qreal xp;
+ qreal yp;
+ qreal w;
+ qreal h;
+ } rect;
+ };
+ struct instr_storeObject {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ ushort line;
+ };
+ struct instr_assignCustomType {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ int primitive;
+ int type;
+ ushort line;
+ };
+ struct instr_storeSignal {
+ QML_INSTR_HEADER
+ int signalIndex;
+ int value;
+ short context;
+ ushort line;
+ ushort column;
+ };
+ struct instr_assignSignalObject {
+ QML_INSTR_HEADER
+ int signal;
+ ushort line;
+ };
+ struct instr_createComponent {
+ QML_INSTR_HEADER
+ int count;
+ int endLine;
+ int metaObject;
+ ushort column;
+ ushort line;
+ bool isRoot;
+ };
+ struct instr_fetchAttached {
+ QML_INSTR_HEADER
+ int id;
+ ushort line;
+ };
+ struct instr_defer {
+ QML_INSTR_HEADER
+ int deferCount;
+ };
+ struct instr_assignObjectList {
+ QML_INSTR_HEADER
+ ushort line;
+ };
+ struct instr_storePoint {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QPoint {
+ int xp;
+ int yp;
+ } point;
+ };
+ struct instr_storePointF {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QPointF {
+ qreal xp;
+ qreal yp;
+ } point;
+ };
+ struct instr_storeSize {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QSize {
+ int wd;
+ int ht;
+ } size;
+ };
+ struct instr_storeSizeF {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QSizeF {
+ qreal wd;
+ qreal ht;
+ } size;
+ };
+ struct instr_storeVector3D {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QVector3D {
+ float xp;
+ float yp;
+ float zp;
+ } vector;
+ };
+ struct instr_storeVector4D {
+ QML_INSTR_HEADER
+ int propertyIndex;
+ struct QVector4D {
+ float xp;
+ float yp;
+ float zp;
+ float wp;
+ } vector;
+ };
+
+ instr_common common;
+ instr_init init;
+ instr_deferInit deferInit;
+ instr_create create;
+ instr_createQml createQml;
+ instr_completeQml completeQml;
+ instr_createSimple createSimple;
+ instr_storeMeta storeMeta;
+ instr_setId setId;
+ instr_assignValueSource assignValueSource;
+ instr_assignValueInterceptor assignValueInterceptor;
+ instr_initV8Bindings initV8Bindings;
+ instr_assignV4Binding assignV4Binding;
+ instr_assignBinding assignBinding;
+ instr_fetch fetch;
+ instr_fetchValue fetchValue;
+ instr_fetchQmlList fetchQmlList;
+ instr_begin begin;
+ instr_storeFloat storeFloat;
+ instr_storeDouble storeDouble;
+ instr_storeInteger storeInteger;
+ instr_storeBool storeBool;
+ instr_storeString storeString;
+ instr_storeTrString storeTrString;
+ instr_storeTrIdString storeTrIdString;
+ instr_storeByteArray storeByteArray;
+ instr_storeScriptString storeScriptString;
+ instr_storeScript storeScript;
+ instr_storeUrl storeUrl;
+ instr_storeColor storeColor;
+ instr_storeDate storeDate;
+ instr_storeTime storeTime;
+ instr_storeDateTime storeDateTime;
+ instr_storePoint storePoint;
+ instr_storePointF storePointF;
+ instr_storeSize storeSize;
+ instr_storeSizeF storeSizeF;
+ instr_storeRect storeRect;
+ instr_storeRectF storeRectF;
+ instr_storeVector3D storeVector3D;
+ instr_storeVector4D storeVector4D;
+ instr_storeObject storeObject;
+ instr_assignCustomType assignCustomType;
+ instr_storeSignal storeSignal;
+ instr_assignSignalObject assignSignalObject;
+ instr_createComponent createComponent;
+ instr_fetchAttached fetchAttached;
+ instr_defer defer;
+ instr_assignObjectList assignObjectList;
+
+ static int size(Type type);
+};
+
+template<int N>
+struct QQmlInstructionMeta {
+};
+
+#define QML_INSTR_META_TEMPLATE(I, FMT) \
+ template<> struct QQmlInstructionMeta<(int)QQmlInstruction::I> { \
+ enum { Size = QML_INSTR_SIZE(I, FMT) }; \
+ typedef QQmlInstruction::instr_##FMT DataType; \
+ static const DataType &data(const QQmlInstruction &instr) { return instr.FMT; } \
+ static void setData(QQmlInstruction &instr, const DataType &v) { instr.FMT = v; } \
+ };
+FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
+#undef QML_INSTR_META_TEMPLATE
+
+template<int Instr>
+class QQmlInstructionData : public QQmlInstructionMeta<Instr>::DataType
+{
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLINSTRUCTION_P_H
diff --git a/src/qml/qml/qqmlintegercache.cpp b/src/qml/qml/qqmlintegercache.cpp
new file mode 100644
index 0000000000..88ea3af2de
--- /dev/null
+++ b/src/qml/qml/qqmlintegercache.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlintegercache_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQmlIntegerCache::QQmlIntegerCache()
+{
+}
+
+QQmlIntegerCache::~QQmlIntegerCache()
+{
+}
+
+QString QQmlIntegerCache::findId(int value) const
+{
+ for (StringCache::ConstIterator iter = stringCache.begin();
+ iter != stringCache.end(); ++iter) {
+ if (iter.value() == value)
+ return iter.key();
+ }
+ return QString();
+}
+
+void QQmlIntegerCache::reserve(int size)
+{
+ stringCache.reserve(size);
+}
+
+void QQmlIntegerCache::add(const QString &id, int value)
+{
+ Q_ASSERT(!stringCache.contains(id));
+
+ stringCache.insert(id, value);
+}
+
+int QQmlIntegerCache::value(const QString &id)
+{
+ int *rv = stringCache.value(id);
+ return rv?*rv:-1;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlintegercache_p.h b/src/qml/qml/qqmlintegercache_p.h
new file mode 100644
index 0000000000..317a86b45a
--- /dev/null
+++ b/src/qml/qml/qqmlintegercache_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLINTEGERCACHE_P_H
+#define QQMLINTEGERCACHE_P_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 <private/qqmlrefcount_p.h>
+#include <private/qhashedstring_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlType;
+class QQmlEngine;
+class QQmlIntegerCache : public QQmlRefCount
+{
+public:
+ QQmlIntegerCache();
+ virtual ~QQmlIntegerCache();
+
+ inline int count() const;
+ void add(const QString &, int);
+ void reserve(int);
+
+ int value(const QString &);
+ inline int value(const QHashedV8String &);
+
+ QString findId(int value) const;
+
+private:
+ typedef QStringHash<int> StringCache;
+ StringCache stringCache;
+};
+
+int QQmlIntegerCache::value(const QHashedV8String &name)
+{
+ int *result = stringCache.value(name);
+ return result?*result:-1;
+}
+
+int QQmlIntegerCache::count() const
+{
+ return stringCache.count();
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLINTEGERCACHE_P_H
+
diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp
new file mode 100644
index 0000000000..00fd805ee0
--- /dev/null
+++ b/src/qml/qml/qqmllist.cpp
@@ -0,0 +1,417 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmllist.h"
+#include "qqmllist_p.h"
+#include "qqmlengine_p.h"
+#include "qqmlproperty_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQmlListReferencePrivate::QQmlListReferencePrivate()
+: propertyType(-1), refCount(1)
+{
+}
+
+QQmlListReference QQmlListReferencePrivate::init(const QQmlListProperty<QObject> &prop, int propType, QQmlEngine *engine)
+{
+ QQmlListReference rv;
+
+ if (!prop.object) return rv;
+
+ QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):0;
+
+ int listType = p?p->listType(propType):QQmlMetaType::listType(propType);
+ if (listType == -1) return rv;
+
+ rv.d = new QQmlListReferencePrivate;
+ rv.d->object = prop.object;
+ rv.d->elementType = p?p->rawMetaObjectForType(listType):QQmlMetaType::qmlType(listType)->baseMetaObject();
+ rv.d->property = prop;
+ rv.d->propertyType = propType;
+
+ return rv;
+}
+
+void QQmlListReferencePrivate::addref()
+{
+ Q_ASSERT(refCount > 0);
+ ++refCount;
+}
+
+void QQmlListReferencePrivate::release()
+{
+ Q_ASSERT(refCount > 0);
+ --refCount;
+ if (!refCount)
+ delete this;
+}
+
+/*!
+\class QQmlListReference
+\since 4.7
+\module QtQml
+\brief The QQmlListReference class allows the manipulation of QQmlListProperty properties.
+
+QQmlListReference allows C++ programs to read from, and assign values to a QML list property in a
+simple and type safe way. A QQmlListReference can be created by passing an object and property
+name or through a QQmlProperty instance. These two are equivalant:
+
+\code
+QQmlListReference ref1(object, "children");
+
+QQmlProperty ref2(object, "children");
+QQmlListReference ref2 = qvariant_cast<QQmlListReference>(ref2.read());
+\endcode
+
+Not all QML list properties support all operations. A set of methods, canAppend(), canAt(), canClear() and
+canCount() allow programs to query whether an operation is supported on a given property.
+
+QML list properties are typesafe. Only QObject's that derive from the correct base class can be assigned to
+the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported.
+Attempting to add objects of the incorrect type to a list property will fail.
+
+Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure
+that it does not request an out of range element using the count() method before calling at().
+*/
+
+/*!
+Constructs an invalid instance.
+*/
+QQmlListReference::QQmlListReference()
+: d(0)
+{
+}
+
+/*!
+Constructs a QQmlListReference for \a object's \a property. If \a property is not a list
+property, an invalid QQmlListReference is created. If \a object is destroyed after
+the reference is constructed, it will automatically become invalid. That is, it is safe to hold
+QQmlListReference instances even after \a object is deleted.
+
+Passing \a engine is required to access some QML created list properties. If in doubt, and an engine
+is available, pass it.
+*/
+QQmlListReference::QQmlListReference(QObject *object, const char *property, QQmlEngine *engine)
+: d(0)
+{
+ if (!object || !property) return;
+
+ QQmlPropertyData local;
+ QQmlPropertyData *data =
+ QQmlPropertyCache::property(engine, object, QLatin1String(property), local);
+
+ if (!data || !data->isQList()) return;
+
+ QQmlEnginePrivate *p = engine?QQmlEnginePrivate::get(engine):0;
+
+ int listType = p?p->listType(data->propType):QQmlMetaType::listType(data->propType);
+ if (listType == -1) return;
+
+ d = new QQmlListReferencePrivate;
+ d->object = object;
+ d->elementType = p?p->rawMetaObjectForType(listType):QQmlMetaType::qmlType(listType)->baseMetaObject();
+ d->propertyType = data->propType;
+
+ void *args[] = { &d->property, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex, args);
+}
+
+/*! \internal */
+QQmlListReference::QQmlListReference(const QQmlListReference &o)
+: d(o.d)
+{
+ if (d) d->addref();
+}
+
+/*! \internal */
+QQmlListReference &QQmlListReference::operator=(const QQmlListReference &o)
+{
+ if (o.d) o.d->addref();
+ if (d) d->release();
+ d = o.d;
+ return *this;
+}
+
+/*! \internal */
+QQmlListReference::~QQmlListReference()
+{
+ if (d) d->release();
+}
+
+/*!
+Returns true if the instance refers to a valid list property, otherwise false.
+*/
+bool QQmlListReference::isValid() const
+{
+ return d && d->object;
+}
+
+/*!
+Returns the list property's object. Returns 0 if the reference is invalid.
+*/
+QObject *QQmlListReference::object() const
+{
+ if (isValid()) return d->object;
+ else return 0;
+}
+
+/*!
+Returns the QMetaObject for the elements stored in the list property. Returns 0 if the reference
+is invalid.
+
+The QMetaObject can be used ahead of time to determine whether a given instance can be added
+to a list.
+*/
+const QMetaObject *QQmlListReference::listElementType() const
+{
+ if (isValid()) return d->elementType;
+ else return 0;
+}
+
+/*!
+Returns true if the list property can be appended to, otherwise false. Returns false if the
+reference is invalid.
+
+\sa append()
+*/
+bool QQmlListReference::canAppend() const
+{
+ return (isValid() && d->property.append);
+}
+
+/*!
+Returns true if the list property can queried by index, otherwise false. Returns false if the
+reference is invalid.
+
+\sa at()
+*/
+bool QQmlListReference::canAt() const
+{
+ return (isValid() && d->property.at);
+}
+
+/*!
+Returns true if the list property can be cleared, otherwise false. Returns false if the
+reference is invalid.
+
+\sa clear()
+*/
+bool QQmlListReference::canClear() const
+{
+ return (isValid() && d->property.clear);
+}
+
+/*!
+Returns true if the list property can be queried for its element count, otherwise false.
+Returns false if the reference is invalid.
+
+\sa count()
+*/
+bool QQmlListReference::canCount() const
+{
+ return (isValid() && d->property.count);
+}
+
+/*!
+Appends \a object to the list. Returns true if the operation succeeded, otherwise false.
+
+\sa canAppend()
+*/
+bool QQmlListReference::append(QObject *object) const
+{
+ if (!canAppend()) return false;
+
+ if (object && !QQmlPropertyPrivate::canConvert(object->metaObject(), d->elementType))
+ return false;
+
+ d->property.append(&d->property, object);
+
+ return true;
+}
+
+/*!
+Returns the list element at \a index, or 0 if the operation failed.
+
+\sa canAt()
+*/
+QObject *QQmlListReference::at(int index) const
+{
+ if (!canAt()) return 0;
+
+ return d->property.at(&d->property, index);
+}
+
+/*!
+Clears the list. Returns true if the operation succeeded, otherwise false.
+
+\sa canClear()
+*/
+bool QQmlListReference::clear() const
+{
+ if (!canClear()) return false;
+
+ d->property.clear(&d->property);
+
+ return true;
+}
+
+/*!
+Returns the number of objects in the list, or 0 if the operation failed.
+*/
+int QQmlListReference::count() const
+{
+ if (!canCount()) return 0;
+
+ return d->property.count(&d->property);
+}
+
+/*!
+\class QQmlListProperty
+\since 4.7
+\brief The QQmlListProperty class allows applications to expose list-like
+properties to QML.
+
+QML has many list properties, where more than one object value can be assigned.
+The use of a list property from QML looks like this:
+
+\code
+FruitBasket {
+ fruit: [
+ Apple {},
+ Orange{},
+ Banana{}
+ ]
+}
+\endcode
+
+The QQmlListProperty encapsulates a group of function pointers that represet the
+set of actions QML can perform on the list - adding items, retrieving items and
+clearing the list. In the future, additional operations may be supported. All
+list properties must implement the append operation, but the rest are optional.
+
+To provide a list property, a C++ class must implement the operation callbacks,
+and then return an appropriate QQmlListProperty value from the property getter.
+List properties should have no setter. In the example above, the Q_PROPERTY()
+declarative will look like this:
+
+\code
+Q_PROPERTY(QQmlListProperty<Fruit> fruit READ fruit);
+\endcode
+
+QML list properties are typesafe - in this case \c {Fruit} is a QObject type that
+\c {Apple}, \c {Orange} and \c {Banana} all derive from.
+
+\note QQmlListProperty can only be used for lists of QObject-derived object pointers.
+
+\sa {Object and List Property Types}
+
+*/
+
+/*!
+\fn QQmlListProperty::QQmlListProperty()
+\internal
+*/
+
+/*!
+\fn QQmlListProperty::QQmlListProperty(QObject *object, QList<T *> &list)
+
+Convenience constructor for making a QQmlListProperty value from an existing
+QList \a list. The \a list reference must remain valid for as long as \a object
+exists. \a object must be provided.
+
+Generally this constructor should not be used in production code, as a
+writable QList violates QML's memory management rules. However, this constructor
+can very useful while prototyping.
+*/
+
+/*!
+\fn QQmlListProperty::QQmlListProperty(QObject *object, void *data, AppendFunction append,
+ CountFunction count = 0, AtFunction at = 0,
+ ClearFunction clear = 0)
+
+Construct a QQmlListProperty from a set of operation functions. An opaque \a data handle
+may be passed which can be accessed from within the operation functions. The list property
+remains valid while \a object exists.
+
+The \a append operation is compulsory and must be provided, while the \a count, \a at and
+\a clear methods are optional.
+*/
+
+/*!
+\typedef QQmlListProperty::AppendFunction
+
+Synonym for \c {void (*)(QQmlListProperty<T> *property, T *value)}.
+
+Append the \a value to the list \a property.
+*/
+
+/*!
+\typedef QQmlListProperty::CountFunction
+
+Synonym for \c {int (*)(QQmlListProperty<T> *property)}.
+
+Return the number of elements in the list \a property.
+*/
+
+/*!
+\fn bool QQmlListProperty::operator==(const QQmlListProperty &other) const
+
+Returns true if this QQmlListProperty is equal to \a other, otherwise false.
+*/
+
+/*!
+\typedef QQmlListProperty::AtFunction
+
+Synonym for \c {T *(*)(QQmlListProperty<T> *property, int index)}.
+
+Return the element at position \a index in the list \a property.
+*/
+
+/*!
+\typedef QQmlListProperty::ClearFunction
+
+Synonym for \c {void (*)(QQmlListProperty<T> *property)}.
+
+Clear the list \a property.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h
new file mode 100644
index 0000000000..3f23cedbc2
--- /dev/null
+++ b/src/qml/qml/qqmllist.h
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLLIST_H
+#define QQMLLIST_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QObject;
+struct QMetaObject;
+
+#ifndef QQMLLISTPROPERTY
+#define QQMLLISTPROPERTY
+template<typename T>
+class QQmlListProperty {
+public:
+ typedef void (*AppendFunction)(QQmlListProperty<T> *, T*);
+ typedef int (*CountFunction)(QQmlListProperty<T> *);
+ typedef T *(*AtFunction)(QQmlListProperty<T> *, int);
+ typedef void (*ClearFunction)(QQmlListProperty<T> *);
+
+ QQmlListProperty()
+ : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {}
+ QQmlListProperty(QObject *o, QList<T *> &list)
+ : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at),
+ clear(qlist_clear), dummy1(0), dummy2(0) {}
+ QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0,
+ ClearFunction r = 0)
+ : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {}
+
+ bool operator==(const QQmlListProperty &o) const {
+ return object == o.object &&
+ data == o.data &&
+ append == o.append &&
+ count == o.count &&
+ at == o.at &&
+ clear == o.clear;
+ }
+
+ QObject *object;
+ void *data;
+
+ AppendFunction append;
+
+ CountFunction count;
+ AtFunction at;
+
+ ClearFunction clear;
+
+ void *dummy1;
+ void *dummy2;
+
+private:
+ static void qlist_append(QQmlListProperty *p, T *v) {
+ reinterpret_cast<QList<T *> *>(p->data)->append(v);
+ }
+ static int qlist_count(QQmlListProperty *p) {
+ return reinterpret_cast<QList<T *> *>(p->data)->count();
+ }
+ static T *qlist_at(QQmlListProperty *p, int idx) {
+ return reinterpret_cast<QList<T *> *>(p->data)->at(idx);
+ }
+ static void qlist_clear(QQmlListProperty *p) {
+ return reinterpret_cast<QList<T *> *>(p->data)->clear();
+ }
+};
+#endif
+
+class QQmlEngine;
+class QQmlListReferencePrivate;
+class Q_QML_EXPORT QQmlListReference
+{
+public:
+ QQmlListReference();
+ QQmlListReference(QObject *, const char *property, QQmlEngine * = 0);
+ QQmlListReference(const QQmlListReference &);
+ QQmlListReference &operator=(const QQmlListReference &);
+ ~QQmlListReference();
+
+ bool isValid() const;
+
+ QObject *object() const;
+ const QMetaObject *listElementType() const;
+
+ bool canAppend() const;
+ bool canAt() const;
+ bool canClear() const;
+ bool canCount() const;
+
+ bool append(QObject *) const;
+ QObject *at(int) const;
+ bool clear() const;
+ int count() const;
+
+private:
+ friend class QQmlListReferencePrivate;
+ QQmlListReferencePrivate* d;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlListReference)
+
+QT_END_HEADER
+
+#endif // QQMLLIST_H
diff --git a/src/qml/qml/qqmllist_p.h b/src/qml/qml/qqmllist_p.h
new file mode 100644
index 0000000000..0fe0ed3d44
--- /dev/null
+++ b/src/qml/qml/qqmllist_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLLIST_P_H
+#define QQMLLIST_P_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 "qqmllist.h"
+#include "qqmlguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQmlListReferencePrivate
+{
+public:
+ QQmlListReferencePrivate();
+
+ static QQmlListReference init(const QQmlListProperty<QObject> &, int, QQmlEngine *);
+
+ QQmlGuard<QObject> object;
+ const QMetaObject *elementType;
+ QQmlListProperty<QObject> property;
+ int propertyType;
+
+ void addref();
+ void release();
+ int refCount;
+
+ static inline QQmlListReferencePrivate *get(QQmlListReference *ref) {
+ return ref->d;
+ }
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QQMLLIST_P_H
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
new file mode 100644
index 0000000000..d684378832
--- /dev/null
+++ b/src/qml/qml/qqmllocale.cpp
@@ -0,0 +1,1126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmllocale_p.h"
+#include "qqmlengine_p.h"
+#include <private/qqmlcontext_p.h>
+#include <private/qjsconverter_impl_p.h>
+#include <QtCore/qnumeric.h>
+#include <QtCore/qdatetime.h>
+
+#include <private/qlocale_p.h>
+#include <private/qlocale_data_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8LocaleDataResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(LocaleDataType)
+public:
+ QV8LocaleDataResource(QV8Engine *e) : QV8ObjectResource(e) {}
+ QLocale locale;
+};
+
+#define GET_LOCALE_DATA_RESOURCE(OBJECT) \
+QV8LocaleDataResource *r = v8_resource_cast<QV8LocaleDataResource>(OBJECT); \
+if (!r) \
+ V8THROW_ERROR("Not a valid Locale object")
+
+static bool isLocaleObject(v8::Handle<v8::Value> val)
+{
+ if (!val->IsObject())
+ return false;
+
+ v8::Handle<v8::Object> localeObj = val->ToObject();
+ return localeObj->Has(v8::String::New("nativeLanguageName")); //XXX detect locale object properly
+}
+
+//--------------
+// Date extension
+
+static const char *dateToLocaleStringFunction =
+ "(function(toLocaleStringFunc) { "
+ " var orig_toLocaleString;"
+ " orig_toLocaleString = Date.prototype.toLocaleString;"
+ " Date.prototype.toLocaleString = (function() {"
+ " var val = toLocaleStringFunc.apply(this, arguments);"
+ " if (val == undefined) val = orig_toLocaleString.call(this);"
+ " return val;"
+ " })"
+ "})";
+
+static const char *dateToLocaleTimeStringFunction =
+ "(function(toLocaleTimeStringFunc) { "
+ " var orig_toLocaleTimeString;"
+ " orig_toLocaleTimeString = Date.prototype.toLocaleTimeString;"
+ " Date.prototype.toLocaleTimeString = (function() {"
+ " var val = toLocaleTimeStringFunc.apply(this, arguments);"
+ " if (val == undefined) val = orig_toLocaleTimeString.call(this);"
+ " return val;"
+ " })"
+ "})";
+
+static const char *dateToLocaleDateStringFunction =
+ "(function(toLocaleDateStringFunc) { "
+ " var orig_toLocaleDateString;"
+ " orig_toLocaleDateString = Date.prototype.toLocaleDateString;"
+ " Date.prototype.toLocaleDateString = (function() {"
+ " var val = toLocaleDateStringFunc.apply(this, arguments);"
+ " if (val == undefined) val = orig_toLocaleDateString.call(this);"
+ " return val;"
+ " })"
+ "})";
+
+
+static const char *dateFromLocaleStringFunction =
+ "(function(fromLocaleStringFunc) { "
+ " Date.fromLocaleString = (function() {"
+ " return fromLocaleStringFunc.apply(null, arguments);"
+ " })"
+ "})";
+
+static const char *dateFromLocaleTimeStringFunction =
+ "(function(fromLocaleTimeStringFunc) { "
+ " Date.fromLocaleTimeString = (function() {"
+ " return fromLocaleTimeStringFunc.apply(null, arguments);"
+ " })"
+ "})";
+
+static const char *dateFromLocaleDateStringFunction =
+ "(function(fromLocaleDateStringFunc) { "
+ " Date.fromLocaleDateString = (function() {"
+ " return fromLocaleDateStringFunc.apply(null, arguments);"
+ " })"
+ "})";
+
+
+static void registerFunction(QV8Engine *engine, const char *script, v8::InvocationCallback func)
+{
+ v8::Local<v8::Script> registerScript = v8::Script::New(v8::String::New(script), 0, 0, v8::Handle<v8::String>(), v8::Script::NativeMode);
+ v8::Local<v8::Value> result = registerScript->Run();
+ Q_ASSERT(result->IsFunction());
+ v8::Local<v8::Function> registerFunc = v8::Local<v8::Function>::Cast(result);
+ v8::Handle<v8::Value> args = V8FUNCTION(func, engine);
+ registerFunc->Call(v8::Local<v8::Object>::Cast(registerFunc), 1, &args);
+}
+
+void QQmlDateExtension::registerExtension(QV8Engine *engine)
+{
+ registerFunction(engine, dateToLocaleStringFunction, toLocaleString);
+ registerFunction(engine, dateToLocaleTimeStringFunction, toLocaleTimeString);
+ registerFunction(engine, dateToLocaleDateStringFunction, toLocaleDateString);
+ registerFunction(engine, dateFromLocaleStringFunction, fromLocaleString);
+ registerFunction(engine, dateFromLocaleTimeStringFunction, fromLocaleTimeString);
+ registerFunction(engine, dateFromLocaleDateStringFunction, fromLocaleDateString);
+}
+
+v8::Handle<v8::Value> QQmlDateExtension::toLocaleString(const v8::Arguments& args)
+{
+ if (args.Length() > 2)
+ return v8::Undefined();
+
+ if (!args.This()->IsDate())
+ return v8::Undefined();
+
+ QDateTime dt = QV8Engine::qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(args.This())->NumberValue());
+
+ if (args.Length() == 0) {
+ // Use QLocale for standard toLocaleString() function
+ QLocale locale;
+ return QJSConverter::toString(locale.toString(dt));
+ }
+
+ if (!isLocaleObject(args[0]))
+ return v8::Undefined(); // Use the default Date toLocaleString()
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+
+ QLocale::FormatType enumFormat = QLocale::LongFormat;
+ QString formattedDt;
+ if (args.Length() == 2) {
+ if (args[1]->IsString()) {
+ QString format = r->engine->toVariant(args[1], -1).toString();
+ formattedDt = r->locale.toString(dt, format);
+ } else if (args[1]->IsNumber()) {
+ quint32 intFormat = args[1]->ToNumber()->Value();
+ QLocale::FormatType format = QLocale::FormatType(intFormat);
+ formattedDt = r->locale.toString(dt, format);
+ } else {
+ V8THROW_ERROR("Locale: Date.toLocaleString(): Invalid datetime format");
+ }
+ } else {
+ formattedDt = r->locale.toString(dt, enumFormat);
+ }
+
+ return r->engine->toString(formattedDt);
+}
+
+v8::Handle<v8::Value> QQmlDateExtension::toLocaleTimeString(const v8::Arguments& args)
+{
+ if (args.Length() > 2)
+ return v8::Undefined();
+
+ if (!args.This()->IsDate())
+ return v8::Undefined();
+
+ QDateTime dt = QV8Engine::qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(args.This())->NumberValue());
+ QTime time = dt.time();
+
+ if (args.Length() == 0) {
+ // Use QLocale for standard toLocaleString() function
+ QLocale locale;
+ return QJSConverter::toString(locale.toString(time));
+ }
+
+ if (!isLocaleObject(args[0]))
+ return v8::Undefined(); // Use the default Date toLocaleTimeString()
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+
+ QLocale::FormatType enumFormat = QLocale::LongFormat;
+ QString formattedTime;
+ if (args.Length() == 2) {
+ if (args[1]->IsString()) {
+ QString format = r->engine->toVariant(args[1], -1).toString();
+ formattedTime = r->locale.toString(time, format);
+ } else if (args[1]->IsNumber()) {
+ quint32 intFormat = args[1]->ToNumber()->Value();
+ QLocale::FormatType format = QLocale::FormatType(intFormat);
+ formattedTime = r->locale.toString(time, format);
+ } else {
+ V8THROW_ERROR("Locale: Date.toLocaleTimeString(): Invalid time format");
+ }
+ } else {
+ formattedTime = r->locale.toString(time, enumFormat);
+ }
+
+ return r->engine->toString(formattedTime);
+}
+
+v8::Handle<v8::Value> QQmlDateExtension::toLocaleDateString(const v8::Arguments& args)
+{
+ if (args.Length() > 2)
+ return v8::Undefined();
+
+ if (!args.This()->IsDate())
+ return v8::Undefined();
+
+ QDateTime dt = QV8Engine::qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(args.This())->NumberValue());
+ QDate date = dt.date();
+
+ if (args.Length() == 0) {
+ // Use QLocale for standard toLocaleString() function
+ QLocale locale;
+ return QJSConverter::toString(locale.toString(date));
+ }
+
+ if (!isLocaleObject(args[0]))
+ return v8::Undefined(); // Use the default Date toLocaleDateString()
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+
+ QLocale::FormatType enumFormat = QLocale::LongFormat;
+ QString formattedDate;
+ if (args.Length() == 2) {
+ if (args[1]->IsString()) {
+ QString format = r->engine->toVariant(args[1], -1).toString();
+ formattedDate = r->locale.toString(date, format);
+ } else if (args[1]->IsNumber()) {
+ quint32 intFormat = args[1]->ToNumber()->Value();
+ QLocale::FormatType format = QLocale::FormatType(intFormat);
+ formattedDate = r->locale.toString(date, format);
+ } else {
+ V8THROW_ERROR("Locale: Date.loLocaleDateString(): Invalid date format");
+ }
+ } else {
+ formattedDate = r->locale.toString(date, enumFormat);
+ }
+
+ return r->engine->toString(formattedDate);
+}
+
+v8::Handle<v8::Value> QQmlDateExtension::fromLocaleString(const v8::Arguments& args)
+{
+ if (args.Length() == 1 && args[0]->IsString()) {
+ QLocale locale;
+ QString dateString = QJSConverter::toString(args[0]->ToString());
+ QDateTime dt = locale.toDateTime(dateString);
+ return QJSConverter::toDateTime(dt);
+ }
+
+ if (args.Length() < 1 || args.Length() > 3 || !isLocaleObject(args[0]))
+ V8THROW_ERROR("Locale: Date.fromLocaleString(): Invalid arguments");
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+
+ QLocale::FormatType enumFormat = QLocale::LongFormat;
+ QDateTime dt;
+ QString dateString = r->engine->toString(args[1]->ToString());
+ if (args.Length() == 3) {
+ if (args[2]->IsString()) {
+ QString format = r->engine->toString(args[2]->ToString());
+ dt = r->locale.toDateTime(dateString, format);
+ } else if (args[2]->IsNumber()) {
+ quint32 intFormat = args[2]->ToNumber()->Value();
+ QLocale::FormatType format = QLocale::FormatType(intFormat);
+ dt = r->locale.toDateTime(dateString, format);
+ } else {
+ V8THROW_ERROR("Locale: Date.fromLocaleString(): Invalid datetime format");
+ }
+ } else {
+ dt = r->locale.toDateTime(dateString, enumFormat);
+ }
+
+ return QJSConverter::toDateTime(dt);
+}
+
+v8::Handle<v8::Value> QQmlDateExtension::fromLocaleTimeString(const v8::Arguments& args)
+{
+ if (args.Length() == 1 && args[0]->IsString()) {
+ QLocale locale;
+ QString timeString = QJSConverter::toString(args[0]->ToString());
+ QTime time = locale.toTime(timeString);
+ QDateTime dt = QDateTime::currentDateTime();
+ dt.setTime(time);
+ return QJSConverter::toDateTime(dt);
+ }
+
+ if (args.Length() < 1 || args.Length() > 3 || !isLocaleObject(args[0]))
+ V8THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid arguments");
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+
+ QLocale::FormatType enumFormat = QLocale::LongFormat;
+ QTime tm;
+ QString dateString = r->engine->toString(args[1]->ToString());
+ if (args.Length() == 3) {
+ if (args[2]->IsString()) {
+ QString format = r->engine->toString(args[2]->ToString());
+ tm = r->locale.toTime(dateString, format);
+ } else if (args[2]->IsNumber()) {
+ quint32 intFormat = args[2]->ToNumber()->Value();
+ QLocale::FormatType format = QLocale::FormatType(intFormat);
+ tm = r->locale.toTime(dateString, format);
+ } else {
+ V8THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid datetime format");
+ }
+ } else {
+ tm = r->locale.toTime(dateString, enumFormat);
+ }
+
+ QDateTime dt = QDateTime::currentDateTime();
+ dt.setTime(tm);
+
+ return QJSConverter::toDateTime(dt);
+}
+
+v8::Handle<v8::Value> QQmlDateExtension::fromLocaleDateString(const v8::Arguments& args)
+{
+ if (args.Length() == 1 && args[0]->IsString()) {
+ QLocale locale;
+ QString dateString = QJSConverter::toString(args[0]->ToString());
+ QDate date = locale.toDate(dateString);
+ return QJSConverter::toDateTime(QDateTime(date));
+ }
+
+ if (args.Length() < 1 || args.Length() > 3 || !isLocaleObject(args[0]))
+ V8THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid arguments");
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+
+ QLocale::FormatType enumFormat = QLocale::LongFormat;
+ QDate dt;
+ QString dateString = r->engine->toString(args[1]->ToString());
+ if (args.Length() == 3) {
+ if (args[2]->IsString()) {
+ QString format = r->engine->toString(args[2]->ToString());
+ dt = r->locale.toDate(dateString, format);
+ } else if (args[2]->IsNumber()) {
+ quint32 intFormat = args[2]->ToNumber()->Value();
+ QLocale::FormatType format = QLocale::FormatType(intFormat);
+ dt = r->locale.toDate(dateString, format);
+ } else {
+ V8THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid datetime format");
+ }
+ } else {
+ dt = r->locale.toDate(dateString, enumFormat);
+ }
+
+ return QJSConverter::toDateTime(QDateTime(dt));
+}
+
+//-----------------
+// Number extension
+
+static const char *numberToLocaleStringFunction =
+ "(function(toLocaleStringFunc) { "
+ " var orig_toLocaleString;"
+ " orig_toLocaleString = Number.prototype.toLocaleString;"
+ " Number.prototype.toLocaleString = (function() {"
+ " var val = toLocaleStringFunc.apply(this, arguments);"
+ " if (val == undefined) val = orig_toLocaleString.call(this);"
+ " return val;"
+ " })"
+ "})";
+
+static const char *numberToLocaleCurrencyStringFunction =
+ "(function(toLocaleCurrencyStringFunc) { "
+ " Number.prototype.toLocaleCurrencyString = (function() {"
+ " return toLocaleCurrencyStringFunc.apply(this, arguments);"
+ " })"
+ "})";
+
+static const char *numberFromLocaleStringFunction =
+ "(function(fromLocaleStringFunc) { "
+ " Number.fromLocaleString = (function() {"
+ " return fromLocaleStringFunc.apply(null, arguments);"
+ " })"
+ "})";
+
+
+void QQmlNumberExtension::registerExtension(QV8Engine *engine)
+{
+ registerFunction(engine, numberToLocaleStringFunction, toLocaleString);
+ registerFunction(engine, numberToLocaleCurrencyStringFunction, toLocaleCurrencyString);
+ registerFunction(engine, numberFromLocaleStringFunction, fromLocaleString);
+}
+
+v8::Handle<v8::Value> QQmlNumberExtension::toLocaleString(const v8::Arguments& args)
+{
+ if (args.Length() > 3)
+ V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
+
+ double number = args.This()->ToNumber()->Value();
+
+ if (args.Length() == 0) {
+ // Use QLocale for standard toLocaleString() function
+ QLocale locale;
+ return QJSConverter::toString(locale.toString(number));
+ }
+
+ if (!isLocaleObject(args[0]))
+ return v8::Undefined(); // Use the default Number toLocaleString()
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+
+ uint16_t format = 'f';
+ if (args.Length() > 1) {
+ if (!args[1]->IsString())
+ V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
+ v8::Local<v8::String> fs = args[1]->ToString();
+ if (!fs.IsEmpty() && fs->Length())
+ format = fs->GetCharacter(0);
+ }
+ int prec = 2;
+ if (args.Length() > 2) {
+ if (!args[2]->IsNumber())
+ V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
+ prec = args[2]->IntegerValue();
+ }
+
+ return r->engine->toString(r->locale.toString(number, (char)format, prec));
+}
+
+v8::Handle<v8::Value> QQmlNumberExtension::toLocaleCurrencyString(const v8::Arguments& args)
+{
+ if (args.Length() > 2)
+ V8THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");
+
+ double number = args.This()->ToNumber()->Value();
+
+ if (args.Length() == 0) {
+ // Use QLocale for standard toLocaleString() function
+ QLocale locale;
+ return QJSConverter::toString(locale.toString(number));
+ }
+
+ if (!isLocaleObject(args[0]))
+ V8THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+
+ QString symbol;
+ if (args.Length() > 1) {
+ if (!args[1]->IsString())
+ V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
+ symbol = r->engine->toString(args[1]->ToString());
+ }
+
+ return r->engine->toString(r->locale.toCurrencyString(number, symbol));
+}
+
+v8::Handle<v8::Value> QQmlNumberExtension::fromLocaleString(const v8::Arguments& args)
+{
+ if (args.Length() < 1 || args.Length() > 2)
+ V8THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");
+
+ int numberIdx = 0;
+ QLocale locale;
+
+ if (args.Length() == 2) {
+ if (!isLocaleObject(args[0]))
+ V8THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");
+
+ GET_LOCALE_DATA_RESOURCE(args[0]->ToObject());
+ locale = r->locale;
+
+ numberIdx = 1;
+ }
+
+ v8::Local<v8::String> ns = args[numberIdx]->ToString();
+ if (ns.IsEmpty() || ns->Length() == 0)
+ return v8::Number::New(Q_QNAN);
+
+ bool ok = false;
+ double val = locale.toDouble(QJSConverter::toString(ns), &ok);
+
+ if (!ok)
+ V8THROW_ERROR("Locale: Number.fromLocaleString(): Invalid format")
+
+ return v8::Number::New(val);
+}
+
+//--------------
+// Locale object
+
+static v8::Handle<v8::Value> locale_get_firstDayOfWeek(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ GET_LOCALE_DATA_RESOURCE(info.This());
+ int fdow = int(r->locale.firstDayOfWeek());
+ if (fdow == 7)
+ fdow = 0; // Qt::Sunday = 7, but Sunday is 0 in JS Date
+ return v8::Integer::New(fdow);
+}
+
+static v8::Handle<v8::Value> locale_get_measurementSystem(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ GET_LOCALE_DATA_RESOURCE(info.This());
+ return v8::Integer::New(r->locale.measurementSystem());
+}
+
+static v8::Handle<v8::Value> locale_get_textDirection(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ GET_LOCALE_DATA_RESOURCE(info.This());
+ return v8::Integer::New(r->locale.textDirection());
+}
+
+static v8::Handle<v8::Value> locale_get_weekDays(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ GET_LOCALE_DATA_RESOURCE(info.This());
+
+ QList<Qt::DayOfWeek> days = r->locale.weekdays();
+
+ v8::Handle<v8::Array> result = v8::Array::New(days.size());
+ for (int i = 0; i < days.size(); ++i) {
+ int day = days.at(i);
+ if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
+ day = 0;
+ result->Set(i, v8::Integer::New(day));
+ }
+
+ return result;
+}
+
+static v8::Handle<v8::Value> locale_get_uiLanguages(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ GET_LOCALE_DATA_RESOURCE(info.This());
+
+ QStringList langs = r->locale.uiLanguages();
+ v8::Handle<v8::Array> result = v8::Array::New(langs.size());
+ for (int i = 0; i < langs.size(); ++i) {
+ result->Set(i, r->engine->toString(langs.at(i)));
+ }
+
+ return result;
+}
+
+static v8::Handle<v8::Value> locale_currencySymbol(const v8::Arguments &args)
+{
+ GET_LOCALE_DATA_RESOURCE(args.This());
+
+ if (args.Length() > 1)
+ V8THROW_ERROR("Locale: currencySymbol(): Invalid arguments");
+
+ QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol;
+ if (args.Length() == 1) {
+ quint32 intFormat = args[0]->ToNumber()->Value();
+ format = QLocale::CurrencySymbolFormat(intFormat);
+ }
+
+ return r->engine->toString(r->locale.currencySymbol(format));
+}
+
+#define LOCALE_FORMAT(FUNC) \
+static v8::Handle<v8::Value> locale_ ##FUNC (const v8::Arguments &args) { \
+ GET_LOCALE_DATA_RESOURCE(args.This());\
+ if (args.Length() > 1) \
+ V8THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \
+ QLocale::FormatType format = QLocale::LongFormat;\
+ if (args.Length() == 1) { \
+ quint32 intFormat = args[0]->Uint32Value(); \
+ format = QLocale::FormatType(intFormat); \
+ } \
+ return r->engine->toString(r->locale. FUNC (format)); \
+}
+
+LOCALE_FORMAT(dateTimeFormat)
+LOCALE_FORMAT(timeFormat)
+LOCALE_FORMAT(dateFormat)
+
+// +1 added to idx because JS is 0-based, whereas QLocale months begin at 1.
+#define LOCALE_FORMATTED_MONTHNAME(VARIABLE) \
+static v8::Handle<v8::Value> locale_ ## VARIABLE (const v8::Arguments &args) {\
+ GET_LOCALE_DATA_RESOURCE(args.This()); \
+ if (args.Length() < 1 || args.Length() > 2) \
+ V8THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
+ QLocale::FormatType enumFormat = QLocale::LongFormat; \
+ int idx = args[0]->IntegerValue() + 1; \
+ if (idx < 1 || idx > 12) \
+ V8THROW_ERROR("Locale: Invalid month"); \
+ QString name; \
+ if (args.Length() == 2) { \
+ if (args[1]->IsNumber()) { \
+ quint32 intFormat = args[1]->IntegerValue(); \
+ QLocale::FormatType format = QLocale::FormatType(intFormat); \
+ name = r->locale. VARIABLE(idx, format); \
+ } else { \
+ V8THROW_ERROR("Locale: Invalid datetime format"); \
+ } \
+ } else { \
+ name = r->locale. VARIABLE(idx, enumFormat); \
+ } \
+ return r->engine->toString(name); \
+}
+
+// 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date
+#define LOCALE_FORMATTED_DAYNAME(VARIABLE) \
+static v8::Handle<v8::Value> locale_ ## VARIABLE (const v8::Arguments &args) {\
+ GET_LOCALE_DATA_RESOURCE(args.This()); \
+ if (args.Length() < 1 || args.Length() > 2) \
+ V8THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
+ QLocale::FormatType enumFormat = QLocale::LongFormat; \
+ int idx = args[0]->IntegerValue(); \
+ if (idx < 0 || idx > 7) \
+ V8THROW_ERROR("Locale: Invalid day"); \
+ if (idx == 0) idx = 7; \
+ QString name; \
+ if (args.Length() == 2) { \
+ if (args[1]->IsNumber()) { \
+ quint32 intFormat = args[1]->ToNumber()->Value(); \
+ QLocale::FormatType format = QLocale::FormatType(intFormat); \
+ name = r->locale. VARIABLE(idx, format); \
+ } else { \
+ V8THROW_ERROR("Locale: Invalid datetime format"); \
+ } \
+ } else { \
+ name = r->locale. VARIABLE(idx, enumFormat); \
+ } \
+ return r->engine->toString(name); \
+}
+
+
+#define LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(FT, VARIABLE, ENGINE) \
+ FT->PrototypeTemplate()->Set(v8::String::New( #VARIABLE ), V8FUNCTION(locale_ ## VARIABLE, ENGINE));
+
+LOCALE_FORMATTED_MONTHNAME(monthName)
+LOCALE_FORMATTED_MONTHNAME(standaloneMonthName)
+LOCALE_FORMATTED_DAYNAME(dayName)
+LOCALE_FORMATTED_DAYNAME(standaloneDayName)
+
+#define LOCALE_STRING_PROPERTY(VARIABLE) static v8::Handle<v8::Value> locale_get_ ## VARIABLE (v8::Local<v8::String>, const v8::AccessorInfo &info) \
+{ \
+ GET_LOCALE_DATA_RESOURCE(info.This()); \
+ return r->engine->toString(r->locale. VARIABLE());\
+}
+
+#define LOCALE_REGISTER_STRING_ACCESSOR(FT, VARIABLE) \
+ FT ->PrototypeTemplate()->SetAccessor( v8::String::New( #VARIABLE ), locale_get_ ## VARIABLE )
+
+
+LOCALE_STRING_PROPERTY(name)
+LOCALE_STRING_PROPERTY(nativeLanguageName)
+LOCALE_STRING_PROPERTY(nativeCountryName)
+LOCALE_STRING_PROPERTY(decimalPoint)
+LOCALE_STRING_PROPERTY(groupSeparator)
+LOCALE_STRING_PROPERTY(percent)
+LOCALE_STRING_PROPERTY(zeroDigit)
+LOCALE_STRING_PROPERTY(negativeSign)
+LOCALE_STRING_PROPERTY(positiveSign)
+LOCALE_STRING_PROPERTY(exponential)
+LOCALE_STRING_PROPERTY(amText)
+LOCALE_STRING_PROPERTY(pmText)
+
+class QV8LocaleDataDeletable : public QV8Engine::Deletable
+{
+public:
+ QV8LocaleDataDeletable(QV8Engine *engine);
+ ~QV8LocaleDataDeletable();
+
+ v8::Persistent<v8::Function> constructor;
+};
+
+QV8LocaleDataDeletable::QV8LocaleDataDeletable(QV8Engine *engine)
+{
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, name);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, nativeLanguageName);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, nativeCountryName);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, decimalPoint);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, groupSeparator);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, percent);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, zeroDigit);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, negativeSign);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, positiveSign);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, exponential);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, amText);
+ LOCALE_REGISTER_STRING_ACCESSOR(ft, pmText);
+
+ ft->PrototypeTemplate()->Set(v8::String::New("currencySymbol"), V8FUNCTION(locale_currencySymbol, engine));
+
+ ft->PrototypeTemplate()->Set(v8::String::New("dateTimeFormat"), V8FUNCTION(locale_dateTimeFormat, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("dateFormat"), V8FUNCTION(locale_dateFormat, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("timeFormat"), V8FUNCTION(locale_timeFormat, engine));
+
+ LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(ft, monthName, engine);
+ LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(ft, standaloneMonthName, engine);
+ LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(ft, dayName, engine);
+ LOCALE_REGISTER_FORMATTED_NAME_FUNCTION(ft, standaloneDayName, engine);
+
+ ft->PrototypeTemplate()->SetAccessor(v8::String::New("firstDayOfWeek"), locale_get_firstDayOfWeek);
+ ft->PrototypeTemplate()->SetAccessor(v8::String::New("weekDays"), locale_get_weekDays);
+ ft->PrototypeTemplate()->SetAccessor(v8::String::New("measurementSystem"), locale_get_measurementSystem);
+ ft->PrototypeTemplate()->SetAccessor(v8::String::New("textDirection"), locale_get_textDirection);
+ ft->PrototypeTemplate()->SetAccessor(v8::String::New("uiLanguages"), locale_get_uiLanguages);
+
+ constructor = qPersistentNew(ft->GetFunction());
+}
+
+QV8LocaleDataDeletable::~QV8LocaleDataDeletable()
+{
+ qPersistentDispose(constructor);
+}
+
+V8_DEFINE_EXTENSION(QV8LocaleDataDeletable, localeV8Data);
+
+/*!
+ \qmlclass Locale QQmlLocale
+ \inqmlmodule QtQuick 2
+ \brief The Locale object provides locale specific properties and formatted data.
+
+ The Locale object is created via the \l{QML:Qt::locale()}{Qt.locale()} function. It cannot be created
+ directly.
+
+ The \l{QML:Qt::locale()}{Qt.locale()} function returns a JS Locale object representing the
+ locale with the specified name, which has the format
+ "language[_territory][.codeset][@modifier]" or "C".
+
+ Locale supports the concept of a default locale, which is
+ determined from the system's locale settings at application
+ startup. If no parameter is passed to Qt.locale() the default
+ locale object is returned.
+
+ The Locale object provides a number of functions and properties
+ providing data for the specified locale.
+
+ The Locale object may also be passed to the \l Date and \l Number toLocaleString()
+ and fromLocaleString() methods in order to convert to/from strings using
+ the specified locale.
+
+ This example shows the current date formatted for the German locale:
+
+ \code
+ import QtQuick 2.0
+
+ Text {
+ text: "The date is: " + Date().toLocaleString(Qt.locale("de_DE"))
+ }
+ \endcode
+
+ The following example displays the specified number
+ in the correct format for the default locale:
+
+ \code
+ import QtQuick 2.0
+
+ Text {
+ text: "The value is: " + Number(23443.34).toLocaleString(Qt.locale())
+ }
+ \endcode
+
+ QtQuick Locale's data is based on Common Locale Data Repository v1.8.1.
+
+ The double-to-string and string-to-double conversion functions are
+ covered by the following licenses:
+
+ \legalese
+ Copyright (c) 1991 by AT&T.
+
+ Permission to use, copy, modify, and distribute this software for any
+ purpose without fee is hereby granted, provided that this entire notice
+ is included in all copies of any software which is or includes a copy
+ or modification of this software and in all copies of the supporting
+ documentation for such software.
+
+ THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
+ REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+
+ This product includes software developed by the University of
+ California, Berkeley and its contributors.
+
+ \sa {QtQuick2::Date}{Date} {QtQuick2::Number}{Number}
+*/
+
+QQmlLocale::QQmlLocale()
+{
+}
+
+QQmlLocale::~QQmlLocale()
+{
+}
+
+v8::Handle<v8::Value> QQmlLocale::locale(QV8Engine *v8engine, const QString &locale)
+{
+ QV8LocaleDataDeletable *d = localeV8Data(v8engine);
+ v8::Local<v8::Object> v8Value = d->constructor->NewInstance();
+ QV8LocaleDataResource *r = new QV8LocaleDataResource(v8engine);
+ if (locale.isEmpty())
+ r->locale = QLocale();
+ else
+ r->locale = QLocale(locale);
+ v8Value->SetExternalResource(r);
+
+ return v8Value;
+}
+
+static const char *localeCompareFunction =
+ "(function(localeCompareFunc) { "
+ " var orig_localeCompare;"
+ " orig_localeCompare = String.prototype.localeCompare;"
+ " String.prototype.localeCompare = (function() {"
+ " var val = localeCompareFunc.apply(this, arguments);"
+ " if (val == undefined) val = orig_localeCompare.call(this);"
+ " return val;"
+ " })"
+ "})";
+
+void QQmlLocale::registerStringLocaleCompare(QV8Engine *engine)
+{
+ registerFunction(engine, localeCompareFunction, localeCompare);
+}
+
+v8::Handle<v8::Value> QQmlLocale::localeCompare(const v8::Arguments &args)
+{
+ if (args.Length() != 1 || (!args[0]->IsString() && !args[0]->IsStringObject()))
+ return v8::Undefined();
+
+ if (!args.This()->IsString() && !args.This()->IsStringObject())
+ return v8::Undefined();
+
+ QString thisString = QJSConverter::toString(args.This()->ToString());
+ QString thatString = QJSConverter::toString(args[0]->ToString());
+
+ return v8::Integer::New(QString::localeAwareCompare(thisString, thatString));
+}
+
+/*!
+ \enum QtQuick2::Locale::FormatType
+
+ This enumeration describes the types of format that can be used when
+ converting Date objects to strings.
+
+ \value LongFormat The long version of day and month names; for
+ example, returning "January" as a month name.
+
+ \value ShortFormat The short version of day and month names; for
+ example, returning "Jan" as a month name.
+
+ \value NarrowFormat A special version of day and month names for
+ use when space is limited; for example, returning "J" as a month
+ name. Note that the narrow format might contain the same text for
+ different months and days or it can even be an empty string if the
+ locale doesn't support narrow names, so you should avoid using it
+ for date formatting. Also, for the system locale this format is
+ the same as ShortFormat.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::name
+
+ Holds the language and country of this locale as a
+ string of the form "language_country", where
+ language is a lowercase, two-letter ISO 639 language code,
+ and country is an uppercase, two- or three-letter ISO 3166 country code.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::decimalPoint
+
+ Holds the decimal point character of this locale.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::groupSeparator
+
+ Holds the group separator character of this locale.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::percent
+
+ Holds the percent character of this locale.
+*/
+
+
+/*!
+ \qmlproperty string QtQuick2::Locale::zeroDigit
+
+ Holds Returns the zero digit character of this locale.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::negativeSign
+
+ Holds the negative sign character of this locale.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::positiveSign
+
+ Holds the positive sign character of this locale.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::exponential
+
+ Holds the exponential character of this locale.
+*/
+
+/*!
+ \qmlmethod string QtQuick2::Locale::dateTimeFormat(type)
+
+ Returns the date time format used for the current locale.
+ \a type specifies the FormatType to return.
+
+ \sa {QtQuick2::Date}{Date}
+*/
+
+/*!
+ \qmlmethod string QtQuick2::Locale::dateFormat(type)
+
+ Returns the date format used for the current locale.
+ \a type specifies the FormatType to return.
+
+ \sa {QtQuick2::Date}{Date}
+*/
+
+/*!
+ \qmlmethod string QtQuick2::Locale::timeFormat(type)
+
+ Returns the time format used for the current locale.
+ \a type specifies the FormatType to return.
+
+ \sa {QtQuick2::Date}{Date}
+*/
+
+/*!
+ \qmlmethod string QtQuick2::Locale::monthName(month, type)
+
+ Returns the localized name of \a month (0-11), in the optional
+ \l FortmatType specified by \a type.
+
+ \note the QLocale C++ API expects a range of (1-12), however Locale.monthName()
+ expects 0-11 as per the JS Date object.
+
+ \sa dayName(), standaloneMonthName()
+*/
+
+/*!
+ \qmlmethod string QtQuick2::Locale::standaloneMonthName(month, type)
+
+ Returns the localized name of \a month (0-11) that is used as a
+ standalone text, in the optional \l FormatType specified by \a type.
+
+ If the locale information doesn't specify the standalone month
+ name then return value is the same as in monthName().
+
+ \note the QLocale C++ API expects a range of (1-12), however Locale.standaloneMonthName()
+ expects 0-11 as per the JS Date object.
+
+ \sa monthName(), standaloneDayName()
+*/
+
+/*!
+ \qmlmethod string QtQuick2::Locale::dayName(day, type)
+
+ Returns the localized name of the \a day (where 0 represents
+ Sunday, 1 represents Monday and so on), in the optional
+ \l FormatType specified by \a type.
+
+ \sa monthName(), standaloneDayName()
+*/
+
+/*!
+ \qmlmethod string QtQuick2::Locale::standaloneDayName(day, type)
+
+ Returns the localized name of the \a day (where 0 represents
+ Sunday, 1 represents Monday and so on) that is used as a
+ standalone text, in the \l FormatType specified by \a type.
+
+ If the locale information does not specify the standalone day
+ name then return value is the same as in dayName().
+
+ \sa dayName(), standaloneMonthName()
+*/
+
+/*!
+ \qmlproperty enumeration QtQuick2::Locale::firstDayOfWeek
+
+ Holds the first day of the week according to the current locale.
+
+ \list
+ \o Locale.Sunday = 0
+ \o Locale.Monday = 1
+ \o Locale.Tuesday = 2
+ \o Locale.Wednesday = 3
+ \o Locale.Thursday = 4
+ \o Locale.Friday = 5
+ \o Locale.Saturday = 6
+ \endlist
+
+ \note that these values match the JS Date API which is different
+ from the Qt C++ API where Qt::Sunday = 7.
+*/
+
+/*!
+ \qmlproperty Array<int> QtQuick2::Locale::weekDays
+
+ Holds an array of days that are considered week days according to the current locale,
+ where Sunday is 0 and Saturday is 6.
+
+ \sa firstDayOfWeek
+*/
+
+/*!
+ \qmlproperty Array<string> QtQuick2::Locale::uiLanguages
+
+ Returns an ordered list of locale names for translation purposes in
+ preference order.
+
+ The return value represents locale names that the user expects to see the
+ UI translation in.
+
+ The first item in the list is the most preferred one.
+*/
+
+/*!
+ \qmlproperty enumeration QtQuick2::Locale::textDirection
+
+ Holds the text direction of the language:
+ \list
+ \o Qt.LeftToRight
+ \o Qt.RightToLeft
+ \endlist
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::amText
+
+ The localized name of the "AM" suffix for times specified using the conventions of the 12-hour clock.
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::pmText
+
+ The localized name of the "PM" suffix for times specified using the conventions of the 12-hour clock.
+*/
+
+/*!
+ \qmlmethod string QtQuick2::Locale::currencySymbol(format)
+
+ Returns the currency symbol for the specified \a format:
+ \list
+ \o Locale.CurrencyIsoCode a ISO-4217 code of the currency.
+ \o Locale.CurrencySymbol a currency symbol.
+ \o Locale.CurrencyDisplayName a user readable name of the currency.
+ \endlist
+ \sa Number::toLocaleCurrencyString()
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::nativeLanguageName
+
+ Holds a native name of the language for the locale. For example
+ "Schwiizertüütsch" for Swiss-German locale.
+
+ \sa nativeCountryName
+*/
+
+/*!
+ \qmlproperty string QtQuick2::Locale::nativeCountryName
+
+ Holds a native name of the country for the locale. For example
+ "España" for Spanish/Spain locale.
+
+ \sa nativeLanguageName
+*/
+
+/*!
+ \qmlproperty enumeration QtQuick2::Locale::measurementSystem
+
+ This property defines which units are used for measurement.
+
+ \list
+ \o Locale.MetricSystem This value indicates metric units, such as meters,
+ centimeters and millimeters.
+ \o Locale.ImperialSystem This value indicates imperial units, such as inches and
+ miles. There are several distinct imperial systems in the world; this
+ value stands for the official United States imperial units.
+ \endlist
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
new file mode 100644
index 0000000000..2763ce4fc3
--- /dev/null
+++ b/src/qml/qml/qqmllocale_p.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLLOCALE_H
+#define QQMLLOCALE_H
+
+#include <qqml.h>
+
+#include <QtCore/qlocale.h>
+#include <QtCore/qobject.h>
+#include <private/qv8engine_p.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlDateExtension
+{
+public:
+ static void registerExtension(QV8Engine *engine);
+
+private:
+ static v8::Handle<v8::Value> toLocaleString(const v8::Arguments& args);
+ static v8::Handle<v8::Value> toLocaleTimeString(const v8::Arguments& args);
+ static v8::Handle<v8::Value> toLocaleDateString(const v8::Arguments& args);
+ static v8::Handle<v8::Value> fromLocaleString(const v8::Arguments& args);
+ static v8::Handle<v8::Value> fromLocaleTimeString(const v8::Arguments& args);
+ static v8::Handle<v8::Value> fromLocaleDateString(const v8::Arguments& args);
+};
+
+
+class QQmlNumberExtension
+{
+public:
+ static void registerExtension(QV8Engine *engine);
+
+private:
+ static v8::Handle<v8::Value> toLocaleString(const v8::Arguments& args);
+ static v8::Handle<v8::Value> fromLocaleString(const v8::Arguments& args);
+ static v8::Handle<v8::Value> toLocaleCurrencyString(const v8::Arguments& args);
+};
+
+
+class Q_AUTOTEST_EXPORT QQmlLocale
+{
+ Q_GADGET
+ Q_ENUMS(MeasurementSystem)
+ Q_ENUMS(FormatType)
+ Q_ENUMS(CurrencySymbolFormat)
+ Q_ENUMS(DayOfWeek)
+
+public:
+ ~QQmlLocale();
+
+ enum MeasurementSystem {
+ MetricSystem = QLocale::MetricSystem,
+ ImperialSystem = QLocale::ImperialSystem
+ };
+ enum FormatType {
+ LongFormat = QLocale::LongFormat,
+ ShortFormat = QLocale::ShortFormat,
+ NarrowFormat = QLocale::NarrowFormat
+ };
+ enum CurrencySymbolFormat {
+ CurrencyIsoCode = QLocale::CurrencyIsoCode,
+ CurrencySymbol = QLocale::CurrencySymbol,
+ CurrencyDisplayName = QLocale::CurrencyDisplayName
+ };
+ // Qt defines Sunday as 7, but JS Date assigns Sunday 0
+ enum DayOfWeek {
+ Sunday = 0,
+ Monday = Qt::Monday,
+ Tuesday = Qt::Tuesday,
+ Wednesday = Qt::Wednesday,
+ Thursday = Qt::Thursday,
+ Friday = Qt::Friday,
+ Saturday = Qt::Saturday
+ };
+
+ static v8::Handle<v8::Value> locale(QV8Engine *v8engine, const QString &lang);
+
+ static void registerStringLocaleCompare(QV8Engine *engine);
+
+private:
+ QQmlLocale();
+
+ static v8::Handle<v8::Value> localeCompare(const v8::Arguments &args);
+};
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
new file mode 100644
index 0000000000..2061530dc5
--- /dev/null
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -0,0 +1,1359 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqmlprivate.h>
+#include "qqmlmetatype_p.h"
+
+#include <private/qqmlproxymetaobject_p.h>
+#include <private/qqmlcustomparser_p.h>
+#include <private/qqmlguard_p.h>
+#include <private/qhashedstring_p.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qbitarray.h>
+#include <QtCore/qreadwritelock.h>
+#include <QtCore/private/qmetaobject_p.h>
+
+#include <qmetatype.h>
+#include <qobjectdefs.h>
+#include <qbytearray.h>
+#include <qreadwritelock.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qvector.h>
+
+#include <ctype.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QQmlMetaTypeData
+{
+ QQmlMetaTypeData();
+ ~QQmlMetaTypeData();
+ QList<QQmlType *> types;
+ typedef QHash<int, QQmlType *> Ids;
+ Ids idToType;
+ typedef QHash<QString, QQmlType *> Names;
+ Names nameToType;
+ typedef QHash<const QMetaObject *, QQmlType *> MetaObjects;
+ MetaObjects metaObjectToType;
+ typedef QHash<int, QQmlMetaType::StringConverter> StringConverters;
+ StringConverters stringConverters;
+
+ struct VersionedUri {
+ VersionedUri()
+ : majorVersion(0) {}
+ VersionedUri(const QString &uri, int majorVersion)
+ : uri(uri), majorVersion(majorVersion) {}
+ bool operator==(const VersionedUri &other) const {
+ return other.majorVersion == majorVersion && other.uri == uri;
+ }
+ QString uri;
+ int majorVersion;
+ };
+ typedef QHash<VersionedUri, QQmlTypeModule *> TypeModules;
+ TypeModules uriToModule;
+
+ struct ModuleApiList {
+ ModuleApiList() : sorted(true) {}
+ QList<QQmlMetaType::ModuleApi> moduleApis;
+ bool sorted;
+ };
+ typedef QHash<QString, ModuleApiList> ModuleApis;
+ ModuleApis moduleApis;
+ int moduleApiCount;
+
+ QBitArray objects;
+ QBitArray interfaces;
+ QBitArray lists;
+
+ QList<QQmlPrivate::AutoParentFunction> parentFunctions;
+};
+
+class QQmlTypeModulePrivate
+{
+public:
+ QQmlTypeModulePrivate()
+ : minMinorVersion(INT_MAX), maxMinorVersion(0) {}
+
+ QQmlMetaTypeData::VersionedUri uri;
+
+ int minMinorVersion;
+ int maxMinorVersion;
+
+ void add(QQmlType *);
+
+ QStringHash<QList<QQmlType *> > typeHash;
+ QList<QQmlType *> types;
+};
+
+Q_GLOBAL_STATIC(QQmlMetaTypeData, metaTypeData)
+Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock)
+
+static uint qHash(const QQmlMetaTypeData::VersionedUri &v)
+{
+ return qHash(v.uri) ^ qHash(v.majorVersion);
+}
+
+QQmlMetaTypeData::QQmlMetaTypeData()
+: moduleApiCount(0)
+{
+}
+
+QQmlMetaTypeData::~QQmlMetaTypeData()
+{
+ for (int i = 0; i < types.count(); ++i)
+ delete types.at(i);
+}
+
+class QQmlTypePrivate
+{
+public:
+ QQmlTypePrivate();
+
+ void init() const;
+ void initEnums() const;
+
+ bool m_isInterface : 1;
+ const char *m_iid;
+ QString m_module;
+ QString m_name;
+ QString m_elementName;
+ int m_version_maj;
+ int m_version_min;
+ int m_typeId; int m_listId;
+ int m_revision;
+ mutable bool m_containsRevisionedAttributes;
+ mutable QQmlType *m_superType;
+
+ int m_allocationSize;
+ void (*m_newFunc)(void *);
+ QString m_noCreationReason;
+
+ const QMetaObject *m_baseMetaObject;
+ QQmlAttachedPropertiesFunc m_attachedPropertiesFunc;
+ const QMetaObject *m_attachedPropertiesType;
+ int m_attachedPropertiesId;
+ int m_parserStatusCast;
+ int m_propertyValueSourceCast;
+ int m_propertyValueInterceptorCast;
+ QObject *(*m_extFunc)(QObject *);
+ const QMetaObject *m_extMetaObject;
+ int m_index;
+ QQmlCustomParser *m_customParser;
+ mutable volatile bool m_isSetup:1;
+ mutable volatile bool m_isEnumSetup:1;
+ mutable bool m_haveSuperType:1;
+ mutable QList<QQmlProxyMetaObject::ProxyData> m_metaObjects;
+ mutable QStringHash<int> m_enums;
+
+ static QHash<const QMetaObject *, int> m_attachedPropertyIds;
+};
+
+QHash<const QMetaObject *, int> QQmlTypePrivate::m_attachedPropertyIds;
+
+QQmlTypePrivate::QQmlTypePrivate()
+: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_revision(0), m_containsRevisionedAttributes(false),
+ m_superType(0), m_allocationSize(0), m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0),
+ m_attachedPropertiesType(0), m_parserStatusCast(-1), m_propertyValueSourceCast(-1),
+ m_propertyValueInterceptorCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0),
+ m_isSetup(false), m_isEnumSetup(false), m_haveSuperType(false)
+{
+}
+
+
+QQmlType::QQmlType(int index, const QQmlPrivate::RegisterInterface &interface)
+: d(new QQmlTypePrivate)
+{
+ d->m_isInterface = true;
+ d->m_iid = interface.iid;
+ d->m_typeId = interface.typeId;
+ d->m_listId = interface.listId;
+ d->m_newFunc = 0;
+ d->m_index = index;
+ d->m_isSetup = true;
+ d->m_version_maj = 0;
+ d->m_version_min = 0;
+}
+
+QQmlType::QQmlType(int index, const QQmlPrivate::RegisterType &type)
+: d(new QQmlTypePrivate)
+{
+ QString name = QString::fromUtf8(type.uri);
+ if (type.uri) name += QLatin1Char('/');
+ name += QString::fromUtf8(type.elementName);
+
+ d->m_module = QString::fromUtf8(type.uri);
+ d->m_name = name;
+ d->m_version_maj = type.versionMajor;
+ d->m_version_min = type.versionMinor;
+ if (type.version >= 1) // revisions added in version 1
+ d->m_revision = type.revision;
+ d->m_typeId = type.typeId;
+ d->m_listId = type.listId;
+ d->m_allocationSize = type.objectSize;
+ d->m_newFunc = type.create;
+ d->m_noCreationReason = type.noCreationReason;
+ d->m_baseMetaObject = type.metaObject;
+ d->m_attachedPropertiesFunc = type.attachedPropertiesFunction;
+ d->m_attachedPropertiesType = type.attachedPropertiesMetaObject;
+ if (d->m_attachedPropertiesType) {
+ QHash<const QMetaObject *, int>::Iterator iter = d->m_attachedPropertyIds.find(d->m_baseMetaObject);
+ if (iter == d->m_attachedPropertyIds.end())
+ iter = d->m_attachedPropertyIds.insert(d->m_baseMetaObject, index);
+ d->m_attachedPropertiesId = *iter;
+ } else {
+ d->m_attachedPropertiesId = -1;
+ }
+ d->m_parserStatusCast = type.parserStatusCast;
+ d->m_propertyValueSourceCast = type.valueSourceCast;
+ d->m_propertyValueInterceptorCast = type.valueInterceptorCast;
+ d->m_extFunc = type.extensionObjectCreate;
+ d->m_index = index;
+ d->m_customParser = type.customParser;
+
+ if (type.extensionMetaObject)
+ d->m_extMetaObject = type.extensionMetaObject;
+}
+
+QQmlType::~QQmlType()
+{
+ delete d->m_customParser;
+ delete d;
+}
+
+QString QQmlType::module() const
+{
+ return d->m_module;
+}
+
+int QQmlType::majorVersion() const
+{
+ return d->m_version_maj;
+}
+
+int QQmlType::minorVersion() const
+{
+ return d->m_version_min;
+}
+
+bool QQmlType::availableInVersion(int vmajor, int vminor) const
+{
+ Q_ASSERT(vmajor >= 0 && vminor >= 0);
+ return vmajor == d->m_version_maj && vminor >= d->m_version_min;
+}
+
+bool QQmlType::availableInVersion(const QString &module, int vmajor, int vminor) const
+{
+ Q_ASSERT(vmajor >= 0 && vminor >= 0);
+ return module == d->m_module && vmajor == d->m_version_maj && vminor >= d->m_version_min;
+}
+
+// returns the nearest _registered_ super class
+QQmlType *QQmlType::superType() const
+{
+ if (!d->m_haveSuperType) {
+ const QMetaObject *mo = d->m_baseMetaObject->superClass();
+ while (mo && !d->m_superType) {
+ d->m_superType = QQmlMetaType::qmlType(mo, d->m_module, d->m_version_maj, d->m_version_min);
+ mo = mo->superClass();
+ }
+ d->m_haveSuperType = true;
+ }
+
+ return d->m_superType;
+}
+
+static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
+ const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
+{
+ // Set classname
+ builder.setClassName(ignoreEnd->className());
+
+ // Clone Q_CLASSINFO
+ for (int ii = mo->classInfoOffset(); ii < mo->classInfoCount(); ++ii) {
+ QMetaClassInfo info = mo->classInfo(ii);
+
+ int otherIndex = ignoreEnd->indexOfClassInfo(info.name());
+ if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) {
+ // Skip
+ } else {
+ builder.addClassInfo(info.name(), info.value());
+ }
+ }
+
+ // Clone Q_PROPERTY
+ for (int ii = mo->propertyOffset(); ii < mo->propertyCount(); ++ii) {
+ QMetaProperty property = mo->property(ii);
+
+ int otherIndex = ignoreEnd->indexOfProperty(property.name());
+ if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) {
+ builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void"));
+ // Skip
+ } else {
+ builder.addProperty(property);
+ }
+ }
+
+ // Clone Q_METHODS
+ for (int ii = mo->methodOffset(); ii < mo->methodCount(); ++ii) {
+ QMetaMethod method = mo->method(ii);
+
+ // More complex - need to search name
+ QByteArray name = method.signature();
+ int parenIdx = name.indexOf('(');
+ if (parenIdx != -1) name = name.left(parenIdx);
+
+
+ bool found = false;
+
+ for (int ii = ignoreStart->methodOffset() + ignoreStart->methodCount();
+ !found && ii < ignoreEnd->methodOffset() + ignoreEnd->methodCount();
+ ++ii) {
+
+ QMetaMethod other = ignoreEnd->method(ii);
+ QByteArray othername = other.signature();
+ int parenIdx = othername.indexOf('(');
+ if (parenIdx != -1) othername = othername.left(parenIdx);
+
+ found = name == othername;
+ }
+
+ QMetaMethodBuilder m = builder.addMethod(method);
+ if (found) // SKIP
+ m.setAccess(QMetaMethod::Private);
+ }
+
+ // Clone Q_ENUMS
+ for (int ii = mo->enumeratorOffset(); ii < mo->enumeratorCount(); ++ii) {
+ QMetaEnum enumerator = mo->enumerator(ii);
+
+ int otherIndex = ignoreEnd->indexOfEnumerator(enumerator.name());
+ if (otherIndex >= ignoreStart->enumeratorOffset() + ignoreStart->enumeratorCount()) {
+ // Skip
+ } else {
+ builder.addEnumerator(enumerator);
+ }
+ }
+}
+
+static bool isPropertyRevisioned(const QMetaObject *mo, int index)
+{
+ int i = index;
+ i -= mo->propertyOffset();
+ if (i < 0 && mo->d.superdata)
+ return isPropertyRevisioned(mo->d.superdata, index);
+
+ const QMetaObjectPrivate *mop = reinterpret_cast<const QMetaObjectPrivate*>(mo->d.data);
+ if (i >= 0 && i < mop->propertyCount) {
+ int handle = mop->propertyData + 3*i;
+ int flags = mo->d.data[handle + 2];
+
+ return (flags & Revisioned);
+ }
+
+ return false;
+}
+
+void QQmlTypePrivate::init() const
+{
+ if (m_isSetup) return;
+
+ QWriteLocker lock(metaTypeDataLock());
+ if (m_isSetup)
+ return;
+
+ // Setup extended meta object
+ // XXX - very inefficient
+ const QMetaObject *mo = m_baseMetaObject;
+ if (m_extFunc) {
+ QMetaObjectBuilder builder;
+ clone(builder, m_extMetaObject, m_extMetaObject, m_extMetaObject);
+ builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
+ QMetaObject *mmo = builder.toMetaObject();
+ mmo->d.superdata = mo;
+ QQmlProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0, 0 };
+ m_metaObjects << data;
+ }
+
+ mo = mo->d.superdata;
+ while(mo) {
+ QQmlType *t = metaTypeData()->metaObjectToType.value(mo);
+ if (t) {
+ if (t->d->m_extFunc) {
+ QMetaObjectBuilder builder;
+ clone(builder, t->d->m_extMetaObject, t->d->m_baseMetaObject, m_baseMetaObject);
+ builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
+ QMetaObject *mmo = builder.toMetaObject();
+ mmo->d.superdata = m_baseMetaObject;
+ if (!m_metaObjects.isEmpty())
+ m_metaObjects.last().metaObject->d.superdata = mmo;
+ QQmlProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0, 0 };
+ m_metaObjects << data;
+ }
+ }
+ mo = mo->d.superdata;
+ }
+
+ for (int ii = 0; ii < m_metaObjects.count(); ++ii) {
+ m_metaObjects[ii].propertyOffset =
+ m_metaObjects.at(ii).metaObject->propertyOffset();
+ m_metaObjects[ii].methodOffset =
+ m_metaObjects.at(ii).metaObject->methodOffset();
+ }
+
+ // Check for revisioned details
+ {
+ const QMetaObject *mo = 0;
+ if (m_metaObjects.isEmpty())
+ mo = m_baseMetaObject;
+ else
+ mo = m_metaObjects.first().metaObject;
+
+ for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->propertyCount(); ++ii) {
+ if (isPropertyRevisioned(mo, ii))
+ m_containsRevisionedAttributes = true;
+ }
+
+ for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->methodCount(); ++ii) {
+ if (mo->method(ii).revision() != 0)
+ m_containsRevisionedAttributes = true;
+ }
+ }
+
+ m_isSetup = true;
+ lock.unlock();
+}
+
+void QQmlTypePrivate::initEnums() const
+{
+ if (m_isEnumSetup) return;
+
+ init();
+
+ QWriteLocker lock(metaTypeDataLock());
+ if (m_isEnumSetup) return;
+
+ const QMetaObject *metaObject = m_baseMetaObject;
+ for (int ii = 0; ii < metaObject->enumeratorCount(); ++ii) {
+
+ QMetaEnum e = metaObject->enumerator(ii);
+
+ for (int jj = 0; jj < e.keyCount(); ++jj)
+ m_enums.insert(QString::fromUtf8(e.key(jj)), e.value(jj));
+ }
+
+ m_isEnumSetup = true;
+}
+
+QByteArray QQmlType::typeName() const
+{
+ if (d->m_baseMetaObject)
+ return d->m_baseMetaObject->className();
+ else
+ return QByteArray();
+}
+
+const QString &QQmlType::elementName() const
+{
+ if (d->m_elementName.isEmpty()) {
+ QString n = qmlTypeName();
+ int idx = n.lastIndexOf(QLatin1Char('/'));
+ d->m_elementName = n.mid(idx + 1);
+ }
+ return d->m_elementName;
+}
+
+const QString &QQmlType::qmlTypeName() const
+{
+ return d->m_name;
+}
+
+QObject *QQmlType::create() const
+{
+ d->init();
+
+ QObject *rv = (QObject *)operator new(d->m_allocationSize);
+ d->m_newFunc(rv);
+
+ if (rv && !d->m_metaObjects.isEmpty())
+ (void *)new QQmlProxyMetaObject(rv, &d->m_metaObjects);
+
+ return rv;
+}
+
+void QQmlType::create(QObject **out, void **memory, size_t additionalMemory) const
+{
+ d->init();
+
+ QObject *rv = (QObject *)operator new(d->m_allocationSize + additionalMemory);
+ d->m_newFunc(rv);
+
+ if (rv && !d->m_metaObjects.isEmpty())
+ (void *)new QQmlProxyMetaObject(rv, &d->m_metaObjects);
+
+ *out = rv;
+ *memory = ((char *)rv) + d->m_allocationSize;
+}
+
+QQmlCustomParser *QQmlType::customParser() const
+{
+ return d->m_customParser;
+}
+
+QQmlType::CreateFunc QQmlType::createFunction() const
+{
+ return d->m_newFunc;
+}
+
+QString QQmlType::noCreationReason() const
+{
+ return d->m_noCreationReason;
+}
+
+int QQmlType::createSize() const
+{
+ return d->m_allocationSize;
+}
+
+bool QQmlType::isCreatable() const
+{
+ return d->m_newFunc != 0;
+}
+
+bool QQmlType::isExtendedType() const
+{
+ d->init();
+
+ return !d->m_metaObjects.isEmpty();
+}
+
+bool QQmlType::isInterface() const
+{
+ return d->m_isInterface;
+}
+
+int QQmlType::typeId() const
+{
+ return d->m_typeId;
+}
+
+int QQmlType::qListTypeId() const
+{
+ return d->m_listId;
+}
+
+const QMetaObject *QQmlType::metaObject() const
+{
+ d->init();
+
+ if (d->m_metaObjects.isEmpty())
+ return d->m_baseMetaObject;
+ else
+ return d->m_metaObjects.first().metaObject;
+
+}
+
+const QMetaObject *QQmlType::baseMetaObject() const
+{
+ return d->m_baseMetaObject;
+}
+
+bool QQmlType::containsRevisionedAttributes() const
+{
+ d->init();
+
+ return d->m_containsRevisionedAttributes;
+}
+
+int QQmlType::metaObjectRevision() const
+{
+ return d->m_revision;
+}
+
+QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction() const
+{
+ return d->m_attachedPropertiesFunc;
+}
+
+const QMetaObject *QQmlType::attachedPropertiesType() const
+{
+ return d->m_attachedPropertiesType;
+}
+
+/*
+This is the id passed to qmlAttachedPropertiesById(). This is different from the index
+for the case that a single class is registered under two or more names (eg. Item in
+Qt 4.7 and QtQuick 1.0).
+*/
+int QQmlType::attachedPropertiesId() const
+{
+ return d->m_attachedPropertiesId;
+}
+
+int QQmlType::parserStatusCast() const
+{
+ return d->m_parserStatusCast;
+}
+
+int QQmlType::propertyValueSourceCast() const
+{
+ return d->m_propertyValueSourceCast;
+}
+
+int QQmlType::propertyValueInterceptorCast() const
+{
+ return d->m_propertyValueInterceptorCast;
+}
+
+const char *QQmlType::interfaceIId() const
+{
+ return d->m_iid;
+}
+
+int QQmlType::index() const
+{
+ return d->m_index;
+}
+
+int QQmlType::enumValue(const QHashedStringRef &name) const
+{
+ d->initEnums();
+
+ int *rv = d->m_enums.value(name);
+ return rv?*rv:-1;
+}
+
+int QQmlType::enumValue(const QHashedV8String &name) const
+{
+ d->initEnums();
+
+ int *rv = d->m_enums.value(name);
+ return rv?*rv:-1;
+}
+
+QQmlTypeModule::QQmlTypeModule()
+: d(new QQmlTypeModulePrivate)
+{
+}
+
+QQmlTypeModule::~QQmlTypeModule()
+{
+ delete d; d = 0;
+}
+
+QString QQmlTypeModule::module() const
+{
+ return d->uri.uri;
+}
+
+int QQmlTypeModule::majorVersion() const
+{
+ return d->uri.majorVersion;
+}
+
+int QQmlTypeModule::minimumMinorVersion() const
+{
+ return d->minMinorVersion;
+}
+
+int QQmlTypeModule::maximumMinorVersion() const
+{
+ return d->maxMinorVersion;
+}
+
+void QQmlTypeModulePrivate::add(QQmlType *type)
+{
+ types << type;
+
+ minMinorVersion = qMin(minMinorVersion, type->minorVersion());
+ maxMinorVersion = qMax(maxMinorVersion, type->minorVersion());
+
+ QList<QQmlType *> &list = typeHash[type->elementName()];
+ for (int ii = 0; ii < list.count(); ++ii) {
+ if (list.at(ii)->minorVersion() < type->minorVersion()) {
+ list.insert(ii, type);
+ return;
+ }
+ }
+ list.append(type);
+}
+
+QList<QQmlType *> QQmlTypeModule::types()
+{
+ QList<QQmlType *> rv;
+ QReadLocker lock(metaTypeDataLock());
+ rv = d->types;
+ return rv;
+}
+
+QList<QQmlType *> QQmlTypeModule::type(const QString &name)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QList<QQmlType *> rv;
+ for (int ii = 0; ii < d->types.count(); ++ii) {
+ if (d->types.at(ii)->elementName() == name)
+ rv << d->types.at(ii);
+ }
+ return rv;
+}
+
+QQmlType *QQmlTypeModule::type(const QHashedStringRef &name, int minor)
+{
+ QReadLocker lock(metaTypeDataLock());
+
+ QList<QQmlType *> *types = d->typeHash.value(name);
+ if (!types) return 0;
+
+ for (int ii = 0; ii < types->count(); ++ii)
+ if (types->at(ii)->minorVersion() <= minor)
+ return types->at(ii);
+
+ return 0;
+}
+
+QQmlType *QQmlTypeModule::type(const QHashedV8String &name, int minor)
+{
+ QReadLocker lock(metaTypeDataLock());
+
+ QList<QQmlType *> *types = d->typeHash.value(name);
+ if (!types) return 0;
+
+ for (int ii = 0; ii < types->count(); ++ii)
+ if (types->at(ii)->minorVersion() <= minor)
+ return types->at(ii);
+
+ return 0;
+}
+
+
+QQmlTypeModuleVersion::QQmlTypeModuleVersion()
+: m_module(0), m_minor(0)
+{
+}
+
+QQmlTypeModuleVersion::QQmlTypeModuleVersion(QQmlTypeModule *module, int minor)
+: m_module(module), m_minor(minor)
+{
+ Q_ASSERT(m_module);
+ Q_ASSERT(m_minor >= 0);
+}
+
+QQmlTypeModuleVersion::QQmlTypeModuleVersion(const QQmlTypeModuleVersion &o)
+: m_module(o.m_module), m_minor(o.m_minor)
+{
+}
+
+QQmlTypeModuleVersion &QQmlTypeModuleVersion::operator=(const QQmlTypeModuleVersion &o)
+{
+ m_module = o.m_module;
+ m_minor = o.m_minor;
+ return *this;
+}
+
+QQmlTypeModule *QQmlTypeModuleVersion::module() const
+{
+ return m_module;
+}
+
+int QQmlTypeModuleVersion::minorVersion() const
+{
+ return m_minor;
+}
+
+QQmlType *QQmlTypeModuleVersion::type(const QHashedStringRef &name) const
+{
+ if (m_module) return m_module->type(name, m_minor);
+ else return 0;
+}
+
+QQmlType *QQmlTypeModuleVersion::type(const QHashedV8String &name) const
+{
+ if (m_module) return m_module->type(name, m_minor);
+ else return 0;
+}
+
+
+int registerAutoParentFunction(QQmlPrivate::RegisterAutoParent &autoparent)
+{
+ QWriteLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ data->parentFunctions.append(autoparent.function);
+
+ return data->parentFunctions.count() - 1;
+}
+
+int registerInterface(const QQmlPrivate::RegisterInterface &interface)
+{
+ if (interface.version > 0)
+ qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
+
+ QWriteLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ int index = data->types.count();
+
+ QQmlType *type = new QQmlType(index, interface);
+
+ data->types.append(type);
+ data->idToType.insert(type->typeId(), type);
+ data->idToType.insert(type->qListTypeId(), type);
+ // XXX No insertMulti, so no multi-version interfaces?
+ if (!type->qmlTypeName().isEmpty())
+ data->nameToType.insert(type->qmlTypeName(), type);
+
+ if (data->interfaces.size() <= interface.typeId)
+ data->interfaces.resize(interface.typeId + 16);
+ if (data->lists.size() <= interface.listId)
+ data->lists.resize(interface.listId + 16);
+ data->interfaces.setBit(interface.typeId, true);
+ data->lists.setBit(interface.listId, true);
+
+ return index;
+}
+
+int registerType(const QQmlPrivate::RegisterType &type)
+{
+ if (type.elementName) {
+ for (int ii = 0; type.elementName[ii]; ++ii) {
+ if (!isalnum(type.elementName[ii])) {
+ qWarning("qmlRegisterType(): Invalid QML element name \"%s\"", type.elementName);
+ return -1;
+ }
+ }
+ }
+
+ QWriteLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ int index = data->types.count();
+
+ QQmlType *dtype = new QQmlType(index, type);
+
+ data->types.append(dtype);
+ data->idToType.insert(dtype->typeId(), dtype);
+ if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
+
+ if (!dtype->qmlTypeName().isEmpty())
+ data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
+
+ data->metaObjectToType.insertMulti(dtype->baseMetaObject(), dtype);
+
+ if (data->objects.size() <= type.typeId)
+ data->objects.resize(type.typeId + 16);
+ if (data->lists.size() <= type.listId)
+ data->lists.resize(type.listId + 16);
+ data->objects.setBit(type.typeId, true);
+ if (type.listId) data->lists.setBit(type.listId, true);
+
+ if (type.uri) {
+ QString mod = QString::fromUtf8(type.uri);
+
+ QQmlMetaTypeData::VersionedUri versionedUri(mod, type.versionMajor);
+ QQmlTypeModule *module = data->uriToModule.value(versionedUri);
+ if (!module) {
+ module = new QQmlTypeModule;
+ module->d->uri = versionedUri;
+ data->uriToModule.insert(versionedUri, module);
+ }
+ module->d->add(dtype);
+ }
+
+ return index;
+}
+
+int registerModuleApi(const QQmlPrivate::RegisterModuleApi &api)
+{
+ QWriteLocker lock(metaTypeDataLock());
+
+ QQmlMetaTypeData *data = metaTypeData();
+ QString uri = QString::fromUtf8(api.uri);
+ QQmlMetaType::ModuleApi import;
+ import.major = api.versionMajor;
+ import.minor = api.versionMinor;
+ import.script = api.scriptApi;
+ import.qobject = api.qobjectApi;
+
+ int index = data->moduleApiCount++;
+
+ QQmlMetaTypeData::ModuleApis::Iterator iter = data->moduleApis.find(uri);
+ if (iter == data->moduleApis.end()) {
+ QQmlMetaTypeData::ModuleApiList apis;
+ apis.moduleApis << import;
+ data->moduleApis.insert(uri, apis);
+ } else {
+ iter->moduleApis << import;
+ iter->sorted = false;
+ }
+
+ return index;
+}
+
+
+/*
+This method is "over generalized" to allow us to (potentially) register more types of things in
+the future without adding exported symbols.
+*/
+int QQmlPrivate::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));
+ } else if (type == ModuleApiRegistration) {
+ return registerModuleApi(*reinterpret_cast<RegisterModuleApi *>(data));
+ }
+ return -1;
+}
+
+/*
+ Returns true if a module \a uri of any version is installed.
+*/
+bool QQmlMetaType::isAnyModule(const QString &uri)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ for (QQmlMetaTypeData::TypeModules::ConstIterator iter = data->uriToModule.begin();
+ iter != data->uriToModule.end(); ++iter) {
+ if ((*iter)->module() == uri)
+ return true;
+ }
+
+ return false;
+}
+
+/*
+ Returns true if any type or API has been registered for the given \a module with at least
+ versionMajor.versionMinor, or if types have been registered for \a module with at most
+ versionMajor.versionMinor.
+
+ So if only 4.7 and 4.9 have been registered, 4.7,4.8, and 4.9 are valid, but not 4.6 nor 4.10.
+*/
+bool QQmlMetaType::isModule(const QString &module, int versionMajor, int versionMinor)
+{
+ Q_ASSERT(versionMajor >= 0 && versionMinor >= 0);
+ QReadLocker lock(metaTypeDataLock());
+
+ QQmlMetaTypeData *data = metaTypeData();
+
+ // first, check Types
+ QQmlTypeModule *tm =
+ data->uriToModule.value(QQmlMetaTypeData::VersionedUri(module, versionMajor));
+ if (tm && tm->minimumMinorVersion() <= versionMinor && tm->maximumMinorVersion() >= versionMinor)
+ return true;
+
+ // then, check ModuleApis
+ foreach (const QQmlMetaType::ModuleApi &mApi, data->moduleApis.value(module).moduleApis) {
+ if (mApi.major == versionMajor && mApi.minor == versionMinor) // XXX is this correct?
+ return true;
+ }
+
+ return false;
+}
+
+QQmlTypeModule *QQmlMetaType::typeModule(const QString &uri, int majorVersion)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ return data->uriToModule.value(QQmlMetaTypeData::VersionedUri(uri, majorVersion));
+}
+
+QList<QQmlPrivate::AutoParentFunction> QQmlMetaType::parentFunctions()
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ return data->parentFunctions;
+}
+
+static bool operator<(const QQmlMetaType::ModuleApi &lhs, const QQmlMetaType::ModuleApi &rhs)
+{
+ return lhs.major < rhs.major || (lhs.major == rhs.major && lhs.minor < rhs.minor);
+}
+
+QQmlMetaType::ModuleApi
+QQmlMetaType::moduleApi(const QString &uri, int versionMajor, int versionMinor)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QQmlMetaTypeData::ModuleApis::Iterator iter = data->moduleApis.find(uri);
+ if (iter == data->moduleApis.end())
+ return ModuleApi();
+
+ if (iter->sorted == false) {
+ qSort(iter->moduleApis.begin(), iter->moduleApis.end());
+ iter->sorted = true;
+ }
+
+ for (int ii = iter->moduleApis.count() - 1; ii >= 0; --ii) {
+ const ModuleApi &import = iter->moduleApis.at(ii);
+ if (import.major == versionMajor && import.minor <= versionMinor)
+ return import;
+ }
+
+ return ModuleApi();
+}
+
+QHash<QString, QList<QQmlMetaType::ModuleApi> > QQmlMetaType::moduleApis()
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QHash<QString, QList<ModuleApi> > moduleApis;
+ QHashIterator<QString, QQmlMetaTypeData::ModuleApiList> it(data->moduleApis);
+ while (it.hasNext()) {
+ it.next();
+ moduleApis[it.key()] = it.value().moduleApis;
+ }
+
+ return moduleApis;
+}
+
+QObject *QQmlMetaType::toQObject(const QVariant &v, bool *ok)
+{
+ if (!isQObject(v.userType())) {
+ if (ok) *ok = false;
+ return 0;
+ }
+
+ if (ok) *ok = true;
+
+ return *(QObject **)v.constData();
+}
+
+bool QQmlMetaType::isQObject(int userType)
+{
+ if (userType == QMetaType::QObjectStar)
+ return true;
+
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ return userType >= 0 && userType < data->objects.size() && data->objects.testBit(userType);
+}
+
+/*
+ Returns the item type for a list of type \a id.
+ */
+int QQmlMetaType::listType(int id)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ QQmlType *type = data->idToType.value(id);
+ if (type && type->qListTypeId() == id)
+ return type->typeId();
+ else
+ return 0;
+}
+
+int QQmlMetaType::attachedPropertiesFuncId(const QMetaObject *mo)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QQmlType *type = data->metaObjectToType.value(mo);
+ if (type && type->attachedPropertiesFunction())
+ return type->attachedPropertiesId();
+ else
+ return -1;
+}
+
+QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(int id)
+{
+ if (id < 0)
+ return 0;
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ return data->types.at(id)->attachedPropertiesFunction();
+}
+
+QMetaProperty QQmlMetaType::defaultProperty(const QMetaObject *metaObject)
+{
+ int idx = metaObject->indexOfClassInfo("DefaultProperty");
+ if (-1 == idx)
+ return QMetaProperty();
+
+ QMetaClassInfo info = metaObject->classInfo(idx);
+ if (!info.value())
+ return QMetaProperty();
+
+ idx = metaObject->indexOfProperty(info.value());
+ if (-1 == idx)
+ return QMetaProperty();
+
+ return metaObject->property(idx);
+}
+
+QMetaProperty QQmlMetaType::defaultProperty(QObject *obj)
+{
+ if (!obj)
+ return QMetaProperty();
+
+ const QMetaObject *metaObject = obj->metaObject();
+ return defaultProperty(metaObject);
+}
+
+QMetaMethod QQmlMetaType::defaultMethod(const QMetaObject *metaObject)
+{
+ int idx = metaObject->indexOfClassInfo("DefaultMethod");
+ if (-1 == idx)
+ return QMetaMethod();
+
+ QMetaClassInfo info = metaObject->classInfo(idx);
+ if (!info.value())
+ return QMetaMethod();
+
+ idx = metaObject->indexOfMethod(info.value());
+ if (-1 == idx)
+ return QMetaMethod();
+
+ return metaObject->method(idx);
+}
+
+QMetaMethod QQmlMetaType::defaultMethod(QObject *obj)
+{
+ if (!obj)
+ return QMetaMethod();
+
+ const QMetaObject *metaObject = obj->metaObject();
+ return defaultMethod(metaObject);
+}
+
+QQmlMetaType::TypeCategory QQmlMetaType::typeCategory(int userType)
+{
+ if (userType < 0)
+ return Unknown;
+ if (userType == QMetaType::QObjectStar)
+ return Object;
+
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ if (userType < data->objects.size() && data->objects.testBit(userType))
+ return Object;
+ else if (userType < data->lists.size() && data->lists.testBit(userType))
+ return List;
+ else
+ return Unknown;
+}
+
+bool QQmlMetaType::isInterface(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ return userType >= 0 && userType < data->interfaces.size() && data->interfaces.testBit(userType);
+}
+
+const char *QQmlMetaType::interfaceIId(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ QQmlType *type = data->idToType.value(userType);
+ lock.unlock();
+ if (type && type->isInterface() && type->typeId() == userType)
+ return type->interfaceIId();
+ else
+ return 0;
+}
+
+bool QQmlMetaType::isList(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType);
+}
+
+/*!
+ A custom string convertor allows you to specify a function pointer that
+ returns a variant of \a type. For example, if you have written your own icon
+ class that you want to support as an object property assignable in QML:
+
+ \code
+ int type = qRegisterMetaType<SuperIcon>("SuperIcon");
+ QML::addCustomStringConvertor(type, &SuperIcon::pixmapFromString);
+ \endcode
+
+ The function pointer must be of the form:
+ \code
+ QVariant (*StringConverter)(const QString &);
+ \endcode
+ */
+void QQmlMetaType::registerCustomStringConverter(int type, StringConverter converter)
+{
+ QWriteLocker lock(metaTypeDataLock());
+
+ QQmlMetaTypeData *data = metaTypeData();
+ if (data->stringConverters.contains(type))
+ return;
+ data->stringConverters.insert(type, converter);
+}
+
+/*!
+ Return the custom string converter for \a type, previously installed through
+ registerCustomStringConverter()
+ */
+QQmlMetaType::StringConverter QQmlMetaType::customStringConverter(int type)
+{
+ QReadLocker lock(metaTypeDataLock());
+
+ QQmlMetaTypeData *data = metaTypeData();
+ return data->stringConverters.value(type);
+}
+
+/*!
+ Returns the type (if any) of URI-qualified named \a name in version specified
+ by \a version_major and \a version_minor.
+*/
+QQmlType *QQmlMetaType::qmlType(const QString &name, int version_major, int version_minor)
+{
+ Q_ASSERT(version_major >= 0 && version_minor >= 0);
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QQmlMetaTypeData::Names::ConstIterator it = data->nameToType.find(name);
+ while (it != data->nameToType.end()) {
+ // XXX version_major<0 just a kludge for QQmlPropertyPrivate::initProperty
+ if (it.key() == name && (version_major<0 || (*it)->availableInVersion(version_major,version_minor)))
+ return (*it);
+ ++it;
+ }
+
+ return 0;
+}
+
+/*!
+ Returns the type (if any) that corresponds to the \a metaObject. Returns null if no
+ type is registered.
+*/
+QQmlType *QQmlMetaType::qmlType(const QMetaObject *metaObject)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ return data->metaObjectToType.value(metaObject);
+}
+
+/*!
+ Returns the type (if any) that corresponds to the \a metaObject in version specified
+ by \a version_major and \a version_minor in module specified by \a uri. Returns null if no
+ type is registered.
+*/
+QQmlType *QQmlMetaType::qmlType(const QMetaObject *metaObject, const QString &module, int version_major, int version_minor)
+{
+ Q_ASSERT(version_major >= 0 && version_minor >= 0);
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QQmlMetaTypeData::MetaObjects::const_iterator it = data->metaObjectToType.find(metaObject);
+ while (it != data->metaObjectToType.end() && it.key() == metaObject) {
+ QQmlType *t = *it;
+ if (version_major < 0 || t->availableInVersion(module, version_major,version_minor))
+ return t;
+ ++it;
+ }
+
+ return 0;
+}
+
+/*!
+ Returns the type (if any) that corresponds to the QVariant::Type \a userType.
+ Returns null if no type is registered.
+*/
+QQmlType *QQmlMetaType::qmlType(int userType)
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QQmlType *type = data->idToType.value(userType);
+ if (type && type->typeId() == userType)
+ return type;
+ else
+ return 0;
+}
+
+/*!
+ Returns the list of registered QML type names.
+*/
+QList<QString> QQmlMetaType::qmlTypeNames()
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ return data->nameToType.keys();
+}
+
+/*!
+ Returns the list of registered QML types.
+*/
+QList<QQmlType*> QQmlMetaType::qmlTypes()
+{
+ QReadLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ return data->nameToType.values();
+}
+
+int QQmlMetaType::QQuickAnchorLineMetaTypeId()
+{
+ static int id = 0;
+ if (!id) {
+ id = QMetaType::type("QQuickAnchorLine");
+ }
+ return id;
+}
+
+QQmlMetaType::CompareFunction QQmlMetaType::anchorLineCompareFunction = 0;
+
+void QQmlMetaType::setQQuickAnchorLineCompareFunction(CompareFunction fun)
+{
+ anchorLineCompareFunction = fun;
+}
+
+bool QQmlMetaType::QQuickAnchorLineCompare(const void *p1, const void *p2)
+{
+ Q_ASSERT(anchorLineCompareFunction != 0);
+ return anchorLineCompareFunction(p1, p2);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
new file mode 100644
index 0000000000..ad6a2aa055
--- /dev/null
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLMETATYPE_P_H
+#define QQMLMETATYPE_P_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 "qqml.h"
+#include <private/qtqmlglobal_p.h>
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qbitarray.h>
+#include <QtQml/qjsvalue.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlType;
+class QQmlCustomParser;
+class QQmlTypePrivate;
+class QQmlTypeModule;
+
+class Q_QML_PRIVATE_EXPORT QQmlMetaType
+{
+public:
+ static QList<QString> qmlTypeNames();
+ static QList<QQmlType*> qmlTypes();
+
+ static QQmlType *qmlType(const QString &, int, int);
+ static QQmlType *qmlType(const QMetaObject *);
+ static QQmlType *qmlType(const QMetaObject *metaObject, const QString &module, int version_major, int version_minor);
+ static QQmlType *qmlType(int);
+
+ static QMetaProperty defaultProperty(const QMetaObject *);
+ static QMetaProperty defaultProperty(QObject *);
+ static QMetaMethod defaultMethod(const QMetaObject *);
+ static QMetaMethod defaultMethod(QObject *);
+
+ static bool isQObject(int);
+ static QObject *toQObject(const QVariant &, bool *ok = 0);
+
+ static int listType(int);
+ static int attachedPropertiesFuncId(const QMetaObject *);
+ static QQmlAttachedPropertiesFunc attachedPropertiesFuncById(int);
+
+ enum TypeCategory { Unknown, Object, List };
+ static TypeCategory typeCategory(int);
+
+ static bool isInterface(int);
+ static const char *interfaceIId(int);
+ static bool isList(int);
+
+ typedef QVariant (*StringConverter)(const QString &);
+ static void registerCustomStringConverter(int, StringConverter);
+ static StringConverter customStringConverter(int);
+
+ static bool isAnyModule(const QString &uri);
+ static bool isModule(const QString &module, int versionMajor, int versionMinor);
+ static QQmlTypeModule *typeModule(const QString &uri, int majorVersion);
+
+ static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
+
+ static int QQuickAnchorLineMetaTypeId();
+ typedef bool (*CompareFunction)(const void *, const void *);
+ static void setQQuickAnchorLineCompareFunction(CompareFunction);
+ static bool QQuickAnchorLineCompare(const void *p1, const void *p2);
+
+ struct ModuleApiInstance {
+ ModuleApiInstance()
+ : scriptCallback(0), qobjectCallback(0), qobjectApi(0) {}
+
+ QJSValue (*scriptCallback)(QQmlEngine *, QJSEngine *);
+ QObject *(*qobjectCallback)(QQmlEngine *, QJSEngine *);
+ QJSValue scriptApi;
+ QObject *qobjectApi;
+ };
+ struct ModuleApi {
+ inline ModuleApi();
+ inline bool operator==(const ModuleApi &) const;
+ int major;
+ int minor;
+ QJSValue (*script)(QQmlEngine *, QJSEngine *);
+ QObject *(*qobject)(QQmlEngine *, QJSEngine *);
+ };
+ static ModuleApi moduleApi(const QString &, int, int);
+ static QHash<QString, QList<ModuleApi> > moduleApis();
+
+private:
+ static CompareFunction anchorLineCompareFunction;
+};
+
+class QHashedStringRef;
+class QHashedV8String;
+class Q_QML_PRIVATE_EXPORT QQmlType
+{
+public:
+ QByteArray typeName() const;
+ const QString &qmlTypeName() const;
+ const QString &elementName() const;
+
+ QString module() const;
+ int majorVersion() const;
+ int minorVersion() const;
+
+ bool availableInVersion(int vmajor, int vminor) const;
+ bool availableInVersion(const QString &module, int vmajor, int vminor) const;
+
+ QObject *create() const;
+ void create(QObject **, void **, size_t) const;
+
+ typedef void (*CreateFunc)(void *);
+ CreateFunc createFunction() const;
+ int createSize() const;
+
+ QQmlCustomParser *customParser() const;
+
+ bool isCreatable() const;
+ bool isExtendedType() const;
+ QString noCreationReason() const;
+
+ bool isInterface() const;
+ int typeId() const;
+ int qListTypeId() const;
+
+ const QMetaObject *metaObject() const;
+ const QMetaObject *baseMetaObject() const;
+ int metaObjectRevision() const;
+ bool containsRevisionedAttributes() const;
+
+ QQmlAttachedPropertiesFunc attachedPropertiesFunction() const;
+ const QMetaObject *attachedPropertiesType() const;
+ int attachedPropertiesId() const;
+
+ int parserStatusCast() const;
+ QVariant fromObject(QObject *) const;
+ const char *interfaceIId() const;
+ int propertyValueSourceCast() const;
+ int propertyValueInterceptorCast() const;
+
+ int index() const;
+
+ int enumValue(const QHashedStringRef &) const;
+ int enumValue(const QHashedV8String &) const;
+private:
+ QQmlType *superType() const;
+ friend class QQmlTypePrivate;
+ friend struct QQmlMetaTypeData;
+ friend int registerType(const QQmlPrivate::RegisterType &);
+ friend int registerInterface(const QQmlPrivate::RegisterInterface &);
+ QQmlType(int, const QQmlPrivate::RegisterInterface &);
+ QQmlType(int, const QQmlPrivate::RegisterType &);
+ ~QQmlType();
+
+ QQmlTypePrivate *d;
+};
+
+class QQmlTypeModulePrivate;
+class QQmlTypeModule
+{
+public:
+ QString module() const;
+ int majorVersion() const;
+
+ int minimumMinorVersion() const;
+ int maximumMinorVersion() const;
+
+ QList<QQmlType *> types();
+ QList<QQmlType *> type(const QString &);
+
+ QQmlType *type(const QHashedStringRef &, int);
+ QQmlType *type(const QHashedV8String &, int);
+
+private:
+ friend int registerType(const QQmlPrivate::RegisterType &);
+ QQmlTypeModule();
+ ~QQmlTypeModule();
+ QQmlTypeModulePrivate *d;
+};
+
+class QQmlTypeModuleVersion
+{
+public:
+ QQmlTypeModuleVersion();
+ QQmlTypeModuleVersion(QQmlTypeModule *, int);
+ QQmlTypeModuleVersion(const QQmlTypeModuleVersion &);
+ QQmlTypeModuleVersion &operator=(const QQmlTypeModuleVersion &);
+
+ QQmlTypeModule *module() const;
+ int minorVersion() const;
+
+ QQmlType *type(const QHashedStringRef &) const;
+ QQmlType *type(const QHashedV8String &) const;
+
+private:
+ QQmlTypeModule *m_module;
+ int m_minor;
+};
+
+QQmlMetaType::ModuleApi::ModuleApi()
+{
+ major = 0;
+ minor = 0;
+ script = 0;
+ qobject = 0;
+}
+
+bool QQmlMetaType::ModuleApi::operator==(const ModuleApi &other) const
+{
+ return major == other.major && minor == other.minor && script == other.script && qobject == other.qobject;
+}
+
+inline uint qHash(const QQmlMetaType::ModuleApi &import)
+{
+ return import.major ^ import.minor ^ quintptr(import.script) ^ quintptr(import.qobject);
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLMETATYPE_P_H
+
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
new file mode 100644
index 0000000000..cc33f387d9
--- /dev/null
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlnetworkaccessmanagerfactory.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QQmlNetworkAccessManagerFactory
+ \since 4.7
+ \brief The QQmlNetworkAccessManagerFactory class creates QNetworkAccessManager instances for a QML engine.
+
+ A QML engine uses QNetworkAccessManager for all network access.
+ By implementing a factory, it is possible to provide the QML engine
+ with custom QNetworkAccessManager instances with specialized caching,
+ proxy and cookies support.
+
+ To implement a factory, subclass QQmlNetworkAccessManagerFactory and
+ implement the virtual create() method, then assign it to the relevant QML
+ engine using QQmlEngine::setNetworkAccessManagerFactory().
+
+ Note the QML engine may create QNetworkAccessManager instances
+ from multiple threads. Because of this, the implementation of the create()
+ method must be \l{Reentrancy and Thread-Safety}{reentrant}. In addition,
+ the developer should be careful if the signals of the object to be
+ returned from create() are connected to the slots of an object that may
+ be created in a different thread:
+
+ \list
+ \o The QML engine internally handles all requests, and cleans up any
+ QNetworkReply objects it creates. Receiving the
+ QNetworkAccessManager::finished() signal in another thread may not
+ provide the receiver with a valid reply object if it has already
+ been deleted.
+ \o Authentication details provided to QNetworkAccessManager::authenticationRequired()
+ must be provided immediately, so this signal cannot be connected as a
+ Qt::QueuedConnection (or as the default Qt::AutoConnection from another
+ thread).
+ \endlist
+
+ For more information about signals and threads, see
+ \l {Threads and QObjects} and \l {Signals and Slots Across Threads}.
+
+ \sa {declarative/cppextensions/networkaccessmanagerfactory}{NetworkAccessManagerFactory example}
+*/
+
+/*!
+ Destroys the factory. The default implementation does nothing.
+ */
+QQmlNetworkAccessManagerFactory::~QQmlNetworkAccessManagerFactory()
+{
+}
+
+/*!
+ \fn QNetworkAccessManager *QQmlNetworkAccessManagerFactory::create(QObject *parent)
+
+ Creates and returns a network access manager with the specified \a parent.
+ This method must return a new QNetworkAccessManager instance each time
+ it is called.
+
+ Note: this method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.h b/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
new file mode 100644
index 0000000000..ac3583cf4c
--- /dev/null
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLNETWORKACCESSMANAGERFACTORY_H
+#define QQMLNETWORKACCESSMANAGERFACTORY_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QNetworkAccessManager;
+class Q_QML_EXPORT QQmlNetworkAccessManagerFactory
+{
+public:
+ virtual ~QQmlNetworkAccessManagerFactory();
+ virtual QNetworkAccessManager *create(QObject *parent) = 0;
+
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLNETWORKACCESSMANAGERFACTORY_H
diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp
new file mode 100644
index 0000000000..270eee52b4
--- /dev/null
+++ b/src/qml/qml/qqmlnotifier.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlnotifier_p.h"
+#include "qqmlproperty_p.h"
+
+QT_BEGIN_NAMESPACE
+
+void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint)
+{
+ QQmlNotifierEndpoint **oldDisconnected = endpoint->disconnected;
+ endpoint->disconnected = &endpoint;
+ endpoint->notifying = 1;
+
+ if (endpoint->next)
+ emitNotify(endpoint->next);
+
+ if (endpoint) {
+
+ Q_ASSERT(endpoint->callback);
+
+ endpoint->callback(endpoint);
+
+ if (endpoint)
+ endpoint->disconnected = oldDisconnected;
+ }
+
+ if (oldDisconnected) *oldDisconnected = endpoint;
+ else if (endpoint) endpoint->notifying = 0;
+}
+
+void QQmlNotifierEndpoint::connect(QObject *source, int sourceSignal)
+{
+ disconnect();
+
+ this->source = source;
+ this->sourceSignal = sourceSignal;
+ QQmlPropertyPrivate::flushSignal(source, sourceSignal);
+ QQmlData *ddata = QQmlData::get(source, true);
+ ddata->addNotify(sourceSignal, this);
+}
+
+void QQmlNotifierEndpoint::copyAndClear(QQmlNotifierEndpoint &other)
+{
+ if (&other == this)
+ return;
+
+ other.disconnect();
+
+ other.callback = callback;
+
+ if (!isConnected())
+ return;
+
+ other.notifier = notifier;
+ other.sourceSignal = sourceSignal;
+ other.disconnected = disconnected;
+ other.notifying = notifying;
+ if (other.disconnected) *other.disconnected = &other;
+
+ if (next) {
+ other.next = next;
+ next->prev = &other.next;
+ }
+ other.prev = prev;
+ *other.prev = &other;
+
+ prev = 0;
+ next = 0;
+ disconnected = 0;
+ notifier = 0;
+ notifying = 0;
+ sourceSignal = -1;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h
new file mode 100644
index 0000000000..ab0711341d
--- /dev/null
+++ b/src/qml/qml/qqmlnotifier_p.h
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLNOTIFIER_P_H
+#define QQMLNOTIFIER_P_H
+
+#include "qqmldata_p.h"
+#include "qqmlguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQmlNotifierEndpoint;
+class Q_QML_EXPORT QQmlNotifier
+{
+public:
+ inline QQmlNotifier();
+ inline ~QQmlNotifier();
+ inline void notify();
+
+private:
+ friend class QQmlData;
+ friend class QQmlNotifierEndpoint;
+
+ static void emitNotify(QQmlNotifierEndpoint *);
+ QQmlNotifierEndpoint *endpoints;
+};
+
+class QQmlNotifierEndpoint
+{
+public:
+ inline QQmlNotifierEndpoint();
+ inline ~QQmlNotifierEndpoint();
+
+ typedef void (*Callback)(QQmlNotifierEndpoint *);
+ Callback callback;
+
+ inline bool isConnected();
+ inline bool isConnected(QObject *source, int sourceSignal);
+ inline bool isConnected(QQmlNotifier *);
+
+ void connect(QObject *source, int sourceSignal);
+ inline void connect(QQmlNotifier *);
+ inline void disconnect();
+
+ inline bool isNotifying() const;
+ inline void cancelNotify();
+
+ void copyAndClear(QQmlNotifierEndpoint &other);
+
+private:
+ friend class QQmlData;
+ friend class QQmlNotifier;
+
+ union {
+ QQmlNotifier *notifier;
+ QObject *source;
+ };
+ unsigned int notifying : 1;
+ signed int sourceSignal : 31;
+ QQmlNotifierEndpoint **disconnected;
+ QQmlNotifierEndpoint *next;
+ QQmlNotifierEndpoint **prev;
+};
+
+QQmlNotifier::QQmlNotifier()
+: endpoints(0)
+{
+}
+
+QQmlNotifier::~QQmlNotifier()
+{
+ QQmlNotifierEndpoint *endpoint = endpoints;
+ while (endpoint) {
+ QQmlNotifierEndpoint *n = endpoint;
+ endpoint = n->next;
+
+ n->next = 0;
+ n->prev = 0;
+ n->notifier = 0;
+ n->sourceSignal = -1;
+ if (n->disconnected) *n->disconnected = 0;
+ n->disconnected = 0;
+ }
+ endpoints = 0;
+}
+
+void QQmlNotifier::notify()
+{
+ if (endpoints) emitNotify(endpoints);
+}
+
+QQmlNotifierEndpoint::QQmlNotifierEndpoint()
+: callback(0), notifier(0), notifying(0), sourceSignal(-1), disconnected(0), next(0), prev(0)
+{
+}
+
+QQmlNotifierEndpoint::~QQmlNotifierEndpoint()
+{
+ disconnect();
+}
+
+bool QQmlNotifierEndpoint::isConnected()
+{
+ return prev != 0;
+}
+
+bool QQmlNotifierEndpoint::isConnected(QObject *source, int sourceSignal)
+{
+ return this->sourceSignal != -1 && this->source == source && this->sourceSignal == sourceSignal;
+}
+
+bool QQmlNotifierEndpoint::isConnected(QQmlNotifier *notifier)
+{
+ return sourceSignal == -1 && this->notifier == notifier;
+}
+
+void QQmlNotifierEndpoint::connect(QQmlNotifier *notifier)
+{
+ disconnect();
+
+ next = notifier->endpoints;
+ if (next) { next->prev = &next; }
+ notifier->endpoints = this;
+ prev = &notifier->endpoints;
+ this->notifier = notifier;
+}
+
+void QQmlNotifierEndpoint::disconnect()
+{
+ if (next) next->prev = prev;
+ if (prev) *prev = next;
+ if (disconnected) *disconnected = 0;
+ next = 0;
+ prev = 0;
+ disconnected = 0;
+ notifier = 0;
+ notifying = 0;
+ sourceSignal = -1;
+}
+
+/*!
+Returns true if a notify is in progress. This means that the signal or QQmlNotifier
+that this endpoing is connected to has been triggered, but this endpoint's callback has not
+yet been called.
+
+An in progress notify can be cancelled by calling cancelNotify.
+*/
+bool QQmlNotifierEndpoint::isNotifying() const
+{
+ return notifying == 1;
+}
+
+/*!
+Cancel any notifies that are in progress.
+*/
+void QQmlNotifierEndpoint::cancelNotify()
+{
+ notifying = 0;
+ if (disconnected) {
+ *disconnected = 0;
+ disconnected = 0;
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLNOTIFIER_P_H
+
diff --git a/src/qml/qml/qqmlnullablevalue_p_p.h b/src/qml/qml/qqmlnullablevalue_p_p.h
new file mode 100644
index 0000000000..b19e2722cf
--- /dev/null
+++ b/src/qml/qml/qqmlnullablevalue_p_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLNULLABLEVALUE_P_H
+#define QQMLNULLABLEVALUE_P_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.
+//
+
+QT_BEGIN_NAMESPACE
+
+template<typename T>
+struct QQmlNullableValue
+{
+ QQmlNullableValue()
+ : isNull(true), value(T()) {}
+ QQmlNullableValue(const QQmlNullableValue<T> &o)
+ : isNull(o.isNull), value(o.value) {}
+ QQmlNullableValue(const T &t)
+ : isNull(false), value(t) {}
+ QQmlNullableValue<T> &operator=(const T &t)
+ { isNull = false; value = t; return *this; }
+ QQmlNullableValue<T> &operator=(const QQmlNullableValue<T> &o)
+ { isNull = o.isNull; value = o.value; return *this; }
+ operator T() const { return value; }
+
+ void invalidate() { isNull = true; }
+ bool isValid() const { return !isNull; }
+ bool isNull;
+ T value;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLNULLABLEVALUE_P_H
diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp
new file mode 100644
index 0000000000..221cb3a314
--- /dev/null
+++ b/src/qml/qml/qqmlopenmetaobject.cpp
@@ -0,0 +1,387 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlopenmetaobject_p.h"
+#include <private/qqmlpropertycache_p.h>
+#include <private/qqmldata_p.h>
+#include <private/qmetaobjectbuilder_p.h>
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlOpenMetaObjectTypePrivate
+{
+public:
+ QQmlOpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {}
+
+ void init(const QMetaObject *metaObj);
+
+ int propertyOffset;
+ int signalOffset;
+ QHash<QByteArray, int> names;
+ QMetaObjectBuilder mob;
+ QMetaObject *mem;
+ QQmlPropertyCache *cache;
+ QQmlEngine *engine;
+ QSet<QQmlOpenMetaObject*> referers;
+};
+
+QQmlOpenMetaObjectType::QQmlOpenMetaObjectType(const QMetaObject *base, QQmlEngine *engine)
+ : QQmlCleanup(engine), d(new QQmlOpenMetaObjectTypePrivate)
+{
+ d->engine = engine;
+ d->init(base);
+}
+
+QQmlOpenMetaObjectType::~QQmlOpenMetaObjectType()
+{
+ if (d->mem)
+ free(d->mem);
+ if (d->cache)
+ d->cache->release();
+ delete d;
+}
+
+void QQmlOpenMetaObjectType::clear()
+{
+ d->engine = 0;
+}
+
+int QQmlOpenMetaObjectType::propertyOffset() const
+{
+ return d->propertyOffset;
+}
+
+int QQmlOpenMetaObjectType::signalOffset() const
+{
+ return d->signalOffset;
+}
+
+int QQmlOpenMetaObjectType::createProperty(const QByteArray &name)
+{
+ int id = d->mob.propertyCount();
+ d->mob.addSignal("__" + QByteArray::number(id) + "()");
+ QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
+ propertyCreated(id, build);
+ free(d->mem);
+ d->mem = d->mob.toMetaObject();
+ d->names.insert(name, id);
+ QSet<QQmlOpenMetaObject*>::iterator it = d->referers.begin();
+ while (it != d->referers.end()) {
+ QQmlOpenMetaObject *omo = *it;
+ *static_cast<QMetaObject *>(omo) = *d->mem;
+ if (d->cache)
+ d->cache->update(d->engine, omo);
+ ++it;
+ }
+
+ return d->propertyOffset + id;
+}
+
+void QQmlOpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder)
+{
+ if (d->referers.count())
+ (*d->referers.begin())->propertyCreated(id, builder);
+}
+
+void QQmlOpenMetaObjectTypePrivate::init(const QMetaObject *metaObj)
+{
+ if (!mem) {
+ mob.setSuperClass(metaObj);
+ mob.setClassName(metaObj->className());
+ mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
+
+ mem = mob.toMetaObject();
+
+ propertyOffset = mem->propertyOffset();
+ signalOffset = mem->methodOffset();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+class QQmlOpenMetaObjectPrivate
+{
+public:
+ QQmlOpenMetaObjectPrivate(QQmlOpenMetaObject *_q)
+ : q(_q), parent(0), type(0), cacheProperties(false) {}
+
+ inline QVariant &getData(int idx) {
+ while (data.count() <= idx)
+ data << QPair<QVariant, bool>(QVariant(), false);
+ QPair<QVariant, bool> &prop = data[idx];
+ if (!prop.second) {
+ prop.first = q->initialValue(idx);
+ prop.second = true;
+ }
+ return prop.first;
+ }
+
+ inline void writeData(int idx, const QVariant &value) {
+ while (data.count() <= idx)
+ data << QPair<QVariant, bool>(QVariant(), false);
+ QPair<QVariant, bool> &prop = data[idx];
+ prop.first = value;
+ prop.second = true;
+ }
+
+ inline bool hasData(int idx) const {
+ if (idx >= data.count())
+ return false;
+ return data[idx].second;
+ }
+
+ bool autoCreate;
+ QQmlOpenMetaObject *q;
+ QAbstractDynamicMetaObject *parent;
+ QList<QPair<QVariant, bool> > data;
+ QObject *object;
+ QQmlOpenMetaObjectType *type;
+ bool cacheProperties;
+};
+
+QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, bool automatic)
+: d(new QQmlOpenMetaObjectPrivate(this))
+{
+ d->autoCreate = automatic;
+ d->object = obj;
+
+ d->type = new QQmlOpenMetaObjectType(obj->metaObject(), 0);
+ d->type->d->referers.insert(this);
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ d->parent = static_cast<QAbstractDynamicMetaObject *>(op->metaObject);
+ *static_cast<QMetaObject *>(this) = *d->type->d->mem;
+ op->metaObject = this;
+}
+
+QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, QQmlOpenMetaObjectType *type, bool automatic)
+: d(new QQmlOpenMetaObjectPrivate(this))
+{
+ d->autoCreate = automatic;
+ d->object = obj;
+
+ d->type = type;
+ d->type->addref();
+ d->type->d->referers.insert(this);
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ d->parent = static_cast<QAbstractDynamicMetaObject *>(op->metaObject);
+ *static_cast<QMetaObject *>(this) = *d->type->d->mem;
+ op->metaObject = this;
+}
+
+QQmlOpenMetaObject::~QQmlOpenMetaObject()
+{
+ if (d->parent)
+ delete d->parent;
+ d->type->d->referers.remove(this);
+ d->type->release();
+ delete d;
+}
+
+QQmlOpenMetaObjectType *QQmlOpenMetaObject::type() const
+{
+ return d->type;
+}
+
+int QQmlOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
+{
+ if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty)
+ && id >= d->type->d->propertyOffset) {
+ int propId = id - d->type->d->propertyOffset;
+ if (c == QMetaObject::ReadProperty) {
+ propertyRead(propId);
+ *reinterpret_cast<QVariant *>(a[0]) = d->getData(propId);
+ } else if (c == QMetaObject::WriteProperty) {
+ if (propId <= d->data.count() || d->data[propId].first != *reinterpret_cast<QVariant *>(a[0])) {
+ propertyWrite(propId);
+ d->writeData(propId, *reinterpret_cast<QVariant *>(a[0]));
+ propertyWritten(propId);
+ activate(d->object, d->type->d->signalOffset + propId, 0);
+ }
+ }
+ return -1;
+ } else {
+ if (d->parent)
+ return d->parent->metaCall(c, id, a);
+ else
+ return d->object->qt_metacall(c, id, a);
+ }
+}
+
+QAbstractDynamicMetaObject *QQmlOpenMetaObject::parent() const
+{
+ return d->parent;
+}
+
+QVariant QQmlOpenMetaObject::value(int id) const
+{
+ return d->getData(id);
+}
+
+void QQmlOpenMetaObject::setValue(int id, const QVariant &value)
+{
+ d->writeData(id, value);
+ activate(d->object, id + d->type->d->signalOffset, 0);
+}
+
+QVariant QQmlOpenMetaObject::value(const QByteArray &name) const
+{
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
+ if (iter == d->type->d->names.end())
+ return QVariant();
+
+ return d->getData(*iter);
+}
+
+QVariant &QQmlOpenMetaObject::operator[](const QByteArray &name)
+{
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
+ Q_ASSERT(iter != d->type->d->names.end());
+
+ return d->getData(*iter);
+}
+
+QVariant &QQmlOpenMetaObject::operator[](int id)
+{
+ return d->getData(id);
+}
+
+bool QQmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
+{
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
+
+ int id = -1;
+ if (iter == d->type->d->names.end()) {
+ id = createProperty(name.constData(), "") - d->type->d->propertyOffset;
+ } else {
+ id = *iter;
+ }
+
+ if (id >= 0) {
+ QVariant &dataVal = d->getData(id);
+ if (dataVal == val)
+ return false;
+
+ dataVal = val;
+ activate(d->object, id + d->type->d->signalOffset, 0);
+ return true;
+ }
+
+ return false;
+}
+
+// returns true if this value has been initialized by a call to either value() or setValue()
+bool QQmlOpenMetaObject::hasValue(int id) const
+{
+ return d->hasData(id);
+}
+
+void QQmlOpenMetaObject::setCached(bool c)
+{
+ if (c == d->cacheProperties || !d->type->d->engine)
+ return;
+
+ d->cacheProperties = c;
+
+ QQmlData *qmldata = QQmlData::get(d->object, true);
+ if (d->cacheProperties) {
+ if (!d->type->d->cache)
+ d->type->d->cache = new QQmlPropertyCache(d->type->d->engine, this);
+ qmldata->propertyCache = d->type->d->cache;
+ d->type->d->cache->addref();
+ } else {
+ if (d->type->d->cache)
+ d->type->d->cache->release();
+ qmldata->propertyCache = 0;
+ }
+}
+
+
+int QQmlOpenMetaObject::createProperty(const char *name, const char *)
+{
+ if (d->autoCreate)
+ return d->type->createProperty(name);
+ else
+ return -1;
+}
+
+void QQmlOpenMetaObject::propertyRead(int)
+{
+}
+
+void QQmlOpenMetaObject::propertyWrite(int)
+{
+}
+
+void QQmlOpenMetaObject::propertyWritten(int)
+{
+}
+
+void QQmlOpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &)
+{
+}
+
+QVariant QQmlOpenMetaObject::initialValue(int)
+{
+ return QVariant();
+}
+
+int QQmlOpenMetaObject::count() const
+{
+ return d->type->d->names.count();
+}
+
+QByteArray QQmlOpenMetaObject::name(int idx) const
+{
+ Q_ASSERT(idx >= 0 && idx < d->type->d->names.count());
+
+ return d->type->d->mob.property(idx).name();
+}
+
+QObject *QQmlOpenMetaObject::object() const
+{
+ return d->object;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h
new file mode 100644
index 0000000000..188192edc1
--- /dev/null
+++ b/src/qml/qml/qqmlopenmetaobject_p.h
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLOPENMETAOBJECT_H
+#define QQMLOPENMETAOBJECT_H
+
+#include <QtCore/QMetaObject>
+#include <QtCore/QObject>
+
+#include <private/qqmlrefcount_p.h>
+#include <private/qqmlcleanup_p.h>
+#include <private/qtqmlglobal_p.h>
+#include <private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlEngine;
+class QMetaPropertyBuilder;
+class QQmlOpenMetaObjectTypePrivate;
+class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObjectType : public QQmlRefCount, public QQmlCleanup
+{
+public:
+ QQmlOpenMetaObjectType(const QMetaObject *base, QQmlEngine *engine);
+ ~QQmlOpenMetaObjectType();
+
+ int createProperty(const QByteArray &name);
+
+ int propertyOffset() const;
+ int signalOffset() const;
+
+protected:
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
+ virtual void clear();
+
+private:
+ QQmlOpenMetaObjectTypePrivate *d;
+ friend class QQmlOpenMetaObject;
+ friend class QQmlOpenMetaObjectPrivate;
+};
+
+class QQmlOpenMetaObjectPrivate;
+class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObject : public QAbstractDynamicMetaObject
+{
+public:
+ QQmlOpenMetaObject(QObject *, bool = true);
+ QQmlOpenMetaObject(QObject *, QQmlOpenMetaObjectType *, bool = true);
+ ~QQmlOpenMetaObject();
+
+ QVariant value(const QByteArray &) const;
+ bool setValue(const QByteArray &, const QVariant &);
+ QVariant value(int) const;
+ void setValue(int, const QVariant &);
+ QVariant &operator[](const QByteArray &);
+ QVariant &operator[](int);
+ bool hasValue(int) const;
+
+ int count() const;
+ QByteArray name(int) const;
+
+ QObject *object() const;
+ virtual QVariant initialValue(int);
+
+ // Be careful - once setCached(true) is called createProperty() is no
+ // longer automatically called for new properties.
+ void setCached(bool);
+
+ QQmlOpenMetaObjectType *type() const;
+
+protected:
+ virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
+ virtual int createProperty(const char *, const char *);
+
+ virtual void propertyRead(int);
+ virtual void propertyWrite(int);
+ virtual void propertyWritten(int);
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
+
+ QAbstractDynamicMetaObject *parent() const;
+
+private:
+ QQmlOpenMetaObjectPrivate *d;
+ friend class QQmlOpenMetaObjectType;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLOPENMETAOBJECT_H
diff --git a/src/qml/qml/qqmlparserstatus.cpp b/src/qml/qml/qqmlparserstatus.cpp
new file mode 100644
index 0000000000..d4e415a069
--- /dev/null
+++ b/src/qml/qml/qqmlparserstatus.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlparserstatus.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QQmlParserStatus
+ \since 4.7
+ \brief The QQmlParserStatus class provides updates on the QML parser state.
+
+ QQmlParserStatus provides a mechanism for classes instantiated by
+ a QQmlEngine to receive notification at key points in their creation.
+
+ This class is often used for optimization purposes, as it allows you to defer an
+ expensive operation until after all the properties have been set on an
+ object. For example, QML's \l {Text} element uses the parser status
+ to defer text layout until all of its properties have been set (we
+ don't want to layout when the \c text is assigned, and then relayout
+ when the \c font is assigned, and relayout again when the \c width is assigned,
+ and so on).
+
+ To use QQmlParserStatus, you must inherit both a QObject-derived class
+ and QQmlParserStatus, and use the Q_INTERFACES() macro.
+
+ \code
+ class MyObject : public QObject, public QQmlParserStatus
+ {
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+
+ public:
+ MyObject(QObject *parent = 0);
+ ...
+ void classBegin();
+ void componentComplete();
+ }
+ \endcode
+*/
+
+/*! \internal */
+QQmlParserStatus::QQmlParserStatus()
+: d(0)
+{
+}
+
+/*! \internal */
+QQmlParserStatus::~QQmlParserStatus()
+{
+ if(d)
+ (*d) = 0;
+}
+
+/*!
+ \fn void QQmlParserStatus::classBegin()
+
+ Invoked after class creation, but before any properties have been set.
+*/
+
+/*!
+ \fn void QQmlParserStatus::componentComplete()
+
+ Invoked after the root component that caused this instantiation has
+ completed construction. At this point all static values and binding values
+ have been assigned to the class.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlparserstatus.h b/src/qml/qml/qqmlparserstatus.h
new file mode 100644
index 0000000000..9f06f45b06
--- /dev/null
+++ b/src/qml/qml/qqmlparserstatus.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPARSERSTATUS_H
+#define QQMLPARSERSTATUS_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class Q_QML_EXPORT QQmlParserStatus
+{
+public:
+ QQmlParserStatus();
+ virtual ~QQmlParserStatus();
+
+ virtual void classBegin()=0;
+ virtual void componentComplete()=0;
+
+private:
+ friend class QQmlVME;
+ friend class QQmlComponent;
+ friend class QQmlComponentPrivate;
+ friend class QQmlEnginePrivate;
+ QQmlParserStatus **d;
+};
+Q_DECLARE_INTERFACE(QQmlParserStatus, "com.trolltech.qml.QQmlParserStatus")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLPARSERSTATUS_H
diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h
new file mode 100644
index 0000000000..b4c6fc3a12
--- /dev/null
+++ b/src/qml/qml/qqmlprivate.h
@@ -0,0 +1,265 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPRIVATE_H
+#define QQMLPRIVATE_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 <QtQml/qtqmlglobal.h>
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+typedef QObject *(*QQmlAttachedPropertiesFunc)(QObject *);
+
+template <typename TYPE>
+class QQmlTypeInfo
+{
+public:
+ enum {
+ hasAttachedProperties = 0
+ };
+};
+
+
+class QJSValue;
+class QJSEngine;
+class QQmlEngine;
+class QQmlCustomParser;
+namespace QQmlPrivate
+{
+ void Q_QML_EXPORT qdeclarativeelement_destructor(QObject *);
+ template<typename T>
+ class QQmlElement : public T
+ {
+ public:
+ virtual ~QQmlElement() {
+ QQmlPrivate::qdeclarativeelement_destructor(this);
+ }
+ };
+
+ template<typename T>
+ void createInto(void *memory) { new (memory) QQmlElement<T>; }
+
+ template<typename T>
+ QObject *createParent(QObject *p) { return new T(p); }
+
+ template<class From, class To, int N>
+ struct StaticCastSelectorClass
+ {
+ static inline int cast() { return -1; }
+ };
+
+ template<class From, class To>
+ struct StaticCastSelectorClass<From, To, sizeof(int)>
+ {
+ static inline int cast() { return int(reinterpret_cast<quintptr>(static_cast<To *>(reinterpret_cast<From *>(0x10000000)))) - 0x10000000; }
+ };
+
+ template<class From, class To>
+ struct StaticCastSelector
+ {
+ typedef int yes_type;
+ typedef char no_type;
+
+ static yes_type check(To *);
+ static no_type check(...);
+
+ static inline int cast()
+ {
+ return StaticCastSelectorClass<From, To, sizeof(check(reinterpret_cast<From *>(0)))>::cast();
+ }
+ };
+
+ template <typename T>
+ struct has_attachedPropertiesMember
+ {
+ static bool const value = QQmlTypeInfo<T>::hasAttachedProperties;
+ };
+
+ template <typename T, bool hasMember>
+ class has_attachedPropertiesMethod
+ {
+ public:
+ typedef int yes_type;
+ typedef char no_type;
+
+ template<typename ReturnType>
+ static yes_type check(ReturnType *(*)(QObject *));
+ static no_type check(...);
+
+ static bool const value = sizeof(check(&T::qmlAttachedProperties)) == sizeof(yes_type);
+ };
+
+ template <typename T>
+ class has_attachedPropertiesMethod<T, false>
+ {
+ public:
+ static bool const value = false;
+ };
+
+ template<typename T, int N>
+ class AttachedPropertySelector
+ {
+ public:
+ static inline QQmlAttachedPropertiesFunc func() { return 0; }
+ static inline const QMetaObject *metaObject() { return 0; }
+ };
+ template<typename T>
+ class AttachedPropertySelector<T, 1>
+ {
+ static inline QObject *attachedProperties(QObject *obj) {
+ return T::qmlAttachedProperties(obj);
+ }
+ template<typename ReturnType>
+ static inline const QMetaObject *attachedPropertiesMetaObject(ReturnType *(*)(QObject *)) {
+ return &ReturnType::staticMetaObject;
+ }
+ public:
+ static inline QQmlAttachedPropertiesFunc func() {
+ return &attachedProperties;
+ }
+ static inline const QMetaObject *metaObject() {
+ return attachedPropertiesMetaObject(&T::qmlAttachedProperties);
+ }
+ };
+
+ template<typename T>
+ inline QQmlAttachedPropertiesFunc attachedPropertiesFunc()
+ {
+ return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::func();
+ }
+
+ template<typename T>
+ inline const QMetaObject *attachedPropertiesMetaObject()
+ {
+ 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;
+
+ int typeId;
+ int listId;
+ int objectSize;
+ void (*create)(void *);
+ QString noCreationReason;
+
+ const char *uri;
+ int versionMajor;
+ int versionMinor;
+ const char *elementName;
+ const QMetaObject *metaObject;
+
+ QQmlAttachedPropertiesFunc attachedPropertiesFunction;
+ const QMetaObject *attachedPropertiesMetaObject;
+
+ int parserStatusCast;
+ int valueSourceCast;
+ int valueInterceptorCast;
+
+ QObject *(*extensionObjectCreate)(QObject *);
+ const QMetaObject *extensionMetaObject;
+
+ QQmlCustomParser *customParser;
+ int revision;
+ // If this is extended ensure "version" is bumped!!!
+ };
+
+ struct RegisterInterface {
+ int version;
+
+ int typeId;
+ int listId;
+
+ const char *iid;
+ };
+
+ struct RegisterAutoParent {
+ int version;
+
+ AutoParentFunction function;
+ };
+
+ struct RegisterModuleApi {
+ int version;
+
+ const char *uri;
+ int versionMajor;
+ int versionMinor;
+
+ QJSValue (*scriptApi)(QQmlEngine *, QJSEngine *);
+ QObject *(*qobjectApi)(QQmlEngine *, QJSEngine *);
+ };
+
+ enum RegistrationType {
+ TypeRegistration = 0,
+ InterfaceRegistration = 1,
+ AutoParentRegistration = 2,
+ ModuleApiRegistration = 3
+ };
+
+ int Q_QML_EXPORT qmlregister(RegistrationType, void *);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLPRIVATE_H
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
new file mode 100644
index 0000000000..6321592e9a
--- /dev/null
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -0,0 +1,1917 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlproperty.h"
+#include "qqmlproperty_p.h"
+
+#include "qqml.h"
+#include "qqmlbinding_p.h"
+#include "qqmlcontext.h"
+#include "qqmlcontext_p.h"
+#include "qqmlboundsignal_p.h"
+#include "qqmlengine.h"
+#include "qqmlengine_p.h"
+#include "qqmldata_p.h"
+#include "qqmlstringconverters_p.h"
+#include "qqmllist_p.h"
+#include "qqmlcompiler_p.h"
+#include "qqmlvmemetaobject_p.h"
+#include "qqmlexpression_p.h"
+
+#include <QStringList>
+#include <QtCore/qdebug.h>
+
+#include <math.h>
+
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QList<qreal>)
+Q_DECLARE_METATYPE(QList<bool>)
+Q_DECLARE_METATYPE(QList<QString>)
+Q_DECLARE_METATYPE(QList<QUrl>)
+
+QT_BEGIN_NAMESPACE
+
+/*!
+\class QQmlProperty
+\since 4.7
+\brief The QQmlProperty class abstracts accessing properties on objects created from QML.
+
+As QML uses Qt's meta-type system all of the existing QMetaObject classes can be used to introspect
+and interact with objects created by QML. However, some of the new features provided by QML - such
+as type safety and attached properties - are most easily used through the QQmlProperty class
+that simplifies some of their natural complexity.
+
+Unlike QMetaProperty which represents a property on a class type, QQmlProperty encapsulates
+a property on a specific object instance. To read a property's value, programmers create a
+QQmlProperty instance and call the read() method. Likewise to write a property value the
+write() method is used.
+
+For example, for the following QML code:
+
+\qml
+// MyItem.qml
+import QtQuick 2.0
+
+Text { text: "A bit of text" }
+\endqml
+
+The \l Text object's properties could be accessed using QQmlProperty, like this:
+
+\code
+#include <QQmlProperty>
+#include <QGraphicsObject>
+
+...
+
+QQuickView view(QUrl::fromLocalFile("MyItem.qml"));
+QQmlProperty property(view.rootObject(), "font.pixelSize");
+qWarning() << "Current pixel size:" << property.read().toInt();
+property.write(24);
+qWarning() << "Pixel size should now be 24:" << property.read().toInt();
+\endcode
+*/
+
+/*!
+ Create an invalid QQmlProperty.
+*/
+QQmlProperty::QQmlProperty()
+: d(0)
+{
+}
+
+/*! \internal */
+QQmlProperty::~QQmlProperty()
+{
+ if (d)
+ d->release();
+ d = 0;
+}
+
+/*!
+ Creates a QQmlProperty for the default property of \a obj. If there is no
+ default property, an invalid QQmlProperty will be created.
+ */
+QQmlProperty::QQmlProperty(QObject *obj)
+: d(new QQmlPropertyPrivate)
+{
+ d->initDefault(obj);
+}
+
+/*!
+ Creates a QQmlProperty for the default property of \a obj
+ using the \l{QQmlContext} {context} \a ctxt. If there is
+ no default property, an invalid QQmlProperty will be
+ created.
+ */
+QQmlProperty::QQmlProperty(QObject *obj, QQmlContext *ctxt)
+: d(new QQmlPropertyPrivate)
+{
+ d->context = ctxt?QQmlContextData::get(ctxt):0;
+ d->engine = ctxt?ctxt->engine():0;
+ d->initDefault(obj);
+}
+
+/*!
+ Creates a QQmlProperty for the default property of \a obj
+ using the environment for instantiating QML components that is
+ provided by \a engine. If there is no default property, an
+ invalid QQmlProperty will be created.
+ */
+QQmlProperty::QQmlProperty(QObject *obj, QQmlEngine *engine)
+ : d(new QQmlPropertyPrivate)
+{
+ d->context = 0;
+ d->engine = engine;
+ d->initDefault(obj);
+}
+
+/*!
+ Initialize from the default property of \a obj
+*/
+void QQmlPropertyPrivate::initDefault(QObject *obj)
+{
+ if (!obj)
+ return;
+
+ QMetaProperty p = QQmlMetaType::defaultProperty(obj);
+ core.load(p);
+ if (core.isValid())
+ object = obj;
+}
+
+/*!
+ Creates a QQmlProperty for the property \a name of \a obj.
+ */
+QQmlProperty::QQmlProperty(QObject *obj, const QString &name)
+: d(new QQmlPropertyPrivate)
+{
+ d->initProperty(obj, name);
+ if (!isValid()) d->object = 0;
+}
+
+/*!
+ Creates a QQmlProperty for the property \a name of \a obj
+ using the \l{QQmlContext} {context} \a ctxt.
+
+ Creating a QQmlProperty without a context will render some
+ properties - like attached properties - inaccessible.
+*/
+QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlContext *ctxt)
+: d(new QQmlPropertyPrivate)
+{
+ d->context = ctxt?QQmlContextData::get(ctxt):0;
+ d->engine = ctxt?ctxt->engine():0;
+ d->initProperty(obj, name);
+ if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
+}
+
+/*!
+ Creates a QQmlProperty for the property \a name of \a obj
+ using the environment for instantiating QML components that is
+ provided by \a engine.
+ */
+QQmlProperty::QQmlProperty(QObject *obj, const QString &name, QQmlEngine *engine)
+: d(new QQmlPropertyPrivate)
+{
+ d->context = 0;
+ d->engine = engine;
+ d->initProperty(obj, name);
+ if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
+}
+
+Q_GLOBAL_STATIC(QQmlValueTypeFactory, qmlValueTypes);
+
+QQmlPropertyPrivate::QQmlPropertyPrivate()
+: context(0), engine(0), object(0), isNameCached(false)
+{
+}
+
+QQmlContextData *QQmlPropertyPrivate::effectiveContext() const
+{
+ if (context) return context;
+ else if (engine) return QQmlContextData::get(engine->rootContext());
+ else return 0;
+}
+
+void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
+{
+ if (!obj) return;
+
+ QQmlTypeNameCache *typeNameCache = context?context->imports:0;
+
+ QStringList path = name.split(QLatin1Char('.'));
+ if (path.isEmpty()) return;
+
+ QObject *currentObject = obj;
+
+ // Everything up to the last property must be an "object type" property
+ for (int ii = 0; ii < path.count() - 1; ++ii) {
+ const QString &pathName = path.at(ii);
+
+ if (typeNameCache) {
+ QQmlTypeNameCache::Result r = typeNameCache->query(pathName);
+ if (r.isValid()) {
+ if (r.type) {
+ QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction();
+ if (!func) return; // Not an attachable type
+
+ currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(), currentObject);
+ if (!currentObject) return; // Something is broken with the attachable type
+ } else if (r.importNamespace) {
+ if ((ii + 1) == path.count()) return; // No type following the namespace
+
+ ++ii; r = typeNameCache->query(path.at(ii), r.importNamespace);
+ if (!r.type) return; // Invalid type in namespace
+
+ QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction();
+ if (!func) return; // Not an attachable type
+
+ currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(), currentObject);
+ if (!currentObject) return; // Something is broken with the attachable type
+
+ } else if (r.scriptIndex != -1) {
+ return; // Not a type
+ } else {
+ Q_ASSERT(!"Unreachable");
+ }
+ continue;
+ }
+
+ }
+
+ QQmlPropertyData local;
+ QQmlPropertyData *property =
+ QQmlPropertyCache::property(engine, obj, pathName, local);
+
+ if (!property) return; // Not a property
+ if (property->isFunction())
+ return; // Not an object property
+
+ if (ii == (path.count() - 2) && QQmlValueTypeFactory::isValueType(property->propType)) {
+ // We're now at a value type property. We can use a global valuetypes array as we
+ // never actually use the objects, just look up their properties.
+ QObject *typeObject = (*qmlValueTypes())[property->propType];
+ if (!typeObject) return; // Not a value type
+
+ int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
+ if (idx == -1) return; // Value type property does not exist
+
+ QMetaProperty vtProp = typeObject->metaObject()->property(idx);
+
+ typedef QQmlPropertyData PCD;
+
+ Q_ASSERT(PCD::flagsForProperty(vtProp) <= PCD::ValueTypeFlagMask);
+ Q_ASSERT(vtProp.userType() <= 0xFF);
+ Q_ASSERT(idx <= 0xFF);
+
+ object = currentObject;
+ core = *property;
+ core.setFlags(core.getFlags() | PCD::IsValueTypeVirtual);
+ core.valueTypeFlags = PCD::flagsForProperty(vtProp);
+ core.valueTypePropType = vtProp.userType();
+ core.valueTypeCoreIndex = idx;
+
+ return;
+ } else {
+ if (!property->isQObject())
+ return; // Not an object property
+
+ void *args[] = { &currentObject, 0 };
+ QMetaObject::metacall(currentObject, QMetaObject::ReadProperty, property->coreIndex, args);
+ if (!currentObject) return; // No value
+
+ }
+
+ }
+
+ const QString &terminal = path.last();
+
+ if (terminal.count() >= 3 &&
+ terminal.at(0) == QLatin1Char('o') &&
+ terminal.at(1) == QLatin1Char('n') &&
+ terminal.at(2).isUpper()) {
+
+ QString signalName = terminal.mid(2);
+ signalName[0] = signalName.at(0).toLower();
+
+ QMetaMethod method = findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData());
+ if (method.signature()) {
+ object = currentObject;
+ core.load(method);
+ return;
+ }
+ }
+
+ // Property
+ QQmlPropertyData local;
+ QQmlPropertyData *property =
+ QQmlPropertyCache::property(engine, currentObject, terminal, local);
+ if (property && !property->isFunction()) {
+ object = currentObject;
+ core = *property;
+ nameCache = terminal;
+ isNameCached = true;
+ }
+}
+
+/*!
+ Create a copy of \a other.
+*/
+QQmlProperty::QQmlProperty(const QQmlProperty &other)
+{
+ d = other.d;
+ if (d)
+ d->addref();
+}
+
+/*!
+ \enum QQmlProperty::PropertyTypeCategory
+
+ This enum specifies a category of QML property.
+
+ \value InvalidCategory The property is invalid, or is a signal property.
+ \value List The property is a QQmlListProperty list property
+ \value Object The property is a QObject derived type pointer
+ \value Normal The property is a normal value property.
+ */
+
+/*!
+ \enum QQmlProperty::Type
+
+ This enum specifies a type of QML property.
+
+ \value Invalid The property is invalid.
+ \value Property The property is a regular Qt property.
+ \value SignalProperty The property is a signal property.
+*/
+
+/*!
+ Returns the property category.
+*/
+QQmlProperty::PropertyTypeCategory QQmlProperty::propertyTypeCategory() const
+{
+ return d ? d->propertyTypeCategory() : InvalidCategory;
+}
+
+QQmlProperty::PropertyTypeCategory
+QQmlPropertyPrivate::propertyTypeCategory() const
+{
+ uint type = this->type();
+
+ if (isValueType()) {
+ return QQmlProperty::Normal;
+ } else if (type & QQmlProperty::Property) {
+ int type = propertyType();
+ if (type == QVariant::Invalid)
+ return QQmlProperty::InvalidCategory;
+ else if (QQmlValueTypeFactory::isValueType((uint)type))
+ return QQmlProperty::Normal;
+ else if (core.isQObject())
+ return QQmlProperty::Object;
+ else if (core.isQList())
+ return QQmlProperty::List;
+ else
+ return QQmlProperty::Normal;
+ } else {
+ return QQmlProperty::InvalidCategory;
+ }
+}
+
+/*!
+ Returns the type name of the property, or 0 if the property has no type
+ name.
+*/
+const char *QQmlProperty::propertyTypeName() const
+{
+ if (!d)
+ return 0;
+ if (d->isValueType()) {
+
+ QQmlEnginePrivate *ep = d->engine?QQmlEnginePrivate::get(d->engine):0;
+ QQmlValueType *valueType = 0;
+ if (ep) valueType = ep->valueTypes[d->core.propType];
+ else valueType = QQmlValueTypeFactory::valueType(d->core.propType);
+ Q_ASSERT(valueType);
+
+ const char *rv = valueType->metaObject()->property(d->core.valueTypeCoreIndex).typeName();
+
+ if (!ep) delete valueType;
+
+ return rv;
+ } else if (d->object && type() & Property && d->core.isValid()) {
+ return d->object->metaObject()->property(d->core.coreIndex).typeName();
+ } else {
+ return 0;
+ }
+}
+
+/*!
+ Returns true if \a other and this QQmlProperty represent the same
+ property.
+*/
+bool QQmlProperty::operator==(const QQmlProperty &other) const
+{
+ if (!d || !other.d)
+ return false;
+ // category is intentially omitted here as it is generated
+ // from the other members
+ return d->object == other.d->object &&
+ d->core.coreIndex == other.d->core.coreIndex &&
+ d->core.isValueTypeVirtual() == other.d->core.isValueTypeVirtual() &&
+ (!d->core.isValueTypeVirtual() ||
+ (d->core.valueTypeCoreIndex == other.d->core.valueTypeCoreIndex &&
+ d->core.valueTypePropType == other.d->core.valueTypePropType));
+}
+
+/*!
+ Returns the QVariant type of the property, or QVariant::Invalid if the
+ property has no QVariant type.
+*/
+int QQmlProperty::propertyType() const
+{
+ return d ? d->propertyType() : int(QVariant::Invalid);
+}
+
+bool QQmlPropertyPrivate::isValueType() const
+{
+ return core.isValueTypeVirtual();
+}
+
+int QQmlPropertyPrivate::propertyType() const
+{
+ uint type = this->type();
+ if (isValueType()) {
+ return core.valueTypePropType;
+ } else if (type & QQmlProperty::Property) {
+ return core.propType;
+ } else {
+ return QVariant::Invalid;
+ }
+}
+
+QQmlProperty::Type QQmlPropertyPrivate::type() const
+{
+ if (core.isFunction())
+ return QQmlProperty::SignalProperty;
+ else if (core.isValid())
+ return QQmlProperty::Property;
+ else
+ return QQmlProperty::Invalid;
+}
+
+/*!
+ Returns the type of the property.
+*/
+QQmlProperty::Type QQmlProperty::type() const
+{
+ return d ? d->type() : Invalid;
+}
+
+/*!
+ Returns true if this QQmlProperty represents a regular Qt property.
+*/
+bool QQmlProperty::isProperty() const
+{
+ return type() & Property;
+}
+
+/*!
+ Returns true if this QQmlProperty represents a QML signal property.
+*/
+bool QQmlProperty::isSignalProperty() const
+{
+ return type() & SignalProperty;
+}
+
+/*!
+ Returns the QQmlProperty's QObject.
+*/
+QObject *QQmlProperty::object() const
+{
+ return d ? d->object : 0;
+}
+
+/*!
+ Assign \a other to this QQmlProperty.
+*/
+QQmlProperty &QQmlProperty::operator=(const QQmlProperty &other)
+{
+ if (d)
+ d->release();
+ d = other.d;
+ if (d)
+ d->addref();
+
+ return *this;
+}
+
+/*!
+ Returns true if the property is writable, otherwise false.
+*/
+bool QQmlProperty::isWritable() const
+{
+ if (!d)
+ return false;
+ if (!d->object)
+ return false;
+ if (d->core.isQList()) //list
+ return true;
+ else if (d->core.isFunction()) //signal handler
+ return false;
+ else if (d->core.isValid()) //normal property
+ return d->core.isWritable();
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is designable, otherwise false.
+*/
+bool QQmlProperty::isDesignable() const
+{
+ if (!d)
+ return false;
+ if (type() & Property && d->core.isValid() && d->object)
+ return d->object->metaObject()->property(d->core.coreIndex).isDesignable();
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property is resettable, otherwise false.
+*/
+bool QQmlProperty::isResettable() const
+{
+ if (!d)
+ return false;
+ if (type() & Property && d->core.isValid() && d->object)
+ return d->core.isResettable();
+ else
+ return false;
+}
+
+/*!
+ Returns true if the QQmlProperty refers to a valid property, otherwise
+ false.
+*/
+bool QQmlProperty::isValid() const
+{
+ if (!d)
+ return false;
+ return type() != Invalid;
+}
+
+/*!
+ Return the name of this QML property.
+*/
+QString QQmlProperty::name() const
+{
+ if (!d)
+ return QString();
+ if (!d->isNameCached) {
+ // ###
+ if (!d->object) {
+ } else if (d->isValueType()) {
+ QString rv = d->core.name(d->object) + QLatin1Char('.');
+
+ QQmlEnginePrivate *ep = d->engine?QQmlEnginePrivate::get(d->engine):0;
+ QQmlValueType *valueType = 0;
+ if (ep) valueType = ep->valueTypes[d->core.propType];
+ else valueType = QQmlValueTypeFactory::valueType(d->core.propType);
+ Q_ASSERT(valueType);
+
+ const char *vtName = valueType->metaObject()->property(d->core.valueTypeCoreIndex).name();
+ rv += QString::fromUtf8(vtName);
+
+ if (!ep) delete valueType;
+
+ d->nameCache = rv;
+ } else if (type() & SignalProperty) {
+ QString name = QLatin1String("on") + d->core.name(d->object);
+ name[2] = name.at(2).toUpper();
+ d->nameCache = name;
+ } else {
+ d->nameCache = d->core.name(d->object);
+ }
+ d->isNameCached = true;
+ }
+
+ return d->nameCache;
+}
+
+/*!
+ Returns the \l{QMetaProperty} {Qt property} associated with
+ this QML property.
+ */
+QMetaProperty QQmlProperty::property() const
+{
+ if (!d)
+ return QMetaProperty();
+ if (type() & Property && d->core.isValid() && d->object)
+ return d->object->metaObject()->property(d->core.coreIndex);
+ else
+ return QMetaProperty();
+}
+
+/*!
+ Return the QMetaMethod for this property if it is a SignalProperty,
+ otherwise returns an invalid QMetaMethod.
+*/
+QMetaMethod QQmlProperty::method() const
+{
+ if (!d)
+ return QMetaMethod();
+ if (type() & SignalProperty && d->object)
+ return d->object->metaObject()->method(d->core.coreIndex);
+ else
+ return QMetaMethod();
+}
+
+/*!
+ Returns the binding associated with this property, or 0 if no binding
+ exists.
+*/
+QQmlAbstractBinding *
+QQmlPropertyPrivate::binding(const QQmlProperty &that)
+{
+ if (!that.d || !that.isProperty() || !that.d->object)
+ return 0;
+
+ return binding(that.d->object, that.d->core.coreIndex,
+ that.d->core.getValueTypeCoreIndex());
+}
+
+/*!
+ Set the binding associated with this property to \a newBinding. Returns
+ the existing binding (if any), otherwise 0.
+
+ \a newBinding will be enabled, and the returned binding (if any) will be
+ disabled.
+
+ Ownership of \a newBinding transfers to QML. Ownership of the return value
+ is assumed by the caller.
+
+ \a flags is passed through to the binding and is used for the initial update (when
+ the binding sets the initial value, it will use these flags for the write).
+*/
+QQmlAbstractBinding *
+QQmlPropertyPrivate::setBinding(const QQmlProperty &that,
+ QQmlAbstractBinding *newBinding,
+ WriteFlags flags)
+{
+ if (!that.d || !that.isProperty() || !that.d->object) {
+ if (newBinding)
+ newBinding->destroy();
+ return 0;
+ }
+
+ if (newBinding) {
+ // In the case that the new binding is provided, we must target the property it
+ // is associated with. If we don't do this, retargetBinding() can fail.
+ QObject *object = newBinding->object();
+ int pi = newBinding->propertyIndex();
+
+ int core = pi & 0xFFFFFF;
+ int vt = (pi & 0xFF000000)?(pi >> 24):-1;
+
+ return setBinding(object, core, vt, newBinding, flags);
+ } else {
+ return setBinding(that.d->object, that.d->core.coreIndex,
+ that.d->core.getValueTypeCoreIndex(),
+ newBinding, flags);
+ }
+}
+
+QQmlAbstractBinding *
+QQmlPropertyPrivate::binding(QObject *object, int coreIndex, int valueTypeIndex)
+{
+ QQmlData *data = QQmlData::get(object);
+ if (!data)
+ return 0;
+
+ QQmlPropertyData *propertyData =
+ data->propertyCache?data->propertyCache->property(coreIndex):0;
+ if (propertyData && propertyData->isAlias()) {
+ const QQmlVMEMetaObject *vme =
+ static_cast<const QQmlVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
+
+ QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
+ if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex) || aCoreIndex == -1)
+ return 0;
+
+ // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
+ Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
+ aValueTypeIndex = (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex;
+ return binding(aObject, aCoreIndex, aValueTypeIndex);
+ }
+
+ if (!data->hasBindingBit(coreIndex))
+ return 0;
+
+ QQmlAbstractBinding *binding = data->bindings;
+ while (binding && binding->propertyIndex() != coreIndex)
+ binding = binding->m_nextBinding;
+
+ if (binding && valueTypeIndex != -1) {
+ if (binding->bindingType() == QQmlAbstractBinding::ValueTypeProxy) {
+ int index = coreIndex | (valueTypeIndex << 24);
+ binding = static_cast<QQmlValueTypeProxyBinding *>(binding)->binding(index);
+ }
+ }
+
+ return binding;
+}
+
+void QQmlPropertyPrivate::findAliasTarget(QObject *object, int bindingIndex,
+ QObject **targetObject, int *targetBindingIndex)
+{
+ int coreIndex = bindingIndex & 0xFFFFFF;
+ int valueTypeIndex = bindingIndex >> 24;
+ if (valueTypeIndex == 0) valueTypeIndex = -1;
+
+ QQmlData *data = QQmlData::get(object, false);
+ if (data) {
+ QQmlPropertyData *propertyData =
+ data->propertyCache?data->propertyCache->property(coreIndex):0;
+ if (propertyData && propertyData->isAlias()) {
+ const QQmlVMEMetaObject *vme =
+ static_cast<const QQmlVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
+ QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
+ if (vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
+ // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
+ Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
+
+ int aBindingIndex = aCoreIndex;
+ if (aValueTypeIndex != -1)
+ aBindingIndex |= aValueTypeIndex << 24;
+ else if (valueTypeIndex != -1)
+ aBindingIndex |= valueTypeIndex << 24;
+
+ findAliasTarget(aObject, aBindingIndex, targetObject, targetBindingIndex);
+ return;
+ }
+ }
+ }
+
+ *targetObject = object;
+ *targetBindingIndex = bindingIndex;
+}
+
+QQmlAbstractBinding *
+QQmlPropertyPrivate::setBinding(QObject *object, int coreIndex, int valueTypeIndex,
+ QQmlAbstractBinding *newBinding, WriteFlags flags)
+{
+ QQmlData *data = QQmlData::get(object, 0 != newBinding);
+ QQmlAbstractBinding *binding = 0;
+
+ if (data) {
+ QQmlPropertyData *propertyData =
+ data->propertyCache?data->propertyCache->property(coreIndex):0;
+ if (propertyData && propertyData->isAlias()) {
+ const QQmlVMEMetaObject *vme =
+ static_cast<const QQmlVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
+
+ QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
+ if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
+ if (newBinding) newBinding->destroy();
+ return 0;
+ }
+
+ // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
+ Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
+ aValueTypeIndex = (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex;
+ return setBinding(aObject, aCoreIndex, aValueTypeIndex, newBinding, flags);
+ }
+ }
+
+ if (data && data->hasBindingBit(coreIndex)) {
+ binding = data->bindings;
+
+ while (binding && binding->propertyIndex() != coreIndex)
+ binding = binding->m_nextBinding;
+ }
+
+ int index = coreIndex;
+ if (valueTypeIndex != -1)
+ index |= (valueTypeIndex << 24);
+
+ if (binding && valueTypeIndex != -1 && binding->bindingType() == QQmlAbstractBinding::ValueTypeProxy)
+ binding = static_cast<QQmlValueTypeProxyBinding *>(binding)->binding(index);
+
+ if (binding) {
+ binding->removeFromObject();
+ binding->setEnabled(false, 0);
+ }
+
+ if (newBinding) {
+ if (newBinding->propertyIndex() != index || newBinding->object() != object)
+ newBinding->retargetBinding(object, index);
+
+ Q_ASSERT(newBinding->propertyIndex() == index);
+ Q_ASSERT(newBinding->object() == object);
+
+ newBinding->addToObject();
+ newBinding->setEnabled(true, flags);
+ }
+
+ return binding;
+}
+
+QQmlAbstractBinding *
+QQmlPropertyPrivate::setBindingNoEnable(QObject *object, int coreIndex, int valueTypeIndex,
+ QQmlAbstractBinding *newBinding)
+{
+ QQmlData *data = QQmlData::get(object, 0 != newBinding);
+ QQmlAbstractBinding *binding = 0;
+
+ if (data) {
+ QQmlPropertyData *propertyData =
+ data->propertyCache?data->propertyCache->property(coreIndex):0;
+ if (propertyData && propertyData->isAlias()) {
+ const QQmlVMEMetaObject *vme =
+ static_cast<const QQmlVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
+
+ QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
+ if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
+ if (newBinding) newBinding->destroy();
+ return 0;
+ }
+
+ // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
+ Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
+ aValueTypeIndex = (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex;
+ return setBindingNoEnable(aObject, aCoreIndex, aValueTypeIndex, newBinding);
+ }
+ }
+
+ if (data && data->hasBindingBit(coreIndex)) {
+ binding = data->bindings;
+
+ while (binding && binding->propertyIndex() != coreIndex)
+ binding = binding->m_nextBinding;
+ }
+
+ int index = coreIndex;
+ if (valueTypeIndex != -1)
+ index |= (valueTypeIndex << 24);
+
+ if (binding && valueTypeIndex != -1 && binding->bindingType() == QQmlAbstractBinding::ValueTypeProxy)
+ binding = static_cast<QQmlValueTypeProxyBinding *>(binding)->binding(index);
+
+ if (binding)
+ binding->removeFromObject();
+
+ if (newBinding) {
+ if (newBinding->propertyIndex() != index || newBinding->object() != object)
+ newBinding->retargetBinding(object, index);
+
+ Q_ASSERT(newBinding->propertyIndex() == index);
+ Q_ASSERT(newBinding->object() == object);
+
+ newBinding->addToObject();
+ }
+
+ return binding;
+}
+
+/*!
+ Returns the expression associated with this signal property, or 0 if no
+ signal expression exists.
+*/
+QQmlExpression *
+QQmlPropertyPrivate::signalExpression(const QQmlProperty &that)
+{
+ if (!(that.type() & QQmlProperty::SignalProperty))
+ return 0;
+
+ const QObjectList &children = that.d->object->children();
+
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+
+ QQmlBoundSignal *signal = QQmlBoundSignal::cast(child);
+ if (signal && signal->index() == that.index())
+ return signal->expression();
+ }
+
+ return 0;
+}
+
+/*!
+ Set the signal expression associated with this signal property to \a expr.
+ Returns the existing signal expression (if any), otherwise 0.
+
+ Ownership of \a expr transfers to QML. Ownership of the return value is
+ assumed by the caller.
+*/
+QQmlExpression *
+QQmlPropertyPrivate::setSignalExpression(const QQmlProperty &that,
+ QQmlExpression *expr)
+{
+ if (!(that.type() & QQmlProperty::SignalProperty)) {
+ delete expr;
+ return 0;
+ }
+
+ const QObjectList &children = that.d->object->children();
+
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+
+ QQmlBoundSignal *signal = QQmlBoundSignal::cast(child);
+ if (signal && signal->index() == that.index())
+ return signal->setExpression(expr);
+ }
+
+ if (expr) {
+ QQmlBoundSignal *signal = new QQmlBoundSignal(that.d->object, that.method(), that.d->object);
+ return signal->setExpression(expr);
+ } else {
+ return 0;
+ }
+}
+
+/*!
+ Returns the property value.
+*/
+QVariant QQmlProperty::read() const
+{
+ if (!d)
+ return QVariant();
+ if (!d->object)
+ return QVariant();
+
+ if (type() & SignalProperty) {
+
+ return QVariant();
+
+ } else if (type() & Property) {
+
+ return d->readValueProperty();
+
+ }
+ return QVariant();
+}
+
+/*!
+Return the \a name property value of \a object. This method is equivalent to:
+\code
+ QQmlProperty p(object, name);
+ p.read();
+\endcode
+*/
+QVariant QQmlProperty::read(QObject *object, const QString &name)
+{
+ QQmlProperty p(object, name);
+ return p.read();
+}
+
+/*!
+ Return the \a name property value of \a object using the
+ \l{QQmlContext} {context} \a ctxt. This method is
+ equivalent to:
+
+ \code
+ QQmlProperty p(object, name, context);
+ p.read();
+ \endcode
+*/
+QVariant QQmlProperty::read(QObject *object, const QString &name, QQmlContext *ctxt)
+{
+ QQmlProperty p(object, name, ctxt);
+ return p.read();
+}
+
+/*!
+
+ Return the \a name property value of \a object using the environment
+ for instantiating QML components that is provided by \a engine. .
+ This method is equivalent to:
+
+ \code
+ QQmlProperty p(object, name, engine);
+ p.read();
+ \endcode
+*/
+QVariant QQmlProperty::read(QObject *object, const QString &name, QQmlEngine *engine)
+{
+ QQmlProperty p(object, name, engine);
+ return p.read();
+}
+
+QVariant QQmlPropertyPrivate::readValueProperty()
+{
+ if (isValueType()) {
+
+ QQmlEnginePrivate *ep = engine?QQmlEnginePrivate::get(engine):0;
+ QQmlValueType *valueType = 0;
+ if (ep) valueType = ep->valueTypes[core.propType];
+ else valueType = QQmlValueTypeFactory::valueType(core.propType);
+ Q_ASSERT(valueType);
+
+ valueType->read(object, core.coreIndex);
+
+ QVariant rv = valueType->metaObject()->property(core.valueTypeCoreIndex).read(valueType);
+
+ if (!ep) delete valueType;
+ return rv;
+
+ } else if (core.isQList()) {
+
+ QQmlListProperty<QObject> prop;
+ void *args[] = { &prop, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
+ return QVariant::fromValue(QQmlListReferencePrivate::init(prop, core.propType, engine));
+
+ } else if (core.isQObject()) {
+
+ QObject *rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
+ return QVariant::fromValue(rv);
+
+ } else {
+
+ return object->metaObject()->property(core.coreIndex).read(object.data());
+
+ }
+}
+
+static QUrl urlFromUserString(const QByteArray &data)
+{
+ QUrl u;
+ if (!data.isEmpty())
+ {
+ // Preserve any valid percent-encoded octets supplied by the source
+ u.setEncodedUrl(data, QUrl::TolerantMode);
+ }
+ return u;
+}
+
+static QUrl urlFromUserString(const QString &data)
+{
+ return urlFromUserString(data.toUtf8());
+}
+
+// helper function to allow assignment / binding to QList<QUrl> properties.
+static QVariant resolvedUrlSequence(const QVariant &value, QQmlContextData *context)
+{
+ QList<QUrl> urls;
+ if (value.userType() == qMetaTypeId<QUrl>()) {
+ urls.append(value.toUrl());
+ } else if (value.userType() == qMetaTypeId<QString>()) {
+ urls.append(urlFromUserString(value.toString()));
+ } else if (value.userType() == qMetaTypeId<QByteArray>()) {
+ urls.append(urlFromUserString(value.toByteArray()));
+ } else if (value.userType() == qMetaTypeId<QList<QUrl> >()) {
+ urls = value.value<QList<QUrl> >();
+ } else if (value.userType() == qMetaTypeId<QStringList>()) {
+ QStringList urlStrings = value.value<QStringList>();
+ for (int i = 0; i < urlStrings.size(); ++i)
+ urls.append(urlFromUserString(urlStrings.at(i)));
+ } else if (value.userType() == qMetaTypeId<QList<QString> >()) {
+ QList<QString> urlStrings = value.value<QList<QString> >();
+ for (int i = 0; i < urlStrings.size(); ++i)
+ urls.append(urlFromUserString(urlStrings.at(i)));
+ } // note: QList<QByteArray> is not currently supported.
+
+ QList<QUrl> resolvedUrls;
+ for (int i = 0; i < urls.size(); ++i) {
+ QUrl u = urls.at(i);
+ if (context && u.isRelative() && !u.isEmpty())
+ u = context->resolvedUrl(u);
+ resolvedUrls.append(u);
+ }
+
+ return QVariant::fromValue<QList<QUrl> >(resolvedUrls);
+}
+
+//writeEnumProperty MIRRORS the relelvant bit of QMetaProperty::write AND MUST BE KEPT IN SYNC!
+bool QQmlPropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
+{
+ if (!object || !prop.isWritable())
+ return false;
+
+ QVariant v = value;
+ if (prop.isEnumType()) {
+ QMetaEnum menum = prop.enumerator();
+ if (v.userType() == QVariant::String
+#ifdef QT3_SUPPORT
+ || v.userType() == QVariant::CString
+#endif
+ ) {
+ bool ok;
+ if (prop.isFlagType())
+ v = QVariant(menum.keysToValue(value.toByteArray(), &ok));
+ else
+ v = QVariant(menum.keyToValue(value.toByteArray(), &ok));
+ if (!ok)
+ return false;
+ } else if (v.userType() != QVariant::Int && v.userType() != QVariant::UInt) {
+ int enumMetaTypeId = QMetaType::type(QByteArray(menum.scope() + QByteArray("::") + menum.name()));
+ if ((enumMetaTypeId == 0) || (v.userType() != enumMetaTypeId) || !v.constData())
+ return false;
+ v = QVariant(*reinterpret_cast<const int *>(v.constData()));
+ }
+ v.convert(QVariant::Int);
+ }
+
+ // the status variable is changed by qt_metacall to indicate what it did
+ // this feature is currently only used by QtDBus and should not be depended
+ // upon. Don't change it without looking into QDBusAbstractInterface first
+ // -1 (unchanged): normal qt_metacall, result stored in argv[0]
+ // changed: result stored directly in value, return the value of status
+ int status = -1;
+ void *argv[] = { v.data(), &v, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, idx, argv);
+ return status;
+}
+
+bool QQmlPropertyPrivate::writeValueProperty(const QVariant &value, WriteFlags flags)
+{
+ return writeValueProperty(object, engine, core, value, effectiveContext(), flags);
+}
+
+bool
+QQmlPropertyPrivate::writeValueProperty(QObject *object, QQmlEngine *engine,
+ const QQmlPropertyData &core,
+ const QVariant &value,
+ QQmlContextData *context, WriteFlags flags)
+{
+ // Remove any existing bindings on this property
+ if (!(flags & DontRemoveBinding) && object) {
+ QQmlAbstractBinding *binding = setBinding(object, core.coreIndex,
+ core.getValueTypeCoreIndex(),
+ 0, flags);
+ if (binding) binding->destroy();
+ }
+
+ bool rv = false;
+ if (core.isValueTypeVirtual()) {
+ QQmlEnginePrivate *ep = engine?QQmlEnginePrivate::get(engine):0;
+
+ QQmlValueType *writeBack = 0;
+ if (ep) {
+ writeBack = ep->valueTypes[core.propType];
+ } else {
+ writeBack = QQmlValueTypeFactory::valueType(core.propType);
+ }
+
+ writeBack->read(object, core.coreIndex);
+
+ QQmlPropertyData data = core;
+ data.setFlags(QQmlPropertyData::Flag(core.valueTypeFlags));
+ data.coreIndex = core.valueTypeCoreIndex;
+ data.propType = core.valueTypePropType;
+
+ rv = write(writeBack, data, value, context, flags);
+
+ writeBack->write(object, core.coreIndex, flags);
+ if (!ep) delete writeBack;
+
+ } else {
+
+ rv = write(object, core, value, context, flags);
+
+ }
+
+ return rv;
+}
+
+bool QQmlPropertyPrivate::write(QObject *object,
+ const QQmlPropertyData &property,
+ const QVariant &value, QQmlContextData *context,
+ WriteFlags flags)
+{
+ int coreIdx = property.coreIndex;
+ int status = -1; //for dbus
+
+ if (property.isEnum()) {
+ QMetaProperty prop = object->metaObject()->property(property.coreIndex);
+ QVariant v = value;
+ // Enum values come through the script engine as doubles
+ if (value.userType() == QVariant::Double) {
+ double integral;
+ double fractional = modf(value.toDouble(), &integral);
+ if (qFuzzyIsNull(fractional))
+ v.convert(QVariant::Int);
+ }
+ return writeEnumProperty(prop, coreIdx, object, v, flags);
+ }
+
+ int propertyType = property.propType;
+ int variantType = value.userType();
+
+ QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(context);
+
+ if (propertyType == QVariant::Url) {
+
+ QUrl u;
+ bool found = false;
+ if (variantType == QVariant::Url) {
+ u = value.toUrl();
+ found = true;
+ } else if (variantType == QVariant::ByteArray) {
+ u = urlFromUserString(value.toByteArray());
+ found = true;
+ } else if (variantType == QVariant::String) {
+ u = urlFromUserString(value.toString());
+ found = true;
+ }
+
+ if (!found)
+ return false;
+
+ if (context && u.isRelative() && !u.isEmpty())
+ u = context->resolvedUrl(u);
+ int status = -1;
+ void *argv[] = { &u, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv);
+
+ } else if (propertyType == qMetaTypeId<QList<QUrl> >()) {
+ QList<QUrl> urlSeq = resolvedUrlSequence(value, context).value<QList<QUrl> >();
+ int status = -1;
+ void *argv[] = { &urlSeq, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv);
+ } else if (variantType == propertyType) {
+
+ void *a[] = { (void *)value.constData(), 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+
+ } else if (qMetaTypeId<QVariant>() == propertyType) {
+
+ void *a[] = { (void *)&value, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+
+ } else if (property.isQObject()) {
+
+ const QMetaObject *valMo = rawMetaObjectForType(enginePriv, value.userType());
+
+ if (!valMo)
+ return false;
+
+ QObject *o = *(QObject **)value.constData();
+ const QMetaObject *propMo = rawMetaObjectForType(enginePriv, propertyType);
+
+ if (o) valMo = o->metaObject();
+
+ if (canConvert(valMo, propMo)) {
+ void *args[] = { &o, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
+ args);
+ } else if (!o && canConvert(propMo, valMo)) {
+ // In the case of a null QObject, we assign the null if there is
+ // any change that the null variant type could be up or down cast to
+ // the property type.
+ void *args[] = { &o, 0, &status, &flags };
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
+ args);
+ } else {
+ return false;
+ }
+
+ } else if (property.isQList()) {
+
+ const QMetaObject *listType = 0;
+ if (enginePriv) {
+ listType = enginePriv->rawMetaObjectForType(enginePriv->listType(property.propType));
+ } else {
+ QQmlType *type = QQmlMetaType::qmlType(QQmlMetaType::listType(property.propType));
+ if (!type) return false;
+ listType = type->baseMetaObject();
+ }
+ if (!listType) return false;
+
+ QQmlListProperty<void> prop;
+ void *args[] = { &prop, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, coreIdx, args);
+
+ if (!prop.clear) return false;
+
+ prop.clear(&prop);
+
+ if (value.userType() == qMetaTypeId<QQmlListReference>()) {
+ QQmlListReference qdlr = value.value<QQmlListReference>();
+
+ for (int ii = 0; ii < qdlr.count(); ++ii) {
+ QObject *o = qdlr.at(ii);
+ if (o && !canConvert(o->metaObject(), listType))
+ o = 0;
+ prop.append(&prop, (void *)o);
+ }
+ } else if (value.userType() == qMetaTypeId<QList<QObject *> >()) {
+ const QList<QObject *> &list = qvariant_cast<QList<QObject *> >(value);
+
+ for (int ii = 0; ii < list.count(); ++ii) {
+ QObject *o = list.at(ii);
+ if (o && !canConvert(o->metaObject(), listType))
+ o = 0;
+ prop.append(&prop, (void *)o);
+ }
+ } else {
+ QObject *o = enginePriv?enginePriv->toQObject(value):QQmlMetaType::toQObject(value);
+ if (o && !canConvert(o->metaObject(), listType))
+ o = 0;
+ prop.append(&prop, (void *)o);
+ }
+
+ } else {
+ Q_ASSERT(variantType != propertyType);
+
+ bool ok = false;
+ QVariant v;
+ if (variantType == QVariant::String)
+ v = QQmlStringConverters::variantFromString(value.toString(), propertyType, &ok);
+ if (!ok) {
+ v = value;
+ if (v.convert((QVariant::Type)propertyType)) {
+ ok = true;
+ } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) {
+ QQmlMetaType::StringConverter con = QQmlMetaType::customStringConverter(propertyType);
+ if (con) {
+ v = con(value.toString());
+ if (v.userType() == propertyType)
+ ok = true;
+ }
+ }
+ }
+ if (!ok) {
+ // the only other option is that they are assigning a single value
+ // to a sequence type property (eg, an int to a QList<int> property).
+ // Note that we've already handled single-value assignment to QList<QUrl> properties.
+ if (variantType == QVariant::Int && propertyType == qMetaTypeId<QList<int> >()) {
+ QList<int> list;
+ list << value.toInt();
+ v = QVariant::fromValue<QList<int> >(list);
+ ok = true;
+ } else if (variantType == QVariant::Double && propertyType == qMetaTypeId<QList<qreal> >()) {
+ QList<qreal> list;
+ list << value.toReal();
+ v = QVariant::fromValue<QList<qreal> >(list);
+ ok = true;
+ } else if (variantType == QVariant::Bool && propertyType == qMetaTypeId<QList<bool> >()) {
+ QList<bool> list;
+ list << value.toBool();
+ v = QVariant::fromValue<QList<bool> >(list);
+ ok = true;
+ } else if (variantType == QVariant::String && propertyType == qMetaTypeId<QList<QString> >()) {
+ QList<QString> list;
+ list << value.toString();
+ v = QVariant::fromValue<QList<QString> >(list);
+ ok = true;
+ } else if (variantType == QVariant::String && propertyType == qMetaTypeId<QStringList>()) {
+ QStringList list;
+ list << value.toString();
+ v = QVariant::fromValue<QStringList>(list);
+ ok = true;
+ }
+ }
+
+ if (ok) {
+ void *a[] = { (void *)v.constData(), 0, &status, &flags};
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+ } else {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+// Returns true if successful, false if an error description was set on expression
+bool QQmlPropertyPrivate::writeBinding(QObject *object,
+ const QQmlPropertyData &core,
+ QQmlContextData *context,
+ QQmlJavaScriptExpression *expression,
+ v8::Handle<v8::Value> result, bool isUndefined,
+ WriteFlags flags)
+{
+ Q_ASSERT(object);
+ Q_ASSERT(core.coreIndex != -1);
+
+ QQmlEngine *engine = context->engine;
+ QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine);
+
+#define QUICK_STORE(cpptype, conversion) \
+ { \
+ cpptype o = (conversion); \
+ int status = -1; \
+ void *argv[] = { &o, 0, &status, &flags }; \
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, core.coreIndex, argv); \
+ return true; \
+ } \
+
+
+ if (!isUndefined && !core.isValueTypeVirtual()) {
+ switch (core.propType) {
+ case QMetaType::Int:
+ if (result->IsInt32())
+ QUICK_STORE(int, result->Int32Value())
+ else if (result->IsNumber())
+ QUICK_STORE(int, qRound(result->NumberValue()))
+ break;
+ case QMetaType::Double:
+ if (result->IsNumber())
+ QUICK_STORE(double, result->NumberValue())
+ break;
+ case QMetaType::Float:
+ if (result->IsNumber())
+ QUICK_STORE(float, result->NumberValue())
+ break;
+ case QMetaType::QString:
+ if (result->IsString())
+ QUICK_STORE(QString, v8engine->toString(result))
+ break;
+ default:
+ break;
+ }
+ }
+#undef QUICK_STORE
+
+ int type = core.isValueTypeVirtual()?core.valueTypePropType:core.propType;
+
+ QQmlJavaScriptExpression::DeleteWatcher watcher(expression);
+
+ QVariant value;
+ bool isVmeProperty = core.isVMEProperty();
+
+ if (isUndefined) {
+ } else if (core.isQList()) {
+ value = v8engine->toVariant(result, qMetaTypeId<QList<QObject *> >());
+ } else if (result->IsNull() && core.isQObject()) {
+ value = QVariant::fromValue((QObject *)0);
+ } else if (core.propType == qMetaTypeId<QList<QUrl> >()) {
+ value = resolvedUrlSequence(v8engine->toVariant(result, qMetaTypeId<QList<QUrl> >()), context);
+ } else if (!isVmeProperty) {
+ value = v8engine->toVariant(result, type);
+ }
+
+ if (expression->hasError()) {
+ return false;
+ } else if (isUndefined && core.isResettable()) {
+ void *args[] = { 0 };
+ QMetaObject::metacall(object, QMetaObject::ResetProperty, core.coreIndex, args);
+ } else if (isUndefined && type == qMetaTypeId<QVariant>()) {
+ writeValueProperty(object, engine, core, QVariant(), context, flags);
+ } else if (isUndefined) {
+ expression->delayedError()->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(type)));
+ return false;
+ } else if (result->IsFunction()) {
+ expression->delayedError()->error.setDescription(QLatin1String("Unable to assign a function to a property."));
+ return false;
+ } else if (isVmeProperty) {
+ typedef QQmlVMEMetaObject VMEMO;
+ VMEMO *vmemo = static_cast<VMEMO *>(const_cast<QMetaObject *>(object->metaObject()));
+ vmemo->setVMEProperty(core.coreIndex, result);
+ } else if (!writeValueProperty(object, engine, core, value, context, flags)) {
+
+ if (watcher.wasDeleted())
+ return true;
+
+ const char *valueType = 0;
+ if (value.userType() == QVariant::Invalid) valueType = "null";
+ else valueType = QMetaType::typeName(value.userType());
+
+ expression->delayedError()->error.setDescription(QLatin1String("Unable to assign ") +
+ QLatin1String(valueType) +
+ QLatin1String(" to ") +
+ QLatin1String(QMetaType::typeName(type)));
+ return false;
+ }
+
+ return true;
+}
+
+bool QQmlPropertyPrivate::writeBinding(const QQmlProperty &that,
+ QQmlContextData *context,
+ QQmlJavaScriptExpression *expression,
+ v8::Handle<v8::Value> result, bool isUndefined,
+ WriteFlags flags)
+{
+ QQmlPropertyPrivate *pp = that.d;
+
+ if (!pp)
+ return true;
+
+ QObject *object = that.object();
+ if (!object)
+ return true;
+
+ return writeBinding(object, pp->core, context, expression, result, isUndefined, flags);
+}
+
+const QMetaObject *QQmlPropertyPrivate::rawMetaObjectForType(QQmlEnginePrivate *engine, int userType)
+{
+ if (engine) {
+ return engine->rawMetaObjectForType(userType);
+ } else {
+ QQmlType *type = QQmlMetaType::qmlType(userType);
+ return type?type->baseMetaObject():0;
+ }
+}
+
+/*!
+ Sets the property value to \a value and returns true.
+ Returns false if the property can't be set because the
+ \a value is the wrong type, for example.
+ */
+bool QQmlProperty::write(const QVariant &value) const
+{
+ return QQmlPropertyPrivate::write(*this, value, 0);
+}
+
+/*!
+ Writes \a value to the \a name property of \a object. This method
+ is equivalent to:
+
+ \code
+ QQmlProperty p(object, name);
+ p.write(value);
+ \endcode
+*/
+bool QQmlProperty::write(QObject *object, const QString &name, const QVariant &value)
+{
+ QQmlProperty p(object, name);
+ return p.write(value);
+}
+
+/*!
+ Writes \a value to the \a name property of \a object using the
+ \l{QQmlContext} {context} \a ctxt. This method is
+ equivalent to:
+
+ \code
+ QQmlProperty p(object, name, ctxt);
+ p.write(value);
+ \endcode
+*/
+bool QQmlProperty::write(QObject *object,
+ const QString &name,
+ const QVariant &value,
+ QQmlContext *ctxt)
+{
+ QQmlProperty p(object, name, ctxt);
+ return p.write(value);
+}
+
+/*!
+
+ Writes \a value to the \a name property of \a object using the
+ environment for instantiating QML components that is provided by
+ \a engine. This method is equivalent to:
+
+ \code
+ QQmlProperty p(object, name, engine);
+ p.write(value);
+ \endcode
+*/
+bool QQmlProperty::write(QObject *object, const QString &name, const QVariant &value,
+ QQmlEngine *engine)
+{
+ QQmlProperty p(object, name, engine);
+ return p.write(value);
+}
+
+/*!
+ Resets the property and returns true if the property is
+ resettable. If the property is not resettable, nothing happens
+ and false is returned.
+*/
+bool QQmlProperty::reset() const
+{
+ if (isResettable()) {
+ void *args[] = { 0 };
+ QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex, args);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool QQmlPropertyPrivate::write(const QQmlProperty &that,
+ const QVariant &value, WriteFlags flags)
+{
+ if (!that.d)
+ return false;
+ if (that.d->object && that.type() & QQmlProperty::Property &&
+ that.d->core.isValid() && that.isWritable())
+ return that.d->writeValueProperty(value, flags);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property has a change notifier signal, otherwise false.
+*/
+bool QQmlProperty::hasNotifySignal() const
+{
+ if (type() & Property && d->object) {
+ return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal();
+ }
+ return false;
+}
+
+/*!
+ Returns true if the property needs a change notifier signal for bindings
+ to remain upto date, false otherwise.
+
+ Some properties, such as attached properties or those whose value never
+ changes, do not require a change notifier.
+*/
+bool QQmlProperty::needsNotifySignal() const
+{
+ return type() & Property && !property().isConstant();
+}
+
+/*!
+ Connects the property's change notifier signal to the
+ specified \a method of the \a dest object and returns
+ true. Returns false if this metaproperty does not
+ represent a regular Qt property or if it has no
+ change notifier signal, or if the \a dest object does
+ not have the specified \a method.
+*/
+bool QQmlProperty::connectNotifySignal(QObject *dest, int method) const
+{
+ if (!(type() & Property) || !d->object)
+ return false;
+
+ QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
+ if (prop.hasNotifySignal()) {
+ return QQmlPropertyPrivate::connect(d->object, prop.notifySignalIndex(), dest, method, Qt::DirectConnection);
+ } else {
+ return false;
+ }
+}
+
+/*!
+ Connects the property's change notifier signal to the
+ specified \a slot of the \a dest object and returns
+ true. Returns false if this metaproperty does not
+ represent a regular Qt property or if it has no
+ change notifier signal, or if the \a dest object does
+ not have the specified \a slot.
+*/
+bool QQmlProperty::connectNotifySignal(QObject *dest, const char *slot) const
+{
+ if (!(type() & Property) || !d->object)
+ return false;
+
+ QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
+ if (prop.hasNotifySignal()) {
+ QByteArray signal(QByteArray("2") + prop.notifySignal().signature());
+ return QObject::connect(d->object, signal.constData(), dest, slot);
+ } else {
+ return false;
+ }
+}
+
+/*!
+ Return the Qt metaobject index of the property.
+*/
+int QQmlProperty::index() const
+{
+ return d ? d->core.coreIndex : -1;
+}
+
+int QQmlPropertyPrivate::valueTypeCoreIndex(const QQmlProperty &that)
+{
+ return that.d ? that.d->core.getValueTypeCoreIndex() : -1;
+}
+
+/*!
+ Returns the "property index" for use in bindings. The top 8 bits are the value type
+ offset, and 0 otherwise. The bottom 24-bits are the regular property index.
+*/
+int QQmlPropertyPrivate::bindingIndex(const QQmlProperty &that)
+{
+ if (!that.d)
+ return -1;
+ return bindingIndex(that.d->core);
+}
+
+int QQmlPropertyPrivate::bindingIndex(const QQmlPropertyData &that)
+{
+ int rv = that.coreIndex;
+ if (rv != -1 && that.isValueTypeVirtual())
+ rv = rv | (that.valueTypeCoreIndex << 24);
+ return rv;
+}
+
+QQmlPropertyData
+QQmlPropertyPrivate::saveValueType(const QMetaObject *metaObject, int index,
+ const QMetaObject *subObject, int subIndex,
+ QQmlEngine *)
+{
+ QMetaProperty subProp = subObject->property(subIndex);
+
+ QQmlPropertyData core;
+ core.load(metaObject->property(index));
+ core.setFlags(core.getFlags() | QQmlPropertyData::IsValueTypeVirtual);
+ core.valueTypeFlags = QQmlPropertyData::flagsForProperty(subProp);
+ core.valueTypeCoreIndex = subIndex;
+ core.valueTypePropType = subProp.userType();
+
+ return core;
+}
+
+QQmlProperty
+QQmlPropertyPrivate::restore(QObject *object, const QQmlPropertyData &data,
+ QQmlContextData *ctxt)
+{
+ QQmlProperty prop;
+
+ prop.d = new QQmlPropertyPrivate;
+ prop.d->object = object;
+ prop.d->context = ctxt;
+ prop.d->engine = ctxt?ctxt->engine:0;
+
+ prop.d->core = data;
+
+ return prop;
+}
+
+/*!
+ Returns true if lhs and rhs refer to the same metaobject data
+*/
+bool QQmlPropertyPrivate::equal(const QMetaObject *lhs, const QMetaObject *rhs)
+{
+ return lhs == rhs || (1 && lhs && rhs && lhs->d.stringdata == rhs->d.stringdata);
+}
+
+/*!
+ Returns true if from inherits to.
+*/
+bool QQmlPropertyPrivate::canConvert(const QMetaObject *from, const QMetaObject *to)
+{
+ if (from && to == &QObject::staticMetaObject)
+ return true;
+
+ while (from) {
+ if (equal(from, to))
+ return true;
+ from = from->superClass();
+ }
+
+ return false;
+}
+
+/*!
+ Return the signal corresponding to \a name
+*/
+QMetaMethod QQmlPropertyPrivate::findSignalByName(const QMetaObject *mo, const QByteArray &name)
+{
+ Q_ASSERT(mo);
+ int methods = mo->methodCount();
+ for (int ii = methods - 1; ii >= 2; --ii) { // >= 2 to block the destroyed signal
+ QMetaMethod method = mo->method(ii);
+ QByteArray methodName = method.signature();
+ int idx = methodName.indexOf('(');
+ methodName = methodName.left(idx);
+
+ if (methodName == name)
+ return method;
+ }
+
+ // If no signal is found, but the signal is of the form "onBlahChanged",
+ // return the notify signal for the property "Blah"
+ if (name.endsWith("Changed")) {
+ QByteArray propName = name.mid(0, name.length() - 7);
+ int propIdx = mo->indexOfProperty(propName.constData());
+ if (propIdx >= 0) {
+ QMetaProperty prop = mo->property(propIdx);
+ if (prop.hasNotifySignal())
+ return prop.notifySignal();
+ }
+ }
+
+ return QMetaMethod();
+}
+
+static inline int QMetaObject_methods(const QMetaObject *metaObject)
+{
+ struct Private
+ {
+ int revision;
+ int className;
+ int classInfoCount, classInfoData;
+ int methodCount, methodData;
+ int propertyCount, propertyData;
+ };
+
+ return reinterpret_cast<const Private *>(metaObject->d.data)->methodCount;
+}
+
+static inline int QMetaObject_properties(const QMetaObject *metaObject)
+{
+ struct Private
+ {
+ int revision;
+ int className;
+ int classInfoCount, classInfoData;
+ int methodCount, methodData;
+ int propertyCount, propertyData;
+ };
+
+ return reinterpret_cast<const Private *>(metaObject->d.data)->propertyCount;
+}
+
+static inline void flush_vme_signal(const QObject *object, int index)
+{
+ QQmlData *data = static_cast<QQmlData *>(QObjectPrivate::get(const_cast<QObject *>(object))->declarativeData);
+ if (data && data->propertyCache) {
+ QQmlPropertyData *property = data->propertyCache->method(index);
+
+ if (property && property->isVMESignal()) {
+ const QMetaObject *metaObject = object->metaObject();
+ int methodOffset = metaObject->methodOffset();
+
+ while (methodOffset > index) {
+ metaObject = metaObject->d.superdata;
+ methodOffset -= QMetaObject_methods(metaObject);
+ }
+
+ QQmlVMEMetaObject *vme =
+ static_cast<QQmlVMEMetaObject *>(const_cast<QMetaObject *>(metaObject));
+
+ vme->connectAliasSignal(index);
+ }
+ }
+}
+
+/*!
+Connect \a sender \a signal_index to \a receiver \a method_index with the specified
+\a type and \a types. This behaves identically to QMetaObject::connect() except that
+it connects any lazy "proxy" signal connections set up by QML.
+
+It is possible that this logic should be moved to QMetaObject::connect().
+*/
+bool QQmlPropertyPrivate::connect(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index,
+ int type, int *types)
+{
+ flush_vme_signal(sender, signal_index);
+ flush_vme_signal(receiver, method_index);
+
+ return QMetaObject::connect(sender, signal_index, receiver, method_index, type, types);
+}
+
+void QQmlPropertyPrivate::flushSignal(const QObject *sender, int signal_index)
+{
+ flush_vme_signal(sender, signal_index);
+}
+
+/*!
+Return \a metaObject's [super] meta object that provides data for \a property.
+*/
+const QMetaObject *QQmlPropertyPrivate::metaObjectForProperty(const QMetaObject *metaObject, int property)
+{
+ int propertyOffset = metaObject->propertyOffset();
+
+ while (propertyOffset > property) {
+ metaObject = metaObject->d.superdata;
+ propertyOffset -= QMetaObject_properties(metaObject);
+ }
+
+ return metaObject;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlproperty.h b/src/qml/qml/qqmlproperty.h
new file mode 100644
index 0000000000..2c4b2544c1
--- /dev/null
+++ b/src/qml/qml/qqmlproperty.h
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROPERTY_H
+#define QQMLPROPERTY_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QObject;
+class QVariant;
+class QQmlContext;
+class QQmlEngine;
+
+class QQmlPropertyPrivate;
+class Q_QML_EXPORT QQmlProperty
+{
+public:
+ enum PropertyTypeCategory {
+ InvalidCategory,
+ List,
+ Object,
+ Normal
+ };
+
+ enum Type {
+ Invalid,
+ Property,
+ SignalProperty
+ };
+
+ QQmlProperty();
+ ~QQmlProperty();
+
+ QQmlProperty(QObject *);
+ QQmlProperty(QObject *, QQmlContext *);
+ QQmlProperty(QObject *, QQmlEngine *);
+
+ QQmlProperty(QObject *, const QString &);
+ QQmlProperty(QObject *, const QString &, QQmlContext *);
+ QQmlProperty(QObject *, const QString &, QQmlEngine *);
+
+ QQmlProperty(const QQmlProperty &);
+ QQmlProperty &operator=(const QQmlProperty &);
+
+ bool operator==(const QQmlProperty &) const;
+
+ Type type() const;
+ bool isValid() const;
+ bool isProperty() const;
+ bool isSignalProperty() const;
+
+ int propertyType() const;
+ PropertyTypeCategory propertyTypeCategory() const;
+ const char *propertyTypeName() const;
+
+ QString name() const;
+
+ QVariant read() const;
+ static QVariant read(QObject *, const QString &);
+ static QVariant read(QObject *, const QString &, QQmlContext *);
+ static QVariant read(QObject *, const QString &, QQmlEngine *);
+
+ bool write(const QVariant &) const;
+ static bool write(QObject *, const QString &, const QVariant &);
+ static bool write(QObject *, const QString &, const QVariant &, QQmlContext *);
+ static bool write(QObject *, const QString &, const QVariant &, QQmlEngine *);
+
+ bool reset() const;
+
+ bool hasNotifySignal() const;
+ bool needsNotifySignal() const;
+ bool connectNotifySignal(QObject *dest, const char *slot) const;
+ bool connectNotifySignal(QObject *dest, int method) const;
+
+ bool isWritable() const;
+ bool isDesignable() const;
+ bool isResettable() const;
+ QObject *object() const;
+
+ int index() const;
+ QMetaProperty property() const;
+ QMetaMethod method() const;
+
+private:
+ friend class QQmlPropertyPrivate;
+ QQmlPropertyPrivate *d;
+};
+typedef QList<QQmlProperty> QQmlProperties;
+
+inline uint qHash (const QQmlProperty &key)
+{
+ return qHash(key.object()) + qHash(key.name());
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLPROPERTY_H
diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h
new file mode 100644
index 0000000000..0f97a63155
--- /dev/null
+++ b/src/qml/qml/qqmlproperty_p.h
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROPERTY_P_H
+#define QQMLPROPERTY_P_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 "qqmlproperty.h"
+
+#include <private/qobject_p.h>
+#include <private/qtqmlglobal_p.h>
+#include <private/qqmlpropertycache_p.h>
+#include <private/qqmlguard_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlContext;
+class QQmlExpression;
+class QQmlEnginePrivate;
+class QQmlJavaScriptExpression;
+class Q_QML_PRIVATE_EXPORT QQmlPropertyPrivate : public QQmlRefCount
+{
+public:
+ enum WriteFlag {
+ BypassInterceptor = 0x01,
+ DontRemoveBinding = 0x02,
+ RemoveBindingOnAliasWrite = 0x04
+ };
+ Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
+
+ QQmlContextData *context;
+ QQmlEngine *engine;
+ QQmlGuard<QObject> object;
+
+ QQmlPropertyData core;
+
+ bool isNameCached:1;
+ QString nameCache;
+
+ QQmlPropertyPrivate();
+
+ inline QQmlContextData *effectiveContext() const;
+
+ void initProperty(QObject *obj, const QString &name);
+ void initDefault(QObject *obj);
+
+ bool isValueType() const;
+ int propertyType() const;
+ QQmlProperty::Type type() const;
+ QQmlProperty::PropertyTypeCategory propertyTypeCategory() const;
+
+ QVariant readValueProperty();
+ bool writeValueProperty(const QVariant &, WriteFlags);
+
+ static const QMetaObject *rawMetaObjectForType(QQmlEnginePrivate *, int);
+ static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
+ const QVariant &value, int flags);
+ static bool writeValueProperty(QObject *, QQmlEngine *,
+ const QQmlPropertyData &,
+ const QVariant &, QQmlContextData *,
+ WriteFlags flags = 0);
+ static bool write(QObject *, const QQmlPropertyData &, const QVariant &,
+ QQmlContextData *, WriteFlags flags = 0);
+ static void findAliasTarget(QObject *, int, QObject **, int *);
+
+ static QQmlAbstractBinding *setBinding(QObject *, int coreIndex,
+ int valueTypeIndex /* -1 */,
+ QQmlAbstractBinding *,
+ WriteFlags flags = DontRemoveBinding);
+ static QQmlAbstractBinding *setBindingNoEnable(QObject *, int coreIndex,
+ int valueTypeIndex /* -1 */,
+ QQmlAbstractBinding *);
+ static QQmlAbstractBinding *binding(QObject *, int coreIndex,
+ int valueTypeIndex /* -1 */);
+
+ static QQmlPropertyData saveValueType(const QMetaObject *, int,
+ const QMetaObject *, int,
+ QQmlEngine *);
+ static QQmlProperty restore(QObject *,
+ const QQmlPropertyData &,
+ QQmlContextData *);
+
+ static bool equal(const QMetaObject *, const QMetaObject *);
+ static bool canConvert(const QMetaObject *from, const QMetaObject *to);
+ static inline QQmlPropertyPrivate *get(const QQmlProperty &p) {
+ return p.d;
+ }
+
+ // "Public" (to QML) methods
+ static QQmlAbstractBinding *binding(const QQmlProperty &that);
+ static QQmlAbstractBinding *setBinding(const QQmlProperty &that,
+ QQmlAbstractBinding *,
+ WriteFlags flags = DontRemoveBinding);
+ static QQmlExpression *signalExpression(const QQmlProperty &that);
+ static QQmlExpression *setSignalExpression(const QQmlProperty &that,
+ QQmlExpression *) ;
+ static bool write(const QQmlProperty &that, const QVariant &, WriteFlags);
+ static bool writeBinding(const QQmlProperty &that,
+ QQmlContextData *context,
+ QQmlJavaScriptExpression *expression,
+ v8::Handle<v8::Value> result, bool isUndefined,
+ WriteFlags flags);
+ static bool writeBinding(QObject *, const QQmlPropertyData &,
+ QQmlContextData *context,
+ QQmlJavaScriptExpression *expression,
+ v8::Handle<v8::Value> result, bool isUndefined,
+ WriteFlags flags);
+ static int valueTypeCoreIndex(const QQmlProperty &that);
+ static int bindingIndex(const QQmlProperty &that);
+ static int bindingIndex(const QQmlPropertyData &that);
+ static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
+ static bool connect(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index,
+ int type = 0, int *types = 0);
+ static const QMetaObject *metaObjectForProperty(const QMetaObject *, int);
+ static void flushSignal(const QObject *sender, int signal_index);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::WriteFlags)
+
+QT_END_NAMESPACE
+
+#endif // QQMLPROPERTY_P_H
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
new file mode 100644
index 0000000000..93c6aa1f00
--- /dev/null
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -0,0 +1,891 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpropertycache_p.h"
+
+#include "qqmlengine_p.h"
+#include "qqmlbinding_p.h"
+#include <private/qv8engine_p.h>
+
+#include <private/qmetaobject_p.h>
+#include <private/qqmlaccessors_p.h>
+
+#include <QtCore/qdebug.h>
+
+#include <ctype.h> // for toupper
+
+Q_DECLARE_METATYPE(QJSValue)
+Q_DECLARE_METATYPE(QQmlV8Handle);
+
+QT_BEGIN_NAMESPACE
+
+#define Q_INT16_MAX 32767
+
+class QQmlPropertyCacheMethodArguments
+{
+public:
+ QQmlPropertyCacheMethodArguments *next;
+ int arguments[0];
+};
+
+// Flags that do *NOT* depend on the property's QMetaProperty::userType() and thus are quick
+// to load
+static QQmlPropertyData::Flags fastFlagsForProperty(const QMetaProperty &p)
+{
+ QQmlPropertyData::Flags flags;
+
+ if (p.isConstant())
+ flags |= QQmlPropertyData::IsConstant;
+ if (p.isWritable())
+ flags |= QQmlPropertyData::IsWritable;
+ if (p.isResettable())
+ flags |= QQmlPropertyData::IsResettable;
+ if (p.isFinal())
+ flags |= QQmlPropertyData::IsFinal;
+ if (p.isEnumType())
+ flags |= QQmlPropertyData::IsEnumType;
+
+ return flags;
+}
+
+// Flags that do depend on the property's QMetaProperty::userType() and thus are slow to
+// load
+static QQmlPropertyData::Flags flagsForPropertyType(int propType, QQmlEngine *engine)
+{
+ Q_ASSERT(propType != -1);
+
+ QQmlPropertyData::Flags flags;
+
+ if (propType == QMetaType::QObjectStar || propType == QMetaType::QWidgetStar) {
+ flags |= QQmlPropertyData::IsQObjectDerived;
+ } else if (propType == QMetaType::QVariant) {
+ flags |= QQmlPropertyData::IsQVariant;
+ } else if (propType < (int)QVariant::UserType) {
+ } else if (propType == qMetaTypeId<QQmlBinding *>()) {
+ flags |= QQmlPropertyData::IsQmlBinding;
+ } else if (propType == qMetaTypeId<QJSValue>()) {
+ flags |= QQmlPropertyData::IsQJSValue;
+ } else if (propType == qMetaTypeId<QQmlV8Handle>()) {
+ flags |= QQmlPropertyData::IsV8Handle;
+ } else {
+ QQmlMetaType::TypeCategory cat =
+ engine ? QQmlEnginePrivate::get(engine)->typeCategory(propType)
+ : QQmlMetaType::typeCategory(propType);
+
+ if (cat == QQmlMetaType::Object)
+ flags |= QQmlPropertyData::IsQObjectDerived;
+ else if (cat == QQmlMetaType::List)
+ flags |= QQmlPropertyData::IsQList;
+ }
+
+ return flags;
+}
+
+static int metaObjectSignalCount(const QMetaObject *metaObject)
+{
+ int signalCount = 0;
+ for (const QMetaObject *obj = metaObject; obj; obj = obj->superClass())
+ signalCount += QMetaObjectPrivate::get(obj)->signalCount;
+ return signalCount;
+}
+
+QQmlPropertyData::Flags
+QQmlPropertyData::flagsForProperty(const QMetaProperty &p, QQmlEngine *engine)
+{
+ return fastFlagsForProperty(p) | flagsForPropertyType(p.userType(), engine);
+}
+
+void QQmlPropertyData::lazyLoad(const QMetaProperty &p, QQmlEngine *engine)
+{
+ Q_UNUSED(engine);
+
+ coreIndex = p.propertyIndex();
+ notifyIndex = p.notifySignalIndex();
+ Q_ASSERT(p.revision() <= Q_INT16_MAX);
+ revision = p.revision();
+
+ flags = fastFlagsForProperty(p);
+
+ int type = p.type();
+ if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) {
+ propType = type;
+ flags |= QQmlPropertyData::IsQObjectDerived;
+ } else if (type == QMetaType::QVariant) {
+ propType = type;
+ flags |= QQmlPropertyData::IsQVariant;
+ } else if (type == QVariant::UserType || type == -1) {
+ propTypeName = p.typeName();
+ flags |= QQmlPropertyData::NotFullyResolved;
+ } else {
+ propType = type;
+ }
+}
+
+void QQmlPropertyData::load(const QMetaProperty &p, QQmlEngine *engine)
+{
+ propType = p.userType();
+ coreIndex = p.propertyIndex();
+ notifyIndex = p.notifySignalIndex();
+ flags = fastFlagsForProperty(p) | flagsForPropertyType(propType, engine);
+ Q_ASSERT(p.revision() <= Q_INT16_MAX);
+ revision = p.revision();
+}
+
+void QQmlPropertyData::load(const QMetaMethod &m)
+{
+ coreIndex = m.methodIndex();
+ arguments = 0;
+ flags |= IsFunction;
+ if (m.methodType() == QMetaMethod::Signal)
+ flags |= IsSignal;
+ propType = QVariant::Invalid;
+
+ const char *returnType = m.typeName();
+ if (returnType)
+ propType = QMetaType::type(returnType);
+
+ const char *signature = m.signature();
+ while (*signature != '(') { Q_ASSERT(*signature != 0); ++signature; }
+
+ ++signature;
+ if (*signature != ')') {
+ flags |= HasArguments;
+ if (0 == ::strcmp(signature, "QQmlV8Function*)")) {
+ flags |= IsV8Function;
+ }
+ }
+
+ Q_ASSERT(m.revision() <= Q_INT16_MAX);
+ revision = m.revision();
+}
+
+void QQmlPropertyData::lazyLoad(const QMetaMethod &m)
+{
+ coreIndex = m.methodIndex();
+ arguments = 0;
+ flags |= IsFunction;
+ if (m.methodType() == QMetaMethod::Signal)
+ flags |= IsSignal;
+ propType = QVariant::Invalid;
+
+ const char *returnType = m.typeName();
+ if (returnType && *returnType) {
+ propTypeName = returnType;
+ flags |= NotFullyResolved;
+ }
+
+ const char *signature = m.signature();
+ while (*signature != '(') { Q_ASSERT(*signature != 0); ++signature; }
+
+ ++signature;
+ if (*signature != ')') {
+ flags |= HasArguments;
+ if (0 == ::strcmp(signature, "QQmlV8Function*)")) {
+ flags |= IsV8Function;
+ }
+ }
+
+ Q_ASSERT(m.revision() <= Q_INT16_MAX);
+ revision = m.revision();
+}
+
+/*!
+Creates a new empty QQmlPropertyCache.
+*/
+QQmlPropertyCache::QQmlPropertyCache(QQmlEngine *e)
+: engine(e), parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
+ signalHanderIndexCacheStart(0), metaObject(0), argumentsCache(0)
+{
+ Q_ASSERT(engine);
+}
+
+/*!
+Creates a new QQmlPropertyCache of \a metaObject.
+*/
+QQmlPropertyCache::QQmlPropertyCache(QQmlEngine *e, const QMetaObject *metaObject)
+: engine(e), parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
+ signalHanderIndexCacheStart(0), metaObject(0), argumentsCache(0)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(metaObject);
+
+ update(engine, metaObject);
+}
+
+QQmlPropertyCache::~QQmlPropertyCache()
+{
+ clear();
+
+ QQmlPropertyCacheMethodArguments *args = argumentsCache;
+ while (args) {
+ QQmlPropertyCacheMethodArguments *next = args->next;
+ free(args);
+ args = next;
+ }
+
+ // We must clear this prior to releasing the parent incase it is a
+ // linked hash
+ stringCache.clear();
+ if (parent) parent->release();
+ parent = 0;
+ engine = 0;
+}
+
+void QQmlPropertyCache::destroy()
+{
+ Q_ASSERT(engine || constructor.IsEmpty());
+ if (constructor.IsEmpty())
+ delete this;
+ else
+ QQmlEnginePrivate::deleteInEngineThread(engine, this);
+}
+
+// This is inherited from QQmlCleanup, so it should only clear the things
+// that are tied to the specific QQmlEngine.
+void QQmlPropertyCache::clear()
+{
+ qPersistentDispose(constructor);
+ engine = 0;
+}
+
+QQmlPropertyCache *QQmlPropertyCache::copy(int reserve)
+{
+ QQmlPropertyCache *cache = new QQmlPropertyCache(engine);
+ cache->parent = this;
+ cache->parent->addref();
+ cache->propertyIndexCacheStart = propertyIndexCache.count() + propertyIndexCacheStart;
+ cache->methodIndexCacheStart = methodIndexCache.count() + methodIndexCacheStart;
+ cache->signalHanderIndexCacheStart = signalHandlerIndexCache.count() + signalHanderIndexCacheStart;
+ cache->stringCache.linkAndReserve(stringCache, reserve);
+ cache->allowedRevisionCache = allowedRevisionCache;
+ cache->metaObject = metaObject;
+
+ // We specifically do *NOT* copy the constructor
+
+ return cache;
+}
+
+QQmlPropertyCache *QQmlPropertyCache::copy()
+{
+ return copy(0);
+}
+
+QQmlPropertyCache *
+QQmlPropertyCache::copyAndAppend(QQmlEngine *engine, const QMetaObject *metaObject,
+ QQmlPropertyData::Flag propertyFlags,
+ QQmlPropertyData::Flag methodFlags,
+ QQmlPropertyData::Flag signalFlags)
+{
+ return copyAndAppend(engine, metaObject, -1, propertyFlags, methodFlags, signalFlags);
+}
+
+QQmlPropertyCache *
+QQmlPropertyCache::copyAndAppend(QQmlEngine *engine, const QMetaObject *metaObject,
+ int revision,
+ QQmlPropertyData::Flag propertyFlags,
+ QQmlPropertyData::Flag methodFlags,
+ QQmlPropertyData::Flag signalFlags)
+{
+ Q_ASSERT(QMetaObjectPrivate::get(metaObject)->revision >= 4);
+
+ // Reserve enough space in the name hash for all the methods (including signals), all the
+ // signal handlers and all the properties. This assumes no name clashes, but this is the
+ // common case.
+ QQmlPropertyCache *rv = copy(QMetaObjectPrivate::get(metaObject)->methodCount +
+ QMetaObjectPrivate::get(metaObject)->signalCount +
+ QMetaObjectPrivate::get(metaObject)->propertyCount);
+
+ rv->append(engine, metaObject, revision, propertyFlags, methodFlags, signalFlags);
+
+ return rv;
+}
+
+void QQmlPropertyCache::append(QQmlEngine *engine, const QMetaObject *metaObject,
+ QQmlPropertyData::Flag propertyFlags,
+ QQmlPropertyData::Flag methodFlags,
+ QQmlPropertyData::Flag signalFlags)
+{
+ append(engine, metaObject, -1, propertyFlags, methodFlags, signalFlags);
+}
+
+void QQmlPropertyCache::append(QQmlEngine *engine, const QMetaObject *metaObject,
+ int revision,
+ QQmlPropertyData::Flag propertyFlags,
+ QQmlPropertyData::Flag methodFlags,
+ QQmlPropertyData::Flag signalFlags)
+{
+ Q_UNUSED(revision);
+ Q_ASSERT(constructor.IsEmpty()); // We should not be appending to an in-use property cache
+
+ this->metaObject = metaObject;
+
+ bool dynamicMetaObject = isDynamicMetaObject(metaObject);
+
+ allowedRevisionCache.append(0);
+
+ int methodCount = metaObject->methodCount();
+ Q_ASSERT(QMetaObjectPrivate::get(metaObject)->revision >= 4);
+ int signalCount = metaObjectSignalCount(metaObject);
+ int classInfoCount = QMetaObjectPrivate::get(metaObject)->classInfoCount;
+
+ QQmlAccessorProperties::Properties accessorProperties;
+
+ // Special case QObject as we don't want to add a qt_HasQmlAccessors classinfo to it
+ if (metaObject == &QObject::staticMetaObject) {
+ accessorProperties = QQmlAccessorProperties::properties(metaObject);
+ } else if (classInfoCount) {
+ int classInfoOffset = metaObject->classInfoOffset();
+ bool hasFastProperty = false;
+ for (int ii = 0; ii < classInfoCount; ++ii) {
+ int idx = ii + classInfoOffset;
+
+ if (0 == qstrcmp(metaObject->classInfo(idx).name(), "qt_HasQmlAccessors")) {
+ hasFastProperty = true;
+ break;
+ }
+ }
+
+ if (hasFastProperty) {
+ accessorProperties = QQmlAccessorProperties::properties(metaObject);
+ if (accessorProperties.count == 0)
+ qFatal("QQmlPropertyCache: %s has FastProperty class info, but has not "
+ "installed property accessors", metaObject->className());
+ } else {
+#ifndef QT_NO_DEBUG
+ accessorProperties = QQmlAccessorProperties::properties(metaObject);
+ if (accessorProperties.count != 0)
+ qFatal("QQmlPropertyCache: %s has fast property accessors, but is missing "
+ "FastProperty class info", metaObject->className());
+#endif
+ }
+ }
+
+ // qMax(defaultMethods, methodOffset) to block the signals and slots of QObject::staticMetaObject
+ // incl. destroyed signals, objectNameChanged signal, deleteLater slot, _q_reregisterTimers slot.
+ int methodOffset = qMax(QObject::staticMetaObject.methodCount(), metaObject->methodOffset());
+ int signalOffset = signalCount - QMetaObjectPrivate::get(metaObject)->signalCount;
+
+ // update() should have reserved enough space in the vector that this doesn't cause a realloc
+ // and invalidate the stringCache.
+ methodIndexCache.resize(methodCount - methodIndexCacheStart);
+ signalHandlerIndexCache.resize(signalCount - signalHanderIndexCacheStart);
+ int signalHandlerIndex = signalOffset;
+ for (int ii = methodOffset; ii < methodCount; ++ii) {
+ QMetaMethod m = metaObject->method(ii);
+ if (m.access() == QMetaMethod::Private)
+ continue;
+
+ // Extract method name
+ const char *signature = m.signature();
+ const char *cptr = signature;
+ char utf8 = 0;
+ while (*cptr != '(') {
+ Q_ASSERT(*cptr != 0);
+ utf8 |= *cptr & 0x80;
+ ++cptr;
+ }
+
+ QQmlPropertyData *data = &methodIndexCache[ii - methodIndexCacheStart];
+ QQmlPropertyData *sigdata = 0;
+
+ data->lazyLoad(m);
+
+ if (data->isSignal())
+ data->flags |= signalFlags;
+ else
+ data->flags |= methodFlags;
+
+ if (!dynamicMetaObject)
+ data->flags |= QQmlPropertyData::IsDirect;
+
+ Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX);
+ data->metaObjectOffset = allowedRevisionCache.count() - 1;
+
+ if (data->isSignal()) {
+ sigdata = &signalHandlerIndexCache[signalHandlerIndex - signalHanderIndexCacheStart];
+ *sigdata = *data;
+ sigdata->flags |= QQmlPropertyData::IsSignalHandler;
+ }
+
+ QQmlPropertyData *old = 0;
+
+ if (utf8) {
+ QHashedString methodName(QString::fromUtf8(signature, cptr - signature));
+ if (QQmlPropertyData **it = stringCache.value(methodName))
+ old = *it;
+ stringCache.insert(methodName, data);
+
+ if (data->isSignal()) {
+ QHashedString on(QStringLiteral("on") % methodName.at(0).toUpper() % methodName.midRef(1));
+ stringCache.insert(on, sigdata);
+ ++signalHandlerIndex;
+ }
+ } else {
+ QHashedCStringRef methodName(signature, cptr - signature);
+ if (QQmlPropertyData **it = stringCache.value(methodName))
+ old = *it;
+ stringCache.insert(methodName, data);
+
+ if (data->isSignal()) {
+ int length = methodName.length();
+
+ QVarLengthArray<char, 128> str(length+3);
+ str[0] = 'o';
+ str[1] = 'n';
+ str[2] = toupper(signature[0]);
+ if (length > 1)
+ memcpy(&str[3], &signature[1], length - 1);
+ str[length + 2] = '\0';
+
+ QHashedString on(QString::fromLatin1(str.data()));
+ stringCache.insert(on, sigdata);
+ ++signalHandlerIndex;
+ }
+ }
+
+ if (old) {
+ // We only overload methods in the same class, exactly like C++
+ if (old->isFunction() && old->coreIndex >= methodOffset)
+ data->flags |= QQmlPropertyData::IsOverload;
+ data->overrideIndexIsProperty = !old->isFunction();
+ data->overrideIndex = old->coreIndex;
+ }
+ }
+
+ int propCount = metaObject->propertyCount();
+ int propOffset = metaObject->propertyOffset();
+
+ // update() should have reserved enough space in the vector that this doesn't cause a realloc
+ // and invalidate the stringCache.
+ propertyIndexCache.resize(propCount - propertyIndexCacheStart);
+ for (int ii = propOffset; ii < propCount; ++ii) {
+ QMetaProperty p = metaObject->property(ii);
+ if (!p.isScriptable())
+ continue;
+
+ const char *str = p.name();
+ char utf8 = 0;
+ const char *cptr = str;
+ while (*cptr != 0) {
+ utf8 |= *cptr & 0x80;
+ ++cptr;
+ }
+
+ QQmlPropertyData *data = &propertyIndexCache[ii - propertyIndexCacheStart];
+
+ data->lazyLoad(p, engine);
+ data->flags |= propertyFlags;
+
+ if (!dynamicMetaObject)
+ data->flags |= QQmlPropertyData::IsDirect;
+
+ Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX);
+ data->metaObjectOffset = allowedRevisionCache.count() - 1;
+
+ QQmlPropertyData *old = 0;
+
+ if (utf8) {
+ QHashedString propName(QString::fromUtf8(str, cptr - str));
+ if (QQmlPropertyData **it = stringCache.value(propName))
+ old = *it;
+ stringCache.insert(propName, data);
+ } else {
+ QHashedCStringRef propName(str, cptr - str);
+ if (QQmlPropertyData **it = stringCache.value(propName))
+ old = *it;
+ stringCache.insert(propName, data);
+ }
+
+ QQmlAccessorProperties::Property *accessorProperty = accessorProperties.property(str);
+
+ // Fast properties may not be overrides or revisioned
+ Q_ASSERT(accessorProperty == 0 || (old == 0 && data->revision == 0));
+
+ if (accessorProperty) {
+ data->flags |= QQmlPropertyData::HasAccessors;
+ data->accessors = accessorProperty->accessors;
+ data->accessorData = accessorProperty->data;
+ } else if (old) {
+ data->overrideIndexIsProperty = !old->isFunction();
+ data->overrideIndex = old->coreIndex;
+ }
+ }
+}
+
+void QQmlPropertyCache::resolve(QQmlPropertyData *data) const
+{
+ Q_ASSERT(data->notFullyResolved());
+
+ data->propType = QMetaType::type(data->propTypeName);
+
+ if (!data->isFunction())
+ data->flags |= flagsForPropertyType(data->propType, engine);
+
+ data->flags &= ~QQmlPropertyData::NotFullyResolved;
+}
+
+void QQmlPropertyCache::updateRecur(QQmlEngine *engine, const QMetaObject *metaObject)
+{
+ if (!metaObject)
+ return;
+
+ updateRecur(engine, metaObject->superClass());
+
+ append(engine, metaObject);
+}
+
+void QQmlPropertyCache::update(QQmlEngine *engine, const QMetaObject *metaObject)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(metaObject);
+ Q_ASSERT(stringCache.isEmpty());
+
+ // Preallocate enough space in the index caches for all the properties/methods/signals that
+ // are not cached in a parent cache so that the caches never need to be reallocated as this
+ // would invalidate pointers stored in the stringCache.
+ int pc = metaObject->propertyCount();
+ int mc = metaObject->methodCount();
+ int sc = metaObjectSignalCount(metaObject);
+ propertyIndexCache.reserve(pc - propertyIndexCacheStart);
+ methodIndexCache.reserve(mc - methodIndexCacheStart);
+ signalHandlerIndexCache.reserve(sc - signalHanderIndexCacheStart);
+
+ // Reserve enough space in the stringCache for all properties/methods/signals including those
+ // cached in a parent cache.
+ stringCache.reserve(pc + mc + sc);
+
+ updateRecur(engine,metaObject);
+}
+
+QQmlPropertyData *
+QQmlPropertyCache::property(int index) const
+{
+ if (index < 0 || index >= (propertyIndexCacheStart + propertyIndexCache.count()))
+ return 0;
+
+ if (index < propertyIndexCacheStart)
+ return parent->property(index);
+
+ QQmlPropertyData *rv = const_cast<QQmlPropertyData *>(&propertyIndexCache.at(index - propertyIndexCacheStart));
+ if (rv->notFullyResolved()) resolve(rv);
+ return rv;
+}
+
+QQmlPropertyData *
+QQmlPropertyCache::method(int index) const
+{
+ if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count()))
+ return 0;
+
+ if (index < methodIndexCacheStart)
+ return parent->method(index);
+
+ QQmlPropertyData *rv = const_cast<QQmlPropertyData *>(&methodIndexCache.at(index - methodIndexCacheStart));
+ if (rv->notFullyResolved()) resolve(rv);
+ return rv;
+}
+
+QQmlPropertyData *
+QQmlPropertyCache::property(const QHashedStringRef &str) const
+{
+ QQmlPropertyData **rv = stringCache.value(str);
+ if (rv && (*rv)->notFullyResolved()) resolve(*rv);
+ return rv?*rv:0;
+}
+
+QQmlPropertyData *
+QQmlPropertyCache::property(const QHashedCStringRef &str) const
+{
+ QQmlPropertyData **rv = stringCache.value(str);
+ if (rv && (*rv)->notFullyResolved()) resolve(*rv);
+ return rv?*rv:0;
+}
+
+QQmlPropertyData *
+QQmlPropertyCache::property(const QString &str) const
+{
+ QQmlPropertyData **rv = stringCache.value(str);
+ if (rv && (*rv)->notFullyResolved()) resolve(*rv);
+ return rv?*rv:0;
+}
+
+QString QQmlPropertyData::name(QObject *object)
+{
+ if (!object)
+ return QString();
+
+ return name(object->metaObject());
+}
+
+QString QQmlPropertyData::name(const QMetaObject *metaObject)
+{
+ if (!metaObject || coreIndex == -1)
+ return QString();
+
+ if (flags & IsFunction) {
+ QMetaMethod m = metaObject->method(coreIndex);
+
+ QString name = QString::fromUtf8(m.signature());
+ int parenIdx = name.indexOf(QLatin1Char('('));
+ if (parenIdx != -1)
+ name = name.left(parenIdx);
+ return name;
+ } else {
+ QMetaProperty p = metaObject->property(coreIndex);
+ return QString::fromUtf8(p.name());
+ }
+}
+
+QStringList QQmlPropertyCache::propertyNames() const
+{
+ QStringList keys;
+ for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter)
+ keys.append(iter.key());
+ return keys;
+}
+
+static int EnumType(const QMetaObject *meta, const QByteArray &str)
+{
+ QByteArray scope;
+ QByteArray name;
+ int scopeIdx = str.lastIndexOf("::");
+ if (scopeIdx != -1) {
+ scope = str.left(scopeIdx);
+ name = str.mid(scopeIdx + 2);
+ } else {
+ name = str;
+ }
+ for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
+ QMetaEnum m = meta->enumerator(i);
+ if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope)))
+ return QVariant::Int;
+ }
+ return QVariant::Invalid;
+}
+
+// Returns an array of the arguments for method \a index. The first entry in the array
+// is the number of arguments.
+int *QQmlPropertyCache::methodParameterTypes(QObject *object, int index,
+ QVarLengthArray<int, 9> &dummy,
+ QByteArray *unknownTypeError)
+{
+ Q_ASSERT(object && index >= 0);
+
+ QQmlData *ddata = QQmlData::get(object, false);
+
+ if (ddata && ddata->propertyCache) {
+ typedef QQmlPropertyCacheMethodArguments A;
+
+ QQmlPropertyCache *c = ddata->propertyCache;
+ Q_ASSERT(index < c->methodIndexCacheStart + c->methodIndexCache.count());
+
+ while (index < c->methodIndexCacheStart)
+ c = c->parent;
+
+ QQmlPropertyData *rv = const_cast<QQmlPropertyData *>(&c->methodIndexCache.at(index - c->methodIndexCacheStart));
+
+ if (rv->arguments)
+ return static_cast<A *>(rv->arguments)->arguments;
+
+ const QMetaObject *metaObject = object->metaObject();
+ QMetaMethod m = metaObject->method(index);
+ QList<QByteArray> argTypeNames = m.parameterTypes();
+
+ A *args = static_cast<A *>(malloc(sizeof(A) + (argTypeNames.count() + 1) * sizeof(int)));
+ args->arguments[0] = argTypeNames.count();
+
+ for (int ii = 0; ii < argTypeNames.count(); ++ii) {
+ int type = QMetaType::type(argTypeNames.at(ii));
+ if (type == QVariant::Invalid)
+ type = EnumType(object->metaObject(), argTypeNames.at(ii));
+ if (type == QVariant::Invalid) {
+ if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii);
+ free(args);
+ return 0;
+ }
+ args->arguments[ii + 1] = type;
+ }
+
+ rv->arguments = args;
+ args->next = c->argumentsCache;
+ c->argumentsCache = args;
+ return static_cast<A *>(rv->arguments)->arguments;
+
+ } else {
+ QMetaMethod m = object->metaObject()->method(index);
+ QList<QByteArray> argTypeNames = m.parameterTypes();
+ dummy.resize(argTypeNames.count() + 1);
+ dummy[0] = argTypeNames.count();
+
+ for (int ii = 0; ii < argTypeNames.count(); ++ii) {
+ int type = QMetaType::type(argTypeNames.at(ii));
+ if (type == QVariant::Invalid)
+ type = EnumType(object->metaObject(), argTypeNames.at(ii));
+ if (type == QVariant::Invalid) {
+ if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii);
+ return 0;
+ }
+ dummy[ii + 1] = type;
+ }
+
+ return dummy.data();
+ }
+}
+
+QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject,
+ const QString &property)
+{
+ Q_ASSERT(metaObject);
+
+ QQmlPropertyData rv;
+ {
+ const QMetaObject *cmo = metaObject;
+ const QByteArray propertyName = property.toUtf8();
+ while (cmo) {
+ int idx = cmo->indexOfProperty(propertyName);
+ if (idx != -1) {
+ QMetaProperty p = cmo->property(idx);
+ if (p.isScriptable()) {
+ rv.load(p);
+ return rv;
+ } else {
+ while (cmo && cmo->propertyOffset() >= idx)
+ cmo = cmo->superClass();
+ }
+ } else {
+ cmo = 0;
+ }
+ }
+ }
+
+ int methodCount = metaObject->methodCount();
+ int defaultMethods = QObject::staticMetaObject.methodCount();
+ for (int ii = methodCount - 1; ii >= defaultMethods; --ii) {
+ // >=defaultMethods to block the signals and slots of QObject::staticMetaObject
+ // incl. destroyed signals, objectNameChanged signal, deleteLater slot, _q_reregisterTimers slot.
+ QMetaMethod m = metaObject->method(ii);
+ if (m.access() == QMetaMethod::Private)
+ continue;
+ QString methodName = QString::fromUtf8(m.signature());
+
+ int parenIdx = methodName.indexOf(QLatin1Char('('));
+ Q_ASSERT(parenIdx != -1);
+ QStringRef methodNameRef = methodName.leftRef(parenIdx);
+
+ if (methodNameRef == property) {
+ rv.load(m);
+ return rv;
+ }
+ }
+
+ return rv;
+}
+
+inline const QString &qQmlPropertyCacheToString(const QString &string)
+{
+ return string;
+}
+
+inline QString qQmlPropertyCacheToString(const QHashedV8String &string)
+{
+ return QV8Engine::toStringStatic(string.string());
+}
+
+template<typename T>
+QQmlPropertyData *
+qQmlPropertyCacheProperty(QQmlEngine *engine, QObject *obj,
+ const T &name, QQmlPropertyData &local)
+{
+ QQmlPropertyCache *cache = 0;
+
+ if (engine) {
+ QQmlData *ddata = QQmlData::get(obj);
+
+ if (ddata && ddata->propertyCache) {
+ cache = ddata->propertyCache;
+ } else if (engine) {
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+ cache = ep->cache(obj);
+ if (cache) {
+ ddata = QQmlData::get(obj, true);
+ cache->addref();
+ ddata->propertyCache = cache;
+ }
+ }
+ }
+
+ QQmlPropertyData *rv = 0;
+
+ if (cache) {
+ rv = cache->property(name);
+ } else {
+ local = qQmlPropertyCacheCreate(obj->metaObject(),
+ qQmlPropertyCacheToString(name));
+ if (local.isValid())
+ rv = &local;
+ }
+
+ return rv;
+}
+
+QQmlPropertyData *
+QQmlPropertyCache::property(QQmlEngine *engine, QObject *obj,
+ const QHashedV8String &name, QQmlPropertyData &local)
+{
+ return qQmlPropertyCacheProperty<QHashedV8String>(engine, obj, name, local);
+}
+
+QQmlPropertyData *
+QQmlPropertyCache::property(QQmlEngine *engine, QObject *obj,
+ const QString &name, QQmlPropertyData &local)
+{
+ return qQmlPropertyCacheProperty<QString>(engine, obj, name, local);
+}
+
+static inline const QMetaObjectPrivate *priv(const uint* data)
+{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
+
+bool QQmlPropertyCache::isDynamicMetaObject(const QMetaObject *mo)
+{
+ return priv(mo->d.data)->revision >= 3 && priv(mo->d.data)->flags & DynamicMetaObject;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
new file mode 100644
index 0000000000..a128cd9055
--- /dev/null
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -0,0 +1,384 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROPERTYCACHE_P_H
+#define QQMLPROPERTYCACHE_P_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 <private/qqmlrefcount_p.h>
+#include "qqmlcleanup_p.h"
+#include "qqmlnotifier_p.h"
+
+#include <private/qhashedstring_p.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qvector.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+class QMetaProperty;
+class QV8QObjectWrapper;
+class QQmlEngine;
+class QQmlPropertyData;
+class QQmlAccessors;
+class QQmlPropertyCacheMethodArguments;
+
+// We have this somewhat awful split between RawData and Data so that RawData can be
+// used in unions. In normal code, you should always use Data which initializes RawData
+// to an invalid state on construction.
+class QQmlPropertyRawData
+{
+public:
+ enum Flag {
+ NoFlags = 0x00000000,
+ ValueTypeFlagMask = 0x0000FFFF, // Flags in valueTypeFlags must fit in this mask
+
+ // Can apply to all properties, except IsFunction
+ IsConstant = 0x00000001, // Has CONST flag
+ IsWritable = 0x00000002, // Has WRITE function
+ IsResettable = 0x00000004, // Has RESET function
+ IsAlias = 0x00000008, // Is a QML alias to another property
+ IsFinal = 0x00000010, // Has FINAL flag
+ IsDirect = 0x00000020, // Exists on a C++ QMetaObject
+ HasAccessors = 0x00000040, // Has property accessors
+
+ // These are mutualy exclusive
+ IsFunction = 0x00000080, // Is an invokable
+ IsQObjectDerived = 0x00000100, // Property type is a QObject* derived type
+ IsEnumType = 0x00000200, // Property type is an enum
+ IsQList = 0x00000400, // Property type is a QML list
+ IsQmlBinding = 0x00000800, // Property type is a QQmlBinding*
+ IsQJSValue = 0x00001000, // Property type is a QScriptValue
+ IsV8Handle = 0x00002000, // Property type is a QQmlV8Handle
+ IsVMEProperty = 0x00004000, // Property type is a "var" property of VMEMO
+ IsValueTypeVirtual = 0x00008000, // Property is a value type "virtual" property
+ IsQVariant = 0x00010000, // Property is a QVariant
+
+ // Apply only to IsFunctions
+ IsVMEFunction = 0x00020000, // Function was added by QML
+ HasArguments = 0x00040000, // Function takes arguments
+ IsSignal = 0x00080000, // Function is a signal
+ IsVMESignal = 0x00100000, // Signal was added by QML
+ IsV8Function = 0x00200000, // Function takes QQmlV8Function* args
+ IsSignalHandler = 0x00400000, // Function is a signal handler
+ IsOverload = 0x00800000, // Function is an overload of another function
+
+ // Internal QQmlPropertyCache flags
+ NotFullyResolved = 0x01000000 // True if the type data is to be lazily resolved
+ };
+ Q_DECLARE_FLAGS(Flags, Flag)
+
+ Flags getFlags() const { return Flag(flags); }
+ void setFlags(Flags f) { flags = f; }
+
+ bool isValid() const { return coreIndex != -1; }
+
+ bool isConstant() const { return flags & IsConstant; }
+ bool isWritable() const { return flags & IsWritable; }
+ bool isResettable() const { return flags & IsResettable; }
+ bool isAlias() const { return flags & IsAlias; }
+ bool isFinal() const { return flags & IsFinal; }
+ bool isDirect() const { return flags & IsDirect; }
+ bool hasAccessors() const { return flags & HasAccessors; }
+ bool isFunction() const { return flags & IsFunction; }
+ bool isQObject() const { return flags & IsQObjectDerived; }
+ bool isEnum() const { return flags & IsEnumType; }
+ bool isQList() const { return flags & IsQList; }
+ bool isQmlBinding() const { return flags & IsQmlBinding; }
+ bool isQJSValue() const { return flags & IsQJSValue; }
+ bool isV8Handle() const { return flags & IsV8Handle; }
+ bool isVMEProperty() const { return flags & IsVMEProperty; }
+ bool isValueTypeVirtual() const { return flags & IsValueTypeVirtual; }
+ bool isQVariant() const { return flags & IsQVariant; }
+ bool isVMEFunction() const { return flags & IsVMEFunction; }
+ bool hasArguments() const { return flags & HasArguments; }
+ bool isSignal() const { return flags & IsSignal; }
+ bool isVMESignal() const { return flags & IsVMESignal; }
+ bool isV8Function() const { return flags & IsV8Function; }
+ bool isSignalHandler() const { return flags & IsSignalHandler; }
+ bool isOverload() const { return flags & IsOverload; }
+
+ bool hasOverride() const { return !(flags & IsValueTypeVirtual) &&
+ !(flags & HasAccessors) &&
+ overrideIndex >= 0; }
+ bool hasRevision() const { return !(flags & HasAccessors) && revision != 0; }
+
+ // Returns -1 if not a value type virtual property
+ inline int getValueTypeCoreIndex() const;
+
+ // Returns the "encoded" index for use with bindings. Encoding is:
+ // coreIndex | (valueTypeCoreIndex << 24)
+ inline int encodedIndex() const;
+
+ union {
+ int propType; // When !NotFullyResolved
+ const char *propTypeName; // When NotFullyResolved
+ };
+ int coreIndex;
+ union {
+ int notifyIndex; // When !IsFunction
+ void *arguments; // When IsFunction && HasArguments
+ };
+
+ union {
+ struct { // When !HasAccessors
+ qint16 revision;
+ qint16 metaObjectOffset;
+
+ union {
+ struct { // When IsValueTypeVirtual
+ quint16 valueTypeFlags; // flags of the access property on the value type proxy
+ // object
+ quint8 valueTypePropType; // The QVariant::Type of access property on the value
+ // type proxy object
+ quint8 valueTypeCoreIndex; // The prop index of the access property on the value
+ // type proxy object
+ };
+
+ struct { // When !IsValueTypeVirtual
+ uint overrideIndexIsProperty : 1;
+ signed int overrideIndex : 31;
+ };
+ };
+ };
+ struct { // When HasAccessors
+ QQmlAccessors *accessors;
+ intptr_t accessorData;
+ };
+ };
+
+private:
+ friend class QQmlPropertyData;
+ friend class QQmlPropertyCache;
+ quint32 flags;
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyRawData::Flags);
+
+class QQmlPropertyData : public QQmlPropertyRawData
+{
+public:
+ inline QQmlPropertyData();
+ inline QQmlPropertyData(const QQmlPropertyRawData &);
+
+ inline bool operator==(const QQmlPropertyRawData &);
+
+ static Flags flagsForProperty(const QMetaProperty &, QQmlEngine *engine = 0);
+ void load(const QMetaProperty &, QQmlEngine *engine = 0);
+ void load(const QMetaMethod &);
+ QString name(QObject *);
+ QString name(const QMetaObject *);
+
+private:
+ friend class QQmlPropertyCache;
+ void lazyLoad(const QMetaProperty &, QQmlEngine *engine = 0);
+ void lazyLoad(const QMetaMethod &);
+ bool notFullyResolved() const { return flags & NotFullyResolved; }
+};
+
+class Q_QML_EXPORT QQmlPropertyCache : public QQmlRefCount, public QQmlCleanup
+{
+public:
+ QQmlPropertyCache(QQmlEngine *);
+ QQmlPropertyCache(QQmlEngine *, const QMetaObject *);
+ virtual ~QQmlPropertyCache();
+
+ void update(QQmlEngine *, const QMetaObject *);
+
+ QQmlPropertyCache *copy();
+
+ QQmlPropertyCache *copyAndAppend(QQmlEngine *, const QMetaObject *,
+ QQmlPropertyData::Flag propertyFlags = QQmlPropertyData::NoFlags,
+ QQmlPropertyData::Flag methodFlags = QQmlPropertyData::NoFlags,
+ QQmlPropertyData::Flag signalFlags = QQmlPropertyData::NoFlags);
+ QQmlPropertyCache *copyAndAppend(QQmlEngine *, const QMetaObject *, int revision,
+ QQmlPropertyData::Flag propertyFlags = QQmlPropertyData::NoFlags,
+ QQmlPropertyData::Flag methodFlags = QQmlPropertyData::NoFlags,
+ QQmlPropertyData::Flag signalFlags = QQmlPropertyData::NoFlags);
+
+ void append(QQmlEngine *, const QMetaObject *,
+ QQmlPropertyData::Flag propertyFlags = QQmlPropertyData::NoFlags,
+ QQmlPropertyData::Flag methodFlags = QQmlPropertyData::NoFlags,
+ QQmlPropertyData::Flag signalFlags = QQmlPropertyData::NoFlags);
+ void append(QQmlEngine *, const QMetaObject *, int revision,
+ QQmlPropertyData::Flag propertyFlags = QQmlPropertyData::NoFlags,
+ QQmlPropertyData::Flag methodFlags = QQmlPropertyData::NoFlags,
+ QQmlPropertyData::Flag signalFlags = QQmlPropertyData::NoFlags);
+
+ inline QQmlPropertyData *property(const QHashedV8String &) const;
+ QQmlPropertyData *property(const QHashedStringRef &) const;
+ QQmlPropertyData *property(const QHashedCStringRef &) const;
+ QQmlPropertyData *property(const QString &) const;
+ QQmlPropertyData *property(int) const;
+ QQmlPropertyData *method(int) const;
+ QStringList propertyNames() const;
+
+ inline QQmlPropertyData *overrideData(QQmlPropertyData *) const;
+ inline bool isAllowedInRevision(QQmlPropertyData *) const;
+
+ inline QQmlEngine *qmlEngine() const;
+ static QQmlPropertyData *property(QQmlEngine *, QObject *, const QString &,
+ QQmlPropertyData &);
+ static QQmlPropertyData *property(QQmlEngine *, QObject *, const QHashedV8String &,
+ QQmlPropertyData &);
+ static int *methodParameterTypes(QObject *, int index, QVarLengthArray<int, 9> &dummy,
+ QByteArray *unknownTypeError);
+
+ static bool isDynamicMetaObject(const QMetaObject *);
+protected:
+ virtual void destroy();
+ virtual void clear();
+
+private:
+ friend class QQmlEnginePrivate;
+ friend class QV8QObjectWrapper;
+
+ inline QQmlPropertyCache *copy(int reserve);
+
+ // Implemented in v8/qv8qobjectwrapper.cpp
+ v8::Local<v8::Object> newQObject(QObject *, QV8Engine *);
+
+ typedef QVector<QQmlPropertyData> IndexCache;
+ typedef QStringHash<QQmlPropertyData *> StringCache;
+ typedef QVector<int> AllowedRevisionCache;
+
+ void resolve(QQmlPropertyData *) const;
+ void updateRecur(QQmlEngine *, const QMetaObject *);
+
+ QQmlEngine *engine;
+
+ QQmlPropertyCache *parent;
+ int propertyIndexCacheStart;
+ int methodIndexCacheStart;
+ int signalHanderIndexCacheStart;
+
+ IndexCache propertyIndexCache;
+ IndexCache methodIndexCache;
+ IndexCache signalHandlerIndexCache;
+ StringCache stringCache;
+ AllowedRevisionCache allowedRevisionCache;
+ v8::Persistent<v8::Function> constructor;
+
+ const QMetaObject *metaObject;
+ QQmlPropertyCacheMethodArguments *argumentsCache;
+};
+
+QQmlPropertyData::QQmlPropertyData()
+{
+ propType = 0;
+ coreIndex = -1;
+ notifyIndex = -1;
+ overrideIndexIsProperty = false;
+ overrideIndex = -1;
+ revision = 0;
+ metaObjectOffset = -1;
+ flags = 0;
+}
+
+QQmlPropertyData::QQmlPropertyData(const QQmlPropertyRawData &d)
+{
+ *(static_cast<QQmlPropertyRawData *>(this)) = d;
+}
+
+bool QQmlPropertyData::operator==(const QQmlPropertyRawData &other)
+{
+ return flags == other.flags &&
+ propType == other.propType &&
+ coreIndex == other.coreIndex &&
+ notifyIndex == other.notifyIndex &&
+ revision == other.revision &&
+ (!isValueTypeVirtual() ||
+ (valueTypeCoreIndex == other.valueTypeCoreIndex &&
+ valueTypePropType == other.valueTypePropType));
+}
+
+int QQmlPropertyRawData::getValueTypeCoreIndex() const
+{
+ return isValueTypeVirtual()?valueTypeCoreIndex:-1;
+}
+
+int QQmlPropertyRawData::encodedIndex() const
+{
+ return isValueTypeVirtual()?(coreIndex | (valueTypeCoreIndex << 24)):coreIndex;
+}
+
+QQmlPropertyData *
+QQmlPropertyCache::overrideData(QQmlPropertyData *data) const
+{
+ if (!data->hasOverride())
+ return 0;
+
+ if (data->overrideIndexIsProperty)
+ return property(data->overrideIndex);
+ else
+ return method(data->overrideIndex);
+}
+
+bool QQmlPropertyCache::isAllowedInRevision(QQmlPropertyData *data) const
+{
+ return (data->hasAccessors() || (data->metaObjectOffset == -1 && data->revision == 0)) ||
+ (allowedRevisionCache[data->metaObjectOffset] >= data->revision);
+}
+
+QQmlEngine *QQmlPropertyCache::qmlEngine() const
+{
+ return engine;
+}
+
+QQmlPropertyData *QQmlPropertyCache::property(const QHashedV8String &str) const
+{
+ QQmlPropertyData **rv = stringCache.value(str);
+ if (rv && (*rv)->notFullyResolved()) resolve(*rv);
+ return rv?*rv:0;
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLPROPERTYCACHE_P_H
diff --git a/src/qml/qml/qqmlpropertyvalueinterceptor.cpp b/src/qml/qml/qqmlpropertyvalueinterceptor.cpp
new file mode 100644
index 0000000000..331b90da5c
--- /dev/null
+++ b/src/qml/qml/qqmlpropertyvalueinterceptor.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpropertyvalueinterceptor_p.h"
+
+#include "qqml.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QQmlPropertyValueInterceptor
+ \brief The QQmlPropertyValueInterceptor class is inherited by property interceptors such as Behavior.
+ \internal
+
+ This class intercepts property writes, allowing for custom handling. For example, Behavior uses this
+ interception to provide a default animation for all changes to a property's value.
+ */
+
+/*!
+ Constructs a QQmlPropertyValueInterceptor.
+*/
+QQmlPropertyValueInterceptor::QQmlPropertyValueInterceptor()
+{
+}
+
+QQmlPropertyValueInterceptor::~QQmlPropertyValueInterceptor()
+{
+}
+
+/*!
+ \fn void QQmlPropertyValueInterceptor::setTarget(const QQmlProperty &property)
+ Set the target \a property for the value interceptor. This method will
+ be called by the QML engine when assigning a value interceptor.
+*/
+
+/*!
+ \fn void QQmlPropertyValueInterceptor::write(const QVariant &value)
+ This method will be called when a new \a value is assigned to the property being intercepted.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlpropertyvalueinterceptor_p.h b/src/qml/qml/qqmlpropertyvalueinterceptor_p.h
new file mode 100644
index 0000000000..cf449c9eff
--- /dev/null
+++ b/src/qml/qml/qqmlpropertyvalueinterceptor_p.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROPERTYVALUEINTERCEPTOR_P_H
+#define QQMLPROPERTYVALUEINTERCEPTOR_P_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 <QtQml/qtqmlglobal.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlProperty;
+class Q_QML_EXPORT QQmlPropertyValueInterceptor
+{
+public:
+ QQmlPropertyValueInterceptor();
+ virtual ~QQmlPropertyValueInterceptor();
+ virtual void setTarget(const QQmlProperty &property) = 0;
+ virtual void write(const QVariant &value) = 0;
+};
+
+#define QQmlPropertyValueInterceptor_iid "org.qt-project.Qt.QQmlPropertyValueInterceptor"
+
+Q_DECLARE_INTERFACE(QQmlPropertyValueInterceptor, QQmlPropertyValueInterceptor_iid)
+
+QT_END_NAMESPACE
+
+#endif // QQMLPROPERTYVALUEINTERCEPTOR_P_H
diff --git a/src/qml/qml/qqmlpropertyvaluesource.cpp b/src/qml/qml/qqmlpropertyvaluesource.cpp
new file mode 100644
index 0000000000..bd1ca05b81
--- /dev/null
+++ b/src/qml/qml/qqmlpropertyvaluesource.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpropertyvaluesource.h"
+
+#include "qqml.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QQmlPropertyValueSource
+ \brief The QQmlPropertyValueSource class is an interface for property value sources such as animations and bindings.
+
+ See \l{Property Value Sources} for information on writing custom property
+ value sources.
+ */
+
+/*!
+ Constructs a QQmlPropertyValueSource.
+*/
+QQmlPropertyValueSource::QQmlPropertyValueSource()
+{
+}
+
+/*!
+ Destroys the value source.
+*/
+QQmlPropertyValueSource::~QQmlPropertyValueSource()
+{
+}
+
+/*!
+ \fn void QQmlPropertyValueSource::setTarget(const QQmlProperty &property)
+ Set the target \a property for the value source. This method will
+ be called by the QML engine when assigning a value source.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlpropertyvaluesource.h b/src/qml/qml/qqmlpropertyvaluesource.h
new file mode 100644
index 0000000000..bbd3c2f594
--- /dev/null
+++ b/src/qml/qml/qqmlpropertyvaluesource.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROPERTYVALUESOURCE_H
+#define QQMLPROPERTYVALUESOURCE_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlProperty;
+class Q_QML_EXPORT QQmlPropertyValueSource
+{
+public:
+ QQmlPropertyValueSource();
+ virtual ~QQmlPropertyValueSource();
+ virtual void setTarget(const QQmlProperty &) = 0;
+};
+
+#define QQmlPropertyValueSource_iid "org.qt-project.Qt.QQmlPropertyValueSource"
+
+Q_DECLARE_INTERFACE(QQmlPropertyValueSource, QQmlPropertyValueSource_iid)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLPROPERTYVALUESOURCE_H
diff --git a/src/qml/qml/qqmlproxymetaobject.cpp b/src/qml/qml/qqmlproxymetaobject.cpp
new file mode 100644
index 0000000000..55bf67739d
--- /dev/null
+++ b/src/qml/qml/qqmlproxymetaobject.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlproxymetaobject_p.h"
+#include "qqmlproperty_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQmlProxyMetaObject::QQmlProxyMetaObject(QObject *obj, QList<ProxyData> *mList)
+: metaObjects(mList), proxies(0), parent(0), object(obj)
+{
+ *static_cast<QMetaObject *>(this) = *metaObjects->first().metaObject;
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ if (op->metaObject)
+ parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject);
+
+ op->metaObject = this;
+}
+
+QQmlProxyMetaObject::~QQmlProxyMetaObject()
+{
+ if (parent)
+ delete parent;
+ parent = 0;
+
+ if (proxies)
+ delete [] proxies;
+ proxies = 0;
+}
+
+int QQmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
+{
+ if ((c == QMetaObject::ReadProperty ||
+ c == QMetaObject::WriteProperty) &&
+ id >= metaObjects->last().propertyOffset) {
+
+ for (int ii = 0; ii < metaObjects->count(); ++ii) {
+ const ProxyData &data = metaObjects->at(ii);
+ if (id >= data.propertyOffset) {
+ if (!proxies) {
+ proxies = new QObject*[metaObjects->count()];
+ ::memset(proxies, 0,
+ sizeof(QObject *) * metaObjects->count());
+ }
+
+ if (!proxies[ii]) {
+ QObject *proxy = data.createFunc(object);
+ const QMetaObject *metaObject = proxy->metaObject();
+ proxies[ii] = proxy;
+
+ int localOffset = data.metaObject->methodOffset();
+ int methodOffset = metaObject->methodOffset();
+ int methods = metaObject->methodCount() - methodOffset;
+
+ // ### - Can this be done more optimally?
+ for (int jj = 0; jj < methods; ++jj) {
+ QMetaMethod method =
+ metaObject->method(jj + methodOffset);
+ if (method.methodType() == QMetaMethod::Signal)
+ QQmlPropertyPrivate::connect(proxy, methodOffset + jj, object, localOffset + jj);
+ }
+ }
+
+ int proxyOffset = proxies[ii]->metaObject()->propertyOffset();
+ int proxyId = id - data.propertyOffset + proxyOffset;
+
+ return proxies[ii]->qt_metacall(c, proxyId, a);
+ }
+ }
+ } else if (c == QMetaObject::InvokeMetaMethod &&
+ id >= metaObjects->last().methodOffset) {
+ QMetaMethod m = object->metaObject()->method(id);
+ if (m.methodType() == QMetaMethod::Signal) {
+ QMetaObject::activate(object, id, a);
+ return -1;
+ }
+ }
+
+ if (parent)
+ return parent->metaCall(c, id, a);
+ else
+ return object->qt_metacall(c, id, a);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlproxymetaobject_p.h b/src/qml/qml/qqmlproxymetaobject_p.h
new file mode 100644
index 0000000000..ec9df42f7f
--- /dev/null
+++ b/src/qml/qml/qqmlproxymetaobject_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROXYMETAOBJECT_P_H
+#define QQMLPROXYMETAOBJECT_P_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 <private/qmetaobjectbuilder_p.h>
+#include "qqml.h"
+
+#include <QtCore/QMetaObject>
+#include <QtCore/QObject>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlProxyMetaObject : public QAbstractDynamicMetaObject
+{
+public:
+ struct ProxyData {
+ typedef QObject *(*CreateFunc)(QObject *);
+ QMetaObject *metaObject;
+ CreateFunc createFunc;
+ int propertyOffset;
+ int methodOffset;
+ };
+
+ QQmlProxyMetaObject(QObject *, QList<ProxyData> *);
+ virtual ~QQmlProxyMetaObject();
+
+protected:
+ virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
+
+private:
+ QList<ProxyData> *metaObjects;
+ QObject **proxies;
+
+ QAbstractDynamicMetaObject *parent;
+ QObject *object;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQMLPROXYMETAOBJECT_P_H
+
diff --git a/src/qml/qml/qqmlrewrite.cpp b/src/qml/qml/qqmlrewrite.cpp
new file mode 100644
index 0000000000..72bd23955b
--- /dev/null
+++ b/src/qml/qml/qqmlrewrite.cpp
@@ -0,0 +1,424 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlrewrite_p.h"
+
+#include <private/qqmlglobal_p.h>
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(rewriteDump, QML_REWRITE_DUMP);
+
+namespace QQmlRewrite {
+
+static void rewriteStringLiteral(AST::StringLiteral *ast, const QString *code, int startPosition, TextWriter *writer)
+{
+ const unsigned position = ast->firstSourceLocation().begin() - startPosition + 1;
+ const unsigned length = ast->literalToken.length - 2;
+ const QStringRef spell = code->midRef(position, length);
+ const int end = spell.size();
+ int index = 0;
+
+ while (index < end) {
+ const QChar ch = spell.at(index++);
+
+ if (index < end && ch == QLatin1Char('\\')) {
+ int pos = index;
+
+ // skip a possibly empty sequence of \r characters
+ while (pos < end && spell.at(pos) == QLatin1Char('\r'))
+ ++pos;
+
+ if (pos < end && spell.at(pos) == QLatin1Char('\n')) {
+ // This is a `\' followed by a newline terminator.
+ // In this case there's nothing to replace. We keep the code
+ // as it is and we resume the searching.
+ index = pos + 1; // refresh the index
+ }
+ } else if (ch == QLatin1Char('\r') || ch == QLatin1Char('\n')) {
+ const QString sep = ch == QLatin1Char('\r') ? QLatin1String("\\r") : QLatin1String("\\n");
+ const int pos = index - 1;
+ QString s = sep;
+
+ while (index < end && spell.at(index) == ch) {
+ s += sep;
+ ++index;
+ }
+
+ writer->replace(position + pos, index - pos, s);
+ }
+ }
+}
+
+bool SharedBindingTester::isSharable(const QString &code)
+{
+ Engine engine;
+ Lexer lexer(&engine);
+ Parser parser(&engine);
+ lexer.setCode(code, 0);
+ parser.parseStatement();
+ if (!parser.statement())
+ return false;
+
+ return isSharable(parser.statement());
+}
+
+bool SharedBindingTester::isSharable(AST::Node *node)
+{
+ _sharable = true;
+ AST::Node::acceptChild(node, this);
+ return _sharable;
+}
+
+QString RewriteBinding::operator()(const QString &code, bool *ok, bool *sharable)
+{
+ Engine engine;
+ Lexer lexer(&engine);
+ Parser parser(&engine);
+ lexer.setCode(code, 0);
+ parser.parseStatement();
+ if (!parser.statement()) {
+ if (ok) *ok = false;
+ return QString();
+ } else {
+ if (ok) *ok = true;
+ if (sharable) {
+ SharedBindingTester tester;
+ *sharable = tester.isSharable(parser.statement());
+ }
+ }
+ return rewrite(code, 0, parser.statement());
+}
+
+QString RewriteBinding::operator()(QQmlJS::AST::Node *node, const QString &code, bool *sharable)
+{
+ if (!node)
+ return code;
+
+ if (sharable) {
+ SharedBindingTester tester;
+ *sharable = tester.isSharable(node);
+ }
+
+ QQmlJS::AST::ExpressionNode *expression = node->expressionCast();
+ QQmlJS::AST::Statement *statement = node->statementCast();
+ if(!expression && !statement)
+ return code;
+
+ TextWriter w;
+ _writer = &w;
+ _position = expression ? expression->firstSourceLocation().begin() : statement->firstSourceLocation().begin();
+ _inLoop = 0;
+ _code = &code;
+
+ accept(node);
+
+ unsigned startOfStatement = 0;
+ unsigned endOfStatement = (expression ? expression->lastSourceLocation().end() : statement->lastSourceLocation().end()) - _position;
+
+ QString startString = QLatin1String("(function ") + _name + QLatin1String("() { ");
+ if (expression)
+ startString += QLatin1String("return ");
+ _writer->replace(startOfStatement, 0, startString);
+ _writer->replace(endOfStatement, 0, QLatin1String(" })"));
+
+ if (rewriteDump()) {
+ qWarning() << "=============================================================";
+ qWarning() << "Rewrote:";
+ qWarning() << qPrintable(code);
+ }
+
+ QString codeCopy = code;
+ w.write(&codeCopy);
+
+ if (rewriteDump()) {
+ qWarning() << "To:";
+ qWarning() << qPrintable(codeCopy);
+ qWarning() << "=============================================================";
+ }
+
+ return codeCopy;
+}
+
+void RewriteBinding::accept(AST::Node *node)
+{
+ AST::Node::acceptChild(node, this);
+}
+
+QString RewriteBinding::rewrite(QString code, unsigned position,
+ AST::Statement *node)
+{
+ TextWriter w;
+ _writer = &w;
+ _position = position;
+ _inLoop = 0;
+ _code = &code;
+
+ accept(node);
+
+ unsigned startOfStatement = node->firstSourceLocation().begin() - _position;
+ unsigned endOfStatement = node->lastSourceLocation().end() - _position;
+
+ _writer->replace(startOfStatement, 0, QLatin1String("(function ") + _name + QLatin1String("() { "));
+ _writer->replace(endOfStatement, 0, QLatin1String(" })"));
+
+ if (rewriteDump()) {
+ qWarning() << "=============================================================";
+ qWarning() << "Rewrote:";
+ qWarning() << qPrintable(code);
+ }
+
+ w.write(&code);
+
+ if (rewriteDump()) {
+ qWarning() << "To:";
+ qWarning() << qPrintable(code);
+ qWarning() << "=============================================================";
+ }
+
+ return code;
+}
+
+bool RewriteBinding::visit(AST::Block *ast)
+{
+ for (AST::StatementList *it = ast->statements; it; it = it->next) {
+ if (! it->next) {
+ // we need to rewrite only the last statement of a block.
+ accept(it->statement);
+ }
+ }
+
+ return false;
+}
+
+bool RewriteBinding::visit(AST::ExpressionStatement *ast)
+{
+ if (! _inLoop) {
+ unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position;
+ _writer->replace(startOfExpressionStatement, 0, QLatin1String("return "));
+ }
+
+ return false;
+}
+
+bool RewriteBinding::visit(AST::StringLiteral *ast)
+{
+ rewriteStringLiteral(ast, _code, _position, _writer);
+ return false;
+}
+
+bool RewriteBinding::visit(AST::DoWhileStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::DoWhileStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::WhileStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::WhileStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::ForStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::ForStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::LocalForStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::LocalForStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::ForEachStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::ForEachStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::LocalForEachStatement *)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::LocalForEachStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::CaseBlock *ast)
+{
+ // Process the initial sequence of the case clauses.
+ for (AST::CaseClauses *it = ast->clauses; it; it = it->next) {
+ // Return the value of the last statement in the block, if this is the last `case clause'
+ // of the switch statement.
+ bool returnTheValueOfLastStatement = (it->next == 0) && (ast->defaultClause == 0) && (ast->moreClauses == 0);
+
+ if (AST::CaseClause *clause = it->clause) {
+ accept(clause->expression);
+ rewriteCaseStatements(clause->statements, returnTheValueOfLastStatement);
+ }
+ }
+
+ // Process the default case clause
+ if (ast->defaultClause) {
+ // Return the value of the last statement in the block, if this is the last `case clause'
+ // of the switch statement.
+ bool rewriteTheLastStatement = (ast->moreClauses == 0);
+
+ rewriteCaseStatements(ast->defaultClause->statements, rewriteTheLastStatement);
+ }
+
+ // Process trailing `case clauses'
+ for (AST::CaseClauses *it = ast->moreClauses; it; it = it->next) {
+ // Return the value of the last statement in the block, if this is the last `case clause'
+ // of the switch statement.
+ bool returnTheValueOfLastStatement = (it->next == 0);
+
+ if (AST::CaseClause *clause = it->clause) {
+ accept(clause->expression);
+ rewriteCaseStatements(clause->statements, returnTheValueOfLastStatement);
+ }
+ }
+
+ return false;
+}
+
+void RewriteBinding::rewriteCaseStatements(AST::StatementList *statements, bool rewriteTheLastStatement)
+{
+ for (AST::StatementList *it = statements; it; it = it->next) {
+ if (it->next && AST::cast<AST::BreakStatement *>(it->next->statement) != 0) {
+ // The value of the first statement followed by a `break'.
+ accept(it->statement);
+ break;
+ } else if (!it->next) {
+ if (rewriteTheLastStatement)
+ accept(it->statement);
+ else if (AST::Block *block = AST::cast<AST::Block *>(it->statement))
+ rewriteCaseStatements(block->statements, rewriteTheLastStatement);
+ }
+ }
+}
+
+RewriteSignalHandler::RewriteSignalHandler()
+ : _writer(0)
+ , _code(0)
+ , _position(0)
+{
+}
+
+void RewriteSignalHandler::accept(AST::Node *node)
+{
+ AST::Node::acceptChild(node, this);
+}
+
+bool RewriteSignalHandler::visit(AST::StringLiteral *ast)
+{
+ rewriteStringLiteral(ast, _code, _position, _writer);
+ return false;
+}
+
+QString RewriteSignalHandler::operator()(QQmlJS::AST::Node *node, const QString &code, const QString &name)
+{
+ if (rewriteDump()) {
+ qWarning() << "=============================================================";
+ qWarning() << "Rewrote:";
+ qWarning() << qPrintable(code);
+ }
+
+ QQmlJS::AST::ExpressionNode *expression = node->expressionCast();
+ QQmlJS::AST::Statement *statement = node->statementCast();
+ if (!expression && !statement)
+ return code;
+
+ TextWriter w;
+ _writer = &w;
+ _code = &code;
+
+ _position = expression ? expression->firstSourceLocation().begin() : statement->firstSourceLocation().begin();
+ accept(node);
+
+ QString rewritten = code;
+ w.write(&rewritten);
+
+ rewritten = QStringLiteral("(function ") + name + QStringLiteral("() { ") + rewritten + QStringLiteral(" })");
+
+ if (rewriteDump()) {
+ qWarning() << "To:";
+ qWarning() << qPrintable(rewritten);
+ qWarning() << "=============================================================";
+ }
+
+ return rewritten;
+}
+
+} // namespace QQmlRewrite
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlrewrite_p.h b/src/qml/qml/qqmlrewrite_p.h
new file mode 100644
index 0000000000..1d69839878
--- /dev/null
+++ b/src/qml/qml/qqmlrewrite_p.h
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLREWRITE_P_H
+#define QQMLREWRITE_P_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 <private/textwriter_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsparser_p.h>
+#include <private/qqmljsmemorypool_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QQmlRewrite {
+using namespace QQmlJS;
+
+class SharedBindingTester : protected AST::Visitor
+{
+ bool _sharable;
+public:
+ bool isSharable(const QString &code);
+ bool isSharable(AST::Node *Node);
+
+ virtual bool visit(AST::FunctionDeclaration *) { _sharable = false; return false; }
+ virtual bool visit(AST::FunctionExpression *) { _sharable = false; return false; }
+ virtual bool visit(AST::CallExpression *) { _sharable = false; return false; }
+};
+
+class RewriteBinding: protected AST::Visitor
+{
+ unsigned _position;
+ TextWriter *_writer;
+ QString _name;
+ const QString *_code;
+
+public:
+ QString operator()(const QString &code, bool *ok = 0, bool *sharable = 0);
+ QString operator()(QQmlJS::AST::Node *node, const QString &code, bool *sharable = 0);
+
+ //name of the function: used for the debugger
+ void setName(const QString &name) { _name = name; }
+
+protected:
+ using AST::Visitor::visit;
+
+ void accept(AST::Node *node);
+ QString rewrite(QString code, unsigned position, AST::Statement *node);
+ void rewriteCaseStatements(AST::StatementList *statements, bool rewriteTheLastStatement);
+
+ virtual bool visit(AST::StringLiteral *ast);
+ virtual bool visit(AST::Block *ast);
+ virtual bool visit(AST::ExpressionStatement *ast);
+
+ virtual bool visit(AST::DoWhileStatement *ast);
+ virtual void endVisit(AST::DoWhileStatement *ast);
+
+ virtual bool visit(AST::WhileStatement *ast);
+ virtual void endVisit(AST::WhileStatement *ast);
+
+ virtual bool visit(AST::ForStatement *ast);
+ virtual void endVisit(AST::ForStatement *ast);
+
+ virtual bool visit(AST::LocalForStatement *ast);
+ virtual void endVisit(AST::LocalForStatement *ast);
+
+ virtual bool visit(AST::ForEachStatement *ast);
+ virtual void endVisit(AST::ForEachStatement *ast);
+
+ virtual bool visit(AST::LocalForEachStatement *ast);
+ virtual void endVisit(AST::LocalForEachStatement *ast);
+
+ virtual bool visit(AST::CaseBlock *ast);
+
+private:
+ int _inLoop;
+};
+
+class RewriteSignalHandler: protected AST::Visitor
+{
+ TextWriter *_writer;
+ const QString *_code;
+ int _position;
+
+public:
+ RewriteSignalHandler();
+ QString operator()(QQmlJS::AST::Node *node, const QString &code, const QString &name);
+
+protected:
+ void rewriteMultilineStrings(QString &code);
+
+ using AST::Visitor::visit;
+ void accept(AST::Node *node);
+ virtual bool visit(AST::StringLiteral *ast);
+};
+
+} // namespace QQmlRewrite
+
+QT_END_NAMESPACE
+
+#endif // QQMLREWRITE_P_H
+
diff --git a/src/qml/qml/qqmlscript.cpp b/src/qml/qml/qqmlscript.cpp
new file mode 100644
index 0000000000..d1c2faa138
--- /dev/null
+++ b/src/qml/qml/qqmlscript.cpp
@@ -0,0 +1,1700 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlscript_p.h"
+
+#include "parser/qqmljsengine_p.h"
+#include "parser/qqmljsparser_p.h"
+#include "parser/qqmljslexer_p.h"
+#include "parser/qqmljsmemorypool_p.h"
+#include "parser/qqmljsastvisitor_p.h"
+#include "parser/qqmljsast_p.h"
+#include <private/qqmlrewrite_p.h>
+
+#include <QStack>
+#include <QCoreApplication>
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QQmlJS;
+using namespace QQmlScript;
+
+//
+// Parser IR classes
+//
+QQmlScript::Object::Object()
+: type(-1), idIndex(-1), metatype(0), synthCache(0), defaultProperty(0), parserStatusCast(-1),
+ componentCompileState(0), nextAliasingObject(0), nextIdObject(0)
+{
+}
+
+QQmlScript::Object::~Object()
+{
+ if (synthCache) synthCache->release();
+}
+
+void Object::setBindingBit(int b)
+{
+ while (bindingBitmask.size() < 4 * (1 + b / 32))
+ bindingBitmask.append(char(0));
+
+ quint32 *bits = (quint32 *)bindingBitmask.data();
+ bits[b / 32] |= (1 << (b % 32));
+}
+
+const QMetaObject *Object::metaObject() const
+{
+ if (!metadata.isEmpty() && metatype)
+ return &extObject;
+ else
+ return metatype;
+}
+
+QQmlScript::Property *Object::getDefaultProperty()
+{
+ if (!defaultProperty) {
+ defaultProperty = pool()->New<Property>();
+ defaultProperty->parent = this;
+ }
+ return defaultProperty;
+}
+
+void QQmlScript::Object::addValueProperty(Property *p)
+{
+ valueProperties.append(p);
+}
+
+void QQmlScript::Object::addSignalProperty(Property *p)
+{
+ signalProperties.append(p);
+}
+
+void QQmlScript::Object::addAttachedProperty(Property *p)
+{
+ attachedProperties.append(p);
+}
+
+void QQmlScript::Object::addGroupedProperty(Property *p)
+{
+ groupedProperties.append(p);
+}
+
+void QQmlScript::Object::addValueTypeProperty(Property *p)
+{
+ valueTypeProperties.append(p);
+}
+
+void QQmlScript::Object::addScriptStringProperty(Property *p)
+{
+ scriptStringProperties.append(p);
+}
+
+// This lookup is optimized for missing, and having to create a new property.
+Property *QQmlScript::Object::getProperty(const QHashedStringRef &name, bool create)
+{
+ if (create) {
+ quint32 h = name.hash();
+ if (propertiesHashField.testAndSet(h)) {
+ for (Property *p = properties.first(); p; p = properties.next(p)) {
+ if (p->name() == name)
+ return p;
+ }
+ }
+
+ Property *property = pool()->New<Property>();
+ property->parent = this;
+ property->_name = name;
+ property->isDefault = false;
+ properties.prepend(property);
+ return property;
+ } else {
+ for (Property *p = properties.first(); p; p = properties.next(p)) {
+ if (p->name() == name)
+ return p;
+ }
+ }
+
+ return 0;
+}
+
+Property *QQmlScript::Object::getProperty(const QStringRef &name, bool create)
+{
+ return getProperty(QHashedStringRef(name), create);
+}
+
+Property *QQmlScript::Object::getProperty(const QString &name, bool create)
+{
+ for (Property *p = properties.first(); p; p = properties.next(p)) {
+ if (p->name() == name)
+ return p;
+ }
+
+ if (create) {
+ Property *property = pool()->New<Property>();
+ property->parent = this;
+ property->_name = QStringRef(pool()->NewString(name));
+ propertiesHashField.testAndSet(property->_name.hash());
+ property->isDefault = false;
+ properties.prepend(property);
+ return property;
+ } else {
+ return 0;
+ }
+}
+
+QQmlScript::Object::DynamicProperty::DynamicProperty()
+: isDefaultProperty(false), isReadOnly(false), type(Variant), defaultValue(0), nextProperty(0),
+ resolvedCustomTypeName(0)
+{
+}
+
+QQmlScript::Object::DynamicSignal::DynamicSignal()
+: nextSignal(0)
+{
+}
+
+// Returns length in utf8 bytes
+int QQmlScript::Object::DynamicSignal::parameterTypesLength() const
+{
+ int rv = 0;
+ for (int ii = 0; ii < parameterTypes.count(); ++ii)
+ rv += parameterTypes.at(ii).length();
+ return rv;
+}
+
+// Returns length in utf8 bytes
+int QQmlScript::Object::DynamicSignal::parameterNamesLength() const
+{
+ int rv = 0;
+ for (int ii = 0; ii < parameterNames.count(); ++ii)
+ rv += parameterNames.at(ii).utf8length();
+ return rv;
+}
+
+QQmlScript::Object::DynamicSlot::DynamicSlot()
+: nextSlot(0)
+{
+}
+
+int QQmlScript::Object::DynamicSlot::parameterNamesLength() const
+{
+ int rv = 0;
+ for (int ii = 0; ii < parameterNames.count(); ++ii)
+ rv += parameterNames.at(ii).length();
+ return rv;
+}
+
+QQmlScript::Property::Property()
+: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false),
+ isValueTypeSubProperty(false), isAlias(false), isReadOnlyDeclaration(false),
+ scriptStringScope(-1), nextMainProperty(0), nextProperty(0)
+{
+}
+
+QQmlScript::Object *QQmlScript::Property::getValue(const LocationSpan &l)
+{
+ if (!value) { value = pool()->New<Object>(); value->location = l; }
+ return value;
+}
+
+void QQmlScript::Property::addValue(Value *v)
+{
+ values.append(v);
+}
+
+void QQmlScript::Property::addOnValue(Value *v)
+{
+ onValues.append(v);
+}
+
+bool QQmlScript::Property::isEmpty() const
+{
+ return !value && values.isEmpty() && onValues.isEmpty();
+}
+
+QQmlScript::Value::Value()
+: type(Unknown), object(0), bindingReference(0), nextValue(0)
+{
+}
+
+QQmlScript::Variant::Variant()
+: t(Invalid)
+{
+}
+
+QQmlScript::Variant::Variant(const Variant &o)
+: t(o.t), d(o.d), asWritten(o.asWritten)
+{
+}
+
+QQmlScript::Variant::Variant(bool v)
+: t(Boolean), b(v)
+{
+}
+
+QQmlScript::Variant::Variant(double v, const QStringRef &asWritten)
+: t(Number), d(v), asWritten(asWritten)
+{
+}
+
+QQmlScript::Variant::Variant(QQmlJS::AST::StringLiteral *v)
+: t(String), l(v)
+{
+}
+
+QQmlScript::Variant::Variant(const QStringRef &asWritten, QQmlJS::AST::Node *n)
+: t(Script), n(n), asWritten(asWritten)
+{
+}
+
+QQmlScript::Variant &QQmlScript::Variant::operator=(const Variant &o)
+{
+ t = o.t;
+ d = o.d;
+ asWritten = o.asWritten;
+ return *this;
+}
+
+QQmlScript::Variant::Type QQmlScript::Variant::type() const
+{
+ return t;
+}
+
+bool QQmlScript::Variant::asBoolean() const
+{
+ return b;
+}
+
+QString QQmlScript::Variant::asString() const
+{
+ if (t == String) {
+ return l->value.toString();
+ } else {
+ return asWritten.toString();
+ }
+}
+
+double QQmlScript::Variant::asNumber() const
+{
+ return d;
+}
+
+//reverse of Lexer::singleEscape()
+QString escapedString(const QString &string)
+{
+ QString tmp = QLatin1String("\"");
+ for (int i = 0; i < string.length(); ++i) {
+ const QChar &c = string.at(i);
+ switch(c.unicode()) {
+ case 0x08:
+ tmp += QLatin1String("\\b");
+ break;
+ case 0x09:
+ tmp += QLatin1String("\\t");
+ break;
+ case 0x0A:
+ tmp += QLatin1String("\\n");
+ break;
+ case 0x0B:
+ tmp += QLatin1String("\\v");
+ break;
+ case 0x0C:
+ tmp += QLatin1String("\\f");
+ break;
+ case 0x0D:
+ tmp += QLatin1String("\\r");
+ break;
+ case 0x22:
+ tmp += QLatin1String("\\\"");
+ break;
+ case 0x27:
+ tmp += QLatin1String("\\\'");
+ break;
+ case 0x5C:
+ tmp += QLatin1String("\\\\");
+ break;
+ default:
+ tmp += c;
+ break;
+ }
+ }
+ tmp += QLatin1Char('\"');
+ return tmp;
+}
+
+QString QQmlScript::Variant::asScript() const
+{
+ switch(type()) {
+ default:
+ case Invalid:
+ return QString();
+ case Boolean:
+ return b?QLatin1String("true"):QLatin1String("false");
+ case Number:
+ if (asWritten.isEmpty())
+ return QString::number(d);
+ else
+ return asWritten.toString();
+ case String:
+ return escapedString(asString());
+ case Script:
+ if (AST::IdentifierExpression *i = AST::cast<AST::IdentifierExpression *>(n)) {
+ return i->name.toString();
+ } else
+ return asWritten.toString();
+ }
+}
+
+QQmlJS::AST::Node *QQmlScript::Variant::asAST() const
+{
+ if (type() == Script)
+ return n;
+ else
+ return 0;
+}
+
+bool QQmlScript::Variant::isStringList() const
+{
+ if (isString())
+ return true;
+
+ if (type() != Script || !n)
+ return false;
+
+ AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
+ if (!array)
+ return false;
+
+ AST::ElementList *elements = array->elements;
+
+ while (elements) {
+
+ if (!AST::cast<AST::StringLiteral *>(elements->expression))
+ return false;
+
+ elements = elements->next;
+ }
+
+ return true;
+}
+
+QStringList QQmlScript::Variant::asStringList() const
+{
+ QStringList rv;
+ if (isString()) {
+ rv << asString();
+ return rv;
+ }
+
+ AST::ArrayLiteral *array = AST::cast<AST::ArrayLiteral *>(n);
+ if (!array)
+ return rv;
+
+ AST::ElementList *elements = array->elements;
+ while (elements) {
+
+ AST::StringLiteral *string = AST::cast<AST::StringLiteral *>(elements->expression);
+ if (!string)
+ return QStringList();
+ rv.append(string->value.toString());
+
+ elements = elements->next;
+ }
+
+ return rv;
+}
+
+//
+// Actual parser classes
+//
+void QQmlScript::Import::extractVersion(int *maj, int *min) const
+{
+ *maj = -1; *min = -1;
+
+ if (!version.isEmpty()) {
+ int dot = version.indexOf(QLatin1Char('.'));
+ if (dot < 0) {
+ *maj = version.toInt();
+ *min = 0;
+ } else {
+ *maj = version.left(dot).toInt();
+ *min = version.mid(dot+1).toInt();
+ }
+ }
+}
+
+namespace {
+
+class ProcessAST: protected AST::Visitor
+{
+ struct State {
+ State() : object(0), property(0) {}
+ State(QQmlScript::Object *o) : object(o), property(0) {}
+ State(QQmlScript::Object *o, Property *p) : object(o), property(p) {}
+
+ QQmlScript::Object *object;
+ Property *property;
+ };
+
+ struct StateStack : public QStack<State>
+ {
+ void pushObject(QQmlScript::Object *obj)
+ {
+ push(State(obj));
+ }
+
+ void pushProperty(const QString &name, const LocationSpan &location)
+ {
+ const State &state = top();
+ if (state.property) {
+ State s(state.property->getValue(location),
+ state.property->getValue(location)->getProperty(name));
+ s.property->location = location;
+ push(s);
+ } else {
+ State s(state.object, state.object->getProperty(name));
+
+ s.property->location = location;
+ push(s);
+ }
+ }
+
+ void pushProperty(const QStringRef &name, const LocationSpan &location)
+ {
+ const State &state = top();
+ if (state.property) {
+ State s(state.property->getValue(location),
+ state.property->getValue(location)->getProperty(name));
+ s.property->location = location;
+ push(s);
+ } else {
+ State s(state.object, state.object->getProperty(name));
+
+ s.property->location = location;
+ push(s);
+ }
+ }
+ };
+
+public:
+ ProcessAST(QQmlScript::Parser *parser);
+ virtual ~ProcessAST();
+
+ void operator()(const QString &code, AST::Node *node);
+
+protected:
+
+ QQmlScript::Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
+ const QString &objectType,
+ AST::SourceLocation typeLocation,
+ LocationSpan location,
+ AST::UiObjectInitializer *initializer = 0);
+
+ QQmlScript::Variant getVariant(AST::Statement *stmt);
+ QQmlScript::Variant getVariant(AST::ExpressionNode *expr);
+
+ LocationSpan location(AST::SourceLocation start, AST::SourceLocation end);
+ LocationSpan location(AST::UiQualifiedId *);
+
+ using AST::Visitor::visit;
+ using AST::Visitor::endVisit;
+
+ virtual bool visit(AST::UiProgram *node);
+ virtual bool visit(AST::UiImport *node);
+ virtual bool visit(AST::UiObjectDefinition *node);
+ virtual bool visit(AST::UiPublicMember *node);
+ virtual bool visit(AST::UiObjectBinding *node);
+
+ virtual bool visit(AST::UiScriptBinding *node);
+ virtual bool visit(AST::UiArrayBinding *node);
+ virtual bool visit(AST::UiSourceElement *node);
+
+ void accept(AST::Node *node);
+
+ QString asString(AST::UiQualifiedId *node) const;
+
+ const State state() const;
+ QQmlScript::Object *currentObject() const;
+ Property *currentProperty() const;
+
+ QString qualifiedNameId() const;
+
+ QString textAt(const AST::SourceLocation &loc) const
+ { return _contents->mid(loc.offset, loc.length); }
+
+ QStringRef textRefAt(const AST::SourceLocation &loc) const
+ { return QStringRef(_contents, loc.offset, loc.length); }
+
+ QString textAt(const AST::SourceLocation &first,
+ const AST::SourceLocation &last) const
+ { return _contents->mid(first.offset, last.offset + last.length - first.offset); }
+
+ QStringRef textRefAt(const AST::SourceLocation &first,
+ const AST::SourceLocation &last) const
+ { return QStringRef(_contents, first.offset, last.offset + last.length - first.offset); }
+
+ QString asString(AST::ExpressionNode *expr)
+ {
+ if (! expr)
+ return QString();
+
+ return textAt(expr->firstSourceLocation(), expr->lastSourceLocation());
+ }
+
+ QStringRef asStringRef(AST::ExpressionNode *expr)
+ {
+ if (! expr)
+ return QStringRef();
+
+ return textRefAt(expr->firstSourceLocation(), expr->lastSourceLocation());
+ }
+
+ QString asString(AST::Statement *stmt)
+ {
+ if (! stmt)
+ return QString();
+
+ QString s = textAt(stmt->firstSourceLocation(), stmt->lastSourceLocation());
+ s += QLatin1Char('\n');
+ return s;
+ }
+
+ QStringRef asStringRef(AST::Statement *stmt)
+ {
+ if (! stmt)
+ return QStringRef();
+
+ return textRefAt(stmt->firstSourceLocation(), stmt->lastSourceLocation());
+ }
+
+private:
+ QQmlScript::Parser *_parser;
+ StateStack _stateStack;
+ QStringList _scope;
+ const QString *_contents;
+};
+
+ProcessAST::ProcessAST(QQmlScript::Parser *parser)
+ : _parser(parser)
+{
+}
+
+ProcessAST::~ProcessAST()
+{
+}
+
+void ProcessAST::operator()(const QString &code, AST::Node *node)
+{
+ _contents = &code;
+ accept(node);
+}
+
+void ProcessAST::accept(AST::Node *node)
+{
+ AST::Node::acceptChild(node, this);
+}
+
+const ProcessAST::State ProcessAST::state() const
+{
+ if (_stateStack.isEmpty())
+ return State();
+
+ return _stateStack.back();
+}
+
+QQmlScript::Object *ProcessAST::currentObject() const
+{
+ return state().object;
+}
+
+Property *ProcessAST::currentProperty() const
+{
+ return state().property;
+}
+
+QString ProcessAST::qualifiedNameId() const
+{
+ return _scope.join(QLatin1String("/"));
+}
+
+QString ProcessAST::asString(AST::UiQualifiedId *node) const
+{
+ QString s;
+
+ for (AST::UiQualifiedId *it = node; it; it = it->next) {
+ s.append(it->name.toString());
+
+ if (it->next)
+ s.append(QLatin1Char('.'));
+ }
+
+ return s;
+}
+
+QQmlScript::Object *
+ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
+ bool onAssignment,
+ const QString &objectType,
+ AST::SourceLocation typeLocation,
+ LocationSpan location,
+ AST::UiObjectInitializer *initializer)
+{
+ int lastTypeDot = objectType.lastIndexOf(QLatin1Char('.'));
+
+ // With no preceding qualification, first char is at (-1 + 1) == 0
+ bool isType = !objectType.isEmpty() && objectType.at(lastTypeDot+1).isUpper();
+
+ int propertyCount = 0;
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
+ ++propertyCount;
+ _stateStack.pushProperty(name->name,
+ this->location(name));
+ }
+
+ if (!onAssignment && propertyCount && currentProperty() && !currentProperty()->values.isEmpty()) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return 0;
+ }
+
+ if (!isType) {
+
+ // Is the identifier qualified by a namespace?
+ int namespaceLength = 0;
+ if (lastTypeDot > 0) {
+ const QString qualifier(objectType.left(lastTypeDot));
+
+ for (int ii = 0; ii < _parser->_imports.count(); ++ii) {
+ const QQmlScript::Import &import = _parser->_imports.at(ii);
+ if (import.qualifier == qualifier) {
+ // The qualifier is a namespace - expect a type here
+ namespaceLength = qualifier.length() + 1;
+ break;
+ }
+ }
+ }
+
+ if (propertyCount || !currentObject() || namespaceLength) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Expected type name"));
+ error.setLine(typeLocation.startLine);
+ error.setColumn(typeLocation.startColumn + namespaceLength);
+ _parser->_errors << error;
+ return 0;
+ }
+
+ LocationSpan loc = ProcessAST::location(typeLocation, typeLocation);
+ if (propertyName)
+ loc = ProcessAST::location(propertyName);
+
+ _stateStack.pushProperty(objectType, loc);
+ accept(initializer);
+ _stateStack.pop();
+
+ return 0;
+
+ } else {
+ // Class
+
+ QString resolvableObjectType = objectType;
+ if (lastTypeDot >= 0)
+ resolvableObjectType.replace(QLatin1Char('.'),QLatin1Char('/'));
+
+ QQmlScript::Object *obj = _parser->_pool.New<QQmlScript::Object>();
+
+ QQmlScript::TypeReference *typeRef = _parser->findOrCreateType(resolvableObjectType);
+ obj->type = typeRef->id;
+
+ typeRef->refObjects.append(obj);
+
+ // XXX this doesn't do anything (_scope never builds up)
+ _scope.append(resolvableObjectType);
+ obj->typeName = qualifiedNameId();
+ _scope.removeLast();
+
+ obj->location = location;
+
+ if (propertyCount) {
+ Property *prop = currentProperty();
+ QQmlScript::Value *v = _parser->_pool.New<QQmlScript::Value>();
+ v->object = obj;
+ v->location = obj->location;
+ if (onAssignment)
+ prop->addOnValue(v);
+ else
+ prop->addValue(v);
+
+ while (propertyCount--)
+ _stateStack.pop();
+
+ } else {
+
+ if (! _parser->tree()) {
+ _parser->setTree(obj);
+ } else {
+ const State state = _stateStack.top();
+ QQmlScript::Value *v = _parser->_pool.New<QQmlScript::Value>();
+ v->object = obj;
+ v->location = obj->location;
+ if (state.property) {
+ state.property->addValue(v);
+ } else {
+ Property *defaultProp = state.object->getDefaultProperty();
+ if (defaultProp->location.start.line == -1) {
+ defaultProp->location = v->location;
+ defaultProp->location.end = defaultProp->location.start;
+ defaultProp->location.range.length = 0;
+ }
+ defaultProp->addValue(v);
+ }
+ }
+ }
+
+ _stateStack.pushObject(obj);
+ accept(initializer);
+ _stateStack.pop();
+
+ return obj;
+ }
+}
+
+LocationSpan ProcessAST::location(AST::UiQualifiedId *id)
+{
+ return location(id->identifierToken, id->identifierToken);
+}
+
+LocationSpan ProcessAST::location(AST::SourceLocation start, AST::SourceLocation end)
+{
+ LocationSpan rv;
+ rv.start.line = start.startLine;
+ rv.start.column = start.startColumn;
+ rv.end.line = end.startLine;
+ rv.end.column = end.startColumn + end.length - 1;
+ rv.range.offset = start.offset;
+ rv.range.length = end.offset + end.length - start.offset;
+ return rv;
+}
+
+// UiProgram: UiImportListOpt UiObjectMemberList ;
+bool ProcessAST::visit(AST::UiProgram *node)
+{
+ accept(node->imports);
+ accept(node->members->member);
+ return false;
+}
+
+// UiImport: T_IMPORT T_STRING_LITERAL ;
+bool ProcessAST::visit(AST::UiImport *node)
+{
+ QString uri;
+ QQmlScript::Import import;
+
+ if (!node->fileName.isNull()) {
+ uri = node->fileName.toString();
+
+ if (uri.endsWith(QLatin1String(".js"))) {
+ import.type = QQmlScript::Import::Script;
+ } else {
+ import.type = QQmlScript::Import::File;
+ }
+ } else {
+ import.type = QQmlScript::Import::Library;
+ uri = asString(node->importUri);
+ }
+
+ AST::SourceLocation startLoc = node->importToken;
+ AST::SourceLocation endLoc = node->semicolonToken;
+
+ // Qualifier
+ if (!node->importId.isNull()) {
+ import.qualifier = node->importId.toString();
+ if (!import.qualifier.at(0).isUpper()) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Invalid import qualifier ID"));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+ if (import.qualifier == QLatin1String("Qt")) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Reserved name \"Qt\" cannot be used as an qualifier"));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ // Check for script qualifier clashes
+ bool isScript = import.type == QQmlScript::Import::Script;
+ for (int ii = 0; ii < _parser->_imports.count(); ++ii) {
+ const QQmlScript::Import &other = _parser->_imports.at(ii);
+ bool otherIsScript = other.type == QQmlScript::Import::Script;
+
+ if ((isScript || otherIsScript) && import.qualifier == other.qualifier) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Script import qualifiers must be unique."));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+ }
+
+ } else if (import.type == QQmlScript::Import::Script) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Script import requires a qualifier"));
+ error.setLine(node->fileNameToken.startLine);
+ error.setColumn(node->fileNameToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ if (node->versionToken.isValid()) {
+ import.version = textAt(node->versionToken);
+ } else if (import.type == QQmlScript::Import::Library) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Library import requires a version"));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+
+ import.location = location(startLoc, endLoc);
+ import.uri = uri;
+
+ _parser->_imports << import;
+
+ return false;
+}
+
+bool ProcessAST::visit(AST::UiPublicMember *node)
+{
+ static const struct TypeNameToType {
+ const char *name;
+ int nameLength;
+ Object::DynamicProperty::Type type;
+ const char *qtName;
+ int qtNameLength;
+ } propTypeNameToTypes[] = {
+ { "int", strlen("int"), Object::DynamicProperty::Int, "int", strlen("int") },
+ { "bool", strlen("bool"), Object::DynamicProperty::Bool, "bool", strlen("bool") },
+ { "double", strlen("double"), Object::DynamicProperty::Real, "double", strlen("double") },
+ { "real", strlen("real"), Object::DynamicProperty::Real, "qreal", strlen("qreal") },
+ { "string", strlen("string"), Object::DynamicProperty::String, "QString", strlen("QString") },
+ { "url", strlen("url"), Object::DynamicProperty::Url, "QUrl", strlen("QUrl") },
+ { "color", strlen("color"), Object::DynamicProperty::Color, "QColor", strlen("QColor") },
+ // Internally QTime, QDate and QDateTime are all supported.
+ // To be more consistent with JavaScript we expose only
+ // QDateTime as it matches closely with the Date JS type.
+ // We also call it "date" to match.
+ // { "time", strlen("time"), Object::DynamicProperty::Time, "QTime", strlen("QTime") },
+ // { "date", strlen("date"), Object::DynamicProperty::Date, "QDate", strlen("QDate") },
+ { "date", strlen("date"), Object::DynamicProperty::DateTime, "QDateTime", strlen("QDateTime") },
+ { "variant", strlen("variant"), Object::DynamicProperty::Variant, "QVariant", strlen("QVariant") },
+ { "var", strlen("var"), Object::DynamicProperty::Var, "QVariant", strlen("QVariant") }
+ };
+ static const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) /
+ sizeof(propTypeNameToTypes[0]);
+
+ if(node->type == AST::UiPublicMember::Signal) {
+ Object::DynamicSignal *signal = _parser->_pool.New<Object::DynamicSignal>();
+ signal->name = node->name;
+
+ AST::UiParameterList *p = node->parameters;
+ int paramLength = 0;
+ while (p) { paramLength++; p = p->next; }
+ p = node->parameters;
+
+ if (paramLength) {
+ signal->parameterTypes = _parser->_pool.NewRawList<QHashedCStringRef>(paramLength);
+ signal->parameterNames = _parser->_pool.NewRawList<QHashedStringRef>(paramLength);
+ }
+
+ int index = 0;
+ while (p) {
+ const QStringRef &memberType = p->type;
+
+ const TypeNameToType *type = 0;
+ for(int typeIndex = 0; typeIndex < propTypeNameToTypesCount; ++typeIndex) {
+ const TypeNameToType *t = propTypeNameToTypes + typeIndex;
+ if (t->nameLength == memberType.length() &&
+ QHashedString::compare(memberType.constData(), t->name, t->nameLength)) {
+ type = t;
+ break;
+ }
+ }
+
+ if (!type) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Expected parameter type"));
+ error.setLine(node->typeToken.startLine);
+ error.setColumn(node->typeToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ signal->parameterTypes[index] = QHashedCStringRef(type->qtName, type->qtNameLength);
+ signal->parameterNames[index] = QHashedStringRef(p->name);
+ p = p->next;
+ index++;
+ }
+
+ signal->location = location(node->typeToken, node->semicolonToken);
+ _stateStack.top().object->dynamicSignals.append(signal);
+ } else {
+ const QStringRef &memberType = node->memberType;
+ const QStringRef &name = node->name;
+
+ bool typeFound = false;
+ Object::DynamicProperty::Type type;
+
+ if ((unsigned)memberType.length() == strlen("alias") &&
+ QHashedString::compare(memberType.constData(), "alias", strlen("alias"))) {
+ type = Object::DynamicProperty::Alias;
+ typeFound = true;
+ }
+
+ for(int ii = 0; !typeFound && ii < propTypeNameToTypesCount; ++ii) {
+ const TypeNameToType *t = propTypeNameToTypes + ii;
+ if (t->nameLength == memberType.length() &&
+ QHashedString::compare(memberType.constData(), t->name, t->nameLength)) {
+ type = t->type;
+ typeFound = true;
+ }
+ }
+
+ if (!typeFound && memberType.at(0).isUpper()) {
+ const QStringRef &typeModifier = node->typeModifier;
+
+ if (typeModifier.isEmpty()) {
+ type = Object::DynamicProperty::Custom;
+ } else if((unsigned)typeModifier.length() == strlen("list") &&
+ QHashedString::compare(typeModifier.constData(), "list", strlen("list"))) {
+ type = Object::DynamicProperty::CustomList;
+ } else {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Invalid property type modifier"));
+ error.setLine(node->typeModifierToken.startLine);
+ error.setColumn(node->typeModifierToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+ typeFound = true;
+ } else if (!node->typeModifier.isNull()) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Unexpected property type modifier"));
+ error.setLine(node->typeModifierToken.startLine);
+ error.setColumn(node->typeModifierToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ if(!typeFound) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Expected property type"));
+ error.setLine(node->typeToken.startLine);
+ error.setColumn(node->typeToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ Object::DynamicProperty *property = _parser->_pool.New<Object::DynamicProperty>();
+ property->isDefaultProperty = node->isDefaultMember;
+ property->isReadOnly = node->isReadonlyMember;
+ property->type = type;
+ property->nameLocation.line = node->identifierToken.startLine;
+ property->nameLocation.column = node->identifierToken.startColumn;
+ if (type >= Object::DynamicProperty::Custom) {
+ QQmlScript::TypeReference *typeRef =
+ _parser->findOrCreateType(memberType.toString());
+ typeRef->refObjects.append(_stateStack.top().object);
+ property->customType = memberType;
+ }
+
+ property->name = QHashedStringRef(name);
+ property->location = location(node->firstSourceLocation(),
+ node->lastSourceLocation());
+
+ if (node->statement) { // default value
+ property->defaultValue = _parser->_pool.New<Property>();
+ property->defaultValue->parent = _stateStack.top().object;
+ property->defaultValue->location =
+ location(node->statement->firstSourceLocation(),
+ node->statement->lastSourceLocation());
+ QQmlScript::Value *value = _parser->_pool.New<QQmlScript::Value>();
+ value->location = location(node->statement->firstSourceLocation(),
+ node->statement->lastSourceLocation());
+ value->value = getVariant(node->statement);
+ property->defaultValue->values.append(value);
+ }
+
+ _stateStack.top().object->dynamicProperties.append(property);
+
+ // process QML-like initializers (e.g. property Object o: Object {})
+ accept(node->binding);
+ }
+
+ return false;
+}
+
+
+// UiObjectMember: UiQualifiedId UiObjectInitializer ;
+bool ProcessAST::visit(AST::UiObjectDefinition *node)
+{
+ LocationSpan l = location(node->firstSourceLocation(),
+ node->lastSourceLocation());
+
+ const QString objectType = asString(node->qualifiedTypeNameId);
+ const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken;
+
+ defineObjectBinding(/*propertyName = */ 0, false, objectType,
+ typeLocation, l, node->initializer);
+
+ return false;
+}
+
+
+// UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
+bool ProcessAST::visit(AST::UiObjectBinding *node)
+{
+ LocationSpan l = location(node->qualifiedTypeNameId->identifierToken,
+ node->initializer->rbraceToken);
+
+ const QString objectType = asString(node->qualifiedTypeNameId);
+ const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken;
+
+ defineObjectBinding(node->qualifiedId, node->hasOnToken, objectType,
+ typeLocation, l, node->initializer);
+
+ return false;
+}
+
+QQmlScript::Variant ProcessAST::getVariant(AST::Statement *stmt)
+{
+ if (stmt) {
+ if (AST::ExpressionStatement *exprStmt = AST::cast<AST::ExpressionStatement *>(stmt))
+ return getVariant(exprStmt->expression);
+
+ return QQmlScript::Variant(asStringRef(stmt), stmt);
+ }
+
+ return QQmlScript::Variant();
+}
+
+QQmlScript::Variant ProcessAST::getVariant(AST::ExpressionNode *expr)
+{
+ if (AST::StringLiteral *lit = AST::cast<AST::StringLiteral *>(expr)) {
+ return QQmlScript::Variant(lit);
+ } else if (expr->kind == AST::Node::Kind_TrueLiteral) {
+ return QQmlScript::Variant(true);
+ } else if (expr->kind == AST::Node::Kind_FalseLiteral) {
+ return QQmlScript::Variant(false);
+ } else if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(expr)) {
+ return QQmlScript::Variant(lit->value, asStringRef(expr));
+ } else {
+
+ if (AST::UnaryMinusExpression *unaryMinus = AST::cast<AST::UnaryMinusExpression *>(expr)) {
+ if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(unaryMinus->expression)) {
+ return QQmlScript::Variant(-lit->value, asStringRef(expr));
+ }
+ }
+
+ return QQmlScript::Variant(asStringRef(expr), expr);
+ }
+}
+
+
+// UiObjectMember: UiQualifiedId T_COLON Statement ;
+bool ProcessAST::visit(AST::UiScriptBinding *node)
+{
+ int propertyCount = 0;
+ AST::UiQualifiedId *propertyName = node->qualifiedId;
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
+ ++propertyCount;
+ _stateStack.pushProperty(name->name,
+ location(name));
+ }
+
+ Property *prop = currentProperty();
+
+ if (!prop->values.isEmpty()) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return 0;
+ }
+
+ QQmlScript::Variant primitive;
+
+ if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) {
+ primitive = getVariant(stmt->expression);
+ } else { // do binding
+ primitive = QQmlScript::Variant(asStringRef(node->statement), node->statement);
+ }
+
+ prop->location.range.length = prop->location.range.offset + prop->location.range.length - node->qualifiedId->identifierToken.offset;
+ prop->location.range.offset = node->qualifiedId->identifierToken.offset;
+ QQmlScript::Value *v = _parser->_pool.New<QQmlScript::Value>();
+ v->value = primitive;
+ v->location = location(node->statement->firstSourceLocation(),
+ node->statement->lastSourceLocation());
+
+ prop->addValue(v);
+
+ while (propertyCount--)
+ _stateStack.pop();
+
+ return false;
+}
+
+// UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
+bool ProcessAST::visit(AST::UiArrayBinding *node)
+{
+ int propertyCount = 0;
+ AST::UiQualifiedId *propertyName = node->qualifiedId;
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
+ ++propertyCount;
+ _stateStack.pushProperty(name->name,
+ location(name));
+ }
+
+ Property* prop = currentProperty();
+
+ if (!prop->values.isEmpty()) {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return false;
+ }
+
+ accept(node->members);
+
+ // For the DOM, store the position of the T_LBRACKET upto the T_RBRACKET as the range:
+ prop->listValueRange.offset = node->lbracketToken.offset;
+ prop->listValueRange.length = node->rbracketToken.offset + node->rbracketToken.length - node->lbracketToken.offset;
+
+ while (propertyCount--)
+ _stateStack.pop();
+
+ return false;
+}
+
+bool ProcessAST::visit(AST::UiSourceElement *node)
+{
+ QQmlScript::Object *obj = currentObject();
+
+ if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
+
+ Object::DynamicSlot *slot = _parser->_pool.New<Object::DynamicSlot>();
+ slot->location = location(funDecl->identifierToken, funDecl->lastSourceLocation());
+
+ AST::FormalParameterList *f = funDecl->formals;
+ while (f) {
+ slot->parameterNames << f->name.toUtf8();
+ f = f->next;
+ }
+
+ AST::SourceLocation loc = funDecl->rparenToken;
+ loc.offset = loc.end();
+ loc.startColumn += 1;
+ QString body = textAt(loc, funDecl->rbraceToken);
+ slot->name = funDecl->name;
+ slot->body = body;
+ obj->dynamicSlots.append(slot);
+
+ } else {
+ QQmlError error;
+ error.setDescription(QCoreApplication::translate("QQmlParser","JavaScript declaration outside Script element"));
+ error.setLine(node->firstSourceLocation().startLine);
+ error.setColumn(node->firstSourceLocation().startColumn);
+ _parser->_errors << error;
+ }
+ return false;
+}
+
+} // end of anonymous namespace
+
+
+QQmlScript::Parser::Parser()
+: root(0), data(0)
+{
+
+}
+
+QQmlScript::Parser::~Parser()
+{
+ clear();
+}
+
+namespace QQmlScript {
+class ParserJsASTData
+{
+public:
+ ParserJsASTData(const QString &filename)
+ : filename(filename) {}
+
+ QString filename;
+ Engine engine;
+};
+}
+
+bool QQmlScript::Parser::parse(const QByteArray &qmldata, const QUrl &url,
+ const QString &urlString)
+{
+ clear();
+
+ if (urlString.isEmpty()) {
+ _scriptFile = url.toString();
+ } else {
+ // Q_ASSERT(urlString == url.toString());
+ _scriptFile = urlString;
+ }
+
+ QTextStream stream(qmldata, QIODevice::ReadOnly);
+#ifndef QT_NO_TEXTCODEC
+ stream.setCodec("UTF-8");
+#endif
+ QString *code = _pool.NewString(stream.readAll());
+
+ data = new QQmlScript::ParserJsASTData(_scriptFile);
+
+ Lexer lexer(&data->engine);
+ lexer.setCode(*code, /*line = */ 1);
+
+ QQmlJS::Parser parser(&data->engine);
+
+ if (! parser.parse() || !_errors.isEmpty()) {
+
+ // Extract errors from the parser
+ foreach (const DiagnosticMessage &m, parser.diagnosticMessages()) {
+
+ if (m.isWarning())
+ continue;
+
+ QQmlError error;
+ error.setUrl(url);
+ error.setDescription(m.message);
+ error.setLine(m.loc.startLine);
+ error.setColumn(m.loc.startColumn);
+ _errors << error;
+
+ }
+ }
+
+ if (_errors.isEmpty()) {
+ ProcessAST process(this);
+ process(*code, parser.ast());
+
+ // Set the url for process errors
+ for(int ii = 0; ii < _errors.count(); ++ii)
+ _errors[ii].setUrl(url);
+ }
+
+ return _errors.isEmpty();
+}
+
+QList<QQmlScript::TypeReference*> QQmlScript::Parser::referencedTypes() const
+{
+ return _refTypes;
+}
+
+QQmlScript::Object *QQmlScript::Parser::tree() const
+{
+ return root;
+}
+
+QList<QQmlScript::Import> QQmlScript::Parser::imports() const
+{
+ return _imports;
+}
+
+QList<QQmlError> QQmlScript::Parser::errors() const
+{
+ return _errors;
+}
+
+static void replaceWithSpace(QString &str, int idx, int n)
+{
+ QChar *data = str.data() + idx;
+ const QChar space(QLatin1Char(' '));
+ for (int ii = 0; ii < n; ++ii)
+ *data++ = space;
+}
+
+static QQmlScript::LocationSpan
+locationFromLexer(const QQmlJS::Lexer &lex, int startLine, int startColumn, int startOffset)
+{
+ QQmlScript::LocationSpan l;
+
+ l.start.line = startLine; l.start.column = startColumn;
+ l.end.line = lex.tokenEndLine(); l.end.column = lex.tokenEndColumn();
+ l.range.offset = startOffset;
+ l.range.length = lex.tokenOffset() + lex.tokenLength() - startOffset;
+
+ return l;
+}
+
+/*
+Searches for ".pragma <value>" declarations within \a script. Currently supported pragmas
+are:
+ library
+*/
+QQmlScript::Object::ScriptBlock::Pragmas QQmlScript::Parser::extractPragmas(QString &script)
+{
+ QQmlScript::Object::ScriptBlock::Pragmas rv = QQmlScript::Object::ScriptBlock::None;
+
+ const QString pragma(QLatin1String("pragma"));
+ const QString library(QLatin1String("library"));
+
+ QQmlJS::Lexer l(0);
+ l.setCode(script, 0);
+
+ int token = l.lex();
+
+ while (true) {
+ if (token != QQmlJSGrammar::T_DOT)
+ return rv;
+
+ int startOffset = l.tokenOffset();
+ int startLine = l.tokenStartLine();
+
+ token = l.lex();
+
+ if (token != QQmlJSGrammar::T_IDENTIFIER ||
+ l.tokenStartLine() != startLine ||
+ script.mid(l.tokenOffset(), l.tokenLength()) != pragma)
+ return rv;
+
+ token = l.lex();
+
+ if (token != QQmlJSGrammar::T_IDENTIFIER ||
+ l.tokenStartLine() != startLine)
+ return rv;
+
+ QString pragmaValue = script.mid(l.tokenOffset(), l.tokenLength());
+ int endOffset = l.tokenLength() + l.tokenOffset();
+
+ token = l.lex();
+ if (l.tokenStartLine() == startLine)
+ return rv;
+
+ if (pragmaValue == library) {
+ rv |= QQmlScript::Object::ScriptBlock::Shared;
+ replaceWithSpace(script, startOffset, endOffset - startOffset);
+ } else {
+ return rv;
+ }
+ }
+ return rv;
+}
+
+#define CHECK_LINE if (l.tokenStartLine() != startLine) return rv;
+#define CHECK_TOKEN(t) if (token != QQmlJSGrammar:: t) return rv;
+
+static const int uriTokens[] = {
+ QQmlJSGrammar::T_IDENTIFIER,
+ QQmlJSGrammar::T_PROPERTY,
+ QQmlJSGrammar::T_SIGNAL,
+ QQmlJSGrammar::T_READONLY,
+ QQmlJSGrammar::T_ON,
+ QQmlJSGrammar::T_BREAK,
+ QQmlJSGrammar::T_CASE,
+ QQmlJSGrammar::T_CATCH,
+ QQmlJSGrammar::T_CONTINUE,
+ QQmlJSGrammar::T_DEFAULT,
+ QQmlJSGrammar::T_DELETE,
+ QQmlJSGrammar::T_DO,
+ QQmlJSGrammar::T_ELSE,
+ QQmlJSGrammar::T_FALSE,
+ QQmlJSGrammar::T_FINALLY,
+ QQmlJSGrammar::T_FOR,
+ QQmlJSGrammar::T_FUNCTION,
+ QQmlJSGrammar::T_IF,
+ QQmlJSGrammar::T_IN,
+ QQmlJSGrammar::T_INSTANCEOF,
+ QQmlJSGrammar::T_NEW,
+ QQmlJSGrammar::T_NULL,
+ QQmlJSGrammar::T_RETURN,
+ QQmlJSGrammar::T_SWITCH,
+ QQmlJSGrammar::T_THIS,
+ QQmlJSGrammar::T_THROW,
+ QQmlJSGrammar::T_TRUE,
+ QQmlJSGrammar::T_TRY,
+ QQmlJSGrammar::T_TYPEOF,
+ QQmlJSGrammar::T_VAR,
+ QQmlJSGrammar::T_VOID,
+ QQmlJSGrammar::T_WHILE,
+ QQmlJSGrammar::T_CONST,
+ QQmlJSGrammar::T_DEBUGGER,
+ QQmlJSGrammar::T_RESERVED_WORD,
+ QQmlJSGrammar::T_WITH,
+
+ QQmlJSGrammar::EOF_SYMBOL
+};
+static inline bool isUriToken(int token)
+{
+ const int *current = uriTokens;
+ while (*current != QQmlJSGrammar::EOF_SYMBOL) {
+ if (*current == token)
+ return true;
+ ++current;
+ }
+ return false;
+}
+
+QQmlScript::Parser::JavaScriptMetaData QQmlScript::Parser::extractMetaData(QString &script)
+{
+ JavaScriptMetaData rv;
+
+ QQmlScript::Object::ScriptBlock::Pragmas &pragmas = rv.pragmas;
+
+ const QString pragma(QLatin1String("pragma"));
+ const QString js(QLatin1String(".js"));
+ const QString library(QLatin1String("library"));
+
+ QQmlJS::Lexer l(0);
+ l.setCode(script, 0);
+
+ int token = l.lex();
+
+ while (true) {
+ if (token != QQmlJSGrammar::T_DOT)
+ return rv;
+
+ int startOffset = l.tokenOffset();
+ int startLine = l.tokenStartLine();
+ int startColumn = l.tokenStartColumn();
+
+ token = l.lex();
+
+ CHECK_LINE;
+
+ if (token == QQmlJSGrammar::T_IMPORT) {
+
+ // .import <URI> <Version> as <Identifier>
+ // .import <file.js> as <Identifier>
+
+ token = l.lex();
+
+ CHECK_LINE;
+
+ if (token == QQmlJSGrammar::T_STRING_LITERAL) {
+
+ QString file = l.tokenText();
+
+ if (!file.endsWith(js))
+ return rv;
+
+ token = l.lex();
+
+ CHECK_TOKEN(T_AS);
+ CHECK_LINE;
+
+ token = l.lex();
+
+ CHECK_TOKEN(T_IDENTIFIER);
+ CHECK_LINE;
+
+ int endOffset = l.tokenLength() + l.tokenOffset();
+
+ QString importId = script.mid(l.tokenOffset(), l.tokenLength());
+
+ if (!importId.at(0).isUpper())
+ return rv;
+
+ QQmlScript::LocationSpan location =
+ locationFromLexer(l, startLine, startColumn, startOffset);
+
+ token = l.lex();
+ if (l.tokenStartLine() == startLine)
+ return rv;
+
+ replaceWithSpace(script, startOffset, endOffset - startOffset);
+
+ Import import;
+ import.type = Import::Script;
+ import.uri = file;
+ import.qualifier = importId;
+ import.location = location;
+
+ rv.imports << import;
+ } else {
+ // URI
+ QString uri;
+ QString version;
+
+ while (true) {
+ if (!isUriToken(token))
+ return rv;
+
+ uri.append(l.tokenText());
+
+ token = l.lex();
+ CHECK_LINE;
+ if (token != QQmlJSGrammar::T_DOT)
+ break;
+
+ uri.append(QLatin1Char('.'));
+
+ token = l.lex();
+ CHECK_LINE;
+ }
+
+ CHECK_TOKEN(T_NUMERIC_LITERAL);
+ version = script.mid(l.tokenOffset(), l.tokenLength());
+
+ token = l.lex();
+
+ CHECK_TOKEN(T_AS);
+ CHECK_LINE;
+
+ token = l.lex();
+
+ CHECK_TOKEN(T_IDENTIFIER);
+ CHECK_LINE;
+
+ int endOffset = l.tokenLength() + l.tokenOffset();
+
+ QString importId = script.mid(l.tokenOffset(), l.tokenLength());
+
+ if (!importId.at(0).isUpper())
+ return rv;
+
+ QQmlScript::LocationSpan location =
+ locationFromLexer(l, startLine, startColumn, startOffset);
+
+ token = l.lex();
+ if (l.tokenStartLine() == startLine)
+ return rv;
+
+ replaceWithSpace(script, startOffset, endOffset - startOffset);
+
+ Import import;
+ import.type = Import::Library;
+ import.uri = uri;
+ import.version = version;
+ import.qualifier = importId;
+ import.location = location;
+
+ rv.imports << import;
+ }
+
+ } else if (token == QQmlJSGrammar::T_IDENTIFIER &&
+ script.mid(l.tokenOffset(), l.tokenLength()) == pragma) {
+
+ token = l.lex();
+
+ CHECK_TOKEN(T_IDENTIFIER);
+ CHECK_LINE;
+
+ QString pragmaValue = script.mid(l.tokenOffset(), l.tokenLength());
+ int endOffset = l.tokenLength() + l.tokenOffset();
+
+ if (pragmaValue == library) {
+ pragmas |= QQmlScript::Object::ScriptBlock::Shared;
+ replaceWithSpace(script, startOffset, endOffset - startOffset);
+ } else {
+ return rv;
+ }
+
+ token = l.lex();
+ if (l.tokenStartLine() == startLine)
+ return rv;
+
+ } else {
+ return rv;
+ }
+ }
+ return rv;
+}
+
+void QQmlScript::Parser::clear()
+{
+ _imports.clear();
+ qDeleteAll(_refTypes);
+ _refTypes.clear();
+ _errors.clear();
+
+ if (data) {
+ delete data;
+ data = 0;
+ }
+
+ _pool.clear();
+}
+
+QQmlScript::TypeReference *QQmlScript::Parser::findOrCreateType(const QString &name)
+{
+ TypeReference *type = 0;
+ int i = 0;
+ for (; i < _refTypes.size(); ++i) {
+ if (_refTypes.at(i)->name == name) {
+ type = _refTypes.at(i);
+ break;
+ }
+ }
+ if (!type) {
+ type = new TypeReference(i, name);
+ _refTypes.append(type);
+ }
+
+ return type;
+}
+
+void QQmlScript::Parser::setTree(QQmlScript::Object *tree)
+{
+ Q_ASSERT(! root);
+
+ root = tree;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlscript_p.h b/src/qml/qml/qqmlscript_p.h
new file mode 100644
index 0000000000..ddf4c9a392
--- /dev/null
+++ b/src/qml/qml/qqmlscript_p.h
@@ -0,0 +1,533 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QQMLSCRIPT_P_H
+#define QQMLSCRIPT_P_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 <QtQml/qqmlerror.h>
+
+#include <private/qfieldlist_p.h>
+#include <private/qhashfield_p.h>
+#include <private/qfastmetabuilder_p.h>
+#include <private/qqmlpool_p.h>
+#include <private/qqmlpropertycache_p.h>
+
+#include <QtCore/QList>
+#include <QtCore/QUrl>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QByteArray;
+class QQmlPropertyCache;
+namespace QQmlJS { namespace AST { class Node; class StringLiteral; } }
+namespace QQmlCompilerTypes { struct BindingReference; struct ComponentCompileState; }
+
+namespace QQmlScript {
+
+struct Location
+{
+ Location() : line(-1), column(-1) {}
+ int line;
+ int column;
+
+ inline bool operator<(const Location &other) {
+ return line < other.line ||
+ (line == other.line && column < other.column);
+ }
+};
+
+struct LocationRange
+{
+ LocationRange() : offset(0), length(0) {}
+ quint32 offset;
+ quint32 length;
+};
+
+struct LocationSpan
+{
+ Location start;
+ Location end;
+ LocationRange range;
+
+ bool operator<(LocationSpan &o) const {
+ return (start.line < o.start.line) ||
+ (start.line == o.start.line && start.column < o.start.column);
+ }
+};
+
+class Import
+{
+public:
+ Import() : type(Library) {}
+
+ enum Type { Library, File, Script };
+ Type type;
+
+ QString uri;
+ QString qualifier;
+ QString version;
+
+ void extractVersion(int *maj, int *min) const;
+
+ QQmlScript::LocationSpan location;
+};
+
+class Object;
+class TypeReference
+{
+public:
+ TypeReference(int typeId, const QString &typeName) : id(typeId), name(typeName) {}
+
+ int id;
+ // type as it has been referenced in Qml
+ QString name;
+ // objects in parse tree referencing the type
+ QList<QQmlScript::Object*> refObjects;
+};
+
+class Object;
+class Property;
+
+class Q_QML_EXPORT Variant
+{
+public:
+ enum Type {
+ Invalid,
+ Boolean,
+ Number,
+ String,
+ Script
+ };
+
+ Variant();
+ Variant(const Variant &);
+ explicit Variant(bool);
+ explicit Variant(double, const QStringRef &asWritten = QStringRef());
+ explicit Variant(QQmlJS::AST::StringLiteral *);
+ explicit Variant(const QStringRef &asWritten, QQmlJS::AST::Node *);
+ Variant &operator=(const Variant &);
+
+ Type type() const;
+
+ bool isBoolean() const { return type() == Boolean; }
+ bool isNumber() const { return type() == Number; }
+ bool isString() const { return type() == String; }
+ bool isScript() const { return type() == Script; }
+ bool isStringList() const;
+
+ bool asBoolean() const;
+ QString asString() const;
+ double asNumber() const;
+ QString asScript() const;
+ QQmlJS::AST::Node *asAST() const;
+ QStringList asStringList() const;
+
+private:
+ Type t;
+ union {
+ bool b;
+ double d;
+ QQmlJS::AST::StringLiteral *l;
+ QQmlJS::AST::Node *n;
+ };
+ QStringRef asWritten;
+};
+
+class Value : public QQmlPool::POD
+{
+public:
+ Value();
+
+ enum Type {
+ // The type of this value assignment is not yet known
+ Unknown,
+ // This is used as a literal property assignment
+ Literal,
+ // This is used as a property binding assignment
+ PropertyBinding,
+ // This is used as a QQmlPropertyValueSource assignment
+ ValueSource,
+ // This is used as a QQmlPropertyValueInterceptor assignment
+ ValueInterceptor,
+ // This is used as a property QObject assignment
+ CreatedObject,
+ // This is used as a signal object assignment
+ SignalObject,
+ // This is used as a signal expression assignment
+ SignalExpression,
+ // This is used as an id assignment only
+ Id
+ };
+ Type type;
+
+ // ### Temporary (for id only)
+ QString primitive() const { return value.isString() ? value.asString() : value.asScript(); }
+
+ // Primitive value
+ Variant value;
+ // Object value
+ Object *object;
+
+ LocationSpan location;
+
+ // Used by compiler
+ union {
+ QQmlCompilerTypes::BindingReference *bindingReference;
+ int signalExpressionContextStack;
+ };
+
+ // Used in Property::ValueList lists
+ Value *nextValue;
+};
+
+class Property : public QQmlPool::POD
+{
+public:
+ Property();
+
+ // The Object to which this property is attached
+ Object *parent;
+
+ Object *getValue(const LocationSpan &);
+ void addValue(Value *v);
+ void addOnValue(Value *v);
+
+ // The QVariant::Type of the property, or 0 (QVariant::Invalid) if
+ // unknown.
+ int type;
+ // The metaobject index of this property, or -1 if unknown.
+ int index;
+ // The core data in the case of a regular property.
+ // XXX This has to be a value now as the synthCache may change during
+ // compilation which invalidates pointers. We should fix this.
+ QQmlPropertyData core;
+
+ // Returns true if this is an empty property - both value and values
+ // are unset.
+ bool isEmpty() const;
+
+ typedef QFieldList<Value, &Value::nextValue> ValueList;
+ // The list of values assigned to this property. Content in values
+ // and value are mutually exclusive
+ ValueList values;
+ // The list of values assigned to this property using the "on" syntax
+ ValueList onValues;
+ // The accessed property. This is used to represent dot properties.
+ // Content in value and values are mutually exclusive.
+ Object *value;
+ // The property name
+ const QHashedStringRef &name() const { return _name; }
+ void setName(const QString &n) { _name = QHashedStringRef(pool()->NewString(n)); }
+ void setName(const QHashedStringRef &n) { _name = n; }
+ // True if this property was accessed as the default property.
+ bool isDefault;
+ // True if the setting of this property will be deferred. Set by the
+ // QQmlCompiler
+ bool isDeferred;
+ // True if this property is a value-type pseudo-property
+ bool isValueTypeSubProperty;
+ // True if this property is a property alias. Set by the
+ // QQmlCompiler
+ bool isAlias;
+ // True if this is a readonly property declaration
+ bool isReadOnlyDeclaration;
+
+ // Used for scriptStringProperties
+ int scriptStringScope;
+
+ LocationSpan location;
+ LocationRange listValueRange;
+
+ // Used in Object::MainPropertyList
+ Property *nextMainProperty;
+
+ // Used in Object::PropertyList lists
+ Property *nextProperty;
+
+private:
+ friend class Object;
+ QHashedStringRef _name;
+};
+
+class Object : public QQmlPool::Class
+{
+public:
+ Object();
+ virtual ~Object();
+
+ // Type of the object. The integer is an index into the
+ // QQmlCompiledData::types array, or -1 if the object is a property
+ // group.
+ int type;
+
+ // The fully-qualified name of this type
+ QString typeName;
+ // The id assigned to the object (if any). Set by the QQmlCompiler
+ QString id;
+ // The id index assigned to the object (if any). Set by the QQmlCompiler
+ int idIndex;
+ // Custom parsed data
+ QByteArray custom;
+ // Bit mask of the properties assigned bindings
+ QByteArray bindingBitmask;
+ void setBindingBit(int);
+ // Returns the metaobject for this type, or 0 if not available.
+ // Internally selectd between the metatype and extObject variables
+ const QMetaObject *metaObject() const;
+
+ // The compile time metaobject for this type
+ const QMetaObject *metatype;
+ // The synthesized metaobject, if QML added signals or properties to
+ // this type. Otherwise null
+ QAbstractDynamicMetaObject extObject;
+ QByteArray metadata; // Generated by compiler
+ QByteArray synthdata; // Generated by compiler
+ QQmlPropertyCache *synthCache; // Generated by compiler
+
+ Property *getDefaultProperty();
+ // name ptr must be guarenteed to remain valid
+ Property *getProperty(const QHashedStringRef &name, bool create=true);
+ Property *getProperty(const QStringRef &name, bool create=true);
+ Property *getProperty(const QString &name, bool create=true);
+
+ Property *defaultProperty;
+
+ typedef QFieldList<Property, &Property::nextMainProperty> MainPropertyList;
+ MainPropertyList properties;
+ QHashField propertiesHashField;
+
+ // Output of the compilation phase (these properties continue to exist
+ // in either the defaultProperty or properties members too)
+ void addValueProperty(Property *);
+ void addSignalProperty(Property *);
+ void addAttachedProperty(Property *);
+ void addGroupedProperty(Property *);
+ void addValueTypeProperty(Property *);
+ void addScriptStringProperty(Property *);
+
+ typedef QFieldList<Property, &Property::nextProperty> PropertyList;
+ PropertyList valueProperties;
+ PropertyList signalProperties;
+ PropertyList attachedProperties;
+ PropertyList groupedProperties;
+ PropertyList valueTypeProperties;
+ PropertyList scriptStringProperties;
+
+ // Script blocks that were nested under this object
+ struct ScriptBlock {
+ enum Pragma {
+ None = 0x00000000,
+ Shared = 0x00000001
+ };
+ Q_DECLARE_FLAGS(Pragmas, Pragma)
+
+ QString code;
+ QString file;
+ Pragmas pragmas;
+ };
+
+ // The bytes to cast instances by to get to the QQmlParserStatus
+ // interface. -1 indicates the type doesn't support this interface.
+ // Set by the QQmlCompiler.
+ int parserStatusCast;
+
+ LocationSpan location;
+
+ struct DynamicProperty : public QQmlPool::POD
+ {
+ DynamicProperty();
+
+ enum Type { Var, Variant, Int, Bool, Real, String, Url, Color,
+ Time, Date, DateTime, Alias, Custom, CustomList };
+
+ quint32 isDefaultProperty:1;
+ quint32 isReadOnly:1;
+
+ Type type;
+
+ QHashedStringRef customType;
+ QHashedStringRef name;
+ QQmlScript::Property *defaultValue;
+ LocationSpan location;
+ Location nameLocation;
+
+ // Used by Object::DynamicPropertyList
+ DynamicProperty *nextProperty;
+
+ // Used by the compiler
+ QByteArray *resolvedCustomTypeName;
+ QFastMetaBuilder::StringRef typeRef;
+ QFastMetaBuilder::StringRef nameRef;
+ QFastMetaBuilder::StringRef changedSignatureRef;
+ };
+
+ struct DynamicSignal : public QQmlPool::POD
+ {
+ DynamicSignal();
+
+ QHashedStringRef name;
+ QQmlPool::List<QHashedCStringRef> parameterTypes;
+ QQmlPool::List<QHashedStringRef> parameterNames;
+
+ int parameterTypesLength() const;
+ int parameterNamesLength() const;
+
+ // Used by Object::DynamicSignalList
+ DynamicSignal *nextSignal;
+
+ // Used by the compiler
+ QFastMetaBuilder::StringRef signatureRef;
+ QFastMetaBuilder::StringRef parameterNamesRef;
+ LocationSpan location;
+ };
+
+ struct DynamicSlot : public QQmlPool::Class
+ {
+ DynamicSlot();
+
+ QHashedStringRef name;
+ QString body;
+ QList<QByteArray> parameterNames;
+ LocationSpan location;
+
+ int parameterNamesLength() const;
+
+ // Used by Object::DynamicSlotList
+ DynamicSlot *nextSlot;
+
+ // Used by the compiler
+ QFastMetaBuilder::StringRef signatureRef;
+ QFastMetaBuilder::StringRef parameterNamesRef;
+ };
+
+ // The list of dynamic properties
+ typedef QFieldList<DynamicProperty, &DynamicProperty::nextProperty> DynamicPropertyList;
+ DynamicPropertyList dynamicProperties;
+ // The list of dynamic signals
+ typedef QFieldList<DynamicSignal, &DynamicSignal::nextSignal> DynamicSignalList;
+ DynamicSignalList dynamicSignals;
+ // The list of dynamic slots
+ typedef QFieldList<DynamicSlot, &DynamicSlot::nextSlot> DynamicSlotList;
+ DynamicSlotList dynamicSlots;
+
+ // Used by compiler
+ QQmlCompilerTypes::ComponentCompileState *componentCompileState;
+
+ // Used by ComponentCompileState::AliasingObjectsList
+ Object *nextAliasingObject;
+ // Used by ComponentComppileState::IdList
+ Object *nextIdObject;
+};
+
+class ParserJsASTData;
+class Q_AUTOTEST_EXPORT Parser
+{
+public:
+ Parser();
+ ~Parser();
+
+ bool parse(const QByteArray &data, const QUrl &url = QUrl(),
+ const QString &urlString = QString());
+
+ QList<TypeReference*> referencedTypes() const;
+
+ QQmlScript::Object *tree() const;
+ QList<Import> imports() const;
+
+ void clear();
+
+ QList<QQmlError> errors() const;
+
+ class JavaScriptMetaData {
+ public:
+ JavaScriptMetaData()
+ : pragmas(QQmlScript::Object::ScriptBlock::None) {}
+
+ QQmlScript::Object::ScriptBlock::Pragmas pragmas;
+ QList<Import> imports;
+ };
+
+ static QQmlScript::Object::ScriptBlock::Pragmas extractPragmas(QString &);
+ static JavaScriptMetaData extractMetaData(QString &);
+
+
+// ### private:
+ TypeReference *findOrCreateType(const QString &name);
+ void setTree(QQmlScript::Object *tree);
+
+ void setScriptFile(const QString &filename) {_scriptFile = filename; }
+ QString scriptFile() const { return _scriptFile; }
+
+// ### private:
+ QList<QQmlError> _errors;
+
+ QQmlPool _pool;
+ QQmlScript::Object *root;
+ QList<Import> _imports;
+ QList<TypeReference*> _refTypes;
+ QString _scriptFile;
+ ParserJsASTData *data;
+};
+
+}
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlScript::Object::ScriptBlock::Pragmas);
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlScript::Variant)
+
+QT_END_HEADER
+
+#endif // QQMLSCRIPT_P_H
diff --git a/src/qml/qml/qqmlscriptstring.cpp b/src/qml/qml/qqmlscriptstring.cpp
new file mode 100644
index 0000000000..ed7a6affa1
--- /dev/null
+++ b/src/qml/qml/qqmlscriptstring.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlscriptstring.h"
+#include "qqmlscriptstring_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+\class QQmlScriptString
+\since 4.7
+\brief The QQmlScriptString class encapsulates a script and its context.
+
+QQmlScriptString is used to create QObject properties that accept a script "assignment" from QML.
+
+Normally, the following QML would result in a binding being established for the \c script
+property; i.e. \c script would be assigned the value obtained from running \c {myObj.value = Math.max(myValue, 100)}
+
+\qml
+MyType {
+ script: myObj.value = Math.max(myValue, 100)
+}
+\endqml
+
+If instead the property had a type of QQmlScriptString,
+the script itself -- \e {myObj.value = Math.max(myValue, 100)} -- would be passed to the \c script property
+and the class could choose how to handle it. Typically, the class will evaluate
+the script at some later time using a QQmlExpression.
+
+\code
+QQmlExpression expr(scriptString);
+expr.evaluate();
+\endcode
+
+\sa QQmlExpression
+*/
+
+/*!
+Constructs an empty instance.
+*/
+QQmlScriptString::QQmlScriptString()
+: d(new QQmlScriptStringPrivate)
+{
+}
+
+/*!
+Copies \a other.
+*/
+QQmlScriptString::QQmlScriptString(const QQmlScriptString &other)
+: d(other.d)
+{
+}
+
+/*!
+\internal
+*/
+QQmlScriptString::~QQmlScriptString()
+{
+}
+
+/*!
+Assigns \a other to this.
+*/
+QQmlScriptString &QQmlScriptString::operator=(const QQmlScriptString &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+Returns the context for the script.
+*/
+QQmlContext *QQmlScriptString::context() const
+{
+ return d->context;
+}
+
+/*!
+Sets the \a context for the script.
+*/
+void QQmlScriptString::setContext(QQmlContext *context)
+{
+ d->context = context;
+}
+
+/*!
+Returns the scope object for the script.
+*/
+QObject *QQmlScriptString::scopeObject() const
+{
+ return d->scope;
+}
+
+/*!
+Sets the scope \a object for the script.
+*/
+void QQmlScriptString::setScopeObject(QObject *object)
+{
+ d->scope = object;
+}
+
+/*!
+Returns the script text.
+*/
+QString QQmlScriptString::script() const
+{
+ return d->script;
+}
+
+/*!
+Sets the \a script text.
+*/
+void QQmlScriptString::setScript(const QString &script)
+{
+ d->script = script;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/qqmlscriptstring.h b/src/qml/qml/qqmlscriptstring.h
new file mode 100644
index 0000000000..15db9088f7
--- /dev/null
+++ b/src/qml/qml/qqmlscriptstring.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLSCRIPTSTRING_H
+#define QQMLSCRIPTSTRING_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qshareddata.h>
+#include <QtCore/qmetatype.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QObject;
+class QQmlContext;
+class QQmlScriptStringPrivate;
+class Q_QML_EXPORT QQmlScriptString
+{
+public:
+ QQmlScriptString();
+ QQmlScriptString(const QQmlScriptString &);
+ ~QQmlScriptString();
+
+ QQmlScriptString &operator=(const QQmlScriptString &);
+
+ QQmlContext *context() const;
+ void setContext(QQmlContext *);
+
+ QObject *scopeObject() const;
+ void setScopeObject(QObject *);
+
+ QString script() const;
+ void setScript(const QString &);
+
+private:
+ QSharedDataPointer<QQmlScriptStringPrivate> d;
+
+ friend class QQmlVME;
+ friend class QQmlExpression;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlScriptString)
+
+QT_END_HEADER
+
+#endif // QQMLSCRIPTSTRING_H
+
diff --git a/src/qml/qml/qqmlscriptstring_p.h b/src/qml/qml/qqmlscriptstring_p.h
new file mode 100644
index 0000000000..15786c7aae
--- /dev/null
+++ b/src/qml/qml/qqmlscriptstring_p.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLSCRIPTSTRING_P_H
+#define QQMLSCRIPTSTRING_P_H
+
+#include <QtQml/qqmlcontext.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlScriptStringPrivate : public QSharedData
+{
+public:
+ QQmlScriptStringPrivate() : context(0), scope(0), bindingId(-1), lineNumber(-1), columnNumber(-1) {}
+
+ QQmlContext *context;
+ QObject *scope;
+ QString script;
+ int bindingId;
+ int lineNumber;
+ int columnNumber;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLSCRIPTSTRING_P_H
diff --git a/src/qml/qml/qqmlstringconverters.cpp b/src/qml/qml/qqmlstringconverters.cpp
new file mode 100644
index 0000000000..2c7f6c9f6e
--- /dev/null
+++ b/src/qml/qml/qqmlstringconverters.cpp
@@ -0,0 +1,311 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlstringconverters_p.h"
+
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qdatetime.h>
+
+QT_BEGIN_NAMESPACE
+
+static uchar fromHex(const uchar c, const uchar c2)
+{
+ uchar rv = 0;
+ if (c >= '0' && c <= '9')
+ rv += (c - '0') * 16;
+ else if (c >= 'A' && c <= 'F')
+ rv += (c - 'A' + 10) * 16;
+ else if (c >= 'a' && c <= 'f')
+ rv += (c - 'a' + 10) * 16;
+
+ if (c2 >= '0' && c2 <= '9')
+ rv += (c2 - '0');
+ else if (c2 >= 'A' && c2 <= 'F')
+ rv += (c2 - 'A' + 10);
+ else if (c2 >= 'a' && c2 <= 'f')
+ rv += (c2 - 'a' + 10);
+
+ return rv;
+}
+
+static uchar fromHex(const QString &s, int idx)
+{
+ uchar c = s.at(idx).toAscii();
+ uchar c2 = s.at(idx + 1).toAscii();
+ return fromHex(c, c2);
+}
+
+QVariant QQmlStringConverters::variantFromString(const QString &s)
+{
+ if (s.isEmpty())
+ return QVariant(s);
+ bool ok = false;
+ QRectF r = rectFFromString(s, &ok);
+ if (ok) return QVariant(r);
+ QColor c = colorFromString(s, &ok);
+ if (ok) return QVariant(c);
+ QPointF p = pointFFromString(s, &ok);
+ if (ok) return QVariant(p);
+ QSizeF sz = sizeFFromString(s, &ok);
+ if (ok) return QVariant(sz);
+ QVector3D v = vector3DFromString(s, &ok);
+ if (ok) return QVariant::fromValue(v);
+ QVector4D v4 = vector4DFromString(s, &ok);
+ if (ok) return QVariant::fromValue(v4);
+
+ return QVariant(s);
+}
+
+QVariant QQmlStringConverters::variantFromString(const QString &s, int preferredType, bool *ok)
+{
+ switch (preferredType) {
+ case QMetaType::Int:
+ return QVariant(int(qRound(s.toDouble(ok))));
+ case QMetaType::UInt:
+ return QVariant(uint(qRound(s.toDouble(ok))));
+ case QMetaType::QColor:
+ return QVariant::fromValue(colorFromString(s, ok));
+#ifndef QT_NO_DATESTRING
+ case QMetaType::QDate:
+ return QVariant::fromValue(dateFromString(s, ok));
+ case QMetaType::QTime:
+ return QVariant::fromValue(timeFromString(s, ok));
+ case QMetaType::QDateTime:
+ return QVariant::fromValue(dateTimeFromString(s, ok));
+#endif // QT_NO_DATESTRING
+ case QMetaType::QPointF:
+ return QVariant::fromValue(pointFFromString(s, ok));
+ case QMetaType::QPoint:
+ return QVariant::fromValue(pointFFromString(s, ok).toPoint());
+ case QMetaType::QSizeF:
+ return QVariant::fromValue(sizeFFromString(s, ok));
+ case QMetaType::QSize:
+ return QVariant::fromValue(sizeFFromString(s, ok).toSize());
+ case QMetaType::QRectF:
+ return QVariant::fromValue(rectFFromString(s, ok));
+ case QMetaType::QRect:
+ return QVariant::fromValue(rectFFromString(s, ok).toRect());
+ case QMetaType::QVector3D:
+ return QVariant::fromValue(vector3DFromString(s, ok));
+ case QMetaType::QVector4D:
+ return QVariant::fromValue(vector4DFromString(s, ok));
+ default:
+ if (ok) *ok = false;
+ return QVariant();
+ }
+}
+
+QColor QQmlStringConverters::colorFromString(const QString &s, bool *ok)
+{
+ if (s.length() == 9 && s.startsWith(QLatin1Char('#'))) {
+ uchar a = fromHex(s, 1);
+ uchar r = fromHex(s, 3);
+ uchar g = fromHex(s, 5);
+ uchar b = fromHex(s, 7);
+ if (ok) *ok = true;
+ return QColor(r, g, b, a);
+ } else {
+ QColor rv(s);
+ if (ok) *ok = rv.isValid();
+ return rv;
+ }
+}
+
+#ifndef QT_NO_DATESTRING
+QDate QQmlStringConverters::dateFromString(const QString &s, bool *ok)
+{
+ QDate d = QDate::fromString(s, Qt::ISODate);
+ if (ok) *ok = d.isValid();
+ return d;
+}
+
+QTime QQmlStringConverters::timeFromString(const QString &s, bool *ok)
+{
+ QTime t = QTime::fromString(s, Qt::ISODate);
+ if (ok) *ok = t.isValid();
+ return t;
+}
+
+QDateTime QQmlStringConverters::dateTimeFromString(const QString &s, bool *ok)
+{
+ QDateTime d = QDateTime::fromString(s, Qt::ISODate);
+ if (ok) *ok = d.isValid();
+ return d;
+}
+#endif // QT_NO_DATESTRING
+
+//expects input of "x,y"
+QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char(',')) != 1) {
+ if (ok)
+ *ok = false;
+ return QPointF();
+ }
+
+ bool xGood, yGood;
+ int index = s.indexOf(QLatin1Char(','));
+ qreal xCoord = s.left(index).toDouble(&xGood);
+ qreal yCoord = s.mid(index+1).toDouble(&yGood);
+ if (!xGood || !yGood) {
+ if (ok)
+ *ok = false;
+ return QPointF();
+ }
+
+ if (ok)
+ *ok = true;
+ return QPointF(xCoord, yCoord);
+}
+
+//expects input of "widthxheight"
+QSizeF QQmlStringConverters::sizeFFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char('x')) != 1) {
+ if (ok)
+ *ok = false;
+ return QSizeF();
+ }
+
+ bool wGood, hGood;
+ int index = s.indexOf(QLatin1Char('x'));
+ qreal width = s.left(index).toDouble(&wGood);
+ qreal height = s.mid(index+1).toDouble(&hGood);
+ if (!wGood || !hGood) {
+ if (ok)
+ *ok = false;
+ return QSizeF();
+ }
+
+ if (ok)
+ *ok = true;
+ return QSizeF(width, height);
+}
+
+//expects input of "x,y,widthxheight" //### use space instead of second comma?
+QRectF QQmlStringConverters::rectFFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char(',')) != 2 || s.count(QLatin1Char('x')) != 1) {
+ if (ok)
+ *ok = false;
+ return QRectF();
+ }
+
+ bool xGood, yGood, wGood, hGood;
+ int index = s.indexOf(QLatin1Char(','));
+ qreal x = s.left(index).toDouble(&xGood);
+ int index2 = s.indexOf(QLatin1Char(','), index+1);
+ qreal y = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ index = s.indexOf(QLatin1Char('x'), index2+1);
+ qreal width = s.mid(index2+1, index-index2-1).toDouble(&wGood);
+ qreal height = s.mid(index+1).toDouble(&hGood);
+ if (!xGood || !yGood || !wGood || !hGood) {
+ if (ok)
+ *ok = false;
+ return QRectF();
+ }
+
+ if (ok)
+ *ok = true;
+ return QRectF(x, y, width, height);
+}
+
+//expects input of "x,y,z"
+QVector3D QQmlStringConverters::vector3DFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char(',')) != 2) {
+ if (ok)
+ *ok = false;
+ return QVector3D();
+ }
+
+ bool xGood, yGood, zGood;
+ int index = s.indexOf(QLatin1Char(','));
+ int index2 = s.indexOf(QLatin1Char(','), index+1);
+ qreal xCoord = s.left(index).toDouble(&xGood);
+ qreal yCoord = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ qreal zCoord = s.mid(index2+1).toDouble(&zGood);
+ if (!xGood || !yGood || !zGood) {
+ if (ok)
+ *ok = false;
+ return QVector3D();
+ }
+
+ if (ok)
+ *ok = true;
+ return QVector3D(xCoord, yCoord, zCoord);
+}
+
+//expects input of "x,y,z,w"
+QVector4D QQmlStringConverters::vector4DFromString(const QString &s, bool *ok)
+{
+ if (s.count(QLatin1Char(',')) != 3) {
+ if (ok)
+ *ok = false;
+ return QVector4D();
+ }
+
+ bool xGood, yGood, zGood, wGood;
+ int index = s.indexOf(QLatin1Char(','));
+ int index2 = s.indexOf(QLatin1Char(','), index+1);
+ int index3 = s.indexOf(QLatin1Char(','), index2+1);
+ qreal xCoord = s.left(index).toDouble(&xGood);
+ qreal yCoord = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ qreal zCoord = s.mid(index2+1, index3-index2-1).toDouble(&zGood);
+ qreal wCoord = s.mid(index3+1).toDouble(&wGood);
+ if (!xGood || !yGood || !zGood || !wGood) {
+ if (ok)
+ *ok = false;
+ return QVector4D();
+ }
+
+ if (ok)
+ *ok = true;
+ return QVector4D(xCoord, yCoord, zCoord, wCoord);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlstringconverters_p.h b/src/qml/qml/qqmlstringconverters_p.h
new file mode 100644
index 0000000000..8f6fb2485d
--- /dev/null
+++ b/src/qml/qml/qqmlstringconverters_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLSTRINGCONVERTERS_P_H
+#define QQMLSTRINGCONVERTERS_P_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>
+
+#include <private/qtqmlglobal_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QColor;
+class QPointF;
+class QSizeF;
+class QRectF;
+class QString;
+class QByteArray;
+class QVector3D;
+class QVector4D;
+
+// XXX - Bauhaus currently uses these methods which is why they're exported
+namespace QQmlStringConverters
+{
+ QVariant Q_QML_PRIVATE_EXPORT variantFromString(const QString &);
+ QVariant Q_QML_PRIVATE_EXPORT variantFromString(const QString &, int preferredType, bool *ok = 0);
+
+ QColor Q_QML_PRIVATE_EXPORT colorFromString(const QString &, bool *ok = 0);
+#ifndef QT_NO_DATESTRING
+ QDate Q_QML_PRIVATE_EXPORT dateFromString(const QString &, bool *ok = 0);
+ QTime Q_QML_PRIVATE_EXPORT timeFromString(const QString &, bool *ok = 0);
+ QDateTime Q_QML_PRIVATE_EXPORT dateTimeFromString(const QString &, bool *ok = 0);
+#endif
+ QPointF Q_QML_PRIVATE_EXPORT pointFFromString(const QString &, bool *ok = 0);
+ QSizeF Q_QML_PRIVATE_EXPORT sizeFFromString(const QString &, bool *ok = 0);
+ QRectF Q_QML_PRIVATE_EXPORT rectFFromString(const QString &, bool *ok = 0);
+ QVector3D Q_QML_PRIVATE_EXPORT vector3DFromString(const QString &, bool *ok = 0);
+ QVector4D Q_QML_PRIVATE_EXPORT vector4DFromString(const QString &, bool *ok = 0);
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLSTRINGCONVERTERS_P_H
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
new file mode 100644
index 0000000000..5cbb2f6943
--- /dev/null
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -0,0 +1,1926 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmltypeloader_p.h"
+
+#include <private/qqmlengine_p.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlthread_p.h>
+#include <private/qqmlcompiler_p.h>
+#include <private/qqmlcomponent_p.h>
+#include <private/qqmlprofilerservice_p.h>
+
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qdiriterator.h>
+#include <QtCore/qwaitcondition.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlextensioninterface.h>
+
+#if defined (Q_OS_UNIX)
+#include <sys/types.h>
+#include <dirent.h>
+#endif
+
+// #define DATABLOB_DEBUG
+
+#ifdef DATABLOB_DEBUG
+
+#define ASSERT_MAINTHREAD() do { if(m_thread->isThisThread()) qFatal("QQmlDataLoader: Caller not in main thread"); } while(false)
+#define ASSERT_LOADTHREAD() do { if(!m_thread->isThisThread()) qFatal("QQmlDataLoader: Caller not in load thread"); } while(false)
+#define ASSERT_CALLBACK() do { if(!m_manager || !m_manager->m_thread->isThisThread()) qFatal("QQmlDataBlob: An API call was made outside a callback"); } while(false)
+
+#else
+
+#define ASSERT_MAINTHREAD()
+#define ASSERT_LOADTHREAD()
+#define ASSERT_CALLBACK()
+
+#endif
+
+QT_BEGIN_NAMESPACE
+
+// This is a lame object that we need to ensure that slots connected to
+// QNetworkReply get called in the correct thread (the loader thread).
+// As QQmlDataLoader lives in the main thread, and we can't use
+// Qt::DirectConnection connections from a QNetworkReply (because then
+// sender() wont work), we need to insert this object in the middle.
+class QQmlDataLoaderNetworkReplyProxy : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlDataLoaderNetworkReplyProxy(QQmlDataLoader *l);
+
+public slots:
+ void finished();
+ void downloadProgress(qint64, qint64);
+
+private:
+ QQmlDataLoader *l;
+};
+
+class QQmlDataLoaderThread : public QQmlThread
+{
+ typedef QQmlDataLoaderThread This;
+
+public:
+ QQmlDataLoaderThread(QQmlDataLoader *loader);
+ QNetworkAccessManager *networkAccessManager() const;
+ QQmlDataLoaderNetworkReplyProxy *networkReplyProxy() const;
+
+ void load(QQmlDataBlob *b);
+ void loadAsync(QQmlDataBlob *b);
+ void loadWithStaticData(QQmlDataBlob *b, const QByteArray &);
+ void loadWithStaticDataAsync(QQmlDataBlob *b, const QByteArray &);
+ void callCompleted(QQmlDataBlob *b);
+ void callDownloadProgressChanged(QQmlDataBlob *b, qreal p);
+ void initializeEngine(QQmlExtensionInterface *, const char *);
+
+protected:
+ virtual void shutdownThread();
+
+private:
+ void loadThread(QQmlDataBlob *b);
+ void loadWithStaticDataThread(QQmlDataBlob *b, const QByteArray &);
+ void callCompletedMain(QQmlDataBlob *b);
+ void callDownloadProgressChangedMain(QQmlDataBlob *b, qreal p);
+ void initializeEngineMain(QQmlExtensionInterface *iface, const char *uri);
+
+ QQmlDataLoader *m_loader;
+ mutable QNetworkAccessManager *m_networkAccessManager;
+ mutable QQmlDataLoaderNetworkReplyProxy *m_networkReplyProxy;
+};
+
+
+QQmlDataLoaderNetworkReplyProxy::QQmlDataLoaderNetworkReplyProxy(QQmlDataLoader *l)
+: l(l)
+{
+}
+
+void QQmlDataLoaderNetworkReplyProxy::finished()
+{
+ Q_ASSERT(sender());
+ Q_ASSERT(qobject_cast<QNetworkReply *>(sender()));
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+ l->networkReplyFinished(reply);
+}
+
+void QQmlDataLoaderNetworkReplyProxy::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
+{
+ Q_ASSERT(sender());
+ Q_ASSERT(qobject_cast<QNetworkReply *>(sender()));
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+ l->networkReplyProgress(reply, bytesReceived, bytesTotal);
+}
+
+/*
+Returns the set of QML files in path (qmldir, *.qml, *.js). The caller
+is responsible for deleting the returned data.
+Returns 0 if the directory does not exist.
+*/
+#if defined (Q_OS_UNIX) && !defined(Q_OS_DARWIN)
+static QStringHash<bool> *qmlFilesInDirectory(const QString &path)
+{
+ QByteArray name(QFile::encodeName(path));
+ DIR *dd = opendir(name);
+ if (!dd)
+ return 0;
+
+ struct dirent *result;
+ union {
+ struct dirent d;
+ char b[offsetof (struct dirent, d_name) + NAME_MAX + 1];
+ } u;
+
+ QStringHash<bool> *files = new QStringHash<bool>;
+ while (readdir_r(dd, &u.d, &result) == 0 && result != 0) {
+ if (!strcmp(u.d.d_name, "qmldir")) {
+ files->insert(QLatin1String("qmldir"), true);
+ continue;
+ }
+ int len = strlen(u.d.d_name);
+ if (len < 4)
+ continue;
+ if (!strcmp(u.d.d_name+len-4, ".qml") || !strcmp(u.d.d_name+len-3, ".js"))
+ files->insert(QFile::decodeName(u.d.d_name), true);
+#if defined(Q_OS_DARWIN)
+ else if ((len > 6 && !strcmp(u.d.d_name+len-6, ".dylib")) || !strcmp(u.d.d_name+len-3, ".so")
+ || (len > 7 && !strcmp(u.d.d_name+len-7, ".bundle")))
+ files->insert(QFile::decodeName(u.d.d_name), true);
+#else // Unix
+ else if (!strcmp(u.d.d_name+len-3, ".so") || !strcmp(u.d.d_name+len-3, ".sl"))
+ files->insert(QFile::decodeName(u.d.d_name), true);
+#endif
+ }
+
+ closedir(dd);
+ return files;
+}
+#else
+static QStringHash<bool> *qmlFilesInDirectory(const QString &path)
+{
+ QDirIterator dir(path, QDir::Files);
+ if (!dir.hasNext())
+ return 0;
+ QStringHash<bool> *files = new QStringHash<bool>;
+ while (dir.hasNext()) {
+ dir.next();
+ QString fileName = dir.fileName();
+ if (fileName == QLatin1String("qmldir")
+ || fileName.endsWith(QLatin1String(".qml"))
+ || fileName.endsWith(QLatin1String(".js"))
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+ || fileName.endsWith(QLatin1String(".dll"))
+#elif defined(Q_OS_DARWIN)
+ || fileName.endsWith(QLatin1String(".dylib"))
+ || fileName.endsWith(QLatin1String(".so"))
+ || fileName.endsWith(QLatin1String(".bundle"))
+#else // Unix
+ || fileName.endsWith(QLatin1String(".so"))
+ || fileName.endsWith(QLatin1String(".sl"))
+#endif
+ ) {
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
+ fileName = fileName.toLower();
+#endif
+ files->insert(fileName, true);
+ }
+ }
+ return files;
+}
+#endif
+
+
+/*!
+\class QQmlDataBlob
+\brief The QQmlDataBlob encapsulates a data request that can be issued to a QQmlDataLoader.
+\internal
+
+QQmlDataBlob's are loaded by a QQmlDataLoader. The user creates the QQmlDataBlob
+and then calls QQmlDataLoader::load() or QQmlDataLoader::loadWithStaticData() to load it.
+The QQmlDataLoader invokes callbacks on the QQmlDataBlob as data becomes available.
+*/
+
+/*!
+\enum QQmlDataBlob::Status
+
+This enum describes the status of the data blob.
+
+\list
+\o Null The blob has not yet been loaded by a QQmlDataLoader
+\o Loading The blob is loading network data. The QQmlDataBlob::setData() callback has not yet been
+invoked or has not yet returned.
+\o WaitingForDependencies The blob is waiting for dependencies to be done before continueing. This status
+only occurs after the QQmlDataBlob::setData() callback has been made, and when the blob has outstanding
+dependencies.
+\o Complete The blob's data has been loaded and all dependencies are done.
+\o Error An error has been set on this blob.
+\endlist
+*/
+
+/*!
+\enum QQmlDataBlob::Type
+
+This enum describes the type of the data blob.
+
+\list
+\o QmlFile This is a QQmlTypeData
+\o JavaScriptFile This is a QQmlScriptData
+\o QmldirFile This is a QQmlQmldirData
+\endlist
+*/
+
+/*!
+Create a new QQmlDataBlob for \a url and of the provided \a type.
+*/
+QQmlDataBlob::QQmlDataBlob(const QUrl &url, Type type)
+: m_type(type), m_url(url), m_finalUrl(url), m_manager(0), m_redirectCount(0),
+ m_inCallback(false), m_isDone(false)
+{
+}
+
+/*! \internal */
+QQmlDataBlob::~QQmlDataBlob()
+{
+ Q_ASSERT(m_waitingOnMe.isEmpty());
+
+ cancelAllWaitingFor();
+}
+
+/*!
+Returns the type provided to the constructor.
+*/
+QQmlDataBlob::Type QQmlDataBlob::type() const
+{
+ return m_type;
+}
+
+/*!
+Returns the blob's status.
+*/
+QQmlDataBlob::Status QQmlDataBlob::status() const
+{
+ return m_data.status();
+}
+
+/*!
+Returns true if the status is Null.
+*/
+bool QQmlDataBlob::isNull() const
+{
+ return status() == Null;
+}
+
+/*!
+Returns true if the status is Loading.
+*/
+bool QQmlDataBlob::isLoading() const
+{
+ return status() == Loading;
+}
+
+/*!
+Returns true if the status is WaitingForDependencies.
+*/
+bool QQmlDataBlob::isWaiting() const
+{
+ return status() == WaitingForDependencies;
+}
+
+/*!
+Returns true if the status is Complete.
+*/
+bool QQmlDataBlob::isComplete() const
+{
+ return status() == Complete;
+}
+
+/*!
+Returns true if the status is Error.
+*/
+bool QQmlDataBlob::isError() const
+{
+ return status() == Error;
+}
+
+/*!
+Returns true if the status is Complete or Error.
+*/
+bool QQmlDataBlob::isCompleteOrError() const
+{
+ Status s = status();
+ return s == Error || s == Complete;
+}
+
+/*!
+Returns the data download progress from 0 to 1.
+*/
+qreal QQmlDataBlob::progress() const
+{
+ quint8 p = m_data.progress();
+ if (p == 0xFF) return 1.;
+ else return qreal(p) / qreal(0xFF);
+}
+
+/*!
+Returns the blob url passed to the constructor. If a network redirect
+happens while fetching the data, this url remains the same.
+
+\sa finalUrl()
+*/
+QUrl QQmlDataBlob::url() const
+{
+ return m_url;
+}
+
+/*!
+Returns the final url of the data. Initially this is the same as
+url(), but if a network redirect happens while fetching the data, this url
+is updated to reflect the new location.
+
+May only be called from the load thread, or after the blob isCompleteOrError().
+*/
+QUrl QQmlDataBlob::finalUrl() const
+{
+ Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread()));
+ return m_finalUrl;
+}
+
+/*!
+Returns the finalUrl() as a string.
+*/
+QString QQmlDataBlob::finalUrlString() const
+{
+ Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread()));
+ if (m_finalUrlString.isEmpty())
+ m_finalUrlString = m_finalUrl.toString();
+
+ return m_finalUrlString;
+}
+
+/*!
+Return the errors on this blob.
+
+May only be called from the load thread, or after the blob isCompleteOrError().
+*/
+QList<QQmlError> QQmlDataBlob::errors() const
+{
+ Q_ASSERT(isCompleteOrError() || (m_manager && m_manager->m_thread->isThisThread()));
+ return m_errors;
+}
+
+/*!
+Mark this blob as having \a errors.
+
+All outstanding dependencies will be cancelled. Requests to add new dependencies
+will be ignored. Entry into the Error state is irreversable.
+
+The setError() method may only be called from within a QQmlDataBlob callback.
+*/
+void QQmlDataBlob::setError(const QQmlError &errors)
+{
+ ASSERT_CALLBACK();
+
+ QList<QQmlError> l;
+ l << errors;
+ setError(l);
+}
+
+/*!
+\overload
+*/
+void QQmlDataBlob::setError(const QList<QQmlError> &errors)
+{
+ ASSERT_CALLBACK();
+
+ Q_ASSERT(status() != Error);
+ Q_ASSERT(m_errors.isEmpty());
+
+ m_errors = errors; // Must be set before the m_data fence
+ m_data.setStatus(Error);
+
+ cancelAllWaitingFor();
+
+ if (!m_inCallback)
+ tryDone();
+}
+
+/*!
+Wait for \a blob to become complete or to error. If \a blob is already
+complete or in error, or this blob is already complete, this has no effect.
+
+The setError() method may only be called from within a QQmlDataBlob callback.
+*/
+void QQmlDataBlob::addDependency(QQmlDataBlob *blob)
+{
+ ASSERT_CALLBACK();
+
+ Q_ASSERT(status() != Null);
+
+ if (!blob ||
+ blob->status() == Error || blob->status() == Complete ||
+ status() == Error || status() == Complete || m_isDone ||
+ m_waitingFor.contains(blob))
+ return;
+
+ blob->addref();
+
+ m_data.setStatus(WaitingForDependencies);
+
+ m_waitingFor.append(blob);
+ blob->m_waitingOnMe.append(this);
+}
+
+/*!
+\fn void QQmlDataBlob::dataReceived(const QByteArray &data)
+
+Invoked when data for the blob is received. Implementors should use this callback
+to determine a blob's dependencies. Within this callback you may call setError()
+or addDependency().
+*/
+
+/*!
+Invoked once data has either been received or a network error occurred, and all
+dependencies are complete.
+
+You can set an error in this method, but you cannot add new dependencies. Implementors
+should use this callback to finalize processing of data.
+
+The default implementation does nothing.
+
+XXX Rename processData() or some such to avoid confusion between done() (processing thread)
+and completed() (main thread)
+*/
+void QQmlDataBlob::done()
+{
+}
+
+/*!
+Invoked if there is a network error while fetching this blob.
+
+The default implementation sets an appropriate QQmlError.
+*/
+void QQmlDataBlob::networkError(QNetworkReply::NetworkError networkError)
+{
+ Q_UNUSED(networkError);
+
+ QQmlError error;
+ error.setUrl(m_finalUrl);
+
+ const char *errorString = 0;
+ switch (networkError) {
+ default:
+ errorString = "Network error";
+ break;
+ case QNetworkReply::ConnectionRefusedError:
+ errorString = "Connection refused";
+ break;
+ case QNetworkReply::RemoteHostClosedError:
+ errorString = "Remote host closed the connection";
+ break;
+ case QNetworkReply::HostNotFoundError:
+ errorString = "Host not found";
+ break;
+ case QNetworkReply::TimeoutError:
+ errorString = "Timeout";
+ break;
+ case QNetworkReply::ProxyConnectionRefusedError:
+ case QNetworkReply::ProxyConnectionClosedError:
+ case QNetworkReply::ProxyNotFoundError:
+ case QNetworkReply::ProxyTimeoutError:
+ case QNetworkReply::ProxyAuthenticationRequiredError:
+ case QNetworkReply::UnknownProxyError:
+ errorString = "Proxy error";
+ break;
+ case QNetworkReply::ContentAccessDenied:
+ errorString = "Access denied";
+ break;
+ case QNetworkReply::ContentNotFoundError:
+ errorString = "File not found";
+ break;
+ case QNetworkReply::AuthenticationRequiredError:
+ errorString = "Authentication required";
+ break;
+ };
+
+ error.setDescription(QLatin1String(errorString));
+
+ setError(error);
+}
+
+/*!
+Called if \a blob, which was previously waited for, has an error.
+
+The default implementation does nothing.
+*/
+void QQmlDataBlob::dependencyError(QQmlDataBlob *blob)
+{
+ Q_UNUSED(blob);
+}
+
+/*!
+Called if \a blob, which was previously waited for, has completed.
+
+The default implementation does nothing.
+*/
+void QQmlDataBlob::dependencyComplete(QQmlDataBlob *blob)
+{
+ Q_UNUSED(blob);
+}
+
+/*!
+Called when all blobs waited for have completed. This occurs regardless of
+whether they are in error, or complete state.
+
+The default implementation does nothing.
+*/
+void QQmlDataBlob::allDependenciesDone()
+{
+}
+
+/*!
+Called when the download progress of this blob changes. \a progress goes
+from 0 to 1.
+
+This callback is only invoked if an asynchronous load for this blob is
+made. An asynchronous load is one in which the Asynchronous mode is
+specified explicitly, or one that is implicitly delayed due to a network
+operation.
+
+The default implementation does nothing.
+*/
+void QQmlDataBlob::downloadProgressChanged(qreal progress)
+{
+ Q_UNUSED(progress);
+}
+
+/*!
+Invoked on the main thread sometime after done() was called on the load thread.
+
+You cannot modify the blobs state at all in this callback and cannot depend on the
+order or timeliness of these callbacks. Implementors should use this callback to notify
+dependencies on the main thread that the blob is done and not a lot else.
+
+This callback is only invoked if an asynchronous load for this blob is
+made. An asynchronous load is one in which the Asynchronous mode is
+specified explicitly, or one that is implicitly delayed due to a network
+operation.
+
+The default implementation does nothing.
+*/
+void QQmlDataBlob::completed()
+{
+}
+
+
+void QQmlDataBlob::tryDone()
+{
+ if (status() != Loading && m_waitingFor.isEmpty() && !m_isDone) {
+ m_isDone = true;
+ addref();
+
+#ifdef DATABLOB_DEBUG
+ qWarning("QQmlDataBlob::done() %s", qPrintable(url().toString()));
+#endif
+ done();
+
+ if (status() != Error)
+ m_data.setStatus(Complete);
+
+ notifyAllWaitingOnMe();
+
+ // Locking is not required here, as anyone expecting callbacks must
+ // already be protected against the blob being completed (as set above);
+ if (m_data.isAsync()) {
+#ifdef DATABLOB_DEBUG
+ qWarning("QQmlDataBlob: Dispatching completed");
+#endif
+ m_manager->m_thread->callCompleted(this);
+ }
+
+ release();
+ }
+}
+
+void QQmlDataBlob::cancelAllWaitingFor()
+{
+ while (m_waitingFor.count()) {
+ QQmlDataBlob *blob = m_waitingFor.takeLast();
+
+ Q_ASSERT(blob->m_waitingOnMe.contains(this));
+
+ blob->m_waitingOnMe.removeOne(this);
+
+ blob->release();
+ }
+}
+
+void QQmlDataBlob::notifyAllWaitingOnMe()
+{
+ while (m_waitingOnMe.count()) {
+ QQmlDataBlob *blob = m_waitingOnMe.takeLast();
+
+ Q_ASSERT(blob->m_waitingFor.contains(this));
+
+ blob->notifyComplete(this);
+ }
+}
+
+void QQmlDataBlob::notifyComplete(QQmlDataBlob *blob)
+{
+ Q_ASSERT(m_waitingFor.contains(blob));
+ Q_ASSERT(blob->status() == Error || blob->status() == Complete);
+
+ m_inCallback = true;
+
+ if (blob->status() == Error) {
+ dependencyError(blob);
+ } else if (blob->status() == Complete) {
+ dependencyComplete(blob);
+ }
+
+ m_waitingFor.removeOne(blob);
+ blob->release();
+
+ if (!isError() && m_waitingFor.isEmpty())
+ allDependenciesDone();
+
+ m_inCallback = false;
+
+ tryDone();
+}
+
+#define TD_STATUS_MASK 0x0000FFFF
+#define TD_STATUS_SHIFT 0
+#define TD_PROGRESS_MASK 0x00FF0000
+#define TD_PROGRESS_SHIFT 16
+#define TD_ASYNC_MASK 0x80000000
+
+QQmlDataBlob::ThreadData::ThreadData()
+: _p(0)
+{
+}
+
+QQmlDataBlob::Status QQmlDataBlob::ThreadData::status() const
+{
+ return QQmlDataBlob::Status((_p.load() & TD_STATUS_MASK) >> TD_STATUS_SHIFT);
+}
+
+void QQmlDataBlob::ThreadData::setStatus(QQmlDataBlob::Status status)
+{
+ while (true) {
+ int d = _p.load();
+ int nd = (d & ~TD_STATUS_MASK) | ((status << TD_STATUS_SHIFT) & TD_STATUS_MASK);
+ if (d == nd || _p.testAndSetOrdered(d, nd)) return;
+ }
+}
+
+bool QQmlDataBlob::ThreadData::isAsync() const
+{
+ return _p.load() & TD_ASYNC_MASK;
+}
+
+void QQmlDataBlob::ThreadData::setIsAsync(bool v)
+{
+ while (true) {
+ int d = _p.load();
+ int nd = (d & ~TD_ASYNC_MASK) | (v?TD_ASYNC_MASK:0);
+ if (d == nd || _p.testAndSetOrdered(d, nd)) return;
+ }
+}
+
+quint8 QQmlDataBlob::ThreadData::progress() const
+{
+ return quint8((_p.load() & TD_PROGRESS_MASK) >> TD_PROGRESS_SHIFT);
+}
+
+void QQmlDataBlob::ThreadData::setProgress(quint8 v)
+{
+ while (true) {
+ int d = _p.load();
+ int nd = (d & ~TD_PROGRESS_MASK) | ((v << TD_PROGRESS_SHIFT) & TD_PROGRESS_MASK);
+ if (d == nd || _p.testAndSetOrdered(d, nd)) return;
+ }
+}
+
+QQmlDataLoaderThread::QQmlDataLoaderThread(QQmlDataLoader *loader)
+: m_loader(loader), m_networkAccessManager(0), m_networkReplyProxy(0)
+{
+}
+
+QNetworkAccessManager *QQmlDataLoaderThread::networkAccessManager() const
+{
+ Q_ASSERT(isThisThread());
+ if (!m_networkAccessManager) {
+ m_networkAccessManager = QQmlEnginePrivate::get(m_loader->engine())->createNetworkAccessManager(0);
+ m_networkReplyProxy = new QQmlDataLoaderNetworkReplyProxy(m_loader);
+ }
+
+ return m_networkAccessManager;
+}
+
+QQmlDataLoaderNetworkReplyProxy *QQmlDataLoaderThread::networkReplyProxy() const
+{
+ Q_ASSERT(isThisThread());
+ Q_ASSERT(m_networkReplyProxy); // Must call networkAccessManager() first
+ return m_networkReplyProxy;
+}
+
+void QQmlDataLoaderThread::load(QQmlDataBlob *b)
+{
+ b->addref();
+ callMethodInThread(&This::loadThread, b);
+}
+
+void QQmlDataLoaderThread::loadAsync(QQmlDataBlob *b)
+{
+ b->addref();
+ postMethodToThread(&This::loadThread, b);
+}
+
+void QQmlDataLoaderThread::loadWithStaticData(QQmlDataBlob *b, const QByteArray &d)
+{
+ b->addref();
+ callMethodInThread(&This::loadWithStaticDataThread, b, d);
+}
+
+void QQmlDataLoaderThread::loadWithStaticDataAsync(QQmlDataBlob *b, const QByteArray &d)
+{
+ b->addref();
+ postMethodToThread(&This::loadWithStaticDataThread, b, d);
+}
+
+void QQmlDataLoaderThread::callCompleted(QQmlDataBlob *b)
+{
+ b->addref();
+ postMethodToMain(&This::callCompletedMain, b);
+}
+
+void QQmlDataLoaderThread::callDownloadProgressChanged(QQmlDataBlob *b, qreal p)
+{
+ b->addref();
+ postMethodToMain(&This::callDownloadProgressChangedMain, b, p);
+}
+
+void QQmlDataLoaderThread::initializeEngine(QQmlExtensionInterface *iface,
+ const char *uri)
+{
+ callMethodInMain(&This::initializeEngineMain, iface, uri);
+}
+
+void QQmlDataLoaderThread::shutdownThread()
+{
+ delete m_networkAccessManager;
+ m_networkAccessManager = 0;
+ delete m_networkReplyProxy;
+ m_networkReplyProxy = 0;
+}
+
+void QQmlDataLoaderThread::loadThread(QQmlDataBlob *b)
+{
+ m_loader->loadThread(b);
+ b->release();
+}
+
+void QQmlDataLoaderThread::loadWithStaticDataThread(QQmlDataBlob *b, const QByteArray &d)
+{
+ m_loader->loadWithStaticDataThread(b, d);
+ b->release();
+}
+
+void QQmlDataLoaderThread::callCompletedMain(QQmlDataBlob *b)
+{
+#ifdef DATABLOB_DEBUG
+ qWarning("QQmlDataLoaderThread: %s completed() callback", qPrintable(b->url().toString()));
+#endif
+ b->completed();
+ b->release();
+}
+
+void QQmlDataLoaderThread::callDownloadProgressChangedMain(QQmlDataBlob *b, qreal p)
+{
+#ifdef DATABLOB_DEBUG
+ qWarning("QQmlDataLoaderThread: %s downloadProgressChanged(%f) callback",
+ qPrintable(b->url().toString()), p);
+#endif
+ b->downloadProgressChanged(p);
+ b->release();
+}
+
+void QQmlDataLoaderThread::initializeEngineMain(QQmlExtensionInterface *iface,
+ const char *uri)
+{
+ Q_ASSERT(m_loader->engine()->thread() == QThread::currentThread());
+ iface->initializeEngine(m_loader->engine(), uri);
+}
+
+/*!
+\class QQmlDataLoader
+\brief The QQmlDataLoader class abstracts loading files and their dependencies over the network.
+\internal
+
+The QQmlDataLoader class is provided for the exclusive use of the QQmlTypeLoader class.
+
+Clients create QQmlDataBlob instances and submit them to the QQmlDataLoader class
+through the QQmlDataLoader::load() or QQmlDataLoader::loadWithStaticData() methods.
+The loader then fetches the data over the network or from the local file system in an efficient way.
+QQmlDataBlob is an abstract class, so should always be specialized.
+
+Once data is received, the QQmlDataBlob::dataReceived() method is invoked on the blob. The
+derived class should use this callback to process the received data. Processing of the data can
+result in an error being set (QQmlDataBlob::setError()), or one or more dependencies being
+created (QQmlDataBlob::addDependency()). Dependencies are other QQmlDataBlob's that
+are required before processing can fully complete.
+
+To complete processing, the QQmlDataBlob::done() callback is invoked. done() is called when
+one of these three preconditions are met.
+
+\list 1
+\o The QQmlDataBlob has no dependencies.
+\o The QQmlDataBlob has an error set.
+\o All the QQmlDataBlob's dependencies are themselves "done()".
+\endlist
+
+Thus QQmlDataBlob::done() will always eventually be called, even if the blob has an error set.
+*/
+
+/*!
+Create a new QQmlDataLoader for \a engine.
+*/
+QQmlDataLoader::QQmlDataLoader(QQmlEngine *engine)
+: m_engine(engine), m_thread(new QQmlDataLoaderThread(this))
+{
+}
+
+/*! \internal */
+QQmlDataLoader::~QQmlDataLoader()
+{
+ for (NetworkReplies::Iterator iter = m_networkReplies.begin(); iter != m_networkReplies.end(); ++iter)
+ (*iter)->release();
+
+ m_thread->shutdown();
+ delete m_thread;
+}
+
+void QQmlDataLoader::lock()
+{
+ m_thread->lock();
+}
+
+void QQmlDataLoader::unlock()
+{
+ m_thread->unlock();
+}
+
+/*!
+Load the provided \a blob from the network or filesystem.
+
+The loader must be locked.
+*/
+void QQmlDataLoader::load(QQmlDataBlob *blob, Mode mode)
+{
+#ifdef DATABLOB_DEBUG
+ qWarning("QQmlDataLoader::load(%s): %s thread", qPrintable(blob->m_url.toString()),
+ m_thread->isThisThread()?"Compile":"Engine");
+#endif
+
+ Q_ASSERT(blob->status() == QQmlDataBlob::Null);
+ Q_ASSERT(blob->m_manager == 0);
+
+ blob->m_data.setStatus(QQmlDataBlob::Loading);
+ blob->m_manager = this;
+
+ if (m_thread->isThisThread()) {
+ unlock();
+ loadThread(blob);
+ lock();
+ } else if (mode == PreferSynchronous) {
+ unlock();
+ m_thread->load(blob);
+ lock();
+ if (!blob->isCompleteOrError())
+ blob->m_data.setIsAsync(true);
+ } else {
+ Q_ASSERT(mode == Asynchronous);
+ blob->m_data.setIsAsync(true);
+ unlock();
+ m_thread->loadAsync(blob);
+ lock();
+ }
+}
+
+/*!
+Load the provided \a blob with \a data. The blob's URL is not used by the data loader in this case.
+
+The loader must be locked.
+*/
+void QQmlDataLoader::loadWithStaticData(QQmlDataBlob *blob, const QByteArray &data, Mode mode)
+{
+#ifdef DATABLOB_DEBUG
+ qWarning("QQmlDataLoader::loadWithStaticData(%s, data): %s thread", qPrintable(blob->m_url.toString()),
+ m_thread->isThisThread()?"Compile":"Engine");
+#endif
+
+ Q_ASSERT(blob->status() == QQmlDataBlob::Null);
+ Q_ASSERT(blob->m_manager == 0);
+
+ blob->m_data.setStatus(QQmlDataBlob::Loading);
+ blob->m_manager = this;
+
+ if (m_thread->isThisThread()) {
+ unlock();
+ loadWithStaticDataThread(blob, data);
+ lock();
+ } else if (mode == PreferSynchronous) {
+ unlock();
+ m_thread->loadWithStaticData(blob, data);
+ lock();
+ if (!blob->isCompleteOrError())
+ blob->m_data.setIsAsync(true);
+ } else {
+ Q_ASSERT(mode == Asynchronous);
+ blob->m_data.setIsAsync(true);
+ unlock();
+ m_thread->loadWithStaticDataAsync(blob, data);
+ lock();
+ }
+}
+
+void QQmlDataLoader::loadWithStaticDataThread(QQmlDataBlob *blob, const QByteArray &data)
+{
+ ASSERT_LOADTHREAD();
+
+ setData(blob, data);
+}
+
+void QQmlDataLoader::loadThread(QQmlDataBlob *blob)
+{
+ ASSERT_LOADTHREAD();
+
+ if (blob->m_url.isEmpty()) {
+ QQmlError error;
+ error.setDescription(QLatin1String("Invalid null URL"));
+ blob->setError(error);
+ return;
+ }
+
+ QString lf = QQmlEnginePrivate::urlToLocalFileOrQrc(blob->m_url);
+
+ if (!lf.isEmpty()) {
+ if (!QQml_isFileCaseCorrect(lf)) {
+ QQmlError error;
+ error.setUrl(blob->m_url);
+ error.setDescription(QLatin1String("File name case mismatch"));
+ blob->setError(error);
+ return;
+ }
+ QFile file(lf);
+ if (file.open(QFile::ReadOnly)) {
+ QByteArray data = file.readAll();
+
+ blob->m_data.setProgress(0xFF);
+ if (blob->m_data.isAsync())
+ m_thread->callDownloadProgressChanged(blob, 1.);
+
+ setData(blob, data);
+ } else {
+ blob->networkError(QNetworkReply::ContentNotFoundError);
+ }
+
+ } else {
+
+ QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(blob->m_url));
+ QObject *nrp = m_thread->networkReplyProxy();
+ QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ nrp, SLOT(downloadProgress(qint64,qint64)));
+ QObject::connect(reply, SIGNAL(finished()),
+ nrp, SLOT(finished()));
+ m_networkReplies.insert(reply, blob);
+
+ blob->addref();
+ }
+}
+
+#define DATALOADER_MAXIMUM_REDIRECT_RECURSION 16
+
+void QQmlDataLoader::networkReplyFinished(QNetworkReply *reply)
+{
+ Q_ASSERT(m_thread->isThisThread());
+
+ reply->deleteLater();
+
+ QQmlDataBlob *blob = m_networkReplies.take(reply);
+
+ Q_ASSERT(blob);
+
+ blob->m_redirectCount++;
+
+ if (blob->m_redirectCount < DATALOADER_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = reply->url().resolved(redirect.toUrl());
+ blob->m_finalUrl = url;
+
+ QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(url));
+ QObject *nrp = m_thread->networkReplyProxy();
+ QObject::connect(reply, SIGNAL(finished()), nrp, SLOT(finished()));
+ m_networkReplies.insert(reply, blob);
+ return;
+ }
+ }
+
+ if (reply->error()) {
+ blob->networkError(reply->error());
+ } else {
+ QByteArray data = reply->readAll();
+ setData(blob, data);
+ }
+
+ blob->release();
+}
+
+void QQmlDataLoader::networkReplyProgress(QNetworkReply *reply,
+ qint64 bytesReceived, qint64 bytesTotal)
+{
+ Q_ASSERT(m_thread->isThisThread());
+
+ QQmlDataBlob *blob = m_networkReplies.value(reply);
+
+ Q_ASSERT(blob);
+
+ if (bytesTotal != 0) {
+ quint8 progress = 0xFF * (qreal(bytesReceived) / qreal(bytesTotal));
+ blob->m_data.setProgress(progress);
+ if (blob->m_data.isAsync())
+ m_thread->callDownloadProgressChanged(blob, blob->m_data.progress());
+ }
+}
+
+/*!
+Return the QQmlEngine associated with this loader
+*/
+QQmlEngine *QQmlDataLoader::engine() const
+{
+ return m_engine;
+}
+
+/*!
+Call the initializeEngine() method on \a iface. Used by QQmlImportDatabase to ensure it
+gets called in the correct thread.
+*/
+void QQmlDataLoader::initializeEngine(QQmlExtensionInterface *iface,
+ const char *uri)
+{
+ Q_ASSERT(m_thread->isThisThread() || engine()->thread() == QThread::currentThread());
+
+ if (m_thread->isThisThread()) {
+ m_thread->initializeEngine(iface, uri);
+ } else {
+ Q_ASSERT(engine()->thread() == QThread::currentThread());
+ iface->initializeEngine(engine(), uri);
+ }
+}
+
+
+void QQmlDataLoader::setData(QQmlDataBlob *blob, const QByteArray &data)
+{
+ blob->m_inCallback = true;
+
+ blob->dataReceived(data);
+
+ if (!blob->isError() && !blob->isWaiting())
+ blob->allDependenciesDone();
+
+ if (blob->status() != QQmlDataBlob::Error)
+ blob->m_data.setStatus(QQmlDataBlob::WaitingForDependencies);
+
+ blob->m_inCallback = false;
+
+ blob->tryDone();
+}
+
+/*!
+Constructs a new type loader that uses the given \a engine.
+*/
+QQmlTypeLoader::QQmlTypeLoader(QQmlEngine *engine)
+: QQmlDataLoader(engine)
+{
+}
+
+/*!
+Destroys the type loader, first clearing the cache of any information about
+loaded files.
+*/
+QQmlTypeLoader::~QQmlTypeLoader()
+{
+ clearCache();
+}
+
+/*!
+\enum QQmlTypeLoader::Option
+
+This enum defines the options that control the way type data is handled.
+
+\value None The default value, indicating that no other options
+ are enabled.
+\value PreserveParser The parser used to handle the type data is preserved
+ after the data has been parsed.
+*/
+
+/*!
+Returns a QQmlTypeData for the specified \a url. The QQmlTypeData may be cached.
+*/
+QQmlTypeData *QQmlTypeLoader::get(const QUrl &url)
+{
+ Q_ASSERT(!url.isRelative() &&
+ (QQmlEnginePrivate::urlToLocalFileOrQrc(url).isEmpty() ||
+ !QDir::isRelativePath(QQmlEnginePrivate::urlToLocalFileOrQrc(url))));
+
+ lock();
+
+ QQmlTypeData *typeData = m_typeCache.value(url);
+
+ if (!typeData) {
+ typeData = new QQmlTypeData(url, None, this);
+ m_typeCache.insert(url, typeData);
+ QQmlDataLoader::load(typeData);
+ }
+
+ typeData->addref();
+
+ unlock();
+
+ return typeData;
+}
+
+/*!
+Returns a QQmlTypeData for the given \a data with the provided base \a url. The
+QQmlTypeData will not be cached.
+
+The specified \a options control how the loader handles type data.
+*/
+QQmlTypeData *QQmlTypeLoader::get(const QByteArray &data, const QUrl &url, Options options)
+{
+ lock();
+
+ QQmlTypeData *typeData = new QQmlTypeData(url, options, this);
+ QQmlDataLoader::loadWithStaticData(typeData, data);
+
+ unlock();
+
+ return typeData;
+}
+
+/*!
+Return a QQmlScriptBlob for \a url. The QQmlScriptData may be cached.
+*/
+QQmlScriptBlob *QQmlTypeLoader::getScript(const QUrl &url)
+{
+ Q_ASSERT(!url.isRelative() &&
+ (QQmlEnginePrivate::urlToLocalFileOrQrc(url).isEmpty() ||
+ !QDir::isRelativePath(QQmlEnginePrivate::urlToLocalFileOrQrc(url))));
+
+ lock();
+
+ QQmlScriptBlob *scriptBlob = m_scriptCache.value(url);
+
+ if (!scriptBlob) {
+ scriptBlob = new QQmlScriptBlob(url, this);
+ m_scriptCache.insert(url, scriptBlob);
+ QQmlDataLoader::load(scriptBlob);
+ }
+
+ scriptBlob->addref();
+
+ unlock();
+
+ return scriptBlob;
+}
+
+/*!
+Returns a QQmlQmldirData for \a url. The QQmlQmldirData may be cached.
+*/
+QQmlQmldirData *QQmlTypeLoader::getQmldir(const QUrl &url)
+{
+ Q_ASSERT(!url.isRelative() &&
+ (QQmlEnginePrivate::urlToLocalFileOrQrc(url).isEmpty() ||
+ !QDir::isRelativePath(QQmlEnginePrivate::urlToLocalFileOrQrc(url))));
+
+ lock();
+
+ QQmlQmldirData *qmldirData = m_qmldirCache.value(url);
+
+ if (!qmldirData) {
+ qmldirData = new QQmlQmldirData(url);
+ m_qmldirCache.insert(url, qmldirData);
+ QQmlDataLoader::load(qmldirData);
+ }
+
+ qmldirData->addref();
+
+ unlock();
+
+ return qmldirData;
+}
+
+/*!
+Returns the absolute filename of path via a directory cache for files named
+"qmldir", "*.qml", "*.js", and plugins.
+Returns a empty string if the path does not exist.
+*/
+QString QQmlTypeLoader::absoluteFilePath(const QString &path)
+{
+ if (path.isEmpty())
+ return QString();
+ if (path.at(0) == QLatin1Char(':')) {
+ // qrc resource
+ QFileInfo fileInfo(path);
+ return fileInfo.isFile() ? fileInfo.absoluteFilePath() : QString();
+ }
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
+ QString lowPath = path.toLower();
+ int lastSlash = lowPath.lastIndexOf(QLatin1Char('/'));
+ QString dirPath = lowPath.left(lastSlash);
+#else
+ int lastSlash = path.lastIndexOf(QLatin1Char('/'));
+ QStringRef dirPath(&path, 0, lastSlash);
+#endif
+
+ StringSet **fileSet = m_importDirCache.value(QHashedStringRef(dirPath.constData(), dirPath.length()));
+ if (!fileSet) {
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
+ QHashedString dirPathString(dirPath);
+#else
+ QHashedString dirPathString(dirPath.toString());
+#endif
+ StringSet *files = qmlFilesInDirectory(dirPathString);
+ m_importDirCache.insert(dirPathString, files);
+ fileSet = m_importDirCache.value(dirPathString);
+ }
+ if (!(*fileSet))
+ return QString();
+
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
+ QString absoluteFilePath = (*fileSet)->contains(QHashedStringRef(lowPath.constData()+lastSlash+1, lowPath.length()-lastSlash-1)) ? path : QString();
+#else
+ QString absoluteFilePath = (*fileSet)->contains(QHashedStringRef(path.constData()+lastSlash+1, path.length()-lastSlash-1)) ? path : QString();
+#endif
+ if (absoluteFilePath.length() > 2 && absoluteFilePath.at(0) != QLatin1Char('/') && absoluteFilePath.at(1) != QLatin1Char(':'))
+ absoluteFilePath = QFileInfo(absoluteFilePath).absoluteFilePath();
+
+ return absoluteFilePath;
+}
+
+/*!
+Returns true if the path is a directory via a directory cache. Cache is
+shared with absoluteFilePath().
+*/
+bool QQmlTypeLoader::directoryExists(const QString &path)
+{
+ if (path.isEmpty())
+ return false;
+ if (path.at(0) == QLatin1Char(':')) {
+ // qrc resource
+ QFileInfo fileInfo(path);
+ return fileInfo.exists() && fileInfo.isDir();
+ }
+
+ int length = path.length();
+ if (path.endsWith(QLatin1Char('/')))
+ --length;
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
+ QString dirPath = path.left(length).toLower();
+#else
+ QStringRef dirPath(&path, 0, length);
+#endif
+
+ StringSet **fileSet = m_importDirCache.value(QHashedStringRef(dirPath.constData(), dirPath.length()));
+ if (!fileSet) {
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_DARWIN)
+ QHashedString dirPathString(dirPath);
+#else
+ QHashedString dirPathString(dirPath.toString());
+#endif
+ StringSet *files = qmlFilesInDirectory(dirPathString);
+ m_importDirCache.insert(dirPathString, files);
+ fileSet = m_importDirCache.value(dirPathString);
+ }
+
+ return (*fileSet);
+}
+
+
+/*!
+Return a QQmlDirParser for absoluteFilePath. The QQmlDirParser may be cached.
+*/
+const QQmlDirParser *QQmlTypeLoader::qmlDirParser(const QString &absoluteFilePath)
+{
+ QQmlDirParser *qmldirParser;
+ QQmlDirParser **val = m_importQmlDirCache.value(absoluteFilePath);
+ if (!val) {
+ qmldirParser = new QQmlDirParser;
+ qmldirParser->setFileSource(absoluteFilePath);
+ qmldirParser->setUrl(QUrl::fromLocalFile(absoluteFilePath));
+ qmldirParser->parse();
+ m_importQmlDirCache.insert(absoluteFilePath, qmldirParser);
+ } else {
+ qmldirParser = *val;
+ }
+
+ return qmldirParser;
+}
+
+
+/*!
+Clears cached information about loaded files, including any type data, scripts
+and qmldir information.
+*/
+void QQmlTypeLoader::clearCache()
+{
+ for (TypeCache::Iterator iter = m_typeCache.begin(); iter != m_typeCache.end(); ++iter)
+ (*iter)->release();
+ for (ScriptCache::Iterator iter = m_scriptCache.begin(); iter != m_scriptCache.end(); ++iter)
+ (*iter)->release();
+ for (QmldirCache::Iterator iter = m_qmldirCache.begin(); iter != m_qmldirCache.end(); ++iter)
+ (*iter)->release();
+ qDeleteAll(m_importDirCache);
+ qDeleteAll(m_importQmlDirCache);
+
+ m_typeCache.clear();
+ m_scriptCache.clear();
+ m_qmldirCache.clear();
+ m_importDirCache.clear();
+ m_importQmlDirCache.clear();
+}
+
+
+QQmlTypeData::QQmlTypeData(const QUrl &url, QQmlTypeLoader::Options options,
+ QQmlTypeLoader *manager)
+: QQmlDataBlob(url, QmlFile), m_options(options), m_imports(manager), m_typesResolved(false),
+ m_compiledData(0), m_typeLoader(manager)
+{
+}
+
+QQmlTypeData::~QQmlTypeData()
+{
+ for (int ii = 0; ii < m_scripts.count(); ++ii)
+ m_scripts.at(ii).script->release();
+ for (int ii = 0; ii < m_qmldirs.count(); ++ii)
+ m_qmldirs.at(ii)->release();
+ for (int ii = 0; ii < m_types.count(); ++ii)
+ if (m_types.at(ii).typeData) m_types.at(ii).typeData->release();
+ if (m_compiledData)
+ m_compiledData->release();
+}
+
+QQmlTypeLoader *QQmlTypeData::typeLoader() const
+{
+ return m_typeLoader;
+}
+
+const QQmlImports &QQmlTypeData::imports() const
+{
+ return m_imports;
+}
+
+const QQmlScript::Parser &QQmlTypeData::parser() const
+{
+ return scriptParser;
+}
+
+const QList<QQmlTypeData::TypeReference> &QQmlTypeData::resolvedTypes() const
+{
+ return m_types;
+}
+
+const QList<QQmlTypeData::ScriptReference> &QQmlTypeData::resolvedScripts() const
+{
+ return m_scripts;
+}
+
+const QSet<QString> &QQmlTypeData::namespaces() const
+{
+ return m_namespaces;
+}
+
+QQmlCompiledData *QQmlTypeData::compiledData() const
+{
+ if (m_compiledData)
+ m_compiledData->addref();
+
+ return m_compiledData;
+}
+
+void QQmlTypeData::registerCallback(TypeDataCallback *callback)
+{
+ Q_ASSERT(!m_callbacks.contains(callback));
+ m_callbacks.append(callback);
+}
+
+void QQmlTypeData::unregisterCallback(TypeDataCallback *callback)
+{
+ Q_ASSERT(m_callbacks.contains(callback));
+ m_callbacks.removeOne(callback);
+ Q_ASSERT(!m_callbacks.contains(callback));
+}
+
+void QQmlTypeData::done()
+{
+ // Check all script dependencies for errors
+ for (int ii = 0; !isError() && ii < m_scripts.count(); ++ii) {
+ const ScriptReference &script = m_scripts.at(ii);
+ Q_ASSERT(script.script->isCompleteOrError());
+ if (script.script->isError()) {
+ QList<QQmlError> errors = script.script->errors();
+ QQmlError error;
+ error.setUrl(finalUrl());
+ error.setLine(script.location.line);
+ error.setColumn(script.location.column);
+ error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->url().toString()));
+ errors.prepend(error);
+ setError(errors);
+ }
+ }
+
+ // Check all type dependencies for errors
+ for (int ii = 0; !isError() && ii < m_types.count(); ++ii) {
+ const TypeReference &type = m_types.at(ii);
+ Q_ASSERT(!type.typeData || type.typeData->isCompleteOrError());
+ if (type.typeData && type.typeData->isError()) {
+ QString typeName = scriptParser.referencedTypes().at(ii)->name;
+
+ QList<QQmlError> errors = type.typeData->errors();
+ QQmlError error;
+ error.setUrl(finalUrl());
+ error.setLine(type.location.line);
+ error.setColumn(type.location.column);
+ error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName));
+ errors.prepend(error);
+ setError(errors);
+ }
+ }
+
+ // Compile component
+ if (!isError())
+ compile();
+
+ if (!(m_options & QQmlTypeLoader::PreserveParser))
+ scriptParser.clear();
+}
+
+void QQmlTypeData::completed()
+{
+ // Notify callbacks
+ while (!m_callbacks.isEmpty()) {
+ TypeDataCallback *callback = m_callbacks.takeFirst();
+ callback->typeDataReady(this);
+ }
+}
+
+void QQmlTypeData::dataReceived(const QByteArray &data)
+{
+ if (!scriptParser.parse(data, finalUrl(), finalUrlString())) {
+ setError(scriptParser.errors());
+ return;
+ }
+
+ m_imports.setBaseUrl(finalUrl(), finalUrlString());
+
+ foreach (const QQmlScript::Import &import, scriptParser.imports()) {
+ if (import.type == QQmlScript::Import::File && import.qualifier.isEmpty()) {
+ QUrl importUrl = finalUrl().resolved(QUrl(import.uri + QLatin1String("/qmldir")));
+ if (QQmlEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty()) {
+ QQmlQmldirData *data = typeLoader()->getQmldir(importUrl);
+ addDependency(data);
+ m_qmldirs << data;
+ }
+ } else if (import.type == QQmlScript::Import::Script) {
+ QUrl scriptUrl = finalUrl().resolved(QUrl(import.uri));
+ QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
+ addDependency(blob);
+
+ ScriptReference ref;
+ ref.location = import.location.start;
+ ref.qualifier = import.qualifier;
+ ref.script = blob;
+ m_scripts << ref;
+
+ }
+ }
+
+ if (!finalUrl().scheme().isEmpty()) {
+ QUrl importUrl = finalUrl().resolved(QUrl(QLatin1String("qmldir")));
+ if (QQmlEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty()) {
+ QQmlQmldirData *data = typeLoader()->getQmldir(importUrl);
+ addDependency(data);
+ m_qmldirs << data;
+ }
+ }
+}
+
+void QQmlTypeData::allDependenciesDone()
+{
+ if (!m_typesResolved) {
+ resolveTypes();
+ m_typesResolved = true;
+ }
+}
+
+void QQmlTypeData::downloadProgressChanged(qreal p)
+{
+ for (int ii = 0; ii < m_callbacks.count(); ++ii) {
+ TypeDataCallback *callback = m_callbacks.at(ii);
+ callback->typeDataProgress(this, p);
+ }
+}
+
+void QQmlTypeData::compile()
+{
+ Q_ASSERT(m_compiledData == 0);
+
+ m_compiledData = new QQmlCompiledData(typeLoader()->engine());
+ m_compiledData->url = finalUrl();
+ m_compiledData->name = finalUrlString();
+
+ QQmlCompilingProfiler prof(m_compiledData->name);
+
+ QQmlCompiler compiler(&scriptParser._pool);
+ if (!compiler.compile(typeLoader()->engine(), this, m_compiledData)) {
+ setError(compiler.errors());
+ m_compiledData->release();
+ m_compiledData = 0;
+ }
+}
+
+void QQmlTypeData::resolveTypes()
+{
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_typeLoader->engine());
+ QQmlImportDatabase *importDatabase = &ep->importDatabase;
+
+ // For local urls, add an implicit import "." as first (most overridden) lookup.
+ // This will also trigger the loading of the qmldir and the import of any native
+ // types from available plugins.
+ QList<QQmlError> errors;
+ if (QQmlQmldirData *qmldir = qmldirForUrl(finalUrl().resolved(QUrl(QLatin1String("./qmldir"))))) {
+ m_imports.addImport(importDatabase, QLatin1String("."),
+ QString(), -1, -1, QQmlScript::Import::File,
+ qmldir->dirComponents(), &errors);
+ } else {
+ m_imports.addImport(importDatabase, QLatin1String("."),
+ QString(), -1, -1, QQmlScript::Import::File,
+ QQmlDirComponents(), &errors);
+ }
+
+ // remove any errors which are due to the implicit import which aren't real errors.
+ // for example, if the implicitly included qmldir file doesn't exist, that is not an error.
+ QList<QQmlError> realErrors;
+ for (int i = 0; i < errors.size(); ++i) {
+ if (errors.at(i).description() != QQmlImportDatabase::tr("import \".\" has no qmldir and no namespace")
+ && errors.at(i).description() != QQmlImportDatabase::tr("\".\": no such directory")) {
+ realErrors.prepend(errors.at(i)); // this is a real error.
+ }
+ }
+
+ // report any real errors which occurred during plugin loading or qmldir parsing.
+ if (!realErrors.isEmpty()) {
+ setError(realErrors);
+ return;
+ }
+
+ foreach (const QQmlScript::Import &import, scriptParser.imports()) {
+ QQmlDirComponents qmldircomponentsnetwork;
+ if (import.type == QQmlScript::Import::Script)
+ continue;
+
+ if (import.type == QQmlScript::Import::File && import.qualifier.isEmpty()) {
+ QUrl qmldirUrl = finalUrl().resolved(QUrl(import.uri + QLatin1String("/qmldir")));
+ if (QQmlQmldirData *qmldir = qmldirForUrl(qmldirUrl))
+ qmldircomponentsnetwork = qmldir->dirComponents();
+ }
+
+ int vmaj = -1;
+ int vmin = -1;
+ import.extractVersion(&vmaj, &vmin);
+
+ QList<QQmlError> errors;
+ if (!m_imports.addImport(importDatabase, import.uri, import.qualifier,
+ vmaj, vmin, import.type, qmldircomponentsnetwork, &errors)) {
+ QQmlError error;
+ if (errors.size()) {
+ error = errors.takeFirst();
+ } else {
+ // this should not be possible!
+ // Description should come from error provided by addImport() function.
+ error.setDescription(QQmlTypeLoader::tr("Unreported error adding script import to import database"));
+ }
+ error.setUrl(m_imports.baseUrl());
+ error.setLine(import.location.start.line);
+ error.setColumn(import.location.start.column);
+ errors.prepend(error); // put it back on the list after filling out information.
+
+ setError(errors);
+ return;
+ }
+ }
+
+ // Add any imported scripts to our resolved set
+ foreach (const QQmlImports::ScriptReference &script, m_imports.resolvedScripts())
+ {
+ QQmlScriptBlob *blob = typeLoader()->getScript(script.location);
+ addDependency(blob);
+
+ ScriptReference ref;
+ //ref.location = ...
+ ref.qualifier = script.nameSpace;
+ if (!script.qualifier.isEmpty())
+ {
+ ref.qualifier.prepend(script.qualifier + QLatin1Char('.'));
+
+ // Add a reference to the enclosing namespace
+ m_namespaces.insert(script.qualifier);
+ }
+
+ ref.script = blob;
+ m_scripts << ref;
+ }
+
+ foreach (QQmlScript::TypeReference *parserRef, scriptParser.referencedTypes()) {
+ TypeReference ref;
+
+ QString url;
+ int majorVersion;
+ int minorVersion;
+ QQmlImportedNamespace *typeNamespace = 0;
+ QList<QQmlError> errors;
+
+ if (!m_imports.resolveType(parserRef->name, &ref.type, &url, &majorVersion, &minorVersion,
+ &typeNamespace, &errors) || typeNamespace) {
+ // Known to not be a type:
+ // - known to be a namespace (Namespace {})
+ // - type with unknown namespace (UnknownNamespace.SomeType {})
+ QQmlError error;
+ QString userTypeName = parserRef->name;
+ userTypeName.replace(QLatin1Char('/'),QLatin1Char('.'));
+ if (typeNamespace) {
+ error.setDescription(QQmlTypeLoader::tr("Namespace %1 cannot be used as a type").arg(userTypeName));
+ } else {
+ if (errors.size()) {
+ error = errors.takeFirst();
+ } else {
+ // this should not be possible!
+ // Description should come from error provided by addImport() function.
+ error.setDescription(QQmlTypeLoader::tr("Unreported error adding script import to import database"));
+ }
+ error.setUrl(m_imports.baseUrl());
+ error.setDescription(QQmlTypeLoader::tr("%1 %2").arg(userTypeName).arg(error.description()));
+ }
+
+ if (!parserRef->refObjects.isEmpty()) {
+ QQmlScript::Object *obj = parserRef->refObjects.first();
+ error.setLine(obj->location.start.line);
+ error.setColumn(obj->location.start.column);
+ }
+
+ errors.prepend(error);
+ setError(errors);
+ return;
+ }
+
+ if (ref.type) {
+ ref.majorVersion = majorVersion;
+ ref.minorVersion = minorVersion;
+ } else {
+ ref.typeData = typeLoader()->get(QUrl(url));
+ addDependency(ref.typeData);
+ }
+
+ if (parserRef->refObjects.count())
+ ref.location = parserRef->refObjects.first()->location.start;
+
+ m_types << ref;
+ }
+}
+
+QQmlQmldirData *QQmlTypeData::qmldirForUrl(const QUrl &url)
+{
+ for (int ii = 0; ii < m_qmldirs.count(); ++ii) {
+ if (m_qmldirs.at(ii)->url() == url)
+ return m_qmldirs.at(ii);
+ }
+ return 0;
+}
+
+QQmlScriptData::QQmlScriptData()
+: importCache(0), pragmas(QQmlScript::Object::ScriptBlock::None), m_loaded(false)
+{
+}
+
+QQmlScriptData::~QQmlScriptData()
+{
+}
+
+void QQmlScriptData::clear()
+{
+ if (importCache) {
+ importCache->release();
+ importCache = 0;
+ }
+
+ for (int ii = 0; ii < scripts.count(); ++ii)
+ scripts.at(ii)->release();
+ scripts.clear();
+
+ qPersistentDispose(m_program);
+ qPersistentDispose(m_value);
+
+ // An addref() was made when the QQmlCleanup was added to the engine.
+ release();
+}
+
+QQmlScriptBlob::QQmlScriptBlob(const QUrl &url, QQmlTypeLoader *loader)
+: QQmlDataBlob(url, JavaScriptFile), m_pragmas(QQmlScript::Object::ScriptBlock::None),
+ m_imports(loader), m_scriptData(0), m_typeLoader(loader)
+{
+}
+
+QQmlScriptBlob::~QQmlScriptBlob()
+{
+ if (m_scriptData) {
+ m_scriptData->release();
+ m_scriptData = 0;
+ }
+}
+
+QQmlScript::Object::ScriptBlock::Pragmas QQmlScriptBlob::pragmas() const
+{
+ return m_pragmas;
+}
+
+QQmlTypeLoader *QQmlScriptBlob::typeLoader() const
+{
+ return m_typeLoader;
+}
+
+const QQmlImports &QQmlScriptBlob::imports() const
+{
+ return m_imports;
+}
+
+QQmlScriptData *QQmlScriptBlob::scriptData() const
+{
+ return m_scriptData;
+}
+
+void QQmlScriptBlob::dataReceived(const QByteArray &data)
+{
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_typeLoader->engine());
+ QQmlImportDatabase *importDatabase = &ep->importDatabase;
+
+ m_source = QString::fromUtf8(data);
+
+ QQmlScript::Parser::JavaScriptMetaData metadata =
+ QQmlScript::Parser::extractMetaData(m_source);
+
+ m_imports.setBaseUrl(finalUrl(), finalUrlString());
+
+ m_pragmas = metadata.pragmas;
+
+ foreach (const QQmlScript::Import &import, metadata.imports) {
+ Q_ASSERT(import.type != QQmlScript::Import::File);
+
+ if (import.type == QQmlScript::Import::Script) {
+ QUrl scriptUrl = finalUrl().resolved(QUrl(import.uri));
+ QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
+ addDependency(blob);
+
+ ScriptReference ref;
+ ref.location = import.location.start;
+ ref.qualifier = import.qualifier;
+ ref.script = blob;
+ m_scripts << ref;
+ } else {
+ Q_ASSERT(import.type == QQmlScript::Import::Library);
+ int vmaj = -1;
+ int vmin = -1;
+ import.extractVersion(&vmaj, &vmin);
+
+ QList<QQmlError> errors;
+ if (!m_imports.addImport(importDatabase, import.uri, import.qualifier, vmaj, vmin,
+ import.type, QQmlDirComponents(), &errors)) {
+ QQmlError error = errors.takeFirst();
+ // description should be set by addImport().
+ error.setUrl(m_imports.baseUrl());
+ error.setLine(import.location.start.line);
+ error.setColumn(import.location.start.column);
+ errors.prepend(error);
+
+ setError(errors);
+ return;
+ }
+ }
+ }
+}
+
+void QQmlScriptBlob::done()
+{
+ // Check all script dependencies for errors
+ for (int ii = 0; !isError() && ii < m_scripts.count(); ++ii) {
+ const ScriptReference &script = m_scripts.at(ii);
+ Q_ASSERT(script.script->isCompleteOrError());
+ if (script.script->isError()) {
+ QList<QQmlError> errors = script.script->errors();
+ QQmlError error;
+ error.setUrl(finalUrl());
+ error.setLine(script.location.line);
+ error.setColumn(script.location.column);
+ error.setDescription(typeLoader()->tr("Script %1 unavailable").arg(script.script->url().toString()));
+ errors.prepend(error);
+ setError(errors);
+ }
+ }
+
+ if (isError())
+ return;
+
+ QQmlEngine *engine = typeLoader()->engine();
+ m_scriptData = new QQmlScriptData();
+ m_scriptData->url = finalUrl();
+ m_scriptData->urlString = finalUrlString();
+ m_scriptData->importCache = new QQmlTypeNameCache();
+
+ for (int ii = 0; !isError() && ii < m_scripts.count(); ++ii) {
+ const ScriptReference &script = m_scripts.at(ii);
+
+ m_scriptData->scripts.append(script.script);
+ m_scriptData->importCache->add(script.qualifier, ii);
+ }
+
+ m_imports.populateCache(m_scriptData->importCache, engine);
+
+ m_scriptData->pragmas = m_pragmas;
+ m_scriptData->m_programSource = m_source.toUtf8();
+ m_source.clear();
+}
+
+QQmlQmldirData::QQmlQmldirData(const QUrl &url)
+: QQmlDataBlob(url, QmldirFile)
+{
+}
+
+const QQmlDirComponents &QQmlQmldirData::dirComponents() const
+{
+ return m_components;
+}
+
+void QQmlQmldirData::dataReceived(const QByteArray &data)
+{
+ QQmlDirParser parser;
+ parser.setSource(QString::fromUtf8(data));
+ parser.parse();
+ m_components = parser.components();
+}
+
+QT_END_NAMESPACE
+
+#include "qqmltypeloader.moc"
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
new file mode 100644
index 0000000000..0dd7adecac
--- /dev/null
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -0,0 +1,435 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLTYPELOADER_P_H
+#define QQMLTYPELOADER_P_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/qobject.h>
+#include <QtCore/qatomic.h>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtQml/qqmlerror.h>
+#include <QtQml/qqmlengine.h>
+
+#include <private/qv8_p.h>
+#include <private/qhashedstring_p.h>
+#include <private/qqmlscript_p.h>
+#include <private/qqmlimport_p.h>
+#include <private/qqmlcleanup_p.h>
+#include <private/qqmldirparser_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlScriptData;
+class QQmlScriptBlob;
+class QQmlQmldirData;
+class QQmlTypeLoader;
+class QQmlCompiledData;
+class QQmlComponentPrivate;
+class QQmlTypeData;
+class QQmlDataLoader;
+class QQmlExtensionInterface;
+
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlDataBlob : public QQmlRefCount
+{
+public:
+ enum Status {
+ Null, // Prior to QQmlDataLoader::load()
+ Loading, // Prior to data being received and dataReceived() being called
+ WaitingForDependencies, // While there are outstanding addDependency()s
+ Complete, // Finished
+ Error // Error
+ };
+
+ enum Type {
+ QmlFile,
+ JavaScriptFile,
+ QmldirFile
+ };
+
+ QQmlDataBlob(const QUrl &, Type);
+ virtual ~QQmlDataBlob();
+
+ Type type() const;
+
+ Status status() const;
+ bool isNull() const;
+ bool isLoading() const;
+ bool isWaiting() const;
+ bool isComplete() const;
+ bool isError() const;
+ bool isCompleteOrError() const;
+
+ qreal progress() const;
+
+ QUrl url() const;
+ QUrl finalUrl() const;
+ QString finalUrlString() const;
+
+ QList<QQmlError> errors() const;
+
+protected:
+ // Can be called from within callbacks
+ void setError(const QQmlError &);
+ void setError(const QList<QQmlError> &errors);
+ void addDependency(QQmlDataBlob *);
+
+ // Callbacks made in load thread
+ virtual void dataReceived(const QByteArray &) = 0;
+ virtual void done();
+ virtual void networkError(QNetworkReply::NetworkError);
+ virtual void dependencyError(QQmlDataBlob *);
+ virtual void dependencyComplete(QQmlDataBlob *);
+ virtual void allDependenciesDone();
+
+ // Callbacks made in main thread
+ virtual void downloadProgressChanged(qreal);
+ virtual void completed();
+private:
+ friend class QQmlDataLoader;
+ friend class QQmlDataLoaderThread;
+
+ void tryDone();
+ void cancelAllWaitingFor();
+ void notifyAllWaitingOnMe();
+ void notifyComplete(QQmlDataBlob *);
+
+ struct ThreadData {
+ inline ThreadData();
+ inline QQmlDataBlob::Status status() const;
+ inline void setStatus(QQmlDataBlob::Status);
+ inline bool isAsync() const;
+ inline void setIsAsync(bool);
+ inline quint8 progress() const;
+ inline void setProgress(quint8);
+
+ private:
+ QAtomicInt _p;
+ };
+ ThreadData m_data;
+
+ // m_errors should *always* be written before the status is set to Error.
+ // We use the status change as a memory fence around m_errors so that locking
+ // isn't required. Once the status is set to Error (or Complete), m_errors
+ // cannot be changed.
+ QList<QQmlError> m_errors;
+
+ Type m_type;
+
+ QUrl m_url;
+ QUrl m_finalUrl;
+ mutable QString m_finalUrlString;
+
+ // List of QQmlDataBlob's that are waiting for me to complete.
+ QList<QQmlDataBlob *> m_waitingOnMe;
+
+ // List of QQmlDataBlob's that I am waiting for to complete.
+ QList<QQmlDataBlob *> m_waitingFor;
+
+ // Manager that is currently fetching data for me
+ QQmlDataLoader *m_manager;
+ int m_redirectCount:30;
+ bool m_inCallback:1;
+ bool m_isDone:1;
+};
+
+class QQmlDataLoaderThread;
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlDataLoader
+{
+public:
+ QQmlDataLoader(QQmlEngine *);
+ ~QQmlDataLoader();
+
+ void lock();
+ void unlock();
+
+ bool isConcurrent() const { return true; }
+
+ enum Mode { PreferSynchronous, Asynchronous };
+
+ void load(QQmlDataBlob *, Mode = PreferSynchronous);
+ void loadWithStaticData(QQmlDataBlob *, const QByteArray &, Mode = PreferSynchronous);
+
+ QQmlEngine *engine() const;
+ void initializeEngine(QQmlExtensionInterface *, const char *);
+
+private:
+ friend class QQmlDataBlob;
+ friend class QQmlDataLoaderThread;
+ friend class QQmlDataLoaderNetworkReplyProxy;
+
+ void loadThread(QQmlDataBlob *);
+ void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &);
+ void networkReplyFinished(QNetworkReply *);
+ void networkReplyProgress(QNetworkReply *, qint64, qint64);
+
+ typedef QHash<QNetworkReply *, QQmlDataBlob *> NetworkReplies;
+
+ void setData(QQmlDataBlob *, const QByteArray &);
+
+ QQmlEngine *m_engine;
+ QQmlDataLoaderThread *m_thread;
+ NetworkReplies m_networkReplies;
+};
+
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlTypeLoader : public QQmlDataLoader
+{
+ Q_DECLARE_TR_FUNCTIONS(QQmlTypeLoader)
+public:
+ QQmlTypeLoader(QQmlEngine *);
+ ~QQmlTypeLoader();
+
+ enum Option {
+ None,
+ PreserveParser
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+
+ QQmlTypeData *get(const QUrl &url);
+ QQmlTypeData *get(const QByteArray &, const QUrl &url, Options = None);
+ void clearCache();
+
+ QQmlScriptBlob *getScript(const QUrl &);
+ QQmlQmldirData *getQmldir(const QUrl &);
+
+ QString absoluteFilePath(const QString &path);
+ bool directoryExists(const QString &path);
+ const QQmlDirParser *qmlDirParser(const QString &absoluteFilePath);
+private:
+ typedef QHash<QUrl, QQmlTypeData *> TypeCache;
+ typedef QHash<QUrl, QQmlScriptBlob *> ScriptCache;
+ typedef QHash<QUrl, QQmlQmldirData *> QmldirCache;
+ typedef QStringHash<bool> StringSet;
+ typedef QStringHash<StringSet*> ImportDirCache;
+ typedef QStringHash<QQmlDirParser*> ImportQmlDirCache;
+
+ TypeCache m_typeCache;
+ ScriptCache m_scriptCache;
+ QmldirCache m_qmldirCache;
+ ImportDirCache m_importDirCache;
+ ImportQmlDirCache m_importQmlDirCache;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlTypeLoader::Options)
+
+class Q_AUTOTEST_EXPORT QQmlTypeData : public QQmlDataBlob
+{
+public:
+ struct TypeReference
+ {
+ TypeReference() : type(0), majorVersion(0), minorVersion(0), typeData(0) {}
+
+ QQmlScript::Location location;
+ QQmlType *type;
+ int majorVersion;
+ int minorVersion;
+ QQmlTypeData *typeData;
+ };
+
+ struct ScriptReference
+ {
+ ScriptReference() : script(0) {}
+
+ QQmlScript::Location location;
+ QString qualifier;
+ QQmlScriptBlob *script;
+ };
+
+ QQmlTypeData(const QUrl &, QQmlTypeLoader::Options, QQmlTypeLoader *);
+ ~QQmlTypeData();
+
+ QQmlTypeLoader *typeLoader() const;
+
+ const QQmlImports &imports() const;
+ const QQmlScript::Parser &parser() const;
+
+ const QList<TypeReference> &resolvedTypes() const;
+ const QList<ScriptReference> &resolvedScripts() const;
+ const QSet<QString> &namespaces() const;
+
+ QQmlCompiledData *compiledData() const;
+
+ // Used by QQmlComponent to get notifications
+ struct TypeDataCallback {
+ ~TypeDataCallback() {}
+ virtual void typeDataProgress(QQmlTypeData *, qreal) {}
+ virtual void typeDataReady(QQmlTypeData *) {}
+ };
+ void registerCallback(TypeDataCallback *);
+ void unregisterCallback(TypeDataCallback *);
+
+protected:
+ virtual void done();
+ virtual void completed();
+ virtual void dataReceived(const QByteArray &);
+ virtual void allDependenciesDone();
+ virtual void downloadProgressChanged(qreal);
+
+private:
+ void resolveTypes();
+ void compile();
+
+ QQmlTypeLoader::Options m_options;
+
+ QQmlQmldirData *qmldirForUrl(const QUrl &);
+
+ QQmlScript::Parser scriptParser;
+ QQmlImports m_imports;
+
+ QList<ScriptReference> m_scripts;
+ QList<QQmlQmldirData *> m_qmldirs;
+
+ QSet<QString> m_namespaces;
+
+ QList<TypeReference> m_types;
+ bool m_typesResolved:1;
+
+ QQmlCompiledData *m_compiledData;
+
+ QList<TypeDataCallback *> m_callbacks;
+
+ QQmlTypeLoader *m_typeLoader;
+};
+
+// QQmlScriptData instances are created, uninitialized, by the loader in the
+// load thread. The first time they are used by the VME, they are initialized which
+// creates their v8 objects and they are referenced and added to the engine's cleanup
+// list. During QQmlCleanup::clear() all v8 resources are destroyed, and the
+// reference that was created is released but final deletion only occurs once all the
+// references as released. This is all intended to ensure that the v8 resources are
+// only created and destroyed in the main thread :)
+class Q_AUTOTEST_EXPORT QQmlScriptData : public QQmlCleanup,
+ public QQmlRefCount
+{
+public:
+ QQmlScriptData();
+ ~QQmlScriptData();
+
+ QUrl url;
+ QString urlString;
+ QQmlTypeNameCache *importCache;
+ QList<QQmlScriptBlob *> scripts;
+ QQmlScript::Object::ScriptBlock::Pragmas pragmas;
+
+ bool isInitialized() const { return hasEngine(); }
+ void initialize(QQmlEngine *);
+
+protected:
+ virtual void clear(); // From QQmlCleanup
+
+private:
+ friend class QQmlVME;
+ friend class QQmlScriptBlob;
+
+ bool m_loaded;
+ QByteArray m_programSource;
+ v8::Persistent<v8::Script> m_program;
+ v8::Persistent<v8::Object> m_value;
+};
+
+class Q_AUTOTEST_EXPORT QQmlScriptBlob : public QQmlDataBlob
+{
+public:
+ QQmlScriptBlob(const QUrl &, QQmlTypeLoader *);
+ ~QQmlScriptBlob();
+
+ struct ScriptReference
+ {
+ ScriptReference() : script(0) {}
+
+ QQmlScript::Location location;
+ QString qualifier;
+ QQmlScriptBlob *script;
+ };
+
+ QQmlScript::Object::ScriptBlock::Pragmas pragmas() const;
+
+ QQmlTypeLoader *typeLoader() const;
+ const QQmlImports &imports() const;
+
+ QQmlScriptData *scriptData() const;
+
+protected:
+ virtual void dataReceived(const QByteArray &);
+ virtual void done();
+
+private:
+ QQmlScript::Object::ScriptBlock::Pragmas m_pragmas;
+ QString m_source;
+
+ QQmlImports m_imports;
+ QList<ScriptReference> m_scripts;
+ QQmlScriptData *m_scriptData;
+
+ QQmlTypeLoader *m_typeLoader;
+};
+
+class Q_AUTOTEST_EXPORT QQmlQmldirData : public QQmlDataBlob
+{
+public:
+ QQmlQmldirData(const QUrl &);
+
+ const QQmlDirComponents &dirComponents() const;
+
+protected:
+ virtual void dataReceived(const QByteArray &);
+
+private:
+ QQmlDirComponents m_components;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLTYPELOADER_P_H
diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp
new file mode 100644
index 0000000000..f9d3e7704c
--- /dev/null
+++ b/src/qml/qml/qqmltypenamecache.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmltypenamecache_p.h"
+
+#include "qqmlengine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQmlTypeNameCache::QQmlTypeNameCache()
+{
+}
+
+QQmlTypeNameCache::~QQmlTypeNameCache()
+{
+}
+
+void QQmlTypeNameCache::add(const QHashedString &name, int importedScriptIndex, const QHashedString &nameSpace)
+{
+ Import import;
+ import.scriptIndex = importedScriptIndex;
+
+ if (nameSpace.length() != 0) {
+ Import *i = m_namedImports.value(nameSpace);
+ Q_ASSERT(i != 0);
+ m_namespacedImports[i].insert(name, import);
+ return;
+ }
+
+ if (m_namedImports.contains(name))
+ return;
+
+ m_namedImports.insert(name, import);
+}
+
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name)
+{
+ Result result = query(m_namedImports, name);
+
+ if (!result.isValid())
+ result = typeSearch(m_anonymousImports, name);
+
+ return result;
+}
+
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
+ const void *importNamespace)
+{
+ Q_ASSERT(importNamespace);
+ const Import *i = static_cast<const Import *>(importNamespace);
+ Q_ASSERT(i->scriptIndex == -1);
+
+ return typeSearch(i->modules, name);
+}
+
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedV8String &name)
+{
+ Result result = query(m_namedImports, name);
+
+ if (!result.isValid())
+ result = typeSearch(m_anonymousImports, name);
+
+ return result;
+}
+
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedV8String &name, const void *importNamespace)
+{
+ Q_ASSERT(importNamespace);
+ const Import *i = static_cast<const Import *>(importNamespace);
+ Q_ASSERT(i->scriptIndex == -1);
+
+ QMap<const Import *, QStringHash<Import> >::const_iterator it = m_namespacedImports.find(i);
+ if (it != m_namespacedImports.constEnd())
+ return query(*it, name);
+
+ return typeSearch(i->modules, name);
+}
+
+QQmlMetaType::ModuleApiInstance *QQmlTypeNameCache::moduleApi(const void *importNamespace)
+{
+ Q_ASSERT(importNamespace);
+ const Import *i = static_cast<const Import *>(importNamespace);
+ Q_ASSERT(i->scriptIndex == -1);
+
+ return i->moduleApi;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h
new file mode 100644
index 0000000000..a9268db37a
--- /dev/null
+++ b/src/qml/qml/qqmltypenamecache_p.h
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLTYPENAMECACHE_P_H
+#define QQMLTYPENAMECACHE_P_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 <private/qqmlrefcount_p.h>
+#include "qqmlcleanup_p.h"
+#include "qqmlmetatype_p.h"
+
+#include <private/qhashedstring_p.h>
+
+#include <QtCore/qvector.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlType;
+class QQmlEngine;
+class QQmlTypeNameCache : public QQmlRefCount
+{
+public:
+ QQmlTypeNameCache();
+ virtual ~QQmlTypeNameCache();
+
+ inline bool isEmpty() const;
+
+ void add(const QHashedString &name, int sciptIndex = -1, const QHashedString &nameSpace = QHashedString());
+
+ struct Result {
+ inline Result();
+ inline Result(const void *importNamespace);
+ inline Result(QQmlType *type);
+ inline Result(int scriptIndex);
+ inline Result(const Result &);
+
+ inline bool isValid() const;
+
+ QQmlType *type;
+ const void *importNamespace;
+ int scriptIndex;
+ };
+ Result query(const QHashedStringRef &);
+ Result query(const QHashedStringRef &, const void *importNamespace);
+ Result query(const QHashedV8String &);
+ Result query(const QHashedV8String &, const void *importNamespace);
+ QQmlMetaType::ModuleApiInstance *moduleApi(const void *importNamespace);
+
+private:
+ friend class QQmlImports;
+
+ struct Import {
+ inline Import();
+ // Imported module
+ QQmlMetaType::ModuleApiInstance *moduleApi;
+ QVector<QQmlTypeModuleVersion> modules;
+
+ // Or, imported script
+ int scriptIndex;
+ };
+
+ template<typename Key>
+ Result query(const QStringHash<Import> &imports, Key key)
+ {
+ Import *i = imports.value(key);
+ if (i) {
+ if (i->scriptIndex != -1) {
+ return Result(i->scriptIndex);
+ } else {
+ return Result(static_cast<const void *>(i));
+ }
+ }
+
+ return Result();
+ }
+
+ template<typename Key>
+ Result typeSearch(const QVector<QQmlTypeModuleVersion> &modules, Key key)
+ {
+ QVector<QQmlTypeModuleVersion>::const_iterator end = modules.constEnd();
+ for (QVector<QQmlTypeModuleVersion>::const_iterator it = modules.constBegin(); it != end; ++it) {
+ if (QQmlType *type = it->type(key))
+ return Result(type);
+ }
+
+ return Result();
+ }
+
+ QStringHash<Import> m_namedImports;
+ QMap<const Import *, QStringHash<Import> > m_namespacedImports;
+ QVector<QQmlTypeModuleVersion> m_anonymousImports;
+
+ QQmlEngine *engine;
+};
+
+QQmlTypeNameCache::Result::Result()
+: type(0), importNamespace(0), scriptIndex(-1)
+{
+}
+
+QQmlTypeNameCache::Result::Result(const void *importNamespace)
+: type(0), importNamespace(importNamespace), scriptIndex(-1)
+{
+}
+
+QQmlTypeNameCache::Result::Result(QQmlType *type)
+: type(type), importNamespace(0), scriptIndex(-1)
+{
+}
+
+QQmlTypeNameCache::Result::Result(int scriptIndex)
+: type(0), importNamespace(0), scriptIndex(scriptIndex)
+{
+}
+
+QQmlTypeNameCache::Result::Result(const Result &o)
+: type(o.type), importNamespace(o.importNamespace), scriptIndex(o.scriptIndex)
+{
+}
+
+bool QQmlTypeNameCache::Result::isValid() const
+{
+ return type || importNamespace || scriptIndex != -1;
+}
+
+QQmlTypeNameCache::Import::Import()
+: moduleApi(0), scriptIndex(-1)
+{
+}
+
+bool QQmlTypeNameCache::isEmpty() const
+{
+ return m_namedImports.isEmpty() && m_anonymousImports.isEmpty();
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLTYPENAMECACHE_P_H
+
diff --git a/src/qml/qml/qqmltypenotavailable.cpp b/src/qml/qml/qqmltypenotavailable.cpp
new file mode 100644
index 0000000000..6eb891af71
--- /dev/null
+++ b/src/qml/qml/qqmltypenotavailable.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmltypenotavailable_p.h"
+
+QT_BEGIN_NAMESPACE
+
+int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
+{
+ return qmlRegisterUncreatableType<QQmlTypeNotAvailable>(uri,versionMajor,versionMinor,qmlName,message);
+}
+
+QQmlTypeNotAvailable::QQmlTypeNotAvailable() { }
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmltypenotavailable_p.h b/src/qml/qml/qqmltypenotavailable_p.h
new file mode 100644
index 0000000000..d0618a0686
--- /dev/null
+++ b/src/qml/qml/qqmltypenotavailable_p.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLTYPENOTAVAILABLE_H
+#define QQMLTYPENOTAVAILABLE_H
+
+#include <qqml.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlTypeNotAvailable : public QObject {
+ Q_OBJECT
+public:
+ QQmlTypeNotAvailable();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQmlTypeNotAvailable)
+
+QT_END_HEADER
+
+#endif // QQMLTYPENOTAVAILABLE_H
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp
new file mode 100644
index 0000000000..4ade00f9b4
--- /dev/null
+++ b/src/qml/qml/qqmlvaluetype.cpp
@@ -0,0 +1,868 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlvaluetype_p.h"
+
+#include "qqmlmetatype_p.h"
+#include <private/qfont_p.h>
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+template<typename T>
+int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+
+ QQmlPrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()), 0, 0, 0,
+
+ QString(),
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ 0, 0,
+
+ 0, 0, 0,
+
+ 0, 0,
+
+ 0,
+ 0
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
+QQmlValueTypeFactory::QQmlValueTypeFactory()
+{
+ // ### Optimize
+ for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
+ valueTypes[ii] = valueType(ii);
+}
+
+QQmlValueTypeFactory::~QQmlValueTypeFactory()
+{
+ for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
+ delete valueTypes[ii];
+}
+
+bool QQmlValueTypeFactory::isValueType(int idx)
+{
+ if ((uint)idx < QVariant::UserType
+ && idx != QVariant::StringList
+ && idx != QMetaType::QObjectStar
+ && idx != QMetaType::QWidgetStar
+ && idx != QMetaType::VoidStar
+ && idx != QMetaType::QVariant) {
+ return true;
+ }
+ return false;
+}
+
+void QQmlValueTypeFactory::registerBaseTypes(const char *uri, int versionMajor, int versionMinor)
+{
+ qmlRegisterValueTypeEnums<QQmlEasingValueType>(uri, versionMajor, versionMinor, "Easing");
+ qmlRegisterValueTypeEnums<QQmlFontValueType>(uri, versionMajor, versionMinor, "Font");
+}
+
+void QQmlValueTypeFactory::registerValueTypes()
+{
+ registerBaseTypes("QtQuick", 2, 0);
+}
+
+QQmlValueType *QQmlValueTypeFactory::valueType(int t)
+{
+ QQmlValueType *rv = 0;
+
+ switch (t) {
+ case QVariant::Point:
+ rv = new QQmlPointValueType;
+ break;
+ case QVariant::PointF:
+ rv = new QQmlPointFValueType;
+ break;
+ case QVariant::Size:
+ rv = new QQmlSizeValueType;
+ break;
+ case QVariant::SizeF:
+ rv = new QQmlSizeFValueType;
+ break;
+ case QVariant::Rect:
+ rv = new QQmlRectValueType;
+ break;
+ case QVariant::RectF:
+ rv = new QQmlRectFValueType;
+ break;
+ case QVariant::Vector2D:
+ rv = new QQmlVector2DValueType;
+ break;
+ case QVariant::Vector3D:
+ rv = new QQmlVector3DValueType;
+ break;
+ case QVariant::Vector4D:
+ rv = new QQmlVector4DValueType;
+ break;
+ case QVariant::Quaternion:
+ rv = new QQmlQuaternionValueType;
+ break;
+ case QVariant::Matrix4x4:
+ rv = new QQmlMatrix4x4ValueType;
+ break;
+ case QVariant::EasingCurve:
+ rv = new QQmlEasingValueType;
+ break;
+ case QVariant::Font:
+ rv = new QQmlFontValueType;
+ break;
+ case QVariant::Color:
+ rv = new QQmlColorValueType;
+ break;
+ default:
+ break;
+ }
+
+ Q_ASSERT(!rv || rv->metaObject()->propertyCount() < 32);
+ return rv;
+}
+
+QQmlValueType::QQmlValueType(QObject *parent)
+: QObject(parent)
+{
+}
+
+#define QML_VALUETYPE_READWRITE(name, cpptype, var) \
+ QQml ## name ## ValueType::QQml ## name ## ValueType(QObject *parent) \
+ : QQmlValueType(parent) \
+ { \
+ } \
+ void QQml ## name ## ValueType::read(QObject *obj, int idx) \
+ { \
+ void *a[] = { &var, 0 }; \
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); \
+ onLoad(); \
+ } \
+ void QQml ## name ## ValueType::write(QObject *obj, int idx, \
+ QQmlPropertyPrivate::WriteFlags flags) \
+ { \
+ int status = -1; \
+ void *a[] = { &var, 0, &status, &flags }; \
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); \
+ } \
+ bool QQml ## name ## ValueType::isEqual(const QVariant &value) const \
+ { \
+ return QVariant(var) == value; \
+ } \
+ QVariant QQml ## name ## ValueType::value() \
+ { \
+ return QVariant(var); \
+ } \
+ void QQml ## name ## ValueType::setValue(const QVariant &value) \
+ { \
+ var = qvariant_cast<cpptype>(value); \
+ onLoad(); \
+ }
+
+QML_VALUETYPE_READWRITE(PointF, QPointF, point);
+QML_VALUETYPE_READWRITE(Point, QPoint, point);
+QML_VALUETYPE_READWRITE(SizeF, QSizeF, size);
+QML_VALUETYPE_READWRITE(Size, QSize, size);
+QML_VALUETYPE_READWRITE(RectF, QRectF, rect);
+QML_VALUETYPE_READWRITE(Rect, QRect, rect);
+QML_VALUETYPE_READWRITE(Vector2D, QVector2D, vector);
+QML_VALUETYPE_READWRITE(Vector3D, QVector3D, vector);
+QML_VALUETYPE_READWRITE(Vector4D, QVector4D, vector);
+QML_VALUETYPE_READWRITE(Quaternion, QQuaternion, quaternion);
+QML_VALUETYPE_READWRITE(Matrix4x4, QMatrix4x4, matrix);
+QML_VALUETYPE_READWRITE(Easing, QEasingCurve, easing);
+QML_VALUETYPE_READWRITE(Font, QFont, font);
+QML_VALUETYPE_READWRITE(Color, QColor, color);
+
+QString QQmlPointFValueType::toString() const
+{
+ return QString(QLatin1String("QPointF(%1, %2)")).arg(point.x()).arg(point.y());
+}
+
+qreal QQmlPointFValueType::x() const
+{
+ return point.x();
+}
+
+qreal QQmlPointFValueType::y() const
+{
+ return point.y();
+}
+
+void QQmlPointFValueType::setX(qreal x)
+{
+ point.setX(x);
+}
+
+void QQmlPointFValueType::setY(qreal y)
+{
+ point.setY(y);
+}
+
+QString QQmlPointValueType::toString() const
+{
+ return QString(QLatin1String("QPoint(%1, %2)")).arg(point.x()).arg(point.y());
+}
+
+int QQmlPointValueType::x() const
+{
+ return point.x();
+}
+
+int QQmlPointValueType::y() const
+{
+ return point.y();
+}
+
+void QQmlPointValueType::setX(int x)
+{
+ point.setX(x);
+}
+
+void QQmlPointValueType::setY(int y)
+{
+ point.setY(y);
+}
+
+QString QQmlSizeFValueType::toString() const
+{
+ return QString(QLatin1String("QSizeF(%1, %2)")).arg(size.width()).arg(size.height());
+}
+
+qreal QQmlSizeFValueType::width() const
+{
+ return size.width();
+}
+
+qreal QQmlSizeFValueType::height() const
+{
+ return size.height();
+}
+
+void QQmlSizeFValueType::setWidth(qreal w)
+{
+ size.setWidth(w);
+}
+
+void QQmlSizeFValueType::setHeight(qreal h)
+{
+ size.setHeight(h);
+}
+
+QString QQmlSizeValueType::toString() const
+{
+ return QString(QLatin1String("QSize(%1, %2)")).arg(size.width()).arg(size.height());
+}
+
+int QQmlSizeValueType::width() const
+{
+ return size.width();
+}
+
+int QQmlSizeValueType::height() const
+{
+ return size.height();
+}
+
+void QQmlSizeValueType::setWidth(int w)
+{
+ size.setWidth(w);
+}
+
+void QQmlSizeValueType::setHeight(int h)
+{
+ size.setHeight(h);
+}
+
+QString QQmlRectFValueType::toString() const
+{
+ return QString(QLatin1String("QRectF(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
+}
+
+qreal QQmlRectFValueType::x() const
+{
+ return rect.x();
+}
+
+qreal QQmlRectFValueType::y() const
+{
+ return rect.y();
+}
+
+void QQmlRectFValueType::setX(qreal x)
+{
+ rect.moveLeft(x);
+}
+
+void QQmlRectFValueType::setY(qreal y)
+{
+ rect.moveTop(y);
+}
+
+qreal QQmlRectFValueType::width() const
+{
+ return rect.width();
+}
+
+qreal QQmlRectFValueType::height() const
+{
+ return rect.height();
+}
+
+void QQmlRectFValueType::setWidth(qreal w)
+{
+ rect.setWidth(w);
+}
+
+void QQmlRectFValueType::setHeight(qreal h)
+{
+ rect.setHeight(h);
+}
+
+QString QQmlRectValueType::toString() const
+{
+ return QString(QLatin1String("QRect(%1, %2, %3, %4)")).arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
+}
+
+int QQmlRectValueType::x() const
+{
+ return rect.x();
+}
+
+int QQmlRectValueType::y() const
+{
+ return rect.y();
+}
+
+void QQmlRectValueType::setX(int x)
+{
+ rect.moveLeft(x);
+}
+
+void QQmlRectValueType::setY(int y)
+{
+ rect.moveTop(y);
+}
+
+int QQmlRectValueType::width() const
+{
+ return rect.width();
+}
+
+int QQmlRectValueType::height() const
+{
+ return rect.height();
+}
+
+void QQmlRectValueType::setWidth(int w)
+{
+ rect.setWidth(w);
+}
+
+void QQmlRectValueType::setHeight(int h)
+{
+ rect.setHeight(h);
+}
+
+QString QQmlVector2DValueType::toString() const
+{
+ return QString(QLatin1String("QVector2D(%1, %2)")).arg(vector.x()).arg(vector.y());
+}
+
+qreal QQmlVector2DValueType::x() const
+{
+ return vector.x();
+}
+
+qreal QQmlVector2DValueType::y() const
+{
+ return vector.y();
+}
+
+void QQmlVector2DValueType::setX(qreal x)
+{
+ vector.setX(x);
+}
+
+void QQmlVector2DValueType::setY(qreal y)
+{
+ vector.setY(y);
+}
+
+QString QQmlVector3DValueType::toString() const
+{
+ return QString(QLatin1String("QVector3D(%1, %2, %3)")).arg(vector.x()).arg(vector.y()).arg(vector.z());
+}
+
+qreal QQmlVector3DValueType::x() const
+{
+ return vector.x();
+}
+
+qreal QQmlVector3DValueType::y() const
+{
+ return vector.y();
+}
+
+qreal QQmlVector3DValueType::z() const
+{
+ return vector.z();
+}
+
+void QQmlVector3DValueType::setX(qreal x)
+{
+ vector.setX(x);
+}
+
+void QQmlVector3DValueType::setY(qreal y)
+{
+ vector.setY(y);
+}
+
+void QQmlVector3DValueType::setZ(qreal z)
+{
+ vector.setZ(z);
+}
+
+QString QQmlVector4DValueType::toString() const
+{
+ return QString(QLatin1String("QVector4D(%1, %2, %3, %4)")).arg(vector.x()).arg(vector.y()).arg(vector.z()).arg(vector.w());
+}
+
+qreal QQmlVector4DValueType::x() const
+{
+ return vector.x();
+}
+
+qreal QQmlVector4DValueType::y() const
+{
+ return vector.y();
+}
+
+qreal QQmlVector4DValueType::z() const
+{
+ return vector.z();
+}
+
+qreal QQmlVector4DValueType::w() const
+{
+ return vector.w();
+}
+
+void QQmlVector4DValueType::setX(qreal x)
+{
+ vector.setX(x);
+}
+
+void QQmlVector4DValueType::setY(qreal y)
+{
+ vector.setY(y);
+}
+
+void QQmlVector4DValueType::setZ(qreal z)
+{
+ vector.setZ(z);
+}
+
+void QQmlVector4DValueType::setW(qreal w)
+{
+ vector.setW(w);
+}
+
+QString QQmlQuaternionValueType::toString() const
+{
+ return QString(QLatin1String("QQuaternion(%1, %2, %3, %4)")).arg(quaternion.scalar()).arg(quaternion.x()).arg(quaternion.y()).arg(quaternion.z());
+}
+
+qreal QQmlQuaternionValueType::scalar() const
+{
+ return quaternion.scalar();
+}
+
+qreal QQmlQuaternionValueType::x() const
+{
+ return quaternion.x();
+}
+
+qreal QQmlQuaternionValueType::y() const
+{
+ return quaternion.y();
+}
+
+qreal QQmlQuaternionValueType::z() const
+{
+ return quaternion.z();
+}
+
+void QQmlQuaternionValueType::setScalar(qreal scalar)
+{
+ quaternion.setScalar(scalar);
+}
+
+void QQmlQuaternionValueType::setX(qreal x)
+{
+ quaternion.setX(x);
+}
+
+void QQmlQuaternionValueType::setY(qreal y)
+{
+ quaternion.setY(y);
+}
+
+void QQmlQuaternionValueType::setZ(qreal z)
+{
+ quaternion.setZ(z);
+}
+
+QString QQmlMatrix4x4ValueType::toString() const
+{
+ return QString(QLatin1String("QMatrix4x4(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16)"))
+ .arg(matrix(0, 0)).arg(matrix(0, 1)).arg(matrix(0, 2)).arg(matrix(0, 3))
+ .arg(matrix(1, 0)).arg(matrix(1, 1)).arg(matrix(1, 2)).arg(matrix(1, 3))
+ .arg(matrix(2, 0)).arg(matrix(2, 1)).arg(matrix(2, 2)).arg(matrix(2, 3))
+ .arg(matrix(3, 0)).arg(matrix(3, 1)).arg(matrix(3, 2)).arg(matrix(3, 3));
+}
+
+QString QQmlEasingValueType::toString() const
+{
+ return QString(QLatin1String("QEasingCurve(%1, %2, %3, %4)")).arg(easing.type()).arg(easing.amplitude()).arg(easing.overshoot()).arg(easing.period());
+}
+
+QQmlEasingValueType::Type QQmlEasingValueType::type() const
+{
+ return (QQmlEasingValueType::Type)easing.type();
+}
+
+qreal QQmlEasingValueType::amplitude() const
+{
+ return easing.amplitude();
+}
+
+qreal QQmlEasingValueType::overshoot() const
+{
+ return easing.overshoot();
+}
+
+qreal QQmlEasingValueType::period() const
+{
+ return easing.period();
+}
+
+void QQmlEasingValueType::setType(QQmlEasingValueType::Type type)
+{
+ easing.setType((QEasingCurve::Type)type);
+}
+
+void QQmlEasingValueType::setAmplitude(qreal amplitude)
+{
+ easing.setAmplitude(amplitude);
+}
+
+void QQmlEasingValueType::setOvershoot(qreal overshoot)
+{
+ easing.setOvershoot(overshoot);
+}
+
+void QQmlEasingValueType::setPeriod(qreal period)
+{
+ easing.setPeriod(period);
+}
+
+void QQmlEasingValueType::setBezierCurve(const QVariantList &customCurveVariant)
+{
+ if (customCurveVariant.isEmpty())
+ return;
+
+ QVariantList variantList = customCurveVariant;
+ if ((variantList.count() % 6) == 0) {
+ bool allRealsOk = true;
+ QList<qreal> reals;
+ for (int i = 0; i < variantList.count(); i++) {
+ bool ok;
+ const qreal real = variantList.at(i).toReal(&ok);
+ reals.append(real);
+ if (!ok)
+ allRealsOk = false;
+ }
+ if (allRealsOk) {
+ QEasingCurve newEasingCurve(QEasingCurve::BezierSpline);
+ for (int i = 0; i < reals.count() / 6; i++) {
+ const qreal c1x = reals.at(i * 6);
+ const qreal c1y = reals.at(i * 6 + 1);
+ const qreal c2x = reals.at(i * 6 + 2);
+ const qreal c2y = reals.at(i * 6 + 3);
+ const qreal c3x = reals.at(i * 6 + 4);
+ const qreal c3y = reals.at(i * 6 + 5);
+
+ const QPointF c1(c1x, c1y);
+ const QPointF c2(c2x, c2y);
+ const QPointF c3(c3x, c3y);
+
+ newEasingCurve.addCubicBezierSegment(c1, c2, c3);
+ easing = newEasingCurve;
+ }
+ }
+ }
+}
+
+QVariantList QQmlEasingValueType::bezierCurve() const
+{
+ QVariantList rv;
+ QList<QPointF> points = easing.cubicBezierSpline();
+ for (int ii = 0; ii < points.count(); ++ii)
+ rv << QVariant(points.at(ii).x()) << QVariant(points.at(ii).y());
+ return rv;
+}
+
+void QQmlFontValueType::onLoad()
+{
+ pixelSizeSet = false;
+ pointSizeSet = false;
+}
+
+QString QQmlFontValueType::toString() const
+{
+ return QString(QLatin1String("QFont(%1)")).arg(font.toString());
+}
+
+QString QQmlFontValueType::family() const
+{
+ return font.family();
+}
+
+void QQmlFontValueType::setFamily(const QString &family)
+{
+ font.setFamily(family);
+}
+
+bool QQmlFontValueType::bold() const
+{
+ return font.bold();
+}
+
+void QQmlFontValueType::setBold(bool b)
+{
+ font.setBold(b);
+}
+
+QQmlFontValueType::FontWeight QQmlFontValueType::weight() const
+{
+ return (QQmlFontValueType::FontWeight)font.weight();
+}
+
+void QQmlFontValueType::setWeight(QQmlFontValueType::FontWeight w)
+{
+ font.setWeight((QFont::Weight)w);
+}
+
+bool QQmlFontValueType::italic() const
+{
+ return font.italic();
+}
+
+void QQmlFontValueType::setItalic(bool b)
+{
+ font.setItalic(b);
+}
+
+bool QQmlFontValueType::underline() const
+{
+ return font.underline();
+}
+
+void QQmlFontValueType::setUnderline(bool b)
+{
+ font.setUnderline(b);
+}
+
+bool QQmlFontValueType::overline() const
+{
+ return font.overline();
+}
+
+void QQmlFontValueType::setOverline(bool b)
+{
+ font.setOverline(b);
+}
+
+bool QQmlFontValueType::strikeout() const
+{
+ return font.strikeOut();
+}
+
+void QQmlFontValueType::setStrikeout(bool b)
+{
+ font.setStrikeOut(b);
+}
+
+qreal QQmlFontValueType::pointSize() const
+{
+ if (font.pointSizeF() == -1) {
+ if (dpi.isNull)
+ dpi = qt_defaultDpi();
+ return font.pixelSize() * qreal(72.) / qreal(dpi);
+ }
+ return font.pointSizeF();
+}
+
+void QQmlFontValueType::setPointSize(qreal size)
+{
+ if (pixelSizeSet) {
+ qWarning() << "Both point size and pixel size set. Using pixel size.";
+ return;
+ }
+
+ if (size >= 0.0) {
+ pointSizeSet = true;
+ font.setPointSizeF(size);
+ } else {
+ pointSizeSet = false;
+ }
+}
+
+int QQmlFontValueType::pixelSize() const
+{
+ if (font.pixelSize() == -1) {
+ if (dpi.isNull)
+ dpi = qt_defaultDpi();
+ return (font.pointSizeF() * dpi) / qreal(72.);
+ }
+ return font.pixelSize();
+}
+
+void QQmlFontValueType::setPixelSize(int size)
+{
+ if (size >0) {
+ if (pointSizeSet)
+ qWarning() << "Both point size and pixel size set. Using pixel size.";
+ font.setPixelSize(size);
+ pixelSizeSet = true;
+ } else {
+ pixelSizeSet = false;
+ }
+}
+
+QQmlFontValueType::Capitalization QQmlFontValueType::capitalization() const
+{
+ return (QQmlFontValueType::Capitalization)font.capitalization();
+}
+
+void QQmlFontValueType::setCapitalization(QQmlFontValueType::Capitalization c)
+{
+ font.setCapitalization((QFont::Capitalization)c);
+}
+
+qreal QQmlFontValueType::letterSpacing() const
+{
+ return font.letterSpacing();
+}
+
+void QQmlFontValueType::setLetterSpacing(qreal size)
+{
+ font.setLetterSpacing(QFont::AbsoluteSpacing, size);
+}
+
+qreal QQmlFontValueType::wordSpacing() const
+{
+ return font.wordSpacing();
+}
+
+void QQmlFontValueType::setWordSpacing(qreal size)
+{
+ font.setWordSpacing(size);
+}
+
+QString QQmlColorValueType::toString() const
+{
+ // special case - to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
+ return QVariant(color).toString();
+}
+
+qreal QQmlColorValueType::r() const
+{
+ return color.redF();
+}
+
+qreal QQmlColorValueType::g() const
+{
+ return color.greenF();
+}
+
+qreal QQmlColorValueType::b() const
+{
+ return color.blueF();
+}
+
+qreal QQmlColorValueType::a() const
+{
+ return color.alphaF();
+}
+
+void QQmlColorValueType::setR(qreal r)
+{
+ color.setRedF(r);
+}
+
+void QQmlColorValueType::setG(qreal g)
+{
+ color.setGreenF(g);
+}
+
+void QQmlColorValueType::setB(qreal b)
+{
+ color.setBlueF(b);
+}
+
+void QQmlColorValueType::setA(qreal a)
+{
+ color.setAlphaF(a);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
new file mode 100644
index 0000000000..71817c2a2d
--- /dev/null
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -0,0 +1,635 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLVALUETYPE_P_H
+#define QQMLVALUETYPE_P_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 "qqmlproperty.h"
+#include "qqmlproperty_p.h"
+#include "qqmlnullablevalue_p_p.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qeasingcurve.h>
+#include <QtCore/qvariant.h>
+#include <QtGui/qvector2d.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
+#include <QtGui/qmatrix4x4.h>
+#include <QtGui/qquaternion.h>
+#include <QtGui/qfont.h>
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QML_PRIVATE_EXPORT QQmlValueType : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlValueType(QObject *parent = 0);
+ virtual void read(QObject *, int) = 0;
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags flags) = 0;
+ virtual QVariant value() = 0;
+ virtual void setValue(const QVariant &) = 0;
+
+ virtual QString toString() const = 0;
+ virtual bool isEqual(const QVariant &value) const = 0;
+
+ inline void onLoad();
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlValueTypeFactory
+{
+public:
+ QQmlValueTypeFactory();
+ ~QQmlValueTypeFactory();
+ static bool isValueType(int);
+ static QQmlValueType *valueType(int);
+
+ static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor);
+ static void registerValueTypes();
+
+ QQmlValueType *operator[](int idx) const {
+ if (idx >= (int)QVariant::UserType) return 0;
+ else return valueTypes[idx];
+ }
+
+private:
+ QQmlValueType *valueTypes[QVariant::UserType - 1];
+};
+
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlPointFValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_OBJECT
+public:
+ QQmlPointFValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal x() const;
+ qreal y() const;
+ void setX(qreal);
+ void setY(qreal);
+
+private:
+ QPointF point;
+};
+
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlPointValueType : public QQmlValueType
+{
+ Q_PROPERTY(int x READ x WRITE setX)
+ Q_PROPERTY(int y READ y WRITE setY)
+ Q_OBJECT
+public:
+ QQmlPointValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ int x() const;
+ int y() const;
+ void setX(int);
+ void setY(int);
+
+private:
+ QPoint point;
+};
+
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlSizeFValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal width READ width WRITE setWidth)
+ Q_PROPERTY(qreal height READ height WRITE setHeight)
+ Q_OBJECT
+public:
+ QQmlSizeFValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal width() const;
+ qreal height() const;
+ void setWidth(qreal);
+ void setHeight(qreal);
+
+private:
+ QSizeF size;
+};
+
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlSizeValueType : public QQmlValueType
+{
+ Q_PROPERTY(int width READ width WRITE setWidth)
+ Q_PROPERTY(int height READ height WRITE setHeight)
+ Q_OBJECT
+public:
+ QQmlSizeValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ int width() const;
+ int height() const;
+ void setWidth(int);
+ void setHeight(int);
+
+private:
+ QSize size;
+};
+
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlRectFValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal width READ width WRITE setWidth)
+ Q_PROPERTY(qreal height READ height WRITE setHeight)
+ Q_OBJECT
+public:
+ QQmlRectFValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal x() const;
+ qreal y() const;
+ void setX(qreal);
+ void setY(qreal);
+
+ qreal width() const;
+ qreal height() const;
+ void setWidth(qreal);
+ void setHeight(qreal);
+
+private:
+ QRectF rect;
+};
+
+// Exported for QtQuick1
+class Q_QML_PRIVATE_EXPORT QQmlRectValueType : public QQmlValueType
+{
+ Q_PROPERTY(int x READ x WRITE setX)
+ Q_PROPERTY(int y READ y WRITE setY)
+ Q_PROPERTY(int width READ width WRITE setWidth)
+ Q_PROPERTY(int height READ height WRITE setHeight)
+ Q_OBJECT
+public:
+ QQmlRectValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ int x() const;
+ int y() const;
+ void setX(int);
+ void setY(int);
+
+ int width() const;
+ int height() const;
+ void setWidth(int);
+ void setHeight(int);
+
+private:
+ QRect rect;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlVector2DValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_OBJECT
+public:
+ QQmlVector2DValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal x() const;
+ qreal y() const;
+ void setX(qreal);
+ void setY(qreal);
+
+private:
+ QVector2D vector;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlVector3DValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal z READ z WRITE setZ)
+ Q_OBJECT
+public:
+ QQmlVector3DValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ void setX(qreal);
+ void setY(qreal);
+ void setZ(qreal);
+
+private:
+ QVector3D vector;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlVector4DValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal z READ z WRITE setZ)
+ Q_PROPERTY(qreal w READ w WRITE setW)
+ Q_OBJECT
+public:
+ QQmlVector4DValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ qreal w() const;
+ void setX(qreal);
+ void setY(qreal);
+ void setZ(qreal);
+ void setW(qreal);
+
+private:
+ QVector4D vector;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlQuaternionValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal scalar READ scalar WRITE setScalar)
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal z READ z WRITE setZ)
+ Q_OBJECT
+public:
+ QQmlQuaternionValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal scalar() const;
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ void setScalar(qreal);
+ void setX(qreal);
+ void setY(qreal);
+ void setZ(qreal);
+
+private:
+ QQuaternion quaternion;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlMatrix4x4ValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal m11 READ m11 WRITE setM11)
+ Q_PROPERTY(qreal m12 READ m12 WRITE setM12)
+ Q_PROPERTY(qreal m13 READ m13 WRITE setM13)
+ Q_PROPERTY(qreal m14 READ m14 WRITE setM14)
+ Q_PROPERTY(qreal m21 READ m21 WRITE setM21)
+ Q_PROPERTY(qreal m22 READ m22 WRITE setM22)
+ Q_PROPERTY(qreal m23 READ m23 WRITE setM23)
+ Q_PROPERTY(qreal m24 READ m24 WRITE setM24)
+ Q_PROPERTY(qreal m31 READ m31 WRITE setM31)
+ Q_PROPERTY(qreal m32 READ m32 WRITE setM32)
+ Q_PROPERTY(qreal m33 READ m33 WRITE setM33)
+ Q_PROPERTY(qreal m34 READ m34 WRITE setM34)
+ Q_PROPERTY(qreal m41 READ m41 WRITE setM41)
+ Q_PROPERTY(qreal m42 READ m42 WRITE setM42)
+ Q_PROPERTY(qreal m43 READ m43 WRITE setM43)
+ Q_PROPERTY(qreal m44 READ m44 WRITE setM44)
+ Q_OBJECT
+public:
+ QQmlMatrix4x4ValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal m11() const { return matrix(0, 0); }
+ qreal m12() const { return matrix(0, 1); }
+ qreal m13() const { return matrix(0, 2); }
+ qreal m14() const { return matrix(0, 3); }
+ qreal m21() const { return matrix(1, 0); }
+ qreal m22() const { return matrix(1, 1); }
+ qreal m23() const { return matrix(1, 2); }
+ qreal m24() const { return matrix(1, 3); }
+ qreal m31() const { return matrix(2, 0); }
+ qreal m32() const { return matrix(2, 1); }
+ qreal m33() const { return matrix(2, 2); }
+ qreal m34() const { return matrix(2, 3); }
+ qreal m41() const { return matrix(3, 0); }
+ qreal m42() const { return matrix(3, 1); }
+ qreal m43() const { return matrix(3, 2); }
+ qreal m44() const { return matrix(3, 3); }
+
+ void setM11(qreal value) { matrix(0, 0) = value; }
+ void setM12(qreal value) { matrix(0, 1) = value; }
+ void setM13(qreal value) { matrix(0, 2) = value; }
+ void setM14(qreal value) { matrix(0, 3) = value; }
+ void setM21(qreal value) { matrix(1, 0) = value; }
+ void setM22(qreal value) { matrix(1, 1) = value; }
+ void setM23(qreal value) { matrix(1, 2) = value; }
+ void setM24(qreal value) { matrix(1, 3) = value; }
+ void setM31(qreal value) { matrix(2, 0) = value; }
+ void setM32(qreal value) { matrix(2, 1) = value; }
+ void setM33(qreal value) { matrix(2, 2) = value; }
+ void setM34(qreal value) { matrix(2, 3) = value; }
+ void setM41(qreal value) { matrix(3, 0) = value; }
+ void setM42(qreal value) { matrix(3, 1) = value; }
+ void setM43(qreal value) { matrix(3, 2) = value; }
+ void setM44(qreal value) { matrix(3, 3) = value; }
+
+private:
+ QMatrix4x4 matrix;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlEasingValueType : public QQmlValueType
+{
+ Q_OBJECT
+ Q_ENUMS(Type)
+
+ Q_PROPERTY(QQmlEasingValueType::Type type READ type WRITE setType)
+ Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude)
+ Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot)
+ Q_PROPERTY(qreal period READ period WRITE setPeriod)
+ Q_PROPERTY(QVariantList bezierCurve READ bezierCurve WRITE setBezierCurve)
+public:
+ enum Type {
+ Linear = QEasingCurve::Linear,
+ InQuad = QEasingCurve::InQuad, OutQuad = QEasingCurve::OutQuad,
+ InOutQuad = QEasingCurve::InOutQuad, OutInQuad = QEasingCurve::OutInQuad,
+ InCubic = QEasingCurve::InCubic, OutCubic = QEasingCurve::OutCubic,
+ InOutCubic = QEasingCurve::InOutCubic, OutInCubic = QEasingCurve::OutInCubic,
+ InQuart = QEasingCurve::InQuart, OutQuart = QEasingCurve::OutQuart,
+ InOutQuart = QEasingCurve::InOutQuart, OutInQuart = QEasingCurve::OutInQuart,
+ InQuint = QEasingCurve::InQuint, OutQuint = QEasingCurve::OutQuint,
+ InOutQuint = QEasingCurve::InOutQuint, OutInQuint = QEasingCurve::OutInQuint,
+ InSine = QEasingCurve::InSine, OutSine = QEasingCurve::OutSine,
+ InOutSine = QEasingCurve::InOutSine, OutInSine = QEasingCurve::OutInSine,
+ InExpo = QEasingCurve::InExpo, OutExpo = QEasingCurve::OutExpo,
+ InOutExpo = QEasingCurve::InOutExpo, OutInExpo = QEasingCurve::OutInExpo,
+ InCirc = QEasingCurve::InCirc, OutCirc = QEasingCurve::OutCirc,
+ InOutCirc = QEasingCurve::InOutCirc, OutInCirc = QEasingCurve::OutInCirc,
+ InElastic = QEasingCurve::InElastic, OutElastic = QEasingCurve::OutElastic,
+ InOutElastic = QEasingCurve::InOutElastic, OutInElastic = QEasingCurve::OutInElastic,
+ InBack = QEasingCurve::InBack, OutBack = QEasingCurve::OutBack,
+ InOutBack = QEasingCurve::InOutBack, OutInBack = QEasingCurve::OutInBack,
+ InBounce = QEasingCurve::InBounce, OutBounce = QEasingCurve::OutBounce,
+ InOutBounce = QEasingCurve::InOutBounce, OutInBounce = QEasingCurve::OutInBounce,
+ InCurve = QEasingCurve::InCurve, OutCurve = QEasingCurve::OutCurve,
+ SineCurve = QEasingCurve::SineCurve, CosineCurve = QEasingCurve::CosineCurve,
+ Bezier = QEasingCurve::BezierSpline
+ };
+
+ QQmlEasingValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ Type type() const;
+ qreal amplitude() const;
+ qreal overshoot() const;
+ qreal period() const;
+ void setType(Type);
+ void setAmplitude(qreal);
+ void setOvershoot(qreal);
+ void setPeriod(qreal);
+ void setBezierCurve(const QVariantList &);
+ QVariantList bezierCurve() const;
+
+
+private:
+ QEasingCurve easing;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlFontValueType : public QQmlValueType
+{
+ Q_OBJECT
+ Q_ENUMS(FontWeight)
+ Q_ENUMS(Capitalization)
+
+ Q_PROPERTY(QString family READ family WRITE setFamily)
+ Q_PROPERTY(bool bold READ bold WRITE setBold)
+ Q_PROPERTY(FontWeight weight READ weight WRITE setWeight)
+ Q_PROPERTY(bool italic READ italic WRITE setItalic)
+ Q_PROPERTY(bool underline READ underline WRITE setUnderline)
+ Q_PROPERTY(bool overline READ overline WRITE setOverline)
+ Q_PROPERTY(bool strikeout READ strikeout WRITE setStrikeout)
+ Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize)
+ Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize)
+ Q_PROPERTY(Capitalization capitalization READ capitalization WRITE setCapitalization)
+ Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing)
+ Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing)
+
+public:
+ enum FontWeight { Light = QFont::Light,
+ Normal = QFont::Normal,
+ DemiBold = QFont::DemiBold,
+ Bold = QFont::Bold,
+ Black = QFont::Black };
+ enum Capitalization { MixedCase = QFont::MixedCase,
+ AllUppercase = QFont::AllUppercase,
+ AllLowercase = QFont::AllLowercase,
+ SmallCaps = QFont::SmallCaps,
+ Capitalize = QFont::Capitalize };
+
+ QQmlFontValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ QString family() const;
+ void setFamily(const QString &);
+
+ bool bold() const;
+ void setBold(bool b);
+
+ FontWeight weight() const;
+ void setWeight(FontWeight);
+
+ bool italic() const;
+ void setItalic(bool b);
+
+ bool underline() const;
+ void setUnderline(bool b);
+
+ bool overline() const;
+ void setOverline(bool b);
+
+ bool strikeout() const;
+ void setStrikeout(bool b);
+
+ qreal pointSize() const;
+ void setPointSize(qreal size);
+
+ int pixelSize() const;
+ void setPixelSize(int size);
+
+ Capitalization capitalization() const;
+ void setCapitalization(Capitalization);
+
+ qreal letterSpacing() const;
+ void setLetterSpacing(qreal spacing);
+
+ qreal wordSpacing() const;
+ void setWordSpacing(qreal spacing);
+
+ void onLoad();
+private:
+ QFont font;
+ bool pixelSizeSet;
+ bool pointSizeSet;
+ mutable QQmlNullableValue<int> dpi;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlColorValueType : public QQmlValueType
+{
+ Q_PROPERTY(qreal r READ r WRITE setR)
+ Q_PROPERTY(qreal g READ g WRITE setG)
+ Q_PROPERTY(qreal b READ b WRITE setB)
+ Q_PROPERTY(qreal a READ a WRITE setA)
+ Q_OBJECT
+public:
+ QQmlColorValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(const QVariant &value);
+ virtual QString toString() const;
+ virtual bool isEqual(const QVariant &value) const;
+
+ qreal r() const;
+ qreal g() const;
+ qreal b() const;
+ qreal a() const;
+ void setR(qreal);
+ void setG(qreal);
+ void setB(qreal);
+ void setA(qreal);
+
+private:
+ QColor color;
+};
+
+void QQmlValueType::onLoad()
+{
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLVALUETYPE_P_H
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
new file mode 100644
index 0000000000..2b66e00bad
--- /dev/null
+++ b/src/qml/qml/qqmlvme.cpp
@@ -0,0 +1,1370 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlvme_p.h"
+
+#include "qqmlcompiler_p.h"
+#include "qqmlboundsignal_p.h"
+#include "qqmlstringconverters_p.h"
+#include <private/qmetaobjectbuilder_p.h>
+#include <private/qfastmetabuilder_p.h>
+#include "qqmldata_p.h"
+#include "qqml.h"
+#include "qqmlcustomparser_p.h"
+#include "qqmlengine.h"
+#include "qqmlcontext.h"
+#include "qqmlcomponent.h"
+#include "qqmlcomponentattached_p.h"
+#include "qqmlbinding_p.h"
+#include "qqmlengine_p.h"
+#include "qqmlcomponent_p.h"
+#include "qqmlvmemetaobject_p.h"
+#include "qqmlbinding_p_p.h"
+#include "qqmlcontext_p.h"
+#include <private/qv4bindings_p.h>
+#include <private/qv8bindings_p.h>
+#include "qqmlglobal_p.h"
+#include <private/qfinitestack_p.h>
+#include "qqmlscriptstring.h"
+#include "qqmlscriptstring_p.h"
+#include "qqmlpropertyvalueinterceptor_p.h"
+
+#include <QStack>
+#include <QColor>
+#include <QPointF>
+#include <QSizeF>
+#include <QRectF>
+#include <QtCore/qdebug.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtQml/qjsvalue.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QQmlVMETypes;
+
+#define VME_EXCEPTION(desc, line) \
+ { \
+ QQmlError error; \
+ error.setDescription(desc.trimmed()); \
+ error.setLine(line); \
+ error.setUrl(COMP->url); \
+ *errors << error; \
+ goto exceptionExit; \
+ }
+
+void QQmlVME::init(QQmlContextData *ctxt, QQmlCompiledData *comp, int start,
+ QQmlContextData *creation)
+{
+ Q_ASSERT(ctxt);
+ Q_ASSERT(comp);
+
+ if (start == -1) {
+ start = 0;
+ } else {
+ creationContext = creation;
+ }
+
+ State initState;
+ initState.context = ctxt;
+ initState.compiledData = comp;
+ initState.instructionStream = comp->bytecode.constData() + start;
+ states.push(initState);
+
+ typedef QQmlInstruction I;
+ I *i = (I *)initState.instructionStream;
+
+ Q_ASSERT(comp->instructionType(i) == I::Init);
+
+ objects.allocate(i->init.objectStackSize);
+ lists.allocate(i->init.listStackSize);
+ bindValues.allocate(i->init.bindingsSize);
+ parserStatus.allocate(i->init.parserStatusSize);
+
+#ifdef QML_ENABLE_TRACE
+ parserStatusData.allocate(i->init.parserStatusSize);
+ rootComponent = comp;
+#endif
+
+ rootContext = 0;
+ engine = ctxt->engine;
+}
+
+bool QQmlVME::initDeferred(QObject *object)
+{
+ QQmlData *data = QQmlData::get(object);
+
+ if (!data || !data->context || !data->deferredComponent)
+ return false;
+
+ QQmlContextData *ctxt = data->context;
+ QQmlCompiledData *comp = data->deferredComponent;
+ int start = data->deferredIdx;
+
+ State initState;
+ initState.flags = State::Deferred;
+ initState.context = ctxt;
+ initState.compiledData = comp;
+ initState.instructionStream = comp->bytecode.constData() + start;
+ states.push(initState);
+
+ typedef QQmlInstruction I;
+ I *i = (I *)initState.instructionStream;
+
+ Q_ASSERT(comp->instructionType(i) == I::DeferInit);
+
+ objects.allocate(i->deferInit.objectStackSize);
+ lists.allocate(i->deferInit.listStackSize);
+ bindValues.allocate(i->deferInit.bindingsSize);
+ parserStatus.allocate(i->deferInit.parserStatusSize);
+
+ objects.push(object);
+
+#ifdef QML_ENABLE_TRACE
+ parserStatusData.allocate(i->deferInit.parserStatusSize);
+ rootComponent = comp;
+#endif
+
+ rootContext = 0;
+ engine = ctxt->engine;
+
+ return true;
+}
+
+namespace {
+struct ActiveVMERestorer
+{
+ ActiveVMERestorer(QQmlVME *me, QQmlEnginePrivate *ep)
+ : ep(ep), oldVME(ep->activeVME) { ep->activeVME = me; }
+ ~ActiveVMERestorer() { ep->activeVME = oldVME; }
+
+ QQmlEnginePrivate *ep;
+ QQmlVME *oldVME;
+};
+}
+
+QObject *QQmlVME::execute(QList<QQmlError> *errors, const Interrupt &interrupt)
+{
+ Q_ASSERT(states.count() >= 1);
+
+#ifdef QML_ENABLE_TRACE
+ QQmlTrace trace("VME Execute");
+ trace.addDetail("URL", rootComponent->url);
+#endif
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(states.at(0).context->engine);
+
+ ActiveVMERestorer restore(this, ep);
+
+ QObject *rv = run(errors, interrupt);
+
+ return rv;
+}
+
+inline bool fastHasBinding(QObject *o, int index)
+{
+ QQmlData *ddata = static_cast<QQmlData *>(QObjectPrivate::get(o)->declarativeData);
+
+ return ddata && (ddata->bindingBitsSize > index) &&
+ (ddata->bindingBits[index / 32] & (1 << (index % 32)));
+}
+
+static void removeBindingOnProperty(QObject *o, int index)
+{
+ QQmlAbstractBinding *binding = QQmlPropertyPrivate::setBinding(o, index, -1, 0);
+ if (binding) binding->destroy();
+}
+
+static QVariant variantFromString(const QString &string)
+{
+ return QQmlStringConverters::variantFromString(string);
+}
+
+// XXX we probably need some form of "work count" here to prevent us checking this
+// for every instruction.
+#define QML_BEGIN_INSTR_COMMON(I) { \
+ const QQmlInstructionMeta<(int)QQmlInstruction::I>::DataType &instr = QQmlInstructionMeta<(int)QQmlInstruction::I>::data(*genericInstr); \
+ INSTRUCTIONSTREAM += QQmlInstructionMeta<(int)QQmlInstruction::I>::Size; \
+ Q_UNUSED(instr);
+
+#ifdef QML_THREADED_VME_INTERPRETER
+# define QML_BEGIN_INSTR(I) op_##I: \
+ QML_BEGIN_INSTR_COMMON(I)
+
+# define QML_NEXT_INSTR(I) { \
+ if (watcher.hasRecursed()) return 0; \
+ genericInstr = reinterpret_cast<const QQmlInstruction *>(INSTRUCTIONSTREAM); \
+ goto *genericInstr->common.code; \
+ }
+
+# define QML_END_INSTR(I) } \
+ if (watcher.hasRecursed()) return 0; \
+ genericInstr = reinterpret_cast<const QQmlInstruction *>(INSTRUCTIONSTREAM); \
+ if (interrupt.shouldInterrupt()) return 0; \
+ goto *genericInstr->common.code;
+
+#else
+# define QML_BEGIN_INSTR(I) \
+ case QQmlInstruction::I: \
+ QML_BEGIN_INSTR_COMMON(I)
+
+# define QML_NEXT_INSTR(I) { \
+ if (watcher.hasRecursed()) return 0; \
+ break; \
+ }
+
+# define QML_END_INSTR(I) \
+ if (watcher.hasRecursed() || interrupt.shouldInterrupt()) return 0; \
+ } break;
+#endif
+
+#define QML_STORE_VALUE(name, cpptype, value) \
+ QML_BEGIN_INSTR(name) \
+ cpptype v = value; \
+ void *a[] = { (void *)&v, 0, &status, &flags }; \
+ QObject *target = objects.top(); \
+ CLEAN_PROPERTY(target, instr.propertyIndex); \
+ QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
+ QML_END_INSTR(name)
+
+#define QML_STORE_LIST(name, cpptype, value) \
+ QML_BEGIN_INSTR(name) \
+ cpptype v; \
+ v.append(value); \
+ void *a[] = { (void *)&v, 0, &status, &flags }; \
+ QObject *target = objects.top(); \
+ CLEAN_PROPERTY(target, instr.propertyIndex); \
+ QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
+ QML_END_INSTR(name)
+
+#define QML_STORE_VAR(name, value) \
+ QML_BEGIN_INSTR(name) \
+ v8::Handle<v8::Value> v8value = value; \
+ QObject *target = objects.top(); \
+ CLEAN_PROPERTY(target, instr.propertyIndex); \
+ QMetaObject *mo = const_cast<QMetaObject *>(target->metaObject()); \
+ QQmlVMEMetaObject *vmemo = static_cast<QQmlVMEMetaObject *>(mo); \
+ vmemo->setVMEProperty(instr.propertyIndex, v8value); \
+ QML_END_INSTR(name)
+
+#define QML_STORE_POINTER(name, value) \
+ QML_BEGIN_INSTR(name) \
+ void *a[] = { (void *)value, 0, &status, &flags }; \
+ QObject *target = objects.top(); \
+ CLEAN_PROPERTY(target, instr.propertyIndex); \
+ QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
+ QML_END_INSTR(name)
+
+#define CLEAN_PROPERTY(o, index) \
+ if (fastHasBinding(o, index)) \
+ removeBindingOnProperty(o, index)
+
+QObject *QQmlVME::run(QList<QQmlError> *errors,
+ const Interrupt &interrupt
+#ifdef QML_THREADED_VME_INTERPRETER
+ , void ***storeJumpTable
+#endif
+ )
+{
+#ifdef QML_THREADED_VME_INTERPRETER
+ if (storeJumpTable) {
+#define QML_INSTR_ADDR(I, FMT) &&op_##I,
+ static void *jumpTable[] = {
+ FOR_EACH_QML_INSTR(QML_INSTR_ADDR)
+ };
+#undef QML_INSTR_ADDR
+ *storeJumpTable = jumpTable;
+ return 0;
+ }
+#endif
+ Q_ASSERT(errors->isEmpty());
+ Q_ASSERT(states.count() >= 1);
+
+ QQmlEngine *engine = states.at(0).context->engine;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+
+ // Need a v8 handle scope and execution context for StoreVar instructions.
+ v8::HandleScope handleScope;
+ v8::Context::Scope contextScope(ep->v8engine()->context());
+
+ int status = -1; // needed for dbus
+ QQmlPropertyPrivate::WriteFlags flags = QQmlPropertyPrivate::BypassInterceptor |
+ QQmlPropertyPrivate::RemoveBindingOnAliasWrite;
+
+ QRecursionWatcher<QQmlVME, &QQmlVME::recursion> watcher(this);
+
+#define COMP states.top().compiledData
+#define CTXT states.top().context
+#define INSTRUCTIONSTREAM states.top().instructionStream
+#define BINDINGSKIPLIST states.top().bindingSkipList
+
+#define TYPES COMP->types
+#define PRIMITIVES COMP->primitives
+#define DATAS COMP->datas
+#define PROGRAMS COMP->programs
+#define PROPERTYCACHES COMP->propertyCaches
+#define SCRIPTS COMP->scripts
+#define URLS COMP->urls
+
+#ifdef QML_THREADED_VME_INTERPRETER
+ const QQmlInstruction *genericInstr = reinterpret_cast<const QQmlInstruction *>(INSTRUCTIONSTREAM);
+ goto *genericInstr->common.code;
+#else
+ for (;;) {
+ const QQmlInstruction *genericInstr = reinterpret_cast<const QQmlInstruction *>(INSTRUCTIONSTREAM);
+
+ switch (genericInstr->common.instructionType) {
+#endif
+
+ // Store a created object in a property. These all pop from the objects stack.
+ QML_STORE_VALUE(StoreObject, QObject *, objects.pop());
+ QML_STORE_VALUE(StoreVariantObject, QVariant, QVariant::fromValue(objects.pop()));
+ QML_STORE_VAR(StoreVarObject, ep->v8engine()->newQObject(objects.pop()));
+
+ // Store a literal value in a corresponding property
+ QML_STORE_VALUE(StoreFloat, float, instr.value);
+ QML_STORE_VALUE(StoreDouble, double, instr.value);
+ QML_STORE_VALUE(StoreBool, bool, instr.value);
+ QML_STORE_VALUE(StoreInteger, int, instr.value);
+ QML_STORE_VALUE(StoreColor, QColor, QColor::fromRgba(instr.value));
+ QML_STORE_VALUE(StoreDate, QDate, QDate::fromJulianDay(instr.value));
+ QML_STORE_VALUE(StoreDateTime, QDateTime,
+ QDateTime(QDate::fromJulianDay(instr.date), *(QTime *)&instr.time));
+ QML_STORE_POINTER(StoreTime, (QTime *)&instr.time);
+ QML_STORE_POINTER(StorePoint, (QPoint *)&instr.point);
+ QML_STORE_POINTER(StorePointF, (QPointF *)&instr.point);
+ QML_STORE_POINTER(StoreSize, (QSize *)&instr.size);
+ QML_STORE_POINTER(StoreSizeF, (QSizeF *)&instr.size);
+ QML_STORE_POINTER(StoreRect, (QRect *)&instr.rect);
+ QML_STORE_POINTER(StoreRectF, (QRectF *)&instr.rect);
+ QML_STORE_POINTER(StoreVector3D, (QVector3D *)&instr.vector);
+ QML_STORE_POINTER(StoreVector4D, (QVector4D *)&instr.vector);
+ QML_STORE_POINTER(StoreString, &PRIMITIVES.at(instr.value));
+ QML_STORE_POINTER(StoreByteArray, &DATAS.at(instr.value));
+ QML_STORE_POINTER(StoreUrl, &URLS.at(instr.value));
+ QML_STORE_VALUE(StoreTrString, QString,
+ QCoreApplication::translate(DATAS.at(instr.context).constData(),
+ DATAS.at(instr.text).constData(),
+ DATAS.at(instr.comment).constData(),
+ QCoreApplication::UnicodeUTF8,
+ instr.n));
+ QML_STORE_VALUE(StoreTrIdString, QString, qtTrId(DATAS.at(instr.text).constData(), instr.n));
+
+ // Store a literal value in a QList
+ QML_STORE_LIST(StoreStringList, QStringList, PRIMITIVES.at(instr.value));
+ QML_STORE_LIST(StoreStringQList, QList<QString>, PRIMITIVES.at(instr.value));
+ QML_STORE_LIST(StoreUrlQList, QList<QUrl>, URLS.at(instr.value));
+ QML_STORE_LIST(StoreDoubleQList, QList<double>, instr.value);
+ QML_STORE_LIST(StoreBoolQList, QList<bool>, instr.value);
+ QML_STORE_LIST(StoreIntegerQList, QList<int>, instr.value);
+
+ // Store a literal value in a QVariant property
+ QML_STORE_VALUE(StoreVariant, QVariant, variantFromString(PRIMITIVES.at(instr.value)));
+ QML_STORE_VALUE(StoreVariantInteger, QVariant, QVariant(instr.value));
+ QML_STORE_VALUE(StoreVariantDouble, QVariant, QVariant(instr.value));
+ QML_STORE_VALUE(StoreVariantBool, QVariant, QVariant(instr.value));
+
+ // Store a literal value in a var property.
+ // We deliberately do not use string converters here
+ QML_STORE_VAR(StoreVar, ep->v8engine()->fromVariant(PRIMITIVES.at(instr.value)));
+ QML_STORE_VAR(StoreVarInteger, v8::Integer::New(instr.value));
+ QML_STORE_VAR(StoreVarDouble, v8::Number::New(instr.value));
+ QML_STORE_VAR(StoreVarBool, v8::Boolean::New(instr.value));
+
+
+ QML_BEGIN_INSTR(Init)
+ // Ensure that the compiled data has been initialized
+ if (!COMP->isInitialized()) COMP->initialize(engine);
+
+ QQmlContextData *parentCtxt = CTXT;
+ CTXT = new QQmlContextData;
+ CTXT->isInternal = true;
+ CTXT->url = COMP->url;
+ CTXT->urlString = COMP->name;
+ CTXT->imports = COMP->importCache;
+ CTXT->imports->addref();
+ CTXT->setParent(parentCtxt);
+ if (instr.contextCache != -1)
+ CTXT->setIdPropertyData(COMP->contextCaches.at(instr.contextCache));
+ if (instr.compiledBinding != -1) {
+ const char *v4data = DATAS.at(instr.compiledBinding).constData();
+ CTXT->v4bindings = new QV4Bindings(v4data, CTXT, COMP);
+ }
+ if (states.count() == 1) {
+ rootContext = CTXT;
+ rootContext->activeVMEData = data;
+ }
+ if (states.count() == 1 && !creationContext.isNull()) {
+ // A component that is logically created within another component instance shares the
+ // same instances of script imports. For example:
+ //
+ // import QtQuick 2.0
+ // import "test.js" as Test
+ // ListView {
+ // model: Test.getModel()
+ // delegate: Component {
+ // Text { text: Test.getValue(index); }
+ // }
+ // }
+ //
+ // Has the same "Test" instance. To implement this, we simply copy the v8 handles into
+ // the inner context. We have to create a fresh persistent handle for each to prevent
+ // double dispose. It is possible we could do this more efficiently using some form of
+ // referencing instead.
+ CTXT->importedScripts = creationContext->importedScripts;
+ for (int ii = 0; ii < CTXT->importedScripts.count(); ++ii)
+ CTXT->importedScripts[ii] = qPersistentNew<v8::Object>(CTXT->importedScripts[ii]);
+ }
+ QML_END_INSTR(Init)
+
+ QML_BEGIN_INSTR(DeferInit)
+ QML_END_INSTR(DeferInit)
+
+ QML_BEGIN_INSTR(Done)
+ states.pop();
+
+ if (states.isEmpty())
+ goto normalExit;
+ QML_END_INSTR(Done)
+
+ QML_BEGIN_INSTR(CreateQMLObject)
+ const QQmlCompiledData::TypeReference &type = TYPES.at(instr.type);
+ Q_ASSERT(type.component);
+
+ states.push(State());
+
+ State *cState = &states[states.count() - 2];
+ State *nState = &states[states.count() - 1];
+
+ nState->context = cState->context;
+ nState->compiledData = type.component;
+ nState->instructionStream = type.component->bytecode.constData();
+
+ if (instr.bindingBits != -1) {
+ const QByteArray &bits = cState->compiledData->datas.at(instr.bindingBits);
+ nState->bindingSkipList = QBitField((const quint32*)bits.constData(),
+ bits.size() * 8);
+ }
+ if (instr.isRoot)
+ nState->bindingSkipList = nState->bindingSkipList.united(cState->bindingSkipList);
+
+ // As the state in the state stack changed, execution will continue in the new program.
+ QML_END_INSTR(CreateQMLObject)
+
+ QML_BEGIN_INSTR(CompleteQMLObject)
+ QObject *o = objects.top();
+
+ QQmlData *ddata = QQmlData::get(o);
+ Q_ASSERT(ddata);
+
+ if (instr.isRoot) {
+ if (ddata->context) {
+ Q_ASSERT(ddata->context != CTXT);
+ Q_ASSERT(ddata->outerContext);
+ Q_ASSERT(ddata->outerContext != CTXT);
+ QQmlContextData *c = ddata->context;
+ while (c->linkedContext) c = c->linkedContext;
+ c->linkedContext = CTXT;
+ } else {
+ CTXT->addObject(o);
+ }
+
+ ddata->ownContext = true;
+ } else if (!ddata->context) {
+ CTXT->addObject(o);
+ }
+
+ ddata->setImplicitDestructible();
+ ddata->outerContext = CTXT;
+ ddata->lineNumber = instr.line;
+ ddata->columnNumber = instr.column;
+ QML_END_INSTR(CompleteQMLObject)
+
+ QML_BEGIN_INSTR(CreateCppObject)
+ const QQmlCompiledData::TypeReference &type = TYPES.at(instr.type);
+ Q_ASSERT(type.type);
+
+ QObject *o = 0;
+ void *memory = 0;
+ type.type->create(&o, &memory, sizeof(QQmlData));
+ QQmlData *ddata = new (memory) QQmlData;
+ ddata->ownMemory = false;
+ QObjectPrivate::get(o)->declarativeData = ddata;
+
+ if (type.typePropertyCache && !ddata->propertyCache) {
+ ddata->propertyCache = type.typePropertyCache;
+ ddata->propertyCache->addref();
+ }
+
+ if (!o)
+ VME_EXCEPTION(tr("Unable to create object of type %1").arg(type.className), instr.line);
+
+ if (instr.isRoot) {
+ if (ddata->context) {
+ Q_ASSERT(ddata->context != CTXT);
+ Q_ASSERT(ddata->outerContext);
+ Q_ASSERT(ddata->outerContext != CTXT);
+ QQmlContextData *c = ddata->context;
+ while (c->linkedContext) c = c->linkedContext;
+ c->linkedContext = CTXT;
+ } else {
+ CTXT->addObject(o);
+ }
+
+ ddata->ownContext = true;
+ } else if (!ddata->context) {
+ CTXT->addObject(o);
+ }
+
+ ddata->setImplicitDestructible();
+ ddata->outerContext = CTXT;
+ ddata->lineNumber = instr.line;
+ ddata->columnNumber = instr.column;
+
+ if (instr.data != -1) {
+ QQmlCustomParser *customParser =
+ TYPES.at(instr.type).type->customParser();
+ customParser->setCustomData(o, DATAS.at(instr.data));
+ }
+ if (!objects.isEmpty()) {
+ QObject *parent = objects.top();
+#if 0 // ### refactor
+ if (o->isWidgetType() && parent->isWidgetType())
+ static_cast<QWidget*>(o)->setParent(static_cast<QWidget*>(parent));
+ else
+#endif
+ QQml_setParent_noEvent(o, parent);
+ }
+ objects.push(o);
+ QML_END_INSTR(CreateCppObject)
+
+ QML_BEGIN_INSTR(CreateSimpleObject)
+ QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QQmlData));
+ ::memset(o, 0, instr.typeSize + sizeof(QQmlData));
+ instr.create(o);
+
+ QQmlData *ddata = (QQmlData *)(((const char *)o) + instr.typeSize);
+ const QQmlCompiledData::TypeReference &ref = TYPES.at(instr.type);
+ if (!ddata->propertyCache && ref.typePropertyCache) {
+ ddata->propertyCache = ref.typePropertyCache;
+ ddata->propertyCache->addref();
+ }
+ ddata->lineNumber = instr.line;
+ ddata->columnNumber = instr.column;
+
+ QObjectPrivate::get(o)->declarativeData = ddata;
+ ddata->context = ddata->outerContext = CTXT;
+ ddata->nextContextObject = CTXT->contextObjects;
+ if (ddata->nextContextObject)
+ ddata->nextContextObject->prevContextObject = &ddata->nextContextObject;
+ ddata->prevContextObject = &CTXT->contextObjects;
+ CTXT->contextObjects = ddata;
+
+ QObject *parent = objects.top();
+ QQml_setParent_noEvent(o, parent);
+
+ objects.push(o);
+ QML_END_INSTR(CreateSimpleObject)
+
+ QML_BEGIN_INSTR(SetId)
+ QObject *target = objects.top();
+ CTXT->setIdProperty(instr.index, target);
+ QML_END_INSTR(SetId)
+
+ QML_BEGIN_INSTR(SetDefault)
+ CTXT->contextObject = objects.top();
+ QML_END_INSTR(SetDefault)
+
+ QML_BEGIN_INSTR(CreateComponent)
+ QQmlComponent *qcomp =
+ new QQmlComponent(CTXT->engine, COMP, INSTRUCTIONSTREAM - COMP->bytecode.constData(),
+ objects.isEmpty() ? 0 : objects.top());
+
+ QQmlData *ddata = QQmlData::get(qcomp, true);
+ Q_ASSERT(ddata);
+
+ CTXT->addObject(qcomp);
+
+ if (instr.isRoot)
+ ddata->ownContext = true;
+
+ ddata->setImplicitDestructible();
+ ddata->outerContext = CTXT;
+ ddata->lineNumber = instr.line;
+ ddata->columnNumber = instr.column;
+
+ QQmlComponentPrivate::get(qcomp)->creationContext = CTXT;
+
+ objects.push(qcomp);
+ INSTRUCTIONSTREAM += instr.count;
+ QML_END_INSTR(CreateComponent)
+
+ QML_BEGIN_INSTR(StoreMetaObject)
+ QObject *target = objects.top();
+
+ QMetaObject mo;
+ const QByteArray &metadata = DATAS.at(instr.data);
+ QFastMetaBuilder::fromData(&mo, 0, metadata);
+
+ const QQmlVMEMetaData *data =
+ (const QQmlVMEMetaData *)DATAS.at(instr.aliasData).constData();
+
+ (void)new QQmlVMEMetaObject(target, &mo, data, COMP);
+
+ if (instr.propertyCache != -1) {
+ QQmlData *ddata = QQmlData::get(target, true);
+ if (ddata->propertyCache) ddata->propertyCache->release();
+ ddata->propertyCache = PROPERTYCACHES.at(instr.propertyCache);
+ ddata->propertyCache->addref();
+ }
+ QML_END_INSTR(StoreMetaObject)
+
+ QML_BEGIN_INSTR(AssignCustomType)
+ QObject *target = objects.top();
+ CLEAN_PROPERTY(target, instr.propertyIndex);
+
+ const QString &primitive = PRIMITIVES.at(instr.primitive);
+ int type = instr.type;
+ QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(type);
+ QVariant v = (*converter)(primitive);
+
+ QMetaProperty prop =
+ target->metaObject()->property(instr.propertyIndex);
+ if (v.isNull() || ((int)prop.type() != type && prop.userType() != type))
+ VME_EXCEPTION(tr("Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name())), instr.line);
+
+ void *a[] = { (void *)v.data(), 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.propertyIndex, a);
+ QML_END_INSTR(AssignCustomType)
+
+ QML_BEGIN_INSTR(AssignSignalObject)
+ // XXX optimize
+
+ QObject *assign = objects.pop();
+ QObject *target = objects.top();
+ int sigIdx = instr.signal;
+ const QString &pr = PRIMITIVES.at(sigIdx);
+
+ QQmlProperty prop(target, pr);
+ if (prop.type() & QQmlProperty::SignalProperty) {
+
+ QMetaMethod method = QQmlMetaType::defaultMethod(assign);
+ if (method.signature() == 0)
+ VME_EXCEPTION(tr("Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className())), instr.line);
+
+ if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature()))
+ VME_EXCEPTION(tr("Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature())), instr.line);
+
+ QQmlPropertyPrivate::connect(target, prop.index(), assign, method.methodIndex());
+
+ } else {
+ VME_EXCEPTION(tr("Cannot assign an object to signal property %1").arg(pr), instr.line);
+ }
+
+
+ QML_END_INSTR(AssignSignalObject)
+
+ QML_BEGIN_INSTR(StoreSignal)
+ QObject *target = objects.top();
+ QObject *context = objects.at(objects.count() - 1 - instr.context);
+
+ QMetaMethod signal = target->metaObject()->method(instr.signalIndex);
+
+ QQmlBoundSignal *bs = new QQmlBoundSignal(target, signal, target);
+ QQmlExpression *expr =
+ new QQmlExpression(CTXT, context, DATAS.at(instr.value), true, COMP->name, instr.line, instr.column, *new QQmlExpressionPrivate);
+ bs->setExpression(expr);
+ QML_END_INSTR(StoreSignal)
+
+ QML_BEGIN_INSTR(StoreImportedScript)
+ CTXT->importedScripts << run(CTXT, SCRIPTS.at(instr.value));
+ QML_END_INSTR(StoreImportedScript)
+
+ QML_BEGIN_INSTR(StoreScriptString)
+ QObject *target = objects.top();
+ QObject *scope = objects.at(objects.count() - 1 - instr.scope);
+ QQmlScriptString ss;
+ ss.setContext(CTXT->asQQmlContext());
+ ss.setScopeObject(scope);
+ ss.setScript(PRIMITIVES.at(instr.value));
+ ss.d.data()->bindingId = instr.bindingId;
+ ss.d.data()->lineNumber = instr.line;
+ ss.d.data()->columnNumber = instr.column;
+
+ void *a[] = { &ss, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.propertyIndex, a);
+ QML_END_INSTR(StoreScriptString)
+
+ QML_BEGIN_INSTR(BeginObject)
+ QObject *target = objects.top();
+ QQmlParserStatus *status = reinterpret_cast<QQmlParserStatus *>(reinterpret_cast<char *>(target) + instr.castValue);
+ parserStatus.push(status);
+#ifdef QML_ENABLE_TRACE
+ Q_ASSERT(QObjectPrivate::get(target)->declarativeData);
+ parserStatusData.push(static_cast<QQmlData *>(QObjectPrivate::get(target)->declarativeData));
+#endif
+ status->d = &parserStatus.top();
+
+ status->classBegin();
+ QML_END_INSTR(BeginObject)
+
+ QML_BEGIN_INSTR(InitV8Bindings)
+ CTXT->v8bindings = new QV8Bindings(&PROGRAMS[instr.programIndex], instr.line, CTXT);
+ QML_END_INSTR(InitV8Bindings)
+
+ QML_BEGIN_INSTR(StoreBinding)
+ QObject *target =
+ objects.at(objects.count() - 1 - instr.owner);
+ QObject *context =
+ objects.at(objects.count() - 1 - instr.context);
+
+ if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
+ QML_NEXT_INSTR(StoreBinding);
+
+ QQmlBinding *bind = new QQmlBinding(PRIMITIVES.at(instr.value), true,
+ context, CTXT, COMP->name, instr.line,
+ instr.column);
+ bindValues.push(bind);
+ bind->m_mePtr = &bindValues.top();
+ bind->setTarget(target, instr.property, CTXT);
+
+ typedef QQmlPropertyPrivate QDPP;
+ Q_ASSERT(bind->propertyIndex() == QDPP::bindingIndex(instr.property));
+ Q_ASSERT(bind->object() == target);
+
+ bind->addToObject();
+ QML_END_INSTR(StoreBinding)
+
+ QML_BEGIN_INSTR(StoreBindingOnAlias)
+ QObject *target =
+ objects.at(objects.count() - 1 - instr.owner);
+ QObject *context =
+ objects.at(objects.count() - 1 - instr.context);
+
+ if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
+ QML_NEXT_INSTR(StoreBindingOnAlias);
+
+ QQmlBinding *bind = new QQmlBinding(PRIMITIVES.at(instr.value), true,
+ context, CTXT, COMP->name, instr.line,
+ instr.column);
+ bindValues.push(bind);
+ bind->m_mePtr = &bindValues.top();
+ bind->setTarget(target, instr.property, CTXT);
+
+ QQmlAbstractBinding *old =
+ QQmlPropertyPrivate::setBindingNoEnable(target, instr.property.coreIndex,
+ instr.property.getValueTypeCoreIndex(),
+ bind);
+ if (old) { old->destroy(); }
+ QML_END_INSTR(StoreBindingOnAlias)
+
+ QML_BEGIN_INSTR(StoreV4Binding)
+ QObject *target =
+ objects.at(objects.count() - 1 - instr.owner);
+ QObject *scope =
+ objects.at(objects.count() - 1 - instr.context);
+
+ int property = instr.property;
+ if (instr.isRoot && BINDINGSKIPLIST.testBit(property & 0xFFFF))
+ QML_NEXT_INSTR(StoreV4Binding);
+
+ QQmlAbstractBinding *binding =
+ CTXT->v4bindings->configBinding(instr.value, target, scope, property,
+ instr.line, instr.column);
+ bindValues.push(binding);
+ binding->m_mePtr = &bindValues.top();
+
+ Q_ASSERT(binding->propertyIndex() == property);
+ Q_ASSERT(binding->object() == target);
+
+ binding->addToObject();
+ QML_END_INSTR(StoreV4Binding)
+
+ QML_BEGIN_INSTR(StoreV8Binding)
+ QObject *target =
+ objects.at(objects.count() - 1 - instr.owner);
+ QObject *scope =
+ objects.at(objects.count() - 1 - instr.context);
+
+ if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
+ QML_NEXT_INSTR(StoreV8Binding);
+
+ QQmlAbstractBinding *binding = CTXT->v8bindings->configBinding(target, scope,
+ &instr);
+ if (binding) {
+ bindValues.push(binding);
+ binding->m_mePtr = &bindValues.top();
+
+ typedef QQmlPropertyPrivate QDPP;
+ Q_ASSERT(binding->propertyIndex() == QDPP::bindingIndex(instr.property));
+ Q_ASSERT(binding->object() == target);
+
+ binding->addToObject();
+ }
+ QML_END_INSTR(StoreV8Binding)
+
+ QML_BEGIN_INSTR(StoreValueSource)
+ QObject *obj = objects.pop();
+ QQmlPropertyValueSource *vs = reinterpret_cast<QQmlPropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.castValue);
+ QObject *target = objects.at(objects.count() - 1 - instr.owner);
+
+ obj->setParent(target);
+ vs->setTarget(QQmlPropertyPrivate::restore(target, instr.property, CTXT));
+ QML_END_INSTR(StoreValueSource)
+
+ QML_BEGIN_INSTR(StoreValueInterceptor)
+ QObject *obj = objects.pop();
+ QQmlPropertyValueInterceptor *vi = reinterpret_cast<QQmlPropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.castValue);
+ QObject *target = objects.at(objects.count() - 1 - instr.owner);
+ QQmlProperty prop =
+ QQmlPropertyPrivate::restore(target, instr.property, CTXT);
+ obj->setParent(target);
+ vi->setTarget(prop);
+ QQmlVMEMetaObject *mo = static_cast<QQmlVMEMetaObject *>((QMetaObject*)target->metaObject());
+ mo->registerInterceptor(prop.index(), QQmlPropertyPrivate::valueTypeCoreIndex(prop), vi);
+ QML_END_INSTR(StoreValueInterceptor)
+
+ QML_BEGIN_INSTR(StoreObjectQList)
+ QObject *assign = objects.pop();
+
+ const List &list = lists.top();
+ list.qListProperty.append((QQmlListProperty<void>*)&list.qListProperty, assign);
+ QML_END_INSTR(StoreObjectQList)
+
+ QML_BEGIN_INSTR(AssignObjectList)
+ // This is only used for assigning interfaces
+ QObject *assign = objects.pop();
+ const List &list = lists.top();
+
+ int type = list.type;
+
+ void *ptr = 0;
+
+ const char *iid = QQmlMetaType::interfaceIId(type);
+ if (iid)
+ ptr = assign->qt_metacast(iid);
+ if (!ptr)
+ VME_EXCEPTION(tr("Cannot assign object to list"), instr.line);
+
+
+ list.qListProperty.append((QQmlListProperty<void>*)&list.qListProperty, ptr);
+ QML_END_INSTR(AssignObjectList)
+
+ QML_BEGIN_INSTR(StoreInterface)
+ QObject *assign = objects.pop();
+ QObject *target = objects.top();
+ CLEAN_PROPERTY(target, instr.propertyIndex);
+
+ int coreIdx = instr.propertyIndex;
+ QMetaProperty prop = target->metaObject()->property(coreIdx);
+ int t = prop.userType();
+ const char *iid = QQmlMetaType::interfaceIId(t);
+ bool ok = false;
+ if (iid) {
+ void *ptr = assign->qt_metacast(iid);
+ if (ptr) {
+ void *a[] = { &ptr, 0, &status, &flags };
+ QMetaObject::metacall(target,
+ QMetaObject::WriteProperty,
+ coreIdx, a);
+ ok = true;
+ }
+ }
+
+ if (!ok)
+ VME_EXCEPTION(tr("Cannot assign object to interface property"), instr.line);
+ QML_END_INSTR(StoreInterface)
+
+ QML_BEGIN_INSTR(FetchAttached)
+ QObject *target = objects.top();
+
+ QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.id, target);
+
+ if (!qmlObject)
+ VME_EXCEPTION(tr("Unable to create attached object"), instr.line);
+
+ objects.push(qmlObject);
+ QML_END_INSTR(FetchAttached)
+
+ QML_BEGIN_INSTR(FetchQList)
+ QObject *target = objects.top();
+
+ lists.push(List(instr.type));
+
+ void *a[1];
+ a[0] = (void *)&(lists.top().qListProperty);
+ QMetaObject::metacall(target, QMetaObject::ReadProperty,
+ instr.property, a);
+ QML_END_INSTR(FetchQList)
+
+ QML_BEGIN_INSTR(FetchObject)
+ QObject *target = objects.top();
+
+ QObject *obj = 0;
+ // NOTE: This assumes a cast to QObject does not alter the
+ // object pointer
+ void *a[1];
+ a[0] = &obj;
+ QMetaObject::metacall(target, QMetaObject::ReadProperty,
+ instr.property, a);
+
+ if (!obj)
+ VME_EXCEPTION(tr("Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.property).name())), instr.line);
+
+ objects.push(obj);
+ QML_END_INSTR(FetchObject)
+
+ QML_BEGIN_INSTR(PopQList)
+ lists.pop();
+ QML_END_INSTR(PopQList)
+
+ QML_BEGIN_INSTR(Defer)
+ if (instr.deferCount) {
+ QObject *target = objects.top();
+ QQmlData *data =
+ QQmlData::get(target, true);
+ COMP->addref();
+ data->deferredComponent = COMP;
+ data->deferredIdx = INSTRUCTIONSTREAM - COMP->bytecode.constData();
+ INSTRUCTIONSTREAM += instr.deferCount;
+ }
+ QML_END_INSTR(Defer)
+
+ QML_BEGIN_INSTR(PopFetchedObject)
+ objects.pop();
+ QML_END_INSTR(PopFetchedObject)
+
+ QML_BEGIN_INSTR(FetchValueType)
+ QObject *target = objects.top();
+
+ if (instr.bindingSkipList != 0) {
+ // Possibly need to clear bindings
+ QQmlData *targetData = QQmlData::get(target);
+ if (targetData) {
+ QQmlAbstractBinding *binding =
+ QQmlPropertyPrivate::binding(target, instr.property, -1);
+
+ if (binding && binding->bindingType() != QQmlAbstractBinding::ValueTypeProxy) {
+ QQmlPropertyPrivate::setBinding(target, instr.property, -1, 0);
+ binding->destroy();
+ } else if (binding) {
+ QQmlValueTypeProxyBinding *proxy =
+ static_cast<QQmlValueTypeProxyBinding *>(binding);
+ proxy->removeBindings(instr.bindingSkipList);
+ }
+ }
+ }
+
+ QQmlValueType *valueHandler = ep->valueTypes[instr.type];
+ valueHandler->read(target, instr.property);
+ objects.push(valueHandler);
+ QML_END_INSTR(FetchValueType)
+
+ QML_BEGIN_INSTR(PopValueType)
+ QQmlValueType *valueHandler =
+ static_cast<QQmlValueType *>(objects.pop());
+ QObject *target = objects.top();
+ valueHandler->write(target, instr.property, QQmlPropertyPrivate::BypassInterceptor);
+ QML_END_INSTR(PopValueType)
+
+#ifdef QML_THREADED_VME_INTERPRETER
+ // nothing to do
+#else
+ default:
+ qFatal("QQmlCompiledData: Internal error - unknown instruction %d", genericInstr->common.instructionType);
+ break;
+ }
+ }
+#endif
+
+exceptionExit:
+ Q_ASSERT(!states.isEmpty());
+ Q_ASSERT(!errors->isEmpty());
+
+ reset();
+
+ return 0;
+
+normalExit:
+ Q_ASSERT(objects.count() == 1);
+
+ QObject *rv = objects.top();
+
+ objects.deallocate();
+ lists.deallocate();
+ states.clear();
+
+ return rv;
+}
+
+void QQmlVME::reset()
+{
+ Q_ASSERT(!states.isEmpty() || objects.isEmpty());
+
+ QRecursionWatcher<QQmlVME, &QQmlVME::recursion> watcher(this);
+
+ if (!objects.isEmpty() && !(states.at(0).flags & State::Deferred))
+ delete objects.at(0);
+
+ if (!rootContext.isNull())
+ rootContext->activeVMEData = 0;
+
+ // Remove the QQmlParserStatus and QQmlAbstractBinding back pointers
+ blank(parserStatus);
+ blank(bindValues);
+
+ while (componentAttached) {
+ QQmlComponentAttached *a = componentAttached;
+ a->rem();
+ }
+
+ engine = 0;
+ objects.deallocate();
+ lists.deallocate();
+ bindValues.deallocate();
+ parserStatus.deallocate();
+#ifdef QML_ENABLE_TRACE
+ parserStatusData.deallocate();
+#endif
+ finalizeCallbacks.clear();
+ states.clear();
+ rootContext = 0;
+ creationContext = 0;
+}
+
+// Must be called with a handle scope and context
+void QQmlScriptData::initialize(QQmlEngine *engine)
+{
+ Q_ASSERT(m_program.IsEmpty());
+ Q_ASSERT(engine);
+ Q_ASSERT(!hasEngine());
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+ QV8Engine *v8engine = ep->v8engine();
+
+ // If compilation throws an error, a surrounding v8::TryCatch will record it.
+ v8::Local<v8::Script> program = v8engine->qmlModeCompile(m_programSource.constData(),
+ m_programSource.length(), urlString, 1);
+ if (program.IsEmpty())
+ return;
+
+ m_program = qPersistentNew<v8::Script>(program);
+ m_programSource.clear(); // We don't need this anymore
+
+ addToEngine(engine);
+
+ addref();
+}
+
+v8::Persistent<v8::Object> QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptData *script)
+{
+ if (script->m_loaded)
+ return qPersistentNew<v8::Object>(script->m_value);
+
+ Q_ASSERT(parentCtxt && parentCtxt->engine);
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(parentCtxt->engine);
+ QV8Engine *v8engine = ep->v8engine();
+
+ bool shared = script->pragmas & QQmlScript::Object::ScriptBlock::Shared;
+
+ QQmlContextData *effectiveCtxt = parentCtxt;
+ if (shared)
+ effectiveCtxt = 0;
+
+ // Create the script context if required
+ QQmlContextData *ctxt = new QQmlContextData;
+ ctxt->isInternal = true;
+ ctxt->isJSContext = true;
+ if (shared)
+ ctxt->isPragmaLibraryContext = true;
+ else
+ ctxt->isPragmaLibraryContext = parentCtxt->isPragmaLibraryContext;
+ ctxt->url = script->url;
+ ctxt->urlString = script->urlString;
+
+ // For backward compatibility, if there are no imports, we need to use the
+ // imports from the parent context. See QTBUG-17518.
+ if (!script->importCache->isEmpty()) {
+ ctxt->imports = script->importCache;
+ } else if (effectiveCtxt) {
+ ctxt->imports = effectiveCtxt->imports;
+ ctxt->importedScripts = effectiveCtxt->importedScripts;
+ for (int ii = 0; ii < ctxt->importedScripts.count(); ++ii)
+ ctxt->importedScripts[ii] = qPersistentNew<v8::Object>(ctxt->importedScripts[ii]);
+ }
+
+ if (ctxt->imports) {
+ ctxt->imports->addref();
+ }
+
+ if (effectiveCtxt) {
+ ctxt->setParent(effectiveCtxt, true);
+ } else {
+ ctxt->engine = parentCtxt->engine; // Fix for QTBUG-21620
+ }
+
+ for (int ii = 0; ii < script->scripts.count(); ++ii) {
+ ctxt->importedScripts << run(ctxt, script->scripts.at(ii)->scriptData());
+ }
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(v8engine->context());
+
+ v8::TryCatch try_catch;
+ if (!script->isInitialized())
+ script->initialize(parentCtxt->engine);
+
+ v8::Local<v8::Object> qmlglobal = v8engine->qmlScope(ctxt, 0);
+
+ if (!script->m_program.IsEmpty()) {
+ script->m_program->Run(qmlglobal);
+ } else {
+ // Compilation failed.
+ Q_ASSERT(try_catch.HasCaught());
+ }
+
+ v8::Persistent<v8::Object> rv;
+
+ if (try_catch.HasCaught()) {
+ v8::Local<v8::Message> message = try_catch.Message();
+ if (!message.IsEmpty()) {
+ QQmlError error;
+ QQmlExpressionPrivate::exceptionToError(message, error);
+ ep->warning(error);
+ }
+ }
+
+ rv = qPersistentNew<v8::Object>(qmlglobal);
+ if (shared) {
+ script->m_value = qPersistentNew<v8::Object>(qmlglobal);
+ script->m_loaded = true;
+ }
+
+ return rv;
+}
+
+#ifdef QML_THREADED_VME_INTERPRETER
+void **QQmlVME::instructionJumpTable()
+{
+ static void **jumpTable = 0;
+ if (!jumpTable) {
+ QQmlVME dummy;
+ QQmlVME::Interrupt i;
+ dummy.run(0, i, &jumpTable);
+ }
+ return jumpTable;
+}
+#endif
+
+QQmlContextData *QQmlVME::complete(const Interrupt &interrupt)
+{
+ Q_ASSERT(engine ||
+ (bindValues.isEmpty() &&
+ parserStatus.isEmpty() &&
+ componentAttached == 0 &&
+ rootContext.isNull() &&
+ finalizeCallbacks.isEmpty()));
+
+ if (!engine)
+ return 0;
+
+ QQmlTrace trace("VME Complete");
+#ifdef QML_ENABLE_TRACE
+ trace.addDetail("URL", rootComponent->url);
+#endif
+
+ ActiveVMERestorer restore(this, QQmlEnginePrivate::get(engine));
+ QRecursionWatcher<QQmlVME, &QQmlVME::recursion> watcher(this);
+
+ {
+ QQmlTrace trace("VME Binding Enable");
+ trace.event("begin binding eval");
+ while (!bindValues.isEmpty()) {
+ QQmlAbstractBinding *b = bindValues.pop();
+
+ if(b) {
+ b->m_mePtr = 0;
+ b->setEnabled(true, QQmlPropertyPrivate::BypassInterceptor |
+ QQmlPropertyPrivate::DontRemoveBinding);
+ }
+
+ if (watcher.hasRecursed() || interrupt.shouldInterrupt())
+ return 0;
+ }
+ bindValues.deallocate();
+ }
+
+ {
+ QQmlTrace trace("VME Component Complete");
+ while (!parserStatus.isEmpty()) {
+ QQmlParserStatus *status = parserStatus.pop();
+#ifdef QML_ENABLE_TRACE
+ QQmlData *data = parserStatusData.pop();
+#endif
+
+ if (status && status->d) {
+ status->d = 0;
+#ifdef QML_ENABLE_TRACE
+ QQmlTrace trace("Component complete");
+ trace.addDetail("URL", data->outerContext->url);
+ trace.addDetail("Line", data->lineNumber);
+#endif
+ status->componentComplete();
+ }
+
+ if (watcher.hasRecursed() || interrupt.shouldInterrupt())
+ return 0;
+ }
+ parserStatus.deallocate();
+ }
+
+ {
+ QQmlTrace trace("VME Finalize Callbacks");
+ for (int ii = 0; ii < finalizeCallbacks.count(); ++ii) {
+ QQmlEnginePrivate::FinalizeCallback callback = finalizeCallbacks.at(ii);
+ QObject *obj = callback.first;
+ if (obj) {
+ void *args[] = { 0 };
+ QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, callback.second, args);
+ }
+ if (watcher.hasRecursed())
+ return 0;
+ }
+ finalizeCallbacks.clear();
+ }
+
+ {
+ QQmlTrace trace("VME Component.onCompleted Callbacks");
+ while (componentAttached) {
+ QQmlComponentAttached *a = componentAttached;
+ a->rem();
+ QQmlData *d = QQmlData::get(a->parent());
+ Q_ASSERT(d);
+ Q_ASSERT(d->context);
+ a->add(&d->context->componentAttached);
+ emit a->completed();
+
+ if (watcher.hasRecursed() || interrupt.shouldInterrupt())
+ return 0;
+ }
+ }
+
+ QQmlContextData *rv = rootContext;
+
+ reset();
+
+ if (rv) rv->activeVMEData = data;
+
+ return rv;
+}
+
+void QQmlVME::blank(QFiniteStack<QQmlAbstractBinding *> &bs)
+{
+ for (int ii = 0; ii < bs.count(); ++ii) {
+ QQmlAbstractBinding *b = bs.at(ii);
+ if (b) b->m_mePtr = 0;
+ }
+}
+
+void QQmlVME::blank(QFiniteStack<QQmlParserStatus *> &pss)
+{
+ for (int ii = 0; ii < pss.count(); ++ii) {
+ QQmlParserStatus *ps = pss.at(ii);
+ if(ps) ps->d = 0;
+ }
+}
+
+QQmlVMEGuard::QQmlVMEGuard()
+: m_objectCount(0), m_objects(0), m_contextCount(0), m_contexts(0)
+{
+}
+
+QQmlVMEGuard::~QQmlVMEGuard()
+{
+ clear();
+}
+
+void QQmlVMEGuard::guard(QQmlVME *vme)
+{
+ clear();
+
+ m_objectCount = vme->objects.count();
+ m_objects = new QQmlGuard<QObject>[m_objectCount];
+ for (int ii = 0; ii < m_objectCount; ++ii)
+ m_objects[ii] = vme->objects[ii];
+
+ m_contextCount = (vme->rootContext.isNull()?0:1) + vme->states.count();
+ m_contexts = new QQmlGuardedContextData[m_contextCount];
+ for (int ii = 0; ii < vme->states.count(); ++ii)
+ m_contexts[ii] = vme->states.at(ii).context;
+ if (!vme->rootContext.isNull())
+ m_contexts[m_contextCount - 1] = vme->rootContext.contextData();
+}
+
+void QQmlVMEGuard::clear()
+{
+ delete [] m_objects;
+ delete [] m_contexts;
+
+ m_objectCount = 0;
+ m_objects = 0;
+ m_contextCount = 0;
+ m_contexts = 0;
+}
+
+bool QQmlVMEGuard::isOK() const
+{
+ for (int ii = 0; ii < m_objectCount; ++ii)
+ if (m_objects[ii].isNull())
+ return false;
+
+ for (int ii = 0; ii < m_contextCount; ++ii)
+ if (m_contexts[ii].isNull())
+ return false;
+
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h
new file mode 100644
index 0000000000..844f2cc98b
--- /dev/null
+++ b/src/qml/qml/qqmlvme_p.h
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLVME_P_H
+#define QQMLVME_P_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 "qqmlerror.h"
+#include <private/qbitfield_p.h>
+#include "qqmlinstruction_p.h"
+#include <private/qrecursionwatcher_p.h>
+
+#include <QtCore/QStack>
+#include <QtCore/QString>
+#include <QtCore/qelapsedtimer.h>
+#include <QtCore/qcoreapplication.h>
+
+#include <private/qv8_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qfinitestack_p.h>
+
+#include <private/qqmltrace_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+class QJSValue;
+class QQmlScriptData;
+class QQmlCompiledData;
+class QQmlCompiledData;
+class QQmlContextData;
+
+namespace QQmlVMETypes {
+ struct List
+ {
+ List() : type(0) {}
+ List(int t) : type(t) {}
+
+ int type;
+ QQmlListProperty<void> qListProperty;
+ };
+}
+Q_DECLARE_TYPEINFO(QQmlVMETypes::List, Q_PRIMITIVE_TYPE | Q_MOVABLE_TYPE);
+
+class QQmlVME
+{
+ Q_DECLARE_TR_FUNCTIONS(QQmlVME)
+public:
+ class Interrupt {
+ public:
+ inline Interrupt();
+ inline Interrupt(volatile bool *runWhile, int nsecs=0);
+ inline Interrupt(int nsecs);
+
+ inline void reset();
+ inline bool shouldInterrupt() const;
+ private:
+ enum Mode { None, Time, Flag };
+ Mode mode;
+ struct {
+ QElapsedTimer timer;
+ int nsecs;
+ };
+ volatile bool *runWhile;
+ };
+
+ QQmlVME() : data(0), componentAttached(0) {}
+ QQmlVME(void *data) : data(data), componentAttached(0) {}
+
+ void *data;
+ QQmlComponentAttached *componentAttached;
+ QList<QQmlEnginePrivate::FinalizeCallback> finalizeCallbacks;
+
+ void init(QQmlContextData *, QQmlCompiledData *, int start,
+ QQmlContextData * = 0);
+ bool initDeferred(QObject *);
+ void reset();
+
+ QObject *execute(QList<QQmlError> *errors, const Interrupt & = Interrupt());
+ QQmlContextData *complete(const Interrupt & = Interrupt());
+
+private:
+ friend class QQmlVMEGuard;
+
+ QObject *run(QList<QQmlError> *errors, const Interrupt &
+#ifdef QML_THREADED_VME_INTERPRETER
+ , void ***storeJumpTable = 0
+#endif
+ );
+ v8::Persistent<v8::Object> run(QQmlContextData *, QQmlScriptData *);
+
+#ifdef QML_THREADED_VME_INTERPRETER
+ static void **instructionJumpTable();
+ friend class QQmlCompiledData;
+#endif
+
+ QQmlEngine *engine;
+ QRecursionNode recursion;
+
+#ifdef QML_ENABLE_TRACE
+ QQmlCompiledData *rootComponent;
+#endif
+
+ QFiniteStack<QObject *> objects;
+ QFiniteStack<QQmlVMETypes::List> lists;
+
+ QFiniteStack<QQmlAbstractBinding *> bindValues;
+ QFiniteStack<QQmlParserStatus *> parserStatus;
+#ifdef QML_ENABLE_TRACE
+ QFiniteStack<QQmlData *> parserStatusData;
+#endif
+
+ QQmlGuardedContextData rootContext;
+ QQmlGuardedContextData creationContext;
+
+ struct State {
+ enum Flag { Deferred = 0x00000001 };
+
+ State() : flags(0), context(0), compiledData(0), instructionStream(0) {}
+ quint32 flags;
+ QQmlContextData *context;
+ QQmlCompiledData *compiledData;
+ const char *instructionStream;
+ QBitField bindingSkipList;
+ };
+
+ QStack<State> states;
+
+ static void blank(QFiniteStack<QQmlParserStatus *> &);
+ static void blank(QFiniteStack<QQmlAbstractBinding *> &);
+};
+
+// Used to check that a QQmlVME that is interrupted mid-execution
+// is still valid. Checks all the objects and contexts have not been
+// deleted.
+class QQmlVMEGuard
+{
+public:
+ QQmlVMEGuard();
+ ~QQmlVMEGuard();
+
+ void guard(QQmlVME *);
+ void clear();
+
+ bool isOK() const;
+
+private:
+ int m_objectCount;
+ QQmlGuard<QObject> *m_objects;
+ int m_contextCount;
+ QQmlGuardedContextData *m_contexts;
+};
+
+QQmlVME::Interrupt::Interrupt()
+ : mode(None), nsecs(0), runWhile(0)
+{
+}
+
+QQmlVME::Interrupt::Interrupt(volatile bool *runWhile, int nsecs)
+ : mode(Flag), nsecs(nsecs), runWhile(runWhile)
+{
+}
+
+QQmlVME::Interrupt::Interrupt(int nsecs)
+ : mode(Time), nsecs(nsecs), runWhile(0)
+{
+}
+
+void QQmlVME::Interrupt::reset()
+{
+ if (mode == Time || nsecs)
+ timer.start();
+}
+
+bool QQmlVME::Interrupt::shouldInterrupt() const
+{
+ if (mode == None) {
+ return false;
+ } else if (mode == Time) {
+ return timer.nsecsElapsed() > nsecs;
+ } else if (mode == Flag) {
+ return !*runWhile || (nsecs && timer.nsecsElapsed() > nsecs);
+ } else {
+ return false;
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLVME_P_H
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
new file mode 100644
index 0000000000..7ea89a4a2d
--- /dev/null
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -0,0 +1,1110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlvmemetaobject_p.h"
+
+
+#include "qqml.h"
+#include <private/qqmlrefcount_p.h>
+#include "qqmlexpression.h"
+#include "qqmlexpression_p.h"
+#include "qqmlcontext_p.h"
+#include "qqmlbinding_p.h"
+#include "qqmlpropertyvalueinterceptor_p.h"
+
+#include <private/qv8variantresource_p.h>
+
+Q_DECLARE_METATYPE(QJSValue);
+
+QT_BEGIN_NAMESPACE
+
+class QQmlVMEVariant
+{
+public:
+ inline QQmlVMEVariant();
+ inline ~QQmlVMEVariant();
+
+ inline const void *dataPtr() const;
+ inline void *dataPtr();
+ inline int dataType() const;
+
+ inline QObject *asQObject();
+ inline const QVariant &asQVariant();
+ inline int asInt();
+ inline bool asBool();
+ inline double asDouble();
+ inline const QString &asQString();
+ inline const QUrl &asQUrl();
+ inline const QColor &asQColor();
+ inline const QTime &asQTime();
+ inline const QDate &asQDate();
+ inline const QDateTime &asQDateTime();
+ inline const QJSValue &asQJSValue();
+
+ inline void setValue(QObject *);
+ inline void setValue(const QVariant &);
+ inline void setValue(int);
+ inline void setValue(bool);
+ inline void setValue(double);
+ inline void setValue(const QString &);
+ inline void setValue(const QUrl &);
+ inline void setValue(const QColor &);
+ inline void setValue(const QTime &);
+ inline void setValue(const QDate &);
+ inline void setValue(const QDateTime &);
+ inline void setValue(const QJSValue &);
+private:
+ int type;
+ void *data[4]; // Large enough to hold all types
+
+ inline void cleanup();
+};
+
+class QQmlVMEMetaObjectEndpoint : public QQmlNotifierEndpoint
+{
+public:
+ QQmlVMEMetaObjectEndpoint();
+ static void vmecallback(QQmlNotifierEndpoint *);
+ void tryConnect();
+
+ QFlagPointer<QQmlVMEMetaObject> metaObject;
+};
+
+
+QQmlVMEVariant::QQmlVMEVariant()
+: type(QVariant::Invalid)
+{
+}
+
+QQmlVMEVariant::~QQmlVMEVariant()
+{
+ cleanup();
+}
+
+void QQmlVMEVariant::cleanup()
+{
+ if (type == QVariant::Invalid) {
+ } else if (type == QMetaType::Int ||
+ type == QMetaType::Bool ||
+ type == QMetaType::Double) {
+ type = QVariant::Invalid;
+ } else if (type == QMetaType::QObjectStar) {
+ ((QQmlGuard<QObject>*)dataPtr())->~QQmlGuard<QObject>();
+ type = QVariant::Invalid;
+ } else if (type == QMetaType::QString) {
+ ((QString *)dataPtr())->~QString();
+ type = QVariant::Invalid;
+ } else if (type == QMetaType::QUrl) {
+ ((QUrl *)dataPtr())->~QUrl();
+ type = QVariant::Invalid;
+ } else if (type == QMetaType::QColor) {
+ ((QColor *)dataPtr())->~QColor();
+ type = QVariant::Invalid;
+ } else if (type == QMetaType::QTime) {
+ ((QTime *)dataPtr())->~QTime();
+ type = QVariant::Invalid;
+ } else if (type == QMetaType::QDate) {
+ ((QDate *)dataPtr())->~QDate();
+ type = QVariant::Invalid;
+ } else if (type == QMetaType::QDateTime) {
+ ((QDateTime *)dataPtr())->~QDateTime();
+ type = QVariant::Invalid;
+ } else if (type == qMetaTypeId<QVariant>()) {
+ ((QVariant *)dataPtr())->~QVariant();
+ type = QVariant::Invalid;
+ } else if (type == qMetaTypeId<QJSValue>()) {
+ ((QJSValue *)dataPtr())->~QJSValue();
+ type = QVariant::Invalid;
+ }
+
+}
+
+int QQmlVMEVariant::dataType() const
+{
+ return type;
+}
+
+const void *QQmlVMEVariant::dataPtr() const
+{
+ return &data;
+}
+
+void *QQmlVMEVariant::dataPtr()
+{
+ return &data;
+}
+
+QObject *QQmlVMEVariant::asQObject()
+{
+ if (type != QMetaType::QObjectStar)
+ setValue((QObject *)0);
+
+ return *(QQmlGuard<QObject> *)(dataPtr());
+}
+
+const QVariant &QQmlVMEVariant::asQVariant()
+{
+ if (type != QMetaType::QVariant)
+ setValue(QVariant());
+
+ return *(QVariant *)(dataPtr());
+}
+
+int QQmlVMEVariant::asInt()
+{
+ if (type != QMetaType::Int)
+ setValue(int(0));
+
+ return *(int *)(dataPtr());
+}
+
+bool QQmlVMEVariant::asBool()
+{
+ if (type != QMetaType::Bool)
+ setValue(bool(false));
+
+ return *(bool *)(dataPtr());
+}
+
+double QQmlVMEVariant::asDouble()
+{
+ if (type != QMetaType::Double)
+ setValue(double(0));
+
+ return *(double *)(dataPtr());
+}
+
+const QString &QQmlVMEVariant::asQString()
+{
+ if (type != QMetaType::QString)
+ setValue(QString());
+
+ return *(QString *)(dataPtr());
+}
+
+const QUrl &QQmlVMEVariant::asQUrl()
+{
+ if (type != QMetaType::QUrl)
+ setValue(QUrl());
+
+ return *(QUrl *)(dataPtr());
+}
+
+const QColor &QQmlVMEVariant::asQColor()
+{
+ if (type != QMetaType::QColor)
+ setValue(QColor());
+
+ return *(QColor *)(dataPtr());
+}
+
+const QTime &QQmlVMEVariant::asQTime()
+{
+ if (type != QMetaType::QTime)
+ setValue(QTime());
+
+ return *(QTime *)(dataPtr());
+}
+
+const QDate &QQmlVMEVariant::asQDate()
+{
+ if (type != QMetaType::QDate)
+ setValue(QDate());
+
+ return *(QDate *)(dataPtr());
+}
+
+const QDateTime &QQmlVMEVariant::asQDateTime()
+{
+ if (type != QMetaType::QDateTime)
+ setValue(QDateTime());
+
+ return *(QDateTime *)(dataPtr());
+}
+
+const QJSValue &QQmlVMEVariant::asQJSValue()
+{
+ if (type != qMetaTypeId<QJSValue>())
+ setValue(QJSValue());
+
+ return *(QJSValue *)(dataPtr());
+}
+
+void QQmlVMEVariant::setValue(QObject *v)
+{
+ if (type != QMetaType::QObjectStar) {
+ cleanup();
+ type = QMetaType::QObjectStar;
+ new (dataPtr()) QQmlGuard<QObject>();
+ }
+ *(QQmlGuard<QObject>*)(dataPtr()) = v;
+}
+
+void QQmlVMEVariant::setValue(const QVariant &v)
+{
+ if (type != qMetaTypeId<QVariant>()) {
+ cleanup();
+ type = qMetaTypeId<QVariant>();
+ new (dataPtr()) QVariant(v);
+ } else {
+ *(QVariant *)(dataPtr()) = v;
+ }
+}
+
+void QQmlVMEVariant::setValue(int v)
+{
+ if (type != QMetaType::Int) {
+ cleanup();
+ type = QMetaType::Int;
+ }
+ *(int *)(dataPtr()) = v;
+}
+
+void QQmlVMEVariant::setValue(bool v)
+{
+ if (type != QMetaType::Bool) {
+ cleanup();
+ type = QMetaType::Bool;
+ }
+ *(bool *)(dataPtr()) = v;
+}
+
+void QQmlVMEVariant::setValue(double v)
+{
+ if (type != QMetaType::Double) {
+ cleanup();
+ type = QMetaType::Double;
+ }
+ *(double *)(dataPtr()) = v;
+}
+
+void QQmlVMEVariant::setValue(const QString &v)
+{
+ if (type != QMetaType::QString) {
+ cleanup();
+ type = QMetaType::QString;
+ new (dataPtr()) QString(v);
+ } else {
+ *(QString *)(dataPtr()) = v;
+ }
+}
+
+void QQmlVMEVariant::setValue(const QUrl &v)
+{
+ if (type != QMetaType::QUrl) {
+ cleanup();
+ type = QMetaType::QUrl;
+ new (dataPtr()) QUrl(v);
+ } else {
+ *(QUrl *)(dataPtr()) = v;
+ }
+}
+
+void QQmlVMEVariant::setValue(const QColor &v)
+{
+ if (type != QMetaType::QColor) {
+ cleanup();
+ type = QMetaType::QColor;
+ new (dataPtr()) QColor(v);
+ } else {
+ *(QColor *)(dataPtr()) = v;
+ }
+}
+
+void QQmlVMEVariant::setValue(const QTime &v)
+{
+ if (type != QMetaType::QTime) {
+ cleanup();
+ type = QMetaType::QTime;
+ new (dataPtr()) QTime(v);
+ } else {
+ *(QTime *)(dataPtr()) = v;
+ }
+}
+
+void QQmlVMEVariant::setValue(const QDate &v)
+{
+ if (type != QMetaType::QDate) {
+ cleanup();
+ type = QMetaType::QDate;
+ new (dataPtr()) QDate(v);
+ } else {
+ *(QDate *)(dataPtr()) = v;
+ }
+}
+
+void QQmlVMEVariant::setValue(const QDateTime &v)
+{
+ if (type != QMetaType::QDateTime) {
+ cleanup();
+ type = QMetaType::QDateTime;
+ new (dataPtr()) QDateTime(v);
+ } else {
+ *(QDateTime *)(dataPtr()) = v;
+ }
+}
+
+void QQmlVMEVariant::setValue(const QJSValue &v)
+{
+ if (type != qMetaTypeId<QJSValue>()) {
+ cleanup();
+ type = qMetaTypeId<QJSValue>();
+ new (dataPtr()) QJSValue(v);
+ } else {
+ *(QJSValue *)(dataPtr()) = v;
+ }
+}
+
+QQmlVMEMetaObjectEndpoint::QQmlVMEMetaObjectEndpoint()
+{
+ callback = &vmecallback;
+}
+
+void QQmlVMEMetaObjectEndpoint::vmecallback(QQmlNotifierEndpoint *e)
+{
+ QQmlVMEMetaObjectEndpoint *vmee = static_cast<QQmlVMEMetaObjectEndpoint*>(e);
+ vmee->tryConnect();
+}
+
+void QQmlVMEMetaObjectEndpoint::tryConnect()
+{
+ int aliasId = this - metaObject->aliasEndpoints;
+
+ if (metaObject.flag()) {
+ // This is actually notify
+ int sigIdx = metaObject->methodOffset + aliasId + metaObject->metaData->propertyCount;
+ QMetaObject::activate(metaObject->object, sigIdx, 0);
+ } else {
+ QQmlVMEMetaData::AliasData *d = metaObject->metaData->aliasData() + aliasId;
+ if (!d->isObjectAlias()) {
+ QQmlContextData *ctxt = metaObject->ctxt;
+ QObject *target = ctxt->idValues[d->contextIdx].data();
+ if (!target)
+ return;
+
+ QMetaProperty prop = target->metaObject()->property(d->propertyIndex());
+ if (prop.hasNotifySignal())
+ connect(target, prop.notifySignalIndex());
+ }
+
+ metaObject.setFlag();
+ }
+}
+
+QQmlVMEMetaObject::QQmlVMEMetaObject(QObject *obj,
+ const QMetaObject *other,
+ const QQmlVMEMetaData *meta,
+ QQmlCompiledData *cdata)
+: QV8GCCallback::Node(GcPrologueCallback), object(obj), compiledData(cdata),
+ ctxt(QQmlData::get(obj, true)->outerContext), metaData(meta), data(0),
+ aliasEndpoints(0), firstVarPropertyIndex(-1), varPropertiesInitialized(false),
+ v8methods(0), parent(0)
+{
+ compiledData->addref();
+
+ *static_cast<QMetaObject *>(this) = *other;
+ this->d.superdata = obj->metaObject();
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ if (op->metaObject)
+ parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject);
+ op->metaObject = this;
+
+ propOffset = QAbstractDynamicMetaObject::propertyOffset();
+ methodOffset = QAbstractDynamicMetaObject::methodOffset();
+
+ data = new QQmlVMEVariant[metaData->propertyCount - metaData->varPropertyCount];
+
+ aConnected.resize(metaData->aliasCount);
+ int list_type = qMetaTypeId<QQmlListProperty<QObject> >();
+
+ // ### Optimize
+ for (int ii = 0; ii < metaData->propertyCount - metaData->varPropertyCount; ++ii) {
+ int t = (metaData->propertyData() + ii)->propertyType;
+ if (t == list_type) {
+ listProperties.append(List(methodOffset + ii));
+ data[ii].setValue(listProperties.count() - 1);
+ }
+ }
+
+ firstVarPropertyIndex = metaData->propertyCount - metaData->varPropertyCount;
+ if (metaData->varPropertyCount)
+ QV8GCCallback::addGcCallbackNode(this);
+}
+
+QQmlVMEMetaObject::~QQmlVMEMetaObject()
+{
+ compiledData->release();
+ delete parent;
+ delete [] data;
+ delete [] aliasEndpoints;
+
+ for (int ii = 0; v8methods && ii < metaData->methodCount; ++ii) {
+ qPersistentDispose(v8methods[ii]);
+ }
+ delete [] v8methods;
+
+ if (metaData->varPropertyCount)
+ qPersistentDispose(varProperties); // if not weak, will not have been cleaned up by the callback.
+}
+
+int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
+{
+ int id = _id;
+ if(c == QMetaObject::WriteProperty) {
+ int flags = *reinterpret_cast<int*>(a[3]);
+ if (!(flags & QQmlPropertyPrivate::BypassInterceptor)
+ && !aInterceptors.isEmpty()
+ && aInterceptors.testBit(id)) {
+ QPair<int, QQmlPropertyValueInterceptor*> pair = interceptors.value(id);
+ int valueIndex = pair.first;
+ QQmlPropertyValueInterceptor *vi = pair.second;
+ int type = property(id).userType();
+
+ if (type != QVariant::Invalid) {
+ if (valueIndex != -1) {
+ QQmlEnginePrivate *ep = ctxt?QQmlEnginePrivate::get(ctxt->engine):0;
+ QQmlValueType *valueType = 0;
+ if (ep) valueType = ep->valueTypes[type];
+ else valueType = QQmlValueTypeFactory::valueType(type);
+ Q_ASSERT(valueType);
+
+ valueType->setValue(QVariant(type, a[0]));
+ QMetaProperty valueProp = valueType->metaObject()->property(valueIndex);
+ vi->write(valueProp.read(valueType));
+
+ if (!ep) delete valueType;
+ return -1;
+ } else {
+ vi->write(QVariant(type, a[0]));
+ return -1;
+ }
+ }
+ }
+ }
+ if (c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty || c == QMetaObject::ResetProperty) {
+ if (id >= propOffset) {
+ id -= propOffset;
+
+ if (id < metaData->propertyCount) {
+ int t = (metaData->propertyData() + id)->propertyType;
+ bool needActivate = false;
+
+ if (id >= firstVarPropertyIndex) {
+ Q_ASSERT(t == QMetaType::QVariant);
+ // the context can be null if accessing var properties from cpp after re-parenting an item.
+ QQmlEnginePrivate *ep = (ctxt == 0 || ctxt->engine == 0) ? 0 : QQmlEnginePrivate::get(ctxt->engine);
+ QV8Engine *v8e = (ep == 0) ? 0 : ep->v8engine();
+ if (v8e) {
+ v8::HandleScope handleScope;
+ v8::Context::Scope contextScope(v8e->context());
+ if (c == QMetaObject::ReadProperty) {
+ *reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id);
+ } else if (c == QMetaObject::WriteProperty) {
+ writeProperty(id, *reinterpret_cast<QVariant *>(a[0]));
+ }
+ } else if (c == QMetaObject::ReadProperty) {
+ // if the context was disposed, we just return an invalid variant from read.
+ *reinterpret_cast<QVariant *>(a[0]) = QVariant();
+ }
+
+ } else {
+
+ if (c == QMetaObject::ReadProperty) {
+ switch(t) {
+ case QVariant::Int:
+ *reinterpret_cast<int *>(a[0]) = data[id].asInt();
+ break;
+ case QVariant::Bool:
+ *reinterpret_cast<bool *>(a[0]) = data[id].asBool();
+ break;
+ case QVariant::Double:
+ *reinterpret_cast<double *>(a[0]) = data[id].asDouble();
+ break;
+ case QVariant::String:
+ *reinterpret_cast<QString *>(a[0]) = data[id].asQString();
+ break;
+ case QVariant::Url:
+ *reinterpret_cast<QUrl *>(a[0]) = data[id].asQUrl();
+ break;
+ case QVariant::Color:
+ *reinterpret_cast<QColor *>(a[0]) = data[id].asQColor();
+ break;
+ case QVariant::Date:
+ *reinterpret_cast<QDate *>(a[0]) = data[id].asQDate();
+ break;
+ case QVariant::DateTime:
+ *reinterpret_cast<QDateTime *>(a[0]) = data[id].asQDateTime();
+ break;
+ case QMetaType::QObjectStar:
+ *reinterpret_cast<QObject **>(a[0]) = data[id].asQObject();
+ break;
+ case QMetaType::QVariant:
+ *reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id);
+ break;
+ default:
+ break;
+ }
+ if (t == qMetaTypeId<QQmlListProperty<QObject> >()) {
+ int listIndex = data[id].asInt();
+ const List *list = &listProperties.at(listIndex);
+ *reinterpret_cast<QQmlListProperty<QObject> *>(a[0]) =
+ QQmlListProperty<QObject>(object, (void *)list,
+ list_append, list_count, list_at,
+ list_clear);
+ }
+
+ } else if (c == QMetaObject::WriteProperty) {
+
+ switch(t) {
+ case QVariant::Int:
+ needActivate = *reinterpret_cast<int *>(a[0]) != data[id].asInt();
+ data[id].setValue(*reinterpret_cast<int *>(a[0]));
+ break;
+ case QVariant::Bool:
+ needActivate = *reinterpret_cast<bool *>(a[0]) != data[id].asBool();
+ data[id].setValue(*reinterpret_cast<bool *>(a[0]));
+ break;
+ case QVariant::Double:
+ needActivate = *reinterpret_cast<double *>(a[0]) != data[id].asDouble();
+ data[id].setValue(*reinterpret_cast<double *>(a[0]));
+ break;
+ case QVariant::String:
+ needActivate = *reinterpret_cast<QString *>(a[0]) != data[id].asQString();
+ data[id].setValue(*reinterpret_cast<QString *>(a[0]));
+ break;
+ case QVariant::Url:
+ needActivate = *reinterpret_cast<QUrl *>(a[0]) != data[id].asQUrl();
+ data[id].setValue(*reinterpret_cast<QUrl *>(a[0]));
+ break;
+ case QVariant::Color:
+ needActivate = *reinterpret_cast<QColor *>(a[0]) != data[id].asQColor();
+ data[id].setValue(*reinterpret_cast<QColor *>(a[0]));
+ break;
+ case QVariant::Date:
+ needActivate = *reinterpret_cast<QDate *>(a[0]) != data[id].asQDate();
+ data[id].setValue(*reinterpret_cast<QDate *>(a[0]));
+ break;
+ case QVariant::DateTime:
+ needActivate = *reinterpret_cast<QDateTime *>(a[0]) != data[id].asQDateTime();
+ data[id].setValue(*reinterpret_cast<QDateTime *>(a[0]));
+ break;
+ case QMetaType::QObjectStar:
+ needActivate = *reinterpret_cast<QObject **>(a[0]) != data[id].asQObject();
+ data[id].setValue(*reinterpret_cast<QObject **>(a[0]));
+ break;
+ case QMetaType::QVariant:
+ writeProperty(id, *reinterpret_cast<QVariant *>(a[0]));
+ break;
+ default:
+ break;
+ }
+ }
+
+ }
+
+ if (c == QMetaObject::WriteProperty && needActivate) {
+ activate(object, methodOffset + id, 0);
+ }
+
+ return -1;
+ }
+
+ id -= metaData->propertyCount;
+
+ if (id < metaData->aliasCount) {
+
+ QQmlVMEMetaData::AliasData *d = metaData->aliasData() + id;
+
+ if (d->flags & QML_ALIAS_FLAG_PTR && c == QMetaObject::ReadProperty)
+ *reinterpret_cast<void **>(a[0]) = 0;
+
+ if (!ctxt) return -1;
+
+ QQmlContext *context = ctxt->asQQmlContext();
+ QQmlContextPrivate *ctxtPriv = QQmlContextPrivate::get(context);
+
+ QObject *target = ctxtPriv->data->idValues[d->contextIdx].data();
+ if (!target)
+ return -1;
+
+ connectAlias(id);
+
+ if (d->isObjectAlias()) {
+ *reinterpret_cast<QObject **>(a[0]) = target;
+ return -1;
+ }
+
+ // Remove binding (if any) on write
+ if(c == QMetaObject::WriteProperty) {
+ int flags = *reinterpret_cast<int*>(a[3]);
+ if (flags & QQmlPropertyPrivate::RemoveBindingOnAliasWrite) {
+ QQmlData *targetData = QQmlData::get(target);
+ if (targetData && targetData->hasBindingBit(d->propertyIndex())) {
+ QQmlAbstractBinding *binding = QQmlPropertyPrivate::setBinding(target, d->propertyIndex(), d->isValueTypeAlias()?d->valueTypeIndex():-1, 0);
+ if (binding) binding->destroy();
+ }
+ }
+ }
+
+ if (d->isValueTypeAlias()) {
+ // Value type property
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(ctxt->engine);
+
+ QQmlValueType *valueType = ep->valueTypes[d->valueType()];
+ Q_ASSERT(valueType);
+
+ valueType->read(target, d->propertyIndex());
+ int rv = QMetaObject::metacall(valueType, c, d->valueTypeIndex(), a);
+
+ if (c == QMetaObject::WriteProperty)
+ valueType->write(target, d->propertyIndex(), 0x00);
+
+ return rv;
+
+ } else {
+ return QMetaObject::metacall(target, c, d->propertyIndex(), a);
+ }
+
+ }
+ return -1;
+
+ }
+
+ } else if(c == QMetaObject::InvokeMetaMethod) {
+
+ if (id >= methodOffset) {
+
+ id -= methodOffset;
+ int plainSignals = metaData->signalCount + metaData->propertyCount +
+ metaData->aliasCount;
+ if (id < plainSignals) {
+ QMetaObject::activate(object, _id, a);
+ return -1;
+ }
+
+ id -= plainSignals;
+
+ if (id < metaData->methodCount) {
+ if (!ctxt->engine)
+ return -1; // We can't run the method
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(ctxt->engine);
+ ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation.
+
+ v8::Handle<v8::Function> function = method(id);
+ if (function.IsEmpty()) {
+ // The function was not compiled. There are some exceptional cases which the
+ // expression rewriter does not rewrite properly (e.g., \r-terminated lines
+ // are not rewritten correctly but this bug is deemed out-of-scope to fix for
+ // performance reasons; see QTBUG-24064) and thus compilation will have failed.
+ QQmlError e;
+ e.setDescription(QString(QLatin1String("Exception occurred during compilation of function: %1")).
+ arg(QLatin1String(QMetaObject::method(_id).signature())));
+ ep->warning(e);
+ return -1; // The dynamic method with that id is not available.
+ }
+
+ QQmlVMEMetaData::MethodData *data = metaData->methodData() + id;
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(ep->v8engine()->context());
+ v8::Handle<v8::Value> *args = 0;
+
+ if (data->parameterCount) {
+ args = new v8::Handle<v8::Value>[data->parameterCount];
+ for (int ii = 0; ii < data->parameterCount; ++ii)
+ args[ii] = ep->v8engine()->fromVariant(*(QVariant *)a[ii + 1]);
+ }
+
+ v8::TryCatch try_catch;
+
+ v8::Local<v8::Value> result = function->Call(ep->v8engine()->global(), data->parameterCount, args);
+
+ QVariant rv;
+ if (try_catch.HasCaught()) {
+ QQmlError error;
+ QQmlExpressionPrivate::exceptionToError(try_catch.Message(), error);
+ if (error.isValid())
+ ep->warning(error);
+ if (a[0]) *(QVariant *)a[0] = QVariant();
+ } else {
+ if (a[0]) *(QVariant *)a[0] = ep->v8engine()->toVariant(result, 0);
+ }
+
+ ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete.
+ return -1;
+ }
+ return -1;
+ }
+ }
+
+ if (parent)
+ return parent->metaCall(c, _id, a);
+ else
+ return object->qt_metacall(c, _id, a);
+}
+
+v8::Handle<v8::Function> QQmlVMEMetaObject::method(int index)
+{
+ if (!v8methods)
+ v8methods = new v8::Persistent<v8::Function>[metaData->methodCount];
+
+ if (v8methods[index].IsEmpty()) {
+ QQmlVMEMetaData::MethodData *data = metaData->methodData() + index;
+
+ const char *body = ((const char*)metaData) + data->bodyOffset;
+ int bodyLength = data->bodyLength;
+
+ // XXX We should evaluate all methods in a single big script block to
+ // improve the call time between dynamic methods defined on the same
+ // object
+ v8methods[index] = QQmlExpressionPrivate::evalFunction(ctxt, object, body,
+ bodyLength,
+ ctxt->urlString,
+ data->lineNumber);
+ }
+
+ return v8methods[index];
+}
+
+v8::Handle<v8::Value> QQmlVMEMetaObject::readVarProperty(int id)
+{
+ Q_ASSERT(id >= firstVarPropertyIndex);
+
+ ensureVarPropertiesAllocated();
+ return varProperties->Get(id - firstVarPropertyIndex);
+}
+
+QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id)
+{
+ if (id >= firstVarPropertyIndex) {
+ ensureVarPropertiesAllocated();
+ return QQmlEnginePrivate::get(ctxt->engine)->v8engine()->toVariant(varProperties->Get(id - firstVarPropertyIndex), -1);
+ } else {
+ if (data[id].dataType() == QMetaType::QObjectStar) {
+ return QVariant::fromValue(data[id].asQObject());
+ } else {
+ return data[id].asQVariant();
+ }
+ }
+}
+
+void QQmlVMEMetaObject::writeVarProperty(int id, v8::Handle<v8::Value> value)
+{
+ Q_ASSERT(id >= firstVarPropertyIndex);
+ ensureVarPropertiesAllocated();
+
+ // Importantly, if the current value is a scarce resource, we need to ensure that it
+ // gets automatically released by the engine if no other references to it exist.
+ v8::Local<v8::Value> oldv = varProperties->Get(id - firstVarPropertyIndex);
+ if (oldv->IsObject()) {
+ QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(v8::Handle<v8::Object>::Cast(oldv));
+ if (r) {
+ r->removeVmePropertyReference();
+ }
+ }
+
+ // And, if the new value is a scarce resource, we need to ensure that it does not get
+ // automatically released by the engine until no other references to it exist.
+ if (value->IsObject()) {
+ QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(v8::Handle<v8::Object>::Cast(value));
+ if (r) {
+ r->addVmePropertyReference();
+ }
+ }
+
+ // Write the value and emit change signal as appropriate.
+ varProperties->Set(id - firstVarPropertyIndex, value);
+ activate(object, methodOffset + id, 0);
+}
+
+void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value)
+{
+ if (id >= firstVarPropertyIndex) {
+ ensureVarPropertiesAllocated();
+
+ // Importantly, if the current value is a scarce resource, we need to ensure that it
+ // gets automatically released by the engine if no other references to it exist.
+ v8::Local<v8::Value> oldv = varProperties->Get(id - firstVarPropertyIndex);
+ if (oldv->IsObject()) {
+ QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(v8::Handle<v8::Object>::Cast(oldv));
+ if (r) {
+ r->removeVmePropertyReference();
+ }
+ }
+
+ // And, if the new value is a scarce resource, we need to ensure that it does not get
+ // automatically released by the engine until no other references to it exist.
+ v8::Handle<v8::Value> newv = QQmlEnginePrivate::get(ctxt->engine)->v8engine()->fromVariant(value);
+ if (newv->IsObject()) {
+ QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(v8::Handle<v8::Object>::Cast(newv));
+ if (r) {
+ r->addVmePropertyReference();
+ }
+ }
+
+ // Write the value and emit change signal as appropriate.
+ QVariant currentValue = readPropertyAsVariant(id);
+ varProperties->Set(id - firstVarPropertyIndex, newv);
+ if ((currentValue.userType() != value.userType() || currentValue != value))
+ activate(object, methodOffset + id, 0);
+ } else {
+ bool needActivate = false;
+ if (value.userType() == QMetaType::QObjectStar) {
+ QObject *o = qvariant_cast<QObject *>(value);
+ needActivate = (data[id].dataType() != QMetaType::QObjectStar || data[id].asQObject() != o);
+ data[id].setValue(qvariant_cast<QObject *>(value));
+ } else {
+ needActivate = (data[id].dataType() != qMetaTypeId<QVariant>() ||
+ data[id].asQVariant().userType() != value.userType() ||
+ data[id].asQVariant() != value);
+ data[id].setValue(value);
+ }
+
+ if (needActivate)
+ activate(object, methodOffset + id, 0);
+ }
+}
+
+void QQmlVMEMetaObject::listChanged(int id)
+{
+ activate(object, methodOffset + id, 0);
+}
+
+void QQmlVMEMetaObject::list_append(QQmlListProperty<QObject> *prop, QObject *o)
+{
+ List *list = static_cast<List *>(prop->data);
+ list->append(o);
+ QMetaObject::activate(prop->object, list->notifyIndex, 0);
+}
+
+int QQmlVMEMetaObject::list_count(QQmlListProperty<QObject> *prop)
+{
+ return static_cast<List *>(prop->data)->count();
+}
+
+QObject *QQmlVMEMetaObject::list_at(QQmlListProperty<QObject> *prop, int index)
+{
+ return static_cast<List *>(prop->data)->at(index);
+}
+
+void QQmlVMEMetaObject::list_clear(QQmlListProperty<QObject> *prop)
+{
+ List *list = static_cast<List *>(prop->data);
+ list->clear();
+ QMetaObject::activate(prop->object, list->notifyIndex, 0);
+}
+
+void QQmlVMEMetaObject::registerInterceptor(int index, int valueIndex, QQmlPropertyValueInterceptor *interceptor)
+{
+ if (aInterceptors.isEmpty())
+ aInterceptors.resize(propertyCount() + metaData->propertyCount);
+ aInterceptors.setBit(index);
+ interceptors.insert(index, qMakePair(valueIndex, interceptor));
+}
+
+int QQmlVMEMetaObject::vmeMethodLineNumber(int index)
+{
+ if (index < methodOffset) {
+ Q_ASSERT(parent);
+ return static_cast<QQmlVMEMetaObject *>(parent)->vmeMethodLineNumber(index);
+ }
+
+ int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
+ Q_ASSERT(index >= (methodOffset + plainSignals) && index < (methodOffset + plainSignals + metaData->methodCount));
+
+ int rawIndex = index - methodOffset - plainSignals;
+
+ QQmlVMEMetaData::MethodData *data = metaData->methodData() + rawIndex;
+ return data->lineNumber;
+}
+
+v8::Handle<v8::Function> QQmlVMEMetaObject::vmeMethod(int index)
+{
+ if (index < methodOffset) {
+ Q_ASSERT(parent);
+ return static_cast<QQmlVMEMetaObject *>(parent)->vmeMethod(index);
+ }
+ int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
+ Q_ASSERT(index >= (methodOffset + plainSignals) && index < (methodOffset + plainSignals + metaData->methodCount));
+ return method(index - methodOffset - plainSignals);
+}
+
+// Used by debugger
+void QQmlVMEMetaObject::setVmeMethod(int index, v8::Persistent<v8::Function> value)
+{
+ if (index < methodOffset) {
+ Q_ASSERT(parent);
+ return static_cast<QQmlVMEMetaObject *>(parent)->setVmeMethod(index, value);
+ }
+ int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
+ Q_ASSERT(index >= (methodOffset + plainSignals) && index < (methodOffset + plainSignals + metaData->methodCount));
+
+ if (!v8methods)
+ v8methods = new v8::Persistent<v8::Function>[metaData->methodCount];
+
+ int methodIndex = index - methodOffset - plainSignals;
+ if (!v8methods[methodIndex].IsEmpty())
+ qPersistentDispose(v8methods[methodIndex]);
+ v8methods[methodIndex] = value;
+}
+
+v8::Handle<v8::Value> QQmlVMEMetaObject::vmeProperty(int index)
+{
+ if (index < propOffset) {
+ Q_ASSERT(parent);
+ return static_cast<QQmlVMEMetaObject *>(parent)->vmeProperty(index);
+ }
+ return readVarProperty(index - propOffset);
+}
+
+void QQmlVMEMetaObject::setVMEProperty(int index, v8::Handle<v8::Value> v)
+{
+ if (index < propOffset) {
+ Q_ASSERT(parent);
+ static_cast<QQmlVMEMetaObject *>(parent)->setVMEProperty(index, v);
+ return;
+ }
+ return writeVarProperty(index - propOffset, v);
+}
+
+void QQmlVMEMetaObject::ensureVarPropertiesAllocated()
+{
+ if (!varPropertiesInitialized)
+ allocateVarPropertiesArray();
+}
+
+// see also: QV8GCCallback::garbageCollectorPrologueCallback()
+void QQmlVMEMetaObject::allocateVarPropertiesArray()
+{
+ v8::HandleScope handleScope;
+ v8::Context::Scope cs(QQmlEnginePrivate::get(ctxt->engine)->v8engine()->context());
+ varProperties = qPersistentNew(v8::Array::New(metaData->varPropertyCount));
+ varProperties.MakeWeak(static_cast<void*>(this), VarPropertiesWeakReferenceCallback);
+ varPropertiesInitialized = true;
+}
+
+/*
+ The "var" properties are stored in a v8::Array which will be strong persistent if the object has cpp-ownership
+ and the root QObject in the parent chain does not have JS-ownership. In the weak persistent handle case,
+ this callback will dispose the handle when the v8object which owns the lifetime of the var properties array
+ is cleared as a result of all other handles to that v8object being released.
+ See QV8GCCallback::garbageCollectorPrologueCallback() for more information.
+ */
+void QQmlVMEMetaObject::VarPropertiesWeakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter)
+{
+ QQmlVMEMetaObject *vmemo = static_cast<QQmlVMEMetaObject*>(parameter);
+ Q_ASSERT(vmemo);
+ qPersistentDispose(object);
+ vmemo->varProperties.Clear();
+}
+
+void QQmlVMEMetaObject::GcPrologueCallback(QV8GCCallback::Node *node)
+{
+ QQmlVMEMetaObject *vmemo = static_cast<QQmlVMEMetaObject*>(node);
+ Q_ASSERT(vmemo);
+ if (!vmemo->varPropertiesInitialized || vmemo->varProperties.IsEmpty() || !vmemo->ctxt || !vmemo->ctxt->engine)
+ return;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(vmemo->ctxt->engine);
+ ep->v8engine()->addRelationshipForGC(vmemo->object, vmemo->varProperties);
+}
+
+bool QQmlVMEMetaObject::aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const
+{
+ Q_ASSERT(index >= propOffset + metaData->propertyCount);
+
+ *target = 0;
+ *coreIndex = -1;
+ *valueTypeIndex = -1;
+
+ if (!ctxt)
+ return false;
+
+ QQmlVMEMetaData::AliasData *d = metaData->aliasData() + (index - propOffset - metaData->propertyCount);
+ QQmlContext *context = ctxt->asQQmlContext();
+ QQmlContextPrivate *ctxtPriv = QQmlContextPrivate::get(context);
+
+ *target = ctxtPriv->data->idValues[d->contextIdx].data();
+ if (!*target)
+ return false;
+
+ if (d->isObjectAlias()) {
+ } else if (d->isValueTypeAlias()) {
+ *coreIndex = d->propertyIndex();
+ *valueTypeIndex = d->valueTypeIndex();
+ } else {
+ *coreIndex = d->propertyIndex();
+ }
+
+ return true;
+}
+
+void QQmlVMEMetaObject::connectAlias(int aliasId)
+{
+ if (!aConnected.testBit(aliasId)) {
+
+ if (!aliasEndpoints)
+ aliasEndpoints = new QQmlVMEMetaObjectEndpoint[metaData->aliasCount];
+
+ aConnected.setBit(aliasId);
+
+ QQmlVMEMetaData::AliasData *d = metaData->aliasData() + aliasId;
+
+ QQmlVMEMetaObjectEndpoint *endpoint = aliasEndpoints + aliasId;
+ endpoint->metaObject = this;
+
+ endpoint->connect(&ctxt->idValues[d->contextIdx].bindings);
+
+ endpoint->tryConnect();
+ }
+}
+
+void QQmlVMEMetaObject::connectAliasSignal(int index)
+{
+ int aliasId = (index - methodOffset) - metaData->propertyCount;
+ if (aliasId < 0 || aliasId >= metaData->aliasCount)
+ return;
+
+ connectAlias(aliasId);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
new file mode 100644
index 0000000000..deee989383
--- /dev/null
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLVMEMETAOBJECT_P_H
+#define QQMLVMEMETAOBJECT_P_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 "qqml.h"
+
+#include <QtCore/QMetaObject>
+#include <QtCore/QBitArray>
+#include <QtCore/QPair>
+#include <QtGui/QColor>
+#include <QtCore/QDate>
+#include <QtCore/qlist.h>
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+#include "qqmlguard_p.h"
+#include "qqmlcompiler_p.h"
+#include "qqmlcontext_p.h"
+
+#include <private/qv8engine_p.h>
+
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#define QML_ALIAS_FLAG_PTR 0x00000001
+
+struct QQmlVMEMetaData
+{
+ short varPropertyCount;
+ short propertyCount;
+ short aliasCount;
+ short signalCount;
+ short methodCount;
+ short dummyForAlignment; // Add padding to ensure that the following
+ // AliasData/PropertyData/MethodData is int aligned.
+
+ struct AliasData {
+ int contextIdx;
+ int propertyIdx;
+ int flags;
+
+ bool isObjectAlias() const {
+ return propertyIdx == -1;
+ }
+ bool isPropertyAlias() const {
+ return !isObjectAlias() && !(propertyIdx & 0xFF000000);
+ }
+ bool isValueTypeAlias() const {
+ return !isObjectAlias() && (propertyIdx & 0xFF000000);
+ }
+ int propertyIndex() const {
+ return propertyIdx & 0x0000FFFF;
+ }
+ int valueTypeIndex() const {
+ return (propertyIdx & 0x00FF0000) >> 16;
+ }
+ int valueType() const {
+ return ((unsigned int)propertyIdx) >> 24;
+ }
+ };
+
+ struct PropertyData {
+ int propertyType;
+ };
+
+ struct MethodData {
+ int parameterCount;
+ int bodyOffset;
+ int bodyLength;
+ int lineNumber;
+ };
+
+ PropertyData *propertyData() const {
+ return (PropertyData *)(((const char *)this) + sizeof(QQmlVMEMetaData));
+ }
+
+ AliasData *aliasData() const {
+ return (AliasData *)(propertyData() + propertyCount);
+ }
+
+ MethodData *methodData() const {
+ return (MethodData *)(aliasData() + aliasCount);
+ }
+};
+
+class QV8QObjectWrapper;
+class QQmlVMEVariant;
+class QQmlRefCount;
+class QQmlVMEMetaObjectEndpoint;
+class Q_AUTOTEST_EXPORT QQmlVMEMetaObject : public QAbstractDynamicMetaObject,
+ public QV8GCCallback::Node
+{
+public:
+ QQmlVMEMetaObject(QObject *obj, const QMetaObject *other, const QQmlVMEMetaData *data,
+ QQmlCompiledData *compiledData);
+ ~QQmlVMEMetaObject();
+
+ bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const;
+ void registerInterceptor(int index, int valueIndex, QQmlPropertyValueInterceptor *interceptor);
+ v8::Handle<v8::Function> vmeMethod(int index);
+ int vmeMethodLineNumber(int index);
+ void setVmeMethod(int index, v8::Persistent<v8::Function>);
+ v8::Handle<v8::Value> vmeProperty(int index);
+ void setVMEProperty(int index, v8::Handle<v8::Value> v);
+
+ void connectAliasSignal(int index);
+
+protected:
+ virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
+
+private:
+ friend class QQmlVMEMetaObjectEndpoint;
+
+ QObject *object;
+ QQmlCompiledData *compiledData;
+ QQmlGuardedContextData ctxt;
+
+ const QQmlVMEMetaData *metaData;
+ int propOffset;
+ int methodOffset;
+
+ QQmlVMEVariant *data;
+ QQmlVMEMetaObjectEndpoint *aliasEndpoints;
+
+ v8::Persistent<v8::Array> varProperties;
+ int firstVarPropertyIndex;
+ bool varPropertiesInitialized;
+ static void VarPropertiesWeakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter);
+ static void GcPrologueCallback(QV8GCCallback::Node *node);
+ inline void allocateVarPropertiesArray();
+ inline void ensureVarPropertiesAllocated();
+
+ void connectAlias(int aliasId);
+ QBitArray aConnected;
+ QBitArray aInterceptors;
+ QHash<int, QPair<int, QQmlPropertyValueInterceptor*> > interceptors;
+
+ v8::Persistent<v8::Function> *v8methods;
+ v8::Handle<v8::Function> method(int);
+
+ v8::Handle<v8::Value> readVarProperty(int);
+ void writeVarProperty(int, v8::Handle<v8::Value>);
+ QVariant readPropertyAsVariant(int);
+ void writeProperty(int, const QVariant &);
+
+ QAbstractDynamicMetaObject *parent;
+
+ void listChanged(int);
+ class List : public QList<QObject*>
+ {
+ public:
+ List(int lpi) : notifyIndex(lpi) {}
+ int notifyIndex;
+ };
+ QList<List> listProperties;
+
+ static void list_append(QQmlListProperty<QObject> *, QObject *);
+ static int list_count(QQmlListProperty<QObject> *);
+ static QObject *list_at(QQmlListProperty<QObject> *, int);
+ static void list_clear(QQmlListProperty<QObject> *);
+
+ friend class QV8GCCallback;
+ friend class QV8QObjectWrapper;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLVMEMETAOBJECT_P_H
diff --git a/src/qml/qml/qqmlwatcher.cpp b/src/qml/qml/qqmlwatcher.cpp
new file mode 100644
index 0000000000..500185762f
--- /dev/null
+++ b/src/qml/qml/qqmlwatcher.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlwatcher_p.h"
+
+#include "qqmlexpression.h"
+#include "qqmlcontext.h"
+#include "qqml.h"
+
+#include <private/qqmldebugservice_p.h>
+#include "qqmlproperty_p.h"
+#include "qqmlvaluetype_p.h"
+
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlWatchProxy : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlWatchProxy(int id,
+ QObject *object,
+ int debugId,
+ const QMetaProperty &prop,
+ QQmlWatcher *parent = 0);
+
+ QQmlWatchProxy(int id,
+ QQmlExpression *exp,
+ int debugId,
+ QQmlWatcher *parent = 0);
+
+public slots:
+ void notifyValueChanged();
+
+private:
+ friend class QQmlWatcher;
+ int m_id;
+ QQmlWatcher *m_watch;
+ QObject *m_object;
+ int m_debugId;
+ QMetaProperty m_property;
+
+ QQmlExpression *m_expr;
+};
+
+QQmlWatchProxy::QQmlWatchProxy(int id,
+ QQmlExpression *exp,
+ int debugId,
+ QQmlWatcher *parent)
+: QObject(parent), m_id(id), m_watch(parent), m_object(0), m_debugId(debugId), m_expr(exp)
+{
+ QObject::connect(m_expr, SIGNAL(valueChanged()), this, SLOT(notifyValueChanged()));
+}
+
+QQmlWatchProxy::QQmlWatchProxy(int id,
+ QObject *object,
+ int debugId,
+ const QMetaProperty &prop,
+ QQmlWatcher *parent)
+: QObject(parent), m_id(id), m_watch(parent), m_object(object), m_debugId(debugId), m_property(prop), m_expr(0)
+{
+ static int refreshIdx = -1;
+ if(refreshIdx == -1)
+ refreshIdx = QQmlWatchProxy::staticMetaObject.indexOfMethod("notifyValueChanged()");
+
+ if (prop.hasNotifySignal())
+ QQmlPropertyPrivate::connect(m_object, prop.notifySignalIndex(), this, refreshIdx);
+}
+
+void QQmlWatchProxy::notifyValueChanged()
+{
+ QVariant v;
+ if (m_expr)
+ v = m_expr->evaluate();
+ else if (QQmlValueTypeFactory::isValueType(m_property.userType()))
+ v = m_property.read(m_object);
+
+ emit m_watch->propertyChanged(m_id, m_debugId, m_property, v);
+}
+
+
+QQmlWatcher::QQmlWatcher(QObject *parent)
+ : QObject(parent)
+{
+}
+
+bool QQmlWatcher::addWatch(int id, quint32 debugId)
+{
+ QObject *object = QQmlDebugService::objectForId(debugId);
+ if (object) {
+ int propCount = object->metaObject()->propertyCount();
+ for (int ii=0; ii<propCount; ii++)
+ addPropertyWatch(id, object, debugId, object->metaObject()->property(ii));
+ return true;
+ }
+ return false;
+}
+
+bool QQmlWatcher::addWatch(int id, quint32 debugId, const QByteArray &property)
+{
+ QObject *object = QQmlDebugService::objectForId(debugId);
+ if (object) {
+ int index = object->metaObject()->indexOfProperty(property.constData());
+ if (index >= 0) {
+ addPropertyWatch(id, object, debugId, object->metaObject()->property(index));
+ return true;
+ }
+ }
+ return false;
+}
+
+bool QQmlWatcher::addWatch(int id, quint32 objectId, const QString &expr)
+{
+ QObject *object = QQmlDebugService::objectForId(objectId);
+ QQmlContext *context = qmlContext(object);
+ if (context) {
+ QQmlExpression *exprObj = new QQmlExpression(context, object, expr);
+ exprObj->setNotifyOnValueChanged(true);
+ QQmlWatchProxy *proxy = new QQmlWatchProxy(id, exprObj, objectId, this);
+ exprObj->setParent(proxy);
+ m_proxies[id].append(proxy);
+ proxy->notifyValueChanged();
+ return true;
+ }
+ return false;
+}
+
+void QQmlWatcher::removeWatch(int id)
+{
+ if (!m_proxies.contains(id))
+ return;
+
+ QList<QPointer<QQmlWatchProxy> > proxies = m_proxies.take(id);
+ qDeleteAll(proxies);
+}
+
+void QQmlWatcher::addPropertyWatch(int id, QObject *object, quint32 debugId, const QMetaProperty &property)
+{
+ QQmlWatchProxy *proxy = new QQmlWatchProxy(id, object, debugId, property, this);
+ m_proxies[id].append(proxy);
+
+ proxy->notifyValueChanged();
+}
+
+QT_END_NAMESPACE
+
+#include <qqmlwatcher.moc>
diff --git a/src/qml/qml/qqmlwatcher_p.h b/src/qml/qml/qqmlwatcher_p.h
new file mode 100644
index 0000000000..70dc9d468c
--- /dev/null
+++ b/src/qml/qml/qqmlwatcher_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLWATCHER_P_H
+#define QQMLWATCHER_P_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/qobject.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qset.h>
+#include <QtCore/qpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlWatchProxy;
+class QQmlExpression;
+class QQmlContext;
+class QMetaProperty;
+
+class QQmlWatcher : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlWatcher(QObject * = 0);
+
+ bool addWatch(int id, quint32 objectId);
+ bool addWatch(int id, quint32 objectId, const QByteArray &property);
+ bool addWatch(int id, quint32 objectId, const QString &expr);
+
+ void removeWatch(int id);
+
+Q_SIGNALS:
+ void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
+
+private:
+ friend class QQmlWatchProxy;
+ void addPropertyWatch(int id, QObject *object, quint32 objectId, const QMetaProperty &property);
+
+ QHash<int, QList<QPointer<QQmlWatchProxy> > > m_proxies;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLWATCHER_P_H
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
new file mode 100644
index 0000000000..122693ad91
--- /dev/null
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -0,0 +1,1797 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlxmlhttprequest_p.h"
+
+#include <private/qv8engine_p.h>
+
+#include "qqmlengine.h"
+#include "qqmlengine_p.h"
+#include <private/qqmlrefcount_p.h>
+#include "qqmlengine_p.h"
+#include "qqmlexpression_p.h"
+#include "qqmlglobal_p.h"
+#include <private/qv8domerrors_p.h>
+
+#include <QtCore/qobject.h>
+#include <QtQml/qjsvalue.h>
+#include <QtQml/qjsengine.h>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtCore/qtextcodec.h>
+#include <QtCore/qxmlstream.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qdebug.h>
+
+#include <QtCore/QStringBuilder>
+
+#ifndef QT_NO_XMLSTREAMREADER
+
+#define V8THROW_REFERENCE(string) { \
+ v8::ThrowException(v8::Exception::ReferenceError(v8::String::New(string))); \
+ return v8::Handle<v8::Value>(); \
+}
+
+#define D(arg) (arg)->release()
+#define A(arg) (arg)->addref()
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(xhrDump, QML_XHR_DUMP);
+
+struct QQmlXMLHttpRequestData {
+ QQmlXMLHttpRequestData();
+ ~QQmlXMLHttpRequestData();
+
+ v8::Persistent<v8::Function> nodeFunction;
+
+ v8::Persistent<v8::Object> namedNodeMapPrototype;
+ v8::Persistent<v8::Object> nodeListPrototype;
+ v8::Persistent<v8::Object> nodePrototype;
+ v8::Persistent<v8::Object> elementPrototype;
+ v8::Persistent<v8::Object> attrPrototype;
+ v8::Persistent<v8::Object> characterDataPrototype;
+ v8::Persistent<v8::Object> textPrototype;
+ v8::Persistent<v8::Object> cdataPrototype;
+ v8::Persistent<v8::Object> documentPrototype;
+
+ v8::Local<v8::Object> newNode();
+};
+
+static inline QQmlXMLHttpRequestData *xhrdata(QV8Engine *engine)
+{
+ return (QQmlXMLHttpRequestData *)engine->xmlHttpRequestData();
+}
+
+QQmlXMLHttpRequestData::QQmlXMLHttpRequestData()
+{
+}
+
+QQmlXMLHttpRequestData::~QQmlXMLHttpRequestData()
+{
+ qPersistentDispose(nodeFunction);
+ qPersistentDispose(namedNodeMapPrototype);
+ qPersistentDispose(nodeListPrototype);
+ qPersistentDispose(nodePrototype);
+ qPersistentDispose(elementPrototype);
+ qPersistentDispose(attrPrototype);
+ qPersistentDispose(characterDataPrototype);
+ qPersistentDispose(textPrototype);
+ qPersistentDispose(cdataPrototype);
+ qPersistentDispose(documentPrototype);
+}
+
+v8::Local<v8::Object> QQmlXMLHttpRequestData::newNode()
+{
+ if (nodeFunction.IsEmpty()) {
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ nodeFunction = qPersistentNew<v8::Function>(ft->GetFunction());
+ }
+
+ return nodeFunction->NewInstance();
+}
+
+namespace {
+
+class DocumentImpl;
+class NodeImpl
+{
+public:
+ NodeImpl() : type(Element), document(0), parent(0) {}
+ virtual ~NodeImpl() {
+ for (int ii = 0; ii < children.count(); ++ii)
+ delete children.at(ii);
+ for (int ii = 0; ii < attributes.count(); ++ii)
+ delete attributes.at(ii);
+ }
+
+ // These numbers are copied from the Node IDL definition
+ enum Type {
+ Attr = 2,
+ CDATA = 4,
+ Comment = 8,
+ Document = 9,
+ DocumentFragment = 11,
+ DocumentType = 10,
+ Element = 1,
+ Entity = 6,
+ EntityReference = 5,
+ Notation = 12,
+ ProcessingInstruction = 7,
+ Text = 3
+ };
+ Type type;
+
+ QString namespaceUri;
+ QString name;
+
+ QString data;
+
+ void addref();
+ void release();
+
+ DocumentImpl *document;
+ NodeImpl *parent;
+
+ QList<NodeImpl *> children;
+ QList<NodeImpl *> attributes;
+};
+
+class DocumentImpl : public QQmlRefCount, public NodeImpl
+{
+public:
+ DocumentImpl() : root(0) { type = Document; }
+ virtual ~DocumentImpl() {
+ if (root) delete root;
+ }
+
+ QString version;
+ QString encoding;
+ bool isStandalone;
+
+ NodeImpl *root;
+
+ void addref() { QQmlRefCount::addref(); }
+ void release() { QQmlRefCount::release(); }
+};
+
+class NamedNodeMap
+{
+public:
+ // JS API
+ static v8::Handle<v8::Value> length(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> indexed(uint32_t index, const v8::AccessorInfo& info);
+ static v8::Handle<v8::Value> named(v8::Local<v8::String> property, const v8::AccessorInfo& args);
+
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+ static v8::Handle<v8::Value> create(QV8Engine *, NodeImpl *, QList<NodeImpl *> *);
+};
+
+class NodeList
+{
+public:
+ // JS API
+ static v8::Handle<v8::Value> length(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> indexed(uint32_t index, const v8::AccessorInfo& info);
+
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+ static v8::Handle<v8::Value> create(QV8Engine *, NodeImpl *);
+};
+
+class Node
+{
+public:
+ // JS API
+ static v8::Handle<v8::Value> nodeName(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> nodeValue(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> nodeType(v8::Local<v8::String>, const v8::AccessorInfo& args);
+
+ static v8::Handle<v8::Value> parentNode(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> childNodes(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> firstChild(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> lastChild(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> previousSibling(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> nextSibling(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> attributes(v8::Local<v8::String>, const v8::AccessorInfo& args);
+
+ //static v8::Handle<v8::Value> ownerDocument(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ //static v8::Handle<v8::Value> namespaceURI(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ //static v8::Handle<v8::Value> prefix(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ //static v8::Handle<v8::Value> localName(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ //static v8::Handle<v8::Value> baseURI(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ //static v8::Handle<v8::Value> textContent(v8::Local<v8::String>, const v8::AccessorInfo& args);
+
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+ static v8::Handle<v8::Value> create(QV8Engine *, NodeImpl *);
+
+ Node();
+ Node(const Node &o);
+ ~Node();
+ bool isNull() const;
+
+ NodeImpl *d;
+
+private:
+ Node &operator=(const Node &);
+};
+
+class Element : public Node
+{
+public:
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+};
+
+class Attr : public Node
+{
+public:
+ // JS API
+ static v8::Handle<v8::Value> name(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> specified(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> value(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> ownerElement(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> schemaTypeInfo(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> isId(v8::Local<v8::String>, const v8::AccessorInfo& args);
+
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+};
+
+class CharacterData : public Node
+{
+public:
+ // JS API
+ static v8::Handle<v8::Value> length(v8::Local<v8::String>, const v8::AccessorInfo& args);
+
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+};
+
+class Text : public CharacterData
+{
+public:
+ // JS API
+ static v8::Handle<v8::Value> isElementContentWhitespace(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> wholeText(v8::Local<v8::String>, const v8::AccessorInfo& args);
+
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+};
+
+class CDATA : public Text
+{
+public:
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+};
+
+class Document : public Node
+{
+public:
+ // JS API
+ static v8::Handle<v8::Value> xmlVersion(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> xmlEncoding(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> xmlStandalone(v8::Local<v8::String>, const v8::AccessorInfo& args);
+ static v8::Handle<v8::Value> documentElement(v8::Local<v8::String>, const v8::AccessorInfo& args);
+
+ // C++ API
+ static v8::Handle<v8::Object> prototype(QV8Engine *);
+ static v8::Handle<v8::Value> load(QV8Engine *engine, const QByteArray &data);
+};
+
+}
+
+class QQmlDOMNodeResource : public QV8ObjectResource, public Node
+{
+ V8_RESOURCE_TYPE(DOMNodeType);
+public:
+ QQmlDOMNodeResource(QV8Engine *e);
+
+ QList<NodeImpl *> *list; // Only used in NamedNodeMap
+};
+
+QQmlDOMNodeResource::QQmlDOMNodeResource(QV8Engine *e)
+: QV8ObjectResource(e), list(0)
+{
+}
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Node)
+Q_DECLARE_METATYPE(NodeList)
+Q_DECLARE_METATYPE(NamedNodeMap)
+
+QT_BEGIN_NAMESPACE
+
+void NodeImpl::addref()
+{
+ A(document);
+}
+
+void NodeImpl::release()
+{
+ D(document);
+}
+
+v8::Handle<v8::Value> Node::nodeName(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ switch (r->d->type) {
+ case NodeImpl::Document:
+ return v8::String::New("#document");
+ case NodeImpl::CDATA:
+ return v8::String::New("#cdata-section");
+ case NodeImpl::Text:
+ return v8::String::New("#text");
+ default:
+ return engine->toString(r->d->name);
+ }
+}
+
+v8::Handle<v8::Value> Node::nodeValue(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if (r->d->type == NodeImpl::Document ||
+ r->d->type == NodeImpl::DocumentFragment ||
+ r->d->type == NodeImpl::DocumentType ||
+ r->d->type == NodeImpl::Element ||
+ r->d->type == NodeImpl::Entity ||
+ r->d->type == NodeImpl::EntityReference ||
+ r->d->type == NodeImpl::Notation)
+ return v8::Null();
+
+ return engine->toString(r->d->data);
+}
+
+v8::Handle<v8::Value> Node::nodeType(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ return v8::Integer::New(r->d->type);
+}
+
+v8::Handle<v8::Value> Node::parentNode(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if (r->d->parent) return Node::create(engine, r->d->parent);
+ else return v8::Null();
+}
+
+v8::Handle<v8::Value> Node::childNodes(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ return NodeList::create(engine, r->d);
+}
+
+v8::Handle<v8::Value> Node::firstChild(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if (r->d->children.isEmpty()) return v8::Null();
+ else return Node::create(engine, r->d->children.first());
+}
+
+v8::Handle<v8::Value> Node::lastChild(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if (r->d->children.isEmpty()) return v8::Null();
+ else return Node::create(engine, r->d->children.last());
+}
+
+v8::Handle<v8::Value> Node::previousSibling(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if (!r->d->parent) return v8::Null();
+
+ for (int ii = 0; ii < r->d->parent->children.count(); ++ii) {
+ if (r->d->parent->children.at(ii) == r->d) {
+ if (ii == 0) return v8::Null();
+ else return Node::create(engine, r->d->parent->children.at(ii - 1));
+ }
+ }
+
+ return v8::Null();
+}
+
+v8::Handle<v8::Value> Node::nextSibling(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if (!r->d->parent) return v8::Null();
+
+ for (int ii = 0; ii < r->d->parent->children.count(); ++ii) {
+ if (r->d->parent->children.at(ii) == r->d) {
+ if ((ii + 1) == r->d->parent->children.count()) return v8::Null();
+ else return Node::create(engine, r->d->parent->children.at(ii + 1));
+ }
+ }
+
+ return v8::Null();
+}
+
+v8::Handle<v8::Value> Node::attributes(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if (r->d->type != NodeImpl::Element)
+ return v8::Null();
+ else
+ return NamedNodeMap::create(engine, r->d, &r->d->attributes);
+}
+
+v8::Handle<v8::Object> Node::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->nodePrototype.IsEmpty()) {
+ d->nodePrototype = qPersistentNew<v8::Object>(v8::Object::New());
+ d->nodePrototype->SetAccessor(v8::String::New("nodeName"), nodeName,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("nodeValue"), nodeValue,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("nodeType"), nodeType,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("parentNode"), parentNode,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("childNodes"), childNodes,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("firstChild"), firstChild,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("lastChild"), lastChild,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("previousSibling"), previousSibling,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("nextSibling"), nextSibling,
+ 0, v8::External::Wrap(engine));
+ d->nodePrototype->SetAccessor(v8::String::New("attributes"), attributes,
+ 0, v8::External::Wrap(engine));
+ engine->freezeObject(d->nodePrototype);
+ }
+ return d->nodePrototype;
+}
+
+v8::Handle<v8::Value> Node::create(QV8Engine *engine, NodeImpl *data)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ v8::Local<v8::Object> instance = d->newNode();
+
+ switch (data->type) {
+ case NodeImpl::Attr:
+ instance->SetPrototype(Attr::prototype(engine));
+ break;
+ case NodeImpl::Comment:
+ case NodeImpl::Document:
+ case NodeImpl::DocumentFragment:
+ case NodeImpl::DocumentType:
+ case NodeImpl::Entity:
+ case NodeImpl::EntityReference:
+ case NodeImpl::Notation:
+ case NodeImpl::ProcessingInstruction:
+ return v8::Undefined();
+ case NodeImpl::CDATA:
+ instance->SetPrototype(CDATA::prototype(engine));
+ break;
+ case NodeImpl::Text:
+ instance->SetPrototype(Text::prototype(engine));
+ break;
+ case NodeImpl::Element:
+ instance->SetPrototype(Element::prototype(engine));
+ break;
+ }
+
+ QQmlDOMNodeResource *r = new QQmlDOMNodeResource(engine);
+ r->d = data;
+ if (data) A(data);
+ instance->SetExternalResource(r);
+
+ return instance;
+}
+
+v8::Handle<v8::Object> Element::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->elementPrototype.IsEmpty()) {
+ d->elementPrototype = qPersistentNew<v8::Object>(v8::Object::New());
+ d->elementPrototype->SetPrototype(Node::prototype(engine));
+ d->elementPrototype->SetAccessor(v8::String::New("tagName"), nodeName,
+ 0, v8::External::Wrap(engine));
+ engine->freezeObject(d->elementPrototype);
+ }
+ return d->elementPrototype;
+}
+
+v8::Handle<v8::Object> Attr::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->attrPrototype.IsEmpty()) {
+ d->attrPrototype = qPersistentNew<v8::Object>(v8::Object::New());
+ d->attrPrototype->SetPrototype(Node::prototype(engine));
+ d->attrPrototype->SetAccessor(v8::String::New("name"), name,
+ 0, v8::External::Wrap(engine));
+ d->attrPrototype->SetAccessor(v8::String::New("value"), value,
+ 0, v8::External::Wrap(engine));
+ d->attrPrototype->SetAccessor(v8::String::New("ownerElement"), ownerElement,
+ 0, v8::External::Wrap(engine));
+ engine->freezeObject(d->attrPrototype);
+ }
+ return d->attrPrototype;
+}
+
+v8::Handle<v8::Value> Attr::name(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ return engine->toString(r->d->name);
+}
+
+v8::Handle<v8::Value> Attr::value(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ return engine->toString(r->d->data);
+}
+
+v8::Handle<v8::Value> Attr::ownerElement(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ return Node::create(engine, r->d->parent);
+}
+
+v8::Handle<v8::Value> CharacterData::length(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+ Q_UNUSED(engine)
+ return v8::Integer::New(r->d->data.length());
+}
+
+v8::Handle<v8::Object> CharacterData::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->characterDataPrototype.IsEmpty()) {
+ d->characterDataPrototype = qPersistentNew<v8::Object>(v8::Object::New());
+ d->characterDataPrototype->SetPrototype(Node::prototype(engine));
+ d->characterDataPrototype->SetAccessor(v8::String::New("data"), nodeValue,
+ 0, v8::External::Wrap(engine));
+ d->characterDataPrototype->SetAccessor(v8::String::New("length"), length,
+ 0, v8::External::Wrap(engine));
+ engine->freezeObject(d->characterDataPrototype);
+ }
+ return d->characterDataPrototype;
+}
+
+v8::Handle<v8::Value> Text::isElementContentWhitespace(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+ Q_UNUSED(engine)
+ return v8::Boolean::New(r->d->data.trimmed().isEmpty());
+}
+
+v8::Handle<v8::Value> Text::wholeText(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ return engine->toString(r->d->data);
+}
+
+v8::Handle<v8::Object> Text::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->textPrototype.IsEmpty()) {
+ d->textPrototype = qPersistentNew<v8::Object>(v8::Object::New());
+ d->textPrototype->SetPrototype(CharacterData::prototype(engine));
+ d->textPrototype->SetAccessor(v8::String::New("isElementContentWhitespace"), isElementContentWhitespace,
+ 0, v8::External::Wrap(engine));
+ d->textPrototype->SetAccessor(v8::String::New("wholeText"), wholeText,
+ 0, v8::External::Wrap(engine));
+ engine->freezeObject(d->textPrototype);
+ }
+ return d->textPrototype;
+}
+
+v8::Handle<v8::Object> CDATA::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->cdataPrototype.IsEmpty()) {
+ d->cdataPrototype = qPersistentNew<v8::Object>(v8::Object::New());
+ d->cdataPrototype->SetPrototype(Text::prototype(engine));
+ engine->freezeObject(d->cdataPrototype);
+ }
+ return d->cdataPrototype;
+}
+
+v8::Handle<v8::Object> Document::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->documentPrototype.IsEmpty()) {
+ d->documentPrototype = qPersistentNew<v8::Object>(v8::Object::New());
+ d->documentPrototype->SetPrototype(Node::prototype(engine));
+ d->documentPrototype->SetAccessor(v8::String::New("xmlVersion"), xmlVersion,
+ 0, v8::External::Wrap(engine));
+ d->documentPrototype->SetAccessor(v8::String::New("xmlEncoding"), xmlEncoding,
+ 0, v8::External::Wrap(engine));
+ d->documentPrototype->SetAccessor(v8::String::New("xmlStandalone"), xmlStandalone,
+ 0, v8::External::Wrap(engine));
+ d->documentPrototype->SetAccessor(v8::String::New("documentElement"), documentElement,
+ 0, v8::External::Wrap(engine));
+ engine->freezeObject(d->documentPrototype);
+ }
+ return d->documentPrototype;
+}
+
+v8::Handle<v8::Value> Document::load(QV8Engine *engine, const QByteArray &data)
+{
+ Q_ASSERT(engine);
+
+ DocumentImpl *document = 0;
+ QStack<NodeImpl *> nodeStack;
+
+ QXmlStreamReader reader(data);
+
+ while (!reader.atEnd()) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::NoToken:
+ break;
+ case QXmlStreamReader::Invalid:
+ break;
+ case QXmlStreamReader::StartDocument:
+ Q_ASSERT(!document);
+ document = new DocumentImpl;
+ document->document = document;
+ document->version = reader.documentVersion().toString();
+ document->encoding = reader.documentEncoding().toString();
+ document->isStandalone = reader.isStandaloneDocument();
+ break;
+ case QXmlStreamReader::EndDocument:
+ break;
+ case QXmlStreamReader::StartElement:
+ {
+ Q_ASSERT(document);
+ NodeImpl *node = new NodeImpl;
+ node->document = document;
+ node->namespaceUri = reader.namespaceUri().toString();
+ node->name = reader.name().toString();
+ if (nodeStack.isEmpty()) {
+ document->root = node;
+ } else {
+ node->parent = nodeStack.top();
+ node->parent->children.append(node);
+ }
+ nodeStack.append(node);
+
+ foreach (const QXmlStreamAttribute &a, reader.attributes()) {
+ NodeImpl *attr = new NodeImpl;
+ attr->document = document;
+ attr->type = NodeImpl::Attr;
+ attr->namespaceUri = a.namespaceUri().toString();
+ attr->name = a.name().toString();
+ attr->data = a.value().toString();
+ attr->parent = node;
+ node->attributes.append(attr);
+ }
+ }
+ break;
+ case QXmlStreamReader::EndElement:
+ nodeStack.pop();
+ break;
+ case QXmlStreamReader::Characters:
+ {
+ NodeImpl *node = new NodeImpl;
+ node->document = document;
+ node->type = reader.isCDATA()?NodeImpl::CDATA:NodeImpl::Text;
+ node->parent = nodeStack.top();
+ node->parent->children.append(node);
+ node->data = reader.text().toString();
+ }
+ break;
+ case QXmlStreamReader::Comment:
+ break;
+ case QXmlStreamReader::DTD:
+ break;
+ case QXmlStreamReader::EntityReference:
+ break;
+ case QXmlStreamReader::ProcessingInstruction:
+ break;
+ }
+ }
+
+ if (!document || reader.hasError()) {
+ if (document) D(document);
+ return v8::Null();
+ }
+
+ v8::Local<v8::Object> instance = xhrdata(engine)->newNode();
+ QQmlDOMNodeResource *r = new QQmlDOMNodeResource(engine);
+ r->d = document;
+ instance->SetExternalResource(r);
+ instance->SetPrototype(Document::prototype(engine));
+ return instance;
+}
+
+Node::Node()
+: d(0)
+{
+}
+
+Node::Node(const Node &o)
+: d(o.d)
+{
+ if (d) A(d);
+}
+
+Node::~Node()
+{
+ if (d) D(d);
+}
+
+bool Node::isNull() const
+{
+ return d == 0;
+}
+
+v8::Handle<v8::Value> NamedNodeMap::length(v8::Local<v8::String>, const v8::AccessorInfo &args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+ Q_UNUSED(engine)
+ return v8::Integer::New(r->list->count());
+}
+
+v8::Handle<v8::Value> NamedNodeMap::indexed(uint32_t index, const v8::AccessorInfo& args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r || !r->list) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if ((int)index < r->list->count()) {
+ return Node::create(engine, r->list->at(index));
+ } else {
+ return v8::Undefined();
+ }
+}
+
+v8::Handle<v8::Value> NamedNodeMap::named(v8::Local<v8::String> property, const v8::AccessorInfo& args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r || !r->list) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ QString str = engine->toString(property);
+ for (int ii = 0; ii < r->list->count(); ++ii) {
+ if (r->list->at(ii)->name == str) {
+ return Node::create(engine, r->list->at(ii));
+ }
+ }
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Object> NamedNodeMap::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->namedNodeMapPrototype.IsEmpty()) {
+ v8::Local<v8::ObjectTemplate> ot = v8::ObjectTemplate::New();
+ ot->SetAccessor(v8::String::New("length"), length, 0, v8::External::Wrap(engine));
+ ot->SetIndexedPropertyHandler(indexed, 0, 0, 0, 0, v8::External::Wrap(engine));
+ ot->SetFallbackPropertyHandler(named, 0, 0, 0, 0, v8::External::Wrap(engine));
+ d->namedNodeMapPrototype = qPersistentNew<v8::Object>(ot->NewInstance());
+ engine->freezeObject(d->namedNodeMapPrototype);
+ }
+ return d->namedNodeMapPrototype;
+}
+
+v8::Handle<v8::Value> NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, QList<NodeImpl *> *list)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ v8::Local<v8::Object> instance = d->newNode();
+ instance->SetPrototype(NamedNodeMap::prototype(engine));
+ QQmlDOMNodeResource *r = new QQmlDOMNodeResource(engine);
+ r->d = data;
+ r->list = list;
+ if (data) A(data);
+ instance->SetExternalResource(r);
+ return instance;
+}
+
+v8::Handle<v8::Value> NodeList::indexed(uint32_t index, const v8::AccessorInfo& args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ if ((int)index < r->d->children.count()) {
+ return Node::create(engine, r->d->children.at(index));
+ } else {
+ return v8::Undefined();
+ }
+}
+
+v8::Handle<v8::Value> NodeList::length(v8::Local<v8::String>, const v8::AccessorInfo& args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+ Q_UNUSED(engine)
+ return v8::Integer::New(r->d->children.count());
+}
+
+v8::Handle<v8::Object> NodeList::prototype(QV8Engine *engine)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ if (d->nodeListPrototype.IsEmpty()) {
+ v8::Local<v8::ObjectTemplate> ot = v8::ObjectTemplate::New();
+ ot->SetAccessor(v8::String::New("length"), length, 0, v8::External::Wrap(engine));
+ ot->SetIndexedPropertyHandler(indexed, 0, 0, 0, 0, v8::External::Wrap(engine));
+ d->nodeListPrototype = qPersistentNew<v8::Object>(ot->NewInstance());
+ engine->freezeObject(d->nodeListPrototype);
+ }
+ return d->nodeListPrototype;
+}
+
+v8::Handle<v8::Value> NodeList::create(QV8Engine *engine, NodeImpl *data)
+{
+ QQmlXMLHttpRequestData *d = xhrdata(engine);
+ v8::Local<v8::Object> instance = d->newNode();
+ instance->SetPrototype(NodeList::prototype(engine));
+ QQmlDOMNodeResource *r = new QQmlDOMNodeResource(engine);
+ r->d = data;
+ if (data) A(data);
+ instance->SetExternalResource(r);
+ return instance;
+}
+
+v8::Handle<v8::Value> Document::documentElement(v8::Local<v8::String>, const v8::AccessorInfo& args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r || r->d->type != NodeImpl::Document) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ return Node::create(engine, static_cast<DocumentImpl *>(r->d)->root);
+}
+
+v8::Handle<v8::Value> Document::xmlStandalone(v8::Local<v8::String>, const v8::AccessorInfo& args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r || r->d->type != NodeImpl::Document) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+ Q_UNUSED(engine)
+ return v8::Boolean::New(static_cast<DocumentImpl *>(r->d)->isStandalone);
+}
+
+v8::Handle<v8::Value> Document::xmlVersion(v8::Local<v8::String>, const v8::AccessorInfo& args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r || r->d->type != NodeImpl::Document) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ return engine->toString(static_cast<DocumentImpl *>(r->d)->version);
+}
+
+v8::Handle<v8::Value> Document::xmlEncoding(v8::Local<v8::String>, const v8::AccessorInfo& args)
+{
+ QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This());
+ if (!r || r->d->type != NodeImpl::Document) return v8::Undefined();
+ QV8Engine *engine = V8ENGINE();
+
+ return engine->toString(static_cast<DocumentImpl *>(r->d)->encoding);
+}
+
+class QQmlXMLHttpRequest : public QObject, public QV8ObjectResource
+{
+Q_OBJECT
+V8_RESOURCE_TYPE(XMLHttpRequestType)
+public:
+ enum State { Unsent = 0,
+ Opened = 1, HeadersReceived = 2,
+ Loading = 3, Done = 4 };
+
+ QQmlXMLHttpRequest(QV8Engine *engine, QNetworkAccessManager *manager);
+ virtual ~QQmlXMLHttpRequest();
+
+ bool sendFlag() const;
+ bool errorFlag() const;
+ quint32 readyState() const;
+ int replyStatus() const;
+ QString replyStatusText() const;
+
+ v8::Handle<v8::Value> open(v8::Handle<v8::Object> me, const QString &, const QUrl &);
+ v8::Handle<v8::Value> send(v8::Handle<v8::Object> me, const QByteArray &);
+ v8::Handle<v8::Value> abort(v8::Handle<v8::Object> me);
+
+ void addHeader(const QString &, const QString &);
+ QString header(const QString &name);
+ QString headers();
+
+
+ QString responseBody();
+ const QByteArray & rawResponseBody() const;
+ bool receivedXml() const;
+private slots:
+ void downloadProgress(qint64);
+ void error(QNetworkReply::NetworkError);
+ void finished();
+
+private:
+ void requestFromUrl(const QUrl &url);
+
+ State m_state;
+ bool m_errorFlag;
+ bool m_sendFlag;
+ QString m_method;
+ QUrl m_url;
+ QByteArray m_responseEntityBody;
+ QByteArray m_data;
+ int m_redirectCount;
+
+ typedef QPair<QByteArray, QByteArray> HeaderPair;
+ typedef QList<HeaderPair> HeadersList;
+ HeadersList m_headersList;
+ void fillHeadersList();
+
+ bool m_gotXml;
+ QByteArray m_mime;
+ QByteArray m_charset;
+ QTextCodec *m_textCodec;
+#ifndef QT_NO_TEXTCODEC
+ QTextCodec* findTextCodec() const;
+#endif
+ void readEncoding();
+
+ v8::Handle<v8::Object> getMe() const;
+ void setMe(v8::Handle<v8::Object> me);
+ v8::Persistent<v8::Object> m_me;
+
+ void dispatchCallback(v8::Handle<v8::Object> me);
+ void printError(v8::Handle<v8::Message>);
+
+ int m_status;
+ QString m_statusText;
+ QNetworkRequest m_request;
+ QQmlGuard<QNetworkReply> m_network;
+ void destroyNetwork();
+
+ QNetworkAccessManager *m_nam;
+ QNetworkAccessManager *networkAccessManager() { return m_nam; }
+};
+
+QQmlXMLHttpRequest::QQmlXMLHttpRequest(QV8Engine *engine, QNetworkAccessManager *manager)
+: QV8ObjectResource(engine), m_state(Unsent), m_errorFlag(false), m_sendFlag(false),
+ m_redirectCount(0), m_gotXml(false), m_textCodec(0), m_network(0), m_nam(manager)
+{
+}
+
+QQmlXMLHttpRequest::~QQmlXMLHttpRequest()
+{
+ destroyNetwork();
+}
+
+bool QQmlXMLHttpRequest::sendFlag() const
+{
+ return m_sendFlag;
+}
+
+bool QQmlXMLHttpRequest::errorFlag() const
+{
+ return m_errorFlag;
+}
+
+quint32 QQmlXMLHttpRequest::readyState() const
+{
+ return m_state;
+}
+
+int QQmlXMLHttpRequest::replyStatus() const
+{
+ return m_status;
+}
+
+QString QQmlXMLHttpRequest::replyStatusText() const
+{
+ return m_statusText;
+}
+
+v8::Handle<v8::Value> QQmlXMLHttpRequest::open(v8::Handle<v8::Object> me, const QString &method,
+ const QUrl &url)
+{
+ destroyNetwork();
+ m_sendFlag = false;
+ m_errorFlag = false;
+ m_responseEntityBody = QByteArray();
+ m_method = method;
+ m_url = url;
+ m_state = Opened;
+ dispatchCallback(me);
+ return v8::Undefined();
+}
+
+void QQmlXMLHttpRequest::addHeader(const QString &name, const QString &value)
+{
+ QByteArray utfname = name.toUtf8();
+
+ if (m_request.hasRawHeader(utfname)) {
+ m_request.setRawHeader(utfname, m_request.rawHeader(utfname) + ',' + value.toUtf8());
+ } else {
+ m_request.setRawHeader(utfname, value.toUtf8());
+ }
+}
+
+QString QQmlXMLHttpRequest::header(const QString &name)
+{
+ QByteArray utfname = name.toLower().toUtf8();
+
+ foreach (const HeaderPair &header, m_headersList) {
+ if (header.first == utfname)
+ return QString::fromUtf8(header.second);
+ }
+ return QString();
+}
+
+QString QQmlXMLHttpRequest::headers()
+{
+ QString ret;
+
+ foreach (const HeaderPair &header, m_headersList) {
+ if (ret.length())
+ ret.append(QLatin1String("\r\n"));
+ ret = ret % QString::fromUtf8(header.first) % QLatin1String(": ")
+ % QString::fromUtf8(header.second);
+ }
+ return ret;
+}
+
+void QQmlXMLHttpRequest::fillHeadersList()
+{
+ QList<QByteArray> headerList = m_network->rawHeaderList();
+
+ m_headersList.clear();
+ foreach (const QByteArray &header, headerList) {
+ HeaderPair pair (header.toLower(), m_network->rawHeader(header));
+ if (pair.first == "set-cookie" ||
+ pair.first == "set-cookie2")
+ continue;
+
+ m_headersList << pair;
+ }
+}
+
+void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url)
+{
+ QNetworkRequest request = m_request;
+ request.setUrl(url);
+ if(m_method == QLatin1String("POST") ||
+ m_method == QLatin1String("PUT")) {
+ QVariant var = request.header(QNetworkRequest::ContentTypeHeader);
+ if (var.isValid()) {
+ QString str = var.toString();
+ int charsetIdx = str.indexOf(QLatin1String("charset="));
+ if (charsetIdx == -1) {
+ // No charset - append
+ if (!str.isEmpty()) str.append(QLatin1Char(';'));
+ str.append(QLatin1String("charset=UTF-8"));
+ } else {
+ charsetIdx += 8;
+ int n = 0;
+ int semiColon = str.indexOf(QLatin1Char(';'), charsetIdx);
+ if (semiColon == -1) {
+ n = str.length() - charsetIdx;
+ } else {
+ n = semiColon - charsetIdx;
+ }
+
+ str.replace(charsetIdx, n, QLatin1String("UTF-8"));
+ }
+ request.setHeader(QNetworkRequest::ContentTypeHeader, str);
+ } else {
+ request.setHeader(QNetworkRequest::ContentTypeHeader,
+ QLatin1String("text/plain;charset=UTF-8"));
+ }
+ }
+
+ if (xhrDump()) {
+ qWarning().nospace() << "XMLHttpRequest: " << qPrintable(m_method) << " " << qPrintable(url.toString());
+ if (!m_data.isEmpty()) {
+ qWarning().nospace() << " "
+ << qPrintable(QString::fromUtf8(m_data));
+ }
+ }
+
+ if (m_method == QLatin1String("GET"))
+ m_network = networkAccessManager()->get(request);
+ else if (m_method == QLatin1String("HEAD"))
+ m_network = networkAccessManager()->head(request);
+ else if (m_method == QLatin1String("POST"))
+ m_network = networkAccessManager()->post(request, m_data);
+ else if (m_method == QLatin1String("PUT"))
+ m_network = networkAccessManager()->put(request, m_data);
+ else if (m_method == QLatin1String("DELETE"))
+ m_network = networkAccessManager()->deleteResource(request);
+
+ QObject::connect(m_network, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(downloadProgress(qint64)));
+ QObject::connect(m_network, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(error(QNetworkReply::NetworkError)));
+ QObject::connect(m_network, SIGNAL(finished()),
+ this, SLOT(finished()));
+}
+
+v8::Handle<v8::Value> QQmlXMLHttpRequest::send(v8::Handle<v8::Object> me, const QByteArray &data)
+{
+ m_errorFlag = false;
+ m_sendFlag = true;
+ m_redirectCount = 0;
+ m_data = data;
+
+ setMe(me);
+
+ requestFromUrl(m_url);
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> QQmlXMLHttpRequest::abort(v8::Handle<v8::Object> me)
+{
+ destroyNetwork();
+ m_responseEntityBody = QByteArray();
+ m_errorFlag = true;
+ m_request = QNetworkRequest();
+
+ if (!(m_state == Unsent ||
+ (m_state == Opened && !m_sendFlag) ||
+ m_state == Done)) {
+
+ m_state = Done;
+ m_sendFlag = false;
+ dispatchCallback(me);
+ }
+
+ m_state = Unsent;
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Object> QQmlXMLHttpRequest::getMe() const
+{
+ return m_me;
+}
+
+void QQmlXMLHttpRequest::setMe(v8::Handle<v8::Object> me)
+{
+ qPersistentDispose(m_me);
+
+ if (!me.IsEmpty())
+ m_me = qPersistentNew<v8::Object>(me);
+}
+
+void QQmlXMLHttpRequest::downloadProgress(qint64 bytes)
+{
+ v8::HandleScope handle_scope;
+
+ Q_UNUSED(bytes)
+ m_status =
+ m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ m_statusText =
+ QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
+
+ // ### We assume if this is called the headers are now available
+ if (m_state < HeadersReceived) {
+ m_state = HeadersReceived;
+ fillHeadersList ();
+ v8::TryCatch tc;
+ dispatchCallback(m_me);
+ if (tc.HasCaught()) printError(tc.Message());
+ }
+
+ bool wasEmpty = m_responseEntityBody.isEmpty();
+ m_responseEntityBody.append(m_network->readAll());
+ if (wasEmpty && !m_responseEntityBody.isEmpty()) {
+ m_state = Loading;
+ v8::TryCatch tc;
+ dispatchCallback(m_me);
+ if (tc.HasCaught()) printError(tc.Message());
+ }
+}
+
+static const char *errorToString(QNetworkReply::NetworkError error)
+{
+ int idx = QNetworkReply::staticMetaObject.indexOfEnumerator("NetworkError");
+ if (idx == -1) return "EnumLookupFailed";
+
+ QMetaEnum e = QNetworkReply::staticMetaObject.enumerator(idx);
+
+ const char *name = e.valueToKey(error);
+ if (!name) return "EnumLookupFailed";
+ else return name;
+}
+
+void QQmlXMLHttpRequest::error(QNetworkReply::NetworkError error)
+{
+ v8::HandleScope handle_scope;
+
+ Q_UNUSED(error)
+ m_status =
+ m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ m_statusText =
+ QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
+
+ m_responseEntityBody = QByteArray();
+
+ m_request = QNetworkRequest();
+ m_data.clear();
+ destroyNetwork();
+
+ if (xhrDump()) {
+ qWarning().nospace() << "XMLHttpRequest: ERROR " << qPrintable(m_url.toString());
+ qWarning().nospace() << " " << error << " " << errorToString(error) << " " << m_statusText;
+ }
+
+ if (error == QNetworkReply::ContentAccessDenied ||
+ error == QNetworkReply::ContentOperationNotPermittedError ||
+ error == QNetworkReply::ContentNotFoundError ||
+ error == QNetworkReply::AuthenticationRequiredError ||
+ error == QNetworkReply::ContentReSendError ||
+ error == QNetworkReply::UnknownContentError) {
+ m_state = Loading;
+ v8::TryCatch tc;
+ dispatchCallback(m_me);
+ if (tc.HasCaught()) printError(tc.Message());
+ } else {
+ m_errorFlag = true;
+ }
+
+ m_state = Done;
+
+ v8::TryCatch tc;
+ dispatchCallback(m_me);
+ if (tc.HasCaught()) printError(tc.Message());
+}
+
+#define XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION 15
+void QQmlXMLHttpRequest::finished()
+{
+ v8::HandleScope handle_scope;
+
+ m_redirectCount++;
+ if (m_redirectCount < XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = m_network->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = m_network->url().resolved(redirect.toUrl());
+ destroyNetwork();
+ requestFromUrl(url);
+ return;
+ }
+ }
+
+ m_status =
+ m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ m_statusText =
+ QString::fromUtf8(m_network->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray());
+
+ if (m_state < HeadersReceived) {
+ m_state = HeadersReceived;
+ fillHeadersList ();
+ v8::TryCatch tc;
+ dispatchCallback(m_me);
+ if (tc.HasCaught()) printError(tc.Message());
+ }
+ m_responseEntityBody.append(m_network->readAll());
+ readEncoding();
+
+ if (xhrDump()) {
+ qWarning().nospace() << "XMLHttpRequest: RESPONSE " << qPrintable(m_url.toString());
+ if (!m_responseEntityBody.isEmpty()) {
+ qWarning().nospace() << " "
+ << qPrintable(QString::fromUtf8(m_responseEntityBody));
+ }
+ }
+
+
+ m_data.clear();
+ destroyNetwork();
+ if (m_state < Loading) {
+ m_state = Loading;
+ v8::TryCatch tc;
+ dispatchCallback(m_me);
+ if (tc.HasCaught()) printError(tc.Message());
+ }
+ m_state = Done;
+
+ v8::TryCatch tc;
+ dispatchCallback(m_me);
+ if (tc.HasCaught()) printError(tc.Message());
+
+ setMe(v8::Handle<v8::Object>());
+}
+
+
+void QQmlXMLHttpRequest::readEncoding()
+{
+ foreach (const HeaderPair &header, m_headersList) {
+ if (header.first == "content-type") {
+ int separatorIdx = header.second.indexOf(';');
+ if (separatorIdx == -1) {
+ m_mime == header.second;
+ } else {
+ m_mime = header.second.mid(0, separatorIdx);
+ int charsetIdx = header.second.indexOf("charset=");
+ if (charsetIdx != -1) {
+ charsetIdx += 8;
+ separatorIdx = header.second.indexOf(';', charsetIdx);
+ m_charset = header.second.mid(charsetIdx, separatorIdx >= 0 ? separatorIdx : header.second.length());
+ }
+ }
+ break;
+ }
+ }
+
+ if (m_mime.isEmpty() || m_mime == "text/xml" || m_mime == "application/xml" || m_mime.endsWith("+xml"))
+ m_gotXml = true;
+}
+
+bool QQmlXMLHttpRequest::receivedXml() const
+{
+ return m_gotXml;
+}
+
+
+#ifndef QT_NO_TEXTCODEC
+QTextCodec* QQmlXMLHttpRequest::findTextCodec() const
+{
+ QTextCodec *codec = 0;
+
+ if (!m_charset.isEmpty())
+ codec = QTextCodec::codecForName(m_charset);
+
+ if (!codec && m_gotXml) {
+ QXmlStreamReader reader(m_responseEntityBody);
+ reader.readNext();
+ codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
+ }
+
+ if (!codec && m_mime == "text/html")
+ codec = QTextCodec::codecForHtml(m_responseEntityBody, 0);
+
+ if (!codec)
+ codec = QTextCodec::codecForUtfText(m_responseEntityBody, 0);
+
+ if (!codec)
+ codec = QTextCodec::codecForName("UTF-8");
+ return codec;
+}
+#endif
+
+
+QString QQmlXMLHttpRequest::responseBody()
+{
+#ifndef QT_NO_TEXTCODEC
+ if (!m_textCodec)
+ m_textCodec = findTextCodec();
+ if (m_textCodec)
+ return m_textCodec->toUnicode(m_responseEntityBody);
+#endif
+
+ return QString::fromUtf8(m_responseEntityBody);
+}
+
+const QByteArray &QQmlXMLHttpRequest::rawResponseBody() const
+{
+ return m_responseEntityBody;
+}
+
+// Requires a TryCatch scope
+void QQmlXMLHttpRequest::dispatchCallback(v8::Handle<v8::Object> me)
+{
+ v8::Local<v8::Value> callback = me->Get(v8::String::New("onreadystatechange"));
+ if (callback->IsFunction()) {
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(callback);
+
+ f->Call(me, 0, 0);
+ }
+}
+
+// Must have a handle scope
+void QQmlXMLHttpRequest::printError(v8::Handle<v8::Message> message)
+{
+ v8::Context::Scope scope(engine->context());
+
+ QQmlError error;
+ QQmlExpressionPrivate::exceptionToError(message, error);
+ QQmlEnginePrivate::warning(QQmlEnginePrivate::get(engine->engine()), error);
+}
+
+void QQmlXMLHttpRequest::destroyNetwork()
+{
+ if (m_network) {
+ m_network->disconnect();
+ m_network->deleteLater();
+ m_network = 0;
+ }
+}
+
+// XMLHttpRequest methods
+static v8::Handle<v8::Value> qmlxmlhttprequest_open(const v8::Arguments &args)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(args.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (args.Length() < 2 || args.Length() > 5)
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
+
+ QV8Engine *engine = r->engine;
+
+ // Argument 0 - Method
+ QString method = engine->toString(args[0]).toUpper();
+ if (method != QLatin1String("GET") &&
+ method != QLatin1String("PUT") &&
+ method != QLatin1String("HEAD") &&
+ method != QLatin1String("POST") &&
+ method != QLatin1String("DELETE"))
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type");
+
+ // Argument 1 - URL
+ QUrl url = QUrl::fromEncoded(engine->toString(args[1]).toUtf8());
+
+ if (url.isRelative())
+ url = engine->callingContext()->resolvedUrl(url);
+
+ // Argument 2 - async (optional)
+ if (args.Length() > 2 && !args[2]->BooleanValue())
+ V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported");
+
+ // Argument 3/4 - user/pass (optional)
+ QString username, password;
+ if (args.Length() > 3)
+ username = engine->toString(args[3]);
+ if (args.Length() > 4)
+ password = engine->toString(args[4]);
+
+ // Clear the fragment (if any)
+ url.setFragment(QString());
+
+ // Set username/password
+ if (!username.isNull()) url.setUserName(username);
+ if (!password.isNull()) url.setPassword(password);
+
+ return r->open(args.This(), method, url);
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_setRequestHeader(const v8::Arguments &args)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(args.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (args.Length() != 2)
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
+
+ if (r->readyState() != QQmlXMLHttpRequest::Opened || r->sendFlag())
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
+
+ QV8Engine *engine = r->engine;
+
+ QString name = engine->toString(args[0]);
+ QString value = engine->toString(args[1]);
+
+ // ### Check that name and value are well formed
+
+ QString nameUpper = name.toUpper();
+ if (nameUpper == QLatin1String("ACCEPT-CHARSET") ||
+ nameUpper == QLatin1String("ACCEPT-ENCODING") ||
+ nameUpper == QLatin1String("CONNECTION") ||
+ nameUpper == QLatin1String("CONTENT-LENGTH") ||
+ nameUpper == QLatin1String("COOKIE") ||
+ nameUpper == QLatin1String("COOKIE2") ||
+ nameUpper == QLatin1String("CONTENT-TRANSFER-ENCODING") ||
+ nameUpper == QLatin1String("DATE") ||
+ nameUpper == QLatin1String("EXPECT") ||
+ nameUpper == QLatin1String("HOST") ||
+ nameUpper == QLatin1String("KEEP-ALIVE") ||
+ nameUpper == QLatin1String("REFERER") ||
+ nameUpper == QLatin1String("TE") ||
+ nameUpper == QLatin1String("TRAILER") ||
+ nameUpper == QLatin1String("TRANSFER-ENCODING") ||
+ nameUpper == QLatin1String("UPGRADE") ||
+ nameUpper == QLatin1String("USER-AGENT") ||
+ nameUpper == QLatin1String("VIA") ||
+ nameUpper.startsWith(QLatin1String("PROXY-")) ||
+ nameUpper.startsWith(QLatin1String("SEC-")))
+ return v8::Undefined();
+
+ r->addHeader(name, value);
+
+ return v8::Undefined();
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_send(const v8::Arguments &args)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(args.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ QV8Engine *engine = r->engine;
+
+ if (r->readyState() != QQmlXMLHttpRequest::Opened ||
+ r->sendFlag())
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
+
+ QByteArray data;
+ if (args.Length() > 0)
+ data = engine->toString(args[0]).toUtf8();
+
+ return r->send(args.This(), data);
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_abort(const v8::Arguments &args)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(args.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ return r->abort(args.This());
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_getResponseHeader(const v8::Arguments &args)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(args.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ QV8Engine *engine = r->engine;
+
+ if (args.Length() != 1)
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
+
+ if (r->readyState() != QQmlXMLHttpRequest::Loading &&
+ r->readyState() != QQmlXMLHttpRequest::Done &&
+ r->readyState() != QQmlXMLHttpRequest::HeadersReceived)
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
+
+ return engine->toString(r->header(engine->toString(args[0])));
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_getAllResponseHeaders(const v8::Arguments &args)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(args.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ QV8Engine *engine = r->engine;
+
+ if (args.Length() != 0)
+ V8THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
+
+ if (r->readyState() != QQmlXMLHttpRequest::Loading &&
+ r->readyState() != QQmlXMLHttpRequest::Done &&
+ r->readyState() != QQmlXMLHttpRequest::HeadersReceived)
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
+
+ return engine->toString(r->headers());
+}
+
+// XMLHttpRequest properties
+static v8::Handle<v8::Value> qmlxmlhttprequest_readyState(v8::Local<v8::String> /* property */,
+ const v8::AccessorInfo& info)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(info.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ return v8::Integer::NewFromUnsigned(r->readyState());
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_status(v8::Local<v8::String> /* property */,
+ const v8::AccessorInfo& info)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(info.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (r->readyState() == QQmlXMLHttpRequest::Unsent ||
+ r->readyState() == QQmlXMLHttpRequest::Opened)
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
+
+ if (r->errorFlag())
+ return v8::Integer::New(0);
+ else
+ return v8::Integer::New(r->replyStatus());
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_statusText(v8::Local<v8::String> /* property */,
+ const v8::AccessorInfo& info)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(info.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ QV8Engine *engine = r->engine;
+
+ if (r->readyState() == QQmlXMLHttpRequest::Unsent ||
+ r->readyState() == QQmlXMLHttpRequest::Opened)
+ V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
+
+ if (r->errorFlag())
+ return engine->toString(QString());
+ else
+ return engine->toString(r->replyStatusText());
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_responseText(v8::Local<v8::String> /* property */,
+ const v8::AccessorInfo& info)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(info.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ QV8Engine *engine = r->engine;
+
+ if (r->readyState() != QQmlXMLHttpRequest::Loading &&
+ r->readyState() != QQmlXMLHttpRequest::Done)
+ return engine->toString(QString());
+ else
+ return engine->toString(r->responseBody());
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_responseXML(v8::Local<v8::String> /* property */,
+ const v8::AccessorInfo& info)
+{
+ QQmlXMLHttpRequest *r = v8_resource_cast<QQmlXMLHttpRequest>(info.This());
+ if (!r)
+ V8THROW_REFERENCE("Not an XMLHttpRequest object");
+
+ if (!r->receivedXml() ||
+ (r->readyState() != QQmlXMLHttpRequest::Loading &&
+ r->readyState() != QQmlXMLHttpRequest::Done)) {
+ return v8::Null();
+ } else {
+ return Document::load(r->engine, r->rawResponseBody());
+ }
+}
+
+static v8::Handle<v8::Value> qmlxmlhttprequest_new(const v8::Arguments &args)
+{
+ if (args.IsConstructCall()) {
+ QV8Engine *engine = V8ENGINE();
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine->engine());
+ Q_UNUSED(ep)
+ QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager());
+ args.This()->SetExternalResource(r);
+
+ return args.This();
+ } else {
+ return v8::Undefined();
+ }
+}
+
+#define NEWFUNCTION(function) v8::FunctionTemplate::New(function)->GetFunction()
+
+void qt_rem_qmlxmlhttprequest(QV8Engine * /* engine */, void *d)
+{
+ QQmlXMLHttpRequestData *data = (QQmlXMLHttpRequestData *)d;
+ delete data;
+}
+
+void *qt_add_qmlxmlhttprequest(QV8Engine *engine)
+{
+ v8::PropertyAttribute attributes = (v8::PropertyAttribute)(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
+
+ // XMLHttpRequest
+ v8::Local<v8::FunctionTemplate> xmlhttprequest = v8::FunctionTemplate::New(qmlxmlhttprequest_new,
+ v8::External::Wrap(engine));
+ xmlhttprequest->InstanceTemplate()->SetHasExternalResource(true);
+
+ // Methods
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("open"), NEWFUNCTION(qmlxmlhttprequest_open), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("setRequestHeader"), NEWFUNCTION(qmlxmlhttprequest_setRequestHeader), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("send"), NEWFUNCTION(qmlxmlhttprequest_send), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("abort"), NEWFUNCTION(qmlxmlhttprequest_abort), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("getResponseHeader"), NEWFUNCTION(qmlxmlhttprequest_getResponseHeader), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("getAllResponseHeaders"), NEWFUNCTION(qmlxmlhttprequest_getAllResponseHeaders), attributes);
+
+ // Read-only properties
+ xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("readyState"), qmlxmlhttprequest_readyState, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
+ xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("status"),qmlxmlhttprequest_status, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
+ xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("statusText"),qmlxmlhttprequest_statusText, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
+ xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("responseText"),qmlxmlhttprequest_responseText, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
+ xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("responseXML"),qmlxmlhttprequest_responseXML, 0, v8::Handle<v8::Value>(), v8::DEFAULT, attributes);
+
+ // State values
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("UNSENT"), v8::Integer::New(0), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("OPENED"), v8::Integer::New(1), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("HEADERS_RECEIVED"), v8::Integer::New(2), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("LOADING"), v8::Integer::New(3), attributes);
+ xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("DONE"), v8::Integer::New(4), attributes);
+
+ // Constructor
+ xmlhttprequest->Set(v8::String::New("UNSENT"), v8::Integer::New(0), attributes);
+ xmlhttprequest->Set(v8::String::New("OPENED"), v8::Integer::New(1), attributes);
+ xmlhttprequest->Set(v8::String::New("HEADERS_RECEIVED"), v8::Integer::New(2), attributes);
+ xmlhttprequest->Set(v8::String::New("LOADING"), v8::Integer::New(3), attributes);
+ xmlhttprequest->Set(v8::String::New("DONE"), v8::Integer::New(4), attributes);
+ engine->global()->Set(v8::String::New("XMLHttpRequest"), xmlhttprequest->GetFunction());
+
+ QQmlXMLHttpRequestData *data = new QQmlXMLHttpRequestData;
+ return data;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_XMLSTREAMREADER
+
+#include <qqmlxmlhttprequest.moc>
diff --git a/src/qml/qml/qqmlxmlhttprequest_p.h b/src/qml/qml/qqmlxmlhttprequest_p.h
new file mode 100644
index 0000000000..2cfdf6a140
--- /dev/null
+++ b/src/qml/qml/qqmlxmlhttprequest_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLXMLHTTPREQUEST_P_H
+#define QQMLXMLHTTPREQUEST_P_H
+
+#include <QtQml/qjsengine.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>
+
+#ifndef QT_NO_XMLSTREAMREADER
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+
+void *qt_add_qmlxmlhttprequest(QV8Engine *engine);
+void qt_rem_qmlxmlhttprequest(QV8Engine *engine, void *);
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_XMLSTREAMREADER
+
+#endif // QQMLXMLHTTPREQUEST_P_H
+
diff --git a/src/qml/qml/qquickapplication.cpp b/src/qml/qml/qquickapplication.cpp
new file mode 100644
index 0000000000..198a917cb8
--- /dev/null
+++ b/src/qml/qml/qquickapplication.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickapplication_p.h"
+#include <private/qobject_p.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QInputMethod>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickApplicationPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickApplication)
+public:
+ QQuickApplicationPrivate() : active(QGuiApplication::activeWindow() != 0),
+ layoutDirection(QGuiApplication::layoutDirection()) {}
+ bool active;
+ Qt::LayoutDirection layoutDirection;
+};
+
+/*
+ This object and its properties are documented as part of the Qt object,
+ in qdeclarativengine.cpp
+*/
+
+QQuickApplication::QQuickApplication(QObject *parent) : QObject(*new QQuickApplicationPrivate(), parent)
+{
+ if (qApp)
+ qApp->installEventFilter(this);
+}
+
+QQuickApplication::~QQuickApplication()
+{
+}
+
+bool QQuickApplication::active() const
+{
+ Q_D(const QQuickApplication);
+ return d->active;
+}
+
+Qt::LayoutDirection QQuickApplication::layoutDirection() const
+{
+ Q_D(const QQuickApplication);
+ return d->layoutDirection;
+}
+
+QObject *QQuickApplication::inputPanel() const
+{
+ static bool warned = false;
+ if (!warned) {
+ qWarning() << "Qt.application.inputPanel is deprecated, use Qt.inputMethod instead";
+ warned = true;
+ }
+ return qApp ? qApp->inputMethod() : 0;
+}
+
+bool QQuickApplication::eventFilter(QObject *obj, QEvent *event)
+{
+ Q_UNUSED(obj)
+ Q_D(QQuickApplication);
+ if (event->type() == QEvent::ApplicationActivate
+ || event->type() == QEvent::ApplicationDeactivate) {
+ bool active = d->active;
+ if (event->type() == QEvent::ApplicationActivate)
+ active = true;
+ else if (event->type() == QEvent::ApplicationDeactivate)
+ active = false;
+
+ if (d->active != active) {
+ d->active = active;
+ emit activeChanged();
+ }
+ }
+ if (event->type() == QEvent::LayoutDirectionChange) {
+ Qt::LayoutDirection direction = QGuiApplication::layoutDirection();
+ if (d->layoutDirection != direction) {
+ d->layoutDirection = direction;
+ emit layoutDirectionChanged();
+ }
+ }
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qquickapplication_p.h b/src/qml/qml/qquickapplication_p.h
new file mode 100644
index 0000000000..66198948ac
--- /dev/null
+++ b/src/qml/qml/qquickapplication_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKAPPLICATION_P_H
+#define QQUICKAPPLICATION_P_H
+
+#include <QtCore/QObject>
+#include <qqml.h>
+#include <private/qtqmlglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQuickApplicationPrivate;
+class Q_QML_PRIVATE_EXPORT QQuickApplication : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool active READ active NOTIFY activeChanged)
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged)
+ Q_PROPERTY(QObject *inputPanel READ inputPanel CONSTANT)
+
+public:
+ explicit QQuickApplication(QObject *parent = 0);
+ virtual ~QQuickApplication();
+ bool active() const;
+ Qt::LayoutDirection layoutDirection() const;
+ QT_DEPRECATED QObject *inputPanel() const;
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+
+Q_SIGNALS:
+ void activeChanged();
+ void layoutDirectionChanged();
+
+private:
+ Q_DISABLE_COPY(QQuickApplication)
+ Q_DECLARE_PRIVATE(QQuickApplication)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickApplication)
+
+QT_END_HEADER
+
+#endif // QQUICKAPPLICATION_P_H
diff --git a/src/qml/qml/qquicklistmodel.cpp b/src/qml/qml/qquicklistmodel.cpp
new file mode 100644
index 0000000000..30c4f5d1d1
--- /dev/null
+++ b/src/qml/qml/qquicklistmodel.cpp
@@ -0,0 +1,2467 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicklistmodel_p_p.h"
+#include "qquicklistmodelworkeragent_p.h"
+#include "qqmlopenmetaobject_p.h"
+#include <private/qqmljsast_p.h>
+#include <private/qqmljsengine_p.h>
+
+#include <private/qqmlcustomparser_p.h>
+#include <private/qqmlscript_p.h>
+#include <private/qqmlengine_p.h>
+#include <qqmlcontext.h>
+#include <qqmlinfo.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstack.h>
+#include <QXmlStreamReader>
+
+Q_DECLARE_METATYPE(QListModelInterface *)
+
+QT_BEGIN_NAMESPACE
+
+// Set to 1024 as a debugging aid - easier to distinguish uids from indices of elements/models.
+enum { MIN_LISTMODEL_UID = 1024 };
+
+static QAtomicInt uidCounter(MIN_LISTMODEL_UID);
+
+template <typename T>
+static bool isMemoryUsed(const char *mem)
+{
+ for (size_t i=0 ; i < sizeof(T) ; ++i) {
+ if (mem[i] != 0)
+ return true;
+ }
+
+ return false;
+}
+
+static QString roleTypeName(ListLayout::Role::DataType t)
+{
+ QString result;
+ const char *roleTypeNames[] = { "String", "Number", "Bool", "List", "QObject", "VariantMap" };
+
+ if (t > ListLayout::Role::Invalid && t < ListLayout::Role::MaxDataType)
+ result = QString::fromLatin1(roleTypeNames[t]);
+
+ return result;
+}
+
+const ListLayout::Role &ListLayout::getRoleOrCreate(const QString &key, Role::DataType type)
+{
+ QStringHash<Role *>::Node *node = roleHash.findNode(key);
+ if (node) {
+ const Role &r = *node->value;
+ if (type != r.type)
+ qmlInfo(0) << QString::fromLatin1("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type));
+ return r;
+ }
+
+ return createRole(key, type);
+}
+
+const ListLayout::Role &ListLayout::getRoleOrCreate(v8::Handle<v8::String> key, Role::DataType type)
+{
+ QHashedV8String hashedKey(key);
+ QStringHash<Role *>::Node *node = roleHash.findNode(hashedKey);
+ if (node) {
+ const Role &r = *node->value;
+ if (type != r.type)
+ qmlInfo(0) << QString::fromLatin1("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(r.name).arg(roleTypeName(type)).arg(roleTypeName(r.type));
+ return r;
+ }
+
+ QString qkey;
+ qkey.resize(key->Length());
+ key->Write(reinterpret_cast<uint16_t*>(qkey.data()));
+
+ return createRole(qkey, type);
+}
+
+const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::Role::DataType type)
+{
+ const int dataSizes[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QQmlGuard<QObject>), sizeof(QVariantMap) };
+ const int dataAlignments[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QObject *), sizeof(QVariantMap) };
+
+ Role *r = new Role;
+ r->name = key;
+ r->type = type;
+
+ if (type == Role::List) {
+ r->subLayout = new ListLayout;
+ } else {
+ r->subLayout = 0;
+ }
+
+ int dataSize = dataSizes[type];
+ int dataAlignment = dataAlignments[type];
+
+ int dataOffset = (currentBlockOffset + dataAlignment-1) & ~(dataAlignment-1);
+ if (dataOffset + dataSize > ListElement::BLOCK_SIZE) {
+ r->blockIndex = ++currentBlock;
+ r->blockOffset = 0;
+ currentBlockOffset = dataSize;
+ } else {
+ r->blockIndex = currentBlock;
+ r->blockOffset = dataOffset;
+ currentBlockOffset = dataOffset + dataSize;
+ }
+
+ int roleIndex = roles.count();
+ r->index = roleIndex;
+
+ roles.append(r);
+ roleHash.insert(key, r);
+
+ return *r;
+}
+
+ListLayout::ListLayout(const ListLayout *other) : currentBlock(0), currentBlockOffset(0)
+{
+ for (int i=0 ; i < other->roles.count() ; ++i) {
+ Role *role = new Role(other->roles[i]);
+ roles.append(role);
+ roleHash.insert(role->name, role);
+ }
+ currentBlockOffset = other->currentBlockOffset;
+ currentBlock = other->currentBlock;
+}
+
+ListLayout::~ListLayout()
+{
+ for (int i=0 ; i < roles.count() ; ++i) {
+ delete roles[i];
+ }
+}
+
+void ListLayout::sync(ListLayout *src, ListLayout *target)
+{
+ int roleOffset = target->roles.count();
+ int newRoleCount = src->roles.count() - roleOffset;
+
+ for (int i=0 ; i < newRoleCount ; ++i) {
+ Role *role = new Role(src->roles[roleOffset + i]);
+ target->roles.append(role);
+ target->roleHash.insert(role->name, role);
+ }
+
+ target->currentBlockOffset = src->currentBlockOffset;
+ target->currentBlock = src->currentBlock;
+}
+
+ListLayout::Role::Role(const Role *other)
+{
+ name = other->name;
+ type = other->type;
+ blockIndex = other->blockIndex;
+ blockOffset = other->blockOffset;
+ index = other->index;
+ if (other->subLayout)
+ subLayout = new ListLayout(other->subLayout);
+ else
+ subLayout = 0;
+}
+
+ListLayout::Role::~Role()
+{
+ delete subLayout;
+}
+
+const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QVariant &data)
+{
+ Role::DataType type;
+
+ switch (data.type()) {
+ case QVariant::Double: type = Role::Number; break;
+ case QVariant::Int: type = Role::Number; break;
+ case QVariant::UserType: type = Role::List; break;
+ case QVariant::Bool: type = Role::Bool; break;
+ case QVariant::String: type = Role::String; break;
+ case QVariant::Map: type = Role::VariantMap; break;
+ default: type = Role::Invalid; break;
+ }
+
+ if (type == Role::Invalid) {
+ qmlInfo(0) << "Can't create role for unsupported data type";
+ return 0;
+ }
+
+ return &getRoleOrCreate(key, type);
+}
+
+const ListLayout::Role *ListLayout::getExistingRole(const QString &key)
+{
+ Role *r = 0;
+ QStringHash<Role *>::Node *node = roleHash.findNode(key);
+ if (node)
+ r = node->value;
+ return r;
+}
+
+const ListLayout::Role *ListLayout::getExistingRole(v8::Handle<v8::String> key)
+{
+ Role *r = 0;
+ QHashedV8String hashedKey(key);
+ QStringHash<Role *>::Node *node = roleHash.findNode(hashedKey);
+ if (node)
+ r = node->value;
+ return r;
+}
+
+ModelObject *ListModel::getOrCreateModelObject(QQuickListModel *model, int elementIndex)
+{
+ ListElement *e = elements[elementIndex];
+ if (e->m_objectCache == 0) {
+ e->m_objectCache = new ModelObject(model, elementIndex);
+ }
+ return e->m_objectCache;
+}
+
+void ListModel::sync(ListModel *src, ListModel *target, QHash<int, ListModel *> *targetModelHash)
+{
+ // Sanity check
+ target->m_uid = src->m_uid;
+ if (targetModelHash)
+ targetModelHash->insert(target->m_uid, target);
+
+ // Build hash of elements <-> uid for each of the lists
+ QHash<int, ElementSync> elementHash;
+ for (int i=0 ; i < target->elements.count() ; ++i) {
+ ListElement *e = target->elements.at(i);
+ int uid = e->getUid();
+ ElementSync sync;
+ sync.target = e;
+ elementHash.insert(uid, sync);
+ }
+ for (int i=0 ; i < src->elements.count() ; ++i) {
+ ListElement *e = src->elements.at(i);
+ int uid = e->getUid();
+
+ QHash<int, ElementSync>::iterator it = elementHash.find(uid);
+ if (it == elementHash.end()) {
+ ElementSync sync;
+ sync.src = e;
+ elementHash.insert(uid, sync);
+ } else {
+ ElementSync &sync = it.value();
+ sync.src = e;
+ }
+ }
+
+ // Get list of elements that are in the target but no longer in the source. These get deleted first.
+ QHash<int, ElementSync>::iterator it = elementHash.begin();
+ QHash<int, ElementSync>::iterator end = elementHash.end();
+ while (it != end) {
+ const ElementSync &s = it.value();
+ if (s.src == 0) {
+ s.target->destroy(target->m_layout);
+ target->elements.removeOne(s.target);
+ delete s.target;
+ }
+ ++it;
+ }
+
+ // Sync the layouts
+ ListLayout::sync(src->m_layout, target->m_layout);
+
+ // Clear the target list, and append in correct order from the source
+ target->elements.clear();
+ for (int i=0 ; i < src->elements.count() ; ++i) {
+ ListElement *srcElement = src->elements.at(i);
+ it = elementHash.find(srcElement->getUid());
+ const ElementSync &s = it.value();
+ ListElement *targetElement = s.target;
+ if (targetElement == 0) {
+ targetElement = new ListElement(srcElement->getUid());
+ }
+ ListElement::sync(srcElement, src->m_layout, targetElement, target->m_layout, targetModelHash);
+ target->elements.append(targetElement);
+ }
+
+ target->updateCacheIndices();
+
+ // Update values stored in target meta objects
+ for (int i=0 ; i < target->elements.count() ; ++i) {
+ ListElement *e = target->elements[i];
+ if (e->m_objectCache)
+ e->m_objectCache->updateValues();
+ }
+}
+
+ListModel::ListModel(ListLayout *layout, QQuickListModel *modelCache, int uid) : m_layout(layout), m_modelCache(modelCache)
+{
+ if (uid == -1)
+ uid = uidCounter.fetchAndAddOrdered(1);
+ m_uid = uid;
+}
+
+void ListModel::destroy()
+{
+ clear();
+ m_uid = -1;
+ m_layout = 0;
+ if (m_modelCache && m_modelCache->m_primary == false)
+ delete m_modelCache;
+ m_modelCache = 0;
+}
+
+int ListModel::appendElement()
+{
+ int elementIndex = elements.count();
+ newElement(elementIndex);
+ return elementIndex;
+}
+
+void ListModel::insertElement(int index)
+{
+ newElement(index);
+ updateCacheIndices();
+}
+
+void ListModel::move(int from, int to, int n)
+{
+ if (from > to) {
+ // Only move forwards - flip if backwards moving
+ int tfrom = from;
+ int tto = to;
+ from = tto;
+ to = tto+n;
+ n = tfrom-tto;
+ }
+
+ QPODVector<ListElement *, 4> store;
+ for (int i=0 ; i < (to-from) ; ++i)
+ store.append(elements[from+n+i]);
+ for (int i=0 ; i < n ; ++i)
+ store.append(elements[from+i]);
+ for (int i=0 ; i < store.count() ; ++i)
+ elements[from+i] = store[i];
+
+ updateCacheIndices();
+}
+
+void ListModel::newElement(int index)
+{
+ ListElement *e = new ListElement;
+ elements.insert(index, e);
+}
+
+void ListModel::updateCacheIndices()
+{
+ for (int i=0 ; i < elements.count() ; ++i) {
+ ListElement *e = elements.at(i);
+ if (e->m_objectCache) {
+ e->m_objectCache->m_elementIndex = i;
+ }
+ }
+}
+
+QVariant ListModel::getProperty(int elementIndex, int roleIndex, const QQuickListModel *owner, QV8Engine *eng)
+{
+ ListElement *e = elements[elementIndex];
+ const ListLayout::Role &r = m_layout->getExistingRole(roleIndex);
+ return e->getProperty(r, owner, eng);
+}
+
+ListModel *ListModel::getListProperty(int elementIndex, const ListLayout::Role &role)
+{
+ ListElement *e = elements[elementIndex];
+ return e->getListProperty(role);
+}
+
+void ListModel::set(int elementIndex, v8::Handle<v8::Object> object, QList<int> *roles, QV8Engine *eng)
+{
+ ListElement *e = elements[elementIndex];
+
+ v8::Local<v8::Array> propertyNames = object->GetPropertyNames();
+ int propertyCount = propertyNames->Length();
+
+ for (int i=0 ; i < propertyCount ; ++i) {
+ v8::Local<v8::String> propertyName = propertyNames->Get(i)->ToString();
+ v8::Local<v8::Value> propertyValue = object->Get(propertyName);
+
+ // Check if this key exists yet
+ int roleIndex = -1;
+
+ // Add the value now
+ if (propertyValue->IsString()) {
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String);
+ v8::Handle<v8::String> jsString = propertyValue->ToString();
+ QString qstr;
+ qstr.resize(jsString->Length());
+ jsString->Write(reinterpret_cast<uint16_t*>(qstr.data()));
+ roleIndex = e->setStringProperty(r, qstr);
+ } else if (propertyValue->IsNumber()) {
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number);
+ roleIndex = e->setDoubleProperty(r, propertyValue->NumberValue());
+ } else if (propertyValue->IsArray()) {
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List);
+ ListModel *subModel = new ListModel(r.subLayout, 0, -1);
+
+ v8::Handle<v8::Array> subArray = v8::Handle<v8::Array>::Cast(propertyValue);
+ int arrayLength = subArray->Length();
+ for (int j=0 ; j < arrayLength ; ++j) {
+ v8::Handle<v8::Object> subObject = subArray->Get(j)->ToObject();
+ subModel->append(subObject, eng);
+ }
+
+ roleIndex = e->setListProperty(r, subModel);
+ } else if (propertyValue->IsBoolean()) {
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool);
+ roleIndex = e->setBoolProperty(r, propertyValue->BooleanValue());
+ } else if (propertyValue->IsObject()) {
+ QV8ObjectResource *r = (QV8ObjectResource *) propertyValue->ToObject()->GetExternalResource();
+ if (r && r->resourceType() == QV8ObjectResource::QObjectType) {
+ QObject *o = QV8QObjectWrapper::toQObject(r);
+ const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);
+ if (role.type == ListLayout::Role::QObject)
+ roleIndex = e->setQObjectProperty(role, o);
+ } else {
+ const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::VariantMap);
+ if (role.type == ListLayout::Role::VariantMap)
+ roleIndex = e->setVariantMapProperty(role, propertyValue->ToObject(), eng);
+ }
+ } else if (propertyValue.IsEmpty() || propertyValue->IsUndefined() || propertyValue->IsNull()) {
+ const ListLayout::Role *r = m_layout->getExistingRole(propertyName);
+ if (r)
+ e->clearProperty(*r);
+ }
+
+ if (roleIndex != -1)
+ roles->append(roleIndex);
+ }
+
+ if (e->m_objectCache) {
+ e->m_objectCache->updateValues(*roles);
+ }
+}
+
+void ListModel::set(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng)
+{
+ ListElement *e = elements[elementIndex];
+
+ v8::Local<v8::Array> propertyNames = object->GetPropertyNames();
+ int propertyCount = propertyNames->Length();
+
+ for (int i=0 ; i < propertyCount ; ++i) {
+ v8::Local<v8::String> propertyName = propertyNames->Get(i)->ToString();
+ v8::Local<v8::Value> propertyValue = object->Get(propertyName);
+
+ // Add the value now
+ if (propertyValue->IsString()) {
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String);
+ if (r.type == ListLayout::Role::String) {
+ v8::Handle<v8::String> jsString = propertyValue->ToString();
+ QString qstr;
+ qstr.resize(jsString->Length());
+ jsString->Write(reinterpret_cast<uint16_t*>(qstr.data()));
+ e->setStringPropertyFast(r, qstr);
+ }
+ } else if (propertyValue->IsNumber()) {
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number);
+ if (r.type == ListLayout::Role::Number) {
+ e->setDoublePropertyFast(r, propertyValue->NumberValue());
+ }
+ } else if (propertyValue->IsArray()) {
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List);
+ if (r.type == ListLayout::Role::List) {
+ ListModel *subModel = new ListModel(r.subLayout, 0, -1);
+
+ v8::Handle<v8::Array> subArray = v8::Handle<v8::Array>::Cast(propertyValue);
+ int arrayLength = subArray->Length();
+ for (int j=0 ; j < arrayLength ; ++j) {
+ v8::Handle<v8::Object> subObject = subArray->Get(j)->ToObject();
+ subModel->append(subObject, eng);
+ }
+
+ e->setListPropertyFast(r, subModel);
+ }
+ } else if (propertyValue->IsBoolean()) {
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Bool);
+ if (r.type == ListLayout::Role::Bool) {
+ e->setBoolPropertyFast(r, propertyValue->BooleanValue());
+ }
+ } else if (propertyValue->IsObject()) {
+ QV8ObjectResource *r = (QV8ObjectResource *) propertyValue->ToObject()->GetExternalResource();
+ if (r && r->resourceType() == QV8ObjectResource::QObjectType) {
+ QObject *o = QV8QObjectWrapper::toQObject(r);
+ const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);
+ if (r.type == ListLayout::Role::QObject)
+ e->setQObjectPropertyFast(r, o);
+ } else {
+ const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::VariantMap);
+ if (role.type == ListLayout::Role::VariantMap)
+ e->setVariantMapFast(role, propertyValue->ToObject(), eng);
+ }
+ } else if (propertyValue.IsEmpty() || propertyValue->IsUndefined() || propertyValue->IsNull()) {
+ const ListLayout::Role *r = m_layout->getExistingRole(propertyName);
+ if (r)
+ e->clearProperty(*r);
+ }
+ }
+}
+
+void ListModel::clear()
+{
+ int elementCount = elements.count();
+ for (int i=0 ; i < elementCount ; ++i) {
+ elements[i]->destroy(m_layout);
+ delete elements[i];
+ }
+ elements.clear();
+}
+
+void ListModel::remove(int index, int count)
+{
+ for (int i=0 ; i < count ; ++i) {
+ elements[index+i]->destroy(m_layout);
+ delete elements[index+i];
+ }
+ elements.remove(index, count);
+ updateCacheIndices();
+}
+
+void ListModel::insert(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng)
+{
+ insertElement(elementIndex);
+ set(elementIndex, object, eng);
+}
+
+int ListModel::append(v8::Handle<v8::Object> object, QV8Engine *eng)
+{
+ int elementIndex = appendElement();
+ set(elementIndex, object, eng);
+ return elementIndex;
+}
+
+int ListModel::setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data)
+{
+ int roleIndex = -1;
+
+ if (elementIndex >= 0 && elementIndex < elements.count()) {
+ ListElement *e = elements[elementIndex];
+
+ const ListLayout::Role *r = m_layout->getRoleOrCreate(key, data);
+ if (r) {
+ roleIndex = e->setVariantProperty(*r, data);
+
+ if (roleIndex != -1 && e->m_objectCache) {
+ QList<int> roles;
+ roles << roleIndex;
+ e->m_objectCache->updateValues(roles);
+ }
+ }
+ }
+
+ return roleIndex;
+}
+
+int ListModel::setExistingProperty(int elementIndex, const QString &key, v8::Handle<v8::Value> data, QV8Engine *eng)
+{
+ int roleIndex = -1;
+
+ if (elementIndex >= 0 && elementIndex < elements.count()) {
+ ListElement *e = elements[elementIndex];
+ const ListLayout::Role *r = m_layout->getExistingRole(key);
+ if (r)
+ roleIndex = e->setJsProperty(*r, data, eng);
+ }
+
+ return roleIndex;
+}
+
+inline char *ListElement::getPropertyMemory(const ListLayout::Role &role)
+{
+ ListElement *e = this;
+ int blockIndex = 0;
+ while (blockIndex < role.blockIndex) {
+ if (e->next == 0) {
+ e->next = new ListElement;
+ e->next->uid = uid;
+ }
+ e = e->next;
+ ++blockIndex;
+ }
+
+ char *mem = &e->data[role.blockOffset];
+ return mem;
+}
+
+QString *ListElement::getStringProperty(const ListLayout::Role &role)
+{
+ char *mem = getPropertyMemory(role);
+ QString *s = reinterpret_cast<QString *>(mem);
+ return s->data_ptr() ? s : 0;
+}
+
+QObject *ListElement::getQObjectProperty(const ListLayout::Role &role)
+{
+ char *mem = getPropertyMemory(role);
+ QQmlGuard<QObject> *o = reinterpret_cast<QQmlGuard<QObject> *>(mem);
+ return o->data();
+}
+
+QVariantMap *ListElement::getVariantMapProperty(const ListLayout::Role &role)
+{
+ QVariantMap *map = 0;
+
+ char *mem = getPropertyMemory(role);
+ if (isMemoryUsed<QVariantMap>(mem))
+ map = reinterpret_cast<QVariantMap *>(mem);
+
+ return map;
+}
+
+QQmlGuard<QObject> *ListElement::getGuardProperty(const ListLayout::Role &role)
+{
+ char *mem = getPropertyMemory(role);
+
+ bool existingGuard = false;
+ for (size_t i=0 ; i < sizeof(QQmlGuard<QObject>) ; ++i) {
+ if (mem[i] != 0) {
+ existingGuard = true;
+ break;
+ }
+ }
+
+ QQmlGuard<QObject> *o = 0;
+
+ if (existingGuard)
+ o = reinterpret_cast<QQmlGuard<QObject> *>(mem);
+
+ return o;
+}
+
+ListModel *ListElement::getListProperty(const ListLayout::Role &role)
+{
+ char *mem = getPropertyMemory(role);
+ ListModel **value = reinterpret_cast<ListModel **>(mem);
+ return *value;
+}
+
+QVariant ListElement::getProperty(const ListLayout::Role &role, const QQuickListModel *owner, QV8Engine *eng)
+{
+ char *mem = getPropertyMemory(role);
+
+ QVariant data;
+
+ switch (role.type) {
+ case ListLayout::Role::Number:
+ {
+ double *value = reinterpret_cast<double *>(mem);
+ data = *value;
+ }
+ break;
+ case ListLayout::Role::String:
+ {
+ QString *value = reinterpret_cast<QString *>(mem);
+ if (value->data_ptr() != 0)
+ data = *value;
+ }
+ break;
+ case ListLayout::Role::Bool:
+ {
+ bool *value = reinterpret_cast<bool *>(mem);
+ data = *value;
+ }
+ break;
+ case ListLayout::Role::List:
+ {
+ ListModel **value = reinterpret_cast<ListModel **>(mem);
+ ListModel *model = *value;
+
+ if (model) {
+ if (model->m_modelCache == 0) {
+ model->m_modelCache = new QQuickListModel(owner, model, eng);
+ QQmlEngine::setContextForObject(model->m_modelCache, QQmlEngine::contextForObject(owner));
+ }
+
+ QObject *object = model->m_modelCache;
+ data = QVariant::fromValue(object);
+ }
+ }
+ break;
+ case ListLayout::Role::QObject:
+ {
+ QQmlGuard<QObject> *guard = reinterpret_cast<QQmlGuard<QObject> *>(mem);
+ QObject *object = guard->data();
+ if (object)
+ data = QVariant::fromValue(object);
+ }
+ break;
+ case ListLayout::Role::VariantMap:
+ {
+ if (isMemoryUsed<QVariantMap>(mem)) {
+ QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);
+ data = *map;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return data;
+}
+
+int ListElement::setStringProperty(const ListLayout::Role &role, const QString &s)
+{
+ int roleIndex = -1;
+
+ if (role.type == ListLayout::Role::String) {
+ char *mem = getPropertyMemory(role);
+ QString *c = reinterpret_cast<QString *>(mem);
+ bool changed;
+ if (c->data_ptr() == 0) {
+ new (mem) QString(s);
+ changed = true;
+ } else {
+ changed = c->compare(s) != 0;
+ *c = s;
+ }
+ if (changed)
+ roleIndex = role.index;
+ }
+
+ return roleIndex;
+}
+
+int ListElement::setDoubleProperty(const ListLayout::Role &role, double d)
+{
+ int roleIndex = -1;
+
+ if (role.type == ListLayout::Role::Number) {
+ char *mem = getPropertyMemory(role);
+ double *value = new (mem) double;
+ bool changed = *value != d;
+ *value = d;
+ if (changed)
+ roleIndex = role.index;
+ }
+
+ return roleIndex;
+}
+
+int ListElement::setBoolProperty(const ListLayout::Role &role, bool b)
+{
+ int roleIndex = -1;
+
+ if (role.type == ListLayout::Role::Bool) {
+ char *mem = getPropertyMemory(role);
+ bool *value = new (mem) bool;
+ bool changed = *value != b;
+ *value = b;
+ if (changed)
+ roleIndex = role.index;
+ }
+
+ return roleIndex;
+}
+
+int ListElement::setListProperty(const ListLayout::Role &role, ListModel *m)
+{
+ int roleIndex = -1;
+
+ if (role.type == ListLayout::Role::List) {
+ char *mem = getPropertyMemory(role);
+ ListModel **value = new (mem) ListModel *;
+ if (*value) {
+ (*value)->destroy();
+ delete *value;
+ }
+ *value = m;
+ roleIndex = role.index;
+ }
+
+ return roleIndex;
+}
+
+int ListElement::setQObjectProperty(const ListLayout::Role &role, QObject *o)
+{
+ int roleIndex = -1;
+
+ if (role.type == ListLayout::Role::QObject) {
+ char *mem = getPropertyMemory(role);
+ QQmlGuard<QObject> *g = reinterpret_cast<QQmlGuard<QObject> *>(mem);
+ bool existingGuard = false;
+ for (size_t i=0 ; i < sizeof(QQmlGuard<QObject>) ; ++i) {
+ if (mem[i] != 0) {
+ existingGuard = true;
+ break;
+ }
+ }
+ bool changed;
+ if (existingGuard) {
+ changed = g->data() != o;
+ g->~QQmlGuard();
+ } else {
+ changed = true;
+ }
+ new (mem) QQmlGuard<QObject>(o);
+ if (changed)
+ roleIndex = role.index;
+ }
+
+ return roleIndex;
+}
+
+int ListElement::setVariantMapProperty(const ListLayout::Role &role, v8::Handle<v8::Object> o, QV8Engine *eng)
+{
+ int roleIndex = -1;
+
+ if (role.type == ListLayout::Role::VariantMap) {
+ char *mem = getPropertyMemory(role);
+ if (isMemoryUsed<QVariantMap>(mem)) {
+ QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);
+ map->~QMap();
+ }
+ new (mem) QVariantMap(eng->variantMapFromJS(o));
+ roleIndex = role.index;
+ }
+
+ return roleIndex;
+}
+
+int ListElement::setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m)
+{
+ int roleIndex = -1;
+
+ if (role.type == ListLayout::Role::VariantMap) {
+ char *mem = getPropertyMemory(role);
+ if (isMemoryUsed<QVariantMap>(mem)) {
+ QVariantMap *map = reinterpret_cast<QVariantMap *>(mem);
+ map->~QMap();
+ }
+ if (m)
+ new (mem) QVariantMap(*m);
+ else
+ new (mem) QVariantMap;
+ roleIndex = role.index;
+ }
+
+ return roleIndex;
+}
+
+void ListElement::setStringPropertyFast(const ListLayout::Role &role, const QString &s)
+{
+ char *mem = getPropertyMemory(role);
+ new (mem) QString(s);
+}
+
+void ListElement::setDoublePropertyFast(const ListLayout::Role &role, double d)
+{
+ char *mem = getPropertyMemory(role);
+ double *value = new (mem) double;
+ *value = d;
+}
+
+void ListElement::setBoolPropertyFast(const ListLayout::Role &role, bool b)
+{
+ char *mem = getPropertyMemory(role);
+ bool *value = new (mem) bool;
+ *value = b;
+}
+
+void ListElement::setQObjectPropertyFast(const ListLayout::Role &role, QObject *o)
+{
+ char *mem = getPropertyMemory(role);
+ new (mem) QQmlGuard<QObject>(o);
+}
+
+void ListElement::setListPropertyFast(const ListLayout::Role &role, ListModel *m)
+{
+ char *mem = getPropertyMemory(role);
+ ListModel **value = new (mem) ListModel *;
+ *value = m;
+}
+
+void ListElement::setVariantMapFast(const ListLayout::Role &role, v8::Handle<v8::Object> o, QV8Engine *eng)
+{
+ char *mem = getPropertyMemory(role);
+ QVariantMap *map = new (mem) QVariantMap;
+ *map = eng->variantMapFromJS(o);
+}
+
+void ListElement::clearProperty(const ListLayout::Role &role)
+{
+ switch (role.type) {
+ case ListLayout::Role::String:
+ setStringProperty(role, QString());
+ break;
+ case ListLayout::Role::Number:
+ setDoubleProperty(role, 0.0);
+ break;
+ case ListLayout::Role::Bool:
+ setBoolProperty(role, false);
+ break;
+ case ListLayout::Role::List:
+ setListProperty(role, 0);
+ break;
+ case ListLayout::Role::QObject:
+ setQObjectProperty(role, 0);
+ break;
+ case ListLayout::Role::VariantMap:
+ setVariantMapProperty(role, 0);
+ break;
+ default:
+ break;
+ }
+}
+
+ListElement::ListElement()
+{
+ m_objectCache = 0;
+ uid = uidCounter.fetchAndAddOrdered(1);
+ next = 0;
+ qMemSet(data, 0, sizeof(data));
+}
+
+ListElement::ListElement(int existingUid)
+{
+ m_objectCache = 0;
+ uid = existingUid;
+ next = 0;
+ qMemSet(data, 0, sizeof(data));
+}
+
+ListElement::~ListElement()
+{
+ delete next;
+}
+
+void ListElement::sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout, QHash<int, ListModel *> *targetModelHash)
+{
+ for (int i=0 ; i < srcLayout->roleCount() ; ++i) {
+ const ListLayout::Role &srcRole = srcLayout->getExistingRole(i);
+ const ListLayout::Role &targetRole = targetLayout->getExistingRole(i);
+
+ switch (srcRole.type) {
+ case ListLayout::Role::List:
+ {
+ ListModel *srcSubModel = src->getListProperty(srcRole);
+ ListModel *targetSubModel = target->getListProperty(targetRole);
+
+ if (srcSubModel) {
+ if (targetSubModel == 0) {
+ targetSubModel = new ListModel(targetRole.subLayout, 0, srcSubModel->getUid());
+ target->setListPropertyFast(targetRole, targetSubModel);
+ }
+ ListModel::sync(srcSubModel, targetSubModel, targetModelHash);
+ }
+ }
+ break;
+ case ListLayout::Role::QObject:
+ {
+ QObject *object = src->getQObjectProperty(srcRole);
+ target->setQObjectProperty(targetRole, object);
+ }
+ break;
+ case ListLayout::Role::String:
+ case ListLayout::Role::Number:
+ case ListLayout::Role::Bool:
+ {
+ QVariant v = src->getProperty(srcRole, 0, 0);
+ target->setVariantProperty(targetRole, v);
+ }
+ case ListLayout::Role::VariantMap:
+ {
+ QVariantMap *map = src->getVariantMapProperty(srcRole);
+ target->setVariantMapProperty(targetRole, map);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+}
+
+void ListElement::destroy(ListLayout *layout)
+{
+ if (layout) {
+ for (int i=0 ; i < layout->roleCount() ; ++i) {
+ const ListLayout::Role &r = layout->getExistingRole(i);
+
+ switch (r.type) {
+ case ListLayout::Role::String:
+ {
+ QString *string = getStringProperty(r);
+ if (string)
+ string->~QString();
+ }
+ break;
+ case ListLayout::Role::List:
+ {
+ ListModel *model = getListProperty(r);
+ if (model) {
+ model->destroy();
+ delete model;
+ }
+ }
+ break;
+ case ListLayout::Role::QObject:
+ {
+ QQmlGuard<QObject> *guard = getGuardProperty(r);
+ if (guard)
+ guard->~QQmlGuard();
+ }
+ break;
+ case ListLayout::Role::VariantMap:
+ {
+ QVariantMap *map = getVariantMapProperty(r);
+ if (map)
+ map->~QMap();
+ }
+ break;
+ default:
+ // other types don't need explicit cleanup.
+ break;
+ }
+ }
+
+ delete m_objectCache;
+ }
+
+ if (next)
+ next->destroy(0);
+ uid = -1;
+}
+
+int ListElement::setVariantProperty(const ListLayout::Role &role, const QVariant &d)
+{
+ int roleIndex = -1;
+
+ switch (role.type) {
+ case ListLayout::Role::Number:
+ roleIndex = setDoubleProperty(role, d.toDouble());
+ break;
+ case ListLayout::Role::String:
+ roleIndex = setStringProperty(role, d.toString());
+ break;
+ case ListLayout::Role::Bool:
+ roleIndex = setBoolProperty(role, d.toBool());
+ break;
+ case ListLayout::Role::List:
+ roleIndex = setListProperty(role, d.value<ListModel *>());
+ break;
+ case ListLayout::Role::VariantMap: {
+ QVariantMap map = d.toMap();
+ roleIndex = setVariantMapProperty(role, &map);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return roleIndex;
+}
+
+int ListElement::setJsProperty(const ListLayout::Role &role, v8::Handle<v8::Value> d, QV8Engine *eng)
+{
+ // Check if this key exists yet
+ int roleIndex = -1;
+
+ // Add the value now
+ if (d->IsString()) {
+ v8::Handle<v8::String> jsString = d->ToString();
+ QString qstr;
+ qstr.resize(jsString->Length());
+ jsString->Write(reinterpret_cast<uint16_t*>(qstr.data()));
+ roleIndex = setStringProperty(role, qstr);
+ } else if (d->IsNumber()) {
+ roleIndex = setDoubleProperty(role, d->NumberValue());
+ } else if (d->IsArray()) {
+ ListModel *subModel = new ListModel(role.subLayout, 0, -1);
+ v8::Handle<v8::Array> subArray = v8::Handle<v8::Array>::Cast(d);
+ int arrayLength = subArray->Length();
+ for (int j=0 ; j < arrayLength ; ++j) {
+ v8::Handle<v8::Object> subObject = subArray->Get(j)->ToObject();
+ subModel->append(subObject, eng);
+ }
+ roleIndex = setListProperty(role, subModel);
+ } else if (d->IsBoolean()) {
+ roleIndex = setBoolProperty(role, d->BooleanValue());
+ } else if (d->IsObject()) {
+ QV8ObjectResource *r = (QV8ObjectResource *) d->ToObject()->GetExternalResource();
+ if (role.type == ListLayout::Role::QObject && r && r->resourceType() == QV8ObjectResource::QObjectType) {
+ QObject *o = QV8QObjectWrapper::toQObject(r);
+ roleIndex = setQObjectProperty(role, o);
+ } else if (role.type == ListLayout::Role::VariantMap) {
+ roleIndex = setVariantMapProperty(role, d->ToObject(), eng);
+ }
+ } else if (d.IsEmpty() || d->IsUndefined() || d->IsNull()) {
+ clearProperty(role);
+ }
+
+ return roleIndex;
+}
+
+ModelObject::ModelObject(QQuickListModel *model, int elementIndex)
+: m_model(model), m_elementIndex(elementIndex), m_meta(new ModelNodeMetaObject(this))
+{
+ updateValues();
+ setNodeUpdatesEnabled(true);
+}
+
+void ModelObject::updateValues()
+{
+ int roleCount = m_model->m_listModel->roleCount();
+ for (int i=0 ; i < roleCount ; ++i) {
+ const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i);
+ QByteArray name = role.name.toUtf8();
+ const QVariant &data = m_model->data(m_elementIndex, i);
+ setValue(name, data, role.type == ListLayout::Role::List);
+ }
+}
+
+void ModelObject::updateValues(const QList<int> &roles)
+{
+ int roleCount = roles.count();
+ for (int i=0 ; i < roleCount ; ++i) {
+ int roleIndex = roles.at(i);
+ const ListLayout::Role &role = m_model->m_listModel->getExistingRole(roleIndex);
+ QByteArray name = role.name.toUtf8();
+ const QVariant &data = m_model->data(m_elementIndex, roleIndex);
+ setValue(name, data, role.type == ListLayout::Role::List);
+ }
+}
+
+ModelNodeMetaObject::ModelNodeMetaObject(ModelObject *object)
+: QQmlOpenMetaObject(object), m_enabled(false), m_obj(object)
+{
+}
+
+ModelNodeMetaObject::~ModelNodeMetaObject()
+{
+}
+
+void ModelNodeMetaObject::propertyWritten(int index)
+{
+ if (!m_enabled)
+ return;
+
+ QV8Engine *eng = m_obj->m_model->engine();
+
+ QString propName = QString::fromUtf8(name(index));
+ QVariant value = operator[](index);
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(eng->context());
+
+ v8::Handle<v8::Value> v = eng->fromVariant(value);
+
+ int roleIndex = m_obj->m_model->m_listModel->setExistingProperty(m_obj->m_elementIndex, propName, v, eng);
+ if (roleIndex != -1) {
+ QList<int> roles;
+ roles << roleIndex;
+ m_obj->m_model->emitItemsChanged(m_obj->m_elementIndex, 1, roles);
+ }
+}
+
+DynamicRoleModelNode::DynamicRoleModelNode(QQuickListModel *owner, int uid) : m_owner(owner), m_uid(uid), m_meta(new DynamicRoleModelNodeMetaObject(this))
+{
+ setNodeUpdatesEnabled(true);
+}
+
+DynamicRoleModelNode *DynamicRoleModelNode::create(const QVariantMap &obj, QQuickListModel *owner)
+{
+ DynamicRoleModelNode *object = new DynamicRoleModelNode(owner, uidCounter.fetchAndAddOrdered(1));
+ QList<int> roles;
+ object->updateValues(obj, roles);
+ return object;
+}
+
+void DynamicRoleModelNode::sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target, QHash<int, QQuickListModel *> *targetModelHash)
+{
+ for (int i=0 ; i < src->m_meta->count() ; ++i) {
+ const QByteArray &name = src->m_meta->name(i);
+ QVariant value = src->m_meta->value(i);
+
+ QQuickListModel *srcModel = qobject_cast<QQuickListModel *>(value.value<QObject *>());
+ QQuickListModel *targetModel = qobject_cast<QQuickListModel *>(target->m_meta->value(i).value<QObject *>());
+
+ if (srcModel) {
+ if (targetModel == 0)
+ targetModel = QQuickListModel::createWithOwner(target->m_owner);
+
+ QQuickListModel::sync(srcModel, targetModel, targetModelHash);
+
+ QObject *targetModelObject = targetModel;
+ value = QVariant::fromValue(targetModelObject);
+ } else if (targetModel) {
+ delete targetModel;
+ }
+
+ target->setValue(name, value);
+ }
+}
+
+void DynamicRoleModelNode::updateValues(const QVariantMap &object, QList<int> &roles)
+{
+ const QList<QString> &keys = object.keys();
+
+ QList<QString>::const_iterator it = keys.begin();
+ QList<QString>::const_iterator end = keys.end();
+
+ while (it != end) {
+ const QString &key = *it;
+
+ int roleIndex = m_owner->m_roles.indexOf(key);
+ if (roleIndex == -1) {
+ roleIndex = m_owner->m_roles.count();
+ m_owner->m_roles.append(key);
+ }
+
+ QVariant value = object[key];
+
+ if (value.type() == QVariant::List) {
+ QQuickListModel *subModel = QQuickListModel::createWithOwner(m_owner);
+
+ QVariantList subArray = value.toList();
+ QVariantList::const_iterator subIt = subArray.begin();
+ QVariantList::const_iterator subEnd = subArray.end();
+ while (subIt != subEnd) {
+ const QVariantMap &subObject = subIt->toMap();
+ subModel->m_modelObjects.append(DynamicRoleModelNode::create(subObject, subModel));
+ ++subIt;
+ }
+
+ QObject *subModelObject = subModel;
+ value = QVariant::fromValue(subModelObject);
+ }
+
+ const QByteArray &keyUtf8 = key.toUtf8();
+
+ QQuickListModel *existingModel = qobject_cast<QQuickListModel *>(m_meta->value(keyUtf8).value<QObject *>());
+ if (existingModel)
+ delete existingModel;
+
+ if (m_meta->setValue(keyUtf8, value))
+ roles << roleIndex;
+
+ ++it;
+ }
+}
+
+DynamicRoleModelNodeMetaObject::DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object)
+ : QQmlOpenMetaObject(object), m_enabled(false), m_owner(object)
+{
+}
+
+DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject()
+{
+ for (int i=0 ; i < count() ; ++i) {
+ QQuickListModel *subModel = qobject_cast<QQuickListModel *>(value(i).value<QObject *>());
+ if (subModel)
+ delete subModel;
+ }
+}
+
+void DynamicRoleModelNodeMetaObject::propertyWrite(int index)
+{
+ if (!m_enabled)
+ return;
+
+ QVariant v = value(index);
+ QQuickListModel *model = qobject_cast<QQuickListModel *>(v.value<QObject *>());
+ if (model)
+ delete model;
+}
+
+void DynamicRoleModelNodeMetaObject::propertyWritten(int index)
+{
+ if (!m_enabled)
+ return;
+
+ QQuickListModel *parentModel = m_owner->m_owner;
+
+ QVariant v = value(index);
+ if (v.type() == QVariant::List) {
+ QQuickListModel *subModel = QQuickListModel::createWithOwner(parentModel);
+
+ QVariantList subArray = v.toList();
+ QVariantList::const_iterator subIt = subArray.begin();
+ QVariantList::const_iterator subEnd = subArray.end();
+ while (subIt != subEnd) {
+ const QVariantMap &subObject = subIt->toMap();
+ subModel->m_modelObjects.append(DynamicRoleModelNode::create(subObject, subModel));
+ ++subIt;
+ }
+
+ QObject *subModelObject = subModel;
+ v = QVariant::fromValue(subModelObject);
+
+ setValue(index, v);
+ }
+
+ int elementIndex = parentModel->m_modelObjects.indexOf(m_owner);
+ int roleIndex = parentModel->m_roles.indexOf(QString::fromLatin1(name(index).constData()));
+
+ if (elementIndex != -1 && roleIndex != -1) {
+ QList<int> roles;
+ roles << roleIndex;
+
+ parentModel->emitItemsChanged(elementIndex, 1, roles);
+ }
+}
+
+QQuickListModelParser::ListInstruction *QQuickListModelParser::ListModelData::instructions() const
+{
+ return (QQuickListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData));
+}
+
+/*!
+ \qmlclass ListModel QQuickListModel
+ \inqmlmodule QtQuick 2
+ \ingroup qml-working-with-data
+ \brief The ListModel element defines a free-form list data source.
+
+ The ListModel is a simple container of ListElement definitions, each containing data roles.
+ The contents can be defined dynamically, or explicitly in QML.
+
+ The number of elements in the model can be obtained from its \l count property.
+ A number of familiar methods are also provided to manipulate the contents of the
+ model, including append(), insert(), move(), remove() and set(). These methods
+ accept dictionaries as their arguments; these are translated to ListElement objects
+ by the model.
+
+ Elements can be manipulated via the model using the setProperty() method, which
+ allows the roles of the specified element to be set and changed.
+
+ \section1 Example Usage
+
+ The following example shows a ListModel containing three elements, with the roles
+ "name" and "cost".
+
+ \div {class="float-right"}
+ \inlineimage listmodel.png
+ \enddiv
+
+ \snippet doc/src/snippets/qml/listmodel.qml 0
+
+ \clearfloat
+ Roles (properties) in each element must begin with a lower-case letter and
+ should be common to all elements in a model. The ListElement documentation
+ provides more guidelines for how elements should be defined.
+
+ Since the example model contains an \c id property, it can be referenced
+ by views, such as the ListView in this example:
+
+ \snippet doc/src/snippets/qml/listmodel-simple.qml 0
+ \dots 8
+ \snippet doc/src/snippets/qml/listmodel-simple.qml 1
+
+ It is possible for roles to contain list data. In the following example we
+ create a list of fruit attributes:
+
+ \snippet doc/src/snippets/qml/listmodel-nested.qml model
+
+ The delegate displays all the fruit attributes:
+
+ \div {class="float-right"}
+ \inlineimage listmodel-nested.png
+ \enddiv
+
+ \snippet doc/src/snippets/qml/listmodel-nested.qml delegate
+
+ \clearfloat
+ \section1 Modifying List Models
+
+ The content of a ListModel may be created and modified using the clear(),
+ append(), set(), insert() and setProperty() methods. For example:
+
+ \snippet doc/src/snippets/qml/listmodel-modify.qml delegate
+
+ Note that when creating content dynamically the set of available properties
+ cannot be changed once set. Whatever properties are first added to the model
+ are the only permitted properties in the model.
+
+ \section1 Using Threaded List Models with WorkerScript
+
+ ListModel can be used together with WorkerScript access a list model
+ from multiple threads. This is useful if list modifications are
+ synchronous and take some time: the list operations can be moved to a
+ different thread to avoid blocking of the main GUI thread.
+
+ Here is an example that uses WorkerScript to periodically append the
+ current time to a list model:
+
+ \snippet examples/declarative/threading/threadedlistmodel/timedisplay.qml 0
+
+ The included file, \tt dataloader.js, looks like this:
+
+ \snippet examples/declarative/threading/threadedlistmodel/dataloader.js 0
+
+ The timer in the main example sends messages to the worker script by calling
+ \l WorkerScript::sendMessage(). When this message is received,
+ \l{WorkerScript::onMessage}{WorkerScript.onMessage()} is invoked in \c dataloader.js,
+ which appends the current time to the list model.
+
+ Note the call to sync() from the \l{WorkerScript::onMessage}{WorkerScript.onMessage()}
+ handler. You must call sync() or else the changes made to the list from the external
+ thread will not be reflected in the list model in the main thread.
+
+ \sa {qmlmodels}{Data Models}, {declarative/threading/threadedlistmodel}{Threaded ListModel example}, QtQml
+*/
+
+QQuickListModel::QQuickListModel(QObject *parent)
+: QListModelInterface(parent)
+{
+ m_mainThread = true;
+ m_primary = true;
+ m_agent = 0;
+ m_uid = uidCounter.fetchAndAddOrdered(1);
+ m_dynamicRoles = false;
+
+ m_layout = new ListLayout;
+ m_listModel = new ListModel(m_layout, this, -1);
+
+ m_engine = 0;
+}
+
+QQuickListModel::QQuickListModel(const QQuickListModel *owner, ListModel *data, QV8Engine *eng, QObject *parent)
+: QListModelInterface(parent)
+{
+ m_mainThread = owner->m_mainThread;
+ m_primary = false;
+ m_agent = owner->m_agent;
+
+ Q_ASSERT(owner->m_dynamicRoles == false);
+ m_dynamicRoles = false;
+ m_layout = 0;
+ m_listModel = data;
+
+ m_engine = eng;
+}
+
+QQuickListModel::QQuickListModel(QQuickListModel *orig, QQuickListModelWorkerAgent *agent)
+: QListModelInterface(agent)
+{
+ m_mainThread = false;
+ m_primary = true;
+ m_agent = agent;
+ m_dynamicRoles = orig->m_dynamicRoles;
+
+ m_layout = new ListLayout(orig->m_layout);
+ m_listModel = new ListModel(m_layout, this, orig->m_listModel->getUid());
+
+ if (m_dynamicRoles)
+ sync(orig, this, 0);
+ else
+ ListModel::sync(orig->m_listModel, m_listModel, 0);
+
+ m_engine = 0;
+}
+
+QQuickListModel::~QQuickListModel()
+{
+ for (int i=0 ; i < m_modelObjects.count() ; ++i)
+ delete m_modelObjects[i];
+
+ if (m_primary) {
+ m_listModel->destroy();
+ delete m_listModel;
+
+ if (m_mainThread && m_agent) {
+ m_agent->modelDestroyed();
+ m_agent->release();
+ }
+ }
+
+ m_listModel = 0;
+
+ delete m_layout;
+ m_layout = 0;
+}
+
+QQuickListModel *QQuickListModel::createWithOwner(QQuickListModel *newOwner)
+{
+ QQuickListModel *model = new QQuickListModel;
+
+ model->m_mainThread = newOwner->m_mainThread;
+ model->m_engine = newOwner->m_engine;
+ model->m_agent = newOwner->m_agent;
+ model->m_dynamicRoles = newOwner->m_dynamicRoles;
+
+ if (model->m_mainThread && model->m_agent)
+ model->m_agent->addref();
+
+ QQmlEngine::setContextForObject(model, QQmlEngine::contextForObject(newOwner));
+
+ return model;
+}
+
+QV8Engine *QQuickListModel::engine() const
+{
+ if (m_engine == 0) {
+ m_engine = QQmlEnginePrivate::getV8Engine(qmlEngine(this));
+ }
+
+ return m_engine;
+}
+
+void QQuickListModel::sync(QQuickListModel *src, QQuickListModel *target, QHash<int, QQuickListModel *> *targetModelHash)
+{
+ Q_ASSERT(src->m_dynamicRoles && target->m_dynamicRoles);
+
+ target->m_uid = src->m_uid;
+ if (targetModelHash)
+ targetModelHash->insert(target->m_uid, target);
+ target->m_roles = src->m_roles;
+
+ // Build hash of elements <-> uid for each of the lists
+ QHash<int, ElementSync> elementHash;
+ for (int i=0 ; i < target->m_modelObjects.count() ; ++i) {
+ DynamicRoleModelNode *e = target->m_modelObjects.at(i);
+ int uid = e->getUid();
+ ElementSync sync;
+ sync.target = e;
+ elementHash.insert(uid, sync);
+ }
+ for (int i=0 ; i < src->m_modelObjects.count() ; ++i) {
+ DynamicRoleModelNode *e = src->m_modelObjects.at(i);
+ int uid = e->getUid();
+
+ QHash<int, ElementSync>::iterator it = elementHash.find(uid);
+ if (it == elementHash.end()) {
+ ElementSync sync;
+ sync.src = e;
+ elementHash.insert(uid, sync);
+ } else {
+ ElementSync &sync = it.value();
+ sync.src = e;
+ }
+ }
+
+ // Get list of elements that are in the target but no longer in the source. These get deleted first.
+ QHash<int, ElementSync>::iterator it = elementHash.begin();
+ QHash<int, ElementSync>::iterator end = elementHash.end();
+ while (it != end) {
+ const ElementSync &s = it.value();
+ if (s.src == 0) {
+ int targetIndex = target->m_modelObjects.indexOf(s.target);
+ target->m_modelObjects.remove(targetIndex, 1);
+ delete s.target;
+ }
+ ++it;
+ }
+
+ // Clear the target list, and append in correct order from the source
+ target->m_modelObjects.clear();
+ for (int i=0 ; i < src->m_modelObjects.count() ; ++i) {
+ DynamicRoleModelNode *srcElement = src->m_modelObjects.at(i);
+ it = elementHash.find(srcElement->getUid());
+ const ElementSync &s = it.value();
+ DynamicRoleModelNode *targetElement = s.target;
+ if (targetElement == 0) {
+ targetElement = new DynamicRoleModelNode(target, srcElement->getUid());
+ }
+ DynamicRoleModelNode::sync(srcElement, targetElement, targetModelHash);
+ target->m_modelObjects.append(targetElement);
+ }
+}
+
+void QQuickListModel::emitItemsChanged(int index, int count, const QList<int> &roles)
+{
+ if (m_mainThread) {
+ emit itemsChanged(index, count, roles);
+ } else {
+ int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
+ m_agent->data.changedChange(uid, index, count, roles);
+ }
+}
+
+void QQuickListModel::emitItemsRemoved(int index, int count)
+{
+ if (m_mainThread) {
+ emit itemsRemoved(index, count);
+ emit countChanged();
+ } else {
+ int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
+ if (index == 0 && count == this->count())
+ m_agent->data.clearChange(uid);
+ m_agent->data.removeChange(uid, index, count);
+ }
+}
+
+void QQuickListModel::emitItemsInserted(int index, int count)
+{
+ if (m_mainThread) {
+ emit itemsInserted(index, count);
+ emit countChanged();
+ } else {
+ int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
+ m_agent->data.insertChange(uid, index, count);
+ }
+}
+
+void QQuickListModel::emitItemsMoved(int from, int to, int n)
+{
+ if (m_mainThread) {
+ emit itemsMoved(from, to, n);
+ } else {
+ int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
+ m_agent->data.moveChange(uid, from, n, to);
+ }
+}
+
+QQuickListModelWorkerAgent *QQuickListModel::agent()
+{
+ if (m_agent)
+ return m_agent;
+
+ m_agent = new QQuickListModelWorkerAgent(this);
+ return m_agent;
+}
+
+QList<int> QQuickListModel::roles() const
+{
+ QList<int> rolesArray;
+
+ if (m_dynamicRoles) {
+ for (int i=0 ; i < m_roles.count() ; ++i)
+ rolesArray << i;
+ } else {
+ for (int i=0 ; i < m_listModel->roleCount() ; ++i)
+ rolesArray << i;
+ }
+
+ return rolesArray;
+}
+
+QString QQuickListModel::toString(int role) const
+{
+ QString roleName;
+
+ if (m_dynamicRoles) {
+ roleName = m_roles[role];
+ } else {
+ const ListLayout::Role &r = m_listModel->getExistingRole(role);
+ roleName = r.name;
+ }
+
+ return roleName;
+}
+
+QVariant QQuickListModel::data(int index, int role) const
+{
+ QVariant v;
+
+ if (index >= count() || index < 0)
+ return v;
+
+ if (m_dynamicRoles)
+ v = m_modelObjects[index]->getValue(m_roles[role]);
+ else
+ v = m_listModel->getProperty(index, role, this, engine());
+
+ return v;
+}
+
+/*!
+ \qmlproperty bool QtQuick2::ListModel::dynamicRoles
+
+ By default, the type of a role is fixed the first time
+ the role is used. For example, if you create a role called
+ "data" and assign a number to it, you can no longer assign
+ a string to the "data" role. However, when the dynamicRoles
+ property is enabled, the type of a given role is not fixed
+ and can be different between elements.
+
+ The dynamicRoles property must be set before any data is
+ added to the ListModel, and must be set from the main
+ thread.
+
+ A ListModel that has data statically defined (via the
+ ListElement QML syntax) cannot have the dynamicRoles
+ property enabled.
+
+ There is a significant performance cost to using a
+ ListModel with dynamic roles enabled. The cost varies
+ from platform to platform but is typically somewhere
+ between 4-6x slower than using static role types.
+
+ Due to the performance cost of using dynamic roles,
+ they are disabled by default.
+*/
+void QQuickListModel::setDynamicRoles(bool enableDynamicRoles)
+{
+ if (m_mainThread && m_agent == 0) {
+ if (enableDynamicRoles) {
+ if (m_layout->roleCount())
+ qmlInfo(this) << tr("unable to enable dynamic roles as this model is not empty!");
+ else
+ m_dynamicRoles = true;
+ } else {
+ if (m_roles.count()) {
+ qmlInfo(this) << tr("unable to enable static roles as this model is not empty!");
+ } else {
+ m_dynamicRoles = false;
+ }
+ }
+ } else {
+ qmlInfo(this) << tr("dynamic role setting must be made from the main thread, before any worker scripts are created");
+ }
+}
+
+/*!
+ \qmlproperty int QtQuick2::ListModel::count
+ The number of data entries in the model.
+*/
+int QQuickListModel::count() const
+{
+ int count;
+
+ if (m_dynamicRoles)
+ count = m_modelObjects.count();
+ else {
+ count = m_listModel->elementCount();
+ }
+
+ return count;
+}
+
+/*!
+ \qmlmethod QtQuick2::ListModel::clear()
+
+ Deletes all content from the model.
+
+ \sa append() remove()
+*/
+void QQuickListModel::clear()
+{
+ int cleared = count();
+
+ if (m_dynamicRoles) {
+ for (int i=0 ; i < m_modelObjects.count() ; ++i)
+ delete m_modelObjects[i];
+ m_modelObjects.clear();
+ } else {
+ m_listModel->clear();
+ }
+
+ emitItemsRemoved(0, cleared);
+}
+
+/*!
+ \qmlmethod QtQuick2::ListModel::remove(int index, int count = 1)
+
+ Deletes the content at \a index from the model.
+
+ \sa clear()
+*/
+void QQuickListModel::remove(QQmlV8Function *args)
+{
+ int argLength = args->Length();
+
+ if (argLength == 1 || argLength == 2) {
+ int index = (*args)[0]->Int32Value();
+ int removeCount = (argLength == 2 ? ((*args)[1]->Int32Value()) : 1);
+
+ if (index < 0 || index+removeCount > count() || removeCount <= 0) {
+ qmlInfo(this) << tr("remove: indices [%1 - %2] out of range [0 - %3]").arg(index).arg(index+removeCount).arg(count());
+ return;
+ }
+
+ if (m_dynamicRoles) {
+ for (int i=0 ; i < removeCount ; ++i)
+ delete m_modelObjects[index+i];
+ m_modelObjects.remove(index, removeCount);
+ } else {
+ m_listModel->remove(index, removeCount);
+ }
+
+ emitItemsRemoved(index, removeCount);
+ } else {
+ qmlInfo(this) << tr("remove: incorrect number of arguments");
+ }
+}
+
+/*!
+ \qmlmethod QtQuick2::ListModel::insert(int index, jsobject dict)
+
+ Adds a new item to the list model at position \a index, with the
+ values in \a dict.
+
+ \code
+ fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be to an existing item in the list, or one past
+ the end of the list (equivalent to append).
+
+ \sa set() append()
+*/
+
+void QQuickListModel::insert(QQmlV8Function *args)
+{
+ if (args->Length() == 2) {
+
+ v8::Handle<v8::Value> arg0 = (*args)[0];
+ int index = arg0->Int32Value();
+
+ if (index < 0 || index > count()) {
+ qmlInfo(this) << tr("insert: index %1 out of range").arg(index);
+ return;
+ }
+
+ v8::Handle<v8::Value> arg1 = (*args)[1];
+
+ if (arg1->IsArray()) {
+ v8::Handle<v8::Array> objectArray = v8::Handle<v8::Array>::Cast(arg1);
+ int objectArrayLength = objectArray->Length();
+ for (int i=0 ; i < objectArrayLength ; ++i) {
+ v8::Handle<v8::Object> argObject = objectArray->Get(i)->ToObject();
+
+ if (m_dynamicRoles) {
+ m_modelObjects.insert(index+i, DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
+ } else {
+ m_listModel->insert(index+i, argObject, args->engine());
+ }
+ }
+ emitItemsInserted(index, objectArrayLength);
+ } else if (arg1->IsObject()) {
+ v8::Handle<v8::Object> argObject = arg1->ToObject();
+
+ if (m_dynamicRoles) {
+ m_modelObjects.insert(index, DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
+ } else {
+ m_listModel->insert(index, argObject, args->engine());
+ }
+
+ emitItemsInserted(index, 1);
+ } else {
+ qmlInfo(this) << tr("insert: value is not an object");
+ }
+ } else {
+ qmlInfo(this) << tr("insert: value is not an object");
+ }
+}
+
+/*!
+ \qmlmethod QtQuick2::ListModel::move(int from, int to, int n)
+
+ Moves \a n items \a from one position \a to another.
+
+ The from and to ranges must exist; for example, to move the first 3 items
+ to the end of the list:
+
+ \code
+ fruitModel.move(0, fruitModel.count - 3, 3)
+ \endcode
+
+ \sa append()
+*/
+void QQuickListModel::move(int from, int to, int n)
+{
+ if (n==0 || from==to)
+ return;
+ if (!canMove(from, to, n)) {
+ qmlInfo(this) << tr("move: out of range");
+ return;
+ }
+
+ if (m_dynamicRoles) {
+
+ int realFrom = from;
+ int realTo = to;
+ int realN = n;
+
+ if (from > to) {
+ // Only move forwards - flip if backwards moving
+ int tfrom = from;
+ int tto = to;
+ realFrom = tto;
+ realTo = tto+n;
+ realN = tfrom-tto;
+ }
+
+ QPODVector<DynamicRoleModelNode *, 4> store;
+ for (int i=0 ; i < (realTo-realFrom) ; ++i)
+ store.append(m_modelObjects[realFrom+realN+i]);
+ for (int i=0 ; i < realN ; ++i)
+ store.append(m_modelObjects[realFrom+i]);
+ for (int i=0 ; i < store.count() ; ++i)
+ m_modelObjects[realFrom+i] = store[i];
+
+ } else {
+ m_listModel->move(from, to, n);
+ }
+
+ emitItemsMoved(from, to, n);
+}
+
+/*!
+ \qmlmethod QtQuick2::ListModel::append(jsobject dict)
+
+ Adds a new item to the end of the list model, with the
+ values in \a dict.
+
+ \code
+ fruitModel.append({"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ \sa set() remove()
+*/
+void QQuickListModel::append(QQmlV8Function *args)
+{
+ if (args->Length() == 1) {
+ v8::Handle<v8::Value> arg = (*args)[0];
+
+ if (arg->IsArray()) {
+ v8::Handle<v8::Array> objectArray = v8::Handle<v8::Array>::Cast(arg);
+ int objectArrayLength = objectArray->Length();
+
+ int index = count();
+ for (int i=0 ; i < objectArrayLength ; ++i) {
+ v8::Handle<v8::Object> argObject = objectArray->Get(i)->ToObject();
+
+ if (m_dynamicRoles) {
+ m_modelObjects.append(DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
+ } else {
+ m_listModel->append(argObject, args->engine());
+ }
+ }
+
+ emitItemsInserted(index, objectArrayLength);
+ } else if (arg->IsObject()) {
+ v8::Handle<v8::Object> argObject = arg->ToObject();
+
+ int index;
+
+ if (m_dynamicRoles) {
+ index = m_modelObjects.count();
+ m_modelObjects.append(DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
+ } else {
+ index = m_listModel->append(argObject, args->engine());
+ }
+
+ emitItemsInserted(index, 1);
+ } else {
+ qmlInfo(this) << tr("append: value is not an object");
+ }
+ } else {
+ qmlInfo(this) << tr("append: value is not an object");
+ }
+}
+
+/*!
+ \qmlmethod object QtQuick2::ListModel::get(int index)
+
+ Returns the item at \a index in the list model. This allows the item
+ data to be accessed or modified from JavaScript:
+
+ \code
+ Component.onCompleted: {
+ fruitModel.append({"cost": 5.95, "name":"Jackfruit"});
+ console.log(fruitModel.get(0).cost);
+ fruitModel.get(0).cost = 10.95;
+ }
+ \endcode
+
+ The \a index must be an element in the list.
+
+ Note that properties of the returned object that are themselves objects
+ will also be models, and this get() method is used to access elements:
+
+ \code
+ fruitModel.append(..., "attributes":
+ [{"name":"spikes","value":"7mm"},
+ {"name":"color","value":"green"}]);
+ fruitModel.get(0).attributes.get(1).value; // == "green"
+ \endcode
+
+ \warning The returned object is not guaranteed to remain valid. It
+ should not be used in \l{Property Binding}{property bindings}.
+
+ \sa append()
+*/
+QQmlV8Handle QQuickListModel::get(int index) const
+{
+ v8::Handle<v8::Value> result = v8::Undefined();
+
+ if (index >= 0 && index < count()) {
+ QV8Engine *v8engine = engine();
+
+ if (m_dynamicRoles) {
+ DynamicRoleModelNode *object = m_modelObjects[index];
+ result = v8engine->newQObject(object);
+ } else {
+ ModelObject *object = m_listModel->getOrCreateModelObject(const_cast<QQuickListModel *>(this), index);
+ result = v8engine->newQObject(object);
+ }
+ }
+
+ return QQmlV8Handle::fromHandle(result);
+}
+
+/*!
+ \qmlmethod QtQuick2::ListModel::set(int index, jsobject dict)
+
+ Changes the item at \a index in the list model with the
+ values in \a dict. Properties not appearing in \a dict
+ are left unchanged.
+
+ \code
+ fruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ If \a index is equal to count() then a new item is appended to the
+ list. Otherwise, \a index must be an element in the list.
+
+ \sa append()
+*/
+void QQuickListModel::set(int index, const QQmlV8Handle &handle)
+{
+ v8::Handle<v8::Value> valuemap = handle.toHandle();
+
+ if (!valuemap->IsObject() || valuemap->IsArray()) {
+ qmlInfo(this) << tr("set: value is not an object");
+ return;
+ }
+ if (index > count() || index < 0) {
+ qmlInfo(this) << tr("set: index %1 out of range").arg(index);
+ return;
+ }
+
+ v8::Handle<v8::Object> object = valuemap->ToObject();
+
+ if (index == count()) {
+
+ if (m_dynamicRoles) {
+ m_modelObjects.append(DynamicRoleModelNode::create(engine()->variantMapFromJS(object), this));
+ } else {
+ m_listModel->insert(index, object, engine());
+ }
+
+ emitItemsInserted(index, 1);
+ } else {
+
+ QList<int> roles;
+
+ if (m_dynamicRoles) {
+ m_modelObjects[index]->updateValues(engine()->variantMapFromJS(object), roles);
+ } else {
+ m_listModel->set(index, object, &roles, engine());
+ }
+
+ if (roles.count())
+ emitItemsChanged(index, 1, roles);
+ }
+}
+
+/*!
+ \qmlmethod QtQuick2::ListModel::setProperty(int index, string property, variant value)
+
+ Changes the \a property of the item at \a index in the list model to \a value.
+
+ \code
+ fruitModel.setProperty(3, "cost", 5.95)
+ \endcode
+
+ The \a index must be an element in the list.
+
+ \sa append()
+*/
+void QQuickListModel::setProperty(int index, const QString& property, const QVariant& value)
+{
+ if (count() == 0 || index >= count() || index < 0) {
+ qmlInfo(this) << tr("set: index %1 out of range").arg(index);
+ return;
+ }
+
+ if (m_dynamicRoles) {
+ int roleIndex = m_roles.indexOf(property);
+ if (roleIndex == -1) {
+ roleIndex = m_roles.count();
+ m_roles.append(property);
+ }
+ if (m_modelObjects[index]->setValue(property.toUtf8(), value)) {
+ QList<int> roles;
+ roles << roleIndex;
+ emitItemsChanged(index, 1, roles);
+ }
+ } else {
+ int roleIndex = m_listModel->setOrCreateProperty(index, property, value);
+ if (roleIndex != -1) {
+
+ QList<int> roles;
+ roles << roleIndex;
+
+ emitItemsChanged(index, 1, roles);
+ }
+ }
+}
+
+/*!
+ \qmlmethod QtQuick2::ListModel::sync()
+
+ Writes any unsaved changes to the list model after it has been modified
+ from a worker script.
+*/
+void QQuickListModel::sync()
+{
+ // This is just a dummy method to make it look like sync() exists in
+ // ListModel (and not just QQuickListModelWorkerAgent) and to let
+ // us document sync().
+ qmlInfo(this) << "List sync() can only be called from a WorkerScript";
+}
+
+bool QQuickListModelParser::compileProperty(const QQmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
+{
+ QList<QVariant> values = prop.assignedValues();
+ for(int ii = 0; ii < values.count(); ++ii) {
+ const QVariant &value = values.at(ii);
+
+ if(value.userType() == qMetaTypeId<QQmlCustomParserNode>()) {
+ QQmlCustomParserNode node =
+ qvariant_cast<QQmlCustomParserNode>(value);
+
+ if (node.name() != listElementTypeName) {
+ const QMetaObject *mo = resolveType(node.name());
+ if (mo != &QQuickListElement::staticMetaObject) {
+ error(node, QQuickListModel::tr("ListElement: cannot contain nested elements"));
+ return false;
+ }
+ listElementTypeName = node.name(); // cache right name for next time
+ }
+
+ {
+ ListInstruction li;
+ li.type = ListInstruction::Push;
+ li.dataIdx = -1;
+ instr << li;
+ }
+
+ QList<QQmlCustomParserProperty> props = node.properties();
+ for(int jj = 0; jj < props.count(); ++jj) {
+ const QQmlCustomParserProperty &nodeProp = props.at(jj);
+ if (nodeProp.name().isEmpty()) {
+ error(nodeProp, QQuickListModel::tr("ListElement: cannot contain nested elements"));
+ return false;
+ }
+ if (nodeProp.name() == QStringLiteral("id")) {
+ error(nodeProp, QQuickListModel::tr("ListElement: cannot use reserved \"id\" property"));
+ return false;
+ }
+
+ ListInstruction li;
+ int ref = data.count();
+ data.append(nodeProp.name().toUtf8());
+ data.append('\0');
+ li.type = ListInstruction::Set;
+ li.dataIdx = ref;
+ instr << li;
+
+ if(!compileProperty(nodeProp, instr, data))
+ return false;
+
+ li.type = ListInstruction::Pop;
+ li.dataIdx = -1;
+ instr << li;
+ }
+
+ {
+ ListInstruction li;
+ li.type = ListInstruction::Pop;
+ li.dataIdx = -1;
+ instr << li;
+ }
+
+ } else {
+
+ QQmlScript::Variant variant =
+ qvariant_cast<QQmlScript::Variant>(value);
+
+ int ref = data.count();
+
+ QByteArray d;
+ d += char(variant.type()); // type tag
+ if (variant.isString()) {
+ d += variant.asString().toUtf8();
+ } else if (variant.isNumber()) {
+ d += QByteArray::number(variant.asNumber(),'g',20);
+ } else if (variant.isBoolean()) {
+ d += char(variant.asBoolean());
+ } else if (variant.isScript()) {
+ if (definesEmptyList(variant.asScript())) {
+ d[0] = char(QQmlScript::Variant::Invalid); // marks empty list
+ } else {
+ QByteArray script = variant.asScript().toUtf8();
+ int v = evaluateEnum(script);
+ if (v<0) {
+ using namespace QQmlJS;
+ AST::Node *node = variant.asAST();
+ AST::StringLiteral *literal = 0;
+ if (AST::CallExpression *callExpr = AST::cast<AST::CallExpression *>(node)) {
+ if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(callExpr->base)) {
+ if (idExpr->name == QLatin1String("QT_TR_NOOP") || idExpr->name == QLatin1String("QT_TRID_NOOP")) {
+ if (callExpr->arguments && !callExpr->arguments->next)
+ literal = AST::cast<AST::StringLiteral *>(callExpr->arguments->expression);
+ if (!literal) {
+ error(prop, QQuickListModel::tr("ListElement: improperly specified %1").arg(idExpr->name.toString()));
+ return false;
+ }
+ } else if (idExpr->name == QLatin1String("QT_TRANSLATE_NOOP")) {
+ if (callExpr->arguments && callExpr->arguments->next && !callExpr->arguments->next->next)
+ literal = AST::cast<AST::StringLiteral *>(callExpr->arguments->next->expression);
+ if (!literal) {
+ error(prop, QQuickListModel::tr("ListElement: improperly specified QT_TRANSLATE_NOOP"));
+ return false;
+ }
+ }
+ }
+ }
+
+ if (literal) {
+ d[0] = char(QQmlScript::Variant::String);
+ d += literal->value.toUtf8();
+ } else {
+ error(prop, QQuickListModel::tr("ListElement: cannot use script for property value"));
+ return false;
+ }
+ } else {
+ d[0] = char(QQmlScript::Variant::Number);
+ d += QByteArray::number(v);
+ }
+ }
+ }
+ d.append('\0');
+ data.append(d);
+
+ ListInstruction li;
+ li.type = ListInstruction::Value;
+ li.dataIdx = ref;
+ instr << li;
+ }
+ }
+
+ return true;
+}
+
+QByteArray QQuickListModelParser::compile(const QList<QQmlCustomParserProperty> &customProps)
+{
+ QList<ListInstruction> instr;
+ QByteArray data;
+ listElementTypeName = QString(); // unknown
+
+ for(int ii = 0; ii < customProps.count(); ++ii) {
+ const QQmlCustomParserProperty &prop = customProps.at(ii);
+ if(!prop.name().isEmpty()) { // isn't default property
+ error(prop, QQuickListModel::tr("ListModel: undefined property '%1'").arg(prop.name()));
+ return QByteArray();
+ }
+
+ if(!compileProperty(prop, instr, data)) {
+ return QByteArray();
+ }
+ }
+
+ int size = sizeof(ListModelData) +
+ instr.count() * sizeof(ListInstruction) +
+ data.count();
+
+ QByteArray rv;
+ rv.resize(size);
+
+ ListModelData *lmd = (ListModelData *)rv.data();
+ lmd->dataOffset = sizeof(ListModelData) +
+ instr.count() * sizeof(ListInstruction);
+ lmd->instrCount = instr.count();
+ for (int ii = 0; ii < instr.count(); ++ii)
+ lmd->instructions()[ii] = instr.at(ii);
+ ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count());
+
+ return rv;
+}
+
+void QQuickListModelParser::setCustomData(QObject *obj, const QByteArray &d)
+{
+ QQuickListModel *rv = static_cast<QQuickListModel *>(obj);
+
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(qmlEngine(rv));
+ rv->m_engine = engine;
+
+ const ListModelData *lmd = (const ListModelData *)d.constData();
+ const char *data = ((const char *)lmd) + lmd->dataOffset;
+
+ QStack<DataStackElement> stack;
+
+ for (int ii = 0; ii < lmd->instrCount; ++ii) {
+ const ListInstruction &instr = lmd->instructions()[ii];
+
+ switch(instr.type) {
+ case ListInstruction::Push:
+ {
+ Q_ASSERT(!rv->m_dynamicRoles);
+
+ ListModel *subModel = 0;
+
+ if (stack.count() == 0) {
+ subModel = rv->m_listModel;
+ } else {
+ const DataStackElement &e0 = stack.at(stack.size() - 1);
+ DataStackElement &e1 = stack[stack.size() - 2];
+
+ const ListLayout::Role &role = e1.model->getOrCreateListRole(e0.name);
+ if (role.type == ListLayout::Role::List) {
+ subModel = e1.model->getListProperty(e1.elementIndex, role);
+
+ if (subModel == 0) {
+ subModel = new ListModel(role.subLayout, 0, -1);
+ QVariant vModel = QVariant::fromValue(subModel);
+ e1.model->setOrCreateProperty(e1.elementIndex, e0.name, vModel);
+ }
+ }
+ }
+
+ DataStackElement e;
+ e.model = subModel;
+ e.elementIndex = subModel ? subModel->appendElement() : -1;
+ stack.push(e);
+ }
+ break;
+
+ case ListInstruction::Pop:
+ stack.pop();
+ break;
+
+ case ListInstruction::Value:
+ {
+ const DataStackElement &e0 = stack.at(stack.size() - 1);
+ DataStackElement &e1 = stack[stack.size() - 2];
+
+ QString name = e0.name;
+ QVariant value;
+
+ switch (QQmlScript::Variant::Type(data[instr.dataIdx])) {
+ case QQmlScript::Variant::Invalid:
+ {
+ const ListLayout::Role &role = e1.model->getOrCreateListRole(e0.name);
+ ListModel *emptyModel = new ListModel(role.subLayout, 0, -1);
+ value = QVariant::fromValue(emptyModel);
+ }
+ break;
+ case QQmlScript::Variant::Boolean:
+ value = bool(data[1 + instr.dataIdx]);
+ break;
+ case QQmlScript::Variant::Number:
+ value = QByteArray(data + 1 + instr.dataIdx).toDouble();
+ break;
+ case QQmlScript::Variant::String:
+ value = QString::fromUtf8(data + 1 + instr.dataIdx);
+ break;
+ default:
+ Q_ASSERT("Format error in ListInstruction");
+ }
+
+ e1.model->setOrCreateProperty(e1.elementIndex, name, value);
+ }
+ break;
+
+ case ListInstruction::Set:
+ {
+ DataStackElement e;
+ e.name = QString::fromUtf8(data + instr.dataIdx);
+ stack.push(e);
+ }
+ break;
+ }
+ }
+}
+
+bool QQuickListModelParser::definesEmptyList(const QString &s)
+{
+ if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) {
+ for (int i=1; i<s.length()-1; i++) {
+ if (!s[i].isSpace())
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+
+/*!
+ \qmlclass ListElement QQuickListElement
+ \inqmlmodule QtQuick 2
+ \ingroup qml-working-with-data
+ \brief The ListElement element defines a data item in a ListModel.
+
+ List elements are defined inside ListModel definitions, and represent items in a
+ list that will be displayed using ListView or \l Repeater items.
+
+ List elements are defined like other QML elements except that they contain
+ a collection of \e role definitions instead of properties. Using the same
+ syntax as property definitions, roles both define how the data is accessed
+ and include the data itself.
+
+ The names used for roles must begin with a lower-case letter and should be
+ common to all elements in a given model. Values must be simple constants; either
+ strings (quoted and optionally within a call to QT_TR_NOOP), boolean values
+ (true, false), numbers, or enumeration values (such as AlignText.AlignHCenter).
+
+ \section1 Referencing Roles
+
+ The role names are used by delegates to obtain data from list elements.
+ Each role name is accessible in the delegate's scope, and refers to the
+ corresponding role in the current element. Where a role name would be
+ ambiguous to use, it can be accessed via the \l{ListView::}{model}
+ property (e.g., \c{model.cost} instead of \c{cost}).
+
+ \section1 Example Usage
+
+ The following model defines a series of list elements, each of which
+ contain "name" and "cost" roles and their associated values.
+
+ \snippet doc/src/snippets/qml/qml-data-models/listelements.qml model
+
+ The delegate obtains the name and cost for each element by simply referring
+ to \c name and \c cost:
+
+ \snippet doc/src/snippets/qml/qml-data-models/listelements.qml view
+
+ \sa ListModel
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/qquicklistmodel_p.h b/src/qml/qml/qquicklistmodel_p.h
new file mode 100644
index 0000000000..2941de9148
--- /dev/null
+++ b/src/qml/qml/qquicklistmodel_p.h
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKLISTMODEL_H
+#define QQUICKLISTMODEL_H
+
+#include <qqml.h>
+#include <private/qqmlcustomparser_p.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QStringList>
+#include <QtCore/QHash>
+#include <QtCore/QList>
+#include <QtCore/QVariant>
+#include "qlistmodelinterface_p.h"
+
+#include <private/qv8engine_p.h>
+#include <private/qpodvector_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQuickListModelWorkerAgent;
+class ListModel;
+class ListLayout;
+
+class Q_QML_PRIVATE_EXPORT QQuickListModel : public QListModelInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+ Q_PROPERTY(bool dynamicRoles READ dynamicRoles WRITE setDynamicRoles)
+
+public:
+ QQuickListModel(QObject *parent=0);
+ ~QQuickListModel();
+
+ virtual QList<int> roles() const;
+ virtual QString toString(int role) const;
+ virtual int count() const;
+ virtual QVariant data(int index, int role) const;
+
+ Q_INVOKABLE void clear();
+ Q_INVOKABLE void remove(QQmlV8Function *args);
+ Q_INVOKABLE void append(QQmlV8Function *args);
+ Q_INVOKABLE void insert(QQmlV8Function *args);
+ Q_INVOKABLE QQmlV8Handle get(int index) const;
+ Q_INVOKABLE void set(int index, const QQmlV8Handle &);
+ Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);
+ Q_INVOKABLE void move(int from, int to, int count);
+ Q_INVOKABLE void sync();
+
+ QQuickListModelWorkerAgent *agent();
+
+ bool dynamicRoles() const { return m_dynamicRoles; }
+ void setDynamicRoles(bool enableDynamicRoles);
+
+Q_SIGNALS:
+ void countChanged();
+
+private:
+ friend class QQuickListModelParser;
+ friend class QQuickListModelWorkerAgent;
+ friend class ModelObject;
+ friend class ModelNodeMetaObject;
+ friend class ListModel;
+ friend class ListElement;
+ friend class DynamicRoleModelNode;
+ friend class DynamicRoleModelNodeMetaObject;
+
+ // Constructs a flat list model for a worker agent
+ QQuickListModel(QQuickListModel *orig, QQuickListModelWorkerAgent *agent);
+ QQuickListModel(const QQuickListModel *owner, ListModel *data, QV8Engine *eng, QObject *parent=0);
+
+ QV8Engine *engine() const;
+
+ inline bool canMove(int from, int to, int n) const { return !(from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0); }
+
+ QQuickListModelWorkerAgent *m_agent;
+ mutable QV8Engine *m_engine;
+ bool m_mainThread;
+ bool m_primary;
+
+ bool m_dynamicRoles;
+
+ ListLayout *m_layout;
+ ListModel *m_listModel;
+
+ QVector<class DynamicRoleModelNode *> m_modelObjects;
+ QVector<QString> m_roles;
+ int m_uid;
+
+ struct ElementSync
+ {
+ ElementSync() : src(0), target(0) {}
+
+ DynamicRoleModelNode *src;
+ DynamicRoleModelNode *target;
+ };
+
+ int getUid() const { return m_uid; }
+
+ static void sync(QQuickListModel *src, QQuickListModel *target, QHash<int, QQuickListModel *> *targetModelHash);
+ static QQuickListModel *createWithOwner(QQuickListModel *newOwner);
+
+ void emitItemsChanged(int index, int count, const QList<int> &roles);
+ void emitItemsRemoved(int index, int count);
+ void emitItemsInserted(int index, int count);
+ void emitItemsMoved(int from, int to, int n);
+};
+
+// ### FIXME
+class QQuickListElement : public QObject
+{
+Q_OBJECT
+};
+
+class QQuickListModelParser : public QQmlCustomParser
+{
+public:
+ QQuickListModelParser() : QQmlCustomParser(QQmlCustomParser::AcceptsSignalHandlers) {}
+ QByteArray compile(const QList<QQmlCustomParserProperty> &);
+ void setCustomData(QObject *, const QByteArray &);
+
+private:
+ struct ListInstruction
+ {
+ enum { Push, Pop, Value, Set } type;
+ int dataIdx;
+ };
+ struct ListModelData
+ {
+ int dataOffset;
+ int instrCount;
+ ListInstruction *instructions() const;
+ };
+ bool compileProperty(const QQmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data);
+
+ bool definesEmptyList(const QString &);
+
+ QString listElementTypeName;
+
+ struct DataStackElement
+ {
+ DataStackElement() : model(0), elementIndex(0) {}
+
+ QString name;
+ ListModel *model;
+ int elementIndex;
+ };
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickListModel)
+QML_DECLARE_TYPE(QQuickListElement)
+
+QT_END_HEADER
+
+#endif // QQUICKLISTMODEL_H
diff --git a/src/qml/qml/qquicklistmodel_p_p.h b/src/qml/qml/qquicklistmodel_p_p.h
new file mode 100644
index 0000000000..f9256c9f0a
--- /dev/null
+++ b/src/qml/qml/qquicklistmodel_p_p.h
@@ -0,0 +1,378 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKLISTMODEL_P_P_H
+#define QQUICKLISTMODEL_P_P_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 "qquicklistmodel_p.h"
+#include <private/qqmlengine_p.h>
+#include "qqmlopenmetaobject_p.h"
+#include <qqml.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class DynamicRoleModelNode;
+
+class DynamicRoleModelNodeMetaObject : public QQmlOpenMetaObject
+{
+public:
+ DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object);
+ ~DynamicRoleModelNodeMetaObject();
+
+ bool m_enabled;
+
+protected:
+ void propertyWrite(int index);
+ void propertyWritten(int index);
+
+private:
+ DynamicRoleModelNode *m_owner;
+};
+
+class DynamicRoleModelNode : public QObject
+{
+ Q_OBJECT
+public:
+ DynamicRoleModelNode(QQuickListModel *owner, int uid);
+
+ static DynamicRoleModelNode *create(const QVariantMap &obj, QQuickListModel *owner);
+
+ void updateValues(const QVariantMap &object, QList<int> &roles);
+
+ QVariant getValue(const QString &name)
+ {
+ return m_meta->value(name.toUtf8());
+ }
+
+ bool setValue(const QByteArray &name, const QVariant &val)
+ {
+ return m_meta->setValue(name, val);
+ }
+
+ void setNodeUpdatesEnabled(bool enable)
+ {
+ m_meta->m_enabled = enable;
+ }
+
+ int getUid() const
+ {
+ return m_uid;
+ }
+
+ static void sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target, QHash<int, QQuickListModel *> *targetModelHash);
+
+private:
+ QQuickListModel *m_owner;
+ int m_uid;
+ DynamicRoleModelNodeMetaObject *m_meta;
+
+ friend class DynamicRoleModelNodeMetaObject;
+};
+
+class ModelObject;
+
+class ModelNodeMetaObject : public QQmlOpenMetaObject
+{
+public:
+ ModelNodeMetaObject(ModelObject *object);
+ ~ModelNodeMetaObject();
+
+ bool m_enabled;
+
+protected:
+ void propertyWritten(int index);
+
+private:
+
+ ModelObject *m_obj;
+};
+
+class ModelObject : public QObject
+{
+ Q_OBJECT
+public:
+ ModelObject(QQuickListModel *model, int elementIndex);
+
+ void setValue(const QByteArray &name, const QVariant &val, bool force)
+ {
+ if (force) {
+ QVariant existingValue = m_meta->value(name);
+ if (existingValue.isValid()) {
+ (*m_meta)[name] = QVariant();
+ }
+ }
+ m_meta->setValue(name, val);
+ }
+
+ void setNodeUpdatesEnabled(bool enable)
+ {
+ m_meta->m_enabled = enable;
+ }
+
+ void updateValues();
+ void updateValues(const QList<int> &roles);
+
+ QQuickListModel *m_model;
+ int m_elementIndex;
+
+private:
+ ModelNodeMetaObject *m_meta;
+};
+
+class ListLayout
+{
+public:
+ ListLayout() : currentBlock(0), currentBlockOffset(0) {}
+ ListLayout(const ListLayout *other);
+ ~ListLayout();
+
+ class Role
+ {
+ public:
+
+ Role() : type(Invalid), blockIndex(-1), blockOffset(-1), index(-1), subLayout(0) {}
+ explicit Role(const Role *other);
+ ~Role();
+
+ // This enum must be kept in sync with the roleTypeNames variable in qdeclarativelistmodel.cpp
+ enum DataType
+ {
+ Invalid = -1,
+
+ String,
+ Number,
+ Bool,
+ List,
+ QObject,
+ VariantMap,
+
+ MaxDataType
+ };
+
+ QString name;
+ DataType type;
+ int blockIndex;
+ int blockOffset;
+ int index;
+ ListLayout *subLayout;
+ };
+
+ const Role *getRoleOrCreate(const QString &key, const QVariant &data);
+ const Role &getRoleOrCreate(v8::Handle<v8::String> key, Role::DataType type);
+ const Role &getRoleOrCreate(const QString &key, Role::DataType type);
+
+ const Role &getExistingRole(int index) { return *roles.at(index); }
+ const Role *getExistingRole(const QString &key);
+ const Role *getExistingRole(v8::Handle<v8::String> key);
+
+ int roleCount() const { return roles.count(); }
+
+ static void sync(ListLayout *src, ListLayout *target);
+
+private:
+ const Role &createRole(const QString &key, Role::DataType type);
+
+ int currentBlock;
+ int currentBlockOffset;
+ QVector<Role *> roles;
+ QStringHash<Role *> roleHash;
+};
+
+class ListElement
+{
+public:
+
+ ListElement();
+ ListElement(int existingUid);
+ ~ListElement();
+
+ static void sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout, QHash<int, ListModel *> *targetModelHash);
+
+ enum
+ {
+ BLOCK_SIZE = 64 - sizeof(int) - sizeof(ListElement *) - sizeof(ModelObject *)
+ };
+
+private:
+
+ void destroy(ListLayout *layout);
+
+ int setVariantProperty(const ListLayout::Role &role, const QVariant &d);
+
+ int setJsProperty(const ListLayout::Role &role, v8::Handle<v8::Value> d, QV8Engine *eng);
+
+ int setStringProperty(const ListLayout::Role &role, const QString &s);
+ int setDoubleProperty(const ListLayout::Role &role, double n);
+ int setBoolProperty(const ListLayout::Role &role, bool b);
+ int setListProperty(const ListLayout::Role &role, ListModel *m);
+ int setQObjectProperty(const ListLayout::Role &role, QObject *o);
+ int setVariantMapProperty(const ListLayout::Role &role, v8::Handle<v8::Object> o, QV8Engine *eng);
+ int setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m);
+
+ void setStringPropertyFast(const ListLayout::Role &role, const QString &s);
+ void setDoublePropertyFast(const ListLayout::Role &role, double n);
+ void setBoolPropertyFast(const ListLayout::Role &role, bool b);
+ void setQObjectPropertyFast(const ListLayout::Role &role, QObject *o);
+ void setListPropertyFast(const ListLayout::Role &role, ListModel *m);
+ void setVariantMapFast(const ListLayout::Role &role, v8::Handle<v8::Object> o, QV8Engine *eng);
+
+ void clearProperty(const ListLayout::Role &role);
+
+ QVariant getProperty(const ListLayout::Role &role, const QQuickListModel *owner, QV8Engine *eng);
+ ListModel *getListProperty(const ListLayout::Role &role);
+ QString *getStringProperty(const ListLayout::Role &role);
+ QObject *getQObjectProperty(const ListLayout::Role &role);
+ QQmlGuard<QObject> *getGuardProperty(const ListLayout::Role &role);
+ QVariantMap *getVariantMapProperty(const ListLayout::Role &role);
+
+ inline char *getPropertyMemory(const ListLayout::Role &role);
+
+ int getUid() const { return uid; }
+
+ char data[BLOCK_SIZE];
+ ListElement *next;
+
+ int uid;
+ ModelObject *m_objectCache;
+
+ friend class ListModel;
+};
+
+class ListModel
+{
+public:
+
+ ListModel(ListLayout *layout, QQuickListModel *modelCache, int uid);
+ ~ListModel() {}
+
+ void destroy();
+
+ int setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data);
+ int setExistingProperty(int uid, const QString &key, v8::Handle<v8::Value> data, QV8Engine *eng);
+
+ QVariant getProperty(int elementIndex, int roleIndex, const QQuickListModel *owner, QV8Engine *eng);
+ ListModel *getListProperty(int elementIndex, const ListLayout::Role &role);
+
+ int roleCount() const
+ {
+ return m_layout->roleCount();
+ }
+
+ const ListLayout::Role &getExistingRole(int index)
+ {
+ return m_layout->getExistingRole(index);
+ }
+
+ const ListLayout::Role &getOrCreateListRole(const QString &name)
+ {
+ return m_layout->getRoleOrCreate(name, ListLayout::Role::List);
+ }
+
+ int elementCount() const
+ {
+ return elements.count();
+ }
+
+ void set(int elementIndex, v8::Handle<v8::Object> object, QList<int> *roles, QV8Engine *eng);
+ void set(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng);
+
+ int append(v8::Handle<v8::Object> object, QV8Engine *eng);
+ void insert(int elementIndex, v8::Handle<v8::Object> object, QV8Engine *eng);
+
+ void clear();
+ void remove(int index, int count);
+
+ int appendElement();
+ void insertElement(int index);
+
+ void move(int from, int to, int n);
+
+ int getUid() const { return m_uid; }
+
+ static void sync(ListModel *src, ListModel *target, QHash<int, ListModel *> *srcModelHash);
+
+ ModelObject *getOrCreateModelObject(QQuickListModel *model, int elementIndex);
+
+private:
+ QPODVector<ListElement *, 4> elements;
+ ListLayout *m_layout;
+ int m_uid;
+
+ QQuickListModel *m_modelCache;
+
+ struct ElementSync
+ {
+ ElementSync() : src(0), target(0) {}
+
+ ListElement *src;
+ ListElement *target;
+ };
+
+ void newElement(int index);
+
+ void updateCacheIndices();
+
+ friend class ListElement;
+ friend class QQuickListModelWorkerAgent;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(ListModel *);
+
+QT_END_HEADER
+
+#endif // QQUICKLISTMODEL_P_P_H
+
diff --git a/src/qml/qml/qquicklistmodelworkeragent.cpp b/src/qml/qml/qquicklistmodelworkeragent.cpp
new file mode 100644
index 0000000000..c50b348a4a
--- /dev/null
+++ b/src/qml/qml/qquicklistmodelworkeragent.cpp
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicklistmodelworkeragent_p.h"
+#include "qquicklistmodel_p_p.h"
+#include <private/qqmldata_p.h>
+#include <private/qqmlengine_p.h>
+#include <qqmlinfo.h>
+
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdebug.h>
+
+
+QT_BEGIN_NAMESPACE
+
+
+void QQuickListModelWorkerAgent::Data::clearChange(int uid)
+{
+ for (int i=0 ; i < changes.count() ; ++i) {
+ if (changes[i].modelUid == uid) {
+ changes.removeAt(i);
+ --i;
+ }
+ }
+}
+
+void QQuickListModelWorkerAgent::Data::insertChange(int uid, int index, int count)
+{
+ Change c = { uid, Change::Inserted, index, count, 0, QList<int>() };
+ changes << c;
+}
+
+void QQuickListModelWorkerAgent::Data::removeChange(int uid, int index, int count)
+{
+ Change c = { uid, Change::Removed, index, count, 0, QList<int>() };
+ changes << c;
+}
+
+void QQuickListModelWorkerAgent::Data::moveChange(int uid, int index, int count, int to)
+{
+ Change c = { uid, Change::Moved, index, count, to, QList<int>() };
+ changes << c;
+}
+
+void QQuickListModelWorkerAgent::Data::changedChange(int uid, int index, int count, const QList<int> &roles)
+{
+ Change c = { uid, Change::Changed, index, count, 0, roles };
+ changes << c;
+}
+
+QQuickListModelWorkerAgent::QQuickListModelWorkerAgent(QQuickListModel *model)
+: m_ref(1), m_orig(model), m_copy(new QQuickListModel(model, this))
+{
+}
+
+QQuickListModelWorkerAgent::~QQuickListModelWorkerAgent()
+{
+ mutex.lock();
+ syncDone.wakeAll();
+ mutex.unlock();
+}
+
+void QQuickListModelWorkerAgent::setV8Engine(QV8Engine *eng)
+{
+ m_copy->m_engine = eng;
+}
+
+void QQuickListModelWorkerAgent::addref()
+{
+ m_ref.ref();
+}
+
+void QQuickListModelWorkerAgent::release()
+{
+ bool del = !m_ref.deref();
+
+ if (del)
+ deleteLater();
+}
+
+void QQuickListModelWorkerAgent::modelDestroyed()
+{
+ m_orig = 0;
+}
+
+int QQuickListModelWorkerAgent::count() const
+{
+ return m_copy->count();
+}
+
+void QQuickListModelWorkerAgent::clear()
+{
+ m_copy->clear();
+}
+
+void QQuickListModelWorkerAgent::remove(QQmlV8Function *args)
+{
+ m_copy->remove(args);
+}
+
+void QQuickListModelWorkerAgent::append(QQmlV8Function *args)
+{
+ m_copy->append(args);
+}
+
+void QQuickListModelWorkerAgent::insert(QQmlV8Function *args)
+{
+ m_copy->insert(args);
+}
+
+QQmlV8Handle QQuickListModelWorkerAgent::get(int index) const
+{
+ return m_copy->get(index);
+}
+
+void QQuickListModelWorkerAgent::set(int index, const QQmlV8Handle &value)
+{
+ m_copy->set(index, value);
+}
+
+void QQuickListModelWorkerAgent::setProperty(int index, const QString& property, const QVariant& value)
+{
+ m_copy->setProperty(index, property, value);
+}
+
+void QQuickListModelWorkerAgent::move(int from, int to, int count)
+{
+ m_copy->move(from, to, count);
+}
+
+void QQuickListModelWorkerAgent::sync()
+{
+ Sync *s = new Sync;
+ s->data = data;
+ s->list = m_copy;
+ data.changes.clear();
+
+ mutex.lock();
+ QCoreApplication::postEvent(this, s);
+ syncDone.wait(&mutex);
+ mutex.unlock();
+}
+
+bool QQuickListModelWorkerAgent::event(QEvent *e)
+{
+ if (e->type() == QEvent::User) {
+ bool cc = false;
+ QMutexLocker locker(&mutex);
+ if (m_orig) {
+ Sync *s = static_cast<Sync *>(e);
+ const QList<Change> &changes = s->data.changes;
+
+ cc = m_orig->count() != s->list->count();
+
+ QHash<int, QQuickListModel *> targetModelDynamicHash;
+ QHash<int, ListModel *> targetModelStaticHash;
+
+ Q_ASSERT(m_orig->m_dynamicRoles == s->list->m_dynamicRoles);
+ if (m_orig->m_dynamicRoles)
+ QQuickListModel::sync(s->list, m_orig, &targetModelDynamicHash);
+ else
+ ListModel::sync(s->list->m_listModel, m_orig->m_listModel, &targetModelStaticHash);
+
+ for (int ii = 0; ii < changes.count(); ++ii) {
+ const Change &change = changes.at(ii);
+
+ QQuickListModel *model = 0;
+ if (m_orig->m_dynamicRoles) {
+ model = targetModelDynamicHash.value(change.modelUid);
+ } else {
+ ListModel *lm = targetModelStaticHash.value(change.modelUid);
+ if (lm)
+ model = lm->m_modelCache;
+ }
+
+ if (model) {
+ switch (change.type) {
+ case Change::Inserted:
+ emit model->itemsInserted(change.index, change.count);
+ break;
+ case Change::Removed:
+ emit model->itemsRemoved(change.index, change.count);
+ break;
+ case Change::Moved:
+ emit model->itemsMoved(change.index, change.to, change.count);
+ break;
+ case Change::Changed:
+ emit model->itemsChanged(change.index, change.count, change.roles);
+ break;
+ }
+ }
+ }
+ }
+
+ syncDone.wakeAll();
+ locker.unlock();
+
+ if (cc)
+ emit m_orig->countChanged();
+ return true;
+ }
+
+ return QObject::event(e);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/qquicklistmodelworkeragent_p.h b/src/qml/qml/qquicklistmodelworkeragent_p.h
new file mode 100644
index 0000000000..cf2ef45c16
--- /dev/null
+++ b/src/qml/qml/qquicklistmodelworkeragent_p.h
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKLISTMODELWORKERAGENT_P_H
+#define QQUICKLISTMODELWORKERAGENT_P_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 <qqml.h>
+
+#include <QtGui/qevent.h>
+#include <QMutex>
+#include <QWaitCondition>
+
+#include <private/qv8engine_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQuickListModel;
+
+class QQuickListModelWorkerAgent : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count)
+
+public:
+ QQuickListModelWorkerAgent(QQuickListModel *);
+ ~QQuickListModelWorkerAgent();
+ void setV8Engine(QV8Engine *eng);
+
+ void addref();
+ void release();
+
+ int count() const;
+
+ Q_INVOKABLE void clear();
+ Q_INVOKABLE void remove(QQmlV8Function *args);
+ Q_INVOKABLE void append(QQmlV8Function *args);
+ Q_INVOKABLE void insert(QQmlV8Function *args);
+ Q_INVOKABLE QQmlV8Handle get(int index) const;
+ Q_INVOKABLE void set(int index, const QQmlV8Handle &);
+ Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);
+ Q_INVOKABLE void move(int from, int to, int count);
+ Q_INVOKABLE void sync();
+
+ struct VariantRef
+ {
+ VariantRef() : a(0) {}
+ VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); }
+ VariantRef(QQuickListModelWorkerAgent *_a) : a(_a) { if (a) a->addref(); }
+ ~VariantRef() { if (a) a->release(); }
+
+ VariantRef &operator=(const VariantRef &o) {
+ if (o.a) o.a->addref();
+ if (a) a->release(); a = o.a;
+ return *this;
+ }
+
+ QQuickListModelWorkerAgent *a;
+ };
+ void modelDestroyed();
+protected:
+ virtual bool event(QEvent *);
+
+private:
+ friend class QQuickWorkerScriptEnginePrivate;
+ friend class QQuickListModel;
+
+ struct Change
+ {
+ int modelUid;
+ enum { Inserted, Removed, Moved, Changed } type;
+ int index; // Inserted/Removed/Moved/Changed
+ int count; // Inserted/Removed/Moved/Changed
+ int to; // Moved
+ QList<int> roles;
+ };
+
+ struct Data
+ {
+ QList<Change> changes;
+
+ void clearChange(int uid);
+ void insertChange(int uid, int index, int count);
+ void removeChange(int uid, int index, int count);
+ void moveChange(int uid, int index, int count, int to);
+ void changedChange(int uid, int index, int count, const QList<int> &roles);
+ };
+ Data data;
+
+ struct Sync : public QEvent {
+ Sync() : QEvent(QEvent::User) {}
+ Data data;
+ QQuickListModel *list;
+ };
+
+ QAtomicInt m_ref;
+ QQuickListModel *m_orig;
+ QQuickListModel *m_copy;
+ QMutex mutex;
+ QWaitCondition syncDone;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQuickListModelWorkerAgent::VariantRef)
+
+QT_END_HEADER
+
+#endif // QQUICKLISTMODELWORKERAGENT_P_H
+
diff --git a/src/qml/qml/qquickworkerscript.cpp b/src/qml/qml/qquickworkerscript.cpp
new file mode 100644
index 0000000000..529f181e7a
--- /dev/null
+++ b/src/qml/qml/qquickworkerscript.cpp
@@ -0,0 +1,730 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickworkerscript_p.h"
+#include "qquicklistmodel_p.h"
+#include "qquicklistmodelworkeragent_p.h"
+#include "qqmlengine_p.h"
+#include "qqmlexpression_p.h"
+
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdebug.h>
+#include <QtQml/qjsengine.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qwaitcondition.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdatetime.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include <QtQml/qqmlinfo.h>
+#include "qqmlnetworkaccessmanagerfactory.h"
+
+#include <private/qv8engine_p.h>
+#include <private/qv8worker_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class WorkerDataEvent : public QEvent
+{
+public:
+ enum Type { WorkerData = QEvent::User };
+
+ WorkerDataEvent(int workerId, const QByteArray &data);
+ virtual ~WorkerDataEvent();
+
+ int workerId() const;
+ QByteArray data() const;
+
+private:
+ int m_id;
+ QByteArray m_data;
+};
+
+class WorkerLoadEvent : public QEvent
+{
+public:
+ enum Type { WorkerLoad = WorkerDataEvent::WorkerData + 1 };
+
+ WorkerLoadEvent(int workerId, const QUrl &url);
+
+ int workerId() const;
+ QUrl url() const;
+
+private:
+ int m_id;
+ QUrl m_url;
+};
+
+class WorkerRemoveEvent : public QEvent
+{
+public:
+ enum Type { WorkerRemove = WorkerLoadEvent::WorkerLoad + 1 };
+
+ WorkerRemoveEvent(int workerId);
+
+ int workerId() const;
+
+private:
+ int m_id;
+};
+
+class WorkerErrorEvent : public QEvent
+{
+public:
+ enum Type { WorkerError = WorkerRemoveEvent::WorkerRemove + 1 };
+
+ WorkerErrorEvent(const QQmlError &error);
+
+ QQmlError error() const;
+
+private:
+ QQmlError m_error;
+};
+
+class QQuickWorkerScriptEnginePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ enum WorkerEventTypes {
+ WorkerDestroyEvent = QEvent::User + 100
+ };
+
+ QQuickWorkerScriptEnginePrivate(QQmlEngine *eng);
+
+ class WorkerEngine : public QV8Engine
+ {
+ public:
+ WorkerEngine(QQuickWorkerScriptEnginePrivate *parent);
+ ~WorkerEngine();
+
+ void init();
+ virtual QNetworkAccessManager *networkAccessManager();
+
+ QQuickWorkerScriptEnginePrivate *p;
+
+ v8::Local<v8::Function> sendFunction(int id);
+ void callOnMessage(v8::Handle<v8::Object> object, v8::Handle<v8::Value> arg);
+ private:
+ v8::Persistent<v8::Function> onmessage;
+ v8::Persistent<v8::Function> createsend;
+ QNetworkAccessManager *accessManager;
+ };
+
+ WorkerEngine *workerEngine;
+ static QQuickWorkerScriptEnginePrivate *get(QV8Engine *e) {
+ return static_cast<WorkerEngine *>(e)->p;
+ }
+
+ QQmlEngine *qmlengine;
+
+ QMutex m_lock;
+ QWaitCondition m_wait;
+
+ struct WorkerScript {
+ WorkerScript();
+ ~WorkerScript();
+
+ int id;
+ QUrl source;
+ bool initialized;
+ QQuickWorkerScript *owner;
+ v8::Persistent<v8::Object> object;
+ };
+
+ QHash<int, WorkerScript *> workers;
+ v8::Handle<v8::Object> getWorker(WorkerScript *);
+
+ int m_nextId;
+
+ static v8::Handle<v8::Value> sendMessage(const v8::Arguments &args);
+
+signals:
+ void stopThread();
+
+protected:
+ virtual bool event(QEvent *);
+
+private:
+ void processMessage(int, const QByteArray &);
+ void processLoad(int, const QUrl &);
+ void reportScriptException(WorkerScript *, const QQmlError &error);
+};
+
+QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEnginePrivate *parent)
+: QV8Engine(0), p(parent), accessManager(0)
+{
+}
+
+QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine()
+{
+ qPersistentDispose(createsend);
+ qPersistentDispose(onmessage);
+ delete accessManager;
+}
+
+void QQuickWorkerScriptEnginePrivate::WorkerEngine::init()
+{
+ initQmlGlobalObject();
+#define CALL_ONMESSAGE_SCRIPT \
+ "(function(object, message) { "\
+ "var isfunction = false; "\
+ "try { "\
+ "isfunction = object.WorkerScript.onMessage instanceof Function; "\
+ "} catch (e) {}" \
+ "if (isfunction) "\
+ "object.WorkerScript.onMessage(message); "\
+ "})"
+
+#define SEND_MESSAGE_CREATE_SCRIPT \
+ "(function(method, engine) { "\
+ "return (function(id) { "\
+ "return (function(message) { "\
+ "if (arguments.length) method(engine, id, message); "\
+ "}); "\
+ "}); "\
+ "})"
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(context());
+
+ {
+ v8::Local<v8::Script> onmessagescript = v8::Script::New(v8::String::New(CALL_ONMESSAGE_SCRIPT));
+ onmessage = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(onmessagescript->Run()));
+ }
+ {
+ v8::Local<v8::Script> createsendscript = v8::Script::New(v8::String::New(SEND_MESSAGE_CREATE_SCRIPT));
+ v8::Local<v8::Function> createsendconstructor = v8::Local<v8::Function>::Cast(createsendscript->Run());
+
+ v8::Handle<v8::Value> args[] = {
+ V8FUNCTION(QQuickWorkerScriptEnginePrivate::sendMessage, this)
+ };
+ v8::Local<v8::Value> createsendvalue = createsendconstructor->Call(global(), 1, args);
+
+ createsend = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(createsendvalue));
+ }
+}
+
+// Requires handle and context scope
+v8::Local<v8::Function> QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(int id)
+{
+ v8::Handle<v8::Value> args[] = { v8::Integer::New(id) };
+ return v8::Local<v8::Function>::Cast(createsend->Call(global(), 1, args));
+}
+
+// Requires handle and context scope
+void QQuickWorkerScriptEnginePrivate::WorkerEngine::callOnMessage(v8::Handle<v8::Object> object,
+ v8::Handle<v8::Value> arg)
+{
+ v8::Handle<v8::Value> args[] = { object, arg };
+ onmessage->Call(global(), 2, args);
+}
+
+QNetworkAccessManager *QQuickWorkerScriptEnginePrivate::WorkerEngine::networkAccessManager()
+{
+ if (!accessManager) {
+ if (p->qmlengine && p->qmlengine->networkAccessManagerFactory()) {
+ accessManager = p->qmlengine->networkAccessManagerFactory()->create(p);
+ } else {
+ accessManager = new QNetworkAccessManager(p);
+ }
+ }
+ return accessManager;
+}
+
+QQuickWorkerScriptEnginePrivate::QQuickWorkerScriptEnginePrivate(QQmlEngine *engine)
+: workerEngine(0), qmlengine(engine), m_nextId(0)
+{
+}
+
+v8::Handle<v8::Value> QQuickWorkerScriptEnginePrivate::sendMessage(const v8::Arguments &args)
+{
+ WorkerEngine *engine = (WorkerEngine*)V8ENGINE();
+
+ int id = args[1]->Int32Value();
+
+ QByteArray data = QV8Worker::serialize(args[2], engine);
+
+ QMutexLocker(&engine->p->m_lock);
+ WorkerScript *script = engine->p->workers.value(id);
+ if (!script)
+ return v8::Undefined();
+
+ if (script->owner)
+ QCoreApplication::postEvent(script->owner, new WorkerDataEvent(0, data));
+
+ return v8::Undefined();
+}
+
+// Requires handle scope and context scope
+v8::Handle<v8::Object> QQuickWorkerScriptEnginePrivate::getWorker(WorkerScript *script)
+{
+ if (!script->initialized) {
+ script->initialized = true;
+
+ script->object = qPersistentNew<v8::Object>(workerEngine->contextWrapper()->urlScope(script->source));
+
+ workerEngine->contextWrapper()->setReadOnly(script->object, false);
+
+ v8::Local<v8::Object> api = v8::Object::New();
+ api->Set(v8::String::New("sendMessage"), workerEngine->sendFunction(script->id));
+
+ script->object->Set(v8::String::New("WorkerScript"), api);
+
+ workerEngine->contextWrapper()->setReadOnly(script->object, true);
+ }
+
+ return script->object;
+}
+
+bool QQuickWorkerScriptEnginePrivate::event(QEvent *event)
+{
+ if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
+ WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
+ processMessage(workerEvent->workerId(), workerEvent->data());
+ return true;
+ } else if (event->type() == (QEvent::Type)WorkerLoadEvent::WorkerLoad) {
+ WorkerLoadEvent *workerEvent = static_cast<WorkerLoadEvent *>(event);
+ processLoad(workerEvent->workerId(), workerEvent->url());
+ return true;
+ } else if (event->type() == (QEvent::Type)WorkerDestroyEvent) {
+ emit stopThread();
+ return true;
+ } else if (event->type() == (QEvent::Type)WorkerRemoveEvent::WorkerRemove) {
+ WorkerRemoveEvent *workerEvent = static_cast<WorkerRemoveEvent *>(event);
+ workers.remove(workerEvent->workerId());
+ return true;
+ } else {
+ return QObject::event(event);
+ }
+}
+
+void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &data)
+{
+ WorkerScript *script = workers.value(id);
+ if (!script)
+ return;
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(workerEngine->context());
+
+ v8::Handle<v8::Value> value = QV8Worker::deserialize(data, workerEngine);
+
+ v8::TryCatch tc;
+ workerEngine->callOnMessage(script->object, value);
+
+ if (tc.HasCaught()) {
+ QQmlError error;
+ QQmlExpressionPrivate::exceptionToError(tc.Message(), error);
+ reportScriptException(script, error);
+ }
+}
+
+void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
+{
+ if (url.isRelative())
+ return;
+
+ QString fileName = QQmlEnginePrivate::urlToLocalFileOrQrc(url);
+
+ QFile f(fileName);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QString sourceCode = QString::fromUtf8(data);
+ QQmlScript::Parser::extractPragmas(sourceCode);
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(workerEngine->context());
+
+ WorkerScript *script = workers.value(id);
+ if (!script)
+ return;
+ script->source = url;
+ v8::Handle<v8::Object> activation = getWorker(script);
+ if (activation.IsEmpty())
+ return;
+
+ // XXX ???
+ // workerEngine->baseUrl = url;
+
+ v8::TryCatch tc;
+ v8::Local<v8::Script> program = workerEngine->qmlModeCompile(sourceCode, url.toString());
+
+ if (!tc.HasCaught())
+ program->Run(activation);
+
+ if (tc.HasCaught()) {
+ QQmlError error;
+ QQmlExpressionPrivate::exceptionToError(tc.Message(), error);
+ reportScriptException(script, error);
+ }
+ } else {
+ qWarning().nospace() << "WorkerScript: Cannot find source file " << url.toString();
+ }
+}
+
+void QQuickWorkerScriptEnginePrivate::reportScriptException(WorkerScript *script,
+ const QQmlError &error)
+{
+ QQuickWorkerScriptEnginePrivate *p = QQuickWorkerScriptEnginePrivate::get(workerEngine);
+
+ QMutexLocker(&p->m_lock);
+ if (script->owner)
+ QCoreApplication::postEvent(script->owner, new WorkerErrorEvent(error));
+}
+
+WorkerDataEvent::WorkerDataEvent(int workerId, const QByteArray &data)
+: QEvent((QEvent::Type)WorkerData), m_id(workerId), m_data(data)
+{
+}
+
+WorkerDataEvent::~WorkerDataEvent()
+{
+}
+
+int WorkerDataEvent::workerId() const
+{
+ return m_id;
+}
+
+QByteArray WorkerDataEvent::data() const
+{
+ return m_data;
+}
+
+WorkerLoadEvent::WorkerLoadEvent(int workerId, const QUrl &url)
+: QEvent((QEvent::Type)WorkerLoad), m_id(workerId), m_url(url)
+{
+}
+
+int WorkerLoadEvent::workerId() const
+{
+ return m_id;
+}
+
+QUrl WorkerLoadEvent::url() const
+{
+ return m_url;
+}
+
+WorkerRemoveEvent::WorkerRemoveEvent(int workerId)
+: QEvent((QEvent::Type)WorkerRemove), m_id(workerId)
+{
+}
+
+int WorkerRemoveEvent::workerId() const
+{
+ return m_id;
+}
+
+WorkerErrorEvent::WorkerErrorEvent(const QQmlError &error)
+: QEvent((QEvent::Type)WorkerError), m_error(error)
+{
+}
+
+QQmlError WorkerErrorEvent::error() const
+{
+ return m_error;
+}
+
+QQuickWorkerScriptEngine::QQuickWorkerScriptEngine(QQmlEngine *parent)
+: QThread(parent), d(new QQuickWorkerScriptEnginePrivate(parent))
+{
+ d->m_lock.lock();
+ connect(d, SIGNAL(stopThread()), this, SLOT(quit()), Qt::DirectConnection);
+ start(QThread::LowestPriority);
+ d->m_wait.wait(&d->m_lock);
+ d->moveToThread(this);
+ d->m_lock.unlock();
+}
+
+QQuickWorkerScriptEngine::~QQuickWorkerScriptEngine()
+{
+ d->m_lock.lock();
+ QCoreApplication::postEvent(d, new QEvent((QEvent::Type)QQuickWorkerScriptEnginePrivate::WorkerDestroyEvent));
+ d->m_lock.unlock();
+
+ //We have to force to cleanup the main thread's event queue here
+ //to make sure the main GUI release all pending locks/wait conditions which
+ //some worker script/agent are waiting for (QQuickListModelWorkerAgent::sync() for example).
+ QCoreApplication::processEvents();
+ wait();
+ d->deleteLater();
+}
+
+QQuickWorkerScriptEnginePrivate::WorkerScript::WorkerScript()
+: id(-1), initialized(false), owner(0)
+{
+}
+
+QQuickWorkerScriptEnginePrivate::WorkerScript::~WorkerScript()
+{
+ qPersistentDispose(object);
+}
+
+int QQuickWorkerScriptEngine::registerWorkerScript(QQuickWorkerScript *owner)
+{
+ typedef QQuickWorkerScriptEnginePrivate::WorkerScript WorkerScript;
+ WorkerScript *script = new WorkerScript;
+
+ script->id = d->m_nextId++;
+ script->owner = owner;
+
+ d->m_lock.lock();
+ d->workers.insert(script->id, script);
+ d->m_lock.unlock();
+
+ return script->id;
+}
+
+void QQuickWorkerScriptEngine::removeWorkerScript(int id)
+{
+ QQuickWorkerScriptEnginePrivate::WorkerScript* script = d->workers.value(id);
+ if (script) {
+ script->owner = 0;
+ QCoreApplication::postEvent(d, new WorkerRemoveEvent(id));
+ }
+}
+
+void QQuickWorkerScriptEngine::executeUrl(int id, const QUrl &url)
+{
+ QCoreApplication::postEvent(d, new WorkerLoadEvent(id, url));
+}
+
+void QQuickWorkerScriptEngine::sendMessage(int id, const QByteArray &data)
+{
+ QCoreApplication::postEvent(d, new WorkerDataEvent(id, data));
+}
+
+void QQuickWorkerScriptEngine::run()
+{
+ d->m_lock.lock();
+
+ d->workerEngine = new QQuickWorkerScriptEnginePrivate::WorkerEngine(d);
+ d->workerEngine->init();
+
+ d->m_wait.wakeAll();
+
+ d->m_lock.unlock();
+
+ exec();
+
+ qDeleteAll(d->workers);
+ d->workers.clear();
+
+ delete d->workerEngine; d->workerEngine = 0;
+}
+
+
+/*!
+ \qmlclass WorkerScript QQuickWorkerScript
+ \ingroup qml-utility-elements
+ \brief The WorkerScript element enables the use of threads in QML.
+
+ Use WorkerScript to run operations in a new thread.
+ This is useful for running operations in the background so
+ that the main GUI thread is not blocked.
+
+ Messages can be passed between the new thread and the parent thread
+ using \l sendMessage() and the \l {WorkerScript::onMessage}{onMessage()} handler.
+
+ An example:
+
+ \snippet doc/src/snippets/qml/workerscript.qml 0
+
+ The above worker script specifies a JavaScript file, "script.js", that handles
+ the operations to be performed in the new thread. Here is \c script.js:
+
+ \quotefile doc/src/snippets/qml/script.js
+
+ When the user clicks anywhere within the rectangle, \c sendMessage() is
+ called, triggering the \tt WorkerScript.onMessage() handler in
+ \tt script.js. This in turn sends a reply message that is then received
+ by the \tt onMessage() handler of \tt myWorker.
+
+
+ \section3 Restrictions
+
+ Since the \c WorkerScript.onMessage() function is run in a separate thread, the
+ JavaScript file is evaluated in a context separate from the main QML engine. This means
+ that unlike an ordinary JavaScript file that is imported into QML, the \c script.js
+ in the above example cannot access the properties, methods or other attributes
+ of the QML item, nor can it access any context properties set on the QML object
+ through QQmlContext.
+
+ Additionally, there are restrictions on the types of values that can be passed to and
+ from the worker script. See the sendMessage() documentation for details.
+
+ \sa {declarative/threading/workerscript}{WorkerScript example},
+ {declarative/threading/threadedlistmodel}{Threaded ListModel example}
+*/
+QQuickWorkerScript::QQuickWorkerScript(QObject *parent)
+: QObject(parent), m_engine(0), m_scriptId(-1), m_componentComplete(true)
+{
+}
+
+QQuickWorkerScript::~QQuickWorkerScript()
+{
+ if (m_scriptId != -1) m_engine->removeWorkerScript(m_scriptId);
+}
+
+/*!
+ \qmlproperty url WorkerScript::source
+
+ This holds the url of the JavaScript file that implements the
+ \tt WorkerScript.onMessage() handler for threaded operations.
+*/
+QUrl QQuickWorkerScript::source() const
+{
+ return m_source;
+}
+
+void QQuickWorkerScript::setSource(const QUrl &source)
+{
+ if (m_source == source)
+ return;
+
+ m_source = source;
+
+ if (engine())
+ m_engine->executeUrl(m_scriptId, m_source);
+
+ emit sourceChanged();
+}
+
+/*!
+ \qmlmethod WorkerScript::sendMessage(jsobject message)
+
+ Sends the given \a message to a worker script handler in another
+ thread. The other worker script handler can receive this message
+ through the onMessage() handler.
+
+ The \c message object may only contain values of the following
+ types:
+
+ \list
+ \o boolean, number, string
+ \o JavaScript objects and arrays
+ \o ListModel objects (any other type of QObject* is not allowed)
+ \endlist
+
+ All objects and arrays are copied to the \c message. With the exception
+ of ListModel objects, any modifications by the other thread to an object
+ passed in \c message will not be reflected in the original object.
+*/
+void QQuickWorkerScript::sendMessage(QQmlV8Function *args)
+{
+ if (!engine()) {
+ qWarning("QQuickWorkerScript: Attempt to send message before WorkerScript establishment");
+ return;
+ }
+
+ v8::Handle<v8::Value> argument = v8::Undefined();
+ if (args->Length() != 0)
+ argument = (*args)[0];
+
+ m_engine->sendMessage(m_scriptId, QV8Worker::serialize(argument, args->engine()));
+}
+
+void QQuickWorkerScript::classBegin()
+{
+ m_componentComplete = false;
+}
+
+QQuickWorkerScriptEngine *QQuickWorkerScript::engine()
+{
+ if (m_engine) return m_engine;
+ if (m_componentComplete) {
+ QQmlEngine *engine = qmlEngine(this);
+ if (!engine) {
+ qWarning("QQuickWorkerScript: engine() called without qmlEngine() set");
+ return 0;
+ }
+
+ m_engine = QQmlEnginePrivate::get(engine)->getWorkerScriptEngine();
+ m_scriptId = m_engine->registerWorkerScript(this);
+
+ if (m_source.isValid())
+ m_engine->executeUrl(m_scriptId, m_source);
+
+ return m_engine;
+ }
+ return 0;
+}
+
+void QQuickWorkerScript::componentComplete()
+{
+ m_componentComplete = true;
+ engine(); // Get it started now.
+}
+
+/*!
+ \qmlsignal WorkerScript::onMessage(jsobject msg)
+
+ This handler is called when a message \a msg is received from a worker
+ script in another thread through a call to sendMessage().
+*/
+
+bool QQuickWorkerScript::event(QEvent *event)
+{
+ if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
+ QQmlEngine *engine = qmlEngine(this);
+ if (engine) {
+ WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
+ QV8Engine *v8engine = QQmlEnginePrivate::get(engine)->v8engine();
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(v8engine->context());
+ v8::Handle<v8::Value> value = QV8Worker::deserialize(workerEvent->data(), v8engine);
+ emit message(QQmlV8Handle::fromHandle(value));
+ }
+ return true;
+ } else if (event->type() == (QEvent::Type)WorkerErrorEvent::WorkerError) {
+ WorkerErrorEvent *workerEvent = static_cast<WorkerErrorEvent *>(event);
+ QQmlEnginePrivate::warning(qmlEngine(this), workerEvent->error());
+ return true;
+ } else {
+ return QObject::event(event);
+ }
+}
+
+QT_END_NAMESPACE
+
+#include <qquickworkerscript.moc>
+
diff --git a/src/qml/qml/qquickworkerscript_p.h b/src/qml/qml/qquickworkerscript_p.h
new file mode 100644
index 0000000000..fd1c3ed690
--- /dev/null
+++ b/src/qml/qml/qquickworkerscript_p.h
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWORKERSCRIPT_P_H
+#define QQUICKWORKERSCRIPT_P_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 "qqml.h"
+#include "qqmlparserstatus.h"
+
+#include <QtCore/qthread.h>
+#include <QtQml/qjsvalue.h>
+#include <QtCore/qurl.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQuickWorkerScript;
+class QQuickWorkerScriptEnginePrivate;
+class QQuickWorkerScriptEngine : public QThread
+{
+Q_OBJECT
+public:
+ QQuickWorkerScriptEngine(QQmlEngine *parent = 0);
+ virtual ~QQuickWorkerScriptEngine();
+
+ int registerWorkerScript(QQuickWorkerScript *);
+ void removeWorkerScript(int);
+ void executeUrl(int, const QUrl &);
+ void sendMessage(int, const QByteArray &);
+
+protected:
+ virtual void run();
+
+private:
+ QQuickWorkerScriptEnginePrivate *d;
+};
+
+class QQmlV8Function;
+class QQmlV8Handle;
+class Q_AUTOTEST_EXPORT QQuickWorkerScript : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+
+ Q_INTERFACES(QQmlParserStatus)
+public:
+ QQuickWorkerScript(QObject *parent = 0);
+ virtual ~QQuickWorkerScript();
+
+ QUrl source() const;
+ void setSource(const QUrl &);
+
+public slots:
+ void sendMessage(QQmlV8Function*);
+
+signals:
+ void sourceChanged();
+ void message(const QQmlV8Handle &messageObject);
+
+protected:
+ virtual void classBegin();
+ virtual void componentComplete();
+ virtual bool event(QEvent *);
+
+private:
+ QQuickWorkerScriptEngine *engine();
+ QQuickWorkerScriptEngine *m_engine;
+ int m_scriptId;
+ QUrl m_source;
+ bool m_componentComplete;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickWorkerScript)
+
+QT_END_HEADER
+
+#endif // QQUICKWORKERSCRIPT_P_H
diff --git a/src/declarative/qml/rewriter/rewriter.pri b/src/qml/qml/rewriter/rewriter.pri
index e51ee5ba4e..e51ee5ba4e 100644
--- a/src/declarative/qml/rewriter/rewriter.pri
+++ b/src/qml/qml/rewriter/rewriter.pri
diff --git a/src/qml/qml/rewriter/textwriter.cpp b/src/qml/qml/rewriter/textwriter.cpp
new file mode 100644
index 0000000000..f14c4af521
--- /dev/null
+++ b/src/qml/qml/rewriter/textwriter.cpp
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textwriter_p.h"
+
+QT_QML_BEGIN_NAMESPACE
+
+using namespace QQmlJS;
+
+TextWriter::TextWriter()
+ :string(0), cursor(0)
+{
+}
+
+static bool overlaps(int posA, int lengthA, int posB, int lengthB) {
+ return (posA < posB + lengthB && posA + lengthA > posB + lengthB)
+ || (posA < posB && posA + lengthA > posB);
+}
+
+bool TextWriter::hasOverlap(int pos, int length)
+{
+ {
+ QListIterator<Replace> i(replaceList);
+ while (i.hasNext()) {
+ const Replace &cmd = i.next();
+ if (overlaps(pos, length, cmd.pos, cmd.length))
+ return true;
+ }
+ }
+ {
+ QListIterator<Move> i(moveList);
+ while (i.hasNext()) {
+ const Move &cmd = i.next();
+ if (overlaps(pos, length, cmd.pos, cmd.length))
+ return true;
+ }
+ return false;
+ }
+}
+
+bool TextWriter::hasMoveInto(int pos, int length)
+{
+ QListIterator<Move> i(moveList);
+ while (i.hasNext()) {
+ const Move &cmd = i.next();
+ if (cmd.to >= pos && cmd.to < pos + length)
+ return true;
+ }
+ return false;
+}
+
+void TextWriter::replace(int pos, int length, const QString &replacement)
+{
+ Q_ASSERT(!hasOverlap(pos, length));
+ Q_ASSERT(!hasMoveInto(pos, length));
+
+ Replace cmd;
+ cmd.pos = pos;
+ cmd.length = length;
+ cmd.replacement = replacement;
+ replaceList += cmd;
+}
+
+void TextWriter::move(int pos, int length, int to)
+{
+ Q_ASSERT(!hasOverlap(pos, length));
+
+ Move cmd;
+ cmd.pos = pos;
+ cmd.length = length;
+ cmd.to = to;
+ moveList += cmd;
+}
+
+void TextWriter::doReplace(const Replace &replace)
+{
+ int diff = replace.replacement.size() - replace.length;
+ {
+ QMutableListIterator<Replace> i(replaceList);
+ while (i.hasNext()) {
+ Replace &c = i.next();
+ if (replace.pos < c.pos)
+ c.pos += diff;
+ else if (replace.pos + replace.length < c.pos + c.length)
+ c.length += diff;
+ }
+ }
+ {
+ QMutableListIterator<Move> i(moveList);
+ while (i.hasNext()) {
+ Move &c = i.next();
+ if (replace.pos < c.pos)
+ c.pos += diff;
+ else if (replace.pos + replace.length < c.pos + c.length)
+ c.length += diff;
+
+ if (replace.pos < c.to)
+ c.to += diff;
+ }
+ }
+
+ if (string) {
+ string->replace(replace.pos, replace.length, replace.replacement);
+ } else if (cursor) {
+ cursor->setPosition(replace.pos);
+ cursor->setPosition(replace.pos + replace.length, QTextCursor::KeepAnchor);
+ cursor->insertText(replace.replacement);
+ }
+}
+
+void TextWriter::doMove(const Move &move)
+{
+ QString text;
+ if (string) {
+ text = string->mid(move.pos, move.length);
+ } else if (cursor) {
+ cursor->setPosition(move.pos);
+ cursor->setPosition(move.pos + move.length, QTextCursor::KeepAnchor);
+ text = cursor->selectedText();
+ }
+
+ Replace cut;
+ cut.pos = move.pos;
+ cut.length = move.length;
+ Replace paste;
+ paste.pos = move.to;
+ paste.length = 0;
+ paste.replacement = text;
+
+ replaceList.append(cut);
+ replaceList.append(paste);
+
+ Replace cmd;
+ while (!replaceList.isEmpty()) {
+ cmd = replaceList.first();
+ replaceList.removeFirst();
+ doReplace(cmd);
+ }
+}
+
+void TextWriter::write(QString *s)
+{
+ string = s;
+ write_helper();
+ string = 0;
+}
+
+void TextWriter::write(QTextCursor *textCursor)
+{
+ cursor = textCursor;
+ write_helper();
+ cursor = 0;
+}
+
+void TextWriter::write_helper()
+{
+ if (cursor)
+ cursor->beginEditBlock();
+ {
+ Replace cmd;
+ while (!replaceList.isEmpty()) {
+ cmd = replaceList.first();
+ replaceList.removeFirst();
+ doReplace(cmd);
+ }
+ }
+ {
+ Move cmd;
+ while (!moveList.isEmpty()) {
+ cmd = moveList.first();
+ moveList.removeFirst();
+ doMove(cmd);
+ }
+ }
+ if (cursor)
+ cursor->endEditBlock();
+}
+
+QT_QML_END_NAMESPACE
diff --git a/src/qml/qml/rewriter/textwriter_p.h b/src/qml/qml/rewriter/textwriter_p.h
new file mode 100644
index 0000000000..94e2d08730
--- /dev/null
+++ b/src/qml/qml/rewriter/textwriter_p.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXTWRITER_H
+#define TEXTWRITER_H
+
+#include <private/qqmljsglobal_p.h>
+
+#include <QtCore/QString>
+#include <QtCore/QList>
+#include <QtGui/QTextCursor>
+
+QT_BEGIN_HEADER
+QT_QML_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+class TextWriter
+{
+ QString *string;
+ QTextCursor *cursor;
+
+ struct Replace {
+ int pos;
+ int length;
+ QString replacement;
+ };
+
+ QList<Replace> replaceList;
+
+ struct Move {
+ int pos;
+ int length;
+ int to;
+ };
+
+ QList<Move> moveList;
+
+ bool hasOverlap(int pos, int length);
+ bool hasMoveInto(int pos, int length);
+
+ void doReplace(const Replace &replace);
+ void doMove(const Move &move);
+
+ void write_helper();
+
+public:
+ TextWriter();
+
+ void replace(int pos, int length, const QString &replacement);
+ void move(int pos, int length, int to);
+
+ void write(QString *s);
+ void write(QTextCursor *textCursor);
+
+};
+
+} // end of namespace QQmlJS
+
+QT_QML_END_NAMESPACE
+QT_END_HEADER
+
+#endif // TEXTWRITER_H
diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp
new file mode 100644
index 0000000000..4fd84945fc
--- /dev/null
+++ b/src/qml/qml/v4/qv4bindings.cpp
@@ -0,0 +1,1615 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// #define REGISTER_CLEANUP_DEBUG
+
+#include "qv4bindings_p.h"
+#include "qv4program_p.h"
+#include "qv4compiler_p.h"
+#include "qv4compiler_p_p.h"
+
+#include <private/qqmlaccessors_p.h>
+#include <private/qqmlprofilerservice_p.h>
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmltrace_p.h>
+#include <private/qqmlstringconverters_p.h>
+
+#include <QtQml/qqmlinfo.h>
+#include <QtCore/qnumeric.h>
+#include <QtCore/qmath.h>
+#include <math.h> // ::fmod
+
+QT_BEGIN_NAMESPACE
+
+using namespace QQmlJS;
+
+namespace {
+struct Register {
+ typedef QQmlRegisterType Type;
+
+ void setUndefined() { dataType = UndefinedType; }
+ void setNaN() { setqreal(qSNaN()); }
+ bool isUndefined() const { return dataType == UndefinedType; }
+
+ void setQObject(QObject *o) { qobjectValue = o; dataType = QObjectStarType; }
+ QObject *getQObject() const { return qobjectValue; }
+
+ void setqreal(qreal v) { qrealValue = v; dataType = QRealType; }
+ qreal getqreal() const { return qrealValue; }
+ qreal &getqrealref() { return qrealValue; }
+
+ void setint(int v) { intValue = v; dataType = IntType; }
+ int getint() const { return intValue; }
+ int &getintref() { return intValue; }
+
+ void setbool(bool v) { boolValue = v; dataType = BoolType; }
+ bool getbool() const { return boolValue; }
+ bool &getboolref() { return boolValue; }
+
+ QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); }
+ QString *getstringptr() { return (QString *)typeDataPtr(); }
+ QUrl *geturlptr() { return (QUrl *)typeDataPtr(); }
+ QColor *getcolorptr() { return (QColor *)typeDataPtr(); }
+ const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); }
+ const QString *getstringptr() const { return (QString *)typeDataPtr(); }
+ const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); }
+ const QColor *getcolorptr() const { return (QColor *)typeDataPtr(); }
+
+ void *typeDataPtr() { return (void *)&data; }
+ void *typeMemory() { return (void *)data; }
+ const void *typeDataPtr() const { return (void *)&data; }
+ const void *typeMemory() const { return (void *)data; }
+
+ Type gettype() const { return dataType; }
+ void settype(Type t) { dataType = t; }
+
+ Type dataType; // Type of data
+ union {
+ QObject *qobjectValue;
+ qreal qrealValue;
+ int intValue;
+ bool boolValue;
+ void *data[sizeof(QVariant)];
+ qint64 q_for_alignment_1;
+ double q_for_alignment_2;
+ };
+
+ inline void cleanup();
+ inline void cleanupString();
+ inline void cleanupUrl();
+ inline void cleanupColor();
+ inline void cleanupVariant();
+
+ inline void copy(const Register &other);
+ inline void init(Type type);
+#ifdef REGISTER_CLEANUP_DEBUG
+ Register() {
+ type = 0;
+ }
+
+ ~Register() {
+ if (dataType >= FirstCleanupType)
+ qWarning("Register leaked of type %d", dataType);
+ }
+#endif
+};
+
+void Register::cleanup()
+{
+ if (dataType >= FirstCleanupType) {
+ if (dataType == QStringType) {
+ getstringptr()->~QString();
+ } else if (dataType == QUrlType) {
+ geturlptr()->~QUrl();
+ } else if (dataType == QColorType) {
+ getcolorptr()->~QColor();
+ } else if (dataType == QVariantType) {
+ getvariantptr()->~QVariant();
+ }
+ }
+ setUndefined();
+}
+
+void Register::cleanupString()
+{
+ getstringptr()->~QString();
+ setUndefined();
+}
+
+void Register::cleanupUrl()
+{
+ geturlptr()->~QUrl();
+ setUndefined();
+}
+
+void Register::cleanupColor()
+{
+ getcolorptr()->~QColor();
+ setUndefined();
+}
+
+void Register::cleanupVariant()
+{
+ getvariantptr()->~QVariant();
+ setUndefined();
+}
+
+void Register::copy(const Register &other)
+{
+ *this = other;
+ if (other.dataType >= FirstCleanupType) {
+ if (other.dataType == QStringType)
+ new (getstringptr()) QString(*other.getstringptr());
+ else if (other.dataType == QUrlType)
+ new (geturlptr()) QUrl(*other.geturlptr());
+ else if (other.dataType == QColorType)
+ new (getcolorptr()) QColor(*other.getcolorptr());
+ else if (other.dataType == QVariantType)
+ new (getvariantptr()) QVariant(*other.getvariantptr());
+ }
+}
+
+void Register::init(Type type)
+{
+ dataType = type;
+ if (dataType >= FirstCleanupType) {
+ if (dataType == QStringType)
+ new (getstringptr()) QString();
+ else if (dataType == QUrlType)
+ new (geturlptr()) QUrl();
+ else if (dataType == QColorType)
+ new (getcolorptr()) QColor();
+ else if (dataType == QVariantType)
+ new (getvariantptr()) QVariant();
+ }
+}
+
+} // end of anonymous namespace
+
+QV4Bindings::QV4Bindings(const char *programData,
+ QQmlContextData *context,
+ QQmlRefCount *ref)
+: subscriptions(0), program(0), dataRef(0), bindings(0)
+{
+ program = (QV4Program *)programData;
+ dataRef = ref;
+ if (dataRef) dataRef->addref();
+
+ if (program) {
+ subscriptions = new Subscription[program->subscriptions];
+ bindings = new Binding[program->bindings];
+
+ QQmlAbstractExpression::setContext(context);
+ }
+}
+
+QV4Bindings::~QV4Bindings()
+{
+ delete [] bindings;
+ delete [] subscriptions; subscriptions = 0;
+ if (dataRef) dataRef->release();
+}
+
+QQmlAbstractBinding *QV4Bindings::configBinding(int index, QObject *target,
+ QObject *scope, int property,
+ int line, int column)
+{
+ Binding *rv = bindings + index;
+
+ rv->index = index;
+ rv->property = property;
+ rv->target = target;
+ rv->scope = scope;
+ rv->line = line;
+ rv->column = column;
+ rv->parent = this;
+
+ addref(); // This is decremented in Binding::destroy()
+
+ return rv;
+}
+
+void QV4Bindings::Binding::setEnabled(bool e, QQmlPropertyPrivate::WriteFlags flags)
+{
+ if (enabled != e) {
+ enabled = e;
+
+ if (e) update(flags);
+ }
+}
+
+void QV4Bindings::Binding::update(QQmlPropertyPrivate::WriteFlags flags)
+{
+ parent->run(this, flags);
+}
+
+void QV4Bindings::Binding::destroy()
+{
+ enabled = false;
+ removeFromObject();
+ clear();
+ removeError();
+ parent->release();
+}
+
+int QV4Bindings::Binding::propertyIndex() const
+{
+ //mask out the type information set for value types
+ return property & 0xFF00FFFF;
+}
+
+QObject *QV4Bindings::Binding::object() const
+{
+ return target;
+}
+
+void QV4Bindings::Subscription::subscriptionCallback(QQmlNotifierEndpoint *e)
+{
+ Subscription *s = static_cast<Subscription *>(e);
+ s->bindings->subscriptionNotify(s->method);
+}
+
+void QV4Bindings::subscriptionNotify(int id)
+{
+ QV4Program::BindingReferenceList *list = program->signalTable(id);
+
+ for (quint32 ii = 0; ii < list->count; ++ii) {
+ QV4Program::BindingReference *bindingRef = list->bindings + ii;
+
+ Binding *binding = bindings + bindingRef->binding;
+
+ if (binding->executedBlocks & bindingRef->blockMask) {
+ run(binding, QQmlPropertyPrivate::DontRemoveBinding);
+ }
+ }
+}
+
+void QV4Bindings::run(Binding *binding, QQmlPropertyPrivate::WriteFlags flags)
+{
+ if (!binding->enabled)
+ return;
+
+ QQmlContextData *context = QQmlAbstractExpression::context();
+ if (!context || !context->isValid())
+ return;
+
+ QQmlTrace trace("V4 Binding Update");
+ trace.addDetail("URL", context->url);
+ trace.addDetail("Line", binding->line);
+ trace.addDetail("Column", binding->column);
+
+ QQmlBindingProfiler prof(context->urlString, binding->line, binding->column);
+
+ if (binding->updating) {
+ QString name;
+ if (binding->property & 0xFFFF0000) {
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
+
+ QQmlValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
+ Q_ASSERT(vt);
+
+ name = QLatin1String(binding->target->metaObject()->property(binding->property & 0xFFFF).name());
+ name.append(QLatin1String("."));
+ name.append(QLatin1String(vt->metaObject()->property(binding->property >> 24).name()));
+ } else {
+ name = QLatin1String(binding->target->metaObject()->property(binding->property).name());
+ }
+ qmlInfo(binding->target) << tr("Binding loop detected for property \"%1\"").arg(name);
+ return;
+ }
+
+ binding->updating = true;
+ if (binding->property & 0xFFFF0000) {
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
+
+ QQmlValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
+ Q_ASSERT(vt);
+ vt->read(binding->target, binding->property & 0xFFFF);
+
+ QObject *target = vt;
+ run(binding->index, binding->executedBlocks, context, binding, binding->scope, target, flags);
+
+ vt->write(binding->target, binding->property & 0xFFFF, flags);
+ } else {
+ run(binding->index, binding->executedBlocks, context, binding, binding->scope, binding->target, flags);
+ }
+ binding->updating = false;
+}
+
+
+void QV4Bindings::unsubscribe(int subIndex)
+{
+ Subscription *sub = (subscriptions + subIndex);
+ sub->disconnect();
+}
+
+void QV4Bindings::subscribeId(QQmlContextData *p, int idIndex, int subIndex)
+{
+ unsubscribe(subIndex);
+
+ if (p->idValues[idIndex]) {
+ Subscription *sub = (subscriptions + subIndex);
+ sub->bindings = this;
+ sub->method = subIndex;
+ sub->connect(&p->idValues[idIndex].bindings);
+ }
+}
+
+void QV4Bindings::subscribe(QObject *o, int notifyIndex, int subIndex)
+{
+ Subscription *sub = (subscriptions + subIndex);
+ if (sub->isConnected(o, notifyIndex))
+ return;
+ sub->bindings = this;
+ sub->method = subIndex;
+ if (o)
+ sub->connect(o, notifyIndex);
+ else
+ sub->disconnect();
+}
+
+// Conversion functions - these MUST match the QtScript expression path
+inline static qreal toReal(Register *reg, int type, bool *ok = 0)
+{
+ if (ok) *ok = true;
+
+ if (type == QMetaType::QReal) {
+ return reg->getqreal();
+ } else if (type == qMetaTypeId<QVariant>()) {
+ return reg->getvariantptr()->toReal();
+ } else {
+ if (ok) *ok = false;
+ return 0;
+ }
+}
+
+inline static QString toString(Register *reg, int type, bool *ok = 0)
+{
+ if (ok) *ok = true;
+
+ if (type == QMetaType::QReal) {
+ return QString::number(reg->getqreal());
+ } else if (type == QMetaType::Int) {
+ return QString::number(reg->getint());
+ } else if (type == qMetaTypeId<QVariant>()) {
+ return reg->getvariantptr()->toString();
+ } else if (type == QMetaType::QString) {
+ return *reg->getstringptr();
+ } else {
+ if (ok) *ok = false;
+ return QString();
+ }
+}
+
+inline static bool toBool(Register *reg, int type, bool *ok = 0)
+{
+ if (ok) *ok = true;
+
+ if (type == QMetaType::Bool) {
+ return reg->getbool();
+ } else if (type == qMetaTypeId<QVariant>()) {
+ return reg->getvariantptr()->toBool();
+ } else {
+ if (ok) *ok = false;
+ return false;
+ }
+}
+
+inline static QUrl toUrl(Register *reg, int type, QQmlContextData *context, bool *ok = 0)
+{
+ if (ok) *ok = true;
+
+ QUrl base;
+ if (type == qMetaTypeId<QVariant>()) {
+ QVariant *var = reg->getvariantptr();
+ int vt = var->type();
+ if (vt == QVariant::Url) {
+ base = var->toUrl();
+ } else if (vt == QVariant::ByteArray) {
+ // Preserve any valid percent-encoded octets supplied by the source
+ base.setEncodedUrl(var->toByteArray(), QUrl::TolerantMode);
+ } else if (vt == QVariant::String) {
+ base.setEncodedUrl(var->toString().toUtf8(), QUrl::TolerantMode);
+ } else {
+ if (ok) *ok = false;
+ return QUrl();
+ }
+ } else if (type == QMetaType::QString) {
+ base.setEncodedUrl(reg->getstringptr()->toUtf8(), QUrl::TolerantMode);
+ } else {
+ if (ok) *ok = false;
+ return QUrl();
+ }
+
+ if (!base.isEmpty() && base.isRelative())
+ return context->url.resolved(base);
+ else
+ return base;
+}
+
+static bool testCompareVariants(const QVariant &qtscriptRaw, const QVariant &v4)
+{
+ QVariant qtscript = qtscriptRaw;
+
+ if (qtscript.userType() == v4.userType()) {
+ } else if (qtscript.canConvert((QVariant::Type)v4.userType())) {
+ qtscript.convert((QVariant::Type)v4.userType());
+ } else if (qtscript.userType() == QVariant::Invalid && v4.userType() == QMetaType::QObjectStar) {
+ qtscript = qVariantFromValue<QObject *>(0);
+ } else {
+ return false;
+ }
+
+ int type = qtscript.userType();
+
+ if (type == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
+ return QQmlMetaType::QQuickAnchorLineCompare(qtscript.constData(), v4.constData());
+ } else if (type == QMetaType::Double) {
+
+ double la = qvariant_cast<double>(qtscript);
+ double lr = qvariant_cast<double>(v4);
+
+ return la == lr || (qIsNaN(la) && qIsNaN(lr));
+
+ } else if (type == QMetaType::Float) {
+
+ float la = qvariant_cast<float>(qtscript);
+ float lr = qvariant_cast<float>(v4);
+
+ return la == lr || (qIsNaN(la) && qIsNaN(lr));
+
+ } else {
+ return qtscript == v4;
+ }
+}
+
+QByteArray testResultToString(const QVariant &result, bool undefined)
+{
+ if (undefined) {
+ return "undefined";
+ } else {
+ QString rv;
+ QDebug d(&rv);
+ d << result;
+ return rv.toUtf8();
+ }
+}
+
+static void testBindingResult(const QString &binding, int line, int column,
+ QQmlContextData *context, QObject *scope,
+ const Register &result, int resultType)
+{
+ QQmlExpression expression(context->asQQmlContext(), scope, binding);
+ bool isUndefined = false;
+ QVariant value = expression.evaluate(&isUndefined);
+
+ bool iserror = false;
+ QByteArray qtscriptResult;
+ QByteArray v4Result;
+
+ if (expression.hasError()) {
+ iserror = true;
+ qtscriptResult = "exception";
+ } else {
+ qtscriptResult = testResultToString(value, isUndefined);
+ }
+
+ if (isUndefined && result.isUndefined()) {
+ return;
+ } else if(isUndefined != result.isUndefined()) {
+ iserror = true;
+ }
+
+ QVariant v4value;
+ if (!result.isUndefined()) {
+ switch (resultType) {
+ case QMetaType::QString:
+ v4value = *result.getstringptr();
+ break;
+ case QMetaType::QUrl:
+ v4value = *result.geturlptr();
+ break;
+ case QMetaType::QObjectStar:
+ v4value = qVariantFromValue<QObject *>(result.getQObject());
+ break;
+ case QMetaType::Bool:
+ v4value = result.getbool();
+ break;
+ case QMetaType::Int:
+ v4value = result.getint();
+ break;
+ case QMetaType::QReal:
+ v4value = result.getqreal();
+ break;
+ default:
+ if (resultType == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
+ v4value = QVariant(QQmlMetaType::QQuickAnchorLineMetaTypeId(), result.typeDataPtr());
+ } else {
+ iserror = true;
+ v4Result = "Unknown V4 type";
+ }
+ }
+ }
+ if (v4Result.isEmpty())
+ v4Result = testResultToString(v4value, result.isUndefined());
+
+ if (!testCompareVariants(value, v4value))
+ iserror = true;
+
+ if (iserror) {
+ qWarning().nospace() << "QV4: Optimization error @" << context->url.toString().toUtf8().constData() << ":" << line << ":" << column;
+
+ qWarning().nospace() << " Binding: " << binding;
+ qWarning().nospace() << " QtScript: " << qtscriptResult.constData();
+ qWarning().nospace() << " V4: " << v4Result.constData();
+ }
+}
+
+static void testBindingException(const QString &binding, int line, int column,
+ QQmlContextData *context, QObject *scope)
+{
+ QQmlExpression expression(context->asQQmlContext(), scope, binding);
+ bool isUndefined = false;
+ QVariant value = expression.evaluate(&isUndefined);
+
+ if (!expression.hasError()) {
+ QByteArray qtscriptResult = testResultToString(value, isUndefined);
+ qWarning().nospace() << "QV4: Optimization error @" << context->url.toString().toUtf8().constData() << ":" << line << ":" << column;
+ qWarning().nospace() << " Binding: " << binding;
+ qWarning().nospace() << " QtScript: " << qtscriptResult.constData();
+ qWarning().nospace() << " V4: exception";
+ }
+}
+
+static void throwException(int id, QQmlDelayedError *error,
+ QV4Program *program, QQmlContextData *context,
+ const QString &description = QString())
+{
+ error->error.setUrl(context->url);
+ if (description.isEmpty())
+ error->error.setDescription(QLatin1String("TypeError: Result of expression is not an object"));
+ else
+ error->error.setDescription(description);
+ if (id != 0xFF) {
+ quint64 e = *((quint64 *)(program->data() + program->exceptionDataOffset) + id);
+ error->error.setLine((e >> 32) & 0xFFFFFFFF);
+ error->error.setColumn(e & 0xFFFFFFFF);
+ } else {
+ error->error.setLine(-1);
+ error->error.setColumn(-1);
+ }
+ if (!context->engine || !error->addError(QQmlEnginePrivate::get(context->engine)))
+ QQmlEnginePrivate::warning(context->engine, error->error);
+}
+
+const qreal QV4Bindings::D32 = 4294967296.0;
+
+qint32 QV4Bindings::toInt32(qreal n)
+{
+ if (qIsNaN(n) || qIsInf(n) || (n == 0))
+ return 0;
+
+ double sign = (n < 0) ? -1.0 : 1.0;
+ qreal abs_n = fabs(n);
+
+ n = ::fmod(sign * ::floor(abs_n), D32);
+ const double D31 = D32 / 2.0;
+
+ if (sign == -1 && n < -D31)
+ n += D32;
+
+ else if (sign != -1 && n >= D31)
+ n -= D32;
+
+ return qint32 (n);
+}
+
+inline quint32 QV4Bindings::toUint32(qreal n)
+{
+ if (qIsNaN(n) || qIsInf(n) || (n == 0))
+ return 0;
+
+ double sign = (n < 0) ? -1.0 : 1.0;
+ qreal abs_n = fabs(n);
+
+ n = ::fmod(sign * ::floor(abs_n), D32);
+
+ if (n < 0)
+ n += D32;
+
+ return quint32 (n);
+}
+
+#define THROW_EXCEPTION_STR(id, str) { \
+ if (testBinding) testBindingException(*testBindingSource, bindingLine, bindingColumn, context, scope); \
+ throwException((id), error, program, context, (str)); \
+ goto exceptionExit; \
+}
+
+#define THROW_EXCEPTION(id) THROW_EXCEPTION_STR(id, QString())
+
+#define MARK_REGISTER(reg) cleanupRegisterMask |= (1 << (reg))
+#define MARK_CLEAN_REGISTER(reg) cleanupRegisterMask &= ~(1 << (reg))
+
+#define STRING_REGISTER(reg) { \
+ registers[(reg)].settype(QStringType); \
+ MARK_REGISTER(reg); \
+}
+
+#define URL_REGISTER(reg) { \
+ registers[(reg)].settype(QUrlType); \
+ MARK_REGISTER(reg); \
+}
+
+#define COLOR_REGISTER(reg) { \
+ registers[(reg)].settype(QColorType); \
+ MARK_REGISTER(reg); \
+}
+
+#define VARIANT_REGISTER(reg) { \
+ registers[(reg)].settype(QVariantType); \
+ MARK_REGISTER(reg); \
+}
+
+#ifdef QML_THREADED_INTERPRETER
+void **QV4Bindings::getDecodeInstrTable()
+{
+ static void **decode_instr;
+ if (!decode_instr) {
+ QV4Bindings *dummy = new QV4Bindings(0, 0, 0);
+ quint32 executedBlocks = 0;
+ dummy->run(0, executedBlocks, 0, 0, 0, 0,
+ QQmlPropertyPrivate::BypassInterceptor,
+ &decode_instr);
+ dummy->release();
+ }
+ return decode_instr;
+}
+#endif
+
+void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
+ QQmlContextData *context, QQmlDelayedError *error,
+ QObject *scope, QObject *output,
+ QQmlPropertyPrivate::WriteFlags storeFlags
+#ifdef QML_THREADED_INTERPRETER
+ ,void ***table
+#endif
+ )
+{
+#ifdef QML_THREADED_INTERPRETER
+ if (table) {
+ static void *decode_instr[] = {
+ FOR_EACH_V4_INSTR(QML_V4_INSTR_ADDR)
+ };
+
+ *table = decode_instr;
+ return;
+ }
+#endif
+
+
+ error->removeError();
+
+ Register registers[32];
+ quint32 cleanupRegisterMask = 0;
+
+ executedBlocks = 0;
+
+ const char *code = program->instructions();
+ code += instrIndex * QML_V4_INSTR_SIZE(Jump, jump);
+ const V4Instr *instr = reinterpret_cast<const V4Instr *>(code);
+
+ const char *data = program->data();
+
+ QString *testBindingSource = 0;
+ bool testBinding = false;
+ int bindingLine = 0;
+ int bindingColumn = 0;
+
+#ifdef QML_THREADED_INTERPRETER
+ goto *instr->common.code;
+#else
+ for (;;) {
+ switch (instr->common.type) {
+#endif
+
+ QML_V4_BEGIN_INSTR(Noop, common)
+ QML_V4_END_INSTR(Noop, common)
+
+ QML_V4_BEGIN_INSTR(BindingId, id)
+ bindingLine = instr->id.line;
+ bindingColumn = instr->id.column;
+ QML_V4_END_INSTR(BindingId, id)
+
+ QML_V4_BEGIN_INSTR(SubscribeId, subscribeop)
+ subscribeId(context, instr->subscribeop.index, instr->subscribeop.offset);
+ QML_V4_END_INSTR(SubscribeId, subscribeop)
+
+ QML_V4_BEGIN_INSTR(Subscribe, subscribeop)
+ {
+ QObject *o = 0;
+ const Register &object = registers[instr->subscribeop.reg];
+ if (!object.isUndefined()) o = object.getQObject();
+ subscribe(o, instr->subscribeop.index, instr->subscribeop.offset);
+ }
+ QML_V4_END_INSTR(Subscribe, subscribeop)
+
+ QML_V4_BEGIN_INSTR(FetchAndSubscribe, fetchAndSubscribe)
+ {
+ Register &reg = registers[instr->fetchAndSubscribe.reg];
+
+ if (reg.isUndefined())
+ THROW_EXCEPTION(instr->fetchAndSubscribe.exceptionId);
+
+ QObject *object = reg.getQObject();
+ if (!object) {
+ reg.setUndefined();
+ } else {
+ int subIdx = instr->fetchAndSubscribe.subscription;
+ Subscription *sub = 0;
+ if (subIdx != -1) {
+ sub = (subscriptions + subIdx);
+ sub->bindings = this;
+ sub->method = subIdx;
+ }
+ reg.init((Register::Type)instr->fetchAndSubscribe.valueType);
+ if (instr->fetchAndSubscribe.valueType >= FirstCleanupType)
+ MARK_REGISTER(instr->fetchAndSubscribe.reg);
+ QQmlAccessors *accessors = instr->fetchAndSubscribe.property.accessors;
+ accessors->read(object, instr->fetchAndSubscribe.property.accessorData,
+ reg.typeDataPtr());
+
+ if (accessors->notifier) {
+ QQmlNotifier *notifier = 0;
+ accessors->notifier(object, instr->fetchAndSubscribe.property.accessorData, &notifier);
+ if (notifier) sub->connect(notifier);
+ } else if (instr->fetchAndSubscribe.property.notifyIndex != -1) {
+ sub->connect(object, instr->fetchAndSubscribe.property.notifyIndex);
+ }
+ }
+ }
+ QML_V4_END_INSTR(FetchAndSubscribe, fetchAndSubscribe)
+
+ QML_V4_BEGIN_INSTR(LoadId, load)
+ registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
+ QML_V4_END_INSTR(LoadId, load)
+
+ QML_V4_BEGIN_INSTR(LoadScope, load)
+ registers[instr->load.reg].setQObject(scope);
+ QML_V4_END_INSTR(LoadScope, load)
+
+ QML_V4_BEGIN_INSTR(LoadRoot, load)
+ registers[instr->load.reg].setQObject(context->contextObject);
+ QML_V4_END_INSTR(LoadRoot, load)
+
+ QML_V4_BEGIN_INSTR(LoadAttached, attached)
+ {
+ const Register &input = registers[instr->attached.reg];
+ Register &output = registers[instr->attached.output];
+ if (input.isUndefined())
+ THROW_EXCEPTION(instr->attached.exceptionId);
+
+ QObject *object = registers[instr->attached.reg].getQObject();
+ if (!object) {
+ output.setUndefined();
+ } else {
+ QObject *attached = qmlAttachedPropertiesObjectById(instr->attached.id, input.getQObject(), true);
+ Q_ASSERT(attached);
+ output.setQObject(attached);
+ }
+ }
+ QML_V4_END_INSTR(LoadAttached, attached)
+
+ QML_V4_BEGIN_INSTR(UnaryNot, unaryop)
+ {
+ registers[instr->unaryop.output].setbool(!registers[instr->unaryop.src].getbool());
+ }
+ QML_V4_END_INSTR(UnaryNot, unaryop)
+
+ QML_V4_BEGIN_INSTR(UnaryMinusReal, unaryop)
+ {
+ registers[instr->unaryop.output].setqreal(-registers[instr->unaryop.src].getqreal());
+ }
+ QML_V4_END_INSTR(UnaryMinusReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(UnaryMinusInt, unaryop)
+ {
+ registers[instr->unaryop.output].setint(-registers[instr->unaryop.src].getint());
+ }
+ QML_V4_END_INSTR(UnaryMinusInt, unaryop)
+
+ QML_V4_BEGIN_INSTR(UnaryPlusReal, unaryop)
+ {
+ registers[instr->unaryop.output].setqreal(+registers[instr->unaryop.src].getqreal());
+ }
+ QML_V4_END_INSTR(UnaryPlusReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(UnaryPlusInt, unaryop)
+ {
+ registers[instr->unaryop.output].setint(+registers[instr->unaryop.src].getint());
+ }
+ QML_V4_END_INSTR(UnaryPlusInt, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertBoolToInt, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setint(src.getbool());
+ }
+ QML_V4_END_INSTR(ConvertBoolToInt, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertBoolToReal, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setqreal(src.getbool());
+ }
+ QML_V4_END_INSTR(ConvertBoolToReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertBoolToString, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ new (output.getstringptr()) QString(QLatin1String(src.getbool() ? "true" : "false"));
+ STRING_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertBoolToString, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertIntToBool, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setbool(src.getint());
+ }
+ QML_V4_END_INSTR(ConvertIntToBool, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertIntToReal, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setqreal(qreal(src.getint()));
+ }
+ QML_V4_END_INSTR(ConvertIntToReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertIntToString, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ new (output.getstringptr()) QString(QString::number(src.getint()));
+ STRING_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertIntToString, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertRealToBool, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setbool(src.getqreal() != 0);
+ }
+ QML_V4_END_INSTR(ConvertRealToBool, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertRealToInt, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setint(toInt32(src.getqreal()));
+ }
+ QML_V4_END_INSTR(ConvertRealToInt, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertRealToString, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ new (output.getstringptr()) QString(QString::number(src.getqreal()));
+ STRING_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertRealToString, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertStringToBool, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
+ // Ideally we should just call the methods in the QScript namespace directly.
+ QJSValue tmp(*src.getstringptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupString();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ output.setbool(tmp.toBool());
+ }
+ }
+ QML_V4_END_INSTR(ConvertStringToBool, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertStringToInt, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
+ // Ideally we should just call the methods in the QScript namespace directly.
+ QJSValue tmp(*src.getstringptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupString();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ output.setint(tmp.toInt());
+ }
+ }
+ QML_V4_END_INSTR(ConvertStringToInt, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertStringToReal, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
+ // Ideally we should just call the methods in the QScript namespace directly.
+ QJSValue tmp(*src.getstringptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupString();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ output.setqreal(tmp.toNumber());
+ }
+ }
+ QML_V4_END_INSTR(ConvertStringToReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertStringToUrl, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QString tmp(*src.getstringptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupString();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ QUrl *urlPtr = output.geturlptr();
+ new (urlPtr) QUrl();
+ urlPtr->setEncodedUrl(tmp.toUtf8(), QUrl::TolerantMode);
+
+ URL_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertStringToColor, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QString tmp(*src.getstringptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupString();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ QColor *colorPtr = output.getcolorptr();
+ new (colorPtr) QColor(QQmlStringConverters::colorFromString(tmp));
+
+ COLOR_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertUrlToBool, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QUrl tmp(*src.geturlptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupUrl();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ output.setbool(!tmp.isEmpty());
+ }
+ }
+ QML_V4_END_INSTR(ConvertUrlToBool, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertUrlToString, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QUrl tmp(*src.geturlptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupUrl();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ new (output.getstringptr()) QString(tmp.toString());
+ STRING_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertUrlToString, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertColorToBool, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ // for compatibility with color behavior in v8, always true
+ output.setbool(true);
+ }
+ }
+ QML_V4_END_INSTR(ConvertColorToBool, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertColorToString, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QColor tmp(*src.getcolorptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupColor();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ // to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
+ new (output.getstringptr()) QString(QVariant(tmp).toString());
+ STRING_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertColorToString, unaryop)
+
+ QML_V4_BEGIN_INSTR(ResolveUrl, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QUrl tmp(*src.geturlptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ *output.geturlptr() = context->resolvedUrl(tmp);
+ } else {
+ new (output.geturlptr()) QUrl(context->resolvedUrl(tmp));
+ URL_REGISTER(instr->unaryop.output);
+ }
+ }
+ }
+ QML_V4_END_INSTR(ResolveUrl, unaryop)
+
+ QML_V4_BEGIN_INSTR(MathSinReal, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setqreal(qSin(src.getqreal()));
+ }
+ QML_V4_END_INSTR(MathSinReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(MathCosReal, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setqreal(qCos(src.getqreal()));
+ }
+ QML_V4_END_INSTR(MathCosReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(MathRoundReal, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setint(qRound(src.getqreal()));
+ }
+ QML_V4_END_INSTR(MathRoundReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(MathFloorReal, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ if (src.isUndefined()) output.setUndefined();
+ else output.setint(qFloor(src.getqreal()));
+ }
+ QML_V4_END_INSTR(MathFloorReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(MathPIReal, unaryop)
+ {
+ static const qreal qmlPI = 2.0 * qAsin(1.0);
+ Register &output = registers[instr->unaryop.output];
+ output.setqreal(qmlPI);
+ }
+ QML_V4_END_INSTR(MathPIReal, unaryop)
+
+ QML_V4_BEGIN_INSTR(LoadReal, real_value)
+ registers[instr->real_value.reg].setqreal(instr->real_value.value);
+ QML_V4_END_INSTR(LoadReal, real_value)
+
+ QML_V4_BEGIN_INSTR(LoadInt, int_value)
+ registers[instr->int_value.reg].setint(instr->int_value.value);
+ QML_V4_END_INSTR(LoadInt, int_value)
+
+ QML_V4_BEGIN_INSTR(LoadBool, bool_value)
+ registers[instr->bool_value.reg].setbool(instr->bool_value.value);
+ QML_V4_END_INSTR(LoadBool, bool_value)
+
+ QML_V4_BEGIN_INSTR(LoadString, string_value)
+ {
+ Register &output = registers[instr->string_value.reg];
+ QChar *string = (QChar *)(data + instr->string_value.offset);
+ new (output.getstringptr()) QString(string, instr->string_value.length);
+ STRING_REGISTER(instr->string_value.reg);
+ }
+ QML_V4_END_INSTR(LoadString, string_value)
+
+ QML_V4_BEGIN_INSTR(EnableV4Test, string_value)
+ {
+ testBindingSource = new QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
+ testBinding = true;
+ }
+ QML_V4_END_INSTR(String, string_value)
+
+ QML_V4_BEGIN_INSTR(BitAndInt, binaryop)
+ {
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() &
+ registers[instr->binaryop.right].getint());
+ }
+ QML_V4_END_INSTR(BitAndInt, binaryop)
+
+ QML_V4_BEGIN_INSTR(BitOrInt, binaryop)
+ {
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() |
+ registers[instr->binaryop.right].getint());
+ }
+ QML_V4_END_INSTR(BitAndInt, binaryop)
+
+ QML_V4_BEGIN_INSTR(BitXorInt, binaryop)
+ {
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() ^
+ registers[instr->binaryop.right].getint());
+ }
+ QML_V4_END_INSTR(BitXorInt, binaryop)
+
+ QML_V4_BEGIN_INSTR(AddReal, binaryop)
+ {
+ registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() +
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(AddReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(AddString, binaryop)
+ {
+ QString &string = *registers[instr->binaryop.output].getstringptr();
+ if (instr->binaryop.output == instr->binaryop.left) {
+ string += registers[instr->binaryop.right].getstringptr();
+ } else {
+ string = *registers[instr->binaryop.left].getstringptr() +
+ *registers[instr->binaryop.right].getstringptr();
+ }
+ }
+ QML_V4_END_INSTR(AddString, binaryop)
+
+ QML_V4_BEGIN_INSTR(SubReal, binaryop)
+ {
+ registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() -
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(SubReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(MulReal, binaryop)
+ {
+ registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() *
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(MulReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(DivReal, binaryop)
+ {
+ registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() /
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(DivReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(ModReal, binaryop)
+ {
+ Register &target = registers[instr->binaryop.output];
+ const Register &left = registers[instr->binaryop.left];
+ const Register &right = registers[instr->binaryop.right];
+ if (QMetaType::QReal == QMetaType::Float)
+ target.setqreal(::fmodf(left.getqreal(), right.getqreal()));
+ else
+ target.setqreal(::fmod(left.getqreal(), right.getqreal()));
+ }
+ QML_V4_END_INSTR(ModInt, binaryop)
+
+ QML_V4_BEGIN_INSTR(LShiftInt, binaryop)
+ {
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() <<
+ registers[instr->binaryop.right].getint());
+ }
+ QML_V4_END_INSTR(LShiftInt, binaryop)
+
+ QML_V4_BEGIN_INSTR(RShiftInt, binaryop)
+ {
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() >>
+ registers[instr->binaryop.right].getint());
+ }
+ QML_V4_END_INSTR(RShiftInt, binaryop)
+
+ QML_V4_BEGIN_INSTR(URShiftInt, binaryop)
+ {
+ registers[instr->binaryop.output].setint((unsigned)registers[instr->binaryop.left].getint() >>
+ registers[instr->binaryop.right].getint());
+ }
+ QML_V4_END_INSTR(URShiftInt, binaryop)
+
+ QML_V4_BEGIN_INSTR(GtReal, binaryop)
+ {
+ registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() >
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(GtReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(LtReal, binaryop)
+ {
+ registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() <
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(LtReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(GeReal, binaryop)
+ {
+ registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() >=
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(GeReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(LeReal, binaryop)
+ {
+ registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() <=
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(LeReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(EqualReal, binaryop)
+ {
+ registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() ==
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(EqualReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(NotEqualReal, binaryop)
+ {
+ registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() !=
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(NotEqualReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(StrictEqualReal, binaryop)
+ {
+ registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() ==
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(StrictEqualReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(StrictNotEqualReal, binaryop)
+ {
+ registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() !=
+ registers[instr->binaryop.right].getqreal());
+ }
+ QML_V4_END_INSTR(StrictNotEqualReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(GtString, binaryop)
+ {
+ const QString &a = *registers[instr->binaryop.left].getstringptr();
+ const QString &b = *registers[instr->binaryop.right].getstringptr();
+ bool result = a > b;
+ if (instr->binaryop.left == instr->binaryop.output) {
+ registers[instr->binaryop.output].cleanupString();
+ MARK_CLEAN_REGISTER(instr->binaryop.output);
+ }
+ registers[instr->binaryop.output].setbool(result);
+ }
+ QML_V4_END_INSTR(GtString, binaryop)
+
+ QML_V4_BEGIN_INSTR(LtString, binaryop)
+ {
+ const QString &a = *registers[instr->binaryop.left].getstringptr();
+ const QString &b = *registers[instr->binaryop.right].getstringptr();
+ bool result = a < b;
+ if (instr->binaryop.left == instr->binaryop.output) {
+ registers[instr->binaryop.output].cleanupString();
+ MARK_CLEAN_REGISTER(instr->binaryop.output);
+ }
+ registers[instr->binaryop.output].setbool(result);
+ }
+ QML_V4_END_INSTR(LtString, binaryop)
+
+ QML_V4_BEGIN_INSTR(GeString, binaryop)
+ {
+ const QString &a = *registers[instr->binaryop.left].getstringptr();
+ const QString &b = *registers[instr->binaryop.right].getstringptr();
+ bool result = a >= b;
+ if (instr->binaryop.left == instr->binaryop.output) {
+ registers[instr->binaryop.output].cleanupString();
+ MARK_CLEAN_REGISTER(instr->binaryop.output);
+ }
+ registers[instr->binaryop.output].setbool(result);
+ }
+ QML_V4_END_INSTR(GeString, binaryop)
+
+ QML_V4_BEGIN_INSTR(LeString, binaryop)
+ {
+ const QString &a = *registers[instr->binaryop.left].getstringptr();
+ const QString &b = *registers[instr->binaryop.right].getstringptr();
+ bool result = a <= b;
+ if (instr->binaryop.left == instr->binaryop.output) {
+ registers[instr->binaryop.output].cleanupString();
+ MARK_CLEAN_REGISTER(instr->binaryop.output);
+ }
+ registers[instr->binaryop.output].setbool(result);
+ }
+ QML_V4_END_INSTR(LeString, binaryop)
+
+ QML_V4_BEGIN_INSTR(EqualString, binaryop)
+ {
+ const QString &a = *registers[instr->binaryop.left].getstringptr();
+ const QString &b = *registers[instr->binaryop.right].getstringptr();
+ bool result = a == b;
+ if (instr->binaryop.left == instr->binaryop.output) {
+ registers[instr->binaryop.output].cleanupString();
+ MARK_CLEAN_REGISTER(instr->binaryop.output);
+ }
+ registers[instr->binaryop.output].setbool(result);
+ }
+ QML_V4_END_INSTR(EqualString, binaryop)
+
+ QML_V4_BEGIN_INSTR(NotEqualString, binaryop)
+ {
+ const QString &a = *registers[instr->binaryop.left].getstringptr();
+ const QString &b = *registers[instr->binaryop.right].getstringptr();
+ bool result = a != b;
+ if (instr->binaryop.left == instr->binaryop.output) {
+ registers[instr->binaryop.output].cleanupString();
+ MARK_CLEAN_REGISTER(instr->binaryop.output);
+ }
+ registers[instr->binaryop.output].setbool(result);
+ }
+ QML_V4_END_INSTR(NotEqualString, binaryop)
+
+ QML_V4_BEGIN_INSTR(StrictEqualString, binaryop)
+ {
+ const QString &a = *registers[instr->binaryop.left].getstringptr();
+ const QString &b = *registers[instr->binaryop.right].getstringptr();
+ bool result = a == b;
+ if (instr->binaryop.left == instr->binaryop.output) {
+ registers[instr->binaryop.output].cleanupString();
+ MARK_CLEAN_REGISTER(instr->binaryop.output);
+ }
+ registers[instr->binaryop.output].setbool(result);
+ }
+ QML_V4_END_INSTR(StrictEqualString, binaryop)
+
+ QML_V4_BEGIN_INSTR(StrictNotEqualString, binaryop)
+ {
+ const QString &a = *registers[instr->binaryop.left].getstringptr();
+ const QString &b = *registers[instr->binaryop.right].getstringptr();
+ bool result = a != b;
+ if (instr->binaryop.left == instr->binaryop.output) {
+ registers[instr->binaryop.output].cleanupString();
+ MARK_CLEAN_REGISTER(instr->binaryop.output);
+ }
+ registers[instr->binaryop.output].setbool(result);
+ }
+ QML_V4_END_INSTR(StrictNotEqualString, binaryop)
+
+ QML_V4_BEGIN_INSTR(NewString, construct)
+ {
+ Register &output = registers[instr->construct.reg];
+ new (output.getstringptr()) QString;
+ STRING_REGISTER(instr->construct.reg);
+ }
+ QML_V4_END_INSTR(NewString, construct)
+
+ QML_V4_BEGIN_INSTR(NewUrl, construct)
+ {
+ Register &output = registers[instr->construct.reg];
+ new (output.geturlptr()) QUrl;
+ URL_REGISTER(instr->construct.reg);
+ }
+ QML_V4_END_INSTR(NewUrl, construct)
+
+ QML_V4_BEGIN_INSTR(Fetch, fetch)
+ {
+ Register &reg = registers[instr->fetch.reg];
+
+ if (reg.isUndefined())
+ THROW_EXCEPTION(instr->fetch.exceptionId);
+
+ QObject *object = reg.getQObject();
+ if (!object) {
+ THROW_EXCEPTION(instr->fetch.exceptionId);
+ } else {
+ reg.init((Register::Type)instr->fetch.valueType);
+ if (instr->fetch.valueType >= FirstCleanupType)
+ MARK_REGISTER(instr->fetch.reg);
+ void *argv[] = { reg.typeDataPtr(), 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
+ }
+ }
+ QML_V4_END_INSTR(Fetch, fetch)
+
+ QML_V4_BEGIN_INSTR(TestV4Store, storetest)
+ {
+ Register &data = registers[instr->storetest.reg];
+ testBindingResult(*testBindingSource, bindingLine, bindingColumn, context,
+ scope, data, instr->storetest.regType);
+ }
+ QML_V4_END_INSTR(TestV4Store, storetest)
+
+ QML_V4_BEGIN_INSTR(Store, store)
+ {
+ Register &data = registers[instr->store.reg];
+
+ if (data.isUndefined())
+ THROW_EXCEPTION_STR(instr->store.exceptionId, QLatin1String("Unable to assign undefined value"));
+
+ int status = -1;
+ void *argv[] = { data.typeDataPtr(), 0, &status, &storeFlags };
+ QMetaObject::metacall(output, QMetaObject::WriteProperty,
+ instr->store.index, argv);
+
+ goto programExit;
+ }
+ QML_V4_END_INSTR(Store, store)
+
+ QML_V4_BEGIN_INSTR(Copy, copy)
+ registers[instr->copy.reg].copy(registers[instr->copy.src]);
+ if (registers[instr->copy.reg].gettype() >= FirstCleanupType)
+ MARK_REGISTER(instr->copy.reg);
+ QML_V4_END_INSTR(Copy, copy)
+
+ QML_V4_BEGIN_INSTR(Jump, jump)
+ if (instr->jump.reg == -1 || !registers[instr->jump.reg].getbool())
+ code += instr->jump.count;
+ QML_V4_END_INSTR(Jump, jump)
+
+ QML_V4_BEGIN_INSTR(BranchTrue, branchop)
+ if (registers[instr->branchop.reg].getbool())
+ code += instr->branchop.offset;
+ QML_V4_END_INSTR(BranchTrue, branchop)
+
+ QML_V4_BEGIN_INSTR(BranchFalse, branchop)
+ if (! registers[instr->branchop.reg].getbool())
+ code += instr->branchop.offset;
+ QML_V4_END_INSTR(BranchFalse, branchop)
+
+ QML_V4_BEGIN_INSTR(Branch, branchop)
+ code += instr->branchop.offset;
+ QML_V4_END_INSTR(Branch, branchop)
+
+ QML_V4_BEGIN_INSTR(Block, blockop)
+ executedBlocks |= instr->blockop.block;
+ QML_V4_END_INSTR(Block, blockop)
+
+ // XXX not applicable in v8
+ QML_V4_BEGIN_INSTR(InitString, initstring)
+// if (!identifiers[instr->initstring.offset].identifier) {
+// quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
+// QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
+
+// QString str = QString::fromRawData(strdata, len);
+
+// // identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
+// }
+ QML_V4_END_INSTR(InitString, initstring)
+
+ QML_V4_BEGIN_INSTR(CleanupRegister, cleanup)
+ registers[instr->cleanup.reg].cleanup();
+ QML_V4_END_INSTR(CleanupRegister, cleanup)
+
+#ifdef QML_THREADED_INTERPRETER
+ // nothing to do
+#else
+ default:
+ qFatal("QV4: Unknown instruction %d encountered.", instr->common.type);
+ break;
+ } // switch
+
+ } // while
+#endif
+
+ Q_ASSERT(!"Unreachable code reached");
+
+programExit:
+exceptionExit:
+ delete testBindingSource;
+
+ int reg = 0;
+ while (cleanupRegisterMask) {
+ if (cleanupRegisterMask & 0x1)
+ registers[reg].cleanup();
+
+ reg++;
+ cleanupRegisterMask >>= 1;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4bindings_p.h b/src/qml/qml/v4/qv4bindings_p.h
new file mode 100644
index 0000000000..1824fa4ee9
--- /dev/null
+++ b/src/qml/qml/v4/qv4bindings_p.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4BINDINGS_P_H
+#define QV4BINDINGS_P_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 "private/qqmlexpression_p.h"
+#include "private/qqmlbinding_p.h"
+#include "private/qv4instruction_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+struct QV4Program;
+class QV4Bindings : public QQmlAbstractExpression,
+ public QQmlRefCount
+{
+ Q_DECLARE_TR_FUNCTIONS(QV4Bindings)
+public:
+ QV4Bindings(const char *program, QQmlContextData *context,
+ QQmlRefCount *);
+ virtual ~QV4Bindings();
+
+ QQmlAbstractBinding *configBinding(int index, QObject *target,
+ QObject *scope, int property,
+ int line, int column);
+
+#ifdef QML_THREADED_INTERPRETER
+ static void **getDecodeInstrTable();
+#endif
+
+private:
+ Q_DISABLE_COPY(QV4Bindings)
+
+ struct Binding : public QQmlAbstractBinding, public QQmlDelayedError {
+ Binding() : enabled(false), updating(0), property(0),
+ scope(0), target(0), executedBlocks(0), parent(0) {}
+
+ // Inherited from QQmlAbstractBinding
+ virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags flags);
+ virtual void update(QQmlPropertyPrivate::WriteFlags flags);
+ virtual void destroy();
+ virtual int propertyIndex() const;
+ virtual QObject *object() const;
+
+ int index:30;
+ bool enabled:1;
+ bool updating:1;
+ // Encoding of property is coreIndex | (propType << 16) | (valueTypeIndex << 24)
+ // propType and valueTypeIndex are only set if the property is a value type property
+ int property;
+ QObject *scope;
+ int line;
+ int column;
+ QObject *target;
+ quint32 executedBlocks;
+
+ QV4Bindings *parent;
+ };
+
+ class Subscription : public QQmlNotifierEndpoint
+ {
+ public:
+ Subscription() : bindings(0), method(-1) { callback = &subscriptionCallback; }
+ static void subscriptionCallback(QQmlNotifierEndpoint *e);
+ QV4Bindings *bindings;
+ int method;
+ };
+ friend class Subscription;
+
+ Subscription *subscriptions;
+
+ void subscriptionNotify(int);
+ void run(Binding *, QQmlPropertyPrivate::WriteFlags flags);
+
+ QV4Program *program;
+ QQmlRefCount *dataRef;
+ Binding *bindings;
+
+ void init();
+ void run(int instr, quint32 &executedBlocks, QQmlContextData *context,
+ QQmlDelayedError *error, QObject *scope, QObject *output,
+ QQmlPropertyPrivate::WriteFlags storeFlags
+#ifdef QML_THREADED_INTERPRETER
+ , void ***decode_instr = 0
+#endif
+ );
+
+
+ inline void unsubscribe(int subIndex);
+ inline void subscribeId(QQmlContextData *p, int idIndex, int subIndex);
+ inline void subscribe(QObject *o, int notifyIndex, int subIndex);
+
+ inline static qint32 toInt32(qreal n);
+ static const qreal D32;
+ static quint32 toUint32(qreal n);
+
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV4BINDINGS_P_H
+
diff --git a/src/qml/qml/v4/qv4compiler.cpp b/src/qml/qml/v4/qv4compiler.cpp
new file mode 100644
index 0000000000..f8fe3b4b57
--- /dev/null
+++ b/src/qml/qml/v4/qv4compiler.cpp
@@ -0,0 +1,1420 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4compiler_p.h"
+#include "qv4compiler_p_p.h"
+#include "qv4program_p.h"
+#include "qv4ir_p.h"
+#include "qv4irbuilder_p.h"
+
+#include <private/qqmlglobal_p.h>
+#include <private/qqmljsast_p.h>
+#include <private/qqmlaccessors_p.h>
+#include <private/qqmljsengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(bindingsDump, QML_BINDINGS_DUMP)
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableOptimizer, QML_DISABLE_OPTIMIZER)
+DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL)
+DEFINE_BOOL_CONFIG_OPTION(qmlVerboseCompiler, QML_VERBOSE_COMPILER)
+DEFINE_BOOL_CONFIG_OPTION(qmlBindingsTestEnv, QML_BINDINGS_TEST)
+
+static bool qmlBindingsTest = false;
+static bool qmlEnableV4 = true;
+
+using namespace QQmlJS;
+QV4CompilerPrivate::QV4CompilerPrivate()
+ : _function(0) , _block(0) , _discarded(false), registerCount(0)
+{
+}
+
+//
+// tracing
+//
+void QV4CompilerPrivate::trace(int line, int column)
+{
+ bytecode.clear();
+
+ this->currentReg = _function->tempCount;
+ this->registerCount = qMax(this->registerCount, this->currentReg);
+
+ foreach (IR::BasicBlock *bb, _function->basicBlocks) {
+ if (! bb->isTerminated() && (bb->index + 1) < _function->basicBlocks.size())
+ bb->JUMP(_function->basicBlocks.at(bb->index + 1));
+ }
+
+ QVector<IR::BasicBlock *> blocks;
+ trace(&blocks);
+ currentBlockMask = 0x00000001;
+
+
+ for (int i = 0; !_discarded && i < blocks.size(); ++i) {
+ IR::BasicBlock *block = blocks.at(i);
+ IR::BasicBlock *next = i + 1 < blocks.size() ? blocks.at(i + 1) : 0;
+ if (IR::Stmt *terminator = block->terminator()) {
+ if (IR::CJump *cj = terminator->asCJump()) {
+ if (cj->iffalse != next) {
+ IR::Jump *jump = _function->pool->New<IR::Jump>();
+ jump->init(cj->iffalse);
+ block->statements.append(jump);
+ }
+ } else if (IR::Jump *j = terminator->asJump()) {
+ if (j->target == next) {
+ block->statements.resize(block->statements.size() - 1);
+ }
+ }
+ }
+
+ block->offset = bytecode.size();
+
+ if (bytecode.isEmpty()) {
+ if (qmlBindingsTest || bindingsDump()) {
+ Instr::BindingId id;
+ id.column = column;
+ id.line = line;
+ gen(id);
+ }
+
+ if (qmlBindingsTest) {
+ QString str = expression->expression.asScript();
+ QByteArray strdata((const char *)str.constData(), str.length() * sizeof(QChar));
+ int offset = data.count();
+ data += strdata;
+
+ Instr::EnableV4Test test;
+ test.reg = 0;
+ test.offset = offset;
+ test.length = str.length();
+ gen(test);
+ }
+ }
+
+ bool usic = false;
+ int patchesCount = patches.count();
+ qSwap(usedSubscriptionIdsChanged, usic);
+
+ int blockopIndex = bytecode.size();
+ Instr::Block blockop;
+ blockop.block = currentBlockMask;
+ gen(blockop);
+
+ foreach (IR::Stmt *s, block->statements) {
+ if (! _discarded)
+ s->accept(this);
+ }
+
+ qSwap(usedSubscriptionIdsChanged, usic);
+
+ if (usic) {
+ if (currentBlockMask == 0x80000000) {
+ discard();
+ return;
+ }
+ currentBlockMask <<= 1;
+ } else if (! _discarded) {
+ const int adjust = bytecode.remove(blockopIndex);
+ // Correct patches
+ for (int ii = patchesCount; ii < patches.count(); ++ii)
+ patches[ii].offset -= adjust;
+ }
+ }
+
+#ifdef DEBUG_IR_STRUCTURE
+ IR::IRDump dump;
+ for (int i = 0; i < blocks.size(); ++i) {
+ dump.basicblock(blocks.at(i));
+ }
+#endif
+
+
+ if (! _discarded) {
+ // back patching
+ foreach (const Patch &patch, patches) {
+ V4Instr &instr = bytecode[patch.offset];
+ int size = V4Instr::size(instructionType(&instr));
+ instr.branchop.offset = patch.block->offset - patch.offset - size;
+ }
+
+ patches.clear();
+ }
+}
+
+void QV4CompilerPrivate::trace(QVector<IR::BasicBlock *> *blocks)
+{
+ for (int i = 0; i < _function->basicBlocks.size(); ++i) {
+ IR::BasicBlock *block = _function->basicBlocks.at(i);
+
+ while (! blocks->contains(block)) {
+ blocks->append(block);
+
+ if (IR::Stmt *terminator = block->terminator()) {
+ if (IR::CJump *cj = terminator->asCJump())
+ block = cj->iffalse;
+ else if (IR::Jump *j = terminator->asJump())
+ block = j->target;
+ }
+ }
+ }
+}
+
+void QV4CompilerPrivate::traceExpression(IR::Expr *e, quint8 r)
+{
+ if (!e) {
+ discard();
+ } else {
+ qSwap(currentReg, r);
+ e->accept(this);
+ qSwap(currentReg, r);
+ }
+}
+
+//
+// expressions
+//
+void QV4CompilerPrivate::visitConst(IR::Const *e)
+{
+ switch (e->type) {
+ case IR::BoolType: {
+ Instr::LoadBool i;
+ i.reg = currentReg;
+ i.value = e->value;
+ gen(i);
+ } break;
+
+ case IR::IntType: {
+ Instr::LoadInt i;
+ i.reg = currentReg;
+ i.value = e->value;
+ gen(i);
+ } break;
+
+ case IR::RealType: {
+ Instr::LoadReal i;
+ i.reg = currentReg;
+ i.value = e->value;
+ gen(i);
+ } break;
+
+ default:
+ if (qmlVerboseCompiler())
+ qWarning() << Q_FUNC_INFO << "unexpected type";
+ discard();
+ }
+}
+
+void QV4CompilerPrivate::visitString(IR::String *e)
+{
+ registerLiteralString(currentReg, e->value);
+}
+
+void QV4CompilerPrivate::visitName(IR::Name *e)
+{
+ if (e->base) {
+ // fetch the object and store it in reg.
+ traceExpression(e->base, currentReg);
+ } else {
+ _subscribeName.clear();
+ }
+
+ if (e->storage == IR::Name::RootStorage) {
+
+ Instr::LoadRoot instr;
+ instr.reg = currentReg;
+ gen(instr);
+
+ if (e->symbol == IR::Name::IdObject) {
+ // The ID is a reference to the root object
+ return;
+ }
+
+ } else if (e->storage == IR::Name::ScopeStorage) {
+
+ Instr::LoadScope instr;
+ instr.reg = currentReg;
+ gen(instr);
+
+ _subscribeName << contextName();
+
+ } else if (e->storage == IR::Name::IdStorage) {
+
+ Instr::LoadId instr;
+ instr.reg = currentReg;
+ instr.index = e->idObject->idIndex;
+ gen(instr);
+
+ _subscribeName << QLatin1String("$$$ID_") + *e->id;
+
+ if (blockNeedsSubscription(_subscribeName)) {
+ Instr::SubscribeId sub;
+ sub.reg = currentReg;
+ sub.offset = subscriptionIndex(_subscribeName);
+ sub.index = instr.index;
+ gen(sub);
+ }
+
+ return;
+ } else {
+ // No action needed
+ }
+
+ switch (e->symbol) {
+ case IR::Name::Unbound:
+ case IR::Name::IdObject:
+ case IR::Name::Slot:
+ case IR::Name::Object: {
+ Q_ASSERT(!"Unreachable");
+ discard();
+ } break;
+
+ case IR::Name::AttachType: {
+ _subscribeName << *e->id;
+
+ Instr::LoadAttached attached;
+ attached.output = currentReg;
+ attached.reg = currentReg;
+ attached.exceptionId = exceptionId(e->line, e->column);
+ if (e->declarativeType->attachedPropertiesId() == -1)
+ discard();
+ attached.id = e->declarativeType->attachedPropertiesId();
+ gen(attached);
+ } break;
+
+ case IR::Name::Property: {
+ _subscribeName << *e->id;
+
+ if (e->property->coreIndex == -1) {
+ QMetaProperty prop;
+ e->property->load(prop, QQmlEnginePrivate::get(engine));
+ }
+
+ const int propTy = e->property->propType;
+ QQmlRegisterType regType;
+
+ switch (propTy) {
+ case QMetaType::QReal:
+ regType = QRealType;
+ break;
+ case QMetaType::Bool:
+ regType = BoolType;
+ break;
+ case QMetaType::Int:
+ regType = IntType;
+ break;
+ case QMetaType::QString:
+ regType = QStringType;
+ break;
+ case QMetaType::QUrl:
+ regType = QUrlType;
+ break;
+ case QMetaType::QColor:
+ regType = QColorType;
+ break;
+
+ default:
+ if (propTy == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
+ regType = PODValueType;
+ } else if (QQmlMetaType::isQObject(propTy)) {
+ regType = QObjectStarType;
+ } else {
+ if (qmlVerboseCompiler())
+ qWarning() << "Discard unsupported property type:" << QMetaType::typeName(propTy);
+ discard(); // Unsupported type
+ return;
+ }
+
+ break;
+ } // switch
+
+ if (e->property->hasAccessors()) {
+ Instr::FetchAndSubscribe fetch;
+ fetch.reg = currentReg;
+ fetch.subscription = subscriptionIndex(_subscribeName);
+ fetch.exceptionId = exceptionId(e->line, e->column);
+ fetch.valueType = regType;
+ fetch.property = *e->property;
+ gen(fetch);
+ } else {
+ if (blockNeedsSubscription(_subscribeName) && e->property->notifyIndex != -1) {
+ Instr::Subscribe sub;
+ sub.reg = currentReg;
+ sub.offset = subscriptionIndex(_subscribeName);
+ sub.index = e->property->notifyIndex;
+ gen(sub);
+ }
+
+ Instr::Fetch fetch;
+ fetch.reg = currentReg;
+ fetch.index = e->property->coreIndex;
+ fetch.exceptionId = exceptionId(e->line, e->column);
+ fetch.valueType = regType;
+ gen(fetch);
+ }
+
+ } break;
+ } // switch
+}
+
+void QV4CompilerPrivate::visitTemp(IR::Temp *e)
+{
+ if (currentReg != e->index) {
+ Instr::Copy i;
+ i.reg = currentReg;
+ i.src = e->index;
+ gen(i);
+ }
+}
+
+void QV4CompilerPrivate::visitUnop(IR::Unop *e)
+{
+ quint8 src = currentReg;
+
+ if (IR::Temp *temp = e->expr->asTemp()) {
+ src = temp->index;
+ } else {
+ traceExpression(e->expr, src);
+ }
+
+ switch (e->op) {
+ case IR::OpInvalid:
+ Q_ASSERT(!"unreachable");
+ break;
+
+ case IR::OpIfTrue:
+ convertToBool(e->expr, src);
+ if (src != currentReg) {
+ Instr::Copy i;
+ i.reg = currentReg;
+ i.src = src;
+ gen(i);
+ }
+ break;
+
+ case IR::OpNot: {
+ Instr::UnaryNot i;
+ convertToBool(e->expr, src);
+ i.output = currentReg;
+ i.src = src;
+ gen(i);
+ } break;
+
+ case IR::OpUMinus:
+ if (e->expr->type == IR::RealType) {
+ Instr::UnaryMinusReal i;
+ i.output = currentReg;
+ i.src = src;
+ gen(i);
+ } else if (e->expr->type == IR::IntType) {
+ convertToReal(e->expr, currentReg);
+ Instr::UnaryMinusReal i;
+ i.output = currentReg;
+ i.src = src;
+ gen(i);
+ } else {
+ discard();
+ }
+ break;
+
+ case IR::OpUPlus:
+ if (e->expr->type == IR::RealType) {
+ Instr::UnaryPlusReal i;
+ i.output = currentReg;
+ i.src = src;
+ gen(i);
+ } else if (e->expr->type == IR::IntType) {
+ convertToReal(e->expr, currentReg);
+ Instr::UnaryPlusReal i;
+ i.output = currentReg;
+ i.src = src;
+ gen(i);
+ } else {
+ discard();
+ }
+ break;
+
+ case IR::OpCompl:
+ // TODO
+ discard();
+ break;
+
+ case IR::OpBitAnd:
+ case IR::OpBitOr:
+ case IR::OpBitXor:
+ case IR::OpAdd:
+ case IR::OpSub:
+ case IR::OpMul:
+ case IR::OpDiv:
+ case IR::OpMod:
+ case IR::OpLShift:
+ case IR::OpRShift:
+ case IR::OpURShift:
+ case IR::OpGt:
+ case IR::OpLt:
+ case IR::OpGe:
+ case IR::OpLe:
+ case IR::OpEqual:
+ case IR::OpNotEqual:
+ case IR::OpStrictEqual:
+ case IR::OpStrictNotEqual:
+ case IR::OpAnd:
+ case IR::OpOr:
+ Q_ASSERT(!"unreachable");
+ break;
+ } // switch
+}
+
+void QV4CompilerPrivate::convertToReal(IR::Expr *expr, int reg)
+{
+ if (expr->type == IR::RealType)
+ return;
+
+ switch (expr->type) {
+ case IR::BoolType: {
+ Instr::ConvertBoolToReal i;
+ i.output = i.src = reg;
+ gen(i);
+ } break;
+
+ case IR::IntType: {
+ Instr::ConvertIntToReal i;
+ i.output = i.src = reg;
+ gen(i);
+ } break;
+
+ case IR::RealType:
+ // nothing to do
+ return;
+
+ default:
+ discard();
+ break;
+ } // switch
+}
+
+void QV4CompilerPrivate::convertToInt(IR::Expr *expr, int reg)
+{
+ if (expr->type == IR::IntType)
+ return;
+
+ switch (expr->type) {
+ case IR::BoolType: {
+ Instr::ConvertBoolToInt i;
+ i.output = i.src = reg;
+ gen(i);
+ } break;
+
+ case IR::IntType:
+ // nothing to do
+ return;
+
+ case IR::RealType: {
+ Instr::ConvertRealToInt i;
+ i.output = i.src = reg;
+ gen(i);
+ } break;
+
+ default:
+ discard();
+ break;
+ } // switch
+}
+
+void QV4CompilerPrivate::convertToBool(IR::Expr *expr, int reg)
+{
+ if (expr->type == IR::BoolType)
+ return;
+
+ switch (expr->type) {
+ case IR::BoolType:
+ // nothing to do
+ break;
+
+ case IR::IntType: {
+ Instr::ConvertIntToBool i;
+ i.output = i.src = reg;
+ gen(i);
+ } break;
+
+ case IR::RealType: {
+ Instr::ConvertRealToBool i;
+ i.output = i.src = reg;
+ gen(i);
+ } return;
+
+ case IR::StringType: {
+ Instr::ConvertStringToBool i;
+ i.output = i.src = reg;
+ gen(i);
+ } return;
+
+ case IR::ColorType: {
+ Instr::ConvertColorToBool i;
+ i.output = i.src = reg;
+ gen(i);
+ } return;
+
+ default:
+ discard();
+ break;
+ } // switch
+}
+
+quint8 QV4CompilerPrivate::instructionOpcode(IR::Binop *e)
+{
+ switch (e->op) {
+ case IR::OpInvalid:
+ return V4Instr::Noop;
+
+ case IR::OpIfTrue:
+ case IR::OpNot:
+ case IR::OpUMinus:
+ case IR::OpUPlus:
+ case IR::OpCompl:
+ return V4Instr::Noop;
+
+ case IR::OpBitAnd:
+ return V4Instr::BitAndInt;
+
+ case IR::OpBitOr:
+ return V4Instr::BitOrInt;
+
+ case IR::OpBitXor:
+ return V4Instr::BitXorInt;
+
+ case IR::OpAdd:
+ if (e->type == IR::StringType)
+ return V4Instr::AddString;
+ return V4Instr::AddReal;
+
+ case IR::OpSub:
+ return V4Instr::SubReal;
+
+ case IR::OpMul:
+ return V4Instr::MulReal;
+
+ case IR::OpDiv:
+ return V4Instr::DivReal;
+
+ case IR::OpMod:
+ return V4Instr::ModReal;
+
+ case IR::OpLShift:
+ return V4Instr::LShiftInt;
+
+ case IR::OpRShift:
+ return V4Instr::RShiftInt;
+
+ case IR::OpURShift:
+ return V4Instr::URShiftInt;
+
+ case IR::OpGt:
+ if (e->left->type == IR::StringType)
+ return V4Instr::GtString;
+ return V4Instr::GtReal;
+
+ case IR::OpLt:
+ if (e->left->type == IR::StringType)
+ return V4Instr::LtString;
+ return V4Instr::LtReal;
+
+ case IR::OpGe:
+ if (e->left->type == IR::StringType)
+ return V4Instr::GeString;
+ return V4Instr::GeReal;
+
+ case IR::OpLe:
+ if (e->left->type == IR::StringType)
+ return V4Instr::LeString;
+ return V4Instr::LeReal;
+
+ case IR::OpEqual:
+ if (e->left->type == IR::StringType)
+ return V4Instr::EqualString;
+ return V4Instr::EqualReal;
+
+ case IR::OpNotEqual:
+ if (e->left->type == IR::StringType)
+ return V4Instr::NotEqualString;
+ return V4Instr::NotEqualReal;
+
+ case IR::OpStrictEqual:
+ if (e->left->type == IR::StringType)
+ return V4Instr::StrictEqualString;
+ return V4Instr::StrictEqualReal;
+
+ case IR::OpStrictNotEqual:
+ if (e->left->type == IR::StringType)
+ return V4Instr::StrictNotEqualString;
+ return V4Instr::StrictNotEqualReal;
+
+ case IR::OpAnd:
+ case IR::OpOr:
+ return V4Instr::Noop;
+
+ } // switch
+
+ return V4Instr::Noop;
+}
+
+void QV4CompilerPrivate::visitBinop(IR::Binop *e)
+{
+ int left = currentReg;
+ int right = currentReg + 1;
+
+ if (e->left->asTemp() && e->type != IR::StringType) // Not sure if the e->type != String test is needed
+ left = e->left->asTemp()->index;
+ else
+ traceExpression(e->left, left);
+
+ if (IR::Temp *t = e->right->asTemp())
+ right = t->index;
+ else
+ traceExpression(e->right, right);
+
+ if (e->left->type != e->right->type) {
+ if (qmlVerboseCompiler())
+ qWarning().nospace() << "invalid operands to binary operator " << IR::binaryOperator(e->op)
+ << "(`" << IR::binaryOperator(e->left->type)
+ << "' and `"
+ << IR::binaryOperator(e->right->type)
+ << "'";
+ discard();
+ return;
+ }
+
+ switch (e->op) {
+ case IR::OpInvalid:
+ discard();
+ break;
+
+ // unary
+ case IR::OpIfTrue:
+ case IR::OpNot:
+ case IR::OpUMinus:
+ case IR::OpUPlus:
+ case IR::OpCompl:
+ discard();
+ break;
+
+ case IR::OpBitAnd:
+ case IR::OpBitOr:
+ case IR::OpBitXor:
+ case IR::OpLShift:
+ case IR::OpRShift:
+ case IR::OpURShift:
+ convertToInt(e->left, left);
+ convertToInt(e->right, right);
+ break;
+
+ case IR::OpAdd:
+ if (e->type != IR::StringType) {
+ convertToReal(e->left, left);
+ convertToReal(e->right, right);
+ }
+ break;
+
+ case IR::OpSub:
+ case IR::OpMul:
+ case IR::OpDiv:
+ case IR::OpMod:
+ convertToReal(e->left, left);
+ convertToReal(e->right, right);
+ break;
+
+ case IR::OpGt:
+ case IR::OpLt:
+ case IR::OpGe:
+ case IR::OpLe:
+ case IR::OpEqual:
+ case IR::OpNotEqual:
+ case IR::OpStrictEqual:
+ case IR::OpStrictNotEqual:
+ if (e->left->type != IR::StringType) {
+ convertToReal(e->left, left);
+ convertToReal(e->right, right);
+ }
+ break;
+
+ case IR::OpAnd:
+ case IR::OpOr:
+ discard(); // ### unreachable
+ break;
+ } // switch
+
+ const quint8 opcode = instructionOpcode(e);
+ if (opcode != V4Instr::Noop) {
+ V4Instr instr;
+ instr.binaryop.output = currentReg;
+ instr.binaryop.left = left;
+ instr.binaryop.right = right;
+ gen(static_cast<V4Instr::Type>(opcode), instr);
+ }
+}
+
+void QV4CompilerPrivate::visitCall(IR::Call *call)
+{
+ if (IR::Name *name = call->base->asName()) {
+ IR::Expr *arg = call->onlyArgument();
+ if (arg != 0 && arg->type == IR::RealType) {
+ traceExpression(arg, currentReg);
+
+ switch (name->builtin) {
+ case IR::NoBuiltinSymbol:
+ break;
+
+ case IR::MathSinBultinFunction: {
+ Instr::MathSinReal i;
+ i.output = i.src = currentReg;
+ gen(i);
+ } return;
+
+ case IR::MathCosBultinFunction: {
+ Instr::MathCosReal i;
+ i.output = i.src = currentReg;
+ gen(i);
+ } return;
+
+ case IR::MathRoundBultinFunction: {
+ Instr::MathRoundReal i;
+ i.output = i.src = currentReg;
+ gen(i);
+ } return;
+
+ case IR::MathFloorBultinFunction: {
+ Instr::MathFloorReal i;
+ i.output = i.src = currentReg;
+ gen(i);
+ } return;
+
+ case IR::MathPIBuiltinConstant:
+ break;
+ } // switch
+ }
+ }
+
+ if (qmlVerboseCompiler())
+ qWarning() << "TODO:" << Q_FUNC_INFO << __LINE__;
+ discard();
+}
+
+
+//
+// statements
+//
+void QV4CompilerPrivate::visitExp(IR::Exp *s)
+{
+ traceExpression(s->expr, currentReg);
+}
+
+void QV4CompilerPrivate::visitMove(IR::Move *s)
+{
+ IR::Temp *target = s->target->asTemp();
+ Q_ASSERT(target != 0);
+
+ quint8 dest = target->index;
+
+ if (target->type != s->source->type) {
+ quint8 src = dest;
+
+ if (IR::Temp *t = s->source->asTemp())
+ src = t->index;
+ else
+ traceExpression(s->source, dest);
+
+ V4Instr::Type opcode = V4Instr::Noop;
+ IR::Type targetTy = s->target->type;
+ IR::Type sourceTy = s->source->type;
+
+ if (sourceTy == IR::UrlType) {
+ switch (targetTy) {
+ case IR::BoolType:
+ case IR::StringType:
+ // nothing to do. V4 will generate optimized
+ // url-to-xxx conversions.
+ break;
+ default: {
+ // generate a UrlToString conversion and fix
+ // the type of the source expression.
+ V4Instr conv;
+ conv.unaryop.output = V4Instr::ConvertUrlToString;
+ conv.unaryop.src = src;
+ gen(opcode, conv);
+
+ sourceTy = IR::StringType;
+ break;
+ }
+ } // switch
+ }
+
+ if (targetTy == IR::BoolType) {
+ switch (sourceTy) {
+ case IR::IntType: opcode = V4Instr::ConvertIntToBool; break;
+ case IR::RealType: opcode = V4Instr::ConvertRealToBool; break;
+ case IR::StringType: opcode = V4Instr::ConvertStringToBool; break;
+ case IR::UrlType: opcode = V4Instr::ConvertUrlToBool; break;
+ case IR::ColorType: opcode = V4Instr::ConvertColorToBool; break;
+ default: break;
+ } // switch
+ } else if (targetTy == IR::IntType) {
+ switch (sourceTy) {
+ case IR::BoolType: opcode = V4Instr::ConvertBoolToInt; break;
+ case IR::RealType: {
+ if (s->isMoveForReturn)
+ opcode = V4Instr::MathRoundReal;
+ else
+ opcode = V4Instr::ConvertRealToInt;
+ break;
+ }
+ case IR::StringType: opcode = V4Instr::ConvertStringToInt; break;
+ default: break;
+ } // switch
+ } else if (targetTy == IR::RealType) {
+ switch (sourceTy) {
+ case IR::BoolType: opcode = V4Instr::ConvertBoolToReal; break;
+ case IR::IntType: opcode = V4Instr::ConvertIntToReal; break;
+ case IR::StringType: opcode = V4Instr::ConvertStringToReal; break;
+ default: break;
+ } // switch
+ } else if (targetTy == IR::StringType) {
+ switch (sourceTy) {
+ case IR::BoolType: opcode = V4Instr::ConvertBoolToString; break;
+ case IR::IntType: opcode = V4Instr::ConvertIntToString; break;
+ case IR::RealType: opcode = V4Instr::ConvertRealToString; break;
+ case IR::UrlType: opcode = V4Instr::ConvertUrlToString; break;
+ case IR::ColorType: opcode = V4Instr::ConvertColorToString; break;
+ default: break;
+ } // switch
+ } else if (targetTy == IR::UrlType) {
+ V4Instr convToString;
+ convToString.unaryop.output = dest;
+ convToString.unaryop.src = src;
+
+ // try to convert the source expression to a string.
+ switch (sourceTy) {
+ case IR::BoolType: gen(V4Instr::ConvertBoolToString, convToString); sourceTy = IR::StringType; break;
+ case IR::IntType: gen(V4Instr::ConvertIntToString, convToString); sourceTy = IR::StringType; break;
+ case IR::RealType: gen(V4Instr::ConvertRealToString, convToString); sourceTy = IR::StringType; break;
+ case IR::ColorType: gen(V4Instr::ConvertColorToString, convToString); sourceTy = IR::StringType; break;
+ default: break;
+ } // switch
+
+ if (sourceTy == IR::StringType)
+ opcode = V4Instr::ConvertStringToUrl;
+ } else if (targetTy == IR::ColorType) {
+ switch (sourceTy) {
+ case IR::StringType: opcode = V4Instr::ConvertStringToColor; break;
+ default: break;
+ } // switch
+ }
+ if (opcode != V4Instr::Noop) {
+ V4Instr conv;
+ conv.unaryop.output = dest;
+ conv.unaryop.src = src;
+ gen(opcode, conv);
+
+ if (s->isMoveForReturn && opcode == V4Instr::ConvertStringToUrl) {
+ V4Instr resolveUrl;
+ resolveUrl.unaryop.output = dest;
+ resolveUrl.unaryop.src = dest;
+ gen(V4Instr::ResolveUrl, resolveUrl);
+ }
+ } else {
+ discard();
+ }
+ } else {
+ traceExpression(s->source, dest);
+ }
+}
+
+void QV4CompilerPrivate::visitJump(IR::Jump *s)
+{
+ patches.append(Patch(s->target, bytecode.size()));
+
+ Instr::Branch i;
+ i.offset = 0; // ### backpatch
+ gen(i);
+}
+
+void QV4CompilerPrivate::visitCJump(IR::CJump *s)
+{
+ traceExpression(s->cond, currentReg);
+
+ patches.append(Patch(s->iftrue, bytecode.size()));
+
+ Instr::BranchTrue i;
+ i.reg = currentReg;
+ i.offset = 0; // ### backpatch
+ gen(i);
+}
+
+void QV4CompilerPrivate::visitRet(IR::Ret *s)
+{
+ Q_ASSERT(s->expr != 0);
+
+ int storeReg = currentReg;
+
+ if (IR::Temp *temp = s->expr->asTemp()) {
+ storeReg = temp->index;
+ } else {
+ traceExpression(s->expr, storeReg);
+ }
+
+ if (qmlBindingsTest) {
+ Instr::TestV4Store test;
+ test.reg = storeReg;
+ switch (s->type) {
+ case IR::StringType:
+ test.regType = QMetaType::QString;
+ break;
+ case IR::UrlType:
+ test.regType = QMetaType::QUrl;
+ break;
+ case IR::ColorType:
+ test.regType = QMetaType::QColor;
+ break;
+ case IR::SGAnchorLineType:
+ test.regType = QQmlMetaType::QQuickAnchorLineMetaTypeId();
+ break;
+ case IR::ObjectType:
+ test.regType = QMetaType::QObjectStar;
+ break;
+ case IR::BoolType:
+ test.regType = QMetaType::Bool;
+ break;
+ case IR::IntType:
+ test.regType = QMetaType::Int;
+ break;
+ case IR::RealType:
+ test.regType = QMetaType::QReal;
+ break;
+ default:
+ discard();
+ return;
+ }
+ gen(test);
+ }
+
+ Instr::Store store;
+ store.output = 0;
+ store.index = expression->property->index;
+ store.reg = storeReg;
+ store.exceptionId = exceptionId(s->line, s->column);
+ gen(store);
+}
+
+void QV4Compiler::dump(const QByteArray &programData)
+{
+ const QV4Program *program = (const QV4Program *)programData.constData();
+
+ qWarning() << "Program.bindings:" << program->bindings;
+ qWarning() << "Program.dataLength:" << program->dataLength;
+ qWarning() << "Program.subscriptions:" << program->subscriptions;
+ qWarning() << "Program.indentifiers:" << program->identifiers;
+
+ const int programSize = program->instructionCount;
+ const char *start = program->instructions();
+ const char *end = start + programSize;
+ Bytecode bc;
+ bc.dump(start, end);
+}
+
+/*!
+Clear the state associated with attempting to compile a specific binding.
+This does not clear the global "committed binding" states.
+*/
+void QV4CompilerPrivate::resetInstanceState()
+{
+ data = committed.data;
+ exceptions = committed.exceptions;
+ usedSubscriptionIds.clear();
+ subscriptionIds = committed.subscriptionIds;
+ registeredStrings = committed.registeredStrings;
+ bytecode.clear();
+ patches.clear();
+ pool.clear();
+ currentReg = 0;
+}
+
+/*!
+Mark the last compile as successful, and add it to the "committed data"
+section.
+
+Returns the index for the committed binding.
+*/
+int QV4CompilerPrivate::commitCompile()
+{
+ int rv = committed.count();
+ committed.offsets << committed.bytecode.count();
+ committed.dependencies << usedSubscriptionIds;
+ committed.bytecode.append(bytecode.constData(), bytecode.size());
+ committed.data = data;
+ committed.exceptions = exceptions;
+ committed.subscriptionIds = subscriptionIds;
+ committed.registeredStrings = registeredStrings;
+ return rv;
+}
+
+bool QV4CompilerPrivate::compile(QQmlJS::AST::Node *node)
+{
+ resetInstanceState();
+
+ if (expression->property->type == -1)
+ return false;
+
+ AST::SourceLocation location;
+ if (AST::ExpressionNode *astExpression = node->expressionCast()) {
+ location = astExpression->firstSourceLocation();
+ } else if (AST::Statement *astStatement = node->statementCast()) {
+ if (AST::Block *block = AST::cast<AST::Block *>(astStatement))
+ location = block->lbraceToken;
+ else if (AST::IfStatement *ifStmt = AST::cast<AST::IfStatement *>(astStatement))
+ location = ifStmt->ifToken;
+ else
+ return false;
+ } else {
+ return false;
+ }
+
+ IR::Function thisFunction(&pool), *function = &thisFunction;
+
+ QV4IRBuilder irBuilder(expression, engine);
+ if (!irBuilder(function, node))
+ return false;
+
+ bool discarded = false;
+ qSwap(_discarded, discarded);
+ qSwap(_function, function);
+ trace(location.startLine, location.startColumn);
+ qSwap(_function, function);
+ qSwap(_discarded, discarded);
+
+ if (qmlVerboseCompiler()) {
+ QTextStream qerr(stderr, QIODevice::WriteOnly);
+ if (discarded)
+ qerr << "======== TODO ====== " << endl;
+ else
+ qerr << "==================== " << endl;
+ qerr << "\tline: " << location.startLine
+ << "\tcolumn: " << location.startColumn
+ << endl;
+ foreach (IR::BasicBlock *bb, function->basicBlocks)
+ bb->dump(qerr);
+ qerr << endl;
+ }
+
+ if (discarded || subscriptionIds.count() > 0xFFFF || registeredStrings.count() > 0xFFFF || registerCount > 31)
+ return false;
+
+ return true;
+}
+
+// Returns a reg
+int QV4CompilerPrivate::registerLiteralString(quint8 reg, const QStringRef &str)
+{
+ // ### string cleanup
+
+ QByteArray strdata((const char *)str.constData(), str.length() * sizeof(QChar));
+ int offset = data.count();
+ data += strdata;
+
+ Instr::LoadString string;
+ string.reg = reg;
+ string.offset = offset;
+ string.length = str.length();
+ gen(string);
+
+ return reg;
+}
+
+// Returns an identifier offset
+int QV4CompilerPrivate::registerString(const QString &string)
+{
+ Q_ASSERT(!string.isEmpty());
+
+ QPair<int, int> *iter = registeredStrings.value(string);
+
+ if (!iter) {
+ quint32 len = string.length();
+ QByteArray lendata((const char *)&len, sizeof(quint32));
+ QByteArray strdata((const char *)string.constData(), string.length() * sizeof(QChar));
+ strdata.prepend(lendata);
+ int rv = data.count();
+ data += strdata;
+
+ iter = &registeredStrings[string];
+ *iter = qMakePair(registeredStrings.count(), rv);
+ }
+
+ Instr::InitString reg;
+ reg.offset = iter->first;
+ reg.dataIdx = iter->second;
+ gen(reg);
+ return reg.offset;
+}
+
+/*!
+Returns true if the current expression has not already subscribed to \a sub in currentBlockMask.
+*/
+bool QV4CompilerPrivate::blockNeedsSubscription(const QStringList &sub)
+{
+ QString str = sub.join(QLatin1String("."));
+
+ int *iter = subscriptionIds.value(str);
+ if (!iter)
+ return true;
+
+ quint32 *uiter = usedSubscriptionIds.value(*iter);
+ if (!uiter)
+ return true;
+ else
+ return !(*uiter & currentBlockMask);
+}
+
+int QV4CompilerPrivate::subscriptionIndex(const QStringList &sub)
+{
+ QString str = sub.join(QLatin1String("."));
+ int *iter = subscriptionIds.value(str);
+ if (!iter) {
+ int count = subscriptionIds.count();
+ iter = &subscriptionIds[str];
+ *iter = count;
+ }
+ quint32 &u = usedSubscriptionIds[*iter];
+ if (!(u & currentBlockMask)) {
+ u |= currentBlockMask;
+ usedSubscriptionIdsChanged = true;
+ }
+ return *iter;
+}
+
+quint32 QV4CompilerPrivate::subscriptionBlockMask(const QStringList &sub)
+{
+ QString str = sub.join(QLatin1String("."));
+
+ int *iter = subscriptionIds.value(str);
+ Q_ASSERT(iter != 0);
+
+ quint32 *uiter = usedSubscriptionIds.value(*iter);
+ Q_ASSERT(uiter != 0);
+
+ return *uiter;
+}
+
+quint8 QV4CompilerPrivate::exceptionId(quint32 line, quint32 column)
+{
+ quint8 rv = 0xFF;
+ if (exceptions.count() < 0xFF) {
+ rv = (quint8)exceptions.count();
+ quint64 e = line;
+ e <<= 32;
+ e |= column;
+ exceptions.append(e);
+ }
+ return rv;
+}
+
+quint8 QV4CompilerPrivate::exceptionId(QQmlJS::AST::ExpressionNode *n)
+{
+ quint8 rv = 0xFF;
+ if (n && exceptions.count() < 0xFF) {
+ QQmlJS::AST::SourceLocation l = n->firstSourceLocation();
+ rv = exceptionId(l.startLine, l.startColumn);
+ }
+ return rv;
+}
+
+QV4Compiler::QV4Compiler()
+: d(new QV4CompilerPrivate)
+{
+ qmlBindingsTest |= qmlBindingsTestEnv();
+}
+
+QV4Compiler::~QV4Compiler()
+{
+ delete d; d = 0;
+}
+
+/*
+Returns true if any bindings were compiled.
+*/
+bool QV4Compiler::isValid() const
+{
+ return !d->committed.bytecode.isEmpty();
+}
+
+/*
+-1 on failure, otherwise the binding index to use.
+*/
+int QV4Compiler::compile(const Expression &expression, QQmlEnginePrivate *engine)
+{
+ if (!expression.expression.asAST()) return false;
+
+ if (!qmlExperimental() && expression.property->isValueTypeSubProperty)
+ return -1;
+
+ if (qmlDisableOptimizer() || !qmlEnableV4)
+ return -1;
+
+ d->expression = &expression;
+ d->engine = engine;
+
+ if (d->compile(expression.expression.asAST())) {
+ return d->commitCompile();
+ } else {
+ return -1;
+ }
+}
+
+QByteArray QV4CompilerPrivate::buildSignalTable() const
+{
+ QHash<int, QList<QPair<int, quint32> > > table;
+
+ for (int ii = 0; ii < committed.count(); ++ii) {
+ const QQmlAssociationList<int, quint32> &deps = committed.dependencies.at(ii);
+ for (QQmlAssociationList<int, quint32>::const_iterator iter = deps.begin(); iter != deps.end(); ++iter)
+ table[iter->first].append(qMakePair(ii, iter->second));
+ }
+
+ QVector<quint32> header;
+ QVector<quint32> data;
+ for (int ii = 0; ii < committed.subscriptionIds.count(); ++ii) {
+ header.append(committed.subscriptionIds.count() + data.count());
+ const QList<QPair<int, quint32> > &bindings = table[ii];
+ data.append(bindings.count());
+ for (int jj = 0; jj < bindings.count(); ++jj) {
+ data.append(bindings.at(jj).first);
+ data.append(bindings.at(jj).second);
+ }
+ }
+ header << data;
+
+ return QByteArray((const char *)header.constData(), header.count() * sizeof(quint32));
+}
+
+QByteArray QV4CompilerPrivate::buildExceptionData() const
+{
+ QByteArray rv;
+ rv.resize(committed.exceptions.count() * sizeof(quint64));
+ ::memcpy(rv.data(), committed.exceptions.constData(), rv.size());
+ return rv;
+}
+
+/*
+Returns the compiled program.
+*/
+QByteArray QV4Compiler::program() const
+{
+ QByteArray programData;
+
+ if (isValid()) {
+ QV4Program prog;
+ prog.bindings = d->committed.count();
+
+ Bytecode bc;
+ QV4CompilerPrivate::Instr::Jump jump;
+ jump.reg = -1;
+
+ for (int ii = 0; ii < d->committed.count(); ++ii) {
+ jump.count = d->committed.count() - ii - 1;
+ jump.count*= V4InstrMeta<V4Instr::Jump>::Size;
+ jump.count+= d->committed.offsets.at(ii);
+ bc.append(jump);
+ }
+
+
+ QByteArray bytecode;
+ bytecode.reserve(bc.size() + d->committed.bytecode.size());
+ bytecode.append(bc.constData(), bc.size());
+ bytecode.append(d->committed.bytecode.constData(), d->committed.bytecode.size());
+
+ QByteArray data = d->committed.data;
+ while (data.count() % 4) data.append('\0');
+ prog.signalTableOffset = data.count();
+ data += d->buildSignalTable();
+ while (data.count() % 4) data.append('\0');
+ prog.exceptionDataOffset = data.count();
+ data += d->buildExceptionData();
+
+ prog.dataLength = 4 * ((data.size() + 3) / 4);
+ prog.subscriptions = d->committed.subscriptionIds.count();
+ prog.identifiers = d->committed.registeredStrings.count();
+ prog.instructionCount = bytecode.count();
+ int size = sizeof(QV4Program) + bytecode.count();
+ size += prog.dataLength;
+
+ programData.resize(size);
+ memcpy(programData.data(), &prog, sizeof(QV4Program));
+ if (prog.dataLength)
+ memcpy((char *)((QV4Program *)programData.data())->data(), data.constData(),
+ data.size());
+ memcpy((char *)((QV4Program *)programData.data())->instructions(), bytecode.constData(),
+ bytecode.count());
+ }
+
+ if (bindingsDump()) {
+ qWarning().nospace() << "Subscription slots:";
+
+ for (QQmlAssociationList<QString, int>::ConstIterator iter = d->committed.subscriptionIds.begin();
+ iter != d->committed.subscriptionIds.end();
+ ++iter) {
+ qWarning().nospace() << " " << iter->first << "\t-> " << iter->second;
+ }
+
+ QV4Compiler::dump(programData);
+ }
+
+ return programData;
+}
+
+void QV4Compiler::enableBindingsTest(bool e)
+{
+ if (e)
+ qmlBindingsTest = true;
+ else
+ qmlBindingsTest = qmlBindingsTestEnv();
+}
+
+void QV4Compiler::enableV4(bool e)
+{
+ qmlEnableV4 = e;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4compiler_p.h b/src/qml/qml/v4/qv4compiler_p.h
new file mode 100644
index 0000000000..a93248ad14
--- /dev/null
+++ b/src/qml/qml/v4/qv4compiler_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4COMPILER_P_H
+#define QV4COMPILER_P_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 <private/qqmlexpression_p.h>
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlcompiler_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQmlTypeNameCache;
+class QV4CompilerPrivate;
+class Q_AUTOTEST_EXPORT QV4Compiler
+{
+public:
+ QV4Compiler();
+ ~QV4Compiler();
+
+ // Returns true if bindings were compiled
+ bool isValid() const;
+
+ struct Expression
+ {
+ Expression(const QQmlImports &imp) : imports(imp) {}
+ QQmlScript::Object *component;
+ QQmlScript::Object *context;
+ QQmlScript::Property *property;
+ QQmlScript::Variant expression;
+ QQmlCompilerTypes::IdList *ids;
+ QQmlTypeNameCache *importCache;
+ QQmlImports imports;
+ };
+
+ // -1 on failure, otherwise the binding index to use
+ int compile(const Expression &, QQmlEnginePrivate *);
+
+ // Returns the compiled program
+ QByteArray program() const;
+
+ static void dump(const QByteArray &);
+ static void enableBindingsTest(bool);
+ static void enableV4(bool);
+private:
+ QV4CompilerPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV4COMPILER_P_H
+
diff --git a/src/qml/qml/v4/qv4compiler_p_p.h b/src/qml/qml/v4/qv4compiler_p_p.h
new file mode 100644
index 0000000000..a9209d978f
--- /dev/null
+++ b/src/qml/qml/v4/qv4compiler_p_p.h
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4COMPILER_P_P_H
+#define QV4COMPILER_P_P_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 "qv4instruction_p.h"
+#include "qv4ir_p.h"
+#include <private/qqmlscript_p.h>
+#include <private/qqmlimport_p.h>
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+template <typename _Key, typename _Value>
+class QQmlAssociationList
+{
+public:
+ typedef QVarLengthArray<QPair<_Key, _Value>, 8> Container;
+ typedef typename Container::const_iterator const_iterator;
+ typedef typename Container::const_iterator ConstIterator;
+
+ const_iterator begin() const { return _container.begin(); }
+ const_iterator end() const { return _container.end(); }
+ int count() const { return _container.count(); }
+ void clear() { _container.clear(); }
+
+ _Value *value(const _Key &key) {
+ for (int i = 0; i < _container.size(); ++i) {
+ QPair<_Key, _Value> &p = _container[i];
+ if (p.first == key)
+ return &p.second;
+ }
+ return 0;
+ }
+
+ _Value &operator[](const _Key &key) {
+ for (int i = 0; i < _container.size(); ++i) {
+ QPair<_Key, _Value> &p = _container[i];
+ if (p.first == key)
+ return p.second;
+ }
+ int index = _container.size();
+ _container.append(qMakePair(key, _Value()));
+ return _container[index].second;
+ }
+
+ void insert(const _Key &key, _Value &value) {
+ for (int i = 0; i < _container.size(); ++i) {
+ QPair<_Key, _Value> &p = _container[i];
+ if (p.first == key) {
+ p.second = value;
+ return;
+ }
+ }
+ _container.append(qMakePair(key, value));
+ }
+
+private:
+ Container _container;
+};
+
+class QV4CompilerPrivate: protected QQmlJS::IR::ExprVisitor,
+ protected QQmlJS::IR::StmtVisitor
+{
+public:
+ QV4CompilerPrivate();
+
+ void resetInstanceState();
+ int commitCompile();
+
+ const QV4Compiler::Expression *expression;
+ QQmlEnginePrivate *engine;
+
+ QString contextName() const { return QLatin1String("$$$SCOPE_") + QString::number((quintptr)expression->context, 16); }
+
+ bool compile(QQmlJS::AST::Node *);
+
+ int registerLiteralString(quint8 reg, const QStringRef &);
+ int registerString(const QString &);
+ QQmlAssociationList<QString, QPair<int, int> > registeredStrings;
+ QByteArray data;
+
+ bool blockNeedsSubscription(const QStringList &);
+ int subscriptionIndex(const QStringList &);
+ quint32 subscriptionBlockMask(const QStringList &);
+
+ quint8 exceptionId(quint32 line, quint32 column);
+ quint8 exceptionId(QQmlJS::AST::ExpressionNode *);
+ QVector<quint64> exceptions;
+
+ QQmlAssociationList<int, quint32> usedSubscriptionIds;
+
+ QQmlAssociationList<QString, int> subscriptionIds;
+ QQmlJS::Bytecode bytecode;
+
+ // back patching
+ struct Patch {
+ QQmlJS::IR::BasicBlock *block; // the basic block
+ int offset; // the index of the instruction to patch
+ Patch(QQmlJS::IR::BasicBlock *block = 0, int index = -1)
+ : block(block), offset(index) {}
+ };
+ QVector<Patch> patches;
+ QQmlPool pool;
+
+ // Committed binding data
+ struct {
+ QList<int> offsets;
+ QList<QQmlAssociationList<int, quint32> > dependencies;
+
+ //QQmlJS::Bytecode bytecode;
+ QByteArray bytecode;
+ QByteArray data;
+ QQmlAssociationList<QString, int> subscriptionIds;
+ QVector<quint64> exceptions;
+
+ QQmlAssociationList<QString, QPair<int, int> > registeredStrings;
+
+ int count() const { return offsets.count(); }
+ } committed;
+
+ QByteArray buildSignalTable() const;
+ QByteArray buildExceptionData() const;
+
+ void convertToReal(QQmlJS::IR::Expr *expr, int reg);
+ void convertToInt(QQmlJS::IR::Expr *expr, int reg);
+ void convertToBool(QQmlJS::IR::Expr *expr, int reg);
+ quint8 instructionOpcode(QQmlJS::IR::Binop *e);
+
+ struct Instr {
+#define QML_V4_INSTR_DATA_TYPEDEF(I, FMT) typedef QQmlJS::V4InstrData<QQmlJS::V4Instr::I> I;
+ FOR_EACH_V4_INSTR(QML_V4_INSTR_DATA_TYPEDEF)
+#undef QML_v4_INSTR_DATA_TYPEDEF
+ private:
+ Instr();
+ };
+
+protected:
+ //
+ // tracing
+ //
+ void trace(int line, int column);
+ void trace(QVector<QQmlJS::IR::BasicBlock *> *blocks);
+ void traceExpression(QQmlJS::IR::Expr *e, quint8 r);
+
+ template <int Instr>
+ inline void gen(const QQmlJS::V4InstrData<Instr> &i)
+ { bytecode.append(i); }
+ inline void gen(QQmlJS::V4Instr::Type type, QQmlJS::V4Instr &instr)
+ { bytecode.append(type, instr); }
+
+ inline QQmlJS::V4Instr::Type instructionType(const QQmlJS::V4Instr *i) const
+ { return bytecode.instructionType(i); }
+
+ //
+ // expressions
+ //
+ virtual void visitConst(QQmlJS::IR::Const *e);
+ virtual void visitString(QQmlJS::IR::String *e);
+ virtual void visitName(QQmlJS::IR::Name *e);
+ virtual void visitTemp(QQmlJS::IR::Temp *e);
+ virtual void visitUnop(QQmlJS::IR::Unop *e);
+ virtual void visitBinop(QQmlJS::IR::Binop *e);
+ virtual void visitCall(QQmlJS::IR::Call *e);
+
+ //
+ // statements
+ //
+ virtual void visitExp(QQmlJS::IR::Exp *s);
+ virtual void visitMove(QQmlJS::IR::Move *s);
+ virtual void visitJump(QQmlJS::IR::Jump *s);
+ virtual void visitCJump(QQmlJS::IR::CJump *s);
+ virtual void visitRet(QQmlJS::IR::Ret *s);
+
+private:
+ QStringList _subscribeName;
+ QQmlJS::IR::Function *_function;
+ QQmlJS::IR::BasicBlock *_block;
+ void discard() { _discarded = true; }
+ bool _discarded;
+ quint8 currentReg;
+ quint8 registerCount;
+
+ bool usedSubscriptionIdsChanged;
+ quint32 currentBlockMask;
+};
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV4COMPILER_P_P_H
+
diff --git a/src/qml/qml/v4/qv4instruction.cpp b/src/qml/qml/v4/qv4instruction.cpp
new file mode 100644
index 0000000000..efbd2b2c1c
--- /dev/null
+++ b/src/qml/qml/v4/qv4instruction.cpp
@@ -0,0 +1,421 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4instruction_p.h"
+#include "qv4bindings_p.h"
+
+#include <QtCore/qdebug.h>
+#include <private/qqmlglobal_p.h>
+
+// Define this to do a test dump of all the instructions at startup. This is
+// helpful to test that each instruction's Instr::dump() case uses the correct
+// number of tabs etc and otherwise looks correct.
+// #define DEBUG_INSTR_DUMP
+
+QT_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+
+#ifdef DEBUG_INSTR_DUMP
+static struct DumpInstrAtStartup {
+ DumpInstrAtStartup() {
+ Bytecode bc;
+#define DUMP_INSTR_AT_STARTUP(I, FMT) { V4InstrData<V4Instr::I> i; bc.append(i); }
+ FOR_EACH_V4_INSTR(DUMP_INSTR_AT_STARTUP);
+#undef DUMP_INSTR_AT_STARTUP
+ const char *start = bc.constData();
+ const char *end = start + bc.size();
+ bc.dump(start, end);
+ }
+} dump_instr_at_startup;
+#endif
+
+int V4Instr::size(Type type)
+{
+#define V4_RETURN_INSTR_SIZE(I, FMT) case I: return QML_V4_INSTR_SIZE(I, FMT);
+ switch (type) {
+ FOR_EACH_V4_INSTR(V4_RETURN_INSTR_SIZE)
+ }
+#undef V4_RETURN_INSTR_SIZE
+ return 0;
+}
+
+void Bytecode::dump(const V4Instr *i, int address) const
+{
+ QByteArray leading;
+ if (address != -1) {
+ leading = QByteArray::number(address);
+ leading.prepend(QByteArray(8 - leading.count(), ' '));
+ leading.append("\t");
+ }
+
+#define INSTR_DUMP qWarning().nospace() << leading.constData()
+
+ switch (instructionType(i)) {
+ case V4Instr::Noop:
+ INSTR_DUMP << "\t" << "Noop";
+ break;
+ case V4Instr::BindingId:
+ INSTR_DUMP << i->id.line << ":" << i->id.column << ":";
+ break;
+ case V4Instr::Subscribe:
+ INSTR_DUMP << "\t" << "Subscribe" << "\t\t" << "Object_Reg(" << i->subscribeop.reg << ") Notify_Signal(" << i->subscribeop.index << ") -> Subscribe_Slot(" << i->subscribeop.offset << ")";
+ break;
+ case V4Instr::SubscribeId:
+ INSTR_DUMP << "\t" << "SubscribeId" << "\t\t" << "Id_Offset(" << i->subscribeop.index << ") -> Subscribe_Slot(" << i->subscribeop.offset << ")";
+ break;
+ case V4Instr::FetchAndSubscribe:
+ INSTR_DUMP << "\t" << "FetchAndSubscribe" << "\t" << "Object_Reg(" << i->fetchAndSubscribe.reg << ") Fast_Accessor(" << i->fetchAndSubscribe.property.accessors << ") -> Output_Reg(" << i->fetchAndSubscribe.reg << ") Subscription_Slot(" << i->fetchAndSubscribe.subscription << ")";
+ break;
+ case V4Instr::LoadId:
+ INSTR_DUMP << "\t" << "LoadId" << "\t\t\t" << "Id_Offset(" << i->load.index << ") -> Output_Reg(" << i->load.reg << ")";
+ break;
+ case V4Instr::LoadScope:
+ INSTR_DUMP << "\t" << "LoadScope" << "\t\t" << "-> Output_Reg(" << i->load.reg << ")";
+ break;
+ case V4Instr::LoadRoot:
+ INSTR_DUMP << "\t" << "LoadRoot" << "\t\t" << "-> Output_Reg(" << i->load.reg << ")";
+ break;
+ case V4Instr::LoadAttached:
+ INSTR_DUMP << "\t" << "LoadAttached" << "\t\t" << "Object_Reg(" << i->attached.reg << ") Attached_Index(" << i->attached.id << ") -> Output_Reg(" << i->attached.output << ")";
+ break;
+ case V4Instr::UnaryNot:
+ INSTR_DUMP << "\t" << "UnaryNot" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::UnaryMinusReal:
+ INSTR_DUMP << "\t" << "UnaryMinusReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::UnaryMinusInt:
+ INSTR_DUMP << "\t" << "UnaryMinusInt" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::UnaryPlusReal:
+ INSTR_DUMP << "\t" << "UnaryPlusReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::UnaryPlusInt:
+ INSTR_DUMP << "\t" << "UnaryPlusInt" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertBoolToInt:
+ INSTR_DUMP << "\t" << "ConvertBoolToInt" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertBoolToReal:
+ INSTR_DUMP << "\t" << "ConvertBoolToReal" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertBoolToString:
+ INSTR_DUMP << "\t" << "ConvertBoolToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertIntToBool:
+ INSTR_DUMP << "\t" << "ConvertIntToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertIntToReal:
+ INSTR_DUMP << "\t" << "ConvertIntToReal" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertIntToString:
+ INSTR_DUMP << "\t" << "ConvertIntToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertRealToBool:
+ INSTR_DUMP << "\t" << "ConvertRealToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertRealToInt:
+ INSTR_DUMP << "\t" << "ConvertRealToInt" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertRealToString:
+ INSTR_DUMP << "\t" << "ConvertRealToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertStringToBool:
+ INSTR_DUMP << "\t" << "ConvertStringToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertStringToInt:
+ INSTR_DUMP << "\t" << "ConvertStringToInt" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertStringToReal:
+ INSTR_DUMP << "\t" << "ConvertStringToReal" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertStringToUrl:
+ INSTR_DUMP << "\t" << "ConvertStringToUrl" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertStringToColor:
+ INSTR_DUMP << "\t" << "ConvertStringToColor" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertUrlToBool:
+ INSTR_DUMP << "\t" << "ConvertUrlToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertUrlToString:
+ INSTR_DUMP << "\t" << "ConvertUrlToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertColorToBool:
+ INSTR_DUMP << "\t" << "ConvertColorToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertColorToString:
+ INSTR_DUMP << "\t" << "ConvertColorToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ResolveUrl:
+ INSTR_DUMP << "\t" << "ResolveUrl" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::MathSinReal:
+ INSTR_DUMP << "\t" << "MathSinReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::MathCosReal:
+ INSTR_DUMP << "\t" << "MathCosReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::MathRoundReal:
+ INSTR_DUMP << "\t" << "MathRoundReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::MathFloorReal:
+ INSTR_DUMP << "\t" << "MathFloorReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::MathPIReal:
+ INSTR_DUMP << "\t" << "MathPIReal" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::LoadReal:
+ INSTR_DUMP << "\t" << "LoadReal" << "\t\t" << "Constant(" << i->real_value.value << ") -> Output_Reg(" << i->real_value.reg << ")";
+ break;
+ case V4Instr::LoadInt:
+ INSTR_DUMP << "\t" << "LoadInt" << "\t\t\t" << "Constant(" << i->int_value.value << ") -> Output_Reg(" << i->int_value.reg << ")";
+ break;
+ case V4Instr::LoadBool:
+ INSTR_DUMP << "\t" << "LoadBool" << "\t\t" << "Constant(" << i->bool_value.value << ") -> Output_Reg(" << i->bool_value.reg << ")";
+ break;
+ case V4Instr::LoadString:
+ INSTR_DUMP << "\t" << "LoadString" << "\t\t" << "String_DataIndex(" << i->string_value.offset << ") String_Length(" << i->string_value.length << ") -> Output_Register(" << i->string_value.reg << ")";
+ break;
+ case V4Instr::EnableV4Test:
+ INSTR_DUMP << "\t" << "EnableV4Test" << "\t\t" << "String_DataIndex(" << i->string_value.offset << ") String_Length(" << i->string_value.length << ")";
+ break;
+ case V4Instr::TestV4Store:
+ INSTR_DUMP << "\t" << "TestV4Store" << "\t\t" << "Input_Reg(" << i->storetest.reg << ") Reg_Type(" << i->storetest.regType << ")";
+ break;
+ case V4Instr::BitAndInt:
+ INSTR_DUMP << "\t" << "BitAndInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::BitOrInt:
+ INSTR_DUMP << "\t" << "BitOrInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::BitXorInt:
+ INSTR_DUMP << "\t" << "BitXorInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::AddReal:
+ INSTR_DUMP << "\t" << "AddReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::AddString:
+ INSTR_DUMP << "\t" << "AddString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::SubReal:
+ INSTR_DUMP << "\t" << "SubReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::MulReal:
+ INSTR_DUMP << "\t" << "MulReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::DivReal:
+ INSTR_DUMP << "\t" << "DivReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::ModReal:
+ INSTR_DUMP << "\t" << "ModReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::LShiftInt:
+ INSTR_DUMP << "\t" << "LShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::RShiftInt:
+ INSTR_DUMP << "\t" << "RShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::URShiftInt:
+ INSTR_DUMP << "\t" << "URShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::GtReal:
+ INSTR_DUMP << "\t" << "GtReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::LtReal:
+ INSTR_DUMP << "\t" << "LtReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::GeReal:
+ INSTR_DUMP << "\t" << "GeReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::LeReal:
+ INSTR_DUMP << "\t" << "LeReal" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::EqualReal:
+ INSTR_DUMP << "\t" << "EqualReal" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::NotEqualReal:
+ INSTR_DUMP << "\t" << "NotEqualReal" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::StrictEqualReal:
+ INSTR_DUMP << "\t" << "StrictEqualReal" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::StrictNotEqualReal:
+ INSTR_DUMP << "\t" << "StrictNotEqualReal" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::GtString:
+ INSTR_DUMP << "\t" << "GtString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::LtString:
+ INSTR_DUMP << "\t" << "LtString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::GeString:
+ INSTR_DUMP << "\t" << "GeString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::LeString:
+ INSTR_DUMP << "\t" << "LeString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::EqualString:
+ INSTR_DUMP << "\t" << "EqualString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::NotEqualString:
+ INSTR_DUMP << "\t" << "NotEqualString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::StrictEqualString:
+ INSTR_DUMP << "\t" << "StrictEqualString" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::StrictNotEqualString:
+ INSTR_DUMP << "\t" << "StrictNotEqualString" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::NewString:
+ INSTR_DUMP << "\t" << "NewString" << "\t\t" << "Register(" << i->construct.reg << ")";
+ break;
+ case V4Instr::NewUrl:
+ INSTR_DUMP << "\t" << "NewUrl" << "\t\t\t" << "Register(" << i->construct.reg << ")";
+ break;
+ case V4Instr::CleanupRegister:
+ INSTR_DUMP << "\t" << "CleanupRegister" << "\t\t" << "Register(" << i->cleanup.reg << ")";
+ break;
+ case V4Instr::Fetch:
+ INSTR_DUMP << "\t" << "Fetch" << "\t\t\t" << "Object_Reg(" << i->fetch.reg << ") Property_Index(" << i->fetch.index << ") -> Output_Reg(" << i->fetch.reg << ")";
+ break;
+ case V4Instr::Store:
+ INSTR_DUMP << "\t" << "Store" << "\t\t\t" << "Input_Reg(" << i->store.reg << ") -> Object_Reg(" << i->store.output << ") Property_Index(" << i->store.index << ")";
+ break;
+ case V4Instr::Copy:
+ INSTR_DUMP << "\t" << "Copy" << "\t\t\t" << "Input_Reg(" << i->copy.src << ") -> Output_Reg(" << i->copy.reg << ")";
+ break;
+ case V4Instr::Jump:
+ if (i->jump.reg != -1) {
+ INSTR_DUMP << "\t" << "Jump" << "\t\t\t" << "Address(" << (address + size() + i->jump.count) << ") [if false == Input_Reg(" << i->jump.reg << ")]";
+ } else {
+ INSTR_DUMP << "\t" << "Jump" << "\t\t\t" << "Address(" << (address + size() + i->jump.count) << ")";
+ }
+ break;
+ case V4Instr::BranchFalse:
+ INSTR_DUMP << "\t" << "BranchFalse" << "\t\t" << "Address(" << (address + size() + i->branchop.offset) << ") [if false == Input_Reg(" << i->branchop.reg << ")]";
+ break;
+ case V4Instr::BranchTrue:
+ INSTR_DUMP << "\t" << "BranchTrue" << "\t\t" << "Address(" << (address + size() + i->branchop.offset) << ") [if true == Input_Reg(" << i->branchop.reg << ")]";
+ break;
+ case V4Instr::Branch:
+ INSTR_DUMP << "\t" << "Branch" << "\t\t\t" << "Address(" << (address + size() + i->branchop.offset) << ")";
+ break;
+ case V4Instr::InitString:
+ INSTR_DUMP << "\t" << "InitString" << "\t\t" << "String_DataIndex(" << i->initstring.dataIdx << ") -> String_Slot(" << i->initstring.offset << ")";
+ break;
+ case V4Instr::Block:
+ INSTR_DUMP << "\t" << "Block" << "\t\t\t" << "Mask(" << QByteArray::number(i->blockop.block, 16).constData() << ")";
+ break;
+ default:
+ INSTR_DUMP << "\t" << "Unknown";
+ break;
+ }
+}
+
+void Bytecode::dump(const char *start, const char *end) const
+{
+ const char *code = start;
+ while (code < end) {
+ const V4Instr *instr = reinterpret_cast<const V4Instr *>(code);
+ dump(instr, code - start);
+ code += V4Instr::size(instructionType(instr));
+ }
+}
+
+Bytecode::Bytecode()
+{
+#ifdef QML_THREADED_INTERPRETER
+ decodeInstr = QV4Bindings::getDecodeInstrTable();
+#endif
+}
+
+V4Instr::Type Bytecode::instructionType(const V4Instr *instr) const
+{
+#ifdef QML_THREADED_INTERPRETER
+ void *code = instr->common.code;
+
+# define CHECK_V4_INSTR_CODE(I, FMT) \
+ if (decodeInstr[static_cast<int>(V4Instr::I)] == code) \
+ return V4Instr::I;
+
+ FOR_EACH_V4_INSTR(CHECK_V4_INSTR_CODE)
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid instruction address");
+ return static_cast<V4Instr::Type>(0);
+# undef CHECK_V4_INSTR_CODE
+#else
+ return static_cast<V4Instr::Type>(instr->common.type);
+#endif
+
+}
+
+void Bytecode::append(V4Instr::Type type, V4Instr &instr)
+{
+#ifdef QML_THREADED_INTERPRETER
+ instr.common.code = decodeInstr[static_cast<int>(type)];
+#else
+ instr.common.type = type;
+#endif
+ d.append(reinterpret_cast<const char *>(&instr), V4Instr::size(type));
+}
+
+int Bytecode::remove(int offset)
+{
+ const V4Instr *instr = reinterpret_cast<const V4Instr *>(d.begin() + offset);
+ const int instrSize = V4Instr::size(instructionType(instr));
+ d.remove(offset, instrSize);
+ return instrSize;
+}
+
+const V4Instr &Bytecode::operator[](int offset) const
+{
+ return *(reinterpret_cast<const V4Instr *>(d.begin() + offset));
+}
+
+V4Instr &Bytecode::operator[](int offset)
+{
+ return *(reinterpret_cast<V4Instr *>(d.begin() + offset));
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4instruction_p.h b/src/qml/qml/v4/qv4instruction_p.h
new file mode 100644
index 0000000000..964c95513f
--- /dev/null
+++ b/src/qml/qml/v4/qv4instruction_p.h
@@ -0,0 +1,435 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4INSTRUCTION_P_H
+#define QV4INSTRUCTION_P_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/qbytearray.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qvarlengtharray.h>
+
+#include <private/qqmlpropertycache_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+#define FOR_EACH_V4_INSTR(F) \
+ F(Noop, common) \
+ F(BindingId, id) \
+ F(Subscribe, subscribeop) \
+ F(SubscribeId, subscribeop) \
+ F(FetchAndSubscribe, fetchAndSubscribe) \
+ F(LoadId, load) \
+ F(LoadScope, load) \
+ F(LoadRoot, load) \
+ F(LoadAttached, attached) \
+ F(UnaryNot, unaryop) \
+ F(UnaryMinusReal, unaryop) \
+ F(UnaryMinusInt, unaryop) \
+ F(UnaryPlusReal, unaryop) \
+ F(UnaryPlusInt, unaryop) \
+ F(ConvertBoolToInt, unaryop) \
+ F(ConvertBoolToReal, unaryop) \
+ F(ConvertBoolToString, unaryop) \
+ F(ConvertIntToBool, unaryop) \
+ F(ConvertIntToReal, unaryop) \
+ F(ConvertIntToString, unaryop) \
+ F(ConvertRealToBool, unaryop) \
+ F(ConvertRealToInt, unaryop) \
+ F(ConvertRealToString, unaryop) \
+ F(ConvertStringToBool, unaryop) \
+ F(ConvertStringToInt, unaryop) \
+ F(ConvertStringToReal, unaryop) \
+ F(ConvertStringToUrl, unaryop) \
+ F(ConvertStringToColor, unaryop) \
+ F(ConvertUrlToBool, unaryop) \
+ F(ConvertUrlToString, unaryop) \
+ F(ConvertColorToBool, unaryop) \
+ F(ConvertColorToString, unaryop) \
+ F(ResolveUrl, unaryop) \
+ F(MathSinReal, unaryop) \
+ F(MathCosReal, unaryop) \
+ F(MathRoundReal, unaryop) \
+ F(MathFloorReal, unaryop) \
+ F(MathPIReal, unaryop) \
+ F(LoadReal, real_value) \
+ F(LoadInt, int_value) \
+ F(LoadBool, bool_value) \
+ F(LoadString, string_value) \
+ F(EnableV4Test, string_value) \
+ F(TestV4Store, storetest) \
+ F(BitAndInt, binaryop) \
+ F(BitOrInt, binaryop) \
+ F(BitXorInt, binaryop) \
+ F(AddReal, binaryop) \
+ F(AddString, binaryop) \
+ F(SubReal, binaryop) \
+ F(MulReal, binaryop) \
+ F(DivReal, binaryop) \
+ F(ModReal, binaryop) \
+ F(LShiftInt, binaryop) \
+ F(RShiftInt, binaryop) \
+ F(URShiftInt, binaryop) \
+ F(GtReal, binaryop) \
+ F(LtReal, binaryop) \
+ F(GeReal, binaryop) \
+ F(LeReal, binaryop) \
+ F(EqualReal, binaryop) \
+ F(NotEqualReal, binaryop) \
+ F(StrictEqualReal, binaryop) \
+ F(StrictNotEqualReal, binaryop) \
+ F(GtString, binaryop) \
+ F(LtString, binaryop) \
+ F(GeString, binaryop) \
+ F(LeString, binaryop) \
+ F(EqualString, binaryop) \
+ F(NotEqualString, binaryop) \
+ F(StrictEqualString, binaryop) \
+ F(StrictNotEqualString, binaryop) \
+ F(NewString, construct) \
+ F(NewUrl, construct) \
+ F(CleanupRegister, cleanup) \
+ F(Copy, copy) \
+ F(Fetch, fetch) \
+ F(Store, store) \
+ F(Jump, jump) \
+ F(BranchTrue, branchop) \
+ F(BranchFalse, branchop) \
+ F(Branch, branchop) \
+ F(Block, blockop) \
+ /* Speculative property resolution */ \
+ F(InitString, initstring)
+
+#if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
+# define QML_THREADED_INTERPRETER
+#endif
+
+#ifdef Q_ALIGNOF
+# define QML_V4_INSTR_ALIGN_MASK (Q_ALIGNOF(V4Instr) - 1)
+#else
+# define QML_V4_INSTR_ALIGN_MASK (sizeof(void *) - 1)
+#endif
+
+#define QML_V4_INSTR_ENUM(I, FMT) I,
+#define QML_V4_INSTR_ADDR(I, FMT) &&op_##I,
+#define QML_V4_INSTR_SIZE(I, FMT) ((sizeof(V4Instr::instr_##FMT) + QML_V4_INSTR_ALIGN_MASK) & ~QML_V4_INSTR_ALIGN_MASK)
+
+#ifdef QML_THREADED_INTERPRETER
+# define QML_V4_BEGIN_INSTR(I,FMT) op_##I:
+# define QML_V4_END_INSTR(I,FMT) code += QML_V4_INSTR_SIZE(I, FMT); instr = (const V4Instr *) code; goto *instr->common.code;
+# define QML_V4_INSTR_HEADER void *code;
+#else
+# define QML_V4_BEGIN_INSTR(I,FMT) case V4Instr::I:
+# define QML_V4_END_INSTR(I,FMT) code += QML_V4_INSTR_SIZE(I, FMT); instr = (const V4Instr *) code; break;
+# define QML_V4_INSTR_HEADER quint8 type;
+#endif
+
+class QObject;
+class QQmlNotifier;
+
+namespace QQmlJS {
+
+union V4Instr {
+ enum Type {
+ FOR_EACH_V4_INSTR(QML_V4_INSTR_ENUM)
+ };
+
+ static int size(Type type);
+
+ struct instr_common {
+ QML_V4_INSTR_HEADER
+ };
+
+ struct instr_id {
+ QML_V4_INSTR_HEADER
+ quint16 column;
+ quint32 line;
+ };
+
+ struct instr_init {
+ QML_V4_INSTR_HEADER
+ quint16 subscriptions;
+ quint16 identifiers;
+ };
+
+ struct instr_subscribeop {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ quint16 offset;
+ quint32 index;
+ };
+
+ struct instr_load {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ quint32 index;
+ };
+
+ struct instr_attached {
+ QML_V4_INSTR_HEADER
+ qint8 output;
+ qint8 reg;
+ quint8 exceptionId;
+ quint32 id;
+ };
+
+ struct instr_store {
+ QML_V4_INSTR_HEADER
+ qint8 output;
+ qint8 reg;
+ quint8 exceptionId;
+ quint32 index;
+ };
+
+ struct instr_storetest {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ qint32 regType;
+ };
+
+ struct instr_fetchAndSubscribe {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ quint8 exceptionId;
+ quint8 valueType;
+ quint16 subscription;
+ QQmlPropertyRawData property;
+ };
+
+ struct instr_fetch{
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ quint8 exceptionId;
+ quint8 valueType;
+ quint32 index;
+ };
+
+ struct instr_copy {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ qint8 src;
+ };
+
+ struct instr_construct {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ };
+
+ struct instr_real_value {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ qreal value; // XXX Makes the instruction 12 bytes
+ };
+
+ struct instr_int_value {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ int value;
+ };
+
+ struct instr_bool_value {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ bool value;
+ };
+
+ struct instr_string_value {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ quint16 length;
+ quint32 offset;
+ };
+
+ struct instr_binaryop {
+ QML_V4_INSTR_HEADER
+ qint8 output;
+ qint8 left;
+ qint8 right;
+ };
+
+ struct instr_unaryop {
+ QML_V4_INSTR_HEADER
+ qint8 output;
+ qint8 src;
+ };
+
+ struct instr_jump {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ quint32 count;
+ };
+
+ struct instr_find {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ qint8 src;
+ quint8 exceptionId;
+ quint16 name;
+ quint16 subscribeIndex;
+ };
+
+ struct instr_cleanup {
+ QML_V4_INSTR_HEADER
+ qint8 reg;
+ };
+
+ struct instr_initstring {
+ QML_V4_INSTR_HEADER
+ quint16 offset;
+ quint32 dataIdx;
+ };
+
+ struct instr_branchop {
+ QML_V4_INSTR_HEADER
+ quint8 reg;
+ qint16 offset;
+ };
+
+ struct instr_blockop {
+ QML_V4_INSTR_HEADER
+ quint32 block;
+ };
+
+ instr_common common;
+ instr_id id;
+ instr_init init;
+ instr_subscribeop subscribeop;
+ instr_load load;
+ instr_attached attached;
+ instr_store store;
+ instr_storetest storetest;
+ instr_fetchAndSubscribe fetchAndSubscribe;
+ instr_fetch fetch;
+ instr_copy copy;
+ instr_construct construct;
+ instr_real_value real_value;
+ instr_int_value int_value;
+ instr_bool_value bool_value;
+ instr_string_value string_value;
+ instr_binaryop binaryop;
+ instr_unaryop unaryop;
+ instr_jump jump;
+ instr_find find;
+ instr_cleanup cleanup;
+ instr_initstring initstring;
+ instr_branchop branchop;
+ instr_blockop blockop;
+};
+
+template<int N>
+struct V4InstrMeta {
+};
+
+#define QML_V4_INSTR_META_TEMPLATE(I, FMT) \
+ template<> struct V4InstrMeta<(int)V4Instr::I> { \
+ enum { Size = QML_V4_INSTR_SIZE(I, FMT) }; \
+ typedef V4Instr::instr_##FMT DataType; \
+ static const DataType &data(const V4Instr &instr) { return instr.FMT; } \
+ static void setData(V4Instr &instr, const DataType &v) { instr.FMT = v; } \
+ };
+FOR_EACH_V4_INSTR(QML_V4_INSTR_META_TEMPLATE);
+#undef QML_V4_INSTR_META_TEMPLATE
+
+template<int Instr>
+class V4InstrData : public V4InstrMeta<Instr>::DataType
+{
+};
+
+class Bytecode
+{
+ Q_DISABLE_COPY(Bytecode)
+
+public:
+ Bytecode();
+
+ const char *constData() const { return d.constData(); }
+ int size() const { return d.size(); }
+ int count() const { return d.count(); }
+ void clear() { d.clear(); }
+ bool isEmpty() const { return d.isEmpty(); }
+ V4Instr::Type instructionType(const V4Instr *instr) const;
+
+ template <int Instr>
+ void append(const V4InstrData<Instr> &data)
+ {
+ V4Instr genericInstr;
+ V4InstrMeta<Instr>::setData(genericInstr, data);
+ return append(static_cast<V4Instr::Type>(Instr), genericInstr);
+ }
+ void append(V4Instr::Type type, V4Instr &instr);
+
+ int remove(int index);
+
+ const V4Instr &operator[](int offset) const;
+ V4Instr &operator[](int offset);
+
+ void dump(const char *start, const char *end) const;
+
+private:
+ void dump(const V4Instr *instr, int = -1) const;
+
+ QVarLengthArray<char, 4 * 1024> d;
+#ifdef QML_THREADED_INTERPRETER
+ void **decodeInstr;
+#endif
+};
+
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV4INSTRUCTION_P_H
+
diff --git a/src/qml/qml/v4/qv4ir.cpp b/src/qml/qml/v4/qv4ir.cpp
new file mode 100644
index 0000000000..3b33898cd1
--- /dev/null
+++ b/src/qml/qml/v4/qv4ir.cpp
@@ -0,0 +1,883 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4ir_p.h"
+
+#include <QtCore/qtextstream.h>
+#include <QtCore/qdebug.h>
+#include <math.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QQmlJS {
+namespace IR {
+
+inline const char *typeName(Type t)
+{
+ switch (t) {
+ case InvalidType: return "invalid";
+ case UndefinedType: return "undefined";
+ case NullType: return "null";
+ case VoidType: return "void";
+ case StringType: return "string";
+ case UrlType: return "url";
+ case ColorType: return "color";
+ case SGAnchorLineType: return "SGAnchorLine";
+ case AttachType: return "AttachType";
+ case ObjectType: return "object";
+ case BoolType: return "bool";
+ case IntType: return "int";
+ case RealType: return "qreal";
+ case RealNaNType: return "NaN";
+ default: return "invalid";
+ }
+}
+
+inline bool isNumberType(IR::Type ty)
+{
+ return ty >= IR::FirstNumberType;
+}
+
+inline bool isStringType(IR::Type ty)
+{
+ return ty == IR::StringType || ty == IR::UrlType || ty == IR::ColorType;
+}
+
+IR::Type maxType(IR::Type left, IR::Type right)
+{
+ if (isStringType(left) && isStringType(right)) {
+ // String promotions (url to string) are more specific than
+ // identity conversions (AKA left == right). That's because
+ // we want to ensure we convert urls to strings in binary
+ // expressions.
+ return IR::StringType;
+ } else if (left == right)
+ return left;
+ else if (isNumberType(left) && isNumberType(right))
+ return qMax(left, right);
+ else if ((isNumberType(left) && isStringType(right)) ||
+ (isNumberType(right) && isStringType(left)))
+ return IR::StringType;
+ else
+ return IR::InvalidType;
+}
+
+
+const char *opname(AluOp op)
+{
+ switch (op) {
+ case OpInvalid: return "?";
+
+ case OpIfTrue: return "(bool)";
+ case OpNot: return "!";
+ case OpUMinus: return "-";
+ case OpUPlus: return "+";
+ case OpCompl: return "~";
+
+ case OpBitAnd: return "&";
+ case OpBitOr: return "|";
+ case OpBitXor: return "^";
+
+ case OpAdd: return "+";
+ case OpSub: return "-";
+ case OpMul: return "*";
+ case OpDiv: return "/";
+ case OpMod: return "%";
+
+ case OpLShift: return "<<";
+ case OpRShift: return ">>";
+ case OpURShift: return ">>>";
+
+ case OpGt: return ">";
+ case OpLt: return "<";
+ case OpGe: return ">=";
+ case OpLe: return "<=";
+ case OpEqual: return "==";
+ case OpNotEqual: return "!=";
+ case OpStrictEqual: return "===";
+ case OpStrictNotEqual: return "!==";
+
+ case OpAnd: return "&&";
+ case OpOr: return "||";
+
+ default: return "?";
+
+ } // switch
+}
+
+AluOp binaryOperator(int op)
+{
+ switch (static_cast<QSOperator::Op>(op)) {
+ case QSOperator::Add: return OpAdd;
+ case QSOperator::And: return OpAnd;
+ case QSOperator::BitAnd: return OpBitAnd;
+ case QSOperator::BitOr: return OpBitOr;
+ case QSOperator::BitXor: return OpBitXor;
+ case QSOperator::Div: return OpDiv;
+ case QSOperator::Equal: return OpEqual;
+ case QSOperator::Ge: return OpGe;
+ case QSOperator::Gt: return OpGt;
+ case QSOperator::Le: return OpLe;
+ case QSOperator::LShift: return OpLShift;
+ case QSOperator::Lt: return OpLt;
+ case QSOperator::Mod: return OpMod;
+ case QSOperator::Mul: return OpMul;
+ case QSOperator::NotEqual: return OpNotEqual;
+ case QSOperator::Or: return OpOr;
+ case QSOperator::RShift: return OpRShift;
+ case QSOperator::StrictEqual: return OpStrictEqual;
+ case QSOperator::StrictNotEqual: return OpStrictNotEqual;
+ case QSOperator::Sub: return OpSub;
+ case QSOperator::URShift: return OpURShift;
+ default: return OpInvalid;
+ }
+}
+
+void Const::dump(QTextStream &out)
+{
+ out << value;
+}
+
+void String::dump(QTextStream &out)
+{
+ out << '"' << escape(value) << '"';
+}
+
+QString String::escape(const QStringRef &s)
+{
+ QString r;
+ for (int i = 0; i < s.length(); ++i) {
+ const QChar ch = s.at(i);
+ if (ch == QLatin1Char('\n'))
+ r += QLatin1String("\\n");
+ else if (ch == QLatin1Char('\r'))
+ r += QLatin1String("\\r");
+ else if (ch == QLatin1Char('\\'))
+ r += QLatin1String("\\\\");
+ else if (ch == QLatin1Char('"'))
+ r += QLatin1String("\\\"");
+ else if (ch == QLatin1Char('\''))
+ r += QLatin1String("\\'");
+ else
+ r += ch;
+ }
+ return r;
+}
+
+void Name::init(Name *base, Type type, const QString *id, Symbol symbol, quint32 line, quint32 column)
+{
+ this->type = type;
+ this->base = base;
+ this->id = id;
+ this->symbol = symbol;
+ this->ptr = 0;
+ this->property = 0;
+ this->storage = MemberStorage;
+ this->builtin = NoBuiltinSymbol;
+ this->line = line;
+ this->column = column;
+
+ if (id->length() == 8 && *id == QLatin1String("Math.sin")) {
+ builtin = MathSinBultinFunction;
+ } else if (id->length() == 8 && *id == QLatin1String("Math.cos")) {
+ builtin = MathCosBultinFunction;
+ } else if (id->length() == 10 && *id == QLatin1String("Math.round")) {
+ builtin = MathRoundBultinFunction;
+ } else if (id->length() == 10 && *id == QLatin1String("Math.floor)")) {
+ builtin = MathFloorBultinFunction;
+ } else if (id->length() == 7 && *id == QLatin1String("Math.PI")) {
+ builtin = MathPIBuiltinConstant;
+ this->type = RealType;
+ }
+}
+
+void Name::dump(QTextStream &out)
+{
+ if (base) {
+ base->dump(out);
+ out << '.';
+ }
+
+ out << *id;
+}
+
+void Temp::dump(QTextStream &out)
+{
+ out << 't' << index;
+}
+
+void Unop::dump(QTextStream &out)
+{
+ out << opname(op);
+ expr->dump(out);
+}
+
+Type Unop::typeForOp(AluOp op, Expr *expr)
+{
+ switch (op) {
+ case OpIfTrue: return BoolType;
+ case OpNot: return BoolType;
+
+ case OpUMinus:
+ case OpUPlus:
+ case OpCompl:
+ return maxType(expr->type, RealType);
+
+ default:
+ break;
+ }
+
+ return InvalidType;
+}
+
+void Binop::dump(QTextStream &out)
+{
+ left->dump(out);
+ out << ' ' << opname(op) << ' ';
+ right->dump(out);
+}
+
+Type Binop::typeForOp(AluOp op, Expr *left, Expr *right)
+{
+ if (! (left && right))
+ return InvalidType;
+
+ switch (op) {
+ case OpInvalid:
+ return InvalidType;
+
+ // unary operators
+ case OpIfTrue:
+ case OpNot:
+ case OpUMinus:
+ case OpUPlus:
+ case OpCompl:
+ return InvalidType;
+
+ // bit fields
+ case OpBitAnd:
+ case OpBitOr:
+ case OpBitXor:
+ return IntType;
+
+ case OpAdd:
+ if (left->type == StringType)
+ return StringType;
+ return RealType;
+
+ case OpSub:
+ case OpMul:
+ case OpDiv:
+ case OpMod:
+ return RealType;
+
+ case OpLShift:
+ case OpRShift:
+ case OpURShift:
+ return IntType;
+
+ case OpAnd:
+ case OpOr:
+ return BoolType;
+
+ case OpGt:
+ case OpLt:
+ case OpGe:
+ case OpLe:
+ case OpEqual:
+ case OpNotEqual:
+ case OpStrictEqual:
+ case OpStrictNotEqual:
+ return BoolType;
+ } // switch
+
+ return InvalidType;
+}
+
+void Call::dump(QTextStream &out)
+{
+ base->dump(out);
+ out << '(';
+ for (ExprList *it = args; it; it = it->next) {
+ if (it != args)
+ out << ", ";
+ it->expr->dump(out);
+ }
+ out << ')';
+}
+
+Type Call::typeForFunction(Expr *base)
+{
+ if (! base)
+ return InvalidType;
+
+ if (Name *name = base->asName()) {
+ switch (name->builtin) {
+ case MathSinBultinFunction:
+ case MathCosBultinFunction:
+ return RealType;
+
+ case MathRoundBultinFunction:
+ case MathFloorBultinFunction:
+ return IntType;
+
+ case NoBuiltinSymbol:
+ case MathPIBuiltinConstant:
+ break;
+ }
+ } // switch
+
+ return InvalidType;
+}
+
+void Exp::dump(QTextStream &out, Mode)
+{
+ out << "(void) ";
+ expr->dump(out);
+ out << ';';
+}
+
+void Move::dump(QTextStream &out, Mode)
+{
+ target->dump(out);
+ out << " = ";
+ if (source->type != target->type)
+ out << typeName(source->type) << "_to_" << typeName(target->type) << '(';
+ source->dump(out);
+ if (source->type != target->type)
+ out << ')';
+ out << ';';
+}
+
+void Jump::dump(QTextStream &out, Mode mode)
+{
+ Q_UNUSED(mode);
+ out << "goto " << 'L' << target << ';';
+}
+
+void CJump::dump(QTextStream &out, Mode mode)
+{
+ Q_UNUSED(mode);
+ out << "if (";
+ cond->dump(out);
+ out << ") goto " << 'L' << iftrue << "; else goto " << 'L' << iffalse << ';';
+}
+
+void Ret::dump(QTextStream &out, Mode)
+{
+ out << "return";
+ if (expr) {
+ out << ' ';
+ expr->dump(out);
+ }
+ out << ';';
+}
+
+Function::~Function()
+{
+ qDeleteAll(basicBlocks);
+}
+
+QString *Function::newString(const QString &text)
+{
+ return pool->NewString(text);
+}
+
+BasicBlock *Function::newBasicBlock()
+{
+ const int index = basicBlocks.size();
+ return i(new BasicBlock(this, index));
+}
+
+void Function::dump(QTextStream &out)
+{
+ out << "function () {" << endl;
+ foreach (BasicBlock *bb, basicBlocks) {
+ bb->dump(out);
+ }
+ out << '}' << endl;
+}
+
+Temp *BasicBlock::TEMP(Type type, int index)
+{
+ Temp *e = function->pool->New<Temp>();
+ e->init(type, index);
+ return e;
+}
+
+Temp *BasicBlock::TEMP(Type type)
+{
+ return TEMP(type, function->tempCount++);
+}
+
+Expr *BasicBlock::CONST(double value)
+{
+ return CONST(IR::RealType, value);
+}
+
+Expr *BasicBlock::CONST(Type type, double value)
+{
+ Const *e = function->pool->New<Const>();
+ e->init(type, value);
+ return e;
+}
+
+Expr *BasicBlock::STRING(const QStringRef &value)
+{
+ String *e = function->pool->New<String>();
+ e->init(value);
+ return e;
+}
+
+Name *BasicBlock::NAME(const QString &id, quint32 line, quint32 column)
+{
+ return NAME(0, id, line, column);
+}
+
+Name *BasicBlock::NAME(Name *base, const QString &id, quint32 line, quint32 column)
+{
+ Name *e = function->pool->New<Name>();
+ e->init(base, InvalidType,
+ function->newString(id),
+ Name::Unbound, line, column);
+ return e;
+}
+
+Name *BasicBlock::SYMBOL(Type type, const QString &id, const QMetaObject *meta, QQmlPropertyData *property, Name::Storage storage,
+ quint32 line, quint32 column)
+{
+ Name *name = SYMBOL(/*base = */ 0, type, id, meta, property, line, column);
+ name->storage = storage;
+ return name;
+}
+
+Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QQmlPropertyData *property, Name::Storage storage,
+ quint32 line, quint32 column)
+{
+ Name *name = function->pool->New<Name>();
+ name->init(base, type, function->newString(id),
+ Name::Property, line, column);
+ name->meta = meta;
+ name->property = property;
+ name->storage = storage;
+ return name;
+}
+
+Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QQmlPropertyData *property,
+ quint32 line, quint32 column)
+{
+ Name *name = function->pool->New<Name>();
+ name->init(base, type, function->newString(id),
+ Name::Property, line, column);
+ name->meta = meta;
+ name->property = property;
+ return name;
+}
+
+Name *BasicBlock::ID_OBJECT(const QString &id, const QQmlScript::Object *object, quint32 line, quint32 column)
+{
+ Name *name = function->pool->New<Name>();
+ name->init(/*base = */ 0, IR::ObjectType,
+ function->newString(id),
+ Name::IdObject, line, column);
+ name->idObject = object;
+ name->property = 0;
+ name->storage = Name::IdStorage;
+ return name;
+}
+
+Name *BasicBlock::ATTACH_TYPE(const QString &id, const QQmlType *attachType, Name::Storage storage,
+ quint32 line, quint32 column)
+{
+ Name *name = function->pool->New<Name>();
+ name->init(/*base = */ 0, IR::AttachType,
+ function->newString(id),
+ Name::AttachType, line, column);
+ name->declarativeType = attachType;
+ name->storage = storage;
+ return name;
+}
+
+
+Expr *BasicBlock::UNOP(AluOp op, Expr *expr)
+{
+ Unop *e = function->pool->New<Unop>();
+ e->init(op, expr);
+ return e;
+}
+
+Expr *BasicBlock::BINOP(AluOp op, Expr *left, Expr *right)
+{
+ if (left && right) {
+ if (Const *c1 = left->asConst()) {
+ if (Const *c2 = right->asConst()) {
+ switch (op) {
+ case OpAdd: return CONST(c1->value + c2->value);
+ case OpAnd: return CONST(c1->value ? c2->value : 0);
+ case OpBitAnd: return CONST(int(c1->value) & int(c2->value));
+ case OpBitOr: return CONST(int(c1->value) | int(c2->value));
+ case OpBitXor: return CONST(int(c1->value) ^ int(c2->value));
+ case OpDiv: return CONST(c1->value / c2->value);
+ case OpEqual: return CONST(c1->value == c2->value);
+ case OpGe: return CONST(c1->value >= c2->value);
+ case OpGt: return CONST(c1->value > c2->value);
+ case OpLe: return CONST(c1->value <= c2->value);
+ case OpLShift: return CONST(int(c1->value) << int(c2->value));
+ case OpLt: return CONST(c1->value < c2->value);
+ case OpMod: return CONST(::fmod(c1->value, c2->value));
+ case OpMul: return CONST(c1->value * c2->value);
+ case OpNotEqual: return CONST(c1->value != c2->value);
+ case OpOr: return CONST(c1->value ? c1->value : c2->value);
+ case OpRShift: return CONST(int(c1->value) >> int(c2->value));
+ case OpStrictEqual: return CONST(c1->value == c2->value);
+ case OpStrictNotEqual: return CONST(c1->value != c2->value);
+ case OpSub: return CONST(c1->value - c2->value);
+ case OpURShift: return CONST(unsigned(c1->value) >> int(c2->value));
+
+ case OpIfTrue: // unary ops
+ case OpNot:
+ case OpUMinus:
+ case OpUPlus:
+ case OpCompl:
+ case OpInvalid:
+ break;
+ }
+ }
+ }
+ }
+
+ Binop *e = function->pool->New<Binop>();
+ e->init(op, left, right);
+ return e;
+}
+
+Expr *BasicBlock::CALL(Expr *base, ExprList *args)
+{
+ Call *e = function->pool->New<Call>();
+ e->init(base, args);
+ return e;
+}
+
+Stmt *BasicBlock::EXP(Expr *expr)
+{
+ Exp *s = function->pool->New<Exp>();
+ s->init(expr);
+ statements.append(s);
+ return s;
+}
+
+Stmt *BasicBlock::MOVE(Expr *target, Expr *source, bool isMoveForReturn)
+{
+ Move *s = function->pool->New<Move>();
+ s->init(target, source, isMoveForReturn);
+ statements.append(s);
+ return s;
+}
+
+Stmt *BasicBlock::JUMP(BasicBlock *target)
+{
+ if (isTerminated())
+ return 0;
+
+ Jump *s = function->pool->New<Jump>();
+ s->init(target);
+ statements.append(s);
+ return s;
+}
+
+Stmt *BasicBlock::CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
+{
+ if (isTerminated())
+ return 0;
+
+ CJump *s = function->pool->New<CJump>();
+ s->init(cond, iftrue, iffalse);
+ statements.append(s);
+ return s;
+}
+
+Stmt *BasicBlock::RET(Expr *expr, Type type, quint32 line, quint32 column)
+{
+ if (isTerminated())
+ return 0;
+
+ Ret *s = function->pool->New<Ret>();
+ s->init(expr, type, line, column);
+ statements.append(s);
+ return s;
+}
+
+void BasicBlock::dump(QTextStream &out)
+{
+ out << 'L' << this << ':' << endl;
+ foreach (Stmt *s, statements) {
+ out << '\t';
+ s->dump(out);
+ out << endl;
+ }
+}
+
+#ifdef DEBUG_IR_STRUCTURE
+
+static const char *symbolname(Name::Symbol s)
+{
+ switch (s) {
+ case Name::Unbound:
+ return "Unbound";
+ case Name::IdObject:
+ return "IdObject";
+ case Name::AttachType:
+ return "AttachType";
+ case Name::Object:
+ return "Object";
+ case Name::Property:
+ return "Property";
+ case Name::Slot:
+ return "Slot";
+ default:
+ Q_ASSERT(!"Unreachable");
+ return "Unknown";
+ }
+}
+
+static const char *storagename(Name::Storage s)
+{
+ switch (s) {
+ case Name::MemberStorage:
+ return "MemberStorage";
+ case Name::IdStorage:
+ return "IdStorage";
+ case Name::RootStorage:
+ return "RootStorage";
+ case Name::ScopeStorage:
+ return "ScopeStorage";
+ default:
+ Q_ASSERT(!"Unreachable");
+ return "UnknownStorage";
+ }
+}
+
+IRDump::IRDump()
+: indentSize(0)
+{
+}
+
+void IRDump::inc()
+{
+ indentSize++;
+ indentData = QByteArray(indentSize * 4, ' ');
+}
+
+void IRDump::dec()
+{
+ indentSize--;
+ indentData = QByteArray(indentSize * 4, ' ');
+}
+
+void IRDump::dec();
+
+void IRDump::expression(QQmlJS::IR::Expr *e)
+{
+ inc();
+
+ e->accept(this);
+
+ dec();
+}
+
+void IRDump::basicblock(QQmlJS::IR::BasicBlock *b)
+{
+ inc();
+
+ qWarning().nospace() << indent() << "BasicBlock " << b << " {";
+ for (int ii = 0; ii < b->statements.count(); ++ii) {
+ statement(b->statements.at(ii));
+ if (ii != (b->statements.count() - 1))
+ qWarning();
+ }
+ qWarning().nospace() << indent() << "}";
+
+ dec();
+}
+
+void IRDump::statement(QQmlJS::IR::Stmt *s)
+{
+ inc();
+
+ s->accept(this);
+
+ dec();
+}
+
+void IRDump::function(QQmlJS::IR::Function *f)
+{
+ inc();
+
+ qWarning().nospace() << indent() << "Function {";
+ for (int ii = 0; ii < f->basicBlocks.count(); ++ii) {
+ basicblock(f->basicBlocks.at(ii));
+ }
+ qWarning().nospace() << indent() << "}";
+
+ dec();
+}
+
+const char *IRDump::indent()
+{
+ return indentData.constData();
+}
+
+void IRDump::visitConst(QQmlJS::IR::Const *e)
+{
+ qWarning().nospace() << indent() << "Const:Expr { type: " << typeName(e->type) << ", value: " << e->value << "}";
+}
+
+void IRDump::visitString(QQmlJS::IR::String *e)
+{
+ qWarning().nospace() << indent() << "String:Expr { type: " << typeName(e->type) << ", value: " << e->value << "}";
+}
+
+static void namedumprecur(QQmlJS::IR::Name *e, const char *indent)
+{
+ if (e->base) namedumprecur(e->base, indent);
+ qWarning().nospace() << indent << " { type: " << typeName(e->type) << ", symbol: " << symbolname(e->symbol) << ", storage: " << storagename(e->storage) << ", id: " << e->id << "}";
+}
+
+void IRDump::visitName(QQmlJS::IR::Name *e)
+{
+ qWarning().nospace() << indent() << "Name:Expr {";
+ namedumprecur(e, indent());
+ qWarning().nospace() << indent() << "}";
+}
+
+void IRDump::visitTemp(QQmlJS::IR::Temp *e)
+{
+ qWarning().nospace() << indent() << "Temp:Expr { type: " << typeName(e->type) << ", index: " << e->index << " }";
+}
+
+void IRDump::visitUnop(QQmlJS::IR::Unop *e)
+{
+ qWarning().nospace() << indent() << "Unop:Expr { ";
+ qWarning().nospace() << indent() << " type: " << typeName(e->type) << ", op: " << opname(e->op);
+ qWarning().nospace() << indent() << " expr: {";
+ expression(e->expr);
+ qWarning().nospace() << indent() << " }";
+ qWarning().nospace() << indent() << "}";
+}
+
+void IRDump::visitBinop(QQmlJS::IR::Binop *e)
+{
+ qWarning().nospace() << indent() << "Binop:Expr { ";
+ qWarning().nospace() << indent() << " type: " << typeName(e->type) << ", op: " << opname(e->op);
+ qWarning().nospace() << indent() << " left: {";
+ inc();
+ expression(e->left);
+ dec();
+ qWarning().nospace() << indent() << " },";
+ qWarning().nospace() << indent() << " right: {";
+ inc();
+ expression(e->right);
+ dec();
+ qWarning().nospace() << indent() << " }";
+ qWarning().nospace() << indent() << "}";
+}
+
+void IRDump::visitCall(QQmlJS::IR::Call *e)
+{
+ Q_UNUSED(e);
+ qWarning().nospace() << indent() << "Exp::Call { }";
+}
+
+void IRDump::visitExp(QQmlJS::IR::Exp *s)
+{
+ qWarning().nospace() << indent() << "Exp:Stmt {";
+ expression(s->expr);
+ qWarning().nospace() << indent() << "}";
+}
+
+void IRDump::visitMove(QQmlJS::IR::Move *s)
+{
+ qWarning().nospace() << indent() << "Move:Stmt {";
+ qWarning().nospace() << indent() << " isMoveForReturn: " << s->isMoveForReturn;
+ qWarning().nospace() << indent() << " target: {";
+ inc();
+ expression(s->target);
+ dec();
+ qWarning().nospace() << indent() << " },";
+ qWarning().nospace() << indent() << " source: {";
+ inc();
+ expression(s->source);
+ dec();
+ qWarning().nospace() << indent() << " }";
+ qWarning().nospace() << indent() << "}";
+}
+
+void IRDump::visitJump(QQmlJS::IR::Jump *s)
+{
+ qWarning().nospace() << indent() << "Jump:Stmt { BasicBlock(" << s->target << ") }";
+}
+
+void IRDump::visitCJump(QQmlJS::IR::CJump *s)
+{
+ qWarning().nospace() << indent() << "CJump:Stmt {";
+ qWarning().nospace() << indent() << " cond: {";
+ inc();
+ expression(s->cond);
+ dec();
+ qWarning().nospace() << indent() << " }";
+ qWarning().nospace() << indent() << " iftrue: BasicBlock(" << s->iftrue << ")";
+ qWarning().nospace() << indent() << " iffalse: BasicBlock(" << s->iffalse << ")";
+ qWarning().nospace() << indent() << "}";
+}
+
+void IRDump::visitRet(QQmlJS::IR::Ret *s)
+{
+ qWarning().nospace() << indent() << "Ret:Stmt {";
+ qWarning().nospace() << indent() << " type: " << typeName(s->type);
+ expression(s->expr);
+ qWarning().nospace() << indent() << "}";
+}
+#endif
+
+} // end of namespace IR
+} // end of namespace QQmlJS
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4ir_p.h b/src/qml/qml/v4/qv4ir_p.h
new file mode 100644
index 0000000000..e80c7e2869
--- /dev/null
+++ b/src/qml/qml/v4/qv4ir_p.h
@@ -0,0 +1,605 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4IR_P_H
+#define QV4IR_P_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 <private/qqmljsast_p.h>
+#include <private/qqmljsengine_p.h>
+#include <private/qqmlscript_p.h>
+#include <private/qqmlimport_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qv4compiler_p.h>
+
+#include <private/qqmlpool_p.h>
+#include <QtCore/qvarlengtharray.h>
+
+// #define DEBUG_IR_STRUCTURE
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QTextStream;
+class QQmlType;
+
+namespace QQmlJS {
+
+namespace IR {
+
+struct BasicBlock;
+struct Function;
+
+struct Stmt;
+struct Expr;
+
+// expressions
+struct Const;
+struct String;
+struct Name;
+struct Temp;
+struct Unop;
+struct Binop;
+struct Call;
+
+// statements
+struct Exp;
+struct Move;
+struct Jump;
+struct CJump;
+struct Ret;
+
+enum AluOp {
+ OpInvalid = 0,
+
+ OpIfTrue,
+ OpNot,
+ OpUMinus,
+ OpUPlus,
+ OpCompl,
+
+ OpBitAnd,
+ OpBitOr,
+ OpBitXor,
+
+ OpAdd,
+ OpSub,
+ OpMul,
+ OpDiv,
+ OpMod,
+
+ OpLShift,
+ OpRShift,
+ OpURShift,
+
+ OpGt,
+ OpLt,
+ OpGe,
+ OpLe,
+ OpEqual,
+ OpNotEqual,
+ OpStrictEqual,
+ OpStrictNotEqual,
+
+ OpAnd,
+ OpOr
+};
+AluOp binaryOperator(int op);
+
+enum Type {
+ InvalidType,
+ UndefinedType,
+ NullType,
+ VoidType,
+ StringType,
+ UrlType,
+ ColorType,
+ SGAnchorLineType,
+ AttachType,
+ ObjectType,
+
+ FirstNumberType,
+ BoolType = FirstNumberType,
+ IntType,
+ RealType,
+ RealNaNType
+};
+Type maxType(IR::Type left, IR::Type right);
+
+struct ExprVisitor {
+ virtual ~ExprVisitor() {}
+ virtual void visitConst(Const *) {}
+ virtual void visitString(String *) {}
+ virtual void visitName(Name *) {}
+ virtual void visitTemp(Temp *) {}
+ virtual void visitUnop(Unop *) {}
+ virtual void visitBinop(Binop *) {}
+ virtual void visitCall(Call *) {}
+};
+
+struct StmtVisitor {
+ virtual ~StmtVisitor() {}
+ virtual void visitExp(Exp *) {}
+ virtual void visitMove(Move *) {}
+ virtual void visitJump(Jump *) {}
+ virtual void visitCJump(CJump *) {}
+ virtual void visitRet(Ret *) {}
+};
+
+struct Expr: QQmlPool::POD {
+ Type type;
+
+ Expr(): type(InvalidType) {}
+ virtual ~Expr() {}
+ virtual void accept(ExprVisitor *) = 0;
+ virtual Const *asConst() { return 0; }
+ virtual String *asString() { return 0; }
+ virtual Name *asName() { return 0; }
+ virtual Temp *asTemp() { return 0; }
+ virtual Unop *asUnop() { return 0; }
+ virtual Binop *asBinop() { return 0; }
+ virtual Call *asCall() { return 0; }
+ virtual void dump(QTextStream &out) = 0;
+};
+
+struct ExprList: QQmlPool::POD {
+ Expr *expr;
+ ExprList *next;
+
+ void init(Expr *expr, ExprList *next = 0)
+ {
+ this->expr = expr;
+ this->next = next;
+ }
+};
+
+struct Const: Expr {
+ double value;
+
+ void init(Type type, double value)
+ {
+ this->type = type;
+ this->value = value;
+ }
+
+ virtual void accept(ExprVisitor *v) { v->visitConst(this); }
+ virtual Const *asConst() { return this; }
+
+ virtual void dump(QTextStream &out);
+};
+
+struct String: Expr {
+ QStringRef value;
+
+ void init(const QStringRef &value)
+ {
+ this->type = StringType;
+ this->value = value;
+ }
+
+ virtual void accept(ExprVisitor *v) { v->visitString(this); }
+ virtual String *asString() { return this; }
+
+ virtual void dump(QTextStream &out);
+ static QString escape(const QStringRef &s);
+};
+
+enum BuiltinSymbol {
+ NoBuiltinSymbol,
+ MathSinBultinFunction,
+ MathCosBultinFunction,
+ MathRoundBultinFunction,
+ MathFloorBultinFunction,
+
+ MathPIBuiltinConstant
+};
+
+struct Name: Expr {
+ enum Symbol {
+ Unbound,
+ IdObject, // This is a load of a id object. Storage will always be IdStorage
+ AttachType, // This is a load of an attached object
+ Object, // XXX what is this for?
+ Property, // This is a load of a regular property
+ Slot // XXX what is this for?
+ };
+
+ enum Storage {
+ MemberStorage, // This is a property of a previously fetched object
+ IdStorage, // This is a load of a id object. Symbol will always be IdObject
+ RootStorage, // This is a property of the root object
+ ScopeStorage // This is a property of the scope object
+ };
+
+ Name *base;
+ const QString *id;
+ Symbol symbol;
+ union {
+ void *ptr;
+ const QMetaObject *meta;
+ const QQmlType *declarativeType;
+ const QQmlScript::Object *idObject;
+ };
+ QQmlPropertyData *property;
+ Storage storage;
+ BuiltinSymbol builtin;
+ quint32 line;
+ quint32 column;
+
+ void init(Name *base, Type type, const QString *id, Symbol symbol, quint32 line, quint32 column);
+
+ inline bool is(Symbol s) const { return s == symbol; }
+ inline bool isNot(Symbol s) const { return s != symbol; }
+
+ virtual void accept(ExprVisitor *v) { v->visitName(this); }
+ virtual Name *asName() { return this; }
+
+ virtual void dump(QTextStream &out);
+};
+
+struct Temp: Expr {
+ int index;
+
+ void init(Type type, int index)
+ {
+ this->type = type;
+ this->index = index;
+ }
+
+ virtual void accept(ExprVisitor *v) { v->visitTemp(this); }
+ virtual Temp *asTemp() { return this; }
+
+ virtual void dump(QTextStream &out);
+};
+
+struct Unop: Expr {
+ AluOp op;
+ Expr *expr;
+
+ void init(AluOp op, Expr *expr)
+ {
+ this->type = this->typeForOp(op, expr);
+ this->op = op;
+ this->expr = expr;
+ }
+
+ virtual void accept(ExprVisitor *v) { v->visitUnop(this); }
+ virtual Unop *asUnop() { return this; }
+
+ virtual void dump(QTextStream &out);
+
+private:
+ static Type typeForOp(AluOp op, Expr *expr);
+};
+
+struct Binop: Expr {
+ AluOp op;
+ Expr *left;
+ Expr *right;
+
+ void init(AluOp op, Expr *left, Expr *right)
+ {
+ this->type = typeForOp(op, left, right);
+ this->op = op;
+ this->left = left;
+ this->right = right;
+ }
+
+ virtual void accept(ExprVisitor *v) { v->visitBinop(this); }
+ virtual Binop *asBinop() { return this; }
+
+ virtual void dump(QTextStream &out);
+
+private:
+ static Type typeForOp(AluOp op, Expr *left, Expr *right);
+};
+
+struct Call: Expr {
+ Expr *base;
+ ExprList *args;
+
+ void init(Expr *base, ExprList *args)
+ {
+ this->type = typeForFunction(base);
+ this->base = base;
+ this->args = args;
+ }
+
+ Expr *onlyArgument() const {
+ if (args && ! args->next)
+ return args->expr;
+ return 0;
+ }
+
+ virtual void accept(ExprVisitor *v) { v->visitCall(this); }
+ virtual Call *asCall() { return this; }
+
+ virtual void dump(QTextStream &out);
+
+private:
+ static Type typeForFunction(Expr *base);
+};
+
+struct Stmt: QQmlPool::POD {
+ enum Mode {
+ HIR,
+ MIR
+ };
+
+ virtual ~Stmt() {}
+ virtual Stmt *asTerminator() { return 0; }
+
+ virtual void accept(StmtVisitor *) = 0;
+ virtual Exp *asExp() { return 0; }
+ virtual Move *asMove() { return 0; }
+ virtual Jump *asJump() { return 0; }
+ virtual CJump *asCJump() { return 0; }
+ virtual Ret *asRet() { return 0; }
+ virtual void dump(QTextStream &out, Mode mode = HIR) = 0;
+};
+
+struct Exp: Stmt {
+ Expr *expr;
+
+ void init(Expr *expr)
+ {
+ this->expr = expr;
+ }
+
+ virtual void accept(StmtVisitor *v) { v->visitExp(this); }
+ virtual Exp *asExp() { return this; }
+
+ virtual void dump(QTextStream &out, Mode);
+};
+
+struct Move: Stmt {
+ Expr *target;
+ Expr *source;
+ bool isMoveForReturn;
+
+ void init(Expr *target, Expr *source, bool isMoveForReturn)
+ {
+ this->target = target;
+ this->source = source;
+ this->isMoveForReturn = isMoveForReturn;
+ }
+
+ virtual void accept(StmtVisitor *v) { v->visitMove(this); }
+ virtual Move *asMove() { return this; }
+
+ virtual void dump(QTextStream &out, Mode);
+};
+
+struct Jump: Stmt {
+ BasicBlock *target;
+
+ void init(BasicBlock *target)
+ {
+ this->target = target;
+ }
+
+ virtual Stmt *asTerminator() { return this; }
+
+ virtual void accept(StmtVisitor *v) { v->visitJump(this); }
+ virtual Jump *asJump() { return this; }
+
+ virtual void dump(QTextStream &out, Mode mode);
+};
+
+struct CJump: Stmt {
+ Expr *cond;
+ BasicBlock *iftrue;
+ BasicBlock *iffalse;
+
+ void init(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
+ {
+ this->cond = cond;
+ this->iftrue = iftrue;
+ this->iffalse = iffalse;
+ }
+
+ virtual Stmt *asTerminator() { return this; }
+
+ virtual void accept(StmtVisitor *v) { v->visitCJump(this); }
+ virtual CJump *asCJump() { return this; }
+
+ virtual void dump(QTextStream &out, Mode mode);
+};
+
+struct Ret: Stmt {
+ Expr *expr;
+ Type type;
+ quint32 line;
+ quint32 column;
+
+ void init(Expr *expr, Type type, quint32 line, quint32 column)
+ {
+ this->expr = expr;
+ this->type = type;
+ this->line = line;
+ this->column = column;
+ }
+
+ virtual Stmt *asTerminator() { return this; }
+
+ virtual void accept(StmtVisitor *v) { v->visitRet(this); }
+ virtual Ret *asRet() { return this; }
+
+ virtual void dump(QTextStream &out, Mode);
+};
+
+struct Function {
+ QQmlPool *pool;
+ QVarLengthArray<BasicBlock *, 8> basicBlocks;
+ int tempCount;
+
+ Function(QQmlPool *pool)
+ : pool(pool), tempCount(0) {}
+
+ ~Function();
+
+ BasicBlock *newBasicBlock();
+ QString *newString(const QString &text);
+
+ inline BasicBlock *i(BasicBlock *block) { basicBlocks.append(block); return block; }
+
+ virtual void dump(QTextStream &out);
+};
+
+struct BasicBlock {
+ Function *function;
+ int index;
+ int offset;
+ QVarLengthArray<Stmt *, 32> statements;
+
+ BasicBlock(Function *function, int index): function(function), index(index), offset(-1) {}
+ ~BasicBlock() {}
+
+ template <typename Instr> inline Instr i(Instr i) { statements.append(i); return i; }
+
+ inline bool isEmpty() const {
+ return statements.isEmpty();
+ }
+
+ inline Stmt *terminator() const {
+ if (! statements.isEmpty() && statements.at(statements.size() - 1)->asTerminator() != 0)
+ return statements.at(statements.size() - 1);
+ return 0;
+ }
+
+ inline bool isTerminated() const {
+ if (terminator() != 0)
+ return true;
+ return false;
+ }
+
+ Temp *TEMP(Type type, int index);
+ Temp *TEMP(Type type);
+
+ Expr *CONST(double value);
+ Expr *CONST(Type type, double value);
+ Expr *STRING(const QStringRef &value);
+
+ Name *NAME(const QString &id, quint32 line, quint32 column);
+ Name *NAME(Name *base, const QString &id, quint32 line, quint32 column);
+ Name *SYMBOL(Type type, const QString &id, const QMetaObject *meta, QQmlPropertyData *property, Name::Storage storage, quint32 line, quint32 column);
+ Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QQmlPropertyData *property, quint32 line, quint32 column);
+ Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QQmlPropertyData *property, Name::Storage storage, quint32 line, quint32 column);
+ Name *ID_OBJECT(const QString &id, const QQmlScript::Object *object, quint32 line, quint32 column);
+ Name *ATTACH_TYPE(const QString &id, const QQmlType *attachType, Name::Storage storage, quint32 line, quint32 column);
+
+ Expr *UNOP(AluOp op, Expr *expr);
+ Expr *BINOP(AluOp op, Expr *left, Expr *right);
+ Expr *CALL(Expr *base, ExprList *args);
+
+ Stmt *EXP(Expr *expr);
+ Stmt *MOVE(Expr *target, Expr *source, bool = false);
+
+ Stmt *JUMP(BasicBlock *target);
+ Stmt *CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse);
+ Stmt *RET(Expr *expr, Type type, quint32 line, quint32 column);
+
+ virtual void dump(QTextStream &out);
+};
+
+#ifdef DEBUG_IR_STRUCTURE
+struct IRDump : public ExprVisitor,
+ public StmtVisitor
+{
+public:
+ IRDump();
+
+ void expression(QQmlJS::IR::Expr *);
+ void basicblock(QQmlJS::IR::BasicBlock *);
+ void statement(QQmlJS::IR::Stmt *);
+ void function(QQmlJS::IR::Function *);
+protected:
+
+ const char *indent();
+
+ //
+ // expressions
+ //
+ virtual void visitConst(QQmlJS::IR::Const *e);
+ virtual void visitString(QQmlJS::IR::String *e);
+ virtual void visitName(QQmlJS::IR::Name *e);
+ virtual void visitTemp(QQmlJS::IR::Temp *e);
+ virtual void visitUnop(QQmlJS::IR::Unop *e);
+ virtual void visitBinop(QQmlJS::IR::Binop *e);
+ virtual void visitCall(QQmlJS::IR::Call *e);
+
+ //
+ // statements
+ //
+ virtual void visitExp(QQmlJS::IR::Exp *s);
+ virtual void visitMove(QQmlJS::IR::Move *s);
+ virtual void visitJump(QQmlJS::IR::Jump *s);
+ virtual void visitCJump(QQmlJS::IR::CJump *s);
+ virtual void visitRet(QQmlJS::IR::Ret *s);
+
+private:
+ int indentSize;
+ QByteArray indentData;
+ void inc();
+ void dec();
+};
+#endif
+
+} // end of namespace IR
+
+} // end of namespace QQmlJS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV4IR_P_H
diff --git a/src/qml/qml/v4/qv4irbuilder.cpp b/src/qml/qml/v4/qv4irbuilder.cpp
new file mode 100644
index 0000000000..0efb2686df
--- /dev/null
+++ b/src/qml/qml/v4/qv4irbuilder.cpp
@@ -0,0 +1,1306 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4irbuilder_p.h"
+#include "qv4compiler_p_p.h"
+
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmltypenamecache_p.h>
+
+DEFINE_BOOL_CONFIG_OPTION(qmlVerboseCompiler, QML_VERBOSE_COMPILER)
+
+QT_BEGIN_NAMESPACE
+
+using namespace QQmlJS;
+
+static IR::Type irTypeFromVariantType(int t, QQmlEnginePrivate *engine, const QMetaObject * /* meta */)
+{
+ switch (t) {
+ case QMetaType::Bool:
+ return IR::BoolType;
+
+ case QMetaType::Int:
+ return IR::IntType;
+
+ case QMetaType::QReal:
+ return IR::RealType;
+
+ case QMetaType::QString:
+ return IR::StringType;
+
+ case QMetaType::QUrl:
+ return IR::UrlType;
+
+ case QMetaType::QColor:
+ return IR::ColorType;
+
+ default:
+ if (t == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
+ return IR::SGAnchorLineType;
+ } else if (engine->metaObjectForType(t)) {
+ return IR::ObjectType;
+ }
+
+ return IR::InvalidType;
+ }
+}
+
+QV4IRBuilder::QV4IRBuilder(const QV4Compiler::Expression *expr,
+ QQmlEnginePrivate *engine)
+: m_expression(expr), m_engine(engine), _function(0), _block(0), _discard(false)
+{
+}
+
+bool QV4IRBuilder::operator()(QQmlJS::IR::Function *function,
+ QQmlJS::AST::Node *ast)
+{
+ bool discarded = false;
+
+ IR::BasicBlock *block = function->newBasicBlock();
+
+ qSwap(_discard, discarded);
+ qSwap(_function, function);
+ qSwap(_block, block);
+
+ ExprResult r;
+ AST::SourceLocation location;
+ if (AST::ExpressionNode *asExpr = ast->expressionCast()) {
+ r = expression(asExpr);
+ location = asExpr->firstSourceLocation();
+ } else if (AST::Statement *asStmt = ast->statementCast()) {
+ r = statement(asStmt);
+ location = asStmt->firstSourceLocation();
+ }
+
+ //_block->MOVE(_block->TEMP(IR::InvalidType), r.code);
+ if (r.code) {
+ const QMetaObject *m = 0;
+ const IR::Type targetType = irTypeFromVariantType(m_expression->property->type, m_engine, m);
+ if (targetType != r.type()) {
+ IR::Expr *x = _block->TEMP(targetType);
+ _block->MOVE(x, r, true);
+ r.code = x;
+ }
+ _block->RET(r.code, targetType, location.startLine, location.startColumn);
+ }
+
+ qSwap(_block, block);
+ qSwap(_function, function);
+ qSwap(_discard, discarded);
+
+ return !discarded;
+}
+
+bool QV4IRBuilder::buildName(QList<QStringRef> &name,
+ AST::Node *node,
+ QList<AST::ExpressionNode *> *nodes)
+{
+ if (node->kind == AST::Node::Kind_IdentifierExpression) {
+ name << static_cast<AST::IdentifierExpression*>(node)->name;
+ if (nodes) *nodes << static_cast<AST::IdentifierExpression*>(node);
+ } else if (node->kind == AST::Node::Kind_FieldMemberExpression) {
+ AST::FieldMemberExpression *expr =
+ static_cast<AST::FieldMemberExpression *>(node);
+
+ if (!buildName(name, expr->base, nodes))
+ return false;
+
+ name << expr->name;
+ if (nodes) *nodes << expr;
+ } else {
+ return false;
+ }
+
+ return true;
+}
+
+void QV4IRBuilder::discard()
+{
+ _discard = true;
+}
+
+QV4IRBuilder::ExprResult
+QV4IRBuilder::expression(AST::ExpressionNode *ast)
+{
+ ExprResult r;
+ if (ast) {
+ qSwap(_expr, r);
+ accept(ast);
+ qSwap(_expr, r);
+
+ if (r.is(IR::InvalidType))
+ discard();
+ else {
+ Q_ASSERT(r.hint == r.format);
+ }
+ }
+
+ return r;
+}
+
+void QV4IRBuilder::condition(AST::ExpressionNode *ast, IR::BasicBlock *iftrue, IR::BasicBlock *iffalse)
+{
+ if (! ast)
+ return;
+ ExprResult r(iftrue, iffalse);
+ qSwap(_expr, r);
+ accept(ast);
+ qSwap(_expr, r);
+
+ if (r.format != ExprResult::cx) {
+ if (! r.code)
+ discard();
+
+ Q_ASSERT(r.hint == ExprResult::cx);
+ Q_ASSERT(r.format == ExprResult::ex);
+
+ if (r.type() != IR::BoolType) {
+ IR::Temp *t = _block->TEMP(IR::BoolType);
+ _block->MOVE(t, r);
+ r = t;
+ }
+
+ _block->CJUMP(_block->UNOP(IR::OpIfTrue, r), iftrue, iffalse);
+ }
+}
+
+QV4IRBuilder::ExprResult
+QV4IRBuilder::statement(AST::Statement *ast)
+{
+ ExprResult r;
+ if (ast) {
+ qSwap(_expr, r);
+ accept(ast);
+ qSwap(_expr, r);
+
+ if (r.is(IR::InvalidType))
+ discard();
+ else {
+ Q_ASSERT(r.hint == r.format);
+ }
+ }
+
+ return r;
+}
+
+void QV4IRBuilder::sourceElement(AST::SourceElement *ast)
+{
+ accept(ast);
+}
+
+void QV4IRBuilder::implicitCvt(ExprResult &expr, IR::Type type)
+{
+ if (expr.type() == type)
+ return; // nothing to do
+
+ IR::Expr *x = _block->TEMP(type);
+ _block->MOVE(x, expr.code);
+ expr.code = x;
+}
+
+// QML
+bool QV4IRBuilder::visit(AST::UiProgram *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiImportList *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiImport *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiPublicMember *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiSourceElement *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiObjectDefinition *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiObjectInitializer *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiObjectBinding *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiScriptBinding *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiArrayBinding *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiObjectMemberList *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiArrayMemberList *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UiQualifiedId *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+
+// JS
+bool QV4IRBuilder::visit(AST::Program *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::SourceElements *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::FunctionSourceElement *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::StatementSourceElement *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+// object literals
+bool QV4IRBuilder::visit(AST::PropertyNameAndValueList *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::IdentifierPropertyName *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::StringLiteralPropertyName *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::NumericLiteralPropertyName *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+
+// array literals
+bool QV4IRBuilder::visit(AST::ElementList *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::Elision *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+
+// function calls
+bool QV4IRBuilder::visit(AST::ArgumentList *)
+{
+ Q_ASSERT(!"unreachable");
+ return false;
+}
+
+// expressions
+bool QV4IRBuilder::visit(AST::ObjectLiteral *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ArrayLiteral *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ThisExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::IdentifierExpression *ast)
+{
+ const quint32 line = ast->identifierToken.startLine;
+ const quint32 column = ast->identifierToken.startColumn;
+
+ const QString name = ast->name.toString();
+
+ if (name.at(0) == QLatin1Char('u') && name.length() == 9 && name == QLatin1String("undefined")) {
+ _expr.code = _block->CONST(IR::UndefinedType, 0); // ### undefined value
+ } else if (m_engine->v8engine()->illegalNames().contains(name) ) {
+ if (qmlVerboseCompiler()) qWarning() << "*** illegal symbol:" << name;
+ return false;
+ } else if (const QQmlScript::Object *obj = m_expression->ids->value(name)) {
+ IR::Name *code = _block->ID_OBJECT(name, obj, line, column);
+ if (obj == m_expression->component)
+ code->storage = IR::Name::RootStorage;
+ _expr.code = code;
+ } else {
+
+ QQmlTypeNameCache::Result r = m_expression->importCache->query(name);
+ if (r.isValid()) {
+ if (r.type) {
+ _expr.code = _block->ATTACH_TYPE(name, r.type, IR::Name::ScopeStorage, line, column);
+ }
+ // We don't support anything else
+ } else {
+ bool found = false;
+
+ if (m_expression->context != m_expression->component) {
+ // RootStorage is more efficient than ScopeStorage, so prefer that if they are the same
+ QQmlPropertyCache *cache = m_expression->context->synthCache;
+ const QMetaObject *metaObject = m_expression->context->metaObject();
+ if (!cache) cache = m_engine->cache(metaObject);
+
+ QQmlPropertyData *data = cache->property(name);
+
+ if (data && data->hasRevision()) {
+ if (qmlVerboseCompiler())
+ qWarning() << "*** versioned symbol:" << name;
+ discard();
+ return false;
+ }
+
+ if (data && !data->isFunction()) {
+ IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject);
+ _expr.code = _block->SYMBOL(irType, name, metaObject, data, IR::Name::ScopeStorage, line, column);
+ found = true;
+ }
+ }
+
+ if (!found) {
+ QQmlPropertyCache *cache = m_expression->component->synthCache;
+ const QMetaObject *metaObject = m_expression->component->metaObject();
+ if (!cache) cache = m_engine->cache(metaObject);
+
+ QQmlPropertyData *data = cache->property(name);
+
+ if (data && data->hasRevision()) {
+ if (qmlVerboseCompiler())
+ qWarning() << "*** versioned symbol:" << name;
+ discard();
+ return false;
+ }
+
+ if (data && !data->isFunction()) {
+ IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject);
+ _expr.code = _block->SYMBOL(irType, name, metaObject, data, IR::Name::RootStorage, line, column);
+ found = true;
+ }
+ }
+
+ if (!found && qmlVerboseCompiler())
+ qWarning() << "*** unknown symbol:" << name;
+ }
+ }
+
+ if (_expr.code && _expr.hint == ExprResult::cx) {
+ _expr.format = ExprResult::cx;
+
+ if (_expr.type() != IR::BoolType) {
+ IR::Temp *t = _block->TEMP(IR::BoolType);
+ _block->MOVE(t, _expr);
+ _expr.code = t;
+ }
+
+ _block->CJUMP(_expr.code, _expr.iftrue, _expr.iffalse);
+ _expr.code = 0;
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::NullExpression *)
+{
+ // ### TODO: cx format
+ _expr.code = _block->CONST(IR::NullType, 0);
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::TrueLiteral *)
+{
+ // ### TODO: cx format
+ _expr.code = _block->CONST(IR::BoolType, 1);
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::FalseLiteral *)
+{
+ // ### TODO: cx format
+ _expr.code = _block->CONST(IR::BoolType, 0);
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::StringLiteral *ast)
+{
+ // ### TODO: cx format
+ _expr.code = _block->STRING(ast->value);
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::NumericLiteral *ast)
+{
+ if (_expr.hint == ExprResult::cx) {
+ _expr.format = ExprResult::cx;
+ _block->JUMP(ast->value ? _expr.iftrue : _expr.iffalse);
+ } else {
+ _expr.code = _block->CONST(ast->value);
+ }
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::RegExpLiteral *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::NestedExpression *)
+{
+ return true; // the value of the nested expression
+}
+
+bool QV4IRBuilder::visit(AST::ArrayMemberExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast)
+{
+ if (IR::Expr *left = expression(ast->base)) {
+ if (IR::Name *baseName = left->asName()) {
+ const quint32 line = ast->identifierToken.startLine;
+ const quint32 column = ast->identifierToken.startColumn;
+
+ QString name = ast->name.toString();
+
+ switch(baseName->symbol) {
+ case IR::Name::Unbound:
+ break;
+
+ case IR::Name::AttachType:
+ if (name.at(0).isUpper()) {
+ QByteArray utf8Name = name.toUtf8();
+ const char *enumName = utf8Name.constData();
+
+ const QMetaObject *meta = baseName->declarativeType->metaObject();
+ bool found = false;
+ for (int ii = 0; !found && ii < meta->enumeratorCount(); ++ii) {
+ QMetaEnum e = meta->enumerator(ii);
+ for (int jj = 0; !found && jj < e.keyCount(); ++jj) {
+ if (0 == strcmp(e.key(jj), enumName)) {
+ found = true;
+ _expr.code = _block->CONST(IR::IntType, e.value(jj));
+ }
+ }
+ }
+
+ if (!found && qmlVerboseCompiler())
+ qWarning() << "*** unresolved enum:"
+ << (*baseName->id + QLatin1String(".") + ast->name.toString());
+ } else if(const QMetaObject *attachedMeta = baseName->declarativeType->attachedPropertiesType()) {
+ QQmlPropertyCache *cache = m_engine->cache(attachedMeta);
+ QQmlPropertyData *data = cache->property(name);
+
+ if (!data || data->isFunction())
+ return false; // Don't support methods (or non-existing properties ;)
+
+ if(!data->isFinal()) {
+ if (qmlVerboseCompiler())
+ qWarning() << "*** non-final attached property:"
+ << (*baseName->id + QLatin1String(".") + ast->name.toString());
+ return false; // We don't know enough about this property
+ }
+
+ IR::Type irType = irTypeFromVariantType(data->propType, m_engine, attachedMeta);
+ _expr.code = _block->SYMBOL(baseName, irType, name, attachedMeta, data, line, column);
+ }
+ break;
+
+ case IR::Name::IdObject: {
+ const QQmlScript::Object *idObject = baseName->idObject;
+ QQmlPropertyCache *cache =
+ idObject->synthCache?idObject->synthCache:m_engine->cache(idObject->metaObject());
+
+ QQmlPropertyData *data = cache->property(name);
+
+ if (!data || data->isFunction())
+ return false; // Don't support methods (or non-existing properties ;)
+
+ if (data->hasRevision()) {
+ if (qmlVerboseCompiler())
+ qWarning() << "*** versioned symbol:" << name;
+ discard();
+ return false;
+ }
+
+ IR::Type irType = irTypeFromVariantType(data->propType, m_engine, idObject->metaObject());
+ _expr.code = _block->SYMBOL(baseName, irType, name,
+ idObject->metaObject(), data, line, column);
+ }
+ break;
+
+ case IR::Name::Property:
+ if (baseName->type == IR::ObjectType && baseName->meta && baseName->property->isFinal()) {
+ QQmlPropertyCache *cache = m_engine->cache(baseName->meta);
+ if (!cache)
+ return false;
+
+ if (QQmlPropertyData *data = cache->property(name)) {
+ if (!data->isFinal()) {
+ if (qmlVerboseCompiler())
+ qWarning() << "*** non-final property access:"
+ << (*baseName->id + QLatin1String(".") + ast->name.toString());
+ return false; // We don't know enough about this property
+ }
+
+ IR::Type irType = irTypeFromVariantType(data->propType, m_engine, baseName->meta);
+ _expr.code = _block->SYMBOL(baseName, irType, name,
+ baseName->meta, data, line, column);
+ }
+ }
+ break;
+
+ case IR::Name::Object:
+ case IR::Name::Slot:
+ break;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::preVisit(AST::Node *)
+{
+ return ! _discard;
+}
+
+bool QV4IRBuilder::visit(AST::NewMemberExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::NewExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::CallExpression *ast)
+{
+ QList<QStringRef> names;
+ QList<AST::ExpressionNode *> nameNodes;
+
+ names.reserve(4);
+ nameNodes.reserve(4);
+
+ if (buildName(names, ast->base, &nameNodes)) {
+ //ExprResult base = expression(ast->base);
+ QString id;
+ for (int i = 0; i < names.size(); ++i) {
+ if (! i)
+ id += QLatin1Char('.');
+ id += names.at(i);
+ }
+ const AST::SourceLocation loc = nameNodes.last()->firstSourceLocation();
+ IR::Expr *base = _block->NAME(id, loc.startLine, loc.startColumn);
+
+ IR::ExprList *args = 0, **argsInserter = &args;
+ for (AST::ArgumentList *it = ast->arguments; it; it = it->next) {
+ IR::Expr *arg = expression(it->expression);
+ *argsInserter = _function->pool->New<IR::ExprList>();
+ (*argsInserter)->init(arg);
+ argsInserter = &(*argsInserter)->next;
+ }
+
+ IR::Temp *r = _block->TEMP(IR::InvalidType);
+ IR::Expr *call = _block->CALL(base, args);
+ _block->MOVE(r, call);
+ r->type = call->type;
+ _expr.code = r;
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::PostIncrementExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::PostDecrementExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::DeleteExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::VoidExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::TypeOfExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::PreIncrementExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::PreDecrementExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UnaryPlusExpression *ast)
+{
+ ExprResult expr = expression(ast->expression);
+ if (expr.isNot(IR::InvalidType)) {
+ if (expr.code->asConst() != 0) {
+ _expr = expr;
+ return false;
+ }
+
+ IR::Expr *code = _block->UNOP(IR::OpUPlus, expr);
+ _expr.code = _block->TEMP(code->type);
+ _block->MOVE(_expr, code);
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::UnaryMinusExpression *ast)
+{
+ ExprResult expr = expression(ast->expression);
+ if (expr.isNot(IR::InvalidType)) {
+ if (IR::Const *c = expr.code->asConst()) {
+ _expr = expr;
+ _expr.code = _block->CONST(-c->value);
+ return false;
+ }
+
+ IR::Expr *code = _block->UNOP(IR::OpUMinus, expr);
+ _expr.code = _block->TEMP(code->type);
+ _block->MOVE(_expr, code);
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::TildeExpression *ast)
+{
+ ExprResult expr = expression(ast->expression);
+ if (expr.isNot(IR::InvalidType)) {
+ if (IR::Const *c = expr.code->asConst()) {
+ _expr = expr;
+ _expr.code = _block->CONST(~int(c->value));
+ return false;
+ }
+ IR::Expr *code = _block->UNOP(IR::OpCompl, expr);
+ _expr.code = _block->TEMP(code->type);
+ _block->MOVE(_expr, code);
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::NotExpression *ast)
+{
+ ExprResult expr = expression(ast->expression);
+
+ if (expr.isNot(IR::InvalidType)) {
+ if (IR::Const *c = expr.code->asConst()) {
+ _expr = expr;
+ _expr.code = _block->CONST(!c->value);
+ return false;
+ }
+
+ IR::Expr *code = _block->UNOP(IR::OpNot, expr);
+ _expr.code = _block->TEMP(code->type);
+ _block->MOVE(_expr, code);
+
+ } else if (expr.hint == ExprResult::cx) {
+ expr.format = ExprResult::cx;
+ _block->CJUMP(_block->UNOP(IR::OpNot, expr), _expr.iftrue, _expr.iffalse);
+ return false;
+ }
+
+ return false;
+}
+
+void QV4IRBuilder::binop(AST::BinaryExpression *ast, ExprResult left, ExprResult right)
+{
+ if (IR::Type t = maxType(left.type(), right.type())) {
+ implicitCvt(left, t);
+ implicitCvt(right, t);
+
+ if (_expr.hint == ExprResult::cx) {
+ _expr.format = ExprResult::cx;
+ _block->CJUMP(_block->BINOP(IR::binaryOperator(ast->op), left, right), _expr.iftrue, _expr.iffalse);
+ } else {
+ IR::Expr *code = _block->BINOP(IR::binaryOperator(ast->op), left, right);
+ _expr.code = _block->TEMP(code->type);
+ _block->MOVE(_expr.code, code);
+ }
+ }
+}
+
+bool QV4IRBuilder::visit(AST::BinaryExpression *ast)
+{
+ switch (ast->op) {
+ case QSOperator::And: {
+ if (_expr.hint == ExprResult::cx) {
+ _expr.format = ExprResult::cx;
+
+ Q_ASSERT(_expr.iffalse != 0);
+ Q_ASSERT(_expr.iftrue != 0);
+
+ IR::BasicBlock *iftrue = _function->newBasicBlock();
+ condition(ast->left, iftrue, _expr.iffalse);
+
+ _block = iftrue;
+ condition(ast->right, _expr.iftrue, _expr.iffalse);
+ } else {
+ IR::BasicBlock *iftrue = _function->newBasicBlock();
+ IR::BasicBlock *iffalse = _function->newBasicBlock();
+ IR::BasicBlock *endif = _function->newBasicBlock();
+
+ condition(ast->left, iftrue, iffalse);
+
+ IR::Temp *r = _block->TEMP(IR::InvalidType);
+
+ _block = iffalse;
+ _block->MOVE(r, _block->CONST(0)); // ### use the right null value
+ _block->JUMP(endif);
+
+ _block = iftrue;
+ ExprResult right = expression(ast->right);
+ _block->MOVE(r, right);
+ _block->JUMP(endif);
+
+ _block = endif;
+
+ r->type = right.type(); // ### not exactly, it can be IR::BoolType.
+ _expr.code = r;
+ }
+ } break;
+
+ case QSOperator::Or: {
+ IR::BasicBlock *iftrue = _function->newBasicBlock();
+ IR::BasicBlock *endif = _function->newBasicBlock();
+
+ ExprResult left = expression(ast->left);
+ IR::Temp *r = _block->TEMP(left.type());
+ _block->MOVE(r, left);
+
+ IR::Expr *cond = r;
+ if (r->type != IR::BoolType) {
+ cond = _block->TEMP(IR::BoolType);
+ _block->MOVE(cond, r);
+ }
+
+ _block->CJUMP(_block->UNOP(IR::OpNot, cond), iftrue, endif);
+
+ _block = iftrue;
+ ExprResult right = expression(ast->right);
+ _block->MOVE(r, right);
+ _block->JUMP(endif);
+
+ if (left.type() != right.type())
+ discard();
+
+ _expr.code = r;
+
+ _block = endif;
+ } break;
+
+ case QSOperator::Lt:
+ case QSOperator::Gt:
+ case QSOperator::Le:
+ case QSOperator::Ge: {
+ ExprResult left = expression(ast->left);
+ ExprResult right = expression(ast->right);
+ if (left.type() == IR::StringType && right.type() == IR::StringType) {
+ binop(ast, left, right);
+ } else if (left.isValid() && right.isValid()) {
+ implicitCvt(left, IR::RealType);
+ implicitCvt(right, IR::RealType);
+ binop(ast, left, right);
+ }
+ } break;
+
+ case QSOperator::NotEqual:
+ case QSOperator::Equal: {
+ ExprResult left = expression(ast->left);
+ ExprResult right = expression(ast->right);
+ if ((left.type() == IR::NullType || left.type() == IR::UndefinedType) &&
+ (right.type() == IR::NullType || right.type() == IR::UndefinedType)) {
+ const bool isEq = ast->op == QSOperator::Equal;
+ if (_expr.hint == ExprResult::cx) {
+ _expr.format = ExprResult::cx;
+ _block->JUMP(isEq ? _expr.iftrue : _expr.iffalse);
+ } else {
+ _expr.code = _block->CONST(IR::BoolType, isEq ? 1 : 0);
+ }
+ } else if ((left.type() == IR::StringType && right.type() >= IR::FirstNumberType) ||
+ (left.type() >= IR::FirstNumberType && right.type() == IR::StringType)) {
+ implicitCvt(left, IR::RealType);
+ implicitCvt(right, IR::RealType);
+ binop(ast, left, right);
+ } else if (left.type() == IR::BoolType || right.type() == IR::BoolType) {
+ implicitCvt(left, IR::BoolType);
+ implicitCvt(right, IR::BoolType);
+ } else if (left.isValid() && right.isValid()) {
+ binop(ast, left, right);
+ }
+ } break;
+
+ case QSOperator::StrictEqual:
+ case QSOperator::StrictNotEqual: {
+ ExprResult left = expression(ast->left);
+ ExprResult right = expression(ast->right);
+ if (left.type() == right.type()) {
+ binop(ast, left, right);
+ } else if (left.type() >= IR::BoolType && right.type() >= IR::BoolType) {
+ // left and right have numeric type (int or real)
+ binop(ast, left, right);
+ } else if (left.isValid() && right.isValid()) {
+ const bool isEq = ast->op == QSOperator::StrictEqual;
+ if (_expr.hint == ExprResult::cx) {
+ _expr.format = ExprResult::cx;
+ _block->JUMP(isEq ? _expr.iftrue : _expr.iffalse);
+ } else {
+ _expr.code = _block->CONST(IR::BoolType, isEq ? 1 : 0);
+ }
+ }
+ } break;
+
+ case QSOperator::BitAnd:
+ case QSOperator::BitOr:
+ case QSOperator::BitXor:
+ case QSOperator::LShift:
+ case QSOperator::RShift:
+ case QSOperator::URShift: {
+ ExprResult left = expression(ast->left);
+ if (left.is(IR::InvalidType))
+ return false;
+
+ ExprResult right = expression(ast->right);
+ if (right.is(IR::InvalidType))
+ return false;
+
+ implicitCvt(left, IR::IntType);
+ implicitCvt(right, IR::IntType);
+
+ IR::Expr *code = _block->BINOP(IR::binaryOperator(ast->op), left, right);
+ _expr.code = _block->TEMP(code->type);
+ _block->MOVE(_expr.code, code);
+
+ } break;
+
+ case QSOperator::Add: {
+ ExprResult left = expression(ast->left);
+ if (left.is(IR::InvalidType))
+ return false;
+
+ ExprResult right = expression(ast->right);
+ if (right.is(IR::InvalidType))
+ return false;
+
+ if (left.isPrimitive() && right.isPrimitive()) {
+ if (left.type() == IR::StringType || right.type() == IR::StringType) {
+ implicitCvt(left, IR::StringType);
+ implicitCvt(right, IR::StringType);
+ }
+ binop(ast, left, right);
+ }
+ } break;
+
+ case QSOperator::Div:
+ case QSOperator::Mod:
+ case QSOperator::Mul:
+ case QSOperator::Sub: {
+ ExprResult left = expression(ast->left);
+ if (left.is(IR::InvalidType))
+ return false;
+
+ ExprResult right = expression(ast->right);
+ if (right.is(IR::InvalidType))
+ return false;
+
+ IR::Type t = maxType(left.type(), right.type());
+ if (t >= IR::FirstNumberType) {
+ implicitCvt(left, IR::RealType);
+ implicitCvt(right, IR::RealType);
+
+ IR::Expr *code = _block->BINOP(IR::binaryOperator(ast->op), left, right);
+ _expr.code = _block->TEMP(code->type);
+ _block->MOVE(_expr.code, code);
+ }
+ } break;
+
+ case QSOperator::In:
+ case QSOperator::InstanceOf:
+ case QSOperator::Assign:
+ case QSOperator::InplaceAnd:
+ case QSOperator::InplaceSub:
+ case QSOperator::InplaceDiv:
+ case QSOperator::InplaceAdd:
+ case QSOperator::InplaceLeftShift:
+ case QSOperator::InplaceMod:
+ case QSOperator::InplaceMul:
+ case QSOperator::InplaceOr:
+ case QSOperator::InplaceRightShift:
+ case QSOperator::InplaceURightShift:
+ case QSOperator::InplaceXor:
+ // yup, we don't do those.
+ break;
+ } // switch
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ConditionalExpression *ast)
+{
+ IR::BasicBlock *iftrue = _function->newBasicBlock();
+ IR::BasicBlock *iffalse = _function->newBasicBlock();
+ IR::BasicBlock *endif = _function->newBasicBlock();
+
+ condition(ast->expression, iftrue, iffalse);
+
+ IR::Temp *r = _block->TEMP(IR::InvalidType);
+
+ qSwap(_block, iftrue);
+ ExprResult ok = expression(ast->ok);
+ _block->MOVE(r, ok);
+ _block->JUMP(endif);
+ qSwap(_block, iftrue);
+
+ qSwap(_block, iffalse);
+ ExprResult ko = expression(ast->ko);
+ _block->MOVE(r, ko);
+ _block->JUMP(endif);
+ qSwap(_block, iffalse);
+
+ r->type = maxType(ok.type(), ko.type());
+ _expr.code = r;
+
+ _block = endif;
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::Expression *ast)
+{
+ _block->EXP(expression(ast->left));
+ _expr = expression(ast->right);
+
+ return false;
+}
+
+
+// statements
+bool QV4IRBuilder::visit(AST::Block *ast)
+{
+ if (ast->statements && ! ast->statements->next) {
+ // we have one and only one statement
+ accept(ast->statements->statement);
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::StatementList *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::VariableStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::VariableDeclarationList *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::VariableDeclaration *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::EmptyStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ExpressionStatement *ast)
+{
+ if (ast->expression) {
+ // return the value of this expression
+ return true;
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::IfStatement *ast)
+{
+ if (! ast->ko) {
+ // This is an if statement without an else branch.
+ discard();
+ } else {
+ IR::BasicBlock *iftrue = _function->newBasicBlock();
+ IR::BasicBlock *iffalse = _function->newBasicBlock();
+ IR::BasicBlock *endif = _function->newBasicBlock();
+
+ condition(ast->expression, iftrue, iffalse);
+
+ IR::Temp *r = _block->TEMP(IR::InvalidType);
+
+ qSwap(_block, iftrue);
+ ExprResult ok = statement(ast->ok);
+ _block->MOVE(r, ok);
+ _block->JUMP(endif);
+ qSwap(_block, iftrue);
+
+ qSwap(_block, iffalse);
+ ExprResult ko = statement(ast->ko);
+ _block->MOVE(r, ko);
+ _block->JUMP(endif);
+ qSwap(_block, iffalse);
+
+ r->type = maxType(ok.type(), ko.type());
+ _expr.code = r;
+
+ _block = endif;
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::DoWhileStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::WhileStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ForStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::LocalForStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ForEachStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::LocalForEachStatement *)
+{
+ discard();
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ContinueStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::BreakStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ReturnStatement *ast)
+{
+ if (ast->expression) {
+ // return the value of the expression
+ return true;
+ }
+
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::WithStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::SwitchStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::CaseBlock *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::CaseClauses *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::CaseClause *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::DefaultClause *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::LabelledStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::ThrowStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::TryStatement *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::Catch *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::Finally *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::FunctionDeclaration *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::FunctionExpression *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::FormalParameterList *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::FunctionBody *)
+{
+ return false;
+}
+
+bool QV4IRBuilder::visit(AST::DebuggerStatement *)
+{
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4irbuilder_p.h b/src/qml/qml/v4/qv4irbuilder_p.h
new file mode 100644
index 0000000000..2b338c0778
--- /dev/null
+++ b/src/qml/qml/v4/qv4irbuilder_p.h
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4IRBUILDER_P_H
+#define QV4IRBUILDER_P_H
+
+#include <QtCore/qglobal.h>
+
+#include "qv4ir_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QV4IRBuilder : public QQmlJS::AST::Visitor
+{
+public:
+ QV4IRBuilder(const QV4Compiler::Expression *, QQmlEnginePrivate *);
+
+ bool operator()(QQmlJS::IR::Function *, QQmlJS::AST::Node *);
+
+protected:
+ struct ExprResult {
+ enum Format {
+ ex, // expression
+ cx // condition
+ };
+
+ QQmlJS::IR::Expr *code;
+ QQmlJS::IR::BasicBlock *iftrue;
+ QQmlJS::IR::BasicBlock *iffalse;
+ Format hint; // requested format
+ Format format; // instruction format
+
+ ExprResult(QQmlJS::IR::Expr *expr = 0)
+ : code(expr), iftrue(0), iffalse(0), hint(ex), format(ex) {}
+
+ ExprResult(QQmlJS::IR::BasicBlock *iftrue, QQmlJS::IR::BasicBlock *iffalse)
+ : code(0), iftrue(iftrue), iffalse(iffalse), hint(cx), format(ex) {}
+
+ inline QQmlJS::IR::Type type() const { return code ? code->type : QQmlJS::IR::InvalidType; }
+
+ inline QQmlJS::IR::Expr *get() const { return code; }
+ inline operator QQmlJS::IR::Expr *() const { return get(); }
+ inline QQmlJS::IR::Expr *operator->() const { return get(); }
+ inline bool isValid() const { return code ? code->type != QQmlJS::IR::InvalidType : false; }
+ inline bool is(QQmlJS::IR::Type t) const { return type() == t; }
+ inline bool isNot(QQmlJS::IR::Type t) const { return type() != t; }
+
+ bool isPrimitive() const {
+ switch (type()) {
+ case QQmlJS::IR::UndefinedType: // ### TODO
+ case QQmlJS::IR::NullType: // ### TODO
+ case QQmlJS::IR::UrlType: // ### TODO
+ return false;
+
+ case QQmlJS::IR::StringType:
+ case QQmlJS::IR::BoolType:
+ case QQmlJS::IR::IntType:
+ case QQmlJS::IR::RealType:
+ case QQmlJS::IR::RealNaNType:
+ return true;
+
+ default:
+ return false;
+ } // switch
+ }
+ };
+
+ inline void accept(QQmlJS::AST::Node *ast) { QQmlJS::AST::Node::accept(ast, this); }
+
+ ExprResult expression(QQmlJS::AST::ExpressionNode *ast);
+ ExprResult statement(QQmlJS::AST::Statement *ast);
+ void sourceElement(QQmlJS::AST::SourceElement *ast);
+ void condition(QQmlJS::AST::ExpressionNode *ast, QQmlJS::IR::BasicBlock *iftrue, QQmlJS::IR::BasicBlock *iffalse);
+ void binop(QQmlJS::AST::BinaryExpression *ast, ExprResult left, ExprResult right);
+
+ void implicitCvt(ExprResult &expr, QQmlJS::IR::Type type);
+
+ virtual bool preVisit(QQmlJS::AST::Node *ast);
+
+ // QML
+ virtual bool visit(QQmlJS::AST::UiProgram *ast);
+ virtual bool visit(QQmlJS::AST::UiImportList *ast);
+ virtual bool visit(QQmlJS::AST::UiImport *ast);
+ virtual bool visit(QQmlJS::AST::UiPublicMember *ast);
+ virtual bool visit(QQmlJS::AST::UiSourceElement *ast);
+ virtual bool visit(QQmlJS::AST::UiObjectDefinition *ast);
+ virtual bool visit(QQmlJS::AST::UiObjectInitializer *ast);
+ virtual bool visit(QQmlJS::AST::UiObjectBinding *ast);
+ virtual bool visit(QQmlJS::AST::UiScriptBinding *ast);
+ virtual bool visit(QQmlJS::AST::UiArrayBinding *ast);
+ virtual bool visit(QQmlJS::AST::UiObjectMemberList *ast);
+ virtual bool visit(QQmlJS::AST::UiArrayMemberList *ast);
+ virtual bool visit(QQmlJS::AST::UiQualifiedId *ast);
+
+ // JS
+ virtual bool visit(QQmlJS::AST::Program *ast);
+ virtual bool visit(QQmlJS::AST::SourceElements *ast);
+ virtual bool visit(QQmlJS::AST::FunctionSourceElement *ast);
+ virtual bool visit(QQmlJS::AST::StatementSourceElement *ast);
+
+ // object literals
+ virtual bool visit(QQmlJS::AST::PropertyNameAndValueList *ast);
+ virtual bool visit(QQmlJS::AST::IdentifierPropertyName *ast);
+ virtual bool visit(QQmlJS::AST::StringLiteralPropertyName *ast);
+ virtual bool visit(QQmlJS::AST::NumericLiteralPropertyName *ast);
+
+ // array literals
+ virtual bool visit(QQmlJS::AST::ElementList *ast);
+ virtual bool visit(QQmlJS::AST::Elision *ast);
+
+ // function calls
+ virtual bool visit(QQmlJS::AST::ArgumentList *ast);
+
+ // expressions
+ virtual bool visit(QQmlJS::AST::ObjectLiteral *ast);
+ virtual bool visit(QQmlJS::AST::ArrayLiteral *ast);
+ virtual bool visit(QQmlJS::AST::ThisExpression *ast);
+ virtual bool visit(QQmlJS::AST::IdentifierExpression *ast);
+ virtual bool visit(QQmlJS::AST::NullExpression *ast);
+ virtual bool visit(QQmlJS::AST::TrueLiteral *ast);
+ virtual bool visit(QQmlJS::AST::FalseLiteral *ast);
+ virtual bool visit(QQmlJS::AST::StringLiteral *ast);
+ virtual bool visit(QQmlJS::AST::NumericLiteral *ast);
+ virtual bool visit(QQmlJS::AST::RegExpLiteral *ast);
+ virtual bool visit(QQmlJS::AST::NestedExpression *ast);
+ virtual bool visit(QQmlJS::AST::ArrayMemberExpression *ast);
+ virtual bool visit(QQmlJS::AST::FieldMemberExpression *ast);
+ virtual bool visit(QQmlJS::AST::NewMemberExpression *ast);
+ virtual bool visit(QQmlJS::AST::NewExpression *ast);
+ virtual bool visit(QQmlJS::AST::CallExpression *ast);
+ virtual bool visit(QQmlJS::AST::PostIncrementExpression *ast);
+ virtual bool visit(QQmlJS::AST::PostDecrementExpression *ast);
+ virtual bool visit(QQmlJS::AST::DeleteExpression *ast);
+ virtual bool visit(QQmlJS::AST::VoidExpression *ast);
+ virtual bool visit(QQmlJS::AST::TypeOfExpression *ast);
+ virtual bool visit(QQmlJS::AST::PreIncrementExpression *ast);
+ virtual bool visit(QQmlJS::AST::PreDecrementExpression *ast);
+ virtual bool visit(QQmlJS::AST::UnaryPlusExpression *ast);
+ virtual bool visit(QQmlJS::AST::UnaryMinusExpression *ast);
+ virtual bool visit(QQmlJS::AST::TildeExpression *ast);
+ virtual bool visit(QQmlJS::AST::NotExpression *ast);
+ virtual bool visit(QQmlJS::AST::BinaryExpression *ast);
+ virtual bool visit(QQmlJS::AST::ConditionalExpression *ast);
+ virtual bool visit(QQmlJS::AST::Expression *ast);
+
+ // statements
+ virtual bool visit(QQmlJS::AST::Block *ast);
+ virtual bool visit(QQmlJS::AST::StatementList *ast);
+ virtual bool visit(QQmlJS::AST::VariableStatement *ast);
+ virtual bool visit(QQmlJS::AST::VariableDeclarationList *ast);
+ virtual bool visit(QQmlJS::AST::VariableDeclaration *ast);
+ virtual bool visit(QQmlJS::AST::EmptyStatement *ast);
+ virtual bool visit(QQmlJS::AST::ExpressionStatement *ast);
+ virtual bool visit(QQmlJS::AST::IfStatement *ast);
+ virtual bool visit(QQmlJS::AST::DoWhileStatement *ast);
+ virtual bool visit(QQmlJS::AST::WhileStatement *ast);
+ virtual bool visit(QQmlJS::AST::ForStatement *ast);
+ virtual bool visit(QQmlJS::AST::LocalForStatement *ast);
+ virtual bool visit(QQmlJS::AST::ForEachStatement *ast);
+ virtual bool visit(QQmlJS::AST::LocalForEachStatement *ast);
+ virtual bool visit(QQmlJS::AST::ContinueStatement *ast);
+ virtual bool visit(QQmlJS::AST::BreakStatement *ast);
+ virtual bool visit(QQmlJS::AST::ReturnStatement *ast);
+ virtual bool visit(QQmlJS::AST::WithStatement *ast);
+ virtual bool visit(QQmlJS::AST::SwitchStatement *ast);
+ virtual bool visit(QQmlJS::AST::CaseBlock *ast);
+ virtual bool visit(QQmlJS::AST::CaseClauses *ast);
+ virtual bool visit(QQmlJS::AST::CaseClause *ast);
+ virtual bool visit(QQmlJS::AST::DefaultClause *ast);
+ virtual bool visit(QQmlJS::AST::LabelledStatement *ast);
+ virtual bool visit(QQmlJS::AST::ThrowStatement *ast);
+ virtual bool visit(QQmlJS::AST::TryStatement *ast);
+ virtual bool visit(QQmlJS::AST::Catch *ast);
+ virtual bool visit(QQmlJS::AST::Finally *ast);
+ virtual bool visit(QQmlJS::AST::FunctionDeclaration *ast);
+ virtual bool visit(QQmlJS::AST::FunctionExpression *ast);
+ virtual bool visit(QQmlJS::AST::FormalParameterList *ast);
+ virtual bool visit(QQmlJS::AST::FunctionBody *ast);
+ virtual bool visit(QQmlJS::AST::DebuggerStatement *ast);
+
+private:
+ bool buildName(QList<QStringRef> &name, QQmlJS::AST::Node *node,
+ QList<QQmlJS::AST::ExpressionNode *> *nodes);
+ void discard();
+
+ const QV4Compiler::Expression *m_expression;
+ QQmlEnginePrivate *m_engine;
+
+ QQmlJS::IR::Function *_function;
+ QQmlJS::IR::BasicBlock *_block;
+ bool _discard;
+
+ ExprResult _expr;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV4IRBUILDER_P_H
diff --git a/src/qml/qml/v4/qv4program_p.h b/src/qml/qml/v4/qv4program_p.h
new file mode 100644
index 0000000000..d23cc6192f
--- /dev/null
+++ b/src/qml/qml/v4/qv4program_p.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4PROGRAM_P_H
+#define QV4PROGRAM_P_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 "qv4instruction_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+struct QV4Program {
+ quint32 bindings;
+ quint32 dataLength;
+ quint32 signalTableOffset;
+ quint32 exceptionDataOffset;
+ quint16 subscriptions;
+ quint16 identifiers;
+ quint16 instructionCount;
+
+ struct BindingReference {
+ quint32 binding;
+ quint32 blockMask;
+ };
+
+ struct BindingReferenceList {
+ quint32 count;
+ BindingReference bindings[];
+ };
+
+ inline const char *data() const;
+ inline const char *instructions() const;
+ inline BindingReferenceList *signalTable(int signalIndex) const;
+};
+
+enum QQmlRegisterType {
+ UndefinedType,
+ QObjectStarType,
+ QRealType,
+ IntType,
+ BoolType,
+
+ PODValueType,
+
+ FirstCleanupType,
+ QStringType = FirstCleanupType,
+ QUrlType,
+ QVariantType,
+ QColorType
+};
+
+const char *QV4Program::data() const
+{
+ return ((const char *)this) + sizeof(QV4Program);
+}
+
+const char *QV4Program::instructions() const
+{
+ return (const char *)(data() + dataLength);
+}
+
+QV4Program::BindingReferenceList *QV4Program::signalTable(int signalIndex) const
+{
+ quint32 *signalTable = (quint32 *)(data() + signalTableOffset);
+ return (BindingReferenceList *)(signalTable + signalTable[signalIndex]);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV4PROGRAM_P_H
+
diff --git a/src/declarative/qml/v4/v4.pri b/src/qml/qml/v4/v4.pri
index b6784851d8..b6784851d8 100644
--- a/src/declarative/qml/v4/v4.pri
+++ b/src/qml/qml/v4/v4.pri
diff --git a/src/qml/qml/v8/notes.txt b/src/qml/qml/v8/notes.txt
new file mode 100644
index 0000000000..a4006b93c6
--- /dev/null
+++ b/src/qml/qml/v8/notes.txt
@@ -0,0 +1,4 @@
+Removed backwards compatible imports - QTBUG-17518
+
+autotest print() taking objects that don't ToString()
+autotest QQmlV8Function
diff --git a/src/qml/qml/v8/qjsconverter_impl_p.h b/src/qml/qml/v8/qjsconverter_impl_p.h
new file mode 100644
index 0000000000..10b8ab5fae
--- /dev/null
+++ b/src/qml/qml/v8/qjsconverter_impl_p.h
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qjsconverter_p.h"
+
+#ifndef QJSCONVERTER_IMPL_P_H
+#define QJSCONVERTER_IMPL_P_H
+
+QT_BEGIN_NAMESPACE
+
+extern char *qdtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **digits_str);
+Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
+
+
+quint32 QJSConverter::toArrayIndex(const QString& string)
+{
+ // FIXME this function should be exported by JSC C API.
+ bool ok;
+ quint32 idx = string.toUInt(&ok);
+ if (!ok || toString(idx) != string)
+ idx = 0xffffffff;
+
+ return idx;
+}
+
+QString QJSConverter::toString(v8::Handle<v8::String> jsString)
+{
+ if (jsString.IsEmpty())
+ return QString();
+ QString qstr;
+ qstr.resize(jsString->Length());
+ jsString->Write(reinterpret_cast<uint16_t*>(qstr.data()));
+ return qstr;
+}
+
+v8::Local<v8::String> QJSConverter::toString(const QString& string)
+{
+ return v8::String::New(reinterpret_cast<const uint16_t*>(string.data()), string.size());
+}
+
+QString QJSConverter::toString(double value)
+{
+ // FIXME this should be easier. The ideal fix is to create
+ // a new function in V8 API which could cover the functionality.
+
+ if (qIsNaN(value))
+ return QString::fromLatin1("NaN");
+ if (qIsInf(value))
+ return QString::fromLatin1(value < 0 ? "-Infinity" : "Infinity");
+ if (!value)
+ return QString::fromLatin1("0");
+
+ QVarLengthArray<char, 25> buf;
+ int decpt;
+ int sign;
+ char* result = 0;
+ char* endresult;
+ (void)qdtoa(value, 0, 0, &decpt, &sign, &endresult, &result);
+
+ if (!result)
+ return QString();
+
+ int resultLen = endresult - result;
+ if (decpt <= 0 && decpt > -6) {
+ buf.resize(-decpt + 2 + sign);
+ qMemSet(buf.data(), '0', -decpt + 2 + sign);
+ if (sign) // fix the sign.
+ buf[0] = '-';
+ buf[sign + 1] = '.';
+ buf.append(result, resultLen);
+ } else {
+ if (sign)
+ buf.append('-');
+ int length = buf.size() - sign + resultLen;
+ if (decpt <= 21 && decpt > 0) {
+ if (length <= decpt) {
+ const char* zeros = "0000000000000000000000000";
+ buf.append(result, resultLen);
+ buf.append(zeros, decpt - length);
+ } else {
+ buf.append(result, decpt);
+ buf.append('.');
+ buf.append(result + decpt, resultLen - decpt);
+ }
+ } else if (result[0] >= '0' && result[0] <= '9') {
+ if (length > 1) {
+ buf.append(result, 1);
+ buf.append('.');
+ buf.append(result + 1, resultLen - 1);
+ } else
+ buf.append(result, resultLen);
+ buf.append('e');
+ buf.append(decpt >= 0 ? '+' : '-');
+ int e = qAbs(decpt - 1);
+ if (e >= 100)
+ buf.append('0' + e / 100);
+ if (e >= 10)
+ buf.append('0' + (e % 100) / 10);
+ buf.append('0' + e % 10);
+ }
+ }
+ free(result);
+ buf.append(0);
+ return QString::fromLatin1(buf.constData());
+}
+
+// return a mask of v8::PropertyAttribute that may also contains QScriptValue::PropertyGetter or QScriptValue::PropertySetter
+uint QJSConverter::toPropertyAttributes(const QFlags<QJSValuePrivate::PropertyFlag>& flags)
+{
+ uint attr = 0;
+ if (flags.testFlag(QJSValuePrivate::ReadOnly))
+ attr |= v8::ReadOnly;
+ if (flags.testFlag(QJSValuePrivate::Undeletable))
+ attr |= v8::DontDelete;
+ if (flags.testFlag(QJSValuePrivate::SkipInEnumeration))
+ attr |= v8::DontEnum;
+ // if (flags.testFlag(QScriptValue::PropertyGetter))
+ // attr |= QScriptValue::PropertyGetter;
+ // if (flags.testFlag(QScriptValue::PropertySetter))
+ // attr |= QScriptValue::PropertySetter;
+ return attr;
+}
+
+// Converts a JS RegExp to a QRegExp.
+// The conversion is not 100% exact since ECMA regexp and QRegExp
+// have different semantics/flags, but we try to do our best.
+QRegExp QJSConverter::toRegExp(v8::Handle<v8::RegExp> jsRegExp)
+{
+ QString pattern = QJSConverter::toString(jsRegExp->GetSource());
+ Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive;
+ if (jsRegExp->GetFlags() & v8::RegExp::kIgnoreCase)
+ caseSensitivity = Qt::CaseInsensitive;
+ return QRegExp(pattern, caseSensitivity, QRegExp::RegExp2);
+}
+
+// Converts a QRegExp to a JS RegExp.
+// The conversion is not 100% exact since ECMA regexp and QRegExp
+// have different semantics/flags, but we try to do our best.
+v8::Local<v8::RegExp> QJSConverter::toRegExp(const QRegExp &re)
+{
+ // Convert the pattern to a ECMAScript pattern.
+ QString pattern = qt_regexp_toCanonical(re.pattern(), re.patternSyntax());
+ if (re.isMinimal()) {
+ QString ecmaPattern;
+ int len = pattern.length();
+ ecmaPattern.reserve(len);
+ int i = 0;
+ const QChar *wc = pattern.unicode();
+ bool inBracket = false;
+ while (i < len) {
+ QChar c = wc[i++];
+ ecmaPattern += c;
+ switch (c.unicode()) {
+ case '?':
+ case '+':
+ case '*':
+ case '}':
+ if (!inBracket)
+ ecmaPattern += QLatin1Char('?');
+ break;
+ case '\\':
+ if (i < len)
+ ecmaPattern += wc[i++];
+ break;
+ case '[':
+ inBracket = true;
+ break;
+ case ']':
+ inBracket = false;
+ break;
+ default:
+ break;
+ }
+ }
+ pattern = ecmaPattern;
+ }
+
+ int flags = v8::RegExp::kNone;
+ if (re.caseSensitivity() == Qt::CaseInsensitive)
+ flags |= v8::RegExp::kIgnoreCase;
+
+ return v8::RegExp::New(QJSConverter::toString(pattern), static_cast<v8::RegExp::Flags>(flags));
+}
+
+// Converts a QStringList to JS.
+// The result is a new Array object with length equal to the length
+// of the QStringList, and the elements being the QStringList's
+// elements converted to JS Strings.
+v8::Local<v8::Array> QJSConverter::toStringList(const QStringList &lst)
+{
+ v8::Local<v8::Array> result = v8::Array::New(lst.size());
+ for (int i = 0; i < lst.size(); ++i)
+ result->Set(i, toString(lst.at(i)));
+ return result;
+}
+
+// Converts a JS Array object to a QStringList.
+// The result is a QStringList with length equal to the length
+// of the JS Array, and elements being the JS Array's elements
+// converted to QStrings.
+QStringList QJSConverter::toStringList(v8::Handle<v8::Array> jsArray)
+{
+ QStringList result;
+ uint32_t length = jsArray->Length();
+ for (uint32_t i = 0; i < length; ++i)
+ result.append(toString(jsArray->Get(i)->ToString()));
+ return result;
+}
+
+
+// Converts a JS Date to a QDateTime.
+QDateTime QJSConverter::toDateTime(v8::Handle<v8::Date> jsDate)
+{
+ return QDateTime::fromMSecsSinceEpoch(jsDate->NumberValue());
+}
+
+// Converts a QDateTime to a JS Date.
+v8::Local<v8::Value> QJSConverter::toDateTime(const QDateTime &dt)
+{
+ double date;
+ if (!dt.isValid())
+ date = qSNaN();
+ else
+ date = dt.toMSecsSinceEpoch();
+ return v8::Date::New(date);
+}
+
+QT_END_NAMESPACE
+
+#endif // QJSCONVERTER_IMPL_P_H
diff --git a/src/qml/qml/v8/qjsconverter_p.h b/src/qml/qml/v8/qjsconverter_p.h
new file mode 100644
index 0000000000..d85f9aa0cf
--- /dev/null
+++ b/src/qml/qml/v8/qjsconverter_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSCONVERTER_P_H
+#define QJSCONVERTER_P_H
+
+#include "qjsvalue_p.h"
+#include <QtCore/qglobal.h>
+#include <QtCore/qnumeric.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qregexp.h>
+#include <QtCore/qdatetime.h>
+
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ \internal
+ \class QJSConverter
+ QJSValue and QJSEngine helper class. This class's responsibility is to convert values
+ between JS values and Qt/C++ values.
+
+ This is a nice way to inline these functions in both QJSValue and QJSEngine.
+*/
+class QJSConverter {
+public:
+ static inline quint32 toArrayIndex(const QString& string);
+
+ static inline QString toString(v8::Handle<v8::String> jsString);
+ static inline v8::Local<v8::String> toString(const QString& string);
+ static inline QString toString(double value);
+
+ enum {
+ PropertyAttributeMask = v8::ReadOnly | v8::DontDelete | v8::DontEnum,
+ };
+ // return a mask of v8::PropertyAttribute that may also contains QScriptValue::PropertyGetter or QScriptValue::PropertySetter
+ static inline uint toPropertyAttributes(const QFlags<QJSValuePrivate::PropertyFlag>& flags);
+
+ // Converts a JS RegExp to a QRegExp.
+ // The conversion is not 100% exact since ECMA regexp and QRegExp
+ // have different semantics/flags, but we try to do our best.
+ static inline QRegExp toRegExp(v8::Handle<v8::RegExp> jsRegExp);
+
+ // Converts a QRegExp to a JS RegExp.
+ // The conversion is not 100% exact since ECMA regexp and QRegExp
+ // have different semantics/flags, but we try to do our best.
+ static inline v8::Local<v8::RegExp> toRegExp(const QRegExp &re);
+
+ // Converts a QStringList to JS.
+ // The result is a new Array object with length equal to the length
+ // of the QStringList, and the elements being the QStringList's
+ // elements converted to JS Strings.
+ static inline v8::Local<v8::Array> toStringList(const QStringList &lst);
+
+ // Converts a JS Array object to a QStringList.
+ // The result is a QStringList with length equal to the length
+ // of the JS Array, and elements being the JS Array's elements
+ // converted to QStrings.
+ static inline QStringList toStringList(v8::Handle<v8::Array> jsArray);
+
+ // Converts a JS Date to a QDateTime.
+ static inline QDateTime toDateTime(v8::Handle<v8::Date> jsDate);
+
+ // Converts a QDateTime to a JS Date.
+ static inline v8::Local<v8::Value> toDateTime(const QDateTime &dt);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/v8/qjsengine.cpp b/src/qml/qml/v8/qjsengine.cpp
index 3121d1b361..3121d1b361 100644
--- a/src/declarative/qml/v8/qjsengine.cpp
+++ b/src/qml/qml/v8/qjsengine.cpp
diff --git a/src/qml/qml/v8/qjsengine.h b/src/qml/qml/v8/qjsengine.h
new file mode 100644
index 0000000000..fa2584bf81
--- /dev/null
+++ b/src/qml/qml/v8/qjsengine.h
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSENGINE_H
+#define QJSENGINE_H
+
+#include <QtCore/qmetatype.h>
+
+#include <QtCore/qvariant.h>
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/qobject.h>
+#include <QtQml/qjsvalue.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QV8Engine;
+
+template <typename T>
+inline T qjsvalue_cast(const QJSValue &);
+
+class QJSEnginePrivate;
+class Q_QML_EXPORT QJSEngine
+ : public QObject
+{
+ Q_OBJECT
+public:
+#ifdef QT_DEPRECATED
+ enum ContextOwnership {
+ AdoptCurrentContext,
+ CreateNewContext
+ };
+ QT_DEPRECATED explicit QJSEngine(ContextOwnership ownership);
+#endif
+
+ QJSEngine();
+ explicit QJSEngine(QObject *parent);
+ virtual ~QJSEngine();
+
+ QJSValue globalObject() const;
+
+ QJSValue evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
+
+ QJSValue newObject();
+ QJSValue newArray(uint length = 0);
+
+ QJSValue newQObject(QObject *object);
+
+ template <typename T>
+ inline QJSValue toScriptValue(const T &value)
+ {
+ return create(qMetaTypeId<T>(), &value);
+ }
+ template <typename T>
+ inline T fromScriptValue(const QJSValue &value)
+ {
+ return qjsvalue_cast<T>(value);
+ }
+
+ void collectGarbage();
+
+ QV8Engine *handle() const { return d; }
+
+#ifdef QT_DEPRECATED
+ QT_DEPRECATED bool hasUncaughtException() const;
+ QT_DEPRECATED QJSValue uncaughtException() const;
+ QT_DEPRECATED void clearExceptions();
+#endif
+
+Q_SIGNALS:
+ void signalHandlerException(const QJSValue &exception);
+
+private:
+ QJSValue create(int type, const void *ptr);
+
+ static bool convertV2(const QJSValue &value, int type, void *ptr);
+
+ friend inline bool qjsvalue_cast_helper(const QJSValue &, int, void *);
+
+protected:
+ QJSEngine(QJSEnginePrivate &dd, QObject *parent = 0);
+
+private:
+ QV8Engine *d;
+ Q_DISABLE_COPY(QJSEngine)
+ Q_DECLARE_PRIVATE(QJSEngine)
+ friend class QV8Engine;
+};
+
+inline bool qjsvalue_cast_helper(const QJSValue &value, int type, void *ptr)
+{
+ return QJSEngine::convertV2(value, type, ptr);
+}
+
+template<typename T>
+T qjsvalue_cast(const QJSValue &value)
+{
+ T t;
+ const int id = qMetaTypeId<T>();
+
+ if (qjsvalue_cast_helper(value, id, &t))
+ return t;
+ else if (value.isVariant())
+ return qvariant_cast<T>(value.toVariant());
+
+ return T();
+}
+
+template <>
+inline QVariant qjsvalue_cast<QVariant>(const QJSValue &value)
+{
+ return value.toVariant();
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QJSENGINE_H
diff --git a/src/qml/qml/v8/qjsengine_p.h b/src/qml/qml/v8/qjsengine_p.h
new file mode 100644
index 0000000000..9866aa84b9
--- /dev/null
+++ b/src/qml/qml/v8/qjsengine_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSENGINE_P_H
+#define QJSENGINE_P_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/private/qobject_p.h>
+#include "qjsengine.h"
+
+
+QT_BEGIN_NAMESPACE
+
+
+class QJSEnginePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QJSEngine)
+
+public:
+ static QJSEnginePrivate* get(QJSEngine*e) { return e->d_func(); }
+
+ QJSEnginePrivate() {}
+};
+
+QT_END_NAMESPACE
+
+#endif // QJSENGINE_P_H
diff --git a/src/declarative/qml/v8/qjsvalue.cpp b/src/qml/qml/v8/qjsvalue.cpp
index e0a925c3bb..e0a925c3bb 100644
--- a/src/declarative/qml/v8/qjsvalue.cpp
+++ b/src/qml/qml/v8/qjsvalue.cpp
diff --git a/src/qml/qml/v8/qjsvalue.h b/src/qml/qml/v8/qjsvalue.h
new file mode 100644
index 0000000000..209090ed47
--- /dev/null
+++ b/src/qml/qml/v8/qjsvalue.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSVALUE_H
+#define QJSVALUE_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/qshareddata.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QJSValue;
+class QJSEngine;
+class QVariant;
+class QObject;
+struct QMetaObject;
+class QDateTime;
+
+typedef QList<QJSValue> QJSValueList;
+
+class QJSValuePrivate;
+struct QScriptValuePrivatePointerDeleter;
+template <class T> class QScriptPassPointer;
+
+class Q_QML_EXPORT QJSValue
+{
+public:
+ enum SpecialValue {
+ NullValue,
+ UndefinedValue
+ };
+
+public:
+ QJSValue(SpecialValue value = UndefinedValue);
+ ~QJSValue();
+ QJSValue(const QJSValue &other);
+
+ QJSValue(bool value);
+ QJSValue(int value);
+ QJSValue(uint value);
+ QJSValue(double value);
+ QJSValue(const QString &value);
+ QJSValue(const QLatin1String &value);
+#ifndef QT_NO_CAST_FROM_ASCII
+ QT_ASCII_CAST_WARN QJSValue(const char *str);
+#endif
+
+ QJSValue &operator=(const QJSValue &other);
+
+ bool isBool() const;
+ bool isNumber() const;
+ bool isNull() const;
+ bool isString() const;
+ bool isUndefined() const;
+ bool isVariant() const;
+ bool isQObject() const;
+ bool isObject() const;
+ bool isDate() const;
+ bool isRegExp() const;
+ bool isArray() const;
+ bool isError() const;
+
+ QString toString() const;
+ double toNumber() const;
+ qint32 toInt() const;
+ quint32 toUInt() const;
+ bool toBool() const;
+ QVariant toVariant() const;
+ QObject *toQObject() const;
+ QDateTime toDateTime() const;
+
+ bool equals(const QJSValue &other) const;
+ bool strictlyEquals(const QJSValue &other) const;
+
+ QJSValue prototype() const;
+ void setPrototype(const QJSValue &prototype);
+
+ QJSValue property(const QString &name) const;
+ void setProperty(const QString &name, const QJSValue &value);
+
+ bool hasProperty(const QString &name) const;
+ bool hasOwnProperty(const QString &name) const;
+
+ QJSValue property(quint32 arrayIndex) const;
+ void setProperty(quint32 arrayIndex, const QJSValue &value);
+
+ bool deleteProperty(const QString &name);
+
+ bool isCallable() const;
+ QJSValue call(const QJSValueList &args = QJSValueList());
+ QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args = QJSValueList());
+ QJSValue callAsConstructor(const QJSValueList &args = QJSValueList());
+
+#ifdef QT_DEPRECATED
+ QT_DEPRECATED QJSEngine *engine() const;
+#endif
+
+private:
+ // force compile error, prevent QJSValue(bool) to be called
+
+ QJSValue(void *) Q_DECL_EQ_DELETE;
+
+ QJSValue(QJSValuePrivate*);
+ QJSValue(QScriptPassPointer<QJSValuePrivate>);
+
+private:
+ QExplicitlySharedDataPointer<QJSValuePrivate> d_ptr;
+
+ Q_DECLARE_PRIVATE(QJSValue)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/qml/qml/v8/qjsvalue_impl_p.h b/src/qml/qml/v8/qjsvalue_impl_p.h
new file mode 100644
index 0000000000..fbddcfa5ba
--- /dev/null
+++ b/src/qml/qml/v8/qjsvalue_impl_p.h
@@ -0,0 +1,995 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// 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.
+//
+
+#ifndef QJSVALUE_IMPL_P_H
+#define QJSVALUE_IMPL_P_H
+
+#include "qjsconverter_p.h"
+#include "qjsvalue_p.h"
+#include "qv8engine_p.h"
+#include "qscriptisolate_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QJSValuePrivate* QJSValuePrivate::get(const QJSValue& q) { Q_ASSERT(q.d_ptr.data()); return q.d_ptr.data(); }
+
+QJSValue QJSValuePrivate::get(const QJSValuePrivate* d)
+{
+ Q_ASSERT(d);
+ return QJSValue(const_cast<QJSValuePrivate*>(d));
+}
+
+QJSValue QJSValuePrivate::get(QScriptPassPointer<QJSValuePrivate> d)
+{
+ Q_ASSERT(d);
+ return QJSValue(d);
+}
+
+QJSValue QJSValuePrivate::get(QJSValuePrivate* d)
+{
+ Q_ASSERT(d);
+ return QJSValue(d);
+}
+
+QJSValuePrivate::QJSValuePrivate(bool value)
+ : m_engine(0), m_state(CBool), u(value)
+{
+}
+
+QJSValuePrivate::QJSValuePrivate(int value)
+ : m_engine(0), m_state(CNumber), u(value)
+{
+}
+
+QJSValuePrivate::QJSValuePrivate(uint value)
+ : m_engine(0), m_state(CNumber), u(value)
+{
+}
+
+QJSValuePrivate::QJSValuePrivate(double value)
+ : m_engine(0), m_state(CNumber), u(value)
+{
+}
+
+QJSValuePrivate::QJSValuePrivate(const QString& value)
+ : m_engine(0), m_state(CString), u(new QString(value))
+{
+}
+
+QJSValuePrivate::QJSValuePrivate(QJSValue::SpecialValue value)
+ : m_engine(0), m_state(value == QJSValue::NullValue ? CNull : CUndefined)
+{
+}
+
+QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, bool value)
+ : m_engine(engine), m_state(JSValue)
+{
+ Q_ASSERT(engine);
+ v8::HandleScope handleScope;
+ m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
+ m_engine->registerValue(this);
+}
+
+QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, int value)
+ : m_engine(engine), m_state(JSValue)
+{
+ Q_ASSERT(engine);
+ v8::HandleScope handleScope;
+ m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
+ m_engine->registerValue(this);
+}
+
+QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, uint value)
+ : m_engine(engine), m_state(JSValue)
+{
+ Q_ASSERT(engine);
+ v8::HandleScope handleScope;
+ m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
+ m_engine->registerValue(this);
+}
+
+QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, double value)
+ : m_engine(engine), m_state(JSValue)
+{
+ Q_ASSERT(engine);
+ v8::HandleScope handleScope;
+ m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
+ m_engine->registerValue(this);
+}
+
+QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, const QString& value)
+ : m_engine(engine), m_state(JSValue)
+{
+ Q_ASSERT(engine);
+ v8::HandleScope handleScope;
+ m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
+ m_engine->registerValue(this);
+}
+
+QJSValuePrivate::QJSValuePrivate(QV8Engine* engine, QJSValue::SpecialValue value)
+ : m_engine(engine), m_state(JSValue)
+{
+ Q_ASSERT(engine);
+ v8::HandleScope handleScope;
+ m_value = v8::Persistent<v8::Value>::New(m_engine->makeJSValue(value));
+ m_engine->registerValue(this);
+}
+
+QJSValuePrivate::QJSValuePrivate(QV8Engine *engine, v8::Handle<v8::Value> value)
+ : m_engine(engine), m_state(JSValue), m_value(v8::Persistent<v8::Value>::New(value))
+{
+ Q_ASSERT(engine);
+ // It shouldn't happen, v8 shows errors by returning an empty handler. This is important debug
+ // information and it can't be simply ignored.
+ Q_ASSERT(!value.IsEmpty());
+ m_engine->registerValue(this);
+}
+
+QJSValuePrivate::~QJSValuePrivate()
+{
+ if (isJSBased()) {
+ m_engine->unregisterValue(this);
+ QScriptIsolate api(m_engine);
+ m_value.Dispose();
+ } else if (isStringBased()) {
+ delete u.m_string;
+ }
+}
+
+bool QJSValuePrivate::toBool() const
+{
+ switch (m_state) {
+ case JSValue:
+ {
+ v8::HandleScope scope;
+ return m_value->ToBoolean()->Value();
+ }
+ case CNumber:
+ return !(qIsNaN(u.m_number) || !u.m_number);
+ case CBool:
+ return u.m_bool;
+ case CNull:
+ case CUndefined:
+ return false;
+ case CString:
+ return u.m_string->length();
+ }
+
+ Q_ASSERT_X(false, "toBool()", "Not all states are included in the previous switch statement.");
+ return false; // Avoid compiler warning.
+}
+
+double QJSValuePrivate::toNumber() const
+{
+ switch (m_state) {
+ case JSValue:
+ {
+ v8::HandleScope scope;
+ return m_value->ToNumber()->Value();
+ }
+ case CNumber:
+ return u.m_number;
+ case CBool:
+ return u.m_bool ? 1 : 0;
+ case CNull:
+ case CUndefined:
+ return qQNaN();
+ case CString:
+ bool ok;
+ double result = u.m_string->toDouble(&ok);
+ if (ok)
+ return result;
+ result = u.m_string->toInt(&ok, 0); // Try other bases.
+ if (ok)
+ return result;
+ if (*u.m_string == QLatin1String("Infinity"))
+ return qInf();
+ if (*u.m_string == QLatin1String("-Infinity"))
+ return -qInf();
+ return u.m_string->length() ? qQNaN() : 0;
+ }
+
+ Q_ASSERT_X(false, "toNumber()", "Not all states are included in the previous switch statement.");
+ return 0; // Avoid compiler warning.
+}
+
+QString QJSValuePrivate::toString() const
+{
+ switch (m_state) {
+ case CBool:
+ return u.m_bool ? QString::fromLatin1("true") : QString::fromLatin1("false");
+ case CString:
+ return *u.m_string;
+ case CNumber:
+ return QJSConverter::toString(u.m_number);
+ case CNull:
+ return QString::fromLatin1("null");
+ case CUndefined:
+ return QString::fromLatin1("undefined");
+ case JSValue:
+ Q_ASSERT(!m_value.IsEmpty());
+ v8::HandleScope handleScope;
+ v8::TryCatch tryCatch;
+ v8::Local<v8::String> result = m_value->ToString();
+ if (result.IsEmpty()) {
+ result = tryCatch.Exception()->ToString();
+ m_engine->setException(tryCatch.Exception(), tryCatch.Message());
+ }
+ return QJSConverter::toString(result);
+ }
+
+ Q_ASSERT_X(false, "toString()", "Not all states are included in the previous switch statement.");
+ return QString(); // Avoid compiler warning.
+}
+
+QVariant QJSValuePrivate::toVariant() const
+{
+ switch (m_state) {
+ case CBool:
+ return QVariant(u.m_bool);
+ case CString:
+ return QVariant(*u.m_string);
+ case CNumber:
+ return QVariant(u.m_number);
+ case CNull:
+ return QVariant();
+ case CUndefined:
+ return QVariant();
+ case JSValue:
+ break;
+ }
+
+ Q_ASSERT(m_state == JSValue);
+ Q_ASSERT(!m_value.IsEmpty());
+ Q_ASSERT(m_engine);
+
+ v8::HandleScope handleScope;
+ return m_engine->variantFromJS(m_value);
+}
+
+inline QDateTime QJSValuePrivate::toDataTime() const
+{
+ if (!isDate())
+ return QDateTime();
+
+ v8::HandleScope handleScope;
+ return QJSConverter::toDateTime(v8::Handle<v8::Date>::Cast(m_value));
+
+}
+
+QObject* QJSValuePrivate::toQObject() const
+{
+ if (!isJSBased())
+ return 0;
+
+ v8::HandleScope handleScope;
+ return engine()->qtObjectFromJS(m_value);
+}
+
+double QJSValuePrivate::toInteger() const
+{
+ double result = toNumber();
+ if (qIsNaN(result))
+ return 0;
+ if (qIsInf(result))
+ return result;
+
+ // Must use floor explicitly rather than qFloor here. On some
+ // platforms qFloor will cast the value to a single precision float and use
+ // floorf() which results in test failures.
+ return (result > 0) ? floor(result) : -1 * floor(-result);
+}
+
+qint32 QJSValuePrivate::toInt32() const
+{
+ double result = toInteger();
+ // Orginaly it should look like that (result == 0 || qIsInf(result) || qIsNaN(result)), but
+ // some of these operation are invoked in toInteger subcall.
+ if (qIsInf(result))
+ return 0;
+ return result;
+}
+
+quint32 QJSValuePrivate::toUInt32() const
+{
+ double result = toInteger();
+ // Orginaly it should look like that (result == 0 || qIsInf(result) || qIsNaN(result)), but
+ // some of these operation are invoked in toInteger subcall.
+ if (qIsInf(result))
+ return 0;
+
+ // The explicit casts are required to avoid undefined behaviour. For example, casting
+ // a negative double directly to an unsigned int on ARM NEON FPU results in the value
+ // being set to zero. Casting to a signed int first ensures well defined behaviour.
+ return (quint32) (qint32) result;
+}
+
+quint16 QJSValuePrivate::toUInt16() const
+{
+ return toInt32();
+}
+
+inline bool QJSValuePrivate::isArray() const
+{
+ return isJSBased() && m_value->IsArray();
+}
+
+inline bool QJSValuePrivate::isBool() const
+{
+ return m_state == CBool || (isJSBased() && m_value->IsBoolean());
+}
+
+inline bool QJSValuePrivate::isCallable() const
+{
+ if (isFunction())
+ return true;
+ if (isObject()) {
+ // Our C++ wrappers register function handlers but not always act as callables.
+ return v8::Object::Cast(*m_value)->IsCallable();
+ }
+ return false;
+}
+
+inline bool QJSValuePrivate::isError() const
+{
+ if (!isJSBased())
+ return false;
+ v8::HandleScope handleScope;
+ return m_value->IsError();
+}
+
+inline bool QJSValuePrivate::isFunction() const
+{
+ return isJSBased() && m_value->IsFunction();
+}
+
+inline bool QJSValuePrivate::isNull() const
+{
+ return m_state == CNull || (isJSBased() && m_value->IsNull());
+}
+
+inline bool QJSValuePrivate::isNumber() const
+{
+ return m_state == CNumber || (isJSBased() && m_value->IsNumber());
+}
+
+inline bool QJSValuePrivate::isObject() const
+{
+ return isJSBased() && m_value->IsObject();
+}
+
+inline bool QJSValuePrivate::isString() const
+{
+ return m_state == CString || (isJSBased() && m_value->IsString());
+}
+
+inline bool QJSValuePrivate::isUndefined() const
+{
+ return m_state == CUndefined || (isJSBased() && m_value->IsUndefined());
+}
+
+inline bool QJSValuePrivate::isVariant() const
+{
+ return isJSBased() && m_engine->isVariant(m_value);
+}
+
+bool QJSValuePrivate::isDate() const
+{
+ return (isJSBased() && m_value->IsDate());
+}
+
+bool QJSValuePrivate::isRegExp() const
+{
+ return (isJSBased() && m_value->IsRegExp());
+}
+
+bool QJSValuePrivate::isQObject() const
+{
+ return isJSBased() && engine()->isQObject(m_value);
+}
+
+inline bool QJSValuePrivate::equals(QJSValuePrivate* other)
+{
+ if (!isJSBased() && !other->isJSBased()) {
+ switch (m_state) {
+ case CNull:
+ case CUndefined:
+ return other->isUndefined() || other->isNull();
+ case CNumber:
+ switch (other->m_state) {
+ case CBool:
+ case CString:
+ return u.m_number == other->toNumber();
+ case CNumber:
+ return u.m_number == other->u.m_number;
+ default:
+ return false;
+ }
+ case CBool:
+ switch (other->m_state) {
+ case CBool:
+ return u.m_bool == other->u.m_bool;
+ case CNumber:
+ return toNumber() == other->u.m_number;
+ case CString:
+ return toNumber() == other->toNumber();
+ default:
+ return false;
+ }
+ case CString:
+ switch (other->m_state) {
+ case CBool:
+ return toNumber() == other->toNumber();
+ case CNumber:
+ return toNumber() == other->u.m_number;
+ case CString:
+ return *u.m_string == *other->u.m_string;
+ default:
+ return false;
+ }
+ default:
+ Q_ASSERT_X(false, "QJSValue::equals", "Not all states are included in the previous switch statement.");
+ }
+ }
+
+ v8::HandleScope handleScope;
+ if (isJSBased() && !other->isJSBased()) {
+ if (!other->assignEngine(engine())) {
+ qWarning("QJSValue::equals: cannot compare to a value created in a different engine");
+ return false;
+ }
+ } else if (!isJSBased() && other->isJSBased()) {
+ if (!assignEngine(other->engine())) {
+ qWarning("QJSValue::equals: cannot compare to a value created in a different engine");
+ return false;
+ }
+ }
+
+ Q_ASSERT(this->engine() && other->engine());
+ if (this->engine() != other->engine()) {
+ qWarning("QJSValue::equals: cannot compare to a value created in a different engine");
+ return false;
+ }
+ return m_value->Equals(other->m_value);
+}
+
+inline bool QJSValuePrivate::strictlyEquals(QJSValuePrivate* other)
+{
+ if (isJSBased()) {
+ // We can't compare these two values without binding to the same engine.
+ if (!other->isJSBased()) {
+ if (other->assignEngine(engine()))
+ return m_value->StrictEquals(other->m_value);
+ return false;
+ }
+ if (other->engine() != engine()) {
+ qWarning("QJSValue::strictlyEquals: cannot compare to a value created in a different engine");
+ return false;
+ }
+ return m_value->StrictEquals(other->m_value);
+ }
+ if (isStringBased()) {
+ if (other->isStringBased())
+ return *u.m_string == *(other->u.m_string);
+ if (other->isJSBased()) {
+ assignEngine(other->engine());
+ return m_value->StrictEquals(other->m_value);
+ }
+ }
+ if (isNumberBased()) {
+ if (other->isJSBased()) {
+ assignEngine(other->engine());
+ return m_value->StrictEquals(other->m_value);
+ }
+ if (m_state != other->m_state)
+ return false;
+ if (m_state == CNumber)
+ return u.m_number == other->u.m_number;
+ Q_ASSERT(m_state == CBool);
+ return u.m_bool == other->u.m_bool;
+ }
+
+ return (isUndefined() && other->isUndefined())
+ || (isNull() && other->isNull());
+}
+
+inline bool QJSValuePrivate::lessThan(QJSValuePrivate *other) const
+{
+ if (engine() != other->engine() && engine() && other->engine()) {
+ qWarning("QJSValue::lessThan: cannot compare to a value created in a different engine");
+ return false;
+ }
+
+ if (isString() && other->isString())
+ return toString() < other->toString();
+
+ if (isObject() || other->isObject()) {
+ v8::HandleScope handleScope;
+ QV8Engine *eng = m_engine ? engine() : other->engine();
+ // FIXME: lessThan can throw an exception which will be dropped by this code:
+ Q_ASSERT(eng);
+ eng->saveException();
+ QScriptSharedDataPointer<QJSValuePrivate> cmp(eng->evaluate(QString::fromLatin1("(function(a,b){return a<b})")));
+ Q_ASSERT(cmp->isFunction());
+ v8::Handle<v8::Value> args[2];
+ cmp->prepareArgumentsForCall(args, QJSValueList() << QJSValuePrivate::get(this) << QJSValuePrivate::get(other));
+ QScriptSharedDataPointer<QJSValuePrivate> resultValue(cmp->call(0, 2, args));
+ bool result = resultValue->toBool();
+ eng->restoreException();
+ return result;
+ }
+
+ double nthis = toNumber();
+ double nother = other->toNumber();
+ if (qIsNaN(nthis) || qIsNaN(nother)) {
+ // Should return undefined in ECMA standard.
+ return false;
+ }
+ return nthis < nother;
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::prototype() const
+{
+ if (isObject()) {
+ v8::HandleScope handleScope;
+ return new QJSValuePrivate(engine(), v8::Handle<v8::Object>::Cast(m_value)->GetPrototype());
+ }
+ return new QJSValuePrivate();
+}
+
+inline void QJSValuePrivate::setPrototype(QJSValuePrivate* prototype)
+{
+ if (isObject() && (prototype->isObject() || prototype->isNull())) {
+ if (engine() != prototype->engine()) {
+ if (prototype->engine()) {
+ qWarning("QJSValue::setPrototype() failed: cannot set a prototype created in a different engine");
+ return;
+ }
+ prototype->assignEngine(engine());
+ }
+ v8::HandleScope handleScope;
+ if (!v8::Handle<v8::Object>::Cast(m_value)->SetPrototype(*prototype))
+ qWarning("QJSValue::setPrototype() failed: cyclic prototype value");
+ }
+}
+
+inline void QJSValuePrivate::setProperty(const QString& name, QJSValuePrivate* value, uint attribs)
+{
+ if (!isObject())
+ return;
+ v8::HandleScope handleScope;
+ setProperty(QJSConverter::toString(name), value, attribs);
+}
+
+inline void QJSValuePrivate::setProperty(v8::Handle<v8::String> name, QJSValuePrivate* value, uint attribs)
+{
+ if (!isObject())
+ return;
+
+ if (!value->isJSBased())
+ value->assignEngine(engine());
+
+ if (engine() != value->engine()) {
+ qWarning("QJSValue::setProperty(%s) failed: "
+ "cannot set value created in a different engine",
+ qPrintable(QJSConverter::toString(name)));
+ return;
+ }
+
+ v8::TryCatch tryCatch;
+// if (attribs & (QJSValue::PropertyGetter | QJSValue::PropertySetter)) {
+// engine()->originalGlobalObject()->defineGetterOrSetter(*this, name, value->m_value, attribs);
+// } else {
+ v8::Object::Cast(*m_value)->Set(name, value->m_value, v8::PropertyAttribute(attribs & QJSConverter::PropertyAttributeMask));
+// }
+ if (tryCatch.HasCaught())
+ engine()->setException(tryCatch.Exception(), tryCatch.Message());
+}
+
+inline void QJSValuePrivate::setProperty(quint32 index, QJSValuePrivate* value, uint attribs)
+{
+ // FIXME this method should by integrated with other overloads to use the same code patch.
+ // for now it is not possible as v8 doesn't allow to set property attributes using index based api.
+
+ if (!isObject())
+ return;
+
+ if (attribs) {
+ // FIXME we dont need to convert index to a string.
+ //Object::Set(int,value) do not take attributes.
+ setProperty(QString::number(index), value, attribs);
+ return;
+ }
+
+ if (!value->isJSBased())
+ value->assignEngine(engine());
+
+ if (engine() != value->engine()) {
+ qWarning("QJSValue::setProperty() failed: cannot set value created in a different engine");
+ return;
+ }
+
+ v8::HandleScope handleScope;
+ v8::TryCatch tryCatch;
+ v8::Object::Cast(*m_value)->Set(index, value->m_value);
+ if (tryCatch.HasCaught())
+ engine()->setException(tryCatch.Exception(), tryCatch.Message());
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(const QString& name) const
+{
+ if (!isObject())
+ return new QJSValuePrivate();
+ if (!name.length())
+ return new QJSValuePrivate(engine());
+
+ v8::HandleScope handleScope;
+ return property(QJSConverter::toString(name));
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(v8::Handle<v8::String> name) const
+{
+ Q_ASSERT(!name.IsEmpty());
+ if (!isObject())
+ return new QJSValuePrivate();
+ return property<>(name);
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(quint32 index) const
+{
+ if (!isObject())
+ return new QJSValuePrivate();
+ return property<>(index);
+}
+
+template<typename T>
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::property(T name) const
+{
+ Q_ASSERT(isObject());
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Object> self(v8::Object::Cast(*m_value));
+
+ v8::TryCatch tryCatch;
+ v8::Handle<v8::Value> result = self->Get(name);
+ if (tryCatch.HasCaught()) {
+ result = tryCatch.Exception();
+ engine()->setException(result, tryCatch.Message());
+ return new QJSValuePrivate(engine(), result);
+ }
+ if (result.IsEmpty())
+ return new QJSValuePrivate(engine());
+ return new QJSValuePrivate(engine(), result);
+}
+
+inline bool QJSValuePrivate::deleteProperty(const QString& name)
+{
+ if (!isObject())
+ return false;
+
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Object> self(v8::Handle<v8::Object>::Cast(m_value));
+ return self->Delete(QJSConverter::toString(name));
+}
+
+inline bool QJSValuePrivate::hasProperty(const QString &name) const
+{
+ if (!isObject())
+ return false;
+
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Object> self(v8::Handle<v8::Object>::Cast(m_value));
+ return self->Has(QJSConverter::toString(name));
+}
+
+inline bool QJSValuePrivate::hasOwnProperty(const QString &name) const
+{
+ if (!isObject())
+ return false;
+
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Object> self(v8::Handle<v8::Object>::Cast(m_value));
+ return self->HasOwnProperty(QJSConverter::toString(name));
+}
+
+inline QJSValuePrivate::PropertyFlags QJSValuePrivate::propertyFlags(const QString& name) const
+{
+ if (!isObject())
+ return QJSValuePrivate::PropertyFlags(0);
+
+ v8::HandleScope handleScope;
+ return engine()->getPropertyFlags(v8::Handle<v8::Object>::Cast(m_value), QJSConverter::toString(name));
+}
+
+inline QJSValuePrivate::PropertyFlags QJSValuePrivate::propertyFlags(v8::Handle<v8::String> name) const
+{
+ if (!isObject())
+ return QJSValuePrivate::PropertyFlags(0);
+
+ v8::HandleScope handleScope;
+ return engine()->getPropertyFlags(v8::Handle<v8::Object>::Cast(m_value), name);
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::call(QJSValuePrivate* thisObject, const QJSValueList& args)
+{
+ if (!isCallable())
+ return new QJSValuePrivate();
+
+ v8::HandleScope handleScope;
+
+ // Convert all arguments and bind to the engine.
+ int argc = args.size();
+ QVarLengthArray<v8::Handle<v8::Value>, 8> argv(argc);
+ if (!prepareArgumentsForCall(argv.data(), args)) {
+ qWarning("QJSValue::call() failed: cannot call function with argument created in a different engine");
+ return new QJSValuePrivate(engine());
+ }
+
+ return call(thisObject, argc, argv.data());
+}
+
+QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::call(QJSValuePrivate* thisObject, int argc, v8::Handle<v8::Value> *argv)
+{
+ QV8Engine *e = engine();
+
+ v8::Handle<v8::Object> recv;
+
+ if (!thisObject || !thisObject->isObject()) {
+ recv = v8::Handle<v8::Object>(v8::Object::Cast(*e->global()));
+ } else {
+ if (!thisObject->assignEngine(e)) {
+ qWarning("QJSValue::call() failed: cannot call function with thisObject created in a different engine");
+ return new QJSValuePrivate(engine());
+ }
+
+ recv = v8::Handle<v8::Object>(v8::Object::Cast(*thisObject->m_value));
+ }
+
+ if (argc < 0) {
+ v8::Local<v8::Value> exeption = v8::Exception::TypeError(v8::String::New("Arguments must be an array"));
+ e->setException(exeption);
+ return new QJSValuePrivate(e, exeption);
+ }
+
+ v8::TryCatch tryCatch;
+ v8::Handle<v8::Value> result = v8::Object::Cast(*m_value)->CallAsFunction(recv, argc, argv);
+
+ if (result.IsEmpty()) {
+ result = tryCatch.Exception();
+ // TODO: figure out why v8 doesn't always produce an exception value.
+ //Q_ASSERT(!result.IsEmpty());
+ if (result.IsEmpty())
+ result = v8::Exception::Error(v8::String::New("missing exception value"));
+ e->setException(result, tryCatch.Message());
+ }
+
+ return new QJSValuePrivate(e, result);
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::callAsConstructor(int argc, v8::Handle<v8::Value> *argv)
+{
+ QV8Engine *e = engine();
+
+ if (argc < 0) {
+ v8::Local<v8::Value> exeption = v8::Exception::TypeError(v8::String::New("Arguments must be an array"));
+ e->setException(exeption);
+ return new QJSValuePrivate(e, exeption);
+ }
+
+ v8::TryCatch tryCatch;
+ v8::Handle<v8::Value> result = v8::Object::Cast(*m_value)->CallAsConstructor(argc, argv);
+
+ if (result.IsEmpty()) {
+ result = tryCatch.Exception();
+ e->setException(result, tryCatch.Message());
+ }
+
+ return new QJSValuePrivate(e, result);
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::callAsConstructor(const QJSValueList& args)
+{
+ if (!isCallable())
+ return new QJSValuePrivate();
+
+ v8::HandleScope handleScope;
+
+ // Convert all arguments and bind to the engine.
+ int argc = args.size();
+ QVarLengthArray<v8::Handle<v8::Value>, 8> argv(argc);
+ if (!prepareArgumentsForCall(argv.data(), args)) {
+ qWarning("QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine");
+ return new QJSValuePrivate(engine());
+ }
+
+ return callAsConstructor(argc, argv.data());
+}
+
+/*! \internal
+ * Make sure this value is associated with a v8 value belonging to this engine.
+ * If the value belongs to another engine, returns false.
+ */
+bool QJSValuePrivate::assignEngine(QV8Engine* engine)
+{
+ Q_ASSERT(engine);
+ v8::HandleScope handleScope;
+ switch (m_state) {
+ case CBool:
+ m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(u.m_bool));
+ break;
+ case CString:
+ m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(*u.m_string));
+ delete u.m_string;
+ break;
+ case CNumber:
+ m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(u.m_number));
+ break;
+ case CNull:
+ m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(QJSValue::NullValue));
+ break;
+ case CUndefined:
+ m_value = v8::Persistent<v8::Value>::New(engine->makeJSValue(QJSValue::UndefinedValue));
+ break;
+ default:
+ if (this->engine() == engine)
+ return true;
+ else if (!isJSBased())
+ Q_ASSERT_X(!isJSBased(), "assignEngine()", "Not all states are included in the previous switch statement.");
+ else
+ qWarning("JSValue can't be rassigned to an another engine.");
+ return false;
+ }
+ m_engine = engine;
+ m_state = JSValue;
+
+ m_engine->registerValue(this);
+ return true;
+}
+
+/*!
+ \internal
+ Invalidates this value (makes it undefined).
+
+ Does not remove the value from the engine's list of
+ registered values; that's the responsibility of the caller.
+*/
+void QJSValuePrivate::invalidate()
+{
+ if (isJSBased()) {
+ m_value.Dispose();
+ m_value.Clear();
+ } else if (isStringBased()) {
+ delete u.m_string;
+ }
+ m_engine = 0;
+ m_state = CUndefined;
+}
+
+QV8Engine* QJSValuePrivate::engine() const
+{
+ return m_engine;
+}
+
+inline QJSValuePrivate::operator v8::Handle<v8::Value>() const
+{
+ Q_ASSERT(isJSBased());
+ return m_value;
+}
+
+inline QJSValuePrivate::operator v8::Handle<v8::Object>() const
+{
+ Q_ASSERT(isObject());
+ return v8::Handle<v8::Object>::Cast(m_value);
+}
+
+/*!
+ * Return a v8::Handle, assign to the engine if needed.
+ */
+v8::Handle<v8::Value> QJSValuePrivate::asV8Value(QV8Engine* engine)
+{
+ if (!m_engine) {
+ if (!assignEngine(engine))
+ return v8::Handle<v8::Value>();
+ }
+ Q_ASSERT(isJSBased());
+ return m_value;
+}
+
+/*!
+ \internal
+ Returns true if QSV have an engine associated.
+*/
+bool QJSValuePrivate::isJSBased() const
+{
+#ifndef QT_NO_DEBUG
+ // internals check.
+ if (m_state >= JSValue)
+ Q_ASSERT(!m_value.IsEmpty());
+ else
+ Q_ASSERT(m_value.IsEmpty());
+#endif
+ return m_state >= JSValue;
+}
+
+/*!
+ \internal
+ Returns true if current value of QSV is placed in m_number.
+*/
+bool QJSValuePrivate::isNumberBased() const { return m_state == CNumber || m_state == CBool; }
+
+/*!
+ \internal
+ Returns true if current value of QSV is placed in m_string.
+*/
+bool QJSValuePrivate::isStringBased() const { return m_state == CString; }
+
+/*!
+ \internal
+ Converts arguments and bind them to the engine.
+ \attention argv should be big enough
+*/
+inline bool QJSValuePrivate::prepareArgumentsForCall(v8::Handle<v8::Value> argv[], const QJSValueList& args) const
+{
+ QJSValueList::const_iterator i = args.constBegin();
+ for (int j = 0; i != args.constEnd(); j++, i++) {
+ QJSValuePrivate* value = QJSValuePrivate::get(*i);
+ if ((value->isJSBased() && engine() != value->engine())
+ || (!value->isJSBased() && !value->assignEngine(engine())))
+ // Different engines are not allowed!
+ return false;
+ argv[j] = *value;
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/qml/v8/qjsvalue_p.h b/src/qml/qml/v8/qjsvalue_p.h
new file mode 100644
index 0000000000..acfe958cb6
--- /dev/null
+++ b/src/qml/qml/v8/qjsvalue_p.h
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// 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.
+//
+
+#ifndef QJSVALUE_P_H
+#define QJSVALUE_P_H
+
+#include <private/qv8_p.h>
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qmath.h>
+#include <QtCore/qvarlengtharray.h>
+#include <qdebug.h>
+
+#include <private/qintrusivelist_p.h>
+#include "qscriptshareddata_p.h"
+#include "qjsvalue.h"
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+
+/*!
+ \internal
+ \class QJSValuePrivate
+*/
+class QJSValuePrivate
+ : public QSharedData
+{
+public:
+ enum PropertyFlag {
+ ReadOnly = 0x00000001,
+ Undeletable = 0x00000002,
+ SkipInEnumeration = 0x00000004
+ };
+ Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)
+
+ inline static QJSValuePrivate* get(const QJSValue& q);
+ inline static QJSValue get(const QJSValuePrivate* d);
+ inline static QJSValue get(QJSValuePrivate* d);
+ inline static QJSValue get(QScriptPassPointer<QJSValuePrivate> d);
+ inline ~QJSValuePrivate();
+
+ inline QJSValuePrivate(bool value);
+ inline QJSValuePrivate(int value);
+ inline QJSValuePrivate(uint value);
+ inline QJSValuePrivate(double value);
+ inline QJSValuePrivate(const QString& value);
+ inline QJSValuePrivate(QJSValue::SpecialValue value = QJSValue::UndefinedValue);
+
+ inline QJSValuePrivate(QV8Engine *engine, bool value);
+ inline QJSValuePrivate(QV8Engine *engine, int value);
+ inline QJSValuePrivate(QV8Engine *engine, uint value);
+ inline QJSValuePrivate(QV8Engine *engine, double value);
+ inline QJSValuePrivate(QV8Engine *engine, const QString& value);
+ inline QJSValuePrivate(QV8Engine *engine, QJSValue::SpecialValue value = QJSValue::UndefinedValue);
+ inline QJSValuePrivate(QV8Engine *engine, v8::Handle<v8::Value>);
+ inline void invalidate();
+
+ inline bool toBool() const;
+ inline double toNumber() const;
+ inline QString toString() const;
+ inline double toInteger() const;
+ inline qint32 toInt32() const;
+ inline quint32 toUInt32() const;
+ inline quint16 toUInt16() const;
+ inline QDateTime toDataTime() const;
+ inline QObject *toQObject() const;
+ inline QVariant toVariant() const;
+
+ inline bool isArray() const;
+ inline bool isBool() const;
+ inline bool isCallable() const;
+ inline bool isError() const;
+ inline bool isFunction() const;
+ inline bool isNull() const;
+ inline bool isNumber() const;
+ inline bool isObject() const;
+ inline bool isString() const;
+ inline bool isUndefined() const;
+ inline bool isVariant() const;
+ inline bool isDate() const;
+ inline bool isRegExp() const;
+ inline bool isQObject() const;
+
+ inline bool equals(QJSValuePrivate* other);
+ inline bool strictlyEquals(QJSValuePrivate* other);
+ inline bool lessThan(QJSValuePrivate *other) const;
+
+ inline QScriptPassPointer<QJSValuePrivate> prototype() const;
+ inline void setPrototype(QJSValuePrivate* prototype);
+
+ inline void setProperty(const QString &name, QJSValuePrivate *value, uint attribs = 0);
+ inline void setProperty(v8::Handle<v8::String> name, QJSValuePrivate *value, uint attribs = 0);
+ inline void setProperty(quint32 index, QJSValuePrivate* value, uint attribs = 0);
+ inline QScriptPassPointer<QJSValuePrivate> property(const QString& name) const;
+ inline QScriptPassPointer<QJSValuePrivate> property(v8::Handle<v8::String> name) const;
+ inline QScriptPassPointer<QJSValuePrivate> property(quint32 index) const;
+ template<typename T>
+ inline QScriptPassPointer<QJSValuePrivate> property(T name) const;
+ inline bool deleteProperty(const QString& name);
+ inline bool hasProperty(const QString &name) const;
+ inline bool hasOwnProperty(const QString &name) const;
+ inline PropertyFlags propertyFlags(const QString& name) const;
+ inline PropertyFlags propertyFlags(v8::Handle<v8::String> name) const;
+
+ inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, const QJSValueList& args);
+ inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, const QJSValue& arguments);
+ inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, int argc, v8::Handle< v8::Value >* argv);
+ inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(int argc, v8::Handle<v8::Value> *argv);
+ inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(const QJSValueList& args);
+ inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(const QJSValue& arguments);
+
+ inline bool assignEngine(QV8Engine *engine);
+ inline QV8Engine *engine() const;
+
+ inline operator v8::Handle<v8::Value>() const;
+ inline operator v8::Handle<v8::Object>() const;
+ inline v8::Handle<v8::Value> asV8Value(QV8Engine *engine);
+private:
+ QIntrusiveListNode m_node;
+ QV8Engine *m_engine;
+
+ // Please, update class documentation when you change the enum.
+ enum State {
+ CString = 0x1000,
+ CNumber,
+ CBool,
+ CNull,
+ CUndefined,
+ JSValue = 0x2000, // V8 values are equal or higher then this value.
+ // JSPrimitive,
+ // JSObject
+ } m_state;
+
+ union CValue {
+ bool m_bool;
+ double m_number;
+ QString* m_string;
+
+ CValue() : m_number(0) {}
+ CValue(bool value) : m_bool(value) {}
+ CValue(int number) : m_number(number) {}
+ CValue(uint number) : m_number(number) {}
+ CValue(double number) : m_number(number) {}
+ CValue(QString* string) : m_string(string) {}
+ } u;
+ // v8::Persistent is not a POD, so can't be part of the union.
+ v8::Persistent<v8::Value> m_value;
+
+ Q_DISABLE_COPY(QJSValuePrivate)
+ inline bool isJSBased() const;
+ inline bool isNumberBased() const;
+ inline bool isStringBased() const;
+ inline bool prepareArgumentsForCall(v8::Handle<v8::Value> argv[], const QJSValueList& arguments) const;
+
+ friend class QV8Engine;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QJSValuePrivate::PropertyFlags)
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/v8/qjsvalueiterator.cpp b/src/qml/qml/v8/qjsvalueiterator.cpp
index 4c3fa15fd3..4c3fa15fd3 100644
--- a/src/declarative/qml/v8/qjsvalueiterator.cpp
+++ b/src/qml/qml/v8/qjsvalueiterator.cpp
diff --git a/src/qml/qml/v8/qjsvalueiterator.h b/src/qml/qml/v8/qjsvalueiterator.h
new file mode 100644
index 0000000000..3c1b450dd8
--- /dev/null
+++ b/src/qml/qml/v8/qjsvalueiterator.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCRIPTVALUEITERATOR_H
+#define QSCRIPTVALUEITERATOR_H
+
+#include <QtQml/qtqmlglobal.h>
+#include <QtQml/qjsvalue.h>
+#include <QtCore/qscopedpointer.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QString;
+
+class QJSValueIteratorPrivate;
+class Q_QML_EXPORT QJSValueIterator
+{
+public:
+ QJSValueIterator(const QJSValue &value);
+ ~QJSValueIterator();
+
+ bool hasNext() const;
+ bool next();
+
+ QString name() const;
+
+ QJSValue value() const;
+ QJSValueIterator& operator=(QJSValue &value);
+
+private:
+ QScopedPointer<QJSValueIteratorPrivate> d_ptr;
+
+ Q_DECLARE_PRIVATE(QJSValueIterator)
+ Q_DISABLE_COPY(QJSValueIterator)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSCRIPTVALUEITERATOR_H
diff --git a/src/qml/qml/v8/qjsvalueiterator_impl_p.h b/src/qml/qml/v8/qjsvalueiterator_impl_p.h
new file mode 100644
index 0000000000..2c060b21a7
--- /dev/null
+++ b/src/qml/qml/v8/qjsvalueiterator_impl_p.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSVALUEITERATOR_IMPL_P_H
+#define QJSVALUEITERATOR_IMPL_P_H
+
+#include "qjsvalueiterator_p.h"
+#include <private/qv8engine_p.h>
+#include "qjsconverter_p.h"
+
+inline QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValuePrivate* value)
+ : m_object(const_cast<QJSValuePrivate*>(value))
+ , m_index(0)
+ , m_count(0)
+{
+ Q_ASSERT(value);
+ QV8Engine *engine = m_object->engine();
+ if (!m_object->isObject())
+ m_object = 0;
+ else {
+ QScriptIsolate api(engine, QScriptIsolate::NotNullEngine);
+ v8::HandleScope scope;
+
+ v8::Handle<v8::Value> tmp = *value;
+ v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(tmp);
+ v8::Local<v8::Array> names;
+
+ // FIXME we need newer V8!
+ //names = obj->GetOwnPropertyNames();
+ names = engine->getOwnPropertyNames(obj);
+ m_names = v8::Persistent<v8::Array>::New(names);
+ m_count = names->Length();
+
+ engine->registerValueIterator(this);
+ }
+}
+
+inline QJSValueIteratorPrivate::~QJSValueIteratorPrivate()
+{
+ if (isValid()) {
+ engine()->unregisterValueIterator(this);
+ m_names.Dispose();
+ }
+}
+
+inline void QJSValueIteratorPrivate::invalidate()
+{
+ m_names.Dispose();
+ m_object.reset();
+ m_index = 0;
+ m_count = 0;
+}
+
+inline bool QJSValueIteratorPrivate::hasNext() const
+{
+ return isValid() ? m_index < m_count : false;
+}
+
+inline bool QJSValueIteratorPrivate::next()
+{
+ if (hasNext()) {
+ ++m_index;
+ return true;
+ }
+ return false;
+}
+
+inline QString QJSValueIteratorPrivate::name() const
+{
+ if (!isValid())
+ return QString();
+
+ v8::HandleScope handleScope;
+ return QJSConverter::toString(m_names->Get(m_index - 1)->ToString());
+}
+
+inline QScriptPassPointer<QJSValuePrivate> QJSValueIteratorPrivate::value() const
+{
+ if (!isValid())
+ return new QJSValuePrivate();
+
+ v8::HandleScope handleScope;
+ return m_object->property(m_names->Get(m_index - 1)->ToString());
+}
+
+inline bool QJSValueIteratorPrivate::isValid() const
+{
+ bool result = m_object ? !m_object->isUndefined() : false;
+ // We know that if this object is still valid then it is an object
+ // if this assumption is not correct then some other logic in this class
+ // have to be changed too.
+ Q_ASSERT(!result || m_object->isObject());
+ return result;
+}
+
+inline QV8Engine* QJSValueIteratorPrivate::engine() const
+{
+ return m_object ? m_object->engine() : 0;
+}
+
+#endif // QJSVALUEITERATOR_IMPL_P_H
diff --git a/src/qml/qml/v8/qjsvalueiterator_p.h b/src/qml/qml/v8/qjsvalueiterator_p.h
new file mode 100644
index 0000000000..f5f4c44441
--- /dev/null
+++ b/src/qml/qml/v8/qjsvalueiterator_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QJSVALUEITERATOR_P_H
+#define QJSVALUEITERATOR_P_H
+
+#include <private/qintrusivelist_p.h>
+#include "qjsvalue_p.h"
+
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+
+class QJSValueIteratorPrivate
+{
+public:
+ inline QJSValueIteratorPrivate(const QJSValuePrivate* value);
+ inline ~QJSValueIteratorPrivate();
+
+ inline bool hasNext() const;
+ inline bool next();
+
+ inline QString name() const;
+
+ inline QScriptPassPointer<QJSValuePrivate> value() const;
+
+ inline bool isValid() const;
+ inline QV8Engine* engine() const;
+
+ inline void invalidate();
+private:
+ Q_DISABLE_COPY(QJSValueIteratorPrivate)
+
+ QIntrusiveListNode m_node;
+ QScriptSharedDataPointer<QJSValuePrivate> m_object;
+ v8::Persistent<v8::Array> m_names;
+ uint32_t m_index;
+ uint32_t m_count;
+
+ friend class QV8Engine;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QJSVALUEITERATOR_P_H
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
new file mode 100644
index 0000000000..7d7aaa2148
--- /dev/null
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -0,0 +1,1321 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlbuiltinfunctions_p.h"
+
+#include <QtQml/qqmlcomponent.h>
+#include <private/qqmlengine_p.h>
+#include <private/qqmlcomponent_p.h>
+#include <private/qqmlstringconverters_p.h>
+#include <private/qqmllocale_p.h>
+#include <private/qv8engine_p.h>
+#include <private/qjsconverter_impl_p.h>
+
+#include <private/qv8profilerservice_p.h>
+#include <private/qqmlprofilerservice_p.h>
+
+#include <QtCore/qstring.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qcryptographichash.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qcoreapplication.h>
+
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
+#include <QtGui/qdesktopservices.h>
+#include <QtGui/qfontdatabase.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QQmlBuiltinFunctions {
+
+enum ConsoleLogTypes {
+ Log,
+ Warn,
+ Error
+};
+
+static void jsContext(v8::Handle<v8::Value> *file, int *line, v8::Handle<v8::Value> *function) {
+ v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(1);
+ if (stackTrace->GetFrameCount()) {
+ v8::Local<v8::StackFrame> frame = stackTrace->GetFrame(0);
+ *file = frame->GetScriptName();
+ *line = frame->GetLineNumber();
+ *function = frame->GetFunctionName();
+ }
+}
+
+static QString jsStack() {
+ QStringList stackFrames;
+
+ //The v8 default is currently 10 stack frames.
+ v8::Handle<v8::StackTrace> stackTrace =
+ v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kOverview);
+ int stackCount = stackTrace->GetFrameCount();
+
+ for (int i = 0; i < stackCount; i++) {
+ v8::Local<v8::StackFrame> frame = stackTrace->GetFrame(i);
+ v8::Handle<v8::String> function(frame->GetFunctionName());
+ v8::Handle<v8::String> script(frame->GetScriptName());
+ int lineNumber = frame->GetLineNumber();
+ int columnNumber = frame->GetColumn();
+
+ QString stackFrame =
+ QString::fromLatin1("%1 (%2:%3:%4)").arg(QJSConverter::toString(function),
+ QJSConverter::toString(script),
+ QString::number(lineNumber),
+ QString::number(columnNumber));
+ stackFrames.append(stackFrame);
+ }
+ return stackFrames.join(QLatin1String("\n"));
+}
+
+v8::Handle<v8::Value> console(ConsoleLogTypes logType, const v8::Arguments &args,
+ bool printStack = false)
+{
+ v8::HandleScope handleScope;
+
+ QString result;
+ for (int i = 0; i < args.Length(); ++i) {
+ if (i != 0)
+ result.append(QLatin1Char(' '));
+
+ v8::Local<v8::Value> value = args[i];
+ //Check for Object Type
+ if (value->IsObject() && !value->IsFunction()
+ && !value->IsArray() && !value->IsDate()
+ && !value->IsRegExp()) {
+ result.append(QLatin1String("Object"));
+ } else {
+ v8::Local<v8::String> jsstr = value->ToString();
+ QString tmp = V8ENGINE()->toString(jsstr);
+ if (value->IsArray())
+ result.append(QString::fromLatin1("[%1]").arg(tmp));
+ else
+ result.append(tmp);
+ }
+ }
+
+ if (printStack) {
+ result.append(QLatin1String("\n"));
+ result.append(jsStack());
+ }
+
+ v8::Handle<v8::Value> fileHandle;
+ v8::Handle<v8::Value> functionHandle;
+ int line;
+
+ jsContext(&fileHandle, &line, &functionHandle);
+
+ switch (logType) {
+ case Log:
+ QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
+ *v8::String::AsciiValue(functionHandle)).debug("%s", qPrintable(result));
+ break;
+ case Warn:
+ QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
+ *v8::String::AsciiValue(functionHandle)).warning("%s", qPrintable(result));
+ break;
+ case Error:
+ QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
+ *v8::String::AsciiValue(functionHandle)).critical("%s", qPrintable(result));
+ break;
+ default:
+ break;
+ }
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> gc(const v8::Arguments &args)
+{
+ Q_UNUSED(args);
+ QV8Engine::gc();
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> consoleError(const v8::Arguments &args)
+{
+ return console(Error, args);
+}
+
+v8::Handle<v8::Value> consoleLog(const v8::Arguments &args)
+{
+ //console.log
+ //console.debug
+ //console.info
+ //print
+ return console(Log, args);
+}
+
+v8::Handle<v8::Value> consoleProfile(const v8::Arguments &args)
+{
+ //DeclarativeDebugTrace cannot handle nested profiling
+ //although v8 can handle several profiling at once,
+ //we do not allow that. Hence, we pass an empty(default) title
+ Q_UNUSED(args);
+ QString title;
+
+
+
+ v8::Handle<v8::Value> file;
+ v8::Handle<v8::Value> function;
+ int line;
+ jsContext(&file, &line, &function);
+
+ if (QQmlProfilerService::startProfiling()) {
+ QV8ProfilerService::instance()->startProfiling(title);
+
+ QMessageLogger(*v8::String::AsciiValue(file), line,
+ *v8::String::AsciiValue(function)).debug("Profiling started.");
+ } else {
+ QMessageLogger(*v8::String::AsciiValue(file), line,
+ *v8::String::AsciiValue(function)).warning(
+ "Profiling is already in progress. First, end current profiling session.");
+ }
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> consoleProfileEnd(const v8::Arguments &args)
+{
+ //DeclarativeDebugTrace cannot handle nested profiling
+ //although v8 can handle several profiling at once,
+ //we do not allow that. Hence, we pass an empty(default) title
+ Q_UNUSED(args);
+ QString title;
+
+ v8::Handle<v8::Value> file;
+ v8::Handle<v8::Value> function;
+ int line;
+ jsContext(&file, &line, &function);
+
+ if (QQmlProfilerService::stopProfiling()) {
+ QV8ProfilerService *profiler = QV8ProfilerService::instance();
+ profiler->stopProfiling(title);
+ QQmlProfilerService::sendProfilingData();
+ profiler->sendProfilingData();
+
+ QMessageLogger(*v8::String::AsciiValue(file), line,
+ *v8::String::AsciiValue(function)).debug("Profiling ended.");
+ } else {
+ QMessageLogger(*v8::String::AsciiValue(file), line,
+ *v8::String::AsciiValue(function)).warning("Profiling was not started.");
+ }
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> consoleTime(const v8::Arguments &args)
+{
+ if (args.Length() != 1)
+ V8THROW_ERROR("console.time(): Invalid arguments");
+ QString name = V8ENGINE()->toString(args[0]);
+ V8ENGINE()->startTimer(name);
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> consoleTimeEnd(const v8::Arguments &args)
+{
+ if (args.Length() != 1)
+ V8THROW_ERROR("console.time(): Invalid arguments");
+ QString name = V8ENGINE()->toString(args[0]);
+ bool wasRunning;
+ qint64 elapsed = V8ENGINE()->stopTimer(name, &wasRunning);
+ if (wasRunning) {
+ qDebug("%s: %llims", qPrintable(name), elapsed);
+ }
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> consoleCount(const v8::Arguments &args)
+{
+ // first argument: name to print. Ignore any additional arguments
+ QString name;
+ if (args.Length() > 0)
+ name = V8ENGINE()->toString(args[0]);
+
+ v8::Handle<v8::StackTrace> stackTrace =
+ v8::StackTrace::CurrentStackTrace(1, v8::StackTrace::kOverview);
+
+ if (stackTrace->GetFrameCount()) {
+ v8::Local<v8::StackFrame> frame = stackTrace->GetFrame(0);
+
+ QString scriptName = V8ENGINE()->toString(frame->GetScriptName());
+ QString functionName = V8ENGINE()->toString(frame->GetFunctionName());
+ int line = frame->GetLineNumber();
+ int column = frame->GetColumn();
+
+ int value = V8ENGINE()->consoleCountHelper(scriptName, line, column);
+ QString message = name + QLatin1String(": ") + QString::number(value);
+
+ QMessageLogger(qPrintable(scriptName), line,
+ qPrintable(functionName)).debug("%s", qPrintable(message));
+ }
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> consoleTrace(const v8::Arguments &args)
+{
+ if (args.Length() != 0)
+ V8THROW_ERROR("console.trace(): Invalid arguments");
+
+ QString stack = jsStack();
+
+ v8::Handle<v8::Value> file;
+ v8::Handle<v8::Value> function;
+ int line;
+ jsContext(&file, &line, &function);
+
+ QMessageLogger(*v8::String::AsciiValue(file), line, *v8::String::AsciiValue(function)).debug(
+ "%s", qPrintable(stack));
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> consoleWarn(const v8::Arguments &args)
+{
+ return console(Warn, args);
+}
+
+v8::Handle<v8::Value> consoleAssert(const v8::Arguments &args)
+{
+ if (args.Length() == 0)
+ V8THROW_ERROR("console.assert(): Missing argument");
+
+ if (!args[0]->ToBoolean()->Value()) {
+ QString message;
+ for (int i = 1; i < args.Length(); ++i) {
+ if (i != 1)
+ message.append(QLatin1Char(' '));
+
+ v8::Local<v8::Value> value = args[i];
+ message.append(V8ENGINE()->toString(value->ToString()));
+ }
+
+ QString stack = jsStack();
+
+ v8::Handle<v8::Value> file;
+ v8::Handle<v8::Value> function;
+ int line;
+ jsContext(&file, &line, &function);
+
+ QMessageLogger(*v8::String::AsciiValue(file), line, *v8::String::AsciiValue(function)).critical(
+ "%s\n%s", qPrintable(message), qPrintable(stack));
+
+ }
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> consoleException(const v8::Arguments &args)
+{
+ if (args.Length() == 0)
+ V8THROW_ERROR("console.exception(): Missing argument");
+
+ console(Error, args, true);
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> stringArg(const v8::Arguments &args)
+{
+ QString value = V8ENGINE()->toString(args.This()->ToString());
+ if (args.Length() != 1)
+ V8THROW_ERROR("String.arg(): Invalid arguments");
+
+ v8::Handle<v8::Value> arg = args[0];
+ if (arg->IsUint32())
+ return V8ENGINE()->toString(value.arg(arg->Uint32Value()));
+ else if (arg->IsInt32())
+ return V8ENGINE()->toString(value.arg(arg->Int32Value()));
+ else if (arg->IsNumber())
+ return V8ENGINE()->toString(value.arg(arg->NumberValue()));
+ else if (arg->IsBoolean())
+ return V8ENGINE()->toString(value.arg(arg->BooleanValue()));
+
+ return V8ENGINE()->toString(value.arg(V8ENGINE()->toString(arg)));
+}
+
+/*!
+\qmlmethod bool Qt::isQtObject(object)
+Returns true if \c object is a valid reference to a Qt or QML object, otherwise false.
+*/
+v8::Handle<v8::Value> isQtObject(const v8::Arguments &args)
+{
+ if (args.Length() == 0)
+ return v8::Boolean::New(false);
+
+ return v8::Boolean::New(0 != V8ENGINE()->toQObject(args[0]));
+}
+
+/*!
+\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
+
+Returns a color with the specified \c red, \c green, \c blue and \c alpha components.
+All components should be in the range 0-1 inclusive.
+*/
+v8::Handle<v8::Value> rgba(const v8::Arguments &args)
+{
+ int argCount = args.Length();
+ if (argCount < 3 || argCount > 4)
+ V8THROW_ERROR("Qt.rgba(): Invalid arguments");
+
+ double r = args[0]->NumberValue();
+ double g = args[1]->NumberValue();
+ double b = args[2]->NumberValue();
+ double a = (argCount == 4) ? args[3]->NumberValue() : 1;
+
+ if (r < 0.0) r=0.0;
+ if (r > 1.0) r=1.0;
+ if (g < 0.0) g=0.0;
+ if (g > 1.0) g=1.0;
+ if (b < 0.0) b=0.0;
+ if (b > 1.0) b=1.0;
+ if (a < 0.0) a=0.0;
+ if (a > 1.0) a=1.0;
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(QColor::fromRgbF(r, g, b, a)));
+}
+
+/*!
+\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha)
+
+Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
+All components should be in the range 0-1 inclusive.
+*/
+v8::Handle<v8::Value> hsla(const v8::Arguments &args)
+{
+ int argCount = args.Length();
+ if (argCount < 3 || argCount > 4)
+ V8THROW_ERROR("Qt.hsla(): Invalid arguments");
+
+ double h = args[0]->NumberValue();
+ double s = args[1]->NumberValue();
+ double l = args[2]->NumberValue();
+ double a = (argCount == 4) ? args[3]->NumberValue() : 1;
+
+ if (h < 0.0) h=0.0;
+ if (h > 1.0) h=1.0;
+ if (s < 0.0) s=0.0;
+ if (s > 1.0) s=1.0;
+ if (l < 0.0) l=0.0;
+ if (l > 1.0) l=1.0;
+ if (a < 0.0) a=0.0;
+ if (a > 1.0) a=1.0;
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(QColor::fromHslF(h, s, l, a)));
+}
+
+/*!
+\qmlmethod rect Qt::rect(int x, int y, int width, int height)
+
+Returns a \c rect with the top-left corner at \c x, \c y and the specified \c width and \c height.
+
+The returned object has \c x, \c y, \c width and \c height attributes with the given values.
+*/
+v8::Handle<v8::Value> rect(const v8::Arguments &args)
+{
+ if (args.Length() != 4)
+ V8THROW_ERROR("Qt.rect(): Invalid arguments");
+
+ double x = args[0]->NumberValue();
+ double y = args[1]->NumberValue();
+ double w = args[2]->NumberValue();
+ double h = args[3]->NumberValue();
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(QRectF(x, y, w, h)));
+}
+
+/*!
+\qmlmethod point Qt::point(int x, int y)
+Returns a Point with the specified \c x and \c y coordinates.
+*/
+v8::Handle<v8::Value> point(const v8::Arguments &args)
+{
+ if (args.Length() != 2)
+ V8THROW_ERROR("Qt.point(): Invalid arguments");
+
+ double x = args[0]->ToNumber()->Value();
+ double y = args[1]->ToNumber()->Value();
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(QPointF(x, y)));
+}
+
+/*!
+\qmlmethod Qt::size(int width, int height)
+Returns a Size with the specified \c width and \c height.
+*/
+v8::Handle<v8::Value> size(const v8::Arguments &args)
+{
+ if (args.Length() != 2)
+ V8THROW_ERROR("Qt.size(): Invalid arguments");
+
+ double w = args[0]->ToNumber()->Value();
+ double h = args[1]->ToNumber()->Value();
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(QSizeF(w, h)));
+}
+
+/*!
+\qmlmethod Qt::vector3d(real x, real y, real z)
+Returns a Vector3D with the specified \c x, \c y and \c z.
+*/
+v8::Handle<v8::Value> vector3d(const v8::Arguments &args)
+{
+ if (args.Length() != 3)
+ V8THROW_ERROR("Qt.vector(): Invalid arguments");
+
+ double x = args[0]->ToNumber()->Value();
+ double y = args[1]->ToNumber()->Value();
+ double z = args[2]->ToNumber()->Value();
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(QVector3D(x, y, z)));
+}
+
+/*!
+\qmlmethod Qt::vector4d(real x, real y, real z, real w)
+Returns a Vector4D with the specified \c x, \c y, \c z and \c w.
+*/
+v8::Handle<v8::Value> vector4d(const v8::Arguments &args)
+{
+ if (args.Length() != 4)
+ V8THROW_ERROR("Qt.vector4d(): Invalid arguments");
+
+ double x = args[0]->NumberValue();
+ double y = args[1]->NumberValue();
+ double z = args[2]->NumberValue();
+ double w = args[3]->NumberValue();
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(QVector4D(x, y, z, w)));
+}
+
+/*!
+\qmlmethod color Qt::lighter(color baseColor, real factor)
+Returns a color lighter than \c baseColor by the \c factor provided.
+
+If the factor is greater than 1.0, this functions returns a lighter color.
+Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0,
+the return color is darker, but we recommend using the Qt.darker() function for this purpose.
+If the factor is 0 or negative, the return value is unspecified.
+
+The function converts the current RGB color to HSV, multiplies the value (V) component
+by factor and converts the color back to RGB.
+
+If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5).
+*/
+v8::Handle<v8::Value> lighter(const v8::Arguments &args)
+{
+ if (args.Length() != 1 && args.Length() != 2)
+ V8THROW_ERROR("Qt.lighter(): Invalid arguments");
+
+ QColor color;
+ QVariant v = V8ENGINE()->toVariant(args[0], -1);
+ if (v.userType() == QVariant::Color) {
+ color = v.value<QColor>();
+ } else if (v.userType() == QVariant::String) {
+ bool ok = false;
+ color = QQmlStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok) {
+ return v8::Null();
+ }
+ } else {
+ return v8::Null();
+ }
+
+ qreal factor = 1.5;
+ if (args.Length() == 2)
+ factor = args[1]->ToNumber()->Value();
+
+ color = color.lighter(int(qRound(factor*100.)));
+ return V8ENGINE()->fromVariant(QVariant::fromValue(color));
+}
+
+/*!
+\qmlmethod color Qt::darker(color baseColor, real factor)
+Returns a color darker than \c baseColor by the \c factor provided.
+
+If the factor is greater than 1.0, this function returns a darker color.
+Setting factor to 3.0 returns a color that has one-third the brightness.
+If the factor is less than 1.0, the return color is lighter, but we recommend using
+the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return
+value is unspecified.
+
+The function converts the current RGB color to HSV, divides the value (V) component
+by factor and converts the color back to RGB.
+
+If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0).
+*/
+v8::Handle<v8::Value> darker(const v8::Arguments &args)
+{
+ if (args.Length() != 1 && args.Length() != 2)
+ V8THROW_ERROR("Qt.darker(): Invalid arguments");
+
+ QColor color;
+ QVariant v = V8ENGINE()->toVariant(args[0], -1);
+ if (v.userType() == QVariant::Color) {
+ color = v.value<QColor>();
+ } else if (v.userType() == QVariant::String) {
+ bool ok = false;
+ color = QQmlStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok) {
+ return v8::Null();
+ }
+ } else {
+ return v8::Null();
+ }
+
+ qreal factor = 2.0;
+ if (args.Length() == 2)
+ factor = args[1]->ToNumber()->Value();
+
+ color = color.darker(int(qRound(factor*100.)));
+ return V8ENGINE()->fromVariant(QVariant::fromValue(color));
+}
+
+/*!
+ \qmlmethod color Qt::tint(color baseColor, color tintColor)
+ This function allows tinting one color with another.
+
+ The tint color should usually be mostly transparent, or you will not be
+ able to see the underlying color. The below example provides a slight red
+ tint by having the tint color be pure red which is only 1/16th opaque.
+
+ \qml
+ Item {
+ Rectangle {
+ x: 0; width: 80; height: 80
+ color: "lightsteelblue"
+ }
+ Rectangle {
+ x: 100; width: 80; height: 80
+ color: Qt.tint("lightsteelblue", "#10FF0000")
+ }
+ }
+ \endqml
+ \image declarative-rect_tint.png
+
+ Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color.
+*/
+v8::Handle<v8::Value> tint(const v8::Arguments &args)
+{
+ if (args.Length() != 2)
+ V8THROW_ERROR("Qt.tint(): Invalid arguments");
+
+ // base color
+ QColor color;
+ QVariant v = V8ENGINE()->toVariant(args[0], -1);
+ if (v.userType() == QVariant::Color) {
+ color = v.value<QColor>();
+ } else if (v.userType() == QVariant::String) {
+ bool ok = false;
+ color = QQmlStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok) {
+ return v8::Null();
+ }
+ } else {
+ return v8::Null();
+ }
+
+ // tint color
+ QColor tintColor;
+ v = V8ENGINE()->toVariant(args[1], -1);
+ if (v.userType() == QVariant::Color) {
+ tintColor = v.value<QColor>();
+ } else if (v.userType() == QVariant::String) {
+ bool ok = false;
+ tintColor = QQmlStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok) {
+ return v8::Null();
+ }
+ } else {
+ return v8::Null();
+ }
+
+ // tint the base color and return the final color
+ QColor finalColor;
+ int a = tintColor.alpha();
+ if (a == 0xFF)
+ finalColor = tintColor;
+ else if (a == 0x00)
+ finalColor = color;
+ else {
+ qreal a = tintColor.alphaF();
+ qreal inv_a = 1.0 - a;
+
+ finalColor.setRgbF(tintColor.redF() * a + color.redF() * inv_a,
+ tintColor.greenF() * a + color.greenF() * inv_a,
+ tintColor.blueF() * a + color.blueF() * inv_a,
+ a + inv_a * color.alphaF());
+ }
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(finalColor));
+}
+
+/*!
+\qmlmethod string Qt::formatDate(datetime date, variant format)
+
+Returns a string representation of \c date, optionally formatted according
+to \c format.
+
+The \a date parameter may be a JavaScript \c Date object, a \l{date}{date}
+property, a QDate, or QDateTime value. The \a format parameter may be any of
+the possible format values as described for
+\l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}.
+
+If \a format is not specified, \a date is formatted using
+\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}.
+
+\sa Locale
+*/
+v8::Handle<v8::Value> formatDate(const v8::Arguments &args)
+{
+ if (args.Length() < 1 || args.Length() > 2)
+ V8THROW_ERROR("Qt.formatDate(): Invalid arguments");
+
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ QDate date = V8ENGINE()->toVariant(args[0], -1).toDateTime().date();
+ QString formattedDate;
+ if (args.Length() == 2) {
+ if (args[1]->IsString()) {
+ QString format = V8ENGINE()->toVariant(args[1], -1).toString();
+ formattedDate = date.toString(format);
+ } else if (args[1]->IsNumber()) {
+ quint32 intFormat = args[1]->ToNumber()->Value();
+ Qt::DateFormat format = Qt::DateFormat(intFormat);
+ formattedDate = date.toString(format);
+ } else {
+ V8THROW_ERROR("Qt.formatDate(): Invalid date format");
+ }
+ } else {
+ formattedDate = date.toString(enumFormat);
+ }
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(formattedDate));
+}
+
+/*!
+\qmlmethod string Qt::formatTime(datetime time, variant format)
+
+Returns a string representation of \c time, optionally formatted according to
+\c format.
+
+The \a time parameter may be a JavaScript \c Date object, a QTime, or QDateTime
+value. The \a format parameter may be any of the possible format values as
+described for \l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}.
+
+If \a format is not specified, \a time is formatted using
+\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}.
+
+\sa Locale
+*/
+v8::Handle<v8::Value> formatTime(const v8::Arguments &args)
+{
+ if (args.Length() < 1 || args.Length() > 2)
+ V8THROW_ERROR("Qt.formatTime(): Invalid arguments");
+
+ QVariant argVariant = V8ENGINE()->toVariant(args[0], -1);
+ QTime time;
+ if (args[0]->IsDate() || (argVariant.type() == QVariant::String))
+ time = argVariant.toDateTime().time();
+ else // if (argVariant.type() == QVariant::Time), or invalid.
+ time = argVariant.toTime();
+
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ QString formattedTime;
+ if (args.Length() == 2) {
+ if (args[1]->IsString()) {
+ QString format = V8ENGINE()->toVariant(args[1], -1).toString();
+ formattedTime = time.toString(format);
+ } else if (args[1]->IsNumber()) {
+ quint32 intFormat = args[1]->ToNumber()->Value();
+ Qt::DateFormat format = Qt::DateFormat(intFormat);
+ formattedTime = time.toString(format);
+ } else {
+ V8THROW_ERROR("Qt.formatTime(): Invalid time format");
+ }
+ } else {
+ formattedTime = time.toString(enumFormat);
+ }
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(formattedTime));
+}
+
+/*!
+\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format)
+
+Returns a string representation of \c datetime, optionally formatted according to
+\c format.
+
+The \a date parameter may be a JavaScript \c Date object, a \l{date}{date}
+property, a QDate, QTime, or QDateTime value.
+
+If \a format is not provided, \a dateTime is formatted using
+\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}. Otherwise,
+\a format should be either:
+
+\list
+\o One of the Qt::DateFormat enumeration values, such as
+ \c Qt.DefaultLocaleShortDate or \c Qt.ISODate
+\o A string that specifies the format of the returned string, as detailed below.
+\endlist
+
+If \a format specifies a format string, it should use the following expressions
+to specify the date:
+
+ \table
+ \header \i Expression \i Output
+ \row \i d \i the day as number without a leading zero (1 to 31)
+ \row \i dd \i the day as number with a leading zero (01 to 31)
+ \row \i ddd
+ \i the abbreviated localized day name (e.g. 'Mon' to 'Sun').
+ Uses QDate::shortDayName().
+ \row \i dddd
+ \i the long localized day name (e.g. 'Monday' to 'Qt::Sunday').
+ Uses QDate::longDayName().
+ \row \i M \i the month as number without a leading zero (1-12)
+ \row \i MM \i the month as number with a leading zero (01-12)
+ \row \i MMM
+ \i the abbreviated localized month name (e.g. 'Jan' to 'Dec').
+ Uses QDate::shortMonthName().
+ \row \i MMMM
+ \i the long localized month name (e.g. 'January' to 'December').
+ Uses QDate::longMonthName().
+ \row \i yy \i the year as two digit number (00-99)
+ \row \i yyyy \i the year as four digit number
+ \endtable
+
+In addition the following expressions can be used to specify the time:
+
+ \table
+ \header \i Expression \i Output
+ \row \i h
+ \i the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
+ \row \i hh
+ \i the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
+ \row \i m \i the minute without a leading zero (0 to 59)
+ \row \i mm \i the minute with a leading zero (00 to 59)
+ \row \i s \i the second without a leading zero (0 to 59)
+ \row \i ss \i the second with a leading zero (00 to 59)
+ \row \i z \i the milliseconds without leading zeroes (0 to 999)
+ \row \i zzz \i the milliseconds with leading zeroes (000 to 999)
+ \row \i AP
+ \i use AM/PM display. \e AP will be replaced by either "AM" or "PM".
+ \row \i ap
+ \i use am/pm display. \e ap will be replaced by either "am" or "pm".
+ \endtable
+
+ All other input characters will be ignored. Any sequence of characters that
+ are enclosed in single quotes will be treated as text and not be used as an
+ expression. Two consecutive single quotes ("''") are replaced by a single quote
+ in the output.
+
+For example, if the following date/time value was specified:
+
+ \code
+ // 21 May 2001 14:13:09
+ var dateTime = new Date(2001, 5, 21, 14, 13, 09)
+ \endcode
+
+This \a dateTime value could be passed to \c Qt.formatDateTime(),
+\l {QML:Qt::formatDate()}{Qt.formatDate()} or \l {QML:Qt::formatTime()}{Qt.formatTime()}
+with the \a format values below to produce the following results:
+
+ \table
+ \header \i Format \i Result
+ \row \i "dd.MM.yyyy" \i 21.05.2001
+ \row \i "ddd MMMM d yy" \i Tue May 21 01
+ \row \i "hh:mm:ss.zzz" \i 14:13:09.042
+ \row \i "h:m:s ap" \i 2:13:9 pm
+ \endtable
+
+ \sa Locale
+*/
+v8::Handle<v8::Value> formatDateTime(const v8::Arguments &args)
+{
+ if (args.Length() < 1 || args.Length() > 2)
+ V8THROW_ERROR("Qt.formatDateTime(): Invalid arguments");
+
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ QDateTime dt = V8ENGINE()->toVariant(args[0], -1).toDateTime();
+ QString formattedDt;
+ if (args.Length() == 2) {
+ if (args[1]->IsString()) {
+ QString format = V8ENGINE()->toVariant(args[1], -1).toString();
+ formattedDt = dt.toString(format);
+ } else if (args[1]->IsNumber()) {
+ quint32 intFormat = args[1]->ToNumber()->Value();
+ Qt::DateFormat format = Qt::DateFormat(intFormat);
+ formattedDt = dt.toString(format);
+ } else {
+ V8THROW_ERROR("Qt.formatDateTime(): Invalid datetime format");
+ }
+ } else {
+ formattedDt = dt.toString(enumFormat);
+ }
+
+ return V8ENGINE()->fromVariant(QVariant::fromValue(formattedDt));
+}
+
+/*!
+\qmlmethod bool Qt::openUrlExternally(url target)
+Attempts to open the specified \c target url in an external application, based on the user's desktop preferences. Returns true if it succeeds, and false otherwise.
+*/
+v8::Handle<v8::Value> openUrlExternally(const v8::Arguments &args)
+{
+ if (args.Length() != 1)
+ return V8ENGINE()->fromVariant(false);
+
+ bool ret = false;
+#ifndef QT_NO_DESKTOPSERVICES
+ ret = QDesktopServices::openUrl(V8ENGINE()->toVariant(resolvedUrl(args), -1).toUrl());
+#endif
+ return V8ENGINE()->fromVariant(ret);
+}
+
+/*!
+ \qmlmethod url Qt::resolvedUrl(url url)
+ Returns \a url resolved relative to the URL of the caller.
+*/
+v8::Handle<v8::Value> resolvedUrl(const v8::Arguments &args)
+{
+ QUrl url = V8ENGINE()->toVariant(args[0], -1).toUrl();
+ QQmlEngine *e = V8ENGINE()->engine();
+ QQmlEnginePrivate *p = 0;
+ if (e) p = QQmlEnginePrivate::get(e);
+ if (p) {
+ QQmlContextData *ctxt = V8ENGINE()->callingContext();
+ if (ctxt)
+ return V8ENGINE()->toString(ctxt->resolvedUrl(url).toString());
+ else
+ return V8ENGINE()->toString(url.toString());
+ }
+
+ return V8ENGINE()->toString(e->baseUrl().resolved(url).toString());
+}
+
+/*!
+\qmlmethod list<string> Qt::fontFamilies()
+Returns a list of the font families available to the application.
+*/
+v8::Handle<v8::Value> fontFamilies(const v8::Arguments &args)
+{
+ if (args.Length() != 0)
+ V8THROW_ERROR("Qt.fontFamilies(): Invalid arguments");
+
+ QFontDatabase database;
+ return V8ENGINE()->fromVariant(database.families());
+}
+
+/*!
+\qmlmethod string Qt::md5(data)
+Returns a hex string of the md5 hash of \c data.
+*/
+v8::Handle<v8::Value> md5(const v8::Arguments &args)
+{
+ if (args.Length() != 1)
+ V8THROW_ERROR("Qt.md5(): Invalid arguments");
+
+ QByteArray data = V8ENGINE()->toString(args[0]->ToString()).toUtf8();
+ QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5);
+ return V8ENGINE()->toString(QLatin1String(result.toHex()));
+}
+
+/*!
+\qmlmethod string Qt::btoa(data)
+Binary to ASCII - this function returns a base64 encoding of \c data.
+*/
+v8::Handle<v8::Value> btoa(const v8::Arguments &args)
+{
+ if (args.Length() != 1)
+ V8THROW_ERROR("Qt.btoa(): Invalid arguments");
+
+ QByteArray data = V8ENGINE()->toString(args[0]->ToString()).toUtf8();
+
+ return V8ENGINE()->toString(QLatin1String(data.toBase64()));
+}
+
+/*!
+\qmlmethod string Qt::atob(data)
+ASCII to binary - this function returns a base64 decoding of \c data.
+*/
+v8::Handle<v8::Value> atob(const v8::Arguments &args)
+{
+ if (args.Length() != 1)
+ V8THROW_ERROR("Qt.atob(): Invalid arguments");
+
+ QByteArray data = V8ENGINE()->toString(args[0]->ToString()).toUtf8();
+
+ return V8ENGINE()->toString(QLatin1String(QByteArray::fromBase64(data)));
+}
+
+/*!
+\qmlmethod Qt::quit()
+This function causes the QQmlEngine::quit() signal to be emitted.
+Within the \l {QML Viewer}, this causes the launcher application to exit;
+to quit a C++ application when this method is called, connect the
+QQmlEngine::quit() signal to the QCoreApplication::quit() slot.
+*/
+v8::Handle<v8::Value> quit(const v8::Arguments &args)
+{
+ QQmlEnginePrivate::get(V8ENGINE()->engine())->sendQuit();
+ return v8::Undefined();
+}
+
+/*!
+\qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath)
+
+Returns a new object created from the given \a string of QML which will have the specified \a parent,
+or \c null if there was an error in creating the object.
+
+If \a filepath is specified, it will be used for error reporting for the created object.
+
+Example (where \c parentItem is the id of an existing QML item):
+
+\snippet doc/src/snippets/qml/createQmlObject.qml 0
+
+In the case of an error, a QtScript Error object is thrown. This object has an additional property,
+\c qmlErrors, which is an array of the errors encountered.
+Each object in this array has the members \c lineNumber, \c columnNumber, \c fileName and \c message.
+For example, if the above snippet had misspelled color as 'colro' then the array would contain an object like the following:
+{ "lineNumber" : 1, "columnNumber" : 32, "fileName" : "dynamicSnippet1", "message" : "Cannot assign to non-existent property \"colro\""}.
+
+Note that this function returns immediately, and therefore may not work if
+the \a qml string loads new components (that is, external QML files that have not yet been loaded).
+If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead.
+
+See \l {Dynamic Object Management in QML} for more information on using this function.
+*/
+v8::Handle<v8::Value> createQmlObject(const v8::Arguments &args)
+{
+ if (args.Length() < 2 || args.Length() > 3)
+ V8THROW_ERROR("Qt.createQmlObject(): Invalid arguments");
+
+ struct Error {
+ static v8::Local<v8::Value> create(QV8Engine *engine, const QList<QQmlError> &errors) {
+ QString errorstr = QLatin1String("Qt.createQmlObject(): failed to create object: ");
+
+ v8::Local<v8::Array> qmlerrors = v8::Array::New(errors.count());
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QQmlError &error = errors.at(ii);
+ errorstr += QLatin1String("\n ") + error.toString();
+ v8::Local<v8::Object> qmlerror = v8::Object::New();
+ qmlerror->Set(v8::String::New("lineNumber"), v8::Integer::New(error.line()));
+ qmlerror->Set(v8::String::New("columnNumber"), v8::Integer::New(error.column()));
+ qmlerror->Set(v8::String::New("fileName"), engine->toString(error.url().toString()));
+ qmlerror->Set(v8::String::New("message"), engine->toString(error.description()));
+ qmlerrors->Set(ii, qmlerror);
+ }
+
+ v8::Local<v8::Value> error = v8::Exception::Error(engine->toString(errorstr));
+ v8::Local<v8::Object> errorObject = error->ToObject();
+ errorObject->Set(v8::String::New("qmlErrors"), qmlerrors);
+ return error;
+ }
+ };
+
+ QV8Engine *v8engine = V8ENGINE();
+ QQmlEngine *engine = v8engine->engine();
+
+ QQmlContextData *context = v8engine->callingContext();
+ QQmlContext *effectiveContext = 0;
+ if (context->isPragmaLibraryContext)
+ effectiveContext = engine->rootContext();
+ else
+ effectiveContext = context->asQQmlContext();
+ Q_ASSERT(context && effectiveContext);
+
+ QString qml = v8engine->toString(args[0]->ToString());
+ if (qml.isEmpty())
+ return v8::Null();
+
+ QUrl url;
+ if (args.Length() > 2)
+ url = QUrl(v8engine->toString(args[2]->ToString()));
+ else
+ url = QUrl(QLatin1String("inline"));
+
+ if (url.isValid() && url.isRelative())
+ url = context->resolvedUrl(url);
+
+ QObject *parentArg = v8engine->toQObject(args[1]);
+ if (!parentArg)
+ V8THROW_ERROR("Qt.createQmlObject(): Missing parent object");
+
+ QQmlComponent component(engine);
+ component.setData(qml.toUtf8(), url);
+
+ if (component.isError()) {
+ v8::ThrowException(Error::create(v8engine, component.errors()));
+ return v8::Undefined();
+ }
+
+ if (!component.isReady())
+ V8THROW_ERROR("Qt.createQmlObject(): Component is not ready");
+
+ QObject *obj = component.beginCreate(effectiveContext);
+ if (obj) {
+ QQmlData::get(obj, true)->setImplicitDestructible();
+
+ obj->setParent(parentArg);
+
+ QList<QQmlPrivate::AutoParentFunction> functions = QQmlMetaType::parentFunctions();
+ for (int ii = 0; ii < functions.count(); ++ii) {
+ if (QQmlPrivate::Parented == functions.at(ii)(obj, parentArg))
+ break;
+ }
+ }
+ component.completeCreate();
+
+ if (component.isError()) {
+ v8::ThrowException(Error::create(v8engine, component.errors()));
+ return v8::Undefined();
+ }
+
+ Q_ASSERT(obj);
+
+ return v8engine->newQObject(obj);
+}
+
+/*!
+\qmlmethod object Qt::createComponent(url)
+
+Returns a \l Component object created using the QML file at the specified \a url,
+or \c null if an empty string was given.
+
+The returned component's \l Component::status property indicates whether the
+component was successfully created. If the status is \c Component.Error,
+see \l Component::errorString() for an error description.
+
+Call \l {Component::createObject()}{Component.createObject()} on the returned
+component to create an object instance of the component.
+
+For example:
+
+\snippet doc/src/snippets/qml/createComponent-simple.qml 0
+
+See \l {Dynamic Object Management in QML} for more information on using this function.
+
+To create a QML object from an arbitrary string of QML (instead of a file),
+use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}.
+*/
+v8::Handle<v8::Value> createComponent(const v8::Arguments &args)
+{
+ if (args.Length() != 1)
+ V8THROW_ERROR("Qt.createComponent(): Invalid arguments");
+
+ QV8Engine *v8engine = V8ENGINE();
+ QQmlEngine *engine = v8engine->engine();
+
+ QQmlContextData *context = v8engine->callingContext();
+ QQmlContextData *effectiveContext = context;
+ if (context->isPragmaLibraryContext)
+ effectiveContext = 0;
+ Q_ASSERT(context);
+
+ QString arg = v8engine->toString(args[0]->ToString());
+ if (arg.isEmpty())
+ return v8::Null();
+
+ QUrl url = context->resolvedUrl(QUrl(arg));
+ QQmlComponent *c = new QQmlComponent(engine, url, engine);
+ QQmlComponentPrivate::get(c)->creationContext = effectiveContext;
+ QQmlData::get(c, true)->setImplicitDestructible();
+ return v8engine->newQObject(c);
+}
+
+v8::Handle<v8::Value> qsTranslate(const v8::Arguments &args)
+{
+ if (args.Length() < 2)
+ V8THROW_ERROR("qsTranslate() requires at least two arguments");
+ if (!args[0]->IsString())
+ V8THROW_ERROR("qsTranslate(): first argument (context) must be a string");
+ if (!args[1]->IsString())
+ V8THROW_ERROR("qsTranslate(): second argument (text) must be a string");
+ if ((args.Length() > 2) && !args[2]->IsString())
+ V8THROW_ERROR("qsTranslate(): third argument (comment) must be a string");
+ if ((args.Length() > 3) && !args[3]->IsString())
+ V8THROW_ERROR("qsTranslate(): fourth argument (encoding) must be a string");
+
+ QV8Engine *v8engine = V8ENGINE();
+ QString context = v8engine->toString(args[0]);
+ QString text = v8engine->toString(args[1]);
+ QString comment;
+ if (args.Length() > 2) comment = v8engine->toString(args[2]);
+
+ QCoreApplication::Encoding encoding = QCoreApplication::UnicodeUTF8;
+ if (args.Length() > 3) {
+ QString encStr = v8engine->toString(args[3]);
+ if (encStr == QLatin1String("CodecForTr")) {
+ encoding = QCoreApplication::CodecForTr;
+ } else if (encStr == QLatin1String("UnicodeUTF8")) {
+ encoding = QCoreApplication::UnicodeUTF8;
+ } else {
+ QString msg = QString::fromLatin1("qsTranslate(): invalid encoding '%0'").arg(encStr);
+ V8THROW_ERROR((uint16_t *)msg.constData());
+ }
+ }
+
+ int n = -1;
+ if (args.Length() > 4)
+ n = args[4]->Int32Value();
+
+ QString result = QCoreApplication::translate(context.toUtf8().constData(),
+ text.toUtf8().constData(),
+ comment.toUtf8().constData(),
+ encoding, n);
+
+ return v8engine->toString(result);
+}
+
+v8::Handle<v8::Value> qsTranslateNoOp(const v8::Arguments &args)
+{
+ if (args.Length() < 2)
+ return v8::Undefined();
+ return args[1];
+}
+
+v8::Handle<v8::Value> qsTr(const v8::Arguments &args)
+{
+ if (args.Length() < 1)
+ V8THROW_ERROR("qsTr() requires at least one argument");
+ if (!args[0]->IsString())
+ V8THROW_ERROR("qsTr(): first argument (text) must be a string");
+ if ((args.Length() > 1) && !args[1]->IsString())
+ V8THROW_ERROR("qsTr(): second argument (comment) must be a string");
+ if ((args.Length() > 2) && !args[2]->IsNumber())
+ V8THROW_ERROR("qsTr(): third argument (n) must be a number");
+
+ QV8Engine *v8engine = V8ENGINE();
+ QQmlContextData *ctxt = v8engine->callingContext();
+
+ QString path = ctxt->url.toString();
+ int lastSlash = path.lastIndexOf(QLatin1Char('/'));
+ QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, path.length()-lastSlash-5) : QString();
+
+ QString text = v8engine->toString(args[0]);
+ QString comment;
+ if (args.Length() > 1)
+ comment = v8engine->toString(args[1]);
+ int n = -1;
+ if (args.Length() > 2)
+ n = args[2]->Int32Value();
+
+ QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(),
+ comment.toUtf8().constData(), QCoreApplication::UnicodeUTF8, n);
+
+ return v8engine->toString(result);
+}
+
+v8::Handle<v8::Value> qsTrNoOp(const v8::Arguments &args)
+{
+ if (args.Length() < 1)
+ return v8::Undefined();
+ return args[0];
+}
+
+v8::Handle<v8::Value> qsTrId(const v8::Arguments &args)
+{
+ if (args.Length() < 1)
+ V8THROW_ERROR("qsTrId() requires at least one argument");
+ if (!args[0]->IsString())
+ V8THROW_TYPE("qsTrId(): first argument (id) must be a string");
+ if (args.Length() > 1 && !args[1]->IsNumber())
+ V8THROW_TYPE("qsTrId(): second argument (n) must be a number");
+
+ int n = -1;
+ if (args.Length() > 1)
+ n = args[1]->Int32Value();
+
+ QV8Engine *v8engine = V8ENGINE();
+ return v8engine->toString(qtTrId(v8engine->toString(args[0]).toUtf8().constData(), n));
+}
+
+v8::Handle<v8::Value> qsTrIdNoOp(const v8::Arguments &args)
+{
+ if (args.Length() < 1)
+ return v8::Undefined();
+ return args[0];
+}
+
+
+/*!
+ \qmlmethod Qt::locale(name)
+
+ Returns a JS object representing the locale with the specified
+ name, which has the format "language[_territory][.codeset][@modifier]"
+ or "C", where:
+
+ \list
+ \o language is a lowercase, two-letter, ISO 639 language code,
+ \o territory is an uppercase, two-letter, ISO 3166 country code,
+ \o and codeset and modifier are ignored.
+ \endlist
+
+ If the string violates the locale format, or language is not a
+ valid ISO 369 code, the "C" locale is used instead. If country
+ is not present, or is not a valid ISO 3166 code, the most
+ appropriate country is chosen for the specified language.
+
+ \sa QtQuick2::Locale
+*/
+v8::Handle<v8::Value> locale(const v8::Arguments &args)
+{
+ QString code;
+ if (args.Length() > 1)
+ V8THROW_ERROR("locale() requires 0 or 1 argument");
+ if (args.Length() == 1 && !args[0]->IsString())
+ V8THROW_TYPE("locale(): argument (locale code) must be a string");
+
+ QV8Engine *v8engine = V8ENGINE();
+ if (args.Length() == 1)
+ code = v8engine->toString(args[0]);
+
+ return QQmlLocale::locale(v8engine, code);
+}
+
+} // namespace QQmlBuiltinFunctions
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
new file mode 100644
index 0000000000..ddb1c64243
--- /dev/null
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLBUILTINFUNCTIONS_P_H
+#define QQMLBUILTINFUNCTIONS_P_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 <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QQmlBuiltinFunctions
+{
+v8::Handle<v8::Value> gc(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleError(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleLog(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleProfile(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleProfileEnd(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleTime(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleTimeEnd(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleCount(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleTrace(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleWarn(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleAssert(const v8::Arguments &args);
+v8::Handle<v8::Value> consoleException(const v8::Arguments &args);
+v8::Handle<v8::Value> isQtObject(const v8::Arguments &args);
+v8::Handle<v8::Value> rgba(const v8::Arguments &args);
+v8::Handle<v8::Value> hsla(const v8::Arguments &args);
+v8::Handle<v8::Value> rect(const v8::Arguments &args);
+v8::Handle<v8::Value> point(const v8::Arguments &args);
+v8::Handle<v8::Value> size(const v8::Arguments &args);
+v8::Handle<v8::Value> vector3d(const v8::Arguments &args);
+v8::Handle<v8::Value> vector4d(const v8::Arguments &args);
+v8::Handle<v8::Value> lighter(const v8::Arguments &args);
+v8::Handle<v8::Value> darker(const v8::Arguments &args);
+v8::Handle<v8::Value> tint(const v8::Arguments &args);
+v8::Handle<v8::Value> formatDate(const v8::Arguments &args);
+v8::Handle<v8::Value> formatTime(const v8::Arguments &args);
+v8::Handle<v8::Value> formatDateTime(const v8::Arguments &args);
+v8::Handle<v8::Value> openUrlExternally(const v8::Arguments &args);
+v8::Handle<v8::Value> fontFamilies(const v8::Arguments &args);
+v8::Handle<v8::Value> md5(const v8::Arguments &args);
+v8::Handle<v8::Value> btoa(const v8::Arguments &args);
+v8::Handle<v8::Value> atob(const v8::Arguments &args);
+v8::Handle<v8::Value> quit(const v8::Arguments &args);
+v8::Handle<v8::Value> resolvedUrl(const v8::Arguments &args);
+v8::Handle<v8::Value> createQmlObject(const v8::Arguments &args);
+v8::Handle<v8::Value> createComponent(const v8::Arguments &args);
+v8::Handle<v8::Value> qsTranslate(const v8::Arguments &args);
+v8::Handle<v8::Value> qsTranslateNoOp(const v8::Arguments &args);
+v8::Handle<v8::Value> qsTr(const v8::Arguments &args);
+v8::Handle<v8::Value> qsTrNoOp(const v8::Arguments &args);
+v8::Handle<v8::Value> qsTrId(const v8::Arguments &args);
+v8::Handle<v8::Value> qsTrIdNoOp(const v8::Arguments &args);
+v8::Handle<v8::Value> stringArg(const v8::Arguments &args);
+v8::Handle<v8::Value> locale(const v8::Arguments &args);
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLBUILTINFUNCTIONS_P_H
diff --git a/src/qml/qml/v8/qscript_impl_p.h b/src/qml/qml/v8/qscript_impl_p.h
new file mode 100644
index 0000000000..d4acc4502a
--- /dev/null
+++ b/src/qml/qml/v8/qscript_impl_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// 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.
+//
+
+#ifndef QSCRIPT_IMPL_P_H
+#define QSCRIPT_IMPL_P_H
+
+#include "qv8engine_impl_p.h"
+#include "qjsvalue_impl_p.h"
+#include "qjsvalueiterator_impl_p.h"
+#include "qjsconverter_impl_p.h"
+
+#endif //QSCRIPT_IMPL_P_H
diff --git a/src/qml/qml/v8/qscriptisolate_p.h b/src/qml/qml/v8/qscriptisolate_p.h
new file mode 100644
index 0000000000..77848557a4
--- /dev/null
+++ b/src/qml/qml/v8/qscriptisolate_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef APIPREAMBLE_P_H
+#define APIPREAMBLE_P_H
+
+#include <private/qv8_p.h>
+#include "qv8engine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/**
+ \internal
+ Class used to switch to the right isolate. It does the same thing as v8::Isolate::Scope but
+ it checks for a null engine.
+ \attention We decided to put context switching "up" which means that it should be as high
+ as possible on call stack. And it should be switched at most once per public API function call.
+*/
+class QScriptIsolate {
+public:
+ // OperationMode was introduced to reduce number of checking for a null engine pointer. If we
+ // know that given pointer is not null than we should pass NotNullEngine as constructor argument
+ // that would nicely remove checking on compilation time.
+ enum OperationMode {Default, NotNullEngine};
+ inline QScriptIsolate(const QV8Engine *engine, const OperationMode mode = Default)
+ : m_engine(engine)
+ , m_mode(mode)
+ {
+ if (m_mode == NotNullEngine || m_engine) {
+ Q_ASSERT(m_engine);
+ m_engine->context()->Enter();
+ }
+ }
+
+ inline ~QScriptIsolate()
+ {
+ if (m_mode == NotNullEngine || m_engine) {
+ m_engine->context()->Exit();
+ }
+ }
+
+private:
+ Q_DISABLE_COPY(QScriptIsolate);
+ const QV8Engine *m_engine;
+ const OperationMode m_mode;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // APIPREAMBLE_P_H
diff --git a/src/qml/qml/v8/qscriptoriginalglobalobject_p.h b/src/qml/qml/v8/qscriptoriginalglobalobject_p.h
new file mode 100644
index 0000000000..e4661c1bf2
--- /dev/null
+++ b/src/qml/qml/v8/qscriptoriginalglobalobject_p.h
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCRIPTORIGINALGLOBALOBJECT_P_H
+#define QSCRIPTORIGINALGLOBALOBJECT_P_H
+
+#include "QtCore/qglobal.h"
+#include "qjsvalue_p.h"
+
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+
+/*!
+ \internal
+ This class is a workaround for missing V8 API functionality. This class keeps all important
+ properties of an original (default) global object, so we can use it even if the global object was
+ changed.
+
+ FIXME this class is a container for workarounds :-) it should be replaced by proper API calls.
+
+ The class have to be created on the QV8Engine creation time (before any change got applied to
+ global object).
+
+ \attention All methods (apart from constructor) assumes that a context and a scope are prepared correctly.
+*/
+class QScriptOriginalGlobalObject
+{
+public:
+ inline QScriptOriginalGlobalObject() {}
+ inline void init(v8::Handle<v8::Context> context);
+ inline void destroy();
+
+ inline QJSValuePrivate::PropertyFlags getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property);
+ inline v8::Local<v8::Object> getOwnPropertyDescriptor(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property) const;
+ inline bool strictlyEquals(v8::Handle<v8::Object> object);
+private:
+ Q_DISABLE_COPY(QScriptOriginalGlobalObject)
+
+ // Copy of constructors and prototypes used in isType functions.
+ v8::Persistent<v8::Function> m_ownPropertyDescriptor;
+ v8::Persistent<v8::Object> m_globalObject;
+};
+
+void QScriptOriginalGlobalObject::init(v8::Handle<v8::Context> context)
+{
+ // Please notice that engine is not fully initialized at this point.
+
+ v8::Context::Scope contextScope(context);
+
+ v8::HandleScope scope;
+
+ m_globalObject = v8::Persistent<v8::Object>::New(context->Global());
+
+ v8::Local<v8::Object> objectConstructor = m_globalObject->Get(v8::String::New("Object"))->ToObject();
+ Q_ASSERT(objectConstructor->IsObject());
+ { // Initialize m_ownPropertyDescriptor.
+ v8::Local<v8::Value> ownPropertyDescriptor = objectConstructor->Get(v8::String::New("getOwnPropertyDescriptor"));
+ Q_ASSERT(!ownPropertyDescriptor.IsEmpty());
+ m_ownPropertyDescriptor = v8::Persistent<v8::Function>::New(v8::Local<v8::Function>::Cast(ownPropertyDescriptor));
+ }
+}
+
+/*!
+ \internal
+ QScriptOriginalGlobalObject lives as long as QV8Engine that keeps it. In ~QSEP
+ the v8 context is removed, so we need to remove our handlers before. to break this dependency
+ destroy method should be called before or insight QSEP destructor.
+*/
+inline void QScriptOriginalGlobalObject::destroy()
+{
+ m_ownPropertyDescriptor.Dispose();
+ m_globalObject.Dispose();
+ // After this line this instance is unusable.
+}
+
+inline QJSValuePrivate::PropertyFlags QScriptOriginalGlobalObject::getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property)
+{
+ Q_ASSERT(object->IsObject());
+ Q_ASSERT(!property.IsEmpty());
+ v8::Local<v8::Object> descriptor = getOwnPropertyDescriptor(object, property);
+ if (descriptor.IsEmpty()) {
+// // Property isn't owned by this object.
+// if (!(mode & QScriptValue::ResolvePrototype))
+// return 0;
+ v8::Local<v8::Value> prototype = object->GetPrototype();
+ if (prototype->IsNull())
+ return 0;
+ return getPropertyFlags(v8::Local<v8::Object>::Cast(prototype), property);
+ }
+ v8::Local<v8::String> writableName = v8::String::New("writable");
+ v8::Local<v8::String> configurableName = v8::String::New("configurable");
+ v8::Local<v8::String> enumerableName = v8::String::New("enumerable");
+// v8::Local<v8::String> getName = v8::String::New("get");
+// v8::Local<v8::String> setName = v8::String::New("set");
+
+ unsigned flags = 0;
+
+ if (!descriptor->Get(configurableName)->BooleanValue())
+ flags |= QJSValuePrivate::Undeletable;
+ if (!descriptor->Get(enumerableName)->BooleanValue())
+ flags |= QJSValuePrivate::SkipInEnumeration;
+
+ //"writable" is only a property of the descriptor if it is not an accessor
+ if (descriptor->Has(writableName)) {
+ if (!descriptor->Get(writableName)->BooleanValue())
+ flags |= QJSValuePrivate::ReadOnly;
+ } else {
+// if (descriptor->Get(getName)->IsObject())
+// flags |= QScriptValue::PropertyGetter;
+// if (descriptor->Get(setName)->IsObject())
+// flags |= QScriptValue::PropertySetter;
+ }
+
+ return QJSValuePrivate::PropertyFlag(flags);
+}
+
+inline v8::Local<v8::Object> QScriptOriginalGlobalObject::getOwnPropertyDescriptor(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property) const
+{
+ Q_ASSERT(object->IsObject());
+ Q_ASSERT(!property.IsEmpty());
+ // FIXME do we need try catch here?
+ v8::Handle<v8::Value> argv[] = {object, property};
+ v8::Local<v8::Value> descriptor = m_ownPropertyDescriptor->Call(m_globalObject, /* argc */ 2, argv);
+ if (descriptor.IsEmpty() || !descriptor->IsObject())
+ return v8::Local<v8::Object>();
+ return v8::Local<v8::Object>::Cast(descriptor);
+}
+
+inline bool QScriptOriginalGlobalObject::strictlyEquals(v8::Handle<v8::Object> object)
+{
+ return m_globalObject->GetPrototype()->StrictEquals(object);
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/qml/v8/qscriptshareddata_p.h b/src/qml/qml/v8/qscriptshareddata_p.h
new file mode 100644
index 0000000000..d3491c70ee
--- /dev/null
+++ b/src/qml/qml/v8/qscriptshareddata_p.h
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// 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.
+//
+
+#ifndef QSCRIPTSHAREDDATA_P_H
+#define QSCRIPTSHAREDDATA_P_H
+
+#include "qglobal.h"
+#include "qshareddata.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+ This class should have the same interface as the QSharedData, but implementation doesn't
+ need to be thread safe, so atomic ref count was replaced by normal integer value.
+*/
+class QScriptSharedData
+{
+public:
+ class ReferenceCounter {
+ // FIXME shouldn't it be uint or something longer?
+ mutable int m_ref;
+ ReferenceCounter(int ref) : m_ref(ref) {}
+ ~ReferenceCounter() { Q_ASSERT_X(!m_ref, Q_FUNC_INFO, "Memory problem found"); }
+ public:
+ bool ref() { return ++m_ref; }
+ bool deref() { return --m_ref; }
+ friend class QScriptSharedData;
+ };
+
+ ReferenceCounter ref;
+ inline QScriptSharedData() : ref(0) { }
+
+private:
+ Q_DISABLE_COPY(QScriptSharedData)
+};
+
+
+template <class T> class QScriptPassPointer;
+
+// FIXME: that could be reimplemented to not check for a null value.
+template<class T>
+class QScriptSharedDataPointer : public QExplicitlySharedDataPointer<T>
+{
+public:
+ inline QScriptSharedDataPointer() {}
+ explicit QScriptSharedDataPointer(QScriptPassPointer<T> data) : QExplicitlySharedDataPointer<T>(data.give()) {}
+ explicit QScriptSharedDataPointer(T *data) : QExplicitlySharedDataPointer<T>(data) {}
+
+ inline QScriptSharedDataPointer<T> &operator=(const QScriptPassPointer<T> &other)
+ {
+ this->QExplicitlySharedDataPointer<T>::operator =(other.give());
+ return *this;
+ }
+ inline QScriptSharedDataPointer<T> &operator=(T *other)
+ {
+ this->QExplicitlySharedDataPointer<T>::operator =(other);
+ return *this;
+ }
+};
+
+// FIXME: that could be reimplemented to not check for a null value.
+template <class T>
+class QScriptPassPointer {
+public:
+ QScriptPassPointer(T *data) : m_ptr(data) {}
+ inline QScriptPassPointer() { m_ptr = 0; }
+ inline QScriptPassPointer(const QScriptPassPointer<T> &other) : m_ptr(other.give()) {}
+ inline ~QScriptPassPointer() { Q_ASSERT_X(!m_ptr, Q_FUNC_INFO, "Ownership of the QScriptPassPointer hasn't been taken"); }
+
+ inline T &operator*() const { return *m_ptr; }
+ inline T *operator->() { return m_ptr; }
+ inline T *operator->() const { return m_ptr; }
+ inline T *data() const { return m_ptr; }
+ inline const T *constData() const { return m_ptr; }
+
+ inline bool operator==(const QScriptPassPointer<T> &other) const { return m_ptr == other.m_ptr; }
+ inline bool operator!=(const QScriptPassPointer<T> &other) const { return m_ptr != other.m_ptr; }
+ inline bool operator==(const QScriptSharedDataPointer<T> &other) const { return m_ptr == other.m_ptr; }
+ inline bool operator!=(const QScriptSharedDataPointer<T> &other) const { return m_ptr != other.m_ptr; }
+ inline bool operator==(const T *ptr) const { return m_ptr == ptr; }
+ inline bool operator!=(const T *ptr) const { return m_ptr != ptr; }
+
+ inline operator bool () const { return m_ptr != 0; }
+ inline bool operator!() const { return !m_ptr; }
+
+ inline QScriptPassPointer<T> & operator=(const QScriptPassPointer<T> &other)
+ {
+ if (other.m_ptr != m_ptr) {
+ if (m_ptr)
+ delete m_ptr;
+ m_ptr = other.give();
+ }
+ return *this;
+ }
+
+ inline QScriptPassPointer &operator=(T *other)
+ {
+ if (other != m_ptr) {
+ if (m_ptr)
+ delete m_ptr;
+ m_ptr = other;
+ }
+ return *this;
+ }
+
+ inline T* give() const
+ {
+ T* result = m_ptr;
+ m_ptr = 0;
+ return result;
+ }
+
+private:
+ mutable T* m_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSCRIPTSHAREDDATA_P_H
diff --git a/src/qml/qml/v8/qscripttools_p.h b/src/qml/qml/v8/qscripttools_p.h
new file mode 100644
index 0000000000..d69e9c83ad
--- /dev/null
+++ b/src/qml/qml/v8/qscripttools_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// 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.
+//
+
+
+#ifndef QSCRIPTTOOLS_P_H
+#define QSCRIPTTOOLS_P_H
+
+#include <private/qintrusivelist_p.h>
+
+QT_BEGIN_NAMESPACE
+
+template<class N, QIntrusiveListNode N::*member>
+class QScriptIntrusiveList : public QIntrusiveList<N, member>
+{
+public:
+ inline void insert(N *n);
+ inline void remove(N *n);
+};
+
+template<class N, QIntrusiveListNode N::*member>
+void QScriptIntrusiveList<N, member>::insert(N *n)
+{
+ Q_ASSERT_X(!this->contains(n), Q_FUNC_INFO, "Can't insert a value which is in the list already");
+ Q_ASSERT_X(!(n->*member).isInList(), Q_FUNC_INFO, "Can't insert a value which is in another list");
+ QIntrusiveList<N, member>::insert(n);
+}
+
+template<class N, QIntrusiveListNode N::*member>
+void QScriptIntrusiveList<N, member>::remove(N *n)
+{
+ Q_ASSERT_X(this->contains(n), Q_FUNC_INFO, "Can't remove a value which is not in the list");
+ QIntrusiveList<N, member>::remove(n);
+}
+
+QT_END_NAMESPACE
+
+#endif //QSCRIPTTOOLS_P_H
diff --git a/src/qml/qml/v8/qv8_p.h b/src/qml/qml/v8/qv8_p.h
new file mode 100644
index 0000000000..d6a06593f5
--- /dev/null
+++ b/src/qml/qml/v8/qv8_p.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/v8.h>
diff --git a/src/qml/qml/v8/qv8bindings.cpp b/src/qml/qml/v8/qv8bindings.cpp
new file mode 100644
index 0000000000..76fbea137e
--- /dev/null
+++ b/src/qml/qml/v8/qv8bindings.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8bindings_p.h"
+
+#include <private/qv8_p.h>
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlcompiler_p.h>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlbinding_p_p.h>
+#include <private/qqmlexpression_p.h>
+#include <private/qobject_p.h>
+#include <private/qqmltrace_p.h>
+#include <private/qqmlprofilerservice_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static QQmlJavaScriptExpression::VTable QV8Bindings_Binding_jsvtable = {
+ QV8Bindings::Binding::expressionIdentifier,
+ QV8Bindings::Binding::expressionChanged
+};
+
+QV8Bindings::Binding::Binding()
+: QQmlJavaScriptExpression(&QV8Bindings_Binding_jsvtable), target(0), parent(0)
+{
+}
+
+void QV8Bindings::Binding::setEnabled(bool e, QQmlPropertyPrivate::WriteFlags flags)
+{
+ if (enabledFlag() != e) {
+ setEnabledFlag(e);
+
+ if (e) update(flags);
+ }
+}
+
+void QV8Bindings::refresh()
+{
+ int count = functions()->Length();
+ for (int ii = 0; ii < count; ++ii)
+ bindings[ii].refresh();
+}
+
+void QV8Bindings::Binding::refresh()
+{
+ update();
+}
+
+int QV8Bindings::Binding::propertyIndex() const
+{
+ return instruction->property.encodedIndex();
+}
+
+QObject *QV8Bindings::Binding::object() const
+{
+ return target;
+}
+
+void QV8Bindings::Binding::update(QQmlPropertyPrivate::WriteFlags flags)
+{
+ if (!enabledFlag())
+ return;
+
+ QQmlTrace trace("V8 Binding Update");
+ trace.addDetail("URL", parent->url());
+ trace.addDetail("Line", instruction->line);
+ trace.addDetail("Column", instruction->column);
+
+ QQmlBindingProfiler prof(parent->urlString(), instruction->line, instruction->column);
+
+ QQmlContextData *context = parent->context();
+ if (!context || !context->isValid())
+ return;
+
+ if (!updatingFlag()) {
+ setUpdatingFlag(true);
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
+
+ bool isUndefined = false;
+
+ DeleteWatcher watcher(this);
+ ep->referenceScarceResources();
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(ep->v8engine()->context());
+ v8::Local<v8::Value> result =
+ evaluate(context,
+ v8::Handle<v8::Function>::Cast(parent->functions()->Get(instruction->value)),
+ &isUndefined);
+
+ trace.event("writing V8 result");
+ bool needsErrorData = false;
+ if (!watcher.wasDeleted() && !hasError()) {
+ typedef QQmlPropertyPrivate PP;
+ needsErrorData = !PP::writeBinding(target, instruction->property, context, this, result,
+ isUndefined, flags);
+ }
+
+ if (!watcher.wasDeleted()) {
+
+ if (needsErrorData) {
+ QUrl url = parent->url();
+ if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
+
+ delayedError()->error.setUrl(url);
+ delayedError()->error.setLine(instruction->line);
+ delayedError()->error.setColumn(-1);
+ }
+
+ if (hasError()) {
+ if (!delayedError()->addError(ep)) ep->warning(delayedError()->error);
+ } else {
+ clearError();
+ }
+
+ setUpdatingFlag(false);
+ }
+
+ ep->dereferenceScarceResources();
+
+ } else {
+ QQmlProperty p = QQmlPropertyPrivate::restore(target, instruction->property,
+ context);
+ QQmlBindingPrivate::printBindingLoopError(p);
+ }
+}
+
+QString QV8Bindings::Binding::expressionIdentifier(QQmlJavaScriptExpression *e)
+{
+ Binding *This = static_cast<Binding *>(e);
+ return This->parent->urlString() + QLatin1String(":") +
+ QString::number(This->instruction->line);
+}
+
+void QV8Bindings::Binding::expressionChanged(QQmlJavaScriptExpression *e)
+{
+ Binding *This = static_cast<Binding *>(e);
+ This->update(QQmlPropertyPrivate::DontRemoveBinding);
+}
+
+void QV8Bindings::Binding::destroy()
+{
+ setEnabledFlag(false);
+ removeFromObject();
+ clear();
+ clearError();
+ parent->release();
+}
+
+QV8Bindings::QV8Bindings(QQmlCompiledData::V8Program *program,
+ int line,
+ QQmlContextData *context)
+: program(program), bindings(0), refCount(1)
+{
+ program->cdata->addref();
+
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(context->engine);
+
+ if (program->bindings.IsEmpty()) {
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+
+ v8::Local<v8::Script> script;
+ bool compileFailed = false;
+ {
+ v8::TryCatch try_catch;
+ const QByteArray &source = program->program;
+ script = engine->qmlModeCompile(source.constData(), source.length(),
+ program->cdata->name, line);
+ if (try_catch.HasCaught()) {
+ // The binding was not compiled. There are some exceptional cases which the
+ // expression rewriter does not rewrite properly (e.g., \r-terminated lines
+ // are not rewritten correctly but this bug is demed out-of-scope to fix for
+ // performance reasons; see QTBUG-24064).
+ compileFailed = true;
+ QQmlError error;
+ error.setDescription(QString(QLatin1String("Exception occurred during compilation of binding at line: %1")).arg(line));
+ v8::Local<v8::Message> message = try_catch.Message();
+ if (!message.IsEmpty())
+ QQmlExpressionPrivate::exceptionToError(message, error);
+ QQmlEnginePrivate::get(engine->engine())->warning(error);
+ program->bindings = qPersistentNew(v8::Array::New());
+ }
+ }
+
+ if (!compileFailed) {
+ v8::Local<v8::Value> result = script->Run(engine->contextWrapper()->sharedContext());
+ if (result->IsArray()) {
+ program->bindings = qPersistentNew(v8::Local<v8::Array>::Cast(result));
+ program->program.clear(); // We don't need the source anymore
+ }
+ }
+ }
+
+ int bindingsCount = functions()->Length();
+ if (bindingsCount) bindings = new QV8Bindings::Binding[bindingsCount];
+
+ setContext(context);
+}
+
+QV8Bindings::~QV8Bindings()
+{
+ program->cdata->release();
+ program = 0;
+
+ delete [] bindings;
+ bindings = 0;
+}
+
+QQmlAbstractBinding *
+QV8Bindings::configBinding(QObject *target, QObject *scope,
+ const QQmlInstruction::instr_assignBinding *i)
+{
+ if (!bindings) // initialization failed.
+ return 0;
+
+ QV8Bindings::Binding *rv = bindings + i->value;
+
+ rv->instruction = i;
+ rv->target = target;
+ rv->setScopeObject(scope);
+ rv->setUseSharedContext(true);
+ rv->setNotifyOnValueChanged(true);
+ rv->parent = this;
+
+ addref(); // This is decremented in Binding::destroy()
+
+ return rv;
+}
+
+const QUrl &QV8Bindings::url() const
+{
+ return program->cdata->url;
+}
+
+const QString &QV8Bindings::urlString() const
+{
+ return program->cdata->name;
+}
+
+v8::Persistent<v8::Array> &QV8Bindings::functions() const
+{
+ return program->bindings;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8bindings_p.h b/src/qml/qml/v8/qv8bindings_p.h
new file mode 100644
index 0000000000..ad5b2cb8b0
--- /dev/null
+++ b/src/qml/qml/v8/qv8bindings_p.h
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8BINDINGS_P_H
+#define QV8BINDINGS_P_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 <private/qqmlpropertycache_p.h>
+#include <private/qqmlinstruction_p.h>
+#include <private/qqmlexpression_p.h>
+#include <private/qqmlcompiler_p.h>
+#include <private/qqmlbinding_p.h>
+#include <private/qflagpointer_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQmlCompiledData;
+
+class QV8BindingsPrivate;
+class QV8Bindings : public QQmlAbstractExpression
+{
+public:
+ QV8Bindings(QQmlCompiledData::V8Program *,
+ int line,
+ QQmlContextData *context);
+ virtual ~QV8Bindings();
+
+ QQmlAbstractBinding *configBinding(QObject *target, QObject *scope,
+ const QQmlInstruction::instr_assignBinding *);
+
+ // Inherited from QQmlAbstractExpression
+ virtual void refresh();
+
+ struct Binding : public QQmlJavaScriptExpression,
+ public QQmlAbstractBinding {
+ Binding();
+
+ void update() { QQmlAbstractBinding::update(); }
+ void refresh();
+
+ // "Inherited" from QQmlJavaScriptExpression
+ static QString expressionIdentifier(QQmlJavaScriptExpression *);
+ static void expressionChanged(QQmlJavaScriptExpression *);
+
+ // Inherited from QQmlAbstractBinding
+ virtual void setEnabled(bool, QQmlPropertyPrivate::WriteFlags flags);
+ virtual void update(QQmlPropertyPrivate::WriteFlags flags);
+ virtual void destroy();
+ virtual int propertyIndex() const;
+ virtual QObject *object() const;
+
+ QObject *target;
+ QV8Bindings *parent;
+
+ // To save memory, we store flags inside the instruction pointer.
+ // flag1: enabled
+ // flag2: updating
+ QFlagPointer<const QQmlInstruction::instr_assignBinding> instruction;
+
+ inline bool enabledFlag() const { return instruction.flag(); }
+ inline void setEnabledFlag(bool v) { instruction.setFlagValue(v); }
+ inline bool updatingFlag() const { return instruction.flag2(); }
+ inline void setUpdatingFlag(bool v) { instruction.setFlag2Value(v); }
+ };
+
+ inline void addref();
+ inline void release();
+
+private:
+ Q_DISABLE_COPY(QV8Bindings)
+
+ const QUrl &url() const;
+ const QString &urlString() const;
+ v8::Persistent<v8::Array> &functions() const;
+
+ QQmlCompiledData::V8Program *program;
+ Binding *bindings;
+ int refCount;
+};
+
+void QV8Bindings::addref()
+{
+ ++refCount;
+}
+
+void QV8Bindings::release()
+{
+ if (0 == --refCount)
+ delete this;
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV8BINDINGS_P_H
+
+
diff --git a/src/qml/qml/v8/qv8contextwrapper.cpp b/src/qml/qml/v8/qv8contextwrapper.cpp
new file mode 100644
index 0000000000..246b716aa0
--- /dev/null
+++ b/src/qml/qml/v8/qv8contextwrapper.cpp
@@ -0,0 +1,455 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8contextwrapper_p.h"
+#include "qv8engine_p.h"
+
+#include <private/qqmlengine_p.h>
+#include <private/qqmlcontext_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static QString internal(QLatin1String("You've stumbled onto an internal implementation detail "
+ "that should never have been exposed."));
+
+class QV8ContextResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(ContextType);
+
+public:
+ QV8ContextResource(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject);
+ ~QV8ContextResource();
+
+ inline QQmlContextData *getContext() const;
+ inline QObject *getScopeObject() const;
+
+ quint32 isSharedContext:1;
+ quint32 hasSubContexts:1;
+ quint32 readOnly:1;
+ quint32 dummy:29;
+
+ QObject *secondaryScope;
+
+ // This is a pretty horrible hack, and an abuse of external strings. When we create a
+ // sub-context (a context created by a Qt.include() in an external javascript file),
+ // we pass a specially crafted SubContext external string as the v8::Script::Data() to
+ // the script, which contains a pointer to the context. We can then access the
+ // v8::Script::Data() later on to resolve names and URLs against the sub-context instead
+ // of the main outer context.
+ struct SubContext : public v8::String::ExternalStringResource {
+ SubContext(QQmlContextData *context) : context(context) {}
+ QQmlGuardedContextData context;
+
+ virtual const uint16_t* data() const { return (const uint16_t *)internal.constData(); }
+ virtual size_t length() const { return internal.length(); }
+ };
+
+private:
+ QQmlGuardedContextData context;
+ QQmlGuard<QObject> scopeObject;
+
+};
+
+QV8ContextResource::QV8ContextResource(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject)
+: QV8ObjectResource(engine), isSharedContext(false), hasSubContexts(false), readOnly(true),
+ secondaryScope(0), context(context), scopeObject(scopeObject)
+{
+}
+
+QV8ContextResource::~QV8ContextResource()
+{
+ if (context && context->isJSContext)
+ context->destroy();
+}
+
+// Returns the scope object
+QObject *QV8ContextResource::getScopeObject() const
+{
+ if (isSharedContext)
+ return QQmlEnginePrivate::get(engine->engine())->sharedScope;
+ else
+ return scopeObject;
+}
+
+// Returns the context, including resolving a subcontext
+QQmlContextData *QV8ContextResource::getContext() const
+{
+ if (isSharedContext)
+ return QQmlEnginePrivate::get(engine->engine())->sharedContext;
+
+ if (!hasSubContexts)
+ return context;
+
+ v8::Local<v8::Value> callingdata = v8::Context::GetCallingScriptData();
+ if (callingdata.IsEmpty() || !callingdata->IsString())
+ return context;
+
+ v8::Local<v8::String> callingstring = callingdata->ToString();
+ Q_ASSERT(callingstring->IsExternal());
+ Q_ASSERT(callingstring->GetExternalStringResource());
+
+ SubContext *sc = static_cast<SubContext *>(callingstring->GetExternalStringResource());
+ return sc->context;
+}
+
+QV8ContextWrapper::QV8ContextWrapper()
+: m_engine(0)
+{
+}
+
+QV8ContextWrapper::~QV8ContextWrapper()
+{
+}
+
+void QV8ContextWrapper::destroy()
+{
+ qPersistentDispose(m_sharedContext);
+ qPersistentDispose(m_urlConstructor);
+ qPersistentDispose(m_constructor);
+}
+
+void QV8ContextWrapper::init(QV8Engine *engine)
+{
+ m_engine = engine;
+ {
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ }
+ {
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(NullGetter, NullSetter);
+ m_urlConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ }
+ {
+ v8::Local<v8::Object> sharedContext = m_constructor->NewInstance();
+ QV8ContextResource *r = new QV8ContextResource(engine, 0, 0);
+ r->isSharedContext = true;
+ sharedContext->SetExternalResource(r);
+ m_sharedContext = qPersistentNew<v8::Object>(sharedContext);
+ }
+}
+
+v8::Local<v8::Object> QV8ContextWrapper::qmlScope(QQmlContextData *ctxt, QObject *scope)
+{
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ QV8ContextResource *r = new QV8ContextResource(m_engine, ctxt, scope);
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+v8::Local<v8::Object> QV8ContextWrapper::urlScope(const QUrl &url)
+{
+ QQmlContextData *context = new QQmlContextData;
+ context->url = url;
+ context->isInternal = true;
+ context->isJSContext = true;
+
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv = m_urlConstructor->NewInstance();
+ QV8ContextResource *r = new QV8ContextResource(m_engine, context, 0);
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+void QV8ContextWrapper::setReadOnly(v8::Handle<v8::Object> qmlglobal, bool readOnly)
+{
+ QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(qmlglobal);
+ Q_ASSERT(resource);
+ resource->readOnly = readOnly;
+}
+
+void QV8ContextWrapper::addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script> script,
+ QQmlContextData *ctxt)
+{
+ QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(qmlglobal);
+ Q_ASSERT(resource);
+ resource->hasSubContexts = true;
+ script->SetData(v8::String::NewExternal(new QV8ContextResource::SubContext(ctxt)));
+}
+
+QObject *QV8ContextWrapper::setSecondaryScope(v8::Handle<v8::Object> ctxt, QObject *scope)
+{
+ QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(ctxt);
+ if (!resource) return 0;
+
+ QObject *rv = resource->secondaryScope;
+ resource->secondaryScope = scope;
+ return rv;
+}
+
+QQmlContextData *QV8ContextWrapper::callingContext()
+{
+ v8::Local<v8::Object> qmlglobal = v8::Context::GetCallingQmlGlobal();
+ if (qmlglobal.IsEmpty()) return 0;
+
+ QV8ContextResource *r = v8_resource_cast<QV8ContextResource>(qmlglobal);
+ return r?r->getContext():0;
+}
+
+QQmlContextData *QV8ContextWrapper::context(v8::Handle<v8::Value> value)
+{
+ if (!value->IsObject())
+ return 0;
+
+ v8::Handle<v8::Object> qmlglobal = v8::Handle<v8::Object>::Cast(value);
+ QV8ContextResource *r = v8_resource_cast<QV8ContextResource>(qmlglobal);
+ return r?r->getContext():0;
+}
+
+v8::Handle<v8::Value> QV8ContextWrapper::NullGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
+
+ QV8Engine *engine = resource->engine;
+
+ QString error = QLatin1String("Can't find variable: ") + engine->toString(property);
+ v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
+
+ // Its possible we could delay the calculation of the "actual" context (in the case
+ // of sub contexts) until it is definately needed.
+ QQmlContextData *context = resource->getContext();
+ QQmlContextData *expressionContext = context;
+
+ if (!context)
+ return v8::Undefined();
+
+ if (v8::Context::GetCallingQmlGlobal() != info.This())
+ return v8::Handle<v8::Value>();
+
+ // Search type (attached property/enum/imported scripts) names
+ // Secondary scope object
+ // while (context) {
+ // Search context properties
+ // Search scope object
+ // Search context object
+ // context = context->parent
+ // }
+
+ QV8Engine *engine = resource->engine;
+
+ QObject *scopeObject = resource->getScopeObject();
+
+ QHashedV8String propertystring(property);
+
+ if (context->imports && QV8Engine::startsWithUpper(property)) {
+ // Search for attached properties, enums and imported scripts
+ QQmlTypeNameCache::Result r = context->imports->query(propertystring);
+
+ if (r.isValid()) {
+ if (r.scriptIndex != -1) {
+ int index = r.scriptIndex;
+ if (index < context->importedScripts.count())
+ return context->importedScripts.at(index);
+ else
+ return v8::Undefined();
+ } else if (r.type) {
+ return engine->typeWrapper()->newObject(scopeObject, r.type);
+ } else if (r.importNamespace) {
+ return engine->typeWrapper()->newObject(scopeObject, context->imports, r.importNamespace);
+ }
+ Q_ASSERT(!"Unreachable");
+ }
+
+ // Fall through
+ }
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine->engine());
+ QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
+
+ if (resource->secondaryScope) {
+ v8::Handle<v8::Value> result = qobjectWrapper->getProperty(resource->secondaryScope, propertystring,
+ QV8QObjectWrapper::IgnoreRevision);
+ if (!result.IsEmpty()) return result;
+ }
+
+ while (context) {
+ // Search context properties
+ if (context->propertyNames) {
+ int propertyIdx = context->propertyNames->value(propertystring);
+
+ if (propertyIdx != -1) {
+
+ if (propertyIdx < context->idValueCount) {
+
+ ep->captureProperty(&context->idValues[propertyIdx].bindings);
+ return engine->newQObject(context->idValues[propertyIdx]);
+ } else {
+
+ QQmlContextPrivate *cp = context->asQQmlContextPrivate();
+
+ ep->captureProperty(context->asQQmlContext(), -1,
+ propertyIdx + cp->notifyIndex);
+
+ const QVariant &value = cp->propertyValues.at(propertyIdx);
+ if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
+ QQmlListProperty<QObject> prop(context->asQQmlContext(), (void*)propertyIdx,
+ 0,
+ QQmlContextPrivate::context_count,
+ QQmlContextPrivate::context_at);
+ return engine->listWrapper()->newList(prop, qMetaTypeId<QQmlListProperty<QObject> >());
+ } else {
+ return engine->fromVariant(cp->propertyValues.at(propertyIdx));
+ }
+ }
+ }
+ }
+
+ // Search scope object
+ if (scopeObject) {
+ v8::Handle<v8::Value> result = qobjectWrapper->getProperty(scopeObject, propertystring,
+ QV8QObjectWrapper::CheckRevision);
+ if (!result.IsEmpty()) return result;
+ }
+ scopeObject = 0;
+
+
+ // Search context object
+ if (context->contextObject) {
+ v8::Handle<v8::Value> result = qobjectWrapper->getProperty(context->contextObject, propertystring,
+ QV8QObjectWrapper::CheckRevision);
+ if (!result.IsEmpty()) return result;
+ }
+
+ context = context->parent;
+ }
+
+ expressionContext->unresolvedNames = true;
+
+ QString error = QLatin1String("Can't find variable: ") + engine->toString(property);
+ v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> QV8ContextWrapper::NullSetter(v8::Local<v8::String> property,
+ v8::Local<v8::Value>,
+ const v8::AccessorInfo &info)
+{
+ QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
+
+ QV8Engine *engine = resource->engine;
+
+ if (!resource->readOnly) {
+ return v8::Handle<v8::Value>();
+ } else {
+ QString error = QLatin1String("Invalid write to global property \"") + engine->toString(property) +
+ QLatin1String("\"");
+ v8::ThrowException(v8::Exception::Error(engine->toString(error)));
+ return v8::Handle<v8::Value>();
+ }
+}
+
+v8::Handle<v8::Value> QV8ContextWrapper::Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info)
+{
+ QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
+
+ // Its possible we could delay the calculation of the "actual" context (in the case
+ // of sub contexts) until it is definately needed.
+ QQmlContextData *context = resource->getContext();
+ QQmlContextData *expressionContext = context;
+
+ if (!context)
+ return v8::Undefined();
+
+ if (v8::Context::GetCallingQmlGlobal() != info.This())
+ return v8::Handle<v8::Value>();
+
+ // See QV8ContextWrapper::Getter for resolution order
+
+ QV8Engine *engine = resource->engine;
+ QObject *scopeObject = resource->getScopeObject();
+
+ QHashedV8String propertystring(property);
+
+ QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
+
+ // Search scope object
+ if (resource->secondaryScope &&
+ qobjectWrapper->setProperty(resource->secondaryScope, propertystring, value,
+ QV8QObjectWrapper::IgnoreRevision))
+ return value;
+
+ while (context) {
+ // Search context properties
+ if (context->propertyNames && -1 != context->propertyNames->value(propertystring))
+ return value;
+
+ // Search scope object
+ if (scopeObject &&
+ qobjectWrapper->setProperty(scopeObject, propertystring, value, QV8QObjectWrapper::CheckRevision))
+ return value;
+ scopeObject = 0;
+
+ // Search context object
+ if (context->contextObject &&
+ qobjectWrapper->setProperty(context->contextObject, propertystring, value,
+ QV8QObjectWrapper::CheckRevision))
+ return value;
+
+ context = context->parent;
+ }
+
+ expressionContext->unresolvedNames = true;
+
+ if (!resource->readOnly) {
+ return v8::Handle<v8::Value>();
+ } else {
+ QString error = QLatin1String("Invalid write to global property \"") + engine->toString(property) +
+ QLatin1String("\"");
+ v8::ThrowException(v8::Exception::Error(engine->toString(error)));
+ return v8::Undefined();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8contextwrapper_p.h b/src/qml/qml/v8/qv8contextwrapper_p.h
new file mode 100644
index 0000000000..117f16ab39
--- /dev/null
+++ b/src/qml/qml/v8/qv8contextwrapper_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8CONTEXTWRAPPER_P_H
+#define QV8CONTEXTWRAPPER_P_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 <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QUrl;
+class QObject;
+class QV8Engine;
+class QQmlContextData;
+class QV8ContextWrapper
+{
+public:
+ QV8ContextWrapper();
+ ~QV8ContextWrapper();
+
+ void init(QV8Engine *);
+ void destroy();
+
+ v8::Local<v8::Object> qmlScope(QQmlContextData *ctxt, QObject *scope);
+ v8::Local<v8::Object> urlScope(const QUrl &);
+
+ void setReadOnly(v8::Handle<v8::Object>, bool);
+
+ void addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script>,
+ QQmlContextData *ctxt);
+
+ // XXX We only use the secondary scope to pass the "arguments" of the signal to
+ // on<SignalName> properties. Instead of doing this we should rewrite the
+ // JavaScript closure function to accept these arguments as named parameters.
+ // To keep backwards compatibility we have to check that the argument names are
+ // not members of the QV8Engine::illegalNames() set.
+ QObject *setSecondaryScope(v8::Handle<v8::Object>, QObject *);
+
+ QQmlContextData *callingContext();
+ QQmlContextData *context(v8::Handle<v8::Value>);
+
+ inline v8::Handle<v8::Object> sharedContext() const;
+
+private:
+ static v8::Handle<v8::Value> NullGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> NullSetter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info);
+
+ QV8Engine *m_engine;
+ v8::Persistent<v8::Function> m_constructor;
+ v8::Persistent<v8::Function> m_urlConstructor;
+ v8::Persistent<v8::Object> m_sharedContext;
+};
+
+v8::Handle<v8::Object> QV8ContextWrapper::sharedContext() const
+{
+ return m_sharedContext;
+}
+
+QT_END_NAMESPACE
+
+#endif // QV8CONTEXTWRAPPER_P_H
+
diff --git a/src/qml/qml/v8/qv8debug_p.h b/src/qml/qml/v8/qv8debug_p.h
new file mode 100644
index 0000000000..4e1ec3e2ca
--- /dev/null
+++ b/src/qml/qml/v8/qv8debug_p.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/v8-debug.h>
diff --git a/src/qml/qml/v8/qv8domerrors.cpp b/src/qml/qml/v8/qv8domerrors.cpp
new file mode 100644
index 0000000000..7b8f10a27e
--- /dev/null
+++ b/src/qml/qml/v8/qv8domerrors.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8domerrors_p.h"
+#include "qv8engine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+void qt_add_domexceptions(QV8Engine *engine)
+{
+ // DOM Exception
+ v8::PropertyAttribute attributes = (v8::PropertyAttribute)(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
+
+ v8::Local<v8::Object> domexception = v8::Object::New();
+ domexception->Set(v8::String::New("INDEX_SIZE_ERR"), v8::Integer::New(DOMEXCEPTION_INDEX_SIZE_ERR), attributes);
+ domexception->Set(v8::String::New("DOMSTRING_SIZE_ERR"), v8::Integer::New(DOMEXCEPTION_DOMSTRING_SIZE_ERR), attributes);
+ domexception->Set(v8::String::New("HIERARCHY_REQUEST_ERR"), v8::Integer::New(DOMEXCEPTION_HIERARCHY_REQUEST_ERR), attributes);
+ domexception->Set(v8::String::New("WRONG_DOCUMENT_ERR"), v8::Integer::New(DOMEXCEPTION_WRONG_DOCUMENT_ERR), attributes);
+ domexception->Set(v8::String::New("INVALID_CHARACTER_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_CHARACTER_ERR), attributes);
+ domexception->Set(v8::String::New("NO_DATA_ALLOWED_ERR"), v8::Integer::New(DOMEXCEPTION_NO_DATA_ALLOWED_ERR), attributes);
+ domexception->Set(v8::String::New("NO_MODIFICATION_ALLOWED_ERR"), v8::Integer::New(DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR), attributes);
+ domexception->Set(v8::String::New("NOT_FOUND_ERR"), v8::Integer::New(DOMEXCEPTION_NOT_FOUND_ERR), attributes);
+ domexception->Set(v8::String::New("NOT_SUPPORTED_ERR"), v8::Integer::New(DOMEXCEPTION_NOT_SUPPORTED_ERR), attributes);
+ domexception->Set(v8::String::New("INUSE_ATTRIBUTE_ERR"), v8::Integer::New(DOMEXCEPTION_INUSE_ATTRIBUTE_ERR), attributes);
+ domexception->Set(v8::String::New("INVALID_STATE_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_STATE_ERR), attributes);
+ domexception->Set(v8::String::New("SYNTAX_ERR"), v8::Integer::New(DOMEXCEPTION_SYNTAX_ERR), attributes);
+ domexception->Set(v8::String::New("INVALID_MODIFICATION_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_MODIFICATION_ERR), attributes);
+ domexception->Set(v8::String::New("NAMESPACE_ERR"), v8::Integer::New(DOMEXCEPTION_NAMESPACE_ERR), attributes);
+ domexception->Set(v8::String::New("INVALID_ACCESS_ERR"), v8::Integer::New(DOMEXCEPTION_INVALID_ACCESS_ERR), attributes);
+ domexception->Set(v8::String::New("VALIDATION_ERR"), v8::Integer::New(DOMEXCEPTION_VALIDATION_ERR), attributes);
+ domexception->Set(v8::String::New("TYPE_MISMATCH_ERR"), v8::Integer::New(DOMEXCEPTION_TYPE_MISMATCH_ERR), attributes);
+ engine->global()->Set(v8::String::New("DOMException"), domexception);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8domerrors_p.h b/src/qml/qml/v8/qv8domerrors_p.h
new file mode 100644
index 0000000000..5d5f277d55
--- /dev/null
+++ b/src/qml/qml/v8/qv8domerrors_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8DOMERRORS_P_H
+#define QV8DOMERRORS_P_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>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+// From DOM-Level-3-Core spec
+// http://www.w3.org/TR/DOM-Level-3-Core/core.html
+#define DOMEXCEPTION_INDEX_SIZE_ERR 1
+#define DOMEXCEPTION_DOMSTRING_SIZE_ERR 2
+#define DOMEXCEPTION_HIERARCHY_REQUEST_ERR 3
+#define DOMEXCEPTION_WRONG_DOCUMENT_ERR 4
+#define DOMEXCEPTION_INVALID_CHARACTER_ERR 5
+#define DOMEXCEPTION_NO_DATA_ALLOWED_ERR 6
+#define DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR 7
+#define DOMEXCEPTION_NOT_FOUND_ERR 8
+#define DOMEXCEPTION_NOT_SUPPORTED_ERR 9
+#define DOMEXCEPTION_INUSE_ATTRIBUTE_ERR 10
+#define DOMEXCEPTION_INVALID_STATE_ERR 11
+#define DOMEXCEPTION_SYNTAX_ERR 12
+#define DOMEXCEPTION_INVALID_MODIFICATION_ERR 13
+#define DOMEXCEPTION_NAMESPACE_ERR 14
+#define DOMEXCEPTION_INVALID_ACCESS_ERR 15
+#define DOMEXCEPTION_VALIDATION_ERR 16
+#define DOMEXCEPTION_TYPE_MISMATCH_ERR 17
+
+#define V8THROW_DOM(error, string) { \
+ v8::Local<v8::Value> v = v8::Exception::Error(v8::String::New(string)); \
+ v->ToObject()->Set(v8::String::New("code"), v8::Integer::New(error)); \
+ v8::ThrowException(v); \
+ return v8::Handle<v8::Value>(); \
+}
+class QV8Engine;
+void qt_add_domexceptions(QV8Engine *engine);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV8DOMERRORS_P_H
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
new file mode 100644
index 0000000000..8e8223fea1
--- /dev/null
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -0,0 +1,1600 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8engine_p.h"
+
+#include <QtGui/QGuiApplication>
+
+#include "qv8contextwrapper_p.h"
+#include "qv8valuetypewrapper_p.h"
+#include "qv8sequencewrapper_p.h"
+#include "qv8include_p.h"
+#include "qjsengine_p.h"
+#include "../../../3rdparty/javascriptcore/DateMath.h"
+
+#include <private/qqmlbuiltinfunctions_p.h>
+#include <private/qqmllist_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qquickapplication_p.h>
+#include <private/qqmlxmlhttprequest_p.h>
+#include <private/qqmllocale_p.h>
+
+#include "qscript_impl_p.h"
+#include "qv8domerrors_p.h"
+#include "qv8sqlerrors_p.h"
+
+
+Q_DECLARE_METATYPE(QJSValue)
+Q_DECLARE_METATYPE(QList<int>)
+
+
+// XXX TODO: Need to check all the global functions will also work in a worker script where the
+// QQmlEngine is not available
+QT_BEGIN_NAMESPACE
+
+static bool ObjectComparisonCallback(v8::Local<v8::Object> lhs, v8::Local<v8::Object> rhs)
+{
+ if (lhs == rhs)
+ return true;
+
+ if (lhs.IsEmpty() || rhs.IsEmpty())
+ return false;
+
+ QV8ObjectResource *lhsr = static_cast<QV8ObjectResource*>(lhs->GetExternalResource());
+ QV8ObjectResource *rhsr = static_cast<QV8ObjectResource*>(rhs->GetExternalResource());
+
+ if (lhsr && rhsr) {
+ Q_ASSERT(lhsr->engine == rhsr->engine);
+ QV8ObjectResource::ResourceType lhst = lhsr->resourceType();
+ QV8ObjectResource::ResourceType rhst = rhsr->resourceType();
+
+ switch (lhst) {
+ case QV8ObjectResource::ValueTypeType:
+ // a value type might be equal to a variant or another value type
+ if (rhst == QV8ObjectResource::ValueTypeType) {
+ return lhsr->engine->valueTypeWrapper()->isEqual(lhsr, lhsr->engine->valueTypeWrapper()->toVariant(rhsr));
+ } else if (rhst == QV8ObjectResource::VariantType) {
+ return lhsr->engine->valueTypeWrapper()->isEqual(lhsr, lhsr->engine->variantWrapper()->toVariant(rhsr));
+ }
+ break;
+ case QV8ObjectResource::VariantType:
+ // a variant might be equal to a value type or other variant.
+ if (rhst == QV8ObjectResource::VariantType) {
+ return lhsr->engine->variantWrapper()->toVariant(lhsr) ==
+ lhsr->engine->variantWrapper()->toVariant(rhsr);
+ } else if (rhst == QV8ObjectResource::ValueTypeType) {
+ return rhsr->engine->valueTypeWrapper()->isEqual(rhsr, rhsr->engine->variantWrapper()->toVariant(lhsr));
+ }
+ break;
+ case QV8ObjectResource::SequenceType:
+ // a sequence might be equal to itself.
+ if (rhst == QV8ObjectResource::SequenceType) {
+ return lhsr->engine->sequenceWrapper()->isEqual(lhsr, rhsr);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return false;
+}
+
+
+QV8Engine::QV8Engine(QJSEngine* qq, QJSEngine::ContextOwnership ownership)
+ : q(qq)
+ , m_engine(0)
+ , m_ownsV8Context(ownership == QJSEngine::CreateNewContext)
+ , m_xmlHttpRequestData(0)
+ , m_listModelData(0)
+{
+ qMetaTypeId<QJSValue>();
+ qMetaTypeId<QList<int> >();
+
+ QByteArray v8args = qgetenv("V8ARGS");
+ // change default v8 behaviour to not relocate breakpoints across lines
+ if (!v8args.contains("breakpoint_relocation"))
+ v8args.append(" --nobreakpoint_relocation");
+ v8::V8::SetFlagsFromString(v8args.constData(), v8args.length());
+
+ ensurePerThreadIsolate();
+
+ v8::HandleScope handle_scope;
+ m_context = (ownership == QJSEngine::CreateNewContext) ? v8::Context::New() : v8::Persistent<v8::Context>::New(v8::Context::GetCurrent());
+ qPersistentRegister(m_context);
+ m_originalGlobalObject.init(m_context);
+ v8::Context::Scope context_scope(m_context);
+
+ v8::V8::SetUserObjectComparisonCallbackFunction(ObjectComparisonCallback);
+ QV8GCCallback::registerGcPrologueCallback();
+ m_strongReferencer = qPersistentNew(v8::Object::New());
+
+ m_stringWrapper.init();
+ m_contextWrapper.init(this);
+ m_qobjectWrapper.init(this);
+ m_typeWrapper.init(this);
+ m_listWrapper.init(this);
+ m_variantWrapper.init(this);
+ m_valueTypeWrapper.init(this);
+ m_sequenceWrapper.init(this);
+
+ {
+ v8::Handle<v8::Value> v = global()->Get(v8::String::New("Object"))->ToObject()->Get(v8::String::New("getOwnPropertyNames"));
+ m_getOwnPropertyNames = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(v));
+ }
+}
+
+QV8Engine::~QV8Engine()
+{
+ Q_ASSERT_X(v8::Isolate::GetCurrent(), "QV8Engine::~QV8Engine()", "called after v8::Isolate has exited");
+ for (int ii = 0; ii < m_extensionData.count(); ++ii)
+ delete m_extensionData[ii];
+ m_extensionData.clear();
+
+ qt_rem_qmlxmlhttprequest(this, m_xmlHttpRequestData);
+ m_xmlHttpRequestData = 0;
+ delete m_listModelData;
+ m_listModelData = 0;
+
+ qPersistentDispose(m_freezeObject);
+ qPersistentDispose(m_getOwnPropertyNames);
+
+ invalidateAllValues();
+ clearExceptions();
+
+ qPersistentDispose(m_strongReferencer);
+
+ m_sequenceWrapper.destroy();
+ m_valueTypeWrapper.destroy();
+ m_variantWrapper.destroy();
+ m_listWrapper.destroy();
+ m_typeWrapper.destroy();
+ m_qobjectWrapper.destroy();
+ m_contextWrapper.destroy();
+ m_stringWrapper.destroy();
+
+ m_originalGlobalObject.destroy();
+
+ if (m_ownsV8Context)
+ qPersistentDispose(m_context);
+}
+
+QString QV8Engine::toStringStatic(v8::Handle<v8::Value> jsstr)
+{
+ return toStringStatic(jsstr->ToString());
+}
+
+QString QV8Engine::toStringStatic(v8::Handle<v8::String> jsstr)
+{
+ QString qstr;
+ qstr.resize(jsstr->Length());
+ jsstr->Write((uint16_t*)qstr.data());
+ return qstr;
+}
+
+QVariant QV8Engine::toVariant(v8::Handle<v8::Value> value, int typeHint)
+{
+ if (value.IsEmpty())
+ return QVariant();
+
+ if (typeHint == QVariant::Bool)
+ return QVariant(value->BooleanValue());
+
+ if (value->IsObject()) {
+ QV8ObjectResource *r = (QV8ObjectResource *)value->ToObject()->GetExternalResource();
+ if (r) {
+ switch (r->resourceType()) {
+ case QV8ObjectResource::Context2DStyleType:
+ case QV8ObjectResource::Context2DPixelArrayType:
+ case QV8ObjectResource::SignalHandlerType:
+ case QV8ObjectResource::IncubatorType:
+ case QV8ObjectResource::VisualDataItemType:
+ case QV8ObjectResource::ContextType:
+ case QV8ObjectResource::XMLHttpRequestType:
+ case QV8ObjectResource::DOMNodeType:
+ case QV8ObjectResource::SQLDatabaseType:
+ case QV8ObjectResource::ListModelType:
+ case QV8ObjectResource::Context2DType:
+ case QV8ObjectResource::ParticleDataType:
+ case QV8ObjectResource::LocaleDataType:
+ return QVariant();
+ case QV8ObjectResource::TypeType:
+ return m_typeWrapper.toVariant(r);
+ case QV8ObjectResource::QObjectType:
+ return qVariantFromValue<QObject *>(m_qobjectWrapper.toQObject(r));
+ case QV8ObjectResource::ListType:
+ return m_listWrapper.toVariant(r);
+ case QV8ObjectResource::VariantType:
+ return m_variantWrapper.toVariant(r);
+ case QV8ObjectResource::ValueTypeType:
+ return m_valueTypeWrapper.toVariant(r);
+ case QV8ObjectResource::SequenceType:
+ return m_sequenceWrapper.toVariant(r);
+ }
+ }
+ }
+
+ if (value->IsArray()) {
+ v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
+ if (typeHint == qMetaTypeId<QList<QObject *> >()) {
+ QList<QObject *> list;
+ uint32_t length = array->Length();
+ for (uint32_t ii = 0; ii < length; ++ii) {
+ v8::Local<v8::Value> arrayItem = array->Get(ii);
+ if (arrayItem->IsObject()) {
+ list << toQObject(arrayItem->ToObject());
+ } else {
+ list << 0;
+ }
+ }
+
+ return qVariantFromValue<QList<QObject*> >(list);
+ }
+
+ bool succeeded = false;
+ QVariant retn = m_sequenceWrapper.toVariant(array, typeHint, &succeeded);
+ if (succeeded)
+ return retn;
+ }
+
+ return toBasicVariant(value);
+}
+
+static v8::Handle<v8::Array> arrayFromStringList(QV8Engine *engine, const QStringList &list)
+{
+ v8::Context::Scope scope(engine->context());
+ v8::Local<v8::Array> result = v8::Array::New(list.count());
+ for (int ii = 0; ii < list.count(); ++ii)
+ result->Set(ii, engine->toString(list.at(ii)));
+ return result;
+}
+
+static v8::Handle<v8::Array> arrayFromVariantList(QV8Engine *engine, const QVariantList &list)
+{
+ v8::Context::Scope scope(engine->context());
+ v8::Local<v8::Array> result = v8::Array::New(list.count());
+ for (int ii = 0; ii < list.count(); ++ii)
+ result->Set(ii, engine->fromVariant(list.at(ii)));
+ return result;
+}
+
+static v8::Handle<v8::Object> objectFromVariantMap(QV8Engine *engine, const QVariantMap &map)
+{
+ v8::Context::Scope scope(engine->context());
+ v8::Local<v8::Object> object = v8::Object::New();
+ for (QVariantMap::ConstIterator iter = map.begin(); iter != map.end(); ++iter)
+ object->Set(engine->toString(iter.key()), engine->fromVariant(iter.value()));
+ return object;
+}
+
+Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
+
+v8::Handle<v8::Value> QV8Engine::fromVariant(const QVariant &variant)
+{
+ int type = variant.userType();
+ const void *ptr = variant.constData();
+
+ if (type < QMetaType::User) {
+ switch (QMetaType::Type(type)) {
+ case QMetaType::Void:
+ return v8::Undefined();
+ case QMetaType::Bool:
+ return v8::Boolean::New(*reinterpret_cast<const bool*>(ptr));
+ case QMetaType::Int:
+ return v8::Integer::New(*reinterpret_cast<const int*>(ptr));
+ case QMetaType::UInt:
+ return v8::Integer::NewFromUnsigned(*reinterpret_cast<const uint*>(ptr));
+ case QMetaType::LongLong:
+ return v8::Number::New(*reinterpret_cast<const qlonglong*>(ptr));
+ case QMetaType::ULongLong:
+ return v8::Number::New(*reinterpret_cast<const qulonglong*>(ptr));
+ case QMetaType::Double:
+ return v8::Number::New(*reinterpret_cast<const double*>(ptr));
+ case QMetaType::QString:
+ return m_stringWrapper.toString(*reinterpret_cast<const QString*>(ptr));
+ case QMetaType::Float:
+ return v8::Number::New(*reinterpret_cast<const float*>(ptr));
+ case QMetaType::Short:
+ return v8::Integer::New(*reinterpret_cast<const short*>(ptr));
+ case QMetaType::UShort:
+ return v8::Integer::NewFromUnsigned(*reinterpret_cast<const unsigned short*>(ptr));
+ case QMetaType::Char:
+ return v8::Integer::New(*reinterpret_cast<const char*>(ptr));
+ case QMetaType::UChar:
+ return v8::Integer::NewFromUnsigned(*reinterpret_cast<const unsigned char*>(ptr));
+ case QMetaType::QChar:
+ return v8::Integer::New((*reinterpret_cast<const QChar*>(ptr)).unicode());
+ case QMetaType::QDateTime:
+ return v8::Date::New(qtDateTimeToJsDate(*reinterpret_cast<const QDateTime *>(ptr)));
+ case QMetaType::QDate:
+ return v8::Date::New(qtDateTimeToJsDate(QDateTime(*reinterpret_cast<const QDate *>(ptr))));
+ case QMetaType::QTime:
+ return v8::Date::New(qtDateTimeToJsDate(QDateTime(QDate(1970,1,1), *reinterpret_cast<const QTime *>(ptr))));
+ case QMetaType::QRegExp:
+ return QJSConverter::toRegExp(*reinterpret_cast<const QRegExp *>(ptr));
+ case QMetaType::QObjectStar:
+ case QMetaType::QWidgetStar:
+ return newQObject(*reinterpret_cast<QObject* const *>(ptr));
+ case QMetaType::QStringList:
+ {
+ bool succeeded = false;
+ v8::Handle<v8::Value> retn = m_sequenceWrapper.fromVariant(variant, &succeeded);
+ if (succeeded)
+ return retn;
+ return arrayFromStringList(this, *reinterpret_cast<const QStringList *>(ptr));
+ }
+ case QMetaType::QVariantList:
+ return arrayFromVariantList(this, *reinterpret_cast<const QVariantList *>(ptr));
+ case QMetaType::QVariantMap:
+ return objectFromVariantMap(this, *reinterpret_cast<const QVariantMap *>(ptr));
+
+ default:
+ break;
+ }
+
+ if (m_engine) {
+ if (QQmlValueType *vt = QQmlEnginePrivate::get(m_engine)->valueTypes[type])
+ return m_valueTypeWrapper.newValueType(variant, vt);
+ }
+
+ } else {
+ if (type == qMetaTypeId<QQmlListReference>()) {
+ typedef QQmlListReferencePrivate QDLRP;
+ QDLRP *p = QDLRP::get((QQmlListReference*)ptr);
+ if (p->object) {
+ return m_listWrapper.newList(p->property, p->propertyType);
+ } else {
+ return v8::Null();
+ }
+ } else if (type == qMetaTypeId<QJSValue>()) {
+ const QJSValue *value = reinterpret_cast<const QJSValue *>(ptr);
+ QJSValuePrivate *valuep = QJSValuePrivate::get(*value);
+ if (valuep->assignEngine(this))
+ return v8::Local<v8::Value>::New(*valuep);
+ } else if (type == qMetaTypeId<QList<QObject *> >()) {
+ // XXX Can this be made more by using Array as a prototype and implementing
+ // directly against QList<QObject*>?
+ const QList<QObject *> &list = *(QList<QObject *>*)ptr;
+ v8::Local<v8::Array> array = v8::Array::New(list.count());
+ for (int ii = 0; ii < list.count(); ++ii)
+ array->Set(ii, newQObject(list.at(ii)));
+ return array;
+ }
+
+ bool objOk;
+ QObject *obj = QQmlMetaType::toQObject(variant, &objOk);
+ if (objOk)
+ return newQObject(obj);
+
+ bool succeeded = false;
+ v8::Handle<v8::Value> retn = m_sequenceWrapper.fromVariant(variant, &succeeded);
+ if (succeeded)
+ return retn;
+ }
+
+ // XXX TODO: To be compatible, we still need to handle:
+ // + QObjectList
+ // + QList<int>
+
+ return m_variantWrapper.newVariant(variant);
+}
+
+// A handle scope and context must be entered
+v8::Local<v8::Script> QV8Engine::qmlModeCompile(const QString &source,
+ const QString &fileName,
+ int lineNumber)
+{
+ v8::Local<v8::String> v8source = m_stringWrapper.toString(source);
+ v8::Local<v8::String> v8fileName = m_stringWrapper.toString(fileName);
+
+ v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1));
+
+ v8::Local<v8::Script> script = v8::Script::Compile(v8source, &origin, 0, v8::Handle<v8::String>(),
+ v8::Script::QmlMode);
+
+ return script;
+}
+
+// A handle scope and context must be entered.
+// source can be either ascii or utf8.
+v8::Local<v8::Script> QV8Engine::qmlModeCompile(const char *source, int sourceLength,
+ const QString &fileName,
+ int lineNumber)
+{
+ if (sourceLength == -1)
+ sourceLength = strlen(source);
+
+ v8::Local<v8::String> v8source = v8::String::New(source, sourceLength);
+ v8::Local<v8::String> v8fileName = m_stringWrapper.toString(fileName);
+
+ v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1));
+
+ v8::Local<v8::Script> script = v8::Script::Compile(v8source, &origin, 0, v8::Handle<v8::String>(),
+ v8::Script::QmlMode);
+
+ return script;
+}
+
+QNetworkAccessManager *QV8Engine::networkAccessManager()
+{
+ return QQmlEnginePrivate::get(m_engine)->getNetworkAccessManager();
+}
+
+const QStringHash<bool> &QV8Engine::illegalNames() const
+{
+ return m_illegalNames;
+}
+
+// Requires a handle scope
+v8::Local<v8::Array> QV8Engine::getOwnPropertyNames(v8::Handle<v8::Object> o)
+{
+ // FIXME Newer v8 have API for this function
+ v8::TryCatch tc;
+ v8::Handle<v8::Value> args[] = { o };
+ v8::Local<v8::Value> r = m_getOwnPropertyNames->Call(global(), 1, args);
+ if (tc.HasCaught())
+ return v8::Array::New();
+ else
+ return v8::Local<v8::Array>::Cast(r);
+}
+
+QQmlContextData *QV8Engine::callingContext()
+{
+ return m_contextWrapper.callingContext();
+}
+
+// Converts a JS value to a QVariant.
+// Null, Undefined -> QVariant() (invalid)
+// Boolean -> QVariant(bool)
+// Number -> QVariant(double)
+// String -> QVariant(QString)
+// Array -> QVariantList(...)
+// Date -> QVariant(QDateTime)
+// RegExp -> QVariant(QRegExp)
+// [Any other object] -> QVariantMap(...)
+QVariant QV8Engine::toBasicVariant(v8::Handle<v8::Value> value)
+{
+ if (value->IsNull() || value->IsUndefined())
+ return QVariant();
+ if (value->IsBoolean())
+ return value->ToBoolean()->Value();
+ if (value->IsInt32())
+ return value->ToInt32()->Value();
+ if (value->IsNumber())
+ return value->ToNumber()->Value();
+ if (value->IsString())
+ return m_stringWrapper.toString(value->ToString());
+ if (value->IsDate())
+ return qtDateTimeFromJsDate(v8::Handle<v8::Date>::Cast(value)->NumberValue());
+ // NOTE: since we convert QTime to JS Date, round trip will change the variant type (to QDateTime)!
+
+ Q_ASSERT(value->IsObject());
+
+ if (value->IsRegExp()) {
+ v8::Context::Scope scope(context());
+ return QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(value));
+ }
+ if (value->IsArray()) {
+ v8::Context::Scope scope(context());
+ QVariantList rv;
+
+ v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
+ int length = array->Length();
+ for (int ii = 0; ii < length; ++ii)
+ rv << toVariant(array->Get(ii), -1);
+ return rv;
+ }
+ if (!value->IsFunction()) {
+ v8::Context::Scope scope(context());
+ v8::Handle<v8::Object> object = value->ToObject();
+ return variantMapFromJS(object);
+ }
+
+ return QVariant();
+}
+
+
+
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
+
+struct StaticQtMetaObject : public QObject
+{
+ static const QMetaObject *get()
+ { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
+};
+
+void QV8Engine::initializeGlobal(v8::Handle<v8::Object> global)
+{
+ using namespace QQmlBuiltinFunctions;
+
+ v8::Local<v8::Object> console = v8::Object::New();
+ v8::Local<v8::Function> consoleLogFn = V8FUNCTION(consoleLog, this);
+
+ console->Set(v8::String::New("debug"), consoleLogFn);
+ console->Set(v8::String::New("log"), consoleLogFn);
+ console->Set(v8::String::New("info"), consoleLogFn);
+ console->Set(v8::String::New("warn"), V8FUNCTION(consoleWarn, this));
+ console->Set(v8::String::New("error"), V8FUNCTION(consoleError, this));
+ console->Set(v8::String::New("assert"), V8FUNCTION(consoleAssert, this));
+
+ console->Set(v8::String::New("count"), V8FUNCTION(consoleCount, this));
+ console->Set(v8::String::New("profile"), V8FUNCTION(consoleProfile, this));
+ console->Set(v8::String::New("profileEnd"), V8FUNCTION(consoleProfileEnd, this));
+ console->Set(v8::String::New("time"), V8FUNCTION(consoleTime, this));
+ console->Set(v8::String::New("timeEnd"), V8FUNCTION(consoleTimeEnd, this));
+ console->Set(v8::String::New("trace"), V8FUNCTION(consoleTrace, this));
+ console->Set(v8::String::New("exception"), V8FUNCTION(consoleException, this));
+
+ v8::Local<v8::Object> qt = v8::Object::New();
+
+ // Set all the enums from the "Qt" namespace
+ const QMetaObject *qtMetaObject = StaticQtMetaObject::get();
+ for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) {
+ QMetaEnum enumerator = qtMetaObject->enumerator(ii);
+ for (int jj = 0; jj < enumerator.keyCount(); ++jj) {
+ qt->Set(v8::String::New(enumerator.key(jj)), v8::Integer::New(enumerator.value(jj)));
+ }
+ }
+ qt->Set(v8::String::New("Asynchronous"), v8::Integer::New(0));
+ qt->Set(v8::String::New("Synchronous"), v8::Integer::New(1));
+
+ qt->Set(v8::String::New("include"), V8FUNCTION(QV8Include::include, this));
+ qt->Set(v8::String::New("isQtObject"), V8FUNCTION(isQtObject, this));
+ qt->Set(v8::String::New("rgba"), V8FUNCTION(rgba, this));
+ qt->Set(v8::String::New("hsla"), V8FUNCTION(hsla, this));
+ qt->Set(v8::String::New("rect"), V8FUNCTION(rect, this));
+ qt->Set(v8::String::New("point"), V8FUNCTION(point, this));
+ qt->Set(v8::String::New("size"), V8FUNCTION(size, this));
+ qt->Set(v8::String::New("vector3d"), V8FUNCTION(vector3d, this));
+ qt->Set(v8::String::New("vector4d"), V8FUNCTION(vector4d, this));
+
+ qt->Set(v8::String::New("formatDate"), V8FUNCTION(formatDate, this));
+ qt->Set(v8::String::New("formatTime"), V8FUNCTION(formatTime, this));
+ qt->Set(v8::String::New("formatDateTime"), V8FUNCTION(formatDateTime, this));
+
+ qt->Set(v8::String::New("openUrlExternally"), V8FUNCTION(openUrlExternally, this));
+ qt->Set(v8::String::New("fontFamilies"), V8FUNCTION(fontFamilies, this));
+ qt->Set(v8::String::New("md5"), V8FUNCTION(md5, this));
+ qt->Set(v8::String::New("btoa"), V8FUNCTION(btoa, this));
+ qt->Set(v8::String::New("atob"), V8FUNCTION(atob, this));
+ qt->Set(v8::String::New("resolvedUrl"), V8FUNCTION(resolvedUrl, this));
+ qt->Set(v8::String::New("locale"), V8FUNCTION(locale, this));
+
+ if (m_engine) {
+ qt->Set(v8::String::New("application"), newQObject(new QQuickApplication(m_engine)));
+ qt->Set(v8::String::New("inputMethod"), newQObject(qGuiApp->inputMethod(), CppOwnership));
+ qt->Set(v8::String::New("lighter"), V8FUNCTION(lighter, this));
+ qt->Set(v8::String::New("darker"), V8FUNCTION(darker, this));
+ qt->Set(v8::String::New("tint"), V8FUNCTION(tint, this));
+ qt->Set(v8::String::New("quit"), V8FUNCTION(quit, this));
+ qt->Set(v8::String::New("createQmlObject"), V8FUNCTION(createQmlObject, this));
+ qt->Set(v8::String::New("createComponent"), V8FUNCTION(createComponent, this));
+ }
+
+ global->Set(v8::String::New("qsTranslate"), V8FUNCTION(qsTranslate, this));
+ global->Set(v8::String::New("QT_TRANSLATE_NOOP"), V8FUNCTION(qsTranslateNoOp, this));
+ global->Set(v8::String::New("qsTr"), V8FUNCTION(qsTr, this));
+ global->Set(v8::String::New("QT_TR_NOOP"), V8FUNCTION(qsTrNoOp, this));
+ global->Set(v8::String::New("qsTrId"), V8FUNCTION(qsTrId, this));
+ global->Set(v8::String::New("QT_TRID_NOOP"), V8FUNCTION(qsTrIdNoOp, this));
+
+ global->Set(v8::String::New("print"), consoleLogFn);
+ global->Set(v8::String::New("console"), console);
+ global->Set(v8::String::New("Qt"), qt);
+ global->Set(v8::String::New("gc"), V8FUNCTION(QQmlBuiltinFunctions::gc, this));
+
+ {
+#define STRING_ARG "(function(stringArg) { "\
+ " String.prototype.arg = (function() {"\
+ " return stringArg.apply(this, arguments);"\
+ " })"\
+ "})"
+
+ v8::Local<v8::Script> registerArg = v8::Script::New(v8::String::New(STRING_ARG), 0, 0, v8::Handle<v8::String>(), v8::Script::NativeMode);
+ v8::Local<v8::Value> result = registerArg->Run();
+ Q_ASSERT(result->IsFunction());
+ v8::Local<v8::Function> registerArgFunc = v8::Local<v8::Function>::Cast(result);
+ v8::Handle<v8::Value> args = V8FUNCTION(stringArg, this);
+ registerArgFunc->Call(v8::Local<v8::Object>::Cast(registerArgFunc), 1, &args);
+#undef STRING_ARG
+ }
+
+ QQmlLocale::registerStringLocaleCompare(this);
+ QQmlDateExtension::registerExtension(this);
+ QQmlNumberExtension::registerExtension(this);
+
+ qt_add_domexceptions(this);
+ m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(this);
+
+ qt_add_sqlexceptions(this);
+
+ {
+ v8::Handle<v8::Value> args[] = { global };
+ v8::Local<v8::Value> names = m_getOwnPropertyNames->Call(global, 1, args);
+ v8::Local<v8::Array> namesArray = v8::Local<v8::Array>::Cast(names);
+ for (quint32 ii = 0; ii < namesArray->Length(); ++ii)
+ m_illegalNames.insert(toString(namesArray->Get(ii)), true);
+ }
+
+ {
+#define FREEZE_SOURCE "(function freeze_recur(obj) { "\
+ " if (Qt.isQtObject(obj)) return;"\
+ " if (obj != Function.connect && obj != Function.disconnect && "\
+ " obj instanceof Object) {"\
+ " var properties = Object.getOwnPropertyNames(obj);"\
+ " for (var prop in properties) { "\
+ " if (prop == \"connect\" || prop == \"disconnect\") {"\
+ " Object.freeze(obj[prop]); "\
+ " continue;"\
+ " }"\
+ " freeze_recur(obj[prop]);"\
+ " }"\
+ " }"\
+ " if (obj instanceof Object) {"\
+ " Object.freeze(obj);"\
+ " }"\
+ "})"
+
+ v8::Local<v8::Script> freeze = v8::Script::New(v8::String::New(FREEZE_SOURCE));
+ v8::Local<v8::Value> result = freeze->Run();
+ Q_ASSERT(result->IsFunction());
+ m_freezeObject = qPersistentNew(v8::Local<v8::Function>::Cast(result));
+#undef FREEZE_SOURCE
+ }
+}
+
+void QV8Engine::freezeObject(v8::Handle<v8::Value> value)
+{
+ v8::Handle<v8::Value> args[] = { value };
+ m_freezeObject->Call(global(), 1, args);
+}
+
+void QV8Engine::gc()
+{
+ v8::V8::LowMemoryNotification();
+ while (!v8::V8::IdleNotification()) {}
+}
+
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+#include <QtCore/qthreadstorage.h>
+static QThreadStorage<QSet<void *> *> QV8Engine_activeHandles;
+
+void QV8Engine::registerHandle(void *handle)
+{
+ if (!handle) {
+ qWarning("Attempting to register a null handle");
+ return;
+ }
+
+ if (!QV8Engine_activeHandles.hasLocalData())
+ QV8Engine_activeHandles.setLocalData(new QSet<void *>);
+
+ if (QV8Engine_activeHandles.localData()->contains(handle)) {
+ qFatal("Handle %p already alive", handle);
+ } else {
+ QV8Engine_activeHandles.localData()->insert(handle);
+ }
+}
+
+void QV8Engine::releaseHandle(void *handle)
+{
+ if (!handle)
+ return;
+
+ if (!QV8Engine_activeHandles.hasLocalData())
+ QV8Engine_activeHandles.setLocalData(new QSet<void *>);
+
+ if (QV8Engine_activeHandles.localData()->contains(handle)) {
+ QV8Engine_activeHandles.localData()->remove(handle);
+ } else {
+ qFatal("Handle %p already dead", handle);
+ }
+}
+#endif
+
+struct QV8EngineRegistrationData
+{
+ QV8EngineRegistrationData() : extensionCount(0) {}
+
+ QMutex mutex;
+ int extensionCount;
+};
+Q_GLOBAL_STATIC(QV8EngineRegistrationData, registrationData);
+
+QMutex *QV8Engine::registrationMutex()
+{
+ return &registrationData()->mutex;
+}
+
+int QV8Engine::registerExtension()
+{
+ return registrationData()->extensionCount++;
+}
+
+void QV8Engine::setExtensionData(int index, Deletable *data)
+{
+ if (m_extensionData.count() <= index)
+ m_extensionData.resize(index + 1);
+
+ if (m_extensionData.at(index))
+ delete m_extensionData.at(index);
+
+ m_extensionData[index] = data;
+}
+
+double QV8Engine::qtDateTimeToJsDate(const QDateTime &dt)
+{
+ // from QScriptEngine::DateTimeToMs()
+ if (!dt.isValid()) {
+ return qSNaN();
+ }
+ QDateTime utc = dt.toUTC();
+ QDate date = utc.date();
+ QTime time = utc.time();
+ QV8DateConverter::JSC::GregorianDateTime tm;
+ tm.year = date.year() - 1900;
+ tm.month = date.month() - 1;
+ tm.monthDay = date.day();
+ tm.weekDay = date.dayOfWeek();
+ tm.yearDay = date.dayOfYear();
+ tm.hour = time.hour();
+ tm.minute = time.minute();
+ tm.second = time.second();
+ return QV8DateConverter::JSC::gregorianDateTimeToMS(tm, time.msec());
+}
+
+v8::Persistent<v8::Object> *QV8Engine::findOwnerAndStrength(QObject *object, bool *shouldBeStrong)
+{
+ QObject *parent = object->parent();
+ if (!parent) {
+ // if the object has JS ownership, the object's v8object owns the lifetime of the persistent value.
+ if (QQmlEngine::objectOwnership(object) == QQmlEngine::JavaScriptOwnership) {
+ *shouldBeStrong = false;
+ return &(QQmlData::get(object)->v8object);
+ }
+
+ // no parent, and has CPP ownership - doesn't have an implicit parent.
+ *shouldBeStrong = true;
+ return 0;
+ }
+
+ // if it is owned by CPP, it's root parent may still be owned by JS.
+ // in that case, the owner of the persistent handle is the root parent's v8object.
+ while (parent->parent())
+ parent = parent->parent();
+
+ if (QQmlEngine::objectOwnership(parent) == QQmlEngine::JavaScriptOwnership) {
+ // root parent is owned by JS. It's v8object owns the persistent value in question.
+ *shouldBeStrong = false;
+ return &(QQmlData::get(parent)->v8object);
+ } else {
+ // root parent has CPP ownership. The persistent value should not be made weak.
+ *shouldBeStrong = true;
+ return 0;
+ }
+}
+
+QDateTime QV8Engine::qtDateTimeFromJsDate(double jsDate)
+{
+ // from QScriptEngine::MsToDateTime()
+ if (qIsNaN(jsDate))
+ return QDateTime();
+ QV8DateConverter::JSC::GregorianDateTime tm;
+ QV8DateConverter::JSC::msToGregorianDateTime(jsDate, tm);
+
+ // from QScriptEngine::MsFromTime()
+ int ms = int(::fmod(jsDate, 1000.0));
+ if (ms < 0)
+ ms += int(1000.0);
+
+ QDateTime convertedUTC = QDateTime(QDate(tm.year + 1900, tm.month + 1, tm.monthDay),
+ QTime(tm.hour, tm.minute, tm.second, ms), Qt::UTC);
+ return convertedUTC.toLocalTime();
+}
+
+void QV8Engine::addRelationshipForGC(QObject *object, v8::Persistent<v8::Value> handle)
+{
+ if (handle.IsEmpty())
+ return;
+
+ bool handleShouldBeStrong = false;
+ v8::Persistent<v8::Object> *implicitOwner = findOwnerAndStrength(object, &handleShouldBeStrong);
+ if (handleShouldBeStrong) {
+ v8::V8::AddImplicitReferences(m_strongReferencer, &handle, 1);
+ } else if (!implicitOwner->IsEmpty()) {
+ v8::V8::AddImplicitReferences(*implicitOwner, &handle, 1);
+ }
+}
+
+void QV8Engine::addRelationshipForGC(QObject *object, QObject *other)
+{
+ bool handleShouldBeStrong = false;
+ v8::Persistent<v8::Object> *implicitOwner = findOwnerAndStrength(object, &handleShouldBeStrong);
+ v8::Persistent<v8::Value> handle = QQmlData::get(other, true)->v8object;
+ if (handleShouldBeStrong) {
+ v8::V8::AddImplicitReferences(m_strongReferencer, &handle, 1);
+ } else if (!implicitOwner->IsEmpty()) {
+ v8::V8::AddImplicitReferences(*implicitOwner, &handle, 1);
+ }
+}
+
+static QThreadStorage<QV8Engine::ThreadData*> perThreadEngineData;
+
+bool QV8Engine::hasThreadData()
+{
+ return perThreadEngineData.hasLocalData();
+}
+
+QV8Engine::ThreadData *QV8Engine::threadData()
+{
+ Q_ASSERT(perThreadEngineData.hasLocalData());
+ return perThreadEngineData.localData();
+}
+
+void QV8Engine::ensurePerThreadIsolate()
+{
+ if (!perThreadEngineData.hasLocalData())
+ perThreadEngineData.setLocalData(new ThreadData);
+}
+
+void QV8Engine::initQmlGlobalObject()
+{
+ v8::HandleScope handels;
+ v8::Context::Scope contextScope(m_context);
+ initializeGlobal(m_context->Global());
+ freezeObject(m_context->Global());
+}
+
+void QV8Engine::setEngine(QQmlEngine *engine)
+{
+ m_engine = engine;
+ initQmlGlobalObject();
+}
+
+void QV8Engine::setException(v8::Handle<v8::Value> value, v8::Handle<v8::Message> msg)
+{
+ m_exception.set(value, msg);
+}
+
+v8::Handle<v8::Value> QV8Engine::throwException(v8::Handle<v8::Value> value)
+{
+ setException(value);
+ v8::ThrowException(value);
+ return value;
+}
+
+void QV8Engine::clearExceptions()
+{
+ m_exception.clear();
+}
+
+v8::Handle<v8::Value> QV8Engine::uncaughtException() const
+{
+ if (!hasUncaughtException())
+ return v8::Handle<v8::Value>();
+ return m_exception;
+}
+
+bool QV8Engine::hasUncaughtException() const
+{
+ return m_exception;
+}
+
+int QV8Engine::uncaughtExceptionLineNumber() const
+{
+ return m_exception.lineNumber();
+}
+
+QStringList QV8Engine::uncaughtExceptionBacktrace() const
+{
+ return m_exception.backtrace();
+}
+
+/*!
+ \internal
+ Save the current exception on stack so it can be set again later.
+ \sa QV8Engine::restoreException
+*/
+void QV8Engine::saveException()
+{
+ m_exception.push();
+}
+
+/*!
+ \internal
+ Load a saved exception from stack. Current exception, if exists will be dropped
+ \sa QV8Engine::saveException
+*/
+void QV8Engine::restoreException()
+{
+ m_exception.pop();
+}
+
+QV8Engine::Exception::Exception() {}
+
+QV8Engine::Exception::~Exception()
+{
+ Q_ASSERT_X(m_stack.isEmpty(), Q_FUNC_INFO, "Some saved exceptions left. Asymetric pop/push found.");
+ clear();
+}
+
+void QV8Engine::Exception::set(v8::Handle<v8::Value> value, v8::Handle<v8::Message> message)
+{
+ Q_ASSERT_X(!value.IsEmpty(), Q_FUNC_INFO, "Throwing an empty value handle is highly suspected");
+ clear();
+ m_value = v8::Persistent<v8::Value>::New(value);
+ m_message = v8::Persistent<v8::Message>::New(message);
+}
+
+void QV8Engine::Exception::clear()
+{
+ m_value.Dispose();
+ m_value.Clear();
+ m_message.Dispose();
+ m_message.Clear();
+}
+
+QV8Engine::Exception::operator bool() const
+{
+ return !m_value.IsEmpty();
+}
+
+QV8Engine::Exception::operator v8::Handle<v8::Value>() const
+{
+ Q_ASSERT(*this);
+ return m_value;
+}
+
+int QV8Engine::Exception::lineNumber() const
+{
+ if (m_message.IsEmpty())
+ return -1;
+ return m_message->GetLineNumber();
+}
+
+QStringList QV8Engine::Exception::backtrace() const
+{
+ if (m_message.IsEmpty())
+ return QStringList();
+
+ QStringList backtrace;
+ v8::Handle<v8::StackTrace> trace = m_message->GetStackTrace();
+ if (trace.IsEmpty())
+ // FIXME it should not happen (SetCaptureStackTraceForUncaughtExceptions is called).
+ return QStringList();
+
+ for (int i = 0; i < trace->GetFrameCount(); ++i) {
+ v8::Local<v8::StackFrame> frame = trace->GetFrame(i);
+ backtrace.append(QJSConverter::toString(frame->GetFunctionName()));
+ backtrace.append(QJSConverter::toString(frame->GetFunctionName()));
+ backtrace.append(QString::fromAscii("()@"));
+ backtrace.append(QJSConverter::toString(frame->GetScriptName()));
+ backtrace.append(QString::fromAscii(":"));
+ backtrace.append(QString::number(frame->GetLineNumber()));
+ }
+ return backtrace;
+}
+
+void QV8Engine::Exception::push()
+{
+ m_stack.push(qMakePair(m_value, m_message));
+ m_value.Clear();
+ m_message.Clear();
+}
+
+void QV8Engine::Exception::pop()
+{
+ Q_ASSERT_X(!m_stack.empty(), Q_FUNC_INFO, "Attempt to load unsaved exception found");
+ ValueMessagePair pair = m_stack.pop();
+ clear();
+ m_value = pair.first;
+ m_message = pair.second;
+}
+
+
+// Converts a QVariantList to JS.
+// The result is a new Array object with length equal to the length
+// of the QVariantList, and the elements being the QVariantList's
+// elements converted to JS, recursively.
+v8::Local<v8::Array> QV8Engine::variantListToJS(const QVariantList &lst)
+{
+ v8::Local<v8::Array> result = v8::Array::New(lst.size());
+ for (int i = 0; i < lst.size(); ++i)
+ result->Set(i, variantToJS(lst.at(i)));
+ return result;
+}
+
+// Converts a JS Array object to a QVariantList.
+// The result is a QVariantList with length equal to the length
+// of the JS Array, and elements being the JS Array's elements
+// converted to QVariants, recursively.
+QVariantList QV8Engine::variantListFromJS(v8::Handle<v8::Array> jsArray)
+{
+ QVariantList result;
+ int hash = jsArray->GetIdentityHash();
+ if (visitedConversionObjects.contains(hash))
+ return result; // Avoid recursion.
+ v8::HandleScope handleScope;
+ visitedConversionObjects.insert(hash);
+ uint32_t length = jsArray->Length();
+ for (uint32_t i = 0; i < length; ++i)
+ result.append(variantFromJS(jsArray->Get(i)));
+ visitedConversionObjects.remove(hash);
+ return result;
+}
+
+// Converts a QVariantMap to JS.
+// The result is a new Object object with property names being
+// the keys of the QVariantMap, and values being the values of
+// the QVariantMap converted to JS, recursively.
+v8::Local<v8::Object> QV8Engine::variantMapToJS(const QVariantMap &vmap)
+{
+ v8::Local<v8::Object> result = v8::Object::New();
+ QVariantMap::const_iterator it;
+ for (it = vmap.constBegin(); it != vmap.constEnd(); ++it)
+ result->Set(QJSConverter::toString(it.key()), variantToJS(it.value()));
+ return result;
+}
+
+// Converts a JS Object to a QVariantMap.
+// The result is a QVariantMap with keys being the property names
+// of the object, and values being the values of the JS object's
+// properties converted to QVariants, recursively.
+QVariantMap QV8Engine::variantMapFromJS(v8::Handle<v8::Object> jsObject)
+{
+ QVariantMap result;
+
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Array> propertyNames = jsObject->GetPropertyNames();
+ uint32_t length = propertyNames->Length();
+ if (length == 0)
+ return result;
+
+ int hash = jsObject->GetIdentityHash();
+ if (visitedConversionObjects.contains(hash))
+ return result; // Avoid recursion.
+
+ visitedConversionObjects.insert(hash);
+ // TODO: Only object's own property names. Include non-enumerable properties.
+ for (uint32_t i = 0; i < length; ++i) {
+ v8::Handle<v8::Value> name = propertyNames->Get(i);
+ result.insert(QJSConverter::toString(name->ToString()), variantFromJS(jsObject->Get(name)));
+ }
+ visitedConversionObjects.remove(hash);
+ return result;
+}
+
+// Converts the meta-type defined by the given type and data to JS.
+// Returns the value if conversion succeeded, an empty handle otherwise.
+v8::Handle<v8::Value> QV8Engine::metaTypeToJS(int type, const void *data)
+{
+ Q_ASSERT(data != 0);
+ v8::Handle<v8::Value> result;
+
+ // check if it's one of the types we know
+ switch (QMetaType::Type(type)) {
+ case QMetaType::Void:
+ return v8::Undefined();
+ case QMetaType::Bool:
+ return v8::Boolean::New(*reinterpret_cast<const bool*>(data));
+ case QMetaType::Int:
+ return v8::Int32::New(*reinterpret_cast<const int*>(data));
+ case QMetaType::UInt:
+ return v8::Uint32::New(*reinterpret_cast<const uint*>(data));
+ case QMetaType::LongLong:
+ return v8::Number::New(double(*reinterpret_cast<const qlonglong*>(data)));
+ case QMetaType::ULongLong:
+#if defined(Q_OS_WIN) && defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 12008804
+#pragma message("** NOTE: You need the Visual Studio Processor Pack to compile support for 64bit unsigned integers.")
+ return v8::Number::New(double((qlonglong)*reinterpret_cast<const qulonglong*>(data)));
+#elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
+ return v8::Number::New(double((qlonglong)*reinterpret_cast<const qulonglong*>(data)));
+#else
+ return v8::Number::New(double(*reinterpret_cast<const qulonglong*>(data)));
+#endif
+ case QMetaType::Double:
+ return v8::Number::New(double(*reinterpret_cast<const double*>(data)));
+ case QMetaType::QString:
+ return QJSConverter::toString(*reinterpret_cast<const QString*>(data));
+ case QMetaType::Float:
+ return v8::Number::New(*reinterpret_cast<const float*>(data));
+ case QMetaType::Short:
+ return v8::Int32::New(*reinterpret_cast<const short*>(data));
+ case QMetaType::UShort:
+ return v8::Uint32::New(*reinterpret_cast<const unsigned short*>(data));
+ case QMetaType::Char:
+ return v8::Int32::New(*reinterpret_cast<const char*>(data));
+ case QMetaType::UChar:
+ return v8::Uint32::New(*reinterpret_cast<const unsigned char*>(data));
+ case QMetaType::QChar:
+ return v8::Uint32::New((*reinterpret_cast<const QChar*>(data)).unicode());
+ case QMetaType::QStringList:
+ result = QJSConverter::toStringList(*reinterpret_cast<const QStringList *>(data));
+ break;
+ case QMetaType::QVariantList:
+ result = variantListToJS(*reinterpret_cast<const QVariantList *>(data));
+ break;
+ case QMetaType::QVariantMap:
+ result = variantMapToJS(*reinterpret_cast<const QVariantMap *>(data));
+ break;
+ case QMetaType::QDateTime:
+ result = QJSConverter::toDateTime(*reinterpret_cast<const QDateTime *>(data));
+ break;
+ case QMetaType::QDate:
+ result = QJSConverter::toDateTime(QDateTime(*reinterpret_cast<const QDate *>(data)));
+ break;
+ case QMetaType::QRegExp:
+ result = QJSConverter::toRegExp(*reinterpret_cast<const QRegExp *>(data));
+ break;
+ case QMetaType::QObjectStar:
+ case QMetaType::QWidgetStar:
+ result = newQObject(*reinterpret_cast<QObject* const *>(data));
+ break;
+ case QMetaType::QVariant:
+ result = variantToJS(*reinterpret_cast<const QVariant*>(data));
+ break;
+ default:
+ if (type == qMetaTypeId<QJSValue>()) {
+ return QJSValuePrivate::get(*reinterpret_cast<const QJSValue*>(data))->asV8Value(this);
+ } else {
+ QByteArray typeName = QMetaType::typeName(type);
+ if (typeName.endsWith('*') && !*reinterpret_cast<void* const *>(data)) {
+ return v8::Null();
+ } else {
+ // Fall back to wrapping in a QVariant.
+ result = newVariant(QVariant(type, data));
+ }
+ }
+ }
+ return result;
+}
+
+// Converts a JS value to a meta-type.
+// data must point to a place that can store a value of the given type.
+// Returns true if conversion succeeded, false otherwise.
+bool QV8Engine::metaTypeFromJS(v8::Handle<v8::Value> value, int type, void *data) {
+ // check if it's one of the types we know
+ switch (QMetaType::Type(type)) {
+ case QMetaType::Bool:
+ *reinterpret_cast<bool*>(data) = value->ToBoolean()->Value();
+ return true;
+ case QMetaType::Int:
+ *reinterpret_cast<int*>(data) = value->ToInt32()->Value();
+ return true;
+ case QMetaType::UInt:
+ *reinterpret_cast<uint*>(data) = value->ToUint32()->Value();
+ return true;
+ case QMetaType::LongLong:
+ *reinterpret_cast<qlonglong*>(data) = qlonglong(value->ToInteger()->Value());
+ return true;
+ case QMetaType::ULongLong:
+ *reinterpret_cast<qulonglong*>(data) = qulonglong(value->ToInteger()->Value());
+ return true;
+ case QMetaType::Double:
+ *reinterpret_cast<double*>(data) = value->ToNumber()->Value();
+ return true;
+ case QMetaType::QString:
+ if (value->IsUndefined() || value->IsNull())
+ *reinterpret_cast<QString*>(data) = QString();
+ else
+ *reinterpret_cast<QString*>(data) = QJSConverter::toString(value->ToString());
+ return true;
+ case QMetaType::Float:
+ *reinterpret_cast<float*>(data) = value->ToNumber()->Value();
+ return true;
+ case QMetaType::Short:
+ *reinterpret_cast<short*>(data) = short(value->ToInt32()->Value());
+ return true;
+ case QMetaType::UShort:
+ *reinterpret_cast<unsigned short*>(data) = ushort(value->ToInt32()->Value()); // ### QScript::ToUInt16()
+ return true;
+ case QMetaType::Char:
+ *reinterpret_cast<char*>(data) = char(value->ToInt32()->Value());
+ return true;
+ case QMetaType::UChar:
+ *reinterpret_cast<unsigned char*>(data) = (unsigned char)(value->ToInt32()->Value());
+ return true;
+ case QMetaType::QChar:
+ if (value->IsString()) {
+ QString str = QJSConverter::toString(v8::Handle<v8::String>::Cast(value));
+ *reinterpret_cast<QChar*>(data) = str.isEmpty() ? QChar() : str.at(0);
+ } else {
+ *reinterpret_cast<QChar*>(data) = QChar(ushort(value->ToInt32()->Value())); // ### QScript::ToUInt16()
+ }
+ return true;
+ case QMetaType::QDateTime:
+ if (value->IsDate()) {
+ *reinterpret_cast<QDateTime *>(data) = QJSConverter::toDateTime(v8::Handle<v8::Date>::Cast(value));
+ return true;
+ } break;
+ case QMetaType::QDate:
+ if (value->IsDate()) {
+ *reinterpret_cast<QDate *>(data) = QJSConverter::toDateTime(v8::Handle<v8::Date>::Cast(value)).date();
+ return true;
+ } break;
+ case QMetaType::QRegExp:
+ if (value->IsRegExp()) {
+ *reinterpret_cast<QRegExp *>(data) = QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(value));
+ return true;
+ } break;
+ case QMetaType::QObjectStar:
+ if (isQObject(value) || value->IsNull()) {
+ *reinterpret_cast<QObject* *>(data) = qtObjectFromJS(value);
+ return true;
+ } break;
+ case QMetaType::QWidgetStar:
+ if (isQObject(value) || value->IsNull()) {
+ QObject *qo = qtObjectFromJS(value);
+ if (!qo || qo->isWidgetType()) {
+ *reinterpret_cast<QWidget* *>(data) = reinterpret_cast<QWidget*>(qo);
+ return true;
+ }
+ } break;
+ case QMetaType::QStringList:
+ if (value->IsArray()) {
+ *reinterpret_cast<QStringList *>(data) = QJSConverter::toStringList(v8::Handle<v8::Array>::Cast(value));
+ return true;
+ } break;
+ case QMetaType::QVariantList:
+ if (value->IsArray()) {
+ *reinterpret_cast<QVariantList *>(data) = variantListFromJS(v8::Handle<v8::Array>::Cast(value));
+ return true;
+ } break;
+ case QMetaType::QVariantMap:
+ if (value->IsObject()) {
+ *reinterpret_cast<QVariantMap *>(data) = variantMapFromJS(v8::Handle<v8::Object>::Cast(value));
+ return true;
+ } break;
+ case QMetaType::QVariant:
+ *reinterpret_cast<QVariant*>(data) = variantFromJS(value);
+ return true;
+ default:
+ ;
+ }
+
+#if 0
+ if (isQtVariant(value)) {
+ const QVariant &var = variantValue(value);
+ // ### Enable once constructInPlace() is in qt master.
+ if (var.userType() == type) {
+ QMetaType::constructInPlace(type, data, var.constData());
+ return true;
+ }
+ if (var.canConvert(QVariant::Type(type))) {
+ QVariant vv = var;
+ vv.convert(QVariant::Type(type));
+ Q_ASSERT(vv.userType() == type);
+ QMetaType::constructInPlace(type, data, vv.constData());
+ return true;
+ }
+
+ }
+#endif
+
+ // Try to use magic; for compatibility with qscriptvalue_cast.
+
+ QByteArray name = QMetaType::typeName(type);
+ if (convertToNativeQObject(value, name, reinterpret_cast<void* *>(data)))
+ return true;
+ if (isVariant(value) && name.endsWith('*')) {
+ int valueType = QMetaType::type(name.left(name.size()-1));
+ QVariant &var = variantValue(value);
+ if (valueType == var.userType()) {
+ // We have T t, T* is requested, so return &t.
+ *reinterpret_cast<void* *>(data) = var.data();
+ return true;
+ } else {
+ // Look in the prototype chain.
+ v8::Handle<v8::Value> proto = value->ToObject()->GetPrototype();
+ while (proto->IsObject()) {
+ bool canCast = false;
+ if (isVariant(proto)) {
+ canCast = (type == variantValue(proto).userType())
+ || (valueType && (valueType == variantValue(proto).userType()));
+ }
+ else if (isQObject(proto)) {
+ QByteArray className = name.left(name.size()-1);
+ if (QObject *qobject = qtObjectFromJS(proto))
+ canCast = qobject->qt_metacast(className) != 0;
+ }
+ if (canCast) {
+ QByteArray varTypeName = QMetaType::typeName(var.userType());
+ if (varTypeName.endsWith('*'))
+ *reinterpret_cast<void* *>(data) = *reinterpret_cast<void* *>(var.data());
+ else
+ *reinterpret_cast<void* *>(data) = var.data();
+ return true;
+ }
+ proto = proto->ToObject()->GetPrototype();
+ }
+ }
+ } else if (value->IsNull() && name.endsWith('*')) {
+ *reinterpret_cast<void* *>(data) = 0;
+ return true;
+ } else if (type == qMetaTypeId<QJSValue>()) {
+ *reinterpret_cast<QJSValue*>(data) = QJSValuePrivate::get(new QJSValuePrivate(this, value));
+ return true;
+ }
+
+ return false;
+}
+
+// Converts a QVariant to JS.
+v8::Handle<v8::Value> QV8Engine::variantToJS(const QVariant &value)
+{
+ return metaTypeToJS(value.userType(), value.constData());
+}
+
+// Converts a JS value to a QVariant.
+// Null, Undefined -> QVariant() (invalid)
+// Boolean -> QVariant(bool)
+// Number -> QVariant(double)
+// String -> QVariant(QString)
+// Array -> QVariantList(...)
+// Date -> QVariant(QDateTime)
+// RegExp -> QVariant(QRegExp)
+// [Any other object] -> QVariantMap(...)
+QVariant QV8Engine::variantFromJS(v8::Handle<v8::Value> value)
+{
+ Q_ASSERT(!value.IsEmpty());
+ if (value->IsNull() || value->IsUndefined())
+ return QVariant();
+ if (value->IsBoolean())
+ return value->ToBoolean()->Value();
+ if (value->IsInt32())
+ return value->ToInt32()->Value();
+ if (value->IsNumber())
+ return value->ToNumber()->Value();
+ if (value->IsString())
+ return QJSConverter::toString(value->ToString());
+ Q_ASSERT(value->IsObject());
+ if (value->IsArray())
+ return variantListFromJS(v8::Handle<v8::Array>::Cast(value));
+ if (value->IsDate())
+ return QJSConverter::toDateTime(v8::Handle<v8::Date>::Cast(value));
+ if (value->IsRegExp())
+ return QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(value));
+ if (isVariant(value))
+ return variantValue(value);
+ if (isQObject(value))
+ return qVariantFromValue(qtObjectFromJS(value));
+ return variantMapFromJS(value->ToObject());
+}
+
+bool QV8Engine::convertToNativeQObject(v8::Handle<v8::Value> value,
+ const QByteArray &targetType,
+ void **result)
+{
+ if (!targetType.endsWith('*'))
+ return false;
+ if (QObject *qobject = qtObjectFromJS(value)) {
+ int start = targetType.startsWith("const ") ? 6 : 0;
+ QByteArray className = targetType.mid(start, targetType.size()-start-1);
+ if (void *instance = qobject->qt_metacast(className)) {
+ *result = instance;
+ return true;
+ }
+ }
+ return false;
+}
+
+QObject *QV8Engine::qtObjectFromJS(v8::Handle<v8::Value> value)
+{
+ if (!value->IsObject())
+ return 0;
+
+ QV8ObjectResource *r = (QV8ObjectResource *)value->ToObject()->GetExternalResource();
+ if (!r)
+ return 0;
+ QV8ObjectResource::ResourceType type = r->resourceType();
+ if (type == QV8ObjectResource::QObjectType)
+ return qobjectWrapper()->toQObject(r);
+ else if (type == QV8ObjectResource::VariantType) {
+ QVariant variant = variantWrapper()->toVariant(r);
+ int type = variant.userType();
+ if ((type == QMetaType::QObjectStar) || (type == QMetaType::QWidgetStar))
+ return *reinterpret_cast<QObject* const *>(variant.constData());
+ }
+ return 0;
+}
+
+
+QVariant &QV8Engine::variantValue(v8::Handle<v8::Value> value)
+{
+ return variantWrapper()->variantValue(value);
+}
+
+// Creates a QVariant wrapper object.
+v8::Local<v8::Object> QV8Engine::newVariant(const QVariant &value)
+{
+ return variantWrapper()->newVariant(value);
+}
+
+QScriptPassPointer<QJSValuePrivate> QV8Engine::evaluate(v8::Handle<v8::Script> script, v8::TryCatch& tryCatch)
+{
+ v8::HandleScope handleScope;
+
+ clearExceptions();
+ if (script.IsEmpty()) {
+ v8::Handle<v8::Value> exception = tryCatch.Exception();
+ if (exception.IsEmpty()) {
+ // This is possible on syntax errors like { a:12, b:21 } <- missing "(", ")" around expression.
+ return new QJSValuePrivate(this);
+ }
+ setException(exception, tryCatch.Message());
+ return new QJSValuePrivate(this, exception);
+ }
+ v8::Handle<v8::Value> result;
+ result = script->Run();
+ if (result.IsEmpty()) {
+ v8::Handle<v8::Value> exception = tryCatch.Exception();
+ // TODO: figure out why v8 doesn't always produce an exception value
+ //Q_ASSERT(!exception.IsEmpty());
+ if (exception.IsEmpty())
+ exception = v8::Exception::Error(v8::String::New("missing exception value"));
+ setException(exception, tryCatch.Message());
+ return new QJSValuePrivate(this, exception);
+ }
+ return new QJSValuePrivate(this, result);
+}
+
+QJSValue QV8Engine::scriptValueFromInternal(v8::Handle<v8::Value> value) const
+{
+ if (value.IsEmpty())
+ return QJSValuePrivate::get(new QJSValuePrivate(const_cast<QV8Engine*>(this)));
+ return QJSValuePrivate::get(new QJSValuePrivate(const_cast<QV8Engine*>(this), value));
+}
+
+QScriptPassPointer<QJSValuePrivate> QV8Engine::newArray(uint length)
+{
+ return new QJSValuePrivate(this, v8::Array::New(length));
+}
+
+void QV8Engine::emitSignalHandlerException()
+{
+ emit q->signalHandlerException(scriptValueFromInternal(uncaughtException()));
+}
+
+void QV8Engine::startTimer(const QString &timerName)
+{
+ if (!m_time.isValid())
+ m_time.start();
+ m_startedTimers[timerName] = m_time.elapsed();
+}
+
+qint64 QV8Engine::stopTimer(const QString &timerName, bool *wasRunning)
+{
+ if (!m_startedTimers.contains(timerName)) {
+ *wasRunning = false;
+ return 0;
+ }
+ *wasRunning = true;
+ qint64 startedAt = m_startedTimers.take(timerName);
+ return m_time.elapsed() - startedAt;
+}
+
+int QV8Engine::consoleCountHelper(const QString &file, int line, int column)
+{
+ const QString key = file + QString::number(line) + QString::number(column);
+ int number = m_consoleCount.value(key, 0);
+ number++;
+ m_consoleCount.insert(key, number);
+ return number;
+}
+
+void QV8GCCallback::registerGcPrologueCallback()
+{
+ QV8Engine::ThreadData *td = QV8Engine::threadData();
+ if (!td->gcPrologueCallbackRegistered) {
+ td->gcPrologueCallbackRegistered = true;
+ v8::V8::AddGCPrologueCallback(QV8GCCallback::garbageCollectorPrologueCallback, v8::kGCTypeMarkSweepCompact);
+ }
+}
+
+QV8GCCallback::Node::Node(PrologueCallback callback)
+ : prologueCallback(callback)
+{
+}
+
+QV8GCCallback::Node::~Node()
+{
+ node.remove();
+}
+
+/*
+ Ensure that each persistent handle is strong if it has CPP ownership
+ and has no implicitly JS owned object owner in its parent chain, and
+ weak otherwise.
+
+ Any weak handle whose parent object is still alive will have an implicit
+ reference (between the parent and the handle) added, so that it will
+ not be collected.
+
+ Note that this callback is registered only for kGCTypeMarkSweepCompact
+ collection cycles, as it is during collection cycles of that type
+ in which weak persistent handle callbacks are called when required.
+ */
+void QV8GCCallback::garbageCollectorPrologueCallback(v8::GCType, v8::GCCallbackFlags)
+{
+ if (!QV8Engine::hasThreadData())
+ return;
+
+ QV8Engine::ThreadData *td = QV8Engine::threadData();
+ QV8GCCallback::Node *currNode = td->gcCallbackNodes.first();
+
+ while (currNode) {
+ // The client which adds itself to the list is responsible
+ // for maintaining the correct implicit references in the
+ // specified callback.
+ currNode->prologueCallback(currNode);
+ currNode = td->gcCallbackNodes.next(currNode);
+ }
+}
+
+void QV8GCCallback::addGcCallbackNode(QV8GCCallback::Node *node)
+{
+ QV8Engine::ThreadData *td = QV8Engine::threadData();
+ td->gcCallbackNodes.insert(node);
+}
+
+QV8Engine::ThreadData::ThreadData()
+ : gcPrologueCallbackRegistered(false)
+{
+ if (!v8::Isolate::GetCurrent()) {
+ isolate = v8::Isolate::New();
+ isolate->Enter();
+ } else {
+ isolate = 0;
+ }
+}
+
+QV8Engine::ThreadData::~ThreadData()
+{
+ if (isolate) {
+ isolate->Exit();
+ isolate->Dispose();
+ isolate = 0;
+ }
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/v8/qv8engine_impl_p.h b/src/qml/qml/v8/qv8engine_impl_p.h
new file mode 100644
index 0000000000..7173ae4c01
--- /dev/null
+++ b/src/qml/qml/v8/qv8engine_impl_p.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8ENGINE_IMPL_P_H
+#define QV8ENGINE_IMPL_P_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 "qv8engine_p.h"
+#include "qjsvalue_p.h"
+#include "qjsconverter_p.h"
+#include "qjsvalueiterator_p.h"
+
+QT_BEGIN_NAMESPACE
+
+inline v8::Handle<v8::Value> QV8Engine::makeJSValue(bool value)
+{
+ return value ? v8::True() : v8::False();
+}
+
+inline v8::Local<v8::Value> QV8Engine::makeJSValue(int value)
+{
+ return v8::Integer::New(value);
+}
+
+inline v8::Local<v8::Value> QV8Engine::makeJSValue(uint value)
+{
+ return v8::Integer::NewFromUnsigned(value);
+}
+
+inline v8::Local<v8::Value> QV8Engine::makeJSValue(double value)
+{
+ return v8::Number::New(value);
+}
+
+inline v8::Handle<v8::Value> QV8Engine::makeJSValue(QJSValue::SpecialValue value) {
+ if (value == QJSValue::NullValue)
+ return v8::Null();
+ return v8::Undefined();
+}
+
+inline v8::Local<v8::Value> QV8Engine::makeJSValue(const QString &value)
+{
+ return QJSConverter::toString(value);
+}
+
+class QtScriptBagCleaner
+{
+public:
+ template<class T>
+ void operator () (T* value) const
+ {
+ value->reinitialize();
+ }
+ void operator () (QJSValueIteratorPrivate *iterator) const
+ {
+ iterator->invalidate();
+ }
+};
+
+inline void QV8Engine::registerValue(QJSValuePrivate *data)
+{
+ m_values.insert(data);
+}
+
+inline void QV8Engine::unregisterValue(QJSValuePrivate *data)
+{
+ m_values.remove(data);
+}
+
+inline void QV8Engine::invalidateAllValues()
+{
+ ValueList::iterator it;
+ for (it = m_values.begin(); it != m_values.end(); it = it.erase())
+ (*it)->invalidate();
+ Q_ASSERT(m_values.isEmpty());
+}
+
+inline void QV8Engine::registerValueIterator(QJSValueIteratorPrivate *data)
+{
+ m_valueIterators.insert(data);
+}
+
+inline void QV8Engine::unregisterValueIterator(QJSValueIteratorPrivate *data)
+{
+ m_valueIterators.remove(data);
+}
+
+inline void QV8Engine::invalidateAllIterators()
+{
+ ValueIteratorList::iterator it;
+ for (it = m_valueIterators.begin(); it != m_valueIterators.end(); it = it.erase())
+ (*it)->invalidate();
+ Q_ASSERT(m_valueIterators.isEmpty());
+}
+
+/*!
+ \internal
+ \note property can be index (v8::Integer) or a property (v8::String) name, according to ECMA script
+ property would be converted to a string.
+*/
+inline QJSValuePrivate::PropertyFlags QV8Engine::getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property)
+{
+ QJSValuePrivate::PropertyFlags flags = m_originalGlobalObject.getPropertyFlags(object, property);
+ return flags;
+}
+
+QScriptPassPointer<QJSValuePrivate> QV8Engine::evaluate(const QString& program, const QString& fileName, int lineNumber)
+{
+ v8::TryCatch tryCatch;
+ v8::ScriptOrigin scriptOrigin(QJSConverter::toString(fileName), v8::Integer::New(lineNumber - 1));
+ v8::Handle<v8::Script> script;
+ script = v8::Script::Compile(QJSConverter::toString(program), &scriptOrigin);
+ if (script.IsEmpty()) {
+ // TODO: Why don't we get the exception, as with Script::Compile()?
+ // Q_ASSERT(tryCatch.HasCaught());
+ v8::Handle<v8::Value> error = v8::Exception::SyntaxError(v8::String::New(""));
+ setException(error);
+ return new QJSValuePrivate(this, error);
+ }
+ return evaluate(script, tryCatch);
+}
+
+QT_END_NAMESPACE
+
+#endif // QV8ENGINE_IMPL_P_H
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
new file mode 100644
index 0000000000..bc57b27085
--- /dev/null
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -0,0 +1,631 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLV8ENGINE_P_H
+#define QQMLV8ENGINE_P_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>
+#include <QtCore/qset.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/QElapsedTimer>
+#include <QtCore/QThreadStorage>
+
+#include <private/qv8_p.h>
+#include <qjsengine.h>
+#include <qjsvalue.h>
+#include "qjsvalue_p.h"
+#include "qjsvalueiterator_p.h"
+#include "qscriptoriginalglobalobject_p.h"
+#include "qscripttools_p.h"
+
+#include <private/qqmlpropertycache_p.h>
+
+#include "qv8contextwrapper_p.h"
+#include "qv8qobjectwrapper_p.h"
+#include "qv8stringwrapper_p.h"
+#include "qv8typewrapper_p.h"
+#include "qv8listwrapper_p.h"
+#include "qv8variantwrapper_p.h"
+#include "qv8valuetypewrapper_p.h"
+#include "qv8sequencewrapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+// Uncomment the following line to enable global handle debugging. When enabled, all the persistent
+// handles allocated using qPersistentNew() (or registered with qPersistentRegsiter()) and disposed
+// with qPersistentDispose() are tracked. If you try and do something illegal, like double disposing
+// a handle, qFatal() is called.
+// #define QML_GLOBAL_HANDLE_DEBUGGING
+
+#define V8_RESOURCE_TYPE(resourcetype) \
+public: \
+ enum { V8ResourceType = QV8ObjectResource:: resourcetype }; \
+ virtual QV8ObjectResource::ResourceType resourceType() const { return QV8ObjectResource:: resourcetype; } \
+private:
+
+#define V8ENGINE() ((QV8Engine *)v8::External::Unwrap(args.Data()))
+#define V8FUNCTION(function, engine) v8::FunctionTemplate::New(function, v8::External::Wrap((QV8Engine*)engine))->GetFunction()
+#define V8THROW_ERROR(string) { \
+ v8::ThrowException(v8::Exception::Error(v8::String::New(string))); \
+ return v8::Handle<v8::Value>(); \
+}
+#define V8THROW_TYPE(string) { \
+ v8::ThrowException(v8::Exception::TypeError(v8::String::New(string))); \
+ return v8::Handle<v8::Value>(); \
+}
+#define V8ENGINE_ACCESSOR() ((QV8Engine *)v8::External::Unwrap(info.Data()));
+#define V8THROW_ERROR_SETTER(string) { \
+ v8::ThrowException(v8::Exception::Error(v8::String::New(string))); \
+ return; \
+}
+
+#define V8_DEFINE_EXTENSION(dataclass, datafunction) \
+ static inline dataclass *datafunction(QV8Engine *engine) \
+ { \
+ static int extensionId = -1; \
+ if (extensionId == -1) { \
+ QV8Engine::registrationMutex()->lock(); \
+ if (extensionId == -1) \
+ extensionId = QV8Engine::registerExtension(); \
+ QV8Engine::registrationMutex()->unlock(); \
+ } \
+ dataclass *rv = (dataclass *)engine->extensionData(extensionId); \
+ if (!rv) { \
+ rv = new dataclass(engine); \
+ engine->setExtensionData(extensionId, rv); \
+ } \
+ return rv; \
+ } \
+
+
+class QV8Engine;
+class QV8ObjectResource : public v8::Object::ExternalResource
+{
+public:
+ QV8ObjectResource(QV8Engine *engine) : engine(engine) { Q_ASSERT(engine); }
+ enum ResourceType { ContextType, QObjectType, TypeType, ListType, VariantType,
+ ValueTypeType, XMLHttpRequestType, DOMNodeType, SQLDatabaseType,
+ ListModelType, Context2DType, Context2DStyleType, Context2DPixelArrayType,
+ ParticleDataType, SignalHandlerType, IncubatorType, VisualDataItemType,
+ SequenceType, LocaleDataType };
+ virtual ResourceType resourceType() const = 0;
+
+ QV8Engine *engine;
+};
+
+template<class T>
+inline T *v8_resource_cast(v8::Handle<v8::Object> object) {
+ QV8ObjectResource *resource = static_cast<QV8ObjectResource *>(object->GetExternalResource());
+ return (resource && (quint32)resource->resourceType() == (quint32)T::V8ResourceType)?static_cast<T *>(resource):0;
+}
+
+template<class T>
+inline T *v8_resource_check(v8::Handle<v8::Object> object) {
+ T *resource = static_cast<T *>(object->GetExternalResource());
+ Q_ASSERT(resource && resource->resourceType() == (quint32)T::V8ResourceType);
+ return resource;
+}
+
+// Used to allow a QObject method take and return raw V8 handles without having to expose
+// v8 in the public API.
+// Use like this:
+// class MyClass : public QObject {
+// Q_OBJECT
+// ...
+// Q_INVOKABLE void myMethod(QQmlV8Function*);
+// };
+// The QQmlV8Function - and consequently the arguments and return value - only remains
+// valid during the call. If the return value isn't set within myMethod(), the will return
+// undefined.
+class QV8Engine;
+class QQmlV8Function
+{
+public:
+ int Length() const { return _ac; }
+ v8::Local<v8::Value> operator[](int idx) { return (*_a)->Get(idx); }
+ QQmlContextData *context() { return _c; }
+ v8::Handle<v8::Object> qmlGlobal() { return *_g; }
+ void returnValue(v8::Handle<v8::Value> rv) { *_r = rv; }
+ QV8Engine *engine() const { return _e; }
+private:
+ friend class QV8QObjectWrapper;
+ QQmlV8Function();
+ QQmlV8Function(const QQmlV8Function &);
+ QQmlV8Function &operator=(const QQmlV8Function &);
+
+ QQmlV8Function(int length, v8::Handle<v8::Object> &args,
+ v8::Handle<v8::Value> &rv, v8::Handle<v8::Object> &global,
+ QQmlContextData *c, QV8Engine *e)
+ : _ac(length), _a(&args), _r(&rv), _g(&global), _c(c), _e(e) {}
+
+ int _ac;
+ v8::Handle<v8::Object> *_a;
+ v8::Handle<v8::Value> *_r;
+ v8::Handle<v8::Object> *_g;
+ QQmlContextData *_c;
+ QV8Engine *_e;
+};
+
+class QQmlV8Handle
+{
+public:
+ QQmlV8Handle() : d(0) {}
+ QQmlV8Handle(const QQmlV8Handle &other) : d(other.d) {}
+ QQmlV8Handle &operator=(const QQmlV8Handle &other) { d = other.d; return *this; }
+
+ static QQmlV8Handle fromHandle(v8::Handle<v8::Value> h) {
+ return QQmlV8Handle(*h);
+ }
+ v8::Handle<v8::Value> toHandle() const {
+ return v8::Handle<v8::Value>((v8::Value *)d);
+ }
+private:
+ QQmlV8Handle(void *d) : d(d) {}
+ void *d;
+};
+
+class QObject;
+class QQmlEngine;
+class QQmlValueType;
+class QNetworkAccessManager;
+class QQmlContextData;
+
+class Q_AUTOTEST_EXPORT QV8GCCallback
+{
+private:
+ class ThreadData;
+public:
+ static void garbageCollectorPrologueCallback(v8::GCType, v8::GCCallbackFlags);
+ static void registerGcPrologueCallback();
+
+ class Q_AUTOTEST_EXPORT Node {
+ public:
+ typedef void (*PrologueCallback)(Node *node);
+ Node(PrologueCallback callback);
+ ~Node();
+
+ QIntrusiveListNode node;
+ PrologueCallback prologueCallback;
+ };
+
+ static void addGcCallbackNode(Node *node);
+};
+
+class Q_QML_EXPORT QV8Engine
+{
+public:
+ static QV8Engine* get(QJSEngine* q) { Q_ASSERT(q); return q->handle(); }
+ static QJSEngine* get(QV8Engine* d) { Q_ASSERT(d); return d->q; }
+
+ QV8Engine(QJSEngine* qq,QJSEngine::ContextOwnership ownership = QJSEngine::CreateNewContext);
+ virtual ~QV8Engine();
+
+ // This enum should be in sync with QQmlEngine::ObjectOwnership
+ enum ObjectOwnership { CppOwnership, JavaScriptOwnership };
+
+ struct Deletable {
+ virtual ~Deletable() {}
+ };
+
+ class Exception
+ {
+ typedef QPair<v8::Persistent<v8::Value>, v8::Persistent<v8::Message> > ValueMessagePair;
+
+ v8::Persistent<v8::Value> m_value;
+ v8::Persistent<v8::Message> m_message;
+ QStack<ValueMessagePair> m_stack;
+
+ Q_DISABLE_COPY(Exception)
+ public:
+ inline Exception();
+ inline ~Exception();
+ inline void set(v8::Handle<v8::Value> value, v8::Handle<v8::Message> message);
+ inline void clear();
+ inline operator bool() const;
+ inline operator v8::Handle<v8::Value>() const;
+ inline int lineNumber() const;
+ inline QStringList backtrace() const;
+
+ inline void push();
+ inline void pop();
+ };
+
+ void initQmlGlobalObject();
+ void setEngine(QQmlEngine *engine);
+ QQmlEngine *engine() { return m_engine; }
+ v8::Local<v8::Object> global() { return m_context->Global(); }
+ v8::Handle<v8::Context> context() const { return m_context; }
+
+ inline void registerValue(QJSValuePrivate *data);
+ inline void unregisterValue(QJSValuePrivate *data);
+ inline void invalidateAllValues();
+
+ inline void registerValueIterator(QJSValueIteratorPrivate *data);
+ inline void unregisterValueIterator(QJSValueIteratorPrivate *data);
+ inline void invalidateAllIterators();
+
+ QV8ContextWrapper *contextWrapper() { return &m_contextWrapper; }
+ QV8QObjectWrapper *qobjectWrapper() { return &m_qobjectWrapper; }
+ QV8TypeWrapper *typeWrapper() { return &m_typeWrapper; }
+ QV8ListWrapper *listWrapper() { return &m_listWrapper; }
+ QV8VariantWrapper *variantWrapper() { return &m_variantWrapper; }
+ QV8ValueTypeWrapper *valueTypeWrapper() { return &m_valueTypeWrapper; }
+ QV8SequenceWrapper *sequenceWrapper() { return &m_sequenceWrapper; }
+
+ void *xmlHttpRequestData() { return m_xmlHttpRequestData; }
+
+ Deletable *listModelData() { return m_listModelData; }
+ void setListModelData(Deletable *d) { if (m_listModelData) delete m_listModelData; m_listModelData = d; }
+
+ QQmlContextData *callingContext();
+
+ v8::Local<v8::Array> getOwnPropertyNames(v8::Handle<v8::Object>);
+ inline QJSValuePrivate::PropertyFlags getPropertyFlags(v8::Handle<v8::Object> object, v8::Handle<v8::Value> property);
+ void freezeObject(v8::Handle<v8::Value>);
+
+ inline QString toString(v8::Handle<v8::Value> string);
+ inline QString toString(v8::Handle<v8::String> string);
+ static QString toStringStatic(v8::Handle<v8::Value>);
+ static QString toStringStatic(v8::Handle<v8::String>);
+ static inline bool startsWithUpper(v8::Handle<v8::String>);
+
+ QVariant toVariant(v8::Handle<v8::Value>, int typeHint);
+ v8::Handle<v8::Value> fromVariant(const QVariant &);
+ inline bool isVariant(v8::Handle<v8::Value>);
+
+ // Compile \a source (from \a fileName at \a lineNumber) in QML mode
+ v8::Local<v8::Script> qmlModeCompile(const QString &source,
+ const QString &fileName = QString(),
+ int lineNumber = 1);
+ v8::Local<v8::Script> qmlModeCompile(const char *source, int sourceLength = -1,
+ const QString &fileName = QString(),
+ int lineNumber = 1);
+
+ // Return the QML global "scope" object for the \a ctxt context and \a scope object.
+ inline v8::Local<v8::Object> qmlScope(QQmlContextData *ctxt, QObject *scope);
+
+ // Return a JS wrapper for the given QObject \a object
+ inline v8::Handle<v8::Value> newQObject(QObject *object);
+ inline v8::Handle<v8::Value> newQObject(QObject *object, const ObjectOwnership ownership);
+ inline bool isQObject(v8::Handle<v8::Value>);
+ inline QObject *toQObject(v8::Handle<v8::Value>);
+
+ // Return a JS string for the given QString \a string
+ inline v8::Local<v8::String> toString(const QString &string);
+
+ // Create a new value type object
+ inline v8::Handle<v8::Value> newValueType(QObject *, int coreIndex, QQmlValueType *);
+ inline v8::Handle<v8::Value> newValueType(const QVariant &, QQmlValueType *);
+
+ // Create a new sequence type object
+ inline v8::Handle<v8::Value> newSequence(int sequenceType, QObject *, int coreIndex, bool *succeeded);
+
+ // Create a new QVariant object. This doesn't examine the type of the variant, but always returns
+ // a QVariant wrapper
+ inline v8::Handle<v8::Value> newQVariant(const QVariant &);
+
+ // Return the network access manager for this engine. By default this returns the network
+ // access manager of the QQmlEngine. It is overridden in the case of a threaded v8
+ // instance (like in WorkerScript).
+ virtual QNetworkAccessManager *networkAccessManager();
+
+ // Return the list of illegal id names (the names of the properties on the global object)
+ const QStringHash<bool> &illegalNames() const;
+
+ inline void collectGarbage() { gc(); }
+ static void gc();
+
+ void clearExceptions();
+ void setException(v8::Handle<v8::Value> value, v8::Handle<v8::Message> message = v8::Handle<v8::Message>());
+ v8::Handle<v8::Value> throwException(v8::Handle<v8::Value> value);
+ bool hasUncaughtException() const;
+ int uncaughtExceptionLineNumber() const;
+ QStringList uncaughtExceptionBacktrace() const;
+ v8::Handle<v8::Value> uncaughtException() const;
+ void saveException();
+ void restoreException();
+
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+ // Used for handle debugging
+ static void registerHandle(void *);
+ static void releaseHandle(void *);
+#endif
+
+ static QMutex *registrationMutex();
+ static int registerExtension();
+
+ inline Deletable *extensionData(int) const;
+ void setExtensionData(int, Deletable *);
+
+ inline v8::Handle<v8::Value> makeJSValue(bool value);
+ inline v8::Local<v8::Value> makeJSValue(int value);
+ inline v8::Local<v8::Value> makeJSValue(uint value);
+ inline v8::Local<v8::Value> makeJSValue(double value);
+ inline v8::Handle<v8::Value> makeJSValue(QJSValue::SpecialValue value);
+ inline v8::Local<v8::Value> makeJSValue(const QString &value);
+
+ inline QScriptPassPointer<QJSValuePrivate> evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
+ QScriptPassPointer<QJSValuePrivate> evaluate(v8::Handle<v8::Script> script, v8::TryCatch& tryCatch);
+
+ QScriptPassPointer<QJSValuePrivate> newArray(uint length);
+ v8::Local<v8::Object> newVariant(const QVariant &variant);
+
+ v8::Local<v8::Array> variantListToJS(const QVariantList &lst);
+ QVariantList variantListFromJS(v8::Handle<v8::Array> jsArray);
+
+ v8::Local<v8::Object> variantMapToJS(const QVariantMap &vmap);
+ QVariantMap variantMapFromJS(v8::Handle<v8::Object> jsObject);
+
+ v8::Handle<v8::Value> variantToJS(const QVariant &value);
+ QVariant variantFromJS(v8::Handle<v8::Value> value);
+
+ v8::Handle<v8::Value> metaTypeToJS(int type, const void *data);
+ bool metaTypeFromJS(v8::Handle<v8::Value> value, int type, void *data);
+
+ bool convertToNativeQObject(v8::Handle<v8::Value> value,
+ const QByteArray &targetType,
+ void **result);
+
+ QVariant &variantValue(v8::Handle<v8::Value> value);
+
+ QJSValue scriptValueFromInternal(v8::Handle<v8::Value>) const;
+
+ void emitSignalHandlerException();
+
+ // used for console.time(), console.timeEnd()
+ void startTimer(const QString &timerName);
+ qint64 stopTimer(const QString &timerName, bool *wasRunning);
+
+ // used for console.count()
+ int consoleCountHelper(const QString &file, int line, int column);
+
+ QObject *qtObjectFromJS(v8::Handle<v8::Value> value);
+ QSet<int> visitedConversionObjects;
+
+ static QDateTime qtDateTimeFromJsDate(double jsDate);
+
+ void addRelationshipForGC(QObject *object, v8::Persistent<v8::Value> handle);
+ void addRelationshipForGC(QObject *object, QObject *other);
+
+ struct ThreadData {
+ ThreadData();
+ ~ThreadData();
+ v8::Isolate* isolate;
+ bool gcPrologueCallbackRegistered;
+ QIntrusiveList<QV8GCCallback::Node, &QV8GCCallback::Node::node> gcCallbackNodes;
+ };
+
+ static bool hasThreadData();
+ static ThreadData* threadData();
+ static void ensurePerThreadIsolate();
+
+ v8::Persistent<v8::Object> m_strongReferencer;
+
+protected:
+ QJSEngine* q;
+ QQmlEngine *m_engine;
+ bool m_ownsV8Context;
+ v8::Persistent<v8::Context> m_context;
+ QScriptOriginalGlobalObject m_originalGlobalObject;
+
+ QV8StringWrapper m_stringWrapper;
+ QV8ContextWrapper m_contextWrapper;
+ QV8QObjectWrapper m_qobjectWrapper;
+ QV8TypeWrapper m_typeWrapper;
+ QV8ListWrapper m_listWrapper;
+ QV8VariantWrapper m_variantWrapper;
+ QV8ValueTypeWrapper m_valueTypeWrapper;
+ QV8SequenceWrapper m_sequenceWrapper;
+
+ v8::Persistent<v8::Function> m_getOwnPropertyNames;
+ v8::Persistent<v8::Function> m_freezeObject;
+
+ void *m_xmlHttpRequestData;
+
+ QVector<Deletable *> m_extensionData;
+ Deletable *m_listModelData;
+
+ QStringHash<bool> m_illegalNames;
+
+ Exception m_exception;
+
+ QElapsedTimer m_time;
+ QHash<QString, qint64> m_startedTimers;
+
+ QHash<QString, quint32> m_consoleCount;
+
+ QVariant toBasicVariant(v8::Handle<v8::Value>);
+
+ void initializeGlobal(v8::Handle<v8::Object>);
+
+ double qtDateTimeToJsDate(const QDateTime &dt);
+
+private:
+ static v8::Persistent<v8::Object> *findOwnerAndStrength(QObject *object, bool *shouldBeStrong);
+
+ typedef QScriptIntrusiveList<QJSValuePrivate, &QJSValuePrivate::m_node> ValueList;
+ ValueList m_values;
+ typedef QScriptIntrusiveList<QJSValueIteratorPrivate, &QJSValueIteratorPrivate::m_node> ValueIteratorList;
+ ValueIteratorList m_valueIterators;
+
+ Q_DISABLE_COPY(QV8Engine)
+};
+
+// Allocate a new Persistent handle. *ALL* persistent handles in QML must be allocated
+// using this method.
+template<class T>
+v8::Persistent<T> qPersistentNew(v8::Handle<T> that)
+{
+ v8::Persistent<T> rv = v8::Persistent<T>::New(that);
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+ QV8Engine::registerHandle(*rv);
+#endif
+ return rv;
+}
+
+// Register a Persistent handle that was returned to you by V8 (such as by
+// v8::Context::New). This allows us to do handle tracking on these handles too.
+template<class T>
+void qPersistentRegister(v8::Persistent<T> handle)
+{
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+ QV8Engine::registerHandle(*handle);
+#else
+ Q_UNUSED(handle);
+#endif
+}
+
+// Dispose and clear a persistent handle. *ALL* persistent handles in QML must be
+// disposed using this method.
+template<class T>
+void qPersistentDispose(v8::Persistent<T> &that)
+{
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+ QV8Engine::releaseHandle(*that);
+#endif
+ that.Dispose();
+ that.Clear();
+}
+
+QString QV8Engine::toString(v8::Handle<v8::Value> string)
+{
+ return m_stringWrapper.toString(string->ToString());
+}
+
+QString QV8Engine::toString(v8::Handle<v8::String> string)
+{
+ return m_stringWrapper.toString(string);
+}
+
+bool QV8Engine::isVariant(v8::Handle<v8::Value> value)
+{
+ return m_variantWrapper.isVariant(value);
+}
+
+v8::Local<v8::Object> QV8Engine::qmlScope(QQmlContextData *ctxt, QObject *scope)
+{
+ return m_contextWrapper.qmlScope(ctxt, scope);
+}
+
+bool QV8Engine::isQObject(v8::Handle<v8::Value> obj)
+{
+ return obj->IsObject()?m_qobjectWrapper.isQObject(v8::Handle<v8::Object>::Cast(obj)):false;
+}
+
+QObject *QV8Engine::toQObject(v8::Handle<v8::Value> obj)
+{
+ return obj->IsObject()?m_qobjectWrapper.toQObject(v8::Handle<v8::Object>::Cast(obj)):0;
+}
+
+v8::Handle<v8::Value> QV8Engine::newQObject(QObject *object)
+{
+ return m_qobjectWrapper.newQObject(object);
+}
+
+v8::Handle<v8::Value> QV8Engine::newQObject(QObject *object, const ObjectOwnership ownership)
+{
+ if (!object)
+ return v8::Null();
+
+ v8::Handle<v8::Value> result = newQObject(object);
+ QQmlData *ddata = QQmlData::get(object, true);
+ if (ownership == JavaScriptOwnership && ddata) {
+ ddata->indestructible = false;
+ ddata->explicitIndestructibleSet = true;
+ }
+ return result;
+}
+
+v8::Local<v8::String> QV8Engine::toString(const QString &string)
+{
+ return m_stringWrapper.toString(string);
+}
+
+v8::Handle<v8::Value> QV8Engine::newValueType(QObject *object, int property, QQmlValueType *type)
+{
+ return m_valueTypeWrapper.newValueType(object, property, type);
+}
+
+v8::Handle<v8::Value> QV8Engine::newValueType(const QVariant &value, QQmlValueType *type)
+{
+ return m_valueTypeWrapper.newValueType(value, type);
+}
+
+v8::Handle<v8::Value> QV8Engine::newSequence(int sequenceType, QObject *object, int property, bool *succeeded)
+{
+ return m_sequenceWrapper.newSequence(sequenceType, object, property, succeeded);
+}
+
+// XXX Can this be made more optimal? It is called prior to resolving each and every
+// unqualified name in QV8ContextWrapper.
+bool QV8Engine::startsWithUpper(v8::Handle<v8::String> string)
+{
+ uint16_t c = string->GetCharacter(0);
+ return (c >= 'A' && c <= 'Z') ||
+ (c > 127 && QChar::category(c) == QChar::Letter_Uppercase);
+}
+
+QV8Engine::Deletable *QV8Engine::extensionData(int index) const
+{
+ if (index < m_extensionData.count())
+ return m_extensionData[index];
+ else
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLV8ENGINE_P_H
diff --git a/src/qml/qml/v8/qv8include.cpp b/src/qml/qml/v8/qv8include.cpp
new file mode 100644
index 0000000000..89f60f256e
--- /dev/null
+++ b/src/qml/qml/v8/qv8include.cpp
@@ -0,0 +1,244 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8include_p.h"
+
+#include <QtQml/qjsengine.h>
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtCore/qfile.h>
+
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QV8Include::QV8Include(const QUrl &url, QV8Engine *engine, QQmlContextData *context,
+ v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Function> callback)
+: m_engine(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0), m_context(context)
+{
+ m_qmlglobal = qPersistentNew<v8::Object>(qmlglobal);
+ if (!callback.IsEmpty())
+ m_callbackFunction = qPersistentNew<v8::Function>(callback);
+
+ m_resultObject = qPersistentNew<v8::Object>(resultValue());
+
+ m_network = engine->networkAccessManager();
+
+ QNetworkRequest request;
+ request.setUrl(url);
+
+ m_reply = m_network->get(request);
+ QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
+}
+
+QV8Include::~QV8Include()
+{
+ delete m_reply; m_reply = 0;
+ qPersistentDispose(m_callbackFunction);
+ qPersistentDispose(m_resultObject);
+}
+
+v8::Local<v8::Object> QV8Include::resultValue(Status status)
+{
+ // XXX It seems inefficient to create this object from scratch each time.
+ v8::Local<v8::Object> result = v8::Object::New();
+ result->Set(v8::String::New("OK"), v8::Integer::New(Ok));
+ result->Set(v8::String::New("LOADING"), v8::Integer::New(Loading));
+ result->Set(v8::String::New("NETWORK_ERROR"), v8::Integer::New(NetworkError));
+ result->Set(v8::String::New("EXCEPTION"), v8::Integer::New(Exception));
+
+ result->Set(v8::String::New("status"), v8::Integer::New(status));
+
+ return result;
+}
+
+void QV8Include::callback(QV8Engine *engine, v8::Handle<v8::Function> callback, v8::Handle<v8::Object> status)
+{
+ if (!callback.IsEmpty()) {
+ v8::Handle<v8::Value> args[] = { status };
+ v8::TryCatch tc;
+ callback->Call(engine->global(), 1, args);
+ }
+}
+
+v8::Handle<v8::Object> QV8Include::result()
+{
+ return m_resultObject;
+}
+
+#define INCLUDE_MAXIMUM_REDIRECT_RECURSION 15
+void QV8Include::finished()
+{
+ m_redirectCount++;
+
+ if (m_redirectCount < INCLUDE_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ m_url = m_url.resolved(redirect.toUrl());
+ delete m_reply;
+
+ QNetworkRequest request;
+ request.setUrl(m_url);
+
+ m_reply = m_network->get(request);
+ QObject::connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
+ return;
+ }
+ }
+
+ v8::HandleScope handle_scope;
+
+ if (m_reply->error() == QNetworkReply::NoError) {
+ QByteArray data = m_reply->readAll();
+
+ QString code = QString::fromUtf8(data);
+ QQmlScript::Parser::extractPragmas(code);
+
+ QQmlContextData *importContext = new QQmlContextData;
+ importContext->isInternal = true;
+ importContext->isJSContext = true;
+ importContext->url = m_url;
+ importContext->isPragmaLibraryContext = m_context->isPragmaLibraryContext;
+ importContext->setParent(m_context, true);
+
+ v8::Context::Scope ctxtscope(m_engine->context());
+ v8::TryCatch try_catch;
+
+ v8::Local<v8::Script> script = m_engine->qmlModeCompile(code, m_url.toString());
+
+ if (!try_catch.HasCaught()) {
+ m_engine->contextWrapper()->addSubContext(m_qmlglobal, script, importContext);
+ script->Run(m_qmlglobal);
+ }
+
+ if (try_catch.HasCaught()) {
+ m_resultObject->Set(v8::String::New("status"), v8::Integer::New(Exception));
+ m_resultObject->Set(v8::String::New("exception"), try_catch.Exception());
+ } else {
+ m_resultObject->Set(v8::String::New("status"), v8::Integer::New(Ok));
+ }
+ } else {
+ m_resultObject->Set(v8::String::New("status"), v8::Integer::New(NetworkError));
+ }
+
+ callback(m_engine, m_callbackFunction, m_resultObject);
+
+ disconnect();
+ deleteLater();
+}
+
+/*
+ Documented in qv8engine.cpp
+*/
+v8::Handle<v8::Value> QV8Include::include(const v8::Arguments &args)
+{
+ if (args.Length() == 0)
+ return v8::Undefined();
+
+ QV8Engine *engine = V8ENGINE();
+ QQmlContextData *context = engine->callingContext();
+
+ if (!context || !context->isJSContext)
+ V8THROW_ERROR("Qt.include(): Can only be called from JavaScript files");
+
+ QUrl url(context->resolvedUrl(QUrl(engine->toString(args[0]->ToString()))));
+
+ v8::Local<v8::Function> callbackFunction;
+ if (args.Length() >= 2 && args[1]->IsFunction())
+ callbackFunction = v8::Local<v8::Function>::Cast(args[1]);
+
+ QString localFile = QQmlEnginePrivate::urlToLocalFileOrQrc(url);
+
+ v8::Local<v8::Object> result;
+
+ if (localFile.isEmpty()) {
+
+ QV8Include *i = new QV8Include(url, engine, context,
+ v8::Context::GetCallingQmlGlobal(),
+ callbackFunction);
+ result = v8::Local<v8::Object>::New(i->result());
+
+ } else {
+
+ QFile f(localFile);
+
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QString code = QString::fromUtf8(data);
+ QQmlScript::Parser::extractPragmas(code);
+
+ QQmlContextData *importContext = new QQmlContextData;
+ importContext->isInternal = true;
+ importContext->isJSContext = true;
+ importContext->url = url;
+ importContext->setParent(context, true);
+
+ v8::TryCatch try_catch;
+
+ v8::Local<v8::Script> script = engine->qmlModeCompile(code, url.toString());
+
+ if (!try_catch.HasCaught()) {
+ v8::Local<v8::Object> qmlglobal = v8::Context::GetCallingQmlGlobal();
+ engine->contextWrapper()->addSubContext(qmlglobal, script, importContext);
+ script->Run(qmlglobal);
+ }
+
+ if (try_catch.HasCaught()) {
+ result = resultValue(Exception);
+ result->Set(v8::String::New("exception"), try_catch.Exception());
+ } else {
+ result = resultValue(Ok);
+ }
+
+ } else {
+ result = resultValue(NetworkError);
+ }
+
+ callback(engine, callbackFunction, result);
+ }
+
+ if (result.IsEmpty())
+ return v8::Undefined();
+ else
+ return result;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8include_p.h b/src/qml/qml/v8/qv8include_p.h
new file mode 100644
index 0000000000..f1e57b3eee
--- /dev/null
+++ b/src/qml/qml/v8/qv8include_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8INCLUDE_P_H
+#define QV8INCLUDE_P_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/qobject.h>
+#include <QtCore/qurl.h>
+
+#include <private/qqmlcontext_p.h>
+#include <private/qqmlguard_p.h>
+
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+class QNetworkAccessManager;
+class QNetworkReply;
+class QV8Engine;
+class QV8Include : public QObject
+{
+ Q_OBJECT
+public:
+ enum Status {
+ Ok = 0,
+ Loading = 1,
+ NetworkError = 2,
+ Exception = 3
+ };
+
+ static v8::Handle<v8::Value> include(const v8::Arguments &args);
+
+private slots:
+ void finished();
+
+private:
+ QV8Include(const QUrl &, QV8Engine *, QQmlContextData *,
+ v8::Handle<v8::Object>, v8::Handle<v8::Function>);
+ ~QV8Include();
+
+ v8::Handle<v8::Object> result();
+
+ static v8::Local<v8::Object> resultValue(Status status = Loading);
+ static void callback(QV8Engine *engine, v8::Handle<v8::Function> callback, v8::Handle<v8::Object> status);
+
+ QV8Engine *m_engine;
+ QNetworkAccessManager *m_network;
+ QQmlGuard<QNetworkReply> m_reply;
+
+ QUrl m_url;
+ int m_redirectCount;
+
+ v8::Persistent<v8::Function> m_callbackFunction;
+ v8::Persistent<v8::Object> m_resultObject;
+
+ QQmlGuardedContextData m_context;
+ v8::Persistent<v8::Object> m_qmlglobal;
+};
+
+QT_END_NAMESPACE
+
+#endif // QV8INCLUDE_P_H
+
diff --git a/src/qml/qml/v8/qv8listwrapper.cpp b/src/qml/qml/v8/qv8listwrapper.cpp
new file mode 100644
index 0000000000..d6eab7af34
--- /dev/null
+++ b/src/qml/qml/v8/qv8listwrapper.cpp
@@ -0,0 +1,194 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8listwrapper_p.h"
+#include "qv8engine_p.h"
+#include <private/qqmllist_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8ListResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(ListType);
+public:
+ QV8ListResource(QV8Engine *engine) : QV8ObjectResource(engine) {}
+
+ QQmlGuard<QObject> object;
+ QQmlListProperty<QObject> property;
+ int propertyType;
+};
+
+QV8ListWrapper::QV8ListWrapper()
+: m_engine(0)
+{
+}
+
+QV8ListWrapper::~QV8ListWrapper()
+{
+}
+
+void QV8ListWrapper::init(QV8Engine *engine)
+{
+ m_engine = engine;
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter, 0, 0, Enumerator);
+ ft->InstanceTemplate()->SetIndexedPropertyHandler(IndexedGetter);
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("length"), LengthGetter, 0,
+ v8::Handle<v8::Value>(), v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum));
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+}
+
+void QV8ListWrapper::destroy()
+{
+ qPersistentDispose(m_constructor);
+}
+
+v8::Handle<v8::Value> QV8ListWrapper::newList(QObject *object, int propId, int propType)
+{
+ if (!object || propId == -1)
+ return v8::Null();
+
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ QV8ListResource *r = new QV8ListResource(m_engine);
+ r->object = object;
+ r->propertyType = propType;
+ void *args[] = { &r->property, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, propId, args);
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+v8::Handle<v8::Value> QV8ListWrapper::newList(const QQmlListProperty<QObject> &prop, int propType)
+{
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ QV8ListResource *r = new QV8ListResource(m_engine);
+ r->object = prop.object;
+ r->property = prop;
+ r->propertyType = propType;
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+QVariant QV8ListWrapper::toVariant(v8::Handle<v8::Object> obj)
+{
+ QV8ListResource *resource = v8_resource_cast<QV8ListResource>(obj);
+ if (resource) return toVariant(resource);
+ else return QVariant();
+}
+
+QVariant QV8ListWrapper::toVariant(QV8ObjectResource *r)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::ListType);
+ QV8ListResource *resource = static_cast<QV8ListResource *>(r);
+
+ if (!resource->object)
+ return QVariant();
+
+ return QVariant::fromValue(QQmlListReferencePrivate::init(resource->property, resource->propertyType,
+ m_engine->engine()));
+}
+
+v8::Handle<v8::Value> QV8ListWrapper::Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ Q_UNUSED(info);
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> QV8ListWrapper::Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ Q_UNUSED(info);
+ return value;
+}
+
+v8::Handle<v8::Value> QV8ListWrapper::IndexedGetter(uint32_t index, const v8::AccessorInfo &info)
+{
+ QV8ListResource *resource = v8_resource_cast<QV8ListResource>(info.This());
+
+ if (!resource || resource->object.isNull()) return v8::Undefined();
+
+ quint32 count = resource->property.count?resource->property.count(&resource->property):0;
+ if (index < count && resource->property.at) {
+ return resource->engine->newQObject(resource->property.at(&resource->property, index));
+ } else {
+ return v8::Undefined();
+ }
+}
+
+v8::Handle<v8::Value> QV8ListWrapper::LengthGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+
+ QV8ListResource *resource = v8_resource_cast<QV8ListResource>(info.This());
+
+ if (!resource || resource->object.isNull()) return v8::Undefined();
+
+ quint32 count = resource->property.count?resource->property.count(&resource->property):0;
+
+ return v8::Integer::NewFromUnsigned(count);
+}
+
+v8::Handle<v8::Array> QV8ListWrapper::Enumerator(const v8::AccessorInfo &info)
+{
+ QV8ListResource *resource = v8_resource_cast<QV8ListResource>(info.This());
+
+ if (!resource || resource->object.isNull()) return v8::Array::New();
+
+ quint32 count = resource->property.count?resource->property.count(&resource->property):0;
+
+ v8::Local<v8::Array> rv = v8::Array::New(count);
+
+ for (uint ii = 0; ii < count; ++ii)
+ rv->Set(ii, v8::Number::New(ii));
+
+ return rv;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8listwrapper_p.h b/src/qml/qml/v8/qv8listwrapper_p.h
new file mode 100644
index 0000000000..1e4bab06d5
--- /dev/null
+++ b/src/qml/qml/v8/qv8listwrapper_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8LISTWRAPPER_P_H
+#define QV8LISTWRAPPER_P_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 <QtQml/qqmllist.h>
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+class QV8ObjectResource;
+class QV8ListWrapper
+{
+public:
+ QV8ListWrapper();
+ ~QV8ListWrapper();
+
+ void init(QV8Engine *);
+ void destroy();
+
+ v8::Handle<v8::Value> newList(QObject *, int, int);
+ v8::Handle<v8::Value> newList(const QQmlListProperty<QObject> &, int);
+ QVariant toVariant(v8::Handle<v8::Object>);
+ QVariant toVariant(QV8ObjectResource *);
+
+private:
+ static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> IndexedGetter(uint32_t index,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> LengthGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo &info);
+
+ QV8Engine *m_engine;
+ v8::Persistent<v8::Function> m_constructor;
+};
+
+QT_END_NAMESPACE
+
+#endif // QV8LISTWRAPPER_P_H
+
diff --git a/src/qml/qml/v8/qv8profiler_p.h b/src/qml/qml/v8/qv8profiler_p.h
new file mode 100644
index 0000000000..45df5a17c4
--- /dev/null
+++ b/src/qml/qml/v8/qv8profiler_p.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/v8-profiler.h>
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp
new file mode 100644
index 0000000000..78b2cb719c
--- /dev/null
+++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp
@@ -0,0 +1,2113 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8qobjectwrapper_p.h"
+#include "qv8contextwrapper_p.h"
+#include "qv8engine_p.h"
+
+#include <private/qqmlguard_p.h>
+#include <private/qqmlpropertycache_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qqmlvmemetaobject_p.h>
+#include <private/qqmlbinding_p.h>
+#include <private/qjsvalue_p.h>
+#include <private/qscript_impl_p.h>
+#include <private/qqmlaccessors_p.h>
+#include <private/qqmlexpression_p.h>
+
+#include <QtQml/qjsvalue.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qatomic.h>
+
+Q_DECLARE_METATYPE(QJSValue);
+Q_DECLARE_METATYPE(QQmlV8Handle);
+
+QT_BEGIN_NAMESPACE
+
+#if defined(__GNUC__)
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
+// The code in this file does not violate strict aliasing, but GCC thinks it does
+// so turn off the warnings for us to have a clean build
+# pragma GCC diagnostic ignored "-Wstrict-aliasing"
+# endif
+#endif
+
+#define QOBJECT_TOSTRING_INDEX -2
+#define QOBJECT_DESTROY_INDEX -3
+
+// XXX TODO: Need to review all calls to QQmlEngine *engine() to confirm QObjects work
+// correctly in a worker thread
+
+class QV8QObjectResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(QObjectType);
+
+public:
+ QV8QObjectResource(QV8Engine *engine, QObject *object);
+
+ QQmlGuard<QObject> object;
+};
+
+class QV8QObjectInstance : public QQmlGuard<QObject>
+{
+public:
+ QV8QObjectInstance(QObject *o, QV8QObjectWrapper *w)
+ : QQmlGuard<QObject>(o), wrapper(w)
+ {
+ }
+
+ ~QV8QObjectInstance()
+ {
+ qPersistentDispose(v8object);
+ }
+
+ virtual void objectDestroyed(QObject *o)
+ {
+ if (wrapper)
+ wrapper->m_taintedObjects.remove(o);
+ delete this;
+ }
+
+ v8::Persistent<v8::Object> v8object;
+ QV8QObjectWrapper *wrapper;
+};
+
+class QV8SignalHandlerResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(SignalHandlerType)
+public:
+ QV8SignalHandlerResource(QV8Engine *engine, QObject *object, int index);
+
+ QQmlGuard<QObject> object;
+ int index;
+};
+
+namespace {
+
+template<typename A, typename B, typename C, typename D, typename E>
+class MaxSizeOf5 {
+ template<typename Z, typename X>
+ struct SMax {
+ static const size_t Size = sizeof(Z) > sizeof(X) ? sizeof(Z) : sizeof(X);
+ };
+public:
+ static const size_t Size = SMax<A, SMax<B, SMax<C, SMax<D, E> > > >::Size;
+};
+
+struct CallArgument {
+ inline CallArgument();
+ inline ~CallArgument();
+ inline void *dataPtr();
+
+ inline void initAsType(int type);
+ inline void fromValue(int type, QV8Engine *, v8::Handle<v8::Value>);
+ inline v8::Handle<v8::Value> toValue(QV8Engine *);
+
+private:
+ CallArgument(const CallArgument &);
+
+ inline void cleanup();
+
+ union {
+ float floatValue;
+ double doubleValue;
+ quint32 intValue;
+ bool boolValue;
+ QObject *qobjectPtr;
+
+ char allocData[MaxSizeOf5<QVariant,
+ QString,
+ QList<QObject *>,
+ QJSValue,
+ QQmlV8Handle>::Size];
+ qint64 q_for_alignment;
+ };
+
+ // Pointers to allocData
+ union {
+ QString *qstringPtr;
+ QVariant *qvariantPtr;
+ QList<QObject *> *qlistPtr;
+ QJSValue *qjsValuePtr;
+ QQmlV8Handle *handlePtr;
+ };
+
+ int type;
+};
+}
+
+QV8QObjectResource::QV8QObjectResource(QV8Engine *engine, QObject *object)
+: QV8ObjectResource(engine), object(object)
+{
+}
+
+QV8SignalHandlerResource::QV8SignalHandlerResource(QV8Engine *engine, QObject *object, int index)
+: QV8ObjectResource(engine), object(object), index(index)
+{
+}
+
+static QAtomicInt objectIdCounter(1);
+
+QV8QObjectWrapper::QV8QObjectWrapper()
+: m_engine(0), m_id(objectIdCounter.fetchAndAddOrdered(1))
+{
+}
+
+QV8QObjectWrapper::~QV8QObjectWrapper()
+{
+ for (TaintedHash::Iterator iter = m_taintedObjects.begin();
+ iter != m_taintedObjects.end();
+ ++iter) {
+ (*iter)->wrapper = 0;
+ }
+ m_taintedObjects.clear();
+}
+
+void QV8QObjectWrapper::destroy()
+{
+ qDeleteAll(m_connections);
+ m_connections.clear();
+
+ qPersistentDispose(m_hiddenObject);
+ qPersistentDispose(m_destroySymbol);
+ qPersistentDispose(m_toStringSymbol);
+ qPersistentDispose(m_signalHandlerConstructor);
+ qPersistentDispose(m_methodConstructor);
+ qPersistentDispose(m_constructor);
+}
+
+struct ReadAccessor {
+ static inline void Indirect(QObject *object, const QQmlPropertyData &property,
+ void *output, QQmlNotifier **n)
+ {
+ Q_ASSERT(n == 0);
+ Q_UNUSED(n);
+
+ void *args[] = { output, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, property.coreIndex, args);
+ }
+
+ static inline void Direct(QObject *object, const QQmlPropertyData &property,
+ void *output, QQmlNotifier **n)
+ {
+ Q_ASSERT(n == 0);
+ Q_UNUSED(n);
+
+ void *args[] = { output, 0 };
+ object->qt_metacall(QMetaObject::ReadProperty, property.coreIndex, args);
+ }
+
+ static inline void Accessor(QObject *object, const QQmlPropertyData &property,
+ void *output, QQmlNotifier **n)
+ {
+ Q_ASSERT(property.accessors);
+
+ property.accessors->read(object, property.accessorData, output);
+ if (n) property.accessors->notifier(object, property.accessorData, n);
+ }
+};
+
+static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, int v)
+{ return v8::Integer::New(v); }
+static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, uint v)
+{ return v8::Integer::NewFromUnsigned(v); }
+static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, bool v)
+{ return v8::Boolean::New(v); }
+static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *e, const QString &v)
+{ return e->toString(v); }
+static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, float v)
+{ return v8::Number::New(v); }
+static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, double v)
+{ return v8::Number::New(v); }
+static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *e, QObject *v)
+{ return e->newQObject(v); }
+
+template<typename T, void (*ReadFunction)(QObject *, const QQmlPropertyData &,
+ void *, QQmlNotifier **)>
+static v8::Handle<v8::Value> GenericValueGetter(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ v8::Handle<v8::Object> This = info.This();
+ QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(This);
+
+ QObject *object = resource->object;
+ if (!object) return v8::Undefined();
+
+ QQmlPropertyData *property =
+ (QQmlPropertyData *)v8::External::Unwrap(info.Data());
+
+ QQmlEngine *engine = resource->engine->engine();
+ QQmlEnginePrivate *ep = engine?QQmlEnginePrivate::get(engine):0;
+
+ T value = T();
+
+ if (ep && ep->propertyCapture) {
+ if (ReadFunction == ReadAccessor::Accessor && property->accessors->notifier) {
+ QQmlNotifier *notifier = 0;
+ ReadFunction(object, *property, &value, &notifier);
+ if (notifier) ep->captureProperty(notifier);
+ } else if (!property->isConstant()) {
+ ep->captureProperty(object, property->coreIndex, property->notifyIndex);
+ ReadFunction(object, *property, &value, 0);
+ } else {
+ ReadFunction(object, *property, &value, 0);
+ }
+ } else {
+ ReadFunction(object, *property, &value, 0);
+ }
+
+ return valueToHandle(resource->engine, value);
+}
+
+#define FAST_GETTER_FUNCTION(property, cpptype) \
+ (property->hasAccessors()?((v8::AccessorGetter)GenericValueGetter<cpptype, &ReadAccessor::Accessor>):(property->isDirect()?((v8::AccessorGetter)GenericValueGetter<cpptype, &ReadAccessor::Direct>):((v8::AccessorGetter)GenericValueGetter<cpptype, &ReadAccessor::Indirect>)))
+
+static quint32 toStringHash = -1;
+static quint32 destroyHash = -1;
+
+void QV8QObjectWrapper::init(QV8Engine *engine)
+{
+ m_engine = engine;
+
+ m_toStringSymbol = qPersistentNew<v8::String>(v8::String::NewSymbol("toString"));
+ m_destroySymbol = qPersistentNew<v8::String>(v8::String::NewSymbol("destroy"));
+ m_hiddenObject = qPersistentNew<v8::Object>(v8::Object::New());
+
+ m_toStringString = QHashedV8String(m_toStringSymbol);
+ m_destroyString = QHashedV8String(m_destroySymbol);
+
+ toStringHash = m_toStringString.hash();
+ destroyHash = m_destroyString.hash();
+
+ {
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter, Query, 0, Enumerator);
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ }
+ {
+ v8::ScriptOrigin origin(m_hiddenObject); // Hack to allow us to identify these functions
+#define CREATE_FUNCTION_SOURCE \
+ "(function(method) { "\
+ "return (function(object, data, qmlglobal) { "\
+ "return (function() { "\
+ "return method(object, data, qmlglobal, arguments.length, arguments); "\
+ "});"\
+ "});"\
+ "})"
+ v8::Local<v8::Script> script = v8::Script::New(v8::String::New(CREATE_FUNCTION_SOURCE), &origin, 0,
+ v8::Handle<v8::String>(), v8::Script::NativeMode);
+#undef CREATE_FUNCTION_SOURCE
+ v8::Local<v8::Function> fn = v8::Local<v8::Function>::Cast(script->Run());
+ v8::Handle<v8::Value> invokeFn = v8::FunctionTemplate::New(Invoke)->GetFunction();
+ v8::Handle<v8::Value> args[] = { invokeFn };
+ v8::Local<v8::Function> createFn = v8::Local<v8::Function>::Cast(fn->Call(engine->global(), 1, args));
+ m_methodConstructor = qPersistentNew<v8::Function>(createFn);
+ }
+
+ v8::Local<v8::Function> connect = V8FUNCTION(Connect, engine);
+ v8::Local<v8::Function> disconnect = V8FUNCTION(Disconnect, engine);
+
+ {
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->PrototypeTemplate()->Set(v8::String::New("connect"), connect, v8::DontEnum);
+ ft->PrototypeTemplate()->Set(v8::String::New("disconnect"), disconnect, v8::DontEnum);
+ m_signalHandlerConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ }
+
+ {
+ v8::Local<v8::Object> prototype = engine->global()->Get(v8::String::New("Function"))->ToObject()->Get(v8::String::New("prototype"))->ToObject();
+ prototype->Set(v8::String::New("connect"), connect, v8::DontEnum);
+ prototype->Set(v8::String::New("disconnect"), disconnect, v8::DontEnum);
+ }
+}
+
+bool QV8QObjectWrapper::isQObject(v8::Handle<v8::Object> obj)
+{
+ return v8_resource_cast<QV8QObjectResource>(obj) != 0;
+}
+
+QObject *QV8QObjectWrapper::toQObject(v8::Handle<v8::Object> obj)
+{
+ QV8QObjectResource *r = v8_resource_cast<QV8QObjectResource>(obj);
+ return r?r->object:0;
+}
+
+// r *MUST* be a QV8ObjectResource (r->type() == QV8ObjectResource::QObjectType)
+QObject *QV8QObjectWrapper::toQObject(QV8ObjectResource *r)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::QObjectType);
+ return static_cast<QV8QObjectResource *>(r)->object;
+}
+
+// Load value properties
+template<void (*ReadFunction)(QObject *, const QQmlPropertyData &,
+ void *, QQmlNotifier **)>
+static v8::Handle<v8::Value> LoadProperty(QV8Engine *engine, QObject *object,
+ const QQmlPropertyData &property,
+ QQmlNotifier **notifier)
+{
+ Q_ASSERT(!property.isFunction());
+
+ if (property.isQObject()) {
+ QObject *rv = 0;
+ ReadFunction(object, property, &rv, notifier);
+ return engine->newQObject(rv);
+ } else if (property.isQList()) {
+ return engine->listWrapper()->newList(object, property.coreIndex, property.propType);
+ } else if (property.propType == QMetaType::QReal) {
+ qreal v = 0;
+ ReadFunction(object, property, &v, notifier);
+ return valueToHandle(engine, v);
+ } else if (property.propType == QMetaType::Int || property.isEnum()) {
+ int v = 0;
+ ReadFunction(object, property, &v, notifier);
+ return valueToHandle(engine, v);
+ } else if (property.propType == QMetaType::Bool) {
+ bool v = false;
+ ReadFunction(object, property, &v, notifier);
+ return valueToHandle(engine, v);
+ } else if (property.propType == QMetaType::QString) {
+ QString v;
+ ReadFunction(object, property, &v, notifier);
+ return valueToHandle(engine, v);
+ } else if (property.propType == QMetaType::UInt) {
+ uint v = 0;
+ ReadFunction(object, property, &v, notifier);
+ return valueToHandle(engine, v);
+ } else if (property.propType == QMetaType::Float) {
+ float v = 0;
+ ReadFunction(object, property, &v, notifier);
+ return valueToHandle(engine, v);
+ } else if (property.propType == QMetaType::Double) {
+ double v = 0;
+ ReadFunction(object, property, &v, notifier);
+ return valueToHandle(engine, v);
+ } else if (property.isV8Handle()) {
+ QQmlV8Handle handle;
+ ReadFunction(object, property, &handle, notifier);
+ return handle.toHandle();
+ } else if (property.isQVariant()) {
+ QVariant v;
+ ReadFunction(object, property, &v, notifier);
+ return engine->fromVariant(v);
+ } else if (QQmlValueTypeFactory::isValueType((uint)property.propType)
+ && engine->engine()) {
+ Q_ASSERT(notifier == 0);
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine->engine());
+ QQmlValueType *valueType = ep->valueTypes[property.propType];
+ if (valueType)
+ return engine->newValueType(object, property.coreIndex, valueType);
+ } else {
+ Q_ASSERT(notifier == 0);
+
+ // see if it's a sequence type
+ bool succeeded = false;
+ v8::Handle<v8::Value> retn = engine->newSequence(property.propType, object, property.coreIndex,
+ &succeeded);
+ if (succeeded)
+ return retn;
+ }
+
+ if (property.propType == QVariant::Invalid) {
+ QMetaProperty p = object->metaObject()->property(property.coreIndex);
+ qWarning("QMetaProperty::read: Unable to handle unregistered datatype '%s' for property "
+ "'%s::%s'", p.typeName(), object->metaObject()->className(), p.name());
+ return v8::Undefined();
+ } else {
+ QVariant v(property.propType, (void *)0);
+ ReadFunction(object, property, v.data(), notifier);
+ return engine->fromVariant(v);
+ }
+}
+
+v8::Handle<v8::Value> QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject *object,
+ v8::Handle<v8::Value> *objectHandle,
+ const QHashedV8String &property,
+ QV8QObjectWrapper::RevisionMode revisionMode)
+{
+ // XXX More recent versions of V8 introduced "Callable" objects. It is possible that these
+ // will be a faster way of creating QObject method objects.
+ struct MethodClosure {
+ static v8::Handle<v8::Value> create(QV8Engine *engine, QObject *object,
+ v8::Handle<v8::Value> *objectHandle,
+ int index) {
+ v8::Handle<v8::Value> argv[] = {
+ objectHandle?*objectHandle:engine->newQObject(object),
+ v8::Integer::New(index)
+ };
+ return engine->qobjectWrapper()->m_methodConstructor->Call(engine->global(), 2, argv);
+ }
+ static v8::Handle<v8::Value> createWithGlobal(QV8Engine *engine, QObject *object,
+ v8::Handle<v8::Value> *objectHandle,
+ int index) {
+ v8::Handle<v8::Value> argv[] = {
+ objectHandle?*objectHandle:engine->newQObject(object),
+ v8::Integer::New(index),
+ v8::Context::GetCallingQmlGlobal()
+ };
+ return engine->qobjectWrapper()->m_methodConstructor->Call(engine->global(), 3, argv);
+ }
+ };
+
+ {
+ // Comparing the hash first actually makes a measurable difference here, at least on x86
+ quint32 hash = property.hash();
+ if (hash == toStringHash && engine->qobjectWrapper()->m_toStringString == property) {
+ return MethodClosure::create(engine, object, objectHandle, QOBJECT_TOSTRING_INDEX);
+ } else if (hash == destroyHash && engine->qobjectWrapper()->m_destroyString == property) {
+ return MethodClosure::create(engine, object, objectHandle, QOBJECT_DESTROY_INDEX);
+ }
+ }
+
+ QQmlPropertyData local;
+ QQmlPropertyData *result = 0;
+ {
+ QQmlData *ddata = QQmlData::get(object, false);
+ if (ddata && ddata->propertyCache)
+ result = ddata->propertyCache->property(property);
+ else
+ result = QQmlPropertyCache::property(engine->engine(), object, property, local);
+ }
+
+ if (!result)
+ return v8::Handle<v8::Value>();
+
+ if (revisionMode == QV8QObjectWrapper::CheckRevision && result->hasRevision()) {
+ QQmlData *ddata = QQmlData::get(object);
+ if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result))
+ return v8::Handle<v8::Value>();
+ }
+
+ if (result->isFunction()) {
+ if (result->isVMEFunction()) {
+ return ((QQmlVMEMetaObject *)(object->metaObject()))->vmeMethod(result->coreIndex);
+ } else if (result->isV8Function()) {
+ return MethodClosure::createWithGlobal(engine, object, objectHandle, result->coreIndex);
+ } else if (result->isSignalHandler()) {
+ v8::Local<v8::Object> handler = engine->qobjectWrapper()->m_signalHandlerConstructor->NewInstance();
+ QV8SignalHandlerResource *r = new QV8SignalHandlerResource(engine, object, result->coreIndex);
+ handler->SetExternalResource(r);
+ return handler;
+ } else {
+ return MethodClosure::create(engine, object, objectHandle, result->coreIndex);
+ }
+ }
+
+ QQmlEnginePrivate *ep =
+ engine->engine()?QQmlEnginePrivate::get(engine->engine()):0;
+
+ if (result->hasAccessors()) {
+ QQmlNotifier *n = 0;
+ QQmlNotifier **nptr = 0;
+
+ if (ep && ep->propertyCapture && result->accessors->notifier)
+ nptr = &n;
+
+ v8::Handle<v8::Value> rv = LoadProperty<ReadAccessor::Accessor>(engine, object, *result, nptr);
+
+ if (result->accessors->notifier) {
+ if (n) ep->captureProperty(n);
+ } else {
+ ep->captureProperty(object, result->coreIndex, result->notifyIndex);
+ }
+
+ return rv;
+ }
+
+ if (ep && !result->isConstant()) {
+
+ if (result->coreIndex == 0)
+ ep->captureProperty(QQmlData::get(object, true)->objectNameNotifier());
+ else
+ ep->captureProperty(object, result->coreIndex, result->notifyIndex);
+ }
+
+ if (result->isVMEProperty()) {
+ typedef QQmlVMEMetaObject VMEMO;
+ VMEMO *vmemo = const_cast<VMEMO *>(static_cast<const VMEMO *>(object->metaObject()));
+ return vmemo->vmeProperty(result->coreIndex);
+ } else if (result->isDirect()) {
+ return LoadProperty<ReadAccessor::Direct>(engine, object, *result, 0);
+ } else {
+ return LoadProperty<ReadAccessor::Indirect>(engine, object, *result, 0);
+ }
+}
+
+// Setter for writable properties. Shared between the interceptor and fast property accessor
+static inline void StoreProperty(QV8Engine *engine, QObject *object, QQmlPropertyData *property,
+ v8::Handle<v8::Value> value)
+{
+ QQmlBinding *newBinding = 0;
+
+ if (value->IsFunction()) {
+ QQmlContextData *context = engine->callingContext();
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
+
+ v8::Local<v8::StackTrace> trace =
+ v8::StackTrace::CurrentStackTrace(1, (v8::StackTrace::StackTraceOptions)(v8::StackTrace::kLineNumber |
+ v8::StackTrace::kScriptName));
+ v8::Local<v8::StackFrame> frame = trace->GetFrame(0);
+ int lineNumber = frame->GetLineNumber();
+ int columNumber = frame->GetColumn();
+ QString url = engine->toString(frame->GetScriptName());
+
+ newBinding = new QQmlBinding(&function, object, context);
+ newBinding->setSourceLocation(url, lineNumber, columNumber);
+ newBinding->setTarget(object, *property, context);
+ newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
+ QQmlBinding::RequiresThisObject);
+ }
+
+ QQmlAbstractBinding *oldBinding =
+ QQmlPropertyPrivate::setBinding(object, property->coreIndex, -1, newBinding);
+ if (oldBinding)
+ oldBinding->destroy();
+
+#define PROPERTY_STORE(cpptype, value) \
+ cpptype o = value; \
+ int status = -1; \
+ int flags = 0; \
+ void *argv[] = { &o, 0, &status, &flags }; \
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, property->coreIndex, argv);
+
+
+ if (value->IsNull() && property->isQObject()) {
+ PROPERTY_STORE(QObject*, 0);
+ } else if (value->IsUndefined() && property->isResettable()) {
+ void *a[] = { 0 };
+ QMetaObject::metacall(object, QMetaObject::ResetProperty, property->coreIndex, a);
+ } else if (value->IsUndefined() && property->propType == qMetaTypeId<QVariant>()) {
+ PROPERTY_STORE(QVariant, QVariant());
+ } else if (value->IsUndefined()) {
+ QString error = QLatin1String("Cannot assign [undefined] to ") +
+ QLatin1String(QMetaType::typeName(property->propType));
+ v8::ThrowException(v8::Exception::Error(engine->toString(error)));
+ } else if (value->IsFunction()) {
+ // this is handled by the binding creation above
+ } else if (property->propType == QMetaType::Int && value->IsNumber()) {
+ PROPERTY_STORE(int, qRound(value->ToNumber()->Value()));
+ } else if (property->propType == QMetaType::QReal && value->IsNumber()) {
+ PROPERTY_STORE(qreal, qreal(value->ToNumber()->Value()));
+ } else if (property->propType == QMetaType::Float && value->IsNumber()) {
+ PROPERTY_STORE(float, float(value->ToNumber()->Value()));
+ } else if (property->propType == QMetaType::Double && value->IsNumber()) {
+ PROPERTY_STORE(double, double(value->ToNumber()->Value()));
+ } else if (property->propType == QMetaType::QString && value->IsString()) {
+ PROPERTY_STORE(QString, engine->toString(value->ToString()));
+ } else if (property->isVMEProperty()) {
+ static_cast<QQmlVMEMetaObject *>(const_cast<QMetaObject *>(object->metaObject()))->setVMEProperty(property->coreIndex, value);
+ } else {
+ QVariant v;
+ if (property->isQList())
+ v = engine->toVariant(value, qMetaTypeId<QList<QObject *> >());
+ else
+ v = engine->toVariant(value, property->propType);
+
+ QQmlContextData *context = engine->callingContext();
+ if (!QQmlPropertyPrivate::write(object, *property, v, context)) {
+ const char *valueType = 0;
+ if (v.userType() == QVariant::Invalid) valueType = "null";
+ else valueType = QMetaType::typeName(v.userType());
+
+ QString error = QLatin1String("Cannot assign ") +
+ QLatin1String(valueType) +
+ QLatin1String(" to ") +
+ QLatin1String(QMetaType::typeName(property->propType));
+ v8::ThrowException(v8::Exception::Error(engine->toString(error)));
+ }
+ }
+}
+
+bool QV8QObjectWrapper::SetProperty(QV8Engine *engine, QObject *object, const QHashedV8String &property,
+ v8::Handle<v8::Value> value, QV8QObjectWrapper::RevisionMode revisionMode)
+{
+ if (engine->qobjectWrapper()->m_toStringString == property ||
+ engine->qobjectWrapper()->m_destroyString == property)
+ return true;
+
+ QQmlPropertyData local;
+ QQmlPropertyData *result = 0;
+ result = QQmlPropertyCache::property(engine->engine(), object, property, local);
+
+ if (!result)
+ return false;
+
+ if (revisionMode == QV8QObjectWrapper::CheckRevision && result->hasRevision()) {
+ QQmlData *ddata = QQmlData::get(object);
+ if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result))
+ return false;
+ }
+
+ if (!result->isWritable() && !result->isQList()) {
+ QString error = QLatin1String("Cannot assign to read-only property \"") +
+ engine->toString(property.string()) + QLatin1Char('\"');
+ v8::ThrowException(v8::Exception::Error(engine->toString(error)));
+ return true;
+ }
+
+ StoreProperty(engine, object, result, value);
+
+ return true;
+}
+
+v8::Handle<v8::Value> QV8QObjectWrapper::Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
+
+ if (resource->object.isNull())
+ return v8::Handle<v8::Value>();
+
+ QObject *object = resource->object;
+
+ QHashedV8String propertystring(property);
+
+ QV8Engine *v8engine = resource->engine;
+ v8::Handle<v8::Value> This = info.This();
+ v8::Handle<v8::Value> result = GetProperty(v8engine, object, &This, propertystring,
+ QV8QObjectWrapper::IgnoreRevision);
+ if (!result.IsEmpty())
+ return result;
+
+ if (QV8Engine::startsWithUpper(property)) {
+ // Check for attached properties
+ QQmlContextData *context = v8engine->callingContext();
+
+ if (context && context->imports) {
+ QQmlTypeNameCache::Result r = context->imports->query(propertystring);
+
+ if (r.isValid()) {
+ if (r.scriptIndex != -1) {
+ return v8::Undefined();
+ } else if (r.type) {
+ return v8engine->typeWrapper()->newObject(object, r.type, QV8TypeWrapper::ExcludeEnums);
+ } else if (r.importNamespace) {
+ return v8engine->typeWrapper()->newObject(object, context->imports, r.importNamespace,
+ QV8TypeWrapper::ExcludeEnums);
+ }
+ Q_ASSERT(!"Unreachable");
+ }
+ }
+ }
+
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> QV8QObjectWrapper::Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info)
+{
+ QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
+
+ if (resource->object.isNull())
+ return value;
+
+ QObject *object = resource->object;
+
+ QHashedV8String propertystring(property);
+
+ QV8Engine *v8engine = resource->engine;
+ bool result = SetProperty(v8engine, object, propertystring, value, QV8QObjectWrapper::IgnoreRevision);
+
+ if (!result) {
+ QString error = QLatin1String("Cannot assign to non-existent property \"") +
+ v8engine->toString(property) + QLatin1Char('\"');
+ v8::ThrowException(v8::Exception::Error(v8engine->toString(error)));
+ return value;
+ }
+
+ return value;
+}
+
+v8::Handle<v8::Integer> QV8QObjectWrapper::Query(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
+
+ if (resource->object.isNull())
+ return v8::Handle<v8::Integer>();
+
+ QV8Engine *engine = resource->engine;
+ QObject *object = resource->object;
+
+ QHashedV8String propertystring(property);
+
+ QQmlPropertyData local;
+ QQmlPropertyData *result = 0;
+ result = QQmlPropertyCache::property(engine->engine(), object, propertystring, local);
+
+ if (!result)
+ return v8::Handle<v8::Integer>();
+ else if (!result->isWritable() && !result->isQList())
+ return v8::Integer::New(v8::ReadOnly | v8::DontDelete);
+ else
+ return v8::Integer::New(v8::DontDelete);
+}
+
+v8::Handle<v8::Array> QV8QObjectWrapper::Enumerator(const v8::AccessorInfo &info)
+{
+ QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
+
+ if (resource->object.isNull())
+ return v8::Array::New();
+
+ QObject *object = resource->object;
+
+ QStringList result;
+
+ QQmlEnginePrivate *ep = resource->engine->engine()
+ ? QQmlEnginePrivate::get(resource->engine->engine())
+ : 0;
+
+ QQmlPropertyCache *cache = 0;
+ QQmlData *ddata = QQmlData::get(object);
+ if (ddata)
+ cache = ddata->propertyCache;
+
+ if (!cache) {
+ cache = ep ? ep->cache(object) : 0;
+ if (cache) {
+ if (ddata) { cache->addref(); ddata->propertyCache = cache; }
+ } else {
+ // Not cachable - fall back to QMetaObject (eg. dynamic meta object)
+ const QMetaObject *mo = object->metaObject();
+ int pc = mo->propertyCount();
+ int po = mo->propertyOffset();
+ for (int i=po; i<pc; ++i)
+ result << QString::fromUtf8(mo->property(i).name());
+ }
+ } else {
+ result = cache->propertyNames();
+ }
+
+ v8::Local<v8::Array> rv = v8::Array::New(result.count());
+
+ for (int ii = 0; ii < result.count(); ++ii)
+ rv->Set(ii, resource->engine->toString(result.at(ii)));
+
+ return rv;
+}
+
+static void FastValueSetter(v8::Local<v8::String>, v8::Local<v8::Value> value,
+ const v8::AccessorInfo& info)
+{
+ QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
+
+ if (resource->object.isNull())
+ return;
+
+ QObject *object = resource->object;
+
+ QQmlPropertyData *property =
+ (QQmlPropertyData *)v8::External::Unwrap(info.Data());
+
+ int index = property->coreIndex;
+
+ QQmlData *ddata = QQmlData::get(object, false);
+ Q_ASSERT(ddata);
+ Q_ASSERT(ddata->propertyCache);
+
+ QQmlPropertyData *pdata = ddata->propertyCache->property(index);
+ Q_ASSERT(pdata);
+
+ Q_ASSERT(pdata->isWritable() || pdata->isQList());
+
+ StoreProperty(resource->engine, object, pdata, value);
+}
+
+static void FastValueSetterReadOnly(v8::Local<v8::String> property, v8::Local<v8::Value>,
+ const v8::AccessorInfo& info)
+{
+ QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This());
+
+ if (resource->object.isNull())
+ return;
+
+ QV8Engine *v8engine = resource->engine;
+
+ QString error = QLatin1String("Cannot assign to read-only property \"") +
+ v8engine->toString(property) + QLatin1Char('\"');
+ v8::ThrowException(v8::Exception::Error(v8engine->toString(error)));
+}
+
+static void WeakQObjectReferenceCallback(v8::Persistent<v8::Value> handle, void *)
+{
+ Q_ASSERT(handle->IsObject());
+
+ QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(handle->ToObject());
+
+ Q_ASSERT(resource);
+
+ QObject *object = resource->object;
+ if (object) {
+ QQmlData *ddata = QQmlData::get(object, false);
+ if (ddata) {
+ ddata->v8object.Clear();
+ if (!object->parent() && !ddata->indestructible)
+ object->deleteLater();
+ }
+ }
+
+ qPersistentDispose(handle);
+}
+
+static void WeakQObjectInstanceCallback(v8::Persistent<v8::Value> handle, void *data)
+{
+ QV8QObjectInstance *instance = (QV8QObjectInstance *)data;
+ instance->v8object.Clear();
+ qPersistentDispose(handle);
+}
+
+v8::Local<v8::Object> QQmlPropertyCache::newQObject(QObject *object, QV8Engine *engine)
+{
+ Q_ASSERT(object);
+ Q_ASSERT(this->engine);
+
+ Q_ASSERT(QQmlData::get(object, false));
+ Q_ASSERT(QQmlData::get(object, false)->propertyCache == this);
+
+ // Setup constructor
+ if (constructor.IsEmpty()) {
+ v8::Local<v8::FunctionTemplate> ft;
+
+ QString toString = QLatin1String("toString");
+ QString destroy = QLatin1String("destroy");
+
+ // As we use hash linking, it is possible that iterating over the values can give duplicates.
+ // To combat this, we must unique'ify our properties.
+ StringCache uniqueHash;
+ if (stringCache.isLinked())
+ uniqueHash.reserve(stringCache.count());
+
+ // XXX TODO: Enables fast property accessors. These more than double the property access
+ // performance, but the cost of setting up this structure hasn't been measured so
+ // its not guarenteed that this is a win overall. We need to try and measure the cost.
+ for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter) {
+ if (stringCache.isLinked()) {
+ if (uniqueHash.contains(iter))
+ continue;
+ uniqueHash.insert(iter);
+ }
+
+ QQmlPropertyData *property = *iter;
+ if (property->notFullyResolved()) resolve(property);
+
+ if (property->isFunction())
+ continue;
+
+ v8::AccessorGetter fastgetter = 0;
+ v8::AccessorSetter fastsetter = FastValueSetter;
+ if (!property->isWritable())
+ fastsetter = FastValueSetterReadOnly;
+
+ if (property->isQObject())
+ fastgetter = FAST_GETTER_FUNCTION(property, QObject*);
+ else if (property->propType == QMetaType::Int || property->isEnum())
+ fastgetter = FAST_GETTER_FUNCTION(property, int);
+ else if (property->propType == QMetaType::Bool)
+ fastgetter = FAST_GETTER_FUNCTION(property, bool);
+ else if (property->propType == QMetaType::QString)
+ fastgetter = FAST_GETTER_FUNCTION(property, QString);
+ else if (property->propType == QMetaType::UInt)
+ fastgetter = FAST_GETTER_FUNCTION(property, uint);
+ else if (property->propType == QMetaType::Float)
+ fastgetter = FAST_GETTER_FUNCTION(property, float);
+ else if (property->propType == QMetaType::Double)
+ fastgetter = FAST_GETTER_FUNCTION(property, double);
+
+ if (fastgetter) {
+ QString name = iter.key();
+ if (name == toString || name == destroy)
+ continue;
+
+ if (ft.IsEmpty()) {
+ ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(QV8QObjectWrapper::Getter,
+ QV8QObjectWrapper::Setter,
+ QV8QObjectWrapper::Query,
+ 0,
+ QV8QObjectWrapper::Enumerator);
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ }
+
+ // We wrap the raw QQmlPropertyData pointer here. This is safe as the
+ // pointer will remain valid at least as long as the lifetime of any QObject's of
+ // this type and the property accessor checks if the object is 0 (deleted) before
+ // dereferencing the pointer.
+ ft->InstanceTemplate()->SetAccessor(engine->toString(name), fastgetter, fastsetter,
+ v8::External::Wrap(property));
+ }
+ }
+
+ if (ft.IsEmpty()) {
+ constructor = qPersistentNew<v8::Function>(engine->qobjectWrapper()->m_constructor);
+ } else {
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(QV8QObjectWrapper::Getter,
+ QV8QObjectWrapper::Setter,
+ QV8QObjectWrapper::Query,
+ 0,
+ QV8QObjectWrapper::Enumerator);
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ }
+
+ QQmlCleanup::addToEngine(this->engine);
+ }
+
+ v8::Local<v8::Object> result = constructor->NewInstance();
+ QV8QObjectResource *r = new QV8QObjectResource(engine, object);
+ result->SetExternalResource(r);
+ return result;
+}
+
+v8::Local<v8::Object> QV8QObjectWrapper::newQObject(QObject *object, QQmlData *ddata, QV8Engine *engine)
+{
+ v8::Local<v8::Object> rv;
+
+ if (!ddata->propertyCache && engine->engine()) {
+ ddata->propertyCache = QQmlEnginePrivate::get(engine->engine())->cache(object);
+ if (ddata->propertyCache) ddata->propertyCache->addref();
+ }
+
+ if (ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine->engine()) {
+ rv = ddata->propertyCache->newQObject(object, engine);
+ } else {
+ // XXX NewInstance() should be optimized
+ rv = m_constructor->NewInstance();
+ QV8QObjectResource *r = new QV8QObjectResource(engine, object);
+ rv->SetExternalResource(r);
+ }
+
+ return rv;
+}
+
+/*
+As V8 doesn't support an equality callback, for QObject's we have to return exactly the same
+V8 handle for subsequent calls to newQObject for the same QObject. To do this we have a two
+pronged strategy:
+ 1. If there is no current outstanding V8 handle to the QObject, we create one and store a
+ persistent handle in QQmlData::v8object. We mark the QV8QObjectWrapper that
+ "owns" this handle by setting the QQmlData::v8objectid to the id of this
+ QV8QObjectWrapper.
+ 2. If another QV8QObjectWrapper has create the handle in QQmlData::v8object we create
+ an entry in the m_taintedObject hash where we store the handle and mark the object as
+ "tainted" in the QQmlData::hasTaintedV8Object flag.
+We have to mark the object as tainted to ensure that we search our m_taintedObject hash even
+in the case that the original QV8QObjectWrapper owner of QQmlData::v8object has
+released the handle.
+*/
+v8::Handle<v8::Value> QV8QObjectWrapper::newQObject(QObject *object)
+{
+ if (!object)
+ return v8::Null();
+
+ if (QObjectPrivate::get(object)->wasDeleted)
+ return v8::Undefined();
+
+ QQmlData *ddata = QQmlData::get(object, true);
+
+ if (!ddata)
+ return v8::Undefined();
+
+ if (ddata->v8objectid == m_id && !ddata->v8object.IsEmpty()) {
+ // We own the v8object
+ return v8::Local<v8::Object>::New(ddata->v8object);
+ } else if (ddata->v8object.IsEmpty() &&
+ (ddata->v8objectid == m_id || // We own the QObject
+ ddata->v8objectid == 0 || // No one owns the QObject
+ !ddata->hasTaintedV8Object)) { // Someone else has used the QObject, but it isn't tainted
+
+ v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
+ ddata->v8object = qPersistentNew<v8::Object>(rv);
+ ddata->v8object.MakeWeak(0, WeakQObjectReferenceCallback);
+ ddata->v8objectid = m_id;
+ return rv;
+
+ } else {
+ // If this object is tainted, we have to check to see if it is in our
+ // tainted object list
+ TaintedHash::Iterator iter =
+ ddata->hasTaintedV8Object?m_taintedObjects.find(object):m_taintedObjects.end();
+ bool found = iter != m_taintedObjects.end();
+
+ // If our tainted handle doesn't exist or has been collected, and there isn't
+ // a handle in the ddata, we can assume ownership of the ddata->v8object
+ if ((!found || (*iter)->v8object.IsEmpty()) && ddata->v8object.IsEmpty()) {
+ v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
+ ddata->v8object = qPersistentNew<v8::Object>(rv);
+ ddata->v8object.MakeWeak(0, WeakQObjectReferenceCallback);
+ ddata->v8objectid = m_id;
+
+ if (found) {
+ delete (*iter);
+ m_taintedObjects.erase(iter);
+ }
+
+ return rv;
+ } else if (!found) {
+ QV8QObjectInstance *instance = new QV8QObjectInstance(object, this);
+ iter = m_taintedObjects.insert(object, instance);
+ ddata->hasTaintedV8Object = true;
+ }
+
+ if ((*iter)->v8object.IsEmpty()) {
+ v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
+ (*iter)->v8object = qPersistentNew<v8::Object>(rv);
+ (*iter)->v8object.MakeWeak((*iter), WeakQObjectInstanceCallback);
+ }
+
+ return v8::Local<v8::Object>::New((*iter)->v8object);
+ }
+}
+
+QPair<QObject *, int> QV8QObjectWrapper::ExtractQtSignal(QV8Engine *engine, v8::Handle<v8::Object> object)
+{
+ if (object->IsFunction())
+ return ExtractQtMethod(engine, v8::Handle<v8::Function>::Cast(object));
+
+ if (QV8SignalHandlerResource *resource = v8_resource_cast<QV8SignalHandlerResource>(object))
+ return qMakePair(resource->object.data(), resource->index);
+
+ return qMakePair((QObject *)0, -1);
+}
+
+QPair<QObject *, int> QV8QObjectWrapper::ExtractQtMethod(QV8Engine *engine, v8::Handle<v8::Function> function)
+{
+ v8::ScriptOrigin origin = function->GetScriptOrigin();
+ if (origin.ResourceName()->StrictEquals(engine->qobjectWrapper()->m_hiddenObject)) {
+
+ // This is one of our special QObject method wrappers
+ v8::Handle<v8::Value> args[] = { engine->qobjectWrapper()->m_hiddenObject };
+ v8::Local<v8::Value> data = function->Call(engine->global(), 1, args);
+
+ if (data->IsArray()) {
+ v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(data);
+ return qMakePair(engine->toQObject(array->Get(0)), array->Get(1)->Int32Value());
+ }
+
+ // In theory this can't fall through, but I suppose V8 might run out of memory or something
+ }
+
+ return qMakePair((QObject *)0, -1);
+}
+
+class QV8QObjectConnectionList : public QObject, public QQmlGuard<QObject>
+{
+public:
+ QV8QObjectConnectionList(QObject *object, QV8Engine *engine);
+ ~QV8QObjectConnectionList();
+
+ struct Connection {
+ Connection()
+ : needsDestroy(false) {}
+ Connection(const Connection &other)
+ : thisObject(other.thisObject), function(other.function), needsDestroy(false) {}
+ Connection &operator=(const Connection &other) {
+ thisObject = other.thisObject;
+ function = other.function;
+ needsDestroy = other.needsDestroy;
+ return *this;
+ }
+
+ v8::Persistent<v8::Object> thisObject;
+ v8::Persistent<v8::Function> function;
+
+ void dispose() {
+ qPersistentDispose(thisObject);
+ qPersistentDispose(function);
+ }
+
+ bool needsDestroy;
+ };
+
+ struct ConnectionList : public QList<Connection> {
+ ConnectionList() : connectionsInUse(0), connectionsNeedClean(false) {}
+ int connectionsInUse;
+ bool connectionsNeedClean;
+ };
+
+ QV8Engine *engine;
+
+ typedef QHash<int, ConnectionList> SlotHash;
+ SlotHash slotHash;
+ bool needsDestroy;
+ int inUse;
+
+ virtual void objectDestroyed(QObject *);
+ virtual int qt_metacall(QMetaObject::Call, int, void **);
+};
+
+QV8QObjectConnectionList::QV8QObjectConnectionList(QObject *object, QV8Engine *engine)
+: QQmlGuard<QObject>(object), engine(engine), needsDestroy(false), inUse(0)
+{
+}
+
+QV8QObjectConnectionList::~QV8QObjectConnectionList()
+{
+ for (SlotHash::Iterator iter = slotHash.begin(); iter != slotHash.end(); ++iter) {
+ QList<Connection> &connections = *iter;
+ for (int ii = 0; ii < connections.count(); ++ii) {
+ qPersistentDispose(connections[ii].thisObject);
+ qPersistentDispose(connections[ii].function);
+ }
+ }
+ slotHash.clear();
+}
+
+void QV8QObjectConnectionList::objectDestroyed(QObject *object)
+{
+ engine->qobjectWrapper()->m_connections.remove(object);
+
+ if (inUse)
+ needsDestroy = true;
+ else
+ delete this;
+}
+
+int QV8QObjectConnectionList::qt_metacall(QMetaObject::Call method, int index, void **metaArgs)
+{
+ if (method == QMetaObject::InvokeMetaMethod) {
+ SlotHash::Iterator iter = slotHash.find(index);
+ if (iter == slotHash.end())
+ return -1;
+ ConnectionList &connectionList = *iter;
+ if (connectionList.isEmpty())
+ return -1;
+
+ inUse++;
+
+ connectionList.connectionsInUse++;
+
+ QList<Connection> connections = connectionList;
+
+ QVarLengthArray<int, 9> dummy;
+ int *argsTypes = QQmlPropertyCache::methodParameterTypes(data(), index, dummy, 0);
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+
+ int argCount = argsTypes?argsTypes[0]:0;
+ QVarLengthArray<v8::Handle<v8::Value>, 9> args(argCount);
+
+ for (int ii = 0; ii < argCount; ++ii) {
+ int type = argsTypes[ii + 1];
+ if (type == qMetaTypeId<QVariant>()) {
+ args[ii] = engine->fromVariant(*((QVariant *)metaArgs[ii + 1]));
+ } else {
+ args[ii] = engine->fromVariant(QVariant(type, metaArgs[ii + 1]));
+ }
+ }
+
+ for (int ii = 0; ii < connections.count(); ++ii) {
+ Connection &connection = connections[ii];
+ if (connection.needsDestroy)
+ continue;
+
+ v8::TryCatch try_catch;
+ if (connection.thisObject.IsEmpty()) {
+ connection.function->Call(engine->global(), argCount, args.data());
+ } else {
+ connection.function->Call(connection.thisObject, argCount, args.data());
+ }
+
+ if (try_catch.HasCaught()) {
+ QQmlError error;
+ error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(engine->toString(connection.function->GetName())));
+ v8::Local<v8::Message> message = try_catch.Message();
+ if (!message.IsEmpty())
+ QQmlExpressionPrivate::exceptionToError(message, error);
+ QQmlEnginePrivate::get(engine->engine())->warning(error);
+ }
+ }
+
+ connectionList.connectionsInUse--;
+ if (connectionList.connectionsInUse == 0 && connectionList.connectionsNeedClean) {
+ for (QList<Connection>::Iterator iter = connectionList.begin();
+ iter != connectionList.end(); ) {
+ if (iter->needsDestroy) {
+ iter->dispose();
+ iter = connectionList.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+ }
+
+ inUse--;
+ if (inUse == 0 && needsDestroy)
+ delete this;
+ }
+
+ return -1;
+}
+
+v8::Handle<v8::Value> QV8QObjectWrapper::Connect(const v8::Arguments &args)
+{
+ if (args.Length() == 0)
+ V8THROW_ERROR("Function.prototype.connect: no arguments given");
+
+ QV8Engine *engine = V8ENGINE();
+
+ QPair<QObject *, int> signalInfo = ExtractQtSignal(engine, args.This());
+ QObject *signalObject = signalInfo.first;
+ int signalIndex = signalInfo.second;
+
+ if (signalIndex == -1)
+ V8THROW_ERROR("Function.prototype.connect: this object is not a signal");
+
+ if (!signalObject)
+ V8THROW_ERROR("Function.prototype.connect: cannot connect to deleted QObject");
+
+ if (signalIndex < 0 || signalObject->metaObject()->method(signalIndex).methodType() != QMetaMethod::Signal)
+ V8THROW_ERROR("Function.prototype.connect: this object is not a signal");
+
+ v8::Local<v8::Value> functionValue;
+ v8::Local<v8::Value> functionThisValue;
+
+ if (args.Length() == 1) {
+ functionValue = args[0];
+ } else {
+ functionThisValue = args[0];
+ functionValue = args[1];
+ }
+
+ if (!functionValue->IsFunction())
+ V8THROW_ERROR("Function.prototype.connect: target is not a function");
+
+ if (!functionThisValue.IsEmpty() && !functionThisValue->IsObject())
+ V8THROW_ERROR("Function.prototype.connect: target this is not an object");
+
+ QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
+ QHash<QObject *, QV8QObjectConnectionList *> &connections = qobjectWrapper->m_connections;
+ QHash<QObject *, QV8QObjectConnectionList *>::Iterator iter = connections.find(signalObject);
+ if (iter == connections.end())
+ iter = connections.insert(signalObject, new QV8QObjectConnectionList(signalObject, engine));
+
+ QV8QObjectConnectionList *connectionList = *iter;
+ QV8QObjectConnectionList::SlotHash::Iterator slotIter = connectionList->slotHash.find(signalIndex);
+ if (slotIter == connectionList->slotHash.end()) {
+ slotIter = connectionList->slotHash.insert(signalIndex, QV8QObjectConnectionList::ConnectionList());
+ QMetaObject::connect(signalObject, signalIndex, connectionList, signalIndex);
+ }
+
+ QV8QObjectConnectionList::Connection connection;
+ if (!functionThisValue.IsEmpty())
+ connection.thisObject = qPersistentNew<v8::Object>(functionThisValue->ToObject());
+ connection.function = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(functionValue));
+
+ slotIter->append(connection);
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> QV8QObjectWrapper::Disconnect(const v8::Arguments &args)
+{
+ if (args.Length() == 0)
+ V8THROW_ERROR("Function.prototype.disconnect: no arguments given");
+
+ QV8Engine *engine = V8ENGINE();
+
+ QPair<QObject *, int> signalInfo = ExtractQtSignal(engine, args.This());
+ QObject *signalObject = signalInfo.first;
+ int signalIndex = signalInfo.second;
+
+ if (signalIndex == -1)
+ V8THROW_ERROR("Function.prototype.disconnect: this object is not a signal");
+
+ if (!signalObject)
+ V8THROW_ERROR("Function.prototype.disconnect: cannot disconnect from deleted QObject");
+
+ if (signalIndex < 0 || signalObject->metaObject()->method(signalIndex).methodType() != QMetaMethod::Signal)
+ V8THROW_ERROR("Function.prototype.disconnect: this object is not a signal");
+
+ v8::Local<v8::Value> functionValue;
+ v8::Local<v8::Value> functionThisValue;
+
+ if (args.Length() == 1) {
+ functionValue = args[0];
+ } else {
+ functionThisValue = args[0];
+ functionValue = args[1];
+ }
+
+ if (!functionValue->IsFunction())
+ V8THROW_ERROR("Function.prototype.disconnect: target is not a function");
+
+ if (!functionThisValue.IsEmpty() && !functionThisValue->IsObject())
+ V8THROW_ERROR("Function.prototype.disconnect: target this is not an object");
+
+ QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper();
+ QHash<QObject *, QV8QObjectConnectionList *> &connectionsList = qobjectWrapper->m_connections;
+ QHash<QObject *, QV8QObjectConnectionList *>::Iterator iter = connectionsList.find(signalObject);
+ if (iter == connectionsList.end())
+ return v8::Undefined(); // Nothing to disconnect from
+
+ QV8QObjectConnectionList *connectionList = *iter;
+ QV8QObjectConnectionList::SlotHash::Iterator slotIter = connectionList->slotHash.find(signalIndex);
+ if (slotIter == connectionList->slotHash.end())
+ return v8::Undefined(); // Nothing to disconnect from
+
+ QV8QObjectConnectionList::ConnectionList &connections = *slotIter;
+
+ v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionValue);
+ QPair<QObject *, int> functionData = ExtractQtMethod(engine, function);
+
+ if (functionData.second != -1) {
+ // This is a QObject function wrapper
+ for (int ii = 0; ii < connections.count(); ++ii) {
+ QV8QObjectConnectionList::Connection &connection = connections[ii];
+
+ if (connection.thisObject.IsEmpty() == functionThisValue.IsEmpty() &&
+ (connection.thisObject.IsEmpty() || connection.thisObject->StrictEquals(functionThisValue))) {
+
+ QPair<QObject *, int> connectedFunctionData = ExtractQtMethod(engine, connection.function);
+ if (connectedFunctionData == functionData) {
+ // Match!
+ if (connections.connectionsInUse) {
+ connection.needsDestroy = true;
+ connections.connectionsNeedClean = true;
+ } else {
+ connection.dispose();
+ connections.removeAt(ii);
+ }
+ return v8::Undefined();
+ }
+ }
+ }
+
+ } else {
+ // This is a normal JS function
+ for (int ii = 0; ii < connections.count(); ++ii) {
+ QV8QObjectConnectionList::Connection &connection = connections[ii];
+ if (connection.function->StrictEquals(function) &&
+ connection.thisObject.IsEmpty() == functionThisValue.IsEmpty() &&
+ (connection.thisObject.IsEmpty() || connection.thisObject->StrictEquals(functionThisValue))) {
+ // Match!
+ if (connections.connectionsInUse) {
+ connection.needsDestroy = true;
+ connections.connectionsNeedClean = true;
+ } else {
+ connection.dispose();
+ connections.removeAt(ii);
+ }
+ return v8::Undefined();
+ }
+ }
+ }
+
+ return v8::Undefined();
+}
+
+/*!
+ \fn v8::Handle<v8::Value> QV8QObjectWrapper::getProperty(QObject *object, const QHashedV8String &property, QV8QObjectWrapper::RevisionMode revisionMode)
+
+ Get the \a property of \a object. Returns an empty handle if the property doesn't exist.
+
+ Only searches for real properties of \a object (including methods), not attached properties etc.
+*/
+
+/*
+ \fn bool QV8QObjectWrapper::setProperty(QObject *object, const QHashedV8String &property, v8::Handle<v8::Value> value, RevisionMode revisionMode)
+
+ Set the \a property of \a object to \a value.
+
+ Returns true if the property was "set" - even if this results in an exception being thrown -
+ and false if the object has no such property.
+
+ Only searches for real properties of \a object (including methods), not attached properties etc.
+*/
+
+namespace {
+struct CallArgs
+{
+ CallArgs(int length, v8::Handle<v8::Object> *args) : _length(length), _args(args) {}
+ int Length() const { return _length; }
+ v8::Local<v8::Value> operator[](int idx) { return (*_args)->Get(idx); }
+
+private:
+ int _length;
+ v8::Handle<v8::Object> *_args;
+};
+}
+
+static v8::Handle<v8::Value> CallMethod(QObject *object, int index, int returnType, int argCount,
+ int *argTypes, QV8Engine *engine, CallArgs &callArgs)
+{
+ if (argCount > 0) {
+
+ QVarLengthArray<CallArgument, 9> args(argCount + 1);
+ args[0].initAsType(returnType);
+
+ for (int ii = 0; ii < argCount; ++ii)
+ args[ii + 1].fromValue(argTypes[ii], engine, callArgs[ii]);
+
+ QVarLengthArray<void *, 9> argData(args.count());
+ for (int ii = 0; ii < args.count(); ++ii)
+ argData[ii] = args[ii].dataPtr();
+
+ QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, argData.data());
+
+ return args[0].toValue(engine);
+
+ } else if (returnType != 0) {
+
+ CallArgument arg;
+ arg.initAsType(returnType);
+
+ void *args[] = { arg.dataPtr() };
+
+ QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, args);
+
+ return arg.toValue(engine);
+
+ } else {
+
+ void *args[] = { 0 };
+ QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, args);
+ return v8::Undefined();
+
+ }
+}
+
+/*!
+ Returns the match score for converting \a actual to be of type \a conversionType. A
+ zero score means "perfect match" whereas a higher score is worse.
+
+ The conversion table is copied out of the QtScript callQtMethod() function.
+*/
+static int MatchScore(v8::Handle<v8::Value> actual, int conversionType)
+{
+ if (actual->IsNumber()) {
+ switch (conversionType) {
+ case QMetaType::Double:
+ return 0;
+ case QMetaType::Float:
+ return 1;
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
+ return 2;
+ case QMetaType::Long:
+ case QMetaType::ULong:
+ return 3;
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ return 4;
+ case QMetaType::Short:
+ case QMetaType::UShort:
+ return 5;
+ break;
+ case QMetaType::Char:
+ case QMetaType::UChar:
+ return 6;
+ default:
+ return 10;
+ }
+ } else if (actual->IsString()) {
+ switch (conversionType) {
+ case QMetaType::QString:
+ return 0;
+ default:
+ return 10;
+ }
+ } else if (actual->IsBoolean()) {
+ switch (conversionType) {
+ case QMetaType::Bool:
+ return 0;
+ default:
+ return 10;
+ }
+ } else if (actual->IsDate()) {
+ switch (conversionType) {
+ case QMetaType::QDateTime:
+ return 0;
+ case QMetaType::QDate:
+ return 1;
+ case QMetaType::QTime:
+ return 2;
+ default:
+ return 10;
+ }
+ } else if (actual->IsRegExp()) {
+ switch (conversionType) {
+ case QMetaType::QRegExp:
+ return 0;
+ default:
+ return 10;
+ }
+ } else if (actual->IsArray()) {
+ switch (conversionType) {
+ case QMetaType::QStringList:
+ case QMetaType::QVariantList:
+ return 5;
+ default:
+ return 10;
+ }
+ } else if (actual->IsNull()) {
+ switch (conversionType) {
+ case QMetaType::VoidStar:
+ case QMetaType::QObjectStar:
+ return 0;
+ default: {
+ const char *typeName = QMetaType::typeName(conversionType);
+ if (typeName && typeName[strlen(typeName) - 1] == '*')
+ return 0;
+ else
+ return 10;
+ }
+ }
+ } else if (actual->IsObject()) {
+ v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(actual);
+
+ QV8ObjectResource *r = static_cast<QV8ObjectResource *>(obj->GetExternalResource());
+ if (r && r->resourceType() == QV8ObjectResource::QObjectType) {
+ switch (conversionType) {
+ case QMetaType::QObjectStar:
+ return 0;
+ default:
+ return 10;
+ }
+ } else if (r && r->resourceType() == QV8ObjectResource::VariantType) {
+ if (conversionType == qMetaTypeId<QVariant>())
+ return 0;
+ else if (r->engine->toVariant(actual, -1).userType() == conversionType)
+ return 0;
+ else
+ return 10;
+ } else {
+ return 10;
+ }
+
+ } else {
+ return 10;
+ }
+}
+
+static inline int QMetaObject_methods(const QMetaObject *metaObject)
+{
+ struct Private
+ {
+ int revision;
+ int className;
+ int classInfoCount, classInfoData;
+ int methodCount, methodData;
+ };
+
+ return reinterpret_cast<const Private *>(metaObject->d.data)->methodCount;
+}
+
+static QByteArray QMetaMethod_name(const QMetaMethod &m)
+{
+ QByteArray sig = m.signature();
+ int paren = sig.indexOf('(');
+ if (paren == -1)
+ return sig;
+ else
+ return sig.left(paren);
+}
+
+/*!
+Returns the next related method, if one, or 0.
+*/
+static const QQmlPropertyData * RelatedMethod(QObject *object,
+ const QQmlPropertyData *current,
+ QQmlPropertyData &dummy)
+{
+ QQmlPropertyCache *cache = QQmlData::get(object)->propertyCache;
+ if (!current->isOverload())
+ return 0;
+
+ Q_ASSERT(!current->overrideIndexIsProperty);
+
+ if (cache) {
+ return cache->method(current->overrideIndex);
+ } else {
+ const QMetaObject *mo = object->metaObject();
+ int methodOffset = mo->methodCount() - QMetaObject_methods(mo);
+
+ while (methodOffset > current->overrideIndex) {
+ mo = mo->superClass();
+ methodOffset -= QMetaObject_methods(mo);
+ }
+
+ QMetaMethod method = mo->method(current->overrideIndex);
+ dummy.load(method);
+
+ // Look for overloaded methods
+ QByteArray methodName = QMetaMethod_name(method);
+ for (int ii = current->overrideIndex - 1; ii >= methodOffset; --ii) {
+ if (methodName == QMetaMethod_name(mo->method(ii))) {
+ dummy.setFlags(dummy.getFlags() | QQmlPropertyData::IsOverload);
+ dummy.overrideIndexIsProperty = 0;
+ dummy.overrideIndex = ii;
+ return &dummy;
+ }
+ }
+
+ return &dummy;
+ }
+}
+
+static v8::Handle<v8::Value> CallPrecise(QObject *object, const QQmlPropertyData &data,
+ QV8Engine *engine, CallArgs &callArgs)
+{
+ if (data.hasArguments()) {
+
+ int *args = 0;
+ QVarLengthArray<int, 9> dummy;
+ QByteArray unknownTypeError;
+
+ args = QQmlPropertyCache::methodParameterTypes(object, data.coreIndex, dummy,
+ &unknownTypeError);
+
+ if (!args) {
+ QString typeName = QString::fromLatin1(unknownTypeError);
+ QString error = QString::fromLatin1("Unknown method parameter type: %1").arg(typeName);
+ v8::ThrowException(v8::Exception::Error(engine->toString(error)));
+ return v8::Handle<v8::Value>();
+ }
+
+ if (args[0] > callArgs.Length()) {
+ QString error = QLatin1String("Insufficient arguments");
+ v8::ThrowException(v8::Exception::Error(engine->toString(error)));
+ return v8::Handle<v8::Value>();
+ }
+
+ return CallMethod(object, data.coreIndex, data.propType, args[0], args + 1, engine, callArgs);
+
+ } else {
+
+ return CallMethod(object, data.coreIndex, data.propType, 0, 0, engine, callArgs);
+
+ }
+}
+
+/*!
+Resolve the overloaded method to call. The algorithm works conceptually like this:
+ 1. Resolve the set of overloads it is *possible* to call.
+ Impossible overloads include those that have too many parameters or have parameters
+ of unknown type.
+ 2. Filter the set of overloads to only contain those with the closest number of
+ parameters.
+ For example, if we are called with 3 parameters and there are 2 overloads that
+ take 2 parameters and one that takes 3, eliminate the 2 parameter overloads.
+ 3. Find the best remaining overload based on its match score.
+ If two or more overloads have the same match score, call the last one. The match
+ score is constructed by adding the matchScore() result for each of the parameters.
+*/
+static v8::Handle<v8::Value> CallOverloaded(QObject *object, const QQmlPropertyData &data,
+ QV8Engine *engine, CallArgs &callArgs)
+{
+ int argumentCount = callArgs.Length();
+
+ const QQmlPropertyData *best = 0;
+ int bestParameterScore = INT_MAX;
+ int bestMatchScore = INT_MAX;
+
+ QQmlPropertyData dummy;
+ const QQmlPropertyData *attempt = &data;
+
+ do {
+ QVarLengthArray<int, 9> dummy;
+ int methodArgumentCount = 0;
+ int *methodArgTypes = 0;
+ if (attempt->hasArguments()) {
+ typedef QQmlPropertyCache PC;
+ int *args = PC::methodParameterTypes(object, attempt->coreIndex, dummy, 0);
+ if (!args) // Must be an unknown argument
+ continue;
+
+ methodArgumentCount = args[0];
+ methodArgTypes = args + 1;
+ }
+
+ if (methodArgumentCount > argumentCount)
+ continue; // We don't have sufficient arguments to call this method
+
+ int methodParameterScore = argumentCount - methodArgumentCount;
+ if (methodParameterScore > bestParameterScore)
+ continue; // We already have a better option
+
+ int methodMatchScore = 0;
+ for (int ii = 0; ii < methodArgumentCount; ++ii)
+ methodMatchScore += MatchScore(callArgs[ii], methodArgTypes[ii]);
+
+ if (bestParameterScore > methodParameterScore || bestMatchScore > methodMatchScore) {
+ best = attempt;
+ bestParameterScore = methodParameterScore;
+ bestMatchScore = methodMatchScore;
+ }
+
+ if (bestParameterScore == 0 && bestMatchScore == 0)
+ break; // We can't get better than that
+
+ } while((attempt = RelatedMethod(object, attempt, dummy)) != 0);
+
+ if (best) {
+ return CallPrecise(object, *best, engine, callArgs);
+ } else {
+ QString error = QLatin1String("Unable to determine callable overload. Candidates are:");
+ const QQmlPropertyData *candidate = &data;
+ while (candidate) {
+ error += QLatin1String("\n ") +
+ QString::fromUtf8(object->metaObject()->method(candidate->coreIndex).signature());
+ candidate = RelatedMethod(object, candidate, dummy);
+ }
+
+ v8::ThrowException(v8::Exception::Error(engine->toString(error)));
+ return v8::Handle<v8::Value>();
+ }
+}
+
+static v8::Handle<v8::Value> ToString(QV8Engine *engine, QObject *object, int, v8::Handle<v8::Object>)
+{
+ QString result;
+ if (object) {
+ QString objectName = object->objectName();
+
+ result += QString::fromUtf8(object->metaObject()->className());
+ result += QLatin1String("(0x");
+ result += QString::number((quintptr)object,16);
+
+ if (!objectName.isEmpty()) {
+ result += QLatin1String(", \"");
+ result += objectName;
+ result += QLatin1Char('\"');
+ }
+
+ result += QLatin1Char(')');
+ } else {
+ result = QLatin1String("null");
+ }
+
+ return engine->toString(result);
+}
+
+static v8::Handle<v8::Value> Destroy(QV8Engine *, QObject *object, int argCount, v8::Handle<v8::Object> args)
+{
+ QQmlData *ddata = QQmlData::get(object, false);
+ if (!ddata || ddata->indestructible) {
+ const char *error = "Invalid attempt to destroy() an indestructible object";
+ v8::ThrowException(v8::Exception::Error(v8::String::New(error)));
+ return v8::Undefined();
+ }
+
+ int delay = 0;
+ if (argCount > 0)
+ delay = args->Get(0)->Uint32Value();
+
+ if (delay > 0)
+ QTimer::singleShot(delay, object, SLOT(deleteLater()));
+ else
+ object->deleteLater();
+
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> QV8QObjectWrapper::Invoke(const v8::Arguments &args)
+{
+ // object, index, qmlglobal, argCount, args
+ Q_ASSERT(args.Length() == 5);
+ Q_ASSERT(args[0]->IsObject());
+
+ QV8QObjectResource *resource = v8_resource_cast<QV8QObjectResource>(args[0]->ToObject());
+
+ if (!resource)
+ return v8::Undefined();
+
+ int argCount = args[3]->Int32Value();
+ v8::Handle<v8::Object> arguments = v8::Handle<v8::Object>::Cast(args[4]);
+
+ // Special hack to return info about this closure.
+ if (argCount == 1 && arguments->Get(0)->StrictEquals(resource->engine->qobjectWrapper()->m_hiddenObject)) {
+ v8::Local<v8::Array> data = v8::Array::New(2);
+ data->Set(0, args[0]);
+ data->Set(1, args[1]);
+ return data;
+ }
+
+ QObject *object = resource->object;
+ int index = args[1]->Int32Value();
+
+ if (!object)
+ return v8::Undefined();
+
+ if (index < 0) {
+ // Builtin functions
+ if (index == QOBJECT_TOSTRING_INDEX) {
+ return ToString(resource->engine, object, argCount, arguments);
+ } else if (index == QOBJECT_DESTROY_INDEX) {
+ return Destroy(resource->engine, object, argCount, arguments);
+ } else {
+ return v8::Undefined();
+ }
+ }
+
+ QQmlPropertyData method;
+
+ if (QQmlData *ddata = static_cast<QQmlData *>(QObjectPrivate::get(object)->declarativeData)) {
+ if (ddata->propertyCache) {
+ QQmlPropertyData *d = ddata->propertyCache->method(index);
+ if (!d)
+ return v8::Undefined();
+ method = *d;
+ }
+ }
+
+ if (method.coreIndex == -1) {
+ method.load(object->metaObject()->method(index));
+
+ if (method.coreIndex == -1)
+ return v8::Undefined();
+ }
+
+ if (method.isV8Function()) {
+ v8::Handle<v8::Value> rv;
+ v8::Handle<v8::Object> qmlglobal = args[2]->ToObject();
+
+ QQmlV8Function func(argCount, arguments, rv, qmlglobal,
+ resource->engine->contextWrapper()->context(qmlglobal),
+ resource->engine);
+ QQmlV8Function *funcptr = &func;
+
+ void *args[] = { 0, &funcptr };
+ QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, method.coreIndex, args);
+
+ if (rv.IsEmpty()) return v8::Undefined();
+ return rv;
+ }
+
+ CallArgs callArgs(argCount, &arguments);
+ if (!method.isOverload()) {
+ return CallPrecise(object, method, resource->engine, callArgs);
+ } else {
+ return CallOverloaded(object, method, resource->engine, callArgs);
+ }
+}
+
+CallArgument::CallArgument()
+: type(QVariant::Invalid)
+{
+}
+
+CallArgument::~CallArgument()
+{
+ cleanup();
+}
+
+void CallArgument::cleanup()
+{
+ if (type == QMetaType::QString) {
+ qstringPtr->~QString();
+ } else if (type == -1 || type == QMetaType::QVariant) {
+ qvariantPtr->~QVariant();
+ } else if (type == qMetaTypeId<QJSValue>()) {
+ qjsValuePtr->~QJSValue();
+ } else if (type == qMetaTypeId<QList<QObject *> >()) {
+ qlistPtr->~QList<QObject *>();
+ }
+}
+
+void *CallArgument::dataPtr()
+{
+ if (type == -1)
+ return qvariantPtr->data();
+ else
+ return (void *)&allocData;
+}
+
+void CallArgument::initAsType(int callType)
+{
+ if (type != 0) { cleanup(); type = 0; }
+ if (callType == 0) return;
+
+ if (callType == qMetaTypeId<QJSValue>()) {
+ qjsValuePtr = new (&allocData) QJSValue();
+ type = callType;
+ } else if (callType == QMetaType::Int ||
+ callType == QMetaType::UInt ||
+ callType == QMetaType::Bool ||
+ callType == QMetaType::Double ||
+ callType == QMetaType::Float) {
+ type = callType;
+ } else if (callType == QMetaType::QObjectStar) {
+ qobjectPtr = 0;
+ type = callType;
+ } else if (callType == QMetaType::QString) {
+ qstringPtr = new (&allocData) QString();
+ type = callType;
+ } else if (callType == QMetaType::QVariant) {
+ type = callType;
+ qvariantPtr = new (&allocData) QVariant();
+ } else if (callType == qMetaTypeId<QList<QObject *> >()) {
+ type = callType;
+ qlistPtr = new (&allocData) QList<QObject *>();
+ } else if (callType == qMetaTypeId<QQmlV8Handle>()) {
+ type = callType;
+ handlePtr = new (&allocData) QQmlV8Handle;
+ } else {
+ type = -1;
+ qvariantPtr = new (&allocData) QVariant(callType, (void *)0);
+ }
+}
+
+void CallArgument::fromValue(int callType, QV8Engine *engine, v8::Handle<v8::Value> value)
+{
+ if (type != 0) { cleanup(); type = 0; }
+
+ if (callType == qMetaTypeId<QJSValue>()) {
+ qjsValuePtr = new (&allocData) QJSValue(QJSValuePrivate::get(new QJSValuePrivate(engine, value)));
+ type = qMetaTypeId<QJSValue>();
+ } else if (callType == QMetaType::Int) {
+ intValue = quint32(value->Int32Value());
+ type = callType;
+ } else if (callType == QMetaType::UInt) {
+ intValue = quint32(value->Uint32Value());
+ type = callType;
+ } else if (callType == QMetaType::Bool) {
+ boolValue = value->BooleanValue();
+ type = callType;
+ } else if (callType == QMetaType::Double) {
+ doubleValue = double(value->NumberValue());
+ type = callType;
+ } else if (callType == QMetaType::Float) {
+ floatValue = float(value->NumberValue());
+ type = callType;
+ } else if (callType == QMetaType::QString) {
+ if (value->IsNull() || value->IsUndefined())
+ qstringPtr = new (&allocData) QString();
+ else
+ qstringPtr = new (&allocData) QString(engine->toString(value->ToString()));
+ type = callType;
+ } else if (callType == QMetaType::QObjectStar) {
+ qobjectPtr = engine->toQObject(value);
+ type = callType;
+ } else if (callType == qMetaTypeId<QVariant>()) {
+ qvariantPtr = new (&allocData) QVariant(engine->toVariant(value, -1));
+ type = callType;
+ } else if (callType == qMetaTypeId<QList<QObject*> >()) {
+ qlistPtr = new (&allocData) QList<QObject *>();
+ if (value->IsArray()) {
+ v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
+ uint32_t length = array->Length();
+ for (uint32_t ii = 0; ii < length; ++ii)
+ qlistPtr->append(engine->toQObject(array->Get(ii)));
+ } else {
+ qlistPtr->append(engine->toQObject(value));
+ }
+ type = callType;
+ } else if (callType == qMetaTypeId<QQmlV8Handle>()) {
+ handlePtr = new (&allocData) QQmlV8Handle(QQmlV8Handle::fromHandle(value));
+ type = callType;
+ } else {
+ qvariantPtr = new (&allocData) QVariant();
+ type = -1;
+
+ QQmlEnginePrivate *ep = engine->engine() ? QQmlEnginePrivate::get(engine->engine()) : 0;
+ QVariant v = engine->toVariant(value, -1);
+
+ if (v.userType() == callType) {
+ *qvariantPtr = v;
+ } else if (v.canConvert((QVariant::Type)callType)) {
+ *qvariantPtr = v;
+ qvariantPtr->convert((QVariant::Type)callType);
+ } else if (const QMetaObject *mo = ep ? ep->rawMetaObjectForType(callType) : 0) {
+ QObject *obj = ep->toQObject(v);
+
+ if (obj) {
+ const QMetaObject *objMo = obj->metaObject();
+ while (objMo && objMo != mo) objMo = objMo->superClass();
+ if (!objMo) obj = 0;
+ }
+
+ *qvariantPtr = QVariant(callType, &obj);
+ } else {
+ *qvariantPtr = QVariant(callType, (void *)0);
+ }
+ }
+}
+
+v8::Handle<v8::Value> CallArgument::toValue(QV8Engine *engine)
+{
+ if (type == qMetaTypeId<QJSValue>()) {
+ return QJSValuePrivate::get(*qjsValuePtr)->asV8Value(engine);
+ } else if (type == QMetaType::Int) {
+ return v8::Integer::New(int(intValue));
+ } else if (type == QMetaType::UInt) {
+ return v8::Integer::NewFromUnsigned(intValue);
+ } else if (type == QMetaType::Bool) {
+ return v8::Boolean::New(boolValue);
+ } else if (type == QMetaType::Double) {
+ return v8::Number::New(doubleValue);
+ } else if (type == QMetaType::Float) {
+ return v8::Number::New(floatValue);
+ } else if (type == QMetaType::QString) {
+ return engine->toString(*qstringPtr);
+ } else if (type == QMetaType::QObjectStar) {
+ QObject *object = qobjectPtr;
+ if (object)
+ QQmlData::get(object, true)->setImplicitDestructible();
+ return engine->newQObject(object);
+ } else if (type == qMetaTypeId<QList<QObject *> >()) {
+ // XXX Can this be made more by using Array as a prototype and implementing
+ // directly against QList<QObject*>?
+ QList<QObject *> &list = *qlistPtr;
+ v8::Local<v8::Array> array = v8::Array::New(list.count());
+ for (int ii = 0; ii < list.count(); ++ii)
+ array->Set(ii, engine->newQObject(list.at(ii)));
+ return array;
+ } else if (type == qMetaTypeId<QQmlV8Handle>()) {
+ return handlePtr->toHandle();
+ } else if (type == -1 || type == qMetaTypeId<QVariant>()) {
+ QVariant value = *qvariantPtr;
+ v8::Handle<v8::Value> rv = engine->fromVariant(value);
+ if (QObject *object = engine->toQObject(rv))
+ QQmlData::get(object, true)->setImplicitDestructible();
+ return rv;
+ } else {
+ return v8::Undefined();
+ }
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/v8/qv8qobjectwrapper_p.h b/src/qml/qml/v8/qv8qobjectwrapper_p.h
new file mode 100644
index 0000000000..f7b965690b
--- /dev/null
+++ b/src/qml/qml/v8/qv8qobjectwrapper_p.h
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8QOBJECTWRAPPER_P_H
+#define QV8QOBJECTWRAPPER_P_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/qmetatype.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qhash.h>
+#include <private/qv8_p.h>
+#include <private/qhashedstring_p.h>
+#include <private/qqmldata_p.h>
+#include <private/qqmlpropertycache_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+class QV8Engine;
+class QQmlData;
+class QV8ObjectResource;
+class QV8QObjectInstance;
+class QV8QObjectConnectionList;
+class QQmlPropertyCache;
+class Q_QML_EXPORT QV8QObjectWrapper
+{
+public:
+ QV8QObjectWrapper();
+ ~QV8QObjectWrapper();
+
+ void init(QV8Engine *);
+ void destroy();
+
+ v8::Handle<v8::Value> newQObject(QObject *object);
+ bool isQObject(v8::Handle<v8::Object>);
+ QObject *toQObject(v8::Handle<v8::Object>);
+ static QObject *toQObject(QV8ObjectResource *);
+
+ enum RevisionMode { IgnoreRevision, CheckRevision };
+ inline v8::Handle<v8::Value> getProperty(QObject *, const QHashedV8String &, RevisionMode);
+ inline bool setProperty(QObject *, const QHashedV8String &, v8::Handle<v8::Value>, RevisionMode);
+
+private:
+ friend class QQmlPropertyCache;
+ friend class QV8QObjectConnectionList;
+ friend class QV8QObjectInstance;
+
+ v8::Local<v8::Object> newQObject(QObject *, QQmlData *, QV8Engine *);
+ static v8::Handle<v8::Value> GetProperty(QV8Engine *, QObject *, v8::Handle<v8::Value> *,
+ const QHashedV8String &, QV8QObjectWrapper::RevisionMode);
+ static bool SetProperty(QV8Engine *, QObject *, const QHashedV8String &,
+ v8::Handle<v8::Value>, QV8QObjectWrapper::RevisionMode);
+ static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Integer> Query(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Connect(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Disconnect(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Invoke(const v8::Arguments &args);
+ static QPair<QObject *, int> ExtractQtMethod(QV8Engine *, v8::Handle<v8::Function>);
+ static QPair<QObject *, int> ExtractQtSignal(QV8Engine *, v8::Handle<v8::Object>);
+
+ QV8Engine *m_engine;
+ quint32 m_id;
+ v8::Persistent<v8::Function> m_constructor;
+ v8::Persistent<v8::Function> m_methodConstructor;
+ v8::Persistent<v8::Function> m_signalHandlerConstructor;
+ v8::Persistent<v8::String> m_toStringSymbol;
+ v8::Persistent<v8::String> m_destroySymbol;
+ QHashedV8String m_toStringString;
+ QHashedV8String m_destroyString;
+ v8::Persistent<v8::Object> m_hiddenObject;
+ QHash<QObject *, QV8QObjectConnectionList *> m_connections;
+ typedef QHash<QObject *, QV8QObjectInstance *> TaintedHash;
+ TaintedHash m_taintedObjects;
+};
+
+v8::Handle<v8::Value> QV8QObjectWrapper::getProperty(QObject *object, const QHashedV8String &string,
+ RevisionMode mode)
+{
+ QQmlData *dd = QQmlData::get(object, false);
+ if (!dd || !dd->propertyCache || m_toStringString == string || m_destroyString == string ||
+ dd->propertyCache->property(string)) {
+ return GetProperty(m_engine, object, 0, string, mode);
+ } else {
+ return v8::Handle<v8::Value>();
+ }
+}
+
+bool QV8QObjectWrapper::setProperty(QObject *object, const QHashedV8String &string,
+ v8::Handle<v8::Value> value, RevisionMode mode)
+{
+ QQmlData *dd = QQmlData::get(object, false);
+ if (!dd || !dd->propertyCache || m_toStringString == string || m_destroyString == string ||
+ dd->propertyCache->property(string)) {
+ return SetProperty(m_engine, object, string, value, mode);
+ } else {
+ return false;
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QV8QOBJECTWRAPPER_P_H
+
+
diff --git a/src/qml/qml/v8/qv8sequencewrapper.cpp b/src/qml/qml/v8/qv8sequencewrapper.cpp
new file mode 100644
index 0000000000..883ed1b60c
--- /dev/null
+++ b/src/qml/qml/v8/qv8sequencewrapper.cpp
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqml.h>
+
+#include "qv8sequencewrapper_p.h"
+#include "qv8sequencewrapper_p_p.h"
+#include "qv8engine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QV8SequenceWrapper::QV8SequenceWrapper()
+ : m_engine(0)
+{
+}
+
+QV8SequenceWrapper::~QV8SequenceWrapper()
+{
+}
+
+#define REGISTER_QML_SEQUENCE_METATYPE(unused, unused2, SequenceType, unused3) qRegisterMetaType<SequenceType>();
+void QV8SequenceWrapper::init(QV8Engine *engine)
+{
+ FOREACH_QML_SEQUENCE_TYPE(REGISTER_QML_SEQUENCE_METATYPE)
+
+ m_engine = engine;
+ m_toString = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ToString)->GetFunction());
+ m_valueOf = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ValueOf)->GetFunction());
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
+ ft->InstanceTemplate()->SetIndexedPropertyHandler(IndexedGetter, IndexedSetter, 0, IndexedDeleter, IndexedEnumerator);
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("length"), LengthGetter, LengthSetter,
+ v8::Handle<v8::Value>(), v8::DEFAULT,
+ v8::PropertyAttribute(v8::DontDelete | v8::DontEnum));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
+ m_toString, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("valueOf"), ValueOfGetter, 0,
+ m_valueOf, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum));
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+}
+#undef REGISTER_QML_SEQUENCE_METATYPE
+
+void QV8SequenceWrapper::destroy()
+{
+ qPersistentDispose(m_toString);
+ qPersistentDispose(m_valueOf);
+ qPersistentDispose(m_constructor);
+}
+
+bool QV8SequenceWrapper::isEqual(QV8ObjectResource *lhs, QV8ObjectResource *rhs)
+{
+ Q_ASSERT(lhs && rhs && lhs->resourceType() == QV8ObjectResource::SequenceType && rhs->resourceType() == QV8ObjectResource::SequenceType);
+ QV8SequenceResource *lr = static_cast<QV8SequenceResource *>(lhs);
+ QV8SequenceResource *rr = static_cast<QV8SequenceResource *>(rhs);
+ return lr->isEqual(rr);
+}
+
+quint32 QV8SequenceWrapper::sequenceLength(QV8ObjectResource *r)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::SequenceType);
+ QV8SequenceResource *sr = static_cast<QV8SequenceResource *>(r);
+ Q_ASSERT(sr);
+ return sr->lengthGetter();
+}
+
+#define NEW_REFERENCE_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \
+ if (sequenceType == qMetaTypeId<SequenceType>()) { \
+ r = new QV8##ElementTypeName##SequenceResource(m_engine, object, propertyIndex); \
+ } else
+
+v8::Local<v8::Object> QV8SequenceWrapper::newSequence(int sequenceType, QObject *object, int propertyIndex, bool *succeeded)
+{
+ // This function is called when the property is a QObject Q_PROPERTY of
+ // the given sequence type. Internally we store a typed-sequence
+ // (as well as object ptr + property index for updated-read and write-back)
+ // and so access/mutate avoids variant conversion.
+ *succeeded = true;
+ QV8SequenceResource *r = 0;
+ FOREACH_QML_SEQUENCE_TYPE(NEW_REFERENCE_SEQUENCE) { /* else */ *succeeded = false; return v8::Local<v8::Object>(); }
+
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ rv->SetExternalResource(r);
+ rv->SetPrototype(v8::Array::New(1)->GetPrototype());
+ return rv;
+}
+#undef NEW_REFERENCE_SEQUENCE
+
+#define NEW_COPY_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \
+ if (sequenceType == qMetaTypeId<SequenceType>()) { \
+ r = new QV8##ElementTypeName##SequenceResource(m_engine, v.value<SequenceType>()); \
+ } else
+
+v8::Local<v8::Object> QV8SequenceWrapper::fromVariant(const QVariant& v, bool *succeeded)
+{
+ // This function is called when assigning a sequence value to a normal JS var
+ // in a JS block. Internally, we store a sequence of the specified type.
+ // Access and mutation is extremely fast since it will not need to modify any
+ // QObject property.
+ int sequenceType = v.userType();
+ *succeeded = true;
+ QV8SequenceResource *r = 0;
+ FOREACH_QML_SEQUENCE_TYPE(NEW_COPY_SEQUENCE) { /* else */ *succeeded = false; return v8::Local<v8::Object>(); }
+
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ rv->SetExternalResource(r);
+ rv->SetPrototype(v8::Array::New(1)->GetPrototype());
+ return rv;
+}
+#undef NEW_COPY_SEQUENCE
+
+QVariant QV8SequenceWrapper::toVariant(QV8ObjectResource *r)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::SequenceType);
+ QV8SequenceResource *resource = static_cast<QV8SequenceResource *>(r);
+ return resource->toVariant();
+}
+
+#define SEQUENCE_TO_VARIANT(ElementType, ElementTypeName, SequenceType, unused) \
+ if (typeHint == qMetaTypeId<SequenceType>()) { \
+ return QV8##ElementTypeName##SequenceResource::toVariant(m_engine, array, length, succeeded); \
+ } else
+
+QVariant QV8SequenceWrapper::toVariant(v8::Handle<v8::Array> array, int typeHint, bool *succeeded)
+{
+ *succeeded = true;
+ uint32_t length = array->Length();
+ FOREACH_QML_SEQUENCE_TYPE(SEQUENCE_TO_VARIANT) { /* else */ *succeeded = false; return QVariant(); }
+}
+#undef SEQUENCE_TO_VARIANT
+
+v8::Handle<v8::Value> QV8SequenceWrapper::IndexedSetter(quint32 index, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
+{
+ QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
+ Q_ASSERT(sr);
+ return sr->indexedSetter(index, value);
+}
+
+v8::Handle<v8::Value> QV8SequenceWrapper::IndexedGetter(quint32 index, const v8::AccessorInfo &info)
+{
+ QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
+ Q_ASSERT(sr);
+ return sr->indexedGetter(index);
+}
+
+v8::Handle<v8::Boolean> QV8SequenceWrapper::IndexedDeleter(quint32 index, const v8::AccessorInfo &info)
+{
+ QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
+ Q_ASSERT(sr);
+ return sr->indexedDeleter(index);
+}
+
+v8::Handle<v8::Array> QV8SequenceWrapper::IndexedEnumerator(const v8::AccessorInfo &info)
+{
+ QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
+ Q_ASSERT(sr);
+ return sr->indexedEnumerator();
+}
+
+v8::Handle<v8::Value> QV8SequenceWrapper::LengthGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
+ Q_ASSERT(sr);
+ return v8::Integer::NewFromUnsigned(sr->lengthGetter());
+}
+
+void QV8SequenceWrapper::LengthSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This());
+ Q_ASSERT(sr);
+ sr->lengthSetter(value);
+}
+
+v8::Handle<v8::Value> QV8SequenceWrapper::ToStringGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
+v8::Handle<v8::Value> QV8SequenceWrapper::ValueOfGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
+v8::Handle<v8::Value> QV8SequenceWrapper::ToString(const v8::Arguments &args)
+{
+ QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(args.This());
+ Q_ASSERT(sr);
+ return sr->toString();
+}
+
+v8::Handle<v8::Value> QV8SequenceWrapper::ValueOf(const v8::Arguments &args)
+{
+ QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(args.This());
+ Q_ASSERT(sr);
+ v8::Handle<v8::Value> tostringValue = sr->toString();
+ if (!tostringValue.IsEmpty())
+ return tostringValue;
+ return v8::Integer::NewFromUnsigned(sr->lengthGetter());
+}
+
+v8::Handle<v8::Value> QV8SequenceWrapper::Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ Q_UNUSED(info);
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> QV8SequenceWrapper::Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ Q_UNUSED(info);
+ return value;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8sequencewrapper_p.h b/src/qml/qml/v8/qv8sequencewrapper_p.h
new file mode 100644
index 0000000000..104135ff76
--- /dev/null
+++ b/src/qml/qml/v8/qv8sequencewrapper_p.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8SEQUENCEWRAPPER_P_H
+#define QV8SEQUENCEWRAPPER_P_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>
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+class QV8ObjectResource;
+class QV8SequenceWrapper
+{
+public:
+ QV8SequenceWrapper();
+ ~QV8SequenceWrapper();
+
+ void init(QV8Engine *);
+ void destroy();
+
+ bool isEqual(QV8ObjectResource *lhs, const QVariant &rhs);
+ bool isEqual(QV8ObjectResource *lhs, QV8ObjectResource *rhs);
+ quint32 sequenceLength(QV8ObjectResource *);
+
+ v8::Local<v8::Object> newSequence(int sequenceTypeId, QObject *object, int propertyIndex, bool *succeeded);
+ v8::Local<v8::Object> fromVariant(const QVariant& v, bool *succeeded);
+ QVariant toVariant(QV8ObjectResource *);
+ QVariant toVariant(v8::Handle<v8::Array> array, int typeHint, bool *succeeded);
+
+private:
+ QV8Engine *m_engine;
+
+ v8::Persistent<v8::Function> m_constructor;
+ v8::Persistent<v8::Function> m_toString;
+ v8::Persistent<v8::Function> m_valueOf;
+
+ static v8::Handle<v8::Value> IndexedGetter(quint32 index, const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> IndexedSetter(quint32 index, v8::Local<v8::Value> value, const v8::AccessorInfo &info);
+ static v8::Handle<v8::Boolean> IndexedDeleter(quint32 index, const v8::AccessorInfo &info);
+ static v8::Handle<v8::Array> IndexedEnumerator(const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> LengthGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
+ static void LengthSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> ToStringGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> ToString(const v8::Arguments &args);
+ static v8::Handle<v8::Value> ValueOfGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> ValueOf(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo &info);
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QV8SEQUENCEWRAPPER_P_H
diff --git a/src/qml/qml/v8/qv8sequencewrapper_p_p.h b/src/qml/qml/v8/qv8sequencewrapper_p_p.h
new file mode 100644
index 0000000000..9d519809fa
--- /dev/null
+++ b/src/qml/qml/v8/qv8sequencewrapper_p_p.h
@@ -0,0 +1,503 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8SEQUENCEWRAPPER_P_P_H
+#define QV8SEQUENCEWRAPPER_P_P_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 <private/qqmlengine_p.h>
+#include <private/qqmlmetatype_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+ \class QV8SequenceResource
+ \brief The abstract base class of the external resource used in sequence type objects
+
+ Every sequence type object returned by QV8SequenceWrapper::fromVariant() or
+ QV8SequenceWrapper::newSequence() has a type-specific QV8SequenceResource which
+ contains the type name, the meta type ids of the sequence and sequence element
+ types, as well as either the sequence data (copy) or object pointer and property
+ index (reference) data associated with the sequence.
+ */
+class QV8SequenceResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(SequenceType);
+
+public:
+ virtual ~QV8SequenceResource() {}
+
+ enum ObjectType { Reference, Copy };
+
+ virtual QVariant toVariant() = 0;
+ virtual bool isEqual(const QV8SequenceResource *v) = 0;
+
+ virtual quint32 lengthGetter() = 0;
+ virtual void lengthSetter(v8::Handle<v8::Value> value) = 0;
+ virtual v8::Handle<v8::Value> indexedSetter(quint32 index, v8::Handle<v8::Value> value) = 0;
+ virtual v8::Handle<v8::Value> indexedGetter(quint32 index) = 0;
+ virtual v8::Handle<v8::Boolean> indexedDeleter(quint32 index) = 0;
+ virtual v8::Handle<v8::Array> indexedEnumerator() = 0;
+ virtual v8::Handle<v8::Value> toString() = 0;
+
+ ObjectType objectType;
+ QByteArray typeName;
+ int sequenceMetaTypeId;
+ int elementMetaTypeId;
+
+protected:
+ QV8SequenceResource(QV8Engine *engine, ObjectType type, const QByteArray &name, int sequenceId, int elementId)
+ : QV8ObjectResource(engine), objectType(type), typeName(name), sequenceMetaTypeId(sequenceId), elementMetaTypeId(elementId)
+ {
+ }
+};
+
+// helper function to generate valid warnings if errors occur during sequence operations.
+static void generateWarning(QV8Engine *engine, const QString& description)
+{
+ if (!engine)
+ return;
+ v8::Local<v8::StackTrace> currStack = v8::StackTrace::CurrentStackTrace(1);
+ if (currStack.IsEmpty())
+ return;
+ v8::Local<v8::StackFrame> currFrame = currStack->GetFrame(0);
+ if (currFrame.IsEmpty())
+ return;
+
+ QQmlError retn;
+ retn.setDescription(description);
+ retn.setLine(currFrame->GetLineNumber());
+ retn.setUrl(QUrl(engine->toString(currFrame->GetScriptName())));
+ QQmlEnginePrivate::warning(engine->engine(), retn);
+}
+
+
+static int convertV8ValueToInt(QV8Engine *, v8::Handle<v8::Value> v)
+{
+ return v->Int32Value();
+}
+
+static v8::Handle<v8::Value> convertIntToV8Value(QV8Engine *, int v)
+{
+ return v8::Integer::New(v);
+}
+
+static QString convertIntToString(QV8Engine *, int v)
+{
+ return QString::number(v);
+}
+
+static qreal convertV8ValueToReal(QV8Engine *, v8::Handle<v8::Value> v)
+{
+ return v->NumberValue();
+}
+
+static v8::Handle<v8::Value> convertRealToV8Value(QV8Engine *, qreal v)
+{
+ return v8::Number::New(v);
+}
+
+static QString convertRealToString(QV8Engine *, qreal v)
+{
+ return QString::number(v);
+}
+
+static bool convertV8ValueToBool(QV8Engine *, v8::Handle<v8::Value> v)
+{
+ return v->BooleanValue();
+}
+
+static v8::Handle<v8::Value> convertBoolToV8Value(QV8Engine *, bool v)
+{
+ return v8::Boolean::New(v);
+}
+
+static QString convertBoolToString(QV8Engine *, bool v)
+{
+ if (v)
+ return QLatin1String("true");
+ return QLatin1String("false");
+}
+
+static QString convertV8ValueToString(QV8Engine *e, v8::Handle<v8::Value> v)
+{
+ return e->toString(v->ToString());
+}
+
+static v8::Handle<v8::Value> convertStringToV8Value(QV8Engine *e, const QString &v)
+{
+ return e->toString(v);
+}
+
+static QString convertStringToString(QV8Engine *, const QString &v)
+{
+ return v;
+}
+
+static QString convertV8ValueToQString(QV8Engine *e, v8::Handle<v8::Value> v)
+{
+ return e->toString(v->ToString());
+}
+
+static v8::Handle<v8::Value> convertQStringToV8Value(QV8Engine *e, const QString &v)
+{
+ return e->toString(v);
+}
+
+static QString convertQStringToString(QV8Engine *, const QString &v)
+{
+ return v;
+}
+
+static QUrl convertV8ValueToUrl(QV8Engine *e, v8::Handle<v8::Value> v)
+{
+ QUrl u;
+ u.setEncodedUrl(e->toString(v->ToString()).toUtf8(), QUrl::TolerantMode);
+ return u;
+}
+
+static v8::Handle<v8::Value> convertUrlToV8Value(QV8Engine *e, const QUrl &v)
+{
+ return e->toString(QLatin1String(v.toEncoded().data()));
+}
+
+static QString convertUrlToString(QV8Engine *, const QUrl &v)
+{
+ return v.toString();
+}
+
+
+/*
+ \internal
+ \class QV8<Type>SequenceResource
+ \brief The external resource used in sequence type objects
+
+ Every sequence type object returned by QV8SequenceWrapper::newSequence() has
+ a QV8<Type>SequenceResource which contains a property index and a pointer
+ to the object which contains the property.
+
+ Every sequence type object returned by QV8SequenceWrapper::fromVariant() has
+ a QV8<Type>SequenceResource which contains a copy of the sequence value.
+ Operations on the sequence are implemented directly in terms of that sequence data.
+
+ There exists one QV8<Type>SequenceResource instance for every JavaScript Object
+ (sequence) instance returned from QV8SequenceWrapper::newSequence() or
+ QV8SequenceWrapper::fromVariant().
+ */
+
+// F(elementType, elementTypeName, sequenceType, defaultValue)
+#define FOREACH_QML_SEQUENCE_TYPE(F) \
+ F(int, Int, QList<int>, 0) \
+ F(qreal, Real, QList<qreal>, 0.0) \
+ F(bool, Bool, QList<bool>, false) \
+ F(QString, String, QList<QString>, QString()) \
+ F(QString, QString, QStringList, QString()) \
+ F(QUrl, Url, QList<QUrl>, QUrl())
+
+#define QML_SEQUENCE_TYPE_RESOURCE(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue, ConversionToV8fn, ConversionFromV8fn, ToStringfn) \
+ QT_END_NAMESPACE \
+ Q_DECLARE_METATYPE(SequenceType) \
+ QT_BEGIN_NAMESPACE \
+ class QV8##SequenceElementTypeName##SequenceResource : public QV8SequenceResource { \
+ public:\
+ QV8##SequenceElementTypeName##SequenceResource(QV8Engine *engine, QObject *obj, int propIdx) \
+ : QV8SequenceResource(engine, QV8SequenceResource::Reference, #SequenceType, qMetaTypeId<SequenceType>(), qMetaTypeId<SequenceElementType>()) \
+ , object(obj), propertyIndex(propIdx) \
+ { \
+ } \
+ QV8##SequenceElementTypeName##SequenceResource(QV8Engine *engine, const SequenceType &value) \
+ : QV8SequenceResource(engine, QV8SequenceResource::Copy, #SequenceType, qMetaTypeId<SequenceType>(), qMetaTypeId<SequenceElementType>()) \
+ , object(0), propertyIndex(-1), c(value) \
+ { \
+ } \
+ ~QV8##SequenceElementTypeName##SequenceResource() \
+ { \
+ } \
+ static QVariant toVariant(QV8Engine *e, v8::Handle<v8::Array> array, uint32_t length, bool *succeeded) \
+ { \
+ SequenceType list; \
+ for (uint32_t ii = 0; ii < length; ++ii) { \
+ list.append(ConversionFromV8fn(e, array->Get(ii))); \
+ } \
+ *succeeded = true; \
+ return QVariant::fromValue<SequenceType>(list); \
+ } \
+ QVariant toVariant() \
+ { \
+ if (objectType == QV8SequenceResource::Reference) { \
+ if (!object) \
+ return QVariant(); \
+ loadReference(); \
+ } \
+ return QVariant::fromValue<SequenceType>(c); \
+ } \
+ bool isEqual(const QV8SequenceResource *v) \
+ { \
+ /* Note: two different sequences can never be equal (even if they */ \
+ /* contain the same elements in the same order) in order to */ \
+ /* maintain JavaScript semantics. However, if they both reference */ \
+ /* the same QObject+propertyIndex, they are equal. */ \
+ if (objectType == QV8SequenceResource::Reference && v->objectType == QV8SequenceResource::Reference) { \
+ if (sequenceMetaTypeId == v->sequenceMetaTypeId) { \
+ const QV8##SequenceElementTypeName##SequenceResource *rhs = static_cast<const QV8##SequenceElementTypeName##SequenceResource *>(v); \
+ return (object != 0 && object == rhs->object && propertyIndex == rhs->propertyIndex); \
+ } \
+ } else if (objectType == QV8SequenceResource::Copy && v->objectType == QV8SequenceResource::Copy) { \
+ if (sequenceMetaTypeId == v->sequenceMetaTypeId) { \
+ const QV8##SequenceElementTypeName##SequenceResource *rhs = static_cast<const QV8##SequenceElementTypeName##SequenceResource *>(v); \
+ return (this == rhs); \
+ } \
+ } \
+ return false; \
+ } \
+ quint32 lengthGetter() \
+ { \
+ if (objectType == QV8SequenceResource::Reference) { \
+ if (!object) \
+ return 0; \
+ loadReference(); \
+ } \
+ return static_cast<quint32>(c.count()); \
+ } \
+ void lengthSetter(v8::Handle<v8::Value> value) \
+ { \
+ /* Get the new required length */ \
+ if (value.IsEmpty() || !value->IsUint32()) \
+ return; \
+ quint32 newLength = value->Uint32Value(); \
+ /* Qt containers have int (rather than uint) allowable indexes. */ \
+ if (newLength > INT_MAX) { \
+ generateWarning(engine, QLatin1String("Index out of range during length set")); \
+ return; \
+ } \
+ /* Read the sequence from the QObject property if we're a reference */ \
+ if (objectType == QV8SequenceResource::Reference) { \
+ if (!object) \
+ return; \
+ loadReference(); \
+ } \
+ /* Determine whether we need to modify the sequence */ \
+ qint32 newCount = static_cast<qint32>(newLength); \
+ qint32 count = c.count(); \
+ if (newCount == count) { \
+ return; \
+ } else if (newCount > count) { \
+ /* according to ECMA262r3 we need to insert */ \
+ /* undefined values increasing length to newLength. */ \
+ /* We cannot, so we insert default-values instead. */ \
+ while (newCount > count++) { \
+ QT_TRY { \
+ c.append(DefaultValue); \
+ } QT_CATCH (std::bad_alloc &exception) { \
+ generateWarning(engine, QString(QLatin1String(exception.what()) \
+ + QLatin1String(" during length set"))); \
+ return; /* failed; don't write back any result. */ \
+ } \
+ } \
+ } else { \
+ /* according to ECMA262r3 we need to remove */ \
+ /* elements until the sequence is the required length. */ \
+ while (newCount < count) { \
+ count--; \
+ c.removeAt(count); \
+ } \
+ } \
+ /* write back if required. */ \
+ if (objectType == QV8SequenceResource::Reference) { \
+ /* write back. already checked that object is non-null, so skip that check here. */ \
+ storeReference(); \
+ } \
+ return; \
+ } \
+ v8::Handle<v8::Value> indexedSetter(quint32 index, v8::Handle<v8::Value> value) \
+ { \
+ /* Qt containers have int (rather than uint) allowable indexes. */ \
+ if (index > INT_MAX) { \
+ generateWarning(engine, QLatin1String("Index out of range during indexed set")); \
+ return v8::Undefined(); \
+ } \
+ if (objectType == QV8SequenceResource::Reference) { \
+ if (!object) \
+ return v8::Undefined(); \
+ loadReference(); \
+ } \
+ /* modify the sequence */ \
+ SequenceElementType elementValue = ConversionFromV8fn(engine, value); \
+ qint32 count = c.count(); \
+ qint32 signedIdx = static_cast<qint32>(index); \
+ if (signedIdx == count) { \
+ c.append(elementValue); \
+ } else if (signedIdx < count) { \
+ c[index] = elementValue; \
+ } else { \
+ /* according to ECMA262r3 we need to insert */ \
+ /* the value at the given index, increasing length to index+1. */ \
+ QT_TRY { \
+ while (signedIdx > count++) { \
+ c.append(DefaultValue); \
+ } \
+ c.append(elementValue); \
+ } QT_CATCH (std::bad_alloc &exception) { \
+ generateWarning(engine, QString(QLatin1String(exception.what()) \
+ + QLatin1String(" during indexed set"))); \
+ return v8::Undefined(); /* failed; don't write back any result. */ \
+ } \
+ } \
+ /* write back. already checked that object is non-null, so skip that check here. */ \
+ if (objectType == QV8SequenceResource::Reference) \
+ storeReference(); \
+ return value; \
+ } \
+ v8::Handle<v8::Value> indexedGetter(quint32 index) \
+ { \
+ /* Qt containers have int (rather than uint) allowable indexes. */ \
+ if (index > INT_MAX) { \
+ generateWarning(engine, QLatin1String("Index out of range during indexed get")); \
+ return v8::Undefined(); \
+ } \
+ if (objectType == QV8SequenceResource::Reference) { \
+ if (!object) \
+ return v8::Undefined(); \
+ loadReference(); \
+ } \
+ qint32 count = c.count(); \
+ qint32 signedIdx = static_cast<qint32>(index); \
+ if (signedIdx < count) \
+ return ConversionToV8fn(engine, c.at(signedIdx)); \
+ return v8::Undefined(); \
+ } \
+ v8::Handle<v8::Boolean> indexedDeleter(quint32 index) \
+ { \
+ /* Qt containers have int (rather than uint) allowable indexes. */ \
+ if (index > INT_MAX) \
+ return v8::Boolean::New(false); \
+ /* Read in the sequence from the QObject */ \
+ if (objectType == QV8SequenceResource::Reference) { \
+ if (!object) \
+ return v8::Boolean::New(false); \
+ loadReference(); \
+ } \
+ qint32 signedIdx = static_cast<qint32>(index); \
+ if (signedIdx < c.count()) { \
+ /* according to ECMA262r3 it should be Undefined, */ \
+ /* but we cannot, so we insert a default-value instead. */ \
+ c.replace(signedIdx, DefaultValue); \
+ if (objectType == QV8SequenceResource::Reference) { \
+ /* write back. already checked that object is non-null, so skip that check here. */ \
+ storeReference(); \
+ } \
+ return v8::Boolean::New(true); \
+ } \
+ return v8::Boolean::New(false); \
+ } \
+ v8::Handle<v8::Array> indexedEnumerator() \
+ { \
+ if (objectType == QV8SequenceResource::Reference) { \
+ if (!object) \
+ return v8::Handle<v8::Array>(); \
+ loadReference(); \
+ } \
+ qint32 count = c.count(); \
+ v8::Local<v8::Array> retn = v8::Array::New(count); \
+ for (qint32 i = 0; i < count; ++i) { \
+ retn->Set(static_cast<quint32>(i), v8::Integer::NewFromUnsigned(static_cast<quint32>(i))); \
+ } \
+ return retn; \
+ } \
+ v8::Handle<v8::Value> toString() \
+ { \
+ if (objectType == QV8SequenceResource::Reference) { \
+ if (!object) \
+ return v8::Undefined(); \
+ loadReference(); \
+ } \
+ QString str; \
+ qint32 count = c.count(); \
+ for (qint32 i = 0; i < count; ++i) { \
+ str += QString(QLatin1String("%1,")).arg(ToStringfn(engine, c[i])); \
+ } \
+ str.chop(1); \
+ return engine->toString(str); \
+ } \
+ void loadReference() \
+ { \
+ Q_ASSERT(object); \
+ Q_ASSERT(objectType == QV8SequenceResource::Reference); \
+ void *a[] = { &c, 0 }; \
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, propertyIndex, a); \
+ } \
+ void storeReference() \
+ { \
+ Q_ASSERT(object); \
+ Q_ASSERT(objectType == QV8SequenceResource::Reference); \
+ int status = -1; \
+ QQmlPropertyPrivate::WriteFlags flags = \
+ QQmlPropertyPrivate::DontRemoveBinding; \
+ void *a[] = { &c, 0, &status, &flags }; \
+ QMetaObject::metacall(object, QMetaObject::WriteProperty, propertyIndex, a); \
+ } \
+ private: \
+ QQmlGuard<QObject> object; \
+ int propertyIndex; \
+ SequenceType c; \
+ };
+
+#define GENERATE_QML_SEQUENCE_TYPE_RESOURCE(ElementType, ElementTypeName, SequenceType, DefaultValue) \
+ QML_SEQUENCE_TYPE_RESOURCE(ElementType, ElementTypeName, SequenceType, DefaultValue, convert##ElementTypeName##ToV8Value, convertV8ValueTo##ElementTypeName, convert##ElementTypeName##ToString)
+
+FOREACH_QML_SEQUENCE_TYPE(GENERATE_QML_SEQUENCE_TYPE_RESOURCE)
+#undef GENERATE_QML_SEQUENCE_TYPE_RESOURCE
+#undef QML_SEQUENCE_TYPE_RESOURCE
+
+QT_END_NAMESPACE
+
+#endif // QV8SEQUENCEWRAPPER_P_P_H
diff --git a/src/qml/qml/v8/qv8sqlerrors.cpp b/src/qml/qml/v8/qv8sqlerrors.cpp
new file mode 100644
index 0000000000..8c5856ea18
--- /dev/null
+++ b/src/qml/qml/v8/qv8sqlerrors.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8sqlerrors_p.h"
+#include "qv8engine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+void qt_add_sqlexceptions(QV8Engine *engine)
+{
+ // SQL Exception
+ v8::PropertyAttribute attributes = (v8::PropertyAttribute)(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
+
+ v8::Local<v8::Object> sqlexception = v8::Object::New();
+ sqlexception->Set(v8::String::New("UNKNOWN_ERR"), v8::Integer::New(SQLEXCEPTION_UNKNOWN_ERR), attributes);
+ sqlexception->Set(v8::String::New("DATABASE_ERR"), v8::Integer::New(SQLEXCEPTION_DATABASE_ERR), attributes);
+ sqlexception->Set(v8::String::New("VERSION_ERR"), v8::Integer::New(SQLEXCEPTION_VERSION_ERR), attributes);
+ sqlexception->Set(v8::String::New("TOO_LARGE_ERR"), v8::Integer::New(SQLEXCEPTION_TOO_LARGE_ERR), attributes);
+ sqlexception->Set(v8::String::New("QUOTA_ERR"), v8::Integer::New(SQLEXCEPTION_QUOTA_ERR), attributes);
+ sqlexception->Set(v8::String::New("SYNTAX_ERR"), v8::Integer::New(SQLEXCEPTION_SYNTAX_ERR), attributes);
+ sqlexception->Set(v8::String::New("CONSTRAINT_ERR"), v8::Integer::New(SQLEXCEPTION_CONSTRAINT_ERR), attributes);
+ sqlexception->Set(v8::String::New("TIMEOUT_ERR"), v8::Integer::New(SQLEXCEPTION_TIMEOUT_ERR), attributes);
+ engine->global()->Set(v8::String::New("SQLException"), sqlexception);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8sqlerrors_p.h b/src/qml/qml/v8/qv8sqlerrors_p.h
new file mode 100644
index 0000000000..c799be6e7c
--- /dev/null
+++ b/src/qml/qml/v8/qv8sqlerrors_p.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8SQLERRORS_P_H
+#define QV8SQLERRORS_P_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>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+#define SQLEXCEPTION_UNKNOWN_ERR 1
+#define SQLEXCEPTION_DATABASE_ERR 2
+#define SQLEXCEPTION_VERSION_ERR 3
+#define SQLEXCEPTION_TOO_LARGE_ERR 4
+#define SQLEXCEPTION_QUOTA_ERR 5
+#define SQLEXCEPTION_SYNTAX_ERR 6
+#define SQLEXCEPTION_CONSTRAINT_ERR 7
+#define SQLEXCEPTION_TIMEOUT_ERR 8
+
+class QV8Engine;
+void qt_add_sqlexceptions(QV8Engine *engine);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QV8SQLERRORS_P_H
diff --git a/src/qml/qml/v8/qv8stringwrapper.cpp b/src/qml/qml/v8/qv8stringwrapper.cpp
new file mode 100644
index 0000000000..d4abbdc60b
--- /dev/null
+++ b/src/qml/qml/v8/qv8stringwrapper.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8stringwrapper_p.h"
+#include "qjsconverter_p.h"
+#include "qjsconverter_impl_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QV8StringWrapper::QV8StringWrapper()
+{
+}
+
+QV8StringWrapper::~QV8StringWrapper()
+{
+}
+
+void QV8StringWrapper::init()
+{
+}
+
+void QV8StringWrapper::destroy()
+{
+}
+
+v8::Local<v8::String> QV8StringWrapper::toString(const QString &qstr)
+{
+ return QJSConverter::toString(qstr);
+}
+
+QString QV8StringWrapper::toString(v8::Handle<v8::String> jsstr)
+{
+ if (jsstr.IsEmpty()) {
+ return QString();
+ } else {
+ return QJSConverter::toString(jsstr);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8stringwrapper_p.h b/src/qml/qml/v8/qv8stringwrapper_p.h
new file mode 100644
index 0000000000..1609720298
--- /dev/null
+++ b/src/qml/qml/v8/qv8stringwrapper_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLV8STRINGWRAPPER_P_H
+#define QQMLV8STRINGWRAPPER_P_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 <QtQml/qtqmlglobal.h>
+
+#include <QtCore/qstring.h>
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QML_EXPORT QV8StringWrapper
+{
+public:
+ QV8StringWrapper();
+ ~QV8StringWrapper();
+
+ void init();
+ void destroy();
+
+ v8::Local<v8::String> toString(const QString &);
+ QString toString(v8::Handle<v8::String>);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLV8STRINGWRAPPER_P_H
diff --git a/src/qml/qml/v8/qv8typewrapper.cpp b/src/qml/qml/v8/qv8typewrapper.cpp
new file mode 100644
index 0000000000..dbf369e678
--- /dev/null
+++ b/src/qml/qml/v8/qv8typewrapper.cpp
@@ -0,0 +1,314 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8contextwrapper_p.h"
+#include "qv8engine_p.h"
+
+#include <private/qqmlengine_p.h>
+#include <private/qqmlcontext_p.h>
+
+#include <private/qjsvalue_p.h>
+#include <private/qscript_impl_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8TypeResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(TypeType);
+
+public:
+ QV8TypeResource(QV8Engine *engine);
+ virtual ~QV8TypeResource();
+
+ QV8TypeWrapper::TypeNameMode mode;
+
+ QQmlGuard<QObject> object;
+
+ QQmlType *type;
+ QQmlTypeNameCache *typeNamespace;
+ const void *importNamespace;
+};
+
+QV8TypeResource::QV8TypeResource(QV8Engine *engine)
+: QV8ObjectResource(engine), mode(QV8TypeWrapper::IncludeEnums), type(0), typeNamespace(0), importNamespace(0)
+{
+}
+
+QV8TypeResource::~QV8TypeResource()
+{
+ if (typeNamespace) typeNamespace->release();
+}
+
+QV8TypeWrapper::QV8TypeWrapper()
+: m_engine(0)
+{
+}
+
+QV8TypeWrapper::~QV8TypeWrapper()
+{
+}
+
+void QV8TypeWrapper::destroy()
+{
+ qPersistentDispose(m_constructor);
+}
+
+void QV8TypeWrapper::init(QV8Engine *engine)
+{
+ m_engine = engine;
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetNamedPropertyHandler(Getter, Setter);
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+}
+
+// Returns a type wrapper for type t on o. This allows access of enums, and attached properties.
+v8::Local<v8::Object> QV8TypeWrapper::newObject(QObject *o, QQmlType *t, TypeNameMode mode)
+{
+ Q_ASSERT(t);
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ QV8TypeResource *r = new QV8TypeResource(m_engine);
+ r->mode = mode; r->object = o; r->type = t;
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+// Returns a type wrapper for importNamespace (of t) on o. This allows nested resolution of a type in a
+// namespace.
+v8::Local<v8::Object> QV8TypeWrapper::newObject(QObject *o, QQmlTypeNameCache *t,
+ const void *importNamespace, TypeNameMode mode)
+{
+ Q_ASSERT(t);
+ Q_ASSERT(importNamespace);
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ QV8TypeResource *r = new QV8TypeResource(m_engine);
+ t->addref();
+ r->mode = mode; r->object = o; r->typeNamespace = t; r->importNamespace = importNamespace;
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+QVariant QV8TypeWrapper::toVariant(QV8ObjectResource *r)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::TypeType);
+ QV8TypeResource *resource = static_cast<QV8TypeResource *>(r);
+ QV8Engine *v8engine = resource->engine;
+
+ if (resource->typeNamespace) {
+ if (QQmlMetaType::ModuleApiInstance *moduleApi = resource->typeNamespace->moduleApi(resource->importNamespace)) {
+ if (moduleApi->scriptCallback) {
+ moduleApi->scriptApi = moduleApi->scriptCallback(v8engine->engine(), v8engine->engine());
+ moduleApi->scriptCallback = 0;
+ moduleApi->qobjectCallback = 0;
+ } else if (moduleApi->qobjectCallback) {
+ moduleApi->qobjectApi = moduleApi->qobjectCallback(v8engine->engine(), v8engine->engine());
+ moduleApi->scriptCallback = 0;
+ moduleApi->qobjectCallback = 0;
+ }
+
+ if (moduleApi->qobjectApi) {
+ return QVariant::fromValue<QObject*>(moduleApi->qobjectApi);
+ }
+ }
+ }
+
+ // only QObject Module API can be converted to a variant.
+ return QVariant();
+}
+
+v8::Handle<v8::Value> QV8TypeWrapper::Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ QV8TypeResource *resource = v8_resource_cast<QV8TypeResource>(info.This());
+
+ if (!resource)
+ return v8::Undefined();
+
+ QV8Engine *v8engine = resource->engine;
+ QObject *object = resource->object;
+
+ QHashedV8String propertystring(property);
+
+ if (resource->type) {
+ QQmlType *type = resource->type;
+
+ if (QV8Engine::startsWithUpper(property)) {
+ int value = type->enumValue(propertystring);
+ if (-1 != value)
+ return v8::Integer::New(value);
+
+ // Fall through to return empty handle
+
+ } else if (resource->object) {
+ QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
+ if (ao)
+ return v8engine->qobjectWrapper()->getProperty(ao, propertystring,
+ QV8QObjectWrapper::IgnoreRevision);
+
+ // Fall through to return empty handle
+ }
+
+ // Fall through to return empty handle
+
+ } else if (resource->typeNamespace) {
+ Q_ASSERT(resource->importNamespace);
+ QQmlTypeNameCache::Result r = resource->typeNamespace->query(propertystring,
+ resource->importNamespace);
+
+ if (r.isValid()) {
+ if (r.type) {
+ return v8engine->typeWrapper()->newObject(object, r.type, resource->mode);
+ } else if (r.scriptIndex != -1) {
+ int index = r.scriptIndex;
+ QQmlContextData *context = v8engine->callingContext();
+ if (index < context->importedScripts.count())
+ return context->importedScripts.at(index);
+ }
+
+ return v8::Undefined();
+ } else if (QQmlMetaType::ModuleApiInstance *moduleApi = resource->typeNamespace->moduleApi(resource->importNamespace)) {
+
+ if (moduleApi->scriptCallback) {
+ moduleApi->scriptApi = moduleApi->scriptCallback(v8engine->engine(), v8engine->engine());
+ moduleApi->scriptCallback = 0;
+ moduleApi->qobjectCallback = 0;
+ } else if (moduleApi->qobjectCallback) {
+ moduleApi->qobjectApi = moduleApi->qobjectCallback(v8engine->engine(), v8engine->engine());
+ moduleApi->scriptCallback = 0;
+ moduleApi->qobjectCallback = 0;
+ }
+
+ if (moduleApi->qobjectApi) {
+ // check for enum value
+ if (QV8Engine::startsWithUpper(property)) {
+ if (resource->mode == IncludeEnums) {
+ QString name = v8engine->toString(property);
+
+ // ### Optimize
+ QByteArray enumName = name.toUtf8();
+ const QMetaObject *metaObject = moduleApi->qobjectApi->metaObject();
+ for (int ii = metaObject->enumeratorCount() - 1; ii >= 0; --ii) {
+ QMetaEnum e = metaObject->enumerator(ii);
+ bool ok;
+ int value = e.keyToValue(enumName.constData(), &ok);
+ if (ok)
+ return v8::Integer::New(value);
+ }
+ }
+ }
+
+ // check for property.
+ v8::Handle<v8::Value> rv = v8engine->qobjectWrapper()->getProperty(moduleApi->qobjectApi, propertystring, QV8QObjectWrapper::IgnoreRevision);
+ return rv;
+ } else if (!moduleApi->scriptApi.isUndefined()) {
+ // NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable.
+ QJSValuePrivate *apiprivate = QJSValuePrivate::get(moduleApi->scriptApi);
+ QScopedPointer<QJSValuePrivate> propertyValue(apiprivate->property(property).give());
+ return propertyValue->asV8Value(v8engine);
+ } else {
+ return v8::Handle<v8::Value>();
+ }
+ }
+
+ // Fall through to return empty handle
+
+ } else {
+ Q_ASSERT(!"Unreachable");
+ }
+
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> QV8TypeWrapper::Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info)
+{
+ QV8TypeResource *resource = v8_resource_cast<QV8TypeResource>(info.This());
+
+ if (!resource)
+ return value;
+
+ QV8Engine *v8engine = resource->engine;
+
+ QHashedV8String propertystring(property);
+
+ if (resource->type && resource->object) {
+ QQmlType *type = resource->type;
+ QObject *object = resource->object;
+ QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
+ if (ao)
+ v8engine->qobjectWrapper()->setProperty(ao, propertystring, value,
+ QV8QObjectWrapper::IgnoreRevision);
+ } else if (resource->typeNamespace) {
+ if (QQmlMetaType::ModuleApiInstance *moduleApi = resource->typeNamespace->moduleApi(resource->importNamespace)) {
+ if (moduleApi->scriptCallback) {
+ moduleApi->scriptApi = moduleApi->scriptCallback(v8engine->engine(), v8engine->engine());
+ moduleApi->scriptCallback = 0;
+ moduleApi->qobjectCallback = 0;
+ } else if (moduleApi->qobjectCallback) {
+ moduleApi->qobjectApi = moduleApi->qobjectCallback(v8engine->engine(), v8engine->engine());
+ moduleApi->scriptCallback = 0;
+ moduleApi->qobjectCallback = 0;
+ }
+
+ if (moduleApi->qobjectApi) {
+ v8engine->qobjectWrapper()->setProperty(moduleApi->qobjectApi, propertystring, value,
+ QV8QObjectWrapper::IgnoreRevision);
+ } else if (!moduleApi->scriptApi.isUndefined()) {
+ QScopedPointer<QJSValuePrivate> setvalp(new QJSValuePrivate(v8engine, value));
+ QJSValuePrivate *apiprivate = QJSValuePrivate::get(moduleApi->scriptApi);
+ if (apiprivate->propertyFlags(property) & QJSValuePrivate::ReadOnly) {
+ QString error = QLatin1String("Cannot assign to read-only property \"") +
+ v8engine->toString(property) + QLatin1Char('\"');
+ v8::ThrowException(v8::Exception::Error(v8engine->toString(error)));
+ } else {
+ apiprivate->setProperty(property, setvalp.data());
+ }
+ }
+ }
+ }
+
+ return value;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8typewrapper_p.h b/src/qml/qml/v8/qv8typewrapper_p.h
new file mode 100644
index 0000000000..8b658da6fb
--- /dev/null
+++ b/src/qml/qml/v8/qv8typewrapper_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8TYPEWRAPPER_P_H
+#define QV8TYPEWRAPPER_P_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 <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+class QV8Engine;
+class QQmlType;
+class QQmlTypeNameCache;
+class QV8TypeWrapper
+{
+public:
+ QV8TypeWrapper();
+ ~QV8TypeWrapper();
+
+ void init(QV8Engine *);
+ void destroy();
+
+ enum TypeNameMode { IncludeEnums, ExcludeEnums };
+ v8::Local<v8::Object> newObject(QObject *, QQmlType *, TypeNameMode = IncludeEnums);
+ v8::Local<v8::Object> newObject(QObject *, QQmlTypeNameCache *, const void *,
+ TypeNameMode = IncludeEnums);
+ QVariant toVariant(QV8ObjectResource *);
+
+private:
+ static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info);
+
+ QV8Engine *m_engine;
+ v8::Persistent<v8::Function> m_constructor;
+};
+
+QT_END_NAMESPACE
+
+#endif // QV8TYPEWRAPPER_P_H
+
diff --git a/src/qml/qml/v8/qv8valuetypewrapper.cpp b/src/qml/qml/v8/qv8valuetypewrapper.cpp
new file mode 100644
index 0000000000..54d871d5f0
--- /dev/null
+++ b/src/qml/qml/v8/qv8valuetypewrapper.cpp
@@ -0,0 +1,387 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8valuetypewrapper_p.h"
+#include "qv8engine_p.h"
+
+#include <private/qqmlvaluetype_p.h>
+#include <private/qqmlbinding_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8ValueTypeResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(ValueTypeType);
+
+public:
+ enum ObjectType { Reference, Copy };
+
+ QV8ValueTypeResource(QV8Engine *engine, ObjectType objectType);
+
+ ObjectType objectType;
+ QQmlValueType *type;
+};
+
+class QV8ValueTypeReferenceResource : public QV8ValueTypeResource
+{
+public:
+ QV8ValueTypeReferenceResource(QV8Engine *engine);
+
+ QQmlGuard<QObject> object;
+ int property;
+};
+
+class QV8ValueTypeCopyResource : public QV8ValueTypeResource
+{
+public:
+ QV8ValueTypeCopyResource(QV8Engine *engine);
+
+ QVariant value;
+};
+
+QV8ValueTypeResource::QV8ValueTypeResource(QV8Engine *engine, ObjectType objectType)
+: QV8ObjectResource(engine), objectType(objectType)
+{
+}
+
+QV8ValueTypeReferenceResource::QV8ValueTypeReferenceResource(QV8Engine *engine)
+: QV8ValueTypeResource(engine, Reference)
+{
+}
+
+QV8ValueTypeCopyResource::QV8ValueTypeCopyResource(QV8Engine *engine)
+: QV8ValueTypeResource(engine, Copy)
+{
+}
+
+QV8ValueTypeWrapper::QV8ValueTypeWrapper()
+: m_engine(0)
+{
+}
+
+QV8ValueTypeWrapper::~QV8ValueTypeWrapper()
+{
+}
+
+void QV8ValueTypeWrapper::destroy()
+{
+ qPersistentDispose(m_toString);
+ qPersistentDispose(m_constructor);
+ qPersistentDispose(m_toStringSymbol);
+}
+
+static quint32 toStringHash = -1;
+
+void QV8ValueTypeWrapper::init(QV8Engine *engine)
+{
+ m_engine = engine;
+ m_toString = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ToString)->GetFunction());
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetNamedPropertyHandler(Getter, Setter);
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
+ m_toString, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+
+ m_toStringSymbol = qPersistentNew<v8::String>(v8::String::NewSymbol("toString"));
+ m_toStringString = QHashedV8String(m_toStringSymbol);
+ toStringHash = m_toStringString.hash();
+}
+
+v8::Local<v8::Object> QV8ValueTypeWrapper::newValueType(QObject *object, int property, QQmlValueType *type)
+{
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ QV8ValueTypeReferenceResource *r = new QV8ValueTypeReferenceResource(m_engine);
+ r->type = type; r->object = object; r->property = property;
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+v8::Local<v8::Object> QV8ValueTypeWrapper::newValueType(const QVariant &value, QQmlValueType *type)
+{
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv = m_constructor->NewInstance();
+ QV8ValueTypeCopyResource *r = new QV8ValueTypeCopyResource(m_engine);
+ r->type = type; r->value = value;
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+QVariant QV8ValueTypeWrapper::toVariant(v8::Handle<v8::Object> obj)
+{
+ QV8ValueTypeResource *r = v8_resource_cast<QV8ValueTypeResource>(obj);
+ if (r) return toVariant(r);
+ else return QVariant();
+}
+
+QVariant QV8ValueTypeWrapper::toVariant(QV8ObjectResource *r)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::ValueTypeType);
+ QV8ValueTypeResource *resource = static_cast<QV8ValueTypeResource *>(r);
+
+ if (resource->objectType == QV8ValueTypeResource::Reference) {
+ QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(resource);
+
+ if (reference->object) {
+ reference->type->read(reference->object, reference->property);
+ return reference->type->value();
+ } else {
+ return QVariant();
+ }
+
+ } else {
+ Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
+
+ QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
+
+ return copy->value;
+ }
+}
+
+bool QV8ValueTypeWrapper::isEqual(QV8ObjectResource *r, const QVariant& value)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::ValueTypeType);
+ QV8ValueTypeResource *resource = static_cast<QV8ValueTypeResource *>(r);
+
+ if (resource->objectType == QV8ValueTypeResource::Reference) {
+ QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(resource);
+ if (reference->object) {
+ reference->type->read(reference->object, reference->property);
+ return reference->type->isEqual(value);
+ } else {
+ return false;
+ }
+ } else {
+ Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
+ QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
+ return (value == copy->value);
+ }
+}
+
+v8::Handle<v8::Value> QV8ValueTypeWrapper::ToStringGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
+v8::Handle<v8::Value> QV8ValueTypeWrapper::ToString(const v8::Arguments &args)
+{
+ QV8ValueTypeResource *resource = v8_resource_cast<QV8ValueTypeResource>(args.This());
+ if (resource) {
+ if (resource->objectType == QV8ValueTypeResource::Reference) {
+ QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(resource);
+ if (reference->object) {
+ reference->type->read(reference->object, reference->property);
+ return resource->engine->toString(resource->type->toString());
+ } else {
+ return v8::Undefined();
+ }
+ } else {
+ Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
+ QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
+ QString result = copy->value.toString();
+ if (result.isEmpty() && !copy->value.canConvert(QVariant::String)) {
+ result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(copy->value.typeName()));
+ }
+ return resource->engine->toString(result);
+ }
+ } else {
+ return v8::Undefined();
+ }
+}
+
+v8::Handle<v8::Value> QV8ValueTypeWrapper::Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ QV8ValueTypeResource *r = v8_resource_cast<QV8ValueTypeResource>(info.This());
+ if (!r) return v8::Handle<v8::Value>();
+
+ QHashedV8String propertystring(property);
+
+ {
+ // Comparing the hash first actually makes a measurable difference here, at least on x86
+ quint32 hash = propertystring.hash();
+ if (hash == toStringHash &&
+ r->engine->valueTypeWrapper()->m_toStringString == propertystring) {
+ return r->engine->valueTypeWrapper()->m_toString;
+ }
+ }
+
+ QQmlPropertyData local;
+ QQmlPropertyData *result = 0;
+ {
+ QQmlData *ddata = QQmlData::get(r->type, false);
+ if (ddata && ddata->propertyCache)
+ result = ddata->propertyCache->property(propertystring);
+ else
+ result = QQmlPropertyCache::property(r->engine->engine(), r->type,
+ propertystring, local);
+ }
+
+ if (!result)
+ return v8::Handle<v8::Value>();
+
+ if (r->objectType == QV8ValueTypeResource::Reference) {
+ QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(r);
+
+ if (!reference->object)
+ return v8::Handle<v8::Value>();
+
+ r->type->read(reference->object, reference->property);
+ } else {
+ Q_ASSERT(r->objectType == QV8ValueTypeResource::Copy);
+
+ QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(r);
+
+ r->type->setValue(copy->value);
+ }
+
+#define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \
+ if (result->propType == metatype) { \
+ cpptype v; \
+ void *args[] = { &v, 0 }; \
+ r->type->qt_metacall(QMetaObject::ReadProperty, result->coreIndex, args); \
+ return constructor(v); \
+ }
+
+ // These four types are the most common used by the value type wrappers
+ VALUE_TYPE_LOAD(QMetaType::QReal, qreal, v8::Number::New);
+ VALUE_TYPE_LOAD(QMetaType::Int, int, v8::Integer::New);
+ VALUE_TYPE_LOAD(QMetaType::QString, QString, r->engine->toString);
+ VALUE_TYPE_LOAD(QMetaType::Bool, bool, v8::Boolean::New);
+
+ QVariant v(result->propType, (void *)0);
+ void *args[] = { v.data(), 0 };
+ r->type->qt_metacall(QMetaObject::ReadProperty, result->coreIndex, args);
+ return r->engine->fromVariant(v);
+#undef VALUE_TYPE_ACCESSOR
+}
+
+v8::Handle<v8::Value> QV8ValueTypeWrapper::Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info)
+{
+ QV8ValueTypeResource *r = v8_resource_cast<QV8ValueTypeResource>(info.This());
+ if (!r) return value;
+
+ QByteArray propName = r->engine->toString(property).toUtf8();
+ int index = r->type->metaObject()->indexOfProperty(propName.constData());
+ if (index == -1)
+ return value;
+
+ if (r->objectType == QV8ValueTypeResource::Reference) {
+ QV8ValueTypeReferenceResource *reference = static_cast<QV8ValueTypeReferenceResource *>(r);
+
+ if (!reference->object ||
+ !reference->object->metaObject()->property(reference->property).isWritable())
+ return value;
+
+ r->type->read(reference->object, reference->property);
+ QMetaProperty p = r->type->metaObject()->property(index);
+
+ QQmlBinding *newBinding = 0;
+
+ if (value->IsFunction()) {
+ QQmlContextData *context = r->engine->callingContext();
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
+
+ QQmlPropertyData cacheData;
+ cacheData.setFlags(QQmlPropertyData::IsWritable |
+ QQmlPropertyData::IsValueTypeVirtual);
+ cacheData.propType = reference->object->metaObject()->property(reference->property).userType();
+ cacheData.coreIndex = reference->property;
+ cacheData.valueTypeFlags = 0;
+ cacheData.valueTypeCoreIndex = index;
+ cacheData.valueTypePropType = p.userType();
+
+ v8::Local<v8::StackTrace> trace =
+ v8::StackTrace::CurrentStackTrace(1,
+ (v8::StackTrace::StackTraceOptions)(v8::StackTrace::kLineNumber |
+ v8::StackTrace::kScriptName));
+ v8::Local<v8::StackFrame> frame = trace->GetFrame(0);
+ int lineNumber = frame->GetLineNumber();
+ int columnNumber = frame->GetColumn();
+ QString url = r->engine->toString(frame->GetScriptName());
+
+ newBinding = new QQmlBinding(&function, reference->object, context);
+ newBinding->setSourceLocation(url, lineNumber, columnNumber);
+ newBinding->setTarget(reference->object, cacheData, context);
+ newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
+ QQmlBinding::RequiresThisObject);
+ }
+
+ QQmlAbstractBinding *oldBinding =
+ QQmlPropertyPrivate::setBinding(reference->object, reference->property, index, newBinding);
+ if (oldBinding)
+ oldBinding->destroy();
+
+ if (!value->IsFunction()) {
+ QVariant v = r->engine->toVariant(value, -1);
+
+ if (p.isEnumType() && (QMetaType::Type)v.type() == QMetaType::Double)
+ v = v.toInt();
+
+ p.write(reference->type, v);
+
+ reference->type->write(reference->object, reference->property, 0);
+ }
+
+ } else {
+ Q_ASSERT(r->objectType == QV8ValueTypeResource::Copy);
+
+ QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(r);
+
+ QVariant v = r->engine->toVariant(value, -1);
+
+ r->type->setValue(copy->value);
+ QMetaProperty p = r->type->metaObject()->property(index);
+ p.write(r->type, v);
+ copy->value = r->type->value();
+ }
+
+ return value;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8valuetypewrapper_p.h b/src/qml/qml/v8/qv8valuetypewrapper_p.h
new file mode 100644
index 0000000000..b80d3cbbba
--- /dev/null
+++ b/src/qml/qml/v8/qv8valuetypewrapper_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8VALUETYPEWRAPPER_P_H
+#define QV8VALUETYPEWRAPPER_P_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 <QtQml/qqmllist.h>
+#include <private/qv8_p.h>
+#include <private/qhashedstring_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+class QV8ObjectResource;
+class QQmlValueType;
+class QV8ValueTypeWrapper
+{
+public:
+ QV8ValueTypeWrapper();
+ ~QV8ValueTypeWrapper();
+
+ void init(QV8Engine *);
+ void destroy();
+
+ v8::Local<v8::Object> newValueType(QObject *, int, QQmlValueType *);
+ v8::Local<v8::Object> newValueType(const QVariant &, QQmlValueType *);
+
+ QVariant toVariant(v8::Handle<v8::Object>);
+ QVariant toVariant(QV8ObjectResource *);
+
+ static bool isEqual(QV8ObjectResource *, const QVariant& value);
+
+private:
+ static v8::Handle<v8::Value> ToStringGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> ToString(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info);
+
+ QV8Engine *m_engine;
+ v8::Persistent<v8::Function> m_constructor;
+ v8::Persistent<v8::Function> m_toString;
+ v8::Persistent<v8::String> m_toStringSymbol;
+ QHashedV8String m_toStringString;
+};
+
+QT_END_NAMESPACE
+
+#endif // QV8VALUETYPEWRAPPER_P_H
+
+
diff --git a/src/qml/qml/v8/qv8variantresource_p.h b/src/qml/qml/v8/qv8variantresource_p.h
new file mode 100644
index 0000000000..0b6328cb54
--- /dev/null
+++ b/src/qml/qml/v8/qv8variantresource_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8VARIANTRESOURCE_P_H
+#define QV8VARIANTRESOURCE_P_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 <private/qv8_p.h>
+#include <private/qv8engine_p.h>
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8VariantResource : public QV8ObjectResource,
+ public QQmlEnginePrivate::ScarceResourceData
+{
+ V8_RESOURCE_TYPE(VariantType)
+
+public:
+ QV8VariantResource(QV8Engine *engine, const QVariant &data);
+
+ void addVmePropertyReference();
+ void removeVmePropertyReference();
+
+ bool m_isScarceResource;
+ int m_vmePropertyReferenceCount;
+};
+
+QT_END_NAMESPACE
+
+#endif // QV8VARIANTRESOURCE_P_H
+
diff --git a/src/qml/qml/v8/qv8variantwrapper.cpp b/src/qml/qml/v8/qv8variantwrapper.cpp
new file mode 100644
index 0000000000..4b1fc643f6
--- /dev/null
+++ b/src/qml/qml/v8/qv8variantwrapper.cpp
@@ -0,0 +1,279 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8variantwrapper_p.h"
+#include "qv8variantresource_p.h"
+#include "qv8engine_p.h"
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QV8VariantResource::QV8VariantResource(QV8Engine *engine, const QVariant &data)
+: QV8ObjectResource(engine), QQmlEnginePrivate::ScarceResourceData(data), m_isScarceResource(false), m_vmePropertyReferenceCount(0)
+{
+}
+
+void QV8VariantResource::addVmePropertyReference()
+{
+ if (m_isScarceResource && ++m_vmePropertyReferenceCount == 1) {
+ // remove from the ep->scarceResources list
+ // since it is now no longer eligible to be
+ // released automatically by the engine.
+ node.remove();
+ }
+}
+
+void QV8VariantResource::removeVmePropertyReference()
+{
+ if (m_isScarceResource && --m_vmePropertyReferenceCount == 0) {
+ // and add to the ep->scarceResources list
+ // since it is now eligible to be released
+ // automatically by the engine.
+ QQmlEnginePrivate::get(engine->engine())->scarceResources.insert(this);
+ }
+}
+
+QV8VariantWrapper::QV8VariantWrapper()
+: m_engine(0)
+{
+}
+
+QV8VariantWrapper::~QV8VariantWrapper()
+{
+}
+
+void QV8VariantWrapper::init(QV8Engine *engine)
+{
+ m_engine = engine;
+ m_toString = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ToString)->GetFunction());
+ m_valueOf = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(ValueOf)->GetFunction());
+
+ {
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
+ m_toString, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("valueOf"), ValueOfGetter, 0,
+ m_valueOf, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ }
+ {
+ m_preserve = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(Preserve)->GetFunction());
+ m_destroy = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(Destroy)->GetFunction());
+ v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
+ ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+ ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("preserve"), PreserveGetter, 0,
+ m_preserve, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("destroy"), DestroyGetter, 0,
+ m_destroy, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("toString"), ToStringGetter, 0,
+ m_toString, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("valueOf"), ValueOfGetter, 0,
+ m_valueOf, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
+ m_scarceConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ }
+
+}
+
+void QV8VariantWrapper::destroy()
+{
+ qPersistentDispose(m_valueOf);
+ qPersistentDispose(m_toString);
+ qPersistentDispose(m_destroy);
+ qPersistentDispose(m_preserve);
+ qPersistentDispose(m_scarceConstructor);
+ qPersistentDispose(m_constructor);
+}
+
+v8::Local<v8::Object> QV8VariantWrapper::newVariant(const QVariant &value)
+{
+ bool scarceResource = value.type() == QVariant::Pixmap ||
+ value.type() == QVariant::Image;
+
+ // XXX NewInstance() should be optimized
+ v8::Local<v8::Object> rv;
+ QV8VariantResource *r = new QV8VariantResource(m_engine, value);
+
+ if (scarceResource) {
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_engine->engine());
+ Q_ASSERT(ep->scarceResourcesRefCount);
+ rv = m_scarceConstructor->NewInstance();
+ r->m_isScarceResource = true;
+ ep->scarceResources.insert(r);
+ } else {
+ rv = m_constructor->NewInstance();
+ }
+
+ rv->SetExternalResource(r);
+ return rv;
+}
+
+bool QV8VariantWrapper::isVariant(v8::Handle<v8::Value> value)
+{
+ return value->IsObject() && v8_resource_cast<QV8VariantResource>(value->ToObject());
+}
+
+QVariant QV8VariantWrapper::toVariant(v8::Handle<v8::Object> obj)
+{
+ QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(obj);
+ return r?r->data:QVariant();
+}
+
+QVariant QV8VariantWrapper::toVariant(QV8ObjectResource *r)
+{
+ Q_ASSERT(r->resourceType() == QV8ObjectResource::VariantType);
+ return static_cast<QV8VariantResource *>(r)->data;
+}
+
+QVariant &QV8VariantWrapper::variantValue(v8::Handle<v8::Value> value)
+{
+ Q_ASSERT(isVariant(value));
+ QV8VariantResource *r = v8_resource_cast<QV8VariantResource>(value->ToObject());
+ return static_cast<QV8VariantResource *>(r)->data;
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::Getter(v8::Local<v8::String> /* property */,
+ const v8::AccessorInfo & /* info */)
+{
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::Setter(v8::Local<v8::String> /* property */,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo & /* info */)
+{
+ return value;
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::PreserveGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::DestroyGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::ToStringGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::ValueOfGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::Preserve(const v8::Arguments &args)
+{
+ QV8VariantResource *resource = v8_resource_cast<QV8VariantResource>(args.This());
+ if (resource) {
+ resource->node.remove();
+ }
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::Destroy(const v8::Arguments &args)
+{
+ QV8VariantResource *resource = v8_resource_cast<QV8VariantResource>(args.This());
+ if (resource) {
+ resource->data = QVariant();
+ resource->node.remove();
+ }
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::ToString(const v8::Arguments &args)
+{
+ QV8VariantResource *resource = v8_resource_cast<QV8VariantResource>(args.This());
+ if (resource) {
+ QString result = resource->data.toString();
+ if (result.isEmpty() && !resource->data.canConvert(QVariant::String))
+ result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(resource->data.typeName()));
+ return resource->engine->toString(result);
+ } else {
+ return v8::Undefined();
+ }
+}
+
+v8::Handle<v8::Value> QV8VariantWrapper::ValueOf(const v8::Arguments &args)
+{
+ QV8VariantResource *resource = v8_resource_cast<QV8VariantResource>(args.This());
+ if (resource) {
+ QVariant v = resource->data;
+ switch (v.type()) {
+ case QVariant::Invalid:
+ return v8::Undefined();
+ case QVariant::String:
+ return resource->engine->toString(v.toString());
+ case QVariant::Int:
+ case QVariant::Double:
+ case QVariant::UInt:
+ return v8::Number::New(v.toDouble());
+ case QVariant::Bool:
+ return v8::Boolean::New(v.toBool());
+ default:
+ break;
+ }
+ }
+ return args.This();
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv8variantwrapper_p.h b/src/qml/qml/v8/qv8variantwrapper_p.h
new file mode 100644
index 0000000000..877155c8ca
--- /dev/null
+++ b/src/qml/qml/v8/qv8variantwrapper_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8VARIANTWRAPPER_P_H
+#define QV8VARIANTWRAPPER_P_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 <QtQml/qqmllist.h>
+#include <private/qv8_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QV8Engine;
+class QV8ObjectResource;
+class QV8VariantWrapper
+{
+public:
+ QV8VariantWrapper();
+ ~QV8VariantWrapper();
+
+ void init(QV8Engine *);
+ void destroy();
+
+ v8::Local<v8::Object> newVariant(const QVariant &);
+ bool isVariant(v8::Handle<v8::Value>);
+ static QVariant toVariant(v8::Handle<v8::Object>);
+ static QVariant toVariant(QV8ObjectResource *);
+ QVariant &variantValue(v8::Handle<v8::Value>);
+
+private:
+ static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> PreserveGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> DestroyGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> ToStringGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> ValueOfGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> Preserve(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Destroy(const v8::Arguments &args);
+ static v8::Handle<v8::Value> ToString(const v8::Arguments &args);
+ static v8::Handle<v8::Value> ValueOf(const v8::Arguments &args);
+
+ QV8Engine *m_engine;
+ v8::Persistent<v8::Function> m_constructor;
+ v8::Persistent<v8::Function> m_scarceConstructor;
+ v8::Persistent<v8::Function> m_preserve;
+ v8::Persistent<v8::Function> m_destroy;
+ v8::Persistent<v8::Function> m_toString;
+ v8::Persistent<v8::Function> m_valueOf;
+};
+
+QT_END_NAMESPACE
+
+#endif // QV8VARIANTWRAPPER_P_H
+
diff --git a/src/qml/qml/v8/qv8worker.cpp b/src/qml/qml/v8/qv8worker.cpp
new file mode 100644
index 0000000000..6ea527166c
--- /dev/null
+++ b/src/qml/qml/v8/qv8worker.cpp
@@ -0,0 +1,392 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv8worker_p.h"
+
+#include <private/qquicklistmodel_p.h>
+#include <private/qquicklistmodelworkeragent_p.h>
+
+QT_BEGIN_NAMESPACE
+
+// We allow the following JavaScript types to be passed between the main and
+// the secondary thread:
+// + undefined
+// + null
+// + Boolean
+// + String
+// + Function
+// + Array
+// + "Simple" Objects
+// + Number
+// + Date
+// + RegExp
+// <quint8 type><quint24 size><data>
+
+enum Type {
+ WorkerUndefined,
+ WorkerNull,
+ WorkerTrue,
+ WorkerFalse,
+ WorkerString,
+ WorkerFunction,
+ WorkerArray,
+ WorkerObject,
+ WorkerInt32,
+ WorkerUint32,
+ WorkerNumber,
+ WorkerDate,
+ WorkerRegexp,
+ WorkerListModel,
+ WorkerSequence
+};
+
+static inline quint32 valueheader(Type type, quint32 size = 0)
+{
+ return quint8(type) << 24 | (size & 0xFFFFFF);
+}
+
+static inline Type headertype(quint32 header)
+{
+ return (Type)(header >> 24);
+}
+
+static inline quint32 headersize(quint32 header)
+{
+ return header & 0xFFFFFF;
+}
+
+static inline void push(QByteArray &data, quint32 value)
+{
+ data.append((const char *)&value, sizeof(quint32));
+}
+
+static inline void push(QByteArray &data, double value)
+{
+ data.append((const char *)&value, sizeof(double));
+}
+
+static inline void push(QByteArray &data, void *ptr)
+{
+ data.append((const char *)&ptr, sizeof(void *));
+}
+
+static inline void reserve(QByteArray &data, int extra)
+{
+ data.reserve(data.size() + extra);
+}
+
+static inline quint32 popUint32(const char *&data)
+{
+ quint32 rv = *((quint32 *)data);
+ data += sizeof(quint32);
+ return rv;
+}
+
+static inline double popDouble(const char *&data)
+{
+ double rv = *((double *)data);
+ data += sizeof(double);
+ return rv;
+}
+
+static inline void *popPtr(const char *&data)
+{
+ void *rv = *((void **)data);
+ data += sizeof(void *);
+ return rv;
+}
+
+// XXX TODO: Check that worker script is exception safe in the case of
+// serialization/deserialization failures
+
+#define ALIGN(size) (((size) + 3) & ~3)
+void QV8Worker::serialize(QByteArray &data, v8::Handle<v8::Value> v, QV8Engine *engine)
+{
+ if (v.IsEmpty()) {
+ } else if (v->IsUndefined()) {
+ push(data, valueheader(WorkerUndefined));
+ } else if (v->IsNull()) {
+ push(data, valueheader(WorkerNull));
+ } else if (v->IsTrue()) {
+ push(data, valueheader(WorkerTrue));
+ } else if (v->IsFalse()) {
+ push(data, valueheader(WorkerFalse));
+ } else if (v->IsString()) {
+ v8::Handle<v8::String> string = v->ToString();
+ int length = string->Length() + 1;
+ if (length > 0xFFFFFF) {
+ push(data, valueheader(WorkerUndefined));
+ return;
+ }
+ int utf16size = ALIGN(length * sizeof(uint16_t));
+
+ reserve(data, utf16size + sizeof(quint32));
+ push(data, valueheader(WorkerString, length));
+
+ int offset = data.size();
+ data.resize(data.size() + utf16size);
+ char *buffer = data.data() + offset;
+
+ string->Write((uint16_t*)buffer);
+ } else if (v->IsFunction()) {
+ // XXX TODO: Implement passing function objects between the main and
+ // worker scripts
+ push(data, valueheader(WorkerUndefined));
+ } else if (v->IsArray()) {
+ v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(v);
+ uint32_t length = array->Length();
+ if (length > 0xFFFFFF) {
+ push(data, valueheader(WorkerUndefined));
+ return;
+ }
+ reserve(data, sizeof(quint32) + length * sizeof(quint32));
+ push(data, valueheader(WorkerArray, length));
+ for (uint32_t ii = 0; ii < length; ++ii)
+ serialize(data, array->Get(ii), engine);
+ } else if (v->IsInt32()) {
+ reserve(data, 2 * sizeof(quint32));
+ push(data, valueheader(WorkerInt32));
+ push(data, (quint32)v->Int32Value());
+ } else if (v->IsUint32()) {
+ reserve(data, 2 * sizeof(quint32));
+ push(data, valueheader(WorkerUint32));
+ push(data, v->Uint32Value());
+ } else if (v->IsNumber()) {
+ reserve(data, sizeof(quint32) + sizeof(double));
+ push(data, valueheader(WorkerNumber));
+ push(data, v->NumberValue());
+ } else if (v->IsDate()) {
+ reserve(data, sizeof(quint32) + sizeof(double));
+ push(data, valueheader(WorkerDate));
+ push(data, v8::Handle<v8::Date>::Cast(v)->NumberValue());
+ } else if (v->IsRegExp()) {
+ v8::Handle<v8::RegExp> regexp = v8::Handle<v8::RegExp>::Cast(v);
+ quint32 flags = regexp->GetFlags();
+ v8::Local<v8::String> source = regexp->GetSource();
+
+ int length = source->Length() + 1;
+ if (length > 0xFFFFFF) {
+ push(data, valueheader(WorkerUndefined));
+ return;
+ }
+ int utf16size = ALIGN(length * sizeof(uint16_t));
+
+ reserve(data, sizeof(quint32) + utf16size);
+ push(data, valueheader(WorkerRegexp, flags));
+ push(data, (quint32)length);
+ int offset = data.size();
+ data.resize(data.size() + utf16size);
+ char *buffer = data.data() + offset;
+
+ source->Write((uint16_t*)buffer);
+ } else if (v->IsObject() && !v->ToObject()->GetExternalResource()) {
+ v8::Handle<v8::Object> object = v->ToObject();
+ v8::Local<v8::Array> properties = engine->getOwnPropertyNames(object);
+ quint32 length = properties->Length();
+ if (length > 0xFFFFFF) {
+ push(data, valueheader(WorkerUndefined));
+ return;
+ }
+ push(data, valueheader(WorkerObject, length));
+ v8::TryCatch tc;
+ for (quint32 ii = 0; ii < length; ++ii) {
+ v8::Local<v8::String> str = properties->Get(ii)->ToString();
+ serialize(data, str, engine);
+
+ v8::Local<v8::Value> val = object->Get(str);
+ if (tc.HasCaught()) {
+ serialize(data, v8::Undefined(), engine);
+ tc.Reset();
+ } else {
+ serialize(data, val, engine);
+ }
+ }
+ } else if (engine->isQObject(v)) {
+ // XXX TODO: Generalize passing objects between the main thread and worker scripts so
+ // that others can trivially plug in their elements.
+ QQuickListModel *lm = qobject_cast<QQuickListModel *>(engine->toQObject(v));
+ if (lm && lm->agent()) {
+ QQuickListModelWorkerAgent *agent = lm->agent();
+ agent->addref();
+ push(data, valueheader(WorkerListModel));
+ push(data, (void *)agent);
+ return;
+ }
+ // No other QObject's are allowed to be sent
+ push(data, valueheader(WorkerUndefined));
+ } else {
+ // we can convert sequences, but not other types with external data.
+ if (v->IsObject()) {
+ v8::Handle<v8::Object> seqObj = v->ToObject();
+ QV8ObjectResource *r = static_cast<QV8ObjectResource *>(seqObj->GetExternalResource());
+ if (r->resourceType() == QV8ObjectResource::SequenceType) {
+ QVariant sequenceVariant = engine->sequenceWrapper()->toVariant(r);
+ if (!sequenceVariant.isNull()) {
+ // valid sequence. we generate a length (sequence length + 1 for the sequence type)
+ uint32_t seqLength = engine->sequenceWrapper()->sequenceLength(r);
+ uint32_t length = seqLength + 1;
+ if (length > 0xFFFFFF) {
+ push(data, valueheader(WorkerUndefined));
+ return;
+ }
+ reserve(data, sizeof(quint32) + length * sizeof(quint32));
+ push(data, valueheader(WorkerSequence, length));
+ serialize(data, v8::Integer::New(sequenceVariant.userType()), engine); // sequence type
+ for (uint32_t ii = 0; ii < seqLength; ++ii) {
+ serialize(data, seqObj->Get(ii), engine); // sequence elements
+ }
+
+ return;
+ }
+ }
+ }
+
+ // not a sequence.
+ push(data, valueheader(WorkerUndefined));
+ }
+}
+
+v8::Handle<v8::Value> QV8Worker::deserialize(const char *&data, QV8Engine *engine)
+{
+ quint32 header = popUint32(data);
+ Type type = headertype(header);
+
+ switch (type) {
+ case WorkerUndefined:
+ return v8::Undefined();
+ case WorkerNull:
+ return v8::Null();
+ case WorkerTrue:
+ return v8::True();
+ case WorkerFalse:
+ return v8::False();
+ case WorkerString:
+ {
+ quint32 size = headersize(header);
+ v8::Local<v8::String> string = v8::String::New((uint16_t*)data, size - 1);
+ data += ALIGN(size * sizeof(uint16_t));
+ return string;
+ }
+ case WorkerFunction:
+ Q_ASSERT(!"Unreachable");
+ break;
+ case WorkerArray:
+ {
+ quint32 size = headersize(header);
+ v8::Local<v8::Array> array = v8::Array::New(size);
+ for (quint32 ii = 0; ii < size; ++ii) {
+ array->Set(ii, deserialize(data, engine));
+ }
+ return array;
+ }
+ case WorkerObject:
+ {
+ quint32 size = headersize(header);
+ v8::Local<v8::Object> o = v8::Object::New();
+ for (quint32 ii = 0; ii < size; ++ii) {
+ v8::Handle<v8::Value> name = deserialize(data, engine);
+ v8::Handle<v8::Value> value = deserialize(data, engine);
+ o->Set(name, value);
+ }
+ return o;
+ }
+ case WorkerInt32:
+ return v8::Integer::New((qint32)popUint32(data));
+ case WorkerUint32:
+ return v8::Integer::NewFromUnsigned(popUint32(data));
+ case WorkerNumber:
+ return v8::Number::New(popDouble(data));
+ case WorkerDate:
+ return v8::Date::New(popDouble(data));
+ case WorkerRegexp:
+ {
+ quint32 flags = headersize(header);
+ quint32 length = popUint32(data);
+ v8::Local<v8::String> source = v8::String::New((uint16_t*)data, length - 1);
+ data += ALIGN(length * sizeof(uint16_t));
+ return v8::RegExp::New(source, (v8::RegExp::Flags)flags);
+ }
+ case WorkerListModel:
+ {
+ void *ptr = popPtr(data);
+ QQuickListModelWorkerAgent *agent = (QQuickListModelWorkerAgent *)ptr;
+ v8::Handle<v8::Value> rv = engine->newQObject(agent);
+ if (rv->IsObject()) {
+ QQuickListModelWorkerAgent::VariantRef ref(agent);
+ QVariant var = qVariantFromValue(ref);
+ rv->ToObject()->SetHiddenValue(v8::String::New("qml::ref"), engine->fromVariant(var));
+ }
+ agent->release();
+ agent->setV8Engine(engine);
+ return rv;
+ }
+ case WorkerSequence:
+ {
+ bool succeeded = false;
+ quint32 length = headersize(header);
+ quint32 seqLength = length - 1;
+ int sequenceType = deserialize(data, engine)->Int32Value();
+ v8::Local<v8::Array> array = v8::Array::New(seqLength);
+ for (quint32 ii = 0; ii < seqLength; ++ii)
+ array->Set(ii, deserialize(data, engine));
+ QVariant seqVariant = engine->sequenceWrapper()->toVariant(array, sequenceType, &succeeded);
+ return engine->sequenceWrapper()->fromVariant(seqVariant, &succeeded);
+ }
+ }
+ Q_ASSERT(!"Unreachable");
+ return v8::Undefined();
+}
+
+QByteArray QV8Worker::serialize(v8::Handle<v8::Value> value, QV8Engine *engine)
+{
+ QByteArray rv;
+ serialize(rv, value, engine);
+ return rv;
+}
+
+v8::Handle<v8::Value> QV8Worker::deserialize(const QByteArray &data, QV8Engine *engine)
+{
+ const char *stream = data.constData();
+ return deserialize(stream, engine);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/qml/v8/qv8worker_p.h b/src/qml/qml/v8/qv8worker_p.h
new file mode 100644
index 0000000000..d398d21f60
--- /dev/null
+++ b/src/qml/qml/v8/qv8worker_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV8WORKER_P_H
+#define QV8WORKER_P_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 "qv8engine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QV8Worker {
+public:
+ struct SavedData {
+ };
+
+ static QByteArray serialize(v8::Handle<v8::Value>, QV8Engine *);
+ static v8::Handle<v8::Value> deserialize(const QByteArray &, QV8Engine *);
+
+private:
+ static void serialize(QByteArray &, v8::Handle<v8::Value>, QV8Engine *);
+ static v8::Handle<v8::Value> deserialize(const char *&, QV8Engine *);
+};
+
+QT_END_NAMESPACE
+
+#endif // QV8WORKER_P_H
diff --git a/src/declarative/qml/v8/script.pri b/src/qml/qml/v8/script.pri
index 3439413f5e..3439413f5e 100644
--- a/src/declarative/qml/v8/script.pri
+++ b/src/qml/qml/v8/script.pri
diff --git a/src/qml/qml/v8/v8.pri b/src/qml/qml/v8/v8.pri
new file mode 100644
index 0000000000..de492a8ce5
--- /dev/null
+++ b/src/qml/qml/v8/v8.pri
@@ -0,0 +1,45 @@
+INCLUDEPATH += $$PWD/../../../3rdparty/javascriptcore
+
+include(script.pri)
+
+HEADERS += \
+ $$PWD/qv8_p.h \
+ $$PWD/qv8debug_p.h \
+ $$PWD/qv8profiler_p.h \
+ $$PWD/qv8stringwrapper_p.h \
+ $$PWD/qv8engine_p.h \
+ $$PWD/qv8sequencewrapper_p.h \
+ $$PWD/qv8sequencewrapper_p_p.h \
+ $$PWD/qv8contextwrapper_p.h \
+ $$PWD/qv8qobjectwrapper_p.h \
+ $$PWD/qv8typewrapper_p.h \
+ $$PWD/qv8listwrapper_p.h \
+ $$PWD/qv8variantwrapper_p.h \
+ $$PWD/qv8variantresource_p.h \
+ $$PWD/qv8valuetypewrapper_p.h \
+ $$PWD/qv8include_p.h \
+ $$PWD/qv8worker_p.h \
+ $$PWD/qv8bindings_p.h \
+ $$PWD/../../../3rdparty/javascriptcore/DateMath.h \
+ $$PWD/qv8engine_impl_p.h \
+ $$PWD/qv8domerrors_p.h \
+ $$PWD/qv8sqlerrors_p.h \
+ $$PWD/qqmlbuiltinfunctions_p.h
+
+SOURCES += \
+ $$PWD/qv8stringwrapper.cpp \
+ $$PWD/qv8engine.cpp \
+ $$PWD/qv8sequencewrapper.cpp \
+ $$PWD/qv8contextwrapper.cpp \
+ $$PWD/qv8qobjectwrapper.cpp \
+ $$PWD/qv8typewrapper.cpp \
+ $$PWD/qv8listwrapper.cpp \
+ $$PWD/qv8variantwrapper.cpp \
+ $$PWD/qv8valuetypewrapper.cpp \
+ $$PWD/qv8include.cpp \
+ $$PWD/qv8worker.cpp \
+ $$PWD/qv8bindings.cpp \
+ $$PWD/../../../3rdparty/javascriptcore/DateMath.cpp \
+ $$PWD/qv8domerrors.cpp \
+ $$PWD/qv8sqlerrors.cpp \
+ $$PWD/qqmlbuiltinfunctions.cpp \ No newline at end of file
diff --git a/src/qml/qtqmlglobal.h b/src/qml/qtqmlglobal.h
new file mode 100644
index 0000000000..65277e60a9
--- /dev/null
+++ b/src/qml/qtqmlglobal.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTQMLGLOBAL_H
+#define QTQMLGLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(Q_OS_WIN)
+# if defined(QT_MAKEDLL) /* create a Qt DLL library */
+# if defined(QT_BUILD_QML_LIB)
+# define Q_QML_EXPORT Q_DECL_EXPORT
+# else
+# define Q_QML_EXPORT Q_DECL_IMPORT
+# endif
+# elif defined(QT_DLL) /* use a Qt DLL library */
+# define Q_QML_EXPORT Q_DECL_IMPORT
+# endif
+#endif
+
+#if !defined(Q_QML_EXPORT)
+# if defined(QT_SHARED)
+# define Q_QML_EXPORT Q_DECL_EXPORT
+# else
+# define Q_QML_EXPORT
+# endif
+#endif
+
+#endif // QTQMLGLOBAL_H
diff --git a/src/qml/qtqmlglobal_p.h b/src/qml/qtqmlglobal_p.h
new file mode 100644
index 0000000000..36926228c7
--- /dev/null
+++ b/src/qml/qtqmlglobal_p.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTQMLGLOBAL_P_H
+#define QTQMLGLOBAL_P_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 "qtqmlglobal.h"
+
+#define Q_QML_PRIVATE_EXPORT Q_QML_EXPORT
+
+#endif // QTQMLGLOBAL_P_H
diff --git a/src/qml/util/qqmlpropertymap.cpp b/src/qml/util/qqmlpropertymap.cpp
new file mode 100644
index 0000000000..5010af17c8
--- /dev/null
+++ b/src/qml/util/qqmlpropertymap.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpropertymap.h"
+
+#include <private/qmetaobjectbuilder_p.h>
+#include <private/qqmlopenmetaobject_p.h>
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+//QQmlPropertyMapMetaObject lets us listen for changes coming from QML
+//so we can emit the changed signal.
+class QQmlPropertyMapMetaObject : public QQmlOpenMetaObject
+{
+public:
+ QQmlPropertyMapMetaObject(QQmlPropertyMap *obj, QQmlPropertyMapPrivate *objPriv);
+
+protected:
+ virtual void propertyWritten(int index);
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
+ virtual int createProperty(const char *, const char *);
+private:
+ QQmlPropertyMap *map;
+ QQmlPropertyMapPrivate *priv;
+};
+
+class QQmlPropertyMapPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlPropertyMap)
+public:
+ QQmlPropertyMapMetaObject *mo;
+ QStringList keys;
+ void emitChanged(const QString &key, const QVariant &value);
+ bool validKeyName(const QString& name);
+};
+
+bool QQmlPropertyMapPrivate::validKeyName(const QString& name)
+{
+ //The following strings shouldn't be used as property names
+ return name != QLatin1String("keys")
+ && name != QLatin1String("valueChanged")
+ && name != QLatin1String("QObject")
+ && name != QLatin1String("destroyed")
+ && name != QLatin1String("deleteLater");
+}
+
+void QQmlPropertyMapPrivate::emitChanged(const QString &key, const QVariant &value)
+{
+ Q_Q(QQmlPropertyMap);
+ emit q->valueChanged(key, value);
+}
+
+QQmlPropertyMapMetaObject::QQmlPropertyMapMetaObject(QQmlPropertyMap *obj, QQmlPropertyMapPrivate *objPriv) : QQmlOpenMetaObject(obj)
+{
+ map = obj;
+ priv = objPriv;
+}
+
+void QQmlPropertyMapMetaObject::propertyWritten(int index)
+{
+ priv->emitChanged(QString::fromUtf8(name(index)), operator[](index));
+}
+
+void QQmlPropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilder &b)
+{
+ priv->keys.append(QString::fromUtf8(b.name()));
+}
+
+int QQmlPropertyMapMetaObject::createProperty(const char *name, const char *value)
+{
+ if (!priv->validKeyName(QString::fromUtf8(name)))
+ return -1;
+ return QQmlOpenMetaObject::createProperty(name, value);
+}
+
+/*!
+ \class QQmlPropertyMap
+ \brief The QQmlPropertyMap class allows you to set key-value pairs that can be used in QML bindings.
+
+ QQmlPropertyMap provides a convenient way to expose domain data to the UI layer.
+ The following example shows how you might declare data in C++ and then
+ access it in QML.
+
+ In the C++ file:
+ \code
+ // create our data
+ QQmlPropertyMap ownerData;
+ ownerData.insert("name", QVariant(QString("John Smith")));
+ ownerData.insert("phone", QVariant(QString("555-5555")));
+
+ // expose it to the UI layer
+ QQuickView view;
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("owner", &ownerData);
+
+ view.setSource(QUrl::fromLocalFile("main.qml"));
+ view.show();
+ \endcode
+
+ Then, in \c main.qml:
+ \code
+ Text { text: owner.name + " " + owner.phone }
+ \endcode
+
+ The binding is dynamic - whenever a key's value is updated, anything bound to that
+ key will be updated as well.
+
+ To detect value changes made in the UI layer you can connect to the valueChanged() signal.
+ However, note that valueChanged() is \bold NOT emitted when changes are made by calling insert()
+ or clear() - it is only emitted when a value is updated from QML.
+
+ \note It is not possible to remove keys from the map; once a key has been added, you can only
+ modify or clear its associated value.
+*/
+
+/*!
+ Constructs a bindable map with parent object \a parent.
+*/
+QQmlPropertyMap::QQmlPropertyMap(QObject *parent)
+: QObject(*(new QQmlPropertyMapPrivate), parent)
+{
+ Q_D(QQmlPropertyMap);
+ d->mo = new QQmlPropertyMapMetaObject(this, d);
+}
+
+/*!
+ Destroys the bindable map.
+*/
+QQmlPropertyMap::~QQmlPropertyMap()
+{
+}
+
+/*!
+ Clears the value (if any) associated with \a key.
+*/
+void QQmlPropertyMap::clear(const QString &key)
+{
+ Q_D(QQmlPropertyMap);
+ d->mo->setValue(key.toUtf8(), QVariant());
+}
+
+/*!
+ Returns the value associated with \a key.
+
+ If no value has been set for this key (or if the value has been cleared),
+ an invalid QVariant is returned.
+*/
+QVariant QQmlPropertyMap::value(const QString &key) const
+{
+ Q_D(const QQmlPropertyMap);
+ return d->mo->value(key.toUtf8());
+}
+
+/*!
+ Sets the value associated with \a key to \a value.
+
+ If the key doesn't exist, it is automatically created.
+*/
+void QQmlPropertyMap::insert(const QString &key, const QVariant &value)
+{
+ Q_D(QQmlPropertyMap);
+
+ if (d->validKeyName(key)) {
+ d->mo->setValue(key.toUtf8(), value);
+ } else {
+ qWarning() << "Creating property with name"
+ << key
+ << "is not permitted, conflicts with internal symbols.";
+ }
+}
+
+/*!
+ Returns the list of keys.
+
+ Keys that have been cleared will still appear in this list, even though their
+ associated values are invalid QVariants.
+*/
+QStringList QQmlPropertyMap::keys() const
+{
+ Q_D(const QQmlPropertyMap);
+ return d->keys;
+}
+
+/*!
+ \overload
+
+ Same as size().
+*/
+int QQmlPropertyMap::count() const
+{
+ Q_D(const QQmlPropertyMap);
+ return d->keys.count();
+}
+
+/*!
+ Returns the number of keys in the map.
+
+ \sa isEmpty(), count()
+*/
+int QQmlPropertyMap::size() const
+{
+ Q_D(const QQmlPropertyMap);
+ return d->keys.size();
+}
+
+/*!
+ Returns true if the map contains no keys; otherwise returns
+ false.
+
+ \sa size()
+*/
+bool QQmlPropertyMap::isEmpty() const
+{
+ Q_D(const QQmlPropertyMap);
+ return d->keys.isEmpty();
+}
+
+/*!
+ Returns true if the map contains \a key.
+
+ \sa size()
+*/
+bool QQmlPropertyMap::contains(const QString &key) const
+{
+ Q_D(const QQmlPropertyMap);
+ return d->keys.contains(key);
+}
+
+/*!
+ Returns the value associated with the key \a key as a modifiable
+ reference.
+
+ If the map contains no item with key \a key, the function inserts
+ an invalid QVariant into the map with key \a key, and
+ returns a reference to it.
+
+ \sa insert(), value()
+*/
+QVariant &QQmlPropertyMap::operator[](const QString &key)
+{
+ //### optimize
+ Q_D(QQmlPropertyMap);
+ QByteArray utf8key = key.toUtf8();
+ if (!d->keys.contains(key))
+ insert(key, QVariant());//force creation -- needed below
+
+ return (*(d->mo))[utf8key];
+}
+
+/*!
+ \overload
+
+ Same as value().
+*/
+QVariant QQmlPropertyMap::operator[](const QString &key) const
+{
+ return value(key);
+}
+
+/*!
+ \fn void QQmlPropertyMap::valueChanged(const QString &key, const QVariant &value)
+ This signal is emitted whenever one of the values in the map is changed. \a key
+ is the key corresponding to the \a value that was changed.
+
+ \note valueChanged() is \bold NOT emitted when changes are made by calling insert()
+ or clear() - it is only emitted when a value is updated from QML.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/qml/util/qqmlpropertymap.h b/src/qml/util/qqmlpropertymap.h
new file mode 100644
index 0000000000..53254ab672
--- /dev/null
+++ b/src/qml/util/qqmlpropertymap.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPROPERTYMAP_H
+#define QQMLPROPERTYMAP_H
+
+#include <QtQml/qtqmlglobal.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QHash>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQmlPropertyMapPrivate;
+class Q_QML_EXPORT QQmlPropertyMap : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlPropertyMap(QObject *parent = 0);
+ virtual ~QQmlPropertyMap();
+
+ QVariant value(const QString &key) const;
+ void insert(const QString &key, const QVariant &value);
+ void clear(const QString &key);
+
+ Q_INVOKABLE QStringList keys() const;
+
+ int count() const;
+ int size() const;
+ bool isEmpty() const;
+ bool contains(const QString &key) const;
+
+ QVariant &operator[](const QString &key);
+ QVariant operator[](const QString &key) const;
+
+Q_SIGNALS:
+ void valueChanged(const QString &key, const QVariant &value);
+
+private:
+ Q_DECLARE_PRIVATE(QQmlPropertyMap)
+ Q_DISABLE_COPY(QQmlPropertyMap)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/qml/util/util.pri b/src/qml/util/util.pri
new file mode 100644
index 0000000000..3b121ba3cb
--- /dev/null
+++ b/src/qml/util/util.pri
@@ -0,0 +1,5 @@
+SOURCES += \
+ $$PWD/qqmlpropertymap.cpp
+
+HEADERS += \
+ $$PWD/qqmlpropertymap.h
diff --git a/src/qmldevtools/qmldevtools.pro b/src/qmldevtools/qmldevtools.pro
index 3aac5e5a9c..97b3788dcd 100644
--- a/src/qmldevtools/qmldevtools.pro
+++ b/src/qmldevtools/qmldevtools.pro
@@ -17,4 +17,4 @@ HEADERS += qtqmldevtoolsversion.h
unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
-include($$QT.declarative.sources/qml/parser/parser.pri)
+include($$QT.qml.sources/qml/parser/parser.pri)
diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro
index 39b7dc8a3f..d2e90c2b5d 100644
--- a/src/qmltest/qmltest.pro
+++ b/src/qmltest/qmltest.pro
@@ -7,7 +7,7 @@ CONFIG += module
CONFIG += dll warn_on declarative_debug
MODULE_PRI += ../../modules/qt_qmltest.pri
-QT += testlib-private declarative testlib quick widgets widgets-private gui
+QT += testlib-private qml testlib quick widgets widgets-private gui
DEFINES += QT_BUILD_QUICK_TEST_LIB QT_NO_URL_CAST_FROM_STRING
load(qt_module_config)
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 19acfaf6f0..e6c27eec00 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -44,15 +44,15 @@
#include <QtTest/qtestsystem.h>
#include "qtestoptions_p.h"
#include <QApplication>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
#if defined(QML_VERSION) && QML_VERSION >= 0x020000
#include <QtQuick/qquickview.h>
#define QUICK_TEST_SCENEGRAPH 1
#endif
-#include <QtDeclarative/qjsvalue.h>
-#include <QtDeclarative/qjsengine.h>
+#include <QtQml/qjsvalue.h>
+#include <QtQml/qjsengine.h>
#include <QtGui/qopengl.h>
#include <QtCore/qurl.h>
#include <QtCore/qfileinfo.h>
@@ -107,7 +107,7 @@ static inline QString stripQuotes(const QString &s)
template <class View> void handleCompileErrors(const QFileInfo &fi, const View &view)
{
// Error compiling the test - flag failure in the log and continue.
- const QList<QDeclarativeError> errors = view.errors();
+ const QList<QQmlError> errors = view.errors();
QuickTestResult results;
results.setTestCaseName(fi.baseName());
results.startLogging();
@@ -117,7 +117,7 @@ template <class View> void handleCompileErrors(const QFileInfo &fi, const View &
QTextStream str(&message);
str << "\n " << QDir::toNativeSeparators(fi.absoluteFilePath()) << " produced "
<< errors.size() << " error(s):\n";
- foreach (const QDeclarativeError &e, errors) {
+ foreach (const QQmlError &e, errors) {
str << " ";
if (e.url().isLocalFile()) {
str << e.url().toLocalFile();
@@ -129,7 +129,7 @@ template <class View> void handleCompileErrors(const QFileInfo &fi, const View &
str << ": " << e.description() << '\n';
}
str << " Working directory: " << QDir::toNativeSeparators(QDir::current().absolutePath()) << '\n';
- if (QDeclarativeEngine *engine = view.engine()) {
+ if (QQmlEngine *engine = view.engine()) {
str << " View: " << view.metaObject()->className() << ", import paths:\n";
foreach (const QString &i, engine->importPathList())
str << " '" << QDir::toNativeSeparators(i) << "'\n";
@@ -254,7 +254,7 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
}
// Scan through all of the "tst_*.qml" files and run each of them
- // in turn with a QDeclarativeView.
+ // in turn with a QQuickView.
#ifdef QUICK_TEST_SCENEGRAPH
if (qtQuick2) {
QQuickView view;
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp
index 4dee9bee77..f996adbeca 100644
--- a/src/qmltest/quicktestevent.cpp
+++ b/src/qmltest/quicktestevent.cpp
@@ -41,7 +41,7 @@
#include "quicktestevent_p.h"
#include <QtTest/qtestkeyboard.h>
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
#if defined(QML_VERSION) && QML_VERSION >= 0x020000
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickcanvas.h>
@@ -279,7 +279,7 @@ QWindow *QuickTestEvent::eventWindow()
#endif
return 0;
/*
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(parent());
+ QQuickItem *item = qobject_cast<QQuickItem *>(parent());
if (!item)
return 0;
QGraphicsScene *s = item->scene();
diff --git a/src/quick/designer/designersupport.cpp b/src/quick/designer/designersupport.cpp
index d500e0a1ee..d389190642 100644
--- a/src/quick/designer/designersupport.cpp
+++ b/src/quick/designer/designersupport.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,9 +44,9 @@
#include <QtQuick/private/qquickshadereffectsource_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qdeclarativeengine_p.h>
+#include <private/qqmlengine_p.h>
#include <private/qquickview_p.h>
-#include <QtQuick/private/qdeclarativestategroup_p.h>
+#include <QtQuick/private/qquickstategroup_p.h>
#include <QtGui/QImage>
QT_BEGIN_NAMESPACE
@@ -309,7 +309,7 @@ QQuickItem *DesignerSupport::anchorCenterInTargetItem(QQuickItem *item)
-QPair<QString, QObject*> DesignerSupport::anchorLineTarget(QQuickItem *item, const QString &name, QDeclarativeContext *context)
+QPair<QString, QObject*> DesignerSupport::anchorLineTarget(QQuickItem *item, const QString &name, QQmlContext *context)
{
QObject *targetObject = 0;
QString targetName;
@@ -319,7 +319,7 @@ QPair<QString, QObject*> DesignerSupport::anchorLineTarget(QQuickItem *item, con
} else if (name == QLatin1String("anchors.centerIn")) {
targetObject = anchors(item)->centerIn();
} else {
- QDeclarativeProperty metaProperty(item, name, context);
+ QQmlProperty metaProperty(item, name, context);
if (!metaProperty.isValid())
return QPair<QString, QObject*>();
@@ -360,7 +360,7 @@ void DesignerSupport::resetAnchor(QQuickItem *item, const QString &name)
QList<QObject*> DesignerSupport::statesForItem(QQuickItem *item)
{
QList<QObject*> objectList;
- QList<QDeclarativeState *> stateList = QQuickItemPrivate::get(item)->_states()->states();
+ QList<QQuickState *> stateList = QQuickItemPrivate::get(item)->_states()->states();
qCopy(stateList.begin(), stateList.end(), objectList.begin());
return objectList;
@@ -380,9 +380,9 @@ int DesignerSupport::borderWidth(QQuickItem *item)
return 0;
}
-void DesignerSupport::refreshExpressions(QDeclarativeContext *context)
+void DesignerSupport::refreshExpressions(QQmlContext *context)
{
- QDeclarativeContextPrivate::get(context)->data->refreshExpressions();
+ QQmlContextPrivate::get(context)->data->refreshExpressions();
}
void DesignerSupport::setRootItem(QQuickView *view, QQuickItem *item)
diff --git a/src/quick/designer/designersupport.h b/src/quick/designer/designersupport.h
index e80a537859..a31c8c3d46 100644
--- a/src/quick/designer/designersupport.h
+++ b/src/quick/designer/designersupport.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -67,7 +67,7 @@ class QQuickItem;
class QQuickShaderEffectTexture;
class QImage;
class QTransform;
-class QDeclarativeContext;
+class QQmlContext;
class QQuickView;
@@ -122,7 +122,7 @@ public:
static bool hasAnchor(QQuickItem *item, const QString &name);
static QQuickItem *anchorFillTargetItem(QQuickItem *item);
static QQuickItem *anchorCenterInTargetItem(QQuickItem *item);
- static QPair<QString, QObject*> anchorLineTarget(QQuickItem *item, const QString &name, QDeclarativeContext *context);
+ static QPair<QString, QObject*> anchorLineTarget(QQuickItem *item, const QString &name, QQmlContext *context);
static void resetAnchor(QQuickItem *item, const QString &name);
@@ -132,7 +132,7 @@ public:
static int borderWidth(QQuickItem *item);
- static void refreshExpressions(QDeclarativeContext *context);
+ static void refreshExpressions(QQmlContext *context);
static void setRootItem(QQuickView *view, QQuickItem *item);
diff --git a/src/quick/items/context2d/qquickcanvascontext.cpp b/src/quick/items/context2d/qquickcanvascontext.cpp
index 3e6e51c89d..bb1065bd6a 100644
--- a/src/quick/items/context2d/qquickcanvascontext.cpp
+++ b/src/quick/items/context2d/qquickcanvascontext.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/context2d/qquickcanvascontext_p.h b/src/quick/items/context2d/qquickcanvascontext_p.h
index 6a2edef7a8..37b5fa33fa 100644
--- a/src/quick/items/context2d/qquickcanvascontext_p.h
+++ b/src/quick/items/context2d/qquickcanvascontext_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 7031294ecc..550ab20403 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,10 +45,10 @@
#include <private/qquickcanvascontext_p.h>
#include <private/qquickcontext2d_p.h>
#include <private/qquickcanvasitemnode_p.h>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
-#include <qdeclarativeinfo.h>
-#include <private/qdeclarativeengine_p.h>
+#include <qqmlinfo.h>
+#include <private/qqmlengine_p.h>
#include <QtCore/QBuffer>
QT_BEGIN_NAMESPACE
@@ -71,7 +71,7 @@ public:
QQuickCanvasItem::RenderTarget renderTarget;
QQuickCanvasItem::RenderStrategy renderStrategy;
QString contextType;
- QHash<QUrl, QDeclarativePixmap*> images;
+ QHash<QUrl, QQuickPixmap*> images;
QUrl baseUrl;
QMap<int, v8::Persistent<v8::Function> > animationCallbacks;
};
@@ -254,13 +254,13 @@ void QQuickCanvasItem::setContextType(const QString &contextType)
this property will contain the current drawing context, otherwise null.
*/
-QDeclarativeV8Handle QQuickCanvasItem::context() const
+QQmlV8Handle QQuickCanvasItem::context() const
{
Q_D(const QQuickCanvasItem);
if (d->contextInitialized)
- return QDeclarativeV8Handle::fromHandle(d->context->v8value());
+ return QQmlV8Handle::fromHandle(d->context->v8value());
- return QDeclarativeV8Handle::fromHandle(v8::Null());
+ return QQmlV8Handle::fromHandle(v8::Null());
}
/*!
@@ -532,7 +532,7 @@ void QQuickCanvasItem::updatePolish()
foreach (int key, animationCallbacks.keys()) {
v8::HandleScope handle_scope;
- v8::Handle<v8::Object> self = QDeclarativeEnginePrivate::getV8Engine(qmlEngine(this))->newQObject(this).As<v8::Object>();
+ v8::Handle<v8::Object> self = QQmlEnginePrivate::getV8Engine(qmlEngine(this))->newQObject(this).As<v8::Object>();
v8::Handle<v8::Value> args[] = { v8::Uint32::New(QDateTime::currentDateTimeUtc().toTime_t()) };
v8::Persistent<v8::Function> f = animationCallbacks.value(key);
f->Call(self, 1, args);
@@ -591,7 +591,7 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
Canvas only supports a 2d context.
*/
-void QQuickCanvasItem::getContext(QDeclarativeV8Function *args)
+void QQuickCanvasItem::getContext(QQmlV8Function *args)
{
Q_D(QQuickCanvasItem);
@@ -633,7 +633,7 @@ void QQuickCanvasItem::getContext(QDeclarativeV8Function *args)
scene.
*/
-void QQuickCanvasItem::requestAnimationFrame(QDeclarativeV8Function *args)
+void QQuickCanvasItem::requestAnimationFrame(QQmlV8Function *args)
{
if (args->Length() < 1 || !(*args)[0]->IsFunction()) {
qmlInfo(this) << "requestAnimationFrame should be called with an animation callback function";
@@ -659,7 +659,7 @@ void QQuickCanvasItem::requestAnimationFrame(QDeclarativeV8Function *args)
This function will cancel the animation callback referenced by \a handle.
*/
-void QQuickCanvasItem::cancelRequestAnimationFrame(QDeclarativeV8Function *args)
+void QQuickCanvasItem::cancelRequestAnimationFrame(QQmlV8Function *args)
{
if (args->Length() < 1 || !(*args)[0]->IsInt32()) {
qmlInfo(this) << "cancelRequestAnimationFrame should be called with an animation callback id";
@@ -737,7 +737,7 @@ QImage QQuickCanvasItem::loadedImage(const QUrl& url)
if (!d->images.contains(fullPathUrl)) {
loadImage(url);
}
- QDeclarativePixmap* pix = d->images.value(fullPathUrl);
+ QQuickPixmap* pix = d->images.value(fullPathUrl);
if (pix->isLoading() || pix->isError()) {
return QImage();
}
@@ -760,12 +760,12 @@ void QQuickCanvasItem::loadImage(const QUrl& url)
Q_D(QQuickCanvasItem);
QUrl fullPathUrl = d->baseUrl.resolved(url);
if (!d->images.contains(fullPathUrl)) {
- QDeclarativePixmap* pix = new QDeclarativePixmap();
+ QQuickPixmap* pix = new QQuickPixmap();
d->images.insert(fullPathUrl, pix);
pix->load(qmlEngine(this)
, fullPathUrl
- , QDeclarativePixmap::Cache | QDeclarativePixmap::Asynchronous);
+ , QQuickPixmap::Cache | QQuickPixmap::Asynchronous);
if (pix->isLoading())
pix->connectFinished(this, SIGNAL(imageLoaded()));
}
@@ -918,7 +918,7 @@ void QQuickCanvasItem::initializeContext(QQuickCanvasContext *context, const QVa
d->context = context;
d->context->init(this, args);
- d->context->setV8Engine(QDeclarativeEnginePrivate::getV8Engine(qmlEngine(this)));
+ d->context->setV8Engine(QQmlEnginePrivate::getV8Engine(qmlEngine(this)));
d->contextInitialized = true;
connect(d->context, SIGNAL(textureChanged()), SLOT(update()));
connect(d->context, SIGNAL(textureChanged()), SIGNAL(painted()));
diff --git a/src/quick/items/context2d/qquickcanvasitem_p.h b/src/quick/items/context2d/qquickcanvasitem_p.h
index 0dad629eea..9a57733d4c 100644
--- a/src/quick/items/context2d/qquickcanvasitem_p.h
+++ b/src/quick/items/context2d/qquickcanvasitem_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -60,7 +60,7 @@ class Q_QUICK_EXPORT QQuickCanvasItem : public QQuickItem
Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged);
Q_PROPERTY(QString contextType READ contextType WRITE setContextType NOTIFY contextTypeChanged)
- Q_PROPERTY(QDeclarativeV8Handle context READ context NOTIFY contextChanged);
+ Q_PROPERTY(QQmlV8Handle context READ context NOTIFY contextChanged);
Q_PROPERTY(QSizeF canvasSize READ canvasSize WRITE setCanvasSize NOTIFY canvasSizeChanged)
Q_PROPERTY(QSize tileSize READ tileSize WRITE setTileSize NOTIFY tileSizeChanged)
Q_PROPERTY(QRectF canvasWindow READ canvasWindow WRITE setCanvasWindow NOTIFY canvasWindowChanged)
@@ -87,7 +87,7 @@ public:
QString contextType() const;
void setContextType(const QString &contextType);
- QDeclarativeV8Handle context() const;
+ QQmlV8Handle context() const;
QSizeF canvasSize() const;
void setCanvasSize(const QSizeF &);
@@ -108,10 +108,10 @@ public:
QImage toImage(const QRectF& rect = QRectF()) const;
- Q_INVOKABLE void getContext(QDeclarativeV8Function *args);
+ Q_INVOKABLE void getContext(QQmlV8Function *args);
- Q_INVOKABLE void requestAnimationFrame(QDeclarativeV8Function *args);
- Q_INVOKABLE void cancelRequestAnimationFrame(QDeclarativeV8Function *args);
+ Q_INVOKABLE void requestAnimationFrame(QQmlV8Function *args);
+ Q_INVOKABLE void cancelRequestAnimationFrame(QQmlV8Function *args);
Q_INVOKABLE void requestPaint();
Q_INVOKABLE void markDirty(const QRectF& dirtyRect = QRectF());
diff --git a/src/quick/items/context2d/qquickcanvasitemnode.cpp b/src/quick/items/context2d/qquickcanvasitemnode.cpp
index b9347dd33c..5a2dd80ff1 100644
--- a/src/quick/items/context2d/qquickcanvasitemnode.cpp
+++ b/src/quick/items/context2d/qquickcanvasitemnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/context2d/qquickcanvasitemnode_p.h b/src/quick/items/context2d/qquickcanvasitemnode_p.h
index 77181c64e6..7eb7d2aec5 100644
--- a/src/quick/items/context2d/qquickcanvasitemnode_p.h
+++ b/src/quick/items/context2d/qquickcanvasitemnode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index ba709b7f66..fc2ada2867 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -49,17 +49,17 @@
#include <QtCore/qdebug.h>
#include <QtQuick/private/qsgcontext_p.h>
-#include <private/qdeclarativesvgparser_p.h>
-#include <private/qdeclarativepath_p.h>
+#include <private/qquicksvgparser_p.h>
+#include <private/qquickpath_p.h>
#include <private/qquickimage_p_p.h>
#include <QtGui/qguiapplication.h>
-#include <qdeclarativeinfo.h>
+#include <qqmlinfo.h>
#include <QtCore/qmath.h>
#include <private/qv8engine_p.h>
-#include <qdeclarativeengine.h>
+#include <qqmlengine.h>
#include <private/qv8domerrors_p.h>
#include <QtCore/qnumeric.h>
@@ -1586,12 +1586,12 @@ static void ctx2d_path_set(v8::Local<v8::String>, v8::Local<v8::Value> value, co
r->context->beginPath();
if (value->IsObject()) {
- QDeclarativePath* path = qobject_cast<QDeclarativePath*>(engine->toQObject(value));
+ QQuickPath* path = qobject_cast<QQuickPath*>(engine->toQObject(value));
if (path)
r->context->m_path = path->path();
} else {
QString path = engine->toString(value->ToString());
- QDeclarativeSvgParser::parsePathDataFast(path, r->context->m_path);
+ QQuickSvgParser::parsePathDataFast(path, r->context->m_path);
}
r->context->m_v8path = value;
}
diff --git a/src/quick/items/context2d/qquickcontext2d_p.h b/src/quick/items/context2d/qquickcontext2d_p.h
index 3cabb6b198..239a244739 100644
--- a/src/quick/items/context2d/qquickcontext2d_p.h
+++ b/src/quick/items/context2d/qquickcontext2d_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,8 +43,8 @@
#define QQUICKCONTEXT2D_P_H
#include <QtQuick/qtquickglobal.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlcomponent.h>
#include <private/qquickcanvascontext_p.h>
#include <private/qquickcanvasitem_p.h>
#include <QtGui/qpainter.h>
@@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
class QQuickContext2DCommandBuffer;
class QQuickContext2DTexture;
-class QDeclarativePixmap;
+class QQuickPixmap;
class QSGTexture;
class QLockedCommandBuffer {
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
index 7342999864..591fc216a4 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -41,7 +41,7 @@
#include "qquickcontext2dcommandbuffer_p.h"
#include "qquickcanvasitem_p.h"
-#include <qdeclarative.h>
+#include <qqml.h>
#include <QtCore/QMutex>
#define HAS_SHADOW(offsetX, offsetY, blur, color) (color.isValid() && color.alpha() && (blur || offsetX || offsetY))
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
index fc4c1a3a9c..f33c43a936 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,7 +44,7 @@
#include <QtCore/qmutex.h>
#include "qquickcontext2d_p.h"
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
QT_BEGIN_HEADER
diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp
index 5d0c0ab63e..28460e2164 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/context2d/qquickcontext2dtexture_p.h b/src/quick/items/context2d/qquickcontext2dtexture_p.h
index bd4d4ff72c..9e00ece16c 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtexture_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/context2d/qquickcontext2dtile.cpp b/src/quick/items/context2d/qquickcontext2dtile.cpp
index 284cdcef83..dd416e15af 100644
--- a/src/quick/items/context2d/qquickcontext2dtile.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtile.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/context2d/qquickcontext2dtile_p.h b/src/quick/items/context2d/qquickcontext2dtile_p.h
index e05030cb88..2e6d61c8f2 100644
--- a/src/quick/items/context2d/qquickcontext2dtile_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtile_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri
index 54220434b4..b8b4e1104c 100644
--- a/src/quick/items/items.pri
+++ b/src/quick/items/items.pri
@@ -58,8 +58,8 @@ HEADERS += \
$$PWD/qquickclipnode_p.h \
$$PWD/qquickview.h \
$$PWD/qquickview_p.h \
- $$PWD/qquickanimation_p.h \
- $$PWD/qquickanimation_p_p.h \
+ $$PWD/qquickitemanimation_p.h \
+ $$PWD/qquickitemanimation_p_p.h \
$$PWD/qquickstateoperations_p.h \
$$PWD/qquickimplicitsizeitem_p.h \
$$PWD/qquickimplicitsizeitem_p_p.h \
@@ -113,7 +113,7 @@ SOURCES += \
$$PWD/qquicktranslate.cpp \
$$PWD/qquickclipnode.cpp \
$$PWD/qquickview.cpp \
- $$PWD/qquickanimation.cpp \
+ $$PWD/qquickitemanimation.cpp \
$$PWD/qquickstateoperations.cpp \
$$PWD/qquickimplicitsizeitem.cpp \
$$PWD/qquickspriteengine.cpp \
diff --git a/src/quick/items/qquickaccessibleattached.cpp b/src/quick/items/qquickaccessibleattached.cpp
index b28c28ba29..177454eedc 100644
--- a/src/quick/items/qquickaccessibleattached.cpp
+++ b/src/quick/items/qquickaccessibleattached.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h
index 02b427337e..5eea44b6e4 100644
--- a/src/quick/items/qquickaccessibleattached_p.h
+++ b/src/quick/items/qquickaccessibleattached_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp
index 2df304e15d..b7071b9598 100644
--- a/src/quick/items/qquickanchors.cpp
+++ b/src/quick/items/qquickanchors.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,7 +44,7 @@
#include "qquickitem.h"
#include "qquickitem_p.h"
-#include <qdeclarativeinfo.h>
+#include <qqmlinfo.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/items/qquickanchors_p.h b/src/quick/items/qquickanchors_p.h
index 52248db3b8..9076fbe697 100644
--- a/src/quick/items/qquickanchors_p.h
+++ b/src/quick/items/qquickanchors_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef QQUICKANCHORS_P_H
#define QQUICKANCHORS_P_H
-#include <qdeclarative.h>
+#include <qqml.h>
#include <QtCore/QObject>
diff --git a/src/quick/items/qquickanchors_p_p.h b/src/quick/items/qquickanchors_p_p.h
index b2b587932b..1814185980 100644
--- a/src/quick/items/qquickanchors_p_p.h
+++ b/src/quick/items/qquickanchors_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp
index 7bea56cc53..eef20db361 100644
--- a/src/quick/items/qquickanimatedimage.cpp
+++ b/src/quick/items/qquickanimatedimage.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,12 +44,12 @@
#ifndef QT_NO_MOVIE
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QtGui/qmovie.h>
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
-#include <private/qdeclarativeengine_p.h>
+#include <private/qqmlengine_p.h>
QT_BEGIN_NAMESPACE
/*!
@@ -82,7 +82,7 @@ QT_BEGIN_NAMESPACE
\bold Note: Unlike images, animated images are not cached or shared internally.
\clearfloat
- \snippet doc/src/snippets/declarative/animatedimage.qml document
+ \snippet doc/src/snippets/qml/animatedimage.qml document
\sa BorderImage, Image
*/
@@ -95,7 +95,7 @@ QT_BEGIN_NAMESPACE
AnimatedImage can handle any image format supported by Qt, loaded from any
URL scheme supported by Qt.
- \sa QDeclarativeImageProvider
+ \sa QQmlImageProvider
*/
/*!
@@ -264,7 +264,7 @@ void QQuickAnimatedImage::load()
if (d->progress != oldProgress)
emit progressChanged(d->progress);
} else {
- QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
+ QString lf = QQmlEnginePrivate::urlToLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
//### should be unified with movieRequestFinished
d->_movie = new QMovie(lf);
diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h
index 3c1f77d674..86910199ac 100644
--- a/src/quick/items/qquickanimatedimage_p.h
+++ b/src/quick/items/qquickanimatedimage_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickanimatedimage_p_p.h b/src/quick/items/qquickanimatedimage_p_p.h
index b1288d78a1..95142f5f1f 100644
--- a/src/quick/items/qquickanimatedimage_p_p.h
+++ b/src/quick/items/qquickanimatedimage_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index ef79d052a8..618178fd1c 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -49,7 +49,7 @@
#include <QtQuick/qsgtexturematerial.h>
#include <QtQuick/qsgtexture.h>
#include <QtQuick/qquickcanvas.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QFile>
#include <cmath>
#include <qmath.h>
@@ -454,11 +454,11 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode()
if (!m_spriteEngine) {
qmlInfo(this) << "No sprite engine...";
return 0;
- } else if (m_spriteEngine->status() == QDeclarativePixmap::Null) {
+ } else if (m_spriteEngine->status() == QQuickPixmap::Null) {
m_spriteEngine->startAssemblingImage();
update();//Schedule another update, where we will check again
return 0;
- } else if (m_spriteEngine->status() == QDeclarativePixmap::Loading) {
+ } else if (m_spriteEngine->status() == QQuickPixmap::Loading) {
update();//Schedule another update, where we will check again
return 0;
}
diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h
index 062b191621..708f94b7ec 100644
--- a/src/quick/items/qquickanimatedsprite_p.h
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickanimation.cpp b/src/quick/items/qquickanimation.cpp
deleted file mode 100644
index 641fbb2d37..0000000000
--- a/src/quick/items/qquickanimation.cpp
+++ /dev/null
@@ -1,1044 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickanimation_p.h"
-#include "qquickanimation_p_p.h"
-#include "qquickstateoperations_p.h"
-
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativepath_p.h>
-
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include <QtCore/qmath.h>
-#include "private/qsequentialanimationgroupjob_p.h"
-#include "private/qparallelanimationgroupjob_p.h"
-#include <QtGui/qtransform.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass ParentAnimation QQuickParentAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \since QtQuick 2.0
- \inherits Animation
- \brief The ParentAnimation element animates changes in parent values.
-
- ParentAnimation is used to animate a parent change for an \l Item.
-
- 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
-
- 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 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.
-
- For convenience, when a ParentAnimation is used in a \l Transition, it will
- animate any ParentChange that has occurred during the state change.
- This can be overridden by setting a specific target item using the
- \l target property.
-
- Like any other animation element, a ParentAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QQuickParentAnimation::QQuickParentAnimation(QObject *parent)
- : QDeclarativeAnimationGroup(*(new QQuickParentAnimationPrivate), parent)
-{
-}
-
-QQuickParentAnimation::~QQuickParentAnimation()
-{
-}
-
-/*!
- \qmlproperty Item QtQuick2::ParentAnimation::target
- The item to reparent.
-
- When used in a transition, if no target is specified, all
- ParentChange occurrences are animated by the ParentAnimation.
-*/
-QQuickItem *QQuickParentAnimation::target() const
-{
- Q_D(const QQuickParentAnimation);
- return d->target;
-}
-
-void QQuickParentAnimation::setTargetObject(QQuickItem *target)
-{
- Q_D(QQuickParentAnimation);
- if (target == d->target)
- return;
-
- d->target = target;
- emit targetChanged();
-}
-
-/*!
- \qmlproperty Item QtQuick2::ParentAnimation::newParent
- The new parent to animate to.
-
- If the ParentAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-*/
-QQuickItem *QQuickParentAnimation::newParent() const
-{
- Q_D(const QQuickParentAnimation);
- return d->newParent;
-}
-
-void QQuickParentAnimation::setNewParent(QQuickItem *newParent)
-{
- Q_D(QQuickParentAnimation);
- if (newParent == d->newParent)
- return;
-
- d->newParent = newParent;
- emit newParentChanged();
-}
-
-/*!
- \qmlproperty Item QtQuick2::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.
-
- \qml
- ParentAnimation {
- target: myItem
- via: topLevelItem
- // ...
- }
- \endqml
-*/
-QQuickItem *QQuickParentAnimation::via() const
-{
- Q_D(const QQuickParentAnimation);
- return d->via;
-}
-
-void QQuickParentAnimation::setVia(QQuickItem *via)
-{
- Q_D(QQuickParentAnimation);
- if (via == d->via)
- return;
-
- d->via = via;
- emit viaChanged();
-}
-
-//### mirrors same-named function in QQuickItem
-QPointF QQuickParentAnimationPrivate::computeTransformOrigin(QQuickItem::TransformOrigin origin, qreal width, qreal height) const
-{
- switch (origin) {
- default:
- case QQuickItem::TopLeft:
- return QPointF(0, 0);
- case QQuickItem::Top:
- return QPointF(width / 2., 0);
- case QQuickItem::TopRight:
- return QPointF(width, 0);
- case QQuickItem::Left:
- return QPointF(0, height / 2.);
- case QQuickItem::Center:
- return QPointF(width / 2., height / 2.);
- case QQuickItem::Right:
- return QPointF(width, height / 2.);
- case QQuickItem::BottomLeft:
- return QPointF(0, height);
- case QQuickItem::Bottom:
- return QPointF(width / 2., height);
- case QQuickItem::BottomRight:
- return QPointF(width, height);
- }
-}
-
-QAbstractAnimationJob* QQuickParentAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QQuickParentAnimation);
-
- struct QQuickParentAnimationData : public QAbstractAnimationAction
- {
- QQuickParentAnimationData() {}
- ~QQuickParentAnimationData() { qDeleteAll(pc); }
-
- QDeclarativeStateActions actions;
- //### reverse should probably apply on a per-action basis
- bool reverse;
- QList<QQuickParentChange *> pc;
- virtual void doAction()
- {
- for (int ii = 0; ii < actions.count(); ++ii) {
- const QDeclarativeAction &action = actions.at(ii);
- if (reverse)
- action.event->reverse();
- else
- action.event->execute();
- }
- }
- };
-
- QQuickParentAnimationData *data = new QQuickParentAnimationData;
- QQuickParentAnimationData *viaData = new QQuickParentAnimationData;
-
- bool hasExplicit = false;
- if (d->target && d->newParent) {
- data->reverse = false;
- QDeclarativeAction myAction;
- QQuickParentChange *pc = new QQuickParentChange;
- pc->setObject(d->target);
- pc->setParent(d->newParent);
- myAction.event = pc;
- data->pc << pc;
- data->actions << myAction;
- hasExplicit = true;
- if (d->via) {
- viaData->reverse = false;
- QDeclarativeAction myVAction;
- QQuickParentChange *vpc = new QQuickParentChange;
- vpc->setObject(d->target);
- vpc->setParent(d->via);
- myVAction.event = vpc;
- viaData->pc << vpc;
- viaData->actions << myVAction;
- }
- //### once actions have concept of modified,
- // loop to match appropriate ParentChanges and mark as modified
- }
-
- if (!hasExplicit)
- for (int i = 0; i < actions.size(); ++i) {
- QDeclarativeAction &action = actions[i];
- if (action.event && action.event->type() == QDeclarativeActionEvent::ParentChange
- && (!d->target || static_cast<QQuickParentChange*>(action.event)->object() == d->target)) {
-
- QQuickParentChange *pc = static_cast<QQuickParentChange*>(action.event);
- QDeclarativeAction myAction = action;
- data->reverse = action.reverseEvent;
-
- //### this logic differs from PropertyAnimation
- // (probably a result of modified vs. done)
- if (d->newParent) {
- QQuickParentChange *epc = new QQuickParentChange;
- epc->setObject(static_cast<QQuickParentChange*>(action.event)->object());
- epc->setParent(d->newParent);
- myAction.event = epc;
- data->pc << epc;
- data->actions << myAction;
- pc = epc;
- } else {
- action.actionDone = true;
- data->actions << myAction;
- }
-
- if (d->via) {
- viaData->reverse = false;
- QDeclarativeAction myAction;
- QQuickParentChange *vpc = new QQuickParentChange;
- vpc->setObject(pc->object());
- vpc->setParent(d->via);
- myAction.event = vpc;
- viaData->pc << vpc;
- viaData->actions << myAction;
- QDeclarativeAction dummyAction;
- QDeclarativeAction &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
- QDeclarativeAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
- QDeclarativeAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
- QDeclarativeAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
- QQuickItem *target = pc->object();
- QQuickItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent();
-
- //### this mirrors the logic in QQuickParentChange.
- bool ok;
- const QTransform &transform = targetParent->itemTransform(d->via, &ok);
- if (transform.type() >= QTransform::TxShear || !ok) {
- qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under complex transform");
- ok = false;
- }
-
- qreal scale = 1;
- qreal rotation = 0;
- bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0);
- if (ok && !isRotate) {
- if (transform.m11() == transform.m22())
- scale = transform.m11();
- else {
- qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
- ok = false;
- }
- } else if (ok && isRotate) {
- if (transform.m11() == transform.m22())
- scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
- else {
- qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
- ok = false;
- }
-
- if (scale != 0)
- rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
- else {
- qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under scale of 0");
- ok = false;
- }
- }
-
- const QPointF &point = transform.map(QPointF(xAction.toValue.toReal(),yAction.toValue.toReal()));
- qreal x = point.x();
- qreal y = point.y();
- if (ok && target->transformOrigin() != QQuickItem::TopLeft) {
- qreal w = target->width();
- qreal h = target->height();
- if (pc->widthIsSet() && i < actions.size() - 1)
- w = actions[++i].toValue.toReal();
- if (pc->heightIsSet() && i < actions.size() - 1)
- h = actions[++i].toValue.toReal();
- const QPointF &transformOrigin
- = d->computeTransformOrigin(target->transformOrigin(), w,h);
- qreal tempxt = transformOrigin.x();
- qreal tempyt = transformOrigin.y();
- QTransform t;
- t.translate(-tempxt, -tempyt);
- t.rotate(rotation);
- t.scale(scale, scale);
- t.translate(tempxt, tempyt);
- const QPointF &offset = t.map(QPointF(0,0));
- x += offset.x();
- y += offset.y();
- }
-
- if (ok) {
- //qDebug() << x << y << rotation << scale;
- xAction.toValue = x;
- yAction.toValue = y;
- sAction.toValue = sAction.toValue.toReal() * scale;
- rAction.toValue = rAction.toValue.toReal() + rotation;
- }
- }
- }
- }
-
- QSequentialAnimationGroupJob *topLevelGroup = new QSequentialAnimationGroupJob;
- QActionAnimation *viaAction = d->via ? new QActionAnimation : 0;
- QActionAnimation *targetAction = new QActionAnimation;
- //we'll assume the common case by far is to have children, and always create ag
- QParallelAnimationGroupJob *ag = new QParallelAnimationGroupJob;
-
- if (data->actions.count()) {
- if (d->via)
- viaAction->setAnimAction(viaData);
- targetAction->setAnimAction(data);
-
- //take care of any child animations
- bool valid = d->defaultProperty.isValid();
- QAbstractAnimationJob* anim;
- for (int ii = 0; ii < d->animations.count(); ++ii) {
- if (valid)
- d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
- anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
- ag->appendAnimation(anim);
- }
-
- //TODO: simplify/clarify logic
- bool forwards = direction == QDeclarativeAbstractAnimation::Forward;
- if (forwards) {
- topLevelGroup->appendAnimation(d->via ? viaAction : targetAction);
- topLevelGroup->appendAnimation(ag);
- if (d->via)
- topLevelGroup->appendAnimation(targetAction);
- } else {
- if (d->via)
- topLevelGroup->appendAnimation(targetAction);
- topLevelGroup->appendAnimation(ag);
- topLevelGroup->appendAnimation(d->via ? viaAction : targetAction);
- }
- } else {
- delete data;
- delete viaData;
- }
-
- return initInstance(topLevelGroup);
-}
-
-/*!
- \qmlclass AnchorAnimation QQuickAnchorAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits Animation
- \brief The AnchorAnimation element animates changes in anchor values.
-
- AnchorAnimation is used to animate an anchor change.
-
- In the following snippet we animate the addition of a right anchor to a \l Rectangle:
-
- \snippet doc/src/snippets/declarative/anchoranimation.qml 0
-
- For convenience, when an AnchorAnimation is used in a \l Transition, it will
- animate any AnchorChanges that have occurred during the state change.
- This can be overridden by setting a specific target item using the
- \l target property.
-
- Like any other animation element, an AnchorAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa {QML Animation and Transitions}, AnchorChanges
-*/
-QQuickAnchorAnimation::QQuickAnchorAnimation(QObject *parent)
-: QDeclarativeAbstractAnimation(*(new QQuickAnchorAnimationPrivate), parent)
-{
-}
-
-QQuickAnchorAnimation::~QQuickAnchorAnimation()
-{
-}
-
-/*!
- \qmlproperty list<Item> QtQuick2::AnchorAnimation::targets
- The items to reanchor.
-
- If no targets are specified all AnchorChanges will be
- animated by the AnchorAnimation.
-*/
-QDeclarativeListProperty<QQuickItem> QQuickAnchorAnimation::targets()
-{
- Q_D(QQuickAnchorAnimation);
- return QDeclarativeListProperty<QQuickItem>(this, d->targets);
-}
-
-/*!
- \qmlproperty int QtQuick2::AnchorAnimation::duration
- This property holds the duration of the animation, in milliseconds.
-
- The default value is 250.
-*/
-int QQuickAnchorAnimation::duration() const
-{
- Q_D(const QQuickAnchorAnimation);
- return d->duration;
-}
-
-void QQuickAnchorAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QQuickAnchorAnimation);
- if (d->duration == duration)
- return;
- d->duration = duration;
- emit durationChanged(duration);
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::AnchorAnimation::easing.type
- \qmlproperty real QtQuick2::AnchorAnimation::easing.amplitude
- \qmlproperty real QtQuick2::AnchorAnimation::easing.overshoot
- \qmlproperty real QtQuick2::AnchorAnimation::easing.period
- \brief the easing curve used for the animation.
-
- To specify an easing curve you need to specify at least the type. For some curves you can also specify
- amplitude, period and/or overshoot. The default easing curve is
- Linear.
-
- \qml
- AnchorAnimation { easing.type: Easing.InOutQuad }
- \endqml
-
- See the \l{PropertyAnimation::easing.type} documentation for information
- about the different types of easing curves.
-*/
-QEasingCurve QQuickAnchorAnimation::easing() const
-{
- Q_D(const QQuickAnchorAnimation);
- return d->easing;
-}
-
-void QQuickAnchorAnimation::setEasing(const QEasingCurve &e)
-{
- Q_D(QQuickAnchorAnimation);
- if (d->easing == e)
- return;
-
- d->easing = e;
- emit easingChanged(e);
-}
-
-QAbstractAnimationJob* QQuickAnchorAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_UNUSED(modified);
- Q_UNUSED(defaultTarget);
- Q_D(QQuickAnchorAnimation);
- QDeclarativeAnimationPropertyUpdater *data = new QDeclarativeAnimationPropertyUpdater;
- data->interpolatorType = QMetaType::QReal;
- data->interpolator = d->interpolator;
- data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = false;
-
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarativeAction &action = actions[ii];
- if (action.event && action.event->type() == QDeclarativeActionEvent::AnchorChanges
- && (d->targets.isEmpty() || d->targets.contains(static_cast<QQuickAnchorChanges*>(action.event)->object()))) {
- data->actions << static_cast<QQuickAnchorChanges*>(action.event)->additionalActions();
- }
- }
-
- QDeclarativeBulkValueAnimator *animator = new QDeclarativeBulkValueAnimator;
- if (data->actions.count()) {
- animator->setAnimValue(data);
- animator->setFromSourcedValue(&data->fromSourced);
- } else {
- delete data;
- }
-
- animator->setDuration(d->duration);
- animator->setEasingCurve(d->easing);
- return initInstance(animator);
-}
-
-/*!
- \qmlclass PathAnimation QQuickPathAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits Animation
- \since QtQuick 2.0
- \brief The PathAnimation element animates an item along a path.
-
- When used in a transition, the path can be specified without start
- or end points, for example:
- \qml
- PathAnimation {
- path: Path {
- //no startX, startY
- PathCurve { x: 100; y: 100}
- PathCurve {} //last element is empty with no end point specified
- }
- }
- \endqml
-
- In the above case, the path start will be the item's current position, and the
- path end will be the item's target position in the target state.
-
- \sa {QML Animation and Transitions}, PathInterpolator
-*/
-QQuickPathAnimation::QQuickPathAnimation(QObject *parent)
-: QDeclarativeAbstractAnimation(*(new QQuickPathAnimationPrivate), parent)
-{
-}
-
-QQuickPathAnimation::~QQuickPathAnimation()
-{
- Q_D(QQuickPathAnimation);
- QHash<QQuickItem*, QQuickPathAnimationAnimator* >::iterator it;
- for (it = d->activeAnimations.begin(); it != d->activeAnimations.end(); ++it) {
- it.value()->clearTemplate();
- }
-}
-
-/*!
- \qmlproperty int QtQuick2::PathAnimation::duration
- This property holds the duration of the animation, in milliseconds.
-
- The default value is 250.
-*/
-int QQuickPathAnimation::duration() const
-{
- Q_D(const QQuickPathAnimation);
- return d->duration;
-}
-
-void QQuickPathAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QQuickPathAnimation);
- if (d->duration == duration)
- return;
- d->duration = duration;
- emit durationChanged(duration);
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::PathAnimation::easing.type
- \qmlproperty real QtQuick2::PathAnimation::easing.amplitude
- \qmlproperty list<real> QtQuick2::PathAnimation::easing.bezierCurve
- \qmlproperty real QtQuick2::PathAnimation::easing.overshoot
- \qmlproperty real QtQuick2::PathAnimation::easing.period
- \brief the easing curve used for the animation.
-
- To specify an easing curve you need to specify at least the type. For some curves you can also specify
- amplitude, period, overshoot or custom bezierCurve data. The default easing curve is \c Easing.Linear.
-
- See the \l{PropertyAnimation::easing.type} documentation for information
- about the different types of easing curves.
-*/
-QEasingCurve QQuickPathAnimation::easing() const
-{
- Q_D(const QQuickPathAnimation);
- return d->easingCurve;
-}
-
-void QQuickPathAnimation::setEasing(const QEasingCurve &e)
-{
- Q_D(QQuickPathAnimation);
- if (d->easingCurve == e)
- return;
-
- d->easingCurve = e;
- emit easingChanged(e);
-}
-
-/*!
- \qmlproperty Path QtQuick2::PathAnimation::path
- This property holds the path to animate along.
-
- For more information on defining a path see the \l Path documentation.
-*/
-QDeclarativePath *QQuickPathAnimation::path() const
-{
- Q_D(const QQuickPathAnimation);
- return d->path;
-}
-
-void QQuickPathAnimation::setPath(QDeclarativePath *path)
-{
- Q_D(QQuickPathAnimation);
- if (d->path == path)
- return;
-
- d->path = path;
- emit pathChanged();
-}
-
-/*!
- \qmlproperty Item QtQuick2::PathAnimation::target
- This property holds the item to animate.
-*/
-QQuickItem *QQuickPathAnimation::target() const
-{
- Q_D(const QQuickPathAnimation);
- return d->target;
-}
-
-void QQuickPathAnimation::setTargetObject(QQuickItem *target)
-{
- Q_D(QQuickPathAnimation);
- if (d->target == target)
- return;
-
- d->target = target;
- emit targetChanged();
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::PathAnimation::orientation
- This property controls the rotation of the item as it animates along the path.
-
- If a value other than \c Fixed is specified, the PathAnimation will rotate the
- item to achieve the specified orientation as it travels along the path.
-
- \list
- \o PathAnimation.Fixed (default) - the PathAnimation will not control
- the rotation of the item.
- \o PathAnimation.RightFirst - The right side of the item will lead along the path.
- \o PathAnimation.LeftFirst - The left side of the item will lead along the path.
- \o PathAnimation.BottomFirst - The bottom of the item will lead along the path.
- \o PathAnimation.TopFirst - The top of the item will lead along the path.
- \endlist
-*/
-QQuickPathAnimation::Orientation QQuickPathAnimation::orientation() const
-{
- Q_D(const QQuickPathAnimation);
- return d->orientation;
-}
-
-void QQuickPathAnimation::setOrientation(Orientation orientation)
-{
- Q_D(QQuickPathAnimation);
- if (d->orientation == orientation)
- return;
-
- d->orientation = orientation;
- emit orientationChanged(d->orientation);
-}
-
-/*!
- \qmlproperty point QtQuick2::PathAnimation::anchorPoint
- This property holds the anchor point for the item being animated.
-
- By default, the upper-left corner of the target (its 0,0 point)
- will be anchored to (or follow) the path. The anchorPoint property can be used to
- specify a different point for anchoring. For example, specifying an anchorPoint of
- 5,5 for a 10x10 item means the center of the item will follow the path.
-*/
-QPointF QQuickPathAnimation::anchorPoint() const
-{
- Q_D(const QQuickPathAnimation);
- return d->anchorPoint;
-}
-
-void QQuickPathAnimation::setAnchorPoint(const QPointF &point)
-{
- Q_D(QQuickPathAnimation);
- if (d->anchorPoint == point)
- return;
-
- d->anchorPoint = point;
- emit anchorPointChanged(point);
-}
-
-/*!
- \qmlproperty real QtQuick2::PathAnimation::orientationEntryDuration
- This property holds the duration (in milliseconds) of the transition in to the orientation.
-
- If an orientation has been specified for the PathAnimation, and the starting
- rotation of the item does not match that given by the orientation,
- orientationEntryDuration can be used to smoothly transition from the item's
- starting rotation to the rotation given by the path orientation.
-*/
-int QQuickPathAnimation::orientationEntryDuration() const
-{
- Q_D(const QQuickPathAnimation);
- return d->entryDuration;
-}
-
-void QQuickPathAnimation::setOrientationEntryDuration(int duration)
-{
- Q_D(QQuickPathAnimation);
- if (d->entryDuration == duration)
- return;
- d->entryDuration = duration;
- emit orientationEntryDurationChanged(duration);
-}
-
-/*!
- \qmlproperty real QtQuick2::PathAnimation::orientationExitDuration
- This property holds the duration (in milliseconds) of the transition out of the orientation.
-
- If an orientation and endRotation have been specified for the PathAnimation,
- orientationExitDuration can be used to smoothly transition from the rotation given
- by the path orientation to the specified endRotation.
-*/
-int QQuickPathAnimation::orientationExitDuration() const
-{
- Q_D(const QQuickPathAnimation);
- return d->exitDuration;
-}
-
-void QQuickPathAnimation::setOrientationExitDuration(int duration)
-{
- Q_D(QQuickPathAnimation);
- if (d->exitDuration == duration)
- return;
- d->exitDuration = duration;
- emit orientationExitDurationChanged(duration);
-}
-
-/*!
- \qmlproperty real QtQuick2::PathAnimation::endRotation
- This property holds the ending rotation for the target.
-
- If an orientation has been specified for the PathAnimation,
- and the path doesn't end with the item at the desired rotation,
- the endRotation property can be used to manually specify an end
- rotation.
-
- This property is typically used with orientationExitDuration, as specifying
- an endRotation without an orientationExitDuration may cause a jump to
- the final rotation, rather than a smooth transition.
-*/
-qreal QQuickPathAnimation::endRotation() const
-{
- Q_D(const QQuickPathAnimation);
- return d->endRotation.isNull ? qreal(0) : d->endRotation.value;
-}
-
-void QQuickPathAnimation::setEndRotation(qreal rotation)
-{
- Q_D(QQuickPathAnimation);
- if (!d->endRotation.isNull && d->endRotation == rotation)
- return;
-
- d->endRotation = rotation;
- emit endRotationChanged(d->endRotation);
-}
-
-QAbstractAnimationJob* QQuickPathAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QQuickPathAnimation);
-
- QQuickItem *target = d->target ? d->target : qobject_cast<QQuickItem*>(defaultTarget);
-
- QQuickPathAnimationUpdater prevData;
- bool havePrevData = false;
- if (d->activeAnimations.contains(target)) {
- havePrevData = true;
- prevData = *d->activeAnimations[target]->pathUpdater();
- }
-
- QList<QQuickItem*> keys = d->activeAnimations.keys();
- foreach (QQuickItem *item, keys) {
- QQuickPathAnimationAnimator *anim = d->activeAnimations.value(item);
- if (anim->state() == QAbstractAnimationJob::Stopped) {
- anim->clearTemplate();
- d->activeAnimations.remove(item);
- }
- }
-
- QQuickPathAnimationUpdater *data = new QQuickPathAnimationUpdater();
- QQuickPathAnimationAnimator *pa = new QQuickPathAnimationAnimator(d);
-
- d->activeAnimations[target] = pa;
-
- data->orientation = d->orientation;
- data->anchorPoint = d->anchorPoint;
- data->entryInterval = d->duration ? qreal(d->entryDuration) / d->duration : qreal(0);
- data->exitInterval = d->duration ? qreal(d->exitDuration) / d->duration : qreal(0);
- data->endRotation = d->endRotation;
- data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = (d->path && d->path->hasStartX() && d->path->hasStartY()) ? true : false;
- data->toDefined = d->path ? d->path->hasEnd() : false;
- int origModifiedSize = modified.count();
-
- for (int i = 0; i < actions.count(); ++i) {
- QDeclarativeAction &action = actions[i];
- if (action.event)
- continue;
- if (action.specifiedObject == target && action.property.name() == QLatin1String("x")) {
- data->toX = action.toValue.toReal();
- modified << action.property;
- action.fromValue = action.toValue;
- }
- if (action.specifiedObject == target && action.property.name() == QLatin1String("y")) {
- data->toY = action.toValue.toReal();
- modified << action.property;
- action.fromValue = action.toValue;
- }
- }
-
- if (target && d->path &&
- (modified.count() > origModifiedSize || data->toDefined)) {
- data->target = target;
- data->path = d->path;
- data->path->invalidateSequentialHistory();
-
- if (havePrevData) {
- // get the original start angle that was used (so we can exactly reverse).
- data->startRotation = prevData.startRotation;
-
- // treat interruptions specially, otherwise we end up with strange paths
- if ((data->reverse || prevData.reverse) && prevData.currentV > 0 && prevData.currentV < 1) {
- if (!data->fromDefined && !data->toDefined && !prevData.painterPath.isEmpty()) {
- QPointF pathPos = QDeclarativePath::sequentialPointAt(prevData.painterPath, prevData.pathLength, prevData.attributePoints, prevData.prevBez, prevData.currentV);
- if (!prevData.anchorPoint.isNull())
- pathPos -= prevData.anchorPoint;
- if (pathPos == data->target->pos()) { //only treat as interruption if we interrupted ourself
- data->painterPath = prevData.painterPath;
- data->toDefined = data->fromDefined = data->fromSourced = true;
- data->prevBez.isValid = false;
- data->interruptStart = prevData.currentV;
- data->startRotation = prevData.startRotation;
- data->pathLength = prevData.pathLength;
- data->attributePoints = prevData.attributePoints;
- }
- }
- }
- }
- pa->setFromSourcedValue(&data->fromSourced);
- pa->setAnimValue(data);
- } else {
- pa->setFromSourcedValue(0);
- pa->setAnimValue(0);
- delete pa;
- delete data;
- }
-
- pa->setDuration(d->duration);
- pa->setEasingCurve(d->easingCurve);
- return initInstance(pa);
-}
-
-void QQuickPathAnimationUpdater::setValue(qreal v)
-{
- if (interruptStart.isValid()) {
- if (reverse)
- v = 1 - v;
- qreal end = reverse ? 0.0 : 1.0;
- v = interruptStart + v * (end-interruptStart);
- }
- currentV = v;
- bool atStart = ((reverse && v == 1.0) || (!reverse && v == 0.0));
- if (!fromSourced && (!fromDefined || !toDefined)) {
- qreal startX = reverse ? toX + anchorPoint.x() : target->x() + anchorPoint.x();
- qreal startY = reverse ? toY + anchorPoint.y() : target->y() + anchorPoint.y();
- qreal endX = reverse ? target->x() + anchorPoint.x() : toX + anchorPoint.x();
- qreal endY = reverse ? target->y() + anchorPoint.y() : toY + anchorPoint.y();
-
- prevBez.isValid = false;
- painterPath = path->createPath(QPointF(startX, startY), QPointF(endX, endY), QStringList(), pathLength, attributePoints);
- fromSourced = true;
- }
-
- qreal angle;
- bool fixed = orientation == QQuickPathAnimation::Fixed;
- QPointF currentPos = !painterPath.isEmpty() ? path->sequentialPointAt(painterPath, pathLength, attributePoints, prevBez, v, fixed ? 0 : &angle) : path->sequentialPointAt(v, fixed ? 0 : &angle);
-
- //adjust position according to anchor point
- if (!anchorPoint.isNull()) {
- currentPos -= anchorPoint;
- if (atStart) {
- if (!anchorPoint.isNull() && !fixed)
- target->setTransformOriginPoint(anchorPoint);
- }
- }
-
- target->setPos(currentPos);
-
- //adjust angle according to orientation
- if (!fixed) {
- switch (orientation) {
- case QQuickPathAnimation::RightFirst:
- angle = -angle;
- break;
- case QQuickPathAnimation::TopFirst:
- angle = -angle + 90;
- break;
- case QQuickPathAnimation::LeftFirst:
- angle = -angle + 180;
- break;
- case QQuickPathAnimation::BottomFirst:
- angle = -angle + 270;
- break;
- default:
- angle = 0;
- break;
- }
-
- if (atStart && !reverse) {
- startRotation = target->rotation();
-
- //shortest distance to correct orientation
- qreal diff = angle - startRotation;
- while (diff > 180.0) {
- startRotation.value += 360.0;
- diff -= 360.0;
- }
- while (diff < -180.0) {
- startRotation.value -= 360.0;
- diff += 360.0;
- }
- }
-
- //smoothly transition to the desired orientation
- //TODO: shortest distance calculations
- if (startRotation.isValid()) {
- if (reverse && v == 0.0)
- angle = startRotation;
- else if (v < entryInterval)
- angle = angle * v / entryInterval + startRotation * (entryInterval - v) / entryInterval;
- }
- if (endRotation.isValid()) {
- qreal exitStart = 1 - entryInterval;
- if (!reverse && v == 1.0)
- angle = endRotation;
- else if (v > exitStart)
- angle = endRotation * (v - exitStart) / exitInterval + angle * (exitInterval - (v - exitStart)) / exitInterval;
- }
- target->setRotation(angle);
- }
-
- /*
- NOTE: we don't always reset the transform origin, as it can cause a
- visual jump if ending on an angle. This means that in some cases
- (anchor point and orientation both specified, and ending at an angle)
- the transform origin will always be set after running the path animation.
- */
- if ((reverse && v == 0.0) || (!reverse && v == 1.0)) {
- if (!anchorPoint.isNull() && !fixed && qFuzzyIsNull(angle))
- target->setTransformOriginPoint(QPointF());
- }
-}
-
-QQuickPathAnimationAnimator::QQuickPathAnimationAnimator(QQuickPathAnimationPrivate *priv)
- : animationTemplate(priv)
-{
-}
-
-QQuickPathAnimationAnimator::~QQuickPathAnimationAnimator()
-{
- if (animationTemplate && pathUpdater()) {
- QHash<QQuickItem*, QQuickPathAnimationAnimator* >::iterator it =
- animationTemplate->activeAnimations.find(pathUpdater()->target);
- if (it != animationTemplate->activeAnimations.end() && it.value() == this)
- animationTemplate->activeAnimations.erase(it);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/items/qquickanimation_p.h b/src/quick/items/qquickanimation_p.h
deleted file mode 100644
index 0823ba0cdd..0000000000
--- a/src/quick/items/qquickanimation_p.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKANIMATION_H
-#define QQUICKANIMATION_H
-
-#include "qquickitem.h"
-
-#include <QtQuick/private/qdeclarativeanimation_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QQuickParentAnimationPrivate;
-class Q_QUICK_PRIVATE_EXPORT QQuickParentAnimation : public QDeclarativeAnimationGroup
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QQuickParentAnimation)
-
- Q_PROPERTY(QQuickItem *target READ target WRITE setTargetObject NOTIFY targetChanged)
- Q_PROPERTY(QQuickItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged)
- Q_PROPERTY(QQuickItem *via READ via WRITE setVia NOTIFY viaChanged)
-
-public:
- QQuickParentAnimation(QObject *parent=0);
- virtual ~QQuickParentAnimation();
-
- QQuickItem *target() const;
- void setTargetObject(QQuickItem *);
-
- QQuickItem *newParent() const;
- void setNewParent(QQuickItem *);
-
- QQuickItem *via() const;
- void setVia(QQuickItem *);
-
-Q_SIGNALS:
- void targetChanged();
- void newParentChanged();
- void viaChanged();
-
-protected:
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-};
-
-class QQuickAnchorAnimationPrivate;
-class Q_QUICK_PRIVATE_EXPORT QQuickAnchorAnimation : public QDeclarativeAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QQuickAnchorAnimation)
- Q_PROPERTY(QDeclarativeListProperty<QQuickItem> targets READ targets)
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
-
-public:
- QQuickAnchorAnimation(QObject *parent=0);
- virtual ~QQuickAnchorAnimation();
-
- QDeclarativeListProperty<QQuickItem> targets();
-
- int duration() const;
- void setDuration(int);
-
- QEasingCurve easing() const;
- void setEasing(const QEasingCurve &);
-
-Q_SIGNALS:
- void durationChanged(int);
- void easingChanged(const QEasingCurve&);
-
-protected:
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-};
-
-class QQuickItem;
-class QDeclarativePath;
-class QQuickPathAnimationPrivate;
-class Q_QUICK_PRIVATE_EXPORT QQuickPathAnimation : public QDeclarativeAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QQuickPathAnimation)
-
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
- Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged)
- Q_PROPERTY(QQuickItem *target READ target WRITE setTargetObject NOTIFY targetChanged)
- Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
- Q_PROPERTY(QPointF anchorPoint READ anchorPoint WRITE setAnchorPoint NOTIFY anchorPointChanged)
- Q_PROPERTY(int orientationEntryDuration READ orientationEntryDuration WRITE setOrientationEntryDuration NOTIFY orientationEntryDurationChanged)
- Q_PROPERTY(int orientationExitDuration READ orientationExitDuration WRITE setOrientationExitDuration NOTIFY orientationExitDurationChanged)
- Q_PROPERTY(qreal endRotation READ endRotation WRITE setEndRotation NOTIFY endRotationChanged)
-
-public:
- QQuickPathAnimation(QObject *parent=0);
- virtual ~QQuickPathAnimation();
-
- enum Orientation {
- Fixed,
- RightFirst,
- LeftFirst,
- BottomFirst,
- TopFirst
- };
- Q_ENUMS(Orientation)
-
- int duration() const;
- void setDuration(int);
-
- QEasingCurve easing() const;
- void setEasing(const QEasingCurve &);
-
- QDeclarativePath *path() const;
- void setPath(QDeclarativePath *);
-
- QQuickItem *target() const;
- void setTargetObject(QQuickItem *);
-
- Orientation orientation() const;
- void setOrientation(Orientation orientation);
-
- QPointF anchorPoint() const;
- void setAnchorPoint(const QPointF &point);
-
- int orientationEntryDuration() const;
- void setOrientationEntryDuration(int);
-
- int orientationExitDuration() const;
- void setOrientationExitDuration(int);
-
- qreal endRotation() const;
- void setEndRotation(qreal);
-
-protected:
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-Q_SIGNALS:
- void durationChanged(int);
- void easingChanged(const QEasingCurve &);
- void pathChanged();
- void targetChanged();
- void orientationChanged(Orientation);
- void anchorPointChanged(const QPointF &);
- void orientationEntryDurationChanged(qreal);
- void orientationExitDurationChanged(qreal);
- void endRotationChanged(qreal);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QQuickParentAnimation)
-QML_DECLARE_TYPE(QQuickAnchorAnimation)
-QML_DECLARE_TYPE(QQuickPathAnimation)
-
-QT_END_HEADER
-
-#endif // QQUICKANIMATION_H
diff --git a/src/quick/items/qquickanimation_p_p.h b/src/quick/items/qquickanimation_p_p.h
deleted file mode 100644
index c34b5ab963..0000000000
--- a/src/quick/items/qquickanimation_p_p.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKANIMATION_P_H
-#define QQUICKANIMATION_P_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 "qquickanimation_p.h"
-
-#include <private/qdeclarativepath_p.h>
-#include <private/qdeclarativeanimation_p_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickParentAnimationPrivate : public QDeclarativeAnimationGroupPrivate
-{
- Q_DECLARE_PUBLIC(QQuickParentAnimation)
-public:
- QQuickParentAnimationPrivate()
- : QDeclarativeAnimationGroupPrivate(), target(0), newParent(0), via(0) {}
-
- QQuickItem *target;
- QQuickItem *newParent;
- QQuickItem *via;
-
- QPointF computeTransformOrigin(QQuickItem::TransformOrigin origin, qreal width, qreal height) const;
-};
-
-class QQuickAnchorAnimationPrivate : public QDeclarativeAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QQuickAnchorAnimation)
-public:
- QQuickAnchorAnimationPrivate() : interpolator(QVariantAnimationPrivate::getInterpolator(QMetaType::QReal)), duration(250) {}
-
- QVariantAnimation::Interpolator interpolator;
- int duration;
- QEasingCurve easing;
- QList<QQuickItem*> targets;
-};
-
-class QQuickPathAnimationUpdater : public QDeclarativeBulkValueUpdater
-{
-public:
- QQuickPathAnimationUpdater() : path(0), target(0), reverse(false),
- fromSourced(false), fromDefined(false), toDefined(false),
- toX(0), toY(0), currentV(0), orientation(QQuickPathAnimation::Fixed),
- entryInterval(0), exitInterval(0) {}
- ~QQuickPathAnimationUpdater() {}
-
- void setValue(qreal v);
-
- QDeclarativePath *path;
-
- QPainterPath painterPath;
- QDeclarativeCachedBezier prevBez;
- qreal pathLength;
- QList<QDeclarativePath::AttributePoint> attributePoints;
-
- QQuickItem *target;
- bool reverse;
- bool fromSourced;
- bool fromDefined;
- bool toDefined;
- qreal toX;
- qreal toY;
- qreal currentV;
- QDeclarativeNullableValue<qreal> interruptStart;
- //TODO: bundle below into common struct
- QQuickPathAnimation::Orientation orientation;
- QPointF anchorPoint;
- qreal entryInterval;
- qreal exitInterval;
- QDeclarativeNullableValue<qreal> endRotation;
- QDeclarativeNullableValue<qreal> startRotation;
-};
-
-class QQuickPathAnimationPrivate;
-class QQuickPathAnimationAnimator : public QDeclarativeBulkValueAnimator
-{
-public:
- QQuickPathAnimationAnimator(QQuickPathAnimationPrivate * = 0);
- ~QQuickPathAnimationAnimator();
-
- void clearTemplate() { animationTemplate = 0; }
-
- QQuickPathAnimationUpdater *pathUpdater() { return static_cast<QQuickPathAnimationUpdater*>(getAnimValue()); }
-private:
- QQuickPathAnimationPrivate *animationTemplate;
-};
-
-class QQuickPathAnimationPrivate : public QDeclarativeAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QQuickPathAnimation)
-public:
- QQuickPathAnimationPrivate() : path(0), target(0),
- orientation(QQuickPathAnimation::Fixed), entryDuration(0), exitDuration(0), duration(250) {}
-
- QDeclarativePath *path;
- QQuickItem *target;
- QQuickPathAnimation::Orientation orientation;
- QPointF anchorPoint;
- qreal entryDuration;
- qreal exitDuration;
- QDeclarativeNullableValue<qreal> endRotation;
- int duration;
- QEasingCurve easingCurve;
- QHash<QQuickItem*, QQuickPathAnimationAnimator* > activeAnimations;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QQUICKANIMATION_P_H
diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp
index 67b5cdf737..5beb345afc 100644
--- a/src/quick/items/qquickborderimage.cpp
+++ b/src/quick/items/qquickborderimage.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,10 +43,11 @@
#include "qquickborderimage_p_p.h"
#include "qquickninepatchnode_p.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QtCore/qfile.h>
-#include <private/qdeclarativeengine_p.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlengine_p.h>
QT_BEGIN_NAMESPACE
@@ -97,7 +98,7 @@ QT_BEGIN_NAMESPACE
used to determine the parts of the image that will lie inside the unscaled corner
areas and the parts that will be stretched horizontally and vertically.
- \snippet doc/src/snippets/declarative/borderimage/normal-image.qml normal image
+ \snippet doc/src/snippets/qml/borderimage/normal-image.qml normal image
\clearfloat
\beginfloatleft
@@ -111,7 +112,7 @@ QT_BEGIN_NAMESPACE
is set to \l{BorderImage::verticalTileMode}{BorderImage.Stretch}, the parts of image
in regions 4 and 6 are stretched vertically.
- \snippet doc/src/snippets/declarative/borderimage/borderimage-scaled.qml scaled border image
+ \snippet doc/src/snippets/qml/borderimage/borderimage-scaled.qml scaled border image
\clearfloat
\beginfloatleft
@@ -125,7 +126,7 @@ QT_BEGIN_NAMESPACE
\l{BorderImage::verticalTileMode}{BorderImage.Repeat}, the parts of image in regions
4 and 6 are tiled so that they fill the space at the left and right of the element.
- \snippet doc/src/snippets/declarative/borderimage/borderimage-tiled.qml tiled border image
+ \snippet doc/src/snippets/qml/borderimage/borderimage-tiled.qml tiled border image
\clearfloat
In some situations, the width of regions 2 and 8 may not be an exact multiple of the width
@@ -256,7 +257,7 @@ QQuickBorderImage::~QQuickBorderImage()
The URL may be absolute, or relative to the URL of the component.
- \sa QDeclarativeImageProvider
+ \sa QQmlImageProvider
*/
/*!
@@ -305,7 +306,7 @@ void QQuickBorderImage::load()
} else {
d->status = Loading;
if (d->url.path().endsWith(QLatin1String("sci"))) {
- QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
+ QString lf = QQmlEnginePrivate::urlToLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
QFile file(lf);
file.open(QIODevice::ReadOnly);
@@ -317,11 +318,11 @@ void QQuickBorderImage::load()
}
} else {
- QDeclarativePixmap::Options options;
+ QQuickPixmap::Options options;
if (d->async)
- options |= QDeclarativePixmap::Asynchronous;
+ options |= QQuickPixmap::Asynchronous;
if (d->cache)
- options |= QDeclarativePixmap::Cache;
+ options |= QQuickPixmap::Cache;
d->pix.clear(this);
d->pix.load(qmlEngine(this), d->url, options);
@@ -448,11 +449,11 @@ void QQuickBorderImage::setGridScaledImage(const QQuickGridScaledImage& sci)
d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
- QDeclarativePixmap::Options options;
+ QQuickPixmap::Options options;
if (d->async)
- options |= QDeclarativePixmap::Asynchronous;
+ options |= QQuickPixmap::Asynchronous;
if (d->cache)
- options |= QDeclarativePixmap::Cache;
+ options |= QQuickPixmap::Cache;
d->pix.clear(this);
d->pix.load(qmlEngine(this), d->sciurl, options);
diff --git a/src/quick/items/qquickborderimage_p.h b/src/quick/items/qquickborderimage_p.h
index 93dc452e87..80532b7082 100644
--- a/src/quick/items/qquickborderimage_p.h
+++ b/src/quick/items/qquickborderimage_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickborderimage_p_p.h b/src/quick/items/qquickborderimage_p_p.h
index b9b5723a06..07a62b4d29 100644
--- a/src/quick/items/qquickborderimage_p_p.h
+++ b/src/quick/items/qquickborderimage_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -56,6 +56,8 @@
#include "qquickimagebase_p_p.h"
#include "qquickscalegrid_p_p.h"
+#include <private/qqmlglobal_p.h>
+
QT_BEGIN_NAMESPACE
class QNetworkReply;
diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp
index f135975b3c..92a422a56d 100644
--- a/src/quick/items/qquickcanvas.cpp
+++ b/src/quick/items/qquickcanvas.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -65,11 +65,11 @@
#include <QtGui/qstylehints.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qabstractanimation.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
+#include <QtQml/qqmlincubator.h>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
-#include <private/qdeclarativeprofilerservice_p.h>
+#include <private/qqmlprofilerservice_p.h>
QT_BEGIN_NAMESPACE
@@ -83,7 +83,7 @@ void QQuickCanvasPrivate::updateFocusItemTransform()
qApp->inputMethod()->setInputItemTransform(QQuickItemPrivate::get(focus)->itemToCanvasTransform());
}
-class QQuickCanvasIncubationController : public QObject, public QDeclarativeIncubationController
+class QQuickCanvasIncubationController : public QObject, public QQmlIncubationController
{
public:
QQuickCanvasIncubationController(QQuickCanvasPrivate *canvas)
@@ -341,7 +341,7 @@ void QQuickCanvasPrivate::init(QQuickCanvas *c)
engine->setCanvas(q);
}
-QDeclarativeListProperty<QObject> QQuickCanvasPrivate::data()
+QQmlListProperty<QObject> QQuickCanvasPrivate::data()
{
initRootItem();
return QQuickItemPrivate::get(rootItem)->data();
@@ -676,7 +676,7 @@ void QQuickCanvasPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item,
void QQuickCanvasPrivate::notifyFocusChangesRecur(QQuickItem **items, int remaining)
{
- QDeclarativeGuard<QQuickItem> item(*items);
+ QQmlGuard<QQuickItem> item(*items);
if (remaining)
notifyFocusChangesRecur(items + 1, remaining - 1);
@@ -775,7 +775,7 @@ void QQuickCanvas::releaseResources()
{
Q_D(QQuickCanvas);
d->windowManager->releaseResources();
- QDeclarativePixmap::purgeCache();
+ QQuickPixmap::purgeCache();
}
@@ -2058,12 +2058,12 @@ QImage QQuickCanvas::grabFrameBuffer()
/*!
Returns an incubation controller that splices incubation between frames
for this canvas. QQuickView automatically installs this controller for you,
- otherwise you will need to install it yourself using \l{QDeclarativeEngine::setIncubationController}
+ otherwise you will need to install it yourself using \l{QQmlEngine::setIncubationController}
The controller is owned by the canvas and will be destroyed when the canvas
is deleted.
*/
-QDeclarativeIncubationController *QQuickCanvas::incubationController() const
+QQmlIncubationController *QQuickCanvas::incubationController() const
{
Q_D(const QQuickCanvas);
diff --git a/src/quick/items/qquickcanvas.h b/src/quick/items/qquickcanvas.h
index 3246d53a42..0b6b01b05a 100644
--- a/src/quick/items/qquickcanvas.h
+++ b/src/quick/items/qquickcanvas.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -58,13 +58,13 @@ class QSGTexture;
class QInputMethodEvent;
class QQuickCanvasPrivate;
class QOpenGLFramebufferObject;
-class QDeclarativeIncubationController;
+class QQmlIncubationController;
class QInputMethodEvent;
class Q_QUICK_EXPORT QQuickCanvas : public QWindow
{
Q_OBJECT
- Q_PRIVATE_PROPERTY(QQuickCanvas::d_func(), QDeclarativeListProperty<QObject> data READ data DESIGNABLE false)
+ Q_PRIVATE_PROPERTY(QQuickCanvas::d_func(), QQmlListProperty<QObject> data READ data DESIGNABLE false)
Q_PROPERTY(QColor color READ clearColor WRITE setClearColor NOTIFY clearColorChanged)
Q_CLASSINFO("DefaultProperty", "data")
Q_DECLARE_PRIVATE(QQuickCanvas)
@@ -100,7 +100,7 @@ public:
uint renderTargetId() const;
QSize renderTargetSize() const;
- QDeclarativeIncubationController *incubationController() const;
+ QQmlIncubationController *incubationController() const;
virtual QAccessibleInterface *accessibleRoot() const;
diff --git a/src/quick/items/qquickcanvas_p.h b/src/quick/items/qquickcanvas_p.h
index d4d6a01f75..147526466e 100644
--- a/src/quick/items/qquickcanvas_p.h
+++ b/src/quick/items/qquickcanvas_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -55,7 +55,7 @@
#include "qquickitem.h"
#include "qquickcanvas.h"
-#include <private/qdeclarativeguard_p.h>
+#include <private/qqmlguard_p.h>
#include <QtQuick/private/qsgcontext_p.h>
#include <private/qquickdrag_p.h>
@@ -108,7 +108,7 @@ public:
QQuickRootItem *rootItem;
QSet<QQuickItem *> parentlessItems;
- QDeclarativeListProperty<QObject> data();
+ QQmlListProperty<QObject> data();
QQuickItem *activeFocusItem;
QQuickItem *mouseGrabberItem;
diff --git a/src/quick/items/qquickclipnode.cpp b/src/quick/items/qquickclipnode.cpp
index 168e973927..f9894edb48 100644
--- a/src/quick/items/qquickclipnode.cpp
+++ b/src/quick/items/qquickclipnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickclipnode_p.h b/src/quick/items/qquickclipnode_p.h
index a48972532c..02902a758e 100644
--- a/src/quick/items/qquickclipnode_p.h
+++ b/src/quick/items/qquickclipnode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index c44e1acd4b..f8c1281af5 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,7 +45,7 @@
#include <QtQuick/private/qquickevents_p_p.h>
#include <private/qquickitemchangelistener_p.h>
#include <private/qv8engine_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QtGui/qevent.h>
QT_BEGIN_NAMESPACE
@@ -76,8 +76,8 @@ public:
QQuickDragGrabber dragGrabber;
- QDeclarativeGuard<QObject> source;
- QDeclarativeGuard<QObject> target;
+ QQmlGuard<QObject> source;
+ QQmlGuard<QObject> target;
QQuickItem *attachedItem;
QQuickDragMimeData *mimeData;
Qt::DropAction proposedAction;
@@ -106,7 +106,7 @@ public:
However, dragging is not limited to mouse drags, anything that can move an item
can generate drag events, this can include touch events, animations and bindings.
- \snippet doc/src/snippets/declarative/drag.qml 0
+ \snippet doc/src/snippets/qml/drag.qml 0
A drag can be terminated either by canceling it with Drag.cancel() or setting
Drag.active to false, or it can be terminated with a drop event by calling
@@ -377,7 +377,7 @@ void QQuickDragAttachedPrivate::start(Qt::DropActions supportedActions)
property for the started sequence.
*/
-void QQuickDragAttached::start(QDeclarativeV8Function *args)
+void QQuickDragAttached::start(QQmlV8Function *args)
{
Q_D(QQuickDragAttached);
if (d->inEvent) {
diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h
index eca3927624..ac19c021e0 100644
--- a/src/quick/items/qquickdrag_p.h
+++ b/src/quick/items/qquickdrag_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -60,10 +60,10 @@ class QQuickDragPrivate;
class QQuickDragGrabber
{
- class Item : public QDeclarativeGuard<QQuickItem>
+ class Item : public QQmlGuard<QQuickItem>
{
public:
- Item(QQuickItem *item) : QDeclarativeGuard<QQuickItem>(item) {}
+ Item(QQuickItem *item) : QQmlGuard<QQuickItem>(item) {}
QIntrusiveListNode node;
protected:
@@ -142,7 +142,7 @@ private:
friend class QQuickDragAttachedPrivate;
};
-class QDeclarativeV8Function;
+class QQmlV8Function;
class QQuickDragAttachedPrivate;
class QQuickDragAttached : public QObject
@@ -183,7 +183,7 @@ public:
Q_INVOKABLE int drop();
public Q_SLOTS:
- void start(QDeclarativeV8Function *);
+ void start(QQmlV8Function *);
void cancel();
Q_SIGNALS:
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index 0534fb5bb0..ed5fb23658 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,7 +44,7 @@
#include "qquickitem_p.h"
#include "qquickcanvas.h"
-#include <private/qdeclarativeengine_p.h>
+#include <private/qqmlengine_p.h>
QT_BEGIN_NAMESPACE
@@ -74,8 +74,8 @@ public:
QRegExp keyRegExp;
QPointF dragPosition;
QQuickDropAreaDrag *drag;
- QDeclarativeGuard<QObject> source;
- QDeclarativeGuard<QMimeData> mimeData;
+ QQmlGuard<QObject> source;
+ QQmlGuard<QMimeData> mimeData;
};
QQuickDropAreaPrivate::QQuickDropAreaPrivate()
@@ -409,7 +409,7 @@ QStringList QQuickDropEvent::keys() const
If an \a action is specified it will overwrite the value of the \l action property.
*/
-void QQuickDropEvent::accept(QDeclarativeV8Function *args)
+void QQuickDropEvent::accept(QQmlV8Function *args)
{
Qt::DropAction action = event->dropAction();
diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h
index 6fdfc4b03b..e207787198 100644
--- a/src/quick/items/qquickdroparea_p.h
+++ b/src/quick/items/qquickdroparea_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,7 +44,7 @@
#include "qquickitem.h"
-#include <private/qdeclarativeguard_p.h>
+#include <private/qqmlguard_p.h>
#include <private/qv8engine_p.h>
#include <QtGui/qevent.h>
@@ -82,7 +82,7 @@ public:
bool accepted() const { return event->isAccepted(); }
void setAccepted(bool accepted) { event->setAccepted(accepted); }
- Q_INVOKABLE void accept(QDeclarativeV8Function *);
+ Q_INVOKABLE void accept(QQmlV8Function *);
private:
QQuickDropAreaPrivate *d;
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 6e7769f1d3..597e64eb18 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 7ff4835b4c..6300b0f2a7 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -54,7 +54,7 @@
//
#include <QtQuick/qtquickglobal.h>
-#include <qdeclarative.h>
+#include <qqml.h>
#include <QtCore/qobject.h>
#include <QtGui/qvector2d.h>
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 0e8097af15..f75ca14989 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,7 +45,9 @@
#include "qquickcanvas_p.h"
#include "qquickevents_p_p.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <private/qqmlglobal_p.h>
+
+#include <QtQml/qqmlinfo.h>
#include <QtGui/qevent.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qstylehints.h>
@@ -204,7 +206,7 @@ QQuickFlickablePrivate::QQuickFlickablePrivate()
void QQuickFlickablePrivate::init()
{
Q_Q(QQuickFlickable);
- QDeclarative_setParent_noEvent(contentItem, q);
+ QQml_setParent_noEvent(contentItem, q);
contentItem->setParentItem(q);
FAST_CONNECT(&timeline, SIGNAL(completed()), q, SLOT(movementEnding()))
q->setAcceptedMouseButtons(Qt::LeftButton);
@@ -277,7 +279,7 @@ void QQuickFlickablePrivate::flickY(qreal velocity)
}
void QQuickFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal,
- QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
+ QQuickTimeLineCallback::Callback fixupCallback, qreal velocity)
{
Q_Q(QQuickFlickable);
qreal maxDistance = -1;
@@ -303,7 +305,7 @@ void QQuickFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExt
timeline.accel(data.move, v, deceleration);
else
timeline.accel(data.move, v, deceleration, maxDistance);
- timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
+ timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this));
if (!hData.flicking && q->xflick() && (&data == &hData)) {
hData.flicking = true;
emit q->flickingChanged();
@@ -507,7 +509,7 @@ is finished.
The following example shows a small view onto a large image in which the
user can drag or flick the image in order to view different parts of it.
- \snippet doc/src/snippets/declarative/flickable.qml document
+ \snippet doc/src/snippets/qml/flickable.qml document
\clearfloat
@@ -569,9 +571,9 @@ is finished.
These properties are typically used to draw a scrollbar. For example:
- \snippet doc/src/snippets/declarative/flickableScrollbar.qml 0
+ \snippet doc/src/snippets/qml/flickableScrollbar.qml 0
\dots 8
- \snippet doc/src/snippets/declarative/flickableScrollbar.qml 1
+ \snippet doc/src/snippets/qml/flickableScrollbar.qml 1
\sa {declarative/ui-components/scrollbar}{scrollbar example}
*/
@@ -1304,7 +1306,7 @@ void QQuickFlickable::viewportMoved()
qreal maxDistance = d->overShootDistance(height());
d->timeline.reset(d->vData.move);
d->timeline.accel(d->vData.move, -d->vData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance);
- d->timeline.callback(QDeclarativeTimeLineCallback(&d->vData.move, d->fixupY_callback, d));
+ d->timeline.callback(QQuickTimeLineCallback(&d->vData.move, d->fixupY_callback, d));
}
if (!d->hData.inOvershoot && !d->hData.fixingUp && d->hData.flicking
&& (d->hData.move.value() > minXExtent() || d->hData.move.value() < maxXExtent())
@@ -1314,7 +1316,7 @@ void QQuickFlickable::viewportMoved()
qreal maxDistance = d->overShootDistance(width());
d->timeline.reset(d->hData.move);
d->timeline.accel(d->hData.move, -d->hData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance);
- d->timeline.callback(QDeclarativeTimeLineCallback(&d->hData.move, d->fixupX_callback, d));
+ d->timeline.callback(QQuickTimeLineCallback(&d->hData.move, d->fixupX_callback, d));
}
d->lastFlickablePosition = QPointF(d->hData.move.value(), d->vData.move.value());
@@ -1388,7 +1390,7 @@ void QQuickFlickable::cancelFlick()
movementEnding();
}
-void QQuickFlickablePrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
+void QQuickFlickablePrivate::data_append(QQmlListProperty<QObject> *prop, QObject *o)
{
QQuickItem *i = qobject_cast<QQuickItem *>(o);
if (i) {
@@ -1398,33 +1400,33 @@ void QQuickFlickablePrivate::data_append(QDeclarativeListProperty<QObject> *prop
}
}
-int QQuickFlickablePrivate::data_count(QDeclarativeListProperty<QObject> *)
+int QQuickFlickablePrivate::data_count(QQmlListProperty<QObject> *)
{
// XXX todo
return 0;
}
-QObject *QQuickFlickablePrivate::data_at(QDeclarativeListProperty<QObject> *, int)
+QObject *QQuickFlickablePrivate::data_at(QQmlListProperty<QObject> *, int)
{
// XXX todo
return 0;
}
-void QQuickFlickablePrivate::data_clear(QDeclarativeListProperty<QObject> *)
+void QQuickFlickablePrivate::data_clear(QQmlListProperty<QObject> *)
{
// XXX todo
}
-QDeclarativeListProperty<QObject> QQuickFlickable::flickableData()
+QQmlListProperty<QObject> QQuickFlickable::flickableData()
{
Q_D(QQuickFlickable);
- return QDeclarativeListProperty<QObject>(this, (void *)d, QQuickFlickablePrivate::data_append,
+ return QQmlListProperty<QObject>(this, (void *)d, QQuickFlickablePrivate::data_append,
QQuickFlickablePrivate::data_count,
QQuickFlickablePrivate::data_at,
QQuickFlickablePrivate::data_clear);
}
-QDeclarativeListProperty<QQuickItem> QQuickFlickable::flickableChildren()
+QQmlListProperty<QQuickItem> QQuickFlickable::flickableChildren()
{
Q_D(QQuickFlickable);
return QQuickItemPrivate::get(d->contentItem)->children();
@@ -1477,7 +1479,7 @@ void QQuickFlickable::setBoundsBehavior(BoundsBehavior b)
The following snippet shows how these properties are used to display
an image that is larger than the Flickable item itself:
- \snippet doc/src/snippets/declarative/flickable.qml document
+ \snippet doc/src/snippets/qml/flickable.qml document
In some cases, the the content dimensions can be automatically set
using the \l {Item::childrenRect.width}{childrenRect.width}
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index 9d6ca94770..7a19b0c05a 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -97,8 +97,8 @@ class Q_QUICK_EXPORT QQuickFlickable : public QQuickItem
Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
- Q_PROPERTY(QDeclarativeListProperty<QQuickItem> flickableChildren READ flickableChildren)
+ Q_PROPERTY(QQmlListProperty<QObject> flickableData READ flickableData)
+ Q_PROPERTY(QQmlListProperty<QQuickItem> flickableChildren READ flickableChildren)
Q_CLASSINFO("DefaultProperty", "flickableData")
Q_ENUMS(FlickableDirection)
@@ -108,8 +108,8 @@ public:
QQuickFlickable(QQuickItem *parent=0);
~QQuickFlickable();
- QDeclarativeListProperty<QObject> flickableData();
- QDeclarativeListProperty<QQuickItem> flickableChildren();
+ QQmlListProperty<QObject> flickableData();
+ QQmlListProperty<QQuickItem> flickableChildren();
enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
BoundsBehavior boundsBehavior() const;
diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h
index 7b16f1ac52..ac6f2fffed 100644
--- a/src/quick/items/qquickflickable_p_p.h
+++ b/src/quick/items/qquickflickable_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -57,12 +57,12 @@
#include "qquickitem_p.h"
#include "qquickitemchangelistener_p.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
#include <QtCore/qdatetime.h>
#include "qplatformdefs.h"
-#include <private/qdeclarativetimeline_p_p.h>
-#include <private/qdeclarativeanimation_p_p.h>
+#include <private/qquicktimeline_p_p.h>
+#include <private/qquickanimation_p_p.h>
QT_BEGIN_NAMESPACE
@@ -80,13 +80,13 @@ public:
QQuickFlickablePrivate();
void init();
- struct Velocity : public QDeclarativeTimeLineValue
+ struct Velocity : public QQuickTimeLineValue
{
Velocity(QQuickFlickablePrivate *p)
: parent(p) {}
virtual void setValue(qreal v) {
if (v != value()) {
- QDeclarativeTimeLineValue::setValue(v);
+ QQuickTimeLineValue::setValue(v);
parent->updateVelocity();
}
}
@@ -119,7 +119,7 @@ public:
void addVelocitySample(qreal v, qreal maxVelocity);
void updateVelocity();
- QDeclarativeTimeLineValueProxy<QQuickFlickablePrivate> move;
+ QQuickTimeLineValueProxy<QQuickFlickablePrivate> move;
qreal viewSize;
qreal pressPos;
qreal dragStartOffset;
@@ -148,7 +148,7 @@ public:
void flickX(qreal velocity);
void flickY(qreal velocity);
virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
- QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
+ QQuickTimeLineCallback::Callback fixupCallback, qreal velocity);
void fixupX();
void fixupY();
@@ -176,7 +176,7 @@ public:
AxisData hData;
AxisData vData;
- QDeclarativeTimeLine timeline;
+ QQuickTimeLine timeline;
bool hMoved : 1;
bool vMoved : 1;
bool stealMouse : 1;
@@ -209,7 +209,7 @@ public:
void updateVelocity();
int vTime;
- QDeclarativeTimeLine velocityTimeline;
+ QQuickTimeLine velocityTimeline;
QQuickFlickableVisibleArea *visibleArea;
QQuickFlickable::FlickableDirection flickableDirection;
QQuickFlickable::BoundsBehavior boundsBehavior;
@@ -221,10 +221,10 @@ public:
qint64 computeCurrentTime(QInputEvent *event);
// flickableData property
- static void data_append(QDeclarativeListProperty<QObject> *, QObject *);
- static int data_count(QDeclarativeListProperty<QObject> *);
- static QObject *data_at(QDeclarativeListProperty<QObject> *, int);
- static void data_clear(QDeclarativeListProperty<QObject> *);
+ static void data_append(QQmlListProperty<QObject> *, QObject *);
+ static int data_count(QQmlListProperty<QObject> *);
+ static QObject *data_at(QQmlListProperty<QObject> *, int);
+ static void data_clear(QQmlListProperty<QObject> *);
};
class QQuickFlickableVisibleArea : public QObject
diff --git a/src/quick/items/qquickflipable.cpp b/src/quick/items/qquickflipable.cpp
index a29c6f0d83..f454ce54d5 100644
--- a/src/quick/items/qquickflipable.cpp
+++ b/src/quick/items/qquickflipable.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,9 +42,9 @@
#include "qquickflipable_p.h"
#include "qquickitem_p.h"
-#include <private/qdeclarativeguard_p.h>
+#include <private/qqmlguard_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
QT_BEGIN_NAMESPACE
@@ -78,9 +78,9 @@ public:
void setBackTransform();
QQuickFlipable::Side current;
- QDeclarativeGuard<QQuickLocalTransform> backTransform;
- QDeclarativeGuard<QQuickItem> front;
- QDeclarativeGuard<QQuickItem> back;
+ QQmlGuard<QQuickLocalTransform> backTransform;
+ QQmlGuard<QQuickItem> front;
+ QQmlGuard<QQuickItem> back;
bool sideDirty;
bool wantBackXFlipped;
@@ -113,7 +113,7 @@ public:
degrees to produce the flipping effect. When \c flipped is false, the
item reverts to the default state, in which the \c angle value is 0.
- \snippet doc/src/snippets/declarative/flipable/flipable.qml 0
+ \snippet doc/src/snippets/qml/flipable/flipable.qml 0
\image flipable.gif
diff --git a/src/quick/items/qquickflipable_p.h b/src/quick/items/qquickflipable_p.h
index cf17bce314..dd53ec3d49 100644
--- a/src/quick/items/qquickflipable_p.h
+++ b/src/quick/items/qquickflipable_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickfocusscope.cpp b/src/quick/items/qquickfocusscope.cpp
index b1d3516d3b..7ef2476b30 100644
--- a/src/quick/items/qquickfocusscope.cpp
+++ b/src/quick/items/qquickfocusscope.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickfocusscope_p.h b/src/quick/items/qquickfocusscope_p.h
index 889b45ca1c..6d43dbb619 100644
--- a/src/quick/items/qquickfocusscope_p.h
+++ b/src/quick/items/qquickfocusscope_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index 8b9f8059fb..45fbc9f93e 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,7 +44,7 @@
#include "qquickflickable_p_p.h"
#include "qquickitemview_p_p.h"
-#include <private/qdeclarativesmoothedanimation_p_p.h>
+#include <private/qquicksmoothedanimation_p_p.h>
#include <private/qlistmodelinterface_p.h>
#include <QtGui/qevent.h>
@@ -190,7 +190,7 @@ public:
virtual void setPosition(qreal pos);
virtual void layoutVisibleItems(int fromModelIndex = 0);
- virtual bool applyInsertionChange(const QDeclarativeChangeSet::Insert &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView);
+ virtual bool applyInsertionChange(const QQuickChangeSet::Insert &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView);
virtual void translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult);
virtual bool needsRefillForAddedOrRemovedIndex(int index) const;
@@ -208,7 +208,7 @@ public:
virtual void fixupPosition();
virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
virtual void flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
- QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
+ QQuickTimeLineCallback::Callback fixupCallback, qreal velocity);
QQuickGridView::Flow flow;
qreal cellWidth;
@@ -689,10 +689,10 @@ void QQuickGridViewPrivate::createHighlight()
if (autoHighlight)
resetHighlightPosition();
highlightXAnimator = new QSmoothedAnimation;
- highlightXAnimator->target = QDeclarativeProperty(item, QLatin1String("x"));
+ highlightXAnimator->target = QQmlProperty(item, QLatin1String("x"));
highlightXAnimator->userDuration = highlightMoveDuration;
highlightYAnimator = new QSmoothedAnimation;
- highlightYAnimator->target = QDeclarativeProperty(item, QLatin1String("y"));
+ highlightYAnimator->target = QQmlProperty(item, QLatin1String("y"));
highlightYAnimator->userDuration = highlightMoveDuration;
highlight = newHighlight;
@@ -957,7 +957,7 @@ void QQuickGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
}
void QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
- QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
+ QQuickTimeLineCallback::Callback fixupCallback, qreal velocity)
{
Q_Q(QQuickGridView);
data.fixingUp = false;
@@ -1057,7 +1057,7 @@ void QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
}
timeline.reset(data.move);
timeline.accel(data.move, v, accel, maxDistance + overshootDist);
- timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
+ timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this));
if (!hData.flicking && q->xflick()) {
hData.flicking = true;
emit q->flickingChanged();
@@ -1100,7 +1100,7 @@ void QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
The following example shows the definition of a simple list model defined
in a file called \c ContactModel.qml:
- \snippet doc/src/snippets/declarative/gridview/ContactModel.qml 0
+ \snippet doc/src/snippets/qml/gridview/ContactModel.qml 0
\div {class="float-right"}
\inlineimage gridview-simple.png
@@ -1114,9 +1114,9 @@ void QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
(containing \l Image and \l Text elements) for its delegate.
\clearfloat
- \snippet doc/src/snippets/declarative/gridview/gridview.qml import
+ \snippet doc/src/snippets/qml/gridview/gridview.qml import
\codeline
- \snippet doc/src/snippets/declarative/gridview/gridview.qml classdocs simple
+ \snippet doc/src/snippets/qml/gridview/gridview.qml classdocs simple
\div {class="float-right"}
\inlineimage gridview-highlight.png
@@ -1129,7 +1129,7 @@ void QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
into a separate \c contactDelegate component.
\clearfloat
- \snippet doc/src/snippets/declarative/gridview/gridview.qml classdocs advanced
+ \snippet doc/src/snippets/qml/gridview/gridview.qml classdocs advanced
The currently selected item is highlighted with a blue \l Rectangle using the \l highlight property,
and \c focus is set to \c true to enable keyboard navigation for the grid view.
@@ -1143,7 +1143,7 @@ void QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
this attached property directly as \c GridView.isCurrentItem, while the child
\c contactInfo object must refer to this property as \c wrapper.GridView.isCurrentItem.
- \snippet doc/src/snippets/declarative/gridview/gridview.qml isCurrentItem
+ \snippet doc/src/snippets/qml/gridview/gridview.qml isCurrentItem
\note Views do not set the \l{Item::}{clip} property automatically.
If the view is not clipped by another item or the screen, it will be necessary
@@ -1187,7 +1187,7 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
It is attached to each instance of the delegate.
- \snippet doc/src/snippets/declarative/gridview/gridview.qml isCurrentItem
+ \snippet doc/src/snippets/qml/gridview/gridview.qml isCurrentItem
*/
/*!
@@ -1199,7 +1199,7 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
until an animation completes. The example delegate below ensures that the
animation completes before the item is removed from the list.
- \snippet doc/src/snippets/declarative/gridview/gridview.qml delayRemove
+ \snippet doc/src/snippets/qml/gridview/gridview.qml delayRemove
If a \l remove transition has been specified, it will not be applied until
delayRemove is returned to \c false.
@@ -1307,7 +1307,7 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
Here is a highlight with its motion defined by a \l {SpringAnimation} item:
- \snippet doc/src/snippets/declarative/gridview/gridview.qml highlightFollowsCurrentItem
+ \snippet doc/src/snippets/qml/gridview/gridview.qml highlightFollowsCurrentItem
*/
@@ -2103,7 +2103,7 @@ void QQuickGridView::moveCurrentIndexRight()
}
}
-bool QQuickGridViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::Insert &change, ChangeResult *insertResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView)
+bool QQuickGridViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &change, ChangeResult *insertResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView)
{
Q_Q(QQuickGridView);
diff --git a/src/quick/items/qquickgridview_p.h b/src/quick/items/qquickgridview_p.h
index b8f44ed0e1..ac3c8f097d 100644
--- a/src/quick/items/qquickgridview_p.h
+++ b/src/quick/items/qquickgridview_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,7 +44,7 @@
#include "qquickitemview_p.h"
-#include <private/qdeclarativeguard_p.h>
+#include <private/qqmlguard_p.h>
QT_BEGIN_HEADER
@@ -131,7 +131,7 @@ Q_SIGNALS:
void viewChanged();
public:
- QDeclarativeGuard<QQuickGridView> m_view;
+ QQmlGuard<QQuickGridView> m_view;
};
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index a71c666977..a939365e98 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -120,7 +120,7 @@ QQuickImagePrivate::QQuickImagePrivate()
The following example shows the simplest usage of the Image element.
- \snippet doc/src/snippets/declarative/image.qml document
+ \snippet doc/src/snippets/qml/image.qml document
\beginfloatleft
\image declarative-qtlogo.png
@@ -147,7 +147,7 @@ QQuickImagePrivate::QQuickImagePrivate()
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}, QDeclarativeImageProvider
+ \sa {declarative/imageelements/image}{Image example}, QQmlImageProvider
*/
QQuickImage::QQuickImage(QQuickItem *parent)
@@ -431,7 +431,7 @@ qreal QQuickImage::paintedHeight() const
The URL may be absolute, or relative to the URL of the component.
- \sa QDeclarativeImageProvider
+ \sa QQmlImageProvider
*/
/*!
diff --git a/src/quick/items/qquickimage_p.h b/src/quick/items/qquickimage_p.h
index 35337dfd09..a9e37b47e1 100644
--- a/src/quick/items/qquickimage_p.h
+++ b/src/quick/items/qquickimage_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickimage_p_p.h b/src/quick/items/qquickimage_p_p.h
index 25e267ccff..6a0ba1535f 100644
--- a/src/quick/items/qquickimage_p_p.h
+++ b/src/quick/items/qquickimage_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index 8b127ba571..0bdfab67a9 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#include "qquickimagebase_p.h"
#include "qquickimagebase_p_p.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
QT_BEGIN_NAMESPACE
@@ -202,11 +202,11 @@ void QQuickImageBase::load()
emit statusChanged(d->status);
update();
} else {
- QDeclarativePixmap::Options options;
+ QQuickPixmap::Options options;
if (d->async)
- options |= QDeclarativePixmap::Asynchronous;
+ options |= QQuickPixmap::Asynchronous;
if (d->cache)
- options |= QDeclarativePixmap::Cache;
+ options |= QQuickPixmap::Cache;
d->pix.clear(this);
pixmapChange();
d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), options);
diff --git a/src/quick/items/qquickimagebase_p.h b/src/quick/items/qquickimagebase_p.h
index bbda9dba9a..dfff1e4b0e 100644
--- a/src/quick/items/qquickimagebase_p.h
+++ b/src/quick/items/qquickimagebase_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickimagebase_p_p.h b/src/quick/items/qquickimagebase_p_p.h
index dd9185676f..7c2fce1e79 100644
--- a/src/quick/items/qquickimagebase_p_p.h
+++ b/src/quick/items/qquickimagebase_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -56,7 +56,7 @@
#include "qquickimplicitsizeitem_p_p.h"
#include "qquickimagebase_p.h"
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
QT_BEGIN_NAMESPACE
@@ -76,7 +76,7 @@ public:
{
}
- QDeclarativePixmap pix;
+ QQuickPixmap pix;
QQuickImageBase::Status status;
QUrl url;
qreal progress;
diff --git a/src/quick/items/qquickimplicitsizeitem.cpp b/src/quick/items/qquickimplicitsizeitem.cpp
index 040263e35a..427be42312 100644
--- a/src/quick/items/qquickimplicitsizeitem.cpp
+++ b/src/quick/items/qquickimplicitsizeitem.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickimplicitsizeitem_p.h b/src/quick/items/qquickimplicitsizeitem_p.h
index 5c4bac3585..a6d58325d8 100644
--- a/src/quick/items/qquickimplicitsizeitem_p.h
+++ b/src/quick/items/qquickimplicitsizeitem_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickimplicitsizeitem_p_p.h b/src/quick/items/qquickimplicitsizeitem_p_p.h
index 15ca8b3127..84e3027e64 100644
--- a/src/quick/items/qquickimplicitsizeitem_p_p.h
+++ b/src/quick/items/qquickimplicitsizeitem_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 7ca683fac3..77808a61d9 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,15 +42,15 @@
#include "qquickitem.h"
#include "qquickcanvas.h"
-#include <QtDeclarative/qjsengine.h>
+#include <QtQml/qjsengine.h>
#include "qquickcanvas_p.h"
#include "qquickevents_p_p.h"
#include "qquickscreen_p.h"
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlinfo.h>
#include <QtGui/qpen.h>
#include <QtGui/qcursor.h>
#include <QtGui/qguiapplication.h>
@@ -59,13 +59,14 @@
#include <QtCore/qcoreevent.h>
#include <QtCore/qnumeric.h>
-#include <private/qdeclarativeengine_p.h>
-#include <QtQuick/private/qdeclarativestategroup_p.h>
-#include <private/qdeclarativeopenmetaobject_p.h>
-#include <QtQuick/private/qdeclarativestate_p.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlengine_p.h>
+#include <QtQuick/private/qquickstategroup_p.h>
+#include <private/qqmlopenmetaobject_p.h>
+#include <QtQuick/private/qquickstate_p.h>
#include <private/qlistmodelinterface_p.h>
#include <private/qquickitem_p.h>
-#include <private/qdeclarativeaccessors_p.h>
+#include <private/qqmlaccessors_p.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
#include <float.h>
@@ -74,7 +75,7 @@
QT_BEGIN_NAMESPACE
-static void QQuickItem_parentNotifier(QObject *o, intptr_t, QDeclarativeNotifier **n)
+static void QQuickItem_parentNotifier(QObject *o, intptr_t, QQmlNotifier **n)
{
QQuickItemPrivate *d = QQuickItemPrivate::get(static_cast<QQuickItem *>(o));
*n = &d->parentNotifier;
@@ -86,11 +87,11 @@ QML_PRIVATE_ACCESSOR(QQuickItem, qreal, y, y)
QML_PRIVATE_ACCESSOR(QQuickItem, qreal, width, width)
QML_PRIVATE_ACCESSOR(QQuickItem, qreal, height, height)
-static QDeclarativeAccessors QQuickItem_parent = { QQuickItem_parentRead, QQuickItem_parentNotifier };
-static QDeclarativeAccessors QQuickItem_x = { QQuickItem_xRead, 0 };
-static QDeclarativeAccessors QQuickItem_y = { QQuickItem_yRead, 0 };
-static QDeclarativeAccessors QQuickItem_width = { QQuickItem_widthRead, 0 };
-static QDeclarativeAccessors QQuickItem_height = { QQuickItem_heightRead, 0 };
+static QQmlAccessors QQuickItem_parent = { QQuickItem_parentRead, QQuickItem_parentNotifier };
+static QQmlAccessors QQuickItem_x = { QQuickItem_xRead, 0 };
+static QQmlAccessors QQuickItem_y = { QQuickItem_yRead, 0 };
+static QQmlAccessors QQuickItem_width = { QQuickItem_widthRead, 0 };
+static QQmlAccessors QQuickItem_height = { QQuickItem_heightRead, 0 };
QML_DECLARE_PROPERTIES(QQuickItem) {
{ QML_PROPERTY_NAME(parent), 0, &QQuickItem_parent },
@@ -233,7 +234,7 @@ void QQuickItemPrivate::registerAccessorProperties()
rotations you must specify the axis to rotate around in addition to the origin point.
The following example shows various 3D-like rotations applied to an \l Image.
- \snippet doc/src/snippets/declarative/rotation.qml 0
+ \snippet doc/src/snippets/qml/rotation.qml 0
\image axisrotation.png
@@ -491,7 +492,7 @@ void QQuickItemKeyFilter::componentComplete()
The following example provides key navigation for a 2x2 grid of items:
- \snippet doc/src/snippets/declarative/keynavigation.qml 0
+ \snippet doc/src/snippets/qml/keynavigation.qml 0
The top-left item initially receives focus by setting \l {Item::}{focus} to
\c true. When an arrow key is pressed, the focus will move to the
@@ -912,13 +913,13 @@ bool QQuickKeysAttachedPrivate::isConnected(const char *signalName)
be used to test for a certain key; in this case, the left cursor
key:
- \snippet doc/src/snippets/declarative/keys/keys-pressed.qml key item
+ \snippet doc/src/snippets/qml/keys/keys-pressed.qml key item
Some keys may alternatively be handled via specific signal properties,
for example \e onSelectPressed. These handlers automatically set
\e event.accepted to true.
- \snippet doc/src/snippets/declarative/keys/keys-handler.qml key item
+ \snippet doc/src/snippets/qml/keys/keys-handler.qml key item
See \l{Qt::Key}{Qt.Key} for the list of keyboard codes.
@@ -1460,7 +1461,7 @@ QQuickKeysAttached *QQuickKeysAttached::qmlAttachedProperties(QObject *obj)
from left to right by default, they are now positioned from right to left instead, as demonstrated
by the numbering and opacity of the items:
- \snippet doc/src/snippets/declarative/layoutmirroring.qml 0
+ \snippet doc/src/snippets/qml/layoutmirroring.qml 0
\image layoutmirroring.png
@@ -1626,7 +1627,7 @@ void QQuickItemPrivate::setAccessibleFlagAndListener()
\inmodule QtQuick
- All visual items in Qt Declarative inherit from QQuickItem. Although QQuickItem
+ All visual items in Qt Quick inherit from QQuickItem. Although QQuickItem
has no visual appearance, it defines all the properties that are
common across visual items - such as the x and y position, the
width and height, \l {anchor-layout}{anchoring} and key handling.
@@ -1645,7 +1646,7 @@ void QQuickItemPrivate::setAccessibleFlagAndListener()
\ingroup qml-basic-visual-elements
\brief The Item is the most basic of all visual items in QML.
- All visual items in Qt Declarative inherit from Item. Although Item
+ All visual items in Qt Quick inherit from Item. Although Item
has no visual appearance, it defines all the properties that are
common across visual items - such as the x and y position, the
width and height, \l {anchor-layout}{anchoring} and key handling.
@@ -2351,7 +2352,7 @@ void QQuickItemPrivate::init(QQuickItem *parent)
}
}
-void QQuickItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
+void QQuickItemPrivate::data_append(QQmlListProperty<QObject> *prop, QObject *o)
{
if (!o)
return;
@@ -2410,14 +2411,14 @@ void QQuickItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QOb
specify it.
*/
-int QQuickItemPrivate::data_count(QDeclarativeListProperty<QObject> *prop)
+int QQuickItemPrivate::data_count(QQmlListProperty<QObject> *prop)
{
Q_UNUSED(prop);
// XXX todo
return 0;
}
-QObject *QQuickItemPrivate::data_at(QDeclarativeListProperty<QObject> *prop, int i)
+QObject *QQuickItemPrivate::data_at(QQmlListProperty<QObject> *prop, int i)
{
Q_UNUSED(prop);
Q_UNUSED(i);
@@ -2425,13 +2426,13 @@ QObject *QQuickItemPrivate::data_at(QDeclarativeListProperty<QObject> *prop, int
return 0;
}
-void QQuickItemPrivate::data_clear(QDeclarativeListProperty<QObject> *prop)
+void QQuickItemPrivate::data_clear(QQmlListProperty<QObject> *prop)
{
Q_UNUSED(prop);
// XXX todo
}
-QObject *QQuickItemPrivate::resources_at(QDeclarativeListProperty<QObject> *prop, int index)
+QObject *QQuickItemPrivate::resources_at(QQmlListProperty<QObject> *prop, int index)
{
const QObjectList children = prop->object->children();
if (index < children.count())
@@ -2440,18 +2441,18 @@ QObject *QQuickItemPrivate::resources_at(QDeclarativeListProperty<QObject> *prop
return 0;
}
-void QQuickItemPrivate::resources_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
+void QQuickItemPrivate::resources_append(QQmlListProperty<QObject> *prop, QObject *o)
{
// XXX todo - do we really want this behavior?
o->setParent(prop->object);
}
-int QQuickItemPrivate::resources_count(QDeclarativeListProperty<QObject> *prop)
+int QQuickItemPrivate::resources_count(QQmlListProperty<QObject> *prop)
{
return prop->object->children().count();
}
-void QQuickItemPrivate::resources_clear(QDeclarativeListProperty<QObject> *prop)
+void QQuickItemPrivate::resources_clear(QQmlListProperty<QObject> *prop)
{
// XXX todo - do we really want this behavior?
const QObjectList children = prop->object->children();
@@ -2459,7 +2460,7 @@ void QQuickItemPrivate::resources_clear(QDeclarativeListProperty<QObject> *prop)
children.at(index)->setParent(0);
}
-QQuickItem *QQuickItemPrivate::children_at(QDeclarativeListProperty<QQuickItem> *prop, int index)
+QQuickItem *QQuickItemPrivate::children_at(QQmlListProperty<QQuickItem> *prop, int index)
{
QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
if (index >= p->childItems.count() || index < 0)
@@ -2468,7 +2469,7 @@ QQuickItem *QQuickItemPrivate::children_at(QDeclarativeListProperty<QQuickItem>
return p->childItems.at(index);
}
-void QQuickItemPrivate::children_append(QDeclarativeListProperty<QQuickItem> *prop, QQuickItem *o)
+void QQuickItemPrivate::children_append(QQmlListProperty<QQuickItem> *prop, QQuickItem *o)
{
if (!o)
return;
@@ -2480,13 +2481,13 @@ void QQuickItemPrivate::children_append(QDeclarativeListProperty<QQuickItem> *pr
o->setParentItem(that);
}
-int QQuickItemPrivate::children_count(QDeclarativeListProperty<QQuickItem> *prop)
+int QQuickItemPrivate::children_count(QQmlListProperty<QQuickItem> *prop)
{
QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
return p->childItems.count();
}
-void QQuickItemPrivate::children_clear(QDeclarativeListProperty<QQuickItem> *prop)
+void QQuickItemPrivate::children_clear(QQmlListProperty<QQuickItem> *prop)
{
QQuickItem *that = static_cast<QQuickItem *>(prop->object);
QQuickItemPrivate *p = QQuickItemPrivate::get(that);
@@ -2494,13 +2495,13 @@ void QQuickItemPrivate::children_clear(QDeclarativeListProperty<QQuickItem> *pro
p->childItems.at(0)->setParentItem(0);
}
-void QQuickItemPrivate::visibleChildren_append(QDeclarativeListProperty<QQuickItem>*, QQuickItem *self)
+void QQuickItemPrivate::visibleChildren_append(QQmlListProperty<QQuickItem>*, QQuickItem *self)
{
// do nothing
qmlInfo(self) << "QQuickItem: visibleChildren property is readonly and cannot be assigned to.";
}
-int QQuickItemPrivate::visibleChildren_count(QDeclarativeListProperty<QQuickItem> *prop)
+int QQuickItemPrivate::visibleChildren_count(QQmlListProperty<QQuickItem> *prop)
{
QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
int visibleCount = 0;
@@ -2512,7 +2513,7 @@ int QQuickItemPrivate::visibleChildren_count(QDeclarativeListProperty<QQuickItem
return visibleCount;
}
-QQuickItem *QQuickItemPrivate::visibleChildren_at(QDeclarativeListProperty<QQuickItem> *prop, int index)
+QQuickItem *QQuickItemPrivate::visibleChildren_at(QQmlListProperty<QQuickItem> *prop, int index)
{
QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
const int childCount = p->childItems.count();
@@ -2527,7 +2528,7 @@ QQuickItem *QQuickItemPrivate::visibleChildren_at(QDeclarativeListProperty<QQuic
return 0;
}
-int QQuickItemPrivate::transform_count(QDeclarativeListProperty<QQuickTransform> *prop)
+int QQuickItemPrivate::transform_count(QQmlListProperty<QQuickTransform> *prop)
{
QQuickItem *that = static_cast<QQuickItem *>(prop->object);
QQuickItemPrivate *p = QQuickItemPrivate::get(that);
@@ -2573,7 +2574,7 @@ void QQuickTransform::prependToItem(QQuickItem *item)
p->dirty(QQuickItemPrivate::Transform);
}
-void QQuickItemPrivate::transform_append(QDeclarativeListProperty<QQuickTransform> *prop, QQuickTransform *transform)
+void QQuickItemPrivate::transform_append(QQmlListProperty<QQuickTransform> *prop, QQuickTransform *transform)
{
if (!transform)
return;
@@ -2582,7 +2583,7 @@ void QQuickItemPrivate::transform_append(QDeclarativeListProperty<QQuickTransfor
transform->appendToItem(that);
}
-QQuickTransform *QQuickItemPrivate::transform_at(QDeclarativeListProperty<QQuickTransform> *prop, int idx)
+QQuickTransform *QQuickItemPrivate::transform_at(QQmlListProperty<QQuickTransform> *prop, int idx)
{
QQuickItem *that = static_cast<QQuickItem *>(prop->object);
QQuickItemPrivate *p = QQuickItemPrivate::get(that);
@@ -2593,7 +2594,7 @@ QQuickTransform *QQuickItemPrivate::transform_at(QDeclarativeListProperty<QQuick
return p->transforms.at(idx);
}
-void QQuickItemPrivate::transform_clear(QDeclarativeListProperty<QQuickTransform> *prop)
+void QQuickItemPrivate::transform_clear(QQmlListProperty<QQuickTransform> *prop)
{
QQuickItem *that = static_cast<QQuickItem *>(prop->object);
QQuickItemPrivate *p = QQuickItemPrivate::get(that);
@@ -2852,9 +2853,9 @@ void QQuickItemPrivate::siblingOrderChanged()
}
}
-QDeclarativeListProperty<QObject> QQuickItemPrivate::data()
+QQmlListProperty<QObject> QQuickItemPrivate::data()
{
- return QDeclarativeListProperty<QObject>(q_func(), 0, QQuickItemPrivate::data_append,
+ return QQmlListProperty<QObject>(q_func(), 0, QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
QQuickItemPrivate::data_at,
QQuickItemPrivate::data_clear);
@@ -3233,7 +3234,7 @@ void QQuickItem::polish()
}
}
-void QQuickItem::mapFromItem(QDeclarativeV8Function *args) const
+void QQuickItem::mapFromItem(QQmlV8Function *args) const
{
if (args->Length() != 0) {
v8::Local<v8::Value> item = (*args)[0];
@@ -3276,7 +3277,7 @@ QTransform QQuickItem::itemTransform(QQuickItem *other, bool *ok) const
return t;
}
-void QQuickItem::mapToItem(QDeclarativeV8Function *args) const
+void QQuickItem::mapToItem(QQmlV8Function *args) const
{
if (args->Length() != 0) {
v8::Local<v8::Value> item = (*args)[0];
@@ -3332,17 +3333,17 @@ QQuickItem *QQuickItem::childAt(qreal x, qreal y) const
return 0;
}
-QDeclarativeListProperty<QObject> QQuickItemPrivate::resources()
+QQmlListProperty<QObject> QQuickItemPrivate::resources()
{
- return QDeclarativeListProperty<QObject>(q_func(), 0, QQuickItemPrivate::resources_append,
+ return QQmlListProperty<QObject>(q_func(), 0, QQuickItemPrivate::resources_append,
QQuickItemPrivate::resources_count,
QQuickItemPrivate::resources_at,
QQuickItemPrivate::resources_clear);
}
-QDeclarativeListProperty<QQuickItem> QQuickItemPrivate::children()
+QQmlListProperty<QQuickItem> QQuickItemPrivate::children()
{
- return QDeclarativeListProperty<QQuickItem>(q_func(), 0, QQuickItemPrivate::children_append,
+ return QQmlListProperty<QQuickItem>(q_func(), 0, QQuickItemPrivate::children_append,
QQuickItemPrivate::children_count,
QQuickItemPrivate::children_at,
QQuickItemPrivate::children_clear);
@@ -3355,20 +3356,20 @@ QDeclarativeListProperty<QQuickItem> QQuickItemPrivate::children()
Note that a child's visibility may have changed explicitly, or because the visibility
of this (it's parent) item or another grandparent changed.
*/
-QDeclarativeListProperty<QQuickItem> QQuickItemPrivate::visibleChildren()
+QQmlListProperty<QQuickItem> QQuickItemPrivate::visibleChildren()
{
- return QDeclarativeListProperty<QQuickItem>(q_func(), 0, QQuickItemPrivate::visibleChildren_append,
+ return QQmlListProperty<QQuickItem>(q_func(), 0, QQuickItemPrivate::visibleChildren_append,
QQuickItemPrivate::visibleChildren_count,
QQuickItemPrivate::visibleChildren_at);
}
-QDeclarativeListProperty<QDeclarativeState> QQuickItemPrivate::states()
+QQmlListProperty<QQuickState> QQuickItemPrivate::states()
{
return _states()->statesProperty();
}
-QDeclarativeListProperty<QDeclarativeTransition> QQuickItemPrivate::transitions()
+QQmlListProperty<QQuickTransition> QQuickItemPrivate::transitions()
{
return _states()->transitionsProperty();
}
@@ -3398,9 +3399,9 @@ void QQuickItem::setState(const QString &state)
d->setState(state);
}
-QDeclarativeListProperty<QQuickTransform> QQuickItem::transform()
+QQmlListProperty<QQuickTransform> QQuickItem::transform()
{
- return QDeclarativeListProperty<QQuickTransform>(this, 0, QQuickItemPrivate::transform_append,
+ return QQmlListProperty<QQuickTransform>(this, 0, QQuickItemPrivate::transform_append,
QQuickItemPrivate::transform_count,
QQuickItemPrivate::transform_at,
QQuickItemPrivate::transform_clear);
@@ -3439,11 +3440,11 @@ void QQuickItem::componentComplete()
d->extra->contents->complete();
}
-QDeclarativeStateGroup *QQuickItemPrivate::_states()
+QQuickStateGroup *QQuickItemPrivate::_states()
{
Q_Q(QQuickItem);
if (!_stateGroup) {
- _stateGroup = new QDeclarativeStateGroup;
+ _stateGroup = new QQuickStateGroup;
if (!componentComplete)
_stateGroup->classBegin();
FAST_CONNECT(_stateGroup, SIGNAL(stateChanged(QString)),
@@ -5566,7 +5567,7 @@ void QQuickItemLayer::deactivateEffect()
\sa samplerName
*/
-void QQuickItemLayer::setEffect(QDeclarativeComponent *component)
+void QQuickItemLayer::setEffect(QQmlComponent *component)
{
if (component == m_effectComponent)
return;
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index 7f98db9168..c44192bd3a 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,8 +43,8 @@
#define QQUICKITEM_H
#include <QtQuick/qtquickglobal.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlcomponent.h>
#include <QtCore/QObject>
#include <QtCore/QList>
@@ -81,10 +81,10 @@ private:
};
class QQuickItemLayer;
-class QDeclarativeV8Function;
-class QDeclarativeState;
+class QQmlV8Function;
+class QQuickState;
class QQuickAnchorLine;
-class QDeclarativeTransition;
+class QQuickTransition;
class QQuickKeyEvent;
class QQuickAnchors;
class QQuickItemPrivate;
@@ -95,15 +95,15 @@ class QSGNode;
class QSGTransformNode;
class QSGTextureProvider;
-class Q_QUICK_EXPORT QQuickItem : public QObject, public QDeclarativeParserStatus
+class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
{
Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
+ Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QQuickItem *parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
- Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QDeclarativeListProperty<QObject> data READ data DESIGNABLE false)
- Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QDeclarativeListProperty<QObject> resources READ resources DESIGNABLE false)
- Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QDeclarativeListProperty<QQuickItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
+ Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQmlListProperty<QObject> data READ data DESIGNABLE false)
+ Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQmlListProperty<QObject> resources READ resources DESIGNABLE false)
+ Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQmlListProperty<QQuickItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
Q_PROPERTY(QPointF pos READ pos FINAL)
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL)
@@ -115,10 +115,10 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QDeclarativeParserStatu
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
- Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QDeclarativeListProperty<QQuickItem> visibleChildren READ visibleChildren NOTIFY visibleChildrenChanged DESIGNABLE false)
+ Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQmlListProperty<QQuickItem> visibleChildren READ visibleChildren NOTIFY visibleChildrenChanged DESIGNABLE false)
- Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QDeclarativeListProperty<QDeclarativeState> states READ states DESIGNABLE false)
- Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QDeclarativeListProperty<QDeclarativeTransition> transitions READ transitions DESIGNABLE false)
+ Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQmlListProperty<QQuickState> states READ states DESIGNABLE false)
+ Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQmlListProperty<QQuickTransition> transitions READ transitions DESIGNABLE false)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL)
Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQuickAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
@@ -140,7 +140,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QDeclarativeParserStatu
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged)
Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint) // XXX todo - notify?
- Q_PROPERTY(QDeclarativeListProperty<QQuickTransform> transform READ transform DESIGNABLE false FINAL)
+ Q_PROPERTY(QQmlListProperty<QQuickTransform> transform READ transform DESIGNABLE false FINAL)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged)
@@ -215,7 +215,7 @@ public:
qreal baselineOffset() const;
void setBaselineOffset(qreal);
- QDeclarativeListProperty<QQuickTransform> transform();
+ QQmlListProperty<QQuickTransform> transform();
qreal x() const;
qreal y() const;
@@ -303,8 +303,8 @@ public:
void polish();
- Q_INVOKABLE void mapFromItem(QDeclarativeV8Function*) const;
- Q_INVOKABLE void mapToItem(QDeclarativeV8Function*) const;
+ Q_INVOKABLE void mapFromItem(QQmlV8Function*) const;
+ Q_INVOKABLE void mapToItem(QQmlV8Function*) const;
Q_INVOKABLE void forceActiveFocus();
Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const;
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index fd02334ab3..03fc66eadb 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -65,14 +65,14 @@
#include "qquickclipnode_p.h"
#include <private/qpodvector_p.h>
-#include <QtQuick/private/qdeclarativestate_p.h>
-#include <private/qdeclarativenullablevalue_p_p.h>
-#include <private/qdeclarativenotifier_p.h>
-#include <private/qdeclarativeglobal_p.h>
+#include <QtQuick/private/qquickstate_p.h>
+#include <private/qqmlnullablevalue_p_p.h>
+#include <private/qqmlnotifier_p.h>
+#include <private/qqmlglobal_p.h>
#include <private/qlazilyallocated_p.h>
-#include <qdeclarative.h>
-#include <qdeclarativecontext.h>
+#include <qqml.h>
+#include <qqmlcontext.h>
#include <QtCore/qlist.h>
#include <QtCore/qdebug.h>
@@ -149,7 +149,7 @@ class QQuickItemLayer : public QObject, public QQuickItemChangeListener
Q_PROPERTY(QQuickShaderEffectSource::WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
Q_PROPERTY(QQuickShaderEffectSource::Format format READ format WRITE setFormat NOTIFY formatChanged)
Q_PROPERTY(QByteArray samplerName READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QDeclarativeComponent *effect READ effect WRITE setEffect NOTIFY effectChanged)
+ Q_PROPERTY(QQmlComponent *effect READ effect WRITE setEffect NOTIFY effectChanged)
public:
QQuickItemLayer(QQuickItem *item);
~QQuickItemLayer();
@@ -181,8 +181,8 @@ public:
QByteArray name() const { return m_name; }
void setName(const QByteArray &name);
- QDeclarativeComponent *effect() const { return m_effectComponent; }
- void setEffect(QDeclarativeComponent *effect);
+ QQmlComponent *effect() const { return m_effectComponent; }
+ void setEffect(QQmlComponent *effect);
QQuickShaderEffectSource *effectSource() const { return m_effectSource; }
@@ -203,7 +203,7 @@ signals:
void mipmapChanged(bool mipmap);
void wrapModeChanged(QQuickShaderEffectSource::WrapMode mode);
void nameChanged(const QByteArray &name);
- void effectChanged(QDeclarativeComponent *component);
+ void effectChanged(QQmlComponent *component);
void smoothChanged(bool smooth);
void formatChanged(QQuickShaderEffectSource::Format format);
void sourceRectChanged(const QRectF &sourceRect);
@@ -224,7 +224,7 @@ private:
QSize m_size;
QRectF m_sourceRect;
QByteArray m_name;
- QDeclarativeComponent *m_effectComponent;
+ QQmlComponent *m_effectComponent;
QQuickItem *m_effect;
QQuickShaderEffectSource *m_effectSource;
};
@@ -243,13 +243,13 @@ public:
~QQuickItemPrivate();
void init(QQuickItem *parent);
- QDeclarativeListProperty<QObject> data();
- QDeclarativeListProperty<QObject> resources();
- QDeclarativeListProperty<QQuickItem> children();
- QDeclarativeListProperty<QQuickItem> visibleChildren();
+ QQmlListProperty<QObject> data();
+ QQmlListProperty<QObject> resources();
+ QQmlListProperty<QQuickItem> children();
+ QQmlListProperty<QQuickItem> visibleChildren();
- QDeclarativeListProperty<QDeclarativeState> states();
- QDeclarativeListProperty<QDeclarativeTransition> transitions();
+ QQmlListProperty<QQuickState> states();
+ QQmlListProperty<QQuickTransition> transitions();
QString state() const;
void setState(const QString &);
@@ -265,33 +265,33 @@ public:
QQuickItemLayer *layer() const;
// data property
- static void data_append(QDeclarativeListProperty<QObject> *, QObject *);
- static int data_count(QDeclarativeListProperty<QObject> *);
- static QObject *data_at(QDeclarativeListProperty<QObject> *, int);
- static void data_clear(QDeclarativeListProperty<QObject> *);
+ static void data_append(QQmlListProperty<QObject> *, QObject *);
+ static int data_count(QQmlListProperty<QObject> *);
+ static QObject *data_at(QQmlListProperty<QObject> *, int);
+ static void data_clear(QQmlListProperty<QObject> *);
// resources property
- static QObject *resources_at(QDeclarativeListProperty<QObject> *, int);
- static void resources_append(QDeclarativeListProperty<QObject> *, QObject *);
- static int resources_count(QDeclarativeListProperty<QObject> *);
- static void resources_clear(QDeclarativeListProperty<QObject> *);
+ static QObject *resources_at(QQmlListProperty<QObject> *, int);
+ static void resources_append(QQmlListProperty<QObject> *, QObject *);
+ static int resources_count(QQmlListProperty<QObject> *);
+ static void resources_clear(QQmlListProperty<QObject> *);
// children property
- static void children_append(QDeclarativeListProperty<QQuickItem> *, QQuickItem *);
- static int children_count(QDeclarativeListProperty<QQuickItem> *);
- static QQuickItem *children_at(QDeclarativeListProperty<QQuickItem> *, int);
- static void children_clear(QDeclarativeListProperty<QQuickItem> *);
+ static void children_append(QQmlListProperty<QQuickItem> *, QQuickItem *);
+ static int children_count(QQmlListProperty<QQuickItem> *);
+ static QQuickItem *children_at(QQmlListProperty<QQuickItem> *, int);
+ static void children_clear(QQmlListProperty<QQuickItem> *);
// visibleChildren property
- static void visibleChildren_append(QDeclarativeListProperty<QQuickItem> *prop, QQuickItem *o);
- static int visibleChildren_count(QDeclarativeListProperty<QQuickItem> *prop);
- static QQuickItem *visibleChildren_at(QDeclarativeListProperty<QQuickItem> *prop, int index);
+ static void visibleChildren_append(QQmlListProperty<QQuickItem> *prop, QQuickItem *o);
+ static int visibleChildren_count(QQmlListProperty<QQuickItem> *prop);
+ static QQuickItem *visibleChildren_at(QQmlListProperty<QQuickItem> *prop, int index);
// transform property
- static int transform_count(QDeclarativeListProperty<QQuickTransform> *list);
- static void transform_append(QDeclarativeListProperty<QQuickTransform> *list, QQuickTransform *);
- static QQuickTransform *transform_at(QDeclarativeListProperty<QQuickTransform> *list, int);
- static void transform_clear(QDeclarativeListProperty<QQuickTransform> *list);
+ static int transform_count(QQmlListProperty<QQuickTransform> *list);
+ static void transform_append(QQmlListProperty<QQuickTransform> *list, QQuickTransform *);
+ static QQuickTransform *transform_at(QQmlListProperty<QQuickTransform> *list, int);
+ static void transform_clear(QQmlListProperty<QQuickTransform> *list);
enum ChangeType {
Geometry = 0x01,
@@ -372,8 +372,8 @@ public:
void updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, GeometryChangeTypes types);
void updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener, GeometryChangeTypes types);
- QDeclarativeStateGroup *_states();
- QDeclarativeStateGroup *_stateGroup;
+ QQuickStateGroup *_states();
+ QQuickStateGroup *_stateGroup;
inline QQuickItem::TransformOrigin origin() const;
@@ -453,7 +453,7 @@ public:
inline QSGContext *sceneGraphContext() const;
QQuickItem *parentItem;
- QDeclarativeNotifier parentNotifier;
+ QQmlNotifier parentNotifier;
QList<QQuickItem *> childItems;
mutable QList<QQuickItem *> *sortedChildItems;
@@ -723,7 +723,7 @@ class QQuickKeysAttached : public QObject, public QQuickItemKeyFilter
Q_DECLARE_PRIVATE(QQuickKeysAttached)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(QDeclarativeListProperty<QQuickItem> forwardTo READ forwardTo)
+ Q_PROPERTY(QQmlListProperty<QQuickItem> forwardTo READ forwardTo)
Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
Q_ENUMS(Priority)
@@ -745,9 +745,9 @@ public:
Priority priority() const;
void setPriority(Priority);
- QDeclarativeListProperty<QQuickItem> forwardTo() {
+ QQmlListProperty<QQuickItem> forwardTo() {
Q_D(QQuickKeysAttached);
- return QDeclarativeListProperty<QQuickItem>(this, d->targets);
+ return QQmlListProperty<QQuickItem>(this, d->targets);
}
virtual void componentComplete();
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp
new file mode 100644
index 0000000000..32f1047e51
--- /dev/null
+++ b/src/quick/items/qquickitemanimation.cpp
@@ -0,0 +1,1044 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickitemanimation_p.h"
+#include "qquickitemanimation_p_p.h"
+#include "qquickstateoperations_p.h"
+
+#include <private/qqmlproperty_p.h>
+#include <private/qquickpath_p.h>
+
+#include <QtQml/qqmlinfo.h>
+#include <QtCore/qmath.h>
+#include "private/qsequentialanimationgroupjob_p.h"
+#include "private/qparallelanimationgroupjob_p.h"
+#include <QtGui/qtransform.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass ParentAnimation QQuickParentAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \since QtQuick 2.0
+ \inherits Animation
+ \brief The ParentAnimation element animates changes in parent values.
+
+ ParentAnimation is used to animate a parent change for an \l Item.
+
+ 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/qml/parentanimation.qml 0
+
+ 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 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.
+
+ For convenience, when a ParentAnimation is used in a \l Transition, it will
+ animate any ParentChange that has occurred during the state change.
+ This can be overridden by setting a specific target item using the
+ \l target property.
+
+ Like any other animation element, a ParentAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
+*/
+QQuickParentAnimation::QQuickParentAnimation(QObject *parent)
+ : QQuickAnimationGroup(*(new QQuickParentAnimationPrivate), parent)
+{
+}
+
+QQuickParentAnimation::~QQuickParentAnimation()
+{
+}
+
+/*!
+ \qmlproperty Item QtQuick2::ParentAnimation::target
+ The item to reparent.
+
+ When used in a transition, if no target is specified, all
+ ParentChange occurrences are animated by the ParentAnimation.
+*/
+QQuickItem *QQuickParentAnimation::target() const
+{
+ Q_D(const QQuickParentAnimation);
+ return d->target;
+}
+
+void QQuickParentAnimation::setTargetObject(QQuickItem *target)
+{
+ Q_D(QQuickParentAnimation);
+ if (target == d->target)
+ return;
+
+ d->target = target;
+ emit targetChanged();
+}
+
+/*!
+ \qmlproperty Item QtQuick2::ParentAnimation::newParent
+ The new parent to animate to.
+
+ If the ParentAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the end state of the
+ \l Transition, or the value of the property change that triggered the
+ \l Behavior.
+*/
+QQuickItem *QQuickParentAnimation::newParent() const
+{
+ Q_D(const QQuickParentAnimation);
+ return d->newParent;
+}
+
+void QQuickParentAnimation::setNewParent(QQuickItem *newParent)
+{
+ Q_D(QQuickParentAnimation);
+ if (newParent == d->newParent)
+ return;
+
+ d->newParent = newParent;
+ emit newParentChanged();
+}
+
+/*!
+ \qmlproperty Item QtQuick2::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.
+
+ \qml
+ ParentAnimation {
+ target: myItem
+ via: topLevelItem
+ // ...
+ }
+ \endqml
+*/
+QQuickItem *QQuickParentAnimation::via() const
+{
+ Q_D(const QQuickParentAnimation);
+ return d->via;
+}
+
+void QQuickParentAnimation::setVia(QQuickItem *via)
+{
+ Q_D(QQuickParentAnimation);
+ if (via == d->via)
+ return;
+
+ d->via = via;
+ emit viaChanged();
+}
+
+//### mirrors same-named function in QQuickItem
+QPointF QQuickParentAnimationPrivate::computeTransformOrigin(QQuickItem::TransformOrigin origin, qreal width, qreal height) const
+{
+ switch (origin) {
+ default:
+ case QQuickItem::TopLeft:
+ return QPointF(0, 0);
+ case QQuickItem::Top:
+ return QPointF(width / 2., 0);
+ case QQuickItem::TopRight:
+ return QPointF(width, 0);
+ case QQuickItem::Left:
+ return QPointF(0, height / 2.);
+ case QQuickItem::Center:
+ return QPointF(width / 2., height / 2.);
+ case QQuickItem::Right:
+ return QPointF(width, height / 2.);
+ case QQuickItem::BottomLeft:
+ return QPointF(0, height);
+ case QQuickItem::Bottom:
+ return QPointF(width / 2., height);
+ case QQuickItem::BottomRight:
+ return QPointF(width, height);
+ }
+}
+
+QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickParentAnimation);
+
+ struct QQuickParentAnimationData : public QAbstractAnimationAction
+ {
+ QQuickParentAnimationData() {}
+ ~QQuickParentAnimationData() { qDeleteAll(pc); }
+
+ QQuickStateActions actions;
+ //### reverse should probably apply on a per-action basis
+ bool reverse;
+ QList<QQuickParentChange *> pc;
+ virtual void doAction()
+ {
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ const QQuickAction &action = actions.at(ii);
+ if (reverse)
+ action.event->reverse();
+ else
+ action.event->execute();
+ }
+ }
+ };
+
+ QQuickParentAnimationData *data = new QQuickParentAnimationData;
+ QQuickParentAnimationData *viaData = new QQuickParentAnimationData;
+
+ bool hasExplicit = false;
+ if (d->target && d->newParent) {
+ data->reverse = false;
+ QQuickAction myAction;
+ QQuickParentChange *pc = new QQuickParentChange;
+ pc->setObject(d->target);
+ pc->setParent(d->newParent);
+ myAction.event = pc;
+ data->pc << pc;
+ data->actions << myAction;
+ hasExplicit = true;
+ if (d->via) {
+ viaData->reverse = false;
+ QQuickAction myVAction;
+ QQuickParentChange *vpc = new QQuickParentChange;
+ vpc->setObject(d->target);
+ vpc->setParent(d->via);
+ myVAction.event = vpc;
+ viaData->pc << vpc;
+ viaData->actions << myVAction;
+ }
+ //### once actions have concept of modified,
+ // loop to match appropriate ParentChanges and mark as modified
+ }
+
+ if (!hasExplicit)
+ for (int i = 0; i < actions.size(); ++i) {
+ QQuickAction &action = actions[i];
+ if (action.event && action.event->type() == QQuickActionEvent::ParentChange
+ && (!d->target || static_cast<QQuickParentChange*>(action.event)->object() == d->target)) {
+
+ QQuickParentChange *pc = static_cast<QQuickParentChange*>(action.event);
+ QQuickAction myAction = action;
+ data->reverse = action.reverseEvent;
+
+ //### this logic differs from PropertyAnimation
+ // (probably a result of modified vs. done)
+ if (d->newParent) {
+ QQuickParentChange *epc = new QQuickParentChange;
+ epc->setObject(static_cast<QQuickParentChange*>(action.event)->object());
+ epc->setParent(d->newParent);
+ myAction.event = epc;
+ data->pc << epc;
+ data->actions << myAction;
+ pc = epc;
+ } else {
+ action.actionDone = true;
+ data->actions << myAction;
+ }
+
+ if (d->via) {
+ viaData->reverse = false;
+ QQuickAction myAction;
+ QQuickParentChange *vpc = new QQuickParentChange;
+ vpc->setObject(pc->object());
+ vpc->setParent(d->via);
+ myAction.event = vpc;
+ viaData->pc << vpc;
+ viaData->actions << myAction;
+ QQuickAction dummyAction;
+ QQuickAction &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
+ QQuickAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
+ QQuickAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
+ QQuickAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
+ QQuickItem *target = pc->object();
+ QQuickItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent();
+
+ //### this mirrors the logic in QQuickParentChange.
+ bool ok;
+ const QTransform &transform = targetParent->itemTransform(d->via, &ok);
+ if (transform.type() >= QTransform::TxShear || !ok) {
+ qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under complex transform");
+ ok = false;
+ }
+
+ qreal scale = 1;
+ qreal rotation = 0;
+ bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0);
+ if (ok && !isRotate) {
+ if (transform.m11() == transform.m22())
+ scale = transform.m11();
+ else {
+ qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
+ ok = false;
+ }
+ } else if (ok && isRotate) {
+ if (transform.m11() == transform.m22())
+ scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
+ else {
+ qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
+ ok = false;
+ }
+
+ if (scale != 0)
+ rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
+ else {
+ qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under scale of 0");
+ ok = false;
+ }
+ }
+
+ const QPointF &point = transform.map(QPointF(xAction.toValue.toReal(),yAction.toValue.toReal()));
+ qreal x = point.x();
+ qreal y = point.y();
+ if (ok && target->transformOrigin() != QQuickItem::TopLeft) {
+ qreal w = target->width();
+ qreal h = target->height();
+ if (pc->widthIsSet() && i < actions.size() - 1)
+ w = actions[++i].toValue.toReal();
+ if (pc->heightIsSet() && i < actions.size() - 1)
+ h = actions[++i].toValue.toReal();
+ const QPointF &transformOrigin
+ = d->computeTransformOrigin(target->transformOrigin(), w,h);
+ qreal tempxt = transformOrigin.x();
+ qreal tempyt = transformOrigin.y();
+ QTransform t;
+ t.translate(-tempxt, -tempyt);
+ t.rotate(rotation);
+ t.scale(scale, scale);
+ t.translate(tempxt, tempyt);
+ const QPointF &offset = t.map(QPointF(0,0));
+ x += offset.x();
+ y += offset.y();
+ }
+
+ if (ok) {
+ //qDebug() << x << y << rotation << scale;
+ xAction.toValue = x;
+ yAction.toValue = y;
+ sAction.toValue = sAction.toValue.toReal() * scale;
+ rAction.toValue = rAction.toValue.toReal() + rotation;
+ }
+ }
+ }
+ }
+
+ QSequentialAnimationGroupJob *topLevelGroup = new QSequentialAnimationGroupJob;
+ QActionAnimation *viaAction = d->via ? new QActionAnimation : 0;
+ QActionAnimation *targetAction = new QActionAnimation;
+ //we'll assume the common case by far is to have children, and always create ag
+ QParallelAnimationGroupJob *ag = new QParallelAnimationGroupJob;
+
+ if (data->actions.count()) {
+ if (d->via)
+ viaAction->setAnimAction(viaData);
+ targetAction->setAnimAction(data);
+
+ //take care of any child animations
+ bool valid = d->defaultProperty.isValid();
+ QAbstractAnimationJob* anim;
+ for (int ii = 0; ii < d->animations.count(); ++ii) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
+ anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
+ ag->appendAnimation(anim);
+ }
+
+ //TODO: simplify/clarify logic
+ bool forwards = direction == QQuickAbstractAnimation::Forward;
+ if (forwards) {
+ topLevelGroup->appendAnimation(d->via ? viaAction : targetAction);
+ topLevelGroup->appendAnimation(ag);
+ if (d->via)
+ topLevelGroup->appendAnimation(targetAction);
+ } else {
+ if (d->via)
+ topLevelGroup->appendAnimation(targetAction);
+ topLevelGroup->appendAnimation(ag);
+ topLevelGroup->appendAnimation(d->via ? viaAction : targetAction);
+ }
+ } else {
+ delete data;
+ delete viaData;
+ }
+
+ return initInstance(topLevelGroup);
+}
+
+/*!
+ \qmlclass AnchorAnimation QQuickAnchorAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits Animation
+ \brief The AnchorAnimation element animates changes in anchor values.
+
+ AnchorAnimation is used to animate an anchor change.
+
+ In the following snippet we animate the addition of a right anchor to a \l Rectangle:
+
+ \snippet doc/src/snippets/qml/anchoranimation.qml 0
+
+ For convenience, when an AnchorAnimation is used in a \l Transition, it will
+ animate any AnchorChanges that have occurred during the state change.
+ This can be overridden by setting a specific target item using the
+ \l target property.
+
+ Like any other animation element, an AnchorAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ \sa {QML Animation and Transitions}, AnchorChanges
+*/
+QQuickAnchorAnimation::QQuickAnchorAnimation(QObject *parent)
+: QQuickAbstractAnimation(*(new QQuickAnchorAnimationPrivate), parent)
+{
+}
+
+QQuickAnchorAnimation::~QQuickAnchorAnimation()
+{
+}
+
+/*!
+ \qmlproperty list<Item> QtQuick2::AnchorAnimation::targets
+ The items to reanchor.
+
+ If no targets are specified all AnchorChanges will be
+ animated by the AnchorAnimation.
+*/
+QQmlListProperty<QQuickItem> QQuickAnchorAnimation::targets()
+{
+ Q_D(QQuickAnchorAnimation);
+ return QQmlListProperty<QQuickItem>(this, d->targets);
+}
+
+/*!
+ \qmlproperty int QtQuick2::AnchorAnimation::duration
+ This property holds the duration of the animation, in milliseconds.
+
+ The default value is 250.
+*/
+int QQuickAnchorAnimation::duration() const
+{
+ Q_D(const QQuickAnchorAnimation);
+ return d->duration;
+}
+
+void QQuickAnchorAnimation::setDuration(int duration)
+{
+ if (duration < 0) {
+ qmlInfo(this) << tr("Cannot set a duration of < 0");
+ return;
+ }
+
+ Q_D(QQuickAnchorAnimation);
+ if (d->duration == duration)
+ return;
+ d->duration = duration;
+ emit durationChanged(duration);
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::AnchorAnimation::easing.type
+ \qmlproperty real QtQuick2::AnchorAnimation::easing.amplitude
+ \qmlproperty real QtQuick2::AnchorAnimation::easing.overshoot
+ \qmlproperty real QtQuick2::AnchorAnimation::easing.period
+ \brief the easing curve used for the animation.
+
+ To specify an easing curve you need to specify at least the type. For some curves you can also specify
+ amplitude, period and/or overshoot. The default easing curve is
+ Linear.
+
+ \qml
+ AnchorAnimation { easing.type: Easing.InOutQuad }
+ \endqml
+
+ See the \l{PropertyAnimation::easing.type} documentation for information
+ about the different types of easing curves.
+*/
+QEasingCurve QQuickAnchorAnimation::easing() const
+{
+ Q_D(const QQuickAnchorAnimation);
+ return d->easing;
+}
+
+void QQuickAnchorAnimation::setEasing(const QEasingCurve &e)
+{
+ Q_D(QQuickAnchorAnimation);
+ if (d->easing == e)
+ return;
+
+ d->easing = e;
+ emit easingChanged(e);
+}
+
+QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_UNUSED(modified);
+ Q_UNUSED(defaultTarget);
+ Q_D(QQuickAnchorAnimation);
+ QQuickAnimationPropertyUpdater *data = new QQuickAnimationPropertyUpdater;
+ data->interpolatorType = QMetaType::QReal;
+ data->interpolator = d->interpolator;
+ data->reverse = direction == Backward ? true : false;
+ data->fromSourced = false;
+ data->fromDefined = false;
+
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QQuickAction &action = actions[ii];
+ if (action.event && action.event->type() == QQuickActionEvent::AnchorChanges
+ && (d->targets.isEmpty() || d->targets.contains(static_cast<QQuickAnchorChanges*>(action.event)->object()))) {
+ data->actions << static_cast<QQuickAnchorChanges*>(action.event)->additionalActions();
+ }
+ }
+
+ QQuickBulkValueAnimator *animator = new QQuickBulkValueAnimator;
+ if (data->actions.count()) {
+ animator->setAnimValue(data);
+ animator->setFromSourcedValue(&data->fromSourced);
+ } else {
+ delete data;
+ }
+
+ animator->setDuration(d->duration);
+ animator->setEasingCurve(d->easing);
+ return initInstance(animator);
+}
+
+/*!
+ \qmlclass PathAnimation QQuickPathAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits Animation
+ \since QtQuick 2.0
+ \brief The PathAnimation element animates an item along a path.
+
+ When used in a transition, the path can be specified without start
+ or end points, for example:
+ \qml
+ PathAnimation {
+ path: Path {
+ //no startX, startY
+ PathCurve { x: 100; y: 100}
+ PathCurve {} //last element is empty with no end point specified
+ }
+ }
+ \endqml
+
+ In the above case, the path start will be the item's current position, and the
+ path end will be the item's target position in the target state.
+
+ \sa {QML Animation and Transitions}, PathInterpolator
+*/
+QQuickPathAnimation::QQuickPathAnimation(QObject *parent)
+: QQuickAbstractAnimation(*(new QQuickPathAnimationPrivate), parent)
+{
+}
+
+QQuickPathAnimation::~QQuickPathAnimation()
+{
+ Q_D(QQuickPathAnimation);
+ QHash<QQuickItem*, QQuickPathAnimationAnimator* >::iterator it;
+ for (it = d->activeAnimations.begin(); it != d->activeAnimations.end(); ++it) {
+ it.value()->clearTemplate();
+ }
+}
+
+/*!
+ \qmlproperty int QtQuick2::PathAnimation::duration
+ This property holds the duration of the animation, in milliseconds.
+
+ The default value is 250.
+*/
+int QQuickPathAnimation::duration() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->duration;
+}
+
+void QQuickPathAnimation::setDuration(int duration)
+{
+ if (duration < 0) {
+ qmlInfo(this) << tr("Cannot set a duration of < 0");
+ return;
+ }
+
+ Q_D(QQuickPathAnimation);
+ if (d->duration == duration)
+ return;
+ d->duration = duration;
+ emit durationChanged(duration);
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::PathAnimation::easing.type
+ \qmlproperty real QtQuick2::PathAnimation::easing.amplitude
+ \qmlproperty list<real> QtQuick2::PathAnimation::easing.bezierCurve
+ \qmlproperty real QtQuick2::PathAnimation::easing.overshoot
+ \qmlproperty real QtQuick2::PathAnimation::easing.period
+ \brief the easing curve used for the animation.
+
+ To specify an easing curve you need to specify at least the type. For some curves you can also specify
+ amplitude, period, overshoot or custom bezierCurve data. The default easing curve is \c Easing.Linear.
+
+ See the \l{PropertyAnimation::easing.type} documentation for information
+ about the different types of easing curves.
+*/
+QEasingCurve QQuickPathAnimation::easing() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->easingCurve;
+}
+
+void QQuickPathAnimation::setEasing(const QEasingCurve &e)
+{
+ Q_D(QQuickPathAnimation);
+ if (d->easingCurve == e)
+ return;
+
+ d->easingCurve = e;
+ emit easingChanged(e);
+}
+
+/*!
+ \qmlproperty Path QtQuick2::PathAnimation::path
+ This property holds the path to animate along.
+
+ For more information on defining a path see the \l Path documentation.
+*/
+QQuickPath *QQuickPathAnimation::path() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->path;
+}
+
+void QQuickPathAnimation::setPath(QQuickPath *path)
+{
+ Q_D(QQuickPathAnimation);
+ if (d->path == path)
+ return;
+
+ d->path = path;
+ emit pathChanged();
+}
+
+/*!
+ \qmlproperty Item QtQuick2::PathAnimation::target
+ This property holds the item to animate.
+*/
+QQuickItem *QQuickPathAnimation::target() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->target;
+}
+
+void QQuickPathAnimation::setTargetObject(QQuickItem *target)
+{
+ Q_D(QQuickPathAnimation);
+ if (d->target == target)
+ return;
+
+ d->target = target;
+ emit targetChanged();
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::PathAnimation::orientation
+ This property controls the rotation of the item as it animates along the path.
+
+ If a value other than \c Fixed is specified, the PathAnimation will rotate the
+ item to achieve the specified orientation as it travels along the path.
+
+ \list
+ \o PathAnimation.Fixed (default) - the PathAnimation will not control
+ the rotation of the item.
+ \o PathAnimation.RightFirst - The right side of the item will lead along the path.
+ \o PathAnimation.LeftFirst - The left side of the item will lead along the path.
+ \o PathAnimation.BottomFirst - The bottom of the item will lead along the path.
+ \o PathAnimation.TopFirst - The top of the item will lead along the path.
+ \endlist
+*/
+QQuickPathAnimation::Orientation QQuickPathAnimation::orientation() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->orientation;
+}
+
+void QQuickPathAnimation::setOrientation(Orientation orientation)
+{
+ Q_D(QQuickPathAnimation);
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ emit orientationChanged(d->orientation);
+}
+
+/*!
+ \qmlproperty point QtQuick2::PathAnimation::anchorPoint
+ This property holds the anchor point for the item being animated.
+
+ By default, the upper-left corner of the target (its 0,0 point)
+ will be anchored to (or follow) the path. The anchorPoint property can be used to
+ specify a different point for anchoring. For example, specifying an anchorPoint of
+ 5,5 for a 10x10 item means the center of the item will follow the path.
+*/
+QPointF QQuickPathAnimation::anchorPoint() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->anchorPoint;
+}
+
+void QQuickPathAnimation::setAnchorPoint(const QPointF &point)
+{
+ Q_D(QQuickPathAnimation);
+ if (d->anchorPoint == point)
+ return;
+
+ d->anchorPoint = point;
+ emit anchorPointChanged(point);
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathAnimation::orientationEntryDuration
+ This property holds the duration (in milliseconds) of the transition in to the orientation.
+
+ If an orientation has been specified for the PathAnimation, and the starting
+ rotation of the item does not match that given by the orientation,
+ orientationEntryDuration can be used to smoothly transition from the item's
+ starting rotation to the rotation given by the path orientation.
+*/
+int QQuickPathAnimation::orientationEntryDuration() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->entryDuration;
+}
+
+void QQuickPathAnimation::setOrientationEntryDuration(int duration)
+{
+ Q_D(QQuickPathAnimation);
+ if (d->entryDuration == duration)
+ return;
+ d->entryDuration = duration;
+ emit orientationEntryDurationChanged(duration);
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathAnimation::orientationExitDuration
+ This property holds the duration (in milliseconds) of the transition out of the orientation.
+
+ If an orientation and endRotation have been specified for the PathAnimation,
+ orientationExitDuration can be used to smoothly transition from the rotation given
+ by the path orientation to the specified endRotation.
+*/
+int QQuickPathAnimation::orientationExitDuration() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->exitDuration;
+}
+
+void QQuickPathAnimation::setOrientationExitDuration(int duration)
+{
+ Q_D(QQuickPathAnimation);
+ if (d->exitDuration == duration)
+ return;
+ d->exitDuration = duration;
+ emit orientationExitDurationChanged(duration);
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathAnimation::endRotation
+ This property holds the ending rotation for the target.
+
+ If an orientation has been specified for the PathAnimation,
+ and the path doesn't end with the item at the desired rotation,
+ the endRotation property can be used to manually specify an end
+ rotation.
+
+ This property is typically used with orientationExitDuration, as specifying
+ an endRotation without an orientationExitDuration may cause a jump to
+ the final rotation, rather than a smooth transition.
+*/
+qreal QQuickPathAnimation::endRotation() const
+{
+ Q_D(const QQuickPathAnimation);
+ return d->endRotation.isNull ? qreal(0) : d->endRotation.value;
+}
+
+void QQuickPathAnimation::setEndRotation(qreal rotation)
+{
+ Q_D(QQuickPathAnimation);
+ if (!d->endRotation.isNull && d->endRotation == rotation)
+ return;
+
+ d->endRotation = rotation;
+ emit endRotationChanged(d->endRotation);
+}
+
+QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickPathAnimation);
+
+ QQuickItem *target = d->target ? d->target : qobject_cast<QQuickItem*>(defaultTarget);
+
+ QQuickPathAnimationUpdater prevData;
+ bool havePrevData = false;
+ if (d->activeAnimations.contains(target)) {
+ havePrevData = true;
+ prevData = *d->activeAnimations[target]->pathUpdater();
+ }
+
+ QList<QQuickItem*> keys = d->activeAnimations.keys();
+ foreach (QQuickItem *item, keys) {
+ QQuickPathAnimationAnimator *anim = d->activeAnimations.value(item);
+ if (anim->state() == QAbstractAnimationJob::Stopped) {
+ anim->clearTemplate();
+ d->activeAnimations.remove(item);
+ }
+ }
+
+ QQuickPathAnimationUpdater *data = new QQuickPathAnimationUpdater();
+ QQuickPathAnimationAnimator *pa = new QQuickPathAnimationAnimator(d);
+
+ d->activeAnimations[target] = pa;
+
+ data->orientation = d->orientation;
+ data->anchorPoint = d->anchorPoint;
+ data->entryInterval = d->duration ? qreal(d->entryDuration) / d->duration : qreal(0);
+ data->exitInterval = d->duration ? qreal(d->exitDuration) / d->duration : qreal(0);
+ data->endRotation = d->endRotation;
+ data->reverse = direction == Backward ? true : false;
+ data->fromSourced = false;
+ data->fromDefined = (d->path && d->path->hasStartX() && d->path->hasStartY()) ? true : false;
+ data->toDefined = d->path ? d->path->hasEnd() : false;
+ int origModifiedSize = modified.count();
+
+ for (int i = 0; i < actions.count(); ++i) {
+ QQuickAction &action = actions[i];
+ if (action.event)
+ continue;
+ if (action.specifiedObject == target && action.property.name() == QLatin1String("x")) {
+ data->toX = action.toValue.toReal();
+ modified << action.property;
+ action.fromValue = action.toValue;
+ }
+ if (action.specifiedObject == target && action.property.name() == QLatin1String("y")) {
+ data->toY = action.toValue.toReal();
+ modified << action.property;
+ action.fromValue = action.toValue;
+ }
+ }
+
+ if (target && d->path &&
+ (modified.count() > origModifiedSize || data->toDefined)) {
+ data->target = target;
+ data->path = d->path;
+ data->path->invalidateSequentialHistory();
+
+ if (havePrevData) {
+ // get the original start angle that was used (so we can exactly reverse).
+ data->startRotation = prevData.startRotation;
+
+ // treat interruptions specially, otherwise we end up with strange paths
+ if ((data->reverse || prevData.reverse) && prevData.currentV > 0 && prevData.currentV < 1) {
+ if (!data->fromDefined && !data->toDefined && !prevData.painterPath.isEmpty()) {
+ QPointF pathPos = QQuickPath::sequentialPointAt(prevData.painterPath, prevData.pathLength, prevData.attributePoints, prevData.prevBez, prevData.currentV);
+ if (!prevData.anchorPoint.isNull())
+ pathPos -= prevData.anchorPoint;
+ if (pathPos == data->target->pos()) { //only treat as interruption if we interrupted ourself
+ data->painterPath = prevData.painterPath;
+ data->toDefined = data->fromDefined = data->fromSourced = true;
+ data->prevBez.isValid = false;
+ data->interruptStart = prevData.currentV;
+ data->startRotation = prevData.startRotation;
+ data->pathLength = prevData.pathLength;
+ data->attributePoints = prevData.attributePoints;
+ }
+ }
+ }
+ }
+ pa->setFromSourcedValue(&data->fromSourced);
+ pa->setAnimValue(data);
+ } else {
+ pa->setFromSourcedValue(0);
+ pa->setAnimValue(0);
+ delete pa;
+ delete data;
+ }
+
+ pa->setDuration(d->duration);
+ pa->setEasingCurve(d->easingCurve);
+ return initInstance(pa);
+}
+
+void QQuickPathAnimationUpdater::setValue(qreal v)
+{
+ if (interruptStart.isValid()) {
+ if (reverse)
+ v = 1 - v;
+ qreal end = reverse ? 0.0 : 1.0;
+ v = interruptStart + v * (end-interruptStart);
+ }
+ currentV = v;
+ bool atStart = ((reverse && v == 1.0) || (!reverse && v == 0.0));
+ if (!fromSourced && (!fromDefined || !toDefined)) {
+ qreal startX = reverse ? toX + anchorPoint.x() : target->x() + anchorPoint.x();
+ qreal startY = reverse ? toY + anchorPoint.y() : target->y() + anchorPoint.y();
+ qreal endX = reverse ? target->x() + anchorPoint.x() : toX + anchorPoint.x();
+ qreal endY = reverse ? target->y() + anchorPoint.y() : toY + anchorPoint.y();
+
+ prevBez.isValid = false;
+ painterPath = path->createPath(QPointF(startX, startY), QPointF(endX, endY), QStringList(), pathLength, attributePoints);
+ fromSourced = true;
+ }
+
+ qreal angle;
+ bool fixed = orientation == QQuickPathAnimation::Fixed;
+ QPointF currentPos = !painterPath.isEmpty() ? path->sequentialPointAt(painterPath, pathLength, attributePoints, prevBez, v, fixed ? 0 : &angle) : path->sequentialPointAt(v, fixed ? 0 : &angle);
+
+ //adjust position according to anchor point
+ if (!anchorPoint.isNull()) {
+ currentPos -= anchorPoint;
+ if (atStart) {
+ if (!anchorPoint.isNull() && !fixed)
+ target->setTransformOriginPoint(anchorPoint);
+ }
+ }
+
+ target->setPos(currentPos);
+
+ //adjust angle according to orientation
+ if (!fixed) {
+ switch (orientation) {
+ case QQuickPathAnimation::RightFirst:
+ angle = -angle;
+ break;
+ case QQuickPathAnimation::TopFirst:
+ angle = -angle + 90;
+ break;
+ case QQuickPathAnimation::LeftFirst:
+ angle = -angle + 180;
+ break;
+ case QQuickPathAnimation::BottomFirst:
+ angle = -angle + 270;
+ break;
+ default:
+ angle = 0;
+ break;
+ }
+
+ if (atStart && !reverse) {
+ startRotation = target->rotation();
+
+ //shortest distance to correct orientation
+ qreal diff = angle - startRotation;
+ while (diff > 180.0) {
+ startRotation.value += 360.0;
+ diff -= 360.0;
+ }
+ while (diff < -180.0) {
+ startRotation.value -= 360.0;
+ diff += 360.0;
+ }
+ }
+
+ //smoothly transition to the desired orientation
+ //TODO: shortest distance calculations
+ if (startRotation.isValid()) {
+ if (reverse && v == 0.0)
+ angle = startRotation;
+ else if (v < entryInterval)
+ angle = angle * v / entryInterval + startRotation * (entryInterval - v) / entryInterval;
+ }
+ if (endRotation.isValid()) {
+ qreal exitStart = 1 - entryInterval;
+ if (!reverse && v == 1.0)
+ angle = endRotation;
+ else if (v > exitStart)
+ angle = endRotation * (v - exitStart) / exitInterval + angle * (exitInterval - (v - exitStart)) / exitInterval;
+ }
+ target->setRotation(angle);
+ }
+
+ /*
+ NOTE: we don't always reset the transform origin, as it can cause a
+ visual jump if ending on an angle. This means that in some cases
+ (anchor point and orientation both specified, and ending at an angle)
+ the transform origin will always be set after running the path animation.
+ */
+ if ((reverse && v == 0.0) || (!reverse && v == 1.0)) {
+ if (!anchorPoint.isNull() && !fixed && qFuzzyIsNull(angle))
+ target->setTransformOriginPoint(QPointF());
+ }
+}
+
+QQuickPathAnimationAnimator::QQuickPathAnimationAnimator(QQuickPathAnimationPrivate *priv)
+ : animationTemplate(priv)
+{
+}
+
+QQuickPathAnimationAnimator::~QQuickPathAnimationAnimator()
+{
+ if (animationTemplate && pathUpdater()) {
+ QHash<QQuickItem*, QQuickPathAnimationAnimator* >::iterator it =
+ animationTemplate->activeAnimations.find(pathUpdater()->target);
+ if (it != animationTemplate->activeAnimations.end() && it.value() == this)
+ animationTemplate->activeAnimations.erase(it);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/items/qquickitemanimation_p.h b/src/quick/items/qquickitemanimation_p.h
new file mode 100644
index 0000000000..a3a7e77871
--- /dev/null
+++ b/src/quick/items/qquickitemanimation_p.h
@@ -0,0 +1,203 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKITEMANIMATION_H
+#define QQUICKITEMANIMATION_H
+
+#include "qquickitem.h"
+
+#include <QtQuick/private/qquickanimation_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickParentAnimationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickParentAnimation : public QQuickAnimationGroup
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickParentAnimation)
+
+ Q_PROPERTY(QQuickItem *target READ target WRITE setTargetObject NOTIFY targetChanged)
+ Q_PROPERTY(QQuickItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged)
+ Q_PROPERTY(QQuickItem *via READ via WRITE setVia NOTIFY viaChanged)
+
+public:
+ QQuickParentAnimation(QObject *parent=0);
+ virtual ~QQuickParentAnimation();
+
+ QQuickItem *target() const;
+ void setTargetObject(QQuickItem *);
+
+ QQuickItem *newParent() const;
+ void setNewParent(QQuickItem *);
+
+ QQuickItem *via() const;
+ void setVia(QQuickItem *);
+
+Q_SIGNALS:
+ void targetChanged();
+ void newParentChanged();
+ void viaChanged();
+
+protected:
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+};
+
+class QQuickAnchorAnimationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickAnchorAnimation : public QQuickAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickAnchorAnimation)
+ Q_PROPERTY(QQmlListProperty<QQuickItem> targets READ targets)
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
+
+public:
+ QQuickAnchorAnimation(QObject *parent=0);
+ virtual ~QQuickAnchorAnimation();
+
+ QQmlListProperty<QQuickItem> targets();
+
+ int duration() const;
+ void setDuration(int);
+
+ QEasingCurve easing() const;
+ void setEasing(const QEasingCurve &);
+
+Q_SIGNALS:
+ void durationChanged(int);
+ void easingChanged(const QEasingCurve&);
+
+protected:
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+};
+
+class QQuickItem;
+class QQuickPath;
+class QQuickPathAnimationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickPathAnimation : public QQuickAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPathAnimation)
+
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
+ Q_PROPERTY(QQuickPath *path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(QQuickItem *target READ target WRITE setTargetObject NOTIFY targetChanged)
+ Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
+ Q_PROPERTY(QPointF anchorPoint READ anchorPoint WRITE setAnchorPoint NOTIFY anchorPointChanged)
+ Q_PROPERTY(int orientationEntryDuration READ orientationEntryDuration WRITE setOrientationEntryDuration NOTIFY orientationEntryDurationChanged)
+ Q_PROPERTY(int orientationExitDuration READ orientationExitDuration WRITE setOrientationExitDuration NOTIFY orientationExitDurationChanged)
+ Q_PROPERTY(qreal endRotation READ endRotation WRITE setEndRotation NOTIFY endRotationChanged)
+
+public:
+ QQuickPathAnimation(QObject *parent=0);
+ virtual ~QQuickPathAnimation();
+
+ enum Orientation {
+ Fixed,
+ RightFirst,
+ LeftFirst,
+ BottomFirst,
+ TopFirst
+ };
+ Q_ENUMS(Orientation)
+
+ int duration() const;
+ void setDuration(int);
+
+ QEasingCurve easing() const;
+ void setEasing(const QEasingCurve &);
+
+ QQuickPath *path() const;
+ void setPath(QQuickPath *);
+
+ QQuickItem *target() const;
+ void setTargetObject(QQuickItem *);
+
+ Orientation orientation() const;
+ void setOrientation(Orientation orientation);
+
+ QPointF anchorPoint() const;
+ void setAnchorPoint(const QPointF &point);
+
+ int orientationEntryDuration() const;
+ void setOrientationEntryDuration(int);
+
+ int orientationExitDuration() const;
+ void setOrientationExitDuration(int);
+
+ qreal endRotation() const;
+ void setEndRotation(qreal);
+
+protected:
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+Q_SIGNALS:
+ void durationChanged(int);
+ void easingChanged(const QEasingCurve &);
+ void pathChanged();
+ void targetChanged();
+ void orientationChanged(Orientation);
+ void anchorPointChanged(const QPointF &);
+ void orientationEntryDurationChanged(qreal);
+ void orientationExitDurationChanged(qreal);
+ void endRotationChanged(qreal);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickParentAnimation)
+QML_DECLARE_TYPE(QQuickAnchorAnimation)
+QML_DECLARE_TYPE(QQuickPathAnimation)
+
+QT_END_HEADER
+
+#endif // QQUICKITEMANIMATION_H
diff --git a/src/quick/items/qquickitemanimation_p_p.h b/src/quick/items/qquickitemanimation_p_p.h
new file mode 100644
index 0000000000..f61b255218
--- /dev/null
+++ b/src/quick/items/qquickitemanimation_p_p.h
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKANIMATION_P_H
+#define QQUICKANIMATION_P_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 "qquickitemanimation_p.h"
+
+#include <private/qquickpath_p.h>
+#include <private/qquickanimation_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickParentAnimationPrivate : public QQuickAnimationGroupPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickParentAnimation)
+public:
+ QQuickParentAnimationPrivate()
+ : QQuickAnimationGroupPrivate(), target(0), newParent(0), via(0) {}
+
+ QQuickItem *target;
+ QQuickItem *newParent;
+ QQuickItem *via;
+
+ QPointF computeTransformOrigin(QQuickItem::TransformOrigin origin, qreal width, qreal height) const;
+};
+
+class QQuickAnchorAnimationPrivate : public QQuickAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickAnchorAnimation)
+public:
+ QQuickAnchorAnimationPrivate() : interpolator(QVariantAnimationPrivate::getInterpolator(QMetaType::QReal)), duration(250) {}
+
+ QVariantAnimation::Interpolator interpolator;
+ int duration;
+ QEasingCurve easing;
+ QList<QQuickItem*> targets;
+};
+
+class QQuickPathAnimationUpdater : public QQuickBulkValueUpdater
+{
+public:
+ QQuickPathAnimationUpdater() : path(0), target(0), reverse(false),
+ fromSourced(false), fromDefined(false), toDefined(false),
+ toX(0), toY(0), currentV(0), orientation(QQuickPathAnimation::Fixed),
+ entryInterval(0), exitInterval(0) {}
+ ~QQuickPathAnimationUpdater() {}
+
+ void setValue(qreal v);
+
+ QQuickPath *path;
+
+ QPainterPath painterPath;
+ QQuickCachedBezier prevBez;
+ qreal pathLength;
+ QList<QQuickPath::AttributePoint> attributePoints;
+
+ QQuickItem *target;
+ bool reverse;
+ bool fromSourced;
+ bool fromDefined;
+ bool toDefined;
+ qreal toX;
+ qreal toY;
+ qreal currentV;
+ QQmlNullableValue<qreal> interruptStart;
+ //TODO: bundle below into common struct
+ QQuickPathAnimation::Orientation orientation;
+ QPointF anchorPoint;
+ qreal entryInterval;
+ qreal exitInterval;
+ QQmlNullableValue<qreal> endRotation;
+ QQmlNullableValue<qreal> startRotation;
+};
+
+class QQuickPathAnimationPrivate;
+class QQuickPathAnimationAnimator : public QQuickBulkValueAnimator
+{
+public:
+ QQuickPathAnimationAnimator(QQuickPathAnimationPrivate * = 0);
+ ~QQuickPathAnimationAnimator();
+
+ void clearTemplate() { animationTemplate = 0; }
+
+ QQuickPathAnimationUpdater *pathUpdater() { return static_cast<QQuickPathAnimationUpdater*>(getAnimValue()); }
+private:
+ QQuickPathAnimationPrivate *animationTemplate;
+};
+
+class QQuickPathAnimationPrivate : public QQuickAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickPathAnimation)
+public:
+ QQuickPathAnimationPrivate() : path(0), target(0),
+ orientation(QQuickPathAnimation::Fixed), entryDuration(0), exitDuration(0), duration(250) {}
+
+ QQuickPath *path;
+ QQuickItem *target;
+ QQuickPathAnimation::Orientation orientation;
+ QPointF anchorPoint;
+ qreal entryDuration;
+ qreal exitDuration;
+ QQmlNullableValue<qreal> endRotation;
+ int duration;
+ QEasingCurve easingCurve;
+ QHash<QQuickItem*, QQuickPathAnimationAnimator* > activeAnimations;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QQUICKANIMATION_P_H
diff --git a/src/quick/items/qquickitemchangelistener_p.h b/src/quick/items/qquickitemchangelistener_p.h
index d59b5b8856..3a5c25f5f5 100644
--- a/src/quick/items/qquickitemchangelistener_p.h
+++ b/src/quick/items/qquickitemchangelistener_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index f50237427b..3d23f7b03a 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -62,8 +62,8 @@
#include "qquickgridview_p.h"
#include "qquickpathview_p.h"
#include "qquickitemviewtransition_p.h"
-#include <private/qdeclarativepath_p.h>
-#include <private/qdeclarativepathinterpolator_p.h>
+#include <private/qquickpath_p.h>
+#include <private/qquickpathinterpolator_p.h>
#include "qquickpositioners_p.h"
#include "qquickrepeater_p.h"
#include "qquickloader_p.h"
@@ -71,7 +71,7 @@
#include "qquickflipable_p.h"
#include "qquicktranslate_p.h"
#include "qquickstateoperations_p.h"
-#include "qquickanimation_p.h"
+#include "qquickitemanimation_p.h"
#include <private/qquickshadereffect_p.h>
#include <QtQuick/private/qquickshadereffectsource_p.h>
//#include <private/qquickpincharea_p.h>
@@ -83,21 +83,21 @@
#include "qquickdrag_p.h"
#include "qquickdroparea_p.h"
#include "qquickmultipointtoucharea_p.h"
-#include <private/qdeclarativemetatype_p.h>
+#include <private/qqmlmetatype_p.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
-static QDeclarativePrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject *parent)
+static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject *parent)
{
QQuickItem *item = qobject_cast<QQuickItem *>(obj);
if (!item)
- return QDeclarativePrivate::IncompatibleObject;
+ return QQmlPrivate::IncompatibleObject;
QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent);
if (!parentItem)
- return QDeclarativePrivate::IncompatibleParent;
+ return QQmlPrivate::IncompatibleParent;
item->setParentItem(parentItem);
- return QDeclarativePrivate::Parented;
+ return QQmlPrivate::Parented;
}
static bool compareQQuickAnchorLines(const void *p1, const void *p2)
@@ -109,8 +109,8 @@ static bool compareQQuickAnchorLines(const void *p1, const void *p2)
static void qt_quickitems_defineModule(const char *uri, int major, int minor)
{
- QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qquickitem_autoParent };
- QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent);
+ QQmlPrivate::RegisterAutoParent autoparent = { 0, &qquickitem_autoParent };
+ QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent);
QQuickItemPrivate::registerAccessorProperties();
#ifdef QT_NO_MOVIE
@@ -123,7 +123,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickFlickable>(uri,major,minor,"Flickable");
qmlRegisterType<QQuickFlipable>(uri,major,minor,"Flipable");
qmlRegisterType<QQuickFlow>(uri,major,minor,"Flow");
-// qmlRegisterType<QDeclarativeFocusPanel>(uri,major,minor,"FocusPanel");
+// qmlRegisterType<QQuickFocusPanel>(uri,major,minor,"FocusPanel");
qmlRegisterType<QQuickFocusScope>(uri,major,minor,"FocusScope");
qmlRegisterType<QQuickGradient>(uri,major,minor,"Gradient");
qmlRegisterType<QQuickGradientStop>(uri,major,minor,"GradientStop");
@@ -134,15 +134,15 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickListView>(uri,major,minor,"ListView");
qmlRegisterType<QQuickLoader>(uri,major,minor,"Loader");
qmlRegisterType<QQuickMouseArea>(uri,major,minor,"MouseArea");
- qmlRegisterType<QDeclarativePath>(uri,major,minor,"Path");
- qmlRegisterType<QDeclarativePathAttribute>(uri,major,minor,"PathAttribute");
- qmlRegisterType<QDeclarativePathCubic>(uri,major,minor,"PathCubic");
- qmlRegisterType<QDeclarativePathLine>(uri,major,minor,"PathLine");
- qmlRegisterType<QDeclarativePathPercent>(uri,major,minor,"PathPercent");
- qmlRegisterType<QDeclarativePathQuad>(uri,major,minor,"PathQuad");
- qmlRegisterType<QDeclarativePathCatmullRomCurve>("QtQuick",2,0,"PathCurve");
- qmlRegisterType<QDeclarativePathArc>("QtQuick",2,0,"PathArc");
- qmlRegisterType<QDeclarativePathSvg>("QtQuick",2,0,"PathSvg");
+ qmlRegisterType<QQuickPath>(uri,major,minor,"Path");
+ qmlRegisterType<QQuickPathAttribute>(uri,major,minor,"PathAttribute");
+ qmlRegisterType<QQuickPathCubic>(uri,major,minor,"PathCubic");
+ qmlRegisterType<QQuickPathLine>(uri,major,minor,"PathLine");
+ qmlRegisterType<QQuickPathPercent>(uri,major,minor,"PathPercent");
+ qmlRegisterType<QQuickPathQuad>(uri,major,minor,"PathQuad");
+ qmlRegisterType<QQuickPathCatmullRomCurve>("QtQuick",2,0,"PathCurve");
+ qmlRegisterType<QQuickPathArc>("QtQuick",2,0,"PathArc");
+ qmlRegisterType<QQuickPathSvg>("QtQuick",2,0,"PathSvg");
qmlRegisterType<QQuickPathView>(uri,major,minor,"PathView");
qmlRegisterUncreatableType<QQuickBasePositioner>(uri,major,minor,"Positioner",
QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
@@ -170,8 +170,8 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickKeyEvent>();
qmlRegisterType<QQuickMouseEvent>();
qmlRegisterType<QQuickTransform>();
- qmlRegisterType<QDeclarativePathElement>();
- qmlRegisterType<QDeclarativeCurve>();
+ qmlRegisterType<QQuickPathElement>();
+ qmlRegisterType<QQuickCurve>();
qmlRegisterType<QQuickScaleGrid>();
qmlRegisterType<QQuickTextLine>();
#ifndef QT_NO_VALIDATOR
@@ -181,7 +181,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickPen>();
qmlRegisterType<QQuickFlickableVisibleArea>();
qRegisterMetaType<QQuickAnchorLine>("QQuickAnchorLine");
- QDeclarativeMetaType::setQQuickAnchorLineCompareFunction(compareQQuickAnchorLines);
+ QQmlMetaType::setQQuickAnchorLineCompareFunction(compareQQuickAnchorLines);
qmlRegisterUncreatableType<QQuickKeyNavigationAttached>(uri,major,minor,"KeyNavigation",QQuickKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
qmlRegisterUncreatableType<QQuickKeysAttached>(uri,major,minor,"Keys",QQuickKeysAttached::tr("Keys is only available via attached properties"));
@@ -212,7 +212,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickAnchorAnimation>(uri, major, minor,"AnchorAnimation");
qmlRegisterType<QQuickParentAnimation>(uri, major, minor,"ParentAnimation");
qmlRegisterType<QQuickPathAnimation>("QtQuick",2,0,"PathAnimation");
- qmlRegisterType<QDeclarativePathInterpolator>("QtQuick",2,0,"PathInterpolator");
+ qmlRegisterType<QQuickPathInterpolator>("QtQuick",2,0,"PathInterpolator");
qmlRegisterType<QQuickDropArea>("QtQuick", 2, 0, "DropArea");
qmlRegisterType<QQuickDropEvent>();
diff --git a/src/quick/items/qquickitemsmodule_p.h b/src/quick/items/qquickitemsmodule_p.h
index cc51771a0b..1d6844ca5e 100644
--- a/src/quick/items/qquickitemsmodule_p.h
+++ b/src/quick/items/qquickitemsmodule_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef QQUICKITEMSMODULE_P_H
#define QQUICKITEMSMODULE_P_H
-#include <qdeclarative.h>
+#include <qqml.h>
QT_BEGIN_HEADER
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 5d58cbf4f5..516cf0c1bb 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qquickitemview_p_p.h"
-#include <QtQuick/private/qdeclarativetransition_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
QT_BEGIN_NAMESPACE
@@ -71,14 +71,14 @@ bool QQuickItemViewChangeSet::hasPendingChanges() const
return !pendingChanges.isEmpty();
}
-void QQuickItemViewChangeSet::applyChanges(const QDeclarativeChangeSet &changeSet)
+void QQuickItemViewChangeSet::applyChanges(const QQuickChangeSet &changeSet)
{
pendingChanges.apply(changeSet);
int moveId = -1;
int moveOffset = 0;
- foreach (const QDeclarativeChangeSet::Remove &r, changeSet.removes()) {
+ foreach (const QQuickChangeSet::Remove &r, changeSet.removes()) {
itemCount -= r.count;
if (moveId == -1 && newCurrentIndex >= r.index + r.count) {
newCurrentIndex -= r.count;
@@ -97,7 +97,7 @@ void QQuickItemViewChangeSet::applyChanges(const QDeclarativeChangeSet &changeSe
currentChanged = true;
}
}
- foreach (const QDeclarativeChangeSet::Insert &i, changeSet.inserts()) {
+ foreach (const QQuickChangeSet::Insert &i, changeSet.inserts()) {
if (moveId == -1) {
if (itemCount && newCurrentIndex >= i.index) {
newCurrentIndex += i.count;
@@ -178,8 +178,8 @@ void QQuickItemView::setModel(const QVariant &model)
if (d->modelVariant == model)
return;
if (d->model) {
- disconnect(d->model, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)),
- this, SLOT(modelUpdated(QDeclarativeChangeSet,bool)));
+ disconnect(d->model, SIGNAL(modelUpdated(QQuickChangeSet,bool)),
+ this, SLOT(modelUpdated(QQuickChangeSet,bool)));
disconnect(d->model, SIGNAL(initItem(int,QQuickItem*)), this, SLOT(initItem(int,QQuickItem*)));
disconnect(d->model, SIGNAL(createdItem(int,QQuickItem*)), this, SLOT(createdItem(int,QQuickItem*)));
disconnect(d->model, SIGNAL(destroyingItem(QQuickItem*)), this, SLOT(destroyingItem(QQuickItem*)));
@@ -241,14 +241,14 @@ void QQuickItemView::setModel(const QVariant &model)
polish();
}
}
- connect(d->model, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)),
- this, SLOT(modelUpdated(QDeclarativeChangeSet,bool)));
+ connect(d->model, SIGNAL(modelUpdated(QQuickChangeSet,bool)),
+ this, SLOT(modelUpdated(QQuickChangeSet,bool)));
emit countChanged();
}
emit modelChanged();
}
-QDeclarativeComponent *QQuickItemView::delegate() const
+QQmlComponent *QQuickItemView::delegate() const
{
Q_D(const QQuickItemView);
if (d->model) {
@@ -259,7 +259,7 @@ QDeclarativeComponent *QQuickItemView::delegate() const
return 0;
}
-void QQuickItemView::setDelegate(QDeclarativeComponent *delegate)
+void QQuickItemView::setDelegate(QQmlComponent *delegate)
{
Q_D(QQuickItemView);
if (delegate == this->delegate())
@@ -394,7 +394,7 @@ Qt::LayoutDirection QQuickItemView::effectiveLayoutDirection() const
}
-QDeclarativeComponent *QQuickItemView::header() const
+QQmlComponent *QQuickItemView::header() const
{
Q_D(const QQuickItemView);
return d->headerComponent;
@@ -407,7 +407,7 @@ QQuickItem *QQuickItemView::headerItem() const
return d->header ? d->header->item : 0;
}
-void QQuickItemView::setHeader(QDeclarativeComponent *headerComponent)
+void QQuickItemView::setHeader(QQmlComponent *headerComponent)
{
Q_D(QQuickItemView);
if (d->headerComponent != headerComponent) {
@@ -430,7 +430,7 @@ void QQuickItemView::setHeader(QDeclarativeComponent *headerComponent)
}
}
-QDeclarativeComponent *QQuickItemView::footer() const
+QQmlComponent *QQuickItemView::footer() const
{
Q_D(const QQuickItemView);
return d->footerComponent;
@@ -443,7 +443,7 @@ QQuickItem *QQuickItemView::footerItem() const
return d->footer ? d->footer->item : 0;
}
-void QQuickItemView::setFooter(QDeclarativeComponent *footerComponent)
+void QQuickItemView::setFooter(QQmlComponent *footerComponent)
{
Q_D(QQuickItemView);
if (d->footerComponent != footerComponent) {
@@ -463,14 +463,14 @@ void QQuickItemView::setFooter(QDeclarativeComponent *footerComponent)
}
}
-QDeclarativeComponent *QQuickItemView::highlight() const
+QQmlComponent *QQuickItemView::highlight() const
{
Q_D(const QQuickItemView);
const_cast<QQuickItemViewPrivate*>(d)->applyPendingChanges();
return d->highlightComponent;
}
-void QQuickItemView::setHighlight(QDeclarativeComponent *highlightComponent)
+void QQuickItemView::setHighlight(QQmlComponent *highlightComponent)
{
Q_D(QQuickItemView);
if (highlightComponent != d->highlightComponent) {
@@ -593,13 +593,13 @@ void QQuickItemView::setHighlightMoveDuration(int duration)
}
}
-QDeclarativeTransition *QQuickItemView::populateTransition() const
+QQuickTransition *QQuickItemView::populateTransition() const
{
Q_D(const QQuickItemView);
return d->transitioner ? d->transitioner->populateTransition : 0;
}
-void QQuickItemView::setPopulateTransition(QDeclarativeTransition *transition)
+void QQuickItemView::setPopulateTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
d->createTransitioner();
@@ -609,13 +609,13 @@ void QQuickItemView::setPopulateTransition(QDeclarativeTransition *transition)
}
}
-QDeclarativeTransition *QQuickItemView::addTransition() const
+QQuickTransition *QQuickItemView::addTransition() const
{
Q_D(const QQuickItemView);
return d->transitioner ? d->transitioner->addTransition : 0;
}
-void QQuickItemView::setAddTransition(QDeclarativeTransition *transition)
+void QQuickItemView::setAddTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
d->createTransitioner();
@@ -625,13 +625,13 @@ void QQuickItemView::setAddTransition(QDeclarativeTransition *transition)
}
}
-QDeclarativeTransition *QQuickItemView::addDisplacedTransition() const
+QQuickTransition *QQuickItemView::addDisplacedTransition() const
{
Q_D(const QQuickItemView);
return d->transitioner ? d->transitioner->addDisplacedTransition : 0;
}
-void QQuickItemView::setAddDisplacedTransition(QDeclarativeTransition *transition)
+void QQuickItemView::setAddDisplacedTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
d->createTransitioner();
@@ -641,13 +641,13 @@ void QQuickItemView::setAddDisplacedTransition(QDeclarativeTransition *transitio
}
}
-QDeclarativeTransition *QQuickItemView::moveTransition() const
+QQuickTransition *QQuickItemView::moveTransition() const
{
Q_D(const QQuickItemView);
return d->transitioner ? d->transitioner->moveTransition : 0;
}
-void QQuickItemView::setMoveTransition(QDeclarativeTransition *transition)
+void QQuickItemView::setMoveTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
d->createTransitioner();
@@ -657,13 +657,13 @@ void QQuickItemView::setMoveTransition(QDeclarativeTransition *transition)
}
}
-QDeclarativeTransition *QQuickItemView::moveDisplacedTransition() const
+QQuickTransition *QQuickItemView::moveDisplacedTransition() const
{
Q_D(const QQuickItemView);
return d->transitioner ? d->transitioner->moveDisplacedTransition : 0;
}
-void QQuickItemView::setMoveDisplacedTransition(QDeclarativeTransition *transition)
+void QQuickItemView::setMoveDisplacedTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
d->createTransitioner();
@@ -673,13 +673,13 @@ void QQuickItemView::setMoveDisplacedTransition(QDeclarativeTransition *transiti
}
}
-QDeclarativeTransition *QQuickItemView::removeTransition() const
+QQuickTransition *QQuickItemView::removeTransition() const
{
Q_D(const QQuickItemView);
return d->transitioner ? d->transitioner->removeTransition : 0;
}
-void QQuickItemView::setRemoveTransition(QDeclarativeTransition *transition)
+void QQuickItemView::setRemoveTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
d->createTransitioner();
@@ -689,13 +689,13 @@ void QQuickItemView::setRemoveTransition(QDeclarativeTransition *transition)
}
}
-QDeclarativeTransition *QQuickItemView::removeDisplacedTransition() const
+QQuickTransition *QQuickItemView::removeDisplacedTransition() const
{
Q_D(const QQuickItemView);
return d->transitioner ? d->transitioner->removeDisplacedTransition : 0;
}
-void QQuickItemView::setRemoveDisplacedTransition(QDeclarativeTransition *transition)
+void QQuickItemView::setRemoveDisplacedTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
d->createTransitioner();
@@ -705,13 +705,13 @@ void QQuickItemView::setRemoveDisplacedTransition(QDeclarativeTransition *transi
}
}
-QDeclarativeTransition *QQuickItemView::displacedTransition() const
+QQuickTransition *QQuickItemView::displacedTransition() const
{
Q_D(const QQuickItemView);
return d->transitioner ? d->transitioner->displacedTransition : 0;
}
-void QQuickItemView::setDisplacedTransition(QDeclarativeTransition *transition)
+void QQuickItemView::setDisplacedTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
d->createTransitioner();
@@ -855,7 +855,7 @@ void QQuickItemViewPrivate::applyPendingChanges()
layout();
}
-int QQuickItemViewPrivate::findMoveKeyIndex(QDeclarativeChangeSet::MoveKey key, const QVector<QDeclarativeChangeSet::Remove> &changes) const
+int QQuickItemViewPrivate::findMoveKeyIndex(QQuickChangeSet::MoveKey key, const QVector<QQuickChangeSet::Remove> &changes) const
{
for (int i=0; i<changes.count(); i++) {
for (int j=changes[i].index; j<changes[i].index + changes[i].count; j++) {
@@ -954,7 +954,7 @@ void QQuickItemView::destroyRemoved()
polish();
}
-void QQuickItemView::modelUpdated(const QDeclarativeChangeSet &changeSet, bool reset)
+void QQuickItemView::modelUpdated(const QQuickChangeSet &changeSet, bool reset)
{
Q_D(QQuickItemView);
if (reset) {
@@ -1701,7 +1701,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
|| !currentChanges.pendingChanges.inserts().isEmpty();
FxViewItem *prevFirstVisible = firstVisibleItem();
- QDeclarativeNullableValue<qreal> prevViewPos;
+ QQmlNullableValue<qreal> prevViewPos;
int prevFirstVisibleIndex = -1;
if (prevFirstVisible) {
prevViewPos = prevFirstVisible->position();
@@ -1712,8 +1712,8 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
totalInsertionResult->visiblePos = prevViewPos;
totalRemovalResult->visiblePos = prevViewPos;
- const QVector<QDeclarativeChangeSet::Remove> &removals = currentChanges.pendingChanges.removes();
- const QVector<QDeclarativeChangeSet::Insert> &insertions = currentChanges.pendingChanges.inserts();
+ const QVector<QQuickChangeSet::Remove> &removals = currentChanges.pendingChanges.removes();
+ const QVector<QQuickChangeSet::Insert> &insertions = currentChanges.pendingChanges.inserts();
ChangeResult insertionResult(prevViewPos);
ChangeResult removalResult(prevViewPos);
@@ -1732,7 +1732,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
}
}
if (runDelayedRemoveTransition) {
- QDeclarativeChangeSet::Remove removal;
+ QQuickChangeSet::Remove removal;
for (QList<FxViewItem*>::Iterator it = visibleItems.begin(); it != visibleItems.end();) {
FxViewItem *item = *it;
if (item->index == -1 && !item->attached->delayRemove()) {
@@ -1800,7 +1800,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
// Whatever removed/moved items remain are no longer visible items.
prepareRemoveTransitions(&currentChanges.removedItems);
- for (QHash<QDeclarativeChangeSet::MoveKey, FxViewItem *>::Iterator it = currentChanges.removedItems.begin();
+ for (QHash<QQuickChangeSet::MoveKey, FxViewItem *>::Iterator it = currentChanges.removedItems.begin();
it != currentChanges.removedItems.end(); ++it) {
releaseItem(it.value());
}
@@ -1830,7 +1830,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
return visibleAffected;
}
-bool QQuickItemViewPrivate::applyRemovalChange(const QDeclarativeChangeSet::Remove &removal, ChangeResult *removeResult, int *removedCount)
+bool QQuickItemViewPrivate::applyRemovalChange(const QQuickChangeSet::Remove &removal, ChangeResult *removeResult, int *removedCount)
{
Q_Q(QQuickItemView);
bool visibleAffected = false;
@@ -1882,7 +1882,7 @@ bool QQuickItemViewPrivate::applyRemovalChange(const QDeclarativeChangeSet::Remo
return visibleAffected;
}
-void QQuickItemViewPrivate::removeItem(FxViewItem *item, const QDeclarativeChangeSet::Remove &removal, ChangeResult *removeResult)
+void QQuickItemViewPrivate::removeItem(FxViewItem *item, const QQuickChangeSet::Remove &removal, ChangeResult *removeResult)
{
if (removeResult->visiblePos.isValid()) {
if (item->position() < removeResult->visiblePos)
@@ -1896,7 +1896,7 @@ void QQuickItemViewPrivate::removeItem(FxViewItem *item, const QDeclarativeChang
transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, true);
} else {
// track item so it is released later
- currentChanges.removedItems.insertMulti(QDeclarativeChangeSet::MoveKey(), item);
+ currentChanges.removedItems.insertMulti(QQuickChangeSet::MoveKey(), item);
}
if (!removeResult->changedFirstItem && item == *visibleItems.constBegin())
removeResult->changedFirstItem = true;
@@ -1908,7 +1908,7 @@ void QQuickItemViewPrivate::repositionFirstItem(FxViewItem *prevVisibleItemsFirs
ChangeResult *insertionResult,
ChangeResult *removalResult)
{
- const QDeclarativeNullableValue<qreal> prevViewPos = insertionResult->visiblePos;
+ const QQmlNullableValue<qreal> prevViewPos = insertionResult->visiblePos;
// reposition visibleItems.first() correctly so that the content y doesn't jump
if (visibleItems.count()) {
@@ -1987,7 +1987,7 @@ void QQuickItemViewPrivate::prepareVisibleItemTransitions()
}
}
-void QQuickItemViewPrivate::prepareRemoveTransitions(QHash<QDeclarativeChangeSet::MoveKey, FxViewItem *> *removedItems)
+void QQuickItemViewPrivate::prepareRemoveTransitions(QHash<QQuickChangeSet::MoveKey, FxViewItem *> *removedItems)
{
if (!transitioner)
return;
@@ -1996,7 +1996,7 @@ void QQuickItemViewPrivate::prepareRemoveTransitions(QHash<QDeclarativeChangeSet
transitioner->removeTransitionTargets.clear();
if (transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, true)) {
- for (QHash<QDeclarativeChangeSet::MoveKey, FxViewItem *>::Iterator it = removedItems->begin();
+ for (QHash<QQuickChangeSet::MoveKey, FxViewItem *>::Iterator it = removedItems->begin();
it != removedItems->end(); ) {
bool isRemove = it.key().moveId < 0;
if (isRemove) {
@@ -2083,7 +2083,7 @@ FxViewItem *QQuickItemViewPrivate::createItem(int modelIndex, bool asynchronous)
if (QQuickItem *item = model->item(modelIndex, asynchronous)) {
item->setParentItem(q->contentItem());
- QDeclarative_setParent_noEvent(item, q->contentItem());
+ QQml_setParent_noEvent(item, q->contentItem());
requestedIndex = -1;
FxViewItem *viewItem = requestedItem;
if (!viewItem)
@@ -2130,7 +2130,7 @@ void QQuickItemView::initItem(int index, QQuickItem *item)
if (d->requestedAsync)
item->setVisible(false);
item->setParentItem(contentItem());
- QDeclarative_setParent_noEvent(item, contentItem());
+ QQml_setParent_noEvent(item, contentItem());
d->requestedItem = d->newViewItem(index, item);
}
}
@@ -2165,18 +2165,18 @@ QQuickItem *QQuickItemViewPrivate::createHighlightItem()
return createComponentItem(highlightComponent, true, true);
}
-QQuickItem *QQuickItemViewPrivate::createComponentItem(QDeclarativeComponent *component, bool receiveItemGeometryChanges, bool createDefault)
+QQuickItem *QQuickItemViewPrivate::createComponentItem(QQmlComponent *component, bool receiveItemGeometryChanges, bool createDefault)
{
Q_Q(QQuickItemView);
QQuickItem *item = 0;
if (component) {
- QDeclarativeContext *creationContext = component->creationContext();
- QDeclarativeContext *context = new QDeclarativeContext(
+ QQmlContext *creationContext = component->creationContext();
+ QQmlContext *context = new QQmlContext(
creationContext ? creationContext : qmlContext(q));
QObject *nobj = component->create(context);
if (nobj) {
- QDeclarative_setParent_noEvent(context, nobj);
+ QQml_setParent_noEvent(context, nobj);
item = qobject_cast<QQuickItem *>(nobj);
if (!item)
delete nobj;
@@ -2187,7 +2187,7 @@ QQuickItem *QQuickItemViewPrivate::createComponentItem(QDeclarativeComponent *co
item = new QQuickItem;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->contentItem());
+ QQml_setParent_noEvent(item, q->contentItem());
item->setParentItem(q->contentItem());
if (receiveItemGeometryChanges) {
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index 69a3d4a0c8..f252fb58f1 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -48,9 +48,9 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
+QT_MODULE(Quick)
-class QDeclarativeChangeSet;
+class QQuickChangeSet;
class QQuickItemViewPrivate;
@@ -59,7 +59,7 @@ class Q_AUTOTEST_EXPORT QQuickItemView : public QQuickFlickable
Q_OBJECT
Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
@@ -71,21 +71,21 @@ class Q_AUTOTEST_EXPORT QQuickItemView : public QQuickFlickable
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
- Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader NOTIFY headerChanged)
+ Q_PROPERTY(QQmlComponent *header READ header WRITE setHeader NOTIFY headerChanged)
Q_PROPERTY(QQuickItem *headerItem READ headerItem NOTIFY headerItemChanged)
- Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter NOTIFY footerChanged)
+ Q_PROPERTY(QQmlComponent *footer READ footer WRITE setFooter NOTIFY footerChanged)
Q_PROPERTY(QQuickItem *footerItem READ footerItem NOTIFY footerItemChanged)
- Q_PROPERTY(QDeclarativeTransition *populate READ populateTransition WRITE setPopulateTransition NOTIFY populateTransitionChanged)
- Q_PROPERTY(QDeclarativeTransition *add READ addTransition WRITE setAddTransition NOTIFY addTransitionChanged)
- Q_PROPERTY(QDeclarativeTransition *addDisplaced READ addDisplacedTransition WRITE setAddDisplacedTransition NOTIFY addDisplacedTransitionChanged)
- Q_PROPERTY(QDeclarativeTransition *move READ moveTransition WRITE setMoveTransition NOTIFY moveTransitionChanged)
- Q_PROPERTY(QDeclarativeTransition *moveDisplaced READ moveDisplacedTransition WRITE setMoveDisplacedTransition NOTIFY moveDisplacedTransitionChanged)
- Q_PROPERTY(QDeclarativeTransition *remove READ removeTransition WRITE setRemoveTransition NOTIFY removeTransitionChanged)
- Q_PROPERTY(QDeclarativeTransition *removeDisplaced READ removeDisplacedTransition WRITE setRemoveDisplacedTransition NOTIFY removeDisplacedTransitionChanged)
- Q_PROPERTY(QDeclarativeTransition *displaced READ displacedTransition WRITE setDisplacedTransition NOTIFY displacedTransitionChanged)
+ Q_PROPERTY(QQuickTransition *populate READ populateTransition WRITE setPopulateTransition NOTIFY populateTransitionChanged)
+ Q_PROPERTY(QQuickTransition *add READ addTransition WRITE setAddTransition NOTIFY addTransitionChanged)
+ Q_PROPERTY(QQuickTransition *addDisplaced READ addDisplacedTransition WRITE setAddDisplacedTransition NOTIFY addDisplacedTransitionChanged)
+ Q_PROPERTY(QQuickTransition *move READ moveTransition WRITE setMoveTransition NOTIFY moveTransitionChanged)
+ Q_PROPERTY(QQuickTransition *moveDisplaced READ moveDisplacedTransition WRITE setMoveDisplacedTransition NOTIFY moveDisplacedTransitionChanged)
+ Q_PROPERTY(QQuickTransition *remove READ removeTransition WRITE setRemoveTransition NOTIFY removeTransitionChanged)
+ Q_PROPERTY(QQuickTransition *removeDisplaced READ removeDisplacedTransition WRITE setRemoveDisplacedTransition NOTIFY removeDisplacedTransitionChanged)
+ Q_PROPERTY(QQuickTransition *displaced READ displacedTransition WRITE setDisplacedTransition NOTIFY displacedTransitionChanged)
- Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
+ Q_PROPERTY(QQmlComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
Q_PROPERTY(QQuickItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem NOTIFY highlightFollowsCurrentItemChanged)
Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
@@ -103,8 +103,8 @@ public:
QVariant model() const;
void setModel(const QVariant &);
- QDeclarativeComponent *delegate() const;
- void setDelegate(QDeclarativeComponent *);
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *);
int count() const;
@@ -123,40 +123,40 @@ public:
void setLayoutDirection(Qt::LayoutDirection);
Qt::LayoutDirection effectiveLayoutDirection() const;
- QDeclarativeComponent *footer() const;
- void setFooter(QDeclarativeComponent *);
+ QQmlComponent *footer() const;
+ void setFooter(QQmlComponent *);
QQuickItem *footerItem() const;
- QDeclarativeComponent *header() const;
- void setHeader(QDeclarativeComponent *);
+ QQmlComponent *header() const;
+ void setHeader(QQmlComponent *);
QQuickItem *headerItem() const;
- QDeclarativeTransition *populateTransition() const;
- void setPopulateTransition(QDeclarativeTransition *transition);
+ QQuickTransition *populateTransition() const;
+ void setPopulateTransition(QQuickTransition *transition);
- QDeclarativeTransition *addTransition() const;
- void setAddTransition(QDeclarativeTransition *transition);
+ QQuickTransition *addTransition() const;
+ void setAddTransition(QQuickTransition *transition);
- QDeclarativeTransition *addDisplacedTransition() const;
- void setAddDisplacedTransition(QDeclarativeTransition *transition);
+ QQuickTransition *addDisplacedTransition() const;
+ void setAddDisplacedTransition(QQuickTransition *transition);
- QDeclarativeTransition *moveTransition() const;
- void setMoveTransition(QDeclarativeTransition *transition);
+ QQuickTransition *moveTransition() const;
+ void setMoveTransition(QQuickTransition *transition);
- QDeclarativeTransition *moveDisplacedTransition() const;
- void setMoveDisplacedTransition(QDeclarativeTransition *transition);
+ QQuickTransition *moveDisplacedTransition() const;
+ void setMoveDisplacedTransition(QQuickTransition *transition);
- QDeclarativeTransition *removeTransition() const;
- void setRemoveTransition(QDeclarativeTransition *transition);
+ QQuickTransition *removeTransition() const;
+ void setRemoveTransition(QQuickTransition *transition);
- QDeclarativeTransition *removeDisplacedTransition() const;
- void setRemoveDisplacedTransition(QDeclarativeTransition *transition);
+ QQuickTransition *removeDisplacedTransition() const;
+ void setRemoveDisplacedTransition(QQuickTransition *transition);
- QDeclarativeTransition *displacedTransition() const;
- void setDisplacedTransition(QDeclarativeTransition *transition);
+ QQuickTransition *displacedTransition() const;
+ void setDisplacedTransition(QQuickTransition *transition);
- QDeclarativeComponent *highlight() const;
- void setHighlight(QDeclarativeComponent *);
+ QQmlComponent *highlight() const;
+ void setHighlight(QQmlComponent *);
QQuickItem *highlightItem() const;
@@ -239,7 +239,7 @@ protected slots:
void destroyRemoved();
void createdItem(int index, QQuickItem *item);
void initItem(int index, QQuickItem *item);
- void modelUpdated(const QDeclarativeChangeSet &changeSet, bool reset);
+ void modelUpdated(const QQuickChangeSet &changeSet, bool reset);
void destroyingItem(QQuickItem *item);
void animStopped();
void trackedPositionChanged();
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index 57860a43c6..80dacc0cb4 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -47,14 +47,14 @@
#include "qquickflickable_p_p.h"
#include "qquickvisualdatamodel_p.h"
#include "qquickvisualitemmodel_p.h"
-#include <private/qdeclarativechangeset_p.h>
+#include <private/qquickchangeset_p.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
+QT_MODULE(Quick)
class FxViewItem : public QQuickViewItem
@@ -86,12 +86,12 @@ public:
void prepare(int currentIndex, int count);
void reset();
- void applyChanges(const QDeclarativeChangeSet &changeSet);
+ void applyChanges(const QQuickChangeSet &changeSet);
int itemCount;
int newCurrentIndex;
- QDeclarativeChangeSet pendingChanges;
- QHash<QDeclarativeChangeSet::MoveKey, FxViewItem *> removedItems;
+ QQuickChangeSet pendingChanges;
+ QHash<QQuickChangeSet::MoveKey, FxViewItem *> removedItems;
bool active : 1;
bool currentChanged : 1;
@@ -107,7 +107,7 @@ public:
~QQuickItemViewPrivate();
struct ChangeResult {
- QDeclarativeNullableValue<qreal> visiblePos;
+ QQmlNullableValue<qreal> visiblePos;
bool changedFirstItem;
qreal sizeChangesBeforeVisiblePos;
qreal sizeChangesAfterVisiblePos;
@@ -119,7 +119,7 @@ public:
sizeChangesBeforeVisiblePos(0), sizeChangesAfterVisiblePos(0),
countChangeBeforeVisible(0), countChangeAfterVisibleItems(0) {}
- ChangeResult(const QDeclarativeNullableValue<qreal> &p)
+ ChangeResult(const QQmlNullableValue<qreal> &p)
: visiblePos(p), changedFirstItem(false),
sizeChangesBeforeVisiblePos(0), sizeChangesAfterVisiblePos(0),
countChangeBeforeVisible(0), countChangeAfterVisibleItems(0) {}
@@ -173,7 +173,7 @@ public:
virtual bool releaseItem(FxViewItem *item);
QQuickItem *createHighlightItem();
- QQuickItem *createComponentItem(QDeclarativeComponent *component, bool receiveItemGeometryChanges, bool createDefault = false);
+ QQuickItem *createComponentItem(QQmlComponent *component, bool receiveItemGeometryChanges, bool createDefault = false);
void updateCurrent(int modelIndex);
void updateTrackedItem();
@@ -183,18 +183,18 @@ public:
void positionViewAtIndex(int index, int mode);
void applyPendingChanges();
bool applyModelChanges(ChangeResult *insertionResult, ChangeResult *removalResult);
- bool applyRemovalChange(const QDeclarativeChangeSet::Remove &removal, ChangeResult *changeResult, int *removedCount);
- void removeItem(FxViewItem *item, const QDeclarativeChangeSet::Remove &removal, ChangeResult *removeResult);
+ bool applyRemovalChange(const QQuickChangeSet::Remove &removal, ChangeResult *changeResult, int *removedCount);
+ void removeItem(FxViewItem *item, const QQuickChangeSet::Remove &removal, ChangeResult *removeResult);
void repositionFirstItem(FxViewItem *prevVisibleItemsFirst, qreal prevVisibleItemsFirstPos,
FxViewItem *prevFirstVisible, ChangeResult *insertionResult, ChangeResult *removalResult);
void createTransitioner();
void prepareVisibleItemTransitions();
- void prepareRemoveTransitions(QHash<QDeclarativeChangeSet::MoveKey, FxViewItem *> *removedItems);
+ void prepareRemoveTransitions(QHash<QQuickChangeSet::MoveKey, FxViewItem *> *removedItems);
bool prepareNonVisibleItemTransition(FxViewItem *item, const QRectF &viewBounds);
virtual void viewItemTransitionFinished(QQuickViewItem *item);
- int findMoveKeyIndex(QDeclarativeChangeSet::MoveKey key, const QVector<QDeclarativeChangeSet::Remove> &changes) const;
+ int findMoveKeyIndex(QQuickChangeSet::MoveKey key, const QVector<QQuickChangeSet::Remove> &changes) const;
void checkVisible() const;
void showVisibleItems() const;
@@ -206,7 +206,7 @@ public:
hData.markExtentsDirty();
}
- QDeclarativeGuard<QQuickVisualModel> model;
+ QQmlGuard<QQuickVisualModel> model;
QVariant modelVariant;
int itemCount;
int buffer;
@@ -225,22 +225,22 @@ public:
FxViewItem *requestedItem;
QQuickItemViewChangeSet currentChanges;
- QDeclarativeComponent *highlightComponent;
+ QQmlComponent *highlightComponent;
FxViewItem *highlight;
int highlightRange; // enum value
qreal highlightRangeStart;
qreal highlightRangeEnd;
int highlightMoveDuration;
- QDeclarativeComponent *headerComponent;
+ QQmlComponent *headerComponent;
FxViewItem *header;
- QDeclarativeComponent *footerComponent;
+ QQmlComponent *footerComponent;
FxViewItem *footer;
struct MovedItem {
FxViewItem *item;
- QDeclarativeChangeSet::MoveKey moveKey;
- MovedItem(FxViewItem *i, QDeclarativeChangeSet::MoveKey k)
+ QQuickChangeSet::MoveKey moveKey;
+ MovedItem(FxViewItem *i, QQuickChangeSet::MoveKey k)
: item(i), moveKey(k) {}
};
QQuickItemViewTransitioner *transitioner;
@@ -300,7 +300,7 @@ protected:
virtual void layoutVisibleItems(int fromModelIndex = 0) = 0;
virtual void changedVisibleIndex(int newIndex) = 0;
- virtual bool applyInsertionChange(const QDeclarativeChangeSet::Insert &insert, ChangeResult *changeResult,
+ virtual bool applyInsertionChange(const QQuickChangeSet::Insert &insert, ChangeResult *changeResult,
QList<FxViewItem *> *newItems, QList<MovedItem> *movingIntoView) = 0;
virtual bool needsRefillForAddedOrRemovedIndex(int) const { return false; }
diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp
index 3febc9b113..54375bf4ff 100644
--- a/src/quick/items/qquickitemviewtransition.cpp
+++ b/src/quick/items/qquickitemviewtransition.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -41,7 +41,7 @@
#include "qquickitemviewtransition_p.h"
#include <QtQuick/qquickitem.h>
-#include <QtQuick/private/qdeclarativetransition_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
QT_BEGIN_NAMESPACE
@@ -49,7 +49,7 @@ static QList<int> qquickitemviewtransition_emptyIndexes = QList<int>();
static QList<QObject *> qquickitemviewtransition_emptyTargets = QList<QObject *>();
-class QQuickItemViewTransitionJob : public QDeclarativeTransitionManager
+class QQuickItemViewTransitionJob : public QQuickTransitionManager
{
public:
QQuickItemViewTransitionJob();
@@ -95,7 +95,7 @@ void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickIt
return;
}
- QDeclarativeTransition *trans = transitioner->transitionObject(type, isTargetItem);
+ QQuickTransition *trans = transitioner->transitionObject(type, isTargetItem);
if (!trans) {
qWarning("QQuickItemView: invalid view transition!");
return;
@@ -122,17 +122,17 @@ void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickIt
emit attached->targetItemsChanged();
}
- QDeclarativeStateOperation::ActionList actions;
- actions << QDeclarativeAction(item->item, QLatin1String("x"), QVariant(to.x()));
- actions << QDeclarativeAction(item->item, QLatin1String("y"), QVariant(to.y()));
+ QQuickStateOperation::ActionList actions;
+ actions << QQuickAction(item->item, QLatin1String("x"), QVariant(to.x()));
+ actions << QQuickAction(item->item, QLatin1String("y"), QVariant(to.y()));
m_transitioner->runningJobs << this;
- QDeclarativeTransitionManager::transition(actions, trans, item->item);
+ QQuickTransitionManager::transition(actions, trans, item->item);
}
void QQuickItemViewTransitionJob::finished()
{
- QDeclarativeTransitionManager::finished();
+ QQuickTransitionManager::finished();
if (m_transitioner)
m_transitioner->finishedTransition(this, m_item);
@@ -218,7 +218,7 @@ void QQuickItemViewTransitioner::transitionNextReposition(QQuickViewItem *item,
}
}
-QDeclarativeTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget)
+QQuickTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget)
{
if (type == QQuickItemViewTransitioner::NoTransition)
return 0;
@@ -226,7 +226,7 @@ QDeclarativeTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemV
if (type == PopulateTransition)
asTarget = true; // no separate displaced transition
- QDeclarativeTransition *trans = 0;
+ QQuickTransition *trans = 0;
switch (type) {
case NoTransition:
break;
@@ -863,9 +863,9 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent)
\sa QtQuick2::ViewTransition::targetIndexes
*/
-QDeclarativeListProperty<QObject> QQuickViewTransitionAttached::targetItems()
+QQmlListProperty<QObject> QQuickViewTransitionAttached::targetItems()
{
- return QDeclarativeListProperty<QObject>(this, m_targetItems);
+ return QQmlListProperty<QObject>(this, m_targetItems);
}
QQuickViewTransitionAttached *QQuickViewTransitionAttached::qmlAttachedProperties(QObject *obj)
diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h
index 57ea85bae6..3fb43d6b96 100644
--- a/src/quick/items/qquickitemviewtransition_p.h
+++ b/src/quick/items/qquickitemviewtransition_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,13 +42,13 @@
#ifndef QQUICKITEMVIEWTRANSITION_P_P_H
#define QQUICKITEMVIEWTRANSITION_P_P_H
-#include <private/qdeclarativetransitionmanager_p_p.h>
+#include <private/qquicktransitionmanager_p_p.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
+QT_MODULE(Quick)
class QQuickItem;
class QQuickViewItem;
@@ -82,7 +82,7 @@ public:
bool canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const;
void transitionNextReposition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, bool isTarget);
- QDeclarativeTransition *transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget);
+ QQuickTransition *transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget);
const QList<int> &targetIndexes(QQuickItemViewTransitioner::TransitionType type) const;
const QList<QObject *> &targetItems(QQuickItemViewTransitioner::TransitionType type) const;
@@ -98,14 +98,14 @@ public:
QList<QObject *> moveTransitionTargets;
QList<QObject *> removeTransitionTargets;
- QDeclarativeTransition *populateTransition;
- QDeclarativeTransition *addTransition;
- QDeclarativeTransition *addDisplacedTransition;
- QDeclarativeTransition *moveTransition;
- QDeclarativeTransition *moveDisplacedTransition;
- QDeclarativeTransition *removeTransition;
- QDeclarativeTransition *removeDisplacedTransition;
- QDeclarativeTransition *displacedTransition;
+ QQuickTransition *populateTransition;
+ QQuickTransition *addTransition;
+ QQuickTransition *addDisplacedTransition;
+ QQuickTransition *moveTransition;
+ QQuickTransition *moveDisplacedTransition;
+ QQuickTransition *removeTransition;
+ QQuickTransition *removeDisplacedTransition;
+ QQuickTransition *displacedTransition;
private:
friend class QQuickItemViewTransitionJob;
@@ -167,7 +167,7 @@ class QQuickViewTransitionAttached : public QObject
Q_PROPERTY(QPointF destination READ destination NOTIFY destinationChanged)
Q_PROPERTY(QList<int> targetIndexes READ targetIndexes NOTIFY targetIndexesChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged)
public:
QQuickViewTransitionAttached(QObject *parent);
@@ -177,7 +177,7 @@ public:
QPointF destination() const { return m_destination; }
QList<int> targetIndexes() const { return m_targetIndexes; }
- QDeclarativeListProperty<QObject> targetItems();
+ QQmlListProperty<QObject> targetItems();
static QQuickViewTransitionAttached *qmlAttachedProperties(QObject *);
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 876859eeb1..5e9a685cf5 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,14 +43,14 @@
#include "qquickitemview_p_p.h"
#include "qquickvisualitemmodel_p.h"
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlinfo.h>
#include <QtGui/qevent.h>
#include <QtCore/qmath.h>
#include <QtCore/qcoreapplication.h>
-#include <private/qdeclarativesmoothedanimation_p_p.h>
+#include <private/qquicksmoothedanimation_p_p.h>
#include <private/qlistmodelinterface_p.h>
#include "qplatformdefs.h"
@@ -106,7 +106,7 @@ public:
virtual void setPosition(qreal pos);
virtual void layoutVisibleItems(int fromModelIndex = 0);
- virtual bool applyInsertionChange(const QDeclarativeChangeSet::Insert &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView);
+ virtual bool applyInsertionChange(const QQuickChangeSet::Insert &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView);
virtual void translateAndTransitionItemsAfter(int afterIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult);
virtual void updateSections();
@@ -132,7 +132,7 @@ public:
virtual void fixupPosition();
virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
virtual void flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
- QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
+ QQuickTimeLineCallback::Callback fixupCallback, qreal velocity);
QQuickListView::Orientation orient;
qreal visiblePos;
@@ -205,7 +205,7 @@ void QQuickViewSection::setCriteria(QQuickViewSection::SectionCriteria criteria)
}
}
-void QQuickViewSection::setDelegate(QDeclarativeComponent *delegate)
+void QQuickViewSection::setDelegate(QQmlComponent *delegate)
{
if (delegate != m_delegate) {
m_delegate = delegate;
@@ -844,7 +844,7 @@ void QQuickListViewPrivate::createHighlight()
}
const QLatin1String posProp(orient == QQuickListView::Vertical ? "y" : "x");
highlightPosAnimator = new QSmoothedAnimation;
- highlightPosAnimator->target = QDeclarativeProperty(item, posProp);
+ highlightPosAnimator->target = QQmlProperty(item, posProp);
highlightPosAnimator->velocity = highlightMoveSpeed;
highlightPosAnimator->userDuration = highlightMoveDuration;
@@ -852,7 +852,7 @@ void QQuickListViewPrivate::createHighlight()
highlightSizeAnimator = new QSmoothedAnimation;
highlightSizeAnimator->velocity = highlightResizeSpeed;
highlightSizeAnimator->userDuration = highlightResizeDuration;
- highlightSizeAnimator->target = QDeclarativeProperty(item, sizeProp);
+ highlightSizeAnimator->target = QQmlProperty(item, sizeProp);
highlight = newHighlight;
changed = true;
@@ -907,22 +907,22 @@ QQuickItem * QQuickListViewPrivate::getSectionItem(const QString &section)
sectionItem = sectionCache[i];
sectionCache[i] = 0;
sectionItem->setVisible(true);
- QDeclarativeContext *context = QDeclarativeEngine::contextForObject(sectionItem)->parentContext();
+ QQmlContext *context = QQmlEngine::contextForObject(sectionItem)->parentContext();
context->setContextProperty(QLatin1String("section"), section);
} else {
- QDeclarativeContext *creationContext = sectionCriteria->delegate()->creationContext();
- QDeclarativeContext *context = new QDeclarativeContext(
+ QQmlContext *creationContext = sectionCriteria->delegate()->creationContext();
+ QQmlContext *context = new QQmlContext(
creationContext ? creationContext : qmlContext(q));
context->setContextProperty(QLatin1String("section"), section);
QObject *nobj = sectionCriteria->delegate()->beginCreate(context);
if (nobj) {
- QDeclarative_setParent_noEvent(context, nobj);
+ QQml_setParent_noEvent(context, nobj);
sectionItem = qobject_cast<QQuickItem *>(nobj);
if (!sectionItem) {
delete nobj;
} else {
sectionItem->setZ(2);
- QDeclarative_setParent_noEvent(sectionItem, contentItem);
+ QQml_setParent_noEvent(sectionItem, contentItem);
sectionItem->setParentItem(contentItem);
}
} else {
@@ -960,7 +960,7 @@ void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem)
listItem->setSection(getSectionItem(listItem->attached->m_section));
listItem->setPosition(pos);
} else {
- QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section())->parentContext();
+ QQmlContext *context = QQmlEngine::contextForObject(listItem->section())->parentContext();
context->setContextProperty(QLatin1String("section"), listItem->attached->m_section);
}
} else if (listItem->section()) {
@@ -1013,7 +1013,7 @@ void QQuickListViewPrivate::updateStickySections()
if (!currentSectionItem) {
currentSectionItem = getSectionItem(currentSection);
} else if (currentStickySection != currentSection) {
- QDeclarativeContext *context = QDeclarativeEngine::contextForObject(currentSectionItem)->parentContext();
+ QQmlContext *context = QQmlEngine::contextForObject(currentSectionItem)->parentContext();
context->setContextProperty(QLatin1String("section"), currentSection);
}
currentStickySection = currentSection;
@@ -1046,7 +1046,7 @@ void QQuickListViewPrivate::updateStickySections()
if (!nextSectionItem) {
nextSectionItem = getSectionItem(nextSection);
} else if (nextStickySection != nextSection) {
- QDeclarativeContext *context = QDeclarativeEngine::contextForObject(nextSectionItem)->parentContext();
+ QQmlContext *context = QQmlEngine::contextForObject(nextSectionItem)->parentContext();
context->setContextProperty(QLatin1String("section"), nextSection);
}
nextStickySection = nextSection;
@@ -1419,7 +1419,7 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
}
void QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
- QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
+ QQuickTimeLineCallback::Callback fixupCallback, qreal velocity)
{
Q_Q(QQuickListView);
@@ -1533,7 +1533,7 @@ void QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
}
timeline.reset(data.move);
timeline.accel(data.move, v, accel, maxDistance + overshootDist);
- timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
+ timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this));
if (!hData.flicking && q->xflick()) {
hData.flicking = true;
emit q->flickingChanged();
@@ -1574,7 +1574,7 @@ void QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
}
timeline.reset(data.move);
timeline.accelDistance(data.move, v, -dist);
- timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
+ timeline.callback(QQuickTimeLineCallback(&data.move, fixupCallback, this));
}
} else {
correctFlick = false;
@@ -1606,13 +1606,13 @@ void QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
The following example shows the definition of a simple list model defined
in a file called \c ContactModel.qml:
- \snippet doc/src/snippets/declarative/listview/ContactModel.qml 0
+ \snippet doc/src/snippets/qml/listview/ContactModel.qml 0
Another component can display this model data in a ListView, like this:
- \snippet doc/src/snippets/declarative/listview/listview.qml import
+ \snippet doc/src/snippets/qml/listview/listview.qml import
\codeline
- \snippet doc/src/snippets/declarative/listview/listview.qml classdocs simple
+ \snippet doc/src/snippets/qml/listview/listview.qml classdocs simple
\image listview-simple.png
@@ -1623,7 +1623,7 @@ void QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
An improved list view is shown below. The delegate is visually improved and is moved
into a separate \c contactDelegate component.
- \snippet doc/src/snippets/declarative/listview/listview.qml classdocs advanced
+ \snippet doc/src/snippets/qml/listview/listview.qml classdocs advanced
\image listview-highlight.png
The currently selected item is highlighted with a blue \l Rectangle using the \l highlight property,
@@ -1638,7 +1638,7 @@ void QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
this attached property directly as \c ListView.isCurrentItem, while the child
\c contactInfo object must refer to this property as \c wrapper.ListView.isCurrentItem.
- \snippet doc/src/snippets/declarative/listview/listview.qml isCurrentItem
+ \snippet doc/src/snippets/qml/listview/listview.qml isCurrentItem
\note Views do not enable \e clip automatically. If the view
is not clipped by another item or the screen, it will be necessary
@@ -1664,7 +1664,7 @@ QQuickListView::~QQuickListView()
This property may be used to adjust the appearance of the current item, for example:
- \snippet doc/src/snippets/declarative/listview/listview.qml isCurrentItem
+ \snippet doc/src/snippets/qml/listview/listview.qml isCurrentItem
*/
/*!
@@ -1711,7 +1711,7 @@ QQuickListView::~QQuickListView()
until an animation completes. The example delegate below ensures that the
animation completes before the item is removed from the list.
- \snippet doc/src/snippets/declarative/listview/listview.qml delayRemove
+ \snippet doc/src/snippets/qml/listview/listview.qml delayRemove
If a \l remove transition has been specified, it will not be applied until
delayRemove is returned to \c false.
@@ -1821,7 +1821,7 @@ QQuickListView::~QQuickListView()
Here is a highlight with its motion defined by a \l {SpringAnimation} item:
- \snippet doc/src/snippets/declarative/listview/listview.qml highlightFollowsCurrentItem
+ \snippet doc/src/snippets/qml/listview/listview.qml highlightFollowsCurrentItem
Note that the highlight animation also affects the way that the view
is scrolled. This is because the view moves to maintain the
@@ -2720,7 +2720,7 @@ void QQuickListView::updateSections()
}
}
-bool QQuickListViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::Insert &change, ChangeResult *insertResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView)
+bool QQuickListViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &change, ChangeResult *insertResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView)
{
int modelIndex = change.index;
int count = change.count;
diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h
index 058c50f4d7..ef989ba839 100644
--- a/src/quick/items/qquicklistview_p.h
+++ b/src/quick/items/qquicklistview_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,7 +44,7 @@
#include "qquickitemview_p.h"
-#include <private/qdeclarativeguard_p.h>
+#include <private/qqmlguard_p.h>
QT_BEGIN_HEADER
@@ -57,7 +57,7 @@ class Q_AUTOTEST_EXPORT QQuickViewSection : public QObject
Q_OBJECT
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY criteriaChanged)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int labelPositioning READ labelPositioning WRITE setLabelPositioning NOTIFY labelPositioningChanged)
Q_ENUMS(SectionCriteria)
Q_ENUMS(LabelPositioning)
@@ -71,8 +71,8 @@ public:
SectionCriteria criteria() const { return m_criteria; }
void setCriteria(SectionCriteria);
- QDeclarativeComponent *delegate() const { return m_delegate; }
- void setDelegate(QDeclarativeComponent *delegate);
+ QQmlComponent *delegate() const { return m_delegate; }
+ void setDelegate(QQmlComponent *delegate);
QString sectionString(const QString &value);
@@ -89,7 +89,7 @@ Q_SIGNALS:
private:
QString m_property;
SectionCriteria m_criteria;
- QDeclarativeComponent *m_delegate;
+ QQmlComponent *m_delegate;
int m_labelPositioning;
QQuickListViewPrivate *m_view;
};
@@ -197,7 +197,7 @@ Q_SIGNALS:
void viewChanged();
public:
- QDeclarativeGuard<QQuickListView> m_view;
+ QQmlGuard<QQuickListView> m_view;
QQuickItem *m_sectionItem;
};
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index 92724f4095..bbc51a4d26 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -41,12 +41,12 @@
#include "qquickloader_p_p.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativeglobal_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qqmlglobal_p.h>
-#include <private/qdeclarativecomponent_p.h>
+#include <private/qqmlcomponent_p.h>
#include <private/qv8_p.h>
@@ -133,7 +133,7 @@ void QQuickLoaderPrivate::initResize()
Here is a Loader that loads "Page1.qml" as a component when the
\l MouseArea is clicked:
- \snippet doc/src/snippets/declarative/loader/simple.qml 0
+ \snippet doc/src/snippets/qml/loader/simple.qml 0
The loaded item can be accessed using the \l item property.
@@ -165,8 +165,8 @@ void QQuickLoaderPrivate::initResize()
\o sizeloader.qml
\o sizeitem.qml
\row
- \o \snippet doc/src/snippets/declarative/loader/sizeloader.qml 0
- \o \snippet doc/src/snippets/declarative/loader/sizeitem.qml 0
+ \o \snippet doc/src/snippets/qml/loader/sizeloader.qml 0
+ \o \snippet doc/src/snippets/qml/loader/sizeitem.qml 0
\row
\o The red rectangle will be sized to the size of the root item.
\o The red rectangle will be 50x50, centered in the root item.
@@ -185,8 +185,8 @@ void QQuickLoaderPrivate::initResize()
\o application.qml
\o MyItem.qml
\row
- \o \snippet doc/src/snippets/declarative/loader/connections.qml 0
- \o \snippet doc/src/snippets/declarative/loader/MyItem.qml 0
+ \o \snippet doc/src/snippets/qml/loader/connections.qml 0
+ \o \snippet doc/src/snippets/qml/loader/MyItem.qml 0
\endtable
Alternatively, since \c MyItem.qml is loaded within the scope of the
@@ -212,8 +212,8 @@ void QQuickLoaderPrivate::initResize()
\o application.qml
\o KeyReader.qml
\row
- \o \snippet doc/src/snippets/declarative/loader/focus.qml 0
- \o \snippet doc/src/snippets/declarative/loader/KeyReader.qml 0
+ \o \snippet doc/src/snippets/qml/loader/focus.qml 0
+ \o \snippet doc/src/snippets/qml/loader/KeyReader.qml 0
\endtable
Once \c KeyReader.qml is loaded, it accepts key events and sets
@@ -344,7 +344,7 @@ void QQuickLoader::loadFromSource()
}
if (isComponentComplete()) {
- d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this);
+ d->component = new QQmlComponent(qmlEngine(this), d->source, this);
d->load();
}
}
@@ -371,13 +371,13 @@ void QQuickLoader::loadFromSource()
\sa source, progress
*/
-QDeclarativeComponent *QQuickLoader::sourceComponent() const
+QQmlComponent *QQuickLoader::sourceComponent() const
{
Q_D(const QQuickLoader);
return d->component;
}
-void QQuickLoader::setSourceComponent(QDeclarativeComponent *comp)
+void QQuickLoader::setSourceComponent(QQmlComponent *comp)
{
Q_D(QQuickLoader);
if (comp == d->component)
@@ -476,7 +476,7 @@ void QQuickLoader::loadFromSourceComponent()
\sa source, active
*/
-void QQuickLoader::setSource(QDeclarativeV8Function *args)
+void QQuickLoader::setSource(QQmlV8Function *args)
{
Q_ASSERT(args);
Q_D(QQuickLoader);
@@ -516,7 +516,7 @@ void QQuickLoaderPrivate::load()
if (!component->isLoading()) {
_q_sourceLoaded();
} else {
- QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
+ QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)),
q, SLOT(_q_sourceLoaded()));
QObject::connect(component, SIGNAL(progressChanged(qreal)),
q, SIGNAL(progressChanged()));
@@ -541,15 +541,15 @@ void QQuickLoaderPrivate::setInitialState(QObject *obj)
QQuickItem *item = qobject_cast<QQuickItem*>(obj);
if (item) {
- QDeclarative_setParent_noEvent(itemContext, obj);
- QDeclarative_setParent_noEvent(item, q);
+ QQml_setParent_noEvent(itemContext, obj);
+ QQml_setParent_noEvent(item, q);
item->setParentItem(q);
}
if (initialPropertyValues.IsEmpty())
return;
- QDeclarativeComponentPrivate *d = QDeclarativeComponentPrivate::get(component);
+ QQmlComponentPrivate *d = QQmlComponentPrivate::get(component);
Q_ASSERT(d && d->engine);
d->initializeObjectWithInitialProperties(qmlGlobalForIpv, initialPropertyValues, obj);
}
@@ -559,13 +559,13 @@ void QQuickLoaderIncubator::statusChanged(Status status)
loader->incubatorStateChanged(status);
}
-void QQuickLoaderPrivate::incubatorStateChanged(QDeclarativeIncubator::Status status)
+void QQuickLoaderPrivate::incubatorStateChanged(QQmlIncubator::Status status)
{
Q_Q(QQuickLoader);
- if (status == QDeclarativeIncubator::Loading || status == QDeclarativeIncubator::Null)
+ if (status == QQmlIncubator::Loading || status == QQmlIncubator::Null)
return;
- if (status == QDeclarativeIncubator::Ready) {
+ if (status == QQmlIncubator::Ready) {
QObject *obj = incubator->object();
item = qobject_cast<QQuickItem*>(obj);
if (item) {
@@ -579,9 +579,9 @@ void QQuickLoaderPrivate::incubatorStateChanged(QDeclarativeIncubator::Status st
emit q->itemChanged();
}
incubator->clear();
- } else if (status == QDeclarativeIncubator::Error) {
+ } else if (status == QQmlIncubator::Error) {
if (!incubator->errors().isEmpty())
- QDeclarativeEnginePrivate::warning(qmlEngine(q), incubator->errors());
+ QQmlEnginePrivate::warning(qmlEngine(q), incubator->errors());
delete itemContext;
itemContext = 0;
delete incubator->object();
@@ -603,7 +603,7 @@ void QQuickLoaderPrivate::_q_sourceLoaded()
Q_Q(QQuickLoader);
if (!component || !component->errors().isEmpty()) {
if (component)
- QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors());
+ QQmlEnginePrivate::warning(qmlEngine(q), component->errors());
if (loadingFromSource)
emit q->sourceChanged();
else
@@ -614,17 +614,17 @@ void QQuickLoaderPrivate::_q_sourceLoaded()
return;
}
- QDeclarativeContext *creationContext = component->creationContext();
+ QQmlContext *creationContext = component->creationContext();
if (!creationContext) creationContext = qmlContext(q);
- itemContext = new QDeclarativeContext(creationContext);
+ itemContext = new QQmlContext(creationContext);
itemContext->setContextObject(q);
delete incubator;
- incubator = new QQuickLoaderIncubator(this, asynchronous ? QDeclarativeIncubator::Asynchronous : QDeclarativeIncubator::AsynchronousIfNested);
+ incubator = new QQuickLoaderIncubator(this, asynchronous ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested);
component->create(*incubator, itemContext);
- if (incubator && incubator->status() == QDeclarativeIncubator::Loading)
+ if (incubator && incubator->status() == QQmlIncubator::Loading)
emit q->statusChanged();
}
@@ -677,11 +677,11 @@ QQuickLoader::Status QQuickLoader::status() const
if (d->component) {
switch (d->component->status()) {
- case QDeclarativeComponent::Loading:
+ case QQmlComponent::Loading:
return Loading;
- case QDeclarativeComponent::Error:
+ case QQmlComponent::Error:
return Error;
- case QDeclarativeComponent::Null:
+ case QQmlComponent::Null:
return Null;
default:
break;
@@ -690,9 +690,9 @@ QQuickLoader::Status QQuickLoader::status() const
if (d->incubator) {
switch (d->incubator->status()) {
- case QDeclarativeIncubator::Loading:
+ case QQmlIncubator::Loading:
return Loading;
- case QDeclarativeIncubator::Error:
+ case QQmlIncubator::Error:
return Error;
default:
break;
@@ -711,7 +711,7 @@ void QQuickLoader::componentComplete()
QQuickItem::componentComplete();
if (active()) {
if (d->loadingFromSource) {
- d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this);
+ d->component = new QQmlComponent(qmlEngine(this), d->source, this);
}
d->load();
}
@@ -826,19 +826,19 @@ void QQuickLoader::geometryChanged(const QRectF &newGeometry, const QRectF &oldG
QQuickItem::geometryChanged(newGeometry, oldGeometry);
}
-QUrl QQuickLoaderPrivate::resolveSourceUrl(QDeclarativeV8Function *args)
+QUrl QQuickLoaderPrivate::resolveSourceUrl(QQmlV8Function *args)
{
QV8Engine *v8engine = args->engine();
QString arg = v8engine->toString((*args)[0]->ToString());
if (arg.isEmpty())
return QUrl();
- QDeclarativeContextData *context = args->context();
+ QQmlContextData *context = args->context();
Q_ASSERT(context);
return context->resolvedUrl(QUrl(arg));
}
-v8::Handle<v8::Object> QQuickLoaderPrivate::extractInitialPropertyValues(QDeclarativeV8Function *args, QObject *loader, bool *error)
+v8::Handle<v8::Object> QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV8Function *args, QObject *loader, bool *error)
{
v8::Local<v8::Object> valuemap;
if (args->Length() >= 2) {
diff --git a/src/quick/items/qquickloader_p.h b/src/quick/items/qquickloader_p.h
index a6cc5a18d9..c5f544b0e8 100644
--- a/src/quick/items/qquickloader_p.h
+++ b/src/quick/items/qquickloader_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -56,7 +56,7 @@ class Q_AUTOTEST_EXPORT QQuickLoader : public QQuickImplicitSizeItem
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QDeclarativeComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceComponentChanged)
+ Q_PROPERTY(QQmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceComponentChanged)
Q_PROPERTY(QQuickItem *item READ item NOTIFY itemChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
@@ -69,13 +69,13 @@ public:
bool active() const;
void setActive(bool newVal);
- Q_INVOKABLE void setSource(QDeclarativeV8Function *);
+ Q_INVOKABLE void setSource(QQmlV8Function *);
QUrl source() const;
void setSource(const QUrl &);
- QDeclarativeComponent *sourceComponent() const;
- void setSourceComponent(QDeclarativeComponent *);
+ QQmlComponent *sourceComponent() const;
+ void setSourceComponent(QQmlComponent *);
void resetSourceComponent();
enum Status { Null, Ready, Loading, Error };
diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h
index 3ef0038493..1ad7756ed8 100644
--- a/src/quick/items/qquickloader_p_p.h
+++ b/src/quick/items/qquickloader_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -56,7 +56,7 @@
#include "qquickloader_p.h"
#include "qquickimplicitsizeitem_p_p.h"
#include "qquickitemchangelistener_p.h"
-#include <qdeclarativeincubator.h>
+#include <qqmlincubator.h>
#include <private/qv8_p.h>
@@ -64,10 +64,10 @@ QT_BEGIN_NAMESPACE
class QQuickLoaderPrivate;
-class QQuickLoaderIncubator : public QDeclarativeIncubator
+class QQuickLoaderIncubator : public QQmlIncubator
{
public:
- QQuickLoaderIncubator(QQuickLoaderPrivate *l, IncubationMode mode) : QDeclarativeIncubator(mode), loader(l) {}
+ QQuickLoaderIncubator(QQuickLoaderPrivate *l, IncubationMode mode) : QQmlIncubator(mode), loader(l) {}
protected:
virtual void statusChanged(Status);
@@ -77,7 +77,7 @@ private:
QQuickLoaderPrivate *loader;
};
-class QDeclarativeContext;
+class QQmlContext;
class QQuickLoaderPrivate : public QQuickImplicitSizeItemPrivate, public QQuickItemChangeListener
{
Q_DECLARE_PUBLIC(QQuickLoader)
@@ -91,16 +91,16 @@ public:
void initResize();
void load();
- void incubatorStateChanged(QDeclarativeIncubator::Status status);
+ void incubatorStateChanged(QQmlIncubator::Status status);
void setInitialState(QObject *o);
void disposeInitialPropertyValues();
- QUrl resolveSourceUrl(QDeclarativeV8Function *args);
- v8::Handle<v8::Object> extractInitialPropertyValues(QDeclarativeV8Function *args, QObject *loader, bool *error);
+ QUrl resolveSourceUrl(QQmlV8Function *args);
+ v8::Handle<v8::Object> extractInitialPropertyValues(QQmlV8Function *args, QObject *loader, bool *error);
QUrl source;
QQuickItem *item;
- QDeclarativeComponent *component;
- QDeclarativeContext *itemContext;
+ QQmlComponent *component;
+ QQmlContext *itemContext;
QQuickLoaderIncubator *incubator;
v8::Persistent<v8::Object> initialPropertyValues;
v8::Persistent<v8::Object> qmlGlobalForIpv;
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index d0894e9590..ec2c980879 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -348,9 +348,9 @@ bool QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent *ev, QQuickItem *i
The following example uses a MouseArea in a \l Rectangle that changes
the \l Rectangle color to red when clicked:
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml import
+ \snippet doc/src/snippets/qml/mousearea/mousearea.qml import
\codeline
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml intro
+ \snippet doc/src/snippets/qml/mousearea/mousearea.qml intro
\clearfloat
Many MouseArea signals pass a \l{MouseEvent}{mouse} parameter that contains
@@ -360,7 +360,7 @@ bool QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent *ev, QQuickItem *i
Here is an extension of the previous example that produces a different
color when the area is right clicked:
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml intro-extended
+ \snippet doc/src/snippets/qml/mousearea/mousearea.qml intro-extended
Behavioral Change in QtQuick 2.0
@@ -659,7 +659,7 @@ void QQuickMouseArea::setPropagateComposedEvents(bool prevent)
The code below displays "right" when the right mouse buttons is pressed:
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml mousebuttons
+ \snippet doc/src/snippets/qml/mousearea/mousearea.qml mousebuttons
\sa acceptedButtons
*/
@@ -1148,7 +1148,7 @@ bool QQuickMouseArea::setPressed(bool p)
The following example displays a \l Rectangle that can be dragged along the X-axis. The opacity
of the rectangle is reduced when it is dragged to the right.
- \snippet doc/src/snippets/declarative/mousearea/mousearea.qml drag
+ \snippet doc/src/snippets/qml/mousearea/mousearea.qml drag
\note Items cannot be dragged if they are anchored for the requested
\c drag.axis. For example, if \c anchors.left or \c anchors.right was set
@@ -1159,7 +1159,7 @@ bool QQuickMouseArea::setPressed(bool p)
If \c drag.filterChildren is set to true, a drag can override descendant MouseAreas. This
enables a parent MouseArea to handle drags, for example, while descendants handle clicks:
- \snippet doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml dragfilter
+ \snippet doc/src/snippets/qml/mousearea/mouseareadragfilter.qml dragfilter
*/
diff --git a/src/quick/items/qquickmousearea_p.h b/src/quick/items/qquickmousearea_p.h
index 0723f8326f..93a0635eb5 100644
--- a/src/quick/items/qquickmousearea_p.h
+++ b/src/quick/items/qquickmousearea_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -132,7 +132,7 @@ class Q_QUICK_EXPORT QQuickMouseArea : public QQuickItem
Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
- Q_PROPERTY(QQuickDrag *drag READ drag CONSTANT) //### add flicking to QQuickDrag or add a QDeclarativeFlick ???
+ Q_PROPERTY(QQuickDrag *drag READ drag CONSTANT) //### add flicking to QQuickDrag or add a QQuickFlick ???
Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
Q_PROPERTY(bool propagateComposedEvents READ propagateComposedEvents WRITE setPropagateComposedEvents NOTIFY propagateComposedEventsChanged)
diff --git a/src/quick/items/qquickmousearea_p_p.h b/src/quick/items/qquickmousearea_p_p.h
index 2060671698..bcdf033cba 100644
--- a/src/quick/items/qquickmousearea_p_p.h
+++ b/src/quick/items/qquickmousearea_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -99,7 +99,7 @@ public:
QPointF startScene;
QPointF targetStartPos;
QPointF lastPos;
- QDeclarativeNullableValue<QPointF> lastScenePos;
+ QQmlNullableValue<QPointF> lastScenePos;
Qt::MouseButton lastButton;
Qt::MouseButtons lastButtons;
Qt::KeyboardModifiers lastModifiers;
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index c1c60c1756..7dd6ec0589 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -309,7 +309,7 @@ void QQuickTouchPoint::setSceneY(qreal sceneY)
In the following example, we have two small rectangles that follow our touch points.
- \snippet doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml 0
+ \snippet doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml 0
By default this property holds an empty list.
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h
index ccb086fd7e..3651278735 100644
--- a/src/quick/items/qquickmultipointtoucharea_p.h
+++ b/src/quick/items/qquickmultipointtoucharea_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -166,7 +166,7 @@ private:
class QQuickGrabGestureEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QObject> touchPoints READ touchPoints)
+ Q_PROPERTY(QQmlListProperty<QObject> touchPoints READ touchPoints)
Q_PROPERTY(qreal dragThreshold READ dragThreshold)
public:
QQuickGrabGestureEvent() : _grab(false), _dragThreshold(qApp->styleHints()->startDragDistance()) {}
@@ -174,8 +174,8 @@ public:
Q_INVOKABLE void grab() { _grab = true; }
bool wantsGrab() const { return _grab; }
- QDeclarativeListProperty<QObject> touchPoints() {
- return QDeclarativeListProperty<QObject>(this, _touchPoints);
+ QQmlListProperty<QObject> touchPoints() {
+ return QQmlListProperty<QObject>(this, _touchPoints);
}
qreal dragThreshold() const { return _dragThreshold; }
@@ -190,7 +190,7 @@ class Q_AUTOTEST_EXPORT QQuickMultiPointTouchArea : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QQuickTouchPoint> touchPoints READ touchPoints)
+ Q_PROPERTY(QQmlListProperty<QQuickTouchPoint> touchPoints READ touchPoints)
Q_PROPERTY(int minimumTouchPoints READ minimumTouchPoints WRITE setMinimumTouchPoints NOTIFY minimumTouchPointsChanged)
Q_PROPERTY(int maximumTouchPoints READ maximumTouchPoints WRITE setMaximumTouchPoints NOTIFY maximumTouchPointsChanged)
@@ -203,21 +203,21 @@ public:
int maximumTouchPoints() const;
void setMaximumTouchPoints(int num);
- QDeclarativeListProperty<QQuickTouchPoint> touchPoints() {
- return QDeclarativeListProperty<QQuickTouchPoint>(this, 0, QQuickMultiPointTouchArea::touchPoint_append, QQuickMultiPointTouchArea::touchPoint_count, QQuickMultiPointTouchArea::touchPoint_at, 0);
+ QQmlListProperty<QQuickTouchPoint> touchPoints() {
+ return QQmlListProperty<QQuickTouchPoint>(this, 0, QQuickMultiPointTouchArea::touchPoint_append, QQuickMultiPointTouchArea::touchPoint_count, QQuickMultiPointTouchArea::touchPoint_at, 0);
}
- static void touchPoint_append(QDeclarativeListProperty<QQuickTouchPoint> *list, QQuickTouchPoint* touch) {
+ static void touchPoint_append(QQmlListProperty<QQuickTouchPoint> *list, QQuickTouchPoint* touch) {
QQuickMultiPointTouchArea *q = static_cast<QQuickMultiPointTouchArea*>(list->object);
q->addTouchPrototype(touch);
}
- static int touchPoint_count(QDeclarativeListProperty<QQuickTouchPoint> *list) {
+ static int touchPoint_count(QQmlListProperty<QQuickTouchPoint> *list) {
QQuickMultiPointTouchArea *q = static_cast<QQuickMultiPointTouchArea*>(list->object);
return q->_touchPrototypes.count();
}
- static QQuickTouchPoint* touchPoint_at(QDeclarativeListProperty<QQuickTouchPoint> *list, int index) {
+ static QQuickTouchPoint* touchPoint_at(QQmlListProperty<QQuickTouchPoint> *list, int index) {
QQuickMultiPointTouchArea *q = static_cast<QQuickMultiPointTouchArea*>(list->object);
return q->_touchPrototypes[index];
}
diff --git a/src/quick/items/qquickninepatchnode.cpp b/src/quick/items/qquickninepatchnode.cpp
index ff265b3a97..649fa527ee 100644
--- a/src/quick/items/qquickninepatchnode.cpp
+++ b/src/quick/items/qquickninepatchnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickninepatchnode_p.h b/src/quick/items/qquickninepatchnode_p.h
index 277b368de7..c2761f74e5 100644
--- a/src/quick/items/qquickninepatchnode_p.h
+++ b/src/quick/items/qquickninepatchnode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp
index 02afc0c4f5..349f2ff3c1 100644
--- a/src/quick/items/qquickpainteditem.cpp
+++ b/src/quick/items/qquickpainteditem.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickpainteditem.h b/src/quick/items/qquickpainteditem.h
index 06768796ca..15afdf8339 100644
--- a/src/quick/items/qquickpainteditem.h
+++ b/src/quick/items/qquickpainteditem.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickpainteditem_p.h b/src/quick/items/qquickpainteditem_p.h
index 8c0a1475a7..d98216ffb0 100644
--- a/src/quick/items/qquickpainteditem_p.h
+++ b/src/quick/items/qquickpainteditem_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index afc336fa04..f8098c8f65 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,10 +43,11 @@
#include "qquickpathview_p_p.h"
#include "qquickcanvas.h"
-#include <QtQuick/private/qdeclarativestate_p.h>
-#include <private/qdeclarativeopenmetaobject_p.h>
+#include <QtQuick/private/qquickstate_p.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlopenmetaobject_p.h>
#include <private/qlistmodelinterface_p.h>
-#include <private/qdeclarativechangeset_p.h>
+#include <private/qquickchangeset_p.h>
#include <QtGui/qevent.h>
#include <QtGui/qevent.h>
@@ -78,16 +79,16 @@ inline qreal qmlMod(qreal x, qreal y)
return fmod(x, y);
}
-static QDeclarativeOpenMetaObjectType *qPathViewAttachedType = 0;
+static QQmlOpenMetaObjectType *qPathViewAttachedType = 0;
QQuickPathViewAttached::QQuickPathViewAttached(QObject *parent)
: QObject(parent), m_percent(-1), m_view(0), m_onPath(false), m_isCurrent(false)
{
if (qPathViewAttachedType) {
- m_metaobject = new QDeclarativeOpenMetaObject(this, qPathViewAttachedType);
+ m_metaobject = new QQmlOpenMetaObject(this, qPathViewAttachedType);
m_metaobject->setCached(true);
} else {
- m_metaobject = new QDeclarativeOpenMetaObject(this);
+ m_metaobject = new QQmlOpenMetaObject(this);
}
}
@@ -126,7 +127,7 @@ QQuickItem *QQuickPathViewPrivate::getItem(int modelIndex, qreal z, bool onPath)
inRequest = true;
QQuickItem *item = model->item(modelIndex, false);
if (item) {
- QDeclarative_setParent_noEvent(item, q);
+ QQml_setParent_noEvent(item, q);
item->setParentItem(q);
requestedIndex = -1;
qPathViewAttachedType = attType;
@@ -153,7 +154,7 @@ void QQuickPathView::createdItem(int index, QQuickItem *item)
att->setOnPath(false);
}
item->setParentItem(this);
- QDeclarative_setParent_noEvent(item, this);
+ QQml_setParent_noEvent(item, this);
d->updateItem(item, index < d->firstIndex ? 0.0 : 1.0);
} else {
d->requestedIndex = -1;
@@ -200,12 +201,12 @@ QQuickPathViewAttached *QQuickPathViewPrivate::attached(QQuickItem *item)
return static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item, false));
}
-QDeclarativeOpenMetaObjectType *QQuickPathViewPrivate::attachedType()
+QQmlOpenMetaObjectType *QQuickPathViewPrivate::attachedType()
{
Q_Q(QQuickPathView);
if (!attType) {
// pre-create one metatype to share with all attached objects
- attType = new QDeclarativeOpenMetaObjectType(&QQuickPathViewAttached::staticMetaObject, qmlEngine(q));
+ attType = new QQmlOpenMetaObjectType(&QQuickPathViewAttached::staticMetaObject, qmlEngine(q));
foreach (const QString &attr, path->attributes())
attType->createProperty(attr.toUtf8());
}
@@ -273,12 +274,12 @@ void QQuickPathViewPrivate::createHighlight()
QQuickItem *item = 0;
if (highlightComponent) {
- QDeclarativeContext *creationContext = highlightComponent->creationContext();
- QDeclarativeContext *highlightContext = new QDeclarativeContext(
+ QQmlContext *creationContext = highlightComponent->creationContext();
+ QQmlContext *highlightContext = new QQmlContext(
creationContext ? creationContext : qmlContext(q));
QObject *nobj = highlightComponent->create(highlightContext);
if (nobj) {
- QDeclarative_setParent_noEvent(highlightContext, nobj);
+ QQml_setParent_noEvent(highlightContext, nobj);
item = qobject_cast<QQuickItem *>(nobj);
if (!item)
delete nobj;
@@ -289,7 +290,7 @@ void QQuickPathViewPrivate::createHighlight()
item = new QQuickItem;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q);
+ QQml_setParent_noEvent(item, q);
item->setParentItem(q);
highlightItem = item;
changed = true;
@@ -426,11 +427,11 @@ void QQuickPathViewPrivate::regenerate()
For example, if there is a simple list model defined in a file \c ContactModel.qml like this:
- \snippet doc/src/snippets/declarative/pathview/ContactModel.qml 0
+ \snippet doc/src/snippets/qml/pathview/ContactModel.qml 0
This data can be represented as a PathView, like this:
- \snippet doc/src/snippets/declarative/pathview/pathview.qml 0
+ \snippet doc/src/snippets/qml/pathview/pathview.qml 0
\image pathview.gif
@@ -463,7 +464,7 @@ void QQuickPathViewPrivate::regenerate()
this attached property directly as \c PathView.isCurrentItem, while the child
\c nameText object must refer to this property as \c wrapper.PathView.isCurrentItem.
- \snippet doc/src/snippets/declarative/pathview/pathview.qml 1
+ \snippet doc/src/snippets/qml/pathview/pathview.qml 1
\bold Note that views do not enable \e clip automatically. If the view
is not clipped by another item or the screen, it will be necessary
@@ -525,7 +526,7 @@ QQuickPathView::~QQuickPathView()
This property may be used to adjust the appearance of the current item.
- \snippet doc/src/snippets/declarative/pathview/pathview.qml 1
+ \snippet doc/src/snippets/qml/pathview/pathview.qml 1
*/
/*!
@@ -551,8 +552,8 @@ void QQuickPathView::setModel(const QVariant &model)
return;
if (d->model) {
- disconnect(d->model, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)),
- this, SLOT(modelUpdated(QDeclarativeChangeSet,bool)));
+ disconnect(d->model, SIGNAL(modelUpdated(QQuickChangeSet,bool)),
+ this, SLOT(modelUpdated(QQuickChangeSet,bool)));
disconnect(d->model, SIGNAL(createdItem(int,QQuickItem*)), this, SLOT(createdItem(int,QQuickItem*)));
disconnect(d->model, SIGNAL(initItem(int,QQuickItem*)), this, SLOT(initItem(int,QQuickItem*)));
for (int i=0; i<d->items.count(); i++){
@@ -583,8 +584,8 @@ void QQuickPathView::setModel(const QVariant &model)
}
d->modelCount = 0;
if (d->model) {
- connect(d->model, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)),
- this, SLOT(modelUpdated(QDeclarativeChangeSet,bool)));
+ connect(d->model, SIGNAL(modelUpdated(QQuickChangeSet,bool)),
+ this, SLOT(modelUpdated(QQuickChangeSet,bool)));
connect(d->model, SIGNAL(createdItem(int,QQuickItem*)), this, SLOT(createdItem(int,QQuickItem*)));
connect(d->model, SIGNAL(initItem(int,QQuickItem*)), this, SLOT(initItem(int,QQuickItem*)));
d->modelCount = d->model->count();
@@ -617,13 +618,13 @@ int QQuickPathView::count() const
This property holds the path used to lay out the items.
For more information see the \l Path documentation.
*/
-QDeclarativePath *QQuickPathView::path() const
+QQuickPath *QQuickPathView::path() const
{
Q_D(const QQuickPathView);
return d->path;
}
-void QQuickPathView::setPath(QDeclarativePath *path)
+void QQuickPathView::setPath(QQuickPath *path)
{
Q_D(QQuickPathView);
if (d->path == path)
@@ -786,13 +787,13 @@ void QQuickPathViewPrivate::setAdjustedOffset(qreal o)
\sa highlightItem, highlightRangeMode
*/
-QDeclarativeComponent *QQuickPathView::highlight() const
+QQmlComponent *QQuickPathView::highlight() const
{
Q_D(const QQuickPathView);
return d->highlightComponent;
}
-void QQuickPathView::setHighlight(QDeclarativeComponent *highlight)
+void QQuickPathView::setHighlight(QQmlComponent *highlight)
{
Q_D(QQuickPathView);
if (highlight != d->highlightComponent) {
@@ -1069,9 +1070,9 @@ bool QQuickPathView::isFlicking() const
item in the delegate.
Here is an example delegate:
- \snippet doc/src/snippets/declarative/pathview/pathview.qml 1
+ \snippet doc/src/snippets/qml/pathview/pathview.qml 1
*/
-QDeclarativeComponent *QQuickPathView::delegate() const
+QQmlComponent *QQuickPathView::delegate() const
{
Q_D(const QQuickPathView);
if (d->model) {
@@ -1082,7 +1083,7 @@ QDeclarativeComponent *QQuickPathView::delegate() const
return 0;
}
-void QQuickPathView::setDelegate(QDeclarativeComponent *delegate)
+void QQuickPathView::setDelegate(QQmlComponent *delegate)
{
Q_D(QQuickPathView);
if (delegate == this->delegate())
@@ -1337,7 +1338,7 @@ void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *)
offsetAdj = 0.0;
moveOffset.setValue(offset);
tl.accel(moveOffset, velocity, accel, dist);
- tl.callback(QDeclarativeTimeLineCallback(&moveOffset, fixOffsetCallback, this));
+ tl.callback(QQuickTimeLineCallback(&moveOffset, fixOffsetCallback, this));
if (!flicking) {
flicking = true;
emit q->flickingChanged();
@@ -1583,7 +1584,7 @@ void QQuickPathView::refill()
d->releaseItem(d->itemCache.takeLast());
}
-void QQuickPathView::modelUpdated(const QDeclarativeChangeSet &changeSet, bool reset)
+void QQuickPathView::modelUpdated(const QQuickChangeSet &changeSet, bool reset)
{
Q_D(QQuickPathView);
if (!d->model || !d->model->isValid() || !d->path || !isComponentComplete())
@@ -1604,7 +1605,7 @@ void QQuickPathView::modelUpdated(const QDeclarativeChangeSet &changeSet, bool r
int moveOffset;
bool currentChanged = false;
bool changedOffset = false;
- foreach (const QDeclarativeChangeSet::Remove &r, changeSet.removes()) {
+ foreach (const QQuickChangeSet::Remove &r, changeSet.removes()) {
if (moveId == -1 && d->currentIndex >= r.index + r.count) {
d->currentIndex -= r.count;
currentChanged = true;
@@ -1630,7 +1631,7 @@ void QQuickPathView::modelUpdated(const QDeclarativeChangeSet &changeSet, bool r
}
d->modelCount -= r.count;
}
- foreach (const QDeclarativeChangeSet::Insert &i, changeSet.inserts()) {
+ foreach (const QQuickChangeSet::Insert &i, changeSet.inserts()) {
if (d->modelCount) {
if (moveId == -1 && i.index <= d->currentIndex) {
d->currentIndex += i.count;
diff --git a/src/quick/items/qquickpathview_p.h b/src/quick/items/qquickpathview_p.h
index 77348302ea..8f1ecd6caf 100644
--- a/src/quick/items/qquickpathview_p.h
+++ b/src/quick/items/qquickpathview_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,13 +44,13 @@
#include "qquickitem.h"
-#include <private/qdeclarativepath_p.h>
+#include <private/qquickpath_p.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QDeclarativeChangeSet;
+class QQuickChangeSet;
class QQuickPathViewPrivate;
class QQuickPathViewAttached;
@@ -59,12 +59,12 @@ class Q_AUTOTEST_EXPORT QQuickPathView : public QQuickItem
Q_OBJECT
Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
- Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(QQuickPath *path READ path WRITE setPath NOTIFY pathChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged)
Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
- Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
+ Q_PROPERTY(QQmlComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
Q_PROPERTY(QQuickItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
@@ -80,7 +80,7 @@ class Q_AUTOTEST_EXPORT QQuickPathView : public QQuickItem
Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged)
Q_ENUMS(HighlightRangeMode)
@@ -92,8 +92,8 @@ public:
QVariant model() const;
void setModel(const QVariant &);
- QDeclarativePath *path() const;
- void setPath(QDeclarativePath *);
+ QQuickPath *path() const;
+ void setPath(QQuickPath *);
int currentIndex() const;
void setCurrentIndex(int idx);
@@ -103,8 +103,8 @@ public:
qreal offset() const;
void setOffset(qreal offset);
- QDeclarativeComponent *highlight() const;
- void setHighlight(QDeclarativeComponent *highlight);
+ QQmlComponent *highlight() const;
+ void setHighlight(QQmlComponent *highlight);
QQuickItem *highlightItem();
enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
@@ -134,8 +134,8 @@ public:
int count() const;
- QDeclarativeComponent *delegate() const;
- void setDelegate(QDeclarativeComponent *);
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *);
int pathItemCount() const;
void setPathItemCount(int);
@@ -186,7 +186,7 @@ private Q_SLOTS:
void refill();
void ticked();
void movementEnding();
- void modelUpdated(const QDeclarativeChangeSet &changeSet, bool reset);
+ void modelUpdated(const QQuickChangeSet &changeSet, bool reset);
void createdItem(int index, QQuickItem *item);
void initItem(int index, QQuickItem *item);
void destroyingItem(QQuickItem *item);
@@ -198,7 +198,7 @@ private:
Q_DECLARE_PRIVATE(QQuickPathView)
};
-class QDeclarativeOpenMetaObject;
+class QQmlOpenMetaObject;
class QQuickPathViewAttached : public QObject
{
Q_OBJECT
@@ -241,7 +241,7 @@ private:
friend class QQuickPathViewPrivate;
friend class QQuickPathView;
QQuickPathView *m_view;
- QDeclarativeOpenMetaObject *m_metaobject;
+ QQmlOpenMetaObject *m_metaobject;
bool m_onPath : 1;
bool m_isCurrent : 1;
};
diff --git a/src/quick/items/qquickpathview_p_p.h b/src/quick/items/qquickpathview_p_p.h
index b57aa13cbf..a80c01f320 100644
--- a/src/quick/items/qquickpathview_p_p.h
+++ b/src/quick/items/qquickpathview_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -57,17 +57,17 @@
#include "qquickitem_p.h"
#include "qquickvisualdatamodel_p.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qcoreapplication.h>
-#include <private/qdeclarativeanimation_p_p.h>
-#include <private/qdeclarativeguard_p.h>
-#include <private/qdeclarativetimeline_p_p.h>
+#include <private/qquickanimation_p_p.h>
+#include <private/qqmlguard_p.h>
+#include <private/qquicktimeline_p_p.h>
QT_BEGIN_NAMESPACE
-class QDeclarativeOpenMetaObjectType;
+class QQmlOpenMetaObjectType;
class QQuickPathViewAttached;
class QQuickPathViewPrivate : public QQuickItemPrivate, public QQuickItemChangeListener
{
@@ -114,7 +114,7 @@ public:
QQuickItem *getItem(int modelIndex, qreal z = 0, bool onPath=true);
void releaseItem(QQuickItem *item);
QQuickPathViewAttached *attached(QQuickItem *item);
- QDeclarativeOpenMetaObjectType *attachedType();
+ QQmlOpenMetaObjectType *attachedType();
void clear();
void updateMappedRange();
qreal positionOfIndex(qreal index) const;
@@ -143,9 +143,9 @@ public:
void addVelocitySample(qreal v);
qreal calcVelocity() const;
- QDeclarativePath *path;
+ QQuickPath *path;
int currentIndex;
- QDeclarativeGuard<QQuickItem> currentItem;
+ QQmlGuard<QQuickItem> currentItem;
qreal currentItemOffset;
qreal startPc;
QPointF startPoint;
@@ -169,24 +169,24 @@ public:
QPointF lastPos;
qreal dragMargin;
qreal deceleration;
- QDeclarativeTimeLine tl;
- QDeclarativeTimeLineValueProxy<QQuickPathViewPrivate> moveOffset;
+ QQuickTimeLine tl;
+ QQuickTimeLineValueProxy<QQuickPathViewPrivate> moveOffset;
int firstIndex;
int pathItems;
int requestedIndex;
qreal requestedZ;
QList<QQuickItem *> items;
QList<QQuickItem *> itemCache;
- QDeclarativeGuard<QQuickVisualModel> model;
+ QQmlGuard<QQuickVisualModel> model;
QVariant modelVariant;
enum MovementReason { Other, SetIndex, Mouse };
MovementReason moveReason;
enum MovementDirection { Shortest, Negative, Positive };
MovementDirection moveDirection;
- QDeclarativeOpenMetaObjectType *attType;
- QDeclarativeComponent *highlightComponent;
+ QQmlOpenMetaObjectType *attType;
+ QQmlComponent *highlightComponent;
QQuickItem *highlightItem;
- QDeclarativeTimeLineValueProxy<QQuickPathViewPrivate> moveHighlight;
+ QQuickTimeLineValueProxy<QQuickPathViewPrivate> moveHighlight;
qreal highlightPosition;
qreal highlightRangeStart;
qreal highlightRangeEnd;
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index 6ed35a9f42..e1d0457916 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,15 +42,15 @@
#include "qquickpositioners_p.h"
#include "qquickpositioners_p_p.h"
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlinfo.h>
#include <QtCore/qmath.h>
#include <QtCore/qcoreapplication.h>
-#include <QtQuick/private/qdeclarativestate_p.h>
-#include <QtQuick/private/qdeclarativestategroup_p.h>
-#include <private/qdeclarativestateoperations_p.h>
-#include <QtQuick/private/qdeclarativetransition_p.h>
+#include <QtQuick/private/qquickstate_p.h>
+#include <QtQuick/private/qquickstategroup_p.h>
+#include <private/qquickstatechangescript_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
QT_BEGIN_NAMESPACE
@@ -140,13 +140,13 @@ void QQuickBasePositioner::setSpacing(qreal s)
emit spacingChanged();
}
-QDeclarativeTransition *QQuickBasePositioner::move() const
+QQuickTransition *QQuickBasePositioner::move() const
{
Q_D(const QQuickBasePositioner);
return d->transitioner ? d->transitioner->displacedTransition : 0;
}
-void QQuickBasePositioner::setMove(QDeclarativeTransition *mt)
+void QQuickBasePositioner::setMove(QQuickTransition *mt)
{
Q_D(QQuickBasePositioner);
if (!d->transitioner)
@@ -158,13 +158,13 @@ void QQuickBasePositioner::setMove(QDeclarativeTransition *mt)
emit moveChanged();
}
-QDeclarativeTransition *QQuickBasePositioner::add() const
+QQuickTransition *QQuickBasePositioner::add() const
{
Q_D(const QQuickBasePositioner);
return d->transitioner ? d->transitioner->addTransition : 0;
}
-void QQuickBasePositioner::setAdd(QDeclarativeTransition *add)
+void QQuickBasePositioner::setAdd(QQuickTransition *add)
{
Q_D(QQuickBasePositioner);
if (!d->transitioner)
@@ -497,7 +497,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
Below is a Column that contains three rectangles of various sizes:
- \snippet doc/src/snippets/declarative/column/vertical-positioner.qml document
+ \snippet doc/src/snippets/qml/column/vertical-positioner.qml document
The Column automatically positions these items in a vertical formation, like this:
@@ -526,7 +526,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
For example, the Column below sets the \l move property to a specific \l Transition:
- \snippet doc/src/snippets/declarative/column/column-transitions.qml document
+ \snippet doc/src/snippets/qml/column/column-transitions.qml document
When the Space key is pressed, the \l {Item::visible}{visible} value of the green
\l Rectangle is toggled. As it appears and disappears, the blue \l Rectangle moves within
@@ -534,7 +534,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
\image verticalpositioner_transition.gif
- \sa Row, Grid, Flow, Positioner, {declarative/positioners}{Positioners example}
+ \sa Row, Grid, Flow, Positioner, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition QtQuick2::Column::add
@@ -574,7 +574,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
See the \l ViewTransition documentation for more details and examples on using these transitions.
- \sa add, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa add, ViewTransition, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty real QtQuick2::Column::spacing
@@ -645,7 +645,7 @@ void QQuickColumn::reportConflictingAnchors()
Below is a Row that contains three rectangles of various sizes:
- \snippet doc/src/snippets/declarative/row/row.qml document
+ \snippet doc/src/snippets/qml/row/row.qml document
The Row automatically positions these items in a horizontal formation, like this:
@@ -667,7 +667,7 @@ void QQuickColumn::reportConflictingAnchors()
\l{Item Layouts}.
- \sa Column, Grid, Flow, Positioner, {declarative/positioners}{Positioners example}
+ \sa Column, Grid, Flow, Positioner, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition QtQuick2::Row::add
@@ -707,7 +707,7 @@ void QQuickColumn::reportConflictingAnchors()
See the \l ViewTransition documentation for more details and examples on using these transitions.
- \sa add, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa add, ViewTransition, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty real QtQuick2::Row::spacing
@@ -736,7 +736,7 @@ QQuickRow::QQuickRow(QQuickItem *parent)
the right anchor remains to the right of the row.
\endlist
- \sa Grid::layoutDirection, Flow::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example}
+ \sa Grid::layoutDirection, Flow::layoutDirection, {qml/righttoleft/layoutdirection}{Layout directions example}
*/
Qt::LayoutDirection QQuickRow::layoutDirection() const
@@ -863,7 +863,7 @@ void QQuickRow::reportConflictingAnchors()
For example, below is a Grid that contains five rectangles of various sizes:
- \snippet doc/src/snippets/declarative/grid/grid.qml document
+ \snippet doc/src/snippets/qml/grid/grid.qml document
The Grid automatically positions the child items in a grid formation:
@@ -879,7 +879,7 @@ void QQuickRow::reportConflictingAnchors()
\l{Item Layouts}.
- \sa Flow, Row, Column, Positioner, {declarative/positioners}{Positioners example}
+ \sa Flow, Row, Column, Positioner, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition QtQuick2::Grid::add
@@ -919,7 +919,7 @@ void QQuickRow::reportConflictingAnchors()
See the \l ViewTransition documentation for more details and examples on using these transitions.
- \sa add, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa add, ViewTransition, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty qreal QtQuick2::Grid::spacing
@@ -1074,7 +1074,7 @@ void QQuickGrid::setColumnSpacing(const qreal columnSpacing)
\l Grid::flow property.
\endlist
- \sa Flow::layoutDirection, Row::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example}
+ \sa Flow::layoutDirection, Row::layoutDirection, {qml/righttoleft/layoutdirection}{Layout directions example}
*/
Qt::LayoutDirection QQuickGrid::layoutDirection() const
{
@@ -1276,7 +1276,7 @@ void QQuickGrid::reportConflictingAnchors()
Below is a Flow that contains various \l Text items:
- \snippet doc/src/snippets/declarative/flow.qml flow item
+ \snippet doc/src/snippets/qml/flow.qml flow item
The Flow item automatically positions the child \l Text items side by
side, wrapping as necessary:
@@ -1292,7 +1292,7 @@ void QQuickGrid::reportConflictingAnchors()
For more information on using Flow and other related positioner-type elements, see
\l{Item Layouts}.
- \sa Column, Row, Grid, Positioner, {declarative/positioners}{Positioners example}
+ \sa Column, Row, Grid, Positioner, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition QtQuick2::Flow::add
@@ -1332,7 +1332,7 @@ void QQuickGrid::reportConflictingAnchors()
See the \l ViewTransition documentation for more details and examples on using these transitions.
- \sa add, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa add, ViewTransition, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty real QtQuick2::Flow::spacing
@@ -1410,7 +1410,7 @@ void QQuickFlow::setFlow(Flow flow)
\l Flow::flow property.
\endlist
- \sa Grid::layoutDirection, Row::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example}
+ \sa Grid::layoutDirection, Row::layoutDirection, {qml/righttoleft/layoutdirection}{Layout directions example}
*/
Qt::LayoutDirection QQuickFlow::layoutDirection() const
diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h
index 32dd9030fe..8921bfa39b 100644
--- a/src/quick/items/qquickpositioners_p.h
+++ b/src/quick/items/qquickpositioners_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,7 +45,7 @@
#include "qquickimplicitsizeitem_p.h"
#include "qquickitemviewtransition_p.h"
-#include <QtQuick/private/qdeclarativestate_p.h>
+#include <QtQuick/private/qquickstate_p.h>
#include <private/qpodvector_p.h>
#include <QtCore/qobject.h>
@@ -93,8 +93,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBasePositioner : public QQuickImplicitSizeIte
Q_OBJECT
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
- Q_PROPERTY(QDeclarativeTransition *move READ move WRITE setMove NOTIFY moveChanged)
- Q_PROPERTY(QDeclarativeTransition *add READ add WRITE setAdd NOTIFY addChanged)
+ Q_PROPERTY(QQuickTransition *move READ move WRITE setMove NOTIFY moveChanged)
+ Q_PROPERTY(QQuickTransition *add READ add WRITE setAdd NOTIFY addChanged)
public:
enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
@@ -104,11 +104,11 @@ public:
qreal spacing() const;
void setSpacing(qreal);
- QDeclarativeTransition *move() const;
- void setMove(QDeclarativeTransition *);
+ QQuickTransition *move() const;
+ void setMove(QQuickTransition *);
- QDeclarativeTransition *add() const;
- void setAdd(QDeclarativeTransition *);
+ QQuickTransition *add() const;
+ void setAdd(QQuickTransition *);
static QQuickPositionerAttached *qmlAttachedProperties(QObject *obj);
diff --git a/src/quick/items/qquickpositioners_p_p.h b/src/quick/items/qquickpositioners_p_p.h
index f1d174dc0a..21fa67574b 100644
--- a/src/quick/items/qquickpositioners_p_p.h
+++ b/src/quick/items/qquickpositioners_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -56,9 +56,9 @@
#include "qquickpositioners_p.h"
#include "qquickimplicitsizeitem_p_p.h"
-#include <QtQuick/private/qdeclarativestate_p.h>
-#include <private/qdeclarativetransitionmanager_p_p.h>
-#include <private/qdeclarativestateoperations_p.h>
+#include <QtQuick/private/qquickstate_p.h>
+#include <private/qquicktransitionmanager_p_p.h>
+#include <private/qquickstatechangescript_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp
index e2dbf17a29..062df127b3 100644
--- a/src/quick/items/qquickrectangle.cpp
+++ b/src/quick/items/qquickrectangle.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -207,7 +207,7 @@ void QQuickGradientStop::updateGradient()
with red, blending to yellow at one third of the height of the rectangle,
and ending with green:
- \snippet doc/src/snippets/declarative/gradient.qml code
+ \snippet doc/src/snippets/qml/gradient.qml code
\clearfloat
\section1 Performance and Limitations
@@ -248,9 +248,9 @@ QQuickGradient::~QQuickGradient()
delete m_gradient;
}
-QDeclarativeListProperty<QQuickGradientStop> QQuickGradient::stops()
+QQmlListProperty<QQuickGradientStop> QQuickGradient::stops()
{
- return QDeclarativeListProperty<QQuickGradientStop>(this, m_stops);
+ return QQmlListProperty<QQuickGradientStop>(this, m_stops);
}
const QGradient *QQuickGradient::gradient() const
@@ -309,7 +309,7 @@ int QQuickRectanglePrivate::doUpdateSlotIdx = -1;
The following example shows the effects of some of the common properties on a
Rectangle item, which in this case is used to create a square:
- \snippet doc/src/snippets/declarative/rectangle/rectangle.qml document
+ \snippet doc/src/snippets/qml/rectangle/rectangle.qml document
\clearfloat
\section1 Performance
@@ -370,7 +370,7 @@ void QQuickRectangle::doUpdate()
\inlineimage rect-border-width.png
\enddiv
- \snippet doc/src/snippets/declarative/rectangle/rect-border-width.qml 0
+ \snippet doc/src/snippets/qml/rectangle/rect-border-width.qml 0
\clearfloat
Here, the innermost rectangle's border is clipped on the bottom and right edges by its
@@ -394,7 +394,7 @@ QQuickPen *QQuickRectangle::border()
\inlineimage declarative-rect_gradient.png
\enddiv
- \snippet doc/src/snippets/declarative/rectangle/rectangle-gradient.qml rectangles
+ \snippet doc/src/snippets/qml/rectangle/rectangle-gradient.qml rectangles
\clearfloat
If both a gradient and a color are specified, the gradient will be used.
@@ -463,7 +463,7 @@ void QQuickRectangle::setRadius(qreal radius)
The following example shows rectangles with colors specified
using hexadecimal and named color notation:
- \snippet doc/src/snippets/declarative/rectangle/rectangle-colors.qml rectangles
+ \snippet doc/src/snippets/qml/rectangle/rectangle-colors.qml rectangles
\clearfloat
If both a gradient and a color are specified, the gradient will be used.
diff --git a/src/quick/items/qquickrectangle_p.h b/src/quick/items/qquickrectangle_p.h
index 621e9dd980..eec2b56fd3 100644
--- a/src/quick/items/qquickrectangle_p.h
+++ b/src/quick/items/qquickrectangle_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -111,14 +111,14 @@ class Q_AUTOTEST_EXPORT QQuickGradient : public QObject
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QQuickGradientStop> stops READ stops)
+ Q_PROPERTY(QQmlListProperty<QQuickGradientStop> stops READ stops)
Q_CLASSINFO("DefaultProperty", "stops")
public:
QQuickGradient(QObject *parent=0);
~QQuickGradient();
- QDeclarativeListProperty<QQuickGradientStop> stops();
+ QQmlListProperty<QQuickGradientStop> stops();
const QGradient *gradient() const;
diff --git a/src/quick/items/qquickrectangle_p_p.h b/src/quick/items/qquickrectangle_p_p.h
index b2f53108a4..cb923ee563 100644
--- a/src/quick/items/qquickrectangle_p_p.h
+++ b/src/quick/items/qquickrectangle_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp
index 4dcbac772d..d26ebed85e 100644
--- a/src/quick/items/qquickrepeater.cpp
+++ b/src/quick/items/qquickrepeater.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,10 +43,10 @@
#include "qquickrepeater_p_p.h"
#include "qquickvisualdatamodel_p.h"
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativelistaccessor_p.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qquicklistaccessor_p.h>
#include <private/qlistmodelinterface_p.h>
-#include <private/qdeclarativechangeset_p.h>
+#include <private/qquickchangeset_p.h>
QT_BEGIN_NAMESPACE
@@ -79,9 +79,9 @@ QQuickRepeaterPrivate::~QQuickRepeaterPrivate()
The following Repeater creates three instances of a \l Rectangle item within
a \l Row:
- \snippet doc/src/snippets/declarative/repeaters/repeater.qml import
+ \snippet doc/src/snippets/qml/repeaters/repeater.qml import
\codeline
- \snippet doc/src/snippets/declarative/repeaters/repeater.qml simple
+ \snippet doc/src/snippets/qml/repeaters/repeater.qml simple
\image repeater-simple.png
@@ -96,7 +96,7 @@ QQuickRepeaterPrivate::~QQuickRepeaterPrivate()
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/repeaters/repeater.qml layout
+ \snippet doc/src/snippets/qml/repeaters/repeater.qml layout
\image repeater.png
@@ -186,8 +186,8 @@ void QQuickRepeater::setModel(const QVariant &model)
clear();
if (d->model) {
- disconnect(d->model, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)),
- this, SLOT(modelUpdated(QDeclarativeChangeSet,bool)));
+ disconnect(d->model, SIGNAL(modelUpdated(QQuickChangeSet,bool)),
+ this, SLOT(modelUpdated(QQuickChangeSet,bool)));
disconnect(d->model, SIGNAL(createdItem(int,QQuickItem*)), this, SLOT(createdItem(int,QQuickItem*)));
disconnect(d->model, SIGNAL(initItem(int,QQuickItem*)), this, SLOT(initItem(int,QQuickItem*)));
// disconnect(d->model, SIGNAL(destroyingItem(QQuickItem*)), this, SLOT(destroyingItem(QQuickItem*)));
@@ -212,8 +212,8 @@ void QQuickRepeater::setModel(const QVariant &model)
dataModel->setModel(model);
}
if (d->model) {
- connect(d->model, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)),
- this, SLOT(modelUpdated(QDeclarativeChangeSet,bool)));
+ connect(d->model, SIGNAL(modelUpdated(QQuickChangeSet,bool)),
+ this, SLOT(modelUpdated(QQuickChangeSet,bool)));
connect(d->model, SIGNAL(createdItem(int,QQuickItem*)), this, SLOT(createdItem(int,QQuickItem*)));
connect(d->model, SIGNAL(initItem(int,QQuickItem*)), this, SLOT(initItem(int,QQuickItem*)));
// connect(d->model, SIGNAL(destroyingItem(QQuickItem*)), this, SLOT(destroyingItem(QQuickItem*)));
@@ -235,7 +235,7 @@ void QQuickRepeater::setModel(const QVariant &model)
\table
\row
- \o \snippet doc/src/snippets/declarative/repeaters/repeater.qml index
+ \o \snippet doc/src/snippets/qml/repeaters/repeater.qml index
\o \image repeater-index.png
\endtable
@@ -246,7 +246,7 @@ void QQuickRepeater::setModel(const QVariant &model)
\table
\row
- \o \snippet doc/src/snippets/declarative/repeaters/repeater.qml modeldata
+ \o \snippet doc/src/snippets/qml/repeaters/repeater.qml modeldata
\o \image repeater-modeldata.png
\endtable
@@ -256,7 +256,7 @@ void QQuickRepeater::setModel(const QVariant &model)
\sa {QML Data Models}
*/
-QDeclarativeComponent *QQuickRepeater::delegate() const
+QQmlComponent *QQuickRepeater::delegate() const
{
Q_D(const QQuickRepeater);
if (d->model) {
@@ -267,7 +267,7 @@ QDeclarativeComponent *QQuickRepeater::delegate() const
return 0;
}
-void QQuickRepeater::setDelegate(QDeclarativeComponent *delegate)
+void QQuickRepeater::setDelegate(QQmlComponent *delegate)
{
Q_D(QQuickRepeater);
if (QQuickVisualDataModel *dataModel = qobject_cast<QQuickVisualDataModel*>(d->model))
@@ -379,7 +379,7 @@ void QQuickRepeaterPrivate::createItems()
break;
}
deletables[ii] = item;
- QDeclarative_setParent_noEvent(item, q->parentItem());
+ QQml_setParent_noEvent(item, q->parentItem());
item->setParentItem(q->parentItem());
if (ii > 0 && deletables.at(ii-1)) {
item->stackAfter(deletables.at(ii-1));
@@ -408,11 +408,11 @@ void QQuickRepeater::createdItem(int, QQuickItem *)
void QQuickRepeater::initItem(int, QQuickItem *item)
{
- QDeclarative_setParent_noEvent(item, parentItem());
+ QQml_setParent_noEvent(item, parentItem());
item->setParentItem(parentItem());
}
-void QQuickRepeater::modelUpdated(const QDeclarativeChangeSet &changeSet, bool reset)
+void QQuickRepeater::modelUpdated(const QQuickChangeSet &changeSet, bool reset)
{
Q_D(QQuickRepeater);
@@ -426,7 +426,7 @@ void QQuickRepeater::modelUpdated(const QDeclarativeChangeSet &changeSet, bool r
int difference = 0;
QHash<int, QVector<QPointer<QQuickItem> > > moved;
- foreach (const QDeclarativeChangeSet::Remove &remove, changeSet.removes()) {
+ foreach (const QQuickChangeSet::Remove &remove, changeSet.removes()) {
int index = qMin(remove.index, d->deletables.count());
int count = qMin(remove.index + remove.count, d->deletables.count()) - index;
if (remove.isMove()) {
@@ -447,7 +447,7 @@ void QQuickRepeater::modelUpdated(const QDeclarativeChangeSet &changeSet, bool r
}
d->createFrom = -1;
- foreach (const QDeclarativeChangeSet::Insert &insert, changeSet.inserts()) {
+ foreach (const QQuickChangeSet::Insert &insert, changeSet.inserts()) {
int index = qMin(insert.index, d->deletables.count());
if (insert.isMove()) {
QVector<QPointer<QQuickItem> > items = moved.value(insert.moveId);
diff --git a/src/quick/items/qquickrepeater_p.h b/src/quick/items/qquickrepeater_p.h
index f23b1a3034..c67b065def 100644
--- a/src/quick/items/qquickrepeater_p.h
+++ b/src/quick/items/qquickrepeater_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -48,7 +48,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QDeclarativeChangeSet;
+class QQuickChangeSet;
class QQuickRepeaterPrivate;
class Q_AUTOTEST_EXPORT QQuickRepeater : public QQuickItem
@@ -56,7 +56,7 @@ class Q_AUTOTEST_EXPORT QQuickRepeater : public QQuickItem
Q_OBJECT
Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
@@ -67,8 +67,8 @@ public:
QVariant model() const;
void setModel(const QVariant &);
- QDeclarativeComponent *delegate() const;
- void setDelegate(QDeclarativeComponent *);
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *);
int count() const;
@@ -93,7 +93,7 @@ protected:
private Q_SLOTS:
void createdItem(int index, QQuickItem *item);
void initItem(int, QQuickItem *item);
- void modelUpdated(const QDeclarativeChangeSet &changeSet, bool reset);
+ void modelUpdated(const QQuickChangeSet &changeSet, bool reset);
private:
Q_DISABLE_COPY(QQuickRepeater)
diff --git a/src/quick/items/qquickrepeater_p_p.h b/src/quick/items/qquickrepeater_p_p.h
index 761e00c7b0..88e0c94218 100644
--- a/src/quick/items/qquickrepeater_p_p.h
+++ b/src/quick/items/qquickrepeater_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -60,7 +60,7 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeContext;
+class QQmlContext;
class QQuickVisualModel;
class QQuickRepeaterPrivate : public QQuickItemPrivate
{
diff --git a/src/quick/items/qquickscalegrid.cpp b/src/quick/items/qquickscalegrid.cpp
index c9b1d3eba7..de10d8de47 100644
--- a/src/quick/items/qquickscalegrid.cpp
+++ b/src/quick/items/qquickscalegrid.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -41,7 +41,7 @@
#include "qquickscalegrid_p_p.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/items/qquickscalegrid_p_p.h b/src/quick/items/qquickscalegrid_p_p.h
index 9d02b6afb3..ae5627a48e 100644
--- a/src/quick/items/qquickscalegrid_p_p.h
+++ b/src/quick/items/qquickscalegrid_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,10 +44,10 @@
#include "qquickborderimage_p.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
#include <QtCore/qobject.h>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
#include <private/qtquickglobal_p.h>
QT_BEGIN_HEADER
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index 3dfeb90ee0..a00df4600d 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h
index 7e2c389d6c..1a501f2f0f 100644
--- a/src/quick/items/qquickscreen_p.h
+++ b/src/quick/items/qquickscreen_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,10 +42,10 @@
#ifndef QQUICKSCREEN_P_H
#define QQUICKSCREEN_P_H
-#include <qdeclarative.h>
+#include <qqml.h>
#include <QRect>
#include <QSize>
-#include <private/qdeclarativeglobal_p.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_HEADER
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp
index d90d8761c8..3024c31d51 100644
--- a/src/quick/items/qquickshadereffect.cpp
+++ b/src/quick/items/qquickshadereffect.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h
index 2217cbc827..4475c22b28 100644
--- a/src/quick/items/qquickshadereffect_p.h
+++ b/src/quick/items/qquickshadereffect_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickshadereffectmesh.cpp b/src/quick/items/qquickshadereffectmesh.cpp
index 8a43fb55f0..eff5910a09 100644
--- a/src/quick/items/qquickshadereffectmesh.cpp
+++ b/src/quick/items/qquickshadereffectmesh.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h
index 2e57d7db4c..0d8f5a24d0 100644
--- a/src/quick/items/qquickshadereffectmesh_p.h
+++ b/src/quick/items/qquickshadereffectmesh_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qdeclarativeparserstatus.h"
+#include "qqmlparserstatus.h"
#include <QtQuick/qtquickglobal.h>
#include <QtGui/qcolor.h>
diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp
index c809c70612..ae61ad940d 100644
--- a/src/quick/items/qquickshadereffectnode.cpp
+++ b/src/quick/items/qquickshadereffectnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickshadereffectnode_p.h b/src/quick/items/qquickshadereffectnode_p.h
index 295ac61d94..fc47f626e1 100644
--- a/src/quick/items/qquickshadereffectnode_p.h
+++ b/src/quick/items/qquickshadereffectnode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp
index 54590292c5..708d75d137 100644
--- a/src/quick/items/qquickshadereffectsource.cpp
+++ b/src/quick/items/qquickshadereffectsource.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h
index 55d72c18d9..793e89cd69 100644
--- a/src/quick/items/qquickshadereffectsource_p.h
+++ b/src/quick/items/qquickshadereffectsource_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquicksprite.cpp b/src/quick/items/qquicksprite.cpp
index 2a1bd08d59..e0535ed77e 100644
--- a/src/quick/items/qquicksprite.cpp
+++ b/src/quick/items/qquicksprite.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qquicksprite_p.h"
-#include <qdeclarative.h>
+#include <qqml.h>
#include <QDebug>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h
index dd6560f5ab..85e3ed8b16 100644
--- a/src/quick/items/qquicksprite_p.h
+++ b/src/quick/items/qquicksprite_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,8 +45,8 @@
#include <QObject>
#include <QUrl>
#include <QVariantMap>
-#include <QDeclarativeListProperty>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <QQmlListProperty>
+#include <QtQuick/private/qquickpixmapcache_p.h>
#include "qquickspriteengine_p.h"
#include <QDebug>
@@ -312,7 +312,7 @@ private:
int m_frameDuration;
int m_frameDurationVariation;
bool m_frameSync;
- QDeclarativePixmap m_pix;
+ QQuickPixmap m_pix;
};
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index c19a5e65c9..1c35688c29 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -41,8 +41,8 @@
#include "qquickspriteengine_p.h"
#include "qquicksprite_p.h"
-#include <qdeclarativeinfo.h>
-#include <qdeclarative.h>
+#include <qqmlinfo.h>
+#include <qqml.h>
#include <QDebug>
#include <QPainter>
#include <QSet>
@@ -307,27 +307,27 @@ void QQuickStochasticEngine::setGoal(int state, int sprite, bool jump)
return;
}
-QDeclarativePixmap::Status QQuickSpriteEngine::status()//Composed status of all Sprites
+QQuickPixmap::Status QQuickSpriteEngine::status()//Composed status of all Sprites
{
if (!m_startedImageAssembly)
- return QDeclarativePixmap::Null;
+ return QQuickPixmap::Null;
int null, loading, ready;
null = loading = ready = 0;
foreach (QQuickSprite* s, m_sprites) {
switch (s->m_pix.status()) {
- case QDeclarativePixmap::Null : null++; break;
- case QDeclarativePixmap::Loading : loading++; break;
- case QDeclarativePixmap::Error : return QDeclarativePixmap::Error;
- case QDeclarativePixmap::Ready : ready++; break;
+ case QQuickPixmap::Null : null++; break;
+ case QQuickPixmap::Loading : loading++; break;
+ case QQuickPixmap::Error : return QQuickPixmap::Error;
+ case QQuickPixmap::Ready : ready++; break;
}
}
if (null)
- return QDeclarativePixmap::Null;
+ return QQuickPixmap::Null;
if (loading)
- return QDeclarativePixmap::Loading;
+ return QQuickPixmap::Loading;
if (ready)
- return QDeclarativePixmap::Ready;
- return QDeclarativePixmap::Null;
+ return QQuickPixmap::Ready;
+ return QQuickPixmap::Null;
}
void QQuickSpriteEngine::startAssemblingImage()
@@ -348,13 +348,13 @@ void QQuickSpriteEngine::startAssemblingImage()
QImage QQuickSpriteEngine::assembledImage()
{
- QDeclarativePixmap::Status stat = status();
- if (stat == QDeclarativePixmap::Error)
+ QQuickPixmap::Status stat = status();
+ if (stat == QQuickPixmap::Error)
foreach (QQuickSprite* s, m_sprites)
if (s->m_pix.isError())
qmlInfo(s) << s->m_pix.error();
- if (stat != QDeclarativePixmap::Ready)
+ if (stat != QQuickPixmap::Ready)
return QImage();
int h = 0;
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index 500d526da5..3763509462 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -47,10 +47,10 @@
#include <QTimer>
#include <QTime>
#include <QList>
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
#include <QImage>
#include <QPair>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
QT_BEGIN_HEADER
@@ -178,15 +178,15 @@ class Q_AUTOTEST_EXPORT QQuickStochasticEngine : public QObject
Q_OBJECT
//TODO: Optimize single state case?
Q_PROPERTY(QString globalGoal READ globalGoal WRITE setGlobalGoal NOTIFY globalGoalChanged)
- Q_PROPERTY(QDeclarativeListProperty<QQuickStochasticState> states READ states)
+ Q_PROPERTY(QQmlListProperty<QQuickStochasticState> states READ states)
public:
explicit QQuickStochasticEngine(QObject *parent = 0);
QQuickStochasticEngine(QList<QQuickStochasticState*> states, QObject *parent=0);
~QQuickStochasticEngine();
- QDeclarativeListProperty<QQuickStochasticState> states()
+ QQmlListProperty<QQuickStochasticState> states()
{
- return QDeclarativeListProperty<QQuickStochasticState>(this, m_states);
+ return QQmlListProperty<QQuickStochasticState>(this, m_states);
}
QString globalGoal() const
@@ -255,14 +255,14 @@ protected:
class QQuickSpriteEngine : public QQuickStochasticEngine
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QQuickSprite> sprites READ sprites)
+ Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites)
public:
explicit QQuickSpriteEngine(QObject *parent = 0);
QQuickSpriteEngine(QList<QQuickSprite*> sprites, QObject *parent=0);
~QQuickSpriteEngine();
- QDeclarativeListProperty<QQuickSprite> sprites()
+ QQmlListProperty<QQuickSprite> sprites()
{
- return QDeclarativeListProperty<QQuickSprite>(this, m_sprites);
+ return QQmlListProperty<QQuickSprite>(this, m_sprites);
}
QQuickSprite* sprite(int sprite=0);
@@ -280,12 +280,12 @@ public:
virtual void restart(int index=0);
virtual void advance(int index=0);
- //Similar API to QDeclarativePixmap for async loading convenience
- bool isNull() { return status() == QDeclarativePixmap::Null; }
- bool isReady() { return status() == QDeclarativePixmap::Ready; }
- bool isLoading() { return status() == QDeclarativePixmap::Loading; }
- bool isError() { return status() == QDeclarativePixmap::Error; }
- QDeclarativePixmap::Status status();//Composed status of all Sprites
+ //Similar API to QQuickPixmap for async loading convenience
+ bool isNull() { return status() == QQuickPixmap::Null; }
+ bool isReady() { return status() == QQuickPixmap::Ready; }
+ bool isLoading() { return status() == QQuickPixmap::Loading; }
+ bool isError() { return status() == QQuickPixmap::Error; }
+ QQuickPixmap::Status status();//Composed status of all Sprites
void startAssemblingImage();
QImage assembledImage();
@@ -296,24 +296,24 @@ private:
};
//Common use is to have your own list property which is transparently an engine
-inline void spriteAppend(QDeclarativeListProperty<QQuickSprite> *p, QQuickSprite* s)
+inline void spriteAppend(QQmlListProperty<QQuickSprite> *p, QQuickSprite* s)
{
reinterpret_cast<QList<QQuickSprite *> *>(p->data)->append(s);
p->object->metaObject()->invokeMethod(p->object, "createEngine");
}
-inline QQuickSprite* spriteAt(QDeclarativeListProperty<QQuickSprite> *p, int idx)
+inline QQuickSprite* spriteAt(QQmlListProperty<QQuickSprite> *p, int idx)
{
return reinterpret_cast<QList<QQuickSprite *> *>(p->data)->at(idx);
}
-inline void spriteClear(QDeclarativeListProperty<QQuickSprite> *p)
+inline void spriteClear(QQmlListProperty<QQuickSprite> *p)
{
reinterpret_cast<QList<QQuickSprite *> *>(p->data)->clear();
p->object->metaObject()->invokeMethod(p->object, "createEngine");
}
-inline int spriteCount(QDeclarativeListProperty<QQuickSprite> *p)
+inline int spriteCount(QQmlListProperty<QQuickSprite> *p)
{
return reinterpret_cast<QList<QQuickSprite *> *>(p->data)->count();
}
diff --git a/src/quick/items/qquickspriteimage.cpp b/src/quick/items/qquickspriteimage.cpp
new file mode 100644
index 0000000000..6edb3ad8c3
--- /dev/null
+++ b/src/quick/items/qquickspriteimage.cpp
@@ -0,0 +1,482 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickspriteimage_p.h"
+#include "qquicksprite_p.h"
+#include "qquickspriteengine_p.h"
+#include <QtQuick/private/qsgcontext_p.h>
+#include <private/qsgadaptationlayer_p.h>
+#include <QtQuick/qsgnode.h>
+#include <QtQuick/qsgengine.h>
+#include <QtQuick/qsgtexturematerial.h>
+#include <QtQuick/qsgtexture.h>
+#include <QtQuick/qquickcanvas.h>
+#include <QtQml/qqmlinfo.h>
+#include <QFile>
+#include <cmath>
+#include <qmath.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+static const char vertexShaderCode[] =
+ "attribute highp vec2 vTex;\n"
+ "uniform highp vec3 animData;// w,h(premultiplied of anim), interpolation progress\n"
+ "uniform highp vec4 animPos;//x,y, x,y (two frames for interpolation)\n"
+ "uniform highp vec2 size;//w,h of element\n"
+ "\n"
+ "uniform highp mat4 qt_Matrix;\n"
+ "\n"
+ "varying highp vec4 fTexS;\n"
+ "varying lowp float progress;\n"
+ "\n"
+ "\n"
+ "void main() {\n"
+ " progress = animData.z;\n"
+ " //Calculate frame location in texture\n"
+ " fTexS.xy = animPos.xy + vTex.xy * animData.xy;\n"
+ " //Next frame is also passed, for interpolation\n"
+ " fTexS.zw = animPos.zw + vTex.xy * animData.xy;\n"
+ "\n"
+ " gl_Position = qt_Matrix * vec4(size.x * vTex.x, size.y * vTex.y, 0, 1);\n"
+ "}\n";
+
+static const char fragmentShaderCode[] =
+ "uniform sampler2D texture;\n"
+ "uniform lowp float qt_Opacity;\n"
+ "\n"
+ "varying highp vec4 fTexS;\n"
+ "varying lowp float progress;\n"
+ "\n"
+ "void main() {\n"
+ " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n"
+ "}\n";
+
+class QQuickSpriteImageMaterial : public QSGMaterial
+{
+public:
+ QQuickSpriteImageMaterial();
+ ~QQuickSpriteImageMaterial();
+ virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; }
+ virtual QSGMaterialShader *createShader() const;
+ virtual int compare(const QSGMaterial *other) const
+ {
+ return this - static_cast<const QQuickSpriteImageMaterial *>(other);
+ }
+
+ QSGTexture *texture;
+
+ float animT;
+ float animX1;
+ float animY1;
+ float animX2;
+ float animY2;
+ float animW;
+ float animH;
+ float elementWidth;
+ float elementHeight;
+};
+
+QQuickSpriteImageMaterial::QQuickSpriteImageMaterial()
+ : animT(0.0f)
+ , animX1(0.0f)
+ , animY1(0.0f)
+ , animX2(0.0f)
+ , animY2(0.0f)
+ , animW(1.0f)
+ , animH(1.0f)
+ , elementWidth(1.0f)
+ , elementHeight(1.0f)
+{
+ setFlag(Blending, true);
+}
+
+QQuickSpriteImageMaterial::~QQuickSpriteImageMaterial()
+{
+ delete texture;
+}
+
+class SpriteImageMaterialData : public QSGMaterialShader
+{
+public:
+ SpriteImageMaterialData(const char * /* vertexFile */ = 0, const char * /* fragmentFile */ = 0)
+ {
+ }
+
+ void deactivate() {
+ QSGMaterialShader::deactivate();
+
+ for (int i=0; i<8; ++i) {
+ program()->setAttributeArray(i, GL_FLOAT, chunkOfBytes, 1, 0);
+ }
+ }
+
+ virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *)
+ {
+ QQuickSpriteImageMaterial *m = static_cast<QQuickSpriteImageMaterial *>(newEffect);
+ m->texture->bind();
+
+ program()->setUniformValue(m_opacity_id, state.opacity());
+ program()->setUniformValue(m_animData_id, m->animW, m->animH, m->animT);
+ program()->setUniformValue(m_animPos_id, m->animX1, m->animY1, m->animX2, m->animY2);
+ program()->setUniformValue(m_size_id, m->elementWidth, m->elementHeight);
+
+ if (state.isMatrixDirty())
+ program()->setUniformValue(m_matrix_id, state.combinedMatrix());
+ }
+
+ virtual void initialize() {
+ m_matrix_id = program()->uniformLocation("qt_Matrix");
+ m_opacity_id = program()->uniformLocation("qt_Opacity");
+ m_animData_id = program()->uniformLocation("animData");
+ m_animPos_id = program()->uniformLocation("animPos");
+ m_size_id = program()->uniformLocation("size");
+ }
+
+ virtual const char *vertexShader() const { return vertexShaderCode; }
+ virtual const char *fragmentShader() const { return fragmentShaderCode; }
+
+ virtual char const *const *attributeNames() const {
+ static const char *attr[] = {
+ "vTex",
+ 0
+ };
+ return attr;
+ }
+
+ int m_matrix_id;
+ int m_opacity_id;
+ int m_animData_id;
+ int m_animPos_id;
+ int m_size_id;
+
+ static float chunkOfBytes[1024];
+};
+
+float SpriteImageMaterialData::chunkOfBytes[1024];
+
+QSGMaterialShader *QQuickSpriteImageMaterial::createShader() const
+{
+ return new SpriteImageMaterialData;
+}
+
+struct SpriteVertex {
+ float tx;
+ float ty;
+};
+
+struct SpriteVertices {
+ SpriteVertex v1;
+ SpriteVertex v2;
+ SpriteVertex v3;
+ SpriteVertex v4;
+};
+
+/*!
+ \qmlclass SpriteImage QQuickSpriteImage
+ \inqmlmodule QtQuick 2
+ \inherits Item
+ \brief The SpriteImage element draws a sprite animation
+
+*/
+/*!
+ \qmlproperty bool QtQuick2::SpriteImage::running
+
+ Whether the sprite is animating or not.
+
+ Default is true
+*/
+/*!
+ \qmlproperty bool QtQuick2::SpriteImage::interpolate
+
+ If true, interpolation will occur between sprite frames to make the
+ animation appear smoother.
+
+ Default is true.
+*/
+/*!
+ \qmlproperty string QtQuick2::SpriteImage::goalSprite
+
+ The name of the Sprite which is currently animating.
+*/
+/*!
+ \qmlproperty string QtQuick2::SpriteImage::goalSprite
+
+ The name of the Sprite which the animation should move to.
+
+ Sprite states have defined durations and transitions between them, setting goalState
+ will cause it to disregard any path weightings (including 0) and head down the path
+ which will reach the goalState quickest (fewest animations). It will pass through
+ intermediate states on that path, and animate them for their duration.
+
+ If it is possible to return to the goalState from the starting point of the goalState
+ it will continue to do so until goalState is set to "" or an unreachable state.
+*/
+/*! \qmlmethod void QtQuick2::SpriteImage::jumpTo(string sprite)
+
+ This function causes the sprite to jump to the specified state immediately, intermediate
+ states are not played.
+*/
+/*!
+ \qmlproperty list<Sprite> QtQuick2::SpriteImage::sprites
+
+ The sprite or sprites to draw. Sprites will be scaled to the size of this element.
+*/
+
+//TODO: Implicitly size element to size of first sprite?
+QQuickSpriteImage::QQuickSpriteImage(QQuickItem *parent) :
+ QQuickItem(parent)
+ , m_node(0)
+ , m_material(0)
+ , m_spriteEngine(0)
+ , m_curFrame(0)
+ , m_pleaseReset(false)
+ , m_running(true)
+ , m_interpolate(true)
+ , m_curStateIdx(0)
+{
+ setFlag(ItemHasContents);
+ connect(this, SIGNAL(runningChanged(bool)),
+ this, SLOT(update()));
+}
+
+void QQuickSpriteImage::jumpTo(const QString &sprite)
+{
+ if (!m_spriteEngine)
+ return;
+ m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite), 0, true);
+}
+
+void QQuickSpriteImage::setGoalSprite(const QString &sprite)
+{
+ if (m_goalState != sprite){
+ m_goalState = sprite;
+ emit goalSpriteChanged(sprite);
+ m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite));
+ }
+}
+
+QQmlListProperty<QQuickSprite> QQuickSpriteImage::sprites()
+{
+ return QQmlListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);
+}
+
+void QQuickSpriteImage::createEngine()
+{
+ //TODO: delay until component complete
+ if (m_spriteEngine)
+ delete m_spriteEngine;
+ if (m_sprites.count())
+ m_spriteEngine = new QQuickSpriteEngine(m_sprites, this);
+ else
+ m_spriteEngine = 0;
+ reset();
+}
+
+static QSGGeometry::Attribute SpriteImage_Attributes[] = {
+ QSGGeometry::Attribute::create(0, 2, GL_FLOAT), // tex
+};
+
+static QSGGeometry::AttributeSet SpriteImage_AttributeSet =
+{
+ 1, // Attribute Count
+ 2 * sizeof(float),
+ SpriteImage_Attributes
+};
+
+QSGGeometryNode* QQuickSpriteImage::buildNode()
+{
+ if (!m_spriteEngine) {
+ qmlInfo(this) << "No sprite engine...";
+ return 0;
+ } else if (m_spriteEngine->status() == QQuickPixmap::Null) {
+ m_spriteEngine->startAssemblingImage();
+ update();//Schedule another update, where we will check again
+ return 0;
+ } else if (m_spriteEngine->status() == QQuickPixmap::Loading) {
+ update();//Schedule another update, where we will check again
+ return 0;
+ }
+
+ m_material = new QQuickSpriteImageMaterial();
+
+ QImage image = m_spriteEngine->assembledImage();
+ if (image.isNull())
+ return 0;
+ m_sheetSize = QSizeF(image.size());
+ m_material->texture = canvas()->createTextureFromImage(image);
+ m_material->texture->setFiltering(QSGTexture::Linear);
+ m_spriteEngine->start(0);
+ m_material->animT = 0;
+ m_material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width();
+ m_material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height();
+ m_material->animX2 = m_material->animX1;
+ m_material->animY2 = m_material->animY1;
+ m_material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width();
+ m_material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height();
+ m_material->elementWidth = width();
+ m_material->elementHeight = height();
+ m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name();
+ emit currentSpriteChanged(m_curState);
+
+ int vCount = 4;
+ int iCount = 6;
+ QSGGeometry *g = new QSGGeometry(SpriteImage_AttributeSet, vCount, iCount);
+ g->setDrawingMode(GL_TRIANGLES);
+
+ SpriteVertices *p = (SpriteVertices *) g->vertexData();
+
+ p->v1.tx = 0;
+ p->v1.ty = 0;
+
+ p->v2.tx = 1.0;
+ p->v2.ty = 0;
+
+ p->v3.tx = 0;
+ p->v3.ty = 1.0;
+
+ p->v4.tx = 1.0;
+ p->v4.ty = 1.0;
+
+ quint16 *indices = g->indexDataAsUShort();
+ indices[0] = 0;
+ indices[1] = 1;
+ indices[2] = 2;
+ indices[3] = 1;
+ indices[4] = 3;
+ indices[5] = 2;
+
+
+ m_timestamp.start();
+ m_node = new QSGGeometryNode();
+ m_node->setGeometry(g);
+ m_node->setMaterial(m_material);
+ m_node->setFlag(QSGGeometryNode::OwnsMaterial);
+ return m_node;
+}
+
+void QQuickSpriteImage::reset()
+{
+ m_pleaseReset = true;
+}
+
+QSGNode *QQuickSpriteImage::updatePaintNode(QSGNode *, UpdatePaintNodeData *)
+{
+ if (m_pleaseReset) {
+ delete m_node;
+
+ m_node = 0;
+ m_material = 0;
+ m_pleaseReset = false;
+ }
+
+ prepareNextFrame();
+
+ if (m_running) {
+ update();
+ if (m_node)
+ m_node->markDirty(QSGNode::DirtyMaterial);
+ }
+
+ return m_node;
+}
+
+void QQuickSpriteImage::prepareNextFrame()
+{
+ if (m_node == 0)
+ m_node = buildNode();
+ if (m_node == 0) //error creating node
+ return;
+
+ uint timeInt = m_timestamp.elapsed();
+ qreal time = timeInt / 1000.;
+ m_material->elementHeight = height();
+ m_material->elementWidth = width();
+
+ //Advance State
+ m_spriteEngine->updateSprites(timeInt);
+ if (m_curStateIdx != m_spriteEngine->curState()) {
+ m_curStateIdx = m_spriteEngine->curState();
+ m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name();
+ emit currentSpriteChanged(m_curState);
+ m_curFrame= -1;
+ }
+
+ //Advance Sprite
+ qreal animT = m_spriteEngine->spriteStart()/1000.0;
+ qreal frameCount = m_spriteEngine->spriteFrames();
+ qreal frameDuration = m_spriteEngine->spriteDuration()/frameCount;
+ double frameAt;
+ qreal progress;
+ if (frameDuration > 0) {
+ qreal frame = (time - animT)/(frameDuration / 1000.0);
+ frame = qBound(qreal(0.0), frame, frameCount - qreal(1.0));//Stop at count-1 frames until we have between anim interpolation
+ progress = modf(frame,&frameAt);
+ } else {
+ m_curFrame++;
+ if (m_curFrame >= frameCount){
+ m_curFrame = 0;
+ m_spriteEngine->advance();
+ }
+ frameAt = m_curFrame;
+ progress = 0;
+ }
+ if (m_spriteEngine->sprite()->reverse())
+ frameAt = (m_spriteEngine->spriteFrames() - 1) - frameAt;
+ qreal y = m_spriteEngine->spriteY() / m_sheetSize.height();
+ qreal w = m_spriteEngine->spriteWidth() / m_sheetSize.width();
+ qreal h = m_spriteEngine->spriteHeight() / m_sheetSize.height();
+ qreal x1 = m_spriteEngine->spriteX() / m_sheetSize.width();
+ x1 += frameAt * w;
+ qreal x2 = x1;
+ if (frameAt < (frameCount-1))
+ x2 += w;
+
+ m_material->animX1 = x1;
+ m_material->animY1 = y;
+ m_material->animX2 = x2;
+ m_material->animY2 = y;
+ m_material->animW = w;
+ m_material->animH = h;
+ m_material->animT = m_interpolate ? progress : 0.0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/items/qquickspriteimage_p.h b/src/quick/items/qquickspriteimage_p.h
new file mode 100644
index 0000000000..1574afcb75
--- /dev/null
+++ b/src/quick/items/qquickspriteimage_p.h
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSPRITEIMAGE_P_H
+#define QQUICKSPRITEIMAGE_P_H
+
+#include <QtQuick/QQuickItem>
+#include <QTime>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QSGContext;
+class QQuickSprite;
+class QQuickSpriteEngine;
+class QSGGeometryNode;
+class QQuickSpriteImageMaterial;
+class Q_AUTOTEST_EXPORT QQuickSpriteImage : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged)
+ Q_PROPERTY(QString goalSprite READ goalSprite WRITE setGoalSprite NOTIFY goalSpriteChanged)
+ Q_PROPERTY(QString currentSprite READ currentSprite NOTIFY currentSpriteChanged)
+ //###try to share similar spriteEngines for less overhead?
+ Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites)
+ Q_CLASSINFO("DefaultProperty", "sprites")
+
+public:
+ explicit QQuickSpriteImage(QQuickItem *parent = 0);
+
+ QQmlListProperty<QQuickSprite> sprites();
+
+ bool running() const
+ {
+ return m_running;
+ }
+
+ bool interpolate() const
+ {
+ return m_interpolate;
+ }
+
+ QString goalSprite() const
+ {
+ return m_goalState;
+ }
+
+ QString currentSprite() const
+ {
+ return m_curState;
+ }
+
+signals:
+
+ void runningChanged(bool arg);
+ void interpolateChanged(bool arg);
+ void goalSpriteChanged(QString arg);
+ void currentSpriteChanged(QString arg);
+
+public slots:
+
+ void jumpTo(const QString &sprite);
+ void setGoalSprite(const QString &sprite);
+
+ void setRunning(bool arg)
+ {
+ if (m_running != arg) {
+ m_running = arg;
+ emit runningChanged(arg);
+ }
+ }
+
+ void setInterpolate(bool arg)
+ {
+ if (m_interpolate != arg) {
+ m_interpolate = arg;
+ emit interpolateChanged(arg);
+ }
+ }
+
+private slots:
+ void createEngine();
+protected:
+ void reset();
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+private:
+ void prepareNextFrame();
+ QSGGeometryNode* buildNode();
+ QSGGeometryNode *m_node;
+ QQuickSpriteImageMaterial *m_material;
+ QList<QQuickSprite*> m_sprites;
+ QQuickSpriteEngine* m_spriteEngine;
+ QTime m_timestamp;
+ int m_curFrame;
+ bool m_pleaseReset;
+ bool m_running;
+ bool m_interpolate;
+ QString m_goalState;
+ QString m_curState;
+ int m_curStateIdx;
+ QSizeF m_sheetSize;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQUICKSPRITEIMAGE_P_H
diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp
index a3a8a6ee8c..ce0a246748 100644
--- a/src/quick/items/qquickspritesequence.cpp
+++ b/src/quick/items/qquickspritesequence.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -49,7 +49,7 @@
#include <QtQuick/qsgtexturematerial.h>
#include <QtQuick/qsgtexture.h>
#include <QtQuick/qquickcanvas.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QFile>
#include <cmath>
#include <qmath.h>
@@ -294,9 +294,9 @@ void QQuickSpriteSequence::setGoalSprite(const QString &sprite)
}
}
-QDeclarativeListProperty<QQuickSprite> QQuickSpriteSequence::sprites()
+QQmlListProperty<QQuickSprite> QQuickSpriteSequence::sprites()
{
- return QDeclarativeListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);
+ return QQmlListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);
}
void QQuickSpriteSequence::createEngine()
@@ -327,11 +327,11 @@ QSGGeometryNode* QQuickSpriteSequence::buildNode()
if (!m_spriteEngine) {
qmlInfo(this) << "No sprite engine...";
return 0;
- } else if (m_spriteEngine->status() == QDeclarativePixmap::Null) {
+ } else if (m_spriteEngine->status() == QQuickPixmap::Null) {
m_spriteEngine->startAssemblingImage();
update();//Schedule another update, where we will check again
return 0;
- } else if (m_spriteEngine->status() == QDeclarativePixmap::Loading) {
+ } else if (m_spriteEngine->status() == QQuickPixmap::Loading) {
update();//Schedule another update, where we will check again
return 0;
}
diff --git a/src/quick/items/qquickspritesequence_p.h b/src/quick/items/qquickspritesequence_p.h
index 8a95594f61..a2f9e4139a 100644
--- a/src/quick/items/qquickspritesequence_p.h
+++ b/src/quick/items/qquickspritesequence_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -62,13 +62,13 @@ class Q_AUTOTEST_EXPORT QQuickSpriteSequence : public QQuickItem
Q_PROPERTY(QString goalSprite READ goalSprite WRITE setGoalSprite NOTIFY goalSpriteChanged)
Q_PROPERTY(QString currentSprite READ currentSprite NOTIFY currentSpriteChanged)
//###try to share similar spriteEngines for less overhead?
- Q_PROPERTY(QDeclarativeListProperty<QQuickSprite> sprites READ sprites)
+ Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites)
Q_CLASSINFO("DefaultProperty", "sprites")
public:
explicit QQuickSpriteSequence(QQuickItem *parent = 0);
- QDeclarativeListProperty<QQuickSprite> sprites();
+ QQmlListProperty<QQuickSprite> sprites();
bool running() const
{
diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp
index ca2a94716a..668c7c07d7 100644
--- a/src/quick/items/qquickstateoperations.cpp
+++ b/src/quick/items/qquickstateoperations.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,14 +42,14 @@
#include "qquickstateoperations_p.h"
#include "qquickitem_p.h"
-#include <private/qdeclarativestate_p_p.h>
+#include <private/qquickstate_p_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
-class QQuickParentChangePrivate : public QDeclarativeStateOperationPrivate
+class QQuickParentChangePrivate : public QQuickStateOperationPrivate
{
Q_DECLARE_PUBLIC(QQuickParentChange)
public:
@@ -57,18 +57,18 @@ public:
rewindParent(0), rewindStackBefore(0) {}
QQuickItem *target;
- QDeclarativeGuard<QQuickItem> parent;
- QDeclarativeGuard<QQuickItem> origParent;
- QDeclarativeGuard<QQuickItem> origStackBefore;
+ QQmlGuard<QQuickItem> parent;
+ QQmlGuard<QQuickItem> origParent;
+ QQmlGuard<QQuickItem> origStackBefore;
QQuickItem *rewindParent;
QQuickItem *rewindStackBefore;
- QDeclarativeNullableValue<QDeclarativeScriptString> xString;
- QDeclarativeNullableValue<QDeclarativeScriptString> yString;
- QDeclarativeNullableValue<QDeclarativeScriptString> widthString;
- QDeclarativeNullableValue<QDeclarativeScriptString> heightString;
- QDeclarativeNullableValue<QDeclarativeScriptString> scaleString;
- QDeclarativeNullableValue<QDeclarativeScriptString> rotationString;
+ QQmlNullableValue<QQmlScriptString> xString;
+ QQmlNullableValue<QQmlScriptString> yString;
+ QQmlNullableValue<QQmlScriptString> widthString;
+ QQmlNullableValue<QQmlScriptString> heightString;
+ QQmlNullableValue<QQmlScriptString> scaleString;
+ QQmlNullableValue<QQmlScriptString> rotationString;
void doChange(QQuickItem *targetParent, QQuickItem *stackBefore = 0);
};
@@ -147,7 +147,7 @@ void QQuickParentChangePrivate::doChange(QQuickItem *targetParent, QQuickItem *s
}
QQuickParentChange::QQuickParentChange(QObject *parent)
- : QDeclarativeStateOperation(*(new QQuickParentChangePrivate), parent)
+ : QQuickStateOperation(*(new QQuickParentChangePrivate), parent)
{
}
@@ -155,13 +155,13 @@ QQuickParentChange::~QQuickParentChange()
{
}
-QDeclarativeScriptString QQuickParentChange::x() const
+QQmlScriptString QQuickParentChange::x() const
{
Q_D(const QQuickParentChange);
return d->xString.value;
}
-void QQuickParentChange::setX(QDeclarativeScriptString x)
+void QQuickParentChange::setX(QQmlScriptString x)
{
Q_D(QQuickParentChange);
d->xString = x;
@@ -173,13 +173,13 @@ bool QQuickParentChange::xIsSet() const
return d->xString.isValid();
}
-QDeclarativeScriptString QQuickParentChange::y() const
+QQmlScriptString QQuickParentChange::y() const
{
Q_D(const QQuickParentChange);
return d->yString.value;
}
-void QQuickParentChange::setY(QDeclarativeScriptString y)
+void QQuickParentChange::setY(QQmlScriptString y)
{
Q_D(QQuickParentChange);
d->yString = y;
@@ -191,13 +191,13 @@ bool QQuickParentChange::yIsSet() const
return d->yString.isValid();
}
-QDeclarativeScriptString QQuickParentChange::width() const
+QQmlScriptString QQuickParentChange::width() const
{
Q_D(const QQuickParentChange);
return d->widthString.value;
}
-void QQuickParentChange::setWidth(QDeclarativeScriptString width)
+void QQuickParentChange::setWidth(QQmlScriptString width)
{
Q_D(QQuickParentChange);
d->widthString = width;
@@ -209,13 +209,13 @@ bool QQuickParentChange::widthIsSet() const
return d->widthString.isValid();
}
-QDeclarativeScriptString QQuickParentChange::height() const
+QQmlScriptString QQuickParentChange::height() const
{
Q_D(const QQuickParentChange);
return d->heightString.value;
}
-void QQuickParentChange::setHeight(QDeclarativeScriptString height)
+void QQuickParentChange::setHeight(QQmlScriptString height)
{
Q_D(QQuickParentChange);
d->heightString = height;
@@ -227,13 +227,13 @@ bool QQuickParentChange::heightIsSet() const
return d->heightString.isValid();
}
-QDeclarativeScriptString QQuickParentChange::scale() const
+QQmlScriptString QQuickParentChange::scale() const
{
Q_D(const QQuickParentChange);
return d->scaleString.value;
}
-void QQuickParentChange::setScale(QDeclarativeScriptString scale)
+void QQuickParentChange::setScale(QQmlScriptString scale)
{
Q_D(QQuickParentChange);
d->scaleString = scale;
@@ -245,13 +245,13 @@ bool QQuickParentChange::scaleIsSet() const
return d->scaleString.isValid();
}
-QDeclarativeScriptString QQuickParentChange::rotation() const
+QQmlScriptString QQuickParentChange::rotation() const
{
Q_D(const QQuickParentChange);
return d->rotationString.value;
}
-void QQuickParentChange::setRotation(QDeclarativeScriptString rotation)
+void QQuickParentChange::setRotation(QQmlScriptString rotation)
{
Q_D(QQuickParentChange);
d->rotationString = rotation;
@@ -293,7 +293,7 @@ void QQuickParentChange::setParent(QQuickItem *parent)
d->parent = parent;
}
-QDeclarativeStateOperation::ActionList QQuickParentChange::actions()
+QQuickStateOperation::ActionList QQuickParentChange::actions()
{
Q_D(QQuickParentChange);
if (!d->target || !d->parent)
@@ -301,7 +301,7 @@ QDeclarativeStateOperation::ActionList QQuickParentChange::actions()
ActionList actions;
- QDeclarativeAction a;
+ QQuickAction a;
a.event = this;
actions << a;
@@ -310,13 +310,13 @@ QDeclarativeStateOperation::ActionList QQuickParentChange::actions()
QString script = d->xString.value.script();
qreal x = script.toFloat(&ok);
if (ok) {
- QDeclarativeAction xa(d->target, QLatin1String("x"), x);
+ QQuickAction xa(d->target, QLatin1String("x"), x);
actions << xa;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- QDeclarativeProperty property(d->target, QLatin1String("x"));
+ QQmlBinding *newBinding = new QQmlBinding(script, d->target, qmlContext(this));
+ QQmlProperty property(d->target, QLatin1String("x"));
newBinding->setTarget(property);
- QDeclarativeAction xa;
+ QQuickAction xa;
xa.property = property;
xa.toBinding = newBinding;
xa.fromValue = xa.property.read();
@@ -330,13 +330,13 @@ QDeclarativeStateOperation::ActionList QQuickParentChange::actions()
QString script = d->yString.value.script();
qreal y = script.toFloat(&ok);
if (ok) {
- QDeclarativeAction ya(d->target, QLatin1String("y"), y);
+ QQuickAction ya(d->target, QLatin1String("y"), y);
actions << ya;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- QDeclarativeProperty property(d->target, QLatin1String("y"));
+ QQmlBinding *newBinding = new QQmlBinding(script, d->target, qmlContext(this));
+ QQmlProperty property(d->target, QLatin1String("y"));
newBinding->setTarget(property);
- QDeclarativeAction ya;
+ QQuickAction ya;
ya.property = property;
ya.toBinding = newBinding;
ya.fromValue = ya.property.read();
@@ -350,13 +350,13 @@ QDeclarativeStateOperation::ActionList QQuickParentChange::actions()
QString script = d->scaleString.value.script();
qreal scale = script.toFloat(&ok);
if (ok) {
- QDeclarativeAction sa(d->target, QLatin1String("scale"), scale);
+ QQuickAction sa(d->target, QLatin1String("scale"), scale);
actions << sa;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- QDeclarativeProperty property(d->target, QLatin1String("scale"));
+ QQmlBinding *newBinding = new QQmlBinding(script, d->target, qmlContext(this));
+ QQmlProperty property(d->target, QLatin1String("scale"));
newBinding->setTarget(property);
- QDeclarativeAction sa;
+ QQuickAction sa;
sa.property = property;
sa.toBinding = newBinding;
sa.fromValue = sa.property.read();
@@ -370,13 +370,13 @@ QDeclarativeStateOperation::ActionList QQuickParentChange::actions()
QString script = d->rotationString.value.script();
qreal rotation = script.toFloat(&ok);
if (ok) {
- QDeclarativeAction ra(d->target, QLatin1String("rotation"), rotation);
+ QQuickAction ra(d->target, QLatin1String("rotation"), rotation);
actions << ra;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- QDeclarativeProperty property(d->target, QLatin1String("rotation"));
+ QQmlBinding *newBinding = new QQmlBinding(script, d->target, qmlContext(this));
+ QQmlProperty property(d->target, QLatin1String("rotation"));
newBinding->setTarget(property);
- QDeclarativeAction ra;
+ QQuickAction ra;
ra.property = property;
ra.toBinding = newBinding;
ra.fromValue = ra.property.read();
@@ -390,13 +390,13 @@ QDeclarativeStateOperation::ActionList QQuickParentChange::actions()
QString script = d->widthString.value.script();
qreal width = script.toFloat(&ok);
if (ok) {
- QDeclarativeAction wa(d->target, QLatin1String("width"), width);
+ QQuickAction wa(d->target, QLatin1String("width"), width);
actions << wa;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- QDeclarativeProperty property(d->target, QLatin1String("width"));
+ QQmlBinding *newBinding = new QQmlBinding(script, d->target, qmlContext(this));
+ QQmlProperty property(d->target, QLatin1String("width"));
newBinding->setTarget(property);
- QDeclarativeAction wa;
+ QQuickAction wa;
wa.property = property;
wa.toBinding = newBinding;
wa.fromValue = wa.property.read();
@@ -410,13 +410,13 @@ QDeclarativeStateOperation::ActionList QQuickParentChange::actions()
QString script = d->heightString.value.script();
qreal height = script.toFloat(&ok);
if (ok) {
- QDeclarativeAction ha(d->target, QLatin1String("height"), height);
+ QQuickAction ha(d->target, QLatin1String("height"), height);
actions << ha;
} else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
- QDeclarativeProperty property(d->target, QLatin1String("height"));
+ QQmlBinding *newBinding = new QQmlBinding(script, d->target, qmlContext(this));
+ QQmlProperty property(d->target, QLatin1String("height"));
newBinding->setTarget(property);
- QDeclarativeAction ha;
+ QQuickAction ha;
ha.property = property;
ha.toBinding = newBinding;
ha.fromValue = ha.property.read();
@@ -436,7 +436,7 @@ void QQuickParentChange::saveOriginals()
d->origStackBefore = d->rewindStackBefore;
}
-/*void QQuickParentChange::copyOriginals(QDeclarativeActionEvent *other)
+/*void QQuickParentChange::copyOriginals(QQuickActionEvent *other)
{
Q_D(QQuickParentChange);
QQuickParentChange *pc = static_cast<QQuickParentChange*>(other);
@@ -464,12 +464,12 @@ void QQuickParentChange::reverse(Reason)
d->doChange(d->origParent, d->origStackBefore);
}
-QDeclarativeActionEvent::EventType QQuickParentChange::type() const
+QQuickActionEvent::EventType QQuickParentChange::type() const
{
return ParentChange;
}
-bool QQuickParentChange::override(QDeclarativeActionEvent*other)
+bool QQuickParentChange::override(QQuickActionEvent*other)
{
Q_D(QQuickParentChange);
if (other->type() != ParentChange)
@@ -526,13 +526,13 @@ public:
QQuickItem *fill;
QQuickItem *centerIn;
- QDeclarativeScriptString leftScript;
- QDeclarativeScriptString rightScript;
- QDeclarativeScriptString topScript;
- QDeclarativeScriptString bottomScript;
- QDeclarativeScriptString hCenterScript;
- QDeclarativeScriptString vCenterScript;
- QDeclarativeScriptString baselineScript;
+ QQmlScriptString leftScript;
+ QQmlScriptString rightScript;
+ QQmlScriptString topScript;
+ QQmlScriptString bottomScript;
+ QQmlScriptString hCenterScript;
+ QQmlScriptString vCenterScript;
+ QQmlScriptString baselineScript;
/*qreal leftMargin;
qreal rightMargin;
@@ -553,13 +553,13 @@ QQuickAnchorSet::~QQuickAnchorSet()
{
}
-QDeclarativeScriptString QQuickAnchorSet::top() const
+QQmlScriptString QQuickAnchorSet::top() const
{
Q_D(const QQuickAnchorSet);
return d->topScript;
}
-void QQuickAnchorSet::setTop(const QDeclarativeScriptString &edge)
+void QQuickAnchorSet::setTop(const QQmlScriptString &edge)
{
Q_D(QQuickAnchorSet);
d->usedAnchors |= QQuickAnchors::TopAnchor;
@@ -575,13 +575,13 @@ void QQuickAnchorSet::resetTop()
d->resetAnchors |= QQuickAnchors::TopAnchor;
}
-QDeclarativeScriptString QQuickAnchorSet::bottom() const
+QQmlScriptString QQuickAnchorSet::bottom() const
{
Q_D(const QQuickAnchorSet);
return d->bottomScript;
}
-void QQuickAnchorSet::setBottom(const QDeclarativeScriptString &edge)
+void QQuickAnchorSet::setBottom(const QQmlScriptString &edge)
{
Q_D(QQuickAnchorSet);
d->usedAnchors |= QQuickAnchors::BottomAnchor;
@@ -597,13 +597,13 @@ void QQuickAnchorSet::resetBottom()
d->resetAnchors |= QQuickAnchors::BottomAnchor;
}
-QDeclarativeScriptString QQuickAnchorSet::verticalCenter() const
+QQmlScriptString QQuickAnchorSet::verticalCenter() const
{
Q_D(const QQuickAnchorSet);
return d->vCenterScript;
}
-void QQuickAnchorSet::setVerticalCenter(const QDeclarativeScriptString &edge)
+void QQuickAnchorSet::setVerticalCenter(const QQmlScriptString &edge)
{
Q_D(QQuickAnchorSet);
d->usedAnchors |= QQuickAnchors::VCenterAnchor;
@@ -619,13 +619,13 @@ void QQuickAnchorSet::resetVerticalCenter()
d->resetAnchors |= QQuickAnchors::VCenterAnchor;
}
-QDeclarativeScriptString QQuickAnchorSet::baseline() const
+QQmlScriptString QQuickAnchorSet::baseline() const
{
Q_D(const QQuickAnchorSet);
return d->baselineScript;
}
-void QQuickAnchorSet::setBaseline(const QDeclarativeScriptString &edge)
+void QQuickAnchorSet::setBaseline(const QQmlScriptString &edge)
{
Q_D(QQuickAnchorSet);
d->usedAnchors |= QQuickAnchors::BaselineAnchor;
@@ -641,13 +641,13 @@ void QQuickAnchorSet::resetBaseline()
d->resetAnchors |= QQuickAnchors::BaselineAnchor;
}
-QDeclarativeScriptString QQuickAnchorSet::left() const
+QQmlScriptString QQuickAnchorSet::left() const
{
Q_D(const QQuickAnchorSet);
return d->leftScript;
}
-void QQuickAnchorSet::setLeft(const QDeclarativeScriptString &edge)
+void QQuickAnchorSet::setLeft(const QQmlScriptString &edge)
{
Q_D(QQuickAnchorSet);
d->usedAnchors |= QQuickAnchors::LeftAnchor;
@@ -663,13 +663,13 @@ void QQuickAnchorSet::resetLeft()
d->resetAnchors |= QQuickAnchors::LeftAnchor;
}
-QDeclarativeScriptString QQuickAnchorSet::right() const
+QQmlScriptString QQuickAnchorSet::right() const
{
Q_D(const QQuickAnchorSet);
return d->rightScript;
}
-void QQuickAnchorSet::setRight(const QDeclarativeScriptString &edge)
+void QQuickAnchorSet::setRight(const QQmlScriptString &edge)
{
Q_D(QQuickAnchorSet);
d->usedAnchors |= QQuickAnchors::RightAnchor;
@@ -685,13 +685,13 @@ void QQuickAnchorSet::resetRight()
d->resetAnchors |= QQuickAnchors::RightAnchor;
}
-QDeclarativeScriptString QQuickAnchorSet::horizontalCenter() const
+QQmlScriptString QQuickAnchorSet::horizontalCenter() const
{
Q_D(const QQuickAnchorSet);
return d->hCenterScript;
}
-void QQuickAnchorSet::setHorizontalCenter(const QDeclarativeScriptString &edge)
+void QQuickAnchorSet::setHorizontalCenter(const QQmlScriptString &edge)
{
Q_D(QQuickAnchorSet);
d->usedAnchors |= QQuickAnchors::HCenterAnchor;
@@ -742,7 +742,7 @@ void QQuickAnchorSet::resetCenterIn()
}
-class QQuickAnchorChangesPrivate : public QDeclarativeStateOperationPrivate
+class QQuickAnchorChangesPrivate : public QQuickStateOperationPrivate
{
public:
QQuickAnchorChangesPrivate()
@@ -760,21 +760,21 @@ public:
QQuickItem *target;
QQuickAnchorSet *anchorSet;
- QDeclarativeBinding *leftBinding;
- QDeclarativeBinding *rightBinding;
- QDeclarativeBinding *hCenterBinding;
- QDeclarativeBinding *topBinding;
- QDeclarativeBinding *bottomBinding;
- QDeclarativeBinding *vCenterBinding;
- QDeclarativeBinding *baselineBinding;
-
- QDeclarativeAbstractBinding *origLeftBinding;
- QDeclarativeAbstractBinding *origRightBinding;
- QDeclarativeAbstractBinding *origHCenterBinding;
- QDeclarativeAbstractBinding *origTopBinding;
- QDeclarativeAbstractBinding *origBottomBinding;
- QDeclarativeAbstractBinding *origVCenterBinding;
- QDeclarativeAbstractBinding *origBaselineBinding;
+ QQmlBinding *leftBinding;
+ QQmlBinding *rightBinding;
+ QQmlBinding *hCenterBinding;
+ QQmlBinding *topBinding;
+ QQmlBinding *bottomBinding;
+ QQmlBinding *vCenterBinding;
+ QQmlBinding *baselineBinding;
+
+ QQmlAbstractBinding *origLeftBinding;
+ QQmlAbstractBinding *origRightBinding;
+ QQmlAbstractBinding *origHCenterBinding;
+ QQmlAbstractBinding *origTopBinding;
+ QQmlAbstractBinding *origBottomBinding;
+ QQmlAbstractBinding *origVCenterBinding;
+ QQmlAbstractBinding *origBaselineBinding;
QQuickAnchorLine rewindLeft;
QQuickAnchorLine rewindRight;
@@ -807,24 +807,24 @@ public:
bool applyOrigVCenter;
bool applyOrigBaseline;
- QDeclarativeNullableValue<qreal> origWidth;
- QDeclarativeNullableValue<qreal> origHeight;
+ QQmlNullableValue<qreal> origWidth;
+ QQmlNullableValue<qreal> origHeight;
qreal origX;
qreal origY;
- QList<QDeclarativeAbstractBinding*> oldBindings;
+ QList<QQmlAbstractBinding*> oldBindings;
- QDeclarativeProperty leftProp;
- QDeclarativeProperty rightProp;
- QDeclarativeProperty hCenterProp;
- QDeclarativeProperty topProp;
- QDeclarativeProperty bottomProp;
- QDeclarativeProperty vCenterProp;
- QDeclarativeProperty baselineProp;
+ QQmlProperty leftProp;
+ QQmlProperty rightProp;
+ QQmlProperty hCenterProp;
+ QQmlProperty topProp;
+ QQmlProperty bottomProp;
+ QQmlProperty vCenterProp;
+ QQmlProperty baselineProp;
};
QQuickAnchorChanges::QQuickAnchorChanges(QObject *parent)
- : QDeclarativeStateOperation(*(new QQuickAnchorChangesPrivate), parent)
+ : QQuickStateOperation(*(new QQuickAnchorChangesPrivate), parent)
{
}
@@ -838,44 +838,44 @@ QQuickAnchorChanges::ActionList QQuickAnchorChanges::actions()
d->leftBinding = d->rightBinding = d->hCenterBinding = d->topBinding
= d->bottomBinding = d->vCenterBinding = d->baselineBinding = 0;
- d->leftProp = QDeclarativeProperty(d->target, QLatin1String("anchors.left"));
- d->rightProp = QDeclarativeProperty(d->target, QLatin1String("anchors.right"));
- d->hCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.horizontalCenter"));
- d->topProp = QDeclarativeProperty(d->target, QLatin1String("anchors.top"));
- d->bottomProp = QDeclarativeProperty(d->target, QLatin1String("anchors.bottom"));
- d->vCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.verticalCenter"));
- d->baselineProp = QDeclarativeProperty(d->target, QLatin1String("anchors.baseline"));
+ d->leftProp = QQmlProperty(d->target, QLatin1String("anchors.left"));
+ d->rightProp = QQmlProperty(d->target, QLatin1String("anchors.right"));
+ d->hCenterProp = QQmlProperty(d->target, QLatin1String("anchors.horizontalCenter"));
+ d->topProp = QQmlProperty(d->target, QLatin1String("anchors.top"));
+ d->bottomProp = QQmlProperty(d->target, QLatin1String("anchors.bottom"));
+ d->vCenterProp = QQmlProperty(d->target, QLatin1String("anchors.verticalCenter"));
+ d->baselineProp = QQmlProperty(d->target, QLatin1String("anchors.baseline"));
if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::LeftAnchor) {
- d->leftBinding = new QDeclarativeBinding(d->anchorSet->d_func()->leftScript.script(), d->target, qmlContext(this));
+ d->leftBinding = new QQmlBinding(d->anchorSet->d_func()->leftScript.script(), d->target, qmlContext(this));
d->leftBinding->setTarget(d->leftProp);
}
if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::RightAnchor) {
- d->rightBinding = new QDeclarativeBinding(d->anchorSet->d_func()->rightScript.script(), d->target, qmlContext(this));
+ d->rightBinding = new QQmlBinding(d->anchorSet->d_func()->rightScript.script(), d->target, qmlContext(this));
d->rightBinding->setTarget(d->rightProp);
}
if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::HCenterAnchor) {
- d->hCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, qmlContext(this));
+ d->hCenterBinding = new QQmlBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, qmlContext(this));
d->hCenterBinding->setTarget(d->hCenterProp);
}
if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::TopAnchor) {
- d->topBinding = new QDeclarativeBinding(d->anchorSet->d_func()->topScript.script(), d->target, qmlContext(this));
+ d->topBinding = new QQmlBinding(d->anchorSet->d_func()->topScript.script(), d->target, qmlContext(this));
d->topBinding->setTarget(d->topProp);
}
if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::BottomAnchor) {
- d->bottomBinding = new QDeclarativeBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, qmlContext(this));
+ d->bottomBinding = new QQmlBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, qmlContext(this));
d->bottomBinding->setTarget(d->bottomProp);
}
if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::VCenterAnchor) {
- d->vCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, qmlContext(this));
+ d->vCenterBinding = new QQmlBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, qmlContext(this));
d->vCenterBinding->setTarget(d->vCenterProp);
}
if (d->anchorSet->d_func()->usedAnchors & QQuickAnchors::BaselineAnchor) {
- d->baselineBinding = new QDeclarativeBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, qmlContext(this));
+ d->baselineBinding = new QQmlBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, qmlContext(this));
d->baselineBinding->setTarget(d->baselineProp);
}
- QDeclarativeAction a;
+ QQuickAction a;
a.event = this;
return ActionList() << a;
}
@@ -909,43 +909,43 @@ void QQuickAnchorChanges::execute(Reason reason)
if (d->applyOrigLeft) {
if (!d->origLeftBinding)
targetPrivate->anchors()->resetLeft();
- QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding);
+ QQmlPropertyPrivate::setBinding(d->leftProp, d->origLeftBinding);
}
if (d->applyOrigRight) {
if (!d->origRightBinding)
targetPrivate->anchors()->resetRight();
- QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding);
+ QQmlPropertyPrivate::setBinding(d->rightProp, d->origRightBinding);
}
if (d->applyOrigHCenter) {
if (!d->origHCenterBinding)
targetPrivate->anchors()->resetHorizontalCenter();
- QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding);
+ QQmlPropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding);
}
if (d->applyOrigTop) {
if (!d->origTopBinding)
targetPrivate->anchors()->resetTop();
- QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding);
+ QQmlPropertyPrivate::setBinding(d->topProp, d->origTopBinding);
}
if (d->applyOrigBottom) {
if (!d->origBottomBinding)
targetPrivate->anchors()->resetBottom();
- QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding);
+ QQmlPropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding);
}
if (d->applyOrigVCenter) {
if (!d->origVCenterBinding)
targetPrivate->anchors()->resetVerticalCenter();
- QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding);
+ QQmlPropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding);
}
if (d->applyOrigBaseline) {
if (!d->origBaselineBinding)
targetPrivate->anchors()->resetBaseline();
- QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding);
+ QQmlPropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding);
}
//destroy old bindings
if (reason == ActualChange) {
for (int i = 0; i < d->oldBindings.size(); ++i) {
- QDeclarativeAbstractBinding *binding = d->oldBindings.at(i);
+ QQmlAbstractBinding *binding = d->oldBindings.at(i);
if (binding)
binding->destroy();
}
@@ -955,48 +955,48 @@ void QQuickAnchorChanges::execute(Reason reason)
//reset any anchors that have been specified as "undefined"
if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::LeftAnchor) {
targetPrivate->anchors()->resetLeft();
- QDeclarativePropertyPrivate::setBinding(d->leftProp, 0);
+ QQmlPropertyPrivate::setBinding(d->leftProp, 0);
}
if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::RightAnchor) {
targetPrivate->anchors()->resetRight();
- QDeclarativePropertyPrivate::setBinding(d->rightProp, 0);
+ QQmlPropertyPrivate::setBinding(d->rightProp, 0);
}
if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::HCenterAnchor) {
targetPrivate->anchors()->resetHorizontalCenter();
- QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0);
+ QQmlPropertyPrivate::setBinding(d->hCenterProp, 0);
}
if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::TopAnchor) {
targetPrivate->anchors()->resetTop();
- QDeclarativePropertyPrivate::setBinding(d->topProp, 0);
+ QQmlPropertyPrivate::setBinding(d->topProp, 0);
}
if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::BottomAnchor) {
targetPrivate->anchors()->resetBottom();
- QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0);
+ QQmlPropertyPrivate::setBinding(d->bottomProp, 0);
}
if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::VCenterAnchor) {
targetPrivate->anchors()->resetVerticalCenter();
- QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0);
+ QQmlPropertyPrivate::setBinding(d->vCenterProp, 0);
}
if (d->anchorSet->d_func()->resetAnchors & QQuickAnchors::BaselineAnchor) {
targetPrivate->anchors()->resetBaseline();
- QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0);
+ QQmlPropertyPrivate::setBinding(d->baselineProp, 0);
}
//set any anchors that have been specified
if (d->leftBinding)
- QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), d->leftBinding);
+ QQmlPropertyPrivate::setBinding(d->leftBinding->property(), d->leftBinding);
if (d->rightBinding)
- QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), d->rightBinding);
+ QQmlPropertyPrivate::setBinding(d->rightBinding->property(), d->rightBinding);
if (d->hCenterBinding)
- QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), d->hCenterBinding);
+ QQmlPropertyPrivate::setBinding(d->hCenterBinding->property(), d->hCenterBinding);
if (d->topBinding)
- QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), d->topBinding);
+ QQmlPropertyPrivate::setBinding(d->topBinding->property(), d->topBinding);
if (d->bottomBinding)
- QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), d->bottomBinding);
+ QQmlPropertyPrivate::setBinding(d->bottomBinding->property(), d->bottomBinding);
if (d->vCenterBinding)
- QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), d->vCenterBinding);
+ QQmlPropertyPrivate::setBinding(d->vCenterBinding->property(), d->vCenterBinding);
if (d->baselineBinding)
- QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), d->baselineBinding);
+ QQmlPropertyPrivate::setBinding(d->baselineBinding->property(), d->baselineBinding);
}
bool QQuickAnchorChanges::isReversable()
@@ -1014,49 +1014,49 @@ void QQuickAnchorChanges::reverse(Reason reason)
//reset any anchors set by the state
if (d->leftBinding) {
targetPrivate->anchors()->resetLeft();
- QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), 0);
+ QQmlPropertyPrivate::setBinding(d->leftBinding->property(), 0);
if (reason == ActualChange) {
d->leftBinding->destroy(); d->leftBinding = 0;
}
}
if (d->rightBinding) {
targetPrivate->anchors()->resetRight();
- QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), 0);
+ QQmlPropertyPrivate::setBinding(d->rightBinding->property(), 0);
if (reason == ActualChange) {
d->rightBinding->destroy(); d->rightBinding = 0;
}
}
if (d->hCenterBinding) {
targetPrivate->anchors()->resetHorizontalCenter();
- QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), 0);
+ QQmlPropertyPrivate::setBinding(d->hCenterBinding->property(), 0);
if (reason == ActualChange) {
d->hCenterBinding->destroy(); d->hCenterBinding = 0;
}
}
if (d->topBinding) {
targetPrivate->anchors()->resetTop();
- QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), 0);
+ QQmlPropertyPrivate::setBinding(d->topBinding->property(), 0);
if (reason == ActualChange) {
d->topBinding->destroy(); d->topBinding = 0;
}
}
if (d->bottomBinding) {
targetPrivate->anchors()->resetBottom();
- QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), 0);
+ QQmlPropertyPrivate::setBinding(d->bottomBinding->property(), 0);
if (reason == ActualChange) {
d->bottomBinding->destroy(); d->bottomBinding = 0;
}
}
if (d->vCenterBinding) {
targetPrivate->anchors()->resetVerticalCenter();
- QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), 0);
+ QQmlPropertyPrivate::setBinding(d->vCenterBinding->property(), 0);
if (reason == ActualChange) {
d->vCenterBinding->destroy(); d->vCenterBinding = 0;
}
}
if (d->baselineBinding) {
targetPrivate->anchors()->resetBaseline();
- QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), 0);
+ QQmlPropertyPrivate::setBinding(d->baselineBinding->property(), 0);
if (reason == ActualChange) {
d->baselineBinding->destroy(); d->baselineBinding = 0;
}
@@ -1064,19 +1064,19 @@ void QQuickAnchorChanges::reverse(Reason reason)
//restore previous anchors
if (d->origLeftBinding)
- QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding);
+ QQmlPropertyPrivate::setBinding(d->leftProp, d->origLeftBinding);
if (d->origRightBinding)
- QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding);
+ QQmlPropertyPrivate::setBinding(d->rightProp, d->origRightBinding);
if (d->origHCenterBinding)
- QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding);
+ QQmlPropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding);
if (d->origTopBinding)
- QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding);
+ QQmlPropertyPrivate::setBinding(d->topProp, d->origTopBinding);
if (d->origBottomBinding)
- QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding);
+ QQmlPropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding);
if (d->origVCenterBinding)
- QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding);
+ QQmlPropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding);
if (d->origBaselineBinding)
- QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding);
+ QQmlPropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding);
//restore any absolute geometry changed by the state's anchors
QQuickAnchors::Anchors stateVAnchors = d->anchorSet->d_func()->usedAnchors & QQuickAnchors::Vertical_Mask;
@@ -1115,39 +1115,39 @@ void QQuickAnchorChanges::reverse(Reason reason)
d->target->setY(d->origY);
}
-QDeclarativeActionEvent::EventType QQuickAnchorChanges::type() const
+QQuickActionEvent::EventType QQuickAnchorChanges::type() const
{
return AnchorChanges;
}
-QList<QDeclarativeAction> QQuickAnchorChanges::additionalActions()
+QList<QQuickAction> QQuickAnchorChanges::additionalActions()
{
Q_D(QQuickAnchorChanges);
- QList<QDeclarativeAction> extra;
+ QList<QQuickAction> extra;
QQuickAnchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors;
bool hChange = combined & QQuickAnchors::Horizontal_Mask;
bool vChange = combined & QQuickAnchors::Vertical_Mask;
if (d->target) {
- QDeclarativeAction a;
+ QQuickAction a;
if (hChange && d->fromX != d->toX) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("x"));
+ a.property = QQmlProperty(d->target, QLatin1String("x"));
a.toValue = d->toX;
extra << a;
}
if (vChange && d->fromY != d->toY) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("y"));
+ a.property = QQmlProperty(d->target, QLatin1String("y"));
a.toValue = d->toY;
extra << a;
}
if (hChange && d->fromWidth != d->toWidth) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("width"));
+ a.property = QQmlProperty(d->target, QLatin1String("width"));
a.toValue = d->toWidth;
extra << a;
}
if (vChange && d->fromHeight != d->toHeight) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("height"));
+ a.property = QQmlProperty(d->target, QLatin1String("height"));
a.toValue = d->toHeight;
extra << a;
}
@@ -1167,13 +1167,13 @@ void QQuickAnchorChanges::saveOriginals()
if (!d->target)
return;
- d->origLeftBinding = QDeclarativePropertyPrivate::binding(d->leftProp);
- d->origRightBinding = QDeclarativePropertyPrivate::binding(d->rightProp);
- d->origHCenterBinding = QDeclarativePropertyPrivate::binding(d->hCenterProp);
- d->origTopBinding = QDeclarativePropertyPrivate::binding(d->topProp);
- d->origBottomBinding = QDeclarativePropertyPrivate::binding(d->bottomProp);
- d->origVCenterBinding = QDeclarativePropertyPrivate::binding(d->vCenterProp);
- d->origBaselineBinding = QDeclarativePropertyPrivate::binding(d->baselineProp);
+ d->origLeftBinding = QQmlPropertyPrivate::binding(d->leftProp);
+ d->origRightBinding = QQmlPropertyPrivate::binding(d->rightProp);
+ d->origHCenterBinding = QQmlPropertyPrivate::binding(d->hCenterProp);
+ d->origTopBinding = QQmlPropertyPrivate::binding(d->topProp);
+ d->origBottomBinding = QQmlPropertyPrivate::binding(d->bottomProp);
+ d->origVCenterBinding = QQmlPropertyPrivate::binding(d->vCenterProp);
+ d->origBaselineBinding = QQmlPropertyPrivate::binding(d->baselineProp);
QQuickItemPrivate *targetPrivate = QQuickItemPrivate::get(d->target);
if (targetPrivate->widthValid)
@@ -1189,7 +1189,7 @@ void QQuickAnchorChanges::saveOriginals()
saveCurrentValues();
}
-void QQuickAnchorChanges::copyOriginals(QDeclarativeActionEvent *other)
+void QQuickAnchorChanges::copyOriginals(QQuickActionEvent *other)
{
Q_D(QQuickAnchorChanges);
QQuickAnchorChanges *ac = static_cast<QQuickAnchorChanges*>(other);
@@ -1247,39 +1247,39 @@ void QQuickAnchorChanges::clearBindings()
d->anchorSet->d_func()->usedAnchors;
if (d->applyOrigLeft || (combined & QQuickAnchors::LeftAnchor)) {
targetPrivate->anchors()->resetLeft();
- QDeclarativePropertyPrivate::setBinding(d->leftProp, 0);
+ QQmlPropertyPrivate::setBinding(d->leftProp, 0);
}
if (d->applyOrigRight || (combined & QQuickAnchors::RightAnchor)) {
targetPrivate->anchors()->resetRight();
- QDeclarativePropertyPrivate::setBinding(d->rightProp, 0);
+ QQmlPropertyPrivate::setBinding(d->rightProp, 0);
}
if (d->applyOrigHCenter || (combined & QQuickAnchors::HCenterAnchor)) {
targetPrivate->anchors()->resetHorizontalCenter();
- QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0);
+ QQmlPropertyPrivate::setBinding(d->hCenterProp, 0);
}
if (d->applyOrigTop || (combined & QQuickAnchors::TopAnchor)) {
targetPrivate->anchors()->resetTop();
- QDeclarativePropertyPrivate::setBinding(d->topProp, 0);
+ QQmlPropertyPrivate::setBinding(d->topProp, 0);
}
if (d->applyOrigBottom || (combined & QQuickAnchors::BottomAnchor)) {
targetPrivate->anchors()->resetBottom();
- QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0);
+ QQmlPropertyPrivate::setBinding(d->bottomProp, 0);
}
if (d->applyOrigVCenter || (combined & QQuickAnchors::VCenterAnchor)) {
targetPrivate->anchors()->resetVerticalCenter();
- QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0);
+ QQmlPropertyPrivate::setBinding(d->vCenterProp, 0);
}
if (d->applyOrigBaseline || (combined & QQuickAnchors::BaselineAnchor)) {
targetPrivate->anchors()->resetBaseline();
- QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0);
+ QQmlPropertyPrivate::setBinding(d->baselineProp, 0);
}
}
-bool QQuickAnchorChanges::override(QDeclarativeActionEvent*other)
+bool QQuickAnchorChanges::override(QQuickActionEvent*other)
{
if (other->type() != AnchorChanges)
return false;
- if (static_cast<QDeclarativeActionEvent*>(this) == other)
+ if (static_cast<QQuickActionEvent*>(this) == other)
return true;
if (static_cast<QQuickAnchorChanges*>(other)->object() == object())
return true;
diff --git a/src/quick/items/qquickstateoperations_p.h b/src/quick/items/qquickstateoperations_p.h
index ff1671d53a..2523cc6d4f 100644
--- a/src/quick/items/qquickstateoperations_p.h
+++ b/src/quick/items/qquickstateoperations_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,28 +45,28 @@
#include "qquickitem.h"
#include "qquickanchors_p.h"
-#include <QtQuick/private/qdeclarativestate_p.h>
+#include <QtQuick/private/qquickstate_p.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
+#include <QtQml/qqmlscriptstring.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QQuickParentChangePrivate;
-class Q_AUTOTEST_EXPORT QQuickParentChange : public QDeclarativeStateOperation, public QDeclarativeActionEvent
+class Q_AUTOTEST_EXPORT QQuickParentChange : public QQuickStateOperation, public QQuickActionEvent
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickParentChange)
Q_PROPERTY(QQuickItem *target READ object WRITE setObject)
Q_PROPERTY(QQuickItem *parent READ parent WRITE setParent)
- Q_PROPERTY(QDeclarativeScriptString x READ x WRITE setX)
- Q_PROPERTY(QDeclarativeScriptString y READ y WRITE setY)
- Q_PROPERTY(QDeclarativeScriptString width READ width WRITE setWidth)
- Q_PROPERTY(QDeclarativeScriptString height READ height WRITE setHeight)
- Q_PROPERTY(QDeclarativeScriptString scale READ scale WRITE setScale)
- Q_PROPERTY(QDeclarativeScriptString rotation READ rotation WRITE setRotation)
+ Q_PROPERTY(QQmlScriptString x READ x WRITE setX)
+ Q_PROPERTY(QQmlScriptString y READ y WRITE setY)
+ Q_PROPERTY(QQmlScriptString width READ width WRITE setWidth)
+ Q_PROPERTY(QQmlScriptString height READ height WRITE setHeight)
+ Q_PROPERTY(QQmlScriptString scale READ scale WRITE setScale)
+ Q_PROPERTY(QQmlScriptString rotation READ rotation WRITE setRotation)
public:
QQuickParentChange(QObject *parent=0);
~QQuickParentChange();
@@ -79,39 +79,39 @@ public:
QQuickItem *originalParent() const;
- QDeclarativeScriptString x() const;
- void setX(QDeclarativeScriptString x);
+ QQmlScriptString x() const;
+ void setX(QQmlScriptString x);
bool xIsSet() const;
- QDeclarativeScriptString y() const;
- void setY(QDeclarativeScriptString y);
+ QQmlScriptString y() const;
+ void setY(QQmlScriptString y);
bool yIsSet() const;
- QDeclarativeScriptString width() const;
- void setWidth(QDeclarativeScriptString width);
+ QQmlScriptString width() const;
+ void setWidth(QQmlScriptString width);
bool widthIsSet() const;
- QDeclarativeScriptString height() const;
- void setHeight(QDeclarativeScriptString height);
+ QQmlScriptString height() const;
+ void setHeight(QQmlScriptString height);
bool heightIsSet() const;
- QDeclarativeScriptString scale() const;
- void setScale(QDeclarativeScriptString scale);
+ QQmlScriptString scale() const;
+ void setScale(QQmlScriptString scale);
bool scaleIsSet() const;
- QDeclarativeScriptString rotation() const;
- void setRotation(QDeclarativeScriptString rotation);
+ QQmlScriptString rotation() const;
+ void setRotation(QQmlScriptString rotation);
bool rotationIsSet() const;
virtual ActionList actions();
virtual void saveOriginals();
- //virtual void copyOriginals(QDeclarativeActionEvent*);
+ //virtual void copyOriginals(QQuickActionEvent*);
virtual void execute(Reason reason = ActualChange);
virtual bool isReversable();
virtual void reverse(Reason reason = ActualChange);
virtual EventType type() const;
- virtual bool override(QDeclarativeActionEvent*other);
+ virtual bool override(QQuickActionEvent*other);
virtual void rewind();
virtual void saveCurrentValues();
};
@@ -122,13 +122,13 @@ class Q_AUTOTEST_EXPORT QQuickAnchorSet : public QObject
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeScriptString left READ left WRITE setLeft RESET resetLeft)
- Q_PROPERTY(QDeclarativeScriptString right READ right WRITE setRight RESET resetRight)
- Q_PROPERTY(QDeclarativeScriptString horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter)
- Q_PROPERTY(QDeclarativeScriptString top READ top WRITE setTop RESET resetTop)
- Q_PROPERTY(QDeclarativeScriptString bottom READ bottom WRITE setBottom RESET resetBottom)
- Q_PROPERTY(QDeclarativeScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
- Q_PROPERTY(QDeclarativeScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline)
+ Q_PROPERTY(QQmlScriptString left READ left WRITE setLeft RESET resetLeft)
+ Q_PROPERTY(QQmlScriptString right READ right WRITE setRight RESET resetRight)
+ Q_PROPERTY(QQmlScriptString horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter)
+ Q_PROPERTY(QQmlScriptString top READ top WRITE setTop RESET resetTop)
+ Q_PROPERTY(QQmlScriptString bottom READ bottom WRITE setBottom RESET resetBottom)
+ Q_PROPERTY(QQmlScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
+ Q_PROPERTY(QQmlScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline)
//Q_PROPERTY(QQuickItem *fill READ fill WRITE setFill RESET resetFill)
//Q_PROPERTY(QQuickItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn)
@@ -145,32 +145,32 @@ public:
QQuickAnchorSet(QObject *parent=0);
virtual ~QQuickAnchorSet();
- QDeclarativeScriptString left() const;
- void setLeft(const QDeclarativeScriptString &edge);
+ QQmlScriptString left() const;
+ void setLeft(const QQmlScriptString &edge);
void resetLeft();
- QDeclarativeScriptString right() const;
- void setRight(const QDeclarativeScriptString &edge);
+ QQmlScriptString right() const;
+ void setRight(const QQmlScriptString &edge);
void resetRight();
- QDeclarativeScriptString horizontalCenter() const;
- void setHorizontalCenter(const QDeclarativeScriptString &edge);
+ QQmlScriptString horizontalCenter() const;
+ void setHorizontalCenter(const QQmlScriptString &edge);
void resetHorizontalCenter();
- QDeclarativeScriptString top() const;
- void setTop(const QDeclarativeScriptString &edge);
+ QQmlScriptString top() const;
+ void setTop(const QQmlScriptString &edge);
void resetTop();
- QDeclarativeScriptString bottom() const;
- void setBottom(const QDeclarativeScriptString &edge);
+ QQmlScriptString bottom() const;
+ void setBottom(const QQmlScriptString &edge);
void resetBottom();
- QDeclarativeScriptString verticalCenter() const;
- void setVerticalCenter(const QDeclarativeScriptString &edge);
+ QQmlScriptString verticalCenter() const;
+ void setVerticalCenter(const QQmlScriptString &edge);
void resetVerticalCenter();
- QDeclarativeScriptString baseline() const;
- void setBaseline(const QDeclarativeScriptString &edge);
+ QQmlScriptString baseline() const;
+ void setBaseline(const QQmlScriptString &edge);
void resetBaseline();
QQuickItem *fill() const;
@@ -224,7 +224,7 @@ private:
};
class QQuickAnchorChangesPrivate;
-class Q_AUTOTEST_EXPORT QQuickAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent
+class Q_AUTOTEST_EXPORT QQuickAnchorChanges : public QQuickStateOperation, public QQuickActionEvent
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickAnchorChanges)
@@ -247,16 +247,16 @@ public:
virtual bool isReversable();
virtual void reverse(Reason reason = ActualChange);
virtual EventType type() const;
- virtual bool override(QDeclarativeActionEvent*other);
+ virtual bool override(QQuickActionEvent*other);
virtual bool changesBindings();
virtual void saveOriginals();
virtual bool needsCopy() { return true; }
- virtual void copyOriginals(QDeclarativeActionEvent*);
+ virtual void copyOriginals(QQuickActionEvent*);
virtual void clearBindings();
virtual void rewind();
virtual void saveCurrentValues();
- QList<QDeclarativeAction> additionalActions();
+ QList<QQuickAction> additionalActions();
virtual void saveTargetValues();
};
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 6d1cc0d8d2..36b902ff8c 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,12 +43,13 @@
#include "qquicktext_p_p.h"
#include <QtQuick/private/qsgcontext_p.h>
+#include <private/qqmlglobal_p.h>
#include <private/qsgadaptationlayer_p.h>
#include "qquicktextnode_p.h"
#include "qquickimage_p_p.h"
#include <QtQuick/private/qsgtexture_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QtGui/qevent.h>
#include <QtGui/qabstracttextdocumentlayout.h>
#include <QtGui/qpainter.h>
@@ -59,8 +60,8 @@
#include <QtGui/qinputmethod.h>
#include <private/qtextengine_p.h>
-#include <private/qdeclarativestyledtext_p.h>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <private/qquickstyledtext_p.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
#include <qmath.h>
#include <limits.h>
@@ -122,11 +123,11 @@ QQuickTextDocumentWithImageResources::~QQuickTextDocumentWithImageResources()
QVariant QQuickTextDocumentWithImageResources::loadResource(int type, const QUrl &name)
{
- QDeclarativeContext *context = qmlContext(parent());
+ QQmlContext *context = qmlContext(parent());
QUrl url = m_baseUrl.resolved(name);
if (type == QTextDocument::ImageResource) {
- QDeclarativePixmap *p = loadPixmap(context, url);
+ QQuickPixmap *p = loadPixmap(context, url);
return p->image();
}
@@ -163,10 +164,10 @@ QSizeF QQuickTextDocumentWithImageResources::intrinsicSize(
QSizeF size(width, height);
if (!hasWidth || !hasHeight) {
- QDeclarativeContext *context = qmlContext(parent());
+ QQmlContext *context = qmlContext(parent());
QUrl url = m_baseUrl.resolved(QUrl(imageFormat.name()));
- QDeclarativePixmap *p = loadPixmap(context, url);
+ QQuickPixmap *p = loadPixmap(context, url);
if (!p->isReady()) {
if (!hasWidth)
size.setWidth(16);
@@ -201,10 +202,10 @@ void QQuickTextDocumentWithImageResources::drawObject(
QImage QQuickTextDocumentWithImageResources::image(const QTextImageFormat &format)
{
- QDeclarativeContext *context = qmlContext(parent());
+ QQmlContext *context = qmlContext(parent());
QUrl url = m_baseUrl.resolved(QUrl(format.name()));
- QDeclarativePixmap *p = loadPixmap(context, url);
+ QQuickPixmap *p = loadPixmap(context, url);
return p->image();
}
@@ -217,14 +218,14 @@ void QQuickTextDocumentWithImageResources::setBaseUrl(const QUrl &url, bool clea
}
}
-QDeclarativePixmap *QQuickTextDocumentWithImageResources::loadPixmap(
- QDeclarativeContext *context, const QUrl &url)
+QQuickPixmap *QQuickTextDocumentWithImageResources::loadPixmap(
+ QQmlContext *context, const QUrl &url)
{
- QHash<QUrl, QDeclarativePixmap *>::Iterator iter = m_resources.find(url);
+ QHash<QUrl, QQuickPixmap *>::Iterator iter = m_resources.find(url);
if (iter == m_resources.end()) {
- QDeclarativePixmap *p = new QDeclarativePixmap(context->engine(), url);
+ QQuickPixmap *p = new QQuickPixmap(context->engine(), url);
iter = m_resources.insert(url, p);
if (p->isLoading()) {
@@ -233,7 +234,7 @@ QDeclarativePixmap *QQuickTextDocumentWithImageResources::loadPixmap(
}
}
- QDeclarativePixmap *p = *iter;
+ QQuickPixmap *p = *iter;
if (p->isError()) {
if (!errors.contains(url)) {
errors.insert(url);
@@ -245,7 +246,7 @@ QDeclarativePixmap *QQuickTextDocumentWithImageResources::loadPixmap(
void QQuickTextDocumentWithImageResources::clearResources()
{
- foreach (QDeclarativePixmap *pixmap, m_resources)
+ foreach (QQuickPixmap *pixmap, m_resources)
pixmap->clear(this);
qDeleteAll(m_resources);
m_resources.clear();
@@ -312,7 +313,7 @@ void QQuickTextPrivate::updateLayout()
layout.setFont(font);
// needs temporary bool because formatModifiesFontSize is in a bit-field
bool fontSizeModified = false;
- QDeclarativeStyledText::parse(text, layout, imgTags, q->baseUrl(), qmlContext(q), !maximumLineCountValid, &fontSizeModified);
+ QQuickStyledText::parse(text, layout, imgTags, q->baseUrl(), qmlContext(q), !maximumLineCountValid, &fontSizeModified);
formatModifiesFontSize = fontSizeModified;
} else {
layout.clearAdditionalFormats();
@@ -364,7 +365,7 @@ void QQuickText::imageDownloadFinished()
if (d->extra.isAllocated() && d->extra->nbActiveDownloads == 0) {
bool needToUpdateLayout = false;
- foreach (QDeclarativeStyledTextImgTag *img, d->visibleImgTags) {
+ foreach (QQuickStyledTextImgTag *img, d->visibleImgTags) {
if (!img->size.isValid()) {
img->size = img->pix->implicitSize();
needToUpdateLayout = true;
@@ -1026,15 +1027,15 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
qreal textHeight = line.height();
qreal totalLineHeight = textHeight;
- QList<QDeclarativeStyledTextImgTag *> imagesInLine;
+ QList<QQuickStyledTextImgTag *> imagesInLine;
- foreach (QDeclarativeStyledTextImgTag *image, imgTags) {
+ foreach (QQuickStyledTextImgTag *image, imgTags) {
if (image->position >= line.textStart() &&
image->position < line.textStart() + line.textLength()) {
if (!image->pix) {
QUrl url = q->baseUrl().resolved(image->url);
- image->pix = new QDeclarativePixmap(qmlEngine(q), url, image->size);
+ image->pix = new QQuickPixmap(qmlEngine(q), url, image->size);
if (image->pix->isLoading()) {
image->pix->connectFinished(q, SLOT(imageDownloadFinished()));
if (!extra.isAllocated() || !extra->nbActiveDownloads)
@@ -1053,9 +1054,9 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
}
qreal ih = qreal(image->size.height());
- if (image->align == QDeclarativeStyledTextImgTag::Top)
+ if (image->align == QQuickStyledTextImgTag::Top)
image->pos.setY(0);
- else if (image->align == QDeclarativeStyledTextImgTag::Middle)
+ else if (image->align == QQuickStyledTextImgTag::Middle)
image->pos.setY((textHeight / 2.0) - (ih / 2.0));
else
image->pos.setY(textHeight - ih);
@@ -1064,7 +1065,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
}
}
- foreach (QDeclarativeStyledTextImgTag *image, imagesInLine) {
+ foreach (QQuickStyledTextImgTag *image, imagesInLine) {
totalLineHeight = qMax(totalLineHeight, textTop + image->pos.y() + image->size.height());
image->pos.setX(line.cursorToX(image->position));
image->pos.setY(image->pos.y() + height + textTop);
@@ -1200,7 +1201,7 @@ QQuickText::~QQuickText()
The link must be in rich text or HTML format and the
\a link string provides access to the particular link.
- \snippet doc/src/snippets/declarative/text/onLinkActivated.qml 0
+ \snippet doc/src/snippets/qml/text/onLinkActivated.qml 0
The example code will display the text
"The main website is at \l{http://qt.nokia.com}{Nokia Qt DF}."
@@ -1924,7 +1925,7 @@ QUrl QQuickText::baseUrl() const
{
Q_D(const QQuickText);
if (d->baseUrl.isEmpty()) {
- if (QDeclarativeContext *context = qmlContext(this))
+ if (QQmlContext *context = qmlContext(this))
const_cast<QQuickTextPrivate *>(d)->baseUrl = context->baseUrl();
}
return d->baseUrl;
@@ -1952,7 +1953,7 @@ void QQuickText::setBaseUrl(const QUrl &url)
void QQuickText::resetBaseUrl()
{
- if (QDeclarativeContext *context = qmlContext(this))
+ if (QQmlContext *context = qmlContext(this))
setBaseUrl(context->baseUrl());
else
setBaseUrl(QUrl());
@@ -2093,8 +2094,8 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data
node->addTextLayout(QPoint(0, bounds.y()), d->elideLayout, color, d->style, styleColor, linkColor);
}
- foreach (QDeclarativeStyledTextImgTag *img, d->visibleImgTags) {
- QDeclarativePixmap *pix = img->pix;
+ foreach (QQuickStyledTextImgTag *img, d->visibleImgTags) {
+ QQuickPixmap *pix = img->pix;
if (pix && pix->isReady())
node->addImage(QRectF(img->pos.x(), img->pos.y() + bounds.y(), pix->width(), pix->height()), pix->image());
}
diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h
index 37287b5445..d73c6e1a10 100644
--- a/src/quick/items/qquicktext_p.h
+++ b/src/quick/items/qquicktext_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h
index 3be62541ea..0425c37406 100644
--- a/src/quick/items/qquicktext_p_p.h
+++ b/src/quick/items/qquicktext_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -56,10 +56,10 @@
#include "qquicktext_p.h"
#include "qquickimplicitsizeitem_p_p.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
#include <QtGui/qabstracttextdocumentlayout.h>
#include <QtGui/qtextlayout.h>
-#include <private/qdeclarativestyledtext_p.h>
+#include <private/qquickstyledtext_p.h>
#include <private/qlazilyallocated_p.h>
QT_BEGIN_NAMESPACE
@@ -107,8 +107,8 @@ public:
QUrl baseUrl;
QFont font;
QFont sourceFont;
- QList<QDeclarativeStyledTextImgTag*> imgTags;
- QList<QDeclarativeStyledTextImgTag*> visibleImgTags;
+ QList<QQuickStyledTextImgTag*> imgTags;
+ QList<QQuickStyledTextImgTag*> visibleImgTags;
QTextLayout layout;
QTextLayout *elideLayout;
@@ -177,7 +177,7 @@ public:
static inline QQuickTextPrivate *get(QQuickText *t) { return t->d_func(); }
};
-class QDeclarativePixmap;
+class QQuickPixmap;
class QQuickTextDocumentWithImageResources : public QTextDocument, public QTextObjectInterface
{
Q_OBJECT
@@ -206,13 +206,13 @@ Q_SIGNALS:
protected:
QVariant loadResource(int type, const QUrl &name);
- QDeclarativePixmap *loadPixmap(QDeclarativeContext *context, const QUrl &name);
+ QQuickPixmap *loadPixmap(QQmlContext *context, const QUrl &name);
private slots:
void requestFinished();
private:
- QHash<QUrl, QDeclarativePixmap *> m_resources;
+ QHash<QUrl, QQuickPixmap *> m_resources;
QUrl m_baseUrl;
int outstanding;
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 66285fcd2b..a9bff73bd9 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -48,15 +48,15 @@
#include "qquicktextnode_p.h"
#include <QtQuick/qsgsimplerectnode.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qevent.h>
#include <QtGui/qpainter.h>
#include <QtGui/qtextobject.h>
#include <QtCore/qmath.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativeproperty_p.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlproperty_p.h>
#include <private/qtextengine_p.h>
#include <private/qsgadaptationlayer_p.h>
@@ -683,7 +683,7 @@ QUrl QQuickTextEdit::baseUrl() const
{
Q_D(const QQuickTextEdit);
if (d->baseUrl.isEmpty()) {
- if (QDeclarativeContext *context = qmlContext(this))
+ if (QQmlContext *context = qmlContext(this))
const_cast<QQuickTextEditPrivate *>(d)->baseUrl = context->baseUrl();
}
return d->baseUrl;
@@ -702,7 +702,7 @@ void QQuickTextEdit::setBaseUrl(const QUrl &url)
void QQuickTextEdit::resetBaseUrl()
{
- if (QDeclarativeContext *context = qmlContext(this))
+ if (QQmlContext *context = qmlContext(this))
setBaseUrl(context->baseUrl());
else
setBaseUrl(QUrl());
@@ -910,16 +910,16 @@ void QQuickTextEdit::setCursorPosition(int pos)
needed, and the x and y properties of delegate instance will be set so as
to be one pixel before the top left of the current character.
- Note that the root item of the delegate component must be a QDeclarativeItem or
- QDeclarativeItem derived item.
+ Note that the root item of the delegate component must be a QQuickItem or
+ QQuickItem derived item.
*/
-QDeclarativeComponent* QQuickTextEdit::cursorDelegate() const
+QQmlComponent* QQuickTextEdit::cursorDelegate() const
{
Q_D(const QQuickTextEdit);
return d->cursorComponent;
}
-void QQuickTextEdit::setCursorDelegate(QDeclarativeComponent* c)
+void QQuickTextEdit::setCursorDelegate(QQmlComponent* c)
{
Q_D(QQuickTextEdit);
if (d->cursorComponent) {
@@ -947,13 +947,13 @@ void QQuickTextEdit::loadCursorDelegate()
Q_D(QQuickTextEdit);
if (d->cursorComponent->isLoading() || !isComponentComplete())
return;
- QDeclarativeContext *creationContext = d->cursorComponent->creationContext();
+ QQmlContext *creationContext = d->cursorComponent->creationContext();
QObject *object = d->cursorComponent->create(creationContext ? creationContext : qmlContext(this));
d->cursor = qobject_cast<QQuickItem*>(object);
if (d->cursor) {
d->control->setCursorWidth(0);
updateCursor();
- QDeclarative_setParent_noEvent(d->cursor, this);
+ QQml_setParent_noEvent(d->cursor, this);
d->cursor->setParentItem(this);
d->cursor->setHeight(QFontMetrics(d->font).height());
moveCursorDelegate();
diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h
index b3fd32af69..b28ec9d7d7 100644
--- a/src/quick/items/qquicktextedit_p.h
+++ b/src/quick/items/qquicktextedit_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -80,7 +80,7 @@ class Q_AUTOTEST_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
- Q_PROPERTY(QDeclarativeComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
+ Q_PROPERTY(QQmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
@@ -172,8 +172,8 @@ public:
int cursorPosition() const;
void setCursorPosition(int pos);
- QDeclarativeComponent* cursorDelegate() const;
- void setCursorDelegate(QDeclarativeComponent*);
+ QQmlComponent* cursorDelegate() const;
+ void setCursorDelegate(QQmlComponent*);
int selectionStart() const;
int selectionEnd() const;
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index 8ec589da29..055b5c7929 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -56,7 +56,7 @@
#include "qquicktextedit_p.h"
#include "qquickimplicitsizeitem_p_p.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
class QTextLayout;
@@ -108,7 +108,7 @@ public:
QFont sourceFont;
QFont font;
- QDeclarativeComponent* cursorComponent;
+ QQmlComponent* cursorComponent;
QQuickItem* cursor;
QQuickTextDocumentWithImageResources *document;
QQuickTextControl *control;
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 6f079dc045..1a93345aa2 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,9 +43,9 @@
#include "qquicktextinput_p_p.h"
#include "qquickcanvas.h"
-#include <private/qdeclarativeglobal_p.h>
+#include <private/qqmlglobal_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
#include <QtGui/qevent.h>
#include <QTextBoundaryFinder>
#include "qquicktextnode_p.h"
@@ -1211,16 +1211,16 @@ void QQuickTextInput::setInputMethodHints(Qt::InputMethodHints hints)
needed, and the x property of delegate instance will be set so as
to be one pixel before the top left of the current character.
- Note that the root item of the delegate component must be a QDeclarativeItem or
- QDeclarativeItem derived item.
+ Note that the root item of the delegate component must be a QQuickItem or
+ QQuickItem derived item.
*/
-QDeclarativeComponent* QQuickTextInput::cursorDelegate() const
+QQmlComponent* QQuickTextInput::cursorDelegate() const
{
Q_D(const QQuickTextInput);
return d->cursorComponent;
}
-void QQuickTextInput::setCursorDelegate(QDeclarativeComponent* c)
+void QQuickTextInput::setCursorDelegate(QQmlComponent* c)
{
Q_D(QQuickTextInput);
if (d->cursorComponent == c)
@@ -1267,7 +1267,7 @@ void QQuickTextInput::createCursor()
if (d->cursorItem)
delete d->cursorItem;
- QDeclarativeContext *creationContext = d->cursorComponent->creationContext();
+ QQmlContext *creationContext = d->cursorComponent->creationContext();
QObject *object = d->cursorComponent->create(creationContext ? creationContext : qmlContext(this));
d->cursorItem = qobject_cast<QQuickItem*>(object);
if (!d->cursorItem) {
@@ -1278,7 +1278,7 @@ void QQuickTextInput::createCursor()
QRectF r = cursorRectangle();
- QDeclarative_setParent_noEvent(d->cursorItem, this);
+ QQml_setParent_noEvent(d->cursorItem, this);
d->cursorItem->setParentItem(this);
d->cursorItem->setPos(r.topLeft());
d->cursorItem->setHeight(r.height());
@@ -1328,7 +1328,7 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
\endlist
*/
-void QQuickTextInput::positionAt(QDeclarativeV8Function *args) const
+void QQuickTextInput::positionAt(QQmlV8Function *args) const
{
Q_D(const QQuickTextInput);
diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h
index ebd3d58957..011af65bff 100644
--- a/src/quick/items/qquicktextinput_p.h
+++ b/src/quick/items/qquicktextinput_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -77,7 +77,7 @@ class Q_AUTOTEST_EXPORT QQuickTextInput : public QQuickImplicitSizeItem
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
- Q_PROPERTY(QDeclarativeComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
+ Q_PROPERTY(QQmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
@@ -150,7 +150,7 @@ public:
//Auxilliary functions needed to control the TextInput from QML
- Q_INVOKABLE void positionAt(QDeclarativeV8Function *args) const;
+ Q_INVOKABLE void positionAt(QQmlV8Function *args) const;
Q_INVOKABLE QRectF positionToRectangle(int pos) const;
Q_INVOKABLE void moveCursorSelection(int pos);
Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
@@ -220,8 +220,8 @@ public:
QString displayText() const;
- QDeclarativeComponent* cursorDelegate() const;
- void setCursorDelegate(QDeclarativeComponent*);
+ QQmlComponent* cursorDelegate() const;
+ void setCursorDelegate(QQmlComponent*);
bool focusOnPress() const;
void setFocusOnPress(bool);
diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h
index 1921451f88..9a59b44549 100644
--- a/src/quick/items/qquicktextinput_p_p.h
+++ b/src/quick/items/qquicktextinput_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -46,7 +46,7 @@
#include "qquicktext_p.h"
#include "qquickimplicitsizeitem_p_p.h"
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qpointer.h>
#include <QtCore/qbasictimer.h>
@@ -174,9 +174,9 @@ public:
QPointF pressPos;
QPointF tripleClickStartPoint;
- QDeclarativeGuard<QDeclarativeComponent> cursorComponent;
+ QQmlGuard<QQmlComponent> cursorComponent;
#ifndef QT_NO_VALIDATOR
- QDeclarativeGuard<QValidator> m_validator;
+ QQmlGuard<QValidator> m_validator;
#endif
qreal hscroll;
diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp
index a3daead6cb..5be4963809 100644
--- a/src/quick/items/qquicktextnode.cpp
+++ b/src/quick/items/qquicktextnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -55,7 +55,7 @@
#include <qrawfont.h>
#include <qtexttable.h>
#include <qtextlist.h>
-#include <private/qdeclarativestyledtext_p.h>
+#include <private/qquickstyledtext_p.h>
#include <private/qquicktext_p_p.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
diff --git a/src/quick/items/qquicktextnode_p.h b/src/quick/items/qquicktextnode_p.h
index 9c2217bfd0..2ecd20d933 100644
--- a/src/quick/items/qquicktextnode_p.h
+++ b/src/quick/items/qquicktextnode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquicktranslate.cpp b/src/quick/items/qquicktranslate.cpp
index a1a1f59173..6cfa7a0338 100644
--- a/src/quick/items/qquicktranslate.cpp
+++ b/src/quick/items/qquicktranslate.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquicktranslate_p.h b/src/quick/items/qquicktranslate_p.h
index 82901d7c6a..d2d8c3abc5 100644
--- a/src/quick/items/qquicktranslate_p.h
+++ b/src/quick/items/qquicktranslate_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index 76d82a4713..7d1411aa6e 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -46,11 +46,11 @@
#include "qquickitem_p.h"
#include "qquickitemchangelistener_p.h"
-#include <private/qdeclarativeprofilerservice_p.h>
-#include <private/qdeclarativeinspectorservice_p.h>
+#include <private/qqmlprofilerservice_p.h>
+#include <private/qqmlinspectorservice_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <private/qdeclarativeengine_p.h>
+#include <QtQml/qqmlengine.h>
+#include <private/qqmlengine_p.h>
#include <QtCore/qbasictimer.h>
@@ -62,8 +62,8 @@ void QQuickViewPrivate::init()
engine.setIncubationController(q->incubationController());
- if (QDeclarativeDebugService::isDebuggingEnabled())
- QDeclarativeInspectorService::instance()->addView(q);
+ if (QQmlDebugService::isDebuggingEnabled())
+ QQmlInspectorService::instance()->addView(q);
}
QQuickViewPrivate::QQuickViewPrivate()
@@ -73,8 +73,8 @@ QQuickViewPrivate::QQuickViewPrivate()
QQuickViewPrivate::~QQuickViewPrivate()
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- QDeclarativeInspectorService::instance()->removeView(q_func());
+ if (QQmlDebugService::isDebuggingEnabled())
+ QQmlInspectorService::instance()->removeView(q_func());
delete root;
}
@@ -91,11 +91,11 @@ void QQuickViewPrivate::execute()
component = 0;
}
if (!source.isEmpty()) {
- component = new QDeclarativeComponent(&engine, source, q);
+ component = new QQmlComponent(&engine, source, q);
if (!component->isLoading()) {
q->continueExecute();
} else {
- QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
+ QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)),
q, SLOT(continueExecute()));
}
}
@@ -120,7 +120,7 @@ void QQuickViewPrivate::itemGeometryChanged(QQuickItem *resizeItem, const QRectF
This is a convenience subclass of QQuickCanvas which
will automatically load and display a QML scene when given the URL of the main source file. Alternatively,
- you can instantiate your own objects using QDeclarativeComponent and place them in a manually setup QQuickCanvas.
+ you can instantiate your own objects using QQmlComponent and place them in a manually setup QQuickCanvas.
Typical usage:
@@ -216,23 +216,23 @@ QUrl QQuickView::source() const
}
/*!
- Returns a pointer to the QDeclarativeEngine used for instantiating
+ Returns a pointer to the QQmlEngine used for instantiating
QML Components.
*/
-QDeclarativeEngine* QQuickView::engine() const
+QQmlEngine* QQuickView::engine() const
{
Q_D(const QQuickView);
- return const_cast<QDeclarativeEngine *>(&d->engine);
+ return const_cast<QQmlEngine *>(&d->engine);
}
/*!
This function returns the root of the context hierarchy. Each QML
- component is instantiated in a QDeclarativeContext. QDeclarativeContext's are
+ component is instantiated in a QQmlContext. QQmlContext's are
essential for passing data to QML components. In QML, contexts are
arranged hierarchically and this hierarchy is managed by the
- QDeclarativeEngine.
+ QQmlEngine.
*/
-QDeclarativeContext* QQuickView::rootContext() const
+QQmlContext* QQuickView::rootContext() const
{
Q_D(const QQuickView);
return d->engine.rootContext();
@@ -275,12 +275,12 @@ QQuickView::Status QQuickView::status() const
Return the list of errors that occurred during the last compile or create
operation. When the status is not Error, an empty list is returned.
*/
-QList<QDeclarativeError> QQuickView::errors() const
+QList<QQmlError> QQuickView::errors() const
{
Q_D(const QQuickView);
if (d->component)
return d->component->errors();
- return QList<QDeclarativeError>();
+ return QList<QQmlError>();
}
/*!
@@ -377,11 +377,11 @@ QQuickView::ResizeMode QQuickView::resizeMode() const
void QQuickView::continueExecute()
{
Q_D(QQuickView);
- disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
+ disconnect(d->component, SIGNAL(statusChanged(QQmlComponent::Status)), this, SLOT(continueExecute()));
if (d->component->isError()) {
- QList<QDeclarativeError> errorList = d->component->errors();
- foreach (const QDeclarativeError &error, errorList) {
+ QList<QQmlError> errorList = d->component->errors();
+ foreach (const QQmlError &error, errorList) {
qWarning() << error;
}
emit statusChanged(status());
@@ -391,8 +391,8 @@ void QQuickView::continueExecute()
QObject *obj = d->component->create();
if (d->component->isError()) {
- QList<QDeclarativeError> errorList = d->component->errors();
- foreach (const QDeclarativeError &error, errorList) {
+ QList<QQmlError> errorList = d->component->errors();
+ foreach (const QQmlError &error, errorList) {
qWarning() << error;
}
emit statusChanged(status());
@@ -422,7 +422,7 @@ void QQuickViewPrivate::setRootObject(QObject *obj)
<< "loaded has 'import QtQuick 1.0' or 'import Qt 4.7', this error will occur." << endl
<< endl
<< "To load files with 'import QtQuick 1.0' or 'import Qt 4.7', use the" << endl
- << "QDeclarativeView class in the qtquick1 module." << endl;
+ << "QQuickView class in the qtquick1 module." << endl;
delete obj;
root = 0;
}
@@ -499,35 +499,35 @@ void QQuickView::resizeEvent(QResizeEvent *e)
void QQuickView::keyPressEvent(QKeyEvent *e)
{
- QDeclarativeProfilerService::addEvent(QDeclarativeProfilerService::Key);
+ QQmlProfilerService::addEvent(QQmlProfilerService::Key);
QQuickCanvas::keyPressEvent(e);
}
void QQuickView::keyReleaseEvent(QKeyEvent *e)
{
- QDeclarativeProfilerService::addEvent(QDeclarativeProfilerService::Key);
+ QQmlProfilerService::addEvent(QQmlProfilerService::Key);
QQuickCanvas::keyReleaseEvent(e);
}
void QQuickView::mouseMoveEvent(QMouseEvent *e)
{
- QDeclarativeProfilerService::addEvent(QDeclarativeProfilerService::Mouse);
+ QQmlProfilerService::addEvent(QQmlProfilerService::Mouse);
QQuickCanvas::mouseMoveEvent(e);
}
void QQuickView::mousePressEvent(QMouseEvent *e)
{
- QDeclarativeProfilerService::addEvent(QDeclarativeProfilerService::Mouse);
+ QQmlProfilerService::addEvent(QQmlProfilerService::Mouse);
QQuickCanvas::mousePressEvent(e);
}
void QQuickView::mouseReleaseEvent(QMouseEvent *e)
{
- QDeclarativeProfilerService::addEvent(QDeclarativeProfilerService::Mouse);
+ QQmlProfilerService::addEvent(QQmlProfilerService::Mouse);
QQuickCanvas::mouseReleaseEvent(e);
}
diff --git a/src/quick/items/qquickview.h b/src/quick/items/qquickview.h
index 6f1b1f12cd..89cca506f7 100644
--- a/src/quick/items/qquickview.h
+++ b/src/quick/items/qquickview.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,15 +44,15 @@
#include <QtQuick/qquickcanvas.h>
#include <QtCore/qurl.h>
-#include <QtDeclarative/qdeclarativedebug.h>
+#include <QtQml/qqmldebug.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QDeclarativeEngine;
-class QDeclarativeContext;
-class QDeclarativeError;
+class QQmlEngine;
+class QQmlContext;
+class QQmlError;
class QQuickItem;
class QQuickViewPrivate;
@@ -70,8 +70,8 @@ public:
QUrl source() const;
- QDeclarativeEngine* engine() const;
- QDeclarativeContext* rootContext() const;
+ QQmlEngine* engine() const;
+ QQmlContext* rootContext() const;
QQuickItem *rootObject() const;
@@ -82,7 +82,7 @@ public:
enum Status { Null, Ready, Loading, Error };
Status status() const;
- QList<QDeclarativeError> errors() const;
+ QList<QQmlError> errors() const;
QSize sizeHint() const;
QSize initialSize() const;
diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h
index 1dacf2f1ee..9b0e26e30d 100644
--- a/src/quick/items/qquickview_p.h
+++ b/src/quick/items/qquickview_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -48,7 +48,7 @@
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qtimer.h>
#include <QtCore/qpointer.h>
-#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtQml/qqmlengine.h>
#include "qquickcanvas_p.h"
#include "qquickitemchangelistener_p.h"
@@ -57,10 +57,10 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QDeclarativeContext;
-class QDeclarativeError;
+class QQmlContext;
+class QQmlError;
class QQuickItem;
-class QDeclarativeComponent;
+class QQmlComponent;
class QQuickViewPrivate : public QQuickCanvasPrivate,
public QQuickItemChangeListener
@@ -87,8 +87,8 @@ public:
QUrl source;
- QDeclarativeEngine engine;
- QDeclarativeComponent *component;
+ QQmlEngine engine;
+ QQmlComponent *component;
QBasicTimer resizetimer;
QQuickView::ResizeMode resizeMode;
diff --git a/src/quick/items/qquickvisualadaptormodel.cpp b/src/quick/items/qquickvisualadaptormodel.cpp
index f504478a3d..fb85810984 100644
--- a/src/quick/items/qquickvisualadaptormodel.cpp
+++ b/src/quick/items/qquickvisualadaptormodel.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,9 +42,9 @@
#include "qquickvisualadaptormodel_p.h"
#include "qquickvisualdatamodel_p_p.h"
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativelistaccessor_p.h>
-#include <private/qdeclarativepropertycache_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qquicklistaccessor_p.h>
+#include <private/qqmlpropertycache_p.h>
#include <private/qlistmodelinterface_p.h>
#include <private/qmetaobjectbuilder_p.h>
#include <private/qintrusivelist_p.h>
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
-class VDMDelegateDataType : public QDeclarativeRefCount
+class VDMDelegateDataType : public QQmlRefCount
{
public:
VDMDelegateDataType()
@@ -86,7 +86,7 @@ public:
}
QMetaObject *metaObject;
- QDeclarativePropertyCache *propertyCache;
+ QQmlPropertyCache *propertyCache;
int propertyOffset;
int signalOffset;
bool shared : 1;
@@ -166,10 +166,10 @@ public:
return 0;
}
- QDeclarativeGuard<QDeclarativeEngine> m_engine;
- QDeclarativeGuard<QListModelInterface> m_listModelInterface;
- QDeclarativeGuard<QAbstractItemModel> m_abstractItemModel;
- QDeclarativeListAccessor *m_listAccessor;
+ QQmlGuard<QQmlEngine> m_engine;
+ QQmlGuard<QListModelInterface> m_listModelInterface;
+ QQmlGuard<QAbstractItemModel> m_abstractItemModel;
+ QQuickListAccessor *m_listAccessor;
VDMDelegateDataType *m_delegateDataType;
CreateModelData createItem;
StringValue stringValue;
@@ -650,7 +650,7 @@ public:
for (int i = previousPropertyCount; i < metaObject->propertyCount() - objectPropertyOffset; ++i) {
QMetaProperty property = metaObject->property(i + objectPropertyOffset);
if (property.hasNotifySignal()) {
- QDeclarativePropertyPrivate::connect(
+ QQmlPropertyPrivate::connect(
m_object, property.notifySignalIndex(), m_data, notifierId);
++notifierId;
}
@@ -658,7 +658,7 @@ public:
return propertyIndex + m_type->propertyOffset - objectPropertyOffset;
}
- QDeclarativeGuard<QObject> m_object;
+ QQmlGuard<QObject> m_object;
};
class QQuickVDMObjectData : public QQuickVisualDataModelItem, public QQuickVisualAdaptorModelProxyInterface
@@ -712,7 +712,7 @@ void QQuickVisualAdaptorModelPrivate::createMetaObject()
m_objectList = false;
m_propertyData.clear();
- QV8Engine *v8Engine = QDeclarativeEnginePrivate::getV8Engine(m_engine);
+ QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(m_engine);
v8::HandleScope handleScope;
v8::Context::Scope contextScope(v8Engine->context());
@@ -722,8 +722,8 @@ void QQuickVisualAdaptorModelPrivate::createMetaObject()
v8::String::New("index"), QQuickVisualDataModelItemMetaObject::get_index);
if (m_listAccessor
- && m_listAccessor->type() != QDeclarativeListAccessor::ListProperty
- && m_listAccessor->type() != QDeclarativeListAccessor::Instance) {
+ && m_listAccessor->type() != QQuickListAccessor::ListProperty
+ && m_listAccessor->type() != QQuickListAccessor::Instance) {
createItem = &QQuickVDMListAccessorData::create;
stringValue = &QQuickVDMListAccessorData::stringValue;
ft->PrototypeTemplate()->SetAccessor(
@@ -794,7 +794,7 @@ void QQuickVisualAdaptorModelPrivate::createMetaObject()
}
m_delegateDataType->metaObject = m_delegateDataType->builder.toMetaObject();
if (!m_objectList) {
- m_delegateDataType->propertyCache = new QDeclarativePropertyCache(
+ m_delegateDataType->propertyCache = new QQmlPropertyCache(
m_engine, m_delegateDataType->metaObject);
m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
@@ -828,7 +828,7 @@ QVariant QQuickVisualAdaptorModel::model() const
return d->m_modelVariant;
}
-void QQuickVisualAdaptorModel::setModel(const QVariant &model, QDeclarativeEngine *engine)
+void QQuickVisualAdaptorModel::setModel(const QVariant &model, QQmlEngine *engine)
{
Q_D(QQuickVisualAdaptorModel);
delete d->m_listAccessor;
@@ -904,7 +904,7 @@ void QQuickVisualAdaptorModel::setModel(const QVariant &model, QDeclarativeEngin
return;
}
- d->m_listAccessor = new QDeclarativeListAccessor;
+ d->m_listAccessor = new QQuickListAccessor;
d->m_listAccessor->setList(model, d->m_engine);
if ((d->m_count = d->m_listAccessor->count()))
emit itemsInserted(0, d->m_count);
@@ -964,7 +964,7 @@ QQuickVisualDataModelItem *QQuickVisualAdaptorModel::createItem(QQuickVisualData
d->m_cache.insert(item);
if (d->m_delegateDataType && d->m_delegateDataType->propertyCache) {
- QDeclarativeData *qmldata = QDeclarativeData::get(item, true);
+ QQmlData *qmldata = QQmlData::get(item, true);
qmldata->propertyCache = d->m_delegateDataType->propertyCache;
qmldata->propertyCache->addref();
}
diff --git a/src/quick/items/qquickvisualadaptormodel_p.h b/src/quick/items/qquickvisualadaptormodel_p.h
index e431f3aa26..cf6dabe237 100644
--- a/src/quick/items/qquickvisualadaptormodel_p.h
+++ b/src/quick/items/qquickvisualadaptormodel_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -49,7 +49,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QDeclarativeEngine;
+class QQmlEngine;
class QQuickVisualDataModelItem;
class QQuickVisualDataModelItemMetaType;
@@ -72,7 +72,7 @@ public:
Flags flags() const;
QVariant model() const;
- void setModel(const QVariant &, QDeclarativeEngine *);
+ void setModel(const QVariant &, QQmlEngine *);
QVariant rootIndex() const;
void setRootIndex(const QVariant &root);
diff --git a/src/quick/items/qquickvisualdatamodel.cpp b/src/quick/items/qquickvisualdatamodel.cpp
index 3aa6077d32..70f8897b2d 100644
--- a/src/quick/items/qquickvisualdatamodel.cpp
+++ b/src/quick/items/qquickvisualdatamodel.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,13 +42,13 @@
#include "qquickvisualdatamodel_p_p.h"
#include "qquickitem.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
-#include <private/qdeclarativepackage_p.h>
+#include <private/qquickpackage_p.h>
#include <private/qmetaobjectbuilder_p.h>
#include <private/qquickvisualadaptormodel_p.h>
-#include <private/qdeclarativechangeset_p.h>
-#include <private/qdeclarativeengine_p.h>
+#include <private/qquickchangeset_p.h>
+#include <private/qqmlengine_p.h>
QT_BEGIN_NAMESPACE
@@ -93,10 +93,10 @@ QHash<QObject*, QQuickVisualDataModelAttached*> QQuickVisualDataModelAttached::a
The example below illustrates using a VisualDataModel with a ListView.
- \snippet doc/src/snippets/declarative/visualdatamodel.qml 0
+ \snippet doc/src/snippets/qml/visualdatamodel.qml 0
*/
-QQuickVisualDataModelPrivate::QQuickVisualDataModelPrivate(QDeclarativeContext *ctxt)
+QQuickVisualDataModelPrivate::QQuickVisualDataModelPrivate(QQmlContext *ctxt)
: m_adaptorModel(0)
, m_delegate(0)
, m_cacheMetaType(0)
@@ -153,7 +153,7 @@ QQuickVisualDataModel::QQuickVisualDataModel()
d->init();
}
-QQuickVisualDataModel::QQuickVisualDataModel(QDeclarativeContext *ctxt, QObject *parent)
+QQuickVisualDataModel::QQuickVisualDataModel(QQmlContext *ctxt, QObject *parent)
: QQuickVisualModel(*(new QQuickVisualDataModelPrivate(ctxt)), parent)
{
Q_D(QQuickVisualDataModel);
@@ -223,7 +223,7 @@ void QQuickVisualDataModel::componentComplete()
d->m_context = qmlContext(this);
d->m_cacheMetaType = new QQuickVisualDataModelItemMetaType(
- QDeclarativeEnginePrivate::getV8Engine(d->m_context->engine()), this, groupNames);
+ QQmlEnginePrivate::getV8Engine(d->m_context->engine()), this, groupNames);
d->m_compositor.setGroupCount(d->m_groupCount);
d->m_compositor.setDefaultGroups(defaultGroups);
@@ -282,13 +282,13 @@ void QQuickVisualDataModel::setModel(const QVariant &model)
The index is exposed as an accessible \c index property. Properties of the
model are also available depending upon the type of \l {qmlmodels}{Data Model}.
*/
-QDeclarativeComponent *QQuickVisualDataModel::delegate() const
+QQmlComponent *QQuickVisualDataModel::delegate() const
{
Q_D(const QQuickVisualDataModel);
return d->m_delegate;
}
-void QQuickVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
+void QQuickVisualDataModel::setDelegate(QQmlComponent *delegate)
{
Q_D(QQuickVisualDataModel);
if (d->m_transaction) {
@@ -329,10 +329,10 @@ void QQuickVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
the new directory's contents.
\c main.cpp:
- \snippet doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp 0
+ \snippet doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp 0
\c view.qml:
- \snippet doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml 0
+ \snippet doc/src/snippets/qml/visualdatamodel_rootindex/view.qml 0
If the \l model is a QAbstractItemModel subclass, the delegate can also
reference a \c hasModelChildren property (optionally qualified by a
@@ -406,7 +406,7 @@ void QQuickVisualDataModelPrivate::destroy(QObject *object)
{
QObjectPrivate *p = QObjectPrivate::get(object);
Q_ASSERT(p->declarativeData);
- QDeclarativeData *data = static_cast<QDeclarativeData*>(p->declarativeData);
+ QQmlData *data = static_cast<QQmlData*>(p->declarativeData);
if (data->ownContext && data->context)
data->context->clearContext();
object->deleteLater();
@@ -470,7 +470,7 @@ void QQuickVisualDataModel::cancel(int index)
}
if (cacheItem->object && !cacheItem->isObjectReferenced()) {
d->destroy(cacheItem->object);
- if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(cacheItem->object))
+ if (QQuickPackage *package = qobject_cast<QQuickPackage *>(cacheItem->object))
d->emitDestroyingPackage(package);
else if (QQuickItem *item = qobject_cast<QQuickItem *>(cacheItem->object))
d->emitDestroyingItem(item);
@@ -486,7 +486,7 @@ void QQuickVisualDataModel::cancel(int index)
}
void QQuickVisualDataModelPrivate::group_append(
- QDeclarativeListProperty<QQuickVisualDataGroup> *property, QQuickVisualDataGroup *group)
+ QQmlListProperty<QQuickVisualDataGroup> *property, QQuickVisualDataGroup *group)
{
QQuickVisualDataModelPrivate *d = static_cast<QQuickVisualDataModelPrivate *>(property->data);
if (d->m_complete)
@@ -500,14 +500,14 @@ void QQuickVisualDataModelPrivate::group_append(
}
int QQuickVisualDataModelPrivate::group_count(
- QDeclarativeListProperty<QQuickVisualDataGroup> *property)
+ QQmlListProperty<QQuickVisualDataGroup> *property)
{
QQuickVisualDataModelPrivate *d = static_cast<QQuickVisualDataModelPrivate *>(property->data);
return d->m_groupCount - 1;
}
QQuickVisualDataGroup *QQuickVisualDataModelPrivate::group_at(
- QDeclarativeListProperty<QQuickVisualDataGroup> *property, int index)
+ QQmlListProperty<QQuickVisualDataGroup> *property, int index)
{
QQuickVisualDataModelPrivate *d = static_cast<QQuickVisualDataModelPrivate *>(property->data);
return index >= 0 && index < d->m_groupCount - 1
@@ -530,13 +530,13 @@ QQuickVisualDataGroup *QQuickVisualDataModelPrivate::group_at(
The following example illustrates using groups to select items in a model.
- \snippet doc/src/snippets/declarative/visualdatagroup.qml 0
+ \snippet doc/src/snippets/qml/visualdatagroup.qml 0
*/
-QDeclarativeListProperty<QQuickVisualDataGroup> QQuickVisualDataModel::groups()
+QQmlListProperty<QQuickVisualDataGroup> QQuickVisualDataModel::groups()
{
Q_D(QQuickVisualDataModel);
- return QDeclarativeListProperty<QQuickVisualDataGroup>(
+ return QQmlListProperty<QQuickVisualDataGroup>(
this,
d,
QQuickVisualDataModelPrivate::group_append,
@@ -622,7 +622,7 @@ void QQuickVisualDataModelPrivate::updateFilterGroup()
if (!m_cacheMetaType)
return;
- QDeclarativeListCompositor::Group previousGroup = m_compositorGroup;
+ QQuickListCompositor::Group previousGroup = m_compositorGroup;
m_compositorGroup = Compositor::Default;
for (int i = 1; i < m_groupCount; ++i) {
if (m_filterGroup == m_cacheMetaType->groupNames.at(i - 1)) {
@@ -633,11 +633,11 @@ void QQuickVisualDataModelPrivate::updateFilterGroup()
QQuickVisualDataGroupPrivate::get(m_groups[m_compositorGroup])->emitters.insert(this);
if (m_compositorGroup != previousGroup) {
- QVector<QDeclarativeChangeSet::Remove> removes;
- QVector<QDeclarativeChangeSet::Insert> inserts;
+ QVector<QQuickChangeSet::Remove> removes;
+ QVector<QQuickChangeSet::Insert> inserts;
m_compositor.transition(previousGroup, m_compositorGroup, &removes, &inserts);
- QDeclarativeChangeSet changeSet;
+ QQuickChangeSet changeSet;
changeSet.apply(removes, inserts);
emit q->modelUpdated(changeSet, false);
@@ -687,19 +687,19 @@ QObject *QQuickVisualDataModel::parts()
return d->m_parts;
}
-void QQuickVisualDataModelPrivate::emitCreatedPackage(QQuickVisualDataModelItem *cacheItem, QDeclarativePackage *package)
+void QQuickVisualDataModelPrivate::emitCreatedPackage(QQuickVisualDataModelItem *cacheItem, QQuickPackage *package)
{
for (int i = 1; i < m_groupCount; ++i)
QQuickVisualDataGroupPrivate::get(m_groups[i])->createdPackage(cacheItem->index[i], package);
}
-void QQuickVisualDataModelPrivate::emitInitPackage(QQuickVisualDataModelItem *cacheItem, QDeclarativePackage *package)
+void QQuickVisualDataModelPrivate::emitInitPackage(QQuickVisualDataModelItem *cacheItem, QQuickPackage *package)
{
for (int i = 1; i < m_groupCount; ++i)
QQuickVisualDataGroupPrivate::get(m_groups[i])->initPackage(cacheItem->index[i], package);
}
-void QQuickVisualDataModelPrivate::emitDestroyingPackage(QDeclarativePackage *package)
+void QQuickVisualDataModelPrivate::emitDestroyingPackage(QQuickPackage *package)
{
for (int i = 1; i < m_groupCount; ++i)
QQuickVisualDataGroupPrivate::get(m_groups[i])->destroyingPackage(package);
@@ -722,23 +722,23 @@ void QQuickVisualDataModelPrivate::releaseIncubator(QVDMIncubationTask *incubati
}
}
-void QQuickVisualDataModelPrivate::incubatorStatusChanged(QVDMIncubationTask *incubationTask, QDeclarativeIncubator::Status status)
+void QQuickVisualDataModelPrivate::incubatorStatusChanged(QVDMIncubationTask *incubationTask, QQmlIncubator::Status status)
{
Q_Q(QQuickVisualDataModel);
- if (status != QDeclarativeIncubator::Ready && status != QDeclarativeIncubator::Error)
+ if (status != QQmlIncubator::Ready && status != QQmlIncubator::Error)
return;
QQuickVisualDataModelItem *cacheItem = incubationTask->incubating;
cacheItem->incubationTask = 0;
- if (status == QDeclarativeIncubator::Ready) {
+ if (status == QQmlIncubator::Ready) {
incubationTask->incubating = 0;
releaseIncubator(incubationTask);
- if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(cacheItem->object))
+ if (QQuickPackage *package = qobject_cast<QQuickPackage *>(cacheItem->object))
emitCreatedPackage(cacheItem, package);
else if (QQuickItem *item = qobject_cast<QQuickItem *>(cacheItem->object))
emitCreatedItem(cacheItem, item);
- } else if (status == QDeclarativeIncubator::Error) {
+ } else if (status == QQmlIncubator::Error) {
delete incubationTask->incubatingContext;
incubationTask->incubatingContext = 0;
if (!cacheItem->isReferenced()) {
@@ -764,7 +764,7 @@ void QQuickVisualDataModelPrivate::setInitialState(QVDMIncubationTask *incubatio
{
QQuickVisualDataModelItem *cacheItem = incubationTask->incubating;
cacheItem->object = o;
- QDeclarative_setParent_noEvent(incubationTask->incubatingContext, cacheItem->object);
+ QQml_setParent_noEvent(incubationTask->incubatingContext, cacheItem->object);
incubationTask->incubatingContext = 0;
cacheItem->attached = QQuickVisualDataModelAttached::properties(cacheItem->object);
@@ -772,7 +772,7 @@ void QQuickVisualDataModelPrivate::setInitialState(QVDMIncubationTask *incubatio
new QQuickVisualDataModelAttachedMetaObject(cacheItem->attached, m_cacheMetaType);
cacheItem->attached->emitChanges();
- if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(cacheItem->object))
+ if (QQuickPackage *package = qobject_cast<QQuickPackage *>(cacheItem->object))
emitInitPackage(cacheItem, package);
else if (QQuickItem *item = qobject_cast<QQuickItem *>(cacheItem->object))
emitInitItem(cacheItem, item);
@@ -808,13 +808,13 @@ QObject *QQuickVisualDataModelPrivate::object(Compositor::Group group, int index
cacheItem->incubationTask->forceCompletion();
}
} else if (!cacheItem->object) {
- QVDMIncubationTask *incubator = new QVDMIncubationTask(this, asynchronous ? QDeclarativeIncubator::Asynchronous : QDeclarativeIncubator::AsynchronousIfNested);
+ QVDMIncubationTask *incubator = new QVDMIncubationTask(this, asynchronous ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested);
cacheItem->incubationTask = incubator;
- QDeclarativeContext *creationContext = m_delegate->creationContext();
- QDeclarativeContext *rootContext = new QQuickVisualDataModelContext(
+ QQmlContext *creationContext = m_delegate->creationContext();
+ QQmlContext *rootContext = new QQuickVisualDataModelContext(
cacheItem, creationContext ? creationContext : m_context.data());
- QDeclarativeContext *ctxt = rootContext;
+ QQmlContext *ctxt = rootContext;
if (m_adaptorModel->flags() & QQuickVisualAdaptorModel::ProxiedObject) {
if (QQuickVisualAdaptorModelProxyInterface *proxy = qobject_cast<QQuickVisualAdaptorModelProxyInterface *>(cacheItem)) {
ctxt->setContextObject(proxy->proxiedObject());
@@ -950,13 +950,13 @@ void QQuickVisualDataModelPrivate::itemsChanged(const QVector<Compositor::Change
if (!m_delegate)
return;
- QVarLengthArray<QVector<QDeclarativeChangeSet::Change>, Compositor::MaximumGroupCount> translatedChanges(m_groupCount);
+ QVarLengthArray<QVector<QQuickChangeSet::Change>, Compositor::MaximumGroupCount> translatedChanges(m_groupCount);
foreach (const Compositor::Change &change, changes) {
for (int i = 1; i < m_groupCount; ++i) {
if (change.inGroup(i)) {
translatedChanges[i].append(
- QDeclarativeChangeSet::Change(change.index[i], change.count));
+ QQuickChangeSet::Change(change.index[i], change.count));
}
}
}
@@ -978,7 +978,7 @@ void QQuickVisualDataModel::_q_itemsChanged(int index, int count)
void QQuickVisualDataModelPrivate::itemsInserted(
const QVector<Compositor::Insert> &inserts,
- QVarLengthArray<QVector<QDeclarativeChangeSet::Insert>, Compositor::MaximumGroupCount> *translatedInserts,
+ QVarLengthArray<QVector<QQuickChangeSet::Insert>, Compositor::MaximumGroupCount> *translatedInserts,
QHash<int, QList<QQuickVisualDataModelItem *> > *movedItems)
{
int cacheIndex = 0;
@@ -996,7 +996,7 @@ void QQuickVisualDataModelPrivate::itemsInserted(
for (int i = 1; i < m_groupCount; ++i) {
if (insert.inGroup(i)) {
(*translatedInserts)[i].append(
- QDeclarativeChangeSet::Insert(insert.index[i], insert.count, insert.moveId));
+ QQuickChangeSet::Insert(insert.index[i], insert.count, insert.moveId));
inserted[i] += insert.count;
}
}
@@ -1032,7 +1032,7 @@ void QQuickVisualDataModelPrivate::itemsInserted(
void QQuickVisualDataModelPrivate::itemsInserted(const QVector<Compositor::Insert> &inserts)
{
- QVarLengthArray<QVector<QDeclarativeChangeSet::Insert>, Compositor::MaximumGroupCount> translatedInserts(m_groupCount);
+ QVarLengthArray<QVector<QQuickChangeSet::Insert>, Compositor::MaximumGroupCount> translatedInserts(m_groupCount);
itemsInserted(inserts, &translatedInserts);
Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
if (!m_delegate)
@@ -1056,7 +1056,7 @@ void QQuickVisualDataModel::_q_itemsInserted(int index, int count)
void QQuickVisualDataModelPrivate::itemsRemoved(
const QVector<Compositor::Remove> &removes,
- QVarLengthArray<QVector<QDeclarativeChangeSet::Remove>, Compositor::MaximumGroupCount> *translatedRemoves,
+ QVarLengthArray<QVector<QQuickChangeSet::Remove>, Compositor::MaximumGroupCount> *translatedRemoves,
QHash<int, QList<QQuickVisualDataModelItem *> > *movedItems)
{
int cacheIndex = 0;
@@ -1075,7 +1075,7 @@ void QQuickVisualDataModelPrivate::itemsRemoved(
for (int i = 1; i < m_groupCount; ++i) {
if (remove.inGroup(i)) {
(*translatedRemoves)[i].append(
- QDeclarativeChangeSet::Remove(remove.index[i], remove.count, remove.moveId));
+ QQuickChangeSet::Remove(remove.index[i], remove.count, remove.moveId));
removed[i] += remove.count;
}
}
@@ -1093,7 +1093,7 @@ void QQuickVisualDataModelPrivate::itemsRemoved(
QQuickVisualDataModelItem *cacheItem = m_cache.at(cacheIndex);
if (remove.inGroup(Compositor::Persisted) && cacheItem->objectRef == 0 && cacheItem->object) {
destroy(cacheItem->object);
- if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(cacheItem->object))
+ if (QQuickPackage *package = qobject_cast<QQuickPackage *>(cacheItem->object))
emitDestroyingPackage(package);
else if (QQuickItem *item = qobject_cast<QQuickItem *>(cacheItem->object))
emitDestroyingItem(item);
@@ -1130,7 +1130,7 @@ void QQuickVisualDataModelPrivate::itemsRemoved(
void QQuickVisualDataModelPrivate::itemsRemoved(const QVector<Compositor::Remove> &removes)
{
- QVarLengthArray<QVector<QDeclarativeChangeSet::Remove>, Compositor::MaximumGroupCount> translatedRemoves(m_groupCount);
+ QVarLengthArray<QVector<QQuickChangeSet::Remove>, Compositor::MaximumGroupCount> translatedRemoves(m_groupCount);
itemsRemoved(removes, &translatedRemoves);
Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
if (!m_delegate)
@@ -1158,10 +1158,10 @@ void QQuickVisualDataModelPrivate::itemsMoved(
{
QHash<int, QList<QQuickVisualDataModelItem *> > movedItems;
- QVarLengthArray<QVector<QDeclarativeChangeSet::Remove>, Compositor::MaximumGroupCount> translatedRemoves(m_groupCount);
+ QVarLengthArray<QVector<QQuickChangeSet::Remove>, Compositor::MaximumGroupCount> translatedRemoves(m_groupCount);
itemsRemoved(removes, &translatedRemoves, &movedItems);
- QVarLengthArray<QVector<QDeclarativeChangeSet::Insert>, Compositor::MaximumGroupCount> translatedInserts(m_groupCount);
+ QVarLengthArray<QVector<QQuickChangeSet::Insert>, Compositor::MaximumGroupCount> translatedInserts(m_groupCount);
itemsInserted(inserts, &translatedInserts, &movedItems);
Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
Q_ASSERT(movedItems.isEmpty());
@@ -1206,7 +1206,7 @@ QQuickVisualDataModelPrivate::buildChangeList(const QVector<T> &changes)
return indexes;
}
-void QQuickVisualDataModelPrivate::emitModelUpdated(const QDeclarativeChangeSet &changeSet, bool reset)
+void QQuickVisualDataModelPrivate::emitModelUpdated(const QQuickChangeSet &changeSet, bool reset)
{
Q_Q(QQuickVisualDataModel);
emit q->modelUpdated(changeSet, reset);
@@ -1220,7 +1220,7 @@ void QQuickVisualDataModelPrivate::emitChanges()
return;
m_transaction = true;
- QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(m_context->engine());
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(m_context->engine());
for (int i = 1; i < m_groupCount; ++i)
QQuickVisualDataGroupPrivate::get(m_groups[i])->emitChanges(engine);
m_transaction = false;
@@ -1751,14 +1751,14 @@ void QQuickVisualDataGroupPrivate::setModel(QQuickVisualDataModel *m, Compositor
void QQuickVisualDataGroupPrivate::emitChanges(QV8Engine *engine)
{
Q_Q(QQuickVisualDataGroup);
- static int idx = signalIndex("changed(QDeclarativeV8Handle,QDeclarativeV8Handle)");
+ static int idx = signalIndex("changed(QQmlV8Handle,QQmlV8Handle)");
if (isSignalConnected(idx) && !changeSet.isEmpty()) {
v8::HandleScope handleScope;
v8::Context::Scope contextScope(engine->context());
v8::Local<v8::Array> removed = QQuickVisualDataModelPrivate::buildChangeList(changeSet.removes());
v8::Local<v8::Array> inserted = QQuickVisualDataModelPrivate::buildChangeList(changeSet.inserts());
emit q->changed(
- QDeclarativeV8Handle::fromHandle(removed), QDeclarativeV8Handle::fromHandle(inserted));
+ QQmlV8Handle::fromHandle(removed), QQmlV8Handle::fromHandle(inserted));
}
if (changeSet.difference() != 0)
emit q->countChanged();
@@ -1771,19 +1771,19 @@ void QQuickVisualDataGroupPrivate::emitModelUpdated(bool reset)
changeSet.clear();
}
-void QQuickVisualDataGroupPrivate::createdPackage(int index, QDeclarativePackage *package)
+void QQuickVisualDataGroupPrivate::createdPackage(int index, QQuickPackage *package)
{
for (QQuickVisualDataGroupEmitterList::iterator it = emitters.begin(); it != emitters.end(); ++it)
it->createdPackage(index, package);
}
-void QQuickVisualDataGroupPrivate::initPackage(int index, QDeclarativePackage *package)
+void QQuickVisualDataGroupPrivate::initPackage(int index, QQuickPackage *package)
{
for (QQuickVisualDataGroupEmitterList::iterator it = emitters.begin(); it != emitters.end(); ++it)
it->initPackage(index, package);
}
-void QQuickVisualDataGroupPrivate::destroyingPackage(QDeclarativePackage *package)
+void QQuickVisualDataGroupPrivate::destroyingPackage(QQuickPackage *package)
{
for (QQuickVisualDataGroupEmitterList::iterator it = emitters.begin(); it != emitters.end(); ++it)
it->destroyingPackage(package);
@@ -1904,16 +1904,16 @@ void QQuickVisualDataGroup::setDefaultInclude(bool include)
\endlist
*/
-QDeclarativeV8Handle QQuickVisualDataGroup::get(int index)
+QQmlV8Handle QQuickVisualDataGroup::get(int index)
{
Q_D(QQuickVisualDataGroup);
if (!d->model)
- return QDeclarativeV8Handle::fromHandle(v8::Undefined());;
+ return QQmlV8Handle::fromHandle(v8::Undefined());;
QQuickVisualDataModelPrivate *model = QQuickVisualDataModelPrivate::get(d->model);
if (index < 0 || index >= model->m_compositor.count(d->group)) {
qmlInfo(this) << tr("get: index out of range");
- return QDeclarativeV8Handle::fromHandle(v8::Undefined());
+ return QQmlV8Handle::fromHandle(v8::Undefined());
}
Compositor::iterator it = model->m_compositor.find(d->group, index);
@@ -1939,7 +1939,7 @@ QDeclarativeV8Handle QQuickVisualDataGroup::get(int index)
++cacheItem->scriptRef;
}
- return QDeclarativeV8Handle::fromHandle(cacheItem->indexHandle);
+ return QQmlV8Handle::fromHandle(cacheItem->indexHandle);
}
bool QQuickVisualDataGroupPrivate::parseIndex(
@@ -1962,7 +1962,7 @@ bool QQuickVisualDataGroupPrivate::parseIndex(
return false;
}
-void QQuickVisualDataGroup::insert(QDeclarativeV8Function *args)
+void QQuickVisualDataGroup::insert(QQmlV8Function *args)
{
Q_D(QQuickVisualDataGroup);
QQuickVisualDataModelPrivate *model = QQuickVisualDataModelPrivate::get(d->model);
@@ -2012,7 +2012,7 @@ void QQuickVisualDataGroup::insert(QDeclarativeV8Function *args)
group remain instantiated when not referenced by any view.
*/
-void QQuickVisualDataGroup::create(QDeclarativeV8Function *args)
+void QQuickVisualDataGroup::create(QQmlV8Function *args)
{
Q_D(QQuickVisualDataGroup);
if (!d->model)
@@ -2067,7 +2067,7 @@ void QQuickVisualDataGroup::create(QDeclarativeV8Function *args)
model->emitChanges();
}
-void QQuickVisualDataGroup::resolve(QDeclarativeV8Function *args)
+void QQuickVisualDataGroup::resolve(QQmlV8Function *args)
{
Q_D(QQuickVisualDataGroup);
if (!d->model)
@@ -2167,7 +2167,7 @@ void QQuickVisualDataGroup::resolve(QDeclarativeV8Function *args)
Removes \a count items starting at \a index from the group.
*/
-void QQuickVisualDataGroup::remove(QDeclarativeV8Function *args)
+void QQuickVisualDataGroup::remove(QQmlV8Function *args)
{
Q_D(QQuickVisualDataGroup);
if (!d->model)
@@ -2206,7 +2206,7 @@ void QQuickVisualDataGroup::remove(QDeclarativeV8Function *args)
}
bool QQuickVisualDataGroupPrivate::parseGroupArgs(
- QDeclarativeV8Function *args, Compositor::Group *group, int *index, int *count, int *groups) const
+ QQmlV8Function *args, Compositor::Group *group, int *index, int *count, int *groups) const
{
if (!model || !QQuickVisualDataModelPrivate::get(model)->m_cacheMetaType)
return false;
@@ -2239,7 +2239,7 @@ bool QQuickVisualDataGroupPrivate::parseGroupArgs(
Adds \a count items starting at \a index to \a groups.
*/
-void QQuickVisualDataGroup::addGroups(QDeclarativeV8Function *args)
+void QQuickVisualDataGroup::addGroups(QQmlV8Function *args)
{
Q_D(QQuickVisualDataGroup);
Compositor::Group group = d->group;
@@ -2269,7 +2269,7 @@ void QQuickVisualDataGroup::addGroups(QDeclarativeV8Function *args)
Removes \a count items starting at \a index from \a groups.
*/
-void QQuickVisualDataGroup::removeGroups(QDeclarativeV8Function *args)
+void QQuickVisualDataGroup::removeGroups(QQmlV8Function *args)
{
Q_D(QQuickVisualDataGroup);
Compositor::Group group = d->group;
@@ -2299,7 +2299,7 @@ void QQuickVisualDataGroup::removeGroups(QDeclarativeV8Function *args)
Sets the \a groups \a count items starting at \a index belong to.
*/
-void QQuickVisualDataGroup::setGroups(QDeclarativeV8Function *args)
+void QQuickVisualDataGroup::setGroups(QQmlV8Function *args)
{
Q_D(QQuickVisualDataGroup);
Compositor::Group group = d->group;
@@ -2335,7 +2335,7 @@ void QQuickVisualDataGroup::setGroups(QDeclarativeV8Function *args)
Moves \a count at \a from in a group \a to a new position.
*/
-void QQuickVisualDataGroup::move(QDeclarativeV8Function *args)
+void QQuickVisualDataGroup::move(QQmlV8Function *args)
{
Q_D(QQuickVisualDataGroup);
@@ -2461,7 +2461,7 @@ void QQuickVisualPartsModel::updateFilterGroup()
m_filterGroup = model->m_filterGroup;
}
- QDeclarativeListCompositor::Group previousGroup = m_compositorGroup;
+ QQuickListCompositor::Group previousGroup = m_compositorGroup;
m_compositorGroup = Compositor::Default;
QQuickVisualDataGroupPrivate::get(model->m_groups[Compositor::Default])->emitters.insert(this);
for (int i = 1; i < model->m_groupCount; ++i) {
@@ -2473,11 +2473,11 @@ void QQuickVisualPartsModel::updateFilterGroup()
QQuickVisualDataGroupPrivate::get(model->m_groups[m_compositorGroup])->emitters.insert(this);
if (m_compositorGroup != previousGroup) {
- QVector<QDeclarativeChangeSet::Remove> removes;
- QVector<QDeclarativeChangeSet::Insert> inserts;
+ QVector<QQuickChangeSet::Remove> removes;
+ QVector<QQuickChangeSet::Insert> inserts;
model->m_compositor.transition(previousGroup, m_compositorGroup, &removes, &inserts);
- QDeclarativeChangeSet changeSet;
+ QQuickChangeSet changeSet;
changeSet.apply(removes, inserts);
if (!changeSet.isEmpty())
emit modelUpdated(changeSet, false);
@@ -2488,7 +2488,7 @@ void QQuickVisualPartsModel::updateFilterGroup()
}
void QQuickVisualPartsModel::updateFilterGroup(
- Compositor::Group group, const QDeclarativeChangeSet &changeSet)
+ Compositor::Group group, const QQuickChangeSet &changeSet)
{
if (!m_inheritGroup)
return;
@@ -2529,7 +2529,7 @@ QQuickItem *QQuickVisualPartsModel::item(int index, bool asynchronous)
QObject *object = model->object(m_compositorGroup, index, asynchronous, true);
- if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(object)) {
+ if (QQuickPackage *package = qobject_cast<QQuickPackage *>(object)) {
QObject *part = package->part(m_part);
if (!part)
return 0;
@@ -2553,10 +2553,10 @@ QQuickVisualModel::ReleaseFlags QQuickVisualPartsModel::release(QQuickItem *item
{
QQuickVisualModel::ReleaseFlags flags = 0;
- QHash<QObject *, QDeclarativePackage *>::iterator it = m_packaged.find(item);
+ QHash<QObject *, QQuickPackage *>::iterator it = m_packaged.find(item);
if (it != m_packaged.end()) {
- QDeclarativePackage *package = *it;
- QDeclarative_setParent_noEvent(item, package);
+ QQuickPackage *package = *it;
+ QQml_setParent_noEvent(item, package);
QQuickVisualDataModelPrivate *model = QQuickVisualDataModelPrivate::get(m_model);
flags = model->release(package);
m_packaged.erase(it);
@@ -2582,7 +2582,7 @@ void QQuickVisualPartsModel::setWatchedRoles(QList<QByteArray> roles)
int QQuickVisualPartsModel::indexOf(QQuickItem *item, QObject *) const
{
- QHash<QObject *, QDeclarativePackage *>::const_iterator it = m_packaged.find(item);
+ QHash<QObject *, QQuickPackage *>::const_iterator it = m_packaged.find(item);
if (it != m_packaged.end()) {
if (QQuickVisualDataModelAttached *attached = QQuickVisualDataModelAttached::properties(*it))
return attached->m_cacheItem->index[m_compositorGroup];
@@ -2590,29 +2590,29 @@ int QQuickVisualPartsModel::indexOf(QQuickItem *item, QObject *) const
return -1;
}
-void QQuickVisualPartsModel::createdPackage(int index, QDeclarativePackage *package)
+void QQuickVisualPartsModel::createdPackage(int index, QQuickPackage *package)
{
if (QQuickItem *item = qobject_cast<QQuickItem *>(package->part(m_part)))
emit createdItem(index, item);
}
-void QQuickVisualPartsModel::initPackage(int index, QDeclarativePackage *package)
+void QQuickVisualPartsModel::initPackage(int index, QQuickPackage *package)
{
if (QQuickItem *item = qobject_cast<QQuickItem *>(package->part(m_part)))
emit initItem(index, item);
}
-void QQuickVisualPartsModel::destroyingPackage(QDeclarativePackage *package)
+void QQuickVisualPartsModel::destroyingPackage(QQuickPackage *package)
{
if (QQuickItem *item = qobject_cast<QQuickItem *>(package->part(m_part))) {
Q_ASSERT(!m_packaged.contains(item));
emit destroyingItem(item);
item->setParentItem(0);
- QDeclarative_setParent_noEvent(item, package);
+ QQml_setParent_noEvent(item, package);
}
}
-void QQuickVisualPartsModel::emitModelUpdated(const QDeclarativeChangeSet &changeSet, bool reset)
+void QQuickVisualPartsModel::emitModelUpdated(const QQuickChangeSet &changeSet, bool reset)
{
emit modelUpdated(changeSet, reset);
if (changeSet.difference() != 0)
diff --git a/src/quick/items/qquickvisualdatamodel_p.h b/src/quick/items/qquickvisualdatamodel_p.h
index 043fcfd8a9..535374be09 100644
--- a/src/quick/items/qquickvisualdatamodel_p.h
+++ b/src/quick/items/qquickvisualdatamodel_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef QQUICKVISUALDATAMODEL_P_H
#define QQUICKVISUALDATAMODEL_P_H
-#include <private/qdeclarativelistcompositor_p.h>
+#include <private/qquicklistcompositor_p.h>
#include <private/qquickvisualitemmodel_p.h>
#include <QtCore/qabstractitemmodel.h>
@@ -50,7 +50,7 @@
#include <private/qv8engine_p.h>
-#include <private/qdeclarativeglobal_p.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_HEADER
@@ -58,33 +58,33 @@ Q_DECLARE_METATYPE(QModelIndex)
QT_BEGIN_NAMESPACE
-class QDeclarativeChangeSet;
-class QDeclarativeComponent;
-class QDeclarativePackage;
-class QDeclarativeV8Function;
+class QQuickChangeSet;
+class QQmlComponent;
+class QQuickPackage;
+class QQmlV8Function;
class QQuickVisualDataGroup;
class QQuickVisualDataModelAttached;
class QQuickVisualDataModelPrivate;
-class Q_QUICK_EXPORT QQuickVisualDataModel : public QQuickVisualModel, public QDeclarativeParserStatus
+class Q_QUICK_EXPORT QQuickVisualDataModel : public QQuickVisualModel, public QQmlParserStatus
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickVisualDataModel)
Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate)
Q_PROPERTY(QString filterOnGroup READ filterGroup WRITE setFilterGroup NOTIFY filterGroupChanged RESET resetFilterGroup)
Q_PROPERTY(QQuickVisualDataGroup *items READ items CONSTANT)
Q_PROPERTY(QQuickVisualDataGroup *persistedItems READ persistedItems CONSTANT)
- Q_PROPERTY(QDeclarativeListProperty<QQuickVisualDataGroup> groups READ groups CONSTANT)
+ Q_PROPERTY(QQmlListProperty<QQuickVisualDataGroup> groups READ groups CONSTANT)
Q_PROPERTY(QObject *parts READ parts CONSTANT)
Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
- Q_INTERFACES(QDeclarativeParserStatus)
+ Q_INTERFACES(QQmlParserStatus)
public:
QQuickVisualDataModel();
- QQuickVisualDataModel(QDeclarativeContext *, QObject *parent=0);
+ QQuickVisualDataModel(QQmlContext *, QObject *parent=0);
virtual ~QQuickVisualDataModel();
void classBegin();
@@ -93,8 +93,8 @@ public:
QVariant model() const;
void setModel(const QVariant &);
- QDeclarativeComponent *delegate() const;
- void setDelegate(QDeclarativeComponent *);
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *);
QVariant rootIndex() const;
void setRootIndex(const QVariant &root);
@@ -118,7 +118,7 @@ public:
QQuickVisualDataGroup *items();
QQuickVisualDataGroup *persistedItems();
- QDeclarativeListProperty<QQuickVisualDataGroup> groups();
+ QQmlListProperty<QQuickVisualDataGroup> groups();
QObject *parts();
bool event(QEvent *);
@@ -160,23 +160,23 @@ public:
bool defaultInclude() const;
void setDefaultInclude(bool include);
- Q_INVOKABLE QDeclarativeV8Handle get(int index);
+ Q_INVOKABLE QQmlV8Handle get(int index);
public Q_SLOTS:
- void insert(QDeclarativeV8Function *);
- void create(QDeclarativeV8Function *);
- void resolve(QDeclarativeV8Function *);
- void remove(QDeclarativeV8Function *);
- void addGroups(QDeclarativeV8Function *);
- void removeGroups(QDeclarativeV8Function *);
- void setGroups(QDeclarativeV8Function *);
- void move(QDeclarativeV8Function *);
+ void insert(QQmlV8Function *);
+ void create(QQmlV8Function *);
+ void resolve(QQmlV8Function *);
+ void remove(QQmlV8Function *);
+ void addGroups(QQmlV8Function *);
+ void removeGroups(QQmlV8Function *);
+ void setGroups(QQmlV8Function *);
+ void move(QQmlV8Function *);
Q_SIGNALS:
void countChanged();
void nameChanged();
void defaultIncludeChanged();
- void changed(const QDeclarativeV8Handle &removed, const QDeclarativeV8Handle &inserted);
+ void changed(const QQmlV8Handle &removed, const QQmlV8Handle &inserted);
private:
Q_DECLARE_PRIVATE(QQuickVisualDataGroup)
};
@@ -195,7 +195,7 @@ public:
, m_previousGroups(0)
, m_modelChanged(false)
{
- QDeclarative_setParent_noEvent(this, parent);
+ QQml_setParent_noEvent(this, parent);
}
~QQuickVisualDataModelAttached() { attachedProperties.remove(parent()); }
@@ -230,7 +230,7 @@ Q_SIGNALS:
public:
QQuickVisualDataModelItem *m_cacheItem;
int m_previousGroups;
- int m_previousIndex[QDeclarativeListCompositor::MaximumGroupCount];
+ int m_previousIndex[QQuickListCompositor::MaximumGroupCount];
bool m_modelChanged;
static QHash<QObject*, QQuickVisualDataModelAttached*> attachedProperties;
diff --git a/src/quick/items/qquickvisualdatamodel_p_p.h b/src/quick/items/qquickvisualdatamodel_p_p.h
index 1fb23d78bb..c53ed5bdbb 100644
--- a/src/quick/items/qquickvisualdatamodel_p_p.h
+++ b/src/quick/items/qquickvisualdatamodel_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,10 +44,10 @@
#include "qquickvisualdatamodel_p.h"
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlincubator.h>
-#include <private/qdeclarativeopenmetaobject_p.h>
+#include <private/qqmlopenmetaobject_p.h>
//
// W A R N I N G
@@ -62,9 +62,9 @@
QT_BEGIN_NAMESPACE
-typedef QDeclarativeListCompositor Compositor;
+typedef QQuickListCompositor Compositor;
-class QQuickVisualDataModelItemMetaType : public QDeclarativeRefCount
+class QQuickVisualDataModelItemMetaType : public QQmlRefCount
{
public:
QQuickVisualDataModelItemMetaType(QV8Engine *engine, QQuickVisualDataModel *model, const QStringList &groupNames);
@@ -85,7 +85,7 @@ public:
v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info);
static v8::Handle<v8::Value> get_index(v8::Local<v8::String>, const v8::AccessorInfo &info);
- QDeclarativeGuard<QQuickVisualDataModel> model;
+ QQmlGuard<QQuickVisualDataModel> model;
const int groupCount;
const int memberPropertyOffset;
const int indexPropertyOffset;
@@ -136,8 +136,8 @@ Q_SIGNALS:
public:
QQuickVisualDataModelItemMetaType * const metaType;
- QDeclarativeGuard<QQuickVisualAdaptorModel> model;
- QDeclarativeGuard<QObject> object;
+ QQmlGuard<QQuickVisualAdaptorModel> model;
+ QQmlGuard<QObject> object;
QQuickVisualDataModelAttached *attached;
v8::Persistent<v8::Object> indexHandle;
v8::Persistent<v8::Value> modelHandle;
@@ -145,17 +145,17 @@ public:
int objectRef;
int scriptRef;
int groups;
- int index[QDeclarativeListCompositor::MaximumGroupCount];
+ int index[QQuickListCompositor::MaximumGroupCount];
QVDMIncubationTask *incubationTask;
};
class QQuickVisualDataModelPrivate;
-class QVDMIncubationTask : public QDeclarativeIncubator
+class QVDMIncubationTask : public QQmlIncubator
{
public:
QVDMIncubationTask(QQuickVisualDataModelPrivate *l, IncubationMode mode)
- : QDeclarativeIncubator(mode)
+ : QQmlIncubator(mode)
, incubating(0)
, incubatingContext(0)
, vdm(l) {}
@@ -164,7 +164,7 @@ public:
virtual void setInitialState(QObject *);
QQuickVisualDataModelItem *incubating;
- QDeclarativeContext *incubatingContext;
+ QQmlContext *incubatingContext;
private:
QQuickVisualDataModelPrivate *vdm;
@@ -174,10 +174,10 @@ private:
class QQuickVisualDataGroupEmitter
{
public:
- virtual void emitModelUpdated(const QDeclarativeChangeSet &changeSet, bool reset) = 0;
- virtual void createdPackage(int, QDeclarativePackage *) {}
- virtual void initPackage(int, QDeclarativePackage *) {}
- virtual void destroyingPackage(QDeclarativePackage *) {}
+ virtual void emitModelUpdated(const QQuickChangeSet &changeSet, bool reset) = 0;
+ virtual void createdPackage(int, QQuickPackage *) {}
+ virtual void initPackage(int, QQuickPackage *) {}
+ virtual void destroyingPackage(QQuickPackage *) {}
QIntrusiveListNode emitterNode;
};
@@ -198,18 +198,18 @@ public:
void emitChanges(QV8Engine *engine);
void emitModelUpdated(bool reset);
- void createdPackage(int index, QDeclarativePackage *package);
- void initPackage(int index, QDeclarativePackage *package);
- void destroyingPackage(QDeclarativePackage *package);
+ void createdPackage(int index, QQuickPackage *package);
+ void initPackage(int index, QQuickPackage *package);
+ void destroyingPackage(QQuickPackage *package);
bool parseIndex(const v8::Local<v8::Value> &value, int *index, Compositor::Group *group) const;
bool parseGroupArgs(
- QDeclarativeV8Function *args, Compositor::Group *group, int *index, int *count, int *groups) const;
+ QQmlV8Function *args, Compositor::Group *group, int *index, int *count, int *groups) const;
Compositor::Group group;
- QDeclarativeGuard<QQuickVisualDataModel> model;
+ QQmlGuard<QQuickVisualDataModel> model;
QQuickVisualDataGroupEmitterList emitters;
- QDeclarativeChangeSet changeSet;
+ QQuickChangeSet changeSet;
QString name;
bool defaultInclude;
};
@@ -220,7 +220,7 @@ class QQuickVisualDataModelPrivate : public QObjectPrivate, public QQuickVisualD
{
Q_DECLARE_PUBLIC(QQuickVisualDataModel)
public:
- QQuickVisualDataModelPrivate(QDeclarativeContext *);
+ QQuickVisualDataModelPrivate(QQmlContext *);
~QQuickVisualDataModelPrivate();
static QQuickVisualDataModelPrivate *get(QQuickVisualDataModel *m) {
@@ -234,13 +234,13 @@ public:
void destroy(QObject *object);
QQuickVisualDataModel::ReleaseFlags release(QObject *object);
QString stringValue(Compositor::Group group, int index, const QString &name);
- void emitCreatedPackage(QQuickVisualDataModelItem *cacheItem, QDeclarativePackage *package);
- void emitInitPackage(QQuickVisualDataModelItem *cacheItem, QDeclarativePackage *package);
+ void emitCreatedPackage(QQuickVisualDataModelItem *cacheItem, QQuickPackage *package);
+ void emitInitPackage(QQuickVisualDataModelItem *cacheItem, QQuickPackage *package);
void emitCreatedItem(QQuickVisualDataModelItem *cacheItem, QQuickItem *item) {
emit q_func()->createdItem(cacheItem->index[m_compositorGroup], item); }
void emitInitItem(QQuickVisualDataModelItem *cacheItem, QQuickItem *item) {
emit q_func()->initItem(cacheItem->index[m_compositorGroup], item); }
- void emitDestroyingPackage(QDeclarativePackage *package);
+ void emitDestroyingPackage(QQuickPackage *package);
void emitDestroyingItem(QQuickItem *item) { emit q_func()->destroyingItem(item); }
void updateFilterGroup();
@@ -251,12 +251,12 @@ public:
void itemsInserted(
const QVector<Compositor::Insert> &inserts,
- QVarLengthArray<QVector<QDeclarativeChangeSet::Insert>, Compositor::MaximumGroupCount> *translatedInserts,
+ QVarLengthArray<QVector<QQuickChangeSet::Insert>, Compositor::MaximumGroupCount> *translatedInserts,
QHash<int, QList<QQuickVisualDataModelItem *> > *movedItems = 0);
void itemsInserted(const QVector<Compositor::Insert> &inserts);
void itemsRemoved(
const QVector<Compositor::Remove> &removes,
- QVarLengthArray<QVector<QDeclarativeChangeSet::Remove>, Compositor::MaximumGroupCount> *translatedRemoves,
+ QVarLengthArray<QVector<QQuickChangeSet::Remove>, Compositor::MaximumGroupCount> *translatedRemoves,
QHash<int, QList<QQuickVisualDataModelItem *> > *movedItems = 0);
void itemsRemoved(const QVector<Compositor::Remove> &removes);
void itemsMoved(
@@ -264,29 +264,29 @@ public:
void itemsChanged(const QVector<Compositor::Change> &changes);
template <typename T> static v8::Local<v8::Array> buildChangeList(const QVector<T> &changes);
void emitChanges();
- void emitModelUpdated(const QDeclarativeChangeSet &changeSet, bool reset);
+ void emitModelUpdated(const QQuickChangeSet &changeSet, bool reset);
bool insert(Compositor::insert_iterator &before, const v8::Local<v8::Object> &object, int groups);
- static void group_append(QDeclarativeListProperty<QQuickVisualDataGroup> *property, QQuickVisualDataGroup *group);
- static int group_count(QDeclarativeListProperty<QQuickVisualDataGroup> *property);
- static QQuickVisualDataGroup *group_at(QDeclarativeListProperty<QQuickVisualDataGroup> *property, int index);
+ static void group_append(QQmlListProperty<QQuickVisualDataGroup> *property, QQuickVisualDataGroup *group);
+ static int group_count(QQmlListProperty<QQuickVisualDataGroup> *property);
+ static QQuickVisualDataGroup *group_at(QQmlListProperty<QQuickVisualDataGroup> *property, int index);
void releaseIncubator(QVDMIncubationTask *incubationTask);
- void incubatorStatusChanged(QVDMIncubationTask *incubationTask, QDeclarativeIncubator::Status status);
+ void incubatorStatusChanged(QVDMIncubationTask *incubationTask, QQmlIncubator::Status status);
void setInitialState(QVDMIncubationTask *incubationTask, QObject *o);
QQuickVisualAdaptorModel *m_adaptorModel;
- QDeclarativeComponent *m_delegate;
+ QQmlComponent *m_delegate;
QQuickVisualDataModelItemMetaType *m_cacheMetaType;
- QDeclarativeGuard<QDeclarativeContext> m_context;
+ QQmlGuard<QQmlContext> m_context;
QList<QQuickVisualDataModelItem *> m_cache;
QQuickVisualDataModelParts *m_parts;
QQuickVisualDataGroupEmitterList m_pendingParts;
- QDeclarativeListCompositor m_compositor;
- QDeclarativeListCompositor::Group m_compositorGroup;
+ QQuickListCompositor m_compositor;
+ QQuickListCompositor::Group m_compositorGroup;
bool m_complete : 1;
bool m_delegateValidated : 1;
bool m_reset : 1;
@@ -321,7 +321,7 @@ public:
void setFilterGroup(const QString &group);
void resetFilterGroup();
void updateFilterGroup();
- void updateFilterGroup(Compositor::Group group, const QDeclarativeChangeSet &changeSet);
+ void updateFilterGroup(Compositor::Group group, const QQuickChangeSet &changeSet);
int count() const;
bool isValid() const;
@@ -332,18 +332,18 @@ public:
int indexOf(QQuickItem *item, QObject *objectContext) const;
- void emitModelUpdated(const QDeclarativeChangeSet &changeSet, bool reset);
+ void emitModelUpdated(const QQuickChangeSet &changeSet, bool reset);
- void createdPackage(int index, QDeclarativePackage *package);
- void initPackage(int index, QDeclarativePackage *package);
- void destroyingPackage(QDeclarativePackage *package);
+ void createdPackage(int index, QQuickPackage *package);
+ void initPackage(int index, QQuickPackage *package);
+ void destroyingPackage(QQuickPackage *package);
Q_SIGNALS:
void filterGroupChanged();
private:
QQuickVisualDataModel *m_model;
- QHash<QObject *, QDeclarativePackage *> m_packaged;
+ QHash<QObject *, QQuickPackage *> m_packaged;
QString m_part;
QString m_filterGroup;
QList<QByteArray> m_watchedRoles;
@@ -353,11 +353,11 @@ private:
class QMetaPropertyBuilder;
-class QQuickVisualDataModelPartsMetaObject : public QDeclarativeOpenMetaObject
+class QQuickVisualDataModelPartsMetaObject : public QQmlOpenMetaObject
{
public:
QQuickVisualDataModelPartsMetaObject(QObject *parent)
- : QDeclarativeOpenMetaObject(parent) {}
+ : QQmlOpenMetaObject(parent) {}
virtual void propertyCreated(int, QMetaPropertyBuilder &);
virtual QVariant initialValue(int);
@@ -387,15 +387,15 @@ private:
QQuickVisualDataModelItemMetaType *metaType;
};
-class QQuickVisualDataModelContext : public QDeclarativeContext
+class QQuickVisualDataModelContext : public QQmlContext
{
Q_OBJECT
public:
QQuickVisualDataModelContext(
QQuickVisualDataModelItem *cacheItem,
- QDeclarativeContext *parentContext,
+ QQmlContext *parentContext,
QObject *parent = 0)
- : QDeclarativeContext(parentContext, parent)
+ : QQmlContext(parentContext, parent)
, cacheItem(cacheItem)
{
++cacheItem->scriptRef;
diff --git a/src/quick/items/qquickvisualitemmodel.cpp b/src/quick/items/qquickvisualitemmodel.cpp
index 2a24e3946c..b1fce55d7d 100644
--- a/src/quick/items/qquickvisualitemmodel.cpp
+++ b/src/quick/items/qquickvisualitemmodel.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,11 +43,11 @@
#include "qquickitem.h"
#include <QtCore/qcoreapplication.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlengine.h>
-#include <private/qdeclarativechangeset_p.h>
-#include <private/qdeclarativeglobal_p.h>
+#include <private/qquickchangeset_p.h>
+#include <private/qqmlglobal_p.h>
#include <private/qobject_p.h>
#include <QtCore/qhash.h>
@@ -64,18 +64,18 @@ class QQuickVisualItemModelPrivate : public QObjectPrivate
public:
QQuickVisualItemModelPrivate() : QObjectPrivate() {}
- static void children_append(QDeclarativeListProperty<QQuickItem> *prop, QQuickItem *item) {
- QDeclarative_setParent_noEvent(item, prop->object);
+ static void children_append(QQmlListProperty<QQuickItem> *prop, QQuickItem *item) {
+ QQml_setParent_noEvent(item, prop->object);
static_cast<QQuickVisualItemModelPrivate *>(prop->data)->children.append(Item(item));
static_cast<QQuickVisualItemModelPrivate *>(prop->data)->itemAppended();
static_cast<QQuickVisualItemModelPrivate *>(prop->data)->emitChildrenChanged();
}
- static int children_count(QDeclarativeListProperty<QQuickItem> *prop) {
+ static int children_count(QQmlListProperty<QQuickItem> *prop) {
return static_cast<QQuickVisualItemModelPrivate *>(prop->data)->children.count();
}
- static QQuickItem *children_at(QDeclarativeListProperty<QQuickItem> *prop, int index) {
+ static QQuickItem *children_at(QQmlListProperty<QQuickItem> *prop, int index) {
return static_cast<QQuickVisualItemModelPrivate *>(prop->data)->children.at(index).item;
}
@@ -83,7 +83,7 @@ public:
Q_Q(QQuickVisualItemModel);
QQuickVisualItemModelAttached *attached = QQuickVisualItemModelAttached::properties(children.last().item);
attached->setIndex(children.count()-1);
- QDeclarativeChangeSet changeSet;
+ QQuickChangeSet changeSet;
changeSet.insert(children.count() - 1, 1);
emit q->modelUpdated(changeSet, false);
emit q->countChanged();
@@ -165,10 +165,10 @@ QQuickVisualItemModel::QQuickVisualItemModel(QObject *parent)
It is attached to each instance of the delegate.
*/
-QDeclarativeListProperty<QQuickItem> QQuickVisualItemModel::children()
+QQmlListProperty<QQuickItem> QQuickVisualItemModel::children()
{
Q_D(QQuickVisualItemModel);
- return QDeclarativeListProperty<QQuickItem>(this, d, d->children_append,
+ return QQmlListProperty<QQuickItem>(this, d, d->children_append,
d->children_count, d->children_at);
}
@@ -206,7 +206,7 @@ QQuickVisualModel::ReleaseFlags QQuickVisualItemModel::release(QQuickItem *item)
if (d->children[idx].deref()) {
// XXX todo - the original did item->scene()->removeItem(). Why?
item->setParentItem(0);
- QDeclarative_setParent_noEvent(item, this);
+ QQml_setParent_noEvent(item, this);
}
}
return 0;
@@ -217,7 +217,7 @@ QString QQuickVisualItemModel::stringValue(int index, const QString &name)
Q_D(QQuickVisualItemModel);
if (index < 0 || index >= d->children.count())
return QString();
- return QDeclarativeEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString();
+ return QQmlEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString();
}
int QQuickVisualItemModel::indexOf(QQuickItem *item, QObject *) const
diff --git a/src/quick/items/qquickvisualitemmodel_p.h b/src/quick/items/qquickvisualitemmodel_p.h
index 7d2b79f718..bf56195c66 100644
--- a/src/quick/items/qquickvisualitemmodel_p.h
+++ b/src/quick/items/qquickvisualitemmodel_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,7 +43,7 @@
#define QQUICKVISUALITEMMODEL_P_H
#include <QtQuick/qtquickglobal.h>
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
#include <QtCore/qobject.h>
QT_BEGIN_HEADER
@@ -51,7 +51,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QQuickItem;
-class QDeclarativeChangeSet;
+class QQuickChangeSet;
class Q_QUICK_EXPORT QQuickVisualModel : public QObject
{
@@ -77,7 +77,7 @@ public:
Q_SIGNALS:
void countChanged();
- void modelUpdated(const QDeclarativeChangeSet &changeSet, bool reset);
+ void modelUpdated(const QQuickChangeSet &changeSet, bool reset);
void createdItem(int index, QQuickItem *item);
void initItem(int index, QQuickItem *item);
void destroyingItem(QQuickItem *item);
@@ -97,7 +97,7 @@ class Q_QUICK_EXPORT QQuickVisualItemModel : public QQuickVisualModel
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickVisualItemModel)
- Q_PROPERTY(QDeclarativeListProperty<QQuickItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
+ Q_PROPERTY(QQmlListProperty<QQuickItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
Q_CLASSINFO("DefaultProperty", "children")
public:
@@ -113,7 +113,7 @@ public:
virtual int indexOf(QQuickItem *item, QObject *objectContext) const;
- QDeclarativeListProperty<QQuickItem> children();
+ QQmlListProperty<QQuickItem> children();
static QQuickVisualItemModelAttached *qmlAttachedProperties(QObject *obj);
diff --git a/src/quick/items/qquickwindowmanager.cpp b/src/quick/items/qquickwindowmanager.cpp
index 79fd266e1e..5de8ad1279 100644
--- a/src/quick/items/qquickwindowmanager.cpp
+++ b/src/quick/items/qquickwindowmanager.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -51,7 +51,7 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qplatformintegration_qpa.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
+#include <QtQml/private/qqmlglobal_p.h>
#include <QtQuick/QQuickCanvas>
#include <QtQuick/private/qquickcanvas_p.h>
diff --git a/src/quick/items/qquickwindowmanager_p.h b/src/quick/items/qquickwindowmanager_p.h
index a0bdf08a91..9372e90f5e 100644
--- a/src/quick/items/qquickwindowmanager_p.h
+++ b/src/quick/items/qquickwindowmanager_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index 6faeb96da0..4c9620748a 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h
index b02d29e776..72fd2b32bd 100644
--- a/src/quick/items/qquickwindowmodule_p.h
+++ b/src/quick/items/qquickwindowmodule_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef QQUICKWINDOWMODULE_H
#define QQUICKWINDOWMODULE_H
-#include <qdeclarative.h>
+#include <qqml.h>
QT_BEGIN_HEADER
diff --git a/src/quick/items/syncexcludes b/src/quick/items/syncexcludes
index ab7a374a5b..19e41ce643 100644
--- a/src/quick/items/syncexcludes
+++ b/src/quick/items/syncexcludes
@@ -6,6 +6,6 @@ qdeclarativelayoutitem.cpp
qdeclarativelayoutitem_p.h
qdeclarativefocuspanel.cpp
qdeclarativefocuspanel_p.h
-qdeclarativepath_p.h
-qdeclarativepath_p_p.h
+qquickpath_p.h
+qquickpath_p_p.h
qdeclarativepath.cpp
diff --git a/src/quick/particles/qquickage.cpp b/src/quick/particles/qquickage.cpp
index 307fb58577..9f24cba3cc 100644
--- a/src/quick/particles/qquickage.cpp
+++ b/src/quick/particles/qquickage.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickage_p.h b/src/quick/particles/qquickage_p.h
index 60fc0bd98d..2ec8faae4b 100644
--- a/src/quick/particles/qquickage_p.h
+++ b/src/quick/particles/qquickage_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickangledirection.cpp b/src/quick/particles/qquickangledirection.cpp
index 726b6fa404..a3bd45e0bf 100644
--- a/src/quick/particles/qquickangledirection.cpp
+++ b/src/quick/particles/qquickangledirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickangledirection_p.h b/src/quick/particles/qquickangledirection_p.h
index 4f86fec5f4..84633cd40e 100644
--- a/src/quick/particles/qquickangledirection_p.h
+++ b/src/quick/particles/qquickangledirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickcumulativedirection.cpp b/src/quick/particles/qquickcumulativedirection.cpp
index 0a2ac92a64..d7c4094297 100644
--- a/src/quick/particles/qquickcumulativedirection.cpp
+++ b/src/quick/particles/qquickcumulativedirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -54,9 +54,9 @@ QQuickCumulativeDirection::QQuickCumulativeDirection(QObject *parent):QQuickDire
{
}
-QDeclarativeListProperty<QQuickDirection> QQuickCumulativeDirection::directions()
+QQmlListProperty<QQuickDirection> QQuickCumulativeDirection::directions()
{
- return QDeclarativeListProperty<QQuickDirection>(this, m_directions);//TODO: Proper list property
+ return QQmlListProperty<QQuickDirection>(this, m_directions);//TODO: Proper list property
}
const QPointF QQuickCumulativeDirection::sample(const QPointF &from)
diff --git a/src/quick/particles/qquickcumulativedirection_p.h b/src/quick/particles/qquickcumulativedirection_p.h
index 2fbb41151e..e1675a18d8 100644
--- a/src/quick/particles/qquickcumulativedirection_p.h
+++ b/src/quick/particles/qquickcumulativedirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef QQuickCUMULATIVEDIRECTION_P_H
#define QQuickCUMULATIVEDIRECTION_P_H
#include "qquickdirection_p.h"
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -50,11 +50,11 @@ QT_BEGIN_NAMESPACE
class QQuickCumulativeDirection : public QQuickDirection
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QQuickDirection> directions READ directions)
+ Q_PROPERTY(QQmlListProperty<QQuickDirection> directions READ directions)
Q_CLASSINFO("DefaultProperty", "directions")
public:
explicit QQuickCumulativeDirection(QObject *parent = 0);
- QDeclarativeListProperty<QQuickDirection> directions();
+ QQmlListProperty<QQuickDirection> directions();
const QPointF sample(const QPointF &from);
private:
QList<QQuickDirection*> m_directions;
diff --git a/src/quick/particles/qquickcustomaffector.cpp b/src/quick/particles/qquickcustomaffector.cpp
index d890400a92..acec98192d 100644
--- a/src/quick/particles/qquickcustomaffector.cpp
+++ b/src/quick/particles/qquickcustomaffector.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -41,8 +41,8 @@
#include "qquickcustomaffector_p.h"
#include <private/qv8engine_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <QDeclarativeEngine>
+#include <private/qqmlengine_p.h>
+#include <QQmlEngine>
#include <QDebug>
QT_BEGIN_NAMESPACE
@@ -102,7 +102,7 @@ QQuickCustomAffector::QQuickCustomAffector(QQuickItem *parent) :
bool QQuickCustomAffector::isAffectConnected()
{
- static int idx = QObjectPrivate::get(this)->signalIndex("affectParticles(QDeclarativeV8Handle,qreal)");
+ static int idx = QObjectPrivate::get(this)->signalIndex("affectParticles(QQmlV8Handle,qreal)");
return QObjectPrivate::get(this)->isSignalConnected(idx);
}
@@ -130,14 +130,14 @@ void QQuickCustomAffector::affectSystem(qreal dt)
dt = 1.0;
v8::HandleScope handle_scope;
- v8::Context::Scope scope(QDeclarativeEnginePrivate::getV8Engine(qmlEngine(this))->context());
+ v8::Context::Scope scope(QQmlEnginePrivate::getV8Engine(qmlEngine(this))->context());
v8::Handle<v8::Array> array = v8::Array::New(toAffect.size());
for (int i=0; i<toAffect.size(); i++)
array->Set(i, toAffect[i]->v8Value().toHandle());
if (dt >= simulationCutoff || dt <= simulationDelta) {
affectProperties(toAffect, dt);
- emit affectParticles(QDeclarativeV8Handle::fromHandle(array), dt);
+ emit affectParticles(QQmlV8Handle::fromHandle(array), dt);
} else {
int realTime = m_system->timeInt;
m_system->timeInt -= dt * 1000.0;
@@ -145,12 +145,12 @@ void QQuickCustomAffector::affectSystem(qreal dt)
m_system->timeInt += simulationDelta * 1000.0;
dt -= simulationDelta;
affectProperties(toAffect, simulationDelta);
- emit affectParticles(QDeclarativeV8Handle::fromHandle(array), simulationDelta);
+ emit affectParticles(QQmlV8Handle::fromHandle(array), simulationDelta);
}
m_system->timeInt = realTime;
if (dt > 0.0) {
affectProperties(toAffect, dt);
- emit affectParticles(QDeclarativeV8Handle::fromHandle(array), dt);
+ emit affectParticles(QQmlV8Handle::fromHandle(array), dt);
}
}
diff --git a/src/quick/particles/qquickcustomaffector_p.h b/src/quick/particles/qquickcustomaffector_p.h
index c38f53cb01..1266830f94 100644
--- a/src/quick/particles/qquickcustomaffector_p.h
+++ b/src/quick/particles/qquickcustomaffector_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -101,7 +101,7 @@ public:
signals:
- void affectParticles(QDeclarativeV8Handle particles, qreal dt);
+ void affectParticles(QQmlV8Handle particles, qreal dt);
void positionChanged(QQuickDirection * arg);
diff --git a/src/quick/particles/qquickcustomparticle.cpp b/src/quick/particles/qquickcustomparticle.cpp
index 347b749ca6..3647e5bfc5 100644
--- a/src/quick/particles/qquickcustomparticle.cpp
+++ b/src/quick/particles/qquickcustomparticle.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickcustomparticle_p.h b/src/quick/particles/qquickcustomparticle_p.h
index c121141621..29f3d19657 100644
--- a/src/quick/particles/qquickcustomparticle_p.h
+++ b/src/quick/particles/qquickcustomparticle_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickdirection.cpp b/src/quick/particles/qquickdirection.cpp
index da022fe4f5..4127d06be0 100644
--- a/src/quick/particles/qquickdirection.cpp
+++ b/src/quick/particles/qquickdirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickdirection_p.h b/src/quick/particles/qquickdirection_p.h
index 22e2278b46..651865a1f5 100644
--- a/src/quick/particles/qquickdirection_p.h
+++ b/src/quick/particles/qquickdirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickellipseextruder.cpp b/src/quick/particles/qquickellipseextruder.cpp
index 63ce5786c5..3eb547fd2f 100644
--- a/src/quick/particles/qquickellipseextruder.cpp
+++ b/src/quick/particles/qquickellipseextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickellipseextruder_p.h b/src/quick/particles/qquickellipseextruder_p.h
index 00b151eae2..c2d0c634ab 100644
--- a/src/quick/particles/qquickellipseextruder_p.h
+++ b/src/quick/particles/qquickellipseextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickfriction.cpp b/src/quick/particles/qquickfriction.cpp
index 57de3d9eac..d37d109f48 100644
--- a/src/quick/particles/qquickfriction.cpp
+++ b/src/quick/particles/qquickfriction.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickfriction_p.h b/src/quick/particles/qquickfriction_p.h
index b79e57a047..3b06710529 100644
--- a/src/quick/particles/qquickfriction_p.h
+++ b/src/quick/particles/qquickfriction_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickgravity.cpp b/src/quick/particles/qquickgravity.cpp
index 2ab3a299f1..cf4f35eb72 100644
--- a/src/quick/particles/qquickgravity.cpp
+++ b/src/quick/particles/qquickgravity.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickgravity_p.h b/src/quick/particles/qquickgravity_p.h
index 807b315255..a738fd3ef3 100644
--- a/src/quick/particles/qquickgravity_p.h
+++ b/src/quick/particles/qquickgravity_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickgroupgoal.cpp b/src/quick/particles/qquickgroupgoal.cpp
index 926768d27a..0d7f15a9e1 100644
--- a/src/quick/particles/qquickgroupgoal.cpp
+++ b/src/quick/particles/qquickgroupgoal.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickgroupgoal_p.h b/src/quick/particles/qquickgroupgoal_p.h
index 483d45fc50..f553badbd6 100644
--- a/src/quick/particles/qquickgroupgoal_p.h
+++ b/src/quick/particles/qquickgroupgoal_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickimageparticle.cpp b/src/quick/particles/qquickimageparticle.cpp
index 562a6c5dc7..7f87dabe7d 100644
--- a/src/quick/particles/qquickimageparticle.cpp
+++ b/src/quick/particles/qquickimageparticle.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -53,8 +53,8 @@
#include <QOpenGLFunctions>
#include <QtQuick/qsgengine.h>
#include <QtQuick/private/qsgtexture_p.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <private/qqmlglobal_p.h>
+#include <QtQml/qqmlinfo.h>
#include <cmath>
QT_BEGIN_NAMESPACE
@@ -834,9 +834,9 @@ QQuickImageParticle::~QQuickImageParticle()
{
}
-QDeclarativeListProperty<QQuickSprite> QQuickImageParticle::sprites()
+QQmlListProperty<QQuickSprite> QQuickImageParticle::sprites()
{
- return QDeclarativeListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);
+ return QQmlListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);
}
void QQuickImageParticle::setImage(const QUrl &image)
diff --git a/src/quick/particles/qquickimageparticle_p.h b/src/quick/particles/qquickimageparticle_p.h
index a0f1595192..dca524bcab 100644
--- a/src/quick/particles/qquickimageparticle_p.h
+++ b/src/quick/particles/qquickimageparticle_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,8 +43,8 @@
#define ULTRAPARTICLE_H
#include "qquickparticlepainter_p.h"
#include "qquickdirection_p.h"
-#include <private/qdeclarativepixmapcache_p.h>
-#include <QDeclarativeListProperty>
+#include <private/qquickpixmapcache_p.h>
+#include <QQmlListProperty>
#include <QtQuick/qsgsimplematerial.h>
#include <QtGui/qcolor.h>
@@ -150,7 +150,7 @@ class QQuickImageParticle : public QQuickParticlePainter
{
Q_OBJECT
Q_PROPERTY(QUrl source READ image WRITE setImage NOTIFY imageChanged)
- Q_PROPERTY(QDeclarativeListProperty<QQuickSprite> sprites READ sprites)
+ Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
//### Is it worth having progress like Image has?
//Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
@@ -193,7 +193,7 @@ public:
enum Status { Null, Ready, Loading, Error };
- QDeclarativeListProperty<QQuickSprite> sprites();
+ QQmlListProperty<QQuickSprite> sprites();
QQuickStochasticEngine* spriteEngine() {return m_spriteEngine;}
enum EntryEffect {
@@ -357,7 +357,7 @@ private slots:
private:
struct ImageData {
QUrl source;
- QDeclarativePixmap pix;
+ QQuickPixmap pix;
};
ImageData *m_image;
ImageData *m_colorTable;
diff --git a/src/quick/particles/qquickitemparticle.cpp b/src/quick/particles/qquickitemparticle.cpp
index db9e3d1519..91ef06fcb2 100644
--- a/src/quick/particles/qquickitemparticle.cpp
+++ b/src/quick/particles/qquickitemparticle.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -43,7 +43,7 @@
#include <private/qquickvisualitemmodel_p.h>
#include <QtQuick/qsgnode.h>
#include <QTimer>
-#include <QDeclarativeComponent>
+#include <QQmlComponent>
#include <QDebug>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/particles/qquickitemparticle_p.h b/src/quick/particles/qquickitemparticle_p.h
index df104a5644..c7b8a2661e 100644
--- a/src/quick/particles/qquickitemparticle_p.h
+++ b/src/quick/particles/qquickitemparticle_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,7 +44,7 @@
#include "qquickparticlepainter_p.h"
#include <QPointer>
#include <QSet>
-#include <private/qdeclarativeanimation_p_p.h>
+#include <private/qquickanimation_p_p.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -56,7 +56,7 @@ class QQuickItemParticle : public QQuickParticlePainter
{
Q_OBJECT
Q_PROPERTY(bool fade READ fade WRITE setFade NOTIFY fadeChanged)
- Q_PROPERTY(QDeclarativeComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
public:
explicit QQuickItemParticle(QQuickItem *parent = 0);
~QQuickItemParticle();
@@ -66,7 +66,7 @@ public:
virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
static QQuickItemParticleAttached *qmlAttachedProperties(QObject *object);
- QDeclarativeComponent* delegate() const
+ QQmlComponent* delegate() const
{
return m_delegate;
}
@@ -74,7 +74,7 @@ public:
signals:
void fadeChanged();
- void delegateChanged(QDeclarativeComponent* arg);
+ void delegateChanged(QQmlComponent* arg);
public slots:
//TODO: Add a follow mode, where moving the delegate causes the logical particle to go with it?
@@ -84,7 +84,7 @@ public slots:
void give(QQuickItem* item);//give from modelparticle
void setFade(bool arg){if (arg == m_fade) return; m_fade = arg; emit fadeChanged();}
- void setDelegate(QDeclarativeComponent* arg)
+ void setDelegate(QQmlComponent* arg)
{
if (m_delegate != arg) {
m_delegate = arg;
@@ -108,7 +108,7 @@ private:
QSet<QQuickItem*> m_stasis;
qreal m_lastT;
int m_activeCount;
- QDeclarativeComponent* m_delegate;
+ QQmlComponent* m_delegate;
typedef QTickAnimationProxy<QQuickItemParticle, &QQuickItemParticle::tick> Clock;
Clock *clock;
diff --git a/src/quick/particles/qquicklineextruder.cpp b/src/quick/particles/qquicklineextruder.cpp
index b034c5293c..f555de3f72 100644
--- a/src/quick/particles/qquicklineextruder.cpp
+++ b/src/quick/particles/qquicklineextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquicklineextruder_p.h b/src/quick/particles/qquicklineextruder_p.h
index 1f65f8d808..6f2b2493a6 100644
--- a/src/quick/particles/qquicklineextruder_p.h
+++ b/src/quick/particles/qquicklineextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickmaskextruder.cpp b/src/quick/particles/qquickmaskextruder.cpp
index 3ed2eb953c..50b71749c0 100644
--- a/src/quick/particles/qquickmaskextruder.cpp
+++ b/src/quick/particles/qquickmaskextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,8 +40,8 @@
****************************************************************************/
#include "qquickmaskextruder_p.h"
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlinfo.h>
#include <QImage>
#include <QDebug>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/particles/qquickmaskextruder_p.h b/src/quick/particles/qquickmaskextruder_p.h
index 0c9f10b1b2..8b6c3f0b2d 100644
--- a/src/quick/particles/qquickmaskextruder_p.h
+++ b/src/quick/particles/qquickmaskextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef MASKEXTRUDER_H
#define MASKEXTRUDER_H
#include "qquickparticleextruder_p.h"
-#include <private/qdeclarativepixmapcache_p.h>
+#include <private/qquickpixmapcache_p.h>
#include <QUrl>
#include <QImage>
@@ -81,7 +81,7 @@ private:
void ensureInitialized(const QRectF &r);
int m_lastWidth;
int m_lastHeight;
- QDeclarativePixmap m_pix;
+ QQuickPixmap m_pix;
QImage m_img;
QList<QPointF> m_mask;//TODO: More memory efficient datastructures
//Perhaps just the mask for the largest bounds is stored, and interpolate up
diff --git a/src/quick/particles/qquickparticleaffector.cpp b/src/quick/particles/qquickparticleaffector.cpp
index 6a5a4f3304..0005af86af 100644
--- a/src/quick/particles/qquickparticleaffector.cpp
+++ b/src/quick/particles/qquickparticleaffector.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticleaffector_p.h b/src/quick/particles/qquickparticleaffector_p.h
index b5126fb0db..4147488f87 100644
--- a/src/quick/particles/qquickparticleaffector_p.h
+++ b/src/quick/particles/qquickparticleaffector_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticleemitter.cpp b/src/quick/particles/qquickparticleemitter.cpp
index 88c062b1f5..0f7f3817f2 100644
--- a/src/quick/particles/qquickparticleemitter.cpp
+++ b/src/quick/particles/qquickparticleemitter.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qquickparticleemitter_p.h"
-#include <private/qdeclarativeengine_p.h>
+#include <private/qqmlengine_p.h>
QT_BEGIN_NAMESPACE
@@ -253,7 +253,7 @@ QQuickParticleEmitter::~QQuickParticleEmitter()
bool QQuickParticleEmitter::isEmitConnected()
{
- static int idx = QObjectPrivate::get(this)->signalIndex("emitParticles(QDeclarativeV8Handle)");
+ static int idx = QObjectPrivate::get(this)->signalIndex("emitParticles(QQmlV8Handle)");
return QObjectPrivate::get(this)->isSignalConnected(idx);
}
@@ -479,12 +479,12 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
if (isEmitConnected()) {
v8::HandleScope handle_scope;
- v8::Context::Scope scope(QDeclarativeEnginePrivate::getV8Engine(qmlEngine(this))->context());
+ v8::Context::Scope scope(QQmlEnginePrivate::getV8Engine(qmlEngine(this))->context());
v8::Handle<v8::Array> array = v8::Array::New(toEmit.size());
for (int i=0; i<toEmit.size(); i++)
array->Set(i, toEmit[i]->v8Value().toHandle());
- emitParticles(QDeclarativeV8Handle::fromHandle(array));//A chance for arbitrary JS changes
+ emitParticles(QQmlV8Handle::fromHandle(array));//A chance for arbitrary JS changes
}
foreach (QQuickParticleData* d, toEmit)
m_system->emitParticle(d);
diff --git a/src/quick/particles/qquickparticleemitter_p.h b/src/quick/particles/qquickparticleemitter_p.h
index 684a06be83..70adcff34c 100644
--- a/src/quick/particles/qquickparticleemitter_p.h
+++ b/src/quick/particles/qquickparticleemitter_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -121,7 +121,7 @@ public:
void setSpeedFromMovement(qreal s);
virtual void componentComplete();
signals:
- void emitParticles(QDeclarativeV8Handle particles);
+ void emitParticles(QQmlV8Handle particles);
void particlesPerSecondChanged(qreal);
void particleDurationChanged(int);
void enabledChanged(bool);
diff --git a/src/quick/particles/qquickparticleextruder.cpp b/src/quick/particles/qquickparticleextruder.cpp
index fc985b0c8e..279f7c05f3 100644
--- a/src/quick/particles/qquickparticleextruder.cpp
+++ b/src/quick/particles/qquickparticleextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticleextruder_p.h b/src/quick/particles/qquickparticleextruder_p.h
index da59bca044..e24950e4e8 100644
--- a/src/quick/particles/qquickparticleextruder_p.h
+++ b/src/quick/particles/qquickparticleextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlegroup.cpp b/src/quick/particles/qquickparticlegroup.cpp
index ae0876f549..9a165074a1 100644
--- a/src/quick/particles/qquickparticlegroup.cpp
+++ b/src/quick/particles/qquickparticlegroup.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -96,20 +96,20 @@ QQuickParticleGroup::QQuickParticleGroup(QObject* parent)
}
-void delayedRedirect(QDeclarativeListProperty<QObject> *prop, QObject *value)
+void delayedRedirect(QQmlListProperty<QObject> *prop, QObject *value)
{
QQuickParticleGroup* pg = qobject_cast<QQuickParticleGroup*>(prop->object);
if (pg)
pg->delayRedirect(value);
}
-QDeclarativeListProperty<QObject> QQuickParticleGroup::particleChildren()
+QQmlListProperty<QObject> QQuickParticleGroup::particleChildren()
{
QQuickParticleSystem* system = qobject_cast<QQuickParticleSystem*>(parent());
if (system)
- return QDeclarativeListProperty<QObject>(this, 0, &QQuickParticleSystem::statePropertyRedirect);
+ return QQmlListProperty<QObject>(this, 0, &QQuickParticleSystem::statePropertyRedirect);
else
- return QDeclarativeListProperty<QObject>(this, 0, &delayedRedirect);
+ return QQmlListProperty<QObject>(this, 0, &delayedRedirect);
}
void QQuickParticleGroup::setSystem(QQuickParticleSystem* arg)
diff --git a/src/quick/particles/qquickparticlegroup_p.h b/src/quick/particles/qquickparticlegroup_p.h
index f9703e8e03..8889187558 100644
--- a/src/quick/particles/qquickparticlegroup_p.h
+++ b/src/quick/particles/qquickparticlegroup_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,11 +42,11 @@
#define QQuickPARTICLEGROUP
#include <private/qquickspriteengine_p.h>
#include "qquickparticlesystem_p.h"
-#include "qdeclarativeparserstatus.h"
+#include "qqmlparserstatus.h"
QT_BEGIN_NAMESPACE
-class QQuickParticleGroup : public QQuickStochasticState, public QDeclarativeParserStatus
+class QQuickParticleGroup : public QQuickStochasticState, public QQmlParserStatus
{
Q_OBJECT
//### Would setting limits per group be useful? Or clutter the API?
@@ -55,14 +55,14 @@ class QQuickParticleGroup : public QQuickStochasticState, public QDeclarativePar
Q_PROPERTY(QQuickParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
//Intercept children requests and assign to the group & system
- Q_PROPERTY(QDeclarativeListProperty<QObject> particleChildren READ particleChildren DESIGNABLE false)//### Hidden property for in-state system definitions - ought not to be used in actual "Sprite" states
+ Q_PROPERTY(QQmlListProperty<QObject> particleChildren READ particleChildren DESIGNABLE false)//### Hidden property for in-state system definitions - ought not to be used in actual "Sprite" states
Q_CLASSINFO("DefaultProperty", "particleChildren")
- Q_INTERFACES(QDeclarativeParserStatus)
+ Q_INTERFACES(QQmlParserStatus)
public:
explicit QQuickParticleGroup(QObject* parent = 0);
- QDeclarativeListProperty<QObject> particleChildren();
+ QQmlListProperty<QObject> particleChildren();
int maximumAlive() const
{
diff --git a/src/quick/particles/qquickparticlepainter.cpp b/src/quick/particles/qquickparticlepainter.cpp
index b9f745edd8..f46f2f2235 100644
--- a/src/quick/particles/qquickparticlepainter.cpp
+++ b/src/quick/particles/qquickparticlepainter.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlepainter_p.h b/src/quick/particles/qquickparticlepainter_p.h
index ffa80d73dd..ebe76d98ea 100644
--- a/src/quick/particles/qquickparticlepainter_p.h
+++ b/src/quick/particles/qquickparticlepainter_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlesmodule.cpp b/src/quick/particles/qquickparticlesmodule.cpp
index f9b45f960e..e83cde3cd1 100644
--- a/src/quick/particles/qquickparticlesmodule.cpp
+++ b/src/quick/particles/qquickparticlesmodule.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlesmodule_p.h b/src/quick/particles/qquickparticlesmodule_p.h
index 9ef9cd4711..b7cf09919e 100644
--- a/src/quick/particles/qquickparticlesmodule_p.h
+++ b/src/quick/particles/qquickparticlesmodule_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef QQuickPARTICLESMODULE_H
#define QQuickPARTICLESMODULE_H
-#include <qdeclarative.h>
+#include <qqml.h>
QT_BEGIN_HEADER
diff --git a/src/quick/particles/qquickparticlesystem.cpp b/src/quick/particles/qquickparticlesystem.cpp
index 2a79b8d90d..4fd6108f2f 100644
--- a/src/quick/particles/qquickparticlesystem.cpp
+++ b/src/quick/particles/qquickparticlesystem.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -50,7 +50,8 @@
#include "qquickparticlegroup_p.h"
#include "qquicktrailemitter_p.h"//###For auto-follow on states, perhaps should be in emitter?
-#include <private/qdeclarativeengine_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qqmlglobal_p.h>
#include <cmath>
#include <QDebug>
@@ -524,10 +525,10 @@ void QQuickParticleData::clone(const QQuickParticleData& other)
animationOwner = other.animationOwner;
}
-QDeclarativeV8Handle QQuickParticleData::v8Value()
+QQmlV8Handle QQuickParticleData::v8Value()
{
if (!v8Datum)
- v8Datum = new QQuickV8ParticleData(QDeclarativeEnginePrivate::getV8Engine(qmlEngine(system)), this);
+ v8Datum = new QQuickV8ParticleData(QQmlEnginePrivate::getV8Engine(qmlEngine(system)), this);
return v8Datum->v8Value();
}
//sets the x accleration without affecting the instantaneous x velocity or position
@@ -782,7 +783,7 @@ void QQuickParticleSystem::setPaused(bool arg) {
}
}
-void QQuickParticleSystem::statePropertyRedirect(QDeclarativeListProperty<QObject> *prop, QObject *value)
+void QQuickParticleSystem::statePropertyRedirect(QQmlListProperty<QObject> *prop, QObject *value)
{
//Hooks up automatic state-associated stuff
QQuickParticleSystem* sys = qobject_cast<QQuickParticleSystem*>(prop->object->parent());
diff --git a/src/quick/particles/qquickparticlesystem_p.h b/src/quick/particles/qquickparticlesystem_p.h
index 68b29b9bc0..f70cc5af94 100644
--- a/src/quick/particles/qquickparticlesystem_p.h
+++ b/src/quick/particles/qquickparticlesystem_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -50,8 +50,8 @@
#include <QSignalMapper>
#include <private/qquicksprite_p.h>
#include <QAbstractAnimation>
-#include <QtDeclarative/qdeclarative.h>
-#include <private/qv8engine_p.h> //For QDeclarativeV8Handle
+#include <QtQml/qqml.h>
+#include <private/qv8engine_p.h> //For QQmlV8Handle
QT_BEGIN_HEADER
@@ -224,7 +224,7 @@ public:
float lifeLeft();
float curSize();
void clone(const QQuickParticleData& other);//Not =, leaves meta-data like index
- QDeclarativeV8Handle v8Value();
+ QQmlV8Handle v8Value();
void extendLife(float time);
private:
QQuickV8ParticleData* v8Datum;
@@ -314,7 +314,7 @@ public:
void registerParticleAffector(QQuickParticleAffector* a);
void registerParticleGroup(QQuickParticleGroup* g);
- static void statePropertyRedirect(QDeclarativeListProperty<QObject> *prop, QObject *value);
+ static void statePropertyRedirect(QQmlListProperty<QObject> *prop, QObject *value);
static void stateRedirect(QQuickParticleGroup* group, QQuickParticleSystem* sys, QObject *value);
bool isPaused() const
{
diff --git a/src/quick/particles/qquickpointattractor.cpp b/src/quick/particles/qquickpointattractor.cpp
index 3772e2d050..7cb8c32671 100644
--- a/src/quick/particles/qquickpointattractor.cpp
+++ b/src/quick/particles/qquickpointattractor.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickpointattractor_p.h b/src/quick/particles/qquickpointattractor_p.h
index 30a666d196..85b7a9aa30 100644
--- a/src/quick/particles/qquickpointattractor_p.h
+++ b/src/quick/particles/qquickpointattractor_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickpointdirection.cpp b/src/quick/particles/qquickpointdirection.cpp
index 6184170aae..e35eb4854c 100644
--- a/src/quick/particles/qquickpointdirection.cpp
+++ b/src/quick/particles/qquickpointdirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickpointdirection_p.h b/src/quick/particles/qquickpointdirection_p.h
index e66014653f..7b18e6d8d7 100644
--- a/src/quick/particles/qquickpointdirection_p.h
+++ b/src/quick/particles/qquickpointdirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickrectangleextruder.cpp b/src/quick/particles/qquickrectangleextruder.cpp
index 4127956e65..ad2207ca9a 100644
--- a/src/quick/particles/qquickrectangleextruder.cpp
+++ b/src/quick/particles/qquickrectangleextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickrectangleextruder_p.h b/src/quick/particles/qquickrectangleextruder_p.h
index 055058c1be..1d4f8cc439 100644
--- a/src/quick/particles/qquickrectangleextruder_p.h
+++ b/src/quick/particles/qquickrectangleextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickspritegoal.cpp b/src/quick/particles/qquickspritegoal.cpp
index 4f9518d97e..95d913cafa 100644
--- a/src/quick/particles/qquickspritegoal.cpp
+++ b/src/quick/particles/qquickspritegoal.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickspritegoal_p.h b/src/quick/particles/qquickspritegoal_p.h
index 1986bc9431..2b6b4f28fc 100644
--- a/src/quick/particles/qquickspritegoal_p.h
+++ b/src/quick/particles/qquickspritegoal_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef SPRITEGOALAFFECTOR_H
#define SPRITEGOALAFFECTOR_H
#include "qquickparticleaffector_p.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
+#include <QtQml/qqmlinfo.h>
QT_BEGIN_HEADER
diff --git a/src/quick/particles/qquicktargetdirection.cpp b/src/quick/particles/qquicktargetdirection.cpp
index 3f24a252d9..695684dfde 100644
--- a/src/quick/particles/qquicktargetdirection.cpp
+++ b/src/quick/particles/qquicktargetdirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquicktargetdirection_p.h b/src/quick/particles/qquicktargetdirection_p.h
index cc5b65e66f..0e0e942ca8 100644
--- a/src/quick/particles/qquicktargetdirection_p.h
+++ b/src/quick/particles/qquicktargetdirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquicktrailemitter.cpp b/src/quick/particles/qquicktrailemitter.cpp
index f5bc78c9cb..32f8763599 100644
--- a/src/quick/particles/qquicktrailemitter.cpp
+++ b/src/quick/particles/qquicktrailemitter.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qquicktrailemitter_p.h"
-#include <private/qdeclarativeengine_p.h>
+#include <private/qqmlengine_p.h>
#include <cmath>
QT_BEGIN_NAMESPACE
@@ -126,7 +126,7 @@ QQuickTrailEmitter::QQuickTrailEmitter(QQuickItem *parent) :
bool QQuickTrailEmitter::isEmitFollowConnected()
{
- static int idx = QObjectPrivate::get(this)->signalIndex("emitFollowParticles(QDeclarativeV8Handle,QDeclarativeV8Handle)");
+ static int idx = QObjectPrivate::get(this)->signalIndex("emitFollowParticles(QQmlV8Handle,QQmlV8Handle)");
return QObjectPrivate::get(this)->isSignalConnected(idx);
}
@@ -265,15 +265,15 @@ void QQuickTrailEmitter::emitWindow(int timeStamp)
if (isEmitConnected() || isEmitFollowConnected()) {
v8::HandleScope handle_scope;
- v8::Context::Scope scope(QDeclarativeEnginePrivate::getV8Engine(qmlEngine(this))->context());
+ v8::Context::Scope scope(QQmlEnginePrivate::getV8Engine(qmlEngine(this))->context());
v8::Handle<v8::Array> array = v8::Array::New(toEmit.size());
for (int i=0; i<toEmit.size(); i++)
array->Set(i, toEmit[i]->v8Value().toHandle());
if (isEmitFollowConnected())
- emitFollowParticles(QDeclarativeV8Handle::fromHandle(array), d->v8Value());//A chance for many arbitrary JS changes
+ emitFollowParticles(QQmlV8Handle::fromHandle(array), d->v8Value());//A chance for many arbitrary JS changes
else if (isEmitConnected())
- emitParticles(QDeclarativeV8Handle::fromHandle(array));//A chance for arbitrary JS changes
+ emitParticles(QQmlV8Handle::fromHandle(array));//A chance for arbitrary JS changes
}
foreach (QQuickParticleData* d, toEmit)
m_system->emitParticle(d);
diff --git a/src/quick/particles/qquicktrailemitter_p.h b/src/quick/particles/qquicktrailemitter_p.h
index bae6464c37..0b63a444ec 100644
--- a/src/quick/particles/qquicktrailemitter_p.h
+++ b/src/quick/particles/qquicktrailemitter_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -93,7 +93,7 @@ public:
}
signals:
- void emitFollowParticles(QDeclarativeV8Handle particles, QDeclarativeV8Handle followed);
+ void emitFollowParticles(QQmlV8Handle particles, QQmlV8Handle followed);
void particlesPerParticlePerSecondChanged(int arg);
diff --git a/src/quick/particles/qquickturbulence.cpp b/src/quick/particles/qquickturbulence.cpp
index db77e8d328..18ecc6a4cd 100644
--- a/src/quick/particles/qquickturbulence.cpp
+++ b/src/quick/particles/qquickturbulence.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickturbulence_p.h b/src/quick/particles/qquickturbulence_p.h
index cc0dfdc845..cd5535c387 100644
--- a/src/quick/particles/qquickturbulence_p.h
+++ b/src/quick/particles/qquickturbulence_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,7 +42,7 @@
#ifndef TURBULENCEAFFECTOR_H
#define TURBULENCEAFFECTOR_H
#include "qquickparticleaffector_p.h"
-#include <QDeclarativeListProperty>
+#include <QQmlListProperty>
QT_BEGIN_HEADER
diff --git a/src/quick/particles/qquickv8particledata.cpp b/src/quick/particles/qquickv8particledata.cpp
index 0a3e9f6e95..8e50e41091 100644
--- a/src/quick/particles/qquickv8particledata.cpp
+++ b/src/quick/particles/qquickv8particledata.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -497,9 +497,9 @@ QQuickV8ParticleData::~QQuickV8ParticleData()
qPersistentDispose(m_v8Value);
}
-QDeclarativeV8Handle QQuickV8ParticleData::v8Value()
+QQmlV8Handle QQuickV8ParticleData::v8Value()
{
- return QDeclarativeV8Handle::fromHandle(m_v8Value);
+ return QQmlV8Handle::fromHandle(m_v8Value);
}
QT_END_NAMESPACE
diff --git a/src/quick/particles/qquickv8particledata_p.h b/src/quick/particles/qquickv8particledata_p.h
index 4afcd89cf9..21ec6458c1 100644
--- a/src/quick/particles/qquickv8particledata_p.h
+++ b/src/quick/particles/qquickv8particledata_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -53,7 +53,7 @@ class QQuickV8ParticleData {
public:
QQuickV8ParticleData(QV8Engine*,QQuickParticleData*);
~QQuickV8ParticleData();
- QDeclarativeV8Handle v8Value();
+ QQmlV8Handle v8Value();
private:
v8::Persistent<v8::Object> m_v8Value;
};
diff --git a/src/quick/particles/qquickwander.cpp b/src/quick/particles/qquickwander.cpp
index ec86323e53..3e7cf33a64 100644
--- a/src/quick/particles/qquickwander.cpp
+++ b/src/quick/particles/qquickwander.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickwander_p.h b/src/quick/particles/qquickwander_p.h
index d71e55dd5f..bb418f7912 100644
--- a/src/quick/particles/qquickwander_p.h
+++ b/src/quick/particles/qquickwander_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/qtquick2.cpp b/src/quick/qtquick2.cpp
index f1417260b9..621c3ff18e 100644
--- a/src/quick/qtquick2.cpp
+++ b/src/quick/qtquick2.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,32 +40,32 @@
****************************************************************************/
#include "qtquick2_p.h"
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativeutilmodule_p.h>
-#include <private/qdeclarativevaluetype_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qquickutilmodule_p.h>
+#include <private/qqmlvaluetype_p.h>
#include <private/qquickitemsmodule_p.h>
#include <private/qquickparticlesmodule_p.h>
#include <private/qquickwindowmodule_p.h>
-#include <private/qdeclarativeenginedebugservice_p.h>
-#include <private/qdeclarativedebugstatesdelegate_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativecontext_p.h>
-#include <QtQuick/private/qdeclarativepropertychanges_p.h>
-#include <QtQuick/private/qdeclarativestate_p.h>
-#include <qdeclarativeproperty.h>
+#include <private/qqmlenginedebugservice_p.h>
+#include <private/qqmldebugstatesdelegate_p.h>
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlcontext_p.h>
+#include <QtQuick/private/qquickpropertychanges_p.h>
+#include <QtQuick/private/qquickstate_p.h>
+#include <qqmlproperty.h>
#include <QtCore/QWeakPointer>
QT_BEGIN_NAMESPACE
-class QDeclarativeQtQuick2DebugStatesDelegate : public QDeclarativeDebugStatesDelegate
+class QQmlQtQuick2DebugStatesDelegate : public QQmlDebugStatesDelegate
{
public:
- QDeclarativeQtQuick2DebugStatesDelegate();
- virtual ~QDeclarativeQtQuick2DebugStatesDelegate();
- virtual void buildStatesList(QDeclarativeContext *ctxt, bool cleanList);
- virtual void updateBinding(QDeclarativeContext *context,
- const QDeclarativeProperty &property,
+ QQmlQtQuick2DebugStatesDelegate();
+ virtual ~QQmlQtQuick2DebugStatesDelegate();
+ virtual void buildStatesList(QQmlContext *ctxt, bool cleanList);
+ virtual void updateBinding(QQmlContext *context,
+ const QQmlProperty &property,
const QVariant &expression, bool isLiteralValue,
const QString &fileName, int line, int column,
bool *isBaseState);
@@ -79,37 +79,37 @@ public:
private:
void buildStatesList(QObject *obj);
- QList<QWeakPointer<QDeclarativeState> > m_allStates;
+ QList<QWeakPointer<QQuickState> > m_allStates;
};
-QDeclarativeQtQuick2DebugStatesDelegate::QDeclarativeQtQuick2DebugStatesDelegate()
+QQmlQtQuick2DebugStatesDelegate::QQmlQtQuick2DebugStatesDelegate()
{
}
-QDeclarativeQtQuick2DebugStatesDelegate::~QDeclarativeQtQuick2DebugStatesDelegate()
+QQmlQtQuick2DebugStatesDelegate::~QQmlQtQuick2DebugStatesDelegate()
{
}
-void QDeclarativeQtQuick2DebugStatesDelegate::buildStatesList(QDeclarativeContext *ctxt, bool cleanList)
+void QQmlQtQuick2DebugStatesDelegate::buildStatesList(QQmlContext *ctxt, bool cleanList)
{
if (cleanList)
m_allStates.clear();
- QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt);
+ QQmlContextPrivate *ctxtPriv = QQmlContextPrivate::get(ctxt);
for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
buildStatesList(ctxtPriv->instances.at(ii));
}
- QDeclarativeContextData *child = QDeclarativeContextData::get(ctxt)->childContexts;
+ QQmlContextData *child = QQmlContextData::get(ctxt)->childContexts;
while (child) {
- buildStatesList(child->asQDeclarativeContext());
+ buildStatesList(child->asQQmlContext());
child = child->nextChild;
}
}
-void QDeclarativeQtQuick2DebugStatesDelegate::buildStatesList(QObject *obj)
+void QQmlQtQuick2DebugStatesDelegate::buildStatesList(QObject *obj)
{
- if (QDeclarativeState *state = qobject_cast<QDeclarativeState *>(obj)) {
+ if (QQuickState *state = qobject_cast<QQuickState *>(obj)) {
m_allStates.append(state);
}
@@ -119,23 +119,23 @@ void QDeclarativeQtQuick2DebugStatesDelegate::buildStatesList(QObject *obj)
}
}
-void QDeclarativeQtQuick2DebugStatesDelegate::updateBinding(QDeclarativeContext *context,
- const QDeclarativeProperty &property,
+void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context,
+ const QQmlProperty &property,
const QVariant &expression, bool isLiteralValue,
const QString &fileName, int line, int column,
bool *inBaseState)
{
QObject *object = property.object();
QString propertyName = property.name();
- foreach (QWeakPointer<QDeclarativeState> statePointer, m_allStates) {
- if (QDeclarativeState *state = statePointer.data()) {
+ foreach (QWeakPointer<QQuickState> statePointer, m_allStates) {
+ if (QQuickState *state = statePointer.data()) {
// here we assume that the revert list on itself defines the base state
if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) {
*inBaseState = false;
- QDeclarativeBinding *newBinding = 0;
+ QQmlBinding *newBinding = 0;
if (!isLiteralValue) {
- newBinding = new QDeclarativeBinding(expression.toString(), object, context);
+ newBinding = new QQmlBinding(expression.toString(), object, context);
newBinding->setTarget(property);
newBinding->setNotifyOnValueChanged(true);
newBinding->setSourceLocation(fileName, line, column);
@@ -150,12 +150,12 @@ void QDeclarativeQtQuick2DebugStatesDelegate::updateBinding(QDeclarativeContext
}
}
-bool QDeclarativeQtQuick2DebugStatesDelegate::setBindingForInvalidProperty(QObject *object,
+bool QQmlQtQuick2DebugStatesDelegate::setBindingForInvalidProperty(QObject *object,
const QString &propertyName,
const QVariant &expression,
bool isLiteralValue)
{
- if (QDeclarativePropertyChanges *propertyChanges = qobject_cast<QDeclarativePropertyChanges *>(object)) {
+ if (QQuickPropertyChanges *propertyChanges = qobject_cast<QQuickPropertyChanges *>(object)) {
if (isLiteralValue)
propertyChanges->changeValue(propertyName, expression);
else
@@ -166,26 +166,26 @@ bool QDeclarativeQtQuick2DebugStatesDelegate::setBindingForInvalidProperty(QObje
}
}
-void QDeclarativeQtQuick2DebugStatesDelegate::resetBindingForInvalidProperty(QObject *object, const QString &propertyName)
+void QQmlQtQuick2DebugStatesDelegate::resetBindingForInvalidProperty(QObject *object, const QString &propertyName)
{
- if (QDeclarativePropertyChanges *propertyChanges = qobject_cast<QDeclarativePropertyChanges *>(object)) {
+ if (QQuickPropertyChanges *propertyChanges = qobject_cast<QQuickPropertyChanges *>(object)) {
propertyChanges->removeProperty(propertyName);
}
}
-void QDeclarativeQtQuick2Module::defineModule()
+void QQmlQtQuick2Module::defineModule()
{
- QDeclarativeUtilModule::defineModule();
- QDeclarativeEnginePrivate::defineModule();
+ QQuickUtilModule::defineModule();
+ QQmlEnginePrivate::defineModule();
QQuickItemsModule::defineModule();
QQuickParticlesModule::defineModule();
QQuickWindowModule::defineModule();
- QDeclarativeValueTypeFactory::registerValueTypes();
+ QQmlValueTypeFactory::registerValueTypes();
- if (QDeclarativeEngineDebugService::isDebuggingEnabled()) {
- QDeclarativeEngineDebugService::instance()->setStatesDelegate(
- new QDeclarativeQtQuick2DebugStatesDelegate);
+ if (QQmlEngineDebugService::isDebuggingEnabled()) {
+ QQmlEngineDebugService::instance()->setStatesDelegate(
+ new QQmlQtQuick2DebugStatesDelegate);
}
}
diff --git a/src/quick/qtquick2_p.h b/src/quick/qtquick2_p.h
index e242179dfa..4032991776 100644
--- a/src/quick/qtquick2_p.h
+++ b/src/quick/qtquick2_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -48,7 +48,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeQtQuick2Module
+class Q_QUICK_PRIVATE_EXPORT QQmlQtQuick2Module
{
public:
static void defineModule();
diff --git a/src/quick/qtquickglobal.h b/src/quick/qtquickglobal.h
index b5eb962a2f..a1d8c714e8 100644
--- a/src/quick/qtquickglobal.h
+++ b/src/quick/qtquickglobal.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/qtquickglobal_p.h b/src/quick/qtquickglobal_p.h
index 539040727c..34ceeedff9 100644
--- a/src/quick/qtquickglobal_p.h
+++ b/src/quick/qtquickglobal_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/quick.pro b/src/quick/quick.pro
index b445e84248..0f0120ee79 100644
--- a/src/quick/quick.pro
+++ b/src/quick/quick.pro
@@ -6,13 +6,13 @@ CONFIG += module
CONFIG += dll warn_on
MODULE_PRI = ../../modules/qt_quick.pri
-QT = core-private gui gui-private network v8-private declarative declarative-private
+QT = core-private gui gui-private network v8-private qml qml-private
DEFINES += QT_BUILD_QUICK_LIB QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES
win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS
solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
-exists("qdeclarative_enable_gcov") {
+exists("qqml_enable_gcov") {
QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors
LIBS += -lgcov
}
@@ -36,12 +36,12 @@ mac {
# FIXME: this is a workaround for broken qmake logic in qtAddModule()
# This function refuses to use frameworks unless the framework exists on
# the filesystem at the time qmake is run, resulting in a build failure
- # if QtQuick is qmaked before QtDeclarative is built and frameworks are
+ # if QtQuick is qmaked before QtQml is built and frameworks are
# in use. qtAddLibrary() contains correct logic to deal with this, so
# we'll explicitly call that for now.
load(qt)
- LIBS -= -lQtDeclarative # in non-framework builds, these should be re-added
- LIBS -= -lQtDeclarative_debug # within the qtAddLibrary if appropriate, so no
- qtAddLibrary(QtDeclarative) # harm done :)
+ LIBS -= -lQtQml # in non-framework builds, these should be re-added
+ LIBS -= -lQtQml_debug # within the qtAddLibrary if appropriate, so no
+ qtAddLibrary(QtQml) # harm done :)
}
diff --git a/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp b/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
index bbea89b5ca..7a219585b0 100644
--- a/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h b/src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h
index 9ef7622a78..3896d03a80 100644
--- a/src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsggeometry_p.h b/src/quick/scenegraph/coreapi/qsggeometry_p.h
index 0b388ec587..63defa2374 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry_p.h
+++ b/src/quick/scenegraph/coreapi/qsggeometry_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index 308a1fa572..9f0def4706 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h
index 0673aca814..450dd2866f 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp
index 618538642e..5c14bd5bc7 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h
index b7e776dbe8..6ba110b91e 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.h
+++ b/src/quick/scenegraph/coreapi/qsgnode.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgnodeupdater.cpp b/src/quick/scenegraph/coreapi/qsgnodeupdater.cpp
index 2562e8d56c..78f007af80 100644
--- a/src/quick/scenegraph/coreapi/qsgnodeupdater.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnodeupdater.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgnodeupdater_p.h b/src/quick/scenegraph/coreapi/qsgnodeupdater_p.h
index 0ad9d76586..c1df82332e 100644
--- a/src/quick/scenegraph/coreapi/qsgnodeupdater_p.h
+++ b/src/quick/scenegraph/coreapi/qsgnodeupdater_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
index 9737fbb294..30dd449b4b 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index 9b177abd6b..9d2402d727 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode.cpp b/src/quick/scenegraph/coreapi/qsgrendernode.cpp
index 0697fbe630..ee9fd9fbbb 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendernode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode_p.h b/src/quick/scenegraph/coreapi/qsgrendernode_p.h
index a2f2be828e..45636cc796 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrendernode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index 2795d4d9a8..92045c55f4 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index 39566c96ac..47dfdb4d8c 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 877278116f..10276c17f8 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -50,13 +50,13 @@
#include <QtQuick/private/qsgshareddistancefieldglyphcache_p.h>
#include <QtQuick/private/qsgtexture_p.h>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
#include <QGuiApplication>
#include <QOpenGLContext>
-#include <QDeclarativeImageProvider>
-#include <private/qdeclarativeglobal_p.h>
+#include <QQmlImageProvider>
+#include <private/qqmlglobal_p.h>
#include <QtQuick/private/qsgtexture_p.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -110,7 +110,7 @@ public:
QOpenGLContext *gl;
QHash<QSGMaterialType *, QSGMaterialShader *> materials;
- QHash<QDeclarativeTextureFactory *, QSGTexture *> textures;
+ QHash<QQuickTextureFactory *, QSGTexture *> textures;
QSGDistanceFieldGlyphCacheManager *distanceFieldCacheManager;
@@ -160,7 +160,7 @@ void QSGContext::invalidate()
}
-QSGTexture *QSGContext::textureForFactory(QDeclarativeTextureFactory *factory, QQuickCanvas *canvas)
+QSGTexture *QSGContext::textureForFactory(QQuickTextureFactory *factory, QQuickCanvas *canvas)
{
Q_D(QSGContext);
if (!factory)
@@ -168,7 +168,7 @@ QSGTexture *QSGContext::textureForFactory(QDeclarativeTextureFactory *factory, Q
QSGTexture *texture = d->textures.value(factory);
if (!texture) {
- if (QDeclarativeDefaultTextureFactory *dtf = qobject_cast<QDeclarativeDefaultTextureFactory *>(factory))
+ if (QQuickDefaultTextureFactory *dtf = qobject_cast<QQuickDefaultTextureFactory *>(factory))
texture = createTexture(dtf->image());
else
texture = factory->createTexture(canvas);
@@ -182,7 +182,7 @@ QSGTexture *QSGContext::textureForFactory(QDeclarativeTextureFactory *factory, Q
void QSGContext::textureFactoryDestroyed(QObject *o)
{
Q_D(QSGContext);
- QDeclarativeTextureFactory *f = static_cast<QDeclarativeTextureFactory *>(o);
+ QQuickTextureFactory *f = static_cast<QQuickTextureFactory *>(o);
// This function will only be called on the scene graph thread, so it is
// safe to directly delete the texture here.
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 7fa3838db9..0f8b5ae1de 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -72,7 +72,7 @@ class QSGEngine;
class QOpenGLContext;
class QOpenGLFramebufferObject;
-class QDeclarativeTextureFactory;
+class QQuickTextureFactory;
class Q_QUICK_EXPORT QSGContext : public QObject
{
@@ -106,7 +106,7 @@ public:
virtual QSurfaceFormat defaultSurfaceFormat() const;
- QSGTexture *textureForFactory(QDeclarativeTextureFactory *factory, QQuickCanvas *canvas);
+ QSGTexture *textureForFactory(QQuickTextureFactory *factory, QQuickCanvas *canvas);
static QSGContext *createDefaultContext();
@@ -121,7 +121,7 @@ public:
virtual QAnimationDriver *createAnimationDriver(QObject *parent);
- static QDeclarativeTextureFactory *createTextureFactoryFromImage(const QImage &image);
+ static QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image);
public slots:
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp
index 6382d42462..b8a66fd0c0 100644
--- a/src/quick/scenegraph/qsgcontextplugin.cpp
+++ b/src/quick/scenegraph/qsgcontextplugin.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -135,7 +135,7 @@ QSGContext *QSGContext::createDefaultContext()
/*!
- \fn QDeclarativeTextureFactory *createTextureFactoryFromImage(const QImage &image)
+ \fn QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image)
Calls into the scene graph adaptation if available and creates a texture
factory. The primary purpose of this function is to reimplement hardware
@@ -143,7 +143,7 @@ QSGContext *QSGContext::createDefaultContext()
the image providers thread.
*/
-QDeclarativeTextureFactory *QSGContext::createTextureFactoryFromImage(const QImage &image)
+QQuickTextureFactory *QSGContext::createTextureFactoryFromImage(const QImage &image)
{
QSGAdaptionPluginData *plugin = contextFactory();
if (plugin->factory)
diff --git a/src/quick/scenegraph/qsgcontextplugin_p.h b/src/quick/scenegraph/qsgcontextplugin_p.h
index 6080c8b394..d0d8ea143b 100644
--- a/src/quick/scenegraph/qsgcontextplugin_p.h
+++ b/src/quick/scenegraph/qsgcontextplugin_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -46,7 +46,7 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-#include <QDeclarativeImageProvider>
+#include <QQmlImageProvider>
QT_BEGIN_HEADER
@@ -58,7 +58,7 @@ struct Q_QUICK_EXPORT QSGContextFactoryInterface : public QFactoryInterface
{
virtual QSGContext *create(const QString &key) const = 0;
- virtual QDeclarativeTextureFactory *createTextureFactoryFromImage(const QImage &image) = 0;
+ virtual QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image) = 0;
};
#define QSGContextFactoryInterface_iid \
@@ -76,7 +76,7 @@ public:
virtual QStringList keys() const = 0;
virtual QSGContext *create(const QString &key) const = 0;
- virtual QDeclarativeTextureFactory *createTextureFactoryFromImage(const QImage &) { return 0; }
+ virtual QQuickTextureFactory *createTextureFactoryFromImage(const QImage &) { return 0; }
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index 08f05075da..05d076ec1e 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
index 7fc2ee63d4..76e4a64e60 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode.cpp b/src/quick/scenegraph/qsgdefaultglyphnode.cpp
index 70f561b61e..f84cd203fa 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index adc092b1c6..33f02a8ac0 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p.h
index b7c7e61014..66662d936a 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
index 6b99ade8b0..d640d4cc2c 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultimagenode.cpp b/src/quick/scenegraph/qsgdefaultimagenode.cpp
index a6d6df8a00..e6855c4c78 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultimagenode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultimagenode_p.h b/src/quick/scenegraph/qsgdefaultimagenode_p.h
index 49c09dbfcd..9062aff2c2 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultimagenode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
index 3d15f6944d..18cac36550 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
@@ -4,7 +4,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
index a5e43f8581..faa2b6a43c 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
index 7b30af85c3..79e5c3b0f4 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index f9c8349c2c..c66b82c16e 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
index df5b8c6f6c..65ac2d499c 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
index 0aee5bb340..c4af15a2af 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgflashnode.cpp b/src/quick/scenegraph/qsgflashnode.cpp
index 0988b23920..9359f5d9c5 100644
--- a/src/quick/scenegraph/qsgflashnode.cpp
+++ b/src/quick/scenegraph/qsgflashnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgflashnode_p.h b/src/quick/scenegraph/qsgflashnode_p.h
index 91614ceb0b..68ae6eecd1 100644
--- a/src/quick/scenegraph/qsgflashnode_p.h
+++ b/src/quick/scenegraph/qsgflashnode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgpathsimplifier.cpp b/src/quick/scenegraph/qsgpathsimplifier.cpp
new file mode 100644
index 0000000000..3adf8d71c7
--- /dev/null
+++ b/src/quick/scenegraph/qsgpathsimplifier.cpp
@@ -0,0 +1,1673 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgpathsimplifier_p.h"
+
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qalgorithms.h>
+
+#include <math.h>
+
+#include <private/qopengl_p.h>
+#include <private/qrbtree_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#define Q_FIXED_POINT_SCALE 256
+#define Q_TRIANGULATE_END_OF_POLYGON quint32(-1)
+
+
+namespace {
+
+//============================================================================//
+// QPoint //
+//============================================================================//
+
+inline bool operator < (const QPoint &a, const QPoint &b)
+{
+ return a.y() < b.y() || (a.y() == b.y() && a.x() < b.x());
+}
+
+inline bool operator > (const QPoint &a, const QPoint &b)
+{
+ return b < a;
+}
+
+inline bool operator <= (const QPoint &a, const QPoint &b)
+{
+ return !(a > b);
+}
+
+inline bool operator >= (const QPoint &a, const QPoint &b)
+{
+ return !(a < b);
+}
+
+inline int cross(const QPoint &u, const QPoint &v)
+{
+ return u.x() * v.y() - u.y() * v.x();
+}
+
+inline int dot(const QPoint &u, const QPoint &v)
+{
+ return u.x() * v.x() + u.y() * v.y();
+}
+
+//============================================================================//
+// Fraction //
+//============================================================================//
+
+// Fraction must be in the range [0, 1)
+struct Fraction
+{
+ bool isValid() const { return denominator != 0; }
+
+ // numerator and denominator must not have common denominators.
+ unsigned int numerator, denominator;
+};
+
+inline unsigned int gcd(unsigned int x, unsigned int y)
+{
+ while (y != 0) {
+ unsigned int z = y;
+ y = x % y;
+ x = z;
+ }
+ return x;
+}
+
+// Fraction must be in the range [0, 1)
+// Assume input is valid.
+Fraction fraction(unsigned int n, unsigned int d) {
+ Fraction result;
+ if (n == 0) {
+ result.numerator = 0;
+ result.denominator = 1;
+ } else {
+ unsigned int g = gcd(n, d);
+ result.numerator = n / g;
+ result.denominator = d / g;
+ }
+ return result;
+}
+
+//============================================================================//
+// Rational //
+//============================================================================//
+
+struct Rational
+{
+ bool isValid() const { return fraction.isValid(); }
+ int integer;
+ Fraction fraction;
+};
+
+//============================================================================//
+// IntersectionPoint //
+//============================================================================//
+
+struct IntersectionPoint
+{
+ bool isValid() const { return x.fraction.isValid() && y.fraction.isValid(); }
+ QPoint round() const;
+ bool isAccurate() const { return x.fraction.numerator == 0 && y.fraction.numerator == 0; }
+
+ Rational x; // 8:8 signed, 32/32
+ Rational y; // 8:8 signed, 32/32
+};
+
+QPoint IntersectionPoint::round() const
+{
+ QPoint result(x.integer, y.integer);
+ if (2 * x.fraction.numerator >= x.fraction.denominator)
+ ++result.rx();
+ if (2 * y.fraction.numerator >= y.fraction.denominator)
+ ++result.ry();
+ return result;
+}
+
+// Return positive value if 'p' is to the right of the line 'v1'->'v2', negative if left of the
+// line and zero if exactly on the line.
+// The returned value is the z-component of the qCross product between 'v2-v1' and 'p-v1',
+// which is twice the signed area of the triangle 'p'->'v1'->'v2' (positive for CW order).
+inline int pointDistanceFromLine(const QPoint &p, const QPoint &v1, const QPoint &v2)
+{
+ return cross(v2 - v1, p - v1);
+}
+
+IntersectionPoint intersectionPoint(const QPoint &u1, const QPoint &u2,
+ const QPoint &v1, const QPoint &v2)
+{
+ IntersectionPoint result = {{0, {0, 0}}, {0, {0, 0}}};
+
+ QPoint u = u2 - u1;
+ QPoint v = v2 - v1;
+ int d1 = cross(u, v1 - u1);
+ int d2 = cross(u, v2 - u1);
+ int det = d2 - d1;
+ int d3 = cross(v, u1 - v1);
+ int d4 = d3 - det; //qCross(v, u2 - v1);
+
+ // Check that the math is correct.
+ Q_ASSERT(d4 == cross(v, u2 - v1));
+
+ // The intersection point can be expressed as:
+ // v1 - v * d1/det
+ // v2 - v * d2/det
+ // u1 + u * d3/det
+ // u2 + u * d4/det
+
+ // I'm only interested in lines that are crossing, so ignore parallel lines even if they overlap.
+ if (det == 0)
+ return result;
+
+ if (det < 0) {
+ det = -det;
+ d1 = -d1;
+ d2 = -d2;
+ d3 = -d3;
+ d4 = -d4;
+ }
+
+ // I'm only interested in lines intersecting at their interior, not at their end points.
+ // The lines intersect at their interior if and only if 'd1 < 0', 'd2 > 0', 'd3 < 0' and 'd4 > 0'.
+ if (d1 >= 0 || d2 <= 0 || d3 <= 0 || d4 >= 0)
+ return result;
+
+ // Calculate the intersection point as follows:
+ // v1 - v * d1/det | v1 <= v2 (component-wise)
+ // v2 - v * d2/det | v2 < v1 (component-wise)
+
+ // Assuming 16 bits per vector component.
+ if (v.x() >= 0) {
+ result.x.integer = v1.x() + int(qint64(-v.x()) * d1 / det);
+ result.x.fraction = fraction((unsigned int)(qint64(-v.x()) * d1 % det), (unsigned int)det);
+ } else {
+ result.x.integer = v2.x() + int(qint64(-v.x()) * d2 / det);
+ result.x.fraction = fraction((unsigned int)(qint64(-v.x()) * d2 % det), (unsigned int)det);
+ }
+
+ if (v.y() >= 0) {
+ result.y.integer = v1.y() + int(qint64(-v.y()) * d1 / det);
+ result.y.fraction = fraction((unsigned int)(qint64(-v.y()) * d1 % det), (unsigned int)det);
+ } else {
+ result.y.integer = v2.y() + int(qint64(-v.y()) * d2 / det);
+ result.y.fraction = fraction((unsigned int)(qint64(-v.y()) * d2 % det), (unsigned int)det);
+ }
+
+ Q_ASSERT(result.x.fraction.isValid());
+ Q_ASSERT(result.y.fraction.isValid());
+ return result;
+}
+
+//============================================================================//
+// PathSimplifier //
+//============================================================================//
+
+class PathSimplifier
+{
+public:
+ PathSimplifier(const QVectorPath &path, QDataBuffer<QPoint> &vertices,
+ QDataBuffer<quint32> &indices, const QTransform &matrix);
+
+private:
+ struct Element;
+
+ class BoundingVolumeHierarchy
+ {
+ public:
+ struct Node
+ {
+ enum Type
+ {
+ Leaf,
+ Split
+ };
+ Type type;
+ QPoint minimum;
+ QPoint maximum;
+ union {
+ Element *element; // type == Leaf
+ Node *left; // type == Split
+ };
+ Node *right;
+ };
+
+ BoundingVolumeHierarchy();
+ ~BoundingVolumeHierarchy();
+ void allocate(int nodeCount);
+ void free();
+ Node *newNode();
+
+ Node *root;
+ private:
+ void freeNode(Node *n);
+
+ Node *nodeBlock;
+ int blockSize;
+ int firstFree;
+ };
+
+ struct Element
+ {
+ enum Degree
+ {
+ Line = 1,
+ Quadratic = 2,
+ Cubic = 3
+ };
+
+ quint32 &upperIndex() { return indices[pointingUp ? degree : 0]; }
+ quint32 &lowerIndex() { return indices[pointingUp ? 0 : degree]; }
+ quint32 upperIndex() const { return indices[pointingUp ? degree : 0]; }
+ quint32 lowerIndex() const { return indices[pointingUp ? 0 : degree]; }
+ void flip();
+
+ QPoint middle;
+ quint32 indices[4]; // index to points
+ Element *next, *previous; // used in connectElements()
+ int winding; // used in connectElements()
+ union {
+ QRBTree<Element *>::Node *edgeNode; // used in connectElements()
+ BoundingVolumeHierarchy::Node *bvhNode;
+ };
+ Degree degree : 8;
+ uint processed : 1; // initially false, true when the element has been checked for intersections.
+ uint pointingUp : 1; // used in connectElements()
+ uint originallyPointingUp : 1; // used in connectElements()
+ };
+
+ class ElementAllocator
+ {
+ public:
+ ElementAllocator();
+ ~ElementAllocator();
+ void allocate(int count);
+ Element *newElement();
+ private:
+ struct ElementBlock
+ {
+ ElementBlock *next;
+ int blockSize;
+ int firstFree;
+ Element elements[1];
+ } *blocks;
+ };
+
+ struct Event
+ {
+ enum Type { Upper, Lower };
+ bool operator < (const Event &other) const;
+
+ QPoint point;
+ Type type;
+ Element *element;
+ };
+
+ typedef QRBTree<Element *>::Node RBNode;
+ typedef BoundingVolumeHierarchy::Node BVHNode;
+
+ void initElements(const QVectorPath &path, const QTransform &matrix);
+ void removeIntersections();
+ void connectElements();
+ void fillIndices();
+ BVHNode *buildTree(Element **elements, int elementCount);
+ bool intersectNodes(QDataBuffer<Element *> &elements, BVHNode *elementNode, BVHNode *treeNode);
+ bool equalElements(const Element *e1, const Element *e2);
+ bool splitLineAt(QDataBuffer<Element *> &elements, BVHNode *node, quint32 pointIndex, bool processAgain);
+ void appendSeparatingAxes(QVarLengthArray<QPoint, 12> &axes, Element *element);
+ QPair<int, int> calculateSeparatingAxisRange(const QPoint &axis, Element *element);
+ void splitCurve(QDataBuffer<Element *> &elements, BVHNode *node);
+ bool setElementToQuadratic(Element *element, quint32 pointIndex1, const QPoint &ctrl, quint32 pointIndex2);
+ bool setElementToCubic(Element *element, quint32 pointIndex1, const QPoint &ctrl1, const QPoint &ctrl2, quint32 pointIndex2);
+ void setElementToCubicAndSimplify(Element *element, quint32 pointIndex1, const QPoint &ctrl1, const QPoint &ctrl2, quint32 pointIndex2);
+ RBNode *findElementLeftOf(const Element *element, const QPair<RBNode *, RBNode *> &bounds);
+ bool elementIsLeftOf(const Element *left, const Element *right);
+ QPair<RBNode *, RBNode *> outerBounds(const QPoint &point);
+ static bool flattenQuadratic(const QPoint &u, const QPoint &v, const QPoint &w);
+ static bool flattenCubic(const QPoint &u, const QPoint &v, const QPoint &w, const QPoint &q);
+ static bool splitQuadratic(const QPoint &u, const QPoint &v, const QPoint &w, QPoint *result);
+ static bool splitCubic(const QPoint &u, const QPoint &v, const QPoint &w, const QPoint &q, QPoint *result);
+ void subDivQuadratic(const QPoint &u, const QPoint &v, const QPoint &w);
+ void subDivCubic(const QPoint &u, const QPoint &v, const QPoint &w, const QPoint &q);
+ static void sortEvents(Event *events, int count);
+
+ ElementAllocator m_elementAllocator;
+ QDataBuffer<Element *> m_elements;
+ QDataBuffer<QPoint> *m_points;
+ BoundingVolumeHierarchy m_bvh;
+ QDataBuffer<quint32> *m_indices;
+ QRBTree<Element *> m_elementList;
+ uint m_hints;
+};
+
+inline PathSimplifier::BoundingVolumeHierarchy::BoundingVolumeHierarchy()
+ : root(0)
+ , nodeBlock(0)
+ , blockSize(0)
+ , firstFree(0)
+{
+}
+
+inline PathSimplifier::BoundingVolumeHierarchy::~BoundingVolumeHierarchy()
+{
+ free();
+}
+
+inline void PathSimplifier::BoundingVolumeHierarchy::allocate(int nodeCount)
+{
+ Q_ASSERT(nodeBlock == 0);
+ Q_ASSERT(firstFree == 0);
+ nodeBlock = new Node[blockSize = nodeCount];
+}
+
+inline void PathSimplifier::BoundingVolumeHierarchy::free()
+{
+ freeNode(root);
+ delete[] nodeBlock;
+ nodeBlock = 0;
+ firstFree = blockSize = 0;
+ root = 0;
+}
+
+inline PathSimplifier::BVHNode *PathSimplifier::BoundingVolumeHierarchy::newNode()
+{
+ if (firstFree < blockSize)
+ return &nodeBlock[firstFree++];
+ return new Node;
+}
+
+inline void PathSimplifier::BoundingVolumeHierarchy::freeNode(Node *n)
+{
+ if (!n)
+ return;
+ Q_ASSERT(n->type == Node::Split || n->type == Node::Leaf);
+ if (n->type == Node::Split) {
+ freeNode(n->left);
+ freeNode(n->right);
+ }
+ if (!(n >= nodeBlock && n < nodeBlock + blockSize))
+ delete n;
+}
+
+inline PathSimplifier::ElementAllocator::ElementAllocator()
+ : blocks(0)
+{
+}
+
+inline PathSimplifier::ElementAllocator::~ElementAllocator()
+{
+ while (blocks) {
+ ElementBlock *block = blocks;
+ blocks = blocks->next;
+ free(block);
+ }
+}
+
+inline void PathSimplifier::ElementAllocator::allocate(int count)
+{
+ Q_ASSERT(blocks == 0);
+ Q_ASSERT(count > 0);
+ blocks = (ElementBlock *)malloc(sizeof(ElementBlock) + (count - 1) * sizeof(Element));
+ blocks->blockSize = count;
+ blocks->next = 0;
+ blocks->firstFree = 0;
+}
+
+inline PathSimplifier::Element *PathSimplifier::ElementAllocator::newElement()
+{
+ Q_ASSERT(blocks);
+ if (blocks->firstFree < blocks->blockSize)
+ return &blocks->elements[blocks->firstFree++];
+ ElementBlock *oldBlock = blocks;
+ blocks = (ElementBlock *)malloc(sizeof(ElementBlock) + (oldBlock->blockSize - 1) * sizeof(Element));
+ blocks->blockSize = oldBlock->blockSize;
+ blocks->next = oldBlock;
+ blocks->firstFree = 0;
+ return &blocks->elements[blocks->firstFree++];
+}
+
+
+inline bool PathSimplifier::Event::operator < (const Event &other) const
+{
+ if (point == other.point)
+ return type < other.type;
+ return other.point < point;
+}
+
+inline void PathSimplifier::Element::flip()
+{
+ for (int i = 0; i < (degree + 1) >> 1; ++i) {
+ Q_ASSERT(degree >= Line && degree <= Cubic);
+ Q_ASSERT(i >= 0 && i < degree);
+ qSwap(indices[i], indices[degree - i]);
+ }
+ pointingUp = !pointingUp;
+ Q_ASSERT(next == 0 && previous == 0);
+}
+
+PathSimplifier::PathSimplifier(const QVectorPath &path, QDataBuffer<QPoint> &vertices,
+ QDataBuffer<quint32> &indices, const QTransform &matrix)
+ : m_elements(0)
+ , m_points(&vertices)
+ , m_indices(&indices)
+{
+ m_points->reset();
+ m_indices->reset();
+ initElements(path, matrix);
+ if (!m_elements.isEmpty()) {
+ removeIntersections();
+ connectElements();
+ fillIndices();
+ }
+}
+
+void PathSimplifier::initElements(const QVectorPath &path, const QTransform &matrix)
+{
+ m_hints = path.hints();
+ int pathElementCount = path.elementCount();
+ if (pathElementCount == 0)
+ return;
+ m_elements.reserve(2 * pathElementCount);
+ m_elementAllocator.allocate(2 * pathElementCount);
+ m_points->reserve(2 * pathElementCount);
+ const QPainterPath::ElementType *e = path.elements();
+ const qreal *p = path.points();
+ if (e) {
+ qreal x, y;
+ quint32 moveToIndex = 0;
+ quint32 previousIndex = 0;
+ for (int i = 0; i < pathElementCount; ++i, ++e, p += 2) {
+ switch (*e) {
+ case QPainterPath::MoveToElement:
+ {
+ if (!m_points->isEmpty()) {
+ const QPoint &from = m_points->at(previousIndex);
+ const QPoint &to = m_points->at(moveToIndex);
+ if (from != to) {
+ Element *element = m_elementAllocator.newElement();
+ element->degree = Element::Line;
+ element->indices[0] = previousIndex;
+ element->indices[1] = moveToIndex;
+ element->middle.rx() = (from.x() + to.x()) >> 1;
+ element->middle.ry() = (from.y() + to.y()) >> 1;
+ m_elements.add(element);
+ }
+ }
+ previousIndex = moveToIndex = m_points->size();
+ matrix.map(p[0], p[1], &x, &y);
+ QPoint to(qRound(x * Q_FIXED_POINT_SCALE), qRound(y * Q_FIXED_POINT_SCALE));
+ m_points->add(to);
+ }
+ break;
+ case QPainterPath::LineToElement:
+ Q_ASSERT(!m_points->isEmpty());
+ {
+ matrix.map(p[0], p[1], &x, &y);
+ QPoint to(qRound(x * Q_FIXED_POINT_SCALE), qRound(y * Q_FIXED_POINT_SCALE));
+ const QPoint &from = m_points->last();
+ if (to != from) {
+ Element *element = m_elementAllocator.newElement();
+ element->degree = Element::Line;
+ element->indices[0] = previousIndex;
+ element->indices[1] = quint32(m_points->size());
+ element->middle.rx() = (from.x() + to.x()) >> 1;
+ element->middle.ry() = (from.y() + to.y()) >> 1;
+ m_elements.add(element);
+ previousIndex = m_points->size();
+ m_points->add(to);
+ }
+ }
+ break;
+ case QPainterPath::CurveToElement:
+ Q_ASSERT(i + 2 < pathElementCount);
+ Q_ASSERT(!m_points->isEmpty());
+ Q_ASSERT(e[1] == QPainterPath::CurveToDataElement);
+ Q_ASSERT(e[2] == QPainterPath::CurveToDataElement);
+ {
+ quint32 startPointIndex = previousIndex;
+ matrix.map(p[4], p[5], &x, &y);
+ QPoint end(qRound(x * Q_FIXED_POINT_SCALE), qRound(y * Q_FIXED_POINT_SCALE));
+ previousIndex = m_points->size();
+ m_points->add(end);
+
+ // See if this cubic bezier is really quadratic.
+ qreal x1 = p[-2] + qreal(1.5) * (p[0] - p[-2]);
+ qreal y1 = p[-1] + qreal(1.5) * (p[1] - p[-1]);
+ qreal x2 = p[4] + qreal(1.5) * (p[2] - p[4]);
+ qreal y2 = p[5] + qreal(1.5) * (p[3] - p[5]);
+
+ Element *element = m_elementAllocator.newElement();
+ if (qAbs(x1 - x2) < qreal(1e-3) && qAbs(y1 - y2) < qreal(1e-3)) {
+ // The bezier curve is quadratic.
+ matrix.map(x1, y1, &x, &y);
+ QPoint ctrl(qRound(x * Q_FIXED_POINT_SCALE),
+ qRound(y * Q_FIXED_POINT_SCALE));
+ setElementToQuadratic(element, startPointIndex, ctrl, previousIndex);
+ } else {
+ // The bezier curve is cubic.
+ matrix.map(p[0], p[1], &x, &y);
+ QPoint ctrl1(qRound(x * Q_FIXED_POINT_SCALE),
+ qRound(y * Q_FIXED_POINT_SCALE));
+ matrix.map(p[2], p[3], &x, &y);
+ QPoint ctrl2(qRound(x * Q_FIXED_POINT_SCALE),
+ qRound(y * Q_FIXED_POINT_SCALE));
+ setElementToCubicAndSimplify(element, startPointIndex, ctrl1, ctrl2,
+ previousIndex);
+ }
+ m_elements.add(element);
+ }
+ i += 2;
+ e += 2;
+ p += 4;
+
+ break;
+ default:
+ Q_ASSERT_X(0, "QSGPathSimplifier::initialize", "Unexpected element type.");
+ break;
+ }
+ }
+ if (!m_points->isEmpty()) {
+ const QPoint &from = m_points->at(previousIndex);
+ const QPoint &to = m_points->at(moveToIndex);
+ if (from != to) {
+ Element *element = m_elementAllocator.newElement();
+ element->degree = Element::Line;
+ element->indices[0] = previousIndex;
+ element->indices[1] = moveToIndex;
+ element->middle.rx() = (from.x() + to.x()) >> 1;
+ element->middle.ry() = (from.y() + to.y()) >> 1;
+ m_elements.add(element);
+ }
+ }
+ } else {
+ qreal x, y;
+
+ for (int i = 0; i < pathElementCount; ++i, p += 2) {
+ matrix.map(p[0], p[1], &x, &y);
+ QPoint to(qRound(x * Q_FIXED_POINT_SCALE), qRound(y * Q_FIXED_POINT_SCALE));
+ if (to != m_points->last())
+ m_points->add(to);
+ }
+
+ while (!m_points->isEmpty() && m_points->last() == m_points->first())
+ m_points->pop_back();
+
+ if (m_points->isEmpty())
+ return;
+
+ quint32 prev = quint32(m_points->size() - 1);
+ for (int i = 0; i < m_points->size(); ++i) {
+ QPoint &to = m_points->at(i);
+ QPoint &from = m_points->at(prev);
+ Element *element = m_elementAllocator.newElement();
+ element->degree = Element::Line;
+ element->indices[0] = prev;
+ element->indices[1] = quint32(i);
+ element->middle.rx() = (from.x() + to.x()) >> 1;
+ element->middle.ry() = (from.y() + to.y()) >> 1;
+ m_elements.add(element);
+ prev = i;
+ }
+ }
+
+ for (int i = 0; i < m_elements.size(); ++i)
+ m_elements.at(i)->processed = false;
+}
+
+void PathSimplifier::removeIntersections()
+{
+ Q_ASSERT(!m_elements.isEmpty());
+ QDataBuffer<Element *> elements(m_elements.size());
+ for (int i = 0; i < m_elements.size(); ++i)
+ elements.add(m_elements.at(i));
+ m_bvh.allocate(2 * m_elements.size());
+ m_bvh.root = buildTree(elements.data(), elements.size());
+
+ elements.reset();
+ for (int i = 0; i < m_elements.size(); ++i)
+ elements.add(m_elements.at(i));
+
+ while (!elements.isEmpty()) {
+ Element *element = elements.last();
+ elements.pop_back();
+ BVHNode *node = element->bvhNode;
+ Q_ASSERT(node->type == BVHNode::Leaf);
+ Q_ASSERT(node->element == element);
+ if (!element->processed) {
+ if (!intersectNodes(elements, node, m_bvh.root))
+ element->processed = true;
+ }
+ }
+
+ m_bvh.free(); // The bounding volume hierarchy is not needed anymore.
+}
+
+void PathSimplifier::connectElements()
+{
+ Q_ASSERT(!m_elements.isEmpty());
+ QDataBuffer<Event> events(m_elements.size() * 2);
+ for (int i = 0; i < m_elements.size(); ++i) {
+ Element *element = m_elements.at(i);
+ element->next = element->previous = 0;
+ element->winding = 0;
+ element->edgeNode = 0;
+ const QPoint &u = m_points->at(element->indices[0]);
+ const QPoint &v = m_points->at(element->indices[element->degree]);
+ if (u != v) {
+ element->pointingUp = element->originallyPointingUp = v < u;
+
+ Event event;
+ event.element = element;
+ event.point = u;
+ event.type = element->pointingUp ? Event::Lower : Event::Upper;
+ events.add(event);
+ event.point = v;
+ event.type = element->pointingUp ? Event::Upper : Event::Lower;
+ events.add(event);
+ }
+ }
+ QVarLengthArray<Element *, 8> orderedElements;
+ if (!events.isEmpty())
+ sortEvents(events.data(), events.size());
+ while (!events.isEmpty()) {
+ const Event *event = &events.last();
+ QPoint eventPoint = event->point;
+
+ // Find all elements passing through the event point.
+ QPair<RBNode *, RBNode *> bounds = outerBounds(eventPoint);
+
+ // Special case: single element above and single element below event point.
+ int eventCount = events.size();
+ if (event->type == Event::Lower && eventCount > 2) {
+ QPair<RBNode *, RBNode *> range;
+ range.first = bounds.first ? m_elementList.next(bounds.first)
+ : m_elementList.front(m_elementList.root);
+ range.second = bounds.second ? m_elementList.previous(bounds.second)
+ : m_elementList.back(m_elementList.root);
+
+ const Event *event2 = &events.at(eventCount - 2);
+ const Event *event3 = &events.at(eventCount - 3);
+ Q_ASSERT(event2->point == eventPoint); // There are always at least two events at a point.
+ if (range.first == range.second && event2->type == Event::Upper && event3->point != eventPoint) {
+ Element *element = event->element;
+ Element *element2 = event2->element;
+ element->edgeNode->data = event2->element;
+ element2->edgeNode = element->edgeNode;
+ element->edgeNode = 0;
+
+ events.pop_back();
+ events.pop_back();
+
+ if (element2->pointingUp != element->pointingUp)
+ element2->flip();
+ element2->winding = element->winding;
+ int winding = element->winding;
+ if (element->originallyPointingUp)
+ ++winding;
+ if (winding == 0 || winding == 1) {
+ if (element->pointingUp) {
+ element->previous = event2->element;
+ element2->next = event->element;
+ } else {
+ element->next = event2->element;
+ element2->previous = event->element;
+ }
+ }
+ continue;
+ }
+ }
+ orderedElements.clear();
+
+ // First, find the ones above the event point.
+ if (m_elementList.root) {
+ RBNode *current = bounds.first ? m_elementList.next(bounds.first)
+ : m_elementList.front(m_elementList.root);
+ while (current != bounds.second) {
+ Element *element = current->data;
+ Q_ASSERT(element->edgeNode == current);
+ int winding = element->winding;
+ if (element->originallyPointingUp)
+ ++winding;
+ const QPoint &lower = m_points->at(element->lowerIndex());
+ if (lower == eventPoint) {
+ if (winding == 0 || winding == 1)
+ orderedElements.append(current->data);
+ } else {
+ // The element is passing through 'event.point'.
+ Q_ASSERT(m_points->at(element->upperIndex()) != eventPoint);
+ Q_ASSERT(element->degree == Element::Line);
+ // Split the line.
+ Element *eventElement = event->element;
+ int indexIndex = (event->type == Event::Upper) == eventElement->pointingUp
+ ? eventElement->degree : 0;
+ quint32 pointIndex = eventElement->indices[indexIndex];
+ Q_ASSERT(eventPoint == m_points->at(pointIndex));
+
+ Element *upperElement = m_elementAllocator.newElement();
+ *upperElement = *element;
+ upperElement->lowerIndex() = element->upperIndex() = pointIndex;
+ upperElement->edgeNode = 0;
+ element->next = element->previous = 0;
+ if (upperElement->next)
+ upperElement->next->previous = upperElement;
+ else if (upperElement->previous)
+ upperElement->previous->next = upperElement;
+ if (element->pointingUp != element->originallyPointingUp)
+ element->flip();
+ if (winding == 0 || winding == 1)
+ orderedElements.append(upperElement);
+ m_elements.add(upperElement);
+ }
+ current = m_elementList.next(current);
+ }
+ }
+ while (!events.isEmpty() && events.last().point == eventPoint) {
+ event = &events.last();
+ if (event->type == Event::Upper) {
+ Q_ASSERT(event->point == m_points->at(event->element->upperIndex()));
+ RBNode *left = findElementLeftOf(event->element, bounds);
+ RBNode *node = m_elementList.newNode();
+ node->data = event->element;
+ Q_ASSERT(event->element->edgeNode == 0);
+ event->element->edgeNode = node;
+ m_elementList.attachAfter(left, node);
+ } else {
+ Q_ASSERT(event->type == Event::Lower);
+ Q_ASSERT(event->point == m_points->at(event->element->lowerIndex()));
+ Element *element = event->element;
+ Q_ASSERT(element->edgeNode);
+ m_elementList.deleteNode(element->edgeNode);
+ Q_ASSERT(element->edgeNode == 0);
+ }
+ events.pop_back();
+ }
+
+ if (m_elementList.root) {
+ RBNode *current = bounds.first ? m_elementList.next(bounds.first)
+ : m_elementList.front(m_elementList.root);
+ int winding = bounds.first ? bounds.first->data->winding : 0;
+
+ // Calculate winding numbers and flip elements if necessary.
+ while (current != bounds.second) {
+ Element *element = current->data;
+ Q_ASSERT(element->edgeNode == current);
+ int ccw = winding & 1;
+ Q_ASSERT(element->pointingUp == element->originallyPointingUp);
+ if (element->originallyPointingUp) {
+ --winding;
+ } else {
+ ++winding;
+ ccw ^= 1;
+ }
+ element->winding = winding;
+ if (ccw == 0)
+ element->flip();
+ current = m_elementList.next(current);
+ }
+
+ // Pick elements with correct winding number.
+ current = bounds.second ? m_elementList.previous(bounds.second)
+ : m_elementList.back(m_elementList.root);
+ while (current != bounds.first) {
+ Element *element = current->data;
+ Q_ASSERT(element->edgeNode == current);
+ Q_ASSERT(m_points->at(element->upperIndex()) == eventPoint);
+ int winding = element->winding;
+ if (element->originallyPointingUp)
+ ++winding;
+ if (winding == 0 || winding == 1)
+ orderedElements.append(current->data);
+ current = m_elementList.previous(current);
+ }
+ }
+
+ if (!orderedElements.isEmpty()) {
+ Q_ASSERT((orderedElements.size() & 1) == 0);
+ int i = 0;
+ Element *firstElement = orderedElements.at(0);
+ if (m_points->at(firstElement->indices[0]) != eventPoint) {
+ orderedElements.append(firstElement);
+ i = 1;
+ }
+ for (; i < orderedElements.size(); i += 2) {
+ Q_ASSERT(i + 1 < orderedElements.size());
+ Element *next = orderedElements.at(i);
+ Element *previous = orderedElements.at(i + 1);
+ Q_ASSERT(next->previous == 0);
+ Q_ASSERT(previous->next == 0);
+ next->previous = previous;
+ previous->next = next;
+ }
+ }
+ }
+#ifndef QT_NO_DEBUG
+ for (int i = 0; i < m_elements.size(); ++i) {
+ const Element *element = m_elements.at(i);
+ Q_ASSERT(element->next == 0 || element->next->previous == element);
+ Q_ASSERT(element->previous == 0 || element->previous->next == element);
+ Q_ASSERT((element->next == 0) == (element->previous == 0));
+ }
+#endif
+}
+
+void PathSimplifier::fillIndices()
+{
+ for (int i = 0; i < m_elements.size(); ++i)
+ m_elements.at(i)->processed = false;
+ for (int i = 0; i < m_elements.size(); ++i) {
+ Element *element = m_elements.at(i);
+ if (element->processed || element->next == 0)
+ continue;
+ do {
+ m_indices->add(element->indices[0]);
+ switch (element->degree) {
+ case Element::Quadratic:
+ {
+ QPoint pts[] = {
+ m_points->at(element->indices[0]),
+ m_points->at(element->indices[1]),
+ m_points->at(element->indices[2])
+ };
+ subDivQuadratic(pts[0], pts[1], pts[2]);
+ }
+ break;
+ case Element::Cubic:
+ {
+ QPoint pts[] = {
+ m_points->at(element->indices[0]),
+ m_points->at(element->indices[1]),
+ m_points->at(element->indices[2]),
+ m_points->at(element->indices[3])
+ };
+ subDivCubic(pts[0], pts[1], pts[2], pts[3]);
+ }
+ break;
+ default:
+ break;
+ }
+ Q_ASSERT(element->next);
+ element->processed = true;
+ element = element->next;
+ } while (element != m_elements.at(i));
+ m_indices->add(Q_TRIANGULATE_END_OF_POLYGON);
+ }
+}
+
+PathSimplifier::BVHNode *PathSimplifier::buildTree(Element **elements, int elementCount)
+{
+ Q_ASSERT(elementCount > 0);
+ BVHNode *node = m_bvh.newNode();
+ if (elementCount == 1) {
+ Element *element = *elements;
+ element->bvhNode = node;
+ node->type = BVHNode::Leaf;
+ node->element = element;
+ node->minimum = node->maximum = m_points->at(element->indices[0]);
+ for (int i = 1; i <= element->degree; ++i) {
+ const QPoint &p = m_points->at(element->indices[i]);
+ node->minimum.rx() = qMin(node->minimum.x(), p.x());
+ node->minimum.ry() = qMin(node->minimum.y(), p.y());
+ node->maximum.rx() = qMax(node->maximum.x(), p.x());
+ node->maximum.ry() = qMax(node->maximum.y(), p.y());
+ }
+ return node;
+ }
+
+ node->type = BVHNode::Split;
+
+ QPoint minimum, maximum;
+ minimum = maximum = elements[0]->middle;
+
+ for (int i = 1; i < elementCount; ++i) {
+ const QPoint &p = elements[i]->middle;
+ minimum.rx() = qMin(minimum.x(), p.x());
+ minimum.ry() = qMin(minimum.y(), p.y());
+ maximum.rx() = qMax(maximum.x(), p.x());
+ maximum.ry() = qMax(maximum.y(), p.y());
+ }
+
+ int comp, pivot;
+ if (maximum.x() - minimum.x() > maximum.y() - minimum.y()) {
+ comp = 0;
+ pivot = (maximum.x() + minimum.x()) >> 1;
+ } else {
+ comp = 1;
+ pivot = (maximum.y() + minimum.y()) >> 1;
+ }
+
+ int lo = 0;
+ int hi = elementCount - 1;
+ while (lo < hi) {
+ while (lo < hi && (&elements[lo]->middle.rx())[comp] <= pivot)
+ ++lo;
+ while (lo < hi && (&elements[hi]->middle.rx())[comp] > pivot)
+ --hi;
+ if (lo < hi)
+ qSwap(elements[lo], elements[hi]);
+ }
+
+ if (lo == elementCount) {
+ // All points are the same.
+ Q_ASSERT(minimum.x() == maximum.x() && minimum.y() == maximum.y());
+ lo = elementCount >> 1;
+ }
+
+ node->left = buildTree(elements, lo);
+ node->right = buildTree(elements + lo, elementCount - lo);
+
+ const BVHNode *left = node->left;
+ const BVHNode *right = node->right;
+ node->minimum.rx() = qMin(left->minimum.x(), right->minimum.x());
+ node->minimum.ry() = qMin(left->minimum.y(), right->minimum.y());
+ node->maximum.rx() = qMax(left->maximum.x(), right->maximum.x());
+ node->maximum.ry() = qMax(left->maximum.y(), right->maximum.y());
+
+ return node;
+}
+
+bool PathSimplifier::intersectNodes(QDataBuffer<Element *> &elements, BVHNode *elementNode,
+ BVHNode *treeNode)
+{
+ if (elementNode->minimum.x() >= treeNode->maximum.x()
+ || elementNode->minimum.y() >= treeNode->maximum.y()
+ || elementNode->maximum.x() <= treeNode->minimum.x()
+ || elementNode->maximum.y() <= treeNode->minimum.y())
+ {
+ return false;
+ }
+
+ Q_ASSERT(elementNode->type == BVHNode::Leaf);
+ Element *element = elementNode->element;
+ Q_ASSERT(!element->processed);
+
+ if (treeNode->type == BVHNode::Leaf) {
+ Element *nodeElement = treeNode->element;
+ if (!nodeElement->processed)
+ return false;
+
+ if (treeNode->element == elementNode->element)
+ return false;
+
+ if (equalElements(treeNode->element, elementNode->element))
+ return false; // element doesn't split itself.
+
+ if (element->degree == Element::Line && nodeElement->degree == Element::Line) {
+ const QPoint &u1 = m_points->at(element->indices[0]);
+ const QPoint &u2 = m_points->at(element->indices[1]);
+ const QPoint &v1 = m_points->at(nodeElement->indices[0]);
+ const QPoint &v2 = m_points->at(nodeElement->indices[1]);
+ IntersectionPoint intersection = intersectionPoint(u1, u2, v1, v2);
+ if (!intersection.isValid())
+ return false;
+
+ Q_ASSERT(intersection.x.integer >= qMin(u1.x(), u2.x()));
+ Q_ASSERT(intersection.y.integer >= qMin(u1.y(), u2.y()));
+ Q_ASSERT(intersection.x.integer >= qMin(v1.x(), v2.x()));
+ Q_ASSERT(intersection.y.integer >= qMin(v1.y(), v2.y()));
+
+ Q_ASSERT(intersection.x.integer <= qMax(u1.x(), u2.x()));
+ Q_ASSERT(intersection.y.integer <= qMax(u1.y(), u2.y()));
+ Q_ASSERT(intersection.x.integer <= qMax(v1.x(), v2.x()));
+ Q_ASSERT(intersection.y.integer <= qMax(v1.y(), v2.y()));
+
+ m_points->add(intersection.round());
+ splitLineAt(elements, treeNode, m_points->size() - 1, !intersection.isAccurate());
+ return splitLineAt(elements, elementNode, m_points->size() - 1, false);
+ } else {
+ QVarLengthArray<QPoint, 12> axes;
+ appendSeparatingAxes(axes, elementNode->element);
+ appendSeparatingAxes(axes, treeNode->element);
+ for (int i = 0; i < axes.size(); ++i) {
+ QPair<int, int> range1 = calculateSeparatingAxisRange(axes.at(i), elementNode->element);
+ QPair<int, int> range2 = calculateSeparatingAxisRange(axes.at(i), treeNode->element);
+ if (range1.first >= range2.second || range1.second <= range2.first) {
+ return false; // Separating axis found.
+ }
+ }
+ // Bounding areas overlap.
+ if (nodeElement->degree > Element::Line)
+ splitCurve(elements, treeNode);
+ if (element->degree > Element::Line) {
+ splitCurve(elements, elementNode);
+ } else {
+ // The element was not split, so it can be processed further.
+ if (intersectNodes(elements, elementNode, treeNode->left))
+ return true;
+ if (intersectNodes(elements, elementNode, treeNode->right))
+ return true;
+ return false;
+ }
+ return true;
+ }
+ } else {
+ if (intersectNodes(elements, elementNode, treeNode->left))
+ return true;
+ if (intersectNodes(elements, elementNode, treeNode->right))
+ return true;
+ return false;
+ }
+}
+
+bool PathSimplifier::equalElements(const Element *e1, const Element *e2)
+{
+ Q_ASSERT(e1 != e2);
+ if (e1->degree != e2->degree)
+ return false;
+
+ // Possibly equal and in the same direction.
+ bool equalSame = true;
+ for (int i = 0; i <= e1->degree; ++i)
+ equalSame &= m_points->at(e1->indices[i]) == m_points->at(e2->indices[i]);
+
+ // Possibly equal and in opposite directions.
+ bool equalOpposite = true;
+ for (int i = 0; i <= e1->degree; ++i)
+ equalOpposite &= m_points->at(e1->indices[e1->degree - i]) == m_points->at(e2->indices[i]);
+
+ return equalSame || equalOpposite;
+}
+
+bool PathSimplifier::splitLineAt(QDataBuffer<Element *> &elements, BVHNode *node,
+ quint32 pointIndex, bool processAgain)
+{
+ Q_ASSERT(node->type == BVHNode::Leaf);
+ Element *element = node->element;
+ Q_ASSERT(element->degree == Element::Line);
+ const QPoint &u = m_points->at(element->indices[0]);
+ const QPoint &v = m_points->at(element->indices[1]);
+ const QPoint &p = m_points->at(pointIndex);
+ if (u == p || v == p)
+ return false; // No split needed.
+
+ if (processAgain)
+ element->processed = false; // Needs to be processed again.
+
+ Element *first = node->element;
+ Element *second = m_elementAllocator.newElement();
+ *second = *first;
+ first->indices[1] = second->indices[0] = pointIndex;
+ first->middle.rx() = (u.x() + p.x()) >> 1;
+ first->middle.ry() = (u.y() + p.y()) >> 1;
+ second->middle.rx() = (v.x() + p.x()) >> 1;
+ second->middle.ry() = (v.y() + p.y()) >> 1;
+ m_elements.add(second);
+
+ BVHNode *left = m_bvh.newNode();
+ BVHNode *right = m_bvh.newNode();
+ left->type = right->type = BVHNode::Leaf;
+ left->element = first;
+ right->element = second;
+ left->minimum = right->minimum = node->minimum;
+ left->maximum = right->maximum = node->maximum;
+ if (u.x() < v.x())
+ left->maximum.rx() = right->minimum.rx() = p.x();
+ else
+ left->minimum.rx() = right->maximum.rx() = p.x();
+ if (u.y() < v.y())
+ left->maximum.ry() = right->minimum.ry() = p.y();
+ else
+ left->minimum.ry() = right->maximum.ry() = p.y();
+ left->element->bvhNode = left;
+ right->element->bvhNode = right;
+
+ node->type = BVHNode::Split;
+ node->left = left;
+ node->right = right;
+
+ if (!first->processed) {
+ elements.add(left->element);
+ elements.add(right->element);
+ }
+ return true;
+}
+
+void PathSimplifier::appendSeparatingAxes(QVarLengthArray<QPoint, 12> &axes, Element *element)
+{
+ switch (element->degree) {
+ case Element::Cubic:
+ {
+ const QPoint &u = m_points->at(element->indices[0]);
+ const QPoint &v = m_points->at(element->indices[1]);
+ const QPoint &w = m_points->at(element->indices[2]);
+ const QPoint &q = m_points->at(element->indices[3]);
+ QPoint ns[] = {
+ QPoint(u.y() - v.y(), v.x() - u.x()),
+ QPoint(v.y() - w.y(), w.x() - v.x()),
+ QPoint(w.y() - q.y(), q.x() - w.x()),
+ QPoint(q.y() - u.y(), u.x() - q.x()),
+ QPoint(u.y() - w.y(), w.x() - u.x()),
+ QPoint(v.y() - q.y(), q.x() - v.x())
+ };
+ for (int i = 0; i < 6; ++i) {
+ if (ns[i].x() || ns[i].y())
+ axes.append(ns[i]);
+ }
+ }
+ break;
+ case Element::Quadratic:
+ {
+ const QPoint &u = m_points->at(element->indices[0]);
+ const QPoint &v = m_points->at(element->indices[1]);
+ const QPoint &w = m_points->at(element->indices[2]);
+ QPoint ns[] = {
+ QPoint(u.y() - v.y(), v.x() - u.x()),
+ QPoint(v.y() - w.y(), w.x() - v.x()),
+ QPoint(w.y() - u.y(), u.x() - w.x())
+ };
+ for (int i = 0; i < 3; ++i) {
+ if (ns[i].x() || ns[i].y())
+ axes.append(ns[i]);
+ }
+ }
+ break;
+ case Element::Line:
+ {
+ const QPoint &u = m_points->at(element->indices[0]);
+ const QPoint &v = m_points->at(element->indices[1]);
+ QPoint n(u.y() - v.y(), v.x() - u.x());
+ if (n.x() || n.y())
+ axes.append(n);
+ }
+ break;
+ default:
+ Q_ASSERT_X(0, "QSGPathSimplifier::appendSeparatingAxes", "Unexpected element type.");
+ break;
+ }
+}
+
+QPair<int, int> PathSimplifier::calculateSeparatingAxisRange(const QPoint &axis, Element *element)
+{
+ QPair<int, int> range(0x7fffffff, -0x7fffffff);
+ for (int i = 0; i <= element->degree; ++i) {
+ const QPoint &p = m_points->at(element->indices[i]);
+ int dist = dot(axis, p);
+ range.first = qMin(range.first, dist);
+ range.second = qMax(range.second, dist);
+ }
+ return range;
+}
+
+void PathSimplifier::splitCurve(QDataBuffer<Element *> &elements, BVHNode *node)
+{
+ Q_ASSERT(node->type == BVHNode::Leaf);
+
+ Element *first = node->element;
+ Element *second = m_elementAllocator.newElement();
+ *second = *first;
+ m_elements.add(second);
+ Q_ASSERT(first->degree > Element::Line);
+
+ bool accurate = true;
+ const QPoint &u = m_points->at(first->indices[0]);
+ const QPoint &v = m_points->at(first->indices[1]);
+ const QPoint &w = m_points->at(first->indices[2]);
+
+ if (first->degree == Element::Quadratic) {
+ QPoint pts[3];
+ accurate = splitQuadratic(u, v, w, pts);
+ int pointIndex = m_points->size();
+ m_points->add(pts[1]);
+ accurate &= setElementToQuadratic(first, first->indices[0], pts[0], pointIndex);
+ accurate &= setElementToQuadratic(second, pointIndex, pts[2], second->indices[2]);
+ } else {
+ Q_ASSERT(first->degree == Element::Cubic);
+ const QPoint &q = m_points->at(first->indices[3]);
+ QPoint pts[5];
+ accurate = splitCubic(u, v, w, q, pts);
+ int pointIndex = m_points->size();
+ m_points->add(pts[2]);
+ accurate &= setElementToCubic(first, first->indices[0], pts[0], pts[1], pointIndex);
+ accurate &= setElementToCubic(second, pointIndex, pts[3], pts[4], second->indices[3]);
+ }
+
+ if (!accurate)
+ first->processed = second->processed = false; // Needs to be processed again.
+
+ BVHNode *left = m_bvh.newNode();
+ BVHNode *right = m_bvh.newNode();
+ left->type = right->type = BVHNode::Leaf;
+ left->element = first;
+ right->element = second;
+
+ left->minimum.rx() = left->minimum.ry() = right->minimum.rx() = right->minimum.ry() = INT_MAX;
+ left->maximum.rx() = left->maximum.ry() = right->maximum.rx() = right->maximum.ry() = INT_MIN;
+
+ for (int i = 0; i <= first->degree; ++i) {
+ QPoint &p = m_points->at(first->indices[i]);
+ left->minimum.rx() = qMin(left->minimum.x(), p.x());
+ left->minimum.ry() = qMin(left->minimum.y(), p.y());
+ left->maximum.rx() = qMax(left->maximum.x(), p.x());
+ left->maximum.ry() = qMax(left->maximum.y(), p.y());
+ }
+ for (int i = 0; i <= second->degree; ++i) {
+ QPoint &p = m_points->at(second->indices[i]);
+ right->minimum.rx() = qMin(right->minimum.x(), p.x());
+ right->minimum.ry() = qMin(right->minimum.y(), p.y());
+ right->maximum.rx() = qMax(right->maximum.x(), p.x());
+ right->maximum.ry() = qMax(right->maximum.y(), p.y());
+ }
+ left->element->bvhNode = left;
+ right->element->bvhNode = right;
+
+ node->type = BVHNode::Split;
+ node->left = left;
+ node->right = right;
+
+ if (!first->processed) {
+ elements.add(left->element);
+ elements.add(right->element);
+ }
+}
+
+bool PathSimplifier::setElementToQuadratic(Element *element, quint32 pointIndex1,
+ const QPoint &ctrl, quint32 pointIndex2)
+{
+ const QPoint &p1 = m_points->at(pointIndex1);
+ const QPoint &p2 = m_points->at(pointIndex2);
+ if (flattenQuadratic(p1, ctrl, p2)) {
+ // Insert line.
+ element->degree = Element::Line;
+ element->indices[0] = pointIndex1;
+ element->indices[1] = pointIndex2;
+ element->middle.rx() = (p1.x() + p2.x()) >> 1;
+ element->middle.ry() = (p1.y() + p2.y()) >> 1;
+ return false;
+ } else {
+ // Insert bezier.
+ element->degree = Element::Quadratic;
+ element->indices[0] = pointIndex1;
+ element->indices[1] = m_points->size();
+ element->indices[2] = pointIndex2;
+ element->middle.rx() = (p1.x() + ctrl.x() + p2.x()) / 3;
+ element->middle.ry() = (p1.y() + ctrl.y() + p2.y()) / 3;
+ m_points->add(ctrl);
+ return true;
+ }
+}
+
+bool PathSimplifier::setElementToCubic(Element *element, quint32 pointIndex1, const QPoint &v,
+ const QPoint &w, quint32 pointIndex2)
+{
+ const QPoint &u = m_points->at(pointIndex1);
+ const QPoint &q = m_points->at(pointIndex2);
+ if (flattenCubic(u, v, w, q)) {
+ // Insert line.
+ element->degree = Element::Line;
+ element->indices[0] = pointIndex1;
+ element->indices[1] = pointIndex2;
+ element->middle.rx() = (u.x() + q.x()) >> 1;
+ element->middle.ry() = (u.y() + q.y()) >> 1;
+ return false;
+ } else {
+ // Insert bezier.
+ element->degree = Element::Cubic;
+ element->indices[0] = pointIndex1;
+ element->indices[1] = m_points->size();
+ element->indices[2] = m_points->size() + 1;
+ element->indices[3] = pointIndex2;
+ element->middle.rx() = (u.x() + v.x() + w.x() + q.x()) >> 2;
+ element->middle.ry() = (u.y() + v.y() + w.y() + q.y()) >> 2;
+ m_points->add(v);
+ m_points->add(w);
+ return true;
+ }
+}
+
+void PathSimplifier::setElementToCubicAndSimplify(Element *element, quint32 pointIndex1,
+ const QPoint &v, const QPoint &w,
+ quint32 pointIndex2)
+{
+ const QPoint &u = m_points->at(pointIndex1);
+ const QPoint &q = m_points->at(pointIndex2);
+ if (flattenCubic(u, v, w, q)) {
+ // Insert line.
+ element->degree = Element::Line;
+ element->indices[0] = pointIndex1;
+ element->indices[1] = pointIndex2;
+ element->middle.rx() = (u.x() + q.x()) >> 1;
+ element->middle.ry() = (u.y() + q.y()) >> 1;
+ return;
+ }
+
+ bool intersecting = (u == q) || intersectionPoint(u, v, w, q).isValid();
+ if (!intersecting) {
+ // Insert bezier.
+ element->degree = Element::Cubic;
+ element->indices[0] = pointIndex1;
+ element->indices[1] = m_points->size();
+ element->indices[2] = m_points->size() + 1;
+ element->indices[3] = pointIndex2;
+ element->middle.rx() = (u.x() + v.x() + w.x() + q.x()) >> 2;
+ element->middle.ry() = (u.y() + v.y() + w.y() + q.y()) >> 2;
+ m_points->add(v);
+ m_points->add(w);
+ return;
+ }
+
+ QPoint pts[5];
+ splitCubic(u, v, w, q, pts);
+ int pointIndex = m_points->size();
+ m_points->add(pts[2]);
+ Element *element2 = m_elementAllocator.newElement();
+ m_elements.add(element2);
+ setElementToCubicAndSimplify(element, pointIndex1, pts[0], pts[1], pointIndex);
+ setElementToCubicAndSimplify(element2, pointIndex, pts[3], pts[4], pointIndex2);
+}
+
+PathSimplifier::RBNode *PathSimplifier::findElementLeftOf(const Element *element,
+ const QPair<RBNode *, RBNode *> &bounds)
+{
+ if (!m_elementList.root)
+ return 0;
+ RBNode *current = bounds.first;
+ Q_ASSERT(!current || !elementIsLeftOf(element, current->data));
+ if (!current)
+ current = m_elementList.front(m_elementList.root);
+ Q_ASSERT(current);
+ RBNode *result = 0;
+ while (current != bounds.second && !elementIsLeftOf(element, current->data)) {
+ result = current;
+ current = m_elementList.next(current);
+ }
+ return result;
+}
+
+bool PathSimplifier::elementIsLeftOf(const Element *left, const Element *right)
+{
+ const QPoint &leftU = m_points->at(left->upperIndex());
+ const QPoint &leftL = m_points->at(left->lowerIndex());
+ const QPoint &rightU = m_points->at(right->upperIndex());
+ const QPoint &rightL = m_points->at(right->lowerIndex());
+ Q_ASSERT(leftL >= rightU && rightL >= leftU);
+ if (leftU.x() < qMin(rightL.x(), rightU.x()))
+ return true;
+ if (leftU.x() > qMax(rightL.x(), rightU.x()))
+ return false;
+ int d = pointDistanceFromLine(leftU, rightL, rightU);
+ // d < 0: left, d > 0: right, d == 0: on top
+ if (d == 0) {
+ d = pointDistanceFromLine(leftL, rightL, rightU);
+ if (d == 0) {
+ if (right->degree > Element::Line) {
+ d = pointDistanceFromLine(leftL, rightL, m_points->at(right->indices[1]));
+ if (d == 0)
+ d = pointDistanceFromLine(leftL, rightL, m_points->at(right->indices[2]));
+ } else if (left->degree > Element::Line) {
+ d = pointDistanceFromLine(m_points->at(left->indices[1]), rightL, rightU);
+ if (d == 0)
+ d = pointDistanceFromLine(m_points->at(left->indices[2]), rightL, rightU);
+ }
+ }
+ }
+ return d < 0;
+}
+
+QPair<PathSimplifier::RBNode *, PathSimplifier::RBNode *> PathSimplifier::outerBounds(const QPoint &point)
+{
+ RBNode *current = m_elementList.root;
+ QPair<RBNode *, RBNode *> result(0, 0);
+
+ while (current) {
+ const Element *element = current->data;
+ Q_ASSERT(element->edgeNode == current);
+ const QPoint &v1 = m_points->at(element->lowerIndex());
+ const QPoint &v2 = m_points->at(element->upperIndex());
+ Q_ASSERT(point >= v2 && point <= v1);
+ if (point == v1 || point == v2)
+ break;
+ int d = pointDistanceFromLine(point, v1, v2);
+ if (d == 0) {
+ if (element->degree == Element::Line)
+ break;
+ d = pointDistanceFromLine(point, v1, m_points->at(element->indices[1]));
+ if (d == 0)
+ d = pointDistanceFromLine(point, v1, m_points->at(element->indices[2]));
+ Q_ASSERT(d != 0);
+ }
+ if (d < 0) {
+ result.second = current;
+ current = current->left;
+ } else {
+ result.first = current;
+ current = current->right;
+ }
+ }
+
+ if (!current)
+ return result;
+
+ RBNode *mid = current;
+
+ current = mid->left;
+ while (current) {
+ const Element *element = current->data;
+ Q_ASSERT(element->edgeNode == current);
+ const QPoint &v1 = m_points->at(element->lowerIndex());
+ const QPoint &v2 = m_points->at(element->upperIndex());
+ Q_ASSERT(point >= v2 && point <= v1);
+ bool equal = (point == v1 || point == v2);
+ if (!equal) {
+ int d = pointDistanceFromLine(point, v1, v2);
+ Q_ASSERT(d >= 0);
+ equal = (d == 0 && element->degree == Element::Line);
+ }
+ if (equal) {
+ current = current->left;
+ } else {
+ result.first = current;
+ current = current->right;
+ }
+ }
+
+ current = mid->right;
+ while (current) {
+ const Element *element = current->data;
+ Q_ASSERT(element->edgeNode == current);
+ const QPoint &v1 = m_points->at(element->lowerIndex());
+ const QPoint &v2 = m_points->at(element->upperIndex());
+ Q_ASSERT(point >= v2 && point <= v1);
+ bool equal = (point == v1 || point == v2);
+ if (!equal) {
+ int d = pointDistanceFromLine(point, v1, v2);
+ Q_ASSERT(d <= 0);
+ equal = (d == 0 && element->degree == Element::Line);
+ }
+ if (equal) {
+ current = current->right;
+ } else {
+ result.second = current;
+ current = current->left;
+ }
+ }
+
+ return result;
+}
+
+inline bool PathSimplifier::flattenQuadratic(const QPoint &u, const QPoint &v, const QPoint &w)
+{
+ QPoint deltas[2] = { v - u, w - v };
+ int d = qAbs(cross(deltas[0], deltas[1]));
+ int l = qAbs(deltas[0].x()) + qAbs(deltas[0].y()) + qAbs(deltas[1].x()) + qAbs(deltas[1].y());
+ return d < (Q_FIXED_POINT_SCALE * Q_FIXED_POINT_SCALE * 3 / 2) || l <= Q_FIXED_POINT_SCALE * 2;
+}
+
+inline bool PathSimplifier::flattenCubic(const QPoint &u, const QPoint &v,
+ const QPoint &w, const QPoint &q)
+{
+ QPoint deltas[] = { v - u, w - v, q - w, q - u };
+ int d = qAbs(cross(deltas[0], deltas[1])) + qAbs(cross(deltas[1], deltas[2]))
+ + qAbs(cross(deltas[0], deltas[3])) + qAbs(cross(deltas[3], deltas[2]));
+ int l = qAbs(deltas[0].x()) + qAbs(deltas[0].y()) + qAbs(deltas[1].x()) + qAbs(deltas[1].y())
+ + qAbs(deltas[2].x()) + qAbs(deltas[2].y());
+ return d < (Q_FIXED_POINT_SCALE * Q_FIXED_POINT_SCALE * 3) || l <= Q_FIXED_POINT_SCALE * 2;
+}
+
+inline bool PathSimplifier::splitQuadratic(const QPoint &u, const QPoint &v,
+ const QPoint &w, QPoint *result)
+{
+ result[0] = u + v;
+ result[2] = v + w;
+ result[1] = result[0] + result[2];
+ bool accurate = ((result[0].x() | result[0].y() | result[2].x() | result[2].y()) & 1) == 0
+ && ((result[1].x() | result[1].y()) & 3) == 0;
+ result[0].rx() >>= 1;
+ result[0].ry() >>= 1;
+ result[1].rx() >>= 2;
+ result[1].ry() >>= 2;
+ result[2].rx() >>= 1;
+ result[2].ry() >>= 1;
+ return accurate;
+}
+
+inline bool PathSimplifier::splitCubic(const QPoint &u, const QPoint &v,
+ const QPoint &w, const QPoint &q, QPoint *result)
+{
+ result[0] = u + v;
+ result[2] = v + w;
+ result[4] = w + q;
+ result[1] = result[0] + result[2];
+ result[3] = result[2] + result[4];
+ result[2] = result[1] + result[3];
+ bool accurate = ((result[0].x() | result[0].y() | result[4].x() | result[4].y()) & 1) == 0
+ && ((result[1].x() | result[1].y() | result[3].x() | result[3].y()) & 3) == 0
+ && ((result[2].x() | result[2].y()) & 7) == 0;
+ result[0].rx() >>= 1;
+ result[0].ry() >>= 1;
+ result[1].rx() >>= 2;
+ result[1].ry() >>= 2;
+ result[2].rx() >>= 3;
+ result[2].ry() >>= 3;
+ result[3].rx() >>= 2;
+ result[3].ry() >>= 2;
+ result[4].rx() >>= 1;
+ result[4].ry() >>= 1;
+ return accurate;
+}
+
+inline void PathSimplifier::subDivQuadratic(const QPoint &u, const QPoint &v, const QPoint &w)
+{
+ if (flattenQuadratic(u, v, w))
+ return;
+ QPoint pts[3];
+ splitQuadratic(u, v, w, pts);
+ subDivQuadratic(u, pts[0], pts[1]);
+ m_indices->add(m_points->size());
+ m_points->add(pts[1]);
+ subDivQuadratic(pts[1], pts[2], w);
+}
+
+inline void PathSimplifier::subDivCubic(const QPoint &u, const QPoint &v,
+ const QPoint &w, const QPoint &q)
+{
+ if (flattenCubic(u, v, w, q))
+ return;
+ QPoint pts[5];
+ splitCubic(u, v, w, q, pts);
+ subDivCubic(u, pts[0], pts[1], pts[2]);
+ m_indices->add(m_points->size());
+ m_points->add(pts[2]);
+ subDivCubic(pts[2], pts[3], pts[4], q);
+}
+
+void PathSimplifier::sortEvents(Event *events, int count)
+{
+ // Bucket sort + insertion sort.
+ Q_ASSERT(count > 0);
+ QDataBuffer<Event> buffer(count);
+ buffer.resize(count);
+ QScopedArrayPointer<int> bins(new int[count]);
+ int counts[0x101];
+ memset(counts, 0, sizeof(counts));
+
+ int minimum, maximum;
+ minimum = maximum = events[0].point.y();
+ for (int i = 1; i < count; ++i) {
+ minimum = qMin(minimum, events[i].point.y());
+ maximum = qMax(maximum, events[i].point.y());
+ }
+
+ for (int i = 0; i < count; ++i) {
+ bins[i] = ((maximum - events[i].point.y()) << 8) / (maximum - minimum + 1);
+ Q_ASSERT(bins[i] >= 0 && bins[i] < 0x100);
+ ++counts[bins[i]];
+ }
+
+ for (int i = 1; i < 0x100; ++i)
+ counts[i] += counts[i - 1];
+ counts[0x100] = counts[0xff];
+ Q_ASSERT(counts[0x100] == count);
+
+ for (int i = 0; i < count; ++i)
+ buffer.at(--counts[bins[i]]) = events[i];
+
+ int j = 0;
+ for (int i = 0; i < 0x100; ++i) {
+ for (; j < counts[i + 1]; ++j) {
+ int k = j;
+ while (k > 0 && (buffer.at(j) < events[k - 1])) {
+ events[k] = events[k - 1];
+ --k;
+ }
+ events[k] = buffer.at(j);
+ }
+ }
+}
+
+} // end anonymous namespace
+
+
+void qSimplifyPath(const QVectorPath &path, QDataBuffer<QPoint> &vertices,
+ QDataBuffer<quint32> &indices, const QTransform &matrix)
+{
+ PathSimplifier(path, vertices, indices, matrix);
+}
+
+void qSimplifyPath(const QPainterPath &path, QDataBuffer<QPoint> &vertices,
+ QDataBuffer<quint32> &indices, const QTransform &matrix)
+{
+ qSimplifyPath(qtVectorPathForPath(path), vertices, indices, matrix);
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgpathsimplifier_p.h b/src/quick/scenegraph/qsgpathsimplifier_p.h
new file mode 100644
index 0000000000..9e38c5ad00
--- /dev/null
+++ b/src/quick/scenegraph/qsgpathsimplifier_p.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGPATHSIMPLIFIER_P_H
+#define QSGPATHSIMPLIFIER_P_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 <QtGui/qpainterpath.h>
+#include <QtGui/private/qdatabuffer_p.h>
+#include <QtGui/private/qvectorpath_p.h>
+
+QT_BEGIN_NAMESPACE
+
+// The returned vertices are in 8:8 fixed point format. The path is assumed to be in the range (-128, 128)x(-128, 128).
+void qSimplifyPath(const QVectorPath &path, QDataBuffer<QPoint> &vertices, QDataBuffer<quint32> &indices, const QTransform &matrix = QTransform());
+void qSimplifyPath(const QPainterPath &path, QDataBuffer<QPoint> &vertices, QDataBuffer<quint32> &indices, const QTransform &matrix = QTransform());
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
index 951ee210c5..46bd141909 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
index 8250b9706e..3052f20813 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgareaallocator.cpp b/src/quick/scenegraph/util/qsgareaallocator.cpp
index 635f38fa5e..415037a7b5 100644
--- a/src/quick/scenegraph/util/qsgareaallocator.cpp
+++ b/src/quick/scenegraph/util/qsgareaallocator.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgareaallocator_p.h b/src/quick/scenegraph/util/qsgareaallocator_p.h
index cab4824c56..998f7ef4d1 100644
--- a/src/quick/scenegraph/util/qsgareaallocator_p.h
+++ b/src/quick/scenegraph/util/qsgareaallocator_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
index a8d73ed7d1..76fdf97d80 100644
--- a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
+++ b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil_p.h b/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
index bc1dbc2c72..49391a737c 100644
--- a/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
+++ b/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgengine.cpp b/src/quick/scenegraph/util/qsgengine.cpp
index c5840b2d2b..5d50002870 100644
--- a/src/quick/scenegraph/util/qsgengine.cpp
+++ b/src/quick/scenegraph/util/qsgengine.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgengine.h b/src/quick/scenegraph/util/qsgengine.h
index 70896d3ef2..f62bdb2ab3 100644
--- a/src/quick/scenegraph/util/qsgengine.h
+++ b/src/quick/scenegraph/util/qsgengine.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
index c1d5b04cc1..50c8d1661e 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.h b/src/quick/scenegraph/util/qsgflatcolormaterial.h
index 1313a89eef..f1020faa56 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.h
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgpainternode.cpp b/src/quick/scenegraph/util/qsgpainternode.cpp
index d4a810c30a..1ea64f6205 100644
--- a/src/quick/scenegraph/util/qsgpainternode.cpp
+++ b/src/quick/scenegraph/util/qsgpainternode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgpainternode_p.h b/src/quick/scenegraph/util/qsgpainternode_p.h
index 0c603c43ca..24b4d26855 100644
--- a/src/quick/scenegraph/util/qsgpainternode_p.h
+++ b/src/quick/scenegraph/util/qsgpainternode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgsimplematerial.h b/src/quick/scenegraph/util/qsgsimplematerial.h
index a3579326ee..5e58bd56ca 100644
--- a/src/quick/scenegraph/util/qsgsimplematerial.h
+++ b/src/quick/scenegraph/util/qsgsimplematerial.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgsimplerectnode.cpp b/src/quick/scenegraph/util/qsgsimplerectnode.cpp
index 4d4ae7c784..09a3b42e98 100644
--- a/src/quick/scenegraph/util/qsgsimplerectnode.cpp
+++ b/src/quick/scenegraph/util/qsgsimplerectnode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgsimplerectnode.h b/src/quick/scenegraph/util/qsgsimplerectnode.h
index abe9973306..cab8a60ad2 100644
--- a/src/quick/scenegraph/util/qsgsimplerectnode.h
+++ b/src/quick/scenegraph/util/qsgsimplerectnode.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
index 0a8edc999c..c347dffbed 100644
--- a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
+++ b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgsimpletexturenode.h b/src/quick/scenegraph/util/qsgsimpletexturenode.h
index 8416556d00..d4bdca21ca 100644
--- a/src/quick/scenegraph/util/qsgsimpletexturenode.h
+++ b/src/quick/scenegraph/util/qsgsimpletexturenode.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index 4dff1b2a3d..24b92fa98f 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,7 +45,8 @@
#include <qopenglfunctions.h>
#include <QtQuick/private/qsgcontext_p.h>
#include <qthread.h>
-#include <private/qdeclarativeprofilerservice_p.h>
+#include <private/qqmlprofilerservice_p.h>
+#include <private/qqmlglobal_p.h>
#if !defined(QT_NO_DEBUG) && (defined(Q_OS_LINUX) || defined(Q_OS_MAC))
#include <execinfo.h>
diff --git a/src/quick/scenegraph/util/qsgtexture.h b/src/quick/scenegraph/util/qsgtexture.h
index 2ff4b5daf8..0b4e6fede2 100644
--- a/src/quick/scenegraph/util/qsgtexture.h
+++ b/src/quick/scenegraph/util/qsgtexture.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgtexture_p.h b/src/quick/scenegraph/util/qsgtexture_p.h
index bbeeec4b74..3d80035c9a 100644
--- a/src/quick/scenegraph/util/qsgtexture_p.h
+++ b/src/quick/scenegraph/util/qsgtexture_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index c5e55a751c..96fc037bfe 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.h b/src/quick/scenegraph/util/qsgtexturematerial.h
index 123fbaafed..bfc76422f1 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.h
+++ b/src/quick/scenegraph/util/qsgtexturematerial.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgtexturematerial_p.h b/src/quick/scenegraph/util/qsgtexturematerial_p.h
index 55d6ad0a78..0895dbd6c2 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial_p.h
+++ b/src/quick/scenegraph/util/qsgtexturematerial_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgtextureprovider.cpp b/src/quick/scenegraph/util/qsgtextureprovider.cpp
index 0ec0c6f724..6d81e4eb79 100644
--- a/src/quick/scenegraph/util/qsgtextureprovider.cpp
+++ b/src/quick/scenegraph/util/qsgtextureprovider.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgtextureprovider.h b/src/quick/scenegraph/util/qsgtextureprovider.h
index 578b323c89..8dcc1f2678 100644
--- a/src/quick/scenegraph/util/qsgtextureprovider.h
+++ b/src/quick/scenegraph/util/qsgtextureprovider.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
index 8c09780b15..545b5f201e 100644
--- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.h b/src/quick/scenegraph/util/qsgvertexcolormaterial.h
index 3ba37eff4a..52808a50d9 100644
--- a/src/quick/scenegraph/util/qsgvertexcolormaterial.h
+++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/util/qdeclarativeanimation.cpp b/src/quick/util/qdeclarativeanimation.cpp
deleted file mode 100644
index b3b6d93115..0000000000
--- a/src/quick/util/qdeclarativeanimation.cpp
+++ /dev/null
@@ -1,2530 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeanimation_p.h"
-#include "qdeclarativeanimation_p_p.h"
-
-#include <private/qdeclarativestateoperations_p.h>
-#include <private/qdeclarativecontext_p.h>
-
-#include <qdeclarativepropertyvaluesource.h>
-#include <qdeclarative.h>
-#include <qdeclarativeinfo.h>
-#include <qdeclarativeexpression.h>
-#include <private/qdeclarativestringconverters_p.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativeengine_p.h>
-
-#include <qvariant.h>
-#include <qcolor.h>
-#include <qfile.h>
-#include "private/qparallelanimationgroupjob_p.h"
-#include "private/qsequentialanimationgroupjob_p.h"
-#include <QtCore/qset.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass Animation QDeclarativeAbstractAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \brief The Animation element is the base of all QML animations.
-
- The Animation element cannot be used directly in a QML file. It exists
- to provide a set of common properties and methods, available across all the
- other animation types that inherit from it. Attempting to use the Animation
- element directly will result in an error.
-*/
-
-QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QObject *parent)
-: QObject(*(new QDeclarativeAbstractAnimationPrivate), parent)
-{
-}
-
-QDeclarativeAbstractAnimation::~QDeclarativeAbstractAnimation()
-{
- Q_D(QDeclarativeAbstractAnimation);
- delete d->animationInstance;
-}
-
-QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QDeclarativeAbstractAnimationPrivate &dd, QObject *parent)
-: QObject(dd, parent)
-{
-}
-
-QAbstractAnimationJob* QDeclarativeAbstractAnimation::qtAnimation()
-{
- Q_D(QDeclarativeAbstractAnimation);
- return d->animationInstance;
-}
-
-/*!
- \qmlproperty bool QtQuick2::Animation::running
- This property holds whether the animation is currently running.
-
- The \c running property can be set to declaratively control whether or not
- an animation is running. The following example will animate a rectangle
- whenever the \l MouseArea is pressed.
-
- \code
- Rectangle {
- width: 100; height: 100
- NumberAnimation on x {
- running: myMouse.pressed
- from: 0; to: 100
- }
- MouseArea { id: myMouse }
- }
- \endcode
-
- Likewise, the \c running property can be read to determine if the animation
- is running. In the following example the text element will indicate whether
- or not the animation is running.
-
- \code
- NumberAnimation { id: myAnimation }
- Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" }
- \endcode
-
- Animations can also be started and stopped imperatively from JavaScript
- using the \c start() and \c stop() methods.
-
- By default, animations are not running. Though, when the animations are assigned to properties,
- as property value sources using the \e on syntax, they are set to running by default.
-*/
-bool QDeclarativeAbstractAnimation::isRunning() const
-{
- Q_D(const QDeclarativeAbstractAnimation);
- return d->running;
-}
-
-// the behavior calls this function
-void QDeclarativeAbstractAnimation::notifyRunningChanged(bool running)
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (d->disableUserControl && d->running != running) {
- d->running = running;
- emit runningChanged(running);
- }
-}
-
-//commence is called to start an animation when it is used as a
-//simple animation, and not as part of a transition
-void QDeclarativeAbstractAnimationPrivate::commence()
-{
- Q_Q(QDeclarativeAbstractAnimation);
-
- QDeclarativeStateActions actions;
- QDeclarativeProperties properties;
-
- QAbstractAnimationJob *oldInstance = animationInstance;
- animationInstance = q->transition(actions, properties, QDeclarativeAbstractAnimation::Forward);
- if (oldInstance != animationInstance) {
- animationInstance->addAnimationChangeListener(this, QAbstractAnimationJob::Completion);
- if (oldInstance)
- delete oldInstance;
- }
- animationInstance->start();
- if (animationInstance->isStopped()) {
- running = false;
- emit q->completed();
- }
-}
-
-QDeclarativeProperty QDeclarativeAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj)
-{
- QDeclarativeProperty prop(obj, str, qmlContext(infoObj));
- if (!prop.isValid()) {
- qmlInfo(infoObj) << QDeclarativeAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str);
- return QDeclarativeProperty();
- } else if (!prop.isWritable()) {
- qmlInfo(infoObj) << QDeclarativeAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str);
- return QDeclarativeProperty();
- }
- return prop;
-}
-
-void QDeclarativeAbstractAnimation::setRunning(bool r)
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (!d->componentComplete) {
- d->running = r;
- if (r == false)
- d->avoidPropertyValueSourceStart = true;
- else if (!d->registered) {
- d->registered = true;
- QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
- static int finalizedIdx = -1;
- if (finalizedIdx < 0)
- finalizedIdx = metaObject()->indexOfSlot("componentFinalized()");
- engPriv->registerFinalizeCallback(this, finalizedIdx);
- }
- return;
- }
-
- if (d->running == r)
- return;
-
- if (d->group || d->disableUserControl) {
- qmlInfo(this) << "setRunning() cannot be used on non-root animation nodes.";
- return;
- }
-
- d->running = r;
- if (d->running) {
- bool supressStart = false;
- if (d->alwaysRunToEnd && d->loopCount != 1
- && d->animationInstance && d->animationInstance->isRunning()) {
- //we've restarted before the final loop finished; restore proper loop count
- if (d->loopCount == -1)
- d->animationInstance->setLoopCount(d->loopCount);
- else
- d->animationInstance->setLoopCount(d->animationInstance->currentLoop() + d->loopCount);
- supressStart = true; //we want the animation to continue, rather than restart
- }
- if (!supressStart)
- d->commence();
- emit started();
- } else {
- if (d->animationInstance) {
- if (d->alwaysRunToEnd) {
- if (d->loopCount != 1)
- d->animationInstance->setLoopCount(d->animationInstance->currentLoop()+1); //finish the current loop
- } else {
- d->animationInstance->stop();
- }
- }
- emit completed();
- }
-
- emit runningChanged(d->running);
-}
-
-/*!
- \qmlproperty bool QtQuick2::Animation::paused
- This property holds whether the animation is currently paused.
-
- The \c paused property can be set to declaratively control whether or not
- an animation is paused.
-
- Animations can also be paused and resumed imperatively from JavaScript
- using the \c pause() and \c resume() methods.
-
- By default, animations are not paused.
-*/
-bool QDeclarativeAbstractAnimation::isPaused() const
-{
- Q_D(const QDeclarativeAbstractAnimation);
- return d->paused;
-}
-
-void QDeclarativeAbstractAnimation::setPaused(bool p)
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (d->paused == p)
- return;
-
- if (d->group || d->disableUserControl) {
- qmlInfo(this) << "setPaused() cannot be used on non-root animation nodes.";
- return;
- }
-
- d->paused = p;
-
- if (!d->componentComplete || !d->animationInstance)
- return;
-
- if (d->paused)
- d->animationInstance->pause();
- else
- d->animationInstance->resume();
-
- emit pausedChanged(d->paused);
-}
-
-void QDeclarativeAbstractAnimation::classBegin()
-{
- Q_D(QDeclarativeAbstractAnimation);
- d->componentComplete = false;
-}
-
-void QDeclarativeAbstractAnimation::componentComplete()
-{
- Q_D(QDeclarativeAbstractAnimation);
- d->componentComplete = true;
-}
-
-void QDeclarativeAbstractAnimation::componentFinalized()
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (d->running) {
- d->running = false;
- setRunning(true);
- }
- if (d->paused) {
- d->paused = false;
- setPaused(true);
- }
-}
-
-/*!
- \qmlproperty bool QtQuick2::Animation::alwaysRunToEnd
- This property holds whether the animation should run to completion when it is stopped.
-
- If this true the animation will complete its current iteration when it
- is stopped - either by setting the \c running property to false, or by
- calling the \c stop() method. The \c complete() method is not effected
- by this value.
-
- This behavior is most useful when the \c repeat property is set, as the
- animation will finish playing normally but not restart.
-
- By default, the alwaysRunToEnd property is not set.
-
- \note alwaysRunToEnd has no effect on animations in a Transition.
-*/
-bool QDeclarativeAbstractAnimation::alwaysRunToEnd() const
-{
- Q_D(const QDeclarativeAbstractAnimation);
- return d->alwaysRunToEnd;
-}
-
-void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (d->alwaysRunToEnd == f)
- return;
-
- d->alwaysRunToEnd = f;
- emit alwaysRunToEndChanged(f);
-}
-
-/*!
- \qmlproperty int QtQuick2::Animation::loops
- This property holds the number of times the animation should play.
-
- By default, \c loops is 1: the animation will play through once and then stop.
-
- If set to Animation.Infinite, the animation will continuously repeat until it is explicitly
- stopped - either by setting the \c running property to false, or by calling
- the \c stop() method.
-
- In the following example, the rectangle will spin indefinitely.
-
- \code
- Rectangle {
- width: 100; height: 100; color: "green"
- RotationAnimation on rotation {
- loops: Animation.Infinite
- from: 0
- to: 360
- }
- }
- \endcode
-*/
-int QDeclarativeAbstractAnimation::loops() const
-{
- Q_D(const QDeclarativeAbstractAnimation);
- return d->loopCount;
-}
-
-void QDeclarativeAbstractAnimation::setLoops(int loops)
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (loops < 0)
- loops = -1;
-
- if (loops == d->loopCount)
- return;
-
- d->loopCount = loops;
- emit loopCountChanged(loops);
-}
-
-int QDeclarativeAbstractAnimation::duration() const
-{
- Q_D(const QDeclarativeAbstractAnimation);
- return d->animationInstance ? d->animationInstance->duration() : 0;
-}
-
-int QDeclarativeAbstractAnimation::currentTime()
-{
- Q_D(QDeclarativeAbstractAnimation);
- return d->animationInstance ? d->animationInstance->currentLoopTime() : 0;
-}
-
-void QDeclarativeAbstractAnimation::setCurrentTime(int time)
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (d->animationInstance)
- d->animationInstance->setCurrentTime(time);
- //TODO save value for start?
-}
-
-QDeclarativeAnimationGroup *QDeclarativeAbstractAnimation::group() const
-{
- Q_D(const QDeclarativeAbstractAnimation);
- return d->group;
-}
-
-void QDeclarativeAbstractAnimation::setGroup(QDeclarativeAnimationGroup *g)
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (d->group == g)
- return;
- if (d->group)
- static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.removeAll(this);
-
- d->group = g;
-
- if (d->group && !static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.contains(this))
- static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.append(this);
-
- //if (g) //if removed from a group, then the group should no longer be the parent
- setParent(g);
-}
-
-/*!
- \qmlmethod QtQuick2::Animation::start()
- \brief Starts the animation.
-
- If the animation is already running, calling this method has no effect. The
- \c running property will be true following a call to \c start().
-*/
-void QDeclarativeAbstractAnimation::start()
-{
- setRunning(true);
-}
-
-/*!
- \qmlmethod QtQuick2::Animation::pause()
- \brief Pauses the animation.
-
- If the animation is already paused, calling this method has no effect. The
- \c paused property will be true following a call to \c pause().
-*/
-void QDeclarativeAbstractAnimation::pause()
-{
- setPaused(true);
-}
-
-/*!
- \qmlmethod QtQuick2::Animation::resume()
- \brief Resumes a paused animation.
-
- If the animation is not paused, calling this method has no effect. The
- \c paused property will be false following a call to \c resume().
-*/
-void QDeclarativeAbstractAnimation::resume()
-{
- setPaused(false);
-}
-
-/*!
- \qmlmethod QtQuick2::Animation::stop()
- \brief Stops the animation.
-
- If the animation is not running, calling this method has no effect. The
- \c running property will be false following a call to \c stop().
-
- Normally \c stop() stops the animation immediately, and the animation has
- no further influence on property values. In this example animation
- \code
- Rectangle {
- NumberAnimation on x { from: 0; to: 100; duration: 500 }
- }
- \endcode
- was stopped at time 250ms, the \c x property will have a value of 50.
-
- However, if the \c alwaysRunToEnd property is set, the animation will
- continue running until it completes and then stop. The \c running property
- will still become false immediately.
-*/
-void QDeclarativeAbstractAnimation::stop()
-{
- setRunning(false);
-}
-
-/*!
- \qmlmethod QtQuick2::Animation::restart()
- \brief Restarts the animation.
-
- This is a convenience method, and is equivalent to calling \c stop() and
- then \c start().
-*/
-void QDeclarativeAbstractAnimation::restart()
-{
- stop();
- start();
-}
-
-/*!
- \qmlmethod QtQuick2::Animation::complete()
- \brief Stops the animation, jumping to the final property values.
-
- If the animation is not running, calling this method has no effect. The
- \c running property will be false following a call to \c complete().
-
- Unlike \c stop(), \c complete() immediately fast-forwards the animation to
- its end. In the following example,
- \code
- Rectangle {
- NumberAnimation on x { from: 0; to: 100; duration: 500 }
- }
- \endcode
- calling \c stop() at time 250ms will result in the \c x property having
- a value of 50, while calling \c complete() will set the \c x property to
- 100, exactly as though the animation had played the whole way through.
-*/
-void QDeclarativeAbstractAnimation::complete()
-{
- Q_D(QDeclarativeAbstractAnimation);
- if (isRunning() && d->animationInstance) {
- d->animationInstance->setCurrentTime(d->animationInstance->duration());
- }
-}
-
-void QDeclarativeAbstractAnimation::setTarget(const QDeclarativeProperty &p)
-{
- Q_D(QDeclarativeAbstractAnimation);
- d->defaultProperty = p;
-
- if (!d->avoidPropertyValueSourceStart)
- setRunning(true);
-}
-
-/*
- we rely on setTarget only being called when used as a value source
- so this function allows us to do the same thing as setTarget without
- that assumption
-*/
-void QDeclarativeAbstractAnimation::setDefaultTarget(const QDeclarativeProperty &p)
-{
- Q_D(QDeclarativeAbstractAnimation);
- d->defaultProperty = p;
-}
-
-/*
- don't allow start/stop/pause/resume to be manually invoked,
- because something else (like a Behavior) already has control
- over the animation.
-*/
-void QDeclarativeAbstractAnimation::setDisableUserControl()
-{
- Q_D(QDeclarativeAbstractAnimation);
- d->disableUserControl = true;
-}
-
-void QDeclarativeAbstractAnimation::setEnableUserControl()
-{
- Q_D(QDeclarativeAbstractAnimation);
- d->disableUserControl = false;
-
-}
-
-bool QDeclarativeAbstractAnimation::userControlDisabled() const
-{
- Q_D(const QDeclarativeAbstractAnimation);
- return d->disableUserControl;
-}
-
-QAbstractAnimationJob* QDeclarativeAbstractAnimation::initInstance(QAbstractAnimationJob *animation)
-{
- Q_D(QDeclarativeAbstractAnimation);
- animation->setLoopCount(d->loopCount);
- return animation;
-}
-
-QAbstractAnimationJob* QDeclarativeAbstractAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_UNUSED(actions);
- Q_UNUSED(modified);
- Q_UNUSED(direction);
- Q_UNUSED(defaultTarget);
- return 0;
-}
-
-void QDeclarativeAbstractAnimationPrivate::animationFinished(QAbstractAnimationJob*)
-{
- Q_Q(QDeclarativeAbstractAnimation);
- q->setRunning(false);
- if (alwaysRunToEnd && loopCount != 1) {
- //restore the proper loopCount for the next run
- animationInstance->setLoopCount(loopCount);
- }
-}
-
-/*!
- \qmlclass PauseAnimation QDeclarativePauseAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits Animation
- \brief The PauseAnimation element provides a pause for an animation.
-
- When used in a SequentialAnimation, PauseAnimation is a step when
- nothing happens, for a specified duration.
-
- A 500ms animation sequence, with a 100ms pause between two animations:
- \code
- SequentialAnimation {
- NumberAnimation { ... duration: 200 }
- PauseAnimation { duration: 100 }
- NumberAnimation { ... duration: 200 }
- }
- \endcode
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarativePauseAnimation::QDeclarativePauseAnimation(QObject *parent)
-: QDeclarativeAbstractAnimation(*(new QDeclarativePauseAnimationPrivate), parent)
-{
-}
-
-QDeclarativePauseAnimation::~QDeclarativePauseAnimation()
-{
-}
-
-/*!
- \qmlproperty int QtQuick2::PauseAnimation::duration
- This property holds the duration of the pause in milliseconds
-
- The default value is 250.
-*/
-int QDeclarativePauseAnimation::duration() const
-{
- Q_D(const QDeclarativePauseAnimation);
- return d->duration;
-}
-
-void QDeclarativePauseAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QDeclarativePauseAnimation);
- if (d->duration == duration)
- return;
- d->duration = duration;
- emit durationChanged(duration);
-}
-
-QAbstractAnimationJob* QDeclarativePauseAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativePauseAnimation);
- Q_UNUSED(actions);
- Q_UNUSED(modified);
- Q_UNUSED(direction);
- Q_UNUSED(defaultTarget);
-
- return initInstance(new QPauseAnimationJob(d->duration));
-}
-
-/*!
- \qmlclass ColorAnimation QDeclarativeColorAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits PropertyAnimation
- \brief The ColorAnimation element animates changes in color values.
-
- 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. 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 ColorAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- For convenience, when a ColorAnimation is used in a \l Transition, it will
- animate any \c color properties that have been modified during the state
- change. If a \l{PropertyAnimation::}{property} or
- \l{PropertyAnimation::}{properties} are explicitly set for the animation,
- then those are used instead.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarativeColorAnimation::QDeclarativeColorAnimation(QObject *parent)
-: QDeclarativePropertyAnimation(parent)
-{
- Q_D(QDeclarativePropertyAnimation);
- d->interpolatorType = QMetaType::QColor;
- d->defaultToInterpolatorType = true;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
-}
-
-QDeclarativeColorAnimation::~QDeclarativeColorAnimation()
-{
-}
-
-/*!
- \qmlproperty color QtQuick2::ColorAnimation::from
- 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: [
- // States are defined here...
- ]
-
- transition: Transition {
- ColorAnimation { from: "#c0c0c0"; duration: 2000 }
- }
- }
- \endqml
-
- If the ColorAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-QColor QDeclarativeColorAnimation::from() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->from.value<QColor>();
-}
-
-void QDeclarativeColorAnimation::setFrom(const QColor &f)
-{
- QDeclarativePropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty color QtQuick2::ColorAnimation::to
-
- This property holds the color value at which the animation should end.
-
- If the ColorAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-QColor QDeclarativeColorAnimation::to() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->to.value<QColor>();
-}
-
-void QDeclarativeColorAnimation::setTo(const QColor &t)
-{
- QDeclarativePropertyAnimation::setTo(t);
-}
-
-QActionAnimation::QActionAnimation()
- : QAbstractAnimationJob(), animAction(0)
-{
-}
-
-QActionAnimation::QActionAnimation(QAbstractAnimationAction *action)
- : QAbstractAnimationJob(), animAction(action)
-{
-}
-
-QActionAnimation::~QActionAnimation()
-{
- delete animAction;
-}
-
-int QActionAnimation::duration() const
-{
- return 0;
-}
-
-void QActionAnimation::setAnimAction(QAbstractAnimationAction *action)
-{
- if (isRunning())
- stop();
- animAction = action;
-}
-
-void QActionAnimation::updateCurrentTime(int)
-{
-}
-
-void QActionAnimation::updateState(State newState, State oldState)
-{
- Q_UNUSED(oldState);
-
- if (newState == Running) {
- if (animAction) {
- animAction->doAction();
- }
- }
-}
-
-/*!
- \qmlclass ScriptAction QDeclarativeScriptAction
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits Animation
- \brief The ScriptAction element allows scripts to be run during an animation.
-
- ScriptAction can be used to run a script at a specific point in an animation.
-
- \qml
- SequentialAnimation {
- NumberAnimation {
- // ...
- }
- ScriptAction { script: doSomething(); }
- NumberAnimation {
- // ...
- }
- }
- \endqml
-
- When used as part of a Transition, you can also target a specific
- StateChangeScript to run using the \c scriptName property.
-
- \snippet doc/src/snippets/declarative/states/statechangescript.qml state and transition
-
- \sa StateChangeScript
-*/
-QDeclarativeScriptAction::QDeclarativeScriptAction(QObject *parent)
- :QDeclarativeAbstractAnimation(*(new QDeclarativeScriptActionPrivate), parent)
-{
-}
-
-QDeclarativeScriptAction::~QDeclarativeScriptAction()
-{
-}
-
-QDeclarativeScriptActionPrivate::QDeclarativeScriptActionPrivate()
- : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false){}
-
-/*!
- \qmlproperty script QtQuick2::ScriptAction::script
- This property holds the script to run.
-*/
-QDeclarativeScriptString QDeclarativeScriptAction::script() const
-{
- Q_D(const QDeclarativeScriptAction);
- return d->script;
-}
-
-void QDeclarativeScriptAction::setScript(const QDeclarativeScriptString &script)
-{
- Q_D(QDeclarativeScriptAction);
- d->script = script;
-}
-
-/*!
- \qmlproperty string QtQuick2::ScriptAction::scriptName
- This property holds the the name of the StateChangeScript to run.
-
- This property is only valid when ScriptAction is used as part of a transition.
- If both script and scriptName are set, scriptName will be used.
-
- \note When using scriptName in a reversible transition, the script will only
- be run when the transition is being run forwards.
-*/
-QString QDeclarativeScriptAction::stateChangeScriptName() const
-{
- Q_D(const QDeclarativeScriptAction);
- return d->name;
-}
-
-void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name)
-{
- Q_D(QDeclarativeScriptAction);
- d->name = name;
-}
-
-QAbstractAnimationAction* QDeclarativeScriptActionPrivate::createAction()
-{
- return new Proxy(this);
-}
-
-void QDeclarativeScriptActionPrivate::execute()
-{
- Q_Q(QDeclarativeScriptAction);
- if (hasRunScriptScript && reversing)
- return;
-
- QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script;
-
- if (!scriptStr.script().isEmpty()) {
- QDeclarativeExpression expr(scriptStr);
- expr.evaluate();
- if (expr.hasError())
- qmlInfo(q) << expr.error();
- }
-}
-
-QAbstractAnimationJob* QDeclarativeScriptAction::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativeScriptAction);
- Q_UNUSED(modified);
- Q_UNUSED(defaultTarget);
-
- d->hasRunScriptScript = false;
- d->reversing = (direction == Backward);
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarativeAction &action = actions[ii];
-
- if (action.event && action.event->type() == QDeclarativeActionEvent::Script
- && static_cast<QDeclarativeStateChangeScript*>(action.event)->name() == d->name) {
- d->runScriptScript = static_cast<QDeclarativeStateChangeScript*>(action.event)->script();
- d->hasRunScriptScript = true;
- action.actionDone = true;
- break; //only match one (names should be unique)
- }
- }
- return initInstance(new QActionAnimation(d->createAction()));
-}
-
-/*!
- \qmlclass PropertyAction QDeclarativePropertyAction
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits Animation
- \brief The PropertyAction element allows immediate property changes during animation.
-
- PropertyAction is used to specify an immediate property change during an
- animation. The property change is not animated.
-
- It is useful for setting non-animated property values during an animation.
-
- For example, here is a SequentialAnimation that sets the image's
- \l {Image::}{smooth} property to \c true, animates the width of the image,
- then sets \l {Image::}{smooth} back to \c false:
-
- \snippet doc/src/snippets/declarative/propertyaction.qml standalone
-
- PropertyAction is also useful for setting the exact point at which a property
- change should occur during a \l Transition. For example, if PropertyChanges
- was used in a \l State to rotate an item around a particular
- \l {Item::}{transformOrigin}, it might be implemented like this:
-
- \snippet doc/src/snippets/declarative/propertyaction.qml transition
-
- However, with this code, the \c transformOrigin is not set until \e after
- the animation, as a \l State is taken to define the values at the \e end of
- a transition. The animation would rotate at the default \c transformOrigin,
- then jump to \c Item.BottomRight. To fix this, insert a PropertyAction
- before the RotationAnimation begins:
-
- \snippet doc/src/snippets/declarative/propertyaction-sequential.qml sequential
-
- This immediately sets the \c transformOrigin property to the value defined
- in the end state of the \l Transition (i.e. the value defined in the
- PropertyAction object) so that the rotation animation begins with the
- correct transform origin.
-
- \sa {QML Animation and Transitions}, QtDeclarative
-*/
-QDeclarativePropertyAction::QDeclarativePropertyAction(QObject *parent)
-: QDeclarativeAbstractAnimation(*(new QDeclarativePropertyActionPrivate), parent)
-{
-}
-
-QDeclarativePropertyAction::~QDeclarativePropertyAction()
-{
-}
-
-QObject *QDeclarativePropertyAction::target() const
-{
- Q_D(const QDeclarativePropertyAction);
- return d->target;
-}
-
-void QDeclarativePropertyAction::setTargetObject(QObject *o)
-{
- Q_D(QDeclarativePropertyAction);
- if (d->target == o)
- return;
- d->target = o;
- emit targetChanged();
-}
-
-QString QDeclarativePropertyAction::property() const
-{
- Q_D(const QDeclarativePropertyAction);
- return d->propertyName;
-}
-
-void QDeclarativePropertyAction::setProperty(const QString &n)
-{
- Q_D(QDeclarativePropertyAction);
- if (d->propertyName == n)
- return;
- d->propertyName = n;
- emit propertyChanged();
-}
-
-/*!
- \qmlproperty Object QtQuick2::PropertyAction::target
- \qmlproperty list<Object> QtQuick2::PropertyAction::targets
- \qmlproperty string QtQuick2::PropertyAction::property
- \qmlproperty string QtQuick2::PropertyAction::properties
-
- 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
- is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
- documentation.
-
- \sa exclude
-*/
-QString QDeclarativePropertyAction::properties() const
-{
- Q_D(const QDeclarativePropertyAction);
- return d->properties;
-}
-
-void QDeclarativePropertyAction::setProperties(const QString &p)
-{
- Q_D(QDeclarativePropertyAction);
- if (d->properties == p)
- return;
- d->properties = p;
- emit propertiesChanged(p);
-}
-
-QDeclarativeListProperty<QObject> QDeclarativePropertyAction::targets()
-{
- Q_D(QDeclarativePropertyAction);
- return QDeclarativeListProperty<QObject>(this, d->targets);
-}
-
-/*!
- \qmlproperty list<Object> QtQuick2::PropertyAction::exclude
- This property holds the objects that should not be affected by this action.
-
- \sa targets
-*/
-QDeclarativeListProperty<QObject> QDeclarativePropertyAction::exclude()
-{
- Q_D(QDeclarativePropertyAction);
- return QDeclarativeListProperty<QObject>(this, d->exclude);
-}
-
-/*!
- \qmlproperty any QtQuick2::PropertyAction::value
- This property holds the value to be set on the property.
-
- If the PropertyAction is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-*/
-QVariant QDeclarativePropertyAction::value() const
-{
- Q_D(const QDeclarativePropertyAction);
- return d->value;
-}
-
-void QDeclarativePropertyAction::setValue(const QVariant &v)
-{
- Q_D(QDeclarativePropertyAction);
- if (d->value.isNull || d->value != v) {
- d->value = v;
- emit valueChanged(v);
- }
-}
-
-QAbstractAnimationJob* QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativePropertyAction);
- Q_UNUSED(direction);
-
- struct QDeclarativeSetPropertyAnimationAction : public QAbstractAnimationAction
- {
- QDeclarativeStateActions actions;
- virtual void doAction()
- {
- for (int ii = 0; ii < actions.count(); ++ii) {
- const QDeclarativeAction &action = actions.at(ii);
- QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- }
- }
- };
-
- QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
- props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty())
- props << d->propertyName;
-
- QList<QObject*> targets = d->targets;
- if (d->target)
- targets.append(d->target);
-
- bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
-
- if (d->defaultProperty.isValid() && !hasSelectors) {
- props << d->defaultProperty.name();
- targets << d->defaultProperty.object();
- }
-
- if (defaultTarget && targets.isEmpty())
- targets << defaultTarget;
-
- QDeclarativeSetPropertyAnimationAction *data = new QDeclarativeSetPropertyAnimationAction;
-
- bool hasExplicit = false;
- //an explicit animation has been specified
- if (d->value.isValid()) {
- for (int i = 0; i < props.count(); ++i) {
- for (int j = 0; j < targets.count(); ++j) {
- QDeclarativeAction myAction;
- myAction.property = d->createProperty(targets.at(j), props.at(i), this);
- if (myAction.property.isValid()) {
- myAction.toValue = d->value;
- QDeclarativePropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarativeAction &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
- }
- }
- }
- }
- }
- }
-
- if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarativeAction &action = actions[ii];
-
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
- QObject *sObj = action.specifiedObject;
- QString sPropertyName = action.specifiedProperty;
- bool same = (obj == sObj);
-
- if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
- (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) {
- QDeclarativeAction myAction = action;
-
- if (d->value.isValid())
- myAction.toValue = d->value;
- QDeclarativePropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
-
- modified << action.property;
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
-
- QActionAnimation *action = new QActionAnimation;
- if (data->actions.count()) {
- action->setAnimAction(data);
- } else {
- delete data;
- }
- return initInstance(action);
-}
-
-/*!
- \qmlclass NumberAnimation QDeclarativeNumberAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits PropertyAnimation
- \brief The NumberAnimation element animates changes in qreal-type values.
-
- 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. 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
-
- Like any other animation element, a NumberAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- Note that NumberAnimation may not animate smoothly if there are irregular
- changes in the number value that it is tracking. If this is the case, use
- SmoothedAnimation instead.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarativeNumberAnimation::QDeclarativeNumberAnimation(QObject *parent)
-: QDeclarativePropertyAnimation(parent)
-{
- init();
-}
-
-QDeclarativeNumberAnimation::QDeclarativeNumberAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent)
-: QDeclarativePropertyAnimation(dd, parent)
-{
- init();
-}
-
-QDeclarativeNumberAnimation::~QDeclarativeNumberAnimation()
-{
-}
-
-void QDeclarativeNumberAnimation::init()
-{
- Q_D(QDeclarativePropertyAnimation);
- d->interpolatorType = QMetaType::QReal;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
-}
-
-/*!
- \qmlproperty real QtQuick2::NumberAnimation::from
- This property holds the starting value for the animation.
-
- For example, the following animation is not applied until the \c x value
- has reached 100:
-
- \qml
- Item {
- states: [
- // ...
- ]
-
- transition: Transition {
- NumberAnimation { properties: "x"; from: 100; duration: 200 }
- }
- }
- \endqml
-
- If the NumberAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-
-qreal QDeclarativeNumberAnimation::from() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->from.toReal();
-}
-
-void QDeclarativeNumberAnimation::setFrom(qreal f)
-{
- QDeclarativePropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real QtQuick2::NumberAnimation::to
- This property holds the end value for the animation.
-
- If the NumberAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-qreal QDeclarativeNumberAnimation::to() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->to.toReal();
-}
-
-void QDeclarativeNumberAnimation::setTo(qreal t)
-{
- QDeclarativePropertyAnimation::setTo(t);
-}
-
-
-
-/*!
- \qmlclass Vector3dAnimation QDeclarativeVector3dAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits PropertyAnimation
- \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.
-
- Like any other animation element, a Vector3dAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent)
-: QDeclarativePropertyAnimation(parent)
-{
- Q_D(QDeclarativePropertyAnimation);
- d->interpolatorType = QMetaType::QVector3D;
- d->defaultToInterpolatorType = true;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
-}
-
-QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation()
-{
-}
-
-/*!
- \qmlproperty real QtQuick2::Vector3dAnimation::from
- This property holds the starting value for the animation.
-
- If the Vector3dAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-QVector3D QDeclarativeVector3dAnimation::from() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->from.value<QVector3D>();
-}
-
-void QDeclarativeVector3dAnimation::setFrom(QVector3D f)
-{
- QDeclarativePropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real QtQuick2::Vector3dAnimation::to
- This property holds the end value for the animation.
-
- If the Vector3dAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-QVector3D QDeclarativeVector3dAnimation::to() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->to.value<QVector3D>();
-}
-
-void QDeclarativeVector3dAnimation::setTo(QVector3D t)
-{
- QDeclarativePropertyAnimation::setTo(t);
-}
-
-
-
-/*!
- \qmlclass RotationAnimation QDeclarativeRotationAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits PropertyAnimation
- \brief The RotationAnimation element animates changes in rotation values.
-
- RotationAnimation is a specialized PropertyAnimation that gives control
- 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 240 degrees
- clockwise, while a rotation from 240 to 0 will rotate 240 degrees
- 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:
-
- \snippet doc/src/snippets/declarative/rotationanimation.qml 0
-
- Notice the RotationAnimation did not need to set a \l 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}.
-
- Also, note the \l Rectangle will be rotated around its default
- \l {Item::}{transformOrigin} (which is \c Item.Center). To use a different
- transform origin, set the origin in the PropertyChanges object and apply
- the change at the start of the animation using PropertyAction. See the
- PropertyAction documentation for more details.
-
- Like any other animation element, a RotationAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff > 180.0){
- newt -= 360.0;
- diff -= 360.0;
- }
- while(diff < -180.0){
- newt += 360.0;
- diff += 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff < 0.0){
- newt += 360.0;
- diff += 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff > 0.0){
- newt -= 360.0;
- diff -= 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QDeclarativeRotationAnimation::QDeclarativeRotationAnimation(QObject *parent)
-: QDeclarativePropertyAnimation(*(new QDeclarativeRotationAnimationPrivate), parent)
-{
- Q_D(QDeclarativeRotationAnimation);
- d->interpolatorType = QMetaType::QReal;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultProperties = QLatin1String("rotation,angle");
-}
-
-QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation()
-{
-}
-
-/*!
- \qmlproperty real QtQuick2::RotationAnimation::from
- This property holds the starting value for the animation.
-
- For example, the following animation is not applied until the \c angle value
- has reached 100:
-
- \qml
- Item {
- states: [
- // ...
- ]
-
- transition: Transition {
- RotationAnimation { properties: "angle"; from: 100; duration: 2000 }
- }
- }
- \endqml
-
- If the RotationAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-qreal QDeclarativeRotationAnimation::from() const
-{
- Q_D(const QDeclarativeRotationAnimation);
- return d->from.toReal();
-}
-
-void QDeclarativeRotationAnimation::setFrom(qreal f)
-{
- QDeclarativePropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real QtQuick2::RotationAnimation::to
- This property holds the end value for the animation..
-
- If the RotationAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-qreal QDeclarativeRotationAnimation::to() const
-{
- Q_D(const QDeclarativeRotationAnimation);
- return d->to.toReal();
-}
-
-void QDeclarativeRotationAnimation::setTo(qreal t)
-{
- QDeclarativePropertyAnimation::setTo(t);
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::RotationAnimation::direction
- This property holds the direction of the rotation.
-
- Possible values are:
-
- \list
- \o RotationAnimation.Numerical (default) - Rotate by linearly interpolating between the two numbers.
- A rotation from 10 to 350 will rotate 340 degrees clockwise.
- \o RotationAnimation.Clockwise - Rotate clockwise between the two values
- \o RotationAnimation.Counterclockwise - Rotate counterclockwise between the two values
- \o RotationAnimation.Shortest - Rotate in the direction that produces the shortest animation path.
- A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
- \endlist
-*/
-QDeclarativeRotationAnimation::RotationDirection QDeclarativeRotationAnimation::direction() const
-{
- Q_D(const QDeclarativeRotationAnimation);
- return d->direction;
-}
-
-void QDeclarativeRotationAnimation::setDirection(QDeclarativeRotationAnimation::RotationDirection direction)
-{
- Q_D(QDeclarativeRotationAnimation);
- if (d->direction == direction)
- return;
-
- d->direction = direction;
- switch(d->direction) {
- case Clockwise:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation);
- break;
- case Counterclockwise:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation);
- break;
- case Shortest:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
- break;
- default:
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- break;
- }
- emit directionChanged();
-}
-
-
-
-QDeclarativeAnimationGroup::QDeclarativeAnimationGroup(QObject *parent)
-: QDeclarativeAbstractAnimation(*(new QDeclarativeAnimationGroupPrivate), parent)
-{
-}
-
-QDeclarativeAnimationGroup::QDeclarativeAnimationGroup(QDeclarativeAnimationGroupPrivate &dd, QObject *parent)
- : QDeclarativeAbstractAnimation(dd, parent)
-{
-}
-
-void QDeclarativeAnimationGroupPrivate::append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a)
-{
- QDeclarativeAnimationGroup *q = qobject_cast<QDeclarativeAnimationGroup *>(list->object);
- if (q) {
- a->setGroup(q);
- }
-}
-
-void QDeclarativeAnimationGroupPrivate::clear_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list)
-{
- QDeclarativeAnimationGroup *q = qobject_cast<QDeclarativeAnimationGroup *>(list->object);
- if (q) {
- while (q->d_func()->animations.count()) {
- QDeclarativeAbstractAnimation *firstAnim = q->d_func()->animations.at(0);
- firstAnim->setGroup(0);
- }
- }
-}
-
-QDeclarativeAnimationGroup::~QDeclarativeAnimationGroup()
-{
-}
-
-QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeAnimationGroup::animations()
-{
- Q_D(QDeclarativeAnimationGroup);
- QDeclarativeListProperty<QDeclarativeAbstractAnimation> list(this, d->animations);
- list.append = &QDeclarativeAnimationGroupPrivate::append_animation;
- list.clear = &QDeclarativeAnimationGroupPrivate::clear_animation;
- return list;
-}
-
-/*!
- \qmlclass SequentialAnimation QDeclarativeSequentialAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits Animation
- \brief The SequentialAnimation element allows animations to be run sequentially.
-
- 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 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.
-
- \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 {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \note Once an animation has been grouped into a SequentialAnimation or
- ParallelAnimation, it cannot be individually started and stopped; the
- SequentialAnimation or ParallelAnimation must be started and stopped as a group.
-
- \sa ParallelAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-
-QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent) :
- QDeclarativeAnimationGroup(parent)
-{
-}
-
-QDeclarativeSequentialAnimation::~QDeclarativeSequentialAnimation()
-{
-}
-
-QAbstractAnimationJob* QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativeAnimationGroup);
-
- QSequentialAnimationGroupJob *ag = new QSequentialAnimationGroupJob;
-
- int inc = 1;
- int from = 0;
- if (direction == Backward) {
- inc = -1;
- from = d->animations.count() - 1;
- }
-
- bool valid = d->defaultProperty.isValid();
- QAbstractAnimationJob* anim;
- for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
- if (valid)
- d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
- anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
- inc == -1 ? ag->prependAnimation(anim) : ag->appendAnimation(anim);
- }
-
- return initInstance(ag);
-}
-
-
-
-/*!
- \qmlclass ParallelAnimation QDeclarativeParallelAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits Animation
- \brief The ParallelAnimation element allows animations to be run in parallel.
-
- 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 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.
-
- \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 {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \note Once an animation has been grouped into a SequentialAnimation or
- ParallelAnimation, it cannot be individually started and stopped; the
- SequentialAnimation or ParallelAnimation must be started and stopped as a group.
-
- \sa SequentialAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarativeParallelAnimation::QDeclarativeParallelAnimation(QObject *parent) :
- QDeclarativeAnimationGroup(parent)
-{
-}
-
-QDeclarativeParallelAnimation::~QDeclarativeParallelAnimation()
-{
-}
-
-QAbstractAnimationJob* QDeclarativeParallelAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativeAnimationGroup);
- QParallelAnimationGroupJob *ag = new QParallelAnimationGroupJob;
-
- bool valid = d->defaultProperty.isValid();
- QAbstractAnimationJob* anim;
- for (int ii = 0; ii < d->animations.count(); ++ii) {
- if (valid)
- d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
- anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
- ag->appendAnimation(anim);
- }
- return initInstance(ag);
-}
-
-//convert a variant from string type to another animatable type
-void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
-{
- if (variant.userType() != QVariant::String) {
- variant.convert((QVariant::Type)type);
- return;
- }
-
- switch (type) {
- case QVariant::Rect: {
- variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()).toRect());
- break;
- }
- case QVariant::RectF: {
- variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()));
- break;
- }
- case QVariant::Point: {
- variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()).toPoint());
- break;
- }
- case QVariant::PointF: {
- variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()));
- break;
- }
- case QVariant::Size: {
- variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()).toSize());
- break;
- }
- case QVariant::SizeF: {
- variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()));
- break;
- }
- case QVariant::Color: {
- variant.setValue(QDeclarativeStringConverters::colorFromString(variant.toString()));
- break;
- }
- case QVariant::Vector3D: {
- variant.setValue(QDeclarativeStringConverters::vector3DFromString(variant.toString()));
- break;
- }
- default:
- if (QDeclarativeValueTypeFactory::isValueType((uint)type)) {
- variant.convert((QVariant::Type)type);
- } else {
- QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
- if (converter)
- variant = converter(variant.toString());
- }
- break;
- }
-}
-
-QDeclarativeBulkValueAnimator::QDeclarativeBulkValueAnimator()
- : QAbstractAnimationJob(), animValue(0), fromSourced(0), m_duration(250)
-{
-}
-
-QDeclarativeBulkValueAnimator::~QDeclarativeBulkValueAnimator()
-{
- delete animValue;
-}
-
-void QDeclarativeBulkValueAnimator::setAnimValue(QDeclarativeBulkValueUpdater *value)
-{
- if (isRunning())
- stop();
- animValue = value;
-}
-
-void QDeclarativeBulkValueAnimator::updateCurrentTime(int currentTime)
-{
- if (isStopped())
- return;
-
- const qreal progress = easing.valueForProgress(((m_duration == 0) ? qreal(1) : qreal(currentTime) / qreal(m_duration)));
-
- if (animValue)
- animValue->setValue(progress);
-}
-
-void QDeclarativeBulkValueAnimator::topLevelAnimationLoopChanged()
-{
- //check for new from every top-level loop (when the top level animation is started and all subsequent loops)
- if (fromSourced)
- *fromSourced = false;
-}
-
-/*!
- \qmlclass PropertyAnimation QDeclarativePropertyAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits Animation
- \brief The PropertyAnimation element animates changes in property values.
-
- PropertyAnimation provides a way to animate changes to a property's value.
-
- It can be used to define animations in a number of ways:
-
- \list
- \o In a \l Transition
-
- For example, to animate any objects that have changed their \c x or \c y properties
- as a result of a state change, using an \c InOutQuad easing curve:
-
- \snippet doc/src/snippets/declarative/propertyanimation.qml transition
-
-
- \o In a \l Behavior
-
- For example, to animate all changes to a rectangle's \c x property:
-
- \snippet doc/src/snippets/declarative/propertyanimation.qml behavior
-
-
- \o As a property value source
-
- For example, to repeatedly animate the rectangle's \c x property:
-
- \snippet doc/src/snippets/declarative/propertyanimation.qml propertyvaluesource
-
-
- \o In a signal handler
-
- For example, to fade out \c theObject when clicked:
- \qml
- MouseArea {
- anchors.fill: theObject
- onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
- }
- \endqml
-
- \o Standalone
-
- For example, to animate \c rect's \c width property over 500ms, from its current width to 30:
-
- \snippet doc/src/snippets/declarative/propertyanimation.qml standalone
-
- \endlist
-
- Depending on how the animation is used, the set of properties normally used will be
- different. For more information see the individual property documentation, as well
- as the \l{QML Animation and Transitions} introduction.
-
- Note that PropertyAnimation inherits the abstract \l Animation element.
- This includes additional properties and methods for controlling the animation.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-
-QDeclarativePropertyAnimation::QDeclarativePropertyAnimation(QObject *parent)
-: QDeclarativeAbstractAnimation(*(new QDeclarativePropertyAnimationPrivate), parent)
-{
-}
-
-QDeclarativePropertyAnimation::QDeclarativePropertyAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent)
-: QDeclarativeAbstractAnimation(dd, parent)
-{
-}
-
-QDeclarativePropertyAnimation::~QDeclarativePropertyAnimation()
-{
-}
-
-/*!
- \qmlproperty int QtQuick2::PropertyAnimation::duration
- This property holds the duration of the animation, in milliseconds.
-
- The default value is 250.
-*/
-int QDeclarativePropertyAnimation::duration() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->duration;
-}
-
-void QDeclarativePropertyAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QDeclarativePropertyAnimation);
- if (d->duration == duration)
- return;
- d->duration = duration;
- emit durationChanged(duration);
-}
-
-/*!
- \qmlproperty real QtQuick2::PropertyAnimation::from
- This property holds the starting value for the animation.
-
- If the PropertyAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-QVariant QDeclarativePropertyAnimation::from() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->from;
-}
-
-void QDeclarativePropertyAnimation::setFrom(const QVariant &f)
-{
- Q_D(QDeclarativePropertyAnimation);
- if (d->fromIsDefined && f == d->from)
- return;
- d->from = f;
- d->fromIsDefined = f.isValid();
- emit fromChanged(f);
-}
-
-/*!
- \qmlproperty real QtQuick2::PropertyAnimation::to
- This property holds the end value for the animation.
-
- If the PropertyAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-QVariant QDeclarativePropertyAnimation::to() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->to;
-}
-
-void QDeclarativePropertyAnimation::setTo(const QVariant &t)
-{
- Q_D(QDeclarativePropertyAnimation);
- if (d->toIsDefined && t == d->to)
- return;
- d->to = t;
- d->toIsDefined = t.isValid();
- emit toChanged(t);
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::PropertyAnimation::easing.type
- \qmlproperty real QtQuick2::PropertyAnimation::easing.amplitude
- \qmlproperty real QtQuick2::PropertyAnimation::easing.overshoot
- \qmlproperty real QtQuick2::PropertyAnimation::easing.period
- \qmlproperty list<real> QtQuick2::PropertyAnimation::easing.bezierCurve
- \brief the easing curve used for the animation.
-
- To specify an easing curve you need to specify at least the type. For some curves you can also specify
- amplitude, period and/or overshoot (more details provided after the table). The default easing curve is
- \c Easing.Linear.
-
- \qml
- PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 }
- \endqml
-
- Available types are:
-
- \table
- \row
- \o \c Easing.Linear
- \o Easing curve for a linear (t) function: velocity is constant.
- \o \inlineimage qeasingcurve-linear.png
- \row
- \o \c Easing.InQuad
- \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquad.png
- \row
- \o \c Easing.OutQuad
- \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity.
- \o \inlineimage qeasingcurve-outquad.png
- \row
- \o \c Easing.InOutQuad
- \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquad.png
- \row
- \o \c Easing.OutInQuad
- \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquad.png
- \row
- \o \c Easing.InCubic
- \o Easing curve for a cubic (t^3) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-incubic.png
- \row
- \o \c Easing.OutCubic
- \o Easing curve for a cubic (t^3) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outcubic.png
- \row
- \o \c Easing.InOutCubic
- \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutcubic.png
- \row
- \o \c Easing.OutInCubic
- \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outincubic.png
- \row
- \o \c Easing.InQuart
- \o Easing curve for a quartic (t^4) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquart.png
- \row
- \o \c Easing.OutQuart
- \o Easing curve for a quartic (t^4) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outquart.png
- \row
- \o \c Easing.InOutQuart
- \o Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquart.png
- \row
- \o \c Easing.OutInQuart
- \o Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquart.png
- \row
- \o \c Easing.InQuint
- \o Easing curve for a quintic (t^5) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquint.png
- \row
- \o \c Easing.OutQuint
- \o Easing curve for a quintic (t^5) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outquint.png
- \row
- \o \c Easing.InOutQuint
- \o Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquint.png
- \row
- \o \c Easing.OutInQuint
- \o Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquint.png
- \row
- \o \c Easing.InSine
- \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-insine.png
- \row
- \o \c Easing.OutSine
- \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outsine.png
- \row
- \o \c Easing.InOutSine
- \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutsine.png
- \row
- \o \c Easing.OutInSine
- \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinsine.png
- \row
- \o \c Easing.InExpo
- \o Easing curve for an exponential (2^t) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inexpo.png
- \row
- \o \c Easing.OutExpo
- \o Easing curve for an exponential (2^t) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outexpo.png
- \row
- \o \c Easing.InOutExpo
- \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutexpo.png
- \row
- \o \c Easing.OutInExpo
- \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinexpo.png
- \row
- \o \c Easing.InCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-incirc.png
- \row
- \o \c Easing.OutCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outcirc.png
- \row
- \o \c Easing.InOutCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutcirc.png
- \row
- \o \c Easing.OutInCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outincirc.png
- \row
- \o \c Easing.InElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity.
- \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
- \o \inlineimage qeasingcurve-inelastic.png
- \row
- \o \c Easing.OutElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity.
- \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
- \o \inlineimage qeasingcurve-outelastic.png
- \row
- \o \c Easing.InOutElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutelastic.png
- \row
- \o \c Easing.OutInElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinelastic.png
- \row
- \o \c Easing.InBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inback.png
- \row
- \o \c Easing.OutBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.
- \o \inlineimage qeasingcurve-outback.png
- \row
- \o \c Easing.InOutBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutback.png
- \row
- \o \c Easing.OutInBack
- \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinback.png
- \row
- \o \c Easing.InBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inbounce.png
- \row
- \o \c Easing.OutBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outbounce.png
- \row
- \o \c Easing.InOutBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutbounce.png
- \row
- \o \c Easing.OutInBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinbounce.png
- \row
- \o \c Easing.Bezier
- \o Custom easing curve defined by the easing.bezierCurve property.
- \o
- \endtable
-
- \c easing.amplitude is only applicable for bounce and elastic curves (curves of type
- \c Easing.InBounce, \c Easing.OutBounce, \c Easing.InOutBounce, \c Easing.OutInBounce, \c Easing.InElastic,
- \c Easing.OutElastic, \c Easing.InOutElastic or \c Easing.OutInElastic).
-
- \c easing.overshoot is only applicable if \c easing.type is: \c Easing.InBack, \c Easing.OutBack,
- \c Easing.InOutBack or \c Easing.OutInBack.
-
- \c easing.period is only applicable if easing.type is: \c Easing.InElastic, \c Easing.OutElastic,
- \c Easing.InOutElastic or \c Easing.OutInElastic.
-
- \c easing.bezierCurve is only applicable if easing.type is: \c Easing.Bezier. This property is a list<real> containing
- groups of three points defining a curve from 0,0 to 1,1 - control1, control2,
- end point: [cx1, cy1, cx2, cy2, endx, endy, ...]. The last point must be 1,1.
-
- See the \l {declarative/animation/easing}{easing} example for a demonstration of
- the different easing settings.
-*/
-QEasingCurve QDeclarativePropertyAnimation::easing() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->easing;
-}
-
-void QDeclarativePropertyAnimation::setEasing(const QEasingCurve &e)
-{
- Q_D(QDeclarativePropertyAnimation);
- if (d->easing == e)
- return;
-
- d->easing = e;
- emit easingChanged(e);
-}
-
-QObject *QDeclarativePropertyAnimation::target() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->target;
-}
-
-void QDeclarativePropertyAnimation::setTargetObject(QObject *o)
-{
- Q_D(QDeclarativePropertyAnimation);
- if (d->target == o)
- return;
- d->target = o;
- emit targetChanged();
-}
-
-QString QDeclarativePropertyAnimation::property() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->propertyName;
-}
-
-void QDeclarativePropertyAnimation::setProperty(const QString &n)
-{
- Q_D(QDeclarativePropertyAnimation);
- if (d->propertyName == n)
- return;
- d->propertyName = n;
- emit propertyChanged();
-}
-
-QString QDeclarativePropertyAnimation::properties() const
-{
- Q_D(const QDeclarativePropertyAnimation);
- return d->properties;
-}
-
-void QDeclarativePropertyAnimation::setProperties(const QString &prop)
-{
- Q_D(QDeclarativePropertyAnimation);
- if (d->properties == prop)
- return;
-
- d->properties = prop;
- emit propertiesChanged(prop);
-}
-
-/*!
- \qmlproperty string QtQuick2::PropertyAnimation::properties
- \qmlproperty list<Object> QtQuick2::PropertyAnimation::targets
- \qmlproperty string QtQuick2::PropertyAnimation::property
- \qmlproperty Object QtQuick2::PropertyAnimation::target
-
- These properties are used as a set to determine which properties should be animated.
- The singular and plural forms are functionally identical, e.g.
- \qml
- NumberAnimation { target: theItem; property: "x"; to: 500 }
- \endqml
- has the same meaning as
- \qml
- NumberAnimation { targets: theItem; properties: "x"; to: 500 }
- \endqml
- The singular forms are slightly optimized, so if you do have only a single target/property
- to animate you should try to use them.
-
- The \c targets property allows multiple targets to be set. For example, this animates the
- \c x property of both \c itemA and \c itemB:
-
- \qml
- NumberAnimation { targets: [itemA, itemB]; properties: "x"; to: 500 }
- \endqml
-
- In many cases these properties do not need to be explicitly specified, as they can be
- inferred from the animation framework:
-
- \table 80%
- \row
- \o Value Source / Behavior
- \o When an animation is used as a value source or in a Behavior, the default target and property
- name to be animated can both be inferred.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- NumberAnimation on x { to: 500; loops: Animation.Infinite } //animate theRect's x property
- Behavior on y { NumberAnimation {} } //animate theRect's y property
- }
- \endqml
- \row
- \o Transition
- \o When used in a transition, a property animation is assumed to match \e all targets
- but \e no properties. In practice, that means you need to specify at least the properties
- in order for the animation to do anything.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- Item { id: uselessItem }
- states: State {
- name: "state1"
- PropertyChanges { target: theRect; x: 200; y: 200; z: 4 }
- PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 }
- }
- transitions: Transition {
- //animate both theRect's and uselessItem's x and y to their final values
- NumberAnimation { properties: "x,y" }
-
- //animate theRect's z to its final value
- NumberAnimation { target: theRect; property: "z" }
- }
- }
- \endqml
- \row
- \o Standalone
- \o When an animation is used standalone, both the target and property need to be
- explicitly specified.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- //need to explicitly specify target and property
- NumberAnimation { id: theAnim; target: theRect; property: "x"; to: 500 }
- MouseArea {
- anchors.fill: parent
- onClicked: theAnim.start()
- }
- }
- \endqml
- \endtable
-
- As seen in the above example, properties is specified as a comma-separated string of property names to animate.
-
- \sa exclude, {QML Animation and Transitions}
-*/
-QDeclarativeListProperty<QObject> QDeclarativePropertyAnimation::targets()
-{
- Q_D(QDeclarativePropertyAnimation);
- return QDeclarativeListProperty<QObject>(this, d->targets);
-}
-
-/*!
- \qmlproperty list<Object> QtQuick2::PropertyAnimation::exclude
- This property holds the items not to be affected by this animation.
- \sa PropertyAnimation::targets
-*/
-QDeclarativeListProperty<QObject> QDeclarativePropertyAnimation::exclude()
-{
- Q_D(QDeclarativePropertyAnimation);
- return QDeclarativeListProperty<QObject>(this, d->exclude);
-}
-
-void QDeclarativeAnimationPropertyUpdater::setValue(qreal v)
-{
- bool deleted = false;
- wasDeleted = &deleted;
- if (reverse)
- v = 1 - v;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarativeAction &action = actions[ii];
-
- if (v == 1.) {
- QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- } else {
- if (!fromSourced && !fromDefined) {
- action.fromValue = action.property.read();
- if (interpolatorType) {
- QDeclarativePropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
- }
- }
- if (!interpolatorType) {
- int propType = action.property.propertyType();
- if (!prevInterpolatorType || prevInterpolatorType != propType) {
- prevInterpolatorType = propType;
- interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
- }
- }
- if (interpolator)
- QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- }
- if (deleted)
- return;
- }
- wasDeleted = 0;
- fromSourced = true;
-}
-
-QDeclarativeStateActions QDeclarativePropertyAnimation::createTransitionActions(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativePropertyAnimation);
- QDeclarativeStateActions newActions;
-
- QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
- props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty())
- props << d->propertyName;
-
- QList<QObject*> targets = d->targets;
- if (d->target)
- targets.append(d->target);
-
- bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
- bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
-
- if (d->defaultProperty.isValid() && !hasSelectors) {
- props << d->defaultProperty.name();
- targets << d->defaultProperty.object();
- }
-
- if (defaultTarget && targets.isEmpty())
- targets << defaultTarget;
-
- if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
- props << d->defaultProperties.split(QLatin1Char(','));
- }
-
- bool hasExplicit = false;
- //an explicit animation has been specified
- if (d->toIsDefined) {
- for (int i = 0; i < props.count(); ++i) {
- for (int j = 0; j < targets.count(); ++j) {
- QDeclarativeAction myAction;
- myAction.property = d->createProperty(targets.at(j), props.at(i), this);
- if (myAction.property.isValid()) {
- if (d->fromIsDefined) {
- myAction.fromValue = d->from;
- d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- }
- myAction.toValue = d->to;
- d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- newActions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarativeAction &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
- }
- }
- }
- }
- }
- }
-
- if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarativeAction &action = actions[ii];
-
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
- QObject *sObj = action.specifiedObject;
- QString sPropertyName = action.specifiedProperty;
- bool same = (obj == sObj);
-
- if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
- (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName))
- || (useType && action.property.propertyType() == d->interpolatorType))) {
- QDeclarativeAction myAction = action;
-
- if (d->fromIsDefined)
- myAction.fromValue = d->from;
- else
- myAction.fromValue = QVariant();
- if (d->toIsDefined)
- myAction.toValue = d->to;
-
- d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
-
- modified << action.property;
-
- newActions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
- return newActions;
-}
-
-QAbstractAnimationJob* QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativePropertyAnimation);
-
- QDeclarativeStateActions dataActions = createTransitionActions(actions, modified, defaultTarget);
-
- QDeclarativeBulkValueAnimator *animator = new QDeclarativeBulkValueAnimator;
- animator->setDuration(d->duration);
- animator->setEasingCurve(d->easing);
-
- if (!dataActions.isEmpty()) {
- QDeclarativeAnimationPropertyUpdater *data = new QDeclarativeAnimationPropertyUpdater;
- data->interpolatorType = d->interpolatorType;
- data->interpolator = d->interpolator;
- data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = d->fromIsDefined;
- data->actions = dataActions;
- animator->setAnimValue(data);
- animator->setFromSourcedValue(&data->fromSourced);
- d->actions = &data->actions; //remove this?
- }
-
- return initInstance(animator);
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativeanimation_p.h b/src/quick/util/qdeclarativeanimation_p.h
deleted file mode 100644
index ec6a42861d..0000000000
--- a/src/quick/util/qdeclarativeanimation_p.h
+++ /dev/null
@@ -1,464 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEANIMATION_H
-#define QDECLARATIVEANIMATION_H
-
-#include "qdeclarativestate_p.h"
-#include <QtGui/qvector3d.h>
-
-#include <qdeclarativepropertyvaluesource.h>
-#include <qdeclarative.h>
-#include <qdeclarativescriptstring.h>
-
-#include <QtCore/qvariant.h>
-#include <QtCore/qeasingcurve.h>
-#include "private/qabstractanimationjob_p.h"
-#include <QtGui/qcolor.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeAbstractAnimationPrivate;
-class QDeclarativeAnimationGroup;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeAbstractAnimation)
-
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_INTERFACES(QDeclarativePropertyValueSource)
- Q_ENUMS(Loops)
- Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged)
- Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged)
- Q_CLASSINFO("DefaultMethod", "start()")
-
-public:
- QDeclarativeAbstractAnimation(QObject *parent=0);
- virtual ~QDeclarativeAbstractAnimation();
-
- enum Loops { Infinite = -2 };
-
- bool isRunning() const;
- void setRunning(bool);
- bool isPaused() const;
- void setPaused(bool);
- bool alwaysRunToEnd() const;
- void setAlwaysRunToEnd(bool);
-
- int loops() const;
- void setLoops(int);
- int duration() const;
-
- int currentTime();
- void setCurrentTime(int);
-
- QDeclarativeAnimationGroup *group() const;
- void setGroup(QDeclarativeAnimationGroup *);
-
- void setDefaultTarget(const QDeclarativeProperty &);
- void setDisableUserControl();
- void setEnableUserControl();
- bool userControlDisabled() const;
- void classBegin();
- void componentComplete();
-
-Q_SIGNALS:
- void started();
- void completed();
- void runningChanged(bool);
- void pausedChanged(bool);
- void alwaysRunToEndChanged(bool);
- void loopCountChanged(int);
-
-public Q_SLOTS:
- void restart();
- void start();
- void pause();
- void resume();
- void stop();
- void complete();
-
-protected:
- QDeclarativeAbstractAnimation(QDeclarativeAbstractAnimationPrivate &dd, QObject *parent);
- QAbstractAnimationJob* initInstance(QAbstractAnimationJob *animation);
-
-public:
- enum TransitionDirection { Forward, Backward };
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
- QAbstractAnimationJob* qtAnimation();
-
-private Q_SLOTS:
- void componentFinalized();
-private:
- virtual void setTarget(const QDeclarativeProperty &);
- void notifyRunningChanged(bool running);
- friend class QDeclarativeBehavior;
- friend class QDeclarativeBehaviorPrivate;
-};
-
-class QDeclarativePauseAnimationPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativePauseAnimation : public QDeclarativeAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativePauseAnimation)
-
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
-
-public:
- QDeclarativePauseAnimation(QObject *parent=0);
- virtual ~QDeclarativePauseAnimation();
-
- int duration() const;
- void setDuration(int);
-
-Q_SIGNALS:
- void durationChanged(int);
-
-protected:
- QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-};
-
-class QDeclarativeScriptActionPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeScriptAction : public QDeclarativeAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeScriptAction)
-
- Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
-
-public:
- QDeclarativeScriptAction(QObject *parent=0);
- virtual ~QDeclarativeScriptAction();
-
- QDeclarativeScriptString script() const;
- void setScript(const QDeclarativeScriptString &);
-
- QString stateChangeScriptName() const;
- void setStateChangeScriptName(const QString &);
-
-protected:
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-};
-
-class QDeclarativePropertyActionPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativePropertyAction : public QDeclarativeAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativePropertyAction)
-
- Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged)
- Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets)
- Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude)
- Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
-
-public:
- QDeclarativePropertyAction(QObject *parent=0);
- virtual ~QDeclarativePropertyAction();
-
- QObject *target() const;
- void setTargetObject(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QString properties() const;
- void setProperties(const QString &);
-
- QDeclarativeListProperty<QObject> targets();
- QDeclarativeListProperty<QObject> exclude();
-
- QVariant value() const;
- void setValue(const QVariant &);
-
-Q_SIGNALS:
- void valueChanged(const QVariant &);
- void propertiesChanged(const QString &);
- void targetChanged();
- void propertyChanged();
-
-protected:
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-};
-
-class QDeclarativePropertyAnimationPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativePropertyAnimation : public QDeclarativeAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
-
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
- Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
- Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged)
- Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets)
- Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude)
-
-public:
- QDeclarativePropertyAnimation(QObject *parent=0);
- virtual ~QDeclarativePropertyAnimation();
-
- virtual int duration() const;
- virtual void setDuration(int);
-
- QVariant from() const;
- void setFrom(const QVariant &);
-
- QVariant to() const;
- void setTo(const QVariant &);
-
- QEasingCurve easing() const;
- void setEasing(const QEasingCurve &);
-
- QObject *target() const;
- void setTargetObject(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QString properties() const;
- void setProperties(const QString &);
-
- QDeclarativeListProperty<QObject> targets();
- QDeclarativeListProperty<QObject> exclude();
-
-protected:
- QDeclarativeStateActions createTransitionActions(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- QObject *defaultTarget = 0);
-
- QDeclarativePropertyAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent);
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-Q_SIGNALS:
- void durationChanged(int);
- void fromChanged(QVariant);
- void toChanged(QVariant);
- void easingChanged(const QEasingCurve &);
- void propertiesChanged(const QString &);
- void targetChanged();
- void propertyChanged();
-};
-
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeColorAnimation : public QDeclarativePropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
- Q_PROPERTY(QColor from READ from WRITE setFrom)
- Q_PROPERTY(QColor to READ to WRITE setTo)
-
-public:
- QDeclarativeColorAnimation(QObject *parent=0);
- virtual ~QDeclarativeColorAnimation();
-
- QColor from() const;
- void setFrom(const QColor &);
-
- QColor to() const;
- void setTo(const QColor &);
-};
-
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeNumberAnimation : public QDeclarativePropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
-
- Q_PROPERTY(qreal from READ from WRITE setFrom)
- Q_PROPERTY(qreal to READ to WRITE setTo)
-
-public:
- QDeclarativeNumberAnimation(QObject *parent=0);
- virtual ~QDeclarativeNumberAnimation();
-
- qreal from() const;
- void setFrom(qreal);
-
- qreal to() const;
- void setTo(qreal);
-
-protected:
- QDeclarativeNumberAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent);
-
-private:
- void init();
-};
-
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeVector3dAnimation : public QDeclarativePropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
-
- Q_PROPERTY(QVector3D from READ from WRITE setFrom)
- Q_PROPERTY(QVector3D to READ to WRITE setTo)
-
-public:
- QDeclarativeVector3dAnimation(QObject *parent=0);
- virtual ~QDeclarativeVector3dAnimation();
-
- QVector3D from() const;
- void setFrom(QVector3D);
-
- QVector3D to() const;
- void setTo(QVector3D);
-};
-
-class QDeclarativeRotationAnimationPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeRotationAnimation : public QDeclarativePropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeRotationAnimation)
- Q_ENUMS(RotationDirection)
-
- Q_PROPERTY(qreal from READ from WRITE setFrom)
- Q_PROPERTY(qreal to READ to WRITE setTo)
- Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
-
-public:
- QDeclarativeRotationAnimation(QObject *parent=0);
- virtual ~QDeclarativeRotationAnimation();
-
- qreal from() const;
- void setFrom(qreal);
-
- qreal to() const;
- void setTo(qreal);
-
- enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
- RotationDirection direction() const;
- void setDirection(RotationDirection direction);
-
-Q_SIGNALS:
- void directionChanged();
-};
-
-class QDeclarativeAnimationGroupPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeAnimationGroup : public QDeclarativeAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
-
- Q_CLASSINFO("DefaultProperty", "animations")
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations)
-
-public:
- QDeclarativeAnimationGroup(QObject *parent);
- virtual ~QDeclarativeAnimationGroup();
-
- QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations();
- friend class QDeclarativeAbstractAnimation;
-
-protected:
- QDeclarativeAnimationGroup(QDeclarativeAnimationGroupPrivate &dd, QObject *parent);
-};
-
-class QDeclarativeSequentialAnimation : public QDeclarativeAnimationGroup
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
-
-public:
- QDeclarativeSequentialAnimation(QObject *parent=0);
- virtual ~QDeclarativeSequentialAnimation();
-
-protected:
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-};
-
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeParallelAnimation : public QDeclarativeAnimationGroup
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
-
-public:
- QDeclarativeParallelAnimation(QObject *parent=0);
- virtual ~QDeclarativeParallelAnimation();
-
-protected:
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeAbstractAnimation)
-QML_DECLARE_TYPE(QDeclarativePauseAnimation)
-QML_DECLARE_TYPE(QDeclarativeScriptAction)
-QML_DECLARE_TYPE(QDeclarativePropertyAction)
-QML_DECLARE_TYPE(QDeclarativePropertyAnimation)
-QML_DECLARE_TYPE(QDeclarativeColorAnimation)
-QML_DECLARE_TYPE(QDeclarativeNumberAnimation)
-QML_DECLARE_TYPE(QDeclarativeSequentialAnimation)
-QML_DECLARE_TYPE(QDeclarativeParallelAnimation)
-QML_DECLARE_TYPE(QDeclarativeVector3dAnimation)
-QML_DECLARE_TYPE(QDeclarativeRotationAnimation)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEANIMATION_H
diff --git a/src/quick/util/qdeclarativeanimation_p_p.h b/src/quick/util/qdeclarativeanimation_p_p.h
deleted file mode 100644
index a6b47cbc17..0000000000
--- a/src/quick/util/qdeclarativeanimation_p_p.h
+++ /dev/null
@@ -1,322 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEANIMATION2_P_H
-#define QDECLARATIVEANIMATION2_P_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 "qdeclarativeanimation_p.h"
-
-#include <private/qdeclarativenullablevalue_p_p.h>
-
-#include <qdeclarative.h>
-#include <qdeclarativecontext.h>
-
-#include <private/qvariantanimation_p.h>
-#include "private/qpauseanimationjob_p.h"
-#include <QDebug>
-
-#include <private/qobject_p.h>
-#include "private/qanimationgroupjob_p.h"
-#include <QDebug>
-
-#include <private/qobject_p.h>
-
-
-QT_BEGIN_NAMESPACE
-
-//interface for classes that provide animation actions for QActionAnimation
-class QAbstractAnimationAction
-{
-public:
- virtual ~QAbstractAnimationAction() {}
- virtual void doAction() = 0;
-};
-
-//templated animation action
-//allows us to specify an action that calls a function of a class.
-//(so that class doesn't have to inherit QDeclarativeAbstractAnimationAction)
-template<class T, void (T::*method)()>
-class QAnimationActionProxy : public QAbstractAnimationAction
-{
-public:
- QAnimationActionProxy(T *instance) : m_instance(instance) {}
- virtual void doAction() { (m_instance->*method)(); }
-
-private:
- T *m_instance;
-};
-
-//performs an action of type QAbstractAnimationAction
-class Q_AUTOTEST_EXPORT QActionAnimation : public QAbstractAnimationJob
-{
- Q_DISABLE_COPY(QActionAnimation)
-public:
- QActionAnimation();
-
- QActionAnimation(QAbstractAnimationAction *action);
- ~QActionAnimation();
-
- virtual int duration() const;
- void setAnimAction(QAbstractAnimationAction *action);
-
-protected:
- virtual void updateCurrentTime(int);
- virtual void updateState(State newState, State oldState);
-
-private:
- QAbstractAnimationAction *animAction;
-};
-
-class QDeclarativeBulkValueUpdater
-{
-public:
- virtual ~QDeclarativeBulkValueUpdater() {}
- virtual void setValue(qreal value) = 0;
-};
-
-//animates QDeclarativeBulkValueUpdater (assumes start and end values will be reals or compatible)
-class Q_AUTOTEST_EXPORT QDeclarativeBulkValueAnimator : public QAbstractAnimationJob
-{
- Q_DISABLE_COPY(QDeclarativeBulkValueAnimator)
-public:
- QDeclarativeBulkValueAnimator();
- ~QDeclarativeBulkValueAnimator();
-
- void setAnimValue(QDeclarativeBulkValueUpdater *value);
- QDeclarativeBulkValueUpdater *getAnimValue() const { return animValue; }
-
- void setFromSourcedValue(bool *value) { fromSourced = value; }
-
- int duration() const { return m_duration; }
- void setDuration(int msecs) { m_duration = msecs; }
-
- QEasingCurve easingCurve() const { return easing; }
- void setEasingCurve(const QEasingCurve &curve) { easing = curve; }
-
-protected:
- void updateCurrentTime(int currentTime);
- void topLevelAnimationLoopChanged();
-
-private:
- QDeclarativeBulkValueUpdater *animValue;
- bool *fromSourced;
- int m_duration;
- QEasingCurve easing;
-};
-
-//an animation that just gives a tick
-template<class T, void (T::*method)(int)>
-class QTickAnimationProxy : public QAbstractAnimationJob
-{
- Q_DISABLE_COPY(QTickAnimationProxy)
-public:
- QTickAnimationProxy(T *instance) : QAbstractAnimationJob(), m_instance(instance) {}
- virtual int duration() const { return -1; }
-protected:
- virtual void updateCurrentTime(int msec) { (m_instance->*method)(msec); }
-
-private:
- T *m_instance;
-};
-
-class QDeclarativeAbstractAnimationPrivate : public QObjectPrivate, public QAnimationJobChangeListener
-{
- Q_DECLARE_PUBLIC(QDeclarativeAbstractAnimation)
-public:
- QDeclarativeAbstractAnimationPrivate()
- : running(false), paused(false), alwaysRunToEnd(false),
- /*connectedTimeLine(false), */componentComplete(true),
- avoidPropertyValueSourceStart(false), disableUserControl(false),
- registered(false), loopCount(1), group(0), animationInstance(0) {}
-
- bool running:1;
- bool paused:1;
- bool alwaysRunToEnd:1;
- //bool connectedTimeLine:1;
- bool componentComplete:1;
- bool avoidPropertyValueSourceStart:1;
- bool disableUserControl:1;
- bool registered:1;
-
- int loopCount;
-
- void commence();
- virtual void animationFinished(QAbstractAnimationJob *);
-
- QDeclarativeProperty defaultProperty;
-
- QDeclarativeAnimationGroup *group;
- QAbstractAnimationJob* animationInstance;
-
- static QDeclarativeProperty createProperty(QObject *obj, const QString &str, QObject *infoObj);
-};
-
-class QDeclarativePauseAnimationPrivate : public QDeclarativeAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativePauseAnimation)
-public:
- QDeclarativePauseAnimationPrivate()
- : QDeclarativeAbstractAnimationPrivate(), duration(250) {}
-
- int duration;
-};
-
-class QDeclarativeScriptActionPrivate : public QDeclarativeAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeScriptAction)
-public:
- QDeclarativeScriptActionPrivate();
-
- QDeclarativeScriptString script;
- QString name;
- QDeclarativeScriptString runScriptScript;
- bool hasRunScriptScript;
- bool reversing;
-
- void execute();
- QAbstractAnimationAction* createAction();
- typedef QAnimationActionProxy<QDeclarativeScriptActionPrivate,
- &QDeclarativeScriptActionPrivate::execute> Proxy;
-};
-
-class QDeclarativePropertyActionPrivate : public QDeclarativeAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativePropertyAction)
-public:
- QDeclarativePropertyActionPrivate()
- : QDeclarativeAbstractAnimationPrivate(), target(0) {}
-
- QObject *target;
- QString propertyName;
- QString properties;
- QList<QObject *> targets;
- QList<QObject *> exclude;
-
- QDeclarativeNullableValue<QVariant> value;
-};
-
-class QDeclarativeAnimationGroupPrivate : public QDeclarativeAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeAnimationGroup)
-public:
- QDeclarativeAnimationGroupPrivate()
- : QDeclarativeAbstractAnimationPrivate() {}
-
- static void append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *role);
- static void clear_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list);
- QList<QDeclarativeAbstractAnimation *> animations;
-};
-
-class QDeclarativePropertyAnimationPrivate : public QDeclarativeAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativePropertyAnimation)
-public:
- QDeclarativePropertyAnimationPrivate()
- : QDeclarativeAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), duration(250), actions(0) {}
-
- QVariant from;
- QVariant to;
-
- QObject *target;
- QString propertyName;
- QString properties;
- QList<QObject *> targets;
- QList<QObject *> exclude;
- QString defaultProperties;
-
- bool fromSourced;
- bool fromIsDefined:1;
- bool toIsDefined:1;
- bool defaultToInterpolatorType:1;
- int interpolatorType;
- QVariantAnimation::Interpolator interpolator;
- int duration;
- QEasingCurve easing;
-
- // for animations that don't use the QDeclarativeBulkValueAnimator
- QDeclarativeStateActions *actions;
-
- static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
- static void convertVariant(QVariant &variant, int type);
-};
-
-class QDeclarativeRotationAnimationPrivate : public QDeclarativePropertyAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeRotationAnimation)
-public:
- QDeclarativeRotationAnimationPrivate() : direction(QDeclarativeRotationAnimation::Numerical) {}
-
- QDeclarativeRotationAnimation::RotationDirection direction;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeAnimationPropertyUpdater : public QDeclarativeBulkValueUpdater
-{
-public:
- QDeclarativeAnimationPropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {}
- ~QDeclarativeAnimationPropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
-
- void setValue(qreal v);
-
- QDeclarativeStateActions actions;
- int interpolatorType; //for Number/ColorAnimation
- QVariantAnimation::Interpolator interpolator;
- int prevInterpolatorType; //for generic
- bool reverse;
- bool fromSourced;
- bool fromDefined;
- bool *wasDeleted;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEANIMATION2_P_H
diff --git a/src/quick/util/qdeclarativeanimationcontroller.cpp b/src/quick/util/qdeclarativeanimationcontroller.cpp
deleted file mode 100644
index 3901a65cb6..0000000000
--- a/src/quick/util/qdeclarativeanimationcontroller.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeanimationcontroller_p.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeAnimationControllerPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeAnimationController)
-public:
- QDeclarativeAnimationControllerPrivate()
- : progress(0.0), animation(0), animationInstance(0), finalized(false) {}
-
- qreal progress;
- QDeclarativeAbstractAnimation *animation;
- QAbstractAnimationJob *animationInstance;
- bool finalized:1;
-
-};
-
-/*!
- \qmlclass AnimationController QDeclarativeAnimationController
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \brief The AnimationController element allows you to control animations manually.
-
- Normally animations are driven by an internal timer, but the AnimationController
- allows the given \a animation to be driven by a \a progress value explicitly.
-*/
-
-
-QDeclarativeAnimationController::QDeclarativeAnimationController(QObject *parent)
-: QObject(*(new QDeclarativeAnimationControllerPrivate), parent)
-{
-}
-
-QDeclarativeAnimationController::~QDeclarativeAnimationController()
-{
- Q_D(QDeclarativeAnimationController);
- delete d->animationInstance;
-}
-
-/*!
- \qmlproperty real QtQuick2::AnimationController::progress
- This property holds the animation progress value.
-
- The valid \c progress value is 0.0 to 1.0, setting values less than 0 will be converted to 0,
- setting values great than 1 will be converted to 1.
-*/
-qreal QDeclarativeAnimationController::progress() const
-{
- Q_D(const QDeclarativeAnimationController);
- return d->progress;
-}
-
-void QDeclarativeAnimationController::setProgress(qreal progress)
-{
- Q_D(QDeclarativeAnimationController);
- progress = qBound(qreal(0), progress, qreal(1));
-
- if (progress != d->progress) {
- d->progress = progress;
- updateProgress();
- emit progressChanged();
- }
-}
-
-/*!
- \qmlproperty real QtQuick2::AnimationController::animation
- \default
-
- This property holds the animation to be controlled by the AnimationController.
-
- Note:An animation controlled by AnimationController will always have its
- \c running and \c paused properties set to true. It can not be manually
- started or stopped (much like an animation in a Behavior can not be manually started or stopped).
-*/
-QDeclarativeAbstractAnimation *QDeclarativeAnimationController::animation() const
-{
- Q_D(const QDeclarativeAnimationController);
- return d->animation;
-}
-
-void QDeclarativeAnimationController::classBegin()
-{
- QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
- engPriv->registerFinalizeCallback(this, this->metaObject()->indexOfSlot("componentFinalized()"));
-}
-
-
-void QDeclarativeAnimationController::setAnimation(QDeclarativeAbstractAnimation *animation)
-{
- Q_D(QDeclarativeAnimationController);
-
- if (animation != d->animation) {
- if (animation) {
- if (animation->userControlDisabled()) {
- qmlInfo(this) << "QDeclarativeAnimationController::setAnimation: the animation is controlled by others, can't be used in AnimationController.";
- return;
- }
- animation->setDisableUserControl();
- }
-
- if (d->animation)
- d->animation->setEnableUserControl();
-
- d->animation = animation;
- reload();
- emit animationChanged();
- }
-}
-
-/*!
- \qmlmethod QtQuick2::AnimationController::reload()
- \brief Reloads the animation properties.
-
- If the animation properties changed, calling this method to reload the animation definations.
-*/
-void QDeclarativeAnimationController::reload()
-{
- Q_D(QDeclarativeAnimationController);
- if (!d->finalized)
- return;
-
- if (!d->animation) {
- d->animationInstance = 0;
- } else {
- QDeclarativeStateActions actions;
- QDeclarativeProperties properties;
- QAbstractAnimationJob *oldInstance = d->animationInstance;
- d->animationInstance = d->animation->transition(actions, properties, QDeclarativeAbstractAnimation::Forward);
- if (oldInstance && oldInstance != d->animationInstance)
- delete oldInstance;
- d->animationInstance->setLoopCount(1);
- d->animationInstance->start();
- d->animationInstance->pause();
- updateProgress();
- }
-}
-
-void QDeclarativeAnimationController::updateProgress()
-{
- Q_D(QDeclarativeAnimationController);
- if (!d->animationInstance)
- return;
-
- d->animationInstance->start();
- QDeclarativeAnimationTimer::unregisterAnimation(d->animationInstance);
- d->animationInstance->setCurrentTime(d->progress * d->animationInstance->duration());
-}
-
-void QDeclarativeAnimationController::componentFinalized()
-{
- Q_D(QDeclarativeAnimationController);
- d->finalized = true;
- reload();
-}
-
-
-QT_END_NAMESPACE
-
-
diff --git a/src/quick/util/qdeclarativeanimationcontroller_p.h b/src/quick/util/qdeclarativeanimationcontroller_p.h
deleted file mode 100644
index 4a064f6808..0000000000
--- a/src/quick/util/qdeclarativeanimationcontroller_p.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEANIMATIONCONTROLLER_H
-#define QDECLARATIVEANIMATIONCONTROLLER_H
-
-#include <qdeclarative.h>
-#include "qdeclarativeanimation_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeAnimationControllerPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeAnimationController : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-
- Q_DECLARE_PRIVATE(QDeclarativeAnimationController)
- Q_CLASSINFO("DefaultProperty", "animation")
-
- Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
- Q_PROPERTY(QDeclarativeAbstractAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged)
-
-public:
- QDeclarativeAnimationController(QObject *parent=0);
- ~QDeclarativeAnimationController();
-
- qreal progress() const;
- void setProgress(qreal progress);
-
- QDeclarativeAbstractAnimation *animation() const;
- void setAnimation(QDeclarativeAbstractAnimation *animation);
-
- void classBegin();
- void componentComplete() {}
-Q_SIGNALS:
- void progressChanged();
- void animationChanged();
-public Q_SLOTS:
- void reload();
-private Q_SLOTS:
- void componentFinalized();
- void updateProgress();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeAnimationController)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEANIMATIONCONTROLLER_H
diff --git a/src/quick/util/qdeclarativebehavior.cpp b/src/quick/util/qdeclarativebehavior.cpp
deleted file mode 100644
index 6cf372ece9..0000000000
--- a/src/quick/util/qdeclarativebehavior.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativebehavior_p.h"
-
-#include "qdeclarativeanimation_p.h"
-#include <qdeclarativecontext.h>
-#include <qdeclarativeinfo.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativeguard_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qabstractanimationjob_p.h>
-#include <private/qdeclarativetransition_p.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeBehaviorPrivate : public QObjectPrivate, public QAnimationJobChangeListener
-{
- Q_DECLARE_PUBLIC(QDeclarativeBehavior)
-public:
- QDeclarativeBehaviorPrivate() : animation(0), animationInstance(0), enabled(true), finalized(false)
- , blockRunningChanged(false) {}
-
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
-
- QDeclarativeProperty property;
- QVariant targetValue;
- QDeclarativeGuard<QDeclarativeAbstractAnimation> animation;
- QAbstractAnimationJob *animationInstance;
- bool enabled;
- bool finalized;
- bool blockRunningChanged;
-};
-
-/*!
- \qmlclass Behavior QDeclarativeBehavior
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \brief The Behavior element allows you to specify a default animation for a property change.
-
- 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
-
- Note that a property cannot have more than one assigned Behavior. To provide
- multiple animations within a Behavior, use ParallelAnimation or
- SequentialAnimation.
-
- If a \l{QML States}{state change} has a \l Transition that matches the same property as a
- Behavior, the \l Transition animation overrides the Behavior for that
- state change. For general advice on using Behaviors to animate state changes, see
- \l{Using QML Behaviors with States}.
-
- \sa {QML Animation and Transitions}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative
-*/
-
-
-QDeclarativeBehavior::QDeclarativeBehavior(QObject *parent)
- : QObject(*(new QDeclarativeBehaviorPrivate), parent)
-{
-}
-
-QDeclarativeBehavior::~QDeclarativeBehavior()
-{
- Q_D(QDeclarativeBehavior);
- delete d->animationInstance;
-}
-
-/*!
- \qmlproperty Animation QtQuick2::Behavior::animation
- \default
-
- This property holds the animation to run when the behavior is triggered.
-*/
-
-QDeclarativeAbstractAnimation *QDeclarativeBehavior::animation()
-{
- Q_D(QDeclarativeBehavior);
- return d->animation;
-}
-
-void QDeclarativeBehavior::setAnimation(QDeclarativeAbstractAnimation *animation)
-{
- Q_D(QDeclarativeBehavior);
- if (d->animation) {
- qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior.");
- return;
- }
-
- d->animation = animation;
- if (d->animation) {
- d->animation->setDefaultTarget(d->property);
- d->animation->setDisableUserControl();
- }
-}
-
-
-void QDeclarativeBehaviorPrivate::animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState,QAbstractAnimationJob::State)
-{
- if (!blockRunningChanged)
- animation->notifyRunningChanged(newState == QAbstractAnimationJob::Running);
-}
-
-/*!
- \qmlproperty bool QtQuick2::Behavior::enabled
-
- This property holds whether the behavior will be triggered when the tracked
- property changes value.
-
- By default a Behavior is enabled.
-*/
-
-bool QDeclarativeBehavior::enabled() const
-{
- Q_D(const QDeclarativeBehavior);
- return d->enabled;
-}
-
-void QDeclarativeBehavior::setEnabled(bool enabled)
-{
- Q_D(QDeclarativeBehavior);
- if (d->enabled == enabled)
- return;
- d->enabled = enabled;
- emit enabledChanged();
-}
-
-void QDeclarativeBehavior::write(const QVariant &value)
-{
- Q_D(QDeclarativeBehavior);
- bool bypass = !d->enabled || !d->finalized;
- if (!bypass)
- qmlExecuteDeferred(this);
- if (!d->animation || bypass) {
- QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- d->targetValue = value;
- return;
- }
-
- if (d->animation->isRunning() && value == d->targetValue)
- return;
-
- const QVariant &currentValue = d->property.read();
- d->targetValue = value;
-
- if (d->animationInstance && d->animationInstance->duration() != -1
- && !d->animationInstance->isStopped()) {
- d->blockRunningChanged = true;
- d->animationInstance->stop();
- }
-
- QDeclarativeStateOperation::ActionList actions;
- QDeclarativeAction action;
- action.property = d->property;
- action.fromValue = currentValue;
- action.toValue = value;
- actions << action;
-
- QList<QDeclarativeProperty> after;
- QAbstractAnimationJob *prev = d->animationInstance;
- d->animationInstance = d->animation->transition(actions, after, QDeclarativeAbstractAnimation::Forward);
- if (d->animationInstance != prev) {
- d->animationInstance->addAnimationChangeListener(d, QAbstractAnimationJob::StateChange);
- if (prev)
- delete prev;
- }
- d->animationInstance->start();
- d->blockRunningChanged = false;
- if (!after.contains(d->property))
- QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
-}
-
-void QDeclarativeBehavior::setTarget(const QDeclarativeProperty &property)
-{
- Q_D(QDeclarativeBehavior);
- d->property = property;
- if (d->animation)
- d->animation->setDefaultTarget(property);
-
- QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
- static int finalizedIdx = -1;
- if (finalizedIdx < 0)
- finalizedIdx = metaObject()->indexOfSlot("componentFinalized()");
- engPriv->registerFinalizeCallback(this, finalizedIdx);
-}
-
-void QDeclarativeBehavior::componentFinalized()
-{
- Q_D(QDeclarativeBehavior);
- d->finalized = true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativebehavior_p.h b/src/quick/util/qdeclarativebehavior_p.h
deleted file mode 100644
index c95304dce7..0000000000
--- a/src/quick/util/qdeclarativebehavior_p.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEBEHAVIOR_H
-#define QDECLARATIVEBEHAVIOR_H
-
-#include <private/qtquickglobal_p.h>
-
-#include <private/qdeclarativepropertyvalueinterceptor_p.h>
-#include <qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeAbstractAnimation;
-class QDeclarativeBehaviorPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeBehavior : public QObject, public QDeclarativePropertyValueInterceptor
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeBehavior)
-
- Q_INTERFACES(QDeclarativePropertyValueInterceptor)
- Q_CLASSINFO("DefaultProperty", "animation")
- Q_PROPERTY(QDeclarativeAbstractAnimation *animation READ animation WRITE setAnimation)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_CLASSINFO("DeferredPropertyNames", "animation")
-
-public:
- QDeclarativeBehavior(QObject *parent=0);
- ~QDeclarativeBehavior();
-
- virtual void setTarget(const QDeclarativeProperty &);
- virtual void write(const QVariant &value);
-
- QDeclarativeAbstractAnimation *animation();
- void setAnimation(QDeclarativeAbstractAnimation *);
-
- bool enabled() const;
- void setEnabled(bool enabled);
-
-Q_SIGNALS:
- void enabledChanged();
-
-private Q_SLOTS:
- void componentFinalized();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeBehavior)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEBEHAVIOR_H
diff --git a/src/quick/util/qdeclarativebind.cpp b/src/quick/util/qdeclarativebind.cpp
deleted file mode 100644
index 05d3b1e6b0..0000000000
--- a/src/quick/util/qdeclarativebind.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativebind_p.h"
-
-#include <private/qdeclarativenullablevalue_p_p.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativeguard_p.h>
-
-#include <qdeclarativeengine.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarativeproperty.h>
-#include <qdeclarativeinfo.h>
-
-#include <QtCore/qfile.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeBindPrivate : public QObjectPrivate
-{
-public:
- QDeclarativeBindPrivate() : componentComplete(true), obj(0), prevBind(0) {}
- ~QDeclarativeBindPrivate() { if (prevBind) prevBind->destroy(); }
-
- QDeclarativeNullableValue<bool> when;
- bool componentComplete;
- QDeclarativeGuard<QObject> obj;
- QString propName;
- QDeclarativeNullableValue<QVariant> value;
- QDeclarativeProperty prop;
- QDeclarativeAbstractBinding *prevBind;
-};
-
-
-/*!
- \qmlclass Binding QDeclarativeBind
- \inqmlmodule QtQuick 2
- \ingroup qml-working-with-data
- \brief The Binding element allows arbitrary property bindings to be created.
-
- \section1 Binding to an inaccessible property
-
- Sometimes it is necessary to bind to a property of an object that wasn't
- directly instantiated by QML - generally a property of a class exported
- to QML by C++. In these cases, regular property binding doesn't work. Binding
- allows you to bind any value to any property.
-
- For example, imagine a C++ application that maps an "app.enteredText"
- property into QML. You could use Binding to update the enteredText property
- like this.
- \code
- TextEdit { id: myTextField; text: "Please type here..." }
- Binding { target: app; property: "enteredText"; value: myTextField.text }
- \endcode
- Whenever the text in the TextEdit is updated, the C++ property will be
- updated also.
-
- \section1 "Single-branch" conditional binding
-
- In some circumstances you may want to control the value of a property
- only when a certain condition is true (and relinquish control in all
- other cirumstances). This often isn't possible to accomplish with a direct
- binding, as you need to supply values for all possible branches.
-
- \qml
- // warning: "Unable to assign [undefined] to double value"
- value: if (mouse.pressed) mouse.mouseX
- \endqml
-
- The above example will produce a warning whenever we release the mouse, as the value
- of the binding is undefined when the mouse isn't pressed. We can use the Binding
- element to rewrite the above code and avoid the warning.
-
- \qml
- Binding on value {
- when: mouse.pressed
- value: mouse.mouseX
- }
- \endqml
-
- The Binding element will also restore any previously set direct bindings on
- the property. In that sense, it functions much like a simplified State.
-
- \qml
- // this is equivilant to the above Binding
- State {
- name: "pressed"
- when: mouse.pressed
- PropertyChanges {
- target: obj
- value: mouse.mouseX
- }
- }
- \endqml
-
- If the binding target or binding property is changed, the bound value is
- immediately pushed onto the new target.
-
- \sa QtDeclarative
-*/
-QDeclarativeBind::QDeclarativeBind(QObject *parent)
- : QObject(*(new QDeclarativeBindPrivate), parent)
-{
-}
-
-QDeclarativeBind::~QDeclarativeBind()
-{
-}
-
-/*!
- \qmlproperty bool QtQuick2::Binding::when
-
- This property holds when the binding is active.
- This should be set to an expression that evaluates to true when you want the binding to be active.
-
- \code
- Binding {
- target: contactName; property: 'text'
- value: name; when: list.ListView.isCurrentItem
- }
- \endcode
-
- When the binding becomes inactive again, any direct bindings that were previously
- set on the property will be restored.
-*/
-bool QDeclarativeBind::when() const
-{
- Q_D(const QDeclarativeBind);
- return d->when;
-}
-
-void QDeclarativeBind::setWhen(bool v)
-{
- Q_D(QDeclarativeBind);
- if (!d->when.isNull && d->when == v)
- return;
-
- d->when = v;
- eval();
-}
-
-/*!
- \qmlproperty Object QtQuick2::Binding::target
-
- The object to be updated.
-*/
-QObject *QDeclarativeBind::object()
-{
- Q_D(const QDeclarativeBind);
- return d->obj;
-}
-
-void QDeclarativeBind::setObject(QObject *obj)
-{
- Q_D(QDeclarativeBind);
- if (d->obj && d->when.isValid() && d->when) {
- /* if we switch the object at runtime, we need to restore the
- previous binding on the old object before continuing */
- d->when = false;
- eval();
- d->when = true;
- }
- d->obj = obj;
- if (d->componentComplete)
- d->prop = QDeclarativeProperty(d->obj, d->propName);
- eval();
-}
-
-/*!
- \qmlproperty string QtQuick2::Binding::property
-
- The property to be updated.
-*/
-QString QDeclarativeBind::property() const
-{
- Q_D(const QDeclarativeBind);
- return d->propName;
-}
-
-void QDeclarativeBind::setProperty(const QString &p)
-{
- Q_D(QDeclarativeBind);
- if (!d->propName.isEmpty() && d->when.isValid() && d->when) {
- /* if we switch the property name at runtime, we need to restore the
- previous binding on the old object before continuing */
- d->when = false;
- eval();
- d->when = true;
- }
- d->propName = p;
- if (d->componentComplete)
- d->prop = QDeclarativeProperty(d->obj, d->propName);
- eval();
-}
-
-/*!
- \qmlproperty any QtQuick2::Binding::value
-
- The value to be set on the target object and property. This can be a
- constant (which isn't very useful), or a bound expression.
-*/
-QVariant QDeclarativeBind::value() const
-{
- Q_D(const QDeclarativeBind);
- return d->value.value;
-}
-
-void QDeclarativeBind::setValue(const QVariant &v)
-{
- Q_D(QDeclarativeBind);
- d->value = v;
- eval();
-}
-
-void QDeclarativeBind::setTarget(const QDeclarativeProperty &p)
-{
- Q_D(QDeclarativeBind);
- d->prop = p;
-}
-
-void QDeclarativeBind::classBegin()
-{
- Q_D(QDeclarativeBind);
- d->componentComplete = false;
-}
-
-void QDeclarativeBind::componentComplete()
-{
- Q_D(QDeclarativeBind);
- d->componentComplete = true;
- if (!d->prop.isValid())
- d->prop = QDeclarativeProperty(d->obj, d->propName);
- eval();
-}
-
-void QDeclarativeBind::eval()
-{
- Q_D(QDeclarativeBind);
- if (!d->prop.isValid() || d->value.isNull || !d->componentComplete)
- return;
-
- if (d->when.isValid()) {
- if (!d->when) {
- //restore any previous binding
- if (d->prevBind) {
- QDeclarativeAbstractBinding *tmp = d->prevBind;
- d->prevBind = 0;
- tmp = QDeclarativePropertyPrivate::setBinding(d->prop, tmp);
- if (tmp) //should this ever be true?
- tmp->destroy();
- }
- return;
- }
-
- //save any set binding for restoration
- QDeclarativeAbstractBinding *tmp;
- tmp = QDeclarativePropertyPrivate::setBinding(d->prop, 0);
- if (tmp && d->prevBind)
- d->prevBind->destroy();
- else if (!d->prevBind)
- d->prevBind = tmp;
- }
-
- d->prop.write(d->value.value);
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativebind_p.h b/src/quick/util/qdeclarativebind_p.h
deleted file mode 100644
index a06ca222d1..0000000000
--- a/src/quick/util/qdeclarativebind_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEBIND_H
-#define QDECLARATIVEBIND_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeBindPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeBind : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeBind)
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_INTERFACES(QDeclarativePropertyValueSource)
- Q_PROPERTY(QObject *target READ object WRITE setObject)
- Q_PROPERTY(QString property READ property WRITE setProperty)
- Q_PROPERTY(QVariant value READ value WRITE setValue)
- Q_PROPERTY(bool when READ when WRITE setWhen)
-
-public:
- QDeclarativeBind(QObject *parent=0);
- ~QDeclarativeBind();
-
- bool when() const;
- void setWhen(bool);
-
- QObject *object();
- void setObject(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QVariant value() const;
- void setValue(const QVariant &);
-
-protected:
- virtual void setTarget(const QDeclarativeProperty &);
- virtual void classBegin();
- virtual void componentComplete();
-
-private:
- void eval();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeBind)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/quick/util/qdeclarativechangeset.cpp b/src/quick/util/qdeclarativechangeset.cpp
deleted file mode 100644
index 74328a603e..0000000000
--- a/src/quick/util/qdeclarativechangeset.cpp
+++ /dev/null
@@ -1,479 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativechangeset_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeChangeSet::QDeclarativeChangeSet()
- : m_moveCounter(0)
- , m_difference(0)
-{
-}
-
-QDeclarativeChangeSet::QDeclarativeChangeSet(const QDeclarativeChangeSet &changeSet)
- : m_removes(changeSet.m_removes)
- , m_inserts(changeSet.m_inserts)
- , m_changes(changeSet.m_changes)
- , m_moveCounter(changeSet.m_moveCounter)
- , m_difference(0)
-{
-}
-
-QDeclarativeChangeSet::~QDeclarativeChangeSet()
-{
-}
-
-QDeclarativeChangeSet &QDeclarativeChangeSet::operator =(const QDeclarativeChangeSet &changeSet)
-{
- m_removes = changeSet.m_removes;
- m_inserts = changeSet.m_inserts;
- m_changes = changeSet.m_changes;
- m_moveCounter = changeSet.m_moveCounter;
- m_difference = changeSet.m_difference;
- return *this;
-}
-
-void QDeclarativeChangeSet::insert(int index, int count)
-{
- applyInsertions(QVector<Insert>() << Insert(index, count));
-}
-
-void QDeclarativeChangeSet::remove(int index, int count)
-{
- QVector<Insert> i;
- applyRemovals(QVector<Remove>() << Remove(index, count), i);
-}
-
-void QDeclarativeChangeSet::move(int from, int to, int count)
-{
- apply(QVector<Remove>() << Remove(from, count, -2), QVector<Insert>() << Insert(to, count, -2));
-}
-
-void QDeclarativeChangeSet::change(int index, int count)
-{
- applyChanges(QVector<Change>() << Change(index, count));
-}
-
-void QDeclarativeChangeSet::apply(const QDeclarativeChangeSet &changeSet)
-{
- apply(changeSet.m_removes, changeSet.m_inserts, changeSet.m_changes);
-}
-
-void QDeclarativeChangeSet::apply(const QVector<Remove> &removals)
-{
- QVector<Remove> r = removals;
- QVector<Insert> i;
- applyRemovals(r, i);
-}
-
-void QDeclarativeChangeSet::apply(const QVector<Insert> &insertions)
-{
- QVector<Insert> i = insertions;
- applyInsertions(i);
-}
-
-void QDeclarativeChangeSet::apply(const QVector<Change> &changes)
-{
- QVector<Change> c = changes;
- applyChanges(c);
-}
-
-void QDeclarativeChangeSet::apply(const QVector<Remove> &removals, const QVector<Insert> &insertions, const QVector<Change> &changes)
-{
- QVector<Remove> r = removals;
- QVector<Insert> i = insertions;
- QVector<Change> c = changes;
- applyRemovals(r, i);
- applyInsertions(i);
- applyChanges(c);
-}
-
-void QDeclarativeChangeSet::applyRemovals(QVector<Remove> &removals, QVector<Insert> &insertions)
-{
- int removeCount = 0;
- int insertCount = 0;
- QVector<Insert>::iterator insert = m_inserts.begin();
- QVector<Change>::iterator change = m_changes.begin();
- QVector<Remove>::iterator rit = removals.begin();
- for (; rit != removals.end(); ++rit) {
- int index = rit->index + removeCount;
- int count = rit->count;
-
- QVector<Insert>::iterator iit = insertions.begin();
- for (; rit->moveId != -1 && iit != insertions.end() && iit->moveId != rit->moveId; ++iit) {}
-
- for (QVector<Remove>::iterator nrit = rit + 1; nrit != removals.end(); nrit = rit + 1) {
- if (nrit->index != rit->index || (rit->moveId == -1) != (nrit->moveId == -1))
- break;
- if (nrit->moveId != -1) {
- QVector<Insert>::iterator niit = iit + 1;
- if (niit->moveId != nrit->moveId || niit->index != iit->index + iit->count)
- break;
- niit->index = iit->index;
- niit->count += iit->count;
- iit = insertions.erase(iit);
- }
- nrit->count += rit->count;
- rit = removals.erase(rit);
- }
-
- for (; change != m_changes.end() && change->end() < rit->index; ++change) {}
- for (; change != m_changes.end() && change->index > rit->end(); ++change) {
- change->count -= qMin(change->end(), rit->end()) - qMax(change->index, rit->index);
- if (change->count == 0) {
- change = m_changes.erase(change);
- } else if (rit->index < change->index) {
- change->index = rit->index;
- }
- }
- for (; insert != m_inserts.end() && insert->end() <= index; ++insert) {
- insertCount += insert->count;
- insert->index -= removeCount;
- }
- for (; insert != m_inserts.end() && insert->index < index + count; ++insert) {
- const int offset = insert->index - index;
- const int difference = qMin(insert->end(), index + count) - qMax(insert->index, index);
- const int moveId = rit->moveId != -1 ? m_moveCounter++ : -1;
- if (insert->moveId != -1) {
- QVector<Remove>::iterator remove = m_removes.begin();
- for (; remove != m_removes.end() && remove->moveId != insert->moveId; ++remove) {}
- Q_ASSERT(remove != m_removes.end());
- const int offset = index - insert->index;
- if (rit->moveId != -1 && offset < 0) {
- const int moveId = m_moveCounter++;
- iit = insertions.insert(iit, Insert(iit->index, -offset, moveId));
- ++iit;
- iit->index += -offset;
- iit->count -= -offset;
- rit = removals.insert(rit, Remove(rit->index, -offset, moveId));
- ++rit;
- rit->count -= -offset;
- }
-
- if (offset > 0) {
- const int moveId = m_moveCounter++;
- insert = m_inserts.insert(insert, Insert(insert->index, offset, moveId));
- ++insert;
- insert->index += offset;
- insert->count -= offset;
- remove = m_removes.insert(remove, Remove(remove->index, offset, moveId));
- ++remove;
- remove->count -= offset;
- rit->index -= offset;
- index += offset;
- count -= offset;
- }
-
- if (remove->count == difference) {
- remove->moveId = moveId;
- } else {
- remove = m_removes.insert(remove, Remove(remove->index, difference, moveId));
- ++remove;
- remove->count -= difference;
- }
- } else if (rit->moveId != -1 && offset > 0) {
- const int moveId = m_moveCounter++;
- iit = insertions.insert(iit, Insert(iit->index, offset, moveId));
- ++iit;
- iit->index += offset;
- iit->count -= offset;
- rit = removals.insert(rit, Remove(rit->index, offset, moveId));
- ++rit;
- rit->count -= offset;
- index += offset;
- count -= offset;
- }
-
- if (rit->moveId != -1 && difference > 0) {
- iit = insertions.insert(iit, Insert(
- iit->index, difference, insert->moveId != -1 ? moveId : -1));
- ++iit;
- iit->index += difference;
- iit->count -= difference;
- }
-
- insert->count -= difference;
- rit->count -= difference;
- if (insert->count == 0) {
- insert = m_inserts.erase(insert);
- --insert;
- } else if (index <= insert->index) {
- insert->index = rit->index;
- } else {
- rit->index -= insert->count;
- }
- index += difference;
- count -= difference;
- removeCount += difference;
- }
- rit->index -= insertCount;
- removeCount += rit->count;
-
- if (rit->count == 0) {
- if (rit->moveId != -1 && iit->count == 0)
- insertions.erase(iit);
- rit = removals.erase(rit);
- --rit;
- } else if (rit->moveId != -1) {
- const int moveId = m_moveCounter++;
- rit->moveId = moveId;
- iit->moveId = moveId;
- }
- }
- for (; change != m_changes.end(); ++change)
- change->index -= removeCount;
- for (; insert != m_inserts.end(); ++insert)
- insert->index -= removeCount;
-
- removeCount = 0;
- QVector<Remove>::iterator remove = m_removes.begin();
- for (rit = removals.begin(); rit != removals.end(); ++rit) {
- QVector<Insert>::iterator iit = insertions.begin();
- int index = rit->index + removeCount;
- for (; rit->moveId != -1 && iit != insertions.end() && iit->moveId != rit->moveId; ++iit) {}
- for (; remove != m_removes.end() && index > remove->index; ++remove)
- remove->index -= removeCount;
- while (remove != m_removes.end() && index + rit->count > remove->index) {
- int count = 0;
- const int offset = remove->index - index - removeCount;
- QVector<Remove>::iterator rend = remove;
- for (; rend != m_removes.end()
- && rit->moveId == -1
- && rend->moveId == -1
- && rit->index + rit->count >= rend->index; ++rend) {
- count += rend->count;
- }
- if (remove != rend) {
- const int difference = rend == m_removes.end() || rit->index + rit->count < rend->index - removeCount
- ? rit->count
- : offset;
- count += difference;
-
- index += difference;
- rit->count -= difference;
- removeCount += difference;
- remove->index = rit->index;
- remove->count = count;
- remove = m_removes.erase(++remove, rend);
- } else if (rit->moveId != -1) {
- if (offset > 0) {
- const int moveId = m_moveCounter++;
- iit = insertions.insert(iit, Insert(iit->index, offset, moveId));
- ++iit;
- iit->index += offset;
- iit->count -= offset;
- remove = m_removes.insert(remove, Remove(rit->index, offset, moveId));
- ++remove;
- rit->count -= offset;
- removeCount += offset;
- }
- remove->index = rit->index;
- index += offset;
-
- ++remove;
- } else {
- if (offset > 0) {
- remove = m_removes.insert(remove, Remove(rit->index, offset));
- ++remove;
- rit->count -= offset;
- removeCount += offset;
- }
- remove->index = rit->index;
- index += offset;
-
- ++remove;
- }
- index += count;
- }
-
- if (rit->count > 0) {
- remove = m_removes.insert(remove, *rit);
- ++remove;
- }
- removeCount += rit->count;
- }
- for (; remove != m_removes.end(); ++remove)
- remove->index -= removeCount;
- m_difference -= removeCount;
-}
-
-void QDeclarativeChangeSet::applyInsertions(QVector<Insert> &insertions)
-{
- int insertCount = 0;
- QVector<Insert>::iterator insert = m_inserts.begin();
- QVector<Change>::iterator change = m_changes.begin();
- for (QVector<Insert>::iterator iit = insertions.begin(); iit != insertions.end(); ++iit) {
- int index = iit->index - insertCount;
- int count = iit->count;
- for (; change != m_changes.end() && change->index >= index; ++change)
- change->index += insertCount;
- if (change != m_changes.end() && change->index < index + count) {
- int offset = index - change->index;
- change = m_changes.insert(change, Change(change->index + insertCount, offset));
- ++change;
- change->index += count + offset;
- change->count -= offset;
- }
- for (; insert != m_inserts.end() && iit->index > insert->index + insert->count; ++insert)
- insert->index += insertCount;
- if (insert == m_inserts.end()) {
- insert = m_inserts.insert(insert, *iit);
- ++insert;
- insertCount += iit->count;
- } else {
- const int offset = index - insert->index;
- if (offset < 0 || (offset == 0 && (iit->moveId != -1 || insert->moveId != -1))) {
- insert = m_inserts.insert(insert, *iit);
- ++insert;
- } else if (iit->moveId == -1 && insert->moveId == -1) {
- insert->index -= iit->count;
- insert->count += iit->count;
- } else if (offset < insert->count) {
- const int moveId = insert->moveId != -1 ? m_moveCounter++ : -1;
- insert = m_inserts.insert(insert, Insert(insert->index + insertCount, offset, moveId));
- ++insert;
- insert->index += offset;
- insert->count -= offset;
- insert = m_inserts.insert(insert, *iit);
- ++insert;
-
- if (insert->moveId != -1) {
- QVector<Remove>::iterator remove = m_removes.begin();
- for (; remove != m_removes.end() && remove->moveId != insert->moveId; ++remove) {}
- Q_ASSERT(remove != m_removes.end());
- if (remove->count == offset) {
- remove->moveId = moveId;
- } else {
- remove = m_removes.insert(remove, Remove(remove->index, offset, moveId));
- ++remove;
- remove->count -= offset;
- }
- }
- } else {
- ++insert;
- insert = m_inserts.insert(insert, *iit);
- ++insert;
- }
- insertCount += iit->count;
- }
- }
- for (; change != m_changes.end(); ++change)
- change->index += insertCount;
- for (; insert != m_inserts.end(); ++insert)
- insert->index += insertCount;
- m_difference += insertCount;
-}
-
-void QDeclarativeChangeSet::applyChanges(QVector<Change> &changes)
-{
- QVector<Insert>::iterator insert = m_inserts.begin();
- QVector<Change>::iterator change = m_changes.begin();
- for (QVector<Change>::iterator cit = changes.begin(); cit != changes.end(); ++cit) {
- for (; insert != m_inserts.end() && insert->end() < cit->index; ++insert) {}
- for (; insert != m_inserts.end() && insert->index < cit->end(); ++insert) {
- const int offset = insert->index - cit->index;
- const int count = cit->count + cit->index - insert->index - insert->count;
- if (offset == 0) {
- cit->index = insert->index + insert->count;
- cit->count = count;
- } else {
- cit = changes.insert(++cit, Change(insert->index + insert->count, count));
- --cit;
- cit->count = offset;
- }
- }
-
- for (; change != m_changes.end() && change->index + change->count < cit->index; ++change) {}
- if (change == m_changes.end() || change->index > cit->index + cit->count) {
- if (cit->count > 0) {
- change = m_changes.insert(change, *cit);
- ++change;
- }
- } else {
- if (cit->index < change->index) {
- change->count += change->index - cit->index;
- change->index = cit->index;
- }
-
- if (cit->index + cit->count > change->index + change->count) {
- change->count = cit->index + cit->count - change->index;
- QVector<Change>::iterator rbegin = change;
- QVector<Change>::iterator rend = ++rbegin;
- for (; rend != m_changes.end() && rend->index <= change->index + change->count; ++rend) {
- if (rend->index + rend->count > change->index + change->count)
- change->count = rend->index + rend->count - change->index;
- }
- if (rbegin != rend) {
- change = m_changes.erase(rbegin, rend);
- --change;
- }
- }
- }
- }
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeChangeSet &set)
-{
- debug.nospace() << "QDeclarativeChangeSet(";
- foreach (const QDeclarativeChangeSet::Remove &remove, set.removes()) debug << remove;
- foreach (const QDeclarativeChangeSet::Insert &insert, set.inserts()) debug << insert;
- foreach (const QDeclarativeChangeSet::Change &change, set.changes()) debug << change;
- return debug.nospace() << ")";
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeChangeSet::Remove &remove)
-{
- return (debug.nospace() << "Remove(" << remove.index << "," << remove.count << "," << remove.moveId << ")").space();
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeChangeSet::Insert &insert)
-{
- return (debug.nospace() << "Insert(" << insert.index << "," << insert.count << "," << insert.moveId << ")").space();
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeChangeSet::Change &change)
-{
- return (debug.nospace() << "Change(" << change.index << "," << change.count << ")").space();
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/quick/util/qdeclarativechangeset_p.h b/src/quick/util/qdeclarativechangeset_p.h
deleted file mode 100644
index 6e26337149..0000000000
--- a/src/quick/util/qdeclarativechangeset_p.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECHANGESET_P_H
-#define QDECLARATIVECHANGESET_P_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/qdebug.h>
-#include <QtCore/qvector.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_AUTOTEST_EXPORT QDeclarativeChangeSet
-{
-public:
- struct MoveKey
- {
- MoveKey() : moveId(-1), offset(0) {}
- MoveKey(int moveId, int offset) : moveId(moveId), offset(offset) {}
- int moveId;
- int offset;
- };
-
- struct Change
- {
- Change() : index(0), count(0), moveId(-1) {}
- Change(int index, int count) : index(index), count(count), moveId(-1) {}
- Change(int index, int count, int moveId) : index(index), count(count), moveId(moveId) {}
-
- int index;
- int count;
- int moveId;
-
- bool isMove() const { return moveId >= 0; }
-
- MoveKey moveKey(int index) const { return MoveKey(moveId, index - Change::index); }
-
- int start() const { return index; }
- int end() const { return index + count; }
- };
-
-
- struct Insert : public Change
- {
- Insert() {}
- Insert(int index, int count) : Change(index, count) {}
- Insert(int index, int count, int moveId) : Change(index, count, moveId) {}
- };
-
- struct Remove : public Change
- {
- Remove() {}
- Remove(int index, int count) : Change(index, count) {}
- Remove(int index, int count, int moveId) : Change(index, count, moveId) {}
- };
-
- QDeclarativeChangeSet();
- QDeclarativeChangeSet(const QDeclarativeChangeSet &changeSet);
- ~QDeclarativeChangeSet();
-
- QDeclarativeChangeSet &operator =(const QDeclarativeChangeSet &changeSet);
-
- const QVector<Remove> &removes() const { return m_removes; }
- const QVector<Insert> &inserts() const { return m_inserts; }
- const QVector<Change> &changes() const {return m_changes; }
-
- void insert(int index, int count);
- void remove(int index, int count);
- void move(int from, int to, int count);
- void change(int index, int count);
-
- void apply(const QDeclarativeChangeSet &changeSet);
- void apply(const QVector<Remove> &removals);
- void apply(const QVector<Insert> &insertions);
- void apply(const QVector<Change> &changes);
- void apply(
- const QVector<Remove> &removals,
- const QVector<Insert> &insertions,
- const QVector<Change> &changes = QVector<Change>());
-
- bool isEmpty() const { return m_removes.empty() && m_inserts.empty() && m_changes.empty(); }
-
- void clear()
- {
- m_removes.clear();
- m_inserts.clear();
- m_changes.clear();
- m_moveCounter = 0;
- m_difference = 0;
- }
-
- int moveCounter() const { return m_moveCounter; }
- int difference() const { return m_difference; }
-
-private:
- void applyRemovals(QVector<Remove> &removals, QVector<Insert> &insertions);
- void applyInsertions(QVector<Insert> &insertions);
- void applyChanges(QVector<Change> &changes);
-
- QVector<Remove> m_removes;
- QVector<Insert> m_inserts;
- QVector<Change> m_changes;
- int m_moveCounter;
- int m_difference;
-};
-
-inline uint qHash(const QDeclarativeChangeSet::MoveKey &key) { return qHash(qMakePair(key.moveId, key.offset)); }
-inline bool operator ==(const QDeclarativeChangeSet::MoveKey &l, const QDeclarativeChangeSet::MoveKey &r) {
- return l.moveId == r.moveId && l.offset == r.offset; }
-
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeChangeSet &change);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeChangeSet::Remove &remove);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeChangeSet::Insert &insert);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeChangeSet::Change &change);
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/quick/util/qdeclarativeconnections.cpp b/src/quick/util/qdeclarativeconnections.cpp
deleted file mode 100644
index c98c87abfa..0000000000
--- a/src/quick/util/qdeclarativeconnections.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeconnections_p.h"
-
-#include <private/qdeclarativeexpression_p.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativeboundsignal_p.h>
-#include <qdeclarativecontext.h>
-#include <private/qdeclarativecontext_p.h>
-#include <qdeclarativeinfo.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstringlist.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeConnectionsPrivate : public QObjectPrivate
-{
-public:
- QDeclarativeConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {}
-
- QList<QDeclarativeBoundSignal*> boundsignals;
- QObject *target;
-
- bool targetSet;
- bool ignoreUnknownSignals;
- bool componentcomplete;
-
- QByteArray data;
-};
-
-/*!
- \qmlclass Connections QDeclarativeConnections
- \inqmlmodule QtQuick 2
- \ingroup qml-utility-elements
- \brief A Connections element describes generalized connections to signals.
-
- A Connections object creates a connection to a QML signal.
-
- When connecting to signals in QML, the usual way is to create an
- "on<Signal>" handler that reacts when a signal is received, like this:
-
- \qml
- MouseArea {
- onClicked: { foo(parameters) }
- }
- \endqml
-
- However, it is not possible to connect to a signal in this way in some
- cases, such as when:
-
- \list
- \i Multiple connections to the same signal are required
- \i Creating connections outside the scope of the signal sender
- \i Connecting to targets not defined in QML
- \endlist
-
- When any of these are needed, the Connections element can be used instead.
-
- For example, the above code can be changed to use a Connections object,
- like this:
-
- \qml
- MouseArea {
- Connections {
- onClicked: foo(parameters)
- }
- }
- \endqml
-
- More generally, the Connections object can be a child of some object other than
- the sender of the signal:
-
- \qml
- MouseArea {
- id: area
- }
- // ...
- \endqml
- \qml
- Connections {
- target: area
- onClicked: foo(parameters)
- }
- \endqml
-
- \sa QtDeclarative
-*/
-QDeclarativeConnections::QDeclarativeConnections(QObject *parent) :
- QObject(*(new QDeclarativeConnectionsPrivate), parent)
-{
-}
-
-QDeclarativeConnections::~QDeclarativeConnections()
-{
-}
-
-/*!
- \qmlproperty Object QtQuick2::Connections::target
- This property holds the object that sends the signal.
-
- If this property is not set, the \c target defaults to the parent of the Connection.
-
- If set to null, no connection is made and any signal handlers are ignored
- until the target is not null.
-*/
-QObject *QDeclarativeConnections::target() const
-{
- Q_D(const QDeclarativeConnections);
- return d->targetSet ? d->target : parent();
-}
-
-void QDeclarativeConnections::setTarget(QObject *obj)
-{
- Q_D(QDeclarativeConnections);
- d->targetSet = true; // even if setting to 0, it is *set*
- if (d->target == obj)
- return;
- foreach (QDeclarativeBoundSignal *s, d->boundsignals) {
- // It is possible that target is being changed due to one of our signal
- // handlers -> use deleteLater().
- if (s->isEvaluating())
- s->deleteLater();
- else
- delete s;
- }
- d->boundsignals.clear();
- d->target = obj;
- connectSignals();
- emit targetChanged();
-}
-
-/*!
- \qmlproperty bool QtQuick2::Connections::ignoreUnknownSignals
-
- Normally, a connection to a non-existent signal produces runtime errors.
-
- If this property is set to \c true, such errors are ignored.
- This is useful if you intend to connect to different types of objects, handling
- a different set of signals for each object.
-*/
-bool QDeclarativeConnections::ignoreUnknownSignals() const
-{
- Q_D(const QDeclarativeConnections);
- return d->ignoreUnknownSignals;
-}
-
-void QDeclarativeConnections::setIgnoreUnknownSignals(bool ignore)
-{
- Q_D(QDeclarativeConnections);
- d->ignoreUnknownSignals = ignore;
-}
-
-
-
-QByteArray
-QDeclarativeConnectionsParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
-{
- QByteArray rv;
- QDataStream ds(&rv, QIODevice::WriteOnly);
-
- for(int ii = 0; ii < props.count(); ++ii)
- {
- QString propName = props.at(ii).name();
- int propLine = props.at(ii).location().line;
- int propColumn = props.at(ii).location().column;
-
- if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) {
- error(props.at(ii), QDeclarativeConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
- return QByteArray();
- }
-
- QList<QVariant> values = props.at(ii).assignedValues();
-
- for (int i = 0; i < values.count(); ++i) {
- const QVariant &value = values.at(i);
-
- if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
- error(props.at(ii), QDeclarativeConnections::tr("Connections: nested objects not allowed"));
- return QByteArray();
- } else if (value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
- error(props.at(ii), QDeclarativeConnections::tr("Connections: syntax error"));
- return QByteArray();
- } else {
- QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(value);
- if (v.isScript()) {
- ds << propName;
- ds << rewriteSignalHandler(v, propName);
- ds << propLine;
- ds << propColumn;
- } else {
- error(props.at(ii), QDeclarativeConnections::tr("Connections: script expected"));
- return QByteArray();
- }
- }
- }
- }
-
- return rv;
-}
-
-void QDeclarativeConnectionsParser::setCustomData(QObject *object,
- const QByteArray &data)
-{
- QDeclarativeConnectionsPrivate *p =
- static_cast<QDeclarativeConnectionsPrivate *>(QObjectPrivate::get(object));
- p->data = data;
-}
-
-
-void QDeclarativeConnections::connectSignals()
-{
- Q_D(QDeclarativeConnections);
- if (!d->componentcomplete || (d->targetSet && !target()))
- return;
-
- QDataStream ds(d->data);
- while (!ds.atEnd()) {
- QString propName;
- ds >> propName;
- QString script;
- ds >> script;
- int line;
- ds >> line;
- int column;
- ds >> column;
-
- QDeclarativeProperty prop(target(), propName);
- if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) {
- QDeclarativeBoundSignal *signal =
- new QDeclarativeBoundSignal(target(), prop.method(), this);
-
- QString location;
- QDeclarativeContextData *ctxtdata = 0;
- QDeclarativeData *ddata = QDeclarativeData::get(this);
- if (ddata) {
- ctxtdata = ddata->outerContext;
- if (ctxtdata && !ctxtdata->url.isEmpty())
- location = ddata->outerContext->urlString;
- }
-
- QDeclarativeExpression *expression = ctxtdata ?
- QDeclarativeExpressionPrivate::create(ctxtdata, 0, script, true, location, line, column) : 0;
- signal->setExpression(expression);
- d->boundsignals += signal;
- } else {
- if (!d->ignoreUnknownSignals)
- qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName);
- }
- }
-}
-
-void QDeclarativeConnections::classBegin()
-{
- Q_D(QDeclarativeConnections);
- d->componentcomplete=false;
-}
-
-void QDeclarativeConnections::componentComplete()
-{
- Q_D(QDeclarativeConnections);
- d->componentcomplete=true;
- connectSignals();
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativeconnections_p.h b/src/quick/util/qdeclarativeconnections_p.h
deleted file mode 100644
index fcfbcaf5d2..0000000000
--- a/src/quick/util/qdeclarativeconnections_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECONNECTIONS_H
-#define QDECLARATIVECONNECTIONS_H
-
-#include <qdeclarative.h>
-#include <private/qdeclarativecustomparser_p.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeBoundSignal;
-class QDeclarativeContext;
-class QDeclarativeConnectionsPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeConnections : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeConnections)
-
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals)
-
-public:
- QDeclarativeConnections(QObject *parent=0);
- ~QDeclarativeConnections();
-
- QObject *target() const;
- void setTarget(QObject *);
-
- bool ignoreUnknownSignals() const;
- void setIgnoreUnknownSignals(bool ignore);
-
-Q_SIGNALS:
- void targetChanged();
-
-private:
- void connectSignals();
- void classBegin();
- void componentComplete();
-};
-
-class QDeclarativeConnectionsParser : public QDeclarativeCustomParser
-{
-public:
- virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
- virtual void setCustomData(QObject *, const QByteArray &);
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeConnections)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/quick/util/qdeclarativefontloader.cpp b/src/quick/util/qdeclarativefontloader.cpp
deleted file mode 100644
index 441ecf60dd..0000000000
--- a/src/quick/util/qdeclarativefontloader.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativefontloader_p.h"
-
-#include <qdeclarativecontext.h>
-#include <qdeclarativeengine.h>
-
-#include <QStringList>
-#include <QUrl>
-#include <QDebug>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QFontDatabase>
-
-#include <private/qobject_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <qdeclarativeinfo.h>
-
-QT_BEGIN_NAMESPACE
-
-#define FONTLOADER_MAXIMUM_REDIRECT_RECURSION 16
-
-class QDeclarativeFontObject : public QObject
-{
-Q_OBJECT
-
-public:
- explicit QDeclarativeFontObject(int _id = -1);
-
- void download(const QUrl &url, QNetworkAccessManager *manager);
-
-Q_SIGNALS:
- void fontDownloaded(const QString&, QDeclarativeFontLoader::Status);
-
-private Q_SLOTS:
- void replyFinished();
-
-public:
- int id;
-
-private:
- QNetworkReply *reply;
- int redirectCount;
-
- Q_DISABLE_COPY(QDeclarativeFontObject)
-};
-
-QDeclarativeFontObject::QDeclarativeFontObject(int _id)
- : QObject(0), id(_id), reply(0), redirectCount(0) {}
-
-
-void QDeclarativeFontObject::download(const QUrl &url, QNetworkAccessManager *manager)
-{
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- reply = manager->get(req);
- QObject::connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
-}
-
-void QDeclarativeFontObject::replyFinished()
-{
- if (reply) {
- redirectCount++;
- if (redirectCount < FONTLOADER_MAXIMUM_REDIRECT_RECURSION) {
- QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- QUrl url = reply->url().resolved(redirect.toUrl());
- QNetworkAccessManager *manager = reply->manager();
- reply->deleteLater();
- reply = 0;
- download(url, manager);
- return;
- }
- }
- redirectCount = 0;
-
- if (!reply->error()) {
- id = QFontDatabase::addApplicationFontFromData(reply->readAll());
- if (id != -1)
- emit fontDownloaded(QFontDatabase::applicationFontFamilies(id).at(0), QDeclarativeFontLoader::Ready);
- else
- emit fontDownloaded(QString(), QDeclarativeFontLoader::Error);
- } else {
- emit fontDownloaded(QString(), QDeclarativeFontLoader::Error);
- }
- reply->deleteLater();
- reply = 0;
- }
-}
-
-
-class QDeclarativeFontLoaderPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeFontLoader)
-
-public:
- QDeclarativeFontLoaderPrivate() : status(QDeclarativeFontLoader::Null) {}
-
- QUrl url;
- QString name;
- QDeclarativeFontLoader::Status status;
- static QHash<QUrl, QDeclarativeFontObject*> fonts;
-};
-
-QHash<QUrl, QDeclarativeFontObject*> QDeclarativeFontLoaderPrivate::fonts;
-
-/*!
- \qmlclass FontLoader QDeclarativeFontLoader
- \inqmlmodule QtQuick 2
- \ingroup qml-utility-elements
- \brief The FontLoader element allows fonts to be loaded by name or URL.
-
- The FontLoader element is used to load fonts by name or URL.
-
- The \l status indicates when the font has been loaded, which is useful
- for fonts loaded from remote sources.
-
- For example:
- \qml
- import QtQuick 2.0
-
- Column {
- FontLoader { id: fixedFont; name: "Courier" }
- FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
-
- Text { text: "Fixed-size font"; font.family: fixedFont.name }
- Text { text: "Fancy font"; font.family: webFont.name }
- }
- \endqml
-
- \sa {declarative/text/fonts}{Fonts example}
-*/
-QDeclarativeFontLoader::QDeclarativeFontLoader(QObject *parent)
- : QObject(*(new QDeclarativeFontLoaderPrivate), parent)
-{
-}
-
-QDeclarativeFontLoader::~QDeclarativeFontLoader()
-{
-}
-
-/*!
- \qmlproperty url QtQuick2::FontLoader::source
- The url of the font to load.
-*/
-QUrl QDeclarativeFontLoader::source() const
-{
- Q_D(const QDeclarativeFontLoader);
- return d->url;
-}
-
-void QDeclarativeFontLoader::setSource(const QUrl &url)
-{
- Q_D(QDeclarativeFontLoader);
- if (url == d->url)
- return;
- d->url = url;
- emit sourceChanged();
-
- QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
- if (!localFile.isEmpty()) {
- if (!d->fonts.contains(d->url)) {
- int id = QFontDatabase::addApplicationFont(localFile);
- if (id != -1) {
- updateFontInfo(QFontDatabase::applicationFontFamilies(id).at(0), Ready);
- QDeclarativeFontObject *fo = new QDeclarativeFontObject(id);
- d->fonts[d->url] = fo;
- } else {
- updateFontInfo(QString(), Error);
- }
- } else {
- updateFontInfo(QFontDatabase::applicationFontFamilies(d->fonts[d->url]->id).at(0), Ready);
- }
- } else {
- if (!d->fonts.contains(d->url)) {
- QDeclarativeFontObject *fo = new QDeclarativeFontObject;
- d->fonts[d->url] = fo;
- fo->download(d->url, qmlEngine(this)->networkAccessManager());
- d->status = Loading;
- emit statusChanged();
- QObject::connect(fo, SIGNAL(fontDownloaded(QString,QDeclarativeFontLoader::Status)),
- this, SLOT(updateFontInfo(QString,QDeclarativeFontLoader::Status)));
- } else {
- QDeclarativeFontObject *fo = d->fonts[d->url];
- if (fo->id == -1) {
- d->status = Loading;
- emit statusChanged();
- QObject::connect(fo, SIGNAL(fontDownloaded(QString,QDeclarativeFontLoader::Status)),
- this, SLOT(updateFontInfo(QString,QDeclarativeFontLoader::Status)));
- }
- else
- updateFontInfo(QFontDatabase::applicationFontFamilies(fo->id).at(0), Ready);
- }
- }
-}
-
-void QDeclarativeFontLoader::updateFontInfo(const QString& name, QDeclarativeFontLoader::Status status)
-{
- Q_D(QDeclarativeFontLoader);
-
- if (name != d->name) {
- d->name = name;
- emit nameChanged();
- }
- if (status != d->status) {
- if (status == Error)
- qmlInfo(this) << "Cannot load font: \"" << d->url.toString() << "\"";
- d->status = status;
- emit statusChanged();
- }
-}
-
-/*!
- \qmlproperty string QtQuick2::FontLoader::name
-
- This property holds the name of the font family.
- It is set automatically when a font is loaded using the \c url property.
-
- Use this to set the \c font.family property of a \c Text item.
-
- Example:
- \qml
- Item {
- width: 200; height: 50
-
- FontLoader {
- id: webFont
- source: "http://www.mysite.com/myfont.ttf"
- }
- Text {
- text: "Fancy font"
- font.family: webFont.name
- }
- }
- \endqml
-*/
-QString QDeclarativeFontLoader::name() const
-{
- Q_D(const QDeclarativeFontLoader);
- return d->name;
-}
-
-void QDeclarativeFontLoader::setName(const QString &name)
-{
- Q_D(QDeclarativeFontLoader);
- if (d->name == name)
- return;
- d->name = name;
- emit nameChanged();
- d->status = Ready;
- emit statusChanged();
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::FontLoader::status
-
- This property holds the status of font loading. It can be one of:
- \list
- \o FontLoader.Null - no font has been set
- \o FontLoader.Ready - the font has been loaded
- \o FontLoader.Loading - the font is currently being loaded
- \o FontLoader.Error - an error occurred while loading the font
- \endlist
-
- Use this status to provide an update or respond to the status change in some way.
- For example, you could:
-
- \list
- \o Trigger a state change:
- \qml
- State { name: 'loaded'; when: loader.status == FontLoader.Ready }
- \endqml
-
- \o Implement an \c onStatusChanged signal handler:
- \qml
- FontLoader {
- id: loader
- onStatusChanged: if (loader.status == FontLoader.Ready) console.log('Loaded')
- }
- \endqml
-
- \o Bind to the status value:
- \qml
- Text { text: loader.status == FontLoader.Ready ? 'Loaded' : 'Not loaded' }
- \endqml
- \endlist
-*/
-QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const
-{
- Q_D(const QDeclarativeFontLoader);
- return d->status;
-}
-
-QT_END_NAMESPACE
-
-#include <qdeclarativefontloader.moc>
diff --git a/src/quick/util/qdeclarativefontloader_p.h b/src/quick/util/qdeclarativefontloader_p.h
deleted file mode 100644
index 3cd75e1a46..0000000000
--- a/src/quick/util/qdeclarativefontloader_p.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEFONTLOADER_H
-#define QDECLARATIVEFONTLOADER_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeFontLoaderPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeFontLoader : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeFontLoader)
- Q_ENUMS(Status)
-
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
-
-public:
- enum Status { Null = 0, Ready, Loading, Error };
-
- QDeclarativeFontLoader(QObject *parent = 0);
- ~QDeclarativeFontLoader();
-
- QUrl source() const;
- void setSource(const QUrl &url);
-
- QString name() const;
- void setName(const QString &name);
-
- Status status() const;
-
-private Q_SLOTS:
- void updateFontInfo(const QString&, QDeclarativeFontLoader::Status);
-
-Q_SIGNALS:
- void sourceChanged();
- void nameChanged();
- void statusChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeFontLoader)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEFONTLOADER_H
-
diff --git a/src/quick/util/qdeclarativelistaccessor.cpp b/src/quick/util/qdeclarativelistaccessor.cpp
deleted file mode 100644
index ae60640328..0000000000
--- a/src/quick/util/qdeclarativelistaccessor.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativelistaccessor_p.h"
-
-#include <private/qdeclarativemetatype_p.h>
-
-#include <QtCore/qstringlist.h>
-#include <QtCore/qdebug.h>
-
-// ### Remove me
-#include <private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QDeclarativeListAccessor::QDeclarativeListAccessor()
-: m_type(Invalid)
-{
-}
-
-QDeclarativeListAccessor::~QDeclarativeListAccessor()
-{
-}
-
-QVariant QDeclarativeListAccessor::list() const
-{
- return d;
-}
-
-void QDeclarativeListAccessor::setList(const QVariant &v, QDeclarativeEngine *engine)
-{
- d = v;
-
- QDeclarativeEnginePrivate *enginePrivate = engine?QDeclarativeEnginePrivate::get(engine):0;
-
- if (!d.isValid()) {
- m_type = Invalid;
- } else if (d.userType() == QVariant::StringList) {
- m_type = StringList;
- } else if (d.userType() == QMetaType::QVariantList) {
- m_type = VariantList;
- } else if (d.canConvert(QVariant::Int)) {
- m_type = Integer;
- } else if ((!enginePrivate && QDeclarativeMetaType::isQObject(d.userType())) ||
- (enginePrivate && enginePrivate->isQObject(d.userType()))) {
- QObject *data = enginePrivate?enginePrivate->toQObject(v):QDeclarativeMetaType::toQObject(v);
- d = QVariant::fromValue(data);
- m_type = Instance;
- } else if (d.userType() == qMetaTypeId<QDeclarativeListReference>()) {
- m_type = ListProperty;
- } else {
- m_type = Instance;
- }
-}
-
-int QDeclarativeListAccessor::count() const
-{
- switch(m_type) {
- case StringList:
- return qvariant_cast<QStringList>(d).count();
- case VariantList:
- return qvariant_cast<QVariantList>(d).count();
- case ListProperty:
- return ((QDeclarativeListReference *)d.constData())->count();
- case Instance:
- return 1;
- case Integer:
- return d.toInt();
- default:
- case Invalid:
- return 0;
- }
-}
-
-QVariant QDeclarativeListAccessor::at(int idx) const
-{
- Q_ASSERT(idx >= 0 && idx < count());
- switch(m_type) {
- case StringList:
- return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx));
- case VariantList:
- return qvariant_cast<QVariantList>(d).at(idx);
- case ListProperty:
- return QVariant::fromValue(((QDeclarativeListReference *)d.constData())->at(idx));
- case Instance:
- return d;
- case Integer:
- return QVariant(idx);
- default:
- case Invalid:
- return QVariant();
- }
-}
-
-bool QDeclarativeListAccessor::isValid() const
-{
- return m_type != Invalid;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativelistaccessor_p.h b/src/quick/util/qdeclarativelistaccessor_p.h
deleted file mode 100644
index 6fc589dec4..0000000000
--- a/src/quick/util/qdeclarativelistaccessor_p.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTACCESSOR_H
-#define QDECLARATIVELISTACCESSOR_H
-
-#include <QtCore/QVariant>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-class Q_AUTOTEST_EXPORT QDeclarativeListAccessor
-{
-public:
- QDeclarativeListAccessor();
- ~QDeclarativeListAccessor();
-
- QVariant list() const;
- void setList(const QVariant &, QDeclarativeEngine * = 0);
-
- bool isValid() const;
-
- int count() const;
- QVariant at(int) const;
-
- enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer };
- Type type() const { return m_type; }
-
-private:
- Type m_type;
- QVariant d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVELISTACCESSOR_H
diff --git a/src/quick/util/qdeclarativelistcompositor.cpp b/src/quick/util/qdeclarativelistcompositor.cpp
deleted file mode 100644
index 6011d6bc5d..0000000000
--- a/src/quick/util/qdeclarativelistcompositor.cpp
+++ /dev/null
@@ -1,1214 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativelistcompositor_p.h"
-
-#include <QtCore/qvarlengtharray.h>
-
-//#define QT_DECLARATIVE_VERIFY_MINIMAL
-//#define QT_DECLARATIVE_VERIFY_INTEGRITY
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_DECLARATIVE_VERIFY_MINIMAL
-#define QT_DECLARATIVE_VERIFY_INTEGRITY
-static bool qt_verifyMinimal(
- const QDeclarativeListCompositor::iterator &begin,
- const QDeclarativeListCompositor::iterator &end)
-{
- bool minimal = true;
- int index = 0;
-
- for (const QDeclarativeListCompositor::Range *range = begin->next; range != *end; range = range->next, ++index) {
- if (range->previous->list == range->list
- && range->previous->flags == (range->flags & ~QDeclarativeListCompositor::AppendFlag)
- && range->previous->end() == range->index) {
- qWarning() << index << "Consecutive ranges";
- qWarning() << *range->previous;
- qWarning() << *range;
- minimal = false;
- }
- }
-
- return minimal;
-}
-
-#endif
-
-#ifdef QT_DECLARATIVE_VERIFY_INTEGRITY
-static bool qt_printInfo(const QDeclarativeListCompositor &compositor)
-{
- qWarning() << compositor;
- return true;
-}
-
-static bool qt_verifyIntegrity(
- const QDeclarativeListCompositor::iterator &begin,
- const QDeclarativeListCompositor::iterator &end,
- const QDeclarativeListCompositor::iterator &cachedIt)
-{
- bool valid = true;
-
- int index = 0;
- QDeclarativeListCompositor::iterator it;
- for (it = begin; *it != *end; *it = it->next) {
- if (it->count == 0 && !it->append()) {
- qWarning() << index << "Empty non-append range";
- valid = false;
- }
- if (it->count < 0) {
- qWarning() << index << "Negative count";
- valid = false;
- }
- if (it->list && it->flags != QDeclarativeListCompositor::CacheFlag && it->index < 0) {
- qWarning() << index <<"Negative index";
- valid = false;
- }
- if (it->previous->next != it.range) {
- qWarning() << index << "broken list: it->previous->next != it.range";
- valid = false;
- }
- if (it->next->previous != it.range) {
- qWarning() << index << "broken list: it->next->previous != it.range";
- valid = false;
- }
- if (*it == *cachedIt) {
- for (int i = 0; i < end.groupCount; ++i) {
- int groupIndex = it.index[i];
- if (cachedIt->flags & (1 << i))
- groupIndex += cachedIt.offset;
- if (groupIndex != cachedIt.index[i]) {
- qWarning() << index
- << "invalid cached index"
- << QDeclarativeListCompositor::Group(i)
- << "Expected:"
- << groupIndex
- << "Actual"
- << cachedIt.index[i]
- << cachedIt;
- valid = false;
- }
- }
- }
- it.incrementIndexes(it->count);
- ++index;
- }
-
- for (int i = 0; i < end.groupCount; ++i) {
- if (end.index[i] != it.index[i]) {
- qWarning() << "Group" << i << "count invalid. Expected:" << end.index[i] << "Actual:" << it.index[i];
- valid = false;
- }
- }
- return valid;
-}
-#endif
-
-#if defined(QT_DECLARATIVE_VERIFY_MINIMAL)
-# define QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR Q_ASSERT(!(!(qt_verifyIntegrity(iterator(m_ranges.next, 0, Default, m_groupCount), m_end, m_cacheIt) \
- && qt_verifyMinimal(iterator(m_ranges.next, 0, Default, m_groupCount), m_end)) \
- && qt_printInfo(*this)));
-#elif defined(QT_DECLARATIVE_VERIFY_INTEGRITY)
-# define QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR Q_ASSERT(!(!qt_verifyIntegrity(iterator(m_ranges.next, 0, Default, m_groupCount), m_end, m_cacheIt) \
- && qt_printInfo(*this)));
-#else
-# define QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
-#endif
-
-//#define QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(args) qDebug() << m_end.index[1] << m_end.index[0] << Q_FUNC_INFO args;
-#define QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(args)
-
-QDeclarativeListCompositor::iterator &QDeclarativeListCompositor::iterator::operator +=(int difference)
-{
- Q_ASSERT(difference >= 0);
- while (!(range->flags & groupFlag)) {
- incrementIndexes(range->count - offset);
- offset = 0;
- range = range->next;
- }
- decrementIndexes(offset);
- offset += difference;
- while (offset >= range->count || !(range->flags & groupFlag)) {
- if (range->flags & groupFlag)
- offset -= range->count;
- incrementIndexes(range->count);
- range = range->next;
- }
- incrementIndexes(offset);
- return *this;
-}
-
-QDeclarativeListCompositor::iterator &QDeclarativeListCompositor::iterator::operator -=(int difference)
-{
- Q_ASSERT(difference >= 0);
- while (!(range->flags & groupFlag)) {
- decrementIndexes(offset);
- range = range->previous;
- offset = range->count;
- }
- decrementIndexes(offset);
- offset -= difference;
- while (offset < 0) {
- range = range->previous;
- if (range->flags & groupFlag)
- offset += range->count;
- decrementIndexes(range->count);
- }
- incrementIndexes(offset);
- return *this;
-}
-
-QDeclarativeListCompositor::insert_iterator &QDeclarativeListCompositor::insert_iterator::operator +=(int difference)
-{
- Q_ASSERT(difference >= 0);
- while (!(range->flags & groupFlag)) {
- incrementIndexes(range->count - offset);
- offset = 0;
- range = range->next;
- }
- decrementIndexes(offset);
- offset += difference;
- while (offset > range->count
- || (offset == range->count && !range->append() && offset > 0)
- || (!(range->flags & groupFlag) && offset > 0)) {
- Q_ASSERT(range->flags);
- if (range->flags & groupFlag)
- offset -= range->count;
- incrementIndexes(range->count);
- range = range->next;
- }
- incrementIndexes(offset);
- return *this;
-}
-
-QDeclarativeListCompositor::insert_iterator &QDeclarativeListCompositor::insert_iterator::operator -=(int difference)
-{
- Q_ASSERT(difference >= 0);
- while (!(range->flags & groupFlag) && range->previous->flags) {
- decrementIndexes(offset);
- range = range->previous;
- offset = (range->flags & (GroupMask | CacheFlag)) ? range->count : 0;
- }
- decrementIndexes(offset);
- offset -= difference;
- while (offset < 0) {
- range = range->previous;
- if (range->flags & groupFlag)
- offset += range->count;
- decrementIndexes(range->count);
- }
- incrementIndexes(offset);
- for (Range *previous = range->previous; offset == 0 && previous->prepend(); previous = previous->previous) {
- if (previous->append() && previous->inGroup()) {
- offset = previous->count;
- range = previous;
- } else if (!previous->inGroup()) {
- break;
- }
- }
-
- return *this;
-}
-
-QDeclarativeListCompositor::QDeclarativeListCompositor()
- : m_end(m_ranges.next, 0, Default, 2)
- , m_cacheIt(m_end)
- , m_groupCount(2)
- , m_defaultFlags(PrependFlag | DefaultFlag)
- , m_removeFlags(AppendFlag | PrependFlag | GroupMask)
-{
-}
-
-QDeclarativeListCompositor::~QDeclarativeListCompositor()
-{
- for (Range *next, *range = m_ranges.next; range != &m_ranges; range = next) {
- next = range->next;
- delete range;
- }
-}
-
-inline QDeclarativeListCompositor::Range *QDeclarativeListCompositor::insert(
- Range *before, void *list, int index, int count, uint flags)
-{
- return new Range(before, list, index, count, flags);
-}
-
-inline QDeclarativeListCompositor::Range *QDeclarativeListCompositor::erase(
- Range *range)
-{
- Range *next = range->next;
- next->previous = range->previous;
- next->previous->next = range->next;
- delete range;
- return next;
-}
-
-void QDeclarativeListCompositor::setGroupCount(int count)
-{
- m_groupCount = count;
- m_end = iterator(&m_ranges, 0, Default, m_groupCount);
- m_cacheIt = m_end;
-}
-
-int QDeclarativeListCompositor::count(Group group) const
-{
- return m_end.index[group];
-}
-
-QDeclarativeListCompositor::iterator QDeclarativeListCompositor::find(Group group, int index)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< group << index)
- Q_ASSERT(index >=0 && index < count(group));
- if (m_cacheIt == m_end) {
- m_cacheIt = iterator(m_ranges.next, 0, group, m_groupCount);
- m_cacheIt += index;
- } else {
- const int offset = index - m_cacheIt.index[group];
- m_cacheIt.setGroup(group);
- if (offset > 0) {
- m_cacheIt += offset;
- } else if (offset < 0) {
- m_cacheIt -= -offset;
- } else if (offset == 0) {
- m_cacheIt -= 0;
- m_cacheIt += 0;
- }
- }
- Q_ASSERT(m_cacheIt.index[group] == index);
- Q_ASSERT(m_cacheIt->inGroup(group));
- QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
- return m_cacheIt;
-}
-
-QDeclarativeListCompositor::iterator QDeclarativeListCompositor::find(Group group, int index) const
-{
- return const_cast<QDeclarativeListCompositor *>(this)->find(group, index);
-}
-
-QDeclarativeListCompositor::insert_iterator QDeclarativeListCompositor::findInsertPosition(Group group, int index)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< group << index)
- Q_ASSERT(index >=0 && index <= count(group));
- insert_iterator it;
- if (m_cacheIt == m_end) {
- it = iterator(m_ranges.next, 0, group, m_groupCount);
- it += index;
- } else {
- const int offset = index - m_cacheIt.index[group];
- it = m_cacheIt;
- it.setGroup(group);
- if (offset > 0) {
- it += offset;
- } else if (offset < 0) {
- it -= -offset;
- } else if (offset == 0) {
- it -= 0;
- it += 0;
- }
- }
- Q_ASSERT(it.index[group] == index);
- return it;
-}
-
-QDeclarativeListCompositor::iterator QDeclarativeListCompositor::begin(Group group)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< group)
- m_cacheIt = iterator(m_ranges.next, 0, group, m_groupCount);
- m_cacheIt += 0;
- return m_cacheIt;
-}
-
-void QDeclarativeListCompositor::append(
- void *list, int index, int count, uint flags, QVector<Insert> *inserts)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << index << count << flags)
- insert(m_end, list, index, count, flags, inserts);
-}
-
-void QDeclarativeListCompositor::insert(
- Group group, int before, void *list, int index, int count, uint flags, QVector<Insert> *inserts)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< group << before << list << index << count << flags)
- insert(findInsertPosition(group, before), list, index, count, flags, inserts);
-}
-
-QDeclarativeListCompositor::iterator QDeclarativeListCompositor::insert(
- iterator before, void *list, int index, int count, uint flags, QVector<Insert> *inserts)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< before << list << index << count << flags)
- if (inserts) {
- inserts->append(Insert(before, count, flags & GroupMask));
- }
- if (before.offset > 0) {
- *before = insert(
- *before, before->list, before->index, before.offset, before->flags & ~AppendFlag)->next;
- before->index += before.offset;
- before->count -= before.offset;
- before.offset = 0;
- }
-
- if (!(flags & AppendFlag) && *before != m_ranges.next
- && before->previous->list == list
- && before->previous->flags == flags
- && (!list || before->previous->end() == index)) {
- before->previous->count += count;
- before.incrementIndexes(count, flags);
- } else {
- *before = insert(*before, list, index, count, flags);
- before.offset = 0;
- }
-
- if (!(flags & AppendFlag) && before->next != &m_ranges
- && before->list == before->next->list
- && before->flags == before->next->flags
- && (!list || before->end() == before->next->index)) {
- before->next->index = before->index;
- before->next->count += before->count;
- *before = erase(*before);
- }
-
- m_end.incrementIndexes(count, flags);
- m_cacheIt = before;
- QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
- return before;
-}
-
-void QDeclarativeListCompositor::setFlags(
- Group fromGroup, int from, int count, Group group, int flags, QVector<Insert> *inserts)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< group << index << count << flags)
- setFlags(find(fromGroup, from), count, group, flags, inserts);
-}
-
-void QDeclarativeListCompositor::setFlags(
- iterator from, int count, Group group, uint flags, QVector<Insert> *inserts)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< from << count << flags)
- if (!flags || !count)
- return;
-
- if (from != group) {
- from.incrementIndexes(from->count - from.offset);
- from.offset = 0;
- *from = from->next;
- } else if (from.offset > 0) {
- *from = insert(*from, from->list, from->index, from.offset, from->flags & ~AppendFlag)->next;
- from->index += from.offset;
- from->count -= from.offset;
- from.offset = 0;
- }
-
- for (; count > 0; *from = from->next) {
- if (from != from.group) {
- from.incrementIndexes(from->count);
- continue;
- }
- const int difference = qMin(count, from->count);
- count -= difference;
-
- const uint insertFlags = ~from->flags & flags;
- const uint setFlags = (from->flags | flags) & ~AppendFlag;
- if (insertFlags && inserts)
- inserts->append(Insert(from, difference, insertFlags | (from->flags & CacheFlag)));
- m_end.incrementIndexes(difference, insertFlags);
- from.incrementIndexes(difference, setFlags);
-
- if (from->previous != &m_ranges
- && from->previous->list == from->list
- && (!from->list || from->previous->end() == from->index)
- && from->previous->flags == setFlags) {
- from->previous->count += difference;
- from->index += difference;
- from->count -= difference;
- if (from->count == 0) {
- if (from->append())
- from->previous->flags |= AppendFlag;
- *from = erase(*from)->previous;
- continue;
- } else {
- break;
- }
- } else if (!insertFlags) {
- from.incrementIndexes(from->count - difference);
- continue;
- } else if (difference < from->count) {
- *from = insert(*from, from->list, from->index, difference, setFlags)->next;
- from->index += difference;
- from->count -= difference;
- } else {
- from->flags |= flags;
- continue;
- }
- from.incrementIndexes(from->count);
- }
-
- if (from->previous != &m_ranges
- && from->previous->list == from->list
- && (!from->list || from->previous->end() == from->index)
- && from->previous->flags == (from->flags & ~AppendFlag)) {
- from.offset = from->previous->count;
- from->previous->count += from->count;
- from->previous->flags = from->flags;
- *from = erase(*from)->previous;
- }
- m_cacheIt = from;
- QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
-}
-
-void QDeclarativeListCompositor::clearFlags(
- Group fromGroup, int from, int count, Group group, uint flags, QVector<Remove> *removes)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< group << index << count << flags)
- clearFlags(find(fromGroup, from), count, group, flags, removes);
-}
-
-void QDeclarativeListCompositor::clearFlags(
- iterator from, int count, Group group, uint flags, QVector<Remove> *removes)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< from << count << flags)
- if (!flags || !count)
- return;
-
- const bool clearCache = flags & CacheFlag;
-
- if (from != group) {
- from.incrementIndexes(from->count - from.offset);
- from.offset = 0;
- *from = from->next;
- } else if (from.offset > 0) {
- *from = insert(*from, from->list, from->index, from.offset, from->flags & ~AppendFlag)->next;
- from->index += from.offset;
- from->count -= from.offset;
- from.offset = 0;
- }
-
- for (; count > 0; *from = from->next) {
- if (from != group) {
- from.incrementIndexes(from->count);
- continue;
- }
- const int difference = qMin(count, from->count);
- count -= difference;
-
- const uint removeFlags = from->flags & flags & ~(AppendFlag | PrependFlag);
- const uint clearedFlags = from->flags & ~(flags | AppendFlag | UnresolvedFlag);
- if (removeFlags && removes) {
- const int maskedFlags = clearCache
- ? (removeFlags & ~CacheFlag)
- : (removeFlags | (from->flags & CacheFlag));
- if (maskedFlags)
- removes->append(Remove(from, difference, maskedFlags));
- }
- m_end.decrementIndexes(difference, removeFlags);
- from.incrementIndexes(difference, clearedFlags);
-
- if (from->previous != &m_ranges
- && from->previous->list == from->list
- && (!from->list || clearedFlags == CacheFlag || from->previous->end() == from->index)
- && from->previous->flags == clearedFlags) {
- from->previous->count += difference;
- from->index += difference;
- from->count -= difference;
- if (from->count == 0) {
- if (from->append())
- from->previous->flags |= AppendFlag;
- *from = erase(*from)->previous;
- } else {
- from.incrementIndexes(from->count);
- }
- } else if (difference < from->count) {
- if (clearedFlags)
- *from = insert(*from, from->list, from->index, difference, clearedFlags)->next;
- from->index += difference;
- from->count -= difference;
- from.incrementIndexes(from->count);
- } else if (clearedFlags) {
- from->flags &= ~flags;
- } else {
- *from = erase(*from)->previous;
- }
- }
-
- if (*from != &m_ranges && from->previous != &m_ranges
- && from->previous->list == from->list
- && (!from->list || from->previous->end() == from->index)
- && from->previous->flags == (from->flags & ~AppendFlag)) {
- from.offset = from->previous->count;
- from->previous->count += from->count;
- from->previous->flags = from->flags;
- *from = erase(*from)->previous;
- }
- m_cacheIt = from;
- QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
-}
-
-void QDeclarativeListCompositor::removeList(void *list, QVector<Remove> *removes, bool destroyed)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << destroyed)
- for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
- if (it->list == list) {
- const int flags = it->flags & (GroupMask | CacheFlag);
- if (flags) {
- removes->append(Remove(it, it->count, flags));
- m_end.decrementIndexes(it->count, flags);
- }
- if (destroyed)
- it->list = 0;
- if (it->inCache()) {
- it->flags = CacheFlag;
- it.cacheIndex += it->count;
- } else {
- *it = erase(*it)->previous;
- }
- } else {
- it.incrementIndexes(it->count);
- }
- }
- m_cacheIt = m_end;
- QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
-}
-
-bool QDeclarativeListCompositor::verifyMoveTo(
- Group fromGroup, int from, Group toGroup, int to, int count, Group group) const
-{
- if (group != toGroup) {
- // determine how many items from the destination group intersect with the source group.
- iterator fromIt = find(fromGroup, from);
-
- int intersectingCount = 0;
-
- for (; count > 0; *fromIt = fromIt->next) {
- if (*fromIt == &m_ranges)
- return false;
- if (!fromIt->inGroup(group))
- continue;
- if (fromIt->inGroup(toGroup))
- intersectingCount += qMin(count, fromIt->count - fromIt.offset);
- count -= fromIt->count - fromIt.offset;
- fromIt.offset = 0;
- }
- count = intersectingCount;
- }
-
- return to >= 0 && to + count <= m_end.index[toGroup];
-}
-
-void QDeclarativeListCompositor::move(
- Group fromGroup,
- int from,
- Group toGroup,
- int to,
- int count,
- Group group,
- QVector<Remove> *removes,
- QVector<Insert> *inserts)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< fromGroup << from << toGroup << to << count)
- Q_ASSERT(count != 0);
- Q_ASSERT(from >=0 && from + count <= m_end.index[toGroup]);
- Q_ASSERT(verifyMoveTo(fromGroup, from, toGroup, to, count, group));
-
- iterator fromIt = find(fromGroup, from);
- if (fromIt != group) {
- fromIt.incrementIndexes(fromIt->count - fromIt.offset);
- fromIt.offset = 0;
- *fromIt = fromIt->next;
- } else if (fromIt.offset > 0) {
- *fromIt = insert(
- *fromIt, fromIt->list, fromIt->index, fromIt.offset, fromIt->flags & ~AppendFlag)->next;
- fromIt->index += fromIt.offset;
- fromIt->count -= fromIt.offset;
- fromIt.offset = 0;
- }
-
- Range movedFlags;
- for (int moveId = 0; count > 0;) {
- if (fromIt != group) {
- fromIt.incrementIndexes(fromIt->count);
- *fromIt = fromIt->next;
- continue;
- }
- int difference = qMin(count, fromIt->count);
-
- new Range(
- &movedFlags,
- fromIt->list,
- fromIt->index,
- difference,
- fromIt->flags & ~(PrependFlag | AppendFlag));
- if (removes)
- removes->append(Remove(fromIt, difference, fromIt->flags, moveId++));
- count -= difference;
- fromIt->count -= difference;
-
- int removeIndex = fromIt->index;
- if (fromIt->prepend()
- && fromIt->previous != &m_ranges
- && fromIt->previous->flags == PrependFlag
- && fromIt->previous->list == fromIt->list
- && fromIt->previous->end() == fromIt->index) {
- fromIt->previous->count += difference;
- } else if (fromIt->prepend()) {
- *fromIt = insert(*fromIt, fromIt->list, removeIndex, difference, PrependFlag)->next;
- }
- fromIt->index += difference;
-
- if (fromIt->count == 0) {
- if (fromIt->append())
- fromIt->previous->flags |= AppendFlag;
- *fromIt = erase(*fromIt);
-
- if (*fromIt != m_ranges.next && fromIt->flags == PrependFlag
- && fromIt->previous != &m_ranges
- && fromIt->previous->flags == PrependFlag
- && fromIt->previous->list == fromIt->list
- && fromIt->previous->end() == fromIt->index) {
- fromIt.incrementIndexes(fromIt->count);
- fromIt->previous->count += fromIt->count;
- *fromIt = erase(*fromIt);
- }
- } else if (count > 0) {
- *fromIt = fromIt->next;
- }
- }
-
- if (*fromIt != m_ranges.next
- && *fromIt != &m_ranges
- && fromIt->previous->list == fromIt->list
- && (!fromIt->list || fromIt->previous->end() == fromIt->index)
- && fromIt->previous->flags == (fromIt->flags & ~AppendFlag)) {
- if (fromIt == fromIt.group)
- fromIt.offset = fromIt->previous->count;
- fromIt.offset = fromIt->previous->count;
- fromIt->previous->count += fromIt->count;
- fromIt->previous->flags = fromIt->flags;
- *fromIt = erase(*fromIt)->previous;
- }
-
- insert_iterator toIt = fromIt;
- toIt.setGroup(toGroup);
- const int difference = to - toIt.index[toGroup];
- if (difference > 0)
- toIt += difference;
- else
- toIt -= -difference;
-
- if (toIt.offset > 0) {
- *toIt = insert(*toIt, toIt->list, toIt->index, toIt.offset, toIt->flags & ~AppendFlag)->next;
- toIt->index += toIt.offset;
- toIt->count -= toIt.offset;
- toIt.offset = 0;
- }
-
- for (Range *range = movedFlags.previous; range != &movedFlags; range = range->previous) {
- if (*toIt != &m_ranges
- && range->list == toIt->list
- && (!range->list || range->end() == toIt->index)
- && range->flags == (toIt->flags & ~AppendFlag)) {
- toIt->index -= range->count;
- toIt->count += range->count;
- } else {
- *toIt = insert(*toIt, range->list, range->index, range->count, range->flags);
- }
- }
-
- if (*toIt != m_ranges.next
- && toIt->previous->list == toIt->list
- && (!toIt->list || (toIt->previous->end() == toIt->index && toIt->previous->flags == (toIt->flags & ~AppendFlag)))) {
- toIt.offset = toIt->previous->count;
- toIt->previous->count += toIt->count;
- toIt->previous->flags = toIt->flags;
- *toIt = erase(*toIt)->previous;
- }
- Insert insert(toIt, 0, 0, 0);
- for (Range *next, *range = movedFlags.next; range != &movedFlags; range = next) {
- insert.count = range->count;
- insert.flags = range->flags;
- if (inserts)
- inserts->append(insert);
- for (int i = 0; i < m_groupCount; ++i) {
- if (insert.inGroup(i))
- insert.index[i] += range->count;
- }
- ++insert.moveId;
- next = range->next;
- delete range;
- }
-
- m_cacheIt = toIt;
- QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
-}
-
-void QDeclarativeListCompositor::clear()
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR( )
- for (Range *range = m_ranges.next; range != &m_ranges; range = erase(range)) {}
- m_end = iterator(m_ranges.next, 0, Default, m_groupCount);
- m_cacheIt = m_end;
-}
-
-void QDeclarativeListCompositor::listItemsInserted(
- QVector<Insert> *translatedInsertions,
- void *list,
- const QVector<QDeclarativeChangeSet::Insert> &insertions,
- const QVector<MovedFlags> *movedFlags)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << insertions)
- for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
- if (it->list != list || it->flags == CacheFlag) {
- it.incrementIndexes(it->count);
- continue;
- } else if (it->flags & MovedFlag) {
- it->flags &= ~MovedFlag;
- it.incrementIndexes(it->count);
- continue;
- }
- foreach (const QDeclarativeChangeSet::Insert &insertion, insertions) {
- int offset = insertion.index - it->index;
- if ((offset > 0 && offset < it->count)
- || (offset == 0 && it->prepend())
- || (offset == it->count && it->append())) {
- if (it->prepend()) {
- uint flags = m_defaultFlags;
- if (insertion.isMove()) {
- for (QVector<MovedFlags>::const_iterator move = movedFlags->begin();
- move != movedFlags->end();
- ++move) {
- if (move->moveId == insertion.moveId) {
- flags = move->flags;
- break;
- }
- }
- }
- if (flags & ~(AppendFlag | PrependFlag)) {
- Insert translatedInsert(it, insertion.count, flags, insertion.moveId);
- for (int i = 0; i < m_groupCount; ++i) {
- if (it->inGroup(i))
- translatedInsert.index[i] += offset;
- }
- translatedInsertions->append(translatedInsert);
- }
- if ((it->flags & ~AppendFlag) == flags) {
- it->count += insertion.count;
- } else if (offset == 0
- && it->previous != &m_ranges
- && it->previous->list == list
- && it->previous->end() == insertion.index
- && it->previous->flags == flags) {
- it->previous->count += insertion.count;
- it->index += insertion.count;
- it.incrementIndexes(insertion.count);
- } else {
- if (offset > 0) {
- it.incrementIndexes(offset);
- *it = insert(*it, it->list, it->index, offset, it->flags & ~AppendFlag)->next;
- }
- *it = insert(*it, it->list, insertion.index, insertion.count, flags)->next;
- it.incrementIndexes(insertion.count, flags);
- it->index += offset + insertion.count;
- it->count -= offset;
- }
- m_end.incrementIndexes(insertion.count, flags);
- } else {
- if (offset > 0) {
- *it = insert(*it, it->list, it->index, offset, it->flags)->next;
- it->index += offset;
- it->count -= offset;
- }
- it->index += insertion.count;
- }
- } else if (offset <= 0) {
- it->index += insertion.count;
- }
- }
- it.incrementIndexes(it->count);
- }
- m_cacheIt = m_end;
- QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
-}
-
-void QDeclarativeListCompositor::listItemsInserted(
- void *list, int index, int count, QVector<Insert> *translatedInsertions)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << index << count)
- Q_ASSERT(count > 0);
-
- QVector<QDeclarativeChangeSet::Insert> insertions;
- insertions.append(QDeclarativeChangeSet::Insert(index, count));
-
- listItemsInserted(translatedInsertions, list, insertions);
-}
-
-void QDeclarativeListCompositor::listItemsRemoved(
- QVector<Remove> *translatedRemovals,
- void *list,
- QVector<QDeclarativeChangeSet::Remove> *removals,
- QVector<QDeclarativeChangeSet::Insert> *insertions,
- QVector<MovedFlags> *movedFlags, int moveId)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << *removals)
-
- for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
- if (it->list != list || it->flags == CacheFlag) {
- it.incrementIndexes(it->count);
- continue;
- }
- bool removed = false;
- for (QVector<QDeclarativeChangeSet::Remove>::iterator removal = removals->begin();
- !removed && removal != removals->end();
- ++removal) {
- int relativeIndex = removal->index - it->index;
- int itemsRemoved = removal->count;
- if (relativeIndex + removal->count > 0 && relativeIndex < it->count) {
- const int offset = qMax(0, relativeIndex);
- int removeCount = qMin(it->count, relativeIndex + removal->count) - offset;
- it->count -= removeCount;
- int removeFlags = it->flags & m_removeFlags;
- Remove translatedRemoval(it, removeCount, it->flags);
- for (int i = 0; i < m_groupCount; ++i) {
- if (it->inGroup(i))
- translatedRemoval.index[i] += offset;
- }
- if (removal->isMove()) {
- QVector<QDeclarativeChangeSet::Insert>::iterator insertion = insertions->begin();
- for (; insertion != insertions->end() && insertion->moveId != removal->moveId;
- ++insertion) {}
- Q_ASSERT(insertion != insertions->end());
- Q_ASSERT(insertion->count == removal->count);
-
- if (relativeIndex < 0) {
- int splitMoveId = ++moveId;
- removal = removals->insert(removal, QDeclarativeChangeSet::Remove(
- removal->index, -relativeIndex, splitMoveId));
- ++removal;
- removal->count -= -relativeIndex;
- insertion = insertions->insert(insertion, QDeclarativeChangeSet::Insert(
- insertion->index, -relativeIndex, splitMoveId));
- ++insertion;
- insertion->index += -relativeIndex;
- insertion->count -= -relativeIndex;
- }
-
- if (it->prepend()) {
- removeFlags |= it->flags & CacheFlag;
- translatedRemoval.moveId = ++moveId;
- movedFlags->append(MovedFlags(moveId, it->flags & ~AppendFlag));
-
- if (removeCount < removal->count) {
- removal = removals->insert(removal, QDeclarativeChangeSet::Remove(
- removal->index, removeCount, translatedRemoval.moveId));
- ++removal;
- insertion = insertions->insert(insertion, QDeclarativeChangeSet::Insert(
- insertion->index, removeCount, translatedRemoval.moveId));
- ++insertion;
-
- removal->count -= removeCount;
- insertion->index += removeCount;
- insertion->count -= removeCount;
- } else {
- removal->moveId = translatedRemoval.moveId;
- insertion->moveId = translatedRemoval.moveId;
- }
- } else {
- if (offset > 0) {
- *it = insert(*it, it->list, it->index, offset, it->flags & ~AppendFlag)->next;
- it->index += offset;
- it->count -= offset;
- it.incrementIndexes(offset);
- }
- if (it->previous != &m_ranges
- && it->previous->list == it->list
- && it->end() == insertion->index
- && it->previous->flags == (it->flags | MovedFlag)) {
- it->previous->count += removeCount;
- } else {
- *it = insert(*it, it->list, insertion->index, removeCount, it->flags | MovedFlag)->next;
- }
- translatedRemoval.flags = 0;
- removeFlags = 0;
- }
- } else if (it->inCache()) {
- if (offset > 0) {
- *it = insert(*it, it->list, it->index, offset, it->flags & ~AppendFlag)->next;
- it->index += offset;
- it->count -= offset;
- it.incrementIndexes(offset);
- }
- if (it->previous != &m_ranges
- && it->previous->list == it->list
- && it->previous->flags == CacheFlag) {
- it->previous->count += removeCount;
- } else {
- *it = insert(*it, it->list, -1, removeCount, CacheFlag)->next;
- }
- it.index[Cache] += removeCount;
- }
- if (removeFlags & GroupMask)
- translatedRemovals->append(translatedRemoval);
- m_end.decrementIndexes(removeCount, removeFlags);
- if (it->count == 0 && !it->append()) {
- *it = erase(*it)->previous;
- removed = true;
- } else if (relativeIndex <= 0) {
- it->index = removal->index;
- }
- } else if (relativeIndex < 0) {
- it->index -= itemsRemoved;
-
- if (it->previous != &m_ranges
- && it->previous->list == it->list
- && it->previous->end() == it->index
- && it->previous->flags == (it->flags & ~AppendFlag)) {
- it.decrementIndexes(it->previous->count);
- it->previous->count += it->count;
- it->previous->flags = it->flags;
- *it = erase(*it)->previous;
- }
- }
- }
- if (it->flags == CacheFlag && it->next->flags == CacheFlag && it->next->list == it->list) {
- it.index[Cache] += it->next->count;
- it->count += it->next->count;
- erase(it->next);
- } else if (!removed) {
- it.incrementIndexes(it->count);
- }
- }
- m_cacheIt = m_end;
- QT_DECLARATIVE_VERIFY_LISTCOMPOSITOR
-}
-
-void QDeclarativeListCompositor::listItemsRemoved(
- void *list, int index, int count, QVector<Remove> *translatedRemovals)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << index << count)
- Q_ASSERT(count >= 0);
-
- QVector<QDeclarativeChangeSet::Remove> removals;
- removals.append(QDeclarativeChangeSet::Remove(index, count));
- listItemsRemoved(translatedRemovals, list, &removals, 0, 0, 0);
-}
-
-void QDeclarativeListCompositor::listItemsMoved(
- void *list,
- int from,
- int to,
- int count,
- QVector<Remove> *translatedRemovals,
- QVector<Insert> *translatedInsertions)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << from << to << count)
- Q_ASSERT(count >= 0);
-
- QVector<QDeclarativeChangeSet::Remove> removals;
- QVector<QDeclarativeChangeSet::Insert> insertions;
- QVector<MovedFlags> movedFlags;
- removals.append(QDeclarativeChangeSet::Remove(from, count, 0));
- insertions.append(QDeclarativeChangeSet::Insert(to, count, 0));
-
- listItemsRemoved(translatedRemovals, list, &removals, &insertions, &movedFlags, 0);
- listItemsInserted(translatedInsertions, list, insertions, &movedFlags);
-}
-
-void QDeclarativeListCompositor::listItemsChanged(
- QVector<Change> *translatedChanges,
- void *list,
- const QVector<QDeclarativeChangeSet::Change> &changes)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << changes)
- for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
- if (it->list != list || it->flags == CacheFlag) {
- it.incrementIndexes(it->count);
- continue;
- } else if (!it->inGroup()) {
- continue;
- }
- foreach (const QDeclarativeChangeSet::Change &change, changes) {
- const int offset = change.index - it->index;
- if (offset + change.count > 0 && offset < it->count) {
- const int changeOffset = qMax(0, offset);
- const int changeCount = qMin(it->count, offset + change.count) - changeOffset;
-
- Change translatedChange(it, changeCount, it->flags);
- for (int i = 0; i < m_groupCount; ++i) {
- if (it->inGroup(i))
- translatedChange.index[i] += changeOffset;
- }
- translatedChanges->append(translatedChange);
- }
- }
- it.incrementIndexes(it->count);
- }
-}
-
-void QDeclarativeListCompositor::listItemsChanged(
- void *list, int index, int count, QVector<Change> *translatedChanges)
-{
- QT_DECLARATIVE_TRACE_LISTCOMPOSITOR(<< list << index << count)
- Q_ASSERT(count >= 0);
- QVector<QDeclarativeChangeSet::Change> changes;
- changes.append(QDeclarativeChangeSet::Change(index, count));
- listItemsChanged(translatedChanges, list, changes);
-}
-
-void QDeclarativeListCompositor::listChanged(
- void *list,
- const QDeclarativeChangeSet &changeSet,
- QVector<Remove> *translatedRemovals,
- QVector<Insert> *translatedInsertions,
- QVector<Change> *translatedChanges)
-{
- QVector<QDeclarativeChangeSet::Remove> removals = changeSet.removes();
- QVector<QDeclarativeChangeSet::Insert> insertions = changeSet.inserts();
- QVector<MovedFlags> movedFlags;
- listItemsRemoved(translatedRemovals, list, &removals, &insertions, &movedFlags, changeSet.moveCounter());
- listItemsInserted(translatedInsertions, list, insertions, &movedFlags);
- listItemsChanged(translatedChanges, list, changeSet.changes());
-}
-
-void QDeclarativeListCompositor::transition(
- Group from,
- Group to,
- QVector<QDeclarativeChangeSet::Remove> *removes,
- QVector<QDeclarativeChangeSet::Insert> *inserts)
-{
- int removeCount = 0;
- for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
- if (it == from && it != to) {
- removes->append(QDeclarativeChangeSet::Remove(it.index[from]- removeCount, it->count));
- removeCount += it->count;
- } else if (it != from && it == to) {
- inserts->append(QDeclarativeChangeSet::Insert(it.index[to], it->count));
- }
- it.incrementIndexes(it->count);
- }
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Group &group)
-{
- switch (group) {
- case QDeclarativeListCompositor::Cache: return debug << "Cache";
- case QDeclarativeListCompositor::Default: return debug << "Default";
- default: return (debug.nospace() << "Group" << int(group)).space();
- }
-
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Range &range)
-{
- (debug.nospace()
- << "Range("
- << range.list) << " "
- << range.index << " "
- << range.count << " "
- << (range.isUnresolved() ? "U" : "0")
- << (range.append() ? "A" : "0")
- << (range.prepend() ? "P" : "0");
- for (int i = QDeclarativeListCompositor::MaximumGroupCount - 1; i >= 2; --i)
- debug << (range.inGroup(i) ? "1" : "0");
- return (debug
- << (range.inGroup(QDeclarativeListCompositor::Default) ? "D" : "0")
- << (range.inGroup(QDeclarativeListCompositor::Cache) ? "C" : "0"));
-}
-
-static void qt_print_indexes(QDebug &debug, int count, const int *indexes)
-{
- for (int i = count - 1; i >= 0; --i)
- debug << indexes[i];
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::iterator &it)
-{
- (debug.nospace() << "iterator(" << it.group).space() << "offset:" << it.offset;
- qt_print_indexes(debug, it.groupCount, it.index);
- return ((debug << **it).nospace() << ")").space();
-}
-
-static QDebug qt_print_change(QDebug debug, const char *name, const QDeclarativeListCompositor::Change &change)
-{
- debug.nospace() << name << "(" << change.moveId << " " << change.count << " ";
- for (int i = QDeclarativeListCompositor::MaximumGroupCount - 1; i >= 2; --i)
- debug << (change.inGroup(i) ? "1" : "0");
- debug << (change.inGroup(QDeclarativeListCompositor::Default) ? "D" : "0")
- << (change.inGroup(QDeclarativeListCompositor::Cache) ? "C" : "0");
- int i = QDeclarativeListCompositor::MaximumGroupCount - 1;
- for (; i >= 0 && !change.inGroup(i); --i) {}
- for (; i >= 0; --i)
- debug << " " << change.index[i];
- return (debug << ")").maybeSpace();
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Change &change)
-{
- return qt_print_change(debug, "Change", change);
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Remove &remove)
-{
- return qt_print_change(debug, "Remove", remove);
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Insert &insert)
-{
- return qt_print_change(debug, "Insert", insert);
-}
-
-QDebug operator <<(QDebug debug, const QDeclarativeListCompositor &list)
-{
- int indexes[QDeclarativeListCompositor::MaximumGroupCount];
- for (int i = 0; i < QDeclarativeListCompositor::MaximumGroupCount; ++i)
- indexes[i] = 0;
- debug.nospace() << "QDeclarativeListCompositor(";
- qt_print_indexes(debug, list.m_groupCount, list.m_end.index);
- for (QDeclarativeListCompositor::Range *range = list.m_ranges.next; range != &list.m_ranges; range = range->next) {
- (debug << "\n").space();
- qt_print_indexes(debug, list.m_groupCount, indexes);
- debug << " " << *range;
-
- for (int i = 0; i < list.m_groupCount; ++i) {
- if (range->inGroup(i))
- indexes[i] += range->count;
- }
- }
- return (debug << ")").maybeSpace();
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativelistcompositor_p.h b/src/quick/util/qdeclarativelistcompositor_p.h
deleted file mode 100644
index 4bee0dab69..0000000000
--- a/src/quick/util/qdeclarativelistcompositor_p.h
+++ /dev/null
@@ -1,382 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTCOMPOSITOR_P_H
-#define QDECLARATIVELISTCOMPOSITOR_P_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/qvector.h>
-
-#include <private/qdeclarativechangeset_p.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_AUTOTEST_EXPORT QDeclarativeListCompositor
-{
-public:
- enum { MinimumGroupCount = 3, MaximumGroupCount = 11 };
-
- enum Group
- {
- Cache = 0,
- Default = 1,
- Persisted = 2
- };
-
- enum Flag
- {
- CacheFlag = 1 << Cache,
- DefaultFlag = 1 << Default,
- PersistedFlag = 1 << Persisted,
- PrependFlag = 0x10000000,
- AppendFlag = 0x20000000,
- UnresolvedFlag = 0x40000000,
- MovedFlag = 0x80000000,
- GroupMask = ~(PrependFlag | AppendFlag | UnresolvedFlag | MovedFlag | CacheFlag)
- };
-
- class Range
- {
- public:
- Range() : next(this), previous(this), list(0), index(0), count(0), flags(0) {}
- Range(Range *next, void *list, int index, int count, uint flags)
- : next(next), previous(next->previous), list(list), index(index), count(count), flags(flags) {
- next->previous = this; previous->next = this; }
-
- Range *next;
- Range *previous;
- void *list;
- int index;
- int count;
- uint flags;
-
- inline int start() const { return index; }
- inline int end() const { return index + count; }
-
- inline int groups() const { return flags & GroupMask; }
-
- inline bool inGroup() const { return flags & GroupMask; }
- inline bool inCache() const { return flags & CacheFlag; }
- inline bool inGroup(int group) const { return flags & (1 << group); }
- inline bool isUnresolved() const { return flags & UnresolvedFlag; }
-
- inline bool prepend() const { return flags & PrependFlag; }
- inline bool append() const { return flags & AppendFlag; }
- };
-
- class Q_AUTOTEST_EXPORT iterator
- {
- public:
- inline iterator();
- inline iterator(const iterator &it);
- inline iterator(Range *range, int offset, Group group, int groupCount);
- inline ~iterator() {}
-
- bool operator ==(const iterator &it) const { return range == it.range && offset == it.offset; }
- bool operator !=(const iterator &it) const { return range != it.range || offset != it.offset; }
-
- bool operator ==(Group group) const { return range->flags & (1 << group); }
- bool operator !=(Group group) const { return !(range->flags & (1 << group)); }
-
- Range *&operator *() { return range; }
- Range * const &operator *() const { return range; }
- Range *operator ->() { return range; }
- const Range *operator ->() const { return range; }
-
- iterator &operator +=(int difference);
- iterator &operator -=(int difference);
-
- template<typename T> T *list() const { return static_cast<T *>(range->list); }
- int modelIndex() const { return range->index + offset; }
-
- void incrementIndexes(int difference) { incrementIndexes(difference, range->flags); }
- void decrementIndexes(int difference) { decrementIndexes(difference, range->flags); }
-
- inline void incrementIndexes(int difference, uint flags);
- inline void decrementIndexes(int difference, uint flags);
-
- void setGroup(Group g) { group = g; groupFlag = 1 << g; }
-
- Range *range;
- int offset;
- Group group;
- int groupFlag;
- int groupCount;
- union {
- struct {
- int cacheIndex;
- };
- int index[MaximumGroupCount];
- };
- };
-
- class Q_AUTOTEST_EXPORT insert_iterator : public iterator
- {
- public:
- inline insert_iterator() {}
- inline insert_iterator(const iterator &it) : iterator(it) {}
- inline insert_iterator(Range *, int, Group, int);
- inline ~insert_iterator() {}
-
- insert_iterator &operator +=(int difference);
- insert_iterator &operator -=(int difference);
- };
-
- struct Change
- {
- inline Change() {}
- inline Change(iterator it, int count, uint flags, int moveId = -1);
- int count;
- uint flags;
- int moveId;
- union {
- struct {
- int cacheIndex;
- };
- int index[MaximumGroupCount];
- };
-
- inline bool isMove() const { return moveId >= 0; }
- inline bool inCache() const { return flags & CacheFlag; }
- inline bool inGroup() const { return flags & GroupMask; }
- inline bool inGroup(int group) const { return flags & (CacheFlag << group); }
-
- inline int groups() const { return flags & GroupMask; }
- };
-
- struct Insert : public Change
- {
- Insert() {}
- Insert(iterator it, int count, uint flags, int moveId = -1)
- : Change(it, count, flags, moveId) {}
- };
-
- struct Remove : public Change
- {
- Remove() {}
- Remove(iterator it, int count, uint flags, int moveId = -1)
- : Change(it, count, flags, moveId) {}
- };
-
- QDeclarativeListCompositor();
- ~QDeclarativeListCompositor();
-
- int defaultGroups() const { return m_defaultFlags & ~PrependFlag; }
- void setDefaultGroups(int groups) { m_defaultFlags = groups | PrependFlag; }
- void setDefaultGroup(Group group) { m_defaultFlags |= (1 << group); }
- void clearDefaultGroup(Group group) { m_defaultFlags &= ~(1 << group); }
- void setRemoveGroups(int groups) { m_removeFlags = PrependFlag | AppendFlag | groups; }
- void setGroupCount(int count);
-
- int count(Group group) const;
- iterator find(Group group, int index);
- iterator find(Group group, int index) const;
- insert_iterator findInsertPosition(Group group, int index);
-
- iterator begin(Group group);
- const iterator &end() { return m_end; }
-
- void append(void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
- void insert(Group group, int before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
- iterator insert(iterator before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
-
- void setFlags(Group fromGroup, int from, int count, Group group, int flags, QVector<Insert> *inserts = 0);
- void setFlags(iterator from, int count, Group group, uint flags, QVector<Insert> *inserts = 0);
- void setFlags(Group fromGroup, int from, int count, uint flags, QVector<Insert> *inserts = 0) {
- setFlags(fromGroup, from, count, fromGroup, flags, inserts); }
- void setFlags(iterator from, int count, uint flags, QVector<Insert> *inserts = 0) {
- setFlags(from, count, from.group, flags, inserts); }
-
- void clearFlags(Group fromGroup, int from, int count, Group group, uint flags, QVector<Remove> *removals = 0);
- void clearFlags(iterator from, int count, Group group, uint flags, QVector<Remove> *removals = 0);
- void clearFlags(Group fromGroup, int from, int count, uint flags, QVector<Remove> *removals = 0) {
- clearFlags(fromGroup, from, count, fromGroup, flags, removals); }
- void clearFlags(iterator from, int count, uint flags, QVector<Remove> *removals = 0) {
- clearFlags(from, count, from.group, flags, removals); }
-
- void removeList(void *list, QVector<Remove> *removals, bool destroyed);
-
- bool verifyMoveTo(Group fromGroup, int from, Group toGroup, int to, int count, Group group) const;
-
- void move(
- Group fromGroup,
- int from,
- Group toGroup,
- int to,
- int count,
- Group group,
- QVector<Remove> *removals = 0,
- QVector<Insert> *inserts = 0);
- void clear();
-
- void listItemsInserted(void *list, int index, int count, QVector<Insert> *inserts);
- void listItemsRemoved(void *list, int index, int count, QVector<Remove> *removals);
- void listItemsMoved(void *list, int from, int to, int count, QVector<Remove> *removals, QVector<Insert> *inserts);
- void listItemsChanged(void *list, int index, int count, QVector<Change> *changes);
- void listChanged(
- void *list,
- const QDeclarativeChangeSet &changeSet,
- QVector<Remove> *removals,
- QVector<Insert> *inserts,
- QVector<Change> *changes);
-
- void transition(
- Group from,
- Group to,
- QVector<QDeclarativeChangeSet::Remove> *removes,
- QVector<QDeclarativeChangeSet::Insert> *inserts);
-
-private:
- Range m_ranges;
- iterator m_end;
- iterator m_cacheIt;
- int m_groupCount;
- int m_defaultFlags;
- int m_removeFlags;
-
- inline Range *insert(Range *before, void *list, int index, int count, uint flags);
- inline Range *erase(Range *range);
-
- struct MovedFlags
- {
- MovedFlags() {}
- MovedFlags(int moveId, uint flags) : moveId(moveId), flags(flags) {}
-
- int moveId;
- uint flags;
- };
-
- void listItemsRemoved(
- QVector<Remove> *translatedRemovals,
- void *list,
- QVector<QDeclarativeChangeSet::Remove> *removals,
- QVector<QDeclarativeChangeSet::Insert> *insertions = 0,
- QVector<MovedFlags> *movedFlags = 0,
- int moveId = 0);
- void listItemsInserted(
- QVector<Insert> *translatedInsertions,
- void *list,
- const QVector<QDeclarativeChangeSet::Insert> &insertions,
- const QVector<MovedFlags> *movedFlags = 0);
- void listItemsChanged(
- QVector<Change> *translatedChanges,
- void *list,
- const QVector<QDeclarativeChangeSet::Change> &changes);
-
- friend Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeListCompositor &list);
-};
-
-inline QDeclarativeListCompositor::iterator::iterator()
- : range(0), offset(0), group(Default), groupCount(0) {}
-inline QDeclarativeListCompositor::iterator::iterator(const iterator &it)
- : range(it.range)
- , offset(it.offset)
- , group(it.group)
- , groupFlag(it.groupFlag)
- , groupCount(it.groupCount)
-{
- for (int i = 0; i < groupCount; ++i)
- index[i] = it.index[i];
-}
-
-inline QDeclarativeListCompositor::iterator::iterator(
- Range *range, int offset, Group group, int groupCount)
- : range(range)
- , offset(offset)
- , group(group)
- , groupFlag(1 << group)
- , groupCount(groupCount)
-{
- for (int i = 0; i < groupCount; ++i)
- index[i] = 0;
-}
-
-inline void QDeclarativeListCompositor::iterator::incrementIndexes(int difference, uint flags)
-{
- for (int i = 0; i < groupCount; ++i) {
- if (flags & (1 << i))
- index[i] += difference;
- }
-}
-
-inline void QDeclarativeListCompositor::iterator::decrementIndexes(int difference, uint flags)
-{
- for (int i = 0; i < groupCount; ++i) {
- if (flags & (1 << i))
- index[i] -= difference;
- }
-}
-
-inline QDeclarativeListCompositor::insert_iterator::insert_iterator(
- Range *range, int offset, Group group, int groupCount)
- : iterator(range, offset, group, groupCount) {}
-
-inline QDeclarativeListCompositor::Change::Change(iterator it, int count, uint flags, int moveId)
- : count(count), flags(flags), moveId(moveId)
-{
- for (int i = 0; i < MaximumGroupCount; ++i)
- index[i] = it.index[i];
-}
-
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Group &group);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Range &range);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::iterator &it);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Change &change);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Remove &remove);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeListCompositor::Insert &insert);
-Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QDeclarativeListCompositor &list);
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/quick/util/qdeclarativepackage.cpp b/src/quick/util/qdeclarativepackage.cpp
deleted file mode 100644
index c6504ffea4..0000000000
--- a/src/quick/util/qdeclarativepackage.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepackage_p.h"
-
-#include <private/qobject_p.h>
-#include <private/qdeclarativeguard_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass Package QDeclarativePackage
- \inqmlmodule QtQuick 2
- \ingroup qml-working-with-data
- \brief Package provides a collection of named items.
-
- The Package class is used in conjunction with
- VisualDataModel to enable delegates with a shared context
- to be provided to multiple views.
-
- Any item within a Package may be assigned a name via the
- \l{Package::name}{Package.name} attached property.
-
- The example below creates a Package containing two named items;
- \e list and \e grid. The third element in the package (the \l Rectangle) is parented to whichever
- delegate it should appear in. This allows an item to move
- between views.
-
- \snippet examples/declarative/modelviews/package/Delegate.qml 0
-
- These named items are used as the delegates by the two views who
- 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}, {declarative/photoviewer}{Photo Viewer example}, QtDeclarative
-*/
-
-/*!
- \qmlattachedproperty string QtQuick2::Package::name
- This attached property holds the name of an item within a Package.
-*/
-
-
-class QDeclarativePackagePrivate : public QObjectPrivate
-{
-public:
- QDeclarativePackagePrivate() {}
-
- struct DataGuard : public QDeclarativeGuard<QObject>
- {
- DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QDeclarativeGuard<QObject>&)*this = obj; }
- QList<DataGuard> *list;
- void objectDestroyed(QObject *) {
- // we assume priv will always be destroyed after objectDestroyed calls
- list->removeOne(*this);
- }
- };
-
- QList<DataGuard> dataList;
- static void data_append(QDeclarativeListProperty<QObject> *prop, QObject *o) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- list->append(DataGuard(o, list));
- }
- static void data_clear(QDeclarativeListProperty<QObject> *prop) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- list->clear();
- }
- static QObject *data_at(QDeclarativeListProperty<QObject> *prop, int index) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- return list->at(index);
- }
- static int data_count(QDeclarativeListProperty<QObject> *prop) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- return list->count();
- }
-};
-
-QHash<QObject *, QDeclarativePackageAttached *> QDeclarativePackageAttached::attached;
-
-QDeclarativePackageAttached::QDeclarativePackageAttached(QObject *parent)
-: QObject(parent)
-{
- attached.insert(parent, this);
-}
-
-QDeclarativePackageAttached::~QDeclarativePackageAttached()
-{
- attached.remove(parent());
-}
-
-QString QDeclarativePackageAttached::name() const
-{
- return _name;
-}
-
-void QDeclarativePackageAttached::setName(const QString &n)
-{
- _name = n;
-}
-
-QDeclarativePackage::QDeclarativePackage(QObject *parent)
- : QObject(*(new QDeclarativePackagePrivate), parent)
-{
-}
-
-QDeclarativePackage::~QDeclarativePackage()
-{
- Q_D(QDeclarativePackage);
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- obj->setParent(this);
- }
-}
-
-QDeclarativeListProperty<QObject> QDeclarativePackage::data()
-{
- Q_D(QDeclarativePackage);
- return QDeclarativeListProperty<QObject>(this, &d->dataList, QDeclarativePackagePrivate::data_append,
- QDeclarativePackagePrivate::data_count,
- QDeclarativePackagePrivate::data_at,
- QDeclarativePackagePrivate::data_clear);
-}
-
-bool QDeclarativePackage::hasPart(const QString &name)
-{
- Q_D(QDeclarativePackage);
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- QDeclarativePackageAttached *a = QDeclarativePackageAttached::attached.value(obj);
- if (a && a->name() == name)
- return true;
- }
- return false;
-}
-
-QObject *QDeclarativePackage::part(const QString &name)
-{
- Q_D(QDeclarativePackage);
- if (name.isEmpty() && !d->dataList.isEmpty())
- return d->dataList.at(0);
-
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- QDeclarativePackageAttached *a = QDeclarativePackageAttached::attached.value(obj);
- if (a && a->name() == name)
- return obj;
- }
-
- if (name == QLatin1String("default") && !d->dataList.isEmpty())
- return d->dataList.at(0);
-
- return 0;
-}
-
-QDeclarativePackageAttached *QDeclarativePackage::qmlAttachedProperties(QObject *o)
-{
- return new QDeclarativePackageAttached(o);
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativepackage_p.h b/src/quick/util/qdeclarativepackage_p.h
deleted file mode 100644
index ad164bc329..0000000000
--- a/src/quick/util/qdeclarativepackage_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPACKAGE_H
-#define QDECLARATIVEPACKAGE_H
-
-#include <qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativePackagePrivate;
-class QDeclarativePackageAttached;
-class Q_AUTOTEST_EXPORT QDeclarativePackage : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativePackage)
-
- Q_CLASSINFO("DefaultProperty", "data")
- Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data)
-
-public:
- QDeclarativePackage(QObject *parent=0);
- virtual ~QDeclarativePackage();
-
- QDeclarativeListProperty<QObject> data();
-
- QObject *part(const QString & = QString());
- bool hasPart(const QString &);
-
- static QDeclarativePackageAttached *qmlAttachedProperties(QObject *);
-};
-
-class QDeclarativePackageAttached : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(QString name READ name WRITE setName)
-public:
- QDeclarativePackageAttached(QObject *parent);
- virtual ~QDeclarativePackageAttached();
-
- QString name() const;
- void setName(const QString &n);
-
- static QHash<QObject *, QDeclarativePackageAttached *> attached;
-private:
- QString _name;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativePackage)
-QML_DECLARE_TYPEINFO(QDeclarativePackage, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPACKAGE_H
diff --git a/src/quick/util/qdeclarativepath.cpp b/src/quick/util/qdeclarativepath.cpp
deleted file mode 100644
index 2ee534880c..0000000000
--- a/src/quick/util/qdeclarativepath.cpp
+++ /dev/null
@@ -1,1798 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepath_p.h"
-#include "qdeclarativepath_p_p.h"
-#include "qdeclarativesvgparser_p.h"
-
-#include <QSet>
-#include <QTime>
-
-#include <private/qbezier_p.h>
-#include <QtCore/qmath.h>
-#include <QtCore/qnumeric.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass PathElement QDeclarativePathElement
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief PathElement is the base path type.
-
- This type is the base for all path types. It cannot
- be instantiated.
-
- \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg
-*/
-
-/*!
- \qmlclass Path QDeclarativePath
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief A Path object defines a path for use by \l PathView.
-
- A Path is composed of one or more path segments - PathLine, PathQuad,
- PathCubic, PathArc, PathCurve, PathSvg.
-
- The spacing of the items along the Path can be adjusted via a
- PathPercent object.
-
- PathAttribute allows named attributes with values to be defined
- along the path.
-
- \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg
-*/
-QDeclarativePath::QDeclarativePath(QObject *parent)
- : QObject(*(new QDeclarativePathPrivate), parent)
-{
-}
-
-QDeclarativePath::~QDeclarativePath()
-{
-}
-
-/*!
- \qmlproperty real QtQuick2::Path::startX
- \qmlproperty real QtQuick2::Path::startY
- These properties hold the starting position of the path.
-*/
-qreal QDeclarativePath::startX() const
-{
- Q_D(const QDeclarativePath);
- return d->startX.isNull ? 0 : d->startX.value;
-}
-
-void QDeclarativePath::setStartX(qreal x)
-{
- Q_D(QDeclarativePath);
- if (d->startX.isValid() && qFuzzyCompare(x, d->startX))
- return;
- d->startX = x;
- emit startXChanged();
- processPath();
-}
-
-bool QDeclarativePath::hasStartX() const
-{
- Q_D(const QDeclarativePath);
- return d->startX.isValid();
-}
-
-qreal QDeclarativePath::startY() const
-{
- Q_D(const QDeclarativePath);
- return d->startY.isNull ? 0 : d->startY.value;
-}
-
-void QDeclarativePath::setStartY(qreal y)
-{
- Q_D(QDeclarativePath);
- if (d->startY.isValid() && qFuzzyCompare(y, d->startY))
- return;
- d->startY = y;
- emit startYChanged();
- processPath();
-}
-
-bool QDeclarativePath::hasStartY() const
-{
- Q_D(const QDeclarativePath);
- return d->startY.isValid();
-}
-
-/*!
- \qmlproperty bool QtQuick2::Path::closed
- This property holds whether the start and end of the path are identical.
-*/
-bool QDeclarativePath::isClosed() const
-{
- Q_D(const QDeclarativePath);
- return d->closed;
-}
-
-bool QDeclarativePath::hasEnd() const
-{
- Q_D(const QDeclarativePath);
- for (int i = d->_pathElements.count() - 1; i > -1; --i) {
- if (QDeclarativeCurve *curve = qobject_cast<QDeclarativeCurve *>(d->_pathElements.at(i))) {
- if ((!curve->hasX() && !curve->hasRelativeX()) || (!curve->hasY() && !curve->hasRelativeY()))
- return false;
- else
- return true;
- }
- }
- return hasStartX() && hasStartY();
-}
-
-/*!
- \qmlproperty list<PathElement> QtQuick2::Path::pathElements
- This property holds the objects composing the path.
-
- \default
-
- A path can contain the following path objects:
- \list
- \i \l PathLine - a straight line to a given position.
- \i \l PathQuad - a quadratic Bezier curve to a given position with a control point.
- \i \l PathCubic - a cubic Bezier curve to a given position with two control points.
- \i \l PathArc - an arc to a given position with a radius.
- \i \l PathSvg - a path specified as an SVG path data string.
- \i \l PathCurve - a point on a Catmull-Rom curve.
- \i \l PathAttribute - an attribute at a given position in the path.
- \i \l PathPercent - a way to spread out items along various segments of the path.
- \endlist
-
- \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 2
-*/
-
-QDeclarativeListProperty<QDeclarativePathElement> QDeclarativePath::pathElements()
-{
- Q_D(QDeclarativePath);
- return QDeclarativeListProperty<QDeclarativePathElement>(this, d->_pathElements);
-}
-
-void QDeclarativePath::interpolate(int idx, const QString &name, qreal value)
-{
- Q_D(QDeclarativePath);
- interpolate(d->_attributePoints, idx, name, value);
-}
-
-void QDeclarativePath::interpolate(QList<AttributePoint> &attributePoints, int idx, const QString &name, qreal value)
-{
- if (!idx)
- return;
-
- qreal lastValue = 0;
- qreal lastPercent = 0;
- int search = idx - 1;
- while(search >= 0) {
- const AttributePoint &point = attributePoints.at(search);
- if (point.values.contains(name)) {
- lastValue = point.values.value(name);
- lastPercent = point.origpercent;
- break;
- }
- --search;
- }
-
- ++search;
-
- const AttributePoint &curPoint = attributePoints.at(idx);
-
- for (int ii = search; ii < idx; ++ii) {
- AttributePoint &point = attributePoints[ii];
-
- qreal val = lastValue + (value - lastValue) * (point.origpercent - lastPercent) / (curPoint.origpercent - lastPercent);
- point.values.insert(name, val);
- }
-}
-
-void QDeclarativePath::endpoint(const QString &name)
-{
- Q_D(QDeclarativePath);
- const AttributePoint &first = d->_attributePoints.first();
- qreal val = first.values.value(name);
- for (int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) {
- const AttributePoint &point = d->_attributePoints.at(ii);
- if (point.values.contains(name)) {
- for (int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) {
- AttributePoint &setPoint = d->_attributePoints[jj];
- setPoint.values.insert(name, val);
- }
- return;
- }
- }
-}
-
-void QDeclarativePath::endpoint(QList<AttributePoint> &attributePoints, const QString &name)
-{
- const AttributePoint &first = attributePoints.first();
- qreal val = first.values.value(name);
- for (int ii = attributePoints.count() - 1; ii >= 0; ii--) {
- const AttributePoint &point = attributePoints.at(ii);
- if (point.values.contains(name)) {
- for (int jj = ii + 1; jj < attributePoints.count(); ++jj) {
- AttributePoint &setPoint = attributePoints[jj];
- setPoint.values.insert(name, val);
- }
- return;
- }
- }
-}
-
-static QString percentString(QLatin1String("_qfx_percent"));
-
-void QDeclarativePath::processPath()
-{
- Q_D(QDeclarativePath);
-
- if (!d->componentComplete)
- return;
-
- d->_pointCache.clear();
- d->prevBez.isValid = false;
-
- d->_path = createPath(QPointF(), QPointF(), d->_attributes, d->pathLength, d->_attributePoints, &d->closed);
-
- emit changed();
-}
-
-QPainterPath QDeclarativePath::createPath(const QPointF &startPoint, const QPointF &endPoint, const QStringList &attributes, qreal &pathLength, QList<AttributePoint> &attributePoints, bool *closed)
-{
- Q_D(QDeclarativePath);
-
- pathLength = 0;
- attributePoints.clear();
-
- if (!d->componentComplete)
- return QPainterPath();
-
- QPainterPath path;
-
- AttributePoint first;
- for (int ii = 0; ii < attributes.count(); ++ii)
- first.values[attributes.at(ii)] = 0;
- attributePoints << first;
-
- qreal startX = d->startX.isValid() ? d->startX.value : startPoint.x();
- qreal startY = d->startY.isValid() ? d->startY.value : startPoint.y();
- path.moveTo(startX, startY);
-
- bool usesPercent = false;
- int index = 0;
- foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
- if (QDeclarativeCurve *curve = qobject_cast<QDeclarativeCurve *>(pathElement)) {
- QDeclarativePathData data;
- data.index = index;
- data.endPoint = endPoint;
- data.curves = d->_pathCurves;
- curve->addToPath(path, data);
- AttributePoint p;
- p.origpercent = path.length();
- attributePoints << p;
- ++index;
- } else if (QDeclarativePathAttribute *attribute = qobject_cast<QDeclarativePathAttribute *>(pathElement)) {
- AttributePoint &point = attributePoints.last();
- point.values[attribute->name()] = attribute->value();
- interpolate(attributePoints, attributePoints.count() - 1, attribute->name(), attribute->value());
- } else if (QDeclarativePathPercent *percent = qobject_cast<QDeclarativePathPercent *>(pathElement)) {
- AttributePoint &point = attributePoints.last();
- point.values[percentString] = percent->value();
- interpolate(attributePoints, attributePoints.count() - 1, percentString, percent->value());
- usesPercent = true;
- }
- }
-
- // Fixup end points
- const AttributePoint &last = attributePoints.last();
- for (int ii = 0; ii < attributes.count(); ++ii) {
- if (!last.values.contains(attributes.at(ii)))
- endpoint(attributePoints, attributes.at(ii));
- }
- if (usesPercent && !last.values.contains(percentString)) {
- d->_attributePoints.last().values[percentString] = 1;
- interpolate(d->_attributePoints.count() - 1, percentString, 1);
- }
-
-
- // Adjust percent
- qreal length = path.length();
- qreal prevpercent = 0;
- qreal prevorigpercent = 0;
- for (int ii = 0; ii < attributePoints.count(); ++ii) {
- const AttributePoint &point = attributePoints.at(ii);
- if (point.values.contains(percentString)) { //special string for QDeclarativePathPercent
- if ( ii > 0) {
- qreal scale = (attributePoints[ii].origpercent/length - prevorigpercent) /
- (point.values.value(percentString)-prevpercent);
- attributePoints[ii].scale = scale;
- }
- attributePoints[ii].origpercent /= length;
- attributePoints[ii].percent = point.values.value(percentString);
- prevorigpercent = attributePoints[ii].origpercent;
- prevpercent = attributePoints[ii].percent;
- } else {
- attributePoints[ii].origpercent /= length;
- attributePoints[ii].percent = attributePoints[ii].origpercent;
- }
- }
-
- if (closed) {
- QPointF end = path.currentPosition();
- *closed = length > 0 && startX == end.x() && startY == end.y();
- }
- pathLength = length;
-
- return path;
-}
-
-void QDeclarativePath::classBegin()
-{
- Q_D(QDeclarativePath);
- d->componentComplete = false;
-}
-
-void QDeclarativePath::componentComplete()
-{
- Q_D(QDeclarativePath);
- QSet<QString> attrs;
- d->componentComplete = true;
-
- // First gather up all the attributes
- foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
- if (QDeclarativeCurve *curve =
- qobject_cast<QDeclarativeCurve *>(pathElement))
- d->_pathCurves.append(curve);
- else if (QDeclarativePathAttribute *attribute =
- qobject_cast<QDeclarativePathAttribute *>(pathElement))
- attrs.insert(attribute->name());
- }
- d->_attributes = attrs.toList();
-
- processPath();
-
- foreach (QDeclarativePathElement *pathElement, d->_pathElements)
- connect(pathElement, SIGNAL(changed()), this, SLOT(processPath()));
-}
-
-QPainterPath QDeclarativePath::path() const
-{
- Q_D(const QDeclarativePath);
- return d->_path;
-}
-
-QStringList QDeclarativePath::attributes() const
-{
- Q_D(const QDeclarativePath);
- if (!d->componentComplete) {
- QSet<QString> attrs;
-
- // First gather up all the attributes
- foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
- if (QDeclarativePathAttribute *attribute =
- qobject_cast<QDeclarativePathAttribute *>(pathElement))
- attrs.insert(attribute->name());
- }
- return attrs.toList();
- }
- return d->_attributes;
-}
-
-static inline QBezier nextBezier(const QPainterPath &path, int *current, qreal *bezLength, bool reverse = false)
-{
- const int lastElement = reverse ? 0 : path.elementCount() - 1;
- const int start = reverse ? *current - 1 : *current + 1;
- for (int i=start; reverse ? i >= lastElement : i <= lastElement; reverse ? --i : ++i) {
- const QPainterPath::Element &e = path.elementAt(i);
-
- switch (e.type) {
- case QPainterPath::MoveToElement:
- break;
- case QPainterPath::LineToElement:
- {
- QLineF line(path.elementAt(i-1), e);
- *bezLength = line.length();
- QPointF a = path.elementAt(i-1);
- QPointF delta = e - a;
- *current = i;
- return QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e);
- }
- case QPainterPath::CurveToElement:
- {
- QBezier b = QBezier::fromPoints(path.elementAt(i-1),
- e,
- path.elementAt(i+1),
- path.elementAt(i+2));
- *bezLength = b.length();
- *current = i;
- return b;
- }
- default:
- break;
- }
- }
- *current = lastElement;
- *bezLength = 0;
- return QBezier();
-}
-
-//derivative of the equation
-static inline qreal slopeAt(qreal t, qreal a, qreal b, qreal c, qreal d)
-{
- return 3*t*t*(d - 3*c + 3*b - a) + 6*t*(c - 2*b + a) + 3*(b - a);
-}
-
-void QDeclarativePath::createPointCache() const
-{
- Q_D(const QDeclarativePath);
- qreal pathLength = d->pathLength;
- if (pathLength <= 0 || qIsNaN(pathLength))
- return;
- // more points means less jitter between items as they move along the
- // path, but takes longer to generate
- const int points = qCeil(pathLength*5);
- const int lastElement = d->_path.elementCount() - 1;
- d->_pointCache.resize(points+1);
-
- int currElement = -1;
- qreal bezLength = 0;
- QBezier currBez = nextBezier(d->_path, &currElement, &bezLength);
- qreal currLength = bezLength;
- qreal epc = currLength / pathLength;
-
- for (int i = 0; i < d->_pointCache.size(); i++) {
- //find which set we are in
- qreal prevPercent = 0;
- qreal prevOrigPercent = 0;
- for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
- qreal percent = qreal(i)/points;
- const AttributePoint &point = d->_attributePoints.at(ii);
- if (percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item
- qreal elementPercent = (percent - prevPercent);
-
- qreal spc = prevOrigPercent + elementPercent * point.scale;
-
- while (spc > epc) {
- if (currElement > lastElement)
- break;
- currBez = nextBezier(d->_path, &currElement, &bezLength);
- if (bezLength == 0.0) {
- currLength = pathLength;
- epc = 1.0;
- break;
- }
- currLength += bezLength;
- epc = currLength / pathLength;
- }
- qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength;
- d->_pointCache[i] = currBez.pointAt(qBound(qreal(0), realT, qreal(1)));
- break;
- }
- prevOrigPercent = point.origpercent;
- prevPercent = point.percent;
- }
- }
-}
-
-void QDeclarativePath::invalidateSequentialHistory() const
-{
- Q_D(const QDeclarativePath);
- d->prevBez.isValid = false;
-}
-
-QPointF QDeclarativePath::sequentialPointAt(qreal p, qreal *angle) const
-{
- Q_D(const QDeclarativePath);
- return sequentialPointAt(d->_path, d->pathLength, d->_attributePoints, d->prevBez, p, angle);
-}
-
-QPointF QDeclarativePath::sequentialPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QDeclarativeCachedBezier &prevBez, qreal p, qreal *angle)
-{
- if (!prevBez.isValid)
- return p > .5 ? backwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle) :
- forwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle);
-
- return p < prevBez.p ? backwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle) :
- forwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle);
-}
-
-QPointF QDeclarativePath::forwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QDeclarativeCachedBezier &prevBez, qreal p, qreal *angle)
-{
- if (pathLength <= 0 || qIsNaN(pathLength))
- return path.pointAtPercent(0); //expensive?
-
- const int lastElement = path.elementCount() - 1;
- bool haveCachedBez = prevBez.isValid;
- int currElement = haveCachedBez ? prevBez.element : -1;
- qreal bezLength = haveCachedBez ? prevBez.bezLength : 0;
- QBezier currBez = haveCachedBez ? prevBez.bezier : nextBezier(path, &currElement, &bezLength);
- qreal currLength = haveCachedBez ? prevBez.currLength : bezLength;
- qreal epc = currLength / pathLength;
-
- //find which set we are in
- qreal prevPercent = 0;
- qreal prevOrigPercent = 0;
- for (int ii = 0; ii < attributePoints.count(); ++ii) {
- qreal percent = p;
- const AttributePoint &point = attributePoints.at(ii);
- if (percent < point.percent || ii == attributePoints.count() - 1) {
- qreal elementPercent = (percent - prevPercent);
-
- qreal spc = prevOrigPercent + elementPercent * point.scale;
-
- while (spc > epc) {
- Q_ASSERT(!(currElement > lastElement));
- Q_UNUSED(lastElement);
- currBez = nextBezier(path, &currElement, &bezLength);
- currLength += bezLength;
- epc = currLength / pathLength;
- }
- prevBez.element = currElement;
- prevBez.bezLength = bezLength;
- prevBez.currLength = currLength;
- prevBez.bezier = currBez;
- prevBez.p = p;
- prevBez.isValid = true;
-
- qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength;
-
- if (angle) {
- qreal m1 = slopeAt(realT, currBez.x1, currBez.x2, currBez.x3, currBez.x4);
- qreal m2 = slopeAt(realT, currBez.y1, currBez.y2, currBez.y3, currBez.y4);
- *angle = QLineF(0, 0, m1, m2).angle();
- }
-
- return currBez.pointAt(qBound(qreal(0), realT, qreal(1)));
- }
- prevOrigPercent = point.origpercent;
- prevPercent = point.percent;
- }
-
- return QPointF(0,0);
-}
-
-//ideally this should be merged with forwardsPointAt
-QPointF QDeclarativePath::backwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QDeclarativeCachedBezier &prevBez, qreal p, qreal *angle)
-{
- if (pathLength <= 0 || qIsNaN(pathLength))
- return path.pointAtPercent(0);
-
- const int firstElement = 1; //element 0 is always a MoveTo, which we ignore
- bool haveCachedBez = prevBez.isValid;
- int currElement = haveCachedBez ? prevBez.element : path.elementCount();
- qreal bezLength = haveCachedBez ? prevBez.bezLength : 0;
- QBezier currBez = haveCachedBez ? prevBez.bezier : nextBezier(path, &currElement, &bezLength, true /*reverse*/);
- qreal currLength = haveCachedBez ? prevBez.currLength : pathLength;
- qreal prevLength = currLength - bezLength;
- qreal epc = prevLength / pathLength;
-
- for (int ii = attributePoints.count() - 1; ii > 0; --ii) {
- qreal percent = p;
- const AttributePoint &point = attributePoints.at(ii);
- const AttributePoint &prevPoint = attributePoints.at(ii-1);
- if (percent > prevPoint.percent || ii == 1) {
- qreal elementPercent = (percent - prevPoint.percent);
-
- qreal spc = prevPoint.origpercent + elementPercent * point.scale;
-
- while (spc < epc) {
- Q_ASSERT(!(currElement < firstElement));
- Q_UNUSED(firstElement);
- currBez = nextBezier(path, &currElement, &bezLength, true /*reverse*/);
- //special case for first element is to avoid floating point math
- //causing an epc that never hits 0.
- currLength = (currElement == firstElement) ? bezLength : prevLength;
- prevLength = currLength - bezLength;
- epc = prevLength / pathLength;
- }
- prevBez.element = currElement;
- prevBez.bezLength = bezLength;
- prevBez.currLength = currLength;
- prevBez.bezier = currBez;
- prevBez.p = p;
- prevBez.isValid = true;
-
- qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength;
-
- if (angle) {
- qreal m1 = slopeAt(realT, currBez.x1, currBez.x2, currBez.x3, currBez.x4);
- qreal m2 = slopeAt(realT, currBez.y1, currBez.y2, currBez.y3, currBez.y4);
- *angle = QLineF(0, 0, m1, m2).angle();
- }
-
- return currBez.pointAt(qBound(qreal(0), realT, qreal(1)));
- }
- }
-
- return QPointF(0,0);
-}
-
-QPointF QDeclarativePath::pointAt(qreal p) const
-{
- Q_D(const QDeclarativePath);
- if (d->_pointCache.isEmpty()) {
- createPointCache();
- if (d->_pointCache.isEmpty())
- return QPointF();
- }
-
- const int pointCacheSize = d->_pointCache.size();
- qreal idxf = p*pointCacheSize;
- int idx1 = qFloor(idxf);
- qreal delta = idxf - idx1;
- if (idx1 >= pointCacheSize)
- idx1 = pointCacheSize - 1;
- else if (idx1 < 0)
- idx1 = 0;
-
- if (delta == 0.0)
- return d->_pointCache.at(idx1);
-
- // interpolate between the two points.
- int idx2 = qCeil(idxf);
- if (idx2 >= pointCacheSize)
- idx2 = pointCacheSize - 1;
- else if (idx2 < 0)
- idx2 = 0;
-
- QPointF p1 = d->_pointCache.at(idx1);
- QPointF p2 = d->_pointCache.at(idx2);
- QPointF pos = p1 * (1.0-delta) + p2 * delta;
-
- return pos;
-}
-
-qreal QDeclarativePath::attributeAt(const QString &name, qreal percent) const
-{
- Q_D(const QDeclarativePath);
- if (percent < 0 || percent > 1)
- return 0;
-
- for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
- const AttributePoint &point = d->_attributePoints.at(ii);
-
- if (point.percent == percent) {
- return point.values.value(name);
- } else if (point.percent > percent) {
- qreal lastValue =
- ii?(d->_attributePoints.at(ii - 1).values.value(name)):0;
- qreal lastPercent =
- ii?(d->_attributePoints.at(ii - 1).percent):0;
- qreal curValue = point.values.value(name);
- qreal curPercent = point.percent;
-
- return lastValue + (curValue - lastValue) * (percent - lastPercent) / (curPercent - lastPercent);
- }
- }
-
- return 0;
-}
-
-/****************************************************************************/
-
-qreal QDeclarativeCurve::x() const
-{
- return _x.isNull ? 0 : _x.value;
-}
-
-void QDeclarativeCurve::setX(qreal x)
-{
- if (_x.isNull || _x != x) {
- _x = x;
- emit xChanged();
- emit changed();
- }
-}
-
-bool QDeclarativeCurve::hasX()
-{
- return _x.isValid();
-}
-
-qreal QDeclarativeCurve::y() const
-{
- return _y.isNull ? 0 : _y.value;
-}
-
-void QDeclarativeCurve::setY(qreal y)
-{
- if (_y.isNull || _y != y) {
- _y = y;
- emit yChanged();
- emit changed();
- }
-}
-
-bool QDeclarativeCurve::hasY()
-{
- return _y.isValid();
-}
-
-qreal QDeclarativeCurve::relativeX() const
-{
- return _relativeX;
-}
-
-void QDeclarativeCurve::setRelativeX(qreal x)
-{
- if (_relativeX.isNull || _relativeX != x) {
- _relativeX = x;
- emit relativeXChanged();
- emit changed();
- }
-}
-
-bool QDeclarativeCurve::hasRelativeX()
-{
- return _relativeX.isValid();
-}
-
-qreal QDeclarativeCurve::relativeY() const
-{
- return _relativeY;
-}
-
-void QDeclarativeCurve::setRelativeY(qreal y)
-{
- if (_relativeY.isNull || _relativeY != y) {
- _relativeY = y;
- emit relativeYChanged();
- emit changed();
- }
-}
-
-bool QDeclarativeCurve::hasRelativeY()
-{
- return _relativeY.isValid();
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathAttribute QDeclarativePathAttribute
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The PathAttribute allows setting an attribute at a given position in a Path.
-
- The PathAttribute object allows attributes consisting of a name and
- a value to be specified for various points along a path. The
- attributes are exposed to the delegate as
- \l{qdeclarativeintroduction.html#attached-properties} {Attached Properties}.
- The value of an attribute at any particular point along the path is interpolated
- from the PathAttributes bounding that point.
-
- The example below shows a path with the items scaled to 30% with
- opacity 50% at the top of the path and scaled 100% with opacity
- 100% at the bottom. Note the use of the PathView.iconScale and
- PathView.iconOpacity attached properties to set the scale and opacity
- of the delegate.
-
- \table
- \row
- \o \image declarative-pathattribute.png
- \o
- \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 0
- (see the PathView documentation for the specification of ContactModel.qml
- used for ContactModel above.)
- \endtable
-
-
- \sa Path
-*/
-
-/*!
- \qmlproperty string QtQuick2::PathAttribute::name
- This property holds 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.
-*/
-
-/*!
- the name of the attribute to change.
-*/
-
-QString QDeclarativePathAttribute::name() const
-{
- return _name;
-}
-
-void QDeclarativePathAttribute::setName(const QString &name)
-{
- if (_name == name)
- return;
- _name = name;
- emit nameChanged();
-}
-
-/*!
- \qmlproperty real QtQuick2::PathAttribute::value
- This property holds the value for the attribute.
-
- The value specified can be used to influence the visual appearance
- of an item along the path. For example, the following Path specifies
- an attribute named \e itemRotation, which has the value \e 0 at the
- beginning of the path, and the value 90 at the end of the path.
-
- \qml
- Path {
- startX: 0
- startY: 0
- PathAttribute { name: "itemRotation"; value: 0 }
- PathLine { x: 100; y: 100 }
- PathAttribute { name: "itemRotation"; value: 90 }
- }
- \endqml
-
- In our delegate, we can then bind the \e rotation property to the
- \l{qdeclarativeintroduction.html#attached-properties} {Attached Property}
- \e PathView.itemRotation created for this attribute.
-
- \qml
- Rectangle {
- width: 10; height: 10
- rotation: PathView.itemRotation
- }
- \endqml
-
- As each item is positioned along the path, it will be rotated accordingly:
- an item at the beginning of the path with be not be rotated, an item at
- the end of the path will be rotated 90 degrees, and an item mid-way along
- the path will be rotated 45 degrees.
-*/
-
-/*!
- the new value of the attribute.
-*/
-qreal QDeclarativePathAttribute::value() const
-{
- return _value;
-}
-
-void QDeclarativePathAttribute::setValue(qreal value)
-{
- if (_value != value) {
- _value = value;
- emit valueChanged();
- emit changed();
- }
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathLine QDeclarativePathLine
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The PathLine defines a straight line.
-
- The example below creates a path consisting of a straight line from
- 0,100 to 200,100:
-
- \qml
- Path {
- startX: 0; startY: 100
- PathLine { x: 200; y: 100 }
- }
- \endqml
-
- \sa Path, PathQuad, PathCubic, PathArc, PathCurve, PathSvg
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathLine::x
- \qmlproperty real QtQuick2::PathLine::y
-
- Defines the end point of the line.
-
- \sa relativeX, relativeY
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathLine::relativeX
- \qmlproperty real QtQuick2::PathLine::relativeY
-
- Defines the end point of the line relative to its start.
-
- If both a relative and absolute end position are specified for a single axis, the relative
- position will be used.
-
- Relative and absolute positions can be mixed, for example it is valid to set a relative x
- and an absolute y.
-
- \sa x, y
-*/
-
-inline QPointF positionForCurve(const QDeclarativePathData &data, const QPointF &prevPoint)
-{
- QDeclarativeCurve *curve = data.curves.at(data.index);
- bool isEnd = data.index == data.curves.size() - 1;
- return QPointF(curve->hasRelativeX() ? prevPoint.x() + curve->relativeX() : !isEnd || curve->hasX() ? curve->x() : data.endPoint.x(),
- curve->hasRelativeY() ? prevPoint.y() + curve->relativeY() : !isEnd || curve->hasY() ? curve->y() : data.endPoint.y());
-}
-
-void QDeclarativePathLine::addToPath(QPainterPath &path, const QDeclarativePathData &data)
-{
- path.lineTo(positionForCurve(data, path.currentPosition()));
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathQuad QDeclarativePathQuad
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The PathQuad defines a quadratic Bezier curve with a control point.
-
- The following QML produces the path shown below:
- \table
- \row
- \o \image declarative-pathquad.png
- \o
- \qml
- Path {
- startX: 0; startY: 0
- PathQuad { x: 200; y: 0; controlX: 100; controlY: 150 }
- }
- \endqml
- \endtable
-
- \sa Path, PathCubic, PathLine, PathArc, PathCurve, PathSvg
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathQuad::x
- \qmlproperty real QtQuick2::PathQuad::y
-
- Defines the end point of the curve.
-
- \sa relativeX, relativeY
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathQuad::relativeX
- \qmlproperty real QtQuick2::PathQuad::relativeY
-
- Defines the end point of the curve relative to its start.
-
- If both a relative and absolute end position are specified for a single axis, the relative
- position will be used.
-
- Relative and absolute positions can be mixed, for example it is valid to set a relative x
- and an absolute y.
-
- \sa x, y
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathQuad::controlX
- \qmlproperty real QtQuick2::PathQuad::controlY
-
- Defines the position of the control point.
-*/
-
-/*!
- the x position of the control point.
-*/
-qreal QDeclarativePathQuad::controlX() const
-{
- return _controlX;
-}
-
-void QDeclarativePathQuad::setControlX(qreal x)
-{
- if (_controlX != x) {
- _controlX = x;
- emit controlXChanged();
- emit changed();
- }
-}
-
-
-/*!
- the y position of the control point.
-*/
-qreal QDeclarativePathQuad::controlY() const
-{
- return _controlY;
-}
-
-void QDeclarativePathQuad::setControlY(qreal y)
-{
- if (_controlY != y) {
- _controlY = y;
- emit controlYChanged();
- emit changed();
- }
-}
-
-/*!
- \qmlproperty real QtQuick2::PathCubic::relativeControlX
- \qmlproperty real QtQuick2::PathCubic::relativeControlY
-
- Defines the position of the control point relative to the curve's start.
-
- If both a relative and absolute control position are specified for a single axis, the relative
- position will be used.
-
- Relative and absolute positions can be mixed, for example it is valid to set a relative control x
- and an absolute control y.
-
- \sa controlX, controlY
-*/
-
-qreal QDeclarativePathQuad::relativeControlX() const
-{
- return _relativeControlX;
-}
-
-void QDeclarativePathQuad::setRelativeControlX(qreal x)
-{
- if (_relativeControlX.isNull || _relativeControlX != x) {
- _relativeControlX = x;
- emit relativeControlXChanged();
- emit changed();
- }
-}
-
-bool QDeclarativePathQuad::hasRelativeControlX()
-{
- return _relativeControlX.isValid();
-}
-
-qreal QDeclarativePathQuad::relativeControlY() const
-{
- return _relativeControlY;
-}
-
-void QDeclarativePathQuad::setRelativeControlY(qreal y)
-{
- if (_relativeControlY.isNull || _relativeControlY != y) {
- _relativeControlY = y;
- emit relativeControlYChanged();
- emit changed();
- }
-}
-
-bool QDeclarativePathQuad::hasRelativeControlY()
-{
- return _relativeControlY.isValid();
-}
-
-void QDeclarativePathQuad::addToPath(QPainterPath &path, const QDeclarativePathData &data)
-{
- const QPointF &prevPoint = path.currentPosition();
- QPointF controlPoint(hasRelativeControlX() ? prevPoint.x() + relativeControlX() : controlX(),
- hasRelativeControlY() ? prevPoint.y() + relativeControlY() : controlY());
- path.quadTo(controlPoint, positionForCurve(data, path.currentPosition()));
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathCubic QDeclarativePathCubic
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The PathCubic defines a cubic Bezier curve with two control points.
-
- The following QML produces the path shown below:
- \table
- \row
- \o \image declarative-pathcubic.png
- \o
- \qml
- Path {
- startX: 20; startY: 0
- PathCubic {
- x: 180; y: 0
- control1X: -10; control1Y: 90
- control2X: 210; control2Y: 90
- }
- }
- \endqml
- \endtable
-
- \sa Path, PathQuad, PathLine, PathArc, PathCurve, PathSvg
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathCubic::x
- \qmlproperty real QtQuick2::PathCubic::y
-
- Defines the end point of the curve.
-
- \sa relativeX, relativeY
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathCubic::relativeX
- \qmlproperty real QtQuick2::PathCubic::relativeY
-
- Defines the end point of the curve relative to its start.
-
- If both a relative and absolute end position are specified for a single axis, the relative
- position will be used.
-
- Relative and absolute positions can be mixed, for example it is valid to set a relative x
- and an absolute y.
-
- \sa x, y
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathCubic::control1X
- \qmlproperty real QtQuick2::PathCubic::control1Y
-
- Defines the position of the first control point.
-*/
-qreal QDeclarativePathCubic::control1X() const
-{
- return _control1X;
-}
-
-void QDeclarativePathCubic::setControl1X(qreal x)
-{
- if (_control1X != x) {
- _control1X = x;
- emit control1XChanged();
- emit changed();
- }
-}
-
-qreal QDeclarativePathCubic::control1Y() const
-{
- return _control1Y;
-}
-
-void QDeclarativePathCubic::setControl1Y(qreal y)
-{
- if (_control1Y != y) {
- _control1Y = y;
- emit control1YChanged();
- emit changed();
- }
-}
-
-/*!
- \qmlproperty real QtQuick2::PathCubic::control2X
- \qmlproperty real QtQuick2::PathCubic::control2Y
-
- Defines the position of the second control point.
-*/
-qreal QDeclarativePathCubic::control2X() const
-{
- return _control2X;
-}
-
-void QDeclarativePathCubic::setControl2X(qreal x)
-{
- if (_control2X != x) {
- _control2X = x;
- emit control2XChanged();
- emit changed();
- }
-}
-
-qreal QDeclarativePathCubic::control2Y() const
-{
- return _control2Y;
-}
-
-void QDeclarativePathCubic::setControl2Y(qreal y)
-{
- if (_control2Y != y) {
- _control2Y = y;
- emit control2YChanged();
- emit changed();
- }
-}
-
-/*!
- \qmlproperty real QtQuick2::PathCubic::relativeControl1X
- \qmlproperty real QtQuick2::PathCubic::relativeControl1Y
- \qmlproperty real QtQuick2::PathCubic::relativeControl2X
- \qmlproperty real QtQuick2::PathCubic::relativeControl2Y
-
- Defines the positions of the control points relative to the curve's start.
-
- If both a relative and absolute control position are specified for a control point's axis, the relative
- position will be used.
-
- Relative and absolute positions can be mixed, for example it is valid to set a relative control1 x
- and an absolute control1 y.
-
- \sa control1X, control1Y, control2X, control2Y
-*/
-
-qreal QDeclarativePathCubic::relativeControl1X() const
-{
- return _relativeControl1X;
-}
-
-void QDeclarativePathCubic::setRelativeControl1X(qreal x)
-{
- if (_relativeControl1X.isNull || _relativeControl1X != x) {
- _relativeControl1X = x;
- emit relativeControl1XChanged();
- emit changed();
- }
-}
-
-bool QDeclarativePathCubic::hasRelativeControl1X()
-{
- return _relativeControl1X.isValid();
-}
-
-qreal QDeclarativePathCubic::relativeControl1Y() const
-{
- return _relativeControl1Y;
-}
-
-void QDeclarativePathCubic::setRelativeControl1Y(qreal y)
-{
- if (_relativeControl1Y.isNull || _relativeControl1Y != y) {
- _relativeControl1Y = y;
- emit relativeControl1YChanged();
- emit changed();
- }
-}
-
-bool QDeclarativePathCubic::hasRelativeControl1Y()
-{
- return _relativeControl1Y.isValid();
-}
-
-qreal QDeclarativePathCubic::relativeControl2X() const
-{
- return _relativeControl2X;
-}
-
-void QDeclarativePathCubic::setRelativeControl2X(qreal x)
-{
- if (_relativeControl2X.isNull || _relativeControl2X != x) {
- _relativeControl2X = x;
- emit relativeControl2XChanged();
- emit changed();
- }
-}
-
-bool QDeclarativePathCubic::hasRelativeControl2X()
-{
- return _relativeControl2X.isValid();
-}
-
-qreal QDeclarativePathCubic::relativeControl2Y() const
-{
- return _relativeControl2Y;
-}
-
-void QDeclarativePathCubic::setRelativeControl2Y(qreal y)
-{
- if (_relativeControl2Y.isNull || _relativeControl2Y != y) {
- _relativeControl2Y = y;
- emit relativeControl2YChanged();
- emit changed();
- }
-}
-
-bool QDeclarativePathCubic::hasRelativeControl2Y()
-{
- return _relativeControl2Y.isValid();
-}
-
-void QDeclarativePathCubic::addToPath(QPainterPath &path, const QDeclarativePathData &data)
-{
- const QPointF &prevPoint = path.currentPosition();
- QPointF controlPoint1(hasRelativeControl1X() ? prevPoint.x() + relativeControl1X() : control1X(),
- hasRelativeControl1Y() ? prevPoint.y() + relativeControl1Y() : control1Y());
- QPointF controlPoint2(hasRelativeControl2X() ? prevPoint.x() + relativeControl2X() : control2X(),
- hasRelativeControl2Y() ? prevPoint.y() + relativeControl2Y() : control2Y());
- path.cubicTo(controlPoint1, controlPoint2, positionForCurve(data, path.currentPosition()));
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathCurve QDeclarativePathCurve
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The PathCurve defines a point on a Catmull-Rom curve.
-
- PathCurve provides an easy way to specify a curve passing directly through a set of points.
- Typically multiple PathCurves are used in a series, as the following example demonstrates:
-
- \snippet doc/src/snippets/declarative/path/basiccurve.qml 0
-
- This example produces the following path (with the starting point and PathCurve points
- highlighted in red):
-
- \image declarative-pathcurve.png
-
- \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathSvg
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathCurve::x
- \qmlproperty real QtQuick2::PathCurve::y
-
- Defines the end point of the curve.
-
- \sa relativeX, relativeY
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathCurve::relativeX
- \qmlproperty real QtQuick2::PathCurve::relativeY
-
- Defines the end point of the curve relative to its start.
-
- If both a relative and absolute end position are specified for a single axis, the relative
- position will be used.
-
- Relative and absolute positions can be mixed, for example it is valid to set a relative x
- and an absolute y.
-
- \sa x, y
-*/
-
-inline QPointF previousPathPosition(const QPainterPath &path)
-{
- int count = path.elementCount();
- if (count < 1)
- return QPointF();
-
- int index = path.elementAt(count-1).type == QPainterPath::CurveToDataElement ? count - 4 : count - 2;
- return index > -1 ? QPointF(path.elementAt(index)) : path.pointAtPercent(0);
-}
-
-void QDeclarativePathCatmullRomCurve::addToPath(QPainterPath &path, const QDeclarativePathData &data)
-{
- //here we convert catmull-rom spline to bezier for use in QPainterPath.
- //basic conversion algorithm:
- // catmull-rom points * inverse bezier matrix * catmull-rom matrix = bezier points
- //each point in the catmull-rom spline produces a bezier endpoint + 2 control points
- //calculations for each point use a moving window of 4 points
- // (previous 2 points + current point + next point)
- QPointF prevFar, prev, point, next;
-
- //get previous points
- int index = data.index - 1;
- QDeclarativeCurve *curve = index == -1 ? 0 : data.curves.at(index);
- if (qobject_cast<QDeclarativePathCatmullRomCurve*>(curve)) {
- prev = path.currentPosition();
- prevFar = previousPathPosition(path);
- } else {
- prev = path.currentPosition();
- bool prevFarSet = false;
- if (index == -1 && data.curves.count() > 1) {
- if (qobject_cast<QDeclarativePathCatmullRomCurve*>(data.curves.at(data.curves.count()-1))) {
- //TODO: profile and optimize
- QPointF pos = prev;
- QDeclarativePathData loopData;
- loopData.endPoint = data.endPoint;
- loopData.curves = data.curves;
- for (int i = data.index; i < data.curves.count(); ++i) {
- loopData.index = i;
- pos = positionForCurve(loopData, pos);
- if (i == data.curves.count()-2)
- prevFar = pos;
- }
- if (pos == QPointF(path.elementAt(0))) {
- //this is a closed path starting and ending with catmull-rom segments.
- //we try to smooth the join point
- prevFarSet = true;
- }
- }
- }
- if (!prevFarSet)
- prevFar = prev;
- }
-
- //get current point
- point = positionForCurve(data, path.currentPosition());
-
- //get next point
- index = data.index + 1;
- if (index < data.curves.count() && qobject_cast<QDeclarativePathCatmullRomCurve*>(data.curves.at(index))) {
- QDeclarativePathData nextData;
- nextData.index = index;
- nextData.endPoint = data.endPoint;
- nextData.curves = data.curves;
- next = positionForCurve(nextData, point);
- } else {
- if (point == QPointF(path.elementAt(0)) && qobject_cast<QDeclarativePathCatmullRomCurve*>(data.curves.at(0))) {
- //this is a closed path starting and ending with catmull-rom segments.
- //we try to smooth the join point
- next = QPointF(path.elementAt(3)); //the first catmull-rom point
- } else
- next = point;
- }
-
- /*
- full conversion matrix (inverse bezier * catmull-rom):
- 0.000, 1.000, 0.000, 0.000,
- -0.167, 1.000, 0.167, 0.000,
- 0.000, 0.167, 1.000, -0.167,
- 0.000, 0.000, 1.000, 0.000
-
- conversion doesn't require full matrix multiplication,
- so below we simplify
- */
- QPointF control1(prevFar.x() * qreal(-0.167) +
- prev.x() +
- point.x() * qreal(0.167),
- prevFar.y() * qreal(-0.167) +
- prev.y() +
- point.y() * qreal(0.167));
-
- QPointF control2(prev.x() * qreal(0.167) +
- point.x() +
- next.x() * qreal(-0.167),
- prev.y() * qreal(0.167) +
- point.y() +
- next.y() * qreal(-0.167));
-
- path.cubicTo(control1, control2, point);
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathArc QDeclarativePathArc
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The PathArc defines an arc with the given radius.
-
- PathArc provides a simple way of specifying an arc that ends at a given position
- and uses the specified radius. It is modeled after the SVG elliptical arc command.
-
- The following QML produces the path shown below:
- \table
- \row
- \o \image declarative-patharc.png
- \o \snippet doc/src/snippets/declarative/path/basicarc.qml 0
- \endtable
-
- Note that a single PathArc cannot be used to specify a circle. Instead, you can
- use two PathArc elements, each specifying half of the circle.
-
- \sa Path, PathLine, PathQuad, PathCubic, PathCurve, PathSvg
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathArc::x
- \qmlproperty real QtQuick2::PathArc::y
-
- Defines the end point of the arc.
-
- \sa relativeX, relativeY
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathArc::relativeX
- \qmlproperty real QtQuick2::PathArc::relativeY
-
- Defines the end point of the arc relative to its start.
-
- If both a relative and absolute end position are specified for a single axis, the relative
- position will be used.
-
- Relative and absolute positions can be mixed, for example it is valid to set a relative x
- and an absolute y.
-
- \sa x, y
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathArc::radiusX
- \qmlproperty real QtQuick2::PathArc::radiusY
-
- Defines the radius of the arc.
-
- The following QML demonstrates how different radius values can be used to change
- the shape of the arc:
- \table
- \row
- \o \image declarative-arcradius.png
- \o \snippet doc/src/snippets/declarative/path/arcradius.qml 0
- \endtable
-*/
-
-qreal QDeclarativePathArc::radiusX() const
-{
- return _radiusX;
-}
-
-void QDeclarativePathArc::setRadiusX(qreal radius)
-{
- if (_radiusX == radius)
- return;
-
- _radiusX = radius;
- emit radiusXChanged();
-}
-
-qreal QDeclarativePathArc::radiusY() const
-{
- return _radiusY;
-}
-
-void QDeclarativePathArc::setRadiusY(qreal radius)
-{
- if (_radiusY == radius)
- return;
-
- _radiusY = radius;
- emit radiusYChanged();
-}
-
-/*!
- \qmlproperty bool QtQuick2::PathArc::useLargeArc
- Whether to use a large arc as defined by the arc points.
-
- Given fixed start and end positions, radius, and direction,
- there are two possible arcs that can fit the data. useLargeArc
- is used to distinguish between these. For example, the following
- QML can produce either of the two illustrated arcs below by
- changing the value of useLargeArc.
-
- \table
- \row
- \o \image declarative-largearc.png
- \o \snippet doc/src/snippets/declarative/path/largearc.qml 0
- \endtable
-
- The default value is false.
-*/
-
-bool QDeclarativePathArc::useLargeArc() const
-{
- return _useLargeArc;
-}
-
-void QDeclarativePathArc::setUseLargeArc(bool largeArc)
-{
- if (_useLargeArc == largeArc)
- return;
-
- _useLargeArc = largeArc;
- emit useLargeArcChanged();
-}
-
-/*!
- \qmlproperty enum QtQuick2::PathArc::direction
-
- Defines the direction of the arc. Possible values are
- PathArc.Clockwise (default) and PathArc.Counterclockwise.
-
- The following QML can produce either of the two illustrated arcs below
- by changing the value of direction.
- \table
- \row
- \o \image declarative-arcdirection.png
- \o \snippet doc/src/snippets/declarative/path/arcdirection.qml 0
- \endtable
-
- \sa useLargeArc
-*/
-
-QDeclarativePathArc::ArcDirection QDeclarativePathArc::direction() const
-{
- return _direction;
-}
-
-void QDeclarativePathArc::setDirection(ArcDirection direction)
-{
- if (_direction == direction)
- return;
-
- _direction = direction;
- emit directionChanged();
-}
-
-void QDeclarativePathArc::addToPath(QPainterPath &path, const QDeclarativePathData &data)
-{
- const QPointF &startPoint = path.currentPosition();
- const QPointF &endPoint = positionForCurve(data, startPoint);
- QDeclarativeSvgParser::pathArc(path,
- _radiusX,
- _radiusY,
- 0, //xAxisRotation
- _useLargeArc,
- _direction == Clockwise ? 1 : 0,
- endPoint.x(),
- endPoint.y(),
- startPoint.x(), startPoint.y());
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathSvg QDeclarativePathSvg
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The PathSvg defines a path using an SVG path data string.
-
- The following QML produces the path shown below:
- \table
- \row
- \o \image declarative-pathsvg.png
- \o
- \qml
- Path {
- startX: 50; startY: 50
- PathSvg { path: "L 150 50 L 100 150 z" }
- }
- \endqml
- \endtable
-
- \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathCurve
-*/
-
-/*!
- \qmlproperty string QtQuick2::PathSvg::path
-
- The SVG path data string specifying the path.
-
- See \l {http://www.w3.org/TR/SVG/paths.html#PathData}{W3C SVG Path Data}
- for more details on this format.
-*/
-
-QString QDeclarativePathSvg::path() const
-{
- return _path;
-}
-
-void QDeclarativePathSvg::setPath(const QString &path)
-{
- if (_path == path)
- return;
-
- _path = path;
- emit pathChanged();
-}
-
-void QDeclarativePathSvg::addToPath(QPainterPath &path, const QDeclarativePathData &)
-{
- QDeclarativeSvgParser::parsePathDataFast(_path, path);
-}
-
-/****************************************************************************/
-
-/*!
- \qmlclass PathPercent QDeclarativePathPercent
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The PathPercent manipulates the way a path is interpreted.
-
- PathPercent allows you to manipulate the spacing between items on a
- PathView's path. You can use it to bunch together items on part of
- the path, and spread them out on other parts of the path.
-
- The examples below show the normal distribution of items along a path
- compared to a distribution which places 50% of the items along the
- PathLine section of the path.
- \table
- \row
- \o \image declarative-nopercent.png
- \o
- \qml
- PathView {
- // ...
- Path {
- startX: 20; startY: 0
- PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
- PathLine { x: 150; y: 80 }
- PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 }
- }
- }
- \endqml
- \row
- \o \image declarative-percent.png
- \o
- \qml
- PathView {
- // ...
- Path {
- startX: 20; startY: 0
- PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
- PathPercent { value: 0.25 }
- PathLine { x: 150; y: 80 }
- PathPercent { value: 0.75 }
- PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 }
- PathPercent { value: 1 }
- }
- }
- \endqml
- \endtable
-
- \sa Path
-*/
-
-/*!
- \qmlproperty real QtQuick2::PathPercent::value
- The proportion of items that should be laid out up to this point.
-
- This value should always be higher than the last value specified
- by a PathPercent at a previous position in the Path.
-
- In the following example we have a Path made up of three PathLines.
- Normally, the items of the PathView would be laid out equally along
- this path, with an equal number of items per line segment. PathPercent
- allows us to specify that the first and third lines should each hold
- 10% of the laid out items, while the second line should hold the remaining
- 80%.
-
- \qml
- PathView {
- // ...
- Path {
- startX: 0; startY: 0
- PathLine { x:100; y: 0; }
- PathPercent { value: 0.1 }
- PathLine { x: 100; y: 100 }
- PathPercent { value: 0.9 }
- PathLine { x: 100; y: 0 }
- PathPercent { value: 1 }
- }
- }
- \endqml
-*/
-
-qreal QDeclarativePathPercent::value() const
-{
- return _value;
-}
-
-void QDeclarativePathPercent::setValue(qreal value)
-{
- if (_value != value) {
- _value = value;
- emit valueChanged();
- emit changed();
- }
-}
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativepath_p.h b/src/quick/util/qdeclarativepath_p.h
deleted file mode 100644
index 7dc2c47990..0000000000
--- a/src/quick/util/qdeclarativepath_p.h
+++ /dev/null
@@ -1,451 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPATH_H
-#define QDECLARATIVEPATH_H
-
-#include <qdeclarative.h>
-
-#include <private/qdeclarativenullablevalue_p_p.h>
-#include <private/qbezier_p.h>
-
-#include <QtCore/QObject>
-#include <QtGui/QPainterPath>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeCurve;
-struct QDeclarativePathData
-{
- int index;
- QPointF endPoint;
- QList<QDeclarativeCurve*> curves;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathElement : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativePathElement(QObject *parent=0) : QObject(parent) {}
-Q_SIGNALS:
- void changed();
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathAttribute : public QDeclarativePathElement
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
-public:
- QDeclarativePathAttribute(QObject *parent=0) : QDeclarativePathElement(parent), _value(0) {}
-
-
- QString name() const;
- void setName(const QString &name);
-
- qreal value() const;
- void setValue(qreal value);
-
-Q_SIGNALS:
- void nameChanged();
- void valueChanged();
-
-private:
- QString _name;
- qreal _value;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeCurve : public QDeclarativePathElement
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
- Q_PROPERTY(qreal relativeX READ relativeX WRITE setRelativeX NOTIFY relativeXChanged)
- Q_PROPERTY(qreal relativeY READ relativeY WRITE setRelativeY NOTIFY relativeYChanged)
-public:
- QDeclarativeCurve(QObject *parent=0) : QDeclarativePathElement(parent) {}
-
- qreal x() const;
- void setX(qreal x);
- bool hasX();
-
- qreal y() const;
- void setY(qreal y);
- bool hasY();
-
- qreal relativeX() const;
- void setRelativeX(qreal x);
- bool hasRelativeX();
-
- qreal relativeY() const;
- void setRelativeY(qreal y);
- bool hasRelativeY();
-
- virtual void addToPath(QPainterPath &, const QDeclarativePathData &) {}
-
-Q_SIGNALS:
- void xChanged();
- void yChanged();
- void relativeXChanged();
- void relativeYChanged();
-
-private:
- QDeclarativeNullableValue<qreal> _x;
- QDeclarativeNullableValue<qreal> _y;
- QDeclarativeNullableValue<qreal> _relativeX;
- QDeclarativeNullableValue<qreal> _relativeY;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathLine : public QDeclarativeCurve
-{
- Q_OBJECT
-public:
- QDeclarativePathLine(QObject *parent=0) : QDeclarativeCurve(parent) {}
-
- void addToPath(QPainterPath &path, const QDeclarativePathData &);
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathQuad : public QDeclarativeCurve
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY controlXChanged)
- Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY controlYChanged)
- Q_PROPERTY(qreal relativeControlX READ relativeControlX WRITE setRelativeControlX NOTIFY relativeControlXChanged)
- Q_PROPERTY(qreal relativeControlY READ relativeControlY WRITE setRelativeControlY NOTIFY relativeControlYChanged)
-public:
- QDeclarativePathQuad(QObject *parent=0) : QDeclarativeCurve(parent), _controlX(0), _controlY(0) {}
-
- qreal controlX() const;
- void setControlX(qreal x);
-
- qreal controlY() const;
- void setControlY(qreal y);
-
- qreal relativeControlX() const;
- void setRelativeControlX(qreal x);
- bool hasRelativeControlX();
-
- qreal relativeControlY() const;
- void setRelativeControlY(qreal y);
- bool hasRelativeControlY();
-
- void addToPath(QPainterPath &path, const QDeclarativePathData &);
-
-Q_SIGNALS:
- void controlXChanged();
- void controlYChanged();
- void relativeControlXChanged();
- void relativeControlYChanged();
-
-private:
- qreal _controlX;
- qreal _controlY;
- QDeclarativeNullableValue<qreal> _relativeControlX;
- QDeclarativeNullableValue<qreal> _relativeControlY;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathCubic : public QDeclarativeCurve
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal control1X READ control1X WRITE setControl1X NOTIFY control1XChanged)
- Q_PROPERTY(qreal control1Y READ control1Y WRITE setControl1Y NOTIFY control1YChanged)
- Q_PROPERTY(qreal control2X READ control2X WRITE setControl2X NOTIFY control2XChanged)
- Q_PROPERTY(qreal control2Y READ control2Y WRITE setControl2Y NOTIFY control2YChanged)
- Q_PROPERTY(qreal relativeControl1X READ relativeControl1X WRITE setRelativeControl1X NOTIFY relativeControl1XChanged)
- Q_PROPERTY(qreal relativeControl1Y READ relativeControl1Y WRITE setRelativeControl1Y NOTIFY relativeControl1YChanged)
- Q_PROPERTY(qreal relativeControl2X READ relativeControl2X WRITE setRelativeControl2X NOTIFY relativeControl2XChanged)
- Q_PROPERTY(qreal relativeControl2Y READ relativeControl2Y WRITE setRelativeControl2Y NOTIFY relativeControl2YChanged)
-public:
- QDeclarativePathCubic(QObject *parent=0) : QDeclarativeCurve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {}
-
- qreal control1X() const;
- void setControl1X(qreal x);
-
- qreal control1Y() const;
- void setControl1Y(qreal y);
-
- qreal control2X() const;
- void setControl2X(qreal x);
-
- qreal control2Y() const;
- void setControl2Y(qreal y);
-
- qreal relativeControl1X() const;
- void setRelativeControl1X(qreal x);
- bool hasRelativeControl1X();
-
- qreal relativeControl1Y() const;
- void setRelativeControl1Y(qreal y);
- bool hasRelativeControl1Y();
-
- qreal relativeControl2X() const;
- void setRelativeControl2X(qreal x);
- bool hasRelativeControl2X();
-
- qreal relativeControl2Y() const;
- void setRelativeControl2Y(qreal y);
- bool hasRelativeControl2Y();
-
- void addToPath(QPainterPath &path, const QDeclarativePathData &);
-
-Q_SIGNALS:
- void control1XChanged();
- void control1YChanged();
- void control2XChanged();
- void control2YChanged();
- void relativeControl1XChanged();
- void relativeControl1YChanged();
- void relativeControl2XChanged();
- void relativeControl2YChanged();
-
-private:
- qreal _control1X;
- qreal _control1Y;
- qreal _control2X;
- qreal _control2Y;
- QDeclarativeNullableValue<qreal> _relativeControl1X;
- QDeclarativeNullableValue<qreal> _relativeControl1Y;
- QDeclarativeNullableValue<qreal> _relativeControl2X;
- QDeclarativeNullableValue<qreal> _relativeControl2Y;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathCatmullRomCurve : public QDeclarativeCurve
-{
- Q_OBJECT
-public:
- QDeclarativePathCatmullRomCurve(QObject *parent=0) : QDeclarativeCurve(parent) {}
-
- void addToPath(QPainterPath &path, const QDeclarativePathData &);
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathArc : public QDeclarativeCurve
-{
- Q_OBJECT
- Q_PROPERTY(qreal radiusX READ radiusX WRITE setRadiusX NOTIFY radiusXChanged)
- Q_PROPERTY(qreal radiusY READ radiusY WRITE setRadiusY NOTIFY radiusYChanged)
- Q_PROPERTY(bool useLargeArc READ useLargeArc WRITE setUseLargeArc NOTIFY useLargeArcChanged)
- Q_PROPERTY(ArcDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
-
-public:
- QDeclarativePathArc(QObject *parent=0)
- : QDeclarativeCurve(parent), _radiusX(0), _radiusY(0), _useLargeArc(false), _direction(Clockwise) {}
-
- enum ArcDirection { Clockwise, Counterclockwise };
- Q_ENUMS(ArcDirection)
-
- qreal radiusX() const;
- void setRadiusX(qreal);
-
- qreal radiusY() const;
- void setRadiusY(qreal);
-
- bool useLargeArc() const;
- void setUseLargeArc(bool);
-
- ArcDirection direction() const;
- void setDirection(ArcDirection direction);
-
- void addToPath(QPainterPath &path, const QDeclarativePathData &);
-
-Q_SIGNALS:
- void radiusXChanged();
- void radiusYChanged();
- void useLargeArcChanged();
- void directionChanged();
-
-private:
- qreal _radiusX;
- qreal _radiusY;
- bool _useLargeArc;
- ArcDirection _direction;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathSvg : public QDeclarativeCurve
-{
- Q_OBJECT
- Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
-public:
- QDeclarativePathSvg(QObject *parent=0) : QDeclarativeCurve(parent) {}
-
- QString path() const;
- void setPath(const QString &path);
-
- void addToPath(QPainterPath &path, const QDeclarativePathData &);
-
-Q_SIGNALS:
- void pathChanged();
-
-private:
- QString _path;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativePathPercent : public QDeclarativePathElement
-{
- Q_OBJECT
- Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
-public:
- QDeclarativePathPercent(QObject *parent=0) : QDeclarativePathElement(parent) {}
-
- qreal value() const;
- void setValue(qreal value);
-
-signals:
- void valueChanged();
-
-private:
- qreal _value;
-};
-
-struct QDeclarativeCachedBezier
-{
- QDeclarativeCachedBezier() : isValid(false) {}
- QBezier bezier;
- int element;
- qreal bezLength;
- qreal currLength;
- qreal p;
- bool isValid;
-};
-
-class QDeclarativePathPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativePath : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
-
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativePathElement> pathElements READ pathElements)
- Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged)
- Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged)
- Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
- Q_CLASSINFO("DefaultProperty", "pathElements")
- Q_INTERFACES(QDeclarativeParserStatus)
-public:
- QDeclarativePath(QObject *parent=0);
- ~QDeclarativePath();
-
- QDeclarativeListProperty<QDeclarativePathElement> pathElements();
-
- qreal startX() const;
- void setStartX(qreal x);
- bool hasStartX() const;
-
- qreal startY() const;
- void setStartY(qreal y);
- bool hasStartY() const;
-
- bool isClosed() const;
- bool hasEnd() const;
-
- QPainterPath path() const;
- QStringList attributes() const;
- qreal attributeAt(const QString &, qreal) const;
- QPointF pointAt(qreal) const;
- QPointF sequentialPointAt(qreal p, qreal *angle = 0) const;
- void invalidateSequentialHistory() const;
-
-Q_SIGNALS:
- void changed();
- void startXChanged();
- void startYChanged();
-
-protected:
- virtual void componentComplete();
- virtual void classBegin();
-
-private Q_SLOTS:
- void processPath();
-
-private:
- struct AttributePoint {
- AttributePoint() : percent(0), scale(1), origpercent(0) {}
- AttributePoint(const AttributePoint &other)
- : percent(other.percent), scale(other.scale), origpercent(other.origpercent), values(other.values) {}
- AttributePoint &operator=(const AttributePoint &other) {
- percent = other.percent; scale = other.scale; origpercent = other.origpercent; values = other.values; return *this;
- }
- qreal percent; //massaged percent along the painter path
- qreal scale;
- qreal origpercent; //'real' percent along the painter path
- QHash<QString, qreal> values;
- };
-
- void interpolate(int idx, const QString &name, qreal value);
- void endpoint(const QString &name);
- void createPointCache() const;
-
- static void interpolate(QList<AttributePoint> &points, int idx, const QString &name, qreal value);
- static void endpoint(QList<AttributePoint> &attributePoints, const QString &name);
- static QPointF forwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QDeclarativeCachedBezier &prevBez, qreal p, qreal *angle = 0);
- static QPointF backwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QDeclarativeCachedBezier &prevBez, qreal p, qreal *angle = 0);
-
-private:
- Q_DISABLE_COPY(QDeclarativePath)
- Q_DECLARE_PRIVATE(QDeclarativePath)
- friend class QQuickPathAnimationUpdater;
-
-public:
- QPainterPath createPath(const QPointF &startPoint, const QPointF &endPoint, const QStringList &attributes, qreal &pathLength, QList<AttributePoint> &attributePoints, bool *closed = 0);
- static QPointF sequentialPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QDeclarativeCachedBezier &prevBez, qreal p, qreal *angle = 0);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativePathElement)
-QML_DECLARE_TYPE(QDeclarativePathAttribute)
-QML_DECLARE_TYPE(QDeclarativeCurve)
-QML_DECLARE_TYPE(QDeclarativePathLine)
-QML_DECLARE_TYPE(QDeclarativePathQuad)
-QML_DECLARE_TYPE(QDeclarativePathCubic)
-QML_DECLARE_TYPE(QDeclarativePathCatmullRomCurve)
-QML_DECLARE_TYPE(QDeclarativePathArc)
-QML_DECLARE_TYPE(QDeclarativePathSvg)
-QML_DECLARE_TYPE(QDeclarativePathPercent)
-QML_DECLARE_TYPE(QDeclarativePath)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPATH_H
diff --git a/src/quick/util/qdeclarativepath_p_p.h b/src/quick/util/qdeclarativepath_p_p.h
deleted file mode 100644
index f02ab79e19..0000000000
--- a/src/quick/util/qdeclarativepath_p_p.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPATH_P_H
-#define QDECLARATIVEPATH_P_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 "qdeclarativepath_p.h"
-
-#include <qdeclarative.h>
-#include <QtCore/QStringList>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativePathPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativePath)
-
-public:
- QDeclarativePathPrivate() : pathLength(0), closed(false), componentComplete(true) { }
-
- QPainterPath _path;
- QList<QDeclarativePathElement*> _pathElements;
- mutable QVector<QPointF> _pointCache;
- QList<QDeclarativePath::AttributePoint> _attributePoints;
- QStringList _attributes;
- QList<QDeclarativeCurve*> _pathCurves;
- mutable QDeclarativeCachedBezier prevBez;
- QDeclarativeNullableValue<qreal> startX;
- QDeclarativeNullableValue<qreal> startY;
- qreal pathLength;
- bool closed;
- bool componentComplete;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/quick/util/qdeclarativepathinterpolator.cpp b/src/quick/util/qdeclarativepathinterpolator.cpp
deleted file mode 100644
index 7550d54159..0000000000
--- a/src/quick/util/qdeclarativepathinterpolator.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepathinterpolator_p.h"
-
-#include "qdeclarativepath_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass PathInterpolator QQuickPathInterpolator
- \inqmlmodule QtQuick 2
- \brief The PathInterpolator element provides a way to manually animate along a path.
-
- PathInterpolator provides \c x, \c y, and \c angle information for a particular \c progress
- along a path.
-
- In the following example, we animate a green rectangle along a bezier path.
-
- \snippet doc/src/snippets/declarative/pathinterpolator.qml 0
-*/
-
-QDeclarativePathInterpolator::QDeclarativePathInterpolator(QObject *parent) :
- QObject(parent), _path(0), _x(0), _y(0), _angle(0), _progress(0)
-{
-}
-
-/*!
- \qmlproperty Path QtQuick2::PathInterpolator::path
- This property holds the path to interpolate.
-
- For more information on defining a path see the \l Path documentation.
-*/
-QDeclarativePath *QDeclarativePathInterpolator::path() const
-{
- return _path;
-}
-
-void QDeclarativePathInterpolator::setPath(QDeclarativePath *path)
-{
- if (_path == path)
- return;
- if (_path)
- disconnect(_path, SIGNAL(changed()), this, SLOT(_q_pathUpdated()));
- _path = path;
- connect(_path, SIGNAL(changed()), this, SLOT(_q_pathUpdated()));
- emit pathChanged();
-}
-
-/*!
- \qmlproperty real QtQuick2::PathInterpolator::progress
- This property holds the current progress along the path.
-
- Typical usage of PathInterpolator is to set the progress
- (often via a NumberAnimation), and read the corresponding
- values for x, y, and angle (often via bindings to these values).
-
- Progress ranges from 0.0 to 1.0.
-*/
-qreal QDeclarativePathInterpolator::progress() const
-{
- return _progress;
-}
-
-void QDeclarativePathInterpolator::setProgress(qreal progress)
-{
- if (progress == _progress)
- return;
- _progress = progress;
- emit progressChanged();
- _q_pathUpdated();
-}
-
-/*!
- \qmlproperty real QtQuick2::PathInterpolator::x
- \qmlproperty real QtQuick2::PathInterpolator::y
-
- These properties hold the position of the path at \l progress.
-*/
-qreal QDeclarativePathInterpolator::x() const
-{
- return _x;
-}
-
-qreal QDeclarativePathInterpolator::y() const
-{
- return _y;
-}
-
-/*!
- \qmlproperty real QtQuick2::PathInterpolator::angle
-
- This property holds the angle of the path tangent at \l progress.
-
- Angles are reported clockwise, with zero degrees at the 3 o'clock position.
-*/
-qreal QDeclarativePathInterpolator::angle() const
-{
- return _angle;
-}
-
-void QDeclarativePathInterpolator::_q_pathUpdated()
-{
- if (! _path)
- return;
-
- qreal angle = 0;
- const QPointF pt = _path->sequentialPointAt(_progress, &angle);
-
- if (_x != pt.x()) {
- _x = pt.x();
- emit xChanged();
- }
-
- if (_y != pt.y()) {
- _y = pt.y();
- emit yChanged();
- }
-
- //convert to clockwise
- angle = qreal(360) - angle;
- if (qFuzzyCompare(angle, qreal(360)))
- angle = qreal(0);
-
- if (angle != _angle) {
- _angle = angle;
- emit angleChanged();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativepathinterpolator_p.h b/src/quick/util/qdeclarativepathinterpolator_p.h
deleted file mode 100644
index 24b58e6a3c..0000000000
--- a/src/quick/util/qdeclarativepathinterpolator_p.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPATHINTERPOLATOR_P_H
-#define QDECLARATIVEPATHINTERPOLATOR_P_H
-
-#include <qdeclarative.h>
-#include <QObject>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativePath;
-class Q_AUTOTEST_EXPORT QDeclarativePathInterpolator : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged)
- Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
- Q_PROPERTY(qreal x READ x NOTIFY xChanged)
- Q_PROPERTY(qreal y READ y NOTIFY yChanged)
- Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged)
-public:
- explicit QDeclarativePathInterpolator(QObject *parent = 0);
-
- QDeclarativePath *path() const;
- void setPath(QDeclarativePath *path);
-
- qreal progress() const;
- void setProgress(qreal progress);
-
- qreal x() const;
- qreal y() const;
- qreal angle() const;
-
-Q_SIGNALS:
- void pathChanged();
- void progressChanged();
- void xChanged();
- void yChanged();
- void angleChanged();
-
-private Q_SLOTS:
- void _q_pathUpdated();
-
-private:
- QDeclarativePath *_path;
- qreal _x;
- qreal _y;
- qreal _angle;
- qreal _progress;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativePathInterpolator)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPATHINTERPOLATOR_P_H
diff --git a/src/quick/util/qdeclarativepixmapcache.cpp b/src/quick/util/qdeclarativepixmapcache.cpp
deleted file mode 100644
index 1f187a7f03..0000000000
--- a/src/quick/util/qdeclarativepixmapcache.cpp
+++ /dev/null
@@ -1,1280 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepixmapcache_p.h"
-#include <qdeclarativenetworkaccessmanagerfactory.h>
-#include <qdeclarativeimageprovider.h>
-
-#include <qdeclarativeengine.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativeengine_p.h>
-
-#include <QtQuick/private/qsgtexture_p.h>
-#include <QtQuick/private/qsgcontext_p.h>
-
-#include <QCoreApplication>
-#include <QImageReader>
-#include <QHash>
-#include <QNetworkReply>
-#include <QPixmapCache>
-#include <QFile>
-#include <QThread>
-#include <QMutex>
-#include <QMutexLocker>
-#include <QWaitCondition>
-#include <QBuffer>
-#include <QWaitCondition>
-#include <QtCore/qdebug.h>
-#include <private/qobject_p.h>
-#include <QSslError>
-
-#define IMAGEREQUEST_MAX_REQUEST_COUNT 8
-#define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16
-#define CACHE_EXPIRE_TIME 30
-#define CACHE_REMOVAL_FRACTION 4
-
-QT_BEGIN_NAMESPACE
-
-// The cache limit describes the maximum "junk" in the cache.
-static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded in qpixmapcache.cpp
-
-QSGTexture *QDeclarativeDefaultTextureFactory::createTexture(QQuickCanvas *) const
-{
- QSGPlainTexture *t = new QSGPlainTexture();
- t->setImage(im);
- return t;
-}
-
-class QDeclarativePixmapReader;
-class QDeclarativePixmapData;
-class QDeclarativePixmapReply : public QObject
-{
- Q_OBJECT
-public:
- enum ReadError { NoError, Loading, Decoding };
-
- QDeclarativePixmapReply(QDeclarativePixmapData *);
- ~QDeclarativePixmapReply();
-
- QDeclarativePixmapData *data;
- QDeclarativeEngine *engineForReader; // always access reader inside readerMutex
- QSize requestSize;
- QUrl url;
-
- bool loading;
- int redirectCount;
-
- class Event : public QEvent {
- public:
- Event(ReadError, const QString &, const QSize &, QDeclarativeTextureFactory *factory, const QImage &image);
-
- ReadError error;
- QString errorString;
- QSize implicitSize;
- QImage image;
- QDeclarativeTextureFactory *textureFactory;
- };
- void postReply(ReadError, const QString &, const QSize &, const QImage &image);
- void postReply(ReadError, const QString &, const QSize &, QDeclarativeTextureFactory *factory, const QImage &image);
-
-
-Q_SIGNALS:
- void finished();
- void downloadProgress(qint64, qint64);
-
-protected:
- bool event(QEvent *event);
-
-private:
- Q_DISABLE_COPY(QDeclarativePixmapReply)
-
-public:
- static int finishedIndex;
- 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
-{
- Q_OBJECT
-public:
- QDeclarativePixmapReader(QDeclarativeEngine *eng);
- ~QDeclarativePixmapReader();
-
- QDeclarativePixmapReply *getImage(QDeclarativePixmapData *);
- void cancel(QDeclarativePixmapReply *rep);
-
- static QDeclarativePixmapReader *instance(QDeclarativeEngine *engine);
- static QDeclarativePixmapReader *existingInstance(QDeclarativeEngine *engine);
-
-protected:
- void run();
-
-private:
- friend class QDeclarativePixmapReaderThreadObject;
- void processJobs();
- void processJob(QDeclarativePixmapReply *, const QUrl &, const QSize &);
- void networkRequestDone(QNetworkReply *);
-
- QList<QDeclarativePixmapReply*> jobs;
- QList<QDeclarativePixmapReply*> cancelled;
- QDeclarativeEngine *engine;
- QObject *eventLoopQuitHack;
-
- QMutex mutex;
- QDeclarativePixmapReaderThreadObject *threadObject;
- QWaitCondition waitCondition;
-
- QNetworkAccessManager *networkAccessManager();
- QNetworkAccessManager *accessManager;
-
- QHash<QNetworkReply*,QDeclarativePixmapReply*> replies;
-
- static int replyDownloadProgress;
- static int replyFinished;
- static int downloadProgress;
- static int threadNetworkRequestDone;
- static QHash<QDeclarativeEngine *,QDeclarativePixmapReader*> readers;
-public:
- static QMutex readerMutex;
-};
-
-class QDeclarativePixmapData
-{
-public:
- QDeclarativePixmapData(QDeclarativePixmap *pixmap, const QUrl &u, const QSize &s, const QString &e)
- : refCount(1), inCache(false), pixmapStatus(QDeclarativePixmap::Error),
- url(u), errorString(e), requestSize(s), textureFactory(0), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
- {
- declarativePixmaps.insert(pixmap);
- }
-
- QDeclarativePixmapData(QDeclarativePixmap *pixmap, const QUrl &u, const QSize &r)
- : refCount(1), inCache(false), pixmapStatus(QDeclarativePixmap::Loading),
- url(u), requestSize(r), textureFactory(0), reply(0), prevUnreferenced(0), prevUnreferencedPtr(0),
- nextUnreferenced(0)
- {
- declarativePixmaps.insert(pixmap);
- }
-
- QDeclarativePixmapData(QDeclarativePixmap *pixmap, const QUrl &u, const QImage &p, const QSize &s, const QSize &r)
- : refCount(1), inCache(false), privatePixmap(false), pixmapStatus(QDeclarativePixmap::Ready),
- url(u), image(p), implicitSize(s), requestSize(r), textureFactory(new QDeclarativeDefaultTextureFactory(p)), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
- {
- declarativePixmaps.insert(pixmap);
- }
-
- QDeclarativePixmapData(QDeclarativePixmap *pixmap, const QUrl &u, QDeclarativeTextureFactory *factory, const QImage &p, const QSize &s, const QSize &r)
- : refCount(1), inCache(false), privatePixmap(false), pixmapStatus(QDeclarativePixmap::Ready),
- url(u), image(p), implicitSize(s), requestSize(r), textureFactory(factory), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
- {
- declarativePixmaps.insert(pixmap);
- }
-
- QDeclarativePixmapData(QDeclarativePixmap *pixmap, const QImage &p)
- : refCount(1), inCache(false), privatePixmap(true), pixmapStatus(QDeclarativePixmap::Ready),
- image(p), implicitSize(p.size()), requestSize(p.size()), textureFactory(new QDeclarativeDefaultTextureFactory(p)), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
- {
- declarativePixmaps.insert(pixmap);
- }
-
- ~QDeclarativePixmapData()
- {
- while (!declarativePixmaps.isEmpty()) {
- QDeclarativePixmap *referencer = declarativePixmaps.first();
- declarativePixmaps.remove(referencer);
- referencer->d = 0;
- }
- delete textureFactory;
- }
-
- int cost() const;
- void addref();
- void release();
- void addToCache();
- void removeFromCache();
-
- uint refCount;
-
- bool inCache:1;
- bool privatePixmap:1;
-
- QDeclarativePixmap::Status pixmapStatus;
- QUrl url;
- QString errorString;
- QImage image;
- QSize implicitSize;
- QSize requestSize;
-
- QDeclarativeTextureFactory *textureFactory;
-
- QIntrusiveList<QDeclarativePixmap, &QDeclarativePixmap::dataListNode> declarativePixmaps;
- QDeclarativePixmapReply *reply;
-
- QDeclarativePixmapData *prevUnreferenced;
- QDeclarativePixmapData**prevUnreferencedPtr;
- QDeclarativePixmapData *nextUnreferenced;
-};
-
-int QDeclarativePixmapReply::finishedIndex = -1;
-int QDeclarativePixmapReply::downloadProgressIndex = -1;
-
-// XXX
-QHash<QDeclarativeEngine *,QDeclarativePixmapReader*> QDeclarativePixmapReader::readers;
-QMutex QDeclarativePixmapReader::readerMutex;
-
-int QDeclarativePixmapReader::replyDownloadProgress = -1;
-int QDeclarativePixmapReader::replyFinished = -1;
-int QDeclarativePixmapReader::downloadProgress = -1;
-int QDeclarativePixmapReader::threadNetworkRequestDone = -1;
-
-
-void QDeclarativePixmapReply::postReply(ReadError error, const QString &errorString,
- const QSize &implicitSize, const QImage &image)
-{
- loading = false;
- QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, new QDeclarativeDefaultTextureFactory(image), image));
-}
-
-void QDeclarativePixmapReply::postReply(ReadError error, const QString &errorString,
- const QSize &implicitSize, QDeclarativeTextureFactory *factory,
- const QImage &image)
-{
- loading = false;
- QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, factory, image));
-}
-
-QDeclarativePixmapReply::Event::Event(ReadError e, const QString &s, const QSize &iSize, QDeclarativeTextureFactory *factory, const QImage &i)
- : QEvent(QEvent::User), error(e), errorString(s), implicitSize(iSize), image(i), textureFactory(factory)
-{
-}
-
-QNetworkAccessManager *QDeclarativePixmapReader::networkAccessManager()
-{
- if (!accessManager) {
- Q_ASSERT(threadObject);
- accessManager = QDeclarativeEnginePrivate::get(engine)->createNetworkAccessManager(threadObject);
- }
- return accessManager;
-}
-
-static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize,
- const QSize &requestSize)
-{
- QImageReader imgio(dev);
-
- bool force_scale = false;
- if (url.path().endsWith(QLatin1String(".svg"),Qt::CaseInsensitive)) {
- imgio.setFormat("svg"); // QSvgPlugin::capabilities bug QTBUG-9053
- force_scale = true;
- }
-
- if (requestSize.width() > 0 || requestSize.height() > 0) {
- QSize s = imgio.size();
- qreal ratio = 0.0;
- if (requestSize.width() && (force_scale || requestSize.width() < s.width())) {
- ratio = qreal(requestSize.width())/s.width();
- }
- if (requestSize.height() && (force_scale || requestSize.height() < s.height())) {
- qreal hr = qreal(requestSize.height())/s.height();
- if (ratio == 0.0 || hr < ratio)
- ratio = hr;
- }
- if (ratio > 0.0) {
- s.setHeight(qRound(s.height() * ratio));
- s.setWidth(qRound(s.width() * ratio));
- imgio.setScaledSize(s);
- }
- }
-
- if (impsize)
- *impsize = imgio.size();
-
- if (imgio.read(image)) {
- if (impsize && impsize->width() < 0)
- *impsize = image->size();
- return true;
- } else {
- if (errorString)
- *errorString = QDeclarativePixmap::tr("Error decoding: %1: %2").arg(url.toString())
- .arg(imgio.errorString());
- return false;
- }
-}
-
-QDeclarativePixmapReader::QDeclarativePixmapReader(QDeclarativeEngine *eng)
-: QThread(eng), engine(eng), threadObject(0), accessManager(0)
-{
- eventLoopQuitHack = new QObject;
- eventLoopQuitHack->moveToThread(this);
- connect(eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection);
- start(QThread::LowestPriority);
-}
-
-QDeclarativePixmapReader::~QDeclarativePixmapReader()
-{
- readerMutex.lock();
- readers.remove(engine);
- readerMutex.unlock();
-
- mutex.lock();
- // manually cancel all outstanding jobs.
- foreach (QDeclarativePixmapReply *reply, jobs) {
- delete reply;
- }
- jobs.clear();
- QList<QDeclarativePixmapReply*> activeJobs = replies.values();
- foreach (QDeclarativePixmapReply *reply, activeJobs) {
- if (reply->loading) {
- cancelled.append(reply);
- reply->data = 0;
- }
- }
- if (threadObject) threadObject->processJobs();
- mutex.unlock();
-
- eventLoopQuitHack->deleteLater();
- wait();
-}
-
-void QDeclarativePixmapReader::networkRequestDone(QNetworkReply *reply)
-{
- QDeclarativePixmapReply *job = replies.take(reply);
-
- if (job) {
- job->redirectCount++;
- if (job->redirectCount < IMAGEREQUEST_MAX_REDIRECT_RECURSION) {
- QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- QUrl url = reply->url().resolved(redirect.toUrl());
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
-
- reply->deleteLater();
- reply = networkAccessManager()->get(req);
-
- QMetaObject::connect(reply, replyDownloadProgress, job, downloadProgress);
- QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
-
- replies.insert(reply, job);
- return;
- }
- }
-
- QImage image;
- QDeclarativePixmapReply::ReadError error = QDeclarativePixmapReply::NoError;
- QString errorString;
- QSize readSize;
- if (reply->error()) {
- error = QDeclarativePixmapReply::Loading;
- errorString = reply->errorString();
- } else {
- QByteArray all = reply->readAll();
- QBuffer buff(&all);
- buff.open(QIODevice::ReadOnly);
- if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize))
- error = QDeclarativePixmapReply::Decoding;
- }
- // send completion event to the QDeclarativePixmapReply
- mutex.lock();
- if (!cancelled.contains(job)) {
- QDeclarativeTextureFactory *factory = QSGContext::createTextureFactoryFromImage(image);
- if (factory)
- job->postReply(error, errorString, readSize, factory, image);
- else
- job->postReply(error, errorString, readSize, image);
- }
- mutex.unlock();
- }
- reply->deleteLater();
-
- // kick off event loop again incase we have dropped below max request count
- threadObject->processJobs();
-}
-
-QDeclarativePixmapReaderThreadObject::QDeclarativePixmapReaderThreadObject(QDeclarativePixmapReader *i)
-: reader(i)
-{
-}
-
-void QDeclarativePixmapReaderThreadObject::processJobs()
-{
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
-}
-
-bool QDeclarativePixmapReaderThreadObject::event(QEvent *e)
-{
- if (e->type() == QEvent::User) {
- reader->processJobs();
- return true;
- } else {
- return QObject::event(e);
- }
-}
-
-void QDeclarativePixmapReaderThreadObject::networkRequestDone()
-{
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
- reader->networkRequestDone(reply);
-}
-
-void QDeclarativePixmapReader::processJobs()
-{
- QMutexLocker locker(&mutex);
-
- while (true) {
- if (cancelled.isEmpty() && (jobs.isEmpty() || replies.count() >= IMAGEREQUEST_MAX_REQUEST_COUNT))
- return; // Nothing else to do
-
- // Clean cancelled jobs
- if (cancelled.count()) {
- for (int i = 0; i < cancelled.count(); ++i) {
- QDeclarativePixmapReply *job = cancelled.at(i);
- QNetworkReply *reply = replies.key(job, 0);
- if (reply && reply->isRunning()) {
- // cancel any jobs already started
- replies.remove(reply);
- reply->close();
- }
- // deleteLater, since not owned by this thread
- job->deleteLater();
- }
- cancelled.clear();
- }
-
- if (!jobs.isEmpty() && replies.count() < IMAGEREQUEST_MAX_REQUEST_COUNT) {
- QDeclarativePixmapReply *runningJob = jobs.takeLast();
- runningJob->loading = true;
-
- QUrl url = runningJob->url;
- QSize requestSize = runningJob->requestSize;
- locker.unlock();
- processJob(runningJob, url, requestSize);
- locker.relock();
- }
- }
-}
-
-void QDeclarativePixmapReader::processJob(QDeclarativePixmapReply *runningJob, const QUrl &url,
- const QSize &requestSize)
-{
- // fetch
- if (url.scheme() == QLatin1String("image")) {
- // Use QmlImageProvider
- QSize readSize;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- QDeclarativeImageProvider::ImageType imageType = ep->getImageProviderType(url);
- if (imageType == QDeclarativeImageProvider::Invalid) {
- QDeclarativePixmapReply::ReadError errorCode = QDeclarativePixmapReply::Loading;
- QString errorStr = QDeclarativePixmap::tr("Invalid image provider: %1").arg(url.toString());
- QImage image;
- mutex.lock();
- if (!cancelled.contains(runningJob))
- runningJob->postReply(errorCode, errorStr, readSize, image);
- mutex.unlock();
- } else if (imageType == QDeclarativeImageProvider::Image) {
- QImage image = ep->getImageFromProvider(url, &readSize, requestSize);
- QDeclarativePixmapReply::ReadError errorCode = QDeclarativePixmapReply::NoError;
- QString errorStr;
- if (image.isNull()) {
- errorCode = QDeclarativePixmapReply::Loading;
- errorStr = QDeclarativePixmap::tr("Failed to get image from provider: %1").arg(url.toString());
- }
- mutex.lock();
- if (!cancelled.contains(runningJob)) {
- QDeclarativeTextureFactory *factory = QSGContext::createTextureFactoryFromImage(image);
- if (factory)
- runningJob->postReply(errorCode, errorStr, readSize, factory, image);
- else
- runningJob->postReply(errorCode, errorStr, readSize, image);
- }
-
- mutex.unlock();
- } else {
- QDeclarativeTextureFactory *t = ep->getTextureFromProvider(url, &readSize, requestSize);
- QDeclarativePixmapReply::ReadError errorCode = QDeclarativePixmapReply::NoError;
- QString errorStr;
- if (!t) {
- errorCode = QDeclarativePixmapReply::Loading;
- errorStr = QDeclarativePixmap::tr("Failed to get texture from provider: %1").arg(url.toString());
- }
- mutex.lock();
- if (!cancelled.contains(runningJob))
- runningJob->postReply(errorCode, errorStr, readSize, t, QImage());
- mutex.unlock();
-
- }
-
- } else {
- QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
- if (!lf.isEmpty()) {
- // Image is local - load/decode immediately
- QImage image;
- QDeclarativePixmapReply::ReadError errorCode = QDeclarativePixmapReply::NoError;
- QString errorStr;
- QFile f(lf);
- QSize readSize;
- if (f.open(QIODevice::ReadOnly)) {
- if (!readImage(url, &f, &image, &errorStr, &readSize, requestSize))
- errorCode = QDeclarativePixmapReply::Loading;
- } else {
- errorStr = QDeclarativePixmap::tr("Cannot open: %1").arg(url.toString());
- errorCode = QDeclarativePixmapReply::Loading;
- }
- mutex.lock();
- if (!cancelled.contains(runningJob)) {
- QDeclarativeTextureFactory *factory = QSGContext::createTextureFactoryFromImage(image);
- if (factory)
- runningJob->postReply(errorCode, errorStr, readSize, factory, image);
- else
- runningJob->postReply(errorCode, errorStr, readSize, image);
- }
- mutex.unlock();
- } else {
- // Network resource
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- QNetworkReply *reply = networkAccessManager()->get(req);
-
- QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
- QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
-
- replies.insert(reply, runningJob);
- }
- }
-}
-
-QDeclarativePixmapReader *QDeclarativePixmapReader::instance(QDeclarativeEngine *engine)
-{
- // XXX NOTE: must be called within readerMutex locking.
- QDeclarativePixmapReader *reader = readers.value(engine);
- if (!reader) {
- reader = new QDeclarativePixmapReader(engine);
- readers.insert(engine, reader);
- }
-
- return reader;
-}
-
-QDeclarativePixmapReader *QDeclarativePixmapReader::existingInstance(QDeclarativeEngine *engine)
-{
- // XXX NOTE: must be called within readerMutex locking.
- return readers.value(engine, 0);
-}
-
-QDeclarativePixmapReply *QDeclarativePixmapReader::getImage(QDeclarativePixmapData *data)
-{
- mutex.lock();
- QDeclarativePixmapReply *reply = new QDeclarativePixmapReply(data);
- reply->engineForReader = engine;
- jobs.append(reply);
- // XXX
- if (threadObject) threadObject->processJobs();
- mutex.unlock();
- return reply;
-}
-
-void QDeclarativePixmapReader::cancel(QDeclarativePixmapReply *reply)
-{
- mutex.lock();
- if (reply->loading) {
- cancelled.append(reply);
- reply->data = 0;
- // XXX
- if (threadObject) threadObject->processJobs();
- } else {
- jobs.removeAll(reply);
- delete reply;
- }
- mutex.unlock();
-}
-
-void QDeclarativePixmapReader::run()
-{
- if (replyDownloadProgress == -1) {
- const QMetaObject *nr = &QNetworkReply::staticMetaObject;
- const QMetaObject *pr = &QDeclarativePixmapReply::staticMetaObject;
- const QMetaObject *ir = &QDeclarativePixmapReaderThreadObject::staticMetaObject;
- replyDownloadProgress = nr->indexOfSignal("downloadProgress(qint64,qint64)");
- replyFinished = nr->indexOfSignal("finished()");
- downloadProgress = pr->indexOfSignal("downloadProgress(qint64,qint64)");
- threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()");
- }
-
- mutex.lock();
- threadObject = new QDeclarativePixmapReaderThreadObject(this);
- mutex.unlock();
-
- processJobs();
- exec();
-
- delete threadObject;
- threadObject = 0;
-}
-
-class QDeclarativePixmapKey
-{
-public:
- const QUrl *url;
- const QSize *size;
-};
-
-inline bool operator==(const QDeclarativePixmapKey &lhs, const QDeclarativePixmapKey &rhs)
-{
- return *lhs.size == *rhs.size && *lhs.url == *rhs.url;
-}
-
-inline uint qHash(const QDeclarativePixmapKey &key)
-{
- return qHash(*key.url) ^ key.size->width() ^ key.size->height();
-}
-
-class QSGContext;
-
-class QDeclarativePixmapStore : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativePixmapStore();
- ~QDeclarativePixmapStore();
-
- void unreferencePixmap(QDeclarativePixmapData *);
- void referencePixmap(QDeclarativePixmapData *);
-
- void purgeCache();
-
-protected:
- virtual void timerEvent(QTimerEvent *);
-
-public:
- QHash<QDeclarativePixmapKey, QDeclarativePixmapData *> m_cache;
-
-private:
- void shrinkCache(int remove);
-
- QDeclarativePixmapData *m_unreferencedPixmaps;
- QDeclarativePixmapData *m_lastUnreferencedPixmap;
-
- int m_unreferencedCost;
- int m_timerId;
- bool m_destroying;
-};
-Q_GLOBAL_STATIC(QDeclarativePixmapStore, pixmapStore);
-
-
-QDeclarativePixmapStore::QDeclarativePixmapStore()
- : m_unreferencedPixmaps(0), m_lastUnreferencedPixmap(0), m_unreferencedCost(0), m_timerId(-1), m_destroying(false)
-{
-}
-
-QDeclarativePixmapStore::~QDeclarativePixmapStore()
-{
- m_destroying = true;
-
- int leakedPixmaps = 0;
- QList<QDeclarativePixmapData*> cachedData = m_cache.values();
-
- // Prevent unreferencePixmap() from assuming it needs to kick
- // off the cache expiry timer, as we're shrinking the cache
- // manually below after releasing all the pixmaps.
- m_timerId = -2;
-
- // unreference all (leaked) pixmaps
- foreach (QDeclarativePixmapData* pixmap, cachedData) {
- int currRefCount = pixmap->refCount;
- if (currRefCount) {
- leakedPixmaps++;
- while (currRefCount > 0) {
- pixmap->release();
- currRefCount--;
- }
- }
- }
-
- // free all unreferenced pixmaps
- while (m_lastUnreferencedPixmap) {
- shrinkCache(20);
- }
-
- if (leakedPixmaps)
- qDebug("Number of leaked pixmaps: %i", leakedPixmaps);
-}
-
-void QDeclarativePixmapStore::unreferencePixmap(QDeclarativePixmapData *data)
-{
- Q_ASSERT(data->prevUnreferenced == 0);
- Q_ASSERT(data->prevUnreferencedPtr == 0);
- Q_ASSERT(data->nextUnreferenced == 0);
-
- data->nextUnreferenced = m_unreferencedPixmaps;
- data->prevUnreferencedPtr = &m_unreferencedPixmaps;
- if (!m_destroying) // the texture factories may have been cleaned up already.
- m_unreferencedCost += data->cost();
-
- m_unreferencedPixmaps = data;
- if (m_unreferencedPixmaps->nextUnreferenced) {
- m_unreferencedPixmaps->nextUnreferenced->prevUnreferenced = m_unreferencedPixmaps;
- m_unreferencedPixmaps->nextUnreferenced->prevUnreferencedPtr = &m_unreferencedPixmaps->nextUnreferenced;
- }
-
- if (!m_lastUnreferencedPixmap)
- m_lastUnreferencedPixmap = data;
-
- shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit
-
- if (m_timerId == -1 && m_unreferencedPixmaps && !m_destroying)
- m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000);
-}
-
-void QDeclarativePixmapStore::referencePixmap(QDeclarativePixmapData *data)
-{
- Q_ASSERT(data->prevUnreferencedPtr);
-
- *data->prevUnreferencedPtr = data->nextUnreferenced;
- if (data->nextUnreferenced) {
- data->nextUnreferenced->prevUnreferencedPtr = data->prevUnreferencedPtr;
- data->nextUnreferenced->prevUnreferenced = data->prevUnreferenced;
- }
- if (m_lastUnreferencedPixmap == data)
- m_lastUnreferencedPixmap = data->prevUnreferenced;
-
- data->nextUnreferenced = 0;
- data->prevUnreferencedPtr = 0;
- data->prevUnreferenced = 0;
-
- m_unreferencedCost -= data->cost();
-}
-
-void QDeclarativePixmapStore::shrinkCache(int remove)
-{
- while ((remove > 0 || m_unreferencedCost > cache_limit) && m_lastUnreferencedPixmap) {
- QDeclarativePixmapData *data = m_lastUnreferencedPixmap;
- Q_ASSERT(data->nextUnreferenced == 0);
-
- *data->prevUnreferencedPtr = 0;
- m_lastUnreferencedPixmap = data->prevUnreferenced;
- data->prevUnreferencedPtr = 0;
- data->prevUnreferenced = 0;
-
- if (!m_destroying) {
- remove -= data->cost();
- m_unreferencedCost -= data->cost();
- }
- data->removeFromCache();
- delete data;
- }
-}
-
-void QDeclarativePixmapStore::timerEvent(QTimerEvent *)
-{
- int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION;
-
- shrinkCache(removalCost);
-
- if (m_unreferencedPixmaps == 0) {
- killTimer(m_timerId);
- m_timerId = -1;
- }
-}
-
-void QDeclarativePixmapStore::purgeCache()
-{
- shrinkCache(m_unreferencedCost);
-}
-
-void QDeclarativePixmap::purgeCache()
-{
- pixmapStore()->purgeCache();
-}
-
-QDeclarativePixmapReply::QDeclarativePixmapReply(QDeclarativePixmapData *d)
-: data(d), engineForReader(0), requestSize(d->requestSize), url(d->url), loading(false), redirectCount(0)
-{
- if (finishedIndex == -1) {
- finishedIndex = QDeclarativePixmapReply::staticMetaObject.indexOfSignal("finished()");
- downloadProgressIndex = QDeclarativePixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
- }
-}
-
-QDeclarativePixmapReply::~QDeclarativePixmapReply()
-{
-}
-
-bool QDeclarativePixmapReply::event(QEvent *event)
-{
- if (event->type() == QEvent::User) {
-
- if (data) {
- Event *de = static_cast<Event *>(event);
- data->pixmapStatus = (de->error == NoError) ? QDeclarativePixmap::Ready : QDeclarativePixmap::Error;
-
- if (data->pixmapStatus == QDeclarativePixmap::Ready) {
- if (de->textureFactory) {
- data->textureFactory = de->textureFactory;
- }
- data->image = de->image;
- data->implicitSize = de->implicitSize;
- } else {
- data->errorString = de->errorString;
- data->removeFromCache(); // We don't continue to cache error'd pixmaps
- }
-
- data->reply = 0;
- emit finished();
- }
-
- delete this;
- return true;
- } else {
- return QObject::event(event);
- }
-}
-
-int QDeclarativePixmapData::cost() const
-{
- if (textureFactory)
- return textureFactory->textureByteCount();
- return image.byteCount();
-}
-
-void QDeclarativePixmapData::addref()
-{
- ++refCount;
- if (prevUnreferencedPtr)
- pixmapStore()->referencePixmap(this);
-}
-
-void QDeclarativePixmapData::release()
-{
- Q_ASSERT(refCount > 0);
- --refCount;
- if (refCount == 0) {
- if (reply) {
- QDeclarativePixmapReply *cancelReply = reply;
- reply->data = 0;
- reply = 0;
- QDeclarativePixmapReader::readerMutex.lock();
- QDeclarativePixmapReader *reader = QDeclarativePixmapReader::existingInstance(cancelReply->engineForReader);
- if (reader)
- reader->cancel(cancelReply);
- QDeclarativePixmapReader::readerMutex.unlock();
- }
-
- if (pixmapStatus == QDeclarativePixmap::Ready) {
- pixmapStore()->unreferencePixmap(this);
- } else {
- removeFromCache();
- delete this;
- }
- }
-}
-
-void QDeclarativePixmapData::addToCache()
-{
- if (!inCache) {
- QDeclarativePixmapKey key = { &url, &requestSize };
- pixmapStore()->m_cache.insert(key, this);
- inCache = true;
- }
-}
-
-void QDeclarativePixmapData::removeFromCache()
-{
- if (inCache) {
- QDeclarativePixmapKey key = { &url, &requestSize };
- pixmapStore()->m_cache.remove(key);
- inCache = false;
- }
-}
-
-static QDeclarativePixmapData* createPixmapDataSync(QDeclarativePixmap *declarativePixmap, QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, bool *ok)
-{
- if (url.scheme() == QLatin1String("image")) {
- QSize readSize;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- QDeclarativeImageProvider::ImageType imageType = ep->getImageProviderType(url);
-
- switch (imageType) {
- case QDeclarativeImageProvider::Invalid:
- return new QDeclarativePixmapData(declarativePixmap, url, requestSize,
- QDeclarativePixmap::tr("Invalid image provider: %1").arg(url.toString()));
- case QDeclarativeImageProvider::Texture:
- {
- QDeclarativeTextureFactory *texture = ep->getTextureFromProvider(url, &readSize, requestSize);
- if (texture) {
- *ok = true;
- return new QDeclarativePixmapData(declarativePixmap, url, texture, QImage(), readSize, requestSize);
- }
- }
-
- case QDeclarativeImageProvider::Image:
- {
- QImage image = ep->getImageFromProvider(url, &readSize, requestSize);
- if (!image.isNull()) {
- *ok = true;
- return new QDeclarativePixmapData(declarativePixmap, url, image, readSize, requestSize);
- }
- }
- case QDeclarativeImageProvider::Pixmap:
- {
- QPixmap pixmap = ep->getPixmapFromProvider(url, &readSize, requestSize);
- if (!pixmap.isNull()) {
- *ok = true;
- return new QDeclarativePixmapData(declarativePixmap, url, pixmap.toImage(), readSize, requestSize);
- }
- }
- }
-
- // provider has bad image type, or provider returned null image
- return new QDeclarativePixmapData(declarativePixmap, url, requestSize,
- QDeclarativePixmap::tr("Failed to get image from provider: %1").arg(url.toString()));
- }
-
- QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
- if (localFile.isEmpty())
- return 0;
-
- QFile f(localFile);
- QSize readSize;
- QString errorString;
-
- if (f.open(QIODevice::ReadOnly)) {
- QImage image;
-
- if (readImage(url, &f, &image, &errorString, &readSize, requestSize)) {
- *ok = true;
- return new QDeclarativePixmapData(declarativePixmap, url, image, readSize, requestSize);
- }
- errorString = QDeclarativePixmap::tr("Invalid image data: %1").arg(url.toString());
-
- } else {
- errorString = QDeclarativePixmap::tr("Cannot open: %1").arg(url.toString());
- }
- return new QDeclarativePixmapData(declarativePixmap, url, requestSize, errorString);
-}
-
-
-struct QDeclarativePixmapNull {
- QUrl url;
- QImage image;
- QSize size;
-};
-Q_GLOBAL_STATIC(QDeclarativePixmapNull, nullPixmap);
-
-QDeclarativePixmap::QDeclarativePixmap()
-: d(0)
-{
-}
-
-QDeclarativePixmap::QDeclarativePixmap(QDeclarativeEngine *engine, const QUrl &url)
-: d(0)
-{
- load(engine, url);
-}
-
-QDeclarativePixmap::QDeclarativePixmap(QDeclarativeEngine *engine, const QUrl &url, const QSize &size)
-: d(0)
-{
- load(engine, url, size);
-}
-
-QDeclarativePixmap::~QDeclarativePixmap()
-{
- if (d) {
- d->declarativePixmaps.remove(this);
- d->release();
- d = 0;
- }
-}
-
-bool QDeclarativePixmap::isNull() const
-{
- return d == 0;
-}
-
-bool QDeclarativePixmap::isReady() const
-{
- return status() == Ready;
-}
-
-bool QDeclarativePixmap::isError() const
-{
- return status() == Error;
-}
-
-bool QDeclarativePixmap::isLoading() const
-{
- return status() == Loading;
-}
-
-QString QDeclarativePixmap::error() const
-{
- if (d)
- return d->errorString;
- else
- return QString();
-}
-
-QDeclarativePixmap::Status QDeclarativePixmap::status() const
-{
- if (d)
- return d->pixmapStatus;
- else
- return Null;
-}
-
-const QUrl &QDeclarativePixmap::url() const
-{
- if (d)
- return d->url;
- else
- return nullPixmap()->url;
-}
-
-const QSize &QDeclarativePixmap::implicitSize() const
-{
- if (d)
- return d->implicitSize;
- else
- return nullPixmap()->size;
-}
-
-const QSize &QDeclarativePixmap::requestSize() const
-{
- if (d)
- return d->requestSize;
- else
- return nullPixmap()->size;
-}
-
-QDeclarativeTextureFactory *QDeclarativePixmap::textureFactory() const
-{
- if (d)
- return d->textureFactory;
-
- return 0;
-}
-
-const QImage &QDeclarativePixmap::image() const
-{
- if (d)
- return d->image;
- else
- return nullPixmap()->image;
-}
-
-void QDeclarativePixmap::setImage(const QImage &p)
-{
- clear();
-
- if (!p.isNull())
- d = new QDeclarativePixmapData(this, p);
-}
-
-int QDeclarativePixmap::width() const
-{
- if (d)
- return d->textureFactory ? d->textureFactory->textureSize().width() : d->image.width();
- else
- return 0;
-}
-
-int QDeclarativePixmap::height() const
-{
- if (d)
- return d->textureFactory ? d->textureFactory->textureSize().height() : d->image.height();
- else
- return 0;
-}
-
-QRect QDeclarativePixmap::rect() const
-{
- if (d)
- return d->textureFactory ? QRect(QPoint(), d->textureFactory->textureSize()) : d->image.rect();
- else
- return QRect();
-}
-
-void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url)
-{
- load(engine, url, QSize(), QDeclarativePixmap::Cache);
-}
-
-void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, QDeclarativePixmap::Options options)
-{
- load(engine, url, QSize(), options);
-}
-
-void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &size)
-{
- load(engine, url, size, QDeclarativePixmap::Cache);
-}
-
-void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, QDeclarativePixmap::Options options)
-{
- if (d) {
- d->declarativePixmaps.remove(this);
- d->release();
- d = 0;
- }
-
- QDeclarativePixmapKey key = { &url, &requestSize };
- QDeclarativePixmapStore *store = pixmapStore();
-
- QHash<QDeclarativePixmapKey, QDeclarativePixmapData *>::Iterator iter = store->m_cache.find(key);
-
- if (iter == store->m_cache.end()) {
- if (options & QDeclarativePixmap::Asynchronous) {
- // pixmaps can only be loaded synchronously
- if (url.scheme() == QLatin1String("image")
- && QDeclarativeEnginePrivate::get(engine)->getImageProviderType(url) == QDeclarativeImageProvider::Pixmap) {
- options &= ~QDeclarativePixmap::Asynchronous;
- }
- }
-
- if (!(options & QDeclarativePixmap::Asynchronous)) {
- bool ok = false;
- d = createPixmapDataSync(this, engine, url, requestSize, &ok);
- if (ok) {
- if (options & QDeclarativePixmap::Cache)
- d->addToCache();
- return;
- }
- if (d) // loadable, but encountered error while loading
- return;
- }
-
- if (!engine)
- return;
-
- d = new QDeclarativePixmapData(this, url, requestSize);
- if (options & QDeclarativePixmap::Cache)
- d->addToCache();
-
- QDeclarativePixmapReader::readerMutex.lock();
- d->reply = QDeclarativePixmapReader::instance(engine)->getImage(d);
- QDeclarativePixmapReader::readerMutex.unlock();
- } else {
- d = *iter;
- d->addref();
- d->declarativePixmaps.insert(this);
- }
-}
-
-void QDeclarativePixmap::clear()
-{
- if (d) {
- d->declarativePixmaps.remove(this);
- d->release();
- d = 0;
- }
-}
-
-void QDeclarativePixmap::clear(QObject *obj)
-{
- if (d) {
- if (d->reply)
- QObject::disconnect(d->reply, 0, obj, 0);
- d->declarativePixmaps.remove(this);
- d->release();
- d = 0;
- }
-}
-
-bool QDeclarativePixmap::connectFinished(QObject *object, const char *method)
-{
- if (!d || !d->reply) {
- qWarning("QDeclarativePixmap: connectFinished() called when not loading.");
- return false;
- }
-
- return QObject::connect(d->reply, SIGNAL(finished()), object, method);
-}
-
-bool QDeclarativePixmap::connectFinished(QObject *object, int method)
-{
- if (!d || !d->reply) {
- qWarning("QDeclarativePixmap: connectFinished() called when not loading.");
- return false;
- }
-
- return QMetaObject::connect(d->reply, QDeclarativePixmapReply::finishedIndex, object, method);
-}
-
-bool QDeclarativePixmap::connectDownloadProgress(QObject *object, const char *method)
-{
- if (!d || !d->reply) {
- qWarning("QDeclarativePixmap: connectDownloadProgress() called when not loading.");
- return false;
- }
-
- return QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), object, method);
-}
-
-bool QDeclarativePixmap::connectDownloadProgress(QObject *object, int method)
-{
- if (!d || !d->reply) {
- qWarning("QDeclarativePixmap: connectDownloadProgress() called when not loading.");
- return false;
- }
-
- return QMetaObject::connect(d->reply, QDeclarativePixmapReply::downloadProgressIndex, object, method);
-}
-
-QT_END_NAMESPACE
-
-#include <qdeclarativepixmapcache.moc>
diff --git a/src/quick/util/qdeclarativepixmapcache_p.h b/src/quick/util/qdeclarativepixmapcache_p.h
deleted file mode 100644
index 69cd84c465..0000000000
--- a/src/quick/util/qdeclarativepixmapcache_p.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPIXMAPCACHE_H
-#define QDECLARATIVEPIXMAPCACHE_H
-
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qpixmap.h>
-#include <QtCore/qurl.h>
-#include <QtQuick/qtquickglobal.h>
-
-#include <private/qintrusivelist_p.h>
-#include <qdeclarativeimageprovider.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-class QDeclarativePixmapData;
-class QDeclarativeTextureFactory;
-
-class QDeclarativeDefaultTextureFactory : public QDeclarativeTextureFactory
-{
- Q_OBJECT
-public:
- QDeclarativeDefaultTextureFactory(const QImage &i)
- : im(i)
- {
- }
-
- QSGTexture *createTexture(QQuickCanvas *canvas) const;
- QSize textureSize() const { return im.size(); }
- int textureByteCount() const { return im.byteCount(); }
- QImage image() const { return im; }
-
-private:
- QImage im;
-};
-
-class Q_QUICK_EXPORT QDeclarativePixmap
-{
- Q_DECLARE_TR_FUNCTIONS(QDeclarativePixmap)
-public:
- QDeclarativePixmap();
- QDeclarativePixmap(QDeclarativeEngine *, const QUrl &);
- QDeclarativePixmap(QDeclarativeEngine *, const QUrl &, const QSize &);
- ~QDeclarativePixmap();
-
- enum Status { Null, Ready, Error, Loading };
-
- enum Option {
- Asynchronous = 0x00000001,
- Cache = 0x00000002
- };
- Q_DECLARE_FLAGS(Options, Option)
-
- bool isNull() const;
- bool isReady() const;
- bool isError() const;
- bool isLoading() const;
-
- Status status() const;
- QString error() const;
- const QUrl &url() const;
- const QSize &implicitSize() const;
- const QSize &requestSize() const;
- const QImage &image() const;
- void setImage(const QImage &);
-
- QDeclarativeTextureFactory *textureFactory() const;
-
- QRect rect() const;
- int width() const;
- int height() const;
-
- void load(QDeclarativeEngine *, const QUrl &);
- void load(QDeclarativeEngine *, const QUrl &, QDeclarativePixmap::Options options);
- void load(QDeclarativeEngine *, const QUrl &, const QSize &);
- void load(QDeclarativeEngine *, const QUrl &, const QSize &, QDeclarativePixmap::Options options);
-
- void clear();
- void clear(QObject *);
-
- bool connectFinished(QObject *, const char *);
- bool connectFinished(QObject *, int);
- bool connectDownloadProgress(QObject *, const char *);
- bool connectDownloadProgress(QObject *, int);
-
- static void purgeCache();
-
-private:
- Q_DISABLE_COPY(QDeclarativePixmap)
- QDeclarativePixmapData *d;
- QIntrusiveListNode dataListNode;
- friend class QDeclarativePixmapData;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePixmap::Options)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPIXMAPCACHE_H
diff --git a/src/quick/util/qdeclarativepropertychanges.cpp b/src/quick/util/qdeclarativepropertychanges.cpp
deleted file mode 100644
index 350c84e737..0000000000
--- a/src/quick/util/qdeclarativepropertychanges.cpp
+++ /dev/null
@@ -1,796 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepropertychanges_p.h"
-
-#include <private/qdeclarativeopenmetaobject_p.h>
-#include <private/qdeclarativerewrite_p.h>
-#include <private/qdeclarativeengine_p.h>
-
-#include <qdeclarativeinfo.h>
-#include <private/qdeclarativecustomparser_p.h>
-#include <private/qdeclarativescript_p.h>
-#include <qdeclarativeexpression.h>
-#include <private/qdeclarativebinding_p.h>
-#include <qdeclarativecontext.h>
-#include <private/qdeclarativeguard_p.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativecontext_p.h>
-#include <private/qdeclarativestate_p_p.h>
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass PropertyChanges QDeclarativePropertyChanges
- \inqmlmodule QtQuick 2
- \ingroup qml-state-elements
- \brief The PropertyChanges element describes new property bindings or values for a state.
-
- PropertyChanges is used to define the property values or bindings in a
- \l State. This enables an item's property values to be changed when it
- \l {QML States}{changes between states}.
-
- To create a PropertyChanges object, specify the \l target item whose
- properties are to be modified, and define the new property values or
- bindings. For example:
-
- \snippet doc/src/snippets/declarative/propertychanges.qml import
- \codeline
- \snippet doc/src/snippets/declarative/propertychanges.qml 0
-
- When the mouse is pressed, the \l Rectangle changes to the \e resized
- state. In this state, the PropertyChanges object sets the rectangle's
- color to blue and the \c height value to that of \c container.height.
-
- Note this automatically binds \c rect.height to \c container.height
- in the \e resized state. If a property binding should not be
- established, and the height should just be set to the value of
- \c container.height at the time of the state change, set the \l explicit
- property to \c true.
-
- A PropertyChanges object can also override the default signal handler
- for an object to implement a signal handler specific to the new state:
-
- \qml
- PropertyChanges {
- target: myMouseArea
- onClicked: doSomethingDifferent()
- }
- \endqml
-
- \note PropertyChanges can be used to change anchor margins, but not other anchor
- values; use AnchorChanges for this instead. Similarly, to change an \l Item's
- \l {Item::}{parent} value, use ParentChanges instead.
-
-
- \section2 Resetting property values
-
- The \c undefined value can be used to reset the property value for a state.
- In the following example, when \c myText changes to the \e widerText
- state, its \c width property is reset, giving the text its natural width
- and displaying the whole string on a single line.
-
- \snippet doc/src/snippets/declarative/propertychanges.qml reset
-
-
- \section2 Immediate property changes in transitions
-
- When \l{QML Animation and Transitions}{Transitions} are used to animate
- state changes, they animate properties from their values in the current
- state to those defined in the new state (as defined by PropertyChanges
- objects). However, it is sometimes desirable to set a property value
- \e immediately during a \l Transition, without animation; in these cases,
- the PropertyAction element can be used to force an immediate property
- change.
-
- See the PropertyAction documentation for more details.
-
- \sa {declarative/animation/states}{states example}, {qmlstate}{States}, QtDeclarative
-*/
-
-/*!
- \qmlproperty Object QtQuick2::PropertyChanges::target
- This property holds the object which contains the properties to be changed.
-*/
-
-class QDeclarativeReplaceSignalHandler : public QDeclarativeActionEvent
-{
-public:
- QDeclarativeReplaceSignalHandler() : expression(0), reverseExpression(0),
- rewindExpression(0), ownedExpression(0) {}
- ~QDeclarativeReplaceSignalHandler() {
- delete ownedExpression;
- }
-
- virtual EventType type() const { return SignalHandler; }
-
- QDeclarativeProperty property;
- QDeclarativeExpression *expression;
- QDeclarativeExpression *reverseExpression;
- QDeclarativeExpression *rewindExpression;
- QDeclarativeGuard<QDeclarativeExpression> ownedExpression;
-
- virtual void execute(Reason) {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression);
- if (ownedExpression == expression)
- ownedExpression = 0;
- }
-
- virtual bool isReversable() { return true; }
- virtual void reverse(Reason) {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression);
- if (ownedExpression == reverseExpression)
- ownedExpression = 0;
- }
-
- virtual void saveOriginals() {
- saveCurrentValues();
- reverseExpression = rewindExpression;
- }
-
- virtual bool needsCopy() { return true; }
- virtual void copyOriginals(QDeclarativeActionEvent *other)
- {
- QDeclarativeReplaceSignalHandler *rsh = static_cast<QDeclarativeReplaceSignalHandler*>(other);
- saveCurrentValues();
- if (rsh == this)
- return;
- reverseExpression = rsh->reverseExpression;
- if (rsh->ownedExpression == reverseExpression) {
- ownedExpression = rsh->ownedExpression;
- rsh->ownedExpression = 0;
- }
- }
-
- virtual void rewind() {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression);
- if (ownedExpression == rewindExpression)
- ownedExpression = 0;
- }
- virtual void saveCurrentValues() {
- rewindExpression = QDeclarativePropertyPrivate::signalExpression(property);
- }
-
- virtual bool override(QDeclarativeActionEvent*other) {
- if (other == this)
- return true;
- if (other->type() != type())
- return false;
- if (static_cast<QDeclarativeReplaceSignalHandler*>(other)->property == property)
- return true;
- return false;
- }
-};
-
-
-class QDeclarativePropertyChangesPrivate : public QDeclarativeStateOperationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativePropertyChanges)
-public:
- QDeclarativePropertyChangesPrivate() : decoded(true), restore(true),
- isExplicit(false) {}
-
- QDeclarativeGuard<QObject> object;
- QByteArray data;
-
- bool decoded : 1;
- bool restore : 1;
- bool isExplicit : 1;
-
- void decode();
-
- class ExpressionChange {
- public:
- ExpressionChange(const QString &_name,
- QDeclarativeBinding::Identifier _id,
- QDeclarativeExpression *_expr)
- : name(_name), id(_id), expression(_expr) {}
- QString name;
- QDeclarativeBinding::Identifier id;
- QDeclarativeExpression *expression;
- };
-
- QList<QPair<QString, QVariant> > properties;
- QList<ExpressionChange> expressions;
- QList<QDeclarativeReplaceSignalHandler*> signalReplacements;
-
- QDeclarativeProperty property(const QString &);
-};
-
-void
-QDeclarativePropertyChangesParser::compileList(QList<QPair<QString, QVariant> > &list,
- const QString &pre,
- const QDeclarativeCustomParserProperty &prop)
-{
- QString propName = pre + prop.name();
-
- QList<QVariant> values = prop.assignedValues();
- for (int ii = 0; ii < values.count(); ++ii) {
- const QVariant &value = values.at(ii);
-
- if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
- error(qvariant_cast<QDeclarativeCustomParserNode>(value),
- QDeclarativePropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
- continue;
- } else if(value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
-
- QDeclarativeCustomParserProperty prop =
- qvariant_cast<QDeclarativeCustomParserProperty>(value);
- QString pre = propName + QLatin1Char('.');
- compileList(list, pre, prop);
-
- } else {
- list << qMakePair(propName, value);
- }
- }
-}
-
-QByteArray
-QDeclarativePropertyChangesParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
-{
- QList<QPair<QString, QVariant> > data;
- for(int ii = 0; ii < props.count(); ++ii)
- compileList(data, QString(), props.at(ii));
-
- QByteArray rv;
- QDataStream ds(&rv, QIODevice::WriteOnly);
-
- ds << data.count();
- for(int ii = 0; ii < data.count(); ++ii) {
- QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(data.at(ii).second);
- QVariant var;
- bool isScript = v.isScript();
- QDeclarativeBinding::Identifier id = 0;
- switch(v.type()) {
- case QDeclarativeScript::Variant::Boolean:
- var = QVariant(v.asBoolean());
- break;
- case QDeclarativeScript::Variant::Number:
- var = QVariant(v.asNumber());
- break;
- case QDeclarativeScript::Variant::String:
- var = QVariant(v.asString());
- break;
- case QDeclarativeScript::Variant::Invalid:
- case QDeclarativeScript::Variant::Script:
- var = QVariant(v.asScript());
- {
- // Pre-rewrite the expression
- id = rewriteBinding(v, data.at(ii).first);
- }
- break;
- }
-
- ds << data.at(ii).first << isScript << var;
- if (isScript)
- ds << id;
- }
-
- return rv;
-}
-
-void QDeclarativePropertyChangesPrivate::decode()
-{
- Q_Q(QDeclarativePropertyChanges);
- if (decoded)
- return;
-
- QDataStream ds(&data, QIODevice::ReadOnly);
-
- int count;
- ds >> count;
- for (int ii = 0; ii < count; ++ii) {
- QString name;
- bool isScript;
- QVariant data;
- QDeclarativeBinding::Identifier id = QDeclarativeBinding::Invalid;
- ds >> name;
- ds >> isScript;
- ds >> data;
- if (isScript)
- ds >> id;
-
- QDeclarativeProperty prop = property(name); //### better way to check for signal property?
- if (prop.type() & QDeclarativeProperty::SignalProperty) {
- QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString());
- QDeclarativeData *ddata = QDeclarativeData::get(q);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
- QDeclarativeReplaceSignalHandler *handler = new QDeclarativeReplaceSignalHandler;
- handler->property = prop;
- handler->expression = expression;
- signalReplacements << handler;
- } else if (isScript) {
- QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString());
- QDeclarativeData *ddata = QDeclarativeData::get(q);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
- expressions << ExpressionChange(name, id, expression);
- } else {
- properties << qMakePair(name, data);
- }
- }
-
- decoded = true;
- data.clear();
-}
-
-void QDeclarativePropertyChangesParser::setCustomData(QObject *object,
- const QByteArray &data)
-{
- QDeclarativePropertyChangesPrivate *p =
- static_cast<QDeclarativePropertyChangesPrivate *>(QObjectPrivate::get(object));
- p->data = data;
- p->decoded = false;
-}
-
-QDeclarativePropertyChanges::QDeclarativePropertyChanges()
-: QDeclarativeStateOperation(*(new QDeclarativePropertyChangesPrivate))
-{
-}
-
-QDeclarativePropertyChanges::~QDeclarativePropertyChanges()
-{
- Q_D(QDeclarativePropertyChanges);
- for(int ii = 0; ii < d->expressions.count(); ++ii)
- delete d->expressions.at(ii).expression;
- for(int ii = 0; ii < d->signalReplacements.count(); ++ii)
- delete d->signalReplacements.at(ii);
-}
-
-QObject *QDeclarativePropertyChanges::object() const
-{
- Q_D(const QDeclarativePropertyChanges);
- return d->object;
-}
-
-void QDeclarativePropertyChanges::setObject(QObject *o)
-{
- Q_D(QDeclarativePropertyChanges);
- d->object = o;
-}
-
-/*!
- \qmlproperty bool QtQuick2::PropertyChanges::restoreEntryValues
-
- This property holds whether the previous values should be restored when
- leaving the state.
-
- The default value is \c true. Setting this value to \c false creates a
- temporary state that has permanent effects on property values.
-*/
-bool QDeclarativePropertyChanges::restoreEntryValues() const
-{
- Q_D(const QDeclarativePropertyChanges);
- return d->restore;
-}
-
-void QDeclarativePropertyChanges::setRestoreEntryValues(bool v)
-{
- Q_D(QDeclarativePropertyChanges);
- d->restore = v;
-}
-
-QDeclarativeProperty
-QDeclarativePropertyChangesPrivate::property(const QString &property)
-{
- Q_Q(QDeclarativePropertyChanges);
- QDeclarativeProperty prop(object, property, qmlContext(q));
- if (!prop.isValid()) {
- qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(property);
- return QDeclarativeProperty();
- } else if (!(prop.type() & QDeclarativeProperty::SignalProperty) && !prop.isWritable()) {
- qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(property);
- return QDeclarativeProperty();
- }
- return prop;
-}
-
-QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions()
-{
- Q_D(QDeclarativePropertyChanges);
-
- d->decode();
-
- ActionList list;
-
- for (int ii = 0; ii < d->properties.count(); ++ii) {
-
- QDeclarativeAction a(d->object, d->properties.at(ii).first,
- qmlContext(this), d->properties.at(ii).second);
-
- if (a.property.isValid()) {
- a.restore = restoreEntryValues();
- list << a;
- }
- }
-
- for (int ii = 0; ii < d->signalReplacements.count(); ++ii) {
-
- QDeclarativeReplaceSignalHandler *handler = d->signalReplacements.at(ii);
-
- if (handler->property.isValid()) {
- QDeclarativeAction a;
- a.event = handler;
- list << a;
- }
- }
-
- for (int ii = 0; ii < d->expressions.count(); ++ii) {
-
- const QString &property = d->expressions.at(ii).name;
- QDeclarativeProperty prop = d->property(property);
-
- if (prop.isValid()) {
- QDeclarativeAction a;
- a.restore = restoreEntryValues();
- a.property = prop;
- a.fromValue = a.property.read();
- a.specifiedObject = d->object;
- a.specifiedProperty = property;
-
- if (d->isExplicit) {
- a.toValue = d->expressions.at(ii).expression->evaluate();
- } else {
- QDeclarativeExpression *e = d->expressions.at(ii).expression;
-
- QDeclarativeBinding::Identifier id = d->expressions.at(ii).id;
- QDeclarativeBinding *newBinding = id != QDeclarativeBinding::Invalid ? QDeclarativeBinding::createBinding(id, object(), qmlContext(this), e->sourceFile(), e->lineNumber()) : 0;
- if (!newBinding) {
- newBinding = new QDeclarativeBinding(e->expression(), object(), qmlContext(this));
- newBinding->setSourceLocation(e->sourceFile(), e->lineNumber(), e->columnNumber());
- }
- newBinding->setTarget(prop);
- a.toBinding = newBinding;
- a.deletableToBinding = true;
- }
-
- list << a;
- }
- }
-
- return list;
-}
-
-/*!
- \qmlproperty bool QtQuick2::PropertyChanges::explicit
-
- If explicit is set to true, any potential bindings will be interpreted as
- once-off assignments that occur when the state is entered.
-
- In the following example, the addition of explicit prevents \c myItem.width from
- being bound to \c parent.width. Instead, it is assigned the value of \c parent.width
- at the time of the state change.
- \qml
- PropertyChanges {
- target: myItem
- explicit: true
- width: parent.width
- }
- \endqml
-
- By default, explicit is false.
-*/
-bool QDeclarativePropertyChanges::isExplicit() const
-{
- Q_D(const QDeclarativePropertyChanges);
- return d->isExplicit;
-}
-
-void QDeclarativePropertyChanges::setIsExplicit(bool e)
-{
- Q_D(QDeclarativePropertyChanges);
- d->isExplicit = e;
-}
-
-bool QDeclarativePropertyChanges::containsValue(const QString &name) const
-{
- Q_D(const QDeclarativePropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
-
- QListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- const PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- return true;
- }
- }
-
- return false;
-}
-
-bool QDeclarativePropertyChanges::containsExpression(const QString &name) const
-{
- Q_D(const QDeclarativePropertyChanges);
- typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- return true;
- }
- }
-
- return false;
-}
-
-bool QDeclarativePropertyChanges::containsProperty(const QString &name) const
-{
- return containsValue(name) || containsExpression(name);
-}
-
-void QDeclarativePropertyChanges::changeValue(const QString &name, const QVariant &value)
-{
- Q_D(QDeclarativePropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
- typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- expressionIterator.remove();
- if (state() && state()->isStateActive()) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name));
- if (oldBinding) {
- QDeclarativePropertyPrivate::setBinding(d->property(name), 0);
- oldBinding->destroy();
- }
- d->property(name).write(value);
- }
-
- d->properties.append(PropertyEntry(name, value));
- return;
- }
- }
-
- QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- entry.second = value;
- if (state() && state()->isStateActive())
- d->property(name).write(value);
- return;
- }
- }
-
- QDeclarativeAction action;
- action.restore = restoreEntryValues();
- action.property = d->property(name);
- action.fromValue = action.property.read();
- action.specifiedObject = object();
- action.specifiedProperty = name;
- action.toValue = value;
-
- propertyIterator.insert(PropertyEntry(name, value));
- if (state() && state()->isStateActive()) {
- state()->addEntryToRevertList(action);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(action.property);
- if (oldBinding)
- oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- d->property(name).write(value);
- }
-}
-
-void QDeclarativePropertyChanges::changeExpression(const QString &name, const QString &expression)
-{
- Q_D(QDeclarativePropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
- typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- bool hadValue = false;
-
- QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- propertyIterator.remove();
- hadValue = true;
- break;
- }
- }
-
- QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- entry.expression->setExpression(expression);
- if (state() && state()->isStateActive()) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name));
- if (oldBinding) {
- QDeclarativePropertyPrivate::setBinding(d->property(name), 0);
- oldBinding->destroy();
- }
-
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(expression, object(), qmlContext(this));
- newBinding->setTarget(d->property(name));
- QDeclarativePropertyPrivate::setBinding(d->property(name), newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- }
- return;
- }
- }
-
- QDeclarativeExpression *newExpression = new QDeclarativeExpression(qmlContext(this), d->object, expression);
- expressionIterator.insert(ExpressionEntry(name, QDeclarativeBinding::Invalid, newExpression));
-
- if (state() && state()->isStateActive()) {
- if (hadValue) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name));
- if (oldBinding) {
- oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- state()->changeBindingInRevertList(object(), name, oldBinding);
- }
-
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(expression, object(), qmlContext(this));
- newBinding->setTarget(d->property(name));
- QDeclarativePropertyPrivate::setBinding(d->property(name), newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- } else {
- QDeclarativeAction action;
- action.restore = restoreEntryValues();
- action.property = d->property(name);
- action.fromValue = action.property.read();
- action.specifiedObject = object();
- action.specifiedProperty = name;
-
-
- if (d->isExplicit) {
- action.toValue = newExpression->evaluate();
- } else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(newExpression->expression(), object(), qmlContext(this));
- newBinding->setTarget(d->property(name));
- action.toBinding = newBinding;
- action.deletableToBinding = true;
-
- state()->addEntryToRevertList(action);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(action.property);
- if (oldBinding)
- oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
-
- QDeclarativePropertyPrivate::setBinding(action.property, newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- }
- }
- }
- // what about the signal handler?
-}
-
-QVariant QDeclarativePropertyChanges::property(const QString &name) const
-{
- Q_D(const QDeclarativePropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
- typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- const PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- return entry.second;
- }
- }
-
- QListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- return QVariant(entry.expression->expression());
- }
- }
-
- return QVariant();
-}
-
-void QDeclarativePropertyChanges::removeProperty(const QString &name)
-{
- Q_D(QDeclarativePropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
- typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- expressionIterator.remove();
- state()->removeEntryFromRevertList(object(), name);
- return;
- }
- }
-
- QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- const PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- propertyIterator.remove();
- state()->removeEntryFromRevertList(object(), name);
- return;
- }
- }
-}
-
-QVariant QDeclarativePropertyChanges::value(const QString &name) const
-{
- Q_D(const QDeclarativePropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
-
- QListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- const PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- return entry.second;
- }
- }
-
- return QVariant();
-}
-
-QString QDeclarativePropertyChanges::expression(const QString &name) const
-{
- Q_D(const QDeclarativePropertyChanges);
- typedef QDeclarativePropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- return entry.expression->expression();
- }
- }
-
- return QString();
-}
-
-void QDeclarativePropertyChanges::detachFromState()
-{
- if (state())
- state()->removeAllEntriesFromRevertList(object());
-}
-
-void QDeclarativePropertyChanges::attachToState()
-{
- if (state())
- state()->addEntriesToRevertList(actions());
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativepropertychanges_p.h b/src/quick/util/qdeclarativepropertychanges_p.h
deleted file mode 100644
index 2d5838ddf4..0000000000
--- a/src/quick/util/qdeclarativepropertychanges_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROPERTYCHANGES_H
-#define QDECLARATIVEPROPERTYCHANGES_H
-
-#include "qdeclarativestateoperations_p.h"
-#include <private/qdeclarativecustomparser_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativePropertyChangesPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativePropertyChanges : public QDeclarativeStateOperation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativePropertyChanges)
-
- Q_PROPERTY(QObject *target READ object WRITE setObject)
- Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
- Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
-public:
- QDeclarativePropertyChanges();
- ~QDeclarativePropertyChanges();
-
- QObject *object() const;
- void setObject(QObject *);
-
- bool restoreEntryValues() const;
- void setRestoreEntryValues(bool);
-
- bool isExplicit() const;
- void setIsExplicit(bool);
-
- virtual ActionList actions();
-
- bool containsProperty(const QString &name) const;
- bool containsValue(const QString &name) const;
- bool containsExpression(const QString &name) const;
- void changeValue(const QString &name, const QVariant &value);
- void changeExpression(const QString &name, const QString &expression);
- void removeProperty(const QString &name);
- QVariant value(const QString &name) const;
- QString expression(const QString &name) const;
-
- void detachFromState();
- void attachToState();
-
- QVariant property(const QString &name) const;
-};
-
-class QDeclarativePropertyChangesParser : public QDeclarativeCustomParser
-{
-public:
- QDeclarativePropertyChangesParser()
- : QDeclarativeCustomParser(AcceptsAttachedProperties) {}
-
- void compileList(QList<QPair<QString, QVariant> > &list, const QString &pre, const QDeclarativeCustomParserProperty &prop);
-
- virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
- virtual void setCustomData(QObject *, const QByteArray &);
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativePropertyChanges)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPROPERTYCHANGES_H
diff --git a/src/quick/util/qdeclarativesmoothedanimation.cpp b/src/quick/util/qdeclarativesmoothedanimation.cpp
deleted file mode 100644
index 4f2ed7dbe3..0000000000
--- a/src/quick/util/qdeclarativesmoothedanimation.cpp
+++ /dev/null
@@ -1,557 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativesmoothedanimation_p.h"
-#include "qdeclarativesmoothedanimation_p_p.h"
-
-#include "qdeclarativeanimation_p_p.h"
-
-#include <qdeclarativeproperty.h>
-#include <private/qdeclarativeproperty_p.h>
-
-#include <private/qdeclarativeglobal_p.h>
-
-#include <QtCore/qdebug.h>
-
-#include <math.h>
-
-#define DELAY_STOP_TIMER_INTERVAL 32
-
-QT_BEGIN_NAMESPACE
-
-
-QSmoothedAnimationTimer::QSmoothedAnimationTimer(QSmoothedAnimation *animation, QObject *parent)
- : QTimer(parent)
- , m_animation(animation)
-{
- connect(this, SIGNAL(timeout()), this, SLOT(stopAnimation()));
-}
-
-QSmoothedAnimationTimer::~QSmoothedAnimationTimer()
-{
-}
-
-void QSmoothedAnimationTimer::stopAnimation()
-{
- m_animation->stop();
-}
-
-QSmoothedAnimation::QSmoothedAnimation(QDeclarativeSmoothedAnimationPrivate *priv)
- : QAbstractAnimationJob(), to(0), velocity(200), userDuration(-1), maximumEasingTime(-1),
- reversingMode(QDeclarativeSmoothedAnimation::Eased), initialVelocity(0),
- trackVelocity(0), initialValue(0), invert(false), finalDuration(-1), lastTime(0),
- useDelta(false), delayedStopTimer(new QSmoothedAnimationTimer(this)), animationTemplate(priv)
-{
- delayedStopTimer->setInterval(DELAY_STOP_TIMER_INTERVAL);
- delayedStopTimer->setSingleShot(true);
-}
-
-QSmoothedAnimation::~QSmoothedAnimation()
-{
- delete delayedStopTimer;
- if (animationTemplate) {
- if (target.object()) {
- QHash<QDeclarativeProperty, QSmoothedAnimation* >::iterator it =
- animationTemplate->activeAnimations.find(target);
- if (it != animationTemplate->activeAnimations.end() && it.value() == this)
- animationTemplate->activeAnimations.erase(it);
- } else {
- //target is no longer valid, need to search linearly
- QHash<QDeclarativeProperty, QSmoothedAnimation* >::iterator it;
- for (it = animationTemplate->activeAnimations.begin(); it != animationTemplate->activeAnimations.end(); ++it) {
- if (it.value() == this) {
- animationTemplate->activeAnimations.erase(it);
- break;
- }
- }
- }
- }
-}
-
-void QSmoothedAnimation::restart()
-{
- initialVelocity = trackVelocity;
- if (isRunning())
- init();
- else
- start();
-}
-
-void QSmoothedAnimation::prepareForRestart()
-{
- initialVelocity = trackVelocity;
- if (isRunning()) {
- //we are joining a new wrapper group while running, our times need to be restarted
- useDelta = true;
- init();
- lastTime = 0;
- } else {
- useDelta = false;
- //we'll be started when the group starts, which will force an init()
- }
-}
-
-void QSmoothedAnimation::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State /*oldState*/)
-{
- if (newState == QAbstractAnimationJob::Running)
- init();
-}
-
-void QSmoothedAnimation::delayedStop()
-{
- if (!delayedStopTimer->isActive())
- delayedStopTimer->start();
-}
-
-int QSmoothedAnimation::duration() const
-{
- return -1;
-}
-
-bool QSmoothedAnimation::recalc()
-{
- s = to - initialValue;
- vi = initialVelocity;
-
- s = (invert? -1.0: 1.0) * s;
-
- if (userDuration > 0 && velocity > 0) {
- tf = s / velocity;
- if (tf > (userDuration / 1000.)) tf = (userDuration / 1000.);
- } else if (userDuration > 0) {
- tf = userDuration / 1000.;
- } else if (velocity > 0) {
- tf = s / velocity;
- } else {
- return false;
- }
-
- finalDuration = ceil(tf * 1000.0);
-
- if (maximumEasingTime == 0) {
- a = 0;
- d = 0;
- tp = 0;
- td = tf;
- vp = velocity;
- sp = 0;
- sd = s;
- } else if (maximumEasingTime != -1 && tf > (maximumEasingTime / 1000.)) {
- qreal met = maximumEasingTime / 1000.;
- /* tp| |td
- * vp_ _______
- * / \
- * vi_ / \
- * \
- * \ _ 0
- * |ta| |ta|
- */
- qreal ta = met / 2.;
- a = (s - (vi * tf - 0.5 * vi * ta)) / (tf * ta - ta * ta);
-
- vp = vi + a * ta;
- d = vp / ta;
- tp = ta;
- sp = vi * ta + 0.5 * a * tp * tp;
- sd = sp + vp * (tf - 2 * ta);
- td = tf - ta;
- } else {
- qreal c1 = 0.25 * tf * tf;
- qreal c2 = 0.5 * vi * tf - s;
- qreal c3 = -0.25 * vi * vi;
-
- qreal a1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
-
- qreal tp1 = 0.5 * tf - 0.5 * vi / a1;
- qreal vp1 = a1 * tp1 + vi;
-
- qreal sp1 = 0.5 * a1 * tp1 * tp1 + vi * tp1;
-
- a = a1;
- d = a1;
- tp = tp1;
- td = tp1;
- vp = vp1;
- sp = sp1;
- sd = sp1;
- }
- return true;
-}
-
-qreal QSmoothedAnimation::easeFollow(qreal time_seconds)
-{
- qreal value;
- if (time_seconds < tp) {
- trackVelocity = vi + time_seconds * a;
- value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds;
- } else if (time_seconds < td) {
- time_seconds -= tp;
- trackVelocity = vp;
- value = sp + time_seconds * vp;
- } else if (time_seconds < tf) {
- time_seconds -= td;
- trackVelocity = vp - time_seconds * a;
- value = sd - 0.5 * d * time_seconds * time_seconds + vp * time_seconds;
- } else {
- trackVelocity = 0;
- value = s;
- delayedStop();
- }
-
- // to normalize 's' between [0..1], divide 'value' by 's'
- return value;
-}
-
-void QSmoothedAnimation::updateCurrentTime(int t)
-{
- qreal time_seconds = useDelta ? qreal(QDeclarativeAnimationTimer::instance()->currentDelta()) / 1000. : qreal(t - lastTime) / 1000.;
- if (useDelta)
- useDelta = false;
-
- qreal value = easeFollow(time_seconds);
- value *= (invert? -1.0: 1.0);
- QDeclarativePropertyPrivate::write(target, initialValue + value,
- QDeclarativePropertyPrivate::BypassInterceptor
- | QDeclarativePropertyPrivate::DontRemoveBinding);
-}
-
-void QSmoothedAnimation::init()
-{
- if (velocity == 0) {
- stop();
- return;
- }
-
- if (delayedStopTimer->isActive())
- delayedStopTimer->stop();
-
- initialValue = target.read().toReal();
- lastTime = this->currentTime();
-
- if (to == initialValue) {
- stop();
- return;
- }
-
- bool hasReversed = trackVelocity != 0. &&
- ((!invert) == ((initialValue - to) > 0));
-
- if (hasReversed) {
- switch (reversingMode) {
- default:
- case QDeclarativeSmoothedAnimation::Eased:
- initialVelocity = -trackVelocity;
- break;
- case QDeclarativeSmoothedAnimation::Sync:
- QDeclarativePropertyPrivate::write(target, to,
- QDeclarativePropertyPrivate::BypassInterceptor
- | QDeclarativePropertyPrivate::DontRemoveBinding);
- trackVelocity = 0;
- stop();
- return;
- case QDeclarativeSmoothedAnimation::Immediate:
- initialVelocity = 0;
- break;
- }
- }
-
- trackVelocity = initialVelocity;
-
- invert = (to < initialValue);
-
- if (!recalc()) {
- QDeclarativePropertyPrivate::write(target, to,
- QDeclarativePropertyPrivate::BypassInterceptor
- | QDeclarativePropertyPrivate::DontRemoveBinding);
- stop();
- return;
- }
-}
-
-/*!
- \qmlclass SmoothedAnimation QDeclarativeSmoothedAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits NumberAnimation
- \brief The SmoothedAnimation element allows a property to smoothly track a value.
-
- 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
- of 200 is set, will take 8 seconds with a duration of 8000 set, and will
- take 4 seconds with both a velocity of 200 and a duration of 8000 set.
- Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
- 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 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.
- To enable a smooth animation in this range the velocity will need to be
- set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity
- of 0.5 will take 2000 ms to complete.
-
- Like any other animation element, a SmoothedAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa SpringAnimation, NumberAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-
-QDeclarativeSmoothedAnimation::QDeclarativeSmoothedAnimation(QObject *parent)
-: QDeclarativeNumberAnimation(*(new QDeclarativeSmoothedAnimationPrivate), parent)
-{
-}
-
-QDeclarativeSmoothedAnimation::~QDeclarativeSmoothedAnimation()
-{
-
-}
-
-QDeclarativeSmoothedAnimationPrivate::QDeclarativeSmoothedAnimationPrivate()
- : anim(0)
-{
- anim = new QSmoothedAnimation;
-}
-
-QDeclarativeSmoothedAnimationPrivate::~QDeclarativeSmoothedAnimationPrivate()
-{
- delete anim;
- QHash<QDeclarativeProperty, QSmoothedAnimation* >::iterator it;
- for (it = activeAnimations.begin(); it != activeAnimations.end(); ++it) {
- it.value()->clearTemplate();
- }
-}
-
-void QDeclarativeSmoothedAnimationPrivate::updateRunningAnimations()
-{
- foreach(QSmoothedAnimation* ease, activeAnimations.values()){
- ease->maximumEasingTime = anim->maximumEasingTime;
- ease->reversingMode = anim->reversingMode;
- ease->velocity = anim->velocity;
- ease->userDuration = anim->userDuration;
- ease->init();
- }
-}
-
-QAbstractAnimationJob* QDeclarativeSmoothedAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_UNUSED(direction);
- Q_D(QDeclarativeSmoothedAnimation);
-
- QDeclarativeStateActions dataActions = QDeclarativePropertyAnimation::createTransitionActions(actions, modified, defaultTarget);
-
- QParallelAnimationGroupJob *wrapperGroup = new QParallelAnimationGroupJob();
-
- if (!dataActions.isEmpty()) {
- QSet<QAbstractAnimationJob*> anims;
- for (int i = 0; i < dataActions.size(); i++) {
- QSmoothedAnimation *ease;
- bool isActive;
- if (!d->activeAnimations.contains(dataActions[i].property)) {
- ease = new QSmoothedAnimation(d);
- d->activeAnimations.insert(dataActions[i].property, ease);
- ease->target = dataActions[i].property;
- isActive = false;
- } else {
- ease = d->activeAnimations.value(dataActions[i].property);
- isActive = true;
- }
- wrapperGroup->appendAnimation(initInstance(ease));
-
- ease->to = dataActions[i].toValue.toReal();
-
- // copying public members from main value holder animation
- ease->maximumEasingTime = d->anim->maximumEasingTime;
- ease->reversingMode = d->anim->reversingMode;
- ease->velocity = d->anim->velocity;
- ease->userDuration = d->anim->userDuration;
-
- ease->initialVelocity = ease->trackVelocity;
-
- if (isActive)
- ease->prepareForRestart();
- anims.insert(ease);
- }
-
- foreach (QSmoothedAnimation *ease, d->activeAnimations.values()){
- if (!anims.contains(ease)) {
- ease->clearTemplate();
- d->activeAnimations.remove(ease->target);
- }
- }
- }
- return wrapperGroup;
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::SmoothedAnimation::reversingMode
-
- Sets how the SmoothedAnimation behaves if an animation direction is reversed.
-
- Possible values are:
-
- \list
- \o SmoothedAnimation.Eased (default) - the animation will smoothly decelerate, and then reverse direction
- \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, beginning with a velocity of 0
- \o SmoothedAnimation.Sync - the property is immediately set to the target value
- \endlist
-*/
-QDeclarativeSmoothedAnimation::ReversingMode QDeclarativeSmoothedAnimation::reversingMode() const
-{
- Q_D(const QDeclarativeSmoothedAnimation);
- return (QDeclarativeSmoothedAnimation::ReversingMode) d->anim->reversingMode;
-}
-
-void QDeclarativeSmoothedAnimation::setReversingMode(ReversingMode m)
-{
- Q_D(QDeclarativeSmoothedAnimation);
- if (d->anim->reversingMode == m)
- return;
-
- d->anim->reversingMode = m;
- emit reversingModeChanged();
- d->updateRunningAnimations();
-}
-
-/*!
- \qmlproperty int QtQuick2::SmoothedAnimation::duration
-
- This property holds the animation duration, in msecs, used when tracking the source.
-
- Setting this to -1 (the default) disables the duration value.
-
- If the velocity value and the duration value are both enabled, then the animation will
- use whichever gives the shorter duration.
-*/
-int QDeclarativeSmoothedAnimation::duration() const
-{
- Q_D(const QDeclarativeSmoothedAnimation);
- return d->anim->userDuration;
-}
-
-void QDeclarativeSmoothedAnimation::setDuration(int duration)
-{
- Q_D(QDeclarativeSmoothedAnimation);
- if (duration != -1)
- QDeclarativeNumberAnimation::setDuration(duration);
- if(duration == d->anim->userDuration)
- return;
- d->anim->userDuration = duration;
- d->updateRunningAnimations();
-}
-
-qreal QDeclarativeSmoothedAnimation::velocity() const
-{
- Q_D(const QDeclarativeSmoothedAnimation);
- return d->anim->velocity;
-}
-
-/*!
- \qmlproperty real QtQuick2::SmoothedAnimation::velocity
-
- This property holds the average velocity allowed when tracking the 'to' value.
-
- The default velocity of SmoothedAnimation is 200 units/second.
-
- Setting this to -1 disables the velocity value.
-
- If the velocity value and the duration value are both enabled, then the animation will
- use whichever gives the shorter duration.
-*/
-void QDeclarativeSmoothedAnimation::setVelocity(qreal v)
-{
- Q_D(QDeclarativeSmoothedAnimation);
- if (d->anim->velocity == v)
- return;
-
- d->anim->velocity = v;
- emit velocityChanged();
- d->updateRunningAnimations();
-}
-
-/*!
- \qmlproperty int QtQuick2::SmoothedAnimation::maximumEasingTime
-
- This property specifies the maximum time, in msecs, any "eases" during the follow should take.
- Setting this property causes the velocity to "level out" after at a time. Setting
- a negative value reverts to the normal mode of easing over the entire animation
- duration.
-
- The default value is -1.
-*/
-int QDeclarativeSmoothedAnimation::maximumEasingTime() const
-{
- Q_D(const QDeclarativeSmoothedAnimation);
- return d->anim->maximumEasingTime;
-}
-
-void QDeclarativeSmoothedAnimation::setMaximumEasingTime(int v)
-{
- Q_D(QDeclarativeSmoothedAnimation);
- if(v == d->anim->maximumEasingTime)
- return;
- d->anim->maximumEasingTime = v;
- emit maximumEasingTimeChanged();
- d->updateRunningAnimations();
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativesmoothedanimation_p.h b/src/quick/util/qdeclarativesmoothedanimation_p.h
deleted file mode 100644
index 9a0bc22216..0000000000
--- a/src/quick/util/qdeclarativesmoothedanimation_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESMOOTHEDANIMATION_H
-#define QDECLARATIVESMOOTHEDANIMATION_H
-
-#include <qdeclarative.h>
-#include "qdeclarativeanimation_p.h"
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeProperty;
-class QDeclarativeSmoothedAnimationPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeSmoothedAnimation : public QDeclarativeNumberAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeSmoothedAnimation)
- Q_ENUMS(ReversingMode)
-
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
- Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged)
- Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged)
-
-public:
- enum ReversingMode { Eased, Immediate, Sync };
-
- QDeclarativeSmoothedAnimation(QObject *parent = 0);
- ~QDeclarativeSmoothedAnimation();
-
- ReversingMode reversingMode() const;
- void setReversingMode(ReversingMode);
-
- virtual int duration() const;
- virtual void setDuration(int);
-
- qreal velocity() const;
- void setVelocity(qreal);
-
- int maximumEasingTime() const;
- void setMaximumEasingTime(int);
-
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-Q_SIGNALS:
- void velocityChanged();
- void reversingModeChanged();
- void maximumEasingTimeChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeSmoothedAnimation)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESMOOTHEDANIMATION_H
diff --git a/src/quick/util/qdeclarativesmoothedanimation_p_p.h b/src/quick/util/qdeclarativesmoothedanimation_p_p.h
deleted file mode 100644
index 9afb6506a7..0000000000
--- a/src/quick/util/qdeclarativesmoothedanimation_p_p.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESMOOTHEDANIMATION2_P_H
-#define QDECLARATIVESMOOTHEDANIMATION2_P_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 "qdeclarativesmoothedanimation_p.h"
-#include "qdeclarativeanimation_p.h"
-
-#include "qdeclarativeanimation_p_p.h"
-
-#include "private/qparallelanimationgroupjob_p.h"
-
-#include <private/qobject_p.h>
-#include <QBasicTimer>
-
-QT_BEGIN_NAMESPACE
-class QSmoothedAnimation;
-class QSmoothedAnimationTimer : public QTimer
-{
- Q_OBJECT
-public:
- explicit QSmoothedAnimationTimer(QSmoothedAnimation *animation, QObject *parent = 0);
- ~QSmoothedAnimationTimer();
-public Q_SLOTS:
- void stopAnimation();
-private:
- QSmoothedAnimation *m_animation;
-};
-
-class QDeclarativeSmoothedAnimationPrivate;
-class Q_AUTOTEST_EXPORT QSmoothedAnimation : public QAbstractAnimationJob
-{
- Q_DISABLE_COPY(QSmoothedAnimation)
-public:
- QSmoothedAnimation(QDeclarativeSmoothedAnimationPrivate * = 0);
-
- ~QSmoothedAnimation();
- qreal to;
- qreal velocity;
- int userDuration;
-
- int maximumEasingTime;
- QDeclarativeSmoothedAnimation::ReversingMode reversingMode;
-
- qreal initialVelocity;
- qreal trackVelocity;
-
- QDeclarativeProperty target;
-
- int duration() const;
- void restart();
- void init();
-
- void prepareForRestart();
- void clearTemplate() { animationTemplate = 0; }
-
-protected:
- virtual void updateCurrentTime(int);
- virtual void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State);
-
-private:
- qreal easeFollow(qreal);
- qreal initialValue;
-
- bool invert;
-
- int finalDuration;
-
- // Parameters for use in updateCurrentTime()
- qreal a; // Acceleration
- qreal d; // Deceleration
- qreal tf; // Total time
- qreal tp; // Time at which peak velocity occurs
- qreal td; // Time at which deceleration begins
- qreal vp; // Velocity at tp
- qreal sp; // Displacement at tp
- qreal sd; // Displacement at td
- qreal vi; // "Normalized" initialvelocity
- qreal s; // Total s
-
- int lastTime;
- bool useDelta;
-
- bool recalc();
- void delayedStop();
- QSmoothedAnimationTimer *delayedStopTimer;
- QDeclarativeSmoothedAnimationPrivate *animationTemplate;
-};
-
-class QDeclarativeSmoothedAnimationPrivate : public QDeclarativePropertyAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeSmoothedAnimation)
-public:
- QDeclarativeSmoothedAnimationPrivate();
- ~QDeclarativeSmoothedAnimationPrivate();
- void updateRunningAnimations();
-
- QSmoothedAnimation *anim;
- QHash<QDeclarativeProperty, QSmoothedAnimation*> activeAnimations;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVESMOOTHEDANIMATION2_P_H
diff --git a/src/quick/util/qdeclarativespringanimation.cpp b/src/quick/util/qdeclarativespringanimation.cpp
deleted file mode 100644
index 3cc5f4dbc3..0000000000
--- a/src/quick/util/qdeclarativespringanimation.cpp
+++ /dev/null
@@ -1,593 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativespringanimation_p.h"
-
-#include "qdeclarativeanimation_p_p.h"
-#include <private/qdeclarativeproperty_p.h>
-#include "private/qparallelanimationgroupjob_p.h"
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-#include <limits.h>
-#include <math.h>
-
-#define DELAY_STOP_TIMER_INTERVAL 32
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeSpringAnimationPrivate;
-class Q_AUTOTEST_EXPORT QSpringAnimation : public QAbstractAnimationJob
-{
- Q_DISABLE_COPY(QSpringAnimation)
-public:
- QSpringAnimation(QDeclarativeSpringAnimationPrivate * = 0);
-
- ~QSpringAnimation();
- int duration() const;
- void restart();
- void init();
-
- qreal currentValue;
- qreal to;
- qreal velocity;
- int startTime;
- int dura;
- int lastTime;
- int stopTime;
- enum Mode {
- Track,
- Velocity,
- Spring
- };
- Mode mode;
- QDeclarativeProperty target;
-
- qreal velocityms;
- qreal maxVelocity;
- qreal mass;
- qreal spring;
- qreal damping;
- qreal epsilon;
- qreal modulus;
-
- bool useMass : 1;
- bool haveModulus : 1;
- bool useDelta : 1;
- typedef QHash<QDeclarativeProperty, QSpringAnimation*> ActiveAnimationHash;
-
- void clearTemplate() { animationTemplate = 0; }
-
-protected:
- virtual void updateCurrentTime(int time);
- virtual void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State);
-
-private:
- QDeclarativeSpringAnimationPrivate *animationTemplate;
-};
-
-class QDeclarativeSpringAnimationPrivate : public QDeclarativePropertyAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeSpringAnimation)
-public:
- QDeclarativeSpringAnimationPrivate()
- : QDeclarativePropertyAnimationPrivate()
- , velocityms(0)
- , maxVelocity(0)
- , mass(1.0)
- , spring(0.)
- , damping(0.)
- , epsilon(0.01)
- , modulus(0.0)
- , useMass(false)
- , haveModulus(false)
- , mode(QSpringAnimation::Track)
- { elapsed.start(); }
-
- void updateMode();
- qreal velocityms;
- qreal maxVelocity;
- qreal mass;
- qreal spring;
- qreal damping;
- qreal epsilon;
- qreal modulus;
-
- bool useMass : 1;
- bool haveModulus : 1;
- QSpringAnimation::Mode mode;
-
- QSpringAnimation::ActiveAnimationHash activeAnimations;
- QElapsedTimer elapsed;
-};
-
-QSpringAnimation::QSpringAnimation(QDeclarativeSpringAnimationPrivate *priv)
- : QAbstractAnimationJob()
- , currentValue(0)
- , to(0)
- , velocity(0)
- , startTime(0)
- , dura(0)
- , lastTime(0)
- , stopTime(-1)
- , mode(Track)
- , velocityms(0)
- , maxVelocity(0)
- , mass(1.0)
- , spring(0.)
- , damping(0.)
- , epsilon(0.01)
- , modulus(0.0)
- , useMass(false)
- , haveModulus(false)
- , useDelta(false)
- , animationTemplate(priv)
-{
-}
-
-QSpringAnimation::~QSpringAnimation()
-{
- if (animationTemplate) {
- if (target.object()) {
- QSpringAnimation::ActiveAnimationHash::iterator it =
- animationTemplate->activeAnimations.find(target);
- if (it != animationTemplate->activeAnimations.end() && it.value() == this)
- animationTemplate->activeAnimations.erase(it);
- } else {
- //target is no longer valid, need to search linearly
- QSpringAnimation::ActiveAnimationHash::iterator it;
- for (it = animationTemplate->activeAnimations.begin(); it != animationTemplate->activeAnimations.end(); ++it) {
- if (it.value() == this) {
- animationTemplate->activeAnimations.erase(it);
- break;
- }
- }
- }
- }
-}
-
-int QSpringAnimation::duration() const
-{
- return -1;
-}
-
-void QSpringAnimation::restart()
-{
- if (isRunning() || (stopTime != -1 && (animationTemplate->elapsed.elapsed() - stopTime) < DELAY_STOP_TIMER_INTERVAL)) {
- useDelta = true;
- init();
- lastTime = 0;
- } else {
- useDelta = false;
- //init() will be triggered when group starts
- }
-}
-
-void QSpringAnimation::init()
-{
- lastTime = startTime = 0;
- stopTime = -1;
-}
-
-void QSpringAnimation::updateCurrentTime(int time)
-{
- if (mode == Track) {
- stop();
- return;
- }
-
- int elapsed = useDelta ? QDeclarativeAnimationTimer::instance()->currentDelta() : time - lastTime;
- if (useDelta) {
- startTime = time - elapsed;
- useDelta = false;
- }
-
- if (!elapsed)
- return;
-
- int count = elapsed / 16;
-
- if (mode == Spring) {
- if (elapsed < 16) // capped at 62fps.
- return;
- lastTime = time - (elapsed - count * 16);
- } else {
- lastTime = time;
- }
-
- qreal srcVal = to;
-
- bool stopped = false;
-
- if (haveModulus) {
- currentValue = fmod(currentValue, modulus);
- srcVal = fmod(srcVal, modulus);
- }
- if (mode == Spring) {
- // Real men solve the spring DEs using RK4.
- // We'll do something much simpler which gives a result that looks fine.
- for (int i = 0; i < count; ++i) {
- qreal diff = srcVal - currentValue;
- if (haveModulus && qAbs(diff) > modulus / 2) {
- if (diff < 0)
- diff += modulus;
- else
- diff -= modulus;
- }
- if (useMass)
- velocity = velocity + (spring * diff - damping * velocity) / mass;
- else
- velocity = velocity + spring * diff - damping * velocity;
- if (maxVelocity > 0.) {
- // limit velocity
- if (velocity > maxVelocity)
- velocity = maxVelocity;
- else if (velocity < -maxVelocity)
- velocity = -maxVelocity;
- }
- currentValue += velocity * 16.0 / 1000.0;
- if (haveModulus) {
- currentValue = fmod(currentValue, modulus);
- if (currentValue < 0.0)
- currentValue += modulus;
- }
- }
- if (qAbs(velocity) < epsilon && qAbs(srcVal - currentValue) < epsilon) {
- velocity = 0.0;
- currentValue = srcVal;
- stopped = true;
- }
- } else {
- qreal moveBy = elapsed * velocityms;
- qreal diff = srcVal - currentValue;
- if (haveModulus && qAbs(diff) > modulus / 2) {
- if (diff < 0)
- diff += modulus;
- else
- diff -= modulus;
- }
- if (diff > 0) {
- currentValue += moveBy;
- if (haveModulus)
- currentValue = fmod(currentValue, modulus);
- } else {
- currentValue -= moveBy;
- if (haveModulus && currentValue < 0.0)
- currentValue = fmod(currentValue, modulus) + modulus;
- }
- if (lastTime - startTime >= dura) {
- currentValue = to;
- stopped = true;
- }
- }
-
- qreal old_to = to;
-
- QDeclarativePropertyPrivate::write(target, currentValue,
- QDeclarativePropertyPrivate::BypassInterceptor |
- QDeclarativePropertyPrivate::DontRemoveBinding);
-
- if (stopped && old_to == to) { // do not stop if we got restarted
- stopTime = animationTemplate->elapsed.elapsed();
- stop();
- }
-}
-
-void QSpringAnimation::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State /*oldState*/)
-{
- if (newState == QAbstractAnimationJob::Running)
- init();
-}
-
-void QDeclarativeSpringAnimationPrivate::updateMode()
-{
- if (spring == 0. && maxVelocity == 0.)
- mode = QSpringAnimation::Track;
- else if (spring > 0.)
- mode = QSpringAnimation::Spring;
- else {
- mode = QSpringAnimation::Velocity;
- QSpringAnimation::ActiveAnimationHash::iterator it;
- for (it = activeAnimations.begin(); it != activeAnimations.end(); ++it) {
- QSpringAnimation *animation = *it;
- animation->startTime = animation->lastTime;
- qreal dist = qAbs(animation->currentValue - animation->to);
- if (haveModulus && dist > modulus / 2)
- dist = modulus - fmod(dist, modulus);
- animation->dura = dist / velocityms;
- }
- }
-}
-
-/*!
- \qmlclass SpringAnimation QDeclarativeSpringAnimation
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \inherits NumberAnimation
-
- \brief The SpringAnimation element allows a property to track a value in a spring-like motion.
-
- SpringAnimation mimics the oscillatory behavior of a spring, with the appropriate \l spring constant to
- control the acceleration and the \l damping to control how quickly the effect dies away.
-
- 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. 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
-
- Like any other animation element, a SpringAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa SmoothedAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example}
-*/
-
-QDeclarativeSpringAnimation::QDeclarativeSpringAnimation(QObject *parent)
-: QDeclarativeNumberAnimation(*(new QDeclarativeSpringAnimationPrivate),parent)
-{
-}
-
-QDeclarativeSpringAnimation::~QDeclarativeSpringAnimation()
-{
- Q_D(QDeclarativeSpringAnimation);
- QSpringAnimation::ActiveAnimationHash::iterator it;
- for (it = d->activeAnimations.begin(); it != d->activeAnimations.end(); ++it) {
- it.value()->clearTemplate();
- }
-}
-
-/*!
- \qmlproperty real QtQuick2::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
-{
- Q_D(const QDeclarativeSpringAnimation);
- return d->maxVelocity;
-}
-
-void QDeclarativeSpringAnimation::setVelocity(qreal velocity)
-{
- Q_D(QDeclarativeSpringAnimation);
- d->maxVelocity = velocity;
- d->velocityms = velocity / 1000.0;
- d->updateMode();
-}
-
-/*!
- \qmlproperty real QtQuick2::SpringAnimation::spring
-
- 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 this property is set and the \l velocity value is greater than 0,
- the \l velocity limits the maximum speed.
-*/
-qreal QDeclarativeSpringAnimation::spring() const
-{
- Q_D(const QDeclarativeSpringAnimation);
- return d->spring;
-}
-
-void QDeclarativeSpringAnimation::setSpring(qreal spring)
-{
- Q_D(QDeclarativeSpringAnimation);
- d->spring = spring;
- d->updateMode();
-}
-
-/*!
- \qmlproperty real QtQuick2::SpringAnimation::damping
- This property holds the spring damping value.
-
- This value describes how quickly the spring-like motion comes to rest.
- The default value is 0.
-
- The useful value range is 0 - 1.0. The lower the value, the faster it
- comes to rest.
-*/
-qreal QDeclarativeSpringAnimation::damping() const
-{
- Q_D(const QDeclarativeSpringAnimation);
- return d->damping;
-}
-
-void QDeclarativeSpringAnimation::setDamping(qreal damping)
-{
- Q_D(QDeclarativeSpringAnimation);
- if (damping > 1.)
- damping = 1.;
-
- d->damping = damping;
-}
-
-
-/*!
- \qmlproperty real QtQuick2::SpringAnimation::epsilon
- This property holds the spring epsilon.
-
- The epsilon is the rate and amount of change in the value which is close enough
- to 0 to be considered equal to zero. This will depend on the usage of the value.
- For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
-
- The default is 0.01. Tuning this value can provide small performance improvements.
-*/
-qreal QDeclarativeSpringAnimation::epsilon() const
-{
- Q_D(const QDeclarativeSpringAnimation);
- return d->epsilon;
-}
-
-void QDeclarativeSpringAnimation::setEpsilon(qreal epsilon)
-{
- Q_D(QDeclarativeSpringAnimation);
- d->epsilon = epsilon;
-}
-
-/*!
- \qmlproperty real QtQuick2::SpringAnimation::modulus
- 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.
-*/
-qreal QDeclarativeSpringAnimation::modulus() const
-{
- Q_D(const QDeclarativeSpringAnimation);
- return d->modulus;
-}
-
-void QDeclarativeSpringAnimation::setModulus(qreal modulus)
-{
- Q_D(QDeclarativeSpringAnimation);
- if (d->modulus != modulus) {
- d->haveModulus = modulus != 0.0;
- d->modulus = modulus;
- d->updateMode();
- emit modulusChanged();
- }
-}
-
-/*!
- \qmlproperty real QtQuick2::SpringAnimation::mass
- This property holds the "mass" of the property being moved.
-
- 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
-{
- Q_D(const QDeclarativeSpringAnimation);
- return d->mass;
-}
-
-void QDeclarativeSpringAnimation::setMass(qreal mass)
-{
- Q_D(QDeclarativeSpringAnimation);
- if (d->mass != mass && mass > 0.0) {
- d->useMass = mass != 1.0;
- d->mass = mass;
- emit massChanged();
- }
-}
-
-QAbstractAnimationJob* QDeclarativeSpringAnimation::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativeSpringAnimation);
- Q_UNUSED(direction);
-
- QParallelAnimationGroupJob *wrapperGroup = new QParallelAnimationGroupJob();
-
- QDeclarativeStateActions dataActions = QDeclarativeNumberAnimation::createTransitionActions(actions, modified, defaultTarget);
- if (!dataActions.isEmpty()) {
- QSet<QAbstractAnimationJob*> anims;
- for (int i = 0; i < dataActions.size(); ++i) {
- QSpringAnimation *animation;
- bool needsRestart = false;
- const QDeclarativeProperty &property = dataActions.at(i).property;
- if (d->activeAnimations.contains(property)) {
- animation = d->activeAnimations[property];
- needsRestart = true;
- } else {
- animation = new QSpringAnimation(d);
- d->activeAnimations.insert(property, animation);
- animation->target = property;
- }
- wrapperGroup->appendAnimation(initInstance(animation));
-
- animation->to = dataActions.at(i).toValue.toReal();
- animation->startTime = 0;
- animation->velocityms = d->velocityms;
- animation->mass = d->mass;
- animation->spring = d->spring;
- animation->damping = d->damping;
- animation->epsilon = d->epsilon;
- animation->modulus = d->modulus;
- animation->useMass = d->useMass;
- animation->haveModulus = d->haveModulus;
- animation->mode = d->mode;
- animation->dura = -1;
- animation->maxVelocity = d->maxVelocity;
-
- if (d->fromIsDefined)
- animation->currentValue = dataActions.at(i).fromValue.toReal();
- else
- animation->currentValue = property.read().toReal();
- if (animation->mode == QSpringAnimation::Velocity) {
- qreal dist = qAbs(animation->currentValue - animation->to);
- if (d->haveModulus && dist > d->modulus / 2)
- dist = d->modulus - fmod(dist, d->modulus);
- animation->dura = dist / animation->velocityms;
- }
-
- if (needsRestart)
- animation->restart();
- anims.insert(animation);
- }
- foreach (QSpringAnimation *anim, d->activeAnimations.values()){
- if (!anims.contains(anim)) {
- anim->clearTemplate();
- d->activeAnimations.remove(anim->target);
- }
- }
- }
- return wrapperGroup;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativespringanimation_p.h b/src/quick/util/qdeclarativespringanimation_p.h
deleted file mode 100644
index 2f28700208..0000000000
--- a/src/quick/util/qdeclarativespringanimation_p.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESPRINGANIMATION_H
-#define QDECLARATIVESPRINGANIMATION_H
-
-#include <qdeclarative.h>
-#include "qdeclarativeanimation_p.h"
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeSpringAnimationPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeSpringAnimation : public QDeclarativeNumberAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeSpringAnimation)
- Q_INTERFACES(QDeclarativePropertyValueSource)
-
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
- Q_PROPERTY(qreal spring READ spring WRITE setSpring)
- Q_PROPERTY(qreal damping READ damping WRITE setDamping)
- Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon)
- Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
- Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
-
-public:
- QDeclarativeSpringAnimation(QObject *parent=0);
- ~QDeclarativeSpringAnimation();
-
- qreal velocity() const;
- void setVelocity(qreal velocity);
-
- qreal spring() const;
- void setSpring(qreal spring);
-
- qreal damping() const;
- void setDamping(qreal damping);
-
- qreal epsilon() const;
- void setEpsilon(qreal epsilon);
-
- qreal mass() const;
- void setMass(qreal modulus);
-
- qreal modulus() const;
- void setModulus(qreal modulus);
-
- virtual QAbstractAnimationJob* transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction,
- QObject *defaultTarget = 0);
-
-Q_SIGNALS:
- void modulusChanged();
- void massChanged();
- void syncChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeSpringAnimation)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESPRINGANIMATION_H
diff --git a/src/quick/util/qdeclarativestate.cpp b/src/quick/util/qdeclarativestate.cpp
deleted file mode 100644
index f0795e92bc..0000000000
--- a/src/quick/util/qdeclarativestate.cpp
+++ /dev/null
@@ -1,729 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativestate_p_p.h"
-#include "qdeclarativestate_p.h"
-
-#include "qdeclarativestategroup_p.h"
-#include "qdeclarativestateoperations_p.h"
-
-#include <private/qdeclarativeglobal_p.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-QDeclarativeAction::QDeclarativeAction()
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), event(0),
- specifiedObject(0)
-{
-}
-
-QDeclarativeAction::QDeclarativeAction(QObject *target, const QString &propertyName,
- const QVariant &value)
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
- property(target, propertyName, qmlEngine(target)), toValue(value),
- fromBinding(0), event(0),
- specifiedObject(target), specifiedProperty(propertyName)
-{
- if (property.isValid())
- fromValue = property.read();
-}
-
-QDeclarativeAction::QDeclarativeAction(QObject *target, const QString &propertyName,
- QDeclarativeContext *context, const QVariant &value)
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
- property(target, propertyName, context), toValue(value),
- fromBinding(0), event(0),
- specifiedObject(target), specifiedProperty(propertyName)
-{
- if (property.isValid())
- fromValue = property.read();
-}
-
-
-QDeclarativeActionEvent::~QDeclarativeActionEvent()
-{
-}
-
-void QDeclarativeActionEvent::execute(Reason)
-{
-}
-
-bool QDeclarativeActionEvent::isReversable()
-{
- return false;
-}
-
-void QDeclarativeActionEvent::reverse(Reason)
-{
-}
-
-bool QDeclarativeActionEvent::changesBindings()
-{
- return false;
-}
-
-void QDeclarativeActionEvent::clearBindings()
-{
-}
-
-bool QDeclarativeActionEvent::override(QDeclarativeActionEvent *other)
-{
- Q_UNUSED(other);
- return false;
-}
-
-QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
-}
-
-/*!
- \qmlclass State QDeclarativeState
- \inqmlmodule QtQuick 2
- \ingroup qml-state-elements
- \brief The State element defines configurations of objects and properties.
-
- A \e state is a set of batched changes from the default configuration.
-
- All items have a default state that defines the default configuration of objects
- and property values. New states can be defined by adding State items to the \l {Item::states}{states} property to
- allow items to switch between different configurations. These configurations
- can, for example, be used to apply different sets of property values or execute
- different scripts.
-
- The following example displays a single \l Rectangle. In the default state, the rectangle
- is colored black. In the "clicked" state, a PropertyChanges element changes the
- rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state
- between the default state and the "clicked" state, thus toggling the color of the
- rectangle between black and red.
-
- \snippet doc/src/snippets/declarative/state.qml 0
-
- Notice the default state is referred to using an empty string ("").
-
- States are commonly used together with \l{QML Animation and Transitions}{Transitions} to provide
- animations when state changes occur.
-
- \note Setting the state of an object from within another state of the same object is
- not allowed.
-
- \sa {declarative/animation/states}{states example}, {qmlstates}{States},
- {QML Animation and Transitions}{Transitions}, QtDeclarative
-*/
-QDeclarativeState::QDeclarativeState(QObject *parent)
-: QObject(*(new QDeclarativeStatePrivate), parent)
-{
- Q_D(QDeclarativeState);
- d->transitionManager.setState(this);
-}
-
-QDeclarativeState::~QDeclarativeState()
-{
- Q_D(QDeclarativeState);
- if (d->group)
- d->group->removeState(this);
-}
-
-/*!
- \qmlproperty string QtQuick2::State::name
- This property holds the name of the state.
-
- Each state should have a unique name within its item.
-*/
-QString QDeclarativeState::name() const
-{
- Q_D(const QDeclarativeState);
- return d->name;
-}
-
-void QDeclarativeState::setName(const QString &n)
-{
- Q_D(QDeclarativeState);
- d->name = n;
- d->named = true;
-}
-
-bool QDeclarativeState::isNamed() const
-{
- Q_D(const QDeclarativeState);
- return d->named;
-}
-
-bool QDeclarativeState::isWhenKnown() const
-{
- Q_D(const QDeclarativeState);
- return d->when != 0;
-}
-
-/*!
- \qmlproperty bool QtQuick2::State::when
- This property holds when the state should be applied.
-
- This should be set to an expression that evaluates to \c true when you want the state to
- be applied. For example, the following \l Rectangle changes in and out of the "hidden"
- state when the \l MouseArea is pressed:
-
- \snippet doc/src/snippets/declarative/state-when.qml 0
-
- If multiple states in a group have \c when clauses that evaluate to \c true
- at the same time, the first matching state will be applied. For example, in
- the following snippet \c state1 will always be selected rather than
- \c state2 when sharedCondition becomes \c true.
- \qml
- Item {
- states: [
- State { name: "state1"; when: sharedCondition },
- State { name: "state2"; when: sharedCondition }
- ]
- // ...
- }
- \endqml
-*/
-QDeclarativeBinding *QDeclarativeState::when() const
-{
- Q_D(const QDeclarativeState);
- return d->when;
-}
-
-void QDeclarativeState::setWhen(QDeclarativeBinding *when)
-{
- Q_D(QDeclarativeState);
- d->when = when;
- if (d->group)
- d->group->updateAutoState();
-}
-
-/*!
- \qmlproperty string QtQuick2::State::extend
- This property holds the state that this state extends.
-
- When a state extends another state, it inherits all the changes of that state.
-
- The state being extended is treated as the base state in regards to
- the changes specified by the extending state.
-*/
-QString QDeclarativeState::extends() const
-{
- Q_D(const QDeclarativeState);
- return d->extends;
-}
-
-void QDeclarativeState::setExtends(const QString &extends)
-{
- Q_D(QDeclarativeState);
- d->extends = extends;
-}
-
-/*!
- \qmlproperty list<Change> QtQuick2::State::changes
- This property holds the changes to apply for this state
- \default
-
- By default these changes are applied against the default state. If the state
- extends another state, then the changes are applied against the state being
- extended.
-*/
-QDeclarativeListProperty<QDeclarativeStateOperation> QDeclarativeState::changes()
-{
- Q_D(QDeclarativeState);
- return QDeclarativeListProperty<QDeclarativeStateOperation>(this, &d->operations, QDeclarativeStatePrivate::operations_append,
- QDeclarativeStatePrivate::operations_count, QDeclarativeStatePrivate::operations_at,
- QDeclarativeStatePrivate::operations_clear);
-}
-
-int QDeclarativeState::operationCount() const
-{
- Q_D(const QDeclarativeState);
- return d->operations.count();
-}
-
-QDeclarativeStateOperation *QDeclarativeState::operationAt(int index) const
-{
- Q_D(const QDeclarativeState);
- return d->operations.at(index);
-}
-
-QDeclarativeState &QDeclarativeState::operator<<(QDeclarativeStateOperation *op)
-{
- Q_D(QDeclarativeState);
- d->operations.append(QDeclarativeStatePrivate::OperationGuard(op, &d->operations));
- return *this;
-}
-
-void QDeclarativeStatePrivate::complete()
-{
- Q_Q(QDeclarativeState);
-
- for (int ii = 0; ii < reverting.count(); ++ii) {
- for (int jj = 0; jj < revertList.count(); ++jj) {
- const QDeclarativeRevertAction &revert = reverting.at(ii);
- const QDeclarativeSimpleAction &simple = revertList.at(jj);
- if ((revert.event && simple.event() == revert.event) ||
- simple.property() == revert.property) {
- revertList.removeAt(jj);
- break;
- }
- }
- }
- reverting.clear();
-
- if (group)
- group->stateAboutToComplete();
- emit q->completed();
-}
-
-// Generate a list of actions for this state. This includes coelescing state
-// actions that this state "extends"
-QDeclarativeStateOperation::ActionList
-QDeclarativeStatePrivate::generateActionList() const
-{
- QDeclarativeStateOperation::ActionList applyList;
- if (inState)
- return applyList;
-
- // Prevent "extends" recursion
- inState = true;
-
- if (!extends.isEmpty()) {
- QList<QDeclarativeState *> states = group ? group->states() : QList<QDeclarativeState *>();
- for (int ii = 0; ii < states.count(); ++ii)
- if (states.at(ii)->name() == extends) {
- qmlExecuteDeferred(states.at(ii));
- applyList = static_cast<QDeclarativeStatePrivate*>(states.at(ii)->d_func())->generateActionList();
- }
- }
-
- foreach(QDeclarativeStateOperation *op, operations)
- applyList << op->actions();
-
- inState = false;
- return applyList;
-}
-
-QDeclarativeStateGroup *QDeclarativeState::stateGroup() const
-{
- Q_D(const QDeclarativeState);
- return d->group;
-}
-
-void QDeclarativeState::setStateGroup(QDeclarativeStateGroup *group)
-{
- Q_D(QDeclarativeState);
- d->group = group;
-}
-
-void QDeclarativeState::cancel()
-{
- Q_D(QDeclarativeState);
- d->transitionManager.cancel();
-}
-
-void QDeclarativeAction::deleteFromBinding()
-{
- if (fromBinding) {
- QDeclarativePropertyPrivate::setBinding(property, 0);
- fromBinding->destroy();
- fromBinding = 0;
- }
-}
-
-bool QDeclarativeState::containsPropertyInRevertList(QObject *target, const QString &name) const
-{
- Q_D(const QDeclarativeState);
-
- if (isStateActive()) {
- QListIterator<QDeclarativeSimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- const QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
- return true;
- }
- }
-
- return false;
-}
-
-bool QDeclarativeState::changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue)
-{
- Q_D(QDeclarativeState);
-
- if (isStateActive()) {
- QMutableListIterator<QDeclarativeSimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
- simpleAction.setValue(revertValue);
- return true;
- }
- }
- }
-
- return false;
-}
-
-bool QDeclarativeState::changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding)
-{
- Q_D(QDeclarativeState);
-
- if (isStateActive()) {
- QMutableListIterator<QDeclarativeSimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
- if (simpleAction.binding())
- simpleAction.binding()->destroy();
-
- simpleAction.setBinding(binding);
- return true;
- }
- }
- }
-
- return false;
-}
-
-bool QDeclarativeState::removeEntryFromRevertList(QObject *target, const QString &name)
-{
- Q_D(QDeclarativeState);
-
- if (isStateActive()) {
- QMutableListIterator<QDeclarativeSimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.property().object() == target && simpleAction.property().name() == name) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property());
- if (oldBinding) {
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0);
- oldBinding->destroy();
- }
-
- simpleAction.property().write(simpleAction.value());
- if (simpleAction.binding())
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding());
-
- revertListIterator.remove();
- return true;
- }
- }
- }
-
- return false;
-}
-
-void QDeclarativeState::addEntryToRevertList(const QDeclarativeAction &action)
-{
- Q_D(QDeclarativeState);
-
- QDeclarativeSimpleAction simpleAction(action);
-
- d->revertList.append(simpleAction);
-}
-
-void QDeclarativeState::removeAllEntriesFromRevertList(QObject *target)
-{
- Q_D(QDeclarativeState);
-
- if (isStateActive()) {
- QMutableListIterator<QDeclarativeSimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.property().object() == target) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property());
- if (oldBinding) {
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0);
- oldBinding->destroy();
- }
-
- simpleAction.property().write(simpleAction.value());
- if (simpleAction.binding())
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding());
-
- revertListIterator.remove();
- }
- }
- }
-}
-
-void QDeclarativeState::addEntriesToRevertList(const QList<QDeclarativeAction> &actionList)
-{
- Q_D(QDeclarativeState);
- if (isStateActive()) {
- QList<QDeclarativeSimpleAction> simpleActionList;
-
- QListIterator<QDeclarativeAction> actionListIterator(actionList);
- while(actionListIterator.hasNext()) {
- const QDeclarativeAction &action = actionListIterator.next();
- QDeclarativeSimpleAction simpleAction(action);
- action.property.write(action.toValue);
- if (!action.toBinding.isNull()) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property());
- if (oldBinding)
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0);
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), action.toBinding.data(), QDeclarativePropertyPrivate::DontRemoveBinding);
- }
-
- simpleActionList.append(simpleAction);
- }
-
- d->revertList.append(simpleActionList);
- }
-}
-
-QVariant QDeclarativeState::valueInRevertList(QObject *target, const QString &name) const
-{
- Q_D(const QDeclarativeState);
-
- if (isStateActive()) {
- QListIterator<QDeclarativeSimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- const QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
- return simpleAction.value();
- }
- }
-
- return QVariant();
-}
-
-QDeclarativeAbstractBinding *QDeclarativeState::bindingInRevertList(QObject *target, const QString &name) const
-{
- Q_D(const QDeclarativeState);
-
- if (isStateActive()) {
- QListIterator<QDeclarativeSimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- const QDeclarativeSimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
- return simpleAction.binding();
- }
- }
-
- return 0;
-}
-
-bool QDeclarativeState::isStateActive() const
-{
- return stateGroup() && stateGroup()->state() == name();
-}
-
-void QDeclarativeState::apply(QDeclarativeTransition *trans, QDeclarativeState *revert)
-{
- Q_D(QDeclarativeState);
-
- qmlExecuteDeferred(this);
-
- cancel();
- if (revert)
- revert->cancel();
- d->revertList.clear();
- d->reverting.clear();
-
- if (revert) {
- QDeclarativeStatePrivate *revertPrivate =
- static_cast<QDeclarativeStatePrivate*>(revert->d_func());
- d->revertList = revertPrivate->revertList;
- revertPrivate->revertList.clear();
- }
-
- // List of actions caused by this state
- QDeclarativeStateOperation::ActionList applyList = d->generateActionList();
-
- // List of actions that need to be reverted to roll back (just) this state
- QDeclarativeStatePrivate::SimpleActionList additionalReverts;
- // First add the reverse of all the applyList actions
- for (int ii = 0; ii < applyList.count(); ++ii) {
- QDeclarativeAction &action = applyList[ii];
-
- if (action.event) {
- if (!action.event->isReversable())
- continue;
- bool found = false;
- for (int jj = 0; jj < d->revertList.count(); ++jj) {
- QDeclarativeActionEvent *event = d->revertList.at(jj).event();
- if (event && event->type() == action.event->type()) {
- if (action.event->override(event)) {
- found = true;
-
- if (action.event != d->revertList.at(jj).event() && action.event->needsCopy()) {
- action.event->copyOriginals(d->revertList.at(jj).event());
-
- QDeclarativeSimpleAction r(action);
- additionalReverts << r;
- d->revertList.removeAt(jj);
- --jj;
- } else if (action.event->isRewindable()) //###why needed?
- action.event->saveCurrentValues();
-
- break;
- }
- }
- }
- if (!found) {
- action.event->saveOriginals();
- // Only need to revert the applyList action if the previous
- // state doesn't have a higher priority revert already
- QDeclarativeSimpleAction r(action);
- additionalReverts << r;
- }
- } else {
- bool found = false;
- action.fromBinding = QDeclarativePropertyPrivate::binding(action.property);
-
- for (int jj = 0; jj < d->revertList.count(); ++jj) {
- if (d->revertList.at(jj).property() == action.property) {
- found = true;
- if (d->revertList.at(jj).binding() != action.fromBinding) {
- action.deleteFromBinding();
- }
- break;
- }
- }
-
- if (!found) {
- if (!action.restore) {
- action.deleteFromBinding();;
- } else {
- // Only need to revert the applyList action if the previous
- // state doesn't have a higher priority revert already
- QDeclarativeSimpleAction r(action);
- additionalReverts << r;
- }
- }
- }
- }
-
- // Any reverts from a previous state that aren't carried forth
- // into this state need to be translated into apply actions
- for (int ii = 0; ii < d->revertList.count(); ++ii) {
- bool found = false;
- if (d->revertList.at(ii).event()) {
- QDeclarativeActionEvent *event = d->revertList.at(ii).event();
- if (!event->isReversable())
- continue;
- for (int jj = 0; !found && jj < applyList.count(); ++jj) {
- const QDeclarativeAction &action = applyList.at(jj);
- if (action.event && action.event->type() == event->type()) {
- if (action.event->override(event))
- found = true;
- }
- }
- } else {
- for (int jj = 0; !found && jj < applyList.count(); ++jj) {
- const QDeclarativeAction &action = applyList.at(jj);
- if (action.property == d->revertList.at(ii).property())
- found = true;
- }
- }
- if (!found) {
- QVariant cur = d->revertList.at(ii).property().read();
- QDeclarativeAbstractBinding *delBinding =
- QDeclarativePropertyPrivate::setBinding(d->revertList.at(ii).property(), 0);
- if (delBinding)
- delBinding->destroy();
-
- QDeclarativeAction a;
- a.property = d->revertList.at(ii).property();
- a.fromValue = cur;
- a.toValue = d->revertList.at(ii).value();
- a.toBinding = QDeclarativeAbstractBinding::getPointer(d->revertList.at(ii).binding());
- a.specifiedObject = d->revertList.at(ii).specifiedObject();
- a.specifiedProperty = d->revertList.at(ii).specifiedProperty();
- a.event = d->revertList.at(ii).event();
- a.reverseEvent = d->revertList.at(ii).reverseEvent();
- if (a.event && a.event->isRewindable())
- a.event->saveCurrentValues();
- applyList << a;
- // Store these special reverts in the reverting list
- if (a.event)
- d->reverting << a.event;
- else
- d->reverting << a.property;
- }
- }
- // All the local reverts now become part of the ongoing revertList
- d->revertList << additionalReverts;
-
-#ifndef QT_NO_DEBUG_STREAM
- // Output for debugging
- if (stateChangeDebug()) {
- foreach(const QDeclarativeAction &action, applyList) {
- if (action.event)
- qWarning() << " QDeclarativeAction event:" << action.event->type();
- else
- qWarning() << " QDeclarativeAction:" << action.property.object()
- << action.property.name() << "From:" << action.fromValue
- << "To:" << action.toValue;
- }
- }
-#endif
-
- d->transitionManager.transition(applyList, trans);
-}
-
-QDeclarativeStateOperation::ActionList QDeclarativeStateOperation::actions()
-{
- return ActionList();
-}
-
-QDeclarativeState *QDeclarativeStateOperation::state() const
-{
- Q_D(const QDeclarativeStateOperation);
- return d->m_state;
-}
-
-void QDeclarativeStateOperation::setState(QDeclarativeState *state)
-{
- Q_D(QDeclarativeStateOperation);
- d->m_state = state;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativestate_p.h b/src/quick/util/qdeclarativestate_p.h
deleted file mode 100644
index 5c2606e7cd..0000000000
--- a/src/quick/util/qdeclarativestate_p.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTATE_H
-#define QDECLARATIVESTATE_H
-
-#include <qdeclarative.h>
-#include <qdeclarativeproperty.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qsharedpointer.h>
-#include <private/qtquickglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeActionEvent;
-class QDeclarativeAbstractBinding;
-class QDeclarativeBinding;
-class QDeclarativeExpression;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeAction
-{
-public:
- QDeclarativeAction();
- QDeclarativeAction(QObject *, const QString &, const QVariant &);
- QDeclarativeAction(QObject *, const QString &,
- QDeclarativeContext *, const QVariant &);
-
- bool restore:1;
- bool actionDone:1;
- bool reverseEvent:1;
- bool deletableToBinding:1;
-
- QDeclarativeProperty property;
- QVariant fromValue;
- QVariant toValue;
-
- QDeclarativeAbstractBinding *fromBinding;
- QWeakPointer<QDeclarativeAbstractBinding> toBinding;
- QDeclarativeActionEvent *event;
-
- //strictly for matching
- QObject *specifiedObject;
- QString specifiedProperty;
-
- void deleteFromBinding();
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeActionEvent
-{
-public:
- virtual ~QDeclarativeActionEvent();
-
- enum EventType { Script, SignalHandler, ParentChange, AnchorChanges };
- enum Reason { ActualChange, FastForward };
-
- virtual EventType type() const = 0;
-
- virtual void execute(Reason reason = ActualChange);
- virtual bool isReversable();
- virtual void reverse(Reason reason = ActualChange);
- virtual void saveOriginals() {}
- virtual bool needsCopy() { return false; }
- virtual void copyOriginals(QDeclarativeActionEvent *) {}
-
- virtual bool isRewindable() { return isReversable(); }
- virtual void rewind() {}
- virtual void saveCurrentValues() {}
- virtual void saveTargetValues() {}
-
- virtual bool changesBindings();
- virtual void clearBindings();
- virtual bool override(QDeclarativeActionEvent*other);
-};
-
-//### rename to QDeclarativeStateChange?
-class QDeclarativeStateGroup;
-class QDeclarativeState;
-class QDeclarativeStateOperationPrivate;
-class Q_QUICK_EXPORT QDeclarativeStateOperation : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeStateOperation(QObject *parent = 0)
- : QObject(parent) {}
- typedef QList<QDeclarativeAction> ActionList;
-
- virtual ActionList actions();
-
- QDeclarativeState *state() const;
- void setState(QDeclarativeState *state);
-
-protected:
- QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent = 0);
-
-private:
- Q_DECLARE_PRIVATE(QDeclarativeStateOperation)
- Q_DISABLE_COPY(QDeclarativeStateOperation)
-};
-
-typedef QDeclarativeStateOperation::ActionList QDeclarativeStateActions;
-
-class QDeclarativeTransition;
-class QDeclarativeStatePrivate;
-class Q_QUICK_EXPORT QDeclarativeState : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen)
- Q_PROPERTY(QString extend READ extends WRITE setExtends)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeStateOperation> changes READ changes)
- Q_CLASSINFO("DefaultProperty", "changes")
- Q_CLASSINFO("DeferredPropertyNames", "changes")
-
-public:
- QDeclarativeState(QObject *parent=0);
- virtual ~QDeclarativeState();
-
- QString name() const;
- void setName(const QString &);
- bool isNamed() const;
-
- /*'when' is a QDeclarativeBinding to limit state changes oscillation
- due to the unpredictable order of evaluation of bound expressions*/
- bool isWhenKnown() const;
- QDeclarativeBinding *when() const;
- void setWhen(QDeclarativeBinding *);
-
- QString extends() const;
- void setExtends(const QString &);
-
- QDeclarativeListProperty<QDeclarativeStateOperation> changes();
- int operationCount() const;
- QDeclarativeStateOperation *operationAt(int) const;
-
- QDeclarativeState &operator<<(QDeclarativeStateOperation *);
-
- void apply(QDeclarativeTransition *, QDeclarativeState *revert);
- void cancel();
-
- QDeclarativeStateGroup *stateGroup() const;
- void setStateGroup(QDeclarativeStateGroup *);
-
- bool containsPropertyInRevertList(QObject *target, const QString &name) const;
- bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
- bool changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding);
- bool removeEntryFromRevertList(QObject *target, const QString &name);
- void addEntryToRevertList(const QDeclarativeAction &action);
- void removeAllEntriesFromRevertList(QObject *target);
- void addEntriesToRevertList(const QList<QDeclarativeAction> &actions);
- QVariant valueInRevertList(QObject *target, const QString &name) const;
- QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const;
-
- bool isStateActive() const;
-
-Q_SIGNALS:
- void completed();
-
-private:
- Q_DECLARE_PRIVATE(QDeclarativeState)
- Q_DISABLE_COPY(QDeclarativeState)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeStateOperation)
-QML_DECLARE_TYPE(QDeclarativeState)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESTATE_H
diff --git a/src/quick/util/qdeclarativestate_p_p.h b/src/quick/util/qdeclarativestate_p_p.h
deleted file mode 100644
index 4cf2bf4561..0000000000
--- a/src/quick/util/qdeclarativestate_p_p.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTATE_P_H
-#define QDECLARATIVESTATE_P_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 "qdeclarativestate_p.h"
-
-#include "qdeclarativetransitionmanager_p_p.h"
-
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativeguard_p.h>
-
-#include <private/qdeclarativebinding_p.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeSimpleAction
-{
-public:
- enum State { StartState, EndState };
- QDeclarativeSimpleAction(const QDeclarativeAction &a, State state = StartState)
- {
- m_property = a.property;
- m_specifiedObject = a.specifiedObject;
- m_specifiedProperty = a.specifiedProperty;
- m_event = a.event;
- if (state == StartState) {
- m_value = a.fromValue;
- if (QDeclarativePropertyPrivate::binding(m_property)) {
- m_binding = QDeclarativeAbstractBinding::getPointer(QDeclarativePropertyPrivate::binding(m_property));
- }
- m_reverseEvent = true;
- } else {
- m_value = a.toValue;
- m_binding = a.toBinding;
- m_reverseEvent = false;
- }
- }
-
- ~QDeclarativeSimpleAction()
- {
- }
-
- QDeclarativeSimpleAction(const QDeclarativeSimpleAction &other)
- : m_property(other.m_property),
- m_value(other.m_value),
- m_binding(QDeclarativeAbstractBinding::getPointer(other.binding())),
- m_specifiedObject(other.m_specifiedObject),
- m_specifiedProperty(other.m_specifiedProperty),
- m_event(other.m_event),
- m_reverseEvent(other.m_reverseEvent)
- {
- }
-
- QDeclarativeSimpleAction &operator =(const QDeclarativeSimpleAction &other)
- {
- m_property = other.m_property;
- m_value = other.m_value;
- m_binding = QDeclarativeAbstractBinding::getPointer(other.binding());
- m_specifiedObject = other.m_specifiedObject;
- m_specifiedProperty = other.m_specifiedProperty;
- m_event = other.m_event;
- m_reverseEvent = other.m_reverseEvent;
-
- return *this;
- }
-
- void setProperty(const QDeclarativeProperty &property)
- {
- m_property = property;
- }
-
- const QDeclarativeProperty &property() const
- {
- return m_property;
- }
-
- void setValue(const QVariant &value)
- {
- m_value = value;
- }
-
- const QVariant &value() const
- {
- return m_value;
- }
-
- void setBinding(QDeclarativeAbstractBinding *binding)
- {
- m_binding = QDeclarativeAbstractBinding::getPointer(binding);
- }
-
- QDeclarativeAbstractBinding *binding() const
- {
- return m_binding.data();
- }
-
- QObject *specifiedObject() const
- {
- return m_specifiedObject;
- }
-
- const QString &specifiedProperty() const
- {
- return m_specifiedProperty;
- }
-
- QDeclarativeActionEvent *event() const
- {
- return m_event;
- }
-
- bool reverseEvent() const
- {
- return m_reverseEvent;
- }
-
-private:
- QDeclarativeProperty m_property;
- QVariant m_value;
- QDeclarativeAbstractBinding::Pointer m_binding;
- QObject *m_specifiedObject;
- QString m_specifiedProperty;
- QDeclarativeActionEvent *m_event;
- bool m_reverseEvent;
-};
-
-class QDeclarativeRevertAction
-{
-public:
- QDeclarativeRevertAction() : event(0) {}
- QDeclarativeRevertAction(const QDeclarativeProperty &prop) : property(prop), event(0) {}
- QDeclarativeRevertAction(QDeclarativeActionEvent *e) : event(e) {}
- QDeclarativeProperty property;
- QDeclarativeActionEvent *event;
-};
-
-class QDeclarativeStateOperationPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeStateOperation)
-
-public:
-
- QDeclarativeStateOperationPrivate()
- : m_state(0) {}
-
- QDeclarativeState *m_state;
-};
-
-class QDeclarativeStatePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeState)
-
-public:
- QDeclarativeStatePrivate()
- : when(0), named(false), inState(false), group(0) {}
-
- typedef QList<QDeclarativeSimpleAction> SimpleActionList;
-
- QString name;
- QDeclarativeBinding *when;
- bool named;
-
- struct OperationGuard : public QDeclarativeGuard<QDeclarativeStateOperation>
- {
- OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) {
- setObject(static_cast<QDeclarativeStateOperation *>(obj));
- }
- QList<OperationGuard> *list;
- void objectDestroyed(QDeclarativeStateOperation *) {
- // we assume priv will always be destroyed after objectDestroyed calls
- list->removeOne(*this);
- }
- };
- QList<OperationGuard> operations;
-
- static void operations_append(QDeclarativeListProperty<QDeclarativeStateOperation> *prop, QDeclarativeStateOperation *op) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- op->setState(qobject_cast<QDeclarativeState*>(prop->object));
- list->append(OperationGuard(op, list));
- }
- static void operations_clear(QDeclarativeListProperty<QDeclarativeStateOperation> *prop) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- QMutableListIterator<OperationGuard> listIterator(*list);
- while(listIterator.hasNext())
- listIterator.next()->setState(0);
- list->clear();
- }
- static int operations_count(QDeclarativeListProperty<QDeclarativeStateOperation> *prop) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- return list->count();
- }
- static QDeclarativeStateOperation *operations_at(QDeclarativeListProperty<QDeclarativeStateOperation> *prop, int index) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- return list->at(index);
- }
-
- QDeclarativeTransitionManager transitionManager;
-
- SimpleActionList revertList;
- QList<QDeclarativeRevertAction> reverting;
- QString extends;
- mutable bool inState;
- QDeclarativeStateGroup *group;
-
- QDeclarativeStateOperation::ActionList generateActionList() const;
- void complete();
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVESTATE_P_H
diff --git a/src/quick/util/qdeclarativestategroup.cpp b/src/quick/util/qdeclarativestategroup.cpp
deleted file mode 100644
index 1ed3ffc582..0000000000
--- a/src/quick/util/qdeclarativestategroup.cpp
+++ /dev/null
@@ -1,516 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativestategroup_p.h"
-
-#include "qdeclarativetransition_p.h"
-
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativeglobal_p.h>
-
-#include <QtCore/qstringbuilder.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-#include <qdeclarativeinfo.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-class QDeclarativeStateGroupPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeStateGroup)
-public:
- QDeclarativeStateGroupPrivate()
- : nullState(0), componentComplete(true),
- ignoreTrans(false), applyingState(false), unnamedCount(0) {}
-
- QString currentState;
- QDeclarativeState *nullState;
-
- static void append_state(QDeclarativeListProperty<QDeclarativeState> *list, QDeclarativeState *state);
- static int count_state(QDeclarativeListProperty<QDeclarativeState> *list);
- static QDeclarativeState *at_state(QDeclarativeListProperty<QDeclarativeState> *list, int index);
- static void clear_states(QDeclarativeListProperty<QDeclarativeState> *list);
-
- static void append_transition(QDeclarativeListProperty<QDeclarativeTransition> *list, QDeclarativeTransition *state);
- static int count_transitions(QDeclarativeListProperty<QDeclarativeTransition> *list);
- static QDeclarativeTransition *at_transition(QDeclarativeListProperty<QDeclarativeTransition> *list, int index);
- static void clear_transitions(QDeclarativeListProperty<QDeclarativeTransition> *list);
-
- QList<QDeclarativeState *> states;
- QList<QDeclarativeTransition *> transitions;
-
- bool componentComplete;
- bool ignoreTrans;
- bool applyingState;
- int unnamedCount;
-
- QDeclarativeTransition *findTransition(const QString &from, const QString &to);
- void setCurrentStateInternal(const QString &state, bool = false);
- bool updateAutoState();
-};
-
-/*!
- \qmlclass StateGroup QDeclarativeStateGroup
- \inqmlmodule QtQuick 2
- \ingroup qml-state-elements
- \brief The StateGroup element provides state support for non-Item elements.
-
- Item (and all derived elements) provides built in support for states and transitions
- via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to
- use this support in other (non-Item-derived) elements.
-
- \qml
- MyCustomObject {
- StateGroup {
- id: myStateGroup
- states: State {
- name: "state1"
- // ...
- }
- transitions: Transition {
- // ...
- }
- }
-
- onSomethingHappened: myStateGroup.state = "state1";
- }
- \endqml
-
- \sa {qmlstate}{States} {QML Animation and Transitions}{Transitions}, {QtDeclarative}
-*/
-
-QDeclarativeStateGroup::QDeclarativeStateGroup(QObject *parent)
- : QObject(*(new QDeclarativeStateGroupPrivate), parent)
-{
-}
-
-QDeclarativeStateGroup::~QDeclarativeStateGroup()
-{
- Q_D(const QDeclarativeStateGroup);
- for (int i = 0; i < d->states.count(); ++i)
- d->states.at(i)->setStateGroup(0);
-}
-
-QList<QDeclarativeState *> QDeclarativeStateGroup::states() const
-{
- Q_D(const QDeclarativeStateGroup);
- return d->states;
-}
-
-/*!
- \qmlproperty list<State> QtQuick2::StateGroup::states
- This property holds a list of states defined by the state group.
-
- \qml
- StateGroup {
- states: [
- State {
- // State definition...
- },
- State {
- // ...
- }
- // Other states...
- ]
- }
- \endqml
-
- \sa {qmlstate}{States}
-*/
-QDeclarativeListProperty<QDeclarativeState> QDeclarativeStateGroup::statesProperty()
-{
- Q_D(QDeclarativeStateGroup);
- return QDeclarativeListProperty<QDeclarativeState>(this, &d->states, &QDeclarativeStateGroupPrivate::append_state,
- &QDeclarativeStateGroupPrivate::count_state,
- &QDeclarativeStateGroupPrivate::at_state,
- &QDeclarativeStateGroupPrivate::clear_states);
-}
-
-void QDeclarativeStateGroupPrivate::append_state(QDeclarativeListProperty<QDeclarativeState> *list, QDeclarativeState *state)
-{
- QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
- if (state) {
- _this->d_func()->states.append(state);
- state->setStateGroup(_this);
- }
-
-}
-
-int QDeclarativeStateGroupPrivate::count_state(QDeclarativeListProperty<QDeclarativeState> *list)
-{
- QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
- return _this->d_func()->states.count();
-}
-
-QDeclarativeState *QDeclarativeStateGroupPrivate::at_state(QDeclarativeListProperty<QDeclarativeState> *list, int index)
-{
- QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
- return _this->d_func()->states.at(index);
-}
-
-void QDeclarativeStateGroupPrivate::clear_states(QDeclarativeListProperty<QDeclarativeState> *list)
-{
- QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
- _this->d_func()->setCurrentStateInternal(QString(), true);
- for (int i = 0; i < _this->d_func()->states.count(); ++i) {
- _this->d_func()->states.at(i)->setStateGroup(0);
- }
- _this->d_func()->states.clear();
-}
-
-/*!
- \qmlproperty list<Transition> QtQuick2::StateGroup::transitions
- This property holds a list of transitions defined by the state group.
-
- \qml
- StateGroup {
- transitions: [
- Transition {
- // ...
- },
- Transition {
- // ...
- }
- // ...
- ]
- }
- \endqml
-
- \sa {QML Animation and Transitions}{Transitions}
-*/
-QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeStateGroup::transitionsProperty()
-{
- Q_D(QDeclarativeStateGroup);
- return QDeclarativeListProperty<QDeclarativeTransition>(this, &d->transitions, &QDeclarativeStateGroupPrivate::append_transition,
- &QDeclarativeStateGroupPrivate::count_transitions,
- &QDeclarativeStateGroupPrivate::at_transition,
- &QDeclarativeStateGroupPrivate::clear_transitions);
-}
-
-void QDeclarativeStateGroupPrivate::append_transition(QDeclarativeListProperty<QDeclarativeTransition> *list, QDeclarativeTransition *trans)
-{
- QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
- if (trans)
- _this->d_func()->transitions.append(trans);
-}
-
-int QDeclarativeStateGroupPrivate::count_transitions(QDeclarativeListProperty<QDeclarativeTransition> *list)
-{
- QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
- return _this->d_func()->transitions.count();
-}
-
-QDeclarativeTransition *QDeclarativeStateGroupPrivate::at_transition(QDeclarativeListProperty<QDeclarativeTransition> *list, int index)
-{
- QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
- return _this->d_func()->transitions.at(index);
-}
-
-void QDeclarativeStateGroupPrivate::clear_transitions(QDeclarativeListProperty<QDeclarativeTransition> *list)
-{
- QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
- _this->d_func()->transitions.clear();
-}
-
-/*!
- \qmlproperty string QtQuick2::StateGroup::state
-
- This property holds the name of the current state of the state group.
-
- This property is often used in scripts to change between states. For
- example:
-
- \js
- function toggle() {
- if (button.state == 'On')
- button.state = 'Off';
- else
- button.state = 'On';
- }
- \endjs
-
- If the state group is in its base state (i.e. no explicit state has been
- set), \c state will be a blank string. Likewise, you can return a
- state group to its base state by setting its current state to \c ''.
-
- \sa {qmlstates}{States}
-*/
-QString QDeclarativeStateGroup::state() const
-{
- Q_D(const QDeclarativeStateGroup);
- return d->currentState;
-}
-
-void QDeclarativeStateGroup::setState(const QString &state)
-{
- Q_D(QDeclarativeStateGroup);
- if (d->currentState == state)
- return;
-
- d->setCurrentStateInternal(state);
-}
-
-void QDeclarativeStateGroup::classBegin()
-{
- Q_D(QDeclarativeStateGroup);
- d->componentComplete = false;
-}
-
-void QDeclarativeStateGroup::componentComplete()
-{
- Q_D(QDeclarativeStateGroup);
- d->componentComplete = true;
-
- for (int ii = 0; ii < d->states.count(); ++ii) {
- QDeclarativeState *state = d->states.at(ii);
- if (!state->isNamed())
- state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount));
- }
-
- if (d->updateAutoState()) {
- return;
- } else if (!d->currentState.isEmpty()) {
- QString cs = d->currentState;
- d->currentState.clear();
- d->setCurrentStateInternal(cs, true);
- }
-}
-
-/*!
- Returns true if the state was changed, otherwise false.
-*/
-bool QDeclarativeStateGroup::updateAutoState()
-{
- Q_D(QDeclarativeStateGroup);
- return d->updateAutoState();
-}
-
-bool QDeclarativeStateGroupPrivate::updateAutoState()
-{
- Q_Q(QDeclarativeStateGroup);
- if (!componentComplete)
- return false;
-
- bool revert = false;
- for (int ii = 0; ii < states.count(); ++ii) {
- QDeclarativeState *state = states.at(ii);
- if (state->isWhenKnown()) {
- if (state->isNamed()) {
- if (state->when() && state->when()->evaluate().toBool()) {
- if (stateChangeDebug())
- qWarning() << "Setting auto state due to:"
- << state->when()->expression();
- if (currentState != state->name()) {
- q->setState(state->name());
- return true;
- } else {
- return false;
- }
- } else if (state->name() == currentState) {
- revert = true;
- }
- }
- }
- }
- if (revert) {
- bool rv = !currentState.isEmpty();
- q->setState(QString());
- return rv;
- } else {
- return false;
- }
-}
-
-QDeclarativeTransition *QDeclarativeStateGroupPrivate::findTransition(const QString &from, const QString &to)
-{
- QDeclarativeTransition *highest = 0;
- int score = 0;
- bool reversed = false;
- bool done = false;
-
- for (int ii = 0; !done && ii < transitions.count(); ++ii) {
- QDeclarativeTransition *t = transitions.at(ii);
- if (!t->enabled())
- continue;
- for (int ii = 0; ii < 2; ++ii)
- {
- if (ii && (!t->reversible() ||
- (t->fromState() == QLatin1String("*") &&
- t->toState() == QLatin1String("*"))))
- break;
- QStringList fromState;
- QStringList toState;
-
- fromState = t->fromState().split(QLatin1Char(','));
- for (int jj = 0; jj < fromState.count(); ++jj)
- fromState[jj] = fromState.at(jj).trimmed();
- toState = t->toState().split(QLatin1Char(','));
- for (int jj = 0; jj < toState.count(); ++jj)
- toState[jj] = toState.at(jj).trimmed();
- if (ii == 1)
- qSwap(fromState, toState);
- int tScore = 0;
- if (fromState.contains(from))
- tScore += 2;
- else if (fromState.contains(QLatin1String("*")))
- tScore += 1;
- else
- continue;
-
- if (toState.contains(to))
- tScore += 2;
- else if (toState.contains(QLatin1String("*")))
- tScore += 1;
- else
- continue;
-
- if (ii == 1)
- reversed = true;
- else
- reversed = false;
-
- if (tScore == 4) {
- highest = t;
- done = true;
- break;
- } else if (tScore > score) {
- score = tScore;
- highest = t;
- }
- }
- }
-
- if (highest)
- highest->setReversed(reversed);
-
- return highest;
-}
-
-void QDeclarativeStateGroupPrivate::setCurrentStateInternal(const QString &state,
- bool ignoreTrans)
-{
- Q_Q(QDeclarativeStateGroup);
- if (!componentComplete) {
- currentState = state;
- return;
- }
-
- if (applyingState) {
- qmlInfo(q) << "Can't apply a state change as part of a state definition.";
- return;
- }
-
- applyingState = true;
-
- QDeclarativeTransition *transition = ignoreTrans ? 0 : findTransition(currentState, state);
- if (stateChangeDebug()) {
- qWarning() << this << "Changing state. From" << currentState << ". To" << state;
- if (transition)
- qWarning() << " using transition" << transition->fromState()
- << transition->toState();
- }
-
- QDeclarativeState *oldState = 0;
- if (!currentState.isEmpty()) {
- for (int ii = 0; ii < states.count(); ++ii) {
- if (states.at(ii)->name() == currentState) {
- oldState = states.at(ii);
- break;
- }
- }
- }
-
- currentState = state;
- emit q->stateChanged(currentState);
-
- QDeclarativeState *newState = 0;
- for (int ii = 0; ii < states.count(); ++ii) {
- if (states.at(ii)->name() == currentState) {
- newState = states.at(ii);
- break;
- }
- }
-
- if (oldState == 0 || newState == 0) {
- if (!nullState) {
- nullState = new QDeclarativeState;
- QDeclarative_setParent_noEvent(nullState, q);
- nullState->setStateGroup(q);
- }
- if (!oldState) oldState = nullState;
- if (!newState) newState = nullState;
- }
-
- newState->apply(transition, oldState);
- applyingState = false; //### consider removing this (don't allow state changes in transition)
-}
-
-QDeclarativeState *QDeclarativeStateGroup::findState(const QString &name) const
-{
- Q_D(const QDeclarativeStateGroup);
- for (int i = 0; i < d->states.count(); ++i) {
- QDeclarativeState *state = d->states.at(i);
- if (state->name() == name)
- return state;
- }
-
- return 0;
-}
-
-void QDeclarativeStateGroup::removeState(QDeclarativeState *state)
-{
- Q_D(QDeclarativeStateGroup);
- d->states.removeOne(state);
-}
-
-void QDeclarativeStateGroup::stateAboutToComplete()
-{
- Q_D(QDeclarativeStateGroup);
- d->applyingState = false;
-}
-
-QT_END_NAMESPACE
-
-
diff --git a/src/quick/util/qdeclarativestategroup_p.h b/src/quick/util/qdeclarativestategroup_p.h
deleted file mode 100644
index d0dc599a63..0000000000
--- a/src/quick/util/qdeclarativestategroup_p.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTATEGROUP_H
-#define QDECLARATIVESTATEGROUP_H
-
-#include "qdeclarativestate_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeStateGroupPrivate;
-class Q_QUICK_EXPORT QDeclarativeStateGroup : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_DECLARE_PRIVATE(QDeclarativeStateGroup)
-
- Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeState> states READ statesProperty DESIGNABLE false)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeTransition> transitions READ transitionsProperty DESIGNABLE false)
-
-public:
- QDeclarativeStateGroup(QObject * = 0);
- virtual ~QDeclarativeStateGroup();
-
- QString state() const;
- void setState(const QString &);
-
- QDeclarativeListProperty<QDeclarativeState> statesProperty();
- QList<QDeclarativeState *> states() const;
-
- QDeclarativeListProperty<QDeclarativeTransition> transitionsProperty();
-
- QDeclarativeState *findState(const QString &name) const;
- void removeState(QDeclarativeState *state);
-
- virtual void classBegin();
- virtual void componentComplete();
-Q_SIGNALS:
- void stateChanged(const QString &);
-
-private:
- friend class QDeclarativeState;
- friend class QDeclarativeStatePrivate;
- bool updateAutoState();
- void stateAboutToComplete();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeStateGroup)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESTATEGROUP_H
diff --git a/src/quick/util/qdeclarativestateoperations.cpp b/src/quick/util/qdeclarativestateoperations.cpp
deleted file mode 100644
index 3ecf4973d5..0000000000
--- a/src/quick/util/qdeclarativestateoperations.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativestateoperations_p.h"
-
-#include <qdeclarative.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarativeexpression.h>
-#include <qdeclarativeinfo.h>
-#include <private/qdeclarativeguard_p.h>
-#include <private/qdeclarativecontext_p.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include "qdeclarativestate_p_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qmath.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeStateChangeScriptPrivate : public QDeclarativeStateOperationPrivate
-{
-public:
- QDeclarativeStateChangeScriptPrivate() {}
-
- QDeclarativeScriptString script;
- QString name;
-};
-
-/*!
- \qmlclass StateChangeScript QDeclarativeStateChangeScript
- \inqmlmodule QtQuick 2
- \ingroup qml-state-elements
- \brief The StateChangeScript element allows you to run a script in a state.
-
- A StateChangeScript is run upon entering a state. You can optionally use
- ScriptAction to specify the point in the transition at which
- the StateChangeScript should to be run.
-
- \snippet snippets/declarative/states/statechangescript.qml state and transition
-
- \sa ScriptAction
-*/
-
-QDeclarativeStateChangeScript::QDeclarativeStateChangeScript(QObject *parent)
-: QDeclarativeStateOperation(*(new QDeclarativeStateChangeScriptPrivate), parent)
-{
-}
-
-QDeclarativeStateChangeScript::~QDeclarativeStateChangeScript()
-{
-}
-
-/*!
- \qmlproperty script QtQuick2::StateChangeScript::script
- This property holds the script to run when the state is current.
-*/
-QDeclarativeScriptString QDeclarativeStateChangeScript::script() const
-{
- Q_D(const QDeclarativeStateChangeScript);
- return d->script;
-}
-
-void QDeclarativeStateChangeScript::setScript(const QDeclarativeScriptString &s)
-{
- Q_D(QDeclarativeStateChangeScript);
- d->script = s;
-}
-
-/*!
- \qmlproperty string QtQuick2::StateChangeScript::name
- This property holds the name of the script. This name can be used by a
- ScriptAction to target a specific script.
-
- \sa ScriptAction::scriptName
-*/
-QString QDeclarativeStateChangeScript::name() const
-{
- Q_D(const QDeclarativeStateChangeScript);
- return d->name;
-}
-
-void QDeclarativeStateChangeScript::setName(const QString &n)
-{
- Q_D(QDeclarativeStateChangeScript);
- d->name = n;
-}
-
-void QDeclarativeStateChangeScript::execute(Reason)
-{
- Q_D(QDeclarativeStateChangeScript);
- if (!d->script.script().isEmpty()) {
- QDeclarativeExpression expr(d->script);
- expr.evaluate();
- if (expr.hasError())
- qmlInfo(this, expr.error());
- }
-}
-
-QDeclarativeStateChangeScript::ActionList QDeclarativeStateChangeScript::actions()
-{
- ActionList rv;
- QDeclarativeAction a;
- a.event = this;
- rv << a;
- return rv;
-}
-
-QDeclarativeActionEvent::EventType QDeclarativeStateChangeScript::type() const
-{
- return Script;
-}
-
-#include <moc_qdeclarativestateoperations_p.cpp>
-
-QT_END_NAMESPACE
-
diff --git a/src/quick/util/qdeclarativestateoperations_p.h b/src/quick/util/qdeclarativestateoperations_p.h
deleted file mode 100644
index a64a7e2972..0000000000
--- a/src/quick/util/qdeclarativestateoperations_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTATEOPERATIONS_H
-#define QDECLARATIVESTATEOPERATIONS_H
-
-#include "qdeclarativestate_p.h"
-#include <qdeclarativescriptstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeStateChangeScriptPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeStateChangeScript : public QDeclarativeStateOperation, public QDeclarativeActionEvent
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeStateChangeScript)
-
- Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString name READ name WRITE setName)
-
-public:
- QDeclarativeStateChangeScript(QObject *parent=0);
- ~QDeclarativeStateChangeScript();
-
- virtual ActionList actions();
-
- virtual EventType type() const;
-
- QDeclarativeScriptString script() const;
- void setScript(const QDeclarativeScriptString &);
-
- QString name() const;
- void setName(const QString &);
-
- virtual void execute(Reason reason = ActualChange);
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeStateChangeScript)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESTATEOPERATIONS_H
diff --git a/src/quick/util/qdeclarativestyledtext.cpp b/src/quick/util/qdeclarativestyledtext.cpp
deleted file mode 100644
index ddb8cadd2a..0000000000
--- a/src/quick/util/qdeclarativestyledtext.cpp
+++ /dev/null
@@ -1,815 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QStack>
-#include <QVector>
-#include <QPainter>
-#include <QTextLayout>
-#include <QDebug>
-#include <qmath.h>
-#include "qdeclarativestyledtext_p.h"
-#include <QDeclarativeContext>
-
-/*
- QDeclarativeStyledText supports few tags:
-
- <b></b> - bold
- <strong></strong> - bold
- <i></i> - italic
- <br> - new line
- <p> - paragraph
- <u> - underlined text
- <font color="color_name" size="1-7"></font>
- <h1> to <h6> - headers
- <a href=""> - anchor
- <ol type="">, <ul type=""> and <li> - ordered and unordered lists
- <pre></pre> - preformated
- <img src=""> - images
-
- The opening and closing tags must be correctly nested.
-*/
-
-QT_BEGIN_NAMESPACE
-
-Q_GUI_EXPORT int qt_defaultDpi();
-
-class QDeclarativeStyledTextPrivate
-{
-public:
- enum ListType { Ordered, Unordered };
- enum ListFormat { Bullet, Disc, Square, Decimal, LowerAlpha, UpperAlpha, LowerRoman, UpperRoman };
-
- struct List {
- int level;
- ListType type;
- ListFormat format;
- };
-
- QDeclarativeStyledTextPrivate(const QString &t, QTextLayout &l,
- QList<QDeclarativeStyledTextImgTag*> &imgTags,
- const QUrl &baseUrl,
- QDeclarativeContext *context,
- bool preloadImages,
- bool *fontSizeModified)
- : text(t), layout(l), imgTags(&imgTags), baseFont(layout.font()), baseUrl(baseUrl), hasNewLine(false), nbImages(0), updateImagePositions(false)
- , preFormat(false), prependSpace(false), hasSpace(true), preloadImages(preloadImages), fontSizeModified(fontSizeModified), context(context)
- {
- }
-
- void parse();
- void appendText(const QString &textIn, int start, int length, QString &textOut);
- bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format);
- bool parseCloseTag(const QChar *&ch, const QString &textIn, QString &textOut);
- void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut);
- bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
- bool parseOrderedListAttributes(const QChar *&ch, const QString &textIn);
- bool parseUnorderedListAttributes(const QChar *&ch, const QString &textIn);
- bool parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
- void parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut);
- QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn);
- QStringRef parseValue(const QChar *&ch, const QString &textIn);
- void setFontSize(int size, QTextCharFormat &format);
-
- inline void skipSpace(const QChar *&ch) {
- while (ch->isSpace() && !ch->isNull())
- ++ch;
- }
-
- static QString toAlpha(int value, bool upper);
- static QString toRoman(int value, bool upper);
-
- QString text;
- QTextLayout &layout;
- QList<QDeclarativeStyledTextImgTag*> *imgTags;
- QFont baseFont;
- QStack<List> listStack;
- QUrl baseUrl;
- bool hasNewLine;
- int nbImages;
- bool updateImagePositions;
- bool preFormat;
- bool prependSpace;
- bool hasSpace;
- bool preloadImages;
- bool *fontSizeModified;
- QDeclarativeContext *context;
-
- static const QChar lessThan;
- static const QChar greaterThan;
- static const QChar equals;
- static const QChar singleQuote;
- static const QChar doubleQuote;
- static const QChar slash;
- static const QChar ampersand;
- static const QChar bullet;
- static const QChar disc;
- static const QChar square;
- static const QChar lineFeed;
- static const QChar space;
- static const int tabsize = 6;
-};
-
-const QChar QDeclarativeStyledTextPrivate::lessThan(QLatin1Char('<'));
-const QChar QDeclarativeStyledTextPrivate::greaterThan(QLatin1Char('>'));
-const QChar QDeclarativeStyledTextPrivate::equals(QLatin1Char('='));
-const QChar QDeclarativeStyledTextPrivate::singleQuote(QLatin1Char('\''));
-const QChar QDeclarativeStyledTextPrivate::doubleQuote(QLatin1Char('\"'));
-const QChar QDeclarativeStyledTextPrivate::slash(QLatin1Char('/'));
-const QChar QDeclarativeStyledTextPrivate::ampersand(QLatin1Char('&'));
-const QChar QDeclarativeStyledTextPrivate::bullet(0x2022);
-const QChar QDeclarativeStyledTextPrivate::disc(0x25e6);
-const QChar QDeclarativeStyledTextPrivate::square(0x25a1);
-const QChar QDeclarativeStyledTextPrivate::lineFeed(QLatin1Char('\n'));
-const QChar QDeclarativeStyledTextPrivate::space(QLatin1Char(' '));
-
-QDeclarativeStyledText::QDeclarativeStyledText(const QString &string, QTextLayout &layout,
- QList<QDeclarativeStyledTextImgTag*> &imgTags,
- const QUrl &baseUrl,
- QDeclarativeContext *context,
- bool preloadImages,
- bool *fontSizeModified)
- : d(new QDeclarativeStyledTextPrivate(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified))
-{
-}
-
-QDeclarativeStyledText::~QDeclarativeStyledText()
-{
- delete d;
-}
-
-void QDeclarativeStyledText::parse(const QString &string, QTextLayout &layout,
- QList<QDeclarativeStyledTextImgTag*> &imgTags,
- const QUrl &baseUrl,
- QDeclarativeContext *context,
- bool preloadImages,
- bool *fontSizeModified)
-{
- if (string.isEmpty())
- return;
- QDeclarativeStyledText styledText(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified);
- styledText.d->parse();
-}
-
-void QDeclarativeStyledTextPrivate::parse()
-{
- QList<QTextLayout::FormatRange> ranges;
- QStack<QTextCharFormat> formatStack;
-
- QString drawText;
- drawText.reserve(text.count());
-
- updateImagePositions = !imgTags->isEmpty();
-
- int textStart = 0;
- int textLength = 0;
- int rangeStart = 0;
- bool formatChanged = false;
-
- const QChar *ch = text.constData();
- while (!ch->isNull()) {
- if (*ch == lessThan) {
- if (textLength) {
- appendText(text, textStart, textLength, drawText);
- } else if (prependSpace) {
- drawText.append(space);
- prependSpace = false;
- hasSpace = true;
- }
-
- if (rangeStart != drawText.length() && formatStack.count()) {
- if (formatChanged) {
- QTextLayout::FormatRange formatRange;
- formatRange.format = formatStack.top();
- formatRange.start = rangeStart;
- formatRange.length = drawText.length() - rangeStart;
- ranges.append(formatRange);
- formatChanged = false;
- } else if (ranges.count()) {
- ranges.last().length += drawText.length() - rangeStart;
- }
- }
- rangeStart = drawText.length();
- ++ch;
- if (*ch == slash) {
- ++ch;
- if (parseCloseTag(ch, text, drawText)) {
- if (formatStack.count()) {
- formatChanged = true;
- formatStack.pop();
- }
- }
- } else {
- QTextCharFormat format;
- if (formatStack.count())
- format = formatStack.top();
- if (parseTag(ch, text, drawText, format)) {
- formatChanged = true;
- formatStack.push(format);
- }
- }
- textStart = ch - text.constData() + 1;
- textLength = 0;
- } else if (*ch == ampersand) {
- ++ch;
- appendText(text, textStart, textLength, drawText);
- parseEntity(ch, text, drawText);
- textStart = ch - text.constData() + 1;
- textLength = 0;
- } else if (ch->isSpace()) {
- if (textLength)
- appendText(text, textStart, textLength, drawText);
- if (!preFormat) {
- prependSpace = !hasSpace;
- for (const QChar *n = ch + 1; !n->isNull() && n->isSpace(); ++n)
- ch = n;
- hasNewLine = false;
- } else if (*ch == lineFeed) {
- drawText.append(QChar(QChar::LineSeparator));
- hasNewLine = true;
- } else {
- drawText.append(QChar(QChar::Nbsp));
- hasNewLine = false;
- }
- textStart = ch - text.constData() + 1;
- textLength = 0;
- } else {
- ++textLength;
- }
- if (!ch->isNull())
- ++ch;
- }
- if (textLength)
- appendText(text, textStart, textLength, drawText);
- if (rangeStart != drawText.length() && formatStack.count()) {
- if (formatChanged) {
- QTextLayout::FormatRange formatRange;
- formatRange.format = formatStack.top();
- formatRange.start = rangeStart;
- formatRange.length = drawText.length() - rangeStart;
- ranges.append(formatRange);
- } else if (ranges.count()) {
- ranges.last().length += drawText.length() - rangeStart;
- }
- }
-
- layout.setText(drawText);
- layout.setAdditionalFormats(ranges);
-}
-
-void QDeclarativeStyledTextPrivate::appendText(const QString &textIn, int start, int length, QString &textOut)
-{
- if (prependSpace)
- textOut.append(space);
- textOut.append(QStringRef(&textIn, start, length));
- prependSpace = false;
- hasSpace = false;
- hasNewLine = false;
-}
-
-//
-// Calculates and sets the correct font size in points
-// depending on the size multiplier and base font.
-//
-void QDeclarativeStyledTextPrivate::setFontSize(int size, QTextCharFormat &format)
-{
- static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 };
- if (baseFont.pointSizeF() != -1)
- format.setFontPointSize(baseFont.pointSize() * scaling[size - 1]);
- else
- format.setFontPointSize(baseFont.pixelSize() * qreal(72.) / qreal(qt_defaultDpi()) * scaling[size - 1]);
- *fontSizeModified = true;
-}
-
-bool QDeclarativeStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format)
-{
- skipSpace(ch);
-
- int tagStart = ch - textIn.constData();
- int tagLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- if (tagLength == 0)
- return false;
- QStringRef tag(&textIn, tagStart, tagLength);
- const QChar char0 = tag.at(0);
- if (char0 == QLatin1Char('b')) {
- if (tagLength == 1) {
- format.setFontWeight(QFont::Bold);
- return true;
- } else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) {
- textOut.append(QChar(QChar::LineSeparator));
- hasSpace = true;
- prependSpace = false;
- return false;
- }
- } else if (char0 == QLatin1Char('i')) {
- if (tagLength == 1) {
- format.setFontItalic(true);
- return true;
- }
- } else if (char0 == QLatin1Char('p')) {
- if (tagLength == 1) {
- if (!hasNewLine)
- textOut.append(QChar::LineSeparator);
- hasSpace = true;
- prependSpace = false;
- } else if (tag == QLatin1String("pre")) {
- preFormat = true;
- if (!hasNewLine)
- textOut.append(QChar::LineSeparator);
- format.setFontFamily(QString::fromLatin1("Courier New,courier"));
- format.setFontFixedPitch(true);
- return true;
- }
- } else if (char0 == QLatin1Char('u')) {
- if (tagLength == 1) {
- format.setFontUnderline(true);
- return true;
- } else if (tag == QLatin1String("ul")) {
- List listItem;
- listItem.level = 0;
- listItem.type = Unordered;
- listItem.format = Bullet;
- listStack.push(listItem);
- }
- } else if (char0 == QLatin1Char('h') && tagLength == 2) {
- int level = tag.at(1).digitValue();
- if (level >= 1 && level <= 6) {
- if (!hasNewLine)
- textOut.append(QChar::LineSeparator);
- hasSpace = true;
- prependSpace = false;
- setFontSize(7 - level, format);
- format.setFontWeight(QFont::Bold);
- return true;
- }
- } else if (tag == QLatin1String("strong")) {
- format.setFontWeight(QFont::Bold);
- return true;
- } else if (tag == QLatin1String("ol")) {
- List listItem;
- listItem.level = 0;
- listItem.type = Ordered;
- listItem.format = Decimal;
- listStack.push(listItem);
- } else if (tag == QLatin1String("li")) {
- if (!hasNewLine)
- textOut.append(QChar(QChar::LineSeparator));
- if (!listStack.isEmpty()) {
- int count = ++listStack.top().level;
- for (int i = 0; i < listStack.size(); ++i)
- textOut += QString(tabsize, QChar::Nbsp);
- switch (listStack.top().format) {
- case Decimal:
- textOut += QString::number(count) % QLatin1Char('.');
- break;
- case LowerAlpha:
- textOut += toAlpha(count, false) % QLatin1Char('.');
- break;
- case UpperAlpha:
- textOut += toAlpha(count, true) % QLatin1Char('.');
- break;
- case LowerRoman:
- textOut += toRoman(count, false) % QLatin1Char('.');
- break;
- case UpperRoman:
- textOut += toRoman(count, true) % QLatin1Char('.');
- break;
- case Bullet:
- textOut += bullet;
- break;
- case Disc:
- textOut += disc;
- break;
- case Square:
- textOut += square;
- break;
- }
- textOut += QString(2, QChar::Nbsp);
- }
- }
- return false;
- } else if (ch->isSpace()) {
- // may have params.
- QStringRef tag(&textIn, tagStart, tagLength);
- if (tag == QLatin1String("font"))
- return parseFontAttributes(ch, textIn, format);
- if (tag == QLatin1String("ol")) {
- parseOrderedListAttributes(ch, textIn);
- return false; // doesn't modify format
- }
- if (tag == QLatin1String("ul")) {
- parseUnorderedListAttributes(ch, textIn);
- return false; // doesn't modify format
- }
- if (tag == QLatin1String("a")) {
- return parseAnchorAttributes(ch, textIn, format);
- }
- if (tag == QLatin1String("img")) {
- parseImageAttributes(ch, textIn, textOut);
- return false;
- }
- if (*ch == greaterThan || ch->isNull())
- continue;
- } else if (*ch != slash) {
- tagLength++;
- }
- ++ch;
- }
- return false;
-}
-
-bool QDeclarativeStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn, QString &textOut)
-{
- skipSpace(ch);
-
- int tagStart = ch - textIn.constData();
- int tagLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- if (tagLength == 0)
- return false;
- QStringRef tag(&textIn, tagStart, tagLength);
- const QChar char0 = tag.at(0);
- hasNewLine = false;
- if (char0 == QLatin1Char('b')) {
- if (tagLength == 1)
- return true;
- else if (tag.at(1) == QLatin1Char('r') && tagLength == 2)
- return false;
- } else if (char0 == QLatin1Char('i')) {
- if (tagLength == 1)
- return true;
- } else if (char0 == QLatin1Char('a')) {
- if (tagLength == 1)
- return true;
- } else if (char0 == QLatin1Char('p')) {
- if (tagLength == 1) {
- textOut.append(QChar::LineSeparator);
- hasNewLine = true;
- hasSpace = true;
- return false;
- } else if (tag == QLatin1String("pre")) {
- preFormat = false;
- if (!hasNewLine)
- textOut.append(QChar::LineSeparator);
- hasNewLine = true;
- hasSpace = true;
- return true;
- }
- } else if (char0 == QLatin1Char('u')) {
- if (tagLength == 1)
- return true;
- else if (tag == QLatin1String("ul")) {
- if (!listStack.isEmpty()) {
- listStack.pop();
- if (!listStack.count())
- textOut.append(QChar::LineSeparator);
- }
- return false;
- }
- } else if (char0 == QLatin1Char('h') && tagLength == 2) {
- textOut.append(QChar::LineSeparator);
- hasNewLine = true;
- hasSpace = true;
- return true;
- } else if (tag == QLatin1String("font")) {
- return true;
- } else if (tag == QLatin1String("strong")) {
- return true;
- } else if (tag == QLatin1String("ol")) {
- if (!listStack.isEmpty()) {
- listStack.pop();
- if (!listStack.count())
- textOut.append(QChar::LineSeparator);
- }
- return false;
- } else if (tag == QLatin1String("li")) {
- return false;
- }
- return false;
- } else if (!ch->isSpace()){
- tagLength++;
- }
- ++ch;
- }
-
- return false;
-}
-
-void QDeclarativeStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut)
-{
- int entityStart = ch - textIn.constData();
- int entityLength = 0;
- while (!ch->isNull()) {
- if (*ch == QLatin1Char(';')) {
- QStringRef entity(&textIn, entityStart, entityLength);
- if (entity == QLatin1String("gt"))
- textOut += QChar(62);
- else if (entity == QLatin1String("lt"))
- textOut += QChar(60);
- else if (entity == QLatin1String("amp"))
- textOut += QChar(38);
- return;
- }
- ++entityLength;
- ++ch;
- }
-}
-
-bool QDeclarativeStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
-{
- bool valid = false;
- QPair<QStringRef,QStringRef> attr;
- do {
- attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("color")) {
- valid = true;
- format.setForeground(QColor(attr.second.toString()));
- } else if (attr.first == QLatin1String("size")) {
- valid = true;
- int size = attr.second.toString().toInt();
- if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+'))
- size += 3;
- if (size >= 1 && size <= 7)
- setFontSize(size, format);
- }
- } while (!ch->isNull() && !attr.first.isEmpty());
-
- return valid;
-}
-
-bool QDeclarativeStyledTextPrivate::parseOrderedListAttributes(const QChar *&ch, const QString &textIn)
-{
- bool valid = false;
-
- List listItem;
- listItem.level = 0;
- listItem.type = Ordered;
- listItem.format = Decimal;
-
- QPair<QStringRef,QStringRef> attr;
- do {
- attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("type")) {
- valid = true;
- if (attr.second == QLatin1String("a"))
- listItem.format = LowerAlpha;
- else if (attr.second == QLatin1String("A"))
- listItem.format = UpperAlpha;
- else if (attr.second == QLatin1String("i"))
- listItem.format = LowerRoman;
- else if (attr.second == QLatin1String("I"))
- listItem.format = UpperRoman;
- }
- } while (!ch->isNull() && !attr.first.isEmpty());
-
- listStack.push(listItem);
- return valid;
-}
-
-bool QDeclarativeStyledTextPrivate::parseUnorderedListAttributes(const QChar *&ch, const QString &textIn)
-{
- bool valid = false;
-
- List listItem;
- listItem.level = 0;
- listItem.type = Unordered;
- listItem.format = Bullet;
-
- QPair<QStringRef,QStringRef> attr;
- do {
- attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("type")) {
- valid = true;
- if (attr.second == QLatin1String("disc"))
- listItem.format = Disc;
- else if (attr.second == QLatin1String("square"))
- listItem.format = Square;
- }
- } while (!ch->isNull() && !attr.first.isEmpty());
-
- listStack.push(listItem);
- return valid;
-}
-
-bool QDeclarativeStyledTextPrivate::parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
-{
- bool valid = false;
-
- QPair<QStringRef,QStringRef> attr;
- do {
- attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("href")) {
- format.setAnchorHref(attr.second.toString());
- format.setAnchor(true);
- format.setFontUnderline(true);
- valid = true;
- }
- } while (!ch->isNull() && !attr.first.isEmpty());
-
- return valid;
-}
-
-void QDeclarativeStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut)
-{
- qreal imgWidth = 0.0;
-
- if (!updateImagePositions) {
- QDeclarativeStyledTextImgTag *image = new QDeclarativeStyledTextImgTag;
- image->position = textOut.length() + 1;
-
- QPair<QStringRef,QStringRef> attr;
- do {
- attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("src")) {
- image->url = QUrl(attr.second.toString());
- } else if (attr.first == QLatin1String("width")) {
- image->size.setWidth(attr.second.toString().toInt());
- } else if (attr.first == QLatin1String("height")) {
- image->size.setHeight(attr.second.toString().toInt());
- } else if (attr.first == QLatin1String("align")) {
- if (attr.second.toString() == QLatin1String("top")) {
- image->align = QDeclarativeStyledTextImgTag::Top;
- } else if (attr.second.toString() == QLatin1String("middle")) {
- image->align = QDeclarativeStyledTextImgTag::Middle;
- }
- }
- } while (!ch->isNull() && !attr.first.isEmpty());
-
- if (preloadImages && !image->size.isValid()) {
- // if we don't know its size but the image is a local image,
- // we load it in the pixmap cache and save its implicit size
- // to avoid a relayout later on.
- QUrl url = baseUrl.resolved(image->url);
- if (url.isLocalFile()) {
- QDeclarativePixmap *pix = new QDeclarativePixmap(context->engine(), url, image->size);
- if (pix && pix->isReady()) {
- image->size = pix->implicitSize();
- image->pix = pix;
- }
- }
- }
-
- imgWidth = image->size.width();
- imgTags->append(image);
-
- } else {
- // if we already have a list of img tags for this text
- // we only want to update the positions of these tags.
- QDeclarativeStyledTextImgTag *image = imgTags->value(nbImages);
- image->position = textOut.length() + 1;
- imgWidth = image->size.width();
- QPair<QStringRef,QStringRef> attr;
- do {
- attr = parseAttribute(ch, textIn);
- } while (!ch->isNull() && !attr.first.isEmpty());
- nbImages++;
- }
-
- QFontMetricsF fm(layout.font());
- QString padding(qFloor(imgWidth / fm.width(QChar::Nbsp)), QChar::Nbsp);
- textOut += QLatin1Char(' ');
- textOut += padding;
- textOut += QLatin1Char(' ');
-}
-
-QPair<QStringRef,QStringRef> QDeclarativeStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
-{
- skipSpace(ch);
-
- int attrStart = ch - textIn.constData();
- int attrLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- break;
- } else if (*ch == equals) {
- ++ch;
- if (*ch != singleQuote && *ch != doubleQuote) {
- while (*ch != greaterThan && !ch->isNull())
- ++ch;
- break;
- }
- ++ch;
- if (!attrLength)
- break;
- QStringRef attr(&textIn, attrStart, attrLength);
- QStringRef val = parseValue(ch, textIn);
- if (!val.isEmpty())
- return QPair<QStringRef,QStringRef>(attr,val);
- break;
- } else {
- ++attrLength;
- }
- ++ch;
- }
-
- return QPair<QStringRef,QStringRef>();
-}
-
-QStringRef QDeclarativeStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
-{
- int valStart = ch - textIn.constData();
- int valLength = 0;
- while (*ch != singleQuote && *ch != doubleQuote && !ch->isNull()) {
- ++valLength;
- ++ch;
- }
- if (ch->isNull())
- return QStringRef();
- ++ch; // skip quote
-
- return QStringRef(&textIn, valStart, valLength);
-}
-
-QString QDeclarativeStyledTextPrivate::toAlpha(int value, bool upper)
-{
- const char baseChar = upper ? 'A' : 'a';
-
- QString result;
- int c = value;
- while (c > 0) {
- c--;
- result.prepend(QChar(baseChar + (c % 26)));
- c /= 26;
- }
- return result;
-}
-
-QString QDeclarativeStyledTextPrivate::toRoman(int value, bool upper)
-{
- QString result = QLatin1String("?");
- // works for up to 4999 items
- if (value < 5000) {
- QByteArray romanNumeral;
-
- static const char romanSymbolsLower[] = "iiivixxxlxcccdcmmmm";
- static const char romanSymbolsUpper[] = "IIIVIXXXLXCCCDCMMMM";
- QByteArray romanSymbols;
- if (!upper)
- romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower));
- else
- romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper));
-
- int c[] = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 };
- int n = value;
- for (int i = 12; i >= 0; n %= c[i], i--) {
- int q = n / c[i];
- if (q > 0) {
- int startDigit = i + (i + 3) / 4;
- int numDigits;
- if (i % 4) {
- if ((i - 2) % 4)
- numDigits = 2;
- else
- numDigits = 1;
- }
- else
- numDigits = q;
- romanNumeral.append(romanSymbols.mid(startDigit, numDigits));
- }
- }
- result = QString::fromLatin1(romanNumeral);
- }
- return result;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativestyledtext_p.h b/src/quick/util/qdeclarativestyledtext_p.h
deleted file mode 100644
index 4487a9e98a..0000000000
--- a/src/quick/util/qdeclarativestyledtext_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTYLEDTEXT_H
-#define QDECLARATIVESTYLEDTEXT_H
-
-#include <QSize>
-#include <QPointF>
-#include <QList>
-#include <QUrl>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeStyledTextImgTag;
-class QDeclarativeStyledTextPrivate;
-class QString;
-class QDeclarativeContext;
-
-class Q_AUTOTEST_EXPORT QDeclarativeStyledTextImgTag
-{
-public:
- QDeclarativeStyledTextImgTag()
- : position(0), align(QDeclarativeStyledTextImgTag::Bottom), pix(0)
- { }
-
- ~QDeclarativeStyledTextImgTag() { delete pix; }
-
- enum Align {
- Bottom,
- Middle,
- Top
- };
-
- QUrl url;
- QPointF pos;
- QSize size;
- int position;
- Align align;
- QDeclarativePixmap *pix;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeStyledText
-{
-public:
- static void parse(const QString &string, QTextLayout &layout,
- QList<QDeclarativeStyledTextImgTag*> &imgTags,
- const QUrl &baseUrl,
- QDeclarativeContext *context,
- bool preloadImages,
- bool *fontSizeModified);
-
-private:
- QDeclarativeStyledText(const QString &string, QTextLayout &layout,
- QList<QDeclarativeStyledTextImgTag*> &imgTags,
- const QUrl &baseUrl,
- QDeclarativeContext *context,
- bool preloadImages,
- bool *fontSizeModified);
- ~QDeclarativeStyledText();
-
- QDeclarativeStyledTextPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/quick/util/qdeclarativesvgparser.cpp b/src/quick/util/qdeclarativesvgparser.cpp
deleted file mode 100644
index 41f12150d6..0000000000
--- a/src/quick/util/qdeclarativesvgparser.cpp
+++ /dev/null
@@ -1,614 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclaractive module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativesvgparser_p.h"
-
-#include <QtCore/qmath.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qstring.h>
-
-QT_BEGIN_NAMESPACE
-
-static const double Q_PI = 3.14159265358979323846; // pi
-
-//copied from QtSvg (qsvghandler.cpp).
-Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
-// '0' is 0x30 and '9' is 0x39
-static inline bool isDigit(ushort ch)
-{
- static quint16 magic = 0x3ff;
- return ((ch >> 4) == 3) && (magic >> (ch & 15));
-}
-
-static qreal toDouble(const QChar *&str)
-{
- const int maxLen = 255;//technically doubles can go til 308+ but whatever
- char temp[maxLen+1];
- int pos = 0;
-
- if (*str == QLatin1Char('-')) {
- temp[pos++] = '-';
- ++str;
- } else if (*str == QLatin1Char('+')) {
- ++str;
- }
- while (isDigit(str->unicode()) && pos < maxLen) {
- temp[pos++] = str->toLatin1();
- ++str;
- }
- if (*str == QLatin1Char('.') && pos < maxLen) {
- temp[pos++] = '.';
- ++str;
- }
- while (isDigit(str->unicode()) && pos < maxLen) {
- temp[pos++] = str->toLatin1();
- ++str;
- }
- bool exponent = false;
- if ((*str == QLatin1Char('e') || *str == QLatin1Char('E')) && pos < maxLen) {
- exponent = true;
- temp[pos++] = 'e';
- ++str;
- if ((*str == QLatin1Char('-') || *str == QLatin1Char('+')) && pos < maxLen) {
- temp[pos++] = str->toLatin1();
- ++str;
- }
- while (isDigit(str->unicode()) && pos < maxLen) {
- temp[pos++] = str->toLatin1();
- ++str;
- }
- }
-
- temp[pos] = '\0';
-
- qreal val;
- if (!exponent && pos < 10) {
- int ival = 0;
- const char *t = temp;
- bool neg = false;
- if(*t == '-') {
- neg = true;
- ++t;
- }
- while(*t && *t != '.') {
- ival *= 10;
- ival += (*t) - '0';
- ++t;
- }
- if(*t == '.') {
- ++t;
- int div = 1;
- while(*t) {
- ival *= 10;
- ival += (*t) - '0';
- div *= 10;
- ++t;
- }
- val = ((qreal)ival)/((qreal)div);
- } else {
- val = ival;
- }
- if (neg)
- val = -val;
- } else {
-#if defined(Q_WS_QWS) && !defined(Q_OS_VXWORKS)
- if(sizeof(qreal) == sizeof(float))
- val = strtof(temp, 0);
- else
-#endif
- {
- bool ok = false;
- val = qstrtod(temp, 0, &ok);
- }
- }
- return val;
-
-}
-static inline void parseNumbersArray(const QChar *&str, QVarLengthArray<qreal, 8> &points)
-{
- while (str->isSpace())
- ++str;
- while (isDigit(str->unicode()) ||
- *str == QLatin1Char('-') || *str == QLatin1Char('+') ||
- *str == QLatin1Char('.')) {
-
- points.append(toDouble(str));
-
- while (str->isSpace())
- ++str;
- if (*str == QLatin1Char(','))
- ++str;
-
- //eat the rest of space
- while (str->isSpace())
- ++str;
- }
-}
-
-static void pathArcSegment(QPainterPath &path,
- qreal xc, qreal yc,
- qreal th0, qreal th1,
- qreal rx, qreal ry, qreal xAxisRotation)
-{
- qreal sinTh, cosTh;
- qreal a00, a01, a10, a11;
- qreal x1, y1, x2, y2, x3, y3;
- qreal t;
- qreal thHalf;
-
- sinTh = qSin(xAxisRotation * (Q_PI / 180.0));
- cosTh = qCos(xAxisRotation * (Q_PI / 180.0));
-
- a00 = cosTh * rx;
- a01 = -sinTh * ry;
- a10 = sinTh * rx;
- a11 = cosTh * ry;
-
- thHalf = 0.5 * (th1 - th0);
- t = (8.0 / 3.0) * qSin(thHalf * 0.5) * qSin(thHalf * 0.5) / qSin(thHalf);
- x1 = xc + qCos(th0) - t * qSin(th0);
- y1 = yc + qSin(th0) + t * qCos(th0);
- x3 = xc + qCos(th1);
- y3 = yc + qSin(th1);
- x2 = x3 + t * qSin(th1);
- y2 = y3 - t * qCos(th1);
-
- path.cubicTo(a00 * x1 + a01 * y1, a10 * x1 + a11 * y1,
- a00 * x2 + a01 * y2, a10 * x2 + a11 * y2,
- a00 * x3 + a01 * y3, a10 * x3 + a11 * y3);
-}
-
-void QDeclarativeSvgParser::pathArc(QPainterPath &path,
- qreal rx,
- qreal ry,
- qreal x_axis_rotation,
- int large_arc_flag,
- int sweep_flag,
- qreal x,
- qreal y,
- qreal curx, qreal cury)
-{
- qreal sin_th, cos_th;
- qreal a00, a01, a10, a11;
- qreal x0, y0, x1, y1, xc, yc;
- qreal d, sfactor, sfactor_sq;
- qreal th0, th1, th_arc;
- int i, n_segs;
- qreal dx, dy, dx1, dy1, Pr1, Pr2, Px, Py, check;
-
- rx = qAbs(rx);
- ry = qAbs(ry);
-
- sin_th = qSin(x_axis_rotation * (Q_PI / 180.0));
- cos_th = qCos(x_axis_rotation * (Q_PI / 180.0));
-
- dx = (curx - x) / 2.0;
- dy = (cury - y) / 2.0;
- dx1 = cos_th * dx + sin_th * dy;
- dy1 = -sin_th * dx + cos_th * dy;
- Pr1 = rx * rx;
- Pr2 = ry * ry;
- Px = dx1 * dx1;
- Py = dy1 * dy1;
- /* Spec : check if radii are large enough */
- check = Px / Pr1 + Py / Pr2;
- if (check > 1) {
- rx = rx * qSqrt(check);
- ry = ry * qSqrt(check);
- }
-
- a00 = cos_th / rx;
- a01 = sin_th / rx;
- a10 = -sin_th / ry;
- a11 = cos_th / ry;
- x0 = a00 * curx + a01 * cury;
- y0 = a10 * curx + a11 * cury;
- x1 = a00 * x + a01 * y;
- y1 = a10 * x + a11 * y;
- /* (x0, y0) is current point in transformed coordinate space.
- (x1, y1) is new point in transformed coordinate space.
-
- The arc fits a unit-radius circle in this space.
- */
- d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
- sfactor_sq = 1.0 / d - 0.25;
- if (sfactor_sq < 0) sfactor_sq = 0;
- sfactor = qSqrt(sfactor_sq);
- if (sweep_flag == large_arc_flag) sfactor = -sfactor;
- xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
- yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);
- /* (xc, yc) is center of the circle. */
-
- th0 = qAtan2(y0 - yc, x0 - xc);
- th1 = qAtan2(y1 - yc, x1 - xc);
-
- th_arc = th1 - th0;
- if (th_arc < 0 && sweep_flag)
- th_arc += 2 * Q_PI;
- else if (th_arc > 0 && !sweep_flag)
- th_arc -= 2 * Q_PI;
-
- n_segs = qCeil(qAbs(th_arc / (Q_PI * 0.5 + 0.001)));
-
- for (i = 0; i < n_segs; i++) {
- pathArcSegment(path, xc, yc,
- th0 + i * th_arc / n_segs,
- th0 + (i + 1) * th_arc / n_segs,
- rx, ry, x_axis_rotation);
- }
-}
-
-
-bool QDeclarativeSvgParser::parsePathDataFast(const QString &dataStr, QPainterPath &path)
-{
- qreal x0 = 0, y0 = 0; // starting point
- qreal x = 0, y = 0; // current point
- char lastMode = 0;
- QPointF ctrlPt;
- const QChar *str = dataStr.constData();
- const QChar *end = str + dataStr.size();
-
- while (str != end) {
- while (str->isSpace())
- ++str;
- QChar pathElem = *str;
- ++str;
- QChar endc = *end;
- *const_cast<QChar *>(end) = 0; // parseNumbersArray requires 0-termination that QStringRef cannot guarantee
- QVarLengthArray<qreal, 8> arg;
- parseNumbersArray(str, arg);
- *const_cast<QChar *>(end) = endc;
- if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z'))
- arg.append(0);//dummy
- const qreal *num = arg.constData();
- int count = arg.count();
- while (count > 0) {
- qreal offsetX = x; // correction offsets
- qreal offsetY = y; // for relative commands
- switch (pathElem.unicode()) {
- case 'm': {
- if (count < 2) {
- num++;
- count--;
- break;
- }
- x = x0 = num[0] + offsetX;
- y = y0 = num[1] + offsetY;
- num += 2;
- count -= 2;
- path.moveTo(x0, y0);
-
- // As per 1.2 spec 8.3.2 The "moveto" commands
- // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands,
- // the subsequent pairs shall be treated as implicit 'lineto' commands.
- pathElem = QLatin1Char('l');
- }
- break;
- case 'M': {
- if (count < 2) {
- num++;
- count--;
- break;
- }
- x = x0 = num[0];
- y = y0 = num[1];
- num += 2;
- count -= 2;
- path.moveTo(x0, y0);
-
- // As per 1.2 spec 8.3.2 The "moveto" commands
- // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands,
- // the subsequent pairs shall be treated as implicit 'lineto' commands.
- pathElem = QLatin1Char('L');
- }
- break;
- case 'z':
- case 'Z': {
- x = x0;
- y = y0;
- count--; // skip dummy
- num++;
- path.closeSubpath();
- }
- break;
- case 'l': {
- if (count < 2) {
- num++;
- count--;
- break;
- }
- x = num[0] + offsetX;
- y = num[1] + offsetY;
- num += 2;
- count -= 2;
- path.lineTo(x, y);
-
- }
- break;
- case 'L': {
- if (count < 2) {
- num++;
- count--;
- break;
- }
- x = num[0];
- y = num[1];
- num += 2;
- count -= 2;
- path.lineTo(x, y);
- }
- break;
- case 'h': {
- x = num[0] + offsetX;
- num++;
- count--;
- path.lineTo(x, y);
- }
- break;
- case 'H': {
- x = num[0];
- num++;
- count--;
- path.lineTo(x, y);
- }
- break;
- case 'v': {
- y = num[0] + offsetY;
- num++;
- count--;
- path.lineTo(x, y);
- }
- break;
- case 'V': {
- y = num[0];
- num++;
- count--;
- path.lineTo(x, y);
- }
- break;
- case 'c': {
- if (count < 6) {
- num += count;
- count = 0;
- break;
- }
- QPointF c1(num[0] + offsetX, num[1] + offsetY);
- QPointF c2(num[2] + offsetX, num[3] + offsetY);
- QPointF e(num[4] + offsetX, num[5] + offsetY);
- num += 6;
- count -= 6;
- path.cubicTo(c1, c2, e);
- ctrlPt = c2;
- x = e.x();
- y = e.y();
- break;
- }
- case 'C': {
- if (count < 6) {
- num += count;
- count = 0;
- break;
- }
- QPointF c1(num[0], num[1]);
- QPointF c2(num[2], num[3]);
- QPointF e(num[4], num[5]);
- num += 6;
- count -= 6;
- path.cubicTo(c1, c2, e);
- ctrlPt = c2;
- x = e.x();
- y = e.y();
- break;
- }
- case 's': {
- if (count < 4) {
- num += count;
- count = 0;
- break;
- }
- QPointF c1;
- if (lastMode == 'c' || lastMode == 'C' ||
- lastMode == 's' || lastMode == 'S')
- c1 = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
- else
- c1 = QPointF(x, y);
- QPointF c2(num[0] + offsetX, num[1] + offsetY);
- QPointF e(num[2] + offsetX, num[3] + offsetY);
- num += 4;
- count -= 4;
- path.cubicTo(c1, c2, e);
- ctrlPt = c2;
- x = e.x();
- y = e.y();
- break;
- }
- case 'S': {
- if (count < 4) {
- num += count;
- count = 0;
- break;
- }
- QPointF c1;
- if (lastMode == 'c' || lastMode == 'C' ||
- lastMode == 's' || lastMode == 'S')
- c1 = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
- else
- c1 = QPointF(x, y);
- QPointF c2(num[0], num[1]);
- QPointF e(num[2], num[3]);
- num += 4;
- count -= 4;
- path.cubicTo(c1, c2, e);
- ctrlPt = c2;
- x = e.x();
- y = e.y();
- break;
- }
- case 'q': {
- if (count < 4) {
- num += count;
- count = 0;
- break;
- }
- QPointF c(num[0] + offsetX, num[1] + offsetY);
- QPointF e(num[2] + offsetX, num[3] + offsetY);
- num += 4;
- count -= 4;
- path.quadTo(c, e);
- ctrlPt = c;
- x = e.x();
- y = e.y();
- break;
- }
- case 'Q': {
- if (count < 4) {
- num += count;
- count = 0;
- break;
- }
- QPointF c(num[0], num[1]);
- QPointF e(num[2], num[3]);
- num += 4;
- count -= 4;
- path.quadTo(c, e);
- ctrlPt = c;
- x = e.x();
- y = e.y();
- break;
- }
- case 't': {
- if (count < 2) {
- num += count;
- count = 0;
- break;
- }
- QPointF e(num[0] + offsetX, num[1] + offsetY);
- num += 2;
- count -= 2;
- QPointF c;
- if (lastMode == 'q' || lastMode == 'Q' ||
- lastMode == 't' || lastMode == 'T')
- c = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
- else
- c = QPointF(x, y);
- path.quadTo(c, e);
- ctrlPt = c;
- x = e.x();
- y = e.y();
- break;
- }
- case 'T': {
- if (count < 2) {
- num += count;
- count = 0;
- break;
- }
- QPointF e(num[0], num[1]);
- num += 2;
- count -= 2;
- QPointF c;
- if (lastMode == 'q' || lastMode == 'Q' ||
- lastMode == 't' || lastMode == 'T')
- c = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
- else
- c = QPointF(x, y);
- path.quadTo(c, e);
- ctrlPt = c;
- x = e.x();
- y = e.y();
- break;
- }
- case 'a': {
- if (count < 7) {
- num += count;
- count = 0;
- break;
- }
- qreal rx = (*num++);
- qreal ry = (*num++);
- qreal xAxisRotation = (*num++);
- qreal largeArcFlag = (*num++);
- qreal sweepFlag = (*num++);
- qreal ex = (*num++) + offsetX;
- qreal ey = (*num++) + offsetY;
- count -= 7;
- qreal curx = x;
- qreal cury = y;
- pathArc(path, rx, ry, xAxisRotation, int(largeArcFlag),
- int(sweepFlag), ex, ey, curx, cury);
-
- x = ex;
- y = ey;
- }
- break;
- case 'A': {
- if (count < 7) {
- num += count;
- count = 0;
- break;
- }
- qreal rx = (*num++);
- qreal ry = (*num++);
- qreal xAxisRotation = (*num++);
- qreal largeArcFlag = (*num++);
- qreal sweepFlag = (*num++);
- qreal ex = (*num++);
- qreal ey = (*num++);
- count -= 7;
- qreal curx = x;
- qreal cury = y;
- pathArc(path, rx, ry, xAxisRotation, int(largeArcFlag),
- int(sweepFlag), ex, ey, curx, cury);
-
- x = ex;
- y = ey;
- }
- break;
- default:
- return false;
- }
- lastMode = pathElem.toLatin1();
- }
- }
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativesvgparser_p.h b/src/quick/util/qdeclarativesvgparser_p.h
deleted file mode 100644
index d1ecf2574c..0000000000
--- a/src/quick/util/qdeclarativesvgparser_p.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclaractive module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESVGPARSER_P_H
-#define QDECLARATIVESVGPARSER_P_H
-
-#include <QtCore/qstring.h>
-#include <QtGui/qpainterpath.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QDeclarativeSvgParser
-{
- bool parsePathDataFast(const QString &dataStr, QPainterPath &path);
- void pathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation,
- int large_arc_flag, int sweep_flag, qreal x, qreal y, qreal curx,
- qreal cury);
-}
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVESVGPARSER_P_H
diff --git a/src/quick/util/qdeclarativesystempalette.cpp b/src/quick/util/qdeclarativesystempalette.cpp
deleted file mode 100644
index ab090e718e..0000000000
--- a/src/quick/util/qdeclarativesystempalette.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativesystempalette_p.h"
-
-#include <QGuiApplication>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeSystemPalettePrivate : public QObjectPrivate
-{
-public:
- QPalette palette;
- QPalette::ColorGroup group;
-};
-
-
-
-/*!
- \qmlclass SystemPalette QDeclarativeSystemPalette
- \inqmlmodule QtQuick 2
- \ingroup qml-utility-elements
- \brief The SystemPalette element provides access to the Qt palettes.
-
- The SystemPalette element provides access to the Qt application
- palettes. This provides information about the standard colors used
- for application windows, buttons and other features. These colors
- are grouped into three \e {color groups}: \c Active, \c Inactive,
- and \c Disabled. See the QPalette documentation for details about
- color groups and the properties provided by SystemPalette.
-
- This can be used to color items in a way that provides a more
- native look and feel.
-
- The following example creates a palette from the \c Active color
- group and uses this to color the window and text items
- appropriately:
-
- \snippet doc/src/snippets/declarative/systempalette.qml 0
-
- \sa QPalette
-*/
-QDeclarativeSystemPalette::QDeclarativeSystemPalette(QObject *parent)
- : QObject(*(new QDeclarativeSystemPalettePrivate), parent)
-{
- Q_D(QDeclarativeSystemPalette);
- d->palette = QGuiApplication::palette();
- d->group = QPalette::Active;
- qApp->installEventFilter(this);
-}
-
-QDeclarativeSystemPalette::~QDeclarativeSystemPalette()
-{
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::window
- The window (general background) color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::window() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Window);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::windowText
- The window text (general foreground) color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::windowText() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::WindowText);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::base
- The base color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::base() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Base);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::text
- The text color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::text() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Text);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::alternateBase
- The alternate base color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::alternateBase() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::AlternateBase);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::button
- The button color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::button() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Button);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::buttonText
- The button text foreground color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::buttonText() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::ButtonText);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::light
- The light color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::light() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Light);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::midlight
- The midlight color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::midlight() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Midlight);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::dark
- The dark color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::dark() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Dark);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::mid
- The mid color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::mid() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Mid);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::shadow
- The shadow color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::shadow() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Shadow);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::highlight
- The highlight color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::highlight() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::Highlight);
-}
-
-/*!
- \qmlproperty color QtQuick2::SystemPalette::highlightedText
- The highlighted text color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarativeSystemPalette::highlightedText() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return d->palette.color(d->group, QPalette::HighlightedText);
-}
-
-/*!
- \qmlproperty enumeration QtQuick2::SystemPalette::colorGroup
-
- The color group of the palette. This can be one of:
-
- \list
- \o SystemPalette.Active (default)
- \o SystemPalette.Inactive
- \o SystemPalette.Disabled
- \endlist
-
- \sa QPalette::ColorGroup
-*/
-QDeclarativeSystemPalette::ColorGroup QDeclarativeSystemPalette::colorGroup() const
-{
- Q_D(const QDeclarativeSystemPalette);
- return (QDeclarativeSystemPalette::ColorGroup)d->group;
-}
-
-void QDeclarativeSystemPalette::setColorGroup(QDeclarativeSystemPalette::ColorGroup colorGroup)
-{
- Q_D(QDeclarativeSystemPalette);
- d->group = (QPalette::ColorGroup)colorGroup;
- emit paletteChanged();
-}
-
-bool QDeclarativeSystemPalette::eventFilter(QObject *watched, QEvent *event)
-{
- if (watched == qApp) {
- if (event->type() == QEvent::ApplicationPaletteChange) {
- QGuiApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
- return false;
- }
- }
- return QObject::eventFilter(watched, event);
-}
-
-bool QDeclarativeSystemPalette::event(QEvent *event)
-{
- Q_D(QDeclarativeSystemPalette);
- if (event->type() == QEvent::ApplicationPaletteChange) {
- d->palette = QGuiApplication::palette();
- emit paletteChanged();
- return true;
- }
- return QObject::event(event);
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativesystempalette_p.h b/src/quick/util/qdeclarativesystempalette_p.h
deleted file mode 100644
index 84813e3030..0000000000
--- a/src/quick/util/qdeclarativesystempalette_p.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESYSTEMPALETTE_H
-#define QDECLARATIVESYSTEMPALETTE_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/qobject.h>
-#include <QPalette>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeSystemPalettePrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeSystemPalette : public QObject
-{
- Q_OBJECT
- Q_ENUMS(ColorGroup)
- Q_DECLARE_PRIVATE(QDeclarativeSystemPalette)
-
- Q_PROPERTY(QDeclarativeSystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
- Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
- Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
- Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
- Q_PROPERTY(QColor text READ text NOTIFY paletteChanged)
- Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged)
- Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
- Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
- Q_PROPERTY(QColor light READ light NOTIFY paletteChanged)
- Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged)
- Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged)
- Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged)
- Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
- Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
- Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
-
-public:
- QDeclarativeSystemPalette(QObject *parent=0);
- ~QDeclarativeSystemPalette();
-
- enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled };
-
- QColor window() const;
- QColor windowText() const;
-
- QColor base() const;
- QColor text() const;
- QColor alternateBase() const;
-
- QColor button() const;
- QColor buttonText() const;
-
- QColor light() const;
- QColor midlight() const;
- QColor dark() const;
- QColor mid() const;
- QColor shadow() const;
-
- QColor highlight() const;
- QColor highlightedText() const;
-
- QDeclarativeSystemPalette::ColorGroup colorGroup() const;
- void setColorGroup(QDeclarativeSystemPalette::ColorGroup);
-
-Q_SIGNALS:
- void paletteChanged();
-
-private:
- bool eventFilter(QObject *watched, QEvent *event);
- bool event(QEvent *event);
-
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeSystemPalette)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESYSTEMPALETTE_H
diff --git a/src/quick/util/qdeclarativetimeline.cpp b/src/quick/util/qdeclarativetimeline.cpp
deleted file mode 100644
index a33fdd5104..0000000000
--- a/src/quick/util/qdeclarativetimeline.cpp
+++ /dev/null
@@ -1,947 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetimeline_p_p.h"
-
-#include <QDebug>
-#include <QMutex>
-#include <QThread>
-#include <QWaitCondition>
-#include <QEvent>
-#include <QCoreApplication>
-#include <QEasingCurve>
-#include <QTime>
-
-QT_BEGIN_NAMESPACE
-
-struct Update {
- Update(QDeclarativeTimeLineValue *_g, qreal _v)
- : g(_g), v(_v) {}
- Update(const QDeclarativeTimeLineCallback &_e)
- : g(0), v(0), e(_e) {}
-
- QDeclarativeTimeLineValue *g;
- qreal v;
- QDeclarativeTimeLineCallback e;
-};
-
-struct QDeclarativeTimeLinePrivate
-{
- QDeclarativeTimeLinePrivate(QDeclarativeTimeLine *);
-
- struct Op {
- enum Type {
- Pause,
- Set,
- Move,
- MoveBy,
- Accel,
- AccelDistance,
- Execute
- };
- Op() {}
- Op(Type t, int l, qreal v, qreal v2, int o,
- const QDeclarativeTimeLineCallback &ev = QDeclarativeTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
- : type(t), length(l), value(v), value2(v2), order(o), event(ev),
- easing(es) {}
- Op(const Op &o)
- : type(o.type), length(o.length), value(o.value), value2(o.value2),
- order(o.order), event(o.event), easing(o.easing) {}
- Op &operator=(const Op &o) {
- type = o.type; length = o.length; value = o.value;
- value2 = o.value2; order = o.order; event = o.event;
- easing = o.easing;
- return *this;
- }
-
- Type type;
- int length;
- qreal value;
- qreal value2;
-
- int order;
- QDeclarativeTimeLineCallback event;
- QEasingCurve easing;
- };
- struct TimeLine
- {
- TimeLine() : length(0), consumedOpLength(0), base(0.) {}
- QList<Op> ops;
- int length;
- int consumedOpLength;
- qreal base;
- };
-
- int length;
- int syncPoint;
- typedef QHash<QDeclarativeTimeLineObject *, TimeLine> Ops;
- Ops ops;
- QDeclarativeTimeLine *q;
-
- void add(QDeclarativeTimeLineObject &, const Op &);
- qreal value(const Op &op, int time, qreal base, bool *) const;
-
- int advance(int);
-
- bool clockRunning;
- int prevTime;
-
- int order;
-
- QDeclarativeTimeLine::SyncMode syncMode;
- int syncAdj;
- QList<QPair<int, Update> > *updateQueue;
-};
-
-QDeclarativeTimeLinePrivate::QDeclarativeTimeLinePrivate(QDeclarativeTimeLine *parent)
-: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QDeclarativeTimeLine::LocalSync), syncAdj(0), updateQueue(0)
-{
-}
-
-void QDeclarativeTimeLinePrivate::add(QDeclarativeTimeLineObject &g, const Op &o)
-{
- if (g._t && g._t != q) {
- qWarning() << "QDeclarativeTimeLine: Cannot modify a QDeclarativeTimeLineValue owned by"
- << "another timeline.";
- return;
- }
- g._t = q;
-
- Ops::Iterator iter = ops.find(&g);
- if (iter == ops.end()) {
- iter = ops.insert(&g, TimeLine());
- if (syncPoint > 0)
- q->pause(g, syncPoint);
- }
- if (!iter->ops.isEmpty() &&
- o.type == Op::Pause &&
- iter->ops.last().type == Op::Pause) {
- iter->ops.last().length += o.length;
- iter->length += o.length;
- } else {
- iter->ops.append(o);
- iter->length += o.length;
- }
-
- if (iter->length > length)
- length = iter->length;
-
- if (!clockRunning) {
- q->stop();
- prevTime = 0;
- clockRunning = true;
-
- if (syncMode == QDeclarativeTimeLine::LocalSync) {
- syncAdj = -1;
- } else {
- syncAdj = 0;
- }
- q->start();
-/* q->tick(0);
- if (syncMode == QDeclarativeTimeLine::LocalSync) {
- syncAdj = -1;
- } else {
- syncAdj = 0;
- }
- */
- }
-}
-
-qreal QDeclarativeTimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const
-{
- Q_ASSERT(time >= 0);
- Q_ASSERT(time <= op.length);
- *changed = true;
-
- switch(op.type) {
- case Op::Pause:
- *changed = false;
- return base;
- case Op::Set:
- return op.value;
- case Op::Move:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return op.value;
- } else {
- qreal delta = op.value - base;
- qreal pTime = (qreal)(time) / (qreal)op.length;
- if (op.easing.type() == QEasingCurve::Linear)
- return base + delta * pTime;
- else
- return base + delta * op.easing.valueForProgress(pTime);
- }
- case Op::MoveBy:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return base + op.value;
- } else {
- qreal delta = op.value;
- qreal pTime = (qreal)(time) / (qreal)op.length;
- if (op.easing.type() == QEasingCurve::Linear)
- return base + delta * pTime;
- else
- return base + delta * op.easing.valueForProgress(pTime);
- }
- case Op::Accel:
- if (time == 0) {
- return base;
- } else {
- qreal t = (qreal)(time) / 1000.0f;
- qreal delta = op.value * t + 0.5f * op.value2 * t * t;
- return base + delta;
- }
- case Op::AccelDistance:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return base + op.value2;
- } else {
- qreal t = (qreal)(time) / 1000.0f;
- qreal accel = -1.0f * 1000.0f * op.value / (qreal)op.length;
- qreal delta = op.value * t + 0.5f * accel * t * t;
- return base + delta;
-
- }
- case Op::Execute:
- op.event.d0(op.event.d1);
- *changed = false;
- return -1;
- }
-
- return base;
-}
-
-/*!
- \internal
- \class QDeclarativeTimeLine
- \brief The QDeclarativeTimeLine class provides a timeline for controlling animations.
-
- QDeclarativeTimeLine is similar to QTimeLine except:
- \list
- \i It updates QDeclarativeTimeLineValue instances directly, rather than maintaining a single
- current value.
-
- For example, the following animates a simple value over 200 milliseconds:
- \code
- QDeclarativeTimeLineValue v(<starting value>);
- QDeclarativeTimeLine tl;
- tl.move(v, 100., 200);
- tl.start()
- \endcode
-
- If your program needs to know when values are changed, it can either
- connect to the QDeclarativeTimeLine's updated() signal, or inherit from QDeclarativeTimeLineValue
- and reimplement the QDeclarativeTimeLineValue::setValue() method.
-
- \i Supports multiple QDeclarativeTimeLineValue, arbitrary start and end values and allows
- animations to be strung together for more complex effects.
-
- For example, the following animation moves the x and y coordinates of
- an object from wherever they are to the position (100, 100) in 50
- milliseconds and then further animates them to (100, 200) in 50
- milliseconds:
-
- \code
- QDeclarativeTimeLineValue x(<starting value>);
- QDeclarativeTimeLineValue y(<starting value>);
-
- QDeclarativeTimeLine tl;
- tl.start();
-
- tl.move(x, 100., 50);
- tl.move(y, 100., 50);
- tl.move(y, 200., 50);
- \endcode
-
- \i All QDeclarativeTimeLine instances share a single, synchronized clock.
-
- Actions scheduled within the same event loop tick are scheduled
- synchronously against each other, regardless of the wall time between the
- scheduling. Synchronized scheduling applies both to within the same
- QDeclarativeTimeLine and across separate QDeclarativeTimeLine's within the same process.
-
- \endlist
-
- Currently easing functions are not supported.
-*/
-
-
-/*!
- Construct a new QDeclarativeTimeLine with the specified \a parent.
-*/
-QDeclarativeTimeLine::QDeclarativeTimeLine(QObject *parent)
- : QObject(parent)
-{
- d = new QDeclarativeTimeLinePrivate(this);
-}
-
-/*!
- Destroys the time line. Any inprogress animations are canceled, but not
- completed.
-*/
-QDeclarativeTimeLine::~QDeclarativeTimeLine()
-{
- for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter)
- iter.key()->_t = 0;
-
- delete d; d = 0;
-}
-
-/*!
- \enum QDeclarativeTimeLine::SyncMode
- */
-
-/*!
- Return the timeline's synchronization mode.
- */
-QDeclarativeTimeLine::SyncMode QDeclarativeTimeLine::syncMode() const
-{
- return d->syncMode;
-}
-
-/*!
- Set the timeline's synchronization mode to \a syncMode.
- */
-void QDeclarativeTimeLine::setSyncMode(SyncMode syncMode)
-{
- d->syncMode = syncMode;
-}
-
-/*!
- Pause \a obj for \a time milliseconds.
-*/
-void QDeclarativeTimeLine::pause(QDeclarativeTimeLineObject &obj, int time)
-{
- if (time <= 0) return;
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Pause, time, 0., 0., d->order++);
- d->add(obj, op);
-}
-
-/*!
- Execute the \a event.
- */
-void QDeclarativeTimeLine::callback(const QDeclarativeTimeLineCallback &callback)
-{
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback);
- d->add(*callback.callbackObject(), op);
-}
-
-/*!
- Set the \a value of \a timeLineValue.
-*/
-void QDeclarativeTimeLine::set(QDeclarativeTimeLineValue &timeLineValue, qreal value)
-{
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Set, 0, value, 0., d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Decelerate \a timeLineValue from the starting \a velocity to zero at the
- given \a acceleration rate. Although the \a acceleration is technically
- a deceleration, it should always be positive. The QDeclarativeTimeLine will ensure
- that the deceleration is in the opposite direction to the initial velocity.
-*/
-int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal acceleration)
-{
- if (acceleration == 0.0f)
- return -1;
-
- if ((velocity > 0.0f) == (acceleration > 0.0f))
- acceleration = acceleration * -1.0f;
-
- int time = static_cast<int>(-1000 * velocity / acceleration);
-
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- \overload
-
- Decelerate \a timeLineValue from the starting \a velocity to zero at the
- given \a acceleration rate over a maximum distance of maxDistance.
-
- If necessary, QDeclarativeTimeLine will reduce the acceleration to ensure that the
- entire operation does not require a move of more than \a maxDistance.
- \a maxDistance should always be positive.
-*/
-int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance)
-{
- if (maxDistance == 0.0f || acceleration == 0.0f)
- return -1;
-
- Q_ASSERT(acceleration > 0.0f && maxDistance > 0.0f);
-
- qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance);
- if (maxAccel > acceleration)
- acceleration = maxAccel;
-
- if ((velocity > 0.0f) == (acceleration > 0.0f))
- acceleration = acceleration * -1.0f;
-
- int time = static_cast<int>(-1000 * velocity / acceleration);
-
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- Decelerate \a timeLineValue from the starting \a velocity to zero over the given
- \a distance. This is like accel(), but the QDeclarativeTimeLine calculates the exact
- deceleration to use.
-
- \a distance should be positive.
-*/
-int QDeclarativeTimeLine::accelDistance(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal distance)
-{
- if (distance == 0.0f || velocity == 0.0f)
- return -1;
-
- Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f));
-
- int time = static_cast<int>(1000 * (2.0f * distance) / velocity);
-
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- Linearly change the \a timeLineValue from its current value to the given
- \a destination value over \a time milliseconds.
-*/
-void QDeclarativeTimeLine::move(QDeclarativeTimeLineValue &timeLineValue, qreal destination, int time)
-{
- if (time <= 0) return;
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Change the \a timeLineValue from its current value to the given \a destination
- value over \a time milliseconds using the \a easing curve.
- */
-void QDeclarativeTimeLine::move(QDeclarativeTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
-{
- if (time <= 0) return;
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QDeclarativeTimeLineCallback(), easing);
- d->add(timeLineValue, op);
-}
-
-/*!
- Linearly change the \a timeLineValue from its current value by the \a change amount
- over \a time milliseconds.
-*/
-void QDeclarativeTimeLine::moveBy(QDeclarativeTimeLineValue &timeLineValue, qreal change, int time)
-{
- if (time <= 0) return;
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Change the \a timeLineValue from its current value by the \a change amount over
- \a time milliseconds using the \a easing curve.
- */
-void QDeclarativeTimeLine::moveBy(QDeclarativeTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
-{
- if (time <= 0) return;
- QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QDeclarativeTimeLineCallback(), easing);
- d->add(timeLineValue, op);
-}
-
-/*!
- Cancel (but don't complete) all scheduled actions for \a timeLineValue.
-*/
-void QDeclarativeTimeLine::reset(QDeclarativeTimeLineValue &timeLineValue)
-{
- if (!timeLineValue._t)
- return;
- if (timeLineValue._t != this) {
- qWarning() << "QDeclarativeTimeLine: Cannot reset a QDeclarativeTimeLineValue owned by another timeline.";
- return;
- }
- remove(&timeLineValue);
- timeLineValue._t = 0;
-}
-
-int QDeclarativeTimeLine::duration() const
-{
- return -1;
-}
-
-/*!
- Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo
- within this timeline.
-
- Following operations on \a timeLineValue in this timeline will be scheduled after
- all the currently scheduled actions on \a syncTo are complete. In
- pseudo-code this is equivalent to:
- \code
- QDeclarativeTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))
- \endcode
-*/
-void QDeclarativeTimeLine::sync(QDeclarativeTimeLineValue &timeLineValue, QDeclarativeTimeLineValue &syncTo)
-{
- QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo);
- if (iter == d->ops.end())
- return;
- int length = iter->length;
-
- iter = d->ops.find(&timeLineValue);
- if (iter == d->ops.end()) {
- pause(timeLineValue, length);
- } else {
- int glength = iter->length;
- pause(timeLineValue, length - glength);
- }
-}
-
-/*!
- Synchronize the end point of \a timeLineValue to the endpoint of the longest
- action cursrently scheduled in the timeline.
-
- In pseudo-code, this is equivalent to:
- \code
- QDeclarativeTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))
- \endcode
-*/
-void QDeclarativeTimeLine::sync(QDeclarativeTimeLineValue &timeLineValue)
-{
- QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue);
- if (iter == d->ops.end()) {
- pause(timeLineValue, d->length);
- } else {
- pause(timeLineValue, d->length - iter->length);
- }
-}
-
-/*
- Synchronize all currently and future scheduled values in this timeline to
- the longest action currently scheduled.
-
- For example:
- \code
- value1->setValue(0.);
- value2->setValue(0.);
- value3->setValue(0.);
- QDeclarativeTimeLine tl;
- ...
- tl.move(value1, 10, 200);
- tl.move(value2, 10, 100);
- tl.sync();
- tl.move(value2, 20, 100);
- tl.move(value3, 20, 100);
- \endcode
-
- will result in:
-
- \table
- \header \o \o 0ms \o 50ms \o 100ms \o 150ms \o 200ms \o 250ms \o 300ms
- \row \o value1 \o 0 \o 2.5 \o 5.0 \o 7.5 \o 10 \o 10 \o 10
- \row \o value2 \o 0 \o 5.0 \o 10.0 \o 10.0 \o 10.0 \o 15.0 \o 20.0
- \row \o value2 \o 0 \o 0 \o 0 \o 0 \o 0 \o 10.0 \o 20.0
- \endtable
-*/
-
-/*void QDeclarativeTimeLine::sync()
-{
- for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter)
- pause(*iter.key(), d->length - iter->length);
- d->syncPoint = d->length;
-}*/
-
-/*!
- \internal
-
- Temporary hack.
- */
-void QDeclarativeTimeLine::setSyncPoint(int sp)
-{
- d->syncPoint = sp;
-}
-
-/*!
- \internal
-
- Temporary hack.
- */
-int QDeclarativeTimeLine::syncPoint() const
-{
- return d->syncPoint;
-}
-
-/*!
- Returns true if the timeline is active. An active timeline is one where
- QDeclarativeTimeLineValue actions are still pending.
-*/
-bool QDeclarativeTimeLine::isActive() const
-{
- return !d->ops.isEmpty();
-}
-
-/*!
- Completes the timeline. All queued actions are played to completion, and then discarded. For example,
- \code
- QDeclarativeTimeLineValue v(0.);
- QDeclarativeTimeLine tl;
- tl.move(v, 100., 1000.);
- // 500 ms passes
- // v.value() == 50.
- tl.complete();
- // v.value() == 100.
- \endcode
-*/
-void QDeclarativeTimeLine::complete()
-{
- d->advance(d->length);
-}
-
-/*!
- Resets the timeline. All queued actions are discarded and QDeclarativeTimeLineValue's retain their current value. For example,
- \code
- QDeclarativeTimeLineValue v(0.);
- QDeclarativeTimeLine tl;
- tl.move(v, 100., 1000.);
- // 500 ms passes
- // v.value() == 50.
- tl.clear();
- // v.value() == 50.
- \endcode
-*/
-void QDeclarativeTimeLine::clear()
-{
- for (QDeclarativeTimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter)
- iter.key()->_t = 0;
- d->ops.clear();
- d->length = 0;
- d->syncPoint = 0;
- //XXX need stop here?
-}
-
-int QDeclarativeTimeLine::time() const
-{
- return d->prevTime;
-}
-
-/*!
- \fn void QDeclarativeTimeLine::updated()
-
- Emitted each time the timeline modifies QDeclarativeTimeLineValues. Even if multiple
- QDeclarativeTimeLineValues are changed, this signal is only emitted once for each clock tick.
-*/
-
-void QDeclarativeTimeLine::updateCurrentTime(int v)
-{
- if (d->syncAdj == -1)
- d->syncAdj = v;
- v -= d->syncAdj;
-
- int timeChanged = v - d->prevTime;
-#if 0
- if (!timeChanged)
- return;
-#endif
- d->prevTime = v;
- d->advance(timeChanged);
- emit updated();
-
- // Do we need to stop the clock?
- if (d->ops.isEmpty()) {
- stop();
- d->prevTime = 0;
- d->clockRunning = false;
- emit completed();
- } /*else if (pauseTime > 0) {
- GfxClock::cancelClock();
- d->prevTime = 0;
- GfxClock::pauseFor(pauseTime);
- d->syncAdj = 0;
- d->clockRunning = false;
- }*/ else if (/*!GfxClock::isActive()*/ state() != Running) {
- stop();
- d->prevTime = 0;
- d->clockRunning = true;
- d->syncAdj = 0;
- start();
- }
-}
-
-bool operator<(const QPair<int, Update> &lhs,
- const QPair<int, Update> &rhs)
-{
- return lhs.first < rhs.first;
-}
-
-int QDeclarativeTimeLinePrivate::advance(int t)
-{
- int pauseTime = -1;
-
- // XXX - surely there is a more efficient way?
- do {
- pauseTime = -1;
- // Minimal advance time
- int advanceTime = t;
- for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) {
- TimeLine &tl = *iter;
- Op &op = tl.ops.first();
- int length = op.length - tl.consumedOpLength;
-
- if (length < advanceTime) {
- advanceTime = length;
- if (advanceTime == 0)
- break;
- }
- }
- t -= advanceTime;
-
- // Process until then. A zero length advance time will only process
- // sets.
- QList<QPair<int, Update> > updates;
-
- for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) {
- QDeclarativeTimeLineValue *v = static_cast<QDeclarativeTimeLineValue *>(iter.key());
- TimeLine &tl = *iter;
- Q_ASSERT(!tl.ops.isEmpty());
-
- do {
- Op &op = tl.ops.first();
- if (advanceTime == 0 && op.length != 0)
- continue;
-
- if (tl.consumedOpLength == 0 &&
- op.type != Op::Pause &&
- op.type != Op::Execute)
- tl.base = v->value();
-
- if ((tl.consumedOpLength + advanceTime) == op.length) {
- if (op.type == Op::Execute) {
- updates << qMakePair(op.order, Update(op.event));
- } else {
- bool changed = false;
- qreal val = value(op, op.length, tl.base, &changed);
- if (changed)
- updates << qMakePair(op.order, Update(v, val));
- }
- tl.length -= qMin(advanceTime, tl.length);
- tl.consumedOpLength = 0;
- tl.ops.removeFirst();
- } else {
- tl.consumedOpLength += advanceTime;
- bool changed = false;
- qreal val = value(op, tl.consumedOpLength, tl.base, &changed);
- if (changed)
- updates << qMakePair(op.order, Update(v, val));
- tl.length -= qMin(advanceTime, tl.length);
- break;
- }
-
- } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0);
-
-
- if (tl.ops.isEmpty()) {
- iter = ops.erase(iter);
- v->_t = 0;
- } else {
- if (tl.ops.first().type == Op::Pause && pauseTime != 0) {
- int opPauseTime = tl.ops.first().length - tl.consumedOpLength;
- if (pauseTime == -1 || opPauseTime < pauseTime)
- pauseTime = opPauseTime;
- } else {
- pauseTime = 0;
- }
- ++iter;
- }
- }
-
- length -= qMin(length, advanceTime);
- syncPoint -= advanceTime;
-
- qSort(updates.begin(), updates.end());
- updateQueue = &updates;
- for (int ii = 0; ii < updates.count(); ++ii) {
- const Update &v = updates.at(ii).second;
- if (v.g) {
- v.g->setValue(v.v);
- } else {
- v.e.d0(v.e.d1);
- }
- }
- updateQueue = 0;
- } while(t);
-
- return pauseTime;
-}
-
-void QDeclarativeTimeLine::remove(QDeclarativeTimeLineObject *v)
-{
- QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(v);
- Q_ASSERT(iter != d->ops.end());
-
- int len = iter->length;
- d->ops.erase(iter);
- if (len == d->length) {
- // We need to recalculate the length
- d->length = 0;
- for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter) {
-
- if (iter->length > d->length)
- d->length = iter->length;
-
- }
- }
- if (d->ops.isEmpty()) {
- stop();
- d->clockRunning = false;
- } else if (/*!GfxClock::isActive()*/ state() != Running) {
- stop();
- d->prevTime = 0;
- d->clockRunning = true;
-
- if (d->syncMode == QDeclarativeTimeLine::LocalSync) {
- d->syncAdj = -1;
- } else {
- d->syncAdj = 0;
- }
- start();
- }
-
- if (d->updateQueue) {
- for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
- if (d->updateQueue->at(ii).second.g == v ||
- d->updateQueue->at(ii).second.e.callbackObject() == v) {
- d->updateQueue->removeAt(ii);
- --ii;
- }
- }
- }
-
-
-}
-
-/*!
- \internal
- \class QDeclarativeTimeLineValue
- \brief The QDeclarativeTimeLineValue class provides a value that can be modified by QDeclarativeTimeLine.
-*/
-
-/*!
- \fn QDeclarativeTimeLineValue::QDeclarativeTimeLineValue(qreal value = 0)
-
- Construct a new QDeclarativeTimeLineValue with an initial \a value.
-*/
-
-/*!
- \fn qreal QDeclarativeTimeLineValue::value() const
-
- Return the current value.
-*/
-
-/*!
- \fn void QDeclarativeTimeLineValue::setValue(qreal value)
-
- Set the current \a value.
-*/
-
-/*!
- \fn QDeclarativeTimeLine *QDeclarativeTimeLineValue::timeLine() const
-
- If a QDeclarativeTimeLine is operating on this value, return a pointer to it,
- otherwise return null.
-*/
-
-
-QDeclarativeTimeLineObject::QDeclarativeTimeLineObject()
-: _t(0)
-{
-}
-
-QDeclarativeTimeLineObject::~QDeclarativeTimeLineObject()
-{
- if (_t) {
- _t->remove(this);
- _t = 0;
- }
-}
-
-QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback()
-: d0(0), d1(0), d2(0)
-{
-}
-
-QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback(QDeclarativeTimeLineObject *b, Callback f, void *d)
-: d0(f), d1(d), d2(b)
-{
-}
-
-QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback(const QDeclarativeTimeLineCallback &o)
-: d0(o.d0), d1(o.d1), d2(o.d2)
-{
-}
-
-QDeclarativeTimeLineCallback &QDeclarativeTimeLineCallback::operator=(const QDeclarativeTimeLineCallback &o)
-{
- d0 = o.d0;
- d1 = o.d1;
- d2 = o.d2;
- return *this;
-}
-
-QDeclarativeTimeLineObject *QDeclarativeTimeLineCallback::callbackObject() const
-{
- return d2;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativetimeline_p_p.h b/src/quick/util/qdeclarativetimeline_p_p.h
deleted file mode 100644
index 421e2e5976..0000000000
--- a/src/quick/util/qdeclarativetimeline_p_p.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETIMELINE_H
-#define QDECLARATIVETIMELINE_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/QObject>
-#include "private/qabstractanimationjob_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QEasingCurve;
-class QDeclarativeTimeLineValue;
-class QDeclarativeTimeLineCallback;
-struct QDeclarativeTimeLinePrivate;
-class QDeclarativeTimeLineObject;
-class Q_AUTOTEST_EXPORT QDeclarativeTimeLine : public QObject, QAbstractAnimationJob
-{
-Q_OBJECT
-public:
- QDeclarativeTimeLine(QObject *parent = 0);
- ~QDeclarativeTimeLine();
-
- enum SyncMode { LocalSync, GlobalSync };
- SyncMode syncMode() const;
- void setSyncMode(SyncMode);
-
- void pause(QDeclarativeTimeLineObject &, int);
- void callback(const QDeclarativeTimeLineCallback &);
- void set(QDeclarativeTimeLineValue &, qreal);
-
- int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel);
- int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
- int accelDistance(QDeclarativeTimeLineValue &, qreal velocity, qreal distance);
-
- void move(QDeclarativeTimeLineValue &, qreal destination, int time = 500);
- void move(QDeclarativeTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
- void moveBy(QDeclarativeTimeLineValue &, qreal change, int time = 500);
- void moveBy(QDeclarativeTimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
-
- void sync();
- void setSyncPoint(int);
- int syncPoint() const;
-
- void sync(QDeclarativeTimeLineValue &);
- void sync(QDeclarativeTimeLineValue &, QDeclarativeTimeLineValue &);
-
- void reset(QDeclarativeTimeLineValue &);
-
- void complete();
- void clear();
- bool isActive() const;
-
- int time() const;
-
- virtual int duration() const;
-Q_SIGNALS:
- void updated();
- void completed();
-
-protected:
- virtual void updateCurrentTime(int);
-
-private:
- void remove(QDeclarativeTimeLineObject *);
- friend class QDeclarativeTimeLineObject;
- friend struct QDeclarativeTimeLinePrivate;
- QDeclarativeTimeLinePrivate *d;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeTimeLineObject
-{
-public:
- QDeclarativeTimeLineObject();
- virtual ~QDeclarativeTimeLineObject();
-
-protected:
- friend class QDeclarativeTimeLine;
- friend struct QDeclarativeTimeLinePrivate;
- QDeclarativeTimeLine *_t;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeTimeLineValue : public QDeclarativeTimeLineObject
-{
-public:
- QDeclarativeTimeLineValue(qreal v = 0.) : _v(v) {}
-
- virtual qreal value() const { return _v; }
- virtual void setValue(qreal v) { _v = v; }
-
- QDeclarativeTimeLine *timeLine() const { return _t; }
-
- operator qreal() const { return _v; }
- QDeclarativeTimeLineValue &operator=(qreal v) { setValue(v); return *this; }
-private:
- friend class QDeclarativeTimeLine;
- friend struct QDeclarativeTimeLinePrivate;
- qreal _v;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarativeTimeLineCallback
-{
-public:
- typedef void (*Callback)(void *);
-
- QDeclarativeTimeLineCallback();
- QDeclarativeTimeLineCallback(QDeclarativeTimeLineObject *b, Callback, void * = 0);
- QDeclarativeTimeLineCallback(const QDeclarativeTimeLineCallback &o);
-
- QDeclarativeTimeLineCallback &operator=(const QDeclarativeTimeLineCallback &o);
- QDeclarativeTimeLineObject *callbackObject() const;
-
-private:
- friend struct QDeclarativeTimeLinePrivate;
- Callback d0;
- void *d1;
- QDeclarativeTimeLineObject *d2;
-};
-
-template<class T>
-class QDeclarativeTimeLineValueProxy : public QDeclarativeTimeLineValue
-{
-public:
- QDeclarativeTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
- : QDeclarativeTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
- {
- Q_ASSERT(_class);
- }
-
- QDeclarativeTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
- : QDeclarativeTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
- {
- Q_ASSERT(_class);
- }
-
- virtual void setValue(qreal v)
- {
- QDeclarativeTimeLineValue::setValue(v);
- if (_setFunctionReal) (_class->*_setFunctionReal)(v);
- else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v);
- }
-
-private:
- T *_class;
- void (T::*_setFunctionReal)(qreal);
- void (T::*_setFunctionInt)(int);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/quick/util/qdeclarativetimer.cpp b/src/quick/util/qdeclarativetimer.cpp
deleted file mode 100644
index 3c57f22c58..0000000000
--- a/src/quick/util/qdeclarativetimer.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetimer_p.h"
-
-#include <QtCore/qcoreapplication.h>
-#include "private/qpauseanimationjob_p.h"
-#include <qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarativeTimerPrivate : public QObjectPrivate, public QAnimationJobChangeListener
-{
- Q_DECLARE_PUBLIC(QDeclarativeTimer)
-public:
- QDeclarativeTimerPrivate()
- : interval(1000), running(false), repeating(false), triggeredOnStart(false)
- , classBegun(false), componentComplete(false), firstTick(true) {}
-
- virtual void animationFinished(QAbstractAnimationJob *);
- virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) { Q_Q(QDeclarativeTimer); q->ticked(); }
-
- int interval;
- QPauseAnimationJob pause;
- bool running : 1;
- bool repeating : 1;
- bool triggeredOnStart : 1;
- bool classBegun : 1;
- bool componentComplete : 1;
- bool firstTick : 1;
-};
-
-/*!
- \qmlclass Timer QDeclarativeTimer
- \inqmlmodule QtQuick 2
- \ingroup qml-utility-elements
- \brief The Timer item triggers a handler at a specified interval.
-
- A Timer can be used to trigger an action either once, or repeatedly
- at a given interval.
-
- Here is a Timer that shows the current date and time, and updates
- the text every 500 milliseconds. It uses the JavaScript \c Date
- object to access the current time.
-
- \qml
- import QtQuick 2.0
-
- Item {
- Timer {
- interval: 500; running: true; repeat: true
- onTriggered: time.text = Date().toString()
- }
-
- Text { id: time }
- }
- \endqml
-
- The Timer element is synchronized with the animation timer. Since the animation
- timer is usually set to 60fps, the resolution of Timer will be
- at best 16ms.
-
- If the Timer is running and one of its properties is changed, the
- elapsed time will be reset. For example, if a Timer with interval of
- 1000ms has its \e repeat property changed 500ms after starting, the
- elapsed time will be reset to 0, and the Timer will be triggered
- 1000ms later.
-
- \sa {declarative/toys/clocks}{Clocks example}
-*/
-
-QDeclarativeTimer::QDeclarativeTimer(QObject *parent)
- : QObject(*(new QDeclarativeTimerPrivate), parent)
-{
- Q_D(QDeclarativeTimer);
- d->pause.addAnimationChangeListener(d, QAbstractAnimationJob::Completion | QAbstractAnimationJob::CurrentLoop);
- d->pause.setLoopCount(1);
- d->pause.setDuration(d->interval);
-}
-
-/*!
- \qmlproperty int QtQuick2::Timer::interval
-
- Sets the \a interval between triggers, in milliseconds.
-
- The default interval is 1000 milliseconds.
-*/
-void QDeclarativeTimer::setInterval(int interval)
-{
- Q_D(QDeclarativeTimer);
- if (interval != d->interval) {
- d->interval = interval;
- update();
- emit intervalChanged();
- }
-}
-
-int QDeclarativeTimer::interval() const
-{
- Q_D(const QDeclarativeTimer);
- return d->interval;
-}
-
-/*!
- \qmlproperty bool QtQuick2::Timer::running
-
- If set to true, starts the timer; otherwise stops the timer.
- For a non-repeating timer, \a running is set to false after the
- timer has been triggered.
-
- \a running defaults to false.
-
- \sa repeat
-*/
-bool QDeclarativeTimer::isRunning() const
-{
- Q_D(const QDeclarativeTimer);
- return d->running;
-}
-
-void QDeclarativeTimer::setRunning(bool running)
-{
- Q_D(QDeclarativeTimer);
- if (d->running != running) {
- d->running = running;
- d->firstTick = true;
- emit runningChanged();
- update();
- }
-}
-
-/*!
- \qmlproperty bool QtQuick2::Timer::repeat
-
- If \a repeat is true the timer is triggered repeatedly at the
- specified interval; otherwise, the timer will trigger once at the
- specified interval and then stop (i.e. running will be set to false).
-
- \a repeat defaults to false.
-
- \sa running
-*/
-bool QDeclarativeTimer::isRepeating() const
-{
- Q_D(const QDeclarativeTimer);
- return d->repeating;
-}
-
-void QDeclarativeTimer::setRepeating(bool repeating)
-{
- Q_D(QDeclarativeTimer);
- if (repeating != d->repeating) {
- d->repeating = repeating;
- update();
- emit repeatChanged();
- }
-}
-
-/*!
- \qmlproperty bool QtQuick2::Timer::triggeredOnStart
-
- When a timer is started, the first trigger is usually after the specified
- interval has elapsed. It is sometimes desirable to trigger immediately
- when the timer is started; for example, to establish an initial
- state.
-
- If \a triggeredOnStart is true, the timer is triggered immediately
- when started, and subsequently at the specified interval. Note that if
- \e repeat is set to false, the timer is triggered twice; once on start,
- and again at the interval.
-
- \a triggeredOnStart defaults to false.
-
- \sa running
-*/
-bool QDeclarativeTimer::triggeredOnStart() const
-{
- Q_D(const QDeclarativeTimer);
- return d->triggeredOnStart;
-}
-
-void QDeclarativeTimer::setTriggeredOnStart(bool triggeredOnStart)
-{
- Q_D(QDeclarativeTimer);
- if (d->triggeredOnStart != triggeredOnStart) {
- d->triggeredOnStart = triggeredOnStart;
- update();
- emit triggeredOnStartChanged();
- }
-}
-
-/*!
- \qmlmethod QtQuick2::Timer::start()
- \brief Starts the timer.
-
- If the timer is already running, calling this method has no effect. The
- \c running property will be true following a call to \c start().
-*/
-void QDeclarativeTimer::start()
-{
- setRunning(true);
-}
-
-/*!
- \qmlmethod QtQuick2::Timer::stop()
- \brief Stops the timer.
-
- If the timer is not running, calling this method has no effect. The
- \c running property will be false following a call to \c stop().
-*/
-void QDeclarativeTimer::stop()
-{
- setRunning(false);
-}
-
-/*!
- \qmlmethod QtQuick2::Timer::restart()
- \brief Restarts the timer.
-
- If the Timer is not running it will be started, otherwise it will be
- stopped, reset to initial state and started. The \c running property
- will be true following a call to \c restart().
-*/
-void QDeclarativeTimer::restart()
-{
- setRunning(false);
- setRunning(true);
-}
-
-void QDeclarativeTimer::update()
-{
- Q_D(QDeclarativeTimer);
- if (d->classBegun && !d->componentComplete)
- return;
- d->pause.stop();
- if (d->running) {
- d->pause.setCurrentTime(0);
- d->pause.setLoopCount(d->repeating ? -1 : 1);
- d->pause.setDuration(d->interval);
- d->pause.start();
- if (d->triggeredOnStart && d->firstTick) {
- QCoreApplication::removePostedEvents(this, QEvent::MetaCall);
- QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection);
- }
- }
-}
-
-void QDeclarativeTimer::classBegin()
-{
- Q_D(QDeclarativeTimer);
- d->classBegun = true;
-}
-
-void QDeclarativeTimer::componentComplete()
-{
- Q_D(QDeclarativeTimer);
- d->componentComplete = true;
- update();
-}
-
-/*!
- \qmlsignal QtQuick2::Timer::onTriggered()
-
- This handler is called when the Timer is triggered.
-*/
-void QDeclarativeTimer::ticked()
-{
- Q_D(QDeclarativeTimer);
- if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick)))
- emit triggered();
- d->firstTick = false;
-}
-
-void QDeclarativeTimerPrivate::animationFinished(QAbstractAnimationJob *)
-{
- Q_Q(QDeclarativeTimer);
- if (repeating || !running)
- return;
- running = false;
- firstTick = false;
- emit q->triggered();
- emit q->runningChanged();
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativetimer_p.h b/src/quick/util/qdeclarativetimer_p.h
deleted file mode 100644
index e400b3dda3..0000000000
--- a/src/quick/util/qdeclarativetimer_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETIMER_H
-#define QDECLARATIVETIMER_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/qobject.h>
-
-#include <private/qtquickglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeTimerPrivate;
-class Q_QUICK_PRIVATE_EXPORT QDeclarativeTimer : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeTimer)
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
- Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged)
- Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged)
- Q_PROPERTY(QObject *parent READ parent CONSTANT)
-
-public:
- QDeclarativeTimer(QObject *parent=0);
-
- void setInterval(int interval);
- int interval() const;
-
- bool isRunning() const;
- void setRunning(bool running);
-
- bool isRepeating() const;
- void setRepeating(bool repeating);
-
- bool triggeredOnStart() const;
- void setTriggeredOnStart(bool triggeredOnStart);
-
-protected:
- void classBegin();
- void componentComplete();
-
-public Q_SLOTS:
- void start();
- void stop();
- void restart();
-
-Q_SIGNALS:
- void triggered();
- void runningChanged();
- void intervalChanged();
- void repeatChanged();
- void triggeredOnStartChanged();
-
-private:
- void update();
-
-private Q_SLOTS:
- void ticked();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeTimer)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/quick/util/qdeclarativetransition.cpp b/src/quick/util/qdeclarativetransition.cpp
deleted file mode 100644
index 96e870df82..0000000000
--- a/src/quick/util/qdeclarativetransition.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetransition_p.h"
-
-#include "qdeclarativestate_p.h"
-#include "qdeclarativestate_p_p.h"
-#include "qdeclarativestateoperations_p.h"
-#include "qdeclarativeanimation_p.h"
-#include "qdeclarativeanimation_p_p.h"
-#include "qdeclarativetransitionmanager_p_p.h"
-
-#include "private/qparallelanimationgroupjob_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass Transition QDeclarativeTransition
- \inqmlmodule QtQuick 2
- \ingroup qml-animation-transition
- \brief The Transition element defines animated transitions that occur on state changes.
-
- A Transition defines the animations to be applied when a \l State change occurs.
-
- For example, the following \l Rectangle has two states: the default state, and
- an added "moved" state. In the "moved state, the rectangle's position changes
- to (50, 50). The added Transition specifies that when the rectangle
- changes between the default and the "moved" state, any changes
- to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad.
-
- \snippet doc/src/snippets/declarative/transition.qml 0
-
- Notice the example does not require \l{PropertyAnimation::}{to} and
- \l{PropertyAnimation::}{from} values for the NumberAnimation. As a convenience,
- these properties are automatically set to the values of \c x and \c y before
- and after the state change; the \c from values are provided by
- the current values of \c x and \c y, and the \c to values are provided by
- the PropertyChanges object. If you wish, you can provide \l{PropertyAnimation::}{to} and
- \l{PropertyAnimation::}{from} values anyway to override the default values.
-
- By default, a Transition's animations are applied for any state change in the
- parent item. The Transition \l {Transition::}{from} and \l {Transition::}{to}
- values can be set to restrict the animations to only be applied when changing
- from one particular state to another.
-
- To define multiple transitions, specify \l Item::transitions as a list:
-
- \snippet doc/src/snippets/declarative/transitions-list.qml list of transitions
-
- If multiple Transitions are specified, only a single (best-matching) Transition will be applied for any particular
- state change. In the example above, when changing to \c state1, the first transition will be used, rather
- than the more generic second transition.
-
- If a state change has a Transition that matches the same property as a
- \l Behavior, the Transition animation overrides the \l Behavior for that
- state change.
-
- \sa {QML Animation and Transitions}, {declarative/animation/states}{states example}, {qmlstates}{States}, {QtDeclarative}
-*/
-
-QDeclarativeTransitionInstance::QDeclarativeTransitionInstance()
- : m_anim(0)
-{
-}
-
-QDeclarativeTransitionInstance::~QDeclarativeTransitionInstance()
-{
- delete m_anim;
-}
-
-void QDeclarativeTransitionInstance::start()
-{
- if (m_anim)
- m_anim->start();
-}
-
-void QDeclarativeTransitionInstance::stop()
-{
- if (m_anim)
- m_anim->stop();
-}
-
-bool QDeclarativeTransitionInstance::isRunning() const
-{
- return m_anim && m_anim->state() == QAbstractAnimationJob::Running;
-}
-
-
-//ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting
-//and disconnecting signals and slots frequently
-class ParallelAnimationWrapper : public QParallelAnimationGroupJob
-{
-public:
- ParallelAnimationWrapper() : QParallelAnimationGroupJob() {}
- QDeclarativeTransitionManager *manager;
-
-protected:
- virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
-};
-
-class QDeclarativeTransitionPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeTransition)
-public:
- QDeclarativeTransitionPrivate()
- : fromState(QLatin1String("*")), toState(QLatin1String("*")),
- reversed(false), reversible(false), enabled(true)
- {
- }
-
- QString fromState;
- QString toState;
- bool reversed;
- bool reversible;
- bool enabled;
-
- static void append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a);
- static int animation_count(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list);
- static QDeclarativeAbstractAnimation* animation_at(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, int pos);
- static void clear_animations(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list);
- QList<QDeclarativeAbstractAnimation *> animations;
-};
-
-void QDeclarativeTransitionPrivate::append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a)
-{
- QDeclarativeTransition *q = static_cast<QDeclarativeTransition *>(list->object);
- q->d_func()->animations.append(a);
- a->setDisableUserControl();
-}
-
-int QDeclarativeTransitionPrivate::animation_count(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list)
-{
- QDeclarativeTransition *q = static_cast<QDeclarativeTransition *>(list->object);
- return q->d_func()->animations.count();
-}
-
-QDeclarativeAbstractAnimation* QDeclarativeTransitionPrivate::animation_at(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, int pos)
-{
- QDeclarativeTransition *q = static_cast<QDeclarativeTransition *>(list->object);
- return q->d_func()->animations.at(pos);
-}
-
-void QDeclarativeTransitionPrivate::clear_animations(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list)
-{
- QDeclarativeTransition *q = static_cast<QDeclarativeTransition *>(list->object);
- while (q->d_func()->animations.count()) {
- QDeclarativeAbstractAnimation *firstAnim = q->d_func()->animations.at(0);
- q->d_func()->animations.removeAll(firstAnim);
- }
-}
-
-void ParallelAnimationWrapper::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState)
-{
- QParallelAnimationGroupJob::updateState(newState, oldState);
- if (newState == Stopped && (duration() == -1
- || (direction() == QAbstractAnimationJob::Forward && currentLoopTime() == duration())
- || (direction() == QAbstractAnimationJob::Backward && currentLoopTime() == 0)))
- {
- manager->complete();
- }
-}
-
-
-QDeclarativeTransition::QDeclarativeTransition(QObject *parent)
- : QObject(*(new QDeclarativeTransitionPrivate), parent)
-{
-}
-
-QDeclarativeTransition::~QDeclarativeTransition()
-{
-}
-
-void QDeclarativeTransition::setReversed(bool r)
-{
- Q_D(QDeclarativeTransition);
- d->reversed = r;
-}
-
-QDeclarativeTransitionInstance *QDeclarativeTransition::prepare(QDeclarativeStateOperation::ActionList &actions,
- QList<QDeclarativeProperty> &after,
- QDeclarativeTransitionManager *manager,
- QObject *defaultTarget)
-{
- Q_D(QDeclarativeTransition);
-
- qmlExecuteDeferred(this);
-
- ParallelAnimationWrapper *group = new ParallelAnimationWrapper();
- group->manager = manager;
-
- QDeclarativeAbstractAnimation::TransitionDirection direction = d->reversed ? QDeclarativeAbstractAnimation::Backward : QDeclarativeAbstractAnimation::Forward;
- int start = d->reversed ? d->animations.count() - 1 : 0;
- int end = d->reversed ? -1 : d->animations.count();
-
- QAbstractAnimationJob *anim = 0;
- for (int i = start; i != end;) {
- anim = d->animations.at(i)->transition(actions, after, direction, defaultTarget);
- if (anim)
- d->reversed ? group->prependAnimation(anim) : group->appendAnimation(anim);
- d->reversed ? --i : ++i;
- }
-
- group->setDirection(d->reversed ? QAbstractAnimationJob::Backward : QAbstractAnimationJob::Forward);
-
- QDeclarativeTransitionInstance *wrapper = new QDeclarativeTransitionInstance;
- wrapper->m_anim = group;
- return wrapper;
-}
-
-/*!
- \qmlproperty string QtQuick2::Transition::from
- \qmlproperty string QtQuick2::Transition::to
-
- These properties indicate the state changes that trigger the transition.
-
- The default values for these properties is "*" (that is, any state).
-
- For example, the following transition has not set the \c to and \c from
- properties, so the animation is always applied when changing between
- the two states (i.e. when the mouse is pressed and released).
-
- \snippet doc/src/snippets/declarative/transition-from-to.qml 0
-
- If the transition was changed to this:
-
- \snippet doc/src/snippets/declarative/transition-from-to-modified.qml modified transition
-
- The animation would only be applied when changing from the default state to
- the "brighter" state (i.e. when the mouse is pressed, but not on release).
-
- Multiple \c to and \from values can be set by using a comma-separated string.
-
- \sa reversible
-*/
-QString QDeclarativeTransition::fromState() const
-{
- Q_D(const QDeclarativeTransition);
- return d->fromState;
-}
-
-void QDeclarativeTransition::setFromState(const QString &f)
-{
- Q_D(QDeclarativeTransition);
- if (f == d->fromState)
- return;
-
- d->fromState = f;
- emit fromChanged();
-}
-
-/*!
- \qmlproperty bool QtQuick2::Transition::reversible
- This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed.
-
- The default value is false.
-
- By default, transitions run in parallel and are applied to all state
- changes if the \l from and \l to states have not been set. In this
- situation, the transition is automatically applied when a state change
- is reversed, and it is not necessary to set this property to reverse
- the transition.
-
- However, if a SequentialAnimation is used, or if the \l from or \l to
- properties have been set, this property will need to be set to reverse
- a transition when a state change is reverted. For example, the following
- transition applies a sequential animation when the mouse is pressed,
- and reverses the sequence of the animation when the mouse is released:
-
- \snippet doc/src/snippets/declarative/transition-reversible.qml 0
-
- If the transition did not set the \c to and \c reversible values, then
- on the mouse release, the transition would play the PropertyAnimation
- before the ColorAnimation instead of reversing the sequence.
-*/
-bool QDeclarativeTransition::reversible() const
-{
- Q_D(const QDeclarativeTransition);
- return d->reversible;
-}
-
-void QDeclarativeTransition::setReversible(bool r)
-{
- Q_D(QDeclarativeTransition);
- if (r == d->reversible)
- return;
-
- d->reversible = r;
- emit reversibleChanged();
-}
-
-QString QDeclarativeTransition::toState() const
-{
- Q_D(const QDeclarativeTransition);
- return d->toState;
-}
-
-void QDeclarativeTransition::setToState(const QString &t)
-{
- Q_D(QDeclarativeTransition);
- if (t == d->toState)
- return;
-
- d->toState = t;
- emit toChanged();
-}
-
-/*!
- \qmlproperty bool QtQuick2::Transition::enabled
-
- This property holds whether the Transition will be run when moving
- from the \c from state to the \c to state.
-
- By default a Transition is enabled.
-
- Note that in some circumstances disabling a Transition may cause an
- alternative Transition to be used in its place. In the following
- example, the generic Transition will be used to animate the change
- from \c state1 to \c state2, as the more specific Transition has
- been disabled.
-
- \qml
- Item {
- states: [
- State { name: "state1" ... }
- State { name: "state2" ... }
- ]
- transitions: [
- Transition { from: "state1"; to: "state2"; enabled: false ... }
- Transition { ... }
- ]
- }
- \endqml
-*/
-
-bool QDeclarativeTransition::enabled() const
-{
- Q_D(const QDeclarativeTransition);
- return d->enabled;
-}
-
-void QDeclarativeTransition::setEnabled(bool enabled)
-{
- Q_D(QDeclarativeTransition);
- if (d->enabled == enabled)
- return;
- d->enabled = enabled;
- emit enabledChanged();
-}
-
-/*!
- \qmlproperty list<Animation> QtQuick2::Transition::animations
- \default
-
- This property holds a list of the animations to be run for this transition.
-
- \snippet examples/declarative/toys/dynamicscene/dynamicscene.qml top-level transitions
-
- The top-level animations are run in parallel. To run them sequentially,
- define them within a SequentialAnimation:
-
- \snippet doc/src/snippets/declarative/transition-reversible.qml sequential animations
-*/
-QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeTransition::animations()
-{
- Q_D(QDeclarativeTransition);
- return QDeclarativeListProperty<QDeclarativeAbstractAnimation>(this, &d->animations, QDeclarativeTransitionPrivate::append_animation,
- QDeclarativeTransitionPrivate::animation_count,
- QDeclarativeTransitionPrivate::animation_at,
- QDeclarativeTransitionPrivate::clear_animations);
-}
-
-QT_END_NAMESPACE
-
-//#include <qdeclarativetransition.moc>
diff --git a/src/quick/util/qdeclarativetransition_p.h b/src/quick/util/qdeclarativetransition_p.h
deleted file mode 100644
index 839a626014..0000000000
--- a/src/quick/util/qdeclarativetransition_p.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETRANSITION_H
-#define QDECLARATIVETRANSITION_H
-
-#include "qdeclarativestate_p.h"
-#include <qdeclarative.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeAbstractAnimation;
-class QDeclarativeTransitionPrivate;
-class QDeclarativeTransitionManager;
-class QDeclarativeTransition;
-class QAbstractAnimationJob;
-
-class Q_QUICK_EXPORT QDeclarativeTransitionInstance
-{
-public:
- QDeclarativeTransitionInstance();
- ~QDeclarativeTransitionInstance();
-
- void start();
- void stop();
-
- bool isRunning() const;
-
-private:
- QAbstractAnimationJob *m_anim;
- friend class QDeclarativeTransition;
-};
-
-class Q_QUICK_EXPORT QDeclarativeTransition : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeTransition)
-
- Q_PROPERTY(QString from READ fromState WRITE setFromState NOTIFY fromChanged)
- Q_PROPERTY(QString to READ toState WRITE setToState NOTIFY toChanged)
- Q_PROPERTY(bool reversible READ reversible WRITE setReversible NOTIFY reversibleChanged)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_CLASSINFO("DefaultProperty", "animations")
- Q_CLASSINFO("DeferredPropertyNames", "animations")
-
-public:
- QDeclarativeTransition(QObject *parent=0);
- ~QDeclarativeTransition();
-
- QString fromState() const;
- void setFromState(const QString &);
-
- QString toState() const;
- void setToState(const QString &);
-
- bool reversible() const;
- void setReversible(bool);
-
- bool enabled() const;
- void setEnabled(bool enabled);
-
- QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations();
-
- QDeclarativeTransitionInstance *prepare(QDeclarativeStateOperation::ActionList &actions,
- QList<QDeclarativeProperty> &after,
- QDeclarativeTransitionManager *end,
- QObject *defaultTarget);
-
- void setReversed(bool r);
-
-Q_SIGNALS:
- void fromChanged();
- void toChanged();
- void reversibleChanged();
- void enabledChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeTransition)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVETRANSITION_H
diff --git a/src/quick/util/qdeclarativetransitionmanager.cpp b/src/quick/util/qdeclarativetransitionmanager.cpp
deleted file mode 100644
index ebe7805c62..0000000000
--- a/src/quick/util/qdeclarativetransitionmanager.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetransitionmanager_p_p.h"
-
-#include "qdeclarativetransition_p.h"
-#include "qdeclarativestate_p_p.h"
-
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativeproperty_p.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-class QDeclarativeTransitionManagerPrivate
-{
-public:
- QDeclarativeTransitionManagerPrivate()
- : state(0), transitionInstance(0) {}
-
- void applyBindings();
- typedef QList<QDeclarativeSimpleAction> SimpleActionList;
- QDeclarativeState *state;
- QDeclarativeTransitionInstance *transitionInstance;
- QDeclarativeStateOperation::ActionList bindingsList;
- SimpleActionList completeList;
-};
-
-QDeclarativeTransitionManager::QDeclarativeTransitionManager()
-: d(new QDeclarativeTransitionManagerPrivate)
-{
-}
-
-void QDeclarativeTransitionManager::setState(QDeclarativeState *s)
-{
- d->state = s;
-}
-
-QDeclarativeTransitionManager::~QDeclarativeTransitionManager()
-{
- delete d->transitionInstance;
- delete d; d = 0;
-}
-
-bool QDeclarativeTransitionManager::isRunning() const
-{
- return d->transitionInstance && d->transitionInstance->isRunning();
-}
-
-void QDeclarativeTransitionManager::complete()
-{
- d->applyBindings();
-
- for (int ii = 0; ii < d->completeList.count(); ++ii) {
- const QDeclarativeProperty &prop = d->completeList.at(ii).property();
- prop.write(d->completeList.at(ii).value());
- }
-
- d->completeList.clear();
-
- if (d->state)
- static_cast<QDeclarativeStatePrivate*>(QObjectPrivate::get(d->state))->complete();
-
- finished();
-}
-
-void QDeclarativeTransitionManagerPrivate::applyBindings()
-{
- foreach(const QDeclarativeAction &action, bindingsList) {
- if (!action.toBinding.isNull()) {
- QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data());
- } else if (action.event) {
- if (action.reverseEvent)
- action.event->reverse();
- else
- action.event->execute();
- }
-
- }
-
- bindingsList.clear();
-}
-
-void QDeclarativeTransitionManager::finished()
-{
-}
-
-void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &list,
- QDeclarativeTransition *transition,
- QObject *defaultTarget)
-{
- cancel();
-
- QDeclarativeStateOperation::ActionList applyList = list;
- // Determine which actions are binding changes and disable any current bindings
- foreach(const QDeclarativeAction &action, applyList) {
- if (action.toBinding)
- d->bindingsList << action;
- if (action.fromBinding)
- QDeclarativePropertyPrivate::setBinding(action.property, 0); // Disable current binding
- if (action.event && action.event->changesBindings()) { //### assume isReversable()?
- d->bindingsList << action;
- action.event->clearBindings();
- }
- }
-
- // Animated transitions need both the start and the end value for
- // each property change. In the presence of bindings, the end values
- // are non-trivial to calculate. As a "best effort" attempt, we first
- // apply all the property and binding changes, then read all the actual
- // final values, then roll back the changes and proceed as normal.
- //
- // This doesn't catch everything, and it might be a little fragile in
- // some cases - but whatcha going to do?
- //
- // Note that we only fast forward if both a transition and bindings are
- // present, as it is unneccessary (and potentially expensive) otherwise.
-
- if (transition && !d->bindingsList.isEmpty()) {
-
- // Apply all the property and binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- const QDeclarativeAction &action = applyList.at(ii);
- if (!action.toBinding.isNull()) {
- QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- } else if (!action.event) {
- QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- } else if (action.event->isReversable()) {
- if (action.reverseEvent)
- action.event->reverse(QDeclarativeActionEvent::FastForward);
- else
- action.event->execute(QDeclarativeActionEvent::FastForward);
- }
- }
-
- // Read all the end values for binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- QDeclarativeAction *action = &applyList[ii];
- if (action->event) {
- action->event->saveTargetValues();
- continue;
- }
- const QDeclarativeProperty &prop = action->property;
- if (!action->toBinding.isNull() || !action->toValue.isValid()) {
- action->toValue = prop.read();
- }
- }
-
- // Revert back to the original values
- foreach(const QDeclarativeAction &action, applyList) {
- if (action.event) {
- if (action.event->isReversable()) {
- action.event->clearBindings();
- action.event->rewind();
- action.event->clearBindings(); //### shouldn't be needed
- }
- continue;
- }
-
- if (action.toBinding)
- QDeclarativePropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition
-
- QDeclarativePropertyPrivate::write(action.property, action.fromValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- }
- }
-
- if (transition) {
- QList<QDeclarativeProperty> touched;
- QDeclarativeTransitionInstance *oldInstance = d->transitionInstance;
- d->transitionInstance = transition->prepare(applyList, touched, this, defaultTarget);
- d->transitionInstance->start();
- if (oldInstance && oldInstance != d->transitionInstance)
- delete oldInstance;
-
- // Modify the action list to remove actions handled in the transition
- for (int ii = 0; ii < applyList.count(); ++ii) {
- const QDeclarativeAction &action = applyList.at(ii);
-
- if (action.event) {
-
- if (action.actionDone) {
- applyList.removeAt(ii);
- --ii;
- }
-
- } else {
-
- if (touched.contains(action.property)) {
- if (action.toValue != action.fromValue)
- d->completeList <<
- QDeclarativeSimpleAction(action, QDeclarativeSimpleAction::EndState);
-
- applyList.removeAt(ii);
- --ii;
- }
-
- }
- }
- }
-
- // Any actions remaining have not been handled by the transition and should
- // be applied immediately. We skip applying bindings, as they are all
- // applied at the end in applyBindings() to avoid any nastiness mid
- // transition
- foreach(const QDeclarativeAction &action, applyList) {
- if (action.event && !action.event->changesBindings()) {
- if (action.event->isReversable() && action.reverseEvent)
- action.event->reverse();
- else
- action.event->execute();
- } else if (!action.event && !action.toBinding) {
- action.property.write(action.toValue);
- }
- }
-#ifndef QT_NO_DEBUG_STREAM
- if (stateChangeDebug()) {
- foreach(const QDeclarativeAction &action, applyList) {
- if (action.event)
- qWarning() << " No transition for event:" << action.event->type();
- else
- qWarning() << " No transition for:" << action.property.object()
- << action.property.name() << "From:" << action.fromValue
- << "To:" << action.toValue;
- }
- }
-#endif
- if (!transition)
- complete();
-}
-
-void QDeclarativeTransitionManager::cancel()
-{
- if (d->transitionInstance && d->transitionInstance->isRunning())
- d->transitionInstance->stop();
-
- for(int i = 0; i < d->bindingsList.count(); ++i) {
- QDeclarativeAction action = d->bindingsList[i];
- if (!action.toBinding.isNull() && action.deletableToBinding) {
- QDeclarativePropertyPrivate::setBinding(action.property, 0);
- action.toBinding.data()->destroy();
- action.toBinding.clear();
- action.deletableToBinding = false;
- } else if (action.event) {
- //### what do we do here?
- }
-
- }
- d->bindingsList.clear();
- d->completeList.clear();
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/util/qdeclarativetransitionmanager_p_p.h b/src/quick/util/qdeclarativetransitionmanager_p_p.h
deleted file mode 100644
index d548c05f3a..0000000000
--- a/src/quick/util/qdeclarativetransitionmanager_p_p.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETRANSITIONMANAGER_P_H
-#define QDECLARATIVETRANSITIONMANAGER_P_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 "qdeclarativestateoperations_p.h"
-#include "qdeclarativeanimation_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeStatePrivate;
-class QDeclarativeTransitionManagerPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeTransitionManager
-{
-public:
- QDeclarativeTransitionManager();
- ~QDeclarativeTransitionManager();
-
- bool isRunning() const;
-
- void transition(const QList<QDeclarativeAction> &, QDeclarativeTransition *transition, QObject *defaultTarget = 0);
-
- void cancel();
-
-protected:
- virtual void finished();
-
-private:
- Q_DISABLE_COPY(QDeclarativeTransitionManager)
- QDeclarativeTransitionManagerPrivate *d;
-
- void complete();
- void setState(QDeclarativeState *);
-
- friend class QDeclarativeState;
- friend class ParallelAnimationWrapper;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVETRANSITIONMANAGER_P_H
diff --git a/src/quick/util/qdeclarativeutilmodule.cpp b/src/quick/util/qdeclarativeutilmodule.cpp
deleted file mode 100644
index 02e4e9cf52..0000000000
--- a/src/quick/util/qdeclarativeutilmodule.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeutilmodule_p.h"
-#include "qdeclarativeanimation_p.h"
-#include "qdeclarativeanimation_p_p.h"
-#include "qdeclarativebehavior_p.h"
-#include "qdeclarativebind_p.h"
-#include "qdeclarativeconnections_p.h"
-#include "qdeclarativesmoothedanimation_p.h"
-#include "qdeclarativefontloader_p.h"
-#include "qdeclarativepackage_p.h"
-#include "qdeclarativepropertychanges_p.h"
-#include "qdeclarativespringanimation_p.h"
-#include "qdeclarativestategroup_p.h"
-#include "qdeclarativestateoperations_p.h"
-#include "qdeclarativestate_p.h"
-#include "qdeclarativestate_p_p.h"
-#include "qdeclarativesystempalette_p.h"
-#include "qdeclarativetimer_p.h"
-#include "qdeclarativetransition_p.h"
-#include <qdeclarativeinfo.h>
-#include <private/qdeclarativetypenotavailable_p.h>
-#include <private/qdeclarativeanimationcontroller_p.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtGui/QInputMethod>
-
-void QDeclarativeUtilModule::defineModule()
-{
- qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputPanel",
- QInputMethod::tr("InputPanel is an abstract class")); // deprecated
- qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputMethod",
- QInputMethod::tr("InputMethod is an abstract class"));
- qmlRegisterUncreatableType<QDeclarativeAbstractAnimation>("QtQuick",2,0,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class"));
-
- qmlRegisterType<QDeclarativeBehavior>("QtQuick",2,0,"Behavior");
- qmlRegisterType<QDeclarativeBind>("QtQuick",2,0,"Binding");
- qmlRegisterType<QDeclarativeColorAnimation>("QtQuick",2,0,"ColorAnimation");
- qmlRegisterType<QDeclarativeConnections>("QtQuick",2,0,"Connections");
- qmlRegisterType<QDeclarativeSmoothedAnimation>("QtQuick",2,0,"SmoothedAnimation");
- qmlRegisterType<QDeclarativeFontLoader>("QtQuick",2,0,"FontLoader");
- qmlRegisterType<QDeclarativeNumberAnimation>("QtQuick",2,0,"NumberAnimation");
- qmlRegisterType<QDeclarativePackage>("QtQuick",2,0,"Package");
- qmlRegisterType<QDeclarativeParallelAnimation>("QtQuick",2,0,"ParallelAnimation");
- qmlRegisterType<QDeclarativePauseAnimation>("QtQuick",2,0,"PauseAnimation");
- qmlRegisterType<QDeclarativePropertyAction>("QtQuick",2,0,"PropertyAction");
- qmlRegisterType<QDeclarativePropertyAnimation>("QtQuick",2,0,"PropertyAnimation");
- qmlRegisterType<QDeclarativeRotationAnimation>("QtQuick",2,0,"RotationAnimation");
- qmlRegisterType<QDeclarativeScriptAction>("QtQuick",2,0,"ScriptAction");
- qmlRegisterType<QDeclarativeSequentialAnimation>("QtQuick",2,0,"SequentialAnimation");
- qmlRegisterType<QDeclarativeSpringAnimation>("QtQuick",2,0,"SpringAnimation");
- qmlRegisterType<QDeclarativeAnimationController>("QtQuick",2,0,"AnimationController");
- qmlRegisterType<QDeclarativeStateChangeScript>("QtQuick",2,0,"StateChangeScript");
- qmlRegisterType<QDeclarativeStateGroup>("QtQuick",2,0,"StateGroup");
- qmlRegisterType<QDeclarativeState>("QtQuick",2,0,"State");
- qmlRegisterType<QDeclarativeSystemPalette>("QtQuick",2,0,"SystemPalette");
- qmlRegisterType<QDeclarativeTimer>("QtQuick",2,0,"Timer");
- qmlRegisterType<QDeclarativeTransition>("QtQuick",2,0,"Transition");
- qmlRegisterType<QDeclarativeVector3dAnimation>("QtQuick",2,0,"Vector3dAnimation");
-
- qmlRegisterType<QDeclarativeStateOperation>();
-
- qmlRegisterCustomType<QDeclarativePropertyChanges>("QtQuick",2,0,"PropertyChanges", new QDeclarativePropertyChangesParser);
- qmlRegisterCustomType<QDeclarativeConnections>("QtQuick",2,0,"Connections", new QDeclarativeConnectionsParser);
-}
diff --git a/src/quick/util/qdeclarativeutilmodule_p.h b/src/quick/util/qdeclarativeutilmodule_p.h
deleted file mode 100644
index 9d20077554..0000000000
--- a/src/quick/util/qdeclarativeutilmodule_p.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEUTILMODULE_H
-#define QDECLARATIVEUTILMODULE_H
-
-#include <qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeUtilModule
-{
-public:
- static void defineModule();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEUTILMODULE_H
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
new file mode 100644
index 0000000000..51b598b28d
--- /dev/null
+++ b/src/quick/util/qquickanimation.cpp
@@ -0,0 +1,2530 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickanimation_p.h"
+#include "qquickanimation_p_p.h"
+
+#include <private/qquickstatechangescript_p.h>
+#include <private/qqmlcontext_p.h>
+
+#include <qqmlpropertyvaluesource.h>
+#include <qqml.h>
+#include <qqmlinfo.h>
+#include <qqmlexpression.h>
+#include <private/qqmlstringconverters_p.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlengine_p.h>
+
+#include <qvariant.h>
+#include <qcolor.h>
+#include <qfile.h>
+#include "private/qparallelanimationgroupjob_p.h"
+#include "private/qsequentialanimationgroupjob_p.h"
+#include <QtCore/qset.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass Animation QQuickAbstractAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \brief The Animation element is the base of all QML animations.
+
+ The Animation element cannot be used directly in a QML file. It exists
+ to provide a set of common properties and methods, available across all the
+ other animation types that inherit from it. Attempting to use the Animation
+ element directly will result in an error.
+*/
+
+QQuickAbstractAnimation::QQuickAbstractAnimation(QObject *parent)
+: QObject(*(new QQuickAbstractAnimationPrivate), parent)
+{
+}
+
+QQuickAbstractAnimation::~QQuickAbstractAnimation()
+{
+ Q_D(QQuickAbstractAnimation);
+ delete d->animationInstance;
+}
+
+QQuickAbstractAnimation::QQuickAbstractAnimation(QQuickAbstractAnimationPrivate &dd, QObject *parent)
+: QObject(dd, parent)
+{
+}
+
+QAbstractAnimationJob* QQuickAbstractAnimation::qtAnimation()
+{
+ Q_D(QQuickAbstractAnimation);
+ return d->animationInstance;
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Animation::running
+ This property holds whether the animation is currently running.
+
+ The \c running property can be set to declaratively control whether or not
+ an animation is running. The following example will animate a rectangle
+ whenever the \l MouseArea is pressed.
+
+ \code
+ Rectangle {
+ width: 100; height: 100
+ NumberAnimation on x {
+ running: myMouse.pressed
+ from: 0; to: 100
+ }
+ MouseArea { id: myMouse }
+ }
+ \endcode
+
+ Likewise, the \c running property can be read to determine if the animation
+ is running. In the following example the text element will indicate whether
+ or not the animation is running.
+
+ \code
+ NumberAnimation { id: myAnimation }
+ Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" }
+ \endcode
+
+ Animations can also be started and stopped imperatively from JavaScript
+ using the \c start() and \c stop() methods.
+
+ By default, animations are not running. Though, when the animations are assigned to properties,
+ as property value sources using the \e on syntax, they are set to running by default.
+*/
+bool QQuickAbstractAnimation::isRunning() const
+{
+ Q_D(const QQuickAbstractAnimation);
+ return d->running;
+}
+
+// the behavior calls this function
+void QQuickAbstractAnimation::notifyRunningChanged(bool running)
+{
+ Q_D(QQuickAbstractAnimation);
+ if (d->disableUserControl && d->running != running) {
+ d->running = running;
+ emit runningChanged(running);
+ }
+}
+
+//commence is called to start an animation when it is used as a
+//simple animation, and not as part of a transition
+void QQuickAbstractAnimationPrivate::commence()
+{
+ Q_Q(QQuickAbstractAnimation);
+
+ QQuickStateActions actions;
+ QQmlProperties properties;
+
+ QAbstractAnimationJob *oldInstance = animationInstance;
+ animationInstance = q->transition(actions, properties, QQuickAbstractAnimation::Forward);
+ if (oldInstance != animationInstance) {
+ animationInstance->addAnimationChangeListener(this, QAbstractAnimationJob::Completion);
+ if (oldInstance)
+ delete oldInstance;
+ }
+ animationInstance->start();
+ if (animationInstance->isStopped()) {
+ running = false;
+ emit q->completed();
+ }
+}
+
+QQmlProperty QQuickAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj)
+{
+ QQmlProperty prop(obj, str, qmlContext(infoObj));
+ if (!prop.isValid()) {
+ qmlInfo(infoObj) << QQuickAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str);
+ return QQmlProperty();
+ } else if (!prop.isWritable()) {
+ qmlInfo(infoObj) << QQuickAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str);
+ return QQmlProperty();
+ }
+ return prop;
+}
+
+void QQuickAbstractAnimation::setRunning(bool r)
+{
+ Q_D(QQuickAbstractAnimation);
+ if (!d->componentComplete) {
+ d->running = r;
+ if (r == false)
+ d->avoidPropertyValueSourceStart = true;
+ else if (!d->registered) {
+ d->registered = true;
+ QQmlEnginePrivate *engPriv = QQmlEnginePrivate::get(qmlEngine(this));
+ static int finalizedIdx = -1;
+ if (finalizedIdx < 0)
+ finalizedIdx = metaObject()->indexOfSlot("componentFinalized()");
+ engPriv->registerFinalizeCallback(this, finalizedIdx);
+ }
+ return;
+ }
+
+ if (d->running == r)
+ return;
+
+ if (d->group || d->disableUserControl) {
+ qmlInfo(this) << "setRunning() cannot be used on non-root animation nodes.";
+ return;
+ }
+
+ d->running = r;
+ if (d->running) {
+ bool supressStart = false;
+ if (d->alwaysRunToEnd && d->loopCount != 1
+ && d->animationInstance && d->animationInstance->isRunning()) {
+ //we've restarted before the final loop finished; restore proper loop count
+ if (d->loopCount == -1)
+ d->animationInstance->setLoopCount(d->loopCount);
+ else
+ d->animationInstance->setLoopCount(d->animationInstance->currentLoop() + d->loopCount);
+ supressStart = true; //we want the animation to continue, rather than restart
+ }
+ if (!supressStart)
+ d->commence();
+ emit started();
+ } else {
+ if (d->animationInstance) {
+ if (d->alwaysRunToEnd) {
+ if (d->loopCount != 1)
+ d->animationInstance->setLoopCount(d->animationInstance->currentLoop()+1); //finish the current loop
+ } else {
+ d->animationInstance->stop();
+ }
+ }
+ emit completed();
+ }
+
+ emit runningChanged(d->running);
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Animation::paused
+ This property holds whether the animation is currently paused.
+
+ The \c paused property can be set to declaratively control whether or not
+ an animation is paused.
+
+ Animations can also be paused and resumed imperatively from JavaScript
+ using the \c pause() and \c resume() methods.
+
+ By default, animations are not paused.
+*/
+bool QQuickAbstractAnimation::isPaused() const
+{
+ Q_D(const QQuickAbstractAnimation);
+ return d->paused;
+}
+
+void QQuickAbstractAnimation::setPaused(bool p)
+{
+ Q_D(QQuickAbstractAnimation);
+ if (d->paused == p)
+ return;
+
+ if (d->group || d->disableUserControl) {
+ qmlInfo(this) << "setPaused() cannot be used on non-root animation nodes.";
+ return;
+ }
+
+ d->paused = p;
+
+ if (!d->componentComplete || !d->animationInstance)
+ return;
+
+ if (d->paused)
+ d->animationInstance->pause();
+ else
+ d->animationInstance->resume();
+
+ emit pausedChanged(d->paused);
+}
+
+void QQuickAbstractAnimation::classBegin()
+{
+ Q_D(QQuickAbstractAnimation);
+ d->componentComplete = false;
+}
+
+void QQuickAbstractAnimation::componentComplete()
+{
+ Q_D(QQuickAbstractAnimation);
+ d->componentComplete = true;
+}
+
+void QQuickAbstractAnimation::componentFinalized()
+{
+ Q_D(QQuickAbstractAnimation);
+ if (d->running) {
+ d->running = false;
+ setRunning(true);
+ }
+ if (d->paused) {
+ d->paused = false;
+ setPaused(true);
+ }
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Animation::alwaysRunToEnd
+ This property holds whether the animation should run to completion when it is stopped.
+
+ If this true the animation will complete its current iteration when it
+ is stopped - either by setting the \c running property to false, or by
+ calling the \c stop() method. The \c complete() method is not effected
+ by this value.
+
+ This behavior is most useful when the \c repeat property is set, as the
+ animation will finish playing normally but not restart.
+
+ By default, the alwaysRunToEnd property is not set.
+
+ \note alwaysRunToEnd has no effect on animations in a Transition.
+*/
+bool QQuickAbstractAnimation::alwaysRunToEnd() const
+{
+ Q_D(const QQuickAbstractAnimation);
+ return d->alwaysRunToEnd;
+}
+
+void QQuickAbstractAnimation::setAlwaysRunToEnd(bool f)
+{
+ Q_D(QQuickAbstractAnimation);
+ if (d->alwaysRunToEnd == f)
+ return;
+
+ d->alwaysRunToEnd = f;
+ emit alwaysRunToEndChanged(f);
+}
+
+/*!
+ \qmlproperty int QtQuick2::Animation::loops
+ This property holds the number of times the animation should play.
+
+ By default, \c loops is 1: the animation will play through once and then stop.
+
+ If set to Animation.Infinite, the animation will continuously repeat until it is explicitly
+ stopped - either by setting the \c running property to false, or by calling
+ the \c stop() method.
+
+ In the following example, the rectangle will spin indefinitely.
+
+ \code
+ Rectangle {
+ width: 100; height: 100; color: "green"
+ RotationAnimation on rotation {
+ loops: Animation.Infinite
+ from: 0
+ to: 360
+ }
+ }
+ \endcode
+*/
+int QQuickAbstractAnimation::loops() const
+{
+ Q_D(const QQuickAbstractAnimation);
+ return d->loopCount;
+}
+
+void QQuickAbstractAnimation::setLoops(int loops)
+{
+ Q_D(QQuickAbstractAnimation);
+ if (loops < 0)
+ loops = -1;
+
+ if (loops == d->loopCount)
+ return;
+
+ d->loopCount = loops;
+ emit loopCountChanged(loops);
+}
+
+int QQuickAbstractAnimation::duration() const
+{
+ Q_D(const QQuickAbstractAnimation);
+ return d->animationInstance ? d->animationInstance->duration() : 0;
+}
+
+int QQuickAbstractAnimation::currentTime()
+{
+ Q_D(QQuickAbstractAnimation);
+ return d->animationInstance ? d->animationInstance->currentLoopTime() : 0;
+}
+
+void QQuickAbstractAnimation::setCurrentTime(int time)
+{
+ Q_D(QQuickAbstractAnimation);
+ if (d->animationInstance)
+ d->animationInstance->setCurrentTime(time);
+ //TODO save value for start?
+}
+
+QQuickAnimationGroup *QQuickAbstractAnimation::group() const
+{
+ Q_D(const QQuickAbstractAnimation);
+ return d->group;
+}
+
+void QQuickAbstractAnimation::setGroup(QQuickAnimationGroup *g)
+{
+ Q_D(QQuickAbstractAnimation);
+ if (d->group == g)
+ return;
+ if (d->group)
+ static_cast<QQuickAnimationGroupPrivate *>(d->group->d_func())->animations.removeAll(this);
+
+ d->group = g;
+
+ if (d->group && !static_cast<QQuickAnimationGroupPrivate *>(d->group->d_func())->animations.contains(this))
+ static_cast<QQuickAnimationGroupPrivate *>(d->group->d_func())->animations.append(this);
+
+ //if (g) //if removed from a group, then the group should no longer be the parent
+ setParent(g);
+}
+
+/*!
+ \qmlmethod QtQuick2::Animation::start()
+ \brief Starts the animation.
+
+ If the animation is already running, calling this method has no effect. The
+ \c running property will be true following a call to \c start().
+*/
+void QQuickAbstractAnimation::start()
+{
+ setRunning(true);
+}
+
+/*!
+ \qmlmethod QtQuick2::Animation::pause()
+ \brief Pauses the animation.
+
+ If the animation is already paused, calling this method has no effect. The
+ \c paused property will be true following a call to \c pause().
+*/
+void QQuickAbstractAnimation::pause()
+{
+ setPaused(true);
+}
+
+/*!
+ \qmlmethod QtQuick2::Animation::resume()
+ \brief Resumes a paused animation.
+
+ If the animation is not paused, calling this method has no effect. The
+ \c paused property will be false following a call to \c resume().
+*/
+void QQuickAbstractAnimation::resume()
+{
+ setPaused(false);
+}
+
+/*!
+ \qmlmethod QtQuick2::Animation::stop()
+ \brief Stops the animation.
+
+ If the animation is not running, calling this method has no effect. The
+ \c running property will be false following a call to \c stop().
+
+ Normally \c stop() stops the animation immediately, and the animation has
+ no further influence on property values. In this example animation
+ \code
+ Rectangle {
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
+ }
+ \endcode
+ was stopped at time 250ms, the \c x property will have a value of 50.
+
+ However, if the \c alwaysRunToEnd property is set, the animation will
+ continue running until it completes and then stop. The \c running property
+ will still become false immediately.
+*/
+void QQuickAbstractAnimation::stop()
+{
+ setRunning(false);
+}
+
+/*!
+ \qmlmethod QtQuick2::Animation::restart()
+ \brief Restarts the animation.
+
+ This is a convenience method, and is equivalent to calling \c stop() and
+ then \c start().
+*/
+void QQuickAbstractAnimation::restart()
+{
+ stop();
+ start();
+}
+
+/*!
+ \qmlmethod QtQuick2::Animation::complete()
+ \brief Stops the animation, jumping to the final property values.
+
+ If the animation is not running, calling this method has no effect. The
+ \c running property will be false following a call to \c complete().
+
+ Unlike \c stop(), \c complete() immediately fast-forwards the animation to
+ its end. In the following example,
+ \code
+ Rectangle {
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
+ }
+ \endcode
+ calling \c stop() at time 250ms will result in the \c x property having
+ a value of 50, while calling \c complete() will set the \c x property to
+ 100, exactly as though the animation had played the whole way through.
+*/
+void QQuickAbstractAnimation::complete()
+{
+ Q_D(QQuickAbstractAnimation);
+ if (isRunning() && d->animationInstance) {
+ d->animationInstance->setCurrentTime(d->animationInstance->duration());
+ }
+}
+
+void QQuickAbstractAnimation::setTarget(const QQmlProperty &p)
+{
+ Q_D(QQuickAbstractAnimation);
+ d->defaultProperty = p;
+
+ if (!d->avoidPropertyValueSourceStart)
+ setRunning(true);
+}
+
+/*
+ we rely on setTarget only being called when used as a value source
+ so this function allows us to do the same thing as setTarget without
+ that assumption
+*/
+void QQuickAbstractAnimation::setDefaultTarget(const QQmlProperty &p)
+{
+ Q_D(QQuickAbstractAnimation);
+ d->defaultProperty = p;
+}
+
+/*
+ don't allow start/stop/pause/resume to be manually invoked,
+ because something else (like a Behavior) already has control
+ over the animation.
+*/
+void QQuickAbstractAnimation::setDisableUserControl()
+{
+ Q_D(QQuickAbstractAnimation);
+ d->disableUserControl = true;
+}
+
+void QQuickAbstractAnimation::setEnableUserControl()
+{
+ Q_D(QQuickAbstractAnimation);
+ d->disableUserControl = false;
+
+}
+
+bool QQuickAbstractAnimation::userControlDisabled() const
+{
+ Q_D(const QQuickAbstractAnimation);
+ return d->disableUserControl;
+}
+
+QAbstractAnimationJob* QQuickAbstractAnimation::initInstance(QAbstractAnimationJob *animation)
+{
+ Q_D(QQuickAbstractAnimation);
+ animation->setLoopCount(d->loopCount);
+ return animation;
+}
+
+QAbstractAnimationJob* QQuickAbstractAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_UNUSED(actions);
+ Q_UNUSED(modified);
+ Q_UNUSED(direction);
+ Q_UNUSED(defaultTarget);
+ return 0;
+}
+
+void QQuickAbstractAnimationPrivate::animationFinished(QAbstractAnimationJob*)
+{
+ Q_Q(QQuickAbstractAnimation);
+ q->setRunning(false);
+ if (alwaysRunToEnd && loopCount != 1) {
+ //restore the proper loopCount for the next run
+ animationInstance->setLoopCount(loopCount);
+ }
+}
+
+/*!
+ \qmlclass PauseAnimation QQuickPauseAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits Animation
+ \brief The PauseAnimation element provides a pause for an animation.
+
+ When used in a SequentialAnimation, PauseAnimation is a step when
+ nothing happens, for a specified duration.
+
+ A 500ms animation sequence, with a 100ms pause between two animations:
+ \code
+ SequentialAnimation {
+ NumberAnimation { ... duration: 200 }
+ PauseAnimation { duration: 100 }
+ NumberAnimation { ... duration: 200 }
+ }
+ \endcode
+
+ \sa {QML Animation and Transitions}, {qml/animation/basics}{Animation basics example}
+*/
+QQuickPauseAnimation::QQuickPauseAnimation(QObject *parent)
+: QQuickAbstractAnimation(*(new QQuickPauseAnimationPrivate), parent)
+{
+}
+
+QQuickPauseAnimation::~QQuickPauseAnimation()
+{
+}
+
+/*!
+ \qmlproperty int QtQuick2::PauseAnimation::duration
+ This property holds the duration of the pause in milliseconds
+
+ The default value is 250.
+*/
+int QQuickPauseAnimation::duration() const
+{
+ Q_D(const QQuickPauseAnimation);
+ return d->duration;
+}
+
+void QQuickPauseAnimation::setDuration(int duration)
+{
+ if (duration < 0) {
+ qmlInfo(this) << tr("Cannot set a duration of < 0");
+ return;
+ }
+
+ Q_D(QQuickPauseAnimation);
+ if (d->duration == duration)
+ return;
+ d->duration = duration;
+ emit durationChanged(duration);
+}
+
+QAbstractAnimationJob* QQuickPauseAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickPauseAnimation);
+ Q_UNUSED(actions);
+ Q_UNUSED(modified);
+ Q_UNUSED(direction);
+ Q_UNUSED(defaultTarget);
+
+ return initInstance(new QPauseAnimationJob(d->duration));
+}
+
+/*!
+ \qmlclass ColorAnimation QQuickColorAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits PropertyAnimation
+ \brief The ColorAnimation element animates changes in color values.
+
+ 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. It animates the \c color property's value from
+ its current value to a value of "red", over 1000 milliseconds:
+
+ \snippet doc/src/snippets/qml/coloranimation.qml 0
+
+ Like any other animation element, a ColorAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ For convenience, when a ColorAnimation is used in a \l Transition, it will
+ animate any \c color properties that have been modified during the state
+ change. If a \l{PropertyAnimation::}{property} or
+ \l{PropertyAnimation::}{properties} are explicitly set for the animation,
+ then those are used instead.
+
+ \sa {QML Animation and Transitions}, {qml/animation/basics}{Animation basics example}
+*/
+QQuickColorAnimation::QQuickColorAnimation(QObject *parent)
+: QQuickPropertyAnimation(parent)
+{
+ Q_D(QQuickPropertyAnimation);
+ d->interpolatorType = QMetaType::QColor;
+ d->defaultToInterpolatorType = true;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+}
+
+QQuickColorAnimation::~QQuickColorAnimation()
+{
+}
+
+/*!
+ \qmlproperty color QtQuick2::ColorAnimation::from
+ 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: [
+ // States are defined here...
+ ]
+
+ transition: Transition {
+ ColorAnimation { from: "#c0c0c0"; duration: 2000 }
+ }
+ }
+ \endqml
+
+ If the ColorAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the starting state of the
+ \l Transition, or the current value of the property at the moment the
+ \l Behavior is triggered.
+
+ \sa {QML Animation and Transitions}
+*/
+QColor QQuickColorAnimation::from() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->from.value<QColor>();
+}
+
+void QQuickColorAnimation::setFrom(const QColor &f)
+{
+ QQuickPropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty color QtQuick2::ColorAnimation::to
+
+ This property holds the color value at which the animation should end.
+
+ If the ColorAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the end state of the
+ \l Transition, or the value of the property change that triggered the
+ \l Behavior.
+
+ \sa {QML Animation and Transitions}
+*/
+QColor QQuickColorAnimation::to() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->to.value<QColor>();
+}
+
+void QQuickColorAnimation::setTo(const QColor &t)
+{
+ QQuickPropertyAnimation::setTo(t);
+}
+
+QActionAnimation::QActionAnimation()
+ : QAbstractAnimationJob(), animAction(0)
+{
+}
+
+QActionAnimation::QActionAnimation(QAbstractAnimationAction *action)
+ : QAbstractAnimationJob(), animAction(action)
+{
+}
+
+QActionAnimation::~QActionAnimation()
+{
+ delete animAction;
+}
+
+int QActionAnimation::duration() const
+{
+ return 0;
+}
+
+void QActionAnimation::setAnimAction(QAbstractAnimationAction *action)
+{
+ if (isRunning())
+ stop();
+ animAction = action;
+}
+
+void QActionAnimation::updateCurrentTime(int)
+{
+}
+
+void QActionAnimation::updateState(State newState, State oldState)
+{
+ Q_UNUSED(oldState);
+
+ if (newState == Running) {
+ if (animAction) {
+ animAction->doAction();
+ }
+ }
+}
+
+/*!
+ \qmlclass ScriptAction QQuickScriptAction
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits Animation
+ \brief The ScriptAction element allows scripts to be run during an animation.
+
+ ScriptAction can be used to run a script at a specific point in an animation.
+
+ \qml
+ SequentialAnimation {
+ NumberAnimation {
+ // ...
+ }
+ ScriptAction { script: doSomething(); }
+ NumberAnimation {
+ // ...
+ }
+ }
+ \endqml
+
+ When used as part of a Transition, you can also target a specific
+ StateChangeScript to run using the \c scriptName property.
+
+ \snippet doc/src/snippets/qml/states/statechangescript.qml state and transition
+
+ \sa StateChangeScript
+*/
+QQuickScriptAction::QQuickScriptAction(QObject *parent)
+ :QQuickAbstractAnimation(*(new QQuickScriptActionPrivate), parent)
+{
+}
+
+QQuickScriptAction::~QQuickScriptAction()
+{
+}
+
+QQuickScriptActionPrivate::QQuickScriptActionPrivate()
+ : QQuickAbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false){}
+
+/*!
+ \qmlproperty script QtQuick2::ScriptAction::script
+ This property holds the script to run.
+*/
+QQmlScriptString QQuickScriptAction::script() const
+{
+ Q_D(const QQuickScriptAction);
+ return d->script;
+}
+
+void QQuickScriptAction::setScript(const QQmlScriptString &script)
+{
+ Q_D(QQuickScriptAction);
+ d->script = script;
+}
+
+/*!
+ \qmlproperty string QtQuick2::ScriptAction::scriptName
+ This property holds the the name of the StateChangeScript to run.
+
+ This property is only valid when ScriptAction is used as part of a transition.
+ If both script and scriptName are set, scriptName will be used.
+
+ \note When using scriptName in a reversible transition, the script will only
+ be run when the transition is being run forwards.
+*/
+QString QQuickScriptAction::stateChangeScriptName() const
+{
+ Q_D(const QQuickScriptAction);
+ return d->name;
+}
+
+void QQuickScriptAction::setStateChangeScriptName(const QString &name)
+{
+ Q_D(QQuickScriptAction);
+ d->name = name;
+}
+
+QAbstractAnimationAction* QQuickScriptActionPrivate::createAction()
+{
+ return new Proxy(this);
+}
+
+void QQuickScriptActionPrivate::execute()
+{
+ Q_Q(QQuickScriptAction);
+ if (hasRunScriptScript && reversing)
+ return;
+
+ QQmlScriptString scriptStr = hasRunScriptScript ? runScriptScript : script;
+
+ if (!scriptStr.script().isEmpty()) {
+ QQmlExpression expr(scriptStr);
+ expr.evaluate();
+ if (expr.hasError())
+ qmlInfo(q) << expr.error();
+ }
+}
+
+QAbstractAnimationJob* QQuickScriptAction::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickScriptAction);
+ Q_UNUSED(modified);
+ Q_UNUSED(defaultTarget);
+
+ d->hasRunScriptScript = false;
+ d->reversing = (direction == Backward);
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QQuickAction &action = actions[ii];
+
+ if (action.event && action.event->type() == QQuickActionEvent::Script
+ && static_cast<QQuickStateChangeScript*>(action.event)->name() == d->name) {
+ d->runScriptScript = static_cast<QQuickStateChangeScript*>(action.event)->script();
+ d->hasRunScriptScript = true;
+ action.actionDone = true;
+ break; //only match one (names should be unique)
+ }
+ }
+ return initInstance(new QActionAnimation(d->createAction()));
+}
+
+/*!
+ \qmlclass PropertyAction QQuickPropertyAction
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits Animation
+ \brief The PropertyAction element allows immediate property changes during animation.
+
+ PropertyAction is used to specify an immediate property change during an
+ animation. The property change is not animated.
+
+ It is useful for setting non-animated property values during an animation.
+
+ For example, here is a SequentialAnimation that sets the image's
+ \l {Image::}{smooth} property to \c true, animates the width of the image,
+ then sets \l {Image::}{smooth} back to \c false:
+
+ \snippet doc/src/snippets/qml/propertyaction.qml standalone
+
+ PropertyAction is also useful for setting the exact point at which a property
+ change should occur during a \l Transition. For example, if PropertyChanges
+ was used in a \l State to rotate an item around a particular
+ \l {Item::}{transformOrigin}, it might be implemented like this:
+
+ \snippet doc/src/snippets/qml/propertyaction.qml transition
+
+ However, with this code, the \c transformOrigin is not set until \e after
+ the animation, as a \l State is taken to define the values at the \e end of
+ a transition. The animation would rotate at the default \c transformOrigin,
+ then jump to \c Item.BottomRight. To fix this, insert a PropertyAction
+ before the RotationAnimation begins:
+
+ \snippet doc/src/snippets/qml/propertyaction-sequential.qml sequential
+
+ This immediately sets the \c transformOrigin property to the value defined
+ in the end state of the \l Transition (i.e. the value defined in the
+ PropertyAction object) so that the rotation animation begins with the
+ correct transform origin.
+
+ \sa {QML Animation and Transitions}, QtQml
+*/
+QQuickPropertyAction::QQuickPropertyAction(QObject *parent)
+: QQuickAbstractAnimation(*(new QQuickPropertyActionPrivate), parent)
+{
+}
+
+QQuickPropertyAction::~QQuickPropertyAction()
+{
+}
+
+QObject *QQuickPropertyAction::target() const
+{
+ Q_D(const QQuickPropertyAction);
+ return d->target;
+}
+
+void QQuickPropertyAction::setTargetObject(QObject *o)
+{
+ Q_D(QQuickPropertyAction);
+ if (d->target == o)
+ return;
+ d->target = o;
+ emit targetChanged();
+}
+
+QString QQuickPropertyAction::property() const
+{
+ Q_D(const QQuickPropertyAction);
+ return d->propertyName;
+}
+
+void QQuickPropertyAction::setProperty(const QString &n)
+{
+ Q_D(QQuickPropertyAction);
+ if (d->propertyName == n)
+ return;
+ d->propertyName = n;
+ emit propertyChanged();
+}
+
+/*!
+ \qmlproperty Object QtQuick2::PropertyAction::target
+ \qmlproperty list<Object> QtQuick2::PropertyAction::targets
+ \qmlproperty string QtQuick2::PropertyAction::property
+ \qmlproperty string QtQuick2::PropertyAction::properties
+
+ 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
+ is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
+ documentation.
+
+ \sa exclude
+*/
+QString QQuickPropertyAction::properties() const
+{
+ Q_D(const QQuickPropertyAction);
+ return d->properties;
+}
+
+void QQuickPropertyAction::setProperties(const QString &p)
+{
+ Q_D(QQuickPropertyAction);
+ if (d->properties == p)
+ return;
+ d->properties = p;
+ emit propertiesChanged(p);
+}
+
+QQmlListProperty<QObject> QQuickPropertyAction::targets()
+{
+ Q_D(QQuickPropertyAction);
+ return QQmlListProperty<QObject>(this, d->targets);
+}
+
+/*!
+ \qmlproperty list<Object> QtQuick2::PropertyAction::exclude
+ This property holds the objects that should not be affected by this action.
+
+ \sa targets
+*/
+QQmlListProperty<QObject> QQuickPropertyAction::exclude()
+{
+ Q_D(QQuickPropertyAction);
+ return QQmlListProperty<QObject>(this, d->exclude);
+}
+
+/*!
+ \qmlproperty any QtQuick2::PropertyAction::value
+ This property holds the value to be set on the property.
+
+ If the PropertyAction is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the end state of the
+ \l Transition, or the value of the property change that triggered the
+ \l Behavior.
+*/
+QVariant QQuickPropertyAction::value() const
+{
+ Q_D(const QQuickPropertyAction);
+ return d->value;
+}
+
+void QQuickPropertyAction::setValue(const QVariant &v)
+{
+ Q_D(QQuickPropertyAction);
+ if (d->value.isNull || d->value != v) {
+ d->value = v;
+ emit valueChanged(v);
+ }
+}
+
+QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickPropertyAction);
+ Q_UNUSED(direction);
+
+ struct QQuickSetPropertyAnimationAction : public QAbstractAnimationAction
+ {
+ QQuickStateActions actions;
+ virtual void doAction()
+ {
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ const QQuickAction &action = actions.at(ii);
+ QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
+ }
+ }
+ };
+
+ QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
+ for (int ii = 0; ii < props.count(); ++ii)
+ props[ii] = props.at(ii).trimmed();
+ if (!d->propertyName.isEmpty())
+ props << d->propertyName;
+
+ QList<QObject*> targets = d->targets;
+ if (d->target)
+ targets.append(d->target);
+
+ bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
+
+ if (d->defaultProperty.isValid() && !hasSelectors) {
+ props << d->defaultProperty.name();
+ targets << d->defaultProperty.object();
+ }
+
+ if (defaultTarget && targets.isEmpty())
+ targets << defaultTarget;
+
+ QQuickSetPropertyAnimationAction *data = new QQuickSetPropertyAnimationAction;
+
+ bool hasExplicit = false;
+ //an explicit animation has been specified
+ if (d->value.isValid()) {
+ for (int i = 0; i < props.count(); ++i) {
+ for (int j = 0; j < targets.count(); ++j) {
+ QQuickAction myAction;
+ myAction.property = d->createProperty(targets.at(j), props.at(i), this);
+ if (myAction.property.isValid()) {
+ myAction.toValue = d->value;
+ QQuickPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
+ data->actions << myAction;
+ hasExplicit = true;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QQuickAction &action = actions[ii];
+ if (action.property.object() == myAction.property.object() &&
+ myAction.property.name() == action.property.name()) {
+ modified << action.property;
+ break; //### any chance there could be multiples?
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!hasExplicit)
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QQuickAction &action = actions[ii];
+
+ QObject *obj = action.property.object();
+ QString propertyName = action.property.name();
+ QObject *sObj = action.specifiedObject;
+ QString sPropertyName = action.specifiedProperty;
+ bool same = (obj == sObj);
+
+ if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
+ (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) {
+ QQuickAction myAction = action;
+
+ if (d->value.isValid())
+ myAction.toValue = d->value;
+ QQuickPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
+
+ modified << action.property;
+ data->actions << myAction;
+ action.fromValue = myAction.toValue;
+ }
+ }
+
+ QActionAnimation *action = new QActionAnimation;
+ if (data->actions.count()) {
+ action->setAnimAction(data);
+ } else {
+ delete data;
+ }
+ return initInstance(action);
+}
+
+/*!
+ \qmlclass NumberAnimation QQuickNumberAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits PropertyAnimation
+ \brief The NumberAnimation element animates changes in qreal-type values.
+
+ 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. It animates the \c x value from its current
+ value to a value of 50, over 1000 milliseconds:
+
+ \snippet doc/src/snippets/qml/numberanimation.qml 0
+
+ Like any other animation element, a NumberAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ Note that NumberAnimation may not animate smoothly if there are irregular
+ changes in the number value that it is tracking. If this is the case, use
+ SmoothedAnimation instead.
+
+ \sa {QML Animation and Transitions}, {qml/animation/basics}{Animation basics example}
+*/
+QQuickNumberAnimation::QQuickNumberAnimation(QObject *parent)
+: QQuickPropertyAnimation(parent)
+{
+ init();
+}
+
+QQuickNumberAnimation::QQuickNumberAnimation(QQuickPropertyAnimationPrivate &dd, QObject *parent)
+: QQuickPropertyAnimation(dd, parent)
+{
+ init();
+}
+
+QQuickNumberAnimation::~QQuickNumberAnimation()
+{
+}
+
+void QQuickNumberAnimation::init()
+{
+ Q_D(QQuickPropertyAnimation);
+ d->interpolatorType = QMetaType::QReal;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+}
+
+/*!
+ \qmlproperty real QtQuick2::NumberAnimation::from
+ This property holds the starting value for the animation.
+
+ For example, the following animation is not applied until the \c x value
+ has reached 100:
+
+ \qml
+ Item {
+ states: [
+ // ...
+ ]
+
+ transition: Transition {
+ NumberAnimation { properties: "x"; from: 100; duration: 200 }
+ }
+ }
+ \endqml
+
+ If the NumberAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the starting state of the
+ \l Transition, or the current value of the property at the moment the
+ \l Behavior is triggered.
+
+ \sa {QML Animation and Transitions}
+*/
+
+qreal QQuickNumberAnimation::from() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->from.toReal();
+}
+
+void QQuickNumberAnimation::setFrom(qreal f)
+{
+ QQuickPropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real QtQuick2::NumberAnimation::to
+ This property holds the end value for the animation.
+
+ If the NumberAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the end state of the
+ \l Transition, or the value of the property change that triggered the
+ \l Behavior.
+
+ \sa {QML Animation and Transitions}
+*/
+qreal QQuickNumberAnimation::to() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->to.toReal();
+}
+
+void QQuickNumberAnimation::setTo(qreal t)
+{
+ QQuickPropertyAnimation::setTo(t);
+}
+
+
+
+/*!
+ \qmlclass Vector3dAnimation QQuickVector3dAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits PropertyAnimation
+ \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.
+
+ Like any other animation element, a Vector3dAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ \sa {QML Animation and Transitions}, {qml/animation/basics}{Animation basics example}
+*/
+QQuickVector3dAnimation::QQuickVector3dAnimation(QObject *parent)
+: QQuickPropertyAnimation(parent)
+{
+ Q_D(QQuickPropertyAnimation);
+ d->interpolatorType = QMetaType::QVector3D;
+ d->defaultToInterpolatorType = true;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+}
+
+QQuickVector3dAnimation::~QQuickVector3dAnimation()
+{
+}
+
+/*!
+ \qmlproperty real QtQuick2::Vector3dAnimation::from
+ This property holds the starting value for the animation.
+
+ If the Vector3dAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the starting state of the
+ \l Transition, or the current value of the property at the moment the
+ \l Behavior is triggered.
+
+ \sa {QML Animation and Transitions}
+*/
+QVector3D QQuickVector3dAnimation::from() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->from.value<QVector3D>();
+}
+
+void QQuickVector3dAnimation::setFrom(QVector3D f)
+{
+ QQuickPropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real QtQuick2::Vector3dAnimation::to
+ This property holds the end value for the animation.
+
+ If the Vector3dAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the end state of the
+ \l Transition, or the value of the property change that triggered the
+ \l Behavior.
+
+ \sa {QML Animation and Transitions}
+*/
+QVector3D QQuickVector3dAnimation::to() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->to.value<QVector3D>();
+}
+
+void QQuickVector3dAnimation::setTo(QVector3D t)
+{
+ QQuickPropertyAnimation::setTo(t);
+}
+
+
+
+/*!
+ \qmlclass RotationAnimation QQuickRotationAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits PropertyAnimation
+ \brief The RotationAnimation element animates changes in rotation values.
+
+ RotationAnimation is a specialized PropertyAnimation that gives control
+ 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 240 degrees
+ clockwise, while a rotation from 240 to 0 will rotate 240 degrees
+ 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:
+
+ \snippet doc/src/snippets/qml/rotationanimation.qml 0
+
+ Notice the RotationAnimation did not need to set a \l 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}.
+
+ Also, note the \l Rectangle will be rotated around its default
+ \l {Item::}{transformOrigin} (which is \c Item.Center). To use a different
+ transform origin, set the origin in the PropertyChanges object and apply
+ the change at the start of the animation using PropertyAction. See the
+ PropertyAction documentation for more details.
+
+ Like any other animation element, a RotationAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ \sa {QML Animation and Transitions}, {qml/animation/basics}{Animation basics example}
+*/
+QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff > 180.0){
+ newt -= 360.0;
+ diff -= 360.0;
+ }
+ while(diff < -180.0){
+ newt += 360.0;
+ diff += 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff < 0.0){
+ newt += 360.0;
+ diff += 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff > 0.0){
+ newt -= 360.0;
+ diff -= 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QQuickRotationAnimation::QQuickRotationAnimation(QObject *parent)
+: QQuickPropertyAnimation(*(new QQuickRotationAnimationPrivate), parent)
+{
+ Q_D(QQuickRotationAnimation);
+ d->interpolatorType = QMetaType::QReal;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ d->defaultProperties = QLatin1String("rotation,angle");
+}
+
+QQuickRotationAnimation::~QQuickRotationAnimation()
+{
+}
+
+/*!
+ \qmlproperty real QtQuick2::RotationAnimation::from
+ This property holds the starting value for the animation.
+
+ For example, the following animation is not applied until the \c angle value
+ has reached 100:
+
+ \qml
+ Item {
+ states: [
+ // ...
+ ]
+
+ transition: Transition {
+ RotationAnimation { properties: "angle"; from: 100; duration: 2000 }
+ }
+ }
+ \endqml
+
+ If the RotationAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the starting state of the
+ \l Transition, or the current value of the property at the moment the
+ \l Behavior is triggered.
+
+ \sa {QML Animation and Transitions}
+*/
+qreal QQuickRotationAnimation::from() const
+{
+ Q_D(const QQuickRotationAnimation);
+ return d->from.toReal();
+}
+
+void QQuickRotationAnimation::setFrom(qreal f)
+{
+ QQuickPropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real QtQuick2::RotationAnimation::to
+ This property holds the end value for the animation..
+
+ If the RotationAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the end state of the
+ \l Transition, or the value of the property change that triggered the
+ \l Behavior.
+
+ \sa {QML Animation and Transitions}
+*/
+qreal QQuickRotationAnimation::to() const
+{
+ Q_D(const QQuickRotationAnimation);
+ return d->to.toReal();
+}
+
+void QQuickRotationAnimation::setTo(qreal t)
+{
+ QQuickPropertyAnimation::setTo(t);
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::RotationAnimation::direction
+ This property holds the direction of the rotation.
+
+ Possible values are:
+
+ \list
+ \o RotationAnimation.Numerical (default) - Rotate by linearly interpolating between the two numbers.
+ A rotation from 10 to 350 will rotate 340 degrees clockwise.
+ \o RotationAnimation.Clockwise - Rotate clockwise between the two values
+ \o RotationAnimation.Counterclockwise - Rotate counterclockwise between the two values
+ \o RotationAnimation.Shortest - Rotate in the direction that produces the shortest animation path.
+ A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
+ \endlist
+*/
+QQuickRotationAnimation::RotationDirection QQuickRotationAnimation::direction() const
+{
+ Q_D(const QQuickRotationAnimation);
+ return d->direction;
+}
+
+void QQuickRotationAnimation::setDirection(QQuickRotationAnimation::RotationDirection direction)
+{
+ Q_D(QQuickRotationAnimation);
+ if (d->direction == direction)
+ return;
+
+ d->direction = direction;
+ switch(d->direction) {
+ case Clockwise:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation);
+ break;
+ case Counterclockwise:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation);
+ break;
+ case Shortest:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ break;
+ default:
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ break;
+ }
+ emit directionChanged();
+}
+
+
+
+QQuickAnimationGroup::QQuickAnimationGroup(QObject *parent)
+: QQuickAbstractAnimation(*(new QQuickAnimationGroupPrivate), parent)
+{
+}
+
+QQuickAnimationGroup::QQuickAnimationGroup(QQuickAnimationGroupPrivate &dd, QObject *parent)
+ : QQuickAbstractAnimation(dd, parent)
+{
+}
+
+void QQuickAnimationGroupPrivate::append_animation(QQmlListProperty<QQuickAbstractAnimation> *list, QQuickAbstractAnimation *a)
+{
+ QQuickAnimationGroup *q = qobject_cast<QQuickAnimationGroup *>(list->object);
+ if (q) {
+ a->setGroup(q);
+ }
+}
+
+void QQuickAnimationGroupPrivate::clear_animation(QQmlListProperty<QQuickAbstractAnimation> *list)
+{
+ QQuickAnimationGroup *q = qobject_cast<QQuickAnimationGroup *>(list->object);
+ if (q) {
+ while (q->d_func()->animations.count()) {
+ QQuickAbstractAnimation *firstAnim = q->d_func()->animations.at(0);
+ firstAnim->setGroup(0);
+ }
+ }
+}
+
+QQuickAnimationGroup::~QQuickAnimationGroup()
+{
+}
+
+QQmlListProperty<QQuickAbstractAnimation> QQuickAnimationGroup::animations()
+{
+ Q_D(QQuickAnimationGroup);
+ QQmlListProperty<QQuickAbstractAnimation> list(this, d->animations);
+ list.append = &QQuickAnimationGroupPrivate::append_animation;
+ list.clear = &QQuickAnimationGroupPrivate::clear_animation;
+ return list;
+}
+
+/*!
+ \qmlclass SequentialAnimation QQuickSequentialAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits Animation
+ \brief The SequentialAnimation element allows animations to be run sequentially.
+
+ 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 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.
+
+ \snippet doc/src/snippets/qml/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 {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ \note Once an animation has been grouped into a SequentialAnimation or
+ ParallelAnimation, it cannot be individually started and stopped; the
+ SequentialAnimation or ParallelAnimation must be started and stopped as a group.
+
+ \sa ParallelAnimation, {QML Animation and Transitions}, {qml/animation/basics}{Animation basics example}
+*/
+
+QQuickSequentialAnimation::QQuickSequentialAnimation(QObject *parent) :
+ QQuickAnimationGroup(parent)
+{
+}
+
+QQuickSequentialAnimation::~QQuickSequentialAnimation()
+{
+}
+
+QAbstractAnimationJob* QQuickSequentialAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickAnimationGroup);
+
+ QSequentialAnimationGroupJob *ag = new QSequentialAnimationGroupJob;
+
+ int inc = 1;
+ int from = 0;
+ if (direction == Backward) {
+ inc = -1;
+ from = d->animations.count() - 1;
+ }
+
+ bool valid = d->defaultProperty.isValid();
+ QAbstractAnimationJob* anim;
+ for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
+ anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
+ inc == -1 ? ag->prependAnimation(anim) : ag->appendAnimation(anim);
+ }
+
+ return initInstance(ag);
+}
+
+
+
+/*!
+ \qmlclass ParallelAnimation QQuickParallelAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits Animation
+ \brief The ParallelAnimation element allows animations to be run in parallel.
+
+ 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 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.
+
+ \snippet doc/src/snippets/qml/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 {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ \note Once an animation has been grouped into a SequentialAnimation or
+ ParallelAnimation, it cannot be individually started and stopped; the
+ SequentialAnimation or ParallelAnimation must be started and stopped as a group.
+
+ \sa SequentialAnimation, {QML Animation and Transitions}, {qml/animation/basics}{Animation basics example}
+*/
+QQuickParallelAnimation::QQuickParallelAnimation(QObject *parent) :
+ QQuickAnimationGroup(parent)
+{
+}
+
+QQuickParallelAnimation::~QQuickParallelAnimation()
+{
+}
+
+QAbstractAnimationJob* QQuickParallelAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickAnimationGroup);
+ QParallelAnimationGroupJob *ag = new QParallelAnimationGroupJob;
+
+ bool valid = d->defaultProperty.isValid();
+ QAbstractAnimationJob* anim;
+ for (int ii = 0; ii < d->animations.count(); ++ii) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
+ anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
+ ag->appendAnimation(anim);
+ }
+ return initInstance(ag);
+}
+
+//convert a variant from string type to another animatable type
+void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
+{
+ if (variant.userType() != QVariant::String) {
+ variant.convert((QVariant::Type)type);
+ return;
+ }
+
+ switch (type) {
+ case QVariant::Rect: {
+ variant.setValue(QQmlStringConverters::rectFFromString(variant.toString()).toRect());
+ break;
+ }
+ case QVariant::RectF: {
+ variant.setValue(QQmlStringConverters::rectFFromString(variant.toString()));
+ break;
+ }
+ case QVariant::Point: {
+ variant.setValue(QQmlStringConverters::pointFFromString(variant.toString()).toPoint());
+ break;
+ }
+ case QVariant::PointF: {
+ variant.setValue(QQmlStringConverters::pointFFromString(variant.toString()));
+ break;
+ }
+ case QVariant::Size: {
+ variant.setValue(QQmlStringConverters::sizeFFromString(variant.toString()).toSize());
+ break;
+ }
+ case QVariant::SizeF: {
+ variant.setValue(QQmlStringConverters::sizeFFromString(variant.toString()));
+ break;
+ }
+ case QVariant::Color: {
+ variant.setValue(QQmlStringConverters::colorFromString(variant.toString()));
+ break;
+ }
+ case QVariant::Vector3D: {
+ variant.setValue(QQmlStringConverters::vector3DFromString(variant.toString()));
+ break;
+ }
+ default:
+ if (QQmlValueTypeFactory::isValueType((uint)type)) {
+ variant.convert((QVariant::Type)type);
+ } else {
+ QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(type);
+ if (converter)
+ variant = converter(variant.toString());
+ }
+ break;
+ }
+}
+
+QQuickBulkValueAnimator::QQuickBulkValueAnimator()
+ : QAbstractAnimationJob(), animValue(0), fromSourced(0), m_duration(250)
+{
+}
+
+QQuickBulkValueAnimator::~QQuickBulkValueAnimator()
+{
+ delete animValue;
+}
+
+void QQuickBulkValueAnimator::setAnimValue(QQuickBulkValueUpdater *value)
+{
+ if (isRunning())
+ stop();
+ animValue = value;
+}
+
+void QQuickBulkValueAnimator::updateCurrentTime(int currentTime)
+{
+ if (isStopped())
+ return;
+
+ const qreal progress = easing.valueForProgress(((m_duration == 0) ? qreal(1) : qreal(currentTime) / qreal(m_duration)));
+
+ if (animValue)
+ animValue->setValue(progress);
+}
+
+void QQuickBulkValueAnimator::topLevelAnimationLoopChanged()
+{
+ //check for new from every top-level loop (when the top level animation is started and all subsequent loops)
+ if (fromSourced)
+ *fromSourced = false;
+}
+
+/*!
+ \qmlclass PropertyAnimation QQuickPropertyAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits Animation
+ \brief The PropertyAnimation element animates changes in property values.
+
+ PropertyAnimation provides a way to animate changes to a property's value.
+
+ It can be used to define animations in a number of ways:
+
+ \list
+ \o In a \l Transition
+
+ For example, to animate any objects that have changed their \c x or \c y properties
+ as a result of a state change, using an \c InOutQuad easing curve:
+
+ \snippet doc/src/snippets/qml/propertyanimation.qml transition
+
+
+ \o In a \l Behavior
+
+ For example, to animate all changes to a rectangle's \c x property:
+
+ \snippet doc/src/snippets/qml/propertyanimation.qml behavior
+
+
+ \o As a property value source
+
+ For example, to repeatedly animate the rectangle's \c x property:
+
+ \snippet doc/src/snippets/qml/propertyanimation.qml propertyvaluesource
+
+
+ \o In a signal handler
+
+ For example, to fade out \c theObject when clicked:
+ \qml
+ MouseArea {
+ anchors.fill: theObject
+ onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
+ }
+ \endqml
+
+ \o Standalone
+
+ For example, to animate \c rect's \c width property over 500ms, from its current width to 30:
+
+ \snippet doc/src/snippets/qml/propertyanimation.qml standalone
+
+ \endlist
+
+ Depending on how the animation is used, the set of properties normally used will be
+ different. For more information see the individual property documentation, as well
+ as the \l{QML Animation and Transitions} introduction.
+
+ Note that PropertyAnimation inherits the abstract \l Animation element.
+ This includes additional properties and methods for controlling the animation.
+
+ \sa {QML Animation and Transitions}, {qml/animation/basics}{Animation basics example}
+*/
+
+QQuickPropertyAnimation::QQuickPropertyAnimation(QObject *parent)
+: QQuickAbstractAnimation(*(new QQuickPropertyAnimationPrivate), parent)
+{
+}
+
+QQuickPropertyAnimation::QQuickPropertyAnimation(QQuickPropertyAnimationPrivate &dd, QObject *parent)
+: QQuickAbstractAnimation(dd, parent)
+{
+}
+
+QQuickPropertyAnimation::~QQuickPropertyAnimation()
+{
+}
+
+/*!
+ \qmlproperty int QtQuick2::PropertyAnimation::duration
+ This property holds the duration of the animation, in milliseconds.
+
+ The default value is 250.
+*/
+int QQuickPropertyAnimation::duration() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->duration;
+}
+
+void QQuickPropertyAnimation::setDuration(int duration)
+{
+ if (duration < 0) {
+ qmlInfo(this) << tr("Cannot set a duration of < 0");
+ return;
+ }
+
+ Q_D(QQuickPropertyAnimation);
+ if (d->duration == duration)
+ return;
+ d->duration = duration;
+ emit durationChanged(duration);
+}
+
+/*!
+ \qmlproperty real QtQuick2::PropertyAnimation::from
+ This property holds the starting value for the animation.
+
+ If the PropertyAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the starting state of the
+ \l Transition, or the current value of the property at the moment the
+ \l Behavior is triggered.
+
+ \sa {QML Animation and Transitions}
+*/
+QVariant QQuickPropertyAnimation::from() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->from;
+}
+
+void QQuickPropertyAnimation::setFrom(const QVariant &f)
+{
+ Q_D(QQuickPropertyAnimation);
+ if (d->fromIsDefined && f == d->from)
+ return;
+ d->from = f;
+ d->fromIsDefined = f.isValid();
+ emit fromChanged(f);
+}
+
+/*!
+ \qmlproperty real QtQuick2::PropertyAnimation::to
+ This property holds the end value for the animation.
+
+ If the PropertyAnimation is defined within a \l Transition or \l Behavior,
+ this value defaults to the value defined in the end state of the
+ \l Transition, or the value of the property change that triggered the
+ \l Behavior.
+
+ \sa {QML Animation and Transitions}
+*/
+QVariant QQuickPropertyAnimation::to() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->to;
+}
+
+void QQuickPropertyAnimation::setTo(const QVariant &t)
+{
+ Q_D(QQuickPropertyAnimation);
+ if (d->toIsDefined && t == d->to)
+ return;
+ d->to = t;
+ d->toIsDefined = t.isValid();
+ emit toChanged(t);
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::PropertyAnimation::easing.type
+ \qmlproperty real QtQuick2::PropertyAnimation::easing.amplitude
+ \qmlproperty real QtQuick2::PropertyAnimation::easing.overshoot
+ \qmlproperty real QtQuick2::PropertyAnimation::easing.period
+ \qmlproperty list<real> QtQuick2::PropertyAnimation::easing.bezierCurve
+ \brief the easing curve used for the animation.
+
+ To specify an easing curve you need to specify at least the type. For some curves you can also specify
+ amplitude, period and/or overshoot (more details provided after the table). The default easing curve is
+ \c Easing.Linear.
+
+ \qml
+ PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 }
+ \endqml
+
+ Available types are:
+
+ \table
+ \row
+ \o \c Easing.Linear
+ \o Easing curve for a linear (t) function: velocity is constant.
+ \o \inlineimage qeasingcurve-linear.png
+ \row
+ \o \c Easing.InQuad
+ \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inquad.png
+ \row
+ \o \c Easing.OutQuad
+ \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity.
+ \o \inlineimage qeasingcurve-outquad.png
+ \row
+ \o \c Easing.InOutQuad
+ \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutquad.png
+ \row
+ \o \c Easing.OutInQuad
+ \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinquad.png
+ \row
+ \o \c Easing.InCubic
+ \o Easing curve for a cubic (t^3) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-incubic.png
+ \row
+ \o \c Easing.OutCubic
+ \o Easing curve for a cubic (t^3) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outcubic.png
+ \row
+ \o \c Easing.InOutCubic
+ \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutcubic.png
+ \row
+ \o \c Easing.OutInCubic
+ \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outincubic.png
+ \row
+ \o \c Easing.InQuart
+ \o Easing curve for a quartic (t^4) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inquart.png
+ \row
+ \o \c Easing.OutQuart
+ \o Easing curve for a quartic (t^4) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outquart.png
+ \row
+ \o \c Easing.InOutQuart
+ \o Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutquart.png
+ \row
+ \o \c Easing.OutInQuart
+ \o Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinquart.png
+ \row
+ \o \c Easing.InQuint
+ \o Easing curve for a quintic (t^5) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inquint.png
+ \row
+ \o \c Easing.OutQuint
+ \o Easing curve for a quintic (t^5) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outquint.png
+ \row
+ \o \c Easing.InOutQuint
+ \o Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutquint.png
+ \row
+ \o \c Easing.OutInQuint
+ \o Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinquint.png
+ \row
+ \o \c Easing.InSine
+ \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-insine.png
+ \row
+ \o \c Easing.OutSine
+ \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outsine.png
+ \row
+ \o \c Easing.InOutSine
+ \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutsine.png
+ \row
+ \o \c Easing.OutInSine
+ \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinsine.png
+ \row
+ \o \c Easing.InExpo
+ \o Easing curve for an exponential (2^t) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inexpo.png
+ \row
+ \o \c Easing.OutExpo
+ \o Easing curve for an exponential (2^t) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outexpo.png
+ \row
+ \o \c Easing.InOutExpo
+ \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutexpo.png
+ \row
+ \o \c Easing.OutInExpo
+ \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinexpo.png
+ \row
+ \o \c Easing.InCirc
+ \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-incirc.png
+ \row
+ \o \c Easing.OutCirc
+ \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outcirc.png
+ \row
+ \o \c Easing.InOutCirc
+ \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutcirc.png
+ \row
+ \o \c Easing.OutInCirc
+ \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outincirc.png
+ \row
+ \o \c Easing.InElastic
+ \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity.
+ \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
+ \o \inlineimage qeasingcurve-inelastic.png
+ \row
+ \o \c Easing.OutElastic
+ \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity.
+ \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
+ \o \inlineimage qeasingcurve-outelastic.png
+ \row
+ \o \c Easing.InOutElastic
+ \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutelastic.png
+ \row
+ \o \c Easing.OutInElastic
+ \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinelastic.png
+ \row
+ \o \c Easing.InBack
+ \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inback.png
+ \row
+ \o \c Easing.OutBack
+ \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.
+ \o \inlineimage qeasingcurve-outback.png
+ \row
+ \o \c Easing.InOutBack
+ \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutback.png
+ \row
+ \o \c Easing.OutInBack
+ \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinback.png
+ \row
+ \o \c Easing.InBounce
+ \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inbounce.png
+ \row
+ \o \c Easing.OutBounce
+ \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outbounce.png
+ \row
+ \o \c Easing.InOutBounce
+ \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutbounce.png
+ \row
+ \o \c Easing.OutInBounce
+ \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinbounce.png
+ \row
+ \o \c Easing.Bezier
+ \o Custom easing curve defined by the easing.bezierCurve property.
+ \o
+ \endtable
+
+ \c easing.amplitude is only applicable for bounce and elastic curves (curves of type
+ \c Easing.InBounce, \c Easing.OutBounce, \c Easing.InOutBounce, \c Easing.OutInBounce, \c Easing.InElastic,
+ \c Easing.OutElastic, \c Easing.InOutElastic or \c Easing.OutInElastic).
+
+ \c easing.overshoot is only applicable if \c easing.type is: \c Easing.InBack, \c Easing.OutBack,
+ \c Easing.InOutBack or \c Easing.OutInBack.
+
+ \c easing.period is only applicable if easing.type is: \c Easing.InElastic, \c Easing.OutElastic,
+ \c Easing.InOutElastic or \c Easing.OutInElastic.
+
+ \c easing.bezierCurve is only applicable if easing.type is: \c Easing.Bezier. This property is a list<real> containing
+ groups of three points defining a curve from 0,0 to 1,1 - control1, control2,
+ end point: [cx1, cy1, cx2, cy2, endx, endy, ...]. The last point must be 1,1.
+
+ See the \l {qml/animation/easing}{easing} example for a demonstration of
+ the different easing settings.
+*/
+QEasingCurve QQuickPropertyAnimation::easing() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->easing;
+}
+
+void QQuickPropertyAnimation::setEasing(const QEasingCurve &e)
+{
+ Q_D(QQuickPropertyAnimation);
+ if (d->easing == e)
+ return;
+
+ d->easing = e;
+ emit easingChanged(e);
+}
+
+QObject *QQuickPropertyAnimation::target() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->target;
+}
+
+void QQuickPropertyAnimation::setTargetObject(QObject *o)
+{
+ Q_D(QQuickPropertyAnimation);
+ if (d->target == o)
+ return;
+ d->target = o;
+ emit targetChanged();
+}
+
+QString QQuickPropertyAnimation::property() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->propertyName;
+}
+
+void QQuickPropertyAnimation::setProperty(const QString &n)
+{
+ Q_D(QQuickPropertyAnimation);
+ if (d->propertyName == n)
+ return;
+ d->propertyName = n;
+ emit propertyChanged();
+}
+
+QString QQuickPropertyAnimation::properties() const
+{
+ Q_D(const QQuickPropertyAnimation);
+ return d->properties;
+}
+
+void QQuickPropertyAnimation::setProperties(const QString &prop)
+{
+ Q_D(QQuickPropertyAnimation);
+ if (d->properties == prop)
+ return;
+
+ d->properties = prop;
+ emit propertiesChanged(prop);
+}
+
+/*!
+ \qmlproperty string QtQuick2::PropertyAnimation::properties
+ \qmlproperty list<Object> QtQuick2::PropertyAnimation::targets
+ \qmlproperty string QtQuick2::PropertyAnimation::property
+ \qmlproperty Object QtQuick2::PropertyAnimation::target
+
+ These properties are used as a set to determine which properties should be animated.
+ The singular and plural forms are functionally identical, e.g.
+ \qml
+ NumberAnimation { target: theItem; property: "x"; to: 500 }
+ \endqml
+ has the same meaning as
+ \qml
+ NumberAnimation { targets: theItem; properties: "x"; to: 500 }
+ \endqml
+ The singular forms are slightly optimized, so if you do have only a single target/property
+ to animate you should try to use them.
+
+ The \c targets property allows multiple targets to be set. For example, this animates the
+ \c x property of both \c itemA and \c itemB:
+
+ \qml
+ NumberAnimation { targets: [itemA, itemB]; properties: "x"; to: 500 }
+ \endqml
+
+ In many cases these properties do not need to be explicitly specified, as they can be
+ inferred from the animation framework:
+
+ \table 80%
+ \row
+ \o Value Source / Behavior
+ \o When an animation is used as a value source or in a Behavior, the default target and property
+ name to be animated can both be inferred.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ NumberAnimation on x { to: 500; loops: Animation.Infinite } //animate theRect's x property
+ Behavior on y { NumberAnimation {} } //animate theRect's y property
+ }
+ \endqml
+ \row
+ \o Transition
+ \o When used in a transition, a property animation is assumed to match \e all targets
+ but \e no properties. In practice, that means you need to specify at least the properties
+ in order for the animation to do anything.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ Item { id: uselessItem }
+ states: State {
+ name: "state1"
+ PropertyChanges { target: theRect; x: 200; y: 200; z: 4 }
+ PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 }
+ }
+ transitions: Transition {
+ //animate both theRect's and uselessItem's x and y to their final values
+ NumberAnimation { properties: "x,y" }
+
+ //animate theRect's z to its final value
+ NumberAnimation { target: theRect; property: "z" }
+ }
+ }
+ \endqml
+ \row
+ \o Standalone
+ \o When an animation is used standalone, both the target and property need to be
+ explicitly specified.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ //need to explicitly specify target and property
+ NumberAnimation { id: theAnim; target: theRect; property: "x"; to: 500 }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: theAnim.start()
+ }
+ }
+ \endqml
+ \endtable
+
+ As seen in the above example, properties is specified as a comma-separated string of property names to animate.
+
+ \sa exclude, {QML Animation and Transitions}
+*/
+QQmlListProperty<QObject> QQuickPropertyAnimation::targets()
+{
+ Q_D(QQuickPropertyAnimation);
+ return QQmlListProperty<QObject>(this, d->targets);
+}
+
+/*!
+ \qmlproperty list<Object> QtQuick2::PropertyAnimation::exclude
+ This property holds the items not to be affected by this animation.
+ \sa PropertyAnimation::targets
+*/
+QQmlListProperty<QObject> QQuickPropertyAnimation::exclude()
+{
+ Q_D(QQuickPropertyAnimation);
+ return QQmlListProperty<QObject>(this, d->exclude);
+}
+
+void QQuickAnimationPropertyUpdater::setValue(qreal v)
+{
+ bool deleted = false;
+ wasDeleted = &deleted;
+ if (reverse)
+ v = 1 - v;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QQuickAction &action = actions[ii];
+
+ if (v == 1.) {
+ QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
+ } else {
+ if (!fromSourced && !fromDefined) {
+ action.fromValue = action.property.read();
+ if (interpolatorType) {
+ QQuickPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
+ }
+ }
+ if (!interpolatorType) {
+ int propType = action.property.propertyType();
+ if (!prevInterpolatorType || prevInterpolatorType != propType) {
+ prevInterpolatorType = propType;
+ interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
+ }
+ }
+ if (interpolator)
+ QQmlPropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
+ }
+ if (deleted)
+ return;
+ }
+ wasDeleted = 0;
+ fromSourced = true;
+}
+
+QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickPropertyAnimation);
+ QQuickStateActions newActions;
+
+ QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
+ for (int ii = 0; ii < props.count(); ++ii)
+ props[ii] = props.at(ii).trimmed();
+ if (!d->propertyName.isEmpty())
+ props << d->propertyName;
+
+ QList<QObject*> targets = d->targets;
+ if (d->target)
+ targets.append(d->target);
+
+ bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
+ bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+
+ if (d->defaultProperty.isValid() && !hasSelectors) {
+ props << d->defaultProperty.name();
+ targets << d->defaultProperty.object();
+ }
+
+ if (defaultTarget && targets.isEmpty())
+ targets << defaultTarget;
+
+ if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
+ props << d->defaultProperties.split(QLatin1Char(','));
+ }
+
+ bool hasExplicit = false;
+ //an explicit animation has been specified
+ if (d->toIsDefined) {
+ for (int i = 0; i < props.count(); ++i) {
+ for (int j = 0; j < targets.count(); ++j) {
+ QQuickAction myAction;
+ myAction.property = d->createProperty(targets.at(j), props.at(i), this);
+ if (myAction.property.isValid()) {
+ if (d->fromIsDefined) {
+ myAction.fromValue = d->from;
+ d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ }
+ myAction.toValue = d->to;
+ d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ newActions << myAction;
+ hasExplicit = true;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QQuickAction &action = actions[ii];
+ if (action.property.object() == myAction.property.object() &&
+ myAction.property.name() == action.property.name()) {
+ modified << action.property;
+ break; //### any chance there could be multiples?
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!hasExplicit)
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QQuickAction &action = actions[ii];
+
+ QObject *obj = action.property.object();
+ QString propertyName = action.property.name();
+ QObject *sObj = action.specifiedObject;
+ QString sPropertyName = action.specifiedProperty;
+ bool same = (obj == sObj);
+
+ if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
+ (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName))
+ || (useType && action.property.propertyType() == d->interpolatorType))) {
+ QQuickAction myAction = action;
+
+ if (d->fromIsDefined)
+ myAction.fromValue = d->from;
+ else
+ myAction.fromValue = QVariant();
+ if (d->toIsDefined)
+ myAction.toValue = d->to;
+
+ d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+
+ modified << action.property;
+
+ newActions << myAction;
+ action.fromValue = myAction.toValue;
+ }
+ }
+ return newActions;
+}
+
+QAbstractAnimationJob* QQuickPropertyAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickPropertyAnimation);
+
+ QQuickStateActions dataActions = createTransitionActions(actions, modified, defaultTarget);
+
+ QQuickBulkValueAnimator *animator = new QQuickBulkValueAnimator;
+ animator->setDuration(d->duration);
+ animator->setEasingCurve(d->easing);
+
+ if (!dataActions.isEmpty()) {
+ QQuickAnimationPropertyUpdater *data = new QQuickAnimationPropertyUpdater;
+ data->interpolatorType = d->interpolatorType;
+ data->interpolator = d->interpolator;
+ data->reverse = direction == Backward ? true : false;
+ data->fromSourced = false;
+ data->fromDefined = d->fromIsDefined;
+ data->actions = dataActions;
+ animator->setAnimValue(data);
+ animator->setFromSourcedValue(&data->fromSourced);
+ d->actions = &data->actions; //remove this?
+ }
+
+ return initInstance(animator);
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickanimation_p.h b/src/quick/util/qquickanimation_p.h
new file mode 100644
index 0000000000..980a2f5171
--- /dev/null
+++ b/src/quick/util/qquickanimation_p.h
@@ -0,0 +1,464 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKANIMATION_H
+#define QQUICKANIMATION_H
+
+#include "qquickstate_p.h"
+#include <QtGui/qvector3d.h>
+
+#include <qqmlpropertyvaluesource.h>
+#include <qqml.h>
+#include <qqmlscriptstring.h>
+
+#include <QtCore/qvariant.h>
+#include <QtCore/qeasingcurve.h>
+#include "private/qabstractanimationjob_p.h"
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickAbstractAnimationPrivate;
+class QQuickAnimationGroup;
+class Q_QUICK_PRIVATE_EXPORT QQuickAbstractAnimation : public QObject, public QQmlPropertyValueSource, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickAbstractAnimation)
+
+ Q_INTERFACES(QQmlParserStatus)
+ Q_INTERFACES(QQmlPropertyValueSource)
+ Q_ENUMS(Loops)
+ Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged)
+ Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged)
+ Q_CLASSINFO("DefaultMethod", "start()")
+
+public:
+ QQuickAbstractAnimation(QObject *parent=0);
+ virtual ~QQuickAbstractAnimation();
+
+ enum Loops { Infinite = -2 };
+
+ bool isRunning() const;
+ void setRunning(bool);
+ bool isPaused() const;
+ void setPaused(bool);
+ bool alwaysRunToEnd() const;
+ void setAlwaysRunToEnd(bool);
+
+ int loops() const;
+ void setLoops(int);
+ int duration() const;
+
+ int currentTime();
+ void setCurrentTime(int);
+
+ QQuickAnimationGroup *group() const;
+ void setGroup(QQuickAnimationGroup *);
+
+ void setDefaultTarget(const QQmlProperty &);
+ void setDisableUserControl();
+ void setEnableUserControl();
+ bool userControlDisabled() const;
+ void classBegin();
+ void componentComplete();
+
+Q_SIGNALS:
+ void started();
+ void completed();
+ void runningChanged(bool);
+ void pausedChanged(bool);
+ void alwaysRunToEndChanged(bool);
+ void loopCountChanged(int);
+
+public Q_SLOTS:
+ void restart();
+ void start();
+ void pause();
+ void resume();
+ void stop();
+ void complete();
+
+protected:
+ QQuickAbstractAnimation(QQuickAbstractAnimationPrivate &dd, QObject *parent);
+ QAbstractAnimationJob* initInstance(QAbstractAnimationJob *animation);
+
+public:
+ enum TransitionDirection { Forward, Backward };
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+ QAbstractAnimationJob* qtAnimation();
+
+private Q_SLOTS:
+ void componentFinalized();
+private:
+ virtual void setTarget(const QQmlProperty &);
+ void notifyRunningChanged(bool running);
+ friend class QQuickBehavior;
+ friend class QQuickBehaviorPrivate;
+};
+
+class QQuickPauseAnimationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickPauseAnimation : public QQuickAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPauseAnimation)
+
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+
+public:
+ QQuickPauseAnimation(QObject *parent=0);
+ virtual ~QQuickPauseAnimation();
+
+ int duration() const;
+ void setDuration(int);
+
+Q_SIGNALS:
+ void durationChanged(int);
+
+protected:
+ QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+};
+
+class QQuickScriptActionPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickScriptAction : public QQuickAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickScriptAction)
+
+ Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
+ Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
+
+public:
+ QQuickScriptAction(QObject *parent=0);
+ virtual ~QQuickScriptAction();
+
+ QQmlScriptString script() const;
+ void setScript(const QQmlScriptString &);
+
+ QString stateChangeScriptName() const;
+ void setStateChangeScriptName(const QString &);
+
+protected:
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+};
+
+class QQuickPropertyActionPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickPropertyAction : public QQuickAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPropertyAction)
+
+ Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged)
+ Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
+ Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
+ Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
+
+public:
+ QQuickPropertyAction(QObject *parent=0);
+ virtual ~QQuickPropertyAction();
+
+ QObject *target() const;
+ void setTargetObject(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
+ QString properties() const;
+ void setProperties(const QString &);
+
+ QQmlListProperty<QObject> targets();
+ QQmlListProperty<QObject> exclude();
+
+ QVariant value() const;
+ void setValue(const QVariant &);
+
+Q_SIGNALS:
+ void valueChanged(const QVariant &);
+ void propertiesChanged(const QString &);
+ void targetChanged();
+ void propertyChanged();
+
+protected:
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+};
+
+class QQuickPropertyAnimationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickPropertyAnimation : public QQuickAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
+
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+ Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
+ Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged)
+ Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
+ Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
+
+public:
+ QQuickPropertyAnimation(QObject *parent=0);
+ virtual ~QQuickPropertyAnimation();
+
+ virtual int duration() const;
+ virtual void setDuration(int);
+
+ QVariant from() const;
+ void setFrom(const QVariant &);
+
+ QVariant to() const;
+ void setTo(const QVariant &);
+
+ QEasingCurve easing() const;
+ void setEasing(const QEasingCurve &);
+
+ QObject *target() const;
+ void setTargetObject(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
+ QString properties() const;
+ void setProperties(const QString &);
+
+ QQmlListProperty<QObject> targets();
+ QQmlListProperty<QObject> exclude();
+
+protected:
+ QQuickStateActions createTransitionActions(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ QObject *defaultTarget = 0);
+
+ QQuickPropertyAnimation(QQuickPropertyAnimationPrivate &dd, QObject *parent);
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+Q_SIGNALS:
+ void durationChanged(int);
+ void fromChanged(QVariant);
+ void toChanged(QVariant);
+ void easingChanged(const QEasingCurve &);
+ void propertiesChanged(const QString &);
+ void targetChanged();
+ void propertyChanged();
+};
+
+class Q_QUICK_PRIVATE_EXPORT QQuickColorAnimation : public QQuickPropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
+ Q_PROPERTY(QColor from READ from WRITE setFrom)
+ Q_PROPERTY(QColor to READ to WRITE setTo)
+
+public:
+ QQuickColorAnimation(QObject *parent=0);
+ virtual ~QQuickColorAnimation();
+
+ QColor from() const;
+ void setFrom(const QColor &);
+
+ QColor to() const;
+ void setTo(const QColor &);
+};
+
+class Q_QUICK_PRIVATE_EXPORT QQuickNumberAnimation : public QQuickPropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
+
+ Q_PROPERTY(qreal from READ from WRITE setFrom)
+ Q_PROPERTY(qreal to READ to WRITE setTo)
+
+public:
+ QQuickNumberAnimation(QObject *parent=0);
+ virtual ~QQuickNumberAnimation();
+
+ qreal from() const;
+ void setFrom(qreal);
+
+ qreal to() const;
+ void setTo(qreal);
+
+protected:
+ QQuickNumberAnimation(QQuickPropertyAnimationPrivate &dd, QObject *parent);
+
+private:
+ void init();
+};
+
+class Q_QUICK_PRIVATE_EXPORT QQuickVector3dAnimation : public QQuickPropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
+
+ Q_PROPERTY(QVector3D from READ from WRITE setFrom)
+ Q_PROPERTY(QVector3D to READ to WRITE setTo)
+
+public:
+ QQuickVector3dAnimation(QObject *parent=0);
+ virtual ~QQuickVector3dAnimation();
+
+ QVector3D from() const;
+ void setFrom(QVector3D);
+
+ QVector3D to() const;
+ void setTo(QVector3D);
+};
+
+class QQuickRotationAnimationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimation : public QQuickPropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickRotationAnimation)
+ Q_ENUMS(RotationDirection)
+
+ Q_PROPERTY(qreal from READ from WRITE setFrom)
+ Q_PROPERTY(qreal to READ to WRITE setTo)
+ Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
+
+public:
+ QQuickRotationAnimation(QObject *parent=0);
+ virtual ~QQuickRotationAnimation();
+
+ qreal from() const;
+ void setFrom(qreal);
+
+ qreal to() const;
+ void setTo(qreal);
+
+ enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
+ RotationDirection direction() const;
+ void setDirection(RotationDirection direction);
+
+Q_SIGNALS:
+ void directionChanged();
+};
+
+class QQuickAnimationGroupPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickAnimationGroup : public QQuickAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickAnimationGroup)
+
+ Q_CLASSINFO("DefaultProperty", "animations")
+ Q_PROPERTY(QQmlListProperty<QQuickAbstractAnimation> animations READ animations)
+
+public:
+ QQuickAnimationGroup(QObject *parent);
+ virtual ~QQuickAnimationGroup();
+
+ QQmlListProperty<QQuickAbstractAnimation> animations();
+ friend class QQuickAbstractAnimation;
+
+protected:
+ QQuickAnimationGroup(QQuickAnimationGroupPrivate &dd, QObject *parent);
+};
+
+class QQuickSequentialAnimation : public QQuickAnimationGroup
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickAnimationGroup)
+
+public:
+ QQuickSequentialAnimation(QObject *parent=0);
+ virtual ~QQuickSequentialAnimation();
+
+protected:
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+};
+
+class Q_QUICK_PRIVATE_EXPORT QQuickParallelAnimation : public QQuickAnimationGroup
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickAnimationGroup)
+
+public:
+ QQuickParallelAnimation(QObject *parent=0);
+ virtual ~QQuickParallelAnimation();
+
+protected:
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickAbstractAnimation)
+QML_DECLARE_TYPE(QQuickPauseAnimation)
+QML_DECLARE_TYPE(QQuickScriptAction)
+QML_DECLARE_TYPE(QQuickPropertyAction)
+QML_DECLARE_TYPE(QQuickPropertyAnimation)
+QML_DECLARE_TYPE(QQuickColorAnimation)
+QML_DECLARE_TYPE(QQuickNumberAnimation)
+QML_DECLARE_TYPE(QQuickSequentialAnimation)
+QML_DECLARE_TYPE(QQuickParallelAnimation)
+QML_DECLARE_TYPE(QQuickVector3dAnimation)
+QML_DECLARE_TYPE(QQuickRotationAnimation)
+
+QT_END_HEADER
+
+#endif // QQUICKANIMATION_H
diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h
new file mode 100644
index 0000000000..e32453aef3
--- /dev/null
+++ b/src/quick/util/qquickanimation_p_p.h
@@ -0,0 +1,322 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKANIMATION2_P_H
+#define QQUICKANIMATION2_P_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 "qquickanimation_p.h"
+
+#include <private/qqmlnullablevalue_p_p.h>
+
+#include <qqml.h>
+#include <qqmlcontext.h>
+
+#include <private/qvariantanimation_p.h>
+#include "private/qpauseanimationjob_p.h"
+#include <QDebug>
+
+#include <private/qobject_p.h>
+#include "private/qanimationgroupjob_p.h"
+#include <QDebug>
+
+#include <private/qobject_p.h>
+
+
+QT_BEGIN_NAMESPACE
+
+//interface for classes that provide animation actions for QActionAnimation
+class QAbstractAnimationAction
+{
+public:
+ virtual ~QAbstractAnimationAction() {}
+ virtual void doAction() = 0;
+};
+
+//templated animation action
+//allows us to specify an action that calls a function of a class.
+//(so that class doesn't have to inherit QQuickAbstractAnimationAction)
+template<class T, void (T::*method)()>
+class QAnimationActionProxy : public QAbstractAnimationAction
+{
+public:
+ QAnimationActionProxy(T *instance) : m_instance(instance) {}
+ virtual void doAction() { (m_instance->*method)(); }
+
+private:
+ T *m_instance;
+};
+
+//performs an action of type QAbstractAnimationAction
+class Q_AUTOTEST_EXPORT QActionAnimation : public QAbstractAnimationJob
+{
+ Q_DISABLE_COPY(QActionAnimation)
+public:
+ QActionAnimation();
+
+ QActionAnimation(QAbstractAnimationAction *action);
+ ~QActionAnimation();
+
+ virtual int duration() const;
+ void setAnimAction(QAbstractAnimationAction *action);
+
+protected:
+ virtual void updateCurrentTime(int);
+ virtual void updateState(State newState, State oldState);
+
+private:
+ QAbstractAnimationAction *animAction;
+};
+
+class QQuickBulkValueUpdater
+{
+public:
+ virtual ~QQuickBulkValueUpdater() {}
+ virtual void setValue(qreal value) = 0;
+};
+
+//animates QQuickBulkValueUpdater (assumes start and end values will be reals or compatible)
+class Q_AUTOTEST_EXPORT QQuickBulkValueAnimator : public QAbstractAnimationJob
+{
+ Q_DISABLE_COPY(QQuickBulkValueAnimator)
+public:
+ QQuickBulkValueAnimator();
+ ~QQuickBulkValueAnimator();
+
+ void setAnimValue(QQuickBulkValueUpdater *value);
+ QQuickBulkValueUpdater *getAnimValue() const { return animValue; }
+
+ void setFromSourcedValue(bool *value) { fromSourced = value; }
+
+ int duration() const { return m_duration; }
+ void setDuration(int msecs) { m_duration = msecs; }
+
+ QEasingCurve easingCurve() const { return easing; }
+ void setEasingCurve(const QEasingCurve &curve) { easing = curve; }
+
+protected:
+ void updateCurrentTime(int currentTime);
+ void topLevelAnimationLoopChanged();
+
+private:
+ QQuickBulkValueUpdater *animValue;
+ bool *fromSourced;
+ int m_duration;
+ QEasingCurve easing;
+};
+
+//an animation that just gives a tick
+template<class T, void (T::*method)(int)>
+class QTickAnimationProxy : public QAbstractAnimationJob
+{
+ Q_DISABLE_COPY(QTickAnimationProxy)
+public:
+ QTickAnimationProxy(T *instance) : QAbstractAnimationJob(), m_instance(instance) {}
+ virtual int duration() const { return -1; }
+protected:
+ virtual void updateCurrentTime(int msec) { (m_instance->*method)(msec); }
+
+private:
+ T *m_instance;
+};
+
+class QQuickAbstractAnimationPrivate : public QObjectPrivate, public QAnimationJobChangeListener
+{
+ Q_DECLARE_PUBLIC(QQuickAbstractAnimation)
+public:
+ QQuickAbstractAnimationPrivate()
+ : running(false), paused(false), alwaysRunToEnd(false),
+ /*connectedTimeLine(false), */componentComplete(true),
+ avoidPropertyValueSourceStart(false), disableUserControl(false),
+ registered(false), loopCount(1), group(0), animationInstance(0) {}
+
+ bool running:1;
+ bool paused:1;
+ bool alwaysRunToEnd:1;
+ //bool connectedTimeLine:1;
+ bool componentComplete:1;
+ bool avoidPropertyValueSourceStart:1;
+ bool disableUserControl:1;
+ bool registered:1;
+
+ int loopCount;
+
+ void commence();
+ virtual void animationFinished(QAbstractAnimationJob *);
+
+ QQmlProperty defaultProperty;
+
+ QQuickAnimationGroup *group;
+ QAbstractAnimationJob* animationInstance;
+
+ static QQmlProperty createProperty(QObject *obj, const QString &str, QObject *infoObj);
+};
+
+class QQuickPauseAnimationPrivate : public QQuickAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickPauseAnimation)
+public:
+ QQuickPauseAnimationPrivate()
+ : QQuickAbstractAnimationPrivate(), duration(250) {}
+
+ int duration;
+};
+
+class QQuickScriptActionPrivate : public QQuickAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickScriptAction)
+public:
+ QQuickScriptActionPrivate();
+
+ QQmlScriptString script;
+ QString name;
+ QQmlScriptString runScriptScript;
+ bool hasRunScriptScript;
+ bool reversing;
+
+ void execute();
+ QAbstractAnimationAction* createAction();
+ typedef QAnimationActionProxy<QQuickScriptActionPrivate,
+ &QQuickScriptActionPrivate::execute> Proxy;
+};
+
+class QQuickPropertyActionPrivate : public QQuickAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickPropertyAction)
+public:
+ QQuickPropertyActionPrivate()
+ : QQuickAbstractAnimationPrivate(), target(0) {}
+
+ QObject *target;
+ QString propertyName;
+ QString properties;
+ QList<QObject *> targets;
+ QList<QObject *> exclude;
+
+ QQmlNullableValue<QVariant> value;
+};
+
+class QQuickAnimationGroupPrivate : public QQuickAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickAnimationGroup)
+public:
+ QQuickAnimationGroupPrivate()
+ : QQuickAbstractAnimationPrivate() {}
+
+ static void append_animation(QQmlListProperty<QQuickAbstractAnimation> *list, QQuickAbstractAnimation *role);
+ static void clear_animation(QQmlListProperty<QQuickAbstractAnimation> *list);
+ QList<QQuickAbstractAnimation *> animations;
+};
+
+class QQuickPropertyAnimationPrivate : public QQuickAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickPropertyAnimation)
+public:
+ QQuickPropertyAnimationPrivate()
+ : QQuickAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
+ defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), duration(250), actions(0) {}
+
+ QVariant from;
+ QVariant to;
+
+ QObject *target;
+ QString propertyName;
+ QString properties;
+ QList<QObject *> targets;
+ QList<QObject *> exclude;
+ QString defaultProperties;
+
+ bool fromSourced;
+ bool fromIsDefined:1;
+ bool toIsDefined:1;
+ bool defaultToInterpolatorType:1;
+ int interpolatorType;
+ QVariantAnimation::Interpolator interpolator;
+ int duration;
+ QEasingCurve easing;
+
+ // for animations that don't use the QQuickBulkValueAnimator
+ QQuickStateActions *actions;
+
+ static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
+ static void convertVariant(QVariant &variant, int type);
+};
+
+class QQuickRotationAnimationPrivate : public QQuickPropertyAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickRotationAnimation)
+public:
+ QQuickRotationAnimationPrivate() : direction(QQuickRotationAnimation::Numerical) {}
+
+ QQuickRotationAnimation::RotationDirection direction;
+};
+
+class Q_AUTOTEST_EXPORT QQuickAnimationPropertyUpdater : public QQuickBulkValueUpdater
+{
+public:
+ QQuickAnimationPropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {}
+ ~QQuickAnimationPropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
+
+ void setValue(qreal v);
+
+ QQuickStateActions actions;
+ int interpolatorType; //for Number/ColorAnimation
+ QVariantAnimation::Interpolator interpolator;
+ int prevInterpolatorType; //for generic
+ bool reverse;
+ bool fromSourced;
+ bool fromDefined;
+ bool *wasDeleted;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKANIMATION2_P_H
diff --git a/src/quick/util/qquickanimationcontroller.cpp b/src/quick/util/qquickanimationcontroller.cpp
new file mode 100644
index 0000000000..a3e343f26d
--- /dev/null
+++ b/src/quick/util/qquickanimationcontroller.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickanimationcontroller_p.h"
+#include <QtQml/qqmlinfo.h>
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QQuickAnimationControllerPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickAnimationController)
+public:
+ QQuickAnimationControllerPrivate()
+ : progress(0.0), animation(0), animationInstance(0), finalized(false) {}
+
+ qreal progress;
+ QQuickAbstractAnimation *animation;
+ QAbstractAnimationJob *animationInstance;
+ bool finalized:1;
+
+};
+
+/*!
+ \qmlclass AnimationController QQuickAnimationController
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \brief The AnimationController element allows you to control animations manually.
+
+ Normally animations are driven by an internal timer, but the AnimationController
+ allows the given \a animation to be driven by a \a progress value explicitly.
+*/
+
+
+QQuickAnimationController::QQuickAnimationController(QObject *parent)
+: QObject(*(new QQuickAnimationControllerPrivate), parent)
+{
+}
+
+QQuickAnimationController::~QQuickAnimationController()
+{
+ Q_D(QQuickAnimationController);
+ delete d->animationInstance;
+}
+
+/*!
+ \qmlproperty real QtQuick2::AnimationController::progress
+ This property holds the animation progress value.
+
+ The valid \c progress value is 0.0 to 1.0, setting values less than 0 will be converted to 0,
+ setting values great than 1 will be converted to 1.
+*/
+qreal QQuickAnimationController::progress() const
+{
+ Q_D(const QQuickAnimationController);
+ return d->progress;
+}
+
+void QQuickAnimationController::setProgress(qreal progress)
+{
+ Q_D(QQuickAnimationController);
+ progress = qBound(qreal(0), progress, qreal(1));
+
+ if (progress != d->progress) {
+ d->progress = progress;
+ updateProgress();
+ emit progressChanged();
+ }
+}
+
+/*!
+ \qmlproperty real QtQuick2::AnimationController::animation
+ \default
+
+ This property holds the animation to be controlled by the AnimationController.
+
+ Note:An animation controlled by AnimationController will always have its
+ \c running and \c paused properties set to true. It can not be manually
+ started or stopped (much like an animation in a Behavior can not be manually started or stopped).
+*/
+QQuickAbstractAnimation *QQuickAnimationController::animation() const
+{
+ Q_D(const QQuickAnimationController);
+ return d->animation;
+}
+
+void QQuickAnimationController::classBegin()
+{
+ QQmlEnginePrivate *engPriv = QQmlEnginePrivate::get(qmlEngine(this));
+ engPriv->registerFinalizeCallback(this, this->metaObject()->indexOfSlot("componentFinalized()"));
+}
+
+
+void QQuickAnimationController::setAnimation(QQuickAbstractAnimation *animation)
+{
+ Q_D(QQuickAnimationController);
+
+ if (animation != d->animation) {
+ if (animation) {
+ if (animation->userControlDisabled()) {
+ qmlInfo(this) << "QQuickAnimationController::setAnimation: the animation is controlled by others, can't be used in AnimationController.";
+ return;
+ }
+ animation->setDisableUserControl();
+ }
+
+ if (d->animation)
+ d->animation->setEnableUserControl();
+
+ d->animation = animation;
+ reload();
+ emit animationChanged();
+ }
+}
+
+/*!
+ \qmlmethod QtQuick2::AnimationController::reload()
+ \brief Reloads the animation properties.
+
+ If the animation properties changed, calling this method to reload the animation definations.
+*/
+void QQuickAnimationController::reload()
+{
+ Q_D(QQuickAnimationController);
+ if (!d->finalized)
+ return;
+
+ if (!d->animation) {
+ d->animationInstance = 0;
+ } else {
+ QQuickStateActions actions;
+ QQmlProperties properties;
+ QAbstractAnimationJob *oldInstance = d->animationInstance;
+ d->animationInstance = d->animation->transition(actions, properties, QQuickAbstractAnimation::Forward);
+ if (oldInstance && oldInstance != d->animationInstance)
+ delete oldInstance;
+ d->animationInstance->setLoopCount(1);
+ d->animationInstance->start();
+ d->animationInstance->pause();
+ updateProgress();
+ }
+}
+
+void QQuickAnimationController::updateProgress()
+{
+ Q_D(QQuickAnimationController);
+ if (!d->animationInstance)
+ return;
+
+ d->animationInstance->start();
+ QQmlAnimationTimer::unregisterAnimation(d->animationInstance);
+ d->animationInstance->setCurrentTime(d->progress * d->animationInstance->duration());
+}
+
+void QQuickAnimationController::componentFinalized()
+{
+ Q_D(QQuickAnimationController);
+ d->finalized = true;
+ reload();
+}
+
+
+QT_END_NAMESPACE
+
+
diff --git a/src/quick/util/qquickanimationcontroller_p.h b/src/quick/util/qquickanimationcontroller_p.h
new file mode 100644
index 0000000000..2b2b2a84ec
--- /dev/null
+++ b/src/quick/util/qquickanimationcontroller_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKANIMATIONCONTROLLER_H
+#define QQUICKANIMATIONCONTROLLER_H
+
+#include <qqml.h>
+#include "qquickanimation_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Quick)
+
+class QQuickAnimationControllerPrivate;
+class Q_AUTOTEST_EXPORT QQuickAnimationController : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+
+ Q_DECLARE_PRIVATE(QQuickAnimationController)
+ Q_CLASSINFO("DefaultProperty", "animation")
+
+ Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
+ Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged)
+
+public:
+ QQuickAnimationController(QObject *parent=0);
+ ~QQuickAnimationController();
+
+ qreal progress() const;
+ void setProgress(qreal progress);
+
+ QQuickAbstractAnimation *animation() const;
+ void setAnimation(QQuickAbstractAnimation *animation);
+
+ void classBegin();
+ void componentComplete() {}
+Q_SIGNALS:
+ void progressChanged();
+ void animationChanged();
+public Q_SLOTS:
+ void reload();
+private Q_SLOTS:
+ void componentFinalized();
+ void updateProgress();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickAnimationController)
+
+QT_END_HEADER
+
+#endif // QQUICKANIMATIONCONTROLLER_H
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp
new file mode 100644
index 0000000000..78d83371d3
--- /dev/null
+++ b/src/quick/util/qquickbehavior.cpp
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickbehavior_p.h"
+
+#include "qquickanimation_p.h"
+#include <qqmlcontext.h>
+#include <qqmlinfo.h>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlguard_p.h>
+#include <private/qqmlengine_p.h>
+#include <private/qabstractanimationjob_p.h>
+#include <private/qquicktransition_p.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickBehaviorPrivate : public QObjectPrivate, public QAnimationJobChangeListener
+{
+ Q_DECLARE_PUBLIC(QQuickBehavior)
+public:
+ QQuickBehaviorPrivate() : animation(0), animationInstance(0), enabled(true), finalized(false)
+ , blockRunningChanged(false) {}
+
+ virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+
+ QQmlProperty property;
+ QVariant targetValue;
+ QQmlGuard<QQuickAbstractAnimation> animation;
+ QAbstractAnimationJob *animationInstance;
+ bool enabled;
+ bool finalized;
+ bool blockRunningChanged;
+};
+
+/*!
+ \qmlclass Behavior QQuickBehavior
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \brief The Behavior element allows you to specify a default animation for a property change.
+
+ 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/qml/behavior.qml 0
+
+ Note that a property cannot have more than one assigned Behavior. To provide
+ multiple animations within a Behavior, use ParallelAnimation or
+ SequentialAnimation.
+
+ If a \l{QML States}{state change} has a \l Transition that matches the same property as a
+ Behavior, the \l Transition animation overrides the Behavior for that
+ state change. For general advice on using Behaviors to animate state changes, see
+ \l{Using QML Behaviors with States}.
+
+ \sa {QML Animation and Transitions}, {declarative/animation/behaviors}{Behavior example}, QtQml
+*/
+
+
+QQuickBehavior::QQuickBehavior(QObject *parent)
+ : QObject(*(new QQuickBehaviorPrivate), parent)
+{
+}
+
+QQuickBehavior::~QQuickBehavior()
+{
+ Q_D(QQuickBehavior);
+ delete d->animationInstance;
+}
+
+/*!
+ \qmlproperty Animation QtQuick2::Behavior::animation
+ \default
+
+ This property holds the animation to run when the behavior is triggered.
+*/
+
+QQuickAbstractAnimation *QQuickBehavior::animation()
+{
+ Q_D(QQuickBehavior);
+ return d->animation;
+}
+
+void QQuickBehavior::setAnimation(QQuickAbstractAnimation *animation)
+{
+ Q_D(QQuickBehavior);
+ if (d->animation) {
+ qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior.");
+ return;
+ }
+
+ d->animation = animation;
+ if (d->animation) {
+ d->animation->setDefaultTarget(d->property);
+ d->animation->setDisableUserControl();
+ }
+}
+
+
+void QQuickBehaviorPrivate::animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState,QAbstractAnimationJob::State)
+{
+ if (!blockRunningChanged)
+ animation->notifyRunningChanged(newState == QAbstractAnimationJob::Running);
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Behavior::enabled
+
+ This property holds whether the behavior will be triggered when the tracked
+ property changes value.
+
+ By default a Behavior is enabled.
+*/
+
+bool QQuickBehavior::enabled() const
+{
+ Q_D(const QQuickBehavior);
+ return d->enabled;
+}
+
+void QQuickBehavior::setEnabled(bool enabled)
+{
+ Q_D(QQuickBehavior);
+ if (d->enabled == enabled)
+ return;
+ d->enabled = enabled;
+ emit enabledChanged();
+}
+
+void QQuickBehavior::write(const QVariant &value)
+{
+ Q_D(QQuickBehavior);
+ bool bypass = !d->enabled || !d->finalized;
+ if (!bypass)
+ qmlExecuteDeferred(this);
+ if (!d->animation || bypass) {
+ QQmlPropertyPrivate::write(d->property, value, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
+ d->targetValue = value;
+ return;
+ }
+
+ if (d->animation->isRunning() && value == d->targetValue)
+ return;
+
+ const QVariant &currentValue = d->property.read();
+ d->targetValue = value;
+
+ if (d->animationInstance && d->animationInstance->duration() != -1
+ && !d->animationInstance->isStopped()) {
+ d->blockRunningChanged = true;
+ d->animationInstance->stop();
+ }
+
+ QQuickStateOperation::ActionList actions;
+ QQuickAction action;
+ action.property = d->property;
+ action.fromValue = currentValue;
+ action.toValue = value;
+ actions << action;
+
+ QList<QQmlProperty> after;
+ QAbstractAnimationJob *prev = d->animationInstance;
+ d->animationInstance = d->animation->transition(actions, after, QQuickAbstractAnimation::Forward);
+ if (d->animationInstance != prev) {
+ d->animationInstance->addAnimationChangeListener(d, QAbstractAnimationJob::StateChange);
+ if (prev)
+ delete prev;
+ }
+ d->animationInstance->start();
+ d->blockRunningChanged = false;
+ if (!after.contains(d->property))
+ QQmlPropertyPrivate::write(d->property, value, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
+}
+
+void QQuickBehavior::setTarget(const QQmlProperty &property)
+{
+ Q_D(QQuickBehavior);
+ d->property = property;
+ if (d->animation)
+ d->animation->setDefaultTarget(property);
+
+ QQmlEnginePrivate *engPriv = QQmlEnginePrivate::get(qmlEngine(this));
+ static int finalizedIdx = -1;
+ if (finalizedIdx < 0)
+ finalizedIdx = metaObject()->indexOfSlot("componentFinalized()");
+ engPriv->registerFinalizeCallback(this, finalizedIdx);
+}
+
+void QQuickBehavior::componentFinalized()
+{
+ Q_D(QQuickBehavior);
+ d->finalized = true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickbehavior_p.h b/src/quick/util/qquickbehavior_p.h
new file mode 100644
index 0000000000..1c258767d3
--- /dev/null
+++ b/src/quick/util/qquickbehavior_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKBEHAVIOR_H
+#define QQUICKBEHAVIOR_H
+
+#include <private/qtquickglobal_p.h>
+
+#include <private/qqmlpropertyvalueinterceptor_p.h>
+#include <qqml.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickAbstractAnimation;
+class QQuickBehaviorPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickBehavior : public QObject, public QQmlPropertyValueInterceptor
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickBehavior)
+
+ Q_INTERFACES(QQmlPropertyValueInterceptor)
+ Q_CLASSINFO("DefaultProperty", "animation")
+ Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_CLASSINFO("DeferredPropertyNames", "animation")
+
+public:
+ QQuickBehavior(QObject *parent=0);
+ ~QQuickBehavior();
+
+ virtual void setTarget(const QQmlProperty &);
+ virtual void write(const QVariant &value);
+
+ QQuickAbstractAnimation *animation();
+ void setAnimation(QQuickAbstractAnimation *);
+
+ bool enabled() const;
+ void setEnabled(bool enabled);
+
+Q_SIGNALS:
+ void enabledChanged();
+
+private Q_SLOTS:
+ void componentFinalized();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickBehavior)
+
+QT_END_HEADER
+
+#endif // QQUICKBEHAVIOR_H
diff --git a/src/quick/util/qquickbind.cpp b/src/quick/util/qquickbind.cpp
new file mode 100644
index 0000000000..a3fba06359
--- /dev/null
+++ b/src/quick/util/qquickbind.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickbind_p.h"
+
+#include <private/qqmlnullablevalue_p_p.h>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlguard_p.h>
+
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqmlproperty.h>
+#include <qqmlinfo.h>
+
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickBindPrivate : public QObjectPrivate
+{
+public:
+ QQuickBindPrivate() : componentComplete(true), obj(0), prevBind(0) {}
+ ~QQuickBindPrivate() { if (prevBind) prevBind->destroy(); }
+
+ QQmlNullableValue<bool> when;
+ bool componentComplete;
+ QQmlGuard<QObject> obj;
+ QString propName;
+ QQmlNullableValue<QVariant> value;
+ QQmlProperty prop;
+ QQmlAbstractBinding *prevBind;
+};
+
+
+/*!
+ \qmlclass Binding QQuickBind
+ \inqmlmodule QtQuick 2
+ \ingroup qml-working-with-data
+ \brief The Binding element allows arbitrary property bindings to be created.
+
+ \section1 Binding to an inaccessible property
+
+ Sometimes it is necessary to bind to a property of an object that wasn't
+ directly instantiated by QML - generally a property of a class exported
+ to QML by C++. In these cases, regular property binding doesn't work. Binding
+ allows you to bind any value to any property.
+
+ For example, imagine a C++ application that maps an "app.enteredText"
+ property into QML. You could use Binding to update the enteredText property
+ like this.
+ \code
+ TextEdit { id: myTextField; text: "Please type here..." }
+ Binding { target: app; property: "enteredText"; value: myTextField.text }
+ \endcode
+ Whenever the text in the TextEdit is updated, the C++ property will be
+ updated also.
+
+ \section1 "Single-branch" conditional binding
+
+ In some circumstances you may want to control the value of a property
+ only when a certain condition is true (and relinquish control in all
+ other cirumstances). This often isn't possible to accomplish with a direct
+ binding, as you need to supply values for all possible branches.
+
+ \qml
+ // warning: "Unable to assign [undefined] to double value"
+ value: if (mouse.pressed) mouse.mouseX
+ \endqml
+
+ The above example will produce a warning whenever we release the mouse, as the value
+ of the binding is undefined when the mouse isn't pressed. We can use the Binding
+ element to rewrite the above code and avoid the warning.
+
+ \qml
+ Binding on value {
+ when: mouse.pressed
+ value: mouse.mouseX
+ }
+ \endqml
+
+ The Binding element will also restore any previously set direct bindings on
+ the property. In that sense, it functions much like a simplified State.
+
+ \qml
+ // this is equivilant to the above Binding
+ State {
+ name: "pressed"
+ when: mouse.pressed
+ PropertyChanges {
+ target: obj
+ value: mouse.mouseX
+ }
+ }
+ \endqml
+
+ If the binding target or binding property is changed, the bound value is
+ immediately pushed onto the new target.
+
+ \sa QtQml
+*/
+QQuickBind::QQuickBind(QObject *parent)
+ : QObject(*(new QQuickBindPrivate), parent)
+{
+}
+
+QQuickBind::~QQuickBind()
+{
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Binding::when
+
+ This property holds when the binding is active.
+ This should be set to an expression that evaluates to true when you want the binding to be active.
+
+ \code
+ Binding {
+ target: contactName; property: 'text'
+ value: name; when: list.ListView.isCurrentItem
+ }
+ \endcode
+
+ When the binding becomes inactive again, any direct bindings that were previously
+ set on the property will be restored.
+*/
+bool QQuickBind::when() const
+{
+ Q_D(const QQuickBind);
+ return d->when;
+}
+
+void QQuickBind::setWhen(bool v)
+{
+ Q_D(QQuickBind);
+ if (!d->when.isNull && d->when == v)
+ return;
+
+ d->when = v;
+ eval();
+}
+
+/*!
+ \qmlproperty Object QtQuick2::Binding::target
+
+ The object to be updated.
+*/
+QObject *QQuickBind::object()
+{
+ Q_D(const QQuickBind);
+ return d->obj;
+}
+
+void QQuickBind::setObject(QObject *obj)
+{
+ Q_D(QQuickBind);
+ if (d->obj && d->when.isValid() && d->when) {
+ /* if we switch the object at runtime, we need to restore the
+ previous binding on the old object before continuing */
+ d->when = false;
+ eval();
+ d->when = true;
+ }
+ d->obj = obj;
+ if (d->componentComplete)
+ d->prop = QQmlProperty(d->obj, d->propName);
+ eval();
+}
+
+/*!
+ \qmlproperty string QtQuick2::Binding::property
+
+ The property to be updated.
+*/
+QString QQuickBind::property() const
+{
+ Q_D(const QQuickBind);
+ return d->propName;
+}
+
+void QQuickBind::setProperty(const QString &p)
+{
+ Q_D(QQuickBind);
+ if (!d->propName.isEmpty() && d->when.isValid() && d->when) {
+ /* if we switch the property name at runtime, we need to restore the
+ previous binding on the old object before continuing */
+ d->when = false;
+ eval();
+ d->when = true;
+ }
+ d->propName = p;
+ if (d->componentComplete)
+ d->prop = QQmlProperty(d->obj, d->propName);
+ eval();
+}
+
+/*!
+ \qmlproperty any QtQuick2::Binding::value
+
+ The value to be set on the target object and property. This can be a
+ constant (which isn't very useful), or a bound expression.
+*/
+QVariant QQuickBind::value() const
+{
+ Q_D(const QQuickBind);
+ return d->value.value;
+}
+
+void QQuickBind::setValue(const QVariant &v)
+{
+ Q_D(QQuickBind);
+ d->value = v;
+ eval();
+}
+
+void QQuickBind::setTarget(const QQmlProperty &p)
+{
+ Q_D(QQuickBind);
+ d->prop = p;
+}
+
+void QQuickBind::classBegin()
+{
+ Q_D(QQuickBind);
+ d->componentComplete = false;
+}
+
+void QQuickBind::componentComplete()
+{
+ Q_D(QQuickBind);
+ d->componentComplete = true;
+ if (!d->prop.isValid())
+ d->prop = QQmlProperty(d->obj, d->propName);
+ eval();
+}
+
+void QQuickBind::eval()
+{
+ Q_D(QQuickBind);
+ if (!d->prop.isValid() || d->value.isNull || !d->componentComplete)
+ return;
+
+ if (d->when.isValid()) {
+ if (!d->when) {
+ //restore any previous binding
+ if (d->prevBind) {
+ QQmlAbstractBinding *tmp = d->prevBind;
+ d->prevBind = 0;
+ tmp = QQmlPropertyPrivate::setBinding(d->prop, tmp);
+ if (tmp) //should this ever be true?
+ tmp->destroy();
+ }
+ return;
+ }
+
+ //save any set binding for restoration
+ QQmlAbstractBinding *tmp;
+ tmp = QQmlPropertyPrivate::setBinding(d->prop, 0);
+ if (tmp && d->prevBind)
+ d->prevBind->destroy();
+ else if (!d->prevBind)
+ d->prevBind = tmp;
+ }
+
+ d->prop.write(d->value.value);
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickbind_p.h b/src/quick/util/qquickbind_p.h
new file mode 100644
index 0000000000..5236fac171
--- /dev/null
+++ b/src/quick/util/qquickbind_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKBIND_H
+#define QQUICKBIND_H
+
+#include <qqml.h>
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickBindPrivate;
+class Q_AUTOTEST_EXPORT QQuickBind : public QObject, public QQmlPropertyValueSource, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickBind)
+ Q_INTERFACES(QQmlParserStatus)
+ Q_INTERFACES(QQmlPropertyValueSource)
+ Q_PROPERTY(QObject *target READ object WRITE setObject)
+ Q_PROPERTY(QString property READ property WRITE setProperty)
+ Q_PROPERTY(QVariant value READ value WRITE setValue)
+ Q_PROPERTY(bool when READ when WRITE setWhen)
+
+public:
+ QQuickBind(QObject *parent=0);
+ ~QQuickBind();
+
+ bool when() const;
+ void setWhen(bool);
+
+ QObject *object();
+ void setObject(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
+ QVariant value() const;
+ void setValue(const QVariant &);
+
+protected:
+ virtual void setTarget(const QQmlProperty &);
+ virtual void classBegin();
+ virtual void componentComplete();
+
+private:
+ void eval();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickBind)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/quick/util/qquickchangeset.cpp b/src/quick/util/qquickchangeset.cpp
new file mode 100644
index 0000000000..b6b5adb60c
--- /dev/null
+++ b/src/quick/util/qquickchangeset.cpp
@@ -0,0 +1,479 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickchangeset_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQuickChangeSet::QQuickChangeSet()
+ : m_moveCounter(0)
+ , m_difference(0)
+{
+}
+
+QQuickChangeSet::QQuickChangeSet(const QQuickChangeSet &changeSet)
+ : m_removes(changeSet.m_removes)
+ , m_inserts(changeSet.m_inserts)
+ , m_changes(changeSet.m_changes)
+ , m_moveCounter(changeSet.m_moveCounter)
+ , m_difference(0)
+{
+}
+
+QQuickChangeSet::~QQuickChangeSet()
+{
+}
+
+QQuickChangeSet &QQuickChangeSet::operator =(const QQuickChangeSet &changeSet)
+{
+ m_removes = changeSet.m_removes;
+ m_inserts = changeSet.m_inserts;
+ m_changes = changeSet.m_changes;
+ m_moveCounter = changeSet.m_moveCounter;
+ m_difference = changeSet.m_difference;
+ return *this;
+}
+
+void QQuickChangeSet::insert(int index, int count)
+{
+ applyInsertions(QVector<Insert>() << Insert(index, count));
+}
+
+void QQuickChangeSet::remove(int index, int count)
+{
+ QVector<Insert> i;
+ applyRemovals(QVector<Remove>() << Remove(index, count), i);
+}
+
+void QQuickChangeSet::move(int from, int to, int count)
+{
+ apply(QVector<Remove>() << Remove(from, count, -2), QVector<Insert>() << Insert(to, count, -2));
+}
+
+void QQuickChangeSet::change(int index, int count)
+{
+ applyChanges(QVector<Change>() << Change(index, count));
+}
+
+void QQuickChangeSet::apply(const QQuickChangeSet &changeSet)
+{
+ apply(changeSet.m_removes, changeSet.m_inserts, changeSet.m_changes);
+}
+
+void QQuickChangeSet::apply(const QVector<Remove> &removals)
+{
+ QVector<Remove> r = removals;
+ QVector<Insert> i;
+ applyRemovals(r, i);
+}
+
+void QQuickChangeSet::apply(const QVector<Insert> &insertions)
+{
+ QVector<Insert> i = insertions;
+ applyInsertions(i);
+}
+
+void QQuickChangeSet::apply(const QVector<Change> &changes)
+{
+ QVector<Change> c = changes;
+ applyChanges(c);
+}
+
+void QQuickChangeSet::apply(const QVector<Remove> &removals, const QVector<Insert> &insertions, const QVector<Change> &changes)
+{
+ QVector<Remove> r = removals;
+ QVector<Insert> i = insertions;
+ QVector<Change> c = changes;
+ applyRemovals(r, i);
+ applyInsertions(i);
+ applyChanges(c);
+}
+
+void QQuickChangeSet::applyRemovals(QVector<Remove> &removals, QVector<Insert> &insertions)
+{
+ int removeCount = 0;
+ int insertCount = 0;
+ QVector<Insert>::iterator insert = m_inserts.begin();
+ QVector<Change>::iterator change = m_changes.begin();
+ QVector<Remove>::iterator rit = removals.begin();
+ for (; rit != removals.end(); ++rit) {
+ int index = rit->index + removeCount;
+ int count = rit->count;
+
+ QVector<Insert>::iterator iit = insertions.begin();
+ for (; rit->moveId != -1 && iit != insertions.end() && iit->moveId != rit->moveId; ++iit) {}
+
+ for (QVector<Remove>::iterator nrit = rit + 1; nrit != removals.end(); nrit = rit + 1) {
+ if (nrit->index != rit->index || (rit->moveId == -1) != (nrit->moveId == -1))
+ break;
+ if (nrit->moveId != -1) {
+ QVector<Insert>::iterator niit = iit + 1;
+ if (niit->moveId != nrit->moveId || niit->index != iit->index + iit->count)
+ break;
+ niit->index = iit->index;
+ niit->count += iit->count;
+ iit = insertions.erase(iit);
+ }
+ nrit->count += rit->count;
+ rit = removals.erase(rit);
+ }
+
+ for (; change != m_changes.end() && change->end() < rit->index; ++change) {}
+ for (; change != m_changes.end() && change->index > rit->end(); ++change) {
+ change->count -= qMin(change->end(), rit->end()) - qMax(change->index, rit->index);
+ if (change->count == 0) {
+ change = m_changes.erase(change);
+ } else if (rit->index < change->index) {
+ change->index = rit->index;
+ }
+ }
+ for (; insert != m_inserts.end() && insert->end() <= index; ++insert) {
+ insertCount += insert->count;
+ insert->index -= removeCount;
+ }
+ for (; insert != m_inserts.end() && insert->index < index + count; ++insert) {
+ const int offset = insert->index - index;
+ const int difference = qMin(insert->end(), index + count) - qMax(insert->index, index);
+ const int moveId = rit->moveId != -1 ? m_moveCounter++ : -1;
+ if (insert->moveId != -1) {
+ QVector<Remove>::iterator remove = m_removes.begin();
+ for (; remove != m_removes.end() && remove->moveId != insert->moveId; ++remove) {}
+ Q_ASSERT(remove != m_removes.end());
+ const int offset = index - insert->index;
+ if (rit->moveId != -1 && offset < 0) {
+ const int moveId = m_moveCounter++;
+ iit = insertions.insert(iit, Insert(iit->index, -offset, moveId));
+ ++iit;
+ iit->index += -offset;
+ iit->count -= -offset;
+ rit = removals.insert(rit, Remove(rit->index, -offset, moveId));
+ ++rit;
+ rit->count -= -offset;
+ }
+
+ if (offset > 0) {
+ const int moveId = m_moveCounter++;
+ insert = m_inserts.insert(insert, Insert(insert->index, offset, moveId));
+ ++insert;
+ insert->index += offset;
+ insert->count -= offset;
+ remove = m_removes.insert(remove, Remove(remove->index, offset, moveId));
+ ++remove;
+ remove->count -= offset;
+ rit->index -= offset;
+ index += offset;
+ count -= offset;
+ }
+
+ if (remove->count == difference) {
+ remove->moveId = moveId;
+ } else {
+ remove = m_removes.insert(remove, Remove(remove->index, difference, moveId));
+ ++remove;
+ remove->count -= difference;
+ }
+ } else if (rit->moveId != -1 && offset > 0) {
+ const int moveId = m_moveCounter++;
+ iit = insertions.insert(iit, Insert(iit->index, offset, moveId));
+ ++iit;
+ iit->index += offset;
+ iit->count -= offset;
+ rit = removals.insert(rit, Remove(rit->index, offset, moveId));
+ ++rit;
+ rit->count -= offset;
+ index += offset;
+ count -= offset;
+ }
+
+ if (rit->moveId != -1 && difference > 0) {
+ iit = insertions.insert(iit, Insert(
+ iit->index, difference, insert->moveId != -1 ? moveId : -1));
+ ++iit;
+ iit->index += difference;
+ iit->count -= difference;
+ }
+
+ insert->count -= difference;
+ rit->count -= difference;
+ if (insert->count == 0) {
+ insert = m_inserts.erase(insert);
+ --insert;
+ } else if (index <= insert->index) {
+ insert->index = rit->index;
+ } else {
+ rit->index -= insert->count;
+ }
+ index += difference;
+ count -= difference;
+ removeCount += difference;
+ }
+ rit->index -= insertCount;
+ removeCount += rit->count;
+
+ if (rit->count == 0) {
+ if (rit->moveId != -1 && iit->count == 0)
+ insertions.erase(iit);
+ rit = removals.erase(rit);
+ --rit;
+ } else if (rit->moveId != -1) {
+ const int moveId = m_moveCounter++;
+ rit->moveId = moveId;
+ iit->moveId = moveId;
+ }
+ }
+ for (; change != m_changes.end(); ++change)
+ change->index -= removeCount;
+ for (; insert != m_inserts.end(); ++insert)
+ insert->index -= removeCount;
+
+ removeCount = 0;
+ QVector<Remove>::iterator remove = m_removes.begin();
+ for (rit = removals.begin(); rit != removals.end(); ++rit) {
+ QVector<Insert>::iterator iit = insertions.begin();
+ int index = rit->index + removeCount;
+ for (; rit->moveId != -1 && iit != insertions.end() && iit->moveId != rit->moveId; ++iit) {}
+ for (; remove != m_removes.end() && index > remove->index; ++remove)
+ remove->index -= removeCount;
+ while (remove != m_removes.end() && index + rit->count > remove->index) {
+ int count = 0;
+ const int offset = remove->index - index - removeCount;
+ QVector<Remove>::iterator rend = remove;
+ for (; rend != m_removes.end()
+ && rit->moveId == -1
+ && rend->moveId == -1
+ && rit->index + rit->count >= rend->index; ++rend) {
+ count += rend->count;
+ }
+ if (remove != rend) {
+ const int difference = rend == m_removes.end() || rit->index + rit->count < rend->index - removeCount
+ ? rit->count
+ : offset;
+ count += difference;
+
+ index += difference;
+ rit->count -= difference;
+ removeCount += difference;
+ remove->index = rit->index;
+ remove->count = count;
+ remove = m_removes.erase(++remove, rend);
+ } else if (rit->moveId != -1) {
+ if (offset > 0) {
+ const int moveId = m_moveCounter++;
+ iit = insertions.insert(iit, Insert(iit->index, offset, moveId));
+ ++iit;
+ iit->index += offset;
+ iit->count -= offset;
+ remove = m_removes.insert(remove, Remove(rit->index, offset, moveId));
+ ++remove;
+ rit->count -= offset;
+ removeCount += offset;
+ }
+ remove->index = rit->index;
+ index += offset;
+
+ ++remove;
+ } else {
+ if (offset > 0) {
+ remove = m_removes.insert(remove, Remove(rit->index, offset));
+ ++remove;
+ rit->count -= offset;
+ removeCount += offset;
+ }
+ remove->index = rit->index;
+ index += offset;
+
+ ++remove;
+ }
+ index += count;
+ }
+
+ if (rit->count > 0) {
+ remove = m_removes.insert(remove, *rit);
+ ++remove;
+ }
+ removeCount += rit->count;
+ }
+ for (; remove != m_removes.end(); ++remove)
+ remove->index -= removeCount;
+ m_difference -= removeCount;
+}
+
+void QQuickChangeSet::applyInsertions(QVector<Insert> &insertions)
+{
+ int insertCount = 0;
+ QVector<Insert>::iterator insert = m_inserts.begin();
+ QVector<Change>::iterator change = m_changes.begin();
+ for (QVector<Insert>::iterator iit = insertions.begin(); iit != insertions.end(); ++iit) {
+ int index = iit->index - insertCount;
+ int count = iit->count;
+ for (; change != m_changes.end() && change->index >= index; ++change)
+ change->index += insertCount;
+ if (change != m_changes.end() && change->index < index + count) {
+ int offset = index - change->index;
+ change = m_changes.insert(change, Change(change->index + insertCount, offset));
+ ++change;
+ change->index += count + offset;
+ change->count -= offset;
+ }
+ for (; insert != m_inserts.end() && iit->index > insert->index + insert->count; ++insert)
+ insert->index += insertCount;
+ if (insert == m_inserts.end()) {
+ insert = m_inserts.insert(insert, *iit);
+ ++insert;
+ insertCount += iit->count;
+ } else {
+ const int offset = index - insert->index;
+ if (offset < 0 || (offset == 0 && (iit->moveId != -1 || insert->moveId != -1))) {
+ insert = m_inserts.insert(insert, *iit);
+ ++insert;
+ } else if (iit->moveId == -1 && insert->moveId == -1) {
+ insert->index -= iit->count;
+ insert->count += iit->count;
+ } else if (offset < insert->count) {
+ const int moveId = insert->moveId != -1 ? m_moveCounter++ : -1;
+ insert = m_inserts.insert(insert, Insert(insert->index + insertCount, offset, moveId));
+ ++insert;
+ insert->index += offset;
+ insert->count -= offset;
+ insert = m_inserts.insert(insert, *iit);
+ ++insert;
+
+ if (insert->moveId != -1) {
+ QVector<Remove>::iterator remove = m_removes.begin();
+ for (; remove != m_removes.end() && remove->moveId != insert->moveId; ++remove) {}
+ Q_ASSERT(remove != m_removes.end());
+ if (remove->count == offset) {
+ remove->moveId = moveId;
+ } else {
+ remove = m_removes.insert(remove, Remove(remove->index, offset, moveId));
+ ++remove;
+ remove->count -= offset;
+ }
+ }
+ } else {
+ ++insert;
+ insert = m_inserts.insert(insert, *iit);
+ ++insert;
+ }
+ insertCount += iit->count;
+ }
+ }
+ for (; change != m_changes.end(); ++change)
+ change->index += insertCount;
+ for (; insert != m_inserts.end(); ++insert)
+ insert->index += insertCount;
+ m_difference += insertCount;
+}
+
+void QQuickChangeSet::applyChanges(QVector<Change> &changes)
+{
+ QVector<Insert>::iterator insert = m_inserts.begin();
+ QVector<Change>::iterator change = m_changes.begin();
+ for (QVector<Change>::iterator cit = changes.begin(); cit != changes.end(); ++cit) {
+ for (; insert != m_inserts.end() && insert->end() < cit->index; ++insert) {}
+ for (; insert != m_inserts.end() && insert->index < cit->end(); ++insert) {
+ const int offset = insert->index - cit->index;
+ const int count = cit->count + cit->index - insert->index - insert->count;
+ if (offset == 0) {
+ cit->index = insert->index + insert->count;
+ cit->count = count;
+ } else {
+ cit = changes.insert(++cit, Change(insert->index + insert->count, count));
+ --cit;
+ cit->count = offset;
+ }
+ }
+
+ for (; change != m_changes.end() && change->index + change->count < cit->index; ++change) {}
+ if (change == m_changes.end() || change->index > cit->index + cit->count) {
+ if (cit->count > 0) {
+ change = m_changes.insert(change, *cit);
+ ++change;
+ }
+ } else {
+ if (cit->index < change->index) {
+ change->count += change->index - cit->index;
+ change->index = cit->index;
+ }
+
+ if (cit->index + cit->count > change->index + change->count) {
+ change->count = cit->index + cit->count - change->index;
+ QVector<Change>::iterator rbegin = change;
+ QVector<Change>::iterator rend = ++rbegin;
+ for (; rend != m_changes.end() && rend->index <= change->index + change->count; ++rend) {
+ if (rend->index + rend->count > change->index + change->count)
+ change->count = rend->index + rend->count - change->index;
+ }
+ if (rbegin != rend) {
+ change = m_changes.erase(rbegin, rend);
+ --change;
+ }
+ }
+ }
+ }
+}
+
+QDebug operator <<(QDebug debug, const QQuickChangeSet &set)
+{
+ debug.nospace() << "QQuickChangeSet(";
+ foreach (const QQuickChangeSet::Remove &remove, set.removes()) debug << remove;
+ foreach (const QQuickChangeSet::Insert &insert, set.inserts()) debug << insert;
+ foreach (const QQuickChangeSet::Change &change, set.changes()) debug << change;
+ return debug.nospace() << ")";
+}
+
+QDebug operator <<(QDebug debug, const QQuickChangeSet::Remove &remove)
+{
+ return (debug.nospace() << "Remove(" << remove.index << "," << remove.count << "," << remove.moveId << ")").space();
+}
+
+QDebug operator <<(QDebug debug, const QQuickChangeSet::Insert &insert)
+{
+ return (debug.nospace() << "Insert(" << insert.index << "," << insert.count << "," << insert.moveId << ")").space();
+}
+
+QDebug operator <<(QDebug debug, const QQuickChangeSet::Change &change)
+{
+ return (debug.nospace() << "Change(" << change.index << "," << change.count << ")").space();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/quick/util/qquickchangeset_p.h b/src/quick/util/qquickchangeset_p.h
new file mode 100644
index 0000000000..64179666c7
--- /dev/null
+++ b/src/quick/util/qquickchangeset_p.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKCHANGESET_P_H
+#define QQUICKCHANGESET_P_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/qdebug.h>
+#include <QtCore/qvector.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_AUTOTEST_EXPORT QQuickChangeSet
+{
+public:
+ struct MoveKey
+ {
+ MoveKey() : moveId(-1), offset(0) {}
+ MoveKey(int moveId, int offset) : moveId(moveId), offset(offset) {}
+ int moveId;
+ int offset;
+ };
+
+ struct Change
+ {
+ Change() : index(0), count(0), moveId(-1) {}
+ Change(int index, int count) : index(index), count(count), moveId(-1) {}
+ Change(int index, int count, int moveId) : index(index), count(count), moveId(moveId) {}
+
+ int index;
+ int count;
+ int moveId;
+
+ bool isMove() const { return moveId >= 0; }
+
+ MoveKey moveKey(int index) const { return MoveKey(moveId, index - Change::index); }
+
+ int start() const { return index; }
+ int end() const { return index + count; }
+ };
+
+
+ struct Insert : public Change
+ {
+ Insert() {}
+ Insert(int index, int count) : Change(index, count) {}
+ Insert(int index, int count, int moveId) : Change(index, count, moveId) {}
+ };
+
+ struct Remove : public Change
+ {
+ Remove() {}
+ Remove(int index, int count) : Change(index, count) {}
+ Remove(int index, int count, int moveId) : Change(index, count, moveId) {}
+ };
+
+ QQuickChangeSet();
+ QQuickChangeSet(const QQuickChangeSet &changeSet);
+ ~QQuickChangeSet();
+
+ QQuickChangeSet &operator =(const QQuickChangeSet &changeSet);
+
+ const QVector<Remove> &removes() const { return m_removes; }
+ const QVector<Insert> &inserts() const { return m_inserts; }
+ const QVector<Change> &changes() const {return m_changes; }
+
+ void insert(int index, int count);
+ void remove(int index, int count);
+ void move(int from, int to, int count);
+ void change(int index, int count);
+
+ void apply(const QQuickChangeSet &changeSet);
+ void apply(const QVector<Remove> &removals);
+ void apply(const QVector<Insert> &insertions);
+ void apply(const QVector<Change> &changes);
+ void apply(
+ const QVector<Remove> &removals,
+ const QVector<Insert> &insertions,
+ const QVector<Change> &changes = QVector<Change>());
+
+ bool isEmpty() const { return m_removes.empty() && m_inserts.empty() && m_changes.empty(); }
+
+ void clear()
+ {
+ m_removes.clear();
+ m_inserts.clear();
+ m_changes.clear();
+ m_moveCounter = 0;
+ m_difference = 0;
+ }
+
+ int moveCounter() const { return m_moveCounter; }
+ int difference() const { return m_difference; }
+
+private:
+ void applyRemovals(QVector<Remove> &removals, QVector<Insert> &insertions);
+ void applyInsertions(QVector<Insert> &insertions);
+ void applyChanges(QVector<Change> &changes);
+
+ QVector<Remove> m_removes;
+ QVector<Insert> m_inserts;
+ QVector<Change> m_changes;
+ int m_moveCounter;
+ int m_difference;
+};
+
+inline uint qHash(const QQuickChangeSet::MoveKey &key) { return qHash(qMakePair(key.moveId, key.offset)); }
+inline bool operator ==(const QQuickChangeSet::MoveKey &l, const QQuickChangeSet::MoveKey &r) {
+ return l.moveId == r.moveId && l.offset == r.offset; }
+
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickChangeSet &change);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickChangeSet::Remove &remove);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickChangeSet::Insert &insert);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickChangeSet::Change &change);
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/quick/util/qquickconnections.cpp b/src/quick/util/qquickconnections.cpp
new file mode 100644
index 0000000000..6e176fde3d
--- /dev/null
+++ b/src/quick/util/qquickconnections.cpp
@@ -0,0 +1,307 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickconnections_p.h"
+
+#include <private/qqmlexpression_p.h>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlboundsignal_p.h>
+#include <qqmlcontext.h>
+#include <private/qqmlcontext_p.h>
+#include <qqmlinfo.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickConnectionsPrivate : public QObjectPrivate
+{
+public:
+ QQuickConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {}
+
+ QList<QQmlBoundSignal*> boundsignals;
+ QObject *target;
+
+ bool targetSet;
+ bool ignoreUnknownSignals;
+ bool componentcomplete;
+
+ QByteArray data;
+};
+
+/*!
+ \qmlclass Connections QQuickConnections
+ \inqmlmodule QtQuick 2
+ \ingroup qml-utility-elements
+ \brief A Connections element describes generalized connections to signals.
+
+ A Connections object creates a connection to a QML signal.
+
+ When connecting to signals in QML, the usual way is to create an
+ "on<Signal>" handler that reacts when a signal is received, like this:
+
+ \qml
+ MouseArea {
+ onClicked: { foo(parameters) }
+ }
+ \endqml
+
+ However, it is not possible to connect to a signal in this way in some
+ cases, such as when:
+
+ \list
+ \i Multiple connections to the same signal are required
+ \i Creating connections outside the scope of the signal sender
+ \i Connecting to targets not defined in QML
+ \endlist
+
+ When any of these are needed, the Connections element can be used instead.
+
+ For example, the above code can be changed to use a Connections object,
+ like this:
+
+ \qml
+ MouseArea {
+ Connections {
+ onClicked: foo(parameters)
+ }
+ }
+ \endqml
+
+ More generally, the Connections object can be a child of some object other than
+ the sender of the signal:
+
+ \qml
+ MouseArea {
+ id: area
+ }
+ // ...
+ \endqml
+ \qml
+ Connections {
+ target: area
+ onClicked: foo(parameters)
+ }
+ \endqml
+
+ \sa QtQml
+*/
+QQuickConnections::QQuickConnections(QObject *parent) :
+ QObject(*(new QQuickConnectionsPrivate), parent)
+{
+}
+
+QQuickConnections::~QQuickConnections()
+{
+}
+
+/*!
+ \qmlproperty Object QtQuick2::Connections::target
+ This property holds the object that sends the signal.
+
+ If this property is not set, the \c target defaults to the parent of the Connection.
+
+ If set to null, no connection is made and any signal handlers are ignored
+ until the target is not null.
+*/
+QObject *QQuickConnections::target() const
+{
+ Q_D(const QQuickConnections);
+ return d->targetSet ? d->target : parent();
+}
+
+void QQuickConnections::setTarget(QObject *obj)
+{
+ Q_D(QQuickConnections);
+ d->targetSet = true; // even if setting to 0, it is *set*
+ if (d->target == obj)
+ return;
+ foreach (QQmlBoundSignal *s, d->boundsignals) {
+ // It is possible that target is being changed due to one of our signal
+ // handlers -> use deleteLater().
+ if (s->isEvaluating())
+ s->deleteLater();
+ else
+ delete s;
+ }
+ d->boundsignals.clear();
+ d->target = obj;
+ connectSignals();
+ emit targetChanged();
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Connections::ignoreUnknownSignals
+
+ Normally, a connection to a non-existent signal produces runtime errors.
+
+ If this property is set to \c true, such errors are ignored.
+ This is useful if you intend to connect to different types of objects, handling
+ a different set of signals for each object.
+*/
+bool QQuickConnections::ignoreUnknownSignals() const
+{
+ Q_D(const QQuickConnections);
+ return d->ignoreUnknownSignals;
+}
+
+void QQuickConnections::setIgnoreUnknownSignals(bool ignore)
+{
+ Q_D(QQuickConnections);
+ d->ignoreUnknownSignals = ignore;
+}
+
+
+
+QByteArray
+QQmlConnectionsParser::compile(const QList<QQmlCustomParserProperty> &props)
+{
+ QByteArray rv;
+ QDataStream ds(&rv, QIODevice::WriteOnly);
+
+ for(int ii = 0; ii < props.count(); ++ii)
+ {
+ QString propName = props.at(ii).name();
+ int propLine = props.at(ii).location().line;
+ int propColumn = props.at(ii).location().column;
+
+ if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) {
+ error(props.at(ii), QQuickConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
+ return QByteArray();
+ }
+
+ QList<QVariant> values = props.at(ii).assignedValues();
+
+ for (int i = 0; i < values.count(); ++i) {
+ const QVariant &value = values.at(i);
+
+ if (value.userType() == qMetaTypeId<QQmlCustomParserNode>()) {
+ error(props.at(ii), QQuickConnections::tr("Connections: nested objects not allowed"));
+ return QByteArray();
+ } else if (value.userType() == qMetaTypeId<QQmlCustomParserProperty>()) {
+ error(props.at(ii), QQuickConnections::tr("Connections: syntax error"));
+ return QByteArray();
+ } else {
+ QQmlScript::Variant v = qvariant_cast<QQmlScript::Variant>(value);
+ if (v.isScript()) {
+ ds << propName;
+ ds << rewriteSignalHandler(v, propName);
+ ds << propLine;
+ ds << propColumn;
+ } else {
+ error(props.at(ii), QQuickConnections::tr("Connections: script expected"));
+ return QByteArray();
+ }
+ }
+ }
+ }
+
+ return rv;
+}
+
+void QQmlConnectionsParser::setCustomData(QObject *object,
+ const QByteArray &data)
+{
+ QQuickConnectionsPrivate *p =
+ static_cast<QQuickConnectionsPrivate *>(QObjectPrivate::get(object));
+ p->data = data;
+}
+
+
+void QQuickConnections::connectSignals()
+{
+ Q_D(QQuickConnections);
+ if (!d->componentcomplete || (d->targetSet && !target()))
+ return;
+
+ QDataStream ds(d->data);
+ while (!ds.atEnd()) {
+ QString propName;
+ ds >> propName;
+ QString script;
+ ds >> script;
+ int line;
+ ds >> line;
+ int column;
+ ds >> column;
+
+ QQmlProperty prop(target(), propName);
+ if (prop.isValid() && (prop.type() & QQmlProperty::SignalProperty)) {
+ QQmlBoundSignal *signal =
+ new QQmlBoundSignal(target(), prop.method(), this);
+
+ QString location;
+ QQmlContextData *ctxtdata = 0;
+ QQmlData *ddata = QQmlData::get(this);
+ if (ddata) {
+ ctxtdata = ddata->outerContext;
+ if (ctxtdata && !ctxtdata->url.isEmpty())
+ location = ddata->outerContext->urlString;
+ }
+
+ QQmlExpression *expression = ctxtdata ?
+ QQmlExpressionPrivate::create(ctxtdata, 0, script, true, location, line, column) : 0;
+ signal->setExpression(expression);
+ d->boundsignals += signal;
+ } else {
+ if (!d->ignoreUnknownSignals)
+ qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName);
+ }
+ }
+}
+
+void QQuickConnections::classBegin()
+{
+ Q_D(QQuickConnections);
+ d->componentcomplete=false;
+}
+
+void QQuickConnections::componentComplete()
+{
+ Q_D(QQuickConnections);
+ d->componentcomplete=true;
+ connectSignals();
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickconnections_p.h b/src/quick/util/qquickconnections_p.h
new file mode 100644
index 0000000000..8184697e88
--- /dev/null
+++ b/src/quick/util/qquickconnections_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKCONNECTIONS_H
+#define QQUICKCONNECTIONS_H
+
+#include <qqml.h>
+#include <private/qqmlcustomparser_p.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQmlBoundSignal;
+class QQmlContext;
+class QQuickConnectionsPrivate;
+class Q_AUTOTEST_EXPORT QQuickConnections : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickConnections)
+
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals)
+
+public:
+ QQuickConnections(QObject *parent=0);
+ ~QQuickConnections();
+
+ QObject *target() const;
+ void setTarget(QObject *);
+
+ bool ignoreUnknownSignals() const;
+ void setIgnoreUnknownSignals(bool ignore);
+
+Q_SIGNALS:
+ void targetChanged();
+
+private:
+ void connectSignals();
+ void classBegin();
+ void componentComplete();
+};
+
+class QQmlConnectionsParser : public QQmlCustomParser
+{
+public:
+ virtual QByteArray compile(const QList<QQmlCustomParserProperty> &);
+ virtual void setCustomData(QObject *, const QByteArray &);
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickConnections)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp
new file mode 100644
index 0000000000..438d00bd1b
--- /dev/null
+++ b/src/quick/util/qquickfontloader.cpp
@@ -0,0 +1,335 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickfontloader_p.h"
+
+#include <qqmlcontext.h>
+#include <qqmlengine.h>
+
+#include <QStringList>
+#include <QUrl>
+#include <QDebug>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QFontDatabase>
+
+#include <private/qobject_p.h>
+#include <private/qqmlengine_p.h>
+#include <qqmlinfo.h>
+
+QT_BEGIN_NAMESPACE
+
+#define FONTLOADER_MAXIMUM_REDIRECT_RECURSION 16
+
+class QQuickFontObject : public QObject
+{
+Q_OBJECT
+
+public:
+ explicit QQuickFontObject(int _id = -1);
+
+ void download(const QUrl &url, QNetworkAccessManager *manager);
+
+Q_SIGNALS:
+ void fontDownloaded(const QString&, QQuickFontLoader::Status);
+
+private Q_SLOTS:
+ void replyFinished();
+
+public:
+ int id;
+
+private:
+ QNetworkReply *reply;
+ int redirectCount;
+
+ Q_DISABLE_COPY(QQuickFontObject)
+};
+
+QQuickFontObject::QQuickFontObject(int _id)
+ : QObject(0), id(_id), reply(0), redirectCount(0) {}
+
+
+void QQuickFontObject::download(const QUrl &url, QNetworkAccessManager *manager)
+{
+ QNetworkRequest req(url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ reply = manager->get(req);
+ QObject::connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+}
+
+void QQuickFontObject::replyFinished()
+{
+ if (reply) {
+ redirectCount++;
+ if (redirectCount < FONTLOADER_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = reply->url().resolved(redirect.toUrl());
+ QNetworkAccessManager *manager = reply->manager();
+ reply->deleteLater();
+ reply = 0;
+ download(url, manager);
+ return;
+ }
+ }
+ redirectCount = 0;
+
+ if (!reply->error()) {
+ id = QFontDatabase::addApplicationFontFromData(reply->readAll());
+ if (id != -1)
+ emit fontDownloaded(QFontDatabase::applicationFontFamilies(id).at(0), QQuickFontLoader::Ready);
+ else
+ emit fontDownloaded(QString(), QQuickFontLoader::Error);
+ } else {
+ emit fontDownloaded(QString(), QQuickFontLoader::Error);
+ }
+ reply->deleteLater();
+ reply = 0;
+ }
+}
+
+
+class QQuickFontLoaderPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickFontLoader)
+
+public:
+ QQuickFontLoaderPrivate() : status(QQuickFontLoader::Null) {}
+
+ QUrl url;
+ QString name;
+ QQuickFontLoader::Status status;
+ static QHash<QUrl, QQuickFontObject*> fonts;
+};
+
+QHash<QUrl, QQuickFontObject*> QQuickFontLoaderPrivate::fonts;
+
+/*!
+ \qmlclass FontLoader QQuickFontLoader
+ \inqmlmodule QtQuick 2
+ \ingroup qml-utility-elements
+ \brief The FontLoader element allows fonts to be loaded by name or URL.
+
+ The FontLoader element is used to load fonts by name or URL.
+
+ The \l status indicates when the font has been loaded, which is useful
+ for fonts loaded from remote sources.
+
+ For example:
+ \qml
+ import QtQuick 2.0
+
+ Column {
+ FontLoader { id: fixedFont; name: "Courier" }
+ FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
+
+ Text { text: "Fixed-size font"; font.family: fixedFont.name }
+ Text { text: "Fancy font"; font.family: webFont.name }
+ }
+ \endqml
+
+ \sa {declarative/text/fonts}{Fonts example}
+*/
+QQuickFontLoader::QQuickFontLoader(QObject *parent)
+ : QObject(*(new QQuickFontLoaderPrivate), parent)
+{
+}
+
+QQuickFontLoader::~QQuickFontLoader()
+{
+}
+
+/*!
+ \qmlproperty url QtQuick2::FontLoader::source
+ The url of the font to load.
+*/
+QUrl QQuickFontLoader::source() const
+{
+ Q_D(const QQuickFontLoader);
+ return d->url;
+}
+
+void QQuickFontLoader::setSource(const QUrl &url)
+{
+ Q_D(QQuickFontLoader);
+ if (url == d->url)
+ return;
+ d->url = url;
+ emit sourceChanged();
+
+ QString localFile = QQmlEnginePrivate::urlToLocalFileOrQrc(d->url);
+ if (!localFile.isEmpty()) {
+ if (!d->fonts.contains(d->url)) {
+ int id = QFontDatabase::addApplicationFont(localFile);
+ if (id != -1) {
+ updateFontInfo(QFontDatabase::applicationFontFamilies(id).at(0), Ready);
+ QQuickFontObject *fo = new QQuickFontObject(id);
+ d->fonts[d->url] = fo;
+ } else {
+ updateFontInfo(QString(), Error);
+ }
+ } else {
+ updateFontInfo(QFontDatabase::applicationFontFamilies(d->fonts[d->url]->id).at(0), Ready);
+ }
+ } else {
+ if (!d->fonts.contains(d->url)) {
+ QQuickFontObject *fo = new QQuickFontObject;
+ d->fonts[d->url] = fo;
+ fo->download(d->url, qmlEngine(this)->networkAccessManager());
+ d->status = Loading;
+ emit statusChanged();
+ QObject::connect(fo, SIGNAL(fontDownloaded(QString,QQuickFontLoader::Status)),
+ this, SLOT(updateFontInfo(QString,QQuickFontLoader::Status)));
+ } else {
+ QQuickFontObject *fo = d->fonts[d->url];
+ if (fo->id == -1) {
+ d->status = Loading;
+ emit statusChanged();
+ QObject::connect(fo, SIGNAL(fontDownloaded(QString,QQuickFontLoader::Status)),
+ this, SLOT(updateFontInfo(QString,QQuickFontLoader::Status)));
+ }
+ else
+ updateFontInfo(QFontDatabase::applicationFontFamilies(fo->id).at(0), Ready);
+ }
+ }
+}
+
+void QQuickFontLoader::updateFontInfo(const QString& name, QQuickFontLoader::Status status)
+{
+ Q_D(QQuickFontLoader);
+
+ if (name != d->name) {
+ d->name = name;
+ emit nameChanged();
+ }
+ if (status != d->status) {
+ if (status == Error)
+ qmlInfo(this) << "Cannot load font: \"" << d->url.toString() << "\"";
+ d->status = status;
+ emit statusChanged();
+ }
+}
+
+/*!
+ \qmlproperty string QtQuick2::FontLoader::name
+
+ This property holds the name of the font family.
+ It is set automatically when a font is loaded using the \c url property.
+
+ Use this to set the \c font.family property of a \c Text item.
+
+ Example:
+ \qml
+ Item {
+ width: 200; height: 50
+
+ FontLoader {
+ id: webFont
+ source: "http://www.mysite.com/myfont.ttf"
+ }
+ Text {
+ text: "Fancy font"
+ font.family: webFont.name
+ }
+ }
+ \endqml
+*/
+QString QQuickFontLoader::name() const
+{
+ Q_D(const QQuickFontLoader);
+ return d->name;
+}
+
+void QQuickFontLoader::setName(const QString &name)
+{
+ Q_D(QQuickFontLoader);
+ if (d->name == name)
+ return;
+ d->name = name;
+ emit nameChanged();
+ d->status = Ready;
+ emit statusChanged();
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::FontLoader::status
+
+ This property holds the status of font loading. It can be one of:
+ \list
+ \o FontLoader.Null - no font has been set
+ \o FontLoader.Ready - the font has been loaded
+ \o FontLoader.Loading - the font is currently being loaded
+ \o FontLoader.Error - an error occurred while loading the font
+ \endlist
+
+ Use this status to provide an update or respond to the status change in some way.
+ For example, you could:
+
+ \list
+ \o Trigger a state change:
+ \qml
+ State { name: 'loaded'; when: loader.status == FontLoader.Ready }
+ \endqml
+
+ \o Implement an \c onStatusChanged signal handler:
+ \qml
+ FontLoader {
+ id: loader
+ onStatusChanged: if (loader.status == FontLoader.Ready) console.log('Loaded')
+ }
+ \endqml
+
+ \o Bind to the status value:
+ \qml
+ Text { text: loader.status == FontLoader.Ready ? 'Loaded' : 'Not loaded' }
+ \endqml
+ \endlist
+*/
+QQuickFontLoader::Status QQuickFontLoader::status() const
+{
+ Q_D(const QQuickFontLoader);
+ return d->status;
+}
+
+QT_END_NAMESPACE
+
+#include <qquickfontloader.moc>
diff --git a/src/quick/util/qquickfontloader_p.h b/src/quick/util/qquickfontloader_p.h
new file mode 100644
index 0000000000..191388df95
--- /dev/null
+++ b/src/quick/util/qquickfontloader_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKFONTLOADER_H
+#define QQUICKFONTLOADER_H
+
+#include <qqml.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickFontLoaderPrivate;
+class Q_AUTOTEST_EXPORT QQuickFontLoader : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickFontLoader)
+ Q_ENUMS(Status)
+
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+
+public:
+ enum Status { Null = 0, Ready, Loading, Error };
+
+ QQuickFontLoader(QObject *parent = 0);
+ ~QQuickFontLoader();
+
+ QUrl source() const;
+ void setSource(const QUrl &url);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ Status status() const;
+
+private Q_SLOTS:
+ void updateFontInfo(const QString&, QQuickFontLoader::Status);
+
+Q_SIGNALS:
+ void sourceChanged();
+ void nameChanged();
+ void statusChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickFontLoader)
+
+QT_END_HEADER
+
+#endif // QQUICKFONTLOADER_H
+
diff --git a/src/quick/util/qquicklistaccessor.cpp b/src/quick/util/qquicklistaccessor.cpp
new file mode 100644
index 0000000000..532882a2f9
--- /dev/null
+++ b/src/quick/util/qquicklistaccessor.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicklistaccessor_p.h"
+
+#include <private/qqmlmetatype_p.h>
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qdebug.h>
+
+// ### Remove me
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QQuickListAccessor::QQuickListAccessor()
+: m_type(Invalid)
+{
+}
+
+QQuickListAccessor::~QQuickListAccessor()
+{
+}
+
+QVariant QQuickListAccessor::list() const
+{
+ return d;
+}
+
+void QQuickListAccessor::setList(const QVariant &v, QQmlEngine *engine)
+{
+ d = v;
+
+ QQmlEnginePrivate *enginePrivate = engine?QQmlEnginePrivate::get(engine):0;
+
+ if (!d.isValid()) {
+ m_type = Invalid;
+ } else if (d.userType() == QVariant::StringList) {
+ m_type = StringList;
+ } else if (d.userType() == QMetaType::QVariantList) {
+ m_type = VariantList;
+ } else if (d.canConvert(QVariant::Int)) {
+ m_type = Integer;
+ } else if ((!enginePrivate && QQmlMetaType::isQObject(d.userType())) ||
+ (enginePrivate && enginePrivate->isQObject(d.userType()))) {
+ QObject *data = enginePrivate?enginePrivate->toQObject(v):QQmlMetaType::toQObject(v);
+ d = QVariant::fromValue(data);
+ m_type = Instance;
+ } else if (d.userType() == qMetaTypeId<QQmlListReference>()) {
+ m_type = ListProperty;
+ } else {
+ m_type = Instance;
+ }
+}
+
+int QQuickListAccessor::count() const
+{
+ switch(m_type) {
+ case StringList:
+ return qvariant_cast<QStringList>(d).count();
+ case VariantList:
+ return qvariant_cast<QVariantList>(d).count();
+ case ListProperty:
+ return ((QQmlListReference *)d.constData())->count();
+ case Instance:
+ return 1;
+ case Integer:
+ return d.toInt();
+ default:
+ case Invalid:
+ return 0;
+ }
+}
+
+QVariant QQuickListAccessor::at(int idx) const
+{
+ Q_ASSERT(idx >= 0 && idx < count());
+ switch(m_type) {
+ case StringList:
+ return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx));
+ case VariantList:
+ return qvariant_cast<QVariantList>(d).at(idx);
+ case ListProperty:
+ return QVariant::fromValue(((QQmlListReference *)d.constData())->at(idx));
+ case Instance:
+ return d;
+ case Integer:
+ return QVariant(idx);
+ default:
+ case Invalid:
+ return QVariant();
+ }
+}
+
+bool QQuickListAccessor::isValid() const
+{
+ return m_type != Invalid;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquicklistaccessor_p.h b/src/quick/util/qquicklistaccessor_p.h
new file mode 100644
index 0000000000..2b54c686bf
--- /dev/null
+++ b/src/quick/util/qquicklistaccessor_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKLISTACCESSOR_H
+#define QQUICKLISTACCESSOR_H
+
+#include <QtCore/QVariant>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+class Q_AUTOTEST_EXPORT QQuickListAccessor
+{
+public:
+ QQuickListAccessor();
+ ~QQuickListAccessor();
+
+ QVariant list() const;
+ void setList(const QVariant &, QQmlEngine * = 0);
+
+ bool isValid() const;
+
+ int count() const;
+ QVariant at(int) const;
+
+ enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer };
+ Type type() const { return m_type; }
+
+private:
+ Type m_type;
+ QVariant d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQUICKLISTACCESSOR_H
diff --git a/src/quick/util/qquicklistcompositor.cpp b/src/quick/util/qquicklistcompositor.cpp
new file mode 100644
index 0000000000..d60fe5fb79
--- /dev/null
+++ b/src/quick/util/qquicklistcompositor.cpp
@@ -0,0 +1,1214 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicklistcompositor_p.h"
+
+#include <QtCore/qvarlengtharray.h>
+
+//#define QT_QML_VERIFY_MINIMAL
+//#define QT_QML_VERIFY_INTEGRITY
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QT_QML_VERIFY_MINIMAL
+#define QT_QML_VERIFY_INTEGRITY
+static bool qt_verifyMinimal(
+ const QQuickListCompositor::iterator &begin,
+ const QQuickListCompositor::iterator &end)
+{
+ bool minimal = true;
+ int index = 0;
+
+ for (const QQuickListCompositor::Range *range = begin->next; range != *end; range = range->next, ++index) {
+ if (range->previous->list == range->list
+ && range->previous->flags == (range->flags & ~QQuickListCompositor::AppendFlag)
+ && range->previous->end() == range->index) {
+ qWarning() << index << "Consecutive ranges";
+ qWarning() << *range->previous;
+ qWarning() << *range;
+ minimal = false;
+ }
+ }
+
+ return minimal;
+}
+
+#endif
+
+#ifdef QT_QML_VERIFY_INTEGRITY
+static bool qt_printInfo(const QQuickListCompositor &compositor)
+{
+ qWarning() << compositor;
+ return true;
+}
+
+static bool qt_verifyIntegrity(
+ const QQuickListCompositor::iterator &begin,
+ const QQuickListCompositor::iterator &end,
+ const QQuickListCompositor::iterator &cachedIt)
+{
+ bool valid = true;
+
+ int index = 0;
+ QQuickListCompositor::iterator it;
+ for (it = begin; *it != *end; *it = it->next) {
+ if (it->count == 0 && !it->append()) {
+ qWarning() << index << "Empty non-append range";
+ valid = false;
+ }
+ if (it->count < 0) {
+ qWarning() << index << "Negative count";
+ valid = false;
+ }
+ if (it->list && it->flags != QQuickListCompositor::CacheFlag && it->index < 0) {
+ qWarning() << index <<"Negative index";
+ valid = false;
+ }
+ if (it->previous->next != it.range) {
+ qWarning() << index << "broken list: it->previous->next != it.range";
+ valid = false;
+ }
+ if (it->next->previous != it.range) {
+ qWarning() << index << "broken list: it->next->previous != it.range";
+ valid = false;
+ }
+ if (*it == *cachedIt) {
+ for (int i = 0; i < end.groupCount; ++i) {
+ int groupIndex = it.index[i];
+ if (cachedIt->flags & (1 << i))
+ groupIndex += cachedIt.offset;
+ if (groupIndex != cachedIt.index[i]) {
+ qWarning() << index
+ << "invalid cached index"
+ << QQuickListCompositor::Group(i)
+ << "Expected:"
+ << groupIndex
+ << "Actual"
+ << cachedIt.index[i]
+ << cachedIt;
+ valid = false;
+ }
+ }
+ }
+ it.incrementIndexes(it->count);
+ ++index;
+ }
+
+ for (int i = 0; i < end.groupCount; ++i) {
+ if (end.index[i] != it.index[i]) {
+ qWarning() << "Group" << i << "count invalid. Expected:" << end.index[i] << "Actual:" << it.index[i];
+ valid = false;
+ }
+ }
+ return valid;
+}
+#endif
+
+#if defined(QT_QML_VERIFY_MINIMAL)
+# define QT_QML_VERIFY_LISTCOMPOSITOR Q_ASSERT(!(!(qt_verifyIntegrity(iterator(m_ranges.next, 0, Default, m_groupCount), m_end, m_cacheIt) \
+ && qt_verifyMinimal(iterator(m_ranges.next, 0, Default, m_groupCount), m_end)) \
+ && qt_printInfo(*this)));
+#elif defined(QT_QML_VERIFY_INTEGRITY)
+# define QT_QML_VERIFY_LISTCOMPOSITOR Q_ASSERT(!(!qt_verifyIntegrity(iterator(m_ranges.next, 0, Default, m_groupCount), m_end, m_cacheIt) \
+ && qt_printInfo(*this)));
+#else
+# define QT_QML_VERIFY_LISTCOMPOSITOR
+#endif
+
+//#define QT_QML_TRACE_LISTCOMPOSITOR(args) qDebug() << m_end.index[1] << m_end.index[0] << Q_FUNC_INFO args;
+#define QT_QML_TRACE_LISTCOMPOSITOR(args)
+
+QQuickListCompositor::iterator &QQuickListCompositor::iterator::operator +=(int difference)
+{
+ Q_ASSERT(difference >= 0);
+ while (!(range->flags & groupFlag)) {
+ incrementIndexes(range->count - offset);
+ offset = 0;
+ range = range->next;
+ }
+ decrementIndexes(offset);
+ offset += difference;
+ while (offset >= range->count || !(range->flags & groupFlag)) {
+ if (range->flags & groupFlag)
+ offset -= range->count;
+ incrementIndexes(range->count);
+ range = range->next;
+ }
+ incrementIndexes(offset);
+ return *this;
+}
+
+QQuickListCompositor::iterator &QQuickListCompositor::iterator::operator -=(int difference)
+{
+ Q_ASSERT(difference >= 0);
+ while (!(range->flags & groupFlag)) {
+ decrementIndexes(offset);
+ range = range->previous;
+ offset = range->count;
+ }
+ decrementIndexes(offset);
+ offset -= difference;
+ while (offset < 0) {
+ range = range->previous;
+ if (range->flags & groupFlag)
+ offset += range->count;
+ decrementIndexes(range->count);
+ }
+ incrementIndexes(offset);
+ return *this;
+}
+
+QQuickListCompositor::insert_iterator &QQuickListCompositor::insert_iterator::operator +=(int difference)
+{
+ Q_ASSERT(difference >= 0);
+ while (!(range->flags & groupFlag)) {
+ incrementIndexes(range->count - offset);
+ offset = 0;
+ range = range->next;
+ }
+ decrementIndexes(offset);
+ offset += difference;
+ while (offset > range->count
+ || (offset == range->count && !range->append() && offset > 0)
+ || (!(range->flags & groupFlag) && offset > 0)) {
+ Q_ASSERT(range->flags);
+ if (range->flags & groupFlag)
+ offset -= range->count;
+ incrementIndexes(range->count);
+ range = range->next;
+ }
+ incrementIndexes(offset);
+ return *this;
+}
+
+QQuickListCompositor::insert_iterator &QQuickListCompositor::insert_iterator::operator -=(int difference)
+{
+ Q_ASSERT(difference >= 0);
+ while (!(range->flags & groupFlag) && range->previous->flags) {
+ decrementIndexes(offset);
+ range = range->previous;
+ offset = (range->flags & (GroupMask | CacheFlag)) ? range->count : 0;
+ }
+ decrementIndexes(offset);
+ offset -= difference;
+ while (offset < 0) {
+ range = range->previous;
+ if (range->flags & groupFlag)
+ offset += range->count;
+ decrementIndexes(range->count);
+ }
+ incrementIndexes(offset);
+ for (Range *previous = range->previous; offset == 0 && previous->prepend(); previous = previous->previous) {
+ if (previous->append() && previous->inGroup()) {
+ offset = previous->count;
+ range = previous;
+ } else if (!previous->inGroup()) {
+ break;
+ }
+ }
+
+ return *this;
+}
+
+QQuickListCompositor::QQuickListCompositor()
+ : m_end(m_ranges.next, 0, Default, 2)
+ , m_cacheIt(m_end)
+ , m_groupCount(2)
+ , m_defaultFlags(PrependFlag | DefaultFlag)
+ , m_removeFlags(AppendFlag | PrependFlag | GroupMask)
+{
+}
+
+QQuickListCompositor::~QQuickListCompositor()
+{
+ for (Range *next, *range = m_ranges.next; range != &m_ranges; range = next) {
+ next = range->next;
+ delete range;
+ }
+}
+
+inline QQuickListCompositor::Range *QQuickListCompositor::insert(
+ Range *before, void *list, int index, int count, uint flags)
+{
+ return new Range(before, list, index, count, flags);
+}
+
+inline QQuickListCompositor::Range *QQuickListCompositor::erase(
+ Range *range)
+{
+ Range *next = range->next;
+ next->previous = range->previous;
+ next->previous->next = range->next;
+ delete range;
+ return next;
+}
+
+void QQuickListCompositor::setGroupCount(int count)
+{
+ m_groupCount = count;
+ m_end = iterator(&m_ranges, 0, Default, m_groupCount);
+ m_cacheIt = m_end;
+}
+
+int QQuickListCompositor::count(Group group) const
+{
+ return m_end.index[group];
+}
+
+QQuickListCompositor::iterator QQuickListCompositor::find(Group group, int index)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< group << index)
+ Q_ASSERT(index >=0 && index < count(group));
+ if (m_cacheIt == m_end) {
+ m_cacheIt = iterator(m_ranges.next, 0, group, m_groupCount);
+ m_cacheIt += index;
+ } else {
+ const int offset = index - m_cacheIt.index[group];
+ m_cacheIt.setGroup(group);
+ if (offset > 0) {
+ m_cacheIt += offset;
+ } else if (offset < 0) {
+ m_cacheIt -= -offset;
+ } else if (offset == 0) {
+ m_cacheIt -= 0;
+ m_cacheIt += 0;
+ }
+ }
+ Q_ASSERT(m_cacheIt.index[group] == index);
+ Q_ASSERT(m_cacheIt->inGroup(group));
+ QT_QML_VERIFY_LISTCOMPOSITOR
+ return m_cacheIt;
+}
+
+QQuickListCompositor::iterator QQuickListCompositor::find(Group group, int index) const
+{
+ return const_cast<QQuickListCompositor *>(this)->find(group, index);
+}
+
+QQuickListCompositor::insert_iterator QQuickListCompositor::findInsertPosition(Group group, int index)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< group << index)
+ Q_ASSERT(index >=0 && index <= count(group));
+ insert_iterator it;
+ if (m_cacheIt == m_end) {
+ it = iterator(m_ranges.next, 0, group, m_groupCount);
+ it += index;
+ } else {
+ const int offset = index - m_cacheIt.index[group];
+ it = m_cacheIt;
+ it.setGroup(group);
+ if (offset > 0) {
+ it += offset;
+ } else if (offset < 0) {
+ it -= -offset;
+ } else if (offset == 0) {
+ it -= 0;
+ it += 0;
+ }
+ }
+ Q_ASSERT(it.index[group] == index);
+ return it;
+}
+
+QQuickListCompositor::iterator QQuickListCompositor::begin(Group group)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< group)
+ m_cacheIt = iterator(m_ranges.next, 0, group, m_groupCount);
+ m_cacheIt += 0;
+ return m_cacheIt;
+}
+
+void QQuickListCompositor::append(
+ void *list, int index, int count, uint flags, QVector<Insert> *inserts)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << index << count << flags)
+ insert(m_end, list, index, count, flags, inserts);
+}
+
+void QQuickListCompositor::insert(
+ Group group, int before, void *list, int index, int count, uint flags, QVector<Insert> *inserts)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< group << before << list << index << count << flags)
+ insert(findInsertPosition(group, before), list, index, count, flags, inserts);
+}
+
+QQuickListCompositor::iterator QQuickListCompositor::insert(
+ iterator before, void *list, int index, int count, uint flags, QVector<Insert> *inserts)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< before << list << index << count << flags)
+ if (inserts) {
+ inserts->append(Insert(before, count, flags & GroupMask));
+ }
+ if (before.offset > 0) {
+ *before = insert(
+ *before, before->list, before->index, before.offset, before->flags & ~AppendFlag)->next;
+ before->index += before.offset;
+ before->count -= before.offset;
+ before.offset = 0;
+ }
+
+ if (!(flags & AppendFlag) && *before != m_ranges.next
+ && before->previous->list == list
+ && before->previous->flags == flags
+ && (!list || before->previous->end() == index)) {
+ before->previous->count += count;
+ before.incrementIndexes(count, flags);
+ } else {
+ *before = insert(*before, list, index, count, flags);
+ before.offset = 0;
+ }
+
+ if (!(flags & AppendFlag) && before->next != &m_ranges
+ && before->list == before->next->list
+ && before->flags == before->next->flags
+ && (!list || before->end() == before->next->index)) {
+ before->next->index = before->index;
+ before->next->count += before->count;
+ *before = erase(*before);
+ }
+
+ m_end.incrementIndexes(count, flags);
+ m_cacheIt = before;
+ QT_QML_VERIFY_LISTCOMPOSITOR
+ return before;
+}
+
+void QQuickListCompositor::setFlags(
+ Group fromGroup, int from, int count, Group group, int flags, QVector<Insert> *inserts)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< group << index << count << flags)
+ setFlags(find(fromGroup, from), count, group, flags, inserts);
+}
+
+void QQuickListCompositor::setFlags(
+ iterator from, int count, Group group, uint flags, QVector<Insert> *inserts)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< from << count << flags)
+ if (!flags || !count)
+ return;
+
+ if (from != group) {
+ from.incrementIndexes(from->count - from.offset);
+ from.offset = 0;
+ *from = from->next;
+ } else if (from.offset > 0) {
+ *from = insert(*from, from->list, from->index, from.offset, from->flags & ~AppendFlag)->next;
+ from->index += from.offset;
+ from->count -= from.offset;
+ from.offset = 0;
+ }
+
+ for (; count > 0; *from = from->next) {
+ if (from != from.group) {
+ from.incrementIndexes(from->count);
+ continue;
+ }
+ const int difference = qMin(count, from->count);
+ count -= difference;
+
+ const uint insertFlags = ~from->flags & flags;
+ const uint setFlags = (from->flags | flags) & ~AppendFlag;
+ if (insertFlags && inserts)
+ inserts->append(Insert(from, difference, insertFlags | (from->flags & CacheFlag)));
+ m_end.incrementIndexes(difference, insertFlags);
+ from.incrementIndexes(difference, setFlags);
+
+ if (from->previous != &m_ranges
+ && from->previous->list == from->list
+ && (!from->list || from->previous->end() == from->index)
+ && from->previous->flags == setFlags) {
+ from->previous->count += difference;
+ from->index += difference;
+ from->count -= difference;
+ if (from->count == 0) {
+ if (from->append())
+ from->previous->flags |= AppendFlag;
+ *from = erase(*from)->previous;
+ continue;
+ } else {
+ break;
+ }
+ } else if (!insertFlags) {
+ from.incrementIndexes(from->count - difference);
+ continue;
+ } else if (difference < from->count) {
+ *from = insert(*from, from->list, from->index, difference, setFlags)->next;
+ from->index += difference;
+ from->count -= difference;
+ } else {
+ from->flags |= flags;
+ continue;
+ }
+ from.incrementIndexes(from->count);
+ }
+
+ if (from->previous != &m_ranges
+ && from->previous->list == from->list
+ && (!from->list || from->previous->end() == from->index)
+ && from->previous->flags == (from->flags & ~AppendFlag)) {
+ from.offset = from->previous->count;
+ from->previous->count += from->count;
+ from->previous->flags = from->flags;
+ *from = erase(*from)->previous;
+ }
+ m_cacheIt = from;
+ QT_QML_VERIFY_LISTCOMPOSITOR
+}
+
+void QQuickListCompositor::clearFlags(
+ Group fromGroup, int from, int count, Group group, uint flags, QVector<Remove> *removes)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< group << index << count << flags)
+ clearFlags(find(fromGroup, from), count, group, flags, removes);
+}
+
+void QQuickListCompositor::clearFlags(
+ iterator from, int count, Group group, uint flags, QVector<Remove> *removes)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< from << count << flags)
+ if (!flags || !count)
+ return;
+
+ const bool clearCache = flags & CacheFlag;
+
+ if (from != group) {
+ from.incrementIndexes(from->count - from.offset);
+ from.offset = 0;
+ *from = from->next;
+ } else if (from.offset > 0) {
+ *from = insert(*from, from->list, from->index, from.offset, from->flags & ~AppendFlag)->next;
+ from->index += from.offset;
+ from->count -= from.offset;
+ from.offset = 0;
+ }
+
+ for (; count > 0; *from = from->next) {
+ if (from != group) {
+ from.incrementIndexes(from->count);
+ continue;
+ }
+ const int difference = qMin(count, from->count);
+ count -= difference;
+
+ const uint removeFlags = from->flags & flags & ~(AppendFlag | PrependFlag);
+ const uint clearedFlags = from->flags & ~(flags | AppendFlag | UnresolvedFlag);
+ if (removeFlags && removes) {
+ const int maskedFlags = clearCache
+ ? (removeFlags & ~CacheFlag)
+ : (removeFlags | (from->flags & CacheFlag));
+ if (maskedFlags)
+ removes->append(Remove(from, difference, maskedFlags));
+ }
+ m_end.decrementIndexes(difference, removeFlags);
+ from.incrementIndexes(difference, clearedFlags);
+
+ if (from->previous != &m_ranges
+ && from->previous->list == from->list
+ && (!from->list || clearedFlags == CacheFlag || from->previous->end() == from->index)
+ && from->previous->flags == clearedFlags) {
+ from->previous->count += difference;
+ from->index += difference;
+ from->count -= difference;
+ if (from->count == 0) {
+ if (from->append())
+ from->previous->flags |= AppendFlag;
+ *from = erase(*from)->previous;
+ } else {
+ from.incrementIndexes(from->count);
+ }
+ } else if (difference < from->count) {
+ if (clearedFlags)
+ *from = insert(*from, from->list, from->index, difference, clearedFlags)->next;
+ from->index += difference;
+ from->count -= difference;
+ from.incrementIndexes(from->count);
+ } else if (clearedFlags) {
+ from->flags &= ~flags;
+ } else {
+ *from = erase(*from)->previous;
+ }
+ }
+
+ if (*from != &m_ranges && from->previous != &m_ranges
+ && from->previous->list == from->list
+ && (!from->list || from->previous->end() == from->index)
+ && from->previous->flags == (from->flags & ~AppendFlag)) {
+ from.offset = from->previous->count;
+ from->previous->count += from->count;
+ from->previous->flags = from->flags;
+ *from = erase(*from)->previous;
+ }
+ m_cacheIt = from;
+ QT_QML_VERIFY_LISTCOMPOSITOR
+}
+
+void QQuickListCompositor::removeList(void *list, QVector<Remove> *removes, bool destroyed)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << destroyed)
+ for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
+ if (it->list == list) {
+ const int flags = it->flags & (GroupMask | CacheFlag);
+ if (flags) {
+ removes->append(Remove(it, it->count, flags));
+ m_end.decrementIndexes(it->count, flags);
+ }
+ if (destroyed)
+ it->list = 0;
+ if (it->inCache()) {
+ it->flags = CacheFlag;
+ it.cacheIndex += it->count;
+ } else {
+ *it = erase(*it)->previous;
+ }
+ } else {
+ it.incrementIndexes(it->count);
+ }
+ }
+ m_cacheIt = m_end;
+ QT_QML_VERIFY_LISTCOMPOSITOR
+}
+
+bool QQuickListCompositor::verifyMoveTo(
+ Group fromGroup, int from, Group toGroup, int to, int count, Group group) const
+{
+ if (group != toGroup) {
+ // determine how many items from the destination group intersect with the source group.
+ iterator fromIt = find(fromGroup, from);
+
+ int intersectingCount = 0;
+
+ for (; count > 0; *fromIt = fromIt->next) {
+ if (*fromIt == &m_ranges)
+ return false;
+ if (!fromIt->inGroup(group))
+ continue;
+ if (fromIt->inGroup(toGroup))
+ intersectingCount += qMin(count, fromIt->count - fromIt.offset);
+ count -= fromIt->count - fromIt.offset;
+ fromIt.offset = 0;
+ }
+ count = intersectingCount;
+ }
+
+ return to >= 0 && to + count <= m_end.index[toGroup];
+}
+
+void QQuickListCompositor::move(
+ Group fromGroup,
+ int from,
+ Group toGroup,
+ int to,
+ int count,
+ Group group,
+ QVector<Remove> *removes,
+ QVector<Insert> *inserts)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< fromGroup << from << toGroup << to << count)
+ Q_ASSERT(count != 0);
+ Q_ASSERT(from >=0 && from + count <= m_end.index[toGroup]);
+ Q_ASSERT(verifyMoveTo(fromGroup, from, toGroup, to, count, group));
+
+ iterator fromIt = find(fromGroup, from);
+ if (fromIt != group) {
+ fromIt.incrementIndexes(fromIt->count - fromIt.offset);
+ fromIt.offset = 0;
+ *fromIt = fromIt->next;
+ } else if (fromIt.offset > 0) {
+ *fromIt = insert(
+ *fromIt, fromIt->list, fromIt->index, fromIt.offset, fromIt->flags & ~AppendFlag)->next;
+ fromIt->index += fromIt.offset;
+ fromIt->count -= fromIt.offset;
+ fromIt.offset = 0;
+ }
+
+ Range movedFlags;
+ for (int moveId = 0; count > 0;) {
+ if (fromIt != group) {
+ fromIt.incrementIndexes(fromIt->count);
+ *fromIt = fromIt->next;
+ continue;
+ }
+ int difference = qMin(count, fromIt->count);
+
+ new Range(
+ &movedFlags,
+ fromIt->list,
+ fromIt->index,
+ difference,
+ fromIt->flags & ~(PrependFlag | AppendFlag));
+ if (removes)
+ removes->append(Remove(fromIt, difference, fromIt->flags, moveId++));
+ count -= difference;
+ fromIt->count -= difference;
+
+ int removeIndex = fromIt->index;
+ if (fromIt->prepend()
+ && fromIt->previous != &m_ranges
+ && fromIt->previous->flags == PrependFlag
+ && fromIt->previous->list == fromIt->list
+ && fromIt->previous->end() == fromIt->index) {
+ fromIt->previous->count += difference;
+ } else if (fromIt->prepend()) {
+ *fromIt = insert(*fromIt, fromIt->list, removeIndex, difference, PrependFlag)->next;
+ }
+ fromIt->index += difference;
+
+ if (fromIt->count == 0) {
+ if (fromIt->append())
+ fromIt->previous->flags |= AppendFlag;
+ *fromIt = erase(*fromIt);
+
+ if (*fromIt != m_ranges.next && fromIt->flags == PrependFlag
+ && fromIt->previous != &m_ranges
+ && fromIt->previous->flags == PrependFlag
+ && fromIt->previous->list == fromIt->list
+ && fromIt->previous->end() == fromIt->index) {
+ fromIt.incrementIndexes(fromIt->count);
+ fromIt->previous->count += fromIt->count;
+ *fromIt = erase(*fromIt);
+ }
+ } else if (count > 0) {
+ *fromIt = fromIt->next;
+ }
+ }
+
+ if (*fromIt != m_ranges.next
+ && *fromIt != &m_ranges
+ && fromIt->previous->list == fromIt->list
+ && (!fromIt->list || fromIt->previous->end() == fromIt->index)
+ && fromIt->previous->flags == (fromIt->flags & ~AppendFlag)) {
+ if (fromIt == fromIt.group)
+ fromIt.offset = fromIt->previous->count;
+ fromIt.offset = fromIt->previous->count;
+ fromIt->previous->count += fromIt->count;
+ fromIt->previous->flags = fromIt->flags;
+ *fromIt = erase(*fromIt)->previous;
+ }
+
+ insert_iterator toIt = fromIt;
+ toIt.setGroup(toGroup);
+ const int difference = to - toIt.index[toGroup];
+ if (difference > 0)
+ toIt += difference;
+ else
+ toIt -= -difference;
+
+ if (toIt.offset > 0) {
+ *toIt = insert(*toIt, toIt->list, toIt->index, toIt.offset, toIt->flags & ~AppendFlag)->next;
+ toIt->index += toIt.offset;
+ toIt->count -= toIt.offset;
+ toIt.offset = 0;
+ }
+
+ for (Range *range = movedFlags.previous; range != &movedFlags; range = range->previous) {
+ if (*toIt != &m_ranges
+ && range->list == toIt->list
+ && (!range->list || range->end() == toIt->index)
+ && range->flags == (toIt->flags & ~AppendFlag)) {
+ toIt->index -= range->count;
+ toIt->count += range->count;
+ } else {
+ *toIt = insert(*toIt, range->list, range->index, range->count, range->flags);
+ }
+ }
+
+ if (*toIt != m_ranges.next
+ && toIt->previous->list == toIt->list
+ && (!toIt->list || (toIt->previous->end() == toIt->index && toIt->previous->flags == (toIt->flags & ~AppendFlag)))) {
+ toIt.offset = toIt->previous->count;
+ toIt->previous->count += toIt->count;
+ toIt->previous->flags = toIt->flags;
+ *toIt = erase(*toIt)->previous;
+ }
+ Insert insert(toIt, 0, 0, 0);
+ for (Range *next, *range = movedFlags.next; range != &movedFlags; range = next) {
+ insert.count = range->count;
+ insert.flags = range->flags;
+ if (inserts)
+ inserts->append(insert);
+ for (int i = 0; i < m_groupCount; ++i) {
+ if (insert.inGroup(i))
+ insert.index[i] += range->count;
+ }
+ ++insert.moveId;
+ next = range->next;
+ delete range;
+ }
+
+ m_cacheIt = toIt;
+ QT_QML_VERIFY_LISTCOMPOSITOR
+}
+
+void QQuickListCompositor::clear()
+{
+ QT_QML_TRACE_LISTCOMPOSITOR( )
+ for (Range *range = m_ranges.next; range != &m_ranges; range = erase(range)) {}
+ m_end = iterator(m_ranges.next, 0, Default, m_groupCount);
+ m_cacheIt = m_end;
+}
+
+void QQuickListCompositor::listItemsInserted(
+ QVector<Insert> *translatedInsertions,
+ void *list,
+ const QVector<QQuickChangeSet::Insert> &insertions,
+ const QVector<MovedFlags> *movedFlags)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << insertions)
+ for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
+ if (it->list != list || it->flags == CacheFlag) {
+ it.incrementIndexes(it->count);
+ continue;
+ } else if (it->flags & MovedFlag) {
+ it->flags &= ~MovedFlag;
+ it.incrementIndexes(it->count);
+ continue;
+ }
+ foreach (const QQuickChangeSet::Insert &insertion, insertions) {
+ int offset = insertion.index - it->index;
+ if ((offset > 0 && offset < it->count)
+ || (offset == 0 && it->prepend())
+ || (offset == it->count && it->append())) {
+ if (it->prepend()) {
+ uint flags = m_defaultFlags;
+ if (insertion.isMove()) {
+ for (QVector<MovedFlags>::const_iterator move = movedFlags->begin();
+ move != movedFlags->end();
+ ++move) {
+ if (move->moveId == insertion.moveId) {
+ flags = move->flags;
+ break;
+ }
+ }
+ }
+ if (flags & ~(AppendFlag | PrependFlag)) {
+ Insert translatedInsert(it, insertion.count, flags, insertion.moveId);
+ for (int i = 0; i < m_groupCount; ++i) {
+ if (it->inGroup(i))
+ translatedInsert.index[i] += offset;
+ }
+ translatedInsertions->append(translatedInsert);
+ }
+ if ((it->flags & ~AppendFlag) == flags) {
+ it->count += insertion.count;
+ } else if (offset == 0
+ && it->previous != &m_ranges
+ && it->previous->list == list
+ && it->previous->end() == insertion.index
+ && it->previous->flags == flags) {
+ it->previous->count += insertion.count;
+ it->index += insertion.count;
+ it.incrementIndexes(insertion.count);
+ } else {
+ if (offset > 0) {
+ it.incrementIndexes(offset);
+ *it = insert(*it, it->list, it->index, offset, it->flags & ~AppendFlag)->next;
+ }
+ *it = insert(*it, it->list, insertion.index, insertion.count, flags)->next;
+ it.incrementIndexes(insertion.count, flags);
+ it->index += offset + insertion.count;
+ it->count -= offset;
+ }
+ m_end.incrementIndexes(insertion.count, flags);
+ } else {
+ if (offset > 0) {
+ *it = insert(*it, it->list, it->index, offset, it->flags)->next;
+ it->index += offset;
+ it->count -= offset;
+ }
+ it->index += insertion.count;
+ }
+ } else if (offset <= 0) {
+ it->index += insertion.count;
+ }
+ }
+ it.incrementIndexes(it->count);
+ }
+ m_cacheIt = m_end;
+ QT_QML_VERIFY_LISTCOMPOSITOR
+}
+
+void QQuickListCompositor::listItemsInserted(
+ void *list, int index, int count, QVector<Insert> *translatedInsertions)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << index << count)
+ Q_ASSERT(count > 0);
+
+ QVector<QQuickChangeSet::Insert> insertions;
+ insertions.append(QQuickChangeSet::Insert(index, count));
+
+ listItemsInserted(translatedInsertions, list, insertions);
+}
+
+void QQuickListCompositor::listItemsRemoved(
+ QVector<Remove> *translatedRemovals,
+ void *list,
+ QVector<QQuickChangeSet::Remove> *removals,
+ QVector<QQuickChangeSet::Insert> *insertions,
+ QVector<MovedFlags> *movedFlags, int moveId)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << *removals)
+
+ for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
+ if (it->list != list || it->flags == CacheFlag) {
+ it.incrementIndexes(it->count);
+ continue;
+ }
+ bool removed = false;
+ for (QVector<QQuickChangeSet::Remove>::iterator removal = removals->begin();
+ !removed && removal != removals->end();
+ ++removal) {
+ int relativeIndex = removal->index - it->index;
+ int itemsRemoved = removal->count;
+ if (relativeIndex + removal->count > 0 && relativeIndex < it->count) {
+ const int offset = qMax(0, relativeIndex);
+ int removeCount = qMin(it->count, relativeIndex + removal->count) - offset;
+ it->count -= removeCount;
+ int removeFlags = it->flags & m_removeFlags;
+ Remove translatedRemoval(it, removeCount, it->flags);
+ for (int i = 0; i < m_groupCount; ++i) {
+ if (it->inGroup(i))
+ translatedRemoval.index[i] += offset;
+ }
+ if (removal->isMove()) {
+ QVector<QQuickChangeSet::Insert>::iterator insertion = insertions->begin();
+ for (; insertion != insertions->end() && insertion->moveId != removal->moveId;
+ ++insertion) {}
+ Q_ASSERT(insertion != insertions->end());
+ Q_ASSERT(insertion->count == removal->count);
+
+ if (relativeIndex < 0) {
+ int splitMoveId = ++moveId;
+ removal = removals->insert(removal, QQuickChangeSet::Remove(
+ removal->index, -relativeIndex, splitMoveId));
+ ++removal;
+ removal->count -= -relativeIndex;
+ insertion = insertions->insert(insertion, QQuickChangeSet::Insert(
+ insertion->index, -relativeIndex, splitMoveId));
+ ++insertion;
+ insertion->index += -relativeIndex;
+ insertion->count -= -relativeIndex;
+ }
+
+ if (it->prepend()) {
+ removeFlags |= it->flags & CacheFlag;
+ translatedRemoval.moveId = ++moveId;
+ movedFlags->append(MovedFlags(moveId, it->flags & ~AppendFlag));
+
+ if (removeCount < removal->count) {
+ removal = removals->insert(removal, QQuickChangeSet::Remove(
+ removal->index, removeCount, translatedRemoval.moveId));
+ ++removal;
+ insertion = insertions->insert(insertion, QQuickChangeSet::Insert(
+ insertion->index, removeCount, translatedRemoval.moveId));
+ ++insertion;
+
+ removal->count -= removeCount;
+ insertion->index += removeCount;
+ insertion->count -= removeCount;
+ } else {
+ removal->moveId = translatedRemoval.moveId;
+ insertion->moveId = translatedRemoval.moveId;
+ }
+ } else {
+ if (offset > 0) {
+ *it = insert(*it, it->list, it->index, offset, it->flags & ~AppendFlag)->next;
+ it->index += offset;
+ it->count -= offset;
+ it.incrementIndexes(offset);
+ }
+ if (it->previous != &m_ranges
+ && it->previous->list == it->list
+ && it->end() == insertion->index
+ && it->previous->flags == (it->flags | MovedFlag)) {
+ it->previous->count += removeCount;
+ } else {
+ *it = insert(*it, it->list, insertion->index, removeCount, it->flags | MovedFlag)->next;
+ }
+ translatedRemoval.flags = 0;
+ removeFlags = 0;
+ }
+ } else if (it->inCache()) {
+ if (offset > 0) {
+ *it = insert(*it, it->list, it->index, offset, it->flags & ~AppendFlag)->next;
+ it->index += offset;
+ it->count -= offset;
+ it.incrementIndexes(offset);
+ }
+ if (it->previous != &m_ranges
+ && it->previous->list == it->list
+ && it->previous->flags == CacheFlag) {
+ it->previous->count += removeCount;
+ } else {
+ *it = insert(*it, it->list, -1, removeCount, CacheFlag)->next;
+ }
+ it.index[Cache] += removeCount;
+ }
+ if (removeFlags & GroupMask)
+ translatedRemovals->append(translatedRemoval);
+ m_end.decrementIndexes(removeCount, removeFlags);
+ if (it->count == 0 && !it->append()) {
+ *it = erase(*it)->previous;
+ removed = true;
+ } else if (relativeIndex <= 0) {
+ it->index = removal->index;
+ }
+ } else if (relativeIndex < 0) {
+ it->index -= itemsRemoved;
+
+ if (it->previous != &m_ranges
+ && it->previous->list == it->list
+ && it->previous->end() == it->index
+ && it->previous->flags == (it->flags & ~AppendFlag)) {
+ it.decrementIndexes(it->previous->count);
+ it->previous->count += it->count;
+ it->previous->flags = it->flags;
+ *it = erase(*it)->previous;
+ }
+ }
+ }
+ if (it->flags == CacheFlag && it->next->flags == CacheFlag && it->next->list == it->list) {
+ it.index[Cache] += it->next->count;
+ it->count += it->next->count;
+ erase(it->next);
+ } else if (!removed) {
+ it.incrementIndexes(it->count);
+ }
+ }
+ m_cacheIt = m_end;
+ QT_QML_VERIFY_LISTCOMPOSITOR
+}
+
+void QQuickListCompositor::listItemsRemoved(
+ void *list, int index, int count, QVector<Remove> *translatedRemovals)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << index << count)
+ Q_ASSERT(count >= 0);
+
+ QVector<QQuickChangeSet::Remove> removals;
+ removals.append(QQuickChangeSet::Remove(index, count));
+ listItemsRemoved(translatedRemovals, list, &removals, 0, 0, 0);
+}
+
+void QQuickListCompositor::listItemsMoved(
+ void *list,
+ int from,
+ int to,
+ int count,
+ QVector<Remove> *translatedRemovals,
+ QVector<Insert> *translatedInsertions)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << from << to << count)
+ Q_ASSERT(count >= 0);
+
+ QVector<QQuickChangeSet::Remove> removals;
+ QVector<QQuickChangeSet::Insert> insertions;
+ QVector<MovedFlags> movedFlags;
+ removals.append(QQuickChangeSet::Remove(from, count, 0));
+ insertions.append(QQuickChangeSet::Insert(to, count, 0));
+
+ listItemsRemoved(translatedRemovals, list, &removals, &insertions, &movedFlags, 0);
+ listItemsInserted(translatedInsertions, list, insertions, &movedFlags);
+}
+
+void QQuickListCompositor::listItemsChanged(
+ QVector<Change> *translatedChanges,
+ void *list,
+ const QVector<QQuickChangeSet::Change> &changes)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << changes)
+ for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
+ if (it->list != list || it->flags == CacheFlag) {
+ it.incrementIndexes(it->count);
+ continue;
+ } else if (!it->inGroup()) {
+ continue;
+ }
+ foreach (const QQuickChangeSet::Change &change, changes) {
+ const int offset = change.index - it->index;
+ if (offset + change.count > 0 && offset < it->count) {
+ const int changeOffset = qMax(0, offset);
+ const int changeCount = qMin(it->count, offset + change.count) - changeOffset;
+
+ Change translatedChange(it, changeCount, it->flags);
+ for (int i = 0; i < m_groupCount; ++i) {
+ if (it->inGroup(i))
+ translatedChange.index[i] += changeOffset;
+ }
+ translatedChanges->append(translatedChange);
+ }
+ }
+ it.incrementIndexes(it->count);
+ }
+}
+
+void QQuickListCompositor::listItemsChanged(
+ void *list, int index, int count, QVector<Change> *translatedChanges)
+{
+ QT_QML_TRACE_LISTCOMPOSITOR(<< list << index << count)
+ Q_ASSERT(count >= 0);
+ QVector<QQuickChangeSet::Change> changes;
+ changes.append(QQuickChangeSet::Change(index, count));
+ listItemsChanged(translatedChanges, list, changes);
+}
+
+void QQuickListCompositor::listChanged(
+ void *list,
+ const QQuickChangeSet &changeSet,
+ QVector<Remove> *translatedRemovals,
+ QVector<Insert> *translatedInsertions,
+ QVector<Change> *translatedChanges)
+{
+ QVector<QQuickChangeSet::Remove> removals = changeSet.removes();
+ QVector<QQuickChangeSet::Insert> insertions = changeSet.inserts();
+ QVector<MovedFlags> movedFlags;
+ listItemsRemoved(translatedRemovals, list, &removals, &insertions, &movedFlags, changeSet.moveCounter());
+ listItemsInserted(translatedInsertions, list, insertions, &movedFlags);
+ listItemsChanged(translatedChanges, list, changeSet.changes());
+}
+
+void QQuickListCompositor::transition(
+ Group from,
+ Group to,
+ QVector<QQuickChangeSet::Remove> *removes,
+ QVector<QQuickChangeSet::Insert> *inserts)
+{
+ int removeCount = 0;
+ for (iterator it(m_ranges.next, 0, Default, m_groupCount); *it != &m_ranges; *it = it->next) {
+ if (it == from && it != to) {
+ removes->append(QQuickChangeSet::Remove(it.index[from]- removeCount, it->count));
+ removeCount += it->count;
+ } else if (it != from && it == to) {
+ inserts->append(QQuickChangeSet::Insert(it.index[to], it->count));
+ }
+ it.incrementIndexes(it->count);
+ }
+}
+
+QDebug operator <<(QDebug debug, const QQuickListCompositor::Group &group)
+{
+ switch (group) {
+ case QQuickListCompositor::Cache: return debug << "Cache";
+ case QQuickListCompositor::Default: return debug << "Default";
+ default: return (debug.nospace() << "Group" << int(group)).space();
+ }
+
+}
+
+QDebug operator <<(QDebug debug, const QQuickListCompositor::Range &range)
+{
+ (debug.nospace()
+ << "Range("
+ << range.list) << " "
+ << range.index << " "
+ << range.count << " "
+ << (range.isUnresolved() ? "U" : "0")
+ << (range.append() ? "A" : "0")
+ << (range.prepend() ? "P" : "0");
+ for (int i = QQuickListCompositor::MaximumGroupCount - 1; i >= 2; --i)
+ debug << (range.inGroup(i) ? "1" : "0");
+ return (debug
+ << (range.inGroup(QQuickListCompositor::Default) ? "D" : "0")
+ << (range.inGroup(QQuickListCompositor::Cache) ? "C" : "0"));
+}
+
+static void qt_print_indexes(QDebug &debug, int count, const int *indexes)
+{
+ for (int i = count - 1; i >= 0; --i)
+ debug << indexes[i];
+}
+
+QDebug operator <<(QDebug debug, const QQuickListCompositor::iterator &it)
+{
+ (debug.nospace() << "iterator(" << it.group).space() << "offset:" << it.offset;
+ qt_print_indexes(debug, it.groupCount, it.index);
+ return ((debug << **it).nospace() << ")").space();
+}
+
+static QDebug qt_print_change(QDebug debug, const char *name, const QQuickListCompositor::Change &change)
+{
+ debug.nospace() << name << "(" << change.moveId << " " << change.count << " ";
+ for (int i = QQuickListCompositor::MaximumGroupCount - 1; i >= 2; --i)
+ debug << (change.inGroup(i) ? "1" : "0");
+ debug << (change.inGroup(QQuickListCompositor::Default) ? "D" : "0")
+ << (change.inGroup(QQuickListCompositor::Cache) ? "C" : "0");
+ int i = QQuickListCompositor::MaximumGroupCount - 1;
+ for (; i >= 0 && !change.inGroup(i); --i) {}
+ for (; i >= 0; --i)
+ debug << " " << change.index[i];
+ return (debug << ")").maybeSpace();
+}
+
+QDebug operator <<(QDebug debug, const QQuickListCompositor::Change &change)
+{
+ return qt_print_change(debug, "Change", change);
+}
+
+QDebug operator <<(QDebug debug, const QQuickListCompositor::Remove &remove)
+{
+ return qt_print_change(debug, "Remove", remove);
+}
+
+QDebug operator <<(QDebug debug, const QQuickListCompositor::Insert &insert)
+{
+ return qt_print_change(debug, "Insert", insert);
+}
+
+QDebug operator <<(QDebug debug, const QQuickListCompositor &list)
+{
+ int indexes[QQuickListCompositor::MaximumGroupCount];
+ for (int i = 0; i < QQuickListCompositor::MaximumGroupCount; ++i)
+ indexes[i] = 0;
+ debug.nospace() << "QQuickListCompositor(";
+ qt_print_indexes(debug, list.m_groupCount, list.m_end.index);
+ for (QQuickListCompositor::Range *range = list.m_ranges.next; range != &list.m_ranges; range = range->next) {
+ (debug << "\n").space();
+ qt_print_indexes(debug, list.m_groupCount, indexes);
+ debug << " " << *range;
+
+ for (int i = 0; i < list.m_groupCount; ++i) {
+ if (range->inGroup(i))
+ indexes[i] += range->count;
+ }
+ }
+ return (debug << ")").maybeSpace();
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquicklistcompositor_p.h b/src/quick/util/qquicklistcompositor_p.h
new file mode 100644
index 0000000000..b12ee8025f
--- /dev/null
+++ b/src/quick/util/qquicklistcompositor_p.h
@@ -0,0 +1,382 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKLISTCOMPOSITOR_P_H
+#define QQUICKLISTCOMPOSITOR_P_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/qvector.h>
+
+#include <private/qquickchangeset_p.h>
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_AUTOTEST_EXPORT QQuickListCompositor
+{
+public:
+ enum { MinimumGroupCount = 3, MaximumGroupCount = 11 };
+
+ enum Group
+ {
+ Cache = 0,
+ Default = 1,
+ Persisted = 2
+ };
+
+ enum Flag
+ {
+ CacheFlag = 1 << Cache,
+ DefaultFlag = 1 << Default,
+ PersistedFlag = 1 << Persisted,
+ PrependFlag = 0x10000000,
+ AppendFlag = 0x20000000,
+ UnresolvedFlag = 0x40000000,
+ MovedFlag = 0x80000000,
+ GroupMask = ~(PrependFlag | AppendFlag | UnresolvedFlag | MovedFlag | CacheFlag)
+ };
+
+ class Range
+ {
+ public:
+ Range() : next(this), previous(this), list(0), index(0), count(0), flags(0) {}
+ Range(Range *next, void *list, int index, int count, uint flags)
+ : next(next), previous(next->previous), list(list), index(index), count(count), flags(flags) {
+ next->previous = this; previous->next = this; }
+
+ Range *next;
+ Range *previous;
+ void *list;
+ int index;
+ int count;
+ uint flags;
+
+ inline int start() const { return index; }
+ inline int end() const { return index + count; }
+
+ inline int groups() const { return flags & GroupMask; }
+
+ inline bool inGroup() const { return flags & GroupMask; }
+ inline bool inCache() const { return flags & CacheFlag; }
+ inline bool inGroup(int group) const { return flags & (1 << group); }
+ inline bool isUnresolved() const { return flags & UnresolvedFlag; }
+
+ inline bool prepend() const { return flags & PrependFlag; }
+ inline bool append() const { return flags & AppendFlag; }
+ };
+
+ class Q_AUTOTEST_EXPORT iterator
+ {
+ public:
+ inline iterator();
+ inline iterator(const iterator &it);
+ inline iterator(Range *range, int offset, Group group, int groupCount);
+ inline ~iterator() {}
+
+ bool operator ==(const iterator &it) const { return range == it.range && offset == it.offset; }
+ bool operator !=(const iterator &it) const { return range != it.range || offset != it.offset; }
+
+ bool operator ==(Group group) const { return range->flags & (1 << group); }
+ bool operator !=(Group group) const { return !(range->flags & (1 << group)); }
+
+ Range *&operator *() { return range; }
+ Range * const &operator *() const { return range; }
+ Range *operator ->() { return range; }
+ const Range *operator ->() const { return range; }
+
+ iterator &operator +=(int difference);
+ iterator &operator -=(int difference);
+
+ template<typename T> T *list() const { return static_cast<T *>(range->list); }
+ int modelIndex() const { return range->index + offset; }
+
+ void incrementIndexes(int difference) { incrementIndexes(difference, range->flags); }
+ void decrementIndexes(int difference) { decrementIndexes(difference, range->flags); }
+
+ inline void incrementIndexes(int difference, uint flags);
+ inline void decrementIndexes(int difference, uint flags);
+
+ void setGroup(Group g) { group = g; groupFlag = 1 << g; }
+
+ Range *range;
+ int offset;
+ Group group;
+ int groupFlag;
+ int groupCount;
+ union {
+ struct {
+ int cacheIndex;
+ };
+ int index[MaximumGroupCount];
+ };
+ };
+
+ class Q_AUTOTEST_EXPORT insert_iterator : public iterator
+ {
+ public:
+ inline insert_iterator() {}
+ inline insert_iterator(const iterator &it) : iterator(it) {}
+ inline insert_iterator(Range *, int, Group, int);
+ inline ~insert_iterator() {}
+
+ insert_iterator &operator +=(int difference);
+ insert_iterator &operator -=(int difference);
+ };
+
+ struct Change
+ {
+ inline Change() {}
+ inline Change(iterator it, int count, uint flags, int moveId = -1);
+ int count;
+ uint flags;
+ int moveId;
+ union {
+ struct {
+ int cacheIndex;
+ };
+ int index[MaximumGroupCount];
+ };
+
+ inline bool isMove() const { return moveId >= 0; }
+ inline bool inCache() const { return flags & CacheFlag; }
+ inline bool inGroup() const { return flags & GroupMask; }
+ inline bool inGroup(int group) const { return flags & (CacheFlag << group); }
+
+ inline int groups() const { return flags & GroupMask; }
+ };
+
+ struct Insert : public Change
+ {
+ Insert() {}
+ Insert(iterator it, int count, uint flags, int moveId = -1)
+ : Change(it, count, flags, moveId) {}
+ };
+
+ struct Remove : public Change
+ {
+ Remove() {}
+ Remove(iterator it, int count, uint flags, int moveId = -1)
+ : Change(it, count, flags, moveId) {}
+ };
+
+ QQuickListCompositor();
+ ~QQuickListCompositor();
+
+ int defaultGroups() const { return m_defaultFlags & ~PrependFlag; }
+ void setDefaultGroups(int groups) { m_defaultFlags = groups | PrependFlag; }
+ void setDefaultGroup(Group group) { m_defaultFlags |= (1 << group); }
+ void clearDefaultGroup(Group group) { m_defaultFlags &= ~(1 << group); }
+ void setRemoveGroups(int groups) { m_removeFlags = PrependFlag | AppendFlag | groups; }
+ void setGroupCount(int count);
+
+ int count(Group group) const;
+ iterator find(Group group, int index);
+ iterator find(Group group, int index) const;
+ insert_iterator findInsertPosition(Group group, int index);
+
+ iterator begin(Group group);
+ const iterator &end() { return m_end; }
+
+ void append(void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
+ void insert(Group group, int before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
+ iterator insert(iterator before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = 0);
+
+ void setFlags(Group fromGroup, int from, int count, Group group, int flags, QVector<Insert> *inserts = 0);
+ void setFlags(iterator from, int count, Group group, uint flags, QVector<Insert> *inserts = 0);
+ void setFlags(Group fromGroup, int from, int count, uint flags, QVector<Insert> *inserts = 0) {
+ setFlags(fromGroup, from, count, fromGroup, flags, inserts); }
+ void setFlags(iterator from, int count, uint flags, QVector<Insert> *inserts = 0) {
+ setFlags(from, count, from.group, flags, inserts); }
+
+ void clearFlags(Group fromGroup, int from, int count, Group group, uint flags, QVector<Remove> *removals = 0);
+ void clearFlags(iterator from, int count, Group group, uint flags, QVector<Remove> *removals = 0);
+ void clearFlags(Group fromGroup, int from, int count, uint flags, QVector<Remove> *removals = 0) {
+ clearFlags(fromGroup, from, count, fromGroup, flags, removals); }
+ void clearFlags(iterator from, int count, uint flags, QVector<Remove> *removals = 0) {
+ clearFlags(from, count, from.group, flags, removals); }
+
+ void removeList(void *list, QVector<Remove> *removals, bool destroyed);
+
+ bool verifyMoveTo(Group fromGroup, int from, Group toGroup, int to, int count, Group group) const;
+
+ void move(
+ Group fromGroup,
+ int from,
+ Group toGroup,
+ int to,
+ int count,
+ Group group,
+ QVector<Remove> *removals = 0,
+ QVector<Insert> *inserts = 0);
+ void clear();
+
+ void listItemsInserted(void *list, int index, int count, QVector<Insert> *inserts);
+ void listItemsRemoved(void *list, int index, int count, QVector<Remove> *removals);
+ void listItemsMoved(void *list, int from, int to, int count, QVector<Remove> *removals, QVector<Insert> *inserts);
+ void listItemsChanged(void *list, int index, int count, QVector<Change> *changes);
+ void listChanged(
+ void *list,
+ const QQuickChangeSet &changeSet,
+ QVector<Remove> *removals,
+ QVector<Insert> *inserts,
+ QVector<Change> *changes);
+
+ void transition(
+ Group from,
+ Group to,
+ QVector<QQuickChangeSet::Remove> *removes,
+ QVector<QQuickChangeSet::Insert> *inserts);
+
+private:
+ Range m_ranges;
+ iterator m_end;
+ iterator m_cacheIt;
+ int m_groupCount;
+ int m_defaultFlags;
+ int m_removeFlags;
+
+ inline Range *insert(Range *before, void *list, int index, int count, uint flags);
+ inline Range *erase(Range *range);
+
+ struct MovedFlags
+ {
+ MovedFlags() {}
+ MovedFlags(int moveId, uint flags) : moveId(moveId), flags(flags) {}
+
+ int moveId;
+ uint flags;
+ };
+
+ void listItemsRemoved(
+ QVector<Remove> *translatedRemovals,
+ void *list,
+ QVector<QQuickChangeSet::Remove> *removals,
+ QVector<QQuickChangeSet::Insert> *insertions = 0,
+ QVector<MovedFlags> *movedFlags = 0,
+ int moveId = 0);
+ void listItemsInserted(
+ QVector<Insert> *translatedInsertions,
+ void *list,
+ const QVector<QQuickChangeSet::Insert> &insertions,
+ const QVector<MovedFlags> *movedFlags = 0);
+ void listItemsChanged(
+ QVector<Change> *translatedChanges,
+ void *list,
+ const QVector<QQuickChangeSet::Change> &changes);
+
+ friend Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickListCompositor &list);
+};
+
+inline QQuickListCompositor::iterator::iterator()
+ : range(0), offset(0), group(Default), groupCount(0) {}
+inline QQuickListCompositor::iterator::iterator(const iterator &it)
+ : range(it.range)
+ , offset(it.offset)
+ , group(it.group)
+ , groupFlag(it.groupFlag)
+ , groupCount(it.groupCount)
+{
+ for (int i = 0; i < groupCount; ++i)
+ index[i] = it.index[i];
+}
+
+inline QQuickListCompositor::iterator::iterator(
+ Range *range, int offset, Group group, int groupCount)
+ : range(range)
+ , offset(offset)
+ , group(group)
+ , groupFlag(1 << group)
+ , groupCount(groupCount)
+{
+ for (int i = 0; i < groupCount; ++i)
+ index[i] = 0;
+}
+
+inline void QQuickListCompositor::iterator::incrementIndexes(int difference, uint flags)
+{
+ for (int i = 0; i < groupCount; ++i) {
+ if (flags & (1 << i))
+ index[i] += difference;
+ }
+}
+
+inline void QQuickListCompositor::iterator::decrementIndexes(int difference, uint flags)
+{
+ for (int i = 0; i < groupCount; ++i) {
+ if (flags & (1 << i))
+ index[i] -= difference;
+ }
+}
+
+inline QQuickListCompositor::insert_iterator::insert_iterator(
+ Range *range, int offset, Group group, int groupCount)
+ : iterator(range, offset, group, groupCount) {}
+
+inline QQuickListCompositor::Change::Change(iterator it, int count, uint flags, int moveId)
+ : count(count), flags(flags), moveId(moveId)
+{
+ for (int i = 0; i < MaximumGroupCount; ++i)
+ index[i] = it.index[i];
+}
+
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickListCompositor::Group &group);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickListCompositor::Range &range);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickListCompositor::iterator &it);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickListCompositor::Change &change);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickListCompositor::Remove &remove);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickListCompositor::Insert &insert);
+Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQuickListCompositor &list);
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/quick/util/qquickpackage.cpp b/src/quick/util/qquickpackage.cpp
new file mode 100644
index 0000000000..1939de62e1
--- /dev/null
+++ b/src/quick/util/qquickpackage.cpp
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickpackage_p.h"
+
+#include <private/qobject_p.h>
+#include <private/qqmlguard_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass Package QQuickPackage
+ \inqmlmodule QtQuick 2
+ \ingroup qml-working-with-data
+ \brief Package provides a collection of named items.
+
+ The Package class is used in conjunction with
+ VisualDataModel to enable delegates with a shared context
+ to be provided to multiple views.
+
+ Any item within a Package may be assigned a name via the
+ \l{Package::name}{Package.name} attached property.
+
+ The example below creates a Package containing two named items;
+ \e list and \e grid. The third element in the package (the \l Rectangle) is parented to whichever
+ delegate it should appear in. This allows an item to move
+ between views.
+
+ \snippet examples/declarative/modelviews/package/Delegate.qml 0
+
+ These named items are used as the delegates by the two views who
+ 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}, {declarative/photoviewer}{Photo Viewer example}, QtQml
+*/
+
+/*!
+ \qmlattachedproperty string QtQuick2::Package::name
+ This attached property holds the name of an item within a Package.
+*/
+
+
+class QQuickPackagePrivate : public QObjectPrivate
+{
+public:
+ QQuickPackagePrivate() {}
+
+ struct DataGuard : public QQmlGuard<QObject>
+ {
+ DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QQmlGuard<QObject>&)*this = obj; }
+ QList<DataGuard> *list;
+ void objectDestroyed(QObject *) {
+ // we assume priv will always be destroyed after objectDestroyed calls
+ list->removeOne(*this);
+ }
+ };
+
+ QList<DataGuard> dataList;
+ static void data_append(QQmlListProperty<QObject> *prop, QObject *o) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->append(DataGuard(o, list));
+ }
+ static void data_clear(QQmlListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->clear();
+ }
+ static QObject *data_at(QQmlListProperty<QObject> *prop, int index) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ return list->at(index);
+ }
+ static int data_count(QQmlListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ return list->count();
+ }
+};
+
+QHash<QObject *, QQuickPackageAttached *> QQuickPackageAttached::attached;
+
+QQuickPackageAttached::QQuickPackageAttached(QObject *parent)
+: QObject(parent)
+{
+ attached.insert(parent, this);
+}
+
+QQuickPackageAttached::~QQuickPackageAttached()
+{
+ attached.remove(parent());
+}
+
+QString QQuickPackageAttached::name() const
+{
+ return _name;
+}
+
+void QQuickPackageAttached::setName(const QString &n)
+{
+ _name = n;
+}
+
+QQuickPackage::QQuickPackage(QObject *parent)
+ : QObject(*(new QQuickPackagePrivate), parent)
+{
+}
+
+QQuickPackage::~QQuickPackage()
+{
+ Q_D(QQuickPackage);
+ for (int ii = 0; ii < d->dataList.count(); ++ii) {
+ QObject *obj = d->dataList.at(ii);
+ obj->setParent(this);
+ }
+}
+
+QQmlListProperty<QObject> QQuickPackage::data()
+{
+ Q_D(QQuickPackage);
+ return QQmlListProperty<QObject>(this, &d->dataList, QQuickPackagePrivate::data_append,
+ QQuickPackagePrivate::data_count,
+ QQuickPackagePrivate::data_at,
+ QQuickPackagePrivate::data_clear);
+}
+
+bool QQuickPackage::hasPart(const QString &name)
+{
+ Q_D(QQuickPackage);
+ for (int ii = 0; ii < d->dataList.count(); ++ii) {
+ QObject *obj = d->dataList.at(ii);
+ QQuickPackageAttached *a = QQuickPackageAttached::attached.value(obj);
+ if (a && a->name() == name)
+ return true;
+ }
+ return false;
+}
+
+QObject *QQuickPackage::part(const QString &name)
+{
+ Q_D(QQuickPackage);
+ if (name.isEmpty() && !d->dataList.isEmpty())
+ return d->dataList.at(0);
+
+ for (int ii = 0; ii < d->dataList.count(); ++ii) {
+ QObject *obj = d->dataList.at(ii);
+ QQuickPackageAttached *a = QQuickPackageAttached::attached.value(obj);
+ if (a && a->name() == name)
+ return obj;
+ }
+
+ if (name == QLatin1String("default") && !d->dataList.isEmpty())
+ return d->dataList.at(0);
+
+ return 0;
+}
+
+QQuickPackageAttached *QQuickPackage::qmlAttachedProperties(QObject *o)
+{
+ return new QQuickPackageAttached(o);
+}
+
+
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickpackage_p.h b/src/quick/util/qquickpackage_p.h
new file mode 100644
index 0000000000..9f16521763
--- /dev/null
+++ b/src/quick/util/qquickpackage_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPACKAGE_H
+#define QQUICKPACKAGE_H
+
+#include <qqml.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPackagePrivate;
+class QQuickPackageAttached;
+class Q_AUTOTEST_EXPORT QQuickPackage : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPackage)
+
+ Q_CLASSINFO("DefaultProperty", "data")
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data)
+
+public:
+ QQuickPackage(QObject *parent=0);
+ virtual ~QQuickPackage();
+
+ QQmlListProperty<QObject> data();
+
+ QObject *part(const QString & = QString());
+ bool hasPart(const QString &);
+
+ static QQuickPackageAttached *qmlAttachedProperties(QObject *);
+};
+
+class QQuickPackageAttached : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+public:
+ QQuickPackageAttached(QObject *parent);
+ virtual ~QQuickPackageAttached();
+
+ QString name() const;
+ void setName(const QString &n);
+
+ static QHash<QObject *, QQuickPackageAttached *> attached;
+private:
+ QString _name;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPackage)
+QML_DECLARE_TYPEINFO(QQuickPackage, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif // QQUICKPACKAGE_H
diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp
new file mode 100644
index 0000000000..b6a01bfe3e
--- /dev/null
+++ b/src/quick/util/qquickpath.cpp
@@ -0,0 +1,1798 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickpath_p.h"
+#include "qquickpath_p_p.h"
+#include "qquicksvgparser_p.h"
+
+#include <QSet>
+#include <QTime>
+
+#include <private/qbezier_p.h>
+#include <QtCore/qmath.h>
+#include <QtCore/qnumeric.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass PathElement QQuickPathElement
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief PathElement is the base path type.
+
+ This type is the base for all path types. It cannot
+ be instantiated.
+
+ \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg
+*/
+
+/*!
+ \qmlclass Path QQuickPath
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief A Path object defines a path for use by \l PathView.
+
+ A Path is composed of one or more path segments - PathLine, PathQuad,
+ PathCubic, PathArc, PathCurve, PathSvg.
+
+ The spacing of the items along the Path can be adjusted via a
+ PathPercent object.
+
+ PathAttribute allows named attributes with values to be defined
+ along the path.
+
+ \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg
+*/
+QQuickPath::QQuickPath(QObject *parent)
+ : QObject(*(new QQuickPathPrivate), parent)
+{
+}
+
+QQuickPath::~QQuickPath()
+{
+}
+
+/*!
+ \qmlproperty real QtQuick2::Path::startX
+ \qmlproperty real QtQuick2::Path::startY
+ These properties hold the starting position of the path.
+*/
+qreal QQuickPath::startX() const
+{
+ Q_D(const QQuickPath);
+ return d->startX.isNull ? 0 : d->startX.value;
+}
+
+void QQuickPath::setStartX(qreal x)
+{
+ Q_D(QQuickPath);
+ if (d->startX.isValid() && qFuzzyCompare(x, d->startX))
+ return;
+ d->startX = x;
+ emit startXChanged();
+ processPath();
+}
+
+bool QQuickPath::hasStartX() const
+{
+ Q_D(const QQuickPath);
+ return d->startX.isValid();
+}
+
+qreal QQuickPath::startY() const
+{
+ Q_D(const QQuickPath);
+ return d->startY.isNull ? 0 : d->startY.value;
+}
+
+void QQuickPath::setStartY(qreal y)
+{
+ Q_D(QQuickPath);
+ if (d->startY.isValid() && qFuzzyCompare(y, d->startY))
+ return;
+ d->startY = y;
+ emit startYChanged();
+ processPath();
+}
+
+bool QQuickPath::hasStartY() const
+{
+ Q_D(const QQuickPath);
+ return d->startY.isValid();
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Path::closed
+ This property holds whether the start and end of the path are identical.
+*/
+bool QQuickPath::isClosed() const
+{
+ Q_D(const QQuickPath);
+ return d->closed;
+}
+
+bool QQuickPath::hasEnd() const
+{
+ Q_D(const QQuickPath);
+ for (int i = d->_pathElements.count() - 1; i > -1; --i) {
+ if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(d->_pathElements.at(i))) {
+ if ((!curve->hasX() && !curve->hasRelativeX()) || (!curve->hasY() && !curve->hasRelativeY()))
+ return false;
+ else
+ return true;
+ }
+ }
+ return hasStartX() && hasStartY();
+}
+
+/*!
+ \qmlproperty list<PathElement> QtQuick2::Path::pathElements
+ This property holds the objects composing the path.
+
+ \default
+
+ A path can contain the following path objects:
+ \list
+ \i \l PathLine - a straight line to a given position.
+ \i \l PathQuad - a quadratic Bezier curve to a given position with a control point.
+ \i \l PathCubic - a cubic Bezier curve to a given position with two control points.
+ \i \l PathArc - an arc to a given position with a radius.
+ \i \l PathSvg - a path specified as an SVG path data string.
+ \i \l PathCurve - a point on a Catmull-Rom curve.
+ \i \l PathAttribute - an attribute at a given position in the path.
+ \i \l PathPercent - a way to spread out items along various segments of the path.
+ \endlist
+
+ \snippet doc/src/snippets/qml/pathview/pathattributes.qml 2
+*/
+
+QQmlListProperty<QQuickPathElement> QQuickPath::pathElements()
+{
+ Q_D(QQuickPath);
+ return QQmlListProperty<QQuickPathElement>(this, d->_pathElements);
+}
+
+void QQuickPath::interpolate(int idx, const QString &name, qreal value)
+{
+ Q_D(QQuickPath);
+ interpolate(d->_attributePoints, idx, name, value);
+}
+
+void QQuickPath::interpolate(QList<AttributePoint> &attributePoints, int idx, const QString &name, qreal value)
+{
+ if (!idx)
+ return;
+
+ qreal lastValue = 0;
+ qreal lastPercent = 0;
+ int search = idx - 1;
+ while(search >= 0) {
+ const AttributePoint &point = attributePoints.at(search);
+ if (point.values.contains(name)) {
+ lastValue = point.values.value(name);
+ lastPercent = point.origpercent;
+ break;
+ }
+ --search;
+ }
+
+ ++search;
+
+ const AttributePoint &curPoint = attributePoints.at(idx);
+
+ for (int ii = search; ii < idx; ++ii) {
+ AttributePoint &point = attributePoints[ii];
+
+ qreal val = lastValue + (value - lastValue) * (point.origpercent - lastPercent) / (curPoint.origpercent - lastPercent);
+ point.values.insert(name, val);
+ }
+}
+
+void QQuickPath::endpoint(const QString &name)
+{
+ Q_D(QQuickPath);
+ const AttributePoint &first = d->_attributePoints.first();
+ qreal val = first.values.value(name);
+ for (int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) {
+ const AttributePoint &point = d->_attributePoints.at(ii);
+ if (point.values.contains(name)) {
+ for (int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) {
+ AttributePoint &setPoint = d->_attributePoints[jj];
+ setPoint.values.insert(name, val);
+ }
+ return;
+ }
+ }
+}
+
+void QQuickPath::endpoint(QList<AttributePoint> &attributePoints, const QString &name)
+{
+ const AttributePoint &first = attributePoints.first();
+ qreal val = first.values.value(name);
+ for (int ii = attributePoints.count() - 1; ii >= 0; ii--) {
+ const AttributePoint &point = attributePoints.at(ii);
+ if (point.values.contains(name)) {
+ for (int jj = ii + 1; jj < attributePoints.count(); ++jj) {
+ AttributePoint &setPoint = attributePoints[jj];
+ setPoint.values.insert(name, val);
+ }
+ return;
+ }
+ }
+}
+
+static QString percentString(QLatin1String("_qfx_percent"));
+
+void QQuickPath::processPath()
+{
+ Q_D(QQuickPath);
+
+ if (!d->componentComplete)
+ return;
+
+ d->_pointCache.clear();
+ d->prevBez.isValid = false;
+
+ d->_path = createPath(QPointF(), QPointF(), d->_attributes, d->pathLength, d->_attributePoints, &d->closed);
+
+ emit changed();
+}
+
+QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &endPoint, const QStringList &attributes, qreal &pathLength, QList<AttributePoint> &attributePoints, bool *closed)
+{
+ Q_D(QQuickPath);
+
+ pathLength = 0;
+ attributePoints.clear();
+
+ if (!d->componentComplete)
+ return QPainterPath();
+
+ QPainterPath path;
+
+ AttributePoint first;
+ for (int ii = 0; ii < attributes.count(); ++ii)
+ first.values[attributes.at(ii)] = 0;
+ attributePoints << first;
+
+ qreal startX = d->startX.isValid() ? d->startX.value : startPoint.x();
+ qreal startY = d->startY.isValid() ? d->startY.value : startPoint.y();
+ path.moveTo(startX, startY);
+
+ bool usesPercent = false;
+ int index = 0;
+ foreach (QQuickPathElement *pathElement, d->_pathElements) {
+ if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement)) {
+ QQuickPathData data;
+ data.index = index;
+ data.endPoint = endPoint;
+ data.curves = d->_pathCurves;
+ curve->addToPath(path, data);
+ AttributePoint p;
+ p.origpercent = path.length();
+ attributePoints << p;
+ ++index;
+ } else if (QQuickPathAttribute *attribute = qobject_cast<QQuickPathAttribute *>(pathElement)) {
+ AttributePoint &point = attributePoints.last();
+ point.values[attribute->name()] = attribute->value();
+ interpolate(attributePoints, attributePoints.count() - 1, attribute->name(), attribute->value());
+ } else if (QQuickPathPercent *percent = qobject_cast<QQuickPathPercent *>(pathElement)) {
+ AttributePoint &point = attributePoints.last();
+ point.values[percentString] = percent->value();
+ interpolate(attributePoints, attributePoints.count() - 1, percentString, percent->value());
+ usesPercent = true;
+ }
+ }
+
+ // Fixup end points
+ const AttributePoint &last = attributePoints.last();
+ for (int ii = 0; ii < attributes.count(); ++ii) {
+ if (!last.values.contains(attributes.at(ii)))
+ endpoint(attributePoints, attributes.at(ii));
+ }
+ if (usesPercent && !last.values.contains(percentString)) {
+ d->_attributePoints.last().values[percentString] = 1;
+ interpolate(d->_attributePoints.count() - 1, percentString, 1);
+ }
+
+
+ // Adjust percent
+ qreal length = path.length();
+ qreal prevpercent = 0;
+ qreal prevorigpercent = 0;
+ for (int ii = 0; ii < attributePoints.count(); ++ii) {
+ const AttributePoint &point = attributePoints.at(ii);
+ if (point.values.contains(percentString)) { //special string for QQuickPathPercent
+ if ( ii > 0) {
+ qreal scale = (attributePoints[ii].origpercent/length - prevorigpercent) /
+ (point.values.value(percentString)-prevpercent);
+ attributePoints[ii].scale = scale;
+ }
+ attributePoints[ii].origpercent /= length;
+ attributePoints[ii].percent = point.values.value(percentString);
+ prevorigpercent = attributePoints[ii].origpercent;
+ prevpercent = attributePoints[ii].percent;
+ } else {
+ attributePoints[ii].origpercent /= length;
+ attributePoints[ii].percent = attributePoints[ii].origpercent;
+ }
+ }
+
+ if (closed) {
+ QPointF end = path.currentPosition();
+ *closed = length > 0 && startX == end.x() && startY == end.y();
+ }
+ pathLength = length;
+
+ return path;
+}
+
+void QQuickPath::classBegin()
+{
+ Q_D(QQuickPath);
+ d->componentComplete = false;
+}
+
+void QQuickPath::componentComplete()
+{
+ Q_D(QQuickPath);
+ QSet<QString> attrs;
+ d->componentComplete = true;
+
+ // First gather up all the attributes
+ foreach (QQuickPathElement *pathElement, d->_pathElements) {
+ if (QQuickCurve *curve =
+ qobject_cast<QQuickCurve *>(pathElement))
+ d->_pathCurves.append(curve);
+ else if (QQuickPathAttribute *attribute =
+ qobject_cast<QQuickPathAttribute *>(pathElement))
+ attrs.insert(attribute->name());
+ }
+ d->_attributes = attrs.toList();
+
+ processPath();
+
+ foreach (QQuickPathElement *pathElement, d->_pathElements)
+ connect(pathElement, SIGNAL(changed()), this, SLOT(processPath()));
+}
+
+QPainterPath QQuickPath::path() const
+{
+ Q_D(const QQuickPath);
+ return d->_path;
+}
+
+QStringList QQuickPath::attributes() const
+{
+ Q_D(const QQuickPath);
+ if (!d->componentComplete) {
+ QSet<QString> attrs;
+
+ // First gather up all the attributes
+ foreach (QQuickPathElement *pathElement, d->_pathElements) {
+ if (QQuickPathAttribute *attribute =
+ qobject_cast<QQuickPathAttribute *>(pathElement))
+ attrs.insert(attribute->name());
+ }
+ return attrs.toList();
+ }
+ return d->_attributes;
+}
+
+static inline QBezier nextBezier(const QPainterPath &path, int *current, qreal *bezLength, bool reverse = false)
+{
+ const int lastElement = reverse ? 0 : path.elementCount() - 1;
+ const int start = reverse ? *current - 1 : *current + 1;
+ for (int i=start; reverse ? i >= lastElement : i <= lastElement; reverse ? --i : ++i) {
+ const QPainterPath::Element &e = path.elementAt(i);
+
+ switch (e.type) {
+ case QPainterPath::MoveToElement:
+ break;
+ case QPainterPath::LineToElement:
+ {
+ QLineF line(path.elementAt(i-1), e);
+ *bezLength = line.length();
+ QPointF a = path.elementAt(i-1);
+ QPointF delta = e - a;
+ *current = i;
+ return QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e);
+ }
+ case QPainterPath::CurveToElement:
+ {
+ QBezier b = QBezier::fromPoints(path.elementAt(i-1),
+ e,
+ path.elementAt(i+1),
+ path.elementAt(i+2));
+ *bezLength = b.length();
+ *current = i;
+ return b;
+ }
+ default:
+ break;
+ }
+ }
+ *current = lastElement;
+ *bezLength = 0;
+ return QBezier();
+}
+
+//derivative of the equation
+static inline qreal slopeAt(qreal t, qreal a, qreal b, qreal c, qreal d)
+{
+ return 3*t*t*(d - 3*c + 3*b - a) + 6*t*(c - 2*b + a) + 3*(b - a);
+}
+
+void QQuickPath::createPointCache() const
+{
+ Q_D(const QQuickPath);
+ qreal pathLength = d->pathLength;
+ if (pathLength <= 0 || qIsNaN(pathLength))
+ return;
+ // more points means less jitter between items as they move along the
+ // path, but takes longer to generate
+ const int points = qCeil(pathLength*5);
+ const int lastElement = d->_path.elementCount() - 1;
+ d->_pointCache.resize(points+1);
+
+ int currElement = -1;
+ qreal bezLength = 0;
+ QBezier currBez = nextBezier(d->_path, &currElement, &bezLength);
+ qreal currLength = bezLength;
+ qreal epc = currLength / pathLength;
+
+ for (int i = 0; i < d->_pointCache.size(); i++) {
+ //find which set we are in
+ qreal prevPercent = 0;
+ qreal prevOrigPercent = 0;
+ for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ qreal percent = qreal(i)/points;
+ const AttributePoint &point = d->_attributePoints.at(ii);
+ if (percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item
+ qreal elementPercent = (percent - prevPercent);
+
+ qreal spc = prevOrigPercent + elementPercent * point.scale;
+
+ while (spc > epc) {
+ if (currElement > lastElement)
+ break;
+ currBez = nextBezier(d->_path, &currElement, &bezLength);
+ if (bezLength == 0.0) {
+ currLength = pathLength;
+ epc = 1.0;
+ break;
+ }
+ currLength += bezLength;
+ epc = currLength / pathLength;
+ }
+ qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength;
+ d->_pointCache[i] = currBez.pointAt(qBound(qreal(0), realT, qreal(1)));
+ break;
+ }
+ prevOrigPercent = point.origpercent;
+ prevPercent = point.percent;
+ }
+ }
+}
+
+void QQuickPath::invalidateSequentialHistory() const
+{
+ Q_D(const QQuickPath);
+ d->prevBez.isValid = false;
+}
+
+QPointF QQuickPath::sequentialPointAt(qreal p, qreal *angle) const
+{
+ Q_D(const QQuickPath);
+ return sequentialPointAt(d->_path, d->pathLength, d->_attributePoints, d->prevBez, p, angle);
+}
+
+QPointF QQuickPath::sequentialPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle)
+{
+ if (!prevBez.isValid)
+ return p > .5 ? backwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle) :
+ forwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle);
+
+ return p < prevBez.p ? backwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle) :
+ forwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle);
+}
+
+QPointF QQuickPath::forwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle)
+{
+ if (pathLength <= 0 || qIsNaN(pathLength))
+ return path.pointAtPercent(0); //expensive?
+
+ const int lastElement = path.elementCount() - 1;
+ bool haveCachedBez = prevBez.isValid;
+ int currElement = haveCachedBez ? prevBez.element : -1;
+ qreal bezLength = haveCachedBez ? prevBez.bezLength : 0;
+ QBezier currBez = haveCachedBez ? prevBez.bezier : nextBezier(path, &currElement, &bezLength);
+ qreal currLength = haveCachedBez ? prevBez.currLength : bezLength;
+ qreal epc = currLength / pathLength;
+
+ //find which set we are in
+ qreal prevPercent = 0;
+ qreal prevOrigPercent = 0;
+ for (int ii = 0; ii < attributePoints.count(); ++ii) {
+ qreal percent = p;
+ const AttributePoint &point = attributePoints.at(ii);
+ if (percent < point.percent || ii == attributePoints.count() - 1) {
+ qreal elementPercent = (percent - prevPercent);
+
+ qreal spc = prevOrigPercent + elementPercent * point.scale;
+
+ while (spc > epc) {
+ Q_ASSERT(!(currElement > lastElement));
+ Q_UNUSED(lastElement);
+ currBez = nextBezier(path, &currElement, &bezLength);
+ currLength += bezLength;
+ epc = currLength / pathLength;
+ }
+ prevBez.element = currElement;
+ prevBez.bezLength = bezLength;
+ prevBez.currLength = currLength;
+ prevBez.bezier = currBez;
+ prevBez.p = p;
+ prevBez.isValid = true;
+
+ qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength;
+
+ if (angle) {
+ qreal m1 = slopeAt(realT, currBez.x1, currBez.x2, currBez.x3, currBez.x4);
+ qreal m2 = slopeAt(realT, currBez.y1, currBez.y2, currBez.y3, currBez.y4);
+ *angle = QLineF(0, 0, m1, m2).angle();
+ }
+
+ return currBez.pointAt(qBound(qreal(0), realT, qreal(1)));
+ }
+ prevOrigPercent = point.origpercent;
+ prevPercent = point.percent;
+ }
+
+ return QPointF(0,0);
+}
+
+//ideally this should be merged with forwardsPointAt
+QPointF QQuickPath::backwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle)
+{
+ if (pathLength <= 0 || qIsNaN(pathLength))
+ return path.pointAtPercent(0);
+
+ const int firstElement = 1; //element 0 is always a MoveTo, which we ignore
+ bool haveCachedBez = prevBez.isValid;
+ int currElement = haveCachedBez ? prevBez.element : path.elementCount();
+ qreal bezLength = haveCachedBez ? prevBez.bezLength : 0;
+ QBezier currBez = haveCachedBez ? prevBez.bezier : nextBezier(path, &currElement, &bezLength, true /*reverse*/);
+ qreal currLength = haveCachedBez ? prevBez.currLength : pathLength;
+ qreal prevLength = currLength - bezLength;
+ qreal epc = prevLength / pathLength;
+
+ for (int ii = attributePoints.count() - 1; ii > 0; --ii) {
+ qreal percent = p;
+ const AttributePoint &point = attributePoints.at(ii);
+ const AttributePoint &prevPoint = attributePoints.at(ii-1);
+ if (percent > prevPoint.percent || ii == 1) {
+ qreal elementPercent = (percent - prevPoint.percent);
+
+ qreal spc = prevPoint.origpercent + elementPercent * point.scale;
+
+ while (spc < epc) {
+ Q_ASSERT(!(currElement < firstElement));
+ Q_UNUSED(firstElement);
+ currBez = nextBezier(path, &currElement, &bezLength, true /*reverse*/);
+ //special case for first element is to avoid floating point math
+ //causing an epc that never hits 0.
+ currLength = (currElement == firstElement) ? bezLength : prevLength;
+ prevLength = currLength - bezLength;
+ epc = prevLength / pathLength;
+ }
+ prevBez.element = currElement;
+ prevBez.bezLength = bezLength;
+ prevBez.currLength = currLength;
+ prevBez.bezier = currBez;
+ prevBez.p = p;
+ prevBez.isValid = true;
+
+ qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength;
+
+ if (angle) {
+ qreal m1 = slopeAt(realT, currBez.x1, currBez.x2, currBez.x3, currBez.x4);
+ qreal m2 = slopeAt(realT, currBez.y1, currBez.y2, currBez.y3, currBez.y4);
+ *angle = QLineF(0, 0, m1, m2).angle();
+ }
+
+ return currBez.pointAt(qBound(qreal(0), realT, qreal(1)));
+ }
+ }
+
+ return QPointF(0,0);
+}
+
+QPointF QQuickPath::pointAt(qreal p) const
+{
+ Q_D(const QQuickPath);
+ if (d->_pointCache.isEmpty()) {
+ createPointCache();
+ if (d->_pointCache.isEmpty())
+ return QPointF();
+ }
+
+ const int pointCacheSize = d->_pointCache.size();
+ qreal idxf = p*pointCacheSize;
+ int idx1 = qFloor(idxf);
+ qreal delta = idxf - idx1;
+ if (idx1 >= pointCacheSize)
+ idx1 = pointCacheSize - 1;
+ else if (idx1 < 0)
+ idx1 = 0;
+
+ if (delta == 0.0)
+ return d->_pointCache.at(idx1);
+
+ // interpolate between the two points.
+ int idx2 = qCeil(idxf);
+ if (idx2 >= pointCacheSize)
+ idx2 = pointCacheSize - 1;
+ else if (idx2 < 0)
+ idx2 = 0;
+
+ QPointF p1 = d->_pointCache.at(idx1);
+ QPointF p2 = d->_pointCache.at(idx2);
+ QPointF pos = p1 * (1.0-delta) + p2 * delta;
+
+ return pos;
+}
+
+qreal QQuickPath::attributeAt(const QString &name, qreal percent) const
+{
+ Q_D(const QQuickPath);
+ if (percent < 0 || percent > 1)
+ return 0;
+
+ for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ const AttributePoint &point = d->_attributePoints.at(ii);
+
+ if (point.percent == percent) {
+ return point.values.value(name);
+ } else if (point.percent > percent) {
+ qreal lastValue =
+ ii?(d->_attributePoints.at(ii - 1).values.value(name)):0;
+ qreal lastPercent =
+ ii?(d->_attributePoints.at(ii - 1).percent):0;
+ qreal curValue = point.values.value(name);
+ qreal curPercent = point.percent;
+
+ return lastValue + (curValue - lastValue) * (percent - lastPercent) / (curPercent - lastPercent);
+ }
+ }
+
+ return 0;
+}
+
+/****************************************************************************/
+
+qreal QQuickCurve::x() const
+{
+ return _x.isNull ? 0 : _x.value;
+}
+
+void QQuickCurve::setX(qreal x)
+{
+ if (_x.isNull || _x != x) {
+ _x = x;
+ emit xChanged();
+ emit changed();
+ }
+}
+
+bool QQuickCurve::hasX()
+{
+ return _x.isValid();
+}
+
+qreal QQuickCurve::y() const
+{
+ return _y.isNull ? 0 : _y.value;
+}
+
+void QQuickCurve::setY(qreal y)
+{
+ if (_y.isNull || _y != y) {
+ _y = y;
+ emit yChanged();
+ emit changed();
+ }
+}
+
+bool QQuickCurve::hasY()
+{
+ return _y.isValid();
+}
+
+qreal QQuickCurve::relativeX() const
+{
+ return _relativeX;
+}
+
+void QQuickCurve::setRelativeX(qreal x)
+{
+ if (_relativeX.isNull || _relativeX != x) {
+ _relativeX = x;
+ emit relativeXChanged();
+ emit changed();
+ }
+}
+
+bool QQuickCurve::hasRelativeX()
+{
+ return _relativeX.isValid();
+}
+
+qreal QQuickCurve::relativeY() const
+{
+ return _relativeY;
+}
+
+void QQuickCurve::setRelativeY(qreal y)
+{
+ if (_relativeY.isNull || _relativeY != y) {
+ _relativeY = y;
+ emit relativeYChanged();
+ emit changed();
+ }
+}
+
+bool QQuickCurve::hasRelativeY()
+{
+ return _relativeY.isValid();
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathAttribute QQuickPathAttribute
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The PathAttribute allows setting an attribute at a given position in a Path.
+
+ The PathAttribute object allows attributes consisting of a name and
+ a value to be specified for various points along a path. The
+ attributes are exposed to the delegate as
+ \l{qdeclarativeintroduction.html#attached-properties} {Attached Properties}.
+ The value of an attribute at any particular point along the path is interpolated
+ from the PathAttributes bounding that point.
+
+ The example below shows a path with the items scaled to 30% with
+ opacity 50% at the top of the path and scaled 100% with opacity
+ 100% at the bottom. Note the use of the PathView.iconScale and
+ PathView.iconOpacity attached properties to set the scale and opacity
+ of the delegate.
+
+ \table
+ \row
+ \o \image declarative-pathattribute.png
+ \o
+ \snippet doc/src/snippets/qml/pathview/pathattributes.qml 0
+ (see the PathView documentation for the specification of ContactModel.qml
+ used for ContactModel above.)
+ \endtable
+
+
+ \sa Path
+*/
+
+/*!
+ \qmlproperty string QtQuick2::PathAttribute::name
+ This property holds 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.
+*/
+
+/*!
+ the name of the attribute to change.
+*/
+
+QString QQuickPathAttribute::name() const
+{
+ return _name;
+}
+
+void QQuickPathAttribute::setName(const QString &name)
+{
+ if (_name == name)
+ return;
+ _name = name;
+ emit nameChanged();
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathAttribute::value
+ This property holds the value for the attribute.
+
+ The value specified can be used to influence the visual appearance
+ of an item along the path. For example, the following Path specifies
+ an attribute named \e itemRotation, which has the value \e 0 at the
+ beginning of the path, and the value 90 at the end of the path.
+
+ \qml
+ Path {
+ startX: 0
+ startY: 0
+ PathAttribute { name: "itemRotation"; value: 0 }
+ PathLine { x: 100; y: 100 }
+ PathAttribute { name: "itemRotation"; value: 90 }
+ }
+ \endqml
+
+ In our delegate, we can then bind the \e rotation property to the
+ \l{qdeclarativeintroduction.html#attached-properties} {Attached Property}
+ \e PathView.itemRotation created for this attribute.
+
+ \qml
+ Rectangle {
+ width: 10; height: 10
+ rotation: PathView.itemRotation
+ }
+ \endqml
+
+ As each item is positioned along the path, it will be rotated accordingly:
+ an item at the beginning of the path with be not be rotated, an item at
+ the end of the path will be rotated 90 degrees, and an item mid-way along
+ the path will be rotated 45 degrees.
+*/
+
+/*!
+ the new value of the attribute.
+*/
+qreal QQuickPathAttribute::value() const
+{
+ return _value;
+}
+
+void QQuickPathAttribute::setValue(qreal value)
+{
+ if (_value != value) {
+ _value = value;
+ emit valueChanged();
+ emit changed();
+ }
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathLine QQuickPathLine
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The PathLine defines a straight line.
+
+ The example below creates a path consisting of a straight line from
+ 0,100 to 200,100:
+
+ \qml
+ Path {
+ startX: 0; startY: 100
+ PathLine { x: 200; y: 100 }
+ }
+ \endqml
+
+ \sa Path, PathQuad, PathCubic, PathArc, PathCurve, PathSvg
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathLine::x
+ \qmlproperty real QtQuick2::PathLine::y
+
+ Defines the end point of the line.
+
+ \sa relativeX, relativeY
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathLine::relativeX
+ \qmlproperty real QtQuick2::PathLine::relativeY
+
+ Defines the end point of the line relative to its start.
+
+ If both a relative and absolute end position are specified for a single axis, the relative
+ position will be used.
+
+ Relative and absolute positions can be mixed, for example it is valid to set a relative x
+ and an absolute y.
+
+ \sa x, y
+*/
+
+inline QPointF positionForCurve(const QQuickPathData &data, const QPointF &prevPoint)
+{
+ QQuickCurve *curve = data.curves.at(data.index);
+ bool isEnd = data.index == data.curves.size() - 1;
+ return QPointF(curve->hasRelativeX() ? prevPoint.x() + curve->relativeX() : !isEnd || curve->hasX() ? curve->x() : data.endPoint.x(),
+ curve->hasRelativeY() ? prevPoint.y() + curve->relativeY() : !isEnd || curve->hasY() ? curve->y() : data.endPoint.y());
+}
+
+void QQuickPathLine::addToPath(QPainterPath &path, const QQuickPathData &data)
+{
+ path.lineTo(positionForCurve(data, path.currentPosition()));
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathQuad QQuickPathQuad
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The PathQuad defines a quadratic Bezier curve with a control point.
+
+ The following QML produces the path shown below:
+ \table
+ \row
+ \o \image declarative-pathquad.png
+ \o
+ \qml
+ Path {
+ startX: 0; startY: 0
+ PathQuad { x: 200; y: 0; controlX: 100; controlY: 150 }
+ }
+ \endqml
+ \endtable
+
+ \sa Path, PathCubic, PathLine, PathArc, PathCurve, PathSvg
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathQuad::x
+ \qmlproperty real QtQuick2::PathQuad::y
+
+ Defines the end point of the curve.
+
+ \sa relativeX, relativeY
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathQuad::relativeX
+ \qmlproperty real QtQuick2::PathQuad::relativeY
+
+ Defines the end point of the curve relative to its start.
+
+ If both a relative and absolute end position are specified for a single axis, the relative
+ position will be used.
+
+ Relative and absolute positions can be mixed, for example it is valid to set a relative x
+ and an absolute y.
+
+ \sa x, y
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathQuad::controlX
+ \qmlproperty real QtQuick2::PathQuad::controlY
+
+ Defines the position of the control point.
+*/
+
+/*!
+ the x position of the control point.
+*/
+qreal QQuickPathQuad::controlX() const
+{
+ return _controlX;
+}
+
+void QQuickPathQuad::setControlX(qreal x)
+{
+ if (_controlX != x) {
+ _controlX = x;
+ emit controlXChanged();
+ emit changed();
+ }
+}
+
+
+/*!
+ the y position of the control point.
+*/
+qreal QQuickPathQuad::controlY() const
+{
+ return _controlY;
+}
+
+void QQuickPathQuad::setControlY(qreal y)
+{
+ if (_controlY != y) {
+ _controlY = y;
+ emit controlYChanged();
+ emit changed();
+ }
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathCubic::relativeControlX
+ \qmlproperty real QtQuick2::PathCubic::relativeControlY
+
+ Defines the position of the control point relative to the curve's start.
+
+ If both a relative and absolute control position are specified for a single axis, the relative
+ position will be used.
+
+ Relative and absolute positions can be mixed, for example it is valid to set a relative control x
+ and an absolute control y.
+
+ \sa controlX, controlY
+*/
+
+qreal QQuickPathQuad::relativeControlX() const
+{
+ return _relativeControlX;
+}
+
+void QQuickPathQuad::setRelativeControlX(qreal x)
+{
+ if (_relativeControlX.isNull || _relativeControlX != x) {
+ _relativeControlX = x;
+ emit relativeControlXChanged();
+ emit changed();
+ }
+}
+
+bool QQuickPathQuad::hasRelativeControlX()
+{
+ return _relativeControlX.isValid();
+}
+
+qreal QQuickPathQuad::relativeControlY() const
+{
+ return _relativeControlY;
+}
+
+void QQuickPathQuad::setRelativeControlY(qreal y)
+{
+ if (_relativeControlY.isNull || _relativeControlY != y) {
+ _relativeControlY = y;
+ emit relativeControlYChanged();
+ emit changed();
+ }
+}
+
+bool QQuickPathQuad::hasRelativeControlY()
+{
+ return _relativeControlY.isValid();
+}
+
+void QQuickPathQuad::addToPath(QPainterPath &path, const QQuickPathData &data)
+{
+ const QPointF &prevPoint = path.currentPosition();
+ QPointF controlPoint(hasRelativeControlX() ? prevPoint.x() + relativeControlX() : controlX(),
+ hasRelativeControlY() ? prevPoint.y() + relativeControlY() : controlY());
+ path.quadTo(controlPoint, positionForCurve(data, path.currentPosition()));
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathCubic QQuickPathCubic
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The PathCubic defines a cubic Bezier curve with two control points.
+
+ The following QML produces the path shown below:
+ \table
+ \row
+ \o \image declarative-pathcubic.png
+ \o
+ \qml
+ Path {
+ startX: 20; startY: 0
+ PathCubic {
+ x: 180; y: 0
+ control1X: -10; control1Y: 90
+ control2X: 210; control2Y: 90
+ }
+ }
+ \endqml
+ \endtable
+
+ \sa Path, PathQuad, PathLine, PathArc, PathCurve, PathSvg
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathCubic::x
+ \qmlproperty real QtQuick2::PathCubic::y
+
+ Defines the end point of the curve.
+
+ \sa relativeX, relativeY
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathCubic::relativeX
+ \qmlproperty real QtQuick2::PathCubic::relativeY
+
+ Defines the end point of the curve relative to its start.
+
+ If both a relative and absolute end position are specified for a single axis, the relative
+ position will be used.
+
+ Relative and absolute positions can be mixed, for example it is valid to set a relative x
+ and an absolute y.
+
+ \sa x, y
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathCubic::control1X
+ \qmlproperty real QtQuick2::PathCubic::control1Y
+
+ Defines the position of the first control point.
+*/
+qreal QQuickPathCubic::control1X() const
+{
+ return _control1X;
+}
+
+void QQuickPathCubic::setControl1X(qreal x)
+{
+ if (_control1X != x) {
+ _control1X = x;
+ emit control1XChanged();
+ emit changed();
+ }
+}
+
+qreal QQuickPathCubic::control1Y() const
+{
+ return _control1Y;
+}
+
+void QQuickPathCubic::setControl1Y(qreal y)
+{
+ if (_control1Y != y) {
+ _control1Y = y;
+ emit control1YChanged();
+ emit changed();
+ }
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathCubic::control2X
+ \qmlproperty real QtQuick2::PathCubic::control2Y
+
+ Defines the position of the second control point.
+*/
+qreal QQuickPathCubic::control2X() const
+{
+ return _control2X;
+}
+
+void QQuickPathCubic::setControl2X(qreal x)
+{
+ if (_control2X != x) {
+ _control2X = x;
+ emit control2XChanged();
+ emit changed();
+ }
+}
+
+qreal QQuickPathCubic::control2Y() const
+{
+ return _control2Y;
+}
+
+void QQuickPathCubic::setControl2Y(qreal y)
+{
+ if (_control2Y != y) {
+ _control2Y = y;
+ emit control2YChanged();
+ emit changed();
+ }
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathCubic::relativeControl1X
+ \qmlproperty real QtQuick2::PathCubic::relativeControl1Y
+ \qmlproperty real QtQuick2::PathCubic::relativeControl2X
+ \qmlproperty real QtQuick2::PathCubic::relativeControl2Y
+
+ Defines the positions of the control points relative to the curve's start.
+
+ If both a relative and absolute control position are specified for a control point's axis, the relative
+ position will be used.
+
+ Relative and absolute positions can be mixed, for example it is valid to set a relative control1 x
+ and an absolute control1 y.
+
+ \sa control1X, control1Y, control2X, control2Y
+*/
+
+qreal QQuickPathCubic::relativeControl1X() const
+{
+ return _relativeControl1X;
+}
+
+void QQuickPathCubic::setRelativeControl1X(qreal x)
+{
+ if (_relativeControl1X.isNull || _relativeControl1X != x) {
+ _relativeControl1X = x;
+ emit relativeControl1XChanged();
+ emit changed();
+ }
+}
+
+bool QQuickPathCubic::hasRelativeControl1X()
+{
+ return _relativeControl1X.isValid();
+}
+
+qreal QQuickPathCubic::relativeControl1Y() const
+{
+ return _relativeControl1Y;
+}
+
+void QQuickPathCubic::setRelativeControl1Y(qreal y)
+{
+ if (_relativeControl1Y.isNull || _relativeControl1Y != y) {
+ _relativeControl1Y = y;
+ emit relativeControl1YChanged();
+ emit changed();
+ }
+}
+
+bool QQuickPathCubic::hasRelativeControl1Y()
+{
+ return _relativeControl1Y.isValid();
+}
+
+qreal QQuickPathCubic::relativeControl2X() const
+{
+ return _relativeControl2X;
+}
+
+void QQuickPathCubic::setRelativeControl2X(qreal x)
+{
+ if (_relativeControl2X.isNull || _relativeControl2X != x) {
+ _relativeControl2X = x;
+ emit relativeControl2XChanged();
+ emit changed();
+ }
+}
+
+bool QQuickPathCubic::hasRelativeControl2X()
+{
+ return _relativeControl2X.isValid();
+}
+
+qreal QQuickPathCubic::relativeControl2Y() const
+{
+ return _relativeControl2Y;
+}
+
+void QQuickPathCubic::setRelativeControl2Y(qreal y)
+{
+ if (_relativeControl2Y.isNull || _relativeControl2Y != y) {
+ _relativeControl2Y = y;
+ emit relativeControl2YChanged();
+ emit changed();
+ }
+}
+
+bool QQuickPathCubic::hasRelativeControl2Y()
+{
+ return _relativeControl2Y.isValid();
+}
+
+void QQuickPathCubic::addToPath(QPainterPath &path, const QQuickPathData &data)
+{
+ const QPointF &prevPoint = path.currentPosition();
+ QPointF controlPoint1(hasRelativeControl1X() ? prevPoint.x() + relativeControl1X() : control1X(),
+ hasRelativeControl1Y() ? prevPoint.y() + relativeControl1Y() : control1Y());
+ QPointF controlPoint2(hasRelativeControl2X() ? prevPoint.x() + relativeControl2X() : control2X(),
+ hasRelativeControl2Y() ? prevPoint.y() + relativeControl2Y() : control2Y());
+ path.cubicTo(controlPoint1, controlPoint2, positionForCurve(data, path.currentPosition()));
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathCurve QQuickPathCurve
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The PathCurve defines a point on a Catmull-Rom curve.
+
+ PathCurve provides an easy way to specify a curve passing directly through a set of points.
+ Typically multiple PathCurves are used in a series, as the following example demonstrates:
+
+ \snippet doc/src/snippets/qml/path/basiccurve.qml 0
+
+ This example produces the following path (with the starting point and PathCurve points
+ highlighted in red):
+
+ \image declarative-pathcurve.png
+
+ \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathSvg
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathCurve::x
+ \qmlproperty real QtQuick2::PathCurve::y
+
+ Defines the end point of the curve.
+
+ \sa relativeX, relativeY
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathCurve::relativeX
+ \qmlproperty real QtQuick2::PathCurve::relativeY
+
+ Defines the end point of the curve relative to its start.
+
+ If both a relative and absolute end position are specified for a single axis, the relative
+ position will be used.
+
+ Relative and absolute positions can be mixed, for example it is valid to set a relative x
+ and an absolute y.
+
+ \sa x, y
+*/
+
+inline QPointF previousPathPosition(const QPainterPath &path)
+{
+ int count = path.elementCount();
+ if (count < 1)
+ return QPointF();
+
+ int index = path.elementAt(count-1).type == QPainterPath::CurveToDataElement ? count - 4 : count - 2;
+ return index > -1 ? QPointF(path.elementAt(index)) : path.pointAtPercent(0);
+}
+
+void QQuickPathCatmullRomCurve::addToPath(QPainterPath &path, const QQuickPathData &data)
+{
+ //here we convert catmull-rom spline to bezier for use in QPainterPath.
+ //basic conversion algorithm:
+ // catmull-rom points * inverse bezier matrix * catmull-rom matrix = bezier points
+ //each point in the catmull-rom spline produces a bezier endpoint + 2 control points
+ //calculations for each point use a moving window of 4 points
+ // (previous 2 points + current point + next point)
+ QPointF prevFar, prev, point, next;
+
+ //get previous points
+ int index = data.index - 1;
+ QQuickCurve *curve = index == -1 ? 0 : data.curves.at(index);
+ if (qobject_cast<QQuickPathCatmullRomCurve*>(curve)) {
+ prev = path.currentPosition();
+ prevFar = previousPathPosition(path);
+ } else {
+ prev = path.currentPosition();
+ bool prevFarSet = false;
+ if (index == -1 && data.curves.count() > 1) {
+ if (qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(data.curves.count()-1))) {
+ //TODO: profile and optimize
+ QPointF pos = prev;
+ QQuickPathData loopData;
+ loopData.endPoint = data.endPoint;
+ loopData.curves = data.curves;
+ for (int i = data.index; i < data.curves.count(); ++i) {
+ loopData.index = i;
+ pos = positionForCurve(loopData, pos);
+ if (i == data.curves.count()-2)
+ prevFar = pos;
+ }
+ if (pos == QPointF(path.elementAt(0))) {
+ //this is a closed path starting and ending with catmull-rom segments.
+ //we try to smooth the join point
+ prevFarSet = true;
+ }
+ }
+ }
+ if (!prevFarSet)
+ prevFar = prev;
+ }
+
+ //get current point
+ point = positionForCurve(data, path.currentPosition());
+
+ //get next point
+ index = data.index + 1;
+ if (index < data.curves.count() && qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(index))) {
+ QQuickPathData nextData;
+ nextData.index = index;
+ nextData.endPoint = data.endPoint;
+ nextData.curves = data.curves;
+ next = positionForCurve(nextData, point);
+ } else {
+ if (point == QPointF(path.elementAt(0)) && qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(0))) {
+ //this is a closed path starting and ending with catmull-rom segments.
+ //we try to smooth the join point
+ next = QPointF(path.elementAt(3)); //the first catmull-rom point
+ } else
+ next = point;
+ }
+
+ /*
+ full conversion matrix (inverse bezier * catmull-rom):
+ 0.000, 1.000, 0.000, 0.000,
+ -0.167, 1.000, 0.167, 0.000,
+ 0.000, 0.167, 1.000, -0.167,
+ 0.000, 0.000, 1.000, 0.000
+
+ conversion doesn't require full matrix multiplication,
+ so below we simplify
+ */
+ QPointF control1(prevFar.x() * qreal(-0.167) +
+ prev.x() +
+ point.x() * qreal(0.167),
+ prevFar.y() * qreal(-0.167) +
+ prev.y() +
+ point.y() * qreal(0.167));
+
+ QPointF control2(prev.x() * qreal(0.167) +
+ point.x() +
+ next.x() * qreal(-0.167),
+ prev.y() * qreal(0.167) +
+ point.y() +
+ next.y() * qreal(-0.167));
+
+ path.cubicTo(control1, control2, point);
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathArc QQuickPathArc
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The PathArc defines an arc with the given radius.
+
+ PathArc provides a simple way of specifying an arc that ends at a given position
+ and uses the specified radius. It is modeled after the SVG elliptical arc command.
+
+ The following QML produces the path shown below:
+ \table
+ \row
+ \o \image declarative-patharc.png
+ \o \snippet doc/src/snippets/qml/path/basicarc.qml 0
+ \endtable
+
+ Note that a single PathArc cannot be used to specify a circle. Instead, you can
+ use two PathArc elements, each specifying half of the circle.
+
+ \sa Path, PathLine, PathQuad, PathCubic, PathCurve, PathSvg
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathArc::x
+ \qmlproperty real QtQuick2::PathArc::y
+
+ Defines the end point of the arc.
+
+ \sa relativeX, relativeY
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathArc::relativeX
+ \qmlproperty real QtQuick2::PathArc::relativeY
+
+ Defines the end point of the arc relative to its start.
+
+ If both a relative and absolute end position are specified for a single axis, the relative
+ position will be used.
+
+ Relative and absolute positions can be mixed, for example it is valid to set a relative x
+ and an absolute y.
+
+ \sa x, y
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathArc::radiusX
+ \qmlproperty real QtQuick2::PathArc::radiusY
+
+ Defines the radius of the arc.
+
+ The following QML demonstrates how different radius values can be used to change
+ the shape of the arc:
+ \table
+ \row
+ \o \image declarative-arcradius.png
+ \o \snippet doc/src/snippets/qml/path/arcradius.qml 0
+ \endtable
+*/
+
+qreal QQuickPathArc::radiusX() const
+{
+ return _radiusX;
+}
+
+void QQuickPathArc::setRadiusX(qreal radius)
+{
+ if (_radiusX == radius)
+ return;
+
+ _radiusX = radius;
+ emit radiusXChanged();
+}
+
+qreal QQuickPathArc::radiusY() const
+{
+ return _radiusY;
+}
+
+void QQuickPathArc::setRadiusY(qreal radius)
+{
+ if (_radiusY == radius)
+ return;
+
+ _radiusY = radius;
+ emit radiusYChanged();
+}
+
+/*!
+ \qmlproperty bool QtQuick2::PathArc::useLargeArc
+ Whether to use a large arc as defined by the arc points.
+
+ Given fixed start and end positions, radius, and direction,
+ there are two possible arcs that can fit the data. useLargeArc
+ is used to distinguish between these. For example, the following
+ QML can produce either of the two illustrated arcs below by
+ changing the value of useLargeArc.
+
+ \table
+ \row
+ \o \image declarative-largearc.png
+ \o \snippet doc/src/snippets/qml/path/largearc.qml 0
+ \endtable
+
+ The default value is false.
+*/
+
+bool QQuickPathArc::useLargeArc() const
+{
+ return _useLargeArc;
+}
+
+void QQuickPathArc::setUseLargeArc(bool largeArc)
+{
+ if (_useLargeArc == largeArc)
+ return;
+
+ _useLargeArc = largeArc;
+ emit useLargeArcChanged();
+}
+
+/*!
+ \qmlproperty enum QtQuick2::PathArc::direction
+
+ Defines the direction of the arc. Possible values are
+ PathArc.Clockwise (default) and PathArc.Counterclockwise.
+
+ The following QML can produce either of the two illustrated arcs below
+ by changing the value of direction.
+ \table
+ \row
+ \o \image declarative-arcdirection.png
+ \o \snippet doc/src/snippets/qml/path/arcdirection.qml 0
+ \endtable
+
+ \sa useLargeArc
+*/
+
+QQuickPathArc::ArcDirection QQuickPathArc::direction() const
+{
+ return _direction;
+}
+
+void QQuickPathArc::setDirection(ArcDirection direction)
+{
+ if (_direction == direction)
+ return;
+
+ _direction = direction;
+ emit directionChanged();
+}
+
+void QQuickPathArc::addToPath(QPainterPath &path, const QQuickPathData &data)
+{
+ const QPointF &startPoint = path.currentPosition();
+ const QPointF &endPoint = positionForCurve(data, startPoint);
+ QQuickSvgParser::pathArc(path,
+ _radiusX,
+ _radiusY,
+ 0, //xAxisRotation
+ _useLargeArc,
+ _direction == Clockwise ? 1 : 0,
+ endPoint.x(),
+ endPoint.y(),
+ startPoint.x(), startPoint.y());
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathSvg QQuickPathSvg
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The PathSvg defines a path using an SVG path data string.
+
+ The following QML produces the path shown below:
+ \table
+ \row
+ \o \image declarative-pathsvg.png
+ \o
+ \qml
+ Path {
+ startX: 50; startY: 50
+ PathSvg { path: "L 150 50 L 100 150 z" }
+ }
+ \endqml
+ \endtable
+
+ \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathCurve
+*/
+
+/*!
+ \qmlproperty string QtQuick2::PathSvg::path
+
+ The SVG path data string specifying the path.
+
+ See \l {http://www.w3.org/TR/SVG/paths.html#PathData}{W3C SVG Path Data}
+ for more details on this format.
+*/
+
+QString QQuickPathSvg::path() const
+{
+ return _path;
+}
+
+void QQuickPathSvg::setPath(const QString &path)
+{
+ if (_path == path)
+ return;
+
+ _path = path;
+ emit pathChanged();
+}
+
+void QQuickPathSvg::addToPath(QPainterPath &path, const QQuickPathData &)
+{
+ QQuickSvgParser::parsePathDataFast(_path, path);
+}
+
+/****************************************************************************/
+
+/*!
+ \qmlclass PathPercent QQuickPathPercent
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The PathPercent manipulates the way a path is interpreted.
+
+ PathPercent allows you to manipulate the spacing between items on a
+ PathView's path. You can use it to bunch together items on part of
+ the path, and spread them out on other parts of the path.
+
+ The examples below show the normal distribution of items along a path
+ compared to a distribution which places 50% of the items along the
+ PathLine section of the path.
+ \table
+ \row
+ \o \image declarative-nopercent.png
+ \o
+ \qml
+ PathView {
+ // ...
+ Path {
+ startX: 20; startY: 0
+ PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
+ PathLine { x: 150; y: 80 }
+ PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 }
+ }
+ }
+ \endqml
+ \row
+ \o \image declarative-percent.png
+ \o
+ \qml
+ PathView {
+ // ...
+ Path {
+ startX: 20; startY: 0
+ PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 }
+ PathPercent { value: 0.25 }
+ PathLine { x: 150; y: 80 }
+ PathPercent { value: 0.75 }
+ PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 }
+ PathPercent { value: 1 }
+ }
+ }
+ \endqml
+ \endtable
+
+ \sa Path
+*/
+
+/*!
+ \qmlproperty real QtQuick2::PathPercent::value
+ The proportion of items that should be laid out up to this point.
+
+ This value should always be higher than the last value specified
+ by a PathPercent at a previous position in the Path.
+
+ In the following example we have a Path made up of three PathLines.
+ Normally, the items of the PathView would be laid out equally along
+ this path, with an equal number of items per line segment. PathPercent
+ allows us to specify that the first and third lines should each hold
+ 10% of the laid out items, while the second line should hold the remaining
+ 80%.
+
+ \qml
+ PathView {
+ // ...
+ Path {
+ startX: 0; startY: 0
+ PathLine { x:100; y: 0; }
+ PathPercent { value: 0.1 }
+ PathLine { x: 100; y: 100 }
+ PathPercent { value: 0.9 }
+ PathLine { x: 100; y: 0 }
+ PathPercent { value: 1 }
+ }
+ }
+ \endqml
+*/
+
+qreal QQuickPathPercent::value() const
+{
+ return _value;
+}
+
+void QQuickPathPercent::setValue(qreal value)
+{
+ if (_value != value) {
+ _value = value;
+ emit valueChanged();
+ emit changed();
+ }
+}
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h
new file mode 100644
index 0000000000..3ffcf3eaa6
--- /dev/null
+++ b/src/quick/util/qquickpath_p.h
@@ -0,0 +1,451 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPATH_H
+#define QQUICKPATH_H
+
+#include <qqml.h>
+
+#include <private/qqmlnullablevalue_p_p.h>
+#include <private/qbezier_p.h>
+
+#include <QtCore/QObject>
+#include <QtGui/QPainterPath>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickCurve;
+struct QQuickPathData
+{
+ int index;
+ QPointF endPoint;
+ QList<QQuickCurve*> curves;
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathElement : public QObject
+{
+ Q_OBJECT
+public:
+ QQuickPathElement(QObject *parent=0) : QObject(parent) {}
+Q_SIGNALS:
+ void changed();
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathAttribute : public QQuickPathElement
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
+public:
+ QQuickPathAttribute(QObject *parent=0) : QQuickPathElement(parent), _value(0) {}
+
+
+ QString name() const;
+ void setName(const QString &name);
+
+ qreal value() const;
+ void setValue(qreal value);
+
+Q_SIGNALS:
+ void nameChanged();
+ void valueChanged();
+
+private:
+ QString _name;
+ qreal _value;
+};
+
+class Q_AUTOTEST_EXPORT QQuickCurve : public QQuickPathElement
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
+ Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
+ Q_PROPERTY(qreal relativeX READ relativeX WRITE setRelativeX NOTIFY relativeXChanged)
+ Q_PROPERTY(qreal relativeY READ relativeY WRITE setRelativeY NOTIFY relativeYChanged)
+public:
+ QQuickCurve(QObject *parent=0) : QQuickPathElement(parent) {}
+
+ qreal x() const;
+ void setX(qreal x);
+ bool hasX();
+
+ qreal y() const;
+ void setY(qreal y);
+ bool hasY();
+
+ qreal relativeX() const;
+ void setRelativeX(qreal x);
+ bool hasRelativeX();
+
+ qreal relativeY() const;
+ void setRelativeY(qreal y);
+ bool hasRelativeY();
+
+ virtual void addToPath(QPainterPath &, const QQuickPathData &) {}
+
+Q_SIGNALS:
+ void xChanged();
+ void yChanged();
+ void relativeXChanged();
+ void relativeYChanged();
+
+private:
+ QQmlNullableValue<qreal> _x;
+ QQmlNullableValue<qreal> _y;
+ QQmlNullableValue<qreal> _relativeX;
+ QQmlNullableValue<qreal> _relativeY;
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathLine : public QQuickCurve
+{
+ Q_OBJECT
+public:
+ QQuickPathLine(QObject *parent=0) : QQuickCurve(parent) {}
+
+ void addToPath(QPainterPath &path, const QQuickPathData &);
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathQuad : public QQuickCurve
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY controlXChanged)
+ Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY controlYChanged)
+ Q_PROPERTY(qreal relativeControlX READ relativeControlX WRITE setRelativeControlX NOTIFY relativeControlXChanged)
+ Q_PROPERTY(qreal relativeControlY READ relativeControlY WRITE setRelativeControlY NOTIFY relativeControlYChanged)
+public:
+ QQuickPathQuad(QObject *parent=0) : QQuickCurve(parent), _controlX(0), _controlY(0) {}
+
+ qreal controlX() const;
+ void setControlX(qreal x);
+
+ qreal controlY() const;
+ void setControlY(qreal y);
+
+ qreal relativeControlX() const;
+ void setRelativeControlX(qreal x);
+ bool hasRelativeControlX();
+
+ qreal relativeControlY() const;
+ void setRelativeControlY(qreal y);
+ bool hasRelativeControlY();
+
+ void addToPath(QPainterPath &path, const QQuickPathData &);
+
+Q_SIGNALS:
+ void controlXChanged();
+ void controlYChanged();
+ void relativeControlXChanged();
+ void relativeControlYChanged();
+
+private:
+ qreal _controlX;
+ qreal _controlY;
+ QQmlNullableValue<qreal> _relativeControlX;
+ QQmlNullableValue<qreal> _relativeControlY;
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathCubic : public QQuickCurve
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal control1X READ control1X WRITE setControl1X NOTIFY control1XChanged)
+ Q_PROPERTY(qreal control1Y READ control1Y WRITE setControl1Y NOTIFY control1YChanged)
+ Q_PROPERTY(qreal control2X READ control2X WRITE setControl2X NOTIFY control2XChanged)
+ Q_PROPERTY(qreal control2Y READ control2Y WRITE setControl2Y NOTIFY control2YChanged)
+ Q_PROPERTY(qreal relativeControl1X READ relativeControl1X WRITE setRelativeControl1X NOTIFY relativeControl1XChanged)
+ Q_PROPERTY(qreal relativeControl1Y READ relativeControl1Y WRITE setRelativeControl1Y NOTIFY relativeControl1YChanged)
+ Q_PROPERTY(qreal relativeControl2X READ relativeControl2X WRITE setRelativeControl2X NOTIFY relativeControl2XChanged)
+ Q_PROPERTY(qreal relativeControl2Y READ relativeControl2Y WRITE setRelativeControl2Y NOTIFY relativeControl2YChanged)
+public:
+ QQuickPathCubic(QObject *parent=0) : QQuickCurve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {}
+
+ qreal control1X() const;
+ void setControl1X(qreal x);
+
+ qreal control1Y() const;
+ void setControl1Y(qreal y);
+
+ qreal control2X() const;
+ void setControl2X(qreal x);
+
+ qreal control2Y() const;
+ void setControl2Y(qreal y);
+
+ qreal relativeControl1X() const;
+ void setRelativeControl1X(qreal x);
+ bool hasRelativeControl1X();
+
+ qreal relativeControl1Y() const;
+ void setRelativeControl1Y(qreal y);
+ bool hasRelativeControl1Y();
+
+ qreal relativeControl2X() const;
+ void setRelativeControl2X(qreal x);
+ bool hasRelativeControl2X();
+
+ qreal relativeControl2Y() const;
+ void setRelativeControl2Y(qreal y);
+ bool hasRelativeControl2Y();
+
+ void addToPath(QPainterPath &path, const QQuickPathData &);
+
+Q_SIGNALS:
+ void control1XChanged();
+ void control1YChanged();
+ void control2XChanged();
+ void control2YChanged();
+ void relativeControl1XChanged();
+ void relativeControl1YChanged();
+ void relativeControl2XChanged();
+ void relativeControl2YChanged();
+
+private:
+ qreal _control1X;
+ qreal _control1Y;
+ qreal _control2X;
+ qreal _control2Y;
+ QQmlNullableValue<qreal> _relativeControl1X;
+ QQmlNullableValue<qreal> _relativeControl1Y;
+ QQmlNullableValue<qreal> _relativeControl2X;
+ QQmlNullableValue<qreal> _relativeControl2Y;
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathCatmullRomCurve : public QQuickCurve
+{
+ Q_OBJECT
+public:
+ QQuickPathCatmullRomCurve(QObject *parent=0) : QQuickCurve(parent) {}
+
+ void addToPath(QPainterPath &path, const QQuickPathData &);
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathArc : public QQuickCurve
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal radiusX READ radiusX WRITE setRadiusX NOTIFY radiusXChanged)
+ Q_PROPERTY(qreal radiusY READ radiusY WRITE setRadiusY NOTIFY radiusYChanged)
+ Q_PROPERTY(bool useLargeArc READ useLargeArc WRITE setUseLargeArc NOTIFY useLargeArcChanged)
+ Q_PROPERTY(ArcDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
+
+public:
+ QQuickPathArc(QObject *parent=0)
+ : QQuickCurve(parent), _radiusX(0), _radiusY(0), _useLargeArc(false), _direction(Clockwise) {}
+
+ enum ArcDirection { Clockwise, Counterclockwise };
+ Q_ENUMS(ArcDirection)
+
+ qreal radiusX() const;
+ void setRadiusX(qreal);
+
+ qreal radiusY() const;
+ void setRadiusY(qreal);
+
+ bool useLargeArc() const;
+ void setUseLargeArc(bool);
+
+ ArcDirection direction() const;
+ void setDirection(ArcDirection direction);
+
+ void addToPath(QPainterPath &path, const QQuickPathData &);
+
+Q_SIGNALS:
+ void radiusXChanged();
+ void radiusYChanged();
+ void useLargeArcChanged();
+ void directionChanged();
+
+private:
+ qreal _radiusX;
+ qreal _radiusY;
+ bool _useLargeArc;
+ ArcDirection _direction;
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathSvg : public QQuickCurve
+{
+ Q_OBJECT
+ Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
+public:
+ QQuickPathSvg(QObject *parent=0) : QQuickCurve(parent) {}
+
+ QString path() const;
+ void setPath(const QString &path);
+
+ void addToPath(QPainterPath &path, const QQuickPathData &);
+
+Q_SIGNALS:
+ void pathChanged();
+
+private:
+ QString _path;
+};
+
+class Q_AUTOTEST_EXPORT QQuickPathPercent : public QQuickPathElement
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
+public:
+ QQuickPathPercent(QObject *parent=0) : QQuickPathElement(parent) {}
+
+ qreal value() const;
+ void setValue(qreal value);
+
+signals:
+ void valueChanged();
+
+private:
+ qreal _value;
+};
+
+struct QQuickCachedBezier
+{
+ QQuickCachedBezier() : isValid(false) {}
+ QBezier bezier;
+ int element;
+ qreal bezLength;
+ qreal currLength;
+ qreal p;
+ bool isValid;
+};
+
+class QQuickPathPrivate;
+class Q_AUTOTEST_EXPORT QQuickPath : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QQmlListProperty<QQuickPathElement> pathElements READ pathElements)
+ Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged)
+ Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged)
+ Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
+ Q_CLASSINFO("DefaultProperty", "pathElements")
+ Q_INTERFACES(QQmlParserStatus)
+public:
+ QQuickPath(QObject *parent=0);
+ ~QQuickPath();
+
+ QQmlListProperty<QQuickPathElement> pathElements();
+
+ qreal startX() const;
+ void setStartX(qreal x);
+ bool hasStartX() const;
+
+ qreal startY() const;
+ void setStartY(qreal y);
+ bool hasStartY() const;
+
+ bool isClosed() const;
+ bool hasEnd() const;
+
+ QPainterPath path() const;
+ QStringList attributes() const;
+ qreal attributeAt(const QString &, qreal) const;
+ QPointF pointAt(qreal) const;
+ QPointF sequentialPointAt(qreal p, qreal *angle = 0) const;
+ void invalidateSequentialHistory() const;
+
+Q_SIGNALS:
+ void changed();
+ void startXChanged();
+ void startYChanged();
+
+protected:
+ virtual void componentComplete();
+ virtual void classBegin();
+
+private Q_SLOTS:
+ void processPath();
+
+private:
+ struct AttributePoint {
+ AttributePoint() : percent(0), scale(1), origpercent(0) {}
+ AttributePoint(const AttributePoint &other)
+ : percent(other.percent), scale(other.scale), origpercent(other.origpercent), values(other.values) {}
+ AttributePoint &operator=(const AttributePoint &other) {
+ percent = other.percent; scale = other.scale; origpercent = other.origpercent; values = other.values; return *this;
+ }
+ qreal percent; //massaged percent along the painter path
+ qreal scale;
+ qreal origpercent; //'real' percent along the painter path
+ QHash<QString, qreal> values;
+ };
+
+ void interpolate(int idx, const QString &name, qreal value);
+ void endpoint(const QString &name);
+ void createPointCache() const;
+
+ static void interpolate(QList<AttributePoint> &points, int idx, const QString &name, qreal value);
+ static void endpoint(QList<AttributePoint> &attributePoints, const QString &name);
+ static QPointF forwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = 0);
+ static QPointF backwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = 0);
+
+private:
+ Q_DISABLE_COPY(QQuickPath)
+ Q_DECLARE_PRIVATE(QQuickPath)
+ friend class QQuickPathAnimationUpdater;
+
+public:
+ QPainterPath createPath(const QPointF &startPoint, const QPointF &endPoint, const QStringList &attributes, qreal &pathLength, QList<AttributePoint> &attributePoints, bool *closed = 0);
+ static QPointF sequentialPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = 0);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPathElement)
+QML_DECLARE_TYPE(QQuickPathAttribute)
+QML_DECLARE_TYPE(QQuickCurve)
+QML_DECLARE_TYPE(QQuickPathLine)
+QML_DECLARE_TYPE(QQuickPathQuad)
+QML_DECLARE_TYPE(QQuickPathCubic)
+QML_DECLARE_TYPE(QQuickPathCatmullRomCurve)
+QML_DECLARE_TYPE(QQuickPathArc)
+QML_DECLARE_TYPE(QQuickPathSvg)
+QML_DECLARE_TYPE(QQuickPathPercent)
+QML_DECLARE_TYPE(QQuickPath)
+
+QT_END_HEADER
+
+#endif // QQUICKPATH_H
diff --git a/src/quick/util/qquickpath_p_p.h b/src/quick/util/qquickpath_p_p.h
new file mode 100644
index 0000000000..a7be68c964
--- /dev/null
+++ b/src/quick/util/qquickpath_p_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPATH_P_H
+#define QQUICKPATH_P_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 "qquickpath_p.h"
+
+#include <qqml.h>
+#include <QtCore/QStringList>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPathPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickPath)
+
+public:
+ QQuickPathPrivate() : pathLength(0), closed(false), componentComplete(true) { }
+
+ QPainterPath _path;
+ QList<QQuickPathElement*> _pathElements;
+ mutable QVector<QPointF> _pointCache;
+ QList<QQuickPath::AttributePoint> _attributePoints;
+ QStringList _attributes;
+ QList<QQuickCurve*> _pathCurves;
+ mutable QQuickCachedBezier prevBez;
+ QQmlNullableValue<qreal> startX;
+ QQmlNullableValue<qreal> startY;
+ qreal pathLength;
+ bool closed;
+ bool componentComplete;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/quick/util/qquickpathinterpolator.cpp b/src/quick/util/qquickpathinterpolator.cpp
new file mode 100644
index 0000000000..2b5fb62872
--- /dev/null
+++ b/src/quick/util/qquickpathinterpolator.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickpathinterpolator_p.h"
+
+#include "qquickpath_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass PathInterpolator QQuickPathInterpolator
+ \inqmlmodule QtQuick 2
+ \brief The PathInterpolator element provides a way to manually animate along a path.
+
+ PathInterpolator provides \c x, \c y, and \c angle information for a particular \c progress
+ along a path.
+
+ In the following example, we animate a green rectangle along a bezier path.
+
+ \snippet doc/src/snippets/qml/pathinterpolator.qml 0
+*/
+
+QQuickPathInterpolator::QQuickPathInterpolator(QObject *parent) :
+ QObject(parent), _path(0), _x(0), _y(0), _angle(0), _progress(0)
+{
+}
+
+/*!
+ \qmlproperty Path QtQuick2::PathInterpolator::path
+ This property holds the path to interpolate.
+
+ For more information on defining a path see the \l Path documentation.
+*/
+QQuickPath *QQuickPathInterpolator::path() const
+{
+ return _path;
+}
+
+void QQuickPathInterpolator::setPath(QQuickPath *path)
+{
+ if (_path == path)
+ return;
+ if (_path)
+ disconnect(_path, SIGNAL(changed()), this, SLOT(_q_pathUpdated()));
+ _path = path;
+ connect(_path, SIGNAL(changed()), this, SLOT(_q_pathUpdated()));
+ emit pathChanged();
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathInterpolator::progress
+ This property holds the current progress along the path.
+
+ Typical usage of PathInterpolator is to set the progress
+ (often via a NumberAnimation), and read the corresponding
+ values for x, y, and angle (often via bindings to these values).
+
+ Progress ranges from 0.0 to 1.0.
+*/
+qreal QQuickPathInterpolator::progress() const
+{
+ return _progress;
+}
+
+void QQuickPathInterpolator::setProgress(qreal progress)
+{
+ if (progress == _progress)
+ return;
+ _progress = progress;
+ emit progressChanged();
+ _q_pathUpdated();
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathInterpolator::x
+ \qmlproperty real QtQuick2::PathInterpolator::y
+
+ These properties hold the position of the path at \l progress.
+*/
+qreal QQuickPathInterpolator::x() const
+{
+ return _x;
+}
+
+qreal QQuickPathInterpolator::y() const
+{
+ return _y;
+}
+
+/*!
+ \qmlproperty real QtQuick2::PathInterpolator::angle
+
+ This property holds the angle of the path tangent at \l progress.
+
+ Angles are reported clockwise, with zero degrees at the 3 o'clock position.
+*/
+qreal QQuickPathInterpolator::angle() const
+{
+ return _angle;
+}
+
+void QQuickPathInterpolator::_q_pathUpdated()
+{
+ if (! _path)
+ return;
+
+ qreal angle = 0;
+ const QPointF pt = _path->sequentialPointAt(_progress, &angle);
+
+ if (_x != pt.x()) {
+ _x = pt.x();
+ emit xChanged();
+ }
+
+ if (_y != pt.y()) {
+ _y = pt.y();
+ emit yChanged();
+ }
+
+ //convert to clockwise
+ angle = qreal(360) - angle;
+ if (qFuzzyCompare(angle, qreal(360)))
+ angle = qreal(0);
+
+ if (angle != _angle) {
+ _angle = angle;
+ emit angleChanged();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickpathinterpolator_p.h b/src/quick/util/qquickpathinterpolator_p.h
new file mode 100644
index 0000000000..b018ce337a
--- /dev/null
+++ b/src/quick/util/qquickpathinterpolator_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPATHINTERPOLATOR_P_H
+#define QQUICKPATHINTERPOLATOR_P_H
+
+#include <qqml.h>
+#include <QObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPath;
+class Q_AUTOTEST_EXPORT QQuickPathInterpolator : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQuickPath *path READ path WRITE setPath NOTIFY pathChanged)
+ Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
+ Q_PROPERTY(qreal x READ x NOTIFY xChanged)
+ Q_PROPERTY(qreal y READ y NOTIFY yChanged)
+ Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged)
+public:
+ explicit QQuickPathInterpolator(QObject *parent = 0);
+
+ QQuickPath *path() const;
+ void setPath(QQuickPath *path);
+
+ qreal progress() const;
+ void setProgress(qreal progress);
+
+ qreal x() const;
+ qreal y() const;
+ qreal angle() const;
+
+Q_SIGNALS:
+ void pathChanged();
+ void progressChanged();
+ void xChanged();
+ void yChanged();
+ void angleChanged();
+
+private Q_SLOTS:
+ void _q_pathUpdated();
+
+private:
+ QQuickPath *_path;
+ qreal _x;
+ qreal _y;
+ qreal _angle;
+ qreal _progress;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPathInterpolator)
+
+QT_END_HEADER
+
+#endif // QQUICKPATHINTERPOLATOR_P_H
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
new file mode 100644
index 0000000000..aae5306aa7
--- /dev/null
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -0,0 +1,1280 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickpixmapcache_p.h"
+#include <qqmlnetworkaccessmanagerfactory.h>
+#include <qqmlimageprovider.h>
+
+#include <qqmlengine.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlengine_p.h>
+
+#include <QtQuick/private/qsgtexture_p.h>
+#include <QtQuick/private/qsgcontext_p.h>
+
+#include <QCoreApplication>
+#include <QImageReader>
+#include <QHash>
+#include <QNetworkReply>
+#include <QPixmapCache>
+#include <QFile>
+#include <QThread>
+#include <QMutex>
+#include <QMutexLocker>
+#include <QWaitCondition>
+#include <QBuffer>
+#include <QWaitCondition>
+#include <QtCore/qdebug.h>
+#include <private/qobject_p.h>
+#include <QSslError>
+
+#define IMAGEREQUEST_MAX_REQUEST_COUNT 8
+#define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16
+#define CACHE_EXPIRE_TIME 30
+#define CACHE_REMOVAL_FRACTION 4
+
+QT_BEGIN_NAMESPACE
+
+// The cache limit describes the maximum "junk" in the cache.
+static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded in qpixmapcache.cpp
+
+QSGTexture *QQuickDefaultTextureFactory::createTexture(QQuickCanvas *) const
+{
+ QSGPlainTexture *t = new QSGPlainTexture();
+ t->setImage(im);
+ return t;
+}
+
+class QQuickPixmapReader;
+class QQuickPixmapData;
+class QQuickPixmapReply : public QObject
+{
+ Q_OBJECT
+public:
+ enum ReadError { NoError, Loading, Decoding };
+
+ QQuickPixmapReply(QQuickPixmapData *);
+ ~QQuickPixmapReply();
+
+ QQuickPixmapData *data;
+ QQmlEngine *engineForReader; // always access reader inside readerMutex
+ QSize requestSize;
+ QUrl url;
+
+ bool loading;
+ int redirectCount;
+
+ class Event : public QEvent {
+ public:
+ Event(ReadError, const QString &, const QSize &, QQuickTextureFactory *factory, const QImage &image);
+
+ ReadError error;
+ QString errorString;
+ QSize implicitSize;
+ QImage image;
+ QQuickTextureFactory *textureFactory;
+ };
+ void postReply(ReadError, const QString &, const QSize &, const QImage &image);
+ void postReply(ReadError, const QString &, const QSize &, QQuickTextureFactory *factory, const QImage &image);
+
+
+Q_SIGNALS:
+ void finished();
+ void downloadProgress(qint64, qint64);
+
+protected:
+ bool event(QEvent *event);
+
+private:
+ Q_DISABLE_COPY(QQuickPixmapReply)
+
+public:
+ static int finishedIndex;
+ static int downloadProgressIndex;
+};
+
+class QQuickPixmapReaderThreadObject : public QObject {
+ Q_OBJECT
+public:
+ QQuickPixmapReaderThreadObject(QQuickPixmapReader *);
+ void processJobs();
+ virtual bool event(QEvent *e);
+private slots:
+ void networkRequestDone();
+private:
+ QQuickPixmapReader *reader;
+};
+
+class QQuickPixmapData;
+class QQuickPixmapReader : public QThread
+{
+ Q_OBJECT
+public:
+ QQuickPixmapReader(QQmlEngine *eng);
+ ~QQuickPixmapReader();
+
+ QQuickPixmapReply *getImage(QQuickPixmapData *);
+ void cancel(QQuickPixmapReply *rep);
+
+ static QQuickPixmapReader *instance(QQmlEngine *engine);
+ static QQuickPixmapReader *existingInstance(QQmlEngine *engine);
+
+protected:
+ void run();
+
+private:
+ friend class QQuickPixmapReaderThreadObject;
+ void processJobs();
+ void processJob(QQuickPixmapReply *, const QUrl &, const QSize &);
+ void networkRequestDone(QNetworkReply *);
+
+ QList<QQuickPixmapReply*> jobs;
+ QList<QQuickPixmapReply*> cancelled;
+ QQmlEngine *engine;
+ QObject *eventLoopQuitHack;
+
+ QMutex mutex;
+ QQuickPixmapReaderThreadObject *threadObject;
+ QWaitCondition waitCondition;
+
+ QNetworkAccessManager *networkAccessManager();
+ QNetworkAccessManager *accessManager;
+
+ QHash<QNetworkReply*,QQuickPixmapReply*> replies;
+
+ static int replyDownloadProgress;
+ static int replyFinished;
+ static int downloadProgress;
+ static int threadNetworkRequestDone;
+ static QHash<QQmlEngine *,QQuickPixmapReader*> readers;
+public:
+ static QMutex readerMutex;
+};
+
+class QQuickPixmapData
+{
+public:
+ QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &s, const QString &e)
+ : refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Error),
+ url(u), errorString(e), requestSize(s), textureFactory(0), reply(0), prevUnreferenced(0),
+ prevUnreferencedPtr(0), nextUnreferenced(0)
+ {
+ declarativePixmaps.insert(pixmap);
+ }
+
+ QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &r)
+ : refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Loading),
+ url(u), requestSize(r), textureFactory(0), reply(0), prevUnreferenced(0), prevUnreferencedPtr(0),
+ nextUnreferenced(0)
+ {
+ declarativePixmaps.insert(pixmap);
+ }
+
+ QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QImage &p, const QSize &s, const QSize &r)
+ : refCount(1), inCache(false), privatePixmap(false), pixmapStatus(QQuickPixmap::Ready),
+ url(u), image(p), implicitSize(s), requestSize(r), textureFactory(new QQuickDefaultTextureFactory(p)), reply(0), prevUnreferenced(0),
+ prevUnreferencedPtr(0), nextUnreferenced(0)
+ {
+ declarativePixmaps.insert(pixmap);
+ }
+
+ QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, QQuickTextureFactory *factory, const QImage &p, const QSize &s, const QSize &r)
+ : refCount(1), inCache(false), privatePixmap(false), pixmapStatus(QQuickPixmap::Ready),
+ url(u), image(p), implicitSize(s), requestSize(r), textureFactory(factory), reply(0), prevUnreferenced(0),
+ prevUnreferencedPtr(0), nextUnreferenced(0)
+ {
+ declarativePixmaps.insert(pixmap);
+ }
+
+ QQuickPixmapData(QQuickPixmap *pixmap, const QImage &p)
+ : refCount(1), inCache(false), privatePixmap(true), pixmapStatus(QQuickPixmap::Ready),
+ image(p), implicitSize(p.size()), requestSize(p.size()), textureFactory(new QQuickDefaultTextureFactory(p)), reply(0), prevUnreferenced(0),
+ prevUnreferencedPtr(0), nextUnreferenced(0)
+ {
+ declarativePixmaps.insert(pixmap);
+ }
+
+ ~QQuickPixmapData()
+ {
+ while (!declarativePixmaps.isEmpty()) {
+ QQuickPixmap *referencer = declarativePixmaps.first();
+ declarativePixmaps.remove(referencer);
+ referencer->d = 0;
+ }
+ delete textureFactory;
+ }
+
+ int cost() const;
+ void addref();
+ void release();
+ void addToCache();
+ void removeFromCache();
+
+ uint refCount;
+
+ bool inCache:1;
+ bool privatePixmap:1;
+
+ QQuickPixmap::Status pixmapStatus;
+ QUrl url;
+ QString errorString;
+ QImage image;
+ QSize implicitSize;
+ QSize requestSize;
+
+ QQuickTextureFactory *textureFactory;
+
+ QIntrusiveList<QQuickPixmap, &QQuickPixmap::dataListNode> declarativePixmaps;
+ QQuickPixmapReply *reply;
+
+ QQuickPixmapData *prevUnreferenced;
+ QQuickPixmapData**prevUnreferencedPtr;
+ QQuickPixmapData *nextUnreferenced;
+};
+
+int QQuickPixmapReply::finishedIndex = -1;
+int QQuickPixmapReply::downloadProgressIndex = -1;
+
+// XXX
+QHash<QQmlEngine *,QQuickPixmapReader*> QQuickPixmapReader::readers;
+QMutex QQuickPixmapReader::readerMutex;
+
+int QQuickPixmapReader::replyDownloadProgress = -1;
+int QQuickPixmapReader::replyFinished = -1;
+int QQuickPixmapReader::downloadProgress = -1;
+int QQuickPixmapReader::threadNetworkRequestDone = -1;
+
+
+void QQuickPixmapReply::postReply(ReadError error, const QString &errorString,
+ const QSize &implicitSize, const QImage &image)
+{
+ loading = false;
+ QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, new QQuickDefaultTextureFactory(image), image));
+}
+
+void QQuickPixmapReply::postReply(ReadError error, const QString &errorString,
+ const QSize &implicitSize, QQuickTextureFactory *factory,
+ const QImage &image)
+{
+ loading = false;
+ QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, factory, image));
+}
+
+QQuickPixmapReply::Event::Event(ReadError e, const QString &s, const QSize &iSize, QQuickTextureFactory *factory, const QImage &i)
+ : QEvent(QEvent::User), error(e), errorString(s), implicitSize(iSize), image(i), textureFactory(factory)
+{
+}
+
+QNetworkAccessManager *QQuickPixmapReader::networkAccessManager()
+{
+ if (!accessManager) {
+ Q_ASSERT(threadObject);
+ accessManager = QQmlEnginePrivate::get(engine)->createNetworkAccessManager(threadObject);
+ }
+ return accessManager;
+}
+
+static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize,
+ const QSize &requestSize)
+{
+ QImageReader imgio(dev);
+
+ bool force_scale = false;
+ if (url.path().endsWith(QLatin1String(".svg"),Qt::CaseInsensitive)) {
+ imgio.setFormat("svg"); // QSvgPlugin::capabilities bug QTBUG-9053
+ force_scale = true;
+ }
+
+ if (requestSize.width() > 0 || requestSize.height() > 0) {
+ QSize s = imgio.size();
+ qreal ratio = 0.0;
+ if (requestSize.width() && (force_scale || requestSize.width() < s.width())) {
+ ratio = qreal(requestSize.width())/s.width();
+ }
+ if (requestSize.height() && (force_scale || requestSize.height() < s.height())) {
+ qreal hr = qreal(requestSize.height())/s.height();
+ if (ratio == 0.0 || hr < ratio)
+ ratio = hr;
+ }
+ if (ratio > 0.0) {
+ s.setHeight(qRound(s.height() * ratio));
+ s.setWidth(qRound(s.width() * ratio));
+ imgio.setScaledSize(s);
+ }
+ }
+
+ if (impsize)
+ *impsize = imgio.size();
+
+ if (imgio.read(image)) {
+ if (impsize && impsize->width() < 0)
+ *impsize = image->size();
+ return true;
+ } else {
+ if (errorString)
+ *errorString = QQuickPixmap::tr("Error decoding: %1: %2").arg(url.toString())
+ .arg(imgio.errorString());
+ return false;
+ }
+}
+
+QQuickPixmapReader::QQuickPixmapReader(QQmlEngine *eng)
+: QThread(eng), engine(eng), threadObject(0), accessManager(0)
+{
+ eventLoopQuitHack = new QObject;
+ eventLoopQuitHack->moveToThread(this);
+ connect(eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection);
+ start(QThread::LowestPriority);
+}
+
+QQuickPixmapReader::~QQuickPixmapReader()
+{
+ readerMutex.lock();
+ readers.remove(engine);
+ readerMutex.unlock();
+
+ mutex.lock();
+ // manually cancel all outstanding jobs.
+ foreach (QQuickPixmapReply *reply, jobs) {
+ delete reply;
+ }
+ jobs.clear();
+ QList<QQuickPixmapReply*> activeJobs = replies.values();
+ foreach (QQuickPixmapReply *reply, activeJobs) {
+ if (reply->loading) {
+ cancelled.append(reply);
+ reply->data = 0;
+ }
+ }
+ if (threadObject) threadObject->processJobs();
+ mutex.unlock();
+
+ eventLoopQuitHack->deleteLater();
+ wait();
+}
+
+void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply)
+{
+ QQuickPixmapReply *job = replies.take(reply);
+
+ if (job) {
+ job->redirectCount++;
+ if (job->redirectCount < IMAGEREQUEST_MAX_REDIRECT_RECURSION) {
+ QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = reply->url().resolved(redirect.toUrl());
+ QNetworkRequest req(url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+
+ reply->deleteLater();
+ reply = networkAccessManager()->get(req);
+
+ QMetaObject::connect(reply, replyDownloadProgress, job, downloadProgress);
+ QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
+
+ replies.insert(reply, job);
+ return;
+ }
+ }
+
+ QImage image;
+ QQuickPixmapReply::ReadError error = QQuickPixmapReply::NoError;
+ QString errorString;
+ QSize readSize;
+ if (reply->error()) {
+ error = QQuickPixmapReply::Loading;
+ errorString = reply->errorString();
+ } else {
+ QByteArray all = reply->readAll();
+ QBuffer buff(&all);
+ buff.open(QIODevice::ReadOnly);
+ if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize))
+ error = QQuickPixmapReply::Decoding;
+ }
+ // send completion event to the QQuickPixmapReply
+ mutex.lock();
+ if (!cancelled.contains(job)) {
+ QQuickTextureFactory *factory = QSGContext::createTextureFactoryFromImage(image);
+ if (factory)
+ job->postReply(error, errorString, readSize, factory, image);
+ else
+ job->postReply(error, errorString, readSize, image);
+ }
+ mutex.unlock();
+ }
+ reply->deleteLater();
+
+ // kick off event loop again incase we have dropped below max request count
+ threadObject->processJobs();
+}
+
+QQuickPixmapReaderThreadObject::QQuickPixmapReaderThreadObject(QQuickPixmapReader *i)
+: reader(i)
+{
+}
+
+void QQuickPixmapReaderThreadObject::processJobs()
+{
+ QCoreApplication::postEvent(this, new QEvent(QEvent::User));
+}
+
+bool QQuickPixmapReaderThreadObject::event(QEvent *e)
+{
+ if (e->type() == QEvent::User) {
+ reader->processJobs();
+ return true;
+ } else {
+ return QObject::event(e);
+ }
+}
+
+void QQuickPixmapReaderThreadObject::networkRequestDone()
+{
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+ reader->networkRequestDone(reply);
+}
+
+void QQuickPixmapReader::processJobs()
+{
+ QMutexLocker locker(&mutex);
+
+ while (true) {
+ if (cancelled.isEmpty() && (jobs.isEmpty() || replies.count() >= IMAGEREQUEST_MAX_REQUEST_COUNT))
+ return; // Nothing else to do
+
+ // Clean cancelled jobs
+ if (cancelled.count()) {
+ for (int i = 0; i < cancelled.count(); ++i) {
+ QQuickPixmapReply *job = cancelled.at(i);
+ QNetworkReply *reply = replies.key(job, 0);
+ if (reply && reply->isRunning()) {
+ // cancel any jobs already started
+ replies.remove(reply);
+ reply->close();
+ }
+ // deleteLater, since not owned by this thread
+ job->deleteLater();
+ }
+ cancelled.clear();
+ }
+
+ if (!jobs.isEmpty() && replies.count() < IMAGEREQUEST_MAX_REQUEST_COUNT) {
+ QQuickPixmapReply *runningJob = jobs.takeLast();
+ runningJob->loading = true;
+
+ QUrl url = runningJob->url;
+ QSize requestSize = runningJob->requestSize;
+ locker.unlock();
+ processJob(runningJob, url, requestSize);
+ locker.relock();
+ }
+ }
+}
+
+void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &url,
+ const QSize &requestSize)
+{
+ // fetch
+ if (url.scheme() == QLatin1String("image")) {
+ // Use QmlImageProvider
+ QSize readSize;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+ QQmlImageProvider::ImageType imageType = ep->getImageProviderType(url);
+ if (imageType == QQmlImageProvider::Invalid) {
+ QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::Loading;
+ QString errorStr = QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString());
+ QImage image;
+ mutex.lock();
+ if (!cancelled.contains(runningJob))
+ runningJob->postReply(errorCode, errorStr, readSize, image);
+ mutex.unlock();
+ } else if (imageType == QQmlImageProvider::Image) {
+ QImage image = ep->getImageFromProvider(url, &readSize, requestSize);
+ QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError;
+ QString errorStr;
+ if (image.isNull()) {
+ errorCode = QQuickPixmapReply::Loading;
+ errorStr = QQuickPixmap::tr("Failed to get image from provider: %1").arg(url.toString());
+ }
+ mutex.lock();
+ if (!cancelled.contains(runningJob)) {
+ QQuickTextureFactory *factory = QSGContext::createTextureFactoryFromImage(image);
+ if (factory)
+ runningJob->postReply(errorCode, errorStr, readSize, factory, image);
+ else
+ runningJob->postReply(errorCode, errorStr, readSize, image);
+ }
+
+ mutex.unlock();
+ } else {
+ QQuickTextureFactory *t = ep->getTextureFromProvider(url, &readSize, requestSize);
+ QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError;
+ QString errorStr;
+ if (!t) {
+ errorCode = QQuickPixmapReply::Loading;
+ errorStr = QQuickPixmap::tr("Failed to get texture from provider: %1").arg(url.toString());
+ }
+ mutex.lock();
+ if (!cancelled.contains(runningJob))
+ runningJob->postReply(errorCode, errorStr, readSize, t, QImage());
+ mutex.unlock();
+
+ }
+
+ } else {
+ QString lf = QQmlEnginePrivate::urlToLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
+ // Image is local - load/decode immediately
+ QImage image;
+ QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError;
+ QString errorStr;
+ QFile f(lf);
+ QSize readSize;
+ if (f.open(QIODevice::ReadOnly)) {
+ if (!readImage(url, &f, &image, &errorStr, &readSize, requestSize))
+ errorCode = QQuickPixmapReply::Loading;
+ } else {
+ errorStr = QQuickPixmap::tr("Cannot open: %1").arg(url.toString());
+ errorCode = QQuickPixmapReply::Loading;
+ }
+ mutex.lock();
+ if (!cancelled.contains(runningJob)) {
+ QQuickTextureFactory *factory = QSGContext::createTextureFactoryFromImage(image);
+ if (factory)
+ runningJob->postReply(errorCode, errorStr, readSize, factory, image);
+ else
+ runningJob->postReply(errorCode, errorStr, readSize, image);
+ }
+ mutex.unlock();
+ } else {
+ // Network resource
+ QNetworkRequest req(url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ QNetworkReply *reply = networkAccessManager()->get(req);
+
+ QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
+ QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
+
+ replies.insert(reply, runningJob);
+ }
+ }
+}
+
+QQuickPixmapReader *QQuickPixmapReader::instance(QQmlEngine *engine)
+{
+ // XXX NOTE: must be called within readerMutex locking.
+ QQuickPixmapReader *reader = readers.value(engine);
+ if (!reader) {
+ reader = new QQuickPixmapReader(engine);
+ readers.insert(engine, reader);
+ }
+
+ return reader;
+}
+
+QQuickPixmapReader *QQuickPixmapReader::existingInstance(QQmlEngine *engine)
+{
+ // XXX NOTE: must be called within readerMutex locking.
+ return readers.value(engine, 0);
+}
+
+QQuickPixmapReply *QQuickPixmapReader::getImage(QQuickPixmapData *data)
+{
+ mutex.lock();
+ QQuickPixmapReply *reply = new QQuickPixmapReply(data);
+ reply->engineForReader = engine;
+ jobs.append(reply);
+ // XXX
+ if (threadObject) threadObject->processJobs();
+ mutex.unlock();
+ return reply;
+}
+
+void QQuickPixmapReader::cancel(QQuickPixmapReply *reply)
+{
+ mutex.lock();
+ if (reply->loading) {
+ cancelled.append(reply);
+ reply->data = 0;
+ // XXX
+ if (threadObject) threadObject->processJobs();
+ } else {
+ jobs.removeAll(reply);
+ delete reply;
+ }
+ mutex.unlock();
+}
+
+void QQuickPixmapReader::run()
+{
+ if (replyDownloadProgress == -1) {
+ const QMetaObject *nr = &QNetworkReply::staticMetaObject;
+ const QMetaObject *pr = &QQuickPixmapReply::staticMetaObject;
+ const QMetaObject *ir = &QQuickPixmapReaderThreadObject::staticMetaObject;
+ replyDownloadProgress = nr->indexOfSignal("downloadProgress(qint64,qint64)");
+ replyFinished = nr->indexOfSignal("finished()");
+ downloadProgress = pr->indexOfSignal("downloadProgress(qint64,qint64)");
+ threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()");
+ }
+
+ mutex.lock();
+ threadObject = new QQuickPixmapReaderThreadObject(this);
+ mutex.unlock();
+
+ processJobs();
+ exec();
+
+ delete threadObject;
+ threadObject = 0;
+}
+
+class QQuickPixmapKey
+{
+public:
+ const QUrl *url;
+ const QSize *size;
+};
+
+inline bool operator==(const QQuickPixmapKey &lhs, const QQuickPixmapKey &rhs)
+{
+ return *lhs.size == *rhs.size && *lhs.url == *rhs.url;
+}
+
+inline uint qHash(const QQuickPixmapKey &key)
+{
+ return qHash(*key.url) ^ key.size->width() ^ key.size->height();
+}
+
+class QSGContext;
+
+class QQuickPixmapStore : public QObject
+{
+ Q_OBJECT
+public:
+ QQuickPixmapStore();
+ ~QQuickPixmapStore();
+
+ void unreferencePixmap(QQuickPixmapData *);
+ void referencePixmap(QQuickPixmapData *);
+
+ void purgeCache();
+
+protected:
+ virtual void timerEvent(QTimerEvent *);
+
+public:
+ QHash<QQuickPixmapKey, QQuickPixmapData *> m_cache;
+
+private:
+ void shrinkCache(int remove);
+
+ QQuickPixmapData *m_unreferencedPixmaps;
+ QQuickPixmapData *m_lastUnreferencedPixmap;
+
+ int m_unreferencedCost;
+ int m_timerId;
+ bool m_destroying;
+};
+Q_GLOBAL_STATIC(QQuickPixmapStore, pixmapStore);
+
+
+QQuickPixmapStore::QQuickPixmapStore()
+ : m_unreferencedPixmaps(0), m_lastUnreferencedPixmap(0), m_unreferencedCost(0), m_timerId(-1), m_destroying(false)
+{
+}
+
+QQuickPixmapStore::~QQuickPixmapStore()
+{
+ m_destroying = true;
+
+ int leakedPixmaps = 0;
+ QList<QQuickPixmapData*> cachedData = m_cache.values();
+
+ // Prevent unreferencePixmap() from assuming it needs to kick
+ // off the cache expiry timer, as we're shrinking the cache
+ // manually below after releasing all the pixmaps.
+ m_timerId = -2;
+
+ // unreference all (leaked) pixmaps
+ foreach (QQuickPixmapData* pixmap, cachedData) {
+ int currRefCount = pixmap->refCount;
+ if (currRefCount) {
+ leakedPixmaps++;
+ while (currRefCount > 0) {
+ pixmap->release();
+ currRefCount--;
+ }
+ }
+ }
+
+ // free all unreferenced pixmaps
+ while (m_lastUnreferencedPixmap) {
+ shrinkCache(20);
+ }
+
+ if (leakedPixmaps)
+ qDebug("Number of leaked pixmaps: %i", leakedPixmaps);
+}
+
+void QQuickPixmapStore::unreferencePixmap(QQuickPixmapData *data)
+{
+ Q_ASSERT(data->prevUnreferenced == 0);
+ Q_ASSERT(data->prevUnreferencedPtr == 0);
+ Q_ASSERT(data->nextUnreferenced == 0);
+
+ data->nextUnreferenced = m_unreferencedPixmaps;
+ data->prevUnreferencedPtr = &m_unreferencedPixmaps;
+ if (!m_destroying) // the texture factories may have been cleaned up already.
+ m_unreferencedCost += data->cost();
+
+ m_unreferencedPixmaps = data;
+ if (m_unreferencedPixmaps->nextUnreferenced) {
+ m_unreferencedPixmaps->nextUnreferenced->prevUnreferenced = m_unreferencedPixmaps;
+ m_unreferencedPixmaps->nextUnreferenced->prevUnreferencedPtr = &m_unreferencedPixmaps->nextUnreferenced;
+ }
+
+ if (!m_lastUnreferencedPixmap)
+ m_lastUnreferencedPixmap = data;
+
+ shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit
+
+ if (m_timerId == -1 && m_unreferencedPixmaps && !m_destroying)
+ m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000);
+}
+
+void QQuickPixmapStore::referencePixmap(QQuickPixmapData *data)
+{
+ Q_ASSERT(data->prevUnreferencedPtr);
+
+ *data->prevUnreferencedPtr = data->nextUnreferenced;
+ if (data->nextUnreferenced) {
+ data->nextUnreferenced->prevUnreferencedPtr = data->prevUnreferencedPtr;
+ data->nextUnreferenced->prevUnreferenced = data->prevUnreferenced;
+ }
+ if (m_lastUnreferencedPixmap == data)
+ m_lastUnreferencedPixmap = data->prevUnreferenced;
+
+ data->nextUnreferenced = 0;
+ data->prevUnreferencedPtr = 0;
+ data->prevUnreferenced = 0;
+
+ m_unreferencedCost -= data->cost();
+}
+
+void QQuickPixmapStore::shrinkCache(int remove)
+{
+ while ((remove > 0 || m_unreferencedCost > cache_limit) && m_lastUnreferencedPixmap) {
+ QQuickPixmapData *data = m_lastUnreferencedPixmap;
+ Q_ASSERT(data->nextUnreferenced == 0);
+
+ *data->prevUnreferencedPtr = 0;
+ m_lastUnreferencedPixmap = data->prevUnreferenced;
+ data->prevUnreferencedPtr = 0;
+ data->prevUnreferenced = 0;
+
+ if (!m_destroying) {
+ remove -= data->cost();
+ m_unreferencedCost -= data->cost();
+ }
+ data->removeFromCache();
+ delete data;
+ }
+}
+
+void QQuickPixmapStore::timerEvent(QTimerEvent *)
+{
+ int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION;
+
+ shrinkCache(removalCost);
+
+ if (m_unreferencedPixmaps == 0) {
+ killTimer(m_timerId);
+ m_timerId = -1;
+ }
+}
+
+void QQuickPixmapStore::purgeCache()
+{
+ shrinkCache(m_unreferencedCost);
+}
+
+void QQuickPixmap::purgeCache()
+{
+ pixmapStore()->purgeCache();
+}
+
+QQuickPixmapReply::QQuickPixmapReply(QQuickPixmapData *d)
+: data(d), engineForReader(0), requestSize(d->requestSize), url(d->url), loading(false), redirectCount(0)
+{
+ if (finishedIndex == -1) {
+ finishedIndex = QQuickPixmapReply::staticMetaObject.indexOfSignal("finished()");
+ downloadProgressIndex = QQuickPixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
+ }
+}
+
+QQuickPixmapReply::~QQuickPixmapReply()
+{
+}
+
+bool QQuickPixmapReply::event(QEvent *event)
+{
+ if (event->type() == QEvent::User) {
+
+ if (data) {
+ Event *de = static_cast<Event *>(event);
+ data->pixmapStatus = (de->error == NoError) ? QQuickPixmap::Ready : QQuickPixmap::Error;
+
+ if (data->pixmapStatus == QQuickPixmap::Ready) {
+ if (de->textureFactory) {
+ data->textureFactory = de->textureFactory;
+ }
+ data->image = de->image;
+ data->implicitSize = de->implicitSize;
+ } else {
+ data->errorString = de->errorString;
+ data->removeFromCache(); // We don't continue to cache error'd pixmaps
+ }
+
+ data->reply = 0;
+ emit finished();
+ }
+
+ delete this;
+ return true;
+ } else {
+ return QObject::event(event);
+ }
+}
+
+int QQuickPixmapData::cost() const
+{
+ if (textureFactory)
+ return textureFactory->textureByteCount();
+ return image.byteCount();
+}
+
+void QQuickPixmapData::addref()
+{
+ ++refCount;
+ if (prevUnreferencedPtr)
+ pixmapStore()->referencePixmap(this);
+}
+
+void QQuickPixmapData::release()
+{
+ Q_ASSERT(refCount > 0);
+ --refCount;
+ if (refCount == 0) {
+ if (reply) {
+ QQuickPixmapReply *cancelReply = reply;
+ reply->data = 0;
+ reply = 0;
+ QQuickPixmapReader::readerMutex.lock();
+ QQuickPixmapReader *reader = QQuickPixmapReader::existingInstance(cancelReply->engineForReader);
+ if (reader)
+ reader->cancel(cancelReply);
+ QQuickPixmapReader::readerMutex.unlock();
+ }
+
+ if (pixmapStatus == QQuickPixmap::Ready) {
+ pixmapStore()->unreferencePixmap(this);
+ } else {
+ removeFromCache();
+ delete this;
+ }
+ }
+}
+
+void QQuickPixmapData::addToCache()
+{
+ if (!inCache) {
+ QQuickPixmapKey key = { &url, &requestSize };
+ pixmapStore()->m_cache.insert(key, this);
+ inCache = true;
+ }
+}
+
+void QQuickPixmapData::removeFromCache()
+{
+ if (inCache) {
+ QQuickPixmapKey key = { &url, &requestSize };
+ pixmapStore()->m_cache.remove(key);
+ inCache = false;
+ }
+}
+
+static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, QQmlEngine *engine, const QUrl &url, const QSize &requestSize, bool *ok)
+{
+ if (url.scheme() == QLatin1String("image")) {
+ QSize readSize;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
+ QQmlImageProvider::ImageType imageType = ep->getImageProviderType(url);
+
+ switch (imageType) {
+ case QQmlImageProvider::Invalid:
+ return new QQuickPixmapData(declarativePixmap, url, requestSize,
+ QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString()));
+ case QQmlImageProvider::Texture:
+ {
+ QQuickTextureFactory *texture = ep->getTextureFromProvider(url, &readSize, requestSize);
+ if (texture) {
+ *ok = true;
+ return new QQuickPixmapData(declarativePixmap, url, texture, QImage(), readSize, requestSize);
+ }
+ }
+
+ case QQmlImageProvider::Image:
+ {
+ QImage image = ep->getImageFromProvider(url, &readSize, requestSize);
+ if (!image.isNull()) {
+ *ok = true;
+ return new QQuickPixmapData(declarativePixmap, url, image, readSize, requestSize);
+ }
+ }
+ case QQmlImageProvider::Pixmap:
+ {
+ QPixmap pixmap = ep->getPixmapFromProvider(url, &readSize, requestSize);
+ if (!pixmap.isNull()) {
+ *ok = true;
+ return new QQuickPixmapData(declarativePixmap, url, pixmap.toImage(), readSize, requestSize);
+ }
+ }
+ }
+
+ // provider has bad image type, or provider returned null image
+ return new QQuickPixmapData(declarativePixmap, url, requestSize,
+ QQuickPixmap::tr("Failed to get image from provider: %1").arg(url.toString()));
+ }
+
+ QString localFile = QQmlEnginePrivate::urlToLocalFileOrQrc(url);
+ if (localFile.isEmpty())
+ return 0;
+
+ QFile f(localFile);
+ QSize readSize;
+ QString errorString;
+
+ if (f.open(QIODevice::ReadOnly)) {
+ QImage image;
+
+ if (readImage(url, &f, &image, &errorString, &readSize, requestSize)) {
+ *ok = true;
+ return new QQuickPixmapData(declarativePixmap, url, image, readSize, requestSize);
+ }
+ errorString = QQuickPixmap::tr("Invalid image data: %1").arg(url.toString());
+
+ } else {
+ errorString = QQuickPixmap::tr("Cannot open: %1").arg(url.toString());
+ }
+ return new QQuickPixmapData(declarativePixmap, url, requestSize, errorString);
+}
+
+
+struct QQuickPixmapNull {
+ QUrl url;
+ QImage image;
+ QSize size;
+};
+Q_GLOBAL_STATIC(QQuickPixmapNull, nullPixmap);
+
+QQuickPixmap::QQuickPixmap()
+: d(0)
+{
+}
+
+QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url)
+: d(0)
+{
+ load(engine, url);
+}
+
+QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url, const QSize &size)
+: d(0)
+{
+ load(engine, url, size);
+}
+
+QQuickPixmap::~QQuickPixmap()
+{
+ if (d) {
+ d->declarativePixmaps.remove(this);
+ d->release();
+ d = 0;
+ }
+}
+
+bool QQuickPixmap::isNull() const
+{
+ return d == 0;
+}
+
+bool QQuickPixmap::isReady() const
+{
+ return status() == Ready;
+}
+
+bool QQuickPixmap::isError() const
+{
+ return status() == Error;
+}
+
+bool QQuickPixmap::isLoading() const
+{
+ return status() == Loading;
+}
+
+QString QQuickPixmap::error() const
+{
+ if (d)
+ return d->errorString;
+ else
+ return QString();
+}
+
+QQuickPixmap::Status QQuickPixmap::status() const
+{
+ if (d)
+ return d->pixmapStatus;
+ else
+ return Null;
+}
+
+const QUrl &QQuickPixmap::url() const
+{
+ if (d)
+ return d->url;
+ else
+ return nullPixmap()->url;
+}
+
+const QSize &QQuickPixmap::implicitSize() const
+{
+ if (d)
+ return d->implicitSize;
+ else
+ return nullPixmap()->size;
+}
+
+const QSize &QQuickPixmap::requestSize() const
+{
+ if (d)
+ return d->requestSize;
+ else
+ return nullPixmap()->size;
+}
+
+QQuickTextureFactory *QQuickPixmap::textureFactory() const
+{
+ if (d)
+ return d->textureFactory;
+
+ return 0;
+}
+
+const QImage &QQuickPixmap::image() const
+{
+ if (d)
+ return d->image;
+ else
+ return nullPixmap()->image;
+}
+
+void QQuickPixmap::setImage(const QImage &p)
+{
+ clear();
+
+ if (!p.isNull())
+ d = new QQuickPixmapData(this, p);
+}
+
+int QQuickPixmap::width() const
+{
+ if (d)
+ return d->textureFactory ? d->textureFactory->textureSize().width() : d->image.width();
+ else
+ return 0;
+}
+
+int QQuickPixmap::height() const
+{
+ if (d)
+ return d->textureFactory ? d->textureFactory->textureSize().height() : d->image.height();
+ else
+ return 0;
+}
+
+QRect QQuickPixmap::rect() const
+{
+ if (d)
+ return d->textureFactory ? QRect(QPoint(), d->textureFactory->textureSize()) : d->image.rect();
+ else
+ return QRect();
+}
+
+void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url)
+{
+ load(engine, url, QSize(), QQuickPixmap::Cache);
+}
+
+void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, QQuickPixmap::Options options)
+{
+ load(engine, url, QSize(), options);
+}
+
+void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &size)
+{
+ load(engine, url, size, QQuickPixmap::Cache);
+}
+
+void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &requestSize, QQuickPixmap::Options options)
+{
+ if (d) {
+ d->declarativePixmaps.remove(this);
+ d->release();
+ d = 0;
+ }
+
+ QQuickPixmapKey key = { &url, &requestSize };
+ QQuickPixmapStore *store = pixmapStore();
+
+ QHash<QQuickPixmapKey, QQuickPixmapData *>::Iterator iter = store->m_cache.find(key);
+
+ if (iter == store->m_cache.end()) {
+ if (options & QQuickPixmap::Asynchronous) {
+ // pixmaps can only be loaded synchronously
+ if (url.scheme() == QLatin1String("image")
+ && QQmlEnginePrivate::get(engine)->getImageProviderType(url) == QQmlImageProvider::Pixmap) {
+ options &= ~QQuickPixmap::Asynchronous;
+ }
+ }
+
+ if (!(options & QQuickPixmap::Asynchronous)) {
+ bool ok = false;
+ d = createPixmapDataSync(this, engine, url, requestSize, &ok);
+ if (ok) {
+ if (options & QQuickPixmap::Cache)
+ d->addToCache();
+ return;
+ }
+ if (d) // loadable, but encountered error while loading
+ return;
+ }
+
+ if (!engine)
+ return;
+
+ d = new QQuickPixmapData(this, url, requestSize);
+ if (options & QQuickPixmap::Cache)
+ d->addToCache();
+
+ QQuickPixmapReader::readerMutex.lock();
+ d->reply = QQuickPixmapReader::instance(engine)->getImage(d);
+ QQuickPixmapReader::readerMutex.unlock();
+ } else {
+ d = *iter;
+ d->addref();
+ d->declarativePixmaps.insert(this);
+ }
+}
+
+void QQuickPixmap::clear()
+{
+ if (d) {
+ d->declarativePixmaps.remove(this);
+ d->release();
+ d = 0;
+ }
+}
+
+void QQuickPixmap::clear(QObject *obj)
+{
+ if (d) {
+ if (d->reply)
+ QObject::disconnect(d->reply, 0, obj, 0);
+ d->declarativePixmaps.remove(this);
+ d->release();
+ d = 0;
+ }
+}
+
+bool QQuickPixmap::connectFinished(QObject *object, const char *method)
+{
+ if (!d || !d->reply) {
+ qWarning("QQuickPixmap: connectFinished() called when not loading.");
+ return false;
+ }
+
+ return QObject::connect(d->reply, SIGNAL(finished()), object, method);
+}
+
+bool QQuickPixmap::connectFinished(QObject *object, int method)
+{
+ if (!d || !d->reply) {
+ qWarning("QQuickPixmap: connectFinished() called when not loading.");
+ return false;
+ }
+
+ return QMetaObject::connect(d->reply, QQuickPixmapReply::finishedIndex, object, method);
+}
+
+bool QQuickPixmap::connectDownloadProgress(QObject *object, const char *method)
+{
+ if (!d || !d->reply) {
+ qWarning("QQuickPixmap: connectDownloadProgress() called when not loading.");
+ return false;
+ }
+
+ return QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), object, method);
+}
+
+bool QQuickPixmap::connectDownloadProgress(QObject *object, int method)
+{
+ if (!d || !d->reply) {
+ qWarning("QQuickPixmap: connectDownloadProgress() called when not loading.");
+ return false;
+ }
+
+ return QMetaObject::connect(d->reply, QQuickPixmapReply::downloadProgressIndex, object, method);
+}
+
+QT_END_NAMESPACE
+
+#include <qquickpixmapcache.moc>
diff --git a/src/quick/util/qquickpixmapcache_p.h b/src/quick/util/qquickpixmapcache_p.h
new file mode 100644
index 0000000000..0b4c2fb473
--- /dev/null
+++ b/src/quick/util/qquickpixmapcache_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPIXMAPCACHE_H
+#define QQUICKPIXMAPCACHE_H
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qpixmap.h>
+#include <QtCore/qurl.h>
+#include <QtQuick/qtquickglobal.h>
+
+#include <private/qintrusivelist_p.h>
+#include <qqmlimageprovider.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+class QQuickPixmapData;
+class QQuickTextureFactory;
+
+class QQuickDefaultTextureFactory : public QQuickTextureFactory
+{
+ Q_OBJECT
+public:
+ QQuickDefaultTextureFactory(const QImage &i)
+ : im(i)
+ {
+ }
+
+ QSGTexture *createTexture(QQuickCanvas *canvas) const;
+ QSize textureSize() const { return im.size(); }
+ int textureByteCount() const { return im.byteCount(); }
+ QImage image() const { return im; }
+
+private:
+ QImage im;
+};
+
+class Q_QUICK_EXPORT QQuickPixmap
+{
+ Q_DECLARE_TR_FUNCTIONS(QQuickPixmap)
+public:
+ QQuickPixmap();
+ QQuickPixmap(QQmlEngine *, const QUrl &);
+ QQuickPixmap(QQmlEngine *, const QUrl &, const QSize &);
+ ~QQuickPixmap();
+
+ enum Status { Null, Ready, Error, Loading };
+
+ enum Option {
+ Asynchronous = 0x00000001,
+ Cache = 0x00000002
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+
+ bool isNull() const;
+ bool isReady() const;
+ bool isError() const;
+ bool isLoading() const;
+
+ Status status() const;
+ QString error() const;
+ const QUrl &url() const;
+ const QSize &implicitSize() const;
+ const QSize &requestSize() const;
+ const QImage &image() const;
+ void setImage(const QImage &);
+
+ QQuickTextureFactory *textureFactory() const;
+
+ QRect rect() const;
+ int width() const;
+ int height() const;
+
+ void load(QQmlEngine *, const QUrl &);
+ void load(QQmlEngine *, const QUrl &, QQuickPixmap::Options options);
+ void load(QQmlEngine *, const QUrl &, const QSize &);
+ void load(QQmlEngine *, const QUrl &, const QSize &, QQuickPixmap::Options options);
+
+ void clear();
+ void clear(QObject *);
+
+ bool connectFinished(QObject *, const char *);
+ bool connectFinished(QObject *, int);
+ bool connectDownloadProgress(QObject *, const char *);
+ bool connectDownloadProgress(QObject *, int);
+
+ static void purgeCache();
+
+private:
+ Q_DISABLE_COPY(QQuickPixmap)
+ QQuickPixmapData *d;
+ QIntrusiveListNode dataListNode;
+ friend class QQuickPixmapData;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPixmap::Options)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQUICKPIXMAPCACHE_H
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
new file mode 100644
index 0000000000..83ddb2530e
--- /dev/null
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -0,0 +1,796 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickpropertychanges_p.h"
+
+#include <private/qqmlopenmetaobject_p.h>
+#include <private/qqmlrewrite_p.h>
+#include <private/qqmlengine_p.h>
+
+#include <qqmlinfo.h>
+#include <private/qqmlcustomparser_p.h>
+#include <private/qqmlscript_p.h>
+#include <qqmlexpression.h>
+#include <private/qqmlbinding_p.h>
+#include <qqmlcontext.h>
+#include <private/qqmlguard_p.h>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlcontext_p.h>
+#include <private/qquickstate_p_p.h>
+
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass PropertyChanges QQuickPropertyChanges
+ \inqmlmodule QtQuick 2
+ \ingroup qml-state-elements
+ \brief The PropertyChanges element describes new property bindings or values for a state.
+
+ PropertyChanges is used to define the property values or bindings in a
+ \l State. This enables an item's property values to be changed when it
+ \l {QML States}{changes between states}.
+
+ To create a PropertyChanges object, specify the \l target item whose
+ properties are to be modified, and define the new property values or
+ bindings. For example:
+
+ \snippet doc/src/snippets/qml/propertychanges.qml import
+ \codeline
+ \snippet doc/src/snippets/qml/propertychanges.qml 0
+
+ When the mouse is pressed, the \l Rectangle changes to the \e resized
+ state. In this state, the PropertyChanges object sets the rectangle's
+ color to blue and the \c height value to that of \c container.height.
+
+ Note this automatically binds \c rect.height to \c container.height
+ in the \e resized state. If a property binding should not be
+ established, and the height should just be set to the value of
+ \c container.height at the time of the state change, set the \l explicit
+ property to \c true.
+
+ A PropertyChanges object can also override the default signal handler
+ for an object to implement a signal handler specific to the new state:
+
+ \qml
+ PropertyChanges {
+ target: myMouseArea
+ onClicked: doSomethingDifferent()
+ }
+ \endqml
+
+ \note PropertyChanges can be used to change anchor margins, but not other anchor
+ values; use AnchorChanges for this instead. Similarly, to change an \l Item's
+ \l {Item::}{parent} value, use ParentChanges instead.
+
+
+ \section2 Resetting property values
+
+ The \c undefined value can be used to reset the property value for a state.
+ In the following example, when \c myText changes to the \e widerText
+ state, its \c width property is reset, giving the text its natural width
+ and displaying the whole string on a single line.
+
+ \snippet doc/src/snippets/qml/propertychanges.qml reset
+
+
+ \section2 Immediate property changes in transitions
+
+ When \l{QML Animation and Transitions}{Transitions} are used to animate
+ state changes, they animate properties from their values in the current
+ state to those defined in the new state (as defined by PropertyChanges
+ objects). However, it is sometimes desirable to set a property value
+ \e immediately during a \l Transition, without animation; in these cases,
+ the PropertyAction element can be used to force an immediate property
+ change.
+
+ See the PropertyAction documentation for more details.
+
+ \sa {declarative/animation/states}{states example}, {qmlstate}{States}, QtQml
+*/
+
+/*!
+ \qmlproperty Object QtQuick2::PropertyChanges::target
+ This property holds the object which contains the properties to be changed.
+*/
+
+class QQuickReplaceSignalHandler : public QQuickActionEvent
+{
+public:
+ QQuickReplaceSignalHandler() : expression(0), reverseExpression(0),
+ rewindExpression(0), ownedExpression(0) {}
+ ~QQuickReplaceSignalHandler() {
+ delete ownedExpression;
+ }
+
+ virtual EventType type() const { return SignalHandler; }
+
+ QQmlProperty property;
+ QQmlExpression *expression;
+ QQmlExpression *reverseExpression;
+ QQmlExpression *rewindExpression;
+ QQmlGuard<QQmlExpression> ownedExpression;
+
+ virtual void execute(Reason) {
+ ownedExpression = QQmlPropertyPrivate::setSignalExpression(property, expression);
+ if (ownedExpression == expression)
+ ownedExpression = 0;
+ }
+
+ virtual bool isReversable() { return true; }
+ virtual void reverse(Reason) {
+ ownedExpression = QQmlPropertyPrivate::setSignalExpression(property, reverseExpression);
+ if (ownedExpression == reverseExpression)
+ ownedExpression = 0;
+ }
+
+ virtual void saveOriginals() {
+ saveCurrentValues();
+ reverseExpression = rewindExpression;
+ }
+
+ virtual bool needsCopy() { return true; }
+ virtual void copyOriginals(QQuickActionEvent *other)
+ {
+ QQuickReplaceSignalHandler *rsh = static_cast<QQuickReplaceSignalHandler*>(other);
+ saveCurrentValues();
+ if (rsh == this)
+ return;
+ reverseExpression = rsh->reverseExpression;
+ if (rsh->ownedExpression == reverseExpression) {
+ ownedExpression = rsh->ownedExpression;
+ rsh->ownedExpression = 0;
+ }
+ }
+
+ virtual void rewind() {
+ ownedExpression = QQmlPropertyPrivate::setSignalExpression(property, rewindExpression);
+ if (ownedExpression == rewindExpression)
+ ownedExpression = 0;
+ }
+ virtual void saveCurrentValues() {
+ rewindExpression = QQmlPropertyPrivate::signalExpression(property);
+ }
+
+ virtual bool override(QQuickActionEvent*other) {
+ if (other == this)
+ return true;
+ if (other->type() != type())
+ return false;
+ if (static_cast<QQuickReplaceSignalHandler*>(other)->property == property)
+ return true;
+ return false;
+ }
+};
+
+
+class QQuickPropertyChangesPrivate : public QQuickStateOperationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickPropertyChanges)
+public:
+ QQuickPropertyChangesPrivate() : decoded(true), restore(true),
+ isExplicit(false) {}
+
+ QQmlGuard<QObject> object;
+ QByteArray data;
+
+ bool decoded : 1;
+ bool restore : 1;
+ bool isExplicit : 1;
+
+ void decode();
+
+ class ExpressionChange {
+ public:
+ ExpressionChange(const QString &_name,
+ QQmlBinding::Identifier _id,
+ QQmlExpression *_expr)
+ : name(_name), id(_id), expression(_expr) {}
+ QString name;
+ QQmlBinding::Identifier id;
+ QQmlExpression *expression;
+ };
+
+ QList<QPair<QString, QVariant> > properties;
+ QList<ExpressionChange> expressions;
+ QList<QQuickReplaceSignalHandler*> signalReplacements;
+
+ QQmlProperty property(const QString &);
+};
+
+void
+QQuickPropertyChangesParser::compileList(QList<QPair<QString, QVariant> > &list,
+ const QString &pre,
+ const QQmlCustomParserProperty &prop)
+{
+ QString propName = pre + prop.name();
+
+ QList<QVariant> values = prop.assignedValues();
+ for (int ii = 0; ii < values.count(); ++ii) {
+ const QVariant &value = values.at(ii);
+
+ if (value.userType() == qMetaTypeId<QQmlCustomParserNode>()) {
+ error(qvariant_cast<QQmlCustomParserNode>(value),
+ QQuickPropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
+ continue;
+ } else if(value.userType() == qMetaTypeId<QQmlCustomParserProperty>()) {
+
+ QQmlCustomParserProperty prop =
+ qvariant_cast<QQmlCustomParserProperty>(value);
+ QString pre = propName + QLatin1Char('.');
+ compileList(list, pre, prop);
+
+ } else {
+ list << qMakePair(propName, value);
+ }
+ }
+}
+
+QByteArray
+QQuickPropertyChangesParser::compile(const QList<QQmlCustomParserProperty> &props)
+{
+ QList<QPair<QString, QVariant> > data;
+ for(int ii = 0; ii < props.count(); ++ii)
+ compileList(data, QString(), props.at(ii));
+
+ QByteArray rv;
+ QDataStream ds(&rv, QIODevice::WriteOnly);
+
+ ds << data.count();
+ for(int ii = 0; ii < data.count(); ++ii) {
+ QQmlScript::Variant v = qvariant_cast<QQmlScript::Variant>(data.at(ii).second);
+ QVariant var;
+ bool isScript = v.isScript();
+ QQmlBinding::Identifier id = 0;
+ switch(v.type()) {
+ case QQmlScript::Variant::Boolean:
+ var = QVariant(v.asBoolean());
+ break;
+ case QQmlScript::Variant::Number:
+ var = QVariant(v.asNumber());
+ break;
+ case QQmlScript::Variant::String:
+ var = QVariant(v.asString());
+ break;
+ case QQmlScript::Variant::Invalid:
+ case QQmlScript::Variant::Script:
+ var = QVariant(v.asScript());
+ {
+ // Pre-rewrite the expression
+ id = rewriteBinding(v, data.at(ii).first);
+ }
+ break;
+ }
+
+ ds << data.at(ii).first << isScript << var;
+ if (isScript)
+ ds << id;
+ }
+
+ return rv;
+}
+
+void QQuickPropertyChangesPrivate::decode()
+{
+ Q_Q(QQuickPropertyChanges);
+ if (decoded)
+ return;
+
+ QDataStream ds(&data, QIODevice::ReadOnly);
+
+ int count;
+ ds >> count;
+ for (int ii = 0; ii < count; ++ii) {
+ QString name;
+ bool isScript;
+ QVariant data;
+ QQmlBinding::Identifier id = QQmlBinding::Invalid;
+ ds >> name;
+ ds >> isScript;
+ ds >> data;
+ if (isScript)
+ ds >> id;
+
+ QQmlProperty prop = property(name); //### better way to check for signal property?
+ if (prop.type() & QQmlProperty::SignalProperty) {
+ QQmlExpression *expression = new QQmlExpression(qmlContext(q), object, data.toString());
+ QQmlData *ddata = QQmlData::get(q);
+ if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
+ expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
+ QQuickReplaceSignalHandler *handler = new QQuickReplaceSignalHandler;
+ handler->property = prop;
+ handler->expression = expression;
+ signalReplacements << handler;
+ } else if (isScript) {
+ QQmlExpression *expression = new QQmlExpression(qmlContext(q), object, data.toString());
+ QQmlData *ddata = QQmlData::get(q);
+ if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
+ expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
+ expressions << ExpressionChange(name, id, expression);
+ } else {
+ properties << qMakePair(name, data);
+ }
+ }
+
+ decoded = true;
+ data.clear();
+}
+
+void QQuickPropertyChangesParser::setCustomData(QObject *object,
+ const QByteArray &data)
+{
+ QQuickPropertyChangesPrivate *p =
+ static_cast<QQuickPropertyChangesPrivate *>(QObjectPrivate::get(object));
+ p->data = data;
+ p->decoded = false;
+}
+
+QQuickPropertyChanges::QQuickPropertyChanges()
+: QQuickStateOperation(*(new QQuickPropertyChangesPrivate))
+{
+}
+
+QQuickPropertyChanges::~QQuickPropertyChanges()
+{
+ Q_D(QQuickPropertyChanges);
+ for(int ii = 0; ii < d->expressions.count(); ++ii)
+ delete d->expressions.at(ii).expression;
+ for(int ii = 0; ii < d->signalReplacements.count(); ++ii)
+ delete d->signalReplacements.at(ii);
+}
+
+QObject *QQuickPropertyChanges::object() const
+{
+ Q_D(const QQuickPropertyChanges);
+ return d->object;
+}
+
+void QQuickPropertyChanges::setObject(QObject *o)
+{
+ Q_D(QQuickPropertyChanges);
+ d->object = o;
+}
+
+/*!
+ \qmlproperty bool QtQuick2::PropertyChanges::restoreEntryValues
+
+ This property holds whether the previous values should be restored when
+ leaving the state.
+
+ The default value is \c true. Setting this value to \c false creates a
+ temporary state that has permanent effects on property values.
+*/
+bool QQuickPropertyChanges::restoreEntryValues() const
+{
+ Q_D(const QQuickPropertyChanges);
+ return d->restore;
+}
+
+void QQuickPropertyChanges::setRestoreEntryValues(bool v)
+{
+ Q_D(QQuickPropertyChanges);
+ d->restore = v;
+}
+
+QQmlProperty
+QQuickPropertyChangesPrivate::property(const QString &property)
+{
+ Q_Q(QQuickPropertyChanges);
+ QQmlProperty prop(object, property, qmlContext(q));
+ if (!prop.isValid()) {
+ qmlInfo(q) << QQuickPropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(property);
+ return QQmlProperty();
+ } else if (!(prop.type() & QQmlProperty::SignalProperty) && !prop.isWritable()) {
+ qmlInfo(q) << QQuickPropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(property);
+ return QQmlProperty();
+ }
+ return prop;
+}
+
+QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
+{
+ Q_D(QQuickPropertyChanges);
+
+ d->decode();
+
+ ActionList list;
+
+ for (int ii = 0; ii < d->properties.count(); ++ii) {
+
+ QQuickAction a(d->object, d->properties.at(ii).first,
+ qmlContext(this), d->properties.at(ii).second);
+
+ if (a.property.isValid()) {
+ a.restore = restoreEntryValues();
+ list << a;
+ }
+ }
+
+ for (int ii = 0; ii < d->signalReplacements.count(); ++ii) {
+
+ QQuickReplaceSignalHandler *handler = d->signalReplacements.at(ii);
+
+ if (handler->property.isValid()) {
+ QQuickAction a;
+ a.event = handler;
+ list << a;
+ }
+ }
+
+ for (int ii = 0; ii < d->expressions.count(); ++ii) {
+
+ const QString &property = d->expressions.at(ii).name;
+ QQmlProperty prop = d->property(property);
+
+ if (prop.isValid()) {
+ QQuickAction a;
+ a.restore = restoreEntryValues();
+ a.property = prop;
+ a.fromValue = a.property.read();
+ a.specifiedObject = d->object;
+ a.specifiedProperty = property;
+
+ if (d->isExplicit) {
+ a.toValue = d->expressions.at(ii).expression->evaluate();
+ } else {
+ QQmlExpression *e = d->expressions.at(ii).expression;
+
+ QQmlBinding::Identifier id = d->expressions.at(ii).id;
+ QQmlBinding *newBinding = id != QQmlBinding::Invalid ? QQmlBinding::createBinding(id, object(), qmlContext(this), e->sourceFile(), e->lineNumber()) : 0;
+ if (!newBinding) {
+ newBinding = new QQmlBinding(e->expression(), object(), qmlContext(this));
+ newBinding->setSourceLocation(e->sourceFile(), e->lineNumber(), e->columnNumber());
+ }
+ newBinding->setTarget(prop);
+ a.toBinding = newBinding;
+ a.deletableToBinding = true;
+ }
+
+ list << a;
+ }
+ }
+
+ return list;
+}
+
+/*!
+ \qmlproperty bool QtQuick2::PropertyChanges::explicit
+
+ If explicit is set to true, any potential bindings will be interpreted as
+ once-off assignments that occur when the state is entered.
+
+ In the following example, the addition of explicit prevents \c myItem.width from
+ being bound to \c parent.width. Instead, it is assigned the value of \c parent.width
+ at the time of the state change.
+ \qml
+ PropertyChanges {
+ target: myItem
+ explicit: true
+ width: parent.width
+ }
+ \endqml
+
+ By default, explicit is false.
+*/
+bool QQuickPropertyChanges::isExplicit() const
+{
+ Q_D(const QQuickPropertyChanges);
+ return d->isExplicit;
+}
+
+void QQuickPropertyChanges::setIsExplicit(bool e)
+{
+ Q_D(QQuickPropertyChanges);
+ d->isExplicit = e;
+}
+
+bool QQuickPropertyChanges::containsValue(const QString &name) const
+{
+ Q_D(const QQuickPropertyChanges);
+ typedef QPair<QString, QVariant> PropertyEntry;
+
+ QListIterator<PropertyEntry> propertyIterator(d->properties);
+ while (propertyIterator.hasNext()) {
+ const PropertyEntry &entry = propertyIterator.next();
+ if (entry.first == name) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool QQuickPropertyChanges::containsExpression(const QString &name) const
+{
+ Q_D(const QQuickPropertyChanges);
+ typedef QQuickPropertyChangesPrivate::ExpressionChange ExpressionEntry;
+
+ QListIterator<ExpressionEntry> expressionIterator(d->expressions);
+ while (expressionIterator.hasNext()) {
+ const ExpressionEntry &entry = expressionIterator.next();
+ if (entry.name == name) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool QQuickPropertyChanges::containsProperty(const QString &name) const
+{
+ return containsValue(name) || containsExpression(name);
+}
+
+void QQuickPropertyChanges::changeValue(const QString &name, const QVariant &value)
+{
+ Q_D(QQuickPropertyChanges);
+ typedef QPair<QString, QVariant> PropertyEntry;
+ typedef QQuickPropertyChangesPrivate::ExpressionChange ExpressionEntry;
+
+ QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
+ while (expressionIterator.hasNext()) {
+ const ExpressionEntry &entry = expressionIterator.next();
+ if (entry.name == name) {
+ expressionIterator.remove();
+ if (state() && state()->isStateActive()) {
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(d->property(name));
+ if (oldBinding) {
+ QQmlPropertyPrivate::setBinding(d->property(name), 0);
+ oldBinding->destroy();
+ }
+ d->property(name).write(value);
+ }
+
+ d->properties.append(PropertyEntry(name, value));
+ return;
+ }
+ }
+
+ QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
+ while (propertyIterator.hasNext()) {
+ PropertyEntry &entry = propertyIterator.next();
+ if (entry.first == name) {
+ entry.second = value;
+ if (state() && state()->isStateActive())
+ d->property(name).write(value);
+ return;
+ }
+ }
+
+ QQuickAction action;
+ action.restore = restoreEntryValues();
+ action.property = d->property(name);
+ action.fromValue = action.property.read();
+ action.specifiedObject = object();
+ action.specifiedProperty = name;
+ action.toValue = value;
+
+ propertyIterator.insert(PropertyEntry(name, value));
+ if (state() && state()->isStateActive()) {
+ state()->addEntryToRevertList(action);
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(action.property);
+ if (oldBinding)
+ oldBinding->setEnabled(false, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor);
+ d->property(name).write(value);
+ }
+}
+
+void QQuickPropertyChanges::changeExpression(const QString &name, const QString &expression)
+{
+ Q_D(QQuickPropertyChanges);
+ typedef QPair<QString, QVariant> PropertyEntry;
+ typedef QQuickPropertyChangesPrivate::ExpressionChange ExpressionEntry;
+
+ bool hadValue = false;
+
+ QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
+ while (propertyIterator.hasNext()) {
+ PropertyEntry &entry = propertyIterator.next();
+ if (entry.first == name) {
+ propertyIterator.remove();
+ hadValue = true;
+ break;
+ }
+ }
+
+ QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
+ while (expressionIterator.hasNext()) {
+ const ExpressionEntry &entry = expressionIterator.next();
+ if (entry.name == name) {
+ entry.expression->setExpression(expression);
+ if (state() && state()->isStateActive()) {
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(d->property(name));
+ if (oldBinding) {
+ QQmlPropertyPrivate::setBinding(d->property(name), 0);
+ oldBinding->destroy();
+ }
+
+ QQmlBinding *newBinding = new QQmlBinding(expression, object(), qmlContext(this));
+ newBinding->setTarget(d->property(name));
+ QQmlPropertyPrivate::setBinding(d->property(name), newBinding, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor);
+ }
+ return;
+ }
+ }
+
+ QQmlExpression *newExpression = new QQmlExpression(qmlContext(this), d->object, expression);
+ expressionIterator.insert(ExpressionEntry(name, QQmlBinding::Invalid, newExpression));
+
+ if (state() && state()->isStateActive()) {
+ if (hadValue) {
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(d->property(name));
+ if (oldBinding) {
+ oldBinding->setEnabled(false, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor);
+ state()->changeBindingInRevertList(object(), name, oldBinding);
+ }
+
+ QQmlBinding *newBinding = new QQmlBinding(expression, object(), qmlContext(this));
+ newBinding->setTarget(d->property(name));
+ QQmlPropertyPrivate::setBinding(d->property(name), newBinding, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor);
+ } else {
+ QQuickAction action;
+ action.restore = restoreEntryValues();
+ action.property = d->property(name);
+ action.fromValue = action.property.read();
+ action.specifiedObject = object();
+ action.specifiedProperty = name;
+
+
+ if (d->isExplicit) {
+ action.toValue = newExpression->evaluate();
+ } else {
+ QQmlBinding *newBinding = new QQmlBinding(newExpression->expression(), object(), qmlContext(this));
+ newBinding->setTarget(d->property(name));
+ action.toBinding = newBinding;
+ action.deletableToBinding = true;
+
+ state()->addEntryToRevertList(action);
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(action.property);
+ if (oldBinding)
+ oldBinding->setEnabled(false, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor);
+
+ QQmlPropertyPrivate::setBinding(action.property, newBinding, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor);
+ }
+ }
+ }
+ // what about the signal handler?
+}
+
+QVariant QQuickPropertyChanges::property(const QString &name) const
+{
+ Q_D(const QQuickPropertyChanges);
+ typedef QPair<QString, QVariant> PropertyEntry;
+ typedef QQuickPropertyChangesPrivate::ExpressionChange ExpressionEntry;
+
+ QListIterator<PropertyEntry> propertyIterator(d->properties);
+ while (propertyIterator.hasNext()) {
+ const PropertyEntry &entry = propertyIterator.next();
+ if (entry.first == name) {
+ return entry.second;
+ }
+ }
+
+ QListIterator<ExpressionEntry> expressionIterator(d->expressions);
+ while (expressionIterator.hasNext()) {
+ const ExpressionEntry &entry = expressionIterator.next();
+ if (entry.name == name) {
+ return QVariant(entry.expression->expression());
+ }
+ }
+
+ return QVariant();
+}
+
+void QQuickPropertyChanges::removeProperty(const QString &name)
+{
+ Q_D(QQuickPropertyChanges);
+ typedef QPair<QString, QVariant> PropertyEntry;
+ typedef QQuickPropertyChangesPrivate::ExpressionChange ExpressionEntry;
+
+ QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
+ while (expressionIterator.hasNext()) {
+ const ExpressionEntry &entry = expressionIterator.next();
+ if (entry.name == name) {
+ expressionIterator.remove();
+ state()->removeEntryFromRevertList(object(), name);
+ return;
+ }
+ }
+
+ QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
+ while (propertyIterator.hasNext()) {
+ const PropertyEntry &entry = propertyIterator.next();
+ if (entry.first == name) {
+ propertyIterator.remove();
+ state()->removeEntryFromRevertList(object(), name);
+ return;
+ }
+ }
+}
+
+QVariant QQuickPropertyChanges::value(const QString &name) const
+{
+ Q_D(const QQuickPropertyChanges);
+ typedef QPair<QString, QVariant> PropertyEntry;
+
+ QListIterator<PropertyEntry> propertyIterator(d->properties);
+ while (propertyIterator.hasNext()) {
+ const PropertyEntry &entry = propertyIterator.next();
+ if (entry.first == name) {
+ return entry.second;
+ }
+ }
+
+ return QVariant();
+}
+
+QString QQuickPropertyChanges::expression(const QString &name) const
+{
+ Q_D(const QQuickPropertyChanges);
+ typedef QQuickPropertyChangesPrivate::ExpressionChange ExpressionEntry;
+
+ QListIterator<ExpressionEntry> expressionIterator(d->expressions);
+ while (expressionIterator.hasNext()) {
+ const ExpressionEntry &entry = expressionIterator.next();
+ if (entry.name == name) {
+ return entry.expression->expression();
+ }
+ }
+
+ return QString();
+}
+
+void QQuickPropertyChanges::detachFromState()
+{
+ if (state())
+ state()->removeAllEntriesFromRevertList(object());
+}
+
+void QQuickPropertyChanges::attachToState()
+{
+ if (state())
+ state()->addEntriesToRevertList(actions());
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickpropertychanges_p.h b/src/quick/util/qquickpropertychanges_p.h
new file mode 100644
index 0000000000..313a781302
--- /dev/null
+++ b/src/quick/util/qquickpropertychanges_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPROPERTYCHANGES_H
+#define QQUICKPROPERTYCHANGES_H
+
+#include "qquickstatechangescript_p.h"
+#include <private/qqmlcustomparser_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPropertyChangesPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickPropertyChanges : public QQuickStateOperation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickPropertyChanges)
+
+ Q_PROPERTY(QObject *target READ object WRITE setObject)
+ Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
+ Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
+public:
+ QQuickPropertyChanges();
+ ~QQuickPropertyChanges();
+
+ QObject *object() const;
+ void setObject(QObject *);
+
+ bool restoreEntryValues() const;
+ void setRestoreEntryValues(bool);
+
+ bool isExplicit() const;
+ void setIsExplicit(bool);
+
+ virtual ActionList actions();
+
+ bool containsProperty(const QString &name) const;
+ bool containsValue(const QString &name) const;
+ bool containsExpression(const QString &name) const;
+ void changeValue(const QString &name, const QVariant &value);
+ void changeExpression(const QString &name, const QString &expression);
+ void removeProperty(const QString &name);
+ QVariant value(const QString &name) const;
+ QString expression(const QString &name) const;
+
+ void detachFromState();
+ void attachToState();
+
+ QVariant property(const QString &name) const;
+};
+
+class QQuickPropertyChangesParser : public QQmlCustomParser
+{
+public:
+ QQuickPropertyChangesParser()
+ : QQmlCustomParser(AcceptsAttachedProperties) {}
+
+ void compileList(QList<QPair<QString, QVariant> > &list, const QString &pre, const QQmlCustomParserProperty &prop);
+
+ virtual QByteArray compile(const QList<QQmlCustomParserProperty> &);
+ virtual void setCustomData(QObject *, const QByteArray &);
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPropertyChanges)
+
+QT_END_HEADER
+
+#endif // QQUICKPROPERTYCHANGES_H
diff --git a/src/quick/util/qquicksmoothedanimation.cpp b/src/quick/util/qquicksmoothedanimation.cpp
new file mode 100644
index 0000000000..024728f1f5
--- /dev/null
+++ b/src/quick/util/qquicksmoothedanimation.cpp
@@ -0,0 +1,557 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicksmoothedanimation_p.h"
+#include "qquicksmoothedanimation_p_p.h"
+
+#include "qquickanimation_p_p.h"
+
+#include <qqmlproperty.h>
+#include <private/qqmlproperty_p.h>
+
+#include <private/qqmlglobal_p.h>
+
+#include <QtCore/qdebug.h>
+
+#include <math.h>
+
+#define DELAY_STOP_TIMER_INTERVAL 32
+
+QT_BEGIN_NAMESPACE
+
+
+QSmoothedAnimationTimer::QSmoothedAnimationTimer(QSmoothedAnimation *animation, QObject *parent)
+ : QTimer(parent)
+ , m_animation(animation)
+{
+ connect(this, SIGNAL(timeout()), this, SLOT(stopAnimation()));
+}
+
+QSmoothedAnimationTimer::~QSmoothedAnimationTimer()
+{
+}
+
+void QSmoothedAnimationTimer::stopAnimation()
+{
+ m_animation->stop();
+}
+
+QSmoothedAnimation::QSmoothedAnimation(QQuickSmoothedAnimationPrivate *priv)
+ : QAbstractAnimationJob(), to(0), velocity(200), userDuration(-1), maximumEasingTime(-1),
+ reversingMode(QQuickSmoothedAnimation::Eased), initialVelocity(0),
+ trackVelocity(0), initialValue(0), invert(false), finalDuration(-1), lastTime(0),
+ useDelta(false), delayedStopTimer(new QSmoothedAnimationTimer(this)), animationTemplate(priv)
+{
+ delayedStopTimer->setInterval(DELAY_STOP_TIMER_INTERVAL);
+ delayedStopTimer->setSingleShot(true);
+}
+
+QSmoothedAnimation::~QSmoothedAnimation()
+{
+ delete delayedStopTimer;
+ if (animationTemplate) {
+ if (target.object()) {
+ QHash<QQmlProperty, QSmoothedAnimation* >::iterator it =
+ animationTemplate->activeAnimations.find(target);
+ if (it != animationTemplate->activeAnimations.end() && it.value() == this)
+ animationTemplate->activeAnimations.erase(it);
+ } else {
+ //target is no longer valid, need to search linearly
+ QHash<QQmlProperty, QSmoothedAnimation* >::iterator it;
+ for (it = animationTemplate->activeAnimations.begin(); it != animationTemplate->activeAnimations.end(); ++it) {
+ if (it.value() == this) {
+ animationTemplate->activeAnimations.erase(it);
+ break;
+ }
+ }
+ }
+ }
+}
+
+void QSmoothedAnimation::restart()
+{
+ initialVelocity = trackVelocity;
+ if (isRunning())
+ init();
+ else
+ start();
+}
+
+void QSmoothedAnimation::prepareForRestart()
+{
+ initialVelocity = trackVelocity;
+ if (isRunning()) {
+ //we are joining a new wrapper group while running, our times need to be restarted
+ useDelta = true;
+ init();
+ lastTime = 0;
+ } else {
+ useDelta = false;
+ //we'll be started when the group starts, which will force an init()
+ }
+}
+
+void QSmoothedAnimation::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State /*oldState*/)
+{
+ if (newState == QAbstractAnimationJob::Running)
+ init();
+}
+
+void QSmoothedAnimation::delayedStop()
+{
+ if (!delayedStopTimer->isActive())
+ delayedStopTimer->start();
+}
+
+int QSmoothedAnimation::duration() const
+{
+ return -1;
+}
+
+bool QSmoothedAnimation::recalc()
+{
+ s = to - initialValue;
+ vi = initialVelocity;
+
+ s = (invert? -1.0: 1.0) * s;
+
+ if (userDuration > 0 && velocity > 0) {
+ tf = s / velocity;
+ if (tf > (userDuration / 1000.)) tf = (userDuration / 1000.);
+ } else if (userDuration > 0) {
+ tf = userDuration / 1000.;
+ } else if (velocity > 0) {
+ tf = s / velocity;
+ } else {
+ return false;
+ }
+
+ finalDuration = ceil(tf * 1000.0);
+
+ if (maximumEasingTime == 0) {
+ a = 0;
+ d = 0;
+ tp = 0;
+ td = tf;
+ vp = velocity;
+ sp = 0;
+ sd = s;
+ } else if (maximumEasingTime != -1 && tf > (maximumEasingTime / 1000.)) {
+ qreal met = maximumEasingTime / 1000.;
+ /* tp| |td
+ * vp_ _______
+ * / \
+ * vi_ / \
+ * \
+ * \ _ 0
+ * |ta| |ta|
+ */
+ qreal ta = met / 2.;
+ a = (s - (vi * tf - 0.5 * vi * ta)) / (tf * ta - ta * ta);
+
+ vp = vi + a * ta;
+ d = vp / ta;
+ tp = ta;
+ sp = vi * ta + 0.5 * a * tp * tp;
+ sd = sp + vp * (tf - 2 * ta);
+ td = tf - ta;
+ } else {
+ qreal c1 = 0.25 * tf * tf;
+ qreal c2 = 0.5 * vi * tf - s;
+ qreal c3 = -0.25 * vi * vi;
+
+ qreal a1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
+
+ qreal tp1 = 0.5 * tf - 0.5 * vi / a1;
+ qreal vp1 = a1 * tp1 + vi;
+
+ qreal sp1 = 0.5 * a1 * tp1 * tp1 + vi * tp1;
+
+ a = a1;
+ d = a1;
+ tp = tp1;
+ td = tp1;
+ vp = vp1;
+ sp = sp1;
+ sd = sp1;
+ }
+ return true;
+}
+
+qreal QSmoothedAnimation::easeFollow(qreal time_seconds)
+{
+ qreal value;
+ if (time_seconds < tp) {
+ trackVelocity = vi + time_seconds * a;
+ value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds;
+ } else if (time_seconds < td) {
+ time_seconds -= tp;
+ trackVelocity = vp;
+ value = sp + time_seconds * vp;
+ } else if (time_seconds < tf) {
+ time_seconds -= td;
+ trackVelocity = vp - time_seconds * a;
+ value = sd - 0.5 * d * time_seconds * time_seconds + vp * time_seconds;
+ } else {
+ trackVelocity = 0;
+ value = s;
+ delayedStop();
+ }
+
+ // to normalize 's' between [0..1], divide 'value' by 's'
+ return value;
+}
+
+void QSmoothedAnimation::updateCurrentTime(int t)
+{
+ qreal time_seconds = useDelta ? qreal(QQmlAnimationTimer::instance()->currentDelta()) / 1000. : qreal(t - lastTime) / 1000.;
+ if (useDelta)
+ useDelta = false;
+
+ qreal value = easeFollow(time_seconds);
+ value *= (invert? -1.0: 1.0);
+ QQmlPropertyPrivate::write(target, initialValue + value,
+ QQmlPropertyPrivate::BypassInterceptor
+ | QQmlPropertyPrivate::DontRemoveBinding);
+}
+
+void QSmoothedAnimation::init()
+{
+ if (velocity == 0) {
+ stop();
+ return;
+ }
+
+ if (delayedStopTimer->isActive())
+ delayedStopTimer->stop();
+
+ initialValue = target.read().toReal();
+ lastTime = this->currentTime();
+
+ if (to == initialValue) {
+ stop();
+ return;
+ }
+
+ bool hasReversed = trackVelocity != 0. &&
+ ((!invert) == ((initialValue - to) > 0));
+
+ if (hasReversed) {
+ switch (reversingMode) {
+ default:
+ case QQuickSmoothedAnimation::Eased:
+ initialVelocity = -trackVelocity;
+ break;
+ case QQuickSmoothedAnimation::Sync:
+ QQmlPropertyPrivate::write(target, to,
+ QQmlPropertyPrivate::BypassInterceptor
+ | QQmlPropertyPrivate::DontRemoveBinding);
+ trackVelocity = 0;
+ stop();
+ return;
+ case QQuickSmoothedAnimation::Immediate:
+ initialVelocity = 0;
+ break;
+ }
+ }
+
+ trackVelocity = initialVelocity;
+
+ invert = (to < initialValue);
+
+ if (!recalc()) {
+ QQmlPropertyPrivate::write(target, to,
+ QQmlPropertyPrivate::BypassInterceptor
+ | QQmlPropertyPrivate::DontRemoveBinding);
+ stop();
+ return;
+ }
+}
+
+/*!
+ \qmlclass SmoothedAnimation QQuickSmoothedAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits NumberAnimation
+ \brief The SmoothedAnimation element allows a property to smoothly track a value.
+
+ 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/qml/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
+ of 200 is set, will take 8 seconds with a duration of 8000 set, and will
+ take 4 seconds with both a velocity of 200 and a duration of 8000 set.
+ Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
+ 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 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.
+ To enable a smooth animation in this range the velocity will need to be
+ set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity
+ of 0.5 will take 2000 ms to complete.
+
+ Like any other animation element, a SmoothedAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ \sa SpringAnimation, NumberAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
+*/
+
+QQuickSmoothedAnimation::QQuickSmoothedAnimation(QObject *parent)
+: QQuickNumberAnimation(*(new QQuickSmoothedAnimationPrivate), parent)
+{
+}
+
+QQuickSmoothedAnimation::~QQuickSmoothedAnimation()
+{
+
+}
+
+QQuickSmoothedAnimationPrivate::QQuickSmoothedAnimationPrivate()
+ : anim(0)
+{
+ anim = new QSmoothedAnimation;
+}
+
+QQuickSmoothedAnimationPrivate::~QQuickSmoothedAnimationPrivate()
+{
+ delete anim;
+ QHash<QQmlProperty, QSmoothedAnimation* >::iterator it;
+ for (it = activeAnimations.begin(); it != activeAnimations.end(); ++it) {
+ it.value()->clearTemplate();
+ }
+}
+
+void QQuickSmoothedAnimationPrivate::updateRunningAnimations()
+{
+ foreach(QSmoothedAnimation* ease, activeAnimations.values()){
+ ease->maximumEasingTime = anim->maximumEasingTime;
+ ease->reversingMode = anim->reversingMode;
+ ease->velocity = anim->velocity;
+ ease->userDuration = anim->userDuration;
+ ease->init();
+ }
+}
+
+QAbstractAnimationJob* QQuickSmoothedAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_UNUSED(direction);
+ Q_D(QQuickSmoothedAnimation);
+
+ QQuickStateActions dataActions = QQuickPropertyAnimation::createTransitionActions(actions, modified, defaultTarget);
+
+ QParallelAnimationGroupJob *wrapperGroup = new QParallelAnimationGroupJob();
+
+ if (!dataActions.isEmpty()) {
+ QSet<QAbstractAnimationJob*> anims;
+ for (int i = 0; i < dataActions.size(); i++) {
+ QSmoothedAnimation *ease;
+ bool isActive;
+ if (!d->activeAnimations.contains(dataActions[i].property)) {
+ ease = new QSmoothedAnimation(d);
+ d->activeAnimations.insert(dataActions[i].property, ease);
+ ease->target = dataActions[i].property;
+ isActive = false;
+ } else {
+ ease = d->activeAnimations.value(dataActions[i].property);
+ isActive = true;
+ }
+ wrapperGroup->appendAnimation(initInstance(ease));
+
+ ease->to = dataActions[i].toValue.toReal();
+
+ // copying public members from main value holder animation
+ ease->maximumEasingTime = d->anim->maximumEasingTime;
+ ease->reversingMode = d->anim->reversingMode;
+ ease->velocity = d->anim->velocity;
+ ease->userDuration = d->anim->userDuration;
+
+ ease->initialVelocity = ease->trackVelocity;
+
+ if (isActive)
+ ease->prepareForRestart();
+ anims.insert(ease);
+ }
+
+ foreach (QSmoothedAnimation *ease, d->activeAnimations.values()){
+ if (!anims.contains(ease)) {
+ ease->clearTemplate();
+ d->activeAnimations.remove(ease->target);
+ }
+ }
+ }
+ return wrapperGroup;
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::SmoothedAnimation::reversingMode
+
+ Sets how the SmoothedAnimation behaves if an animation direction is reversed.
+
+ Possible values are:
+
+ \list
+ \o SmoothedAnimation.Eased (default) - the animation will smoothly decelerate, and then reverse direction
+ \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, beginning with a velocity of 0
+ \o SmoothedAnimation.Sync - the property is immediately set to the target value
+ \endlist
+*/
+QQuickSmoothedAnimation::ReversingMode QQuickSmoothedAnimation::reversingMode() const
+{
+ Q_D(const QQuickSmoothedAnimation);
+ return (QQuickSmoothedAnimation::ReversingMode) d->anim->reversingMode;
+}
+
+void QQuickSmoothedAnimation::setReversingMode(ReversingMode m)
+{
+ Q_D(QQuickSmoothedAnimation);
+ if (d->anim->reversingMode == m)
+ return;
+
+ d->anim->reversingMode = m;
+ emit reversingModeChanged();
+ d->updateRunningAnimations();
+}
+
+/*!
+ \qmlproperty int QtQuick2::SmoothedAnimation::duration
+
+ This property holds the animation duration, in msecs, used when tracking the source.
+
+ Setting this to -1 (the default) disables the duration value.
+
+ If the velocity value and the duration value are both enabled, then the animation will
+ use whichever gives the shorter duration.
+*/
+int QQuickSmoothedAnimation::duration() const
+{
+ Q_D(const QQuickSmoothedAnimation);
+ return d->anim->userDuration;
+}
+
+void QQuickSmoothedAnimation::setDuration(int duration)
+{
+ Q_D(QQuickSmoothedAnimation);
+ if (duration != -1)
+ QQuickNumberAnimation::setDuration(duration);
+ if(duration == d->anim->userDuration)
+ return;
+ d->anim->userDuration = duration;
+ d->updateRunningAnimations();
+}
+
+qreal QQuickSmoothedAnimation::velocity() const
+{
+ Q_D(const QQuickSmoothedAnimation);
+ return d->anim->velocity;
+}
+
+/*!
+ \qmlproperty real QtQuick2::SmoothedAnimation::velocity
+
+ This property holds the average velocity allowed when tracking the 'to' value.
+
+ The default velocity of SmoothedAnimation is 200 units/second.
+
+ Setting this to -1 disables the velocity value.
+
+ If the velocity value and the duration value are both enabled, then the animation will
+ use whichever gives the shorter duration.
+*/
+void QQuickSmoothedAnimation::setVelocity(qreal v)
+{
+ Q_D(QQuickSmoothedAnimation);
+ if (d->anim->velocity == v)
+ return;
+
+ d->anim->velocity = v;
+ emit velocityChanged();
+ d->updateRunningAnimations();
+}
+
+/*!
+ \qmlproperty int QtQuick2::SmoothedAnimation::maximumEasingTime
+
+ This property specifies the maximum time, in msecs, any "eases" during the follow should take.
+ Setting this property causes the velocity to "level out" after at a time. Setting
+ a negative value reverts to the normal mode of easing over the entire animation
+ duration.
+
+ The default value is -1.
+*/
+int QQuickSmoothedAnimation::maximumEasingTime() const
+{
+ Q_D(const QQuickSmoothedAnimation);
+ return d->anim->maximumEasingTime;
+}
+
+void QQuickSmoothedAnimation::setMaximumEasingTime(int v)
+{
+ Q_D(QQuickSmoothedAnimation);
+ if(v == d->anim->maximumEasingTime)
+ return;
+ d->anim->maximumEasingTime = v;
+ emit maximumEasingTimeChanged();
+ d->updateRunningAnimations();
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquicksmoothedanimation_p.h b/src/quick/util/qquicksmoothedanimation_p.h
new file mode 100644
index 0000000000..8825a04a0e
--- /dev/null
+++ b/src/quick/util/qquicksmoothedanimation_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSMOOTHEDANIMATION_H
+#define QQUICKSMOOTHEDANIMATION_H
+
+#include <qqml.h>
+#include "qquickanimation_p.h"
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQmlProperty;
+class QQuickSmoothedAnimationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickSmoothedAnimation : public QQuickNumberAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickSmoothedAnimation)
+ Q_ENUMS(ReversingMode)
+
+ Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
+ Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged)
+ Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged)
+
+public:
+ enum ReversingMode { Eased, Immediate, Sync };
+
+ QQuickSmoothedAnimation(QObject *parent = 0);
+ ~QQuickSmoothedAnimation();
+
+ ReversingMode reversingMode() const;
+ void setReversingMode(ReversingMode);
+
+ virtual int duration() const;
+ virtual void setDuration(int);
+
+ qreal velocity() const;
+ void setVelocity(qreal);
+
+ int maximumEasingTime() const;
+ void setMaximumEasingTime(int);
+
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+Q_SIGNALS:
+ void velocityChanged();
+ void reversingModeChanged();
+ void maximumEasingTimeChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickSmoothedAnimation)
+
+QT_END_HEADER
+
+#endif // QQUICKSMOOTHEDANIMATION_H
diff --git a/src/quick/util/qquicksmoothedanimation_p_p.h b/src/quick/util/qquicksmoothedanimation_p_p.h
new file mode 100644
index 0000000000..8112aa2885
--- /dev/null
+++ b/src/quick/util/qquicksmoothedanimation_p_p.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSMOOTHEDANIMATION2_P_H
+#define QQUICKSMOOTHEDANIMATION2_P_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 "qquicksmoothedanimation_p.h"
+#include "qquickanimation_p.h"
+
+#include "qquickanimation_p_p.h"
+
+#include "private/qparallelanimationgroupjob_p.h"
+
+#include <private/qobject_p.h>
+#include <QBasicTimer>
+
+QT_BEGIN_NAMESPACE
+class QSmoothedAnimation;
+class QSmoothedAnimationTimer : public QTimer
+{
+ Q_OBJECT
+public:
+ explicit QSmoothedAnimationTimer(QSmoothedAnimation *animation, QObject *parent = 0);
+ ~QSmoothedAnimationTimer();
+public Q_SLOTS:
+ void stopAnimation();
+private:
+ QSmoothedAnimation *m_animation;
+};
+
+class QQuickSmoothedAnimationPrivate;
+class Q_AUTOTEST_EXPORT QSmoothedAnimation : public QAbstractAnimationJob
+{
+ Q_DISABLE_COPY(QSmoothedAnimation)
+public:
+ QSmoothedAnimation(QQuickSmoothedAnimationPrivate * = 0);
+
+ ~QSmoothedAnimation();
+ qreal to;
+ qreal velocity;
+ int userDuration;
+
+ int maximumEasingTime;
+ QQuickSmoothedAnimation::ReversingMode reversingMode;
+
+ qreal initialVelocity;
+ qreal trackVelocity;
+
+ QQmlProperty target;
+
+ int duration() const;
+ void restart();
+ void init();
+
+ void prepareForRestart();
+ void clearTemplate() { animationTemplate = 0; }
+
+protected:
+ virtual void updateCurrentTime(int);
+ virtual void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State);
+
+private:
+ qreal easeFollow(qreal);
+ qreal initialValue;
+
+ bool invert;
+
+ int finalDuration;
+
+ // Parameters for use in updateCurrentTime()
+ qreal a; // Acceleration
+ qreal d; // Deceleration
+ qreal tf; // Total time
+ qreal tp; // Time at which peak velocity occurs
+ qreal td; // Time at which deceleration begins
+ qreal vp; // Velocity at tp
+ qreal sp; // Displacement at tp
+ qreal sd; // Displacement at td
+ qreal vi; // "Normalized" initialvelocity
+ qreal s; // Total s
+
+ int lastTime;
+ bool useDelta;
+
+ bool recalc();
+ void delayedStop();
+ QSmoothedAnimationTimer *delayedStopTimer;
+ QQuickSmoothedAnimationPrivate *animationTemplate;
+};
+
+class QQuickSmoothedAnimationPrivate : public QQuickPropertyAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickSmoothedAnimation)
+public:
+ QQuickSmoothedAnimationPrivate();
+ ~QQuickSmoothedAnimationPrivate();
+ void updateRunningAnimations();
+
+ QSmoothedAnimation *anim;
+ QHash<QQmlProperty, QSmoothedAnimation*> activeAnimations;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSMOOTHEDANIMATION2_P_H
diff --git a/src/quick/util/qquickspringanimation.cpp b/src/quick/util/qquickspringanimation.cpp
new file mode 100644
index 0000000000..84de994452
--- /dev/null
+++ b/src/quick/util/qquickspringanimation.cpp
@@ -0,0 +1,593 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickspringanimation_p.h"
+
+#include "qquickanimation_p_p.h"
+#include <private/qqmlproperty_p.h>
+#include "private/qparallelanimationgroupjob_p.h"
+
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+#include <limits.h>
+#include <math.h>
+
+#define DELAY_STOP_TIMER_INTERVAL 32
+
+QT_BEGIN_NAMESPACE
+
+class QQuickSpringAnimationPrivate;
+class Q_AUTOTEST_EXPORT QSpringAnimation : public QAbstractAnimationJob
+{
+ Q_DISABLE_COPY(QSpringAnimation)
+public:
+ QSpringAnimation(QQuickSpringAnimationPrivate * = 0);
+
+ ~QSpringAnimation();
+ int duration() const;
+ void restart();
+ void init();
+
+ qreal currentValue;
+ qreal to;
+ qreal velocity;
+ int startTime;
+ int dura;
+ int lastTime;
+ int stopTime;
+ enum Mode {
+ Track,
+ Velocity,
+ Spring
+ };
+ Mode mode;
+ QQmlProperty target;
+
+ qreal velocityms;
+ qreal maxVelocity;
+ qreal mass;
+ qreal spring;
+ qreal damping;
+ qreal epsilon;
+ qreal modulus;
+
+ bool useMass : 1;
+ bool haveModulus : 1;
+ bool useDelta : 1;
+ typedef QHash<QQmlProperty, QSpringAnimation*> ActiveAnimationHash;
+
+ void clearTemplate() { animationTemplate = 0; }
+
+protected:
+ virtual void updateCurrentTime(int time);
+ virtual void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State);
+
+private:
+ QQuickSpringAnimationPrivate *animationTemplate;
+};
+
+class QQuickSpringAnimationPrivate : public QQuickPropertyAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickSpringAnimation)
+public:
+ QQuickSpringAnimationPrivate()
+ : QQuickPropertyAnimationPrivate()
+ , velocityms(0)
+ , maxVelocity(0)
+ , mass(1.0)
+ , spring(0.)
+ , damping(0.)
+ , epsilon(0.01)
+ , modulus(0.0)
+ , useMass(false)
+ , haveModulus(false)
+ , mode(QSpringAnimation::Track)
+ { elapsed.start(); }
+
+ void updateMode();
+ qreal velocityms;
+ qreal maxVelocity;
+ qreal mass;
+ qreal spring;
+ qreal damping;
+ qreal epsilon;
+ qreal modulus;
+
+ bool useMass : 1;
+ bool haveModulus : 1;
+ QSpringAnimation::Mode mode;
+
+ QSpringAnimation::ActiveAnimationHash activeAnimations;
+ QElapsedTimer elapsed;
+};
+
+QSpringAnimation::QSpringAnimation(QQuickSpringAnimationPrivate *priv)
+ : QAbstractAnimationJob()
+ , currentValue(0)
+ , to(0)
+ , velocity(0)
+ , startTime(0)
+ , dura(0)
+ , lastTime(0)
+ , stopTime(-1)
+ , mode(Track)
+ , velocityms(0)
+ , maxVelocity(0)
+ , mass(1.0)
+ , spring(0.)
+ , damping(0.)
+ , epsilon(0.01)
+ , modulus(0.0)
+ , useMass(false)
+ , haveModulus(false)
+ , useDelta(false)
+ , animationTemplate(priv)
+{
+}
+
+QSpringAnimation::~QSpringAnimation()
+{
+ if (animationTemplate) {
+ if (target.object()) {
+ QSpringAnimation::ActiveAnimationHash::iterator it =
+ animationTemplate->activeAnimations.find(target);
+ if (it != animationTemplate->activeAnimations.end() && it.value() == this)
+ animationTemplate->activeAnimations.erase(it);
+ } else {
+ //target is no longer valid, need to search linearly
+ QSpringAnimation::ActiveAnimationHash::iterator it;
+ for (it = animationTemplate->activeAnimations.begin(); it != animationTemplate->activeAnimations.end(); ++it) {
+ if (it.value() == this) {
+ animationTemplate->activeAnimations.erase(it);
+ break;
+ }
+ }
+ }
+ }
+}
+
+int QSpringAnimation::duration() const
+{
+ return -1;
+}
+
+void QSpringAnimation::restart()
+{
+ if (isRunning() || (stopTime != -1 && (animationTemplate->elapsed.elapsed() - stopTime) < DELAY_STOP_TIMER_INTERVAL)) {
+ useDelta = true;
+ init();
+ lastTime = 0;
+ } else {
+ useDelta = false;
+ //init() will be triggered when group starts
+ }
+}
+
+void QSpringAnimation::init()
+{
+ lastTime = startTime = 0;
+ stopTime = -1;
+}
+
+void QSpringAnimation::updateCurrentTime(int time)
+{
+ if (mode == Track) {
+ stop();
+ return;
+ }
+
+ int elapsed = useDelta ? QQmlAnimationTimer::instance()->currentDelta() : time - lastTime;
+ if (useDelta) {
+ startTime = time - elapsed;
+ useDelta = false;
+ }
+
+ if (!elapsed)
+ return;
+
+ int count = elapsed / 16;
+
+ if (mode == Spring) {
+ if (elapsed < 16) // capped at 62fps.
+ return;
+ lastTime = time - (elapsed - count * 16);
+ } else {
+ lastTime = time;
+ }
+
+ qreal srcVal = to;
+
+ bool stopped = false;
+
+ if (haveModulus) {
+ currentValue = fmod(currentValue, modulus);
+ srcVal = fmod(srcVal, modulus);
+ }
+ if (mode == Spring) {
+ // Real men solve the spring DEs using RK4.
+ // We'll do something much simpler which gives a result that looks fine.
+ for (int i = 0; i < count; ++i) {
+ qreal diff = srcVal - currentValue;
+ if (haveModulus && qAbs(diff) > modulus / 2) {
+ if (diff < 0)
+ diff += modulus;
+ else
+ diff -= modulus;
+ }
+ if (useMass)
+ velocity = velocity + (spring * diff - damping * velocity) / mass;
+ else
+ velocity = velocity + spring * diff - damping * velocity;
+ if (maxVelocity > 0.) {
+ // limit velocity
+ if (velocity > maxVelocity)
+ velocity = maxVelocity;
+ else if (velocity < -maxVelocity)
+ velocity = -maxVelocity;
+ }
+ currentValue += velocity * 16.0 / 1000.0;
+ if (haveModulus) {
+ currentValue = fmod(currentValue, modulus);
+ if (currentValue < 0.0)
+ currentValue += modulus;
+ }
+ }
+ if (qAbs(velocity) < epsilon && qAbs(srcVal - currentValue) < epsilon) {
+ velocity = 0.0;
+ currentValue = srcVal;
+ stopped = true;
+ }
+ } else {
+ qreal moveBy = elapsed * velocityms;
+ qreal diff = srcVal - currentValue;
+ if (haveModulus && qAbs(diff) > modulus / 2) {
+ if (diff < 0)
+ diff += modulus;
+ else
+ diff -= modulus;
+ }
+ if (diff > 0) {
+ currentValue += moveBy;
+ if (haveModulus)
+ currentValue = fmod(currentValue, modulus);
+ } else {
+ currentValue -= moveBy;
+ if (haveModulus && currentValue < 0.0)
+ currentValue = fmod(currentValue, modulus) + modulus;
+ }
+ if (lastTime - startTime >= dura) {
+ currentValue = to;
+ stopped = true;
+ }
+ }
+
+ qreal old_to = to;
+
+ QQmlPropertyPrivate::write(target, currentValue,
+ QQmlPropertyPrivate::BypassInterceptor |
+ QQmlPropertyPrivate::DontRemoveBinding);
+
+ if (stopped && old_to == to) { // do not stop if we got restarted
+ stopTime = animationTemplate->elapsed.elapsed();
+ stop();
+ }
+}
+
+void QSpringAnimation::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State /*oldState*/)
+{
+ if (newState == QAbstractAnimationJob::Running)
+ init();
+}
+
+void QQuickSpringAnimationPrivate::updateMode()
+{
+ if (spring == 0. && maxVelocity == 0.)
+ mode = QSpringAnimation::Track;
+ else if (spring > 0.)
+ mode = QSpringAnimation::Spring;
+ else {
+ mode = QSpringAnimation::Velocity;
+ QSpringAnimation::ActiveAnimationHash::iterator it;
+ for (it = activeAnimations.begin(); it != activeAnimations.end(); ++it) {
+ QSpringAnimation *animation = *it;
+ animation->startTime = animation->lastTime;
+ qreal dist = qAbs(animation->currentValue - animation->to);
+ if (haveModulus && dist > modulus / 2)
+ dist = modulus - fmod(dist, modulus);
+ animation->dura = dist / velocityms;
+ }
+ }
+}
+
+/*!
+ \qmlclass SpringAnimation QQuickSpringAnimation
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \inherits NumberAnimation
+
+ \brief The SpringAnimation element allows a property to track a value in a spring-like motion.
+
+ SpringAnimation mimics the oscillatory behavior of a spring, with the appropriate \l spring constant to
+ control the acceleration and the \l damping to control how quickly the effect dies away.
+
+ 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. 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/qml/springanimation.qml 0
+
+ Like any other animation element, a SpringAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l {QML Animation and Transitions} documentation shows a
+ variety of methods for creating animations.
+
+ \sa SmoothedAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example}
+*/
+
+QQuickSpringAnimation::QQuickSpringAnimation(QObject *parent)
+: QQuickNumberAnimation(*(new QQuickSpringAnimationPrivate),parent)
+{
+}
+
+QQuickSpringAnimation::~QQuickSpringAnimation()
+{
+ Q_D(QQuickSpringAnimation);
+ QSpringAnimation::ActiveAnimationHash::iterator it;
+ for (it = d->activeAnimations.begin(); it != d->activeAnimations.end(); ++it) {
+ it.value()->clearTemplate();
+ }
+}
+
+/*!
+ \qmlproperty real QtQuick2::SpringAnimation::velocity
+
+ This property holds the maximum velocity allowed when tracking the source.
+
+ The default value is 0 (no maximum velocity).
+*/
+
+qreal QQuickSpringAnimation::velocity() const
+{
+ Q_D(const QQuickSpringAnimation);
+ return d->maxVelocity;
+}
+
+void QQuickSpringAnimation::setVelocity(qreal velocity)
+{
+ Q_D(QQuickSpringAnimation);
+ d->maxVelocity = velocity;
+ d->velocityms = velocity / 1000.0;
+ d->updateMode();
+}
+
+/*!
+ \qmlproperty real QtQuick2::SpringAnimation::spring
+
+ 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 this property is set and the \l velocity value is greater than 0,
+ the \l velocity limits the maximum speed.
+*/
+qreal QQuickSpringAnimation::spring() const
+{
+ Q_D(const QQuickSpringAnimation);
+ return d->spring;
+}
+
+void QQuickSpringAnimation::setSpring(qreal spring)
+{
+ Q_D(QQuickSpringAnimation);
+ d->spring = spring;
+ d->updateMode();
+}
+
+/*!
+ \qmlproperty real QtQuick2::SpringAnimation::damping
+ This property holds the spring damping value.
+
+ This value describes how quickly the spring-like motion comes to rest.
+ The default value is 0.
+
+ The useful value range is 0 - 1.0. The lower the value, the faster it
+ comes to rest.
+*/
+qreal QQuickSpringAnimation::damping() const
+{
+ Q_D(const QQuickSpringAnimation);
+ return d->damping;
+}
+
+void QQuickSpringAnimation::setDamping(qreal damping)
+{
+ Q_D(QQuickSpringAnimation);
+ if (damping > 1.)
+ damping = 1.;
+
+ d->damping = damping;
+}
+
+
+/*!
+ \qmlproperty real QtQuick2::SpringAnimation::epsilon
+ This property holds the spring epsilon.
+
+ The epsilon is the rate and amount of change in the value which is close enough
+ to 0 to be considered equal to zero. This will depend on the usage of the value.
+ For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
+
+ The default is 0.01. Tuning this value can provide small performance improvements.
+*/
+qreal QQuickSpringAnimation::epsilon() const
+{
+ Q_D(const QQuickSpringAnimation);
+ return d->epsilon;
+}
+
+void QQuickSpringAnimation::setEpsilon(qreal epsilon)
+{
+ Q_D(QQuickSpringAnimation);
+ d->epsilon = epsilon;
+}
+
+/*!
+ \qmlproperty real QtQuick2::SpringAnimation::modulus
+ 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.
+*/
+qreal QQuickSpringAnimation::modulus() const
+{
+ Q_D(const QQuickSpringAnimation);
+ return d->modulus;
+}
+
+void QQuickSpringAnimation::setModulus(qreal modulus)
+{
+ Q_D(QQuickSpringAnimation);
+ if (d->modulus != modulus) {
+ d->haveModulus = modulus != 0.0;
+ d->modulus = modulus;
+ d->updateMode();
+ emit modulusChanged();
+ }
+}
+
+/*!
+ \qmlproperty real QtQuick2::SpringAnimation::mass
+ This property holds the "mass" of the property being moved.
+
+ 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 QQuickSpringAnimation::mass() const
+{
+ Q_D(const QQuickSpringAnimation);
+ return d->mass;
+}
+
+void QQuickSpringAnimation::setMass(qreal mass)
+{
+ Q_D(QQuickSpringAnimation);
+ if (d->mass != mass && mass > 0.0) {
+ d->useMass = mass != 1.0;
+ d->mass = mass;
+ emit massChanged();
+ }
+}
+
+QAbstractAnimationJob* QQuickSpringAnimation::transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickSpringAnimation);
+ Q_UNUSED(direction);
+
+ QParallelAnimationGroupJob *wrapperGroup = new QParallelAnimationGroupJob();
+
+ QQuickStateActions dataActions = QQuickNumberAnimation::createTransitionActions(actions, modified, defaultTarget);
+ if (!dataActions.isEmpty()) {
+ QSet<QAbstractAnimationJob*> anims;
+ for (int i = 0; i < dataActions.size(); ++i) {
+ QSpringAnimation *animation;
+ bool needsRestart = false;
+ const QQmlProperty &property = dataActions.at(i).property;
+ if (d->activeAnimations.contains(property)) {
+ animation = d->activeAnimations[property];
+ needsRestart = true;
+ } else {
+ animation = new QSpringAnimation(d);
+ d->activeAnimations.insert(property, animation);
+ animation->target = property;
+ }
+ wrapperGroup->appendAnimation(initInstance(animation));
+
+ animation->to = dataActions.at(i).toValue.toReal();
+ animation->startTime = 0;
+ animation->velocityms = d->velocityms;
+ animation->mass = d->mass;
+ animation->spring = d->spring;
+ animation->damping = d->damping;
+ animation->epsilon = d->epsilon;
+ animation->modulus = d->modulus;
+ animation->useMass = d->useMass;
+ animation->haveModulus = d->haveModulus;
+ animation->mode = d->mode;
+ animation->dura = -1;
+ animation->maxVelocity = d->maxVelocity;
+
+ if (d->fromIsDefined)
+ animation->currentValue = dataActions.at(i).fromValue.toReal();
+ else
+ animation->currentValue = property.read().toReal();
+ if (animation->mode == QSpringAnimation::Velocity) {
+ qreal dist = qAbs(animation->currentValue - animation->to);
+ if (d->haveModulus && dist > d->modulus / 2)
+ dist = d->modulus - fmod(dist, d->modulus);
+ animation->dura = dist / animation->velocityms;
+ }
+
+ if (needsRestart)
+ animation->restart();
+ anims.insert(animation);
+ }
+ foreach (QSpringAnimation *anim, d->activeAnimations.values()){
+ if (!anims.contains(anim)) {
+ anim->clearTemplate();
+ d->activeAnimations.remove(anim->target);
+ }
+ }
+ }
+ return wrapperGroup;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickspringanimation_p.h b/src/quick/util/qquickspringanimation_p.h
new file mode 100644
index 0000000000..03c586e687
--- /dev/null
+++ b/src/quick/util/qquickspringanimation_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSPRINGANIMATION_H
+#define QQUICKSPRINGANIMATION_H
+
+#include <qqml.h>
+#include "qquickanimation_p.h"
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickSpringAnimationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickSpringAnimation : public QQuickNumberAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickSpringAnimation)
+ Q_INTERFACES(QQmlPropertyValueSource)
+
+ Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
+ Q_PROPERTY(qreal spring READ spring WRITE setSpring)
+ Q_PROPERTY(qreal damping READ damping WRITE setDamping)
+ Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon)
+ Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
+ Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
+
+public:
+ QQuickSpringAnimation(QObject *parent=0);
+ ~QQuickSpringAnimation();
+
+ qreal velocity() const;
+ void setVelocity(qreal velocity);
+
+ qreal spring() const;
+ void setSpring(qreal spring);
+
+ qreal damping() const;
+ void setDamping(qreal damping);
+
+ qreal epsilon() const;
+ void setEpsilon(qreal epsilon);
+
+ qreal mass() const;
+ void setMass(qreal modulus);
+
+ qreal modulus() const;
+ void setModulus(qreal modulus);
+
+ virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QQmlProperties &modified,
+ TransitionDirection direction,
+ QObject *defaultTarget = 0);
+
+Q_SIGNALS:
+ void modulusChanged();
+ void massChanged();
+ void syncChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickSpringAnimation)
+
+QT_END_HEADER
+
+#endif // QQUICKSPRINGANIMATION_H
diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp
new file mode 100644
index 0000000000..53906a5651
--- /dev/null
+++ b/src/quick/util/qquickstate.cpp
@@ -0,0 +1,729 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickstate_p_p.h"
+#include "qquickstate_p.h"
+
+#include "qquickstategroup_p.h"
+#include "qquickstatechangescript_p.h"
+
+#include <private/qqmlglobal_p.h>
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
+
+QQuickAction::QQuickAction()
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), event(0),
+ specifiedObject(0)
+{
+}
+
+QQuickAction::QQuickAction(QObject *target, const QString &propertyName,
+ const QVariant &value)
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
+ property(target, propertyName, qmlEngine(target)), toValue(value),
+ fromBinding(0), event(0),
+ specifiedObject(target), specifiedProperty(propertyName)
+{
+ if (property.isValid())
+ fromValue = property.read();
+}
+
+QQuickAction::QQuickAction(QObject *target, const QString &propertyName,
+ QQmlContext *context, const QVariant &value)
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
+ property(target, propertyName, context), toValue(value),
+ fromBinding(0), event(0),
+ specifiedObject(target), specifiedProperty(propertyName)
+{
+ if (property.isValid())
+ fromValue = property.read();
+}
+
+
+QQuickActionEvent::~QQuickActionEvent()
+{
+}
+
+void QQuickActionEvent::execute(Reason)
+{
+}
+
+bool QQuickActionEvent::isReversable()
+{
+ return false;
+}
+
+void QQuickActionEvent::reverse(Reason)
+{
+}
+
+bool QQuickActionEvent::changesBindings()
+{
+ return false;
+}
+
+void QQuickActionEvent::clearBindings()
+{
+}
+
+bool QQuickActionEvent::override(QQuickActionEvent *other)
+{
+ Q_UNUSED(other);
+ return false;
+}
+
+QQuickStateOperation::QQuickStateOperation(QObjectPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
+/*!
+ \qmlclass State QQuickState
+ \inqmlmodule QtQuick 2
+ \ingroup qml-state-elements
+ \brief The State element defines configurations of objects and properties.
+
+ A \e state is a set of batched changes from the default configuration.
+
+ All items have a default state that defines the default configuration of objects
+ and property values. New states can be defined by adding State items to the \l {Item::states}{states} property to
+ allow items to switch between different configurations. These configurations
+ can, for example, be used to apply different sets of property values or execute
+ different scripts.
+
+ The following example displays a single \l Rectangle. In the default state, the rectangle
+ is colored black. In the "clicked" state, a PropertyChanges element changes the
+ rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state
+ between the default state and the "clicked" state, thus toggling the color of the
+ rectangle between black and red.
+
+ \snippet doc/src/snippets/qml/state.qml 0
+
+ Notice the default state is referred to using an empty string ("").
+
+ States are commonly used together with \l{QML Animation and Transitions}{Transitions} to provide
+ animations when state changes occur.
+
+ \note Setting the state of an object from within another state of the same object is
+ not allowed.
+
+ \sa {declarative/animation/states}{states example}, {qmlstates}{States},
+ {QML Animation and Transitions}{Transitions}, QtQml
+*/
+QQuickState::QQuickState(QObject *parent)
+: QObject(*(new QQuickStatePrivate), parent)
+{
+ Q_D(QQuickState);
+ d->transitionManager.setState(this);
+}
+
+QQuickState::~QQuickState()
+{
+ Q_D(QQuickState);
+ if (d->group)
+ d->group->removeState(this);
+}
+
+/*!
+ \qmlproperty string QtQuick2::State::name
+ This property holds the name of the state.
+
+ Each state should have a unique name within its item.
+*/
+QString QQuickState::name() const
+{
+ Q_D(const QQuickState);
+ return d->name;
+}
+
+void QQuickState::setName(const QString &n)
+{
+ Q_D(QQuickState);
+ d->name = n;
+ d->named = true;
+}
+
+bool QQuickState::isNamed() const
+{
+ Q_D(const QQuickState);
+ return d->named;
+}
+
+bool QQuickState::isWhenKnown() const
+{
+ Q_D(const QQuickState);
+ return d->when != 0;
+}
+
+/*!
+ \qmlproperty bool QtQuick2::State::when
+ This property holds when the state should be applied.
+
+ This should be set to an expression that evaluates to \c true when you want the state to
+ be applied. For example, the following \l Rectangle changes in and out of the "hidden"
+ state when the \l MouseArea is pressed:
+
+ \snippet doc/src/snippets/qml/state-when.qml 0
+
+ If multiple states in a group have \c when clauses that evaluate to \c true
+ at the same time, the first matching state will be applied. For example, in
+ the following snippet \c state1 will always be selected rather than
+ \c state2 when sharedCondition becomes \c true.
+ \qml
+ Item {
+ states: [
+ State { name: "state1"; when: sharedCondition },
+ State { name: "state2"; when: sharedCondition }
+ ]
+ // ...
+ }
+ \endqml
+*/
+QQmlBinding *QQuickState::when() const
+{
+ Q_D(const QQuickState);
+ return d->when;
+}
+
+void QQuickState::setWhen(QQmlBinding *when)
+{
+ Q_D(QQuickState);
+ d->when = when;
+ if (d->group)
+ d->group->updateAutoState();
+}
+
+/*!
+ \qmlproperty string QtQuick2::State::extend
+ This property holds the state that this state extends.
+
+ When a state extends another state, it inherits all the changes of that state.
+
+ The state being extended is treated as the base state in regards to
+ the changes specified by the extending state.
+*/
+QString QQuickState::extends() const
+{
+ Q_D(const QQuickState);
+ return d->extends;
+}
+
+void QQuickState::setExtends(const QString &extends)
+{
+ Q_D(QQuickState);
+ d->extends = extends;
+}
+
+/*!
+ \qmlproperty list<Change> QtQuick2::State::changes
+ This property holds the changes to apply for this state
+ \default
+
+ By default these changes are applied against the default state. If the state
+ extends another state, then the changes are applied against the state being
+ extended.
+*/
+QQmlListProperty<QQuickStateOperation> QQuickState::changes()
+{
+ Q_D(QQuickState);
+ return QQmlListProperty<QQuickStateOperation>(this, &d->operations, QQuickStatePrivate::operations_append,
+ QQuickStatePrivate::operations_count, QQuickStatePrivate::operations_at,
+ QQuickStatePrivate::operations_clear);
+}
+
+int QQuickState::operationCount() const
+{
+ Q_D(const QQuickState);
+ return d->operations.count();
+}
+
+QQuickStateOperation *QQuickState::operationAt(int index) const
+{
+ Q_D(const QQuickState);
+ return d->operations.at(index);
+}
+
+QQuickState &QQuickState::operator<<(QQuickStateOperation *op)
+{
+ Q_D(QQuickState);
+ d->operations.append(QQuickStatePrivate::OperationGuard(op, &d->operations));
+ return *this;
+}
+
+void QQuickStatePrivate::complete()
+{
+ Q_Q(QQuickState);
+
+ for (int ii = 0; ii < reverting.count(); ++ii) {
+ for (int jj = 0; jj < revertList.count(); ++jj) {
+ const QQuickRevertAction &revert = reverting.at(ii);
+ const QQuickSimpleAction &simple = revertList.at(jj);
+ if ((revert.event && simple.event() == revert.event) ||
+ simple.property() == revert.property) {
+ revertList.removeAt(jj);
+ break;
+ }
+ }
+ }
+ reverting.clear();
+
+ if (group)
+ group->stateAboutToComplete();
+ emit q->completed();
+}
+
+// Generate a list of actions for this state. This includes coelescing state
+// actions that this state "extends"
+QQuickStateOperation::ActionList
+QQuickStatePrivate::generateActionList() const
+{
+ QQuickStateOperation::ActionList applyList;
+ if (inState)
+ return applyList;
+
+ // Prevent "extends" recursion
+ inState = true;
+
+ if (!extends.isEmpty()) {
+ QList<QQuickState *> states = group ? group->states() : QList<QQuickState *>();
+ for (int ii = 0; ii < states.count(); ++ii)
+ if (states.at(ii)->name() == extends) {
+ qmlExecuteDeferred(states.at(ii));
+ applyList = static_cast<QQuickStatePrivate*>(states.at(ii)->d_func())->generateActionList();
+ }
+ }
+
+ foreach(QQuickStateOperation *op, operations)
+ applyList << op->actions();
+
+ inState = false;
+ return applyList;
+}
+
+QQuickStateGroup *QQuickState::stateGroup() const
+{
+ Q_D(const QQuickState);
+ return d->group;
+}
+
+void QQuickState::setStateGroup(QQuickStateGroup *group)
+{
+ Q_D(QQuickState);
+ d->group = group;
+}
+
+void QQuickState::cancel()
+{
+ Q_D(QQuickState);
+ d->transitionManager.cancel();
+}
+
+void QQuickAction::deleteFromBinding()
+{
+ if (fromBinding) {
+ QQmlPropertyPrivate::setBinding(property, 0);
+ fromBinding->destroy();
+ fromBinding = 0;
+ }
+}
+
+bool QQuickState::containsPropertyInRevertList(QObject *target, const QString &name) const
+{
+ Q_D(const QQuickState);
+
+ if (isStateActive()) {
+ QListIterator<QQuickSimpleAction> revertListIterator(d->revertList);
+
+ while (revertListIterator.hasNext()) {
+ const QQuickSimpleAction &simpleAction = revertListIterator.next();
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool QQuickState::changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue)
+{
+ Q_D(QQuickState);
+
+ if (isStateActive()) {
+ QMutableListIterator<QQuickSimpleAction> revertListIterator(d->revertList);
+
+ while (revertListIterator.hasNext()) {
+ QQuickSimpleAction &simpleAction = revertListIterator.next();
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
+ simpleAction.setValue(revertValue);
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool QQuickState::changeBindingInRevertList(QObject *target, const QString &name, QQmlAbstractBinding *binding)
+{
+ Q_D(QQuickState);
+
+ if (isStateActive()) {
+ QMutableListIterator<QQuickSimpleAction> revertListIterator(d->revertList);
+
+ while (revertListIterator.hasNext()) {
+ QQuickSimpleAction &simpleAction = revertListIterator.next();
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
+ if (simpleAction.binding())
+ simpleAction.binding()->destroy();
+
+ simpleAction.setBinding(binding);
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool QQuickState::removeEntryFromRevertList(QObject *target, const QString &name)
+{
+ Q_D(QQuickState);
+
+ if (isStateActive()) {
+ QMutableListIterator<QQuickSimpleAction> revertListIterator(d->revertList);
+
+ while (revertListIterator.hasNext()) {
+ QQuickSimpleAction &simpleAction = revertListIterator.next();
+ if (simpleAction.property().object() == target && simpleAction.property().name() == name) {
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(simpleAction.property());
+ if (oldBinding) {
+ QQmlPropertyPrivate::setBinding(simpleAction.property(), 0);
+ oldBinding->destroy();
+ }
+
+ simpleAction.property().write(simpleAction.value());
+ if (simpleAction.binding())
+ QQmlPropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding());
+
+ revertListIterator.remove();
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void QQuickState::addEntryToRevertList(const QQuickAction &action)
+{
+ Q_D(QQuickState);
+
+ QQuickSimpleAction simpleAction(action);
+
+ d->revertList.append(simpleAction);
+}
+
+void QQuickState::removeAllEntriesFromRevertList(QObject *target)
+{
+ Q_D(QQuickState);
+
+ if (isStateActive()) {
+ QMutableListIterator<QQuickSimpleAction> revertListIterator(d->revertList);
+
+ while (revertListIterator.hasNext()) {
+ QQuickSimpleAction &simpleAction = revertListIterator.next();
+ if (simpleAction.property().object() == target) {
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(simpleAction.property());
+ if (oldBinding) {
+ QQmlPropertyPrivate::setBinding(simpleAction.property(), 0);
+ oldBinding->destroy();
+ }
+
+ simpleAction.property().write(simpleAction.value());
+ if (simpleAction.binding())
+ QQmlPropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding());
+
+ revertListIterator.remove();
+ }
+ }
+ }
+}
+
+void QQuickState::addEntriesToRevertList(const QList<QQuickAction> &actionList)
+{
+ Q_D(QQuickState);
+ if (isStateActive()) {
+ QList<QQuickSimpleAction> simpleActionList;
+
+ QListIterator<QQuickAction> actionListIterator(actionList);
+ while(actionListIterator.hasNext()) {
+ const QQuickAction &action = actionListIterator.next();
+ QQuickSimpleAction simpleAction(action);
+ action.property.write(action.toValue);
+ if (!action.toBinding.isNull()) {
+ QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(simpleAction.property());
+ if (oldBinding)
+ QQmlPropertyPrivate::setBinding(simpleAction.property(), 0);
+ QQmlPropertyPrivate::setBinding(simpleAction.property(), action.toBinding.data(), QQmlPropertyPrivate::DontRemoveBinding);
+ }
+
+ simpleActionList.append(simpleAction);
+ }
+
+ d->revertList.append(simpleActionList);
+ }
+}
+
+QVariant QQuickState::valueInRevertList(QObject *target, const QString &name) const
+{
+ Q_D(const QQuickState);
+
+ if (isStateActive()) {
+ QListIterator<QQuickSimpleAction> revertListIterator(d->revertList);
+
+ while (revertListIterator.hasNext()) {
+ const QQuickSimpleAction &simpleAction = revertListIterator.next();
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
+ return simpleAction.value();
+ }
+ }
+
+ return QVariant();
+}
+
+QQmlAbstractBinding *QQuickState::bindingInRevertList(QObject *target, const QString &name) const
+{
+ Q_D(const QQuickState);
+
+ if (isStateActive()) {
+ QListIterator<QQuickSimpleAction> revertListIterator(d->revertList);
+
+ while (revertListIterator.hasNext()) {
+ const QQuickSimpleAction &simpleAction = revertListIterator.next();
+ if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
+ return simpleAction.binding();
+ }
+ }
+
+ return 0;
+}
+
+bool QQuickState::isStateActive() const
+{
+ return stateGroup() && stateGroup()->state() == name();
+}
+
+void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
+{
+ Q_D(QQuickState);
+
+ qmlExecuteDeferred(this);
+
+ cancel();
+ if (revert)
+ revert->cancel();
+ d->revertList.clear();
+ d->reverting.clear();
+
+ if (revert) {
+ QQuickStatePrivate *revertPrivate =
+ static_cast<QQuickStatePrivate*>(revert->d_func());
+ d->revertList = revertPrivate->revertList;
+ revertPrivate->revertList.clear();
+ }
+
+ // List of actions caused by this state
+ QQuickStateOperation::ActionList applyList = d->generateActionList();
+
+ // List of actions that need to be reverted to roll back (just) this state
+ QQuickStatePrivate::SimpleActionList additionalReverts;
+ // First add the reverse of all the applyList actions
+ for (int ii = 0; ii < applyList.count(); ++ii) {
+ QQuickAction &action = applyList[ii];
+
+ if (action.event) {
+ if (!action.event->isReversable())
+ continue;
+ bool found = false;
+ for (int jj = 0; jj < d->revertList.count(); ++jj) {
+ QQuickActionEvent *event = d->revertList.at(jj).event();
+ if (event && event->type() == action.event->type()) {
+ if (action.event->override(event)) {
+ found = true;
+
+ if (action.event != d->revertList.at(jj).event() && action.event->needsCopy()) {
+ action.event->copyOriginals(d->revertList.at(jj).event());
+
+ QQuickSimpleAction r(action);
+ additionalReverts << r;
+ d->revertList.removeAt(jj);
+ --jj;
+ } else if (action.event->isRewindable()) //###why needed?
+ action.event->saveCurrentValues();
+
+ break;
+ }
+ }
+ }
+ if (!found) {
+ action.event->saveOriginals();
+ // Only need to revert the applyList action if the previous
+ // state doesn't have a higher priority revert already
+ QQuickSimpleAction r(action);
+ additionalReverts << r;
+ }
+ } else {
+ bool found = false;
+ action.fromBinding = QQmlPropertyPrivate::binding(action.property);
+
+ for (int jj = 0; jj < d->revertList.count(); ++jj) {
+ if (d->revertList.at(jj).property() == action.property) {
+ found = true;
+ if (d->revertList.at(jj).binding() != action.fromBinding) {
+ action.deleteFromBinding();
+ }
+ break;
+ }
+ }
+
+ if (!found) {
+ if (!action.restore) {
+ action.deleteFromBinding();;
+ } else {
+ // Only need to revert the applyList action if the previous
+ // state doesn't have a higher priority revert already
+ QQuickSimpleAction r(action);
+ additionalReverts << r;
+ }
+ }
+ }
+ }
+
+ // Any reverts from a previous state that aren't carried forth
+ // into this state need to be translated into apply actions
+ for (int ii = 0; ii < d->revertList.count(); ++ii) {
+ bool found = false;
+ if (d->revertList.at(ii).event()) {
+ QQuickActionEvent *event = d->revertList.at(ii).event();
+ if (!event->isReversable())
+ continue;
+ for (int jj = 0; !found && jj < applyList.count(); ++jj) {
+ const QQuickAction &action = applyList.at(jj);
+ if (action.event && action.event->type() == event->type()) {
+ if (action.event->override(event))
+ found = true;
+ }
+ }
+ } else {
+ for (int jj = 0; !found && jj < applyList.count(); ++jj) {
+ const QQuickAction &action = applyList.at(jj);
+ if (action.property == d->revertList.at(ii).property())
+ found = true;
+ }
+ }
+ if (!found) {
+ QVariant cur = d->revertList.at(ii).property().read();
+ QQmlAbstractBinding *delBinding =
+ QQmlPropertyPrivate::setBinding(d->revertList.at(ii).property(), 0);
+ if (delBinding)
+ delBinding->destroy();
+
+ QQuickAction a;
+ a.property = d->revertList.at(ii).property();
+ a.fromValue = cur;
+ a.toValue = d->revertList.at(ii).value();
+ a.toBinding = QQmlAbstractBinding::getPointer(d->revertList.at(ii).binding());
+ a.specifiedObject = d->revertList.at(ii).specifiedObject();
+ a.specifiedProperty = d->revertList.at(ii).specifiedProperty();
+ a.event = d->revertList.at(ii).event();
+ a.reverseEvent = d->revertList.at(ii).reverseEvent();
+ if (a.event && a.event->isRewindable())
+ a.event->saveCurrentValues();
+ applyList << a;
+ // Store these special reverts in the reverting list
+ if (a.event)
+ d->reverting << a.event;
+ else
+ d->reverting << a.property;
+ }
+ }
+ // All the local reverts now become part of the ongoing revertList
+ d->revertList << additionalReverts;
+
+#ifndef QT_NO_DEBUG_STREAM
+ // Output for debugging
+ if (stateChangeDebug()) {
+ foreach(const QQuickAction &action, applyList) {
+ if (action.event)
+ qWarning() << " QQuickAction event:" << action.event->type();
+ else
+ qWarning() << " QQuickAction:" << action.property.object()
+ << action.property.name() << "From:" << action.fromValue
+ << "To:" << action.toValue;
+ }
+ }
+#endif
+
+ d->transitionManager.transition(applyList, trans);
+}
+
+QQuickStateOperation::ActionList QQuickStateOperation::actions()
+{
+ return ActionList();
+}
+
+QQuickState *QQuickStateOperation::state() const
+{
+ Q_D(const QQuickStateOperation);
+ return d->m_state;
+}
+
+void QQuickStateOperation::setState(QQuickState *state)
+{
+ Q_D(QQuickStateOperation);
+ d->m_state = state;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickstate_p.h b/src/quick/util/qquickstate_p.h
new file mode 100644
index 0000000000..7dfc1daa44
--- /dev/null
+++ b/src/quick/util/qquickstate_p.h
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTATE_H
+#define QQUICKSTATE_H
+
+#include <qqml.h>
+#include <qqmlproperty.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qsharedpointer.h>
+#include <private/qtquickglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickActionEvent;
+class QQmlAbstractBinding;
+class QQmlBinding;
+class QQmlExpression;
+class Q_QUICK_PRIVATE_EXPORT QQuickAction
+{
+public:
+ QQuickAction();
+ QQuickAction(QObject *, const QString &, const QVariant &);
+ QQuickAction(QObject *, const QString &,
+ QQmlContext *, const QVariant &);
+
+ bool restore:1;
+ bool actionDone:1;
+ bool reverseEvent:1;
+ bool deletableToBinding:1;
+
+ QQmlProperty property;
+ QVariant fromValue;
+ QVariant toValue;
+
+ QQmlAbstractBinding *fromBinding;
+ QWeakPointer<QQmlAbstractBinding> toBinding;
+ QQuickActionEvent *event;
+
+ //strictly for matching
+ QObject *specifiedObject;
+ QString specifiedProperty;
+
+ void deleteFromBinding();
+};
+
+class Q_AUTOTEST_EXPORT QQuickActionEvent
+{
+public:
+ virtual ~QQuickActionEvent();
+
+ enum EventType { Script, SignalHandler, ParentChange, AnchorChanges };
+ enum Reason { ActualChange, FastForward };
+
+ virtual EventType type() const = 0;
+
+ virtual void execute(Reason reason = ActualChange);
+ virtual bool isReversable();
+ virtual void reverse(Reason reason = ActualChange);
+ virtual void saveOriginals() {}
+ virtual bool needsCopy() { return false; }
+ virtual void copyOriginals(QQuickActionEvent *) {}
+
+ virtual bool isRewindable() { return isReversable(); }
+ virtual void rewind() {}
+ virtual void saveCurrentValues() {}
+ virtual void saveTargetValues() {}
+
+ virtual bool changesBindings();
+ virtual void clearBindings();
+ virtual bool override(QQuickActionEvent*other);
+};
+
+//### rename to QQuickStateChange?
+class QQuickStateGroup;
+class QQuickState;
+class QQuickStateOperationPrivate;
+class Q_QUICK_EXPORT QQuickStateOperation : public QObject
+{
+ Q_OBJECT
+public:
+ QQuickStateOperation(QObject *parent = 0)
+ : QObject(parent) {}
+ typedef QList<QQuickAction> ActionList;
+
+ virtual ActionList actions();
+
+ QQuickState *state() const;
+ void setState(QQuickState *state);
+
+protected:
+ QQuickStateOperation(QObjectPrivate &dd, QObject *parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(QQuickStateOperation)
+ Q_DISABLE_COPY(QQuickStateOperation)
+};
+
+typedef QQuickStateOperation::ActionList QQuickStateActions;
+
+class QQuickTransition;
+class QQuickStatePrivate;
+class Q_QUICK_EXPORT QQuickState : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QQmlBinding *when READ when WRITE setWhen)
+ Q_PROPERTY(QString extend READ extends WRITE setExtends)
+ Q_PROPERTY(QQmlListProperty<QQuickStateOperation> changes READ changes)
+ Q_CLASSINFO("DefaultProperty", "changes")
+ Q_CLASSINFO("DeferredPropertyNames", "changes")
+
+public:
+ QQuickState(QObject *parent=0);
+ virtual ~QQuickState();
+
+ QString name() const;
+ void setName(const QString &);
+ bool isNamed() const;
+
+ /*'when' is a QQmlBinding to limit state changes oscillation
+ due to the unpredictable order of evaluation of bound expressions*/
+ bool isWhenKnown() const;
+ QQmlBinding *when() const;
+ void setWhen(QQmlBinding *);
+
+ QString extends() const;
+ void setExtends(const QString &);
+
+ QQmlListProperty<QQuickStateOperation> changes();
+ int operationCount() const;
+ QQuickStateOperation *operationAt(int) const;
+
+ QQuickState &operator<<(QQuickStateOperation *);
+
+ void apply(QQuickTransition *, QQuickState *revert);
+ void cancel();
+
+ QQuickStateGroup *stateGroup() const;
+ void setStateGroup(QQuickStateGroup *);
+
+ bool containsPropertyInRevertList(QObject *target, const QString &name) const;
+ bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
+ bool changeBindingInRevertList(QObject *target, const QString &name, QQmlAbstractBinding *binding);
+ bool removeEntryFromRevertList(QObject *target, const QString &name);
+ void addEntryToRevertList(const QQuickAction &action);
+ void removeAllEntriesFromRevertList(QObject *target);
+ void addEntriesToRevertList(const QList<QQuickAction> &actions);
+ QVariant valueInRevertList(QObject *target, const QString &name) const;
+ QQmlAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const;
+
+ bool isStateActive() const;
+
+Q_SIGNALS:
+ void completed();
+
+private:
+ Q_DECLARE_PRIVATE(QQuickState)
+ Q_DISABLE_COPY(QQuickState)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickStateOperation)
+QML_DECLARE_TYPE(QQuickState)
+
+QT_END_HEADER
+
+#endif // QQUICKSTATE_H
diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h
new file mode 100644
index 0000000000..e1cd85a00c
--- /dev/null
+++ b/src/quick/util/qquickstate_p_p.h
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTATE_P_H
+#define QQUICKSTATE_P_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 "qquickstate_p.h"
+
+#include "qquicktransitionmanager_p_p.h"
+
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlguard_p.h>
+
+#include <private/qqmlbinding_p.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickSimpleAction
+{
+public:
+ enum State { StartState, EndState };
+ QQuickSimpleAction(const QQuickAction &a, State state = StartState)
+ {
+ m_property = a.property;
+ m_specifiedObject = a.specifiedObject;
+ m_specifiedProperty = a.specifiedProperty;
+ m_event = a.event;
+ if (state == StartState) {
+ m_value = a.fromValue;
+ if (QQmlPropertyPrivate::binding(m_property)) {
+ m_binding = QQmlAbstractBinding::getPointer(QQmlPropertyPrivate::binding(m_property));
+ }
+ m_reverseEvent = true;
+ } else {
+ m_value = a.toValue;
+ m_binding = a.toBinding;
+ m_reverseEvent = false;
+ }
+ }
+
+ ~QQuickSimpleAction()
+ {
+ }
+
+ QQuickSimpleAction(const QQuickSimpleAction &other)
+ : m_property(other.m_property),
+ m_value(other.m_value),
+ m_binding(QQmlAbstractBinding::getPointer(other.binding())),
+ m_specifiedObject(other.m_specifiedObject),
+ m_specifiedProperty(other.m_specifiedProperty),
+ m_event(other.m_event),
+ m_reverseEvent(other.m_reverseEvent)
+ {
+ }
+
+ QQuickSimpleAction &operator =(const QQuickSimpleAction &other)
+ {
+ m_property = other.m_property;
+ m_value = other.m_value;
+ m_binding = QQmlAbstractBinding::getPointer(other.binding());
+ m_specifiedObject = other.m_specifiedObject;
+ m_specifiedProperty = other.m_specifiedProperty;
+ m_event = other.m_event;
+ m_reverseEvent = other.m_reverseEvent;
+
+ return *this;
+ }
+
+ void setProperty(const QQmlProperty &property)
+ {
+ m_property = property;
+ }
+
+ const QQmlProperty &property() const
+ {
+ return m_property;
+ }
+
+ void setValue(const QVariant &value)
+ {
+ m_value = value;
+ }
+
+ const QVariant &value() const
+ {
+ return m_value;
+ }
+
+ void setBinding(QQmlAbstractBinding *binding)
+ {
+ m_binding = QQmlAbstractBinding::getPointer(binding);
+ }
+
+ QQmlAbstractBinding *binding() const
+ {
+ return m_binding.data();
+ }
+
+ QObject *specifiedObject() const
+ {
+ return m_specifiedObject;
+ }
+
+ const QString &specifiedProperty() const
+ {
+ return m_specifiedProperty;
+ }
+
+ QQuickActionEvent *event() const
+ {
+ return m_event;
+ }
+
+ bool reverseEvent() const
+ {
+ return m_reverseEvent;
+ }
+
+private:
+ QQmlProperty m_property;
+ QVariant m_value;
+ QQmlAbstractBinding::Pointer m_binding;
+ QObject *m_specifiedObject;
+ QString m_specifiedProperty;
+ QQuickActionEvent *m_event;
+ bool m_reverseEvent;
+};
+
+class QQuickRevertAction
+{
+public:
+ QQuickRevertAction() : event(0) {}
+ QQuickRevertAction(const QQmlProperty &prop) : property(prop), event(0) {}
+ QQuickRevertAction(QQuickActionEvent *e) : event(e) {}
+ QQmlProperty property;
+ QQuickActionEvent *event;
+};
+
+class QQuickStateOperationPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickStateOperation)
+
+public:
+
+ QQuickStateOperationPrivate()
+ : m_state(0) {}
+
+ QQuickState *m_state;
+};
+
+class QQuickStatePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickState)
+
+public:
+ QQuickStatePrivate()
+ : when(0), named(false), inState(false), group(0) {}
+
+ typedef QList<QQuickSimpleAction> SimpleActionList;
+
+ QString name;
+ QQmlBinding *when;
+ bool named;
+
+ struct OperationGuard : public QQmlGuard<QQuickStateOperation>
+ {
+ OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) {
+ setObject(static_cast<QQuickStateOperation *>(obj));
+ }
+ QList<OperationGuard> *list;
+ void objectDestroyed(QQuickStateOperation *) {
+ // we assume priv will always be destroyed after objectDestroyed calls
+ list->removeOne(*this);
+ }
+ };
+ QList<OperationGuard> operations;
+
+ static void operations_append(QQmlListProperty<QQuickStateOperation> *prop, QQuickStateOperation *op) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ op->setState(qobject_cast<QQuickState*>(prop->object));
+ list->append(OperationGuard(op, list));
+ }
+ static void operations_clear(QQmlListProperty<QQuickStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ QMutableListIterator<OperationGuard> listIterator(*list);
+ while(listIterator.hasNext())
+ listIterator.next()->setState(0);
+ list->clear();
+ }
+ static int operations_count(QQmlListProperty<QQuickStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ return list->count();
+ }
+ static QQuickStateOperation *operations_at(QQmlListProperty<QQuickStateOperation> *prop, int index) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ return list->at(index);
+ }
+
+ QQuickTransitionManager transitionManager;
+
+ SimpleActionList revertList;
+ QList<QQuickRevertAction> reverting;
+ QString extends;
+ mutable bool inState;
+ QQuickStateGroup *group;
+
+ QQuickStateOperation::ActionList generateActionList() const;
+ void complete();
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSTATE_P_H
diff --git a/src/quick/util/qquickstatechangescript.cpp b/src/quick/util/qquickstatechangescript.cpp
new file mode 100644
index 0000000000..4dedbcc920
--- /dev/null
+++ b/src/quick/util/qquickstatechangescript.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickstatechangescript_p.h"
+
+#include <qqml.h>
+#include <qqmlcontext.h>
+#include <qqmlexpression.h>
+#include <qqmlinfo.h>
+#include <private/qqmlguard_p.h>
+#include <private/qqmlcontext_p.h>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlbinding_p.h>
+#include "qquickstate_p_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickStateChangeScriptPrivate : public QQuickStateOperationPrivate
+{
+public:
+ QQuickStateChangeScriptPrivate() {}
+
+ QQmlScriptString script;
+ QString name;
+};
+
+/*!
+ \qmlclass StateChangeScript QQuickStateChangeScript
+ \inqmlmodule QtQuick 2
+ \ingroup qml-state-elements
+ \brief The StateChangeScript element allows you to run a script in a state.
+
+ A StateChangeScript is run upon entering a state. You can optionally use
+ ScriptAction to specify the point in the transition at which
+ the StateChangeScript should to be run.
+
+ \snippet snippets/declarative/states/statechangescript.qml state and transition
+
+ \sa ScriptAction
+*/
+
+QQuickStateChangeScript::QQuickStateChangeScript(QObject *parent)
+: QQuickStateOperation(*(new QQuickStateChangeScriptPrivate), parent)
+{
+}
+
+QQuickStateChangeScript::~QQuickStateChangeScript()
+{
+}
+
+/*!
+ \qmlproperty script QtQuick2::StateChangeScript::script
+ This property holds the script to run when the state is current.
+*/
+QQmlScriptString QQuickStateChangeScript::script() const
+{
+ Q_D(const QQuickStateChangeScript);
+ return d->script;
+}
+
+void QQuickStateChangeScript::setScript(const QQmlScriptString &s)
+{
+ Q_D(QQuickStateChangeScript);
+ d->script = s;
+}
+
+/*!
+ \qmlproperty string QtQuick2::StateChangeScript::name
+ This property holds the name of the script. This name can be used by a
+ ScriptAction to target a specific script.
+
+ \sa ScriptAction::scriptName
+*/
+QString QQuickStateChangeScript::name() const
+{
+ Q_D(const QQuickStateChangeScript);
+ return d->name;
+}
+
+void QQuickStateChangeScript::setName(const QString &n)
+{
+ Q_D(QQuickStateChangeScript);
+ d->name = n;
+}
+
+void QQuickStateChangeScript::execute(Reason)
+{
+ Q_D(QQuickStateChangeScript);
+ if (!d->script.script().isEmpty()) {
+ QQmlExpression expr(d->script);
+ expr.evaluate();
+ if (expr.hasError())
+ qmlInfo(this, expr.error());
+ }
+}
+
+QQuickStateChangeScript::ActionList QQuickStateChangeScript::actions()
+{
+ ActionList rv;
+ QQuickAction a;
+ a.event = this;
+ rv << a;
+ return rv;
+}
+
+QQuickActionEvent::EventType QQuickStateChangeScript::type() const
+{
+ return Script;
+}
+
+
+#include <moc_qquickstatechangescript_p.cpp>
+
+QT_END_NAMESPACE
+
diff --git a/src/quick/util/qquickstatechangescript_p.h b/src/quick/util/qquickstatechangescript_p.h
new file mode 100644
index 0000000000..444657d245
--- /dev/null
+++ b/src/quick/util/qquickstatechangescript_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTATEOPERATIONS_H
+#define QQUICKSTATEOPERATIONS_H
+
+#include "qquickstate_p.h"
+#include <qqmlscriptstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickStateChangeScriptPrivate;
+class Q_AUTOTEST_EXPORT QQuickStateChangeScript : public QQuickStateOperation, public QQuickActionEvent
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickStateChangeScript)
+
+ Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+public:
+ QQuickStateChangeScript(QObject *parent=0);
+ ~QQuickStateChangeScript();
+
+ virtual ActionList actions();
+
+ virtual EventType type() const;
+
+ QQmlScriptString script() const;
+ void setScript(const QQmlScriptString &);
+
+ QString name() const;
+ void setName(const QString &);
+
+ virtual void execute(Reason reason = ActualChange);
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickStateChangeScript)
+
+QT_END_HEADER
+
+#endif // QQUICKSTATEOPERATIONS_H
diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp
new file mode 100644
index 0000000000..3a3192716e
--- /dev/null
+++ b/src/quick/util/qquickstategroup.cpp
@@ -0,0 +1,516 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickstategroup_p.h"
+
+#include "qquicktransition_p.h"
+
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlglobal_p.h>
+
+#include <QtCore/qstringbuilder.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+#include <qqmlinfo.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
+
+class QQuickStateGroupPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickStateGroup)
+public:
+ QQuickStateGroupPrivate()
+ : nullState(0), componentComplete(true),
+ ignoreTrans(false), applyingState(false), unnamedCount(0) {}
+
+ QString currentState;
+ QQuickState *nullState;
+
+ static void append_state(QQmlListProperty<QQuickState> *list, QQuickState *state);
+ static int count_state(QQmlListProperty<QQuickState> *list);
+ static QQuickState *at_state(QQmlListProperty<QQuickState> *list, int index);
+ static void clear_states(QQmlListProperty<QQuickState> *list);
+
+ static void append_transition(QQmlListProperty<QQuickTransition> *list, QQuickTransition *state);
+ static int count_transitions(QQmlListProperty<QQuickTransition> *list);
+ static QQuickTransition *at_transition(QQmlListProperty<QQuickTransition> *list, int index);
+ static void clear_transitions(QQmlListProperty<QQuickTransition> *list);
+
+ QList<QQuickState *> states;
+ QList<QQuickTransition *> transitions;
+
+ bool componentComplete;
+ bool ignoreTrans;
+ bool applyingState;
+ int unnamedCount;
+
+ QQuickTransition *findTransition(const QString &from, const QString &to);
+ void setCurrentStateInternal(const QString &state, bool = false);
+ bool updateAutoState();
+};
+
+/*!
+ \qmlclass StateGroup QQuickStateGroup
+ \inqmlmodule QtQuick 2
+ \ingroup qml-state-elements
+ \brief The StateGroup element provides state support for non-Item elements.
+
+ Item (and all derived elements) provides built in support for states and transitions
+ via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to
+ use this support in other (non-Item-derived) elements.
+
+ \qml
+ MyCustomObject {
+ StateGroup {
+ id: myStateGroup
+ states: State {
+ name: "state1"
+ // ...
+ }
+ transitions: Transition {
+ // ...
+ }
+ }
+
+ onSomethingHappened: myStateGroup.state = "state1";
+ }
+ \endqml
+
+ \sa {qmlstate}{States} {QML Animation and Transitions}{Transitions}, {QtQml}
+*/
+
+QQuickStateGroup::QQuickStateGroup(QObject *parent)
+ : QObject(*(new QQuickStateGroupPrivate), parent)
+{
+}
+
+QQuickStateGroup::~QQuickStateGroup()
+{
+ Q_D(const QQuickStateGroup);
+ for (int i = 0; i < d->states.count(); ++i)
+ d->states.at(i)->setStateGroup(0);
+}
+
+QList<QQuickState *> QQuickStateGroup::states() const
+{
+ Q_D(const QQuickStateGroup);
+ return d->states;
+}
+
+/*!
+ \qmlproperty list<State> QtQuick2::StateGroup::states
+ This property holds a list of states defined by the state group.
+
+ \qml
+ StateGroup {
+ states: [
+ State {
+ // State definition...
+ },
+ State {
+ // ...
+ }
+ // Other states...
+ ]
+ }
+ \endqml
+
+ \sa {qmlstate}{States}
+*/
+QQmlListProperty<QQuickState> QQuickStateGroup::statesProperty()
+{
+ Q_D(QQuickStateGroup);
+ return QQmlListProperty<QQuickState>(this, &d->states, &QQuickStateGroupPrivate::append_state,
+ &QQuickStateGroupPrivate::count_state,
+ &QQuickStateGroupPrivate::at_state,
+ &QQuickStateGroupPrivate::clear_states);
+}
+
+void QQuickStateGroupPrivate::append_state(QQmlListProperty<QQuickState> *list, QQuickState *state)
+{
+ QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
+ if (state) {
+ _this->d_func()->states.append(state);
+ state->setStateGroup(_this);
+ }
+
+}
+
+int QQuickStateGroupPrivate::count_state(QQmlListProperty<QQuickState> *list)
+{
+ QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
+ return _this->d_func()->states.count();
+}
+
+QQuickState *QQuickStateGroupPrivate::at_state(QQmlListProperty<QQuickState> *list, int index)
+{
+ QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
+ return _this->d_func()->states.at(index);
+}
+
+void QQuickStateGroupPrivate::clear_states(QQmlListProperty<QQuickState> *list)
+{
+ QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
+ _this->d_func()->setCurrentStateInternal(QString(), true);
+ for (int i = 0; i < _this->d_func()->states.count(); ++i) {
+ _this->d_func()->states.at(i)->setStateGroup(0);
+ }
+ _this->d_func()->states.clear();
+}
+
+/*!
+ \qmlproperty list<Transition> QtQuick2::StateGroup::transitions
+ This property holds a list of transitions defined by the state group.
+
+ \qml
+ StateGroup {
+ transitions: [
+ Transition {
+ // ...
+ },
+ Transition {
+ // ...
+ }
+ // ...
+ ]
+ }
+ \endqml
+
+ \sa {QML Animation and Transitions}{Transitions}
+*/
+QQmlListProperty<QQuickTransition> QQuickStateGroup::transitionsProperty()
+{
+ Q_D(QQuickStateGroup);
+ return QQmlListProperty<QQuickTransition>(this, &d->transitions, &QQuickStateGroupPrivate::append_transition,
+ &QQuickStateGroupPrivate::count_transitions,
+ &QQuickStateGroupPrivate::at_transition,
+ &QQuickStateGroupPrivate::clear_transitions);
+}
+
+void QQuickStateGroupPrivate::append_transition(QQmlListProperty<QQuickTransition> *list, QQuickTransition *trans)
+{
+ QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
+ if (trans)
+ _this->d_func()->transitions.append(trans);
+}
+
+int QQuickStateGroupPrivate::count_transitions(QQmlListProperty<QQuickTransition> *list)
+{
+ QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
+ return _this->d_func()->transitions.count();
+}
+
+QQuickTransition *QQuickStateGroupPrivate::at_transition(QQmlListProperty<QQuickTransition> *list, int index)
+{
+ QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
+ return _this->d_func()->transitions.at(index);
+}
+
+void QQuickStateGroupPrivate::clear_transitions(QQmlListProperty<QQuickTransition> *list)
+{
+ QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
+ _this->d_func()->transitions.clear();
+}
+
+/*!
+ \qmlproperty string QtQuick2::StateGroup::state
+
+ This property holds the name of the current state of the state group.
+
+ This property is often used in scripts to change between states. For
+ example:
+
+ \js
+ function toggle() {
+ if (button.state == 'On')
+ button.state = 'Off';
+ else
+ button.state = 'On';
+ }
+ \endjs
+
+ If the state group is in its base state (i.e. no explicit state has been
+ set), \c state will be a blank string. Likewise, you can return a
+ state group to its base state by setting its current state to \c ''.
+
+ \sa {qmlstates}{States}
+*/
+QString QQuickStateGroup::state() const
+{
+ Q_D(const QQuickStateGroup);
+ return d->currentState;
+}
+
+void QQuickStateGroup::setState(const QString &state)
+{
+ Q_D(QQuickStateGroup);
+ if (d->currentState == state)
+ return;
+
+ d->setCurrentStateInternal(state);
+}
+
+void QQuickStateGroup::classBegin()
+{
+ Q_D(QQuickStateGroup);
+ d->componentComplete = false;
+}
+
+void QQuickStateGroup::componentComplete()
+{
+ Q_D(QQuickStateGroup);
+ d->componentComplete = true;
+
+ for (int ii = 0; ii < d->states.count(); ++ii) {
+ QQuickState *state = d->states.at(ii);
+ if (!state->isNamed())
+ state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount));
+ }
+
+ if (d->updateAutoState()) {
+ return;
+ } else if (!d->currentState.isEmpty()) {
+ QString cs = d->currentState;
+ d->currentState.clear();
+ d->setCurrentStateInternal(cs, true);
+ }
+}
+
+/*!
+ Returns true if the state was changed, otherwise false.
+*/
+bool QQuickStateGroup::updateAutoState()
+{
+ Q_D(QQuickStateGroup);
+ return d->updateAutoState();
+}
+
+bool QQuickStateGroupPrivate::updateAutoState()
+{
+ Q_Q(QQuickStateGroup);
+ if (!componentComplete)
+ return false;
+
+ bool revert = false;
+ for (int ii = 0; ii < states.count(); ++ii) {
+ QQuickState *state = states.at(ii);
+ if (state->isWhenKnown()) {
+ if (state->isNamed()) {
+ if (state->when() && state->when()->evaluate().toBool()) {
+ if (stateChangeDebug())
+ qWarning() << "Setting auto state due to:"
+ << state->when()->expression();
+ if (currentState != state->name()) {
+ q->setState(state->name());
+ return true;
+ } else {
+ return false;
+ }
+ } else if (state->name() == currentState) {
+ revert = true;
+ }
+ }
+ }
+ }
+ if (revert) {
+ bool rv = !currentState.isEmpty();
+ q->setState(QString());
+ return rv;
+ } else {
+ return false;
+ }
+}
+
+QQuickTransition *QQuickStateGroupPrivate::findTransition(const QString &from, const QString &to)
+{
+ QQuickTransition *highest = 0;
+ int score = 0;
+ bool reversed = false;
+ bool done = false;
+
+ for (int ii = 0; !done && ii < transitions.count(); ++ii) {
+ QQuickTransition *t = transitions.at(ii);
+ if (!t->enabled())
+ continue;
+ for (int ii = 0; ii < 2; ++ii)
+ {
+ if (ii && (!t->reversible() ||
+ (t->fromState() == QLatin1String("*") &&
+ t->toState() == QLatin1String("*"))))
+ break;
+ QStringList fromState;
+ QStringList toState;
+
+ fromState = t->fromState().split(QLatin1Char(','));
+ for (int jj = 0; jj < fromState.count(); ++jj)
+ fromState[jj] = fromState.at(jj).trimmed();
+ toState = t->toState().split(QLatin1Char(','));
+ for (int jj = 0; jj < toState.count(); ++jj)
+ toState[jj] = toState.at(jj).trimmed();
+ if (ii == 1)
+ qSwap(fromState, toState);
+ int tScore = 0;
+ if (fromState.contains(from))
+ tScore += 2;
+ else if (fromState.contains(QLatin1String("*")))
+ tScore += 1;
+ else
+ continue;
+
+ if (toState.contains(to))
+ tScore += 2;
+ else if (toState.contains(QLatin1String("*")))
+ tScore += 1;
+ else
+ continue;
+
+ if (ii == 1)
+ reversed = true;
+ else
+ reversed = false;
+
+ if (tScore == 4) {
+ highest = t;
+ done = true;
+ break;
+ } else if (tScore > score) {
+ score = tScore;
+ highest = t;
+ }
+ }
+ }
+
+ if (highest)
+ highest->setReversed(reversed);
+
+ return highest;
+}
+
+void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state,
+ bool ignoreTrans)
+{
+ Q_Q(QQuickStateGroup);
+ if (!componentComplete) {
+ currentState = state;
+ return;
+ }
+
+ if (applyingState) {
+ qmlInfo(q) << "Can't apply a state change as part of a state definition.";
+ return;
+ }
+
+ applyingState = true;
+
+ QQuickTransition *transition = ignoreTrans ? 0 : findTransition(currentState, state);
+ if (stateChangeDebug()) {
+ qWarning() << this << "Changing state. From" << currentState << ". To" << state;
+ if (transition)
+ qWarning() << " using transition" << transition->fromState()
+ << transition->toState();
+ }
+
+ QQuickState *oldState = 0;
+ if (!currentState.isEmpty()) {
+ for (int ii = 0; ii < states.count(); ++ii) {
+ if (states.at(ii)->name() == currentState) {
+ oldState = states.at(ii);
+ break;
+ }
+ }
+ }
+
+ currentState = state;
+ emit q->stateChanged(currentState);
+
+ QQuickState *newState = 0;
+ for (int ii = 0; ii < states.count(); ++ii) {
+ if (states.at(ii)->name() == currentState) {
+ newState = states.at(ii);
+ break;
+ }
+ }
+
+ if (oldState == 0 || newState == 0) {
+ if (!nullState) {
+ nullState = new QQuickState;
+ QQml_setParent_noEvent(nullState, q);
+ nullState->setStateGroup(q);
+ }
+ if (!oldState) oldState = nullState;
+ if (!newState) newState = nullState;
+ }
+
+ newState->apply(transition, oldState);
+ applyingState = false; //### consider removing this (don't allow state changes in transition)
+}
+
+QQuickState *QQuickStateGroup::findState(const QString &name) const
+{
+ Q_D(const QQuickStateGroup);
+ for (int i = 0; i < d->states.count(); ++i) {
+ QQuickState *state = d->states.at(i);
+ if (state->name() == name)
+ return state;
+ }
+
+ return 0;
+}
+
+void QQuickStateGroup::removeState(QQuickState *state)
+{
+ Q_D(QQuickStateGroup);
+ d->states.removeOne(state);
+}
+
+void QQuickStateGroup::stateAboutToComplete()
+{
+ Q_D(QQuickStateGroup);
+ d->applyingState = false;
+}
+
+QT_END_NAMESPACE
+
+
diff --git a/src/quick/util/qquickstategroup_p.h b/src/quick/util/qquickstategroup_p.h
new file mode 100644
index 0000000000..07e3c0505a
--- /dev/null
+++ b/src/quick/util/qquickstategroup_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTATEGROUP_H
+#define QQUICKSTATEGROUP_H
+
+#include "qquickstate_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickStateGroupPrivate;
+class Q_QUICK_EXPORT QQuickStateGroup : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_DECLARE_PRIVATE(QQuickStateGroup)
+
+ Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
+ Q_PROPERTY(QQmlListProperty<QQuickState> states READ statesProperty DESIGNABLE false)
+ Q_PROPERTY(QQmlListProperty<QQuickTransition> transitions READ transitionsProperty DESIGNABLE false)
+
+public:
+ QQuickStateGroup(QObject * = 0);
+ virtual ~QQuickStateGroup();
+
+ QString state() const;
+ void setState(const QString &);
+
+ QQmlListProperty<QQuickState> statesProperty();
+ QList<QQuickState *> states() const;
+
+ QQmlListProperty<QQuickTransition> transitionsProperty();
+
+ QQuickState *findState(const QString &name) const;
+ void removeState(QQuickState *state);
+
+ virtual void classBegin();
+ virtual void componentComplete();
+Q_SIGNALS:
+ void stateChanged(const QString &);
+
+private:
+ friend class QQuickState;
+ friend class QQuickStatePrivate;
+ bool updateAutoState();
+ void stateAboutToComplete();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickStateGroup)
+
+QT_END_HEADER
+
+#endif // QQUICKSTATEGROUP_H
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
new file mode 100644
index 0000000000..8462166dec
--- /dev/null
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -0,0 +1,815 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QStack>
+#include <QVector>
+#include <QPainter>
+#include <QTextLayout>
+#include <QDebug>
+#include <qmath.h>
+#include "qquickstyledtext_p.h"
+#include <QQmlContext>
+
+/*
+ QQuickStyledText supports few tags:
+
+ <b></b> - bold
+ <strong></strong> - bold
+ <i></i> - italic
+ <br> - new line
+ <p> - paragraph
+ <u> - underlined text
+ <font color="color_name" size="1-7"></font>
+ <h1> to <h6> - headers
+ <a href=""> - anchor
+ <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+ <pre></pre> - preformated
+ <img src=""> - images
+
+ The opening and closing tags must be correctly nested.
+*/
+
+QT_BEGIN_NAMESPACE
+
+Q_GUI_EXPORT int qt_defaultDpi();
+
+class QQuickStyledTextPrivate
+{
+public:
+ enum ListType { Ordered, Unordered };
+ enum ListFormat { Bullet, Disc, Square, Decimal, LowerAlpha, UpperAlpha, LowerRoman, UpperRoman };
+
+ struct List {
+ int level;
+ ListType type;
+ ListFormat format;
+ };
+
+ QQuickStyledTextPrivate(const QString &t, QTextLayout &l,
+ QList<QQuickStyledTextImgTag*> &imgTags,
+ const QUrl &baseUrl,
+ QQmlContext *context,
+ bool preloadImages,
+ bool *fontSizeModified)
+ : text(t), layout(l), imgTags(&imgTags), baseFont(layout.font()), baseUrl(baseUrl), hasNewLine(false), nbImages(0), updateImagePositions(false)
+ , preFormat(false), prependSpace(false), hasSpace(true), preloadImages(preloadImages), fontSizeModified(fontSizeModified), context(context)
+ {
+ }
+
+ void parse();
+ void appendText(const QString &textIn, int start, int length, QString &textOut);
+ bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format);
+ bool parseCloseTag(const QChar *&ch, const QString &textIn, QString &textOut);
+ void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut);
+ bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
+ bool parseOrderedListAttributes(const QChar *&ch, const QString &textIn);
+ bool parseUnorderedListAttributes(const QChar *&ch, const QString &textIn);
+ bool parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
+ void parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut);
+ QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn);
+ QStringRef parseValue(const QChar *&ch, const QString &textIn);
+ void setFontSize(int size, QTextCharFormat &format);
+
+ inline void skipSpace(const QChar *&ch) {
+ while (ch->isSpace() && !ch->isNull())
+ ++ch;
+ }
+
+ static QString toAlpha(int value, bool upper);
+ static QString toRoman(int value, bool upper);
+
+ QString text;
+ QTextLayout &layout;
+ QList<QQuickStyledTextImgTag*> *imgTags;
+ QFont baseFont;
+ QStack<List> listStack;
+ QUrl baseUrl;
+ bool hasNewLine;
+ int nbImages;
+ bool updateImagePositions;
+ bool preFormat;
+ bool prependSpace;
+ bool hasSpace;
+ bool preloadImages;
+ bool *fontSizeModified;
+ QQmlContext *context;
+
+ static const QChar lessThan;
+ static const QChar greaterThan;
+ static const QChar equals;
+ static const QChar singleQuote;
+ static const QChar doubleQuote;
+ static const QChar slash;
+ static const QChar ampersand;
+ static const QChar bullet;
+ static const QChar disc;
+ static const QChar square;
+ static const QChar lineFeed;
+ static const QChar space;
+ static const int tabsize = 6;
+};
+
+const QChar QQuickStyledTextPrivate::lessThan(QLatin1Char('<'));
+const QChar QQuickStyledTextPrivate::greaterThan(QLatin1Char('>'));
+const QChar QQuickStyledTextPrivate::equals(QLatin1Char('='));
+const QChar QQuickStyledTextPrivate::singleQuote(QLatin1Char('\''));
+const QChar QQuickStyledTextPrivate::doubleQuote(QLatin1Char('\"'));
+const QChar QQuickStyledTextPrivate::slash(QLatin1Char('/'));
+const QChar QQuickStyledTextPrivate::ampersand(QLatin1Char('&'));
+const QChar QQuickStyledTextPrivate::bullet(0x2022);
+const QChar QQuickStyledTextPrivate::disc(0x25e6);
+const QChar QQuickStyledTextPrivate::square(0x25a1);
+const QChar QQuickStyledTextPrivate::lineFeed(QLatin1Char('\n'));
+const QChar QQuickStyledTextPrivate::space(QLatin1Char(' '));
+
+QQuickStyledText::QQuickStyledText(const QString &string, QTextLayout &layout,
+ QList<QQuickStyledTextImgTag*> &imgTags,
+ const QUrl &baseUrl,
+ QQmlContext *context,
+ bool preloadImages,
+ bool *fontSizeModified)
+ : d(new QQuickStyledTextPrivate(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified))
+{
+}
+
+QQuickStyledText::~QQuickStyledText()
+{
+ delete d;
+}
+
+void QQuickStyledText::parse(const QString &string, QTextLayout &layout,
+ QList<QQuickStyledTextImgTag*> &imgTags,
+ const QUrl &baseUrl,
+ QQmlContext *context,
+ bool preloadImages,
+ bool *fontSizeModified)
+{
+ if (string.isEmpty())
+ return;
+ QQuickStyledText styledText(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified);
+ styledText.d->parse();
+}
+
+void QQuickStyledTextPrivate::parse()
+{
+ QList<QTextLayout::FormatRange> ranges;
+ QStack<QTextCharFormat> formatStack;
+
+ QString drawText;
+ drawText.reserve(text.count());
+
+ updateImagePositions = !imgTags->isEmpty();
+
+ int textStart = 0;
+ int textLength = 0;
+ int rangeStart = 0;
+ bool formatChanged = false;
+
+ const QChar *ch = text.constData();
+ while (!ch->isNull()) {
+ if (*ch == lessThan) {
+ if (textLength) {
+ appendText(text, textStart, textLength, drawText);
+ } else if (prependSpace) {
+ drawText.append(space);
+ prependSpace = false;
+ hasSpace = true;
+ }
+
+ if (rangeStart != drawText.length() && formatStack.count()) {
+ if (formatChanged) {
+ QTextLayout::FormatRange formatRange;
+ formatRange.format = formatStack.top();
+ formatRange.start = rangeStart;
+ formatRange.length = drawText.length() - rangeStart;
+ ranges.append(formatRange);
+ formatChanged = false;
+ } else if (ranges.count()) {
+ ranges.last().length += drawText.length() - rangeStart;
+ }
+ }
+ rangeStart = drawText.length();
+ ++ch;
+ if (*ch == slash) {
+ ++ch;
+ if (parseCloseTag(ch, text, drawText)) {
+ if (formatStack.count()) {
+ formatChanged = true;
+ formatStack.pop();
+ }
+ }
+ } else {
+ QTextCharFormat format;
+ if (formatStack.count())
+ format = formatStack.top();
+ if (parseTag(ch, text, drawText, format)) {
+ formatChanged = true;
+ formatStack.push(format);
+ }
+ }
+ textStart = ch - text.constData() + 1;
+ textLength = 0;
+ } else if (*ch == ampersand) {
+ ++ch;
+ appendText(text, textStart, textLength, drawText);
+ parseEntity(ch, text, drawText);
+ textStart = ch - text.constData() + 1;
+ textLength = 0;
+ } else if (ch->isSpace()) {
+ if (textLength)
+ appendText(text, textStart, textLength, drawText);
+ if (!preFormat) {
+ prependSpace = !hasSpace;
+ for (const QChar *n = ch + 1; !n->isNull() && n->isSpace(); ++n)
+ ch = n;
+ hasNewLine = false;
+ } else if (*ch == lineFeed) {
+ drawText.append(QChar(QChar::LineSeparator));
+ hasNewLine = true;
+ } else {
+ drawText.append(QChar(QChar::Nbsp));
+ hasNewLine = false;
+ }
+ textStart = ch - text.constData() + 1;
+ textLength = 0;
+ } else {
+ ++textLength;
+ }
+ if (!ch->isNull())
+ ++ch;
+ }
+ if (textLength)
+ appendText(text, textStart, textLength, drawText);
+ if (rangeStart != drawText.length() && formatStack.count()) {
+ if (formatChanged) {
+ QTextLayout::FormatRange formatRange;
+ formatRange.format = formatStack.top();
+ formatRange.start = rangeStart;
+ formatRange.length = drawText.length() - rangeStart;
+ ranges.append(formatRange);
+ } else if (ranges.count()) {
+ ranges.last().length += drawText.length() - rangeStart;
+ }
+ }
+
+ layout.setText(drawText);
+ layout.setAdditionalFormats(ranges);
+}
+
+void QQuickStyledTextPrivate::appendText(const QString &textIn, int start, int length, QString &textOut)
+{
+ if (prependSpace)
+ textOut.append(space);
+ textOut.append(QStringRef(&textIn, start, length));
+ prependSpace = false;
+ hasSpace = false;
+ hasNewLine = false;
+}
+
+//
+// Calculates and sets the correct font size in points
+// depending on the size multiplier and base font.
+//
+void QQuickStyledTextPrivate::setFontSize(int size, QTextCharFormat &format)
+{
+ static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 };
+ if (baseFont.pointSizeF() != -1)
+ format.setFontPointSize(baseFont.pointSize() * scaling[size - 1]);
+ else
+ format.setFontPointSize(baseFont.pixelSize() * qreal(72.) / qreal(qt_defaultDpi()) * scaling[size - 1]);
+ *fontSizeModified = true;
+}
+
+bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format)
+{
+ skipSpace(ch);
+
+ int tagStart = ch - textIn.constData();
+ int tagLength = 0;
+ while (!ch->isNull()) {
+ if (*ch == greaterThan) {
+ if (tagLength == 0)
+ return false;
+ QStringRef tag(&textIn, tagStart, tagLength);
+ const QChar char0 = tag.at(0);
+ if (char0 == QLatin1Char('b')) {
+ if (tagLength == 1) {
+ format.setFontWeight(QFont::Bold);
+ return true;
+ } else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) {
+ textOut.append(QChar(QChar::LineSeparator));
+ hasSpace = true;
+ prependSpace = false;
+ return false;
+ }
+ } else if (char0 == QLatin1Char('i')) {
+ if (tagLength == 1) {
+ format.setFontItalic(true);
+ return true;
+ }
+ } else if (char0 == QLatin1Char('p')) {
+ if (tagLength == 1) {
+ if (!hasNewLine)
+ textOut.append(QChar::LineSeparator);
+ hasSpace = true;
+ prependSpace = false;
+ } else if (tag == QLatin1String("pre")) {
+ preFormat = true;
+ if (!hasNewLine)
+ textOut.append(QChar::LineSeparator);
+ format.setFontFamily(QString::fromLatin1("Courier New,courier"));
+ format.setFontFixedPitch(true);
+ return true;
+ }
+ } else if (char0 == QLatin1Char('u')) {
+ if (tagLength == 1) {
+ format.setFontUnderline(true);
+ return true;
+ } else if (tag == QLatin1String("ul")) {
+ List listItem;
+ listItem.level = 0;
+ listItem.type = Unordered;
+ listItem.format = Bullet;
+ listStack.push(listItem);
+ }
+ } else if (char0 == QLatin1Char('h') && tagLength == 2) {
+ int level = tag.at(1).digitValue();
+ if (level >= 1 && level <= 6) {
+ if (!hasNewLine)
+ textOut.append(QChar::LineSeparator);
+ hasSpace = true;
+ prependSpace = false;
+ setFontSize(7 - level, format);
+ format.setFontWeight(QFont::Bold);
+ return true;
+ }
+ } else if (tag == QLatin1String("strong")) {
+ format.setFontWeight(QFont::Bold);
+ return true;
+ } else if (tag == QLatin1String("ol")) {
+ List listItem;
+ listItem.level = 0;
+ listItem.type = Ordered;
+ listItem.format = Decimal;
+ listStack.push(listItem);
+ } else if (tag == QLatin1String("li")) {
+ if (!hasNewLine)
+ textOut.append(QChar(QChar::LineSeparator));
+ if (!listStack.isEmpty()) {
+ int count = ++listStack.top().level;
+ for (int i = 0; i < listStack.size(); ++i)
+ textOut += QString(tabsize, QChar::Nbsp);
+ switch (listStack.top().format) {
+ case Decimal:
+ textOut += QString::number(count) % QLatin1Char('.');
+ break;
+ case LowerAlpha:
+ textOut += toAlpha(count, false) % QLatin1Char('.');
+ break;
+ case UpperAlpha:
+ textOut += toAlpha(count, true) % QLatin1Char('.');
+ break;
+ case LowerRoman:
+ textOut += toRoman(count, false) % QLatin1Char('.');
+ break;
+ case UpperRoman:
+ textOut += toRoman(count, true) % QLatin1Char('.');
+ break;
+ case Bullet:
+ textOut += bullet;
+ break;
+ case Disc:
+ textOut += disc;
+ break;
+ case Square:
+ textOut += square;
+ break;
+ }
+ textOut += QString(2, QChar::Nbsp);
+ }
+ }
+ return false;
+ } else if (ch->isSpace()) {
+ // may have params.
+ QStringRef tag(&textIn, tagStart, tagLength);
+ if (tag == QLatin1String("font"))
+ return parseFontAttributes(ch, textIn, format);
+ if (tag == QLatin1String("ol")) {
+ parseOrderedListAttributes(ch, textIn);
+ return false; // doesn't modify format
+ }
+ if (tag == QLatin1String("ul")) {
+ parseUnorderedListAttributes(ch, textIn);
+ return false; // doesn't modify format
+ }
+ if (tag == QLatin1String("a")) {
+ return parseAnchorAttributes(ch, textIn, format);
+ }
+ if (tag == QLatin1String("img")) {
+ parseImageAttributes(ch, textIn, textOut);
+ return false;
+ }
+ if (*ch == greaterThan || ch->isNull())
+ continue;
+ } else if (*ch != slash) {
+ tagLength++;
+ }
+ ++ch;
+ }
+ return false;
+}
+
+bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn, QString &textOut)
+{
+ skipSpace(ch);
+
+ int tagStart = ch - textIn.constData();
+ int tagLength = 0;
+ while (!ch->isNull()) {
+ if (*ch == greaterThan) {
+ if (tagLength == 0)
+ return false;
+ QStringRef tag(&textIn, tagStart, tagLength);
+ const QChar char0 = tag.at(0);
+ hasNewLine = false;
+ if (char0 == QLatin1Char('b')) {
+ if (tagLength == 1)
+ return true;
+ else if (tag.at(1) == QLatin1Char('r') && tagLength == 2)
+ return false;
+ } else if (char0 == QLatin1Char('i')) {
+ if (tagLength == 1)
+ return true;
+ } else if (char0 == QLatin1Char('a')) {
+ if (tagLength == 1)
+ return true;
+ } else if (char0 == QLatin1Char('p')) {
+ if (tagLength == 1) {
+ textOut.append(QChar::LineSeparator);
+ hasNewLine = true;
+ hasSpace = true;
+ return false;
+ } else if (tag == QLatin1String("pre")) {
+ preFormat = false;
+ if (!hasNewLine)
+ textOut.append(QChar::LineSeparator);
+ hasNewLine = true;
+ hasSpace = true;
+ return true;
+ }
+ } else if (char0 == QLatin1Char('u')) {
+ if (tagLength == 1)
+ return true;
+ else if (tag == QLatin1String("ul")) {
+ if (!listStack.isEmpty()) {
+ listStack.pop();
+ if (!listStack.count())
+ textOut.append(QChar::LineSeparator);
+ }
+ return false;
+ }
+ } else if (char0 == QLatin1Char('h') && tagLength == 2) {
+ textOut.append(QChar::LineSeparator);
+ hasNewLine = true;
+ hasSpace = true;
+ return true;
+ } else if (tag == QLatin1String("font")) {
+ return true;
+ } else if (tag == QLatin1String("strong")) {
+ return true;
+ } else if (tag == QLatin1String("ol")) {
+ if (!listStack.isEmpty()) {
+ listStack.pop();
+ if (!listStack.count())
+ textOut.append(QChar::LineSeparator);
+ }
+ return false;
+ } else if (tag == QLatin1String("li")) {
+ return false;
+ }
+ return false;
+ } else if (!ch->isSpace()){
+ tagLength++;
+ }
+ ++ch;
+ }
+
+ return false;
+}
+
+void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut)
+{
+ int entityStart = ch - textIn.constData();
+ int entityLength = 0;
+ while (!ch->isNull()) {
+ if (*ch == QLatin1Char(';')) {
+ QStringRef entity(&textIn, entityStart, entityLength);
+ if (entity == QLatin1String("gt"))
+ textOut += QChar(62);
+ else if (entity == QLatin1String("lt"))
+ textOut += QChar(60);
+ else if (entity == QLatin1String("amp"))
+ textOut += QChar(38);
+ return;
+ }
+ ++entityLength;
+ ++ch;
+ }
+}
+
+bool QQuickStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
+{
+ bool valid = false;
+ QPair<QStringRef,QStringRef> attr;
+ do {
+ attr = parseAttribute(ch, textIn);
+ if (attr.first == QLatin1String("color")) {
+ valid = true;
+ format.setForeground(QColor(attr.second.toString()));
+ } else if (attr.first == QLatin1String("size")) {
+ valid = true;
+ int size = attr.second.toString().toInt();
+ if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+'))
+ size += 3;
+ if (size >= 1 && size <= 7)
+ setFontSize(size, format);
+ }
+ } while (!ch->isNull() && !attr.first.isEmpty());
+
+ return valid;
+}
+
+bool QQuickStyledTextPrivate::parseOrderedListAttributes(const QChar *&ch, const QString &textIn)
+{
+ bool valid = false;
+
+ List listItem;
+ listItem.level = 0;
+ listItem.type = Ordered;
+ listItem.format = Decimal;
+
+ QPair<QStringRef,QStringRef> attr;
+ do {
+ attr = parseAttribute(ch, textIn);
+ if (attr.first == QLatin1String("type")) {
+ valid = true;
+ if (attr.second == QLatin1String("a"))
+ listItem.format = LowerAlpha;
+ else if (attr.second == QLatin1String("A"))
+ listItem.format = UpperAlpha;
+ else if (attr.second == QLatin1String("i"))
+ listItem.format = LowerRoman;
+ else if (attr.second == QLatin1String("I"))
+ listItem.format = UpperRoman;
+ }
+ } while (!ch->isNull() && !attr.first.isEmpty());
+
+ listStack.push(listItem);
+ return valid;
+}
+
+bool QQuickStyledTextPrivate::parseUnorderedListAttributes(const QChar *&ch, const QString &textIn)
+{
+ bool valid = false;
+
+ List listItem;
+ listItem.level = 0;
+ listItem.type = Unordered;
+ listItem.format = Bullet;
+
+ QPair<QStringRef,QStringRef> attr;
+ do {
+ attr = parseAttribute(ch, textIn);
+ if (attr.first == QLatin1String("type")) {
+ valid = true;
+ if (attr.second == QLatin1String("disc"))
+ listItem.format = Disc;
+ else if (attr.second == QLatin1String("square"))
+ listItem.format = Square;
+ }
+ } while (!ch->isNull() && !attr.first.isEmpty());
+
+ listStack.push(listItem);
+ return valid;
+}
+
+bool QQuickStyledTextPrivate::parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
+{
+ bool valid = false;
+
+ QPair<QStringRef,QStringRef> attr;
+ do {
+ attr = parseAttribute(ch, textIn);
+ if (attr.first == QLatin1String("href")) {
+ format.setAnchorHref(attr.second.toString());
+ format.setAnchor(true);
+ format.setFontUnderline(true);
+ valid = true;
+ }
+ } while (!ch->isNull() && !attr.first.isEmpty());
+
+ return valid;
+}
+
+void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut)
+{
+ qreal imgWidth = 0.0;
+
+ if (!updateImagePositions) {
+ QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag;
+ image->position = textOut.length() + 1;
+
+ QPair<QStringRef,QStringRef> attr;
+ do {
+ attr = parseAttribute(ch, textIn);
+ if (attr.first == QLatin1String("src")) {
+ image->url = QUrl(attr.second.toString());
+ } else if (attr.first == QLatin1String("width")) {
+ image->size.setWidth(attr.second.toString().toInt());
+ } else if (attr.first == QLatin1String("height")) {
+ image->size.setHeight(attr.second.toString().toInt());
+ } else if (attr.first == QLatin1String("align")) {
+ if (attr.second.toString() == QLatin1String("top")) {
+ image->align = QQuickStyledTextImgTag::Top;
+ } else if (attr.second.toString() == QLatin1String("middle")) {
+ image->align = QQuickStyledTextImgTag::Middle;
+ }
+ }
+ } while (!ch->isNull() && !attr.first.isEmpty());
+
+ if (preloadImages && !image->size.isValid()) {
+ // if we don't know its size but the image is a local image,
+ // we load it in the pixmap cache and save its implicit size
+ // to avoid a relayout later on.
+ QUrl url = baseUrl.resolved(image->url);
+ if (url.isLocalFile()) {
+ QQuickPixmap *pix = new QQuickPixmap(context->engine(), url, image->size);
+ if (pix && pix->isReady()) {
+ image->size = pix->implicitSize();
+ image->pix = pix;
+ }
+ }
+ }
+
+ imgWidth = image->size.width();
+ imgTags->append(image);
+
+ } else {
+ // if we already have a list of img tags for this text
+ // we only want to update the positions of these tags.
+ QQuickStyledTextImgTag *image = imgTags->value(nbImages);
+ image->position = textOut.length() + 1;
+ imgWidth = image->size.width();
+ QPair<QStringRef,QStringRef> attr;
+ do {
+ attr = parseAttribute(ch, textIn);
+ } while (!ch->isNull() && !attr.first.isEmpty());
+ nbImages++;
+ }
+
+ QFontMetricsF fm(layout.font());
+ QString padding(qFloor(imgWidth / fm.width(QChar::Nbsp)), QChar::Nbsp);
+ textOut += QLatin1Char(' ');
+ textOut += padding;
+ textOut += QLatin1Char(' ');
+}
+
+QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
+{
+ skipSpace(ch);
+
+ int attrStart = ch - textIn.constData();
+ int attrLength = 0;
+ while (!ch->isNull()) {
+ if (*ch == greaterThan) {
+ break;
+ } else if (*ch == equals) {
+ ++ch;
+ if (*ch != singleQuote && *ch != doubleQuote) {
+ while (*ch != greaterThan && !ch->isNull())
+ ++ch;
+ break;
+ }
+ ++ch;
+ if (!attrLength)
+ break;
+ QStringRef attr(&textIn, attrStart, attrLength);
+ QStringRef val = parseValue(ch, textIn);
+ if (!val.isEmpty())
+ return QPair<QStringRef,QStringRef>(attr,val);
+ break;
+ } else {
+ ++attrLength;
+ }
+ ++ch;
+ }
+
+ return QPair<QStringRef,QStringRef>();
+}
+
+QStringRef QQuickStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
+{
+ int valStart = ch - textIn.constData();
+ int valLength = 0;
+ while (*ch != singleQuote && *ch != doubleQuote && !ch->isNull()) {
+ ++valLength;
+ ++ch;
+ }
+ if (ch->isNull())
+ return QStringRef();
+ ++ch; // skip quote
+
+ return QStringRef(&textIn, valStart, valLength);
+}
+
+QString QQuickStyledTextPrivate::toAlpha(int value, bool upper)
+{
+ const char baseChar = upper ? 'A' : 'a';
+
+ QString result;
+ int c = value;
+ while (c > 0) {
+ c--;
+ result.prepend(QChar(baseChar + (c % 26)));
+ c /= 26;
+ }
+ return result;
+}
+
+QString QQuickStyledTextPrivate::toRoman(int value, bool upper)
+{
+ QString result = QLatin1String("?");
+ // works for up to 4999 items
+ if (value < 5000) {
+ QByteArray romanNumeral;
+
+ static const char romanSymbolsLower[] = "iiivixxxlxcccdcmmmm";
+ static const char romanSymbolsUpper[] = "IIIVIXXXLXCCCDCMMMM";
+ QByteArray romanSymbols;
+ if (!upper)
+ romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower));
+ else
+ romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper));
+
+ int c[] = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 };
+ int n = value;
+ for (int i = 12; i >= 0; n %= c[i], i--) {
+ int q = n / c[i];
+ if (q > 0) {
+ int startDigit = i + (i + 3) / 4;
+ int numDigits;
+ if (i % 4) {
+ if ((i - 2) % 4)
+ numDigits = 2;
+ else
+ numDigits = 1;
+ }
+ else
+ numDigits = q;
+ romanNumeral.append(romanSymbols.mid(startDigit, numDigits));
+ }
+ }
+ result = QString::fromLatin1(romanNumeral);
+ }
+ return result;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickstyledtext_p.h b/src/quick/util/qquickstyledtext_p.h
new file mode 100644
index 0000000000..4e0f9eaaaf
--- /dev/null
+++ b/src/quick/util/qquickstyledtext_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTYLEDTEXT_H
+#define QQUICKSTYLEDTEXT_H
+
+#include <QSize>
+#include <QPointF>
+#include <QList>
+#include <QUrl>
+#include <QtQuick/private/qquickpixmapcache_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickStyledTextImgTag;
+class QQuickStyledTextPrivate;
+class QString;
+class QQmlContext;
+
+class Q_AUTOTEST_EXPORT QQuickStyledTextImgTag
+{
+public:
+ QQuickStyledTextImgTag()
+ : position(0), align(QQuickStyledTextImgTag::Bottom), pix(0)
+ { }
+
+ ~QQuickStyledTextImgTag() { delete pix; }
+
+ enum Align {
+ Bottom,
+ Middle,
+ Top
+ };
+
+ QUrl url;
+ QPointF pos;
+ QSize size;
+ int position;
+ Align align;
+ QQuickPixmap *pix;
+};
+
+class Q_AUTOTEST_EXPORT QQuickStyledText
+{
+public:
+ static void parse(const QString &string, QTextLayout &layout,
+ QList<QQuickStyledTextImgTag*> &imgTags,
+ const QUrl &baseUrl,
+ QQmlContext *context,
+ bool preloadImages,
+ bool *fontSizeModified);
+
+private:
+ QQuickStyledText(const QString &string, QTextLayout &layout,
+ QList<QQuickStyledTextImgTag*> &imgTags,
+ const QUrl &baseUrl,
+ QQmlContext *context,
+ bool preloadImages,
+ bool *fontSizeModified);
+ ~QQuickStyledText();
+
+ QQuickStyledTextPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/quick/util/qquicksvgparser.cpp b/src/quick/util/qquicksvgparser.cpp
new file mode 100644
index 0000000000..6a1b743160
--- /dev/null
+++ b/src/quick/util/qquicksvgparser.cpp
@@ -0,0 +1,614 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtDeclaractive module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicksvgparser_p.h"
+
+#include <QtCore/qmath.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_NAMESPACE
+
+static const double Q_PI = 3.14159265358979323846; // pi
+
+//copied from QtSvg (qsvghandler.cpp).
+Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
+// '0' is 0x30 and '9' is 0x39
+static inline bool isDigit(ushort ch)
+{
+ static quint16 magic = 0x3ff;
+ return ((ch >> 4) == 3) && (magic >> (ch & 15));
+}
+
+static qreal toDouble(const QChar *&str)
+{
+ const int maxLen = 255;//technically doubles can go til 308+ but whatever
+ char temp[maxLen+1];
+ int pos = 0;
+
+ if (*str == QLatin1Char('-')) {
+ temp[pos++] = '-';
+ ++str;
+ } else if (*str == QLatin1Char('+')) {
+ ++str;
+ }
+ while (isDigit(str->unicode()) && pos < maxLen) {
+ temp[pos++] = str->toLatin1();
+ ++str;
+ }
+ if (*str == QLatin1Char('.') && pos < maxLen) {
+ temp[pos++] = '.';
+ ++str;
+ }
+ while (isDigit(str->unicode()) && pos < maxLen) {
+ temp[pos++] = str->toLatin1();
+ ++str;
+ }
+ bool exponent = false;
+ if ((*str == QLatin1Char('e') || *str == QLatin1Char('E')) && pos < maxLen) {
+ exponent = true;
+ temp[pos++] = 'e';
+ ++str;
+ if ((*str == QLatin1Char('-') || *str == QLatin1Char('+')) && pos < maxLen) {
+ temp[pos++] = str->toLatin1();
+ ++str;
+ }
+ while (isDigit(str->unicode()) && pos < maxLen) {
+ temp[pos++] = str->toLatin1();
+ ++str;
+ }
+ }
+
+ temp[pos] = '\0';
+
+ qreal val;
+ if (!exponent && pos < 10) {
+ int ival = 0;
+ const char *t = temp;
+ bool neg = false;
+ if(*t == '-') {
+ neg = true;
+ ++t;
+ }
+ while(*t && *t != '.') {
+ ival *= 10;
+ ival += (*t) - '0';
+ ++t;
+ }
+ if(*t == '.') {
+ ++t;
+ int div = 1;
+ while(*t) {
+ ival *= 10;
+ ival += (*t) - '0';
+ div *= 10;
+ ++t;
+ }
+ val = ((qreal)ival)/((qreal)div);
+ } else {
+ val = ival;
+ }
+ if (neg)
+ val = -val;
+ } else {
+#if defined(Q_WS_QWS) && !defined(Q_OS_VXWORKS)
+ if(sizeof(qreal) == sizeof(float))
+ val = strtof(temp, 0);
+ else
+#endif
+ {
+ bool ok = false;
+ val = qstrtod(temp, 0, &ok);
+ }
+ }
+ return val;
+
+}
+static inline void parseNumbersArray(const QChar *&str, QVarLengthArray<qreal, 8> &points)
+{
+ while (str->isSpace())
+ ++str;
+ while (isDigit(str->unicode()) ||
+ *str == QLatin1Char('-') || *str == QLatin1Char('+') ||
+ *str == QLatin1Char('.')) {
+
+ points.append(toDouble(str));
+
+ while (str->isSpace())
+ ++str;
+ if (*str == QLatin1Char(','))
+ ++str;
+
+ //eat the rest of space
+ while (str->isSpace())
+ ++str;
+ }
+}
+
+static void pathArcSegment(QPainterPath &path,
+ qreal xc, qreal yc,
+ qreal th0, qreal th1,
+ qreal rx, qreal ry, qreal xAxisRotation)
+{
+ qreal sinTh, cosTh;
+ qreal a00, a01, a10, a11;
+ qreal x1, y1, x2, y2, x3, y3;
+ qreal t;
+ qreal thHalf;
+
+ sinTh = qSin(xAxisRotation * (Q_PI / 180.0));
+ cosTh = qCos(xAxisRotation * (Q_PI / 180.0));
+
+ a00 = cosTh * rx;
+ a01 = -sinTh * ry;
+ a10 = sinTh * rx;
+ a11 = cosTh * ry;
+
+ thHalf = 0.5 * (th1 - th0);
+ t = (8.0 / 3.0) * qSin(thHalf * 0.5) * qSin(thHalf * 0.5) / qSin(thHalf);
+ x1 = xc + qCos(th0) - t * qSin(th0);
+ y1 = yc + qSin(th0) + t * qCos(th0);
+ x3 = xc + qCos(th1);
+ y3 = yc + qSin(th1);
+ x2 = x3 + t * qSin(th1);
+ y2 = y3 - t * qCos(th1);
+
+ path.cubicTo(a00 * x1 + a01 * y1, a10 * x1 + a11 * y1,
+ a00 * x2 + a01 * y2, a10 * x2 + a11 * y2,
+ a00 * x3 + a01 * y3, a10 * x3 + a11 * y3);
+}
+
+void QQuickSvgParser::pathArc(QPainterPath &path,
+ qreal rx,
+ qreal ry,
+ qreal x_axis_rotation,
+ int large_arc_flag,
+ int sweep_flag,
+ qreal x,
+ qreal y,
+ qreal curx, qreal cury)
+{
+ qreal sin_th, cos_th;
+ qreal a00, a01, a10, a11;
+ qreal x0, y0, x1, y1, xc, yc;
+ qreal d, sfactor, sfactor_sq;
+ qreal th0, th1, th_arc;
+ int i, n_segs;
+ qreal dx, dy, dx1, dy1, Pr1, Pr2, Px, Py, check;
+
+ rx = qAbs(rx);
+ ry = qAbs(ry);
+
+ sin_th = qSin(x_axis_rotation * (Q_PI / 180.0));
+ cos_th = qCos(x_axis_rotation * (Q_PI / 180.0));
+
+ dx = (curx - x) / 2.0;
+ dy = (cury - y) / 2.0;
+ dx1 = cos_th * dx + sin_th * dy;
+ dy1 = -sin_th * dx + cos_th * dy;
+ Pr1 = rx * rx;
+ Pr2 = ry * ry;
+ Px = dx1 * dx1;
+ Py = dy1 * dy1;
+ /* Spec : check if radii are large enough */
+ check = Px / Pr1 + Py / Pr2;
+ if (check > 1) {
+ rx = rx * qSqrt(check);
+ ry = ry * qSqrt(check);
+ }
+
+ a00 = cos_th / rx;
+ a01 = sin_th / rx;
+ a10 = -sin_th / ry;
+ a11 = cos_th / ry;
+ x0 = a00 * curx + a01 * cury;
+ y0 = a10 * curx + a11 * cury;
+ x1 = a00 * x + a01 * y;
+ y1 = a10 * x + a11 * y;
+ /* (x0, y0) is current point in transformed coordinate space.
+ (x1, y1) is new point in transformed coordinate space.
+
+ The arc fits a unit-radius circle in this space.
+ */
+ d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
+ sfactor_sq = 1.0 / d - 0.25;
+ if (sfactor_sq < 0) sfactor_sq = 0;
+ sfactor = qSqrt(sfactor_sq);
+ if (sweep_flag == large_arc_flag) sfactor = -sfactor;
+ xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
+ yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);
+ /* (xc, yc) is center of the circle. */
+
+ th0 = qAtan2(y0 - yc, x0 - xc);
+ th1 = qAtan2(y1 - yc, x1 - xc);
+
+ th_arc = th1 - th0;
+ if (th_arc < 0 && sweep_flag)
+ th_arc += 2 * Q_PI;
+ else if (th_arc > 0 && !sweep_flag)
+ th_arc -= 2 * Q_PI;
+
+ n_segs = qCeil(qAbs(th_arc / (Q_PI * 0.5 + 0.001)));
+
+ for (i = 0; i < n_segs; i++) {
+ pathArcSegment(path, xc, yc,
+ th0 + i * th_arc / n_segs,
+ th0 + (i + 1) * th_arc / n_segs,
+ rx, ry, x_axis_rotation);
+ }
+}
+
+
+bool QQuickSvgParser::parsePathDataFast(const QString &dataStr, QPainterPath &path)
+{
+ qreal x0 = 0, y0 = 0; // starting point
+ qreal x = 0, y = 0; // current point
+ char lastMode = 0;
+ QPointF ctrlPt;
+ const QChar *str = dataStr.constData();
+ const QChar *end = str + dataStr.size();
+
+ while (str != end) {
+ while (str->isSpace())
+ ++str;
+ QChar pathElem = *str;
+ ++str;
+ QChar endc = *end;
+ *const_cast<QChar *>(end) = 0; // parseNumbersArray requires 0-termination that QStringRef cannot guarantee
+ QVarLengthArray<qreal, 8> arg;
+ parseNumbersArray(str, arg);
+ *const_cast<QChar *>(end) = endc;
+ if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z'))
+ arg.append(0);//dummy
+ const qreal *num = arg.constData();
+ int count = arg.count();
+ while (count > 0) {
+ qreal offsetX = x; // correction offsets
+ qreal offsetY = y; // for relative commands
+ switch (pathElem.unicode()) {
+ case 'm': {
+ if (count < 2) {
+ num++;
+ count--;
+ break;
+ }
+ x = x0 = num[0] + offsetX;
+ y = y0 = num[1] + offsetY;
+ num += 2;
+ count -= 2;
+ path.moveTo(x0, y0);
+
+ // As per 1.2 spec 8.3.2 The "moveto" commands
+ // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands,
+ // the subsequent pairs shall be treated as implicit 'lineto' commands.
+ pathElem = QLatin1Char('l');
+ }
+ break;
+ case 'M': {
+ if (count < 2) {
+ num++;
+ count--;
+ break;
+ }
+ x = x0 = num[0];
+ y = y0 = num[1];
+ num += 2;
+ count -= 2;
+ path.moveTo(x0, y0);
+
+ // As per 1.2 spec 8.3.2 The "moveto" commands
+ // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands,
+ // the subsequent pairs shall be treated as implicit 'lineto' commands.
+ pathElem = QLatin1Char('L');
+ }
+ break;
+ case 'z':
+ case 'Z': {
+ x = x0;
+ y = y0;
+ count--; // skip dummy
+ num++;
+ path.closeSubpath();
+ }
+ break;
+ case 'l': {
+ if (count < 2) {
+ num++;
+ count--;
+ break;
+ }
+ x = num[0] + offsetX;
+ y = num[1] + offsetY;
+ num += 2;
+ count -= 2;
+ path.lineTo(x, y);
+
+ }
+ break;
+ case 'L': {
+ if (count < 2) {
+ num++;
+ count--;
+ break;
+ }
+ x = num[0];
+ y = num[1];
+ num += 2;
+ count -= 2;
+ path.lineTo(x, y);
+ }
+ break;
+ case 'h': {
+ x = num[0] + offsetX;
+ num++;
+ count--;
+ path.lineTo(x, y);
+ }
+ break;
+ case 'H': {
+ x = num[0];
+ num++;
+ count--;
+ path.lineTo(x, y);
+ }
+ break;
+ case 'v': {
+ y = num[0] + offsetY;
+ num++;
+ count--;
+ path.lineTo(x, y);
+ }
+ break;
+ case 'V': {
+ y = num[0];
+ num++;
+ count--;
+ path.lineTo(x, y);
+ }
+ break;
+ case 'c': {
+ if (count < 6) {
+ num += count;
+ count = 0;
+ break;
+ }
+ QPointF c1(num[0] + offsetX, num[1] + offsetY);
+ QPointF c2(num[2] + offsetX, num[3] + offsetY);
+ QPointF e(num[4] + offsetX, num[5] + offsetY);
+ num += 6;
+ count -= 6;
+ path.cubicTo(c1, c2, e);
+ ctrlPt = c2;
+ x = e.x();
+ y = e.y();
+ break;
+ }
+ case 'C': {
+ if (count < 6) {
+ num += count;
+ count = 0;
+ break;
+ }
+ QPointF c1(num[0], num[1]);
+ QPointF c2(num[2], num[3]);
+ QPointF e(num[4], num[5]);
+ num += 6;
+ count -= 6;
+ path.cubicTo(c1, c2, e);
+ ctrlPt = c2;
+ x = e.x();
+ y = e.y();
+ break;
+ }
+ case 's': {
+ if (count < 4) {
+ num += count;
+ count = 0;
+ break;
+ }
+ QPointF c1;
+ if (lastMode == 'c' || lastMode == 'C' ||
+ lastMode == 's' || lastMode == 'S')
+ c1 = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
+ else
+ c1 = QPointF(x, y);
+ QPointF c2(num[0] + offsetX, num[1] + offsetY);
+ QPointF e(num[2] + offsetX, num[3] + offsetY);
+ num += 4;
+ count -= 4;
+ path.cubicTo(c1, c2, e);
+ ctrlPt = c2;
+ x = e.x();
+ y = e.y();
+ break;
+ }
+ case 'S': {
+ if (count < 4) {
+ num += count;
+ count = 0;
+ break;
+ }
+ QPointF c1;
+ if (lastMode == 'c' || lastMode == 'C' ||
+ lastMode == 's' || lastMode == 'S')
+ c1 = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
+ else
+ c1 = QPointF(x, y);
+ QPointF c2(num[0], num[1]);
+ QPointF e(num[2], num[3]);
+ num += 4;
+ count -= 4;
+ path.cubicTo(c1, c2, e);
+ ctrlPt = c2;
+ x = e.x();
+ y = e.y();
+ break;
+ }
+ case 'q': {
+ if (count < 4) {
+ num += count;
+ count = 0;
+ break;
+ }
+ QPointF c(num[0] + offsetX, num[1] + offsetY);
+ QPointF e(num[2] + offsetX, num[3] + offsetY);
+ num += 4;
+ count -= 4;
+ path.quadTo(c, e);
+ ctrlPt = c;
+ x = e.x();
+ y = e.y();
+ break;
+ }
+ case 'Q': {
+ if (count < 4) {
+ num += count;
+ count = 0;
+ break;
+ }
+ QPointF c(num[0], num[1]);
+ QPointF e(num[2], num[3]);
+ num += 4;
+ count -= 4;
+ path.quadTo(c, e);
+ ctrlPt = c;
+ x = e.x();
+ y = e.y();
+ break;
+ }
+ case 't': {
+ if (count < 2) {
+ num += count;
+ count = 0;
+ break;
+ }
+ QPointF e(num[0] + offsetX, num[1] + offsetY);
+ num += 2;
+ count -= 2;
+ QPointF c;
+ if (lastMode == 'q' || lastMode == 'Q' ||
+ lastMode == 't' || lastMode == 'T')
+ c = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
+ else
+ c = QPointF(x, y);
+ path.quadTo(c, e);
+ ctrlPt = c;
+ x = e.x();
+ y = e.y();
+ break;
+ }
+ case 'T': {
+ if (count < 2) {
+ num += count;
+ count = 0;
+ break;
+ }
+ QPointF e(num[0], num[1]);
+ num += 2;
+ count -= 2;
+ QPointF c;
+ if (lastMode == 'q' || lastMode == 'Q' ||
+ lastMode == 't' || lastMode == 'T')
+ c = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
+ else
+ c = QPointF(x, y);
+ path.quadTo(c, e);
+ ctrlPt = c;
+ x = e.x();
+ y = e.y();
+ break;
+ }
+ case 'a': {
+ if (count < 7) {
+ num += count;
+ count = 0;
+ break;
+ }
+ qreal rx = (*num++);
+ qreal ry = (*num++);
+ qreal xAxisRotation = (*num++);
+ qreal largeArcFlag = (*num++);
+ qreal sweepFlag = (*num++);
+ qreal ex = (*num++) + offsetX;
+ qreal ey = (*num++) + offsetY;
+ count -= 7;
+ qreal curx = x;
+ qreal cury = y;
+ pathArc(path, rx, ry, xAxisRotation, int(largeArcFlag),
+ int(sweepFlag), ex, ey, curx, cury);
+
+ x = ex;
+ y = ey;
+ }
+ break;
+ case 'A': {
+ if (count < 7) {
+ num += count;
+ count = 0;
+ break;
+ }
+ qreal rx = (*num++);
+ qreal ry = (*num++);
+ qreal xAxisRotation = (*num++);
+ qreal largeArcFlag = (*num++);
+ qreal sweepFlag = (*num++);
+ qreal ex = (*num++);
+ qreal ey = (*num++);
+ count -= 7;
+ qreal curx = x;
+ qreal cury = y;
+ pathArc(path, rx, ry, xAxisRotation, int(largeArcFlag),
+ int(sweepFlag), ex, ey, curx, cury);
+
+ x = ex;
+ y = ey;
+ }
+ break;
+ default:
+ return false;
+ }
+ lastMode = pathElem.toLatin1();
+ }
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquicksvgparser_p.h b/src/quick/util/qquicksvgparser_p.h
new file mode 100644
index 0000000000..ed8234dc0f
--- /dev/null
+++ b/src/quick/util/qquicksvgparser_p.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtDeclaractive module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSVGPARSER_P_H
+#define QQUICKSVGPARSER_P_H
+
+#include <QtCore/qstring.h>
+#include <QtGui/qpainterpath.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QQuickSvgParser
+{
+ bool parsePathDataFast(const QString &dataStr, QPainterPath &path);
+ void pathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation,
+ int large_arc_flag, int sweep_flag, qreal x, qreal y, qreal curx,
+ qreal cury);
+}
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSVGPARSER_P_H
diff --git a/src/quick/util/qquicksystempalette.cpp b/src/quick/util/qquicksystempalette.cpp
new file mode 100644
index 0000000000..735d18abf5
--- /dev/null
+++ b/src/quick/util/qquicksystempalette.cpp
@@ -0,0 +1,312 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicksystempalette_p.h"
+
+#include <QGuiApplication>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickSystemPalettePrivate : public QObjectPrivate
+{
+public:
+ QPalette palette;
+ QPalette::ColorGroup group;
+};
+
+
+
+/*!
+ \qmlclass SystemPalette QQuickSystemPalette
+ \inqmlmodule QtQuick 2
+ \ingroup qml-utility-elements
+ \brief The SystemPalette element provides access to the Qt palettes.
+
+ The SystemPalette element provides access to the Qt application
+ palettes. This provides information about the standard colors used
+ for application windows, buttons and other features. These colors
+ are grouped into three \e {color groups}: \c Active, \c Inactive,
+ and \c Disabled. See the QPalette documentation for details about
+ color groups and the properties provided by SystemPalette.
+
+ This can be used to color items in a way that provides a more
+ native look and feel.
+
+ The following example creates a palette from the \c Active color
+ group and uses this to color the window and text items
+ appropriately:
+
+ \snippet doc/src/snippets/qml/systempalette.qml 0
+
+ \sa QPalette
+*/
+QQuickSystemPalette::QQuickSystemPalette(QObject *parent)
+ : QObject(*(new QQuickSystemPalettePrivate), parent)
+{
+ Q_D(QQuickSystemPalette);
+ d->palette = QGuiApplication::palette();
+ d->group = QPalette::Active;
+ qApp->installEventFilter(this);
+}
+
+QQuickSystemPalette::~QQuickSystemPalette()
+{
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::window
+ The window (general background) color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::window() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Window);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::windowText
+ The window text (general foreground) color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::windowText() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::WindowText);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::base
+ The base color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::base() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Base);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::text
+ The text color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::text() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Text);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::alternateBase
+ The alternate base color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::alternateBase() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::AlternateBase);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::button
+ The button color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::button() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Button);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::buttonText
+ The button text foreground color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::buttonText() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::ButtonText);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::light
+ The light color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::light() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Light);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::midlight
+ The midlight color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::midlight() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Midlight);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::dark
+ The dark color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::dark() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Dark);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::mid
+ The mid color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::mid() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Mid);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::shadow
+ The shadow color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::shadow() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Shadow);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::highlight
+ The highlight color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::highlight() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::Highlight);
+}
+
+/*!
+ \qmlproperty color QtQuick2::SystemPalette::highlightedText
+ The highlighted text color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QQuickSystemPalette::highlightedText() const
+{
+ Q_D(const QQuickSystemPalette);
+ return d->palette.color(d->group, QPalette::HighlightedText);
+}
+
+/*!
+ \qmlproperty enumeration QtQuick2::SystemPalette::colorGroup
+
+ The color group of the palette. This can be one of:
+
+ \list
+ \o SystemPalette.Active (default)
+ \o SystemPalette.Inactive
+ \o SystemPalette.Disabled
+ \endlist
+
+ \sa QPalette::ColorGroup
+*/
+QQuickSystemPalette::ColorGroup QQuickSystemPalette::colorGroup() const
+{
+ Q_D(const QQuickSystemPalette);
+ return (QQuickSystemPalette::ColorGroup)d->group;
+}
+
+void QQuickSystemPalette::setColorGroup(QQuickSystemPalette::ColorGroup colorGroup)
+{
+ Q_D(QQuickSystemPalette);
+ d->group = (QPalette::ColorGroup)colorGroup;
+ emit paletteChanged();
+}
+
+bool QQuickSystemPalette::eventFilter(QObject *watched, QEvent *event)
+{
+ if (watched == qApp) {
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ QGuiApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
+ return false;
+ }
+ }
+ return QObject::eventFilter(watched, event);
+}
+
+bool QQuickSystemPalette::event(QEvent *event)
+{
+ Q_D(QQuickSystemPalette);
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ d->palette = QGuiApplication::palette();
+ emit paletteChanged();
+ return true;
+ }
+ return QObject::event(event);
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquicksystempalette_p.h b/src/quick/util/qquicksystempalette_p.h
new file mode 100644
index 0000000000..e7b8f8a418
--- /dev/null
+++ b/src/quick/util/qquicksystempalette_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSYSTEMPALETTE_H
+#define QQUICKSYSTEMPALETTE_H
+
+#include <qqml.h>
+
+#include <QtCore/qobject.h>
+#include <QPalette>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickSystemPalettePrivate;
+class Q_AUTOTEST_EXPORT QQuickSystemPalette : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(ColorGroup)
+ Q_DECLARE_PRIVATE(QQuickSystemPalette)
+
+ Q_PROPERTY(QQuickSystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
+ Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
+ Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
+ Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
+ Q_PROPERTY(QColor text READ text NOTIFY paletteChanged)
+ Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged)
+ Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
+ Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
+ Q_PROPERTY(QColor light READ light NOTIFY paletteChanged)
+ Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged)
+ Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged)
+ Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged)
+ Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
+ Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
+ Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
+
+public:
+ QQuickSystemPalette(QObject *parent=0);
+ ~QQuickSystemPalette();
+
+ enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled };
+
+ QColor window() const;
+ QColor windowText() const;
+
+ QColor base() const;
+ QColor text() const;
+ QColor alternateBase() const;
+
+ QColor button() const;
+ QColor buttonText() const;
+
+ QColor light() const;
+ QColor midlight() const;
+ QColor dark() const;
+ QColor mid() const;
+ QColor shadow() const;
+
+ QColor highlight() const;
+ QColor highlightedText() const;
+
+ QQuickSystemPalette::ColorGroup colorGroup() const;
+ void setColorGroup(QQuickSystemPalette::ColorGroup);
+
+Q_SIGNALS:
+ void paletteChanged();
+
+private:
+ bool eventFilter(QObject *watched, QEvent *event);
+ bool event(QEvent *event);
+
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickSystemPalette)
+
+QT_END_HEADER
+
+#endif // QQUICKSYSTEMPALETTE_H
diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp
new file mode 100644
index 0000000000..3e8b36714a
--- /dev/null
+++ b/src/quick/util/qquicktimeline.cpp
@@ -0,0 +1,947 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicktimeline_p_p.h"
+
+#include <QDebug>
+#include <QMutex>
+#include <QThread>
+#include <QWaitCondition>
+#include <QEvent>
+#include <QCoreApplication>
+#include <QEasingCurve>
+#include <QTime>
+
+QT_BEGIN_NAMESPACE
+
+struct Update {
+ Update(QQuickTimeLineValue *_g, qreal _v)
+ : g(_g), v(_v) {}
+ Update(const QQuickTimeLineCallback &_e)
+ : g(0), v(0), e(_e) {}
+
+ QQuickTimeLineValue *g;
+ qreal v;
+ QQuickTimeLineCallback e;
+};
+
+struct QQuickTimeLinePrivate
+{
+ QQuickTimeLinePrivate(QQuickTimeLine *);
+
+ struct Op {
+ enum Type {
+ Pause,
+ Set,
+ Move,
+ MoveBy,
+ Accel,
+ AccelDistance,
+ Execute
+ };
+ Op() {}
+ Op(Type t, int l, qreal v, qreal v2, int o,
+ const QQuickTimeLineCallback &ev = QQuickTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
+ : type(t), length(l), value(v), value2(v2), order(o), event(ev),
+ easing(es) {}
+ Op(const Op &o)
+ : type(o.type), length(o.length), value(o.value), value2(o.value2),
+ order(o.order), event(o.event), easing(o.easing) {}
+ Op &operator=(const Op &o) {
+ type = o.type; length = o.length; value = o.value;
+ value2 = o.value2; order = o.order; event = o.event;
+ easing = o.easing;
+ return *this;
+ }
+
+ Type type;
+ int length;
+ qreal value;
+ qreal value2;
+
+ int order;
+ QQuickTimeLineCallback event;
+ QEasingCurve easing;
+ };
+ struct TimeLine
+ {
+ TimeLine() : length(0), consumedOpLength(0), base(0.) {}
+ QList<Op> ops;
+ int length;
+ int consumedOpLength;
+ qreal base;
+ };
+
+ int length;
+ int syncPoint;
+ typedef QHash<QQuickTimeLineObject *, TimeLine> Ops;
+ Ops ops;
+ QQuickTimeLine *q;
+
+ void add(QQuickTimeLineObject &, const Op &);
+ qreal value(const Op &op, int time, qreal base, bool *) const;
+
+ int advance(int);
+
+ bool clockRunning;
+ int prevTime;
+
+ int order;
+
+ QQuickTimeLine::SyncMode syncMode;
+ int syncAdj;
+ QList<QPair<int, Update> > *updateQueue;
+};
+
+QQuickTimeLinePrivate::QQuickTimeLinePrivate(QQuickTimeLine *parent)
+: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QQuickTimeLine::LocalSync), syncAdj(0), updateQueue(0)
+{
+}
+
+void QQuickTimeLinePrivate::add(QQuickTimeLineObject &g, const Op &o)
+{
+ if (g._t && g._t != q) {
+ qWarning() << "QQuickTimeLine: Cannot modify a QQuickTimeLineValue owned by"
+ << "another timeline.";
+ return;
+ }
+ g._t = q;
+
+ Ops::Iterator iter = ops.find(&g);
+ if (iter == ops.end()) {
+ iter = ops.insert(&g, TimeLine());
+ if (syncPoint > 0)
+ q->pause(g, syncPoint);
+ }
+ if (!iter->ops.isEmpty() &&
+ o.type == Op::Pause &&
+ iter->ops.last().type == Op::Pause) {
+ iter->ops.last().length += o.length;
+ iter->length += o.length;
+ } else {
+ iter->ops.append(o);
+ iter->length += o.length;
+ }
+
+ if (iter->length > length)
+ length = iter->length;
+
+ if (!clockRunning) {
+ q->stop();
+ prevTime = 0;
+ clockRunning = true;
+
+ if (syncMode == QQuickTimeLine::LocalSync) {
+ syncAdj = -1;
+ } else {
+ syncAdj = 0;
+ }
+ q->start();
+/* q->tick(0);
+ if (syncMode == QQuickTimeLine::LocalSync) {
+ syncAdj = -1;
+ } else {
+ syncAdj = 0;
+ }
+ */
+ }
+}
+
+qreal QQuickTimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const
+{
+ Q_ASSERT(time >= 0);
+ Q_ASSERT(time <= op.length);
+ *changed = true;
+
+ switch(op.type) {
+ case Op::Pause:
+ *changed = false;
+ return base;
+ case Op::Set:
+ return op.value;
+ case Op::Move:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return op.value;
+ } else {
+ qreal delta = op.value - base;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if (op.easing.type() == QEasingCurve::Linear)
+ return base + delta * pTime;
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
+ }
+ case Op::MoveBy:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return base + op.value;
+ } else {
+ qreal delta = op.value;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if (op.easing.type() == QEasingCurve::Linear)
+ return base + delta * pTime;
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
+ }
+ case Op::Accel:
+ if (time == 0) {
+ return base;
+ } else {
+ qreal t = (qreal)(time) / 1000.0f;
+ qreal delta = op.value * t + 0.5f * op.value2 * t * t;
+ return base + delta;
+ }
+ case Op::AccelDistance:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return base + op.value2;
+ } else {
+ qreal t = (qreal)(time) / 1000.0f;
+ qreal accel = -1.0f * 1000.0f * op.value / (qreal)op.length;
+ qreal delta = op.value * t + 0.5f * accel * t * t;
+ return base + delta;
+
+ }
+ case Op::Execute:
+ op.event.d0(op.event.d1);
+ *changed = false;
+ return -1;
+ }
+
+ return base;
+}
+
+/*!
+ \internal
+ \class QQuickTimeLine
+ \brief The QQuickTimeLine class provides a timeline for controlling animations.
+
+ QQuickTimeLine is similar to QTimeLine except:
+ \list
+ \i It updates QQuickTimeLineValue instances directly, rather than maintaining a single
+ current value.
+
+ For example, the following animates a simple value over 200 milliseconds:
+ \code
+ QQuickTimeLineValue v(<starting value>);
+ QQuickTimeLine tl;
+ tl.move(v, 100., 200);
+ tl.start()
+ \endcode
+
+ If your program needs to know when values are changed, it can either
+ connect to the QQuickTimeLine's updated() signal, or inherit from QQuickTimeLineValue
+ and reimplement the QQuickTimeLineValue::setValue() method.
+
+ \i Supports multiple QQuickTimeLineValue, arbitrary start and end values and allows
+ animations to be strung together for more complex effects.
+
+ For example, the following animation moves the x and y coordinates of
+ an object from wherever they are to the position (100, 100) in 50
+ milliseconds and then further animates them to (100, 200) in 50
+ milliseconds:
+
+ \code
+ QQuickTimeLineValue x(<starting value>);
+ QQuickTimeLineValue y(<starting value>);
+
+ QQuickTimeLine tl;
+ tl.start();
+
+ tl.move(x, 100., 50);
+ tl.move(y, 100., 50);
+ tl.move(y, 200., 50);
+ \endcode
+
+ \i All QQuickTimeLine instances share a single, synchronized clock.
+
+ Actions scheduled within the same event loop tick are scheduled
+ synchronously against each other, regardless of the wall time between the
+ scheduling. Synchronized scheduling applies both to within the same
+ QQuickTimeLine and across separate QQuickTimeLine's within the same process.
+
+ \endlist
+
+ Currently easing functions are not supported.
+*/
+
+
+/*!
+ Construct a new QQuickTimeLine with the specified \a parent.
+*/
+QQuickTimeLine::QQuickTimeLine(QObject *parent)
+ : QObject(parent)
+{
+ d = new QQuickTimeLinePrivate(this);
+}
+
+/*!
+ Destroys the time line. Any inprogress animations are canceled, but not
+ completed.
+*/
+QQuickTimeLine::~QQuickTimeLine()
+{
+ for (QQuickTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter)
+ iter.key()->_t = 0;
+
+ delete d; d = 0;
+}
+
+/*!
+ \enum QQuickTimeLine::SyncMode
+ */
+
+/*!
+ Return the timeline's synchronization mode.
+ */
+QQuickTimeLine::SyncMode QQuickTimeLine::syncMode() const
+{
+ return d->syncMode;
+}
+
+/*!
+ Set the timeline's synchronization mode to \a syncMode.
+ */
+void QQuickTimeLine::setSyncMode(SyncMode syncMode)
+{
+ d->syncMode = syncMode;
+}
+
+/*!
+ Pause \a obj for \a time milliseconds.
+*/
+void QQuickTimeLine::pause(QQuickTimeLineObject &obj, int time)
+{
+ if (time <= 0) return;
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::Pause, time, 0., 0., d->order++);
+ d->add(obj, op);
+}
+
+/*!
+ Execute the \a event.
+ */
+void QQuickTimeLine::callback(const QQuickTimeLineCallback &callback)
+{
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback);
+ d->add(*callback.callbackObject(), op);
+}
+
+/*!
+ Set the \a value of \a timeLineValue.
+*/
+void QQuickTimeLine::set(QQuickTimeLineValue &timeLineValue, qreal value)
+{
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::Set, 0, value, 0., d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
+ given \a acceleration rate. Although the \a acceleration is technically
+ a deceleration, it should always be positive. The QQuickTimeLine will ensure
+ that the deceleration is in the opposite direction to the initial velocity.
+*/
+int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal acceleration)
+{
+ if (acceleration == 0.0f)
+ return -1;
+
+ if ((velocity > 0.0f) == (acceleration > 0.0f))
+ acceleration = acceleration * -1.0f;
+
+ int time = static_cast<int>(-1000 * velocity / acceleration);
+
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ \overload
+
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
+ given \a acceleration rate over a maximum distance of maxDistance.
+
+ If necessary, QQuickTimeLine will reduce the acceleration to ensure that the
+ entire operation does not require a move of more than \a maxDistance.
+ \a maxDistance should always be positive.
+*/
+int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance)
+{
+ if (maxDistance == 0.0f || acceleration == 0.0f)
+ return -1;
+
+ Q_ASSERT(acceleration > 0.0f && maxDistance > 0.0f);
+
+ qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance);
+ if (maxAccel > acceleration)
+ acceleration = maxAccel;
+
+ if ((velocity > 0.0f) == (acceleration > 0.0f))
+ acceleration = acceleration * -1.0f;
+
+ int time = static_cast<int>(-1000 * velocity / acceleration);
+
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ Decelerate \a timeLineValue from the starting \a velocity to zero over the given
+ \a distance. This is like accel(), but the QQuickTimeLine calculates the exact
+ deceleration to use.
+
+ \a distance should be positive.
+*/
+int QQuickTimeLine::accelDistance(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal distance)
+{
+ if (distance == 0.0f || velocity == 0.0f)
+ return -1;
+
+ Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f));
+
+ int time = static_cast<int>(1000 * (2.0f * distance) / velocity);
+
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ Linearly change the \a timeLineValue from its current value to the given
+ \a destination value over \a time milliseconds.
+*/
+void QQuickTimeLine::move(QQuickTimeLineValue &timeLineValue, qreal destination, int time)
+{
+ if (time <= 0) return;
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Change the \a timeLineValue from its current value to the given \a destination
+ value over \a time milliseconds using the \a easing curve.
+ */
+void QQuickTimeLine::move(QQuickTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
+{
+ if (time <= 0) return;
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QQuickTimeLineCallback(), easing);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Linearly change the \a timeLineValue from its current value by the \a change amount
+ over \a time milliseconds.
+*/
+void QQuickTimeLine::moveBy(QQuickTimeLineValue &timeLineValue, qreal change, int time)
+{
+ if (time <= 0) return;
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Change the \a timeLineValue from its current value by the \a change amount over
+ \a time milliseconds using the \a easing curve.
+ */
+void QQuickTimeLine::moveBy(QQuickTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
+{
+ if (time <= 0) return;
+ QQuickTimeLinePrivate::Op op(QQuickTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QQuickTimeLineCallback(), easing);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Cancel (but don't complete) all scheduled actions for \a timeLineValue.
+*/
+void QQuickTimeLine::reset(QQuickTimeLineValue &timeLineValue)
+{
+ if (!timeLineValue._t)
+ return;
+ if (timeLineValue._t != this) {
+ qWarning() << "QQuickTimeLine: Cannot reset a QQuickTimeLineValue owned by another timeline.";
+ return;
+ }
+ remove(&timeLineValue);
+ timeLineValue._t = 0;
+}
+
+int QQuickTimeLine::duration() const
+{
+ return -1;
+}
+
+/*!
+ Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo
+ within this timeline.
+
+ Following operations on \a timeLineValue in this timeline will be scheduled after
+ all the currently scheduled actions on \a syncTo are complete. In
+ pseudo-code this is equivalent to:
+ \code
+ QQuickTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))
+ \endcode
+*/
+void QQuickTimeLine::sync(QQuickTimeLineValue &timeLineValue, QQuickTimeLineValue &syncTo)
+{
+ QQuickTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo);
+ if (iter == d->ops.end())
+ return;
+ int length = iter->length;
+
+ iter = d->ops.find(&timeLineValue);
+ if (iter == d->ops.end()) {
+ pause(timeLineValue, length);
+ } else {
+ int glength = iter->length;
+ pause(timeLineValue, length - glength);
+ }
+}
+
+/*!
+ Synchronize the end point of \a timeLineValue to the endpoint of the longest
+ action cursrently scheduled in the timeline.
+
+ In pseudo-code, this is equivalent to:
+ \code
+ QQuickTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))
+ \endcode
+*/
+void QQuickTimeLine::sync(QQuickTimeLineValue &timeLineValue)
+{
+ QQuickTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue);
+ if (iter == d->ops.end()) {
+ pause(timeLineValue, d->length);
+ } else {
+ pause(timeLineValue, d->length - iter->length);
+ }
+}
+
+/*
+ Synchronize all currently and future scheduled values in this timeline to
+ the longest action currently scheduled.
+
+ For example:
+ \code
+ value1->setValue(0.);
+ value2->setValue(0.);
+ value3->setValue(0.);
+ QQuickTimeLine tl;
+ ...
+ tl.move(value1, 10, 200);
+ tl.move(value2, 10, 100);
+ tl.sync();
+ tl.move(value2, 20, 100);
+ tl.move(value3, 20, 100);
+ \endcode
+
+ will result in:
+
+ \table
+ \header \o \o 0ms \o 50ms \o 100ms \o 150ms \o 200ms \o 250ms \o 300ms
+ \row \o value1 \o 0 \o 2.5 \o 5.0 \o 7.5 \o 10 \o 10 \o 10
+ \row \o value2 \o 0 \o 5.0 \o 10.0 \o 10.0 \o 10.0 \o 15.0 \o 20.0
+ \row \o value2 \o 0 \o 0 \o 0 \o 0 \o 0 \o 10.0 \o 20.0
+ \endtable
+*/
+
+/*void QQuickTimeLine::sync()
+{
+ for (QQuickTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter)
+ pause(*iter.key(), d->length - iter->length);
+ d->syncPoint = d->length;
+}*/
+
+/*!
+ \internal
+
+ Temporary hack.
+ */
+void QQuickTimeLine::setSyncPoint(int sp)
+{
+ d->syncPoint = sp;
+}
+
+/*!
+ \internal
+
+ Temporary hack.
+ */
+int QQuickTimeLine::syncPoint() const
+{
+ return d->syncPoint;
+}
+
+/*!
+ Returns true if the timeline is active. An active timeline is one where
+ QQuickTimeLineValue actions are still pending.
+*/
+bool QQuickTimeLine::isActive() const
+{
+ return !d->ops.isEmpty();
+}
+
+/*!
+ Completes the timeline. All queued actions are played to completion, and then discarded. For example,
+ \code
+ QQuickTimeLineValue v(0.);
+ QQuickTimeLine tl;
+ tl.move(v, 100., 1000.);
+ // 500 ms passes
+ // v.value() == 50.
+ tl.complete();
+ // v.value() == 100.
+ \endcode
+*/
+void QQuickTimeLine::complete()
+{
+ d->advance(d->length);
+}
+
+/*!
+ Resets the timeline. All queued actions are discarded and QQuickTimeLineValue's retain their current value. For example,
+ \code
+ QQuickTimeLineValue v(0.);
+ QQuickTimeLine tl;
+ tl.move(v, 100., 1000.);
+ // 500 ms passes
+ // v.value() == 50.
+ tl.clear();
+ // v.value() == 50.
+ \endcode
+*/
+void QQuickTimeLine::clear()
+{
+ for (QQuickTimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter)
+ iter.key()->_t = 0;
+ d->ops.clear();
+ d->length = 0;
+ d->syncPoint = 0;
+ //XXX need stop here?
+}
+
+int QQuickTimeLine::time() const
+{
+ return d->prevTime;
+}
+
+/*!
+ \fn void QQuickTimeLine::updated()
+
+ Emitted each time the timeline modifies QQuickTimeLineValues. Even if multiple
+ QQuickTimeLineValues are changed, this signal is only emitted once for each clock tick.
+*/
+
+void QQuickTimeLine::updateCurrentTime(int v)
+{
+ if (d->syncAdj == -1)
+ d->syncAdj = v;
+ v -= d->syncAdj;
+
+ int timeChanged = v - d->prevTime;
+#if 0
+ if (!timeChanged)
+ return;
+#endif
+ d->prevTime = v;
+ d->advance(timeChanged);
+ emit updated();
+
+ // Do we need to stop the clock?
+ if (d->ops.isEmpty()) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = false;
+ emit completed();
+ } /*else if (pauseTime > 0) {
+ GfxClock::cancelClock();
+ d->prevTime = 0;
+ GfxClock::pauseFor(pauseTime);
+ d->syncAdj = 0;
+ d->clockRunning = false;
+ }*/ else if (/*!GfxClock::isActive()*/ state() != Running) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = true;
+ d->syncAdj = 0;
+ start();
+ }
+}
+
+bool operator<(const QPair<int, Update> &lhs,
+ const QPair<int, Update> &rhs)
+{
+ return lhs.first < rhs.first;
+}
+
+int QQuickTimeLinePrivate::advance(int t)
+{
+ int pauseTime = -1;
+
+ // XXX - surely there is a more efficient way?
+ do {
+ pauseTime = -1;
+ // Minimal advance time
+ int advanceTime = t;
+ for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) {
+ TimeLine &tl = *iter;
+ Op &op = tl.ops.first();
+ int length = op.length - tl.consumedOpLength;
+
+ if (length < advanceTime) {
+ advanceTime = length;
+ if (advanceTime == 0)
+ break;
+ }
+ }
+ t -= advanceTime;
+
+ // Process until then. A zero length advance time will only process
+ // sets.
+ QList<QPair<int, Update> > updates;
+
+ for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) {
+ QQuickTimeLineValue *v = static_cast<QQuickTimeLineValue *>(iter.key());
+ TimeLine &tl = *iter;
+ Q_ASSERT(!tl.ops.isEmpty());
+
+ do {
+ Op &op = tl.ops.first();
+ if (advanceTime == 0 && op.length != 0)
+ continue;
+
+ if (tl.consumedOpLength == 0 &&
+ op.type != Op::Pause &&
+ op.type != Op::Execute)
+ tl.base = v->value();
+
+ if ((tl.consumedOpLength + advanceTime) == op.length) {
+ if (op.type == Op::Execute) {
+ updates << qMakePair(op.order, Update(op.event));
+ } else {
+ bool changed = false;
+ qreal val = value(op, op.length, tl.base, &changed);
+ if (changed)
+ updates << qMakePair(op.order, Update(v, val));
+ }
+ tl.length -= qMin(advanceTime, tl.length);
+ tl.consumedOpLength = 0;
+ tl.ops.removeFirst();
+ } else {
+ tl.consumedOpLength += advanceTime;
+ bool changed = false;
+ qreal val = value(op, tl.consumedOpLength, tl.base, &changed);
+ if (changed)
+ updates << qMakePair(op.order, Update(v, val));
+ tl.length -= qMin(advanceTime, tl.length);
+ break;
+ }
+
+ } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0);
+
+
+ if (tl.ops.isEmpty()) {
+ iter = ops.erase(iter);
+ v->_t = 0;
+ } else {
+ if (tl.ops.first().type == Op::Pause && pauseTime != 0) {
+ int opPauseTime = tl.ops.first().length - tl.consumedOpLength;
+ if (pauseTime == -1 || opPauseTime < pauseTime)
+ pauseTime = opPauseTime;
+ } else {
+ pauseTime = 0;
+ }
+ ++iter;
+ }
+ }
+
+ length -= qMin(length, advanceTime);
+ syncPoint -= advanceTime;
+
+ qSort(updates.begin(), updates.end());
+ updateQueue = &updates;
+ for (int ii = 0; ii < updates.count(); ++ii) {
+ const Update &v = updates.at(ii).second;
+ if (v.g) {
+ v.g->setValue(v.v);
+ } else {
+ v.e.d0(v.e.d1);
+ }
+ }
+ updateQueue = 0;
+ } while(t);
+
+ return pauseTime;
+}
+
+void QQuickTimeLine::remove(QQuickTimeLineObject *v)
+{
+ QQuickTimeLinePrivate::Ops::Iterator iter = d->ops.find(v);
+ Q_ASSERT(iter != d->ops.end());
+
+ int len = iter->length;
+ d->ops.erase(iter);
+ if (len == d->length) {
+ // We need to recalculate the length
+ d->length = 0;
+ for (QQuickTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter) {
+
+ if (iter->length > d->length)
+ d->length = iter->length;
+
+ }
+ }
+ if (d->ops.isEmpty()) {
+ stop();
+ d->clockRunning = false;
+ } else if (/*!GfxClock::isActive()*/ state() != Running) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = true;
+
+ if (d->syncMode == QQuickTimeLine::LocalSync) {
+ d->syncAdj = -1;
+ } else {
+ d->syncAdj = 0;
+ }
+ start();
+ }
+
+ if (d->updateQueue) {
+ for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
+ if (d->updateQueue->at(ii).second.g == v ||
+ d->updateQueue->at(ii).second.e.callbackObject() == v) {
+ d->updateQueue->removeAt(ii);
+ --ii;
+ }
+ }
+ }
+
+
+}
+
+/*!
+ \internal
+ \class QQuickTimeLineValue
+ \brief The QQuickTimeLineValue class provides a value that can be modified by QQuickTimeLine.
+*/
+
+/*!
+ \fn QQuickTimeLineValue::QQuickTimeLineValue(qreal value = 0)
+
+ Construct a new QQuickTimeLineValue with an initial \a value.
+*/
+
+/*!
+ \fn qreal QQuickTimeLineValue::value() const
+
+ Return the current value.
+*/
+
+/*!
+ \fn void QQuickTimeLineValue::setValue(qreal value)
+
+ Set the current \a value.
+*/
+
+/*!
+ \fn QQuickTimeLine *QQuickTimeLineValue::timeLine() const
+
+ If a QQuickTimeLine is operating on this value, return a pointer to it,
+ otherwise return null.
+*/
+
+
+QQuickTimeLineObject::QQuickTimeLineObject()
+: _t(0)
+{
+}
+
+QQuickTimeLineObject::~QQuickTimeLineObject()
+{
+ if (_t) {
+ _t->remove(this);
+ _t = 0;
+ }
+}
+
+QQuickTimeLineCallback::QQuickTimeLineCallback()
+: d0(0), d1(0), d2(0)
+{
+}
+
+QQuickTimeLineCallback::QQuickTimeLineCallback(QQuickTimeLineObject *b, Callback f, void *d)
+: d0(f), d1(d), d2(b)
+{
+}
+
+QQuickTimeLineCallback::QQuickTimeLineCallback(const QQuickTimeLineCallback &o)
+: d0(o.d0), d1(o.d1), d2(o.d2)
+{
+}
+
+QQuickTimeLineCallback &QQuickTimeLineCallback::operator=(const QQuickTimeLineCallback &o)
+{
+ d0 = o.d0;
+ d1 = o.d1;
+ d2 = o.d2;
+ return *this;
+}
+
+QQuickTimeLineObject *QQuickTimeLineCallback::callbackObject() const
+{
+ return d2;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquicktimeline_p_p.h b/src/quick/util/qquicktimeline_p_p.h
new file mode 100644
index 0000000000..88ee3dafd2
--- /dev/null
+++ b/src/quick/util/qquicktimeline_p_p.h
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTIMELINE_H
+#define QQUICKTIMELINE_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/QObject>
+#include "private/qabstractanimationjob_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QEasingCurve;
+class QQuickTimeLineValue;
+class QQuickTimeLineCallback;
+struct QQuickTimeLinePrivate;
+class QQuickTimeLineObject;
+class Q_AUTOTEST_EXPORT QQuickTimeLine : public QObject, QAbstractAnimationJob
+{
+Q_OBJECT
+public:
+ QQuickTimeLine(QObject *parent = 0);
+ ~QQuickTimeLine();
+
+ enum SyncMode { LocalSync, GlobalSync };
+ SyncMode syncMode() const;
+ void setSyncMode(SyncMode);
+
+ void pause(QQuickTimeLineObject &, int);
+ void callback(const QQuickTimeLineCallback &);
+ void set(QQuickTimeLineValue &, qreal);
+
+ int accel(QQuickTimeLineValue &, qreal velocity, qreal accel);
+ int accel(QQuickTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
+ int accelDistance(QQuickTimeLineValue &, qreal velocity, qreal distance);
+
+ void move(QQuickTimeLineValue &, qreal destination, int time = 500);
+ void move(QQuickTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
+ void moveBy(QQuickTimeLineValue &, qreal change, int time = 500);
+ void moveBy(QQuickTimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
+
+ void sync();
+ void setSyncPoint(int);
+ int syncPoint() const;
+
+ void sync(QQuickTimeLineValue &);
+ void sync(QQuickTimeLineValue &, QQuickTimeLineValue &);
+
+ void reset(QQuickTimeLineValue &);
+
+ void complete();
+ void clear();
+ bool isActive() const;
+
+ int time() const;
+
+ virtual int duration() const;
+Q_SIGNALS:
+ void updated();
+ void completed();
+
+protected:
+ virtual void updateCurrentTime(int);
+
+private:
+ void remove(QQuickTimeLineObject *);
+ friend class QQuickTimeLineObject;
+ friend struct QQuickTimeLinePrivate;
+ QQuickTimeLinePrivate *d;
+};
+
+class Q_AUTOTEST_EXPORT QQuickTimeLineObject
+{
+public:
+ QQuickTimeLineObject();
+ virtual ~QQuickTimeLineObject();
+
+protected:
+ friend class QQuickTimeLine;
+ friend struct QQuickTimeLinePrivate;
+ QQuickTimeLine *_t;
+};
+
+class Q_AUTOTEST_EXPORT QQuickTimeLineValue : public QQuickTimeLineObject
+{
+public:
+ QQuickTimeLineValue(qreal v = 0.) : _v(v) {}
+
+ virtual qreal value() const { return _v; }
+ virtual void setValue(qreal v) { _v = v; }
+
+ QQuickTimeLine *timeLine() const { return _t; }
+
+ operator qreal() const { return _v; }
+ QQuickTimeLineValue &operator=(qreal v) { setValue(v); return *this; }
+private:
+ friend class QQuickTimeLine;
+ friend struct QQuickTimeLinePrivate;
+ qreal _v;
+};
+
+class Q_AUTOTEST_EXPORT QQuickTimeLineCallback
+{
+public:
+ typedef void (*Callback)(void *);
+
+ QQuickTimeLineCallback();
+ QQuickTimeLineCallback(QQuickTimeLineObject *b, Callback, void * = 0);
+ QQuickTimeLineCallback(const QQuickTimeLineCallback &o);
+
+ QQuickTimeLineCallback &operator=(const QQuickTimeLineCallback &o);
+ QQuickTimeLineObject *callbackObject() const;
+
+private:
+ friend struct QQuickTimeLinePrivate;
+ Callback d0;
+ void *d1;
+ QQuickTimeLineObject *d2;
+};
+
+template<class T>
+class QQuickTimeLineValueProxy : public QQuickTimeLineValue
+{
+public:
+ QQuickTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
+ : QQuickTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
+ {
+ Q_ASSERT(_class);
+ }
+
+ QQuickTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
+ : QQuickTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
+ {
+ Q_ASSERT(_class);
+ }
+
+ virtual void setValue(qreal v)
+ {
+ QQuickTimeLineValue::setValue(v);
+ if (_setFunctionReal) (_class->*_setFunctionReal)(v);
+ else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v);
+ }
+
+private:
+ T *_class;
+ void (T::*_setFunctionReal)(qreal);
+ void (T::*_setFunctionInt)(int);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/quick/util/qquicktimer.cpp b/src/quick/util/qquicktimer.cpp
new file mode 100644
index 0000000000..151f1f8b48
--- /dev/null
+++ b/src/quick/util/qquicktimer.cpp
@@ -0,0 +1,327 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicktimer_p.h"
+
+#include <QtCore/qcoreapplication.h>
+#include "private/qpauseanimationjob_p.h"
+#include <qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+
+
+class QQuickTimerPrivate : public QObjectPrivate, public QAnimationJobChangeListener
+{
+ Q_DECLARE_PUBLIC(QQuickTimer)
+public:
+ QQuickTimerPrivate()
+ : interval(1000), running(false), repeating(false), triggeredOnStart(false)
+ , classBegun(false), componentComplete(false), firstTick(true) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *);
+ virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) { Q_Q(QQuickTimer); q->ticked(); }
+
+ int interval;
+ QPauseAnimationJob pause;
+ bool running : 1;
+ bool repeating : 1;
+ bool triggeredOnStart : 1;
+ bool classBegun : 1;
+ bool componentComplete : 1;
+ bool firstTick : 1;
+};
+
+/*!
+ \qmlclass Timer QQuickTimer
+ \inqmlmodule QtQuick 2
+ \ingroup qml-utility-elements
+ \brief The Timer item triggers a handler at a specified interval.
+
+ A Timer can be used to trigger an action either once, or repeatedly
+ at a given interval.
+
+ Here is a Timer that shows the current date and time, and updates
+ the text every 500 milliseconds. It uses the JavaScript \c Date
+ object to access the current time.
+
+ \qml
+ import QtQuick 2.0
+
+ Item {
+ Timer {
+ interval: 500; running: true; repeat: true
+ onTriggered: time.text = Date().toString()
+ }
+
+ Text { id: time }
+ }
+ \endqml
+
+ The Timer element is synchronized with the animation timer. Since the animation
+ timer is usually set to 60fps, the resolution of Timer will be
+ at best 16ms.
+
+ If the Timer is running and one of its properties is changed, the
+ elapsed time will be reset. For example, if a Timer with interval of
+ 1000ms has its \e repeat property changed 500ms after starting, the
+ elapsed time will be reset to 0, and the Timer will be triggered
+ 1000ms later.
+
+ \sa {declarative/toys/clocks}{Clocks example}
+*/
+
+QQuickTimer::QQuickTimer(QObject *parent)
+ : QObject(*(new QQuickTimerPrivate), parent)
+{
+ Q_D(QQuickTimer);
+ d->pause.addAnimationChangeListener(d, QAbstractAnimationJob::Completion | QAbstractAnimationJob::CurrentLoop);
+ d->pause.setLoopCount(1);
+ d->pause.setDuration(d->interval);
+}
+
+/*!
+ \qmlproperty int QtQuick2::Timer::interval
+
+ Sets the \a interval between triggers, in milliseconds.
+
+ The default interval is 1000 milliseconds.
+*/
+void QQuickTimer::setInterval(int interval)
+{
+ Q_D(QQuickTimer);
+ if (interval != d->interval) {
+ d->interval = interval;
+ update();
+ emit intervalChanged();
+ }
+}
+
+int QQuickTimer::interval() const
+{
+ Q_D(const QQuickTimer);
+ return d->interval;
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Timer::running
+
+ If set to true, starts the timer; otherwise stops the timer.
+ For a non-repeating timer, \a running is set to false after the
+ timer has been triggered.
+
+ \a running defaults to false.
+
+ \sa repeat
+*/
+bool QQuickTimer::isRunning() const
+{
+ Q_D(const QQuickTimer);
+ return d->running;
+}
+
+void QQuickTimer::setRunning(bool running)
+{
+ Q_D(QQuickTimer);
+ if (d->running != running) {
+ d->running = running;
+ d->firstTick = true;
+ emit runningChanged();
+ update();
+ }
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Timer::repeat
+
+ If \a repeat is true the timer is triggered repeatedly at the
+ specified interval; otherwise, the timer will trigger once at the
+ specified interval and then stop (i.e. running will be set to false).
+
+ \a repeat defaults to false.
+
+ \sa running
+*/
+bool QQuickTimer::isRepeating() const
+{
+ Q_D(const QQuickTimer);
+ return d->repeating;
+}
+
+void QQuickTimer::setRepeating(bool repeating)
+{
+ Q_D(QQuickTimer);
+ if (repeating != d->repeating) {
+ d->repeating = repeating;
+ update();
+ emit repeatChanged();
+ }
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Timer::triggeredOnStart
+
+ When a timer is started, the first trigger is usually after the specified
+ interval has elapsed. It is sometimes desirable to trigger immediately
+ when the timer is started; for example, to establish an initial
+ state.
+
+ If \a triggeredOnStart is true, the timer is triggered immediately
+ when started, and subsequently at the specified interval. Note that if
+ \e repeat is set to false, the timer is triggered twice; once on start,
+ and again at the interval.
+
+ \a triggeredOnStart defaults to false.
+
+ \sa running
+*/
+bool QQuickTimer::triggeredOnStart() const
+{
+ Q_D(const QQuickTimer);
+ return d->triggeredOnStart;
+}
+
+void QQuickTimer::setTriggeredOnStart(bool triggeredOnStart)
+{
+ Q_D(QQuickTimer);
+ if (d->triggeredOnStart != triggeredOnStart) {
+ d->triggeredOnStart = triggeredOnStart;
+ update();
+ emit triggeredOnStartChanged();
+ }
+}
+
+/*!
+ \qmlmethod QtQuick2::Timer::start()
+ \brief Starts the timer.
+
+ If the timer is already running, calling this method has no effect. The
+ \c running property will be true following a call to \c start().
+*/
+void QQuickTimer::start()
+{
+ setRunning(true);
+}
+
+/*!
+ \qmlmethod QtQuick2::Timer::stop()
+ \brief Stops the timer.
+
+ If the timer is not running, calling this method has no effect. The
+ \c running property will be false following a call to \c stop().
+*/
+void QQuickTimer::stop()
+{
+ setRunning(false);
+}
+
+/*!
+ \qmlmethod QtQuick2::Timer::restart()
+ \brief Restarts the timer.
+
+ If the Timer is not running it will be started, otherwise it will be
+ stopped, reset to initial state and started. The \c running property
+ will be true following a call to \c restart().
+*/
+void QQuickTimer::restart()
+{
+ setRunning(false);
+ setRunning(true);
+}
+
+void QQuickTimer::update()
+{
+ Q_D(QQuickTimer);
+ if (d->classBegun && !d->componentComplete)
+ return;
+ d->pause.stop();
+ if (d->running) {
+ d->pause.setCurrentTime(0);
+ d->pause.setLoopCount(d->repeating ? -1 : 1);
+ d->pause.setDuration(d->interval);
+ d->pause.start();
+ if (d->triggeredOnStart && d->firstTick) {
+ QCoreApplication::removePostedEvents(this, QEvent::MetaCall);
+ QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection);
+ }
+ }
+}
+
+void QQuickTimer::classBegin()
+{
+ Q_D(QQuickTimer);
+ d->classBegun = true;
+}
+
+void QQuickTimer::componentComplete()
+{
+ Q_D(QQuickTimer);
+ d->componentComplete = true;
+ update();
+}
+
+/*!
+ \qmlsignal QtQuick2::Timer::onTriggered()
+
+ This handler is called when the Timer is triggered.
+*/
+void QQuickTimer::ticked()
+{
+ Q_D(QQuickTimer);
+ if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick)))
+ emit triggered();
+ d->firstTick = false;
+}
+
+void QQuickTimerPrivate::animationFinished(QAbstractAnimationJob *)
+{
+ Q_Q(QQuickTimer);
+ if (repeating || !running)
+ return;
+ running = false;
+ firstTick = false;
+ emit q->triggered();
+ emit q->runningChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquicktimer_p.h b/src/quick/util/qquicktimer_p.h
new file mode 100644
index 0000000000..b0354e4874
--- /dev/null
+++ b/src/quick/util/qquicktimer_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTIMER_H
+#define QQUICKTIMER_H
+
+#include <qqml.h>
+
+#include <QtCore/qobject.h>
+
+#include <private/qtquickglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickTimerPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickTimer : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickTimer)
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
+ Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged)
+ Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged)
+ Q_PROPERTY(QObject *parent READ parent CONSTANT)
+
+public:
+ QQuickTimer(QObject *parent=0);
+
+ void setInterval(int interval);
+ int interval() const;
+
+ bool isRunning() const;
+ void setRunning(bool running);
+
+ bool isRepeating() const;
+ void setRepeating(bool repeating);
+
+ bool triggeredOnStart() const;
+ void setTriggeredOnStart(bool triggeredOnStart);
+
+protected:
+ void classBegin();
+ void componentComplete();
+
+public Q_SLOTS:
+ void start();
+ void stop();
+ void restart();
+
+Q_SIGNALS:
+ void triggered();
+ void runningChanged();
+ void intervalChanged();
+ void repeatChanged();
+ void triggeredOnStartChanged();
+
+private:
+ void update();
+
+private Q_SLOTS:
+ void ticked();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickTimer)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/quick/util/qquicktransition.cpp b/src/quick/util/qquicktransition.cpp
new file mode 100644
index 0000000000..5d9a2880d2
--- /dev/null
+++ b/src/quick/util/qquicktransition.cpp
@@ -0,0 +1,412 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicktransition_p.h"
+
+#include "qquickstate_p.h"
+#include "qquickstate_p_p.h"
+#include "qquickstatechangescript_p.h"
+#include "qquickanimation_p.h"
+#include "qquickanimation_p_p.h"
+#include "qquicktransitionmanager_p_p.h"
+
+#include "private/qparallelanimationgroupjob_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass Transition QQuickTransition
+ \inqmlmodule QtQuick 2
+ \ingroup qml-animation-transition
+ \brief The Transition element defines animated transitions that occur on state changes.
+
+ A Transition defines the animations to be applied when a \l State change occurs.
+
+ For example, the following \l Rectangle has two states: the default state, and
+ an added "moved" state. In the "moved state, the rectangle's position changes
+ to (50, 50). The added Transition specifies that when the rectangle
+ changes between the default and the "moved" state, any changes
+ to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad.
+
+ \snippet doc/src/snippets/qml/transition.qml 0
+
+ Notice the example does not require \l{PropertyAnimation::}{to} and
+ \l{PropertyAnimation::}{from} values for the NumberAnimation. As a convenience,
+ these properties are automatically set to the values of \c x and \c y before
+ and after the state change; the \c from values are provided by
+ the current values of \c x and \c y, and the \c to values are provided by
+ the PropertyChanges object. If you wish, you can provide \l{PropertyAnimation::}{to} and
+ \l{PropertyAnimation::}{from} values anyway to override the default values.
+
+ By default, a Transition's animations are applied for any state change in the
+ parent item. The Transition \l {Transition::}{from} and \l {Transition::}{to}
+ values can be set to restrict the animations to only be applied when changing
+ from one particular state to another.
+
+ To define multiple transitions, specify \l Item::transitions as a list:
+
+ \snippet doc/src/snippets/qml/transitions-list.qml list of transitions
+
+ If multiple Transitions are specified, only a single (best-matching) Transition will be applied for any particular
+ state change. In the example above, when changing to \c state1, the first transition will be used, rather
+ than the more generic second transition.
+
+ If a state change has a Transition that matches the same property as a
+ \l Behavior, the Transition animation overrides the \l Behavior for that
+ state change.
+
+ \sa {QML Animation and Transitions}, {declarative/animation/states}{states example}, {qmlstates}{States}, {QtQml}
+*/
+
+QQuickTransitionInstance::QQuickTransitionInstance()
+ : m_anim(0)
+{
+}
+
+QQuickTransitionInstance::~QQuickTransitionInstance()
+{
+ delete m_anim;
+}
+
+void QQuickTransitionInstance::start()
+{
+ if (m_anim)
+ m_anim->start();
+}
+
+void QQuickTransitionInstance::stop()
+{
+ if (m_anim)
+ m_anim->stop();
+}
+
+bool QQuickTransitionInstance::isRunning() const
+{
+ return m_anim && m_anim->state() == QAbstractAnimationJob::Running;
+}
+
+
+//ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting
+//and disconnecting signals and slots frequently
+class ParallelAnimationWrapper : public QParallelAnimationGroupJob
+{
+public:
+ ParallelAnimationWrapper() : QParallelAnimationGroupJob() {}
+ QQuickTransitionManager *manager;
+
+protected:
+ virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+};
+
+class QQuickTransitionPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickTransition)
+public:
+ QQuickTransitionPrivate()
+ : fromState(QLatin1String("*")), toState(QLatin1String("*")),
+ reversed(false), reversible(false), enabled(true)
+ {
+ }
+
+ QString fromState;
+ QString toState;
+ bool reversed;
+ bool reversible;
+ bool enabled;
+
+ static void append_animation(QQmlListProperty<QQuickAbstractAnimation> *list, QQuickAbstractAnimation *a);
+ static int animation_count(QQmlListProperty<QQuickAbstractAnimation> *list);
+ static QQuickAbstractAnimation* animation_at(QQmlListProperty<QQuickAbstractAnimation> *list, int pos);
+ static void clear_animations(QQmlListProperty<QQuickAbstractAnimation> *list);
+ QList<QQuickAbstractAnimation *> animations;
+};
+
+void QQuickTransitionPrivate::append_animation(QQmlListProperty<QQuickAbstractAnimation> *list, QQuickAbstractAnimation *a)
+{
+ QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
+ q->d_func()->animations.append(a);
+ a->setDisableUserControl();
+}
+
+int QQuickTransitionPrivate::animation_count(QQmlListProperty<QQuickAbstractAnimation> *list)
+{
+ QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
+ return q->d_func()->animations.count();
+}
+
+QQuickAbstractAnimation* QQuickTransitionPrivate::animation_at(QQmlListProperty<QQuickAbstractAnimation> *list, int pos)
+{
+ QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
+ return q->d_func()->animations.at(pos);
+}
+
+void QQuickTransitionPrivate::clear_animations(QQmlListProperty<QQuickAbstractAnimation> *list)
+{
+ QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
+ while (q->d_func()->animations.count()) {
+ QQuickAbstractAnimation *firstAnim = q->d_func()->animations.at(0);
+ q->d_func()->animations.removeAll(firstAnim);
+ }
+}
+
+void ParallelAnimationWrapper::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState)
+{
+ QParallelAnimationGroupJob::updateState(newState, oldState);
+ if (newState == Stopped && (duration() == -1
+ || (direction() == QAbstractAnimationJob::Forward && currentLoopTime() == duration())
+ || (direction() == QAbstractAnimationJob::Backward && currentLoopTime() == 0)))
+ {
+ manager->complete();
+ }
+}
+
+
+QQuickTransition::QQuickTransition(QObject *parent)
+ : QObject(*(new QQuickTransitionPrivate), parent)
+{
+}
+
+QQuickTransition::~QQuickTransition()
+{
+}
+
+void QQuickTransition::setReversed(bool r)
+{
+ Q_D(QQuickTransition);
+ d->reversed = r;
+}
+
+QQuickTransitionInstance *QQuickTransition::prepare(QQuickStateOperation::ActionList &actions,
+ QList<QQmlProperty> &after,
+ QQuickTransitionManager *manager,
+ QObject *defaultTarget)
+{
+ Q_D(QQuickTransition);
+
+ qmlExecuteDeferred(this);
+
+ ParallelAnimationWrapper *group = new ParallelAnimationWrapper();
+ group->manager = manager;
+
+ QQuickAbstractAnimation::TransitionDirection direction = d->reversed ? QQuickAbstractAnimation::Backward : QQuickAbstractAnimation::Forward;
+ int start = d->reversed ? d->animations.count() - 1 : 0;
+ int end = d->reversed ? -1 : d->animations.count();
+
+ QAbstractAnimationJob *anim = 0;
+ for (int i = start; i != end;) {
+ anim = d->animations.at(i)->transition(actions, after, direction, defaultTarget);
+ if (anim)
+ d->reversed ? group->prependAnimation(anim) : group->appendAnimation(anim);
+ d->reversed ? --i : ++i;
+ }
+
+ group->setDirection(d->reversed ? QAbstractAnimationJob::Backward : QAbstractAnimationJob::Forward);
+
+ QQuickTransitionInstance *wrapper = new QQuickTransitionInstance;
+ wrapper->m_anim = group;
+ return wrapper;
+}
+
+/*!
+ \qmlproperty string QtQuick2::Transition::from
+ \qmlproperty string QtQuick2::Transition::to
+
+ These properties indicate the state changes that trigger the transition.
+
+ The default values for these properties is "*" (that is, any state).
+
+ For example, the following transition has not set the \c to and \c from
+ properties, so the animation is always applied when changing between
+ the two states (i.e. when the mouse is pressed and released).
+
+ \snippet doc/src/snippets/qml/transition-from-to.qml 0
+
+ If the transition was changed to this:
+
+ \snippet doc/src/snippets/qml/transition-from-to-modified.qml modified transition
+
+ The animation would only be applied when changing from the default state to
+ the "brighter" state (i.e. when the mouse is pressed, but not on release).
+
+ Multiple \c to and \from values can be set by using a comma-separated string.
+
+ \sa reversible
+*/
+QString QQuickTransition::fromState() const
+{
+ Q_D(const QQuickTransition);
+ return d->fromState;
+}
+
+void QQuickTransition::setFromState(const QString &f)
+{
+ Q_D(QQuickTransition);
+ if (f == d->fromState)
+ return;
+
+ d->fromState = f;
+ emit fromChanged();
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Transition::reversible
+ This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed.
+
+ The default value is false.
+
+ By default, transitions run in parallel and are applied to all state
+ changes if the \l from and \l to states have not been set. In this
+ situation, the transition is automatically applied when a state change
+ is reversed, and it is not necessary to set this property to reverse
+ the transition.
+
+ However, if a SequentialAnimation is used, or if the \l from or \l to
+ properties have been set, this property will need to be set to reverse
+ a transition when a state change is reverted. For example, the following
+ transition applies a sequential animation when the mouse is pressed,
+ and reverses the sequence of the animation when the mouse is released:
+
+ \snippet doc/src/snippets/qml/transition-reversible.qml 0
+
+ If the transition did not set the \c to and \c reversible values, then
+ on the mouse release, the transition would play the PropertyAnimation
+ before the ColorAnimation instead of reversing the sequence.
+*/
+bool QQuickTransition::reversible() const
+{
+ Q_D(const QQuickTransition);
+ return d->reversible;
+}
+
+void QQuickTransition::setReversible(bool r)
+{
+ Q_D(QQuickTransition);
+ if (r == d->reversible)
+ return;
+
+ d->reversible = r;
+ emit reversibleChanged();
+}
+
+QString QQuickTransition::toState() const
+{
+ Q_D(const QQuickTransition);
+ return d->toState;
+}
+
+void QQuickTransition::setToState(const QString &t)
+{
+ Q_D(QQuickTransition);
+ if (t == d->toState)
+ return;
+
+ d->toState = t;
+ emit toChanged();
+}
+
+/*!
+ \qmlproperty bool QtQuick2::Transition::enabled
+
+ This property holds whether the Transition will be run when moving
+ from the \c from state to the \c to state.
+
+ By default a Transition is enabled.
+
+ Note that in some circumstances disabling a Transition may cause an
+ alternative Transition to be used in its place. In the following
+ example, the generic Transition will be used to animate the change
+ from \c state1 to \c state2, as the more specific Transition has
+ been disabled.
+
+ \qml
+ Item {
+ states: [
+ State { name: "state1" ... }
+ State { name: "state2" ... }
+ ]
+ transitions: [
+ Transition { from: "state1"; to: "state2"; enabled: false ... }
+ Transition { ... }
+ ]
+ }
+ \endqml
+*/
+
+bool QQuickTransition::enabled() const
+{
+ Q_D(const QQuickTransition);
+ return d->enabled;
+}
+
+void QQuickTransition::setEnabled(bool enabled)
+{
+ Q_D(QQuickTransition);
+ if (d->enabled == enabled)
+ return;
+ d->enabled = enabled;
+ emit enabledChanged();
+}
+
+/*!
+ \qmlproperty list<Animation> QtQuick2::Transition::animations
+ \default
+
+ This property holds a list of the animations to be run for this transition.
+
+ \snippet examples/declarative/toys/dynamicscene/dynamicscene.qml top-level transitions
+
+ The top-level animations are run in parallel. To run them sequentially,
+ define them within a SequentialAnimation:
+
+ \snippet doc/src/snippets/qml/transition-reversible.qml sequential animations
+*/
+QQmlListProperty<QQuickAbstractAnimation> QQuickTransition::animations()
+{
+ Q_D(QQuickTransition);
+ return QQmlListProperty<QQuickAbstractAnimation>(this, &d->animations, QQuickTransitionPrivate::append_animation,
+ QQuickTransitionPrivate::animation_count,
+ QQuickTransitionPrivate::animation_at,
+ QQuickTransitionPrivate::clear_animations);
+}
+
+QT_END_NAMESPACE
+
+//#include <qquicktransition.moc>
diff --git a/src/quick/util/qquicktransition_p.h b/src/quick/util/qquicktransition_p.h
new file mode 100644
index 0000000000..ebd82fde2c
--- /dev/null
+++ b/src/quick/util/qquicktransition_p.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTRANSITION_H
+#define QQUICKTRANSITION_H
+
+#include "qquickstate_p.h"
+#include <qqml.h>
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickAbstractAnimation;
+class QQuickTransitionPrivate;
+class QQuickTransitionManager;
+class QQuickTransition;
+class QAbstractAnimationJob;
+
+class Q_QUICK_EXPORT QQuickTransitionInstance
+{
+public:
+ QQuickTransitionInstance();
+ ~QQuickTransitionInstance();
+
+ void start();
+ void stop();
+
+ bool isRunning() const;
+
+private:
+ QAbstractAnimationJob *m_anim;
+ friend class QQuickTransition;
+};
+
+class Q_QUICK_EXPORT QQuickTransition : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickTransition)
+
+ Q_PROPERTY(QString from READ fromState WRITE setFromState NOTIFY fromChanged)
+ Q_PROPERTY(QString to READ toState WRITE setToState NOTIFY toChanged)
+ Q_PROPERTY(bool reversible READ reversible WRITE setReversible NOTIFY reversibleChanged)
+ Q_PROPERTY(QQmlListProperty<QQuickAbstractAnimation> animations READ animations)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_CLASSINFO("DefaultProperty", "animations")
+ Q_CLASSINFO("DeferredPropertyNames", "animations")
+
+public:
+ QQuickTransition(QObject *parent=0);
+ ~QQuickTransition();
+
+ QString fromState() const;
+ void setFromState(const QString &);
+
+ QString toState() const;
+ void setToState(const QString &);
+
+ bool reversible() const;
+ void setReversible(bool);
+
+ bool enabled() const;
+ void setEnabled(bool enabled);
+
+ QQmlListProperty<QQuickAbstractAnimation> animations();
+
+ QQuickTransitionInstance *prepare(QQuickStateOperation::ActionList &actions,
+ QList<QQmlProperty> &after,
+ QQuickTransitionManager *end,
+ QObject *defaultTarget);
+
+ void setReversed(bool r);
+
+Q_SIGNALS:
+ void fromChanged();
+ void toChanged();
+ void reversibleChanged();
+ void enabledChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickTransition)
+
+QT_END_HEADER
+
+#endif // QQUICKTRANSITION_H
diff --git a/src/quick/util/qquicktransitionmanager.cpp b/src/quick/util/qquicktransitionmanager.cpp
new file mode 100644
index 0000000000..910043e251
--- /dev/null
+++ b/src/quick/util/qquicktransitionmanager.cpp
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicktransitionmanager_p_p.h"
+
+#include "qquicktransition_p.h"
+#include "qquickstate_p_p.h"
+
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlglobal_p.h>
+#include <private/qqmlproperty_p.h>
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
+
+class QQuickTransitionManagerPrivate
+{
+public:
+ QQuickTransitionManagerPrivate()
+ : state(0), transitionInstance(0) {}
+
+ void applyBindings();
+ typedef QList<QQuickSimpleAction> SimpleActionList;
+ QQuickState *state;
+ QQuickTransitionInstance *transitionInstance;
+ QQuickStateOperation::ActionList bindingsList;
+ SimpleActionList completeList;
+};
+
+QQuickTransitionManager::QQuickTransitionManager()
+: d(new QQuickTransitionManagerPrivate)
+{
+}
+
+void QQuickTransitionManager::setState(QQuickState *s)
+{
+ d->state = s;
+}
+
+QQuickTransitionManager::~QQuickTransitionManager()
+{
+ delete d->transitionInstance;
+ delete d; d = 0;
+}
+
+bool QQuickTransitionManager::isRunning() const
+{
+ return d->transitionInstance && d->transitionInstance->isRunning();
+}
+
+void QQuickTransitionManager::complete()
+{
+ d->applyBindings();
+
+ for (int ii = 0; ii < d->completeList.count(); ++ii) {
+ const QQmlProperty &prop = d->completeList.at(ii).property();
+ prop.write(d->completeList.at(ii).value());
+ }
+
+ d->completeList.clear();
+
+ if (d->state)
+ static_cast<QQuickStatePrivate*>(QObjectPrivate::get(d->state))->complete();
+
+ finished();
+}
+
+void QQuickTransitionManagerPrivate::applyBindings()
+{
+ foreach(const QQuickAction &action, bindingsList) {
+ if (!action.toBinding.isNull()) {
+ QQmlPropertyPrivate::setBinding(action.property, action.toBinding.data());
+ } else if (action.event) {
+ if (action.reverseEvent)
+ action.event->reverse();
+ else
+ action.event->execute();
+ }
+
+ }
+
+ bindingsList.clear();
+}
+
+void QQuickTransitionManager::finished()
+{
+}
+
+void QQuickTransitionManager::transition(const QList<QQuickAction> &list,
+ QQuickTransition *transition,
+ QObject *defaultTarget)
+{
+ cancel();
+
+ QQuickStateOperation::ActionList applyList = list;
+ // Determine which actions are binding changes and disable any current bindings
+ foreach(const QQuickAction &action, applyList) {
+ if (action.toBinding)
+ d->bindingsList << action;
+ if (action.fromBinding)
+ QQmlPropertyPrivate::setBinding(action.property, 0); // Disable current binding
+ if (action.event && action.event->changesBindings()) { //### assume isReversable()?
+ d->bindingsList << action;
+ action.event->clearBindings();
+ }
+ }
+
+ // Animated transitions need both the start and the end value for
+ // each property change. In the presence of bindings, the end values
+ // are non-trivial to calculate. As a "best effort" attempt, we first
+ // apply all the property and binding changes, then read all the actual
+ // final values, then roll back the changes and proceed as normal.
+ //
+ // This doesn't catch everything, and it might be a little fragile in
+ // some cases - but whatcha going to do?
+ //
+ // Note that we only fast forward if both a transition and bindings are
+ // present, as it is unneccessary (and potentially expensive) otherwise.
+
+ if (transition && !d->bindingsList.isEmpty()) {
+
+ // Apply all the property and binding changes
+ for (int ii = 0; ii < applyList.size(); ++ii) {
+ const QQuickAction &action = applyList.at(ii);
+ if (!action.toBinding.isNull()) {
+ QQmlPropertyPrivate::setBinding(action.property, action.toBinding.data(), QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
+ } else if (!action.event) {
+ QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
+ } else if (action.event->isReversable()) {
+ if (action.reverseEvent)
+ action.event->reverse(QQuickActionEvent::FastForward);
+ else
+ action.event->execute(QQuickActionEvent::FastForward);
+ }
+ }
+
+ // Read all the end values for binding changes
+ for (int ii = 0; ii < applyList.size(); ++ii) {
+ QQuickAction *action = &applyList[ii];
+ if (action->event) {
+ action->event->saveTargetValues();
+ continue;
+ }
+ const QQmlProperty &prop = action->property;
+ if (!action->toBinding.isNull() || !action->toValue.isValid()) {
+ action->toValue = prop.read();
+ }
+ }
+
+ // Revert back to the original values
+ foreach(const QQuickAction &action, applyList) {
+ if (action.event) {
+ if (action.event->isReversable()) {
+ action.event->clearBindings();
+ action.event->rewind();
+ action.event->clearBindings(); //### shouldn't be needed
+ }
+ continue;
+ }
+
+ if (action.toBinding)
+ QQmlPropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition
+
+ QQmlPropertyPrivate::write(action.property, action.fromValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding);
+ }
+ }
+
+ if (transition) {
+ QList<QQmlProperty> touched;
+ QQuickTransitionInstance *oldInstance = d->transitionInstance;
+ d->transitionInstance = transition->prepare(applyList, touched, this, defaultTarget);
+ d->transitionInstance->start();
+ if (oldInstance && oldInstance != d->transitionInstance)
+ delete oldInstance;
+
+ // Modify the action list to remove actions handled in the transition
+ for (int ii = 0; ii < applyList.count(); ++ii) {
+ const QQuickAction &action = applyList.at(ii);
+
+ if (action.event) {
+
+ if (action.actionDone) {
+ applyList.removeAt(ii);
+ --ii;
+ }
+
+ } else {
+
+ if (touched.contains(action.property)) {
+ if (action.toValue != action.fromValue)
+ d->completeList <<
+ QQuickSimpleAction(action, QQuickSimpleAction::EndState);
+
+ applyList.removeAt(ii);
+ --ii;
+ }
+
+ }
+ }
+ }
+
+ // Any actions remaining have not been handled by the transition and should
+ // be applied immediately. We skip applying bindings, as they are all
+ // applied at the end in applyBindings() to avoid any nastiness mid
+ // transition
+ foreach(const QQuickAction &action, applyList) {
+ if (action.event && !action.event->changesBindings()) {
+ if (action.event->isReversable() && action.reverseEvent)
+ action.event->reverse();
+ else
+ action.event->execute();
+ } else if (!action.event && !action.toBinding) {
+ action.property.write(action.toValue);
+ }
+ }
+#ifndef QT_NO_DEBUG_STREAM
+ if (stateChangeDebug()) {
+ foreach(const QQuickAction &action, applyList) {
+ if (action.event)
+ qWarning() << " No transition for event:" << action.event->type();
+ else
+ qWarning() << " No transition for:" << action.property.object()
+ << action.property.name() << "From:" << action.fromValue
+ << "To:" << action.toValue;
+ }
+ }
+#endif
+ if (!transition)
+ complete();
+}
+
+void QQuickTransitionManager::cancel()
+{
+ if (d->transitionInstance && d->transitionInstance->isRunning())
+ d->transitionInstance->stop();
+
+ for(int i = 0; i < d->bindingsList.count(); ++i) {
+ QQuickAction action = d->bindingsList[i];
+ if (!action.toBinding.isNull() && action.deletableToBinding) {
+ QQmlPropertyPrivate::setBinding(action.property, 0);
+ action.toBinding.data()->destroy();
+ action.toBinding.clear();
+ action.deletableToBinding = false;
+ } else if (action.event) {
+ //### what do we do here?
+ }
+
+ }
+ d->bindingsList.clear();
+ d->completeList.clear();
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquicktransitionmanager_p_p.h b/src/quick/util/qquicktransitionmanager_p_p.h
new file mode 100644
index 0000000000..4270ed61a8
--- /dev/null
+++ b/src/quick/util/qquicktransitionmanager_p_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTRANSITIONMANAGER_P_H
+#define QQUICKTRANSITIONMANAGER_P_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 "qquickstatechangescript_p.h"
+#include "qquickanimation_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickStatePrivate;
+class QQuickTransitionManagerPrivate;
+class Q_AUTOTEST_EXPORT QQuickTransitionManager
+{
+public:
+ QQuickTransitionManager();
+ ~QQuickTransitionManager();
+
+ bool isRunning() const;
+
+ void transition(const QList<QQuickAction> &, QQuickTransition *transition, QObject *defaultTarget = 0);
+
+ void cancel();
+
+protected:
+ virtual void finished();
+
+private:
+ Q_DISABLE_COPY(QQuickTransitionManager)
+ QQuickTransitionManagerPrivate *d;
+
+ void complete();
+ void setState(QQuickState *);
+
+ friend class QQuickState;
+ friend class ParallelAnimationWrapper;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKTRANSITIONMANAGER_P_H
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
new file mode 100644
index 0000000000..4abbfe591d
--- /dev/null
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickutilmodule_p.h"
+#include "qquickanimation_p.h"
+#include "qquickanimation_p_p.h"
+#include "qquickbehavior_p.h"
+#include "qquickbind_p.h"
+#include "qquickconnections_p.h"
+#include "qquicksmoothedanimation_p.h"
+#include "qquickfontloader_p.h"
+#include "qquickpackage_p.h"
+#include "qquickpropertychanges_p.h"
+#include "qquickspringanimation_p.h"
+#include "qquickstategroup_p.h"
+#include "qquickstatechangescript_p.h"
+#include "qquickstate_p.h"
+#include "qquickstate_p_p.h"
+#include "qquicksystempalette_p.h"
+#include "qquicktimer_p.h"
+#include "qquicktransition_p.h"
+#include <qqmlinfo.h>
+#include <private/qqmltypenotavailable_p.h>
+#include <private/qquickanimationcontroller_p.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtGui/QInputMethod>
+
+void QQuickUtilModule::defineModule()
+{
+ qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputPanel",
+ QInputMethod::tr("InputPanel is an abstract class")); // deprecated
+ qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputMethod",
+ QInputMethod::tr("InputMethod is an abstract class"));
+ qmlRegisterUncreatableType<QQuickAbstractAnimation>("QtQuick",2,0,"Animation",QQuickAbstractAnimation::tr("Animation is an abstract class"));
+
+ qmlRegisterType<QQuickBehavior>("QtQuick",2,0,"Behavior");
+ qmlRegisterType<QQuickBind>("QtQuick",2,0,"Binding");
+ qmlRegisterType<QQuickColorAnimation>("QtQuick",2,0,"ColorAnimation");
+ qmlRegisterType<QQuickConnections>("QtQuick",2,0,"Connections");
+ qmlRegisterType<QQuickSmoothedAnimation>("QtQuick",2,0,"SmoothedAnimation");
+ qmlRegisterType<QQuickFontLoader>("QtQuick",2,0,"FontLoader");
+ qmlRegisterType<QQuickNumberAnimation>("QtQuick",2,0,"NumberAnimation");
+ qmlRegisterType<QQuickPackage>("QtQuick",2,0,"Package");
+ qmlRegisterType<QQuickParallelAnimation>("QtQuick",2,0,"ParallelAnimation");
+ qmlRegisterType<QQuickPauseAnimation>("QtQuick",2,0,"PauseAnimation");
+ qmlRegisterType<QQuickPropertyAction>("QtQuick",2,0,"PropertyAction");
+ qmlRegisterType<QQuickPropertyAnimation>("QtQuick",2,0,"PropertyAnimation");
+ qmlRegisterType<QQuickRotationAnimation>("QtQuick",2,0,"RotationAnimation");
+ qmlRegisterType<QQuickScriptAction>("QtQuick",2,0,"ScriptAction");
+ qmlRegisterType<QQuickSequentialAnimation>("QtQuick",2,0,"SequentialAnimation");
+ qmlRegisterType<QQuickSpringAnimation>("QtQuick",2,0,"SpringAnimation");
+ qmlRegisterType<QQuickAnimationController>("QtQuick",2,0,"AnimationController");
+ qmlRegisterType<QQuickStateChangeScript>("QtQuick",2,0,"StateChangeScript");
+ qmlRegisterType<QQuickStateGroup>("QtQuick",2,0,"StateGroup");
+ qmlRegisterType<QQuickState>("QtQuick",2,0,"State");
+ qmlRegisterType<QQuickSystemPalette>("QtQuick",2,0,"SystemPalette");
+ qmlRegisterType<QQuickTimer>("QtQuick",2,0,"Timer");
+ qmlRegisterType<QQuickTransition>("QtQuick",2,0,"Transition");
+ qmlRegisterType<QQuickVector3dAnimation>("QtQuick",2,0,"Vector3dAnimation");
+
+ qmlRegisterType<QQuickStateOperation>();
+
+ qmlRegisterCustomType<QQuickPropertyChanges>("QtQuick",2,0,"PropertyChanges", new QQuickPropertyChangesParser);
+ qmlRegisterCustomType<QQuickConnections>("QtQuick",2,0,"Connections", new QQmlConnectionsParser);
+}
diff --git a/src/quick/util/qquickutilmodule_p.h b/src/quick/util/qquickutilmodule_p.h
new file mode 100644
index 0000000000..dc0254370e
--- /dev/null
+++ b/src/quick/util/qquickutilmodule_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKUTILMODULE_H
+#define QQUICKUTILMODULE_H
+
+#include <qqml.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QQuickUtilModule
+{
+public:
+ static void defineModule();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQUICKUTILMODULE_H
diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri
index d933459596..c3cec91404 100644
--- a/src/quick/util/util.pri
+++ b/src/quick/util/util.pri
@@ -1,61 +1,61 @@
SOURCES += \
- $$PWD/qdeclarativeutilmodule.cpp\
- $$PWD/qdeclarativeconnections.cpp \
- $$PWD/qdeclarativepackage.cpp \
- $$PWD/qdeclarativeanimation.cpp \
- $$PWD/qdeclarativesystempalette.cpp \
- $$PWD/qdeclarativespringanimation.cpp \
- $$PWD/qdeclarativesmoothedanimation.cpp \
- $$PWD/qdeclarativeanimationcontroller.cpp \
- $$PWD/qdeclarativestate.cpp\
- $$PWD/qdeclarativetransitionmanager.cpp \
- $$PWD/qdeclarativestateoperations.cpp \
- $$PWD/qdeclarativepropertychanges.cpp \
- $$PWD/qdeclarativestategroup.cpp \
- $$PWD/qdeclarativetransition.cpp \
- $$PWD/qdeclarativelistaccessor.cpp \
- $$PWD/qdeclarativetimeline.cpp \
- $$PWD/qdeclarativetimer.cpp \
- $$PWD/qdeclarativebind.cpp \
- $$PWD/qdeclarativepixmapcache.cpp \
- $$PWD/qdeclarativebehavior.cpp \
- $$PWD/qdeclarativefontloader.cpp \
- $$PWD/qdeclarativestyledtext.cpp \
- $$PWD/qdeclarativepath.cpp \
- $$PWD/qdeclarativechangeset.cpp \
- $$PWD/qdeclarativelistcompositor.cpp \
- $$PWD/qdeclarativepathinterpolator.cpp \
- $$PWD/qdeclarativesvgparser.cpp
+ $$PWD/qquickutilmodule.cpp\
+ $$PWD/qquickconnections.cpp \
+ $$PWD/qquickpackage.cpp \
+ $$PWD/qquickanimation.cpp \
+ $$PWD/qquicksystempalette.cpp \
+ $$PWD/qquickspringanimation.cpp \
+ $$PWD/qquicksmoothedanimation.cpp \
+ $$PWD/qquickanimationcontroller.cpp \
+ $$PWD/qquickstate.cpp\
+ $$PWD/qquicktransitionmanager.cpp \
+ $$PWD/qquickstatechangescript.cpp \
+ $$PWD/qquickpropertychanges.cpp \
+ $$PWD/qquickstategroup.cpp \
+ $$PWD/qquicktransition.cpp \
+ $$PWD/qquicklistaccessor.cpp \
+ $$PWD/qquicktimeline.cpp \
+ $$PWD/qquicktimer.cpp \
+ $$PWD/qquickbind.cpp \
+ $$PWD/qquickpixmapcache.cpp \
+ $$PWD/qquickbehavior.cpp \
+ $$PWD/qquickfontloader.cpp \
+ $$PWD/qquickstyledtext.cpp \
+ $$PWD/qquickpath.cpp \
+ $$PWD/qquickchangeset.cpp \
+ $$PWD/qquicklistcompositor.cpp \
+ $$PWD/qquickpathinterpolator.cpp \
+ $$PWD/qquicksvgparser.cpp
HEADERS += \
- $$PWD/qdeclarativeutilmodule_p.h\
- $$PWD/qdeclarativeconnections_p.h \
- $$PWD/qdeclarativepackage_p.h \
- $$PWD/qdeclarativeanimation_p.h \
- $$PWD/qdeclarativeanimation_p_p.h \
- $$PWD/qdeclarativesystempalette_p.h \
- $$PWD/qdeclarativespringanimation_p.h \
- $$PWD/qdeclarativeanimationcontroller_p.h \
- $$PWD/qdeclarativesmoothedanimation_p.h \
- $$PWD/qdeclarativesmoothedanimation_p_p.h \
- $$PWD/qdeclarativestate_p.h\
- $$PWD/qdeclarativestateoperations_p.h \
- $$PWD/qdeclarativepropertychanges_p.h \
- $$PWD/qdeclarativestate_p_p.h\
- $$PWD/qdeclarativetransitionmanager_p_p.h \
- $$PWD/qdeclarativestategroup_p.h \
- $$PWD/qdeclarativetransition_p.h \
- $$PWD/qdeclarativelistaccessor_p.h \
- $$PWD/qdeclarativetimeline_p_p.h \
- $$PWD/qdeclarativetimer_p.h \
- $$PWD/qdeclarativebind_p.h \
- $$PWD/qdeclarativepixmapcache_p.h \
- $$PWD/qdeclarativebehavior_p.h \
- $$PWD/qdeclarativefontloader_p.h \
- $$PWD/qdeclarativestyledtext_p.h \
- $$PWD/qdeclarativepath_p.h \
- $$PWD/qdeclarativepath_p_p.h \
- $$PWD/qdeclarativechangeset_p.h \
- $$PWD/qdeclarativelistcompositor_p.h \
- $$PWD/qdeclarativepathinterpolator_p.h \
- $$PWD/qdeclarativesvgparser_p.h \ No newline at end of file
+ $$PWD/qquickutilmodule_p.h\
+ $$PWD/qquickconnections_p.h \
+ $$PWD/qquickpackage_p.h \
+ $$PWD/qquickanimation_p.h \
+ $$PWD/qquickanimation_p_p.h \
+ $$PWD/qquicksystempalette_p.h \
+ $$PWD/qquickspringanimation_p.h \
+ $$PWD/qquickanimationcontroller_p.h \
+ $$PWD/qquicksmoothedanimation_p.h \
+ $$PWD/qquicksmoothedanimation_p_p.h \
+ $$PWD/qquickstate_p.h\
+ $$PWD/qquickstatechangescript_p.h \
+ $$PWD/qquickpropertychanges_p.h \
+ $$PWD/qquickstate_p_p.h\
+ $$PWD/qquicktransitionmanager_p_p.h \
+ $$PWD/qquickstategroup_p.h \
+ $$PWD/qquicktransition_p.h \
+ $$PWD/qquicklistaccessor_p.h \
+ $$PWD/qquicktimeline_p_p.h \
+ $$PWD/qquicktimer_p.h \
+ $$PWD/qquickbind_p.h \
+ $$PWD/qquickpixmapcache_p.h \
+ $$PWD/qquickbehavior_p.h \
+ $$PWD/qquickfontloader_p.h \
+ $$PWD/qquickstyledtext_p.h \
+ $$PWD/qquickpath_p.h \
+ $$PWD/qquickpath_p_p.h \
+ $$PWD/qquickchangeset_p.h \
+ $$PWD/qquicklistcompositor_p.h \
+ $$PWD/qquickpathinterpolator_p.h \
+ $$PWD/qquicksvgparser_p.h
diff --git a/src/src.pro b/src/src.pro
index f8ef168260..0246eea409 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,9 +1,10 @@
TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS += declarative quick plugins
+SUBDIRS += qml quick plugins
contains(QT_CONFIG, qmltest): SUBDIRS += qmltest
SUBDIRS += imports
SUBDIRS += qmldevtools
+SUBDIRS += compatibility
diff --git a/sync.profile b/sync.profile
index 0265d1dbe9..7c7e1a5507 100644
--- a/sync.profile
+++ b/sync.profile
@@ -1,13 +1,15 @@
%modules = ( # path to module name map
- "QtDeclarative" => "$basedir/src/declarative",
+ "QtQml" => "$basedir/src/qml",
"QtQuick" => "$basedir/src/quick",
"QtQuickTest" => "$basedir/src/qmltest",
"QtQmlDevTools" => "$basedir/src/qmldevtools",
+ "QtDeclarative" => "$basedir/src/compatibility",
);
%moduleheaders = ( # restrict the module headers to those found in relative path
- "QtQmlDevTools" => "../declarative/qml/parser",
+ "QtQmlDevTools" => "../qml/qml/parser",
);
%classnames = (
+ "qtqmlversion.h" => "QtQmlVersion",
"qtdeclarativeversion.h" => "QtDeclarativeVersion",
);
%mastercontent = (
@@ -15,14 +17,197 @@
"script" => "#include <QtScript/QtScript>\n",
"network" => "#include <QtNetwork/QtNetwork>\n",
"testlib" => "#include <QtTest/QtTest>\n",
+ "qml" => "#include <QtQml/QtQml>\n",
);
%modulepris = (
- "QtDeclarative" => "$basedir/modules/qt_declarative.pri",
+ "QtQml" => "$basedir/modules/qt_qml.pri",
"QtQuick" => "$basedir/modules/qt_quick.pri",
"QtQuickTest" => "$basedir/modules/qt_qmltest.pri",
"QtQmlDevTools" => "$basedir/modules/qt_qmldevtools.pri",
+ "QtDeclarative" => "$basedir/modules/qt_declarative.pri",
);
%deprecatedheaders = (
+ "QtDeclarative" => {
+ "QtDeclarative" => "QtQml/QQml",
+ "qdeclarative.h" => "QtQml/qqml.h",
+ "qdeclarativeprivate.h" => "QtQml/qqmlprivate.h",
+ "QDeclarativeAttachedPropertiesFunc" => "QtQml/QQmlAttachedPropertiesFunc",
+ "QDeclarativeComponent" => "QtQml/QQmlComponent",
+ "qdeclarativecomponent.h" => "QtQml/qqmlcomponent.h",
+ "QDeclarativeContext" => "QtQml/QQmlContext",
+ "qdeclarativecontext.h" => "QtQml/qqmlcontext.h",
+ "QDeclarativeDebuggingEnabler" => "QtQml/QQmlDebuggingEnabler",
+ "qdeclarativedebug.h" => "QtQml/qqmldebug.h",
+ "QDeclarativeEngine" => "QtQml/QQmlEngine",
+ "qdeclarativeengine.h" => "QtQml/qqmlengine.h",
+ "QDeclarativeError" => "QtQml/QQmlError",
+ "qdeclarativeerror.h" => "QtQml/qqmlerror.h",
+ "QDeclarativeExpression" => "QtQml/QQmlExpression",
+ "qdeclarativeexpression.h" => "QtQml/qqmlexpression.h",
+ "QDeclarativeExtensionInterface" => "QtQml/QQmlExtensionInterface",
+ "qdeclarativeextensioninterface.h" => "QtQml/qqmlextensioninterface.h",
+ "QDeclarativeExtensionPlugin" => "QtQml/QQmlExtensionPlugin",
+ "qdeclarativeextensionplugin.h" => "QtQml/qqmlextensionplugin.h",
+ "QDeclarativeImageProvider" => "QtQml/QQmlImageProvider",
+ "qdeclarativeimageprovider.h" => "QtQml/qqmlimageprovider.h",
+ "QDeclarativeIncubationController" => "QtQml/QQmlIncubationController",
+ "QDeclarativeIncubator" => "QtQml/QQmlIncubator",
+ "qdeclarativeincubator.h" => "QtQml/qqmlincubator.h",
+ "QDeclarativeInfo" => "QtQml/QQmlInfo",
+ "qdeclarativeinfo.h" => "QtQml/qqmlinfo.h",
+ "qdeclarativelist.h" => "QtQml/qqmllist.h",
+ "QDeclarativeListProperty" => "QtQml/QQmlListProperty",
+ "QDeclarativeListReference" => "QtQml/QQmlListReference",
+ "QDeclarativeNetworkAccessManagerFactory" => "QtQml/QQmlNetworkAccessManagerFactory",
+ "qdeclarativenetworkaccessmanagerfactory.h" => "QtQml/qqmlnetworkaccessmanagerfactory.h",
+ "QDeclarativeParserStatus" => "QtQml/QQmlParserStatus",
+ "qdeclarativeparserstatus.h" => "QtQml/qqmlparserstatus.h",
+ "QDeclarativeProperties" => "QtQml/QQuickProperties",
+ "QDeclarativeProperty" => "QtQml/QQmlProperty",
+ "qdeclarativeproperty.h" => "QtQml/qqmlproperty.h",
+ "QDeclarativePropertyMap" => "QtQml/QQmlPropertyMap",
+ "qdeclarativepropertymap.h" => "QtQml/qqmlpropertymap.h",
+ "QDeclarativePropertyValueSource" => "QtQml/QQmlPropertyValueSource",
+ "qdeclarativepropertyvaluesource.h" => "QtQml/qqmlpropertyvaluesource.h",
+ "QDeclarativeScriptString" => "QtQml/QQmlScriptString",
+ "qdeclarativescriptstring.h" => "QtQml/qqmlscriptstring.h",
+ "QDeclarativeTextureFactory" => "QtQml/QQuickTextureFactory",
+ "QDeclarativeTypeInfo" => "QtQml/QQmlTypeInfo",
+ "QDeclarativeTypesExtensionInterface" => "QtQml/QQmlTypesExtensionInterface",
+ "QJSEngine" => "QtQml/QJSEngine",
+ "qjsengine.h" => "QtQml/qjsengine.h",
+ "QJSValue" => "QtQml/QJSValue",
+ "qjsvalue.h" => "QtQml/qjsvalue.h",
+ "QJSValueIterator" => "QtQml/QJSValueIterator",
+ "qjsvalueiterator.h" => "QtQml/qjsvalueiterator.h",
+ "QJSValueList" => "QtQml/QJSValueList",
+ "qintrusivelist_p.h" => "QtQml/private/qintrusivelist_p.h",
+ "qjsconverter_impl_p.h" => "QtQml/private/qjsconverter_impl_p.h",
+ "qjsconverter_p.h" => "QtQml/private/qjsconverter_p.h",
+ "qjsengine_p.h" => "QtQml/private/qjsengine_p.h",
+ "qjsvalue_impl_p.h" => "QtQml/private/qjsvalue_impl_p.h",
+ "qjsvalueiterator_impl_p.h" => "QtQml/private/qjsvalueiterator_impl_p.h",
+ "qjsvalueiterator_p.h" => "QtQml/private/qjsvalueiterator_p.h",
+ "qjsvalue_p.h" => "QtQml/private/qjsvalue_p.h",
+ "qlistmodelinterface_p.h" => "QtQml/private/qlistmodelinterface_p.h",
+ "qpacketprotocol_p.h" => "QtQml/private/qpacketprotocol_p.h",
+ "qparallelanimationgroupjob_p.h" => "QtQml/private/qparallelanimationgroupjob_p.h",
+ "qpauseanimationjob_p.h" => "QtQml/private/qpauseanimationjob_p.h",
+ "qpodvector_p.h" => "QtQml/private/qpodvector_p.h",
+ "qdeclarativeaccessors_p.h" => "QtQml/private/qqmlaccessors_p.h",
+ "qdeclarativebinding_p.h" => "QtQml/private/qqmlbinding_p.h",
+ "qdeclarativebinding_p_p.h" => "QtQml/private/qqmlbinding_p_p.h",
+ "qdeclarativeboundsignal_p.h" => "QtQml/private/qqmlboundsignal_p.h",
+ "qdeclarativebuiltinfunctions_p.h" => "QtQml/private/qqmlbuiltinfunctions_p.h",
+ "qdeclarativecleanup_p.h" => "QtQml/private/qqmlcleanup_p.h",
+ "qdeclarativecompiler_p.h" => "QtQml/private/qqmlcompiler_p.h",
+ "qdeclarativecomponentattached_p.h" => "QtQml/private/qqmlcomponentattached_p.h",
+ "qdeclarativecomponent_p.h" => "QtQml/private/qqmlcomponent_p.h",
+ "qdeclarativecontext_p.h" => "QtQml/private/qqmlcontext_p.h",
+ "qdeclarativecustomparser_p.h" => "QtQml/private/qqmlcustomparser_p.h",
+ "qdeclarativecustomparser_p_p.h" => "QtQml/private/qqmlcustomparser_p_p.h",
+ "qdeclarativedata_p.h" => "QtQml/private/qqmldata_p.h",
+ "qdeclarativedebugclient_p.h" => "QtQml/private/qqmldebugclient_p.h",
+ "qdeclarativedebughelper_p.h" => "QtQml/private/qqmldebughelper_p.h",
+ "qdeclarativedebugserverconnection_p.h" => "QtQml/private/qqmldebugserverconnection_p.h",
+ "qdeclarativedebugserver_p.h" => "QtQml/private/qqmldebugserver_p.h",
+ "qdeclarativedebugservice_p.h" => "QtQml/private/qqmldebugservice_p.h",
+ "qdeclarativedebugservice_p_p.h" => "QtQml/private/qqmldebugservice_p_p.h",
+ "qdeclarativedebugstatesdelegate_p.h" => "QtQml/private/qqmldebugstatesdelegate_p.h",
+ "qdeclarativedirparser_p.h" => "QtQml/private/qqmldirparser_p.h",
+ "qdeclarativeenginedebug_p.h" => "QtQml/private/qqmlenginedebug_p.h",
+ "qdeclarativeenginedebugservice_p.h" => "QtQml/private/qqmlenginedebugservice_p.h",
+ "qdeclarativeengine_p.h" => "QtQml/private/qqmlengine_p.h",
+ "qdeclarativeexpression_p.h" => "QtQml/private/qqmlexpression_p.h",
+ "qdeclarativeglobal_p.h" => "QtQml/private/qqmlglobal_p.h",
+ "qdeclarativeguard_p.h" => "QtQml/private/qqmlguard_p.h",
+ "qdeclarativeimport_p.h" => "QtQml/private/qqmlimport_p.h",
+ "qdeclarativeincubator_p.h" => "QtQml/private/qqmlincubator_p.h",
+ "qdeclarativeinspectorinterface_p.h" => "QtQml/private/qqmlinspectorinterface_p.h",
+ "qdeclarativeinspectorservice_p.h" => "QtQml/private/qqmlinspectorservice_p.h",
+ "qdeclarativeinstruction_p.h" => "QtQml/private/qqmlinstruction_p.h",
+ "qdeclarativeintegercache_p.h" => "QtQml/private/qqmlintegercache_p.h",
+ "qdeclarativejsastfwd_p.h" => "QtQml/private/qqmljsastfwd_p.h",
+ "qdeclarativejsast_p.h" => "QtQml/private/qqmljsast_p.h",
+ "qdeclarativejsastvisitor_p.h" => "QtQml/private/qqmljsastvisitor_p.h",
+ "qdeclarativejsengine_p.h" => "QtQml/private/qqmljsengine_p.h",
+ "qdeclarativejsglobal_p.h" => "QtQml/private/qqmljsglobal_p.h",
+ "qdeclarativejsgrammar_p.h" => "QtQml/private/qqmljsgrammar_p.h",
+ "qdeclarativejskeywords_p.h" => "QtQml/private/qqmljskeywords_p.h",
+ "qdeclarativejslexer_p.h" => "QtQml/private/qqmljslexer_p.h",
+ "qdeclarativejsmemorypool_p.h" => "QtQml/private/qqmljsmemorypool_p.h",
+ "qdeclarativejsparser_p.h" => "QtQml/private/qqmljsparser_p.h",
+ "qdeclarativelist_p.h" => "QtQml/private/qqmllist_p.h",
+ "qdeclarativelocale_p.h" => "QtQml/private/qqmllocale_p.h",
+ "qdeclarativemetatype_p.h" => "QtQml/private/qqmlmetatype_p.h",
+ "qdeclarativenotifier_p.h" => "QtQml/private/qqmlnotifier_p.h",
+ "qdeclarativenullablevalue_p_p.h" => "QtQml/private/qqmlnullablevalue_p_p.h",
+ "qdeclarativeopenmetaobject_p.h" => "QtQml/private/qqmlopenmetaobject_p.h",
+ "qdeclarativepool_p.h" => "QtQml/private/qqmlpool_p.h",
+ "qdeclarativeprofilerservice_p.h" => "QtQml/private/qqmlprofilerservice_p.h",
+ "qdeclarativepropertycache_p.h" => "QtQml/private/qqmlpropertycache_p.h",
+ "qdeclarativeproperty_p.h" => "QtQml/private/qqmlproperty_p.h",
+ "qdeclarativepropertyvalueinterceptor_p.h" => "QtQml/private/qqmlpropertyvalueinterceptor_p.h",
+ "qdeclarativeproxymetaobject_p.h" => "QtQml/private/qqmlproxymetaobject_p.h",
+ "qdeclarativerefcount_p.h" => "QtQml/private/qqmlrefcount_p.h",
+ "qdeclarativerewrite_p.h" => "QtQml/private/qqmlrewrite_p.h",
+ "qdeclarativescript_p.h" => "QtQml/private/qqmlscript_p.h",
+ "qdeclarativescriptstring_p.h" => "QtQml/private/qqmlscriptstring_p.h",
+ "qdeclarativestringconverters_p.h" => "QtQml/private/qqmlstringconverters_p.h",
+ "qdeclarativethread_p.h" => "QtQml/private/qqmlthread_p.h",
+ "qdeclarativetrace_p.h" => "QtQml/private/qqmltrace_p.h",
+ "qdeclarativetypeloader_p.h" => "QtQml/private/qqmltypeloader_p.h",
+ "qdeclarativetypenamecache_p.h" => "QtQml/private/qqmltypenamecache_p.h",
+ "qdeclarativetypenotavailable_p.h" => "QtQml/private/qqmltypenotavailable_p.h",
+ "qdeclarativevaluetype_p.h" => "QtQml/private/qqmlvaluetype_p.h",
+ "qdeclarativevmemetaobject_p.h" => "QtQml/private/qqmlvmemetaobject_p.h",
+ "qdeclarativevme_p.h" => "QtQml/private/qqmlvme_p.h",
+ "qdeclarativewatcher_p.h" => "QtQml/private/qqmlwatcher_p.h",
+ "qdeclarativexmlhttprequest_p.h" => "QtQml/private/qqmlxmlhttprequest_p.h",
+ "qdeclarativeapplication_p.h" => "QtQml/private/qquickapplication_p.h",
+ "qdeclarativelistmodel_p.h" => "QtQml/private/qquicklistmodel_p.h",
+ "qdeclarativelistmodel_p_p.h" => "QtQml/private/qquicklistmodel_p_p.h",
+ "qdeclarativelistmodelworkeragent_p.h" => "QtQml/private/qquicklistmodelworkeragent_p.h",
+ "qdeclarativeworkerscript_p.h" => "QtQml/private/qquickworkerscript_p.h",
+ "qrecursionwatcher_p.h" => "QtQml/private/qrecursionwatcher_p.h",
+ "qrecyclepool_p.h" => "QtQml/private/qrecyclepool_p.h",
+ "qscript_impl_p.h" => "QtQml/private/qscript_impl_p.h",
+ "qscriptisolate_p.h" => "QtQml/private/qscriptisolate_p.h",
+ "qscriptoriginalglobalobject_p.h" => "QtQml/private/qscriptoriginalglobalobject_p.h",
+ "qscriptshareddata_p.h" => "QtQml/private/qscriptshareddata_p.h",
+ "qscripttools_p.h" => "QtQml/private/qscripttools_p.h",
+ "qsequentialanimationgroupjob_p.h" => "QtQml/private/qsequentialanimationgroupjob_p.h",
+ "qv4bindings_p.h" => "QtQml/private/qv4bindings_p.h",
+ "qv4compiler_p.h" => "QtQml/private/qv4compiler_p.h",
+ "qv4compiler_p_p.h" => "QtQml/private/qv4compiler_p_p.h",
+ "qv4instruction_p.h" => "QtQml/private/qv4instruction_p.h",
+ "qv4irbuilder_p.h" => "QtQml/private/qv4irbuilder_p.h",
+ "qv4ir_p.h" => "QtQml/private/qv4ir_p.h",
+ "qv4program_p.h" => "QtQml/private/qv4program_p.h",
+ "qv8bindings_p.h" => "QtQml/private/qv8bindings_p.h",
+ "qv8contextwrapper_p.h" => "QtQml/private/qv8contextwrapper_p.h",
+ "qv8debug_p.h" => "QtQml/private/qv8debug_p.h",
+ "qv8debugservice_p.h" => "QtQml/private/qv8debugservice_p.h",
+ "qv8domerrors_p.h" => "QtQml/private/qv8domerrors_p.h",
+ "qv8engine_impl_p.h" => "QtQml/private/qv8engine_impl_p.h",
+ "qv8engine_p.h" => "QtQml/private/qv8engine_p.h",
+ "qv8include_p.h" => "QtQml/private/qv8include_p.h",
+ "qv8listwrapper_p.h" => "QtQml/private/qv8listwrapper_p.h",
+ "qv8_p.h" => "QtQml/private/qv8_p.h",
+ "qv8profiler_p.h" => "QtQml/private/qv8profiler_p.h",
+ "qv8profilerservice_p.h" => "QtQml/private/qv8profilerservice_p.h",
+ "qv8qobjectwrapper_p.h" => "QtQml/private/qv8qobjectwrapper_p.h",
+ "qv8sequencewrapper_p.h" => "QtQml/private/qv8sequencewrapper_p.h",
+ "qv8sequencewrapper_p_p.h" => "QtQml/private/qv8sequencewrapper_p_p.h",
+ "qv8sqlerrors_p.h" => "QtQml/private/qv8sqlerrors_p.h",
+ "qv8stringwrapper_p.h" => "QtQml/private/qv8stringwrapper_p.h",
+ "qv8typewrapper_p.h" => "QtQml/private/qv8typewrapper_p.h",
+ "qv8valuetypewrapper_p.h" => "QtQml/private/qv8valuetypewrapper_p.h",
+ "qv8variantresource_p.h" => "QtQml/private/qv8variantresource_p.h",
+ "qv8variantwrapper_p.h" => "QtQml/private/qv8variantwrapper_p.h",
+ "qv8worker_p.h" => "QtQml/private/qv8worker_p.h",
+ "textwriter_p.h" => "QtQml/private/textwriter_p.h",
+ },
);
# Module dependencies.
# Every module that is required to build this module should have one entry.
@@ -31,7 +216,7 @@
# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
#
%dependencies = (
- "qtbase" => "95c5be8bc1c8f9ff8e7f95e52a8abd3cd7976ba1",
+ "qtbase" => "refs/heads/api_changes",
"qtxmlpatterns" => "refs/heads/master",
"qtjsbackend" => "refs/heads/master",
);
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 367b2e724b..5012b5cdec 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,7 +1,7 @@
TEMPLATE=subdirs
SUBDIRS=\
- declarative \
- qtquick2 \
+ qml \
+ quick \
particles \
qmldevtools
diff --git a/tests/auto/compilerwarnings/data/test_cpp.txt b/tests/auto/compilerwarnings/data/test_cpp.txt
index c74bb20fdb..01b3bf9980 100644
--- a/tests/auto/compilerwarnings/data/test_cpp.txt
+++ b/tests/auto/compilerwarnings/data/test_cpp.txt
@@ -40,7 +40,7 @@
****************************************************************************/
#ifndef QT_NO_DECLARATIVE
-#include <QtDeclarative/QtDeclarative>
+#include <QtQml/QtQml>
#endif
#ifndef Q_OS_MAC
diff --git a/tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro b/tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro
deleted file mode 100644
index db8649bbb9..0000000000
--- a/tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase parallel_test
-macx:CONFIG -= app_bundle
-TARGET = tst_qabstractanimationjob
-QT = core-private declarative-private testlib
-SOURCES = tst_qabstractanimationjob.cpp
diff --git a/tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp b/tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp
deleted file mode 100644
index 772605d494..0000000000
--- a/tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtDeclarative/private/qabstractanimationjob_p.h>
-#include <QtDeclarative/private/qanimationgroupjob_p.h>
-#include <QtTest>
-
-class tst_QAbstractAnimationJob : public QObject
-{
- Q_OBJECT
-private slots:
- void construction();
- void destruction();
- void currentLoop();
- void currentLoopTime();
- void currentTime();
- void direction();
- void group();
- void loopCount();
- void state();
- void totalDuration();
- void avoidJumpAtStart();
- void avoidJumpAtStartWithStop();
- void avoidJumpAtStartWithRunning();
-};
-
-class TestableQAbstractAnimation : public QAbstractAnimationJob
-{
-public:
- TestableQAbstractAnimation() : m_duration(10) {}
- virtual ~TestableQAbstractAnimation() {};
-
- int duration() const { return m_duration; }
- virtual void updateCurrentTime(int) {}
-
- void setDuration(int duration) { m_duration = duration; }
-private:
- int m_duration;
-};
-
-class DummyQAnimationGroup : public QAnimationGroupJob
-{
-public:
- int duration() const { return 10; }
- virtual void updateCurrentTime(int) {}
-};
-
-void tst_QAbstractAnimationJob::construction()
-{
- TestableQAbstractAnimation anim;
-}
-
-void tst_QAbstractAnimationJob::destruction()
-{
- TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
- delete anim;
-}
-
-void tst_QAbstractAnimationJob::currentLoop()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.currentLoop(), 0);
-}
-
-void tst_QAbstractAnimationJob::currentLoopTime()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.currentLoopTime(), 0);
-}
-
-void tst_QAbstractAnimationJob::currentTime()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.currentTime(), 0);
- anim.setCurrentTime(10);
- QCOMPARE(anim.currentTime(), 10);
-}
-
-void tst_QAbstractAnimationJob::direction()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward);
- anim.setDirection(QAbstractAnimationJob::Backward);
- QCOMPARE(anim.direction(), QAbstractAnimationJob::Backward);
- anim.setDirection(QAbstractAnimationJob::Forward);
- QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward);
-}
-
-void tst_QAbstractAnimationJob::group()
-{
- TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
- DummyQAnimationGroup group;
- group.appendAnimation(anim);
- QCOMPARE(anim->group(), &group);
-}
-
-void tst_QAbstractAnimationJob::loopCount()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.loopCount(), 1);
- anim.setLoopCount(10);
- QCOMPARE(anim.loopCount(), 10);
-}
-
-void tst_QAbstractAnimationJob::state()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.state(), QAbstractAnimationJob::Stopped);
-}
-
-void tst_QAbstractAnimationJob::totalDuration()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.duration(), 10);
- anim.setLoopCount(5);
- QCOMPARE(anim.totalDuration(), 50);
-}
-
-void tst_QAbstractAnimationJob::avoidJumpAtStart()
-{
- TestableQAbstractAnimation anim;
- anim.setDuration(1000);
-
- /*
- the timer shouldn't actually start until we hit the event loop,
- so the sleep should have no effect
- */
- anim.start();
- QTest::qSleep(300);
- QCoreApplication::processEvents();
- QVERIFY(anim.currentTime() < 50);
-}
-
-void tst_QAbstractAnimationJob::avoidJumpAtStartWithStop()
-{
- TestableQAbstractAnimation anim;
- anim.setDuration(1000);
-
- TestableQAbstractAnimation anim2;
- anim2.setDuration(1000);
-
- TestableQAbstractAnimation anim3;
- anim3.setDuration(1000);
-
- anim.start();
- QTest::qWait(300);
- anim.stop();
-
- /*
- same test as avoidJumpAtStart, but after there is a
- running animation that is stopped
- */
- anim2.start();
- QTest::qSleep(300);
- anim3.start();
- QCoreApplication::processEvents();
- QVERIFY(anim2.currentTime() < 50);
- QVERIFY(anim3.currentTime() < 50);
-}
-
-void tst_QAbstractAnimationJob::avoidJumpAtStartWithRunning()
-{
- TestableQAbstractAnimation anim;
- anim.setDuration(2000);
-
- TestableQAbstractAnimation anim2;
- anim2.setDuration(1000);
-
- TestableQAbstractAnimation anim3;
- anim3.setDuration(1000);
-
- anim.start();
- QTest::qWait(300); //make sure timer has started
-
- /*
- same test as avoidJumpAtStart, but with an
- existing running animation
- */
- anim2.start();
- QTest::qSleep(300); //force large delta for next tick
- anim3.start();
- QCoreApplication::processEvents();
- QVERIFY(anim2.currentTime() < 50);
- QVERIFY(anim3.currentTime() < 50);
-}
-
-
-QTEST_MAIN(tst_QAbstractAnimationJob)
-
-#include "tst_qabstractanimationjob.moc"
diff --git a/tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro b/tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro
deleted file mode 100644
index b9c9d2921d..0000000000
--- a/tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase parallel_test
-macx:CONFIG -= app_bundle
-TARGET = tst_qanimationgroupjob
-QT = core-private declarative-private testlib
-SOURCES = tst_qanimationgroupjob.cpp
diff --git a/tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
deleted file mode 100644
index 2bb974af7d..0000000000
--- a/tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include <QtDeclarative/private/qanimationgroupjob_p.h>
-#include <QtDeclarative/private/qsequentialanimationgroupjob_p.h>
-#include <QtDeclarative/private/qparallelanimationgroupjob_p.h>
-
-Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
-
-class tst_QAnimationGroupJob : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void initTestCase();
-
-private slots:
- void construction();
- void emptyGroup();
- void setCurrentTime();
- void addChildTwice();
-};
-
-void tst_QAnimationGroupJob::initTestCase()
-{
- qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
-}
-
-void tst_QAnimationGroupJob::construction()
-{
- QSequentialAnimationGroupJob animationgroup;
-}
-
-class TestableGenericAnimation : public QAbstractAnimationJob
-{
-public:
- TestableGenericAnimation(int duration = 250) : m_duration(duration) {}
- int duration() const { return m_duration; }
-
-private:
- int m_duration;
-};
-
-class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
-{
- Q_OBJECT
-public:
- UncontrolledAnimation()
- : id(0)
- {
- }
-
- int duration() const { return -1; /* not time driven */ }
-
-protected:
- void timerEvent(QTimerEvent *event)
- {
- if (event->timerId() == id)
- stop();
- }
-
- void updateRunning(bool running)
- {
- if (running) {
- id = startTimer(500);
- } else {
- killTimer(id);
- id = 0;
- }
- }
-
-private:
- int id;
-};
-
-class StateChangeListener: public QAnimationJobChangeListener
-{
-public:
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
- {
- states << newState;
- }
-
- int count()
- {
- return states.count();
- }
-
- QList<QAbstractAnimationJob::State> states;
-};
-
-void tst_QAnimationGroupJob::emptyGroup()
-{
- QSequentialAnimationGroupJob group;
- StateChangeListener groupStateChangedSpy;
- group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- group.start();
-
- QCOMPARE(groupStateChangedSpy.count(), 2);
-
- QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(groupStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
-
- QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimationJob::pause: Cannot pause a stopped animation");
- group.pause();
-
- QCOMPARE(groupStateChangedSpy.count(), 2);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
-
- group.start();
-
- QCOMPARE(groupStateChangedSpy.states.at(2),
- QAnimationGroupJob::Running);
- QCOMPARE(groupStateChangedSpy.states.at(3),
- QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
-
- group.stop();
-
- QCOMPARE(groupStateChangedSpy.count(), 4);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QAnimationGroupJob::setCurrentTime()
-{
- // was originally sequence operating on same object/property
- QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- QAbstractAnimationJob *a1_s_o1 = new TestableGenericAnimation;
- QAbstractAnimationJob *a2_s_o1 = new TestableGenericAnimation;
- QAbstractAnimationJob *a3_s_o1 = new TestableGenericAnimation;
- a2_s_o1->setLoopCount(3);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
-
- // was originally sequence operating on different object/properties
- QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
- QAbstractAnimationJob *a1_s_o2 = new TestableGenericAnimation;
- QAbstractAnimationJob *a1_s_o3 = new TestableGenericAnimation;
- sequence2->appendAnimation(a1_s_o2);
- sequence2->appendAnimation(a1_s_o3);
-
- // was originally parallel operating on different object/properties
- QAnimationGroupJob *parallel = new QParallelAnimationGroupJob();
- QAbstractAnimationJob *a1_p_o1 = new TestableGenericAnimation;
- QAbstractAnimationJob *a1_p_o2 = new TestableGenericAnimation;
- QAbstractAnimationJob *a1_p_o3 = new TestableGenericAnimation;
- a1_p_o2->setLoopCount(3);
- parallel->appendAnimation(a1_p_o1);
- parallel->appendAnimation(a1_p_o2);
- parallel->appendAnimation(a1_p_o3);
-
- QAbstractAnimationJob *notTimeDriven = new UncontrolledAnimation;
- QCOMPARE(notTimeDriven->totalDuration(), -1);
-
- QAbstractAnimationJob *loopsForever = new TestableGenericAnimation;
- loopsForever->setLoopCount(-1);
- QCOMPARE(loopsForever->totalDuration(), -1);
-
- QParallelAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(sequence2);
- group.appendAnimation(parallel);
- group.appendAnimation(notTimeDriven);
- group.appendAnimation(loopsForever);
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 1);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
- QCOMPARE(a1_p_o1->currentLoopTime(), 1);
- QCOMPARE(a1_p_o2->currentLoopTime(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 1);
- QCOMPARE(notTimeDriven->currentLoopTime(), 1);
- QCOMPARE(loopsForever->currentLoopTime(), 1);
-
- // Current time = 250
- group.setCurrentTime(250);
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(sequence->currentLoopTime(), 250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
- QCOMPARE(a1_p_o1->currentLoopTime(), 250);
- QCOMPARE(a1_p_o2->currentLoopTime(), 0);
- QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 250);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoop(), 1);
- QCOMPARE(sequence->currentAnimation(), a2_s_o1);
-
- // Current time = 251
- group.setCurrentTime(251);
- QCOMPARE(group.currentLoopTime(), 251);
- QCOMPARE(sequence->currentLoopTime(), 251);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 251);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 1);
- QCOMPARE(a1_p_o1->currentLoopTime(), 250);
- QCOMPARE(a1_p_o2->currentLoopTime(), 1);
- QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 251);
- QCOMPARE(loopsForever->currentLoopTime(), 1);
- QCOMPARE(sequence->currentAnimation(), a2_s_o1);
-}
-
-void tst_QAnimationGroupJob::addChildTwice()
-{
- QAbstractAnimationJob *subGroup;
- QAbstractAnimationJob *subGroup2;
- QAnimationGroupJob *parent = new QSequentialAnimationGroupJob();
-
- subGroup = new QAbstractAnimationJob;
- parent->appendAnimation(subGroup);
- parent->appendAnimation(subGroup);
- QVERIFY(parent->firstChild() && !parent->firstChild()->nextSibling());
-
- parent->clear();
-
- QVERIFY(!parent->firstChild());
-
- // adding the same item twice to a group will remove the item from its current position
- // and append it to the end
- subGroup = new QAbstractAnimationJob;
- parent->appendAnimation(subGroup);
- subGroup2 = new QAbstractAnimationJob;
- parent->appendAnimation(subGroup2);
-
- QCOMPARE(parent->firstChild(), subGroup);
- QCOMPARE(parent->lastChild(), subGroup2);
-
- parent->appendAnimation(subGroup);
-
- QCOMPARE(parent->firstChild(), subGroup2);
- QCOMPARE(parent->lastChild(), subGroup);
-
- delete parent;
-}
-
-QTEST_MAIN(tst_QAnimationGroupJob)
-#include "tst_qanimationgroupjob.moc"
diff --git a/tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro b/tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro
deleted file mode 100644
index 332fa4554b..0000000000
--- a/tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-TARGET = tst_qparallelanimationgroupjob
-QT = core-private gui declarative-private testlib
-SOURCES = tst_qparallelanimationgroupjob.cpp
diff --git a/tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
deleted file mode 100644
index ef24182115..0000000000
--- a/tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
+++ /dev/null
@@ -1,931 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include <QtDeclarative/private/qparallelanimationgroupjob_p.h>
-
-Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
-
-class tst_QParallelAnimationGroupJob : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void initTestCase();
-
-private slots:
- void construction();
- void setCurrentTime();
- void stateChanged();
- void clearGroup();
- void propagateGroupUpdateToChildren();
- void updateChildrenWithRunningGroup();
- void deleteChildrenWithRunningGroup();
- void startChildrenWithStoppedGroup();
- void stopGroupWithRunningChild();
- void startGroupWithRunningChild();
- void zeroDurationAnimation();
- void stopUncontrolledAnimations();
- void loopCount_data();
- void loopCount();
- void addAndRemoveDuration();
- void pauseResume();
-
- void crashWhenRemovingUncontrolledAnimation();
-};
-
-void tst_QParallelAnimationGroupJob::initTestCase()
-{
- qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
-#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
- // give the mac/wince app start event queue time to clear
- QTest::qWait(1000);
-#endif
-}
-
-void tst_QParallelAnimationGroupJob::construction()
-{
- QParallelAnimationGroupJob animationgroup;
-}
-
-class TestAnimation : public QAbstractAnimationJob
-{
-public:
- TestAnimation(int duration = 250) : m_duration(duration) {}
- int duration() const { return m_duration; }
-
-private:
- int m_duration;
-};
-
-class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
-{
- Q_OBJECT
-public:
- UncontrolledAnimation()
- : id(0)
- {
- }
-
- int duration() const { return -1; /* not time driven */ }
-
-protected:
- void timerEvent(QTimerEvent *event)
- {
- if (event->timerId() == id)
- stop();
- }
-
- void updateRunning(bool running)
- {
- if (running) {
- id = startTimer(500);
- } else {
- killTimer(id);
- id = 0;
- }
- }
-
-private:
- int id;
-};
-
-class StateChangeListener: public QAnimationJobChangeListener
-{
-public:
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
- {
- states << newState;
- }
-
- void clear() { states.clear(); }
- int count() { return states.count(); }
-
- QList<QAbstractAnimationJob::State> states;
-};
-
-class FinishedListener: public QAnimationJobChangeListener
-{
-public:
- FinishedListener() : m_count(0) {}
-
- virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; }
- void clear() { m_count = 0; }
- int count() { return m_count; }
-
-private:
- int m_count;
-};
-
-void tst_QParallelAnimationGroupJob::setCurrentTime()
-{
- // originally was parallel operating on different object/properties
- QAnimationGroupJob *parallel = new QParallelAnimationGroupJob();
- TestAnimation *a1_p_o1 = new TestAnimation;
- TestAnimation *a1_p_o2 = new TestAnimation;
- TestAnimation *a1_p_o3 = new TestAnimation;
- a1_p_o2->setLoopCount(3);
- parallel->appendAnimation(a1_p_o1);
- parallel->appendAnimation(a1_p_o2);
- parallel->appendAnimation(a1_p_o3);
-
- UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation;
- QCOMPARE(notTimeDriven->totalDuration(), -1);
-
- TestAnimation *loopsForever = new TestAnimation;
- loopsForever->setLoopCount(-1);
- QCOMPARE(loopsForever->totalDuration(), -1);
-
- QParallelAnimationGroupJob group;
- group.appendAnimation(parallel);
- group.appendAnimation(notTimeDriven);
- group.appendAnimation(loopsForever);
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(a1_p_o1->currentLoopTime(), 1);
- QCOMPARE(a1_p_o2->currentLoopTime(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 1);
- QCOMPARE(notTimeDriven->currentLoopTime(), 1);
- QCOMPARE(loopsForever->currentLoopTime(), 1);
-
- // Current time = 250
- group.setCurrentTime(250);
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(a1_p_o1->currentLoopTime(), 250);
- QCOMPARE(a1_p_o2->currentLoopTime(), 0);
- QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 250);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoop(), 1);
-
- // Current time = 251
- group.setCurrentTime(251);
- QCOMPARE(group.currentLoopTime(), 251);
- QCOMPARE(a1_p_o1->currentLoopTime(), 250);
- QCOMPARE(a1_p_o2->currentLoopTime(), 1);
- QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 251);
- QCOMPARE(loopsForever->currentLoopTime(), 1);
-}
-
-void tst_QParallelAnimationGroupJob::stateChanged()
-{
- //this ensures that the correct animations are started when starting the group
- TestAnimation *anim1 = new TestAnimation(1000);
- TestAnimation *anim2 = new TestAnimation(2000);
- TestAnimation *anim3 = new TestAnimation(3000);
- TestAnimation *anim4 = new TestAnimation(3000);
-
- QParallelAnimationGroupJob group;
- group.appendAnimation(anim1);
- group.appendAnimation(anim2);
- group.appendAnimation(anim3);
- group.appendAnimation(anim4);
-
- StateChangeListener spy1;
- anim1->addAnimationChangeListener(&spy1, QAbstractAnimationJob::StateChange);
- StateChangeListener spy2;
- anim2->addAnimationChangeListener(&spy2, QAbstractAnimationJob::StateChange);
- StateChangeListener spy3;
- anim3->addAnimationChangeListener(&spy3, QAbstractAnimationJob::StateChange);
- StateChangeListener spy4;
- anim4->addAnimationChangeListener(&spy4, QAbstractAnimationJob::StateChange);
-
- //first; let's start forward
- group.start();
- //all the animations should be started
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy1.states.last(), TestAnimation::Running);
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy2.states.last(), TestAnimation::Running);
- QCOMPARE(spy3.count(), 1);
- QCOMPARE(spy3.states.last(), TestAnimation::Running);
- QCOMPARE(spy4.count(), 1);
- QCOMPARE(spy4.states.last(), TestAnimation::Running);
-
- group.setCurrentTime(1500); //anim1 should be finished
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 2);
- QCOMPARE(spy1.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy2.count(), 1); //no change
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
-
- group.setCurrentTime(2500); //anim2 should be finished
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 2); //no change
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy2.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
-
- group.setCurrentTime(3500); //everything should be finished
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(spy1.count(), 2); //no change
- QCOMPARE(spy2.count(), 2); //no change
- QCOMPARE(spy3.count(), 2);
- QCOMPARE(spy3.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy4.count(), 2);
- QCOMPARE(spy4.states.last(), TestAnimation::Stopped);
-
- //cleanup
- spy1.clear();
- spy2.clear();
- spy3.clear();
- spy4.clear();
-
- //now let's try to reverse that
- group.setDirection(QAbstractAnimationJob::Backward);
- group.start();
-
- //only anim3 and anim4 should be started
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 0);
- QCOMPARE(spy2.count(), 0);
- QCOMPARE(spy3.count(), 1);
- QCOMPARE(spy3.states.last(), TestAnimation::Running);
- QCOMPARE(spy4.count(), 1);
- QCOMPARE(spy4.states.last(), TestAnimation::Running);
-
- group.setCurrentTime(1500); //anim2 should be started
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 0); //no change
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy2.states.last(), TestAnimation::Running);
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
-
- group.setCurrentTime(500); //anim1 is finally also started
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy1.states.last(), TestAnimation::Running);
- QCOMPARE(spy2.count(), 1); //no change
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
-
- group.setCurrentTime(0); //everything should be stopped
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(spy1.count(), 2);
- QCOMPARE(spy1.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy2.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy3.count(), 2);
- QCOMPARE(spy3.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy4.count(), 2);
- QCOMPARE(spy4.states.last(), TestAnimation::Stopped);
-}
-
-void tst_QParallelAnimationGroupJob::clearGroup()
-{
- QParallelAnimationGroupJob group;
- static const int animationCount = 10;
-
- for (int i = 0; i < animationCount; ++i) {
- group.appendAnimation(new QParallelAnimationGroupJob);
- }
-
- int count = 0;
- for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
- ++count;
- QCOMPARE(count, animationCount);
-
- group.clear();
-
- QVERIFY(!group.firstChild() && !group.lastChild());
- QCOMPARE(group.currentLoopTime(), 0);
-}
-
-void tst_QParallelAnimationGroupJob::propagateGroupUpdateToChildren()
-{
- // this test verifies if group state changes are updating its children correctly
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(100);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
-
- group.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QParallelAnimationGroupJob::updateChildrenWithRunningGroup()
-{
- // assert that its possible to modify a child's state directly while their group is running
- QParallelAnimationGroupJob group;
-
- TestAnimation anim(200);
-
- StateChangeListener groupStateChangedSpy;
- group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
- StateChangeListener childStateChangedSpy;
- anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(groupStateChangedSpy.count(), 0);
- QCOMPARE(childStateChangedSpy.count(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Running);
-
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
-
- QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
-
- // starting directly a running child will not have any effect
- anim.start();
-
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
-
- anim.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Paused);
-
- // in the animation stops directly, the group will still be running
- anim.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
-
- //cleanup
- group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
- anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QParallelAnimationGroupJob::deleteChildrenWithRunningGroup()
-{
- // test if children can be activated when their group is stopped
- QParallelAnimationGroupJob group;
-
- TestAnimation *anim1 = new TestAnimation(200);
- group.appendAnimation(anim1);
-
- QCOMPARE(group.duration(), anim1->duration());
-
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
-
- QTest::qWait(80);
- QVERIFY(group.currentLoopTime() > 0);
-
- delete anim1;
- QVERIFY(!group.firstChild());
- QCOMPARE(group.duration(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
-}
-
-void tst_QParallelAnimationGroupJob::startChildrenWithStoppedGroup()
-{
- // test if children can be activated when their group is stopped
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-}
-
-void tst_QParallelAnimationGroupJob::stopGroupWithRunningChild()
-{
- // children that started independently will not be affected by a group stop
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- anim1.stop();
- anim2.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QParallelAnimationGroupJob::startGroupWithRunningChild()
-{
- // as the group has precedence over its children, starting a group will restart all the children
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- StateChangeListener stateChangedSpy1;
- anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- StateChangeListener stateChangedSpy2;
- anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(stateChangedSpy1.count(), 0);
- QCOMPARE(stateChangedSpy2.count(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy2.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy2.states.at(1), QAnimationGroupJob::Paused);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- group.start();
-
- QCOMPARE(stateChangedSpy1.count(), 3);
- QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped);
- QCOMPARE(stateChangedSpy1.states.at(2), QAnimationGroupJob::Running);
-
- QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped);
- QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
-
- //cleanup
- anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QParallelAnimationGroupJob::zeroDurationAnimation()
-{
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(0);
- TestAnimation anim2(100);
- TestAnimation anim3(10);
-
- StateChangeListener stateChangedSpy1;
- anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- FinishedListener finishedSpy1;
- anim1.addAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion);
-
- StateChangeListener stateChangedSpy2;
- anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
- FinishedListener finishedSpy2;
- anim2.addAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion);
-
- StateChangeListener stateChangedSpy3;
- anim3.addAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange);
- FinishedListener finishedSpy3;
- anim3.addAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
- group.appendAnimation(&anim3);
- QCOMPARE(stateChangedSpy1.count(), 0);
- group.start();
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(finishedSpy1.count(), 1);
- QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped);
-
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(finishedSpy2.count(), 0);
- QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
-
- QCOMPARE(stateChangedSpy3.count(), 1);
- QCOMPARE(finishedSpy3.count(), 0);
- QCOMPARE(stateChangedSpy3.states.at(0), QAnimationGroupJob::Running);
-
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim3.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
-
- group.stop();
- group.setLoopCount(4);
- stateChangedSpy1.clear();
- stateChangedSpy2.clear();
- stateChangedSpy3.clear();
-
- group.start();
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(stateChangedSpy3.count(), 1);
- group.setCurrentTime(50);
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(stateChangedSpy3.count(), 2);
- group.setCurrentTime(150);
- QCOMPARE(stateChangedSpy1.count(), 4);
- QCOMPARE(stateChangedSpy2.count(), 3);
- QCOMPARE(stateChangedSpy3.count(), 4);
- group.setCurrentTime(50);
- QCOMPARE(stateChangedSpy1.count(), 6);
- QCOMPARE(stateChangedSpy2.count(), 5);
- QCOMPARE(stateChangedSpy3.count(), 6);
-
- //cleanup
- anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- anim1.removeAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion);
- anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
- anim2.removeAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion);
- anim3.removeAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange);
- anim3.removeAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion);
-}
-
-void tst_QParallelAnimationGroupJob::stopUncontrolledAnimations()
-{
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(0);
-
- UncontrolledAnimation notTimeDriven;
- QCOMPARE(notTimeDriven.totalDuration(), -1);
-
- TestAnimation loopsForever(100);
- loopsForever.setLoopCount(-1);
-
- StateChangeListener stateChangedSpy;
- anim1.addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&notTimeDriven);
- group.appendAnimation(&loopsForever);
-
- group.start();
-
- QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
-
- notTimeDriven.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
-
- loopsForever.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
-}
-
-struct AnimState {
- AnimState(int time = -1) : time(time), state(-1) {}
- AnimState(int time, int state) : time(time), state(state) {}
- int time;
- int state;
-};
-
-#define Running QAbstractAnimationJob::Running
-#define Stopped QAbstractAnimationJob::Stopped
-
-Q_DECLARE_METATYPE(AnimState)
-void tst_QParallelAnimationGroupJob::loopCount_data()
-{
- QTest::addColumn<bool>("directionBackward");
- QTest::addColumn<int>("setLoopCount");
- QTest::addColumn<int>("initialGroupTime");
- QTest::addColumn<int>("currentGroupTime");
- QTest::addColumn<AnimState>("expected1");
- QTest::addColumn<AnimState>("expected2");
- QTest::addColumn<AnimState>("expected3");
-
- // D U R A T I O N
- // 100 60*2 0
- // direction = Forward
- QTest::newRow("50") << false << 3 << 0 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("100") << false << 3 << 0 << 100 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("110") << false << 3 << 0 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("120") << false << 3 << 0 << 120 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
-
- QTest::newRow("170") << false << 3 << 0 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("220") << false << 3 << 0 << 220 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("230") << false << 3 << 0 << 230 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("240") << false << 3 << 0 << 240 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
-
- QTest::newRow("290") << false << 3 << 0 << 290 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("340") << false << 3 << 0 << 340 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("350") << false << 3 << 0 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("360") << false << 3 << 0 << 360 << AnimState(100, Stopped) << AnimState( 60 ) << AnimState( 0, Stopped);
-
- QTest::newRow("410") << false << 3 << 0 << 410 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
- QTest::newRow("460") << false << 3 << 0 << 460 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
- QTest::newRow("470") << false << 3 << 0 << 470 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
- QTest::newRow("480") << false << 3 << 0 << 480 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
-
- // direction = Forward, rewind
- QTest::newRow("120-110") << false << 3 << 120 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("120-50") << false << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("120-0") << false << 3 << 120 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
- QTest::newRow("300-110") << false << 3 << 300 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("300-50") << false << 3 << 300 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("300-0") << false << 3 << 300 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
- QTest::newRow("115-105") << false << 3 << 115 << 105 << AnimState( 42, Stopped) << AnimState( 45, Running) << AnimState( 0, Stopped);
-
- // direction = Backward
- QTest::newRow("b120-120") << true << 3 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
- QTest::newRow("b120-110") << true << 3 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("b120-100") << true << 3 << 120 << 100 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("b120-50") << true << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("b120-0") << true << 3 << 120 << 0 << AnimState( 0, Stopped) << AnimState( 0, Stopped) << AnimState( 0, Stopped);
- QTest::newRow("b360-170") << true << 3 << 360 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("b360-220") << true << 3 << 360 << 220 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("b360-210") << true << 3 << 360 << 210 << AnimState( 90, Running) << AnimState( 30, Running) << AnimState( 0, Stopped);
- QTest::newRow("b360-120") << true << 3 << 360 << 120 << AnimState( 0, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
-
- // rewind, direction = Backward
- QTest::newRow("b50-110") << true << 3 << 50 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-120") << true << 3 << 50 << 120 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-140") << true << 3 << 50 << 140 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-240") << true << 3 << 50 << 240 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-260") << true << 3 << 50 << 260 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-350") << true << 3 << 50 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
-
- // infinite looping
- QTest::newRow("inf1220") << false << -1 << 0 << 1220 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
- QTest::newRow("inf1310") << false << -1 << 0 << 1310 << AnimState( 100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- // infinite looping, direction = Backward (will only loop once)
- QTest::newRow("b.inf120-120") << true << -1 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
- QTest::newRow("b.inf120-20") << true << -1 << 120 << 20 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
- QTest::newRow("b.inf120-110") << true << -1 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
-
-
-}
-
-void tst_QParallelAnimationGroupJob::loopCount()
-{
- QFETCH(bool, directionBackward);
- QFETCH(int, setLoopCount);
- QFETCH(int, initialGroupTime);
- QFETCH(int, currentGroupTime);
- QFETCH(AnimState, expected1);
- QFETCH(AnimState, expected2);
- QFETCH(AnimState, expected3);
-
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(100);
- TestAnimation anim2(60); //total 120
- anim2.setLoopCount(2);
- TestAnimation anim3(0);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
- group.appendAnimation(&anim3);
-
- group.setLoopCount(setLoopCount);
- if (initialGroupTime >= 0)
- group.setCurrentTime(initialGroupTime);
- if (directionBackward)
- group.setDirection(QAbstractAnimationJob::Backward);
-
- group.start();
- if (initialGroupTime >= 0)
- group.setCurrentTime(initialGroupTime);
-
- anim1.setCurrentTime(42); // 42 is "untouched"
- anim2.setCurrentTime(42);
-
- group.setCurrentTime(currentGroupTime);
-
- QCOMPARE(anim1.currentLoopTime(), expected1.time);
- QCOMPARE(anim2.currentLoopTime(), expected2.time);
- QCOMPARE(anim3.currentLoopTime(), expected3.time);
-
- if (expected1.state >=0)
- QCOMPARE(int(anim1.state()), expected1.state);
- if (expected2.state >=0)
- QCOMPARE(int(anim2.state()), expected2.state);
- if (expected3.state >=0)
- QCOMPARE(int(anim3.state()), expected3.state);
-
-}
-
-void tst_QParallelAnimationGroupJob::addAndRemoveDuration()
-{
- QParallelAnimationGroupJob group;
- QCOMPARE(group.duration(), 0);
- TestAnimation *test = new TestAnimation(250); // 0, duration = 250;
- group.appendAnimation(test);
- QCOMPARE(test->group(), static_cast<QAnimationGroupJob*>(&group));
- QCOMPARE(test->duration(), 250);
- QCOMPARE(group.duration(), 250);
-
- TestAnimation *test2 = new TestAnimation(750); // 1
- group.appendAnimation(test2);
- QCOMPARE(test2->group(), static_cast<QAnimationGroupJob*>(&group));
- QCOMPARE(group.duration(), 750);
-
- TestAnimation *test3 = new TestAnimation(500); // 2
- group.appendAnimation(test3);
- QCOMPARE(test3->group(), static_cast<QAnimationGroupJob*>(&group));
- QCOMPARE(group.duration(), 750);
-
- group.removeAnimation(test2); // remove the one with duration = 750
- delete test2;
- QCOMPARE(group.duration(), 500);
-
- group.removeAnimation(test3); // remove the one with duration = 500
- delete test3;
- QCOMPARE(group.duration(), 250);
-
- group.removeAnimation(test); // remove the last one (with duration = 250)
- QCOMPARE(test->group(), static_cast<QAnimationGroupJob*>(0));
- QCOMPARE(group.duration(), 0);
- delete test;
-}
-
-void tst_QParallelAnimationGroupJob::pauseResume()
-{
- QParallelAnimationGroupJob group;
- TestAnimation *anim = new TestAnimation(250); // 0, duration = 250;
- group.appendAnimation(anim);
- StateChangeListener spy;
- anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
- QCOMPARE(group.duration(), 250);
- group.start();
- QTest::qWait(100);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim->state(), QAnimationGroupJob::Running);
- QCOMPARE(spy.count(), 1);
- spy.clear();
- const int currentTime = group.currentLoopTime();
- QCOMPARE(anim->currentLoopTime(), currentTime);
-
- group.pause();
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(group.currentLoopTime(), currentTime);
- QCOMPARE(anim->state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
- spy.clear();
-
- group.resume();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentLoopTime(), currentTime);
- QCOMPARE(anim->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
-
- group.stop();
- spy.clear();
- group.appendAnimation(new TestAnimation(500));
- group.start();
- QCOMPARE(spy.count(), 1); //the animation should have been started
- QCOMPARE(spy.states.at(0), TestAnimation::Running);
- group.setCurrentTime(250); //end of first animation
- QCOMPARE(spy.count(), 2); //the animation should have been stopped
- QCOMPARE(spy.states.at(1), TestAnimation::Stopped);
- group.pause();
- QCOMPARE(spy.count(), 2); //this shouldn't have changed
- group.resume();
- QCOMPARE(spy.count(), 2); //this shouldn't have changed
-}
-
-// This is a regression test for QTBUG-8910, where a crash occurred when the
-// last animation was removed from a group.
-void tst_QParallelAnimationGroupJob::crashWhenRemovingUncontrolledAnimation()
-{
- QParallelAnimationGroupJob group;
- TestAnimation *anim = new TestAnimation;
- anim->setLoopCount(-1);
- TestAnimation *anim2 = new TestAnimation;
- anim2->setLoopCount(-1);
- group.appendAnimation(anim);
- group.appendAnimation(anim2);
- group.start();
- delete anim;
- // it would crash here because the internals of the group would still have a reference to anim
- delete anim2;
-}
-
-
-QTEST_MAIN(tst_QParallelAnimationGroupJob)
-#include "tst_qparallelanimationgroupjob.moc"
diff --git a/tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro b/tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro
deleted file mode 100644
index d2b48a6c74..0000000000
--- a/tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-TARGET = tst_qpauseanimationjob
-QT = core-private gui-private declarative-private testlib
-SOURCES = tst_qpauseanimationjob.cpp
diff --git a/tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
deleted file mode 100644
index 97be325017..0000000000
--- a/tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include <QtDeclarative/private/qpauseanimationjob_p.h>
-#include <QtDeclarative/private/qsequentialanimationgroupjob_p.h>
-#include <QtDeclarative/private/qparallelanimationgroupjob_p.h>
-
-#ifdef Q_OS_WIN
-static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution";
-#endif
-
-class TestablePauseAnimation : public QPauseAnimationJob
-{
-public:
- TestablePauseAnimation()
- : m_updateCurrentTimeCount(0)
- {
- }
-
- TestablePauseAnimation(int duration)
- : QPauseAnimationJob(duration), m_updateCurrentTimeCount(0)
- {
- }
-
- int m_updateCurrentTimeCount;
-protected:
- void updateCurrentTime(int currentTime)
- {
- QPauseAnimationJob::updateCurrentTime(currentTime);
- ++m_updateCurrentTimeCount;
- }
-};
-
-class TestableGenericAnimation : public QAbstractAnimationJob
-{
-public:
- TestableGenericAnimation(int duration = 250) : m_duration(duration) {}
- int duration() const { return m_duration; }
-
-private:
- int m_duration;
-};
-
-class EnableConsistentTiming
-{
-public:
- EnableConsistentTiming()
- {
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(true);
- }
- ~EnableConsistentTiming()
- {
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(false);
- }
-};
-
-class tst_QPauseAnimationJob : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void initTestCase();
-
-private slots:
- void changeDirectionWhileRunning();
- void noTimerUpdates_data();
- void noTimerUpdates();
- void multiplePauseAnimations();
- void pauseAndPropertyAnimations();
- void pauseResume();
- void sequentialPauseGroup();
- void sequentialGroupWithPause();
- void multipleSequentialGroups();
- void zeroDuration();
-};
-
-void tst_QPauseAnimationJob::initTestCase()
-{
-// qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
-}
-
-void tst_QPauseAnimationJob::changeDirectionWhileRunning()
-{
- EnableConsistentTiming enabled;
-
- TestablePauseAnimation animation;
- animation.setDuration(400);
- animation.start();
- QTest::qWait(100);
- QVERIFY(animation.state() == QAbstractAnimationJob::Running);
- animation.setDirection(QAbstractAnimationJob::Backward);
- QTest::qWait(animation.totalDuration() + 50);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
-}
-
-void tst_QPauseAnimationJob::noTimerUpdates_data()
-{
- QTest::addColumn<int>("duration");
- QTest::addColumn<int>("loopCount");
-
- QTest::newRow("0") << 200 << 1;
- QTest::newRow("1") << 160 << 1;
- QTest::newRow("2") << 160 << 2;
- QTest::newRow("3") << 200 << 3;
-}
-
-void tst_QPauseAnimationJob::noTimerUpdates()
-{
- EnableConsistentTiming enabled;
-
- QFETCH(int, duration);
- QFETCH(int, loopCount);
-
- TestablePauseAnimation animation;
- animation.setDuration(duration);
- animation.setLoopCount(loopCount);
- animation.start();
- QTest::qWait(animation.totalDuration() + 100);
-
-#ifdef Q_OS_WIN
- if (animation.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
-
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- const int expectedLoopCount = 1 + loopCount;
-
-#ifdef Q_OS_WIN
- if (animation.m_updateCurrentTimeCount != expectedLoopCount)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount);
-}
-
-void tst_QPauseAnimationJob::multiplePauseAnimations()
-{
- EnableConsistentTiming enabled;
-
- TestablePauseAnimation animation;
- animation.setDuration(200);
-
- TestablePauseAnimation animation2;
- animation2.setDuration(800);
-
- animation.start();
- animation2.start();
- QTest::qWait(animation.totalDuration() + 100);
-
-#ifdef Q_OS_WIN
- if (animation.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (animation2.state() != QAbstractAnimationJob::Running)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(animation2.state() == QAbstractAnimationJob::Running);
-
-#ifdef Q_OS_WIN
- if (animation.m_updateCurrentTimeCount != 2)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation.m_updateCurrentTimeCount, 2);
-
-#ifdef Q_OS_WIN
- if (animation2.m_updateCurrentTimeCount != 2)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
-
- QTest::qWait(550);
-
-#ifdef Q_OS_WIN
- if (animation2.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (animation2.m_updateCurrentTimeCount != 3)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation2.m_updateCurrentTimeCount, 3);
-}
-
-void tst_QPauseAnimationJob::pauseAndPropertyAnimations()
-{
- EnableConsistentTiming enabled;
-
- TestablePauseAnimation pause;
- pause.setDuration(200);
-
- TestableGenericAnimation animation;
-
- pause.start();
-
- QTest::qWait(100);
- animation.start();
-
- QVERIFY(animation.state() == QAbstractAnimationJob::Running);
- QVERIFY(pause.state() == QAbstractAnimationJob::Running);
- QCOMPARE(pause.m_updateCurrentTimeCount, 2);
-
- QTest::qWait(animation.totalDuration() + 100);
-
-#ifdef Q_OS_WIN
- if (animation.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(pause.m_updateCurrentTimeCount > 3);
-}
-
-void tst_QPauseAnimationJob::pauseResume()
-{
- TestablePauseAnimation animation;
- animation.setDuration(400);
- animation.start();
- QVERIFY(animation.state() == QAbstractAnimationJob::Running);
- QTest::qWait(200);
- animation.pause();
- QVERIFY(animation.state() == QAbstractAnimationJob::Paused);
- animation.start();
- QTest::qWait(300);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (animation.m_updateCurrentTimeCount != 3)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation.m_updateCurrentTimeCount, 3);
-}
-
-void tst_QPauseAnimationJob::sequentialPauseGroup()
-{
- QSequentialAnimationGroupJob group;
-
- TestablePauseAnimation animation1(200);
- group.appendAnimation(&animation1);
- TestablePauseAnimation animation2(200);
- group.appendAnimation(&animation2);
- TestablePauseAnimation animation3(200);
- group.appendAnimation(&animation3);
-
- group.start();
- QCOMPARE(animation1.m_updateCurrentTimeCount, 1);
- QCOMPARE(animation2.m_updateCurrentTimeCount, 0);
- QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation1.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
-
- group.setCurrentTime(250);
- QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation2.m_updateCurrentTimeCount, 1);
- QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
- QCOMPARE((QAbstractAnimationJob*)&animation2, group.currentAnimation());
- QVERIFY(animation2.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
-
- group.setCurrentTime(500);
- QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation3.m_updateCurrentTimeCount, 1);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
- QCOMPARE((QAbstractAnimationJob*)&animation3, group.currentAnimation());
- QVERIFY(animation3.state() == QAbstractAnimationJob::Running);
-
- group.setCurrentTime(750);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
-
- QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation3.m_updateCurrentTimeCount, 2);
-}
-
-void tst_QPauseAnimationJob::sequentialGroupWithPause()
-{
- QSequentialAnimationGroupJob group;
-
- TestableGenericAnimation animation;
- group.appendAnimation(&animation);
-
- TestablePauseAnimation pause;
- pause.setDuration(250);
- group.appendAnimation(&pause);
-
- group.start();
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation.state() == QAbstractAnimationJob::Running);
- QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
-
- group.setCurrentTime(300);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- QCOMPARE((QAbstractAnimationJob*)&pause, group.currentAnimation());
- QVERIFY(pause.state() == QAbstractAnimationJob::Running);
-
- group.setCurrentTime(600);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
-
- QCOMPARE(pause.m_updateCurrentTimeCount, 2);
-}
-
-void tst_QPauseAnimationJob::multipleSequentialGroups()
-{
- EnableConsistentTiming enabled;
-
- QParallelAnimationGroupJob group;
- group.setLoopCount(2);
-
- QSequentialAnimationGroupJob subgroup1;
- group.appendAnimation(&subgroup1);
-
- TestableGenericAnimation animation(300);
- subgroup1.appendAnimation(&animation);
-
- TestablePauseAnimation pause(200);
- subgroup1.appendAnimation(&pause);
-
- QSequentialAnimationGroupJob subgroup2;
- group.appendAnimation(&subgroup2);
-
- TestableGenericAnimation animation2(200);
- subgroup2.appendAnimation(&animation2);
-
- TestablePauseAnimation pause2(250);
- subgroup2.appendAnimation(&pause2);
-
- QSequentialAnimationGroupJob subgroup3;
- group.appendAnimation(&subgroup3);
-
- TestablePauseAnimation pause3(400);
- subgroup3.appendAnimation(&pause3);
-
- TestableGenericAnimation animation3(200);
- subgroup3.appendAnimation(&animation3);
-
- QSequentialAnimationGroupJob subgroup4;
- group.appendAnimation(&subgroup4);
-
- TestablePauseAnimation pause4(310);
- subgroup4.appendAnimation(&pause4);
-
- TestablePauseAnimation pause5(60);
- subgroup4.appendAnimation(&pause5);
-
- group.start();
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(subgroup1.state() == QAbstractAnimationJob::Running);
- QVERIFY(subgroup2.state() == QAbstractAnimationJob::Running);
- QVERIFY(subgroup3.state() == QAbstractAnimationJob::Running);
- QVERIFY(subgroup4.state() == QAbstractAnimationJob::Running);
-
- // This is a pretty long animation so it tends to get rather out of sync
- // when using the consistent timer, so run for an extra half second for good
- // measure...
- QTest::qWait(group.totalDuration() + 500);
-
-#ifdef Q_OS_WIN
- if (group.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (subgroup1.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(subgroup1.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (subgroup2.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(subgroup2.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (subgroup3.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(subgroup3.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (subgroup4.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(subgroup4.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (pause5.m_updateCurrentTimeCount != 4)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(pause5.m_updateCurrentTimeCount, 4);
-}
-
-void tst_QPauseAnimationJob::zeroDuration()
-{
- TestablePauseAnimation animation;
- animation.setDuration(0);
- animation.start();
- QTest::qWait(animation.totalDuration() + 100);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- QCOMPARE(animation.m_updateCurrentTimeCount, 1);
-}
-
-QTEST_MAIN(tst_QPauseAnimationJob)
-#include "tst_qpauseanimationjob.moc"
diff --git a/tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro b/tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro
deleted file mode 100644
index 914fc3ca62..0000000000
--- a/tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase parallel_test
-macx:CONFIG -= app_bundle
-TARGET = tst_qsequentialanimationgroupjob
-QT = core-private declarative-private testlib
-SOURCES = tst_qsequentialanimationgroupjob.cpp
diff --git a/tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
deleted file mode 100644
index d5a9b07f8f..0000000000
--- a/tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
+++ /dev/null
@@ -1,1617 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtDeclarative/private/qsequentialanimationgroupjob_p.h>
-#include <QtDeclarative/private/qparallelanimationgroupjob_p.h>
-#include <QtDeclarative/private/qpauseanimationjob_p.h>
-
-Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
-Q_DECLARE_METATYPE(QAbstractAnimationJob*)
-
-class tst_QSequentialAnimationGroupJob : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void initTestCase();
-
-private slots:
- void construction();
- void setCurrentTime();
- void setCurrentTimeWithUncontrolledAnimation();
- void seekingForwards();
- void seekingBackwards();
- void pauseAndResume();
- void restart();
- void looping();
- void startDelay();
- void clearGroup();
- void groupWithZeroDurationAnimations();
- void propagateGroupUpdateToChildren();
- void updateChildrenWithRunningGroup();
- void deleteChildrenWithRunningGroup();
- void startChildrenWithStoppedGroup();
- void stopGroupWithRunningChild();
- void startGroupWithRunningChild();
- void zeroDurationAnimation();
- void stopUncontrolledAnimations();
- void finishWithUncontrolledAnimation();
- void addRemoveAnimation();
- void currentAnimation();
- void currentAnimationWithZeroDuration();
- void insertAnimation();
- void clear();
- void pauseResume();
-};
-
-void tst_QSequentialAnimationGroupJob::initTestCase()
-{
- qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
- qRegisterMetaType<QAbstractAnimationJob*>("QAbstractAnimationJob*");
-}
-
-void tst_QSequentialAnimationGroupJob::construction()
-{
- QSequentialAnimationGroupJob animationgroup;
-}
-
-class TestAnimation : public QAbstractAnimationJob
-{
-public:
- TestAnimation(int duration = 250) : m_duration(duration) {}
- int duration() const { return m_duration; }
-
-private:
- int m_duration;
-};
-
-class TestValueAnimation : public TestAnimation
-{
-public:
- TestValueAnimation(int duration = 250)
- : TestAnimation(duration), start(0), end(0), value(0) {}
-
- void updateCurrentTime(int msecs)
- {
- if (msecs >= duration())
- value = end;
- else
- value = start + (end - start) * (qreal(msecs) / duration());
- }
-
- qreal start, end;
- qreal value;
-};
-
-class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
-{
- Q_OBJECT
-public:
- int duration() const { return -1; /* not time driven */ }
-
-protected:
- void updateCurrentTime(int currentTime)
- {
- if (currentTime >= 250)
- stop();
- }
-};
-
-class StateChangeListener: public QAnimationJobChangeListener
-{
-public:
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
- {
- states << newState;
- }
-
- void clear() { states.clear(); }
- int count() const { return states.count(); }
-
- QList<QAbstractAnimationJob::State> states;
-};
-
-class FinishedListener: public QAnimationJobChangeListener
-{
-public:
- FinishedListener() : m_count(0) {}
-
- virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; }
- void clear() { m_count = 0; }
- int count() { return m_count; }
-
-private:
- int m_count;
-};
-
-void tst_QSequentialAnimationGroupJob::setCurrentTime()
-{
- // sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a2_s_o1 = new TestAnimation;
- TestAnimation *a3_s_o1 = new TestAnimation;
- a2_s_o1->setLoopCount(3);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
-
- // sequence operating on different object/properties
- QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o2 = new TestAnimation;
- TestAnimation *a1_s_o3 = new TestAnimation;
- sequence2->appendAnimation(a1_s_o2);
- sequence2->appendAnimation(a1_s_o3);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(sequence2);
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 250
- group.setCurrentTime(250);
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(sequence->currentLoopTime(), 250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 251
- group.setCurrentTime(251);
- QCOMPARE(group.currentLoopTime(), 251);
- QCOMPARE(sequence->currentLoopTime(), 251);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 750
- group.setCurrentTime(750);
- QCOMPARE(group.currentLoopTime(), 750);
- QCOMPARE(sequence->currentLoopTime(), 750);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1000
- group.setCurrentTime(1000);
- QCOMPARE(group.currentLoopTime(), 1000);
- QCOMPARE(sequence->currentLoopTime(), 1000);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1010
- group.setCurrentTime(1010);
- QCOMPARE(group.currentLoopTime(), 1010);
- QCOMPARE(sequence->currentLoopTime(), 1010);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 10);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1250
- group.setCurrentTime(1250);
- QCOMPARE(group.currentLoopTime(), 1250);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1500
- group.setCurrentTime(1500);
- QCOMPARE(group.currentLoopTime(), 1500);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1750
- group.setCurrentTime(1750);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 500);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 250);
-
- // Current time = 2000
- group.setCurrentTime(2000);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 500);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 250);
-}
-
-void tst_QSequentialAnimationGroupJob::setCurrentTimeWithUncontrolledAnimation()
-{
- // sequence operating on different object/properties
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a1_s_o2 = new TestAnimation;
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a1_s_o2);
-
- UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation;
- QCOMPARE(notTimeDriven->totalDuration(), -1);
-
- TestAnimation *loopsForever = new TestAnimation;
- loopsForever->setLoopCount(-1);
- QCOMPARE(loopsForever->totalDuration(), -1);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(notTimeDriven);
- group.appendAnimation(loopsForever);
- group.start();
- group.pause(); // this allows the group to listen for the finish signal of its children
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(notTimeDriven->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
-
- // Current time = 250
- group.setCurrentTime(250);
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(sequence->currentLoopTime(), 250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(notTimeDriven->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
-
- // Current time = 500
- group.setCurrentTime(500);
- QCOMPARE(group.currentLoopTime(), 500);
- QCOMPARE(sequence->currentLoopTime(), 500);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob *>(notTimeDriven));
-
- // Current time = 505
- group.setCurrentTime(505);
- QCOMPARE(group.currentLoopTime(), 505);
- QCOMPARE(sequence->currentLoopTime(), 500);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 5);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob *>(notTimeDriven));
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Paused);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-
- // Current time = 750 (end of notTimeDriven animation)
- group.setCurrentTime(750);
- QCOMPARE(group.currentLoopTime(), 750);
- QCOMPARE(sequence->currentLoopTime(), 500);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 250);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), loopsForever);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Paused);
-
- // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run)
- group.setCurrentTime(800);
- QCOMPARE(group.currentLoopTime(), 800);
- QCOMPARE(group.currentAnimation(), loopsForever);
- QCOMPARE(sequence->currentLoopTime(), 500);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 250);
- QCOMPARE(loopsForever->currentLoopTime(), 50);
-
- loopsForever->stop(); // this should stop the group
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::seekingForwards()
-{
-
- // sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob;
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a2_s_o1 = new TestAnimation;
- TestAnimation *a3_s_o1 = new TestAnimation;
- a2_s_o1->setLoopCount(3);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
-
- // sequence operating on different object/properties
- QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob;
- TestAnimation *a1_s_o2 = new TestAnimation;
- TestAnimation *a1_s_o3 = new TestAnimation;
- sequence2->appendAnimation(a1_s_o2);
- sequence2->appendAnimation(a1_s_o3);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(sequence2);
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1500
- group.setCurrentTime(1500);
- QCOMPARE(group.currentLoopTime(), 1500);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // this will restart the group
- group.start();
- group.pause();
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
-
- // Current time = 1750
- group.setCurrentTime(1750);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 500);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 250);
-}
-
-void tst_QSequentialAnimationGroupJob::seekingBackwards()
-{
- // sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a2_s_o1 = new TestAnimation;
- TestAnimation *a3_s_o1 = new TestAnimation;
- a2_s_o1->setLoopCount(3);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
-
- // sequence operating on different object/properties
- QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o2 = new TestAnimation;
- TestAnimation *a1_s_o3 = new TestAnimation;
- sequence2->appendAnimation(a1_s_o2);
- sequence2->appendAnimation(a1_s_o3);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(sequence2);
-
- group.start();
-
- // Current time = 1600
- group.setCurrentTime(1600);
- QCOMPARE(group.currentLoopTime(), 1600);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 350);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 100);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Running);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Running);
-
- // Seeking backwards, current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
-
- QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
- "hence they don't reset from their current animation", Continue);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
- "hence they don't reset from their current animation", Continue);
- QCOMPARE(a2_s_o1->currentLoop(), 0);
- QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
- "hence they don't reset from their current animation", Continue);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Running);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Running);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
-
- // Current time = 2000
- group.setCurrentTime(2000);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 500);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 250);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
-}
-
-typedef QList<QAbstractAnimationJob::State> StateList;
-
-static bool compareStates(const StateChangeListener& spy, const StateList &expectedStates)
-{
- bool equals = true;
- for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
- if (i >= spy.count() || i >= expectedStates.count()) {
- equals = false;
- break;
- }
- QAbstractAnimationJob::State st = expectedStates.at(i);
- QAbstractAnimationJob::State actual = spy.states.at(i);
- if (equals && actual != st) {
- equals = false;
- break;
- }
- }
- if (!equals) {
- const char *stateStrings[] = {"Stopped", "Paused", "Running"};
- QString e,a;
- for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
- if (i < expectedStates.count()) {
- int exp = int(expectedStates.at(i));
- if (!e.isEmpty())
- e += QLatin1String(", ");
- e += QLatin1String(stateStrings[exp]);
- }
- if (i < spy.count()) {
- QAbstractAnimationJob::State actual = spy.states.at(i);
- if (!a.isEmpty())
- a += QLatin1String(", ");
- if (int(actual) >= 0 && int(actual) <= 2) {
- a += QLatin1String(stateStrings[int(actual)]);
- } else {
- a += QLatin1String("NaN");
- }
- }
-
- }
- qDebug("\n"
- "expected (count == %d): %s\n"
- "actual (count == %d): %s\n", expectedStates.count(), qPrintable(e), spy.count(), qPrintable(a));
- }
- return equals;
-}
-
-void tst_QSequentialAnimationGroupJob::pauseAndResume()
-{
- // sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a2_s_o1 = new TestAnimation;
- TestAnimation *a3_s_o1 = new TestAnimation;
- a2_s_o1->setLoopCount(2);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
- sequence->setLoopCount(2);
-
- StateChangeListener a1StateChangedSpy;
- a1_s_o1->addAnimationChangeListener(&a1StateChangedSpy, QAbstractAnimationJob::StateChange);
- StateChangeListener seqStateChangedSpy;
- sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
-
- group.start();
- group.pause();
-
- // Current time = 1751
- group.setCurrentTime(1751);
- QCOMPARE(group.currentLoopTime(), 1751);
- QCOMPARE(sequence->currentLoopTime(), 751);
- QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 1);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
-
- QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped
- QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused
-
- QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped)));
-
- //### is this the same test as compareStates test above?
- QCOMPARE(a1StateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(a1StateChangedSpy.states.at(1), QAnimationGroupJob::Paused);
- QCOMPARE(a1StateChangedSpy.states.at(2), QAnimationGroupJob::Stopped);
- QCOMPARE(a1StateChangedSpy.states.at(3), QAnimationGroupJob::Running);
- QCOMPARE(a1StateChangedSpy.states.at(4), QAnimationGroupJob::Stopped);
-
- QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Paused);
-
- group.resume();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Running);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Running);
-
- QVERIFY(group.currentLoopTime() >= 1751);
- QVERIFY(sequence->currentLoopTime() >= 751);
- QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QVERIFY(a3_s_o1->currentLoopTime() >= 1);
-
- QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
- QCOMPARE(seqStateChangedSpy.states.at(2), QAnimationGroupJob::Running);
-
- group.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
-
- QVERIFY(group.currentLoopTime() >= 1751);
- QVERIFY(sequence->currentLoopTime() >= 751);
- QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QVERIFY(a3_s_o1->currentLoopTime() >= 1);
-
- QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
- QCOMPARE(seqStateChangedSpy.states.at(3), QAnimationGroupJob::Paused);
-
- group.stop();
-
- QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped
- QCOMPARE(seqStateChangedSpy.states.at(4), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::restart()
-{
- // originally was sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- //### no equivilant signal
- //QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimationJob*)));
-
- StateChangeListener seqStateChangedSpy;
- sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- TestAnimation *anims[3];
- StateChangeListener *animsStateChanged[3];
-
- for (int i = 0; i < 3; i++) {
- anims[i] = new TestAnimation(100);
- animsStateChanged[i] = new StateChangeListener;
- anims[i]->addAnimationChangeListener(animsStateChanged[i], QAbstractAnimationJob::StateChange);
- }
-
- anims[1]->setLoopCount(2);
- sequence->appendAnimation(anims[0]);
- sequence->appendAnimation(anims[1]);
- sequence->appendAnimation(anims[2]);
- sequence->setLoopCount(2);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
-
- group.start();
-
- QTest::qWait(500);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
-
- QTest::qWait(300);
- QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
-
- for (int i = 0; i < 3; i++) {
- QCOMPARE(animsStateChanged[i]->count(), 4);
- QCOMPARE(animsStateChanged[i]->states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(animsStateChanged[i]->states.at(1), QAnimationGroupJob::Stopped);
- QCOMPARE(animsStateChanged[i]->states.at(2), QAnimationGroupJob::Running);
- QCOMPARE(animsStateChanged[i]->states.at(3), QAnimationGroupJob::Stopped);
- }
-
- QCOMPARE(seqStateChangedSpy.count(), 2);
- QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
-
- //QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
- //for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
- // QCOMPARE(static_cast<QAbstractAnimationJob*>(anims[i%3]), qVariantValue<QAbstractAnimationJob*>(seqCurrentAnimChangedSpy.at(i).at(0)));
-
- group.start();
-
- QCOMPARE(animsStateChanged[0]->count(), 5);
- QCOMPARE(animsStateChanged[1]->count(), 4);
- QCOMPARE(animsStateChanged[2]->count(), 4);
- QCOMPARE(seqStateChangedSpy.count(), 3);
-}
-
-void tst_QSequentialAnimationGroupJob::looping()
-{
- // originally was sequence operating on same object/property
- QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- QAbstractAnimationJob *a1_s_o1 = new TestAnimation;
- QAbstractAnimationJob *a2_s_o1 = new TestAnimation;
- QAbstractAnimationJob *a3_s_o1 = new TestAnimation;
-
- StateChangeListener a1Spy;
- a1_s_o1->addAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange);
- StateChangeListener a2Spy;
- a2_s_o1->addAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange);
- StateChangeListener a3Spy;
- a3_s_o1->addAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange);
- StateChangeListener seqSpy;
- sequence->addAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange);
-
- a2_s_o1->setLoopCount(2);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
- sequence->setLoopCount(2);
-
- QSequentialAnimationGroupJob group;
- StateChangeListener groupSpy;
- group.addAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange);
-
- group.appendAnimation(sequence);
- group.setLoopCount(2);
-
- group.start();
- group.pause();
-
- // Current time = 1750
- group.setCurrentTime(1750);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 750);
- QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- // this animation is at the beginning because it is the current one inside sequence
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence->currentAnimation(), a3_s_o1);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
-
- QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped
- QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped)));
-
- QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped
- QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused)));
-
- QCOMPARE(seqSpy.count(), 2); // Running,Paused
- QCOMPARE(groupSpy.count(), 2); // Running,Paused
-
- // Looping, current time = duration + 1
- group.setCurrentTime(group.duration() + 1);
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(group.currentLoop(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoop(), 0);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- // this animation is at the end because it was run on the previous loop
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped
- QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped
- QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused
- << QAbstractAnimationJob::Stopped)));
- QVERIFY(compareStates(seqSpy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused)));
- QCOMPARE(groupSpy.count(), 2);
-
- //cleanup
- a1_s_o1->removeAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange);
- a2_s_o1->removeAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange);
- a3_s_o1->removeAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange);
- sequence->removeAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange);
- group.removeAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::startDelay()
-{
- QSequentialAnimationGroupJob group;
- group.appendAnimation(new QPauseAnimationJob(250));
- group.appendAnimation(new QPauseAnimationJob(125));
- QCOMPARE(group.totalDuration(), 375);
-
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
-
- QTest::qWait(500);
-
- QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
- QVERIFY(group.currentLoopTime() == 375);
-}
-
-void tst_QSequentialAnimationGroupJob::clearGroup()
-{
- QSequentialAnimationGroupJob group;
-
- static const int animationCount = 20;
-
- for (int i = 0; i < animationCount/2; ++i) {
- QSequentialAnimationGroupJob *subGroup = new QSequentialAnimationGroupJob;
- group.appendAnimation(subGroup);
- group.appendAnimation(new QPauseAnimationJob(100));
- subGroup->appendAnimation(new QPauseAnimationJob(10));
- }
-
- int count = 0;
- for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
- ++count;
- QCOMPARE(count, animationCount);
-
- group.clear();
-
- QVERIFY(!group.firstChild() && !group.lastChild());
- QCOMPARE(group.currentLoopTime(), 0);
-}
-
-void tst_QSequentialAnimationGroupJob::groupWithZeroDurationAnimations()
-{
- QSequentialAnimationGroupJob group;
-
- TestValueAnimation *a1 = new TestValueAnimation(0);
- a1->start = 42;
- a1->end = 43;
- group.appendAnimation(a1);
-
- //this should just run fine and change nothing
- group.setCurrentTime(0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(a1));
-
- TestValueAnimation *a2 = new TestValueAnimation(500);
- a2->start = 13;
- a2->end = 31;
- group.appendAnimation(a2);
-
- TestValueAnimation *a3 = new TestValueAnimation(0);
- a3->start = 43;
- a3->end = 44;
- group.appendAnimation(a3);
-
- TestValueAnimation *a4 = new TestValueAnimation(250);
- a4->start = 13;
- a4->end = 75;
- group.appendAnimation(a4);
-
- TestValueAnimation *a5 = new TestValueAnimation(0);
- a5->start = 42;
- a5->end = 12;
- group.appendAnimation(a5);
-
- QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want?
- QCOMPARE((int)a2->value, 0);
- QCOMPARE((int)a3->value, 0);
- QCOMPARE((int)a4->value, 0);
- QCOMPARE((int)a5->value, 0);
-
- group.start();
-
- QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want?
- QCOMPARE((int)a2->value, 13);
- QCOMPARE((int)a3->value, 0);
- QCOMPARE((int)a4->value, 0);
- QCOMPARE((int)a5->value, 0);
-
- QTest::qWait(100);
-
- QCOMPARE((int)a1->value, 43);
- QVERIFY(a2->value > 13 && a2->value < 31);
- QCOMPARE((int)a3->value, 0);
- QCOMPARE((int)a4->value, 0);
- QCOMPARE((int)a5->value, 0);
-
- QTest::qWait(500);
-
- QTRY_COMPARE((int)a3->value, 44);
- QCOMPARE((int)a1->value, 43);
- QCOMPARE((int)a2->value, 31);
- //QCOMPARE((int)a4->value, 36);
- QCOMPARE((int)a5->value, 0);
- QCOMPARE(a1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a4->state(), QAnimationGroupJob::Running);
- QCOMPARE(a5->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QTest::qWait(500);
-
- QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE((int)a1->value, 43);
- QCOMPARE((int)a2->value, 31);
- QCOMPARE((int)a3->value, 44);
- QCOMPARE((int)a4->value, 75);
- QCOMPARE((int)a5->value, 12);
- QCOMPARE(a1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a4->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a5->state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::propagateGroupUpdateToChildren()
-{
- // this test verifies if group state changes are updating its children correctly
- QSequentialAnimationGroupJob group;
-
- TestAnimation anim1(100);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::updateChildrenWithRunningGroup()
-{
- // assert that its possible to modify a child's state directly while their group is running
- QSequentialAnimationGroupJob group;
-
- TestAnimation anim(200);
-
- StateChangeListener groupStateChangedSpy;
- group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
- StateChangeListener childStateChangedSpy;
- anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(groupStateChangedSpy.count(), 0);
- QCOMPARE(childStateChangedSpy.count(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Running);
-
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
-
- QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
-
- // starting directly a running child will not have any effect
- anim.start();
-
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
-
- anim.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Paused);
-
- // in the animation stops directly, the group will still be running
- anim.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
-
- //cleanup
- group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
- anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::deleteChildrenWithRunningGroup()
-{
- // test if children can be activated when their group is stopped
- QSequentialAnimationGroupJob group;
-
- TestAnimation *anim1 = new TestAnimation(200);
- group.appendAnimation(anim1);
-
- QCOMPARE(group.duration(), anim1->duration());
-
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
-
- QTest::qWait(100);
- QTRY_VERIFY(group.currentLoopTime() > 0);
-
- delete anim1;
- QVERIFY(!group.firstChild());
- QCOMPARE(group.duration(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
-}
-
-void tst_QSequentialAnimationGroupJob::startChildrenWithStoppedGroup()
-{
- // test if children can be activated when their group is stopped
- QSequentialAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-}
-
-void tst_QSequentialAnimationGroupJob::stopGroupWithRunningChild()
-{
- // children that started independently will not be affected by a group stop
- QSequentialAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- anim1.stop();
- anim2.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::startGroupWithRunningChild()
-{
- // as the group has precedence over its children, starting a group will restart all the children
- QSequentialAnimationGroupJob group;
-
- TestAnimation *anim1 = new TestAnimation(200);
- TestAnimation *anim2 = new TestAnimation(200);
-
- StateChangeListener stateChangedSpy1;
- anim1->addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- StateChangeListener stateChangedSpy2;
- anim2->addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(stateChangedSpy1.count(), 0);
- QCOMPARE(stateChangedSpy2.count(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(anim1);
- group.appendAnimation(anim2);
-
- anim1->start();
- anim2->start();
- anim2->pause();
-
- QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running)));
-
- QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused)));
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Paused);
-
- group.start();
-
- QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running)));
- QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused)));
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Paused);
-
- QTest::qWait(300);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
-
- QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped);
- QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped);
-
- anim1->removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- anim2->removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::zeroDurationAnimation()
-{
- QSequentialAnimationGroupJob group;
-
- TestAnimation *anim1 = new TestAnimation(0);
- TestAnimation *anim2 = new TestAnimation(100);
- TestValueAnimation *anim3 = new TestValueAnimation(0);
- anim3->end = 100;
-
- StateChangeListener stateChangedSpy;
- anim1->addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
-
- group.appendAnimation(anim1);
- group.appendAnimation(anim2);
- group.appendAnimation(anim3);
- group.setLoopCount(2);
- group.start();
-
- QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
-
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
-
- //now let's try to seek to the next loop
- group.setCurrentTime(group.duration() + 1);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- //TODO: test that anim3 was run
- QCOMPARE(anim3->value, qreal(100)); //anim3 should have been run
-
- anim1->removeAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::stopUncontrolledAnimations()
-{
- QSequentialAnimationGroupJob group;
-
- UncontrolledAnimation notTimeDriven;
- QCOMPARE(notTimeDriven.totalDuration(), -1);
-
- TestAnimation loopsForever(100);
- loopsForever.setLoopCount(-1);
-
- group.appendAnimation(&notTimeDriven);
- group.appendAnimation(&loopsForever);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
-
- notTimeDriven.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
-
- loopsForever.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::finishWithUncontrolledAnimation()
-{
- //1st case:
- //first we test a group with one uncontrolled animation
- QSequentialAnimationGroupJob group;
- UncontrolledAnimation notTimeDriven;
- group.appendAnimation(&notTimeDriven);
- FinishedListener spy;
- group.addAnimationChangeListener(&spy, QAbstractAnimationJob::Completion);
-
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(notTimeDriven.currentLoopTime(), 0);
-
- QTest::qWait(300); //wait for the end of notTimeDriven
- QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- const int actualDuration = notTimeDriven.currentLoopTime();
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.currentLoopTime(), actualDuration);
- QCOMPARE(spy.count(), 1);
-
- //2nd case:
- // lets make sure the seeking will work again
- spy.clear();
- TestAnimation anim;
- group.appendAnimation(&anim);
- StateChangeListener animStateChangedSpy;
- anim.addAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- group.setCurrentTime(300);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven.currentLoopTime(), actualDuration);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
-
- //3rd case:
- //now let's add a perfectly defined animation at the end
- QCOMPARE(animStateChangedSpy.count(), 0);
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(notTimeDriven.currentLoopTime(), 0);
-
- QCOMPARE(animStateChangedSpy.count(), 0);
-
- QTest::qWait(300); //wait for the end of notTimeDriven
- QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
- QCOMPARE(animStateChangedSpy.count(), 1);
- QTest::qWait(300); //wait for the end of anim
-
- QTRY_COMPARE(anim.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim.currentLoopTime(), anim.duration());
-
- //we should simply be at the end
- QCOMPARE(spy.count(), 1);
- QCOMPARE(animStateChangedSpy.count(), 2);
- QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime());
-
- //cleanup
- group.removeAnimationChangeListener(&spy, QAbstractAnimationJob::Completion);
- anim.removeAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::addRemoveAnimation()
-{
- //this test is specific to the sequential animation group
- QSequentialAnimationGroupJob group;
-
- QCOMPARE(group.duration(), 0);
- QCOMPARE(group.currentLoopTime(), 0);
- QAbstractAnimationJob *anim1 = new TestAnimation;
- group.appendAnimation(anim1);
- QCOMPARE(group.duration(), 250);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), anim1);
-
- //let's append an animation
- QAbstractAnimationJob *anim2 = new TestAnimation;
- group.appendAnimation(anim2);
- QCOMPARE(group.duration(), 500);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), anim1);
-
- //let's prepend an animation
- QAbstractAnimationJob *anim0 = new TestAnimation;
- group.prependAnimation(anim0);
- QCOMPARE(group.duration(), 750);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation
-
- group.setCurrentTime(300); //anim0 | anim1 | anim2
- QCOMPARE(group.currentLoopTime(), 300);
- QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentLoopTime(), 50);
-
- group.removeAnimation(anim0); //anim1 | anim2
- QCOMPARE(group.currentLoopTime(), 50);
- QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentLoopTime(), 50);
-
- group.setCurrentTime(0);
- group.prependAnimation(anim0); //anim0 | anim1 | anim2
- group.setCurrentTime(300);
- QCOMPARE(group.currentLoopTime(), 300);
- QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentLoopTime(), 50);
-
- group.removeAnimation(anim1); //anim0 | anim2
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(group.currentAnimation(), anim2);
- QCOMPARE(anim0->currentLoopTime(), 250);
-}
-
-void tst_QSequentialAnimationGroupJob::currentAnimation()
-{
- QSequentialAnimationGroupJob group;
- QVERIFY(group.currentAnimation() == 0);
-
- TestAnimation anim(0);
- group.appendAnimation(&anim);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
-}
-
-void tst_QSequentialAnimationGroupJob::currentAnimationWithZeroDuration()
-{
- QSequentialAnimationGroupJob group;
- QVERIFY(group.currentAnimation() == 0);
-
- TestAnimation zero1(0);
- TestAnimation zero2(0);
-
- TestAnimation anim;
-
- TestAnimation zero3(0);
- TestAnimation zero4(0);
-
- group.appendAnimation(&zero1);
- group.appendAnimation(&zero2);
- group.appendAnimation(&anim);
- group.appendAnimation(&zero3);
- group.appendAnimation(&zero4);
-
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero1));
-
- group.setCurrentTime(0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
-
- group.setCurrentTime(group.duration());
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero4));
-
- group.setDirection(QAbstractAnimationJob::Backward);
-
- group.setCurrentTime(0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero1));
-
- group.setCurrentTime(group.duration());
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
-}
-
-void tst_QSequentialAnimationGroupJob::insertAnimation()
-{
- QSequentialAnimationGroupJob group;
- group.setLoopCount(2);
- TestAnimation *anim = new TestAnimation;
- group.appendAnimation(anim);
- QCOMPARE(group.duration(), anim->duration());
- group.setCurrentTime(300);
- QCOMPARE(group.currentLoop(), 1);
-
- //this will crash if the sequential group calls duration on the created animation
- group.appendAnimation(new TestAnimation);
-}
-
-class ClearFinishedListener: public QAnimationJobChangeListener
-{
-public:
- ClearFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {}
-
- virtual void animationFinished(QAbstractAnimationJob *)
- {
- group->clear();
- }
-
- QSequentialAnimationGroupJob *group;
-};
-
-class RefillFinishedListener: public QAnimationJobChangeListener
-{
-public:
- RefillFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {}
-
- virtual void animationFinished(QAbstractAnimationJob *)
- {
- group->stop();
- group->clear();
- group->appendAnimation(new TestAnimation);
- group->start();
- }
-
- QSequentialAnimationGroupJob *group;
-};
-
-void tst_QSequentialAnimationGroupJob::clear()
-{
- QSKIP("deleting an animation when finished is not currently supported");
- QSequentialAnimationGroupJob group;
- TestAnimation *anim1 = new TestAnimation;
- group.appendAnimation(anim1);
- ClearFinishedListener clearListener(&group);
- anim1->addAnimationChangeListener(&clearListener, QAbstractAnimationJob::Completion);
-
- TestAnimation *anim2 = new TestAnimation;
- group.appendAnimation(anim2);
- QCOMPARE(group.firstChild(), anim1);
- QCOMPARE(group.lastChild(), anim2);
-
- group.start();
- QTest::qWait(anim1->duration() + 100);
- QTRY_VERIFY(!group.firstChild());
- QCOMPARE(group.state(), QAbstractAnimationJob::Stopped);
- QCOMPARE(group.currentLoopTime(), 0);
-
- anim1 = new TestAnimation;
- group.appendAnimation(anim1);
- RefillFinishedListener refillListener(&group);
- anim1->addAnimationChangeListener(&refillListener, QAbstractAnimationJob::Completion);
- group.start();
- QTest::qWait(anim1->duration() + 100);
- QTRY_COMPARE(group.state(), QAbstractAnimationJob::Running);
-}
-
-void tst_QSequentialAnimationGroupJob::pauseResume()
-{
- QParallelAnimationGroupJob group;
- TestAnimation *anim = new TestAnimation;
- group.appendAnimation(anim);
- StateChangeListener spy;
- anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
- QCOMPARE(group.duration(), 250);
- group.start();
- QTest::qWait(100);
- QTRY_COMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim->state(), QAnimationGroupJob::Running);
- QCOMPARE(spy.count(), 1);
- spy.clear();
- const int currentTime = group.currentLoopTime();
- QCOMPARE(anim->currentLoopTime(), currentTime);
-
- group.pause();
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(group.currentLoopTime(), currentTime);
- QCOMPARE(anim->state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
- spy.clear();
-
- group.resume();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentLoopTime(), currentTime);
- QCOMPARE(anim->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
-
- anim->removeAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
-}
-
-QTEST_MAIN(tst_QSequentialAnimationGroupJob)
-#include "tst_qsequentialanimationgroupjob.moc"
diff --git a/tests/auto/declarative/debugger/debugger.pro b/tests/auto/declarative/debugger/debugger.pro
deleted file mode 100644
index 314f0d1b78..0000000000
--- a/tests/auto/declarative/debugger/debugger.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = subdirs
-
-PRIVATETESTS += \
- qdeclarativeenginedebug \
- qdeclarativedebugclient \
- qdeclarativedebugservice \
- qdeclarativedebugjs \
- qdeclarativeinspector \
- qdeclarativeprofilerservice \
- qpacketprotocol \
- qv8profilerservice \
- qdebugmessageservice
-
-contains(QT_CONFIG, private_tests) {
- SUBDIRS += $$PRIVATETESTS
-}
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro
deleted file mode 100644
index 698e9604f0..0000000000
--- a/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdebugmessageservice
-QT += network declarative-private testlib
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-
-SOURCES += tst_qdebugmessageservice.cpp \
- ../shared/debugutil.cpp
-
-INCLUDEPATH += ../shared
-
-include(../../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-OTHER_FILES += data/test.qml
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
deleted file mode 100644
index 94738dc083..0000000000
--- a/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtDeclarative/private/qdeclarativedebugclient_p.h>
-
-//QDeclarativeDebugTest
-#include "../shared/debugutil_p.h"
-#include "../../../shared/util.h"
-
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-
-const char *NORMALMODE = "-qmljsdebugger=port:3777,block";
-const char *QMLFILE = "test.qml";
-
-class QDeclarativeDebugMsgClient;
-class tst_QDebugMessageService : public QDeclarativeDataTest
-{
- Q_OBJECT
-
-public:
- tst_QDebugMessageService();
-
- void init();
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void cleanup();
-
- void retrieveDebugOutput();
-
-private:
- QDeclarativeDebugProcess *m_process;
- QDeclarativeDebugMsgClient *m_client;
- QDeclarativeDebugConnection *m_connection;
-};
-
-struct LogEntry {
- LogEntry(QtMsgType _type, QString _message)
- : type(_type), message(_message) {}
-
- QtMsgType type;
- QString message;
- int line;
- QString file;
- QString function;
-
- QString toString() const { return QString::number(type) + ": " + message; }
-};
-
-bool operator==(const LogEntry &t1, const LogEntry &t2)
-{
- return t1.type == t2.type && t1.message == t2.message
- && t1.line == t2.line && t1.file == t2.file
- && t1.function == t2.function;
-}
-
-class QDeclarativeDebugMsgClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-public:
- QDeclarativeDebugMsgClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("DebugMessages"), connection)
- {
- }
-
- QList<LogEntry> logBuffer;
-
-protected:
- //inherited from QDeclarativeDebugClient
- void stateChanged(State state);
- void messageReceived(const QByteArray &data);
-
-signals:
- void enabled();
- void debugOutput();
-};
-
-void QDeclarativeDebugMsgClient::stateChanged(State state)
-{
- if (state == Enabled) {
- emit enabled();
- }
-}
-
-void QDeclarativeDebugMsgClient::messageReceived(const QByteArray &data)
-{
- QDataStream ds(data);
- QByteArray command;
- ds >> command;
-
- if (command == "MESSAGE") {
- int type;
- QByteArray message;
- QByteArray file;
- QByteArray function;
- int line;
- ds >> type >> message >> file >> line >> function;
- QVERIFY(ds.atEnd());
-
- QVERIFY(type >= QtDebugMsg);
- QVERIFY(type <= QtFatalMsg);
-
- LogEntry entry((QtMsgType)type, QString::fromUtf8(message));
- entry.line = line;
- entry.file = QString::fromUtf8(file);
- entry.function = QString::fromUtf8(function);
- logBuffer << entry;
- emit debugOutput();
- } else {
- QFAIL("Unknown message");
- }
-}
-
-tst_QDebugMessageService::tst_QDebugMessageService()
-{
-}
-
-void tst_QDebugMessageService::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- m_process = 0;
- m_client = 0;
- m_connection = 0;
-}
-
-void tst_QDebugMessageService::cleanupTestCase()
-{
- if (m_process)
- delete m_process;
-
- if (m_client)
- delete m_client;
-
- if (m_connection)
- delete m_connection;
-}
-
-void tst_QDebugMessageService::init()
-{
- m_connection = new QDeclarativeDebugConnection();
- m_process = new QDeclarativeDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
- m_client = new QDeclarativeDebugMsgClient(m_connection);
-
- m_process->start(QStringList() << QLatin1String(NORMALMODE) << QDeclarativeDataTest::instance()->testFile(QMLFILE));
- if (!m_process->waitForSessionStart()) {
- QFAIL(QString("Could not launch app. Application output: \n%1").arg(m_process->output()).toAscii());
- }
-
- m_connection->connectToHost("127.0.0.1", 3777);
- QVERIFY(m_connection->waitForConnected());
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(enabled())));
-}
-
-void tst_QDebugMessageService::cleanup()
-{
- if (QTest::currentTestFailed())
- qDebug() << m_process->output();
- if (m_process)
- delete m_process;
-
- if (m_client)
- delete m_client;
-
- if (m_connection)
- delete m_connection;
-
- m_process = 0;
- m_client = 0;
- m_connection = 0;
-}
-
-void tst_QDebugMessageService::retrieveDebugOutput()
-{
- init();
-
- int maxTries = 2;
- while ((m_client->logBuffer.size() < 2)
- || (maxTries-- > 0))
- QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(debugOutput()), 1000);
-
- QVERIFY(m_client->logBuffer.size() >= 2);
-
- const QString path =
- QUrl::fromLocalFile(QDeclarativeDataTest::instance()->testFile(QMLFILE)).toString();
- LogEntry entry1(QtDebugMsg, QLatin1String("console.log"));
- entry1.line = 48;
- entry1.file = path;
- entry1.function = QLatin1String("onCompleted");
- LogEntry entry2(QtDebugMsg, QLatin1String("console.count: 1"));
- entry2.line = 49;
- entry2.file = path;
- entry2.function = QLatin1String("onCompleted");
-
- QVERIFY(m_client->logBuffer.contains(entry1));
- QVERIFY(m_client->logBuffer.contains(entry2));
-}
-
-QTEST_MAIN(tst_QDebugMessageService)
-
-#include "tst_qdebugmessageservice.moc"
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro b/tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro
deleted file mode 100644
index 8eb33fb81d..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativedebugclient
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativedebugclient.cpp \
- ../shared/debugutil.cpp
-
-CONFIG += declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
deleted file mode 100644
index e059c7617b..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include "../shared/debugutil_p.h"
-
-#define PORT 13770
-#define STR_PORT "13770"
-
-class tst_QDeclarativeDebugClient : public QObject
-{
- Q_OBJECT
-
-private:
- QDeclarativeDebugConnection *m_conn;
-
-private slots:
- void initTestCase();
-
- void name();
- void state();
- void sendMessage();
- void parallelConnect();
- void sequentialConnect();
-};
-
-void tst_QDeclarativeDebugClient::initTestCase()
-{
- const QString waitingMsg = QString("QDeclarativeDebugServer: Waiting for connection on port %1...").arg(PORT);
- QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
- new QDeclarativeEngine(this);
-
- m_conn = new QDeclarativeDebugConnection(this);
-
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::handshake()", m_conn);
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::handshake()");
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
- for (int i = 0; i < 50; ++i) {
- // try for 5 seconds ...
- m_conn->connectToHost("127.0.0.1", PORT);
- if (m_conn->waitForConnected())
- break;
- QTest::qSleep(100);
- }
-
- QVERIFY(m_conn->isConnected());
-
- QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
-}
-
-void tst_QDeclarativeDebugClient::name()
-{
- QString name = "tst_QDeclarativeDebugClient::name()";
-
- QDeclarativeDebugClient client(name, m_conn);
- QCOMPARE(client.name(), name);
-}
-
-void tst_QDeclarativeDebugClient::state()
-{
- {
- QDeclarativeDebugConnection dummyConn;
- QDeclarativeDebugClient client("tst_QDeclarativeDebugClient::state()", &dummyConn);
- QCOMPARE(client.state(), QDeclarativeDebugClient::NotConnected);
- QCOMPARE(client.serviceVersion(), -1.0f);
- }
-
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::state()", m_conn);
- QCOMPARE(client.state(), QDeclarativeDebugClient::Unavailable);
-
- {
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::state()", 2);
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
- QCOMPARE(client.serviceVersion(), 2.0f);
- }
-
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Unavailable);
-
- // duplicate plugin name
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugClient: Conflicting plugin name \"tst_QDeclarativeDebugClient::state()\" ");
- QDeclarativeDebugClient client2("tst_QDeclarativeDebugClient::state()", m_conn);
- QCOMPARE(client2.state(), QDeclarativeDebugClient::NotConnected);
-
- QDeclarativeDebugClient client3("tst_QDeclarativeDebugClient::state3()", 0);
- QCOMPARE(client3.state(), QDeclarativeDebugClient::NotConnected);
-}
-
-void tst_QDeclarativeDebugClient::sendMessage()
-{
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::sendMessage()");
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::sendMessage()", m_conn);
-
- QByteArray msg = "hello!";
-
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
-
- client.sendMessage(msg);
- QByteArray resp = client.waitForResponse();
- QCOMPARE(resp, msg);
-}
-
-void tst_QDeclarativeDebugClient::parallelConnect()
-{
- QDeclarativeDebugConnection connection2;
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Another client is already connected");
- // will connect & immediately disconnect
- connection2.connectToHost("127.0.0.1", PORT);
- QVERIFY(connection2.waitForConnected());
- QTRY_COMPARE(connection2.state(), QAbstractSocket::UnconnectedState);
- QVERIFY(m_conn->isConnected());
-}
-
-void tst_QDeclarativeDebugClient::sequentialConnect()
-{
- QDeclarativeDebugConnection connection2;
- QDeclarativeDebugTestClient client2("tst_QDeclarativeDebugClient::handshake()", &connection2);
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::handshake()");
-
- m_conn->close();
- QVERIFY(!m_conn->isConnected());
- QCOMPARE(m_conn->state(), QAbstractSocket::UnconnectedState);
-
- // Make sure that the disconnect is actually delivered to the server
- QTest::qWait(100);
-
- connection2.connectToHost("127.0.0.1", PORT);
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
- QVERIFY(connection2.waitForConnected());
- QVERIFY(connection2.isConnected());
- QTRY_VERIFY(client2.state() == QDeclarativeDebugClient::Enabled);
-}
-
-int main(int argc, char *argv[])
-{
- int _argc = argc + 1;
- char **_argv = new char*[_argc];
- for (int i = 0; i < argc; ++i)
- _argv[i] = argv[i];
- char arg[] = "-qmljsdebugger=port:" STR_PORT;
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QDeclarativeDebugClient tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
-
-#include "tst_qdeclarativedebugclient.moc"
-
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro b/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro
deleted file mode 100644
index 5618995b4d..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro
+++ /dev/null
@@ -1,29 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativedebugjs
-QT += declarative-private testlib
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativedebugjs.cpp \
- ../shared/debugutil.cpp
-
-INCLUDEPATH += ../shared
-
-include (../../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-OTHER_FILES += data/test.qml data/test.js \
- data/timer.qml \
- data/exception.qml \
- data/oncompleted.qml \
- data/loadjsfile.qml \
- data/condition.qml \
- data/changeBreakpoint.qml \
- data/stepAction.qml \
- data/breakpointRelocation.qml \
- data/createComponent.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
deleted file mode 100644
index 7d57c8eda2..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
+++ /dev/null
@@ -1,1790 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtCore/QProcess>
-#include <QtCore/QTimer>
-#include <QtCore/QFileInfo>
-#include <QtCore/QDir>
-#include <QtCore/QMutex>
-#include <QtCore/QLibraryInfo>
-#include <QtDeclarative/private/qdeclarativedebugclient_p.h>
-#include <QtDeclarative/QJSEngine>
-
-//QDeclarativeDebugTest
-#include "../shared/debugutil_p.h"
-#include "../../../shared/util.h"
-
-const char *V8REQUEST = "v8request";
-const char *V8MESSAGE = "v8message";
-const char *SEQ = "seq";
-const char *TYPE = "type";
-const char *COMMAND = "command";
-const char *ARGUMENTS = "arguments";
-const char *STEPACTION = "stepaction";
-const char *STEPCOUNT = "stepcount";
-const char *EXPRESSION = "expression";
-const char *FRAME = "frame";
-const char *GLOBAL = "global";
-const char *DISABLEBREAK = "disable_break";
-const char *HANDLES = "handles";
-const char *INCLUDESOURCE = "includeSource";
-const char *FROMFRAME = "fromFrame";
-const char *TOFRAME = "toFrame";
-const char *BOTTOM = "bottom";
-const char *NUMBER = "number";
-const char *FRAMENUMBER = "frameNumber";
-const char *TYPES = "types";
-const char *IDS = "ids";
-const char *FILTER = "filter";
-const char *FROMLINE = "fromLine";
-const char *TOLINE = "toLine";
-const char *TARGET = "target";
-const char *LINE = "line";
-const char *COLUMN = "column";
-const char *ENABLED = "enabled";
-const char *CONDITION = "condition";
-const char *IGNORECOUNT = "ignoreCount";
-const char *BREAKPOINT = "breakpoint";
-const char *FLAGS = "flags";
-
-const char *CONTINEDEBUGGING = "continue";
-const char *EVALUATE = "evaluate";
-const char *LOOKUP = "lookup";
-const char *BACKTRACE = "backtrace";
-const char *SCOPE = "scope";
-const char *SCOPES = "scopes";
-const char *SCRIPTS = "scripts";
-const char *SOURCE = "source";
-const char *SETBREAKPOINT = "setbreakpoint";
-const char *CHANGEBREAKPOINT = "changebreakpoint";
-const char *CLEARBREAKPOINT = "clearbreakpoint";
-const char *SETEXCEPTIONBREAK = "setexceptionbreak";
-const char *V8FLAGS = "v8flags";
-const char *VERSION = "version";
-const char *DISCONNECT = "disconnect";
-const char *LISTBREAKPOINTS = "listbreakpoints";
-const char *GARBAGECOLLECTOR = "gc";
-//const char *PROFILE = "profile";
-
-const char *CONNECT = "connect";
-const char *INTERRUPT = "interrupt";
-const char *BREAKAFTERCOMPILE = "breakaftercompile";
-
-const char *REQUEST = "request";
-const char *IN = "in";
-const char *NEXT = "next";
-const char *OUT = "out";
-
-const char *FUNCTION = "function";
-const char *SCRIPT = "script";
-const char *SCRIPTREGEXP = "scriptRegExp";
-const char *EVENT = "event";
-
-const char *ALL = "all";
-const char *UNCAUGHT = "uncaught";
-
-//const char *PAUSE = "pause";
-//const char *RESUME = "resume";
-
-const char *BLOCKMODE = "-qmljsdebugger=port:3771,block";
-const char *NORMALMODE = "-qmljsdebugger=port:3771";
-const char *TEST_QMLFILE = "test.qml";
-const char *TEST_JSFILE = "test.js";
-const char *TIMER_QMLFILE = "timer.qml";
-const char *LOADJSFILE_QMLFILE = "loadjsfile.qml";
-const char *EXCEPTION_QMLFILE = "exception.qml";
-const char *ONCOMPLETED_QMLFILE = "oncompleted.qml";
-const char *CREATECOMPONENT_QMLFILE = "createComponent.qml";
-const char *CONDITION_QMLFILE = "condition.qml";
-const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml";
-const char *STEPACTION_QMLFILE = "stepAction.qml";
-const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml";
-
-#define VARIANTMAPINIT \
- QString obj("{}"); \
- QJSValue jsonVal = parser.call(QJSValueList() << obj); \
- jsonVal.setProperty(SEQ,QJSValue(seq++)); \
- jsonVal.setProperty(TYPE,REQUEST);
-
-
-#undef QVERIFY
-#define QVERIFY(statement) \
-do {\
- if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\
- if (QTest::currentTestFailed()) \
- qDebug().nospace() << "\nDEBUGGEE OUTPUT:\n" << process->output();\
- return;\
- }\
-} while (0)
-
-
-class QJSDebugClient;
-
-class tst_QDeclarativeDebugJS : public QDeclarativeDataTest
-{
- Q_OBJECT
-
- bool init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true);
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void cleanup();
-
- void connect();
- void interrupt();
- void breakAfterCompile();
- void getVersion();
- void getVersionWhenAttaching();
-
- void applyV8Flags();
-
- void disconnect();
-
- void gc();
-
- void listBreakpoints();
-
- void setBreakpointInScriptOnCompleted();
- void setBreakpointInScriptOnComponentCreated();
- void setBreakpointInScriptOnTimerCallback();
- void setBreakpointInScriptInDifferentFile();
- void setBreakpointInScriptOnComment();
- void setBreakpointInScriptOnEmptyLine();
- void setBreakpointInScriptWithCondition();
- //void setBreakpointInFunction(); //NOT SUPPORTED
- void setBreakpointOnEvent();
- void setBreakpointWhenAttaching();
-
- void changeBreakpoint();
- void changeBreakpointOnCondition();
-
- void clearBreakpoint();
-
- void setExceptionBreak();
-
- void stepNext();
- void stepNextWithCount();
- void stepIn();
- void stepOut();
- void continueDebugging();
-
- void backtrace();
-
- void getFrameDetails();
-
- void getScopeDetails();
-
- void evaluateInGlobalScope();
- void evaluateInLocalScope();
-
- void getScopes();
-
- void getScripts();
-
- void getSource();
-
- // void profile(); //NOT SUPPORTED
-
- // void verifyQMLOptimizerDisabled();
-
-private:
- QDeclarativeDebugProcess *process;
- QJSDebugClient *client;
- QDeclarativeDebugConnection *connection;
- QTime t;
-};
-
-class QJSDebugClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-public:
- enum StepAction
- {
- Continue,
- In,
- Out,
- Next
- };
-
- enum Exception
- {
- All,
- Uncaught
- };
-
-// enum ProfileCommand
-// {
-// Pause,
-// Resume
-// };
-
- QJSDebugClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("V8Debugger"), connection),
- seq(0)
- {
- parser = jsEngine.evaluate(QLatin1String("JSON.parse"));
- stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
- }
-
- void connect();
- void interrupt();
- void breakAfterCompile(bool enabled);
-
- void continueDebugging(StepAction stepAction, int stepCount = 1);
- void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
- void lookup(QList<int> handles, bool includeSource = false);
- void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
- void frame(int number = -1);
- void scope(int number = -1, int frameNumber = -1);
- void scopes(int frameNumber = -1);
- void scripts(int types = 4, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
- void source(int frame = -1, int fromLine = -1, int toLine = -1);
- void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = true, QString condition = QString(), int ignoreCount = -1);
- void changeBreakpoint(int breakpoint, bool enabled = true, QString condition = QString(), int ignoreCount = -1);
- void clearBreakpoint(int breakpoint);
- void setExceptionBreak(Exception type, bool enabled = false);
- void v8flags(QString flags);
- void version();
- //void profile(ProfileCommand command); //NOT SUPPORTED
- void disconnect();
- void gc();
- void listBreakpoints();
-
-protected:
- //inherited from QDeclarativeDebugClient
- void stateChanged(State state);
- void messageReceived(const QByteArray &data);
-
-signals:
- void enabled();
- void connected();
- void interruptRequested();
- void breakAfterCompileRequested();
- void result();
- void stopped();
-
-private:
- void sendMessage(const QByteArray &);
- void flushSendBuffer();
- QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray());
-
-private:
- QJSEngine jsEngine;
- int seq;
-
- QList<QByteArray> sendBuffer;
-public:
- QJSValue parser;
- QJSValue stringify;
- QByteArray response;
-
-};
-
-void QJSDebugClient::connect()
-{
- sendMessage(packMessage(CONNECT));
-}
-
-void QJSDebugClient::interrupt()
-{
- sendMessage(packMessage(INTERRUPT));
-}
-
-void QJSDebugClient::breakAfterCompile(bool enabled)
-{
- QByteArray request;
- QDataStream rs(&request, QIODevice::WriteOnly);
- rs << enabled;
- sendMessage(packMessage(BREAKAFTERCOMPILE, request));
-}
-
-void QJSDebugClient::continueDebugging(StepAction action, int count)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "continue",
- // "arguments" : { "stepaction" : <"in", "next" or "out">,
- // "stepcount" : <number of steps (default 1)>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CONTINEDEBUGGING)));
-
- if (action != Continue) {
- QJSValue args = parser.call(QJSValueList() << obj);
- switch (action) {
- case In: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(IN)));
- break;
- case Out: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(OUT)));
- break;
- case Next: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(NEXT)));
- break;
- default:break;
- }
- if (!args.isUndefined()) {
- if (count != 1)
- args.setProperty(QLatin1String(STEPCOUNT),QJSValue(count));
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::evaluate(QString expr, bool global, bool disableBreak, int frame, const QVariantMap &/*addContext*/)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "evaluate",
- // "arguments" : { "expression" : <expression to evaluate>,
- // "frame" : <number>,
- // "global" : <boolean>,
- // "disable_break" : <boolean>,
- // "additional_context" : [
- // { "name" : <name1>, "handle" : <handle1> },
- // { "name" : <name2>, "handle" : <handle2> },
- // ...
- // ]
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(EVALUATE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(EXPRESSION),QJSValue(expr));
-
- if (frame != -1)
- args.setProperty(QLatin1String(FRAME),QJSValue(frame));
-
- if (global)
- args.setProperty(QLatin1String(GLOBAL),QJSValue(global));
-
- if (disableBreak)
- args.setProperty(QLatin1String(DISABLEBREAK),QJSValue(disableBreak));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::lookup(QList<int> handles, bool includeSource)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "lookup",
- // "arguments" : { "handles" : <array of handles>,
- // "includeSource" : <boolean indicating whether the source will be included when script objects are returned>,
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LOOKUP)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- QString arr("[]");
- QJSValue array = parser.call(QJSValueList() << arr);
- int index = 0;
- foreach (int handle, handles) {
- array.setProperty(index++,QJSValue(handle));
- }
- args.setProperty(QLatin1String(HANDLES),array);
-
- if (includeSource)
- args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "backtrace",
- // "arguments" : { "fromFrame" : <number>
- // "toFrame" : <number>
- // "bottom" : <boolean, set to true if the bottom of the stack is requested>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(BACKTRACE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (fromFrame != -1)
- args.setProperty(QLatin1String(FROMFRAME),QJSValue(fromFrame));
-
- if (toFrame != -1)
- args.setProperty(QLatin1String(TOFRAME),QJSValue(toFrame));
-
- if (bottom)
- args.setProperty(QLatin1String(BOTTOM),QJSValue(bottom));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::frame(int number)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "frame",
- // "arguments" : { "number" : <frame number>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(FRAME)));
-
- if (number != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(NUMBER),QJSValue(number));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scope(int number, int frameNumber)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scope",
- // "arguments" : { "number" : <scope number>
- // "frameNumber" : <frame number, optional uses selected frame if missing>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPE)));
-
- if (number != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(NUMBER),QJSValue(number));
-
- if (frameNumber != -1)
- args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scopes(int frameNumber)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scopes",
- // "arguments" : { "frameNumber" : <frame number, optional uses selected frame if missing>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPES)));
-
- if (frameNumber != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVariant /*filter*/)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scripts",
- // "arguments" : { "types" : <types of scripts to retrieve
- // set bit 0 for native scripts
- // set bit 1 for extension scripts
- // set bit 2 for normal scripts
- // (default is 4 for normal scripts)>
- // "ids" : <array of id's of scripts to return. If this is not specified all scripts are requrned>
- // "includeSource" : <boolean indicating whether the source code should be included for the scripts returned>
- // "filter" : <string or number: filter string or script id.
- // If a number is specified, then only the script with the same number as its script id will be retrieved.
- // If a string is specified, then only scripts whose names contain the filter string will be retrieved.>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCRIPTS)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(TYPES),QJSValue(types));
-
- if (ids.count()) {
- QString arr("[]");
- QJSValue array = parser.call(QJSValueList() << arr);
- int index = 0;
- foreach (int id, ids) {
- array.setProperty(index++,QJSValue(id));
- }
- args.setProperty(QLatin1String(IDS),array);
- }
-
- if (includeSource)
- args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::source(int frame, int fromLine, int toLine)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "source",
- // "arguments" : { "frame" : <frame number (default selected frame)>
- // "fromLine" : <from line within the source default is line 0>
- // "toLine" : <to line within the source this line is not included in
- // the result default is the number of lines in the script>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SOURCE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (frame != -1)
- args.setProperty(QLatin1String(FRAME),QJSValue(frame));
-
- if (fromLine != -1)
- args.setProperty(QLatin1String(FROMLINE),QJSValue(fromLine));
-
- if (toLine != -1)
- args.setProperty(QLatin1String(TOLINE),QJSValue(toLine));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int column, bool enabled, QString condition, int ignoreCount)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "setbreakpoint",
- // "arguments" : { "type" : <"function" or "script" or "scriptId" or "scriptRegExp">
- // "target" : <function expression or script identification>
- // "line" : <line in script or function>
- // "column" : <character position within the line>
- // "enabled" : <initial enabled state. True or false, default is true>
- // "condition" : <string with break point condition>
- // "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0>
- // }
- // }
-
- if (type == QLatin1String(EVENT)) {
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << target.toUtf8() << enabled;
- sendMessage(packMessage(QByteArray("breakonsignal"), reply));
-
- } else {
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(TYPE),QJSValue(type));
- args.setProperty(QLatin1String(TARGET),QJSValue(target));
-
- if (line != -1)
- args.setProperty(QLatin1String(LINE),QJSValue(line));
-
- if (column != -1)
- args.setProperty(QLatin1String(COLUMN),QJSValue(column));
-
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!condition.isEmpty())
- args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
-
- if (ignoreCount != -1)
- args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
- }
-}
-
-void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled, QString condition, int ignoreCount)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "changebreakpoint",
- // "arguments" : { "breakpoint" : <number of the break point to clear>
- // "enabled" : <initial enabled state. True or false, default is true>
- // "condition" : <string with break point condition>
- // "ignoreCount" : <number specifying the number of break point hits }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CHANGEBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
-
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!condition.isEmpty())
- args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
-
- if (ignoreCount != -1)
- args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::clearBreakpoint(int breakpoint)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "clearbreakpoint",
- // "arguments" : { "breakpoint" : <number of the break point to clear>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CLEARBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::setExceptionBreak(Exception type, bool enabled)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "setexceptionbreak",
- // "arguments" : { "type" : <string: "all", or "uncaught">,
- // "enabled" : <optional bool: enables the break type if true>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETEXCEPTIONBREAK)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (type == All)
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
- else if (type == Uncaught)
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(UNCAUGHT)));
-
- if (enabled)
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::v8flags(QString flags)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "v8flags",
- // "arguments" : { "flags" : <string: a sequence of v8 flags just like those used on the command line>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(V8FLAGS)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(FLAGS),QJSValue(flags));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::version()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "version",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(VERSION)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-//void QJSDebugClient::profile(ProfileCommand command)
-//{
-//// { "seq" : <number>,
-//// "type" : "request",
-//// "command" : "profile",
-//// "arguments" : { "command" : "resume" or "pause" }
-//// }
-// VARIANTMAPINIT;
-// jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PROFILE)));
-
-// QJSValue args = parser.call(QJSValueList() << obj);
-
-// if (command == Resume)
-// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(RESUME)));
-// else
-// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PAUSE)));
-
-// args.setProperty(QLatin1String("modules"),QJSValue(1));
-// if (!args.isUndefined()) {
-// jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
-// }
-
-// QJSValue json = stringify.call(QJSValueList() << jsonVal);
-// sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-//}
-
-void QJSDebugClient::disconnect()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "disconnect",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(DISCONNECT)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(DISCONNECT, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::gc()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "gc",
- // "arguments" : { "type" : <string: "all">,
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(GARBAGECOLLECTOR)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::listBreakpoints()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "listbreakpoints",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LISTBREAKPOINTS)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::stateChanged(State state)
-{
- if (state == Enabled) {
- flushSendBuffer();
- emit enabled();
- }
-}
-
-void QJSDebugClient::messageReceived(const QByteArray &data)
-{
- QDataStream ds(data);
- QByteArray command;
- ds >> command;
-
- if (command == "V8DEBUG") {
- QByteArray type;
- ds >> type >> response;
-
- if (type == CONNECT) {
- emit connected();
-
- } else if (type == INTERRUPT) {
- emit interruptRequested();
-
- } else if (type == V8MESSAGE) {
- QString jsonString(response);
- QVariantMap value = parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
- QString type = value.value("type").toString();
-
- if (type == "response") {
-
- if (!value.value("success").toBool()) {
-// qDebug() << "Error: The test case will fail since no signal is emitted";
- return;
- }
-
- QString debugCommand(value.value("command").toString());
- if (debugCommand == "backtrace" ||
- debugCommand == "lookup" ||
- debugCommand == "setbreakpoint" ||
- debugCommand == "evaluate" ||
- debugCommand == "listbreakpoints" ||
- debugCommand == "version" ||
- debugCommand == "v8flags" ||
- debugCommand == "disconnect" ||
- debugCommand == "gc" ||
- debugCommand == "changebreakpoint" ||
- debugCommand == "clearbreakpoint" ||
- debugCommand == "frame" ||
- debugCommand == "scope" ||
- debugCommand == "scopes" ||
- debugCommand == "scripts" ||
- debugCommand == "source" ||
- debugCommand == "setexceptionbreak" /*||
- debugCommand == "profile"*/) {
- emit result();
-
- } else {
- // DO NOTHING
- }
-
- } else if (type == QLatin1String(EVENT)) {
- QString event(value.value(QLatin1String(EVENT)).toString());
-
- if (event == "break" ||
- event == "exception")
- emit stopped();
- }
-
- } else if (type == BREAKAFTERCOMPILE) {
- emit breakAfterCompileRequested();
-
- }
- }
-}
-
-void QJSDebugClient::sendMessage(const QByteArray &msg)
-{
- if (state() == Enabled) {
- QDeclarativeDebugClient::sendMessage(msg);
- } else {
- sendBuffer.append(msg);
- }
-}
-
-void QJSDebugClient::flushSendBuffer()
-{
- foreach (const QByteArray &msg, sendBuffer)
- QDeclarativeDebugClient::sendMessage(msg);
- sendBuffer.clear();
-}
-
-QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray &message)
-{
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- QByteArray cmd = "V8DEBUG";
- rs << cmd << type << message;
- return reply;
-}
-
-void tst_QDeclarativeDebugJS::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- t.start();
- process = 0;
- client = 0;
- connection = 0;
-}
-
-void tst_QDeclarativeDebugJS::cleanupTestCase()
-{
- if (process) {
- process->stop();
- delete process;
- }
-
- if (client)
- delete client;
-
- if (connection)
- delete connection;
-
-// qDebug() << "Time Elapsed:" << t.elapsed();
-}
-
-bool tst_QDeclarativeDebugJS::init(const QString &qmlFile, bool blockMode)
-{
- connection = new QDeclarativeDebugConnection();
- process = new QDeclarativeDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
- client = new QJSDebugClient(connection);
-
- QStringList systemEnvironment = QProcess::systemEnvironment();
- systemEnvironment << "QML_DISABLE_OPTIMIZER=1";
- process->setEnvironment(systemEnvironment);
- if (blockMode)
- process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile));
- else
- process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile));
-
- if (!process->waitForSessionStart()) {
- return false;
- }
-
- connection->connectToHost("127.0.0.1", 3771);
- if (!connection->waitForConnected())
- return false;
-
- return QDeclarativeDebugTest::waitForSignal(client, SIGNAL(enabled()));
-}
-
-void tst_QDeclarativeDebugJS::cleanup()
-{
- if (process) {
- process->stop();
- delete process;
- }
-
- if (client)
- delete client;
-
- if (connection)
- delete connection;
-
- process = 0;
- client = 0;
- connection = 0;
-}
-
-void tst_QDeclarativeDebugJS::connect()
-{
- //void connect()
-
- QVERIFY(init());
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(connected())));
-}
-
-void tst_QDeclarativeDebugJS::interrupt()
-{
- //void connect()
-
- QVERIFY(init());
- client->connect();
-
- client->interrupt();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(interruptRequested())));
-}
-
-void tst_QDeclarativeDebugJS::breakAfterCompile()
-{
- //void breakAfterCompile(bool enabled)
-
- QVERIFY(init());
- client->breakAfterCompile(true);
- client->connect();
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(breakAfterCompileRequested())));
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-}
-
-void tst_QDeclarativeDebugJS::getVersion()
-{
- //void version()
-
- QVERIFY(init());
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(connected())));
-
- client->version();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::getVersionWhenAttaching()
-{
- //void version()
-
- QVERIFY(init(QLatin1String(TIMER_QMLFILE), false));
- client->connect();
-
- client->version();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::applyV8Flags()
-{
- //void v8flags(QString flags)
-
- QVERIFY(init());
- client->connect();
-
- client->v8flags(QString());
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::disconnect()
-{
- //void disconnect()
-
- QVERIFY(init());
- client->connect();
-
- client->disconnect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::gc()
-{
- //void gc()
-
- QVERIFY(init());
- client->connect();
-
- client->gc();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::listBreakpoints()
-{
- //void listBreakpoints()
-
- int sourceLine1 = 47;
- int sourceLine2 = 48;
- int sourceLine3 = 49;
-
- QVERIFY(init());
- client->connect();
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine3, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
- client->listBreakpoints();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QList<QVariant> breakpoints = value.value("body").toMap().value("breakpoints").toList();
-
- QCOMPARE(breakpoints.count(), 3);
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnCompleted()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnComponentCreated()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 47;
- QVERIFY(init(CREATECOMPONENT_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnTimerCallback()
-{
- int sourceLine = 48;
- QVERIFY(init(TIMER_QMLFILE));
-
- client->connect();
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptInDifferentFile()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 43;
- QVERIFY(init(LOADJSFILE_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_JSFILE), sourceLine, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnComment()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 47;
- int actualLine = 49;
- QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnEmptyLine()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 48;
- int actualLine = 49;
- QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptWithCondition()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int out = 10;
- int sourceLine = 50;
- QVERIFY(init(CONDITION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10"));
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Get the frame index
- QString jsonString = client->response;
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- int frameIndex = body.value("index").toInt();
-
- //Verify the value of 'result'
- client->evaluate(QLatin1String("a"),frameIndex);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QVERIFY(body.value("value").toInt() > out);
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointWhenAttaching()
-{
- int sourceLine = 49;
- QVERIFY(init(QLatin1String(TIMER_QMLFILE), false));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-}
-
-//void tst_QDeclarativeDebugJS::setBreakpointInFunction()
-//{
-// //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
-// int actualLine = 31;
-
-// client->connect();
-// client->setBreakpoint(QLatin1String(FUNCTION), QLatin1String("doSomethingElse"), -1, -1, true);
-
-// QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
-// QString jsonString(client->response);
-// QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
-// QVariantMap body = value.value("body").toMap();
-
-// QCOMPARE(body.value("sourceLine").toInt(), actualLine);
-// QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QMLFILE));
-//}
-
-void tst_QDeclarativeDebugJS::setBreakpointOnEvent()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- QVERIFY(init(TIMER_QMLFILE));
-
- client->connect();
-
- client->setBreakpoint(QLatin1String(EVENT), QLatin1String("triggered"), -1, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
-}
-
-
-void tst_QDeclarativeDebugJS::changeBreakpoint()
-{
- //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine1 = 50;
- int sourceLine2 = 51;
- QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Will hit 1st brakpoint, change this breakpoint enable = false
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
- QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
-
- int breakpoint = breakpointsHit.at(0).toInt();
- client->changeBreakpoint(breakpoint,false);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Hit 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Should stop at 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
-}
-
-void tst_QDeclarativeDebugJS::changeBreakpointOnCondition()
-{
- //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine1 = 50;
- int sourceLine2 = 51;
-
- QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Will hit 1st brakpoint, change this breakpoint enable = false
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
- QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
-
- int breakpoint = breakpointsHit.at(0).toInt();
- client->changeBreakpoint(breakpoint, false, QLatin1String("d == 0"));
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Hit 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Should stop at 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
-
-}
-
-void tst_QDeclarativeDebugJS::clearBreakpoint()
-{
- //void clearBreakpoint(int breakpoint);
-
- int sourceLine1 = 50;
- int sourceLine2 = 51;
- QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Will hit 1st brakpoint, change this breakpoint enable = false
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
- QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
-
- int breakpoint = breakpointsHit.at(0).toInt();
- client->clearBreakpoint(breakpoint);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Hit 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Should stop at 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
-}
-
-void tst_QDeclarativeDebugJS::setExceptionBreak()
-{
- //void setExceptionBreak(QString type, bool enabled = false);
-
- QVERIFY(init(EXCEPTION_QMLFILE));
- client->setExceptionBreak(QJSDebugClient::All,true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-}
-
-void tst_QDeclarativeDebugJS::stepNext()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine = 50;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::Next);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 1);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::stepNextWithCount()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine = 50;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::Next, 2);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 2);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::stepIn()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine = 54;
- int actualLine = 50;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::In);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::stepOut()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine = 50;
- int actualLine = 54;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::Out);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::continueDebugging()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine1 = 54;
- int sourceLine2 = 51;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true);
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::Continue);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::backtrace()
-{
- //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->backtrace();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::getFrameDetails()
-{
- //void frame(int number = -1);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->frame();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::getScopeDetails()
-{
- //void scope(int number = -1, int frameNumber = -1);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->scope();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::evaluateInGlobalScope()
-{
- //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
-
- QVERIFY(init());
-
- client->connect();
- client->evaluate(QLatin1String("print('Hello World')"), true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Verify the value of 'print'
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("text").toString(),QLatin1String("undefined"));
-}
-
-void tst_QDeclarativeDebugJS::evaluateInLocalScope()
-{
- //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->frame();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Get the frame index
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- int frameIndex = body.value("index").toInt();
-
- client->evaluate(QLatin1String("root.a"), frameIndex);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Verify the value of 'timer.interval'
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("value").toInt(),10);
-}
-
-void tst_QDeclarativeDebugJS::getScopes()
-{
- //void scopes(int frameNumber = -1);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->scopes();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::getScripts()
-{
- //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
-
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-23475 - Unreliable test on Mac OS X");
-#endif
-
- QVERIFY(init());
-
- client->connect();
-
- client->scripts();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList()
- << QJSValue(jsonString)).toVariant().toMap();
-
- QList<QVariant> scripts = value.value("body").toList();
-
- QCOMPARE(scripts.count(), 2);
-}
-
-void tst_QDeclarativeDebugJS::getSource()
-{
- //void source(int frame = -1, int fromLine = -1, int toLine = -1);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->source();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-QTEST_MAIN(tst_QDeclarativeDebugJS)
-
-#include "tst_qdeclarativedebugjs.moc"
-
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro b/tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro
deleted file mode 100644
index 015a7232f6..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativedebugservice
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativedebugservice.cpp \
- ../shared/debugutil.cpp
-
-CONFIG += parallel_test declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
deleted file mode 100644
index c38b7854e0..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <private/qdeclarativedebugclient_p.h>
-#include <private/qdeclarativedebugservice_p.h>
-
-#include "../../../shared/util.h"
-#include "../shared/debugutil_p.h"
-
-#define PORT 13769
-#define STR_PORT "13769"
-
-class tst_QDeclarativeDebugService : public QObject
-{
- Q_OBJECT
-private:
- QDeclarativeDebugConnection *m_conn;
-
-private slots:
- void initTestCase();
-
- void name();
- void version();
- void state();
- void sendMessage();
- void idForObject();
- void objectForId();
- void objectToString();
-};
-
-void tst_QDeclarativeDebugService::initTestCase()
-{
- const QString waitingMsg = QString("QDeclarativeDebugServer: Waiting for connection on port %1...").arg(PORT);
- QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
- new QDeclarativeEngine(this);
-
- m_conn = new QDeclarativeDebugConnection(this);
-
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
- for (int i = 0; i < 50; ++i) {
- // try for 5 seconds ...
- m_conn->connectToHost("127.0.0.1", PORT);
- if (m_conn->waitForConnected())
- break;
- QTest::qSleep(100);
- }
- QVERIFY(m_conn->isConnected());
-
- QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
-}
-
-void tst_QDeclarativeDebugService::name()
-{
- QString name = "tst_QDeclarativeDebugService::name()";
-
- QDeclarativeDebugService service(name, 1);
- QCOMPARE(service.name(), name);
-}
-
-void tst_QDeclarativeDebugService::version()
-{
- QString name = "tst_QDeclarativeDebugService::name()";
-
- QDeclarativeDebugService service(name, 2);
- QCOMPARE(service.version(), 2.0f);
-}
-
-void tst_QDeclarativeDebugService::state()
-{
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::state()");
- QCOMPARE(service.state(), QDeclarativeDebugService::Unavailable);
-
- {
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::state()", m_conn);
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
- QTRY_COMPARE(service.state(), QDeclarativeDebugService::Enabled);
- }
-
-
- QTRY_COMPARE(service.state(), QDeclarativeDebugService::Unavailable);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugService: Conflicting plugin name \"tst_QDeclarativeDebugService::state()\" ");
- QDeclarativeDebugTestService duplicate("tst_QDeclarativeDebugService::state()");
- QCOMPARE(duplicate.state(), QDeclarativeDebugService::NotConnected);
-}
-
-void tst_QDeclarativeDebugService::sendMessage()
-{
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::sendMessage()");
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::sendMessage()", m_conn);
-
- QByteArray msg = "hello!";
-
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
- QTRY_COMPARE(service.state(), QDeclarativeDebugService::Enabled);
-
- client.sendMessage(msg);
- QByteArray resp = client.waitForResponse();
- QCOMPARE(resp, msg);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugService: Conflicting plugin name \"tst_QDeclarativeDebugService::sendMessage()\" ");
- QDeclarativeDebugTestService duplicate("tst_QDeclarativeDebugService::sendMessage()");
- duplicate.sendMessage("msg");
-}
-
-void tst_QDeclarativeDebugService::idForObject()
-{
- QCOMPARE(QDeclarativeDebugService::idForObject(0), -1);
-
- QObject *objA = new QObject;
-
- int idA = QDeclarativeDebugService::idForObject(objA);
- QVERIFY(idA >= 0);
- QCOMPARE(QDeclarativeDebugService::objectForId(idA), objA);
-
- int idAA = QDeclarativeDebugService::idForObject(objA);
- QCOMPARE(idAA, idA);
-
- QObject *objB = new QObject;
- int idB = QDeclarativeDebugService::idForObject(objB);
- QVERIFY(idB != idA);
- QCOMPARE(QDeclarativeDebugService::objectForId(idB), objB);
-
- delete objA;
- delete objB;
-}
-
-void tst_QDeclarativeDebugService::objectForId()
-{
- QCOMPARE(QDeclarativeDebugService::objectForId(-1), static_cast<QObject*>(0));
- QCOMPARE(QDeclarativeDebugService::objectForId(1), static_cast<QObject*>(0));
-
- QObject *obj = new QObject;
- int id = QDeclarativeDebugService::idForObject(obj);
- QCOMPARE(QDeclarativeDebugService::objectForId(id), obj);
-
- delete obj;
- QCOMPARE(QDeclarativeDebugService::objectForId(id), static_cast<QObject*>(0));
-}
-
-void tst_QDeclarativeDebugService::objectToString()
-{
- QCOMPARE(QDeclarativeDebugService::objectToString(0), QString("NULL"));
-
- QObject *obj = new QObject;
- QCOMPARE(QDeclarativeDebugService::objectToString(obj), QString("QObject: <unnamed>"));
-
- obj->setObjectName("Hello");
- QCOMPARE(QDeclarativeDebugService::objectToString(obj), QString("QObject: Hello"));
- delete obj;
-}
-
-
-int main(int argc, char *argv[])
-{
- int _argc = argc + 1;
- char **_argv = new char*[_argc];
- for (int i = 0; i < argc; ++i)
- _argv[i] = argv[i];
- char arg[] = "-qmljsdebugger=port:" STR_PORT;
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QDeclarativeDebugService tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
-
-#include "tst_qdeclarativedebugservice.moc"
diff --git a/tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro b/tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro
deleted file mode 100644
index 6b414d3c32..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeenginedebug
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativeenginedebug.cpp \
- ../shared/debugutil.cpp
-
-CONFIG += parallel_test declarative_debug
-
-QT += core-private declarative-private quick-private v8-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp b/tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp
deleted file mode 100644
index 246ba6080a..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp
+++ /dev/null
@@ -1,1235 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtQuick/qquickitem.h>
-
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativeboundsignal_p.h>
-#include <private/qdeclarativeenginedebug_p.h>
-#include <private/qdeclarativedebugservice_p.h>
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativeproperty_p.h>
-
-#include "../shared/debugutil_p.h"
-
-Q_DECLARE_METATYPE(QDeclarativeDebugWatch::State)
-
-class tst_QDeclarativeEngineDebug : public QObject
-{
- Q_OBJECT
-
-private:
- QDeclarativeDebugObjectReference findRootObject(int context = 0, bool recursive = false);
- QDeclarativeDebugPropertyReference findProperty(const QList<QDeclarativeDebugPropertyReference> &props, const QString &name) const;
- void waitForQuery(QDeclarativeDebugQuery *query);
-
- void recursiveObjectTest(QObject *o, const QDeclarativeDebugObjectReference &oref, bool recursive) const;
-
- void recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const;
- void recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const;
- void compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const;
-
- QDeclarativeDebugConnection *m_conn;
- QDeclarativeEngineDebug *m_dbg;
- QDeclarativeEngine *m_engine;
- QQuickItem *m_rootItem;
-
- QObjectList m_components;
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void watch_property();
- void watch_object();
- void watch_expression();
- void watch_expression_data();
- void watch_context();
- void watch_file();
-
- void queryAvailableEngines();
- void queryRootContexts();
- void queryObject();
- void queryObject_data();
- void queryExpressionResult();
- void queryExpressionResult_data();
-
- void tst_QDeclarativeDebugFileReference();
- void tst_QDeclarativeDebugEngineReference();
- void tst_QDeclarativeDebugObjectReference();
- void tst_QDeclarativeDebugContextReference();
- void tst_QDeclarativeDebugPropertyReference();
-
- void setBindingForObject();
- void setMethodBody();
- void queryObjectTree();
- void setBindingInStates();
-};
-
-class NonScriptProperty : public QObject {
- Q_OBJECT
- Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false)
-public:
- int nonScriptProp() const { return 0; }
- void setNonScriptProp(int) {}
-signals:
- void nonScriptPropChanged();
-};
-QML_DECLARE_TYPE(NonScriptProperty)
-
-
-QDeclarativeDebugObjectReference tst_QDeclarativeEngineDebug::findRootObject(int context, bool recursive)
-{
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- if (q_engines->engines().count() == 0)
- return QDeclarativeDebugObjectReference();
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- if (q_context->rootContext().objects().count() == 0)
- return QDeclarativeDebugObjectReference();
- QDeclarativeDebugObjectQuery *q_obj = recursive ?
- m_dbg->queryObjectRecursive(q_context->rootContext().objects()[context], this) :
- m_dbg->queryObject(q_context->rootContext().objects()[context], this);
- waitForQuery(q_obj);
-
- QDeclarativeDebugObjectReference result = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- return result;
-}
-
-QDeclarativeDebugPropertyReference tst_QDeclarativeEngineDebug::findProperty(const QList<QDeclarativeDebugPropertyReference> &props, const QString &name) const
-{
- foreach(const QDeclarativeDebugPropertyReference &p, props) {
- if (p.name() == name)
- return p;
- }
- return QDeclarativeDebugPropertyReference();
-}
-
-void tst_QDeclarativeEngineDebug::waitForQuery(QDeclarativeDebugQuery *query)
-{
- QVERIFY(query);
- QCOMPARE(query->parent(), qobject_cast<QObject*>(this));
- QVERIFY(query->state() == QDeclarativeDebugQuery::Waiting);
- if (!QDeclarativeDebugTest::waitForSignal(query, SIGNAL(stateChanged(QDeclarativeDebugQuery::State))))
- QFAIL("query timed out");
-}
-
-void tst_QDeclarativeEngineDebug::recursiveObjectTest(QObject *o, const QDeclarativeDebugObjectReference &oref, bool recursive) const
-{
- const QMetaObject *meta = o->metaObject();
-
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(meta);
- QString className = type ? QString(type->qmlTypeName()) : QString(meta->className());
- className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
-
- QCOMPARE(oref.debugId(), QDeclarativeDebugService::idForObject(o));
- QCOMPARE(oref.name(), o->objectName());
- QCOMPARE(oref.className(), className);
- QCOMPARE(oref.contextDebugId(), QDeclarativeDebugService::idForObject(qmlContext(o)));
-
- const QObjectList &children = o->children();
- for (int i=0; i<children.count(); i++) {
- QObject *child = children[i];
- if (!qmlContext(child))
- continue;
- int debugId = QDeclarativeDebugService::idForObject(child);
- QVERIFY(debugId >= 0);
-
- QDeclarativeDebugObjectReference cref;
- foreach (const QDeclarativeDebugObjectReference &ref, oref.children()) {
- if (ref.debugId() == debugId) {
- cref = ref;
- break;
- }
- }
- QVERIFY(cref.debugId() >= 0);
-
- if (recursive)
- recursiveObjectTest(child, cref, true);
- }
-
- foreach (const QDeclarativeDebugPropertyReference &p, oref.properties()) {
- QCOMPARE(p.objectDebugId(), QDeclarativeDebugService::idForObject(o));
-
- // signal properties are fake - they are generated from QDeclarativeBoundSignal children
- if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) {
- QList<QDeclarativeBoundSignal*> signalHandlers = o->findChildren<QDeclarativeBoundSignal*>();
- QString signal = p.value().toString();
- bool found = false;
- for (int i = 0; i < signalHandlers.count(); ++i)
- if (signalHandlers.at(i)->expression()->expression() == signal) {
- found = true;
- break;
- }
- QVERIFY(found);
- QVERIFY(p.valueTypeName().isEmpty());
- QVERIFY(p.binding().isEmpty());
- QVERIFY(!p.hasNotifySignal());
- continue;
- }
-
- QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name().toUtf8().constData()));
-
- QCOMPARE(p.name(), QString::fromUtf8(pmeta.name()));
-
- if (pmeta.type() < QVariant::UserType && pmeta.userType() != QMetaType::QVariant) // TODO test complex types
- QCOMPARE(p.value(), pmeta.read(o));
-
- if (p.name() == "parent")
- QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QQuickItem*");
- else
- QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName()));
-
- QDeclarativeAbstractBinding *binding =
- QDeclarativePropertyPrivate::binding(QDeclarativeProperty(o, p.name()));
- if (binding)
- QCOMPARE(binding->expression(), p.binding());
-
- QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal());
-
- QVERIFY(pmeta.isValid());
- }
-}
-
-void tst_QDeclarativeEngineDebug::recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const
-{
- QCOMPARE(a.debugId(), b.debugId());
- QCOMPARE(a.className(), b.className());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.contextDebugId(), b.contextDebugId());
-
- QCOMPARE(a.source().url(), b.source().url());
- QCOMPARE(a.source().lineNumber(), b.source().lineNumber());
- QCOMPARE(a.source().columnNumber(), b.source().columnNumber());
-
- QCOMPARE(a.properties().count(), b.properties().count());
- QCOMPARE(a.children().count(), b.children().count());
-
- QList<QDeclarativeDebugPropertyReference> aprops = a.properties();
- QList<QDeclarativeDebugPropertyReference> bprops = b.properties();
-
- for (int i=0; i<aprops.count(); i++)
- compareProperties(aprops[i], bprops[i]);
-
- for (int i=0; i<a.children().count(); i++)
- recursiveCompareObjects(a.children()[i], b.children()[i]);
-}
-
-void tst_QDeclarativeEngineDebug::recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const
-{
- QCOMPARE(a.debugId(), b.debugId());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.objects().count(), b.objects().count());
- QCOMPARE(a.contexts().count(), b.contexts().count());
-
- for (int i=0; i<a.objects().count(); i++)
- recursiveCompareObjects(a.objects()[i], b.objects()[i]);
-
- for (int i=0; i<a.contexts().count(); i++)
- recursiveCompareContexts(a.contexts()[i], b.contexts()[i]);
-}
-
-void tst_QDeclarativeEngineDebug::compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const
-{
- QCOMPARE(a.objectDebugId(), b.objectDebugId());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.value(), b.value());
- QCOMPARE(a.valueTypeName(), b.valueTypeName());
- QCOMPARE(a.binding(), b.binding());
- QCOMPARE(a.hasNotifySignal(), b.hasNotifySignal());
-}
-
-void tst_QDeclarativeEngineDebug::initTestCase()
-{
- qRegisterMetaType<QDeclarativeDebugWatch::State>();
- qmlRegisterType<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement");
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768...");
- m_engine = new QDeclarativeEngine(this);
-
- QList<QByteArray> qml;
- qml << "import QtQuick 2.0\n"
- "import Test 1.0\n"
- "Item {"
- "id: root\n"
- "width: 10; height: 20; scale: blueRect.scale;"
- "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
- "Text { color: blueRect.color; }"
- "MouseArea {"
- "onEntered: { console.log('hello') }"
- "}"
- "property variant varObj\n"
- "property variant varObjList: []\n"
- "property variant varObjMap\n"
- "Component.onCompleted: {\n"
- "varObj = blueRect;\n"
- "var list = varObjList;\n"
- "list[0] = blueRect;\n"
- "varObjList = list;\n"
- "var map = new Object;\n"
- "map.rect = blueRect;\n"
- "varObjMap = map;\n"
- "}\n"
- "NonScriptPropertyElement {\n"
- "}\n"
- "}";
-
- // add second component to test multiple root contexts
- qml << "import QtQuick 2.0\n"
- "Item {}";
-
- // and a third to test methods
- qml << "import QtQuick 2.0\n"
- "Item {"
- "function myMethodNoArgs() { return 3; }\n"
- "function myMethod(a) { return a + 9; }\n"
- "function myMethodIndirect() { myMethod(3); }\n"
- "}";
-
- // and a fourth to test states
- qml << "import QtQuick 2.0\n"
- "Rectangle {\n"
- "id:rootRect\n"
- "width:100\n"
- "states: [\n"
- "State {\n"
- "name:\"state1\"\n"
- "PropertyChanges {\n"
- "target:rootRect\n"
- "width:200\n"
- "}\n"
- "}\n"
- "]\n"
- "transitions: [\n"
- "Transition {\n"
- "from:\"*\"\n"
- "to:\"state1\"\n"
- "PropertyAnimation {\n"
- "target:rootRect\n"
- "property:\"width\"\n"
- "duration:100\n"
- "}\n"
- "}\n"
- "]\n"
- "}\n"
- ;
-
- for (int i=0; i<qml.count(); i++) {
- QDeclarativeComponent component(m_engine);
- component.setData(qml[i], QUrl::fromLocalFile(""));
- QVERIFY(component.isReady()); // fails if bad syntax
- m_components << qobject_cast<QQuickItem*>(component.create());
- }
- m_rootItem = qobject_cast<QQuickItem*>(m_components.first());
-
- // add an extra context to test for multiple contexts
- QDeclarativeContext *context = new QDeclarativeContext(m_engine->rootContext(), this);
- context->setObjectName("tst_QDeclarativeDebug_childContext");
-
- m_conn = new QDeclarativeDebugConnection(this);
- m_conn->connectToHost("127.0.0.1", 3768);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
- bool ok = m_conn->waitForConnected();
- QVERIFY(ok);
- QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
- QTRY_VERIFY(m_dbg->state() == QDeclarativeEngineDebug::Enabled);
-}
-
-void tst_QDeclarativeEngineDebug::cleanupTestCase()
-{
- delete m_dbg;
- delete m_conn;
- qDeleteAll(m_components);
- delete m_engine;
-}
-
-void tst_QDeclarativeEngineDebug::setMethodBody()
-{
- QDeclarativeDebugObjectReference obj = findRootObject(2);
-
- QObject *root = m_components.at(2);
- // Without args
- {
- QVariant rv;
- QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, rv)));
- QVERIFY(rv == QVariant(qreal(3)));
-
-
- QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethodNoArgs", "return 7"));
- QTest::qWait(100);
-
- QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, rv)));
- QVERIFY(rv == QVariant(qreal(7)));
- }
-
- // With args
- {
- QVariant rv;
- QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
- QVERIFY(rv == QVariant(qreal(28)));
-
- QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethod", "return a + 7"));
- QTest::qWait(100);
-
- QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
- QVERIFY(rv == QVariant(qreal(26)));
- }
-}
-
-void tst_QDeclarativeEngineDebug::watch_property()
-{
- QDeclarativeDebugObjectReference obj = findRootObject();
- QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width");
-
- QDeclarativeDebugPropertyWatch *watch;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- watch = unconnected->addWatch(prop, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QDeclarativeDebugPropertyReference(), this);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(prop, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->name(), prop.name());
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
-
- int origWidth = m_rootItem->property("width").toInt();
- m_rootItem->setProperty("width", origWidth*2);
-
- // stateChanged() is received before valueChanged()
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
- QCOMPARE(spy.count(), 1);
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // restore original value and verify spy doesn't get additional signal since watch has been removed
- m_rootItem->setProperty("width", origWidth);
- QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
-
- QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name().toUtf8());
- QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));
-}
-
-void tst_QDeclarativeEngineDebug::watch_object()
-{
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QVERIFY(q_engines->engines().count() > 0);
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- QVERIFY(q_context->rootContext().objects().count() > 0);
- QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
- waitForQuery(q_obj);
-
- QDeclarativeDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- QDeclarativeDebugWatch *watch;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- watch = unconnected->addWatch(obj, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), this);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
-
- int origWidth = m_rootItem->property("width").toInt();
- int origHeight = m_rootItem->property("height").toInt();
- m_rootItem->setProperty("width", origWidth*2);
- m_rootItem->setProperty("height", origHeight*2);
-
- // stateChanged() is received before any valueChanged() signals
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
- QVERIFY(spy.count() > 0);
-
- int newWidth = -1;
- int newHeight = -1;
- for (int i=0; i<spy.count(); i++) {
- const QVariantList &values = spy[i];
- if (values[0].value<QByteArray>() == "width")
- newWidth = values[1].value<QVariant>().toInt();
- else if (values[0].value<QByteArray>() == "height")
- newHeight = values[1].value<QVariant>().toInt();
-
- }
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // since watch has been removed, restoring the original values should not trigger a valueChanged()
- spy.clear();
- m_rootItem->setProperty("width", origWidth);
- m_rootItem->setProperty("height", origHeight);
- QTest::qWait(100);
- QCOMPARE(spy.count(), 0);
-
- QCOMPARE(newWidth, origWidth * 2);
- QCOMPARE(newHeight, origHeight * 2);
-}
-
-void tst_QDeclarativeEngineDebug::watch_expression()
-{
- QFETCH(QString, expr);
- QFETCH(int, increment);
- QFETCH(int, incrementCount);
-
- int origWidth = m_rootItem->property("width").toInt();
-
- QDeclarativeDebugObjectReference obj = findRootObject();
-
- QDeclarativeDebugObjectExpressionWatch *watch;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- watch = unconnected->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), expr, this);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->expression(), expr);
-
- QSignalSpy spyState(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State)));
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
- int expectedSpyCount = incrementCount + 1; // should also get signal with expression's initial value
-
- int width = origWidth;
- for (int i=0; i<incrementCount+1; i++) {
- if (i > 0) {
- width += increment;
- m_rootItem->setProperty("width", width);
- }
- if (!QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
- QFAIL("Did not receive valueChanged() for expression");
- }
-
- if (spyState.count() == 0)
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(spyState.count(), 1);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // restore original value and verify spy doesn't get a signal since watch has been removed
- m_rootItem->setProperty("width", origWidth);
- QTest::qWait(100);
- QCOMPARE(spy.count(), expectedSpyCount);
-
- width = origWidth + increment;
- for (int i=0; i<spy.count(); i++) {
- QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
- width += increment;
- }
-}
-
-void tst_QDeclarativeEngineDebug::watch_expression_data()
-{
- QTest::addColumn<QString>("expr");
- QTest::addColumn<int>("increment");
- QTest::addColumn<int>("incrementCount");
-
- QTest::newRow("width") << "width" << 0 << 0;
- QTest::newRow("width+10") << "width + 10" << 10 << 5;
-}
-
-void tst_QDeclarativeEngineDebug::watch_context()
-{
- QDeclarativeDebugContextReference c;
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(c, QString(), this));
-}
-
-void tst_QDeclarativeEngineDebug::watch_file()
-{
- QDeclarativeDebugFileReference f;
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(f, this));
-}
-
-void tst_QDeclarativeEngineDebug::queryAvailableEngines()
-{
- QDeclarativeDebugEnginesQuery *q_engines;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- q_engines = unconnected->queryAvailableEngines(0);
- QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Error);
- delete q_engines;
- delete unconnected;
-
- q_engines = m_dbg->queryAvailableEngines(this);
- delete q_engines;
-
- q_engines = m_dbg->queryAvailableEngines(this);
- QVERIFY(q_engines->engines().isEmpty());
- waitForQuery(q_engines);
-
- // TODO test multiple engines
- QList<QDeclarativeDebugEngineReference> engines = q_engines->engines();
- QCOMPARE(engines.count(), 1);
-
- foreach(const QDeclarativeDebugEngineReference &e, engines) {
- QCOMPARE(e.debugId(), QDeclarativeDebugService::idForObject(m_engine));
- QCOMPARE(e.name(), m_engine->objectName());
- }
-
- // Make query invalid by deleting client
- q_engines = m_dbg->queryAvailableEngines(this);
- QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Error);
- delete q_engines;
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
-}
-
-void tst_QDeclarativeEngineDebug::queryRootContexts()
-{
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- int engineId = q_engines->engines()[0].debugId();
- delete q_engines;
-
- QDeclarativeDebugRootContextQuery *q_context;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- q_context = unconnected->queryRootContexts(engineId, this);
- QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
- delete q_context;
- delete unconnected;
-
- q_context = m_dbg->queryRootContexts(engineId, this);
- delete q_context;
-
- q_context = m_dbg->queryRootContexts(engineId, this);
- waitForQuery(q_context);
-
- QDeclarativeContext *actualContext = m_engine->rootContext();
- QDeclarativeDebugContextReference context = q_context->rootContext();
- QCOMPARE(context.debugId(), QDeclarativeDebugService::idForObject(actualContext));
- QCOMPARE(context.name(), actualContext->objectName());
-
- QCOMPARE(context.objects().count(), 4); // 4 qml component objects created for context in main()
-
- // root context query sends only root object data - it doesn't fill in
- // the children or property info
- QCOMPARE(context.objects()[0].properties().count(), 0);
- QCOMPARE(context.objects()[0].children().count(), 0);
-
- QCOMPARE(context.contexts().count(), 5);
- QVERIFY(context.contexts()[0].debugId() >= 0);
- QCOMPARE(context.contexts()[0].name(), QString("tst_QDeclarativeDebug_childContext"));
-
- // Make query invalid by deleting client
- q_context = m_dbg->queryRootContexts(engineId, this);
- QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
- delete q_context;
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
-}
-
-void tst_QDeclarativeEngineDebug::queryObject()
-{
- QFETCH(bool, recursive);
-
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[0];
-
- QDeclarativeDebugObjectQuery *q_obj = 0;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
- QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Error);
- delete q_obj;
- delete unconnected;
-
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- delete q_obj;
-
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- waitForQuery(q_obj);
-
- QDeclarativeDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
-
- // Make query invalid by deleting client
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Error);
- delete q_obj;
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
-
- // check source as defined in main()
- QDeclarativeDebugFileReference source = obj.source();
- QCOMPARE(source.url(), QUrl::fromLocalFile(""));
- QCOMPARE(source.lineNumber(), 3);
- QCOMPARE(source.columnNumber(), 1);
-
- // generically test all properties, children and childrens' properties
- recursiveObjectTest(m_rootItem, obj, recursive);
-
- if (recursive) {
- foreach(const QDeclarativeDebugObjectReference &child, obj.children())
- QVERIFY(child.properties().count() > 0);
-
- QDeclarativeDebugObjectReference rect;
- QDeclarativeDebugObjectReference text;
- foreach (const QDeclarativeDebugObjectReference &child, obj.children()) {
- if (child.className() == "Rectangle")
- rect = child;
- else if (child.className() == "Text")
- text = child;
- }
-
- // test specific property values
- QCOMPARE(findProperty(rect.properties(), "width").value(), qVariantFromValue(500));
- QCOMPARE(findProperty(rect.properties(), "height").value(), qVariantFromValue(600));
- QCOMPARE(findProperty(rect.properties(), "color").value(), qVariantFromValue(QColor("blue")));
-
- QCOMPARE(findProperty(text.properties(), "color").value(), qVariantFromValue(QColor("blue")));
- } else {
- foreach(const QDeclarativeDebugObjectReference &child, obj.children())
- QCOMPARE(child.properties().count(), 0);
- }
-}
-
-void tst_QDeclarativeEngineDebug::queryObject_data()
-{
- QTest::addColumn<bool>("recursive");
-
- QTest::newRow("non-recursive") << false;
- QTest::newRow("recursive") << true;
-}
-
-void tst_QDeclarativeEngineDebug::queryExpressionResult()
-{
- QFETCH(QString, expr);
- QFETCH(QVariant, result);
-
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines); // check immediate deletion is ok
-
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- int objectId = q_context->rootContext().objects()[0].debugId();
-
- QDeclarativeDebugExpressionQuery *q_expr;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- q_expr = unconnected->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
- delete q_expr;
- delete unconnected;
-
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- delete q_expr;
-
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->expression().toString(), expr);
- waitForQuery(q_expr);
-
- QCOMPARE(q_expr->result(), result);
-
- delete q_engines;
- delete q_context;
-
- // Make query invalid by deleting client
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
- delete q_expr;
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
-}
-
-void tst_QDeclarativeEngineDebug::queryExpressionResult_data()
-{
- QTest::addColumn<QString>("expr");
- QTest::addColumn<QVariant>("result");
-
- QTest::newRow("width + 50") << "width + 50" << qVariantFromValue(60);
- QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500);
- QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("<undefined>"));
- QTest::newRow("QObject*") << "varObj" << qVariantFromValue(QString("<unnamed object>"));
- QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QString("<unknown value>"));
- QVariantMap map;
- map.insert(QLatin1String("rect"), QVariant(QLatin1String("<unnamed object>")));
- QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map);
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugFileReference()
-{
- QDeclarativeDebugFileReference ref;
- QVERIFY(ref.url().isEmpty());
- QCOMPARE(ref.lineNumber(), -1);
- QCOMPARE(ref.columnNumber(), -1);
-
- ref.setUrl(QUrl("http://test"));
- QCOMPARE(ref.url(), QUrl("http://test"));
- ref.setLineNumber(1);
- QCOMPARE(ref.lineNumber(), 1);
- ref.setColumnNumber(1);
- QCOMPARE(ref.columnNumber(), 1);
-
- QDeclarativeDebugFileReference copy(ref);
- QDeclarativeDebugFileReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugFileReference &r, (QList<QDeclarativeDebugFileReference>() << copy << copyAssign)) {
- QCOMPARE(r.url(), ref.url());
- QCOMPARE(r.lineNumber(), ref.lineNumber());
- QCOMPARE(r.columnNumber(), ref.columnNumber());
- }
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugEngineReference()
-{
- QDeclarativeDebugEngineReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
-
- ref = QDeclarativeDebugEngineReference(1);
- QCOMPARE(ref.debugId(), 1);
- QVERIFY(ref.name().isEmpty());
-
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- ref = q_engines->engines()[0];
- delete q_engines;
-
- QDeclarativeDebugEngineReference copy(ref);
- QDeclarativeDebugEngineReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugEngineReference &r, (QList<QDeclarativeDebugEngineReference>() << copy << copyAssign)) {
- QCOMPARE(r.debugId(), ref.debugId());
- QCOMPARE(r.name(), ref.name());
- }
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugObjectReference()
-{
- QDeclarativeDebugObjectReference ref;
- QCOMPARE(ref.debugId(), -1);
- QCOMPARE(ref.className(), QString());
- QCOMPARE(ref.name(), QString());
- QCOMPARE(ref.contextDebugId(), -1);
- QVERIFY(ref.properties().isEmpty());
- QVERIFY(ref.children().isEmpty());
-
- QDeclarativeDebugFileReference source = ref.source();
- QVERIFY(source.url().isEmpty());
- QVERIFY(source.lineNumber() < 0);
- QVERIFY(source.columnNumber() < 0);
-
- ref = QDeclarativeDebugObjectReference(1);
- QCOMPARE(ref.debugId(), 1);
-
- QDeclarativeDebugObjectReference rootObject = findRootObject();
- QDeclarativeDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this);
- waitForQuery(query);
- ref = query->object();
- delete query;
-
- QVERIFY(ref.debugId() >= 0);
-
- QDeclarativeDebugObjectReference copy(ref);
- QDeclarativeDebugObjectReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugObjectReference &r, (QList<QDeclarativeDebugObjectReference>() << copy << copyAssign))
- recursiveCompareObjects(r, ref);
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugContextReference()
-{
- QDeclarativeDebugContextReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
- QVERIFY(ref.objects().isEmpty());
- QVERIFY(ref.contexts().isEmpty());
-
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- ref = q_context->rootContext();
- delete q_engines;
- delete q_context;
- QVERIFY(ref.debugId() >= 0);
-
- QDeclarativeDebugContextReference copy(ref);
- QDeclarativeDebugContextReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugContextReference &r, (QList<QDeclarativeDebugContextReference>() << copy << copyAssign))
- recursiveCompareContexts(r, ref);
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugPropertyReference()
-{
- QDeclarativeDebugObjectReference rootObject = findRootObject();
- QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
- waitForQuery(query);
- QDeclarativeDebugObjectReference obj = query->object();
- delete query;
-
- QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale");
- QVERIFY(ref.objectDebugId() > 0);
- QVERIFY(!ref.name().isEmpty());
- QVERIFY(!ref.value().isNull());
- QVERIFY(!ref.valueTypeName().isEmpty());
- QVERIFY(!ref.binding().isEmpty());
- QVERIFY(ref.hasNotifySignal());
-
- QDeclarativeDebugPropertyReference copy(ref);
- QDeclarativeDebugPropertyReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugPropertyReference &r, (QList<QDeclarativeDebugPropertyReference>() << copy << copyAssign))
- compareProperties(r, ref);
-}
-
-void tst_QDeclarativeEngineDebug::setBindingForObject()
-{
- QDeclarativeDebugObjectReference rootObject = findRootObject();
- QVERIFY(rootObject.debugId() != -1);
- QDeclarativeDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties(), "width");
-
- QCOMPARE(widthPropertyRef.value(), QVariant(10));
- QCOMPARE(widthPropertyRef.binding(), QString());
-
- //
- // set literal
- //
- m_dbg->setBindingForObject(rootObject.debugId(), "width", "15", true);
-
- rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
-
- QCOMPARE(widthPropertyRef.value(), QVariant(15));
- QCOMPARE(widthPropertyRef.binding(), QString());
-
- //
- // set expression
- //
- m_dbg->setBindingForObject(rootObject.debugId(), "width", "height", false);
-
- rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
-
- QCOMPARE(widthPropertyRef.value(), QVariant(20));
- QCOMPARE(widthPropertyRef.binding(), QString("height"));
-
- //
- // reset
- //
- m_dbg->resetBindingForObject(rootObject.debugId(), "width");
-
- rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
-
- // QCOMPARE(widthPropertyRef.value(), QVariant(0)); // TODO: Shouldn't this work?
- QCOMPARE(widthPropertyRef.binding(), QString());
-
- //
- // set handler
- //
- rootObject = findRootObject();
- QCOMPARE(rootObject.children().size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement
- QDeclarativeDebugObjectReference mouseAreaObject = rootObject.children().at(2);
- QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
- waitForQuery(q_obj);
- mouseAreaObject = q_obj->object();
-
- QCOMPARE(mouseAreaObject.className(), QString("MouseArea"));
-
- QDeclarativeDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
-
- QCOMPARE(onEnteredRef.name(), QString("onEntered"));
- QCOMPARE(onEnteredRef.value(), QVariant("(function onEntered() { { console.log('hello') } })"));
-
- m_dbg->setBindingForObject(mouseAreaObject.debugId(), "onEntered", "{console.log('hello, world') }", false) ;
-
- rootObject = findRootObject();
- mouseAreaObject = rootObject.children().at(2);
- q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
- waitForQuery(q_obj);
- mouseAreaObject = q_obj->object();
- onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
- QCOMPARE(onEnteredRef.name(), QString("onEntered"));
- QCOMPARE(onEnteredRef.value(), QVariant("{console.log('hello, world') }"));
-}
-
-void tst_QDeclarativeEngineDebug::setBindingInStates()
-{
- // Check if changing bindings of propertychanges works
-
- const int sourceIndex = 3;
-
- QDeclarativeDebugObjectReference obj = findRootObject(sourceIndex);
-
- QVERIFY(obj.debugId() != -1);
- QVERIFY(obj.children().count() >= 2);
-
- // We are going to switch state a couple of times, we need to get rid of the transition before
- QDeclarativeDebugExpressionQuery *q_deleteTransition = m_dbg->queryExpressionResult(obj.debugId(),QString("transitions = []"),this);
- waitForQuery(q_deleteTransition);
- delete q_deleteTransition;
-
-
- // check initial value of the property that is changing
- QDeclarativeDebugExpressionQuery *q_setState;
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),200);
-
-
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
-
- obj = findRootObject(sourceIndex, true);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
-
-
- // change the binding
- QDeclarativeDebugObjectReference state = obj.children()[1];
- QCOMPARE(state.className(), QString("State"));
- QVERIFY(state.children().count() > 0);
-
- QDeclarativeDebugObjectReference propertyChange = state.children()[0];
- QVERIFY(propertyChange.debugId() != -1);
-
- QVERIFY( m_dbg->setBindingForObject(propertyChange.debugId(), "width",QVariant(300),true) );
-
- // check properties changed in state
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
-
-
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
-
- // check changing properties of base state from within a state
- QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"width","height*2",false));
- QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"height","200",true));
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
-
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
-
- // reset binding while in a state
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
-
- m_dbg->resetBindingForObject(propertyChange.debugId(), "width");
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
-
- // re-add binding
- m_dbg->setBindingForObject(propertyChange.debugId(), "width", "300", true);
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
-}
-
-void tst_QDeclarativeEngineDebug::queryObjectTree()
-{
- const int sourceIndex = 3;
-
- // Check if states/transitions are initialized when fetching root item
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- QVERIFY(q_context->rootContext().objects().count() > sourceIndex);
- QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[sourceIndex];
-
- QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(rootObject, this);
- waitForQuery(q_obj);
-
- QDeclarativeDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- QVERIFY(obj.debugId() != -1);
- QVERIFY(obj.children().count() >= 2);
-
-
-
- // check state
- QDeclarativeDebugObjectReference state = obj.children()[1];
- QCOMPARE(state.className(), QString("State"));
- QVERIFY(state.children().count() > 0);
-
- QDeclarativeDebugObjectReference propertyChange = state.children()[0];
- QVERIFY(propertyChange.debugId() != -1);
-
- QDeclarativeDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties(),"target");
- QCOMPARE(propertyChangeTarget.objectDebugId(), propertyChange.debugId());
-
- QDeclarativeDebugObjectReference targetReference = qvariant_cast<QDeclarativeDebugObjectReference>(propertyChangeTarget.value());
- QVERIFY(targetReference.debugId() != -1);
-
-
-
- // check transition
- QDeclarativeDebugObjectReference transition = obj.children()[0];
- QCOMPARE(transition.className(), QString("Transition"));
- QCOMPARE(findProperty(transition.properties(),"from").value().toString(), QString("*"));
- QCOMPARE(findProperty(transition.properties(),"to").value(), findProperty(state.properties(),"name").value());
- QVERIFY(transition.children().count() > 0);
-
- QDeclarativeDebugObjectReference animation = transition.children()[0];
- QVERIFY(animation.debugId() != -1);
-
- QDeclarativeDebugPropertyReference animationTarget = findProperty(animation.properties(),"target");
- QCOMPARE(animationTarget.objectDebugId(), animation.debugId());
-
- targetReference = qvariant_cast<QDeclarativeDebugObjectReference>(animationTarget.value());
- QVERIFY(targetReference.debugId() != -1);
-
- QCOMPARE(findProperty(animation.properties(),"property").value().toString(), QString("width"));
- QCOMPARE(findProperty(animation.properties(),"duration").value().toInt(), 100);
-}
-
-int main(int argc, char *argv[])
-{
- int _argc = argc + 1;
- char **_argv = new char*[_argc];
- for (int i = 0; i < argc; ++i)
- _argv[i] = argv[i];
- char arg[] = "-qmljsdebugger=port:3768";
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QDeclarativeEngineDebug tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
-
-#include "tst_qdeclarativeenginedebug.moc"
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro b/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro
deleted file mode 100644
index 6433631c4b..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = app
-QT += declarative quick widgets
-
-CONFIG += declarative_debug
-macx:CONFIG -= app_bundle
-
-SOURCES += main.cpp
-
-OTHER_FILES += qtquick1.qml qtquick2.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro b/tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro
deleted file mode 100644
index 28d16a5029..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += tst_qdeclarativeinspector.pro app
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp b/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp
deleted file mode 100644
index 4d7e57f4d4..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include "../../../../../src/plugins/qmltooling/shared/qdeclarativeinspectorprotocol.h"
-#include "../shared/debugutil_p.h"
-
-using namespace QmlJSDebugger;
-
-#define PORT 13772
-#define STR_PORT "13772"
-
-class QDeclarativeInspectorClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-
-public:
- QDeclarativeInspectorClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("QDeclarativeObserverMode"), connection)
- , m_showAppOnTop(false)
- {
- }
-
- bool showAppOnTop() const { return m_showAppOnTop; }
- void setShowAppOnTop(bool showOnTop);
-
-signals:
- void showAppOnTopChanged();
-
-protected:
- void messageReceived(const QByteArray &message);
-
-private:
- bool m_showAppOnTop;
-};
-
-class tst_QDeclarativeInspector : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QDeclarativeInspector()
- : m_process(0)
- , m_connection(0)
- , m_client(0)
- {
- }
-
-
-private:
- QDeclarativeDebugProcess *m_process;
- QDeclarativeDebugConnection *m_connection;
- QDeclarativeInspectorClient *m_client;
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
- void connect();
- void showAppOnTop();
-};
-
-
-void QDeclarativeInspectorClient::setShowAppOnTop(bool showOnTop)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << InspectorProtocol::ShowAppOnTop << showOnTop;
-
- sendMessage(message);
-}
-
-void QDeclarativeInspectorClient::messageReceived(const QByteArray &message)
-{
- QDataStream ds(message);
- InspectorProtocol::Message type;
- ds >> type;
-
- switch (type) {
- case InspectorProtocol::ShowAppOnTop:
- ds >> m_showAppOnTop;
- emit showAppOnTopChanged();
- break;
- default:
- qDebug() << "Unhandled message " << (int)type;
- }
-}
-
-void tst_QDeclarativeInspector::initTestCase()
-{
-}
-
-void tst_QDeclarativeInspector::cleanupTestCase()
-{
-}
-
-void tst_QDeclarativeInspector::init()
-{
- const QString executable = SRCDIR"/app/app";
- const QString argument = "-qmljsdebugger=port:"STR_PORT",block";
-
- m_process = new QDeclarativeDebugProcess(executable);
- m_process->start(QStringList() << argument);
- if (!m_process->waitForSessionStart()) {
- QFAIL(QString("Could not launch app '%1'.\nApplication output:\n%2").arg(executable, m_process->output()).toAscii());
- }
-
- QDeclarativeDebugConnection *m_connection = new QDeclarativeDebugConnection();
- m_client = new QDeclarativeInspectorClient(m_connection);
-
- m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
-}
-
-void tst_QDeclarativeInspector::cleanup()
-{
- delete m_process;
- delete m_connection;
- delete m_client;
-}
-
-void tst_QDeclarativeInspector::connect()
-{
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-}
-
-void tst_QDeclarativeInspector::showAppOnTop()
-{
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setShowAppOnTop(true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged())));
- QCOMPARE(m_client->showAppOnTop(), true);
-
- m_client->setShowAppOnTop(false);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged())));
- QCOMPARE(m_client->showAppOnTop(), false);
-}
-
-QTEST_MAIN(tst_QDeclarativeInspector)
-
-#include "tst_qdeclarativeinspector.moc"
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro b/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro
deleted file mode 100644
index 6ea6010a32..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeinspector
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativeinspector.cpp \
- ../shared/debugutil.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-CONFIG += parallel_test declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro
deleted file mode 100644
index 52139bf569..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeprofilerservice
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-
-SOURCES += tst_qdeclarativeprofilerservice.cpp \
- ../shared/debugutil.cpp
-OTHER_FILES += data/test.qml
-
-include (../../../shared/util.pri)
-
-CONFIG += parallel_test declarative_debug
-
-QT += core-private v8-private declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp
deleted file mode 100644
index 5de7b8621d..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-
-#include "QtDeclarative/private/qdeclarativeprofilerservice_p.h"
-#include "../shared/debugutil_p.h"
-#include "../../../shared/util.h"
-
-#define PORT 13773
-#define STR_PORT "13773"
-
-class QDeclarativeProfilerClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-
-public:
- QDeclarativeProfilerClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), connection)
- {
- }
-
- QList<QDeclarativeProfilerData> traceMessages;
-
- void setTraceState(bool enabled) {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << enabled;
- sendMessage(message);
- }
-
-signals:
- void complete();
-
-protected:
- void messageReceived(const QByteArray &message);
-};
-
-class tst_QDeclarativeProfilerService : public QDeclarativeDataTest
-{
- Q_OBJECT
-
-public:
- tst_QDeclarativeProfilerService()
- : m_process(0)
- , m_connection(0)
- , m_client(0)
- {
- }
-
-private:
- QDeclarativeDebugProcess *m_process;
- QDeclarativeDebugConnection *m_connection;
- QDeclarativeProfilerClient *m_client;
-
- void connect(bool block, const QString &testFile);
-
-private slots:
- void cleanup();
-
- void blockingConnectWithTraceEnabled();
- void blockingConnectWithTraceDisabled();
- void nonBlockingConnect();
- void profileOnExit();
-};
-
-void QDeclarativeProfilerClient::messageReceived(const QByteArray &message)
-{
- QByteArray msg = message;
- QDataStream stream(&msg, QIODevice::ReadOnly);
-
-
- QDeclarativeProfilerData data;
- data.time = -2;
- data.messageType = -1;
- data.detailType = -1;
- data.line = -1;
- data.framerate = -1;
- data.animationcount = -1;
-
- stream >> data.time >> data.messageType;
-
- QVERIFY(data.time >= -1);
-
- switch (data.messageType) {
- case (QDeclarativeProfilerService::Event): {
- stream >> data.detailType;
-
- switch (data.detailType) {
- case QDeclarativeProfilerService::AnimationFrame: {
- stream >> data.framerate >> data.animationcount;
- QVERIFY(data.framerate != -1);
- QVERIFY(data.animationcount != -1);
- break;
- }
- case QDeclarativeProfilerService::FramePaint:
- case QDeclarativeProfilerService::Mouse:
- case QDeclarativeProfilerService::Key:
- case QDeclarativeProfilerService::StartTrace:
- case QDeclarativeProfilerService::EndTrace:
- break;
- default: {
- QString failMsg = QString("Unknown event type:") + data.detailType;
- QFAIL(qPrintable(failMsg));
- break;
- }
- }
- break;
- }
- case QDeclarativeProfilerService::Complete: {
- emit complete();
- return;
- }
- case QDeclarativeProfilerService::RangeStart: {
- stream >> data.detailType;
- QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType);
- break;
- }
- case QDeclarativeProfilerService::RangeEnd: {
- stream >> data.detailType;
- QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType);
- break;
- }
- case QDeclarativeProfilerService::RangeData: {
- stream >> data.detailType >> data.detailData;
- QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType);
- break;
- }
- case QDeclarativeProfilerService::RangeLocation: {
- stream >> data.detailType >> data.detailData >> data.line >> data.column;
- QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType);
- QVERIFY(data.line >= -2);
- break;
- }
- default:
- QString failMsg = QString("Unknown message type:") + data.messageType;
- QFAIL(qPrintable(failMsg));
- break;
- }
- QVERIFY(stream.atEnd());
- traceMessages.append(data);
-}
-
-void tst_QDeclarativeProfilerService::connect(bool block, const QString &testFile)
-{
- const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
- QStringList arguments;
-
- if (block)
- arguments << QString("-qmljsdebugger=port:"STR_PORT",block");
- else
- arguments << QString("-qmljsdebugger=port:"STR_PORT);
-
- arguments << QDeclarativeDataTest::instance()->testFile(testFile);
-
- m_process = new QDeclarativeDebugProcess(executable);
- m_process->start(QStringList() << arguments);
- if (!m_process->waitForSessionStart()) {
- QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg(
- executable, m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- QDeclarativeDebugConnection *m_connection = new QDeclarativeDebugConnection();
- m_client = new QDeclarativeProfilerClient(m_connection);
-
- m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
-}
-
-void tst_QDeclarativeProfilerService::cleanup()
-{
- delete m_process;
- delete m_connection;
- delete m_client;
-}
-
-void tst_QDeclarativeProfilerService::blockingConnectWithTraceEnabled()
-{
- connect(true, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setTraceState(true);
- m_client->setTraceState(false);
- if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
- QString failMsg
- = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- QVERIFY(m_client->traceMessages.count());
- // must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace);
-
- // must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace);
-}
-
-void tst_QDeclarativeProfilerService::blockingConnectWithTraceDisabled()
-{
- connect(true, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setTraceState(false);
- m_client->setTraceState(true);
- m_client->setTraceState(false);
- if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
- QString failMsg
- = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- QVERIFY(m_client->traceMessages.count());
-
- // must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace);
-
- // must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace);
-}
-
-void tst_QDeclarativeProfilerService::nonBlockingConnect()
-{
- connect(false, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setTraceState(true);
- m_client->setTraceState(false);
- if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
- QString failMsg
- = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- // must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace);
-
- // must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace);
-}
-
-void tst_QDeclarativeProfilerService::profileOnExit()
-{
- connect(true, "exit.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setTraceState(true);
-
- if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
- QString failMsg
- = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- // must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace);
-
- // must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace);
-}
-
-QTEST_MAIN(tst_QDeclarativeProfilerService)
-
-#include "tst_qdeclarativeprofilerservice.moc"
diff --git a/tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro
deleted file mode 100644
index 949132feff..0000000000
--- a/tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qpacketprotocol
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qpacketprotocol.cpp \
- ../shared/debugutil.cpp
-
-CONFIG += parallel_test
-QT += declarative-private network testlib
diff --git a/tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
deleted file mode 100644
index ac664730cb..0000000000
--- a/tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QTcpSocket>
-#include <QTcpServer>
-#include <QDebug>
-#include <QBuffer>
-
-#include <private/qpacketprotocol_p.h>
-
-#include "../shared/debugutil_p.h"
-
-class tst_QPacketProtocol : public QObject
-{
- Q_OBJECT
-
-private:
- QTcpServer *m_server;
- QTcpSocket *m_client;
- QTcpSocket *m_serverConn;
-
-private slots:
- void init();
- void cleanup();
-
- void maximumPacketSize();
- void setMaximumPacketSize();
- void setMaximumPacketSize_data();
- void send();
- void send_data();
- void packetsAvailable();
- void packetsAvailable_data();
- void clear();
- void read();
- void device();
-
- void tst_QPacket_clear();
-};
-
-void tst_QPacketProtocol::init()
-{
- m_server = new QTcpServer(this);
- m_serverConn = 0;
- QVERIFY(m_server->listen(QHostAddress("127.0.0.1")));
-
- m_client = new QTcpSocket(this);
- m_client->connectToHost(m_server->serverAddress(), m_server->serverPort());
-
- QVERIFY(m_client->waitForConnected());
- QVERIFY(m_server->waitForNewConnection(5000));
- m_serverConn = m_server->nextPendingConnection();
-}
-
-void tst_QPacketProtocol::cleanup()
-{
- delete m_client;
- delete m_serverConn;
- delete m_server;
-}
-
-void tst_QPacketProtocol::maximumPacketSize()
-{
- QPacketProtocol p(m_client);
- QCOMPARE(p.maximumPacketSize(), 0x7FFFFFFF);
-}
-
-void tst_QPacketProtocol::setMaximumPacketSize()
-{
- QFETCH(qint32, size);
- QFETCH(qint32, expected);
-
- QPacketProtocol out(m_serverConn);
- QCOMPARE(out.setMaximumPacketSize(size), expected);
-}
-
-void tst_QPacketProtocol::setMaximumPacketSize_data()
-{
- QTest::addColumn<int>("size");
- QTest::addColumn<int>("expected");
-
- QTest::newRow("invalid") << qint32(sizeof(qint32) - 1) << qint32(0x7FFFFFFF);
- QTest::newRow("still invalid") << qint32(sizeof(qint32)) << qint32(0x7FFFFFFF);
- QTest::newRow("valid") << qint32(sizeof(qint32) + 1) << qint32(sizeof(qint32) + 1);
-}
-
-void tst_QPacketProtocol::send()
-{
- QFETCH(bool, useAutoSend);
-
- QPacketProtocol in(m_client);
- QPacketProtocol out(m_serverConn);
-
- QByteArray ba;
- int num;
-
- if (useAutoSend) {
- out.send() << "Hello world" << 123;
- } else {
- QPacket packet;
- packet << "Hello world" << 123;
- out.send(packet);
- }
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
-
- QPacket p = in.read();
- p >> ba >> num;
- QCOMPARE(ba, QByteArray("Hello world") + '\0');
- QCOMPARE(num, 123);
-}
-
-void tst_QPacketProtocol::send_data()
-{
- QTest::addColumn<bool>("useAutoSend");
-
- QTest::newRow("auto send") << true;
- QTest::newRow("no auto send") << false;
-}
-
-void tst_QPacketProtocol::packetsAvailable()
-{
- QFETCH(int, packetCount);
-
- QPacketProtocol out(m_client);
- QPacketProtocol in(m_serverConn);
-
- QCOMPARE(out.packetsAvailable(), qint64(0));
- QCOMPARE(in.packetsAvailable(), qint64(0));
-
- for (int i=0; i<packetCount; i++)
- out.send() << "Hello";
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
- QCOMPARE(in.packetsAvailable(), qint64(packetCount));
-}
-
-void tst_QPacketProtocol::packetsAvailable_data()
-{
- QTest::addColumn<int>("packetCount");
-
- QTest::newRow("1") << 1;
- QTest::newRow("2") << 2;
- QTest::newRow("10") << 10;
-}
-
-void tst_QPacketProtocol::clear()
-{
- QPacketProtocol in(m_client);
- QPacketProtocol out(m_serverConn);
-
- out.send() << 123;
- out.send() << 456;
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
-
- in.clear();
- QVERIFY(in.read().isEmpty());
-}
-
-void tst_QPacketProtocol::read()
-{
- QPacketProtocol in(m_client);
- QPacketProtocol out(m_serverConn);
-
- QVERIFY(in.read().isEmpty());
-
- out.send() << 123;
- out.send() << 456;
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
-
- int num;
-
- QPacket p1 = in.read();
- QVERIFY(!p1.isEmpty());
- p1 >> num;
- QCOMPARE(num, 123);
-
- QPacket p2 = in.read();
- QVERIFY(!p2.isEmpty());
- p2 >> num;
- QCOMPARE(num, 456);
-
- QVERIFY(in.read().isEmpty());
-}
-
-void tst_QPacketProtocol::device()
-{
- QPacketProtocol p(m_client);
- QVERIFY(p.device() == m_client);
-}
-
-void tst_QPacketProtocol::tst_QPacket_clear()
-{
- QPacketProtocol protocol(m_client);
-
- QPacket packet;
-
- packet << "Hello world!" << 123;
- protocol.send(packet);
-
- packet.clear();
- QVERIFY(packet.isEmpty());
- packet << "Goodbyte world!" << 789;
- protocol.send(packet);
-
- QByteArray ba;
- int num;
- QPacketProtocol in(m_serverConn);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
-
- QPacket p1 = in.read();
- p1 >> ba >> num;
- QCOMPARE(ba, QByteArray("Hello world!") + '\0');
- QCOMPARE(num, 123);
-
- QPacket p2 = in.read();
- p2 >> ba >> num;
- QCOMPARE(ba, QByteArray("Goodbyte world!") + '\0');
- QCOMPARE(num, 789);
-}
-
-QTEST_MAIN(tst_QPacketProtocol)
-
-#include "tst_qpacketprotocol.moc"
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro b/tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro
deleted file mode 100644
index eb57dff2fe..0000000000
--- a/tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qv8profilerservice
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-
-SOURCES += tst_qv8profilerservice.cpp \
- ../shared/debugutil.cpp
-
-include (../../../shared/util.pri)
-
-OTHER_FILES += data/test.qml
-
-CONFIG += parallel_test declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
deleted file mode 100644
index 165783fed5..0000000000
--- a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-
-#include "QtDeclarative/private/qv8profilerservice_p.h"
-#include "../shared/debugutil_p.h"
-#include "../../../shared/util.h"
-
-#define PORT 13774
-#define STR_PORT "13774"
-
-class QV8ProfilerClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-
-public:
- QV8ProfilerClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("V8Profiler"), connection)
- {
- }
-
- void startProfiling(const QString &name) {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << QByteArray("V8PROFILER") << QByteArray("start") << name;
- sendMessage(message);
- }
-
- void stopProfiling(const QString &name) {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << QByteArray("V8PROFILER") << QByteArray("stop") << name;
- sendMessage(message);
- }
-
- void takeSnapshot() {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << QByteArray("V8SNAPSHOT") << QByteArray("full");
- sendMessage(message);
- }
-
- void deleteSnapshots() {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << QByteArray("V8SNAPSHOT") << QByteArray("delete");
- sendMessage(message);
- }
-
- QList<QV8ProfilerData> traceMessages;
- QList<QByteArray> snapshotMessages;
-
-signals:
- void started();
- void complete();
- void snapshot();
-
-protected:
- void messageReceived(const QByteArray &message);
-};
-
-class tst_QV8ProfilerService : public QDeclarativeDataTest
-{
- Q_OBJECT
-
-public:
- tst_QV8ProfilerService()
- : m_process(0)
- , m_connection(0)
- , m_client(0)
- {
- }
-
-private:
- QDeclarativeDebugProcess *m_process;
- QDeclarativeDebugConnection *m_connection;
- QV8ProfilerClient *m_client;
-
- void connect(bool block, const QString &testFile);
-
-private slots:
- void cleanup();
-
- void blockingConnectWithTraceEnabled();
- void blockingConnectWithTraceDisabled();
- void nonBlockingConnect();
- void snapshot();
- void profileOnExit();
- void console();
-};
-
-void QV8ProfilerClient::messageReceived(const QByteArray &message)
-{
- QByteArray msg = message;
- QDataStream stream(&msg, QIODevice::ReadOnly);
-
- int messageType;
- stream >> messageType;
-
- QVERIFY(messageType >= 0);
- QVERIFY(messageType < QV8ProfilerService::V8MaximumMessage);
-
- switch (messageType) {
- case QV8ProfilerService::V8Entry: {
- QV8ProfilerData entry;
- stream >> entry.filename >> entry.functionname >> entry.lineNumber >> entry.totalTime >> entry.selfTime >> entry.treeLevel;
- traceMessages.append(entry);
- break;
- }
- case QV8ProfilerService::V8Complete:
- emit complete();
- break;
- case QV8ProfilerService::V8SnapshotChunk: {
- QByteArray json;
- stream >> json;
- snapshotMessages.append(json);
- break;
- }
- case QV8ProfilerService::V8SnapshotComplete:
- emit snapshot();
- break;
- case QV8ProfilerService::V8Started:
- emit started();
- break;
- default:
- QString failMessage = QString("Unknown message type: %1").arg(messageType);
- QFAIL(qPrintable(failMessage));
- }
-
- QVERIFY(stream.atEnd());
-}
-
-void tst_QV8ProfilerService::connect(bool block, const QString &testFile)
-{
- const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
- QStringList arguments;
-
- if (block)
- arguments << QString("-qmljsdebugger=port:"STR_PORT",block");
- else
- arguments << QString("-qmljsdebugger=port:"STR_PORT);
-
- arguments << QDeclarativeDataTest::instance()->testFile(testFile);
-
- m_process = new QDeclarativeDebugProcess(executable);
- m_process->start(QStringList() << arguments);
- if (!m_process->waitForSessionStart()) {
- QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg(
- executable, m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- QDeclarativeDebugConnection *m_connection = new QDeclarativeDebugConnection();
- m_client = new QV8ProfilerClient(m_connection);
-
- m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
-}
-
-void tst_QV8ProfilerService::cleanup()
-{
- if (QTest::currentTestFailed())
- qDebug() << "Application Output:" << m_process->output();
-
- delete m_process;
- delete m_connection;
- delete m_client;
-}
-
-void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
-{
- connect(true, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->startProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
- "No start signal received in time.");
- m_client->stopProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
-}
-
-void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
-{
- connect(true, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->stopProfiling("");
- if (QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()), 1000)) {
- QString failMsg
- = QString("Unexpected trace received! App output: %1\n\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
- m_client->startProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
- "No start signal received in time.");
- m_client->stopProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
-}
-
-void tst_QV8ProfilerService::nonBlockingConnect()
-{
- connect(false, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->startProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
- "No start signal received in time.");
- m_client->stopProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
-}
-
-void tst_QV8ProfilerService::snapshot()
-{
- connect(false, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->takeSnapshot();
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(snapshot())),
- "No trace received in time.");
-}
-
-void tst_QV8ProfilerService::profileOnExit()
-{
- connect(true, "exit.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->startProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
- "No start signal received in time.");
-
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
- //QVERIFY(!m_client->traceMessages.isEmpty());
-}
-
-void tst_QV8ProfilerService::console()
-{
- connect(true, "console.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->stopProfiling("");
-
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())),
- "No start signal received in time.");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
- QVERIFY(!m_client->traceMessages.isEmpty());
-}
-
-QTEST_MAIN(tst_QV8ProfilerService)
-
-#include "tst_qv8profilerservice.moc"
diff --git a/tests/auto/declarative/debugger/shared/debugutil.cpp b/tests/auto/declarative/debugger/shared/debugutil.cpp
deleted file mode 100644
index fcac1bc61d..0000000000
--- a/tests/auto/declarative/debugger/shared/debugutil.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "debugutil_p.h"
-
-#include <QEventLoop>
-#include <QTimer>
-
-#include <private/qdeclarativedebugclient_p.h>
-#include <private/qdeclarativedebugservice_p.h>
-
-bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
- QEventLoop loop;
- QTimer timer;
- timer.setSingleShot(true);
- QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- QObject::connect(receiver, member, &loop, SLOT(quit()));
- timer.start(timeout);
- loop.exec();
- return timer.isActive();
-}
-
-QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, float version, QObject *parent)
- : QDeclarativeDebugService(s, version, parent)
-{
- registerService();
-}
-
-void QDeclarativeDebugTestService::messageReceived(const QByteArray &ba)
-{
- sendMessage(ba);
-}
-
-void QDeclarativeDebugTestService::stateChanged(State)
-{
- emit stateHasChanged();
-}
-
-
-QDeclarativeDebugTestClient::QDeclarativeDebugTestClient(const QString &s, QDeclarativeDebugConnection *c)
- : QDeclarativeDebugClient(s, c)
-{
-}
-
-QByteArray QDeclarativeDebugTestClient::waitForResponse()
-{
- lastMsg.clear();
- QDeclarativeDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
- if (lastMsg.isEmpty()) {
- qWarning() << "tst_QDeclarativeDebugClient: no response from server!";
- return QByteArray();
- }
- return lastMsg;
-}
-
-void QDeclarativeDebugTestClient::stateChanged(State stat)
-{
- QCOMPARE(stat, state());
- emit stateHasChanged();
-}
-
-void QDeclarativeDebugTestClient::messageReceived(const QByteArray &ba)
-{
- lastMsg = ba;
- emit serverMessage(ba);
-}
-
-QDeclarativeDebugProcess::QDeclarativeDebugProcess(const QString &executable)
- : m_executable(executable)
- , m_started(false)
-{
- m_process.setProcessChannelMode(QProcess::MergedChannels);
- m_timer.setSingleShot(true);
- m_timer.setInterval(5000);
- connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput()));
- connect(&m_timer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
-}
-
-QDeclarativeDebugProcess::~QDeclarativeDebugProcess()
-{
- stop();
-}
-
-void QDeclarativeDebugProcess::start(const QStringList &arguments)
-{
- m_mutex.lock();
- m_process.setEnvironment(m_environment);
- m_process.start(m_executable, arguments);
- m_process.waitForStarted();
- m_timer.start();
- m_mutex.unlock();
-}
-
-void QDeclarativeDebugProcess::stop()
-{
- if (m_process.state() != QProcess::NotRunning) {
- m_process.kill();
- m_process.waitForFinished(5000);
- }
-}
-
-bool QDeclarativeDebugProcess::waitForSessionStart()
-{
- if (m_process.state() != QProcess::Running) {
- qWarning() << "Could not start up " << m_executable;
- return false;
- }
- m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
-
- return m_started;
-}
-
-void QDeclarativeDebugProcess::setEnvironment(const QStringList &environment)
-{
- m_environment = environment;
-}
-
-QString QDeclarativeDebugProcess::output() const
-{
- return m_output;
-}
-
-void QDeclarativeDebugProcess::processAppOutput()
-{
- m_mutex.lock();
-
- QString newOutput = m_process.readAll();
- m_output.append(newOutput);
- m_outputBuffer.append(newOutput);
-
- while (true) {
- const int nlIndex = m_outputBuffer.indexOf(QLatin1Char('\n'));
- if (nlIndex < 0) // no further complete lines
- break;
- const QString line = m_outputBuffer.left(nlIndex);
- m_outputBuffer = m_outputBuffer.right(m_outputBuffer.size() - nlIndex - 1);
-
- if (line.startsWith("Qml debugging is enabled")) // ignore
- continue;
- if (line.startsWith("QDeclarativeDebugServer:")) {
- if (line.contains("Waiting for connection ")) {
- m_started = true;
- m_eventLoop.quit();
- continue;
- }
- if (line.contains("Connection established")) {
- continue;
- }
- }
- }
- m_mutex.unlock();
-}
diff --git a/tests/auto/declarative/debugger/shared/debugutil_p.h b/tests/auto/declarative/debugger/shared/debugutil_p.h
deleted file mode 100644
index 520cb11a5a..0000000000
--- a/tests/auto/declarative/debugger/shared/debugutil_p.h
+++ /dev/null
@@ -1,127 +0,0 @@
-
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DEBUGUTIL_H
-#define DEBUGUTIL_H
-
-#include <QEventLoop>
-#include <QTimer>
-#include <QThread>
-#include <QTest>
-#include <QProcess>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <private/qdeclarativedebugclient_p.h>
-#include <private/qdeclarativedebugservice_p.h>
-
-class QDeclarativeDebugTest
-{
-public:
- static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
-};
-
-class QDeclarativeDebugTestService : public QDeclarativeDebugService
-{
- Q_OBJECT
-public:
- QDeclarativeDebugTestService(const QString &s, float version = 1, QObject *parent = 0);
-
-signals:
- void stateHasChanged();
-
-protected:
- virtual void messageReceived(const QByteArray &ba);
- virtual void stateChanged(State state);
-};
-
-class QDeclarativeDebugTestClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-public:
- QDeclarativeDebugTestClient(const QString &s, QDeclarativeDebugConnection *c);
-
- QByteArray waitForResponse();
-
-signals:
- void stateHasChanged();
- void serverMessage(const QByteArray &);
-
-protected:
- virtual void stateChanged(State state);
- virtual void messageReceived(const QByteArray &ba);
-
-private:
- QByteArray lastMsg;
-};
-
-class QDeclarativeDebugProcess : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeDebugProcess(const QString &executable);
- ~QDeclarativeDebugProcess();
-
- void setEnvironment(const QStringList &environment);
-
- void start(const QStringList &arguments);
- bool waitForSessionStart();
-
- QString output() const;
- void stop();
-
-private slots:
- void processAppOutput();
-
-private:
- QString m_executable;
- QProcess m_process;
- QString m_outputBuffer;
- QString m_output;
- QTimer m_timer;
- QEventLoop m_eventLoop;
- QMutex m_mutex;
- bool m_started;
- QStringList m_environment;
-};
-
-#endif // DEBUGUTIL_H
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
deleted file mode 100644
index 85de8618e2..0000000000
--- a/tests/auto/declarative/declarative.pro
+++ /dev/null
@@ -1,56 +0,0 @@
-TEMPLATE = subdirs
-
-METATYPETESTS += \
- qdeclarativemetatype
-
-PUBLICTESTS += \
- parserstress \
- qdeclarativecomponent \
- qdeclarativeconsole \
- qdeclarativecontext \
- qdeclarativeengine \
- qdeclarativeerror \
- qdeclarativefolderlistmodel \
- qdeclarativeincubator \
- qdeclarativeinfo \
- qdeclarativelistreference \
- qdeclarativelocale \
- qdeclarativemetaobject \
- qdeclarativemoduleplugin \
- qdeclarativeqt \
- qdeclarativetranslation \
- qdeclarativexmlhttprequest \
- qdeclarativeparser \
- qjsengine \
- qjsvalue \
- qjsvalueiterator \
- qmlmin \
- qmlplugindump
-
-PRIVATETESTS += \
- animation \
- qdeclarativebinding \
- qdeclarativechangeset \
- qdeclarativeconnection \
- qdeclarativecpputils \
- qdeclarativeecmascript \
- qdeclarativeexpression \
- qdeclarativeimageprovider \
- qdeclarativeinstruction \
- qdeclarativelanguage \
- qdeclarativelistcompositor \
- qdeclarativelistmodel \
- qdeclarativeproperty \
- qdeclarativepropertymap \
- qdeclarativesqldatabase \
- qdeclarativevaluetypes \
- qdeclarativeworkerscript \
- v4
-
-SUBDIRS += $$PUBLICTESTS
-SUBDIRS += $$METATYPETESTS
-SUBDIRS += debugger
-
-contains(QT_CONFIG, private_tests) {
- SUBDIRS += $$PRIVATETESTS
-}
diff --git a/tests/auto/declarative/parserstress/parserstress.pro b/tests/auto/declarative/parserstress/parserstress.pro
deleted file mode 100644
index 021b1de9cc..0000000000
--- a/tests/auto/declarative/parserstress/parserstress.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_parserstress
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_parserstress.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-DEFINES += TESTDATADIR=\\\"$$PWD/tests\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp
deleted file mode 100644
index 25ecef15f6..0000000000
--- a/tests/auto/declarative/parserstress/tst_parserstress.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-#include <QDir>
-#include <QFile>
-
-class tst_parserstress : public QObject
-{
- Q_OBJECT
-public:
- tst_parserstress() {}
-
-private slots:
- void ecmascript_data();
- void ecmascript();
-
-private:
- static QStringList findJSFiles(const QDir &);
- QDeclarativeEngine engine;
-};
-
-QStringList tst_parserstress::findJSFiles(const QDir &d)
-{
- QStringList rv;
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.js"),
- QDir::Files);
- foreach (const QString &file, files) {
- if (file == "browser.js")
- continue;
- rv << d.absoluteFilePath(file);
- }
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findJSFiles(sub);
- }
-
- return rv;
-}
-
-void tst_parserstress::ecmascript_data()
-{
-#ifdef TESTDATADIR
- QDir dir(TESTDATADIR);
- QStringList files = findJSFiles(dir);
-
- QTest::addColumn<QString>("file");
- foreach (const QString &file, files) {
- QTest::newRow(qPrintable(file)) << file;
- }
-#endif
-}
-
-void tst_parserstress::ecmascript()
-{
- QFETCH(QString, file);
-
- QFile f(file);
- QVERIFY(f.open(QIODevice::ReadOnly));
-
- QByteArray data = f.readAll();
-
- QVERIFY(!data.isEmpty());
-
- QString dataStr = QString::fromUtf8(data);
-
- QString qml = "import QtQuick 2.0\n";
- qml+= "\n";
- qml+= "QtObject {\n";
- qml+= " property int test\n";
- qml+= " test: {\n";
- qml+= dataStr + "\n";
- qml+= " return 1;\n";
- qml+= " }\n";
- qml+= " function stress() {\n";
- qml+= dataStr;
- qml+= " }\n";
- qml+= "}\n";
-
- QByteArray qmlData = qml.toUtf8();
-
- QDeclarativeComponent component(&engine);
-
- component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml")));
-
- QFileInfo info(file);
-
- if (info.fileName() == QLatin1String("regress-352044-02-n.js")) {
- QVERIFY(component.isError());
-
- QCOMPARE(component.errors().length(), 2);
-
- QCOMPARE(component.errors().at(0).description(), QString("Expected token `;'"));
- QCOMPARE(component.errors().at(0).line(), 66);
-
- QCOMPARE(component.errors().at(1).description(), QString("Expected token `;'"));
- QCOMPARE(component.errors().at(1).line(), 142);
-
- } else {
-
- QVERIFY(!component.isError());
- }
-}
-
-
-QTEST_MAIN(tst_parserstress)
-
-#include "tst_parserstress.moc"
diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
deleted file mode 100644
index 6098d03509..0000000000
--- a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativebinding
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativebinding.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp
deleted file mode 100644
index 7dc861c02b..0000000000
--- a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativebind_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativebinding : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativebinding();
-
-private slots:
- void binding();
- void whenAfterValue();
- void restoreBinding();
- void restoreBindingWithLoop();
- void deletedObject();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativebinding::tst_qdeclarativebinding()
-{
-}
-
-void tst_qdeclarativebinding::binding()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-binding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarativeBind *binding3 = qobject_cast<QDeclarativeBind*>(rect->findChild<QDeclarativeBind*>("binding3"));
- QVERIFY(binding3 != 0);
-
- QCOMPARE(rect->color(), QColor("yellow"));
- QCOMPARE(rect->property("text").toString(), QString("Hello"));
- QCOMPARE(binding3->when(), false);
-
- rect->setProperty("changeColor", true);
- QCOMPARE(rect->color(), QColor("red"));
-
- QCOMPARE(binding3->when(), true);
-
- QDeclarativeBind *binding = qobject_cast<QDeclarativeBind*>(rect->findChild<QDeclarativeBind*>("binding1"));
- QVERIFY(binding != 0);
- QCOMPARE(binding->object(), qobject_cast<QObject*>(rect));
- QCOMPARE(binding->property(), QLatin1String("text"));
- QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
-
- delete rect;
-}
-
-void tst_qdeclarativebinding::whenAfterValue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-binding2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
-
- QVERIFY(rect != 0);
- QCOMPARE(rect->color(), QColor("yellow"));
- QCOMPARE(rect->property("text").toString(), QString("Hello"));
-
- rect->setProperty("changeColor", true);
- QCOMPARE(rect->color(), QColor("red"));
-
- delete rect;
-}
-
-void tst_qdeclarativebinding::restoreBinding()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("restoreBinding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *myItem = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("myItem"));
- QVERIFY(myItem != 0);
-
- myItem->setY(25);
- QCOMPARE(myItem->x(), qreal(100-25));
-
- myItem->setY(13);
- QCOMPARE(myItem->x(), qreal(100-13));
-
- //Binding takes effect
- myItem->setY(51);
- QCOMPARE(myItem->x(), qreal(51));
-
- myItem->setY(88);
- QCOMPARE(myItem->x(), qreal(88));
-
- //original binding restored
- myItem->setY(49);
- QCOMPARE(myItem->x(), qreal(100-49));
-
- delete rect;
-}
-
-void tst_qdeclarativebinding::restoreBindingWithLoop()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("restoreBindingWithLoop.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *myItem = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("myItem"));
- QVERIFY(myItem != 0);
-
- myItem->setY(25);
- QCOMPARE(myItem->x(), qreal(25 + 100));
-
- myItem->setY(13);
- QCOMPARE(myItem->x(), qreal(13 + 100));
-
- //Binding takes effect
- rect->setProperty("activateBinding", true);
- myItem->setY(51);
- QCOMPARE(myItem->x(), qreal(51));
-
- myItem->setY(88);
- QCOMPARE(myItem->x(), qreal(88));
-
- //original binding restored
- QString warning = c.url().toString() + QLatin1String(":9:5: QML Rectangle: Binding loop detected for property \"x\"");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- rect->setProperty("activateBinding", false);
- QCOMPARE(myItem->x(), qreal(88 + 100)); //if loop handling changes this could be 90 + 100
-
- myItem->setY(49);
- QCOMPARE(myItem->x(), qreal(49 + 100));
-
- delete rect;
-}
-
-//QTBUG-20692
-void tst_qdeclarativebinding::deletedObject()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("deletedObject.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QGuiApplication::sendPostedEvents(0, QEvent::DeferredDelete);
-
- //don't crash
- rect->setProperty("activateBinding", true);
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qdeclarativebinding)
-
-#include "tst_qdeclarativebinding.moc"
diff --git a/tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro b/tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro
deleted file mode 100644
index 7c52ef5dfd..0000000000
--- a/tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativechangeset
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativechangeset.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp b/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp
deleted file mode 100644
index 254996e4db..0000000000
--- a/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp
+++ /dev/null
@@ -1,812 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <private/qdeclarativechangeset_p.h>
-
-#define VERIFY_EXPECTED_OUTPUT
-
-class tst_qdeclarativemodelchange : public QObject
-{
- Q_OBJECT
-public:
- struct Signal
- {
- int index;
- int count;
- int to;
- int moveId;
-
- bool isInsert() const { return to == -1; }
- bool isRemove() const { return to == -2; }
- bool isMove() const { return to >= 0; }
- bool isChange() const { return to == -3; }
- };
-
- static Signal Insert(int index, int count, int moveId = -1) { Signal signal = { index, count, -1, moveId }; return signal; }
- static Signal Remove(int index, int count, int moveId = -1) { Signal signal = { index, count, -2, moveId }; return signal; }
- static Signal Move(int from, int to, int count) { Signal signal = { from, count, to, -1 }; return signal; }
- static Signal Change(int index, int count) { Signal signal = { index, count, -3, -1 }; return signal; }
-
- typedef QVector<Signal> SignalList;
-
-
-#ifdef VERIFY_EXPECTED_OUTPUT
-
- template<typename T>
- void move(int from, int to, int n, T *items)
- {
- if (from > to) {
- // Only move forwards - flip if backwards moving
- int tfrom = from;
- int tto = to;
- from = tto;
- to = tto+n;
- n = tfrom-tto;
- }
-
- T replaced;
- int i=0;
- typename T::ConstIterator it=items->begin(); it += from+n;
- for (; i<to-from; ++i,++it)
- replaced.append(*it);
- i=0;
- it=items->begin(); it += from;
- for (; i<n; ++i,++it)
- replaced.append(*it);
- typename T::ConstIterator f=replaced.begin();
- typename T::Iterator t=items->begin(); t += from;
- for (; f != replaced.end(); ++f, ++t)
- *t = *f;
- }
-
- QVector<int> applyChanges(const QVector<int> &list, const QVector<Signal> &changes)
- {
- QHash<int, QVector<int> > removedValues;
- QVector<int> alteredList = list;
- foreach (const Signal &signal, changes) {
- if (signal.isInsert()) {
- if (signal.moveId != -1) {
- QVector<int> tail = alteredList.mid(signal.index);
- alteredList = alteredList.mid(0, signal.index) + removedValues.take(signal.moveId) + tail;
- } else {
- alteredList.insert(signal.index, signal.count, 100);
- }
- } else if (signal.isRemove()) {
- if (signal.moveId != -1)
- removedValues.insert(signal.moveId, alteredList.mid(signal.index, signal.count));
- alteredList.erase(alteredList.begin() + signal.index, alteredList.begin() + signal.index + signal.count);
- } else if (signal.isMove()) {
- move(signal.index, signal.to, signal.count, &alteredList);
- } else if (signal.isChange()) {
- for (int i = signal.index; i < signal.index + signal.count; ++i) {
- if (alteredList[i] < 100)
- alteredList[i] = 100;
- }
- }
- }
- return alteredList;
- }
-
-#endif
-
-private slots:
- void sequence_data();
- void sequence();
-};
-
-bool operator ==(const tst_qdeclarativemodelchange::Signal &left, const tst_qdeclarativemodelchange::Signal &right)
-{
- return left.index == right.index
- && left.count == right.count
- && left.to == right.to
- && ((left.moveId == -1 && right.moveId == -1) || (left.moveId != -1 && right.moveId != -1));
-}
-
-
-QDebug operator <<(QDebug debug, const tst_qdeclarativemodelchange::Signal &signal)
-{
- if (signal.isInsert())
- debug.nospace() << "Insert(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
- else if (signal.isRemove())
- debug.nospace() << "Remove(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
- else if (signal.isMove())
- debug.nospace() << "Move(" << signal.index << "," << signal.to << "," << signal.count << ")";
- else if (signal.isChange())
- debug.nospace() << "Change(" << signal.index << "," << signal.count << ")";
- return debug;
-}
-
-Q_DECLARE_METATYPE(tst_qdeclarativemodelchange::SignalList)
-
-void tst_qdeclarativemodelchange::sequence_data()
-{
- QTest::addColumn<SignalList>("input");
- QTest::addColumn<SignalList>("output");
-
- // Insert
- QTest::newRow("i(12,5)")
- << (SignalList() << Insert(12,5))
- << (SignalList() << Insert(12,5));
- QTest::newRow("i(2,3),i(12,5)")
- << (SignalList() << Insert(2,3) << Insert(12,5))
- << (SignalList() << Insert(2,3) << Insert(12,5));
- QTest::newRow("i(12,5),i(2,3)")
- << (SignalList() << Insert(12,5) << Insert(2,3))
- << (SignalList() << Insert(2,3) << Insert(15,5));
- QTest::newRow("i(12,5),i(12,3)")
- << (SignalList() << Insert(12,5) << Insert(12,3))
- << (SignalList() << Insert(12,8));
- QTest::newRow("i(12,5),i(17,3)")
- << (SignalList() << Insert(12,5) << Insert(17,3))
- << (SignalList() << Insert(12,8));
- QTest::newRow("i(12,5),i(15,3)")
- << (SignalList() << Insert(12,5) << Insert(15,3))
- << (SignalList() << Insert(12,8));
-
- // Remove
- QTest::newRow("r(3,9)")
- << (SignalList() << Remove(3,9))
- << (SignalList() << Remove(3,9));
- QTest::newRow("r(3,4),r(3,2)")
- << (SignalList() << Remove(3,4) << Remove(3,2))
- << (SignalList() << Remove(3,6));
- QTest::newRow("r(4,3),r(14,5)")
- << (SignalList() << Remove(4,3) << Remove(14,5))
- << (SignalList() << Remove(4,3) << Remove(14,5));
- QTest::newRow("r(14,5),r(4,3)")
- << (SignalList() << Remove(14,5) << Remove(4,3))
- << (SignalList() << Remove(4,3) << Remove(11,5));
- QTest::newRow("r(4,3),r(2,9)")
- << (SignalList() << Remove(4,3) << Remove(2,9))
- << (SignalList() << Remove(2,12));
-
- // Move
- QTest::newRow("m(8-10,2)")
- << (SignalList() << Move(8,10,2))
- << (SignalList() << Remove(8,2,1) << Insert(10,2,1));
-
- QTest::newRow("m(23-12,6),m(13-15,5)")
- << (SignalList() << Move(23,12,6) << Move(13,15,5))
- << (SignalList() << Remove(23,1,0) << Remove(23,5,1) << Insert(12,1,0) << Insert(15,5,1));
- QTest::newRow("m(23-12,6),m(13-15,2)")
- << (SignalList() << Move(23,12,6) << Move(13,20,2))
- << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(12,1,0) << Insert(13,3,2) << Insert(20,2,1));
- QTest::newRow("m(23-12,6),m(13-2,2)")
- << (SignalList() << Move(23,12,6) << Move(13,2,2))
- << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(2,2,1) << Insert(14,1,0) << Insert(15,3,2));
- QTest::newRow("m(23-12,6),m(12-6,5)")
- << (SignalList() << Move(23,12,6) << Move(12,6,5))
- << (SignalList() << Remove(23,5,0) << Remove(23,1,1) << Insert(6,5,0) << Insert(17,1,1));
- QTest::newRow("m(23-12,6),m(10-5,4)")
- << (SignalList() << Move(23,12,6) << Move(10,5,4))
- << (SignalList() << Remove(10,2,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(5,2,0) << Insert(7,2,1) << Insert(14,4,2));
- QTest::newRow("m(23-12,6),m(16-5,4)")
- << (SignalList() << Move(23,12,6) << Move(16,5,4))
- << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(5,2,2) << Insert(7,2,0) << Insert(16,4,1));
- QTest::newRow("m(23-12,6),m(13-5,4)")
- << (SignalList() << Move(23,12,6) << Move(13,5,4))
- << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(5,4,1) << Insert(16,1,0) << Insert(17,1,2));
- QTest::newRow("m(23-12,6),m(14-5,4)")
- << (SignalList() << Move(23,12,6) << Move(14,5,4))
- << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(5,4,1) << Insert(16,2,0));
- QTest::newRow("m(23-12,6),m(12-5,4)")
- << (SignalList() << Move(23,12,6) << Move(12,5,4))
- << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(5,4,0) << Insert(16,2,1));
- QTest::newRow("m(23-12,6),m(11-5,8)")
- << (SignalList() << Move(23,12,6) << Move(11,5,8))
- << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(5,1,0) << Insert(6,6,2) << Insert(12,1,1));
- QTest::newRow("m(23-12,6),m(8-5,4)")
- << (SignalList() << Move(23,12,6) << Move(8,5,4))
- << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
- QTest::newRow("m(23-12,6),m(2-5,4)")
- << (SignalList() << Move(23,12,6) << Move(2,5,4))
- << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
- QTest::newRow("m(23-12,6),m(18-5,4)")
- << (SignalList() << Move(23,12,6) << Move(18,5,4))
- << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
- QTest::newRow("m(23-12,6),m(20-5,4)")
- << (SignalList() << Move(23,12,6) << Move(20,5,4))
- << (SignalList() << Remove(14,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
-
- QTest::newRow("m(23-12,6),m(5-13,11)")
- << (SignalList() << Move(23,12,6) << Move(5,13,11))
- << (SignalList() << Remove(5,7,0) << Remove(16,4,1) << Remove(16,2,2) << Insert(5,2,2) << Insert(13,7,0) << Insert(20,4,1));
-
- QTest::newRow("m(23-12,6),m(12-23,6)")
- << (SignalList() << Move(23,12,6) << Move(12,23,6))
- << (SignalList() << Remove(23,6,0) << Insert(23,6,0)); // ### These cancel out.
- QTest::newRow("m(23-12,6),m(10-23,4)")
- << (SignalList() << Move(23,12,6) << Move(10,23,4))
- << (SignalList() << Remove(10,2 ,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(10,4,2) << Insert(23,2,0) << Insert(25,2,1));
- QTest::newRow("m(23-12,6),m(16-23.4)")
- << (SignalList() << Move(23,12,6) << Move(16,23,4))
- << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(12,4,1) << Insert(23,2,2) << Insert(25,2,0));
- QTest::newRow("m(23-12,6),m(13-23,4)")
- << (SignalList() << Move(23,12,6) << Move(13,23,4))
- << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(12,1,0) << Insert(13,1,2) << Insert(23,4,1));
- QTest::newRow("m(23-12,6),m(14-23,)")
- << (SignalList() << Move(23,12,6) << Move(14,23,4))
- << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(12,2,0) << Insert(23,4,1));
- QTest::newRow("m(23-12,6),m(12-23,4)")
- << (SignalList() << Move(23,12,6) << Move(12,23,4))
- << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(12,2,1) << Insert(23,4,0));
- QTest::newRow("m(23-12,6),m(11-23,8)")
- << (SignalList() << Move(23,12,6) << Move(11,23,8))
- << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(23,1,0) << Insert(24,6,2) << Insert(30,1,1));
- QTest::newRow("m(23-12,6),m(8-23,4)")
- << (SignalList() << Move(23,12,6) << Move(8,23,4))
- << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
- QTest::newRow("m(23-12,6),m(2-23,4)")
- << (SignalList() << Move(23,12,6) << Move(2,23,4))
- << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
- QTest::newRow("m(23-12,6),m(18-23,4)")
- << (SignalList() << Move(23,12,6) << Move(18,23,4))
- << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(12,6,1) << Insert(23,4,0));
- QTest::newRow("m(23-12,6),m(20-23,4)")
- << (SignalList() << Move(23,12,6) << Move(20,23,4))
- << (SignalList() << Remove(14,4,1) << Remove(19,6,0) << Insert(12,6,0) << Insert(23,4,1));
-
- QTest::newRow("m(23-12,6),m(11-23,10)")
- << (SignalList() << Move(23,12,6) << Move(11,23,10))
- << (SignalList() << Remove(11,1,3) << Remove(11,3,1) << Remove(19,6,2) << Insert(23,1,3) << Insert(24,6,2) << Insert(30,3,1));
-
- QTest::newRow("m(3-9,12),m(13-5,12)")
- << (SignalList() << Move(3,9,12) << Move(13,15,5))
- << (SignalList() << Remove(3,4,2) << Remove(3,5,1) << Remove(3,2,0) << Remove(3,1,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,5,1) << Insert(20,1,3));
- QTest::newRow("m(3-9,12),m(13-15,20)")
- << (SignalList() << Move(3,9,12) << Move(13,15,20))
- << (SignalList() << Remove(3,4,0) << Remove(3,8,1) << Remove(9,12,2) << Insert(9,4,0) << Insert(15,8,1) << Insert(23,12,2));
- QTest::newRow("m(3-9,12),m(13-15,2)")
- << (SignalList() << Move(3,9,12) << Move(13,15,2))
- << (SignalList() << Remove(3,4,2) << Remove(3,2,1) << Remove(3,2,0) << Remove(3,4,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,2,1) << Insert(17,4,3));
- QTest::newRow("m(3-9,12),m(12-5,6)")
- << (SignalList() << Move(3,9,12) << Move(12,5,6))
- << (SignalList() << Remove(3,3,0) << Remove(3,6,1) << Remove(3,3,2) << Insert(5,6,1) << Insert(15,3,0) << Insert(18,3,2));
- QTest::newRow("m(3-9,12),m(10-14,5)")
- << (SignalList() << Move(3,9,12) << Move(10,14,5))
- << (SignalList() << Remove(3,1,2) << Remove(3,5,1) << Remove(3,4,0) << Remove(3,2,3) << Insert(9,1,2) << Insert(10,4,0) << Insert(14,5,1) << Insert(19,2,3));
- QTest::newRow("m(3-9,12),m(16-20,5)")
- << (SignalList() << Move(3,9,12) << Move(16,20,5))
- << (SignalList() << Remove(3,7,0) << Remove(3,5,1) << Insert(9,7,0) << Insert(20,5,1));
- QTest::newRow("m(3-9,12),m(13-17,5)")
- << (SignalList() << Move(3,9,12) << Move(13,17,5))
- << (SignalList() << Remove(3,4,0) << Remove(3,5,1) << Remove(3,3,2) << Insert(9,4,0) << Insert(13,3,2) << Insert(17,5,1));
- QTest::newRow("m(3-9,12),m(14-18,5)")
- << (SignalList() << Move(3,9,12) << Move(14,18,5))
- << (SignalList() << Remove(3,5,0) << Remove(3,5,1) << Remove(3,2,2) << Insert(9,5,0) << Insert(14,2,2) << Insert(18,5,1));
- QTest::newRow("m(3-9,12),m(12-16,5)")
- << (SignalList() << Move(3,9,12) << Move(12,16,5))
- << (SignalList() << Remove(3,3,2) << Remove(3,5,1) << Remove(3,4,0) << Insert(9,3,2) << Insert(12,4,0) << Insert(16,5,1));
- QTest::newRow("m(3-9,12),m(11-19,5)")
- << (SignalList() << Move(3,9,12) << Move(11,19,5))
- << (SignalList() << Remove(3,2,0) << Remove(3,5,1) << Remove(3,5,2) << Insert(9,2,0) << Insert(11,5,2) << Insert(19,5,1));
- QTest::newRow("m(3-9,12),m(8-12,5)")
- << (SignalList() << Move(3,9,12) << Move(8,12,5))
- << (SignalList() << Remove(3,4,1) << Remove(3,4,0) << Remove(3,4,4) << Remove(8,1,2) << Insert(8,4,0) << Insert(12,1,2) << Insert(13,4,1) << Insert(17,4,4));
- QTest::newRow("m(3-9,12),m(2-6,5)")
- << (SignalList() << Move(3,9,12) << Move(2,6,5))
- << (SignalList() << Remove(2,1,2) << Remove(2,2,0) << Remove(2,10,3) << Remove(2,4,1) << Insert(4,2,0) << Insert(6,1,2) << Insert(7,4,1) << Insert(11,10,3));
- QTest::newRow("m(3-9,12),m(18-22,5)")
- << (SignalList() << Move(3,9,12) << Move(18,22,5))
- << (SignalList() << Remove(3,9,0) << Remove(3,3,1) << Remove(9,2,2) << Insert(9,9,0) << Insert(22,3,1) << Insert(25,2,2));
- QTest::newRow("m(3-9,12),m(20-24,5)")
- << (SignalList() << Move(3,9,12) << Move(20,24,5))
- << (SignalList() << Remove(3,11,0) << Remove(3,1,1) << Remove(9,4,2) << Insert(9,11,0) << Insert(24,1,1) << Insert(25,4,2));
-
- QTest::newRow("m(3-9,12),m(5-11,8)")
- << (SignalList() << Move(3,9,12) << Move(5,11,8))
- << (SignalList() << Remove(3,4,1) << Remove(3,6,0) << Remove(3,2,3) << Remove(5,4,2) << Insert(5,6,0) << Insert(11,4,2) << Insert(15,2,3) << Insert(15,4,1));
-
- QTest::newRow("m(3-9,12),m(12-23,6)")
- << (SignalList() << Move(3,9,12) << Move(12,23,6))
- << (SignalList() << Remove(3,3,2) << Remove(3,6,1) << Remove(3,3,0) << Insert(9,3,2) << Insert(12,3,0) << Insert(23,6,1));
- QTest::newRow("m(3-9,12),m(10-23,4)")
- << (SignalList() << Move(3,9,12) << Move(10,23,4))
- << (SignalList() << Remove(3,1,2) << Remove(3,4,1) << Remove(3,7,0) << Insert(9,1,2) << Insert(10,7,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(16-23,4)")
- << (SignalList() << Move(3,9,12) << Move(16,23,4))
- << (SignalList() << Remove(3,7,2) << Remove(3,4,1) << Remove(3,1,0) << Insert(9,7,2) << Insert(16,1,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(13-23,4)")
- << (SignalList() << Move(3,9,12) << Move(13,23,4))
- << (SignalList() << Remove(3,4,2) << Remove(3,4,1) << Remove(3,4,0) << Insert(9,4,2) << Insert(13,4,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(14-23,4)")
- << (SignalList() << Move(3,9,12) << Move(14,23,4))
- << (SignalList() << Remove(3,5,2) << Remove(3,4,1) << Remove(3,3,0) << Insert(9,5,2) << Insert(14,3,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(12-23,4)")
- << (SignalList() << Move(3,9,12) << Move(12,23,4))
- << (SignalList() << Remove(3,3,2) << Remove(3,4,1) << Remove(3,5,0) << Insert(9,3,2) << Insert(12,5,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(11-23,8)")
- << (SignalList() << Move(3,9,12) << Move(11,23,8))
- << (SignalList() << Remove(3,2,2) << Remove(3,8,1) << Remove(3,2,0) << Insert(9,2,2) << Insert(11,2,0) << Insert(23,8,1));
- QTest::newRow("m(3-9,12),m(8-23,4)")
- << (SignalList() << Move(3,9,12) << Move(8,23,4))
- << (SignalList() << Remove(3,3,1) << Remove(3,9,0) << Remove(8,1,2) << Insert(8,9,0) << Insert(23,1,2) << Insert(24,3,1));
- QTest::newRow("m(3-9,12),m(2-23,4)")
- << (SignalList() << Move(3,9,12) << Move(2,23,4))
- << (SignalList() << Remove(2,1,2) << Remove(2,12,0) << Remove(2,3,1) << Insert(5,12,0) << Insert(23,1,2) << Insert(24,3,1));
- QTest::newRow("m(3-9,12),m(18-23,4)")
- << (SignalList() << Move(3,9,12) << Move(18,23,4))
- << (SignalList() << Remove(3,9,3) << Remove(3,3,2) << Remove(9,1,1) << Insert(9,9,3) << Insert(23,3,2) << Insert(26,1,1));
- QTest::newRow("m(3-9,12),m(20-23,4)")
- << (SignalList() << Move(3,9,12) << Move(20,23,4))
- << (SignalList() << Remove(3,11,3) << Remove(3,1,2) << Remove(9,3,1) << Insert(9,11,3) << Insert(23,1,2) << Insert(24,3,1));
-
- QTest::newRow("m(3-9,12),m(11-23,10)")
- << (SignalList() << Move(3,9,12) << Move(11,23,10))
- << (SignalList() << Remove(3,2,2) << Remove(3,10,1) << Insert(9,2,2) << Insert(23,10,1));
-
- // Change
- QTest::newRow("c(4,5)")
- << (SignalList() << Change(4,5))
- << (SignalList() << Change(4,5));
- QTest::newRow("c(4,5),c(12,2)")
- << (SignalList() << Change(4,5) << Change(12,2))
- << (SignalList() << Change(4,5) << Change(12,2));
- QTest::newRow("c(12,2),c(4,5)")
- << (SignalList() << Change(12,2) << Change(4,5))
- << (SignalList() << Change(4,5) << Change(12,2));
- QTest::newRow("c(4,5),c(2,2)")
- << (SignalList() << Change(4,5) << Change(2,2))
- << (SignalList() << Change(2,7));
- QTest::newRow("c(4,5),c(9,2)")
- << (SignalList() << Change(4,5) << Change(9,2))
- << (SignalList() << Change(4,7));
- QTest::newRow("c(4,5),c(3,2)")
- << (SignalList() << Change(4,5) << Change(3,2))
- << (SignalList() << Change(3,6));
- QTest::newRow("c(4,5),c(8,2)")
- << (SignalList() << Change(4,5) << Change(8,2))
- << (SignalList() << Change(4,6));
- QTest::newRow("c(4,5),c(3,2)")
- << (SignalList() << Change(4,5) << Change(3,2))
- << (SignalList() << Change(3,6));
- QTest::newRow("c(4,5),c(2,9)")
- << (SignalList() << Change(4,5) << Change(2,9))
- << (SignalList() << Change(2,9));
- QTest::newRow("c(4,5),c(12,3),c(8,6)")
- << (SignalList() << Change(4,5) << Change(12,3) << Change(8,6))
- << (SignalList() << Change(4,11));
-
- // Insert,then remove.
- QTest::newRow("i(12,6),r(12,6)")
- << (SignalList() << Insert(12,6) << Remove(12,6))
- << (SignalList());
- QTest::newRow("i(12,6),r(10,4)")
- << (SignalList() << Insert(12,6) << Remove(10,4))
- << (SignalList() << Remove(10,2) << Insert(10,4));
- QTest::newRow("i(12,6),r(16,4)")
- << (SignalList() << Insert(12,6) << Remove(16,4))
- << (SignalList() << Remove(12,2) << Insert(12,4));
- QTest::newRow("i(12,6),r(13,4)")
- << (SignalList() << Insert(12,6) << Remove(13,4))
- << (SignalList() << Insert(12,2));
- QTest::newRow("i(12,6),r(14,4)")
- << (SignalList() << Insert(12,6) << Remove(14,4))
- << (SignalList() << Insert(12,2));
- QTest::newRow("i(12,6),r(12,4)")
- << (SignalList() << Insert(12,6) << Remove(12,4))
- << (SignalList() << Insert(12,2));
- QTest::newRow("i(12,6),r(11,8)")
- << (SignalList() << Insert(12,6) << Remove(11,8))
- << (SignalList() << Remove(11,2));
- QTest::newRow("i(12,6),r(8,4)")
- << (SignalList() << Insert(12,6) << Remove(8,4))
- << (SignalList() << Remove(8,4) << Insert(8,6));
- QTest::newRow("i(12,6),r(2,4)")
- << (SignalList() << Insert(12,6) << Remove(2,4))
- << (SignalList() << Remove(2,4) << Insert(8,6));
- QTest::newRow("i(12,6),r(18,4)")
- << (SignalList() << Insert(12,6) << Remove(18,4))
- << (SignalList() << Remove(12,4) << Insert(12,6));
- QTest::newRow("i(12,6),r(20,4)")
- << (SignalList() << Insert(12,6) << Remove(20,4))
- << (SignalList() << Remove(14,4) << Insert(12,6));
-
- // Insert,then move
- QTest::newRow("i(12,6),m(12-5,6)")
- << (SignalList() << Insert(12,6) << Move(12,5,6))
- << (SignalList() << Insert(5,6));
- QTest::newRow("i(12,6),m(10-5,4)")
- << (SignalList() << Insert(12,6) << Move(10,5,4))
- << (SignalList() << Remove(10,2,0) << Insert(5,2,0) << Insert(7,2) << Insert(14,4));
- QTest::newRow("i(12,6),m(16-5,4)")
- << (SignalList() << Insert(12,6) << Move(16,5,4))
- << (SignalList() << Remove(12,2,0) << Insert(5,2) << Insert(7,2,0) << Insert(16,4));
- QTest::newRow("i(12,6),m(13-5,4)")
- << (SignalList() << Insert(12,6) << Move(13,5,4))
- << (SignalList() << Insert(5,4) << Insert(16,2));
- QTest::newRow("i(12,6),m(14-5,4)")
- << (SignalList() << Insert(12,6) << Move(14,5,4))
- << (SignalList() << Insert(5,4) << Insert(16,2));
- QTest::newRow("i(12,6),m(12-5,4)")
- << (SignalList() << Insert(12,6) << Move(12,5,4))
- << (SignalList() << Insert(5,4) << Insert(16,2));
- QTest::newRow("i(12,6),m(11-5,8)")
- << (SignalList() << Insert(12,6) << Move(11,5,8))
- << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(5,1,0) << Insert(6,6) << Insert(12,1,1));
- QTest::newRow("i(12,6),m(8-5,4)")
- << (SignalList() << Insert(12,6) << Move(8,5,4))
- << (SignalList() << Remove(8,4,0) << Insert(5,4,0) << Insert(12,6));
- QTest::newRow("i(12,6),m(2-5,4)")
- << (SignalList() << Insert(12,6) << Move(2,5,4))
- << (SignalList() << Remove(2,4,0) << Insert(5,4,0) << Insert(12,6));
- QTest::newRow("i(12,6),m(18-5,4)")
- << (SignalList() << Insert(12,6) << Move(18,5,4))
- << (SignalList() << Remove(12,4,0) << Insert(5,4,0) << Insert(16,6));
- QTest::newRow("i(12,6),m(20-5,4)")
- << (SignalList() << Insert(12,6) << Move(20,5,4))
- << (SignalList() << Remove(14,4,0) << Insert(5,4,0) << Insert(16,6));
-
- QTest::newRow("i(12,6),m(5-13,11)")
- << (SignalList() << Insert(12,6) << Move(5,11,8))
- << (SignalList() << Remove(5,7,0) << Insert(5,5) << Insert(11,7,0) << Insert(18,1));
-
- QTest::newRow("i(12,6),m(12-23,6)")
- << (SignalList() << Insert(12,6) << Move(12,23,6))
- << (SignalList() << Insert(23,6));
- QTest::newRow("i(12,6),m(10-23,4)")
- << (SignalList() << Insert(12,6) << Move(10,23,4))
- << (SignalList() << Remove(10,2,0) << Insert(10,4) << Insert(23,2,0) << Insert(25,2));
- QTest::newRow("i(12,6),m(16-23,4)")
- << (SignalList() << Insert(12,6) << Move(16,23,4))
- << (SignalList() << Remove(12,2,0) << Insert(12,4) << Insert(23,2) << Insert(25,2,0));
- QTest::newRow("i(12,6),m(13-23,4)")
- << (SignalList() << Insert(12,6) << Move(13,23,4))
- << (SignalList() << Insert(12,2) << Insert(23,4));
- QTest::newRow("i(12,6),m(14-23,4)")
- << (SignalList() << Insert(12,6) << Move(14,23,4))
- << (SignalList() << Insert(12,2) << Insert(23,4));
- QTest::newRow("i(12,6),m(12-23,4)")
- << (SignalList() << Insert(12,6) << Move(12,23,4))
- << (SignalList() << Insert(12,2) << Insert(23,4));
- QTest::newRow("i(12,6),m(11-23,8)")
- << (SignalList() << Insert(12,6) << Move(11,23,8))
- << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(23,1,0)<< Insert(24,6) << Insert(30,1,1));
- QTest::newRow("i(12,6),m(8-23,4)")
- << (SignalList() << Insert(12,6) << Move(8,23,4))
- << (SignalList() << Remove(8,4,0) << Insert(8,6) << Insert(23,4,0));
- QTest::newRow("i(12,6),m(2-23,4)")
- << (SignalList() << Insert(12,6) << Move(2,23,4))
- << (SignalList() << Remove(2,4,0) << Insert(8,6) << Insert(23,4,0));
- QTest::newRow("i(12,6),m(18-23,4)")
- << (SignalList() << Insert(12,6) << Move(18,23,4))
- << (SignalList() << Remove(12,4,0) << Insert(12,6) << Insert(23,4,0));
- QTest::newRow("i(12,6),m(20-23,4)")
- << (SignalList() << Insert(12,6) << Move(20,23,4))
- << (SignalList() << Remove(14,4,0) << Insert(12,6) << Insert(23,4,0));
-
- QTest::newRow("i(12,6),m(11-23,10)")
- << (SignalList() << Insert(12,6) << Move(11,23,10))
- << (SignalList() << Remove(11,1,0) << Remove(11,3,1) << Insert(23,1,0) << Insert(24,6) << Insert(30,3,1));
-
- // Insert,then change
- QTest::newRow("i(12,6),c(12,6)")
- << (SignalList() << Insert(12,6) << Change(12,6))
- << (SignalList() << Insert(12,6));
- QTest::newRow("i(12,6),c(10,6)")
- << (SignalList() << Insert(12,6) << Change(10,6))
- << (SignalList() << Insert(12,6) << Change(10,2));
- QTest::newRow("i(12,6),c(16,4)")
- << (SignalList() << Insert(12,6) << Change(16,4))
- << (SignalList() << Insert(12,6) << Change(18,2));
- QTest::newRow("i(12,6),c(13,4)")
- << (SignalList() << Insert(12,6) << Change(13,4))
- << (SignalList() << Insert(12,6));
- QTest::newRow("i(12,6),c(14,4)")
- << (SignalList() << Insert(12,6) << Change(14,4))
- << (SignalList() << Insert(12,6));
- QTest::newRow("i(12,6),c(12,4)")
- << (SignalList() << Insert(12,6) << Change(12,4))
- << (SignalList() << Insert(12,6));
- QTest::newRow("i(12,6),c(11,8)")
- << (SignalList() << Insert(12,6) << Change(11,8))
- << (SignalList() << Insert(12,6) << Change(11,1) << Change(18,1));
- QTest::newRow("i(12,6),c(8,4)")
- << (SignalList() << Insert(12,6) << Change(8,4))
- << (SignalList() << Insert(12,6) << Change(8,4));
- QTest::newRow("i(12,6),c(2,4)")
- << (SignalList() << Insert(12,6) << Change(2,4))
- << (SignalList() << Insert(12,6) << Change(2,4));
- QTest::newRow("i(12,6),c(18,4)")
- << (SignalList() << Insert(12,6) << Change(18,4))
- << (SignalList() << Insert(12,6) << Change(18,4));
- QTest::newRow("i(12,6),c(20,4)")
- << (SignalList() << Insert(12,6) << Change(20,4))
- << (SignalList() << Insert(12,6) << Change(20,4));
-
- // Remove,then insert
- QTest::newRow("r(12,6),i(12,6)")
- << (SignalList() << Remove(12,6) << Insert(12,6))
- << (SignalList() << Remove(12,6) << Insert(12,6));
- QTest::newRow("r(12,6),i(10,4)")
- << (SignalList() << Remove(12,6) << Insert(10,14))
- << (SignalList() << Remove(12,6) << Insert(10,14));
- QTest::newRow("r(12,6),i(16,4)")
- << (SignalList() << Remove(12,6) << Insert(16,4))
- << (SignalList() << Remove(12,6) << Insert(16,4));
- QTest::newRow("r(12,6),i(13,4)")
- << (SignalList() << Remove(12,6) << Insert(13,4))
- << (SignalList() << Remove(12,6) << Insert(13,4));
- QTest::newRow("r(12,6),i(14,4)")
- << (SignalList() << Remove(12,6) << Insert(14,4))
- << (SignalList() << Remove(12,6) << Insert(14,4));
- QTest::newRow("r(12,6),i(12,4)")
- << (SignalList() << Remove(12,6) << Insert(12,4))
- << (SignalList() << Remove(12,6) << Insert(12,4));
- QTest::newRow("r(12,6),i(11,8)")
- << (SignalList() << Remove(12,6) << Insert(11,8))
- << (SignalList() << Remove(12,6) << Insert(11,8));
- QTest::newRow("r(12,6),i(8,4)")
- << (SignalList() << Remove(12,6) << Insert(8,4))
- << (SignalList() << Remove(12,6) << Insert(8,4));
- QTest::newRow("r(12,6),i(2,4)")
- << (SignalList() << Remove(12,6) << Insert(2,4))
- << (SignalList() << Remove(12,6) << Insert(2,4));
- QTest::newRow("r(12,6),i(18,4)")
- << (SignalList() << Remove(12,6) << Insert(18,4))
- << (SignalList() << Remove(12,6) << Insert(18,4));
- QTest::newRow("r(12,6),i(20,4)")
- << (SignalList() << Remove(12,6) << Insert(20,4))
- << (SignalList() << Remove(12,6) << Insert(20,4));
-
- // Move,then insert
- QTest::newRow("m(12-5,6),i(12,6)")
- << (SignalList() << Move(12,5,6) << Insert(12,6))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,6));
- QTest::newRow("m(12-5,6),i(10,4)")
- << (SignalList() << Move(12,5,6) << Insert(10,4))
- << (SignalList() << Remove(12,5,0) << Remove(12,1,1) << Insert(5,5,0) << Insert(10,4) << Insert(14,1,1));
- QTest::newRow("m(12-5,6),i(16,4)")
- << (SignalList() << Move(12,5,6) << Insert(16,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(16,4));
- QTest::newRow("m(12-5,6),i(13,4)")
- << (SignalList() << Move(12,5,6) << Insert(13,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(13,4));
- QTest::newRow("m(12-5,6),i(14,4)")
- << (SignalList() << Move(12,5,6) << Insert(14,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(14,4));
- QTest::newRow("m(12-5,6),i(12,4)")
- << (SignalList() << Move(12,5,6) << Insert(12,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,4));
- QTest::newRow("m(12-5,6),i(11,8)")
- << (SignalList() << Move(12,5,6) << Insert(11,8))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(11,8));
- QTest::newRow("m(12-5,6),i(8,4)")
- << (SignalList() << Move(12,5,6) << Insert(8,4))
- << (SignalList() << Remove(12,3,0) << Remove(12,3,1) << Insert(5,3,0) << Insert(8,4) << Insert(12,3,1));
- QTest::newRow("m(12-5,6),i(2,4)")
- << (SignalList() << Move(12,5,6) << Insert(2,4))
- << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(9,6,0));
- QTest::newRow("m(12-5,6),i(18,4)")
- << (SignalList() << Move(12,5,6) << Insert(18,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(18,4));
- QTest::newRow("m(12-5,6),i(20,4)")
- << (SignalList() << Move(12,5,6) << Insert(20,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(20,4));
-
- QTest::newRow("m(12-23,6),i(12,6)")
- << (SignalList() << Move(12,23,6) << Insert(12,6))
- << (SignalList() << Remove(12,6,0) << Insert(12,6) << Insert(29,6,0));
- QTest::newRow("m(12-23,6),i(10,4)")
- << (SignalList() << Move(12,23,6) << Insert(10,4))
- << (SignalList() << Remove(12,6,0) << Insert(10,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(16,4)")
- << (SignalList() << Move(12,23,6) << Insert(16,4))
- << (SignalList() << Remove(12,6,0) << Insert(16,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(13,4)")
- << (SignalList() << Move(12,23,6) << Insert(13,4))
- << (SignalList() << Remove(12,6,0) << Insert(13,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(14,4)")
- << (SignalList() << Move(12,23,6) << Insert(14,4))
- << (SignalList() << Remove(12,6,0) << Insert(14,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(12,4)")
- << (SignalList() << Move(12,23,6) << Insert(12,4))
- << (SignalList() << Remove(12,6,0) << Insert(12,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(11,8)")
- << (SignalList() << Move(12,23,6) << Insert(11,8))
- << (SignalList() << Remove(12,6,0) << Insert(11,8) << Insert(31,6,0));
- QTest::newRow("m(12-23,6),i(8,4)")
- << (SignalList() << Move(12,23,6) << Insert(8,4))
- << (SignalList() << Remove(12,6,0) << Insert(8,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(2,4)")
- << (SignalList() << Move(12,23,6) << Insert(2,4))
- << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(18,4)")
- << (SignalList() << Move(12,23,6) << Insert(18,4))
- << (SignalList() << Remove(12,6,0) << Insert(18,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(20,4)")
- << (SignalList() << Move(12,23,6) << Insert(20,4))
- << (SignalList() << Remove(12,6,0) << Insert(20,4) << Insert(27,6,0));
-
- // Move,then remove
- QTest::newRow("m(12-5,6),r(12,6)")
- << (SignalList() << Move(12,5,6) << Remove(12,6))
- << (SignalList() << Remove(6,6) << Remove(6,6,0) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(10,4)")
- << (SignalList() << Move(12,5,6) << Remove(10,4))
- << (SignalList() << Remove(5,3) << Remove(9,5,0) << Remove(9,1) << Insert(5,5,0));
- QTest::newRow("m(12-5,6),r(16,4)")
- << (SignalList() << Move(12,5,6) << Remove(16,4))
- << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(13,4)")
- << (SignalList() << Move(12,5,6) << Remove(13,4))
- << (SignalList() << Remove(7,4) << Remove(8,6,0) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(14,4)")
- << (SignalList() << Move(12,5,6) << Remove(14,4))
- << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(12,4)")
- << (SignalList() << Move(12,5,6) << Remove(12,4))
- << (SignalList() << Remove(6,4) << Remove(8,6,0) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(11,8)")
- << (SignalList() << Move(12,5,6) << Remove(11,8))
- << (SignalList() << Remove(5,7) << Remove(5,6,0) << Remove(5,1) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(8,4)")
- << (SignalList() << Move(12,5,6) << Remove(8,4))
- << (SignalList() << Remove(5,1) << Remove(11,3,0) << Remove(11,3) << Insert(5,3,0));
- QTest::newRow("m(12-5,6),r(2,4)")
- << (SignalList() << Move(12,5,6) << Remove(2,4))
- << (SignalList() << Remove(2,3) << Remove(9,1) << Remove(9,5,0) << Insert(2,5,0));
- QTest::newRow("m(12-5,6),r(6,4)")
- << (SignalList() << Move(12,5,6) << Remove(6,4))
- << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(12,1,1) << Insert(5,1,0) << Insert(6,1,1));
- QTest::newRow("m(12-5,6),r(18,4)")
- << (SignalList() << Move(12,5,6) << Remove(18,4))
- << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(20,4)")
- << (SignalList() << Move(12,5,6) << Remove(20,4))
- << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(5,6,0));
-
- QTest::newRow("m(12-23,6),r(12,6)")
- << (SignalList() << Move(12,23,6) << Remove(12,6))
- << (SignalList() << Remove(12,6,0) << Remove(12,6) << Insert(17,6,0));
- QTest::newRow("m(12-23,6),r(10,4)")
- << (SignalList() << Move(12,23,6) << Remove(10,4))
- << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(16,4)")
- << (SignalList() << Move(12,23,6) << Remove(16,4))
- << (SignalList() << Remove(12,6,0) << Remove(16,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(13,4)")
- << (SignalList() << Move(12,23,6) << Remove(13,4))
- << (SignalList() << Remove(12,6,0) << Remove(13,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(14,4)")
- << (SignalList() << Move(12,23,6) << Remove(14,4))
- << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(12,4)")
- << (SignalList() << Move(12,23,6) << Remove(12,4))
- << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(11,8)")
- << (SignalList() << Move(12,23,6) << Remove(11,8))
- << (SignalList() << Remove(11,1) << Remove(11,6,0) << Remove(11,7) << Insert(15,6,0));
- QTest::newRow("m(12-23,6),r(8,4)")
- << (SignalList() << Move(12,23,6) << Remove(8,4))
- << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(2,4)")
- << (SignalList() << Move(12,23,6) << Remove(2,4))
- << (SignalList() << Remove(2,4) << Remove(8,6,0) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(18,4)")
- << (SignalList() << Move(12,23,6) << Remove(18,4))
- << (SignalList() << Remove(12,6,0) << Remove(18,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(20,4)")
- << (SignalList() << Move(12,23,6) << Remove(20,4))
- << (SignalList() << Remove(12,1) << Remove(12,5,0) << Remove(20,3) << Insert(20,5,0));
-
-
- // Complex
- QTest::newRow("r(15,1),r(22,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1))
- << (SignalList() << Remove(15,1) << Remove(22,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1))
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1))
- << (SignalList() << Remove(15,2) << Remove(21,1) << Remove(24,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1))
- << (SignalList() << Remove(13,1) << Remove(14,2) << Remove(20,1) << Remove(23,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1))
- << (SignalList() << Remove(13,4) << Remove(19,1) << Remove(22,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1),m(12,13,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1) << Move(12,13,1))
- << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(18,1) << Remove(21,1) << Insert(13,1,0));
-
-}
-
-void tst_qdeclarativemodelchange::sequence()
-{
- QFETCH(SignalList, input);
- QFETCH(SignalList, output);
-
- QDeclarativeChangeSet set;
-
- foreach (const Signal &signal, input) {
- if (signal.isRemove())
- set.remove(signal.index, signal.count);
- else if (signal.isInsert())
- set.insert(signal.index, signal.count);
- else if (signal.isMove())
- set.move(signal.index, signal.to, signal.count);
- else if (signal.isChange())
- set.change(signal.index, signal.count);
- }
-
- SignalList changes;
- foreach (const QDeclarativeChangeSet::Remove &remove, set.removes())
- changes << Remove(remove.index, remove.count, remove.moveId);
- foreach (const QDeclarativeChangeSet::Insert &insert, set.inserts())
- changes << Insert(insert.index, insert.count, insert.moveId);
- foreach (const QDeclarativeChangeSet::Change &change, set.changes())
- changes << Change(change.index, change.count);
-
-#ifdef VERIFY_EXPECTED_OUTPUT
- QVector<int> list;
- for (int i = 0; i < 40; ++i)
- list.append(i);
- QVector<int> inputList = applyChanges(list, input);
- QVector<int> outputList = applyChanges(list, output);
- if (outputList != inputList /* || changes != output*/) {
- qDebug() << input;
- qDebug() << output;
- qDebug() << changes;
- qDebug() << inputList;
- qDebug() << outputList;
- } else if (changes != output) {
- qDebug() << output;
- qDebug() << changes;
- }
- QCOMPARE(outputList, inputList);
-#else
-
- if (changes != output) {
- qDebug() << output;
- qDebug() << changes;
- }
-
-#endif
-
- QCOMPARE(changes, output);
-}
-
-
-QTEST_MAIN(tst_qdeclarativemodelchange)
-
-#include "tst_qdeclarativechangeset.moc"
diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
deleted file mode 100644
index 2389ca4a20..0000000000
--- a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativecomponent
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativecomponent.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
deleted file mode 100644
index 993c706092..0000000000
--- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QDebug>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <qcolor.h>
-#include "../../shared/util.h"
-
-class MyIC : public QObject, public QDeclarativeIncubationController
-{
- Q_OBJECT
-public:
- MyIC() { startTimer(5); }
-protected:
- virtual void timerEvent(QTimerEvent*) {
- incubateFor(5);
- }
-};
-
-class tst_qdeclarativecomponent : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativecomponent() { engine.setIncubationController(&ic); }
-
-private slots:
- void null();
- void loadEmptyUrl();
- void qmlCreateObject();
- void qmlCreateObjectWithProperties();
- void qmlIncubateObject();
- void qmlCreateParentReference();
-
-private:
- QDeclarativeEngine engine;
- MyIC ic;
-};
-
-void tst_qdeclarativecomponent::null()
-{
- {
- QDeclarativeComponent c;
- QVERIFY(c.isNull());
- }
-
- {
- QDeclarativeComponent c(&engine);
- QVERIFY(c.isNull());
- }
-}
-
-
-void tst_qdeclarativecomponent::loadEmptyUrl()
-{
- QDeclarativeComponent c(&engine);
- c.loadUrl(QUrl());
-
- QVERIFY(c.isError());
- QCOMPARE(c.errors().count(), 1);
- QDeclarativeError error = c.errors().first();
- QCOMPARE(error.url(), QUrl());
- QCOMPARE(error.line(), -1);
- QCOMPARE(error.column(), -1);
- QCOMPARE(error.description(), QLatin1String("Invalid empty URL"));
-}
-
-void tst_qdeclarativecomponent::qmlIncubateObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("incubateObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), false);
-
- QTRY_VERIFY(object->property("test2").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativecomponent::qmlCreateObject()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("createObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *testObject1 = object->property("qobject").value<QObject*>();
- QVERIFY(testObject1);
- QVERIFY(testObject1->parent() == object);
-
- QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
- QVERIFY(testObject2);
- QVERIFY(testObject2->parent() == object);
- QCOMPARE(testObject2->metaObject()->className(), "QQuickItem");
-}
-
-void tst_qdeclarativecomponent::qmlCreateObjectWithProperties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("createObjectWithScript.qml"));
- QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *testObject1 = object->property("declarativerectangle").value<QObject*>();
- QVERIFY(testObject1);
- QVERIFY(testObject1->parent() == object);
- QCOMPARE(testObject1->property("x").value<int>(), 17);
- QCOMPARE(testObject1->property("y").value<int>(), 17);
- QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255));
- QCOMPARE(QDeclarativeProperty::read(testObject1,"border.width").toInt(), 3);
- QCOMPARE(QDeclarativeProperty::read(testObject1,"innerRect.border.width").toInt(), 20);
- delete testObject1;
-
- QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
- QVERIFY(testObject2);
- QVERIFY(testObject2->parent() == object);
- //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2");
- QCOMPARE(testObject2->property("x").value<int>(), 17);
- QCOMPARE(testObject2->property("y").value<int>(), 17);
- QCOMPARE(testObject2->property("testBool").value<bool>(), true);
- QCOMPARE(testObject2->property("testInt").value<int>(), 17);
- QCOMPARE(testObject2->property("testObject").value<QObject*>(), object);
- delete testObject2;
-
- QObject *testBindingObj = object->property("bindingTestObject").value<QObject*>();
- QVERIFY(testBindingObj);
- QCOMPARE(testBindingObj->parent(), object);
- QCOMPARE(testBindingObj->property("testValue").value<int>(), 300);
- object->setProperty("width", 150);
- QCOMPARE(testBindingObj->property("testValue").value<int>(), 150 * 3);
- delete testBindingObj;
-
- QObject *testBindingThisObj = object->property("bindingThisTestObject").value<QObject*>();
- QVERIFY(testBindingThisObj);
- QCOMPARE(testBindingThisObj->parent(), object);
- QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 900);
- testBindingThisObj->setProperty("width", 200);
- QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 200 * 3);
- delete testBindingThisObj;
-}
-
-static QStringList warnings;
-static void msgHandler(QtMsgType, const char *warning)
-{
- warnings << QString::fromUtf8(warning);
-}
-
-void tst_qdeclarativecomponent::qmlCreateParentReference()
-{
- QDeclarativeEngine engine;
-
- QCOMPARE(engine.outputWarningsToStandardError(), true);
-
- warnings.clear();
- QtMsgHandler old = qInstallMsgHandler(msgHandler);
-
- QDeclarativeComponent component(&engine, testFileUrl("createParentReference.qml"));
- QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(QMetaObject::invokeMethod(object, "createChild"));
- delete object;
-
- qInstallMsgHandler(old);
-
- engine.setOutputWarningsToStandardError(false);
- QCOMPARE(engine.outputWarningsToStandardError(), false);
-
- QCOMPARE(warnings.count(), 0);
-}
-
-QTEST_MAIN(tst_qdeclarativecomponent)
-
-#include "tst_qdeclarativecomponent.moc"
diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
deleted file mode 100644
index bb863c5262..0000000000
--- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeconnection
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeconnection.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
deleted file mode 100644
index 0474b4388e..0000000000
--- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativeconnections_p.h>
-#include <private/qquickitem_p.h>
-#include "../../shared/util.h"
-#include <QtDeclarative/qdeclarativescriptstring.h>
-
-class tst_qdeclarativeconnection : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeconnection();
-
-private slots:
- void defaultValues();
- void properties();
- void connection();
- void trimming();
- void targetChanged();
- void unknownSignals_data();
- void unknownSignals();
- void errors_data();
- void errors();
- void moduleApiTarget();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeconnection::tst_qdeclarativeconnection()
-{
-}
-
-void tst_qdeclarativeconnection::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-connection3.qml"));
- QDeclarativeConnections *item = qobject_cast<QDeclarativeConnections*>(c.create());
-
- QVERIFY(item != 0);
- QVERIFY(item->target() == 0);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-connection2.qml"));
- QDeclarativeConnections *item = qobject_cast<QDeclarativeConnections*>(c.create());
-
- QVERIFY(item != 0);
-
- QVERIFY(item != 0);
- QVERIFY(item->target() == item);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::connection()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-connection.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
-
- QVERIFY(item != 0);
-
- QCOMPARE(item->property("tested").toBool(), false);
- QCOMPARE(item->width(), 50.);
- emit item->setWidth(100.);
- QCOMPARE(item->width(), 100.);
- QCOMPARE(item->property("tested").toBool(), true);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::trimming()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("trimming.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
-
- QVERIFY(item != 0);
-
- QCOMPARE(item->property("tested").toString(), QString(""));
- int index = item->metaObject()->indexOfSignal("testMe(int,QString)");
- QMetaMethod method = item->metaObject()->method(index);
- method.invoke(item,
- Qt::DirectConnection,
- Q_ARG(int, 5),
- Q_ARG(QString, "worked"));
- QCOMPARE(item->property("tested").toString(), QString("worked5"));
-
- delete item;
-}
-
-// Confirm that target can be changed by one of our signal handlers
-void tst_qdeclarativeconnection::targetChanged()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("connection-targetchange.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(item != 0);
-
- QDeclarativeConnections *connections = item->findChild<QDeclarativeConnections*>("connections");
- QVERIFY(connections);
-
- QQuickItem *item1 = item->findChild<QQuickItem*>("item1");
- QVERIFY(item1);
-
- item1->setWidth(200);
-
- QQuickItem *item2 = item->findChild<QQuickItem*>("item2");
- QVERIFY(item2);
- QVERIFY(connections->target() == item2);
-
- // If we don't crash then we're OK
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::unknownSignals_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
- QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
- QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error
- QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error
-}
-
-void tst_qdeclarativeconnection::unknownSignals()
-{
- QFETCH(QString, file);
- QFETCH(QString, error);
-
- QUrl url = testFileUrl(file);
- if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1());
- } else {
- // QTest has no way to insist no message (i.e. fail)
- }
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, url);
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(item != 0);
-
- // check that connection is created (they are all runtime errors)
- QDeclarativeConnections *connections = item->findChild<QDeclarativeConnections*>("connections");
- QVERIFY(connections);
-
- if (file == "connection-unknownsignals-ignored.qml")
- QVERIFY(connections->ignoreUnknownSignals());
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::errors_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\"";
- QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\"";
- QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed";
- QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error";
-}
-
-void tst_qdeclarativeconnection::errors()
-{
- QFETCH(QString, file);
- QFETCH(QString, error);
-
- QUrl url = testFileUrl(file);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, url);
- QVERIFY(c.isError() == true);
- QList<QDeclarativeError> errors = c.errors();
- QVERIFY(errors.count() == 1);
- QCOMPARE(errors.at(0).description(), error);
-}
-
-
-class MyTestModuleApi : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged)
-
-public:
- MyTestModuleApi(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {}
- ~MyTestModuleApi() {}
-
- Q_INVOKABLE int otherMethod(int val) { return val + 4; }
-
- int intProp() const { return m_intProp; }
- void setIntProp(int val)
- {
- if (++m_changeCount % 3 == 0) emit otherSignal();
- m_intProp = val; emit intPropChanged();
- }
-
-signals:
- void intPropChanged();
- void otherSignal();
-
-private:
- int m_intProp;
- int m_changeCount;
-};
-
-static QObject *module_api_factory(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
- MyTestModuleApi *api = new MyTestModuleApi();
- return api;
-}
-
-// QTBUG-20937
-void tst_qdeclarativeconnection::moduleApiTarget()
-{
- qmlRegisterModuleApi("MyTestModuleApi", 1, 0, module_api_factory);
- QDeclarativeComponent component(&engine, testFileUrl("moduleapi-target.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 0);
- QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
-
- QMetaObject::invokeMethod(object, "setModuleIntProp");
- QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 1);
- QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
-
- QMetaObject::invokeMethod(object, "setModuleIntProp");
- QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 2);
- QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
-
- // the module API emits otherSignal every 3 times the int property changes.
- QMetaObject::invokeMethod(object, "setModuleIntProp");
- QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 3);
- QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 1);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativeconnection)
-
-#include "tst_qdeclarativeconnection.moc"
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/tracing.qml b/tests/auto/declarative/qdeclarativeconsole/data/tracing.qml
deleted file mode 100644
index 0d1b76359e..0000000000
--- a/tests/auto/declarative/qdeclarativeconsole/data/tracing.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-// moving lines in here requires fixing tst_qdeclarativeconsole.cpp
-QtObject {
- id: root
-
- function tracing()
- {
- console.trace();
- }
-
- Component.onCompleted: {
- tracing();
- }
-}
diff --git a/tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro b/tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro
deleted file mode 100644
index 0563491c1e..0000000000
--- a/tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeconsole
-SOURCES += tst_qdeclarativeconsole.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += declarative testlib
diff --git a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp b/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
deleted file mode 100644
index f5788dcf55..0000000000
--- a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QDebug>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeconsole : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeconsole() {}
-
-private slots:
- void logging();
- void tracing();
- void profiling();
- void assert();
- void exception();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeconsole::logging()
-{
- QUrl testUrl = testFileUrl("logging.qml");
-
- QTest::ignoreMessage(QtDebugMsg, "console.debug");
- QTest::ignoreMessage(QtDebugMsg, "console.log");
- QTest::ignoreMessage(QtDebugMsg, "console.info");
- QTest::ignoreMessage(QtWarningMsg, "console.warn");
- QTest::ignoreMessage(QtCriticalMsg, "console.error");
-
- QTest::ignoreMessage(QtDebugMsg, "console.count: 1");
- QTest::ignoreMessage(QtDebugMsg, ": 1");
- QTest::ignoreMessage(QtDebugMsg, "console.count: 2");
- QTest::ignoreMessage(QtDebugMsg, ": 2");
-
- QTest::ignoreMessage(QtDebugMsg, "[1,2]");
- QTest::ignoreMessage(QtDebugMsg, "Object");
- QTest::ignoreMessage(QtDebugMsg, "undefined");
- QTest::ignoreMessage(QtDebugMsg, "12");
- QTest::ignoreMessage(QtDebugMsg, "function () { return 5;}");
- QTest::ignoreMessage(QtDebugMsg, "true");
- QTest::ignoreMessage(QtDebugMsg, "Object");
- QTest::ignoreMessage(QtDebugMsg, "Object");
- QTest::ignoreMessage(QtDebugMsg, "1 pong! Object");
- QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] Object 2");
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeconsole::tracing()
-{
- QUrl testUrl = testFileUrl("tracing.qml");
-
- QString traceText =
- QString::fromLatin1("tracing (%1:%2:%3)\n").arg(testUrl.toString()).arg(50).arg(17) +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(9);
-
- QTest::ignoreMessage(QtDebugMsg, qPrintable(traceText));
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeconsole::profiling()
-{
- QUrl testUrl = testFileUrl("profiling.qml");
-
- // profiling()
- QTest::ignoreMessage(QtDebugMsg, "Profiling started.");
- QTest::ignoreMessage(QtDebugMsg, "Profiling ended.");
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeconsole::assert()
-{
- QUrl testUrl = testFileUrl("assert.qml");
-
- // assert()
- QString assert1 = "This will fail\n" +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(17);
-
- QString assert2 = "This will fail too\n" +
- QString::fromLatin1("assertFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(47).arg(17) +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(59).arg(9);
-
- QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert1));
- QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert2));
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeconsole::exception()
-{
- QUrl testUrl = testFileUrl("exception.qml");
-
- // exception()
- QString exception1 = "Exception 1\n" +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(51).arg(21);
-
- QString exception2 = "Exception 2\n" +
- QString::fromLatin1("exceptionFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(46).arg(17) +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(56).arg(9);
-
- QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception1));
- QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception2));
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativeconsole)
-
-#include "tst_qdeclarativeconsole.moc"
diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
deleted file mode 100644
index 3e1cc01e09..0000000000
--- a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativecontext
-SOURCES += tst_qdeclarativecontext.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib v8-private
diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
deleted file mode 100644
index 05db898045..0000000000
--- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
+++ /dev/null
@@ -1,652 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-#include <QDeclarativeComponent>
-#include <QDeclarativeExpression>
-#include <private/qdeclarativecontext_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativecontext : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativecontext() {}
-
-private slots:
- void baseUrl();
- void resolvedUrl();
- void engineMethod();
- void parentContext();
- void setContextProperty();
- void setContextObject();
- void destruction();
- void idAsContextProperty();
- void readOnlyContexts();
- void nameForObject();
-
- void refreshExpressions();
- void refreshExpressionsCrash();
- void refreshExpressionsRootContext();
-
- void qtbug_22535();
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativecontext::baseUrl()
-{
- QDeclarativeContext ctxt(&engine);
-
- QCOMPARE(ctxt.baseUrl(), QUrl());
-
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QCOMPARE(ctxt.baseUrl(), QUrl("http://www.nokia.com/"));
-}
-
-void tst_qdeclarativecontext::resolvedUrl()
-{
- // Relative to the component
- {
- QDeclarativeContext ctxt(&engine);
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), QUrl("http://www.nokia.com/main.qml"));
- }
-
- // Relative to a parent
- {
- QDeclarativeContext ctxt(&engine);
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QDeclarativeContext ctxt2(&ctxt);
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
- }
-
- // Relative to the engine
- {
- QDeclarativeContext ctxt(&engine);
- QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), engine.baseUrl().resolved(QUrl("main.qml")));
- }
-
- // Relative to a deleted parent
- {
- QDeclarativeContext *ctxt = new QDeclarativeContext(&engine);
- ctxt->setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QDeclarativeContext ctxt2(ctxt);
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
-
- delete ctxt; ctxt = 0;
-
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl());
- }
-
- // Absolute
- {
- QDeclarativeContext ctxt(&engine);
-
- QCOMPARE(ctxt.resolvedUrl(QUrl("http://www.nokia.com/main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
- QCOMPARE(ctxt.resolvedUrl(QUrl("file:///main2.qml")), QUrl("file:///main2.qml"));
- }
-}
-
-void tst_qdeclarativecontext::engineMethod()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
-
- QDeclarativeContext ctxt(engine);
- QDeclarativeContext ctxt2(&ctxt);
- QDeclarativeContext ctxt3(&ctxt2);
- QDeclarativeContext ctxt4(&ctxt2);
-
- QCOMPARE(ctxt.engine(), engine);
- QCOMPARE(ctxt2.engine(), engine);
- QCOMPARE(ctxt3.engine(), engine);
- QCOMPARE(ctxt4.engine(), engine);
-
- delete engine; engine = 0;
-
- QCOMPARE(ctxt.engine(), engine);
- QCOMPARE(ctxt2.engine(), engine);
- QCOMPARE(ctxt3.engine(), engine);
- QCOMPARE(ctxt4.engine(), engine);
-}
-
-void tst_qdeclarativecontext::parentContext()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
-
- QCOMPARE(engine->rootContext()->parentContext(), (QDeclarativeContext *)0);
-
- QDeclarativeContext *ctxt = new QDeclarativeContext(engine);
- QDeclarativeContext *ctxt2 = new QDeclarativeContext(ctxt);
- QDeclarativeContext *ctxt3 = new QDeclarativeContext(ctxt2);
- QDeclarativeContext *ctxt4 = new QDeclarativeContext(ctxt2);
- QDeclarativeContext *ctxt5 = new QDeclarativeContext(ctxt);
- QDeclarativeContext *ctxt6 = new QDeclarativeContext(engine);
- QDeclarativeContext *ctxt7 = new QDeclarativeContext(engine->rootContext());
-
- QCOMPARE(ctxt->parentContext(), engine->rootContext());
- QCOMPARE(ctxt2->parentContext(), ctxt);
- QCOMPARE(ctxt3->parentContext(), ctxt2);
- QCOMPARE(ctxt4->parentContext(), ctxt2);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), engine->rootContext());
- QCOMPARE(ctxt7->parentContext(), engine->rootContext());
-
- delete ctxt2; ctxt2 = 0;
-
- QCOMPARE(ctxt->parentContext(), engine->rootContext());
- QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), engine->rootContext());
- QCOMPARE(ctxt7->parentContext(), engine->rootContext());
-
- delete engine; engine = 0;
-
- QCOMPARE(ctxt->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt5->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt6->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt7->parentContext(), (QDeclarativeContext *)0);
-
- delete ctxt7;
- delete ctxt6;
- delete ctxt5;
- delete ctxt4;
- delete ctxt3;
- delete ctxt;
-}
-
-class TestObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int a READ a NOTIFY aChanged)
- Q_PROPERTY(int b READ b NOTIFY bChanged)
- Q_PROPERTY(int c READ c NOTIFY cChanged)
-
-public:
- TestObject() : _a(10), _b(10), _c(10) {}
-
- int a() const { return _a; }
- void setA(int a) { _a = a; emit aChanged(); }
-
- int b() const { return _b; }
- void setB(int b) { _b = b; emit bChanged(); }
-
- int c() const { return _c; }
- void setC(int c) { _c = c; emit cChanged(); }
-
-signals:
- void aChanged();
- void bChanged();
- void cChanged();
-
-private:
- int _a;
- int _b;
- int _c;
-};
-
-#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
-{ \
- QDeclarativeComponent component(&engine); \
- component.setData("import QtQuick 2.0; QtObject { property variant test: " #name " }", QUrl()); \
-\
- QObject *obj = component.create(ctxt); \
-\
- QCOMPARE(obj->property("test"), value); \
-\
- delete obj; \
-}
-
-void tst_qdeclarativecontext::setContextProperty()
-{
- QDeclarativeContext ctxt(&engine);
- QDeclarativeContext ctxt2(&ctxt);
-
- TestObject obj1;
- obj1.setA(3345);
- TestObject obj2;
- obj2.setA(-19);
-
- // Static context properties
- ctxt.setContextProperty("a", QVariant(10));
- ctxt.setContextProperty("b", QVariant(9));
- ctxt2.setContextProperty("d", &obj2);
- ctxt2.setContextProperty("b", QVariant(19));
- ctxt2.setContextProperty("c", QVariant(QString("Hello World!")));
- ctxt.setContextProperty("d", &obj1);
- ctxt.setContextProperty("e", &obj1);
-
- TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(10));
- TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(19));
- TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hello World!")));
- TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(-19));
- TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(3345));
-
- ctxt.setContextProperty("a", QVariant(13));
- ctxt.setContextProperty("b", QVariant(4));
- ctxt2.setContextProperty("b", QVariant(8));
- ctxt2.setContextProperty("c", QVariant(QString("Hi World!")));
- ctxt2.setContextProperty("d", &obj1);
- obj1.setA(12);
-
- TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(13));
- TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(8));
- TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hi World!")));
- TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(12));
- TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(12));
-
- // Changes in context properties
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(13));
- ctxt.setContextProperty("a", QVariant(19));
- QCOMPARE(obj->property("test"), QVariant(19));
-
- delete obj;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: b }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(8));
- ctxt.setContextProperty("b", QVariant(5));
- QCOMPARE(obj->property("test"), QVariant(8));
- ctxt2.setContextProperty("b", QVariant(1912));
- QCOMPARE(obj->property("test"), QVariant(1912));
-
- delete obj;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: e.a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(12));
- obj1.setA(13);
- QCOMPARE(obj->property("test"), QVariant(13));
-
- delete obj;
- }
-
- // New context properties
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(19));
- ctxt2.setContextProperty("a", QVariant(1945));
- QCOMPARE(obj->property("test"), QVariant(1945));
-
- delete obj;
- }
-
- // Setting an object-variant context property
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property variant obj: root; }", QUrl());
-
- QDeclarativeContext ctxt(engine.rootContext());
- ctxt.setContextProperty("ctxtProp", QVariant());
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Cannot read property 'a' of undefined");
- QObject *obj = component.create(&ctxt);
-
- QVariant v = obj->property("obj");
-
- ctxt.setContextProperty("ctxtProp", v);
-
- QCOMPARE(obj->property("test"), QVariant(10));
-
- delete obj;
- }
-}
-
-void tst_qdeclarativecontext::setContextObject()
-{
- QDeclarativeContext ctxt(&engine);
-
- TestObject to;
-
- to.setA(2);
- to.setB(192);
- to.setC(18);
-
- ctxt.setContextObject(&to);
- ctxt.setContextProperty("c", QVariant(9));
-
- // Static context properties
- TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2));
- TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(192));
- TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9));
-
- to.setA(12);
- to.setB(100);
- to.setC(7);
- ctxt.setContextProperty("c", QVariant(3));
-
- TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12));
- TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(100));
- TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3));
-
- // Changes in context properties
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt);
-
- QCOMPARE(obj->property("test"), QVariant(12));
- to.setA(14);
- QCOMPARE(obj->property("test"), QVariant(14));
-
- delete obj;
- }
-}
-
-void tst_qdeclarativecontext::destruction()
-{
- QDeclarativeContext *ctxt = new QDeclarativeContext(&engine);
-
- QObject obj;
- QDeclarativeEngine::setContextForObject(&obj, ctxt);
- QDeclarativeExpression expr(ctxt, 0, "a");
-
- QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj));
- QCOMPARE(ctxt, expr.context());
-
- delete ctxt; ctxt = 0;
-
- QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj));
- QCOMPARE(ctxt, expr.context());
-}
-
-void tst_qdeclarativecontext::idAsContextProperty()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant a; a: QtObject { id: myObject } }", QUrl());
-
- QObject *obj = component.create();
- QVERIFY(obj);
-
- QVariant a = obj->property("a");
- QVERIFY(a.userType() == QMetaType::QObjectStar);
-
- QVariant ctxt = qmlContext(obj)->contextProperty("myObject");
- QVERIFY(ctxt.userType() == QMetaType::QObjectStar);
-
- QVERIFY(a == ctxt);
-
- delete obj;
-}
-
-// Internal contexts should be read-only
-void tst_qdeclarativecontext::readOnlyContexts()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { id: me }", QUrl());
-
- QObject *obj = component.create();
- QVERIFY(obj);
-
- QDeclarativeContext *context = qmlContext(obj);
- QVERIFY(context);
-
- QVERIFY(qvariant_cast<QObject*>(context->contextProperty("me")) == obj);
- QVERIFY(context->contextObject() == obj);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set property on internal context.");
- context->setContextProperty("hello", 12);
- QVERIFY(context->contextProperty("hello") == QVariant());
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set property on internal context.");
- context->setContextProperty("hello", obj);
- QVERIFY(context->contextProperty("hello") == QVariant());
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set context object for internal context.");
- context->setContextObject(0);
- QVERIFY(context->contextObject() == obj);
-
- delete obj;
-}
-
-void tst_qdeclarativecontext::nameForObject()
-{
- QObject o1;
- QObject o2;
- QObject o3;
-
- QDeclarativeEngine engine;
-
- // As a context property
- engine.rootContext()->setContextProperty("o1", &o1);
- engine.rootContext()->setContextProperty("o2", &o2);
- engine.rootContext()->setContextProperty("o1_2", &o1);
-
- QCOMPARE(engine.rootContext()->nameForObject(&o1), QString("o1"));
- QCOMPARE(engine.rootContext()->nameForObject(&o2), QString("o2"));
- QCOMPARE(engine.rootContext()->nameForObject(&o3), QString());
-
- // As an id
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { id: root; property QtObject o: QtObject { id: nested } }", QUrl());
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(qmlContext(o)->nameForObject(o), QString("root"));
- QCOMPARE(qmlContext(o)->nameForObject(qvariant_cast<QObject*>(o->property("o"))), QString("nested"));
- QCOMPARE(qmlContext(o)->nameForObject(&o1), QString());
-
- delete o;
-}
-
-class DeleteCommand : public QObject
-{
-Q_OBJECT
-public:
- DeleteCommand() : object(0) {}
-
- QObject *object;
-
-public slots:
- void doCommand() { if (object) delete object; object = 0; }
-};
-
-// Calling refresh expressions would crash if an expression or context was deleted during
-// the refreshing
-void tst_qdeclarativecontext::refreshExpressionsCrash()
-{
- {
- QDeclarativeEngine engine;
-
- DeleteCommand command;
- engine.rootContext()->setContextProperty("deleteCommand", &command);
- // We use a fresh context here to bypass any root-context optimizations in
- // the engine
- QDeclarativeContext ctxt(engine.rootContext());
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl());
- QVERIFY(component.isReady());
-
- QObject *o1 = component.create(&ctxt);
- QObject *o2 = component.create(&ctxt);
-
- command.object = o2;
-
- QDeclarativeContextData::get(&ctxt)->refreshExpressions();
-
- delete o1;
- }
- {
- QDeclarativeEngine engine;
-
- DeleteCommand command;
- engine.rootContext()->setContextProperty("deleteCommand", &command);
- // We use a fresh context here to bypass any root-context optimizations in
- // the engine
- QDeclarativeContext ctxt(engine.rootContext());
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl());
- QVERIFY(component.isReady());
-
- QObject *o1 = component.create(&ctxt);
- QObject *o2 = component.create(&ctxt);
-
- command.object = o1;
-
- QDeclarativeContextData::get(&ctxt)->refreshExpressions();
-
- delete o2;
- }
-}
-
-class CountCommand : public QObject
-{
-Q_OBJECT
-public:
- CountCommand() : count(0) {}
-
- int count;
-
-public slots:
- void doCommand() { ++count; }
-};
-
-
-// Test that calling refresh expressions causes all the expressions to refresh
-void tst_qdeclarativecontext::refreshExpressions()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("refreshExpressions.qml"));
- QDeclarativeComponent component2(&engine, testFileUrl("RefreshExpressionsType.qml"));
-
- CountCommand command;
- engine.rootContext()->setContextProperty("countCommand", &command);
-
- // We use a fresh context here to bypass any root-context optimizations in
- // the engine
- QDeclarativeContext context(engine.rootContext());
- QDeclarativeContext context2(&context);
-
- QObject *o1 = component.create(&context);
- QObject *o2 = component.create(&context2);
- QObject *o3 = component2.create(&context);
-
- QCOMPARE(command.count, 5);
-
- QDeclarativeContextData::get(&context)->refreshExpressions();
-
- QCOMPARE(command.count, 10);
-
- delete o3;
- delete o2;
- delete o1;
-}
-
-// Test that updating the root context, only causes expressions in contexts with an
-// unresolved name to reevaluate
-void tst_qdeclarativecontext::refreshExpressionsRootContext()
-{
- QDeclarativeEngine engine;
-
- CountCommand command;
- engine.rootContext()->setContextProperty("countCommand", &command);
-
- QDeclarativeComponent component(&engine, testFileUrl("refreshExpressions.qml"));
- QDeclarativeComponent component2(&engine, testFileUrl("refreshExpressionsRootContext.qml"));
-
- QDeclarativeContext context(engine.rootContext());
- QDeclarativeContext context2(engine.rootContext());
-
- QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: Can't find variable: unresolvedName");
-
- QObject *o1 = component.create(&context);
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QObject *o2 = component2.create(&context2);
-
- QCOMPARE(command.count, 3);
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QDeclarativeContextData::get(engine.rootContext())->refreshExpressions();
-
- QCOMPARE(command.count, 4);
-
- delete o2;
- delete o1;
-}
-
-void tst_qdeclarativecontext::qtbug_22535()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_22535.qml"));
- QDeclarativeContext context(engine.rootContext());
-
- QObject *o = component.create(&context);
-
- // Don't crash!
- delete o;
-}
-
-QTEST_MAIN(tst_qdeclarativecontext)
-
-#include "tst_qdeclarativecontext.moc"
diff --git a/tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro b/tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro
deleted file mode 100644
index 3cae5c25f3..0000000000
--- a/tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativecpputils
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativecpputils.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp b/tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp
deleted file mode 100644
index dbd877b2d5..0000000000
--- a/tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <qsignalspy.h>
-#include <private/qdeclarativeglobal_p.h>
-
-class tst_qdeclarativecpputils : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativecpputils() {}
-
-private slots:
- void fastConnect();
-};
-
-class MyObject : public QObject {
- Q_OBJECT
-public:
- MyObject() : slotCount(0) {}
- friend class tst_qdeclarativecpputils;
-
- int slotCount;
-
-signals:
- void signal1();
- void signal2();
-
-public slots:
- void slot1() { slotCount++; }
-};
-
-void tst_qdeclarativecpputils::fastConnect()
-{
- {
- MyObject *obj = new MyObject;
- FAST_CONNECT(obj, SIGNAL(signal1()), obj, SLOT(slot1()));
-
- obj->signal1();
- QCOMPARE(obj->slotCount, 1);
-
- delete obj;
- }
-
- {
- MyObject obj;
- FAST_CONNECT(&obj, SIGNAL(signal1()), &obj, SLOT(slot1()))
-
- obj.signal1();
- QCOMPARE(obj.slotCount, 1);
- }
-
- {
- MyObject *obj = new MyObject;
- QSignalSpy spy(obj, SIGNAL(signal2()));
- FAST_CONNECT(obj, SIGNAL(signal1()), obj, SIGNAL(signal2()));
-
- obj->signal1();
- QCOMPARE(spy.count(), 1);
-
- delete obj;
- }
-}
-
-QTEST_MAIN(tst_qdeclarativecpputils)
-
-#include "tst_qdeclarativecpputils.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml
deleted file mode 100644
index 7b4463773c..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 2.0
-import Qt.test 1.0
-
-// In this example, a common syntax error will only be "caught"
-// when the function is called via:
-// QDeclarativeVMEMetaObject::metaCall->invokeMetaMethod()
-// We would like to ensure that a useful error message is printed.
-
-QtObject {
- id: root
- property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider }
- property var scarceResourceCopy;
- property string srp_name: a.toString();
-
- function retrieveScarceResource() {
- root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception
- }
-
- function releaseScarceResource() {
- root.scarceResourceCopy = null;
- }
-}
-
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml
deleted file mode 100644
index 45acc53e63..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 2.0
-import Qt.test 1.0
-
-// In this example, a common syntax error will only be "caught"
-// when the function is called via:
-// QDeclarativeVMEMetaObject::metaCall->invokeMetaMethod()
-// We would like to ensure that a useful error message is printed.
-
-QtObject {
- id: root
- property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider }
- property variant scarceResourceCopy;
- property string srp_name: a.toString();
-
- function retrieveScarceResource() {
- root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception
- }
-
- function releaseScarceResource() {
- root.scarceResourceCopy = null;
- }
-}
-
diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
deleted file mode 100644
index f4c2638f95..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeecmascript
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeecmascript.cpp \
- testtypes.cpp \
- ../../shared/testhttpserver.cpp
-HEADERS += testtypes.h \
- ../../shared/testhttpserver.h
-INCLUDEPATH += ../../shared
-
-include (../../shared/util.pri)
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private network widgets testlib
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
deleted file mode 100644
index c8f50535ef..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-#include <QWidget>
-#include <QPlainTextEdit>
-#include <QDeclarativeEngine>
-#include <QJSEngine>
-
-class BaseExtensionObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged)
-public:
- BaseExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
-
- int extendedProperty() const { return m_value; }
- void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
-
-signals:
- void extendedPropertyChanged();
-private:
- int m_value;
-};
-
-class ExtensionObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged)
-public:
- ExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
-
- int extendedProperty() const { return m_value; }
- void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
-
-signals:
- void extendedPropertyChanged();
-private:
- int m_value;
-};
-
-class DefaultPropertyExtensionObject : public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("DefaultProperty", "firstProperty")
-public:
- DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {}
-};
-
-class QWidgetDeclarativeUI : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
-
-signals:
- void widthChanged();
-
-public:
- QWidgetDeclarativeUI(QObject *other) : QObject(other) { }
-
-public:
- int width() const { return 0; }
- void setWidth(int) { }
-};
-
-void MyQmlObject::v8function(QDeclarativeV8Function *args)
-{
- const char *error = "Exception thrown from within QObject slot";
- v8::ThrowException(v8::Exception::Error(v8::String::New(error)));
-}
-
-static QJSValue script_api(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
-
- static int testProperty = 13;
- QJSValue v = scriptEngine->newObject();
- v.setProperty("scriptTestProperty", testProperty++);
- return v;
-}
-
-static QJSValue readonly_script_api(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
-
- static int testProperty = 42;
- QJSValue v = scriptEngine->newObject();
- v.setProperty("scriptTestProperty", testProperty++);
-
- // now freeze it so that it's read-only
- QJSValue freezeFunction = scriptEngine->evaluate("(function(obj) { return Object.freeze(obj); })");
- v = freezeFunction.call(QJSValueList() << v);
-
- return v;
-}
-
-static QObject *qobject_api(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
-
- testQObjectApi *o = new testQObjectApi();
- o->setQObjectTestProperty(20);
- o->setQObjectTestWritableProperty(50);
- return o;
-}
-
-static QObject *qobject_api_engine_parent(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(scriptEngine)
-
- static int testProperty = 26;
- testQObjectApi *o = new testQObjectApi(engine);
- o->setQObjectTestProperty(testProperty++);
- return o;
-}
-
-void registerTypes()
-{
- qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias");
- qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
- qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject");
- qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer");
- qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject");
- qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject");
- qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject");
- qmlRegisterType<MyDerivedObject>("Qt.test", 1,0, "MyDerivedObject");
- qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
- qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject");
- qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject");
- qmlRegisterType<MyRevisionedClass>("Qt.test",1,0,"MyRevisionedClass");
- qmlRegisterType<MyDeleteObject>("Qt.test", 1,0, "MyDeleteObject");
- qmlRegisterType<MyRevisionedClass,1>("Qt.test",1,1,"MyRevisionedClass");
-
- // test scarce resource property binding post-evaluation optimisation
- // and for testing memory usage in property var circular reference test
- qmlRegisterType<ScarceResourceObject>("Qt.test", 1,0, "MyScarceResourceObject");
-
- // Register the uncreatable base class
- qmlRegisterRevision<MyRevisionedBaseClassRegistered,1>("Qt.test",1,1);
- // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
- qmlRegisterType<MyRevisionedSubclass>("Qt.test",1,0,"MyRevisionedSubclass");
- // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
- qmlRegisterType<MyRevisionedSubclass,1>("Qt.test",1,1,"MyRevisionedSubclass");
-
- qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget");
- qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
-
- qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
-
- qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements
- qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace!
- qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi("Qt.test.scriptApi",2,0,readonly_script_api); // register (script) module API for a uri which doesn't contain elements - will be made read-only
- qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set
- qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
- qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
-
- qRegisterMetaType<MyQmlObject::MyType>("MyEnum2");
- qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
-
- qmlRegisterType<CircularReferenceObject>("Qt.test", 1, 0, "CircularReferenceObject");
- qmlRegisterType<CircularReferenceHandle>("Qt.test", 1, 0, "CircularReferenceHandle");
-
- qmlRegisterType<MyDynamicCreationDestructionObject>("Qt.test", 1, 0, "MyDynamicCreationDestructionObject");
- qmlRegisterType<WriteCounter>("Qt.test", 1, 0, "WriteCounter");
-
- qmlRegisterType<MySequenceConversionObject>("Qt.test", 1, 0, "MySequenceConversionObject");
-}
-
-#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
deleted file mode 100644
index ce8e80e81b..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ /dev/null
@@ -1,1313 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtDeclarative/qdeclarativelist.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/QPixmap>
-#include <QtCore/qdatetime.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-
-#include <private/qdeclarativeengine_p.h>
-#include <private/qv8engine_p.h>
-
-class MyQmlAttachedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value CONSTANT)
- Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
-public:
- MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
-
- int value() const { return 19; }
- int value2() const { return m_value2; }
- void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
-
- void emitMySignal() { emit mySignal(); }
-
-signals:
- void value2Changed();
- void mySignal();
-
-private:
- int m_value2;
-};
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_ENUMS(MyEnum2)
- Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
- Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
- Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int console READ console CONSTANT)
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
- Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlChanged)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
- Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
- Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
- Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false)
- Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged)
-
-public:
- MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0) {}
-
- enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
- enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
-
- bool trueProperty() const { return true; }
- bool falseProperty() const { return false; }
-
- QString stringProperty() const { return m_string; }
- void setStringProperty(const QString &s)
- {
- if (s == m_string)
- return;
- m_string = s;
- emit stringChanged();
- }
-
- QUrl urlProperty() const { return m_url; }
- void setUrlProperty(const QUrl &url)
- {
- if (url == m_url)
- return;
- m_url = url;
- emit urlChanged();
- }
-
- QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) {
- if (obj == m_object)
- return;
- m_object = obj;
- emit objectChanged();
- }
-
- QDeclarativeListProperty<QObject> objectListProperty() { return QDeclarativeListProperty<QObject>(this, m_objectQList); }
-
- bool methodCalled() const { return m_methodCalled; }
- bool methodIntCalled() const { return m_methodIntCalled; }
-
- QString string() const { return m_string; }
-
- static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
- return new MyQmlAttachedObject(o);
- }
-
- int deleteOnSet() const { return 1; }
- void setDeleteOnSet(int v) { if(v) delete this; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
- int resettableProperty() const { return m_resetProperty; }
- void setResettableProperty(int v) { m_resetProperty = v; }
- void resetProperty() { m_resetProperty = 13; }
-
- QRegExp regExp() { return m_regExp; }
- void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
-
- int console() const { return 11; }
-
- int nonscriptable() const { return 0; }
- void setNonscriptable(int) {}
-
- MyQmlObject *myinvokableObject;
- Q_INVOKABLE MyQmlObject *returnme() { return this; }
-
- struct MyType {
- int value;
- };
- QVariant variant() const { return m_variant; }
- QJSValue qjsvalue() const { return m_qjsvalue; }
-
- int intProperty() const { return m_intProperty; }
- void setIntProperty(int i) { m_intProperty = i; emit intChanged(); }
-
-signals:
- void basicSignal();
- void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
- void unnamedArgumentSignal(int a, qreal, QString c);
- void stringChanged();
- void urlChanged();
- void objectChanged();
- void anotherBasicSignal();
- void thirdBasicSignal();
- void signalWithUnknownType(const MyQmlObject::MyType &arg);
- void signalWithVariant(const QVariant &arg);
- void signalWithQJSValue(const QJSValue &arg);
- void signalWithGlobalName(int parseInt);
- void intChanged();
-
-public slots:
- void deleteMe() { delete this; }
- void methodNoArgs() { m_methodCalled = true; }
- void method(int a) { if(a == 163) m_methodIntCalled = true; }
- void setString(const QString &s) { m_string = s; }
- void myinvokable(MyQmlObject *o) { myinvokableObject = o; }
- void variantMethod(const QVariant &v) { m_variant = v; }
- void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; }
- void v8function(QDeclarativeV8Function*);
-
-private:
- friend class tst_qdeclarativeecmascript;
- bool m_methodCalled;
- bool m_methodIntCalled;
-
- QObject *m_object;
- QString m_string;
- QUrl m_url;
- QList<QObject *> m_objectQList;
- int m_value;
- int m_resetProperty;
- QRegExp m_regExp;
- QVariant m_variant;
- QJSValue m_qjsvalue;
- int m_intProperty;
-};
-
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-
-class MyQmlContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<MyQmlObject> children READ children CONSTANT)
-public:
- MyQmlContainer() {}
-
- QDeclarativeListProperty<MyQmlObject> children() { return QDeclarativeListProperty<MyQmlObject>(this, m_children); }
-
-private:
- QList<MyQmlObject*> m_children;
-};
-
-
-class MyExpression : public QDeclarativeExpression
-{
- Q_OBJECT
-public:
- MyExpression(QDeclarativeContext *ctxt, const QString &expr)
- : QDeclarativeExpression(ctxt, 0, expr), changed(false)
- {
- QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged()));
- setNotifyOnValueChanged(true);
- }
-
- bool changed;
-
-public slots:
- void expressionValueChanged() {
- changed = true;
- }
-};
-
-
-class MyDefaultObject1 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int horseLegs READ horseLegs CONSTANT)
- Q_PROPERTY(int antLegs READ antLegs CONSTANT)
- Q_PROPERTY(int emuLegs READ emuLegs CONSTANT)
-public:
- int horseLegs() const { return 4; }
- int antLegs() const { return 6; }
- int emuLegs() const { return 2; }
-};
-
-class MyDefaultObject3 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int antLegs READ antLegs CONSTANT)
- Q_PROPERTY(int humanLegs READ humanLegs CONSTANT)
-public:
- int antLegs() const { return 7; } // Mutant
- int humanLegs() const { return 2; }
- int millipedeLegs() const { return 1000; }
-};
-
-class MyDeferredObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
- Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2)
- Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2")
-
-public:
- MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; emit valueChanged(); }
-
- QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) { m_object = obj; }
-
- QObject *objectProperty2() const { return m_object2; }
- void setObjectProperty2(QObject *obj) { m_object2 = obj; }
-
-signals:
- void valueChanged();
-
-private:
- int m_value;
- QObject *m_object;
- QObject *m_object2;
-};
-
-class MyBaseExtendedObject : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
-public:
- MyBaseExtendedObject() : m_value(0) {}
-
- int baseProperty() const { return m_value; }
- void setBaseProperty(int v) { m_value = v; }
-
-private:
- int m_value;
-};
-
-class MyExtendedObject : public MyBaseExtendedObject
-{
-Q_OBJECT
-Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty)
-public:
- MyExtendedObject() : m_value(0) {}
-
- int coreProperty() const { return m_value; }
- void setCoreProperty(int v) { m_value = v; }
-
-private:
- int m_value;
-};
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_FLAGS(MyFlags)
-
- Q_PROPERTY(QString id READ id WRITE setId)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
- Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty)
- Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
- Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
- Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
- Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
- Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
- Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
- Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
- Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
- Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
- Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
- Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
- Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
- Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
- Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
- Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
- Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
- Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
- Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
- Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
- Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
- Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
- Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
-
- Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
-
-public:
- MyTypeObject()
- : objectPropertyValue(0), componentPropertyValue(0) {}
-
- QString idValue;
- QString id() const {
- return idValue;
- }
- void setId(const QString &v) {
- idValue = v;
- }
-
- QObject *objectPropertyValue;
- QObject *objectProperty() const {
- return objectPropertyValue;
- }
- void setObjectProperty(QObject *v) {
- objectPropertyValue = v;
- }
-
- QDeclarativeComponent *componentPropertyValue;
- QDeclarativeComponent *componentProperty() const {
- return componentPropertyValue;
- }
- void setComponentProperty(QDeclarativeComponent *v) {
- componentPropertyValue = v;
- }
-
- enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
- Q_DECLARE_FLAGS(MyFlags, MyFlag)
- MyFlags flagPropertyValue;
- MyFlags flagProperty() const {
- return flagPropertyValue;
- }
- void setFlagProperty(MyFlags v) {
- flagPropertyValue = v;
- }
-
- enum MyEnum { EnumVal1, EnumVal2 };
- MyEnum enumPropertyValue;
- MyEnum enumProperty() const {
- return enumPropertyValue;
- }
- void setEnumProperty(MyEnum v) {
- enumPropertyValue = v;
- }
-
- QString stringPropertyValue;
- QString stringProperty() const {
- return stringPropertyValue;
- }
- void setStringProperty(const QString &v) {
- stringPropertyValue = v;
- }
-
- uint uintPropertyValue;
- uint uintProperty() const {
- return uintPropertyValue;
- }
- void setUintProperty(const uint &v) {
- uintPropertyValue = v;
- }
-
- int intPropertyValue;
- int intProperty() const {
- return intPropertyValue;
- }
- void setIntProperty(const int &v) {
- intPropertyValue = v;
- }
-
- qreal realPropertyValue;
- qreal realProperty() const {
- return realPropertyValue;
- }
- void setRealProperty(const qreal &v) {
- realPropertyValue = v;
- }
-
- double doublePropertyValue;
- double doubleProperty() const {
- return doublePropertyValue;
- }
- void setDoubleProperty(const double &v) {
- doublePropertyValue = v;
- }
-
- float floatPropertyValue;
- float floatProperty() const {
- return floatPropertyValue;
- }
- void setFloatProperty(const float &v) {
- floatPropertyValue = v;
- }
-
- QColor colorPropertyValue;
- QColor colorProperty() const {
- return colorPropertyValue;
- }
- void setColorProperty(const QColor &v) {
- colorPropertyValue = v;
- }
-
- QDate datePropertyValue;
- QDate dateProperty() const {
- return datePropertyValue;
- }
- void setDateProperty(const QDate &v) {
- datePropertyValue = v;
- }
-
- QTime timePropertyValue;
- QTime timeProperty() const {
- return timePropertyValue;
- }
- void setTimeProperty(const QTime &v) {
- timePropertyValue = v;
- }
-
- QDateTime dateTimePropertyValue;
- QDateTime dateTimeProperty() const {
- return dateTimePropertyValue;
- }
- void setDateTimeProperty(const QDateTime &v) {
- dateTimePropertyValue = v;
- }
-
- QPoint pointPropertyValue;
- QPoint pointProperty() const {
- return pointPropertyValue;
- }
- void setPointProperty(const QPoint &v) {
- pointPropertyValue = v;
- }
-
- QPointF pointFPropertyValue;
- QPointF pointFProperty() const {
- return pointFPropertyValue;
- }
- void setPointFProperty(const QPointF &v) {
- pointFPropertyValue = v;
- }
-
- QSize sizePropertyValue;
- QSize sizeProperty() const {
- return sizePropertyValue;
- }
- void setSizeProperty(const QSize &v) {
- sizePropertyValue = v;
- }
-
- QSizeF sizeFPropertyValue;
- QSizeF sizeFProperty() const {
- return sizeFPropertyValue;
- }
- void setSizeFProperty(const QSizeF &v) {
- sizeFPropertyValue = v;
- }
-
- QRect rectPropertyValue;
- QRect rectProperty() const {
- return rectPropertyValue;
- }
- void setRectProperty(const QRect &v) {
- rectPropertyValue = v;
- emit rectPropertyChanged();
- }
-
- QRect rectPropertyValue2;
- QRect rectProperty2() const {
- return rectPropertyValue2;
- }
- void setRectProperty2(const QRect &v) {
- rectPropertyValue2 = v;
- }
-
- QRectF rectFPropertyValue;
- QRectF rectFProperty() const {
- return rectFPropertyValue;
- }
- void setRectFProperty(const QRectF &v) {
- rectFPropertyValue = v;
- }
-
- bool boolPropertyValue;
- bool boolProperty() const {
- return boolPropertyValue;
- }
- void setBoolProperty(const bool &v) {
- boolPropertyValue = v;
- }
-
- QVariant variantPropertyValue;
- QVariant variantProperty() const {
- return variantPropertyValue;
- }
- void setVariantProperty(const QVariant &v) {
- variantPropertyValue = v;
- }
-
- QVector3D vectorPropertyValue;
- QVector3D vectorProperty() const {
- return vectorPropertyValue;
- }
- void setVectorProperty(const QVector3D &v) {
- vectorPropertyValue = v;
- }
-
- QUrl urlPropertyValue;
- QUrl urlProperty() const {
- return urlPropertyValue;
- }
- void setUrlProperty(const QUrl &v) {
- urlPropertyValue = v;
- }
-
- QDeclarativeScriptString scriptPropertyValue;
- QDeclarativeScriptString scriptProperty() const {
- return scriptPropertyValue;
- }
- void setScriptProperty(const QDeclarativeScriptString &v) {
- scriptPropertyValue = v;
- }
-
- void doAction() { emit action(); }
-signals:
- void action();
- void rectPropertyChanged();
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
-
-class MyDerivedObject : public MyTypeObject
-{
- Q_OBJECT
-public:
- Q_INVOKABLE bool intProperty() const {
- return true;
- }
-};
-
-Q_DECLARE_METATYPE(QJSValue);
-class MyInvokableBaseObject : public QObject
-{
- Q_OBJECT
-public:
- inline ~MyInvokableBaseObject() = 0;
-
- Q_INVOKABLE inline void method_inherited(int a);
- Q_INVOKABLE inline void method_overload();
-};
-
-class MyInvokableObject : public MyInvokableBaseObject
-{
- Q_OBJECT
- Q_ENUMS(TestEnum)
-public:
- enum TestEnum { EnumValue1, EnumValue2 };
- MyInvokableObject() { reset(); }
-
- int invoked() const { return m_invoked; }
- bool error() const { return m_invokedError; }
- const QVariantList &actuals() const { return m_actuals; }
- void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
-
- Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
- Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
-
- 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.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; }
- Q_INVOKABLE QJSValue method_NoArgs_QScriptValue() { invoke(6); return QJSValue("Hello world"); }
- Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
-
- Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
- Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
- Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
- Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
- Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
- Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
- Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
- Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
-
- Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
- Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
- Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; }
-
- Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(19); m_actuals << (int)e; }
-
- Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; }
-
- Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; }
-
-private:
- friend class MyInvokableBaseObject;
- void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
- int m_invoked;
- bool m_invokedError;
- QVariantList m_actuals;
-};
-
-MyInvokableBaseObject::~MyInvokableBaseObject() {}
-
-void MyInvokableBaseObject::method_inherited(int a)
-{
- static_cast<MyInvokableObject *>(this)->invoke(-3);
- static_cast<MyInvokableObject *>(this)->m_actuals << a;
-}
-
-// This is a hidden overload of the MyInvokableObject::method_overload() method
-void MyInvokableBaseObject::method_overload()
-{
- static_cast<MyInvokableObject *>(this)->invoke(-2);
-}
-
-class NumberAssignment : public QObject
-{
- Q_OBJECT
-public:
- Q_PROPERTY(qreal test1 READ test1 WRITE setTest1)
- qreal _test1;
- qreal test1() const { return _test1; }
- void setTest1(qreal v) { _test1 = v; }
-
- Q_PROPERTY(qreal test2 READ test2 WRITE setTest2)
- qreal _test2;
- qreal test2() const { return _test2; }
- void setTest2(qreal v) { _test2 = v; }
-
- Q_PROPERTY(qreal test3 READ test3 WRITE setTest3)
- qreal _test3;
- qreal test3() const { return _test3; }
- void setTest3(qreal v) { _test3 = v; }
-
- Q_PROPERTY(qreal test4 READ test4 WRITE setTest4)
- qreal _test4;
- qreal test4() const { return _test4; }
- void setTest4(qreal v) { _test4 = v; }
-
- Q_PROPERTY(int test5 READ test5 WRITE setTest5)
- int _test5;
- int test5() const { return _test5; }
- void setTest5(int v) { _test5 = v; }
-
- Q_PROPERTY(int test6 READ test6 WRITE setTest6)
- int _test6;
- int test6() const { return _test6; }
- void setTest6(int v) { _test6 = v; }
-
- Q_PROPERTY(int test7 READ test7 WRITE setTest7)
- int _test7;
- int test7() const { return _test7; }
- void setTest7(int v) { _test7 = v; }
-
- Q_PROPERTY(int test8 READ test8 WRITE setTest8)
- int _test8;
- int test8() const { return _test8; }
- void setTest8(int v) { _test8 = v; }
-
- Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9)
- unsigned int _test9;
- unsigned int test9() const { return _test9; }
- void setTest9(unsigned int v) { _test9 = v; }
-
- Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10)
- unsigned int _test10;
- unsigned int test10() const { return _test10; }
- void setTest10(unsigned int v) { _test10 = v; }
-
- Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11)
- unsigned int _test11;
- unsigned int test11() const { return _test11; }
- void setTest11(unsigned int v) { _test11 = v; }
-
- Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12)
- unsigned int _test12;
- unsigned int test12() const { return _test12; }
- void setTest12(unsigned int v) { _test12 = v; }
-};
-
-class DefaultPropertyExtendedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty)
- Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty)
-public:
- DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {}
-
- QObject *firstProperty() const { return m_firstProperty; }
- QObject *secondProperty() const { return m_secondProperty; }
- void setFirstProperty(QObject *property) { m_firstProperty = property; }
- void setSecondProperty(QObject *property) { m_secondProperty = property; }
-private:
- QObject* m_firstProperty;
- QObject* m_secondProperty;
-};
-
-class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject
-{
- Q_OBJECT
- Q_CLASSINFO("DefaultProperty", "secondProperty")
-public:
- OverrideDefaultPropertyObject() {}
-};
-
-class MyRevisionedBaseClassRegistered : public QObject
-{
-Q_OBJECT
- Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
- Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
-
-public:
- MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
-
- qreal propA() const { return m_pa; }
- void setPropA(qreal p) {
- if (p != m_pa) {
- m_pa = p;
- emit propAChanged();
- }
- }
- qreal propB() const { return m_pb; }
- void setPropB(qreal p) {
- if (p != m_pb) {
- m_pb = p;
- emit propBChanged();
- }
- }
-
- Q_INVOKABLE void methodA() { }
- Q_INVOKABLE Q_REVISION(1) void methodB() { }
-
-signals:
- void propAChanged();
- void propBChanged();
-
- void signalA();
- Q_REVISION(1) void signalB();
-
-protected:
- qreal m_pa;
- qreal m_pb;
-};
-
-class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
-{
-Q_OBJECT
- Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
- Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
-
-public:
- MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
-
- qreal propC() const { return m_pc; }
- void setPropC(qreal p) {
- if (p != m_pc) {
- m_pc = p;
- emit propCChanged();
- }
- }
- qreal propD() const { return m_pd; }
- void setPropD(qreal p) {
- if (p != m_pd) {
- m_pd = p;
- emit propDChanged();
- }
- }
-
- Q_INVOKABLE void methodC() { }
- Q_INVOKABLE Q_REVISION(1) void methodD() { }
-
-signals:
- void propCChanged();
- void propDChanged();
-
- void signalC();
- Q_REVISION(1) void signalD();
-
-protected:
- qreal m_pc;
- qreal m_pd;
-};
-
-class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
- Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
-
-public:
- MyRevisionedClass() {}
-
- qreal prop1() const { return m_p1; }
- void setProp1(qreal p) {
- if (p != m_p1) {
- m_p1 = p;
- emit prop1Changed();
- }
- }
- qreal prop2() const { return m_p2; }
- void setProp2(qreal p) {
- if (p != m_p2) {
- m_p2 = p;
- emit prop2Changed();
- }
- }
-
- Q_INVOKABLE void method1() { }
- Q_INVOKABLE Q_REVISION(1) void method2() { }
-
-signals:
- void prop1Changed();
- void prop2Changed();
-
- void signal1();
- Q_REVISION(1) void signal2();
-
-protected:
- qreal m_p1;
- qreal m_p2;
-};
-
-class MyRevisionedSubclass : public MyRevisionedClass
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
- Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
-
-public:
- MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
-
- qreal prop3() const { return m_p3; }
- void setProp3(qreal p) {
- if (p != m_p3) {
- m_p3 = p;
- emit prop3Changed();
- }
- }
- qreal prop4() const { return m_p4; }
- void setProp4(qreal p) {
- if (p != m_p4) {
- m_p4 = p;
- emit prop4Changed();
- }
- }
-
- Q_INVOKABLE void method3() { }
- Q_INVOKABLE Q_REVISION(1) void method4() { }
-
-signals:
- void prop3Changed();
- void prop4Changed();
-
- void signal3();
- Q_REVISION(1) void signal4();
-
-protected:
- qreal m_p3;
- qreal m_p4;
-};
-
-QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
-QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
-QML_DECLARE_TYPE(MyRevisionedClass)
-QML_DECLARE_TYPE(MyRevisionedSubclass)
-Q_DECLARE_METATYPE(MyQmlObject::MyType)
-
-
-class ScarceResourceObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QPixmap scarceResource READ scarceResource WRITE setScarceResource NOTIFY scarceResourceChanged)
-public:
- ScarceResourceObject(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); }
- ~ScarceResourceObject() {}
-
- QPixmap scarceResource() const { return m_value; }
- void setScarceResource(QPixmap v) { m_value = v; emit scarceResourceChanged(); }
-
- bool scarceResourceIsDetached() const { return m_value.isDetached(); }
-
- // this particular one returns a new one each time
- // this means that every Scarce Resource Copy will
- // consume resources (so that we can track disposal
- // of v8 handles with circular references).
- Q_INVOKABLE QPixmap newScarceResource() const
- {
- QPixmap retn(800, 600);
- retn.fill(QColor(100, 110, 120, 45));
- return retn;
- }
-
-signals:
- void scarceResourceChanged();
-
-private:
- QPixmap m_value;
-};
-QML_DECLARE_TYPE(ScarceResourceObject)
-
-class testQObjectApi : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged)
- Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged)
-
-public:
- testQObjectApi(QObject* parent = 0)
- : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_methodCallCount(0)
- {
- }
-
- ~testQObjectApi() {}
-
- enum MyEnum { EnumValue1 = 25, EnumValue2 = 42 };
- Q_INVOKABLE int qobjectEnumTestMethod(MyEnum val) { return (static_cast<int>(val) + 5); }
- Q_INVOKABLE int qobjectTestMethod(int increment = 1) { m_methodCallCount += increment; return m_methodCallCount; }
-
- int qobjectTestProperty() const { return m_testProperty; }
- void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); }
-
- int qobjectTestWritableProperty() const { return m_testWritableProperty; }
- void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); }
-
-signals:
- void qobjectTestPropertyChanged(int testProperty);
- void qobjectTestWritablePropertyChanged(int testWritableProperty);
-
-private:
- int m_testProperty;
- int m_testWritableProperty;
- int m_methodCallCount;
-};
-
-class CircularReferenceObject : public QObject,
- public QV8GCCallback::Node
-{
- Q_OBJECT
-
-public:
- CircularReferenceObject(QObject *parent = 0)
- : QObject(parent), QV8GCCallback::Node(callback), m_referenced(0), m_dtorCount(0)
- {
- QV8GCCallback::addGcCallbackNode(this);
- }
-
- ~CircularReferenceObject()
- {
- if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
- }
-
- Q_INVOKABLE void setDtorCount(int *dtorCount)
- {
- m_dtorCount = dtorCount;
- }
-
- Q_INVOKABLE CircularReferenceObject *generate(QObject *parent = 0)
- {
- CircularReferenceObject *retn = new CircularReferenceObject(parent);
- retn->m_dtorCount = m_dtorCount;
- retn->m_engine = m_engine;
- return retn;
- }
-
- Q_INVOKABLE void addReference(QObject *other)
- {
- m_referenced = other;
- }
-
- static void callback(QV8GCCallback::Node *n)
- {
- CircularReferenceObject *cro = static_cast<CircularReferenceObject*>(n);
- if (cro->m_referenced) {
- cro->m_engine->addRelationshipForGC(cro, cro->m_referenced);
- }
- }
-
- void setEngine(QDeclarativeEngine* declarativeEngine)
- {
- m_engine = QDeclarativeEnginePrivate::get(declarativeEngine)->v8engine();
- }
-
-private:
- QObject *m_referenced;
- int *m_dtorCount;
- QV8Engine* m_engine;
-};
-Q_DECLARE_METATYPE(CircularReferenceObject*)
-
-class CircularReferenceHandle : public QObject,
- public QV8GCCallback::Node
-{
- Q_OBJECT
-
-public:
- CircularReferenceHandle(QObject *parent = 0)
- : QObject(parent), QV8GCCallback::Node(gccallback), m_dtorCount(0), m_engine(0)
- {
- QV8GCCallback::addGcCallbackNode(this);
- }
-
- ~CircularReferenceHandle()
- {
- if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
- }
-
- Q_INVOKABLE void setDtorCount(int *dtorCount)
- {
- m_dtorCount = dtorCount;
- }
-
- Q_INVOKABLE CircularReferenceHandle *generate(QObject *parent = 0)
- {
- CircularReferenceHandle *retn = new CircularReferenceHandle(parent);
- retn->m_dtorCount = m_dtorCount;
- retn->m_engine = m_engine;
- return retn;
- }
-
- Q_INVOKABLE void addReference(v8::Persistent<v8::Value> handle)
- {
- m_referenced = qPersistentNew(handle);
- m_referenced.MakeWeak(static_cast<void*>(this), wrcallback);
- }
-
- static void wrcallback(v8::Persistent<v8::Value> handle, void *params)
- {
- CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(params);
- qPersistentDispose(handle);
- crh->m_referenced.Clear();
- }
-
- static void gccallback(QV8GCCallback::Node *n)
- {
- CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(n);
- crh->m_engine->addRelationshipForGC(crh, crh->m_referenced);
- }
-
- void setEngine(QDeclarativeEngine* declarativeEngine)
- {
- m_engine = QDeclarativeEnginePrivate::get(declarativeEngine)->v8engine();
- }
-
-private:
- v8::Persistent<v8::Value> m_referenced;
- int *m_dtorCount;
- QV8Engine* m_engine;
-};
-Q_DECLARE_METATYPE(CircularReferenceHandle*)
-
-class MyDynamicCreationDestructionObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY (int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged)
-
-public:
- MyDynamicCreationDestructionObject(QObject *parent = 0) : QObject(parent), m_intProperty(0), m_dtorCount(0)
- {
- }
-
- ~MyDynamicCreationDestructionObject()
- {
- if (m_dtorCount) {
- (*m_dtorCount)++;
- }
- }
-
- int intProperty() const { return m_intProperty; }
- void setIntProperty(int val) { m_intProperty = val; emit intPropertyChanged(); }
-
- Q_INVOKABLE MyDynamicCreationDestructionObject *createNew()
- {
- // no parent == ownership transfers to JS; same dtor counter.
- MyDynamicCreationDestructionObject *retn = new MyDynamicCreationDestructionObject;
- retn->setDtorCount(m_dtorCount);
- return retn;
- }
-
- void setDtorCount(int *dtorCount)
- {
- m_dtorCount = dtorCount;
- }
-
-signals:
- void intPropertyChanged();
-
-private:
- int m_intProperty;
- int *m_dtorCount;
-};
-
-class WriteCounter : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue);
-public:
- WriteCounter() : m_value(0), m_count(0) {}
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; ++m_count; }
-
- int count() const { return m_count; }
-
-private:
- int m_value;
- int m_count;
-};
-
-class MySequenceConversionObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY (QList<int> intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged)
- Q_PROPERTY (QList<int> intListProperty2 READ intListProperty2 WRITE setIntListProperty2 NOTIFY intListProperty2Changed)
- Q_PROPERTY (QList<qreal> qrealListProperty READ qrealListProperty WRITE setQrealListProperty NOTIFY qrealListPropertyChanged)
- Q_PROPERTY (QList<bool> boolListProperty READ boolListProperty WRITE setBoolListProperty NOTIFY boolListPropertyChanged)
- Q_PROPERTY (QList<QString> stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged)
- Q_PROPERTY (QList<QUrl> urlListProperty READ urlListProperty WRITE setUrlListProperty NOTIFY urlListPropertyChanged)
- Q_PROPERTY (QStringList qstringListProperty READ qstringListProperty WRITE setQStringListProperty NOTIFY qstringListPropertyChanged)
-
- Q_PROPERTY (QList<QPoint> pointListProperty READ pointListProperty WRITE setPointListProperty NOTIFY pointListPropertyChanged)
- Q_PROPERTY (QList<QVariant> variantListProperty READ variantListProperty WRITE setVariantListProperty NOTIFY variantListPropertyChanged)
-
- Q_PROPERTY (qint32 maxIndex READ maxIndex CONSTANT)
- Q_PROPERTY (quint32 tooBigIndex READ tooBigIndex CONSTANT)
- Q_PROPERTY (qint32 negativeIndex READ negativeIndex CONSTANT)
-
-public:
- MySequenceConversionObject()
- {
- m_intList << 1 << 2 << 3 << 4;
- m_intList2 << 1 << 2 << 3 << 4;
- m_qrealList << 1.1 << 2.2 << 3.3 << 4.4;
- m_boolList << true << false << true << false;
- m_stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
- m_urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
- m_qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
-
- m_pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6);
- m_variantList << QVariant(QLatin1String("one")) << QVariant(true) << QVariant(3);
- }
-
- ~MySequenceConversionObject() {}
-
- qint32 maxIndex() const
- {
- return INT_MAX;
- }
- quint32 tooBigIndex() const
- {
- quint32 retn = 7;
- retn += INT_MAX;
- return retn;
- }
- qint32 negativeIndex() const
- {
- return -5;
- }
-
- QList<int> intListProperty() const { return m_intList; }
- void setIntListProperty(const QList<int> &list) { m_intList = list; emit intListPropertyChanged(); }
- QList<int> intListProperty2() const { return m_intList2; }
- void setIntListProperty2(const QList<int> &list) { m_intList2 = list; emit intListProperty2Changed(); }
- QList<qreal> qrealListProperty() const { return m_qrealList; }
- void setQrealListProperty(const QList<qreal> &list) { m_qrealList = list; emit qrealListPropertyChanged(); }
- QList<bool> boolListProperty() const { return m_boolList; }
- void setBoolListProperty(const QList<bool> &list) { m_boolList = list; emit boolListPropertyChanged(); }
- QList<QString> stringListProperty() const { return m_stringList; }
- void setStringListProperty(const QList<QString> &list) { m_stringList = list; emit stringListPropertyChanged(); }
- QList<QUrl> urlListProperty() const { return m_urlList; }
- void setUrlListProperty(const QList<QUrl> &list) { m_urlList = list; emit urlListPropertyChanged(); }
- QStringList qstringListProperty() const { return m_qstringList; }
- void setQStringListProperty(const QStringList &list) { m_qstringList = list; emit qstringListPropertyChanged(); }
- QList<QPoint> pointListProperty() const { return m_pointList; }
- void setPointListProperty(const QList<QPoint> &list) { m_pointList = list; emit pointListPropertyChanged(); }
- QList<QVariant> variantListProperty() const { return m_variantList; }
- void setVariantListProperty(const QList<QVariant> &list) { m_variantList = list; emit variantListPropertyChanged(); }
-
- // now for "copy resource" sequences:
- Q_INVOKABLE QList<int> generateIntSequence() const { QList<int> retn; retn << 1 << 2 << 3; return retn; }
- Q_INVOKABLE QList<qreal> generateQrealSequence() const { QList<qreal> retn; retn << 1.1 << 2.2 << 3.3; return retn; }
- Q_INVOKABLE QList<bool> generateBoolSequence() const { QList<bool> retn; retn << true << false << true; return retn; }
- Q_INVOKABLE QList<QString> generateStringSequence() const { QList<QString> retn; retn << "one" << "two" << "three"; return retn; }
- Q_INVOKABLE QList<QUrl> generateUrlSequence() const { QList<QUrl> retn; retn << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); return retn; }
- Q_INVOKABLE QStringList generateQStringSequence() const { QStringList retn; retn << "one" << "two" << "three"; return retn; }
-
- // "reference resource" underlying qobject deletion test:
- Q_INVOKABLE MySequenceConversionObject *generateTestObject() const { return new MySequenceConversionObject; }
- Q_INVOKABLE void deleteTestObject(QObject *object) const { delete object; }
-
-signals:
- void intListPropertyChanged();
- void intListProperty2Changed();
- void qrealListPropertyChanged();
- void boolListPropertyChanged();
- void stringListPropertyChanged();
- void urlListPropertyChanged();
- void qstringListPropertyChanged();
- void pointListPropertyChanged();
- void variantListPropertyChanged();
-
-private:
- QList<int> m_intList;
- QList<int> m_intList2;
- QList<qreal> m_qrealList;
- QList<bool> m_boolList;
- QList<QString> m_stringList;
- QList<QUrl> m_urlList;
- QStringList m_qstringList;
-
- QList<QPoint> m_pointList; // not a supported sequence type
- QList<QVariant> m_variantList; // not a supported sequence type, but QVariantList support is hardcoded.
-};
-
-class MyDeleteObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QObject *nestedObject READ nestedObject NOTIFY nestedObjectChanged);
- Q_PROPERTY(int deleteNestedObject READ deleteNestedObject NOTIFY deleteNestedObjectChanged);
-
-public:
- MyDeleteObject() : m_nestedObject(new MyQmlObject) {}
-
- QObject *nestedObject() const { return m_nestedObject; }
- int deleteNestedObject() { delete m_nestedObject; m_nestedObject = 0; return 1; }
-
-signals:
- void nestedObjectChanged();
- void deleteNestedObjectChanged();
-
-private:
- MyQmlObject *m_nestedObject;
-};
-
-void registerTypes();
-
-#endif // TESTTYPES_H
-
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
deleted file mode 100644
index 6905252107..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ /dev/null
@@ -1,6097 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdebug.h>
-#include <QtDeclarative/private/qdeclarativeguard_p.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qnumeric.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativevmemetaobject_p.h>
-#include <private/qv4compiler_p.h>
-#include "testtypes.h"
-#include "testhttpserver.h"
-#include "../../shared/util.h"
-
-/*
-This test covers evaluation of ECMAScript expressions and bindings from within
-QML. This does not include static QML language issues.
-
-Static QML language issues are covered in qmllanguage
-*/
-
-class tst_qdeclarativeecmascript : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeecmascript() {}
-
-private slots:
- void initTestCase();
- void assignBasicTypes();
- void idShortcutInvalidates();
- void boolPropertiesEvaluateAsBool();
- void methods();
- void signalAssignment();
- void bindingLoop();
- void basicExpressions();
- void basicExpressions_data();
- void arrayExpressions();
- void contextPropertiesTriggerReeval();
- void objectPropertiesTriggerReeval();
- void deferredProperties();
- void deferredPropertiesErrors();
- void extensionObjects();
- void overrideExtensionProperties();
- void attachedProperties();
- void enums();
- void valueTypeFunctions();
- void constantsOverrideBindings();
- void outerBindingOverridesInnerBinding();
- void aliasPropertyAndBinding();
- void aliasPropertyReset();
- void nonExistentAttachedObject();
- void scope();
- void importScope();
- void signalParameterTypes();
- void objectsCompareAsEqual();
- void dynamicCreation_data();
- void dynamicCreation();
- void dynamicDestruction();
- void objectToString();
- void objectHasOwnProperty();
- void selfDeletingBinding();
- void extendedObjectPropertyLookup();
- void extendedObjectPropertyLookup2();
- void scriptErrors();
- void functionErrors();
- void propertyAssignmentErrors();
- void signalTriggeredBindings();
- void listProperties();
- void exceptionClearsOnReeval();
- void exceptionSlotProducesWarning();
- void exceptionBindingProducesWarning();
- void compileInvalidBinding();
- void transientErrors();
- void shutdownErrors();
- void compositePropertyType();
- void jsObject();
- void undefinedResetsProperty();
- void listToVariant();
- void listAssignment();
- void multiEngineObject();
- void deletedObject();
- void attachedPropertyScope();
- void scriptConnect();
- void scriptDisconnect();
- void ownership();
- void cppOwnershipReturnValue();
- void ownershipCustomReturnValue();
- void qlistqobjectMethods();
- void strictlyEquals();
- void compiled();
- void numberAssignment();
- void propertySplicing();
- void signalWithUnknownTypes();
- void signalWithJSValueInVariant_data();
- void signalWithJSValueInVariant();
- void signalWithJSValueInVariant_twoEngines_data();
- void signalWithJSValueInVariant_twoEngines();
- void signalWithQJSValue_data();
- void signalWithQJSValue();
- void moduleApi_data();
- void moduleApi();
- void importScripts_data();
- void importScripts();
- void scarceResources();
- void scarceResources_data();
- void scarceResources_other();
- void propertyChangeSlots();
- void propertyVar_data();
- void propertyVar();
- void propertyVarCpp();
- void propertyVarOwnership();
- void propertyVarImplicitOwnership();
- void propertyVarReparent();
- void propertyVarReparentNullContext();
- void propertyVarCircular();
- void propertyVarCircular2();
- void propertyVarInheritance();
- void propertyVarInheritance2();
- void elementAssign();
- void objectPassThroughSignals();
- void objectConversion();
- void booleanConversion();
- void handleReferenceManagement();
- void stringArg();
- void readonlyDeclaration();
- void sequenceConversionRead();
- void sequenceConversionWrite();
- void sequenceConversionArray();
- void sequenceConversionIndexes();
- void sequenceConversionThreads();
- void sequenceConversionBindings();
- void sequenceConversionCopy();
- void assignSequenceTypes();
- void qtbug_22464();
- void qtbug_21580();
-
- void bug1();
- void bug2();
- void dynamicCreationCrash();
- void dynamicCreationOwnership();
- void regExpBug();
- void nullObjectBinding();
- void deletedEngine();
- void libraryScriptAssert();
- void variantsAssignedUndefined();
- void qtbug_9792();
- void qtcreatorbug_1289();
- void noSpuriousWarningsAtShutdown();
- void canAssignNullToQObject();
- void functionAssignment_fromBinding();
- void functionAssignment_fromJS();
- void functionAssignment_fromJS_data();
- void functionAssignmentfromJS_invalid();
- void eval();
- void function();
- void functionException();
- void qtbug_10696();
- void qtbug_11606();
- void qtbug_11600();
- void qtbug_21864();
- void qobjectConnectionListExceptionHandling();
- void nonscriptable();
- void deleteLater();
- void in();
- void typeOf();
- void sharedAttachedObject();
- void objectName();
- void writeRemovesBinding();
- void aliasBindingsAssignCorrectly();
- void aliasBindingsOverrideTarget();
- void aliasWritesOverrideBindings();
- void aliasToCompositeElement();
- void realToInt();
- void urlProperty();
- void urlPropertyWithEncoding();
- void urlListPropertyWithEncoding();
- void dynamicString();
- void include();
- void signalHandlers();
- void doubleEvaluate();
- void forInLoop();
- void nonNotifyable();
- void deleteWhileBindingRunning();
- void callQtInvokables();
- void invokableObjectArg();
- void invokableObjectRet();
- void qtbug_20344();
- void qtbug_22679();
- void qtbug_22843_data();
- void qtbug_22843();
- void rewriteMultiLineStrings();
- void revisionErrors();
- void revision();
- void invokableWithQObjectDerived();
-
- void automaticSemicolon();
- void unaryExpression();
- void switchStatement();
- void withStatement();
- void tryStatement();
-
-private:
- static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeecmascript::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- registerTypes();
-}
-
-void tst_qdeclarativeecmascript::assignBasicTypes()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- QCOMPARE(object->uintProperty(), uint(10));
- QCOMPARE(object->intProperty(), -19);
- QCOMPARE((float)object->realProperty(), float(23.2));
- 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));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- QCOMPARE(object->uintProperty(), uint(10));
- QCOMPARE(object->intProperty(), -19);
- QCOMPARE((float)object->realProperty(), float(23.2));
- 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));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::idShortcutInvalidates()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("idShortcutInvalidates.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->objectProperty() != 0);
- delete object->objectProperty();
- QVERIFY(object->objectProperty() == 0);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("idShortcutInvalidates.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->objectProperty() != 0);
- delete object->objectProperty();
- QVERIFY(object->objectProperty() == 0);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::boolPropertiesEvaluateAsBool()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), QLatin1String("pass"));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), QLatin1String("pass"));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::signalAssignment()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->basicSignal();
- QCOMPARE(object->string(), QString("pass"));
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.3.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->unnamedArgumentSignal(19, 10.25, "Hello world!");
- QEXPECT_FAIL("", "QTBUG-24481", Continue);
- QCOMPARE(object->string(), QString("pass 19 Hello world!"));
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.4.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->signalWithGlobalName(19);
- QCOMPARE(object->string(), QString("pass 5"));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::methods()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), false);
- emit object->basicSignal();
- QCOMPARE(object->methodCalled(), true);
- QCOMPARE(object->methodIntCalled(), false);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), false);
- emit object->basicSignal();
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), true);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 19);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 19);
- QCOMPARE(object->property("test2").toInt(), 17);
- QCOMPARE(object->property("test3").toInt(), 16);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 9);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::bindingLoop()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingLoop.qml"));
- QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\"";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::basicExpressions_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QVariant>("result");
- QTest::addColumn<bool>("nest");
-
- QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false;
- QTest::newRow("Context property") << "a" << QVariant(1944) << false;
- QTest::newRow("Context property") << "a" << QVariant(1944) << true;
- QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false;
- QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << true;
- QTest::newRow("Overridden context property") << "b" << QVariant("Milk") << false;
- QTest::newRow("Overridden context property") << "b" << QVariant("Cow") << true;
- QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << false;
- QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << true;
- QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object2") << false;
- QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object3") << true;
- QTest::newRow("Default object property") << "horseLegs" << QVariant(4) << false;
- QTest::newRow("Default object property") << "antLegs" << QVariant(6) << false;
- QTest::newRow("Default object property") << "emuLegs" << QVariant(2) << false;
- QTest::newRow("Nested default object property") << "horseLegs" << QVariant(4) << true;
- QTest::newRow("Nested default object property") << "antLegs" << QVariant(7) << true;
- QTest::newRow("Nested default object property") << "emuLegs" << QVariant(2) << true;
- QTest::newRow("Nested default object property") << "humanLegs" << QVariant(2) << true;
- QTest::newRow("Context property override default object property") << "millipedeLegs" << QVariant(100) << true;
-}
-
-void tst_qdeclarativeecmascript::basicExpressions()
-{
- QFETCH(QString, expression);
- QFETCH(QVariant, result);
- QFETCH(bool, nest);
-
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject object3;
- MyDefaultObject1 default1;
- MyDefaultObject3 default3;
- object1.setStringProperty("Object1");
- object2.setStringProperty("Object2");
- object3.setStringProperty("Object3");
-
- QDeclarativeContext context(engine.rootContext());
- QDeclarativeContext nestedContext(&context);
-
- context.setContextObject(&default1);
- context.setContextProperty("a", QVariant(1944));
- context.setContextProperty("b", QVariant("Milk"));
- context.setContextProperty("object", &object1);
- context.setContextProperty("objectOverride", &object2);
- nestedContext.setContextObject(&default3);
- nestedContext.setContextProperty("b", QVariant("Cow"));
- nestedContext.setContextProperty("objectOverride", &object3);
- nestedContext.setContextProperty("millipedeLegs", QVariant(100));
-
- MyExpression expr(nest?&nestedContext:&context, expression);
- QCOMPARE(expr.evaluate(), result);
-}
-
-void tst_qdeclarativeecmascript::arrayExpressions()
-{
- QObject obj1;
- QObject obj2;
- QObject obj3;
-
- QDeclarativeContext context(engine.rootContext());
- context.setContextProperty("a", &obj1);
- context.setContextProperty("b", &obj2);
- context.setContextProperty("c", &obj3);
-
- MyExpression expr(&context, "[a, b, c, 10]");
- QVariant result = expr.evaluate();
- QCOMPARE(result.userType(), qMetaTypeId<QList<QObject *> >());
- QList<QObject *> list = qvariant_cast<QList<QObject *> >(result);
- QCOMPARE(list.count(), 4);
- QCOMPARE(list.at(0), &obj1);
- QCOMPARE(list.at(1), &obj2);
- QCOMPARE(list.at(2), &obj3);
- QCOMPARE(list.at(3), (QObject *)0);
-}
-
-// Tests that modifying a context property will reevaluate expressions
-void tst_qdeclarativeecmascript::contextPropertiesTriggerReeval()
-{
- QDeclarativeContext context(engine.rootContext());
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject *object3 = new MyQmlObject;
-
- object1.setStringProperty("Hello");
- object2.setStringProperty("World");
-
- context.setContextProperty("testProp", QVariant(1));
- context.setContextProperty("testObj", &object1);
- context.setContextProperty("testObj2", object3);
-
- {
- MyExpression expr(&context, "testProp + 1");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant(2));
-
- context.setContextProperty("testProp", QVariant(2));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant(3));
- }
-
- {
- MyExpression expr(&context, "testProp + testProp + testProp");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant(6));
-
- context.setContextProperty("testProp", QVariant(4));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant(12));
- }
-
- {
- MyExpression expr(&context, "testObj.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant("Hello"));
-
- context.setContextProperty("testObj", &object2);
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant("World"));
- }
-
- {
- MyExpression expr(&context, "testObj.stringProperty /**/");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant("World"));
-
- context.setContextProperty("testObj", &object1);
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant("Hello"));
- }
-
- {
- MyExpression expr(&context, "testObj2");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant::fromValue((QObject *)object3));
- }
-
- delete object3;
-}
-
-void tst_qdeclarativeecmascript::objectPropertiesTriggerReeval()
-{
- QDeclarativeContext context(engine.rootContext());
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject object3;
- context.setContextProperty("testObj", &object1);
-
- object1.setStringProperty(QLatin1String("Hello"));
- object2.setStringProperty(QLatin1String("Dog"));
- object3.setStringProperty(QLatin1String("Cat"));
-
- {
- MyExpression expr(&context, "testObj.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant("Hello"));
-
- object1.setStringProperty(QLatin1String("World"));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant("World"));
- }
-
- {
- MyExpression expr(&context, "testObj.objectProperty.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant());
-
- object1.setObjectProperty(&object2);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant("Dog"));
-
- object1.setObjectProperty(&object3);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant("Cat"));
-
- object1.setObjectProperty(0);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant());
-
- object1.setObjectProperty(&object3);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant("Cat"));
-
- object3.setStringProperty("Donkey");
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant("Donkey"));
- }
-}
-
-void tst_qdeclarativeecmascript::deferredProperties()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deferredProperties.qml"));
- MyDeferredObject *object =
- qobject_cast<MyDeferredObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->value(), 0);
- QVERIFY(object->objectProperty() == 0);
- QVERIFY(object->objectProperty2() != 0);
- qmlExecuteDeferred(object);
- QCOMPARE(object->value(), 10);
- QVERIFY(object->objectProperty() != 0);
- MyQmlObject *qmlObject =
- qobject_cast<MyQmlObject *>(object->objectProperty());
- QVERIFY(qmlObject != 0);
- QCOMPARE(qmlObject->value(), 10);
- object->setValue(19);
- QCOMPARE(qmlObject->value(), 19);
-
- delete object;
-}
-
-// Check errors on deferred properties are correctly emitted
-void tst_qdeclarativeecmascript::deferredPropertiesErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml"));
- MyDeferredObject *object =
- qobject_cast<MyDeferredObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->value(), 0);
- QVERIFY(object->objectProperty() == 0);
- QVERIFY(object->objectProperty2() == 0);
-
- QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- qmlExecuteDeferred(object);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::extensionObjects()
-{
- QDeclarativeComponent component(&engine, testFileUrl("extensionObjects.qml"));
- MyExtendedObject *object =
- qobject_cast<MyExtendedObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->baseProperty(), 13);
- QCOMPARE(object->coreProperty(), 9);
- object->setProperty("extendedProperty", QVariant(11));
- object->setProperty("baseExtendedProperty", QVariant(92));
- QCOMPARE(object->coreProperty(), 11);
- QCOMPARE(object->baseProperty(), 92);
-
- MyExtendedObject *nested = qobject_cast<MyExtendedObject*>(qvariant_cast<QObject *>(object->property("nested")));
- QVERIFY(nested);
- QCOMPARE(nested->baseProperty(), 13);
- QCOMPARE(nested->coreProperty(), 9);
- nested->setProperty("extendedProperty", QVariant(11));
- nested->setProperty("baseExtendedProperty", QVariant(92));
- QCOMPARE(nested->coreProperty(), 11);
- QCOMPARE(nested->baseProperty(), 92);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::overrideExtensionProperties()
-{
- QDeclarativeComponent component(&engine, testFileUrl("extensionObjectsPropertyOverride.qml"));
- OverrideDefaultPropertyObject *object =
- qobject_cast<OverrideDefaultPropertyObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->secondProperty() != 0);
- QVERIFY(object->firstProperty() == 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::attachedProperties()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("attachedProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 19);
- QCOMPARE(object->property("b").toInt(), 19);
- QCOMPARE(object->property("c").toInt(), 19);
- QCOMPARE(object->property("d").toInt(), 19);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("attachedProperty.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 26);
- QCOMPARE(object->property("b").toInt(), 26);
- QCOMPARE(object->property("c").toInt(), 26);
- QCOMPARE(object->property("d").toInt(), 26);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("writeAttachedProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, "writeValue2");
-
- MyQmlAttachedObject *attached =
- qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
- QVERIFY(attached != 0);
-
- QCOMPARE(attached->value2(), 9);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::enums()
-{
- // Existent enums
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("a").toInt(), 0);
- QCOMPARE(object->property("b").toInt(), 1);
- QCOMPARE(object->property("c").toInt(), 2);
- QCOMPARE(object->property("d").toInt(), 3);
- QCOMPARE(object->property("e").toInt(), 0);
- QCOMPARE(object->property("f").toInt(), 1);
- QCOMPARE(object->property("g").toInt(), 2);
- QCOMPARE(object->property("h").toInt(), 3);
- QCOMPARE(object->property("i").toInt(), 19);
- QCOMPARE(object->property("j").toInt(), 19);
-
- delete object;
- }
- // Non-existent enums
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.2.qml"));
-
- QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
- QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 0);
- QCOMPARE(object->property("b").toInt(), 0);
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::valueTypeFunctions()
-{
- QDeclarativeComponent component(&engine, testFileUrl("valueTypeFunctions.qml"));
- MyTypeObject *obj = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->rectProperty(), QRect(0,0,100,100));
- QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5));
-
- delete obj;
-}
-
-/*
-Tests that writing a constant to a property with a binding on it disables the
-binding.
-*/
-void tst_qdeclarativeecmascript::constantsOverrideBindings()
-{
- // From ECMAScript
- {
- QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 0);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c2").toInt(), 9);
-
- emit object->basicSignal();
-
- QCOMPARE(object->property("c2").toInt(), 13);
- object->setProperty("c1", QVariant(8));
- QCOMPARE(object->property("c2").toInt(), 13);
-
- delete object;
- }
-
- // During construction
- {
- QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c1").toInt(), 0);
- QCOMPARE(object->property("c2").toInt(), 10);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 10);
-
- delete object;
- }
-
-#if 0
- // From C++
- {
- QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.3.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 0);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c2").toInt(), 9);
-
- object->setProperty("c2", QVariant(13));
- QCOMPARE(object->property("c2").toInt(), 13);
- object->setProperty("c1", QVariant(7));
- QCOMPARE(object->property("c1").toInt(), 7);
- QCOMPARE(object->property("c2").toInt(), 13);
-
- delete object;
- }
-#endif
-
- // Using an alias
- {
- QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.4.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c1").toInt(), 0);
- QCOMPARE(object->property("c3").toInt(), 10);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c3").toInt(), 10);
-
- delete object;
- }
-}
-
-/*
-Tests that assigning a binding to a property that already has a binding causes
-the original binding to be disabled.
-*/
-void tst_qdeclarativeecmascript::outerBindingOverridesInnerBinding()
-{
- QDeclarativeComponent component(&engine,
- testFileUrl("outerBindingOverridesInnerBinding.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c1").toInt(), 0);
- QCOMPARE(object->property("c2").toInt(), 0);
- QCOMPARE(object->property("c3").toInt(), 0);
-
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 0);
- QCOMPARE(object->property("c3").toInt(), 0);
-
- object->setProperty("c3", QVariant(8));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 8);
- QCOMPARE(object->property("c3").toInt(), 8);
-
- delete object;
-}
-
-/*
-Access a non-existent attached object.
-
-Tests for a regression where this used to crash.
-*/
-void tst_qdeclarativeecmascript::nonExistentAttachedObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml"));
-
- QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::scope()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 1);
- QCOMPARE(object->property("test2").toInt(), 2);
- QCOMPARE(object->property("test3").toString(), QString("1Test"));
- QCOMPARE(object->property("test4").toString(), QString("2Test"));
- QCOMPARE(object->property("test5").toInt(), 1);
- QCOMPARE(object->property("test6").toInt(), 1);
- QCOMPARE(object->property("test7").toInt(), 2);
- QCOMPARE(object->property("test8").toInt(), 2);
- QCOMPARE(object->property("test9").toInt(), 1);
- QCOMPARE(object->property("test10").toInt(), 3);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 19);
- QCOMPARE(object->property("test2").toInt(), 19);
- QCOMPARE(object->property("test3").toInt(), 14);
- QCOMPARE(object->property("test4").toInt(), 14);
- QCOMPARE(object->property("test5").toInt(), 24);
- QCOMPARE(object->property("test6").toInt(), 24);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
-
- delete object;
- }
-
- // Signal argument scope
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.4.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- QCOMPARE(object->property("test2").toString(), QString());
-
- emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton);
-
- QCOMPARE(object->property("test").toInt(), 13);
- QCOMPARE(object->property("test2").toString(), QString("Argument Scope"));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.6.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-}
-
-// In 4.7, non-library javascript files that had no imports shared the imports of their
-// importing context
-void tst_qdeclarativeecmascript::importScope()
-{
- QDeclarativeComponent component(&engine, testFileUrl("importScope.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toInt(), 240);
-
- delete o;
-}
-
-/*
-Tests that "any" type passes through a synthesized signal parameter. This
-is essentially a test of QDeclarativeMetaType::copy()
-*/
-void tst_qdeclarativeecmascript::signalParameterTypes()
-{
- QDeclarativeComponent component(&engine, testFileUrl("signalParameterTypes.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- emit object->basicSignal();
-
- QCOMPARE(object->property("intProperty").toInt(), 10);
- QCOMPARE(object->property("realProperty").toReal(), 19.2);
- QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
- QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
- QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3);
- QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton);
-
- delete object;
-}
-
-/*
-Test that two JS objects for the same QObject compare as equal.
-*/
-void tst_qdeclarativeecmascript::objectsCompareAsEqual()
-{
- QDeclarativeComponent component(&engine, testFileUrl("objectsCompareAsEqual.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
- QCOMPARE(object->property("test5").toBool(), true);
-
- delete object;
-}
-
-/*
-Confirm bindings and alias properties can coexist.
-
-Tests for a regression where the binding would not reevaluate.
-*/
-void tst_qdeclarativeecmascript::aliasPropertyAndBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyAndBinding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 3);
- QCOMPARE(object->property("c3").toInt(), 3);
-
- object->setProperty("c2", QVariant(19));
-
- QCOMPARE(object->property("c2").toInt(), 19);
- QCOMPARE(object->property("c3").toInt(), 19);
-
- delete object;
-}
-
-/*
-Ensure that we can write undefined value to an alias property,
-and that the aliased property is reset correctly if possible.
-*/
-void tst_qdeclarativeecmascript::aliasPropertyReset()
-{
- QObject *object = 0;
-
- // test that a manual write (of undefined) to a resettable aliased property succeeds
- QDeclarativeComponent c1(&engine, testFileUrl("aliasreset/aliasPropertyReset.1.qml"));
- object = c1.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
- QCOMPARE(object->property("aliasIsUndefined"), QVariant(false));
- QMetaObject::invokeMethod(object, "resetAliased");
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- QCOMPARE(object->property("aliasIsUndefined"), QVariant(true));
- delete object;
-
- // test that a manual write (of undefined) to a resettable alias property succeeds
- QDeclarativeComponent c2(&engine, testFileUrl("aliasreset/aliasPropertyReset.2.qml"));
- object = c2.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
- QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false));
- QMetaObject::invokeMethod(object, "resetAlias");
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(true));
- delete object;
-
- // test that an alias to a bound property works correctly
- QDeclarativeComponent c3(&engine, testFileUrl("aliasreset/aliasPropertyReset.3.qml"));
- object = c3.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
- QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false));
- QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
- QMetaObject::invokeMethod(object, "resetAlias");
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(true));
- QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
- delete object;
-
- // test that a manual write (of undefined) to a resettable alias property
- // whose aliased property's object has been deleted, does not crash.
- QDeclarativeComponent c4(&engine, testFileUrl("aliasreset/aliasPropertyReset.4.qml"));
- object = c4.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
- QObject *loader = object->findChild<QObject*>("loader");
- QVERIFY(loader != 0);
- delete loader;
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0); // deletion should have caused value unset.
- QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash.
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- QMetaObject::invokeMethod(object, "setAlias"); // shouldn't crash, and shouldn't change value (since it's no longer referencing anything).
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- delete object;
-
- // test that binding an alias property to an undefined value works correctly
- QDeclarativeComponent c5(&engine, testFileUrl("aliasreset/aliasPropertyReset.5.qml"));
- object = c5.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0); // bound to undefined value.
- delete object;
-
- // test that a manual write (of undefined) to a non-resettable property fails properly
- QUrl url = testFileUrl("aliasreset/aliasPropertyReset.error.1.qml");
- QString warning1 = url.toString() + QLatin1String(":15: Error: Cannot assign [undefined] to int");
- QDeclarativeComponent e1(&engine, url);
- object = e1.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("intAlias").value<int>(), 12);
- QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QMetaObject::invokeMethod(object, "resetAlias");
- QCOMPARE(object->property("intAlias").value<int>(), 12);
- QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
- delete object;
-}
-
-void tst_qdeclarativeecmascript::dynamicCreation_data()
-{
- QTest::addColumn<QString>("method");
- QTest::addColumn<QString>("createdName");
-
- QTest::newRow("One") << "createOne" << "objectOne";
- QTest::newRow("Two") << "createTwo" << "objectTwo";
- QTest::newRow("Three") << "createThree" << "objectThree";
-}
-
-/*
-Test using createQmlObject to dynamically generate an item
-Also using createComponent is tested.
-*/
-void tst_qdeclarativeecmascript::dynamicCreation()
-{
- QFETCH(QString, method);
- QFETCH(QString, createdName);
-
- QDeclarativeComponent component(&engine, testFileUrl("dynamicCreation.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, method.toUtf8());
- QObject *created = object->objectProperty();
- QVERIFY(created);
- QCOMPARE(created->objectName(), createdName);
-
- delete object;
-}
-
-/*
- Tests the destroy function
-*/
-void tst_qdeclarativeecmascript::dynamicDestruction()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("dynamicDeletion.qml"));
- QDeclarativeGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QDeclarativeGuard<QObject> createdQmlObject = 0;
-
- QMetaObject::invokeMethod(object, "create");
- createdQmlObject = object->objectProperty();
- QVERIFY(createdQmlObject);
- QCOMPARE(createdQmlObject->objectName(), QString("emptyObject"));
-
- QMetaObject::invokeMethod(object, "killOther");
- QVERIFY(createdQmlObject);
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QVERIFY(createdQmlObject);
- for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
- if (createdQmlObject) {
- QTest::qWait(100);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- }
- }
- QVERIFY(!createdQmlObject);
-
- QDeclarativeEngine::setObjectOwnership(object, QDeclarativeEngine::JavaScriptOwnership);
- QMetaObject::invokeMethod(object, "killMe");
- QVERIFY(object);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QVERIFY(!object);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("dynamicDeletion.2.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0);
-
- QMetaObject::invokeMethod(o, "create");
-
- QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) != 0);
-
- QMetaObject::invokeMethod(o, "destroy");
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0);
-
- delete o;
- }
-}
-
-/*
- tests that id.toString() works
-*/
-void tst_qdeclarativeecmascript::objectToString()
-{
- QDeclarativeComponent component(&engine, testFileUrl("declarativeToString.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "testToString");
- QVERIFY(object->stringProperty().startsWith("MyQmlObject_QML_"));
- QVERIFY(object->stringProperty().endsWith(", \"objName\")"));
-
- delete object;
-}
-
-/*
- tests that id.hasOwnProperty() works
-*/
-void tst_qdeclarativeecmascript::objectHasOwnProperty()
-{
- QUrl url = testFileUrl("declarativeHasOwnProperty.qml");
- QString warning1 = url.toString() + ":59: TypeError: Cannot call method 'hasOwnProperty' of undefined";
- QString warning2 = url.toString() + ":64: TypeError: Cannot call method 'hasOwnProperty' of undefined";
- QString warning3 = url.toString() + ":69: TypeError: Cannot call method 'hasOwnProperty' of undefined";
-
- QDeclarativeComponent component(&engine, url);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // test QObjects in QML
- QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess");
- QVERIFY(object->property("result").value<bool>() == true);
- QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure");
- QVERIFY(object->property("result").value<bool>() == false);
-
- // now test other types in QML
- QObject *child = object->findChild<QObject*>("typeObj");
- QVERIFY(child != 0);
- QMetaObject::invokeMethod(child, "testHasOwnPropertySuccess");
- QCOMPARE(child->property("valueTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("valueTypeHasOwnProperty2").toBool(), true);
- QCOMPARE(child->property("variantTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("stringTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("listTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("emptyListTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("enumTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("typenameHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("typenameHasOwnProperty2").toBool(), true);
- QCOMPARE(child->property("moduleApiTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("moduleApiPropertyTypeHasOwnProperty").toBool(), true);
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureOne");
- QCOMPARE(child->property("enumNonValueHasOwnProperty").toBool(), false);
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureTwo");
- QCOMPARE(child->property("moduleApiNonPropertyHasOwnProperty").toBool(), false);
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureThree");
- QCOMPARE(child->property("listAtInvalidHasOwnProperty").toBool(), false);
-
- delete object;
-}
-
-/*
-Tests bindings that indirectly cause their own deletion work.
-
-This test is best run under valgrind to ensure no invalid memory access occur.
-*/
-void tst_qdeclarativeecmascript::selfDeletingBinding()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("selfDeletingBinding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- object->setProperty("triggerDelete", true);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("selfDeletingBinding.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- object->setProperty("triggerDelete", true);
- delete object;
- }
-}
-
-/*
-Test that extended object properties can be accessed.
-
-This test a regression where this used to crash. The issue was specificially
-for extended objects that did not include a synthesized meta object (so non-root
-and no synthesiszed properties).
-*/
-void tst_qdeclarativeecmascript::extendedObjectPropertyLookup()
-{
- QDeclarativeComponent component(&engine, testFileUrl("extendedObjectPropertyLookup.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-/*
-Test that extended object properties can be accessed correctly.
-*/
-void tst_qdeclarativeecmascript::extendedObjectPropertyLookup2()
-{
- QDeclarativeComponent component(&engine, testFileUrl("extendedObjectPropertyLookup2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVariant returnValue;
- QVERIFY(QMetaObject::invokeMethod(object, "getValue", Q_RETURN_ARG(QVariant, returnValue)));
- QCOMPARE(returnValue.toInt(), 42);
-
- delete object;
-}
-/*
-Test file/lineNumbers for binding/Script errors.
-*/
-void tst_qdeclarativeecmascript::scriptErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("scriptErrors.qml"));
- QString url = component.url().toString();
-
- QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
- QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
- QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
- QString warning4 = url + ":13: ReferenceError: Can't find variable: a";
- QString warning5 = url + ":11: ReferenceError: Can't find variable: a";
- QString warning6 = url + ":10: Unable to assign [undefined] to int";
- QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\"";
- QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\"";
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning6.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
- emit object->basicSignal();
-
- QTest::ignoreMessage(QtWarningMsg, warning7.toLatin1().constData());
- emit object->anotherBasicSignal();
-
- QTest::ignoreMessage(QtWarningMsg, warning8.toLatin1().constData());
- emit object->thirdBasicSignal();
-
- delete object;
-}
-
-/*
-Test file/lineNumbers for inline functions.
-*/
-void tst_qdeclarativeecmascript::functionErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("functionErrors.qml"));
- QString url = component.url().toString();
-
- QString warning = url + ":5: Error: Invalid write to global property \"a\"";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-
- // test that if an exception occurs while invoking js function from cpp, it is reported as expected.
- QDeclarativeComponent componentTwo(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
- url = componentTwo.url().toString();
- object = componentTwo.create();
- QVERIFY(object != 0);
-
- QString srpname = object->property("srp_name").toString();
-
- warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srpname
- + QLatin1String(" is not a function");
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- delete object;
-}
-
-/*
-Test various errors that can occur when assigning a property from script
-*/
-void tst_qdeclarativeecmascript::propertyAssignmentErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("propertyAssignmentErrors.qml"));
-
- QString url = component.url().toString();
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
-}
-
-/*
-Test bindings still work when the reeval is triggered from within
-a signal script.
-*/
-void tst_qdeclarativeecmascript::signalTriggeredBindings()
-{
- QDeclarativeComponent component(&engine, testFileUrl("signalTriggeredBindings.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("base").toReal(), 50.);
- QCOMPARE(object->property("test1").toReal(), 50.);
- QCOMPARE(object->property("test2").toReal(), 50.);
-
- object->basicSignal();
-
- QCOMPARE(object->property("base").toReal(), 200.);
- QCOMPARE(object->property("test1").toReal(), 200.);
- QCOMPARE(object->property("test2").toReal(), 200.);
-
- object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton);
-
- QCOMPARE(object->property("base").toReal(), 400.);
- QCOMPARE(object->property("test1").toReal(), 400.);
- QCOMPARE(object->property("test2").toReal(), 400.);
-
- delete object;
-}
-
-/*
-Test that list properties can be iterated from ECMAScript
-*/
-void tst_qdeclarativeecmascript::listProperties()
-{
- QDeclarativeComponent component(&engine, testFileUrl("listProperties.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 21);
- QCOMPARE(object->property("test2").toInt(), 2);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::exceptionClearsOnReeval()
-{
- QDeclarativeComponent component(&engine, testFileUrl("exceptionClearsOnReeval.qml"));
- QString url = component.url().toString();
-
- QString warning = url + ":4: TypeError: Cannot read property 'objectProperty' of null";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
-
- MyQmlObject object2;
- MyQmlObject object3;
- object2.setObjectProperty(&object3);
- object->setObjectProperty(&object2);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::exceptionSlotProducesWarning()
-{
- QDeclarativeComponent component(&engine, testFileUrl("exceptionProducesWarning.qml"));
- QString url = component.url().toString();
-
- QString warning = component.url().toString() + ":6: Error: JS exception";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::exceptionBindingProducesWarning()
-{
- QDeclarativeComponent component(&engine, testFileUrl("exceptionProducesWarning2.qml"));
- QString url = component.url().toString();
-
- QString warning = component.url().toString() + ":5: Error: JS exception";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::compileInvalidBinding()
-{
- // QTBUG-23387: ensure that invalid bindings don't cause a crash.
- QDeclarativeComponent component(&engine, testFileUrl("v8bindingException.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-static int transientErrorsMsgCount = 0;
-static void transientErrorsMsgHandler(QtMsgType, const char *)
-{
- ++transientErrorsMsgCount;
-}
-
-// Check that transient binding errors are not displayed
-void tst_qdeclarativeecmascript::transientErrors()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("transientErrors.qml"));
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
-
- delete object;
- }
-
- // One binding erroring multiple times, but then resolving
- {
- QDeclarativeComponent component(&engine, testFileUrl("transientErrors.2.qml"));
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
-
- delete object;
- }
-}
-
-// Check that errors during shutdown are minimized
-void tst_qdeclarativeecmascript::shutdownErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("shutdownErrors.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- delete object;
-
- qInstallMsgHandler(old);
- QCOMPARE(transientErrorsMsgCount, 0);
-}
-
-void tst_qdeclarativeecmascript::compositePropertyType()
-{
- QDeclarativeComponent component(&engine, testFileUrl("compositePropertyType.qml"));
-
- QTest::ignoreMessage(QtDebugMsg, "hello world");
- QObject *object = qobject_cast<QObject *>(component.create());
- delete object;
-}
-
-// QTBUG-5759
-void tst_qdeclarativeecmascript::jsObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("jsObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::undefinedResetsProperty()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("undefinedResetsProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 92);
-
- object->setProperty("setUndefined", true);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 13);
-
- object->setProperty("setUndefined", false);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 92);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("undefinedResetsProperty.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 19);
-
- QMetaObject::invokeMethod(object, "doReset");
-
- QCOMPARE(object->property("resettableProperty").toInt(), 13);
-
- delete object;
- }
-}
-
-// Aliases to variant properties should work
-void tst_qdeclarativeecmascript::qtbug_22464()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_22464.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::qtbug_21580()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_21580.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// QTBUG-6781
-void tst_qdeclarativeecmascript::bug1()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bug.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 14);
-
- object->setProperty("a", 11);
-
- QCOMPARE(object->property("test").toInt(), 3);
-
- object->setProperty("b", true);
-
- QCOMPARE(object->property("test").toInt(), 9);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::bug2()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl());
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-// Don't crash in createObject when the component has errors.
-void tst_qdeclarativeecmascript::dynamicCreationCrash()
-{
- QDeclarativeComponent component(&engine, testFileUrl("dynamicCreation.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QMetaObject::invokeMethod(object, "dontCrash");
- QObject *created = object->objectProperty();
- QVERIFY(created == 0);
-
- delete object;
-}
-
-// ownership transferred to JS, ensure that GC runs the dtor
-void tst_qdeclarativeecmascript::dynamicCreationOwnership()
-{
- int dtorCount = 0;
- int expectedDtorCount = 1; // start at 1 since we expect mdcdo to dtor too.
-
- // allow the engine to go out of scope too.
- {
- QDeclarativeEngine dcoEngine;
- QDeclarativeComponent component(&dcoEngine, testFileUrl("dynamicCreationOwnership.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- MyDynamicCreationDestructionObject *mdcdo = object->findChild<MyDynamicCreationDestructionObject*>("mdcdo");
- QVERIFY(mdcdo != 0);
- mdcdo->setDtorCount(&dtorCount);
-
- for (int i = 1; i < 105; ++i, ++expectedDtorCount) {
- QMetaObject::invokeMethod(object, "dynamicallyCreateJsOwnedObject");
- if (i % 90 == 0) {
- // we do this once manually, but it should be done automatically
- // when the engine goes out of scope (since it should gc in dtor)
- QMetaObject::invokeMethod(object, "performGc");
- }
- if (i % 10 == 0) {
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- }
- }
-
- delete object;
- }
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, expectedDtorCount);
-}
-
-void tst_qdeclarativeecmascript::regExpBug()
-{
- //QTBUG-9367
- {
- QDeclarativeComponent component(&engine, testFileUrl("regExp.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]"));
- delete object;
- }
-
- //QTBUG-23068
- {
- QString err = QString(QLatin1String("%1:6 Invalid property assignment: regular expression expected; use /pattern/ syntax\n")).arg(testFileUrl("regExp.2.qml").toString());
- QDeclarativeComponent component(&engine, testFileUrl("regExp.2.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(!object);
- QCOMPARE(component.errorString(), err);
- }
-}
-
-static inline bool evaluate_error(QV8Engine *engine, v8::Handle<v8::Object> o, const char *source)
-{
- QString functionSource = QLatin1String("(function(object) { return ") +
- QLatin1String(source) + QLatin1String(" })");
- v8::TryCatch tc;
- v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
- if (tc.HasCaught())
- return false;
- v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
- if (function.IsEmpty())
- return false;
- v8::Handle<v8::Value> args[] = { o };
- function->Call(engine->global(), 1, args);
- return tc.HasCaught();
-}
-
-static inline bool evaluate_value(QV8Engine *engine, v8::Handle<v8::Object> o,
- const char *source, v8::Handle<v8::Value> result)
-{
- QString functionSource = QLatin1String("(function(object) { return ") +
- QLatin1String(source) + QLatin1String(" })");
- v8::TryCatch tc;
- v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
- if (tc.HasCaught())
- return false;
- v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
- if (function.IsEmpty())
- return false;
- v8::Handle<v8::Value> args[] = { o };
-
- v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args);
-
- if (tc.HasCaught())
- return false;
-
- return value->StrictEquals(result);
-}
-
-static inline v8::Handle<v8::Value> evaluate(QV8Engine *engine, v8::Handle<v8::Object> o,
- const char *source)
-{
- QString functionSource = QLatin1String("(function(object) { return ") +
- QLatin1String(source) + QLatin1String(" })");
- v8::TryCatch tc;
- v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
- if (tc.HasCaught())
- return v8::Handle<v8::Value>();
- v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
- if (function.IsEmpty())
- return v8::Handle<v8::Value>();
- v8::Handle<v8::Value> args[] = { o };
-
- v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args);
-
- if (tc.HasCaught())
- return v8::Handle<v8::Value>();
- return value;
-}
-
-#define EVALUATE_ERROR(source) evaluate_error(engine, object, source)
-#define EVALUATE_VALUE(source, result) evaluate_value(engine, object, source, result)
-#define EVALUATE(source) evaluate(engine, object, source)
-
-void tst_qdeclarativeecmascript::callQtInvokables()
-{
- MyInvokableObject o;
-
- QDeclarativeEngine qmlengine;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine);
-
- QV8Engine *engine = ep->v8engine();
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- v8::Local<v8::Object> object = engine->newQObject(&o)->ToObject();
-
- // Non-existent methods
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_nonexistent()"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_nonexistent(10, 11)"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- // Insufficient arguments
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_int()"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_intint(10)"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- // Excessive arguments
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(10, 11)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(10));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intint(10, 11, 12)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 9);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(11));
-
- // Test return types
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs()", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 0);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_int()", v8::Integer::New(6)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_real()", v8::Number::New(19.75)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 2);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- {
- v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QPointF()");
- QVERIFY(!ret.IsEmpty());
- QCOMPARE(engine->toVariant(ret, -1), QVariant(QPointF(123, 4.5)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 3);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- {
- v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QObject()");
- QCOMPARE(engine->toQObject(ret), (QObject *)&o);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 4);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_unknown()", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 5);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- {
- v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QScriptValue()");
- QVERIFY(ret->IsString());
- QCOMPARE(engine->toString(ret), QString("Hello world"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 6);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_QVariant()", engine->toString("QML rocks")));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 7);
- QCOMPARE(o.actuals().count(), 0);
-
- // Test arg types
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(94)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(\"94\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(\"not a number\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intint(122, 9)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 9);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(122));
- QCOMPARE(o.actuals().at(1), QVariant(9));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(94.3)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94.3));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(\"94.3\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94.3));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(\"not a number\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QString(\"Hello world\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant("Hello world"));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QString(19)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant("19"));
-
- o.reset();
- {
- QString expected = "MyInvokableObject(0x" + QString::number((quintptr)&o, 16) + ")";
- QVERIFY(EVALUATE_VALUE("object.method_QString(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(expected));
- }
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QString(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QString(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(0)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPointF())", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF(99.3, -10.2)));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPoint())", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12)));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(0)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(\"Hello world\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isNull());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isUndefined());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(19)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).strictlyEquals(QJSValue(19)));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QScriptValue([19, 20])", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isArray());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(4, null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(4));
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isNull());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(8, undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(8));
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isUndefined());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(3, 19)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(3));
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).strictlyEquals(QJSValue(19)));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(44, [19, 20])", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(44));
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isArray());
-
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_overload()"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_overload(10)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 16);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(10));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_overload(10, 11)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 17);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(11));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_overload(\"Hello\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 18);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString("Hello")));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_with_enum(9)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 19);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(9));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_default(10)", v8::Integer::New(19)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 20);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(19));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_default(10, 13)", v8::Integer::New(13)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 20);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(13));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_inherited(9)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -3);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(9));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QVariant(9)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 21);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(9));
- QCOMPARE(o.actuals().at(1), QVariant());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QVariant(\"Hello\", \"World\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 21);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(QString("Hello")));
- QCOMPARE(o.actuals().at(1), QVariant(QString("World")));
-}
-
-// QTBUG-13047 (check that you can pass registered object types as args)
-void tst_qdeclarativeecmascript::invokableObjectArg()
-{
- QDeclarativeComponent component(&engine, testFileUrl("invokableObjectArg.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
- MyQmlObject *qmlobject = qobject_cast<MyQmlObject *>(o);
- QVERIFY(qmlobject);
- QCOMPARE(qmlobject->myinvokableObject, qmlobject);
-
- delete o;
-}
-
-// QTBUG-13047 (check that you can return registered object types from methods)
-void tst_qdeclarativeecmascript::invokableObjectRet()
-{
- QDeclarativeComponent component(&engine, testFileUrl("invokableObjectRet.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-// QTBUG-5675
-void tst_qdeclarativeecmascript::listToVariant()
-{
- QDeclarativeComponent component(&engine, testFileUrl("listToVariant.qml"));
-
- MyQmlContainer container;
-
- QDeclarativeContext context(engine.rootContext());
- context.setContextObject(&container);
-
- QObject *object = component.create(&context);
- QVERIFY(object != 0);
-
- QVariant v = object->property("test");
- QCOMPARE(v.userType(), qMetaTypeId<QDeclarativeListReference>());
- QVERIFY(qvariant_cast<QDeclarativeListReference>(v).object() == &container);
-
- delete object;
-}
-
-// QTBUG-16316
-Q_DECLARE_METATYPE(QDeclarativeListProperty<MyQmlObject>)
-void tst_qdeclarativeecmascript::listAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("listAssignment.qml"));
- QObject *obj = component.create();
- QCOMPARE(obj->property("list1length").toInt(), 2);
- QDeclarativeListProperty<MyQmlObject> list1 = obj->property("list1").value<QDeclarativeListProperty<MyQmlObject> >();
- QDeclarativeListProperty<MyQmlObject> list2 = obj->property("list2").value<QDeclarativeListProperty<MyQmlObject> >();
- QCOMPARE(list1.count(&list1), list2.count(&list2));
- QCOMPARE(list1.at(&list1, 0), list2.at(&list2, 0));
- QCOMPARE(list1.at(&list1, 1), list2.at(&list2, 1));
- delete obj;
-}
-
-// QTBUG-7957
-void tst_qdeclarativeecmascript::multiEngineObject()
-{
- MyQmlObject obj;
- obj.setStringProperty("Howdy planet");
-
- QDeclarativeEngine e1;
- e1.rootContext()->setContextProperty("thing", &obj);
- QDeclarativeComponent c1(&e1, testFileUrl("multiEngineObject.qml"));
-
- QDeclarativeEngine e2;
- e2.rootContext()->setContextProperty("thing", &obj);
- QDeclarativeComponent c2(&e2, testFileUrl("multiEngineObject.qml"));
-
- QObject *o1 = c1.create();
- QObject *o2 = c2.create();
-
- QCOMPARE(o1->property("test").toString(), QString("Howdy planet"));
- QCOMPARE(o2->property("test").toString(), QString("Howdy planet"));
-
- delete o2;
- delete o1;
-}
-
-// Test that references to QObjects are cleanup when the object is destroyed
-void tst_qdeclarativeecmascript::deletedObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deletedObject.qml"));
-
- QObject *object = component.create();
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::attachedPropertyScope()
-{
- QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyScope.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- MyQmlAttachedObject *attached =
- qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
- QVERIFY(attached != 0);
-
- QCOMPARE(object->property("value2").toInt(), 0);
-
- attached->emitMySignal();
-
- QCOMPARE(object->property("value2").toInt(), 9);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::scriptConnect()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.1.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.2.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.3.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.4.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->methodCalled(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.5.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->methodCalled(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.6.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::scriptDisconnect()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.1.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->basicSignal();
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.2.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->basicSignal();
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.3.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->basicSignal();
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 3);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.4.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->basicSignal();
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 3);
-
- delete object;
- }
-}
-
-class OwnershipObject : public QObject
-{
- Q_OBJECT
-public:
- OwnershipObject() { object = new QObject; }
-
- QPointer<QObject> object;
-
-public slots:
- QObject *getObject() { return object; }
-};
-
-void tst_qdeclarativeecmascript::ownership()
-{
- OwnershipObject own;
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- context->setContextObject(&own);
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("ownership.qml"));
-
- QVERIFY(own.object != 0);
-
- QObject *object = component.create(context);
-
- engine.collectGarbage();
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(own.object == 0);
-
- delete object;
- }
-
- own.object = new QObject(&own);
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("ownership.qml"));
-
- QVERIFY(own.object != 0);
-
- QObject *object = component.create(context);
-
- engine.collectGarbage();
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(own.object != 0);
-
- delete object;
- }
-
- delete context;
-}
-
-class CppOwnershipReturnValue : public QObject
-{
- Q_OBJECT
-public:
- CppOwnershipReturnValue() : value(0) {}
- ~CppOwnershipReturnValue() { delete value; }
-
- Q_INVOKABLE QObject *create() {
- value = new QObject;
- QDeclarativeEngine::setObjectOwnership(value, QDeclarativeEngine::CppOwnership);
- return value;
- }
-
- Q_INVOKABLE MyQmlObject *createQmlObject() {
- MyQmlObject *rv = new MyQmlObject;
- value = rv;
- return rv;
- }
-
- QPointer<QObject> value;
-};
-
-// QTBUG-15695.
-// Test setObjectOwnership(CppOwnership) works even when there is no QDeclarativeData
-void tst_qdeclarativeecmascript::cppOwnershipReturnValue()
-{
- CppOwnershipReturnValue source;
-
- {
- QDeclarativeEngine engine;
- engine.rootContext()->setContextProperty("source", &source);
-
- QVERIFY(source.value == 0);
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl());
-
- QObject *object = component.create();
-
- QVERIFY(object != 0);
- QVERIFY(source.value != 0);
-
- delete object;
- }
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(source.value != 0);
-}
-
-// QTBUG-15697
-void tst_qdeclarativeecmascript::ownershipCustomReturnValue()
-{
- CppOwnershipReturnValue source;
-
- {
- QDeclarativeEngine engine;
- engine.rootContext()->setContextProperty("source", &source);
-
- QVERIFY(source.value == 0);
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl());
-
- QObject *object = component.create();
-
- QVERIFY(object != 0);
- QVERIFY(source.value != 0);
-
- delete object;
- }
-
- engine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(source.value == 0);
-}
-
-class QListQObjectMethodsObject : public QObject
-{
- Q_OBJECT
-public:
- QListQObjectMethodsObject() {
- m_objects.append(new MyQmlObject());
- m_objects.append(new MyQmlObject());
- }
-
- ~QListQObjectMethodsObject() {
- qDeleteAll(m_objects);
- }
-
-public slots:
- QList<QObject *> getObjects() { return m_objects; }
-
-private:
- QList<QObject *> m_objects;
-};
-
-// Tests that returning a QList<QObject*> from a method works
-void tst_qdeclarativeecmascript::qlistqobjectMethods()
-{
- QListQObjectMethodsObject obj;
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- context->setContextObject(&obj);
-
- QDeclarativeComponent component(&engine, testFileUrl("qlistqobjectMethods.qml"));
-
- QObject *object = component.create(context);
-
- QCOMPARE(object->property("test").toInt(), 2);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
- delete context;
-}
-
-// QTBUG-9205
-void tst_qdeclarativeecmascript::strictlyEquals()
-{
- QDeclarativeComponent component(&engine, testFileUrl("strictlyEquals.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
- QCOMPARE(object->property("test5").toBool(), true);
- QCOMPARE(object->property("test6").toBool(), true);
- QCOMPARE(object->property("test7").toBool(), true);
- QCOMPARE(object->property("test8").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::compiled()
-{
- QDeclarativeComponent component(&engine, testFileUrl("compiled.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toReal(), qreal(15.7));
- QCOMPARE(object->property("test2").toReal(), qreal(-6.7));
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), false);
- QCOMPARE(object->property("test5").toBool(), false);
- QCOMPARE(object->property("test6").toBool(), true);
-
- QCOMPARE(object->property("test7").toInt(), 185);
- QCOMPARE(object->property("test8").toInt(), 167);
- QCOMPARE(object->property("test9").toBool(), true);
- QCOMPARE(object->property("test10").toBool(), false);
- QCOMPARE(object->property("test11").toBool(), false);
- QCOMPARE(object->property("test12").toBool(), true);
-
- QCOMPARE(object->property("test13").toString(), QLatin1String("HelloWorld"));
- QCOMPARE(object->property("test14").toString(), QLatin1String("Hello World"));
- QCOMPARE(object->property("test15").toBool(), false);
- QCOMPARE(object->property("test16").toBool(), true);
-
- QCOMPARE(object->property("test17").toInt(), 5);
- QCOMPARE(object->property("test18").toReal(), qreal(176));
- QCOMPARE(object->property("test19").toInt(), 7);
- QCOMPARE(object->property("test20").toReal(), qreal(6.7));
- QCOMPARE(object->property("test21").toString(), QLatin1String("6.7"));
- QCOMPARE(object->property("test22").toString(), QLatin1String("!"));
- QCOMPARE(object->property("test23").toBool(), true);
- QCOMPARE(qvariant_cast<QColor>(object->property("test24")), QColor(0x11,0x22,0x33));
- QCOMPARE(qvariant_cast<QColor>(object->property("test25")), QColor(0x11,0x22,0x33,0xAA));
-
- delete object;
-}
-
-// Test that numbers assigned in bindings as strings work consistently
-void tst_qdeclarativeecmascript::numberAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("numberAssignment.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1"), QVariant((qreal)6.7));
- QCOMPARE(object->property("test2"), QVariant((qreal)6.7));
- QCOMPARE(object->property("test2"), QVariant((qreal)6.7));
- QCOMPARE(object->property("test3"), QVariant((qreal)6));
- QCOMPARE(object->property("test4"), QVariant((qreal)6));
-
- QCOMPARE(object->property("test5"), QVariant((int)7));
- QCOMPARE(object->property("test6"), QVariant((int)7));
- QCOMPARE(object->property("test7"), QVariant((int)6));
- QCOMPARE(object->property("test8"), QVariant((int)6));
-
- QCOMPARE(object->property("test9"), QVariant((unsigned int)7));
- QCOMPARE(object->property("test10"), QVariant((unsigned int)7));
- QCOMPARE(object->property("test11"), QVariant((unsigned int)6));
- QCOMPARE(object->property("test12"), QVariant((unsigned int)6));
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertySplicing()
-{
- QDeclarativeComponent component(&engine, testFileUrl("propertySplicing.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// QTBUG-16683
-void tst_qdeclarativeecmascript::signalWithUnknownTypes()
-{
- QDeclarativeComponent component(&engine, testFileUrl("signalWithUnknownTypes.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- MyQmlObject::MyType type;
- type.value = 0x8971123;
- emit object->signalWithUnknownType(type);
-
- MyQmlObject::MyType result = qvariant_cast<MyQmlObject::MyType>(object->variant());
-
- QCOMPARE(result.value, type.value);
-
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::signalWithJSValueInVariant_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QString>("compare");
-
- QString compareStrict("(function(a, b) { return a === b; })");
- QTest::newRow("true") << "true" << compareStrict;
- QTest::newRow("undefined") << "undefined" << compareStrict;
- QTest::newRow("null") << "null" << compareStrict;
- QTest::newRow("123") << "123" << compareStrict;
- QTest::newRow("'ciao'") << "'ciao'" << compareStrict;
-
- QString comparePropertiesStrict(
- "(function(a, b) {"
- " if (typeof b != 'object')"
- " return a === b;"
- " var props = Object.getOwnPropertyNames(b);"
- " for (var i = 0; i < props.length; ++i) {"
- " var p = props[i];"
- " return arguments.callee(a[p], b[p]);"
- " }"
- "})");
- QTest::newRow("{ foo: 'bar' }") << "({ foo: 'bar' })" << comparePropertiesStrict;
- QTest::newRow("[10,20,30]") << "[10,20,30]" << comparePropertiesStrict;
-}
-
-void tst_qdeclarativeecmascript::signalWithJSValueInVariant()
-{
- QFETCH(QString, expression);
- QFETCH(QString, compare);
-
- QDeclarativeComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
- QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
- QVERIFY(object != 0);
-
- QJSValue value = engine.evaluate(expression);
- QVERIFY(!engine.hasUncaughtException());
- object->setProperty("expression", expression);
- object->setProperty("compare", compare);
- object->setProperty("pass", false);
-
- emit object->signalWithVariant(QVariant::fromValue(value));
- QVERIFY(object->property("pass").toBool());
-}
-
-void tst_qdeclarativeecmascript::signalWithJSValueInVariant_twoEngines_data()
-{
- signalWithJSValueInVariant_data();
-}
-
-void tst_qdeclarativeecmascript::signalWithJSValueInVariant_twoEngines()
-{
- QFETCH(QString, expression);
- QFETCH(QString, compare);
-
- QDeclarativeComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
- QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
- QVERIFY(object != 0);
-
- QJSEngine engine2;
- QJSValue value = engine2.evaluate(expression);
- QVERIFY(!engine2.hasUncaughtException());
- object->setProperty("expression", expression);
- object->setProperty("compare", compare);
- object->setProperty("pass", false);
-
- QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine.");
- emit object->signalWithVariant(QVariant::fromValue(value));
- QVERIFY(!object->property("pass").toBool());
-}
-
-void tst_qdeclarativeecmascript::signalWithQJSValue_data()
-{
- signalWithJSValueInVariant_data();
-}
-
-void tst_qdeclarativeecmascript::signalWithQJSValue()
-{
- QFETCH(QString, expression);
- QFETCH(QString, compare);
-
- QDeclarativeComponent component(&engine, testFileUrl("signalWithQJSValue.qml"));
- QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
- QVERIFY(object != 0);
-
- QJSValue value = engine.evaluate(expression);
- QVERIFY(!engine.hasUncaughtException());
- object->setProperty("expression", expression);
- object->setProperty("compare", compare);
- object->setProperty("pass", false);
-
- emit object->signalWithQJSValue(value);
-
- QVERIFY(object->property("pass").toBool());
- QVERIFY(object->qjsvalue().strictlyEquals(value));
-}
-
-void tst_qdeclarativeecmascript::moduleApi_data()
-{
- QTest::addColumn<QUrl>("testfile");
- QTest::addColumn<QString>("errorMessage");
- QTest::addColumn<QStringList>("warningMessages");
- QTest::addColumn<QStringList>("readProperties");
- QTest::addColumn<QVariantList>("readExpectedValues");
- QTest::addColumn<QStringList>("writeProperties");
- QTest::addColumn<QVariantList>("writeValues");
- QTest::addColumn<QStringList>("readBackProperties");
- QTest::addColumn<QVariantList>("readBackExpectedValues");
-
- QTest::newRow("qobject, register + read + method")
- << testFileUrl("moduleapi/qobjectModuleApi.qml")
- << QString()
- << QStringList()
- << (QStringList() << "existingUriTest" << "qobjectTest" << "qobjectMethodTest"
- << "qobjectMinorVersionTest" << "qobjectMajorVersionTest" << "qobjectParentedTest")
- << (QVariantList() << 20 << 20 << 1 << 20 << 20 << 26)
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("script, register + read")
- << testFileUrl("moduleapi/scriptModuleApi.qml")
- << QString()
- << QStringList()
- << (QStringList() << "scriptTest")
- << (QVariantList() << 13)
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("qobject, caching + read")
- << testFileUrl("moduleapi/qobjectModuleApiCaching.qml")
- << QString()
- << QStringList()
- << (QStringList() << "existingUriTest" << "qobjectParentedTest")
- << (QVariantList() << 20 << 26) // 26, shouldn't have incremented to 27.
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("script, caching + read")
- << testFileUrl("moduleapi/scriptModuleApiCaching.qml")
- << QString()
- << QStringList()
- << (QStringList() << "scriptTest")
- << (QVariantList() << 13) // 13, shouldn't have incremented to 14.
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("qobject, writing + readonly constraints")
- << testFileUrl("moduleapi/qobjectModuleApiWriting.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
- << (QStringList() << "readOnlyProperty" << "writableProperty")
- << (QVariantList() << 20 << 50)
- << (QStringList() << "firstProperty" << "writableProperty")
- << (QVariantList() << 30 << 30)
- << (QStringList() << "readOnlyProperty" << "writableProperty")
- << (QVariantList() << 20 << 30);
-
- QTest::newRow("script, writing + readonly constraints")
- << testFileUrl("moduleapi/scriptModuleApiWriting.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
- << (QStringList() << "readBack" << "unchanged")
- << (QVariantList() << 13 << 42)
- << (QStringList() << "firstProperty" << "secondProperty")
- << (QVariantList() << 30 << 30)
- << (QStringList() << "readBack" << "unchanged")
- << (QVariantList() << 30 << 42);
-
- QTest::newRow("qobject module API enum values in JS")
- << testFileUrl("moduleapi/qobjectModuleApiEnums.qml")
- << QString()
- << QStringList()
- << (QStringList() << "enumValue" << "enumMethod")
- << (QVariantList() << 42 << 30)
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("qobject, invalid major version fail")
- << testFileUrl("moduleapi/moduleApiMajorVersionFail.qml")
- << QString("QDeclarativeComponent: Component is not ready")
- << QStringList()
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("qobject, invalid minor version fail")
- << testFileUrl("moduleapi/moduleApiMinorVersionFail.qml")
- << QString("QDeclarativeComponent: Component is not ready")
- << QStringList()
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-}
-
-void tst_qdeclarativeecmascript::moduleApi()
-{
- QFETCH(QUrl, testfile);
- QFETCH(QString, errorMessage);
- QFETCH(QStringList, warningMessages);
- QFETCH(QStringList, readProperties);
- QFETCH(QVariantList, readExpectedValues);
- QFETCH(QStringList, writeProperties);
- QFETCH(QVariantList, writeValues);
- QFETCH(QStringList, readBackProperties);
- QFETCH(QVariantList, readBackExpectedValues);
-
- QDeclarativeComponent component(&engine, testfile);
-
- if (!errorMessage.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData());
-
- if (warningMessages.size())
- foreach (const QString &warning, warningMessages)
- QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
-
- QObject *object = component.create();
- if (!errorMessage.isEmpty()) {
- QVERIFY(object == 0);
- } else {
- QVERIFY(object != 0);
- for (int i = 0; i < readProperties.size(); ++i)
- QCOMPARE(object->property(readProperties.at(i).toAscii().constData()), readExpectedValues.at(i));
- for (int i = 0; i < writeProperties.size(); ++i)
- QVERIFY(object->setProperty(writeProperties.at(i).toAscii().constData(), writeValues.at(i)));
- for (int i = 0; i < readBackProperties.size(); ++i)
- QCOMPARE(object->property(readBackProperties.at(i).toAscii().constData()), readBackExpectedValues.at(i));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::importScripts_data()
-{
- QTest::addColumn<QUrl>("testfile");
- QTest::addColumn<QString>("errorMessage");
- QTest::addColumn<QStringList>("warningMessages");
- QTest::addColumn<QStringList>("propertyNames");
- QTest::addColumn<QVariantList>("propertyValues");
-
- QTest::newRow("basic functionality")
- << testFileUrl("jsimport/testImport.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("importedScriptStringValue")
- << QLatin1String("importedScriptFunctionValue")
- << QLatin1String("importedModuleAttachedPropertyValue")
- << QLatin1String("importedModuleEnumValue"))
- << (QVariantList() << QVariant(QLatin1String("Hello, World!"))
- << QVariant(20)
- << QVariant(19)
- << QVariant(2));
-
- QTest::newRow("import scoping")
- << testFileUrl("jsimport/testImportScoping.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("componentError"))
- << (QVariantList() << QVariant(5));
-
- QTest::newRow("parent scope shouldn't be inherited by import with imports")
- << testFileUrl("jsimportfail/failOne.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined")))
- << (QStringList() << QLatin1String("importScriptFunctionValue"))
- << (QVariantList() << QVariant(QString()));
-
- QTest::newRow("javascript imports in an import should be private to the import scope")
- << testFileUrl("jsimportfail/failTwo.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs")))
- << (QStringList() << QLatin1String("importScriptFunctionValue"))
- << (QVariantList() << QVariant(QString()));
-
- QTest::newRow("module imports in an import should be private to the import scope")
- << testFileUrl("jsimportfail/failThree.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined")))
- << (QStringList() << QLatin1String("importedModuleAttachedPropertyValue"))
- << (QVariantList() << QVariant(false));
-
- QTest::newRow("typenames in an import should be private to the import scope")
- << testFileUrl("jsimportfail/failFour.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest")))
- << (QStringList() << QLatin1String("importedModuleEnumValue"))
- << (QVariantList() << QVariant(0));
-
- QTest::newRow("import with imports has it's own activation scope")
- << testFileUrl("jsimportfail/failFive.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component")))
- << (QStringList() << QLatin1String("componentError"))
- << (QVariantList() << QVariant(0));
-
- QTest::newRow("import pragma library script")
- << testFileUrl("jsimport/testImportPragmaLibrary.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(31));
-
- QTest::newRow("pragma library imports shouldn't inherit parent imports or scope")
- << testFileUrl("jsimportfail/testImportPragmaLibrary.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component")))
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(0));
-
- QTest::newRow("import pragma library script which has an import")
- << testFileUrl("jsimport/testImportPragmaLibraryWithImports.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(55));
-
- QTest::newRow("import pragma library script which has a pragma library import")
- << testFileUrl("jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(18));
-
- QTest::newRow("import module api into js import")
- << testFileUrl("jsimport/testImportModuleApi.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(20));
-}
-
-void tst_qdeclarativeecmascript::importScripts()
-{
- QFETCH(QUrl, testfile);
- QFETCH(QString, errorMessage);
- QFETCH(QStringList, warningMessages);
- QFETCH(QStringList, propertyNames);
- QFETCH(QVariantList, propertyValues);
-
- QDeclarativeComponent component(&engine, testfile);
-
- if (!errorMessage.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData());
-
- if (warningMessages.size())
- foreach (const QString &warning, warningMessages)
- QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
-
- QObject *object = component.create();
- if (!errorMessage.isEmpty()) {
- QVERIFY(object == 0);
- } else {
- QVERIFY(object != 0);
- for (int i = 0; i < propertyNames.size(); ++i)
- QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::scarceResources_other()
-{
- /* These tests require knowledge of state, since we test values after
- performing signal or function invocation. */
-
- QPixmap origPixmap(100, 100);
- origPixmap.fill(Qt::blue);
- QString srp_name, expectedWarning;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&engine);
- ScarceResourceObject *eo = 0;
- QObject *srsc = 0;
- QObject *object = 0;
-
- /* property var semantics */
-
- // test that scarce resources are handled properly in signal invocation
- QDeclarativeComponent varComponentTen(&engine, testFileUrl("scarceResourceSignal.var.qml"));
- object = varComponentTen.create();
- srsc = object->findChild<QObject*>("srsc");
- QVERIFY(srsc);
- QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet.
- QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QMetaObject::invokeMethod(srsc, "testSignal");
- QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated
- QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage.
- QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap.
- QVERIFY(srsc->property("scarceResourceCopy").isValid());
- QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that scarce resources are handled properly from js functions in qml files
- QDeclarativeComponent varComponentEleven(&engine, testFileUrl("scarceResourceFunction.var.qml"));
- object = varComponentEleven.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid.
- QCOMPARE(object->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage.
- QMetaObject::invokeMethod(object, "releaseScarceResource");
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that if an exception occurs while invoking js function from cpp, that the resources are released.
- QDeclarativeComponent varComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
- object = varComponentTwelve.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- srp_name = object->property("srp_name").toString();
- expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that if an Item which has JS ownership but has a scarce resource property is garbage collected,
- // that the scarce resource is removed from the engine's list of scarce resources to clean up.
- QDeclarativeComponent varComponentThirteen(&engine, testFileUrl("scarceResourceObjectGc.var.qml"));
- object = varComponentThirteen.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("varProperty").isValid()); // not assigned yet
- QMetaObject::invokeMethod(object, "assignVarProperty");
- QVERIFY(ep->scarceResources.isEmpty()); // the scarce resource is a VME property.
- QMetaObject::invokeMethod(object, "deassignVarProperty");
- QVERIFY(ep->scarceResources.isEmpty()); // should still be empty; the resource should have been released on gc.
- delete object;
-
- /* property variant semantics */
-
- // test that scarce resources are handled properly in signal invocation
- QDeclarativeComponent variantComponentTen(&engine, testFileUrl("scarceResourceSignal.variant.qml"));
- object = variantComponentTen.create();
- QVERIFY(object != 0);
- srsc = object->findChild<QObject*>("srsc");
- QVERIFY(srsc);
- QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet.
- QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QMetaObject::invokeMethod(srsc, "testSignal");
- QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated
- QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage.
- QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap.
- QVERIFY(srsc->property("scarceResourceCopy").isValid());
- QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that scarce resources are handled properly from js functions in qml files
- QDeclarativeComponent variantComponentEleven(&engine, testFileUrl("scarceResourceFunction.variant.qml"));
- object = variantComponentEleven.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid.
- QCOMPARE(object->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage.
- QMetaObject::invokeMethod(object, "releaseScarceResource");
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that if an exception occurs while invoking js function from cpp, that the resources are released.
- QDeclarativeComponent variantComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.variant.qml"));
- object = variantComponentTwelve.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- srp_name = object->property("srp_name").toString();
- expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-}
-
-void tst_qdeclarativeecmascript::scarceResources_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<bool>("readDetachStatus");
- QTest::addColumn<bool>("expectedDetachStatus");
- QTest::addColumn<QStringList>("propertyNames");
- QTest::addColumn<QVariantList>("expectedValidity");
- QTest::addColumn<QVariantList>("expectedValues");
- QTest::addColumn<QStringList>("expectedErrors");
-
- QPixmap origPixmap(100, 100);
- origPixmap.fill(Qt::blue);
-
- /* property var semantics */
-
- // in the following three cases, the instance created from the component
- // has a property which is a copy of the scarce resource; hence, the
- // resource should NOT be detached prior to deletion of the object instance,
- // unless the resource is destroyed explicitly.
- QTest::newRow("var: import scarce resource copy directly")
- << testFileUrl("scarceResourceCopy.var.qml")
- << true
- << false // won't be detached, because assigned to property and not explicitly released
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << origPixmap)
- << QStringList();
-
- QTest::newRow("var: import scarce resource copy from JS")
- << testFileUrl("scarceResourceCopyFromJs.var.qml")
- << true
- << false // won't be detached, because assigned to property and not explicitly released
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << origPixmap)
- << QStringList();
-
- QTest::newRow("var: import released scarce resource copy from JS")
- << testFileUrl("scarceResourceDestroyedCopy.var.qml")
- << true
- << true // explicitly released, so it will be detached
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << false)
- << (QList<QVariant>() << QVariant())
- << QStringList();
-
- // in the following three cases, no other copy should exist in memory,
- // and so it should be detached (unless explicitly preserved).
- QTest::newRow("var: import auto-release SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTest.var.qml")
- << true
- << true // auto released, so it will be detached
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
- QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTestPreserve.var.qml")
- << true
- << false // won't be detached because we explicitly preserve it
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
- QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTestMultiple.var.qml")
- << true
- << true // will be detached because all resources were released manually or automatically.
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
-
- // In the following three cases, test that scarce resources are handled
- // correctly for imports.
- QTest::newRow("var: import with no binding")
- << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
- << false // cannot check detach status.
- << false
- << QStringList()
- << QList<QVariant>()
- << QList<QVariant>()
- << QStringList();
- QTest::newRow("var: import with binding without explicit preserve")
- << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << false) // will have been released prior to evaluation of binding.
- << (QList<QVariant>() << QVariant())
- << QStringList();
- QTest::newRow("var: import with explicit release after binding evaluation")
- << testFileUrl("scarceResourceCopyImport.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
- << (QList<QVariant>() << false << false << false << true) // since property var = JS object reference, by releasing the provider's resource, all handles are invalidated.
- << (QList<QVariant>() << QVariant() << QVariant() << QVariant() << QVariant(true))
- << QStringList();
- QTest::newRow("var: import with different js objects")
- << testFileUrl("scarceResourceCopyImportDifferent.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
- << (QList<QVariant>() << false << true << true) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object.
- << (QList<QVariant>() << QVariant() << QVariant(origPixmap) << QVariant(false))
- << QStringList();
- QTest::newRow("var: import with different js objects and explicit release")
- << testFileUrl("scarceResourceMultipleDifferentNoBinding.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
- << (QList<QVariant>() << true << false) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object.
- << (QList<QVariant>() << QVariant(origPixmap) << QVariant())
- << QStringList();
- QTest::newRow("var: import with same js objects and explicit release")
- << testFileUrl("scarceResourceMultipleSameNoBinding.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
- << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object.
- << (QList<QVariant>() << QVariant() << QVariant())
- << QStringList();
- QTest::newRow("var: binding with same js objects and explicit release")
- << testFileUrl("scarceResourceMultipleSameWithBinding.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
- << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object.
- << (QList<QVariant>() << QVariant() << QVariant())
- << QStringList();
-
-
- /* property variant semantics */
-
- // in the following three cases, the instance created from the component
- // has a property which is a copy of the scarce resource; hence, the
- // resource should NOT be detached prior to deletion of the object instance,
- // unless the resource is destroyed explicitly.
- QTest::newRow("variant: import scarce resource copy directly")
- << testFileUrl("scarceResourceCopy.variant.qml")
- << true
- << false // won't be detached, because assigned to property and not explicitly released
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << origPixmap)
- << QStringList();
-
- QTest::newRow("variant: import scarce resource copy from JS")
- << testFileUrl("scarceResourceCopyFromJs.variant.qml")
- << true
- << false // won't be detached, because assigned to property and not explicitly released
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << origPixmap)
- << QStringList();
-
- QTest::newRow("variant: import released scarce resource copy from JS")
- << testFileUrl("scarceResourceDestroyedCopy.variant.qml")
- << true
- << true // explicitly released, so it will be detached
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << false)
- << (QList<QVariant>() << QVariant())
- << QStringList();
-
- // in the following three cases, no other copy should exist in memory,
- // and so it should be detached (unless explicitly preserved).
- QTest::newRow("variant: import auto-release SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTest.variant.qml")
- << true
- << true // auto released, so it will be detached
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
- QTest::newRow("variant: import explicit-preserve SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTestPreserve.variant.qml")
- << true
- << false // won't be detached because we explicitly preserve it
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
- QTest::newRow("variant: import multiple scarce resources")
- << testFileUrl("scarceResourceTestMultiple.variant.qml")
- << true
- << true // will be detached because all resources were released manually or automatically.
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
-
- // In the following three cases, test that scarce resources are handled
- // correctly for imports.
- QTest::newRow("variant: import with no binding")
- << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
- << false // cannot check detach status.
- << false
- << QStringList()
- << QList<QVariant>()
- << QList<QVariant>()
- << QStringList();
- QTest::newRow("variant: import with binding without explicit preserve")
- << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << false) // will have been released prior to evaluation of binding.
- << (QList<QVariant>() << QVariant())
- << QStringList();
- QTest::newRow("variant: import with explicit release after binding evaluation")
- << testFileUrl("scarceResourceCopyImport.variant.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo"))
- << (QList<QVariant>() << true << true << false) // since property variant = variant copy, releasing the provider's resource does not invalidate previously assigned copies.
- << (QList<QVariant>() << origPixmap << origPixmap << QVariant())
- << QStringList();
-}
-
-void tst_qdeclarativeecmascript::scarceResources()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(bool, readDetachStatus);
- QFETCH(bool, expectedDetachStatus);
- QFETCH(QStringList, propertyNames);
- QFETCH(QVariantList, expectedValidity);
- QFETCH(QVariantList, expectedValues);
- QFETCH(QStringList, expectedErrors);
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&engine);
- ScarceResourceObject *eo = 0;
- QObject *object = 0;
-
- QDeclarativeComponent c(&engine, qmlFile);
- object = c.create();
- QVERIFY(object != 0);
- for (int i = 0; i < propertyNames.size(); ++i) {
- QString prop = propertyNames.at(i);
- bool validity = expectedValidity.at(i).toBool();
- QVariant value = expectedValues.at(i);
-
- QCOMPARE(object->property(prop.toLatin1().constData()).isValid(), validity);
- if (value.type() == QVariant::Int) {
- QCOMPARE(object->property(prop.toLatin1().constData()).toInt(), value.toInt());
- } else if (value.type() == QVariant::Pixmap) {
- QCOMPARE(object->property(prop.toLatin1().constData()).value<QPixmap>(), value.value<QPixmap>());
- }
- }
-
- if (readDetachStatus) {
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QCOMPARE(eo->scarceResourceIsDetached(), expectedDetachStatus);
- }
-
- QVERIFY(ep->scarceResources.isEmpty());
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyChangeSlots()
-{
- // ensure that allowable property names are allowed and onPropertyNameChanged slots are generated correctly.
- QDeclarativeComponent component(&engine, testFileUrl("changeslots/propertyChangeSlots.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-
- // ensure that invalid property names fail properly.
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e1(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.1.qml"));
- QString expectedErrorString = e1.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_nameWithUnderscoreChanged\"");
- QCOMPARE(e1.errors().at(0).toString(), expectedErrorString);
- object = e1.create();
- QVERIFY(object == 0);
- delete object;
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e2(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.2.qml"));
- expectedErrorString = e2.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on____nameWithUnderscoresChanged\"");
- QCOMPARE(e2.errors().at(0).toString(), expectedErrorString);
- object = e2.create();
- QVERIFY(object == 0);
- delete object;
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e3(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.3.qml"));
- expectedErrorString = e3.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on$NameWithDollarsignChanged\"");
- QCOMPARE(e3.errors().at(0).toString(), expectedErrorString);
- object = e3.create();
- QVERIFY(object == 0);
- delete object;
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e4(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.4.qml"));
- expectedErrorString = e4.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_6NameWithUnderscoreNumberChanged\"");
- QCOMPARE(e4.errors().at(0).toString(), expectedErrorString);
- object = e4.create();
- QVERIFY(object == 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVar_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
-
- // valid
- QTest::newRow("non-bindable object subproperty changed") << testFileUrl("propertyVar.1.qml");
- QTest::newRow("non-bindable object changed") << testFileUrl("propertyVar.2.qml");
- QTest::newRow("primitive changed") << testFileUrl("propertyVar.3.qml");
- QTest::newRow("javascript array modification") << testFileUrl("propertyVar.4.qml");
- QTest::newRow("javascript map modification") << testFileUrl("propertyVar.5.qml");
- QTest::newRow("javascript array assignment") << testFileUrl("propertyVar.6.qml");
- QTest::newRow("javascript map assignment") << testFileUrl("propertyVar.7.qml");
- QTest::newRow("literal property assignment") << testFileUrl("propertyVar.8.qml");
- QTest::newRow("qobject property assignment") << testFileUrl("propertyVar.9.qml");
- QTest::newRow("base class var property assignment") << testFileUrl("propertyVar.10.qml");
-}
-
-void tst_qdeclarativeecmascript::propertyVar()
-{
- QFETCH(QUrl, qmlFile);
-
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Tests that we can write QVariant values to var properties from C++
-void tst_qdeclarativeecmascript::propertyVarCpp()
-{
- QObject *object = 0;
-
- // ensure that writing to and reading from a var property from cpp works as required.
- // Literal values stored in var properties can be read and written as QVariants
- // of a specific type, whereas object values are read as QVariantMaps.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarCpp.qml"));
- object = component.create();
- QVERIFY(object != 0);
- // assign int to property var that currently has int assigned
- QVERIFY(object->setProperty("varProperty", QVariant::fromValue(10)));
- QCOMPARE(object->property("varBound"), QVariant(15));
- QCOMPARE(object->property("intBound"), QVariant(15));
- QCOMPARE(object->property("varProperty").userType(), (int)QVariant::Int);
- QCOMPARE(object->property("varBound").userType(), (int)QVariant::Int);
- // assign string to property var that current has bool assigned
- QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::Bool);
- QVERIFY(object->setProperty("varProperty2", QVariant(QLatin1String("randomString"))));
- QCOMPARE(object->property("varProperty2"), QVariant(QLatin1String("randomString")));
- QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::String);
- // now enforce behaviour when accessing JavaScript objects from cpp.
- QCOMPARE(object->property("jsobject").userType(), (int)QVariant::Map);
- delete object;
-}
-
-static void gc(QDeclarativeEngine &engine)
-{
- engine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-}
-
-void tst_qdeclarativeecmascript::propertyVarOwnership()
-{
- // Referenced JS objects are not collected
- {
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toBool(), false);
- QMetaObject::invokeMethod(object, "runTest");
- QCOMPARE(object->property("test").toBool(), true);
- delete object;
- }
- // Referenced JS objects are not collected
- {
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toBool(), false);
- QMetaObject::invokeMethod(object, "runTest");
- QCOMPARE(object->property("test").toBool(), true);
- delete object;
- }
- // Qt objects are not collected until they've been dereferenced
- {
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test2").toBool(), false);
- QCOMPARE(object->property("test2").toBool(), false);
-
- QMetaObject::invokeMethod(object, "runTest");
- QCOMPARE(object->property("test1").toBool(), true);
-
- QPointer<QObject> referencedObject = object->property("object").value<QObject*>();
- QVERIFY(!referencedObject.isNull());
- gc(engine);
- QVERIFY(!referencedObject.isNull());
-
- QMetaObject::invokeMethod(object, "runTest2");
- QCOMPARE(object->property("test2").toBool(), true);
- gc(engine);
- QVERIFY(referencedObject.isNull());
-
- delete object;
- }
- // Self reference does not prevent Qt object collection
- {
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- QPointer<QObject> referencedObject = object->property("object").value<QObject*>();
- QVERIFY(!referencedObject.isNull());
- gc(engine);
- QVERIFY(!referencedObject.isNull());
-
- QMetaObject::invokeMethod(object, "runTest");
- gc(engine);
- QVERIFY(referencedObject.isNull());
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::propertyVarImplicitOwnership()
-{
- // The childObject has a reference to a different QObject. We want to ensure
- // that the different item will not be cleaned up until required. IE, the childObject
- // has implicit ownership of the constructed QObject.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarImplicitOwnership.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rootObject = object->property("vp").value<QObject*>();
- QVERIFY(rootObject != 0);
- QObject *childObject = rootObject->findChild<QObject*>("text");
- QVERIFY(childObject != 0);
- QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
- QCOMPARE(childObject->property("textCanary").toInt(), 10);
- QMetaObject::invokeMethod(childObject, "constructQObject"); // creates a reference to a constructed QObject.
- QWeakPointer<QObject> qobjectGuard(childObject->property("vp").value<QObject*>()); // get the pointer prior to processing deleteLater events.
- QVERIFY(!qobjectGuard.isNull());
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(!qobjectGuard.isNull());
- QMetaObject::invokeMethod(object, "deassignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(qobjectGuard.isNull()); // should have been collected now.
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVarReparent()
-{
- // ensure that nothing breaks if we re-parent objects
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignVarProp");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rect = object->property("vp").value<QObject*>();
- QObject *text = rect->findChild<QObject*>("textOne");
- QObject *text2 = rect->findChild<QObject*>("textTwo");
- QWeakPointer<QObject> rectGuard(rect);
- QWeakPointer<QObject> textGuard(text);
- QWeakPointer<QObject> text2Guard(text2);
- QVERIFY(!rectGuard.isNull());
- QVERIFY(!textGuard.isNull());
- QVERIFY(!text2Guard.isNull());
- QCOMPARE(text->property("textCanary").toInt(), 11);
- QCOMPARE(text2->property("textCanary").toInt(), 12);
- // now construct an image which we will reparent.
- QMetaObject::invokeMethod(text2, "constructQObject");
- QObject *image = text2->property("vp").value<QObject*>();
- QWeakPointer<QObject> imageGuard(image);
- QVERIFY(!imageGuard.isNull());
- QCOMPARE(image->property("imageCanary").toInt(), 13);
- // now reparent the "Image" object (currently, it has JS ownership)
- image->setParent(text); // shouldn't be collected after deassignVp now, since has a parent.
- QMetaObject::invokeMethod(text2, "deassignVp");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QCOMPARE(text->property("textCanary").toInt(), 11);
- QCOMPARE(text2->property("textCanary").toInt(), 22);
- QVERIFY(!imageGuard.isNull()); // should still be alive.
- QCOMPARE(image->property("imageCanary").toInt(), 13); // still able to access var properties
- QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(imageGuard.isNull()); // should now have been deleted, due to parent being deleted.
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVarReparentNullContext()
-{
- // sometimes reparenting can cause problems
- // (eg, if the ctxt is collected, varproperties are no longer available)
- // this test ensures that no crash occurs in that situation.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignVarProp");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rect = object->property("vp").value<QObject*>();
- QObject *text = rect->findChild<QObject*>("textOne");
- QObject *text2 = rect->findChild<QObject*>("textTwo");
- QWeakPointer<QObject> rectGuard(rect);
- QWeakPointer<QObject> textGuard(text);
- QWeakPointer<QObject> text2Guard(text2);
- QVERIFY(!rectGuard.isNull());
- QVERIFY(!textGuard.isNull());
- QVERIFY(!text2Guard.isNull());
- QCOMPARE(text->property("textCanary").toInt(), 11);
- QCOMPARE(text2->property("textCanary").toInt(), 12);
- // now construct an image which we will reparent.
- QMetaObject::invokeMethod(text2, "constructQObject");
- QObject *image = text2->property("vp").value<QObject*>();
- QWeakPointer<QObject> imageGuard(image);
- QVERIFY(!imageGuard.isNull());
- QCOMPARE(image->property("imageCanary").toInt(), 13);
- // now reparent the "Image" object (currently, it has JS ownership)
- image->setParent(object); // reparented to base object. after deassignVarProp, the ctxt will be invalid.
- QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(!imageGuard.isNull()); // should still be alive.
- QVERIFY(!image->property("imageCanary").isValid()); // but varProperties won't be available (null context).
- delete object;
- QVERIFY(imageGuard.isNull()); // should now be dead.
-}
-
-void tst_qdeclarativeecmascript::propertyVarCircular()
-{
- // enforce behaviour regarding circular references - ensure qdvmemo deletion.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QCOMPARE(object->property("canaryInt"), QVariant(5));
- QVariant canaryResourceVariant = object->property("canaryResource");
- QVERIFY(canaryResourceVariant.isValid());
- QPixmap canaryResourcePixmap = canaryResourceVariant.value<QPixmap>();
- canaryResourceVariant = QVariant(); // invalidate it to remove one copy of the pixmap from memory.
- QMetaObject::invokeMethod(object, "deassignCanaryResource"); // remove one copy of the pixmap from memory
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(!canaryResourcePixmap.isDetached()); // two copies extant - this and the propertyVar.vp.vp.vp.vp.memoryHog.
- QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QCOMPARE(object->property("canaryInt"), QVariant(2));
- QCOMPARE(object->property("canaryResource"), QVariant(1));
- QVERIFY(canaryResourcePixmap.isDetached()); // now detached, since orig copy was member of qdvmemo which was deleted.
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVarCircular2()
-{
- // track deletion of JS-owned parent item with Cpp-owned child
- // where the child has a var property referencing its parent.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rootObject = object->property("vp").value<QObject*>();
- QVERIFY(rootObject != 0);
- QObject *childObject = rootObject->findChild<QObject*>("text");
- QVERIFY(childObject != 0);
- QWeakPointer<QObject> rootObjectTracker(rootObject);
- QVERIFY(!rootObjectTracker.isNull());
- QWeakPointer<QObject> childObjectTracker(childObject);
- QVERIFY(!childObjectTracker.isNull());
- gc(engine);
- QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
- QCOMPARE(childObject->property("textCanary").toInt(), 10);
- QMetaObject::invokeMethod(object, "deassignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(rootObjectTracker.isNull()); // should have been collected
- QVERIFY(childObjectTracker.isNull()); // should have been collected
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter)
-{
- *(int*)(parameter) += 1;
- qPersistentDispose(object);
-}
-
-void tst_qdeclarativeecmascript::propertyVarInheritance()
-{
- int propertyVarWeakRefCallbackCount = 0;
-
- // enforce behaviour regarding element inheritance - ensure handle disposal.
- // The particular component under test here has a chain of references.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.inherit.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- // we want to be able to track when the varProperties array of the last metaobject is disposed
- QObject *cco5 = object->property("varProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
- QObject *ico5 = object->property("varProperty").value<QObject*>()->property("inheritanceVarProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
- QDeclarativeVMEMetaObject *icovmemo = ((QDeclarativeVMEMetaObject *)(ico5->metaObject()));
- QDeclarativeVMEMetaObject *ccovmemo = ((QDeclarativeVMEMetaObject *)(cco5->metaObject()));
- v8::Persistent<v8::Value> icoCanaryHandle;
- v8::Persistent<v8::Value> ccoCanaryHandle;
- {
- v8::HandleScope hs;
- // XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only
- // public function which can return us a handle to something in the varProperties array.
- icoCanaryHandle = qPersistentNew(icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ")));
- ccoCanaryHandle = qPersistentNew(ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ")));
- // we make them weak and invoke the gc, but we should not hit the weak-callback yet
- // as the varproperties array of each vmemo still references the resource.
- icoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
- ccoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
- gc(engine);
- QVERIFY(propertyVarWeakRefCallbackCount == 0);
- }
- // now we deassign the var prop, which should trigger collection of item subtrees.
- QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- // ensure that there are only weak handles to the underlying varProperties array remaining.
- gc(engine);
- QCOMPARE(propertyVarWeakRefCallbackCount, 2); // should have been called for both, since all refs should be weak.
- delete object;
- // since there are no parent vmemo's to keep implicit references alive, and the only handles
- // to what remains are weak, all varProperties arrays must have been collected.
-}
-
-void tst_qdeclarativeecmascript::propertyVarInheritance2()
-{
- int propertyVarWeakRefCallbackCount = 0;
-
- // The particular component under test here does NOT have a chain of references; the
- // only link between rootObject and childObject is that rootObject is the parent of childObject.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rootObject = object->property("vp").value<QObject*>();
- QVERIFY(rootObject != 0);
- QObject *childObject = rootObject->findChild<QObject*>("text");
- QVERIFY(childObject != 0);
- QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
- QCOMPARE(childObject->property("textCanary").toInt(), 10);
- v8::Persistent<v8::Value> childObjectVarArrayValueHandle;
- {
- v8::HandleScope hs;
- propertyVarWeakRefCallbackCount = 0; // reset callback count.
- childObjectVarArrayValueHandle = qPersistentNew(((QDeclarativeVMEMetaObject *)(childObject->metaObject()))->vmeProperty(childObject->metaObject()->indexOfProperty("vp")));
- childObjectVarArrayValueHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
- gc(engine);
- QVERIFY(propertyVarWeakRefCallbackCount == 0); // should not have been collected yet.
- QCOMPARE(childObject->property("vp").value<QObject*>(), rootObject);
- QCOMPARE(childObject->property("textCanary").toInt(), 10);
- }
- QMetaObject::invokeMethod(object, "deassignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(propertyVarWeakRefCallbackCount == 1); // should have been collected now.
- delete object;
-}
-
-// Ensure that QObject type conversion works on binding assignment
-void tst_qdeclarativeecmascript::elementAssign()
-{
- QDeclarativeComponent component(&engine, testFileUrl("elementAssign.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// QTBUG-12457
-void tst_qdeclarativeecmascript::objectPassThroughSignals()
-{
- QDeclarativeComponent component(&engine, testFileUrl("objectsPassThroughSignals.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// QTBUG-21626
-void tst_qdeclarativeecmascript::objectConversion()
-{
- QDeclarativeComponent component(&engine, testFileUrl("objectConversion.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVariant retn;
- QMetaObject::invokeMethod(object, "circularObject", Q_RETURN_ARG(QVariant, retn));
- QCOMPARE(retn.value<QVariantMap>().value("test"), QVariant(100));
-
- delete object;
-}
-
-
-// QTBUG-20242
-void tst_qdeclarativeecmascript::booleanConversion()
-{
- QDeclarativeComponent component(&engine, testFileUrl("booleanConversion.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test_true1").toBool(), true);
- QCOMPARE(object->property("test_true2").toBool(), true);
- QCOMPARE(object->property("test_true3").toBool(), true);
- QCOMPARE(object->property("test_true4").toBool(), true);
- QCOMPARE(object->property("test_true5").toBool(), true);
-
- QCOMPARE(object->property("test_false1").toBool(), false);
- QCOMPARE(object->property("test_false2").toBool(), false);
- QCOMPARE(object->property("test_false3").toBool(), false);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::handleReferenceManagement()
-{
-
- int dtorCount = 0;
- {
- // Linear QObject reference
- QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
- cro->setEngine(&hrmEngine);
- cro->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object, "createReference");
- gc(engine);
- QCOMPARE(dtorCount, 0); // second has JS ownership, kept alive by first's reference
- delete object;
- hrmEngine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 3);
- }
-
- dtorCount = 0;
- {
- // Circular QObject reference
- QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
- cro->setEngine(&hrmEngine);
- cro->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object, "circularReference");
- gc(engine);
- QCOMPARE(dtorCount, 2); // both should be cleaned up, since circular references shouldn't keep alive.
- delete object;
- hrmEngine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 3);
- }
-
- dtorCount = 0;
- {
- // Linear handle reference
- QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh != 0);
- crh->setEngine(&hrmEngine);
- crh->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object, "createReference");
- CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first != 0);
- QVERIFY(second != 0);
- first->addReference(QDeclarativeData::get(second)->v8object); // create reference
- // now we have to reparent second and make second owned by JS.
- second->setParent(0);
- QDeclarativeEngine::setObjectOwnership(second, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCOMPARE(dtorCount, 0); // due to reference from first to second, second shouldn't be collected.
- delete object;
- hrmEngine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 3);
- }
-
- dtorCount = 0;
- {
- // Circular handle reference
- QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh != 0);
- crh->setEngine(&hrmEngine);
- crh->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object, "circularReference");
- CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first != 0);
- QVERIFY(second != 0);
- first->addReference(QDeclarativeData::get(second)->v8object); // create circular reference
- second->addReference(QDeclarativeData::get(first)->v8object); // note: must be weak.
- // now we have to reparent and change ownership.
- first->setParent(0);
- second->setParent(0);
- QDeclarativeEngine::setObjectOwnership(first, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(second, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCOMPARE(dtorCount, 2); // despite circular references, both will be collected.
- delete object;
- hrmEngine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 3);
- }
-
- dtorCount = 0;
- {
- // multiple engine interaction - linear reference
- QDeclarativeEngine hrmEngine1;
- QDeclarativeEngine hrmEngine2;
- QDeclarativeComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QObject *object1 = component1.create();
- QObject *object2 = component2.create();
- QVERIFY(object1 != 0);
- QVERIFY(object2 != 0);
- CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
- CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh1 != 0);
- QVERIFY(crh2 != 0);
- crh1->setEngine(&hrmEngine1);
- crh2->setEngine(&hrmEngine2);
- crh1->setDtorCount(&dtorCount);
- crh2->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object1, "createReference");
- QMetaObject::invokeMethod(object2, "createReference");
- CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
- CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first1 != 0);
- QVERIFY(second1 != 0);
- QVERIFY(first2 != 0);
- QVERIFY(second2 != 0);
- first1->addReference(QDeclarativeData::get(second2)->v8object); // create reference across engines
- // now we have to reparent second2 and make second2 owned by JS.
- second2->setParent(0);
- QDeclarativeEngine::setObjectOwnership(second2, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 0); // due to reference from first1 to second2, second2 shouldn't be collected.
- delete object1;
- delete object2;
- hrmEngine1.collectGarbage();
- hrmEngine2.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 6);
- }
-
- dtorCount = 0;
- {
- // multiple engine interaction - circular reference
- QDeclarativeEngine hrmEngine1;
- QDeclarativeEngine hrmEngine2;
- QDeclarativeComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QObject *object1 = component1.create();
- QObject *object2 = component2.create();
- QVERIFY(object1 != 0);
- QVERIFY(object2 != 0);
- CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
- CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh1 != 0);
- QVERIFY(crh2 != 0);
- crh1->setEngine(&hrmEngine1);
- crh2->setEngine(&hrmEngine2);
- crh1->setDtorCount(&dtorCount);
- crh2->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object1, "createReference");
- QMetaObject::invokeMethod(object2, "createReference");
- CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
- CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first1 != 0);
- QVERIFY(second1 != 0);
- QVERIFY(first2 != 0);
- QVERIFY(second2 != 0);
- first1->addReference(QDeclarativeData::get(second1)->v8object); // create linear reference within engine1
- second1->addReference(QDeclarativeData::get(second2)->v8object); // create linear reference across engines
- second2->addReference(QDeclarativeData::get(first2)->v8object); // create linear reference within engine2
- first2->addReference(QDeclarativeData::get(first1)->v8object); // close the loop - circular ref across engines
- // now we have to reparent and change ownership to JS.
- first1->setParent(0);
- second1->setParent(0);
- first2->setParent(0);
- second2->setParent(0);
- QDeclarativeEngine::setObjectOwnership(first1, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(second1, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(first2, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(second2, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 4); // circular references shouldn't keep them alive.
- delete object1;
- delete object2;
- hrmEngine1.collectGarbage();
- hrmEngine2.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 6);
- }
-
- dtorCount = 0;
- {
- // multiple engine interaction - linear reference with engine deletion
- QDeclarativeEngine *hrmEngine1 = new QDeclarativeEngine;
- QDeclarativeEngine *hrmEngine2 = new QDeclarativeEngine;
- QDeclarativeComponent component1(hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QObject *object1 = component1.create();
- QObject *object2 = component2.create();
- QVERIFY(object1 != 0);
- QVERIFY(object2 != 0);
- CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
- CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh1 != 0);
- QVERIFY(crh2 != 0);
- crh1->setEngine(hrmEngine1);
- crh2->setEngine(hrmEngine2);
- crh1->setDtorCount(&dtorCount);
- crh2->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object1, "createReference");
- QMetaObject::invokeMethod(object2, "createReference");
- CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
- CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first1 != 0);
- QVERIFY(second1 != 0);
- QVERIFY(first2 != 0);
- QVERIFY(second2 != 0);
- first1->addReference(QDeclarativeData::get(second1)->v8object); // create linear reference within engine1
- second1->addReference(QDeclarativeData::get(second2)->v8object); // create linear reference across engines
- second2->addReference(QDeclarativeData::get(first2)->v8object); // create linear reference within engine2
- // now we have to reparent and change ownership to JS.
- first1->setParent(crh1);
- second1->setParent(0);
- first2->setParent(0);
- second2->setParent(0);
- QDeclarativeEngine::setObjectOwnership(second1, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(first2, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(second2, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCOMPARE(dtorCount, 0);
- delete hrmEngine2;
- gc(engine);
- QCOMPARE(dtorCount, 0);
- delete object1;
- delete object2;
- hrmEngine1->collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 6);
- delete hrmEngine1;
- }
-}
-
-void tst_qdeclarativeecmascript::stringArg()
-{
- QDeclarativeComponent component(&engine, testFileUrl("stringArg.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "success");
- QVERIFY(object->property("returnValue").toBool());
-
- QString w1 = testFileUrl("stringArg.qml").toString() + QLatin1String(":45: Error: String.arg(): Invalid arguments");
- QTest::ignoreMessage(QtWarningMsg, w1.toAscii().constData());
- QMetaObject::invokeMethod(object, "failure");
- QVERIFY(object->property("returnValue").toBool());
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::readonlyDeclaration()
-{
- QDeclarativeComponent component(&engine, testFileUrl("readonlyDeclaration.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-Q_DECLARE_METATYPE(QList<int>)
-Q_DECLARE_METATYPE(QList<qreal>)
-Q_DECLARE_METATYPE(QList<bool>)
-Q_DECLARE_METATYPE(QList<QString>)
-Q_DECLARE_METATYPE(QList<QUrl>)
-void tst_qdeclarativeecmascript::sequenceConversionRead()
-{
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.read.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
- QVERIFY(seq != 0);
-
- QMetaObject::invokeMethod(object, "readSequences");
- QList<int> intList; intList << 1 << 2 << 3 << 4;
- QCOMPARE(object->property("intListLength").toInt(), intList.length());
- QCOMPARE(object->property("intList").value<QList<int> >(), intList);
- QList<qreal> qrealList; qrealList << 1.1 << 2.2 << 3.3 << 4.4;
- QCOMPARE(object->property("qrealListLength").toInt(), qrealList.length());
- QCOMPARE(object->property("qrealList").value<QList<qreal> >(), qrealList);
- QList<bool> boolList; boolList << true << false << true << false;
- QCOMPARE(object->property("boolListLength").toInt(), boolList.length());
- QCOMPARE(object->property("boolList").value<QList<bool> >(), boolList);
- QList<QString> stringList; stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
- QCOMPARE(object->property("stringListLength").toInt(), stringList.length());
- QCOMPARE(object->property("stringList").value<QList<QString> >(), stringList);
- QList<QUrl> urlList; urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
- QCOMPARE(object->property("urlListLength").toInt(), urlList.length());
- QCOMPARE(object->property("urlList").value<QList<QUrl> >(), urlList);
- QStringList qstringList; qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
- QCOMPARE(object->property("qstringListLength").toInt(), qstringList.length());
- QCOMPARE(object->property("qstringList").value<QStringList>(), qstringList);
-
- QMetaObject::invokeMethod(object, "readSequenceElements");
- QCOMPARE(object->property("intVal").toInt(), 2);
- QCOMPARE(object->property("qrealVal").toReal(), 2.2);
- QCOMPARE(object->property("boolVal").toBool(), false);
- QCOMPARE(object->property("stringVal").toString(), QString(QLatin1String("second")));
- QCOMPARE(object->property("urlVal").toUrl(), QUrl("http://www.example2.com"));
- QCOMPARE(object->property("qstringVal").toString(), QString(QLatin1String("second")));
-
- QMetaObject::invokeMethod(object, "enumerateSequenceElements");
- QCOMPARE(object->property("enumerationMatches").toBool(), true);
-
- intList.clear(); intList << 1 << 2 << 3 << 4 << 5; // set by the enumerateSequenceElements test.
- QDeclarativeProperty seqProp(seq, "intListProperty");
- QCOMPARE(seqProp.read().value<QList<int> >(), intList);
- QDeclarativeProperty seqProp2(seq, "intListProperty", &engine);
- QCOMPARE(seqProp2.read().value<QList<int> >(), intList);
-
- QMetaObject::invokeMethod(object, "testReferenceDeletion");
- QCOMPARE(object->property("referenceDeletion").toBool(), true);
-
- delete object;
- }
-
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.read.error.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
- QVERIFY(seq != 0);
-
- // we haven't registered QList<QPoint> as a sequence type.
- QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'");
- QString warningTwo = qmlFile.toString() + QLatin1String(":18: TypeError: Cannot read property 'length' of undefined");
- QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
- QTest::ignoreMessage(QtWarningMsg, warningTwo.toAscii().constData());
-
- QMetaObject::invokeMethod(object, "performTest");
-
- // QList<QPoint> has not been registered as a sequence type.
- QCOMPARE(object->property("pointListLength").toInt(), 0);
- QVERIFY(!object->property("pointList").isValid());
- QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'");
- QDeclarativeProperty seqProp(seq, "pointListProperty", &engine);
- QVERIFY(!seqProp.read().isValid()); // not a valid/known sequence type
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionWrite()
-{
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.write.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
- QVERIFY(seq != 0);
-
- QMetaObject::invokeMethod(object, "writeSequences");
- QCOMPARE(object->property("success").toBool(), true);
-
- QMetaObject::invokeMethod(object, "writeSequenceElements");
- QCOMPARE(object->property("success").toBool(), true);
-
- QMetaObject::invokeMethod(object, "writeOtherElements");
- QCOMPARE(object->property("success").toBool(), true);
-
- QMetaObject::invokeMethod(object, "testReferenceDeletion");
- QCOMPARE(object->property("referenceDeletion").toBool(), true);
-
- delete object;
- }
-
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.write.error.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
- QVERIFY(seq != 0);
-
- // we haven't registered QList<QPoint> as a sequence type, so writing shouldn't work.
- QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QVariantList to void");
- QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
-
- QMetaObject::invokeMethod(object, "performTest");
-
- QList<QPoint> pointList; pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6); // original values, shouldn't have changed
- QCOMPARE(seq->pointListProperty(), pointList);
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionArray()
-{
- // ensure that in JS the returned sequences act just like normal JS Arrays.
- QUrl qmlFile = testFileUrl("sequenceConversion.array.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "indexedAccess");
- QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "arrayOperations");
- QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "testEqualitySemantics");
- QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "testReferenceDeletion");
- QCOMPARE(object->property("referenceDeletion").toBool(), true);
- delete object;
-}
-
-
-void tst_qdeclarativeecmascript::sequenceConversionIndexes()
-{
- // ensure that we gracefully fail if unsupported index values are specified.
- // Qt container classes only support non-negative, signed integer index values.
- QUrl qmlFile = testFileUrl("sequenceConversion.indexes.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QString w1 = qmlFile.toString() + QLatin1String(":34: Index out of range during length set");
- QString w2 = qmlFile.toString() + QLatin1String(":41: Index out of range during indexed set");
- QString w3 = qmlFile.toString() + QLatin1String(":48: Index out of range during indexed get");
- QString w4 = qmlFile.toString() + QLatin1String(":78: std::bad_alloc during length set");
- QString w5 = qmlFile.toString() + QLatin1String(":83: std::bad_alloc during indexed set");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w4));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w5));
- QMetaObject::invokeMethod(object, "indexedAccess");
- QVERIFY(object->property("success").toBool());
- delete object;
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionThreads()
-{
- // ensure that sequence conversion operations work correctly in a worker thread
- // and that serialisation between the main and worker thread succeeds.
- QUrl qmlFile = testFileUrl("sequenceConversion.threads.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, "testIntSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testQrealSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testBoolSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testStringSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testQStringSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testUrlSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testVariantSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionBindings()
-{
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.bindings.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QList<int> intList; intList << 1 << 2 << 3 << 12 << 7;
- QCOMPARE(object->property("boundSequence").value<QList<int> >(), intList);
- QCOMPARE(object->property("boundElement").toInt(), intList.at(3));
- QList<int> intListTwo; intListTwo << 1 << 2 << 3 << 12 << 14;
- QCOMPARE(object->property("boundSequenceTwo").value<QList<int> >(), intListTwo);
- delete object;
- }
-
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml");
- QString warning = QString(QLatin1String("%1:17: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString());
- QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionCopy()
-{
- QUrl qmlFile = testFileUrl("sequenceConversion.copy.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "testCopySequences");
- QCOMPARE(object->property("success").toBool(), true);
- QMetaObject::invokeMethod(object, "readSequenceCopyElements");
- QCOMPARE(object->property("success").toBool(), true);
- QMetaObject::invokeMethod(object, "testEqualitySemantics");
- QCOMPARE(object->property("success").toBool(), true);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::assignSequenceTypes()
-{
- // test binding array to sequence type property
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.1.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1 << 2.2));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false << true));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com")));
- QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one") << QLatin1String("two")));
- QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two")));
- delete object;
- }
-
- // test binding literal to sequence type property
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.2.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com")));
- QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one")));
- QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two")));
- delete object;
- }
-
- // test binding single value to sequence type property
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.3.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
- delete object;
- }
-
- // test assigning array to sequence type property in js function
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.4.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1 << 2.2));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false << true));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com")));
- QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one") << QLatin1String("two")));
- QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two")));
- delete object;
- }
-
- // test assigning literal to sequence type property in js function
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.5.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com")));
- QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one")));
- QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two")));
- delete object;
- }
-
- // test assigning single value to sequence type property in js function
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.6.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
- delete object;
- }
-
- // test QList<QUrl> literal assignment and binding assignment causes url resolution when required
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.7.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
- MySequenceConversionObject *msco2 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco2"));
- MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3"));
- MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
- MySequenceConversionObject *msco5 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco5"));
- QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0 && msco5 != 0);
- QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
- QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
- QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
- QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
- QCOMPARE(msco5->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
- delete object;
- }
-}
-
-// Test that assigning a null object works
-// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
-void tst_qdeclarativeecmascript::nullObjectBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nullObjectBinding.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->property("test") == QVariant::fromValue((QObject *)0));
-
- delete object;
-}
-
-// Test that bindings don't evaluate once the engine has been destroyed
-void tst_qdeclarativeecmascript::deletedEngine()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
- QDeclarativeComponent component(engine, testFileUrl("deletedEngine.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("a").toInt(), 39);
- object->setProperty("b", QVariant(9));
- QCOMPARE(object->property("a").toInt(), 117);
-
- delete engine;
-
- QCOMPARE(object->property("a").toInt(), 117);
- object->setProperty("b", QVariant(10));
- QCOMPARE(object->property("a").toInt(), 117);
-
- delete object;
-}
-
-// Test the crashing part of QTBUG-9705
-void tst_qdeclarativeecmascript::libraryScriptAssert()
-{
- QDeclarativeComponent component(&engine, testFileUrl("libraryScriptAssert.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::variantsAssignedUndefined()
-{
- QDeclarativeComponent component(&engine, testFileUrl("variantsAssignedUndefined.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 10);
- QCOMPARE(object->property("test2").toInt(), 11);
-
- object->setProperty("runTest", true);
-
- QCOMPARE(object->property("test1"), QVariant());
- QCOMPARE(object->property("test2"), QVariant());
-
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::qtbug_9792()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_9792.qml"));
-
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
-
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create(context));
- QVERIFY(object != 0);
-
- QTest::ignoreMessage(QtDebugMsg, "Hello world!");
- object->basicSignal();
-
- delete context;
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- object->basicSignal();
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
-
- delete object;
-}
-
-// Verifies that QDeclarativeGuard<>s used in the vmemetaobject are cleaned correctly
-void tst_qdeclarativeecmascript::qtcreatorbug_1289()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QObject *nested = qvariant_cast<QObject *>(o->property("object"));
- QVERIFY(nested != 0);
-
- QVERIFY(qvariant_cast<QObject *>(nested->property("nestedObject")) == o);
-
- delete nested;
- nested = qvariant_cast<QObject *>(o->property("object"));
- QVERIFY(nested == 0);
-
- // If the bug is present, the next line will crash
- delete o;
-}
-
-// Test that we shut down without stupid warnings
-void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.qml"));
-
- QObject *o = component.create();
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- delete o;
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
- }
-
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.2.qml"));
-
- QObject *o = component.create();
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- delete o;
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
- }
-}
-
-void tst_qdeclarativeecmascript::canAssignNullToQObject()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("canAssignNullToQObject.1.qml"));
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
-
- QVERIFY(o->objectProperty() != 0);
-
- o->setProperty("runTest", true);
-
- QVERIFY(o->objectProperty() == 0);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("canAssignNullToQObject.2.qml"));
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
-
- QVERIFY(o->objectProperty() == 0);
-
- delete o;
- }
-}
-
-void tst_qdeclarativeecmascript::functionAssignment_fromBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.1.qml"));
-
- QString url = component.url().toString();
- QString warning = url + ":4: Unable to assign a function to a property.";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
-
- QVERIFY(!o->property("a").isValid());
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::functionAssignment_fromJS()
-{
- QFETCH(QString, triggerProperty);
-
- QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
- QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
- QVERIFY(!o->property("a").isValid());
-
- o->setProperty("aNumber", QVariant(5));
- o->setProperty(triggerProperty.toUtf8().constData(), true);
- QCOMPARE(o->property("a"), QVariant(50));
-
- o->setProperty("aNumber", QVariant(10));
- QCOMPARE(o->property("a"), QVariant(100));
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::functionAssignment_fromJS_data()
-{
- QTest::addColumn<QString>("triggerProperty");
-
- QTest::newRow("assign to property") << "assignToProperty";
- QTest::newRow("assign to property, from JS file") << "assignToPropertyFromJsFile";
-
- QTest::newRow("assign to value type") << "assignToValueType";
-
- QTest::newRow("use 'this'") << "assignWithThis";
- QTest::newRow("use 'this' from JS file") << "assignWithThisFromJsFile";
-}
-
-void tst_qdeclarativeecmascript::functionAssignmentfromJS_invalid()
-{
- QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
- QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
- QVERIFY(!o->property("a").isValid());
-
- o->setProperty("assignFuncWithoutReturn", true);
- QVERIFY(!o->property("a").isValid());
-
- QString url = component.url().toString();
- QString warning = url + ":67: Unable to assign QString to int";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- o->setProperty("assignWrongType", true);
-
- warning = url + ":71: Unable to assign QString to int";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- o->setProperty("assignWrongTypeToValueType", true);
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::eval()
-{
- QDeclarativeComponent component(&engine, testFileUrl("eval.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::function()
-{
- QDeclarativeComponent component(&engine, testFileUrl("function.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::functionException()
-{
- // QTBUG-24037 - shouldn't crash.
- QString errstr = testFileUrl("v8functionException.qml").toString() + QLatin1String(":13: SyntaxError: Unexpected token ILLEGAL");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(errstr));
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Exception occurred during compilation of function: dynamicSlot()");
- QDeclarativeComponent component(&engine, testFileUrl("v8functionException.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QMetaObject::invokeMethod(o, "dynamicSlot");
- delete o;
-}
-
-// Test the "Qt.include" method
-void tst_qdeclarativeecmascript::include()
-{
- // Non-library relative include
- {
- QDeclarativeComponent component(&engine, testFileUrl("include.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test0").toInt(), 99);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test2_1").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test3_1").toBool(), true);
-
- delete o;
- }
-
- // Library relative include
- {
- QDeclarativeComponent component(&engine, testFileUrl("include_shared.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test0").toInt(), 99);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test2_1").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test3_1").toBool(), true);
-
- delete o;
- }
-
- // Callback
- {
- QDeclarativeComponent component(&engine, testFileUrl("include_callback.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- QCOMPARE(o->property("test6").toBool(), true);
-
- delete o;
- }
-
- // Including file with ".pragma library"
- {
- QDeclarativeComponent component(&engine, testFileUrl("include_pragma.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toInt(), 100);
-
- delete o;
- }
-
- // Remote - success
- {
- TestHTTPServer server(8111);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("include_remote.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QTRY_VERIFY(o->property("done").toBool() == true);
- QTRY_VERIFY(o->property("done2").toBool() == true);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
-
- QCOMPARE(o->property("test6").toBool(), true);
- QCOMPARE(o->property("test7").toBool(), true);
- QCOMPARE(o->property("test8").toBool(), true);
- QCOMPARE(o->property("test9").toBool(), true);
- QCOMPARE(o->property("test10").toBool(), true);
-
- delete o;
- }
-
- // Remote - error
- {
- TestHTTPServer server(8111);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("include_remote_missing.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QTRY_VERIFY(o->property("done").toBool() == true);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
-
- delete o;
- }
-}
-
-void tst_qdeclarativeecmascript::signalHandlers()
-{
- QDeclarativeComponent component(&engine, testFileUrl("signalHandlers.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QVERIFY(o->property("count").toInt() == 0);
- QMetaObject::invokeMethod(o, "testSignalCall");
- QCOMPARE(o->property("count").toInt(), 1);
-
- QMetaObject::invokeMethod(o, "testSignalHandlerCall");
- QCOMPARE(o->property("count").toInt(), 1);
- QCOMPARE(o->property("errorString").toString(), QLatin1String("TypeError: Property 'onTestSignal' of object [object Object] is not a function"));
-
- QVERIFY(o->property("funcCount").toInt() == 0);
- QMetaObject::invokeMethod(o, "testSignalConnection");
- QCOMPARE(o->property("funcCount").toInt(), 1);
-
- QMetaObject::invokeMethod(o, "testSignalHandlerConnection");
- QCOMPARE(o->property("funcCount").toInt(), 2);
-
- QMetaObject::invokeMethod(o, "testSignalDefined");
- QCOMPARE(o->property("definedResult").toBool(), true);
-
- QMetaObject::invokeMethod(o, "testSignalHandlerDefined");
- QCOMPARE(o->property("definedHandlerResult").toBool(), true);
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_10696()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_10696.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_11606()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_11606.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_11600()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_11600.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_21864()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_21864.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::rewriteMultiLineStrings()
-{
- {
- // QTBUG-23387
- QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QTRY_COMPARE(o->property("test").toBool(), true);
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings_crlf.1.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- delete o;
- }
-}
-
-void tst_qdeclarativeecmascript::qobjectConnectionListExceptionHandling()
-{
- // QTBUG-23375
- QDeclarativeComponent component(&engine, testFileUrl("qobjectConnectionListExceptionHandling.qml"));
- QString warning = component.url().toString() + QLatin1String(":13: TypeError: Cannot read property 'undefined' of undefined");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-// Reading and writing non-scriptable properties should fail
-void tst_qdeclarativeecmascript::nonscriptable()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nonscriptable.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("readOk").toBool(), true);
- QCOMPARE(o->property("writeOk").toBool(), true);
- delete o;
-}
-
-// deleteLater() should not be callable from QML
-void tst_qdeclarativeecmascript::deleteLater()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deleteLater.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::in()
-{
- QDeclarativeComponent component(&engine, testFileUrl("in.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::typeOf()
-{
- QDeclarativeComponent component(&engine, testFileUrl("typeOf.qml"));
-
- // These warnings should not happen once QTBUG-21864 is fixed
- QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString");
- QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: Can't find variable: a");
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QEXPECT_FAIL("", "QTBUG-21864", Abort);
- QCOMPARE(o->property("test1").toString(), QLatin1String("undefined"));
- QCOMPARE(o->property("test2").toString(), QLatin1String("object"));
- QCOMPARE(o->property("test3").toString(), QLatin1String("number"));
- QCOMPARE(o->property("test4").toString(), QLatin1String("string"));
- QCOMPARE(o->property("test5").toString(), QLatin1String("function"));
- QCOMPARE(o->property("test6").toString(), QLatin1String("object"));
- QCOMPARE(o->property("test7").toString(), QLatin1String("undefined"));
- QCOMPARE(o->property("test8").toString(), QLatin1String("boolean"));
- QCOMPARE(o->property("test9").toString(), QLatin1String("object"));
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::sharedAttachedObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("sharedAttachedObject.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- delete o;
-}
-
-// QTBUG-13999
-void tst_qdeclarativeecmascript::objectName()
-{
- QDeclarativeComponent component(&engine, testFileUrl("objectName.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toString(), QString("hello"));
- QCOMPARE(o->property("test2").toString(), QString("ell"));
-
- o->setObjectName("world");
-
- QCOMPARE(o->property("test1").toString(), QString("world"));
- QCOMPARE(o->property("test2").toString(), QString("orl"));
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::writeRemovesBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("writeRemovesBinding.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
-}
-
-// Test bindings assigned to alias properties actually assign to the alias' target
-void tst_qdeclarativeecmascript::aliasBindingsAssignCorrectly()
-{
- QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsAssignCorrectly.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
-}
-
-// Test bindings assigned to alias properties override a binding on the target (QTBUG-13719)
-void tst_qdeclarativeecmascript::aliasBindingsOverrideTarget()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.2.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.3.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-}
-
-// Test that writes to alias properties override bindings on the alias target (QTBUG-13719)
-void tst_qdeclarativeecmascript::aliasWritesOverrideBindings()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.2.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.3.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-}
-
-// Allow an alais to a composite element
-// QTBUG-20200
-void tst_qdeclarativeecmascript::aliasToCompositeElement()
-{
- QDeclarativeComponent component(&engine, testFileUrl("aliasToCompositeElement.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::qtbug_20344()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_20344.qml"));
-
- QString warning = component.url().toString() + ":5: Error: Exception thrown from within QObject slot";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::revisionErrors()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml"));
- QString url = component.url().toString();
-
- QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
- QString warning2 = url + ":11: ReferenceError: Can't find variable: prop2";
- QString warning3 = url + ":13: ReferenceError: Can't find variable: method2";
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors2.qml"));
- QString url = component.url().toString();
-
- // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
- // method2, prop2 from MyRevisionedClass not available
- // method4, prop4 from MyRevisionedSubclass not available
- QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
- QString warning2 = url + ":14: ReferenceError: Can't find variable: prop2";
- QString warning3 = url + ":10: ReferenceError: Can't find variable: prop4";
- QString warning4 = url + ":16: ReferenceError: Can't find variable: prop4";
- QString warning5 = url + ":20: ReferenceError: Can't find variable: method2";
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors3.qml"));
- QString url = component.url().toString();
-
- // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
- // All properties/methods available, except MyRevisionedBaseClassUnregistered rev 1
- QString warning1 = url + ":30: ReferenceError: Can't find variable: methodD";
- QString warning2 = url + ":10: ReferenceError: Can't find variable: propD";
- QString warning3 = url + ":20: ReferenceError: Can't find variable: propD";
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::revision()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision.qml"));
- QString url = component.url().toString();
-
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision2.qml"));
- QString url = component.url().toString();
-
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision3.qml"));
- QString url = component.url().toString();
-
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- // Test that non-root classes can resolve revisioned methods
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision4.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toReal(), 11.);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::realToInt()
-{
- QDeclarativeComponent component(&engine, testFileUrl("realToInt.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, "test1");
- QCOMPARE(object->value(), int(4));
- QMetaObject::invokeMethod(object, "test2");
- QCOMPARE(object->value(), int(8));
-}
-
-void tst_qdeclarativeecmascript::urlProperty()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("urlProperty.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- object->setStringProperty("http://qt-project.org");
- QCOMPARE(object->urlProperty(), QUrl("http://qt-project.org/index.html"));
- QCOMPARE(object->intProperty(), 123);
- QCOMPARE(object->value(), 1);
- QCOMPARE(object->property("result").toBool(), true);
- }
-}
-
-void tst_qdeclarativeecmascript::urlPropertyWithEncoding()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("urlProperty.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- object->setStringProperty("http://qt-project.org");
- QUrl encoded;
- encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode);
- QCOMPARE(object->urlProperty(), encoded);
- QCOMPARE(object->value(), 0); // Interpreting URL as string yields canonicalised version
- QCOMPARE(object->property("result").toBool(), true);
- }
-}
-
-void tst_qdeclarativeecmascript::urlListPropertyWithEncoding()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("urlListProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
- MySequenceConversionObject *msco2 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco2"));
- MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3"));
- MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
- QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0);
- QUrl encoded;
- encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode);
- QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << encoded));
- QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << encoded));
- QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << encoded << encoded));
- QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << encoded << encoded));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::dynamicString()
-{
- QDeclarativeComponent component(&engine, testFileUrl("dynamicString.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("stringProperty").toString(),
- QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!"));
-}
-
-void tst_qdeclarativeecmascript::automaticSemicolon()
-{
- QDeclarativeComponent component(&engine, testFileUrl("automaticSemicolon.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qdeclarativeecmascript::unaryExpression()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unaryExpression.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Makes sure that a binding isn't double re-evaluated when it depends on the same variable twice
-void tst_qdeclarativeecmascript::doubleEvaluate()
-{
- QDeclarativeComponent component(&engine, testFileUrl("doubleEvaluate.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- WriteCounter *wc = qobject_cast<WriteCounter *>(object);
- QVERIFY(wc != 0);
- QCOMPARE(wc->count(), 1);
-
- wc->setProperty("x", 9);
-
- QCOMPARE(wc->count(), 2);
-
- delete object;
-}
-
-static QStringList messages;
-static void captureMsgHandler(QtMsgType, const char *msg)
-{
- messages.append(QLatin1String(msg));
-}
-
-void tst_qdeclarativeecmascript::nonNotifyable()
-{
- QV4Compiler::enableV4(false);
- QDeclarativeComponent component(&engine, testFileUrl("nonNotifyable.qml"));
- QV4Compiler::enableV4(true);
-
- QtMsgHandler old = qInstallMsgHandler(captureMsgHandler);
- messages.clear();
- QObject *object = component.create();
- qInstallMsgHandler(old);
-
- QVERIFY(object != 0);
-
- QString expected1 = QLatin1String("QDeclarativeExpression: Expression ") +
- component.url().toString() +
- QLatin1String(":5 depends on non-NOTIFYable properties:");
- QString expected2 = QLatin1String(" ") +
- QLatin1String(object->metaObject()->className()) +
- QLatin1String("::value");
-
- QCOMPARE(messages.length(), 2);
- QCOMPARE(messages.at(0), expected1);
- QCOMPARE(messages.at(1), expected2);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::forInLoop()
-{
- QDeclarativeComponent component(&engine, testFileUrl("forInLoop.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, "listProperty");
-
- QStringList r = object->property("listResult").toString().split("|", QString::SkipEmptyParts);
- QCOMPARE(r.size(), 3);
- QCOMPARE(r[0],QLatin1String("0=obj1"));
- QCOMPARE(r[1],QLatin1String("1=obj2"));
- QCOMPARE(r[2],QLatin1String("2=obj3"));
-
- //TODO: should test for in loop for other objects (such as QObjects) as well.
-
- delete object;
-}
-
-// An object the binding depends on is deleted while the binding is still running
-void tst_qdeclarativeecmascript::deleteWhileBindingRunning()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deleteWhileBindingRunning.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::qtbug_22679()
-{
- MyQmlObject object;
- object.setStringProperty(QLatin1String("Please work correctly"));
- engine.rootContext()->setContextProperty("contextProp", &object);
-
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_22679.qml"));
- qRegisterMetaType<QList<QDeclarativeError> >("QList<QDeclarativeError>");
- QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QDeclarativeError>)));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(warningsSpy.count(), 0);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_22843_data()
-{
- QTest::addColumn<bool>("library");
-
- QTest::newRow("without .pragma library") << false;
- QTest::newRow("with .pragma library") << true;
-}
-
-void tst_qdeclarativeecmascript::qtbug_22843()
-{
- QFETCH(bool, library);
-
- QString fileName("qtbug_22843");
- if (library)
- fileName += QLatin1String(".library");
- fileName += QLatin1String(".qml");
-
- QDeclarativeComponent component(&engine, testFileUrl(fileName));
- QString url = component.url().toString();
- QString warning1 = url.left(url.length()-3) + QLatin1String("js:4: SyntaxError: Unexpected token )");
- QString warning2 = url + QLatin1String(":5: TypeError: Object [object Object] has no method 'func'");
-
- qRegisterMetaType<QList<QDeclarativeError> >("QList<QDeclarativeError>");
- QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QDeclarativeError>)));
- for (int x = 0; x < 3; ++x) {
- warningsSpy.clear();
- // For libraries, only the first import attempt should produce a
- // SyntaxError warning; subsequent component creation should not
- // attempt to reload the script.
- bool expectSyntaxError = !library || (x == 0);
- if (expectSyntaxError)
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(warningsSpy.count(), 1 + (expectSyntaxError?1:0));
- delete object;
- }
-}
-
-
-void tst_qdeclarativeecmascript::switchStatement()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 5);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 4);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 1);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 5);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 4);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.3.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 5);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 6);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.4.qml"));
-
- QString warning = component.url().toString() + ":4: Unable to assign [undefined] to int";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 5);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 3);
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- object->setStringProperty("something else");
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.5.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 1);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 1);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 1);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 1);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 1);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.6.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 123);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 123);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 321);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 321);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 0);
- }
-}
-
-void tst_qdeclarativeecmascript::withStatement()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("withStatement.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 123);
- }
-}
-
-void tst_qdeclarativeecmascript::tryStatement()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("tryStatement.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 123);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("tryStatement.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 321);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("tryStatement.3.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 1);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("tryStatement.4.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 1);
- }
-}
-
-class CppInvokableWithQObjectDerived : public QObject
-{
- Q_OBJECT
-public:
- CppInvokableWithQObjectDerived() {}
- ~CppInvokableWithQObjectDerived() {}
-
- Q_INVOKABLE MyQmlObject *createMyQmlObject(QString data)
- {
- MyQmlObject *obj = new MyQmlObject();
- obj->setStringProperty(data);
- return obj;
- }
-
- Q_INVOKABLE QString getStringProperty(MyQmlObject *obj)
- {
- return obj->stringProperty();
- }
-};
-
-void tst_qdeclarativeecmascript::invokableWithQObjectDerived()
-{
- CppInvokableWithQObjectDerived invokable;
-
- {
- QDeclarativeEngine engine;
- engine.rootContext()->setContextProperty("invokable", &invokable);
-
- QDeclarativeComponent component(&engine, testFileUrl("qobjectDerivedArgument.qml"));
-
- QObject *object = component.create();
-
- QVERIFY(object != 0);
- QVERIFY(object->property("result").value<bool>() == true);
-
- delete object;
- }
-}
-
-QTEST_MAIN(tst_qdeclarativeecmascript)
-
-#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
deleted file mode 100644
index 547d56b3ad..0000000000
--- a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeengine
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeengine.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
deleted file mode 100644
index 1de738f81f..0000000000
--- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
+++ /dev/null
@@ -1,365 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-#include <QNetworkAccessManager>
-#include <QPointer>
-#include <QDir>
-#include <QStandardPaths>
-#include <QDebug>
-#include <QDeclarativeComponent>
-#include <QDeclarativeNetworkAccessManagerFactory>
-#include <QDeclarativeExpression>
-
-class tst_qdeclarativeengine : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeengine() {}
-
-private slots:
- void rootContext();
- void networkAccessManager();
- void baseUrl();
- void contextForObject();
- void offlineStoragePath();
- void clearComponentCache();
- void outputWarningsToStandardError();
- void objectOwnership();
- void multipleEngines();
-};
-
-void tst_qdeclarativeengine::rootContext()
-{
- QDeclarativeEngine engine;
-
- QVERIFY(engine.rootContext());
-
- QCOMPARE(engine.rootContext()->engine(), &engine);
- QVERIFY(engine.rootContext()->parentContext() == 0);
-}
-
-class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory
-{
-public:
- NetworkAccessManagerFactory() : manager(0) {}
-
- QNetworkAccessManager *create(QObject *parent) {
- manager = new QNetworkAccessManager(parent);
- return manager;
- }
-
- QNetworkAccessManager *manager;
-};
-
-void tst_qdeclarativeengine::networkAccessManager()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
-
- // Test QDeclarativeEngine created manager
- QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
- QVERIFY(manager != 0);
- delete engine;
-
- // Test factory created manager
- engine = new QDeclarativeEngine;
- NetworkAccessManagerFactory factory;
- engine->setNetworkAccessManagerFactory(&factory);
- QVERIFY(engine->networkAccessManagerFactory() == &factory);
- QVERIFY(engine->networkAccessManager() == factory.manager);
- delete engine;
-}
-
-void tst_qdeclarativeengine::baseUrl()
-{
- QDeclarativeEngine engine;
-
- QUrl cwd = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
-
- QCOMPARE(engine.baseUrl(), cwd);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
-
- QDir dir = QDir::current();
- dir.cdUp();
- QVERIFY(dir != QDir::current());
- QDir::setCurrent(dir.path());
- QVERIFY(QDir::current() == dir);
-
- QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
- QCOMPARE(engine.baseUrl(), cwd2);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd2.resolved(QUrl("main.qml")));
-
- engine.setBaseUrl(cwd);
- QCOMPARE(engine.baseUrl(), cwd);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
-}
-
-void tst_qdeclarativeengine::contextForObject()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
-
- // Test null-object
- QVERIFY(QDeclarativeEngine::contextForObject(0) == 0);
-
- // Test an object with no context
- QObject object;
- QVERIFY(QDeclarativeEngine::contextForObject(&object) == 0);
-
- // Test setting null-object
- QDeclarativeEngine::setContextForObject(0, engine->rootContext());
-
- // Test setting null-context
- QDeclarativeEngine::setContextForObject(&object, 0);
-
- // Test setting context
- QDeclarativeEngine::setContextForObject(&object, engine->rootContext());
- QVERIFY(QDeclarativeEngine::contextForObject(&object) == engine->rootContext());
-
- QDeclarativeContext context(engine->rootContext());
-
- // Try changing context
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngine::setContextForObject(): Object already has a QDeclarativeContext");
- QDeclarativeEngine::setContextForObject(&object, &context);
- QVERIFY(QDeclarativeEngine::contextForObject(&object) == engine->rootContext());
-
- // Delete context
- delete engine; engine = 0;
- QVERIFY(QDeclarativeEngine::contextForObject(&object) == 0);
-}
-
-void tst_qdeclarativeengine::offlineStoragePath()
-{
- // Without these set, QDesktopServices::storageLocation returns
- // strings with extra "//" at the end. We set them to ignore this problem.
- qApp->setApplicationName("tst_qdeclarativeengine");
- qApp->setOrganizationName("Nokia");
- qApp->setOrganizationDomain("nokia.com");
-
- QDeclarativeEngine engine;
-
- QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
- dir.mkpath("QML");
- dir.cd("QML");
- dir.mkpath("OfflineStorage");
- dir.cd("OfflineStorage");
-
- QCOMPARE(QDir::fromNativeSeparators(engine.offlineStoragePath()), dir.path());
-
- engine.setOfflineStoragePath(QDir::homePath());
- QCOMPARE(engine.offlineStoragePath(), QDir::homePath());
-}
-
-void tst_qdeclarativeengine::clearComponentCache()
-{
- QDeclarativeEngine engine;
-
- // Create original qml file
- {
- QFile file("temp.qml");
- QVERIFY(file.open(QIODevice::WriteOnly));
- file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 10\n}\n");
- file.close();
- }
-
- // Test "test" property
- {
- QDeclarativeComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 10);
- delete obj;
- }
-
- // Modify qml file
- {
- QFile file("temp.qml");
- QVERIFY(file.open(QIODevice::WriteOnly));
- file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 11\n}\n");
- file.close();
- }
-
- // Test cache hit
- {
- QDeclarativeComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 10);
- delete obj;
- }
-
- // Clear cache
- engine.clearComponentCache();
-
- // Test cache refresh
- {
- QDeclarativeComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 11);
- delete obj;
- }
-}
-
-static QStringList warnings;
-static void msgHandler(QtMsgType, const char *warning)
-{
- warnings << QString::fromUtf8(warning);
-}
-
-void tst_qdeclarativeengine::outputWarningsToStandardError()
-{
- QDeclarativeEngine engine;
-
- QCOMPARE(engine.outputWarningsToStandardError(), true);
-
- QDeclarativeComponent c(&engine);
- c.setData("import QtQuick 2.0; QtObject { property int a: undefined }", QUrl());
-
- QVERIFY(c.isReady() == true);
-
- warnings.clear();
- QtMsgHandler old = qInstallMsgHandler(msgHandler);
-
- QObject *o = c.create();
-
- qInstallMsgHandler(old);
-
- QVERIFY(o != 0);
- delete o;
-
- QCOMPARE(warnings.count(), 1);
- QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int"));
- warnings.clear();
-
-
- engine.setOutputWarningsToStandardError(false);
- QCOMPARE(engine.outputWarningsToStandardError(), false);
-
-
- old = qInstallMsgHandler(msgHandler);
-
- o = c.create();
-
- qInstallMsgHandler(old);
-
- QVERIFY(o != 0);
- delete o;
-
- QCOMPARE(warnings.count(), 0);
-}
-
-void tst_qdeclarativeengine::objectOwnership()
-{
- {
- QCOMPARE(QDeclarativeEngine::objectOwnership(0), QDeclarativeEngine::CppOwnership);
- QDeclarativeEngine::setObjectOwnership(0, QDeclarativeEngine::JavaScriptOwnership);
- QCOMPARE(QDeclarativeEngine::objectOwnership(0), QDeclarativeEngine::CppOwnership);
- }
-
- {
- QObject o;
- QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
- QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
- QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
- QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::JavaScriptOwnership);
- QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
- QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine);
- c.setData("import QtQuick 2.0; QtObject { property QtObject object: QtObject {} }", QUrl());
-
- QObject *o = c.create();
- QVERIFY(o != 0);
-
- QCOMPARE(QDeclarativeEngine::objectOwnership(o), QDeclarativeEngine::CppOwnership);
-
- QObject *o2 = qvariant_cast<QObject *>(o->property("object"));
- QCOMPARE(QDeclarativeEngine::objectOwnership(o2), QDeclarativeEngine::JavaScriptOwnership);
-
- delete o;
- }
-
-}
-
-// Test an object can be accessed by multiple engines
-void tst_qdeclarativeengine::multipleEngines()
-{
- QObject o;
- o.setObjectName("TestName");
-
- // Simultaneous engines
- {
- QDeclarativeEngine engine1;
- QDeclarativeEngine engine2;
- engine1.rootContext()->setContextProperty("object", &o);
- engine2.rootContext()->setContextProperty("object", &o);
-
- QDeclarativeExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
- QDeclarativeExpression expr2(engine2.rootContext(), 0, QString("object.objectName"));
-
- QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
- QCOMPARE(expr2.evaluate().toString(), QString("TestName"));
- }
-
- // Serial engines
- {
- QDeclarativeEngine engine1;
- engine1.rootContext()->setContextProperty("object", &o);
- QDeclarativeExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
- QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
- }
- {
- QDeclarativeEngine engine1;
- engine1.rootContext()->setContextProperty("object", &o);
- QDeclarativeExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
- QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
- }
-}
-
-QTEST_MAIN(tst_qdeclarativeengine)
-
-#include "tst_qdeclarativeengine.moc"
diff --git a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
deleted file mode 100644
index 8acf46f7bc..0000000000
--- a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeerror
-SOURCES += tst_qdeclarativeerror.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp b/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp
deleted file mode 100644
index 14aaa06106..0000000000
--- a/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeError>
-#include <QDebug>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeerror : public QDeclarativeDataTest
-{
- Q_OBJECT
-private slots:
- void url();
- void description();
- void line();
- void column();
- void toString();
-
- void copy();
- void debug();
-};
-
-void tst_qdeclarativeerror::url()
-{
- QDeclarativeError error;
-
- QCOMPARE(error.url(), QUrl());
-
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
-
- QCOMPARE(error.url(), QUrl("http://www.nokia.com/main.qml"));
-
- QDeclarativeError error2 = error;
-
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
-
- error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
-
- QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
-}
-
-void tst_qdeclarativeerror::description()
-{
- QDeclarativeError error;
-
- QCOMPARE(error.description(), QString());
-
- error.setDescription("An Error");
-
- QCOMPARE(error.description(), QString("An Error"));
-
- QDeclarativeError error2 = error;
-
- QCOMPARE(error2.description(), QString("An Error"));
-
- error.setDescription("Another Error");
-
- QCOMPARE(error.description(), QString("Another Error"));
- QCOMPARE(error2.description(), QString("An Error"));
-}
-
-void tst_qdeclarativeerror::line()
-{
- QDeclarativeError error;
-
- QCOMPARE(error.line(), -1);
-
- error.setLine(102);
-
- QCOMPARE(error.line(), 102);
-
- QDeclarativeError error2 = error;
-
- QCOMPARE(error2.line(), 102);
-
- error.setLine(4);
-
- QCOMPARE(error.line(), 4);
- QCOMPARE(error2.line(), 102);
-}
-
-void tst_qdeclarativeerror::column()
-{
- QDeclarativeError error;
-
- QCOMPARE(error.column(), -1);
-
- error.setColumn(16);
-
- QCOMPARE(error.column(), 16);
-
- QDeclarativeError error2 = error;
-
- QCOMPARE(error2.column(), 16);
-
- error.setColumn(3);
-
- QCOMPARE(error.column(), 3);
- QCOMPARE(error2.column(), 16);
-}
-
-void tst_qdeclarativeerror::toString()
-{
- {
- QDeclarativeError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92:13: An Error"));
- }
-
- {
- QDeclarativeError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
-
- QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92: An Error"));
- }
-}
-
-void tst_qdeclarativeerror::copy()
-{
- QDeclarativeError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QDeclarativeError error2(error);
- QDeclarativeError error3;
- error3 = error;
-
- error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
- error.setDescription("Another Error");
- error.setLine(2);
- error.setColumn(33);
-
- QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
- QCOMPARE(error.description(), QString("Another Error"));
- QCOMPARE(error.line(), 2);
- QCOMPARE(error.column(), 33);
-
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
- QCOMPARE(error2.description(), QString("An Error"));
- QCOMPARE(error2.line(), 92);
- QCOMPARE(error2.column(), 13);
-
- QCOMPARE(error3.url(), QUrl("http://www.nokia.com/main.qml"));
- QCOMPARE(error3.description(), QString("An Error"));
- QCOMPARE(error3.line(), 92);
- QCOMPARE(error3.column(), 13);
-
-}
-
-void tst_qdeclarativeerror::debug()
-{
- {
- QDeclarativeError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QTest::ignoreMessage(QtWarningMsg, "http://www.nokia.com/main.qml:92:13: An Error ");
- qWarning() << error;
- }
-
- {
- QUrl url(dataDirectoryUrl().resolved(QUrl("test.txt")));
- QDeclarativeError error;
- error.setUrl(url);
- error.setDescription("An Error");
- error.setLine(2);
- error.setColumn(5);
-
- QString out = url.toString() + ":2:5: An Error \n Line2 Content \n ^ ";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
-
- qWarning() << error;
- }
-
- {
- QUrl url(dataDirectoryUrl().resolved(QUrl("foo.txt")));
- QDeclarativeError error;
- error.setUrl(url);
- error.setDescription("An Error");
- error.setLine(2);
- error.setColumn(5);
-
- QString out = url.toString() + ":2:5: An Error ";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
-
- qWarning() << error;
- }
-}
-
-
-
-QTEST_MAIN(tst_qdeclarativeerror)
-
-#include "tst_qdeclarativeerror.moc"
diff --git a/tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro b/tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro
deleted file mode 100644
index bd32e6a9ac..0000000000
--- a/tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeexpression
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeexpression.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp b/tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp
deleted file mode 100644
index 10ddf8abad..0000000000
--- a/tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeexpression : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeexpression() {}
-
-private slots:
- void scriptString();
- void syntaxError();
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeScriptString scriptString READ scriptString WRITE setScriptString)
- Q_PROPERTY(QDeclarativeScriptString scriptStringError READ scriptStringError WRITE setScriptStringError)
-public:
- TestObject(QObject *parent = 0) : QObject(parent) {}
-
- QDeclarativeScriptString scriptString() const { return m_scriptString; }
- void setScriptString(QDeclarativeScriptString scriptString) { m_scriptString = scriptString; }
-
- QDeclarativeScriptString scriptStringError() const { return m_scriptStringError; }
- void setScriptStringError(QDeclarativeScriptString scriptString) { m_scriptStringError = scriptString; }
-
-private:
- QDeclarativeScriptString m_scriptString;
- QDeclarativeScriptString m_scriptStringError;
-};
-
-QML_DECLARE_TYPE(TestObject)
-
-void tst_qdeclarativeexpression::scriptString()
-{
- qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("scriptString.qml"));
- TestObject *testObj = qobject_cast<TestObject*>(c.create());
- QVERIFY(testObj != 0);
-
- QDeclarativeScriptString script = testObj->scriptString();
- QCOMPARE(script.script(), QLatin1String("value1 + value2"));
-
- QDeclarativeExpression expression(script);
- QVariant value = expression.evaluate();
- QCOMPARE(value.toInt(), 15);
-
- QDeclarativeScriptString scriptError = testObj->scriptStringError();
- QCOMPARE(scriptError.script(), QLatin1String("value3 * 5"));
-
- //verify that the expression has the correct error location information
- QDeclarativeExpression expressionError(scriptError);
- QVariant valueError = expressionError.evaluate();
- QVERIFY(!valueError.isValid());
- QVERIFY(expressionError.hasError());
- QDeclarativeError error = expressionError.error();
- QCOMPARE(error.url(), c.url());
- QCOMPARE(error.line(), 8);
-}
-
-// QTBUG-21310 - crash test
-void tst_qdeclarativeexpression::syntaxError()
-{
- QDeclarativeEngine engine;
- QDeclarativeExpression expression(engine.rootContext(), 0, "asd asd");
- QVariant v = expression.evaluate();
- QCOMPARE(v, QVariant());
-}
-
-QTEST_MAIN(tst_qdeclarativeexpression)
-
-#include "tst_qdeclarativeexpression.moc"
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro
deleted file mode 100644
index 045d48a710..0000000000
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativefolderlistmodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativefolderlistmodel.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
deleted file mode 100644
index 708f3c90bb..0000000000
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qabstractitemmodel.h>
-#include <QDebug>
-#include "../../shared/util.h"
-
-// From qdeclarastivefolderlistmodel.h
-const int FileNameRole = Qt::UserRole+1;
-const int FilePathRole = Qt::UserRole+2;
-enum SortField { Unsorted, Name, Time, Size, Type };
-
-class tst_qdeclarativefolderlistmodel : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativefolderlistmodel() : removeStart(0), removeEnd(0) {}
-
-public slots:
- void removed(const QModelIndex &, int start, int end) {
- removeStart = start;
- removeEnd = end;
- }
-
-private slots:
- void basicProperties();
- void resetFiltering();
- void refresh();
-
-private:
- void checkNoErrors(const QDeclarativeComponent& component);
- QDeclarativeEngine engine;
-
- int removeStart;
- int removeEnd;
-};
-
-void tst_qdeclarativefolderlistmodel::checkNoErrors(const QDeclarativeComponent& component)
-{
- // Wait until the component is ready
- QTRY_VERIFY(component.isReady() || component.isError());
-
- if (component.isError()) {
- QList<QDeclarativeError> errors = component.errors();
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QDeclarativeError &error = errors.at(ii);
- QByteArray errorStr = QByteArray::number(error.line()) + ":" +
- QByteArray::number(error.column()) + ":" +
- error.description().toUtf8();
- qWarning() << errorStr;
- }
- }
- QVERIFY(!component.isError());
-}
-
-void tst_qdeclarativefolderlistmodel::basicProperties()
-{
- QDeclarativeComponent component(&engine, testFileUrl("basic.qml"));
- checkNoErrors(component);
-
- QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
- QVERIFY(flm != 0);
-
- flm->setProperty("folder", dataDirectoryUrl());
- QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
- QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl());
- QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath()));
- QCOMPARE(flm->property("sortField").toInt(), int(Name));
- QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml");
- QCOMPARE(flm->property("sortReversed").toBool(), false);
- QCOMPARE(flm->property("showDirs").toBool(), true);
- QCOMPARE(flm->property("showDotAndDotDot").toBool(), false);
- QCOMPARE(flm->property("showOnlyReadable").toBool(), false);
- QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml"));
- QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml"));
-
- flm->setProperty("folder",QUrl::fromLocalFile(""));
- QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(""));
-}
-
-void tst_qdeclarativefolderlistmodel::resetFiltering()
-{
- // see QTBUG-17837
- QDeclarativeComponent component(&engine, testFileUrl("resetFiltering.qml"));
- checkNoErrors(component);
-
- QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
- QVERIFY(flm != 0);
-
- connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
- this, SLOT(removed(const QModelIndex&,int,int)));
-
- flm->setProperty("folder", testFileUrl("resetfiltering"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
- int count = flm->rowCount();
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
-
- flm->setProperty("folder", testFileUrl("resetfiltering/innerdir"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible
- count = flm->rowCount();
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
-
- flm->setProperty("folder", testFileUrl("resetfiltering"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
- count = flm->rowCount();
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
-}
-
-void tst_qdeclarativefolderlistmodel::refresh()
-{
- QDeclarativeComponent component(&engine, testFileUrl("basic.qml"));
- checkNoErrors(component);
-
- QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
- QVERIFY(flm != 0);
-
- flm->setProperty("folder", dataDirectoryUrl());
- QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
-
- int count = flm->rowCount();
-
- connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
- this, SLOT(removed(const QModelIndex&,int,int)));
-
- flm->setProperty("sortReversed", true);
-
- QTRY_COMPARE(removeStart, 0);
- QTRY_COMPARE(removeEnd, count-1); // wait for refresh
-}
-
-QTEST_MAIN(tst_qdeclarativefolderlistmodel)
-
-#include "tst_qdeclarativefolderlistmodel.moc"
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
deleted file mode 100644
index 70b9a406b3..0000000000
--- a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeimageprovider
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeimageprovider.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
deleted file mode 100644
index 14da99374b..0000000000
--- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeimageprovider.h>
-#include <private/qquickimage_p.h>
-#include <QImageReader>
-#include <QWaitCondition>
-
-Q_DECLARE_METATYPE(QDeclarativeImageProvider*);
-
-class tst_qdeclarativeimageprovider : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeimageprovider()
- {
- }
-
-private slots:
- void requestImage_sync_data();
- void requestImage_sync();
- void requestImage_async_data();
- void requestImage_async();
-
- void requestPixmap_sync_data();
- void requestPixmap_sync();
- void requestPixmap_async();
-
- void removeProvider_data();
- void removeProvider();
-
- void threadTest();
-
-private:
- QString newImageFileName() const;
- void fillRequestTestsData(const QString &id);
- void runTest(bool async, QDeclarativeImageProvider *provider);
-};
-
-
-class TestQImageProvider : public QDeclarativeImageProvider
-{
-public:
- TestQImageProvider(bool *deleteWatch = 0)
- : QDeclarativeImageProvider(Image), deleteWatch(deleteWatch)
- {
- }
-
- ~TestQImageProvider()
- {
- if (deleteWatch)
- *deleteWatch = true;
- }
-
- QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
- {
- lastImageId = id;
-
- if (id == QLatin1String("no-such-file.png"))
- return QImage();
-
- int width = 100;
- int height = 100;
- QImage image(width, height, QImage::Format_RGB32);
- if (size)
- *size = QSize(width, height);
- if (requestedSize.isValid())
- image = image.scaled(requestedSize);
- return image;
- }
-
- bool *deleteWatch;
- QString lastImageId;
-};
-Q_DECLARE_METATYPE(TestQImageProvider*);
-
-
-class TestQPixmapProvider : public QDeclarativeImageProvider
-{
-public:
- TestQPixmapProvider(bool *deleteWatch = 0)
- : QDeclarativeImageProvider(Pixmap), deleteWatch(deleteWatch)
- {
- }
-
- ~TestQPixmapProvider()
- {
- if (deleteWatch)
- *deleteWatch = true;
- }
-
- QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
- {
- lastImageId = id;
-
- if (id == QLatin1String("no-such-file.png"))
- return QPixmap();
-
- int width = 100;
- int height = 100;
- QPixmap image(width, height);
- if (size)
- *size = QSize(width, height);
- if (requestedSize.isValid())
- image = image.scaled(requestedSize);
- return image;
- }
-
- bool *deleteWatch;
- QString lastImageId;
-};
-Q_DECLARE_METATYPE(TestQPixmapProvider*);
-
-
-QString tst_qdeclarativeimageprovider::newImageFileName() const
-{
- // need to generate new filenames each time or else images are loaded
- // from cache and we won't get loading status changes when testing
- // async loading
- static int count = 0;
- return QString("image://test/image-%1.png").arg(count++);
-}
-
-void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id)
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<QString>("imageId");
- QTest::addColumn<QString>("properties");
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QString>("error");
-
- QString fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " simple test"))
- << "image://test/" + fileName << fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference
- << "image://Test/" + fileName << fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with no id"))
- << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with path"))
- << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with fragment"))
- << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with query"))
- << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName
- << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " scaled image"))
- << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << "";
-
- QTest::newRow(QTest::toString(id + " missing"))
- << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100)
- << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png";
-
- QTest::newRow(QTest::toString(id + " unknown provider"))
- << "image://bogus/exists.png" << "" << "" << QSize()
- << "file::2:1: QML Image: Invalid image provider: image://bogus/exists.png";
-}
-
-void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider)
-{
- QFETCH(QString, source);
- QFETCH(QString, imageId);
- QFETCH(QString, properties);
- QFETCH(QSize, size);
- QFETCH(QString, error);
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QDeclarativeEngine engine;
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; "
- + (async ? "asynchronous: true; " : "")
- + properties + " }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
-
- QCOMPARE(obj->source(), QUrl(source));
-
- if (error.isEmpty()) {
- if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- else
- QVERIFY(obj->status() == QQuickImage::Ready);
- if (QByteArray(QTest::currentDataTag()).startsWith("qimage"))
- QCOMPARE(static_cast<TestQImageProvider*>(provider)->lastImageId, imageId);
- else
- QCOMPARE(static_cast<TestQPixmapProvider*>(provider)->lastImageId, imageId);
-
- QCOMPARE(obj->width(), qreal(size.width()));
- QCOMPARE(obj->height(), qreal(size.height()));
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Error);
- else
- QVERIFY(obj->status() == QQuickImage::Error);
- }
-
- delete obj;
-}
-
-void tst_qdeclarativeimageprovider::requestImage_sync_data()
-{
- fillRequestTestsData("qimage|sync");
-}
-
-void tst_qdeclarativeimageprovider::requestImage_sync()
-{
- bool deleteWatch = false;
- runTest(false, new TestQImageProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestImage_async_data()
-{
- fillRequestTestsData("qimage|async");
-}
-
-void tst_qdeclarativeimageprovider::requestImage_async()
-{
- bool deleteWatch = false;
- runTest(true, new TestQImageProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_sync_data()
-{
- fillRequestTestsData("qpixmap");
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_sync()
-{
- bool deleteWatch = false;
- runTest(false, new TestQPixmapProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_async()
-{
- QDeclarativeEngine engine;
- QDeclarativeImageProvider *provider = new TestQPixmapProvider();
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- // pixmaps are loaded synchronously regardless of 'asynchronous' value
- QString componentStr = "import QtQuick 2.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- delete obj;
-}
-
-void tst_qdeclarativeimageprovider::removeProvider_data()
-{
- QTest::addColumn<QDeclarativeImageProvider*>("provider");
-
- QTest::newRow("qimage") << static_cast<QDeclarativeImageProvider*>(new TestQImageProvider);
- QTest::newRow("qpixmap") << static_cast<QDeclarativeImageProvider*>(new TestQPixmapProvider);
-}
-
-void tst_qdeclarativeimageprovider::removeProvider()
-{
- QFETCH(QDeclarativeImageProvider*, provider);
-
- QDeclarativeEngine engine;
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- // add provider, confirm it works
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + newImageFileName() + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->status(), QQuickImage::Ready);
-
- // remove the provider and confirm
- QString fileName = newImageFileName();
- QString error("file::2:1: QML Image: Invalid image provider: " + fileName);
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- engine.removeImageProvider("test");
-
- obj->setSource(QUrl(fileName));
- QCOMPARE(obj->status(), QQuickImage::Error);
-
- delete obj;
-}
-
-class TestThreadProvider : public QDeclarativeImageProvider
-{
- public:
- TestThreadProvider() : QDeclarativeImageProvider(Image), ok(false) {}
-
- ~TestThreadProvider() {}
-
- QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
- {
- mutex.lock();
- if (!ok)
- cond.wait(&mutex);
- mutex.unlock();
- QVector<int> v;
- for (int i = 0; i < 10000; i++)
- v.prepend(i); //do some computation
- QImage image(50,50, QImage::Format_RGB32);
- image.fill(QColor(id).rgb());
- if (size)
- *size = image.size();
- if (requestedSize.isValid())
- image = image.scaled(requestedSize);
- return image;
- }
-
- QWaitCondition cond;
- QMutex mutex;
- bool ok;
-};
-
-
-void tst_qdeclarativeimageprovider::threadTest()
-{
- QDeclarativeEngine engine;
-
- TestThreadProvider *provider = new TestThreadProvider;
-
- engine.addImageProvider("test_thread", provider);
- QVERIFY(engine.imageProvider("test_thread") != 0);
-
- QString componentStr = "import QtQuick 2.0\nItem { \n"
- "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n"
- "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n"
- "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n"
- "Image { source: \"image://test_thread/yellow\"; asynchronous: true; }\n"
- " }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QObject *obj = component.create();
- //MUST not deadlock
- QVERIFY(obj != 0);
- QList<QQuickImage *> images = obj->findChildren<QQuickImage *>();
- QCOMPARE(images.count(), 4);
- QTest::qWait(100);
- foreach (QQuickImage *img, images) {
- QCOMPARE(img->status(), QQuickImage::Loading);
- }
- provider->ok = true;
- provider->cond.wakeAll();
- QTest::qWait(250);
- foreach (QQuickImage *img, images) {
- QTRY_VERIFY(img->status() == QQuickImage::Ready);
- }
-}
-
-
-QTEST_MAIN(tst_qdeclarativeimageprovider)
-
-#include "tst_qdeclarativeimageprovider.moc"
diff --git a/tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro b/tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro
deleted file mode 100644
index 90a6720bd7..0000000000
--- a/tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeincubator
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeincubator.cpp \
- testtypes.cpp
-
-HEADERS += testtypes.h
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private network widgets testlib
diff --git a/tests/auto/declarative/qdeclarativeincubator/testtypes.cpp b/tests/auto/declarative/qdeclarativeincubator/testtypes.cpp
deleted file mode 100644
index 784c727cb7..0000000000
--- a/tests/auto/declarative/qdeclarativeincubator/testtypes.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-#include <QtDeclarative/qdeclarative.h>
-
-SelfRegisteringType *SelfRegisteringType::m_me = 0;
-SelfRegisteringType::SelfRegisteringType()
-: m_v(0)
-{
- m_me = this;
-}
-
-SelfRegisteringType *SelfRegisteringType::me()
-{
- return m_me;
-}
-
-void SelfRegisteringType::clearMe()
-{
- m_me = 0;
-}
-
-CompletionRegisteringType *CompletionRegisteringType::m_me = 0;
-CompletionRegisteringType::CompletionRegisteringType()
-{
-}
-
-void CompletionRegisteringType::classBegin()
-{
-}
-
-void CompletionRegisteringType::componentComplete()
-{
- m_me = this;
-}
-
-CompletionRegisteringType *CompletionRegisteringType::me()
-{
- return m_me;
-}
-
-void CompletionRegisteringType::clearMe()
-{
- m_me = 0;
-}
-
-CallbackRegisteringType::callback CallbackRegisteringType::m_callback = 0;
-void *CallbackRegisteringType::m_data = 0;
-CallbackRegisteringType::CallbackRegisteringType()
-: m_v(0)
-{
-}
-
-void CallbackRegisteringType::clearCallback()
-{
- m_callback = 0;
- m_data = 0;
-}
-
-void CallbackRegisteringType::registerCallback(callback c, void *d)
-{
- m_callback = c;
- m_data = d;
-}
-
-CompletionCallbackType::callback CompletionCallbackType::m_callback = 0;
-void *CompletionCallbackType::m_data = 0;
-CompletionCallbackType::CompletionCallbackType()
-{
-}
-
-void CompletionCallbackType::classBegin()
-{
-}
-
-void CompletionCallbackType::componentComplete()
-{
- if (m_callback) m_callback(this, m_data);
-}
-
-void CompletionCallbackType::clearCallback()
-{
- m_callback = 0;
- m_data = 0;
-}
-
-void CompletionCallbackType::registerCallback(callback c, void *d)
-{
- m_callback = c;
- m_data = d;
-}
-
-void registerTypes()
-{
- qmlRegisterType<SelfRegisteringType>("Qt.test", 1,0, "SelfRegistering");
- qmlRegisterType<CompletionRegisteringType>("Qt.test", 1,0, "CompletionRegistering");
- qmlRegisterType<CallbackRegisteringType>("Qt.test", 1,0, "CallbackRegistering");
- qmlRegisterType<CompletionCallbackType>("Qt.test", 1,0, "CompletionCallback");
-}
diff --git a/tests/auto/declarative/qdeclarativeincubator/testtypes.h b/tests/auto/declarative/qdeclarativeincubator/testtypes.h
deleted file mode 100644
index 3e679d3119..0000000000
--- a/tests/auto/declarative/qdeclarativeincubator/testtypes.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QDeclarativeParserStatus>
-
-class SelfRegisteringType : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int value READ value WRITE setValue);
-public:
- SelfRegisteringType();
-
- int value() const { return m_v; }
- void setValue(int v) { m_v = v; }
-
- static SelfRegisteringType *me();
- static void clearMe();
-
-private:
- static SelfRegisteringType *m_me;
-
- int m_v;
-};
-
-class CallbackRegisteringType : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int value READ value WRITE setValue)
-public:
- CallbackRegisteringType();
-
- int value() const { return m_v; }
- void setValue(int v) { if (m_callback) m_callback(this, m_data); m_v = v; }
-
- typedef void (*callback)(CallbackRegisteringType *, void *);
- static void clearCallback();
- static void registerCallback(callback, void *);
-
-private:
- static callback m_callback;
- static void *m_data;
-
- int m_v;
-};
-
-class CompletionRegisteringType : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-public:
- CompletionRegisteringType();
-
- virtual void classBegin();
- virtual void componentComplete();
-
- static CompletionRegisteringType *me();
- static void clearMe();
-
-private:
- static CompletionRegisteringType *m_me;
-};
-
-class CompletionCallbackType : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-public:
- CompletionCallbackType();
-
- virtual void classBegin();
- virtual void componentComplete();
-
- typedef void (*callback)(CompletionCallbackType *, void *);
- static void clearCallback();
- static void registerCallback(callback, void *);
-
-private:
- static callback m_callback;
- static void *m_data;
-};
-
-void registerTypes();
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp b/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
deleted file mode 100644
index 7f68b9af95..0000000000
--- a/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
+++ /dev/null
@@ -1,1030 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-
-#include <QUrl>
-#include <QDir>
-#include <QDebug>
-#include <qtest.h>
-#include <QPointer>
-#include <QFileInfo>
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-#include <QDeclarativeProperty>
-#include <QDeclarativeComponent>
-#include <QDeclarativeIncubator>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeincubator : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeincubator() {}
-
-private slots:
- void initTestCase();
-
- void incubationMode();
- void objectDeleted();
- void clear();
- void noIncubationController();
- void forceCompletion();
- void setInitialState();
- void clearDuringCompletion();
- void objectDeletionAfterInit();
- void recursiveClear();
- void statusChanged();
- void asynchronousIfNested();
- void nestedComponent();
- void chainedAsynchronousIfNested();
- void chainedAsynchronousIfNestedOnCompleted();
- void selfDelete();
- void contextDelete();
-
-private:
- QDeclarativeIncubationController controller;
- QDeclarativeEngine engine;
-};
-
-#define VERIFY_ERRORS(component, errorfile) \
- if (!errorfile) { \
- if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
- qWarning() << "Unexpected Errors:" << component.errors(); \
- QVERIFY(!component.isError()); \
- QVERIFY(component.errors().isEmpty()); \
- } else { \
- QFile file(QDeclarativeDataTest::instance()->testFile(errorfile)); \
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- QList<QByteArray> expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QDeclarativeError> errors = component.errors(); \
- QList<QByteArray> actual; \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QDeclarativeError &error = errors.at(ii); \
- QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
- QByteArray::number(error.column()) + ":" + \
- error.description().toUtf8(); \
- actual << errorStr; \
- } \
- if (qgetenv("DEBUG") != "" && expected != actual) \
- qWarning() << "Expected:" << expected << "Actual:" << actual; \
- QCOMPARE(expected, actual); \
- }
-
-void tst_qdeclarativeincubator::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- registerTypes();
- engine.setIncubationController(&controller);
-}
-
-void tst_qdeclarativeincubator::incubationMode()
-{
- {
- QDeclarativeIncubator incubator;
- QCOMPARE(incubator.incubationMode(), QDeclarativeIncubator::Asynchronous);
- }
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
- QCOMPARE(incubator.incubationMode(), QDeclarativeIncubator::Asynchronous);
- }
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Synchronous);
- QCOMPARE(incubator.incubationMode(), QDeclarativeIncubator::Synchronous);
- }
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- QCOMPARE(incubator.incubationMode(), QDeclarativeIncubator::AsynchronousIfNested);
- }
-}
-
-void tst_qdeclarativeincubator::objectDeleted()
-{
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("objectDeleted.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- QCOMPARE(incubator.status(), QDeclarativeIncubator::Loading);
- QVERIFY(SelfRegisteringType::me() == 0);
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- delete SelfRegisteringType::me();
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isError());
- VERIFY_ERRORS(incubator, "objectDeleted.errors.txt");
- QVERIFY(incubator.object() == 0);
-}
-
-void tst_qdeclarativeincubator::clear()
-{
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("clear.qml"));
- QVERIFY(component.isReady());
-
- // Clear in null state
- {
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- incubator.clear(); // no effect
- QVERIFY(incubator.isNull());
- }
-
- // Clear in loading state
- {
- QDeclarativeIncubator incubator;
- component.create(incubator);
- QVERIFY(incubator.isLoading());
- incubator.clear();
- QVERIFY(incubator.isNull());
- }
-
- // Clear mid load
- {
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() != 0);
- QPointer<SelfRegisteringType> srt = SelfRegisteringType::me();
-
- incubator.clear();
- QVERIFY(incubator.isNull());
- QVERIFY(srt.isNull());
- }
-
- // Clear in ready state
- {
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QPointer<QObject> obj = incubator.object();
-
- incubator.clear();
- QVERIFY(incubator.isNull());
- QVERIFY(incubator.object() == 0);
- QVERIFY(!obj.isNull());
-
- delete obj;
- QVERIFY(obj.isNull());
- }
-}
-
-void tst_qdeclarativeincubator::noIncubationController()
-{
- // All incubators should behave synchronously when there is no controller
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("noIncubationController.qml"));
-
- QVERIFY(component.isReady());
-
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
- delete incubator.object();
- }
-
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
- delete incubator.object();
- }
-
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Synchronous);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::forceCompletion()
-{
- QDeclarativeComponent component(&engine, testFileUrl("forceCompletion.qml"));
- QVERIFY(component.isReady());
-
- {
- // forceCompletion on a null incubator does nothing
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- incubator.forceCompletion();
- QVERIFY(incubator.isNull());
- }
-
- {
- // forceCompletion immediately after creating an asynchronous object completes it
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- component.create(incubator);
- QVERIFY(incubator.isLoading());
-
- incubator.forceCompletion();
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
-
- delete incubator.object();
- }
-
- {
- // forceCompletion during creation completes it
- SelfRegisteringType::clearMe();
-
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- component.create(incubator);
- QVERIFY(incubator.isLoading());
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- incubator.forceCompletion();
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
-
- delete incubator.object();
- }
-
- {
- // forceCompletion on a ready incubator has no effect
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- component.create(incubator);
- QVERIFY(incubator.isLoading());
-
- incubator.forceCompletion();
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
-
- incubator.forceCompletion();
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
-
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::setInitialState()
-{
- QDeclarativeComponent component(&engine, testFileUrl("setInitialState.qml"));
- QVERIFY(component.isReady());
-
- struct MyIncubator : public QDeclarativeIncubator
- {
- MyIncubator(QDeclarativeIncubator::IncubationMode mode)
- : QDeclarativeIncubator(mode) {}
-
- virtual void setInitialState(QObject *o) {
- QDeclarativeProperty::write(o, "test2", 19);
- QDeclarativeProperty::write(o, "testData1", 201);
- }
- };
-
- {
- MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
- QVERIFY(incubator.isLoading());
- bool b = true;
- controller.incubateWhile(&b);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false);
- QCOMPARE(incubator.object()->property("test1").toInt(), 502);
- QCOMPARE(incubator.object()->property("test2").toInt(), 19);
- delete incubator.object();
- }
-
- {
- MyIncubator incubator(QDeclarativeIncubator::Synchronous);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false);
- QCOMPARE(incubator.object()->property("test1").toInt(), 502);
- QCOMPARE(incubator.object()->property("test2").toInt(), 19);
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::clearDuringCompletion()
-{
- CompletionRegisteringType::clearMe();
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("clearDuringCompletion.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- QCOMPARE(incubator.status(), QDeclarativeIncubator::Loading);
- QVERIFY(CompletionRegisteringType::me() == 0);
-
- while (CompletionRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(CompletionRegisteringType::me() != 0);
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- QPointer<QObject> srt = SelfRegisteringType::me();
-
- incubator.clear();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QVERIFY(incubator.isNull());
- QVERIFY(srt.isNull());
-}
-
-void tst_qdeclarativeincubator::objectDeletionAfterInit()
-{
- QDeclarativeComponent component(&engine, testFileUrl("clear.qml"));
- QVERIFY(component.isReady());
-
- struct MyIncubator : public QDeclarativeIncubator
- {
- MyIncubator(QDeclarativeIncubator::IncubationMode mode)
- : QDeclarativeIncubator(mode), obj(0) {}
-
- virtual void setInitialState(QObject *o) {
- obj = o;
- }
-
- QObject *obj;
- };
-
- SelfRegisteringType::clearMe();
- MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
-
- while (!incubator.obj && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() != 0);
-
- delete incubator.obj;
-
- incubator.clear();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QVERIFY(incubator.isNull());
-}
-
-class Switcher : public QObject
-{
- Q_OBJECT
-public:
- Switcher(QDeclarativeEngine *e) : QObject(), engine(e) { }
-
- struct MyIncubator : public QDeclarativeIncubator
- {
- MyIncubator(QDeclarativeIncubator::IncubationMode mode, QObject *s)
- : QDeclarativeIncubator(mode), switcher(s) {}
-
- virtual void setInitialState(QObject *o) {
- if (o->objectName() == "switchMe")
- connect(o, SIGNAL(switchMe()), switcher, SLOT(switchIt()));
- }
-
- QObject *switcher;
- };
-
- void start()
- {
- incubator = new MyIncubator(QDeclarativeIncubator::Synchronous, this);
- component = new QDeclarativeComponent(engine, QDeclarativeDataTest::instance()->testFileUrl("recursiveClear.1.qml"));
- component->create(*incubator);
- }
-
- QDeclarativeEngine *engine;
- MyIncubator *incubator;
- QDeclarativeComponent *component;
-
-public slots:
- void switchIt() {
- component->deleteLater();
- incubator->clear();
- component = new QDeclarativeComponent(engine, QDeclarativeDataTest::instance()->testFileUrl("recursiveClear.2.qml"));
- component->create(*incubator);
- }
-};
-
-void tst_qdeclarativeincubator::recursiveClear()
-{
- Switcher switcher(&engine);
- switcher.start();
-}
-
-void tst_qdeclarativeincubator::statusChanged()
-{
- class MyIncubator : public QDeclarativeIncubator
- {
- public:
- MyIncubator(QDeclarativeIncubator::IncubationMode mode = QDeclarativeIncubator::Asynchronous)
- : QDeclarativeIncubator(mode) {}
-
- QList<int> statuses;
- protected:
- virtual void statusChanged(Status s) { statuses << s; }
- virtual void setInitialState(QObject *) { statuses << -1; }
- };
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("statusChanged.qml"));
- QVERIFY(component.isReady());
-
- MyIncubator incubator(QDeclarativeIncubator::Synchronous);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QCOMPARE(incubator.statuses.count(), 3);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
- QCOMPARE(incubator.statuses.at(1), -1);
- QCOMPARE(incubator.statuses.at(2), int(QDeclarativeIncubator::Ready));
- delete incubator.object();
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("statusChanged.qml"));
- QVERIFY(component.isReady());
-
- MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
- QVERIFY(incubator.isLoading());
- QCOMPARE(incubator.statuses.count(), 1);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QCOMPARE(incubator.statuses.count(), 3);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
- QCOMPARE(incubator.statuses.at(1), -1);
- QCOMPARE(incubator.statuses.at(2), int(QDeclarativeIncubator::Ready));
- delete incubator.object();
- }
-
- {
- QDeclarativeComponent component2(&engine, testFileUrl("statusChanged.nested.qml"));
- QVERIFY(component2.isReady());
-
- MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component2.create(incubator);
- QVERIFY(incubator.isLoading());
- QCOMPARE(incubator.statuses.count(), 1);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isReady());
- QCOMPARE(incubator.statuses.count(), 3);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
- QCOMPARE(incubator.statuses.at(1), -1);
- QCOMPARE(incubator.statuses.at(2), int(QDeclarativeIncubator::Ready));
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::asynchronousIfNested()
-{
- // Asynchronous if nested within a finalized context behaves synchronously
- {
- QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.1.qml"));
- QVERIFY(component.isReady());
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 10);
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- component.create(incubator, 0, qmlContext(object));
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("a").toInt(), 10);
- delete incubator.object();
- delete object;
- }
-
- // Asynchronous if nested within an executing context behaves asynchronously, but prevents
- // the parent from finishing
- {
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.2.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() == 0);
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- QDeclarativeIncubator nested(QDeclarativeIncubator::AsynchronousIfNested);
- component.create(nested, 0, qmlContext(SelfRegisteringType::me()));
- QVERIFY(nested.isLoading());
-
- while (nested.isLoading()) {
- QVERIFY(incubator.isLoading());
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(nested.isReady());
- QVERIFY(incubator.isLoading());
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(nested.isReady());
- QVERIFY(incubator.isReady());
-
- delete nested.object();
- delete incubator.object();
- }
-
- // AsynchronousIfNested within a synchronous AsynchronousIfNested behaves synchronously
- {
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.3.qml"));
- QVERIFY(component.isReady());
-
- struct CallbackData {
- CallbackData(QDeclarativeEngine *e) : engine(e), pass(false) {}
- QDeclarativeEngine *engine;
- bool pass;
- static void callback(CallbackRegisteringType *o, void *data) {
- CallbackData *d = (CallbackData *)data;
-
- QDeclarativeComponent c(d->engine, QDeclarativeDataTest::instance()->testFileUrl("asynchronousIfNested.1.qml"));
- if (!c.isReady()) return;
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- c.create(incubator, 0, qmlContext(o));
-
- if (!incubator.isReady()) return;
-
- if (incubator.object()->property("a").toInt() != 10) return;
-
- d->pass = true;
- }
- };
-
- CallbackData cd(&engine);
- CallbackRegisteringType::registerCallback(&CallbackData::callback, &cd);
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- component.create(incubator);
-
- QVERIFY(incubator.isReady());
- QCOMPARE(cd.pass, true);
-
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::nestedComponent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nestedComponent.qml"));
- QVERIFY(component.isReady());
-
- QObject *object = component.create();
-
- QDeclarativeComponent *nested = object->property("c").value<QDeclarativeComponent*>();
- QVERIFY(nested);
- QVERIFY(nested->isReady());
-
- // Test without incubator
- {
- QObject *nestedObject = nested->create();
- QCOMPARE(nestedObject->property("value").toInt(), 19988);
- delete nestedObject;
- }
-
- // Test with incubator
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Synchronous);
- nested->create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("value").toInt(), 19988);
- delete incubator.object();
- }
-
- delete object;
-}
-
-// Checks that a new AsynchronousIfNested incubator can be correctly started in the
-// statusChanged() callback of another.
-void tst_qdeclarativeincubator::chainedAsynchronousIfNested()
-{
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() == 0);
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- struct MyIncubator : public QDeclarativeIncubator {
- MyIncubator(MyIncubator *next, QDeclarativeComponent *component, QDeclarativeContext *ctxt)
- : QDeclarativeIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {}
-
- protected:
- virtual void statusChanged(Status s) {
- if (s == Ready && next)
- component->create(*next, 0, ctxt);
- }
-
- private:
- MyIncubator *next;
- QDeclarativeComponent *component;
- QDeclarativeContext *ctxt;
- };
-
- MyIncubator incubator2(0, &component, 0);
- MyIncubator incubator1(&incubator2, &component, qmlContext(SelfRegisteringType::me()));
-
- component.create(incubator1, 0, qmlContext(SelfRegisteringType::me()));
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isLoading());
- QVERIFY(incubator2.isNull());
-
- while (incubator1.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isLoading());
- QVERIFY(incubator2.isNull());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isLoading());
-
- while (incubator2.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isLoading());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
-}
-
-// Checks that new AsynchronousIfNested incubators can be correctly chained if started in
-// componentCompleted().
-void tst_qdeclarativeincubator::chainedAsynchronousIfNestedOnCompleted()
-{
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("chainInCompletion.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeComponent c1(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
- QVERIFY(c1.isReady());
-
- struct MyIncubator : public QDeclarativeIncubator {
- MyIncubator(MyIncubator *next, QDeclarativeComponent *component, QDeclarativeContext *ctxt)
- : QDeclarativeIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {}
-
- protected:
- virtual void statusChanged(Status s) {
- if (s == Ready && next) {
- component->create(*next, 0, ctxt);
- }
- }
-
- private:
- MyIncubator *next;
- QDeclarativeComponent *component;
- QDeclarativeContext *ctxt;
- };
-
- struct CallbackData {
- CallbackData(QDeclarativeComponent *c, MyIncubator *i, QDeclarativeContext *ct)
- : component(c), incubator(i), ctxt(ct) {}
- QDeclarativeComponent *component;
- MyIncubator *incubator;
- QDeclarativeContext *ctxt;
- static void callback(CompletionCallbackType *, void *data) {
- CallbackData *d = (CallbackData *)data;
- d->component->create(*d->incubator, 0, d->ctxt);
- }
- };
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() == 0);
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- MyIncubator incubator3(0, &c1, qmlContext(SelfRegisteringType::me()));
- MyIncubator incubator2(&incubator3, &c1, qmlContext(SelfRegisteringType::me()));
- MyIncubator incubator1(&incubator2, &c1, qmlContext(SelfRegisteringType::me()));
-
- // start incubator1 in componentComplete
- CallbackData cd(&c1, &incubator1, qmlContext(SelfRegisteringType::me()));
- CompletionCallbackType::registerCallback(&CallbackData::callback, &cd);
-
- while (!incubator1.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator2.isNull());
- QVERIFY(incubator3.isNull());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isLoading());
- QVERIFY(incubator2.isNull());
- QVERIFY(incubator3.isNull());
-
- while (incubator1.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isLoading());
- QVERIFY(incubator2.isNull());
- QVERIFY(incubator3.isNull());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isLoading());
- QVERIFY(incubator3.isNull());
-
- while (incubator2.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isLoading());
- QVERIFY(incubator3.isNull());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
- QVERIFY(incubator3.isLoading());
-
- while (incubator3.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
- QVERIFY(incubator3.isLoading());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
- QVERIFY(incubator3.isReady());
-}
-
-void tst_qdeclarativeincubator::selfDelete()
-{
- struct MyIncubator : public QDeclarativeIncubator {
- MyIncubator(bool *done, Status status, IncubationMode mode)
- : QDeclarativeIncubator(mode), done(done), status(status) {}
-
- protected:
- virtual void statusChanged(Status s) {
- if (s == status) {
- *done = true;
- if (s == Ready) delete object();
- delete this;
- }
- }
-
- private:
- bool *done;
- Status status;
- };
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("selfDelete.qml"));
-
-#define DELETE_TEST(status, mode) { \
- bool done = false; \
- component.create(*(new MyIncubator(&done, status, mode))); \
- bool True = true; \
- controller.incubateWhile(&True); \
- QVERIFY(done == true); \
- }
-
- DELETE_TEST(QDeclarativeIncubator::Loading, QDeclarativeIncubator::Synchronous);
- DELETE_TEST(QDeclarativeIncubator::Ready, QDeclarativeIncubator::Synchronous);
- DELETE_TEST(QDeclarativeIncubator::Loading, QDeclarativeIncubator::Asynchronous);
- DELETE_TEST(QDeclarativeIncubator::Ready, QDeclarativeIncubator::Asynchronous);
-
-#undef DELETE_TEST
- }
-
- // Delete within error status
- {
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("objectDeleted.qml"));
- QVERIFY(component.isReady());
-
- bool done = false;
- MyIncubator *incubator = new MyIncubator(&done, QDeclarativeIncubator::Error,
- QDeclarativeIncubator::Asynchronous);
- component.create(*incubator);
-
- QCOMPARE(incubator->QDeclarativeIncubator::status(), QDeclarativeIncubator::Loading);
- QVERIFY(SelfRegisteringType::me() == 0);
-
- while (SelfRegisteringType::me() == 0 && incubator->isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator->isLoading());
-
- delete SelfRegisteringType::me();
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(done);
- }
-}
-
-// Test that QML doesn't crash if the context is deleted prior to the incubator
-// first executing.
-void tst_qdeclarativeincubator::contextDelete()
-{
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- QDeclarativeComponent component(&engine, testFileUrl("contextDelete.qml"));
-
- QDeclarativeIncubator incubator;
- component.create(incubator, context);
-
- delete context;
-
- {
- bool b = false;
- controller.incubateWhile(&b);
- }
-}
-
-QTEST_MAIN(tst_qdeclarativeincubator)
-
-#include "tst_qdeclarativeincubator.moc"
diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
deleted file mode 100644
index af4667184f..0000000000
--- a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeinfo
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeinfo.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private widgets testlib
diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
deleted file mode 100644
index 868cd901c0..0000000000
--- a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QTimer>
-#include <QDeclarativeContext>
-#include <qdeclarativeinfo.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeinfo : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeinfo() {}
-
-private slots:
- void qmlObject();
- void nestedQmlObject();
- void nestedComponent();
- void nonQmlObject();
- void nullObject();
- void nonQmlContextedObject();
- void types();
- void chaining();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeinfo::qmlObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qmlObject.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QString message = component.url().toString() + ":3:1: QML QtObject: Test Message";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(object) << "Test Message";
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
-
- message = component.url().toString() + ":6:13: QML QtObject: Second Test Message";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Second Test Message";
-}
-
-void tst_qdeclarativeinfo::nestedQmlObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nestedQmlObject.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
- QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
- QVERIFY(nested2 != 0);
-
- QString message = component.url().toString() + ":5:13: QML NestedObject: Outer Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Outer Object";
-
- message = testFileUrl("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested2) << "Inner Object";
-}
-
-void tst_qdeclarativeinfo::nestedComponent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("NestedComponent.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
- QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
- QVERIFY(nested2 != 0);
-
- QString message = component.url().toString() + ":10:9: QML NestedObject: Complex Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Complex Object";
-
- message = component.url().toString() + ":16:9: QML Image: Simple Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested2) << "Simple Object";
-}
-
-void tst_qdeclarativeinfo::nonQmlObject()
-{
- QObject object;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Test Message");
- qmlInfo(&object) << "Test Message";
-
- QTimer nonQmlObject;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QTimer: Test Message");
- qmlInfo(&nonQmlObject) << "Test Message";
-}
-
-void tst_qdeclarativeinfo::nullObject()
-{
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Null Object Test Message");
- qmlInfo(0) << "Null Object Test Message";
-}
-
-void tst_qdeclarativeinfo::nonQmlContextedObject()
-{
- QObject object;
- QDeclarativeContext context(&engine);
- QDeclarativeEngine::setContextForObject(&object, &context);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Test Message");
- qmlInfo(&object) << "Test Message";
-}
-
-void tst_qdeclarativeinfo::types()
-{
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false");
- qmlInfo(0) << false;
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.1");
- qmlInfo(0) << 1.1;
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.2");
- qmlInfo(0) << 1.2f;
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 15");
- qmlInfo(0) << 15;
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 'b'");
- qmlInfo(0) << QChar('b');
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: \"Qt\"");
- qmlInfo(0) << QByteArray("Qt");
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: true");
- qmlInfo(0) << bool(true);
-
- //### do we actually want QUrl to show up in the output?
- //### why the extra space at the end?
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QUrl(\"http://qt.nokia.com\") ");
- qmlInfo(0) << QUrl("http://qt.nokia.com");
-
- //### should this be quoted?
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: hello");
- qmlInfo(0) << QLatin1String("hello");
-
- //### should this be quoted?
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: World");
- QString str("Hello World");
- QStringRef ref(&str, 6, 5);
- qmlInfo(0) << ref;
-
- //### should this be quoted?
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Quick");
- qmlInfo(0) << QString ("Quick");
-}
-
-void tst_qdeclarativeinfo::chaining()
-{
- //### should more of these be automatically inserting spaces?
- QString str("Hello World");
- QStringRef ref(&str, 6, 5);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' QUrl(\"http://qt.nokia.com\") World \"Qt\" true Quick ");
- qmlInfo(0) << false << ' '
- << 1.1 << ' '
- << 1.2f << ' '
- << 15 << ' '
- << QLatin1String("hello") << ' '
- << QChar('b') << ' '
- << QUrl("http://qt.nokia.com")
- << ref
- << QByteArray("Qt")
- << bool(true)
- << QString ("Quick");
-}
-
-QTEST_MAIN(tst_qdeclarativeinfo)
-
-#include "tst_qdeclarativeinfo.moc"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
deleted file mode 100644
index 437b0869d1..0000000000
--- a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeinstruction
-SOURCES += tst_qdeclarativeinstruction.cpp
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
deleted file mode 100644
index 769d385efc..0000000000
--- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
+++ /dev/null
@@ -1,678 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <private/qdeclarativecompiler_p.h>
-
-class tst_qdeclarativeinstruction : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeinstruction() {}
-
-private slots:
- void dump();
-
- void point();
- void pointf();
- void size();
- void sizef();
- void rect();
- void rectf();
- void vector3d();
- void vector4d();
- void time();
-};
-
-static QStringList messages;
-static void msgHandler(QtMsgType, const char *msg)
-{
- messages << QLatin1String(msg);
-}
-
-void tst_qdeclarativeinstruction::dump()
-{
- QDeclarativeEngine engine;
- QDeclarativeCompiledData *data = new QDeclarativeCompiledData(&engine);
-
- {
- QDeclarativeCompiledData::Instruction::Init i;
- i.bindingsSize = 0;
- i.parserStatusSize = 3;
- i.contextCache = -1;
- i.compiledBinding = -1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::TypeReference ref;
- ref.className = "Test";
- data->types << ref;
-
- QDeclarativeCompiledData::Instruction::CreateCppObject i;
- i.type = 0;
- i.data = -1;
- i.column = 10;
- data->addInstruction(i);
- }
-
- {
- data->primitives << "testId";
-
- QDeclarativeCompiledData::Instruction::SetId i;
- i.value = data->primitives.count() - 1;
- i.index = 0;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::SetDefault i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::CreateComponent i;
- i.count = 3;
- i.column = 4;
- i.endLine = 14;
- i.metaObject = 0;
-
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreMetaObject i;
- i.data = 3;
- i.aliasData = 6;
- i.propertyCache = 7;
-
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreFloat i;
- i.propertyIndex = 3;
- i.value = 11.3;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreDouble i;
- i.propertyIndex = 4;
- i.value = 14.8;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreInteger i;
- i.propertyIndex = 5;
- i.value = 9;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreBool i;
- i.propertyIndex = 6;
- i.value = true;
-
- data->addInstruction(i);
- }
-
- {
- data->primitives << "Test String";
- QDeclarativeCompiledData::Instruction::StoreString i;
- i.propertyIndex = 7;
- i.value = data->primitives.count() - 1;
- data->addInstruction(i);
- }
-
- {
- data->urls << QUrl("http://www.nokia.com");
- QDeclarativeCompiledData::Instruction::StoreUrl i;
- i.propertyIndex = 8;
- i.value = data->urls.count() - 1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreColor i;
- i.propertyIndex = 9;
- i.value = 0xFF00FF00;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreDate i;
- i.propertyIndex = 10;
- i.value = 9;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreTime i;
- i.propertyIndex = 11;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreDateTime i;
- i.propertyIndex = 12;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StorePoint i;
- i.propertyIndex = 13;
- i.point.xp = 3;
- i.point.yp = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StorePointF i;
- i.propertyIndex = 13;
- i.point.xp = 3;
- i.point.yp = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreSize i;
- i.propertyIndex = 15;
- i.size.wd = 8;
- i.size.ht = 11;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreSizeF i;
- i.propertyIndex = 15;
- i.size.wd = 8;
- i.size.ht = 11;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreRect i;
- i.propertyIndex = 17;
- i.rect.x1 = 7;
- i.rect.y1 = 9;
- i.rect.x2 = 11;
- i.rect.y2 = 13;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreRectF i;
- i.propertyIndex = 18;
- i.rect.xp = 11.3;
- i.rect.yp = 9.8;
- i.rect.w = 3;
- i.rect.h = 2.1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreVector3D i;
- i.propertyIndex = 19;
- i.vector.xp = 9;
- i.vector.yp = 3;
- i.vector.zp = 92;
- data->addInstruction(i);
- }
-
- {
- data->primitives << "color(1, 1, 1, 1)";
- QDeclarativeCompiledData::Instruction::StoreVariant i;
- i.propertyIndex = 20;
- i.value = data->primitives.count() - 1;
-
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreObject i;
- i.propertyIndex = 21;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreVariantObject i;
- i.propertyIndex = 22;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreInterface i;
- i.propertyIndex = 23;
- data->addInstruction(i);
- }
-
- {
- data->primitives << "console.log(1921)";
-
- QDeclarativeCompiledData::Instruction::StoreSignal i;
- i.signalIndex = 2;
- i.value = data->primitives.count() - 1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreScriptString i;
- i.propertyIndex = 24;
- i.value = 3;
- i.scope = 1;
- i.bindingId = 4;
- data->addInstruction(i);
- }
-
- {
- data->primitives << "mySignal";
-
- QDeclarativeCompiledData::Instruction::AssignSignalObject i;
- i.signal = data->primitives.count() - 1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::AssignCustomType i;
- i.propertyIndex = 25;
- i.primitive = 6;
- i.type = 9;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreBinding i;
- i.property.coreIndex = 26;
- i.value = 3;
- i.context = 2;
- i.owner = 0;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreV4Binding i;
- i.property = 27;
- i.value = 2;
- i.context = 4;
- i.owner = 0;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreValueSource i;
- i.property.coreIndex = 29;
- i.owner = 1;
- i.castValue = 4;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreValueInterceptor i;
- i.property.coreIndex = 30;
- i.owner = 2;
- i.castValue = -4;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::BeginObject i;
- i.castValue = 4;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreObjectQList i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::AssignObjectList i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::FetchAttached i;
- i.id = 23;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::FetchQList i;
- i.property = 32;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::FetchObject i;
- i.property = 33;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::FetchValueType i;
- i.property = 34;
- i.type = 6;
- i.bindingSkipList = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::PopFetchedObject i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::PopQList i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::PopValueType i;
- i.property = 35;
- i.type = 8;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::Defer i;
- i.deferCount = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::Defer i;
- i.deferCount = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreImportedScript i;
- i.value = 2;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreVariantInteger i;
- i.value = 11;
- i.propertyIndex = 32;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreVariantDouble i;
- i.value = 33.7;
- i.propertyIndex = 19;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::Done i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreTrString i;
- i.propertyIndex = 99;
- i.context = 3;
- i.text = 14;
- i.comment = 14;
- i.n = 2;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreTrIdString i;
- i.propertyIndex = 78;
- i.text = 7;
- i.n = -1;
- data->addInstruction(i);
- }
-
- QStringList expect;
- expect
- << "Index\tOperation\t\tData1\tData2\tData3\tComments"
- << "-------------------------------------------------------------------------------"
- << "0\t\tINIT\t\t\t0\t3\t-1\t-1"
- << "1\t\tCREATECPP\t\t\t0\t\t\t\"Test\""
- << "2\t\tSETID\t\t\t0\t\t\t\"testId\""
- << "3\t\tSET_DEFAULT"
- << "4\t\tCREATE_COMPONENT\t3"
- << "5\t\tSTORE_META\t\t3"
- << "6\t\tSTORE_FLOAT\t\t3\t11.3"
- << "7\t\tSTORE_DOUBLE\t\t4\t14.8"
- << "8\t\tSTORE_INTEGER\t\t5\t9"
- << "9\t\tSTORE_BOOL\t\t6\ttrue"
- << "10\t\tSTORE_STRING\t\t7\t1\t\t\"Test String\""
- << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.nokia.com\") "
- << "12\t\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
- << "13\t\tSTORE_DATE\t\t10\t9"
- << "14\t\tSTORE_TIME\t\t11"
- << "15\t\tSTORE_DATETIME\t\t12"
- << "16\t\tSTORE_POINT\t\t13\t3\t7"
- << "17\t\tSTORE_POINTF\t\t13\t3\t7"
- << "18\t\tSTORE_SIZE\t\t15\t8\t11"
- << "19\t\tSTORE_SIZEF\t\t15\t8\t11"
- << "20\t\tSTORE_RECT\t\t17\t7\t9\t11\t13"
- << "21\t\tSTORE_RECTF\t\t18\t11.3\t9.8\t3\t2.1"
- << "22\t\tSTORE_VECTOR3D\t\t19\t9\t3\t92"
- << "23\t\tSTORE_VARIANT\t\t20\t2\t\t\"color(1, 1, 1, 1)\""
- << "24\t\tSTORE_OBJECT\t\t21"
- << "25\t\tSTORE_VARIANT_OBJECT\t22"
- << "26\t\tSTORE_INTERFACE\t\t23"
- << "27\t\tSTORE_SIGNAL\t\t2\t3"
- << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4"
- << "29\t\tASSIGN_SIGNAL_OBJECT\t4"
- << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9"
- << "31\t\tSTORE_BINDING\t26\t3\t2"
- << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4"
- << "33\t\tSTORE_VALUE_SOURCE\t29\t4"
- << "34\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
- << "35\t\tBEGIN\t\t\t4"
- << "36\t\tSTORE_OBJECT_QLIST"
- << "37\t\tASSIGN_OBJECT_LIST"
- << "38\t\tFETCH_ATTACHED\t\t23"
- << "39\t\tFETCH_QLIST\t\t32"
- << "40\t\tFETCH\t\t\t33"
- << "41\t\tFETCH_VALUE\t\t34\t6\t7"
- << "42\t\tPOP"
- << "43\t\tPOP_QLIST"
- << "44\t\tPOP_VALUE\t\t35\t8"
- << "45\t\tDEFER\t\t\t7"
- << "46\t\tDEFER\t\t\t7"
- << "47\t\tSTORE_IMPORTED_SCRIPT\t2"
- << "48\t\tSTORE_VARIANT_INTEGER\t\t32\t11"
- << "49\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7"
- << "50\t\tDONE"
- << "51\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2"
- << "52\t\tSTORE_TRID_STRING\t78\t7\t-1"
- << "-------------------------------------------------------------------------------";
-
- messages = QStringList();
- QtMsgHandler old = qInstallMsgHandler(msgHandler);
-
- data->dumpInstructions();
- qInstallMsgHandler(old);
-
- QCOMPARE(messages.count(), expect.count());
- for (int ii = 0; ii < messages.count(); ++ii) {
- QCOMPARE(messages.at(ii), expect.at(ii));
- }
-
- data->release();
-}
-
-void tst_qdeclarativeinstruction::point()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storePoint::QPoint), sizeof(QPoint));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storePoint::QPoint), Q_ALIGNOF(QPoint));
-
- QDeclarativeInstruction i;
- i.storePoint.point.xp = 8;
- i.storePoint.point.yp = 11;
-
- const QPoint &point = (const QPoint &)(i.storePoint.point);
- QCOMPARE(point.x(), 8);
- QCOMPARE(point.y(), 11);
-}
-
-void tst_qdeclarativeinstruction::pointf()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storePointF::QPointF), sizeof(QPointF));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storePointF::QPointF), Q_ALIGNOF(QPointF));
-
- QDeclarativeInstruction i;
- i.storePointF.point.xp = 8.7;
- i.storePointF.point.yp = 11.3;
-
- const QPointF &point = (const QPointF &)(i.storePointF.point);
- QCOMPARE(point.x(), 8.7);
- QCOMPARE(point.y(), 11.3);
-}
-
-void tst_qdeclarativeinstruction::size()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeSize::QSize), sizeof(QSize));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeSize::QSize), Q_ALIGNOF(QSize));
-
- QDeclarativeInstruction i;
- i.storeSize.size.wd = 8;
- i.storeSize.size.ht = 11;
-
- const QSize &size = (const QSize &)(i.storeSize.size);
- QCOMPARE(size.width(), 8);
- QCOMPARE(size.height(), 11);
-}
-
-void tst_qdeclarativeinstruction::sizef()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeSizeF::QSizeF), sizeof(QSizeF));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeSizeF::QSizeF), Q_ALIGNOF(QSizeF));
-
- QDeclarativeInstruction i;
- i.storeSizeF.size.wd = 8;
- i.storeSizeF.size.ht = 11;
-
- const QSizeF &size = (const QSizeF &)(i.storeSizeF.size);
- QCOMPARE(size.width(), (qreal)8);
- QCOMPARE(size.height(), (qreal)11);
-}
-
-void tst_qdeclarativeinstruction::rect()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeRect::QRect), sizeof(QRect));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeRect::QRect), Q_ALIGNOF(QRect));
-
- QDeclarativeInstruction i;
- i.storeRect.rect.x1 = 8;
- i.storeRect.rect.y1 = 11;
- i.storeRect.rect.x2 = 13;
- i.storeRect.rect.y2 = 19;
-
- const QRect &rect = (const QRect &)(i.storeRect.rect);
- QCOMPARE(rect.left(), 8);
- QCOMPARE(rect.top(), 11);
- QCOMPARE(rect.right(), 13);
- QCOMPARE(rect.bottom(), 19);
-}
-
-void tst_qdeclarativeinstruction::rectf()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeRectF::QRectF), sizeof(QRectF));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeRectF::QRectF), Q_ALIGNOF(QRectF));
-
- QDeclarativeInstruction i;
- i.storeRectF.rect.xp = 8;
- i.storeRectF.rect.yp = 11;
- i.storeRectF.rect.w = 13;
- i.storeRectF.rect.h = 19;
-
- const QRectF &rect = (const QRectF &)(i.storeRectF.rect);
- QCOMPARE(rect.left(), (qreal)8);
- QCOMPARE(rect.top(), (qreal)11);
- QCOMPARE(rect.width(), (qreal)13);
- QCOMPARE(rect.height(), (qreal)19);
-}
-
-void tst_qdeclarativeinstruction::vector3d()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeVector3D::QVector3D), sizeof(QVector3D));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeVector3D::QVector3D), Q_ALIGNOF(QVector3D));
-
- QDeclarativeInstruction i;
- i.storeVector3D.vector.xp = 8.2;
- i.storeVector3D.vector.yp = 99.3;
- i.storeVector3D.vector.zp = 12.0;
-
- const QVector3D &vector = (const QVector3D &)(i.storeVector3D.vector);
- QCOMPARE(vector.x(), (qreal)(float)8.2);
- QCOMPARE(vector.y(), (qreal)(float)99.3);
- QCOMPARE(vector.z(), (qreal)(float)12.0);
-}
-
-void tst_qdeclarativeinstruction::vector4d()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeVector4D::QVector4D), sizeof(QVector4D));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeVector4D::QVector4D), Q_ALIGNOF(QVector4D));
-
- QDeclarativeInstruction i;
- i.storeVector4D.vector.xp = 8.2;
- i.storeVector4D.vector.yp = 99.3;
- i.storeVector4D.vector.zp = 12.0;
- i.storeVector4D.vector.wp = 121.1;
-
- const QVector4D &vector = (const QVector4D &)(i.storeVector4D.vector);
- QCOMPARE(vector.x(), (qreal)(float)8.2);
- QCOMPARE(vector.y(), (qreal)(float)99.3);
- QCOMPARE(vector.z(), (qreal)(float)12.0);
- QCOMPARE(vector.w(), (qreal)(float)121.1);
-}
-
-void tst_qdeclarativeinstruction::time()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeTime::QTime), sizeof(QTime));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeTime::QTime), Q_ALIGNOF(QTime));
-}
-
-QTEST_MAIN(tst_qdeclarativeinstruction)
-
-#include "tst_qdeclarativeinstruction.moc"
diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
deleted file mode 100644
index f79d1c99c9..0000000000
--- a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelanguage
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelanguage.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += ../../shared/testhttpserver.cpp
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
deleted file mode 100644
index ec0c185123..0000000000
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ /dev/null
@@ -1,824 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qdatetime.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeparserstatus.h>
-#include <QtDeclarative/qdeclarativepropertyvaluesource.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-
-#include <private/qdeclarativecustomparser_p.h>
-
-QVariant myCustomVariantTypeConverter(const QString &data);
-
-class MyInterface
-{
-public:
- MyInterface() : id(913) {}
- int id;
-};
-
-QT_BEGIN_NAMESPACE
-#define MyInterface_iid "org.qt-project.Qt.Test.MyInterface"
-Q_DECLARE_INTERFACE(MyInterface, MyInterface_iid);
-QT_END_NAMESPACE
-QML_DECLARE_INTERFACE(MyInterface);
-
-struct MyCustomVariantType
-{
- MyCustomVariantType() : a(0) {}
- int a;
-};
-Q_DECLARE_METATYPE(MyCustomVariantType);
-
-class MyAttachedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY(int value2 READ value2 WRITE setValue2)
-public:
- MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {}
-
- int value() const { return m_value; }
- void setValue(int v) { if (m_value != v) { m_value = v; emit valueChanged(); } }
-
- int value2() const { return m_value2; }
- void setValue2(int v) { m_value2 = v; }
-
-signals:
- void valueChanged();
-
-private:
- int m_value;
- int m_value2;
-};
-
-class MyQmlObject : public QObject, public MyInterface
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue FINAL)
- Q_PROPERTY(QString readOnlyString READ readOnlyString)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
- Q_PROPERTY(QRect rect READ rect WRITE setRect)
- Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML
- Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
- Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal)
- Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType)
- Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
- Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
- Q_PROPERTY(int nonScriptable READ nonScriptable WRITE setNonScriptable SCRIPTABLE false)
-
- Q_INTERFACES(MyInterface)
-public:
- MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
- QString readOnlyString() const { return QLatin1String(""); }
-
- bool enabled() const { return false; }
- void setEnabled(bool) {}
-
- QRect rect() const { return QRect(); }
- void setRect(const QRect&) {}
-
- QMatrix matrix() const { return QMatrix(); }
- void setMatrix(const QMatrix&) {}
-
- MyInterface *interface() const { return m_interface; }
- void setInterface(MyInterface *iface) { m_interface = iface; }
-
- static MyAttachedObject *qmlAttachedProperties(QObject *other) {
- return new MyAttachedObject(other);
- }
- Q_CLASSINFO("DefaultMethod", "basicSlot()")
-
- int onLiteralSignal() const { return m_value; }
- void setOnLiteralSignal(int v) { m_value = v; }
-
- MyQmlObject *qmlobject() const { return m_qmlobject; }
- void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
-
- MyCustomVariantType customType() const { return m_custom; }
- void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
-
- int propertyWithNotify() const { return m_propertyWithNotify; }
- void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
-
- int nonScriptable() const { return 0; }
- void setNonScriptable(int) {}
-public slots:
- void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
- void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
-
-signals:
- void basicSignal();
- void basicParameterizedSignal(int parameter);
- void oddlyNamedNotifySignal();
-
-private:
- friend class tst_qdeclarativelanguage;
- int m_value;
- MyInterface *m_interface;
- MyQmlObject *m_qmlobject;
- MyCustomVariantType m_custom;
- int m_propertyWithNotify;
-};
-QML_DECLARE_TYPE(MyQmlObject)
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-
-class MyGroupedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
- Q_PROPERTY(int value READ value WRITE setValue)
-public:
- QDeclarativeScriptString script() const { return m_script; }
- void setScript(const QDeclarativeScriptString &s) { m_script = s; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
-private:
- int m_value;
- QDeclarativeScriptString m_script;
-};
-
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_FLAGS(MyFlags)
-
- Q_PROPERTY(QString id READ id WRITE setId)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
- Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty)
- Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
- Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
- Q_PROPERTY(MyEnum readOnlyEnumProperty READ readOnlyEnumProperty)
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
- Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
- Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
- Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
- Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
- Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
- Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
- Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
- Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
- Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
- Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
- Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
- Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
- Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
- Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
- Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
- Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
- Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
- Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
- Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
- Q_PROPERTY(QVector4D vector4Property READ vector4Property WRITE setVector4Property)
- Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
-
- Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
- Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT)
- Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT)
-
-public:
- MyTypeObject()
- : objectPropertyValue(0), componentPropertyValue(0) {}
-
- QString idValue;
- QString id() const {
- return idValue;
- }
- void setId(const QString &v) {
- idValue = v;
- }
-
- QObject *objectPropertyValue;
- QObject *objectProperty() const {
- return objectPropertyValue;
- }
- void setObjectProperty(QObject *v) {
- objectPropertyValue = v;
- }
-
- QDeclarativeComponent *componentPropertyValue;
- QDeclarativeComponent *componentProperty() const {
- return componentPropertyValue;
- }
- void setComponentProperty(QDeclarativeComponent *v) {
- componentPropertyValue = v;
- }
-
- enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
- Q_DECLARE_FLAGS(MyFlags, MyFlag)
- MyFlags flagPropertyValue;
- MyFlags flagProperty() const {
- return flagPropertyValue;
- }
- void setFlagProperty(MyFlags v) {
- flagPropertyValue = v;
- }
-
- enum MyEnum { EnumVal1, EnumVal2 };
- MyEnum enumPropertyValue;
- MyEnum enumProperty() const {
- return enumPropertyValue;
- }
- void setEnumProperty(MyEnum v) {
- enumPropertyValue = v;
- }
-
- MyEnum readOnlyEnumProperty() const {
- return EnumVal1;
- }
-
- QString stringPropertyValue;
- QString stringProperty() const {
- return stringPropertyValue;
- }
- void setStringProperty(const QString &v) {
- stringPropertyValue = v;
- }
-
- uint uintPropertyValue;
- uint uintProperty() const {
- return uintPropertyValue;
- }
- void setUintProperty(const uint &v) {
- uintPropertyValue = v;
- }
-
- int intPropertyValue;
- int intProperty() const {
- return intPropertyValue;
- }
- void setIntProperty(const int &v) {
- intPropertyValue = v;
- }
-
- qreal realPropertyValue;
- qreal realProperty() const {
- return realPropertyValue;
- }
- void setRealProperty(const qreal &v) {
- realPropertyValue = v;
- }
-
- double doublePropertyValue;
- double doubleProperty() const {
- return doublePropertyValue;
- }
- void setDoubleProperty(const double &v) {
- doublePropertyValue = v;
- }
-
- float floatPropertyValue;
- float floatProperty() const {
- return floatPropertyValue;
- }
- void setFloatProperty(const float &v) {
- floatPropertyValue = v;
- }
-
- QColor colorPropertyValue;
- QColor colorProperty() const {
- return colorPropertyValue;
- }
- void setColorProperty(const QColor &v) {
- colorPropertyValue = v;
- }
-
- QDate datePropertyValue;
- QDate dateProperty() const {
- return datePropertyValue;
- }
- void setDateProperty(const QDate &v) {
- datePropertyValue = v;
- }
-
- QTime timePropertyValue;
- QTime timeProperty() const {
- return timePropertyValue;
- }
- void setTimeProperty(const QTime &v) {
- timePropertyValue = v;
- }
-
- QDateTime dateTimePropertyValue;
- QDateTime dateTimeProperty() const {
- return dateTimePropertyValue;
- }
- void setDateTimeProperty(const QDateTime &v) {
- dateTimePropertyValue = v;
- }
-
- QPoint pointPropertyValue;
- QPoint pointProperty() const {
- return pointPropertyValue;
- }
- void setPointProperty(const QPoint &v) {
- pointPropertyValue = v;
- }
-
- QPointF pointFPropertyValue;
- QPointF pointFProperty() const {
- return pointFPropertyValue;
- }
- void setPointFProperty(const QPointF &v) {
- pointFPropertyValue = v;
- }
-
- QSize sizePropertyValue;
- QSize sizeProperty() const {
- return sizePropertyValue;
- }
- void setSizeProperty(const QSize &v) {
- sizePropertyValue = v;
- }
-
- QSizeF sizeFPropertyValue;
- QSizeF sizeFProperty() const {
- return sizeFPropertyValue;
- }
- void setSizeFProperty(const QSizeF &v) {
- sizeFPropertyValue = v;
- }
-
- QRect rectPropertyValue;
- QRect rectProperty() const {
- return rectPropertyValue;
- }
- void setRectProperty(const QRect &v) {
- rectPropertyValue = v;
- emit rectPropertyChanged();
- }
-
- QRect rectPropertyValue2;
- QRect rectProperty2() const {
- return rectPropertyValue2;
- }
- void setRectProperty2(const QRect &v) {
- rectPropertyValue2 = v;
- }
-
- QRectF rectFPropertyValue;
- QRectF rectFProperty() const {
- return rectFPropertyValue;
- }
- void setRectFProperty(const QRectF &v) {
- rectFPropertyValue = v;
- }
-
- bool boolPropertyValue;
- bool boolProperty() const {
- return boolPropertyValue;
- }
- void setBoolProperty(const bool &v) {
- boolPropertyValue = v;
- }
-
- QVariant variantPropertyValue;
- QVariant variantProperty() const {
- return variantPropertyValue;
- }
- void setVariantProperty(const QVariant &v) {
- variantPropertyValue = v;
- }
-
- QVector3D vectorPropertyValue;
- QVector3D vectorProperty() const {
- return vectorPropertyValue;
- }
- void setVectorProperty(const QVector3D &v) {
- vectorPropertyValue = v;
- }
-
- QVector4D vector4PropertyValue;
- QVector4D vector4Property() const {
- return vector4PropertyValue;
- }
- void setVector4Property(const QVector4D &v) {
- vector4PropertyValue = v;
- }
-
- QUrl urlPropertyValue;
- QUrl urlProperty() const {
- return urlPropertyValue;
- }
- void setUrlProperty(const QUrl &v) {
- urlPropertyValue = v;
- }
-
- QDeclarativeScriptString scriptPropertyValue;
- QDeclarativeScriptString scriptProperty() const {
- return scriptPropertyValue;
- }
- void setScriptProperty(const QDeclarativeScriptString &v) {
- scriptPropertyValue = v;
- }
-
- MyGroupedObject groupedValue;
- MyGroupedObject *grouped() { return &groupedValue; }
-
- MyGroupedObject *nullGrouped() { return 0; }
-
- void doAction() { emit action(); }
-signals:
- void action();
- void rectPropertyChanged();
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
-
-
-class MyContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QObject> children READ children)
- Q_PROPERTY(QDeclarativeListProperty<MyContainer> containerChildren READ containerChildren)
- Q_PROPERTY(QDeclarativeListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
- Q_CLASSINFO("DefaultProperty", "children")
-public:
- MyContainer() {}
-
- QDeclarativeListProperty<QObject> children() { return QDeclarativeListProperty<QObject>(this, m_children); }
- QDeclarativeListProperty<MyContainer> containerChildren() { return QDeclarativeListProperty<MyContainer>(this, m_containerChildren); }
- QList<QObject *> *getChildren() { return &m_children; }
- QDeclarativeListProperty<MyInterface> qlistInterfaces() { return QDeclarativeListProperty<MyInterface>(this, m_interfaces); }
- QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
-
- QList<MyContainer*> m_containerChildren;
- QList<QObject*> m_children;
- QList<MyInterface *> m_interfaces;
-};
-
-
-class MyPropertyValueSource : public QObject, public QDeclarativePropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueSource)
-public:
- MyPropertyValueSource()
- : QDeclarativePropertyValueSource() {}
-
- QDeclarativeProperty prop;
- virtual void setTarget(const QDeclarativeProperty &p)
- {
- prop = p;
- }
-};
-
-class UnavailableType : public QObject
-{
- Q_OBJECT
-public:
- UnavailableType() {}
-};
-
-class MyDotPropertyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(MyQmlObject *obj READ obj)
- Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj)
-public:
- MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {}
- ~MyDotPropertyObject()
- {
- if (m_ownRWObj)
- delete m_rwobj;
- }
-
- MyQmlObject *obj() { return 0; }
-
- MyQmlObject *readWriteObj()
- {
- if (!m_rwobj) {
- m_rwobj = new MyQmlObject;
- m_ownRWObj = true;
- }
- return m_rwobj;
- }
-
- void setReadWriteObj(MyQmlObject *obj)
- {
- if (m_ownRWObj) {
- delete m_rwobj;
- m_ownRWObj = false;
- }
-
- m_rwobj = obj;
- }
-
-private:
- MyQmlObject *m_rwobj;
- bool m_ownRWObj;
-};
-
-
-namespace MyNamespace {
- class MyNamespacedType : public QObject
- {
- Q_OBJECT
- };
-
- class MySecondNamespacedType : public QObject
- {
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<MyNamespace::MyNamespacedType> list READ list)
- public:
- QDeclarativeListProperty<MyNamespacedType> list() { return QDeclarativeListProperty<MyNamespacedType>(this, m_list); }
-
- private:
- QList<MyNamespacedType *> m_list;
- };
-}
-
-class MyCustomParserType : public QObject
-{
- Q_OBJECT
-};
-
-class MyCustomParserTypeParser : public QDeclarativeCustomParser
-{
-public:
- QByteArray compile(const QList<QDeclarativeCustomParserProperty> &) { return QByteArray(); }
- void setCustomData(QObject *, const QByteArray &) {}
-};
-
-class MyParserStatus : public QObject, public QDeclarativeParserStatus
-{
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_OBJECT
-public:
- MyParserStatus() : m_cbc(0), m_ccc(0) {}
-
- int classBeginCount() const { return m_cbc; }
- int componentCompleteCount() const { return m_ccc; }
-
- virtual void classBegin() { m_cbc++; }
- virtual void componentComplete() { m_ccc++; }
-private:
- int m_cbc;
- int m_ccc;
-};
-
-class MyRevisionedBaseClassRegistered : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
- Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
-
-public:
- MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
-
- qreal propA() const { return m_pa; }
- void setPropA(qreal p) {
- if (p != m_pa) {
- m_pa = p;
- emit propAChanged();
- }
- }
- qreal propB() const { return m_pb; }
- void setPropB(qreal p) {
- if (p != m_pb) {
- m_pb = p;
- emit propBChanged();
- }
- }
-
- Q_INVOKABLE void methodA() { }
- Q_INVOKABLE Q_REVISION(1) void methodB() { }
-
-signals:
- void propAChanged();
- void propBChanged();
-
- void signalA();
- Q_REVISION(1) void signalB();
-
-protected:
- qreal m_pa;
- qreal m_pb;
-};
-
-class MyRevisionedIllegalOverload : public MyRevisionedBaseClassRegistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal propA READ propA WRITE setPropA REVISION 1);
-};
-
-class MyRevisionedLegalOverload : public MyRevisionedBaseClassRegistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal propB READ propB WRITE setPropB REVISION 1);
-};
-
-class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
- Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
-
-public:
- MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
-
- qreal propC() const { return m_pc; }
- void setPropC(qreal p) {
- if (p != m_pc) {
- m_pc = p;
- emit propCChanged();
- }
- }
- qreal propD() const { return m_pd; }
- void setPropD(qreal p) {
- if (p != m_pd) {
- m_pd = p;
- emit propDChanged();
- }
- }
-
- Q_INVOKABLE void methodC() { }
- Q_INVOKABLE Q_REVISION(1) void methodD() { }
-
-signals:
- void propCChanged();
- void propDChanged();
-
- void signalC();
- Q_REVISION(1) void signalD();
-
-protected:
- qreal m_pc;
- qreal m_pd;
-};
-
-class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
- Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
-
-public:
- MyRevisionedClass() : m_p1(1), m_p2(2) {}
-
- qreal prop1() const { return m_p1; }
- void setProp1(qreal p) {
- if (p != m_p1) {
- m_p1 = p;
- emit prop1Changed();
- }
- }
- qreal prop2() const { return m_p2; }
- void setProp2(qreal p) {
- if (p != m_p2) {
- m_p2 = p;
- emit prop2Changed();
- }
- }
-
- Q_INVOKABLE void method1() { }
- Q_INVOKABLE Q_REVISION(1) void method2() { }
-
-signals:
- void prop1Changed();
- void prop2Changed();
-
- void signal1();
- Q_REVISION(1) void signal2();
-
-protected:
- qreal m_p1;
- qreal m_p2;
-};
-
-class MyRevisionedSubclass : public MyRevisionedClass
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
- Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
-
-public:
- MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
-
- qreal prop3() const { return m_p3; }
- void setProp3(qreal p) {
- if (p != m_p3) {
- m_p3 = p;
- emit prop3Changed();
- }
- }
- qreal prop4() const { return m_p4; }
- void setProp4(qreal p) {
- if (p != m_p4) {
- m_p4 = p;
- emit prop4Changed();
- }
- }
-
- Q_INVOKABLE void method3() { }
- Q_INVOKABLE Q_REVISION(1) void method4() { }
-
-signals:
- void prop3Changed();
- void prop4Changed();
-
- void signal3();
- Q_REVISION(1) void signal4();
-
-protected:
- qreal m_p3;
- qreal m_p4;
-};
-
-class MySubclass : public MyRevisionedClass
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop5 READ prop5 WRITE setProp5 NOTIFY prop5Changed)
-
-public:
- MySubclass() : m_p5(5) {}
-
- qreal prop5() const { return m_p5; }
- void setProp5(qreal p) {
- if (p != m_p5) {
- m_p5 = p;
- emit prop5Changed();
- }
- }
-
- Q_INVOKABLE void method5() { }
-
-signals:
- void prop5Changed();
-
-protected:
- qreal m_p5;
-};
-
-class MyVersion2Class : public QObject
-{
- Q_OBJECT
-};
-
-QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
-QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
-QML_DECLARE_TYPE(MyRevisionedClass)
-QML_DECLARE_TYPE(MyRevisionedSubclass)
-QML_DECLARE_TYPE(MySubclass)
-
-
-
-void registerTypes();
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
deleted file mode 100644
index 1f211ae963..0000000000
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ /dev/null
@@ -1,2290 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdir.h>
-
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativeglobal_p.h>
-
-#include "testtypes.h"
-#include "testhttpserver.h"
-
-DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
-
-/*
- Returns the path to some testdata file or directory.
-*/
-QString testdata(QString const& name = QString())
-{
- static const QString dataDirectory = QDir::currentPath() + QLatin1String("/data");
- QString result = dataDirectory;
- if (!name.isEmpty()) {
- result += QLatin1Char('/');
- result += name;
- }
- return result;
-}
-
-/*
-This test case covers QML language issues. This covers everything that does not
-involve evaluating ECMAScript expressions and bindings.
-
-Evaluation of expressions and bindings is covered in qmlecmascript
-*/
-class tst_qdeclarativelanguage : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativelanguage() {
- QDeclarativeMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
- engine.addImportPath(testdata("lib"));
- }
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void errors_data();
- void errors();
-
- void insertedSemicolon_data();
- void insertedSemicolon();
-
- void simpleObject();
- void simpleContainer();
- void interfaceProperty();
- void interfaceQList();
- void assignObjectToSignal();
- void assignObjectToVariant();
- void assignLiteralSignalProperty();
- void assignQmlComponent();
- void assignBasicTypes();
- void assignTypeExtremes();
- void assignCompositeToType();
- void assignLiteralToVariant();
- void assignLiteralToVar();
- void customParserTypes();
- void rootAsQmlComponent();
- void inlineQmlComponents();
- void idProperty();
- void autoNotifyConnection();
- void assignSignal();
- void dynamicProperties();
- void dynamicPropertiesNested();
- void listProperties();
- void dynamicObjectProperties();
- void dynamicSignalsAndSlots();
- void simpleBindings();
- void autoComponentCreation();
- void propertyValueSource();
- void attachedProperties();
- void dynamicObjects();
- void customVariantTypes();
- void valueTypes();
- void cppnamespace();
- void aliasProperties();
- void aliasPropertiesAndSignals();
- void aliasPropertyChangeSignals();
- void componentCompositeType();
- void i18n();
- void i18n_data();
- void onCompleted();
- void onDestruction();
- void scriptString();
- void defaultPropertyListOrder();
- void declaredPropertyValues();
- void dontDoubleCallClassBegin();
- void reservedWords_data();
- void reservedWords();
- void inlineAssignmentsOverrideBindings();
- void nestedComponentRoots();
- void registrationOrder();
- void readonly();
-
- void basicRemote_data();
- void basicRemote();
- void importsBuiltin_data();
- void importsBuiltin();
- void importsLocal_data();
- void importsLocal();
- void importsRemote_data();
- void importsRemote();
- void importsInstalled_data();
- void importsInstalled();
- void importsOrder_data();
- void importsOrder();
- void importIncorrectCase();
- void importJs_data();
- void importJs();
-
- void qmlAttachedPropertiesObjectMethod();
- void customOnProperty();
- void variantNotify();
-
- void revisions();
- void revisionOverloads();
-
- void propertyInit();
- void remoteLoadCrash();
-
- // regression tests for crashes
- void crash1();
- void crash2();
-
-private:
- QDeclarativeEngine engine;
- void testType(const QString& qml, const QString& type, const QString& error);
-};
-
-#define DETERMINE_ERRORS(errorfile,expected,actual)\
- QList<QByteArray> expected; \
- QList<QByteArray> actual; \
- do { \
- QFile file(testdata(QLatin1String(errorfile))); \
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QDeclarativeError> errors = component.errors(); \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QDeclarativeError &error = errors.at(ii); \
- QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
- QByteArray::number(error.column()) + ":" + \
- error.description().toUtf8(); \
- actual << errorStr; \
- } \
- } while (false);
-
-#define VERIFY_ERRORS(errorfile) \
- if (!errorfile) { \
- if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
- qWarning() << "Unexpected Errors:" << component.errors(); \
- QVERIFY(!component.isError()); \
- QVERIFY(component.errors().isEmpty()); \
- } else { \
- DETERMINE_ERRORS(errorfile,actual,expected);\
- if (qgetenv("DEBUG") != "" && expected != actual) \
- qWarning() << "Expected:" << expected << "Actual:" << actual; \
- if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
- QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::WriteOnly)); \
- for (int ii = 0; ii < actual.count(); ++ii) { \
- file.write(actual.at(ii)); file.write("\n"); \
- } \
- file.close(); \
- } else { \
- QCOMPARE(expected, actual); \
- } \
- }
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(testdata(filename));
-}
-
-inline QUrl TEST_FILE(const char *filename)
-{
- return TEST_FILE(QLatin1String(filename));
-}
-
-void tst_qdeclarativelanguage::cleanupTestCase()
-{
- QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
-}
-
-void tst_qdeclarativelanguage::insertedSemicolon_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
- QTest::addColumn<bool>("create");
-
- QTest::newRow("insertedSemicolon.1") << "insertedSemicolon.1.qml" << "insertedSemicolon.1.errors.txt" << false;
-}
-
-void tst_qdeclarativelanguage::insertedSemicolon()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
- QFETCH(bool, create);
-
- QDeclarativeComponent component(&engine, TEST_FILE(file));
-
- if(create) {
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- VERIFY_ERRORS(errorFile.toLatin1().constData());
-}
-
-void tst_qdeclarativelanguage::errors_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
- QTest::addColumn<bool>("create");
-
- QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.qml" << "nonexistantProperty.1.errors.txt" << false;
- QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.qml" << "nonexistantProperty.2.errors.txt" << false;
- QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.qml" << "nonexistantProperty.3.errors.txt" << false;
- QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false;
- QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false;
- QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false;
-
- QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false;
- QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false;
- QTest::newRow("wrongType (bad rect)") << "wrongType.3.qml" << "wrongType.3.errors.txt" << false;
-
- QTest::newRow("wrongType (invalid enum)") << "wrongType.4.qml" << "wrongType.4.errors.txt" << false;
- QTest::newRow("wrongType (int for uint)") << "wrongType.5.qml" << "wrongType.5.errors.txt" << false;
- QTest::newRow("wrongType (string for real)") << "wrongType.6.qml" << "wrongType.6.errors.txt" << false;
- QTest::newRow("wrongType (int for color)") << "wrongType.7.qml" << "wrongType.7.errors.txt" << false;
- QTest::newRow("wrongType (int for date)") << "wrongType.8.qml" << "wrongType.8.errors.txt" << false;
- QTest::newRow("wrongType (int for time)") << "wrongType.9.qml" << "wrongType.9.errors.txt" << false;
- QTest::newRow("wrongType (int for datetime)") << "wrongType.10.qml" << "wrongType.10.errors.txt" << false;
- QTest::newRow("wrongType (string for point)") << "wrongType.11.qml" << "wrongType.11.errors.txt" << false;
- QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false;
- QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false;
- QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false;
- QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false;
- QTest::newRow("wrongType (invalid object)") << "wrongType.16.qml" << "wrongType.16.errors.txt" << false;
- QTest::newRow("wrongType (int for enum)") << "wrongType.17.qml" << "wrongType.17.errors.txt" << false;
-
- QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false;
- QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false;
- QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false;
- QTest::newRow("readOnly.4") << "readOnly.4.qml" << "readOnly.4.errors.txt" << false;
- QTest::newRow("readOnly.5") << "readOnly.5.qml" << "readOnly.5.errors.txt" << false;
-
- QTest::newRow("listAssignment.1") << "listAssignment.1.qml" << "listAssignment.1.errors.txt" << false;
- QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false;
- QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false;
-
- QTest::newRow("invalidID.1") << "invalidID.qml" << "invalidID.errors.txt" << false;
- QTest::newRow("invalidID.2") << "invalidID.2.qml" << "invalidID.2.errors.txt" << false;
- QTest::newRow("invalidID.3") << "invalidID.3.qml" << "invalidID.3.errors.txt" << false;
- QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false;
- QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false;
- QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false;
- QTest::newRow("invalidID.7") << "invalidID.7.qml" << "invalidID.7.errors.txt" << false;
- QTest::newRow("invalidID.8") << "invalidID.8.qml" << "invalidID.8.errors.txt" << false;
- QTest::newRow("invalidID.9") << "invalidID.9.qml" << "invalidID.9.errors.txt" << false;
-
- QTest::newRow("scriptString.1") << "scriptString.1.qml" << "scriptString.1.errors.txt" << false;
- QTest::newRow("scriptString.2") << "scriptString.2.qml" << "scriptString.2.errors.txt" << false;
-
- QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false;
- QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true;
- QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false;
- QTest::newRow("duplicateIDs") << "duplicateIDs.qml" << "duplicateIDs.errors.txt" << false;
- QTest::newRow("unregisteredObject") << "unregisteredObject.qml" << "unregisteredObject.errors.txt" << false;
- QTest::newRow("empty") << "empty.qml" << "empty.errors.txt" << false;
- QTest::newRow("missingObject") << "missingObject.qml" << "missingObject.errors.txt" << false;
- QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false;
- QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false;
- QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
- QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
-
- QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true;
- QTest::newRow("invalidGroupedProperty.8") << "invalidGroupedProperty.8.qml" << "invalidGroupedProperty.8.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.9") << "invalidGroupedProperty.9.qml" << "invalidGroupedProperty.9.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.10") << "invalidGroupedProperty.10.qml" << "invalidGroupedProperty.10.errors.txt" << false;
-
- QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
- QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
- QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
- QTest::newRow("importNonExist (installed)") << "importNonExist.qml" << "importNonExist.errors.txt" << false;
- 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;
- QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false;
- QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false;
- QTest::newRow("signal.5") << "signal.5.qml" << "signal.5.errors.txt" << false;
-
- QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false;
-
- QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false;
- QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false;
- QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false;
- QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false;
- QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false;
- QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false;
-
- QTest::newRow("importScript.1") << "importscript.1.qml" << "importscript.1.errors.txt" << false;
-
- QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false;
- QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false;
- QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false;
- QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false;
- QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false;
- QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false;
- QTest::newRow("Component.7") << "component.7.qml" << "component.7.errors.txt" << false;
- QTest::newRow("Component.8") << "component.8.qml" << "component.8.errors.txt" << false;
- QTest::newRow("Component.9") << "component.9.qml" << "component.9.errors.txt" << false;
-
- QTest::newRow("MultiSet.1") << "multiSet.1.qml" << "multiSet.1.errors.txt" << false;
- QTest::newRow("MultiSet.2") << "multiSet.2.qml" << "multiSet.2.errors.txt" << false;
- QTest::newRow("MultiSet.3") << "multiSet.3.qml" << "multiSet.3.errors.txt" << false;
- QTest::newRow("MultiSet.4") << "multiSet.4.qml" << "multiSet.4.errors.txt" << false;
- QTest::newRow("MultiSet.5") << "multiSet.5.qml" << "multiSet.5.errors.txt" << false;
- QTest::newRow("MultiSet.6") << "multiSet.6.qml" << "multiSet.6.errors.txt" << false;
- QTest::newRow("MultiSet.7") << "multiSet.7.qml" << "multiSet.7.errors.txt" << false;
- QTest::newRow("MultiSet.8") << "multiSet.8.qml" << "multiSet.8.errors.txt" << false;
- QTest::newRow("MultiSet.9") << "multiSet.9.qml" << "multiSet.9.errors.txt" << false;
- QTest::newRow("MultiSet.10") << "multiSet.10.qml" << "multiSet.10.errors.txt" << false;
- QTest::newRow("MultiSet.11") << "multiSet.11.qml" << "multiSet.11.errors.txt" << false;
-
- QTest::newRow("dynamicMeta.1") << "dynamicMeta.1.qml" << "dynamicMeta.1.errors.txt" << false;
- QTest::newRow("dynamicMeta.2") << "dynamicMeta.2.qml" << "dynamicMeta.2.errors.txt" << false;
- QTest::newRow("dynamicMeta.3") << "dynamicMeta.3.qml" << "dynamicMeta.3.errors.txt" << false;
- QTest::newRow("dynamicMeta.4") << "dynamicMeta.4.qml" << "dynamicMeta.4.errors.txt" << false;
- QTest::newRow("dynamicMeta.5") << "dynamicMeta.5.qml" << "dynamicMeta.5.errors.txt" << false;
-
- QTest::newRow("invalidAlias.1") << "invalidAlias.1.qml" << "invalidAlias.1.errors.txt" << false;
- QTest::newRow("invalidAlias.2") << "invalidAlias.2.qml" << "invalidAlias.2.errors.txt" << false;
- QTest::newRow("invalidAlias.3") << "invalidAlias.3.qml" << "invalidAlias.3.errors.txt" << false;
- QTest::newRow("invalidAlias.4") << "invalidAlias.4.qml" << "invalidAlias.4.errors.txt" << false;
- QTest::newRow("invalidAlias.5") << "invalidAlias.5.qml" << "invalidAlias.5.errors.txt" << false;
- QTest::newRow("invalidAlias.6") << "invalidAlias.6.qml" << "invalidAlias.6.errors.txt" << false;
- QTest::newRow("invalidAlias.7") << "invalidAlias.7.qml" << "invalidAlias.7.errors.txt" << false;
- QTest::newRow("invalidAlias.8") << "invalidAlias.8.qml" << "invalidAlias.8.errors.txt" << false;
- QTest::newRow("invalidAlias.9") << "invalidAlias.9.qml" << "invalidAlias.9.errors.txt" << false;
- QTest::newRow("invalidAlias.10") << "invalidAlias.10.qml" << "invalidAlias.10.errors.txt" << false;
-
- QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.12") << "invalidAttachedProperty.12.qml" << "invalidAttachedProperty.12.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.13") << "invalidAttachedProperty.13.qml" << "invalidAttachedProperty.13.errors.txt" << false;
-
- QTest::newRow("assignValueToSignal") << "assignValueToSignal.qml" << "assignValueToSignal.errors.txt" << false;
- QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
-
- QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
- QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
- QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
- QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
- QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
- QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false;
- QTest::newRow("noCreation") << "noCreation.qml" << "noCreation.errors.txt" << false;
- QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false;
- QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false;
- QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
- QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
- QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false;
- QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
- QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false;
- QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false;
- QTest::newRow("incorrectCase") << "incorrectCase.qml"
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
- << "incorrectCase.errors.insensitive.txt"
-#else
- << "incorrectCase.errors.sensitive.txt"
-#endif
- << false;
-
- QTest::newRow("metaobjectRevision.1") << "metaobjectRevision.1.qml" << "metaobjectRevision.1.errors.txt" << false;
- QTest::newRow("metaobjectRevision.2") << "metaobjectRevision.2.qml" << "metaobjectRevision.2.errors.txt" << false;
- QTest::newRow("metaobjectRevision.3") << "metaobjectRevision.3.qml" << "metaobjectRevision.3.errors.txt" << false;
-
- QTest::newRow("invalidRoot.1") << "invalidRoot.1.qml" << "invalidRoot.1.errors.txt" << false;
- QTest::newRow("invalidRoot.2") << "invalidRoot.2.qml" << "invalidRoot.2.errors.txt" << false;
- QTest::newRow("invalidRoot.3") << "invalidRoot.3.qml" << "invalidRoot.3.errors.txt" << false;
- QTest::newRow("invalidRoot.4") << "invalidRoot.4.qml" << "invalidRoot.4.errors.txt" << false;
-
- QTest::newRow("invalidTypeName.1") << "invalidTypeName.1.qml" << "invalidTypeName.1.errors.txt" << false;
- QTest::newRow("invalidTypeName.2") << "invalidTypeName.2.qml" << "invalidTypeName.2.errors.txt" << false;
- QTest::newRow("invalidTypeName.3") << "invalidTypeName.3.qml" << "invalidTypeName.3.errors.txt" << false;
- QTest::newRow("invalidTypeName.4") << "invalidTypeName.4.qml" << "invalidTypeName.4.errors.txt" << false;
-
- QTest::newRow("Major version isolation") << "majorVersionIsolation.qml" << "majorVersionIsolation.errors.txt" << false;
-}
-
-
-void tst_qdeclarativelanguage::errors()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
- QFETCH(bool, create);
-
- QDeclarativeComponent component(&engine, TEST_FILE(file));
-
- if(create) {
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- VERIFY_ERRORS(errorFile.toLatin1().constData());
-}
-
-void tst_qdeclarativelanguage::simpleObject()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("simpleObject.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qdeclarativelanguage::simpleContainer()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("simpleContainer.qml"));
- VERIFY_ERRORS(0);
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QCOMPARE(container->getChildren()->count(),2);
-}
-
-void tst_qdeclarativelanguage::interfaceProperty()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("interfaceProperty.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->interface());
- QVERIFY(object->interface()->id == 913);
-}
-
-void tst_qdeclarativelanguage::interfaceQList()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("interfaceQList.qml"));
- VERIFY_ERRORS(0);
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QVERIFY(container->getQListInterfaces()->count() == 2);
- for(int ii = 0; ii < 2; ++ii)
- QVERIFY(container->getQListInterfaces()->at(ii)->id == 913);
-}
-
-void tst_qdeclarativelanguage::assignObjectToSignal()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToSignal.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
- emit object->basicSignal();
-}
-
-void tst_qdeclarativelanguage::assignObjectToVariant()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToVariant.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVariant v = object->property("a");
- QVERIFY(v.userType() == qMetaTypeId<QObject *>());
-}
-
-void tst_qdeclarativelanguage::assignLiteralSignalProperty()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->onLiteralSignal(), 10);
-}
-
-// Test is an external component can be loaded and assigned (to a qlist)
-void tst_qdeclarativelanguage::assignQmlComponent()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignQmlComponent.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->getChildren()->count() == 1);
- QObject *child = object->getChildren()->at(0);
- QCOMPARE(child->property("x"), QVariant(10));
- QCOMPARE(child->property("y"), QVariant(11));
-}
-
-// Test literal assignment to all the basic types
-void tst_qdeclarativelanguage::assignBasicTypes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- 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->floatProperty(), float(8.5));
- QCOMPARE(object->colorProperty(), QColor("red"));
- QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2, 2.3));
- QUrl encoded;
- encoded.setEncodedUrl("main.qml?with%3cencoded%3edata", QUrl::TolerantMode);
- QCOMPARE(object->urlProperty(), component.url().resolved(encoded));
- QVERIFY(object->objectProperty() != 0);
- MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
- QVERIFY(child != 0);
- QCOMPARE(child->intProperty(), 8);
-}
-
-// Test edge case type assignments
-void tst_qdeclarativelanguage::assignTypeExtremes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignTypeExtremes.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->uintProperty(), 0xEE6B2800);
- QCOMPARE(object->intProperty(), -0x77359400);
-}
-
-// Test that a composite type can assign to a property of its base type
-void tst_qdeclarativelanguage::assignCompositeToType()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignCompositeToType.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Test that literals are stored correctly in variant properties
-void tst_qdeclarativelanguage::assignLiteralToVariant()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").userType(), (int)QVariant::Int);
- QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
- QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test4").userType(), (int)QVariant::Color);
- QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF);
- QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF);
- QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF);
- QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D);
- QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool);
- QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool);
- QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D);
-
- QVERIFY(object->property("test1") == QVariant(1));
- QVERIFY(object->property("test2") == QVariant((double)1.7));
- QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!"))));
- QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800)));
- QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10)));
- QVERIFY(object->property("test6") == QVariant(QPointF(10, 10)));
- QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10)));
- QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100)));
- QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800"))));
- QVERIFY(object->property("test10") == QVariant(bool(true)));
- QVERIFY(object->property("test11") == QVariant(bool(false)));
- QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100)));
-
- delete object;
-}
-
-// Test that literals are stored correctly in "var" properties
-// Note that behaviour differs from "variant" properties in that
-// no conversion from "special strings" to QVariants is performed.
-void tst_qdeclarativelanguage::assignLiteralToVar()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVar.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").userType(), (int)QMetaType::Int);
- QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
- QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test4").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test5").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test6").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test7").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test8").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool);
- QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool);
- QCOMPARE(object->property("test12").userType(), (int)QVariant::Color);
- QCOMPARE(object->property("test13").userType(), (int)QVariant::RectF);
- QCOMPARE(object->property("test14").userType(), (int)QVariant::PointF);
- QCOMPARE(object->property("test15").userType(), (int)QVariant::SizeF);
- QCOMPARE(object->property("test16").userType(), (int)QVariant::Vector3D);
- QCOMPARE(object->property("variantTest1Bound").userType(), (int)QMetaType::Int);
- QCOMPARE(object->property("test1Bound").userType(), (int)QMetaType::Int);
-
- QCOMPARE(object->property("test1"), QVariant(5));
- QCOMPARE(object->property("test2"), QVariant((double)1.7));
- QCOMPARE(object->property("test3"), QVariant(QString(QLatin1String("Hello world!"))));
- QCOMPARE(object->property("test4"), QVariant(QString(QLatin1String("#FF008800"))));
- QCOMPARE(object->property("test5"), QVariant(QString(QLatin1String("10,10,10x10"))));
- QCOMPARE(object->property("test6"), QVariant(QString(QLatin1String("10,10"))));
- QCOMPARE(object->property("test7"), QVariant(QString(QLatin1String("10x10"))));
- QCOMPARE(object->property("test8"), QVariant(QString(QLatin1String("100,100,100"))));
- QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800"))));
- QCOMPARE(object->property("test10"), QVariant(bool(true)));
- QCOMPARE(object->property("test11"), QVariant(bool(false)));
- QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2, 0.3, 0.4, 0.5)));
- QCOMPARE(object->property("test13"), QVariant(QRectF(10, 10, 10, 10)));
- QCOMPARE(object->property("test14"), QVariant(QPointF(10, 10)));
- QCOMPARE(object->property("test15"), QVariant(QSizeF(10, 10)));
- QCOMPARE(object->property("test16"), QVariant(QVector3D(100, 100, 100)));
- QCOMPARE(object->property("variantTest1Bound"), QVariant(9));
- QCOMPARE(object->property("test1Bound"), QVariant(11));
-
- delete object;
-}
-
-// Tests that custom parser types can be instantiated
-void tst_qdeclarativelanguage::customParserTypes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("customParserTypes.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("count") == QVariant(2));
-}
-
-// Tests that the root item can be a custom component
-void tst_qdeclarativelanguage::rootAsQmlComponent()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->property("x"), QVariant(11));
- QCOMPARE(object->getChildren()->count(), 2);
-}
-
-// Tests that components can be specified inline
-void tst_qdeclarativelanguage::inlineQmlComponents()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("inlineQmlComponents.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->getChildren()->count(), 1);
- QDeclarativeComponent *comp = qobject_cast<QDeclarativeComponent *>(object->getChildren()->at(0));
- QVERIFY(comp != 0);
- MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create());
- QVERIFY(compObject != 0);
- QCOMPARE(compObject->value(), 11);
-}
-
-// Tests that types that have an id property have it set
-void tst_qdeclarativelanguage::idProperty()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("idProperty.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->getChildren()->count(), 1);
- MyTypeObject *child =
- qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
- QVERIFY(child != 0);
- QCOMPARE(child->id(), QString("myObjectId"));
- QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
-}
-
-// Tests automatic connection to notify signals if "onBlahChanged" syntax is used
-// even if the notify signal for "blah" is not called "blahChanged"
-void tst_qdeclarativelanguage::autoNotifyConnection()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("autoNotifyConnection.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify"));
- QVERIFY(prop.isValid());
-
- QCOMPARE(prop.read(object), QVariant::fromValue(false));
- object->setPropertyWithNotify(1);
- QCOMPARE(prop.read(object), QVariant::fromValue(true));
-}
-
-// Tests that signals can be assigned to
-void tst_qdeclarativelanguage::assignSignal()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSignal.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
- emit object->basicSignal();
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)");
- emit object->basicParameterizedSignal(9);
-}
-
-// Tests the creation and assignment of dynamic properties
-void tst_qdeclarativelanguage::dynamicProperties()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("intProperty"), QVariant(10));
- QCOMPARE(object->property("boolProperty"), QVariant(false));
- QCOMPARE(object->property("doubleProperty"), QVariant(-10.1));
- QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9));
- QCOMPARE(object->property("stringProperty"), QVariant("Hello World!"));
- QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml")));
- QCOMPARE(object->property("colorProperty"), QVariant(QColor("red")));
- QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2)));
- QCOMPARE(object->property("varProperty"), QVariant("Hello World!"));
-}
-
-// Test that nested types can use dynamic properties
-void tst_qdeclarativelanguage::dynamicPropertiesNested()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("super_a").toInt(), 11); // Overridden
- QCOMPARE(object->property("super_c").toInt(), 14); // Inherited
- QCOMPARE(object->property("a").toInt(), 13); // New
- QCOMPARE(object->property("b").toInt(), 12); // New
-
- delete object;
-}
-
-// Tests the creation and assignment to dynamic list properties
-void tst_qdeclarativelanguage::listProperties()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("listProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 2);
-}
-
-// Tests the creation and assignment of dynamic object properties
-// ### Not complete
-void tst_qdeclarativelanguage::dynamicObjectProperties()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0));
- QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0));
- }
- {
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.2.qml"));
- QEXPECT_FAIL("", "QTBUG-10822", Abort);
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->property("objectProperty") != qVariantFromValue((QObject*)0));
- }
-}
-
-// Tests the declaration of dynamic signals and slots
-void tst_qdeclarativelanguage::dynamicSignalsAndSlots()
-{
- QTest::ignoreMessage(QtDebugMsg, "1921");
-
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1);
-
- QCOMPARE(object->property("test").toInt(), 0);
- QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10)));
- QCOMPARE(object->property("test").toInt(), 10);
-}
-
-void tst_qdeclarativelanguage::simpleBindings()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("simpleBindings.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value1"), QVariant(10));
- QCOMPARE(object->property("value2"), QVariant(10));
- QCOMPARE(object->property("value3"), QVariant(21));
- QCOMPARE(object->property("value4"), QVariant(10));
- QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object));
-}
-
-void tst_qdeclarativelanguage::autoComponentCreation()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("autoComponentCreation.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->componentProperty() != 0);
- MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create());
- QVERIFY(child != 0);
- QCOMPARE(child->realProperty(), qreal(9));
-}
-
-void tst_qdeclarativelanguage::propertyValueSource()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QList<QObject *> valueSources;
- QObjectList allChildren = object->findChildren<QObject*>();
- foreach (QObject *child, allChildren) {
- if (qobject_cast<QDeclarativePropertyValueSource *>(child))
- valueSources.append(child);
- }
-
- QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
- qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
- QVERIFY(valueSource != 0);
- QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
- QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.2.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QList<QObject *> valueSources;
- QObjectList allChildren = object->findChildren<QObject*>();
- foreach (QObject *child, allChildren) {
- if (qobject_cast<QDeclarativePropertyValueSource *>(child))
- valueSources.append(child);
- }
-
- QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
- qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
- QVERIFY(valueSource != 0);
- QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
- QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
- }
-}
-
-void tst_qdeclarativelanguage::attachedProperties()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("attachedProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object);
- QVERIFY(attached != 0);
- QCOMPARE(attached->property("value"), QVariant(10));
- QCOMPARE(attached->property("value2"), QVariant(13));
-}
-
-// Tests non-static object properties
-void tst_qdeclarativelanguage::dynamicObjects()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicObject.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Tests the registration of custom variant string converters
-void tst_qdeclarativelanguage::customVariantTypes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("customVariantTypes.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->customType().a, 10);
-}
-
-void tst_qdeclarativelanguage::valueTypes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("valueTypes.qml"));
- VERIFY_ERRORS(0);
-
- QString message = component.url().toString() + ":2:1: QML MyTypeObject: Binding loop detected for property \"rectProperty.width\"";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
-
-
- QCOMPARE(object->rectProperty(), QRect(10, 11, 12, 13));
- QCOMPARE(object->rectProperty2(), QRect(10, 11, 12, 13));
- QCOMPARE(object->intProperty(), 10);
- object->doAction();
- QCOMPARE(object->rectProperty(), QRect(12, 11, 14, 13));
- QCOMPARE(object->rectProperty2(), QRect(12, 11, 14, 13));
- QCOMPARE(object->intProperty(), 12);
-
- // ###
-#if 0
- QDeclarativeProperty p(object, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(12));
- p.write(13);
- QCOMPARE(p.read(), QVariant(13));
-
- quint32 r = QDeclarativePropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex());
- QDeclarativeProperty p2;
- QDeclarativePropertyPrivate::restore(p2, r, object);
- QCOMPARE(p2.read(), QVariant(13));
-#endif
-}
-
-void tst_qdeclarativelanguage::cppnamespace()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-}
-
-void tst_qdeclarativelanguage::aliasProperties()
-{
- // Simple "int" alias
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- QCOMPARE(object->property("valueAlias").toInt(), 10);
- object->setProperty("value", QVariant(13));
- QCOMPARE(object->property("valueAlias").toInt(), 13);
-
- // Write through alias
- object->setProperty("valueAlias", QVariant(19));
- QCOMPARE(object->property("valueAlias").toInt(), 19);
- QCOMPARE(object->property("value").toInt(), 19);
-
- delete object;
- }
-
- // Complex object alias
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- MyQmlObject *v =
- qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
- QVERIFY(v != 0);
- QCOMPARE(v->value(), 10);
-
- // Write through alias
- MyQmlObject *v2 = new MyQmlObject();
- v2->setParent(object);
- object->setProperty("aliasObject", qVariantFromValue(v2));
- MyQmlObject *v3 =
- qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
- QVERIFY(v3 != 0);
- QCOMPARE(v3, v2);
-
- delete object;
- }
-
- // Nested aliases
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.3.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 1892);
- QCOMPARE(object->property("value2").toInt(), 1892);
-
- object->setProperty("value", QVariant(1313));
- QCOMPARE(object->property("value").toInt(), 1313);
- QCOMPARE(object->property("value2").toInt(), 1313);
-
- object->setProperty("value2", QVariant(8080));
- QCOMPARE(object->property("value").toInt(), 8080);
- QCOMPARE(object->property("value2").toInt(), 8080);
-
- delete object;
- }
-
- // Enum aliases
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.4.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("enumAlias").toInt(), 1);
-
- delete object;
- }
-
- // Id aliases
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.5.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVariant v = object->property("otherAlias");
- QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
- MyQmlObject *o = qvariant_cast<MyQmlObject*>(v);
- QCOMPARE(o->value(), 10);
-
- delete o;
-
- v = object->property("otherAlias");
- QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
- o = qvariant_cast<MyQmlObject*>(v);
- QVERIFY(o == 0);
-
- delete object;
- }
-
- // Nested aliases - this used to cause a crash
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.6.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("a").toInt(), 1923);
- }
-
- // Ptr Alias Cleanup - check that aliases to ptr types return 0
- // if the object aliased to is removed
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.7.qml"));
- VERIFY_ERRORS(0);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *object1 = qvariant_cast<QObject *>(object->property("object"));
- QVERIFY(object1 != 0);
- QObject *object2 = qvariant_cast<QObject *>(object1->property("object"));
- QVERIFY(object2 != 0);
-
- QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject"));
- QVERIFY(alias == object2);
-
- delete object1;
-
- QObject *alias2 = object; // "Random" start value
- int status = -1;
- void *a[] = { &alias2, 0, &status };
- QMetaObject::metacall(object, QMetaObject::ReadProperty,
- object->metaObject()->indexOfProperty("aliasedObject"), a);
- QVERIFY(alias2 == 0);
- }
-
- // Simple composite type
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.8.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 10);
-
- delete object;
- }
-
- // Complex composite type
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.9.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 10);
-
- delete object;
- }
-
- // Valuetype alias
- // Simple "int" alias
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.10.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- QCOMPARE(object->property("valueAlias").toRect(), QRect(10, 11, 9, 8));
- object->setProperty("rectProperty", QVariant(QRect(33, 12, 99, 100)));
- QCOMPARE(object->property("valueAlias").toRect(), QRect(33, 12, 99, 100));
-
- // Write through alias
- object->setProperty("valueAlias", QVariant(QRect(3, 3, 4, 9)));
- QCOMPARE(object->property("valueAlias").toRect(), QRect(3, 3, 4, 9));
- QCOMPARE(object->property("rectProperty").toRect(), QRect(3, 3, 4, 9));
-
- delete object;
- }
-
- // Valuetype sub-alias
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.11.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- QCOMPARE(object->property("aliasProperty").toInt(), 19);
- object->setProperty("rectProperty", QVariant(QRect(33, 8, 102, 111)));
- QCOMPARE(object->property("aliasProperty").toInt(), 33);
-
- // Write through alias
- object->setProperty("aliasProperty", QVariant(4));
- QCOMPARE(object->property("aliasProperty").toInt(), 4);
- QCOMPARE(object->property("rectProperty").toRect(), QRect(4, 8, 102, 111));
-
- delete object;
- }
-}
-
-// QTBUG-13374 Test that alias properties and signals can coexist
-void tst_qdeclarativelanguage::aliasPropertiesAndSignals()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertiesAndSignals.qml"));
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-// Test that the root element in a composite type can be a Component
-void tst_qdeclarativelanguage::componentCompositeType()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-class TestType : public QObject {
- Q_OBJECT
-public:
- TestType(QObject *p=0) : QObject(p) {}
-};
-
-class TestType2 : public QObject {
- Q_OBJECT
-public:
- TestType2(QObject *p=0) : QObject(p) {}
-};
-
-void tst_qdeclarativelanguage::i18n_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("stringProperty");
- QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)");
- QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10");
- QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15");
- QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20");
- QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30");
- QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40");
-}
-
-void tst_qdeclarativelanguage::i18n()
-{
- QFETCH(QString, file);
- QFETCH(QString, stringProperty);
- QDeclarativeComponent component(&engine, TEST_FILE(file));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), stringProperty);
-
- delete object;
-}
-
-// Check that the Component::onCompleted attached property works
-void tst_qdeclarativelanguage::onCompleted()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("onCompleted.qml"));
- VERIFY_ERRORS(0);
- QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Completed 10 11");
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Check that the Component::onDestruction attached property works
-void tst_qdeclarativelanguage::onDestruction()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("onDestruction.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Destruction 10 11");
- delete object;
-}
-
-// Check that assignments to QDeclarativeScriptString properties work
-void tst_qdeclarativelanguage::scriptString()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("foo + bar"));
- QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object));
- QCOMPARE(object->scriptProperty().context(), qmlContext(object));
-
- QVERIFY(object->grouped() != 0);
- QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)"));
- QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object));
- QCOMPARE(object->grouped()->script().context(), qmlContext(object));
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("scriptString2.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("\"hello\\n\\\"world\\\"\""));
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("scriptString3.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("12.345"));
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("scriptString4.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("true"));
- }
-}
-
-// Check that default property assignments are correctly spliced into explicit
-// property assignments
-void tst_qdeclarativelanguage::defaultPropertyListOrder()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml"));
- VERIFY_ERRORS(0);
-
- MyContainer *container = qobject_cast<MyContainer *>(component.create());
- QVERIFY(container != 0);
-
- QCOMPARE(container->getChildren()->count(), 6);
- QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0));
- QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1));
- QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2));
- QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3));
- QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4));
- QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5));
-}
-
-void tst_qdeclarativelanguage::declaredPropertyValues()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
- VERIFY_ERRORS(0);
-}
-
-void tst_qdeclarativelanguage::dontDoubleCallClassBegin()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("dontDoubleCallClassBegin.qml"));
- QObject *o = component.create();
- QVERIFY(o);
-
- MyParserStatus *o2 = qobject_cast<MyParserStatus *>(qvariant_cast<QObject *>(o->property("object")));
- QVERIFY(o2);
- QCOMPARE(o2->classBeginCount(), 1);
- QCOMPARE(o2->componentCompleteCount(), 1);
-
- delete o;
-}
-
-void tst_qdeclarativelanguage::reservedWords_data()
-{
- QTest::addColumn<QByteArray>("word");
-
- QTest::newRow("abstract") << QByteArray("abstract");
- QTest::newRow("as") << QByteArray("as");
- QTest::newRow("boolean") << QByteArray("boolean");
- QTest::newRow("break") << QByteArray("break");
- QTest::newRow("byte") << QByteArray("byte");
- QTest::newRow("case") << QByteArray("case");
- QTest::newRow("catch") << QByteArray("catch");
- QTest::newRow("char") << QByteArray("char");
- QTest::newRow("class") << QByteArray("class");
- QTest::newRow("continue") << QByteArray("continue");
- QTest::newRow("const") << QByteArray("const");
- QTest::newRow("debugger") << QByteArray("debugger");
- QTest::newRow("default") << QByteArray("default");
- QTest::newRow("delete") << QByteArray("delete");
- QTest::newRow("do") << QByteArray("do");
- QTest::newRow("double") << QByteArray("double");
- QTest::newRow("else") << QByteArray("else");
- QTest::newRow("enum") << QByteArray("enum");
- QTest::newRow("export") << QByteArray("export");
- QTest::newRow("extends") << QByteArray("extends");
- QTest::newRow("false") << QByteArray("false");
- QTest::newRow("final") << QByteArray("final");
- QTest::newRow("finally") << QByteArray("finally");
- QTest::newRow("float") << QByteArray("float");
- QTest::newRow("for") << QByteArray("for");
- QTest::newRow("function") << QByteArray("function");
- QTest::newRow("goto") << QByteArray("goto");
- QTest::newRow("if") << QByteArray("if");
- QTest::newRow("implements") << QByteArray("implements");
- QTest::newRow("import") << QByteArray("import");
- QTest::newRow("in") << QByteArray("in");
- QTest::newRow("instanceof") << QByteArray("instanceof");
- QTest::newRow("int") << QByteArray("int");
- QTest::newRow("interface") << QByteArray("interface");
- QTest::newRow("long") << QByteArray("long");
- QTest::newRow("native") << QByteArray("native");
- QTest::newRow("new") << QByteArray("new");
- QTest::newRow("null") << QByteArray("null");
- QTest::newRow("package") << QByteArray("package");
- QTest::newRow("private") << QByteArray("private");
- QTest::newRow("protected") << QByteArray("protected");
- QTest::newRow("public") << QByteArray("public");
- QTest::newRow("return") << QByteArray("return");
- QTest::newRow("short") << QByteArray("short");
- QTest::newRow("static") << QByteArray("static");
- QTest::newRow("super") << QByteArray("super");
- QTest::newRow("switch") << QByteArray("switch");
- QTest::newRow("synchronized") << QByteArray("synchronized");
- QTest::newRow("this") << QByteArray("this");
- QTest::newRow("throw") << QByteArray("throw");
- QTest::newRow("throws") << QByteArray("throws");
- QTest::newRow("transient") << QByteArray("transient");
- QTest::newRow("true") << QByteArray("true");
- QTest::newRow("try") << QByteArray("try");
- QTest::newRow("typeof") << QByteArray("typeof");
- QTest::newRow("var") << QByteArray("var");
- QTest::newRow("void") << QByteArray("void");
- QTest::newRow("volatile") << QByteArray("volatile");
- QTest::newRow("while") << QByteArray("while");
- QTest::newRow("with") << QByteArray("with");
-}
-
-void tst_qdeclarativelanguage::reservedWords()
-{
- QFETCH(QByteArray, word);
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nQtObject { property string " + word + " }", QUrl());
- QCOMPARE(component.errorString(), QLatin1String(":2 Expected token `identifier'\n"));
-}
-
-// Check that first child of qml is of given type. Empty type insists on error.
-void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
-{
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
-
- QTRY_VERIFY(!component.isLoading());
-
- if (type.isEmpty()) {
- QVERIFY(component.isError());
- QString actualerror;
- foreach (const QDeclarativeError e, component.errors()) {
- if (!actualerror.isEmpty())
- actualerror.append("; ");
- actualerror.append(e.description());
- }
- QCOMPARE(actualerror,expectederror);
- } else {
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(QString(object->metaObject()->className()), type);
- delete object;
- }
-}
-
-// QTBUG-17276
-void tst_qdeclarativelanguage::inlineAssignmentsOverrideBindings()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("inlineAssignmentsOverrideBindings.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toInt(), 11);
- delete o;
-}
-
-// QTBUG-19354
-void tst_qdeclarativelanguage::nestedComponentRoots()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("nestedComponentRoots.qml"));
-}
-
-// Import tests (QT-558)
-void tst_qdeclarativelanguage::importsBuiltin_data()
-{
- // QT-610
-
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- // import built-ins
- QTest::newRow("missing import")
- << "Test {}"
- << ""
- << "Test is not a type";
- QTest::newRow("not in version 0.0")
- << "import com.nokia.Test 0.0\n"
- "Test {}"
- << ""
- << "Test is not a type";
- QTest::newRow("version not installed")
- << "import com.nokia.Test 99.0\n"
- "Test {}"
- << ""
- << "module \"com.nokia.Test\" version 99.0 is not installed";
- QTest::newRow("in version 0.0")
- << "import com.nokia.Test 0.0\n"
- "TestTP {}"
- << "TestType"
- << "";
- QTest::newRow("qualified in version 0.0")
- << "import com.nokia.Test 0.0 as T\n"
- "T.TestTP {}"
- << "TestType"
- << "";
- QTest::newRow("in version 1.0")
- << "import com.nokia.Test 1.0\n"
- "Test {}"
- << "TestType"
- << "";
- QTest::newRow("qualified wrong")
- << "import com.nokia.Test 1.0 as T\n" // QT-610
- "Test {}"
- << ""
- << "Test is not a type";
- QTest::newRow("qualified right")
- << "import com.nokia.Test 1.0 as T\n"
- "T.Test {}"
- << "TestType"
- << "";
- QTest::newRow("qualified right but not in version 0.0")
- << "import com.nokia.Test 0.0 as T\n"
- "T.Test {}"
- << ""
- << "T.Test is not a type";
- QTest::newRow("in version 1.1")
- << "import com.nokia.Test 1.1\n"
- "Test {}"
- << "TestType"
- << "";
- QTest::newRow("in version 1.3")
- << "import com.nokia.Test 1.3\n"
- "Test {}"
- << "TestType"
- << "";
- QTest::newRow("in version 1.5")
- << "import com.nokia.Test 1.5\n"
- "Test {}"
- << "TestType"
- << "";
- QTest::newRow("changed in version 1.8")
- << "import com.nokia.Test 1.8\n"
- "Test {}"
- << "TestType2"
- << "";
- QTest::newRow("in version 1.12")
- << "import com.nokia.Test 1.12\n"
- "Test {}"
- << "TestType2"
- << "";
- QTest::newRow("old in version 1.9")
- << "import com.nokia.Test 1.9\n"
- "OldTest {}"
- << "TestType"
- << "";
- QTest::newRow("old in version 1.11")
- << "import com.nokia.Test 1.11\n"
- "OldTest {}"
- << "TestType"
- << "";
- QTest::newRow("multiversion 1")
- << "import com.nokia.Test 1.11\n"
- "import com.nokia.Test 1.12\n"
- "Test {}"
- << (!qmlCheckTypes()?"TestType2":"")
- << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
- QTest::newRow("multiversion 2")
- << "import com.nokia.Test 1.11\n"
- "import com.nokia.Test 1.12\n"
- "OldTest {}"
- << (!qmlCheckTypes()?"TestType":"")
- << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
- QTest::newRow("qualified multiversion 3")
- << "import com.nokia.Test 1.0 as T0\n"
- "import com.nokia.Test 1.8 as T8\n"
- "T0.Test {}"
- << "TestType"
- << "";
- QTest::newRow("qualified multiversion 4")
- << "import com.nokia.Test 1.0 as T0\n"
- "import com.nokia.Test 1.8 as T8\n"
- "T8.Test {}"
- << "TestType2"
- << "";
-}
-
-void tst_qdeclarativelanguage::importsBuiltin()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
- testType(qml,type,error);
-}
-
-void tst_qdeclarativelanguage::importsLocal_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- // import locals
- QTest::newRow("local import")
- << "import \"subdir\"\n" // QT-613
- "Test {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("local import second")
- << "import QtQuick 2.0\nimport \"subdir\"\n"
- "Test {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("local import subsubdir")
- << "import QtQuick 2.0\nimport \"subdir/subsubdir\"\n"
- "SubTest {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("local import QTBUG-7721 A")
- << "subdir.Test {}" // no longer allowed (QTBUG-7721)
- << ""
- << "subdir.Test - subdir is not a namespace";
- QTest::newRow("local import QTBUG-7721 B")
- << "import \"subdir\" as X\n"
- "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
- << ""
- << "X.subsubdir.SubTest - nested namespaces not allowed";
- QTest::newRow("local import as")
- << "import \"subdir\" as T\n"
- "T.Test {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("wrong local import as")
- << "import \"subdir\" as T\n"
- "Test {}"
- << ""
- << "Test is not a type";
- QTest::newRow("library precedence over local import")
- << "import \"subdir\"\n"
- "import com.nokia.Test 1.0\n"
- "Test {}"
- << (!qmlCheckTypes()?"TestType":"")
- << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir");
-}
-
-void tst_qdeclarativelanguage::importsLocal()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
- testType(qml,type,error);
-}
-
-void tst_qdeclarativelanguage::basicRemote_data()
-{
- QTest::addColumn<QUrl>("url");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- QString serverdir = "http://127.0.0.1:14447/qtest/declarative/qmllanguage/";
-
- QTest::newRow("no need for qmldir") << QUrl(serverdir+"Test.qml") << "" << "";
- QTest::newRow("absent qmldir") << QUrl(serverdir+"/noqmldir/Test.qml") << "" << "";
- QTest::newRow("need qmldir") << QUrl(serverdir+"TestLocal.qml") << "" << "";
-}
-
-void tst_qdeclarativelanguage::basicRemote()
-{
- QFETCH(QUrl, url);
- QFETCH(QString, type);
- QFETCH(QString, error);
-
- TestHTTPServer server(14447);
- server.serveDirectory(testdata());
-
- QDeclarativeComponent component(&engine, url);
-
- QTRY_VERIFY(!component.isLoading());
-
- if (error.isEmpty()) {
- if (component.isError())
- qDebug() << component.errors();
- QVERIFY(!component.isError());
- } else {
- QVERIFY(component.isError());
- }
-}
-
-void tst_qdeclarativelanguage::importsRemote_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- QString serverdir = "http://127.0.0.1:14447/qtest/declarative/qmllanguage";
-
- QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QQuickRectangle"
- << "";
- QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QQuickText"
- << "";
- QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QQuickImage"
- << "";
- QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << ""
- << "WrongTestLocal is not a type";
- QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << ""
- << "LocalInternal is not a type";
- QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << ""
- << "UndeclaredLocal is not a type";
-}
-
-void tst_qdeclarativelanguage::importsRemote()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
-
- TestHTTPServer server(14447);
- server.serveDirectory(testdata());
-
- testType(qml,type,error);
-}
-
-void tst_qdeclarativelanguage::importsInstalled_data()
-{
- // QT-610
-
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- // import installed
- QTest::newRow("installed import 0")
- << "import com.nokia.installedtest0 0.0\n"
- "InstalledTestTP {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("installed import 0 as TP")
- << "import com.nokia.installedtest0 0.0 as TP\n"
- "TP.InstalledTestTP {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("installed import 1")
- << "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("installed import 2")
- << "import com.nokia.installedtest 1.3\n"
- "InstalledTest {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("installed import 3")
- << "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << "QQuickText"
- << "";
- QTest::newRow("installed import minor version not available") // QTBUG-11936
- << "import com.nokia.installedtest 0.1\n"
- "InstalledTest {}"
- << ""
- << "module \"com.nokia.installedtest\" version 0.1 is not installed";
- QTest::newRow("installed import minor version not available") // QTBUG-9627
- << "import com.nokia.installedtest 1.10\n"
- "InstalledTest {}"
- << ""
- << "module \"com.nokia.installedtest\" version 1.10 is not installed";
- QTest::newRow("installed import major version not available") // QTBUG-9627
- << "import com.nokia.installedtest 9.0\n"
- "InstalledTest {}"
- << ""
- << "module \"com.nokia.installedtest\" version 9.0 is not installed";
- QTest::newRow("installed import visibility") // QT-614
- << "import com.nokia.installedtest 1.4\n"
- "PrivateType {}"
- << ""
- << "PrivateType is not a type";
-}
-
-void tst_qdeclarativelanguage::importsInstalled()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
- testType(qml,type,error);
-}
-
-
-void tst_qdeclarativelanguage::importsOrder_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("double import") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4");
- QTest::newRow("installed import overrides 1") <<
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
- QTest::newRow("installed import overrides 2") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
- QTest::newRow("installed import re-overrides 1") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
- QTest::newRow("installed import re-overrides 2") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
-
- QTest::newRow("installed import versus builtin 1") <<
- "import com.nokia.installedtest 1.5\n"
- "import QtQuick 2.0\n"
- "Rectangle {}"
- << (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest");
- QTest::newRow("installed import versus builtin 2") <<
- "import QtQuick 2.0\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle {}"
- << (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt");
- QTest::newRow("namespaces cannot be overridden by types 1") <<
- "import QtQuick 2.0 as Rectangle\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle {}"
- << ""
- << "Namespace Rectangle cannot be used as a type";
- QTest::newRow("namespaces cannot be overridden by types 2") <<
- "import QtQuick 2.0 as Rectangle\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle.Image {}"
- << "QQuickImage"
- << "";
- QTest::newRow("local last 1") <<
- "LocalLast {}"
- << "QQuickText"
- << "";
- QTest::newRow("local last 2") <<
- "import com.nokia.installedtest 1.0\n"
- "LocalLast {}"
- << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
- << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
-}
-
-void tst_qdeclarativelanguage::importsOrder()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
- testType(qml,type,error);
-}
-
-void tst_qdeclarativelanguage::importIncorrectCase()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("importIncorrectCase.qml"));
-
- QList<QDeclarativeError> errors = component.errors();
- QCOMPARE(errors.count(), 1);
-
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
- QString expectedError = QLatin1String("cannot load module \"com.Nokia.installedtest\": File name case mismatch for \"") + testdata("lib/com/Nokia/installedtest/qmldir") + QLatin1String("\"");
-#else
- QString expectedError = QLatin1String("module \"com.Nokia.installedtest\" is not installed");
-#endif
-
- QCOMPARE(errors.at(0).description(), expectedError);
-}
-
-void tst_qdeclarativelanguage::importJs_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
- QTest::addColumn<bool>("performTest");
-
- QTest::newRow("defaultVersion")
- << "importJs.1.qml"
- << "importJs.1.errors.txt"
- << true;
-
- QTest::newRow("specifiedVersion")
- << "importJs.2.qml"
- << "importJs.2.errors.txt"
- << true;
-
- QTest::newRow("excludeExcessiveVersion")
- << "importJs.3.qml"
- << "importJs.3.errors.txt"
- << false;
-
- QTest::newRow("includeAppropriateVersion")
- << "importJs.4.qml"
- << "importJs.4.errors.txt"
- << true;
-
- QTest::newRow("noDefaultVersion")
- << "importJs.5.qml"
- << "importJs.5.errors.txt"
- << false;
-
- QTest::newRow("repeatImportFails")
- << "importJs.6.qml"
- << "importJs.6.errors.txt"
- << false;
-
- QTest::newRow("multipleVersionImportFails")
- << "importJs.7.qml"
- << "importJs.7.errors.txt"
- << false;
-
- QTest::newRow("namespacedImport")
- << "importJs.8.qml"
- << "importJs.8.errors.txt"
- << true;
-
- QTest::newRow("namespacedVersionedImport")
- << "importJs.9.qml"
- << "importJs.9.errors.txt"
- << true;
-
- QTest::newRow("namespacedRepeatImport")
- << "importJs.10.qml"
- << "importJs.10.errors.txt"
- << true;
-}
-
-void tst_qdeclarativelanguage::importJs()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
- QFETCH(bool, performTest);
-
- QDeclarativeComponent component(&engine, TEST_FILE(file));
-
- {
- DETERMINE_ERRORS(errorFile.toLatin1().constData(),expected,actual);
- QCOMPARE(expected.size(), actual.size());
- for (int i = 0; i < expected.size(); ++i)
- {
- size_t compareLen = std::min(expected.at(i).length(), actual.at(i).length());
- QCOMPARE(expected.at(i).left(compareLen), actual.at(i).left(compareLen));
- }
- }
-
- if (performTest) {
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toBool(),true);
- delete object;
- }
-}
-
-void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod()
-{
- QObject object;
-
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0);
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0);
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(object, false), (QObject *)0);
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, false) != 0);
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
- }
-}
-
-void tst_qdeclarativelanguage::crash1()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nComponent {}", QUrl());
-}
-
-void tst_qdeclarativelanguage::crash2()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("crash2.qml"));
-}
-
-// QTBUG-8676
-void tst_qdeclarativelanguage::customOnProperty()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("customOnProperty.qml"));
-
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("on").toInt(), 10);
-
- delete object;
-}
-
-// QTBUG-12601
-void tst_qdeclarativelanguage::variantNotify()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("variantNotify.qml"));
-
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("notifyCount").toInt(), 1);
-
- delete object;
-}
-
-void tst_qdeclarativelanguage::revisions()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("revisions11.qml"));
-
- VERIFY_ERRORS(0);
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->prop2(), 10.0);
-
- delete object;
- }
- {
- QDeclarativeEngine myEngine;
- QDeclarativeComponent component(&myEngine, TEST_FILE("revisionssub11.qml"));
-
- VERIFY_ERRORS(0);
- MyRevisionedSubclass *object = qobject_cast<MyRevisionedSubclass*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->prop1(), 10.0);
- QCOMPARE(object->prop2(), 10.0);
- QCOMPARE(object->prop3(), 10.0);
- QCOMPARE(object->prop4(), 10.0);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, TEST_FILE("versionedbase.qml"));
- VERIFY_ERRORS(0);
- MySubclass *object = qobject_cast<MySubclass*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->prop1(), 10.0);
- QCOMPARE(object->prop2(), 10.0);
-
- delete object;
- }
-}
-
-void tst_qdeclarativelanguage::revisionOverloads()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("allowedRevisionOverloads.qml"));
- VERIFY_ERRORS(0);
- }
- {
- QDeclarativeComponent component(&engine, TEST_FILE("disallowedRevisionOverloads.qml"));
- QEXPECT_FAIL("", "QTBUG-13849", Abort);
- QVERIFY(0);
- VERIFY_ERRORS("disallowedRevisionOverloads.errors.txt");
- }
-}
-
-void tst_qdeclarativelanguage::initTestCase()
-{
- QString testdataDir = QFileInfo(QFINDTESTDATA("data")).absolutePath();
- QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir));
-
- registerTypes();
-
- // Registering the TestType class in other modules should have no adverse effects
- qmlRegisterType<TestType>("com.nokia.TestPre", 1, 0, "Test");
-
- qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP");
- qmlRegisterType<TestType>("com.nokia.Test", 1, 0, "Test");
- qmlRegisterType<TestType>("com.nokia.Test", 1, 5, "Test");
- qmlRegisterType<TestType2>("com.nokia.Test", 1, 8, "Test");
- qmlRegisterType<TestType>("com.nokia.Test", 1, 9, "OldTest");
- qmlRegisterType<TestType2>("com.nokia.Test", 1, 12, "Test");
-
- // Registering the TestType class in other modules should have no adverse effects
- qmlRegisterType<TestType>("com.nokia.TestPost", 1, 0, "Test");
-
- // Create locale-specific file
- // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit
- // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters
- // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
- QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
- QVERIFY2(in.open(QIODevice::ReadOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(in.fileName(), in.errorString())));
- QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
- QVERIFY2(out.open(QIODevice::WriteOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(out.fileName(), out.errorString())));
- out.write(in.readAll());
-}
-
-void tst_qdeclarativelanguage::aliasPropertyChangeSignals()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.qml"));
-
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- // QTCREATORBUG-2769
- {
- QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.2.qml"));
-
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-}
-
-// Tests property initializers
-void tst_qdeclarativelanguage::propertyInit()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("propertyInit.1.qml"));
-
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toInt(), 1);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("propertyInit.2.qml"));
-
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toInt(), 123);
-
- delete o;
- }
-}
-
-// Test that registration order doesn't break type availability
-// QTBUG-16878
-void tst_qdeclarativelanguage::registrationOrder()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("registrationOrder.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QVERIFY(o->metaObject() == &MyVersion2Class::staticMetaObject);
- delete o;
-}
-
-void tst_qdeclarativelanguage::readonly()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("readonly.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toInt(), 10);
- QCOMPARE(o->property("test2").toInt(), 18);
- QCOMPARE(o->property("test3").toInt(), 13);
-
- o->setProperty("testData", 13);
-
- QCOMPARE(o->property("test1").toInt(), 10);
- QCOMPARE(o->property("test2").toInt(), 22);
- QCOMPARE(o->property("test3").toInt(), 13);
-
- o->setProperty("testData2", 2);
-
- QCOMPARE(o->property("test1").toInt(), 10);
- QCOMPARE(o->property("test2").toInt(), 22);
- QCOMPARE(o->property("test3").toInt(), 2);
-
- o->setProperty("test1", 11);
- o->setProperty("test2", 11);
- o->setProperty("test3", 11);
-
- QCOMPARE(o->property("test1").toInt(), 10);
- QCOMPARE(o->property("test2").toInt(), 22);
- QCOMPARE(o->property("test3").toInt(), 2);
-
- delete o;
-}
-
-// QTBUG-18268
-void tst_qdeclarativelanguage::remoteLoadCrash()
-{
- TestHTTPServer server(14448);
- server.serveDirectory(testdata());
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml"));
- while (component.isLoading())
- QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50);
-
- QObject *o = component.create();
- delete o;
-}
-
-QTEST_MAIN(tst_qdeclarativelanguage)
-
-#include "tst_qdeclarativelanguage.moc"
diff --git a/tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro b/tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro
deleted file mode 100644
index 3936f4beff..0000000000
--- a/tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelistcompositor
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelistcompositor.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp b/tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp
deleted file mode 100644
index 1716bfe2c7..0000000000
--- a/tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp
+++ /dev/null
@@ -1,1637 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <private/qdeclarativelistcompositor_p.h>
-
-template<typename T, int N> int lengthOf(const T (&)[N]) { return N; }
-
-typedef QDeclarativeListCompositor C;
-
-struct Range
-{
- Range() {}
- Range(void *list, int index, int count, int flags)
- : list(list), index(index), count(count), flags(flags) {}
- void *list;
- int index;
- int count;
- int flags;
-};
-
-template <typename T> struct Array
-{
- Array() : array(0), count(0) {}
- template<int N> Array(const T (&array)[N]) : array(array), count(N) {}
-
- T operator [](int index) const { return array[index]; }
-
- const T *array;
- int count;
-};
-
-typedef Array<int> IndexArray;
-typedef Array<const void *> ListArray;
-
-typedef QVector<QDeclarativeListCompositor::Remove> RemoveList;
-typedef QVector<QDeclarativeListCompositor::Insert> InsertList;
-typedef QVector<QDeclarativeListCompositor::Change> ChangeList;
-
-typedef QVector<Range> RangeList;
-
-Q_DECLARE_METATYPE(RangeList)
-Q_DECLARE_METATYPE(RemoveList)
-Q_DECLARE_METATYPE(InsertList)
-Q_DECLARE_METATYPE(ChangeList)
-Q_DECLARE_METATYPE(void *)
-Q_DECLARE_METATYPE(IndexArray)
-Q_DECLARE_METATYPE(ListArray)
-Q_DECLARE_METATYPE(C::Group)
-
-QT_BEGIN_NAMESPACE
-bool operator ==(const C::Change &left, const C::Change &right)
-{
- return left.index[3] == right.index[3]
- && left.index[2] == right.index[2]
- && left.index[1] == right.index[1]
- && left.index[0] == right.index[0]
- && left.count == right.count
- && left.groups() == right.groups()
- && left.inCache() == right.inCache()
- && (left.moveId == -1) == (right.moveId == -1);
-}
-QT_END_NAMESPACE
-
-static const C::Group Visible = C::Group(2);
-static const C::Group Selection = C::Group(3);
-
-class tst_qdeclarativelistcompositor : public QObject
-{
- Q_OBJECT
-
- enum {
- VisibleFlag = 0x04,
- SelectionFlag = 0x08
- };
-
- void populateChange(
- C::Change &change, int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId)
- {
- change.index[Selection] = sIndex;
- change.index[Visible] = vIndex;
- change.index[C::Default] = dIndex;
- change.index[C::Cache] = cIndex;
- change.count = count;
- change.flags = flags;
- change.moveId = moveId;
- }
-
- C::Remove Remove(
- int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
- {
- C::Remove remove;
- populateChange(remove, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
- return remove;
- }
-
- C::Insert Insert(
- int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
- {
- C::Insert insert;
- populateChange(insert, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
- return insert;
- }
-
- C::Change Change(
- int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
- {
- C::Change change;
- populateChange(change, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
- return change;
- }
-
-private slots:
- void find_data();
- void find();
- void findInsertPosition_data();
- void findInsertPosition();
- void insert();
- void clearFlags_data();
- void clearFlags();
- void setFlags_data();
- void setFlags();
- void move_data();
- void move();
- void moveFromEnd();
- void clear();
- void listItemsInserted_data();
- void listItemsInserted();
- void listItemsRemoved_data();
- void listItemsRemoved();
- void listItemsMoved_data();
- void listItemsMoved();
- void listItemsChanged_data();
- void listItemsChanged();
-};
-
-void tst_qdeclarativelistcompositor::find_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("startGroup");
- QTest::addColumn<int>("startIndex");
- QTest::addColumn<C::Group>("group");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("selectionIndex");
- QTest::addColumn<int>("visibleIndex");
- QTest::addColumn<int>("defaultIndex");
- QTest::addColumn<int>("cacheIndex");
- QTest::addColumn<uint>("rangeFlags");
- QTest::addColumn<int>("rangeIndex");
-
- int listA; void *a = &listA;
-
- QTest::newRow("Start")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
- << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
- << C::Cache << 2
- << Selection << 0
- << 0 << 0 << 0 << 0
- << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0;
-}
-
-void tst_qdeclarativelistcompositor::find()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, startGroup);
- QFETCH(int, startIndex);
- QFETCH(C::Group, group);
- QFETCH(int, index);
- QFETCH(int, cacheIndex);
- QFETCH(int, defaultIndex);
- QFETCH(int, visibleIndex);
- QFETCH(int, selectionIndex);
- QFETCH(uint, rangeFlags);
- QFETCH(int, rangeIndex);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- compositor.find(startGroup, startIndex);
-
- QDeclarativeListCompositor::iterator it = compositor.find(group, index);
- QCOMPARE(it.index[C::Cache], cacheIndex);
- QCOMPARE(it.index[C::Default], defaultIndex);
- QCOMPARE(it.index[Visible], visibleIndex);
- QCOMPARE(it.index[Selection], selectionIndex);
- QCOMPARE(it->flags, rangeFlags);
- QCOMPARE(it->index, rangeIndex);
-}
-
-void tst_qdeclarativelistcompositor::findInsertPosition_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("group");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("selectionIndex");
- QTest::addColumn<int>("visibleIndex");
- QTest::addColumn<int>("defaultIndex");
- QTest::addColumn<int>("cacheIndex");
- QTest::addColumn<uint>("rangeFlags");
- QTest::addColumn<int>("rangeIndex");
-
- int listA; void *a = &listA;
-
- QTest::newRow("Start")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
- << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
- << Selection << 0
- << 0 << 0 << 0 << 0
- << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0;
- QTest::newRow("1")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
- << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
- << Selection << 1
- << 1 << 0 << 1 << 1
- << uint(C::AppendFlag | C::PrependFlag | C::CacheFlag) << 1;
-}
-
-void tst_qdeclarativelistcompositor::findInsertPosition()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, group);
- QFETCH(int, index);
- QFETCH(int, cacheIndex);
- QFETCH(int, defaultIndex);
- QFETCH(int, visibleIndex);
- QFETCH(int, selectionIndex);
- QFETCH(uint, rangeFlags);
- QFETCH(int, rangeIndex);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QDeclarativeListCompositor::insert_iterator it = compositor.findInsertPosition(group, index);
- QCOMPARE(it.index[C::Cache], cacheIndex);
- QCOMPARE(it.index[C::Default], defaultIndex);
- QCOMPARE(it.index[Visible], visibleIndex);
- QCOMPARE(it.index[Selection], selectionIndex);
- QCOMPARE(it->flags, rangeFlags);
- QCOMPARE(it->index, rangeIndex);
-}
-
-void tst_qdeclarativelistcompositor::insert()
-{
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- C::iterator it;
-
- int listA; int *a = &listA;
- int listB; int *b = &listB;
- int listC; int *c = &listC;
-
- {
- compositor.append(a, 0, 12, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
- const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } {
- compositor.append(b, 4, 4, C::DefaultFlag);
- const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7};
- const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert at end.
- compositor.insert(
- C::Default, 16, c, 2, 2, C::DefaultFlag);
- const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert at start
- compositor.insert(
- C::Default, 0, c, 6, 4, C::DefaultFlag);
- const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert after static range.
- compositor.insert(
- C::Default, 4, b, 0, 8, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
- const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert at end of dynamic range.
- compositor.insert(
- C::Default, 12, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
- const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert into range.
- compositor.insert(
- C::Default, 8, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
- const int indexes[] = {6,7,8,9,0,1,2,3,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {c,c,c,c,b,b,b,b,c,c,c,c,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- }
-}
-
-void tst_qdeclarativelistcompositor::clearFlags_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("group");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<int>("flags");
- QTest::addColumn<RemoveList>("expectedRemoves");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<ListArray>("cacheLists");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<ListArray>("defaultLists");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<ListArray>("visibleLists");
- QTest::addColumn<IndexArray>("selectionIndexes");
- QTest::addColumn<ListArray>("selectionLists");
-
- int listA; void *a = &listA;
-
- { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int visibleIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- QTest::newRow("Default, 2, 2, Selection")
- << (RangeList()
- << Range(a, 0, 12, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << C::Default << 2 << 2 << int(SelectionFlag)
- << (RemoveList()
- << Remove(2, 2, 2, 2, 2, SelectionFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- QTest::newRow("Selection, 1, 2, Visible")
- << (RangeList()
- << Range(a, 0, 2, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 4, 8, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << Selection << 1 << 2 << int(VisibleFlag)
- << (RemoveList()
- << Remove(1, 1, 1, 1, 1, VisibleFlag | C::CacheFlag)
- << Remove(2, 3, 4, 4, 1, VisibleFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0};
- static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
- QTest::newRow("Default, 13, 1, Prepend | Selection | Visible | Default")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << C::Default << 13 << 1 << int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag)
- << (RemoveList()
- << Remove(11, 11, 13, 13, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0};
- static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
- QTest::newRow("Cache, 11, 4, Cache")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(0, 0, 1, int(C::CacheFlag))
- << Range(0, 0, 3, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << C::Cache << 11 << 4 << int(C::CacheFlag)
- << (RemoveList())
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
- static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a,0};
- QTest::newRow("Default, 11, 3, Default | Visible | Selection")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 5, 6, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 11, 1, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag))
- << Range(0, 0, 2, int(SelectionFlag | VisibleFlag | C::DefaultFlag))
- << Range(0, 0, 1, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << C::Default << 11 << 3 << int(C::DefaultFlag | VisibleFlag| SelectionFlag)
- << (RemoveList()
- << Remove(9, 9, 11, 11, 1, SelectionFlag | VisibleFlag | C::DefaultFlag)
- << Remove(9, 9, 11, 11, 2, SelectionFlag | VisibleFlag | C::DefaultFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- }
-}
-
-void tst_qdeclarativelistcompositor::clearFlags()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, group);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(int, flags);
- QFETCH(RemoveList, expectedRemoves);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(ListArray, cacheLists);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(ListArray, defaultLists);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(ListArray, visibleLists);
- QFETCH(IndexArray, selectionIndexes);
- QFETCH(ListArray, selectionLists);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Remove> removes;
- compositor.clearFlags(group, index, count, flags, &removes);
-
- QCOMPARE(removes, expectedRemoves);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Cache, i);
- QCOMPARE(it->list, cacheLists[i]);
- if (cacheLists[i])
- QCOMPARE(it.modelIndex(), cacheIndexes[i]);
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Default, i);
- QCOMPARE(it->list, defaultLists[i]);
- if (defaultLists[i])
- QCOMPARE(it.modelIndex(), defaultIndexes[i]);
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- C::iterator it = compositor.find(Visible, i);
- QCOMPARE(it->list, visibleLists[i]);
- if (visibleLists[i])
- QCOMPARE(it.modelIndex(), visibleIndexes[i]);
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- C::iterator it = compositor.find(Selection, i);
- QCOMPARE(it->list, selectionLists[i]);
- if (selectionLists[i])
- QCOMPARE(it.modelIndex(), selectionIndexes[i]);
- }
-}
-
-void tst_qdeclarativelistcompositor::setFlags_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("group");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<int>("flags");
- QTest::addColumn<InsertList>("expectedInserts");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<ListArray>("cacheLists");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<ListArray>("defaultLists");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<ListArray>("visibleLists");
- QTest::addColumn<IndexArray>("selectionIndexes");
- QTest::addColumn<ListArray>("selectionLists");
-
- int listA; void *a = &listA;
-
- { static const int cacheIndexes[] = {0,0,0,0};
- static const void *cacheLists[] = {0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- QTest::newRow("Default, 2, 2, Default")
- << (RangeList()
- << Range(a, 0, 12, C::DefaultFlag)
- << Range(0, 0, 4, C::CacheFlag))
- << C::Default << 2 << 2 << int(C::DefaultFlag)
- << (InsertList())
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0};
- static const void *cacheLists[] = {0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int visibleIndexes[] = {2,3};
- static const void *visibleLists[] = {a,a};
- QTest::newRow("Default, 2, 2, Visible")
- << (RangeList()
- << Range(a, 0, 12, C::DefaultFlag)
- << Range(0, 0, 4, C::CacheFlag))
- << C::Default << 2 << 2 << int(VisibleFlag)
- << (InsertList()
- << Insert(0, 0, 2, 0, 2, VisibleFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {3,6,0,0,0,0};
- static const void *cacheLists[] = {a,a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int visibleIndexes[] = {2,3,6,7};
- static const void *visibleLists[] = {a,a,a,a};
- static const int selectionIndexes[] = {3,6};
- static const void *selectionLists[] = {a,a};
- QTest::newRow("Visible, 1, 2, Selection | Cache")
- << (RangeList()
- << Range(a, 0, 2, C::DefaultFlag)
- << Range(a, 2, 2, VisibleFlag | C::DefaultFlag)
- << Range(a, 4, 2, C::DefaultFlag)
- << Range(a, 6, 2, VisibleFlag | C::DefaultFlag)
- << Range(a, 8, 4, C::DefaultFlag)
- << Range(0, 0, 4, C::CacheFlag))
- << Visible << 1 << 2 << int(SelectionFlag | C::CacheFlag)
- << (InsertList()
- << Insert(0, 1, 3, 0, 1, SelectionFlag | C::CacheFlag)
- << Insert(1, 2, 6, 1, 1, SelectionFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {3,6,0,0,0,0};
- static const void *cacheLists[] = {a,a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int visibleIndexes[] = {2,3,6,7,0};
- static const void *visibleLists[] = {a,a,a,a,0};
- static const int selectionIndexes[] = {3,6};
- static const void *selectionLists[] = {a,a};
- QTest::newRow("Cache, 3, 1, Visible")
- << (RangeList()
- << Range(a, 0, 2, C::DefaultFlag)
- << Range(a, 2, 1, VisibleFlag | C::DefaultFlag)
- << Range(a, 3, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 4, 2, C::DefaultFlag)
- << Range(a, 6, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 7, 1, VisibleFlag | C::DefaultFlag)
- << Range(a, 8, 4, C::DefaultFlag)
- << Range(0, 0, 4, C::CacheFlag))
- << C::Cache << 3 << 1 << int(VisibleFlag)
- << (InsertList()
- << Insert(2, 4, 12, 3, 1, VisibleFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int visibleIndexes[] = {0,1,3,4,5,6,7,8,9,10,11};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a, a, a};
- static const int selectionIndexes[] = {2,6,7,8,9};
- static const void *selectionLists[] = {a,a,a,a,a};
- QTest::newRow("Existing flag, sparse selection")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 3, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 6, 4, C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a,10, 2, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << C::Cache << 3 << 1 << int(VisibleFlag)
- << InsertList()
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- }
-}
-
-void tst_qdeclarativelistcompositor::setFlags()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, group);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(int, flags);
- QFETCH(InsertList, expectedInserts);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(ListArray, cacheLists);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(ListArray, defaultLists);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(ListArray, visibleLists);
- QFETCH(IndexArray, selectionIndexes);
- QFETCH(ListArray, selectionLists);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Insert> inserts;
- compositor.setFlags(group, index, count, flags, &inserts);
-
- QCOMPARE(inserts, expectedInserts);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Cache, i);
- QCOMPARE(it->list, cacheLists[i]);
- if (cacheLists[i])
- QCOMPARE(it.modelIndex(), cacheIndexes[i]);
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Default, i);
- QCOMPARE(it->list, defaultLists[i]);
- if (defaultLists[i])
- QCOMPARE(it.modelIndex(), defaultIndexes[i]);
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- C::iterator it = compositor.find(Visible, i);
- QCOMPARE(it->list, visibleLists[i]);
- if (visibleLists[i])
- QCOMPARE(it.modelIndex(), visibleIndexes[i]);
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- C::iterator it = compositor.find(Selection, i);
- QCOMPARE(it->list, selectionLists[i]);
- if (selectionLists[i])
- QCOMPARE(it.modelIndex(), selectionIndexes[i]);
- }
-}
-
-void tst_qdeclarativelistcompositor::move_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("fromGroup");
- QTest::addColumn<int>("from");
- QTest::addColumn<C::Group>("toGroup");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<RemoveList>("expectedRemoves");
- QTest::addColumn<InsertList>("expectedInserts");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<ListArray>("cacheLists");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<ListArray>("defaultLists");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<ListArray>("visibleLists");
- QTest::addColumn<IndexArray>("selectionIndexes");
- QTest::addColumn<ListArray>("selectionLists");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
- int listC; void *c = &listC;
-
- { static const int cacheIndexes[] = {0,0,0,0,2,3};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,0,1,2,3,4,5,0,1,2,3,4,5,1,2,3,0,1,2,3,4,5};
- static const void *defaultLists[] = {0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,0,c,c,c,c,c,c};
- QTest::newRow("15, 0, 1")
- << (RangeList()
- << Range(a, 0, 6, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(0, 0, 4, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 15 << C::Default << 0 << 1
- << (RemoveList()
- << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0,2,3};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,1,0,1,2,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5};
- static const void *defaultLists[] = {0,0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c};
- QTest::newRow("15, 1, 1")
- << (RangeList()
- << Range(0, 0, 1, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 6, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(0, 0, 3, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 15 << C::Default << 1 << 1
- << (RemoveList()
- << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0,2,3};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,1,2,0,1,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5};
- static const void *defaultLists[] = {a,a,a,0,0,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c};
- QTest::newRow("0, 3, 2")
- << (RangeList()
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 6, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 0 << C::Default << 3 << 2
- << (RemoveList()
- << Remove(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 3, 0, 2, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0,2,3};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,1,2,3,4,5};
- static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c};
- QTest::newRow("7, 1, 10")
- << (RangeList()
- << Range(a, 0, 3, C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 3, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 7 << C::Default << 1 << 10
- << (RemoveList()
- << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 0)
- << Remove(0, 0, 7, 2, 6, C::DefaultFlag, 1)
- << Remove(0, 0, 7, 2, 2, C::DefaultFlag | C::CacheFlag, 2)
- << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 3))
- << (InsertList()
- << Insert(0, 0, 1, 0, 1, C::DefaultFlag, 0)
- << Insert(0, 0, 2, 0, 6, C::DefaultFlag, 1)
- << Insert(0, 0, 8, 0, 2, C::DefaultFlag | C::CacheFlag, 2)
- << Insert(0, 0, 10, 2, 1, C::DefaultFlag, 3))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0,3,2};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,3,4,5,1,2};
- static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c};
- QTest::newRow("17, 20, 2")
- << (RangeList()
- << Range(a, 0, 1, C::DefaultFlag)
- << Range(a, 5, 1, C::DefaultFlag)
- << Range(b, 0, 6, C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 1, C::DefaultFlag)
- << Range(a, 1, 2, C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 2, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag)
- << Range(c, 0, 1, C::PrependFlag)
- << Range(c, 1, 1, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 17 << C::Default << 20 << 2
- << (RemoveList()
- << Remove(0, 0, 17, 4, 1, C::DefaultFlag, 0)
- << Remove(0, 0, 17, 4, 1, C::DefaultFlag | C::CacheFlag, 1))
- << (InsertList()
- << Insert(0, 0, 20, 5, 1, C::DefaultFlag, 0)
- << Insert(0, 0, 21, 5, 1, C::DefaultFlag | C::CacheFlag, 1))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
- static const void *cacheLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
- static const int defaultIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
- static const void *defaultLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
- static const int visibleIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
- static const void *visibleLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
- QTest::newRow("3, 4, 5")
- << (RangeList()
- << Range(a, 8, 4, VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 1, C::PrependFlag)
- << Range(a, 2, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 8, 4, C::AppendFlag | C::PrependFlag))
- << C::Default << 3 << C::Default << 4 << 5
- << (RemoveList()
- << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0)
- << Remove(0, 3, 3, 3, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1)
- << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2)
- << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3))
- << (InsertList()
- << Insert(0, 4, 4, 4, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0)
- << Insert(0, 5, 5, 5, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1)
- << Insert(0, 7, 7, 7, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2)
- << Insert(0, 8, 8, 8, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,1};
- static const void *cacheLists[] = {a,a};
- static const int defaultIndexes[] = {0,1};
- static const void *defaultLists[] = {a,a};
- QTest::newRow("0, 1, 1")
- << (RangeList()
- << Range(a, 0, 1, C::PrependFlag)
- << Range(a, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 0, C::AppendFlag | C::PrependFlag)
- << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag))
- << C::Default << 0 << C::Default << 1 << 1
- << (RemoveList()
- << Remove(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- }
-}
-
-void tst_qdeclarativelistcompositor::move()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, fromGroup);
- QFETCH(int, from);
- QFETCH(C::Group, toGroup);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(RemoveList, expectedRemoves);
- QFETCH(InsertList, expectedInserts);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(ListArray, cacheLists);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(ListArray, defaultLists);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(ListArray, visibleLists);
- QFETCH(IndexArray, selectionIndexes);
- QFETCH(ListArray, selectionLists);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Remove> removes;
- QVector<C::Insert> inserts;
- compositor.move(fromGroup, from, toGroup, to, count, fromGroup, &removes, &inserts);
-
- QCOMPARE(removes, expectedRemoves);
- QCOMPARE(inserts, expectedInserts);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Cache, i);
- QCOMPARE(it->list, cacheLists[i]);
- if (cacheLists[i])
- QCOMPARE(it.modelIndex(), cacheIndexes[i]);
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Default, i);
- QCOMPARE(it->list, defaultLists[i]);
- if (defaultLists[i])
- QCOMPARE(it.modelIndex(), defaultIndexes[i]);
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- C::iterator it = compositor.find(Visible, i);
- QCOMPARE(it->list, visibleLists[i]);
- if (visibleLists[i])
- QCOMPARE(it.modelIndex(), visibleIndexes[i]);
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- C::iterator it = compositor.find(Selection, i);
- QCOMPARE(it->list, selectionLists[i]);
- if (selectionLists[i])
- QCOMPARE(it.modelIndex(), selectionIndexes[i]);
- }
-}
-
-void tst_qdeclarativelistcompositor::moveFromEnd()
-{
- int listA; void *a = &listA;
-
- QDeclarativeListCompositor compositor;
- compositor.append(a, 0, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
-
- // Moving an item anchors it to that position.
- compositor.move(C::Default, 0, C::Default, 0, 1, C::Default);
-
- // The existing item is anchored at 0 so prepending an item to the source will append it here
- QVector<C::Insert> inserts;
- compositor.listItemsInserted(a, 0, 1, &inserts);
-
- QCOMPARE(inserts.count(), 1);
- QCOMPARE(inserts.at(0).index[1], 1);
- QCOMPARE(inserts.at(0).count, 1);
-
- C::iterator it;
- it = compositor.find(C::Default, 0);
- QCOMPARE(it.modelIndex(), 1);
-
- it = compositor.find(C::Default, 1);
- QCOMPARE(it.modelIndex(), 0);
-}
-
-void tst_qdeclarativelistcompositor::clear()
-{
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- compositor.append(a, 0, 8, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag);
- compositor.append(b, 4, 5, VisibleFlag | C::DefaultFlag);
- compositor.append(0, 0, 3, VisibleFlag | C::DefaultFlag | C::CacheFlag);
-
- QCOMPARE(compositor.count(C::Default), 16);
- QCOMPARE(compositor.count(Visible), 16);
- QCOMPARE(compositor.count(C::Cache), 3);
-
- compositor.clear();
- QCOMPARE(compositor.count(C::Default), 0);
- QCOMPARE(compositor.count(Visible), 0);
- QCOMPARE(compositor.count(C::Cache), 0);
-}
-
-void tst_qdeclarativelistcompositor::listItemsInserted_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<void *>("list");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<InsertList>("expectedInserts");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<IndexArray>("selectionIndexes");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
- QTest::newRow("A 10, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 10 << 2
- << InsertList()
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
- QTest::newRow("B 10, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << b << 10 << 2
- << InsertList()
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,2,3,7,8,/*B*/0,1,2,3,/*A*/4,5,6};
- static const int visibleIndexes[] = {/*A*/0,1};
- QTest::newRow("A 0, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 0 << 2
- << (InsertList()
- << Insert(0, 0, 0, 0, 2, VisibleFlag | C::DefaultFlag))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,/*B*/0,1,2,3,/*A*/4,6,7};
- static const int visibleIndexes[] = {/*A*/0,1,5};
- QTest::newRow("A 5, 1")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag)
- << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 4, 3, C::PrependFlag)
- << Range(a, 7, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 4, 3, C::DefaultFlag))
- << a << 5 << 1
- << (InsertList()
- << Insert(0, 2, 4, 0, 1, VisibleFlag | C::DefaultFlag))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,10,11,/*B*/0,1,2,3,/*A*/4,6,7};
- static const int visibleIndexes[] = {/*A*/0,1,5,10,11};
- QTest::newRow("A 10, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag)
- << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 4, 1, C::PrependFlag)
- << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag)
- << Range(a, 6, 2, C::PrependFlag)
- << Range(a, 8, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 4, 1, C::DefaultFlag)
- << Range(a, 6, 2, C::DefaultFlag))
- << a << 10 << 2
- << (InsertList()
- << Insert(0, 3, 7, 0, 2, VisibleFlag | C::DefaultFlag))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,5,6,7,8,9};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9};
- static const int visibleIndexes[] = {/*A*/3,4};
- QTest::newRow("Insert after remove")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 3, C::CacheFlag)
- << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 3 << 2
- << (InsertList()
- << Insert(0, 0, 3, 6, 2, VisibleFlag | C::DefaultFlag))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6};
- static const int visibleIndexes[] = {/*A*/0,1,2,3,4,5,6};
- QTest::newRow("Consecutive appends")
- << (RangeList()
- << Range(a, 0, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag)
- << Range(a, 6, 0, C::AppendFlag | VisibleFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 6 << 1
- << (InsertList()
- << Insert(0, 6, 6, 5, 1, VisibleFlag | C::DefaultFlag))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsInserted()
-{
- QFETCH(RangeList, ranges);
- QFETCH(void *, list);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(InsertList, expectedInserts);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(IndexArray, selectionIndexes);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Insert> inserts;
- compositor.listItemsInserted(list, index, count, &inserts);
-
- QCOMPARE(inserts, expectedInserts);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- if (cacheIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- if (defaultIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- if (visibleIndexes[i] != -1) {
- QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- if (selectionIndexes[i] != -1) {
- QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
- }
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsRemoved_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<void *>("list");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<RemoveList>("expectedRemoves");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<IndexArray>("selectionIndexes");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
- QTest::newRow("12, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 12 << 2
- << RemoveList()
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,/*B*/0,1,2,3,/*A*/2,3};
- QTest::newRow("4, 3")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 4 << 3
- << (RemoveList()
- << Remove(0, 0, 2, 0, 2, C::DefaultFlag)
- << Remove(0, 0, 8, 0, 1, C::DefaultFlag))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,-1,-1,3,4,5};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5};
- QTest::newRow("Remove after remove")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 3, C::CacheFlag)
- << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 3 << 2
- << (RemoveList()
- << Remove(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6};
- QTest::newRow("Sparse remove")
- << (RangeList()
- << Range(a, 0, 2, C::CacheFlag)
- << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 1, C::CacheFlag)
- << Range(a, 1, 5, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 1, C::CacheFlag)
- << Range(a, 6, 2, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 1, C::CacheFlag)
- << Range(a, 8, 3, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 1, C::CacheFlag)
- << Range(a, 11, 1, C::DefaultFlag | C::CacheFlag)
- << Range(a, 12, 5, C::DefaultFlag))
- << a << 1 << 10
- << (RemoveList()
- << Remove(0, 0, 1, 4, 5, C::DefaultFlag | C::CacheFlag)
- << Remove(0, 0, 1,10, 2, C::DefaultFlag | C::CacheFlag)
- << Remove(0, 0, 1,13, 3, C::DefaultFlag | C::CacheFlag))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsRemoved()
-{
- QFETCH(RangeList, ranges);
- QFETCH(void *, list);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(RemoveList, expectedRemoves);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(IndexArray, selectionIndexes);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Remove> removes;
- compositor.listItemsRemoved(list, index, count, &removes);
-
- QCOMPARE(removes, expectedRemoves);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- if (cacheIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- if (defaultIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- if (visibleIndexes[i] != -1) {
- QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- if (selectionIndexes[i] != -1) {
- QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
- }
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsMoved_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<void *>("list");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<RemoveList>("expectedRemoves");
- QTest::addColumn<InsertList>("expectedInserts");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<IndexArray>("selectionIndexes");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- { static const int defaultIndexes[] = {/*A*/0,2,3,4,/*B*/0,1,2,3,/*A*/5,6,1};
- QTest::newRow("4, 1, 3")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 4 << 1 << 3
- << (RemoveList()
- << Remove(0, 0, 2, 0, 2, C::DefaultFlag, 0))
- << (InsertList()
- << Insert(0, 0, 1, 0, 2, C::DefaultFlag, 0))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/1,2,3,6,/*B*/0,1,2,3,/*A*/4,5,0};
- QTest::newRow("0, 6, 1")
- << (RangeList()
- << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag)
- << Range(a, 1, 1, C::PrependFlag)
- << Range(a, 2, 3, C::PrependFlag | C::DefaultFlag)
- << Range(a, 5, 2, C::PrependFlag)
- << Range(a, 7, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 5, 2, C::DefaultFlag)
- << Range(a, 1, 1, C::DefaultFlag))
- << a << 0 << 6 << 1
- << (RemoveList()
- << Remove(0, 0, 0, 0, 1, C::DefaultFlag, 0))
- << (InsertList()
- << Insert(0, 0, 3, 0, 1, C::DefaultFlag, 0))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,3,4};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7};
- QTest::newRow("6, 2, 1")
- << (RangeList()
- << Range(a, 0, 4, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 4, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << a << 6 << 2 << 1
- << (RemoveList()
- << Remove(0, 0, 6, 4, 1, C::DefaultFlag, 0))
- << (InsertList()
- << Insert(0, 0, 2, 2, 1, C::DefaultFlag, 0))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,3,4,5,6,7};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7};
- QTest::newRow("Move after remove")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 3, C::CacheFlag)
- << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 4 << 2 << 2
- << (RemoveList()
- << Remove(0, 0, 4, 7, 2, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 2, 5, 2, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,5,6,7,8,9,10,11,12};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11,12};
- QTest::newRow("Move merge tail")
- << (RangeList()
- << Range(a, 0, 10, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 10, 3, C::PrependFlag | C::DefaultFlag)
- << Range(a, 13, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 8 << 0 << 5
- << (RemoveList()
- << Remove(0, 0, 8, 8, 2, C::DefaultFlag | C::CacheFlag, 0)
- << Remove(0, 0, 8, 8, 3, C::DefaultFlag, 1))
- << (InsertList()
- << Insert(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0)
- << Insert(0, 0, 2, 2, 3, C::DefaultFlag, 1))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,2,3};
- static const int defaultIndexes[] = {/*A*/0,1,2,3};
- static const int selectionIndexes[] = {/*A*/3};
- QTest::newRow("Move selection")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 2 << 3 << 1
- << (RemoveList()
- << Remove(0, 0, 2, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 3, 3, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray(selectionIndexes);
- } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4,5,8,9};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11};
- QTest::newRow("move mixed cached items")
- << (RangeList()
- << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 1, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 3, 7, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 10, 2, C::PrependFlag | C::DefaultFlag))
- << a << 1 << 6 << 3
- << (RemoveList()
- << Remove(0, 0, 1, 1, 2, C::PrependFlag | C::DefaultFlag, 0)
- << Remove(0, 0, 1, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
- << (InsertList()
- << Insert(0, 0, 6, 6, 2, C::PrependFlag | C::DefaultFlag, 0)
- << Insert(0, 0, 8, 6, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsMoved()
-{
- QFETCH(RangeList, ranges);
- QFETCH(void *, list);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(RemoveList, expectedRemoves);
- QFETCH(InsertList, expectedInserts);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(IndexArray, selectionIndexes);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Remove> removes;
- QVector<C::Insert> inserts;
- compositor.listItemsMoved(list, from, to, count, &removes, &inserts);
-
- QCOMPARE(removes, expectedRemoves);
- QCOMPARE(inserts, expectedInserts);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- if (cacheIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- if (defaultIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- if (visibleIndexes[i] != -1) {
- QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- if (selectionIndexes[i] != -1) {
- QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
- }
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsChanged_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<void *>("list");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<ChangeList>("expectedChanges");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- QTest::newRow("overlapping")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 3 << 4
- << (ChangeList()
- << Change(0, 0, 2, 0, 2, C::DefaultFlag)
- << Change(0, 0, 9, 0, 2, C::DefaultFlag));
- QTest::newRow("Change after remove")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 3, C::CacheFlag)
- << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 3 << 2
- << (ChangeList()
- << Change(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag));
-}
-
-void tst_qdeclarativelistcompositor::listItemsChanged()
-{
- QFETCH(RangeList, ranges);
- QFETCH(void *, list);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(ChangeList, expectedChanges);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Change> changes;
- compositor.listItemsChanged(list, index, count, &changes);
-
- QCOMPARE(changes, expectedChanges);
-}
-
-QTEST_MAIN(tst_qdeclarativelistcompositor)
-
-#include "tst_qdeclarativelistcompositor.moc"
-
-
diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
deleted file mode 100644
index 25db0f9415..0000000000
--- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelistmodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelistmodel.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
deleted file mode 100644
index 4eb723bf8e..0000000000
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ /dev/null
@@ -1,1632 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
-#include <QtDeclarative/private/qdeclarativeexpression_p.h>
-#include <QDeclarativeComponent>
-
-#include <QtCore/qtimer.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qtranslator.h>
-#include <QSignalSpy>
-
-#include "../../shared/util.h"
-
-Q_DECLARE_METATYPE(QList<int>)
-Q_DECLARE_METATYPE(QList<QVariantHash>)
-
-#define RUNEVAL(object, string) \
- QVERIFY(QMetaObject::invokeMethod(object, "runEval", Q_ARG(QVariant, QString(string))));
-
-inline QVariant runexpr(QDeclarativeEngine *engine, const QString &str)
-{
- QDeclarativeExpression expr(engine->rootContext(), 0, str);
- return expr.evaluate();
-}
-
-#define RUNEXPR(string) runexpr(&engine, QString(string))
-
-static bool isValidErrorMessage(const QString &msg, bool dynamicRoleTest)
-{
- bool valid = true;
-
- if (msg.isEmpty()) {
- valid = false;
- } else if (dynamicRoleTest) {
- if (msg.contains("Can't assign to existing role") || msg.contains("Can't create role for unsupported data type"))
- valid = false;
- }
-
- return valid;
-}
-
-class tst_qdeclarativelistmodel : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativelistmodel() {}
-
-private:
- int roleFromName(const QDeclarativeListModel *model, const QString &roleName);
- QQuickItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model);
- void waitForWorker(QQuickItem *item);
-
- static bool compareVariantList(const QVariantList &testList, QVariant object);
-
-private slots:
- void static_types();
- void static_types_data();
- void static_i18n();
- void static_i18n_data();
- void static_nestedElements();
- void static_nestedElements_data();
- void dynamic_data();
- void dynamic();
- void dynamic_worker_data();
- void dynamic_worker();
- void dynamic_worker_sync_data();
- void dynamic_worker_sync();
- void enumerate();
- void error_data();
- void error();
- void syncError();
- void get();
- void set_data();
- void set();
- void get_data();
- void get_worker();
- void get_worker_data();
- void get_nested();
- void get_nested_data();
- void crash_model_with_multiple_roles();
- void set_model_cache();
- void property_changes();
- void property_changes_data();
- void property_changes_worker();
- void property_changes_worker_data();
- void clear_data();
- void clear();
- void signal_handlers_data();
- void signal_handlers();
- void worker_sync_data();
- void worker_sync();
- void worker_remove_element_data();
- void worker_remove_element();
- void worker_remove_list_data();
- void worker_remove_list();
- void role_mode_data();
- void role_mode();
- void dynamic_role();
- void dynamic_role_data();
-};
-
-bool tst_qdeclarativelistmodel::compareVariantList(const QVariantList &testList, QVariant object)
-{
- bool allOk = true;
-
- QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel *>(object.value<QObject *>());
- if (model == 0)
- return false;
-
- if (model->count() != testList.count())
- return false;
-
- for (int i=0 ; i < testList.count() ; ++i) {
- const QVariant &testVariant = testList.at(i);
- if (testVariant.type() != QVariant::Map)
- return false;
- const QVariantMap &map = testVariant.toMap();
-
- const QList<int> &roles = model->roles();
-
- QVariantMap::const_iterator it = map.begin();
- QVariantMap::const_iterator end = map.end();
-
- while (it != end) {
- const QString &testKey = it.key();
- const QVariant &testData = it.value();
-
- int roleIndex = -1;
- for (int j=0 ; j < roles.count() ; ++j) {
- if (model->toString(roles[j]).compare(testKey) == 0) {
- roleIndex = j;
- break;
- }
- }
-
- if (roleIndex == -1)
- return false;
-
- const QVariant &modelData = model->data(i, roleIndex);
-
- if (testData.type() == QVariant::List) {
- const QVariantList &subList = testData.toList();
- allOk = allOk && compareVariantList(subList, modelData);
- } else {
- allOk = allOk && (testData == modelData);
- }
-
- ++it;
- }
- }
-
- return allOk;
-}
-
-int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName)
-{
- QList<int> roles = model->roles();
- for (int i=0; i<roles.count(); i++) {
- if (model->toString(roles[i]) == roleName)
- return roles[i];
- }
- return -1;
-}
-
-QQuickItem *tst_qdeclarativelistmodel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model)
-{
- QQuickItem *item = qobject_cast<QQuickItem*>(component->create());
- QDeclarativeEngine::setContextForObject(model, eng->rootContext());
- if (item)
- item->setProperty("model", qVariantFromValue(model));
- return item;
-}
-
-void tst_qdeclarativelistmodel::waitForWorker(QQuickItem *item)
-{
- QEventLoop loop;
- QTimer timer;
- timer.setSingleShot(true);
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
-
- QDeclarativeProperty prop(item, "done");
- QVERIFY(prop.isValid());
- QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit())));
- timer.start(10000);
- loop.exec();
- QVERIFY(timer.isActive());
-}
-
-void tst_qdeclarativelistmodel::static_types_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QVariant>("value");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("string")
- << "ListElement { foo: \"bar\" }"
- << QVariant(QString("bar"))
- << QString();
-
- QTest::newRow("real")
- << "ListElement { foo: 10.5 }"
- << QVariant(10.5)
- << QString();
-
- QTest::newRow("real0")
- << "ListElement { foo: 0 }"
- << QVariant(double(0))
- << QString();
-
- QTest::newRow("bool")
- << "ListElement { foo: false }"
- << QVariant(false)
- << QString();
-
- QTest::newRow("bool")
- << "ListElement { foo: true }"
- << QVariant(true)
- << QString();
-
- QTest::newRow("enum")
- << "ListElement { foo: Text.AlignHCenter }"
- << QVariant(double(QQuickText::AlignHCenter))
- << QString();
-
- QTest::newRow("Qt enum")
- << "ListElement { foo: Qt.AlignBottom }"
- << QVariant(double(Qt::AlignBottom))
- << QString();
-
- QTest::newRow("role error")
- << "ListElement { foo: 1 } ListElement { foo: 'string' }"
- << QVariant()
- << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [String -> Number]");
-
- QTest::newRow("list type error")
- << "ListElement { foo: 1 } ListElement { foo: ListElement { bar: 1 } }"
- << QVariant()
- << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [List -> Number]");
-}
-
-void tst_qdeclarativelistmodel::static_types()
-{
- QFETCH(QString, qml);
- QFETCH(QVariant, value);
- QFETCH(QString, error);
-
- qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
-
- if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
- }
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
-
- QVERIFY(!component.isError());
-
- QObject *obj = component.create();
- QVERIFY(obj != 0);
-
- if (error.isEmpty()) {
- QVariant actual = obj->property("test");
-
- QCOMPARE(actual, value);
- QCOMPARE(actual.toString(), value.toString());
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_i18n_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QVariant>("value");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("QT_TR_NOOP")
- << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"na\303\257ve\") }")
- << QVariant(QString::fromUtf8("na\303\257ve"))
- << QString();
-
- QTest::newRow("QT_TRANSLATE_NOOP")
- << "ListElement { foo: QT_TRANSLATE_NOOP(\"MyListModel\", \"hello\") }"
- << QVariant(QString("hello"))
- << QString();
-
- QTest::newRow("QT_TRID_NOOP")
- << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP(\"qtn_1st_text\") }")
- << QVariant(QString("qtn_1st_text"))
- << QString();
-
- QTest::newRow("QT_TR_NOOP extra param")
- << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"hello\",\"world\") }")
- << QVariant(QString())
- << QString("ListElement: improperly specified QT_TR_NOOP");
-
- QTest::newRow("QT_TRANSLATE_NOOP missing params")
- << "ListElement { foo: QT_TRANSLATE_NOOP() }"
- << QVariant(QString())
- << QString("ListElement: improperly specified QT_TRANSLATE_NOOP");
-
- QTest::newRow("QT_TRID_NOOP missing param")
- << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP() }")
- << QVariant(QString())
- << QString("ListElement: improperly specified QT_TRID_NOOP");
-}
-
-void tst_qdeclarativelistmodel::static_i18n()
-{
- QFETCH(QString, qml);
- QFETCH(QVariant, value);
- QFETCH(QString, error);
-
- qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
-
- if (!error.isEmpty()) {
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), error);
- return;
- }
-
- QVERIFY(!component.isError());
-
- QObject *obj = component.create();
- QVERIFY(obj != 0);
-
- QVariant actual = obj->property("test");
-
- QCOMPARE(actual, value);
- QCOMPARE(actual.toString(), value.toString());
-
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_nestedElements()
-{
- QFETCH(int, elementCount);
-
- QStringList elements;
- for (int i=0; i<elementCount; i++)
- elements.append("ListElement { a: 1; b: 2 }");
- QString elementsStr = elements.join(",\n") + "\n";
-
- QString componentStr =
- "import QtQuick 2.0\n"
- "Item {\n"
- " property variant count: model.get(0).attributes.count\n"
- " ListModel {\n"
- " id: model\n"
- " ListElement {\n"
- " attributes: [\n";
- componentStr += elementsStr.toUtf8().constData();
- componentStr +=
- " ]\n"
- " }\n"
- " }\n"
- "}";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
-
- QObject *obj = component.create();
- QVERIFY(obj != 0);
-
- QVariant count = obj->property("count");
- QCOMPARE(count.type(), QVariant::Int);
- QCOMPARE(count.toInt(), elementCount);
-
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_nestedElements_data()
-{
- QTest::addColumn<int>("elementCount");
-
- QTest::newRow("0 items") << 0;
- QTest::newRow("1 item") << 1;
- QTest::newRow("2 items") << 2;
- QTest::newRow("many items") << 5;
-}
-
-void tst_qdeclarativelistmodel::dynamic_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<bool>("dynamicRoles");
-
- for (int i=0 ; i < 2 ; ++i) {
- bool dr = (i != 0);
-
- // Simple flat model
- QTest::newRow("count") << "count" << 0 << "" << dr;
-
- QTest::newRow("get1") << "{get(0) === undefined}" << 1 << "" << dr;
- QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "" << dr;
- QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "" << dr;
- QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "" << dr;
- QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "" << dr;
- QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "" << dr;
-
- QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "" << dr;
- QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "" << dr;
- QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "" << dr;
- QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "" << dr;
- QTest::newRow("append4a") << "{append(123)}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
- QTest::newRow("append4b") << "{append([{'foo':123},{'foo':456},{'foo':789}]);count}" << 3 << "" << dr;
- QTest::newRow("append4c") << "{append([{'foo':123},{'foo':456},{'foo':789}]);get(1).foo}" << 456 << "" << dr;
-
- QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "" << dr;
- QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "" << dr;
- QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << "" << dr;
-
- QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "" << dr;
- QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "" << dr;
- QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "" << dr;
- QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << "" << dr;
- QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [-1 - 0] out of range [0 - 1]" << dr;
- QTest::newRow("remove4a") << "{remove(0)}" << 0 << "<Unknown File>: QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr;
- QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << "<Unknown File>: QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr;
- QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [1 - 2] out of range [0 - 1]" << dr;
- QTest::newRow("remove5a") << "{append({'foo':123});append({'foo':456});remove(0,2);count}" << 0 << "" << dr;
- QTest::newRow("remove5b") << "{append({'foo':123});append({'foo':456});remove(0,1);count}" << 1 << "" << dr;
- QTest::newRow("remove5c") << "{append({'foo':123});append({'foo':456});remove(1,1);count}" << 1 << "" << dr;
- QTest::newRow("remove5d") << "{append({'foo':123});append({'foo':456});remove(0,1);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("remove5e") << "{append({'foo':123});append({'foo':456});remove(1,1);get(0).foo}" << 123 << "" << dr;
- QTest::newRow("remove5f") << "{append({'foo':123});append({'foo':456});append({'foo':789});remove(0,1);remove(1,1);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("remove6a") << "{remove();count}" << 0 << "<Unknown File>: QML ListModel: remove: incorrect number of arguments" << dr;
- QTest::newRow("remove6b") << "{remove(1,2,3);count}" << 0 << "<Unknown File>: QML ListModel: remove: incorrect number of arguments" << dr;
- QTest::newRow("remove7a") << "{append({'foo':123});remove(0,0);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [0 - 0] out of range [0 - 1]" << dr;
- QTest::newRow("remove7b") << "{append({'foo':123});remove(0,-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [0 - -1] out of range [0 - 1]" << dr;
-
- QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "" << dr;
- QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "<Unknown File>: QML ListModel: insert: index 1 out of range" << dr;
- QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "" << dr;
- QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "" << dr;
- QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "" << dr;
- QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "" << dr;
- QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "" << dr;
- QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << "<Unknown File>: QML ListModel: insert: index -1 out of range" << dr;
- QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
- QTest::newRow("insert5b") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);count}" << 3 << "" << dr;
- QTest::newRow("insert5c") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);get(2).foo}" << 33 << "" << dr;
-
- QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "" << dr;
- QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "" << dr;
- QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "" << dr;
- QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "" << dr;
- QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "" << dr;
- QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr;
- QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr;
- QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr;
- QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "" << dr;
-
- QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "" << dr;
- QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "" << dr;
- QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "" << dr;
- QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index 0 out of range" << dr;
- QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr;
- QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << "<Unknown File>: QML ListModel: set: index 1 out of range" << dr;
- QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "" << dr;
-
- QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "" << dr;
- QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "" << dr;
- QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "" << dr;
- QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "" << dr;
- QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "" << dr;
- QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "" << dr;
- QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "" << dr;
- QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
- QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
- QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
- QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
-
- QTest::newRow("large1") << "{append({'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8});get(0).h}" << 8 << "" << dr;
-
- QTest::newRow("datatypes1") << "{append({'a':1});append({'a':'string'});}" << 0 << "<Unknown File>: Can't assign to existing role 'a' of different type [String -> Number]" << dr;
-
- QTest::newRow("null") << "{append({'a':null});}" << 0 << "" << dr;
- QTest::newRow("setNull") << "{append({'a':1});set(0, {'a':null});}" << 0 << "" << dr;
- QTest::newRow("setString") << "{append({'a':'hello'});set(0, {'a':'world'});get(0).a == 'world'}" << 1 << "" << dr;
- QTest::newRow("setInt") << "{append({'a':5});set(0, {'a':10});get(0).a}" << 10 << "" << dr;
- QTest::newRow("setNumber") << "{append({'a':6});set(0, {'a':5.5});get(0).a < 5.6}" << 1 << "" << dr;
- QTest::newRow("badType0") << "{append({'a':'hello'});set(0, {'a':1});}" << 0 << "<Unknown File>: Can't assign to existing role 'a' of different type [Number -> String]" << dr;
- QTest::newRow("invalidInsert0") << "{insert(0);}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
- QTest::newRow("invalidAppend0") << "{append();}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
- QTest::newRow("invalidInsert1") << "{insert(0, 34);}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
- QTest::newRow("invalidAppend1") << "{append(37);}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
-
- // QObjects
- QTest::newRow("qobject0") << "{append({'a':dummyItem0});}" << 0 << "" << dr;
- QTest::newRow("qobject1") << "{append({'a':dummyItem0});set(0,{'a':dummyItem1});get(0).a == dummyItem1;}" << 1 << "" << dr;
- QTest::newRow("qobject2") << "{append({'a':dummyItem0});get(0).a == dummyItem0;}" << 1 << "" << dr;
- QTest::newRow("qobject3") << "{append({'a':dummyItem0});append({'b':1});}" << 0 << "" << dr;
-
- // JS objects
- QTest::newRow("js1") << "{append({'foo':{'prop':1}});count}" << 1 << "" << dr;
- QTest::newRow("js2") << "{append({'foo':{'prop':27}});get(0).foo.prop}" << 27 << "" << dr;
- QTest::newRow("js3") << "{append({'foo':{'prop':27}});append({'bar':1});count}" << 2 << "" << dr;
- QTest::newRow("js4") << "{append({'foo':{'prop':27}});append({'bar':1});set(0, {'foo':{'prop':28}});get(0).foo.prop}" << 28 << "" << dr;
- QTest::newRow("js5") << "{append({'foo':{'prop':27}});append({'bar':1});set(1, {'foo':{'prop':33}});get(1).foo.prop}" << 33 << "" << dr;
- QTest::newRow("js6") << "{append({'foo':{'prop':27}});clear();count}" << 0 << "" << dr;
- QTest::newRow("js7") << "{append({'foo':{'prop':27}});set(0, {'foo':null});count}" << 1 << "" << dr;
- QTest::newRow("js8") << "{append({'foo':{'prop':27}});set(0, {'foo':{'prop2':31}});get(0).foo.prop2}" << 31 << "" << dr;
-
- // Nested models
- QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "" << dr;
- QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "" << dr;
- QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "" << dr;
-
- QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << "" << dr;
- QTest::newRow("nested-set") << "{append({'foo':[{'x':1}]});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << "" << dr;
-
- QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << "" << dr;
- QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << "" << dr;
- }
-}
-
-void tst_qdeclarativelistmodel::dynamic()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
- QFETCH(bool, dynamicRoles);
-
- QQuickItem dummyItem0, dummyItem1;
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->setContextObject(&model);
- engine.rootContext()->setContextProperty("dummyItem0", QVariant::fromValue(&dummyItem0));
- engine.rootContext()->setContextProperty("dummyItem1", QVariant::fromValue(&dummyItem1));
- QDeclarativeExpression e(engine.rootContext(), &model, script);
- if (isValidErrorMessage(warning, dynamicRoles))
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QSignalSpy spyCount(&model, SIGNAL(countChanged()));
-
- int actual = e.evaluate().toInt();
- if (e.hasError())
- qDebug() << e.error(); // errors not expected
-
- QCOMPARE(actual,result);
-
- if (model.count() > 0)
- QVERIFY(spyCount.count() > 0);
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker_data()
-{
- dynamic_data();
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
- QFETCH(bool, dynamicRoles);
-
- if (QByteArray(QTest::currentDataTag()).startsWith("qobject"))
- return;
-
- // This is same as dynamic() except it applies the test to a ListModel called
- // from a WorkerScript.
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QSignalSpy spyCount(&model, SIGNAL(countChanged()));
-
- if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
- script = script.mid(1, script.length() - 2);
- QVariantList operations;
- foreach (const QString &s, script.split(';')) {
- if (!s.isEmpty())
- operations << s;
- }
-
- if (isValidErrorMessage(warning, dynamicRoles))
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations)));
- waitForWorker(item);
- QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result);
-
- if (model.count() > 0)
- QVERIFY(spyCount.count() > 0);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker_sync_data()
-{
- dynamic_data();
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker_sync()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
- QFETCH(bool, dynamicRoles);
-
- if (QByteArray(QTest::currentDataTag()).startsWith("qobject"))
- return;
-
- // This is the same as dynamic_worker() except that it executes a set of list operations
- // from the worker script, calls sync(), and tests the changes are reflected in the
- // list in the main thread
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
- script = script.mid(1, script.length() - 2);
- QVariantList operations;
- foreach (const QString &s, script.split(';')) {
- if (!s.isEmpty())
- operations << s;
- }
-
- if (isValidErrorMessage(warning, dynamicRoles))
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- // execute a set of commands on the worker list model, then check the
- // changes are reflected in the list model in the main thread
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
- waitForWorker(item);
-
- QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString());
- QCOMPARE(e.evaluate().toInt(), result);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::enumerate()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("enumerate.qml"));
- QVERIFY(!component.isError());
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item != 0);
-
- QLatin1String expectedStrings[] = {
- QLatin1String("val1=1Y"),
- QLatin1String("val2=2Y"),
- QLatin1String("val3=strY"),
- QLatin1String("val4=falseN"),
- QLatin1String("val5=trueY")
- };
-
- int expectedStringCount = sizeof(expectedStrings) / sizeof(expectedStrings[0]);
-
- QStringList r = item->property("result").toString().split(":");
-
- int matchCount = 0;
- for (int i=0 ; i < expectedStringCount ; ++i) {
- const QLatin1String &expectedString = expectedStrings[i];
-
- QStringList::const_iterator it = r.begin();
- QStringList::const_iterator end = r.end();
-
- while (it != end) {
- if (it->compare(expectedString) == 0) {
- ++matchCount;
- break;
- }
- ++it;
- }
- }
-
- QVERIFY(matchCount == expectedStringCount);
-
- delete item;
-}
-
-void tst_qdeclarativelistmodel::error_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("id not allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { id: fred } }"
- << "ListElement: cannot use reserved \"id\" property";
-
- QTest::newRow("id allowed in ListModel")
- << "import QtQuick 2.0\nListModel { id:model }"
- << "";
-
- QTest::newRow("random properties not allowed in ListModel")
- << "import QtQuick 2.0\nListModel { foo:123 }"
- << "ListModel: undefined property 'foo'";
-
- QTest::newRow("random properties allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { foo:123 } }"
- << "";
-
- QTest::newRow("bindings not allowed in ListElement")
- << "import QtQuick 2.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
- << "ListElement: cannot use script for property value";
-
- QTest::newRow("random object list properties allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
- << "";
-
- QTest::newRow("default properties not allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { Item { } } }"
- << "ListElement: cannot contain nested elements";
-
- QTest::newRow("QML elements not allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { a: Item { } } }"
- << "ListElement: cannot contain nested elements";
-
- QTest::newRow("qualified ListElement supported")
- << "import QtQuick 2.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }"
- << "";
-
- QTest::newRow("qualified ListElement required")
- << "import QtQuick 2.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }"
- << "ListElement is not a type";
-
- QTest::newRow("unknown qualified ListElement not allowed")
- << "import QtQuick 2.0\nListModel { Foo.ListElement { a: 123 } }"
- << "Foo.ListElement - Foo is not a namespace";
-}
-
-void tst_qdeclarativelistmodel::error()
-{
- QFETCH(QString, qml);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- if (error.isEmpty()) {
- QVERIFY(!component.isError());
- } else {
- QVERIFY(component.isError());
- QList<QDeclarativeError> errors = component.errors();
- QCOMPARE(errors.count(),1);
- QCOMPARE(errors.at(0).description(),error);
- }
-}
-
-void tst_qdeclarativelistmodel::syncError()
-{
- QString qml = "import QtQuick 2.0\nListModel { id: lm; Component.onCompleted: lm.sync() }";
- QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- QTest::ignoreMessage(QtWarningMsg,error.toUtf8());
- QObject *obj = component.create();
- QVERIFY(obj);
- delete obj;
-}
-
-/*
- Test model changes from set() are available to the view
-*/
-void tst_qdeclarativelistmodel::set_data()
-{
- QTest::addColumn<bool>("dynamicRoles");
-
- QTest::newRow("staticRoles") << false;
- QTest::newRow("dynamicRoles") << true;
-}
-
-void tst_qdeclarativelistmodel::set()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->setContextProperty("model", &model);
-
- RUNEXPR("model.append({test:false})");
- RUNEXPR("model.set(0, {test:true})");
-
- QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache
- QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true));
-
- RUNEXPR("model.set(0, {test:false})");
- QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated
- QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false));
-
- QString warning = QString::fromLatin1("<Unknown File>: Can't create role for unsupported data type");
- if (isValidErrorMessage(warning, dynamicRoles))
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
- QVariant invalidData = QColor();
- model.setProperty(0, "test", invalidData);
-}
-
-/*
- Test model changes on values returned by get() are available to the view
-*/
-void tst_qdeclarativelistmodel::get()
-{
- QFETCH(QString, expression);
- QFETCH(int, index);
- QFETCH(QString, roleName);
- QFETCH(QVariant, roleValue);
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "ListModel {}\n", QUrl());
- QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
- model->setDynamicRoles(dynamicRoles);
- engine.rootContext()->setContextProperty("model", model);
-
- RUNEXPR("model.append({roleA: 100})");
- RUNEXPR("model.append({roleA: 200, roleB: 400})");
- RUNEXPR("model.append({roleA: 200, roleB: 400})");
- RUNEXPR("model.append({roleC: {} })");
- RUNEXPR("model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })");
-
- QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
- QDeclarativeExpression expr(engine.rootContext(), model, expression);
- expr.evaluate();
- QVERIFY(!expr.hasError());
-
- int role = roleFromName(model, roleName);
- QVERIFY(role >= 0);
-
- if (roleValue.type() == QVariant::List) {
- const QVariantList &list = roleValue.toList();
- QVERIFY(compareVariantList(list, model->data(index, role)));
- } else {
- QCOMPARE(model->data(index, role), roleValue);
- }
-
- QCOMPARE(spy.count(), 1);
-
- QList<QVariant> spyResult = spy.takeFirst();
- QCOMPARE(spyResult.at(0).toInt(), index);
- QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
- QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::get_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<int>("index");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<QVariant>("roleValue");
- QTest::addColumn<bool>("dynamicRoles");
-
- for (int i=0 ; i < 2 ; ++i) {
- bool dr = (i != 0);
-
- QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500) << dr;
- QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500) << dr;
-
- QVariantMap map;
- QVariantList list;
- map.clear(); map["a"] = 50; map["b"] = 500;
- list << map;
- map.clear(); map["c"] = 1000;
- list << map;
- QTest::newRow("list of objects") << "get(2).roleD = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleD" << QVariant::fromValue(list) << dr;
- }
-}
-
-void tst_qdeclarativelistmodel::get_worker()
-{
- QFETCH(QString, expression);
- QFETCH(int, index);
- QFETCH(QString, roleName);
- QFETCH(QVariant, roleValue);
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- // Add some values like get() test
- RUNEVAL(item, "model.append({roleA: 100})");
- RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
- RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
- RUNEVAL(item, "model.append({roleC: {} })");
- RUNEVAL(item, "model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })");
-
- int role = roleFromName(&model, roleName);
- QVERIFY(role >= 0);
-
- QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
-
- // in the worker thread, change the model data and call sync()
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, QStringList(expression))));
- waitForWorker(item);
-
- // see if we receive the model changes in the main thread's model
- if (roleValue.type() == QVariant::List) {
- const QVariantList &list = roleValue.toList();
- QVERIFY(compareVariantList(list, model.data(index, role)));
- } else {
- QCOMPARE(model.data(index, role), roleValue);
- }
-
- QCOMPARE(spy.count(), 1);
-
- QList<QVariant> spyResult = spy.takeFirst();
- QCOMPARE(spyResult.at(0).toInt(), index);
- QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
- QVERIFY(spyResult.at(2).value<QList<int> >().contains(role));
-}
-
-void tst_qdeclarativelistmodel::get_worker_data()
-{
- get_data();
-}
-
-/*
- Test that the tests run in get() also work for nested list data
-*/
-void tst_qdeclarativelistmodel::get_nested()
-{
- QFETCH(QString, expression);
- QFETCH(int, index);
- QFETCH(QString, roleName);
- QFETCH(QVariant, roleValue);
- QFETCH(bool, dynamicRoles);
-
- if (roleValue.type() == QVariant::Map)
- return;
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "ListModel {}", QUrl());
- QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
- model->setDynamicRoles(dynamicRoles);
- QVERIFY(component.errorString().isEmpty());
- QDeclarativeListModel *childModel;
- engine.rootContext()->setContextProperty("model", model);
-
- RUNEXPR("model.append({ listRoleA: [\n"
- "{ roleA: 100 },\n"
- "{ roleA: 200, roleB: 400 },\n"
- "{ roleA: 200, roleB: 400 }, \n"
- "{ roleC: {} }, \n"
- "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
- "] })\n");
-
- RUNEXPR("model.append({ listRoleA: [\n"
- "{ roleA: 100 },\n"
- "{ roleA: 200, roleB: 400 },\n"
- "{ roleA: 200, roleB: 400 }, \n"
- "{ roleC: {} }, \n"
- "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
- "],\n"
- "listRoleB: [\n"
- "{ roleA: 100 },\n"
- "{ roleA: 200, roleB: 400 },\n"
- "{ roleA: 200, roleB: 400 }, \n"
- "{ roleC: {} }, \n"
- "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
- "],\n"
- "listRoleC: [\n"
- "{ roleA: 100 },\n"
- "{ roleA: 200, roleB: 400 },\n"
- "{ roleA: 200, roleB: 400 }, \n"
- "{ roleC: {} }, \n"
- "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
- "] })\n");
-
- // Test setting the inner list data for:
- // get(0).listRoleA
- // get(1).listRoleA
- // get(1).listRoleB
- // get(1).listRoleC
-
- QList<QPair<int, QString> > testData;
- testData << qMakePair(0, QString("listRoleA"));
- testData << qMakePair(1, QString("listRoleA"));
- testData << qMakePair(1, QString("listRoleB"));
- testData << qMakePair(1, QString("listRoleC"));
-
- for (int i=0; i<testData.count(); i++) {
- int outerListIndex = testData[i].first;
- QString outerListRoleName = testData[i].second;
- int outerListRole = roleFromName(model, outerListRoleName);
- QVERIFY(outerListRole >= 0);
-
- childModel = qobject_cast<QDeclarativeListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>());
- QVERIFY(childModel);
-
- QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression);
- QDeclarativeExpression expr(engine.rootContext(), model, extendedExpression);
-
- QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList<int>)));
- expr.evaluate();
- QVERIFY(!expr.hasError());
-
- int role = roleFromName(childModel, roleName);
- QVERIFY(role >= 0);
- if (roleValue.type() == QVariant::List) {
- QVERIFY(compareVariantList(roleValue.toList(), childModel->data(index, role)));
- } else {
- QCOMPARE(childModel->data(index, role), roleValue);
- }
- QCOMPARE(spy.count(), 1);
-
- QList<QVariant> spyResult = spy.takeFirst();
- QCOMPARE(spyResult.at(0).toInt(), index);
- QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
- QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
- }
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::get_nested_data()
-{
- get_data();
-}
-
-//QTBUG-13754
-void tst_qdeclarativelistmodel::crash_model_with_multiple_roles()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("multipleroles.qml"));
- QObject *rootItem = component.create();
- QVERIFY(component.errorString().isEmpty());
- QVERIFY(rootItem != 0);
- QDeclarativeListModel *model = rootItem->findChild<QDeclarativeListModel*>("listModel");
- QVERIFY(model != 0);
-
- // used to cause a crash in QDeclarativeVisualDataModel
- model->setProperty(0, "black", true);
-
- delete rootItem;
-}
-
-//QTBUG-15190
-void tst_qdeclarativelistmodel::set_model_cache()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("setmodelcachelist.qml"));
- QObject *model = component.create();
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
- QVERIFY(model != 0);
- QVERIFY(model->property("ok").toBool());
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::property_changes()
-{
- QFETCH(QString, script_setup);
- QFETCH(QString, script_change);
- QFETCH(QString, roleName);
- QFETCH(int, listIndex);
- QFETCH(bool, itemsChanged);
- QFETCH(QString, testExpression);
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine::setContextForObject(&model, engine.rootContext());
- engine.rootContext()->setContextObject(&model);
-
- QDeclarativeExpression expr(engine.rootContext(), &model, script_setup);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
-
- QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:";
- QString qml = "import QtQuick 2.0\n"
- "Connections {\n"
- "property bool gotSignal: false\n"
- "target: model.get(" + QString::number(listIndex) + ")\n"
- + signalHandler + " gotSignal = true\n"
- "}\n";
-
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(), QUrl::fromLocalFile(""));
- engine.rootContext()->setContextProperty("model", &model);
- QObject *connectionsObject = component.create();
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
-
- QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
-
- expr.setExpression(script_change);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error()));
-
- // test the object returned by get() emits the correct signals
- QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged);
-
- // test itemsChanged() is emitted correctly
- if (itemsChanged) {
- QCOMPARE(spyItemsChanged.count(), 1);
- QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
- QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
- } else {
- QCOMPARE(spyItemsChanged.count(), 0);
- }
-
- expr.setExpression(testExpression);
- QCOMPARE(expr.evaluate().toBool(), true);
-
- delete connectionsObject;
-}
-
-void tst_qdeclarativelistmodel::property_changes_data()
-{
- QTest::addColumn<QString>("script_setup");
- QTest::addColumn<QString>("script_change");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<int>("listIndex");
- QTest::addColumn<bool>("itemsChanged");
- QTest::addColumn<QString>("testExpression");
- QTest::addColumn<bool>("dynamicRoles");
-
- for (int i=0 ; i < 2 ; ++i) {
- bool dr = (i != 0);
-
- QTest::newRow("set: plain") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':123});"
- << "b" << 0 << true << "get(0).b == 123" << dr;
- QTest::newRow("setProperty: plain") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 123);"
- << "b" << 0 << true << "get(0).b == 123" << dr;
-
- QTest::newRow("set: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':456});"
- << "b" << 0 << false << "get(0).b == 456" << dr;
- QTest::newRow("setProperty: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 456);"
- << "b" << 0 << false << "get(0).b == 456" << dr;
-
- QTest::newRow("set: inserted item")
- << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
- << "set(1, {'a':456});"
- << "a" << 1 << true << "get(1).a == 456" << dr;
- QTest::newRow("setProperty: inserted item")
- << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
- << "setProperty(1, 'a', 456);"
- << "a" << 1 << true << "get(1).a == 456" << dr;
- QTest::newRow("get: inserted item")
- << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
- << "get(1).a = 456;"
- << "a" << 1 << true << "get(1).a == 456" << dr;
- QTest::newRow("set: removed item")
- << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
- << "set(0, {'a':456});"
- << "a" << 0 << true << "get(0).a == 456" << dr;
- QTest::newRow("setProperty: removed item")
- << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
- << "setProperty(0, 'a', 456);"
- << "a" << 0 << true << "get(0).a == 456" << dr;
- QTest::newRow("get: removed item")
- << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
- << "get(0).a = 456;"
- << "a" << 0 << true << "get(0).a == 456" << dr;
-
- // Following tests only call set() since setProperty() only allows plain
- // values, not lists, as the argument.
- // Note that when a list is changed, itemsChanged() is currently always
- // emitted regardless of whether it actually changed or not.
-
- QTest::newRow("nested-set: list, new size") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2" << dr;
-
- QTest::newRow("nested-set: list, empty -> non-empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr;
-
- QTest::newRow("nested-set: list, non-empty -> empty") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[]});"
- << "b" << 0 << true << "get(0).b.count == 0" << dr;
-
- QTest::newRow("nested-set: list, same size, different values") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':222},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 222 && get(0).b.get(2).a == 3" << dr;
-
- QTest::newRow("nested-set: list, no changes") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr;
-
- QTest::newRow("nested-set: list, no changes, empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[]});"
- << "b" << 0 << true << "get(0).b.count == 0" << dr;
- }
-}
-
-void tst_qdeclarativelistmodel::property_changes_worker()
-{
- QFETCH(QString, script_setup);
- QFETCH(QString, script_change);
- QFETCH(QString, roleName);
- QFETCH(int, listIndex);
- QFETCH(bool, itemsChanged);
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
- QQuickItem *item = createWorkerTest(&engine, &component, &model);
- QVERIFY(item != 0);
-
- QDeclarativeExpression expr(engine.rootContext(), &model, script_setup);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
-
- QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, QStringList(script_change))));
- waitForWorker(item);
-
- // test itemsChanged() is emitted correctly
- if (itemsChanged) {
- QCOMPARE(spyItemsChanged.count(), 1);
- QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
- QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
- } else {
- QCOMPARE(spyItemsChanged.count(), 0);
- }
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::property_changes_worker_data()
-{
- property_changes_data();
-}
-
-void tst_qdeclarativelistmodel::clear_data()
-{
- QTest::addColumn<bool>("dynamicRoles");
-
- QTest::newRow("staticRoles") << false;
- QTest::newRow("dynamicRoles") << true;
-}
-
-void tst_qdeclarativelistmodel::clear()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine::setContextForObject(&model, engine.rootContext());
- engine.rootContext()->setContextProperty("model", &model);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- QCOMPARE(model.count(), 1);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- QCOMPARE(model.count(), 2);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- // clearing does not remove the roles
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})");
- QList<int> roles = model.roles();
- model.clear();
- QCOMPARE(model.count(), 0);
- QCOMPARE(model.roles(), roles);
- QCOMPARE(model.toString(roles[0]), QString("propertyA"));
- QCOMPARE(model.toString(roles[1]), QString("propertyB"));
- QCOMPARE(model.toString(roles[2]), QString("propertyC"));
-}
-
-void tst_qdeclarativelistmodel::signal_handlers_data()
-{
- QTest::addColumn<bool>("dynamicRoles");
-
- QTest::newRow("staticRoles") << false;
- QTest::newRow("dynamicRoles") << true;
-}
-
-void tst_qdeclarativelistmodel::signal_handlers()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("signalhandlers.qml"));
- QObject *model = component.create();
- QDeclarativeListModel *lm = qobject_cast<QDeclarativeListModel *>(model);
- QVERIFY(lm != 0);
- lm->setDynamicRoles(dynamicRoles);
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
- QVERIFY(model != 0);
- QVERIFY(model->property("ok").toBool());
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::worker_sync_data()
-{
- QTest::addColumn<bool>("dynamicRoles");
-
- QTest::newRow("staticRoles") << false;
- QTest::newRow("dynamicRoles") << true;
-}
-
-void tst_qdeclarativelistmodel::worker_sync()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("workersync.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QVERIFY(model.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItem0"));
-
- QVERIFY(model.count() == 2);
- QVariant childData = model.data(0, 0);
- QDeclarativeListModel *childModel = qobject_cast<QDeclarativeListModel *>(childData.value<QObject *>());
- QVERIFY(childModel);
- QVERIFY(childModel->count() == 1);
-
- QSignalSpy spyModelInserted(&model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyChildInserted(childModel, SIGNAL(itemsInserted(int,int)));
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 2);
- QVERIFY(childModel->count() == 1);
- QVERIFY(spyModelInserted.count() == 0);
- QVERIFY(spyChildInserted.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 2);
- QVERIFY(childModel->count() == 2);
- QVERIFY(spyModelInserted.count() == 0);
- QVERIFY(spyChildInserted.count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 2);
- QVERIFY(childModel->count() == 2);
- QVERIFY(spyModelInserted.count() == 0);
- QVERIFY(spyChildInserted.count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 2);
- QVERIFY(childModel->count() == 3);
- QVERIFY(spyModelInserted.count() == 0);
- QVERIFY(spyChildInserted.count() == 2);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::worker_remove_element_data()
-{
- worker_sync_data();
-}
-
-void tst_qdeclarativelistmodel::worker_remove_element()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("workerremoveelement.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int)));
-
- QVERIFY(model.count() == 0);
- QVERIFY(spyModelRemoved.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
-
- QVERIFY(model.count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 1);
- QVERIFY(spyModelRemoved.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 0);
- QVERIFY(spyModelRemoved.count() == 1);
-
- delete item;
- qApp->processEvents();
-
- {
- //don't crash if model was deleted earlier
- QDeclarativeListModel* model = new QDeclarativeListModel;
- model->setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("workerremoveelement.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, model);
- QVERIFY(item != 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
-
- QVERIFY(model->count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker"));
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- delete model;
- qApp->processEvents(); //must not crash here
- waitForWorker(item);
-
- delete item;
- }
-}
-
-void tst_qdeclarativelistmodel::worker_remove_list_data()
-{
- worker_sync_data();
-}
-
-void tst_qdeclarativelistmodel::worker_remove_list()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("workerremovelist.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int)));
-
- QVERIFY(model.count() == 0);
- QVERIFY(spyModelRemoved.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addList"));
-
- QVERIFY(model.count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "removeListViaWorker"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 1);
- QVERIFY(spyModelRemoved.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 0);
- QVERIFY(spyModelRemoved.count() == 1);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::role_mode_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
- QTest::addColumn<QString>("warning");
-
- QTest::newRow("default0") << "{dynamicRoles}" << 0 << "";
- QTest::newRow("default1") << "{append({'a':1});dynamicRoles}" << 0 << "";
-
- QTest::newRow("enableDynamic0") << "{dynamicRoles=true;dynamicRoles}" << 1 << "";
- QTest::newRow("enableDynamic1") << "{append({'a':1});dynamicRoles=true;dynamicRoles}" << 0 << "<Unknown File>: QML ListModel: unable to enable dynamic roles as this model is not empty!";
- QTest::newRow("enableDynamic2") << "{dynamicRoles=true;append({'a':1});dynamicRoles=false;dynamicRoles}" << 1 << "<Unknown File>: QML ListModel: unable to enable static roles as this model is not empty!";
-}
-
-void tst_qdeclarativelistmodel::role_mode()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
-
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->setContextObject(&model);
- QDeclarativeExpression e(engine.rootContext(), &model, script);
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- int actual = e.evaluate().toInt();
- if (e.hasError())
- qDebug() << e.error(); // errors not expected
-
- QCOMPARE(actual,result);
-}
-
-void tst_qdeclarativelistmodel::dynamic_role_data()
-{
- QTest::addColumn<QString>("preamble");
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
-
- QTest::newRow("sync1") << "{append({'a':[{'b':1},{'b':2}]})}" << "{get(0).a = 'string';count}" << 1;
-}
-
-void tst_qdeclarativelistmodel::dynamic_role()
-{
- QFETCH(QString, preamble);
- QFETCH(QString, script);
- QFETCH(int, result);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(true);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QQuickItem *item = createWorkerTest(&engine, &component, &model);
- QVERIFY(item != 0);
-
- QDeclarativeExpression preExp(engine.rootContext(), &model, preamble);
- QCOMPARE(preExp.evaluate().toInt(), 0);
-
- if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
- script = script.mid(1, script.length() - 2);
- QVariantList operations;
- foreach (const QString &s, script.split(';')) {
- if (!s.isEmpty())
- operations << s;
- }
-
- // execute a set of commands on the worker list model, then check the
- // changes are reflected in the list model in the main thread
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
- waitForWorker(item);
-
- QDeclarativeExpression e(engine.rootContext(), &model, operations.last().toString());
- QCOMPARE(e.evaluate().toInt(), result);
-
- delete item;
- qApp->processEvents();
-}
-
-QTEST_MAIN(tst_qdeclarativelistmodel)
-
-#include "tst_qdeclarativelistmodel.moc"
diff --git a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
deleted file mode 100644
index 7900f3c554..0000000000
--- a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelistreference
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelistreference.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp
deleted file mode 100644
index bfd2ea2f42..0000000000
--- a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp
+++ /dev/null
@@ -1,570 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QUrl>
-#include <QFileInfo>
-#include <QDir>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeprivate.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QDebug>
-#include "../../shared/util.h"
-
-class tst_qdeclarativelistreference : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativelistreference() {}
-
-private slots:
- void initTestCase();
- void qmllistreference();
- void qmllistreference_invalid();
- void isValid();
- void object();
- void listElementType();
- void canAppend();
- void canAt();
- void canClear();
- void canCount();
- void append();
- void at();
- void clear();
- void count();
- void copy();
- void qmlmetaproperty();
- void engineTypes();
- void variantToList();
-};
-
-class TestType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<TestType> data READ dataProperty)
- Q_PROPERTY(int intProperty READ intProperty)
-
-public:
- TestType() : property(this, data) {}
- QDeclarativeListProperty<TestType> dataProperty() { return property; }
- int intProperty() const { return 10; }
-
- QList<TestType *> data;
- QDeclarativeListProperty<TestType> property;
-};
-
-void tst_qdeclarativelistreference::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<TestType>();
-}
-
-void tst_qdeclarativelistreference::qmllistreference()
-{
- TestType tt;
-
- QDeclarativeListReference r(&tt, "data");
- QVERIFY(r.isValid() == true);
- QCOMPARE(r.count(), 0);
-
- tt.data.append(&tt);
- QCOMPARE(r.count(), 1);
-}
-
-void tst_qdeclarativelistreference::qmllistreference_invalid()
-{
- TestType tt;
-
- // Invalid
- {
- QDeclarativeListReference r;
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-
- // Non-property
- {
- QDeclarativeListReference r(&tt, "blah");
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-
- // Non-list property
- {
- QDeclarativeListReference r(&tt, "intProperty");
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-}
-
-void tst_qdeclarativelistreference::isValid()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.isValid() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.isValid() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.isValid() == true);
- delete tt;
- QVERIFY(ref.isValid() == false);
- }
-}
-
-void tst_qdeclarativelistreference::object()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.object() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.object() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.object() == tt);
- delete tt;
- QVERIFY(ref.object() == 0);
- }
-}
-
-void tst_qdeclarativelistreference::listElementType()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.listElementType() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.listElementType() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
- delete tt;
- QVERIFY(ref.listElementType() == 0);
- }
-}
-
-void tst_qdeclarativelistreference::canAppend()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.canAppend() == true);
- delete tt;
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- TestType tt;
- tt.property.append = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.canAppend() == false);
- }
-}
-
-void tst_qdeclarativelistreference::canAt()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.canAt() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.canAt() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.canAt() == true);
- delete tt;
- QVERIFY(ref.canAt() == false);
- }
-
- {
- TestType tt;
- tt.property.at = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.canAt() == false);
- }
-}
-
-void tst_qdeclarativelistreference::canClear()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.canClear() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.canClear() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.canClear() == true);
- delete tt;
- QVERIFY(ref.canClear() == false);
- }
-
- {
- TestType tt;
- tt.property.clear = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.canClear() == false);
- }
-}
-
-void tst_qdeclarativelistreference::canCount()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.canCount() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.canCount() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.canCount() == true);
- delete tt;
- QVERIFY(ref.canCount() == false);
- }
-
- {
- TestType tt;
- tt.property.count = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.canCount() == false);
- }
-}
-
-void tst_qdeclarativelistreference::append()
-{
- TestType *tt = new TestType;
- QObject object;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.append(tt) == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.append(tt) == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.append(tt) == true);
- QVERIFY(tt->data.count() == 1);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(ref.append(&object) == false);
- QVERIFY(tt->data.count() == 1);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(ref.append(0) == true);
- QVERIFY(tt->data.count() == 2);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(tt->data.at(1) == 0);
- delete tt;
- QVERIFY(ref.append(0) == false);
- }
-
- {
- TestType tt;
- tt.property.append = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.append(&tt) == false);
- }
-}
-
-void tst_qdeclarativelistreference::at()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.at(0) == tt);
- QVERIFY(ref.at(1) == 0);
- QVERIFY(ref.at(2) == tt);
- delete tt;
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- TestType tt;
- tt.data.append(&tt);
- tt.property.at = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.at(0) == 0);
- }
-}
-
-void tst_qdeclarativelistreference::clear()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.clear() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.clear() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.clear() == true);
- QVERIFY(tt->data.count() == 0);
- delete tt;
- QVERIFY(ref.clear() == false);
- }
-
- {
- TestType tt;
- tt.property.clear = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.clear() == false);
- }
-}
-
-void tst_qdeclarativelistreference::count()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.count() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.count() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.count() == 3);
- tt->data.removeAt(1);
- QVERIFY(ref.count() == 2);
- delete tt;
- QVERIFY(ref.count() == 0);
- }
-
- {
- TestType tt;
- tt.data.append(&tt);
- tt.property.count = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.count() == 0);
- }
-}
-
-void tst_qdeclarativelistreference::copy()
-{
- TestType tt;
- tt.data.append(&tt);
- tt.data.append(0);
- tt.data.append(&tt);
-
- QDeclarativeListReference *r1 = new QDeclarativeListReference(&tt, "data");
- QVERIFY(r1->count() == 3);
-
- QDeclarativeListReference r2(*r1);
- QDeclarativeListReference r3;
- r3 = *r1;
-
- QVERIFY(r2.count() == 3);
- QVERIFY(r3.count() == 3);
-
- delete r1;
-
- QVERIFY(r2.count() == 3);
- QVERIFY(r3.count() == 3);
-
- tt.data.removeAt(2);
-
- QVERIFY(r2.count() == 2);
- QVERIFY(r3.count() == 2);
-}
-
-void tst_qdeclarativelistreference::qmlmetaproperty()
-{
- TestType tt;
- tt.data.append(&tt);
- tt.data.append(0);
- tt.data.append(&tt);
-
- QDeclarativeProperty prop(&tt, QLatin1String("data"));
- QVariant v = prop.read();
- QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
- QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
- QVERIFY(ref.count() == 3);
- QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
-}
-
-void tst_qdeclarativelistreference::engineTypes()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("engineTypes.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
-
- QDeclarativeProperty p1(o, QLatin1String("myList"));
- QVERIFY(p1.propertyTypeCategory() == QDeclarativeProperty::Normal);
-
- QDeclarativeProperty p2(o, QLatin1String("myList"), engine.rootContext());
- QVERIFY(p2.propertyTypeCategory() == QDeclarativeProperty::List);
- QVariant v = p2.read();
- QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
- QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
- QVERIFY(ref.count() == 2);
- QVERIFY(ref.listElementType());
- QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
-
- delete o;
-}
-
-void tst_qdeclarativelistreference::variantToList()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("variantToList.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
-
- QVERIFY(o->property("value").userType() == qMetaTypeId<QDeclarativeListReference>());
- QCOMPARE(o->property("test").toInt(), 1);
-
- delete o;
-}
-
-QTEST_MAIN(tst_qdeclarativelistreference)
-
-#include "tst_qdeclarativelistreference.moc"
diff --git a/tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro b/tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro
deleted file mode 100644
index 75ff0e9504..0000000000
--- a/tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelocale
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelocale.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += declarative testlib
diff --git a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
deleted file mode 100644
index 7d86ad9148..0000000000
--- a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
+++ /dev/null
@@ -1,1219 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QDebug>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtCore/QDateTime>
-#include <qcolor.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativelocale : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativelocale() { }
-
-private slots:
- void defaultLocale();
-
- void properties_data();
- void properties();
- void currencySymbol_data();
- void currencySymbol();
- void monthName_data();
- void monthName();
- void standaloneMonthName_data();
- void standaloneMonthName();
- void dayName_data();
- void dayName();
- void standaloneDayName_data();
- void standaloneDayName();
- void firstDayOfWeek_data();
- void firstDayOfWeek();
- void weekDays_data();
- void weekDays();
- void uiLanguages_data();
- void uiLanguages();
- void dateFormat_data();
- void dateFormat();
- void dateTimeFormat_data();
- void dateTimeFormat();
- void timeFormat_data();
- void timeFormat();
-
- void dateToLocaleString_data();
- void dateToLocaleString();
- void dateToLocaleStringFormatted_data();
- void dateToLocaleStringFormatted();
- void dateToLocaleDateString_data();
- void dateToLocaleDateString();
- void dateToLocaleDateStringFormatted_data();
- void dateToLocaleDateStringFormatted();
- void dateToLocaleTimeString_data();
- void dateToLocaleTimeString();
- void dateToLocaleTimeStringFormatted_data();
- void dateToLocaleTimeStringFormatted();
- void dateFromLocaleString_data();
- void dateFromLocaleString();
- void dateFromLocaleDateString_data();
- void dateFromLocaleDateString();
- void dateFromLocaleTimeString_data();
- void dateFromLocaleTimeString();
-
- void numberToLocaleString_data();
- void numberToLocaleString();
- void numberToLocaleCurrencyString_data();
- void numberToLocaleCurrencyString();
- void numberFromLocaleString_data();
- void numberFromLocaleString();
- void numberConstToLocaleString();
-
- void stringLocaleCompare_data();
- void stringLocaleCompare();
-
-private:
- void addPropertyData(const QString &l);
- QVariant getProperty(QObject *obj, const QString &locale, const QString &property);
- void addCurrencySymbolData(const QString &locale);
- void addStandardFormatData();
- void addFormatNameData(const QString &locale);
- void addDateTimeFormatData(const QString &l);
- void addDateFormatData(const QString &l);
- void addTimeFormatData(const QString &l);
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativelocale::defaultLocale()
-{
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QCOMPARE(obj->property("name").toString(), QLocale().name());
-}
-
-#define LOCALE_PROP(type,prop) { #prop, QVariant(type(qlocale.prop())) }
-
-void tst_qdeclarativelocale::addPropertyData(const QString &l)
-{
- QLocale qlocale(l);
-
- struct {
- const char *name;
- QVariant value;
- }
- values[] = {
- LOCALE_PROP(QString,name),
- LOCALE_PROP(QString,amText),
- LOCALE_PROP(QString,pmText),
- LOCALE_PROP(QString,nativeLanguageName),
- LOCALE_PROP(QString,nativeCountryName),
- LOCALE_PROP(QString,decimalPoint),
- LOCALE_PROP(QString,groupSeparator),
- LOCALE_PROP(QString,percent),
- LOCALE_PROP(QString,zeroDigit),
- LOCALE_PROP(QString,negativeSign),
- LOCALE_PROP(QString,positiveSign),
- LOCALE_PROP(QString,exponential),
- LOCALE_PROP(int,measurementSystem),
- LOCALE_PROP(int,textDirection),
- { 0, QVariant() }
- };
-
- int i = 0;
- while (values[i].name) {
- QByteArray n = l.toLatin1() + ':' + values[i].name;
- QTest::newRow(n.constData()) << l << QByteArray(values[i].name) << values[i].value;
- ++i;
- }
-}
-
-void tst_qdeclarativelocale::properties_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QByteArray>("property");
- QTest::addColumn<QVariant>("value");
-
- addPropertyData("en_US");
- addPropertyData("de_DE");
- addPropertyData("ar_SA");
- addPropertyData("hi_IN");
- addPropertyData("zh_CN");
- addPropertyData("th_TH");
-}
-
-void tst_qdeclarativelocale::properties()
-{
- QFETCH(QString, locale);
- QFETCH(QByteArray, property);
- QFETCH(QVariant, value);
-
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QCOMPARE(obj->property(property), value);
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::addCurrencySymbolData(const QString &l)
-{
- QByteArray locale = l.toLatin1();
- QTest::newRow(locale.constData()) << l << -1;
- QByteArray t(locale);
- t += " CurrencyIsoCode";
- QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyIsoCode;
- t = locale + " CurrencySymbol";
- QTest::newRow(t.constData()) << l << (int)QLocale::CurrencySymbol;
- t = locale + " CurrencyDisplayName";
- QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyDisplayName;
-}
-
-void tst_qdeclarativelocale::currencySymbol_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<int>("param");
-
- addCurrencySymbolData("en_US");
- addCurrencySymbolData("de_DE");
- addCurrencySymbolData("ar_SA");
- addCurrencySymbolData("hi_IN");
- addCurrencySymbolData("zh_CN");
- addCurrencySymbolData("th_TH");
-}
-
-void tst_qdeclarativelocale::currencySymbol()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol;
-
- if (param >= 0)
- format = QLocale::CurrencySymbolFormat(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QMetaObject::invokeMethod(obj, "currencySymbol", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(int(format))));
-
- QCOMPARE(val.toString(), l.currencySymbol(format));
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::addFormatNameData(const QString &l)
-{
- QByteArray locale = l.toLatin1();
- QTest::newRow(locale.constData()) << l << -1;
- QByteArray t(locale);
- t += " LongFormat";
- QTest::newRow(t.constData()) << l << (int)QLocale::LongFormat;
- t = locale + " ShortFormat";
- QTest::newRow(t.constData()) << l << (int)QLocale::ShortFormat;
- t = locale + " NarrowFormat";
- QTest::newRow(t.constData()) << l << (int)QLocale::NarrowFormat;
-}
-
-void tst_qdeclarativelocale::addStandardFormatData()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<int>("param");
-
- addFormatNameData("en_US");
- addFormatNameData("de_DE");
- addFormatNameData("ar_SA");
- addFormatNameData("hi_IN");
- addFormatNameData("zh_CN");
- addFormatNameData("th_TH");
-}
-
-void tst_qdeclarativelocale::monthName_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::monthName()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::FormatType format = QLocale::LongFormat;
- if (param >= 0)
- format = QLocale::FormatType(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- for (int i = 0; i <= 11; ++i) {
- QMetaObject::invokeMethod(obj, "monthName", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(i)),
- Q_ARG(QVariant, QVariant(int(format))));
-
- // QLocale January == 1, JS Date January == 0
- QCOMPARE(val.toString(), l.monthName(i+1, format));
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::standaloneMonthName_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::standaloneMonthName()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::FormatType format = QLocale::LongFormat;
- if (param >= 0)
- format = QLocale::FormatType(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- for (int i = 0; i <= 11; ++i) {
- QMetaObject::invokeMethod(obj, "standaloneMonthName", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(i)),
- Q_ARG(QVariant, QVariant(int(format))));
-
- // QLocale January == 1, JS Date January == 0
- QCOMPARE(val.toString(), l.standaloneMonthName(i+1, format));
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::dayName_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dayName()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::FormatType format = QLocale::LongFormat;
- if (param >= 0)
- format = QLocale::FormatType(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- for (int i = 1; i <= 7; ++i) {
- QMetaObject::invokeMethod(obj, "dayName", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(i)),
- Q_ARG(QVariant, QVariant(int(format))));
-
- QCOMPARE(val.toString(), l.dayName(i, format));
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::standaloneDayName_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::standaloneDayName()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- for (int i = 1; i <= 7; ++i) {
- QMetaObject::invokeMethod(obj, "standaloneDayName", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(i)),
- Q_ARG(QVariant, QVariant(int(format))));
-
- QCOMPARE(val.toString(), l.standaloneDayName(i, format));
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::firstDayOfWeek_data()
-{
- QTest::addColumn<QString>("locale");
-
- QTest::newRow("en_US") << "en_US";
- QTest::newRow("de_DE") << "de_DE";
- QTest::newRow("ar_SA") << "ar_SA";
- QTest::newRow("hi_IN") << "hi_IN";
- QTest::newRow("zh_CN") << "zh_CN";
- QTest::newRow("th_TH") << "th_TH";
-}
-
-void tst_qdeclarativelocale::firstDayOfWeek()
-{
- QFETCH(QString, locale);
-
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val = obj->property("firstDayOfWeek");
- QVERIFY(val.type() == QVariant::Int);
-
- int day = int(QLocale(locale).firstDayOfWeek());
- if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
- day = 0;
- QCOMPARE(day, val.toInt());
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::weekDays_data()
-{
- QTest::addColumn<QString>("locale");
-
- QTest::newRow("en_US") << "en_US";
- QTest::newRow("de_DE") << "de_DE";
- QTest::newRow("ar_SA") << "ar_SA";
- QTest::newRow("hi_IN") << "hi_IN";
- QTest::newRow("zh_CN") << "zh_CN";
- QTest::newRow("th_TH") << "th_TH";
-}
-
-void tst_qdeclarativelocale::weekDays()
-{
- QFETCH(QString, locale);
-
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val = obj->property("weekDays");
- QVERIFY(val.type() == QVariant::List);
-
- QList<QVariant> qmlDays = val.toList();
- QList<Qt::DayOfWeek> days = QLocale(locale).weekdays();
-
- QVERIFY(days.count() == qmlDays.count());
-
- for (int i = 0; i < days.count(); ++i) {
- int day = int(days.at(i));
- if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
- day = 0;
- QCOMPARE(day, qmlDays.at(i).toInt());
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::uiLanguages_data()
-{
- QTest::addColumn<QString>("locale");
-
- QTest::newRow("en_US") << "en_US";
- QTest::newRow("de_DE") << "de_DE";
- QTest::newRow("ar_SA") << "ar_SA";
- QTest::newRow("hi_IN") << "hi_IN";
- QTest::newRow("zh_CN") << "zh_CN";
- QTest::newRow("th_TH") << "th_TH";
-}
-
-void tst_qdeclarativelocale::uiLanguages()
-{
- QFETCH(QString, locale);
-
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val = obj->property("uiLanguages");
- QVERIFY(val.type() == QVariant::List);
-
- QList<QVariant> qmlLangs = val.toList();
- QStringList langs = QLocale(locale).uiLanguages();
-
- QVERIFY(langs.count() == qmlLangs.count());
-
- for (int i = 0; i < langs.count(); ++i) {
- QCOMPARE(langs.at(i), qmlLangs.at(i).toString());
- }
-
- delete obj;
-}
-
-
-void tst_qdeclarativelocale::dateTimeFormat_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateTimeFormat()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
- QMetaObject::invokeMethod(obj, "dateTimeFormat", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QCOMPARE(val.toString(), l.dateTimeFormat(format));
-}
-
-void tst_qdeclarativelocale::dateFormat_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateFormat()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
- QMetaObject::invokeMethod(obj, "dateFormat", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QCOMPARE(val.toString(), l.dateFormat(format));
-}
-
-void tst_qdeclarativelocale::timeFormat_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::timeFormat()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
- QMetaObject::invokeMethod(obj, "timeFormat", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QCOMPARE(val.toString(), l.timeFormat(format));
-}
-
-void tst_qdeclarativelocale::dateToLocaleString_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateToLocaleString()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt, format));
-}
-
-void tst_qdeclarativelocale::addDateTimeFormatData(const QString &l)
-{
- const char *formats[] = {
- "hh:mm dd.MM.yyyy",
- "h:m:sap ddd MMMM d yy",
- "'The date and time is: 'H:mm:ss:zzz dd/MM/yy",
- "MMM d yyyy HH:mm t",
- 0
- };
- QByteArray locale = l.toLatin1();
- int i = 0;
- while (formats[i]) {
- QByteArray t(locale);
- t += " ";
- t += formats[i];
- QTest::newRow(t.constData()) << l << QString(formats[i]);
- ++i;
- }
-}
-
-void tst_qdeclarativelocale::dateToLocaleStringFormatted_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- addDateTimeFormatData("en_US");
- addDateTimeFormatData("de_DE");
- addDateTimeFormatData("ar_SA");
- addDateTimeFormatData("hi_IN");
- addDateTimeFormatData("zh_CN");
- addDateTimeFormatData("th_TH");
-}
-
-void tst_qdeclarativelocale::dateToLocaleStringFormatted()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(format)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt, format));
-}
-
-void tst_qdeclarativelocale::dateToLocaleDateString_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateToLocaleDateString()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleDateString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt.date(), format));
-}
-
-void tst_qdeclarativelocale::addDateFormatData(const QString &l)
-{
- const char *formats[] = {
- "dd.MM.yyyy",
- "ddd MMMM d yy",
- "'The date is: 'dd/MM/yy",
- "MMM d yyyy",
- 0
- };
- QByteArray locale = l.toLatin1();
- int i = 0;
- while (formats[i]) {
- QByteArray t(locale);
- t += " ";
- t += formats[i];
- QTest::newRow(t.constData()) << l << QString(formats[i]);
- ++i;
- }
-}
-
-void tst_qdeclarativelocale::dateToLocaleDateStringFormatted_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- addDateFormatData("en_US");
- addDateFormatData("de_DE");
- addDateFormatData("ar_SA");
- addDateFormatData("hi_IN");
- addDateFormatData("zh_CN");
- addDateFormatData("th_TH");
-}
-
-void tst_qdeclarativelocale::dateToLocaleDateStringFormatted()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(format)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt.date(), format));
-}
-
-void tst_qdeclarativelocale::dateToLocaleTimeString_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateToLocaleTimeString()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleTimeString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt.time(), format));
-}
-
-void tst_qdeclarativelocale::addTimeFormatData(const QString &l)
-{
- const char *formats[] = {
- "hh:mm",
- "h:m:sap",
- "'The time is: 'H:mm:ss:zzz",
- "HH:mm t",
- 0
- };
- QByteArray locale = l.toLatin1();
- int i = 0;
- while (formats[i]) {
- QByteArray t(locale);
- t += " ";
- t += formats[i];
- QTest::newRow(t.constData()) << l << QString(formats[i]);
- ++i;
- }
-}
-
-void tst_qdeclarativelocale::dateToLocaleTimeStringFormatted_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- addTimeFormatData("en_US");
- addTimeFormatData("de_DE");
- addTimeFormatData("ar_SA");
- addTimeFormatData("hi_IN");
- addTimeFormatData("zh_CN");
- addTimeFormatData("th_TH");
-}
-
-void tst_qdeclarativelocale::dateToLocaleTimeStringFormatted()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(format)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt.time(), format));
-}
-
-void tst_qdeclarativelocale::dateFromLocaleString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
- QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
- QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
- QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
- QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
- QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleString()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7));
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(l.toString(dt, format))),
- Q_ARG(QVariant, QVariant(format)));
-
- QDateTime pd = l.toDateTime(l.toString(dt, format), format);
- QCOMPARE(val.toDateTime(), pd);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleDateString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
- QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
- QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
- QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
- QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
- QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleDateString()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7));
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "fromLocaleDateString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(l.toString(dt, format))),
- Q_ARG(QVariant, QVariant(format)));
-
- QDate pd = l.toDate(l.toString(dt, format), format);
- QCOMPARE(val.toDate(), pd);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleTimeString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
- QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
- QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
- QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
- QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
- QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleTimeString()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7));
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "fromLocaleTimeString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(l.toString(dt, format))),
- Q_ARG(QVariant, QVariant(format)));
-
- QTime pd = l.toTime(l.toString(dt, format), format);
- QCOMPARE(val.toTime(), pd);
-}
-
-void tst_qdeclarativelocale::numberToLocaleString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<char>("format");
- QTest::addColumn<int>("prec");
-
- QTest::newRow("en_US 1") << "en_US" << 'f' << 2;
- QTest::newRow("en_US 2") << "en_US" << 'g' << 3;
- QTest::newRow("en_US 3") << "en_US" << 'f' << 0;
- QTest::newRow("en_US 4") << "en_US" << 'f' << -1;
- QTest::newRow("de_DE 1") << "de_DE" << 'f' << 2;
- QTest::newRow("de_DE 2") << "de_DE" << 'g' << 3;
- QTest::newRow("ar_SA 1") << "ar_SA" << 'f' << 2;
- QTest::newRow("ar_SA 2") << "ar_SA" << 'g' << 3;
-}
-
-void tst_qdeclarativelocale::numberToLocaleString()
-{
- QFETCH(QString, locale);
- QFETCH(char, format);
- QFETCH(int, prec);
-
- QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- double number = 2344423.3289;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(number)),
- Q_ARG(QVariant, QVariant(QString(format))),
- Q_ARG(QVariant, QVariant(prec)));
-
- if (prec < 0) prec = 2;
- QCOMPARE(val.toString(), l.toString(number, format, prec));
-}
-
-void tst_qdeclarativelocale::numberToLocaleCurrencyString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("symbol");
-
- QTest::newRow("en_US 1") << "en_US" << QString();
- QTest::newRow("en_US 2") << "en_US" << "USD";
- QTest::newRow("de_DE") << "de_DE" << QString();
- QTest::newRow("ar_SA") << "ar_SA" << QString();
- QTest::newRow("hi_IN") << "hi_IN" << QString();
- QTest::newRow("zh_CN") << "zh_CN" << QString();
- QTest::newRow("th_TH") << "th_TH" << QString();
-}
-
-void tst_qdeclarativelocale::numberToLocaleCurrencyString()
-{
- QFETCH(QString, locale);
- QFETCH(QString, symbol);
-
- QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- double number = 2344423.3289;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleCurrencyString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(number)),
- Q_ARG(QVariant, QVariant(symbol)));
-
- QCOMPARE(val.toString(), l.toCurrencyString(number, symbol));
-}
-
-void tst_qdeclarativelocale::numberFromLocaleString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<double>("number");
-
- QTest::newRow("en_US 1") << "en_US" << 1234567.2345;
- QTest::newRow("en_US 2") << "en_US" << 0.234;
- QTest::newRow("en_US 3") << "en_US" << 234.0;
- QTest::newRow("de_DE") << "de_DE" << 1234567.2345;
- QTest::newRow("ar_SA") << "ar_SA" << 1234567.2345;
- QTest::newRow("hi_IN") << "hi_IN" << 1234567.2345;
- QTest::newRow("zh_CN") << "zh_CN" << 1234567.2345;
- QTest::newRow("th_TH") << "th_TH" << 1234567.2345;
-}
-
-void tst_qdeclarativelocale::numberFromLocaleString()
-{
- QFETCH(QString, locale);
- QFETCH(double, number);
-
- QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QString strNumber = l.toString(number, 'f');
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(strNumber)));
-
- QCOMPARE(val.toDouble(), l.toDouble(strNumber));
-}
-
-void tst_qdeclarativelocale::numberConstToLocaleString()
-{
- QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant("en_US")));
-
- QLocale l("en_US");
- QCOMPARE(obj->property("const1").toString(), l.toString(1234.56, 'f', 2));
- QCOMPARE(obj->property("const2").toString(), l.toString(1234., 'f', 2));
-}
-
-void tst_qdeclarativelocale::stringLocaleCompare_data()
-{
- QTest::addColumn<QString>("string1");
- QTest::addColumn<QString>("string2");
-
- QTest::newRow("before") << "a" << "b";
- QTest::newRow("equal") << "a" << "a";
- QTest::newRow("after") << "b" << "a";
-
- // Copied from QString::localeAwareCompare tests
- // We don't actually change locale - we just care that String.localeCompare()
- // matches QString::localeAwareCompare();
- QTest::newRow("swedish1") << QString("\xe5") << QString("\xe4");
- QTest::newRow("swedish2") << QString("\xe4") << QString("\xf6");
- QTest::newRow("swedish3") << QString("\xe5") << QString("\xf6");
- QTest::newRow("swedish4") << QString("z") << QString("\xe5");
-
- QTest::newRow("german1") << QString("z") << QString("\xe4");
- QTest::newRow("german2") << QString("\xe4") << QString("\xf6");
- QTest::newRow("german3") << QString("z") << QString("\xf6");
-}
-
-void tst_qdeclarativelocale::stringLocaleCompare()
-{
- QFETCH(QString, string1);
- QFETCH(QString, string2);
-
- QDeclarativeComponent c(&engine, testFileUrl("localeCompare.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- obj->setProperty("string1", string1);
- obj->setProperty("string2", string2);
-
- QCOMPARE(obj->property("comparison").toInt(), QString::localeAwareCompare(string1, string2));
-}
-
-QTEST_MAIN(tst_qdeclarativelocale)
-
-#include "tst_qdeclarativelocale.moc"
diff --git a/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro b/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro
deleted file mode 100644
index 206f510506..0000000000
--- a/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativemetaobject
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativemetaobject.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += declarative testlib
diff --git a/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp b/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp
deleted file mode 100644
index 424de872b7..0000000000
--- a/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include "../../shared/util.h"
-
-Q_DECLARE_METATYPE(QMetaMethod::MethodType)
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
-};
-QML_DECLARE_TYPE(MyQmlObject)
-
-class tst_QDeclarativeMetaObject : public QDeclarativeDataTest
-{
- Q_OBJECT
-private slots:
- void initTestCase();
-
- void property_data();
- void property();
- void method_data();
- void method();
-
-private:
- MyQmlObject myQmlObject;
-};
-
-void tst_QDeclarativeMetaObject::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
-
- qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
-}
-
-void tst_QDeclarativeMetaObject::property_data()
-{
- QTest::addColumn<QString>("testFile");
- QTest::addColumn<QByteArray>("cppTypeName");
- QTest::addColumn<int>("cppType");
- QTest::addColumn<bool>("isDefault");
- QTest::addColumn<QVariant>("expectedValue");
- QTest::addColumn<bool>("isWritable");
- QTest::addColumn<QVariant>("newValue");
-
- QTest::newRow("int") << "property.int.qml"
- << QByteArray("int") << int(QMetaType::Int)
- << false // default
- << QVariant(19) << true << QVariant(42);
- QTest::newRow("bool") << "property.bool.qml"
- << QByteArray("bool") << int(QMetaType::Bool)
- << true // default
- << QVariant(true) << true << QVariant(false);
- QTest::newRow("real") << "property.real.qml"
- << QByteArray("double") << int(QMetaType::Double)
- << false // default
- << QVariant(double(21))
- << true // writable
- << QVariant(double(37));
- QTest::newRow("string") << "property.string.qml"
- << QByteArray("QString") << int(QMetaType::QString)
- << true // default
- << QVariant(QString::fromLatin1("dog"))
- << true // writable
- << QVariant(QString::fromLatin1("food"));
- QTest::newRow("url") << "property.url.qml"
- << QByteArray("QUrl") << int(QMetaType::QUrl)
- << false // default
- << QVariant(QUrl("http://foo.bar"))
- << true //writable
- << QVariant(QUrl("http://bar.baz"));
- QTest::newRow("color") << "property.color.qml"
- << QByteArray("QColor") << int(QMetaType::QColor)
- << true // default
- << QVariant(QColor("#ff0000"))
- << true // writable
- << QVariant(QColor("#00ff00"));
- QTest::newRow("date") << "property.date.qml"
- << QByteArray("QDateTime") << int(QMetaType::QDateTime)
- << false // default
- << QVariant(QDateTime(QDate(2012, 2, 7)))
- << true // writable
- << QVariant(QDateTime(QDate(2010, 7, 2)));
- QTest::newRow("variant") << "property.variant.qml"
- << QByteArray("QVariant") << int(QMetaType::QVariant)
- << true // default
- << QVariant(QPointF(12, 34))
- << true // writable
- << QVariant(QSizeF(45, 67));
- QTest::newRow("var") << "property.var.qml"
- << QByteArray("QVariant") << int(QMetaType::QVariant)
- << false // default
- << QVariant(QVariantList() << 5 << true << "ciao")
- << true // writable
- << QVariant(QVariantList() << 17.0);
- QTest::newRow("QtObject") << "property.QtObject.qml"
- << QByteArray("QObject*") << int(QMetaType::QObjectStar)
- << false // default
- << QVariant()
- << true // writable
- << QVariant::fromValue(static_cast<QObject*>(this));
- QTest::newRow("list<QtObject>") << "property.list.QtObject.qml"
- << QByteArray("QDeclarativeListProperty<QObject>")
- << qMetaTypeId<QDeclarativeListProperty<QObject> >()
- << false // default
- << QVariant()
- << false // writable
- << QVariant();
- QTest::newRow("MyQmlObject") << "property.MyQmlObject.qml"
- << QByteArray("MyQmlObject*") << qMetaTypeId<MyQmlObject*>()
- << false // default
- << QVariant()
- << true // writable
- << QVariant::fromValue(&myQmlObject);
- QTest::newRow("list<MyQmlObject>") << "property.list.MyQmlObject.qml"
- << QByteArray("QDeclarativeListProperty<MyQmlObject>")
- << qMetaTypeId<QDeclarativeListProperty<MyQmlObject> >()
- << false // default
- << QVariant()
- << false // writable
- << QVariant();
- QTest::newRow("alias") << "property.alias.qml"
- << QByteArray("QString") << int(QMetaType::QString)
- << false // default
- << QVariant(QString::fromLatin1("Joe"))
- << true // writable
- << QVariant(QString::fromLatin1("Bob"));
- QTest::newRow("alias-2") << "property.alias.2.qml"
- << QByteArray("QObject*") << int(QMetaType::QObjectStar)
- << false // default
- << QVariant()
- << false // writable
- << QVariant();
- QTest::newRow("alias-3") << "property.alias.3.qml"
- << QByteArray("QString") << int(QMetaType::QString)
- << false // default
- << QVariant(QString::fromLatin1("Arial"))
- << true // writable
- << QVariant(QString::fromLatin1("Helvetica"));
-}
-
-void tst_QDeclarativeMetaObject::property()
-{
- QFETCH(QString, testFile);
- QFETCH(QByteArray, cppTypeName);
- QFETCH(int, cppType);
- QFETCH(bool, isDefault);
- QFETCH(QVariant, expectedValue);
- QFETCH(bool, isWritable);
- QFETCH(QVariant, newValue);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl(testFile));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- const QMetaObject *mo = object->metaObject();
- QVERIFY(mo->superClass() != 0);
- QVERIFY(QByteArray(mo->className()).contains("_QML_"));
- QCOMPARE(mo->propertyOffset(), mo->superClass()->propertyCount());
- QCOMPARE(mo->propertyCount(), mo->superClass()->propertyCount() + 1);
-
- QMetaProperty prop = mo->property(mo->propertyOffset());
- QCOMPARE(prop.name(), "test");
-
- QCOMPARE(QByteArray(prop.typeName()), cppTypeName);
- QEXPECT_FAIL("QtObject", "prop.type() returns UserType for QtObject properties", Continue);
- QEXPECT_FAIL("alias-2", "prop.type() returns UserType for QtObject properties", Continue);
- if (prop.userType() < QMetaType::User)
- QCOMPARE(prop.type(), QVariant::Type(cppType));
- QCOMPARE(prop.userType(), cppType);
-
- QVERIFY(!prop.isConstant());
- QVERIFY(!prop.isDesignable());
- QVERIFY(!prop.isEnumType());
- QVERIFY(!prop.isFinal());
- QVERIFY(!prop.isFlagType());
- QVERIFY(prop.isReadable());
- QVERIFY(!prop.isResettable());
- QVERIFY(prop.isScriptable());
- QVERIFY(!prop.isStored());
- QVERIFY(!prop.isUser());
- QVERIFY(prop.isValid());
- QCOMPARE(prop.isWritable(), isWritable);
-
- QCOMPARE(mo->classInfoOffset(), mo->superClass()->classInfoCount());
- QCOMPARE(mo->classInfoCount(), mo->superClass()->classInfoCount() + (isDefault ? 1 : 0));
- if (isDefault) {
- QMetaClassInfo info = mo->classInfo(mo->classInfoOffset());
- QCOMPARE(info.name(), "DefaultProperty");
- QCOMPARE(info.value(), "test");
- }
-
- QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount());
- QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); // the signal
-
- QVERIFY(prop.notifySignalIndex() != -1);
- QMetaMethod signal = prop.notifySignal();
- QCOMPARE(signal.methodType(), QMetaMethod::Signal);
- QCOMPARE(signal.signature(), "testChanged()");
- QCOMPARE(signal.access(), QMetaMethod::Protected);
- QCOMPARE(signal.parameterTypes(), QList<QByteArray>());
- QCOMPARE(signal.parameterNames(), QList<QByteArray>());
- QCOMPARE(signal.tag(), "");
- QCOMPARE(signal.typeName(), "");
-
- QSignalSpy changedSpy(object, SIGNAL(testChanged()));
- QObject::connect(object, SIGNAL(testChanged()), object, SLOT(deleteLater()));
-
- if (expectedValue.isValid())
- QCOMPARE(prop.read(object), expectedValue);
- else
- QVERIFY(prop.read(object).isValid());
- QCOMPARE(changedSpy.count(), 0);
-
- if (isWritable) {
- QVERIFY(prop.write(object, newValue));
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(prop.read(object), newValue);
- } else {
- QVERIFY(!prop.write(object, prop.read(object)));
- QCOMPARE(changedSpy.count(), 0);
- }
-
- delete object;
-}
-
-void tst_QDeclarativeMetaObject::method_data()
-{
- QTest::addColumn<QString>("testFile");
- QTest::addColumn<QString>("signature");
- QTest::addColumn<QMetaMethod::MethodType>("methodType");
- QTest::addColumn<QString>("returnTypeName");
- QTest::addColumn<QList<QByteArray> >("parameterTypeNames");
- QTest::addColumn<QList<QByteArray> >("parameterNames");
-
- QTest::newRow("testFunction()") << "method.1.qml"
- << "testFunction()"
- << QMetaMethod::Slot
- << "QVariant"
- << QList<QByteArray>()
- << QList<QByteArray>();
- QTest::newRow("testFunction(foo)") << "method.2.qml"
- << "testFunction(QVariant)"
- << QMetaMethod::Slot
- << "QVariant"
- << (QList<QByteArray>() << "QVariant")
- << (QList<QByteArray>() << "foo");
- QTest::newRow("testFunction(foo, bar, baz)") << "method.3.qml"
- << "testFunction(QVariant,QVariant,QVariant)"
- << QMetaMethod::Slot
- << "QVariant"
- << (QList<QByteArray>() << "QVariant" << "QVariant" << "QVariant")
- << (QList<QByteArray>() << "foo" << "bar" << "baz");
- QTest::newRow("testSignal") << "signal.1.qml"
- << "testSignal()"
- << QMetaMethod::Signal
- << ""
- << QList<QByteArray>()
- << QList<QByteArray>();
- QTest::newRow("testSignal(string foo)") << "signal.2.qml"
- << "testSignal(QString)"
- << QMetaMethod::Signal
- << ""
- << (QList<QByteArray>() << "QString")
- << (QList<QByteArray>() << "foo");
- QTest::newRow("testSignal(int foo, bool bar, real baz)") << "signal.3.qml"
- << "testSignal(int,bool,qreal)"
- << QMetaMethod::Signal
- << ""
- << (QList<QByteArray>() << "int" << "bool" << "qreal")
- << (QList<QByteArray>() << "foo" << "bar" << "baz");
- QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml"
- << "testSignal(QVariant,QVariant)"
- << QMetaMethod::Signal
- << ""
- << (QList<QByteArray>() << "QVariant" << "QVariant")
- << (QList<QByteArray>() << "foo" << "bar");
- QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml"
- << "testSignal(QColor,QDateTime,QUrl)"
- << QMetaMethod::Signal
- << ""
- << (QList<QByteArray>() << "QColor" << "QDateTime" << "QUrl")
- << (QList<QByteArray>() << "foo" << "bar" << "baz");
-}
-
-void tst_QDeclarativeMetaObject::method()
-{
- QFETCH(QString, testFile);
- QFETCH(QString, signature);
- QFETCH(QMetaMethod::MethodType, methodType);
- QFETCH(QString, returnTypeName);
- QFETCH(QList<QByteArray>, parameterTypeNames);
- QFETCH(QList<QByteArray>, parameterNames);
-
- QCOMPARE(parameterTypeNames.size(), parameterNames.size());
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl(testFile));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- const QMetaObject *mo = object->metaObject();
- QVERIFY(mo->superClass() != 0);
- QVERIFY(QByteArray(mo->className()).contains("_QML_"));
- QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount());
- QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1);
-
- QMetaMethod method = mo->method(mo->methodOffset());
- QCOMPARE(method.methodType(), methodType);
- QCOMPARE(QString::fromUtf8(method.signature()), signature);
- QCOMPARE(method.access(), QMetaMethod::Protected);
- QCOMPARE(method.parameterTypes(), parameterTypeNames);
- QCOMPARE(method.parameterNames(), parameterNames);
- QCOMPARE(method.tag(), "");
- QCOMPARE(QString::fromUtf8(method.typeName()), returnTypeName);
-
- delete object;
-}
-
-QTEST_MAIN(tst_QDeclarativeMetaObject)
-
-#include "tst_qdeclarativemetaobject.moc"
diff --git a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
deleted file mode 100644
index 8261f6d930..0000000000
--- a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativemetatype
-SOURCES += tst_qdeclarativemetatype.cpp
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private widgets testlib
diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
deleted file mode 100644
index e8748ee56a..0000000000
--- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <qdeclarative.h>
-
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativepropertyvalueinterceptor_p.h>
-
-class tst_qdeclarativemetatype : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativemetatype() {}
-
-private slots:
- void initTestCase();
-
- void qmlParserStatusCast();
- void qmlPropertyValueSourceCast();
- void qmlPropertyValueInterceptorCast();
-
- void isList();
-
- void defaultObject();
-};
-
-class TestType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo)
-
- Q_CLASSINFO("DefaultProperty", "foo")
-public:
- int foo() { return 0; }
-};
-QML_DECLARE_TYPE(TestType);
-
-class ParserStatusTestType : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- void classBegin(){}
- void componentComplete(){}
- Q_CLASSINFO("DefaultProperty", "foo") // Missing default property
- Q_INTERFACES(QDeclarativeParserStatus)
-};
-QML_DECLARE_TYPE(ParserStatusTestType);
-
-class ValueSourceTestType : public QObject, public QDeclarativePropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueSource)
-public:
- virtual void setTarget(const QDeclarativeProperty &) {}
-};
-QML_DECLARE_TYPE(ValueSourceTestType);
-
-class ValueInterceptorTestType : public QObject, public QDeclarativePropertyValueInterceptor
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueInterceptor)
-public:
- virtual void setTarget(const QDeclarativeProperty &) {}
- virtual void write(const QVariant &) {}
-};
-QML_DECLARE_TYPE(ValueInterceptorTestType);
-
-void tst_qdeclarativemetatype::initTestCase()
-{
- qmlRegisterType<TestType>("Test", 1, 0, "TestType");
- qmlRegisterType<ParserStatusTestType>("Test", 1, 0, "ParserStatusTestType");
- qmlRegisterType<ValueSourceTestType>("Test", 1, 0, "ValueSourceTestType");
- qmlRegisterType<ValueInterceptorTestType>("Test", 1, 0, "ValueInterceptorTestType");
-}
-
-void tst_qdeclarativemetatype::qmlParserStatusCast()
-{
- QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->parserStatusCast(), -1);
-
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->parserStatusCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ParserStatusTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativeParserStatus *)&t));
-
- QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(status, (QDeclarativeParserStatus*)&t);
-}
-
-void tst_qdeclarativemetatype::qmlPropertyValueSourceCast()
-{
- QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueSourceCast(), -1);
-
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
- int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->propertyValueSourceCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ValueSourceTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueSource *)&t));
-
- QDeclarativePropertyValueSource *source = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(source, (QDeclarativePropertyValueSource*)&t);
-}
-
-void tst_qdeclarativemetatype::qmlPropertyValueInterceptorCast()
-{
- QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueInterceptorCast(), -1);
-
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>()) != 0);
- int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>())->propertyValueInterceptorCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ValueInterceptorTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueInterceptor *)&t));
-
- QDeclarativePropertyValueInterceptor *interceptor = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(interceptor, (QDeclarativePropertyValueInterceptor*)&t);
-}
-
-void tst_qdeclarativemetatype::isList()
-{
- QCOMPARE(QDeclarativeMetaType::isList(QVariant::Invalid), false);
- QCOMPARE(QDeclarativeMetaType::isList(QVariant::Int), false);
-
- QDeclarativeListProperty<TestType> list;
-
- QCOMPARE(QDeclarativeMetaType::isList(qMetaTypeId<QDeclarativeListProperty<TestType> >()), true);
-}
-
-void tst_qdeclarativemetatype::defaultObject()
-{
- QVERIFY(QDeclarativeMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0);
- QVERIFY(QDeclarativeMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0);
- QCOMPARE(QString(QDeclarativeMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo"));
-
- QObject o;
- TestType t;
- ParserStatusTestType p;
-
- QVERIFY(QDeclarativeMetaType::defaultProperty((QObject *)0).name() == 0);
- QVERIFY(QDeclarativeMetaType::defaultProperty(&o).name() == 0);
- QVERIFY(QDeclarativeMetaType::defaultProperty(&p).name() == 0);
- QCOMPARE(QString(QDeclarativeMetaType::defaultProperty(&t).name()), QString("foo"));
-}
-
-QTEST_MAIN(tst_qdeclarativemetatype)
-
-#include "tst_qdeclarativemetatype.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro
deleted file mode 100644
index 21835613af..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2.1
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp
deleted file mode 100644
index a8a0f69a3a..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import2.1 worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json")
-
-public:
- MyPlugin()
- {
- qWarning("plugin2.1 created");
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
- qmlRegisterType<MyPluginType>(uri, 2, 1, "MyPluginType");
- }
-};
-
-#include "plugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro
deleted file mode 100644
index 6d4f5fb301..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp
deleted file mode 100644
index c67b5b1b63..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import2 worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json")
-
-public:
- MyPlugin()
- {
- qWarning("plugin2 created");
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
- qmlRegisterType<MyPluginType>(uri, 2, 0, "MyPluginType");
- }
-};
-
-#include "plugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp
deleted file mode 100644
index 869630bd63..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json")
-
-public:
- MyPlugin()
- {
- qWarning("plugin created");
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
- qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
- }
-};
-
-#include "plugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro
deleted file mode 100644
index 61fab02109..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp
deleted file mode 100644
index 51e48781f6..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class BarPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value)
-
-public:
- int value() const { return 16; }
-};
-
-
-class MyMixedPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json")
-
-public:
- MyMixedPlugin()
- {
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlMixedPluginType");
- qmlRegisterType<BarPluginType>(uri, 1, 0, "Bar");
- }
-};
-
-#include "plugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro
deleted file mode 100644
index f8b279cbf6..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlMixedPluginType
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp
deleted file mode 100644
index ab8b3d479e..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class FloorPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value);
-
-public:
- int value() const { return 16; }
-};
-
-
-class MyMixedPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json")
-
-public:
- MyMixedPlugin()
- {
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlVersionPluginType");
- qmlRegisterType<FloorPluginType>(uri, 1, 4, "Floor");
- }
-};
-
-#include "plugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro
deleted file mode 100644
index 32e017e79d..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlVersionPluginType
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp
deleted file mode 100644
index 88b807e14d..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json")
-
-public:
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestPluginWithQmlFile");
- }
-};
-
-#include "plugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro
deleted file mode 100644
index 1b496d689a..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestPluginWithQmlFile
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp
deleted file mode 100644
index fe110a28d4..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json")
-
-public:
- MyPlugin()
- {
- qWarning("plugin created");
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.WrongCase");
- qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
- }
-};
-
-#include "plugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro
deleted file mode 100644
index 5d21114a2f..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-TARGET = Plugin
-DESTDIR = ../imports/com/nokia/WrongCase
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
deleted file mode 100644
index 25c6c6ad56..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT = core
-TEMPLATE = subdirs
-SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion
-tst_qdeclarativemoduleplugin_pro.depends += plugin
-SUBDIRS += tst_qdeclarativemoduleplugin.pro
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
deleted file mode 100644
index 46e5358fab..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <qdir.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QDebug>
-
-#include "../../shared/testhttpserver.h"
-#include "../../shared/util.h"
-
-#define SERVER_ADDR "http://127.0.0.1:14450"
-#define SERVER_PORT 14450
-
-
-class tst_qdeclarativemoduleplugin : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- virtual void initTestCase();
- void importsPlugin();
- void importsPlugin2();
- void importsPlugin21();
- void importsMixedQmlCppPlugin();
- void incorrectPluginCase();
- void importPluginWithQmlFile();
- void remoteImportWithQuotedUrl();
- void remoteImportWithUnquotedUri();
- void versionNotInstalled();
- void versionNotInstalled_data();
- void implicitQmldir();
- void implicitQmldir_data();
-
-private:
- QString m_importsDirectory;
-};
-
-void tst_qdeclarativemoduleplugin::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- m_importsDirectory = directory() + QStringLiteral("/imports");
- QVERIFY2(QFileInfo(m_importsDirectory).isDir(),
- qPrintable(QString::fromLatin1("Imports directory '%1' does not exist.").arg(m_importsDirectory)));
-}
-
-#define VERIFY_ERRORS(errorfile) \
- if (!errorfile) { \
- if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
- qWarning() << "Unexpected Errors:" << component.errors(); \
- QVERIFY(!component.isError()); \
- QVERIFY(component.errors().isEmpty()); \
- } else { \
- QString verify_errors_file_name = testFile(errorfile); \
- QFile file(verify_errors_file_name); \
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- QList<QByteArray> expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QDeclarativeError> errors = component.errors(); \
- QList<QByteArray> actual; \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QDeclarativeError &error = errors.at(ii); \
- QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
- QByteArray::number(error.column()) + ":" + \
- error.description().toUtf8(); \
- actual << errorStr; \
- } \
- if (qgetenv("DEBUG") != "" && expected != actual) { \
- qWarning() << "Expected:" << expected << "Actual:" << actual; \
- } \
- if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
- QFile file(testFile(errorfile)); \
- QVERIFY(file.open(QIODevice::WriteOnly)); \
- for (int ii = 0; ii < actual.count(); ++ii) { \
- file.write(actual.at(ii)); file.write("\n"); \
- } \
- file.close(); \
- } else { \
- QCOMPARE(expected, actual); \
- } \
- }
-
-void tst_qdeclarativemoduleplugin::importsPlugin()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin created");
- QTest::ignoreMessage(QtWarningMsg, "import worked");
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works.qml")));
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
- delete object;
-}
-
-void tst_qdeclarativemoduleplugin::importsPlugin2()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin2 created");
- QTest::ignoreMessage(QtWarningMsg, "import2 worked");
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works2.qml")));
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
- delete object;
-}
-
-void tst_qdeclarativemoduleplugin::importsPlugin21()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created");
- QTest::ignoreMessage(QtWarningMsg, "import2.1 worked");
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works21.qml")));
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
- delete object;
-}
-
-void tst_qdeclarativemoduleplugin::incorrectPluginCase()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
-
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("incorrectCase.qml")));
-
- QList<QDeclarativeError> errors = component.errors();
- QCOMPARE(errors.count(), 1);
-
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
-#if defined(Q_OS_MAC)
- QString libname = "libPluGin.dylib";
-#elif defined(Q_OS_WIN32)
- QString libname = "PluGin.dll";
-#endif
- QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("com/nokia/WrongCase/" + libname) + QLatin1String("\"");
-#else
- QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found");
-#endif
-
- QCOMPARE(errors.at(0).description(), expectedError);
-}
-
-void tst_qdeclarativemoduleplugin::importPluginWithQmlFile()
-{
- QString path = m_importsDirectory;
-
- // QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure
- // (this only happens if the plugin includes pure QML files)
- #ifdef Q_OS_WIN
- QVERIFY(path.at(0).isUpper() && path.at(1) == QLatin1Char(':'));
- path = path.at(0).toLower() + path.mid(1);
- #endif
-
- QDeclarativeEngine engine;
- engine.addImportPath(path);
-
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml")));
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativemoduleplugin::remoteImportWithQuotedUrl()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(m_importsDirectory);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import \"http://127.0.0.1:14450/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl());
-
- QTRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
- QObject *object = component.create();
- QCOMPARE(object->property("width").toInt(), 300);
- QVERIFY(object != 0);
- delete object;
-
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
-}
-
-void tst_qdeclarativemoduleplugin::remoteImportWithUnquotedUri()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(m_importsDirectory);
-
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
- QDeclarativeComponent component(&engine);
- component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl());
-
-
- QTRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("width").toInt(), 300);
- delete object;
-
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
-}
-
-// QTBUG-17324
-
-void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
-
- {
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml")));
-
- QObject *o = component.create();
- QVERIFY2(o != 0, QDeclarativeDataTest::msgComponentError(component, &engine));
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.2.qml")));
-
- QObject *o = component.create();
- QVERIFY2(o != 0, QDeclarativeDataTest::msgComponentError(component, &engine));
- QCOMPARE(o->property("test").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- delete o;
- }
-
-
-}
-
-void tst_qdeclarativemoduleplugin::versionNotInstalled_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
-
- QTest::newRow("versionNotInstalled") << "versionNotInstalled.qml" << "versionNotInstalled.errors.txt";
- QTest::newRow("versionNotInstalled") << "versionNotInstalled.2.qml" << "versionNotInstalled.2.errors.txt";
-}
-
-void tst_qdeclarativemoduleplugin::versionNotInstalled()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
-
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
-
- QDeclarativeComponent component(&engine, testFileUrl(file));
- VERIFY_ERRORS(errorFile.toLatin1().constData());
-}
-
-
-// test that errors are reporting correctly for plugin loading and qmldir parsing
-void tst_qdeclarativemoduleplugin::implicitQmldir_data()
-{
- QTest::addColumn<QString>("directory");
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
-
- // parsing qmldir succeeds, but plugin specified in the qmldir file doesn't exist
- QTest::newRow("implicitQmldir") << "implicit1" << "temptest.qml" << "implicitQmldir.errors.txt";
-
- // parsing qmldir fails due to syntax errors, etc.
- QTest::newRow("implicitQmldir2") << "implicit2" << "temptest2.qml" << "implicitQmldir.2.errors.txt";
-}
-void tst_qdeclarativemoduleplugin::implicitQmldir()
-{
- QFETCH(QString, directory);
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
-
- QString importPath = testFile(directory);
- QString fileName = directory + QDir::separator() + file;
- QString errorFileName = directory + QDir::separator() + errorFile;
- QUrl testUrl = testFileUrl(fileName);
-
- QDeclarativeEngine engine;
- engine.addImportPath(importPath);
-
- QDeclarativeComponent component(&engine, testUrl);
- QList<QDeclarativeError> errors = component.errors();
- VERIFY_ERRORS(errorFileName.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QObject *obj = component.create();
- QVERIFY(!obj);
- delete obj;
-}
-
-
-QTEST_MAIN(tst_qdeclarativemoduleplugin)
-
-#include "tst_qdeclarativemoduleplugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro
deleted file mode 100644
index 58f329d095..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativemoduleplugin
-
-HEADERS = ../../shared/testhttpserver.h
-SOURCES = tst_qdeclarativemoduleplugin.cpp \
- ../../shared/testhttpserver.cpp
-CONFIG -= app_bundle
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-testImportFiles.files = imports
-testImportFiles.path = .
-DEPLOYMENT += testImportFiles
-
-QT += core-private gui-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro b/tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro
deleted file mode 100644
index f864337fa7..0000000000
--- a/tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeparser
-QT += qmldevtools-private testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeparser.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp b/tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp
deleted file mode 100644
index 8c3b93615d..0000000000
--- a/tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qdeclarativejsengine_p.h>
-#include <private/qdeclarativejsparser_p.h>
-#include <private/qdeclarativejslexer_p.h>
-#include <private/qdeclarativejsastvisitor_p.h>
-#include <private/qdeclarativejsast_p.h>
-
-#include <qtest.h>
-#include <QDir>
-#include <QDebug>
-#include <cstdlib>
-
-class tst_qdeclarativeparser : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeparser();
-
-private slots:
- void initTestCase();
- void qmlParser_data();
- void qmlParser();
-
-private:
- QStringList excludedDirs;
-
- QStringList findFiles(const QDir &);
-};
-
-namespace check {
-
-using namespace QDeclarativeJS;
-
-class Check: public AST::Visitor
-{
- Engine *engine;
- QList<AST::Node *> nodeStack;
-
-public:
- Check(Engine *engine)
- : engine(engine)
- {
- }
-
- void operator()(AST::Node *node)
- {
- AST::Node::accept(node, this);
- }
-
- void checkNode(AST::Node *node)
- {
- if (! nodeStack.isEmpty()) {
- AST::Node *parent = nodeStack.last();
- const quint32 parentBegin = parent->firstSourceLocation().begin();
- const quint32 parentEnd = parent->lastSourceLocation().end();
-
- QVERIFY(node->firstSourceLocation().begin() >= parentBegin);
- QVERIFY(node->lastSourceLocation().end() <= parentEnd);
- }
- }
-
- virtual bool preVisit(AST::Node *node)
- {
- checkNode(node);
- nodeStack.append(node);
- return true;
- }
-
- virtual void postVisit(AST::Node *)
- {
- nodeStack.removeLast();
- }
-};
-
-}
-
-tst_qdeclarativeparser::tst_qdeclarativeparser()
-{
-}
-
-void tst_qdeclarativeparser::initTestCase()
-{
- // Add directories you want excluded here
-
- // These snippets are not expected to run on their own.
- excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/declarative/qtbinding";
- excludedDirs << "doc/src/snippets/declarative/imports";
- excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
- excludedDirs << "doc/src/snippets/qtquick1/imports";
-}
-
-QStringList tst_qdeclarativeparser::findFiles(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return QStringList();
- }
-
- QStringList rv;
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"),
- QDir::Files);
- foreach (const QString &file, files) {
- rv << d.absoluteFilePath(file);
- }
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findFiles(sub);
- }
-
- return rv;
-}
-
-/*
-This test checks all the qml and js files in the declarative UI source tree
-and ensures that the subnode's source locations are inside parent node's source locations
-*/
-
-void tst_qdeclarativeparser::qmlParser_data()
-{
- QTest::addColumn<QString>("file");
-
- QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
- QString tests = QLatin1String(SRCDIR) + "/../../../../tests/";
-
- QStringList files;
- files << findFiles(QDir(examples));
- files << findFiles(QDir(tests));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_qdeclarativeparser::qmlParser()
-{
- QFETCH(QString, file);
-
- using namespace QDeclarativeJS;
-
- QString code;
-
- QFile f(file);
- if (f.open(QFile::ReadOnly))
- code = QString::fromUtf8(f.readAll());
-
- const bool qmlMode = file.endsWith(QLatin1String(".qml"));
-
- Engine engine;
- Lexer lexer(&engine);
- lexer.setCode(code, 1, qmlMode);
- Parser parser(&engine);
- if (qmlMode)
- parser.parse();
- else
- parser.parseProgram();
-
- check::Check chk(&engine);
- chk(parser.rootNode());
-}
-
-QTEST_MAIN(tst_qdeclarativeparser)
-
-#include "tst_qdeclarativeparser.moc"
diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
deleted file mode 100644
index 45b240b9bd..0000000000
--- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeproperty
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeproperty.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private widgets testlib
diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
deleted file mode 100644
index 9dfe8db09b..0000000000
--- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
+++ /dev/null
@@ -1,1721 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <QtWidgets/QLineEdit>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdir.h>
-#include "../../shared/util.h"
-
-#include <QDebug>
-class MyQmlObject : public QObject
-{
- Q_OBJECT
-public:
- MyQmlObject() {}
-};
-
-QML_DECLARE_TYPE(MyQmlObject);
-
-class MyAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo WRITE setFoo)
-public:
- MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
-
- int foo() const { return m_foo; }
- void setFoo(int f) { m_foo = f; }
-
-private:
- int m_foo;
-};
-
-class MyContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<MyQmlObject> children READ children)
-public:
- MyContainer() {}
-
- QDeclarativeListProperty<MyQmlObject> children() { return QDeclarativeListProperty<MyQmlObject>(this, m_children); }
-
- static MyAttached *qmlAttachedProperties(QObject *o) {
- return new MyAttached(o);
- }
-
-private:
- QList<MyQmlObject*> m_children;
-};
-
-QML_DECLARE_TYPE(MyContainer);
-QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES)
-
-class tst_qdeclarativeproperty : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeproperty() {}
-
-private slots:
- void initTestCase();
-
- // Constructors
- void qmlmetaproperty();
- void qmlmetaproperty_object();
- void qmlmetaproperty_object_string();
- void qmlmetaproperty_object_context();
- void qmlmetaproperty_object_string_context();
-
- // Methods
- void name();
- void read();
- void write();
- void reset();
-
- // Functionality
- void writeObjectToList();
- void writeListToList();
-
- //writeToReadOnly();
-
- void urlHandling_data();
- void urlHandling();
-
- void variantMapHandling_data();
- void variantMapHandling();
-
- // Bugs
- void crashOnValueProperty();
- void aliasPropertyBindings();
- void noContext();
- void assignEmptyVariantMap();
-
- void copy();
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeproperty::qmlmetaproperty()
-{
- QDeclarativeProperty prop;
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
-}
-
-class PropertyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int defaultProperty READ defaultProperty)
- Q_PROPERTY(QRect rectProperty READ rectProperty)
- Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty)
- Q_PROPERTY(QUrl url READ url WRITE setUrl)
- Q_PROPERTY(QVariantMap variantMap READ variantMap WRITE setVariantMap)
- Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
- Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
- Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject)
-
- Q_CLASSINFO("DefaultProperty", "defaultProperty")
-public:
- PropertyObject() : m_resetProperty(9) {}
-
- int defaultProperty() { return 10; }
- QRect rectProperty() { return QRect(10, 10, 1, 209); }
-
- QRect wrectProperty() { return m_rect; }
- void setWRectProperty(const QRect &r) { m_rect = r; }
-
- QUrl url() { return m_url; }
- void setUrl(const QUrl &u) { m_url = u; }
-
- QVariantMap variantMap() const { return m_variantMap; }
- void setVariantMap(const QVariantMap &variantMap) { m_variantMap = variantMap; }
-
- int resettableProperty() const { return m_resetProperty; }
- void setResettableProperty(int r) { m_resetProperty = r; }
- void resetProperty() { m_resetProperty = 9; }
-
- int propertyWithNotify() const { return m_propertyWithNotify; }
- void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
-
- MyQmlObject *qmlObject() { return &m_qmlObject; }
-
-signals:
- void clicked();
- void oddlyNamedNotifySignal();
-
-private:
- int m_resetProperty;
- QRect m_rect;
- QUrl m_url;
- QVariantMap m_variantMap;
- int m_propertyWithNotify;
- MyQmlObject m_qmlObject;
-};
-
-QML_DECLARE_TYPE(PropertyObject);
-
-void tst_qdeclarativeproperty::qmlmetaproperty_object()
-{
- QObject object; // Has no default property
- PropertyObject dobject; // Has default property
-
- {
- QDeclarativeProperty prop(&object);
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject);
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), true);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data());
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeproperty::qmlmetaproperty_object_string()
-{
- QObject object;
- PropertyObject dobject;
-
- {
- QDeclarativeProperty prop(&object, QString("defaultProperty"));
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("defaultProperty"));
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), true);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data());
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("onClicked"));
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onClicked"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
- QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), true);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression != 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data());
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"));
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
- QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), true);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression != 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data());
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeproperty::qmlmetaproperty_object_context()
-{
- QObject object; // Has no default property
- PropertyObject dobject; // Has default property
-
- {
- QDeclarativeProperty prop(&object, engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), true);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data());
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context()
-{
- QObject object;
- PropertyObject dobject;
-
- {
- QDeclarativeProperty prop(&object, QString("defaultProperty"), engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), true);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data());
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("onClicked"), engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onClicked"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
- QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), true);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression != 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data());
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
- QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), true);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression != 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data());
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeproperty::name()
-{
- {
- QDeclarativeProperty p;
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.name(), QString("defaultProperty"));
- }
-
- {
- QObject o;
- QDeclarativeProperty p(&o, QString("objectName"));
- QCOMPARE(p.name(), QString("objectName"));
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onClicked");
- QCOMPARE(p.name(), QString("onClicked"));
- }
-
- {
- QObject o;
- QDeclarativeProperty p(&o, "onClicked");
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
- QCOMPARE(p.name(), QString("onOddlyNamedNotifySignal"));
- }
-
- {
- QObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
- QCOMPARE(p.name(), QString());
- }
-
- {
- QObject o;
- QDeclarativeProperty p(&o, "foo");
- QCOMPARE(p.name(), QString());
- }
-
- {
- QDeclarativeProperty p(0, "foo");
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty");
- QCOMPARE(p.name(), QString("rectProperty"));
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty.x");
- QCOMPARE(p.name(), QString("rectProperty.x"));
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty.foo");
- QCOMPARE(p.name(), QString());
- }
-}
-
-void tst_qdeclarativeproperty::read()
-{
- // Invalid
- {
- QDeclarativeProperty p;
- QCOMPARE(p.read(), QVariant());
- }
-
- // Default prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.read(), QVariant(10));
- }
-
- // Invalid default prop
- {
- QObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.read(), QVariant());
- }
-
- // Value prop by name
- {
- QObject o;
-
- QDeclarativeProperty p(&o, "objectName");
- QCOMPARE(p.read(), QVariant(QString()));
-
- o.setObjectName("myName");
-
- QCOMPARE(p.read(), QVariant("myName"));
- }
-
- // Value prop by name (static)
- {
- QObject o;
-
- QCOMPARE(QDeclarativeProperty::read(&o, "objectName"), QVariant(QString()));
-
- o.setObjectName("myName");
-
- QCOMPARE(QDeclarativeProperty::read(&o, "objectName"), QVariant("myName"));
- }
-
- // Value-type prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(10));
- }
-
- // Invalid value-type prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty.foo");
- QCOMPARE(p.read(), QVariant());
- }
-
- // Signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onClicked");
- QCOMPARE(p.read(), QVariant());
-
- QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
-
- QCOMPARE(p.read(), QVariant());
- }
-
- // Automatic signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
- QCOMPARE(p.read(), QVariant());
-
- QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
-
- QCOMPARE(p.read(), QVariant());
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
- QDeclarativeProperty p(o, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(10));
- delete o;
- QCOMPARE(p.read(), QVariant());
- }
-
- // Object property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "qmlObject");
- QCOMPARE(p.propertyTypeCategory(), QDeclarativeProperty::Object);
- QCOMPARE(p.propertyType(), qMetaTypeId<MyQmlObject*>());
- QVariant v = p.read();
- QVERIFY(v.userType() == QMetaType::QObjectStar);
- QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject());
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "test", &engine);
-
- QCOMPARE(p.propertyTypeCategory(), QDeclarativeProperty::Object);
- QVERIFY(p.propertyType() != QMetaType::QObjectStar);
-
- QVariant v = p.read();
- QVERIFY(v.userType() == QMetaType::QObjectStar);
- QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
- QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
- }
- { // static
- QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVariant v = QDeclarativeProperty::read(object, "test", &engine);
- QVERIFY(v.userType() == QMetaType::QObjectStar);
- QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
- QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
- }
-
- // Attached property
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(13));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(10));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(10));
- delete object;
- }
- { // static
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(QDeclarativeProperty::read(object, "Foo.MyContainer.foo", qmlContext(object)), QVariant(10));
- delete object;
- }
-}
-
-void tst_qdeclarativeproperty::write()
-{
- // Invalid
- {
- QDeclarativeProperty p;
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Read-only default prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Invalid default prop
- {
- QObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Read-only prop by name
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, QString("defaultProperty"));
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Writable prop by name
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, QString("objectName"));
- QCOMPARE(o.objectName(), QString());
- QCOMPARE(p.write(QVariant(QString("myName"))), true);
- QCOMPARE(o.objectName(), QString("myName"));
- }
-
- // Writable prop by name (static)
- {
- PropertyObject o;
- QCOMPARE(QDeclarativeProperty::write(&o, QString("objectName"), QVariant(QString("myName"))), true);
- QCOMPARE(o.objectName(), QString("myName"));
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
- QDeclarativeProperty p(o, QString("objectName"));
- QCOMPARE(p.write(QVariant(QString("myName"))), true);
- QCOMPARE(o->objectName(), QString("myName"));
-
- delete o;
-
- QCOMPARE(p.write(QVariant(QString("myName"))), false);
- }
-
- // Signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onClicked");
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
-
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
- }
-
- // Automatic signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
-
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
- }
-
- // Value-type property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "wrectProperty");
-
- QCOMPARE(o.wrectProperty(), QRect());
- QCOMPARE(p.write(QRect(1, 13, 99, 8)), true);
- QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8));
-
- QDeclarativeProperty p2(&o, "wrectProperty.x");
- QCOMPARE(p2.read(), QVariant(1));
- QCOMPARE(p2.write(QVariant(6)), true);
- QCOMPARE(p2.read(), QVariant(6));
- QCOMPARE(o.wrectProperty(), QRect(6, 13, 99, 8));
- }
-
- // URL-property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "url");
-
- QCOMPARE(p.write(QUrl("main.qml")), true);
- QCOMPARE(o.url(), QUrl("main.qml"));
-
- QDeclarativeProperty p2(&o, "url", engine.rootContext());
-
- QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
- QVERIFY(result != QUrl("main.qml"));
-
- QCOMPARE(p2.write(QUrl("main.qml")), true);
- QCOMPARE(o.url(), result);
- }
- { // static
- PropertyObject o;
-
- QCOMPARE(QDeclarativeProperty::write(&o, "url", QUrl("main.qml")), true);
- QCOMPARE(o.url(), QUrl("main.qml"));
-
- QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
- QVERIFY(result != QUrl("main.qml"));
-
- QCOMPARE(QDeclarativeProperty::write(&o, "url", QUrl("main.qml"), engine.rootContext()), true);
- QCOMPARE(o.url(), result);
- }
-
- // VariantMap-property
- QVariantMap vm;
- vm.insert("key", "value");
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "variantMap");
-
- QCOMPARE(p.write(vm), true);
- QCOMPARE(o.variantMap(), vm);
-
- QDeclarativeProperty p2(&o, "variantMap", engine.rootContext());
-
- QCOMPARE(p2.write(vm), true);
- QCOMPARE(o.variantMap(), vm);
- }
- { // static
- PropertyObject o;
-
- QCOMPARE(QDeclarativeProperty::write(&o, "variantMap", vm), true);
- QCOMPARE(o.variantMap(), vm);
-
- QCOMPARE(QDeclarativeProperty::write(&o, "variantMap", vm, engine.rootContext()), true);
- QCOMPARE(o.variantMap(), vm);
- }
-
- // Attached property
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
- p.write(QVariant(99));
- QCOMPARE(p.read(), QVariant(99));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
- p.write(QVariant(99));
- QCOMPARE(p.read(), QVariant(99));
- delete object;
- }
-}
-
-void tst_qdeclarativeproperty::reset()
-{
- // Invalid
- {
- QDeclarativeProperty p;
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Read-only default prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Invalid default prop
- {
- QObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Non-resettable-only prop by name
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, QString("defaultProperty"));
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Resettable prop by name
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, QString("resettableProperty"));
-
- QCOMPARE(p.read(), QVariant(9));
- QCOMPARE(p.write(QVariant(11)), true);
- QCOMPARE(p.read(), QVariant(11));
-
- QCOMPARE(p.isResettable(), true);
- QCOMPARE(p.reset(), true);
-
- QCOMPARE(p.read(), QVariant(9));
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
-
- QDeclarativeProperty p(o, QString("resettableProperty"));
-
- QCOMPARE(p.isResettable(), true);
- QCOMPARE(p.reset(), true);
-
- delete o;
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onClicked");
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Automatic signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-}
-
-void tst_qdeclarativeproperty::writeObjectToList()
-{
- QDeclarativeComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QDeclarativeListReference list(container, "children");
- QVERIFY(list.count() == 1);
-
- MyQmlObject *object = new MyQmlObject;
- QDeclarativeProperty prop(container, "children");
- prop.write(qVariantFromValue(object));
- QCOMPARE(list.count(), 1);
- QCOMPARE(list.at(0), qobject_cast<QObject*>(object));
-}
-
-void tst_qdeclarativeproperty::writeListToList()
-{
- QDeclarativeComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QDeclarativeListReference list(container, "children");
- QVERIFY(list.count() == 1);
-
- QList<QObject*> objList;
- objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
- QDeclarativeProperty prop(container, "children");
- prop.write(qVariantFromValue(objList));
- QCOMPARE(list.count(), 4);
-
- //XXX need to try this with read/write prop (for read-only it correctly doesn't write)
- /*QList<MyQmlObject*> typedObjList;
- typedObjList << new MyQmlObject();
- prop.write(qVariantFromValue(&typedObjList));
- QCOMPARE(container->children()->size(), 1);*/
-}
-
-void tst_qdeclarativeproperty::urlHandling_data()
-{
- QTest::addColumn<QByteArray>("input");
- QTest::addColumn<QString>("scheme");
- QTest::addColumn<QString>("path");
- QTest::addColumn<QByteArray>("encoded");
-
- QTest::newRow("unspecifiedFile")
- << QByteArray("main.qml")
- << QString("")
- << QString("main.qml")
- << QByteArray("main.qml");
-
- QTest::newRow("specifiedFile")
- << QByteArray("file:///main.qml")
- << QString("file")
- << QString("/main.qml")
- << QByteArray("file:///main.qml");
-
- QTest::newRow("httpFile")
- << QByteArray("http://www.example.com/main.qml")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml");
-
- QTest::newRow("pathFile")
- << QByteArray("http://www.example.com/resources/main.qml")
- << QString("http")
- << QString("/resources/main.qml")
- << QByteArray("http://www.example.com/resources/main.qml");
-
- QTest::newRow("encodableName")
- << QByteArray("http://www.example.com/main file.qml")
- << QString("http")
- << QString("/main file.qml")
- << QByteArray("http://www.example.com/main%20file.qml");
-
- QTest::newRow("preencodedName")
- << QByteArray("http://www.example.com/resources%7cmain%20file.qml")
- << QString("http")
- << QString("/resources|main file.qml")
- << QByteArray("http://www.example.com/resources%7cmain%20file.qml");
-
- QTest::newRow("encodableQuery")
- << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now working?")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now%20working?");
-
- QTest::newRow("preencodedQuery")
- << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now working%3f")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now%20working%3f");
-
- QTest::newRow("encodableFragment")
- << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000|volume+50%")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7Cvolume+50%25");
-
- QTest::newRow("preencodedFragment")
- << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%25");
-}
-
-void tst_qdeclarativeproperty::urlHandling()
-{
- QFETCH(QByteArray, input);
- QFETCH(QString, scheme);
- QFETCH(QString, path);
- QFETCH(QByteArray, encoded);
-
- QString inputString(QString::fromUtf8(input));
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "url");
-
- // Test url written as QByteArray
- QCOMPARE(p.write(input), true);
- QUrl byteArrayResult(o.url());
-
- QCOMPARE(byteArrayResult.scheme(), scheme);
- QCOMPARE(byteArrayResult.path(), path);
- QCOMPARE(byteArrayResult.toEncoded(), encoded);
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "url");
-
- // Test url written as QString
- QCOMPARE(p.write(inputString), true);
- QUrl stringResult(o.url());
-
- QCOMPARE(stringResult.scheme(), scheme);
- QCOMPARE(stringResult.path(), path);
- QCOMPARE(stringResult.toEncoded(), encoded);
- }
-}
-
-void tst_qdeclarativeproperty::variantMapHandling_data()
-{
- QTest::addColumn<QVariantMap>("vm");
-
- // Object literals
- {
- QVariantMap m;
- QTest::newRow("{}") << m;
- }
- {
- QVariantMap m;
- m["a"] = QVariantMap();
- QTest::newRow("{ a:{} }") << m;
- }
- {
- QVariantMap m, m2;
- m2["b"] = 10;
- m2["c"] = 20;
- m["a"] = m2;
- QTest::newRow("{ a:{b:10, c:20} }") << m;
- }
- {
- QVariantMap m;
- m["a"] = 10;
- m["b"] = QVariantList() << 20 << 30;
- QTest::newRow("{ a:10, b:[20, 30]}") << m;
- }
-
- // Cyclic objects
- {
- QVariantMap m;
- m["p"] = QVariantMap();
- QTest::newRow("var o={}; o.p=o") << m;
- }
- {
- QVariantMap m;
- m["p"] = 123;
- m["q"] = QVariantMap();
- QTest::newRow("var o={}; o.p=123; o.q=o") << m;
- }
-}
-
-void tst_qdeclarativeproperty::variantMapHandling()
-{
- QFETCH(QVariantMap, vm);
-
- PropertyObject o;
- QDeclarativeProperty p(&o, "variantMap");
-
- QCOMPARE(p.write(vm), true);
- QCOMPARE(o.variantMap(), vm);
-}
-
-void tst_qdeclarativeproperty::crashOnValueProperty()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
- QDeclarativeComponent component(engine);
-
- component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
- PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
- QVERIFY(obj != 0);
-
- QDeclarativeProperty p(obj, "wrectProperty.x", qmlContext(obj));
- QCOMPARE(p.name(), QString("wrectProperty.x"));
-
- QCOMPARE(p.read(), QVariant(10));
-
- //don't crash once the engine is deleted
- delete engine;
- engine = 0;
-
- QCOMPARE(p.propertyTypeName(), "int");
- QCOMPARE(p.read(), QVariant(10));
- p.write(QVariant(20));
- QCOMPARE(p.read(), QVariant(20));
-}
-
-// QTBUG-13719
-void tst_qdeclarativeproperty::aliasPropertyBindings()
-{
- QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyBindings.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("realProperty").toReal(), 90.);
- QCOMPARE(object->property("aliasProperty").toReal(), 90.);
-
- object->setProperty("test", 10);
-
- QCOMPARE(object->property("realProperty").toReal(), 110.);
- QCOMPARE(object->property("aliasProperty").toReal(), 110.);
-
- QDeclarativeProperty realProperty(object, QLatin1String("realProperty"));
- QDeclarativeProperty aliasProperty(object, QLatin1String("aliasProperty"));
-
- // Check there is a binding on these two properties
- QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
-
- // Check that its the same binding on these two properties
- QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
- QDeclarativePropertyPrivate::binding(aliasProperty));
-
- // Change the binding
- object->setProperty("state", QString("switch"));
-
- QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
- QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
- QDeclarativePropertyPrivate::binding(aliasProperty));
-
- QCOMPARE(object->property("realProperty").toReal(), 96.);
- QCOMPARE(object->property("aliasProperty").toReal(), 96.);
-
- // Check the old binding really has not effect any more
- object->setProperty("test", 4);
-
- QCOMPARE(object->property("realProperty").toReal(), 96.);
- QCOMPARE(object->property("aliasProperty").toReal(), 96.);
-
- object->setProperty("test2", 9);
-
- QCOMPARE(object->property("realProperty").toReal(), 288.);
- QCOMPARE(object->property("aliasProperty").toReal(), 288.);
-
- // Revert
- object->setProperty("state", QString(""));
-
- QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
- QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
- QDeclarativePropertyPrivate::binding(aliasProperty));
-
- QCOMPARE(object->property("realProperty").toReal(), 20.);
- QCOMPARE(object->property("aliasProperty").toReal(), 20.);
-
- object->setProperty("test2", 3);
-
- QCOMPARE(object->property("realProperty").toReal(), 20.);
- QCOMPARE(object->property("aliasProperty").toReal(), 20.);
-
- delete object;
-}
-
-void tst_qdeclarativeproperty::copy()
-{
- PropertyObject object;
-
- QDeclarativeProperty *property = new QDeclarativeProperty(&object, QLatin1String("defaultProperty"));
- QCOMPARE(property->name(), QString("defaultProperty"));
- QCOMPARE(property->read(), QVariant(10));
- QCOMPARE(property->type(), QDeclarativeProperty::Property);
- QCOMPARE(property->propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(property->propertyType(), (int)QVariant::Int);
-
- QDeclarativeProperty p1(*property);
- QCOMPARE(p1.name(), QString("defaultProperty"));
- QCOMPARE(p1.read(), QVariant(10));
- QCOMPARE(p1.type(), QDeclarativeProperty::Property);
- QCOMPARE(p1.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(p1.propertyType(), (int)QVariant::Int);
-
- QDeclarativeProperty p2(&object, QLatin1String("url"));
- QCOMPARE(p2.name(), QString("url"));
- p2 = *property;
- QCOMPARE(p2.name(), QString("defaultProperty"));
- QCOMPARE(p2.read(), QVariant(10));
- QCOMPARE(p2.type(), QDeclarativeProperty::Property);
- QCOMPARE(p2.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(p2.propertyType(), (int)QVariant::Int);
-
- delete property; property = 0;
-
- QCOMPARE(p1.name(), QString("defaultProperty"));
- QCOMPARE(p1.read(), QVariant(10));
- QCOMPARE(p1.type(), QDeclarativeProperty::Property);
- QCOMPARE(p1.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(p1.propertyType(), (int)QVariant::Int);
-
- QCOMPARE(p2.name(), QString("defaultProperty"));
- QCOMPARE(p2.read(), QVariant(10));
- QCOMPARE(p2.type(), QDeclarativeProperty::Property);
- QCOMPARE(p2.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(p2.propertyType(), (int)QVariant::Int);
-}
-
-void tst_qdeclarativeproperty::noContext()
-{
- QDeclarativeComponent compA(&engine, testFileUrl("NoContextTypeA.qml"));
- QDeclarativeComponent compB(&engine, testFileUrl("NoContextTypeB.qml"));
-
- QObject *a = compA.create();
- QVERIFY(a != 0);
- QObject *b = compB.create();
- QVERIFY(b != 0);
-
- QVERIFY(QDeclarativeProperty::write(b, "myTypeA", QVariant::fromValue(a), &engine));
-
- delete a;
- delete b;
-}
-
-void tst_qdeclarativeproperty::assignEmptyVariantMap()
-{
- PropertyObject o;
-
- QVariantMap map;
- map.insert("key", "value");
- o.setVariantMap(map);
- QCOMPARE(o.variantMap().count(), 1);
- QCOMPARE(o.variantMap().isEmpty(), false);
-
- QDeclarativeContext context(&engine);
- context.setContextProperty("o", &o);
-
- QDeclarativeComponent component(&engine, testFileUrl("assignEmptyVariantMap.qml"));
- QObject *obj = component.create(&context);
- QVERIFY(obj);
-
- QCOMPARE(o.variantMap().count(), 0);
- QCOMPARE(o.variantMap().isEmpty(), true);
-
- delete obj;
-}
-
-void tst_qdeclarativeproperty::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<MyQmlObject>("Test",1,0,"MyQmlObject");
- qmlRegisterType<PropertyObject>("Test",1,0,"PropertyObject");
- qmlRegisterType<MyContainer>("Test",1,0,"MyContainer");
-}
-
-QTEST_MAIN(tst_qdeclarativeproperty)
-
-#include "tst_qdeclarativeproperty.moc"
diff --git a/tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro b/tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro
deleted file mode 100644
index 4b47a2cae9..0000000000
--- a/tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepropertycache
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepropertycache.cpp
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private testlib v8-private
diff --git a/tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp b/tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp
deleted file mode 100644
index 495f8a5f20..0000000000
--- a/tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <private/qdeclarativepropertycache_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativepropertycache : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativepropertycache() {}
-
-private slots:
- void properties();
- void propertiesDerived();
- void methods();
- void methodsDerived();
- void signalHandlers();
- void signalHandlersDerived();
-
-private:
- QDeclarativeEngine engine;
-};
-
-class BaseObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int propertyA READ propertyA NOTIFY propertyAChanged)
- Q_PROPERTY(QString propertyB READ propertyB NOTIFY propertyBChanged)
-public:
- BaseObject(QObject *parent = 0) : QObject(parent) {}
-
- int propertyA() const { return 0; }
- QString propertyB() const { return QString(); }
-
-public Q_SLOTS:
- void slotA() {}
-
-Q_SIGNALS:
- void propertyAChanged();
- void propertyBChanged();
- void signalA();
-};
-
-class DerivedObject : public BaseObject
-{
- Q_OBJECT
- Q_PROPERTY(int propertyC READ propertyC NOTIFY propertyCChanged)
- Q_PROPERTY(QString propertyD READ propertyD NOTIFY propertyDChanged)
-public:
- DerivedObject(QObject *parent = 0) : BaseObject(parent) {}
-
- int propertyC() const { return 0; }
- QString propertyD() const { return QString(); }
-
-public Q_SLOTS:
- void slotB() {}
-
-Q_SIGNALS:
- void propertyCChanged();
- void propertyDChanged();
- void signalB();
-};
-
-void tst_qdeclarativepropertycache::properties()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(new QDeclarativePropertyCache(&engine, metaObject));
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("propertyA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyC")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyD")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
-}
-
-void tst_qdeclarativepropertycache::propertiesDerived()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> parentCache(new QDeclarativePropertyCache(&engine, &BaseObject::staticMetaObject));
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(parentCache->copy());
- cache->append(&engine, object.metaObject());
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("propertyA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyC")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyD")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
-}
-
-void tst_qdeclarativepropertycache::methods()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(new QDeclarativePropertyCache(&engine, metaObject));
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("slotA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
-
- QVERIFY(data = cache->property(QLatin1String("slotB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
-
- QVERIFY(data = cache->property(QLatin1String("signalA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
-
- QVERIFY(data = cache->property(QLatin1String("signalB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
-}
-
-void tst_qdeclarativepropertycache::methodsDerived()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> parentCache(new QDeclarativePropertyCache(&engine, &BaseObject::staticMetaObject));
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(parentCache->copy());
- cache->append(&engine, object.metaObject());
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("slotA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
-
- QVERIFY(data = cache->property(QLatin1String("slotB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
-
- QVERIFY(data = cache->property(QLatin1String("signalA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
-
- QVERIFY(data = cache->property(QLatin1String("signalB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
-}
-
-void tst_qdeclarativepropertycache::signalHandlers()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(new QDeclarativePropertyCache(&engine, metaObject));
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("onSignalA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
-
- QVERIFY(data = cache->property(QLatin1String("onSignalB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
-}
-
-void tst_qdeclarativepropertycache::signalHandlersDerived()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> parentCache(new QDeclarativePropertyCache(&engine, &BaseObject::staticMetaObject));
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(parentCache->copy());
- cache->append(&engine, object.metaObject());
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("onSignalA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
-
- QVERIFY(data = cache->property(QLatin1String("onSignalB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
-}
-
-QTEST_MAIN(tst_qdeclarativepropertycache)
-
-#include "tst_qdeclarativepropertycache.moc"
diff --git a/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro b/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
deleted file mode 100644
index f94405c770..0000000000
--- a/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepropertymap
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepropertymap.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp b/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp
deleted file mode 100644
index 32c2e79b8b..0000000000
--- a/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativepropertymap.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QSignalSpy>
-
-class tst_QDeclarativePropertyMap : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarativePropertyMap() {}
-
-private slots:
- void insert();
- void operatorInsert();
- void operatorValue();
- void clear();
- void changed();
- void count();
-
- void crashBug();
- void QTBUG_17868();
-};
-
-void tst_QDeclarativePropertyMap::insert()
-{
- QDeclarativePropertyMap map;
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(map.contains(QLatin1String("key1")));
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
-
- map.insert(QLatin1String("key1"),"Hello World");
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-
- //inserting property names same with existing method(signal, slot, method) names is not allowed
- //QDeclarativePropertyMap has an invokable keys() method
- QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols. ");
- map.insert(QLatin1String("keys"), 1);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(!map.contains(QLatin1String("keys")));
- QVERIFY(map.value(QLatin1String("keys")).isNull());
-
- //QDeclarativePropertyMap has a deleteLater() slot
- QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols. ");
- map.insert(QLatin1String("deleteLater"), 1);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(!map.contains(QLatin1String("deleteLater")));
- QVERIFY(map.value(QLatin1String("deleteLater")).isNull());
-
- //QDeclarativePropertyMap has an valueChanged() signal
- QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols. ");
- map.insert(QLatin1String("valueChanged"), 1);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(!map.contains(QLatin1String("valueChanged")));
- QVERIFY(map.value(QLatin1String("valueChanged")).isNull());
-
- //but 'valueChange' should be ok
- map.insert(QLatin1String("valueChange"), 1);
- QVERIFY(map.keys().count() == 3);
- QVERIFY(map.contains(QLatin1String("valueChange")));
- QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1));
-
- //'valueCHANGED' should be ok, too
- map.insert(QLatin1String("valueCHANGED"), 1);
- QVERIFY(map.keys().count() == 4);
- QVERIFY(map.contains(QLatin1String("valueCHANGED")));
- QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1));
-}
-
-void tst_QDeclarativePropertyMap::operatorInsert()
-{
- QDeclarativePropertyMap map;
- map[QLatin1String("key1")] = 100;
- map[QLatin1String("key2")] = 200;
- QVERIFY(map.keys().count() == 2);
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
-
- map[QLatin1String("key1")] = "Hello World";
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-}
-
-void tst_QDeclarativePropertyMap::operatorValue()
-{
- QDeclarativePropertyMap map;
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QVERIFY(map.count() == 2);
- QVERIFY(map.contains(QLatin1String("key1")));
-
- const QDeclarativePropertyMap &constMap = map;
-
- QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200));
- QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1")));
- QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2")));
-}
-
-void tst_QDeclarativePropertyMap::clear()
-{
- QDeclarativePropertyMap map;
- map.insert(QLatin1String("key1"),100);
- QVERIFY(map.keys().count() == 1);
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
-
- map.clear(QLatin1String("key1"));
- QVERIFY(map.keys().count() == 1);
- QVERIFY(map.contains(QLatin1String("key1")));
- QCOMPARE(map.value(QLatin1String("key1")), QVariant());
-}
-
-void tst_QDeclarativePropertyMap::changed()
-{
- QDeclarativePropertyMap map;
- QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&, const QVariant&)));
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QCOMPARE(spy.count(), 0);
-
- map.clear(QLatin1String("key1"));
- QCOMPARE(spy.count(), 0);
-
- //make changes in QML
- QDeclarativeEngine engine;
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty(QLatin1String("testdata"), &map);
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
- QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
- QQuickText *txt = qobject_cast<QQuickText*>(component.create());
- QVERIFY(txt);
- QCOMPARE(txt->text(), QString('X'));
- QCOMPARE(spy.count(), 1);
- QList<QVariant> arguments = spy.takeFirst();
- QCOMPARE(arguments.count(), 2);
- QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
- QCOMPARE(arguments.at(1).value<QVariant>(),QVariant("Hello World"));
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-}
-
-void tst_QDeclarativePropertyMap::count()
-{
- QDeclarativePropertyMap map;
- QCOMPARE(map.isEmpty(), true);
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QCOMPARE(map.count(), 2);
- QCOMPARE(map.isEmpty(), false);
-
- map.insert(QLatin1String("key3"),"Hello World");
- QCOMPARE(map.count(), 3);
-
- //clearing doesn't remove the key
- map.clear(QLatin1String("key3"));
- QCOMPARE(map.count(), 3);
- QCOMPARE(map.size(), map.count());
-}
-
-void tst_QDeclarativePropertyMap::crashBug()
-{
- QDeclarativePropertyMap map;
-
- QDeclarativeEngine engine;
- QDeclarativeContext context(&engine);
- context.setContextProperty("map", &map);
-
- QDeclarativeComponent c(&engine);
- c.setData("import QtQuick 2.0\nBinding { target: map; property: \"myProp\"; value: 10 + 23 }",QUrl());
- QObject *obj = c.create(&context);
- delete obj;
-}
-
-void tst_QDeclarativePropertyMap::QTBUG_17868()
-{
- QDeclarativePropertyMap map;
-
- QDeclarativeEngine engine;
- QDeclarativeContext context(&engine);
- context.setContextProperty("map", &map);
- map.insert("key", 1);
- QDeclarativeComponent c(&engine);
- c.setData("import QtQuick 2.0\nItem {property bool error:false; Component.onCompleted: {try{ map.keys(); }catch(e) {error=true;}}}",QUrl());
- QObject *obj = c.create(&context);
- QVERIFY(obj);
- QVERIFY(!obj->property("error").toBool());
- delete obj;
-
-}
-
-QTEST_MAIN(tst_QDeclarativePropertyMap)
-
-#include "tst_qdeclarativepropertymap.moc"
diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
deleted file mode 100644
index 5ed808831c..0000000000
--- a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeqt
-SOURCES += tst_qdeclarativeqt.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
deleted file mode 100644
index c88e56476e..0000000000
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ /dev/null
@@ -1,732 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <private/qdeclarativeengine_p.h>
-
-#include <qtest.h>
-#include <QDebug>
-#include <QDeclarativeEngine>
-#include <QFontDatabase>
-#include <QFileInfo>
-#include <QDeclarativeComponent>
-#include <QDesktopServices>
-#include <QDir>
-#include <QVector3D>
-#include <QCryptographicHash>
-#include <QtQuick/QQuickItem>
-#include <QSignalSpy>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeqt : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeqt() {}
-
-private slots:
- void enums();
- void rgba();
- void hsla();
- void rect();
- void point();
- void size();
- void vector();
- void vector4d();
- void lighter();
- void darker();
- void tint();
- void openUrlExternally();
- void openUrlExternally_pragmaLibrary();
- void md5();
- void createComponent();
- void createComponent_pragmaLibrary();
- void createQmlObject();
- void dateTimeConversion();
- void dateTimeFormatting();
- void dateTimeFormatting_data();
- void dateTimeFormattingVariants();
- void dateTimeFormattingVariants_data();
- void isQtObject();
- void btoa();
- void atob();
- void fontFamilies();
- void quit();
- void resolvedUrl();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeqt::enums()
-{
- QDeclarativeComponent component(&engine, testFileUrl("enums.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), (int)Qt::Key_Escape);
- QCOMPARE(object->property("test2").toInt(), (int)Qt::DescendingOrder);
- QCOMPARE(object->property("test3").toInt(), (int)Qt::ElideMiddle);
- QCOMPARE(object->property("test4").toInt(), (int)Qt::AlignRight);
-
- delete object;
-}
-
-void tst_qdeclarativeqt::rgba()
-{
- QDeclarativeComponent component(&engine, testFileUrl("rgba.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromRgbF(0, 0, 0, 0));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::hsla()
-{
- QDeclarativeComponent component(&engine, testFileUrl("hsla.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHslF(1, 1, 1, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromHslF(0, 0, 0, 0));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::rect()
-{
- QDeclarativeComponent component(&engine, testFileUrl("rect.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QRectF>(object->property("test1")), QRectF(10, 13, 100, 109));
- QCOMPARE(qvariant_cast<QRectF>(object->property("test2")), QRectF(-10, 13, 100, 109.6));
- QCOMPARE(qvariant_cast<QRectF>(object->property("test3")), QRectF());
- QCOMPARE(qvariant_cast<QRectF>(object->property("test4")), QRectF());
- QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF(10, 13, 100, -109));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::point()
-{
- QDeclarativeComponent component(&engine, testFileUrl("point.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QPointF>(object->property("test1")), QPointF(19, 34));
- QCOMPARE(qvariant_cast<QPointF>(object->property("test2")), QPointF(-3, 109.2));
- QCOMPARE(qvariant_cast<QPointF>(object->property("test3")), QPointF());
- QCOMPARE(qvariant_cast<QPointF>(object->property("test4")), QPointF());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::size()
-{
- QDeclarativeComponent component(&engine, testFileUrl("size.qml"));
-
- QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments";
- QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test1")), QSizeF(19, 34));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test2")), QSizeF(3, 109.2));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test3")), QSizeF(-3, 10));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test4")), QSizeF());
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test5")), QSizeF());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::vector()
-{
- QDeclarativeComponent component(&engine, testFileUrl("vector.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9));
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1));
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test3")), QVector3D());
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test4")), QVector3D());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::vector4d()
-{
- QDeclarativeComponent component(&engine, testFileUrl("vector4.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QVector4D>(object->property("test1")), QVector4D(1, 0, 0.9, 0.6));
- QCOMPARE(qvariant_cast<QVector4D>(object->property("test2")), QVector4D(102, -10, -982.1, 10));
- QCOMPARE(qvariant_cast<QVector4D>(object->property("test3")), QVector4D());
- QCOMPARE(qvariant_cast<QVector4D>(object->property("test4")), QVector4D());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::lighter()
-{
- QDeclarativeComponent component(&engine, testFileUrl("lighter.qml"));
-
- QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments";
- QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::darker()
-{
- QDeclarativeComponent component(&engine, testFileUrl("darker.qml"));
-
- QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments";
- QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280));
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::tint()
-{
- QDeclarativeComponent component(&engine, testFileUrl("tint.qml"));
-
- QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments";
- QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments";
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(0, 0, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0, 0));
- QColor test3 = qvariant_cast<QColor>(object->property("test3"));
- QCOMPARE(test3.rgba(), 0xFF7F0080);
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
-
- delete object;
-}
-
-class MyUrlHandler : public QObject
-{
- Q_OBJECT
-public:
- MyUrlHandler() : called(0) { }
- int called;
- QUrl last;
-
-public slots:
- void noteCall(const QUrl &url) { called++; last = url; }
-};
-
-void tst_qdeclarativeqt::openUrlExternally()
-{
- MyUrlHandler handler;
-
- QDesktopServices::setUrlHandler("test", &handler, "noteCall");
- QDesktopServices::setUrlHandler("file", &handler, "noteCall");
-
- QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(handler.called,1);
- QCOMPARE(handler.last, QUrl("test:url"));
-
- object->setProperty("testFile", true);
-
- QCOMPARE(handler.called,2);
- QCOMPARE(handler.last, testFileUrl("test.html"));
-
- QDesktopServices::unsetUrlHandler("test");
- QDesktopServices::unsetUrlHandler("file");
-}
-
-void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary()
-{
- MyUrlHandler handler;
-
- QDesktopServices::setUrlHandler("test", &handler, "noteCall");
- QDesktopServices::setUrlHandler("file", &handler, "noteCall");
-
- QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally_lib.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(handler.called,1);
- QCOMPARE(handler.last, QUrl("test:url"));
-
- object->setProperty("testFile", true);
-
- QCOMPARE(handler.called,2);
- QCOMPARE(handler.last, testFileUrl("test.html"));
-
- QDesktopServices::unsetUrlHandler("test");
- QDesktopServices::unsetUrlHandler("file");
-}
-
-void tst_qdeclarativeqt::md5()
-{
- QDeclarativeComponent component(&engine, testFileUrl("md5.qml"));
-
- QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::createComponent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("createComponent.qml"));
-
- QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments";
- QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
- QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::createComponent_pragmaLibrary()
-{
- // Currently, just loading createComponent_lib.qml causes crash on some platforms
- QDeclarativeComponent component(&engine, testFileUrl("createComponent_lib.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready));
- QCOMPARE(object->property("readValue").toInt(), int(1913));
- delete object;
-}
-
-void tst_qdeclarativeqt::createQmlObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("createQmlObject.qml"));
-
- QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments";
- QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":2:10: Blah is not a type";
- QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("main.qml").toString() + ":4:14: Duplicate property name";
- QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object";
- QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments";
- QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":3: Cannot assign object type QObject with no default method";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
- QTest::ignoreMessage(QtDebugMsg, qPrintable(warning6));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("emptyArg").toBool(), true);
- QCOMPARE(object->property("success").toBool(), true);
-
- QQuickItem *item = qobject_cast<QQuickItem *>(object);
- QVERIFY(item != 0);
- QVERIFY(item->childItems().count() == 1);
-
- delete object;
-}
-
-
-void tst_qdeclarativeqt::dateTimeConversion()
-{
- QDate date(2008,12,24);
- QTime time(14,15,38,200);
- QDateTime dateTime(date, time);
- //Note that when converting Date to QDateTime they can argue over historical DST data when converting to local time.
- //Tests should use UTC or recent dates.
- QDateTime dateTime2(QDate(2852,12,31), QTime(23,59,59,500));
- QDateTime dateTime3(QDate(2000,1,1), QTime(0,0,0,0));
- QDateTime dateTime4(QDate(2001,2,2), QTime(0,0,0,0));
- QDateTime dateTime5(QDate(1999,1,1), QTime(2,3,4,0));
- QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200));
-
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("dateTimeConversion.qml"));
- QObject *obj = component.create();
-
- QCOMPARE(obj->property("qdate").toDate(), date);
- QCOMPARE(obj->property("qtime").toTime(), time);
- QCOMPARE(obj->property("qdatetime").toDateTime(), dateTime);
- QCOMPARE(obj->property("qdatetime2").toDateTime(), dateTime2);
- QCOMPARE(obj->property("qdatetime3").toDateTime(), dateTime3);
- QCOMPARE(obj->property("qdatetime4").toDateTime(), dateTime4);
- QCOMPARE(obj->property("qdatetime5").toDateTime(), dateTime5);
- QCOMPARE(obj->property("qdatetime6").toDateTime(), dateTime6);
-}
-
-void tst_qdeclarativeqt::dateTimeFormatting()
-{
- QFETCH(QString, method);
- QFETCH(QStringList, inputProperties);
- QFETCH(QStringList, expectedResults);
-
- QDate date(2008,12,24);
- QTime time(14,15,38,200);
- QDateTime dateTime(date, time);
-
- QDeclarativeEngine eng;
-
- eng.rootContext()->setContextProperty("qdate", date);
- eng.rootContext()->setContextProperty("qtime", time);
- eng.rootContext()->setContextProperty("qdatetime", dateTime);
-
- QDeclarativeComponent component(&eng, testFileUrl("formatting.qml"));
-
- QStringList warnings;
- warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
- << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments"
- << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format"
- << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments"
- << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format"
- << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments";
-
- foreach (const QString &warning, warnings)
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
- QVERIFY(object != 0);
-
- QVERIFY(inputProperties.count() > 0);
- QVariant result;
- foreach(const QString &prop, inputProperties) {
- QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(),
- Q_RETURN_ARG(QVariant, result),
- Q_ARG(QVariant, prop)));
- QStringList output = result.toStringList();
- QCOMPARE(output.size(), expectedResults.size());
- for (int i=0; i<output.count(); i++)
- QCOMPARE(output[i], expectedResults[i]);
- }
-
- delete object;
-}
-
-void tst_qdeclarativeqt::dateTimeFormatting_data()
-{
- QTest::addColumn<QString>("method");
- QTest::addColumn<QStringList>("inputProperties");
- QTest::addColumn<QStringList>("expectedResults");
-
- QDate date(2008,12,24);
- QTime time(14,15,38,200);
- QDateTime dateTime(date, time);
-
- QTest::newRow("formatDate")
- << "formatDate"
- << (QStringList() << "dateFromString" << "jsdate" << "qdate" << "qdatetime")
- << (QStringList() << date.toString(Qt::DefaultLocaleShortDate)
- << date.toString(Qt::DefaultLocaleLongDate)
- << date.toString("ddd MMMM d yy"));
-
- QTest::newRow("formatTime")
- << "formatTime"
- << (QStringList() << "jsdate" << "qtime" << "qdatetime")
- << (QStringList() << time.toString(Qt::DefaultLocaleShortDate)
- << time.toString(Qt::DefaultLocaleLongDate)
- << time.toString("H:m:s a")
- << time.toString("hh:mm:ss.zzz"));
-
- QTest::newRow("formatDateTime")
- << "formatDateTime"
- << (QStringList() << "jsdate" << "qdatetime")
- << (QStringList() << dateTime.toString(Qt::DefaultLocaleShortDate)
- << dateTime.toString(Qt::DefaultLocaleLongDate)
- << dateTime.toString("M/d/yy H:m:s a"));
-}
-
-void tst_qdeclarativeqt::dateTimeFormattingVariants()
-{
- QFETCH(QString, method);
- QFETCH(QVariant, variant);
- QFETCH(QStringList, expectedResults);
-
- QDeclarativeEngine eng;
- eng.rootContext()->setContextProperty("qvariant", variant);
- QDeclarativeComponent component(&eng, testFileUrl("formatting.qml"));
-
- QStringList warnings;
- warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
- << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments"
- << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format"
- << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments"
- << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format"
- << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments";
-
- foreach (const QString &warning, warnings)
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
- QVERIFY(object != 0);
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(),
- Q_RETURN_ARG(QVariant, result),
- Q_ARG(QVariant, QString(QLatin1String("qvariant")))));
- QStringList output = result.toStringList();
- QCOMPARE(output, expectedResults);
-
- delete object;
-}
-
-void tst_qdeclarativeqt::dateTimeFormattingVariants_data()
-{
- QTest::addColumn<QString>("method");
- QTest::addColumn<QVariant>("variant");
- QTest::addColumn<QStringList>("expectedResults");
-
- QDateTime temporary;
-
- QTime time(11, 16, 39, 755);
- temporary = QDateTime(QDate(1970,1,1), time);
- QTest::newRow("formatDate, qtime") << "formatDate" << QVariant::fromValue(time) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qtime") << "formatDateTime" << QVariant::fromValue(time) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qtime") << "formatTime" << QVariant::fromValue(time) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- QDate date(2011,5,31);
- temporary = QDateTime(date);
- QTest::newRow("formatDate, qdate") << "formatDate" << QVariant::fromValue(date) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qdate") << "formatDateTime" << QVariant::fromValue(date) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qdate") << "formatTime" << QVariant::fromValue(date) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- QDateTime dateTime(date, time);
- temporary = dateTime;
- QTest::newRow("formatDate, qdatetime") << "formatDate" << QVariant::fromValue(dateTime) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qdatetime") << "formatDateTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qdatetime") << "formatTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- QString string(QLatin1String("2011/05/31 11:16:39.755"));
- temporary = QDateTime::fromString(string, "yyyy/MM/dd HH:mm:ss.zzz");
- QTest::newRow("formatDate, qstring") << "formatDate" << QVariant::fromValue(string) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qstring") << "formatDateTime" << QVariant::fromValue(string) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qstring") << "formatTime" << QVariant::fromValue(string) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- QColor color(Qt::red);
- temporary = QVariant::fromValue(color).toDateTime();
- QTest::newRow("formatDate, qcolor") << "formatDate" << QVariant::fromValue(color) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qcolor") << "formatDateTime" << QVariant::fromValue(color) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qcolor") << "formatTime" << QVariant::fromValue(color) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- int integer(4);
- temporary = QVariant::fromValue(integer).toDateTime();
- QTest::newRow("formatDate, int") << "formatDate" << QVariant::fromValue(integer) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, int") << "formatDateTime" << QVariant::fromValue(integer) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, int") << "formatTime" << QVariant::fromValue(integer) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-}
-
-void tst_qdeclarativeqt::isQtObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("isQtObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), false);
- QCOMPARE(object->property("test3").toBool(), false);
- QCOMPARE(object->property("test4").toBool(), false);
- QCOMPARE(object->property("test5").toBool(), false);
-
- delete object;
-}
-
-void tst_qdeclarativeqt::btoa()
-{
- QDeclarativeComponent component(&engine, testFileUrl("btoa.qml"));
-
- QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test2").toString(), QString("SGVsbG8gd29ybGQh"));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::atob()
-{
- QDeclarativeComponent component(&engine, testFileUrl("atob.qml"));
-
- QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test2").toString(), QString("Hello world!"));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::fontFamilies()
-{
- QDeclarativeComponent component(&engine, testFileUrl("fontFamilies.qml"));
-
- QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QFontDatabase database;
- QCOMPARE(object->property("test2"), QVariant::fromValue(database.families()));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::quit()
-{
- QDeclarativeComponent component(&engine, testFileUrl("quit.qml"));
-
- QSignalSpy spy(&engine, SIGNAL(quit()));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(spy.count(), 1);
-
- delete object;
-}
-
-void tst_qdeclarativeqt::resolvedUrl()
-{
- QDeclarativeComponent component(&engine, testFileUrl("resolvedUrl.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("result").toString(), component.url().toString());
- QCOMPARE(object->property("isString").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativeqt)
-
-#include "tst_qdeclarativeqt.moc"
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro
deleted file mode 100644
index cc27d173ab..0000000000
--- a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativesqldatabase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesqldatabase.cpp
-
-include (../../shared/util.pri)
-
-CONFIG += parallel_test
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private v8-private declarative-private quick-private sql testlib
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp b/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp
deleted file mode 100644
index cf4daed2f9..0000000000
--- a/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <QtCore/qcryptographichash.h>
-/*
-#include <QtWebKit/qwebpage.h>
-#include <QtWebKit/qwebframe.h>
-#include <QtWebKit/qwebdatabase.h>
-#include <QtWebKit/qwebsecurityorigin.h>
-*/
-#include <QtSql/qsqldatabase.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfile.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativesqldatabase : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativesqldatabase()
- {
- qApp->setApplicationName("tst_qdeclarativesqldatabase");
- qApp->setOrganizationName("Nokia");
- qApp->setOrganizationDomain("nokia.com");
- engine = new QDeclarativeEngine;
- }
-
- ~tst_qdeclarativesqldatabase()
- {
- delete engine;
- }
-
-private slots:
- void initTestCase();
-
- void checkDatabasePath();
-
- void testQml_data();
- void testQml();
- void testQml_cleanopen_data();
- void testQml_cleanopen();
- void totalDatabases();
-
- void cleanupTestCase();
-
-private:
- QString dbDir() const;
- QDeclarativeEngine *engine;
-};
-
-void removeRecursive(const QString& dirname)
-{
- QDir dir(dirname);
- QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
- for (int i = 0; i < entries.count(); ++i)
- if (entries[i].isDir())
- removeRecursive(entries[i].filePath());
- else
- dir.remove(entries[i].fileName());
- QDir().rmdir(dirname);
-}
-
-void tst_qdeclarativesqldatabase::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- removeRecursive(dbDir());
- QDir().mkpath(dbDir());
-}
-
-void tst_qdeclarativesqldatabase::cleanupTestCase()
-{
- removeRecursive(dbDir());
-}
-
-QString tst_qdeclarativesqldatabase::dbDir() const
-{
- static QString tmpd = QDir::tempPath()+"/tst_qdeclarativesqldatabase_output-"
- + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
- return tmpd;
-}
-
-void tst_qdeclarativesqldatabase::checkDatabasePath()
-{
- // Check default storage path (we can't use it since we don't want to mess with user's data)
- QVERIFY(engine->offlineStoragePath().contains("tst_qdeclarativesqldatabase"));
- QVERIFY(engine->offlineStoragePath().contains("OfflineStorage"));
-}
-
-static const int total_databases_created_by_tests = 12;
-void tst_qdeclarativesqldatabase::testQml_data()
-{
- QTest::addColumn<QString>("jsfile"); // The input file
-
- // Each test should use a newly named DB to avoid inter-test dependencies
- QTest::newRow("creation") << "creation.js";
- QTest::newRow("creation-a") << "creation-a.js";
- QTest::newRow("creation") << "creation.js";
- QTest::newRow("error-creation") << "error-creation.js"; // re-uses above DB
- QTest::newRow("changeversion") << "changeversion.js";
- QTest::newRow("readonly") << "readonly.js";
- QTest::newRow("readonly-error") << "readonly-error.js";
- QTest::newRow("selection") << "selection.js";
- QTest::newRow("selection-bindnames") << "selection-bindnames.js";
- QTest::newRow("iteration") << "iteration.js";
- QTest::newRow("iteration-forwardonly") << "iteration-forwardonly.js";
- QTest::newRow("error-a") << "error-a.js";
- QTest::newRow("error-notransaction") << "error-notransaction.js";
- QTest::newRow("error-outsidetransaction") << "error-outsidetransaction.js"; // reuse above
- QTest::newRow("reopen1") << "reopen1.js";
- QTest::newRow("reopen2") << "reopen2.js"; // re-uses above DB
-
- // If you add a test, you should usually use a new database in the
- // test - in which case increment total_databases_created_by_tests above.
-}
-
-/*
-class QWebPageWithJavaScriptConsoleMessages : public QWebPage {
-public:
- void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
- {
- qWarning() << sourceID << ":" << lineNumber << ":" << message;
- }
-};
-
-void tst_qdeclarativesqldatabase::validateAgainstWebkit()
-{
- // Validates tests against WebKit (HTML5) support.
- //
- QFETCH(QString, jsfile);
- QFETCH(QString, result);
- QFETCH(int, databases);
-
- QFile f(jsfile);
- QVERIFY(f.open(QIODevice::ReadOnly));
- QString js=f.readAll();
-
- QWebPageWithJavaScriptConsoleMessages webpage;
- webpage.settings()->setOfflineStoragePath(dbDir());
- webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
-
- QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue);
- QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result);
-
- QTest::qWait(100); // WebKit crashes if you quit it too fast
-
- QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin();
- QList<QWebDatabase> dbs = origin.databases();
- QCOMPARE(dbs.count(), databases);
-}
-*/
-
-void tst_qdeclarativesqldatabase::testQml()
-{
- // Tests QML SQL Database support with tests
- // that have been validated against Webkit.
- //
- QFETCH(QString, jsfile);
-
- QString qml=
- "import QtQuick 2.0\n"
- "import \""+jsfile+"\" as JS\n"
- "Text { text: JS.test() }";
-
- engine->setOfflineStoragePath(dbDir());
- QDeclarativeComponent component(engine);
- component.setData(qml.toUtf8(), testFileUrl("empty.qml")); // just a file for relative local imports
- QVERIFY(!component.isError());
- QQuickText *text = qobject_cast<QQuickText*>(component.create());
- QVERIFY(text != 0);
- QCOMPARE(text->text(),QString("passed"));
-}
-
-void tst_qdeclarativesqldatabase::testQml_cleanopen_data()
-{
- QTest::addColumn<QString>("jsfile"); // The input file
- QTest::newRow("reopen1") << "reopen1.js";
- QTest::newRow("reopen2") << "reopen2.js";
- QTest::newRow("error-creation") << "error-creation.js"; // re-uses creation DB
-}
-
-void tst_qdeclarativesqldatabase::testQml_cleanopen()
-{
- // Same as testQml, but clean connections between tests,
- // making it more like the tests are running in new processes.
- testQml();
-
- engine->collectGarbage();
-
- foreach (QString dbname, QSqlDatabase::connectionNames()) {
- QSqlDatabase::removeDatabase(dbname);
- }
-}
-
-void tst_qdeclarativesqldatabase::totalDatabases()
-{
- QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2);
-}
-
-QTEST_MAIN(tst_qdeclarativesqldatabase)
-
-#include "tst_qdeclarativesqldatabase.moc"
diff --git a/tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro b/tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro
deleted file mode 100644
index d6f067e440..0000000000
--- a/tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativetranslation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativetranslation.cpp
-RESOURCES += data/translation.qrc
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp b/tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp
deleted file mode 100644
index ced1478649..0000000000
--- a/tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QTranslator>
-#include "../../shared/util.h"
-
-class tst_qdeclarativetranslation : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativetranslation() {}
-
-private slots:
- void translation();
- void idTranslation();
- void translationInQrc();
-};
-
-void tst_qdeclarativetranslation::translation()
-{
- QTranslator translator;
- translator.load(QLatin1String("qml_fr"), dataDirectory());
- QCoreApplication::installTranslator(&translator);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("translation.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir"));
- QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut"));
- QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard"));
- QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut"));
- QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir"));
- QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard"));
- QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard"));
- QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards"));
- QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards"));
-
- QCoreApplication::removeTranslator(&translator);
- delete object;
-}
-
-void tst_qdeclarativetranslation::idTranslation()
-{
- QTranslator translator;
- translator.load(QLatin1String("qmlid_fr"), dataDirectory());
- QCoreApplication::installTranslator(&translator);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("idtranslation.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("idTranslation").toString(), QLatin1String("bonjour tout le monde"));
- QCOMPARE(object->property("idTranslation2").toString(), QLatin1String("bonjour tout le monde"));
- QCOMPARE(object->property("idTranslation3").toString(), QLatin1String("bonjour tout le monde"));
-
- QCoreApplication::removeTranslator(&translator);
- delete object;
-}
-
-void tst_qdeclarativetranslation::translationInQrc()
-{
- QTranslator translator;
- translator.load(":/qml_fr.qm");
- QCoreApplication::installTranslator(&translator);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:/translation.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir"));
- QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut"));
- QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard"));
- QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut"));
- QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir"));
- QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard"));
- QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard"));
- QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards"));
- QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards"));
-
- QCoreApplication::removeTranslator(&translator);
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativetranslation)
-
-#include "tst_qdeclarativetranslation.moc"
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
deleted file mode 100644
index 2968c8812b..0000000000
--- a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativevaluetypes
-macx:CONFIG -= app_bundle
-
-HEADERS += testtypes.h
-
-SOURCES += tst_qdeclarativevaluetypes.cpp \
- testtypes.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
deleted file mode 100644
index ff0e84ceaf..0000000000
--- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QObject>
-#include <QPoint>
-#include <QPointF>
-#include <QSize>
-#include <QSizeF>
-#include <QRect>
-#include <QRectF>
-#include <QVector2D>
-#include <QVector3D>
-#include <QVector4D>
-#include <QQuaternion>
-#include <QMatrix4x4>
-#include <QFont>
-#include <QColor>
-#include <qdeclarative.h>
-#include <QDeclarativePropertyValueSource>
-#include <QDeclarativeProperty>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativepropertyvalueinterceptor_p.h>
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed)
- Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed)
- Q_PROPERTY(QPointF pointfpoint READ pointfpoint WRITE setPointfpoint NOTIFY changed)
- Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed)
- Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed)
- Q_PROPERTY(QSizeF sizefsize READ sizefsize WRITE setSizefsize NOTIFY changed)
- Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed)
- Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed)
- Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed)
- Q_PROPERTY(QRectF rectfrect READ rectfrect WRITE setRectfrect NOTIFY changed)
- Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed)
- Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed)
- Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed)
- Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed)
- Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed)
- Q_PROPERTY(QVariant variant READ variant NOTIFY changed)
-
-public:
- MyTypeObject() :
- m_point(10, 4),
- m_pointf(11.3, -10.9),
- m_pointfpoint(10.0, 4.0),
- m_size(1912, 1913),
- m_sizef(0.1, 100923.2),
- m_sizefsize(1912.0, 1913.0),
- m_rect(2, 3, 109, 102),
- m_rectf(103.8, 99.2, 88.1, 77.6),
- m_rectfrect(2.0, 3.0, 109.0, 102.0),
- m_vector2(32.88, 1.3),
- m_vector(23.88, 3.1, 4.3),
- m_vector4(54.2, 23.88, 3.1, 4.3),
- m_quaternion(4.3, 54.2, 23.88, 3.1),
- m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
- {
- m_font.setFamily("Arial");
- m_font.setBold(true);
- m_font.setWeight(QFont::DemiBold);
- m_font.setItalic(true);
- m_font.setUnderline(true);
- m_font.setOverline(true);
- m_font.setStrikeOut(true);
- m_font.setPointSize(29);
- m_font.setCapitalization(QFont::AllLowercase);
- m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
- m_font.setWordSpacing(19.7);
- m_color.setRedF(0.2);
- m_color.setGreenF(0.88);
- m_color.setBlueF(0.6);
- m_color.setAlphaF(0.34);
- }
-
- QPoint m_point;
- QPoint point() const { return m_point; }
- void setPoint(const QPoint &v) { m_point = v; emit changed(); }
-
- QPointF m_pointf;
- QPointF pointf() const { return m_pointf; }
- void setPointf(const QPointF &v) { m_pointf = v; emit changed(); }
-
- QPointF m_pointfpoint;
- QPointF pointfpoint() const { return m_pointfpoint; }
- void setPointfpoint(const QPointF &v) { m_pointfpoint = v; emit changed(); }
-
- QSize m_size;
- QSize size() const { return m_size; }
- void setSize(const QSize &v) { m_size = v; emit changed(); }
-
- QSizeF m_sizef;
- QSizeF sizef() const { return m_sizef; }
- void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); }
-
- QSizeF m_sizefsize;
- QSizeF sizefsize() const { return m_sizefsize; }
- void setSizefsize(const QSizeF &v) { m_sizefsize = v; emit changed(); }
-
- QRect m_rect;
- QRect rect() const { return m_rect; }
- void setRect(const QRect &v) { m_rect = v; emit changed(); }
-
- QRectF m_rectf;
- QRectF rectf() const { return m_rectf; }
- void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
-
- QRectF m_rectfrect;
- QRectF rectfrect() const { return m_rectfrect; }
- void setRectfrect(const QRectF &v) { m_rectfrect = v; emit changed(); }
-
- QVector2D m_vector2;
- QVector2D vector2() const { return m_vector2; }
- void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); }
-
- QVector3D m_vector;
- QVector3D vector() const { return m_vector; }
- void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
-
- QVector4D m_vector4;
- QVector4D vector4() const { return m_vector4; }
- void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); }
-
- QQuaternion m_quaternion;
- QQuaternion quaternion() const { return m_quaternion; }
- void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); }
-
- QMatrix4x4 m_matrix;
- QMatrix4x4 matrix() const { return m_matrix; }
- void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); }
-
- QFont m_font;
- QFont font() const { return m_font; }
- void setFont(const QFont &v) { m_font = v; emit changed(); }
-
- QColor m_color;
- QColor color() const { return m_color; }
- void setColor(const QColor &v) { m_color = v; emit changed(); }
-
- QVariant variant() const { return sizef(); }
-
- void emitRunScript() { emit runScript(); }
-
-signals:
- void changed();
- void runScript();
-
-public slots:
- QSize method() { return QSize(13, 14); }
-};
-
-class MyConstantValueSource : public QObject, public QDeclarativePropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueSource)
-public:
- virtual void setTarget(const QDeclarativeProperty &p) { p.write(3345); }
-};
-
-class MyOffsetValueInterceptor : public QObject, public QDeclarativePropertyValueInterceptor
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueInterceptor)
-public:
- virtual void setTarget(const QDeclarativeProperty &p) { prop = p; }
- virtual void write(const QVariant &value) { QDeclarativePropertyPrivate::write(prop, value.toInt() + 13, QDeclarativePropertyPrivate::BypassInterceptor); }
-
-private:
- QDeclarativeProperty prop;
-};
-
-void registerTypes();
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
deleted file mode 100644
index 15001f70c8..0000000000
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ /dev/null
@@ -1,1319 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-#include <private/qdeclarativevaluetype_p.h>
-#include "../../shared/util.h"
-#include "testtypes.h"
-
-QT_BEGIN_NAMESPACE
-extern int qt_defaultDpi();
-QT_END_NAMESPACE
-
-class tst_qdeclarativevaluetypes : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativevaluetypes() {}
-
-private slots:
- void initTestCase();
-
- void point();
- void pointf();
- void size();
- void sizef();
- void sizereadonly();
- void rect();
- void rectf();
- void vector2d();
- void vector3d();
- void vector4d();
- void quaternion();
- void matrix4x4();
- void font();
- void color();
- void variant();
-
- void bindingAssignment();
- void bindingRead();
- void staticAssignment();
- void scriptAccess();
- void autoBindingRemoval();
- void valueSources();
- void valueInterceptors();
- void bindingConflict();
- void deletedObject();
- void bindingVariantCopy();
- void scriptVariantCopy();
- void cppClasses();
- void enums();
- void conflictingBindings();
- void returnValues();
- void varAssignment();
- void bindingsSpliceCorrectly();
- void nonValueTypeComparison();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativevaluetypes::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- registerTypes();
-}
-
-void tst_qdeclarativevaluetypes::point()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("point_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("p_x").toInt(), 10);
- QCOMPARE(object->property("p_y").toInt(), 4);
- QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("point_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->point(), QPoint(11, 12));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("point_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QPoint(10, 4)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), true);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("pointEqualsPointf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::pointf()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("pointf_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- 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;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("pointf_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("pointf_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QPointF(11.3, -10.9)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), true);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("pointfEqualsPoint").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::size()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("size_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("s_width").toInt(), 1912);
- QCOMPARE(object->property("s_height").toInt(), 1913);
- QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("size_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->size(), QSize(13, 88));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("size_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QSize(1912, 1913)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), true);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("sizeEqualsSizef").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::sizef()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizef_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- 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;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizef_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizef_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QSizeF(0.1, 100923)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), true);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("sizefEqualsSize").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::variant()
-{
- QDeclarativeComponent component(&engine, testFileUrl("variant_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- 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;
-}
-
-void tst_qdeclarativevaluetypes::sizereadonly()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("s_width").toInt(), 1912);
- QCOMPARE(object->property("s_height").toInt(), 1913);
- QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror2.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror3.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror4.qml"));
-
- QObject *object = component.create();
- QVERIFY(object);
-
- QCOMPARE(object->property("sizereadonly").toSize(), QSize(1912, 1913));
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::rect()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("rect_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("r_x").toInt(), 2);
- QCOMPARE(object->property("r_y").toInt(), 3);
- QCOMPARE(object->property("r_width").toInt(), 109);
- QCOMPARE(object->property("r_height").toInt(), 102);
- QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rect_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rect_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QRect(2, 3, 109, 102)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), true);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("rectEqualsRectf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::rectf()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("rectf_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- 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;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rectf_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rectf_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QRectF(103.8, 99.2, 88.1, 77.6)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), true);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("rectfEqualsRect").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::vector2d()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector2d_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_x").toDouble(), (float)32.88);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)1.3);
- QCOMPARE(object->property("copy"), QVariant(QVector2D(32.88, 1.3)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector2d_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->vector2(), QVector2D(-0.3, -12.9));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector2d_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QVector2D(32.88, 1.3)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::vector3d()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector3d_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1);
- QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3);
- QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector3d_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector3d_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QVector3D(23.88, 3.1, 4.3)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), true);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::vector4d()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector4d_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
- QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
- QCOMPARE((float)object->property("v_w").toDouble(), (float)4.3);
- QCOMPARE(object->property("copy"), QVariant(QVector4D(54.2, 23.88, 3.1, 4.3)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector4d_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->vector4(), QVector4D(-0.3, -12.9, 907.4, 88.5));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector4d_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QVector4D(54.2, 23.88, 3.1, 4.3)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::quaternion()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("quaternion_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_scalar").toDouble(), (float)4.3);
- QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
- QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
- QCOMPARE(object->property("copy"), QVariant(QQuaternion(4.3, 54.2, 23.88, 3.1)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("quaternion_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->quaternion(), QQuaternion(88.5, -0.3, -12.9, 907.4));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("quaternion_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QQuaternion(4.3, 54.2, 23.88, 3.1)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::matrix4x4()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_m11").toDouble(), (float)1);
- QCOMPARE((float)object->property("v_m12").toDouble(), (float)2);
- QCOMPARE((float)object->property("v_m13").toDouble(), (float)3);
- QCOMPARE((float)object->property("v_m14").toDouble(), (float)4);
- QCOMPARE((float)object->property("v_m21").toDouble(), (float)5);
- QCOMPARE((float)object->property("v_m22").toDouble(), (float)6);
- QCOMPARE((float)object->property("v_m23").toDouble(), (float)7);
- QCOMPARE((float)object->property("v_m24").toDouble(), (float)8);
- QCOMPARE((float)object->property("v_m31").toDouble(), (float)9);
- QCOMPARE((float)object->property("v_m32").toDouble(), (float)10);
- QCOMPARE((float)object->property("v_m33").toDouble(), (float)11);
- QCOMPARE((float)object->property("v_m34").toDouble(), (float)12);
- QCOMPARE((float)object->property("v_m41").toDouble(), (float)13);
- QCOMPARE((float)object->property("v_m42").toDouble(), (float)14);
- QCOMPARE((float)object->property("v_m43").toDouble(), (float)15);
- QCOMPARE((float)object->property("v_m44").toDouble(), (float)16);
- QCOMPARE(object->property("copy"),
- QVariant(QMatrix4x4(1, 2, 3, 4,
- 5, 6, 7, 8,
- 9, 10, 11, 12,
- 13, 14, 15, 16)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->matrix(), QMatrix4x4(11, 12, 13, 14,
- 21, 22, 23, 24,
- 31, 32, 33, 34,
- 41, 42, 43, 44));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::font()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("f_family").toString(), object->font().family());
- QCOMPARE(object->property("f_bold").toBool(), object->font().bold());
- QCOMPARE(object->property("f_weight").toInt(), object->font().weight());
- QCOMPARE(object->property("f_italic").toBool(), object->font().italic());
- QCOMPARE(object->property("f_underline").toBool(), object->font().underline());
- QCOMPARE(object->property("f_overline").toBool(), object->font().overline());
- QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut());
- QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF());
- QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.)));
- QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization());
- QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing());
- QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing());
-
- QCOMPARE(object->property("copy"), QVariant(object->font()));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QFont font;
- font.setFamily("Helvetica");
- font.setBold(false);
- font.setWeight(QFont::Normal);
- font.setItalic(false);
- font.setUnderline(false);
- font.setStrikeOut(false);
- font.setPointSize(15);
- font.setCapitalization(QFont::AllLowercase);
- font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
- font.setWordSpacing(11.2);
-
- QFont f = object->font();
- QCOMPARE(f.family(), font.family());
- QCOMPARE(f.bold(), font.bold());
- QCOMPARE(f.weight(), font.weight());
- QCOMPARE(f.italic(), font.italic());
- QCOMPARE(f.underline(), font.underline());
- QCOMPARE(f.strikeOut(), font.strikeOut());
- QCOMPARE(f.pointSize(), font.pointSize());
- QCOMPARE(f.capitalization(), font.capitalization());
- QCOMPARE(f.letterSpacing(), font.letterSpacing());
- QCOMPARE(f.wordSpacing(), font.wordSpacing());
-
- delete object;
- }
-
- // Test pixelSize
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->font().pixelSize(), 10);
-
- delete object;
- }
-
- // Test pixelSize and pointSize
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.3.qml"));
- QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->font().pixelSize(), 10);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.4.qml"));
- QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->font().pixelSize(), 10);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.5.qml"));
- QObject *object = qobject_cast<QObject *>(component.create());
- QVERIFY(object != 0);
- MyTypeObject *object1 = object->findChild<MyTypeObject *>("object1");
- QVERIFY(object1 != 0);
- MyTypeObject *object2 = object->findChild<MyTypeObject *>("object2");
- QVERIFY(object2 != 0);
-
- QCOMPARE(object1->font().pixelSize(), 19);
- QCOMPARE(object2->font().pointSize(), 14);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QFont(") + object->font().toString() + QLatin1Char(')');
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::color()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("color_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_r").toDouble(), (float)0.2);
- QCOMPARE((float)object->property("v_g").toDouble(), (float)0.88);
- QCOMPARE((float)object->property("v_b").toDouble(), (float)0.6);
- QCOMPARE((float)object->property("v_a").toDouble(), (float)0.34);
- QColor comparison;
- comparison.setRedF(0.2);
- comparison.setGreenF(0.88);
- comparison.setBlueF(0.6);
- comparison.setAlphaF(0.34);
- QCOMPARE(object->property("copy"), QVariant(comparison));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("color_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QColor newColor;
- newColor.setRedF(0.5);
- newColor.setGreenF(0.38);
- newColor.setBlueF(0.3);
- newColor.setAlphaF(0.7);
- QCOMPARE(object->color(), newColor);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("color_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QString colorString("#33e199");
- QCOMPARE(object->property("colorToString").toString(), colorString);
- QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true);
- QCOMPARE(object->property("colorEqualsDifferentAlpha").toBool(), false);
- QCOMPARE(object->property("colorEqualsDifferentRgba").toBool(), false);
- QCOMPARE(object->property("colorToStringEqualsColorString").toBool(), true);
- QCOMPARE(object->property("colorToStringEqualsDifferentAlphaString").toBool(), true);
- QCOMPARE(object->property("colorToStringEqualsDifferentRgbaString").toBool(), false);
- QCOMPARE(object->property("colorEqualsColorString").toBool(), true); // maintaining behaviour with QtQuick 1.0
- QCOMPARE(object->property("colorEqualsDifferentAlphaString").toBool(), true); // maintaining behaviour with QtQuick 1.0
- QCOMPARE(object->property("colorEqualsDifferentRgbaString").toBool(), false);
-
- QCOMPARE(object->property("equalsColor").toBool(), true);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
-
- // Color == Property and Property == Color should return the same result.
- QCOMPARE(object->property("equalsColorRHS").toBool(), object->property("equalsColor").toBool());
- QCOMPARE(object->property("colorEqualsCopy").toBool(), true);
- QCOMPARE(object->property("copyEqualsColor").toBool(), object->property("colorEqualsCopy").toBool());
-
- delete object;
- }
-}
-
-// Test bindings can write to value types
-void tst_qdeclarativevaluetypes::bindingAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingAssignment.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(92));
-
- QCOMPARE(object->rect().x(), 92);
-
- delete object;
-}
-
-// Test bindings can read from value types
-void tst_qdeclarativevaluetypes::bindingRead()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingRead.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 2);
-
- object->setRect(QRect(19, 3, 88, 2));
-
- QCOMPARE(object->property("value").toInt(), 19);
-
- delete object;
-}
-
-// Test static values can assign to value types
-void tst_qdeclarativevaluetypes::staticAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("staticAssignment.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 9);
-
- delete object;
-}
-
-// Test scripts can read/write value types
-void tst_qdeclarativevaluetypes::scriptAccess()
-{
- QDeclarativeComponent component(&engine, testFileUrl("scriptAccess.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("valuePre").toInt(), 2);
- QCOMPARE(object->rect().x(), 19);
- QCOMPARE(object->property("valuePost").toInt(), 19);
-
- delete object;
-}
-
-// Test that assigning a constant from script removes any binding
-void tst_qdeclarativevaluetypes::autoBindingRemoval()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(13));
-
- QCOMPARE(object->rect().x(), 13);
-
- object->emitRunScript();
-
- QCOMPARE(object->rect().x(), 42);
-
- object->setProperty("value", QVariant(92));
-
- QCOMPARE(object->rect().x(), 42);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(13));
-
- QCOMPARE(object->rect().x(), 13);
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
-
- object->setProperty("value", QVariant(92));
-
- QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml"));
- QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QRect";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- object->setProperty("value", QVariant(QRect(9, 22, 33, 44)));
-
- QCOMPARE(object->rect(), QRect(9, 22, 33, 44));
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
-
- object->setProperty("value", QVariant(QRect(19, 3, 4, 8)));
-
- QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
-
- delete object;
- }
-}
-
-// Test that property value sources assign to value types
-void tst_qdeclarativevaluetypes::valueSources()
-{
- QDeclarativeComponent component(&engine, testFileUrl("valueSources.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 3345);
-
- delete object;
-}
-
-static void checkNoErrors(QDeclarativeComponent& component)
-{
- QList<QDeclarativeError> errors = component.errors();
- if (errors.isEmpty())
- return;
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QDeclarativeError &error = errors.at(ii);
- qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
- }
-}
-
-// Test that property value interceptors can be applied to value types
-void tst_qdeclarativevaluetypes::valueInterceptors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("valueInterceptors.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- checkNoErrors(component);
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 13);
-
- object->setProperty("value", 99);
-
- QCOMPARE(object->rect().x(), 112);
-
- delete object;
-}
-
-// Test that you can't assign a binding to the "root" value type, and a sub-property
-void tst_qdeclarativevaluetypes::bindingConflict()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingConflict.qml"));
- QCOMPARE(component.isError(), true);
-}
-
-#define CPP_TEST(type, v) \
-{ \
- type *t = new type; \
- QVariant value(v); \
- t->setValue(value); \
- QCOMPARE(t->value(), value); \
- delete t; \
-}
-
-// Test that accessing a reference to a valuetype after the owning object is deleted
-// doesn't crash
-void tst_qdeclarativevaluetypes::deletedObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deletedObject.qml"));
- QTest::ignoreMessage(QtDebugMsg, "Test: 2");
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QObject *dObject = qvariant_cast<QObject *>(object->property("object"));
- QVERIFY(dObject != 0);
- delete dObject;
-
- QTest::ignoreMessage(QtDebugMsg, "Test: undefined");
- object->emitRunScript();
-
- delete object;
-}
-
-// Test that value types can be assigned to another value type property in a binding
-void tst_qdeclarativevaluetypes::bindingVariantCopy()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingVariantCopy.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
-
- delete object;
-}
-
-// Test that value types can be assigned to another value type property in script
-void tst_qdeclarativevaluetypes::scriptVariantCopy()
-{
- QDeclarativeComponent component(&engine, testFileUrl("scriptVariantCopy.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(2, 3, 109, 102));
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
-
- delete object;
-}
-
-
-// Test that the value type classes can be used manually
-void tst_qdeclarativevaluetypes::cppClasses()
-{
- CPP_TEST(QDeclarativePointValueType, QPoint(19, 33));
- CPP_TEST(QDeclarativePointFValueType, QPointF(33.6, -23));
- CPP_TEST(QDeclarativeSizeValueType, QSize(-100, 18));
- CPP_TEST(QDeclarativeSizeFValueType, QSizeF(-100.7, 18.2));
- CPP_TEST(QDeclarativeRectValueType, QRect(13, 39, 10928, 88));
- CPP_TEST(QDeclarativeRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
- CPP_TEST(QDeclarativeVector2DValueType, QVector2D(19.7, 1002));
- CPP_TEST(QDeclarativeVector3DValueType, QVector3D(18.2, 19.7, 1002));
- CPP_TEST(QDeclarativeVector4DValueType, QVector4D(18.2, 19.7, 1002, 54));
- CPP_TEST(QDeclarativeQuaternionValueType, QQuaternion(18.2, 19.7, 1002, 54));
- CPP_TEST(QDeclarativeMatrix4x4ValueType,
- QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
- CPP_TEST(QDeclarativeFontValueType, QFont("Helvetica"));
-
-}
-
-void tst_qdeclarativevaluetypes::enums()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.1.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.3.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.4.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.5.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-}
-
-// Tests switching between "conflicting" bindings (eg. a binding on the core
-// property, to a binding on the value-type sub-property)
-void tst_qdeclarativevaluetypes::conflictingBindings()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("conflicting.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("conflicting.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("conflicting.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 24);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::returnValues()
-{
- QDeclarativeComponent component(&engine, testFileUrl("returnValues.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("size").toSize(), QSize(13, 14));
-
- delete object;
-}
-
-void tst_qdeclarativevaluetypes::varAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("varAssignment.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("x").toInt(), 1);
- QCOMPARE(object->property("y").toInt(), 2);
- QCOMPARE(object->property("z").toInt(), 3);
-
- delete object;
-}
-
-// Test bindings splice together correctly
-void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::nonValueTypeComparison()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nonValueTypeComparison.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativevaluetypes)
-
-#include "tst_qdeclarativevaluetypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
deleted file mode 100644
index 9e5cc43f20..0000000000
--- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeworkerscript
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeworkerscript.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
deleted file mode 100644
index 92e5df127a..0000000000
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfileinfo.h>
-#include <QtDeclarative/qjsengine.h>
-
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <private/qdeclarativeworkerscript_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include "../../shared/util.h"
-
-class tst_QDeclarativeWorkerScript : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QDeclarativeWorkerScript() {}
-private slots:
- void source();
- void messaging();
- void messaging_data();
- void messaging_sendQObjectList();
- void messaging_sendJsObject();
- void messaging_sendExternalObject();
- void script_with_pragma();
- void script_included();
- void scriptError_onLoad();
- void scriptError_onCall();
- void stressDispose();
-
-private:
- void waitForEchoMessage(QDeclarativeWorkerScript *worker) {
- QEventLoop loop;
- QVERIFY(connect(worker, SIGNAL(done()), &loop, SLOT(quit())));
- QTimer timer;
- timer.setSingleShot(true);
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- timer.start(10000);
- loop.exec();
- QVERIFY(timer.isActive());
- }
-
- QDeclarativeEngine m_engine;
-};
-
-void tst_QDeclarativeWorkerScript::source()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
- const QMetaObject *mo = worker->metaObject();
-
- QVariant value(100);
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
-
- QUrl source = testFileUrl("script_fixed_return.js");
- worker->setSource(source);
- QCOMPARE(worker->source(), source);
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), qVariantFromValue(QString("Hello_World")));
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::messaging()
-{
- QFETCH(QVariant, value);
-
- QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
-
- const QMetaObject *mo = worker->metaObject();
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::messaging_data()
-{
- QTest::addColumn<QVariant>("value");
-
- QTest::newRow("invalid") << QVariant();
- QTest::newRow("bool") << qVariantFromValue(true);
- QTest::newRow("int") << qVariantFromValue(1001);
- QTest::newRow("real") << qVariantFromValue(10334.375);
- QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!"));
- QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c"));
- QTest::newRow("date time") << qVariantFromValue(QDateTime::currentDateTime());
-#ifndef QT_NO_REGEXP
- // QtScript's QScriptValue -> QRegExp uses RegExp2 pattern syntax
- QTest::newRow("regexp") << qVariantFromValue(QRegExp("^\\d\\d?$", Qt::CaseInsensitive, QRegExp::RegExp2));
-#endif
-}
-
-void tst_QDeclarativeWorkerScript::messaging_sendQObjectList()
-{
- // Not allowed to send QObjects other than QDeclarativeWorkerListModelAgent
- // instances. If objects are sent in a list, they will be sent as 'undefined'
- // js values.
-
- QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QVariantList objects;
- for (int i=0; i<3; i++)
- objects << qVariantFromValue(new QObject(this));
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(objects))));
- waitForEchoMessage(worker);
-
- const QMetaObject *mo = worker->metaObject();
- QVariantList result = mo->property(mo->indexOfProperty("response")).read(worker).value<QVariantList>();
- QCOMPARE(result, (QVariantList() << QVariant() << QVariant() << QVariant()));
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- // Properties are in alphabetical order to enable string-based comparison after
- // QVariant roundtrip, since the properties will be stored in a QVariantMap.
- QString jsObject = "{'haste': 1125, 'name': 'zyz', 'spell power': 3101}";
-
- QVariantMap map;
- map.insert("haste", 1125);
- map.insert("name", "zyz");
- map.insert("spell power", 3101);
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(map))));
- waitForEchoMessage(worker);
-
- QVariant result = qVariantFromValue(false);
- QVERIFY(QMetaObject::invokeMethod(worker, "compareLiteralResponse", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, jsObject)));
- QVERIFY(result.toBool());
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::messaging_sendExternalObject()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("externalObjectWorker.qml"));
- QObject *obj = component.create();
- QVERIFY(obj);
- QMetaObject::invokeMethod(obj, "testExternalObject");
- QTest::qWait(100); // shouldn't crash.
- delete obj;
-}
-
-void tst_QDeclarativeWorkerScript::script_with_pragma()
-{
- QVariant value(100);
-
- QDeclarativeComponent component(&m_engine, testFileUrl("worker_pragma.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
-
- const QMetaObject *mo = worker->metaObject();
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::script_included()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker_include.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QString value("Hello");
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
-
- const QMetaObject *mo = worker->metaObject();
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World");
-
- qApp->processEvents();
- delete worker;
-}
-
-static QString qdeclarativeworkerscript_lastWarning;
-static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char *msg)
-{
- if (type == QtWarningMsg)
- qdeclarativeworkerscript_lastWarning = QString::fromUtf8(msg);
-}
-
-void tst_QDeclarativeWorkerScript::scriptError_onLoad()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onLoad.qml"));
-
- QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler);
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QTRY_COMPARE(qdeclarativeworkerscript_lastWarning,
- testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier"));
-
- qInstallMsgHandler(previousMsgHandler);
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::scriptError_onCall()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onCall.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler);
- QVariant value;
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
-
- QTRY_COMPARE(qdeclarativeworkerscript_lastWarning,
- testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData"));
-
- qInstallMsgHandler(previousMsgHandler);
- qApp->processEvents();
- delete worker;
-}
-
-// Rapidly create and destroy worker scripts to test resources are being disposed
-// in the correct isolate
-void tst_QDeclarativeWorkerScript::stressDispose()
-{
- for (int ii = 0; ii < 100; ++ii) {
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stressDispose.qml"));
- QObject *o = component.create();
- QVERIFY(o);
- delete o;
- }
-}
-
-QTEST_MAIN(tst_QDeclarativeWorkerScript)
-
-#include "tst_qdeclarativeworkerscript.moc"
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
deleted file mode 100644
index b8f09f8722..0000000000
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativexmlhttprequest
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-
-SOURCES += tst_qdeclarativexmlhttprequest.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
deleted file mode 100644
index f3c3b57725..0000000000
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
+++ /dev/null
@@ -1,1160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-#include <QScopedPointer>
-#include <QNetworkCookieJar>
-#include "testhttpserver.h"
-#include "../../shared/util.h"
-
-#define SERVER_PORT 14445
-
-class tst_qdeclarativexmlhttprequest : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativexmlhttprequest() {}
-
-private slots:
- void domExceptionCodes();
- void callbackException();
- void callbackException_data();
- void staticStateValues();
- void instanceStateValues();
- void constructor();
- void defaultState();
- void open();
- void open_data();
- void open_invalid_method();
- void open_sync();
- void open_arg_count();
- void setRequestHeader();
- void setRequestHeader_caseInsensitive();
- void setRequestHeader_unsent();
- void setRequestHeader_illegalName_data();
- void setRequestHeader_illegalName();
- void setRequestHeader_sent();
- void setRequestHeader_args();
- void send_unsent();
- void send_alreadySent();
- void send_ignoreData();
- void send_withdata();
- void send_withdata_data();
- void abort();
- void abort_unsent();
- void abort_opened();
- void getResponseHeader();
- void getResponseHeader_unsent();
- void getResponseHeader_sent();
- void getResponseHeader_args();
- void getAllResponseHeaders();
- void getAllResponseHeaders_unsent();
- void getAllResponseHeaders_sent();
- void getAllResponseHeaders_args();
- void status();
- void status_data();
- void statusText();
- void statusText_data();
- void responseText();
- void responseText_data();
- void responseXML_invalid();
- void invalidMethodUsage();
- void redirects();
- void nonUtf8();
- void nonUtf8_data();
-
- // Attributes
- void document();
- void element();
- void attr();
- void text();
- void cdata();
-
- // Crashes
- // void outstanding_request_at_shutdown();
-
- // void network_errors()
- // void readyState()
-
-private:
- QDeclarativeEngine engine;
-};
-
-// Test that the dom exception codes are correct
-void tst_qdeclarativexmlhttprequest::domExceptionCodes()
-{
- QDeclarativeComponent component(&engine, testFileUrl("domExceptionCodes.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("index_size_err").toInt(), 1);
- QCOMPARE(object->property("domstring_size_err").toInt(), 2);
- QCOMPARE(object->property("hierarchy_request_err").toInt(), 3);
- QCOMPARE(object->property("wrong_document_err").toInt(), 4);
- QCOMPARE(object->property("invalid_character_err").toInt(), 5);
- QCOMPARE(object->property("no_data_allowed_err").toInt(), 6);
- QCOMPARE(object->property("no_modification_allowed_err").toInt(), 7);
- QCOMPARE(object->property("not_found_err").toInt(), 8);
- QCOMPARE(object->property("not_supported_err").toInt(), 9);
- QCOMPARE(object->property("inuse_attribute_err").toInt(), 10);
- QCOMPARE(object->property("invalid_state_err").toInt(), 11);
- QCOMPARE(object->property("syntax_err").toInt(), 12);
- QCOMPARE(object->property("invalid_modification_err").toInt(), 13);
- QCOMPARE(object->property("namespace_err").toInt(), 14);
- QCOMPARE(object->property("invalid_access_err").toInt(), 15);
- QCOMPARE(object->property("validation_err").toInt(), 16);
- QCOMPARE(object->property("type_mismatch_err").toInt(), 17);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::callbackException_data()
-{
- QTest::addColumn<QString>("which");
- QTest::addColumn<int>("line");
-
- QTest::newRow("on-opened") << "1" << 15;
- QTest::newRow("on-loading") << "3" << 15;
- QTest::newRow("on-done") << "4" << 15;
-}
-
-void tst_qdeclarativexmlhttprequest::callbackException()
-{
- // Test exception reporting for exceptions thrown at various points.
-
- QFETCH(QString, which);
- QFETCH(int, line);
-
- QString expect = testFileUrl("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QDeclarativeComponent component(&engine, testFileUrl("callbackException.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- object->setProperty("which", which);
- component.completeCreate();
-
- QTRY_VERIFY(object->property("threw").toBool() == true);
-
- delete object;
-}
-
-// Test that the state value properties on the XMLHttpRequest constructor have the correct values.
-// ### WebKit does not do this, but it seems to fit the standard and QML better
-void tst_qdeclarativexmlhttprequest::staticStateValues()
-{
- QDeclarativeComponent component(&engine, testFileUrl("staticStateValues.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("unsent").toInt(), 0);
- QCOMPARE(object->property("opened").toInt(), 1);
- QCOMPARE(object->property("headers_received").toInt(), 2);
- QCOMPARE(object->property("loading").toInt(), 3);
- QCOMPARE(object->property("done").toInt(), 4);
-
- delete object;
-}
-
-// Test that the state value properties on instances have the correct values.
-void tst_qdeclarativexmlhttprequest::instanceStateValues()
-{
- QDeclarativeComponent component(&engine, testFileUrl("instanceStateValues.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("unsent").toInt(), 0);
- QCOMPARE(object->property("opened").toInt(), 1);
- QCOMPARE(object->property("headers_received").toInt(), 2);
- QCOMPARE(object->property("loading").toInt(), 3);
- QCOMPARE(object->property("done").toInt(), 4);
-
- delete object;
-}
-
-// Test calling constructor
-void tst_qdeclarativexmlhttprequest::constructor()
-{
- QDeclarativeComponent component(&engine, testFileUrl("constructor.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("calledAsConstructor").toBool(), true);
- QCOMPARE(object->property("calledAsFunction").toBool(), true);
-
- delete object;
-}
-
-// Test that all the properties are set correctly before any request is sent
-void tst_qdeclarativexmlhttprequest::defaultState()
-{
- QDeclarativeComponent component(&engine, testFileUrl("defaultState.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("readState").toInt(), 0);
- QCOMPARE(object->property("statusIsException").toBool(), true);
- QCOMPARE(object->property("statusTextIsException").toBool(), true);
- QCOMPARE(object->property("responseText").toString(), QString());
- QCOMPARE(object->property("responseXMLIsNull").toBool(), true);
-
- delete object;
-}
-
-// Test valid XMLHttpRequest.open() calls
-void tst_qdeclarativexmlhttprequest::open()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(QString, url);
- QFETCH(bool, remote);
-
- QScopedPointer<TestHTTPServer> server; // ensure deletion in case test fails
- if (remote) {
- server.reset(new TestHTTPServer(SERVER_PORT));
- QVERIFY(server->isValid());
- QVERIFY(server->wait(testFileUrl("open_network.expect"),
- testFileUrl("open_network.reply"),
- testFileUrl("testdocument.html")));
- }
-
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", url);
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::open_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<QString>("url");
- QTest::addColumn<bool>("remote");
-
- QTest::newRow("Relative url)") << testFileUrl("open.qml") << "testdocument.html" << false;
- QTest::newRow("Absolute url)") << testFileUrl("open.qml") << testFileUrl("testdocument.html").toString() << false;
- QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
-
- // ### Check that the username/password were sent to the server
- QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
-}
-
-// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
-void tst_qdeclarativexmlhttprequest::open_invalid_method()
-{
- QDeclarativeComponent component(&engine, testFileUrl("open_invalid_method.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Test that calling XMLHttpRequest.open() with sync raises an exception
-void tst_qdeclarativexmlhttprequest::open_sync()
-{
- QDeclarativeComponent component(&engine, testFileUrl("open_sync.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Calling with incorrect arg count raises an exception
-void tst_qdeclarativexmlhttprequest::open_arg_count()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("open_arg_count.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("open_arg_count.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
- }
-}
-
-// Test valid setRequestHeader() calls
-void tst_qdeclarativexmlhttprequest::setRequestHeader()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
- testFileUrl("setRequestHeader.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test valid setRequestHeader() calls with different header cases
-void tst_qdeclarativexmlhttprequest::setRequestHeader_caseInsensitive()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
- testFileUrl("setRequestHeader.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-// Test setting headers before open() throws exception
-void tst_qdeclarativexmlhttprequest::setRequestHeader_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName_data()
-{
- QTest::addColumn<QString>("name");
-
- QTest::newRow("Accept-Charset") << "AccePT-CHArset";
- QTest::newRow("Accept-Encoding") << "AccEpt-EnCOding";
- QTest::newRow("Connection") << "ConnECtion";
- QTest::newRow("Content-Length") << "ContEnt-LenGth";
- QTest::newRow("Cookie") << "CookIe";
- QTest::newRow("Cookie2") << "CoOkie2";
- QTest::newRow("Content-Transfer-Encoding") << "ConteNT-tRANSFER-eNCOding";
- QTest::newRow("Date") << "DaTE";
- QTest::newRow("Expect") << "ExPect";
- QTest::newRow("Host") << "HoST";
- QTest::newRow("Keep-Alive") << "KEEP-aLive";
- QTest::newRow("Referer") << "ReferEr";
- QTest::newRow("TE") << "Te";
- QTest::newRow("Trailer") << "TraILEr";
- QTest::newRow("Transfer-Encoding") << "tRANsfer-Encoding";
- QTest::newRow("Upgrade") << "UpgrADe";
- QTest::newRow("User-Agent") << "uSEr-Agent";
- QTest::newRow("Via") << "vIa";
- QTest::newRow("Proxy-") << "ProXy-";
- QTest::newRow("Sec-") << "SeC-";
- QTest::newRow("Proxy-*") << "Proxy-BLAH";
- QTest::newRow("Sec-*") << "Sec-F";
-}
-
-// Tests that using illegal header names has no effect
-void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName()
-{
- QFETCH(QString, name);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("open_network.expect"),
- testFileUrl("open_network.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("header", name);
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test that attempting to set a header after a request is sent throws an exception
-void tst_qdeclarativexmlhttprequest::setRequestHeader_sent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("open_network.expect"),
- testFileUrl("open_network.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_sent.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("test").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qdeclarativexmlhttprequest::setRequestHeader_args()
-{
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Test that calling send() in UNSENT state throws an exception
-void tst_qdeclarativexmlhttprequest::send_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("send_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test attempting to resend a sent request throws an exception
-void tst_qdeclarativexmlhttprequest::send_alreadySent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("send_alreadySent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test that sends for GET, HEAD and DELETE ignore data
-void tst_qdeclarativexmlhttprequest::send_ignoreData()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"),
- testFileUrl("send_ignoreData.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("reqType", "GET");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"),
- testFileUrl("send_ignoreData.reply"),
- QUrl()));
-
- QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("reqType", "HEAD");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"),
- testFileUrl("send_ignoreData.reply"),
- QUrl()));
-
- QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("reqType", "DELETE");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-}
-
-// Test that send()'ing data works
-void tst_qdeclarativexmlhttprequest::send_withdata()
-{
- QFETCH(QString, file_expected);
- QFETCH(QString, file_qml);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl(file_expected),
- testFileUrl("send_data.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl(file_qml));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::send_withdata_data()
-{
- QTest::addColumn<QString>("file_expected");
- QTest::addColumn<QString>("file_qml");
-
- QTest::newRow("No content-type") << "send_data.1.expect" << "send_data.1.qml";
- QTest::newRow("Correct content-type") << "send_data.1.expect" << "send_data.2.qml";
- QTest::newRow("Incorrect content-type") << "send_data.1.expect" << "send_data.3.qml";
- QTest::newRow("Correct content-type - out of order") << "send_data.4.expect" << "send_data.4.qml";
- QTest::newRow("Incorrect content-type - out of order") << "send_data.4.expect" << "send_data.5.qml";
- QTest::newRow("PUT") << "send_data.6.expect" << "send_data.6.qml";
- QTest::newRow("Correct content-type - no charset") << "send_data.1.expect" << "send_data.7.qml";
-}
-
-// Test abort() has no effect in unsent state
-void tst_qdeclarativexmlhttprequest::abort_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("abort_unsent.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test abort() cancels an open (but unsent) request
-void tst_qdeclarativexmlhttprequest::abort_opened()
-{
- QDeclarativeComponent component(&engine, testFileUrl("abort_opened.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test abort() aborts in progress send
-void tst_qdeclarativexmlhttprequest::abort()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("abort.expect"),
- testFileUrl("abort.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("abort.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("seenDone").toBool(), true);
- QCOMPARE(object->property("didNotSeeUnsent").toBool(), true);
- QCOMPARE(object->property("endStateUnsent").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::getResponseHeader()
-{
- QDeclarativeEngine engine; // Avoid cookie contamination
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
- testFileUrl("getResponseHeader.reply"),
- testFileUrl("testdocument.html")));
-
-
- QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("headersReceivedState").toBool(), true);
- QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedValidHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedMultiValidHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedCookieHeader").toBool(), true);
-
- QCOMPARE(object->property("doneState").toBool(), true);
- QCOMPARE(object->property("doneNullHeader").toBool(), true);
- QCOMPARE(object->property("doneValidHeader").toBool(), true);
- QCOMPARE(object->property("doneMultiValidHeader").toBool(), true);
- QCOMPARE(object->property("doneCookieHeader").toBool(), true);
-
- delete object;
-}
-
-// Test getResponseHeader throws an exception in an invalid state
-void tst_qdeclarativexmlhttprequest::getResponseHeader_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test getResponseHeader throws an exception in an invalid state
-void tst_qdeclarativexmlhttprequest::getResponseHeader_sent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_sent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qdeclarativexmlhttprequest::getResponseHeader_args()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::getAllResponseHeaders()
-{
- QDeclarativeEngine engine; // Avoid cookie contamination
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
- testFileUrl("getResponseHeader.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("headersReceivedState").toBool(), true);
- QCOMPARE(object->property("headersReceivedHeader").toBool(), true);
-
- QCOMPARE(object->property("doneState").toBool(), true);
- QCOMPARE(object->property("doneHeader").toBool(), true);
-
- delete object;
-}
-
-// Test getAllResponseHeaders throws an exception in an invalid state
-void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test getAllResponseHeaders throws an exception in an invalid state
-void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_sent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_sent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::status()
-{
- QFETCH(QUrl, replyUrl);
- QFETCH(int, status);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("status.expect"),
- replyUrl,
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("status.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", status);
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::status_data()
-{
- QTest::addColumn<QUrl>("replyUrl");
- QTest::addColumn<int>("status");
-
- QTest::newRow("OK") << testFileUrl("status.200.reply") << 200;
- QTest::newRow("Not Found") << testFileUrl("status.404.reply") << 404;
- QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << 400;
-}
-
-void tst_qdeclarativexmlhttprequest::statusText()
-{
- QFETCH(QUrl, replyUrl);
- QFETCH(QString, statusText);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("status.expect"),
- replyUrl,
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("statusText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", statusText);
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::statusText_data()
-{
- QTest::addColumn<QUrl>("replyUrl");
- QTest::addColumn<QString>("statusText");
-
- QTest::newRow("OK") << testFileUrl("status.200.reply") << "OK";
- QTest::newRow("Not Found") << testFileUrl("status.404.reply") << "Document not found";
- QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << "Bad request";
-}
-
-void tst_qdeclarativexmlhttprequest::responseText()
-{
- QFETCH(QUrl, replyUrl);
- QFETCH(QUrl, bodyUrl);
- QFETCH(QString, responseText);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("status.expect"),
- replyUrl,
- bodyUrl));
-
- QDeclarativeComponent component(&engine, testFileUrl("responseText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedText", responseText);
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsent").toBool(), true);
- QCOMPARE(object->property("opened").toBool(), true);
- QCOMPARE(object->property("sent").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("reset").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::responseText_data()
-{
- QTest::addColumn<QUrl>("replyUrl");
- QTest::addColumn<QUrl>("bodyUrl");
- QTest::addColumn<QString>("responseText");
-
- QTest::newRow("OK") << testFileUrl("status.200.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n";
- QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << "";
- QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
- QTest::newRow("Bad Request") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
-}
-
-void tst_qdeclarativexmlhttprequest::nonUtf8()
-{
- QFETCH(QString, fileName);
- QFETCH(QString, responseText);
- QFETCH(QString, xmlRootNodeValue);
-
- QDeclarativeComponent component(&engine, testFileUrl("utf16.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- object->setProperty("fileName", fileName);
- QMetaObject::invokeMethod(object, "startRequest");
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("responseText").toString(), responseText);
-
- if (!xmlRootNodeValue.isEmpty()) {
- QString rootNodeValue = object->property("responseXmlRootNodeValue").toString();
- QCOMPARE(rootNodeValue, xmlRootNodeValue);
- }
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::nonUtf8_data()
-{
- QTest::addColumn<QString>("fileName");
- QTest::addColumn<QString>("responseText");
- QTest::addColumn<QString>("xmlRootNodeValue");
-
- QString uc;
- uc.resize(3);
- uc[0] = QChar(0x10e3);
- uc[1] = QChar(' ');
- uc[2] = QChar(0x03a3);
-
- QTest::newRow("responseText") << "utf16.html" << uc + '\n' << "";
- QTest::newRow("responseXML") << "utf16.xml" << "<?xml version=\"1.0\" encoding=\"UTF-16\" standalone='yes'?>\n<root>\n" + uc + "\n</root>\n" << QString('\n' + uc + '\n');
-}
-
-// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
-// throws an exception
-void tst_qdeclarativexmlhttprequest::invalidMethodUsage()
-{
- QDeclarativeComponent component(&engine, testFileUrl("invalidMethodUsage.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QCOMPARE(object->property("open").toBool(), true);
- QCOMPARE(object->property("setRequestHeader").toBool(), true);
- QCOMPARE(object->property("send").toBool(), true);
- QCOMPARE(object->property("abort").toBool(), true);
- QCOMPARE(object->property("getResponseHeader").toBool(), true);
- QCOMPARE(object->property("getAllResponseHeaders").toBool(), true);
-
- delete object;
-}
-
-// Test that XMLHttpRequest transparently redirects
-void tst_qdeclarativexmlhttprequest::redirects()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("redirects.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("done").toBool() == true);
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("redirectError.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("done").toBool() == true);
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("redirectRecur.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- for (int ii = 0; ii < 60; ++ii) {
- if (object->property("done").toBool()) break;
- QTest::qWait(50);
- }
- QVERIFY(object->property("done").toBool() == true);
-
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativexmlhttprequest::responseXML_invalid()
-{
- QDeclarativeComponent component(&engine, testFileUrl("responseXML_invalid.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlNull").toBool(), true);
-
- delete object;
-}
-
-// Test the Document DOM element
-void tst_qdeclarativexmlhttprequest::document()
-{
- QDeclarativeComponent component(&engine, testFileUrl("document.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Element DOM element
-void tst_qdeclarativexmlhttprequest::element()
-{
- QDeclarativeComponent component(&engine, testFileUrl("element.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Attr DOM element
-void tst_qdeclarativexmlhttprequest::attr()
-{
- QDeclarativeComponent component(&engine, testFileUrl("attr.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Text DOM element
-void tst_qdeclarativexmlhttprequest::text()
-{
- QDeclarativeComponent component(&engine, testFileUrl("text.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the CDataSection DOM element
-void tst_qdeclarativexmlhttprequest::cdata()
-{
- QDeclarativeComponent component(&engine, testFileUrl("cdata.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativexmlhttprequest)
-
-#include "tst_qdeclarativexmlhttprequest.moc"
diff --git a/tests/auto/declarative/qjsengine/qjsengine.pro b/tests/auto/declarative/qjsengine/qjsengine.pro
deleted file mode 100644
index dd6234acd8..0000000000
--- a/tests/auto/declarative/qjsengine/qjsengine.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qjsengine
-QT += declarative widgets testlib
-macx:CONFIG -= app_bundle
-SOURCES += tst_qjsengine.cpp
-wince* {
- addFiles.files = script
- addFiles.path = .
- DEPLOYMENT += addFiles
- DEFINES += SRCDIR=\\\"./\\\"
-} else {
- DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
diff --git a/tests/auto/declarative/qjsvalue/qjsvalue.pro b/tests/auto/declarative/qjsvalue/qjsvalue.pro
deleted file mode 100644
index 3b40e92e67..0000000000
--- a/tests/auto/declarative/qjsvalue/qjsvalue.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qjsvalue
-macx:CONFIG -= app_bundle
-QT += declarative widgets testlib
-SOURCES += tst_qjsvalue.cpp
-HEADERS += tst_qjsvalue.h
diff --git a/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro b/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro
deleted file mode 100644
index 9f991c0ab6..0000000000
--- a/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qjsvalueiterator
-macx:CONFIG -= app_bundle
-QT = core declarative testlib
-SOURCES += tst_qjsvalueiterator.cpp
-
-
diff --git a/tests/auto/declarative/qmlmin/qmlmin.pro b/tests/auto/declarative/qmlmin/qmlmin.pro
deleted file mode 100644
index 61d2330b06..0000000000
--- a/tests/auto/declarative/qmlmin/qmlmin.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmlmin
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlmin.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
diff --git a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp b/tests/auto/declarative/qmlmin/tst_qmlmin.cpp
deleted file mode 100644
index df4e2a01dc..0000000000
--- a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-#include <QDir>
-#include <QProcess>
-#include <QDebug>
-#include <QDeclarativeError>
-#include <cstdlib>
-
-class tst_qmlmin : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlmin();
-
-private slots:
- void initTestCase();
- void qmlMinify_data();
- void qmlMinify();
-
-private:
- QString qmlminPath;
- QStringList excludedDirs;
- QStringList invalidFiles;
-
- QStringList findFiles(const QDir &);
- bool isInvalidFile(const QFileInfo &fileName) const;
-};
-
-tst_qmlmin::tst_qmlmin()
-{
-}
-
-void tst_qmlmin::initTestCase()
-{
- qmlminPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmlmin");
-#ifdef Q_OS_WIN
- qmlminPath += QLatin1String(".exe");
-#endif
- if (!QFileInfo(qmlminPath).exists()) {
- QString message = QString::fromLatin1("qmlmin executable not found (looked for %0)")
- .arg(qmlminPath);
- QFAIL(qPrintable(message));
- }
-
- // Add directories you want excluded here
-
- // These snippets are not expected to run on their own.
- excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/declarative/qtbinding";
- excludedDirs << "doc/src/snippets/declarative/imports";
- excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
- excludedDirs << "doc/src/snippets/qtquick1/imports";
-
- // Add invalid files (i.e. files with syntax errors)
- invalidFiles << "tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/property.4.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/empty.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js";
- invalidFiles << "tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js";
- invalidFiles << "tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js";
- invalidFiles << "tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js";
-}
-
-QStringList tst_qmlmin::findFiles(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return QStringList();
- }
-
- QStringList rv;
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"),
- QDir::Files);
- foreach (const QString &file, files) {
- rv << d.absoluteFilePath(file);
- }
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findFiles(sub);
- }
-
- return rv;
-}
-
-bool tst_qmlmin::isInvalidFile(const QFileInfo &fileName) const
-{
- foreach (const QString &invalidFile, invalidFiles) {
- if (fileName.absoluteFilePath().endsWith(invalidFile))
- return true;
- }
- return false;
-}
-
-/*
-This test runs all the examples in the declarative UI source tree and ensures
-that they start and exit cleanly.
-
-Examples are any .qml files under the examples/ directory that start
-with a lower case letter.
-*/
-
-void tst_qmlmin::qmlMinify_data()
-{
- QTest::addColumn<QString>("file");
-
- QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
- QString tests = QLatin1String(SRCDIR) + "/../../../../tests/";
-
- QStringList files;
- files << findFiles(QDir(examples));
- files << findFiles(QDir(tests));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_qmlmin::qmlMinify()
-{
- QFETCH(QString, file);
-
- QProcess qmlminify;
- qmlminify.start(qmlminPath, QStringList() << QLatin1String("--verify-only") << file);
- qmlminify.waitForFinished();
-
- QCOMPARE(qmlminify.error(), QProcess::UnknownError);
- QCOMPARE(qmlminify.exitStatus(), QProcess::NormalExit);
-
- if (isInvalidFile(file))
- QCOMPARE(qmlminify.exitCode(), EXIT_FAILURE); // cannot minify files with syntax errors
- else
- QCOMPARE(qmlminify.exitCode(), 0);
-}
-
-QTEST_MAIN(tst_qmlmin)
-
-#include "tst_qmlmin.moc"
diff --git a/tests/auto/declarative/runall.sh b/tests/auto/declarative/runall.sh
deleted file mode 100755
index 621791b6ab..0000000000
--- a/tests/auto/declarative/runall.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/bash
-#
-#############################################################################
-##
-## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: http://www.qt-project.org/
-##
-## This file is part of the test suite of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## GNU Lesser General Public License Usage
-## 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.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU General
-## Public License version 3.0 as published by the Free Software Foundation
-## and appearing in the file LICENSE.GPL included in the packaging of this
-## file. Please review the following information to ensure the GNU General
-## Public License version 3.0 requirements will be met:
-## http://www.gnu.org/copyleft/gpl.html.
-##
-## Other Usage
-## Alternatively, this file may be used in accordance with the terms and
-## conditions contained in a signed written agreement between you and Nokia.
-##
-##
-##
-##
-##
-##
-## $QT_END_LICENSE$
-##
-############################################################################/
-
-if [ "$(uname)" = Linux ]
-then
- Xnest :7 2>/dev/null &
- sleep 1
- trap "kill $!" EXIT
- export DISPLAY=:7
- export LANG=en_US
- kwin 2>/dev/null &
- sleep 1
-fi
-
-function filter
-{
- exe=$1
- skip=0
- while read line
- do
- if [ $skip != 0 ]
- then
- let skip=skip-1
- else
- case "$line" in
- make*Error) echo "$line";;
- make*Stop) echo "$line";;
- /*/bin/make*) ;;
- make*) ;;
- install*) ;;
- QDeclarativeDebugServer:*Waiting*) ;;
- QDeclarativeDebugServer:*Connection*) ;;
- */qmake*) ;;
- */bin/moc*) ;;
- *targ.debug*) ;;
- g++*) ;;
- cd*) ;;
- XFAIL*) skip=1;;
- SKIP*) skip=1;;
- PASS*) ;;
- QDEBUG*) ;;
- Makefile*) ;;
- Config*) ;;
- Totals*) ;;
- \**) ;;
- ./*) ;;
- *tst_*) echo "$line" ;;
- *) echo "$exe: $line"
- esac
- fi
- done
-}
-
-make -k -j1 install 2>&1 | filter build
-for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p')
-do
- echo $exe
- $exe 2>&1 | filter $exe
-done
-
diff --git a/tests/auto/declarative/v4/testtypes.cpp b/tests/auto/declarative/v4/testtypes.cpp
deleted file mode 100644
index 6bfd5dc43e..0000000000
--- a/tests/auto/declarative/v4/testtypes.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-
-#include <QtDeclarative/qdeclarative.h>
-
-void registerTypes()
-{
- qmlRegisterType<ResultObject>("Qt.v4", 1,0, "Result");
- qmlRegisterType<NestedObject>();
-}
diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp
deleted file mode 100644
index 99e3f3255f..0000000000
--- a/tests/auto/declarative/v4/tst_v4.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdir.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtCore/qdebug.h>
-#include <QtGui/qcolor.h>
-
-#include <private/qv4compiler_p.h>
-
-#include "../../shared/util.h"
-#include "testtypes.h"
-
-class tst_v4 : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_v4() {}
-
-private slots:
- void initTestCase();
-
- void unnecessaryReeval();
- void logicalOr();
- void nestedLogicalOr();
- void conditionalExpr();
- void qtscript();
- void qtscript_data();
- void nestedObjectAccess();
- void subscriptionsInConditionalExpressions();
- void qtbug_21883();
- void qtbug_22816();
- void stringComparison();
- void unaryMinus();
- void unaryPlus();
- void colorType();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_v4::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- registerTypes();
-}
-
-static int v4ErrorsMsgCount = 0;
-static void v4ErrorsMsgHandler(QtMsgType, const char *message)
-{
- QByteArray m(message);
- if (m.contains("QV4"))
- v4ErrorsMsgCount++;
-}
-
-void tst_v4::qtscript()
-{
- QFETCH(QString, file);
- QV4Compiler::enableBindingsTest(true);
-
- QDeclarativeComponent component(&engine, testFileUrl(file));
-
- v4ErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(v4ErrorsMsgHandler);
-
- QObject *o = component.create();
- delete o;
-
- qInstallMsgHandler(old);
-
- QCOMPARE(v4ErrorsMsgCount, 0);
-
- QV4Compiler::enableBindingsTest(false);
-}
-
-void tst_v4::qtscript_data()
-{
- QTest::addColumn<QString>("file");
-
- QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml";
- QTest::newRow("exception on fetch") << "fetchException.qml";
- QTest::newRow("logical or") << "logicalOr.qml";
- QTest::newRow("conditional expressions") << "conditionalExpr.qml";
- QTest::newRow("double bool jump") << "doubleBoolJump.qml";
- QTest::newRow("unary minus") << "unaryMinus.qml";
- QTest::newRow("null qobject") << "nullQObject.qml";
-}
-
-void tst_v4::unnecessaryReeval()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unnecessaryReeval.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->resultCounter(), 1);
- QCOMPARE(ro->result(), 19);
- ro->resetResultCounter();
-
- ro->setProperty("b", 6);
-
- QCOMPARE(ro->resultCounter(), 1);
- QCOMPARE(ro->result(), 6);
- ro->resetResultCounter();
-
- ro->setProperty("a", 14);
-
- QCOMPARE(ro->resultCounter(), 1);
- QCOMPARE(ro->result(), 7);
- ro->resetResultCounter();
-
- ro->setProperty("b", 14);
- QCOMPARE(ro->resultCounter(), 0);
- QCOMPARE(ro->result(), 7);
-
- delete o;
-}
-
-void tst_v4::logicalOr()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("logicalOr.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 0);
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("logicalOr.2.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 1);
- delete o;
- }
-}
-
-void tst_v4::nestedLogicalOr()
-{
- //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038)
- QDeclarativeComponent component(&engine, testFileUrl("nestedLogicalOr.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 1);
- delete o;
-}
-
-void tst_v4::conditionalExpr()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("conditionalExpr.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 0);
- delete o;
- }
-}
-
-// This would previously use the metaObject of the root element to result the nested access.
-// That is, the index for accessing "result" would have been RootObject::result, instead of
-// NestedObject::result.
-void tst_v4::nestedObjectAccess()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nestedObjectAccess.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 37);
-
- delete o;
-}
-
-void tst_v4::subscriptionsInConditionalExpressions()
-{
- QDeclarativeComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QObject *ro = qobject_cast<QObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->property("result").toReal(), qreal(2));
-
- delete o;
-}
-
-// Crash test
-void tst_v4::qtbug_21883()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_21883.qml"));
-
- QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- delete o;
-}
-
-void tst_v4::qtbug_22816()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_22816.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toBool(), false);
- QCOMPARE(o->property("test2").toBool(), false);
- delete o;
-}
-
-void tst_v4::stringComparison()
-{
- QDeclarativeComponent component(&engine, testFileUrl("stringComparison.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- QCOMPARE(o->property("test6").toBool(), true);
- QCOMPARE(o->property("test7").toBool(), true);
- QCOMPARE(o->property("test8").toBool(), true);
- QCOMPARE(o->property("test9").toBool(), true);
- QCOMPARE(o->property("test10").toBool(), true);
- QCOMPARE(o->property("test11").toBool(), true);
- QCOMPARE(o->property("test12").toBool(), true);
- QCOMPARE(o->property("test13").toBool(), true);
- QCOMPARE(o->property("test14").toBool(), true);
- QCOMPARE(o->property("test15").toBool(), true);
- QCOMPARE(o->property("test16").toBool(), true);
- QCOMPARE(o->property("test17").toBool(), true);
- QCOMPARE(o->property("test18").toBool(), true);
- QCOMPARE(o->property("test19").toBool(), true);
- QCOMPARE(o->property("test20").toBool(), true);
- QCOMPARE(o->property("test21").toBool(), true);
- QCOMPARE(o->property("test22").toBool(), true);
- delete o;
-}
-
-void tst_v4::unaryMinus()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unaryMinus.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toReal(), qreal(-18));
- QCOMPARE(o->property("test2").toInt(), -18);
- QCOMPARE(o->property("test3").toReal(), qreal(3.7));
- QCOMPARE(o->property("test4").toInt(), 4);
- QCOMPARE(o->property("test5").toReal(), qreal(3.3));
- QCOMPARE(o->property("test6").toInt(), 3);
- QCOMPARE(o->property("test7").toReal(), qreal(7));
- QCOMPARE(o->property("test8").toInt(), 7);
- QCOMPARE(o->property("test9").toReal(), qreal(-4.4));
- QCOMPARE(o->property("test10").toInt(), -4);
-
- delete o;
-}
-
-void tst_v4::unaryPlus()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unaryPlus.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toReal(), qreal(18));
- QCOMPARE(o->property("test2").toInt(), 18);
- QCOMPARE(o->property("test3").toReal(), qreal(-3.7));
- QCOMPARE(o->property("test4").toInt(), -4);
- QCOMPARE(o->property("test5").toReal(), qreal(-3.3));
- QCOMPARE(o->property("test6").toInt(), -3);
- QCOMPARE(o->property("test7").toReal(), qreal(-7));
- QCOMPARE(o->property("test8").toInt(), -7);
- QCOMPARE(o->property("test9").toReal(), qreal(4.4));
- QCOMPARE(o->property("test10").toInt(), 4);
-
- delete o;
-}
-
-void tst_v4::colorType()
-{
- QDeclarativeComponent component(&engine, testFileUrl("colorType.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").value<QColor>(), QColor("red"));
- QCOMPARE(o->property("test2").value<QColor>(), QColor("red"));
- QCOMPARE(o->property("test3").value<QColor>(), QColor("red"));
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- QCOMPARE(o->property("test6").toBool(), true);
- QCOMPARE(o->property("test7").toBool(), true);
- delete o;
-}
-
-QTEST_MAIN(tst_v4)
-
-#include "tst_v4.moc"
diff --git a/tests/auto/declarative/v4/v4.pro b/tests/auto/declarative/v4/v4.pro
deleted file mode 100644
index 81d12f89be..0000000000
--- a/tests/auto/declarative/v4/v4.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativev4
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_v4.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private network testlib
diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro
index 16802b7e06..4ce05fe512 100644
--- a/tests/auto/headersclean/headersclean.pro
+++ b/tests/auto/headersclean/headersclean.pro
@@ -3,4 +3,4 @@ TARGET = tst_headersclean
SOURCES += tst_headersclean.cpp
QT = core testlib
-contains(QT_CONFIG,declarative): QT += declarative declarative-private
+contains(QT_CONFIG,qml): QT += qml qml-private
diff --git a/tests/auto/headersclean/tst_headersclean.cpp b/tests/auto/headersclean/tst_headersclean.cpp
index 132eb90231..d5131f96cd 100644
--- a/tests/auto/headersclean/tst_headersclean.cpp
+++ b/tests/auto/headersclean/tst_headersclean.cpp
@@ -49,7 +49,7 @@
#include <QtCore/QtCore>
#include <QtTest/QtTest>
-#include <QtDeclarative/QtDeclarative>
+#include <QtQml/QtQml>
class tst_HeadersClean: public QObject
{
diff --git a/tests/auto/host.pro b/tests/auto/host.pro
index 6bc8753fb0..0a96ef0413 100644
--- a/tests/auto/host.pro
+++ b/tests/auto/host.pro
@@ -1,4 +1,9 @@
TEMPLATE=subdirs
-SUBDIRS=\
- headersclean \
+
+# FIXME
+# This test is crrently broken:
+#SUBDIRS=\
+ #headersclean \
+
+SUBDIRS=
diff --git a/tests/auto/particles/qquickage/qquickage.pro b/tests/auto/particles/qquickage/qquickage.pro
index 99c52dfdae..6616ec45ee 100644
--- a/tests/auto/particles/qquickage/qquickage.pro
+++ b/tests/auto/particles/qquickage/qquickage.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro b/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro
index 235f0d81b0..ac37973695 100644
--- a/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro
+++ b/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro b/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro
index 09fe1aa06a..42029ce721 100644
--- a/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro
+++ b/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro b/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro
index 6d3ecaa6f4..fdc2445bd1 100644
--- a/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro
+++ b/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro
index e9bcc1e373..a12c1af62c 100644
--- a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro
+++ b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro b/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro
index 803a366429..48d01201ce 100644
--- a/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro
+++ b/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickfriction/qquickfriction.pro b/tests/auto/particles/qquickfriction/qquickfriction.pro
index 889b2d9505..85b5263d36 100644
--- a/tests/auto/particles/qquickfriction/qquickfriction.pro
+++ b/tests/auto/particles/qquickfriction/qquickfriction.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickgravity/qquickgravity.pro b/tests/auto/particles/qquickgravity/qquickgravity.pro
index 3bdd8c1efa..5340b32cab 100644
--- a/tests/auto/particles/qquickgravity/qquickgravity.pro
+++ b/tests/auto/particles/qquickgravity/qquickgravity.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro b/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro
index 8e7d5ae021..623993c2de 100644
--- a/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro
+++ b/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private opengl-private testlib
diff --git a/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro b/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro
index fa43b28407..1241467ba1 100644
--- a/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro
+++ b/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro
@@ -7,4 +7,4 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro b/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro
index c36dabbc14..262ebdd5b2 100644
--- a/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro
+++ b/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro b/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro
index fae5203961..3b87f00320 100644
--- a/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro
+++ b/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro b/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro
index d82adf8b4a..33d6f2e41e 100644
--- a/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro
+++ b/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro b/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro
index 27547c16b1..594b704bd5 100644
--- a/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro
+++ b/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro b/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro
index 6fd13ec01e..ea5642aaa9 100644
--- a/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro
+++ b/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro b/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro
index a9d390aab8..4a93555f5c 100644
--- a/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro
+++ b/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro b/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro
index 04fe1617de..093e7a743f 100644
--- a/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro
+++ b/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro b/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro
index e45c43a587..1b5da6165c 100644
--- a/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro
+++ b/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro b/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro
index d335a91537..9908f220d2 100644
--- a/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro
+++ b/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private opengl-private testlib
diff --git a/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro b/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro
index 0a887d1fb3..226cd9d139 100644
--- a/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro
+++ b/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro
index 9139dd39fb..67b14c86c3 100644
--- a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro
+++ b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickturbulence/qquickturbulence.pro b/tests/auto/particles/qquickturbulence/qquickturbulence.pro
index 16d85445f5..d8de625b9c 100644
--- a/tests/auto/particles/qquickturbulence/qquickturbulence.pro
+++ b/tests/auto/particles/qquickturbulence/qquickturbulence.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickwander/qquickwander.pro b/tests/auto/particles/qquickwander/qquickwander.pro
index a9c48ece78..ceb1d9f2c2 100644
--- a/tests/auto/particles/qquickwander/qquickwander.pro
+++ b/tests/auto/particles/qquickwander/qquickwander.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/declarative/animation/animation.pro b/tests/auto/qml/animation/animation.pro
index a9c0cee309..a9c0cee309 100644
--- a/tests/auto/declarative/animation/animation.pro
+++ b/tests/auto/qml/animation/animation.pro
diff --git a/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro b/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro
new file mode 100644
index 0000000000..6d3a05e923
--- /dev/null
+++ b/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase parallel_test
+macx:CONFIG -= app_bundle
+TARGET = tst_qabstractanimationjob
+QT = core-private qml-private testlib
+SOURCES = tst_qabstractanimationjob.cpp
diff --git a/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp b/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp
new file mode 100644
index 0000000000..ea347ab2bd
--- /dev/null
+++ b/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp
@@ -0,0 +1,229 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtQml/private/qabstractanimationjob_p.h>
+#include <QtQml/private/qanimationgroupjob_p.h>
+#include <QtTest>
+
+class tst_QAbstractAnimationJob : public QObject
+{
+ Q_OBJECT
+private slots:
+ void construction();
+ void destruction();
+ void currentLoop();
+ void currentLoopTime();
+ void currentTime();
+ void direction();
+ void group();
+ void loopCount();
+ void state();
+ void totalDuration();
+ void avoidJumpAtStart();
+ void avoidJumpAtStartWithStop();
+ void avoidJumpAtStartWithRunning();
+};
+
+class TestableQAbstractAnimation : public QAbstractAnimationJob
+{
+public:
+ TestableQAbstractAnimation() : m_duration(10) {}
+ virtual ~TestableQAbstractAnimation() {};
+
+ int duration() const { return m_duration; }
+ virtual void updateCurrentTime(int) {}
+
+ void setDuration(int duration) { m_duration = duration; }
+private:
+ int m_duration;
+};
+
+class DummyQAnimationGroup : public QAnimationGroupJob
+{
+public:
+ int duration() const { return 10; }
+ virtual void updateCurrentTime(int) {}
+};
+
+void tst_QAbstractAnimationJob::construction()
+{
+ TestableQAbstractAnimation anim;
+}
+
+void tst_QAbstractAnimationJob::destruction()
+{
+ TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
+ delete anim;
+}
+
+void tst_QAbstractAnimationJob::currentLoop()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.currentLoop(), 0);
+}
+
+void tst_QAbstractAnimationJob::currentLoopTime()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.currentLoopTime(), 0);
+}
+
+void tst_QAbstractAnimationJob::currentTime()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.currentTime(), 0);
+ anim.setCurrentTime(10);
+ QCOMPARE(anim.currentTime(), 10);
+}
+
+void tst_QAbstractAnimationJob::direction()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward);
+ anim.setDirection(QAbstractAnimationJob::Backward);
+ QCOMPARE(anim.direction(), QAbstractAnimationJob::Backward);
+ anim.setDirection(QAbstractAnimationJob::Forward);
+ QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward);
+}
+
+void tst_QAbstractAnimationJob::group()
+{
+ TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
+ DummyQAnimationGroup group;
+ group.appendAnimation(anim);
+ QCOMPARE(anim->group(), &group);
+}
+
+void tst_QAbstractAnimationJob::loopCount()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.loopCount(), 1);
+ anim.setLoopCount(10);
+ QCOMPARE(anim.loopCount(), 10);
+}
+
+void tst_QAbstractAnimationJob::state()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.state(), QAbstractAnimationJob::Stopped);
+}
+
+void tst_QAbstractAnimationJob::totalDuration()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.duration(), 10);
+ anim.setLoopCount(5);
+ QCOMPARE(anim.totalDuration(), 50);
+}
+
+void tst_QAbstractAnimationJob::avoidJumpAtStart()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(1000);
+
+ /*
+ the timer shouldn't actually start until we hit the event loop,
+ so the sleep should have no effect
+ */
+ anim.start();
+ QTest::qSleep(300);
+ QCoreApplication::processEvents();
+ QVERIFY(anim.currentTime() < 50);
+}
+
+void tst_QAbstractAnimationJob::avoidJumpAtStartWithStop()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(1000);
+
+ TestableQAbstractAnimation anim2;
+ anim2.setDuration(1000);
+
+ TestableQAbstractAnimation anim3;
+ anim3.setDuration(1000);
+
+ anim.start();
+ QTest::qWait(300);
+ anim.stop();
+
+ /*
+ same test as avoidJumpAtStart, but after there is a
+ running animation that is stopped
+ */
+ anim2.start();
+ QTest::qSleep(300);
+ anim3.start();
+ QCoreApplication::processEvents();
+ QVERIFY(anim2.currentTime() < 50);
+ QVERIFY(anim3.currentTime() < 50);
+}
+
+void tst_QAbstractAnimationJob::avoidJumpAtStartWithRunning()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(2000);
+
+ TestableQAbstractAnimation anim2;
+ anim2.setDuration(1000);
+
+ TestableQAbstractAnimation anim3;
+ anim3.setDuration(1000);
+
+ anim.start();
+ QTest::qWait(300); //make sure timer has started
+
+ /*
+ same test as avoidJumpAtStart, but with an
+ existing running animation
+ */
+ anim2.start();
+ QTest::qSleep(300); //force large delta for next tick
+ anim3.start();
+ QCoreApplication::processEvents();
+ QVERIFY(anim2.currentTime() < 50);
+ QVERIFY(anim3.currentTime() < 50);
+}
+
+
+QTEST_MAIN(tst_QAbstractAnimationJob)
+
+#include "tst_qabstractanimationjob.moc"
diff --git a/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro b/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro
new file mode 100644
index 0000000000..96081d0116
--- /dev/null
+++ b/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase parallel_test
+macx:CONFIG -= app_bundle
+TARGET = tst_qanimationgroupjob
+QT = core-private qml-private testlib
+SOURCES = tst_qanimationgroupjob.cpp
diff --git a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
new file mode 100644
index 0000000000..f3fd3b4cfb
--- /dev/null
+++ b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQml/private/qanimationgroupjob_p.h>
+#include <QtQml/private/qsequentialanimationgroupjob_p.h>
+#include <QtQml/private/qparallelanimationgroupjob_p.h>
+
+Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
+
+class tst_QAnimationGroupJob : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private slots:
+ void construction();
+ void emptyGroup();
+ void setCurrentTime();
+ void addChildTwice();
+};
+
+void tst_QAnimationGroupJob::initTestCase()
+{
+ qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
+}
+
+void tst_QAnimationGroupJob::construction()
+{
+ QSequentialAnimationGroupJob animationgroup;
+}
+
+class TestableGenericAnimation : public QAbstractAnimationJob
+{
+public:
+ TestableGenericAnimation(int duration = 250) : m_duration(duration) {}
+ int duration() const { return m_duration; }
+
+private:
+ int m_duration;
+};
+
+class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
+{
+ Q_OBJECT
+public:
+ UncontrolledAnimation()
+ : id(0)
+ {
+ }
+
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == id)
+ stop();
+ }
+
+ void updateRunning(bool running)
+ {
+ if (running) {
+ id = startTimer(500);
+ } else {
+ killTimer(id);
+ id = 0;
+ }
+ }
+
+private:
+ int id;
+};
+
+class StateChangeListener: public QAnimationJobChangeListener
+{
+public:
+ virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
+ {
+ states << newState;
+ }
+
+ int count()
+ {
+ return states.count();
+ }
+
+ QList<QAbstractAnimationJob::State> states;
+};
+
+void tst_QAnimationGroupJob::emptyGroup()
+{
+ QSequentialAnimationGroupJob group;
+ StateChangeListener groupStateChangedSpy;
+ group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ group.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 2);
+
+ QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(groupStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+
+ QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimationJob::pause: Cannot pause a stopped animation");
+ group.pause();
+
+ QCOMPARE(groupStateChangedSpy.count(), 2);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+
+ group.start();
+
+ QCOMPARE(groupStateChangedSpy.states.at(2),
+ QAnimationGroupJob::Running);
+ QCOMPARE(groupStateChangedSpy.states.at(3),
+ QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+
+ group.stop();
+
+ QCOMPARE(groupStateChangedSpy.count(), 4);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QAnimationGroupJob::setCurrentTime()
+{
+ // was originally sequence operating on same object/property
+ QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ QAbstractAnimationJob *a1_s_o1 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a2_s_o1 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a3_s_o1 = new TestableGenericAnimation;
+ a2_s_o1->setLoopCount(3);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+
+ // was originally sequence operating on different object/properties
+ QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
+ QAbstractAnimationJob *a1_s_o2 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a1_s_o3 = new TestableGenericAnimation;
+ sequence2->appendAnimation(a1_s_o2);
+ sequence2->appendAnimation(a1_s_o3);
+
+ // was originally parallel operating on different object/properties
+ QAnimationGroupJob *parallel = new QParallelAnimationGroupJob();
+ QAbstractAnimationJob *a1_p_o1 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a1_p_o2 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a1_p_o3 = new TestableGenericAnimation;
+ a1_p_o2->setLoopCount(3);
+ parallel->appendAnimation(a1_p_o1);
+ parallel->appendAnimation(a1_p_o2);
+ parallel->appendAnimation(a1_p_o3);
+
+ QAbstractAnimationJob *notTimeDriven = new UncontrolledAnimation;
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ QAbstractAnimationJob *loopsForever = new TestableGenericAnimation;
+ loopsForever->setLoopCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QParallelAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(sequence2);
+ group.appendAnimation(parallel);
+ group.appendAnimation(notTimeDriven);
+ group.appendAnimation(loopsForever);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 1);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 1);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoop(), 1);
+ QCOMPARE(sequence->currentAnimation(), a2_s_o1);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(sequence->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 251);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
+ QCOMPARE(sequence->currentAnimation(), a2_s_o1);
+}
+
+void tst_QAnimationGroupJob::addChildTwice()
+{
+ QAbstractAnimationJob *subGroup;
+ QAbstractAnimationJob *subGroup2;
+ QAnimationGroupJob *parent = new QSequentialAnimationGroupJob();
+
+ subGroup = new QAbstractAnimationJob;
+ parent->appendAnimation(subGroup);
+ parent->appendAnimation(subGroup);
+ QVERIFY(parent->firstChild() && !parent->firstChild()->nextSibling());
+
+ parent->clear();
+
+ QVERIFY(!parent->firstChild());
+
+ // adding the same item twice to a group will remove the item from its current position
+ // and append it to the end
+ subGroup = new QAbstractAnimationJob;
+ parent->appendAnimation(subGroup);
+ subGroup2 = new QAbstractAnimationJob;
+ parent->appendAnimation(subGroup2);
+
+ QCOMPARE(parent->firstChild(), subGroup);
+ QCOMPARE(parent->lastChild(), subGroup2);
+
+ parent->appendAnimation(subGroup);
+
+ QCOMPARE(parent->firstChild(), subGroup2);
+ QCOMPARE(parent->lastChild(), subGroup);
+
+ delete parent;
+}
+
+QTEST_MAIN(tst_QAnimationGroupJob)
+#include "tst_qanimationgroupjob.moc"
diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro b/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro
new file mode 100644
index 0000000000..f76548183e
--- /dev/null
+++ b/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+TARGET = tst_qparallelanimationgroupjob
+QT = core-private gui qml-private testlib
+SOURCES = tst_qparallelanimationgroupjob.cpp
diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
new file mode 100644
index 0000000000..b6b3fac039
--- /dev/null
+++ b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
@@ -0,0 +1,931 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQml/private/qparallelanimationgroupjob_p.h>
+
+Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
+
+class tst_QParallelAnimationGroupJob : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private slots:
+ void construction();
+ void setCurrentTime();
+ void stateChanged();
+ void clearGroup();
+ void propagateGroupUpdateToChildren();
+ void updateChildrenWithRunningGroup();
+ void deleteChildrenWithRunningGroup();
+ void startChildrenWithStoppedGroup();
+ void stopGroupWithRunningChild();
+ void startGroupWithRunningChild();
+ void zeroDurationAnimation();
+ void stopUncontrolledAnimations();
+ void loopCount_data();
+ void loopCount();
+ void addAndRemoveDuration();
+ void pauseResume();
+
+ void crashWhenRemovingUncontrolledAnimation();
+};
+
+void tst_QParallelAnimationGroupJob::initTestCase()
+{
+ qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
+#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
+ // give the mac/wince app start event queue time to clear
+ QTest::qWait(1000);
+#endif
+}
+
+void tst_QParallelAnimationGroupJob::construction()
+{
+ QParallelAnimationGroupJob animationgroup;
+}
+
+class TestAnimation : public QAbstractAnimationJob
+{
+public:
+ TestAnimation(int duration = 250) : m_duration(duration) {}
+ int duration() const { return m_duration; }
+
+private:
+ int m_duration;
+};
+
+class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
+{
+ Q_OBJECT
+public:
+ UncontrolledAnimation()
+ : id(0)
+ {
+ }
+
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == id)
+ stop();
+ }
+
+ void updateRunning(bool running)
+ {
+ if (running) {
+ id = startTimer(500);
+ } else {
+ killTimer(id);
+ id = 0;
+ }
+ }
+
+private:
+ int id;
+};
+
+class StateChangeListener: public QAnimationJobChangeListener
+{
+public:
+ virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
+ {
+ states << newState;
+ }
+
+ void clear() { states.clear(); }
+ int count() { return states.count(); }
+
+ QList<QAbstractAnimationJob::State> states;
+};
+
+class FinishedListener: public QAnimationJobChangeListener
+{
+public:
+ FinishedListener() : m_count(0) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; }
+ void clear() { m_count = 0; }
+ int count() { return m_count; }
+
+private:
+ int m_count;
+};
+
+void tst_QParallelAnimationGroupJob::setCurrentTime()
+{
+ // originally was parallel operating on different object/properties
+ QAnimationGroupJob *parallel = new QParallelAnimationGroupJob();
+ TestAnimation *a1_p_o1 = new TestAnimation;
+ TestAnimation *a1_p_o2 = new TestAnimation;
+ TestAnimation *a1_p_o3 = new TestAnimation;
+ a1_p_o2->setLoopCount(3);
+ parallel->appendAnimation(a1_p_o1);
+ parallel->appendAnimation(a1_p_o2);
+ parallel->appendAnimation(a1_p_o3);
+
+ UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation;
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ TestAnimation *loopsForever = new TestAnimation;
+ loopsForever->setLoopCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QParallelAnimationGroupJob group;
+ group.appendAnimation(parallel);
+ group.appendAnimation(notTimeDriven);
+ group.appendAnimation(loopsForever);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 1);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 1);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoop(), 1);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 251);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
+}
+
+void tst_QParallelAnimationGroupJob::stateChanged()
+{
+ //this ensures that the correct animations are started when starting the group
+ TestAnimation *anim1 = new TestAnimation(1000);
+ TestAnimation *anim2 = new TestAnimation(2000);
+ TestAnimation *anim3 = new TestAnimation(3000);
+ TestAnimation *anim4 = new TestAnimation(3000);
+
+ QParallelAnimationGroupJob group;
+ group.appendAnimation(anim1);
+ group.appendAnimation(anim2);
+ group.appendAnimation(anim3);
+ group.appendAnimation(anim4);
+
+ StateChangeListener spy1;
+ anim1->addAnimationChangeListener(&spy1, QAbstractAnimationJob::StateChange);
+ StateChangeListener spy2;
+ anim2->addAnimationChangeListener(&spy2, QAbstractAnimationJob::StateChange);
+ StateChangeListener spy3;
+ anim3->addAnimationChangeListener(&spy3, QAbstractAnimationJob::StateChange);
+ StateChangeListener spy4;
+ anim4->addAnimationChangeListener(&spy4, QAbstractAnimationJob::StateChange);
+
+ //first; let's start forward
+ group.start();
+ //all the animations should be started
+ QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.states.last(), TestAnimation::Running);
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.states.last(), TestAnimation::Running);
+ QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.states.last(), TestAnimation::Running);
+ QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.states.last(), TestAnimation::Running);
+
+ group.setCurrentTime(1500); //anim1 should be finished
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy2.count(), 1); //no change
+ QCOMPARE(spy3.count(), 1); //no change
+ QCOMPARE(spy4.count(), 1); //no change
+
+ group.setCurrentTime(2500); //anim2 should be finished
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 2); //no change
+ QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy2.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy3.count(), 1); //no change
+ QCOMPARE(spy4.count(), 1); //no change
+
+ group.setCurrentTime(3500); //everything should be finished
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(spy1.count(), 2); //no change
+ QCOMPARE(spy2.count(), 2); //no change
+ QCOMPARE(spy3.count(), 2);
+ QCOMPARE(spy3.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy4.count(), 2);
+ QCOMPARE(spy4.states.last(), TestAnimation::Stopped);
+
+ //cleanup
+ spy1.clear();
+ spy2.clear();
+ spy3.clear();
+ spy4.clear();
+
+ //now let's try to reverse that
+ group.setDirection(QAbstractAnimationJob::Backward);
+ group.start();
+
+ //only anim3 and anim4 should be started
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy2.count(), 0);
+ QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.states.last(), TestAnimation::Running);
+ QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.states.last(), TestAnimation::Running);
+
+ group.setCurrentTime(1500); //anim2 should be started
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 0); //no change
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.states.last(), TestAnimation::Running);
+ QCOMPARE(spy3.count(), 1); //no change
+ QCOMPARE(spy4.count(), 1); //no change
+
+ group.setCurrentTime(500); //anim1 is finally also started
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.states.last(), TestAnimation::Running);
+ QCOMPARE(spy2.count(), 1); //no change
+ QCOMPARE(spy3.count(), 1); //no change
+ QCOMPARE(spy4.count(), 1); //no change
+
+ group.setCurrentTime(0); //everything should be stopped
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy2.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy3.count(), 2);
+ QCOMPARE(spy3.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy4.count(), 2);
+ QCOMPARE(spy4.states.last(), TestAnimation::Stopped);
+}
+
+void tst_QParallelAnimationGroupJob::clearGroup()
+{
+ QParallelAnimationGroupJob group;
+ static const int animationCount = 10;
+
+ for (int i = 0; i < animationCount; ++i) {
+ group.appendAnimation(new QParallelAnimationGroupJob);
+ }
+
+ int count = 0;
+ for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
+ ++count;
+ QCOMPARE(count, animationCount);
+
+ group.clear();
+
+ QVERIFY(!group.firstChild() && !group.lastChild());
+ QCOMPARE(group.currentLoopTime(), 0);
+}
+
+void tst_QParallelAnimationGroupJob::propagateGroupUpdateToChildren()
+{
+ // this test verifies if group state changes are updating its children correctly
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(100);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QParallelAnimationGroupJob::updateChildrenWithRunningGroup()
+{
+ // assert that its possible to modify a child's state directly while their group is running
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim(200);
+
+ StateChangeListener groupStateChangedSpy;
+ group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+ StateChangeListener childStateChangedSpy;
+ anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(groupStateChangedSpy.count(), 0);
+ QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Running);
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+
+ // starting directly a running child will not have any effect
+ anim.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ anim.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Paused);
+
+ // in the animation stops directly, the group will still be running
+ anim.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
+
+ //cleanup
+ group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+ anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QParallelAnimationGroupJob::deleteChildrenWithRunningGroup()
+{
+ // test if children can be activated when their group is stopped
+ QParallelAnimationGroupJob group;
+
+ TestAnimation *anim1 = new TestAnimation(200);
+ group.appendAnimation(anim1);
+
+ QCOMPARE(group.duration(), anim1->duration());
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
+
+ QTest::qWait(80);
+ QVERIFY(group.currentLoopTime() > 0);
+
+ delete anim1;
+ QVERIFY(!group.firstChild());
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
+}
+
+void tst_QParallelAnimationGroupJob::startChildrenWithStoppedGroup()
+{
+ // test if children can be activated when their group is stopped
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+}
+
+void tst_QParallelAnimationGroupJob::stopGroupWithRunningChild()
+{
+ // children that started independently will not be affected by a group stop
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ anim1.stop();
+ anim2.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QParallelAnimationGroupJob::startGroupWithRunningChild()
+{
+ // as the group has precedence over its children, starting a group will restart all the children
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ StateChangeListener stateChangedSpy1;
+ anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ StateChangeListener stateChangedSpy2;
+ anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy2.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy2.states.at(1), QAnimationGroupJob::Paused);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ group.start();
+
+ QCOMPARE(stateChangedSpy1.count(), 3);
+ QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped);
+ QCOMPARE(stateChangedSpy1.states.at(2), QAnimationGroupJob::Running);
+
+ QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped);
+ QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
+
+ //cleanup
+ anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QParallelAnimationGroupJob::zeroDurationAnimation()
+{
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(0);
+ TestAnimation anim2(100);
+ TestAnimation anim3(10);
+
+ StateChangeListener stateChangedSpy1;
+ anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ FinishedListener finishedSpy1;
+ anim1.addAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion);
+
+ StateChangeListener stateChangedSpy2;
+ anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+ FinishedListener finishedSpy2;
+ anim2.addAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion);
+
+ StateChangeListener stateChangedSpy3;
+ anim3.addAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange);
+ FinishedListener finishedSpy3;
+ anim3.addAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+ group.appendAnimation(&anim3);
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ group.start();
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(finishedSpy1.count(), 1);
+ QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ QCOMPARE(finishedSpy2.count(), 0);
+ QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
+
+ QCOMPARE(stateChangedSpy3.count(), 1);
+ QCOMPARE(finishedSpy3.count(), 0);
+ QCOMPARE(stateChangedSpy3.states.at(0), QAnimationGroupJob::Running);
+
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim3.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+
+ group.stop();
+ group.setLoopCount(4);
+ stateChangedSpy1.clear();
+ stateChangedSpy2.clear();
+ stateChangedSpy3.clear();
+
+ group.start();
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ QCOMPARE(stateChangedSpy3.count(), 1);
+ group.setCurrentTime(50);
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ QCOMPARE(stateChangedSpy3.count(), 2);
+ group.setCurrentTime(150);
+ QCOMPARE(stateChangedSpy1.count(), 4);
+ QCOMPARE(stateChangedSpy2.count(), 3);
+ QCOMPARE(stateChangedSpy3.count(), 4);
+ group.setCurrentTime(50);
+ QCOMPARE(stateChangedSpy1.count(), 6);
+ QCOMPARE(stateChangedSpy2.count(), 5);
+ QCOMPARE(stateChangedSpy3.count(), 6);
+
+ //cleanup
+ anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ anim1.removeAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion);
+ anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+ anim2.removeAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion);
+ anim3.removeAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange);
+ anim3.removeAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion);
+}
+
+void tst_QParallelAnimationGroupJob::stopUncontrolledAnimations()
+{
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(0);
+
+ UncontrolledAnimation notTimeDriven;
+ QCOMPARE(notTimeDriven.totalDuration(), -1);
+
+ TestAnimation loopsForever(100);
+ loopsForever.setLoopCount(-1);
+
+ StateChangeListener stateChangedSpy;
+ anim1.addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&notTimeDriven);
+ group.appendAnimation(&loopsForever);
+
+ group.start();
+
+ QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+
+ notTimeDriven.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
+
+ loopsForever.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
+}
+
+struct AnimState {
+ AnimState(int time = -1) : time(time), state(-1) {}
+ AnimState(int time, int state) : time(time), state(state) {}
+ int time;
+ int state;
+};
+
+#define Running QAbstractAnimationJob::Running
+#define Stopped QAbstractAnimationJob::Stopped
+
+Q_DECLARE_METATYPE(AnimState)
+void tst_QParallelAnimationGroupJob::loopCount_data()
+{
+ QTest::addColumn<bool>("directionBackward");
+ QTest::addColumn<int>("setLoopCount");
+ QTest::addColumn<int>("initialGroupTime");
+ QTest::addColumn<int>("currentGroupTime");
+ QTest::addColumn<AnimState>("expected1");
+ QTest::addColumn<AnimState>("expected2");
+ QTest::addColumn<AnimState>("expected3");
+
+ // D U R A T I O N
+ // 100 60*2 0
+ // direction = Forward
+ QTest::newRow("50") << false << 3 << 0 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("100") << false << 3 << 0 << 100 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("110") << false << 3 << 0 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120") << false << 3 << 0 << 120 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+
+ QTest::newRow("170") << false << 3 << 0 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("220") << false << 3 << 0 << 220 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("230") << false << 3 << 0 << 230 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("240") << false << 3 << 0 << 240 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+
+ QTest::newRow("290") << false << 3 << 0 << 290 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("340") << false << 3 << 0 << 340 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("350") << false << 3 << 0 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("360") << false << 3 << 0 << 360 << AnimState(100, Stopped) << AnimState( 60 ) << AnimState( 0, Stopped);
+
+ QTest::newRow("410") << false << 3 << 0 << 410 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("460") << false << 3 << 0 << 460 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("470") << false << 3 << 0 << 470 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("480") << false << 3 << 0 << 480 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+
+ // direction = Forward, rewind
+ QTest::newRow("120-110") << false << 3 << 120 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120-50") << false << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120-0") << false << 3 << 120 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-110") << false << 3 << 300 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-50") << false << 3 << 300 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-0") << false << 3 << 300 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+ QTest::newRow("115-105") << false << 3 << 115 << 105 << AnimState( 42, Stopped) << AnimState( 45, Running) << AnimState( 0, Stopped);
+
+ // direction = Backward
+ QTest::newRow("b120-120") << true << 3 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-110") << true << 3 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-100") << true << 3 << 120 << 100 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-50") << true << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-0") << true << 3 << 120 << 0 << AnimState( 0, Stopped) << AnimState( 0, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("b360-170") << true << 3 << 360 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-220") << true << 3 << 360 << 220 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-210") << true << 3 << 360 << 210 << AnimState( 90, Running) << AnimState( 30, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-120") << true << 3 << 360 << 120 << AnimState( 0, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+
+ // rewind, direction = Backward
+ QTest::newRow("b50-110") << true << 3 << 50 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-120") << true << 3 << 50 << 120 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-140") << true << 3 << 50 << 140 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-240") << true << 3 << 50 << 240 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-260") << true << 3 << 50 << 260 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-350") << true << 3 << 50 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+
+ // infinite looping
+ QTest::newRow("inf1220") << false << -1 << 0 << 1220 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("inf1310") << false << -1 << 0 << 1310 << AnimState( 100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ // infinite looping, direction = Backward (will only loop once)
+ QTest::newRow("b.inf120-120") << true << -1 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b.inf120-20") << true << -1 << 120 << 20 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b.inf120-110") << true << -1 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+
+
+}
+
+void tst_QParallelAnimationGroupJob::loopCount()
+{
+ QFETCH(bool, directionBackward);
+ QFETCH(int, setLoopCount);
+ QFETCH(int, initialGroupTime);
+ QFETCH(int, currentGroupTime);
+ QFETCH(AnimState, expected1);
+ QFETCH(AnimState, expected2);
+ QFETCH(AnimState, expected3);
+
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(100);
+ TestAnimation anim2(60); //total 120
+ anim2.setLoopCount(2);
+ TestAnimation anim3(0);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+ group.appendAnimation(&anim3);
+
+ group.setLoopCount(setLoopCount);
+ if (initialGroupTime >= 0)
+ group.setCurrentTime(initialGroupTime);
+ if (directionBackward)
+ group.setDirection(QAbstractAnimationJob::Backward);
+
+ group.start();
+ if (initialGroupTime >= 0)
+ group.setCurrentTime(initialGroupTime);
+
+ anim1.setCurrentTime(42); // 42 is "untouched"
+ anim2.setCurrentTime(42);
+
+ group.setCurrentTime(currentGroupTime);
+
+ QCOMPARE(anim1.currentLoopTime(), expected1.time);
+ QCOMPARE(anim2.currentLoopTime(), expected2.time);
+ QCOMPARE(anim3.currentLoopTime(), expected3.time);
+
+ if (expected1.state >=0)
+ QCOMPARE(int(anim1.state()), expected1.state);
+ if (expected2.state >=0)
+ QCOMPARE(int(anim2.state()), expected2.state);
+ if (expected3.state >=0)
+ QCOMPARE(int(anim3.state()), expected3.state);
+
+}
+
+void tst_QParallelAnimationGroupJob::addAndRemoveDuration()
+{
+ QParallelAnimationGroupJob group;
+ QCOMPARE(group.duration(), 0);
+ TestAnimation *test = new TestAnimation(250); // 0, duration = 250;
+ group.appendAnimation(test);
+ QCOMPARE(test->group(), static_cast<QAnimationGroupJob*>(&group));
+ QCOMPARE(test->duration(), 250);
+ QCOMPARE(group.duration(), 250);
+
+ TestAnimation *test2 = new TestAnimation(750); // 1
+ group.appendAnimation(test2);
+ QCOMPARE(test2->group(), static_cast<QAnimationGroupJob*>(&group));
+ QCOMPARE(group.duration(), 750);
+
+ TestAnimation *test3 = new TestAnimation(500); // 2
+ group.appendAnimation(test3);
+ QCOMPARE(test3->group(), static_cast<QAnimationGroupJob*>(&group));
+ QCOMPARE(group.duration(), 750);
+
+ group.removeAnimation(test2); // remove the one with duration = 750
+ delete test2;
+ QCOMPARE(group.duration(), 500);
+
+ group.removeAnimation(test3); // remove the one with duration = 500
+ delete test3;
+ QCOMPARE(group.duration(), 250);
+
+ group.removeAnimation(test); // remove the last one (with duration = 250)
+ QCOMPARE(test->group(), static_cast<QAnimationGroupJob*>(0));
+ QCOMPARE(group.duration(), 0);
+ delete test;
+}
+
+void tst_QParallelAnimationGroupJob::pauseResume()
+{
+ QParallelAnimationGroupJob group;
+ TestAnimation *anim = new TestAnimation(250); // 0, duration = 250;
+ group.appendAnimation(anim);
+ StateChangeListener spy;
+ anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
+ QCOMPARE(group.duration(), 250);
+ group.start();
+ QTest::qWait(100);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ const int currentTime = group.currentLoopTime();
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(group.currentLoopTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ group.resume();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentLoopTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+
+ group.stop();
+ spy.clear();
+ group.appendAnimation(new TestAnimation(500));
+ group.start();
+ QCOMPARE(spy.count(), 1); //the animation should have been started
+ QCOMPARE(spy.states.at(0), TestAnimation::Running);
+ group.setCurrentTime(250); //end of first animation
+ QCOMPARE(spy.count(), 2); //the animation should have been stopped
+ QCOMPARE(spy.states.at(1), TestAnimation::Stopped);
+ group.pause();
+ QCOMPARE(spy.count(), 2); //this shouldn't have changed
+ group.resume();
+ QCOMPARE(spy.count(), 2); //this shouldn't have changed
+}
+
+// This is a regression test for QTBUG-8910, where a crash occurred when the
+// last animation was removed from a group.
+void tst_QParallelAnimationGroupJob::crashWhenRemovingUncontrolledAnimation()
+{
+ QParallelAnimationGroupJob group;
+ TestAnimation *anim = new TestAnimation;
+ anim->setLoopCount(-1);
+ TestAnimation *anim2 = new TestAnimation;
+ anim2->setLoopCount(-1);
+ group.appendAnimation(anim);
+ group.appendAnimation(anim2);
+ group.start();
+ delete anim;
+ // it would crash here because the internals of the group would still have a reference to anim
+ delete anim2;
+}
+
+
+QTEST_MAIN(tst_QParallelAnimationGroupJob)
+#include "tst_qparallelanimationgroupjob.moc"
diff --git a/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro b/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro
new file mode 100644
index 0000000000..b80bb0c55c
--- /dev/null
+++ b/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+TARGET = tst_qpauseanimationjob
+QT = core-private gui-private qml-private testlib
+SOURCES = tst_qpauseanimationjob.cpp
diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
new file mode 100644
index 0000000000..247d7791bf
--- /dev/null
+++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
@@ -0,0 +1,470 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQml/private/qpauseanimationjob_p.h>
+#include <QtQml/private/qsequentialanimationgroupjob_p.h>
+#include <QtQml/private/qparallelanimationgroupjob_p.h>
+
+#ifdef Q_OS_WIN
+static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution";
+#endif
+
+class TestablePauseAnimation : public QPauseAnimationJob
+{
+public:
+ TestablePauseAnimation()
+ : m_updateCurrentTimeCount(0)
+ {
+ }
+
+ TestablePauseAnimation(int duration)
+ : QPauseAnimationJob(duration), m_updateCurrentTimeCount(0)
+ {
+ }
+
+ int m_updateCurrentTimeCount;
+protected:
+ void updateCurrentTime(int currentTime)
+ {
+ QPauseAnimationJob::updateCurrentTime(currentTime);
+ ++m_updateCurrentTimeCount;
+ }
+};
+
+class TestableGenericAnimation : public QAbstractAnimationJob
+{
+public:
+ TestableGenericAnimation(int duration = 250) : m_duration(duration) {}
+ int duration() const { return m_duration; }
+
+private:
+ int m_duration;
+};
+
+class EnableConsistentTiming
+{
+public:
+ EnableConsistentTiming()
+ {
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(true);
+ }
+ ~EnableConsistentTiming()
+ {
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(false);
+ }
+};
+
+class tst_QPauseAnimationJob : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private slots:
+ void changeDirectionWhileRunning();
+ void noTimerUpdates_data();
+ void noTimerUpdates();
+ void multiplePauseAnimations();
+ void pauseAndPropertyAnimations();
+ void pauseResume();
+ void sequentialPauseGroup();
+ void sequentialGroupWithPause();
+ void multipleSequentialGroups();
+ void zeroDuration();
+};
+
+void tst_QPauseAnimationJob::initTestCase()
+{
+// qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
+}
+
+void tst_QPauseAnimationJob::changeDirectionWhileRunning()
+{
+ EnableConsistentTiming enabled;
+
+ TestablePauseAnimation animation;
+ animation.setDuration(400);
+ animation.start();
+ QTest::qWait(100);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Running);
+ animation.setDirection(QAbstractAnimationJob::Backward);
+ QTest::qWait(animation.totalDuration() + 50);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+}
+
+void tst_QPauseAnimationJob::noTimerUpdates_data()
+{
+ QTest::addColumn<int>("duration");
+ QTest::addColumn<int>("loopCount");
+
+ QTest::newRow("0") << 200 << 1;
+ QTest::newRow("1") << 160 << 1;
+ QTest::newRow("2") << 160 << 2;
+ QTest::newRow("3") << 200 << 3;
+}
+
+void tst_QPauseAnimationJob::noTimerUpdates()
+{
+ EnableConsistentTiming enabled;
+
+ QFETCH(int, duration);
+ QFETCH(int, loopCount);
+
+ TestablePauseAnimation animation;
+ animation.setDuration(duration);
+ animation.setLoopCount(loopCount);
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ const int expectedLoopCount = 1 + loopCount;
+
+#ifdef Q_OS_WIN
+ if (animation.m_updateCurrentTimeCount != expectedLoopCount)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount);
+}
+
+void tst_QPauseAnimationJob::multiplePauseAnimations()
+{
+ EnableConsistentTiming enabled;
+
+ TestablePauseAnimation animation;
+ animation.setDuration(200);
+
+ TestablePauseAnimation animation2;
+ animation2.setDuration(800);
+
+ animation.start();
+ animation2.start();
+ QTest::qWait(animation.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (animation2.state() != QAbstractAnimationJob::Running)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Running);
+
+#ifdef Q_OS_WIN
+ if (animation.m_updateCurrentTimeCount != 2)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation.m_updateCurrentTimeCount, 2);
+
+#ifdef Q_OS_WIN
+ if (animation2.m_updateCurrentTimeCount != 2)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+
+ QTest::qWait(550);
+
+#ifdef Q_OS_WIN
+ if (animation2.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (animation2.m_updateCurrentTimeCount != 3)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 3);
+}
+
+void tst_QPauseAnimationJob::pauseAndPropertyAnimations()
+{
+ EnableConsistentTiming enabled;
+
+ TestablePauseAnimation pause;
+ pause.setDuration(200);
+
+ TestableGenericAnimation animation;
+
+ pause.start();
+
+ QTest::qWait(100);
+ animation.start();
+
+ QVERIFY(animation.state() == QAbstractAnimationJob::Running);
+ QVERIFY(pause.state() == QAbstractAnimationJob::Running);
+ QCOMPARE(pause.m_updateCurrentTimeCount, 2);
+
+ QTest::qWait(animation.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(pause.m_updateCurrentTimeCount > 3);
+}
+
+void tst_QPauseAnimationJob::pauseResume()
+{
+ TestablePauseAnimation animation;
+ animation.setDuration(400);
+ animation.start();
+ QVERIFY(animation.state() == QAbstractAnimationJob::Running);
+ QTest::qWait(200);
+ animation.pause();
+ QVERIFY(animation.state() == QAbstractAnimationJob::Paused);
+ animation.start();
+ QTest::qWait(300);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (animation.m_updateCurrentTimeCount != 3)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation.m_updateCurrentTimeCount, 3);
+}
+
+void tst_QPauseAnimationJob::sequentialPauseGroup()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestablePauseAnimation animation1(200);
+ group.appendAnimation(&animation1);
+ TestablePauseAnimation animation2(200);
+ group.appendAnimation(&animation2);
+ TestablePauseAnimation animation3(200);
+ group.appendAnimation(&animation3);
+
+ group.start();
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 1);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 0);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation1.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
+
+ group.setCurrentTime(250);
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 1);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
+ QCOMPARE((QAbstractAnimationJob*)&animation2, group.currentAnimation());
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
+
+ group.setCurrentTime(500);
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 1);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
+ QCOMPARE((QAbstractAnimationJob*)&animation3, group.currentAnimation());
+ QVERIFY(animation3.state() == QAbstractAnimationJob::Running);
+
+ group.setCurrentTime(750);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
+
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 2);
+}
+
+void tst_QPauseAnimationJob::sequentialGroupWithPause()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestableGenericAnimation animation;
+ group.appendAnimation(&animation);
+
+ TestablePauseAnimation pause;
+ pause.setDuration(250);
+ group.appendAnimation(&pause);
+
+ group.start();
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Running);
+ QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
+
+ group.setCurrentTime(300);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ QCOMPARE((QAbstractAnimationJob*)&pause, group.currentAnimation());
+ QVERIFY(pause.state() == QAbstractAnimationJob::Running);
+
+ group.setCurrentTime(600);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
+
+ QCOMPARE(pause.m_updateCurrentTimeCount, 2);
+}
+
+void tst_QPauseAnimationJob::multipleSequentialGroups()
+{
+ EnableConsistentTiming enabled;
+
+ QParallelAnimationGroupJob group;
+ group.setLoopCount(2);
+
+ QSequentialAnimationGroupJob subgroup1;
+ group.appendAnimation(&subgroup1);
+
+ TestableGenericAnimation animation(300);
+ subgroup1.appendAnimation(&animation);
+
+ TestablePauseAnimation pause(200);
+ subgroup1.appendAnimation(&pause);
+
+ QSequentialAnimationGroupJob subgroup2;
+ group.appendAnimation(&subgroup2);
+
+ TestableGenericAnimation animation2(200);
+ subgroup2.appendAnimation(&animation2);
+
+ TestablePauseAnimation pause2(250);
+ subgroup2.appendAnimation(&pause2);
+
+ QSequentialAnimationGroupJob subgroup3;
+ group.appendAnimation(&subgroup3);
+
+ TestablePauseAnimation pause3(400);
+ subgroup3.appendAnimation(&pause3);
+
+ TestableGenericAnimation animation3(200);
+ subgroup3.appendAnimation(&animation3);
+
+ QSequentialAnimationGroupJob subgroup4;
+ group.appendAnimation(&subgroup4);
+
+ TestablePauseAnimation pause4(310);
+ subgroup4.appendAnimation(&pause4);
+
+ TestablePauseAnimation pause5(60);
+ subgroup4.appendAnimation(&pause5);
+
+ group.start();
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(subgroup1.state() == QAbstractAnimationJob::Running);
+ QVERIFY(subgroup2.state() == QAbstractAnimationJob::Running);
+ QVERIFY(subgroup3.state() == QAbstractAnimationJob::Running);
+ QVERIFY(subgroup4.state() == QAbstractAnimationJob::Running);
+
+ // This is a pretty long animation so it tends to get rather out of sync
+ // when using the consistent timer, so run for an extra half second for good
+ // measure...
+ QTest::qWait(group.totalDuration() + 500);
+
+#ifdef Q_OS_WIN
+ if (group.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (subgroup1.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(subgroup1.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (subgroup2.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(subgroup2.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (subgroup3.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(subgroup3.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (subgroup4.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(subgroup4.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (pause5.m_updateCurrentTimeCount != 4)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(pause5.m_updateCurrentTimeCount, 4);
+}
+
+void tst_QPauseAnimationJob::zeroDuration()
+{
+ TestablePauseAnimation animation;
+ animation.setDuration(0);
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 100);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ QCOMPARE(animation.m_updateCurrentTimeCount, 1);
+}
+
+QTEST_MAIN(tst_QPauseAnimationJob)
+#include "tst_qpauseanimationjob.moc"
diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro b/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro
new file mode 100644
index 0000000000..fe4dc9ce82
--- /dev/null
+++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase parallel_test
+macx:CONFIG -= app_bundle
+TARGET = tst_qsequentialanimationgroupjob
+QT = core-private qml-private testlib
+SOURCES = tst_qsequentialanimationgroupjob.cpp
diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
new file mode 100644
index 0000000000..caa43cf9cb
--- /dev/null
+++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
@@ -0,0 +1,1617 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQml/private/qsequentialanimationgroupjob_p.h>
+#include <QtQml/private/qparallelanimationgroupjob_p.h>
+#include <QtQml/private/qpauseanimationjob_p.h>
+
+Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
+Q_DECLARE_METATYPE(QAbstractAnimationJob*)
+
+class tst_QSequentialAnimationGroupJob : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private slots:
+ void construction();
+ void setCurrentTime();
+ void setCurrentTimeWithUncontrolledAnimation();
+ void seekingForwards();
+ void seekingBackwards();
+ void pauseAndResume();
+ void restart();
+ void looping();
+ void startDelay();
+ void clearGroup();
+ void groupWithZeroDurationAnimations();
+ void propagateGroupUpdateToChildren();
+ void updateChildrenWithRunningGroup();
+ void deleteChildrenWithRunningGroup();
+ void startChildrenWithStoppedGroup();
+ void stopGroupWithRunningChild();
+ void startGroupWithRunningChild();
+ void zeroDurationAnimation();
+ void stopUncontrolledAnimations();
+ void finishWithUncontrolledAnimation();
+ void addRemoveAnimation();
+ void currentAnimation();
+ void currentAnimationWithZeroDuration();
+ void insertAnimation();
+ void clear();
+ void pauseResume();
+};
+
+void tst_QSequentialAnimationGroupJob::initTestCase()
+{
+ qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
+ qRegisterMetaType<QAbstractAnimationJob*>("QAbstractAnimationJob*");
+}
+
+void tst_QSequentialAnimationGroupJob::construction()
+{
+ QSequentialAnimationGroupJob animationgroup;
+}
+
+class TestAnimation : public QAbstractAnimationJob
+{
+public:
+ TestAnimation(int duration = 250) : m_duration(duration) {}
+ int duration() const { return m_duration; }
+
+private:
+ int m_duration;
+};
+
+class TestValueAnimation : public TestAnimation
+{
+public:
+ TestValueAnimation(int duration = 250)
+ : TestAnimation(duration), start(0), end(0), value(0) {}
+
+ void updateCurrentTime(int msecs)
+ {
+ if (msecs >= duration())
+ value = end;
+ else
+ value = start + (end - start) * (qreal(msecs) / duration());
+ }
+
+ qreal start, end;
+ qreal value;
+};
+
+class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
+{
+ Q_OBJECT
+public:
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void updateCurrentTime(int currentTime)
+ {
+ if (currentTime >= 250)
+ stop();
+ }
+};
+
+class StateChangeListener: public QAnimationJobChangeListener
+{
+public:
+ virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
+ {
+ states << newState;
+ }
+
+ void clear() { states.clear(); }
+ int count() const { return states.count(); }
+
+ QList<QAbstractAnimationJob::State> states;
+};
+
+class FinishedListener: public QAnimationJobChangeListener
+{
+public:
+ FinishedListener() : m_count(0) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; }
+ void clear() { m_count = 0; }
+ int count() { return m_count; }
+
+private:
+ int m_count;
+};
+
+void tst_QSequentialAnimationGroupJob::setCurrentTime()
+{
+ // sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a2_s_o1 = new TestAnimation;
+ TestAnimation *a3_s_o1 = new TestAnimation;
+ a2_s_o1->setLoopCount(3);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o2 = new TestAnimation;
+ TestAnimation *a1_s_o3 = new TestAnimation;
+ sequence2->appendAnimation(a1_s_o2);
+ sequence2->appendAnimation(a1_s_o3);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(sequence2);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(sequence->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 750
+ group.setCurrentTime(750);
+ QCOMPARE(group.currentLoopTime(), 750);
+ QCOMPARE(sequence->currentLoopTime(), 750);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1000
+ group.setCurrentTime(1000);
+ QCOMPARE(group.currentLoopTime(), 1000);
+ QCOMPARE(sequence->currentLoopTime(), 1000);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1010
+ group.setCurrentTime(1010);
+ QCOMPARE(group.currentLoopTime(), 1010);
+ QCOMPARE(sequence->currentLoopTime(), 1010);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 10);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1250
+ group.setCurrentTime(1250);
+ QCOMPARE(group.currentLoopTime(), 1250);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1500
+ group.setCurrentTime(1500);
+ QCOMPARE(group.currentLoopTime(), 1500);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
+
+ // Current time = 2000
+ group.setCurrentTime(2000);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
+}
+
+void tst_QSequentialAnimationGroupJob::setCurrentTimeWithUncontrolledAnimation()
+{
+ // sequence operating on different object/properties
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a1_s_o2 = new TestAnimation;
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a1_s_o2);
+
+ UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation;
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ TestAnimation *loopsForever = new TestAnimation;
+ loopsForever->setLoopCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(notTimeDriven);
+ group.appendAnimation(loopsForever);
+ group.start();
+ group.pause(); // this allows the group to listen for the finish signal of its children
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+
+ // Current time = 500
+ group.setCurrentTime(500);
+ QCOMPARE(group.currentLoopTime(), 500);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob *>(notTimeDriven));
+
+ // Current time = 505
+ group.setCurrentTime(505);
+ QCOMPARE(group.currentLoopTime(), 505);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 5);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob *>(notTimeDriven));
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+
+ // Current time = 750 (end of notTimeDriven animation)
+ group.setCurrentTime(750);
+ QCOMPARE(group.currentLoopTime(), 750);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), loopsForever);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Paused);
+
+ // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run)
+ group.setCurrentTime(800);
+ QCOMPARE(group.currentLoopTime(), 800);
+ QCOMPARE(group.currentAnimation(), loopsForever);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 50);
+
+ loopsForever->stop(); // this should stop the group
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::seekingForwards()
+{
+
+ // sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob;
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a2_s_o1 = new TestAnimation;
+ TestAnimation *a3_s_o1 = new TestAnimation;
+ a2_s_o1->setLoopCount(3);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob;
+ TestAnimation *a1_s_o2 = new TestAnimation;
+ TestAnimation *a1_s_o3 = new TestAnimation;
+ sequence2->appendAnimation(a1_s_o2);
+ sequence2->appendAnimation(a1_s_o3);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(sequence2);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1500
+ group.setCurrentTime(1500);
+ QCOMPARE(group.currentLoopTime(), 1500);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // this will restart the group
+ group.start();
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
+}
+
+void tst_QSequentialAnimationGroupJob::seekingBackwards()
+{
+ // sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a2_s_o1 = new TestAnimation;
+ TestAnimation *a3_s_o1 = new TestAnimation;
+ a2_s_o1->setLoopCount(3);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o2 = new TestAnimation;
+ TestAnimation *a1_s_o3 = new TestAnimation;
+ sequence2->appendAnimation(a1_s_o2);
+ sequence2->appendAnimation(a1_s_o3);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(sequence2);
+
+ group.start();
+
+ // Current time = 1600
+ group.setCurrentTime(1600);
+ QCOMPARE(group.currentLoopTime(), 1600);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 350);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 100);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Running);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Running);
+
+ // Seeking backwards, current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Running);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Running);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
+
+ // Current time = 2000
+ group.setCurrentTime(2000);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
+}
+
+typedef QList<QAbstractAnimationJob::State> StateList;
+
+static bool compareStates(const StateChangeListener& spy, const StateList &expectedStates)
+{
+ bool equals = true;
+ for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
+ if (i >= spy.count() || i >= expectedStates.count()) {
+ equals = false;
+ break;
+ }
+ QAbstractAnimationJob::State st = expectedStates.at(i);
+ QAbstractAnimationJob::State actual = spy.states.at(i);
+ if (equals && actual != st) {
+ equals = false;
+ break;
+ }
+ }
+ if (!equals) {
+ const char *stateStrings[] = {"Stopped", "Paused", "Running"};
+ QString e,a;
+ for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
+ if (i < expectedStates.count()) {
+ int exp = int(expectedStates.at(i));
+ if (!e.isEmpty())
+ e += QLatin1String(", ");
+ e += QLatin1String(stateStrings[exp]);
+ }
+ if (i < spy.count()) {
+ QAbstractAnimationJob::State actual = spy.states.at(i);
+ if (!a.isEmpty())
+ a += QLatin1String(", ");
+ if (int(actual) >= 0 && int(actual) <= 2) {
+ a += QLatin1String(stateStrings[int(actual)]);
+ } else {
+ a += QLatin1String("NaN");
+ }
+ }
+
+ }
+ qDebug("\n"
+ "expected (count == %d): %s\n"
+ "actual (count == %d): %s\n", expectedStates.count(), qPrintable(e), spy.count(), qPrintable(a));
+ }
+ return equals;
+}
+
+void tst_QSequentialAnimationGroupJob::pauseAndResume()
+{
+ // sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a2_s_o1 = new TestAnimation;
+ TestAnimation *a3_s_o1 = new TestAnimation;
+ a2_s_o1->setLoopCount(2);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+ sequence->setLoopCount(2);
+
+ StateChangeListener a1StateChangedSpy;
+ a1_s_o1->addAnimationChangeListener(&a1StateChangedSpy, QAbstractAnimationJob::StateChange);
+ StateChangeListener seqStateChangedSpy;
+ sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+
+ group.start();
+ group.pause();
+
+ // Current time = 1751
+ group.setCurrentTime(1751);
+ QCOMPARE(group.currentLoopTime(), 1751);
+ QCOMPARE(sequence->currentLoopTime(), 751);
+ QCOMPARE(sequence->currentLoop(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 1);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
+
+ QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped
+ QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused
+
+ QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped)));
+
+ //### is this the same test as compareStates test above?
+ QCOMPARE(a1StateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(a1StateChangedSpy.states.at(1), QAnimationGroupJob::Paused);
+ QCOMPARE(a1StateChangedSpy.states.at(2), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1StateChangedSpy.states.at(3), QAnimationGroupJob::Running);
+ QCOMPARE(a1StateChangedSpy.states.at(4), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Paused);
+
+ group.resume();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Running);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Running);
+
+ QVERIFY(group.currentLoopTime() >= 1751);
+ QVERIFY(sequence->currentLoopTime() >= 751);
+ QCOMPARE(sequence->currentLoop(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QVERIFY(a3_s_o1->currentLoopTime() >= 1);
+
+ QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
+ QCOMPARE(seqStateChangedSpy.states.at(2), QAnimationGroupJob::Running);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
+
+ QVERIFY(group.currentLoopTime() >= 1751);
+ QVERIFY(sequence->currentLoopTime() >= 751);
+ QCOMPARE(sequence->currentLoop(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QVERIFY(a3_s_o1->currentLoopTime() >= 1);
+
+ QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
+ QCOMPARE(seqStateChangedSpy.states.at(3), QAnimationGroupJob::Paused);
+
+ group.stop();
+
+ QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped
+ QCOMPARE(seqStateChangedSpy.states.at(4), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::restart()
+{
+ // originally was sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ //### no equivilant signal
+ //QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimationJob*)));
+
+ StateChangeListener seqStateChangedSpy;
+ sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ TestAnimation *anims[3];
+ StateChangeListener *animsStateChanged[3];
+
+ for (int i = 0; i < 3; i++) {
+ anims[i] = new TestAnimation(100);
+ animsStateChanged[i] = new StateChangeListener;
+ anims[i]->addAnimationChangeListener(animsStateChanged[i], QAbstractAnimationJob::StateChange);
+ }
+
+ anims[1]->setLoopCount(2);
+ sequence->appendAnimation(anims[0]);
+ sequence->appendAnimation(anims[1]);
+ sequence->appendAnimation(anims[2]);
+ sequence->setLoopCount(2);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+
+ group.start();
+
+ QTest::qWait(500);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+
+ QTest::qWait(300);
+ QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
+
+ for (int i = 0; i < 3; i++) {
+ QCOMPARE(animsStateChanged[i]->count(), 4);
+ QCOMPARE(animsStateChanged[i]->states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(animsStateChanged[i]->states.at(1), QAnimationGroupJob::Stopped);
+ QCOMPARE(animsStateChanged[i]->states.at(2), QAnimationGroupJob::Running);
+ QCOMPARE(animsStateChanged[i]->states.at(3), QAnimationGroupJob::Stopped);
+ }
+
+ QCOMPARE(seqStateChangedSpy.count(), 2);
+ QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
+
+ //QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
+ //for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
+ // QCOMPARE(static_cast<QAbstractAnimationJob*>(anims[i%3]), qVariantValue<QAbstractAnimationJob*>(seqCurrentAnimChangedSpy.at(i).at(0)));
+
+ group.start();
+
+ QCOMPARE(animsStateChanged[0]->count(), 5);
+ QCOMPARE(animsStateChanged[1]->count(), 4);
+ QCOMPARE(animsStateChanged[2]->count(), 4);
+ QCOMPARE(seqStateChangedSpy.count(), 3);
+}
+
+void tst_QSequentialAnimationGroupJob::looping()
+{
+ // originally was sequence operating on same object/property
+ QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ QAbstractAnimationJob *a1_s_o1 = new TestAnimation;
+ QAbstractAnimationJob *a2_s_o1 = new TestAnimation;
+ QAbstractAnimationJob *a3_s_o1 = new TestAnimation;
+
+ StateChangeListener a1Spy;
+ a1_s_o1->addAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange);
+ StateChangeListener a2Spy;
+ a2_s_o1->addAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange);
+ StateChangeListener a3Spy;
+ a3_s_o1->addAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange);
+ StateChangeListener seqSpy;
+ sequence->addAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange);
+
+ a2_s_o1->setLoopCount(2);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+ sequence->setLoopCount(2);
+
+ QSequentialAnimationGroupJob group;
+ StateChangeListener groupSpy;
+ group.addAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange);
+
+ group.appendAnimation(sequence);
+ group.setLoopCount(2);
+
+ group.start();
+ group.pause();
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 750);
+ QCOMPARE(sequence->currentLoop(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ // this animation is at the beginning because it is the current one inside sequence
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence->currentAnimation(), a3_s_o1);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
+
+ QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped
+ QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped)));
+
+ QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped
+ QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused)));
+
+ QCOMPARE(seqSpy.count(), 2); // Running,Paused
+ QCOMPARE(groupSpy.count(), 2); // Running,Paused
+
+ // Looping, current time = duration + 1
+ group.setCurrentTime(group.duration() + 1);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(group.currentLoop(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoop(), 0);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ // this animation is at the end because it was run on the previous loop
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped
+ QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped
+ QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused
+ << QAbstractAnimationJob::Stopped)));
+ QVERIFY(compareStates(seqSpy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused)));
+ QCOMPARE(groupSpy.count(), 2);
+
+ //cleanup
+ a1_s_o1->removeAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange);
+ a2_s_o1->removeAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange);
+ a3_s_o1->removeAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange);
+ sequence->removeAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange);
+ group.removeAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::startDelay()
+{
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(new QPauseAnimationJob(250));
+ group.appendAnimation(new QPauseAnimationJob(125));
+ QCOMPARE(group.totalDuration(), 375);
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+
+ QTest::qWait(500);
+
+ QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QVERIFY(group.currentLoopTime() == 375);
+}
+
+void tst_QSequentialAnimationGroupJob::clearGroup()
+{
+ QSequentialAnimationGroupJob group;
+
+ static const int animationCount = 20;
+
+ for (int i = 0; i < animationCount/2; ++i) {
+ QSequentialAnimationGroupJob *subGroup = new QSequentialAnimationGroupJob;
+ group.appendAnimation(subGroup);
+ group.appendAnimation(new QPauseAnimationJob(100));
+ subGroup->appendAnimation(new QPauseAnimationJob(10));
+ }
+
+ int count = 0;
+ for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
+ ++count;
+ QCOMPARE(count, animationCount);
+
+ group.clear();
+
+ QVERIFY(!group.firstChild() && !group.lastChild());
+ QCOMPARE(group.currentLoopTime(), 0);
+}
+
+void tst_QSequentialAnimationGroupJob::groupWithZeroDurationAnimations()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestValueAnimation *a1 = new TestValueAnimation(0);
+ a1->start = 42;
+ a1->end = 43;
+ group.appendAnimation(a1);
+
+ //this should just run fine and change nothing
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(a1));
+
+ TestValueAnimation *a2 = new TestValueAnimation(500);
+ a2->start = 13;
+ a2->end = 31;
+ group.appendAnimation(a2);
+
+ TestValueAnimation *a3 = new TestValueAnimation(0);
+ a3->start = 43;
+ a3->end = 44;
+ group.appendAnimation(a3);
+
+ TestValueAnimation *a4 = new TestValueAnimation(250);
+ a4->start = 13;
+ a4->end = 75;
+ group.appendAnimation(a4);
+
+ TestValueAnimation *a5 = new TestValueAnimation(0);
+ a5->start = 42;
+ a5->end = 12;
+ group.appendAnimation(a5);
+
+ QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want?
+ QCOMPARE((int)a2->value, 0);
+ QCOMPARE((int)a3->value, 0);
+ QCOMPARE((int)a4->value, 0);
+ QCOMPARE((int)a5->value, 0);
+
+ group.start();
+
+ QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want?
+ QCOMPARE((int)a2->value, 13);
+ QCOMPARE((int)a3->value, 0);
+ QCOMPARE((int)a4->value, 0);
+ QCOMPARE((int)a5->value, 0);
+
+ QTest::qWait(100);
+
+ QCOMPARE((int)a1->value, 43);
+ QVERIFY(a2->value > 13 && a2->value < 31);
+ QCOMPARE((int)a3->value, 0);
+ QCOMPARE((int)a4->value, 0);
+ QCOMPARE((int)a5->value, 0);
+
+ QTest::qWait(500);
+
+ QTRY_COMPARE((int)a3->value, 44);
+ QCOMPARE((int)a1->value, 43);
+ QCOMPARE((int)a2->value, 31);
+ //QCOMPARE((int)a4->value, 36);
+ QCOMPARE((int)a5->value, 0);
+ QCOMPARE(a1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a4->state(), QAnimationGroupJob::Running);
+ QCOMPARE(a5->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QTest::qWait(500);
+
+ QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE((int)a1->value, 43);
+ QCOMPARE((int)a2->value, 31);
+ QCOMPARE((int)a3->value, 44);
+ QCOMPARE((int)a4->value, 75);
+ QCOMPARE((int)a5->value, 12);
+ QCOMPARE(a1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a4->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a5->state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::propagateGroupUpdateToChildren()
+{
+ // this test verifies if group state changes are updating its children correctly
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation anim1(100);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::updateChildrenWithRunningGroup()
+{
+ // assert that its possible to modify a child's state directly while their group is running
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation anim(200);
+
+ StateChangeListener groupStateChangedSpy;
+ group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+ StateChangeListener childStateChangedSpy;
+ anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(groupStateChangedSpy.count(), 0);
+ QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Running);
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+
+ // starting directly a running child will not have any effect
+ anim.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ anim.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Paused);
+
+ // in the animation stops directly, the group will still be running
+ anim.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
+
+ //cleanup
+ group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+ anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::deleteChildrenWithRunningGroup()
+{
+ // test if children can be activated when their group is stopped
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation *anim1 = new TestAnimation(200);
+ group.appendAnimation(anim1);
+
+ QCOMPARE(group.duration(), anim1->duration());
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
+
+ QTest::qWait(100);
+ QTRY_VERIFY(group.currentLoopTime() > 0);
+
+ delete anim1;
+ QVERIFY(!group.firstChild());
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
+}
+
+void tst_QSequentialAnimationGroupJob::startChildrenWithStoppedGroup()
+{
+ // test if children can be activated when their group is stopped
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+}
+
+void tst_QSequentialAnimationGroupJob::stopGroupWithRunningChild()
+{
+ // children that started independently will not be affected by a group stop
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ anim1.stop();
+ anim2.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::startGroupWithRunningChild()
+{
+ // as the group has precedence over its children, starting a group will restart all the children
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation *anim1 = new TestAnimation(200);
+ TestAnimation *anim2 = new TestAnimation(200);
+
+ StateChangeListener stateChangedSpy1;
+ anim1->addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ StateChangeListener stateChangedSpy2;
+ anim2->addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(anim1);
+ group.appendAnimation(anim2);
+
+ anim1->start();
+ anim2->start();
+ anim2->pause();
+
+ QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running)));
+
+ QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused)));
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Paused);
+
+ group.start();
+
+ QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running)));
+ QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused)));
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Paused);
+
+ QTest::qWait(300);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
+
+ QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped);
+ QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped);
+
+ anim1->removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ anim2->removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::zeroDurationAnimation()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation *anim1 = new TestAnimation(0);
+ TestAnimation *anim2 = new TestAnimation(100);
+ TestValueAnimation *anim3 = new TestValueAnimation(0);
+ anim3->end = 100;
+
+ StateChangeListener stateChangedSpy;
+ anim1->addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ group.appendAnimation(anim1);
+ group.appendAnimation(anim2);
+ group.appendAnimation(anim3);
+ group.setLoopCount(2);
+ group.start();
+
+ QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+
+ //now let's try to seek to the next loop
+ group.setCurrentTime(group.duration() + 1);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ //TODO: test that anim3 was run
+ QCOMPARE(anim3->value, qreal(100)); //anim3 should have been run
+
+ anim1->removeAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::stopUncontrolledAnimations()
+{
+ QSequentialAnimationGroupJob group;
+
+ UncontrolledAnimation notTimeDriven;
+ QCOMPARE(notTimeDriven.totalDuration(), -1);
+
+ TestAnimation loopsForever(100);
+ loopsForever.setLoopCount(-1);
+
+ group.appendAnimation(&notTimeDriven);
+ group.appendAnimation(&loopsForever);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
+
+ notTimeDriven.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
+
+ loopsForever.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::finishWithUncontrolledAnimation()
+{
+ //1st case:
+ //first we test a group with one uncontrolled animation
+ QSequentialAnimationGroupJob group;
+ UncontrolledAnimation notTimeDriven;
+ group.appendAnimation(&notTimeDriven);
+ FinishedListener spy;
+ group.addAnimationChangeListener(&spy, QAbstractAnimationJob::Completion);
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven.currentLoopTime(), 0);
+
+ QTest::qWait(300); //wait for the end of notTimeDriven
+ QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ const int actualDuration = notTimeDriven.currentLoopTime();
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.currentLoopTime(), actualDuration);
+ QCOMPARE(spy.count(), 1);
+
+ //2nd case:
+ // lets make sure the seeking will work again
+ spy.clear();
+ TestAnimation anim;
+ group.appendAnimation(&anim);
+ StateChangeListener animStateChangedSpy;
+ anim.addAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ group.setCurrentTime(300);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven.currentLoopTime(), actualDuration);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+
+ //3rd case:
+ //now let's add a perfectly defined animation at the end
+ QCOMPARE(animStateChangedSpy.count(), 0);
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven.currentLoopTime(), 0);
+
+ QCOMPARE(animStateChangedSpy.count(), 0);
+
+ QTest::qWait(300); //wait for the end of notTimeDriven
+ QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+ QCOMPARE(animStateChangedSpy.count(), 1);
+ QTest::qWait(300); //wait for the end of anim
+
+ QTRY_COMPARE(anim.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim.currentLoopTime(), anim.duration());
+
+ //we should simply be at the end
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(animStateChangedSpy.count(), 2);
+ QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime());
+
+ //cleanup
+ group.removeAnimationChangeListener(&spy, QAbstractAnimationJob::Completion);
+ anim.removeAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::addRemoveAnimation()
+{
+ //this test is specific to the sequential animation group
+ QSequentialAnimationGroupJob group;
+
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QAbstractAnimationJob *anim1 = new TestAnimation;
+ group.appendAnimation(anim1);
+ QCOMPARE(group.duration(), 250);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim1);
+
+ //let's append an animation
+ QAbstractAnimationJob *anim2 = new TestAnimation;
+ group.appendAnimation(anim2);
+ QCOMPARE(group.duration(), 500);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim1);
+
+ //let's prepend an animation
+ QAbstractAnimationJob *anim0 = new TestAnimation;
+ group.prependAnimation(anim0);
+ QCOMPARE(group.duration(), 750);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation
+
+ group.setCurrentTime(300); //anim0 | anim1 | anim2
+ QCOMPARE(group.currentLoopTime(), 300);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentLoopTime(), 50);
+
+ group.removeAnimation(anim0); //anim1 | anim2
+ QCOMPARE(group.currentLoopTime(), 50);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentLoopTime(), 50);
+
+ group.setCurrentTime(0);
+ group.prependAnimation(anim0); //anim0 | anim1 | anim2
+ group.setCurrentTime(300);
+ QCOMPARE(group.currentLoopTime(), 300);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentLoopTime(), 50);
+
+ group.removeAnimation(anim1); //anim0 | anim2
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(group.currentAnimation(), anim2);
+ QCOMPARE(anim0->currentLoopTime(), 250);
+}
+
+void tst_QSequentialAnimationGroupJob::currentAnimation()
+{
+ QSequentialAnimationGroupJob group;
+ QVERIFY(group.currentAnimation() == 0);
+
+ TestAnimation anim(0);
+ group.appendAnimation(&anim);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+}
+
+void tst_QSequentialAnimationGroupJob::currentAnimationWithZeroDuration()
+{
+ QSequentialAnimationGroupJob group;
+ QVERIFY(group.currentAnimation() == 0);
+
+ TestAnimation zero1(0);
+ TestAnimation zero2(0);
+
+ TestAnimation anim;
+
+ TestAnimation zero3(0);
+ TestAnimation zero4(0);
+
+ group.appendAnimation(&zero1);
+ group.appendAnimation(&zero2);
+ group.appendAnimation(&anim);
+ group.appendAnimation(&zero3);
+ group.appendAnimation(&zero4);
+
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero1));
+
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+
+ group.setCurrentTime(group.duration());
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero4));
+
+ group.setDirection(QAbstractAnimationJob::Backward);
+
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero1));
+
+ group.setCurrentTime(group.duration());
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+}
+
+void tst_QSequentialAnimationGroupJob::insertAnimation()
+{
+ QSequentialAnimationGroupJob group;
+ group.setLoopCount(2);
+ TestAnimation *anim = new TestAnimation;
+ group.appendAnimation(anim);
+ QCOMPARE(group.duration(), anim->duration());
+ group.setCurrentTime(300);
+ QCOMPARE(group.currentLoop(), 1);
+
+ //this will crash if the sequential group calls duration on the created animation
+ group.appendAnimation(new TestAnimation);
+}
+
+class ClearFinishedListener: public QAnimationJobChangeListener
+{
+public:
+ ClearFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *)
+ {
+ group->clear();
+ }
+
+ QSequentialAnimationGroupJob *group;
+};
+
+class RefillFinishedListener: public QAnimationJobChangeListener
+{
+public:
+ RefillFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *)
+ {
+ group->stop();
+ group->clear();
+ group->appendAnimation(new TestAnimation);
+ group->start();
+ }
+
+ QSequentialAnimationGroupJob *group;
+};
+
+void tst_QSequentialAnimationGroupJob::clear()
+{
+ QSKIP("deleting an animation when finished is not currently supported");
+ QSequentialAnimationGroupJob group;
+ TestAnimation *anim1 = new TestAnimation;
+ group.appendAnimation(anim1);
+ ClearFinishedListener clearListener(&group);
+ anim1->addAnimationChangeListener(&clearListener, QAbstractAnimationJob::Completion);
+
+ TestAnimation *anim2 = new TestAnimation;
+ group.appendAnimation(anim2);
+ QCOMPARE(group.firstChild(), anim1);
+ QCOMPARE(group.lastChild(), anim2);
+
+ group.start();
+ QTest::qWait(anim1->duration() + 100);
+ QTRY_VERIFY(!group.firstChild());
+ QCOMPARE(group.state(), QAbstractAnimationJob::Stopped);
+ QCOMPARE(group.currentLoopTime(), 0);
+
+ anim1 = new TestAnimation;
+ group.appendAnimation(anim1);
+ RefillFinishedListener refillListener(&group);
+ anim1->addAnimationChangeListener(&refillListener, QAbstractAnimationJob::Completion);
+ group.start();
+ QTest::qWait(anim1->duration() + 100);
+ QTRY_COMPARE(group.state(), QAbstractAnimationJob::Running);
+}
+
+void tst_QSequentialAnimationGroupJob::pauseResume()
+{
+ QParallelAnimationGroupJob group;
+ TestAnimation *anim = new TestAnimation;
+ group.appendAnimation(anim);
+ StateChangeListener spy;
+ anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
+ QCOMPARE(group.duration(), 250);
+ group.start();
+ QTest::qWait(100);
+ QTRY_COMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ const int currentTime = group.currentLoopTime();
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(group.currentLoopTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ group.resume();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentLoopTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+
+ anim->removeAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
+}
+
+QTEST_MAIN(tst_QSequentialAnimationGroupJob)
+#include "tst_qsequentialanimationgroupjob.moc"
diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro
new file mode 100644
index 0000000000..4f9ebbc350
--- /dev/null
+++ b/tests/auto/qml/debugger/debugger.pro
@@ -0,0 +1,16 @@
+TEMPLATE = subdirs
+
+PRIVATETESTS += \
+ qqmlenginedebug \
+ qqmldebugclient \
+ qqmldebugservice \
+ qqmldebugjs \
+ qqmlinspector \
+ qqmlprofilerservice \
+ qpacketprotocol \
+ qv8profilerservice \
+ qdebugmessageservice
+
+contains(QT_CONFIG, private_tests) {
+ SUBDIRS += $$PRIVATETESTS
+}
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml b/tests/auto/qml/debugger/qdebugmessageservice/data/test.qml
index ab86c7d468..ab86c7d468 100644
--- a/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml
+++ b/tests/auto/qml/debugger/qdebugmessageservice/data/test.qml
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro
new file mode 100644
index 0000000000..afda4b23bd
--- /dev/null
+++ b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro
@@ -0,0 +1,21 @@
+CONFIG += testcase
+TARGET = tst_qdebugmessageservice
+QT += network qml-private testlib
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+
+SOURCES += tst_qdebugmessageservice.cpp \
+ ../shared/debugutil.cpp
+
+INCLUDEPATH += ../shared
+
+include(../../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+OTHER_FILES += data/test.qml
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
new file mode 100644
index 0000000000..a19fd4b766
--- /dev/null
+++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/private/qqmldebugclient_p.h>
+
+//QQmlDebugTest
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+
+const char *NORMALMODE = "-qmljsdebugger=port:3777,block";
+const char *QMLFILE = "test.qml";
+
+class QQmlDebugMsgClient;
+class tst_QDebugMessageService : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QDebugMessageService();
+
+ void init();
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void cleanup();
+
+ void retrieveDebugOutput();
+
+private:
+ QQmlDebugProcess *m_process;
+ QQmlDebugMsgClient *m_client;
+ QQmlDebugConnection *m_connection;
+};
+
+struct LogEntry {
+ LogEntry(QtMsgType _type, QString _message)
+ : type(_type), message(_message) {}
+
+ QtMsgType type;
+ QString message;
+ int line;
+ QString file;
+ QString function;
+
+ QString toString() const { return QString::number(type) + ": " + message; }
+};
+
+bool operator==(const LogEntry &t1, const LogEntry &t2)
+{
+ return t1.type == t2.type && t1.message == t2.message
+ && t1.line == t2.line && t1.file == t2.file
+ && t1.function == t2.function;
+}
+
+class QQmlDebugMsgClient : public QQmlDebugClient
+{
+ Q_OBJECT
+public:
+ QQmlDebugMsgClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("DebugMessages"), connection)
+ {
+ }
+
+ QList<LogEntry> logBuffer;
+
+protected:
+ //inherited from QQmlDebugClient
+ void stateChanged(State state);
+ void messageReceived(const QByteArray &data);
+
+signals:
+ void enabled();
+ void debugOutput();
+};
+
+void QQmlDebugMsgClient::stateChanged(State state)
+{
+ if (state == Enabled) {
+ emit enabled();
+ }
+}
+
+void QQmlDebugMsgClient::messageReceived(const QByteArray &data)
+{
+ QDataStream ds(data);
+ QByteArray command;
+ ds >> command;
+
+ if (command == "MESSAGE") {
+ int type;
+ QByteArray message;
+ QByteArray file;
+ QByteArray function;
+ int line;
+ ds >> type >> message >> file >> line >> function;
+ QVERIFY(ds.atEnd());
+
+ QVERIFY(type >= QtDebugMsg);
+ QVERIFY(type <= QtFatalMsg);
+
+ LogEntry entry((QtMsgType)type, QString::fromUtf8(message));
+ entry.line = line;
+ entry.file = QString::fromUtf8(file);
+ entry.function = QString::fromUtf8(function);
+ logBuffer << entry;
+ emit debugOutput();
+ } else {
+ QFAIL("Unknown message");
+ }
+}
+
+tst_QDebugMessageService::tst_QDebugMessageService()
+{
+}
+
+void tst_QDebugMessageService::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ m_process = 0;
+ m_client = 0;
+ m_connection = 0;
+}
+
+void tst_QDebugMessageService::cleanupTestCase()
+{
+ if (m_process)
+ delete m_process;
+
+ if (m_client)
+ delete m_client;
+
+ if (m_connection)
+ delete m_connection;
+}
+
+void tst_QDebugMessageService::init()
+{
+ m_connection = new QQmlDebugConnection();
+ m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
+ m_client = new QQmlDebugMsgClient(m_connection);
+
+ m_process->start(QStringList() << QLatin1String(NORMALMODE) << QQmlDataTest::instance()->testFile(QMLFILE));
+ if (!m_process->waitForSessionStart()) {
+ QFAIL(QString("Could not launch app. Application output: \n%1").arg(m_process->output()).toAscii());
+ }
+
+ m_connection->connectToHost("127.0.0.1", 3777);
+ QVERIFY(m_connection->waitForConnected());
+
+ QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(enabled())));
+}
+
+void tst_QDebugMessageService::cleanup()
+{
+ if (QTest::currentTestFailed())
+ qDebug() << m_process->output();
+ if (m_process)
+ delete m_process;
+
+ if (m_client)
+ delete m_client;
+
+ if (m_connection)
+ delete m_connection;
+
+ m_process = 0;
+ m_client = 0;
+ m_connection = 0;
+}
+
+void tst_QDebugMessageService::retrieveDebugOutput()
+{
+ init();
+
+ int maxTries = 2;
+ while ((m_client->logBuffer.size() < 2)
+ || (maxTries-- > 0))
+ QQmlDebugTest::waitForSignal(m_client, SIGNAL(debugOutput()), 1000);
+
+ QVERIFY(m_client->logBuffer.size() >= 2);
+
+ const QString path =
+ QUrl::fromLocalFile(QQmlDataTest::instance()->testFile(QMLFILE)).toString();
+ LogEntry entry1(QtDebugMsg, QLatin1String("console.log"));
+ entry1.line = 48;
+ entry1.file = path;
+ entry1.function = QLatin1String("onCompleted");
+ LogEntry entry2(QtDebugMsg, QLatin1String("console.count: 1"));
+ entry2.line = 49;
+ entry2.file = path;
+ entry2.function = QLatin1String("onCompleted");
+
+ QVERIFY(m_client->logBuffer.contains(entry1));
+ QVERIFY(m_client->logBuffer.contains(entry2));
+}
+
+QTEST_MAIN(tst_QDebugMessageService)
+
+#include "tst_qdebugmessageservice.moc"
diff --git a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro
new file mode 100644
index 0000000000..88439196a7
--- /dev/null
+++ b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TARGET = tst_qpacketprotocol
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qpacketprotocol.cpp \
+ ../shared/debugutil.cpp
+
+CONFIG += parallel_test
+QT += qml-private network testlib
diff --git a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
new file mode 100644
index 0000000000..c02dd2d8fa
--- /dev/null
+++ b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QTcpSocket>
+#include <QTcpServer>
+#include <QDebug>
+#include <QBuffer>
+
+#include <private/qpacketprotocol_p.h>
+
+#include "../shared/debugutil_p.h"
+
+class tst_QPacketProtocol : public QObject
+{
+ Q_OBJECT
+
+private:
+ QTcpServer *m_server;
+ QTcpSocket *m_client;
+ QTcpSocket *m_serverConn;
+
+private slots:
+ void init();
+ void cleanup();
+
+ void maximumPacketSize();
+ void setMaximumPacketSize();
+ void setMaximumPacketSize_data();
+ void send();
+ void send_data();
+ void packetsAvailable();
+ void packetsAvailable_data();
+ void clear();
+ void read();
+ void device();
+
+ void tst_QPacket_clear();
+};
+
+void tst_QPacketProtocol::init()
+{
+ m_server = new QTcpServer(this);
+ m_serverConn = 0;
+ QVERIFY(m_server->listen(QHostAddress("127.0.0.1")));
+
+ m_client = new QTcpSocket(this);
+ m_client->connectToHost(m_server->serverAddress(), m_server->serverPort());
+
+ QVERIFY(m_client->waitForConnected());
+ QVERIFY(m_server->waitForNewConnection(5000));
+ m_serverConn = m_server->nextPendingConnection();
+}
+
+void tst_QPacketProtocol::cleanup()
+{
+ delete m_client;
+ delete m_serverConn;
+ delete m_server;
+}
+
+void tst_QPacketProtocol::maximumPacketSize()
+{
+ QPacketProtocol p(m_client);
+ QCOMPARE(p.maximumPacketSize(), 0x7FFFFFFF);
+}
+
+void tst_QPacketProtocol::setMaximumPacketSize()
+{
+ QFETCH(qint32, size);
+ QFETCH(qint32, expected);
+
+ QPacketProtocol out(m_serverConn);
+ QCOMPARE(out.setMaximumPacketSize(size), expected);
+}
+
+void tst_QPacketProtocol::setMaximumPacketSize_data()
+{
+ QTest::addColumn<int>("size");
+ QTest::addColumn<int>("expected");
+
+ QTest::newRow("invalid") << qint32(sizeof(qint32) - 1) << qint32(0x7FFFFFFF);
+ QTest::newRow("still invalid") << qint32(sizeof(qint32)) << qint32(0x7FFFFFFF);
+ QTest::newRow("valid") << qint32(sizeof(qint32) + 1) << qint32(sizeof(qint32) + 1);
+}
+
+void tst_QPacketProtocol::send()
+{
+ QFETCH(bool, useAutoSend);
+
+ QPacketProtocol in(m_client);
+ QPacketProtocol out(m_serverConn);
+
+ QByteArray ba;
+ int num;
+
+ if (useAutoSend) {
+ out.send() << "Hello world" << 123;
+ } else {
+ QPacket packet;
+ packet << "Hello world" << 123;
+ out.send(packet);
+ }
+
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+
+ QPacket p = in.read();
+ p >> ba >> num;
+ QCOMPARE(ba, QByteArray("Hello world") + '\0');
+ QCOMPARE(num, 123);
+}
+
+void tst_QPacketProtocol::send_data()
+{
+ QTest::addColumn<bool>("useAutoSend");
+
+ QTest::newRow("auto send") << true;
+ QTest::newRow("no auto send") << false;
+}
+
+void tst_QPacketProtocol::packetsAvailable()
+{
+ QFETCH(int, packetCount);
+
+ QPacketProtocol out(m_client);
+ QPacketProtocol in(m_serverConn);
+
+ QCOMPARE(out.packetsAvailable(), qint64(0));
+ QCOMPARE(in.packetsAvailable(), qint64(0));
+
+ for (int i=0; i<packetCount; i++)
+ out.send() << "Hello";
+
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QCOMPARE(in.packetsAvailable(), qint64(packetCount));
+}
+
+void tst_QPacketProtocol::packetsAvailable_data()
+{
+ QTest::addColumn<int>("packetCount");
+
+ QTest::newRow("1") << 1;
+ QTest::newRow("2") << 2;
+ QTest::newRow("10") << 10;
+}
+
+void tst_QPacketProtocol::clear()
+{
+ QPacketProtocol in(m_client);
+ QPacketProtocol out(m_serverConn);
+
+ out.send() << 123;
+ out.send() << 456;
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+
+ in.clear();
+ QVERIFY(in.read().isEmpty());
+}
+
+void tst_QPacketProtocol::read()
+{
+ QPacketProtocol in(m_client);
+ QPacketProtocol out(m_serverConn);
+
+ QVERIFY(in.read().isEmpty());
+
+ out.send() << 123;
+ out.send() << 456;
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+
+ int num;
+
+ QPacket p1 = in.read();
+ QVERIFY(!p1.isEmpty());
+ p1 >> num;
+ QCOMPARE(num, 123);
+
+ QPacket p2 = in.read();
+ QVERIFY(!p2.isEmpty());
+ p2 >> num;
+ QCOMPARE(num, 456);
+
+ QVERIFY(in.read().isEmpty());
+}
+
+void tst_QPacketProtocol::device()
+{
+ QPacketProtocol p(m_client);
+ QVERIFY(p.device() == m_client);
+}
+
+void tst_QPacketProtocol::tst_QPacket_clear()
+{
+ QPacketProtocol protocol(m_client);
+
+ QPacket packet;
+
+ packet << "Hello world!" << 123;
+ protocol.send(packet);
+
+ packet.clear();
+ QVERIFY(packet.isEmpty());
+ packet << "Goodbyte world!" << 789;
+ protocol.send(packet);
+
+ QByteArray ba;
+ int num;
+ QPacketProtocol in(m_serverConn);
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+
+ QPacket p1 = in.read();
+ p1 >> ba >> num;
+ QCOMPARE(ba, QByteArray("Hello world!") + '\0');
+ QCOMPARE(num, 123);
+
+ QPacket p2 = in.read();
+ p2 >> ba >> num;
+ QCOMPARE(ba, QByteArray("Goodbyte world!") + '\0');
+ QCOMPARE(num, 789);
+}
+
+QTEST_MAIN(tst_QPacketProtocol)
+
+#include "tst_qpacketprotocol.moc"
diff --git a/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro
new file mode 100644
index 0000000000..d298b5c087
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_qqmldebugclient
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmldebugclient.cpp \
+ ../shared/debugutil.cpp
+
+CONFIG += declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
new file mode 100644
index 0000000000..2891076af6
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtQml/qqmlengine.h>
+
+#include "../shared/debugutil_p.h"
+
+#define PORT 13770
+#define STR_PORT "13770"
+
+class tst_QQmlDebugClient : public QObject
+{
+ Q_OBJECT
+
+private:
+ QQmlDebugConnection *m_conn;
+
+private slots:
+ void initTestCase();
+
+ void name();
+ void state();
+ void sendMessage();
+ void parallelConnect();
+ void sequentialConnect();
+};
+
+void tst_QQmlDebugClient::initTestCase()
+{
+ const QString waitingMsg = QString("QQmlDebugServer: Waiting for connection on port %1...").arg(PORT);
+ QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
+ new QQmlEngine(this);
+
+ m_conn = new QQmlDebugConnection(this);
+
+ QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn);
+ QQmlDebugTestService service("tst_QQmlDebugClient::handshake()");
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established");
+ for (int i = 0; i < 50; ++i) {
+ // try for 5 seconds ...
+ m_conn->connectToHost("127.0.0.1", PORT);
+ if (m_conn->waitForConnected())
+ break;
+ QTest::qSleep(100);
+ }
+
+ QVERIFY(m_conn->isConnected());
+
+ QTRY_VERIFY(QQmlDebugService::hasDebuggingClient());
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+}
+
+void tst_QQmlDebugClient::name()
+{
+ QString name = "tst_QQmlDebugClient::name()";
+
+ QQmlDebugClient client(name, m_conn);
+ QCOMPARE(client.name(), name);
+}
+
+void tst_QQmlDebugClient::state()
+{
+ {
+ QQmlDebugConnection dummyConn;
+ QQmlDebugClient client("tst_QQmlDebugClient::state()", &dummyConn);
+ QCOMPARE(client.state(), QQmlDebugClient::NotConnected);
+ QCOMPARE(client.serviceVersion(), -1.0f);
+ }
+
+ QQmlDebugTestClient client("tst_QQmlDebugClient::state()", m_conn);
+ QCOMPARE(client.state(), QQmlDebugClient::Unavailable);
+
+ {
+ QQmlDebugTestService service("tst_QQmlDebugClient::state()", 2);
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+ QCOMPARE(client.serviceVersion(), 2.0f);
+ }
+
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable);
+
+ // duplicate plugin name
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\" ");
+ QQmlDebugClient client2("tst_QQmlDebugClient::state()", m_conn);
+ QCOMPARE(client2.state(), QQmlDebugClient::NotConnected);
+
+ QQmlDebugClient client3("tst_QQmlDebugClient::state3()", 0);
+ QCOMPARE(client3.state(), QQmlDebugClient::NotConnected);
+}
+
+void tst_QQmlDebugClient::sendMessage()
+{
+ QQmlDebugTestService service("tst_QQmlDebugClient::sendMessage()");
+ QQmlDebugTestClient client("tst_QQmlDebugClient::sendMessage()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+}
+
+void tst_QQmlDebugClient::parallelConnect()
+{
+ QQmlDebugConnection connection2;
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Another client is already connected");
+ // will connect & immediately disconnect
+ connection2.connectToHost("127.0.0.1", PORT);
+ QVERIFY(connection2.waitForConnected());
+ QTRY_COMPARE(connection2.state(), QAbstractSocket::UnconnectedState);
+ QVERIFY(m_conn->isConnected());
+}
+
+void tst_QQmlDebugClient::sequentialConnect()
+{
+ QQmlDebugConnection connection2;
+ QQmlDebugTestClient client2("tst_QQmlDebugClient::handshake()", &connection2);
+ QQmlDebugTestService service("tst_QQmlDebugClient::handshake()");
+
+ m_conn->close();
+ QVERIFY(!m_conn->isConnected());
+ QCOMPARE(m_conn->state(), QAbstractSocket::UnconnectedState);
+
+ // Make sure that the disconnect is actually delivered to the server
+ QTest::qWait(100);
+
+ connection2.connectToHost("127.0.0.1", PORT);
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established");
+ QVERIFY(connection2.waitForConnected());
+ QVERIFY(connection2.isConnected());
+ QTRY_VERIFY(client2.state() == QQmlDebugClient::Enabled);
+}
+
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ char arg[] = "-qmljsdebugger=port:" STR_PORT;
+ _argv[_argc - 1] = arg;
+
+ QGuiApplication app(_argc, _argv);
+ tst_QQmlDebugClient tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
+
+#include "tst_qqmldebugclient.moc"
+
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
index 1f0f9e22c9..1f0f9e22c9 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml b/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml
index fd81b3f805..fd81b3f805 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml b/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml
index ad4144be11..ad4144be11 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml b/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml
index 993f33a661..993f33a661 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml b/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml
index b491087a02..b491087a02 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml b/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml
index 4fff66a325..4fff66a325 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml b/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml
index e03ba2ca79..e03ba2ca79 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml b/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml
index 690f9fd446..690f9fd446 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.js b/tests/auto/qml/debugger/qqmldebugjs/data/test.js
index 7de138bdf6..7de138bdf6 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.js
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/test.js
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml b/tests/auto/qml/debugger/qqmldebugjs/data/test.qml
index 200f26b1c3..200f26b1c3 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/test.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml b/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml
index d9440415d2..d9440415d2 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
new file mode 100644
index 0000000000..72b0e77f71
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
@@ -0,0 +1,29 @@
+CONFIG += testcase
+TARGET = tst_qqmldebugjs
+QT += qml-private testlib
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmldebugjs.cpp \
+ ../shared/debugutil.cpp
+
+INCLUDEPATH += ../shared
+
+include (../../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+OTHER_FILES += data/test.qml data/test.js \
+ data/timer.qml \
+ data/exception.qml \
+ data/oncompleted.qml \
+ data/loadjsfile.qml \
+ data/condition.qml \
+ data/changeBreakpoint.qml \
+ data/stepAction.qml \
+ data/breakpointRelocation.qml \
+ data/createComponent.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
new file mode 100644
index 0000000000..9a8b00bb6c
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -0,0 +1,1790 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtCore/QProcess>
+#include <QtCore/QTimer>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QMutex>
+#include <QtCore/QLibraryInfo>
+#include <QtQml/private/qqmldebugclient_p.h>
+#include <QtQml/QJSEngine>
+
+//QQmlDebugTest
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+const char *V8REQUEST = "v8request";
+const char *V8MESSAGE = "v8message";
+const char *SEQ = "seq";
+const char *TYPE = "type";
+const char *COMMAND = "command";
+const char *ARGUMENTS = "arguments";
+const char *STEPACTION = "stepaction";
+const char *STEPCOUNT = "stepcount";
+const char *EXPRESSION = "expression";
+const char *FRAME = "frame";
+const char *GLOBAL = "global";
+const char *DISABLEBREAK = "disable_break";
+const char *HANDLES = "handles";
+const char *INCLUDESOURCE = "includeSource";
+const char *FROMFRAME = "fromFrame";
+const char *TOFRAME = "toFrame";
+const char *BOTTOM = "bottom";
+const char *NUMBER = "number";
+const char *FRAMENUMBER = "frameNumber";
+const char *TYPES = "types";
+const char *IDS = "ids";
+const char *FILTER = "filter";
+const char *FROMLINE = "fromLine";
+const char *TOLINE = "toLine";
+const char *TARGET = "target";
+const char *LINE = "line";
+const char *COLUMN = "column";
+const char *ENABLED = "enabled";
+const char *CONDITION = "condition";
+const char *IGNORECOUNT = "ignoreCount";
+const char *BREAKPOINT = "breakpoint";
+const char *FLAGS = "flags";
+
+const char *CONTINEDEBUGGING = "continue";
+const char *EVALUATE = "evaluate";
+const char *LOOKUP = "lookup";
+const char *BACKTRACE = "backtrace";
+const char *SCOPE = "scope";
+const char *SCOPES = "scopes";
+const char *SCRIPTS = "scripts";
+const char *SOURCE = "source";
+const char *SETBREAKPOINT = "setbreakpoint";
+const char *CHANGEBREAKPOINT = "changebreakpoint";
+const char *CLEARBREAKPOINT = "clearbreakpoint";
+const char *SETEXCEPTIONBREAK = "setexceptionbreak";
+const char *V8FLAGS = "v8flags";
+const char *VERSION = "version";
+const char *DISCONNECT = "disconnect";
+const char *LISTBREAKPOINTS = "listbreakpoints";
+const char *GARBAGECOLLECTOR = "gc";
+//const char *PROFILE = "profile";
+
+const char *CONNECT = "connect";
+const char *INTERRUPT = "interrupt";
+const char *BREAKAFTERCOMPILE = "breakaftercompile";
+
+const char *REQUEST = "request";
+const char *IN = "in";
+const char *NEXT = "next";
+const char *OUT = "out";
+
+const char *FUNCTION = "function";
+const char *SCRIPT = "script";
+const char *SCRIPTREGEXP = "scriptRegExp";
+const char *EVENT = "event";
+
+const char *ALL = "all";
+const char *UNCAUGHT = "uncaught";
+
+//const char *PAUSE = "pause";
+//const char *RESUME = "resume";
+
+const char *BLOCKMODE = "-qmljsdebugger=port:3771,block";
+const char *NORMALMODE = "-qmljsdebugger=port:3771";
+const char *TEST_QMLFILE = "test.qml";
+const char *TEST_JSFILE = "test.js";
+const char *TIMER_QMLFILE = "timer.qml";
+const char *LOADJSFILE_QMLFILE = "loadjsfile.qml";
+const char *EXCEPTION_QMLFILE = "exception.qml";
+const char *ONCOMPLETED_QMLFILE = "oncompleted.qml";
+const char *CREATECOMPONENT_QMLFILE = "createComponent.qml";
+const char *CONDITION_QMLFILE = "condition.qml";
+const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml";
+const char *STEPACTION_QMLFILE = "stepAction.qml";
+const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml";
+
+#define VARIANTMAPINIT \
+ QString obj("{}"); \
+ QJSValue jsonVal = parser.call(QJSValueList() << obj); \
+ jsonVal.setProperty(SEQ,QJSValue(seq++)); \
+ jsonVal.setProperty(TYPE,REQUEST);
+
+
+#undef QVERIFY
+#define QVERIFY(statement) \
+do {\
+ if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\
+ if (QTest::currentTestFailed()) \
+ qDebug().nospace() << "\nDEBUGGEE OUTPUT:\n" << process->output();\
+ return;\
+ }\
+} while (0)
+
+
+class QJSDebugClient;
+
+class tst_QQmlDebugJS : public QQmlDataTest
+{
+ Q_OBJECT
+
+ bool init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true);
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void cleanup();
+
+ void connect();
+ void interrupt();
+ void breakAfterCompile();
+ void getVersion();
+ void getVersionWhenAttaching();
+
+ void applyV8Flags();
+
+ void disconnect();
+
+ void gc();
+
+ void listBreakpoints();
+
+ void setBreakpointInScriptOnCompleted();
+ void setBreakpointInScriptOnComponentCreated();
+ void setBreakpointInScriptOnTimerCallback();
+ void setBreakpointInScriptInDifferentFile();
+ void setBreakpointInScriptOnComment();
+ void setBreakpointInScriptOnEmptyLine();
+ void setBreakpointInScriptWithCondition();
+ //void setBreakpointInFunction(); //NOT SUPPORTED
+ void setBreakpointOnEvent();
+ void setBreakpointWhenAttaching();
+
+ void changeBreakpoint();
+ void changeBreakpointOnCondition();
+
+ void clearBreakpoint();
+
+ void setExceptionBreak();
+
+ void stepNext();
+ void stepNextWithCount();
+ void stepIn();
+ void stepOut();
+ void continueDebugging();
+
+ void backtrace();
+
+ void getFrameDetails();
+
+ void getScopeDetails();
+
+ void evaluateInGlobalScope();
+ void evaluateInLocalScope();
+
+ void getScopes();
+
+ void getScripts();
+
+ void getSource();
+
+ // void profile(); //NOT SUPPORTED
+
+ // void verifyQMLOptimizerDisabled();
+
+private:
+ QQmlDebugProcess *process;
+ QJSDebugClient *client;
+ QQmlDebugConnection *connection;
+ QTime t;
+};
+
+class QJSDebugClient : public QQmlDebugClient
+{
+ Q_OBJECT
+public:
+ enum StepAction
+ {
+ Continue,
+ In,
+ Out,
+ Next
+ };
+
+ enum Exception
+ {
+ All,
+ Uncaught
+ };
+
+// enum ProfileCommand
+// {
+// Pause,
+// Resume
+// };
+
+ QJSDebugClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("V8Debugger"), connection),
+ seq(0)
+ {
+ parser = jsEngine.evaluate(QLatin1String("JSON.parse"));
+ stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
+ }
+
+ void connect();
+ void interrupt();
+ void breakAfterCompile(bool enabled);
+
+ void continueDebugging(StepAction stepAction, int stepCount = 1);
+ void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
+ void lookup(QList<int> handles, bool includeSource = false);
+ void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
+ void frame(int number = -1);
+ void scope(int number = -1, int frameNumber = -1);
+ void scopes(int frameNumber = -1);
+ void scripts(int types = 4, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
+ void source(int frame = -1, int fromLine = -1, int toLine = -1);
+ void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = true, QString condition = QString(), int ignoreCount = -1);
+ void changeBreakpoint(int breakpoint, bool enabled = true, QString condition = QString(), int ignoreCount = -1);
+ void clearBreakpoint(int breakpoint);
+ void setExceptionBreak(Exception type, bool enabled = false);
+ void v8flags(QString flags);
+ void version();
+ //void profile(ProfileCommand command); //NOT SUPPORTED
+ void disconnect();
+ void gc();
+ void listBreakpoints();
+
+protected:
+ //inherited from QQmlDebugClient
+ void stateChanged(State state);
+ void messageReceived(const QByteArray &data);
+
+signals:
+ void enabled();
+ void connected();
+ void interruptRequested();
+ void breakAfterCompileRequested();
+ void result();
+ void stopped();
+
+private:
+ void sendMessage(const QByteArray &);
+ void flushSendBuffer();
+ QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray());
+
+private:
+ QJSEngine jsEngine;
+ int seq;
+
+ QList<QByteArray> sendBuffer;
+public:
+ QJSValue parser;
+ QJSValue stringify;
+ QByteArray response;
+
+};
+
+void QJSDebugClient::connect()
+{
+ sendMessage(packMessage(CONNECT));
+}
+
+void QJSDebugClient::interrupt()
+{
+ sendMessage(packMessage(INTERRUPT));
+}
+
+void QJSDebugClient::breakAfterCompile(bool enabled)
+{
+ QByteArray request;
+ QDataStream rs(&request, QIODevice::WriteOnly);
+ rs << enabled;
+ sendMessage(packMessage(BREAKAFTERCOMPILE, request));
+}
+
+void QJSDebugClient::continueDebugging(StepAction action, int count)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "continue",
+ // "arguments" : { "stepaction" : <"in", "next" or "out">,
+ // "stepcount" : <number of steps (default 1)>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CONTINEDEBUGGING)));
+
+ if (action != Continue) {
+ QJSValue args = parser.call(QJSValueList() << obj);
+ switch (action) {
+ case In: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(IN)));
+ break;
+ case Out: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(OUT)));
+ break;
+ case Next: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(NEXT)));
+ break;
+ default:break;
+ }
+ if (!args.isUndefined()) {
+ if (count != 1)
+ args.setProperty(QLatin1String(STEPCOUNT),QJSValue(count));
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+ }
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::evaluate(QString expr, bool global, bool disableBreak, int frame, const QVariantMap &/*addContext*/)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "evaluate",
+ // "arguments" : { "expression" : <expression to evaluate>,
+ // "frame" : <number>,
+ // "global" : <boolean>,
+ // "disable_break" : <boolean>,
+ // "additional_context" : [
+ // { "name" : <name1>, "handle" : <handle1> },
+ // { "name" : <name2>, "handle" : <handle2> },
+ // ...
+ // ]
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(EVALUATE)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(EXPRESSION),QJSValue(expr));
+
+ if (frame != -1)
+ args.setProperty(QLatin1String(FRAME),QJSValue(frame));
+
+ if (global)
+ args.setProperty(QLatin1String(GLOBAL),QJSValue(global));
+
+ if (disableBreak)
+ args.setProperty(QLatin1String(DISABLEBREAK),QJSValue(disableBreak));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::lookup(QList<int> handles, bool includeSource)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "lookup",
+ // "arguments" : { "handles" : <array of handles>,
+ // "includeSource" : <boolean indicating whether the source will be included when script objects are returned>,
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LOOKUP)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ QString arr("[]");
+ QJSValue array = parser.call(QJSValueList() << arr);
+ int index = 0;
+ foreach (int handle, handles) {
+ array.setProperty(index++,QJSValue(handle));
+ }
+ args.setProperty(QLatin1String(HANDLES),array);
+
+ if (includeSource)
+ args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "backtrace",
+ // "arguments" : { "fromFrame" : <number>
+ // "toFrame" : <number>
+ // "bottom" : <boolean, set to true if the bottom of the stack is requested>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(BACKTRACE)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ if (fromFrame != -1)
+ args.setProperty(QLatin1String(FROMFRAME),QJSValue(fromFrame));
+
+ if (toFrame != -1)
+ args.setProperty(QLatin1String(TOFRAME),QJSValue(toFrame));
+
+ if (bottom)
+ args.setProperty(QLatin1String(BOTTOM),QJSValue(bottom));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::frame(int number)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "frame",
+ // "arguments" : { "number" : <frame number>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(FRAME)));
+
+ if (number != -1) {
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(NUMBER),QJSValue(number));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::scope(int number, int frameNumber)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "scope",
+ // "arguments" : { "number" : <scope number>
+ // "frameNumber" : <frame number, optional uses selected frame if missing>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPE)));
+
+ if (number != -1) {
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(NUMBER),QJSValue(number));
+
+ if (frameNumber != -1)
+ args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::scopes(int frameNumber)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "scopes",
+ // "arguments" : { "frameNumber" : <frame number, optional uses selected frame if missing>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPES)));
+
+ if (frameNumber != -1) {
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVariant /*filter*/)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "scripts",
+ // "arguments" : { "types" : <types of scripts to retrieve
+ // set bit 0 for native scripts
+ // set bit 1 for extension scripts
+ // set bit 2 for normal scripts
+ // (default is 4 for normal scripts)>
+ // "ids" : <array of id's of scripts to return. If this is not specified all scripts are requrned>
+ // "includeSource" : <boolean indicating whether the source code should be included for the scripts returned>
+ // "filter" : <string or number: filter string or script id.
+ // If a number is specified, then only the script with the same number as its script id will be retrieved.
+ // If a string is specified, then only scripts whose names contain the filter string will be retrieved.>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCRIPTS)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(TYPES),QJSValue(types));
+
+ if (ids.count()) {
+ QString arr("[]");
+ QJSValue array = parser.call(QJSValueList() << arr);
+ int index = 0;
+ foreach (int id, ids) {
+ array.setProperty(index++,QJSValue(id));
+ }
+ args.setProperty(QLatin1String(IDS),array);
+ }
+
+ if (includeSource)
+ args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::source(int frame, int fromLine, int toLine)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "source",
+ // "arguments" : { "frame" : <frame number (default selected frame)>
+ // "fromLine" : <from line within the source default is line 0>
+ // "toLine" : <to line within the source this line is not included in
+ // the result default is the number of lines in the script>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SOURCE)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ if (frame != -1)
+ args.setProperty(QLatin1String(FRAME),QJSValue(frame));
+
+ if (fromLine != -1)
+ args.setProperty(QLatin1String(FROMLINE),QJSValue(fromLine));
+
+ if (toLine != -1)
+ args.setProperty(QLatin1String(TOLINE),QJSValue(toLine));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int column, bool enabled, QString condition, int ignoreCount)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "setbreakpoint",
+ // "arguments" : { "type" : <"function" or "script" or "scriptId" or "scriptRegExp">
+ // "target" : <function expression or script identification>
+ // "line" : <line in script or function>
+ // "column" : <character position within the line>
+ // "enabled" : <initial enabled state. True or false, default is true>
+ // "condition" : <string with break point condition>
+ // "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0>
+ // }
+ // }
+
+ if (type == QLatin1String(EVENT)) {
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << target.toUtf8() << enabled;
+ sendMessage(packMessage(QByteArray("breakonsignal"), reply));
+
+ } else {
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETBREAKPOINT)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(TYPE),QJSValue(type));
+ args.setProperty(QLatin1String(TARGET),QJSValue(target));
+
+ if (line != -1)
+ args.setProperty(QLatin1String(LINE),QJSValue(line));
+
+ if (column != -1)
+ args.setProperty(QLatin1String(COLUMN),QJSValue(column));
+
+ args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
+
+ if (!condition.isEmpty())
+ args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
+
+ if (ignoreCount != -1)
+ args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+ }
+}
+
+void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled, QString condition, int ignoreCount)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "changebreakpoint",
+ // "arguments" : { "breakpoint" : <number of the break point to clear>
+ // "enabled" : <initial enabled state. True or false, default is true>
+ // "condition" : <string with break point condition>
+ // "ignoreCount" : <number specifying the number of break point hits }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CHANGEBREAKPOINT)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
+
+ args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
+
+ if (!condition.isEmpty())
+ args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
+
+ if (ignoreCount != -1)
+ args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::clearBreakpoint(int breakpoint)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "clearbreakpoint",
+ // "arguments" : { "breakpoint" : <number of the break point to clear>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CLEARBREAKPOINT)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::setExceptionBreak(Exception type, bool enabled)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "setexceptionbreak",
+ // "arguments" : { "type" : <string: "all", or "uncaught">,
+ // "enabled" : <optional bool: enables the break type if true>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETEXCEPTIONBREAK)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ if (type == All)
+ args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
+ else if (type == Uncaught)
+ args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(UNCAUGHT)));
+
+ if (enabled)
+ args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::v8flags(QString flags)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "v8flags",
+ // "arguments" : { "flags" : <string: a sequence of v8 flags just like those used on the command line>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(V8FLAGS)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(FLAGS),QJSValue(flags));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::version()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "version",
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(VERSION)));
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+//void QJSDebugClient::profile(ProfileCommand command)
+//{
+//// { "seq" : <number>,
+//// "type" : "request",
+//// "command" : "profile",
+//// "arguments" : { "command" : "resume" or "pause" }
+//// }
+// VARIANTMAPINIT;
+// jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PROFILE)));
+
+// QJSValue args = parser.call(QJSValueList() << obj);
+
+// if (command == Resume)
+// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(RESUME)));
+// else
+// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PAUSE)));
+
+// args.setProperty(QLatin1String("modules"),QJSValue(1));
+// if (!args.isUndefined()) {
+// jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+// }
+
+// QJSValue json = stringify.call(QJSValueList() << jsonVal);
+// sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+//}
+
+void QJSDebugClient::disconnect()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "disconnect",
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(DISCONNECT)));
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(DISCONNECT, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::gc()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "gc",
+ // "arguments" : { "type" : <string: "all">,
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(GARBAGECOLLECTOR)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::listBreakpoints()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "listbreakpoints",
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LISTBREAKPOINTS)));
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::stateChanged(State state)
+{
+ if (state == Enabled) {
+ flushSendBuffer();
+ emit enabled();
+ }
+}
+
+void QJSDebugClient::messageReceived(const QByteArray &data)
+{
+ QDataStream ds(data);
+ QByteArray command;
+ ds >> command;
+
+ if (command == "V8DEBUG") {
+ QByteArray type;
+ ds >> type >> response;
+
+ if (type == CONNECT) {
+ emit connected();
+
+ } else if (type == INTERRUPT) {
+ emit interruptRequested();
+
+ } else if (type == V8MESSAGE) {
+ QString jsonString(response);
+ QVariantMap value = parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+ QString type = value.value("type").toString();
+
+ if (type == "response") {
+
+ if (!value.value("success").toBool()) {
+// qDebug() << "Error: The test case will fail since no signal is emitted";
+ return;
+ }
+
+ QString debugCommand(value.value("command").toString());
+ if (debugCommand == "backtrace" ||
+ debugCommand == "lookup" ||
+ debugCommand == "setbreakpoint" ||
+ debugCommand == "evaluate" ||
+ debugCommand == "listbreakpoints" ||
+ debugCommand == "version" ||
+ debugCommand == "v8flags" ||
+ debugCommand == "disconnect" ||
+ debugCommand == "gc" ||
+ debugCommand == "changebreakpoint" ||
+ debugCommand == "clearbreakpoint" ||
+ debugCommand == "frame" ||
+ debugCommand == "scope" ||
+ debugCommand == "scopes" ||
+ debugCommand == "scripts" ||
+ debugCommand == "source" ||
+ debugCommand == "setexceptionbreak" /*||
+ debugCommand == "profile"*/) {
+ emit result();
+
+ } else {
+ // DO NOTHING
+ }
+
+ } else if (type == QLatin1String(EVENT)) {
+ QString event(value.value(QLatin1String(EVENT)).toString());
+
+ if (event == "break" ||
+ event == "exception")
+ emit stopped();
+ }
+
+ } else if (type == BREAKAFTERCOMPILE) {
+ emit breakAfterCompileRequested();
+
+ }
+ }
+}
+
+void QJSDebugClient::sendMessage(const QByteArray &msg)
+{
+ if (state() == Enabled) {
+ QQmlDebugClient::sendMessage(msg);
+ } else {
+ sendBuffer.append(msg);
+ }
+}
+
+void QJSDebugClient::flushSendBuffer()
+{
+ foreach (const QByteArray &msg, sendBuffer)
+ QQmlDebugClient::sendMessage(msg);
+ sendBuffer.clear();
+}
+
+QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray &message)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "V8DEBUG";
+ rs << cmd << type << message;
+ return reply;
+}
+
+void tst_QQmlDebugJS::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ t.start();
+ process = 0;
+ client = 0;
+ connection = 0;
+}
+
+void tst_QQmlDebugJS::cleanupTestCase()
+{
+ if (process) {
+ process->stop();
+ delete process;
+ }
+
+ if (client)
+ delete client;
+
+ if (connection)
+ delete connection;
+
+// qDebug() << "Time Elapsed:" << t.elapsed();
+}
+
+bool tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode)
+{
+ connection = new QQmlDebugConnection();
+ process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
+ client = new QJSDebugClient(connection);
+
+ QStringList systemEnvironment = QProcess::systemEnvironment();
+ systemEnvironment << "QML_DISABLE_OPTIMIZER=1";
+ process->setEnvironment(systemEnvironment);
+ if (blockMode)
+ process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile));
+ else
+ process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile));
+
+ if (!process->waitForSessionStart()) {
+ return false;
+ }
+
+ connection->connectToHost("127.0.0.1", 3771);
+ if (!connection->waitForConnected())
+ return false;
+
+ return QQmlDebugTest::waitForSignal(client, SIGNAL(enabled()));
+}
+
+void tst_QQmlDebugJS::cleanup()
+{
+ if (process) {
+ process->stop();
+ delete process;
+ }
+
+ if (client)
+ delete client;
+
+ if (connection)
+ delete connection;
+
+ process = 0;
+ client = 0;
+ connection = 0;
+}
+
+void tst_QQmlDebugJS::connect()
+{
+ //void connect()
+
+ QVERIFY(init());
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected())));
+}
+
+void tst_QQmlDebugJS::interrupt()
+{
+ //void connect()
+
+ QVERIFY(init());
+ client->connect();
+
+ client->interrupt();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(interruptRequested())));
+}
+
+void tst_QQmlDebugJS::breakAfterCompile()
+{
+ //void breakAfterCompile(bool enabled)
+
+ QVERIFY(init());
+ client->breakAfterCompile(true);
+ client->connect();
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(breakAfterCompileRequested())));
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+}
+
+void tst_QQmlDebugJS::getVersion()
+{
+ //void version()
+
+ QVERIFY(init());
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected())));
+
+ client->version();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::getVersionWhenAttaching()
+{
+ //void version()
+
+ QVERIFY(init(QLatin1String(TIMER_QMLFILE), false));
+ client->connect();
+
+ client->version();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::applyV8Flags()
+{
+ //void v8flags(QString flags)
+
+ QVERIFY(init());
+ client->connect();
+
+ client->v8flags(QString());
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::disconnect()
+{
+ //void disconnect()
+
+ QVERIFY(init());
+ client->connect();
+
+ client->disconnect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::gc()
+{
+ //void gc()
+
+ QVERIFY(init());
+ client->connect();
+
+ client->gc();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::listBreakpoints()
+{
+ //void listBreakpoints()
+
+ int sourceLine1 = 47;
+ int sourceLine2 = 48;
+ int sourceLine3 = 49;
+
+ QVERIFY(init());
+ client->connect();
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine3, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+ client->listBreakpoints();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QList<QVariant> breakpoints = value.value("body").toMap().value("breakpoints").toList();
+
+ QCOMPARE(breakpoints.count(), 3);
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 47;
+ QVERIFY(init(CREATECOMPONENT_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
+{
+ int sourceLine = 48;
+ QVERIFY(init(TIMER_QMLFILE));
+
+ client->connect();
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 43;
+ QVERIFY(init(LOADJSFILE_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_JSFILE), sourceLine, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 47;
+ int actualLine = 49;
+ QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
+ QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 48;
+ int actualLine = 49;
+ QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
+ QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int out = 10;
+ int sourceLine = 50;
+ QVERIFY(init(CONDITION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10"));
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Get the frame index
+ QString jsonString = client->response;
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ int frameIndex = body.value("index").toInt();
+
+ //Verify the value of 'result'
+ client->evaluate(QLatin1String("a"),frameIndex);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QVERIFY(body.value("value").toInt() > out);
+}
+
+void tst_QQmlDebugJS::setBreakpointWhenAttaching()
+{
+ int sourceLine = 49;
+ QVERIFY(init(QLatin1String(TIMER_QMLFILE), false));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+}
+
+//void tst_QQmlDebugJS::setBreakpointInFunction()
+//{
+// //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+// int actualLine = 31;
+
+// client->connect();
+// client->setBreakpoint(QLatin1String(FUNCTION), QLatin1String("doSomethingElse"), -1, -1, true);
+
+// QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+// QString jsonString(client->response);
+// QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+// QVariantMap body = value.value("body").toMap();
+
+// QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+// QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QMLFILE));
+//}
+
+void tst_QQmlDebugJS::setBreakpointOnEvent()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ QVERIFY(init(TIMER_QMLFILE));
+
+ client->connect();
+
+ client->setBreakpoint(QLatin1String(EVENT), QLatin1String("triggered"), -1, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
+}
+
+
+void tst_QQmlDebugJS::changeBreakpoint()
+{
+ //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine1 = 50;
+ int sourceLine2 = 51;
+ QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Will hit 1st brakpoint, change this breakpoint enable = false
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+ QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+
+ int breakpoint = breakpointsHit.at(0).toInt();
+ client->changeBreakpoint(breakpoint,false);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Hit 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Should stop at 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+}
+
+void tst_QQmlDebugJS::changeBreakpointOnCondition()
+{
+ //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine1 = 50;
+ int sourceLine2 = 51;
+
+ QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Will hit 1st brakpoint, change this breakpoint enable = false
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+ QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+
+ int breakpoint = breakpointsHit.at(0).toInt();
+ client->changeBreakpoint(breakpoint, false, QLatin1String("d == 0"));
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Hit 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Should stop at 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+
+}
+
+void tst_QQmlDebugJS::clearBreakpoint()
+{
+ //void clearBreakpoint(int breakpoint);
+
+ int sourceLine1 = 50;
+ int sourceLine2 = 51;
+ QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Will hit 1st brakpoint, change this breakpoint enable = false
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+ QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+
+ int breakpoint = breakpointsHit.at(0).toInt();
+ client->clearBreakpoint(breakpoint);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Hit 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Should stop at 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+}
+
+void tst_QQmlDebugJS::setExceptionBreak()
+{
+ //void setExceptionBreak(QString type, bool enabled = false);
+
+ QVERIFY(init(EXCEPTION_QMLFILE));
+ client->setExceptionBreak(QJSDebugClient::All,true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+}
+
+void tst_QQmlDebugJS::stepNext()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine = 50;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::Next);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 1);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::stepNextWithCount()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine = 50;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::Next, 2);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 2);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::stepIn()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine = 54;
+ int actualLine = 50;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::In);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::stepOut()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine = 50;
+ int actualLine = 54;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::Out);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::continueDebugging()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine1 = 54;
+ int sourceLine2 = 51;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true);
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::Continue);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::backtrace()
+{
+ //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->backtrace();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::getFrameDetails()
+{
+ //void frame(int number = -1);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->frame();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::getScopeDetails()
+{
+ //void scope(int number = -1, int frameNumber = -1);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->scope();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::evaluateInGlobalScope()
+{
+ //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
+
+ QVERIFY(init());
+
+ client->connect();
+ client->evaluate(QLatin1String("print('Hello World')"), true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Verify the value of 'print'
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("text").toString(),QLatin1String("undefined"));
+}
+
+void tst_QQmlDebugJS::evaluateInLocalScope()
+{
+ //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->frame();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Get the frame index
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ int frameIndex = body.value("index").toInt();
+
+ client->evaluate(QLatin1String("root.a"), frameIndex);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Verify the value of 'timer.interval'
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QCOMPARE(body.value("value").toInt(),10);
+}
+
+void tst_QQmlDebugJS::getScopes()
+{
+ //void scopes(int frameNumber = -1);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->scopes();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::getScripts()
+{
+ //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
+
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-23475 - Unreliable test on Mac OS X");
+#endif
+
+ QVERIFY(init());
+
+ client->connect();
+
+ client->scripts();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList()
+ << QJSValue(jsonString)).toVariant().toMap();
+
+ QList<QVariant> scripts = value.value("body").toList();
+
+ QCOMPARE(scripts.count(), 2);
+}
+
+void tst_QQmlDebugJS::getSource()
+{
+ //void source(int frame = -1, int fromLine = -1, int toLine = -1);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->source();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+QTEST_MAIN(tst_QQmlDebugJS)
+
+#include "tst_qqmldebugjs.moc"
+
diff --git a/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro
new file mode 100644
index 0000000000..ecb3b2ca2c
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_qqmldebugservice
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmldebugservice.cpp \
+ ../shared/debugutil.cpp
+
+CONFIG += parallel_test declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
new file mode 100644
index 0000000000..5af38c2af0
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtQml/qqmlengine.h>
+
+#include <private/qqmldebugclient_p.h>
+#include <private/qqmldebugservice_p.h>
+
+#include "../../../shared/util.h"
+#include "../shared/debugutil_p.h"
+
+#define PORT 13769
+#define STR_PORT "13769"
+
+class tst_QQmlDebugService : public QObject
+{
+ Q_OBJECT
+private:
+ QQmlDebugConnection *m_conn;
+
+private slots:
+ void initTestCase();
+
+ void name();
+ void version();
+ void state();
+ void sendMessage();
+ void idForObject();
+ void objectForId();
+ void objectToString();
+};
+
+void tst_QQmlDebugService::initTestCase()
+{
+ const QString waitingMsg = QString("QQmlDebugServer: Waiting for connection on port %1...").arg(PORT);
+ QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
+ new QQmlEngine(this);
+
+ m_conn = new QQmlDebugConnection(this);
+
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established");
+ for (int i = 0; i < 50; ++i) {
+ // try for 5 seconds ...
+ m_conn->connectToHost("127.0.0.1", PORT);
+ if (m_conn->waitForConnected())
+ break;
+ QTest::qSleep(100);
+ }
+ QVERIFY(m_conn->isConnected());
+
+ QTRY_VERIFY(QQmlDebugService::hasDebuggingClient());
+}
+
+void tst_QQmlDebugService::name()
+{
+ QString name = "tst_QQmlDebugService::name()";
+
+ QQmlDebugService service(name, 1);
+ QCOMPARE(service.name(), name);
+}
+
+void tst_QQmlDebugService::version()
+{
+ QString name = "tst_QQmlDebugService::name()";
+
+ QQmlDebugService service(name, 2);
+ QCOMPARE(service.version(), 2.0f);
+}
+
+void tst_QQmlDebugService::state()
+{
+ QQmlDebugTestService service("tst_QQmlDebugService::state()");
+ QCOMPARE(service.state(), QQmlDebugService::Unavailable);
+
+ {
+ QQmlDebugTestClient client("tst_QQmlDebugService::state()", m_conn);
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+ QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+ }
+
+
+ QTRY_COMPARE(service.state(), QQmlDebugService::Unavailable);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\" ");
+ QQmlDebugTestService duplicate("tst_QQmlDebugService::state()");
+ QCOMPARE(duplicate.state(), QQmlDebugService::NotConnected);
+}
+
+void tst_QQmlDebugService::sendMessage()
+{
+ QQmlDebugTestService service("tst_QQmlDebugService::sendMessage()");
+ QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+ QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\" ");
+ QQmlDebugTestService duplicate("tst_QQmlDebugService::sendMessage()");
+ duplicate.sendMessage("msg");
+}
+
+void tst_QQmlDebugService::idForObject()
+{
+ QCOMPARE(QQmlDebugService::idForObject(0), -1);
+
+ QObject *objA = new QObject;
+
+ int idA = QQmlDebugService::idForObject(objA);
+ QVERIFY(idA >= 0);
+ QCOMPARE(QQmlDebugService::objectForId(idA), objA);
+
+ int idAA = QQmlDebugService::idForObject(objA);
+ QCOMPARE(idAA, idA);
+
+ QObject *objB = new QObject;
+ int idB = QQmlDebugService::idForObject(objB);
+ QVERIFY(idB != idA);
+ QCOMPARE(QQmlDebugService::objectForId(idB), objB);
+
+ delete objA;
+ delete objB;
+}
+
+void tst_QQmlDebugService::objectForId()
+{
+ QCOMPARE(QQmlDebugService::objectForId(-1), static_cast<QObject*>(0));
+ QCOMPARE(QQmlDebugService::objectForId(1), static_cast<QObject*>(0));
+
+ QObject *obj = new QObject;
+ int id = QQmlDebugService::idForObject(obj);
+ QCOMPARE(QQmlDebugService::objectForId(id), obj);
+
+ delete obj;
+ QCOMPARE(QQmlDebugService::objectForId(id), static_cast<QObject*>(0));
+}
+
+void tst_QQmlDebugService::objectToString()
+{
+ QCOMPARE(QQmlDebugService::objectToString(0), QString("NULL"));
+
+ QObject *obj = new QObject;
+ QCOMPARE(QQmlDebugService::objectToString(obj), QString("QObject: <unnamed>"));
+
+ obj->setObjectName("Hello");
+ QCOMPARE(QQmlDebugService::objectToString(obj), QString("QObject: Hello"));
+ delete obj;
+}
+
+
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ char arg[] = "-qmljsdebugger=port:" STR_PORT;
+ _argv[_argc - 1] = arg;
+
+ QGuiApplication app(_argc, _argv);
+ tst_QQmlDebugService tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
+
+#include "tst_qqmldebugservice.moc"
diff --git a/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro b/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro
new file mode 100644
index 0000000000..529c4667cf
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_qqmlenginedebug
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmlenginedebug.cpp \
+ ../shared/debugutil.cpp
+
+CONFIG += parallel_test declarative_debug
+
+QT += core-private qml-private quick-private v8-private testlib
diff --git a/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp b/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp
new file mode 100644
index 0000000000..21ed2f40ff
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp
@@ -0,0 +1,1235 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlproperty.h>
+#include <QtQuick/qquickitem.h>
+
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlboundsignal_p.h>
+#include <private/qqmlenginedebug_p.h>
+#include <private/qqmldebugservice_p.h>
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmlproperty_p.h>
+
+#include "../shared/debugutil_p.h"
+
+Q_DECLARE_METATYPE(QQmlDebugWatch::State)
+
+class tst_QQmlEngineDebug : public QObject
+{
+ Q_OBJECT
+
+private:
+ QQmlDebugObjectReference findRootObject(int context = 0, bool recursive = false);
+ QQmlDebugPropertyReference findProperty(const QList<QQmlDebugPropertyReference> &props, const QString &name) const;
+ void waitForQuery(QQmlDebugQuery *query);
+
+ void recursiveObjectTest(QObject *o, const QQmlDebugObjectReference &oref, bool recursive) const;
+
+ void recursiveCompareObjects(const QQmlDebugObjectReference &a, const QQmlDebugObjectReference &b) const;
+ void recursiveCompareContexts(const QQmlDebugContextReference &a, const QQmlDebugContextReference &b) const;
+ void compareProperties(const QQmlDebugPropertyReference &a, const QQmlDebugPropertyReference &b) const;
+
+ QQmlDebugConnection *m_conn;
+ QQmlEngineDebug *m_dbg;
+ QQmlEngine *m_engine;
+ QQuickItem *m_rootItem;
+
+ QObjectList m_components;
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void watch_property();
+ void watch_object();
+ void watch_expression();
+ void watch_expression_data();
+ void watch_context();
+ void watch_file();
+
+ void queryAvailableEngines();
+ void queryRootContexts();
+ void queryObject();
+ void queryObject_data();
+ void queryExpressionResult();
+ void queryExpressionResult_data();
+
+ void tst_QQmlDebugFileReference();
+ void tst_QQmlDebugEngineReference();
+ void tst_QQmlDebugObjectReference();
+ void tst_QQmlDebugContextReference();
+ void tst_QQmlDebugPropertyReference();
+
+ void setBindingForObject();
+ void setMethodBody();
+ void queryObjectTree();
+ void setBindingInStates();
+};
+
+class NonScriptProperty : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false)
+public:
+ int nonScriptProp() const { return 0; }
+ void setNonScriptProp(int) {}
+signals:
+ void nonScriptPropChanged();
+};
+QML_DECLARE_TYPE(NonScriptProperty)
+
+
+QQmlDebugObjectReference tst_QQmlEngineDebug::findRootObject(int context, bool recursive)
+{
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ if (q_engines->engines().count() == 0)
+ return QQmlDebugObjectReference();
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ if (q_context->rootContext().objects().count() == 0)
+ return QQmlDebugObjectReference();
+ QQmlDebugObjectQuery *q_obj = recursive ?
+ m_dbg->queryObjectRecursive(q_context->rootContext().objects()[context], this) :
+ m_dbg->queryObject(q_context->rootContext().objects()[context], this);
+ waitForQuery(q_obj);
+
+ QQmlDebugObjectReference result = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ return result;
+}
+
+QQmlDebugPropertyReference tst_QQmlEngineDebug::findProperty(const QList<QQmlDebugPropertyReference> &props, const QString &name) const
+{
+ foreach(const QQmlDebugPropertyReference &p, props) {
+ if (p.name() == name)
+ return p;
+ }
+ return QQmlDebugPropertyReference();
+}
+
+void tst_QQmlEngineDebug::waitForQuery(QQmlDebugQuery *query)
+{
+ QVERIFY(query);
+ QCOMPARE(query->parent(), qobject_cast<QObject*>(this));
+ QVERIFY(query->state() == QQmlDebugQuery::Waiting);
+ if (!QQmlDebugTest::waitForSignal(query, SIGNAL(stateChanged(QQmlDebugQuery::State))))
+ QFAIL("query timed out");
+}
+
+void tst_QQmlEngineDebug::recursiveObjectTest(QObject *o, const QQmlDebugObjectReference &oref, bool recursive) const
+{
+ const QMetaObject *meta = o->metaObject();
+
+ QQmlType *type = QQmlMetaType::qmlType(meta);
+ QString className = type ? QString(type->qmlTypeName()) : QString(meta->className());
+ className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
+
+ QCOMPARE(oref.debugId(), QQmlDebugService::idForObject(o));
+ QCOMPARE(oref.name(), o->objectName());
+ QCOMPARE(oref.className(), className);
+ QCOMPARE(oref.contextDebugId(), QQmlDebugService::idForObject(qmlContext(o)));
+
+ const QObjectList &children = o->children();
+ for (int i=0; i<children.count(); i++) {
+ QObject *child = children[i];
+ if (!qmlContext(child))
+ continue;
+ int debugId = QQmlDebugService::idForObject(child);
+ QVERIFY(debugId >= 0);
+
+ QQmlDebugObjectReference cref;
+ foreach (const QQmlDebugObjectReference &ref, oref.children()) {
+ if (ref.debugId() == debugId) {
+ cref = ref;
+ break;
+ }
+ }
+ QVERIFY(cref.debugId() >= 0);
+
+ if (recursive)
+ recursiveObjectTest(child, cref, true);
+ }
+
+ foreach (const QQmlDebugPropertyReference &p, oref.properties()) {
+ QCOMPARE(p.objectDebugId(), QQmlDebugService::idForObject(o));
+
+ // signal properties are fake - they are generated from QQmlBoundSignal children
+ if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) {
+ QList<QQmlBoundSignal*> signalHandlers = o->findChildren<QQmlBoundSignal*>();
+ QString signal = p.value().toString();
+ bool found = false;
+ for (int i = 0; i < signalHandlers.count(); ++i)
+ if (signalHandlers.at(i)->expression()->expression() == signal) {
+ found = true;
+ break;
+ }
+ QVERIFY(found);
+ QVERIFY(p.valueTypeName().isEmpty());
+ QVERIFY(p.binding().isEmpty());
+ QVERIFY(!p.hasNotifySignal());
+ continue;
+ }
+
+ QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name().toUtf8().constData()));
+
+ QCOMPARE(p.name(), QString::fromUtf8(pmeta.name()));
+
+ if (pmeta.type() < QVariant::UserType && pmeta.userType() != QMetaType::QVariant) // TODO test complex types
+ QCOMPARE(p.value(), pmeta.read(o));
+
+ if (p.name() == "parent")
+ QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QQuickItem*");
+ else
+ QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName()));
+
+ QQmlAbstractBinding *binding =
+ QQmlPropertyPrivate::binding(QQmlProperty(o, p.name()));
+ if (binding)
+ QCOMPARE(binding->expression(), p.binding());
+
+ QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal());
+
+ QVERIFY(pmeta.isValid());
+ }
+}
+
+void tst_QQmlEngineDebug::recursiveCompareObjects(const QQmlDebugObjectReference &a, const QQmlDebugObjectReference &b) const
+{
+ QCOMPARE(a.debugId(), b.debugId());
+ QCOMPARE(a.className(), b.className());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.contextDebugId(), b.contextDebugId());
+
+ QCOMPARE(a.source().url(), b.source().url());
+ QCOMPARE(a.source().lineNumber(), b.source().lineNumber());
+ QCOMPARE(a.source().columnNumber(), b.source().columnNumber());
+
+ QCOMPARE(a.properties().count(), b.properties().count());
+ QCOMPARE(a.children().count(), b.children().count());
+
+ QList<QQmlDebugPropertyReference> aprops = a.properties();
+ QList<QQmlDebugPropertyReference> bprops = b.properties();
+
+ for (int i=0; i<aprops.count(); i++)
+ compareProperties(aprops[i], bprops[i]);
+
+ for (int i=0; i<a.children().count(); i++)
+ recursiveCompareObjects(a.children()[i], b.children()[i]);
+}
+
+void tst_QQmlEngineDebug::recursiveCompareContexts(const QQmlDebugContextReference &a, const QQmlDebugContextReference &b) const
+{
+ QCOMPARE(a.debugId(), b.debugId());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.objects().count(), b.objects().count());
+ QCOMPARE(a.contexts().count(), b.contexts().count());
+
+ for (int i=0; i<a.objects().count(); i++)
+ recursiveCompareObjects(a.objects()[i], b.objects()[i]);
+
+ for (int i=0; i<a.contexts().count(); i++)
+ recursiveCompareContexts(a.contexts()[i], b.contexts()[i]);
+}
+
+void tst_QQmlEngineDebug::compareProperties(const QQmlDebugPropertyReference &a, const QQmlDebugPropertyReference &b) const
+{
+ QCOMPARE(a.objectDebugId(), b.objectDebugId());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.value(), b.value());
+ QCOMPARE(a.valueTypeName(), b.valueTypeName());
+ QCOMPARE(a.binding(), b.binding());
+ QCOMPARE(a.hasNotifySignal(), b.hasNotifySignal());
+}
+
+void tst_QQmlEngineDebug::initTestCase()
+{
+ qRegisterMetaType<QQmlDebugWatch::State>();
+ qmlRegisterType<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement");
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Waiting for connection on port 3768...");
+ m_engine = new QQmlEngine(this);
+
+ QList<QByteArray> qml;
+ qml << "import QtQuick 2.0\n"
+ "import Test 1.0\n"
+ "Item {"
+ "id: root\n"
+ "width: 10; height: 20; scale: blueRect.scale;"
+ "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
+ "Text { color: blueRect.color; }"
+ "MouseArea {"
+ "onEntered: { console.log('hello') }"
+ "}"
+ "property variant varObj\n"
+ "property variant varObjList: []\n"
+ "property variant varObjMap\n"
+ "Component.onCompleted: {\n"
+ "varObj = blueRect;\n"
+ "var list = varObjList;\n"
+ "list[0] = blueRect;\n"
+ "varObjList = list;\n"
+ "var map = new Object;\n"
+ "map.rect = blueRect;\n"
+ "varObjMap = map;\n"
+ "}\n"
+ "NonScriptPropertyElement {\n"
+ "}\n"
+ "}";
+
+ // add second component to test multiple root contexts
+ qml << "import QtQuick 2.0\n"
+ "Item {}";
+
+ // and a third to test methods
+ qml << "import QtQuick 2.0\n"
+ "Item {"
+ "function myMethodNoArgs() { return 3; }\n"
+ "function myMethod(a) { return a + 9; }\n"
+ "function myMethodIndirect() { myMethod(3); }\n"
+ "}";
+
+ // and a fourth to test states
+ qml << "import QtQuick 2.0\n"
+ "Rectangle {\n"
+ "id:rootRect\n"
+ "width:100\n"
+ "states: [\n"
+ "State {\n"
+ "name:\"state1\"\n"
+ "PropertyChanges {\n"
+ "target:rootRect\n"
+ "width:200\n"
+ "}\n"
+ "}\n"
+ "]\n"
+ "transitions: [\n"
+ "Transition {\n"
+ "from:\"*\"\n"
+ "to:\"state1\"\n"
+ "PropertyAnimation {\n"
+ "target:rootRect\n"
+ "property:\"width\"\n"
+ "duration:100\n"
+ "}\n"
+ "}\n"
+ "]\n"
+ "}\n"
+ ;
+
+ for (int i=0; i<qml.count(); i++) {
+ QQmlComponent component(m_engine);
+ component.setData(qml[i], QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady()); // fails if bad syntax
+ m_components << qobject_cast<QQuickItem*>(component.create());
+ }
+ m_rootItem = qobject_cast<QQuickItem*>(m_components.first());
+
+ // add an extra context to test for multiple contexts
+ QQmlContext *context = new QQmlContext(m_engine->rootContext(), this);
+ context->setObjectName("tst_QQmlDebug_childContext");
+
+ m_conn = new QQmlDebugConnection(this);
+ m_conn->connectToHost("127.0.0.1", 3768);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established");
+ bool ok = m_conn->waitForConnected();
+ QVERIFY(ok);
+ QTRY_VERIFY(QQmlDebugService::hasDebuggingClient());
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+ QTRY_VERIFY(m_dbg->state() == QQmlEngineDebug::Enabled);
+}
+
+void tst_QQmlEngineDebug::cleanupTestCase()
+{
+ delete m_dbg;
+ delete m_conn;
+ qDeleteAll(m_components);
+ delete m_engine;
+}
+
+void tst_QQmlEngineDebug::setMethodBody()
+{
+ QQmlDebugObjectReference obj = findRootObject(2);
+
+ QObject *root = m_components.at(2);
+ // Without args
+ {
+ QVariant rv;
+ QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, rv)));
+ QVERIFY(rv == QVariant(qreal(3)));
+
+
+ QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethodNoArgs", "return 7"));
+ QTest::qWait(100);
+
+ QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, rv)));
+ QVERIFY(rv == QVariant(qreal(7)));
+ }
+
+ // With args
+ {
+ QVariant rv;
+ QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
+ QVERIFY(rv == QVariant(qreal(28)));
+
+ QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethod", "return a + 7"));
+ QTest::qWait(100);
+
+ QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
+ QVERIFY(rv == QVariant(qreal(26)));
+ }
+}
+
+void tst_QQmlEngineDebug::watch_property()
+{
+ QQmlDebugObjectReference obj = findRootObject();
+ QQmlDebugPropertyReference prop = findProperty(obj.properties(), "width");
+
+ QQmlDebugPropertyWatch *watch;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ watch = unconnected->addWatch(prop, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QQmlDebugPropertyReference(), this);
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(prop, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+ QCOMPARE(watch->name(), prop.name());
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+
+ int origWidth = m_rootItem->property("width").toInt();
+ m_rootItem->setProperty("width", origWidth*2);
+
+ // stateChanged() is received before valueChanged()
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Active);
+ QCOMPARE(spy.count(), 1);
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // restore original value and verify spy doesn't get additional signal since watch has been removed
+ m_rootItem->setProperty("width", origWidth);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 1);
+
+ QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name().toUtf8());
+ QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));
+}
+
+void tst_QQmlEngineDebug::watch_object()
+{
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ QVERIFY(q_engines->engines().count() > 0);
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ QVERIFY(q_context->rootContext().objects().count() > 0);
+ QQmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
+ waitForQuery(q_obj);
+
+ QQmlDebugObjectReference obj = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ QQmlDebugWatch *watch;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ watch = unconnected->addWatch(obj, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QQmlDebugObjectReference(), this);
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(obj, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+
+ int origWidth = m_rootItem->property("width").toInt();
+ int origHeight = m_rootItem->property("height").toInt();
+ m_rootItem->setProperty("width", origWidth*2);
+ m_rootItem->setProperty("height", origHeight*2);
+
+ // stateChanged() is received before any valueChanged() signals
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Active);
+ QVERIFY(spy.count() > 0);
+
+ int newWidth = -1;
+ int newHeight = -1;
+ for (int i=0; i<spy.count(); i++) {
+ const QVariantList &values = spy[i];
+ if (values[0].value<QByteArray>() == "width")
+ newWidth = values[1].value<QVariant>().toInt();
+ else if (values[0].value<QByteArray>() == "height")
+ newHeight = values[1].value<QVariant>().toInt();
+
+ }
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // since watch has been removed, restoring the original values should not trigger a valueChanged()
+ spy.clear();
+ m_rootItem->setProperty("width", origWidth);
+ m_rootItem->setProperty("height", origHeight);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 0);
+
+ QCOMPARE(newWidth, origWidth * 2);
+ QCOMPARE(newHeight, origHeight * 2);
+}
+
+void tst_QQmlEngineDebug::watch_expression()
+{
+ QFETCH(QString, expr);
+ QFETCH(int, increment);
+ QFETCH(int, incrementCount);
+
+ int origWidth = m_rootItem->property("width").toInt();
+
+ QQmlDebugObjectReference obj = findRootObject();
+
+ QQmlDebugObjectExpressionWatch *watch;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ watch = unconnected->addWatch(obj, expr, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QQmlDebugObjectReference(), expr, this);
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(obj, expr, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+ QCOMPARE(watch->expression(), expr);
+
+ QSignalSpy spyState(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)));
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+ int expectedSpyCount = incrementCount + 1; // should also get signal with expression's initial value
+
+ int width = origWidth;
+ for (int i=0; i<incrementCount+1; i++) {
+ if (i > 0) {
+ width += increment;
+ m_rootItem->setProperty("width", width);
+ }
+ if (!QQmlDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
+ QFAIL("Did not receive valueChanged() for expression");
+ }
+
+ if (spyState.count() == 0)
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(spyState.count(), 1);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Active);
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // restore original value and verify spy doesn't get a signal since watch has been removed
+ m_rootItem->setProperty("width", origWidth);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), expectedSpyCount);
+
+ width = origWidth + increment;
+ for (int i=0; i<spy.count(); i++) {
+ QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
+ width += increment;
+ }
+}
+
+void tst_QQmlEngineDebug::watch_expression_data()
+{
+ QTest::addColumn<QString>("expr");
+ QTest::addColumn<int>("increment");
+ QTest::addColumn<int>("incrementCount");
+
+ QTest::newRow("width") << "width" << 0 << 0;
+ QTest::newRow("width+10") << "width + 10" << 10 << 5;
+}
+
+void tst_QQmlEngineDebug::watch_context()
+{
+ QQmlDebugContextReference c;
+ QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebug::addWatch(): Not implemented");
+ QVERIFY(!m_dbg->addWatch(c, QString(), this));
+}
+
+void tst_QQmlEngineDebug::watch_file()
+{
+ QQmlDebugFileReference f;
+ QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebug::addWatch(): Not implemented");
+ QVERIFY(!m_dbg->addWatch(f, this));
+}
+
+void tst_QQmlEngineDebug::queryAvailableEngines()
+{
+ QQmlDebugEnginesQuery *q_engines;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ q_engines = unconnected->queryAvailableEngines(0);
+ QCOMPARE(q_engines->state(), QQmlDebugQuery::Error);
+ delete q_engines;
+ delete unconnected;
+
+ q_engines = m_dbg->queryAvailableEngines(this);
+ delete q_engines;
+
+ q_engines = m_dbg->queryAvailableEngines(this);
+ QVERIFY(q_engines->engines().isEmpty());
+ waitForQuery(q_engines);
+
+ // TODO test multiple engines
+ QList<QQmlDebugEngineReference> engines = q_engines->engines();
+ QCOMPARE(engines.count(), 1);
+
+ foreach(const QQmlDebugEngineReference &e, engines) {
+ QCOMPARE(e.debugId(), QQmlDebugService::idForObject(m_engine));
+ QCOMPARE(e.name(), m_engine->objectName());
+ }
+
+ // Make query invalid by deleting client
+ q_engines = m_dbg->queryAvailableEngines(this);
+ QCOMPARE(q_engines->state(), QQmlDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_engines->state(), QQmlDebugQuery::Error);
+ delete q_engines;
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+}
+
+void tst_QQmlEngineDebug::queryRootContexts()
+{
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ int engineId = q_engines->engines()[0].debugId();
+ delete q_engines;
+
+ QQmlDebugRootContextQuery *q_context;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ q_context = unconnected->queryRootContexts(engineId, this);
+ QCOMPARE(q_context->state(), QQmlDebugQuery::Error);
+ delete q_context;
+ delete unconnected;
+
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ delete q_context;
+
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ waitForQuery(q_context);
+
+ QQmlContext *actualContext = m_engine->rootContext();
+ QQmlDebugContextReference context = q_context->rootContext();
+ QCOMPARE(context.debugId(), QQmlDebugService::idForObject(actualContext));
+ QCOMPARE(context.name(), actualContext->objectName());
+
+ QCOMPARE(context.objects().count(), 4); // 4 qml component objects created for context in main()
+
+ // root context query sends only root object data - it doesn't fill in
+ // the children or property info
+ QCOMPARE(context.objects()[0].properties().count(), 0);
+ QCOMPARE(context.objects()[0].children().count(), 0);
+
+ QCOMPARE(context.contexts().count(), 5);
+ QVERIFY(context.contexts()[0].debugId() >= 0);
+ QCOMPARE(context.contexts()[0].name(), QString("tst_QQmlDebug_childContext"));
+
+ // Make query invalid by deleting client
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ QCOMPARE(q_context->state(), QQmlDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_context->state(), QQmlDebugQuery::Error);
+ delete q_context;
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+}
+
+void tst_QQmlEngineDebug::queryObject()
+{
+ QFETCH(bool, recursive);
+
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+ QQmlDebugObjectReference rootObject = q_context->rootContext().objects()[0];
+
+ QQmlDebugObjectQuery *q_obj = 0;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
+ QCOMPARE(q_obj->state(), QQmlDebugQuery::Error);
+ delete q_obj;
+ delete unconnected;
+
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ delete q_obj;
+
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ waitForQuery(q_obj);
+
+ QQmlDebugObjectReference obj = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+
+ // Make query invalid by deleting client
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ QCOMPARE(q_obj->state(), QQmlDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_obj->state(), QQmlDebugQuery::Error);
+ delete q_obj;
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+
+ // check source as defined in main()
+ QQmlDebugFileReference source = obj.source();
+ QCOMPARE(source.url(), QUrl::fromLocalFile(""));
+ QCOMPARE(source.lineNumber(), 3);
+ QCOMPARE(source.columnNumber(), 1);
+
+ // generically test all properties, children and childrens' properties
+ recursiveObjectTest(m_rootItem, obj, recursive);
+
+ if (recursive) {
+ foreach(const QQmlDebugObjectReference &child, obj.children())
+ QVERIFY(child.properties().count() > 0);
+
+ QQmlDebugObjectReference rect;
+ QQmlDebugObjectReference text;
+ foreach (const QQmlDebugObjectReference &child, obj.children()) {
+ if (child.className() == "Rectangle")
+ rect = child;
+ else if (child.className() == "Text")
+ text = child;
+ }
+
+ // test specific property values
+ QCOMPARE(findProperty(rect.properties(), "width").value(), qVariantFromValue(500));
+ QCOMPARE(findProperty(rect.properties(), "height").value(), qVariantFromValue(600));
+ QCOMPARE(findProperty(rect.properties(), "color").value(), qVariantFromValue(QColor("blue")));
+
+ QCOMPARE(findProperty(text.properties(), "color").value(), qVariantFromValue(QColor("blue")));
+ } else {
+ foreach(const QQmlDebugObjectReference &child, obj.children())
+ QCOMPARE(child.properties().count(), 0);
+ }
+}
+
+void tst_QQmlEngineDebug::queryObject_data()
+{
+ QTest::addColumn<bool>("recursive");
+
+ QTest::newRow("non-recursive") << false;
+ QTest::newRow("recursive") << true;
+}
+
+void tst_QQmlEngineDebug::queryExpressionResult()
+{
+ QFETCH(QString, expr);
+ QFETCH(QVariant, result);
+
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines); // check immediate deletion is ok
+
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+ int objectId = q_context->rootContext().objects()[0].debugId();
+
+ QQmlDebugExpressionQuery *q_expr;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ q_expr = unconnected->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->state(), QQmlDebugQuery::Error);
+ delete q_expr;
+ delete unconnected;
+
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ delete q_expr;
+
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->expression().toString(), expr);
+ waitForQuery(q_expr);
+
+ QCOMPARE(q_expr->result(), result);
+
+ delete q_engines;
+ delete q_context;
+
+ // Make query invalid by deleting client
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->state(), QQmlDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_expr->state(), QQmlDebugQuery::Error);
+ delete q_expr;
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+}
+
+void tst_QQmlEngineDebug::queryExpressionResult_data()
+{
+ QTest::addColumn<QString>("expr");
+ QTest::addColumn<QVariant>("result");
+
+ QTest::newRow("width + 50") << "width + 50" << qVariantFromValue(60);
+ QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500);
+ QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("<undefined>"));
+ QTest::newRow("QObject*") << "varObj" << qVariantFromValue(QString("<unnamed object>"));
+ QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QString("<unknown value>"));
+ QVariantMap map;
+ map.insert(QLatin1String("rect"), QVariant(QLatin1String("<unnamed object>")));
+ QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map);
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugFileReference()
+{
+ QQmlDebugFileReference ref;
+ QVERIFY(ref.url().isEmpty());
+ QCOMPARE(ref.lineNumber(), -1);
+ QCOMPARE(ref.columnNumber(), -1);
+
+ ref.setUrl(QUrl("http://test"));
+ QCOMPARE(ref.url(), QUrl("http://test"));
+ ref.setLineNumber(1);
+ QCOMPARE(ref.lineNumber(), 1);
+ ref.setColumnNumber(1);
+ QCOMPARE(ref.columnNumber(), 1);
+
+ QQmlDebugFileReference copy(ref);
+ QQmlDebugFileReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugFileReference &r, (QList<QQmlDebugFileReference>() << copy << copyAssign)) {
+ QCOMPARE(r.url(), ref.url());
+ QCOMPARE(r.lineNumber(), ref.lineNumber());
+ QCOMPARE(r.columnNumber(), ref.columnNumber());
+ }
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugEngineReference()
+{
+ QQmlDebugEngineReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QVERIFY(ref.name().isEmpty());
+
+ ref = QQmlDebugEngineReference(1);
+ QCOMPARE(ref.debugId(), 1);
+ QVERIFY(ref.name().isEmpty());
+
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ ref = q_engines->engines()[0];
+ delete q_engines;
+
+ QQmlDebugEngineReference copy(ref);
+ QQmlDebugEngineReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugEngineReference &r, (QList<QQmlDebugEngineReference>() << copy << copyAssign)) {
+ QCOMPARE(r.debugId(), ref.debugId());
+ QCOMPARE(r.name(), ref.name());
+ }
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugObjectReference()
+{
+ QQmlDebugObjectReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QCOMPARE(ref.className(), QString());
+ QCOMPARE(ref.name(), QString());
+ QCOMPARE(ref.contextDebugId(), -1);
+ QVERIFY(ref.properties().isEmpty());
+ QVERIFY(ref.children().isEmpty());
+
+ QQmlDebugFileReference source = ref.source();
+ QVERIFY(source.url().isEmpty());
+ QVERIFY(source.lineNumber() < 0);
+ QVERIFY(source.columnNumber() < 0);
+
+ ref = QQmlDebugObjectReference(1);
+ QCOMPARE(ref.debugId(), 1);
+
+ QQmlDebugObjectReference rootObject = findRootObject();
+ QQmlDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this);
+ waitForQuery(query);
+ ref = query->object();
+ delete query;
+
+ QVERIFY(ref.debugId() >= 0);
+
+ QQmlDebugObjectReference copy(ref);
+ QQmlDebugObjectReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugObjectReference &r, (QList<QQmlDebugObjectReference>() << copy << copyAssign))
+ recursiveCompareObjects(r, ref);
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugContextReference()
+{
+ QQmlDebugContextReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QVERIFY(ref.name().isEmpty());
+ QVERIFY(ref.objects().isEmpty());
+ QVERIFY(ref.contexts().isEmpty());
+
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ ref = q_context->rootContext();
+ delete q_engines;
+ delete q_context;
+ QVERIFY(ref.debugId() >= 0);
+
+ QQmlDebugContextReference copy(ref);
+ QQmlDebugContextReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugContextReference &r, (QList<QQmlDebugContextReference>() << copy << copyAssign))
+ recursiveCompareContexts(r, ref);
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugPropertyReference()
+{
+ QQmlDebugObjectReference rootObject = findRootObject();
+ QQmlDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
+ waitForQuery(query);
+ QQmlDebugObjectReference obj = query->object();
+ delete query;
+
+ QQmlDebugPropertyReference ref = findProperty(obj.properties(), "scale");
+ QVERIFY(ref.objectDebugId() > 0);
+ QVERIFY(!ref.name().isEmpty());
+ QVERIFY(!ref.value().isNull());
+ QVERIFY(!ref.valueTypeName().isEmpty());
+ QVERIFY(!ref.binding().isEmpty());
+ QVERIFY(ref.hasNotifySignal());
+
+ QQmlDebugPropertyReference copy(ref);
+ QQmlDebugPropertyReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugPropertyReference &r, (QList<QQmlDebugPropertyReference>() << copy << copyAssign))
+ compareProperties(r, ref);
+}
+
+void tst_QQmlEngineDebug::setBindingForObject()
+{
+ QQmlDebugObjectReference rootObject = findRootObject();
+ QVERIFY(rootObject.debugId() != -1);
+ QQmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties(), "width");
+
+ QCOMPARE(widthPropertyRef.value(), QVariant(10));
+ QCOMPARE(widthPropertyRef.binding(), QString());
+
+ //
+ // set literal
+ //
+ m_dbg->setBindingForObject(rootObject.debugId(), "width", "15", true);
+
+ rootObject = findRootObject();
+ widthPropertyRef = findProperty(rootObject.properties(), "width");
+
+ QCOMPARE(widthPropertyRef.value(), QVariant(15));
+ QCOMPARE(widthPropertyRef.binding(), QString());
+
+ //
+ // set expression
+ //
+ m_dbg->setBindingForObject(rootObject.debugId(), "width", "height", false);
+
+ rootObject = findRootObject();
+ widthPropertyRef = findProperty(rootObject.properties(), "width");
+
+ QCOMPARE(widthPropertyRef.value(), QVariant(20));
+ QCOMPARE(widthPropertyRef.binding(), QString("height"));
+
+ //
+ // reset
+ //
+ m_dbg->resetBindingForObject(rootObject.debugId(), "width");
+
+ rootObject = findRootObject();
+ widthPropertyRef = findProperty(rootObject.properties(), "width");
+
+ // QCOMPARE(widthPropertyRef.value(), QVariant(0)); // TODO: Shouldn't this work?
+ QCOMPARE(widthPropertyRef.binding(), QString());
+
+ //
+ // set handler
+ //
+ rootObject = findRootObject();
+ QCOMPARE(rootObject.children().size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement
+ QQmlDebugObjectReference mouseAreaObject = rootObject.children().at(2);
+ QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
+ waitForQuery(q_obj);
+ mouseAreaObject = q_obj->object();
+
+ QCOMPARE(mouseAreaObject.className(), QString("MouseArea"));
+
+ QQmlDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
+
+ QCOMPARE(onEnteredRef.name(), QString("onEntered"));
+ QCOMPARE(onEnteredRef.value(), QVariant("(function onEntered() { { console.log('hello') } })"));
+
+ m_dbg->setBindingForObject(mouseAreaObject.debugId(), "onEntered", "{console.log('hello, world') }", false) ;
+
+ rootObject = findRootObject();
+ mouseAreaObject = rootObject.children().at(2);
+ q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
+ waitForQuery(q_obj);
+ mouseAreaObject = q_obj->object();
+ onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
+ QCOMPARE(onEnteredRef.name(), QString("onEntered"));
+ QCOMPARE(onEnteredRef.value(), QVariant("{console.log('hello, world') }"));
+}
+
+void tst_QQmlEngineDebug::setBindingInStates()
+{
+ // Check if changing bindings of propertychanges works
+
+ const int sourceIndex = 3;
+
+ QQmlDebugObjectReference obj = findRootObject(sourceIndex);
+
+ QVERIFY(obj.debugId() != -1);
+ QVERIFY(obj.children().count() >= 2);
+
+ // We are going to switch state a couple of times, we need to get rid of the transition before
+ QQmlDebugExpressionQuery *q_deleteTransition = m_dbg->queryExpressionResult(obj.debugId(),QString("transitions = []"),this);
+ waitForQuery(q_deleteTransition);
+ delete q_deleteTransition;
+
+
+ // check initial value of the property that is changing
+ QQmlDebugExpressionQuery *q_setState;
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),200);
+
+
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+
+ obj = findRootObject(sourceIndex, true);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
+
+
+ // change the binding
+ QQmlDebugObjectReference state = obj.children()[1];
+ QCOMPARE(state.className(), QString("State"));
+ QVERIFY(state.children().count() > 0);
+
+ QQmlDebugObjectReference propertyChange = state.children()[0];
+ QVERIFY(propertyChange.debugId() != -1);
+
+ QVERIFY( m_dbg->setBindingForObject(propertyChange.debugId(), "width",QVariant(300),true) );
+
+ // check properties changed in state
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
+
+
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
+
+ // check changing properties of base state from within a state
+ QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"width","height*2",false));
+ QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"height","200",true));
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
+
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
+
+ // reset binding while in a state
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
+
+ m_dbg->resetBindingForObject(propertyChange.debugId(), "width");
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
+
+ // re-add binding
+ m_dbg->setBindingForObject(propertyChange.debugId(), "width", "300", true);
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
+}
+
+void tst_QQmlEngineDebug::queryObjectTree()
+{
+ const int sourceIndex = 3;
+
+ // Check if states/transitions are initialized when fetching root item
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ QVERIFY(q_context->rootContext().objects().count() > sourceIndex);
+ QQmlDebugObjectReference rootObject = q_context->rootContext().objects()[sourceIndex];
+
+ QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(rootObject, this);
+ waitForQuery(q_obj);
+
+ QQmlDebugObjectReference obj = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ QVERIFY(obj.debugId() != -1);
+ QVERIFY(obj.children().count() >= 2);
+
+
+
+ // check state
+ QQmlDebugObjectReference state = obj.children()[1];
+ QCOMPARE(state.className(), QString("State"));
+ QVERIFY(state.children().count() > 0);
+
+ QQmlDebugObjectReference propertyChange = state.children()[0];
+ QVERIFY(propertyChange.debugId() != -1);
+
+ QQmlDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties(),"target");
+ QCOMPARE(propertyChangeTarget.objectDebugId(), propertyChange.debugId());
+
+ QQmlDebugObjectReference targetReference = qvariant_cast<QQmlDebugObjectReference>(propertyChangeTarget.value());
+ QVERIFY(targetReference.debugId() != -1);
+
+
+
+ // check transition
+ QQmlDebugObjectReference transition = obj.children()[0];
+ QCOMPARE(transition.className(), QString("Transition"));
+ QCOMPARE(findProperty(transition.properties(),"from").value().toString(), QString("*"));
+ QCOMPARE(findProperty(transition.properties(),"to").value(), findProperty(state.properties(),"name").value());
+ QVERIFY(transition.children().count() > 0);
+
+ QQmlDebugObjectReference animation = transition.children()[0];
+ QVERIFY(animation.debugId() != -1);
+
+ QQmlDebugPropertyReference animationTarget = findProperty(animation.properties(),"target");
+ QCOMPARE(animationTarget.objectDebugId(), animation.debugId());
+
+ targetReference = qvariant_cast<QQmlDebugObjectReference>(animationTarget.value());
+ QVERIFY(targetReference.debugId() != -1);
+
+ QCOMPARE(findProperty(animation.properties(),"property").value().toString(), QString("width"));
+ QCOMPARE(findProperty(animation.properties(),"duration").value().toInt(), 100);
+}
+
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ char arg[] = "-qmljsdebugger=port:3768";
+ _argv[_argc - 1] = arg;
+
+ QGuiApplication app(_argc, _argv);
+ tst_QQmlEngineDebug tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
+
+#include "tst_qqmlenginedebug.moc"
diff --git a/tests/auto/qml/debugger/qqmlinspector/app/app.pro b/tests/auto/qml/debugger/qqmlinspector/app/app.pro
new file mode 100644
index 0000000000..f6ef983735
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/app/app.pro
@@ -0,0 +1,9 @@
+TARGET = app
+QT += qml quick widgets
+
+CONFIG += declarative_debug
+macx:CONFIG -= app_bundle
+
+SOURCES += main.cpp
+
+OTHER_FILES += qtquick1.qml qtquick2.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp b/tests/auto/qml/debugger/qqmlinspector/app/main.cpp
index a7ef09c283..a7ef09c283 100644
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp
+++ b/tests/auto/qml/debugger/qqmlinspector/app/main.cpp
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick2.qml b/tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml
index 9c36e13c5b..9c36e13c5b 100644
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick2.qml
+++ b/tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml
diff --git a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
new file mode 100644
index 0000000000..5544f76581
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+
+SUBDIRS += tst_qqmlinspector.pro app
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
new file mode 100644
index 0000000000..4f74a036d6
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include "../../../../../src/plugins/qmltooling/shared/qqmlinspectorprotocol.h"
+#include "../shared/debugutil_p.h"
+
+using namespace QmlJSDebugger;
+
+#define PORT 13772
+#define STR_PORT "13772"
+
+class QQmlInspectorClient : public QQmlDebugClient
+{
+ Q_OBJECT
+
+public:
+ QQmlInspectorClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("QQmlObserverMode"), connection)
+ , m_showAppOnTop(false)
+ {
+ }
+
+ bool showAppOnTop() const { return m_showAppOnTop; }
+ void setShowAppOnTop(bool showOnTop);
+
+signals:
+ void showAppOnTopChanged();
+
+protected:
+ void messageReceived(const QByteArray &message);
+
+private:
+ bool m_showAppOnTop;
+};
+
+class tst_QQmlInspector : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QQmlInspector()
+ : m_process(0)
+ , m_connection(0)
+ , m_client(0)
+ {
+ }
+
+
+private:
+ QQmlDebugProcess *m_process;
+ QQmlDebugConnection *m_connection;
+ QQmlInspectorClient *m_client;
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void connect();
+ void showAppOnTop();
+};
+
+
+void QQmlInspectorClient::setShowAppOnTop(bool showOnTop)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << InspectorProtocol::ShowAppOnTop << showOnTop;
+
+ sendMessage(message);
+}
+
+void QQmlInspectorClient::messageReceived(const QByteArray &message)
+{
+ QDataStream ds(message);
+ InspectorProtocol::Message type;
+ ds >> type;
+
+ switch (type) {
+ case InspectorProtocol::ShowAppOnTop:
+ ds >> m_showAppOnTop;
+ emit showAppOnTopChanged();
+ break;
+ default:
+ qDebug() << "Unhandled message " << (int)type;
+ }
+}
+
+void tst_QQmlInspector::initTestCase()
+{
+}
+
+void tst_QQmlInspector::cleanupTestCase()
+{
+}
+
+void tst_QQmlInspector::init()
+{
+ const QString executable = SRCDIR"/app/app";
+ const QString argument = "-qmljsdebugger=port:"STR_PORT",block";
+
+ m_process = new QQmlDebugProcess(executable);
+ m_process->start(QStringList() << argument);
+ if (!m_process->waitForSessionStart()) {
+ QFAIL(QString("Could not launch app '%1'.\nApplication output:\n%2").arg(executable, m_process->output()).toAscii());
+ }
+
+ QQmlDebugConnection *m_connection = new QQmlDebugConnection();
+ m_client = new QQmlInspectorClient(m_connection);
+
+ m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
+}
+
+void tst_QQmlInspector::cleanup()
+{
+ delete m_process;
+ delete m_connection;
+ delete m_client;
+}
+
+void tst_QQmlInspector::connect()
+{
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+}
+
+void tst_QQmlInspector::showAppOnTop()
+{
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setShowAppOnTop(true);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged())));
+ QCOMPARE(m_client->showAppOnTop(), true);
+
+ m_client->setShowAppOnTop(false);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged())));
+ QCOMPARE(m_client->showAppOnTop(), false);
+}
+
+QTEST_MAIN(tst_QQmlInspector)
+
+#include "tst_qqmlinspector.moc"
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro
new file mode 100644
index 0000000000..010e97cef7
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro
@@ -0,0 +1,12 @@
+CONFIG += testcase
+TARGET = tst_qqmlinspector
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmlinspector.cpp \
+ ../shared/debugutil.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+CONFIG += parallel_test declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml
index b250524caa..b250524caa 100644
--- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml
index 9c36e13c5b..9c36e13c5b 100644
--- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
new file mode 100644
index 0000000000..81fe3d5943
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlprofilerservice
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+
+SOURCES += tst_qqmlprofilerservice.cpp \
+ ../shared/debugutil.cpp
+OTHER_FILES += data/test.qml
+
+include (../../../shared/util.pri)
+
+CONFIG += parallel_test declarative_debug
+
+QT += core-private v8-private qml-private testlib
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
new file mode 100644
index 0000000000..edc120ba85
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLibraryInfo>
+
+#include "QtQml/private/qqmlprofilerservice_p.h"
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+#define PORT 13773
+#define STR_PORT "13773"
+
+class QQmlProfilerClient : public QQmlDebugClient
+{
+ Q_OBJECT
+
+public:
+ QQmlProfilerClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("CanvasFrameRate"), connection)
+ {
+ }
+
+ QList<QQmlProfilerData> traceMessages;
+
+ void setTraceState(bool enabled) {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << enabled;
+ sendMessage(message);
+ }
+
+signals:
+ void complete();
+
+protected:
+ void messageReceived(const QByteArray &message);
+};
+
+class tst_QQmlProfilerService : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QQmlProfilerService()
+ : m_process(0)
+ , m_connection(0)
+ , m_client(0)
+ {
+ }
+
+private:
+ QQmlDebugProcess *m_process;
+ QQmlDebugConnection *m_connection;
+ QQmlProfilerClient *m_client;
+
+ void connect(bool block, const QString &testFile);
+
+private slots:
+ void cleanup();
+
+ void blockingConnectWithTraceEnabled();
+ void blockingConnectWithTraceDisabled();
+ void nonBlockingConnect();
+ void profileOnExit();
+};
+
+void QQmlProfilerClient::messageReceived(const QByteArray &message)
+{
+ QByteArray msg = message;
+ QDataStream stream(&msg, QIODevice::ReadOnly);
+
+
+ QQmlProfilerData data;
+ data.time = -2;
+ data.messageType = -1;
+ data.detailType = -1;
+ data.line = -1;
+ data.framerate = -1;
+ data.animationcount = -1;
+
+ stream >> data.time >> data.messageType;
+
+ QVERIFY(data.time >= -1);
+
+ switch (data.messageType) {
+ case (QQmlProfilerService::Event): {
+ stream >> data.detailType;
+
+ switch (data.detailType) {
+ case QQmlProfilerService::AnimationFrame: {
+ stream >> data.framerate >> data.animationcount;
+ QVERIFY(data.framerate != -1);
+ QVERIFY(data.animationcount != -1);
+ break;
+ }
+ case QQmlProfilerService::FramePaint:
+ case QQmlProfilerService::Mouse:
+ case QQmlProfilerService::Key:
+ case QQmlProfilerService::StartTrace:
+ case QQmlProfilerService::EndTrace:
+ break;
+ default: {
+ QString failMsg = QString("Unknown event type:") + data.detailType;
+ QFAIL(qPrintable(failMsg));
+ break;
+ }
+ }
+ break;
+ }
+ case QQmlProfilerService::Complete: {
+ emit complete();
+ return;
+ }
+ case QQmlProfilerService::RangeStart: {
+ stream >> data.detailType;
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ break;
+ }
+ case QQmlProfilerService::RangeEnd: {
+ stream >> data.detailType;
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ break;
+ }
+ case QQmlProfilerService::RangeData: {
+ stream >> data.detailType >> data.detailData;
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ break;
+ }
+ case QQmlProfilerService::RangeLocation: {
+ stream >> data.detailType >> data.detailData >> data.line >> data.column;
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ QVERIFY(data.line >= -2);
+ break;
+ }
+ default:
+ QString failMsg = QString("Unknown message type:") + data.messageType;
+ QFAIL(qPrintable(failMsg));
+ break;
+ }
+ QVERIFY(stream.atEnd());
+ traceMessages.append(data);
+}
+
+void tst_QQmlProfilerService::connect(bool block, const QString &testFile)
+{
+ const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
+ QStringList arguments;
+
+ if (block)
+ arguments << QString("-qmljsdebugger=port:"STR_PORT",block");
+ else
+ arguments << QString("-qmljsdebugger=port:"STR_PORT);
+
+ arguments << QQmlDataTest::instance()->testFile(testFile);
+
+ m_process = new QQmlDebugProcess(executable);
+ m_process->start(QStringList() << arguments);
+ if (!m_process->waitForSessionStart()) {
+ QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg(
+ executable, m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ QQmlDebugConnection *m_connection = new QQmlDebugConnection();
+ m_client = new QQmlProfilerClient(m_connection);
+
+ m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
+}
+
+void tst_QQmlProfilerService::cleanup()
+{
+ delete m_process;
+ delete m_connection;
+ delete m_client;
+}
+
+void tst_QQmlProfilerService::blockingConnectWithTraceEnabled()
+{
+ connect(true, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(true);
+ m_client->setTraceState(false);
+ if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
+ QString failMsg
+ = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ QVERIFY(m_client->traceMessages.count());
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+}
+
+void tst_QQmlProfilerService::blockingConnectWithTraceDisabled()
+{
+ connect(true, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(false);
+ m_client->setTraceState(true);
+ m_client->setTraceState(false);
+ if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
+ QString failMsg
+ = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ QVERIFY(m_client->traceMessages.count());
+
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+}
+
+void tst_QQmlProfilerService::nonBlockingConnect()
+{
+ connect(false, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(true);
+ m_client->setTraceState(false);
+ if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
+ QString failMsg
+ = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+}
+
+void tst_QQmlProfilerService::profileOnExit()
+{
+ connect(true, "exit.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(true);
+
+ if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
+ QString failMsg
+ = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+}
+
+QTEST_MAIN(tst_QQmlProfilerService)
+
+#include "tst_qqmlprofilerservice.moc"
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/data/console.qml b/tests/auto/qml/debugger/qv8profilerservice/data/console.qml
index c23c820216..c23c820216 100644
--- a/tests/auto/declarative/debugger/qv8profilerservice/data/console.qml
+++ b/tests/auto/qml/debugger/qv8profilerservice/data/console.qml
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml b/tests/auto/qml/debugger/qv8profilerservice/data/exit.qml
index 604265354c..604265354c 100644
--- a/tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml
+++ b/tests/auto/qml/debugger/qv8profilerservice/data/exit.qml
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/data/test.qml b/tests/auto/qml/debugger/qv8profilerservice/data/test.qml
index 9c36e13c5b..9c36e13c5b 100644
--- a/tests/auto/declarative/debugger/qv8profilerservice/data/test.qml
+++ b/tests/auto/qml/debugger/qv8profilerservice/data/test.qml
diff --git a/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro
new file mode 100644
index 0000000000..e980d6594d
--- /dev/null
+++ b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qv8profilerservice
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+
+SOURCES += tst_qv8profilerservice.cpp \
+ ../shared/debugutil.cpp
+
+include (../../../shared/util.pri)
+
+OTHER_FILES += data/test.qml
+
+CONFIG += parallel_test declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
new file mode 100644
index 0000000000..c5992a4403
--- /dev/null
+++ b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLibraryInfo>
+
+#include "QtQml/private/qv8profilerservice_p.h"
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+#define PORT 13774
+#define STR_PORT "13774"
+
+class QV8ProfilerClient : public QQmlDebugClient
+{
+ Q_OBJECT
+
+public:
+ QV8ProfilerClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("V8Profiler"), connection)
+ {
+ }
+
+ void startProfiling(const QString &name) {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << QByteArray("V8PROFILER") << QByteArray("start") << name;
+ sendMessage(message);
+ }
+
+ void stopProfiling(const QString &name) {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << QByteArray("V8PROFILER") << QByteArray("stop") << name;
+ sendMessage(message);
+ }
+
+ void takeSnapshot() {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << QByteArray("V8SNAPSHOT") << QByteArray("full");
+ sendMessage(message);
+ }
+
+ void deleteSnapshots() {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << QByteArray("V8SNAPSHOT") << QByteArray("delete");
+ sendMessage(message);
+ }
+
+ QList<QV8ProfilerData> traceMessages;
+ QList<QByteArray> snapshotMessages;
+
+signals:
+ void started();
+ void complete();
+ void snapshot();
+
+protected:
+ void messageReceived(const QByteArray &message);
+};
+
+class tst_QV8ProfilerService : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QV8ProfilerService()
+ : m_process(0)
+ , m_connection(0)
+ , m_client(0)
+ {
+ }
+
+private:
+ QQmlDebugProcess *m_process;
+ QQmlDebugConnection *m_connection;
+ QV8ProfilerClient *m_client;
+
+ void connect(bool block, const QString &testFile);
+
+private slots:
+ void cleanup();
+
+ void blockingConnectWithTraceEnabled();
+ void blockingConnectWithTraceDisabled();
+ void nonBlockingConnect();
+ void snapshot();
+ void profileOnExit();
+ void console();
+};
+
+void QV8ProfilerClient::messageReceived(const QByteArray &message)
+{
+ QByteArray msg = message;
+ QDataStream stream(&msg, QIODevice::ReadOnly);
+
+ int messageType;
+ stream >> messageType;
+
+ QVERIFY(messageType >= 0);
+ QVERIFY(messageType < QV8ProfilerService::V8MaximumMessage);
+
+ switch (messageType) {
+ case QV8ProfilerService::V8Entry: {
+ QV8ProfilerData entry;
+ stream >> entry.filename >> entry.functionname >> entry.lineNumber >> entry.totalTime >> entry.selfTime >> entry.treeLevel;
+ traceMessages.append(entry);
+ break;
+ }
+ case QV8ProfilerService::V8Complete:
+ emit complete();
+ break;
+ case QV8ProfilerService::V8SnapshotChunk: {
+ QByteArray json;
+ stream >> json;
+ snapshotMessages.append(json);
+ break;
+ }
+ case QV8ProfilerService::V8SnapshotComplete:
+ emit snapshot();
+ break;
+ case QV8ProfilerService::V8Started:
+ emit started();
+ break;
+ default:
+ QString failMessage = QString("Unknown message type: %1").arg(messageType);
+ QFAIL(qPrintable(failMessage));
+ }
+
+ QVERIFY(stream.atEnd());
+}
+
+void tst_QV8ProfilerService::connect(bool block, const QString &testFile)
+{
+ const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
+ QStringList arguments;
+
+ if (block)
+ arguments << QString("-qmljsdebugger=port:"STR_PORT",block");
+ else
+ arguments << QString("-qmljsdebugger=port:"STR_PORT);
+
+ arguments << QQmlDataTest::instance()->testFile(testFile);
+
+ m_process = new QQmlDebugProcess(executable);
+ m_process->start(QStringList() << arguments);
+ if (!m_process->waitForSessionStart()) {
+ QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg(
+ executable, m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ QQmlDebugConnection *m_connection = new QQmlDebugConnection();
+ m_client = new QV8ProfilerClient(m_connection);
+
+ m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
+}
+
+void tst_QV8ProfilerService::cleanup()
+{
+ if (QTest::currentTestFailed())
+ qDebug() << "Application Output:" << m_process->output();
+
+ delete m_process;
+ delete m_connection;
+ delete m_client;
+}
+
+void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
+{
+ connect(true, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->startProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
+ m_client->stopProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+}
+
+void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
+{
+ connect(true, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->stopProfiling("");
+ if (QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()), 1000)) {
+ QString failMsg
+ = QString("Unexpected trace received! App output: %1\n\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+ m_client->startProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
+ m_client->stopProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+}
+
+void tst_QV8ProfilerService::nonBlockingConnect()
+{
+ connect(false, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->startProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
+ m_client->stopProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+}
+
+void tst_QV8ProfilerService::snapshot()
+{
+ connect(false, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->takeSnapshot();
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(snapshot())),
+ "No trace received in time.");
+}
+
+void tst_QV8ProfilerService::profileOnExit()
+{
+ connect(true, "exit.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->startProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
+
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+ //QVERIFY(!m_client->traceMessages.isEmpty());
+}
+
+void tst_QV8ProfilerService::console()
+{
+ connect(true, "console.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->stopProfiling("");
+
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+ QVERIFY(!m_client->traceMessages.isEmpty());
+}
+
+QTEST_MAIN(tst_QV8ProfilerService)
+
+#include "tst_qv8profilerservice.moc"
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
new file mode 100644
index 0000000000..8ed64d3a5d
--- /dev/null
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "debugutil_p.h"
+
+#include <QEventLoop>
+#include <QTimer>
+
+#include <private/qqmldebugclient_p.h>
+#include <private/qqmldebugservice_p.h>
+
+bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
+ QEventLoop loop;
+ QTimer timer;
+ timer.setSingleShot(true);
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ QObject::connect(receiver, member, &loop, SLOT(quit()));
+ timer.start(timeout);
+ loop.exec();
+ return timer.isActive();
+}
+
+QQmlDebugTestService::QQmlDebugTestService(const QString &s, float version, QObject *parent)
+ : QQmlDebugService(s, version, parent)
+{
+ registerService();
+}
+
+void QQmlDebugTestService::messageReceived(const QByteArray &ba)
+{
+ sendMessage(ba);
+}
+
+void QQmlDebugTestService::stateChanged(State)
+{
+ emit stateHasChanged();
+}
+
+
+QQmlDebugTestClient::QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c)
+ : QQmlDebugClient(s, c)
+{
+}
+
+QByteArray QQmlDebugTestClient::waitForResponse()
+{
+ lastMsg.clear();
+ QQmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
+ if (lastMsg.isEmpty()) {
+ qWarning() << "tst_QQmlDebugTestClient: no response from server!";
+ return QByteArray();
+ }
+ return lastMsg;
+}
+
+void QQmlDebugTestClient::stateChanged(State stat)
+{
+ QCOMPARE(stat, state());
+ emit stateHasChanged();
+}
+
+void QQmlDebugTestClient::messageReceived(const QByteArray &ba)
+{
+ lastMsg = ba;
+ emit serverMessage(ba);
+}
+
+QQmlDebugProcess::QQmlDebugProcess(const QString &executable)
+ : m_executable(executable)
+ , m_started(false)
+{
+ m_process.setProcessChannelMode(QProcess::MergedChannels);
+ m_timer.setSingleShot(true);
+ m_timer.setInterval(5000);
+ connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput()));
+ connect(&m_timer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
+}
+
+QQmlDebugProcess::~QQmlDebugProcess()
+{
+ stop();
+}
+
+void QQmlDebugProcess::start(const QStringList &arguments)
+{
+ m_mutex.lock();
+ m_process.setEnvironment(m_environment);
+ m_process.start(m_executable, arguments);
+ m_process.waitForStarted();
+ m_timer.start();
+ m_mutex.unlock();
+}
+
+void QQmlDebugProcess::stop()
+{
+ if (m_process.state() != QProcess::NotRunning) {
+ m_process.kill();
+ m_process.waitForFinished(5000);
+ }
+}
+
+bool QQmlDebugProcess::waitForSessionStart()
+{
+ if (m_process.state() != QProcess::Running) {
+ qWarning() << "Could not start up " << m_executable;
+ return false;
+ }
+ m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
+
+ return m_started;
+}
+
+void QQmlDebugProcess::setEnvironment(const QStringList &environment)
+{
+ m_environment = environment;
+}
+
+QString QQmlDebugProcess::output() const
+{
+ return m_output;
+}
+
+void QQmlDebugProcess::processAppOutput()
+{
+ m_mutex.lock();
+
+ QString newOutput = m_process.readAll();
+ m_output.append(newOutput);
+ m_outputBuffer.append(newOutput);
+
+ while (true) {
+ const int nlIndex = m_outputBuffer.indexOf(QLatin1Char('\n'));
+ if (nlIndex < 0) // no further complete lines
+ break;
+ const QString line = m_outputBuffer.left(nlIndex);
+ m_outputBuffer = m_outputBuffer.right(m_outputBuffer.size() - nlIndex - 1);
+
+ if (line.startsWith("Qml debugging is enabled")) // ignore
+ continue;
+ if (line.startsWith("QQmlDebugServer:")) {
+ if (line.contains("Waiting for connection ")) {
+ m_started = true;
+ m_eventLoop.quit();
+ continue;
+ }
+ if (line.contains("Connection established")) {
+ continue;
+ }
+ }
+ }
+ m_mutex.unlock();
+}
diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h
new file mode 100644
index 0000000000..194f8fa14c
--- /dev/null
+++ b/tests/auto/qml/debugger/shared/debugutil_p.h
@@ -0,0 +1,127 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEBUGUTIL_H
+#define DEBUGUTIL_H
+
+#include <QEventLoop>
+#include <QTimer>
+#include <QThread>
+#include <QTest>
+#include <QProcess>
+
+#include <QtQml/qqmlengine.h>
+
+#include <private/qqmldebugclient_p.h>
+#include <private/qqmldebugservice_p.h>
+
+class QQmlDebugTest
+{
+public:
+ static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
+};
+
+class QQmlDebugTestService : public QQmlDebugService
+{
+ Q_OBJECT
+public:
+ QQmlDebugTestService(const QString &s, float version = 1, QObject *parent = 0);
+
+signals:
+ void stateHasChanged();
+
+protected:
+ virtual void messageReceived(const QByteArray &ba);
+ virtual void stateChanged(State state);
+};
+
+class QQmlDebugTestClient : public QQmlDebugClient
+{
+ Q_OBJECT
+public:
+ QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c);
+
+ QByteArray waitForResponse();
+
+signals:
+ void stateHasChanged();
+ void serverMessage(const QByteArray &);
+
+protected:
+ virtual void stateChanged(State state);
+ virtual void messageReceived(const QByteArray &ba);
+
+private:
+ QByteArray lastMsg;
+};
+
+class QQmlDebugProcess : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlDebugProcess(const QString &executable);
+ ~QQmlDebugProcess();
+
+ void setEnvironment(const QStringList &environment);
+
+ void start(const QStringList &arguments);
+ bool waitForSessionStart();
+
+ QString output() const;
+ void stop();
+
+private slots:
+ void processAppOutput();
+
+private:
+ QString m_executable;
+ QProcess m_process;
+ QString m_outputBuffer;
+ QString m_output;
+ QTimer m_timer;
+ QEventLoop m_eventLoop;
+ QMutex m_mutex;
+ bool m_started;
+ QStringList m_environment;
+};
+
+#endif // DEBUGUTIL_H
diff --git a/tests/auto/qml/parserstress/parserstress.pro b/tests/auto/qml/parserstress/parserstress.pro
new file mode 100644
index 0000000000..3cf3e02e4e
--- /dev/null
+++ b/tests/auto/qml/parserstress/parserstress.pro
@@ -0,0 +1,12 @@
+CONFIG += testcase
+TARGET = tst_parserstress
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_parserstress.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+DEFINES += TESTDATADIR=\\\"$$PWD/tests\\\"
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js
index b73ca2df71..b73ca2df71 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js
index 7d00703d30..7d00703d30 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js
index b894433d01..b894433d01 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js
index 7e2e7ef436..7e2e7ef436 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js
index b36f339966..b36f339966 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js
index 414c901926..414c901926 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js
index 986684e338..986684e338 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js
index 9e957cbb21..9e957cbb21 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js
index 4d1806d9b8..4d1806d9b8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js
index 255d0b5fb4..255d0b5fb4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js
index e77ba8d876..e77ba8d876 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js
index 27d9bd257b..27d9bd257b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js
index 36c1967f16..36c1967f16 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js
index dfb47ca284..dfb47ca284 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js
index bd886b0cb0..bd886b0cb0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js
index d0be6bd471..d0be6bd471 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js
index ff97512a44..ff97512a44 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js
index 503d7e635e..503d7e635e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js
index a9b7b0ec14..a9b7b0ec14 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js
index a3a521da09..a3a521da09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js
index 301c435d15..301c435d15 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js
index 984d2fe80a..984d2fe80a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js
index 2ab2072098..2ab2072098 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js
index 090300d59b..090300d59b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js
index 2966a00456..2966a00456 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js
index ff15f9d4e8..ff15f9d4e8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js
index 56a400ab49..56a400ab49 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/browser.js b/tests/auto/qml/parserstress/tests/ecma/Array/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/shell.js b/tests/auto/qml/parserstress/tests/ecma/Array/shell.js
index 9480d9e77d..9480d9e77d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js
index b698cbe407..b698cbe407 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js
index f9fccb3e57..f9fccb3e57 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js
index 0be8097487..0be8097487 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js
index 5d435982d4..5d435982d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js
index 0f1b125267..0f1b125267 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js
index 822750308a..822750308a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js
index ca808c63a5..ca808c63a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js
index 584562b2a8..584562b2a8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js
index 3b75fb49ec..3b75fb49ec 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js
index 54bd2e19d3..54bd2e19d3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js
index 2039004472..2039004472 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js
index 4dcc65f21f..4dcc65f21f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js
index 0dd3e5f349..0dd3e5f349 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js
index 8b913e011e..8b913e011e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js
index 5548a7874f..5548a7874f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js
index f05dfc0c60..f05dfc0c60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js
index 4ebabfa84c..4ebabfa84c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js
index 570652ee39..570652ee39 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js
index 0c95d255fe..0c95d255fe 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/browser.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/shell.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js
index 2ff7258ce8..2ff7258ce8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js
index 8e82d205f3..8e82d205f3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js
index 7b8c2644e3..7b8c2644e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.13-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js
index 720b39dd54..720b39dd54 100755
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.13-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js
index 6cd76efb6b..6cd76efb6b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js
index 0c643cfd3a..0c643cfd3a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js
index af95bb3ae6..af95bb3ae6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js
index f7de60b5b1..f7de60b5b1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js
index 119b4f2559..119b4f2559 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js
index d9369ca4c5..d9369ca4c5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js
index 8e549936e3..8e549936e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js
index 642169a60c..642169a60c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js
index fb9dff486c..fb9dff486c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js
index 0d888b089c..0d888b089c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js
index 5f95a5b797..5f95a5b797 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js
index f37c1c8da2..f37c1c8da2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js
index ae0502be64..ae0502be64 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js
index acc2ac7f0b..acc2ac7f0b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js
index d4b48fed35..d4b48fed35 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js
index 1b2757cd9a..1b2757cd9a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js
index 09d6272c6f..09d6272c6f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js
index d48199ccba..d48199ccba 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js
index f9d8d36d04..f9d8d36d04 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js
index c3042a8216..c3042a8216 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js
index c3a1eae7dc..c3a1eae7dc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js
index 405842c79f..405842c79f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js
index 4b269f264f..4b269f264f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js
index 5a518e6442..5a518e6442 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js
index b0549588aa..b0549588aa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js
index 3185a7c4e5..3185a7c4e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js
index cd73d288c9..cd73d288c9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-10.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js
index 4142635486..4142635486 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-11.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js
index dfadc18838..dfadc18838 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-12.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js
index 2557108faf..2557108faf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-13.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js
index e0e2402ebd..e0e2402ebd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-13.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js
index e44cfcc5d7..e44cfcc5d7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js
index 325c9bfaf2..325c9bfaf2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js
index 41676c2658..41676c2658 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js
index f17b0a0b29..f17b0a0b29 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js
index 84f57b8805..84f57b8805 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js
index 96ba89078a..96ba89078a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js
index bae220a94e..bae220a94e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js
index a1cee0e682..a1cee0e682 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js
index 5c2439ba09..5c2439ba09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js
index d9eda4cfc1..d9eda4cfc1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js
index d35f8d5967..d35f8d5967 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js
index 4fc9f2ee65..4fc9f2ee65 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js
index cee93a770b..cee93a770b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js
index b756e43a7e..b756e43a7e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js
index 65c5c1c765..65c5c1c765 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js
index c173ffb193..c173ffb193 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js
index 5967da6ef6..5967da6ef6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js
index 9ce226665c..9ce226665c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js
index 3b752a1767..3b752a1767 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js
index 7fe153a5ea..7fe153a5ea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js
index 663ab81b2d..663ab81b2d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js
index 23a0218058..23a0218058 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js
index 4f3f66e0ce..4f3f66e0ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js
index d82f39a7e0..d82f39a7e0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js
index 13f0d080e3..13f0d080e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js
index 7c78072ee5..7c78072ee5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js
index bcfcfb8c00..bcfcfb8c00 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js
index 96b1acb170..96b1acb170 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js
index e749ad6b7f..e749ad6b7f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js
index 63607f8d2d..63607f8d2d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js
index 75d42b200b..75d42b200b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.14.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js
index 5a3f8216da..5a3f8216da 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.14.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.15.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js
index ca2babd7ef..ca2babd7ef 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.15.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.16.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js
index e791b74eae..e791b74eae 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.16.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.17.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js
index e9b30c3eed..e9b30c3eed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.17.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.18.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js
index f735168efe..f735168efe 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.18.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.19.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js
index 2a0d7430ef..2a0d7430ef 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.19.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js
index 7ec3c691c8..7ec3c691c8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js
index c5513b8168..c5513b8168 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js
index ef2df0510b..ef2df0510b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.20.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js
index fb3dafde2c..fb3dafde2c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.20.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js
index 4eea164305..4eea164305 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js
index 37b443117a..37b443117a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js
index d1d96cb7a3..d1d96cb7a3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js
index b7dfa656ff..b7dfa656ff 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js
index ca90b1784a..ca90b1784a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js
index 9178ae76cf..9178ae76cf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js
index c4d0a4b615..c4d0a4b615 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js
index 624d6c6bcb..624d6c6bcb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js
index 5d2a6934ab..5d2a6934ab 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js
index b828b468d1..b828b468d1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js
index 26c059368d..26c059368d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js
index 96b9771d59..96b9771d59 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js
index a943aa5699..a943aa5699 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js
index 96b39d2c43..96b39d2c43 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js
index 7fa0ecaf14..7fa0ecaf14 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js
index 3eca9d8ec9..3eca9d8ec9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js
index e4a228e2cd..e4a228e2cd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-10.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js
index d4cb298d19..d4cb298d19 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-11.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js
index ca28015766..ca28015766 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-12.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js
index a03f599567..a03f599567 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-13.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js
index a68128770c..a68128770c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-13.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-14.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js
index 1923d715e3..1923d715e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-14.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-15.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js
index 31680eb386..31680eb386 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-15.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-16.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js
index 3dc0726ca8..3dc0726ca8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-16.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-17.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js
index 605f4cf00b..605f4cf00b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-17.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-18.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js
index e30d0f05c8..e30d0f05c8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-18.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js
index 8086af88d9..8086af88d9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js
index 040604bd0e..040604bd0e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js
index 39e3dec8d4..39e3dec8d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js
index b4317e6a55..b4317e6a55 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js
index cc9e07b9fd..cc9e07b9fd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js
index 46bb900b18..46bb900b18 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js
index 8072a9cc1f..8072a9cc1f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js
index b480791e3d..b480791e3d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js
index e02aa6150a..e02aa6150a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js
index da6261670b..da6261670b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js
index 8199010953..8199010953 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js
index f6b1dae966..f6b1dae966 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js
index 53458028be..53458028be 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js
index 188dbacff9..188dbacff9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js
index b2fe8fcff9..b2fe8fcff9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js
index d6ea2d8d3e..d6ea2d8d3e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.25-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js
index 0eb7783ec8..0eb7783ec8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.25-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.26-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js
index 509ec73d33..509ec73d33 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.26-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.27-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js
index 1b06777332..1b06777332 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.27-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.28-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js
index 902d70a873..902d70a873 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.28-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.29-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js
index 42fa36e9b5..42fa36e9b5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.29-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js
index e1f227f785..e1f227f785 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js
index 9f425c3450..9f425c3450 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.30-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js
index 7abb3927d7..7abb3927d7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.30-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.31-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js
index 10f0f93e17..10f0f93e17 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.31-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.32-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js
index d277fd9af1..d277fd9af1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.32-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.33-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js
index 01e1ff2f94..01e1ff2f94 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.33-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.34-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js
index de4d8c817b..de4d8c817b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.34-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.35-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js
index 427657cb47..427657cb47 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.35-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js
index f4cd44c2c2..f4cd44c2c2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js
index a0ce018d0f..a0ce018d0f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js
index f0849f28e7..f0849f28e7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js
index 0ca872f8db..0ca872f8db 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js
index 2496548b1d..2496548b1d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js
index 9a05c3130e..9a05c3130e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js
index 5bc330bbea..5bc330bbea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js
index a6acd3d10a..a6acd3d10a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js
index e5ec78ea72..e5ec78ea72 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js
index d256511459..d256511459 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js
index 017afd6389..017afd6389 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js
index 046f3095df..046f3095df 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js
index 6ad06931f8..6ad06931f8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js
index 1cd98dd801..1cd98dd801 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js
index f0136b00ad..f0136b00ad 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js
index 9ae804ebb9..9ae804ebb9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js
index c4c83a2c38..c4c83a2c38 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js
index 572e293960..572e293960 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js
index 9f0fc124af..9f0fc124af 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js
index 9e3bd94080..9e3bd94080 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/browser.js b/tests/auto/qml/parserstress/tests/ecma/Date/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/shell.js b/tests/auto/qml/parserstress/tests/ecma/Date/shell.js
index 0beb78e064..0beb78e064 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js
index 699296d6b1..699296d6b1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js
index 3762842461..3762842461 100755
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js
index fd466de210..fd466de210 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js
index ec49f20596..ec49f20596 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js
index 218031c83f..218031c83f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js
index 2aee831b45..2aee831b45 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js
index a3ae0ffdec..a3ae0ffdec 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js
index 31274a0209..31274a0209 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js
index c36d2db8cc..c36d2db8cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js
index da11110cc5..da11110cc5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js
index f1a0db4569..f1a0db4569 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js
index 1eee8da4fb..1eee8da4fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js
index 363581eff6..363581eff6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js
index cfba3b5c73..cfba3b5c73 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js
index f5234cb13b..f5234cb13b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js
index 953e6a8feb..953e6a8feb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js
index 40e6f0ee8f..40e6f0ee8f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js
index 71aa876f02..71aa876f02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js
index 5384da4f83..5384da4f83 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js
index 787ef9e5b3..787ef9e5b3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js
index 8048c45575..8048c45575 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js
index a1977c66d6..a1977c66d6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js
index e1aa78c5da..e1aa78c5da 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/browser.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/shell.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js
index 1d353cff74..1d353cff74 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.1.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js
index 18f0ec7f13..18f0ec7f13 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js
index 5b70334ff5..5b70334ff5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js
index 27bde196e0..27bde196e0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js
index 3da6963255..3da6963255 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js
index ff131b672e..ff131b672e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js
index c2a1e894e0..c2a1e894e0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js
index 11dde79fb3..11dde79fb3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js
index 861692c4e8..861692c4e8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js
index 5e548a3e76..5e548a3e76 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js
index 41402b77ce..41402b77ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js
index 2d3b53630b..2d3b53630b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js
index c432934a30..c432934a30 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js
index 8514dd8c9c..8514dd8c9c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js
index 99d227b80f..99d227b80f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js
index bf5f172d36..bf5f172d36 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.14-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js
index c2f30afb6a..c2f30afb6a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.14-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js
index 91e25b01f1..91e25b01f1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js
index eda8168c0f..eda8168c0f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js
index 0732aa0378..0732aa0378 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js
index 110684c9c6..110684c9c6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js
index 2d9f0f1632..2d9f0f1632 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js
index 3603892114..3603892114 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js
index 7105f17071..7105f17071 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-10-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js
index 36781503d9..36781503d9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-10-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-11.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js
index 03a0f8c436..03a0f8c436 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js
index 7fbea97ca1..7fbea97ca1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js
index 8b344a3dda..8b344a3dda 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js
index c2ff538b9f..c2ff538b9f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js
index ba8d0756fb..ba8d0756fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-6-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js
index f89b4009e3..f89b4009e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-6-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-7-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js
index 97ae43e810..97ae43e810 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-7-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-8-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js
index 10117c726e..10117c726e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js
index 6099754ca3..6099754ca3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js
index 6e36ba8d3f..6e36ba8d3f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js
index c3539e817a..c3539e817a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js
index 3023fee16b..3023fee16b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js
index 3c0ac1a4b3..3c0ac1a4b3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js
index 92b356c1dd..92b356c1dd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js
index 29235f1107..29235f1107 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js
index 2d6f6c6770..2d6f6c6770 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js
index 62354e17bc..62354e17bc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js
index b89d9145c9..b89d9145c9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js
index b746fbe8b5..b746fbe8b5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js
index cbacf869e4..cbacf869e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js
index ee761c5d96..ee761c5d96 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.6.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js
index 9b100d9d50..9b100d9d50 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-01.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js
index 827b80189d..827b80189d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-02.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js
index 43bd923e23..43bd923e23 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.8.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js
index f617e10689..f617e10689 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.9.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js
index 2c57e88211..2c57e88211 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js
index 94edcefea5..94edcefea5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js
index e459e7613f..e459e7613f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js
index 9558b63a96..9558b63a96 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js
index 87666161b6..87666161b6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js
index 1d96d14e92..1d96d14e92 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js
index 9a162787d5..9a162787d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js
index b3ab9b17fb..b3ab9b17fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js
index cf44738528..cf44738528 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js
index 44099f6c94..44099f6c94 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js
index 843388767f..843388767f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js
index 27d24e121a..27d24e121a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js
index 4b35c11b16..4b35c11b16 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js
index c4e6f4cfbd..c4e6f4cfbd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js
index 2180fc5655..2180fc5655 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js
index d43aaa260d..d43aaa260d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js
index 6bf3fc0517..6bf3fc0517 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js
index b6983e6af1..b6983e6af1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js
index cce1c63c16..cce1c63c16 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/browser.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/shell.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js
index 8f5d1129d5..8f5d1129d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js
index 90f080acc9..90f080acc9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js
index 57fe78c8f1..57fe78c8f1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js
index 51f7bb763b..51f7bb763b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js
index d76e57b828..d76e57b828 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js
index 7729c9587a..7729c9587a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js
index 80b1c41e00..80b1c41e00 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js
index b760afd149..b760afd149 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js
index 62e6d42342..62e6d42342 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js
index 6e1aa8426d..6e1aa8426d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js
index b1d04f3957..b1d04f3957 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js
index c90c26a9e5..c90c26a9e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js
index a6bc775902..a6bc775902 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js
index 59e3ff81a5..59e3ff81a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js
index c3fbfc774e..c3fbfc774e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js
index dcb351985d..dcb351985d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js
index 406d569dba..406d569dba 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js
index 4a127fbc68..4a127fbc68 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js
index 27aa7b1318..27aa7b1318 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-1-n.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js
index 9946a7f2da..9946a7f2da 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-2-n.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js
index 545caeeae0..545caeeae0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js
index a8d4e7fecf..a8d4e7fecf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js
index 8671ff642a..8671ff642a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js
index 8572371f8e..8572371f8e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js
index a4bf1c7de6..a4bf1c7de6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js
index ff8806dfb2..ff8806dfb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js
index 56bf83adcc..56bf83adcc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js
index 557b93f637..557b93f637 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.4.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js
index bd2114a1a9..bd2114a1a9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js
index b7b072a627..b7b072a627 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js
index 99b58752b2..99b58752b2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js
index 2615d62531..2615d62531 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.6.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js
index faeeb9e0b0..faeeb9e0b0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.7.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js
index e3db5e7931..e3db5e7931 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/browser.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/shell.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js
index d922707218..d922707218 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js
index 7fa415c20d..7fa415c20d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js
index aa0c3fb373..aa0c3fb373 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js
index c405106ade..c405106ade 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js
index dd4f2fcbed..dd4f2fcbed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js
index d945115832..d945115832 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js
index c62410d202..c62410d202 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js
index b29f999739..b29f999739 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js
index b563d86437..b563d86437 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js
index 220548e78e..220548e78e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js
index 9701660576..9701660576 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-10.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js
index 1cd0f18a90..1cd0f18a90 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-11.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js
index f9033cd05a..f9033cd05a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-12.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js
index 04ceb81409..04ceb81409 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js
index 714de99a9a..714de99a9a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js
index 7aa029feda..7aa029feda 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js
index 1886639e26..1886639e26 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-4.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js
index 4cb53af0fb..4cb53af0fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-5.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js
index 22d9e08a60..22d9e08a60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js
index 91afd319a4..91afd319a4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-7.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js
index a35cd54289..a35cd54289 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-8.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js
index 2d665c4ff0..2d665c4ff0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-9.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js
index caff9f7f09..caff9f7f09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js
index 2153cc2638..2153cc2638 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js
index a50bd6020f..a50bd6020f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js
index b49fe7937b..b49fe7937b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js
index 36723173f5..36723173f5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js
index 89003d3601..89003d3601 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js
index 3aff749e51..3aff749e51 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js
index f19ed8c904..f19ed8c904 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js
index 22a5284dcc..22a5284dcc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js
index b9b05f42b7..b9b05f42b7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js
index 27e83972c3..27e83972c3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js
index 988920538c..988920538c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js
index 648610a9e6..648610a9e6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js
index d8b74d6b0e..d8b74d6b0e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js
index 2bb0aa260b..2bb0aa260b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js
index 3fdf06b2c1..3fdf06b2c1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js
index 00f3f99a4c..00f3f99a4c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js
index 6a85b261ce..6a85b261ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js
index 5f5122e0f2..5f5122e0f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js
index c1c4df6d9b..c1c4df6d9b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js
index dee163d8e5..dee163d8e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js
index 8d717f323d..8d717f323d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js
index 4e29e9c3af..4e29e9c3af 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js
index 913fae905b..913fae905b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js
index c196ea2418..c196ea2418 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js
index 8d5af29ede..8d5af29ede 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js
index f855132d8a..f855132d8a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js
index 6d86d357f2..6d86d357f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js
index fe5f6ffac1..fe5f6ffac1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js
index b95c8ecbe0..b95c8ecbe0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js
index b17b06f2e9..b17b06f2e9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js
index d76025b3cc..d76025b3cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js
index 36ffe63977..36ffe63977 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js
index 31239d561a..31239d561a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js
index 666abcc0c8..666abcc0c8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js
index 4fee9c8c4a..4fee9c8c4a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js
index 57be9b63ee..57be9b63ee 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js
index 2561a3deda..2561a3deda 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js
index 3401fe4891..3401fe4891 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js
index 778c284cfb..778c284cfb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js
index 0f4b0fb2f1..0f4b0fb2f1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js
index 97a61e3449..97a61e3449 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js
index a53f4413eb..a53f4413eb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-7.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js
index c3446c6c0d..c3446c6c0d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js
index e363666148..e363666148 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js
index c1ac68512a..c1ac68512a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js
index 091c74d7db..091c74d7db 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js
index 83325b5f32..83325b5f32 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js
index f021eb9b18..f021eb9b18 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js
index fb13b24e07..fb13b24e07 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js
index 8fbe16cb8f..8fbe16cb8f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js
index 9ccb912752..9ccb912752 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.4.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js
index 015a385220..015a385220 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js
index b8d844e41d..b8d844e41d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/browser.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/shell.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js
index 4e1d61d68a..4e1d61d68a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js
index 40c2ae8d2d..40c2ae8d2d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js
index f6333d7ec7..f6333d7ec7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js
index f90f74b9e8..f90f74b9e8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js
index 9f136f2fb8..9f136f2fb8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js
index 0cbc65a4fb..0cbc65a4fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js
index 6937b3520b..6937b3520b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js
index 8289cc2a46..8289cc2a46 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js
index 24a8b18231..24a8b18231 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js
index 227dbb3e2a..227dbb3e2a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js
index c9aa98e77a..c9aa98e77a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js
index b753025c8a..b753025c8a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js
index c134e4a577..c134e4a577 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js
index f2a395618c..f2a395618c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js
index ba53e78de5..ba53e78de5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js
index aa60aead5b..aa60aead5b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js
index 2f8c45c9f9..2f8c45c9f9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js
index 3c5764d019..3c5764d019 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js
index f999dac920..f999dac920 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-3.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js
index 0c823aea57..0c823aea57 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js
index 009325640b..009325640b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js
index 0412742767..0412742767 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.10.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js
index 05d4c187c9..05d4c187c9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.11.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js
index 5a957b3de4..5a957b3de4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.12.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js
index a33a5aca4a..a33a5aca4a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.13.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js
index 341b3e7651..341b3e7651 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.13.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.14.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js
index 1972518c81..1972518c81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.14.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.15.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js
index a5c36b4e61..a5c36b4e61 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.15.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.16.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js
index deb873cdaa..deb873cdaa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.16.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.17.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js
index 2f12f1d93b..2f12f1d93b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.17.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.18.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js
index be68ea191f..be68ea191f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.18.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js
index 12fb00ef81..12fb00ef81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.3.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js
index 11c6d73657..11c6d73657 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.4.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js
index c67ac6d4ea..c67ac6d4ea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.5.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js
index 0adc690743..0adc690743 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.6.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js
index 1c20a1c93e..1c20a1c93e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.7.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js
index 2b19b5986e..2b19b5986e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.8.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js
index 96b6231da2..96b6231da2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.9.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js
index b68a57d5bb..b68a57d5bb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/browser.js b/tests/auto/qml/parserstress/tests/ecma/Math/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/shell.js b/tests/auto/qml/parserstress/tests/ecma/Math/shell.js
index fbcc5c3f92..fbcc5c3f92 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/NativeObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/NativeObjects/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/NativeObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js
index 4ddb940f71..4ddb940f71 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/NativeObjects/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js
index 34cec9f378..34cec9f378 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js
index 4c2c8a298c..4c2c8a298c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js
index d275f50a12..d275f50a12 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js
index ff26a03e63..ff26a03e63 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js
index 4669e969a7..4669e969a7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js
index 35ff1b25c3..35ff1b25c3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js
index 980b688bb6..980b688bb6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js
index 2f20efe2a8..2f20efe2a8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js
index 04d70ce3a9..04d70ce3a9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js
index ed7f0e88a9..ed7f0e88a9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js
index 2b73147c2a..2b73147c2a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js
index d0c98282dd..d0c98282dd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js
index e9427c62f2..e9427c62f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js
index 6a6835f04d..6a6835f04d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js
index fd1e630d54..fd1e630d54 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js
index 6cf1072e20..6cf1072e20 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js
index 3e1db5b9d2..3e1db5b9d2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js
index 8bcb3e3782..8bcb3e3782 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js
index e0c2c440ac..e0c2c440ac 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js
index 983cdd3147..983cdd3147 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js
index acf7b0f543..acf7b0f543 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js
index 466267f7d4..466267f7d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js
index c3e6dbd0fb..c3e6dbd0fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js
index 6055f49374..6055f49374 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js
index 75fa6ee485..75fa6ee485 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js
index bc5e7a3fa1..bc5e7a3fa1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js
index 175835987a..175835987a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js
index 27c0a0a9e4..27c0a0a9e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js
index 531876d980..531876d980 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js
index a99b1deb45..a99b1deb45 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js
index f6148db1cc..f6148db1cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js
index c2fd40dd17..c2fd40dd17 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js
index 755e2281b3..755e2281b3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js
index 1bfed1d4af..1bfed1d4af 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js
index 7df413ae48..7df413ae48 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/browser.js b/tests/auto/qml/parserstress/tests/ecma/Number/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/shell.js b/tests/auto/qml/parserstress/tests/ecma/Number/shell.js
index 03cca1d551..03cca1d551 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js
index 73ddd2894c..73ddd2894c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js
index 9e41594430..9e41594430 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js
index dfdfaeb4ab..dfdfaeb4ab 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js
index 2a5743a826..2a5743a826 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js
index 5242d7e6a5..5242d7e6a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js
index 39510b6b22..39510b6b22 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js
index a92739f2d1..a92739f2d1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js
index 0a82c6cd02..0a82c6cd02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js
index 86be98e1ad..86be98e1ad 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js
index 70a9605c2e..70a9605c2e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js
index bff668f43c..bff668f43c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js
index c52a825bb8..c52a825bb8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js
index 17c4558679..17c4558679 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js
index 1a71207967..1a71207967 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/README b/tests/auto/qml/parserstress/tests/ecma/README
index 91f174ab61..91f174ab61 100755
--- a/tests/auto/declarative/parserstress/tests/ecma/README
+++ b/tests/auto/qml/parserstress/tests/ecma/README
diff --git a/tests/auto/declarative/parserstress/tests/ecma/SourceText/6-1.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js
index 487a47e3aa..487a47e3aa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/SourceText/6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/SourceText/6-2.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js
index 4044308053..4044308053 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/SourceText/6-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/SourceText/browser.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/SourceText/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/SourceText/shell.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js
index c8f9f02671..c8f9f02671 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/SourceText/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js
index 7cb13789eb..7cb13789eb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.10-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.10.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js
index b8d27c64e9..b8d27c64e9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js
index d6f3b97f6d..d6f3b97f6d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js
index 0745428c4a..0745428c4a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js
index 143edb0705..143edb0705 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js
index 97b9afaa82..97b9afaa82 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js
index 2ef9378f5a..2ef9378f5a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js
index cc8676cd29..cc8676cd29 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js
index a16b7aa18e..a16b7aa18e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js
index 6b1500d3a4..6b1500d3a4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js
index a6f86ecc88..a6f86ecc88 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-6.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js
index 48a4e2e607..48a4e2e607 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-7.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js
index a14ced0497..a14ced0497 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-8.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js
index 73d931d838..73d931d838 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js
index 3e2f942a22..3e2f942a22 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js
index 6e23b84a48..6e23b84a48 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-10.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js
index 0e74f14ece..0e74f14ece 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-11.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js
index efc65ee14e..efc65ee14e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-12.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js
index 840ca9da65..840ca9da65 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-19.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js
index 5acbee7127..5acbee7127 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-19.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js
index 3ed93dc9a1..3ed93dc9a1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js
index f52569bba2..f52569bba2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-4.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js
index c30641f8bb..c30641f8bb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-5-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js
index 295d059c39..295d059c39 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-6-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js
index 8cb4c7f638..8cb4c7f638 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-6-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-7-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js
index 871dd474cb..871dd474cb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-7-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-8-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js
index b75a7b5f37..b75a7b5f37 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js
index f83a8ed65a..f83a8ed65a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.7-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js
index 7978f3be56..7978f3be56 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.7-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.8-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js
index 29f46cf29e..29f46cf29e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.8-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.9-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js
index 450cb66593..450cb66593 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.9-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma/Statements/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/shell.js b/tests/auto/qml/parserstress/tests/ecma/Statements/shell.js
index 7346f697a5..7346f697a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js
index cf7ab8b420..cf7ab8b420 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js
index 062d31cdc2..062d31cdc2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js
index cc62c9ed51..cc62c9ed51 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js
index b87137a140..b87137a140 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js
index f94f83db11..f94f83db11 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js
index af8c1b9560..af8c1b9560 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js
index 17e715bca0..17e715bca0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js
index 563623e6e3..563623e6e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js
index ae41742be2..ae41742be2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js
index 5370484568..5370484568 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js
index ae8e12463d..ae8e12463d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.10-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js
index 2647d18cb2..2647d18cb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.10-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js
index a705f3bbda..a705f3bbda 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js
index 7377dc8247..7377dc8247 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js
index 0a37dcd28a..0a37dcd28a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js
index 1196e61c08..1196e61c08 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js
index eec6410200..eec6410200 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-6.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js
index e3cc6039d4..e3cc6039d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js
index ecc497db48..ecc497db48 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js
index c22b87b4dc..c22b87b4dc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js
index d9d8bc69ce..d9d8bc69ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js
index caf5663f07..caf5663f07 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js
index 2fbed42202..2fbed42202 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js
index e607ed51e4..e607ed51e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js
index 930c1f8136..930c1f8136 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js
index 1e306a06f3..1e306a06f3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js
index 0a1100fc63..0a1100fc63 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js
index b990876fe8..b990876fe8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js
index 4747e013e6..4747e013e6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js
index bdfa52ece0..bdfa52ece0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js
index 5dbffb1d14..5dbffb1d14 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js
index c822a1d5f7..c822a1d5f7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js
index 96b4759c98..96b4759c98 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js
index bf9f7a6898..bf9f7a6898 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js
index a1ba440a60..a1ba440a60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js
index 29cb76152e..29cb76152e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js
index 46852f4022..46852f4022 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js
index e1d42c820f..e1d42c820f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js
index cb3ec71e25..cb3ec71e25 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js
index 94e34ad5ed..94e34ad5ed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js
index acaeffb38a..acaeffb38a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js
index 094be2ed62..094be2ed62 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js
index 0252eae00f..0252eae00f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js
index 4aa16d5ea0..4aa16d5ea0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js
index ff33e62ba6..ff33e62ba6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js
index fe10284a9c..fe10284a9c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.9-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js
index 2184c60f45..2184c60f45 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.9-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js
index 063e4e68d1..063e4e68d1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.5.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js
index 85d3d24ef2..85d3d24ef2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/browser.js b/tests/auto/qml/parserstress/tests/ecma/String/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/shell.js b/tests/auto/qml/parserstress/tests/ecma/String/shell.js
index 7d850446cc..7d850446cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js
index 2d428b9a9e..2d428b9a9e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js
index 9994d6a7cd..9994d6a7cd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js
index da3e8794c0..da3e8794c0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js
index 911ec84b94..911ec84b94 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js
index dc56427395..dc56427395 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js
index c4b866e7f3..c4b866e7f3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js
index e99875697a..e99875697a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js
index 9b26a67fac..9b26a67fac 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.5-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js
index 2773052340..2773052340 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.6.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js
index 3d958b3f9d..3d958b3f9d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.7.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js
index 34e4857fd7..34e4857fd7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.8.1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js
index 897dc59f6f..897dc59f6f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.8.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.9-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js
index ea22980767..ea22980767 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.9-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/browser.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/shell.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js
index 49ce60f627..49ce60f627 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/8.1.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.1.js
index 7abcb93c02..7abcb93c02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/8.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/8.4.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.4.js
index 7d3465f8b2..7d3465f8b2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/8.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/8.6.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js
index c06999c42c..c06999c42c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/8.6.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/browser.js b/tests/auto/qml/parserstress/tests/ecma/Types/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/shell.js b/tests/auto/qml/parserstress/tests/ecma/Types/shell.js
index a16b996e00..a16b996e00 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/browser.js b/tests/auto/qml/parserstress/tests/ecma/browser.js
index 60e48ceed8..60e48ceed8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js
index 91982de20c..91982de20c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js
index 99fd4a7ff1..99fd4a7ff1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js
index adfc8d5df5..adfc8d5df5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js
index e467157441..e467157441 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js
index a486885b7f..a486885b7f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js
index 7d66e58530..7d66e58530 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js
index be8a6f6c98..be8a6f6c98 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js
index fc037873a5..fc037873a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js
index e403e46e8e..e403e46e8e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js
index c3fe679e5e..c3fe679e5e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js
index f4f821877d..f4f821877d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js
index 6d49db2481..6d49db2481 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js
index df55e0894a..df55e0894a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js
index 169cf50851..169cf50851 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js
index 42165465bc..42165465bc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js
index fab359211f..fab359211f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js
index 0b37e21028..0b37e21028 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js
index d4f22ff257..d4f22ff257 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js
index 8cbf949855..8cbf949855 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js
index c25398c4f4..c25398c4f4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js
index ebf4d03781..ebf4d03781 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js
index c2e115e0c6..c2e115e0c6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js
index 4eadc66c04..4eadc66c04 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js
index c5832fd477..c5832fd477 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js
index b9f35b8225..b9f35b8225 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js
index 0ae48c59f2..0ae48c59f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js
index 7ca222235f..7ca222235f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js
index 84e362c2db..84e362c2db 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js
index 733b937e55..733b937e55 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js
index 0f51cf5e61..0f51cf5e61 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js
index 54e6bb6f0f..54e6bb6f0f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js
index a99bb01ee6..a99bb01ee6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js
index 0df44013cd..0df44013cd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js b/tests/auto/qml/parserstress/tests/ecma/extensions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js b/tests/auto/qml/parserstress/tests/ecma/extensions/shell.js
index 3f52cffbc0..3f52cffbc0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/jsref.js b/tests/auto/qml/parserstress/tests/ecma/jsref.js
index 1416643e1e..1416643e1e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/jsref.js
+++ b/tests/auto/qml/parserstress/tests/ecma/jsref.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/shell.js b/tests/auto/qml/parserstress/tests/ecma/shell.js
index 1c012601e6..1c012601e6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/template.js b/tests/auto/qml/parserstress/tests/ecma/template.js
index 8f11686890..8f11686890 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/template.js
+++ b/tests/auto/qml/parserstress/tests/ecma/template.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js
index 7462df2f98..7462df2f98 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js
index 813e11cd39..813e11cd39 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js
index 041bbb523c..041bbb523c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js
index 4fb11b38d9..4fb11b38d9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js
index 95129177c7..95129177c7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js
index d77bd1c272..d77bd1c272 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js
index 3762c5b3c4..3762c5b3c4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js
index e5328b8b81..e5328b8b81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js
index c5956ffc95..c5956ffc95 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js
index 15a07a806f..15a07a806f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js
index e5532ff40c..e5532ff40c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js
index b37b52becb..b37b52becb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js
index a63ed0e3f8..a63ed0e3f8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js
index 39326183a4..39326183a4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js
index bd5cbe7f40..bd5cbe7f40 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js
index cb28d635a6..cb28d635a6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js
index ec5302c247..ec5302c247 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js
index c3ae4f21e6..c3ae4f21e6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js
index 2f060936ae..2f060936ae 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js
index 5007b83adf..5007b83adf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js
index 2befdd10f3..2befdd10f3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js
index 2d76593ea2..2d76593ea2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js
index eb21e0308c..eb21e0308c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js
index a2305be16d..a2305be16d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js
index c85310f957..c85310f957 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js
index feec2cd052..feec2cd052 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js
index e0b38a4838..e0b38a4838 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js
index 75f872480d..75f872480d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js
index 5223abd480..5223abd480 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js
index 10ad726653..10ad726653 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js
index fadca81c7a..fadca81c7a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js
index 2bd2b8d094..2bd2b8d094 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js
index 3c91495f3c..3c91495f3c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js
index 4e762a54a9..4e762a54a9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js
index 11ee3a0063..11ee3a0063 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js
index d5f7b452e2..d5f7b452e2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js
index a186a51e64..a186a51e64 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js
index c4ef143529..c4ef143529 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js
index cc2e3a46aa..cc2e3a46aa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js
index f7f691a049..f7f691a049 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js
index 482382eeed..482382eeed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js
index ccf6124109..ccf6124109 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js
index 44b2ea9c87..44b2ea9c87 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js
index 6f693d8ad2..6f693d8ad2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js
index b6d5152ea0..b6d5152ea0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js
index eed455c243..eed455c243 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js
index d796574809..d796574809 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js
index 059b5a06be..059b5a06be 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js
index 7f01041c41..7f01041c41 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js
index e55b6eb30f..e55b6eb30f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js
index fbbf20b263..fbbf20b263 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js
index 880d2800e5..880d2800e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js
index a15a2be544..a15a2be544 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js
index 021594d052..021594d052 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js
index b89a526229..b89a526229 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js
index 18773dafe6..18773dafe6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js
index c1c34a93c1..c1c34a93c1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js
index e82e1e50b9..e82e1e50b9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js
index 47a0725a09..47a0725a09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js
index 75d72aa5b6..75d72aa5b6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js
index aa89c04782..aa89c04782 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js
index 7c1f22f745..7c1f22f745 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js
index f1c7b93daf..f1c7b93daf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js
index 31b5aaaf61..31b5aaaf61 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js
index 573025b591..573025b591 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js
index 1b76a22169..1b76a22169 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js
index f978b8ef89..f978b8ef89 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js
index 3796551698..3796551698 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js
index 13379fed01..13379fed01 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js
index 48e6e9aac5..48e6e9aac5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js
index cc223c2282..cc223c2282 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js
index 4d3c7d5fc0..4d3c7d5fc0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js
index 2a61b437ba..2a61b437ba 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js
index a1923b7303..a1923b7303 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js
index e3cd75bd60..e3cd75bd60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js
index 1bf8c6c4e4..1bf8c6c4e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js
index 2f193af89a..2f193af89a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js
index f5ba3533dd..f5ba3533dd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js
index 06d63bddb3..06d63bddb3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js
index c2cedb0b81..c2cedb0b81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js
index e809c24149..e809c24149 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js
index 18054d4328..18054d4328 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js
index e4ce840829..e4ce840829 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js
index d9161c4b8f..d9161c4b8f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js
index 97ccbc6b43..97ccbc6b43 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js
index 20d2d3c254..20d2d3c254 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js
index 4e64fa1322..4e64fa1322 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js
index 3e25c36ef8..3e25c36ef8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js
index eb49a5b9bd..eb49a5b9bd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js
index fef61fd527..fef61fd527 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js
index 46920b7072..46920b7072 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js
index 6c671f1eea..6c671f1eea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js
index 98e3d61a0c..98e3d61a0c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js
index da9931e9ab..da9931e9ab 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js
index d51083c4cf..d51083c4cf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js
index 8b9789a929..8b9789a929 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js
index 62a8c45d92..62a8c45d92 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js
index ec5ba97576..ec5ba97576 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js
index bb367c9924..bb367c9924 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js
index 54ab39a9c9..54ab39a9c9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js
index a63bd84e8e..a63bd84e8e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js
index 551030db33..551030db33 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js
index 785e339080..785e339080 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js
index db5c403d3d..db5c403d3d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js
index 8f5d1129d5..8f5d1129d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js
index e58d087121..e58d087121 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js
index 283e323797..283e323797 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js
index 27aa7b1318..27aa7b1318 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js
index 7362613783..7362613783 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js
index caa50fe363..caa50fe363 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js
index 911b5d117a..911b5d117a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js
index 4e1d61d68a..4e1d61d68a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/README b/tests/auto/qml/parserstress/tests/ecma_2/README
index 6da6cdd514..6da6cdd514 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/README
+++ b/tests/auto/qml/parserstress/tests/ecma_2/README
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js
index f1dba13b06..f1dba13b06 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js
index 2d1bab472c..2d1bab472c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js
index 026f27d9d4..026f27d9d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js
index 8b219b935b..8b219b935b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js
index 3e85ac7abf..3e85ac7abf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js
index 102f91fcd4..102f91fcd4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js
index 1c520750ce..1c520750ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js
index b654e5e68a..b654e5e68a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js
index ee07ca602b..ee07ca602b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js
index 7d2913cc53..7d2913cc53 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js
index 1fcfd8d219..1fcfd8d219 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js
index c26a1216ea..c26a1216ea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js
index 219ce245ee..219ce245ee 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js
index 9b4657d963..9b4657d963 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js
index 79a3212a2e..79a3212a2e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js
index 8cfdc25dd6..8cfdc25dd6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js
index ca53dff899..ca53dff899 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js
index 598f655f8d..598f655f8d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js
index eb8e0c1b72..eb8e0c1b72 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js
index e4096f0d25..e4096f0d25 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js
index c8ad46f629..c8ad46f629 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js
index 5d148095d1..5d148095d1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js
index 0f20f6e953..0f20f6e953 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js
index 524bf38b9a..524bf38b9a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js
index 439410c9a6..439410c9a6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js
index 07bdeb6b81..07bdeb6b81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js
index 83b114d3f2..83b114d3f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js
index 7346f697a5..7346f697a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js
index 22ab0a7b60..22ab0a7b60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js
index 6cb5491beb..6cb5491beb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js
index 27ed593bfe..27ed593bfe 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js
index e7605222d6..e7605222d6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js
index c7b430dabe..c7b430dabe 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js
index 2c39aac243..2c39aac243 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js
index d41903de18..d41903de18 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js
index 0b9a055325..0b9a055325 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js
index 1cfbd28656..1cfbd28656 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js
index 566166755c..566166755c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js
index 016ab29a31..016ab29a31 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js
index d6ce368638..d6ce368638 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js
index 27e712c895..27e712c895 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js
index 79dfca2f03..79dfca2f03 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js
index 467efe7f02..467efe7f02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js
index c89e195497..c89e195497 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js
index 5fb734cce6..5fb734cce6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js
index c5e2472816..c5e2472816 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/String/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js
index de2275b5d6..de2275b5d6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js
index a57da2f77f..a57da2f77f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js
index cd3d80c919..cd3d80c919 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js
index 5c26de8b61..5c26de8b61 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js
index f0ae3cdbfa..f0ae3cdbfa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/String/shell.js
index 7d850446cc..7d850446cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js
index bbab3b0428..bbab3b0428 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js
index 9ae000790e..9ae000790e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js
index 5029fc98f9..5029fc98f9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/browser.js
index 4cde9b0629..4cde9b0629 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js
index cc7907d006..cc7907d006 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js
index 5153d25f9d..5153d25f9d 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js
index 8ea446a248..8ea446a248 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js
index 9cc837d8ef..9cc837d8ef 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js
index 7a763a895c..7a763a895c 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js
index 1662ae566b..1662ae566b 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js
index 1a9b1b3437..1a9b1b3437 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js
index 03c0f16fb9..03c0f16fb9 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js
index 3f52cffbc0..3f52cffbc0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js
index 39ae96fa5b..39ae96fa5b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js
index c35fcb0486..c35fcb0486 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js
index 6c1279f865..6c1279f865 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js
index c643920b04..c643920b04 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js
index b390356c38..b390356c38 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/jsref.js b/tests/auto/qml/parserstress/tests/ecma_2/jsref.js
index e5a3ddfeed..e5a3ddfeed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/jsref.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/jsref.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/shell.js
index a83dd68ec2..a83dd68ec2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/template.js b/tests/auto/qml/parserstress/tests/ecma_2/template.js
index 83397ba7b3..83397ba7b3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/template.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/template.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js
index 0436b8c1e0..0436b8c1e0 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js
index e3de6fb116..e3de6fb116 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js
index b87233ea97..b87233ea97 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.5.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js
index b55430b44e..b55430b44e 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.5.1-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-101488.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-101488.js
index 15a4556298..15a4556298 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-101488.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-101488.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-130451.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-130451.js
index a738bf6356..a738bf6356 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-130451.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-130451.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js
index 4e277e6da5..4e277e6da5 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js
index ee426a0cec..ee426a0cec 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-03.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js
index 95ee7f7a92..95ee7f7a92 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-03.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-04.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js
index fe9f8fc71e..fe9f8fc71e 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-04.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-387501.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js
index 36cf1478d2..36cf1478d2 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-387501.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-421325.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js
index c869d7bff4..c869d7bff4 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-421325.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-430717.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js
index f750ffb449..f750ffb449 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-430717.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/shell.js
index 9480d9e77d..9480d9e77d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.1.2-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js
index 61b1de6ef1..61b1de6ef1 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.1.2-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js
index d79b60b996..d79b60b996 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.3.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.4.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js
index b197dcb9c2..b197dcb9c2 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.3.js
index 6704f1fcad..6704f1fcad 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.4.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.4.js
index a2643bfe3c..a2643bfe3c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js
index e3b073e7ec..e3b073e7ec 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5.js
index 2b76fdcfc2..2b76fdcfc2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.6.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.6.js
index 004fbce2e0..004fbce2e0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.7.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.7.js
index 00d2541803..00d2541803 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/browser.js
index 4cde9b0629..4cde9b0629 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/shell.js
index 6111c3b934..6111c3b934 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js
index 6910d76f15..6910d76f15 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js
index 00f9503041..00f9503041 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js
index c6248cc7c1..c6248cc7c1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js
index a9da1c4e4e..a9da1c4e4e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js
index af45b2112d..af45b2112d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/binding-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/binding-001.js
index ea2dd6042f..ea2dd6042f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/binding-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/binding-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js
index 3fe80f15ac..3fe80f15ac 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js
index f4d1f224c8..f4d1f224c8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js
index 97212c88a0..97212c88a0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js
index b7ef074350..b7ef074350 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js
index 6c671f1eea..6c671f1eea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js
index 1e7e0254bf..1e7e0254bf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js
index b2e22e6c55..b2e22e6c55 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js
index 45a81f1f3a..45a81f1f3a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js
index 896841fa29..896841fa29 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js
index 6fbe85e19f..6fbe85e19f 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js
index 6283d886f0..6283d886f0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js
index f303199b51..f303199b51 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/shell.js
index 1d353cff74..1d353cff74 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js
index fd47d5d86b..fd47d5d86b 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js
index 8f387c1349..8f387c1349 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-03.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js
index 99af0f87c5..99af0f87c5 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-03.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.6.1-1.js
index 8854c499f2..8854c499f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.6.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.6.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js
index 05f9622ce2..05f9622ce2 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.1-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.2-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js
index 64e426888a..64e426888a 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.2-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js
index d5af3b86d4..d5af3b86d4 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js
index 1e8f59e400..1e8f59e400 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/shell.js
index 8f5d1129d5..8f5d1129d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001-n.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001-n.js
index 71ed2fbb08..71ed2fbb08 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001.js
index 366c5fd472..366c5fd472 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-002.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-002.js
index d602b01b09..d602b01b09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/shell.js
index ecf5f4798f..ecf5f4798f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.3-1.js
index ef51379e4f..ef51379e4f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.4-1.js
index d27b8487b7..d27b8487b7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-001.js
index 2dbd603e02..2dbd603e02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js
index 78005560a7..78005560a7 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/call-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/call-001.js
index 61ab3b930b..61ab3b930b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/call-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/call-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-131964.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-131964.js
index f3998db91c..f3998db91c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-131964.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-131964.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-137181.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-137181.js
index 1bf7c35f93..1bf7c35f93 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-137181.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-137181.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-193555.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-193555.js
index ed37b46c90..ed37b46c90 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-193555.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-193555.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-313570.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js
index e159c4c87f..e159c4c87f 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-313570.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-49286.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-49286.js
index 50e203bed8..50e203bed8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-49286.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-49286.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-58274.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-58274.js
index da5bde597f..da5bde597f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-58274.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-58274.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-85880.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-85880.js
index 8ea4fb6c41..8ea4fb6c41 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-85880.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-85880.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-94506.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-94506.js
index b6ab5cc24c..b6ab5cc24c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-94506.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-94506.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-97921.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-97921.js
index 855f966dc4..855f966dc4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-97921.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-97921.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/scope-001.js
index 3aa1d3bc03..3aa1d3bc03 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/scope-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/scope-002.js
index 7a9b6f204b..7a9b6f204b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/scope-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/shell.js
index eebf3d51f8..eebf3d51f8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js
index 10ee26f929..10ee26f929 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/shell.js
index 4e1d61d68a..4e1d61d68a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.2-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.2-01.js
index 36d63ed7e4..36d63ed7e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.2-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.2-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-01.js
index 7c4cba753d..7c4cba753d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-02.js
index 72e7c56141..72e7c56141 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.5-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.5-1.js
index c21efa0b66..c21efa0b66 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.6-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.6-1.js
index dec9ed6a90..dec9ed6a90 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-1.js
index 5aa0724a46..5aa0724a46 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-2.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-2.js
index 5c8ff396e4..5c8ff396e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/regress-442242-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js
index e3fa070e5a..e3fa070e5a 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/regress-442242-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/shell.js
index 03cca1d551..03cca1d551 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/shell.js
index 1847703bf3..1847703bf3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js
index 34152aa5c0..34152aa5c0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js
index 2897ece555..2897ece555 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.1-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js
index 8fe2b23f4a..8fe2b23f4a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js
index 0e57d1fcd0..0e57d1fcd0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js
index faa2f4fceb..faa2f4fceb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js
index 0b49ffd9db..0b49ffd9db 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js
index 7afedb2985..7afedb2985 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-004.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js
index 729b041086..729b041086 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-005.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js
index f57d0681cf..f57d0681cf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-361274.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js
index d3962004e3..d3962004e3 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-361274.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-385393-07.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js
index 0473fe4956..0473fe4956 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-385393-07.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-72773.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js
index 5b0dee62bf..5b0dee62bf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-72773.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-79129-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js
index efafed8047..efafed8047 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-79129-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js
index d0ee054485..d0ee054485 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-001.js
index 935eed2de1..935eed2de1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js
index 5d3307e4a7..5d3307e4a7 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-001.js
index 7a5ed8f915..7a5ed8f915 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js
index c48565ba5f..c48565ba5f 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/order-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js
index 671faceb81..671faceb81 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/order-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js
index 910515cfe4..910515cfe4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/README b/tests/auto/qml/parserstress/tests/ecma_3/README
index eebd421c2e..eebd421c2e 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/README
+++ b/tests/auto/qml/parserstress/tests/ecma_3/README
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js
index 9439a2ccd6..9439a2ccd6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js
index d68b86c2ed..d68b86c2ed 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js
index 7286cea297..7286cea297 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js
index d78be13c25..d78be13c25 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js
index 47faf0051b..47faf0051b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js
index 1d67b8afe6..1d67b8afe6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js
index 12ef46bde8..12ef46bde8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js
index 3b4245851e..3b4245851e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js
index 592fb03ac7..592fb03ac7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js
index 8203da4967..8203da4967 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js
index e6fd6c6311..e6fd6c6311 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js
index f35724e47b..f35724e47b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js
index 401ad43c11..401ad43c11 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js
index 0b27529a32..0b27529a32 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js
index a9b147b977..a9b147b977 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js
index 8c88aa7f52..8c88aa7f52 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js
index e691c518b4..e691c518b4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js
index 97f6414bc7..97f6414bc7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-122076.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-122076.js
index e77f433fc4..e77f433fc4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-122076.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-122076.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-123437.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-123437.js
index 745a3a707a..745a3a707a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-123437.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-123437.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-165353.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-165353.js
index f7c736ce4d..f7c736ce4d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-165353.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-165353.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169497.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169497.js
index 5613a93872..5613a93872 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169497.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169497.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js
index c736631bd7..c736631bd7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-187133.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-187133.js
index 98ec4753bf..98ec4753bf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-187133.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-187133.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-188206.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-188206.js
index 308c0ff605..308c0ff605 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-188206.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-188206.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-191479.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-191479.js
index 51d5f14c42..51d5f14c42 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-191479.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-191479.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-202564.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-202564.js
index e0ae0f9948..e0ae0f9948 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-202564.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-202564.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209067.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209067.js
index 98b4029ce4..98b4029ce4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209067.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209067.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209919.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209919.js
index 62c3cd86f0..62c3cd86f0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209919.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209919.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-216591.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-216591.js
index 455565ae36..455565ae36 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-216591.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-216591.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-220367-001.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-220367-001.js
index 59abc0c4b0..59abc0c4b0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-220367-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-220367-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223273.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223273.js
index 2858e85487..2858e85487 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223273.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223273.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223535.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223535.js
index 82305502fd..82305502fd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223535.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223535.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-224676.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-224676.js
index 88e89ee609..88e89ee609 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-224676.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-224676.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225289.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225289.js
index 6e05d12ead..6e05d12ead 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225289.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225289.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225343.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225343.js
index 25e248adaa..25e248adaa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225343.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225343.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-24712.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-24712.js
index c94472195f..c94472195f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-24712.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-24712.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-285219.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js
index 9d462359fa..9d462359fa 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-285219.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-28686.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-28686.js
index b3e355fa1c..b3e355fa1c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-28686.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-28686.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-289669.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js
index 2e3d044b74..2e3d044b74 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-289669.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-307456.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js
index dd2f540f6c..dd2f540f6c 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-307456.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js
index 8680b7bcfd..8680b7bcfd 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js
index a24a07bb2b..a24a07bb2b 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js
index a9b00d317c..a9b00d317c 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js
index 594913f07c..594913f07c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js
index b097fbc3d7..b097fbc3d7 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js
index 41ebf0a731..41ebf0a731 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js
index dfd53a9922..dfd53a9922 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js
index 923c1e5ab3..923c1e5ab3 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js
index 236eb00d28..236eb00d28 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js
index 6e7339f9e9..6e7339f9e9 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js
index 437dcbd5c5..437dcbd5c5 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js
index 3cd858e845..3cd858e845 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js
index ffc5c5a4cc..ffc5c5a4cc 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js
index 0c78a372ee..0c78a372ee 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js
index c7abd410bf..c7abd410bf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js
index dc222bfc0f..dc222bfc0f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js
index 4ee0d52854..4ee0d52854 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js
index 67a41e505c..67a41e505c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js
index 8792e379ca..8792e379ca 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js
index dd42ce060b..dd42ce060b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js
index bca1a15e19..bca1a15e19 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js
index b5467322eb..b5467322eb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js
index a2bfc2bf93..a2bfc2bf93 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/shell.js
index dbc733c376..dbc733c376 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-385393-04.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js
index 6e735fd1d2..6e735fd1d2 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-385393-04.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-419152.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js
index f57f3a4f98..f57f3a4f98 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-419152.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420087.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js
index 1f21d19739..1f21d19739 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420087.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420610.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js
index ecd5a2dd42..ecd5a2dd42 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420610.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-441477-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js
index 1be199743d..1be199743d 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-441477-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js
index 8c83369020..8c83369020 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js
index 97c3ca3136..97c3ca3136 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js
index 828cc5d8d5..828cc5d8d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-131348.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-131348.js
index 013e114178..013e114178 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-131348.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-131348.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-157509.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-157509.js
index 0b1319ebba..0b1319ebba 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-157509.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-157509.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-194364.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-194364.js
index a139f2b985..a139f2b985 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-194364.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-194364.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-226517.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-226517.js
index d99bfb503e..d99bfb503e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-226517.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-226517.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-302439.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js
index e1ebdb6e30..e1ebdb6e30 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-302439.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-324650.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js
index 003cd0fa42..003cd0fa42 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-324650.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-001.js
index 93dc425f72..93dc425f72 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-002.js
index 1c54849c48..1c54849c48 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-003.js
index 0bbe062ca9..0bbe062ca9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-001.js
index 8e2bb6b010..8e2bb6b010 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-002.js
index 3bd5ce8703..3bd5ce8703 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/shell.js
index 7346f697a5..7346f697a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/switch-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/switch-001.js
index aae6659cc1..aae6659cc1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/switch-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/switch-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.11.js b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js
index ef518bb9e5..ef518bb9e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.11.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js
index aa6c7354c2..aa6c7354c2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js
index c5593948d7..c5593948d7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-189898.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js
index c75c081513..c75c081513 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-189898.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-304376.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js
index 733cd713d8..733cd713d8 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-304376.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-313567.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js
index 9610238cc3..9610238cc3 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-313567.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-392378.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js
index 368fde1278..368fde1278 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-392378.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-83293.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js
index 55e74d4dd5..55e74d4dd5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-83293.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js
index 7d850446cc..7d850446cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js
index bb10ac6f7a..bb10ac6f7a 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js
index 0e3c4b0189..0e3c4b0189 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js
index 97a64fe83d..97a64fe83d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js
index 31a13f70e2..31a13f70e2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js
index 3fc0c8d927..3fc0c8d927 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js
index f1ae9a749d..f1ae9a749d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js
index d19b2c4786..d19b2c4786 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js
index 66c3f09860..66c3f09860 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js
index a54923c525..a54923c525 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js
index 3727042046..3727042046 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/browser.js
index 2339522cb6..2339522cb6 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js
index f941cb7800..f941cb7800 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/10.1.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/7.9.1.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js
index b69e9d065a..b69e9d065a 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/7.9.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-103087.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-103087.js
index 8cef9404e9..8cef9404e9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-103087.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-103087.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-01.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-01.js
index f09963a7b5..f09963a7b5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-02.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-02.js
index 3bd079fae6..3bd079fae6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-220367-002.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-220367-002.js
index 7af2a9d63f..7af2a9d63f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-220367-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-220367-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-228087.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-228087.js
index 6e16126cc0..6e16126cc0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-228087.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-228087.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-274152.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js
index d7074d9128..d7074d9128 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-274152.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-320854.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js
index 85e684882f..85e684882f 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-320854.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-327170.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js
index 5d15ce31a9..5d15ce31a9 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-327170.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-368516.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js
index a5f5fb769b..a5f5fb769b 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-368516.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-385393-03.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js
index 40c7e8dd81..40c7e8dd81 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-385393-03.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-429248.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js
index 9966269115..9966269115 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-429248.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-430740.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js
index 446adb95a6..446adb95a6 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-430740.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/shell.js
index d83e3591af..d83e3591af 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/shell.js
index ea63a51957..ea63a51957 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/template.js b/tests/auto/qml/parserstress/tests/ecma_3/template.js
index 4dedd5a0e3..4dedd5a0e3 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/template.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/template.js
diff --git a/tests/auto/declarative/parserstress/tests/shell.js b/tests/auto/qml/parserstress/tests/shell.js
index 40af0f3799..40af0f3799 100644
--- a/tests/auto/declarative/parserstress/tests/shell.js
+++ b/tests/auto/qml/parserstress/tests/shell.js
diff --git a/tests/auto/qml/parserstress/tst_parserstress.cpp b/tests/auto/qml/parserstress/tst_parserstress.cpp
new file mode 100644
index 0000000000..c7f4840a11
--- /dev/null
+++ b/tests/auto/qml/parserstress/tst_parserstress.cpp
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+#include <QDir>
+#include <QFile>
+
+class tst_parserstress : public QObject
+{
+ Q_OBJECT
+public:
+ tst_parserstress() {}
+
+private slots:
+ void ecmascript_data();
+ void ecmascript();
+
+private:
+ static QStringList findJSFiles(const QDir &);
+ QQmlEngine engine;
+};
+
+QStringList tst_parserstress::findJSFiles(const QDir &d)
+{
+ QStringList rv;
+
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.js"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ if (file == "browser.js")
+ continue;
+ rv << d.absoluteFilePath(file);
+ }
+
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ rv << findJSFiles(sub);
+ }
+
+ return rv;
+}
+
+void tst_parserstress::ecmascript_data()
+{
+#ifdef TESTDATADIR
+ QDir dir(TESTDATADIR);
+ QStringList files = findJSFiles(dir);
+
+ QTest::addColumn<QString>("file");
+ foreach (const QString &file, files) {
+ QTest::newRow(qPrintable(file)) << file;
+ }
+#endif
+}
+
+void tst_parserstress::ecmascript()
+{
+ QFETCH(QString, file);
+
+ QFile f(file);
+ QVERIFY(f.open(QIODevice::ReadOnly));
+
+ QByteArray data = f.readAll();
+
+ QVERIFY(!data.isEmpty());
+
+ QString dataStr = QString::fromUtf8(data);
+
+ QString qml = "import QtQuick 2.0\n";
+ qml+= "\n";
+ qml+= "QtObject {\n";
+ qml+= " property int test\n";
+ qml+= " test: {\n";
+ qml+= dataStr + "\n";
+ qml+= " return 1;\n";
+ qml+= " }\n";
+ qml+= " function stress() {\n";
+ qml+= dataStr;
+ qml+= " }\n";
+ qml+= "}\n";
+
+ QByteArray qmlData = qml.toUtf8();
+
+ QQmlComponent component(&engine);
+
+ component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml")));
+
+ QFileInfo info(file);
+
+ if (info.fileName() == QLatin1String("regress-352044-02-n.js")) {
+ QVERIFY(component.isError());
+
+ QCOMPARE(component.errors().length(), 2);
+
+ QCOMPARE(component.errors().at(0).description(), QString("Expected token `;'"));
+ QCOMPARE(component.errors().at(0).line(), 66);
+
+ QCOMPARE(component.errors().at(1).description(), QString("Expected token `;'"));
+ QCOMPARE(component.errors().at(1).line(), 142);
+
+ } else {
+
+ QVERIFY(!component.isError());
+ }
+}
+
+
+QTEST_MAIN(tst_parserstress)
+
+#include "tst_parserstress.moc"
diff --git a/tests/auto/qml/qjsengine/qjsengine.pro b/tests/auto/qml/qjsengine/qjsengine.pro
new file mode 100644
index 0000000000..3451157dbb
--- /dev/null
+++ b/tests/auto/qml/qjsengine/qjsengine.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TARGET = tst_qjsengine
+QT += qml widgets testlib
+macx:CONFIG -= app_bundle
+SOURCES += tst_qjsengine.cpp
+wince* {
+ addFiles.files = script
+ addFiles.path = .
+ DEPLOYMENT += addFiles
+ DEFINES += SRCDIR=\\\"./\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
diff --git a/tests/auto/declarative/qjsengine/script/com/__init__.js b/tests/auto/qml/qjsengine/script/com/__init__.js
index 7db3ee4cac..7db3ee4cac 100644
--- a/tests/auto/declarative/qjsengine/script/com/__init__.js
+++ b/tests/auto/qml/qjsengine/script/com/__init__.js
diff --git a/tests/auto/declarative/qjsengine/script/com/trolltech/__init__.js b/tests/auto/qml/qjsengine/script/com/trolltech/__init__.js
index a55b1328ba..a55b1328ba 100644
--- a/tests/auto/declarative/qjsengine/script/com/trolltech/__init__.js
+++ b/tests/auto/qml/qjsengine/script/com/trolltech/__init__.js
diff --git a/tests/auto/declarative/qjsengine/script/com/trolltech/recursive/__init__.js b/tests/auto/qml/qjsengine/script/com/trolltech/recursive/__init__.js
index 2f4cad48da..2f4cad48da 100644
--- a/tests/auto/declarative/qjsengine/script/com/trolltech/recursive/__init__.js
+++ b/tests/auto/qml/qjsengine/script/com/trolltech/recursive/__init__.js
diff --git a/tests/auto/declarative/qjsengine/script/com/trolltech/syntaxerror/__init__.js b/tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js
index 55bc35b5f2..55bc35b5f2 100644
--- a/tests/auto/declarative/qjsengine/script/com/trolltech/syntaxerror/__init__.js
+++ b/tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js
diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 66fef8e2dd..66fef8e2dd 100644
--- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
diff --git a/tests/auto/qml/qjsvalue/qjsvalue.pro b/tests/auto/qml/qjsvalue/qjsvalue.pro
new file mode 100644
index 0000000000..19b983e549
--- /dev/null
+++ b/tests/auto/qml/qjsvalue/qjsvalue.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qjsvalue
+macx:CONFIG -= app_bundle
+QT += qml widgets testlib
+SOURCES += tst_qjsvalue.cpp
+HEADERS += tst_qjsvalue.h
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index cec10ccf38..cec10ccf38 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
index 0e7f7405a6..0e7f7405a6 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
diff --git a/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro b/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro
new file mode 100644
index 0000000000..4ee1693ad8
--- /dev/null
+++ b/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qjsvalueiterator
+macx:CONFIG -= app_bundle
+QT = core qml testlib
+SOURCES += tst_qjsvalueiterator.cpp
+
+
diff --git a/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
index eade3de1a7..eade3de1a7 100644
--- a/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp
+++ b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
new file mode 100644
index 0000000000..bcfbcbdbf0
--- /dev/null
+++ b/tests/auto/qml/qml.pro
@@ -0,0 +1,56 @@
+TEMPLATE = subdirs
+
+METATYPETESTS += \
+ qqmlmetatype
+
+PUBLICTESTS += \
+ parserstress \
+ qjsengine \
+ qjsvalue \
+ qjsvalueiterator \
+ qmlmin \
+ qmlplugindump \
+ qqmlcomponent \
+ qqmlconsole \
+ qqmlcontext \
+ qqmlengine \
+ qqmlerror \
+ qqmlincubator \
+ qqmlinfo \
+ qqmllistreference \
+ qqmllocale \
+ qqmlmetaobject \
+ qqmlmoduleplugin \
+ qqmlqt \
+ qqmltranslation \
+ qqmlxmlhttprequest \
+ qqmlparser \
+ qquickfolderlistmodel
+
+PRIVATETESTS += \
+ animation \
+ qqmlcpputils \
+ qqmlecmascript \
+ qqmlexpression \
+ qqmlimageprovider \
+ qqmlinstruction \
+ qqmllanguage \
+ qqmlproperty \
+ qqmlpropertymap \
+ qqmlsqldatabase \
+ qqmlvaluetypes \
+ qquickbinding \
+ qquickchangeset \
+ qquickconnection \
+ qquicklistcompositor \
+ qquicklistmodel \
+ qquickworkerscript \
+ v4
+
+SUBDIRS += $$PUBLICTESTS
+SUBDIRS += $$METATYPETESTS
+SUBDIRS += debugger
+
+contains(QT_CONFIG, private_tests) {
+ SUBDIRS += $$PRIVATETESTS
+}
diff --git a/tests/auto/qml/qmlmin/qmlmin.pro b/tests/auto/qml/qmlmin/qmlmin.pro
new file mode 100644
index 0000000000..49a4e7ff58
--- /dev/null
+++ b/tests/auto/qml/qmlmin/qmlmin.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qmlmin
+QT += qml testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qmlmin.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
new file mode 100644
index 0000000000..dfc88fb78c
--- /dev/null
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLibraryInfo>
+#include <QDir>
+#include <QProcess>
+#include <QDebug>
+#include <QQmlError>
+#include <cstdlib>
+
+class tst_qmlmin : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qmlmin();
+
+private slots:
+ void initTestCase();
+ void qmlMinify_data();
+ void qmlMinify();
+
+private:
+ QString qmlminPath;
+ QStringList excludedDirs;
+ QStringList invalidFiles;
+
+ QStringList findFiles(const QDir &);
+ bool isInvalidFile(const QFileInfo &fileName) const;
+};
+
+tst_qmlmin::tst_qmlmin()
+{
+}
+
+void tst_qmlmin::initTestCase()
+{
+ qmlminPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmlmin");
+#ifdef Q_OS_WIN
+ qmlminPath += QLatin1String(".exe");
+#endif
+ if (!QFileInfo(qmlminPath).exists()) {
+ QString message = QString::fromLatin1("qmlmin executable not found (looked for %0)")
+ .arg(qmlminPath);
+ QFAIL(qPrintable(message));
+ }
+
+ // Add directories you want excluded here
+
+ // These snippets are not expected to run on their own.
+ excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qml/qtbinding";
+ excludedDirs << "doc/src/snippets/qml/imports";
+ excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
+ excludedDirs << "doc/src/snippets/qtquick1/imports";
+
+ // Add invalid files (i.e. files with syntax errors)
+ invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.5.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/property.4.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/empty.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/missingObject.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml";
+ invalidFiles << "tests/auto/qml/qquickfolderlistmodel/data/dummy.qml";
+ invalidFiles << "tests/auto/qml/qqmlecmascript/data/qtbug_22843.js";
+ invalidFiles << "tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js";
+ invalidFiles << "tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js";
+ invalidFiles << "tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js";
+}
+
+QStringList tst_qmlmin::findFiles(const QDir &d)
+{
+ for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ QString s = excludedDirs.at(ii);
+ if (d.absolutePath().endsWith(s))
+ return QStringList();
+ }
+
+ QStringList rv;
+
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ rv << d.absoluteFilePath(file);
+ }
+
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ rv << findFiles(sub);
+ }
+
+ return rv;
+}
+
+bool tst_qmlmin::isInvalidFile(const QFileInfo &fileName) const
+{
+ foreach (const QString &invalidFile, invalidFiles) {
+ if (fileName.absoluteFilePath().endsWith(invalidFile))
+ return true;
+ }
+ return false;
+}
+
+/*
+This test runs all the examples in the QtQml UI source tree and ensures
+that they start and exit cleanly.
+
+Examples are any .qml files under the examples/ directory that start
+with a lower case letter.
+*/
+
+void tst_qmlmin::qmlMinify_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
+ QString tests = QLatin1String(SRCDIR) + "/../../../../tests/";
+
+ QStringList files;
+ files << findFiles(QDir(examples));
+ files << findFiles(QDir(tests));
+
+ foreach (const QString &file, files)
+ QTest::newRow(qPrintable(file)) << file;
+}
+
+void tst_qmlmin::qmlMinify()
+{
+ QFETCH(QString, file);
+
+ QProcess qmlminify;
+ qmlminify.start(qmlminPath, QStringList() << QLatin1String("--verify-only") << file);
+ qmlminify.waitForFinished();
+
+ QCOMPARE(qmlminify.error(), QProcess::UnknownError);
+ QCOMPARE(qmlminify.exitStatus(), QProcess::NormalExit);
+
+ if (isInvalidFile(file))
+ QCOMPARE(qmlminify.exitCode(), EXIT_FAILURE); // cannot minify files with syntax errors
+ else
+ QCOMPARE(qmlminify.exitCode(), 0);
+}
+
+QTEST_MAIN(tst_qmlmin)
+
+#include "tst_qmlmin.moc"
diff --git a/tests/auto/declarative/qmlplugindump/qmlplugindump.pro b/tests/auto/qml/qmlplugindump/qmlplugindump.pro
index 498a520873..498a520873 100644
--- a/tests/auto/declarative/qmlplugindump/qmlplugindump.pro
+++ b/tests/auto/qml/qmlplugindump/qmlplugindump.pro
diff --git a/tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
index 5512cfdfe8..5512cfdfe8 100644
--- a/tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp
+++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml b/tests/auto/qml/qqmlcomponent/data/createObject.qml
index da5db8e8e6..da5db8e8e6 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml
+++ b/tests/auto/qml/qqmlcomponent/data/createObject.qml
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
index 122c6a87c8..122c6a87c8 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml
+++ b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml
index daa5d3c167..daa5d3c167 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml
+++ b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/incubateObject.qml b/tests/auto/qml/qqmlcomponent/data/incubateObject.qml
index c11319db30..c11319db30 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/incubateObject.qml
+++ b/tests/auto/qml/qqmlcomponent/data/incubateObject.qml
diff --git a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro
new file mode 100644
index 0000000000..7cef181a4a
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlcomponent
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlcomponent.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
new file mode 100644
index 0000000000..603c091a03
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QDebug>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlproperty.h>
+#include <QtQml/qqmlincubator.h>
+#include <qcolor.h>
+#include "../../shared/util.h"
+
+class MyIC : public QObject, public QQmlIncubationController
+{
+ Q_OBJECT
+public:
+ MyIC() { startTimer(5); }
+protected:
+ virtual void timerEvent(QTimerEvent*) {
+ incubateFor(5);
+ }
+};
+
+class tst_qqmlcomponent : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlcomponent() { engine.setIncubationController(&ic); }
+
+private slots:
+ void null();
+ void loadEmptyUrl();
+ void qmlCreateObject();
+ void qmlCreateObjectWithProperties();
+ void qmlIncubateObject();
+ void qmlCreateParentReference();
+
+private:
+ QQmlEngine engine;
+ MyIC ic;
+};
+
+void tst_qqmlcomponent::null()
+{
+ {
+ QQmlComponent c;
+ QVERIFY(c.isNull());
+ }
+
+ {
+ QQmlComponent c(&engine);
+ QVERIFY(c.isNull());
+ }
+}
+
+
+void tst_qqmlcomponent::loadEmptyUrl()
+{
+ QQmlComponent c(&engine);
+ c.loadUrl(QUrl());
+
+ QVERIFY(c.isError());
+ QCOMPARE(c.errors().count(), 1);
+ QQmlError error = c.errors().first();
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), -1);
+ QCOMPARE(error.column(), -1);
+ QCOMPARE(error.description(), QLatin1String("Invalid empty URL"));
+}
+
+void tst_qqmlcomponent::qmlIncubateObject()
+{
+ QQmlComponent component(&engine, testFileUrl("incubateObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), false);
+
+ QTRY_VERIFY(object->property("test2").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlcomponent::qmlCreateObject()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("createObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *testObject1 = object->property("qobject").value<QObject*>();
+ QVERIFY(testObject1);
+ QVERIFY(testObject1->parent() == object);
+
+ QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
+ QVERIFY(testObject2);
+ QVERIFY(testObject2->parent() == object);
+ QCOMPARE(testObject2->metaObject()->className(), "QQuickItem");
+}
+
+void tst_qqmlcomponent::qmlCreateObjectWithProperties()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("createObjectWithScript.qml"));
+ QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *testObject1 = object->property("declarativerectangle").value<QObject*>();
+ QVERIFY(testObject1);
+ QVERIFY(testObject1->parent() == object);
+ QCOMPARE(testObject1->property("x").value<int>(), 17);
+ QCOMPARE(testObject1->property("y").value<int>(), 17);
+ QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255));
+ QCOMPARE(QQmlProperty::read(testObject1,"border.width").toInt(), 3);
+ QCOMPARE(QQmlProperty::read(testObject1,"innerRect.border.width").toInt(), 20);
+ delete testObject1;
+
+ QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
+ QVERIFY(testObject2);
+ QVERIFY(testObject2->parent() == object);
+ //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2");
+ QCOMPARE(testObject2->property("x").value<int>(), 17);
+ QCOMPARE(testObject2->property("y").value<int>(), 17);
+ QCOMPARE(testObject2->property("testBool").value<bool>(), true);
+ QCOMPARE(testObject2->property("testInt").value<int>(), 17);
+ QCOMPARE(testObject2->property("testObject").value<QObject*>(), object);
+ delete testObject2;
+
+ QObject *testBindingObj = object->property("bindingTestObject").value<QObject*>();
+ QVERIFY(testBindingObj);
+ QCOMPARE(testBindingObj->parent(), object);
+ QCOMPARE(testBindingObj->property("testValue").value<int>(), 300);
+ object->setProperty("width", 150);
+ QCOMPARE(testBindingObj->property("testValue").value<int>(), 150 * 3);
+ delete testBindingObj;
+
+ QObject *testBindingThisObj = object->property("bindingThisTestObject").value<QObject*>();
+ QVERIFY(testBindingThisObj);
+ QCOMPARE(testBindingThisObj->parent(), object);
+ QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 900);
+ testBindingThisObj->setProperty("width", 200);
+ QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 200 * 3);
+ delete testBindingThisObj;
+}
+
+static QStringList warnings;
+static void msgHandler(QtMsgType, const char *warning)
+{
+ warnings << QString::fromUtf8(warning);
+}
+
+void tst_qqmlcomponent::qmlCreateParentReference()
+{
+ QQmlEngine engine;
+
+ QCOMPARE(engine.outputWarningsToStandardError(), true);
+
+ warnings.clear();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+
+ QQmlComponent component(&engine, testFileUrl("createParentReference.qml"));
+ QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(object, "createChild"));
+ delete object;
+
+ qInstallMsgHandler(old);
+
+ engine.setOutputWarningsToStandardError(false);
+ QCOMPARE(engine.outputWarningsToStandardError(), false);
+
+ QCOMPARE(warnings.count(), 0);
+}
+
+QTEST_MAIN(tst_qqmlcomponent)
+
+#include "tst_qqmlcomponent.moc"
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/assert.qml b/tests/auto/qml/qqmlconsole/data/assert.qml
index 43ca893809..43ca893809 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/assert.qml
+++ b/tests/auto/qml/qqmlconsole/data/assert.qml
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/exception.qml b/tests/auto/qml/qqmlconsole/data/exception.qml
index 1cda37a9f4..1cda37a9f4 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/exception.qml
+++ b/tests/auto/qml/qqmlconsole/data/exception.qml
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/logging.qml b/tests/auto/qml/qqmlconsole/data/logging.qml
index 44009b5db9..44009b5db9 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/logging.qml
+++ b/tests/auto/qml/qqmlconsole/data/logging.qml
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/profiling.qml b/tests/auto/qml/qqmlconsole/data/profiling.qml
index 9a0ca354a5..9a0ca354a5 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/profiling.qml
+++ b/tests/auto/qml/qqmlconsole/data/profiling.qml
diff --git a/tests/auto/qml/qqmlconsole/data/tracing.qml b/tests/auto/qml/qqmlconsole/data/tracing.qml
new file mode 100644
index 0000000000..9586829f8f
--- /dev/null
+++ b/tests/auto/qml/qqmlconsole/data/tracing.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+// moving lines in here requires fixing tst_qqmlconsole.cpp
+QtObject {
+ id: root
+
+ function tracing()
+ {
+ console.trace();
+ }
+
+ Component.onCompleted: {
+ tracing();
+ }
+}
diff --git a/tests/auto/qml/qqmlconsole/qqmlconsole.pro b/tests/auto/qml/qqmlconsole/qqmlconsole.pro
new file mode 100644
index 0000000000..9ae23316a1
--- /dev/null
+++ b/tests/auto/qml/qqmlconsole/qqmlconsole.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlconsole
+SOURCES += tst_qqmlconsole.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += qml testlib
diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
new file mode 100644
index 0000000000..d96da678e2
--- /dev/null
+++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QDebug>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include "../../shared/util.h"
+
+class tst_qqmlconsole : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlconsole() {}
+
+private slots:
+ void logging();
+ void tracing();
+ void profiling();
+ void assert();
+ void exception();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlconsole::logging()
+{
+ QUrl testUrl = testFileUrl("logging.qml");
+
+ QTest::ignoreMessage(QtDebugMsg, "console.debug");
+ QTest::ignoreMessage(QtDebugMsg, "console.log");
+ QTest::ignoreMessage(QtDebugMsg, "console.info");
+ QTest::ignoreMessage(QtWarningMsg, "console.warn");
+ QTest::ignoreMessage(QtCriticalMsg, "console.error");
+
+ QTest::ignoreMessage(QtDebugMsg, "console.count: 1");
+ QTest::ignoreMessage(QtDebugMsg, ": 1");
+ QTest::ignoreMessage(QtDebugMsg, "console.count: 2");
+ QTest::ignoreMessage(QtDebugMsg, ": 2");
+
+ QTest::ignoreMessage(QtDebugMsg, "[1,2]");
+ QTest::ignoreMessage(QtDebugMsg, "Object");
+ QTest::ignoreMessage(QtDebugMsg, "undefined");
+ QTest::ignoreMessage(QtDebugMsg, "12");
+ QTest::ignoreMessage(QtDebugMsg, "function () { return 5;}");
+ QTest::ignoreMessage(QtDebugMsg, "true");
+ QTest::ignoreMessage(QtDebugMsg, "Object");
+ QTest::ignoreMessage(QtDebugMsg, "Object");
+ QTest::ignoreMessage(QtDebugMsg, "1 pong! Object");
+ QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] Object 2");
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlconsole::tracing()
+{
+ QUrl testUrl = testFileUrl("tracing.qml");
+
+ QString traceText =
+ QString::fromLatin1("tracing (%1:%2:%3)\n").arg(testUrl.toString()).arg(50).arg(17) +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(9);
+
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(traceText));
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlconsole::profiling()
+{
+ QUrl testUrl = testFileUrl("profiling.qml");
+
+ // profiling()
+ QTest::ignoreMessage(QtDebugMsg, "Profiling started.");
+ QTest::ignoreMessage(QtDebugMsg, "Profiling ended.");
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlconsole::assert()
+{
+ QUrl testUrl = testFileUrl("assert.qml");
+
+ // assert()
+ QString assert1 = "This will fail\n" +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(17);
+
+ QString assert2 = "This will fail too\n" +
+ QString::fromLatin1("assertFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(47).arg(17) +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(59).arg(9);
+
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert1));
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert2));
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlconsole::exception()
+{
+ QUrl testUrl = testFileUrl("exception.qml");
+
+ // exception()
+ QString exception1 = "Exception 1\n" +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(51).arg(21);
+
+ QString exception2 = "Exception 2\n" +
+ QString::fromLatin1("exceptionFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(46).arg(17) +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(56).arg(9);
+
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception1));
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception2));
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmlconsole)
+
+#include "tst_qqmlconsole.moc"
diff --git a/tests/auto/declarative/qdeclarativecontext/data/Object_22535.qml b/tests/auto/qml/qqmlcontext/data/Object_22535.qml
index 294c744317..294c744317 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/Object_22535.qml
+++ b/tests/auto/qml/qqmlcontext/data/Object_22535.qml
diff --git a/tests/auto/declarative/qdeclarativecontext/data/RefreshExpressionsType.qml b/tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml
index b7c3427c85..b7c3427c85 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/RefreshExpressionsType.qml
+++ b/tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml
diff --git a/tests/auto/declarative/qdeclarativecontext/data/qtbug_22535.qml b/tests/auto/qml/qqmlcontext/data/qtbug_22535.qml
index 3553f6c03b..3553f6c03b 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/qtbug_22535.qml
+++ b/tests/auto/qml/qqmlcontext/data/qtbug_22535.qml
diff --git a/tests/auto/declarative/qdeclarativecontext/data/refreshExpressions.qml b/tests/auto/qml/qqmlcontext/data/refreshExpressions.qml
index 01e503f8dc..01e503f8dc 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/refreshExpressions.qml
+++ b/tests/auto/qml/qqmlcontext/data/refreshExpressions.qml
diff --git a/tests/auto/declarative/qdeclarativecontext/data/refreshExpressionsRootContext.qml b/tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml
index bd82cd9552..bd82cd9552 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/refreshExpressionsRootContext.qml
+++ b/tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml
diff --git a/tests/auto/qml/qqmlcontext/qqmlcontext.pro b/tests/auto/qml/qqmlcontext/qqmlcontext.pro
new file mode 100644
index 0000000000..9920766d61
--- /dev/null
+++ b/tests/auto/qml/qqmlcontext/qqmlcontext.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlcontext
+SOURCES += tst_qqmlcontext.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib v8-private
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
new file mode 100644
index 0000000000..6125362365
--- /dev/null
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -0,0 +1,652 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QQmlComponent>
+#include <QQmlExpression>
+#include <private/qqmlcontext_p.h>
+#include "../../shared/util.h"
+
+class tst_qqmlcontext : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlcontext() {}
+
+private slots:
+ void baseUrl();
+ void resolvedUrl();
+ void engineMethod();
+ void parentContext();
+ void setContextProperty();
+ void setContextObject();
+ void destruction();
+ void idAsContextProperty();
+ void readOnlyContexts();
+ void nameForObject();
+
+ void refreshExpressions();
+ void refreshExpressionsCrash();
+ void refreshExpressionsRootContext();
+
+ void qtbug_22535();
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlcontext::baseUrl()
+{
+ QQmlContext ctxt(&engine);
+
+ QCOMPARE(ctxt.baseUrl(), QUrl());
+
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QCOMPARE(ctxt.baseUrl(), QUrl("http://www.nokia.com/"));
+}
+
+void tst_qqmlcontext::resolvedUrl()
+{
+ // Relative to the component
+ {
+ QQmlContext ctxt(&engine);
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), QUrl("http://www.nokia.com/main.qml"));
+ }
+
+ // Relative to a parent
+ {
+ QQmlContext ctxt(&engine);
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QQmlContext ctxt2(&ctxt);
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+ }
+
+ // Relative to the engine
+ {
+ QQmlContext ctxt(&engine);
+ QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), engine.baseUrl().resolved(QUrl("main.qml")));
+ }
+
+ // Relative to a deleted parent
+ {
+ QQmlContext *ctxt = new QQmlContext(&engine);
+ ctxt->setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QQmlContext ctxt2(ctxt);
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+
+ delete ctxt; ctxt = 0;
+
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl());
+ }
+
+ // Absolute
+ {
+ QQmlContext ctxt(&engine);
+
+ QCOMPARE(ctxt.resolvedUrl(QUrl("http://www.nokia.com/main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+ QCOMPARE(ctxt.resolvedUrl(QUrl("file:///main2.qml")), QUrl("file:///main2.qml"));
+ }
+}
+
+void tst_qqmlcontext::engineMethod()
+{
+ QQmlEngine *engine = new QQmlEngine;
+
+ QQmlContext ctxt(engine);
+ QQmlContext ctxt2(&ctxt);
+ QQmlContext ctxt3(&ctxt2);
+ QQmlContext ctxt4(&ctxt2);
+
+ QCOMPARE(ctxt.engine(), engine);
+ QCOMPARE(ctxt2.engine(), engine);
+ QCOMPARE(ctxt3.engine(), engine);
+ QCOMPARE(ctxt4.engine(), engine);
+
+ delete engine; engine = 0;
+
+ QCOMPARE(ctxt.engine(), engine);
+ QCOMPARE(ctxt2.engine(), engine);
+ QCOMPARE(ctxt3.engine(), engine);
+ QCOMPARE(ctxt4.engine(), engine);
+}
+
+void tst_qqmlcontext::parentContext()
+{
+ QQmlEngine *engine = new QQmlEngine;
+
+ QCOMPARE(engine->rootContext()->parentContext(), (QQmlContext *)0);
+
+ QQmlContext *ctxt = new QQmlContext(engine);
+ QQmlContext *ctxt2 = new QQmlContext(ctxt);
+ QQmlContext *ctxt3 = new QQmlContext(ctxt2);
+ QQmlContext *ctxt4 = new QQmlContext(ctxt2);
+ QQmlContext *ctxt5 = new QQmlContext(ctxt);
+ QQmlContext *ctxt6 = new QQmlContext(engine);
+ QQmlContext *ctxt7 = new QQmlContext(engine->rootContext());
+
+ QCOMPARE(ctxt->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt2->parentContext(), ctxt);
+ QCOMPARE(ctxt3->parentContext(), ctxt2);
+ QCOMPARE(ctxt4->parentContext(), ctxt2);
+ QCOMPARE(ctxt5->parentContext(), ctxt);
+ QCOMPARE(ctxt6->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt7->parentContext(), engine->rootContext());
+
+ delete ctxt2; ctxt2 = 0;
+
+ QCOMPARE(ctxt->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt3->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt4->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt5->parentContext(), ctxt);
+ QCOMPARE(ctxt6->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt7->parentContext(), engine->rootContext());
+
+ delete engine; engine = 0;
+
+ QCOMPARE(ctxt->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt3->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt4->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt5->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt6->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt7->parentContext(), (QQmlContext *)0);
+
+ delete ctxt7;
+ delete ctxt6;
+ delete ctxt5;
+ delete ctxt4;
+ delete ctxt3;
+ delete ctxt;
+}
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int a READ a NOTIFY aChanged)
+ Q_PROPERTY(int b READ b NOTIFY bChanged)
+ Q_PROPERTY(int c READ c NOTIFY cChanged)
+
+public:
+ TestObject() : _a(10), _b(10), _c(10) {}
+
+ int a() const { return _a; }
+ void setA(int a) { _a = a; emit aChanged(); }
+
+ int b() const { return _b; }
+ void setB(int b) { _b = b; emit bChanged(); }
+
+ int c() const { return _c; }
+ void setC(int c) { _c = c; emit cChanged(); }
+
+signals:
+ void aChanged();
+ void bChanged();
+ void cChanged();
+
+private:
+ int _a;
+ int _b;
+ int _c;
+};
+
+#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
+{ \
+ QQmlComponent component(&engine); \
+ component.setData("import QtQuick 2.0; QtObject { property variant test: " #name " }", QUrl()); \
+\
+ QObject *obj = component.create(ctxt); \
+\
+ QCOMPARE(obj->property("test"), value); \
+\
+ delete obj; \
+}
+
+void tst_qqmlcontext::setContextProperty()
+{
+ QQmlContext ctxt(&engine);
+ QQmlContext ctxt2(&ctxt);
+
+ TestObject obj1;
+ obj1.setA(3345);
+ TestObject obj2;
+ obj2.setA(-19);
+
+ // Static context properties
+ ctxt.setContextProperty("a", QVariant(10));
+ ctxt.setContextProperty("b", QVariant(9));
+ ctxt2.setContextProperty("d", &obj2);
+ ctxt2.setContextProperty("b", QVariant(19));
+ ctxt2.setContextProperty("c", QVariant(QString("Hello World!")));
+ ctxt.setContextProperty("d", &obj1);
+ ctxt.setContextProperty("e", &obj1);
+
+ TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(10));
+ TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(19));
+ TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hello World!")));
+ TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(-19));
+ TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(3345));
+
+ ctxt.setContextProperty("a", QVariant(13));
+ ctxt.setContextProperty("b", QVariant(4));
+ ctxt2.setContextProperty("b", QVariant(8));
+ ctxt2.setContextProperty("c", QVariant(QString("Hi World!")));
+ ctxt2.setContextProperty("d", &obj1);
+ obj1.setA(12);
+
+ TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(13));
+ TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(8));
+ TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hi World!")));
+ TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(12));
+ TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(12));
+
+ // Changes in context properties
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(13));
+ ctxt.setContextProperty("a", QVariant(19));
+ QCOMPARE(obj->property("test"), QVariant(19));
+
+ delete obj;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: b }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(8));
+ ctxt.setContextProperty("b", QVariant(5));
+ QCOMPARE(obj->property("test"), QVariant(8));
+ ctxt2.setContextProperty("b", QVariant(1912));
+ QCOMPARE(obj->property("test"), QVariant(1912));
+
+ delete obj;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: e.a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(12));
+ obj1.setA(13);
+ QCOMPARE(obj->property("test"), QVariant(13));
+
+ delete obj;
+ }
+
+ // New context properties
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(19));
+ ctxt2.setContextProperty("a", QVariant(1945));
+ QCOMPARE(obj->property("test"), QVariant(1945));
+
+ delete obj;
+ }
+
+ // Setting an object-variant context property
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property variant obj: root; }", QUrl());
+
+ QQmlContext ctxt(engine.rootContext());
+ ctxt.setContextProperty("ctxtProp", QVariant());
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Cannot read property 'a' of undefined");
+ QObject *obj = component.create(&ctxt);
+
+ QVariant v = obj->property("obj");
+
+ ctxt.setContextProperty("ctxtProp", v);
+
+ QCOMPARE(obj->property("test"), QVariant(10));
+
+ delete obj;
+ }
+}
+
+void tst_qqmlcontext::setContextObject()
+{
+ QQmlContext ctxt(&engine);
+
+ TestObject to;
+
+ to.setA(2);
+ to.setB(192);
+ to.setC(18);
+
+ ctxt.setContextObject(&to);
+ ctxt.setContextProperty("c", QVariant(9));
+
+ // Static context properties
+ TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2));
+ TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(192));
+ TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9));
+
+ to.setA(12);
+ to.setB(100);
+ to.setC(7);
+ ctxt.setContextProperty("c", QVariant(3));
+
+ TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12));
+ TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(100));
+ TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3));
+
+ // Changes in context properties
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt);
+
+ QCOMPARE(obj->property("test"), QVariant(12));
+ to.setA(14);
+ QCOMPARE(obj->property("test"), QVariant(14));
+
+ delete obj;
+ }
+}
+
+void tst_qqmlcontext::destruction()
+{
+ QQmlContext *ctxt = new QQmlContext(&engine);
+
+ QObject obj;
+ QQmlEngine::setContextForObject(&obj, ctxt);
+ QQmlExpression expr(ctxt, 0, "a");
+
+ QCOMPARE(ctxt, QQmlEngine::contextForObject(&obj));
+ QCOMPARE(ctxt, expr.context());
+
+ delete ctxt; ctxt = 0;
+
+ QCOMPARE(ctxt, QQmlEngine::contextForObject(&obj));
+ QCOMPARE(ctxt, expr.context());
+}
+
+void tst_qqmlcontext::idAsContextProperty()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant a; a: QtObject { id: myObject } }", QUrl());
+
+ QObject *obj = component.create();
+ QVERIFY(obj);
+
+ QVariant a = obj->property("a");
+ QVERIFY(a.userType() == QMetaType::QObjectStar);
+
+ QVariant ctxt = qmlContext(obj)->contextProperty("myObject");
+ QVERIFY(ctxt.userType() == QMetaType::QObjectStar);
+
+ QVERIFY(a == ctxt);
+
+ delete obj;
+}
+
+// Internal contexts should be read-only
+void tst_qqmlcontext::readOnlyContexts()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { id: me }", QUrl());
+
+ QObject *obj = component.create();
+ QVERIFY(obj);
+
+ QQmlContext *context = qmlContext(obj);
+ QVERIFY(context);
+
+ QVERIFY(qvariant_cast<QObject*>(context->contextProperty("me")) == obj);
+ QVERIFY(context->contextObject() == obj);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context.");
+ context->setContextProperty("hello", 12);
+ QVERIFY(context->contextProperty("hello") == QVariant());
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context.");
+ context->setContextProperty("hello", obj);
+ QVERIFY(context->contextProperty("hello") == QVariant());
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set context object for internal context.");
+ context->setContextObject(0);
+ QVERIFY(context->contextObject() == obj);
+
+ delete obj;
+}
+
+void tst_qqmlcontext::nameForObject()
+{
+ QObject o1;
+ QObject o2;
+ QObject o3;
+
+ QQmlEngine engine;
+
+ // As a context property
+ engine.rootContext()->setContextProperty("o1", &o1);
+ engine.rootContext()->setContextProperty("o2", &o2);
+ engine.rootContext()->setContextProperty("o1_2", &o1);
+
+ QCOMPARE(engine.rootContext()->nameForObject(&o1), QString("o1"));
+ QCOMPARE(engine.rootContext()->nameForObject(&o2), QString("o2"));
+ QCOMPARE(engine.rootContext()->nameForObject(&o3), QString());
+
+ // As an id
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { id: root; property QtObject o: QtObject { id: nested } }", QUrl());
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(qmlContext(o)->nameForObject(o), QString("root"));
+ QCOMPARE(qmlContext(o)->nameForObject(qvariant_cast<QObject*>(o->property("o"))), QString("nested"));
+ QCOMPARE(qmlContext(o)->nameForObject(&o1), QString());
+
+ delete o;
+}
+
+class DeleteCommand : public QObject
+{
+Q_OBJECT
+public:
+ DeleteCommand() : object(0) {}
+
+ QObject *object;
+
+public slots:
+ void doCommand() { if (object) delete object; object = 0; }
+};
+
+// Calling refresh expressions would crash if an expression or context was deleted during
+// the refreshing
+void tst_qqmlcontext::refreshExpressionsCrash()
+{
+ {
+ QQmlEngine engine;
+
+ DeleteCommand command;
+ engine.rootContext()->setContextProperty("deleteCommand", &command);
+ // We use a fresh context here to bypass any root-context optimizations in
+ // the engine
+ QQmlContext ctxt(engine.rootContext());
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl());
+ QVERIFY(component.isReady());
+
+ QObject *o1 = component.create(&ctxt);
+ QObject *o2 = component.create(&ctxt);
+
+ command.object = o2;
+
+ QQmlContextData::get(&ctxt)->refreshExpressions();
+
+ delete o1;
+ }
+ {
+ QQmlEngine engine;
+
+ DeleteCommand command;
+ engine.rootContext()->setContextProperty("deleteCommand", &command);
+ // We use a fresh context here to bypass any root-context optimizations in
+ // the engine
+ QQmlContext ctxt(engine.rootContext());
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl());
+ QVERIFY(component.isReady());
+
+ QObject *o1 = component.create(&ctxt);
+ QObject *o2 = component.create(&ctxt);
+
+ command.object = o1;
+
+ QQmlContextData::get(&ctxt)->refreshExpressions();
+
+ delete o2;
+ }
+}
+
+class CountCommand : public QObject
+{
+Q_OBJECT
+public:
+ CountCommand() : count(0) {}
+
+ int count;
+
+public slots:
+ void doCommand() { ++count; }
+};
+
+
+// Test that calling refresh expressions causes all the expressions to refresh
+void tst_qqmlcontext::refreshExpressions()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("refreshExpressions.qml"));
+ QQmlComponent component2(&engine, testFileUrl("RefreshExpressionsType.qml"));
+
+ CountCommand command;
+ engine.rootContext()->setContextProperty("countCommand", &command);
+
+ // We use a fresh context here to bypass any root-context optimizations in
+ // the engine
+ QQmlContext context(engine.rootContext());
+ QQmlContext context2(&context);
+
+ QObject *o1 = component.create(&context);
+ QObject *o2 = component.create(&context2);
+ QObject *o3 = component2.create(&context);
+
+ QCOMPARE(command.count, 5);
+
+ QQmlContextData::get(&context)->refreshExpressions();
+
+ QCOMPARE(command.count, 10);
+
+ delete o3;
+ delete o2;
+ delete o1;
+}
+
+// Test that updating the root context, only causes expressions in contexts with an
+// unresolved name to reevaluate
+void tst_qqmlcontext::refreshExpressionsRootContext()
+{
+ QQmlEngine engine;
+
+ CountCommand command;
+ engine.rootContext()->setContextProperty("countCommand", &command);
+
+ QQmlComponent component(&engine, testFileUrl("refreshExpressions.qml"));
+ QQmlComponent component2(&engine, testFileUrl("refreshExpressionsRootContext.qml"));
+
+ QQmlContext context(engine.rootContext());
+ QQmlContext context2(engine.rootContext());
+
+ QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: Can't find variable: unresolvedName");
+
+ QObject *o1 = component.create(&context);
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QObject *o2 = component2.create(&context2);
+
+ QCOMPARE(command.count, 3);
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQmlContextData::get(engine.rootContext())->refreshExpressions();
+
+ QCOMPARE(command.count, 4);
+
+ delete o2;
+ delete o1;
+}
+
+void tst_qqmlcontext::qtbug_22535()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("qtbug_22535.qml"));
+ QQmlContext context(engine.rootContext());
+
+ QObject *o = component.create(&context);
+
+ // Don't crash!
+ delete o;
+}
+
+QTEST_MAIN(tst_qqmlcontext)
+
+#include "tst_qqmlcontext.moc"
diff --git a/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro
new file mode 100644
index 0000000000..1c088860e5
--- /dev/null
+++ b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlcpputils
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlcpputils.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
new file mode 100644
index 0000000000..186b82a0a8
--- /dev/null
+++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <qsignalspy.h>
+#include <private/qqmlglobal_p.h>
+
+class tst_qqmlcpputils : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlcpputils() {}
+
+private slots:
+ void fastConnect();
+};
+
+class MyObject : public QObject {
+ Q_OBJECT
+public:
+ MyObject() : slotCount(0) {}
+ friend class tst_qqmlcpputils;
+
+ int slotCount;
+
+signals:
+ void signal1();
+ void signal2();
+
+public slots:
+ void slot1() { slotCount++; }
+};
+
+void tst_qqmlcpputils::fastConnect()
+{
+ {
+ MyObject *obj = new MyObject;
+ FAST_CONNECT(obj, SIGNAL(signal1()), obj, SLOT(slot1()));
+
+ obj->signal1();
+ QCOMPARE(obj->slotCount, 1);
+
+ delete obj;
+ }
+
+ {
+ MyObject obj;
+ FAST_CONNECT(&obj, SIGNAL(signal1()), &obj, SLOT(slot1()))
+
+ obj.signal1();
+ QCOMPARE(obj.slotCount, 1);
+ }
+
+ {
+ MyObject *obj = new MyObject;
+ QSignalSpy spy(obj, SIGNAL(signal2()));
+ FAST_CONNECT(obj, SIGNAL(signal1()), obj, SIGNAL(signal2()));
+
+ obj->signal1();
+ QCOMPARE(spy.count(), 1);
+
+ delete obj;
+ }
+}
+
+QTEST_MAIN(tst_qqmlcpputils)
+
+#include "tst_qqmlcpputils.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml
index e8e108fa44..e8e108fa44 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml
index 062772106b..062772106b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml
index 823c0ef367..823c0ef367 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml
index cef8ae09ea..cef8ae09ea 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml
index 4a45535a50..4a45535a50 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml b/tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml
index 07bb16b0d8..07bb16b0d8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml b/tests/auto/qml/qqmlecmascript/data/CustomObject.qml
index aa1a1d6061..aa1a1d6061 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/CustomObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml b/tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml
index 4a45535a50..4a45535a50 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml b/tests/auto/qml/qqmlecmascript/data/MethodsObject.qml
index eaca0a7f92..eaca0a7f92 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/MethodsObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml b/tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml
index 3b3e84a900..3b3e84a900 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml
index 5f28833fe7..5f28833fe7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml
index 36c025401f..36c025401f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent2.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml
index 6a49cb9317..6a49cb9317 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent3.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml
index a90725016e..a90725016e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent4.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml
index 9273a52f54..9273a52f54 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent5.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml
index 94ef338792..94ef338792 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarInheritanceComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml
index b01cf6ed84..b01cf6ed84 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarInheritanceComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarOwnershipComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml
index c1f73d3bac..c1f73d3bac 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarOwnershipComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVar.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml
index d56bd41a99..d56bd41a99 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVar.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVariant.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml
index e10fcfe36a..e10fcfe36a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVariant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceVarComponent.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml
index 2cf6b4223b..2cf6b4223b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceVarComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/Scope6Nested.qml b/tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml
index a3794df22b..a3794df22b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/Scope6Nested.qml
+++ b/tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml b/tests/auto/qml/qqmlecmascript/data/ScopeObject.qml
index f341cce3c9..f341cce3c9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ScopeObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/SequenceConversionComponent.qml b/tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml
index 0c7f60b062..0c7f60b062 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/SequenceConversionComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml b/tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml
index f6398d254d..f6398d254d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml
+++ b/tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml b/tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml
index 56e06252c4..56e06252c4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml
+++ b/tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml
index ff6c553c31..ff6c553c31 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml
index bba9033235..bba9033235 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml
index 3e4cda6ba3..3e4cda6ba3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml
index de5f49ffc5..de5f49ffc5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml b/tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml
index f228b2c19f..f228b2c19f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml b/tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml
index 79d6e6887c..79d6e6887c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml
index b5bc280d11..b5bc280d11 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml
index 6c16ff5604..6c16ff5604 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml
index 441098bd39..441098bd39 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml
index 9135e79469..9135e79469 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml
index b855a183ee..b855a183ee 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml
index b0bb3681cf..b0bb3681cf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml
index b318af0138..b318af0138 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml
index c5f56a8798..c5f56a8798 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml
index b07db8ba40..b07db8ba40 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml
index 35c9d6fd5d..35c9d6fd5d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml
index 2c79729651..2c79729651 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml
index 86ff6b6bb3..86ff6b6bb3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.1.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml
index be283fdda1..be283fdda1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.2.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml
index c8fb28b04e..c8fb28b04e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.3.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml
index ad8a92e317..ad8a92e317 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.4.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml
index a9f2e642d1..a9f2e642d1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.5.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml
index b8697e4290..b8697e4290 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.6.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml
index 7a794eb694..7a794eb694 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.7.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml
index 96c0684939..96c0684939 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.7.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml
index a7184c9200..a7184c9200 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml b/tests/auto/qml/qqmlecmascript/data/attachedProperty.qml
index 061eda0e54..061eda0e54 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/attachedProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml b/tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml
index 11fb7ccad2..11fb7ccad2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml
+++ b/tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/automaticSemicolon.qml b/tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml
index 6db68f2328..6db68f2328 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/automaticSemicolon.qml
+++ b/tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml b/tests/auto/qml/qqmlecmascript/data/bindingLoop.qml
index 80545cf72b..80545cf72b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml
+++ b/tests/auto/qml/qqmlecmascript/data/bindingLoop.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/blank.js b/tests/auto/qml/qqmlecmascript/data/blank.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/blank.js
+++ b/tests/auto/qml/qqmlecmascript/data/blank.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml
index 3147f63989..3147f63989 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml
index c89bb49b45..c89bb49b45 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml b/tests/auto/qml/qqmlecmascript/data/booleanConversion.qml
index a363cf4dd1..a363cf4dd1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml
+++ b/tests/auto/qml/qqmlecmascript/data/booleanConversion.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml b/tests/auto/qml/qqmlecmascript/data/bug.1.qml
index 31f7c44fcc..31f7c44fcc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/bug.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml
index 3fd9131b2f..3fd9131b2f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml
index 3fbf931fca..3fbf931fca 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml
index 1e92aca825..1e92aca825 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml
index 3549d8c556..3549d8c556 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml
index d611e0fe30..d611e0fe30 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml
index a6862517c6..a6862517c6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml
index f91fb71f1f..f91fb71f1f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml b/tests/auto/qml/qqmlecmascript/data/compiled.qml
index 7c46306772..7c46306772 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml
+++ b/tests/auto/qml/qqmlecmascript/data/compiled.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml b/tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml
index e97b75c8d0..e97b75c8d0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml
+++ b/tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml
index 13c5ae5fff..13c5ae5fff 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml
index 207a06b700..207a06b700 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml
index ca9d1d8ab9..ca9d1d8ab9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.4.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml
index 5a2091f71c..5a2091f71c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml b/tests/auto/qml/qqmlecmascript/data/deferredProperties.qml
index e01f708a07..e01f708a07 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deferredProperties.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml b/tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml
index 308a01ce6f..308a01ce6f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml b/tests/auto/qml/qqmlecmascript/data/deleteLater.qml
index 2a9ce44b20..2a9ce44b20 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deleteLater.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deleteWhileBindingRunning.qml b/tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml
index b5cc59e2c0..b5cc59e2c0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deleteWhileBindingRunning.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml b/tests/auto/qml/qqmlecmascript/data/deletedEngine.qml
index 97acddf5fc..97acddf5fc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deletedEngine.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml b/tests/auto/qml/qqmlecmascript/data/deletedObject.qml
index 24c12bf694..24c12bf694 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deletedObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/doubleEvaluate.qml b/tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml
index 0532715432..0532715432 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/doubleEvaluate.qml
+++ b/tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml
index d790d634e9..d790d634e9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml
index 7b132e1edf..7b132e1edf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreationOwnership.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml
index ed396d49b0..ed396d49b0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreationOwnership.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml
index 9a5732c194..9a5732c194 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml
index f41e5262fd..f41e5262fd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicString.qml b/tests/auto/qml/qqmlecmascript/data/dynamicString.qml
index 5693794c71..5693794c71 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicString.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicString.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml b/tests/auto/qml/qqmlecmascript/data/elementAssign.qml
index 0d75cbf6fc..0d75cbf6fc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml
+++ b/tests/auto/qml/qqmlecmascript/data/elementAssign.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml b/tests/auto/qml/qqmlecmascript/data/enums.1.qml
index 6351823230..6351823230 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/enums.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml b/tests/auto/qml/qqmlecmascript/data/enums.2.qml
index bdc672fadc..bdc672fadc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/enums.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/qml/qqmlecmascript/data/eval.qml
index a752b8c0d3..a752b8c0d3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
+++ b/tests/auto/qml/qqmlecmascript/data/eval.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exception.js b/tests/auto/qml/qqmlecmascript/data/exception.js
index 160bbfa5b6..160bbfa5b6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/exception.js
+++ b/tests/auto/qml/qqmlecmascript/data/exception.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml b/tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml
index a2f0d1a8b7..a2f0d1a8b7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml
+++ b/tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml
index b8d5e5e60f..b8d5e5e60f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml
+++ b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml
index a4ce55e245..a4ce55e245 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml
index 2c382e871a..2c382e871a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml
+++ b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup2.qml b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml
index e4af3359d0..e4af3359d0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml b/tests/auto/qml/qqmlecmascript/data/extensionObjects.qml
index 7734a11dd8..7734a11dd8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml
+++ b/tests/auto/qml/qqmlecmascript/data/extensionObjects.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml b/tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml
index 3c443cb975..3c443cb975 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml
+++ b/tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/forInLoop.qml b/tests/auto/qml/qqmlecmascript/data/forInLoop.qml
index f14367f177..f14367f177 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/forInLoop.qml
+++ b/tests/auto/qml/qqmlecmascript/data/forInLoop.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/qml/qqmlecmascript/data/function.qml
index af2da7023c..af2da7023c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
+++ b/tests/auto/qml/qqmlecmascript/data/function.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml
index 09540f1f6e..09540f1f6e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml
index 0f78eaf1dc..0f78eaf1dc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.js b/tests/auto/qml/qqmlecmascript/data/functionAssignment.js
index 14daa7629f..14daa7629f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.js
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml b/tests/auto/qml/qqmlecmascript/data/functionErrors.qml
index 230a626600..230a626600 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/functionErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.1.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml
index 8a06c30d8c..8a06c30d8c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.2.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml
index 91edc447e2..91edc447e2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.1.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml
index 70e8390677..70e8390677 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.2.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml
index 2ddb9253eb..2ddb9253eb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml
index ece23269f1..ece23269f1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml
index 650ed7c73e..650ed7c73e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml
+++ b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js b/tests/auto/qml/qqmlecmascript/data/importScope.1.js
index 4c556f9e96..4c556f9e96 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js
+++ b/tests/auto/qml/qqmlecmascript/data/importScope.1.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js b/tests/auto/qml/qqmlecmascript/data/importScope.2.js
index 291fb9d2cc..291fb9d2cc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js
+++ b/tests/auto/qml/qqmlecmascript/data/importScope.2.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml b/tests/auto/qml/qqmlecmascript/data/importScope.qml
index 9b907f11f9..9b907f11f9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml
+++ b/tests/auto/qml/qqmlecmascript/data/importScope.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/in.qml b/tests/auto/qml/qqmlecmascript/data/in.qml
index f84c9a1481..f84c9a1481 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/in.qml
+++ b/tests/auto/qml/qqmlecmascript/data/in.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.js b/tests/auto/qml/qqmlecmascript/data/include.js
index 232fd808f8..232fd808f8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include.js
+++ b/tests/auto/qml/qqmlecmascript/data/include.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml b/tests/auto/qml/qqmlecmascript/data/include.qml
index 5ce2ed78ec..5ce2ed78ec 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js b/tests/auto/qml/qqmlecmascript/data/include_callback.js
index ea19eba300..ea19eba300 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_callback.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml b/tests/auto/qml/qqmlecmascript/data/include_callback.qml
index fbebcdcd58..fbebcdcd58 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_callback.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml b/tests/auto/qml/qqmlecmascript/data/include_pragma.qml
index 7b23c76baa..7b23c76baa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_pragma.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js b/tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js
index a0380a25df..a0380a25df 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js b/tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js
index d87bafc816..d87bafc816 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js b/tests/auto/qml/qqmlecmascript/data/include_remote.js
index e6a4676819..e6a4676819 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_remote.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml b/tests/auto/qml/qqmlecmascript/data/include_remote.qml
index fe020a55df..fe020a55df 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_remote.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.js
index cc90860cc9..cc90860cc9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml
index e8ef609fed..e8ef609fed 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js b/tests/auto/qml/qqmlecmascript/data/include_shared.js
index a49c07bbfc..a49c07bbfc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_shared.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml b/tests/auto/qml/qqmlecmascript/data/include_shared.qml
index 28b1003fd4..28b1003fd4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_shared.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml b/tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml
index 160a90b574..160a90b574 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml
+++ b/tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml b/tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml
index 4612273727..4612273727 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml
+++ b/tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js b/tests/auto/qml/qqmlecmascript/data/js/include2.js
index 2a0c039dfa..2a0c039dfa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js
+++ b/tests/auto/qml/qqmlecmascript/data/js/include2.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js b/tests/auto/qml/qqmlecmascript/data/js/include3.js
index 84b2770b6f..84b2770b6f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js
+++ b/tests/auto/qml/qqmlecmascript/data/js/include3.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml b/tests/auto/qml/qqmlecmascript/data/jsObject.qml
index 4223c25f31..4223c25f31 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml
index 97c72bd9a6..97c72bd9a6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml
index d006343782..d006343782 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFive.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js
index e458094552..e458094552 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFive.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFour.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js
index faddc15c9d..faddc15c9d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFour.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js
index 7a4f434665..7a4f434665 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importOne.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js
index 338c4e042f..338c4e042f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importOne.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibrary.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js
index c746fef14b..c746fef14b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibrary.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js
index 3f2e6589dd..3f2e6589dd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
index fa6497d99b..fa6497d99b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importThree.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js
index 3917134ee2..3917134ee2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importThree.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importTwo.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js
index 45b3c9a74d..45b3c9a74d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importTwo.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importWithNoImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js
index 83426c425c..83426c425c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importWithNoImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml
index 456a10c7f0..456a10c7f0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml
index b3e545dd7c..b3e545dd7c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml
index 29de15c197..29de15c197 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml
index 6a7459d3bb..6a7459d3bb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
index 01f08dbdc3..01f08dbdc3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml
index aff61cc436..aff61cc436 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js
index 69bc1c9887..69bc1c9887 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testModuleImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testScriptImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js
index 2ecccd8816..2ecccd8816 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testScriptImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml
index 73193a35a5..73193a35a5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml
index ef2fc591b3..ef2fc591b3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml
index d0c37ad9ba..d0c37ad9ba 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml
index edd103bd82..edd103bd82 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml
index 28e2026f8d..28e2026f8d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importOne.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js
index 45fd9c75dd..45fd9c75dd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importOne.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importPragmaLibrary.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js
index ad0e6946a2..ad0e6946a2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importPragmaLibrary.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importWithImports.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js
index 6d77ceccb1..6d77ceccb1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importWithImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml
index f04ce007d8..f04ce007d8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js
index 69bc1c9887..69bc1c9887 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testModuleImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testScriptImport.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js
index 2ecccd8816..2ecccd8816 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testScriptImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js
index 3ffdb339ad..3ffdb339ad 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js
+++ b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml
index 5884e2719b..5884e2719b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml
+++ b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listAssignment.qml b/tests/auto/qml/qqmlecmascript/data/listAssignment.qml
index 6e6039715b..6e6039715b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/listAssignment.qml
+++ b/tests/auto/qml/qqmlecmascript/data/listAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml b/tests/auto/qml/qqmlecmascript/data/listProperties.qml
index bdb1265a21..bdb1265a21 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml
+++ b/tests/auto/qml/qqmlecmascript/data/listProperties.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml b/tests/auto/qml/qqmlecmascript/data/listToVariant.qml
index 690024b928..690024b928 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/listToVariant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml
index 77accd80de..77accd80de 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision2.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml
index 36057cb902..36057cb902 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision3.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml
index 81769e98f7..81769e98f7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml
index 6ebe4790bb..6ebe4790bb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml
index 8a7e24d788..8a7e24d788 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml
index 43e87948cd..43e87948cd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml
index 2f82d685fa..2f82d685fa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml b/tests/auto/qml/qqmlecmascript/data/methods.1.qml
index 0bbee16df8..0bbee16df8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml b/tests/auto/qml/qqmlecmascript/data/methods.2.qml
index 9f0c6b15fe..9f0c6b15fe 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml b/tests/auto/qml/qqmlecmascript/data/methods.3.qml
index 365780a560..365780a560 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml b/tests/auto/qml/qqmlecmascript/data/methods.4.qml
index a3bd7bebf8..a3bd7bebf8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml b/tests/auto/qml/qqmlecmascript/data/methods.5.qml
index ede2759e2e..ede2759e2e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMajorVersionFail.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml
index fb050f65bc..fb050f65bc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMajorVersionFail.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMinorVersionFail.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml
index e06be667f7..e06be667f7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMinorVersionFail.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml
index 718a64652d..718a64652d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApi.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiCaching.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml
index 56a55e4e9b..56a55e4e9b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiCaching.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiEnums.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml
index da5ffd5e76..da5ffd5e76 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiEnums.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml
index be647ca57f..be647ca57f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiWriting.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml
index 7c4e20489d..7c4e20489d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApi.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiCaching.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml
index 90974b5969..90974b5969 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiCaching.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml
index 02461d59ed..02461d59ed 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiWriting.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml b/tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml
index e349ced98f..e349ced98f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml
index 23276f778d..23276f778d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml
index b4a417e04e..b4a417e04e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml
+++ b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nonExistentAttachedObject.qml b/tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml
index f9585db009..f9585db009 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/nonExistentAttachedObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nonNotifyable.qml b/tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml
index 2b8b113c34..2b8b113c34 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/nonNotifyable.qml
+++ b/tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml b/tests/auto/qml/qqmlecmascript/data/nonscriptable.qml
index e96df6b40e..e96df6b40e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml
+++ b/tests/auto/qml/qqmlecmascript/data/nonscriptable.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml b/tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml
index 1aee7a1670..1aee7a1670 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml b/tests/auto/qml/qqmlecmascript/data/numberAssignment.qml
index 30a77e8aed..30a77e8aed 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml
+++ b/tests/auto/qml/qqmlecmascript/data/numberAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectConversion.qml b/tests/auto/qml/qqmlecmascript/data/objectConversion.qml
index 67fc342db3..67fc342db3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/objectConversion.qml
+++ b/tests/auto/qml/qqmlecmascript/data/objectConversion.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml b/tests/auto/qml/qqmlecmascript/data/objectName.qml
index 20b9ec2935..20b9ec2935 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml
+++ b/tests/auto/qml/qqmlecmascript/data/objectName.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml b/tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml
index 845f74b1aa..845f74b1aa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml
+++ b/tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml b/tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml
index 98f9e05bdf..98f9e05bdf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml
+++ b/tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml b/tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml
index 090c948f26..090c948f26 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml b/tests/auto/qml/qqmlecmascript/data/ownership.qml
index 855a264995..855a264995 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ownership.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml b/tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml
index 34523ec1c7..34523ec1c7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml b/tests/auto/qml/qqmlecmascript/data/propertySplicing.qml
index 53711db3f4..53711db3f4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertySplicing.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.1.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml
index 219e61bf91..219e61bf91 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml
index ac7f2bed57..ac7f2bed57 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml
index 2ac4807ec5..2ac4807ec5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.3.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml
index cf6a651639..cf6a651639 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.4.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml
index 82fc225e71..82fc225e71 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.5.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml
index a5c7812289..a5c7812289 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml
index 060d24e7bc..060d24e7bc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.7.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml
index 1d6c8c0a37..1d6c8c0a37 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.7.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.8.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml
index a9f73db402..a9f73db402 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.8.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.9.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml
index f5aca28417..f5aca28417 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.9.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml
index 93c44afcc9..93c44afcc9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml
index 171d7747cd..171d7747cd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.inherit.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml
index abd0dd7c04..abd0dd7c04 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.inherit.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.reparent.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml
index 7b3df674f1..7b3df674f1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.reparent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarCpp.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml
index cd3147f565..cd3147f565 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarCpp.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarImplicitOwnership.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml
index 9cebded932..9cebded932 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarImplicitOwnership.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml
index 14d4f9fd27..14d4f9fd27 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml
index d5b449c938..d5b449c938 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.type.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml
index 3406553b91..3406553b91 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.type.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml
index 1eba36ce81..1eba36ce81 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type1.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml
index 9a29b6e17f..9a29b6e17f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml
index f82b8a1c1e..f82b8a1c1e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml
index 7b99c4b6ad..7b99c4b6ad 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml b/tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml
index 3c1986d721..3c1986d721 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
index 12598b3b9f..12598b3b9f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml b/tests/auto/qml/qqmlecmascript/data/qmlToString.qml
index ac296ce293..ac296ce293 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qmlToString.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml b/tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml
index acd512a2be..acd512a2be 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectDerivedArgument.qml b/tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml
index bf4ab6fd7a..bf4ab6fd7a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectDerivedArgument.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml
index 90263e5124..90263e5124 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.js
index 092bc2b041..092bc2b041 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml
index 6c7e8806e6..6c7e8806e6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml
index b1b062ed35..b1b062ed35 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml
index f490848caf..f490848caf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21580.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml
index dc0066ba3f..dc0066ba3f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21580.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.js b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.js
index e1a688ebbe..e1a688ebbe 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.js
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml
index 0f972d5459..0f972d5459 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22464.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml
index 19f26736f1..19f26736f1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22464.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml
index b38a84b4c0..b38a84b4c0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.js
index 6d19fe0571..6d19fe0571 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js
index 1a7c8a2e6e..1a7c8a2e6e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml
index 281765bff6..281765bff6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml
index 90a47c0f4b..90a47c0f4b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_9792.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml
index 9ac44308c6..9ac44308c6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_9792.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml b/tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml
index 90711c8d09..90711c8d09 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml b/tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml
index 5377d2dcbf..5377d2dcbf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml
+++ b/tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml b/tests/auto/qml/qqmlecmascript/data/realToInt.qml
index a9e7dd2a95..a9e7dd2a95 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml
+++ b/tests/auto/qml/qqmlecmascript/data/realToInt.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.2.qml b/tests/auto/qml/qqmlecmascript/data/regExp.2.qml
index 68cca5733b..68cca5733b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/regExp.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml b/tests/auto/qml/qqmlecmascript/data/regExp.qml
index 0dc404b5db..0dc404b5db 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml
+++ b/tests/auto/qml/qqmlecmascript/data/regExp.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js b/tests/auto/qml/qqmlecmascript/data/remote_file.js
index 1b123aee61..1b123aee61 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js
+++ b/tests/auto/qml/qqmlecmascript/data/remote_file.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings.qml b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml
index 1ae1b162b2..1ae1b162b2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml
index f84ba8c722..f84ba8c722 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml
index 805655fc17..805655fc17 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml
index ee5b05b28a..ee5b05b28a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml
index 09868e5e7c..09868e5e7c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml
index a1ebeb4073..a1ebeb4073 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js
index 468a6b4f2e..468a6b4f2e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml
index 9321481f45..9321481f45 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js
index 9aeb507487..9aeb507487 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml
index e8b53979dd..e8b53979dd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js
index 000eeddb34..000eeddb34 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml
index 082d132c24..082d132c24 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js
index ba52b323f0..ba52b323f0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml
index a1a3c1d66f..a1a3c1d66f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js
index b59b5b1fa9..b59b5b1fa9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml
index 8f6dcd6603..8f6dcd6603 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js
index 130199f78a..130199f78a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml
index 5284b40cc8..5284b40cc8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js
index 14a36a19ea..14a36a19ea 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml
index 826cbe49fc..826cbe49fc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml
index 4adef39980..4adef39980 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml
index 4adef39980..4adef39980 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml
index 500f5d5bd7..500f5d5bd7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml
index 7a3b845247..7a3b845247 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml
index 23e4c8d15e..23e4c8d15e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml
index fe3707b5d3..fe3707b5d3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml
diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml
new file mode 100644
index 0000000000..9b4b1e6fd9
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+import Qt.test 1.0
+
+// In this example, a common syntax error will only be "caught"
+// when the function is called via:
+// QQmlVMEMetaObject::metaCall->invokeMetaMethod()
+// We would like to ensure that a useful error message is printed.
+
+QtObject {
+ id: root
+ property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider }
+ property var scarceResourceCopy;
+ property string srp_name: a.toString();
+
+ function retrieveScarceResource() {
+ root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception
+ }
+
+ function releaseScarceResource() {
+ root.scarceResourceCopy = null;
+ }
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml
new file mode 100644
index 0000000000..57673de3f3
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+import Qt.test 1.0
+
+// In this example, a common syntax error will only be "caught"
+// when the function is called via:
+// QQmlVMEMetaObject::metaCall->invokeMetaMethod()
+// We would like to ensure that a useful error message is printed.
+
+QtObject {
+ id: root
+ property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider }
+ property variant scarceResourceCopy;
+ property string srp_name: a.toString();
+
+ function retrieveScarceResource() {
+ root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception
+ }
+
+ function releaseScarceResource() {
+ root.scarceResourceCopy = null;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js
index 217f693456..217f693456 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml
index 205131661f..205131661f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js
index 5b2494c8e6..5b2494c8e6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml
index e7f6d7868f..e7f6d7868f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameWithBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml
index 34cb97f39c..34cb97f39c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameWithBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceObjectGc.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml
index 7ec98e6619..7ec98e6619 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceObjectGc.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml
index 0b30e88fa8..0b30e88fa8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml
index 1011c7e240..1011c7e240 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js
index c904eb3564..c904eb3564 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml
index 1d4e67055e..1d4e67055e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js
index c904eb3564..c904eb3564 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml
index 1d4e67055e..1d4e67055e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml
index 5e6c2d97f9..5e6c2d97f9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml
index 2970bcb26c..2970bcb26c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml
index 9e9495c0fa..9e9495c0fa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml
index 022067beca..022067beca 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml b/tests/auto/qml/qqmlecmascript/data/scope.2.qml
index fe1c4c7931..fe1c4c7931 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml b/tests/auto/qml/qqmlecmascript/data/scope.3.qml
index 9add81809c..9add81809c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml b/tests/auto/qml/qqmlecmascript/data/scope.4.qml
index d65b6e7c7c..d65b6e7c7c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml b/tests/auto/qml/qqmlecmascript/data/scope.5.qml
index 6dbcbe2a40..6dbcbe2a40 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml b/tests/auto/qml/qqmlecmascript/data/scope.6.qml
index 5897b533d7..5897b533d7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml b/tests/auto/qml/qqmlecmascript/data/scope.qml
index a00352b684..a00352b684 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js
index 54284fea47..54284fea47 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml
index ace473756e..ace473756e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js
index 595c778aa7..595c778aa7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml
index cdf2d6ad98..cdf2d6ad98 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml
index b0e40565c0..b0e40565c0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml
index ef5331c94a..ef5331c94a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml
index 8dcacbcbb7..8dcacbcbb7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js
index 71bdd088a2..71bdd088a2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml
index 06b6f0fa62..06b6f0fa62 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.js b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js
index 407426fcd1..407426fcd1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml
index e546ee44d8..e546ee44d8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml
index e70cd8b900..e70cd8b900 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml
index 6f47776ea5..6f47776ea5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml
index b3887545fb..b3887545fb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js b/tests/auto/qml/qqmlecmascript/data/scriptErrors.js
index d22f623edb..d22f623edb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptErrors.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml b/tests/auto/qml/qqmlecmascript/data/scriptErrors.qml
index 4998f63929..4998f63929 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml
index 58cf8051f0..58cf8051f0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml
index 074851a67b..074851a67b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.array.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
index 52abda1e55..52abda1e55 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.array.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml
index 9c87dd293e..9c87dd293e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.error.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml
index 8d83e9f9f5..8d83e9f9f5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.copy.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml
index f6614dad0c..f6614dad0c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.copy.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.indexes.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml
index 23f1e90417..23f1e90417 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.indexes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml
index 12a76d7e7d..12a76d7e7d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.error.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml
index 4a8a4a17b2..4a8a4a17b2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.threads.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml
index aefad89ca4..aefad89ca4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.threads.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml
index 75beafd1ee..75beafd1ee 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.error.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml
index 812de043b7..812de043b7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml b/tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml
index b967f0984c..b967f0984c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml b/tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml
index b30aa8b4cd..b30aa8b4cd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml
index fbd09142f7..fbd09142f7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml
index 6467c42bb9..6467c42bb9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml
index 690b7cf216..690b7cf216 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml
index 0e1e728a86..0e1e728a86 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalHandlers.qml b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
index 975be1b2ad..975be1b2ad 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalHandlers.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
index 4fc2dab943..4fc2dab943 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml b/tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml
index d98d7e9c81..d98d7e9c81 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithJSValueInVariant.qml b/tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml
index a6f1aa381a..a6f1aa381a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithJSValueInVariant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithQJSValue.qml b/tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml
index 36f481d533..36f481d533 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithQJSValue.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithUnknownTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml
index 49293edfb3..49293edfb3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithUnknownTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml b/tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml
index e709e3a8bd..e709e3a8bd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml
+++ b/tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/stringArg.qml b/tests/auto/qml/qqmlecmascript/data/stringArg.qml
index 7019af9da5..7019af9da5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/stringArg.qml
+++ b/tests/auto/qml/qqmlecmascript/data/stringArg.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml
index 3c7870839d..3c7870839d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.2.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml
index 928d36be1f..928d36be1f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.3.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml
index 5b05d88767..5b05d88767 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.4.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml
index 43ba199a04..43ba199a04 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.5.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml
index e0fc62e392..e0fc62e392 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.6.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml
index 6fb71eb345..6fb71eb345 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/threadScript.js b/tests/auto/qml/qqmlecmascript/data/threadScript.js
index 9f94de1bc1..9f94de1bc1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/threadScript.js
+++ b/tests/auto/qml/qqmlecmascript/data/threadScript.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml b/tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml
index c44acf4fd1..c44acf4fd1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml b/tests/auto/qml/qqmlecmascript/data/transientErrors.qml
index 451bb51996..451bb51996 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/transientErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml
index 71cc67a941..71cc67a941 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.2.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml
index e7fca0bff7..e7fca0bff7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.3.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml
index 04b39f73d5..04b39f73d5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.4.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml
index 231aaf0683..231aaf0683 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js b/tests/auto/qml/qqmlecmascript/data/typeOf.js
index 16a34234c0..16a34234c0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js
+++ b/tests/auto/qml/qqmlecmascript/data/typeOf.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml b/tests/auto/qml/qqmlecmascript/data/typeOf.qml
index 28f7debed5..28f7debed5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml
+++ b/tests/auto/qml/qqmlecmascript/data/typeOf.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/unaryExpression.qml b/tests/auto/qml/qqmlecmascript/data/unaryExpression.qml
index 0d40bec710..0d40bec710 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/unaryExpression.qml
+++ b/tests/auto/qml/qqmlecmascript/data/unaryExpression.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml
index e73d38e2ce..e73d38e2ce 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml
index eceff60aa1..eceff60aa1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/urlListProperty.qml b/tests/auto/qml/qqmlecmascript/data/urlListProperty.qml
index eeb0815f09..eeb0815f09 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/urlListProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/urlListProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml b/tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml
index 451cb03206..451cb03206 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml
index 0e8bdaec96..0e8bdaec96 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/v8bindingException.qml b/tests/auto/qml/qqmlecmascript/data/v8bindingException.qml
index ff203e23e3..ff203e23e3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/v8bindingException.qml
+++ b/tests/auto/qml/qqmlecmascript/data/v8bindingException.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/v8functionException.qml b/tests/auto/qml/qqmlecmascript/data/v8functionException.qml
index 51df1c65d8..51df1c65d8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/v8functionException.qml
+++ b/tests/auto/qml/qqmlecmascript/data/v8functionException.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml b/tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml
index 33b4a68c40..33b4a68c40 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml
+++ b/tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml b/tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml
index 6aa8480365..6aa8480365 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml
+++ b/tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/withStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/withStatement.1.qml
index 28f0c08451..28f0c08451 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/withStatement.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/withStatement.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml b/tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml
index 3854b069a0..3854b069a0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml b/tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml
index a1ba5df071..a1ba5df071 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml
diff --git a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro
new file mode 100644
index 0000000000..b07e4393a9
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro
@@ -0,0 +1,22 @@
+CONFIG += testcase
+TARGET = tst_qqmlecmascript
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlecmascript.cpp \
+ testtypes.cpp \
+ ../../shared/testhttpserver.cpp
+HEADERS += testtypes.h \
+ ../../shared/testhttpserver.h
+INCLUDEPATH += ../../shared
+
+include (../../shared/util.pri)
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private network widgets testlib
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
new file mode 100644
index 0000000000..78119cb776
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+#include <QWidget>
+#include <QPlainTextEdit>
+#include <QQmlEngine>
+#include <QJSEngine>
+
+class BaseExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged)
+public:
+ BaseExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
+
+ int extendedProperty() const { return m_value; }
+ void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
+
+signals:
+ void extendedPropertyChanged();
+private:
+ int m_value;
+};
+
+class ExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged)
+public:
+ ExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
+
+ int extendedProperty() const { return m_value; }
+ void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
+
+signals:
+ void extendedPropertyChanged();
+private:
+ int m_value;
+};
+
+class DefaultPropertyExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("DefaultProperty", "firstProperty")
+public:
+ DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {}
+};
+
+class QWidgetDeclarativeUI : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
+
+signals:
+ void widthChanged();
+
+public:
+ QWidgetDeclarativeUI(QObject *other) : QObject(other) { }
+
+public:
+ int width() const { return 0; }
+ void setWidth(int) { }
+};
+
+void MyQmlObject::v8function(QQmlV8Function *args)
+{
+ const char *error = "Exception thrown from within QObject slot";
+ v8::ThrowException(v8::Exception::Error(v8::String::New(error)));
+}
+
+static QJSValue script_api(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+
+ static int testProperty = 13;
+ QJSValue v = scriptEngine->newObject();
+ v.setProperty("scriptTestProperty", testProperty++);
+ return v;
+}
+
+static QJSValue readonly_script_api(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+
+ static int testProperty = 42;
+ QJSValue v = scriptEngine->newObject();
+ v.setProperty("scriptTestProperty", testProperty++);
+
+ // now freeze it so that it's read-only
+ QJSValue freezeFunction = scriptEngine->evaluate("(function(obj) { return Object.freeze(obj); })");
+ v = freezeFunction.call(QJSValueList() << v);
+
+ return v;
+}
+
+static QObject *qobject_api(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+
+ testQObjectApi *o = new testQObjectApi();
+ o->setQObjectTestProperty(20);
+ o->setQObjectTestWritableProperty(50);
+ return o;
+}
+
+static QObject *qobject_api_engine_parent(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(scriptEngine)
+
+ static int testProperty = 26;
+ testQObjectApi *o = new testQObjectApi(engine);
+ o->setQObjectTestProperty(testProperty++);
+ return o;
+}
+
+void registerTypes()
+{
+ qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias");
+ qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
+ qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject");
+ qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer");
+ qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject");
+ qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject");
+ qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject");
+ qmlRegisterType<MyDerivedObject>("Qt.test", 1,0, "MyDerivedObject");
+ qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
+ qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject");
+ qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject");
+ qmlRegisterType<MyRevisionedClass>("Qt.test",1,0,"MyRevisionedClass");
+ qmlRegisterType<MyDeleteObject>("Qt.test", 1,0, "MyDeleteObject");
+ qmlRegisterType<MyRevisionedClass,1>("Qt.test",1,1,"MyRevisionedClass");
+
+ // test scarce resource property binding post-evaluation optimisation
+ // and for testing memory usage in property var circular reference test
+ qmlRegisterType<ScarceResourceObject>("Qt.test", 1,0, "MyScarceResourceObject");
+
+ // Register the uncreatable base class
+ qmlRegisterRevision<MyRevisionedBaseClassRegistered,1>("Qt.test",1,1);
+ // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
+ qmlRegisterType<MyRevisionedSubclass>("Qt.test",1,0,"MyRevisionedSubclass");
+ // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
+ qmlRegisterType<MyRevisionedSubclass,1>("Qt.test",1,1,"MyRevisionedSubclass");
+
+ qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget");
+ qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
+
+ qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
+
+ qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements
+ qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace!
+ qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements
+ qmlRegisterModuleApi("Qt.test.scriptApi",2,0,readonly_script_api); // register (script) module API for a uri which doesn't contain elements - will be made read-only
+ qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements
+ qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set
+ qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
+ qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
+
+ qRegisterMetaType<MyQmlObject::MyType>("MyEnum2");
+ qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
+
+ qmlRegisterType<CircularReferenceObject>("Qt.test", 1, 0, "CircularReferenceObject");
+ qmlRegisterType<CircularReferenceHandle>("Qt.test", 1, 0, "CircularReferenceHandle");
+
+ qmlRegisterType<MyDynamicCreationDestructionObject>("Qt.test", 1, 0, "MyDynamicCreationDestructionObject");
+ qmlRegisterType<WriteCounter>("Qt.test", 1, 0, "WriteCounter");
+
+ qmlRegisterType<MySequenceConversionObject>("Qt.test", 1, 0, "MySequenceConversionObject");
+}
+
+#include "testtypes.moc"
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
new file mode 100644
index 0000000000..1d68e8ae13
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -0,0 +1,1313 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+#include <QtQml/qqmllist.h>
+#include <QtCore/qrect.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/QPixmap>
+#include <QtCore/qdatetime.h>
+#include <QtQml/qjsvalue.h>
+#include <QtQml/qqmlscriptstring.h>
+#include <QtQml/qqmlcomponent.h>
+
+#include <private/qqmlengine_p.h>
+#include <private/qv8engine_p.h>
+
+class MyQmlAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value CONSTANT)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
+public:
+ MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
+
+ int value() const { return 19; }
+ int value2() const { return m_value2; }
+ void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
+
+ void emitMySignal() { emit mySignal(); }
+
+signals:
+ void value2Changed();
+ void mySignal();
+
+private:
+ int m_value2;
+};
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_ENUMS(MyEnum2)
+ Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
+ Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
+ Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int console READ console CONSTANT)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlChanged)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
+ Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
+ Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
+ Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false)
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged)
+
+public:
+ MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0) {}
+
+ enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
+ enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
+
+ bool trueProperty() const { return true; }
+ bool falseProperty() const { return false; }
+
+ QString stringProperty() const { return m_string; }
+ void setStringProperty(const QString &s)
+ {
+ if (s == m_string)
+ return;
+ m_string = s;
+ emit stringChanged();
+ }
+
+ QUrl urlProperty() const { return m_url; }
+ void setUrlProperty(const QUrl &url)
+ {
+ if (url == m_url)
+ return;
+ m_url = url;
+ emit urlChanged();
+ }
+
+ QObject *objectProperty() const { return m_object; }
+ void setObjectProperty(QObject *obj) {
+ if (obj == m_object)
+ return;
+ m_object = obj;
+ emit objectChanged();
+ }
+
+ QQmlListProperty<QObject> objectListProperty() { return QQmlListProperty<QObject>(this, m_objectQList); }
+
+ bool methodCalled() const { return m_methodCalled; }
+ bool methodIntCalled() const { return m_methodIntCalled; }
+
+ QString string() const { return m_string; }
+
+ static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
+ return new MyQmlAttachedObject(o);
+ }
+
+ int deleteOnSet() const { return 1; }
+ void setDeleteOnSet(int v) { if(v) delete this; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ int resettableProperty() const { return m_resetProperty; }
+ void setResettableProperty(int v) { m_resetProperty = v; }
+ void resetProperty() { m_resetProperty = 13; }
+
+ QRegExp regExp() { return m_regExp; }
+ void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
+
+ int console() const { return 11; }
+
+ int nonscriptable() const { return 0; }
+ void setNonscriptable(int) {}
+
+ MyQmlObject *myinvokableObject;
+ Q_INVOKABLE MyQmlObject *returnme() { return this; }
+
+ struct MyType {
+ int value;
+ };
+ QVariant variant() const { return m_variant; }
+ QJSValue qjsvalue() const { return m_qjsvalue; }
+
+ int intProperty() const { return m_intProperty; }
+ void setIntProperty(int i) { m_intProperty = i; emit intChanged(); }
+
+signals:
+ void basicSignal();
+ void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
+ void unnamedArgumentSignal(int a, qreal, QString c);
+ void stringChanged();
+ void urlChanged();
+ void objectChanged();
+ void anotherBasicSignal();
+ void thirdBasicSignal();
+ void signalWithUnknownType(const MyQmlObject::MyType &arg);
+ void signalWithVariant(const QVariant &arg);
+ void signalWithQJSValue(const QJSValue &arg);
+ void signalWithGlobalName(int parseInt);
+ void intChanged();
+
+public slots:
+ void deleteMe() { delete this; }
+ void methodNoArgs() { m_methodCalled = true; }
+ void method(int a) { if(a == 163) m_methodIntCalled = true; }
+ void setString(const QString &s) { m_string = s; }
+ void myinvokable(MyQmlObject *o) { myinvokableObject = o; }
+ void variantMethod(const QVariant &v) { m_variant = v; }
+ void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; }
+ void v8function(QQmlV8Function*);
+
+private:
+ friend class tst_qqmlecmascript;
+ bool m_methodCalled;
+ bool m_methodIntCalled;
+
+ QObject *m_object;
+ QString m_string;
+ QUrl m_url;
+ QList<QObject *> m_objectQList;
+ int m_value;
+ int m_resetProperty;
+ QRegExp m_regExp;
+ QVariant m_variant;
+ QJSValue m_qjsvalue;
+ int m_intProperty;
+};
+
+QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+
+class MyQmlContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<MyQmlObject> children READ children CONSTANT)
+public:
+ MyQmlContainer() {}
+
+ QQmlListProperty<MyQmlObject> children() { return QQmlListProperty<MyQmlObject>(this, m_children); }
+
+private:
+ QList<MyQmlObject*> m_children;
+};
+
+
+class MyExpression : public QQmlExpression
+{
+ Q_OBJECT
+public:
+ MyExpression(QQmlContext *ctxt, const QString &expr)
+ : QQmlExpression(ctxt, 0, expr), changed(false)
+ {
+ QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged()));
+ setNotifyOnValueChanged(true);
+ }
+
+ bool changed;
+
+public slots:
+ void expressionValueChanged() {
+ changed = true;
+ }
+};
+
+
+class MyDefaultObject1 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int horseLegs READ horseLegs CONSTANT)
+ Q_PROPERTY(int antLegs READ antLegs CONSTANT)
+ Q_PROPERTY(int emuLegs READ emuLegs CONSTANT)
+public:
+ int horseLegs() const { return 4; }
+ int antLegs() const { return 6; }
+ int emuLegs() const { return 2; }
+};
+
+class MyDefaultObject3 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int antLegs READ antLegs CONSTANT)
+ Q_PROPERTY(int humanLegs READ humanLegs CONSTANT)
+public:
+ int antLegs() const { return 7; } // Mutant
+ int humanLegs() const { return 2; }
+ int millipedeLegs() const { return 1000; }
+};
+
+class MyDeferredObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
+ Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2)
+ Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2")
+
+public:
+ MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; emit valueChanged(); }
+
+ QObject *objectProperty() const { return m_object; }
+ void setObjectProperty(QObject *obj) { m_object = obj; }
+
+ QObject *objectProperty2() const { return m_object2; }
+ void setObjectProperty2(QObject *obj) { m_object2 = obj; }
+
+signals:
+ void valueChanged();
+
+private:
+ int m_value;
+ QObject *m_object;
+ QObject *m_object2;
+};
+
+class MyBaseExtendedObject : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
+public:
+ MyBaseExtendedObject() : m_value(0) {}
+
+ int baseProperty() const { return m_value; }
+ void setBaseProperty(int v) { m_value = v; }
+
+private:
+ int m_value;
+};
+
+class MyExtendedObject : public MyBaseExtendedObject
+{
+Q_OBJECT
+Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty)
+public:
+ MyExtendedObject() : m_value(0) {}
+
+ int coreProperty() const { return m_value; }
+ void setCoreProperty(int v) { m_value = v; }
+
+private:
+ int m_value;
+};
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_FLAGS(MyFlags)
+
+ Q_PROPERTY(QString id READ id WRITE setId)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
+ Q_PROPERTY(QQmlComponent *componentProperty READ componentProperty WRITE setComponentProperty)
+ Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
+ Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
+ Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
+ Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
+ Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
+ Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
+ Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
+ Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
+ Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
+ Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
+ Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
+ Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
+ Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
+ Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
+ Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
+ Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
+ Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
+
+ Q_PROPERTY(QQmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
+
+public:
+ MyTypeObject()
+ : objectPropertyValue(0), componentPropertyValue(0) {}
+
+ QString idValue;
+ QString id() const {
+ return idValue;
+ }
+ void setId(const QString &v) {
+ idValue = v;
+ }
+
+ QObject *objectPropertyValue;
+ QObject *objectProperty() const {
+ return objectPropertyValue;
+ }
+ void setObjectProperty(QObject *v) {
+ objectPropertyValue = v;
+ }
+
+ QQmlComponent *componentPropertyValue;
+ QQmlComponent *componentProperty() const {
+ return componentPropertyValue;
+ }
+ void setComponentProperty(QQmlComponent *v) {
+ componentPropertyValue = v;
+ }
+
+ enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
+ Q_DECLARE_FLAGS(MyFlags, MyFlag)
+ MyFlags flagPropertyValue;
+ MyFlags flagProperty() const {
+ return flagPropertyValue;
+ }
+ void setFlagProperty(MyFlags v) {
+ flagPropertyValue = v;
+ }
+
+ enum MyEnum { EnumVal1, EnumVal2 };
+ MyEnum enumPropertyValue;
+ MyEnum enumProperty() const {
+ return enumPropertyValue;
+ }
+ void setEnumProperty(MyEnum v) {
+ enumPropertyValue = v;
+ }
+
+ QString stringPropertyValue;
+ QString stringProperty() const {
+ return stringPropertyValue;
+ }
+ void setStringProperty(const QString &v) {
+ stringPropertyValue = v;
+ }
+
+ uint uintPropertyValue;
+ uint uintProperty() const {
+ return uintPropertyValue;
+ }
+ void setUintProperty(const uint &v) {
+ uintPropertyValue = v;
+ }
+
+ int intPropertyValue;
+ int intProperty() const {
+ return intPropertyValue;
+ }
+ void setIntProperty(const int &v) {
+ intPropertyValue = v;
+ }
+
+ qreal realPropertyValue;
+ qreal realProperty() const {
+ return realPropertyValue;
+ }
+ void setRealProperty(const qreal &v) {
+ realPropertyValue = v;
+ }
+
+ double doublePropertyValue;
+ double doubleProperty() const {
+ return doublePropertyValue;
+ }
+ void setDoubleProperty(const double &v) {
+ doublePropertyValue = v;
+ }
+
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
+ QColor colorPropertyValue;
+ QColor colorProperty() const {
+ return colorPropertyValue;
+ }
+ void setColorProperty(const QColor &v) {
+ colorPropertyValue = v;
+ }
+
+ QDate datePropertyValue;
+ QDate dateProperty() const {
+ return datePropertyValue;
+ }
+ void setDateProperty(const QDate &v) {
+ datePropertyValue = v;
+ }
+
+ QTime timePropertyValue;
+ QTime timeProperty() const {
+ return timePropertyValue;
+ }
+ void setTimeProperty(const QTime &v) {
+ timePropertyValue = v;
+ }
+
+ QDateTime dateTimePropertyValue;
+ QDateTime dateTimeProperty() const {
+ return dateTimePropertyValue;
+ }
+ void setDateTimeProperty(const QDateTime &v) {
+ dateTimePropertyValue = v;
+ }
+
+ QPoint pointPropertyValue;
+ QPoint pointProperty() const {
+ return pointPropertyValue;
+ }
+ void setPointProperty(const QPoint &v) {
+ pointPropertyValue = v;
+ }
+
+ QPointF pointFPropertyValue;
+ QPointF pointFProperty() const {
+ return pointFPropertyValue;
+ }
+ void setPointFProperty(const QPointF &v) {
+ pointFPropertyValue = v;
+ }
+
+ QSize sizePropertyValue;
+ QSize sizeProperty() const {
+ return sizePropertyValue;
+ }
+ void setSizeProperty(const QSize &v) {
+ sizePropertyValue = v;
+ }
+
+ QSizeF sizeFPropertyValue;
+ QSizeF sizeFProperty() const {
+ return sizeFPropertyValue;
+ }
+ void setSizeFProperty(const QSizeF &v) {
+ sizeFPropertyValue = v;
+ }
+
+ QRect rectPropertyValue;
+ QRect rectProperty() const {
+ return rectPropertyValue;
+ }
+ void setRectProperty(const QRect &v) {
+ rectPropertyValue = v;
+ emit rectPropertyChanged();
+ }
+
+ QRect rectPropertyValue2;
+ QRect rectProperty2() const {
+ return rectPropertyValue2;
+ }
+ void setRectProperty2(const QRect &v) {
+ rectPropertyValue2 = v;
+ }
+
+ QRectF rectFPropertyValue;
+ QRectF rectFProperty() const {
+ return rectFPropertyValue;
+ }
+ void setRectFProperty(const QRectF &v) {
+ rectFPropertyValue = v;
+ }
+
+ bool boolPropertyValue;
+ bool boolProperty() const {
+ return boolPropertyValue;
+ }
+ void setBoolProperty(const bool &v) {
+ boolPropertyValue = v;
+ }
+
+ QVariant variantPropertyValue;
+ QVariant variantProperty() const {
+ return variantPropertyValue;
+ }
+ void setVariantProperty(const QVariant &v) {
+ variantPropertyValue = v;
+ }
+
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
+ QUrl urlPropertyValue;
+ QUrl urlProperty() const {
+ return urlPropertyValue;
+ }
+ void setUrlProperty(const QUrl &v) {
+ urlPropertyValue = v;
+ }
+
+ QQmlScriptString scriptPropertyValue;
+ QQmlScriptString scriptProperty() const {
+ return scriptPropertyValue;
+ }
+ void setScriptProperty(const QQmlScriptString &v) {
+ scriptPropertyValue = v;
+ }
+
+ void doAction() { emit action(); }
+signals:
+ void action();
+ void rectPropertyChanged();
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
+
+class MyDerivedObject : public MyTypeObject
+{
+ Q_OBJECT
+public:
+ Q_INVOKABLE bool intProperty() const {
+ return true;
+ }
+};
+
+Q_DECLARE_METATYPE(QJSValue);
+class MyInvokableBaseObject : public QObject
+{
+ Q_OBJECT
+public:
+ inline ~MyInvokableBaseObject() = 0;
+
+ Q_INVOKABLE inline void method_inherited(int a);
+ Q_INVOKABLE inline void method_overload();
+};
+
+class MyInvokableObject : public MyInvokableBaseObject
+{
+ Q_OBJECT
+ Q_ENUMS(TestEnum)
+public:
+ enum TestEnum { EnumValue1, EnumValue2 };
+ MyInvokableObject() { reset(); }
+
+ int invoked() const { return m_invoked; }
+ bool error() const { return m_invokedError; }
+ const QVariantList &actuals() const { return m_actuals; }
+ void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
+
+ Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
+ Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
+
+ 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.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; }
+ Q_INVOKABLE QJSValue method_NoArgs_QScriptValue() { invoke(6); return QJSValue("Hello world"); }
+ Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
+
+ Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
+ Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
+ Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
+ Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
+ Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
+ Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
+ Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
+ Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
+
+ Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
+ Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
+ Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; }
+
+ Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(19); m_actuals << (int)e; }
+
+ Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; }
+
+ Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; }
+
+private:
+ friend class MyInvokableBaseObject;
+ void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
+ int m_invoked;
+ bool m_invokedError;
+ QVariantList m_actuals;
+};
+
+MyInvokableBaseObject::~MyInvokableBaseObject() {}
+
+void MyInvokableBaseObject::method_inherited(int a)
+{
+ static_cast<MyInvokableObject *>(this)->invoke(-3);
+ static_cast<MyInvokableObject *>(this)->m_actuals << a;
+}
+
+// This is a hidden overload of the MyInvokableObject::method_overload() method
+void MyInvokableBaseObject::method_overload()
+{
+ static_cast<MyInvokableObject *>(this)->invoke(-2);
+}
+
+class NumberAssignment : public QObject
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(qreal test1 READ test1 WRITE setTest1)
+ qreal _test1;
+ qreal test1() const { return _test1; }
+ void setTest1(qreal v) { _test1 = v; }
+
+ Q_PROPERTY(qreal test2 READ test2 WRITE setTest2)
+ qreal _test2;
+ qreal test2() const { return _test2; }
+ void setTest2(qreal v) { _test2 = v; }
+
+ Q_PROPERTY(qreal test3 READ test3 WRITE setTest3)
+ qreal _test3;
+ qreal test3() const { return _test3; }
+ void setTest3(qreal v) { _test3 = v; }
+
+ Q_PROPERTY(qreal test4 READ test4 WRITE setTest4)
+ qreal _test4;
+ qreal test4() const { return _test4; }
+ void setTest4(qreal v) { _test4 = v; }
+
+ Q_PROPERTY(int test5 READ test5 WRITE setTest5)
+ int _test5;
+ int test5() const { return _test5; }
+ void setTest5(int v) { _test5 = v; }
+
+ Q_PROPERTY(int test6 READ test6 WRITE setTest6)
+ int _test6;
+ int test6() const { return _test6; }
+ void setTest6(int v) { _test6 = v; }
+
+ Q_PROPERTY(int test7 READ test7 WRITE setTest7)
+ int _test7;
+ int test7() const { return _test7; }
+ void setTest7(int v) { _test7 = v; }
+
+ Q_PROPERTY(int test8 READ test8 WRITE setTest8)
+ int _test8;
+ int test8() const { return _test8; }
+ void setTest8(int v) { _test8 = v; }
+
+ Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9)
+ unsigned int _test9;
+ unsigned int test9() const { return _test9; }
+ void setTest9(unsigned int v) { _test9 = v; }
+
+ Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10)
+ unsigned int _test10;
+ unsigned int test10() const { return _test10; }
+ void setTest10(unsigned int v) { _test10 = v; }
+
+ Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11)
+ unsigned int _test11;
+ unsigned int test11() const { return _test11; }
+ void setTest11(unsigned int v) { _test11 = v; }
+
+ Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12)
+ unsigned int _test12;
+ unsigned int test12() const { return _test12; }
+ void setTest12(unsigned int v) { _test12 = v; }
+};
+
+class DefaultPropertyExtendedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty)
+ Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty)
+public:
+ DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {}
+
+ QObject *firstProperty() const { return m_firstProperty; }
+ QObject *secondProperty() const { return m_secondProperty; }
+ void setFirstProperty(QObject *property) { m_firstProperty = property; }
+ void setSecondProperty(QObject *property) { m_secondProperty = property; }
+private:
+ QObject* m_firstProperty;
+ QObject* m_secondProperty;
+};
+
+class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("DefaultProperty", "secondProperty")
+public:
+ OverrideDefaultPropertyObject() {}
+};
+
+class MyRevisionedBaseClassRegistered : public QObject
+{
+Q_OBJECT
+ Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
+ Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
+
+public:
+ MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
+
+ qreal propA() const { return m_pa; }
+ void setPropA(qreal p) {
+ if (p != m_pa) {
+ m_pa = p;
+ emit propAChanged();
+ }
+ }
+ qreal propB() const { return m_pb; }
+ void setPropB(qreal p) {
+ if (p != m_pb) {
+ m_pb = p;
+ emit propBChanged();
+ }
+ }
+
+ Q_INVOKABLE void methodA() { }
+ Q_INVOKABLE Q_REVISION(1) void methodB() { }
+
+signals:
+ void propAChanged();
+ void propBChanged();
+
+ void signalA();
+ Q_REVISION(1) void signalB();
+
+protected:
+ qreal m_pa;
+ qreal m_pb;
+};
+
+class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
+{
+Q_OBJECT
+ Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
+ Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
+
+public:
+ MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
+
+ qreal propC() const { return m_pc; }
+ void setPropC(qreal p) {
+ if (p != m_pc) {
+ m_pc = p;
+ emit propCChanged();
+ }
+ }
+ qreal propD() const { return m_pd; }
+ void setPropD(qreal p) {
+ if (p != m_pd) {
+ m_pd = p;
+ emit propDChanged();
+ }
+ }
+
+ Q_INVOKABLE void methodC() { }
+ Q_INVOKABLE Q_REVISION(1) void methodD() { }
+
+signals:
+ void propCChanged();
+ void propDChanged();
+
+ void signalC();
+ Q_REVISION(1) void signalD();
+
+protected:
+ qreal m_pc;
+ qreal m_pd;
+};
+
+class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
+ Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
+
+public:
+ MyRevisionedClass() {}
+
+ qreal prop1() const { return m_p1; }
+ void setProp1(qreal p) {
+ if (p != m_p1) {
+ m_p1 = p;
+ emit prop1Changed();
+ }
+ }
+ qreal prop2() const { return m_p2; }
+ void setProp2(qreal p) {
+ if (p != m_p2) {
+ m_p2 = p;
+ emit prop2Changed();
+ }
+ }
+
+ Q_INVOKABLE void method1() { }
+ Q_INVOKABLE Q_REVISION(1) void method2() { }
+
+signals:
+ void prop1Changed();
+ void prop2Changed();
+
+ void signal1();
+ Q_REVISION(1) void signal2();
+
+protected:
+ qreal m_p1;
+ qreal m_p2;
+};
+
+class MyRevisionedSubclass : public MyRevisionedClass
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
+ Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
+
+public:
+ MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
+
+ qreal prop3() const { return m_p3; }
+ void setProp3(qreal p) {
+ if (p != m_p3) {
+ m_p3 = p;
+ emit prop3Changed();
+ }
+ }
+ qreal prop4() const { return m_p4; }
+ void setProp4(qreal p) {
+ if (p != m_p4) {
+ m_p4 = p;
+ emit prop4Changed();
+ }
+ }
+
+ Q_INVOKABLE void method3() { }
+ Q_INVOKABLE Q_REVISION(1) void method4() { }
+
+signals:
+ void prop3Changed();
+ void prop4Changed();
+
+ void signal3();
+ Q_REVISION(1) void signal4();
+
+protected:
+ qreal m_p3;
+ qreal m_p4;
+};
+
+QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
+QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
+QML_DECLARE_TYPE(MyRevisionedClass)
+QML_DECLARE_TYPE(MyRevisionedSubclass)
+Q_DECLARE_METATYPE(MyQmlObject::MyType)
+
+
+class ScarceResourceObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QPixmap scarceResource READ scarceResource WRITE setScarceResource NOTIFY scarceResourceChanged)
+public:
+ ScarceResourceObject(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); }
+ ~ScarceResourceObject() {}
+
+ QPixmap scarceResource() const { return m_value; }
+ void setScarceResource(QPixmap v) { m_value = v; emit scarceResourceChanged(); }
+
+ bool scarceResourceIsDetached() const { return m_value.isDetached(); }
+
+ // this particular one returns a new one each time
+ // this means that every Scarce Resource Copy will
+ // consume resources (so that we can track disposal
+ // of v8 handles with circular references).
+ Q_INVOKABLE QPixmap newScarceResource() const
+ {
+ QPixmap retn(800, 600);
+ retn.fill(QColor(100, 110, 120, 45));
+ return retn;
+ }
+
+signals:
+ void scarceResourceChanged();
+
+private:
+ QPixmap m_value;
+};
+QML_DECLARE_TYPE(ScarceResourceObject)
+
+class testQObjectApi : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged)
+ Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged)
+
+public:
+ testQObjectApi(QObject* parent = 0)
+ : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_methodCallCount(0)
+ {
+ }
+
+ ~testQObjectApi() {}
+
+ enum MyEnum { EnumValue1 = 25, EnumValue2 = 42 };
+ Q_INVOKABLE int qobjectEnumTestMethod(MyEnum val) { return (static_cast<int>(val) + 5); }
+ Q_INVOKABLE int qobjectTestMethod(int increment = 1) { m_methodCallCount += increment; return m_methodCallCount; }
+
+ int qobjectTestProperty() const { return m_testProperty; }
+ void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); }
+
+ int qobjectTestWritableProperty() const { return m_testWritableProperty; }
+ void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); }
+
+signals:
+ void qobjectTestPropertyChanged(int testProperty);
+ void qobjectTestWritablePropertyChanged(int testWritableProperty);
+
+private:
+ int m_testProperty;
+ int m_testWritableProperty;
+ int m_methodCallCount;
+};
+
+class CircularReferenceObject : public QObject,
+ public QV8GCCallback::Node
+{
+ Q_OBJECT
+
+public:
+ CircularReferenceObject(QObject *parent = 0)
+ : QObject(parent), QV8GCCallback::Node(callback), m_referenced(0), m_dtorCount(0)
+ {
+ QV8GCCallback::addGcCallbackNode(this);
+ }
+
+ ~CircularReferenceObject()
+ {
+ if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
+ }
+
+ Q_INVOKABLE void setDtorCount(int *dtorCount)
+ {
+ m_dtorCount = dtorCount;
+ }
+
+ Q_INVOKABLE CircularReferenceObject *generate(QObject *parent = 0)
+ {
+ CircularReferenceObject *retn = new CircularReferenceObject(parent);
+ retn->m_dtorCount = m_dtorCount;
+ retn->m_engine = m_engine;
+ return retn;
+ }
+
+ Q_INVOKABLE void addReference(QObject *other)
+ {
+ m_referenced = other;
+ }
+
+ static void callback(QV8GCCallback::Node *n)
+ {
+ CircularReferenceObject *cro = static_cast<CircularReferenceObject*>(n);
+ if (cro->m_referenced) {
+ cro->m_engine->addRelationshipForGC(cro, cro->m_referenced);
+ }
+ }
+
+ void setEngine(QQmlEngine* declarativeEngine)
+ {
+ m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine();
+ }
+
+private:
+ QObject *m_referenced;
+ int *m_dtorCount;
+ QV8Engine* m_engine;
+};
+Q_DECLARE_METATYPE(CircularReferenceObject*)
+
+class CircularReferenceHandle : public QObject,
+ public QV8GCCallback::Node
+{
+ Q_OBJECT
+
+public:
+ CircularReferenceHandle(QObject *parent = 0)
+ : QObject(parent), QV8GCCallback::Node(gccallback), m_dtorCount(0), m_engine(0)
+ {
+ QV8GCCallback::addGcCallbackNode(this);
+ }
+
+ ~CircularReferenceHandle()
+ {
+ if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
+ }
+
+ Q_INVOKABLE void setDtorCount(int *dtorCount)
+ {
+ m_dtorCount = dtorCount;
+ }
+
+ Q_INVOKABLE CircularReferenceHandle *generate(QObject *parent = 0)
+ {
+ CircularReferenceHandle *retn = new CircularReferenceHandle(parent);
+ retn->m_dtorCount = m_dtorCount;
+ retn->m_engine = m_engine;
+ return retn;
+ }
+
+ Q_INVOKABLE void addReference(v8::Persistent<v8::Value> handle)
+ {
+ m_referenced = qPersistentNew(handle);
+ m_referenced.MakeWeak(static_cast<void*>(this), wrcallback);
+ }
+
+ static void wrcallback(v8::Persistent<v8::Value> handle, void *params)
+ {
+ CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(params);
+ qPersistentDispose(handle);
+ crh->m_referenced.Clear();
+ }
+
+ static void gccallback(QV8GCCallback::Node *n)
+ {
+ CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(n);
+ crh->m_engine->addRelationshipForGC(crh, crh->m_referenced);
+ }
+
+ void setEngine(QQmlEngine* declarativeEngine)
+ {
+ m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine();
+ }
+
+private:
+ v8::Persistent<v8::Value> m_referenced;
+ int *m_dtorCount;
+ QV8Engine* m_engine;
+};
+Q_DECLARE_METATYPE(CircularReferenceHandle*)
+
+class MyDynamicCreationDestructionObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY (int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged)
+
+public:
+ MyDynamicCreationDestructionObject(QObject *parent = 0) : QObject(parent), m_intProperty(0), m_dtorCount(0)
+ {
+ }
+
+ ~MyDynamicCreationDestructionObject()
+ {
+ if (m_dtorCount) {
+ (*m_dtorCount)++;
+ }
+ }
+
+ int intProperty() const { return m_intProperty; }
+ void setIntProperty(int val) { m_intProperty = val; emit intPropertyChanged(); }
+
+ Q_INVOKABLE MyDynamicCreationDestructionObject *createNew()
+ {
+ // no parent == ownership transfers to JS; same dtor counter.
+ MyDynamicCreationDestructionObject *retn = new MyDynamicCreationDestructionObject;
+ retn->setDtorCount(m_dtorCount);
+ return retn;
+ }
+
+ void setDtorCount(int *dtorCount)
+ {
+ m_dtorCount = dtorCount;
+ }
+
+signals:
+ void intPropertyChanged();
+
+private:
+ int m_intProperty;
+ int *m_dtorCount;
+};
+
+class WriteCounter : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue);
+public:
+ WriteCounter() : m_value(0), m_count(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; ++m_count; }
+
+ int count() const { return m_count; }
+
+private:
+ int m_value;
+ int m_count;
+};
+
+class MySequenceConversionObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY (QList<int> intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged)
+ Q_PROPERTY (QList<int> intListProperty2 READ intListProperty2 WRITE setIntListProperty2 NOTIFY intListProperty2Changed)
+ Q_PROPERTY (QList<qreal> qrealListProperty READ qrealListProperty WRITE setQrealListProperty NOTIFY qrealListPropertyChanged)
+ Q_PROPERTY (QList<bool> boolListProperty READ boolListProperty WRITE setBoolListProperty NOTIFY boolListPropertyChanged)
+ Q_PROPERTY (QList<QString> stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged)
+ Q_PROPERTY (QList<QUrl> urlListProperty READ urlListProperty WRITE setUrlListProperty NOTIFY urlListPropertyChanged)
+ Q_PROPERTY (QStringList qstringListProperty READ qstringListProperty WRITE setQStringListProperty NOTIFY qstringListPropertyChanged)
+
+ Q_PROPERTY (QList<QPoint> pointListProperty READ pointListProperty WRITE setPointListProperty NOTIFY pointListPropertyChanged)
+ Q_PROPERTY (QList<QVariant> variantListProperty READ variantListProperty WRITE setVariantListProperty NOTIFY variantListPropertyChanged)
+
+ Q_PROPERTY (qint32 maxIndex READ maxIndex CONSTANT)
+ Q_PROPERTY (quint32 tooBigIndex READ tooBigIndex CONSTANT)
+ Q_PROPERTY (qint32 negativeIndex READ negativeIndex CONSTANT)
+
+public:
+ MySequenceConversionObject()
+ {
+ m_intList << 1 << 2 << 3 << 4;
+ m_intList2 << 1 << 2 << 3 << 4;
+ m_qrealList << 1.1 << 2.2 << 3.3 << 4.4;
+ m_boolList << true << false << true << false;
+ m_stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
+ m_urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
+ m_qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
+
+ m_pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6);
+ m_variantList << QVariant(QLatin1String("one")) << QVariant(true) << QVariant(3);
+ }
+
+ ~MySequenceConversionObject() {}
+
+ qint32 maxIndex() const
+ {
+ return INT_MAX;
+ }
+ quint32 tooBigIndex() const
+ {
+ quint32 retn = 7;
+ retn += INT_MAX;
+ return retn;
+ }
+ qint32 negativeIndex() const
+ {
+ return -5;
+ }
+
+ QList<int> intListProperty() const { return m_intList; }
+ void setIntListProperty(const QList<int> &list) { m_intList = list; emit intListPropertyChanged(); }
+ QList<int> intListProperty2() const { return m_intList2; }
+ void setIntListProperty2(const QList<int> &list) { m_intList2 = list; emit intListProperty2Changed(); }
+ QList<qreal> qrealListProperty() const { return m_qrealList; }
+ void setQrealListProperty(const QList<qreal> &list) { m_qrealList = list; emit qrealListPropertyChanged(); }
+ QList<bool> boolListProperty() const { return m_boolList; }
+ void setBoolListProperty(const QList<bool> &list) { m_boolList = list; emit boolListPropertyChanged(); }
+ QList<QString> stringListProperty() const { return m_stringList; }
+ void setStringListProperty(const QList<QString> &list) { m_stringList = list; emit stringListPropertyChanged(); }
+ QList<QUrl> urlListProperty() const { return m_urlList; }
+ void setUrlListProperty(const QList<QUrl> &list) { m_urlList = list; emit urlListPropertyChanged(); }
+ QStringList qstringListProperty() const { return m_qstringList; }
+ void setQStringListProperty(const QStringList &list) { m_qstringList = list; emit qstringListPropertyChanged(); }
+ QList<QPoint> pointListProperty() const { return m_pointList; }
+ void setPointListProperty(const QList<QPoint> &list) { m_pointList = list; emit pointListPropertyChanged(); }
+ QList<QVariant> variantListProperty() const { return m_variantList; }
+ void setVariantListProperty(const QList<QVariant> &list) { m_variantList = list; emit variantListPropertyChanged(); }
+
+ // now for "copy resource" sequences:
+ Q_INVOKABLE QList<int> generateIntSequence() const { QList<int> retn; retn << 1 << 2 << 3; return retn; }
+ Q_INVOKABLE QList<qreal> generateQrealSequence() const { QList<qreal> retn; retn << 1.1 << 2.2 << 3.3; return retn; }
+ Q_INVOKABLE QList<bool> generateBoolSequence() const { QList<bool> retn; retn << true << false << true; return retn; }
+ Q_INVOKABLE QList<QString> generateStringSequence() const { QList<QString> retn; retn << "one" << "two" << "three"; return retn; }
+ Q_INVOKABLE QList<QUrl> generateUrlSequence() const { QList<QUrl> retn; retn << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); return retn; }
+ Q_INVOKABLE QStringList generateQStringSequence() const { QStringList retn; retn << "one" << "two" << "three"; return retn; }
+
+ // "reference resource" underlying qobject deletion test:
+ Q_INVOKABLE MySequenceConversionObject *generateTestObject() const { return new MySequenceConversionObject; }
+ Q_INVOKABLE void deleteTestObject(QObject *object) const { delete object; }
+
+signals:
+ void intListPropertyChanged();
+ void intListProperty2Changed();
+ void qrealListPropertyChanged();
+ void boolListPropertyChanged();
+ void stringListPropertyChanged();
+ void urlListPropertyChanged();
+ void qstringListPropertyChanged();
+ void pointListPropertyChanged();
+ void variantListPropertyChanged();
+
+private:
+ QList<int> m_intList;
+ QList<int> m_intList2;
+ QList<qreal> m_qrealList;
+ QList<bool> m_boolList;
+ QList<QString> m_stringList;
+ QList<QUrl> m_urlList;
+ QStringList m_qstringList;
+
+ QList<QPoint> m_pointList; // not a supported sequence type
+ QList<QVariant> m_variantList; // not a supported sequence type, but QVariantList support is hardcoded.
+};
+
+class MyDeleteObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *nestedObject READ nestedObject NOTIFY nestedObjectChanged);
+ Q_PROPERTY(int deleteNestedObject READ deleteNestedObject NOTIFY deleteNestedObjectChanged);
+
+public:
+ MyDeleteObject() : m_nestedObject(new MyQmlObject) {}
+
+ QObject *nestedObject() const { return m_nestedObject; }
+ int deleteNestedObject() { delete m_nestedObject; m_nestedObject = 0; return 1; }
+
+signals:
+ void nestedObjectChanged();
+ void deleteNestedObjectChanged();
+
+private:
+ MyQmlObject *m_nestedObject;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
+
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
new file mode 100644
index 0000000000..676557a81c
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -0,0 +1,6097 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdebug.h>
+#include <QtQml/private/qqmlguard_p.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qnumeric.h>
+#include <private/qqmlengine_p.h>
+#include <private/qqmlvmemetaobject_p.h>
+#include <private/qv4compiler_p.h>
+#include "testtypes.h"
+#include "testhttpserver.h"
+#include "../../shared/util.h"
+
+/*
+This test covers evaluation of ECMAScript expressions and bindings from within
+QML. This does not include static QML language issues.
+
+Static QML language issues are covered in qmllanguage
+*/
+
+class tst_qqmlecmascript : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlecmascript() {}
+
+private slots:
+ void initTestCase();
+ void assignBasicTypes();
+ void idShortcutInvalidates();
+ void boolPropertiesEvaluateAsBool();
+ void methods();
+ void signalAssignment();
+ void bindingLoop();
+ void basicExpressions();
+ void basicExpressions_data();
+ void arrayExpressions();
+ void contextPropertiesTriggerReeval();
+ void objectPropertiesTriggerReeval();
+ void deferredProperties();
+ void deferredPropertiesErrors();
+ void extensionObjects();
+ void overrideExtensionProperties();
+ void attachedProperties();
+ void enums();
+ void valueTypeFunctions();
+ void constantsOverrideBindings();
+ void outerBindingOverridesInnerBinding();
+ void aliasPropertyAndBinding();
+ void aliasPropertyReset();
+ void nonExistentAttachedObject();
+ void scope();
+ void importScope();
+ void signalParameterTypes();
+ void objectsCompareAsEqual();
+ void dynamicCreation_data();
+ void dynamicCreation();
+ void dynamicDestruction();
+ void objectToString();
+ void objectHasOwnProperty();
+ void selfDeletingBinding();
+ void extendedObjectPropertyLookup();
+ void extendedObjectPropertyLookup2();
+ void scriptErrors();
+ void functionErrors();
+ void propertyAssignmentErrors();
+ void signalTriggeredBindings();
+ void listProperties();
+ void exceptionClearsOnReeval();
+ void exceptionSlotProducesWarning();
+ void exceptionBindingProducesWarning();
+ void compileInvalidBinding();
+ void transientErrors();
+ void shutdownErrors();
+ void compositePropertyType();
+ void jsObject();
+ void undefinedResetsProperty();
+ void listToVariant();
+ void listAssignment();
+ void multiEngineObject();
+ void deletedObject();
+ void attachedPropertyScope();
+ void scriptConnect();
+ void scriptDisconnect();
+ void ownership();
+ void cppOwnershipReturnValue();
+ void ownershipCustomReturnValue();
+ void qlistqobjectMethods();
+ void strictlyEquals();
+ void compiled();
+ void numberAssignment();
+ void propertySplicing();
+ void signalWithUnknownTypes();
+ void signalWithJSValueInVariant_data();
+ void signalWithJSValueInVariant();
+ void signalWithJSValueInVariant_twoEngines_data();
+ void signalWithJSValueInVariant_twoEngines();
+ void signalWithQJSValue_data();
+ void signalWithQJSValue();
+ void moduleApi_data();
+ void moduleApi();
+ void importScripts_data();
+ void importScripts();
+ void scarceResources();
+ void scarceResources_data();
+ void scarceResources_other();
+ void propertyChangeSlots();
+ void propertyVar_data();
+ void propertyVar();
+ void propertyVarCpp();
+ void propertyVarOwnership();
+ void propertyVarImplicitOwnership();
+ void propertyVarReparent();
+ void propertyVarReparentNullContext();
+ void propertyVarCircular();
+ void propertyVarCircular2();
+ void propertyVarInheritance();
+ void propertyVarInheritance2();
+ void elementAssign();
+ void objectPassThroughSignals();
+ void objectConversion();
+ void booleanConversion();
+ void handleReferenceManagement();
+ void stringArg();
+ void readonlyDeclaration();
+ void sequenceConversionRead();
+ void sequenceConversionWrite();
+ void sequenceConversionArray();
+ void sequenceConversionIndexes();
+ void sequenceConversionThreads();
+ void sequenceConversionBindings();
+ void sequenceConversionCopy();
+ void assignSequenceTypes();
+ void qtbug_22464();
+ void qtbug_21580();
+
+ void bug1();
+ void bug2();
+ void dynamicCreationCrash();
+ void dynamicCreationOwnership();
+ void regExpBug();
+ void nullObjectBinding();
+ void deletedEngine();
+ void libraryScriptAssert();
+ void variantsAssignedUndefined();
+ void qtbug_9792();
+ void qtcreatorbug_1289();
+ void noSpuriousWarningsAtShutdown();
+ void canAssignNullToQObject();
+ void functionAssignment_fromBinding();
+ void functionAssignment_fromJS();
+ void functionAssignment_fromJS_data();
+ void functionAssignmentfromJS_invalid();
+ void eval();
+ void function();
+ void functionException();
+ void qtbug_10696();
+ void qtbug_11606();
+ void qtbug_11600();
+ void qtbug_21864();
+ void qobjectConnectionListExceptionHandling();
+ void nonscriptable();
+ void deleteLater();
+ void in();
+ void typeOf();
+ void sharedAttachedObject();
+ void objectName();
+ void writeRemovesBinding();
+ void aliasBindingsAssignCorrectly();
+ void aliasBindingsOverrideTarget();
+ void aliasWritesOverrideBindings();
+ void aliasToCompositeElement();
+ void realToInt();
+ void urlProperty();
+ void urlPropertyWithEncoding();
+ void urlListPropertyWithEncoding();
+ void dynamicString();
+ void include();
+ void signalHandlers();
+ void doubleEvaluate();
+ void forInLoop();
+ void nonNotifyable();
+ void deleteWhileBindingRunning();
+ void callQtInvokables();
+ void invokableObjectArg();
+ void invokableObjectRet();
+ void qtbug_20344();
+ void qtbug_22679();
+ void qtbug_22843_data();
+ void qtbug_22843();
+ void rewriteMultiLineStrings();
+ void revisionErrors();
+ void revision();
+ void invokableWithQObjectDerived();
+
+ void automaticSemicolon();
+ void unaryExpression();
+ void switchStatement();
+ void withStatement();
+ void tryStatement();
+
+private:
+ static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
+ QQmlEngine engine;
+};
+
+void tst_qqmlecmascript::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+}
+
+void tst_qqmlecmascript::assignBasicTypes()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ 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));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("assignBasicTypes.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ 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));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::idShortcutInvalidates()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("idShortcutInvalidates.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->objectProperty() != 0);
+ delete object->objectProperty();
+ QVERIFY(object->objectProperty() == 0);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("idShortcutInvalidates.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->objectProperty() != 0);
+ delete object->objectProperty();
+ QVERIFY(object->objectProperty() == 0);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::boolPropertiesEvaluateAsBool()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::signalAssignment()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->basicSignal();
+ QCOMPARE(object->string(), QString("pass"));
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->unnamedArgumentSignal(19, 10.25, "Hello world!");
+ QEXPECT_FAIL("", "QTBUG-24481", Continue);
+ QCOMPARE(object->string(), QString("pass 19 Hello world!"));
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->signalWithGlobalName(19);
+ QCOMPARE(object->string(), QString("pass 5"));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::methods()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), false);
+ emit object->basicSignal();
+ QCOMPARE(object->methodCalled(), true);
+ QCOMPARE(object->methodIntCalled(), false);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), false);
+ emit object->basicSignal();
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), true);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 19);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 19);
+ QCOMPARE(object->property("test2").toInt(), 17);
+ QCOMPARE(object->property("test3").toInt(), 16);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 9);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::bindingLoop()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingLoop.qml"));
+ QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\"";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::basicExpressions_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QVariant>("result");
+ QTest::addColumn<bool>("nest");
+
+ QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false;
+ QTest::newRow("Context property") << "a" << QVariant(1944) << false;
+ QTest::newRow("Context property") << "a" << QVariant(1944) << true;
+ QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false;
+ QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << true;
+ QTest::newRow("Overridden context property") << "b" << QVariant("Milk") << false;
+ QTest::newRow("Overridden context property") << "b" << QVariant("Cow") << true;
+ QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << false;
+ QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << true;
+ QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object2") << false;
+ QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object3") << true;
+ QTest::newRow("Default object property") << "horseLegs" << QVariant(4) << false;
+ QTest::newRow("Default object property") << "antLegs" << QVariant(6) << false;
+ QTest::newRow("Default object property") << "emuLegs" << QVariant(2) << false;
+ QTest::newRow("Nested default object property") << "horseLegs" << QVariant(4) << true;
+ QTest::newRow("Nested default object property") << "antLegs" << QVariant(7) << true;
+ QTest::newRow("Nested default object property") << "emuLegs" << QVariant(2) << true;
+ QTest::newRow("Nested default object property") << "humanLegs" << QVariant(2) << true;
+ QTest::newRow("Context property override default object property") << "millipedeLegs" << QVariant(100) << true;
+}
+
+void tst_qqmlecmascript::basicExpressions()
+{
+ QFETCH(QString, expression);
+ QFETCH(QVariant, result);
+ QFETCH(bool, nest);
+
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject object3;
+ MyDefaultObject1 default1;
+ MyDefaultObject3 default3;
+ object1.setStringProperty("Object1");
+ object2.setStringProperty("Object2");
+ object3.setStringProperty("Object3");
+
+ QQmlContext context(engine.rootContext());
+ QQmlContext nestedContext(&context);
+
+ context.setContextObject(&default1);
+ context.setContextProperty("a", QVariant(1944));
+ context.setContextProperty("b", QVariant("Milk"));
+ context.setContextProperty("object", &object1);
+ context.setContextProperty("objectOverride", &object2);
+ nestedContext.setContextObject(&default3);
+ nestedContext.setContextProperty("b", QVariant("Cow"));
+ nestedContext.setContextProperty("objectOverride", &object3);
+ nestedContext.setContextProperty("millipedeLegs", QVariant(100));
+
+ MyExpression expr(nest?&nestedContext:&context, expression);
+ QCOMPARE(expr.evaluate(), result);
+}
+
+void tst_qqmlecmascript::arrayExpressions()
+{
+ QObject obj1;
+ QObject obj2;
+ QObject obj3;
+
+ QQmlContext context(engine.rootContext());
+ context.setContextProperty("a", &obj1);
+ context.setContextProperty("b", &obj2);
+ context.setContextProperty("c", &obj3);
+
+ MyExpression expr(&context, "[a, b, c, 10]");
+ QVariant result = expr.evaluate();
+ QCOMPARE(result.userType(), qMetaTypeId<QList<QObject *> >());
+ QList<QObject *> list = qvariant_cast<QList<QObject *> >(result);
+ QCOMPARE(list.count(), 4);
+ QCOMPARE(list.at(0), &obj1);
+ QCOMPARE(list.at(1), &obj2);
+ QCOMPARE(list.at(2), &obj3);
+ QCOMPARE(list.at(3), (QObject *)0);
+}
+
+// Tests that modifying a context property will reevaluate expressions
+void tst_qqmlecmascript::contextPropertiesTriggerReeval()
+{
+ QQmlContext context(engine.rootContext());
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject *object3 = new MyQmlObject;
+
+ object1.setStringProperty("Hello");
+ object2.setStringProperty("World");
+
+ context.setContextProperty("testProp", QVariant(1));
+ context.setContextProperty("testObj", &object1);
+ context.setContextProperty("testObj2", object3);
+
+ {
+ MyExpression expr(&context, "testProp + 1");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant(2));
+
+ context.setContextProperty("testProp", QVariant(2));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant(3));
+ }
+
+ {
+ MyExpression expr(&context, "testProp + testProp + testProp");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant(6));
+
+ context.setContextProperty("testProp", QVariant(4));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant(12));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
+
+ context.setContextProperty("testObj", &object2);
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant("World"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty /**/");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant("World"));
+
+ context.setContextProperty("testObj", &object1);
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj2");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant::fromValue((QObject *)object3));
+ }
+
+ delete object3;
+}
+
+void tst_qqmlecmascript::objectPropertiesTriggerReeval()
+{
+ QQmlContext context(engine.rootContext());
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject object3;
+ context.setContextProperty("testObj", &object1);
+
+ object1.setStringProperty(QLatin1String("Hello"));
+ object2.setStringProperty(QLatin1String("Dog"));
+ object3.setStringProperty(QLatin1String("Cat"));
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
+
+ object1.setStringProperty(QLatin1String("World"));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant("World"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.objectProperty.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant());
+
+ object1.setObjectProperty(&object2);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant("Dog"));
+
+ object1.setObjectProperty(&object3);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant("Cat"));
+
+ object1.setObjectProperty(0);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant());
+
+ object1.setObjectProperty(&object3);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant("Cat"));
+
+ object3.setStringProperty("Donkey");
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant("Donkey"));
+ }
+}
+
+void tst_qqmlecmascript::deferredProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("deferredProperties.qml"));
+ MyDeferredObject *object =
+ qobject_cast<MyDeferredObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->value(), 0);
+ QVERIFY(object->objectProperty() == 0);
+ QVERIFY(object->objectProperty2() != 0);
+ qmlExecuteDeferred(object);
+ QCOMPARE(object->value(), 10);
+ QVERIFY(object->objectProperty() != 0);
+ MyQmlObject *qmlObject =
+ qobject_cast<MyQmlObject *>(object->objectProperty());
+ QVERIFY(qmlObject != 0);
+ QCOMPARE(qmlObject->value(), 10);
+ object->setValue(19);
+ QCOMPARE(qmlObject->value(), 19);
+
+ delete object;
+}
+
+// Check errors on deferred properties are correctly emitted
+void tst_qqmlecmascript::deferredPropertiesErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml"));
+ MyDeferredObject *object =
+ qobject_cast<MyDeferredObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->value(), 0);
+ QVERIFY(object->objectProperty() == 0);
+ QVERIFY(object->objectProperty2() == 0);
+
+ QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ qmlExecuteDeferred(object);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::extensionObjects()
+{
+ QQmlComponent component(&engine, testFileUrl("extensionObjects.qml"));
+ MyExtendedObject *object =
+ qobject_cast<MyExtendedObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->baseProperty(), 13);
+ QCOMPARE(object->coreProperty(), 9);
+ object->setProperty("extendedProperty", QVariant(11));
+ object->setProperty("baseExtendedProperty", QVariant(92));
+ QCOMPARE(object->coreProperty(), 11);
+ QCOMPARE(object->baseProperty(), 92);
+
+ MyExtendedObject *nested = qobject_cast<MyExtendedObject*>(qvariant_cast<QObject *>(object->property("nested")));
+ QVERIFY(nested);
+ QCOMPARE(nested->baseProperty(), 13);
+ QCOMPARE(nested->coreProperty(), 9);
+ nested->setProperty("extendedProperty", QVariant(11));
+ nested->setProperty("baseExtendedProperty", QVariant(92));
+ QCOMPARE(nested->coreProperty(), 11);
+ QCOMPARE(nested->baseProperty(), 92);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::overrideExtensionProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("extensionObjectsPropertyOverride.qml"));
+ OverrideDefaultPropertyObject *object =
+ qobject_cast<OverrideDefaultPropertyObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->secondProperty() != 0);
+ QVERIFY(object->firstProperty() == 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::attachedProperties()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("attachedProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 19);
+ QCOMPARE(object->property("b").toInt(), 19);
+ QCOMPARE(object->property("c").toInt(), 19);
+ QCOMPARE(object->property("d").toInt(), 19);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("attachedProperty.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 26);
+ QCOMPARE(object->property("b").toInt(), 26);
+ QCOMPARE(object->property("c").toInt(), 26);
+ QCOMPARE(object->property("d").toInt(), 26);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("writeAttachedProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "writeValue2");
+
+ MyQmlAttachedObject *attached =
+ qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
+ QVERIFY(attached != 0);
+
+ QCOMPARE(attached->value2(), 9);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::enums()
+{
+ // Existent enums
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 1);
+ QCOMPARE(object->property("c").toInt(), 2);
+ QCOMPARE(object->property("d").toInt(), 3);
+ QCOMPARE(object->property("e").toInt(), 0);
+ QCOMPARE(object->property("f").toInt(), 1);
+ QCOMPARE(object->property("g").toInt(), 2);
+ QCOMPARE(object->property("h").toInt(), 3);
+ QCOMPARE(object->property("i").toInt(), 19);
+ QCOMPARE(object->property("j").toInt(), 19);
+
+ delete object;
+ }
+ // Non-existent enums
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.2.qml"));
+
+ QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
+ QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 0);
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::valueTypeFunctions()
+{
+ QQmlComponent component(&engine, testFileUrl("valueTypeFunctions.qml"));
+ MyTypeObject *obj = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->rectProperty(), QRect(0,0,100,100));
+ QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5));
+
+ delete obj;
+}
+
+/*
+Tests that writing a constant to a property with a binding on it disables the
+binding.
+*/
+void tst_qqmlecmascript::constantsOverrideBindings()
+{
+ // From ECMAScript
+ {
+ QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ emit object->basicSignal();
+
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(8));
+ QCOMPARE(object->property("c2").toInt(), 13);
+
+ delete object;
+ }
+
+ // During construction
+ {
+ QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 10);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 10);
+
+ delete object;
+ }
+
+#if 0
+ // From C++
+ {
+ QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ object->setProperty("c2", QVariant(13));
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(7));
+ QCOMPARE(object->property("c1").toInt(), 7);
+ QCOMPARE(object->property("c2").toInt(), 13);
+
+ delete object;
+ }
+#endif
+
+ // Using an alias
+ {
+ QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 10);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c3").toInt(), 10);
+
+ delete object;
+ }
+}
+
+/*
+Tests that assigning a binding to a property that already has a binding causes
+the original binding to be disabled.
+*/
+void tst_qqmlecmascript::outerBindingOverridesInnerBinding()
+{
+ QQmlComponent component(&engine,
+ testFileUrl("outerBindingOverridesInnerBinding.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c3", QVariant(8));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 8);
+ QCOMPARE(object->property("c3").toInt(), 8);
+
+ delete object;
+}
+
+/*
+Access a non-existent attached object.
+
+Tests for a regression where this used to crash.
+*/
+void tst_qqmlecmascript::nonExistentAttachedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml"));
+
+ QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::scope()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 1);
+ QCOMPARE(object->property("test2").toInt(), 2);
+ QCOMPARE(object->property("test3").toString(), QString("1Test"));
+ QCOMPARE(object->property("test4").toString(), QString("2Test"));
+ QCOMPARE(object->property("test5").toInt(), 1);
+ QCOMPARE(object->property("test6").toInt(), 1);
+ QCOMPARE(object->property("test7").toInt(), 2);
+ QCOMPARE(object->property("test8").toInt(), 2);
+ QCOMPARE(object->property("test9").toInt(), 1);
+ QCOMPARE(object->property("test10").toInt(), 3);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 19);
+ QCOMPARE(object->property("test2").toInt(), 19);
+ QCOMPARE(object->property("test3").toInt(), 14);
+ QCOMPARE(object->property("test4").toInt(), 14);
+ QCOMPARE(object->property("test5").toInt(), 24);
+ QCOMPARE(object->property("test6").toInt(), 24);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+
+ delete object;
+ }
+
+ // Signal argument scope
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ QCOMPARE(object->property("test2").toString(), QString());
+
+ emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton);
+
+ QCOMPARE(object->property("test").toInt(), 13);
+ QCOMPARE(object->property("test2").toString(), QString("Argument Scope"));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.6.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+}
+
+// In 4.7, non-library javascript files that had no imports shared the imports of their
+// importing context
+void tst_qqmlecmascript::importScope()
+{
+ QQmlComponent component(&engine, testFileUrl("importScope.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toInt(), 240);
+
+ delete o;
+}
+
+/*
+Tests that "any" type passes through a synthesized signal parameter. This
+is essentially a test of QQmlMetaType::copy()
+*/
+void tst_qqmlecmascript::signalParameterTypes()
+{
+ QQmlComponent component(&engine, testFileUrl("signalParameterTypes.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ emit object->basicSignal();
+
+ QCOMPARE(object->property("intProperty").toInt(), 10);
+ QCOMPARE(object->property("realProperty").toReal(), 19.2);
+ QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
+ QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
+ QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3);
+ QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton);
+
+ delete object;
+}
+
+/*
+Test that two JS objects for the same QObject compare as equal.
+*/
+void tst_qqmlecmascript::objectsCompareAsEqual()
+{
+ QQmlComponent component(&engine, testFileUrl("objectsCompareAsEqual.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+ QCOMPARE(object->property("test5").toBool(), true);
+
+ delete object;
+}
+
+/*
+Confirm bindings and alias properties can coexist.
+
+Tests for a regression where the binding would not reevaluate.
+*/
+void tst_qqmlecmascript::aliasPropertyAndBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("aliasPropertyAndBinding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 3);
+ QCOMPARE(object->property("c3").toInt(), 3);
+
+ object->setProperty("c2", QVariant(19));
+
+ QCOMPARE(object->property("c2").toInt(), 19);
+ QCOMPARE(object->property("c3").toInt(), 19);
+
+ delete object;
+}
+
+/*
+Ensure that we can write undefined value to an alias property,
+and that the aliased property is reset correctly if possible.
+*/
+void tst_qqmlecmascript::aliasPropertyReset()
+{
+ QObject *object = 0;
+
+ // test that a manual write (of undefined) to a resettable aliased property succeeds
+ QQmlComponent c1(&engine, testFileUrl("aliasreset/aliasPropertyReset.1.qml"));
+ object = c1.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0);
+ QCOMPARE(object->property("aliasIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAliased");
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ QCOMPARE(object->property("aliasIsUndefined"), QVariant(true));
+ delete object;
+
+ // test that a manual write (of undefined) to a resettable alias property succeeds
+ QQmlComponent c2(&engine, testFileUrl("aliasreset/aliasPropertyReset.2.qml"));
+ object = c2.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0);
+ QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(true));
+ delete object;
+
+ // test that an alias to a bound property works correctly
+ QQmlComponent c3(&engine, testFileUrl("aliasreset/aliasPropertyReset.3.qml"));
+ object = c3.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0);
+ QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false));
+ QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(true));
+ QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
+ delete object;
+
+ // test that a manual write (of undefined) to a resettable alias property
+ // whose aliased property's object has been deleted, does not crash.
+ QQmlComponent c4(&engine, testFileUrl("aliasreset/aliasPropertyReset.4.qml"));
+ object = c4.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0);
+ QObject *loader = object->findChild<QObject*>("loader");
+ QVERIFY(loader != 0);
+ delete loader;
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); // deletion should have caused value unset.
+ QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash.
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ QMetaObject::invokeMethod(object, "setAlias"); // shouldn't crash, and shouldn't change value (since it's no longer referencing anything).
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ delete object;
+
+ // test that binding an alias property to an undefined value works correctly
+ QQmlComponent c5(&engine, testFileUrl("aliasreset/aliasPropertyReset.5.qml"));
+ object = c5.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); // bound to undefined value.
+ delete object;
+
+ // test that a manual write (of undefined) to a non-resettable property fails properly
+ QUrl url = testFileUrl("aliasreset/aliasPropertyReset.error.1.qml");
+ QString warning1 = url.toString() + QLatin1String(":15: Error: Cannot assign [undefined] to int");
+ QQmlComponent e1(&engine, url);
+ object = e1.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("intAlias").value<int>(), 12);
+ QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QCOMPARE(object->property("intAlias").value<int>(), 12);
+ QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
+ delete object;
+}
+
+void tst_qqmlecmascript::dynamicCreation_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QString>("createdName");
+
+ QTest::newRow("One") << "createOne" << "objectOne";
+ QTest::newRow("Two") << "createTwo" << "objectTwo";
+ QTest::newRow("Three") << "createThree" << "objectThree";
+}
+
+/*
+Test using createQmlObject to dynamically generate an item
+Also using createComponent is tested.
+*/
+void tst_qqmlecmascript::dynamicCreation()
+{
+ QFETCH(QString, method);
+ QFETCH(QString, createdName);
+
+ QQmlComponent component(&engine, testFileUrl("dynamicCreation.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, method.toUtf8());
+ QObject *created = object->objectProperty();
+ QVERIFY(created);
+ QCOMPARE(created->objectName(), createdName);
+
+ delete object;
+}
+
+/*
+ Tests the destroy function
+*/
+void tst_qqmlecmascript::dynamicDestruction()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("dynamicDeletion.qml"));
+ QQmlGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QQmlGuard<QObject> createdQmlObject = 0;
+
+ QMetaObject::invokeMethod(object, "create");
+ createdQmlObject = object->objectProperty();
+ QVERIFY(createdQmlObject);
+ QCOMPARE(createdQmlObject->objectName(), QString("emptyObject"));
+
+ QMetaObject::invokeMethod(object, "killOther");
+ QVERIFY(createdQmlObject);
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QVERIFY(createdQmlObject);
+ for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
+ if (createdQmlObject) {
+ QTest::qWait(100);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ }
+ }
+ QVERIFY(!createdQmlObject);
+
+ QQmlEngine::setObjectOwnership(object, QQmlEngine::JavaScriptOwnership);
+ QMetaObject::invokeMethod(object, "killMe");
+ QVERIFY(object);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QVERIFY(!object);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("dynamicDeletion.2.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0);
+
+ QMetaObject::invokeMethod(o, "create");
+
+ QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) != 0);
+
+ QMetaObject::invokeMethod(o, "destroy");
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0);
+
+ delete o;
+ }
+}
+
+/*
+ tests that id.toString() works
+*/
+void tst_qqmlecmascript::objectToString()
+{
+ QQmlComponent component(&engine, testFileUrl("qmlToString.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "testToString");
+ QVERIFY(object->stringProperty().startsWith("MyQmlObject_QML_"));
+ QVERIFY(object->stringProperty().endsWith(", \"objName\")"));
+
+ delete object;
+}
+
+/*
+ tests that id.hasOwnProperty() works
+*/
+void tst_qqmlecmascript::objectHasOwnProperty()
+{
+ QUrl url = testFileUrl("qmlHasOwnProperty.qml");
+ QString warning1 = url.toString() + ":59: TypeError: Cannot call method 'hasOwnProperty' of undefined";
+ QString warning2 = url.toString() + ":64: TypeError: Cannot call method 'hasOwnProperty' of undefined";
+ QString warning3 = url.toString() + ":69: TypeError: Cannot call method 'hasOwnProperty' of undefined";
+
+ QQmlComponent component(&engine, url);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // test QObjects in QML
+ QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess");
+ QVERIFY(object->property("result").value<bool>() == true);
+ QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure");
+ QVERIFY(object->property("result").value<bool>() == false);
+
+ // now test other types in QML
+ QObject *child = object->findChild<QObject*>("typeObj");
+ QVERIFY(child != 0);
+ QMetaObject::invokeMethod(child, "testHasOwnPropertySuccess");
+ QCOMPARE(child->property("valueTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("valueTypeHasOwnProperty2").toBool(), true);
+ QCOMPARE(child->property("variantTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("stringTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("listTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("emptyListTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("enumTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("typenameHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("typenameHasOwnProperty2").toBool(), true);
+ QCOMPARE(child->property("moduleApiTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("moduleApiPropertyTypeHasOwnProperty").toBool(), true);
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureOne");
+ QCOMPARE(child->property("enumNonValueHasOwnProperty").toBool(), false);
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureTwo");
+ QCOMPARE(child->property("moduleApiNonPropertyHasOwnProperty").toBool(), false);
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureThree");
+ QCOMPARE(child->property("listAtInvalidHasOwnProperty").toBool(), false);
+
+ delete object;
+}
+
+/*
+Tests bindings that indirectly cause their own deletion work.
+
+This test is best run under valgrind to ensure no invalid memory access occur.
+*/
+void tst_qqmlecmascript::selfDeletingBinding()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("selfDeletingBinding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ object->setProperty("triggerDelete", true);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("selfDeletingBinding.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ object->setProperty("triggerDelete", true);
+ delete object;
+ }
+}
+
+/*
+Test that extended object properties can be accessed.
+
+This test a regression where this used to crash. The issue was specificially
+for extended objects that did not include a synthesized meta object (so non-root
+and no synthesiszed properties).
+*/
+void tst_qqmlecmascript::extendedObjectPropertyLookup()
+{
+ QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+/*
+Test that extended object properties can be accessed correctly.
+*/
+void tst_qqmlecmascript::extendedObjectPropertyLookup2()
+{
+ QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVariant returnValue;
+ QVERIFY(QMetaObject::invokeMethod(object, "getValue", Q_RETURN_ARG(QVariant, returnValue)));
+ QCOMPARE(returnValue.toInt(), 42);
+
+ delete object;
+}
+/*
+Test file/lineNumbers for binding/Script errors.
+*/
+void tst_qqmlecmascript::scriptErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("scriptErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
+ QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
+ QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
+ QString warning4 = url + ":13: ReferenceError: Can't find variable: a";
+ QString warning5 = url + ":11: ReferenceError: Can't find variable: a";
+ QString warning6 = url + ":10: Unable to assign [undefined] to int";
+ QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\"";
+ QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\"";
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning6.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
+ emit object->basicSignal();
+
+ QTest::ignoreMessage(QtWarningMsg, warning7.toLatin1().constData());
+ emit object->anotherBasicSignal();
+
+ QTest::ignoreMessage(QtWarningMsg, warning8.toLatin1().constData());
+ emit object->thirdBasicSignal();
+
+ delete object;
+}
+
+/*
+Test file/lineNumbers for inline functions.
+*/
+void tst_qqmlecmascript::functionErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("functionErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning = url + ":5: Error: Invalid write to global property \"a\"";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+
+ // test that if an exception occurs while invoking js function from cpp, it is reported as expected.
+ QQmlComponent componentTwo(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
+ url = componentTwo.url().toString();
+ object = componentTwo.create();
+ QVERIFY(object != 0);
+
+ QString srpname = object->property("srp_name").toString();
+
+ warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srpname
+ + QLatin1String(" is not a function");
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ delete object;
+}
+
+/*
+Test various errors that can occur when assigning a property from script
+*/
+void tst_qqmlecmascript::propertyAssignmentErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("propertyAssignmentErrors.qml"));
+
+ QString url = component.url().toString();
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+}
+
+/*
+Test bindings still work when the reeval is triggered from within
+a signal script.
+*/
+void tst_qqmlecmascript::signalTriggeredBindings()
+{
+ QQmlComponent component(&engine, testFileUrl("signalTriggeredBindings.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("base").toReal(), 50.);
+ QCOMPARE(object->property("test1").toReal(), 50.);
+ QCOMPARE(object->property("test2").toReal(), 50.);
+
+ object->basicSignal();
+
+ QCOMPARE(object->property("base").toReal(), 200.);
+ QCOMPARE(object->property("test1").toReal(), 200.);
+ QCOMPARE(object->property("test2").toReal(), 200.);
+
+ object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton);
+
+ QCOMPARE(object->property("base").toReal(), 400.);
+ QCOMPARE(object->property("test1").toReal(), 400.);
+ QCOMPARE(object->property("test2").toReal(), 400.);
+
+ delete object;
+}
+
+/*
+Test that list properties can be iterated from ECMAScript
+*/
+void tst_qqmlecmascript::listProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("listProperties.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 21);
+ QCOMPARE(object->property("test2").toInt(), 2);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::exceptionClearsOnReeval()
+{
+ QQmlComponent component(&engine, testFileUrl("exceptionClearsOnReeval.qml"));
+ QString url = component.url().toString();
+
+ QString warning = url + ":4: TypeError: Cannot read property 'objectProperty' of null";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+
+ MyQmlObject object2;
+ MyQmlObject object3;
+ object2.setObjectProperty(&object3);
+ object->setObjectProperty(&object2);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::exceptionSlotProducesWarning()
+{
+ QQmlComponent component(&engine, testFileUrl("exceptionProducesWarning.qml"));
+ QString url = component.url().toString();
+
+ QString warning = component.url().toString() + ":6: Error: JS exception";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::exceptionBindingProducesWarning()
+{
+ QQmlComponent component(&engine, testFileUrl("exceptionProducesWarning2.qml"));
+ QString url = component.url().toString();
+
+ QString warning = component.url().toString() + ":5: Error: JS exception";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::compileInvalidBinding()
+{
+ // QTBUG-23387: ensure that invalid bindings don't cause a crash.
+ QQmlComponent component(&engine, testFileUrl("v8bindingException.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+static int transientErrorsMsgCount = 0;
+static void transientErrorsMsgHandler(QtMsgType, const char *)
+{
+ ++transientErrorsMsgCount;
+}
+
+// Check that transient binding errors are not displayed
+void tst_qqmlecmascript::transientErrors()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("transientErrors.qml"));
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+
+ delete object;
+ }
+
+ // One binding erroring multiple times, but then resolving
+ {
+ QQmlComponent component(&engine, testFileUrl("transientErrors.2.qml"));
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+
+ delete object;
+ }
+}
+
+// Check that errors during shutdown are minimized
+void tst_qqmlecmascript::shutdownErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("shutdownErrors.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ delete object;
+
+ qInstallMsgHandler(old);
+ QCOMPARE(transientErrorsMsgCount, 0);
+}
+
+void tst_qqmlecmascript::compositePropertyType()
+{
+ QQmlComponent component(&engine, testFileUrl("compositePropertyType.qml"));
+
+ QTest::ignoreMessage(QtDebugMsg, "hello world");
+ QObject *object = qobject_cast<QObject *>(component.create());
+ delete object;
+}
+
+// QTBUG-5759
+void tst_qqmlecmascript::jsObject()
+{
+ QQmlComponent component(&engine, testFileUrl("jsObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::undefinedResetsProperty()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("undefinedResetsProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 92);
+
+ object->setProperty("setUndefined", true);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 13);
+
+ object->setProperty("setUndefined", false);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 92);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("undefinedResetsProperty.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 19);
+
+ QMetaObject::invokeMethod(object, "doReset");
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 13);
+
+ delete object;
+ }
+}
+
+// Aliases to variant properties should work
+void tst_qqmlecmascript::qtbug_22464()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_22464.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::qtbug_21580()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_21580.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// QTBUG-6781
+void tst_qqmlecmascript::bug1()
+{
+ QQmlComponent component(&engine, testFileUrl("bug.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 14);
+
+ object->setProperty("a", 11);
+
+ QCOMPARE(object->property("test").toInt(), 3);
+
+ object->setProperty("b", true);
+
+ QCOMPARE(object->property("test").toInt(), 9);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::bug2()
+{
+ QQmlComponent component(&engine);
+ component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+// Don't crash in createObject when the component has errors.
+void tst_qqmlecmascript::dynamicCreationCrash()
+{
+ QQmlComponent component(&engine, testFileUrl("dynamicCreation.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QMetaObject::invokeMethod(object, "dontCrash");
+ QObject *created = object->objectProperty();
+ QVERIFY(created == 0);
+
+ delete object;
+}
+
+// ownership transferred to JS, ensure that GC runs the dtor
+void tst_qqmlecmascript::dynamicCreationOwnership()
+{
+ int dtorCount = 0;
+ int expectedDtorCount = 1; // start at 1 since we expect mdcdo to dtor too.
+
+ // allow the engine to go out of scope too.
+ {
+ QQmlEngine dcoEngine;
+ QQmlComponent component(&dcoEngine, testFileUrl("dynamicCreationOwnership.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MyDynamicCreationDestructionObject *mdcdo = object->findChild<MyDynamicCreationDestructionObject*>("mdcdo");
+ QVERIFY(mdcdo != 0);
+ mdcdo->setDtorCount(&dtorCount);
+
+ for (int i = 1; i < 105; ++i, ++expectedDtorCount) {
+ QMetaObject::invokeMethod(object, "dynamicallyCreateJsOwnedObject");
+ if (i % 90 == 0) {
+ // we do this once manually, but it should be done automatically
+ // when the engine goes out of scope (since it should gc in dtor)
+ QMetaObject::invokeMethod(object, "performGc");
+ }
+ if (i % 10 == 0) {
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ }
+ }
+
+ delete object;
+ }
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, expectedDtorCount);
+}
+
+void tst_qqmlecmascript::regExpBug()
+{
+ //QTBUG-9367
+ {
+ QQmlComponent component(&engine, testFileUrl("regExp.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]"));
+ delete object;
+ }
+
+ //QTBUG-23068
+ {
+ QString err = QString(QLatin1String("%1:6 Invalid property assignment: regular expression expected; use /pattern/ syntax\n")).arg(testFileUrl("regExp.2.qml").toString());
+ QQmlComponent component(&engine, testFileUrl("regExp.2.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(!object);
+ QCOMPARE(component.errorString(), err);
+ }
+}
+
+static inline bool evaluate_error(QV8Engine *engine, v8::Handle<v8::Object> o, const char *source)
+{
+ QString functionSource = QLatin1String("(function(object) { return ") +
+ QLatin1String(source) + QLatin1String(" })");
+ v8::TryCatch tc;
+ v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
+ if (tc.HasCaught())
+ return false;
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
+ if (function.IsEmpty())
+ return false;
+ v8::Handle<v8::Value> args[] = { o };
+ function->Call(engine->global(), 1, args);
+ return tc.HasCaught();
+}
+
+static inline bool evaluate_value(QV8Engine *engine, v8::Handle<v8::Object> o,
+ const char *source, v8::Handle<v8::Value> result)
+{
+ QString functionSource = QLatin1String("(function(object) { return ") +
+ QLatin1String(source) + QLatin1String(" })");
+ v8::TryCatch tc;
+ v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
+ if (tc.HasCaught())
+ return false;
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
+ if (function.IsEmpty())
+ return false;
+ v8::Handle<v8::Value> args[] = { o };
+
+ v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args);
+
+ if (tc.HasCaught())
+ return false;
+
+ return value->StrictEquals(result);
+}
+
+static inline v8::Handle<v8::Value> evaluate(QV8Engine *engine, v8::Handle<v8::Object> o,
+ const char *source)
+{
+ QString functionSource = QLatin1String("(function(object) { return ") +
+ QLatin1String(source) + QLatin1String(" })");
+ v8::TryCatch tc;
+ v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
+ if (tc.HasCaught())
+ return v8::Handle<v8::Value>();
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
+ if (function.IsEmpty())
+ return v8::Handle<v8::Value>();
+ v8::Handle<v8::Value> args[] = { o };
+
+ v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args);
+
+ if (tc.HasCaught())
+ return v8::Handle<v8::Value>();
+ return value;
+}
+
+#define EVALUATE_ERROR(source) evaluate_error(engine, object, source)
+#define EVALUATE_VALUE(source, result) evaluate_value(engine, object, source, result)
+#define EVALUATE(source) evaluate(engine, object, source)
+
+void tst_qqmlecmascript::callQtInvokables()
+{
+ MyInvokableObject o;
+
+ QQmlEngine qmlengine;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&qmlengine);
+
+ QV8Engine *engine = ep->v8engine();
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+
+ v8::Local<v8::Object> object = engine->newQObject(&o)->ToObject();
+
+ // Non-existent methods
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_nonexistent()"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_nonexistent(10, 11)"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Insufficient arguments
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_int()"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_intint(10)"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Excessive arguments
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(10, 11)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intint(10, 11, 12)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 9);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(11));
+
+ // Test return types
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs()", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 0);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_int()", v8::Integer::New(6)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_real()", v8::Number::New(19.75)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 2);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ {
+ v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QPointF()");
+ QVERIFY(!ret.IsEmpty());
+ QCOMPARE(engine->toVariant(ret, -1), QVariant(QPointF(123, 4.5)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 3);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ {
+ v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QObject()");
+ QCOMPARE(engine->toQObject(ret), (QObject *)&o);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 4);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_unknown()", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 5);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ {
+ v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QScriptValue()");
+ QVERIFY(ret->IsString());
+ QCOMPARE(engine->toString(ret), QString("Hello world"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 6);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_QVariant()", engine->toString("QML rocks")));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 7);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Test arg types
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(94)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(\"94\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(\"not a number\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intint(122, 9)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 9);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(122));
+ QCOMPARE(o.actuals().at(1), QVariant(9));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(94.3)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94.3));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(\"94.3\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94.3));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(\"not a number\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QString(\"Hello world\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant("Hello world"));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QString(19)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant("19"));
+
+ o.reset();
+ {
+ QString expected = "MyInvokableObject(0x" + QString::number((quintptr)&o, 16) + ")";
+ QVERIFY(EVALUATE_VALUE("object.method_QString(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(expected));
+ }
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QString(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QString(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(0)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPointF())", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF(99.3, -10.2)));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPoint())", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12)));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(0)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(\"Hello world\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isNull());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isUndefined());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(19)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).strictlyEquals(QJSValue(19)));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QScriptValue([19, 20])", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isArray());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(4, null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(4));
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isNull());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(8, undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(8));
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isUndefined());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(3, 19)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(3));
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).strictlyEquals(QJSValue(19)));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(44, [19, 20])", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(44));
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isArray());
+
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_overload()"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_overload(10)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 16);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_overload(10, 11)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 17);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(11));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_overload(\"Hello\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 18);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString("Hello")));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_with_enum(9)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 19);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(9));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_default(10)", v8::Integer::New(19)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 20);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(19));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_default(10, 13)", v8::Integer::New(13)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 20);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(13));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_inherited(9)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -3);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(9));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QVariant(9)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 21);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(9));
+ QCOMPARE(o.actuals().at(1), QVariant());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QVariant(\"Hello\", \"World\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 21);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(QString("Hello")));
+ QCOMPARE(o.actuals().at(1), QVariant(QString("World")));
+}
+
+// QTBUG-13047 (check that you can pass registered object types as args)
+void tst_qqmlecmascript::invokableObjectArg()
+{
+ QQmlComponent component(&engine, testFileUrl("invokableObjectArg.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+ MyQmlObject *qmlobject = qobject_cast<MyQmlObject *>(o);
+ QVERIFY(qmlobject);
+ QCOMPARE(qmlobject->myinvokableObject, qmlobject);
+
+ delete o;
+}
+
+// QTBUG-13047 (check that you can return registered object types from methods)
+void tst_qqmlecmascript::invokableObjectRet()
+{
+ QQmlComponent component(&engine, testFileUrl("invokableObjectRet.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+// QTBUG-5675
+void tst_qqmlecmascript::listToVariant()
+{
+ QQmlComponent component(&engine, testFileUrl("listToVariant.qml"));
+
+ MyQmlContainer container;
+
+ QQmlContext context(engine.rootContext());
+ context.setContextObject(&container);
+
+ QObject *object = component.create(&context);
+ QVERIFY(object != 0);
+
+ QVariant v = object->property("test");
+ QCOMPARE(v.userType(), qMetaTypeId<QQmlListReference>());
+ QVERIFY(qvariant_cast<QQmlListReference>(v).object() == &container);
+
+ delete object;
+}
+
+// QTBUG-16316
+Q_DECLARE_METATYPE(QQmlListProperty<MyQmlObject>)
+void tst_qqmlecmascript::listAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("listAssignment.qml"));
+ QObject *obj = component.create();
+ QCOMPARE(obj->property("list1length").toInt(), 2);
+ QQmlListProperty<MyQmlObject> list1 = obj->property("list1").value<QQmlListProperty<MyQmlObject> >();
+ QQmlListProperty<MyQmlObject> list2 = obj->property("list2").value<QQmlListProperty<MyQmlObject> >();
+ QCOMPARE(list1.count(&list1), list2.count(&list2));
+ QCOMPARE(list1.at(&list1, 0), list2.at(&list2, 0));
+ QCOMPARE(list1.at(&list1, 1), list2.at(&list2, 1));
+ delete obj;
+}
+
+// QTBUG-7957
+void tst_qqmlecmascript::multiEngineObject()
+{
+ MyQmlObject obj;
+ obj.setStringProperty("Howdy planet");
+
+ QQmlEngine e1;
+ e1.rootContext()->setContextProperty("thing", &obj);
+ QQmlComponent c1(&e1, testFileUrl("multiEngineObject.qml"));
+
+ QQmlEngine e2;
+ e2.rootContext()->setContextProperty("thing", &obj);
+ QQmlComponent c2(&e2, testFileUrl("multiEngineObject.qml"));
+
+ QObject *o1 = c1.create();
+ QObject *o2 = c2.create();
+
+ QCOMPARE(o1->property("test").toString(), QString("Howdy planet"));
+ QCOMPARE(o2->property("test").toString(), QString("Howdy planet"));
+
+ delete o2;
+ delete o1;
+}
+
+// Test that references to QObjects are cleanup when the object is destroyed
+void tst_qqmlecmascript::deletedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("deletedObject.qml"));
+
+ QObject *object = component.create();
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::attachedPropertyScope()
+{
+ QQmlComponent component(&engine, testFileUrl("attachedPropertyScope.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ MyQmlAttachedObject *attached =
+ qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
+ QVERIFY(attached != 0);
+
+ QCOMPARE(object->property("value2").toInt(), 0);
+
+ attached->emitMySignal();
+
+ QCOMPARE(object->property("value2").toInt(), 9);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::scriptConnect()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.1.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.2.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.3.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.4.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->methodCalled(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->methodCalled(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.5.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->methodCalled(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->methodCalled(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.6.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::scriptDisconnect()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptDisconnect.1.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 1);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->basicSignal();
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptDisconnect.2.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 1);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->basicSignal();
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptDisconnect.3.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 1);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->basicSignal();
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 3);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptDisconnect.4.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 1);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->basicSignal();
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 3);
+
+ delete object;
+ }
+}
+
+class OwnershipObject : public QObject
+{
+ Q_OBJECT
+public:
+ OwnershipObject() { object = new QObject; }
+
+ QPointer<QObject> object;
+
+public slots:
+ QObject *getObject() { return object; }
+};
+
+void tst_qqmlecmascript::ownership()
+{
+ OwnershipObject own;
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ context->setContextObject(&own);
+
+ {
+ QQmlComponent component(&engine, testFileUrl("ownership.qml"));
+
+ QVERIFY(own.object != 0);
+
+ QObject *object = component.create(context);
+
+ engine.collectGarbage();
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(own.object == 0);
+
+ delete object;
+ }
+
+ own.object = new QObject(&own);
+
+ {
+ QQmlComponent component(&engine, testFileUrl("ownership.qml"));
+
+ QVERIFY(own.object != 0);
+
+ QObject *object = component.create(context);
+
+ engine.collectGarbage();
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(own.object != 0);
+
+ delete object;
+ }
+
+ delete context;
+}
+
+class CppOwnershipReturnValue : public QObject
+{
+ Q_OBJECT
+public:
+ CppOwnershipReturnValue() : value(0) {}
+ ~CppOwnershipReturnValue() { delete value; }
+
+ Q_INVOKABLE QObject *create() {
+ value = new QObject;
+ QQmlEngine::setObjectOwnership(value, QQmlEngine::CppOwnership);
+ return value;
+ }
+
+ Q_INVOKABLE MyQmlObject *createQmlObject() {
+ MyQmlObject *rv = new MyQmlObject;
+ value = rv;
+ return rv;
+ }
+
+ QPointer<QObject> value;
+};
+
+// QTBUG-15695.
+// Test setObjectOwnership(CppOwnership) works even when there is no QQmlData
+void tst_qqmlecmascript::cppOwnershipReturnValue()
+{
+ CppOwnershipReturnValue source;
+
+ {
+ QQmlEngine engine;
+ engine.rootContext()->setContextProperty("source", &source);
+
+ QVERIFY(source.value == 0);
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl());
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(source.value != 0);
+
+ delete object;
+ }
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(source.value != 0);
+}
+
+// QTBUG-15697
+void tst_qqmlecmascript::ownershipCustomReturnValue()
+{
+ CppOwnershipReturnValue source;
+
+ {
+ QQmlEngine engine;
+ engine.rootContext()->setContextProperty("source", &source);
+
+ QVERIFY(source.value == 0);
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl());
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(source.value != 0);
+
+ delete object;
+ }
+
+ engine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(source.value == 0);
+}
+
+class QListQObjectMethodsObject : public QObject
+{
+ Q_OBJECT
+public:
+ QListQObjectMethodsObject() {
+ m_objects.append(new MyQmlObject());
+ m_objects.append(new MyQmlObject());
+ }
+
+ ~QListQObjectMethodsObject() {
+ qDeleteAll(m_objects);
+ }
+
+public slots:
+ QList<QObject *> getObjects() { return m_objects; }
+
+private:
+ QList<QObject *> m_objects;
+};
+
+// Tests that returning a QList<QObject*> from a method works
+void tst_qqmlecmascript::qlistqobjectMethods()
+{
+ QListQObjectMethodsObject obj;
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ context->setContextObject(&obj);
+
+ QQmlComponent component(&engine, testFileUrl("qlistqobjectMethods.qml"));
+
+ QObject *object = component.create(context);
+
+ QCOMPARE(object->property("test").toInt(), 2);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ delete context;
+}
+
+// QTBUG-9205
+void tst_qqmlecmascript::strictlyEquals()
+{
+ QQmlComponent component(&engine, testFileUrl("strictlyEquals.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+ QCOMPARE(object->property("test5").toBool(), true);
+ QCOMPARE(object->property("test6").toBool(), true);
+ QCOMPARE(object->property("test7").toBool(), true);
+ QCOMPARE(object->property("test8").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::compiled()
+{
+ QQmlComponent component(&engine, testFileUrl("compiled.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toReal(), qreal(15.7));
+ QCOMPARE(object->property("test2").toReal(), qreal(-6.7));
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), false);
+ QCOMPARE(object->property("test5").toBool(), false);
+ QCOMPARE(object->property("test6").toBool(), true);
+
+ QCOMPARE(object->property("test7").toInt(), 185);
+ QCOMPARE(object->property("test8").toInt(), 167);
+ QCOMPARE(object->property("test9").toBool(), true);
+ QCOMPARE(object->property("test10").toBool(), false);
+ QCOMPARE(object->property("test11").toBool(), false);
+ QCOMPARE(object->property("test12").toBool(), true);
+
+ QCOMPARE(object->property("test13").toString(), QLatin1String("HelloWorld"));
+ QCOMPARE(object->property("test14").toString(), QLatin1String("Hello World"));
+ QCOMPARE(object->property("test15").toBool(), false);
+ QCOMPARE(object->property("test16").toBool(), true);
+
+ QCOMPARE(object->property("test17").toInt(), 5);
+ QCOMPARE(object->property("test18").toReal(), qreal(176));
+ QCOMPARE(object->property("test19").toInt(), 7);
+ QCOMPARE(object->property("test20").toReal(), qreal(6.7));
+ QCOMPARE(object->property("test21").toString(), QLatin1String("6.7"));
+ QCOMPARE(object->property("test22").toString(), QLatin1String("!"));
+ QCOMPARE(object->property("test23").toBool(), true);
+ QCOMPARE(qvariant_cast<QColor>(object->property("test24")), QColor(0x11,0x22,0x33));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test25")), QColor(0x11,0x22,0x33,0xAA));
+
+ delete object;
+}
+
+// Test that numbers assigned in bindings as strings work consistently
+void tst_qqmlecmascript::numberAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("numberAssignment.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1"), QVariant((qreal)6.7));
+ QCOMPARE(object->property("test2"), QVariant((qreal)6.7));
+ QCOMPARE(object->property("test2"), QVariant((qreal)6.7));
+ QCOMPARE(object->property("test3"), QVariant((qreal)6));
+ QCOMPARE(object->property("test4"), QVariant((qreal)6));
+
+ QCOMPARE(object->property("test5"), QVariant((int)7));
+ QCOMPARE(object->property("test6"), QVariant((int)7));
+ QCOMPARE(object->property("test7"), QVariant((int)6));
+ QCOMPARE(object->property("test8"), QVariant((int)6));
+
+ QCOMPARE(object->property("test9"), QVariant((unsigned int)7));
+ QCOMPARE(object->property("test10"), QVariant((unsigned int)7));
+ QCOMPARE(object->property("test11"), QVariant((unsigned int)6));
+ QCOMPARE(object->property("test12"), QVariant((unsigned int)6));
+
+ delete object;
+}
+
+void tst_qqmlecmascript::propertySplicing()
+{
+ QQmlComponent component(&engine, testFileUrl("propertySplicing.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// QTBUG-16683
+void tst_qqmlecmascript::signalWithUnknownTypes()
+{
+ QQmlComponent component(&engine, testFileUrl("signalWithUnknownTypes.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ MyQmlObject::MyType type;
+ type.value = 0x8971123;
+ emit object->signalWithUnknownType(type);
+
+ MyQmlObject::MyType result = qvariant_cast<MyQmlObject::MyType>(object->variant());
+
+ QCOMPARE(result.value, type.value);
+
+
+ delete object;
+}
+
+void tst_qqmlecmascript::signalWithJSValueInVariant_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QString>("compare");
+
+ QString compareStrict("(function(a, b) { return a === b; })");
+ QTest::newRow("true") << "true" << compareStrict;
+ QTest::newRow("undefined") << "undefined" << compareStrict;
+ QTest::newRow("null") << "null" << compareStrict;
+ QTest::newRow("123") << "123" << compareStrict;
+ QTest::newRow("'ciao'") << "'ciao'" << compareStrict;
+
+ QString comparePropertiesStrict(
+ "(function(a, b) {"
+ " if (typeof b != 'object')"
+ " return a === b;"
+ " var props = Object.getOwnPropertyNames(b);"
+ " for (var i = 0; i < props.length; ++i) {"
+ " var p = props[i];"
+ " return arguments.callee(a[p], b[p]);"
+ " }"
+ "})");
+ QTest::newRow("{ foo: 'bar' }") << "({ foo: 'bar' })" << comparePropertiesStrict;
+ QTest::newRow("[10,20,30]") << "[10,20,30]" << comparePropertiesStrict;
+}
+
+void tst_qqmlecmascript::signalWithJSValueInVariant()
+{
+ QFETCH(QString, expression);
+ QFETCH(QString, compare);
+
+ QQmlComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
+ QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
+ QVERIFY(object != 0);
+
+ QJSValue value = engine.evaluate(expression);
+ QVERIFY(!engine.hasUncaughtException());
+ object->setProperty("expression", expression);
+ object->setProperty("compare", compare);
+ object->setProperty("pass", false);
+
+ emit object->signalWithVariant(QVariant::fromValue(value));
+ QVERIFY(object->property("pass").toBool());
+}
+
+void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines_data()
+{
+ signalWithJSValueInVariant_data();
+}
+
+void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines()
+{
+ QFETCH(QString, expression);
+ QFETCH(QString, compare);
+
+ QQmlComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
+ QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
+ QVERIFY(object != 0);
+
+ QJSEngine engine2;
+ QJSValue value = engine2.evaluate(expression);
+ QVERIFY(!engine2.hasUncaughtException());
+ object->setProperty("expression", expression);
+ object->setProperty("compare", compare);
+ object->setProperty("pass", false);
+
+ QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine.");
+ emit object->signalWithVariant(QVariant::fromValue(value));
+ QVERIFY(!object->property("pass").toBool());
+}
+
+void tst_qqmlecmascript::signalWithQJSValue_data()
+{
+ signalWithJSValueInVariant_data();
+}
+
+void tst_qqmlecmascript::signalWithQJSValue()
+{
+ QFETCH(QString, expression);
+ QFETCH(QString, compare);
+
+ QQmlComponent component(&engine, testFileUrl("signalWithQJSValue.qml"));
+ QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
+ QVERIFY(object != 0);
+
+ QJSValue value = engine.evaluate(expression);
+ QVERIFY(!engine.hasUncaughtException());
+ object->setProperty("expression", expression);
+ object->setProperty("compare", compare);
+ object->setProperty("pass", false);
+
+ emit object->signalWithQJSValue(value);
+
+ QVERIFY(object->property("pass").toBool());
+ QVERIFY(object->qjsvalue().strictlyEquals(value));
+}
+
+void tst_qqmlecmascript::moduleApi_data()
+{
+ QTest::addColumn<QUrl>("testfile");
+ QTest::addColumn<QString>("errorMessage");
+ QTest::addColumn<QStringList>("warningMessages");
+ QTest::addColumn<QStringList>("readProperties");
+ QTest::addColumn<QVariantList>("readExpectedValues");
+ QTest::addColumn<QStringList>("writeProperties");
+ QTest::addColumn<QVariantList>("writeValues");
+ QTest::addColumn<QStringList>("readBackProperties");
+ QTest::addColumn<QVariantList>("readBackExpectedValues");
+
+ QTest::newRow("qobject, register + read + method")
+ << testFileUrl("moduleapi/qobjectModuleApi.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "existingUriTest" << "qobjectTest" << "qobjectMethodTest"
+ << "qobjectMinorVersionTest" << "qobjectMajorVersionTest" << "qobjectParentedTest")
+ << (QVariantList() << 20 << 20 << 1 << 20 << 20 << 26)
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("script, register + read")
+ << testFileUrl("moduleapi/scriptModuleApi.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "scriptTest")
+ << (QVariantList() << 13)
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("qobject, caching + read")
+ << testFileUrl("moduleapi/qobjectModuleApiCaching.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "existingUriTest" << "qobjectParentedTest")
+ << (QVariantList() << 20 << 26) // 26, shouldn't have incremented to 27.
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("script, caching + read")
+ << testFileUrl("moduleapi/scriptModuleApiCaching.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "scriptTest")
+ << (QVariantList() << 13) // 13, shouldn't have incremented to 14.
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("qobject, writing + readonly constraints")
+ << testFileUrl("moduleapi/qobjectModuleApiWriting.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
+ << (QStringList() << "readOnlyProperty" << "writableProperty")
+ << (QVariantList() << 20 << 50)
+ << (QStringList() << "firstProperty" << "writableProperty")
+ << (QVariantList() << 30 << 30)
+ << (QStringList() << "readOnlyProperty" << "writableProperty")
+ << (QVariantList() << 20 << 30);
+
+ QTest::newRow("script, writing + readonly constraints")
+ << testFileUrl("moduleapi/scriptModuleApiWriting.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
+ << (QStringList() << "readBack" << "unchanged")
+ << (QVariantList() << 13 << 42)
+ << (QStringList() << "firstProperty" << "secondProperty")
+ << (QVariantList() << 30 << 30)
+ << (QStringList() << "readBack" << "unchanged")
+ << (QVariantList() << 30 << 42);
+
+ QTest::newRow("qobject module API enum values in JS")
+ << testFileUrl("moduleapi/qobjectModuleApiEnums.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "enumValue" << "enumMethod")
+ << (QVariantList() << 42 << 30)
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("qobject, invalid major version fail")
+ << testFileUrl("moduleapi/moduleApiMajorVersionFail.qml")
+ << QString("QQmlComponent: Component is not ready")
+ << QStringList()
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("qobject, invalid minor version fail")
+ << testFileUrl("moduleapi/moduleApiMinorVersionFail.qml")
+ << QString("QQmlComponent: Component is not ready")
+ << QStringList()
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+}
+
+void tst_qqmlecmascript::moduleApi()
+{
+ QFETCH(QUrl, testfile);
+ QFETCH(QString, errorMessage);
+ QFETCH(QStringList, warningMessages);
+ QFETCH(QStringList, readProperties);
+ QFETCH(QVariantList, readExpectedValues);
+ QFETCH(QStringList, writeProperties);
+ QFETCH(QVariantList, writeValues);
+ QFETCH(QStringList, readBackProperties);
+ QFETCH(QVariantList, readBackExpectedValues);
+
+ QQmlComponent component(&engine, testfile);
+
+ if (!errorMessage.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData());
+
+ if (warningMessages.size())
+ foreach (const QString &warning, warningMessages)
+ QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
+
+ QObject *object = component.create();
+ if (!errorMessage.isEmpty()) {
+ QVERIFY(object == 0);
+ } else {
+ QVERIFY(object != 0);
+ for (int i = 0; i < readProperties.size(); ++i)
+ QCOMPARE(object->property(readProperties.at(i).toAscii().constData()), readExpectedValues.at(i));
+ for (int i = 0; i < writeProperties.size(); ++i)
+ QVERIFY(object->setProperty(writeProperties.at(i).toAscii().constData(), writeValues.at(i)));
+ for (int i = 0; i < readBackProperties.size(); ++i)
+ QCOMPARE(object->property(readBackProperties.at(i).toAscii().constData()), readBackExpectedValues.at(i));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::importScripts_data()
+{
+ QTest::addColumn<QUrl>("testfile");
+ QTest::addColumn<QString>("errorMessage");
+ QTest::addColumn<QStringList>("warningMessages");
+ QTest::addColumn<QStringList>("propertyNames");
+ QTest::addColumn<QVariantList>("propertyValues");
+
+ QTest::newRow("basic functionality")
+ << testFileUrl("jsimport/testImport.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("importedScriptStringValue")
+ << QLatin1String("importedScriptFunctionValue")
+ << QLatin1String("importedModuleAttachedPropertyValue")
+ << QLatin1String("importedModuleEnumValue"))
+ << (QVariantList() << QVariant(QLatin1String("Hello, World!"))
+ << QVariant(20)
+ << QVariant(19)
+ << QVariant(2));
+
+ QTest::newRow("import scoping")
+ << testFileUrl("jsimport/testImportScoping.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("componentError"))
+ << (QVariantList() << QVariant(5));
+
+ QTest::newRow("parent scope shouldn't be inherited by import with imports")
+ << testFileUrl("jsimportfail/failOne.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined")))
+ << (QStringList() << QLatin1String("importScriptFunctionValue"))
+ << (QVariantList() << QVariant(QString()));
+
+ QTest::newRow("javascript imports in an import should be private to the import scope")
+ << testFileUrl("jsimportfail/failTwo.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs")))
+ << (QStringList() << QLatin1String("importScriptFunctionValue"))
+ << (QVariantList() << QVariant(QString()));
+
+ QTest::newRow("module imports in an import should be private to the import scope")
+ << testFileUrl("jsimportfail/failThree.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined")))
+ << (QStringList() << QLatin1String("importedModuleAttachedPropertyValue"))
+ << (QVariantList() << QVariant(false));
+
+ QTest::newRow("typenames in an import should be private to the import scope")
+ << testFileUrl("jsimportfail/failFour.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest")))
+ << (QStringList() << QLatin1String("importedModuleEnumValue"))
+ << (QVariantList() << QVariant(0));
+
+ QTest::newRow("import with imports has it's own activation scope")
+ << testFileUrl("jsimportfail/failFive.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component")))
+ << (QStringList() << QLatin1String("componentError"))
+ << (QVariantList() << QVariant(0));
+
+ QTest::newRow("import pragma library script")
+ << testFileUrl("jsimport/testImportPragmaLibrary.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(31));
+
+ QTest::newRow("pragma library imports shouldn't inherit parent imports or scope")
+ << testFileUrl("jsimportfail/testImportPragmaLibrary.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component")))
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(0));
+
+ QTest::newRow("import pragma library script which has an import")
+ << testFileUrl("jsimport/testImportPragmaLibraryWithImports.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(55));
+
+ QTest::newRow("import pragma library script which has a pragma library import")
+ << testFileUrl("jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(18));
+
+ QTest::newRow("import module api into js import")
+ << testFileUrl("jsimport/testImportModuleApi.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(20));
+}
+
+void tst_qqmlecmascript::importScripts()
+{
+ QFETCH(QUrl, testfile);
+ QFETCH(QString, errorMessage);
+ QFETCH(QStringList, warningMessages);
+ QFETCH(QStringList, propertyNames);
+ QFETCH(QVariantList, propertyValues);
+
+ QQmlComponent component(&engine, testfile);
+
+ if (!errorMessage.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData());
+
+ if (warningMessages.size())
+ foreach (const QString &warning, warningMessages)
+ QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
+
+ QObject *object = component.create();
+ if (!errorMessage.isEmpty()) {
+ QVERIFY(object == 0);
+ } else {
+ QVERIFY(object != 0);
+ for (int i = 0; i < propertyNames.size(); ++i)
+ QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::scarceResources_other()
+{
+ /* These tests require knowledge of state, since we test values after
+ performing signal or function invocation. */
+
+ QPixmap origPixmap(100, 100);
+ origPixmap.fill(Qt::blue);
+ QString srp_name, expectedWarning;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&engine);
+ ScarceResourceObject *eo = 0;
+ QObject *srsc = 0;
+ QObject *object = 0;
+
+ /* property var semantics */
+
+ // test that scarce resources are handled properly in signal invocation
+ QQmlComponent varComponentTen(&engine, testFileUrl("scarceResourceSignal.var.qml"));
+ object = varComponentTen.create();
+ srsc = object->findChild<QObject*>("srsc");
+ QVERIFY(srsc);
+ QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet.
+ QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QMetaObject::invokeMethod(srsc, "testSignal");
+ QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated
+ QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage.
+ QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap.
+ QVERIFY(srsc->property("scarceResourceCopy").isValid());
+ QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that scarce resources are handled properly from js functions in qml files
+ QQmlComponent varComponentEleven(&engine, testFileUrl("scarceResourceFunction.var.qml"));
+ object = varComponentEleven.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid.
+ QCOMPARE(object->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage.
+ QMetaObject::invokeMethod(object, "releaseScarceResource");
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that if an exception occurs while invoking js function from cpp, that the resources are released.
+ QQmlComponent varComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
+ object = varComponentTwelve.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ srp_name = object->property("srp_name").toString();
+ expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that if an Item which has JS ownership but has a scarce resource property is garbage collected,
+ // that the scarce resource is removed from the engine's list of scarce resources to clean up.
+ QQmlComponent varComponentThirteen(&engine, testFileUrl("scarceResourceObjectGc.var.qml"));
+ object = varComponentThirteen.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("varProperty").isValid()); // not assigned yet
+ QMetaObject::invokeMethod(object, "assignVarProperty");
+ QVERIFY(ep->scarceResources.isEmpty()); // the scarce resource is a VME property.
+ QMetaObject::invokeMethod(object, "deassignVarProperty");
+ QVERIFY(ep->scarceResources.isEmpty()); // should still be empty; the resource should have been released on gc.
+ delete object;
+
+ /* property variant semantics */
+
+ // test that scarce resources are handled properly in signal invocation
+ QQmlComponent variantComponentTen(&engine, testFileUrl("scarceResourceSignal.variant.qml"));
+ object = variantComponentTen.create();
+ QVERIFY(object != 0);
+ srsc = object->findChild<QObject*>("srsc");
+ QVERIFY(srsc);
+ QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet.
+ QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QMetaObject::invokeMethod(srsc, "testSignal");
+ QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated
+ QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage.
+ QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap.
+ QVERIFY(srsc->property("scarceResourceCopy").isValid());
+ QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that scarce resources are handled properly from js functions in qml files
+ QQmlComponent variantComponentEleven(&engine, testFileUrl("scarceResourceFunction.variant.qml"));
+ object = variantComponentEleven.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid.
+ QCOMPARE(object->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage.
+ QMetaObject::invokeMethod(object, "releaseScarceResource");
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that if an exception occurs while invoking js function from cpp, that the resources are released.
+ QQmlComponent variantComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.variant.qml"));
+ object = variantComponentTwelve.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ srp_name = object->property("srp_name").toString();
+ expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+}
+
+void tst_qqmlecmascript::scarceResources_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<bool>("readDetachStatus");
+ QTest::addColumn<bool>("expectedDetachStatus");
+ QTest::addColumn<QStringList>("propertyNames");
+ QTest::addColumn<QVariantList>("expectedValidity");
+ QTest::addColumn<QVariantList>("expectedValues");
+ QTest::addColumn<QStringList>("expectedErrors");
+
+ QPixmap origPixmap(100, 100);
+ origPixmap.fill(Qt::blue);
+
+ /* property var semantics */
+
+ // in the following three cases, the instance created from the component
+ // has a property which is a copy of the scarce resource; hence, the
+ // resource should NOT be detached prior to deletion of the object instance,
+ // unless the resource is destroyed explicitly.
+ QTest::newRow("var: import scarce resource copy directly")
+ << testFileUrl("scarceResourceCopy.var.qml")
+ << true
+ << false // won't be detached, because assigned to property and not explicitly released
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << origPixmap)
+ << QStringList();
+
+ QTest::newRow("var: import scarce resource copy from JS")
+ << testFileUrl("scarceResourceCopyFromJs.var.qml")
+ << true
+ << false // won't be detached, because assigned to property and not explicitly released
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << origPixmap)
+ << QStringList();
+
+ QTest::newRow("var: import released scarce resource copy from JS")
+ << testFileUrl("scarceResourceDestroyedCopy.var.qml")
+ << true
+ << true // explicitly released, so it will be detached
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << false)
+ << (QList<QVariant>() << QVariant())
+ << QStringList();
+
+ // in the following three cases, no other copy should exist in memory,
+ // and so it should be detached (unless explicitly preserved).
+ QTest::newRow("var: import auto-release SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTest.var.qml")
+ << true
+ << true // auto released, so it will be detached
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+ QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTestPreserve.var.qml")
+ << true
+ << false // won't be detached because we explicitly preserve it
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+ QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTestMultiple.var.qml")
+ << true
+ << true // will be detached because all resources were released manually or automatically.
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+
+ // In the following three cases, test that scarce resources are handled
+ // correctly for imports.
+ QTest::newRow("var: import with no binding")
+ << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
+ << false // cannot check detach status.
+ << false
+ << QStringList()
+ << QList<QVariant>()
+ << QList<QVariant>()
+ << QStringList();
+ QTest::newRow("var: import with binding without explicit preserve")
+ << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << false) // will have been released prior to evaluation of binding.
+ << (QList<QVariant>() << QVariant())
+ << QStringList();
+ QTest::newRow("var: import with explicit release after binding evaluation")
+ << testFileUrl("scarceResourceCopyImport.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
+ << (QList<QVariant>() << false << false << false << true) // since property var = JS object reference, by releasing the provider's resource, all handles are invalidated.
+ << (QList<QVariant>() << QVariant() << QVariant() << QVariant() << QVariant(true))
+ << QStringList();
+ QTest::newRow("var: import with different js objects")
+ << testFileUrl("scarceResourceCopyImportDifferent.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
+ << (QList<QVariant>() << false << true << true) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object.
+ << (QList<QVariant>() << QVariant() << QVariant(origPixmap) << QVariant(false))
+ << QStringList();
+ QTest::newRow("var: import with different js objects and explicit release")
+ << testFileUrl("scarceResourceMultipleDifferentNoBinding.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
+ << (QList<QVariant>() << true << false) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object.
+ << (QList<QVariant>() << QVariant(origPixmap) << QVariant())
+ << QStringList();
+ QTest::newRow("var: import with same js objects and explicit release")
+ << testFileUrl("scarceResourceMultipleSameNoBinding.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
+ << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object.
+ << (QList<QVariant>() << QVariant() << QVariant())
+ << QStringList();
+ QTest::newRow("var: binding with same js objects and explicit release")
+ << testFileUrl("scarceResourceMultipleSameWithBinding.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
+ << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object.
+ << (QList<QVariant>() << QVariant() << QVariant())
+ << QStringList();
+
+
+ /* property variant semantics */
+
+ // in the following three cases, the instance created from the component
+ // has a property which is a copy of the scarce resource; hence, the
+ // resource should NOT be detached prior to deletion of the object instance,
+ // unless the resource is destroyed explicitly.
+ QTest::newRow("variant: import scarce resource copy directly")
+ << testFileUrl("scarceResourceCopy.variant.qml")
+ << true
+ << false // won't be detached, because assigned to property and not explicitly released
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << origPixmap)
+ << QStringList();
+
+ QTest::newRow("variant: import scarce resource copy from JS")
+ << testFileUrl("scarceResourceCopyFromJs.variant.qml")
+ << true
+ << false // won't be detached, because assigned to property and not explicitly released
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << origPixmap)
+ << QStringList();
+
+ QTest::newRow("variant: import released scarce resource copy from JS")
+ << testFileUrl("scarceResourceDestroyedCopy.variant.qml")
+ << true
+ << true // explicitly released, so it will be detached
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << false)
+ << (QList<QVariant>() << QVariant())
+ << QStringList();
+
+ // in the following three cases, no other copy should exist in memory,
+ // and so it should be detached (unless explicitly preserved).
+ QTest::newRow("variant: import auto-release SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTest.variant.qml")
+ << true
+ << true // auto released, so it will be detached
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+ QTest::newRow("variant: import explicit-preserve SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTestPreserve.variant.qml")
+ << true
+ << false // won't be detached because we explicitly preserve it
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+ QTest::newRow("variant: import multiple scarce resources")
+ << testFileUrl("scarceResourceTestMultiple.variant.qml")
+ << true
+ << true // will be detached because all resources were released manually or automatically.
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+
+ // In the following three cases, test that scarce resources are handled
+ // correctly for imports.
+ QTest::newRow("variant: import with no binding")
+ << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
+ << false // cannot check detach status.
+ << false
+ << QStringList()
+ << QList<QVariant>()
+ << QList<QVariant>()
+ << QStringList();
+ QTest::newRow("variant: import with binding without explicit preserve")
+ << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << false) // will have been released prior to evaluation of binding.
+ << (QList<QVariant>() << QVariant())
+ << QStringList();
+ QTest::newRow("variant: import with explicit release after binding evaluation")
+ << testFileUrl("scarceResourceCopyImport.variant.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo"))
+ << (QList<QVariant>() << true << true << false) // since property variant = variant copy, releasing the provider's resource does not invalidate previously assigned copies.
+ << (QList<QVariant>() << origPixmap << origPixmap << QVariant())
+ << QStringList();
+}
+
+void tst_qqmlecmascript::scarceResources()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(bool, readDetachStatus);
+ QFETCH(bool, expectedDetachStatus);
+ QFETCH(QStringList, propertyNames);
+ QFETCH(QVariantList, expectedValidity);
+ QFETCH(QVariantList, expectedValues);
+ QFETCH(QStringList, expectedErrors);
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&engine);
+ ScarceResourceObject *eo = 0;
+ QObject *object = 0;
+
+ QQmlComponent c(&engine, qmlFile);
+ object = c.create();
+ QVERIFY(object != 0);
+ for (int i = 0; i < propertyNames.size(); ++i) {
+ QString prop = propertyNames.at(i);
+ bool validity = expectedValidity.at(i).toBool();
+ QVariant value = expectedValues.at(i);
+
+ QCOMPARE(object->property(prop.toLatin1().constData()).isValid(), validity);
+ if (value.type() == QVariant::Int) {
+ QCOMPARE(object->property(prop.toLatin1().constData()).toInt(), value.toInt());
+ } else if (value.type() == QVariant::Pixmap) {
+ QCOMPARE(object->property(prop.toLatin1().constData()).value<QPixmap>(), value.value<QPixmap>());
+ }
+ }
+
+ if (readDetachStatus) {
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QCOMPARE(eo->scarceResourceIsDetached(), expectedDetachStatus);
+ }
+
+ QVERIFY(ep->scarceResources.isEmpty());
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyChangeSlots()
+{
+ // ensure that allowable property names are allowed and onPropertyNameChanged slots are generated correctly.
+ QQmlComponent component(&engine, testFileUrl("changeslots/propertyChangeSlots.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+
+ // ensure that invalid property names fail properly.
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QQmlComponent e1(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.1.qml"));
+ QString expectedErrorString = e1.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_nameWithUnderscoreChanged\"");
+ QCOMPARE(e1.errors().at(0).toString(), expectedErrorString);
+ object = e1.create();
+ QVERIFY(object == 0);
+ delete object;
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QQmlComponent e2(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.2.qml"));
+ expectedErrorString = e2.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on____nameWithUnderscoresChanged\"");
+ QCOMPARE(e2.errors().at(0).toString(), expectedErrorString);
+ object = e2.create();
+ QVERIFY(object == 0);
+ delete object;
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QQmlComponent e3(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.3.qml"));
+ expectedErrorString = e3.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on$NameWithDollarsignChanged\"");
+ QCOMPARE(e3.errors().at(0).toString(), expectedErrorString);
+ object = e3.create();
+ QVERIFY(object == 0);
+ delete object;
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QQmlComponent e4(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.4.qml"));
+ expectedErrorString = e4.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_6NameWithUnderscoreNumberChanged\"");
+ QCOMPARE(e4.errors().at(0).toString(), expectedErrorString);
+ object = e4.create();
+ QVERIFY(object == 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVar_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+
+ // valid
+ QTest::newRow("non-bindable object subproperty changed") << testFileUrl("propertyVar.1.qml");
+ QTest::newRow("non-bindable object changed") << testFileUrl("propertyVar.2.qml");
+ QTest::newRow("primitive changed") << testFileUrl("propertyVar.3.qml");
+ QTest::newRow("javascript array modification") << testFileUrl("propertyVar.4.qml");
+ QTest::newRow("javascript map modification") << testFileUrl("propertyVar.5.qml");
+ QTest::newRow("javascript array assignment") << testFileUrl("propertyVar.6.qml");
+ QTest::newRow("javascript map assignment") << testFileUrl("propertyVar.7.qml");
+ QTest::newRow("literal property assignment") << testFileUrl("propertyVar.8.qml");
+ QTest::newRow("qobject property assignment") << testFileUrl("propertyVar.9.qml");
+ QTest::newRow("base class var property assignment") << testFileUrl("propertyVar.10.qml");
+}
+
+void tst_qqmlecmascript::propertyVar()
+{
+ QFETCH(QUrl, qmlFile);
+
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Tests that we can write QVariant values to var properties from C++
+void tst_qqmlecmascript::propertyVarCpp()
+{
+ QObject *object = 0;
+
+ // ensure that writing to and reading from a var property from cpp works as required.
+ // Literal values stored in var properties can be read and written as QVariants
+ // of a specific type, whereas object values are read as QVariantMaps.
+ QQmlComponent component(&engine, testFileUrl("propertyVarCpp.qml"));
+ object = component.create();
+ QVERIFY(object != 0);
+ // assign int to property var that currently has int assigned
+ QVERIFY(object->setProperty("varProperty", QVariant::fromValue(10)));
+ QCOMPARE(object->property("varBound"), QVariant(15));
+ QCOMPARE(object->property("intBound"), QVariant(15));
+ QCOMPARE(object->property("varProperty").userType(), (int)QVariant::Int);
+ QCOMPARE(object->property("varBound").userType(), (int)QVariant::Int);
+ // assign string to property var that current has bool assigned
+ QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::Bool);
+ QVERIFY(object->setProperty("varProperty2", QVariant(QLatin1String("randomString"))));
+ QCOMPARE(object->property("varProperty2"), QVariant(QLatin1String("randomString")));
+ QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::String);
+ // now enforce behaviour when accessing JavaScript objects from cpp.
+ QCOMPARE(object->property("jsobject").userType(), (int)QVariant::Map);
+ delete object;
+}
+
+static void gc(QQmlEngine &engine)
+{
+ engine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+}
+
+void tst_qqmlecmascript::propertyVarOwnership()
+{
+ // Referenced JS objects are not collected
+ {
+ QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toBool(), false);
+ QMetaObject::invokeMethod(object, "runTest");
+ QCOMPARE(object->property("test").toBool(), true);
+ delete object;
+ }
+ // Referenced JS objects are not collected
+ {
+ QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toBool(), false);
+ QMetaObject::invokeMethod(object, "runTest");
+ QCOMPARE(object->property("test").toBool(), true);
+ delete object;
+ }
+ // Qt objects are not collected until they've been dereferenced
+ {
+ QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toBool(), false);
+ QCOMPARE(object->property("test2").toBool(), false);
+
+ QMetaObject::invokeMethod(object, "runTest");
+ QCOMPARE(object->property("test1").toBool(), true);
+
+ QPointer<QObject> referencedObject = object->property("object").value<QObject*>();
+ QVERIFY(!referencedObject.isNull());
+ gc(engine);
+ QVERIFY(!referencedObject.isNull());
+
+ QMetaObject::invokeMethod(object, "runTest2");
+ QCOMPARE(object->property("test2").toBool(), true);
+ gc(engine);
+ QVERIFY(referencedObject.isNull());
+
+ delete object;
+ }
+ // Self reference does not prevent Qt object collection
+ {
+ QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ QPointer<QObject> referencedObject = object->property("object").value<QObject*>();
+ QVERIFY(!referencedObject.isNull());
+ gc(engine);
+ QVERIFY(!referencedObject.isNull());
+
+ QMetaObject::invokeMethod(object, "runTest");
+ gc(engine);
+ QVERIFY(referencedObject.isNull());
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::propertyVarImplicitOwnership()
+{
+ // The childObject has a reference to a different QObject. We want to ensure
+ // that the different item will not be cleaned up until required. IE, the childObject
+ // has implicit ownership of the constructed QObject.
+ QQmlComponent component(&engine, testFileUrl("propertyVarImplicitOwnership.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rootObject = object->property("vp").value<QObject*>();
+ QVERIFY(rootObject != 0);
+ QObject *childObject = rootObject->findChild<QObject*>("text");
+ QVERIFY(childObject != 0);
+ QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
+ QCOMPARE(childObject->property("textCanary").toInt(), 10);
+ QMetaObject::invokeMethod(childObject, "constructQObject"); // creates a reference to a constructed QObject.
+ QWeakPointer<QObject> qobjectGuard(childObject->property("vp").value<QObject*>()); // get the pointer prior to processing deleteLater events.
+ QVERIFY(!qobjectGuard.isNull());
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(!qobjectGuard.isNull());
+ QMetaObject::invokeMethod(object, "deassignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(qobjectGuard.isNull()); // should have been collected now.
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVarReparent()
+{
+ // ensure that nothing breaks if we re-parent objects
+ QQmlComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignVarProp");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rect = object->property("vp").value<QObject*>();
+ QObject *text = rect->findChild<QObject*>("textOne");
+ QObject *text2 = rect->findChild<QObject*>("textTwo");
+ QWeakPointer<QObject> rectGuard(rect);
+ QWeakPointer<QObject> textGuard(text);
+ QWeakPointer<QObject> text2Guard(text2);
+ QVERIFY(!rectGuard.isNull());
+ QVERIFY(!textGuard.isNull());
+ QVERIFY(!text2Guard.isNull());
+ QCOMPARE(text->property("textCanary").toInt(), 11);
+ QCOMPARE(text2->property("textCanary").toInt(), 12);
+ // now construct an image which we will reparent.
+ QMetaObject::invokeMethod(text2, "constructQObject");
+ QObject *image = text2->property("vp").value<QObject*>();
+ QWeakPointer<QObject> imageGuard(image);
+ QVERIFY(!imageGuard.isNull());
+ QCOMPARE(image->property("imageCanary").toInt(), 13);
+ // now reparent the "Image" object (currently, it has JS ownership)
+ image->setParent(text); // shouldn't be collected after deassignVp now, since has a parent.
+ QMetaObject::invokeMethod(text2, "deassignVp");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QCOMPARE(text->property("textCanary").toInt(), 11);
+ QCOMPARE(text2->property("textCanary").toInt(), 22);
+ QVERIFY(!imageGuard.isNull()); // should still be alive.
+ QCOMPARE(image->property("imageCanary").toInt(), 13); // still able to access var properties
+ QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(imageGuard.isNull()); // should now have been deleted, due to parent being deleted.
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVarReparentNullContext()
+{
+ // sometimes reparenting can cause problems
+ // (eg, if the ctxt is collected, varproperties are no longer available)
+ // this test ensures that no crash occurs in that situation.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignVarProp");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rect = object->property("vp").value<QObject*>();
+ QObject *text = rect->findChild<QObject*>("textOne");
+ QObject *text2 = rect->findChild<QObject*>("textTwo");
+ QWeakPointer<QObject> rectGuard(rect);
+ QWeakPointer<QObject> textGuard(text);
+ QWeakPointer<QObject> text2Guard(text2);
+ QVERIFY(!rectGuard.isNull());
+ QVERIFY(!textGuard.isNull());
+ QVERIFY(!text2Guard.isNull());
+ QCOMPARE(text->property("textCanary").toInt(), 11);
+ QCOMPARE(text2->property("textCanary").toInt(), 12);
+ // now construct an image which we will reparent.
+ QMetaObject::invokeMethod(text2, "constructQObject");
+ QObject *image = text2->property("vp").value<QObject*>();
+ QWeakPointer<QObject> imageGuard(image);
+ QVERIFY(!imageGuard.isNull());
+ QCOMPARE(image->property("imageCanary").toInt(), 13);
+ // now reparent the "Image" object (currently, it has JS ownership)
+ image->setParent(object); // reparented to base object. after deassignVarProp, the ctxt will be invalid.
+ QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(!imageGuard.isNull()); // should still be alive.
+ QVERIFY(!image->property("imageCanary").isValid()); // but varProperties won't be available (null context).
+ delete object;
+ QVERIFY(imageGuard.isNull()); // should now be dead.
+}
+
+void tst_qqmlecmascript::propertyVarCircular()
+{
+ // enforce behaviour regarding circular references - ensure qdvmemo deletion.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.circular.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QCOMPARE(object->property("canaryInt"), QVariant(5));
+ QVariant canaryResourceVariant = object->property("canaryResource");
+ QVERIFY(canaryResourceVariant.isValid());
+ QPixmap canaryResourcePixmap = canaryResourceVariant.value<QPixmap>();
+ canaryResourceVariant = QVariant(); // invalidate it to remove one copy of the pixmap from memory.
+ QMetaObject::invokeMethod(object, "deassignCanaryResource"); // remove one copy of the pixmap from memory
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(!canaryResourcePixmap.isDetached()); // two copies extant - this and the propertyVar.vp.vp.vp.vp.memoryHog.
+ QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QCOMPARE(object->property("canaryInt"), QVariant(2));
+ QCOMPARE(object->property("canaryResource"), QVariant(1));
+ QVERIFY(canaryResourcePixmap.isDetached()); // now detached, since orig copy was member of qdvmemo which was deleted.
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVarCircular2()
+{
+ // track deletion of JS-owned parent item with Cpp-owned child
+ // where the child has a var property referencing its parent.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rootObject = object->property("vp").value<QObject*>();
+ QVERIFY(rootObject != 0);
+ QObject *childObject = rootObject->findChild<QObject*>("text");
+ QVERIFY(childObject != 0);
+ QWeakPointer<QObject> rootObjectTracker(rootObject);
+ QVERIFY(!rootObjectTracker.isNull());
+ QWeakPointer<QObject> childObjectTracker(childObject);
+ QVERIFY(!childObjectTracker.isNull());
+ gc(engine);
+ QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
+ QCOMPARE(childObject->property("textCanary").toInt(), 10);
+ QMetaObject::invokeMethod(object, "deassignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(rootObjectTracker.isNull()); // should have been collected
+ QVERIFY(childObjectTracker.isNull()); // should have been collected
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter)
+{
+ *(int*)(parameter) += 1;
+ qPersistentDispose(object);
+}
+
+void tst_qqmlecmascript::propertyVarInheritance()
+{
+ int propertyVarWeakRefCallbackCount = 0;
+
+ // enforce behaviour regarding element inheritance - ensure handle disposal.
+ // The particular component under test here has a chain of references.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.inherit.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ // we want to be able to track when the varProperties array of the last metaobject is disposed
+ QObject *cco5 = object->property("varProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
+ QObject *ico5 = object->property("varProperty").value<QObject*>()->property("inheritanceVarProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
+ QQmlVMEMetaObject *icovmemo = ((QQmlVMEMetaObject *)(ico5->metaObject()));
+ QQmlVMEMetaObject *ccovmemo = ((QQmlVMEMetaObject *)(cco5->metaObject()));
+ v8::Persistent<v8::Value> icoCanaryHandle;
+ v8::Persistent<v8::Value> ccoCanaryHandle;
+ {
+ v8::HandleScope hs;
+ // XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only
+ // public function which can return us a handle to something in the varProperties array.
+ icoCanaryHandle = qPersistentNew(icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ")));
+ ccoCanaryHandle = qPersistentNew(ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ")));
+ // we make them weak and invoke the gc, but we should not hit the weak-callback yet
+ // as the varproperties array of each vmemo still references the resource.
+ icoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
+ ccoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
+ gc(engine);
+ QVERIFY(propertyVarWeakRefCallbackCount == 0);
+ }
+ // now we deassign the var prop, which should trigger collection of item subtrees.
+ QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ // ensure that there are only weak handles to the underlying varProperties array remaining.
+ gc(engine);
+ QCOMPARE(propertyVarWeakRefCallbackCount, 2); // should have been called for both, since all refs should be weak.
+ delete object;
+ // since there are no parent vmemo's to keep implicit references alive, and the only handles
+ // to what remains are weak, all varProperties arrays must have been collected.
+}
+
+void tst_qqmlecmascript::propertyVarInheritance2()
+{
+ int propertyVarWeakRefCallbackCount = 0;
+
+ // The particular component under test here does NOT have a chain of references; the
+ // only link between rootObject and childObject is that rootObject is the parent of childObject.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rootObject = object->property("vp").value<QObject*>();
+ QVERIFY(rootObject != 0);
+ QObject *childObject = rootObject->findChild<QObject*>("text");
+ QVERIFY(childObject != 0);
+ QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
+ QCOMPARE(childObject->property("textCanary").toInt(), 10);
+ v8::Persistent<v8::Value> childObjectVarArrayValueHandle;
+ {
+ v8::HandleScope hs;
+ propertyVarWeakRefCallbackCount = 0; // reset callback count.
+ childObjectVarArrayValueHandle = qPersistentNew(((QQmlVMEMetaObject *)(childObject->metaObject()))->vmeProperty(childObject->metaObject()->indexOfProperty("vp")));
+ childObjectVarArrayValueHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
+ gc(engine);
+ QVERIFY(propertyVarWeakRefCallbackCount == 0); // should not have been collected yet.
+ QCOMPARE(childObject->property("vp").value<QObject*>(), rootObject);
+ QCOMPARE(childObject->property("textCanary").toInt(), 10);
+ }
+ QMetaObject::invokeMethod(object, "deassignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(propertyVarWeakRefCallbackCount == 1); // should have been collected now.
+ delete object;
+}
+
+// Ensure that QObject type conversion works on binding assignment
+void tst_qqmlecmascript::elementAssign()
+{
+ QQmlComponent component(&engine, testFileUrl("elementAssign.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// QTBUG-12457
+void tst_qqmlecmascript::objectPassThroughSignals()
+{
+ QQmlComponent component(&engine, testFileUrl("objectsPassThroughSignals.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// QTBUG-21626
+void tst_qqmlecmascript::objectConversion()
+{
+ QQmlComponent component(&engine, testFileUrl("objectConversion.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVariant retn;
+ QMetaObject::invokeMethod(object, "circularObject", Q_RETURN_ARG(QVariant, retn));
+ QCOMPARE(retn.value<QVariantMap>().value("test"), QVariant(100));
+
+ delete object;
+}
+
+
+// QTBUG-20242
+void tst_qqmlecmascript::booleanConversion()
+{
+ QQmlComponent component(&engine, testFileUrl("booleanConversion.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test_true1").toBool(), true);
+ QCOMPARE(object->property("test_true2").toBool(), true);
+ QCOMPARE(object->property("test_true3").toBool(), true);
+ QCOMPARE(object->property("test_true4").toBool(), true);
+ QCOMPARE(object->property("test_true5").toBool(), true);
+
+ QCOMPARE(object->property("test_false1").toBool(), false);
+ QCOMPARE(object->property("test_false2").toBool(), false);
+ QCOMPARE(object->property("test_false3").toBool(), false);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::handleReferenceManagement()
+{
+
+ int dtorCount = 0;
+ {
+ // Linear QObject reference
+ QQmlEngine hrmEngine;
+ QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
+ cro->setEngine(&hrmEngine);
+ cro->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object, "createReference");
+ gc(engine);
+ QCOMPARE(dtorCount, 0); // second has JS ownership, kept alive by first's reference
+ delete object;
+ hrmEngine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 3);
+ }
+
+ dtorCount = 0;
+ {
+ // Circular QObject reference
+ QQmlEngine hrmEngine;
+ QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
+ cro->setEngine(&hrmEngine);
+ cro->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object, "circularReference");
+ gc(engine);
+ QCOMPARE(dtorCount, 2); // both should be cleaned up, since circular references shouldn't keep alive.
+ delete object;
+ hrmEngine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 3);
+ }
+
+ dtorCount = 0;
+ {
+ // Linear handle reference
+ QQmlEngine hrmEngine;
+ QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh != 0);
+ crh->setEngine(&hrmEngine);
+ crh->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object, "createReference");
+ CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first != 0);
+ QVERIFY(second != 0);
+ first->addReference(QQmlData::get(second)->v8object); // create reference
+ // now we have to reparent second and make second owned by JS.
+ second->setParent(0);
+ QQmlEngine::setObjectOwnership(second, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCOMPARE(dtorCount, 0); // due to reference from first to second, second shouldn't be collected.
+ delete object;
+ hrmEngine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 3);
+ }
+
+ dtorCount = 0;
+ {
+ // Circular handle reference
+ QQmlEngine hrmEngine;
+ QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh != 0);
+ crh->setEngine(&hrmEngine);
+ crh->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object, "circularReference");
+ CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first != 0);
+ QVERIFY(second != 0);
+ first->addReference(QQmlData::get(second)->v8object); // create circular reference
+ second->addReference(QQmlData::get(first)->v8object); // note: must be weak.
+ // now we have to reparent and change ownership.
+ first->setParent(0);
+ second->setParent(0);
+ QQmlEngine::setObjectOwnership(first, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(second, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCOMPARE(dtorCount, 2); // despite circular references, both will be collected.
+ delete object;
+ hrmEngine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 3);
+ }
+
+ dtorCount = 0;
+ {
+ // multiple engine interaction - linear reference
+ QQmlEngine hrmEngine1;
+ QQmlEngine hrmEngine2;
+ QQmlComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QQmlComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QObject *object1 = component1.create();
+ QObject *object2 = component2.create();
+ QVERIFY(object1 != 0);
+ QVERIFY(object2 != 0);
+ CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
+ CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh1 != 0);
+ QVERIFY(crh2 != 0);
+ crh1->setEngine(&hrmEngine1);
+ crh2->setEngine(&hrmEngine2);
+ crh1->setDtorCount(&dtorCount);
+ crh2->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object1, "createReference");
+ QMetaObject::invokeMethod(object2, "createReference");
+ CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first1 != 0);
+ QVERIFY(second1 != 0);
+ QVERIFY(first2 != 0);
+ QVERIFY(second2 != 0);
+ first1->addReference(QQmlData::get(second2)->v8object); // create reference across engines
+ // now we have to reparent second2 and make second2 owned by JS.
+ second2->setParent(0);
+ QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 0); // due to reference from first1 to second2, second2 shouldn't be collected.
+ delete object1;
+ delete object2;
+ hrmEngine1.collectGarbage();
+ hrmEngine2.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 6);
+ }
+
+ dtorCount = 0;
+ {
+ // multiple engine interaction - circular reference
+ QQmlEngine hrmEngine1;
+ QQmlEngine hrmEngine2;
+ QQmlComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QQmlComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QObject *object1 = component1.create();
+ QObject *object2 = component2.create();
+ QVERIFY(object1 != 0);
+ QVERIFY(object2 != 0);
+ CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
+ CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh1 != 0);
+ QVERIFY(crh2 != 0);
+ crh1->setEngine(&hrmEngine1);
+ crh2->setEngine(&hrmEngine2);
+ crh1->setDtorCount(&dtorCount);
+ crh2->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object1, "createReference");
+ QMetaObject::invokeMethod(object2, "createReference");
+ CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first1 != 0);
+ QVERIFY(second1 != 0);
+ QVERIFY(first2 != 0);
+ QVERIFY(second2 != 0);
+ first1->addReference(QQmlData::get(second1)->v8object); // create linear reference within engine1
+ second1->addReference(QQmlData::get(second2)->v8object); // create linear reference across engines
+ second2->addReference(QQmlData::get(first2)->v8object); // create linear reference within engine2
+ first2->addReference(QQmlData::get(first1)->v8object); // close the loop - circular ref across engines
+ // now we have to reparent and change ownership to JS.
+ first1->setParent(0);
+ second1->setParent(0);
+ first2->setParent(0);
+ second2->setParent(0);
+ QQmlEngine::setObjectOwnership(first1, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(second1, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(first2, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 4); // circular references shouldn't keep them alive.
+ delete object1;
+ delete object2;
+ hrmEngine1.collectGarbage();
+ hrmEngine2.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 6);
+ }
+
+ dtorCount = 0;
+ {
+ // multiple engine interaction - linear reference with engine deletion
+ QQmlEngine *hrmEngine1 = new QQmlEngine;
+ QQmlEngine *hrmEngine2 = new QQmlEngine;
+ QQmlComponent component1(hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QQmlComponent component2(hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QObject *object1 = component1.create();
+ QObject *object2 = component2.create();
+ QVERIFY(object1 != 0);
+ QVERIFY(object2 != 0);
+ CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
+ CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh1 != 0);
+ QVERIFY(crh2 != 0);
+ crh1->setEngine(hrmEngine1);
+ crh2->setEngine(hrmEngine2);
+ crh1->setDtorCount(&dtorCount);
+ crh2->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object1, "createReference");
+ QMetaObject::invokeMethod(object2, "createReference");
+ CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first1 != 0);
+ QVERIFY(second1 != 0);
+ QVERIFY(first2 != 0);
+ QVERIFY(second2 != 0);
+ first1->addReference(QQmlData::get(second1)->v8object); // create linear reference within engine1
+ second1->addReference(QQmlData::get(second2)->v8object); // create linear reference across engines
+ second2->addReference(QQmlData::get(first2)->v8object); // create linear reference within engine2
+ // now we have to reparent and change ownership to JS.
+ first1->setParent(crh1);
+ second1->setParent(0);
+ first2->setParent(0);
+ second2->setParent(0);
+ QQmlEngine::setObjectOwnership(second1, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(first2, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCOMPARE(dtorCount, 0);
+ delete hrmEngine2;
+ gc(engine);
+ QCOMPARE(dtorCount, 0);
+ delete object1;
+ delete object2;
+ hrmEngine1->collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 6);
+ delete hrmEngine1;
+ }
+}
+
+void tst_qqmlecmascript::stringArg()
+{
+ QQmlComponent component(&engine, testFileUrl("stringArg.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "success");
+ QVERIFY(object->property("returnValue").toBool());
+
+ QString w1 = testFileUrl("stringArg.qml").toString() + QLatin1String(":45: Error: String.arg(): Invalid arguments");
+ QTest::ignoreMessage(QtWarningMsg, w1.toAscii().constData());
+ QMetaObject::invokeMethod(object, "failure");
+ QVERIFY(object->property("returnValue").toBool());
+
+ delete object;
+}
+
+void tst_qqmlecmascript::readonlyDeclaration()
+{
+ QQmlComponent component(&engine, testFileUrl("readonlyDeclaration.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QList<qreal>)
+Q_DECLARE_METATYPE(QList<bool>)
+Q_DECLARE_METATYPE(QList<QString>)
+Q_DECLARE_METATYPE(QList<QUrl>)
+void tst_qqmlecmascript::sequenceConversionRead()
+{
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.read.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
+ QVERIFY(seq != 0);
+
+ QMetaObject::invokeMethod(object, "readSequences");
+ QList<int> intList; intList << 1 << 2 << 3 << 4;
+ QCOMPARE(object->property("intListLength").toInt(), intList.length());
+ QCOMPARE(object->property("intList").value<QList<int> >(), intList);
+ QList<qreal> qrealList; qrealList << 1.1 << 2.2 << 3.3 << 4.4;
+ QCOMPARE(object->property("qrealListLength").toInt(), qrealList.length());
+ QCOMPARE(object->property("qrealList").value<QList<qreal> >(), qrealList);
+ QList<bool> boolList; boolList << true << false << true << false;
+ QCOMPARE(object->property("boolListLength").toInt(), boolList.length());
+ QCOMPARE(object->property("boolList").value<QList<bool> >(), boolList);
+ QList<QString> stringList; stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
+ QCOMPARE(object->property("stringListLength").toInt(), stringList.length());
+ QCOMPARE(object->property("stringList").value<QList<QString> >(), stringList);
+ QList<QUrl> urlList; urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
+ QCOMPARE(object->property("urlListLength").toInt(), urlList.length());
+ QCOMPARE(object->property("urlList").value<QList<QUrl> >(), urlList);
+ QStringList qstringList; qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
+ QCOMPARE(object->property("qstringListLength").toInt(), qstringList.length());
+ QCOMPARE(object->property("qstringList").value<QStringList>(), qstringList);
+
+ QMetaObject::invokeMethod(object, "readSequenceElements");
+ QCOMPARE(object->property("intVal").toInt(), 2);
+ QCOMPARE(object->property("qrealVal").toReal(), 2.2);
+ QCOMPARE(object->property("boolVal").toBool(), false);
+ QCOMPARE(object->property("stringVal").toString(), QString(QLatin1String("second")));
+ QCOMPARE(object->property("urlVal").toUrl(), QUrl("http://www.example2.com"));
+ QCOMPARE(object->property("qstringVal").toString(), QString(QLatin1String("second")));
+
+ QMetaObject::invokeMethod(object, "enumerateSequenceElements");
+ QCOMPARE(object->property("enumerationMatches").toBool(), true);
+
+ intList.clear(); intList << 1 << 2 << 3 << 4 << 5; // set by the enumerateSequenceElements test.
+ QQmlProperty seqProp(seq, "intListProperty");
+ QCOMPARE(seqProp.read().value<QList<int> >(), intList);
+ QQmlProperty seqProp2(seq, "intListProperty", &engine);
+ QCOMPARE(seqProp2.read().value<QList<int> >(), intList);
+
+ QMetaObject::invokeMethod(object, "testReferenceDeletion");
+ QCOMPARE(object->property("referenceDeletion").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.read.error.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
+ QVERIFY(seq != 0);
+
+ // we haven't registered QList<QPoint> as a sequence type.
+ QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'");
+ QString warningTwo = qmlFile.toString() + QLatin1String(":18: TypeError: Cannot read property 'length' of undefined");
+ QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
+ QTest::ignoreMessage(QtWarningMsg, warningTwo.toAscii().constData());
+
+ QMetaObject::invokeMethod(object, "performTest");
+
+ // QList<QPoint> has not been registered as a sequence type.
+ QCOMPARE(object->property("pointListLength").toInt(), 0);
+ QVERIFY(!object->property("pointList").isValid());
+ QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'");
+ QQmlProperty seqProp(seq, "pointListProperty", &engine);
+ QVERIFY(!seqProp.read().isValid()); // not a valid/known sequence type
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::sequenceConversionWrite()
+{
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.write.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
+ QVERIFY(seq != 0);
+
+ QMetaObject::invokeMethod(object, "writeSequences");
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QMetaObject::invokeMethod(object, "writeSequenceElements");
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QMetaObject::invokeMethod(object, "writeOtherElements");
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QMetaObject::invokeMethod(object, "testReferenceDeletion");
+ QCOMPARE(object->property("referenceDeletion").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.write.error.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
+ QVERIFY(seq != 0);
+
+ // we haven't registered QList<QPoint> as a sequence type, so writing shouldn't work.
+ QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QVariantList to void");
+ QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
+
+ QMetaObject::invokeMethod(object, "performTest");
+
+ QList<QPoint> pointList; pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6); // original values, shouldn't have changed
+ QCOMPARE(seq->pointListProperty(), pointList);
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::sequenceConversionArray()
+{
+ // ensure that in JS the returned sequences act just like normal JS Arrays.
+ QUrl qmlFile = testFileUrl("sequenceConversion.array.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "indexedAccess");
+ QVERIFY(object->property("success").toBool());
+ QMetaObject::invokeMethod(object, "arrayOperations");
+ QVERIFY(object->property("success").toBool());
+ QMetaObject::invokeMethod(object, "testEqualitySemantics");
+ QVERIFY(object->property("success").toBool());
+ QMetaObject::invokeMethod(object, "testReferenceDeletion");
+ QCOMPARE(object->property("referenceDeletion").toBool(), true);
+ delete object;
+}
+
+
+void tst_qqmlecmascript::sequenceConversionIndexes()
+{
+ // ensure that we gracefully fail if unsupported index values are specified.
+ // Qt container classes only support non-negative, signed integer index values.
+ QUrl qmlFile = testFileUrl("sequenceConversion.indexes.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QString w1 = qmlFile.toString() + QLatin1String(":34: Index out of range during length set");
+ QString w2 = qmlFile.toString() + QLatin1String(":41: Index out of range during indexed set");
+ QString w3 = qmlFile.toString() + QLatin1String(":48: Index out of range during indexed get");
+ QString w4 = qmlFile.toString() + QLatin1String(":78: std::bad_alloc during length set");
+ QString w5 = qmlFile.toString() + QLatin1String(":83: std::bad_alloc during indexed set");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w4));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w5));
+ QMetaObject::invokeMethod(object, "indexedAccess");
+ QVERIFY(object->property("success").toBool());
+ delete object;
+}
+
+void tst_qqmlecmascript::sequenceConversionThreads()
+{
+ // ensure that sequence conversion operations work correctly in a worker thread
+ // and that serialisation between the main and worker thread succeeds.
+ QUrl qmlFile = testFileUrl("sequenceConversion.threads.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "testIntSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testQrealSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testBoolSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testStringSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testQStringSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testUrlSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testVariantSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ delete object;
+}
+
+void tst_qqmlecmascript::sequenceConversionBindings()
+{
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.bindings.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QList<int> intList; intList << 1 << 2 << 3 << 12 << 7;
+ QCOMPARE(object->property("boundSequence").value<QList<int> >(), intList);
+ QCOMPARE(object->property("boundElement").toInt(), intList.at(3));
+ QList<int> intListTwo; intListTwo << 1 << 2 << 3 << 12 << 14;
+ QCOMPARE(object->property("boundSequenceTwo").value<QList<int> >(), intListTwo);
+ delete object;
+ }
+
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml");
+ QString warning = QString(QLatin1String("%1:17: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString());
+ QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::sequenceConversionCopy()
+{
+ QUrl qmlFile = testFileUrl("sequenceConversion.copy.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "testCopySequences");
+ QCOMPARE(object->property("success").toBool(), true);
+ QMetaObject::invokeMethod(object, "readSequenceCopyElements");
+ QCOMPARE(object->property("success").toBool(), true);
+ QMetaObject::invokeMethod(object, "testEqualitySemantics");
+ QCOMPARE(object->property("success").toBool(), true);
+ delete object;
+}
+
+void tst_qqmlecmascript::assignSequenceTypes()
+{
+ // test binding array to sequence type property
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.1.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1 << 2.2));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false << true));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com")));
+ QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one") << QLatin1String("two")));
+ QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two")));
+ delete object;
+ }
+
+ // test binding literal to sequence type property
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.2.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com")));
+ QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one")));
+ QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two")));
+ delete object;
+ }
+
+ // test binding single value to sequence type property
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.3.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ delete object;
+ }
+
+ // test assigning array to sequence type property in js function
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.4.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1 << 2.2));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false << true));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com")));
+ QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one") << QLatin1String("two")));
+ QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two")));
+ delete object;
+ }
+
+ // test assigning literal to sequence type property in js function
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.5.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com")));
+ QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one")));
+ QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two")));
+ delete object;
+ }
+
+ // test assigning single value to sequence type property in js function
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.6.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ delete object;
+ }
+
+ // test QList<QUrl> literal assignment and binding assignment causes url resolution when required
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.7.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
+ MySequenceConversionObject *msco2 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco2"));
+ MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3"));
+ MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
+ MySequenceConversionObject *msco5 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco5"));
+ QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0 && msco5 != 0);
+ QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
+ QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
+ QCOMPARE(msco5->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
+ delete object;
+ }
+}
+
+// Test that assigning a null object works
+// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
+void tst_qqmlecmascript::nullObjectBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("nullObjectBinding.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("test") == QVariant::fromValue((QObject *)0));
+
+ delete object;
+}
+
+// Test that bindings don't evaluate once the engine has been destroyed
+void tst_qqmlecmascript::deletedEngine()
+{
+ QQmlEngine *engine = new QQmlEngine;
+ QQmlComponent component(engine, testFileUrl("deletedEngine.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 39);
+ object->setProperty("b", QVariant(9));
+ QCOMPARE(object->property("a").toInt(), 117);
+
+ delete engine;
+
+ QCOMPARE(object->property("a").toInt(), 117);
+ object->setProperty("b", QVariant(10));
+ QCOMPARE(object->property("a").toInt(), 117);
+
+ delete object;
+}
+
+// Test the crashing part of QTBUG-9705
+void tst_qqmlecmascript::libraryScriptAssert()
+{
+ QQmlComponent component(&engine, testFileUrl("libraryScriptAssert.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::variantsAssignedUndefined()
+{
+ QQmlComponent component(&engine, testFileUrl("variantsAssignedUndefined.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 10);
+ QCOMPARE(object->property("test2").toInt(), 11);
+
+ object->setProperty("runTest", true);
+
+ QCOMPARE(object->property("test1"), QVariant());
+ QCOMPARE(object->property("test2"), QVariant());
+
+
+ delete object;
+}
+
+void tst_qqmlecmascript::qtbug_9792()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_9792.qml"));
+
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create(context));
+ QVERIFY(object != 0);
+
+ QTest::ignoreMessage(QtDebugMsg, "Hello world!");
+ object->basicSignal();
+
+ delete context;
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ object->basicSignal();
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+
+ delete object;
+}
+
+// Verifies that QQmlGuard<>s used in the vmemetaobject are cleaned correctly
+void tst_qqmlecmascript::qtcreatorbug_1289()
+{
+ QQmlComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QObject *nested = qvariant_cast<QObject *>(o->property("object"));
+ QVERIFY(nested != 0);
+
+ QVERIFY(qvariant_cast<QObject *>(nested->property("nestedObject")) == o);
+
+ delete nested;
+ nested = qvariant_cast<QObject *>(o->property("object"));
+ QVERIFY(nested == 0);
+
+ // If the bug is present, the next line will crash
+ delete o;
+}
+
+// Test that we shut down without stupid warnings
+void tst_qqmlecmascript::noSpuriousWarningsAtShutdown()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.qml"));
+
+ QObject *o = component.create();
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ delete o;
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+ }
+
+
+ {
+ QQmlComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.2.qml"));
+
+ QObject *o = component.create();
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ delete o;
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+ }
+}
+
+void tst_qqmlecmascript::canAssignNullToQObject()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("canAssignNullToQObject.1.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(o->objectProperty() != 0);
+
+ o->setProperty("runTest", true);
+
+ QVERIFY(o->objectProperty() == 0);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("canAssignNullToQObject.2.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(o->objectProperty() == 0);
+
+ delete o;
+ }
+}
+
+void tst_qqmlecmascript::functionAssignment_fromBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("functionAssignment.1.qml"));
+
+ QString url = component.url().toString();
+ QString warning = url + ":4: Unable to assign a function to a property.";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(!o->property("a").isValid());
+
+ delete o;
+}
+
+void tst_qqmlecmascript::functionAssignment_fromJS()
+{
+ QFETCH(QString, triggerProperty);
+
+ QQmlComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+ QVERIFY(!o->property("a").isValid());
+
+ o->setProperty("aNumber", QVariant(5));
+ o->setProperty(triggerProperty.toUtf8().constData(), true);
+ QCOMPARE(o->property("a"), QVariant(50));
+
+ o->setProperty("aNumber", QVariant(10));
+ QCOMPARE(o->property("a"), QVariant(100));
+
+ delete o;
+}
+
+void tst_qqmlecmascript::functionAssignment_fromJS_data()
+{
+ QTest::addColumn<QString>("triggerProperty");
+
+ QTest::newRow("assign to property") << "assignToProperty";
+ QTest::newRow("assign to property, from JS file") << "assignToPropertyFromJsFile";
+
+ QTest::newRow("assign to value type") << "assignToValueType";
+
+ QTest::newRow("use 'this'") << "assignWithThis";
+ QTest::newRow("use 'this' from JS file") << "assignWithThisFromJsFile";
+}
+
+void tst_qqmlecmascript::functionAssignmentfromJS_invalid()
+{
+ QQmlComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+ QVERIFY(!o->property("a").isValid());
+
+ o->setProperty("assignFuncWithoutReturn", true);
+ QVERIFY(!o->property("a").isValid());
+
+ QString url = component.url().toString();
+ QString warning = url + ":67: Unable to assign QString to int";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ o->setProperty("assignWrongType", true);
+
+ warning = url + ":71: Unable to assign QString to int";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ o->setProperty("assignWrongTypeToValueType", true);
+
+ delete o;
+}
+
+void tst_qqmlecmascript::eval()
+{
+ QQmlComponent component(&engine, testFileUrl("eval.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+
+ delete o;
+}
+
+void tst_qqmlecmascript::function()
+{
+ QQmlComponent component(&engine, testFileUrl("function.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+
+ delete o;
+}
+
+void tst_qqmlecmascript::functionException()
+{
+ // QTBUG-24037 - shouldn't crash.
+ QString errstr = testFileUrl("v8functionException.qml").toString() + QLatin1String(":13: SyntaxError: Unexpected token ILLEGAL");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(errstr));
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Exception occurred during compilation of function: dynamicSlot()");
+ QQmlComponent component(&engine, testFileUrl("v8functionException.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QMetaObject::invokeMethod(o, "dynamicSlot");
+ delete o;
+}
+
+// Test the "Qt.include" method
+void tst_qqmlecmascript::include()
+{
+ // Non-library relative include
+ {
+ QQmlComponent component(&engine, testFileUrl("include.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test0").toInt(), 99);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test2_1").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test3_1").toBool(), true);
+
+ delete o;
+ }
+
+ // Library relative include
+ {
+ QQmlComponent component(&engine, testFileUrl("include_shared.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test0").toInt(), 99);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test2_1").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test3_1").toBool(), true);
+
+ delete o;
+ }
+
+ // Callback
+ {
+ QQmlComponent component(&engine, testFileUrl("include_callback.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toBool(), true);
+
+ delete o;
+ }
+
+ // Including file with ".pragma library"
+ {
+ QQmlComponent component(&engine, testFileUrl("include_pragma.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toInt(), 100);
+
+ delete o;
+ }
+
+ // Remote - success
+ {
+ TestHTTPServer server(8111);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("include_remote.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QTRY_VERIFY(o->property("done").toBool() == true);
+ QTRY_VERIFY(o->property("done2").toBool() == true);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+
+ QCOMPARE(o->property("test6").toBool(), true);
+ QCOMPARE(o->property("test7").toBool(), true);
+ QCOMPARE(o->property("test8").toBool(), true);
+ QCOMPARE(o->property("test9").toBool(), true);
+ QCOMPARE(o->property("test10").toBool(), true);
+
+ delete o;
+ }
+
+ // Remote - error
+ {
+ TestHTTPServer server(8111);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("include_remote_missing.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QTRY_VERIFY(o->property("done").toBool() == true);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+
+ delete o;
+ }
+}
+
+void tst_qqmlecmascript::signalHandlers()
+{
+ QQmlComponent component(&engine, testFileUrl("signalHandlers.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QVERIFY(o->property("count").toInt() == 0);
+ QMetaObject::invokeMethod(o, "testSignalCall");
+ QCOMPARE(o->property("count").toInt(), 1);
+
+ QMetaObject::invokeMethod(o, "testSignalHandlerCall");
+ QCOMPARE(o->property("count").toInt(), 1);
+ QCOMPARE(o->property("errorString").toString(), QLatin1String("TypeError: Property 'onTestSignal' of object [object Object] is not a function"));
+
+ QVERIFY(o->property("funcCount").toInt() == 0);
+ QMetaObject::invokeMethod(o, "testSignalConnection");
+ QCOMPARE(o->property("funcCount").toInt(), 1);
+
+ QMetaObject::invokeMethod(o, "testSignalHandlerConnection");
+ QCOMPARE(o->property("funcCount").toInt(), 2);
+
+ QMetaObject::invokeMethod(o, "testSignalDefined");
+ QCOMPARE(o->property("definedResult").toBool(), true);
+
+ QMetaObject::invokeMethod(o, "testSignalHandlerDefined");
+ QCOMPARE(o->property("definedHandlerResult").toBool(), true);
+
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_10696()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_10696.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_11606()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_11606.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_11600()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_11600.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_21864()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_21864.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::rewriteMultiLineStrings()
+{
+ {
+ // QTBUG-23387
+ QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QTRY_COMPARE(o->property("test").toBool(), true);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings_crlf.1.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+ }
+}
+
+void tst_qqmlecmascript::qobjectConnectionListExceptionHandling()
+{
+ // QTBUG-23375
+ QQmlComponent component(&engine, testFileUrl("qobjectConnectionListExceptionHandling.qml"));
+ QString warning = component.url().toString() + QLatin1String(":13: TypeError: Cannot read property 'undefined' of undefined");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+// Reading and writing non-scriptable properties should fail
+void tst_qqmlecmascript::nonscriptable()
+{
+ QQmlComponent component(&engine, testFileUrl("nonscriptable.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("readOk").toBool(), true);
+ QCOMPARE(o->property("writeOk").toBool(), true);
+ delete o;
+}
+
+// deleteLater() should not be callable from QML
+void tst_qqmlecmascript::deleteLater()
+{
+ QQmlComponent component(&engine, testFileUrl("deleteLater.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::in()
+{
+ QQmlComponent component(&engine, testFileUrl("in.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::typeOf()
+{
+ QQmlComponent component(&engine, testFileUrl("typeOf.qml"));
+
+ // These warnings should not happen once QTBUG-21864 is fixed
+ QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString");
+ QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: Can't find variable: a");
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QEXPECT_FAIL("", "QTBUG-21864", Abort);
+ QCOMPARE(o->property("test1").toString(), QLatin1String("undefined"));
+ QCOMPARE(o->property("test2").toString(), QLatin1String("object"));
+ QCOMPARE(o->property("test3").toString(), QLatin1String("number"));
+ QCOMPARE(o->property("test4").toString(), QLatin1String("string"));
+ QCOMPARE(o->property("test5").toString(), QLatin1String("function"));
+ QCOMPARE(o->property("test6").toString(), QLatin1String("object"));
+ QCOMPARE(o->property("test7").toString(), QLatin1String("undefined"));
+ QCOMPARE(o->property("test8").toString(), QLatin1String("boolean"));
+ QCOMPARE(o->property("test9").toString(), QLatin1String("object"));
+
+ delete o;
+}
+
+void tst_qqmlecmascript::sharedAttachedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("sharedAttachedObject.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ delete o;
+}
+
+// QTBUG-13999
+void tst_qqmlecmascript::objectName()
+{
+ QQmlComponent component(&engine, testFileUrl("objectName.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toString(), QString("hello"));
+ QCOMPARE(o->property("test2").toString(), QString("ell"));
+
+ o->setObjectName("world");
+
+ QCOMPARE(o->property("test1").toString(), QString("world"));
+ QCOMPARE(o->property("test2").toString(), QString("orl"));
+
+ delete o;
+}
+
+void tst_qqmlecmascript::writeRemovesBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("writeRemovesBinding.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+}
+
+// Test bindings assigned to alias properties actually assign to the alias' target
+void tst_qqmlecmascript::aliasBindingsAssignCorrectly()
+{
+ QQmlComponent component(&engine, testFileUrl("aliasBindingsAssignCorrectly.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+}
+
+// Test bindings assigned to alias properties override a binding on the target (QTBUG-13719)
+void tst_qqmlecmascript::aliasBindingsOverrideTarget()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.2.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.3.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+}
+
+// Test that writes to alias properties override bindings on the alias target (QTBUG-13719)
+void tst_qqmlecmascript::aliasWritesOverrideBindings()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.2.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.3.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+}
+
+// Allow an alais to a composite element
+// QTBUG-20200
+void tst_qqmlecmascript::aliasToCompositeElement()
+{
+ QQmlComponent component(&engine, testFileUrl("aliasToCompositeElement.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::qtbug_20344()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_20344.qml"));
+
+ QString warning = component.url().toString() + ":5: Error: Exception thrown from within QObject slot";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::revisionErrors()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
+ QString warning2 = url + ":11: ReferenceError: Can't find variable: prop2";
+ QString warning3 = url + ":13: ReferenceError: Can't find variable: method2";
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors2.qml"));
+ QString url = component.url().toString();
+
+ // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
+ // method2, prop2 from MyRevisionedClass not available
+ // method4, prop4 from MyRevisionedSubclass not available
+ QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
+ QString warning2 = url + ":14: ReferenceError: Can't find variable: prop2";
+ QString warning3 = url + ":10: ReferenceError: Can't find variable: prop4";
+ QString warning4 = url + ":16: ReferenceError: Can't find variable: prop4";
+ QString warning5 = url + ":20: ReferenceError: Can't find variable: method2";
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors3.qml"));
+ QString url = component.url().toString();
+
+ // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
+ // All properties/methods available, except MyRevisionedBaseClassUnregistered rev 1
+ QString warning1 = url + ":30: ReferenceError: Can't find variable: methodD";
+ QString warning2 = url + ":10: ReferenceError: Can't find variable: propD";
+ QString warning3 = url + ":20: ReferenceError: Can't find variable: propD";
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::revision()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevision.qml"));
+ QString url = component.url().toString();
+
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevision2.qml"));
+ QString url = component.url().toString();
+
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevision3.qml"));
+ QString url = component.url().toString();
+
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ // Test that non-root classes can resolve revisioned methods
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevision4.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toReal(), 11.);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::realToInt()
+{
+ QQmlComponent component(&engine, testFileUrl("realToInt.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "test1");
+ QCOMPARE(object->value(), int(4));
+ QMetaObject::invokeMethod(object, "test2");
+ QCOMPARE(object->value(), int(8));
+}
+
+void tst_qqmlecmascript::urlProperty()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("urlProperty.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ object->setStringProperty("http://qt-project.org");
+ QCOMPARE(object->urlProperty(), QUrl("http://qt-project.org/index.html"));
+ QCOMPARE(object->intProperty(), 123);
+ QCOMPARE(object->value(), 1);
+ QCOMPARE(object->property("result").toBool(), true);
+ }
+}
+
+void tst_qqmlecmascript::urlPropertyWithEncoding()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("urlProperty.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ object->setStringProperty("http://qt-project.org");
+ QUrl encoded;
+ encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode);
+ QCOMPARE(object->urlProperty(), encoded);
+ QCOMPARE(object->value(), 0); // Interpreting URL as string yields canonicalised version
+ QCOMPARE(object->property("result").toBool(), true);
+ }
+}
+
+void tst_qqmlecmascript::urlListPropertyWithEncoding()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("urlListProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
+ MySequenceConversionObject *msco2 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco2"));
+ MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3"));
+ MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
+ QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0);
+ QUrl encoded;
+ encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode);
+ QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << encoded));
+ QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << encoded));
+ QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << encoded << encoded));
+ QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << encoded << encoded));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::dynamicString()
+{
+ QQmlComponent component(&engine, testFileUrl("dynamicString.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("stringProperty").toString(),
+ QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!"));
+}
+
+void tst_qqmlecmascript::automaticSemicolon()
+{
+ QQmlComponent component(&engine, testFileUrl("automaticSemicolon.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_qqmlecmascript::unaryExpression()
+{
+ QQmlComponent component(&engine, testFileUrl("unaryExpression.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Makes sure that a binding isn't double re-evaluated when it depends on the same variable twice
+void tst_qqmlecmascript::doubleEvaluate()
+{
+ QQmlComponent component(&engine, testFileUrl("doubleEvaluate.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ WriteCounter *wc = qobject_cast<WriteCounter *>(object);
+ QVERIFY(wc != 0);
+ QCOMPARE(wc->count(), 1);
+
+ wc->setProperty("x", 9);
+
+ QCOMPARE(wc->count(), 2);
+
+ delete object;
+}
+
+static QStringList messages;
+static void captureMsgHandler(QtMsgType, const char *msg)
+{
+ messages.append(QLatin1String(msg));
+}
+
+void tst_qqmlecmascript::nonNotifyable()
+{
+ QV4Compiler::enableV4(false);
+ QQmlComponent component(&engine, testFileUrl("nonNotifyable.qml"));
+ QV4Compiler::enableV4(true);
+
+ QtMsgHandler old = qInstallMsgHandler(captureMsgHandler);
+ messages.clear();
+ QObject *object = component.create();
+ qInstallMsgHandler(old);
+
+ QVERIFY(object != 0);
+
+ QString expected1 = QLatin1String("QQmlExpression: Expression ") +
+ component.url().toString() +
+ QLatin1String(":5 depends on non-NOTIFYable properties:");
+ QString expected2 = QLatin1String(" ") +
+ QLatin1String(object->metaObject()->className()) +
+ QLatin1String("::value");
+
+ QCOMPARE(messages.length(), 2);
+ QCOMPARE(messages.at(0), expected1);
+ QCOMPARE(messages.at(1), expected2);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::forInLoop()
+{
+ QQmlComponent component(&engine, testFileUrl("forInLoop.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "listProperty");
+
+ QStringList r = object->property("listResult").toString().split("|", QString::SkipEmptyParts);
+ QCOMPARE(r.size(), 3);
+ QCOMPARE(r[0],QLatin1String("0=obj1"));
+ QCOMPARE(r[1],QLatin1String("1=obj2"));
+ QCOMPARE(r[2],QLatin1String("2=obj3"));
+
+ //TODO: should test for in loop for other objects (such as QObjects) as well.
+
+ delete object;
+}
+
+// An object the binding depends on is deleted while the binding is still running
+void tst_qqmlecmascript::deleteWhileBindingRunning()
+{
+ QQmlComponent component(&engine, testFileUrl("deleteWhileBindingRunning.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::qtbug_22679()
+{
+ MyQmlObject object;
+ object.setStringProperty(QLatin1String("Please work correctly"));
+ engine.rootContext()->setContextProperty("contextProp", &object);
+
+ QQmlComponent component(&engine, testFileUrl("qtbug_22679.qml"));
+ qRegisterMetaType<QList<QQmlError> >("QList<QQmlError>");
+ QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QQmlError>)));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(warningsSpy.count(), 0);
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_22843_data()
+{
+ QTest::addColumn<bool>("library");
+
+ QTest::newRow("without .pragma library") << false;
+ QTest::newRow("with .pragma library") << true;
+}
+
+void tst_qqmlecmascript::qtbug_22843()
+{
+ QFETCH(bool, library);
+
+ QString fileName("qtbug_22843");
+ if (library)
+ fileName += QLatin1String(".library");
+ fileName += QLatin1String(".qml");
+
+ QQmlComponent component(&engine, testFileUrl(fileName));
+ QString url = component.url().toString();
+ QString warning1 = url.left(url.length()-3) + QLatin1String("js:4: SyntaxError: Unexpected token )");
+ QString warning2 = url + QLatin1String(":5: TypeError: Object [object Object] has no method 'func'");
+
+ qRegisterMetaType<QList<QQmlError> >("QList<QQmlError>");
+ QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QQmlError>)));
+ for (int x = 0; x < 3; ++x) {
+ warningsSpy.clear();
+ // For libraries, only the first import attempt should produce a
+ // SyntaxError warning; subsequent component creation should not
+ // attempt to reload the script.
+ bool expectSyntaxError = !library || (x == 0);
+ if (expectSyntaxError)
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(warningsSpy.count(), 1 + (expectSyntaxError?1:0));
+ delete object;
+ }
+}
+
+
+void tst_qqmlecmascript::switchStatement()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 5);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 4);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 1);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 5);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 4);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 5);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 6);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.4.qml"));
+
+ QString warning = component.url().toString() + ":4: Unable to assign [undefined] to int";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 5);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 3);
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ object->setStringProperty("something else");
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.5.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 1);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 1);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 1);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 1);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 1);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.6.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 123);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 123);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 321);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 321);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 0);
+ }
+}
+
+void tst_qqmlecmascript::withStatement()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("withStatement.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 123);
+ }
+}
+
+void tst_qqmlecmascript::tryStatement()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("tryStatement.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 123);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("tryStatement.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 321);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("tryStatement.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 1);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("tryStatement.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 1);
+ }
+}
+
+class CppInvokableWithQObjectDerived : public QObject
+{
+ Q_OBJECT
+public:
+ CppInvokableWithQObjectDerived() {}
+ ~CppInvokableWithQObjectDerived() {}
+
+ Q_INVOKABLE MyQmlObject *createMyQmlObject(QString data)
+ {
+ MyQmlObject *obj = new MyQmlObject();
+ obj->setStringProperty(data);
+ return obj;
+ }
+
+ Q_INVOKABLE QString getStringProperty(MyQmlObject *obj)
+ {
+ return obj->stringProperty();
+ }
+};
+
+void tst_qqmlecmascript::invokableWithQObjectDerived()
+{
+ CppInvokableWithQObjectDerived invokable;
+
+ {
+ QQmlEngine engine;
+ engine.rootContext()->setContextProperty("invokable", &invokable);
+
+ QQmlComponent component(&engine, testFileUrl("qobjectDerivedArgument.qml"));
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(object->property("result").value<bool>() == true);
+
+ delete object;
+ }
+}
+
+QTEST_MAIN(tst_qqmlecmascript)
+
+#include "tst_qqmlecmascript.moc"
diff --git a/tests/auto/qml/qqmlengine/qqmlengine.pro b/tests/auto/qml/qqmlengine/qqmlengine.pro
new file mode 100644
index 0000000000..e87b4e30aa
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/qqmlengine.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlengine
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlengine.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
new file mode 100644
index 0000000000..af2c897d7a
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -0,0 +1,365 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QNetworkAccessManager>
+#include <QPointer>
+#include <QDir>
+#include <QStandardPaths>
+#include <QDebug>
+#include <QQmlComponent>
+#include <QQmlNetworkAccessManagerFactory>
+#include <QQmlExpression>
+
+class tst_qqmlengine : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlengine() {}
+
+private slots:
+ void rootContext();
+ void networkAccessManager();
+ void baseUrl();
+ void contextForObject();
+ void offlineStoragePath();
+ void clearComponentCache();
+ void outputWarningsToStandardError();
+ void objectOwnership();
+ void multipleEngines();
+};
+
+void tst_qqmlengine::rootContext()
+{
+ QQmlEngine engine;
+
+ QVERIFY(engine.rootContext());
+
+ QCOMPARE(engine.rootContext()->engine(), &engine);
+ QVERIFY(engine.rootContext()->parentContext() == 0);
+}
+
+class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
+{
+public:
+ NetworkAccessManagerFactory() : manager(0) {}
+
+ QNetworkAccessManager *create(QObject *parent) {
+ manager = new QNetworkAccessManager(parent);
+ return manager;
+ }
+
+ QNetworkAccessManager *manager;
+};
+
+void tst_qqmlengine::networkAccessManager()
+{
+ QQmlEngine *engine = new QQmlEngine;
+
+ // Test QQmlEngine created manager
+ QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
+ QVERIFY(manager != 0);
+ delete engine;
+
+ // Test factory created manager
+ engine = new QQmlEngine;
+ NetworkAccessManagerFactory factory;
+ engine->setNetworkAccessManagerFactory(&factory);
+ QVERIFY(engine->networkAccessManagerFactory() == &factory);
+ QVERIFY(engine->networkAccessManager() == factory.manager);
+ delete engine;
+}
+
+void tst_qqmlengine::baseUrl()
+{
+ QQmlEngine engine;
+
+ QUrl cwd = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
+
+ QCOMPARE(engine.baseUrl(), cwd);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
+
+ QDir dir = QDir::current();
+ dir.cdUp();
+ QVERIFY(dir != QDir::current());
+ QDir::setCurrent(dir.path());
+ QVERIFY(QDir::current() == dir);
+
+ QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
+ QCOMPARE(engine.baseUrl(), cwd2);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd2.resolved(QUrl("main.qml")));
+
+ engine.setBaseUrl(cwd);
+ QCOMPARE(engine.baseUrl(), cwd);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
+}
+
+void tst_qqmlengine::contextForObject()
+{
+ QQmlEngine *engine = new QQmlEngine;
+
+ // Test null-object
+ QVERIFY(QQmlEngine::contextForObject(0) == 0);
+
+ // Test an object with no context
+ QObject object;
+ QVERIFY(QQmlEngine::contextForObject(&object) == 0);
+
+ // Test setting null-object
+ QQmlEngine::setContextForObject(0, engine->rootContext());
+
+ // Test setting null-context
+ QQmlEngine::setContextForObject(&object, 0);
+
+ // Test setting context
+ QQmlEngine::setContextForObject(&object, engine->rootContext());
+ QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext());
+
+ QQmlContext context(engine->rootContext());
+
+ // Try changing context
+ QTest::ignoreMessage(QtWarningMsg, "QQmlEngine::setContextForObject(): Object already has a QQmlContext");
+ QQmlEngine::setContextForObject(&object, &context);
+ QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext());
+
+ // Delete context
+ delete engine; engine = 0;
+ QVERIFY(QQmlEngine::contextForObject(&object) == 0);
+}
+
+void tst_qqmlengine::offlineStoragePath()
+{
+ // Without these set, QDesktopServices::storageLocation returns
+ // strings with extra "//" at the end. We set them to ignore this problem.
+ qApp->setApplicationName("tst_qqmlengine");
+ qApp->setOrganizationName("Nokia");
+ qApp->setOrganizationDomain("nokia.com");
+
+ QQmlEngine engine;
+
+ QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+ dir.mkpath("QML");
+ dir.cd("QML");
+ dir.mkpath("OfflineStorage");
+ dir.cd("OfflineStorage");
+
+ QCOMPARE(QDir::fromNativeSeparators(engine.offlineStoragePath()), dir.path());
+
+ engine.setOfflineStoragePath(QDir::homePath());
+ QCOMPARE(engine.offlineStoragePath(), QDir::homePath());
+}
+
+void tst_qqmlengine::clearComponentCache()
+{
+ QQmlEngine engine;
+
+ // Create original qml file
+ {
+ QFile file("temp.qml");
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 10\n}\n");
+ file.close();
+ }
+
+ // Test "test" property
+ {
+ QQmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 10);
+ delete obj;
+ }
+
+ // Modify qml file
+ {
+ QFile file("temp.qml");
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 11\n}\n");
+ file.close();
+ }
+
+ // Test cache hit
+ {
+ QQmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 10);
+ delete obj;
+ }
+
+ // Clear cache
+ engine.clearComponentCache();
+
+ // Test cache refresh
+ {
+ QQmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 11);
+ delete obj;
+ }
+}
+
+static QStringList warnings;
+static void msgHandler(QtMsgType, const char *warning)
+{
+ warnings << QString::fromUtf8(warning);
+}
+
+void tst_qqmlengine::outputWarningsToStandardError()
+{
+ QQmlEngine engine;
+
+ QCOMPARE(engine.outputWarningsToStandardError(), true);
+
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0; QtObject { property int a: undefined }", QUrl());
+
+ QVERIFY(c.isReady() == true);
+
+ warnings.clear();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+
+ QObject *o = c.create();
+
+ qInstallMsgHandler(old);
+
+ QVERIFY(o != 0);
+ delete o;
+
+ QCOMPARE(warnings.count(), 1);
+ QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int"));
+ warnings.clear();
+
+
+ engine.setOutputWarningsToStandardError(false);
+ QCOMPARE(engine.outputWarningsToStandardError(), false);
+
+
+ old = qInstallMsgHandler(msgHandler);
+
+ o = c.create();
+
+ qInstallMsgHandler(old);
+
+ QVERIFY(o != 0);
+ delete o;
+
+ QCOMPARE(warnings.count(), 0);
+}
+
+void tst_qqmlengine::objectOwnership()
+{
+ {
+ QCOMPARE(QQmlEngine::objectOwnership(0), QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership(0, QQmlEngine::JavaScriptOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(0), QQmlEngine::CppOwnership);
+ }
+
+ {
+ QObject o;
+ QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership(&o, QQmlEngine::CppOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership(&o, QQmlEngine::JavaScriptOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(&o, QQmlEngine::CppOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership);
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0; QtObject { property QtObject object: QtObject {} }", QUrl());
+
+ QObject *o = c.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(QQmlEngine::objectOwnership(o), QQmlEngine::CppOwnership);
+
+ QObject *o2 = qvariant_cast<QObject *>(o->property("object"));
+ QCOMPARE(QQmlEngine::objectOwnership(o2), QQmlEngine::JavaScriptOwnership);
+
+ delete o;
+ }
+
+}
+
+// Test an object can be accessed by multiple engines
+void tst_qqmlengine::multipleEngines()
+{
+ QObject o;
+ o.setObjectName("TestName");
+
+ // Simultaneous engines
+ {
+ QQmlEngine engine1;
+ QQmlEngine engine2;
+ engine1.rootContext()->setContextProperty("object", &o);
+ engine2.rootContext()->setContextProperty("object", &o);
+
+ QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
+ QQmlExpression expr2(engine2.rootContext(), 0, QString("object.objectName"));
+
+ QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
+ QCOMPARE(expr2.evaluate().toString(), QString("TestName"));
+ }
+
+ // Serial engines
+ {
+ QQmlEngine engine1;
+ engine1.rootContext()->setContextProperty("object", &o);
+ QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
+ QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
+ }
+ {
+ QQmlEngine engine1;
+ engine1.rootContext()->setContextProperty("object", &o);
+ QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
+ QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
+ }
+}
+
+QTEST_MAIN(tst_qqmlengine)
+
+#include "tst_qqmlengine.moc"
diff --git a/tests/auto/declarative/qdeclarativeerror/data/test.txt b/tests/auto/qml/qqmlerror/data/test.txt
index cdafd9ed82..cdafd9ed82 100644
--- a/tests/auto/declarative/qdeclarativeerror/data/test.txt
+++ b/tests/auto/qml/qqmlerror/data/test.txt
diff --git a/tests/auto/qml/qqmlerror/qqmlerror.pro b/tests/auto/qml/qqmlerror/qqmlerror.pro
new file mode 100644
index 0000000000..be2b9ab24f
--- /dev/null
+++ b/tests/auto/qml/qqmlerror/qqmlerror.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlerror
+SOURCES += tst_qqmlerror.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp
new file mode 100644
index 0000000000..b0e9f50a17
--- /dev/null
+++ b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlError>
+#include <QDebug>
+#include "../../shared/util.h"
+
+class tst_qqmlerror : public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void url();
+ void description();
+ void line();
+ void column();
+ void toString();
+
+ void copy();
+ void debug();
+};
+
+void tst_qqmlerror::url()
+{
+ QQmlError error;
+
+ QCOMPARE(error.url(), QUrl());
+
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+
+ QCOMPARE(error.url(), QUrl("http://www.nokia.com/main.qml"));
+
+ QQmlError error2 = error;
+
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+
+ error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
+
+ QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+}
+
+void tst_qqmlerror::description()
+{
+ QQmlError error;
+
+ QCOMPARE(error.description(), QString());
+
+ error.setDescription("An Error");
+
+ QCOMPARE(error.description(), QString("An Error"));
+
+ QQmlError error2 = error;
+
+ QCOMPARE(error2.description(), QString("An Error"));
+
+ error.setDescription("Another Error");
+
+ QCOMPARE(error.description(), QString("Another Error"));
+ QCOMPARE(error2.description(), QString("An Error"));
+}
+
+void tst_qqmlerror::line()
+{
+ QQmlError error;
+
+ QCOMPARE(error.line(), -1);
+
+ error.setLine(102);
+
+ QCOMPARE(error.line(), 102);
+
+ QQmlError error2 = error;
+
+ QCOMPARE(error2.line(), 102);
+
+ error.setLine(4);
+
+ QCOMPARE(error.line(), 4);
+ QCOMPARE(error2.line(), 102);
+}
+
+void tst_qqmlerror::column()
+{
+ QQmlError error;
+
+ QCOMPARE(error.column(), -1);
+
+ error.setColumn(16);
+
+ QCOMPARE(error.column(), 16);
+
+ QQmlError error2 = error;
+
+ QCOMPARE(error2.column(), 16);
+
+ error.setColumn(3);
+
+ QCOMPARE(error.column(), 3);
+ QCOMPARE(error2.column(), 16);
+}
+
+void tst_qqmlerror::toString()
+{
+ {
+ QQmlError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92:13: An Error"));
+ }
+
+ {
+ QQmlError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+
+ QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92: An Error"));
+ }
+}
+
+void tst_qqmlerror::copy()
+{
+ QQmlError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QQmlError error2(error);
+ QQmlError error3;
+ error3 = error;
+
+ error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
+ error.setDescription("Another Error");
+ error.setLine(2);
+ error.setColumn(33);
+
+ QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
+ QCOMPARE(error.description(), QString("Another Error"));
+ QCOMPARE(error.line(), 2);
+ QCOMPARE(error.column(), 33);
+
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+ QCOMPARE(error2.description(), QString("An Error"));
+ QCOMPARE(error2.line(), 92);
+ QCOMPARE(error2.column(), 13);
+
+ QCOMPARE(error3.url(), QUrl("http://www.nokia.com/main.qml"));
+ QCOMPARE(error3.description(), QString("An Error"));
+ QCOMPARE(error3.line(), 92);
+ QCOMPARE(error3.column(), 13);
+
+}
+
+void tst_qqmlerror::debug()
+{
+ {
+ QQmlError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QTest::ignoreMessage(QtWarningMsg, "http://www.nokia.com/main.qml:92:13: An Error ");
+ qWarning() << error;
+ }
+
+ {
+ QUrl url(dataDirectoryUrl().resolved(QUrl("test.txt")));
+ QQmlError error;
+ error.setUrl(url);
+ error.setDescription("An Error");
+ error.setLine(2);
+ error.setColumn(5);
+
+ QString out = url.toString() + ":2:5: An Error \n Line2 Content \n ^ ";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
+
+ qWarning() << error;
+ }
+
+ {
+ QUrl url(dataDirectoryUrl().resolved(QUrl("foo.txt")));
+ QQmlError error;
+ error.setUrl(url);
+ error.setDescription("An Error");
+ error.setLine(2);
+ error.setColumn(5);
+
+ QString out = url.toString() + ":2:5: An Error ";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
+
+ qWarning() << error;
+ }
+}
+
+
+
+QTEST_MAIN(tst_qqmlerror)
+
+#include "tst_qqmlerror.moc"
diff --git a/tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml b/tests/auto/qml/qqmlexpression/data/scriptString.qml
index 38c3d1b456..38c3d1b456 100644
--- a/tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml
+++ b/tests/auto/qml/qqmlexpression/data/scriptString.qml
diff --git a/tests/auto/qml/qqmlexpression/qqmlexpression.pro b/tests/auto/qml/qqmlexpression/qqmlexpression.pro
new file mode 100644
index 0000000000..c2c1aa86e3
--- /dev/null
+++ b/tests/auto/qml/qqmlexpression/qqmlexpression.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlexpression
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlexpression.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp
new file mode 100644
index 0000000000..5cc6289212
--- /dev/null
+++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlscriptstring.h>
+#include "../../shared/util.h"
+
+class tst_qqmlexpression : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlexpression() {}
+
+private slots:
+ void scriptString();
+ void syntaxError();
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlScriptString scriptString READ scriptString WRITE setScriptString)
+ Q_PROPERTY(QQmlScriptString scriptStringError READ scriptStringError WRITE setScriptStringError)
+public:
+ TestObject(QObject *parent = 0) : QObject(parent) {}
+
+ QQmlScriptString scriptString() const { return m_scriptString; }
+ void setScriptString(QQmlScriptString scriptString) { m_scriptString = scriptString; }
+
+ QQmlScriptString scriptStringError() const { return m_scriptStringError; }
+ void setScriptStringError(QQmlScriptString scriptString) { m_scriptStringError = scriptString; }
+
+private:
+ QQmlScriptString m_scriptString;
+ QQmlScriptString m_scriptStringError;
+};
+
+QML_DECLARE_TYPE(TestObject)
+
+void tst_qqmlexpression::scriptString()
+{
+ qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("scriptString.qml"));
+ TestObject *testObj = qobject_cast<TestObject*>(c.create());
+ QVERIFY(testObj != 0);
+
+ QQmlScriptString script = testObj->scriptString();
+ QCOMPARE(script.script(), QLatin1String("value1 + value2"));
+
+ QQmlExpression expression(script);
+ QVariant value = expression.evaluate();
+ QCOMPARE(value.toInt(), 15);
+
+ QQmlScriptString scriptError = testObj->scriptStringError();
+ QCOMPARE(scriptError.script(), QLatin1String("value3 * 5"));
+
+ //verify that the expression has the correct error location information
+ QQmlExpression expressionError(scriptError);
+ QVariant valueError = expressionError.evaluate();
+ QVERIFY(!valueError.isValid());
+ QVERIFY(expressionError.hasError());
+ QQmlError error = expressionError.error();
+ QCOMPARE(error.url(), c.url());
+ QCOMPARE(error.line(), 8);
+}
+
+// QTBUG-21310 - crash test
+void tst_qqmlexpression::syntaxError()
+{
+ QQmlEngine engine;
+ QQmlExpression expression(engine.rootContext(), 0, "asd asd");
+ QVariant v = expression.evaluate();
+ QCOMPARE(v, QVariant());
+}
+
+QTEST_MAIN(tst_qqmlexpression)
+
+#include "tst_qqmlexpression.moc"
diff --git a/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro b/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro
new file mode 100644
index 0000000000..9feeee15fd
--- /dev/null
+++ b/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlimageprovider
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlimageprovider.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp b/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp
new file mode 100644
index 0000000000..bc53544566
--- /dev/null
+++ b/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp
@@ -0,0 +1,424 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlimageprovider.h>
+#include <private/qquickimage_p.h>
+#include <QImageReader>
+#include <QWaitCondition>
+
+Q_DECLARE_METATYPE(QQmlImageProvider*);
+
+class tst_qqmlimageprovider : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlimageprovider()
+ {
+ }
+
+private slots:
+ void requestImage_sync_data();
+ void requestImage_sync();
+ void requestImage_async_data();
+ void requestImage_async();
+
+ void requestPixmap_sync_data();
+ void requestPixmap_sync();
+ void requestPixmap_async();
+
+ void removeProvider_data();
+ void removeProvider();
+
+ void threadTest();
+
+private:
+ QString newImageFileName() const;
+ void fillRequestTestsData(const QString &id);
+ void runTest(bool async, QQmlImageProvider *provider);
+};
+
+
+class TestQImageProvider : public QQmlImageProvider
+{
+public:
+ TestQImageProvider(bool *deleteWatch = 0)
+ : QQmlImageProvider(Image), deleteWatch(deleteWatch)
+ {
+ }
+
+ ~TestQImageProvider()
+ {
+ if (deleteWatch)
+ *deleteWatch = true;
+ }
+
+ QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
+ {
+ lastImageId = id;
+
+ if (id == QLatin1String("no-such-file.png"))
+ return QImage();
+
+ int width = 100;
+ int height = 100;
+ QImage image(width, height, QImage::Format_RGB32);
+ if (size)
+ *size = QSize(width, height);
+ if (requestedSize.isValid())
+ image = image.scaled(requestedSize);
+ return image;
+ }
+
+ bool *deleteWatch;
+ QString lastImageId;
+};
+Q_DECLARE_METATYPE(TestQImageProvider*);
+
+
+class TestQPixmapProvider : public QQmlImageProvider
+{
+public:
+ TestQPixmapProvider(bool *deleteWatch = 0)
+ : QQmlImageProvider(Pixmap), deleteWatch(deleteWatch)
+ {
+ }
+
+ ~TestQPixmapProvider()
+ {
+ if (deleteWatch)
+ *deleteWatch = true;
+ }
+
+ QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
+ {
+ lastImageId = id;
+
+ if (id == QLatin1String("no-such-file.png"))
+ return QPixmap();
+
+ int width = 100;
+ int height = 100;
+ QPixmap image(width, height);
+ if (size)
+ *size = QSize(width, height);
+ if (requestedSize.isValid())
+ image = image.scaled(requestedSize);
+ return image;
+ }
+
+ bool *deleteWatch;
+ QString lastImageId;
+};
+Q_DECLARE_METATYPE(TestQPixmapProvider*);
+
+
+QString tst_qqmlimageprovider::newImageFileName() const
+{
+ // need to generate new filenames each time or else images are loaded
+ // from cache and we won't get loading status changes when testing
+ // async loading
+ static int count = 0;
+ return QString("image://test/image-%1.png").arg(count++);
+}
+
+void tst_qqmlimageprovider::fillRequestTestsData(const QString &id)
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<QString>("imageId");
+ QTest::addColumn<QString>("properties");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QString>("error");
+
+ QString fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " simple test"))
+ << "image://test/" + fileName << fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference
+ << "image://Test/" + fileName << fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " url with no id"))
+ << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " url with path"))
+ << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " url with fragment"))
+ << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " url with query"))
+ << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName
+ << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " scaled image"))
+ << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << "";
+
+ QTest::newRow(QTest::toString(id + " missing"))
+ << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100)
+ << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png";
+
+ QTest::newRow(QTest::toString(id + " unknown provider"))
+ << "image://bogus/exists.png" << "" << "" << QSize()
+ << "file::2:1: QML Image: Invalid image provider: image://bogus/exists.png";
+}
+
+void tst_qqmlimageprovider::runTest(bool async, QQmlImageProvider *provider)
+{
+ QFETCH(QString, source);
+ QFETCH(QString, imageId);
+ QFETCH(QString, properties);
+ QFETCH(QSize, size);
+ QFETCH(QString, error);
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QQmlEngine engine;
+
+ engine.addImageProvider("test", provider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; "
+ + (async ? "asynchronous: true; " : "")
+ + properties + " }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (async)
+ QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+
+ QCOMPARE(obj->source(), QUrl(source));
+
+ if (error.isEmpty()) {
+ if (async)
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ else
+ QVERIFY(obj->status() == QQuickImage::Ready);
+ if (QByteArray(QTest::currentDataTag()).startsWith("qimage"))
+ QCOMPARE(static_cast<TestQImageProvider*>(provider)->lastImageId, imageId);
+ else
+ QCOMPARE(static_cast<TestQPixmapProvider*>(provider)->lastImageId, imageId);
+
+ QCOMPARE(obj->width(), qreal(size.width()));
+ QCOMPARE(obj->height(), qreal(size.height()));
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ if (async)
+ QTRY_VERIFY(obj->status() == QQuickImage::Error);
+ else
+ QVERIFY(obj->status() == QQuickImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qqmlimageprovider::requestImage_sync_data()
+{
+ fillRequestTestsData("qimage|sync");
+}
+
+void tst_qqmlimageprovider::requestImage_sync()
+{
+ bool deleteWatch = false;
+ runTest(false, new TestQImageProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
+}
+
+void tst_qqmlimageprovider::requestImage_async_data()
+{
+ fillRequestTestsData("qimage|async");
+}
+
+void tst_qqmlimageprovider::requestImage_async()
+{
+ bool deleteWatch = false;
+ runTest(true, new TestQImageProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
+}
+
+void tst_qqmlimageprovider::requestPixmap_sync_data()
+{
+ fillRequestTestsData("qpixmap");
+}
+
+void tst_qqmlimageprovider::requestPixmap_sync()
+{
+ bool deleteWatch = false;
+ runTest(false, new TestQPixmapProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
+}
+
+void tst_qqmlimageprovider::requestPixmap_async()
+{
+ QQmlEngine engine;
+ QQmlImageProvider *provider = new TestQPixmapProvider();
+
+ engine.addImageProvider("test", provider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ // pixmaps are loaded synchronously regardless of 'asynchronous' value
+ QString componentStr = "import QtQuick 2.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ delete obj;
+}
+
+void tst_qqmlimageprovider::removeProvider_data()
+{
+ QTest::addColumn<QQmlImageProvider*>("provider");
+
+ QTest::newRow("qimage") << static_cast<QQmlImageProvider*>(new TestQImageProvider);
+ QTest::newRow("qpixmap") << static_cast<QQmlImageProvider*>(new TestQPixmapProvider);
+}
+
+void tst_qqmlimageprovider::removeProvider()
+{
+ QFETCH(QQmlImageProvider*, provider);
+
+ QQmlEngine engine;
+
+ engine.addImageProvider("test", provider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ // add provider, confirm it works
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + newImageFileName() + "\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->status(), QQuickImage::Ready);
+
+ // remove the provider and confirm
+ QString fileName = newImageFileName();
+ QString error("file::2:1: QML Image: Invalid image provider: " + fileName);
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ engine.removeImageProvider("test");
+
+ obj->setSource(QUrl(fileName));
+ QCOMPARE(obj->status(), QQuickImage::Error);
+
+ delete obj;
+}
+
+class TestThreadProvider : public QQmlImageProvider
+{
+ public:
+ TestThreadProvider() : QQmlImageProvider(Image), ok(false) {}
+
+ ~TestThreadProvider() {}
+
+ QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
+ {
+ mutex.lock();
+ if (!ok)
+ cond.wait(&mutex);
+ mutex.unlock();
+ QVector<int> v;
+ for (int i = 0; i < 10000; i++)
+ v.prepend(i); //do some computation
+ QImage image(50,50, QImage::Format_RGB32);
+ image.fill(QColor(id).rgb());
+ if (size)
+ *size = image.size();
+ if (requestedSize.isValid())
+ image = image.scaled(requestedSize);
+ return image;
+ }
+
+ QWaitCondition cond;
+ QMutex mutex;
+ bool ok;
+};
+
+
+void tst_qqmlimageprovider::threadTest()
+{
+ QQmlEngine engine;
+
+ TestThreadProvider *provider = new TestThreadProvider;
+
+ engine.addImageProvider("test_thread", provider);
+ QVERIFY(engine.imageProvider("test_thread") != 0);
+
+ QString componentStr = "import QtQuick 2.0\nItem { \n"
+ "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n"
+ "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n"
+ "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n"
+ "Image { source: \"image://test_thread/yellow\"; asynchronous: true; }\n"
+ " }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QObject *obj = component.create();
+ //MUST not deadlock
+ QVERIFY(obj != 0);
+ QList<QQuickImage *> images = obj->findChildren<QQuickImage *>();
+ QCOMPARE(images.count(), 4);
+ QTest::qWait(100);
+ foreach (QQuickImage *img, images) {
+ QCOMPARE(img->status(), QQuickImage::Loading);
+ }
+ provider->ok = true;
+ provider->cond.wakeAll();
+ QTest::qWait(250);
+ foreach (QQuickImage *img, images) {
+ QTRY_VERIFY(img->status() == QQuickImage::Ready);
+ }
+}
+
+
+QTEST_MAIN(tst_qqmlimageprovider)
+
+#include "tst_qqmlimageprovider.moc"
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/AsynchronousIfNestedType.qml b/tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml
index 8a3f46ee72..8a3f46ee72 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/AsynchronousIfNestedType.qml
+++ b/tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.1.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml
index 18ff4aabb7..18ff4aabb7 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.1.qml
+++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.2.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml
index 3f6cd932de..3f6cd932de 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.2.qml
+++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.3.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml
index 7e5ee7cf5c..7e5ee7cf5c 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.3.qml
+++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/chainInCompletion.qml b/tests/auto/qml/qqmlincubator/data/chainInCompletion.qml
index e79fed356a..e79fed356a 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/chainInCompletion.qml
+++ b/tests/auto/qml/qqmlincubator/data/chainInCompletion.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/chainedAsynchronousIfNested.qml b/tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml
index 1300426cfa..1300426cfa 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/chainedAsynchronousIfNested.qml
+++ b/tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/clear.qml b/tests/auto/qml/qqmlincubator/data/clear.qml
index f00f975923..f00f975923 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/clear.qml
+++ b/tests/auto/qml/qqmlincubator/data/clear.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/clearDuringCompletion.qml b/tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml
index 556f460d58..556f460d58 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/clearDuringCompletion.qml
+++ b/tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml b/tests/auto/qml/qqmlincubator/data/contextDelete.qml
index c3952074f1..c3952074f1 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml
+++ b/tests/auto/qml/qqmlincubator/data/contextDelete.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/forceCompletion.qml b/tests/auto/qml/qqmlincubator/data/forceCompletion.qml
index 9b76701c1b..9b76701c1b 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/forceCompletion.qml
+++ b/tests/auto/qml/qqmlincubator/data/forceCompletion.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.js b/tests/auto/qml/qqmlincubator/data/nestedComponent.js
index 4b6b0bde43..4b6b0bde43 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.js
+++ b/tests/auto/qml/qqmlincubator/data/nestedComponent.js
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.qml b/tests/auto/qml/qqmlincubator/data/nestedComponent.qml
index dd20707456..dd20707456 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.qml
+++ b/tests/auto/qml/qqmlincubator/data/nestedComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/noIncubationController.qml b/tests/auto/qml/qqmlincubator/data/noIncubationController.qml
index 7d93e856f0..7d93e856f0 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/noIncubationController.qml
+++ b/tests/auto/qml/qqmlincubator/data/noIncubationController.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.errors.txt b/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt
index eeda289d35..eeda289d35 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.errors.txt
+++ b/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.qml b/tests/auto/qml/qqmlincubator/data/objectDeleted.qml
index f00f975923..f00f975923 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.qml
+++ b/tests/auto/qml/qqmlincubator/data/objectDeleted.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.1.qml b/tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml
index 748a3f0cbf..748a3f0cbf 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.1.qml
+++ b/tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.2.qml b/tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml
index e96ac00f21..e96ac00f21 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.2.qml
+++ b/tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/selfDelete.qml b/tests/auto/qml/qqmlincubator/data/selfDelete.qml
index c3952074f1..c3952074f1 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/selfDelete.qml
+++ b/tests/auto/qml/qqmlincubator/data/selfDelete.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/setInitialState.qml b/tests/auto/qml/qqmlincubator/data/setInitialState.qml
index 0fd61abfd2..0fd61abfd2 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/setInitialState.qml
+++ b/tests/auto/qml/qqmlincubator/data/setInitialState.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/statusChanged.nested.qml b/tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml
index 3a496ea6fe..3a496ea6fe 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/statusChanged.nested.qml
+++ b/tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/statusChanged.qml b/tests/auto/qml/qqmlincubator/data/statusChanged.qml
index 18ff4aabb7..18ff4aabb7 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/statusChanged.qml
+++ b/tests/auto/qml/qqmlincubator/data/statusChanged.qml
diff --git a/tests/auto/qml/qqmlincubator/qqmlincubator.pro b/tests/auto/qml/qqmlincubator/qqmlincubator.pro
new file mode 100644
index 0000000000..956d72402c
--- /dev/null
+++ b/tests/auto/qml/qqmlincubator/qqmlincubator.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qqmlincubator
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlincubator.cpp \
+ testtypes.cpp
+
+HEADERS += testtypes.h
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private network widgets testlib
diff --git a/tests/auto/qml/qqmlincubator/testtypes.cpp b/tests/auto/qml/qqmlincubator/testtypes.cpp
new file mode 100644
index 0000000000..7936fc146c
--- /dev/null
+++ b/tests/auto/qml/qqmlincubator/testtypes.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+#include <QtQml/qqml.h>
+
+SelfRegisteringType *SelfRegisteringType::m_me = 0;
+SelfRegisteringType::SelfRegisteringType()
+: m_v(0)
+{
+ m_me = this;
+}
+
+SelfRegisteringType *SelfRegisteringType::me()
+{
+ return m_me;
+}
+
+void SelfRegisteringType::clearMe()
+{
+ m_me = 0;
+}
+
+CompletionRegisteringType *CompletionRegisteringType::m_me = 0;
+CompletionRegisteringType::CompletionRegisteringType()
+{
+}
+
+void CompletionRegisteringType::classBegin()
+{
+}
+
+void CompletionRegisteringType::componentComplete()
+{
+ m_me = this;
+}
+
+CompletionRegisteringType *CompletionRegisteringType::me()
+{
+ return m_me;
+}
+
+void CompletionRegisteringType::clearMe()
+{
+ m_me = 0;
+}
+
+CallbackRegisteringType::callback CallbackRegisteringType::m_callback = 0;
+void *CallbackRegisteringType::m_data = 0;
+CallbackRegisteringType::CallbackRegisteringType()
+: m_v(0)
+{
+}
+
+void CallbackRegisteringType::clearCallback()
+{
+ m_callback = 0;
+ m_data = 0;
+}
+
+void CallbackRegisteringType::registerCallback(callback c, void *d)
+{
+ m_callback = c;
+ m_data = d;
+}
+
+CompletionCallbackType::callback CompletionCallbackType::m_callback = 0;
+void *CompletionCallbackType::m_data = 0;
+CompletionCallbackType::CompletionCallbackType()
+{
+}
+
+void CompletionCallbackType::classBegin()
+{
+}
+
+void CompletionCallbackType::componentComplete()
+{
+ if (m_callback) m_callback(this, m_data);
+}
+
+void CompletionCallbackType::clearCallback()
+{
+ m_callback = 0;
+ m_data = 0;
+}
+
+void CompletionCallbackType::registerCallback(callback c, void *d)
+{
+ m_callback = c;
+ m_data = d;
+}
+
+void registerTypes()
+{
+ qmlRegisterType<SelfRegisteringType>("Qt.test", 1,0, "SelfRegistering");
+ qmlRegisterType<CompletionRegisteringType>("Qt.test", 1,0, "CompletionRegistering");
+ qmlRegisterType<CallbackRegisteringType>("Qt.test", 1,0, "CallbackRegistering");
+ qmlRegisterType<CompletionCallbackType>("Qt.test", 1,0, "CompletionCallback");
+}
diff --git a/tests/auto/qml/qqmlincubator/testtypes.h b/tests/auto/qml/qqmlincubator/testtypes.h
new file mode 100644
index 0000000000..8ca7ee34ee
--- /dev/null
+++ b/tests/auto/qml/qqmlincubator/testtypes.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QQmlParserStatus>
+
+class SelfRegisteringType : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int value READ value WRITE setValue);
+public:
+ SelfRegisteringType();
+
+ int value() const { return m_v; }
+ void setValue(int v) { m_v = v; }
+
+ static SelfRegisteringType *me();
+ static void clearMe();
+
+private:
+ static SelfRegisteringType *m_me;
+
+ int m_v;
+};
+
+class CallbackRegisteringType : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int value READ value WRITE setValue)
+public:
+ CallbackRegisteringType();
+
+ int value() const { return m_v; }
+ void setValue(int v) { if (m_callback) m_callback(this, m_data); m_v = v; }
+
+ typedef void (*callback)(CallbackRegisteringType *, void *);
+ static void clearCallback();
+ static void registerCallback(callback, void *);
+
+private:
+ static callback m_callback;
+ static void *m_data;
+
+ int m_v;
+};
+
+class CompletionRegisteringType : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+public:
+ CompletionRegisteringType();
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+ static CompletionRegisteringType *me();
+ static void clearMe();
+
+private:
+ static CompletionRegisteringType *m_me;
+};
+
+class CompletionCallbackType : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+public:
+ CompletionCallbackType();
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+ typedef void (*callback)(CompletionCallbackType *, void *);
+ static void clearCallback();
+ static void registerCallback(callback, void *);
+
+private:
+ static callback m_callback;
+ static void *m_data;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
new file mode 100644
index 0000000000..fc54f715c9
--- /dev/null
+++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
@@ -0,0 +1,1030 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+#include <QUrl>
+#include <QDir>
+#include <QDebug>
+#include <qtest.h>
+#include <QPointer>
+#include <QFileInfo>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QQmlProperty>
+#include <QQmlComponent>
+#include <QQmlIncubator>
+#include "../../shared/util.h"
+
+class tst_qqmlincubator : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlincubator() {}
+
+private slots:
+ void initTestCase();
+
+ void incubationMode();
+ void objectDeleted();
+ void clear();
+ void noIncubationController();
+ void forceCompletion();
+ void setInitialState();
+ void clearDuringCompletion();
+ void objectDeletionAfterInit();
+ void recursiveClear();
+ void statusChanged();
+ void asynchronousIfNested();
+ void nestedComponent();
+ void chainedAsynchronousIfNested();
+ void chainedAsynchronousIfNestedOnCompleted();
+ void selfDelete();
+ void contextDelete();
+
+private:
+ QQmlIncubationController controller;
+ QQmlEngine engine;
+};
+
+#define VERIFY_ERRORS(component, errorfile) \
+ if (!errorfile) { \
+ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
+ qWarning() << "Unexpected Errors:" << component.errors(); \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ QFile file(QQmlDataTest::instance()->testFile(errorfile)); \
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
+ QByteArray data = file.readAll(); \
+ file.close(); \
+ QList<QByteArray> expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QQmlError> errors = component.errors(); \
+ QList<QByteArray> actual; \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QQmlError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ if (qgetenv("DEBUG") != "" && expected != actual) \
+ qWarning() << "Expected:" << expected << "Actual:" << actual; \
+ QCOMPARE(expected, actual); \
+ }
+
+void tst_qqmlincubator::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+ engine.setIncubationController(&controller);
+}
+
+void tst_qqmlincubator::incubationMode()
+{
+ {
+ QQmlIncubator incubator;
+ QCOMPARE(incubator.incubationMode(), QQmlIncubator::Asynchronous);
+ }
+ {
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ QCOMPARE(incubator.incubationMode(), QQmlIncubator::Asynchronous);
+ }
+ {
+ QQmlIncubator incubator(QQmlIncubator::Synchronous);
+ QCOMPARE(incubator.incubationMode(), QQmlIncubator::Synchronous);
+ }
+ {
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ QCOMPARE(incubator.incubationMode(), QQmlIncubator::AsynchronousIfNested);
+ }
+}
+
+void tst_qqmlincubator::objectDeleted()
+{
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("objectDeleted.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ QCOMPARE(incubator.status(), QQmlIncubator::Loading);
+ QVERIFY(SelfRegisteringType::me() == 0);
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ delete SelfRegisteringType::me();
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isError());
+ VERIFY_ERRORS(incubator, "objectDeleted.errors.txt");
+ QVERIFY(incubator.object() == 0);
+}
+
+void tst_qqmlincubator::clear()
+{
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("clear.qml"));
+ QVERIFY(component.isReady());
+
+ // Clear in null state
+ {
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ incubator.clear(); // no effect
+ QVERIFY(incubator.isNull());
+ }
+
+ // Clear in loading state
+ {
+ QQmlIncubator incubator;
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+ incubator.clear();
+ QVERIFY(incubator.isNull());
+ }
+
+ // Clear mid load
+ {
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QPointer<SelfRegisteringType> srt = SelfRegisteringType::me();
+
+ incubator.clear();
+ QVERIFY(incubator.isNull());
+ QVERIFY(srt.isNull());
+ }
+
+ // Clear in ready state
+ {
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QPointer<QObject> obj = incubator.object();
+
+ incubator.clear();
+ QVERIFY(incubator.isNull());
+ QVERIFY(incubator.object() == 0);
+ QVERIFY(!obj.isNull());
+
+ delete obj;
+ QVERIFY(obj.isNull());
+ }
+}
+
+void tst_qqmlincubator::noIncubationController()
+{
+ // All incubators should behave synchronously when there is no controller
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("noIncubationController.qml"));
+
+ QVERIFY(component.isReady());
+
+ {
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
+ delete incubator.object();
+ }
+
+ {
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
+ delete incubator.object();
+ }
+
+ {
+ QQmlIncubator incubator(QQmlIncubator::Synchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::forceCompletion()
+{
+ QQmlComponent component(&engine, testFileUrl("forceCompletion.qml"));
+ QVERIFY(component.isReady());
+
+ {
+ // forceCompletion on a null incubator does nothing
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ incubator.forceCompletion();
+ QVERIFY(incubator.isNull());
+ }
+
+ {
+ // forceCompletion immediately after creating an asynchronous object completes it
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+
+ incubator.forceCompletion();
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
+
+ delete incubator.object();
+ }
+
+ {
+ // forceCompletion during creation completes it
+ SelfRegisteringType::clearMe();
+
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ incubator.forceCompletion();
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
+
+ delete incubator.object();
+ }
+
+ {
+ // forceCompletion on a ready incubator has no effect
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+
+ incubator.forceCompletion();
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
+
+ incubator.forceCompletion();
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
+
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::setInitialState()
+{
+ QQmlComponent component(&engine, testFileUrl("setInitialState.qml"));
+ QVERIFY(component.isReady());
+
+ struct MyIncubator : public QQmlIncubator
+ {
+ MyIncubator(QQmlIncubator::IncubationMode mode)
+ : QQmlIncubator(mode) {}
+
+ virtual void setInitialState(QObject *o) {
+ QQmlProperty::write(o, "test2", 19);
+ QQmlProperty::write(o, "testData1", 201);
+ }
+ };
+
+ {
+ MyIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+ bool b = true;
+ controller.incubateWhile(&b);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false);
+ QCOMPARE(incubator.object()->property("test1").toInt(), 502);
+ QCOMPARE(incubator.object()->property("test2").toInt(), 19);
+ delete incubator.object();
+ }
+
+ {
+ MyIncubator incubator(QQmlIncubator::Synchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false);
+ QCOMPARE(incubator.object()->property("test1").toInt(), 502);
+ QCOMPARE(incubator.object()->property("test2").toInt(), 19);
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::clearDuringCompletion()
+{
+ CompletionRegisteringType::clearMe();
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("clearDuringCompletion.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ QCOMPARE(incubator.status(), QQmlIncubator::Loading);
+ QVERIFY(CompletionRegisteringType::me() == 0);
+
+ while (CompletionRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(CompletionRegisteringType::me() != 0);
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ QPointer<QObject> srt = SelfRegisteringType::me();
+
+ incubator.clear();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QVERIFY(incubator.isNull());
+ QVERIFY(srt.isNull());
+}
+
+void tst_qqmlincubator::objectDeletionAfterInit()
+{
+ QQmlComponent component(&engine, testFileUrl("clear.qml"));
+ QVERIFY(component.isReady());
+
+ struct MyIncubator : public QQmlIncubator
+ {
+ MyIncubator(QQmlIncubator::IncubationMode mode)
+ : QQmlIncubator(mode), obj(0) {}
+
+ virtual void setInitialState(QObject *o) {
+ obj = o;
+ }
+
+ QObject *obj;
+ };
+
+ SelfRegisteringType::clearMe();
+ MyIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+
+ while (!incubator.obj && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() != 0);
+
+ delete incubator.obj;
+
+ incubator.clear();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QVERIFY(incubator.isNull());
+}
+
+class Switcher : public QObject
+{
+ Q_OBJECT
+public:
+ Switcher(QQmlEngine *e) : QObject(), engine(e) { }
+
+ struct MyIncubator : public QQmlIncubator
+ {
+ MyIncubator(QQmlIncubator::IncubationMode mode, QObject *s)
+ : QQmlIncubator(mode), switcher(s) {}
+
+ virtual void setInitialState(QObject *o) {
+ if (o->objectName() == "switchMe")
+ connect(o, SIGNAL(switchMe()), switcher, SLOT(switchIt()));
+ }
+
+ QObject *switcher;
+ };
+
+ void start()
+ {
+ incubator = new MyIncubator(QQmlIncubator::Synchronous, this);
+ component = new QQmlComponent(engine, QQmlDataTest::instance()->testFileUrl("recursiveClear.1.qml"));
+ component->create(*incubator);
+ }
+
+ QQmlEngine *engine;
+ MyIncubator *incubator;
+ QQmlComponent *component;
+
+public slots:
+ void switchIt() {
+ component->deleteLater();
+ incubator->clear();
+ component = new QQmlComponent(engine, QQmlDataTest::instance()->testFileUrl("recursiveClear.2.qml"));
+ component->create(*incubator);
+ }
+};
+
+void tst_qqmlincubator::recursiveClear()
+{
+ Switcher switcher(&engine);
+ switcher.start();
+}
+
+void tst_qqmlincubator::statusChanged()
+{
+ class MyIncubator : public QQmlIncubator
+ {
+ public:
+ MyIncubator(QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous)
+ : QQmlIncubator(mode) {}
+
+ QList<int> statuses;
+ protected:
+ virtual void statusChanged(Status s) { statuses << s; }
+ virtual void setInitialState(QObject *) { statuses << -1; }
+ };
+
+ {
+ QQmlComponent component(&engine, testFileUrl("statusChanged.qml"));
+ QVERIFY(component.isReady());
+
+ MyIncubator incubator(QQmlIncubator::Synchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+ QCOMPARE(incubator.statuses.at(1), -1);
+ QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
+ delete incubator.object();
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("statusChanged.qml"));
+ QVERIFY(component.isReady());
+
+ MyIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+ QCOMPARE(incubator.statuses.count(), 1);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+ QCOMPARE(incubator.statuses.at(1), -1);
+ QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
+ delete incubator.object();
+ }
+
+ {
+ QQmlComponent component2(&engine, testFileUrl("statusChanged.nested.qml"));
+ QVERIFY(component2.isReady());
+
+ MyIncubator incubator(QQmlIncubator::Asynchronous);
+ component2.create(incubator);
+ QVERIFY(incubator.isLoading());
+ QCOMPARE(incubator.statuses.count(), 1);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isReady());
+ QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+ QCOMPARE(incubator.statuses.at(1), -1);
+ QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::asynchronousIfNested()
+{
+ // Asynchronous if nested within a finalized context behaves synchronously
+ {
+ QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.1.qml"));
+ QVERIFY(component.isReady());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 10);
+
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ component.create(incubator, 0, qmlContext(object));
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("a").toInt(), 10);
+ delete incubator.object();
+ delete object;
+ }
+
+ // Asynchronous if nested within an executing context behaves asynchronously, but prevents
+ // the parent from finishing
+ {
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.2.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() == 0);
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ QQmlIncubator nested(QQmlIncubator::AsynchronousIfNested);
+ component.create(nested, 0, qmlContext(SelfRegisteringType::me()));
+ QVERIFY(nested.isLoading());
+
+ while (nested.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(nested.isReady());
+ QVERIFY(incubator.isLoading());
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(nested.isReady());
+ QVERIFY(incubator.isReady());
+
+ delete nested.object();
+ delete incubator.object();
+ }
+
+ // AsynchronousIfNested within a synchronous AsynchronousIfNested behaves synchronously
+ {
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.3.qml"));
+ QVERIFY(component.isReady());
+
+ struct CallbackData {
+ CallbackData(QQmlEngine *e) : engine(e), pass(false) {}
+ QQmlEngine *engine;
+ bool pass;
+ static void callback(CallbackRegisteringType *o, void *data) {
+ CallbackData *d = (CallbackData *)data;
+
+ QQmlComponent c(d->engine, QQmlDataTest::instance()->testFileUrl("asynchronousIfNested.1.qml"));
+ if (!c.isReady()) return;
+
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ c.create(incubator, 0, qmlContext(o));
+
+ if (!incubator.isReady()) return;
+
+ if (incubator.object()->property("a").toInt() != 10) return;
+
+ d->pass = true;
+ }
+ };
+
+ CallbackData cd(&engine);
+ CallbackRegisteringType::registerCallback(&CallbackData::callback, &cd);
+
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ component.create(incubator);
+
+ QVERIFY(incubator.isReady());
+ QCOMPARE(cd.pass, true);
+
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::nestedComponent()
+{
+ QQmlComponent component(&engine, testFileUrl("nestedComponent.qml"));
+ QVERIFY(component.isReady());
+
+ QObject *object = component.create();
+
+ QQmlComponent *nested = object->property("c").value<QQmlComponent*>();
+ QVERIFY(nested);
+ QVERIFY(nested->isReady());
+
+ // Test without incubator
+ {
+ QObject *nestedObject = nested->create();
+ QCOMPARE(nestedObject->property("value").toInt(), 19988);
+ delete nestedObject;
+ }
+
+ // Test with incubator
+ {
+ QQmlIncubator incubator(QQmlIncubator::Synchronous);
+ nested->create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("value").toInt(), 19988);
+ delete incubator.object();
+ }
+
+ delete object;
+}
+
+// Checks that a new AsynchronousIfNested incubator can be correctly started in the
+// statusChanged() callback of another.
+void tst_qqmlincubator::chainedAsynchronousIfNested()
+{
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() == 0);
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ struct MyIncubator : public QQmlIncubator {
+ MyIncubator(MyIncubator *next, QQmlComponent *component, QQmlContext *ctxt)
+ : QQmlIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {}
+
+ protected:
+ virtual void statusChanged(Status s) {
+ if (s == Ready && next)
+ component->create(*next, 0, ctxt);
+ }
+
+ private:
+ MyIncubator *next;
+ QQmlComponent *component;
+ QQmlContext *ctxt;
+ };
+
+ MyIncubator incubator2(0, &component, 0);
+ MyIncubator incubator1(&incubator2, &component, qmlContext(SelfRegisteringType::me()));
+
+ component.create(incubator1, 0, qmlContext(SelfRegisteringType::me()));
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isLoading());
+ QVERIFY(incubator2.isNull());
+
+ while (incubator1.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isLoading());
+ QVERIFY(incubator2.isNull());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isLoading());
+
+ while (incubator2.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isLoading());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+}
+
+// Checks that new AsynchronousIfNested incubators can be correctly chained if started in
+// componentCompleted().
+void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted()
+{
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("chainInCompletion.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlComponent c1(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
+ QVERIFY(c1.isReady());
+
+ struct MyIncubator : public QQmlIncubator {
+ MyIncubator(MyIncubator *next, QQmlComponent *component, QQmlContext *ctxt)
+ : QQmlIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {}
+
+ protected:
+ virtual void statusChanged(Status s) {
+ if (s == Ready && next) {
+ component->create(*next, 0, ctxt);
+ }
+ }
+
+ private:
+ MyIncubator *next;
+ QQmlComponent *component;
+ QQmlContext *ctxt;
+ };
+
+ struct CallbackData {
+ CallbackData(QQmlComponent *c, MyIncubator *i, QQmlContext *ct)
+ : component(c), incubator(i), ctxt(ct) {}
+ QQmlComponent *component;
+ MyIncubator *incubator;
+ QQmlContext *ctxt;
+ static void callback(CompletionCallbackType *, void *data) {
+ CallbackData *d = (CallbackData *)data;
+ d->component->create(*d->incubator, 0, d->ctxt);
+ }
+ };
+
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() == 0);
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ MyIncubator incubator3(0, &c1, qmlContext(SelfRegisteringType::me()));
+ MyIncubator incubator2(&incubator3, &c1, qmlContext(SelfRegisteringType::me()));
+ MyIncubator incubator1(&incubator2, &c1, qmlContext(SelfRegisteringType::me()));
+
+ // start incubator1 in componentComplete
+ CallbackData cd(&c1, &incubator1, qmlContext(SelfRegisteringType::me()));
+ CompletionCallbackType::registerCallback(&CallbackData::callback, &cd);
+
+ while (!incubator1.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator2.isNull());
+ QVERIFY(incubator3.isNull());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isLoading());
+ QVERIFY(incubator2.isNull());
+ QVERIFY(incubator3.isNull());
+
+ while (incubator1.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isLoading());
+ QVERIFY(incubator2.isNull());
+ QVERIFY(incubator3.isNull());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isLoading());
+ QVERIFY(incubator3.isNull());
+
+ while (incubator2.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isLoading());
+ QVERIFY(incubator3.isNull());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+ QVERIFY(incubator3.isLoading());
+
+ while (incubator3.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+ QVERIFY(incubator3.isLoading());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+ QVERIFY(incubator3.isReady());
+}
+
+void tst_qqmlincubator::selfDelete()
+{
+ struct MyIncubator : public QQmlIncubator {
+ MyIncubator(bool *done, Status status, IncubationMode mode)
+ : QQmlIncubator(mode), done(done), status(status) {}
+
+ protected:
+ virtual void statusChanged(Status s) {
+ if (s == status) {
+ *done = true;
+ if (s == Ready) delete object();
+ delete this;
+ }
+ }
+
+ private:
+ bool *done;
+ Status status;
+ };
+
+ {
+ QQmlComponent component(&engine, testFileUrl("selfDelete.qml"));
+
+#define DELETE_TEST(status, mode) { \
+ bool done = false; \
+ component.create(*(new MyIncubator(&done, status, mode))); \
+ bool True = true; \
+ controller.incubateWhile(&True); \
+ QVERIFY(done == true); \
+ }
+
+ DELETE_TEST(QQmlIncubator::Loading, QQmlIncubator::Synchronous);
+ DELETE_TEST(QQmlIncubator::Ready, QQmlIncubator::Synchronous);
+ DELETE_TEST(QQmlIncubator::Loading, QQmlIncubator::Asynchronous);
+ DELETE_TEST(QQmlIncubator::Ready, QQmlIncubator::Asynchronous);
+
+#undef DELETE_TEST
+ }
+
+ // Delete within error status
+ {
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("objectDeleted.qml"));
+ QVERIFY(component.isReady());
+
+ bool done = false;
+ MyIncubator *incubator = new MyIncubator(&done, QQmlIncubator::Error,
+ QQmlIncubator::Asynchronous);
+ component.create(*incubator);
+
+ QCOMPARE(incubator->QQmlIncubator::status(), QQmlIncubator::Loading);
+ QVERIFY(SelfRegisteringType::me() == 0);
+
+ while (SelfRegisteringType::me() == 0 && incubator->isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator->isLoading());
+
+ delete SelfRegisteringType::me();
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(done);
+ }
+}
+
+// Test that QML doesn't crash if the context is deleted prior to the incubator
+// first executing.
+void tst_qqmlincubator::contextDelete()
+{
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ QQmlComponent component(&engine, testFileUrl("contextDelete.qml"));
+
+ QQmlIncubator incubator;
+ component.create(incubator, context);
+
+ delete context;
+
+ {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+}
+
+QTEST_MAIN(tst_qqmlincubator)
+
+#include "tst_qqmlincubator.moc"
diff --git a/tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml b/tests/auto/qml/qqmlinfo/data/NestedComponent.qml
index cfe47589df..cfe47589df 100644
--- a/tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml
+++ b/tests/auto/qml/qqmlinfo/data/NestedComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml b/tests/auto/qml/qqmlinfo/data/NestedObject.qml
index 4b19b11699..4b19b11699 100644
--- a/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml
+++ b/tests/auto/qml/qqmlinfo/data/NestedObject.qml
diff --git a/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml b/tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml
index d199a612c4..d199a612c4 100644
--- a/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml
+++ b/tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml
diff --git a/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml b/tests/auto/qml/qqmlinfo/data/qmlObject.qml
index 6a8e2fbc90..6a8e2fbc90 100644
--- a/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml
+++ b/tests/auto/qml/qqmlinfo/data/qmlObject.qml
diff --git a/tests/auto/qml/qqmlinfo/qqmlinfo.pro b/tests/auto/qml/qqmlinfo/qqmlinfo.pro
new file mode 100644
index 0000000000..21dc2c76a6
--- /dev/null
+++ b/tests/auto/qml/qqmlinfo/qqmlinfo.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qqmlinfo
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlinfo.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private widgets testlib
diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
new file mode 100644
index 0000000000..ed53cbd1aa
--- /dev/null
+++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QTimer>
+#include <QQmlContext>
+#include <qqmlinfo.h>
+#include "../../shared/util.h"
+
+class tst_qqmlinfo : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlinfo() {}
+
+private slots:
+ void qmlObject();
+ void nestedQmlObject();
+ void nestedComponent();
+ void nonQmlObject();
+ void nullObject();
+ void nonQmlContextedObject();
+ void types();
+ void chaining();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlinfo::qmlObject()
+{
+ QQmlComponent component(&engine, testFileUrl("qmlObject.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QString message = component.url().toString() + ":3:1: QML QtObject: Test Message";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(object) << "Test Message";
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+
+ message = component.url().toString() + ":6:13: QML QtObject: Second Test Message";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Second Test Message";
+}
+
+void tst_qqmlinfo::nestedQmlObject()
+{
+ QQmlComponent component(&engine, testFileUrl("nestedQmlObject.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+ QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
+ QVERIFY(nested2 != 0);
+
+ QString message = component.url().toString() + ":5:13: QML NestedObject: Outer Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Outer Object";
+
+ message = testFileUrl("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested2) << "Inner Object";
+}
+
+void tst_qqmlinfo::nestedComponent()
+{
+ QQmlComponent component(&engine, testFileUrl("NestedComponent.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+ QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
+ QVERIFY(nested2 != 0);
+
+ QString message = component.url().toString() + ":10:9: QML NestedObject: Complex Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Complex Object";
+
+ message = component.url().toString() + ":16:9: QML Image: Simple Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested2) << "Simple Object";
+}
+
+void tst_qqmlinfo::nonQmlObject()
+{
+ QObject object;
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Test Message");
+ qmlInfo(&object) << "Test Message";
+
+ QTimer nonQmlObject;
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QTimer: Test Message");
+ qmlInfo(&nonQmlObject) << "Test Message";
+}
+
+void tst_qqmlinfo::nullObject()
+{
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Null Object Test Message");
+ qmlInfo(0) << "Null Object Test Message";
+}
+
+void tst_qqmlinfo::nonQmlContextedObject()
+{
+ QObject object;
+ QQmlContext context(&engine);
+ QQmlEngine::setContextForObject(&object, &context);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Test Message");
+ qmlInfo(&object) << "Test Message";
+}
+
+void tst_qqmlinfo::types()
+{
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false");
+ qmlInfo(0) << false;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.1");
+ qmlInfo(0) << 1.1;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.2");
+ qmlInfo(0) << 1.2f;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 15");
+ qmlInfo(0) << 15;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 'b'");
+ qmlInfo(0) << QChar('b');
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: \"Qt\"");
+ qmlInfo(0) << QByteArray("Qt");
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: true");
+ qmlInfo(0) << bool(true);
+
+ //### do we actually want QUrl to show up in the output?
+ //### why the extra space at the end?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QUrl(\"http://qt.nokia.com\") ");
+ qmlInfo(0) << QUrl("http://qt.nokia.com");
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: hello");
+ qmlInfo(0) << QLatin1String("hello");
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: World");
+ QString str("Hello World");
+ QStringRef ref(&str, 6, 5);
+ qmlInfo(0) << ref;
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Quick");
+ qmlInfo(0) << QString ("Quick");
+}
+
+void tst_qqmlinfo::chaining()
+{
+ //### should more of these be automatically inserting spaces?
+ QString str("Hello World");
+ QStringRef ref(&str, 6, 5);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' QUrl(\"http://qt.nokia.com\") World \"Qt\" true Quick ");
+ qmlInfo(0) << false << ' '
+ << 1.1 << ' '
+ << 1.2f << ' '
+ << 15 << ' '
+ << QLatin1String("hello") << ' '
+ << QChar('b') << ' '
+ << QUrl("http://qt.nokia.com")
+ << ref
+ << QByteArray("Qt")
+ << bool(true)
+ << QString ("Quick");
+}
+
+QTEST_MAIN(tst_qqmlinfo)
+
+#include "tst_qqmlinfo.moc"
diff --git a/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro
new file mode 100644
index 0000000000..093b190bbf
--- /dev/null
+++ b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qqmlinstruction
+SOURCES += tst_qqmlinstruction.cpp
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private testlib
diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp
new file mode 100644
index 0000000000..d076f038d3
--- /dev/null
+++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp
@@ -0,0 +1,678 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <private/qqmlcompiler_p.h>
+
+class tst_qqmlinstruction : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlinstruction() {}
+
+private slots:
+ void dump();
+
+ void point();
+ void pointf();
+ void size();
+ void sizef();
+ void rect();
+ void rectf();
+ void vector3d();
+ void vector4d();
+ void time();
+};
+
+static QStringList messages;
+static void msgHandler(QtMsgType, const char *msg)
+{
+ messages << QLatin1String(msg);
+}
+
+void tst_qqmlinstruction::dump()
+{
+ QQmlEngine engine;
+ QQmlCompiledData *data = new QQmlCompiledData(&engine);
+
+ {
+ QQmlCompiledData::Instruction::Init i;
+ i.bindingsSize = 0;
+ i.parserStatusSize = 3;
+ i.contextCache = -1;
+ i.compiledBinding = -1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::TypeReference ref;
+ ref.className = "Test";
+ data->types << ref;
+
+ QQmlCompiledData::Instruction::CreateCppObject i;
+ i.type = 0;
+ i.data = -1;
+ i.column = 10;
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "testId";
+
+ QQmlCompiledData::Instruction::SetId i;
+ i.value = data->primitives.count() - 1;
+ i.index = 0;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::SetDefault i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::CreateComponent i;
+ i.count = 3;
+ i.column = 4;
+ i.endLine = 14;
+ i.metaObject = 0;
+
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreMetaObject i;
+ i.data = 3;
+ i.aliasData = 6;
+ i.propertyCache = 7;
+
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreFloat i;
+ i.propertyIndex = 3;
+ i.value = 11.3;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreDouble i;
+ i.propertyIndex = 4;
+ i.value = 14.8;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreInteger i;
+ i.propertyIndex = 5;
+ i.value = 9;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreBool i;
+ i.propertyIndex = 6;
+ i.value = true;
+
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "Test String";
+ QQmlCompiledData::Instruction::StoreString i;
+ i.propertyIndex = 7;
+ i.value = data->primitives.count() - 1;
+ data->addInstruction(i);
+ }
+
+ {
+ data->urls << QUrl("http://www.nokia.com");
+ QQmlCompiledData::Instruction::StoreUrl i;
+ i.propertyIndex = 8;
+ i.value = data->urls.count() - 1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreColor i;
+ i.propertyIndex = 9;
+ i.value = 0xFF00FF00;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreDate i;
+ i.propertyIndex = 10;
+ i.value = 9;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreTime i;
+ i.propertyIndex = 11;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreDateTime i;
+ i.propertyIndex = 12;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StorePoint i;
+ i.propertyIndex = 13;
+ i.point.xp = 3;
+ i.point.yp = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StorePointF i;
+ i.propertyIndex = 13;
+ i.point.xp = 3;
+ i.point.yp = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreSize i;
+ i.propertyIndex = 15;
+ i.size.wd = 8;
+ i.size.ht = 11;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreSizeF i;
+ i.propertyIndex = 15;
+ i.size.wd = 8;
+ i.size.ht = 11;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreRect i;
+ i.propertyIndex = 17;
+ i.rect.x1 = 7;
+ i.rect.y1 = 9;
+ i.rect.x2 = 11;
+ i.rect.y2 = 13;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreRectF i;
+ i.propertyIndex = 18;
+ i.rect.xp = 11.3;
+ i.rect.yp = 9.8;
+ i.rect.w = 3;
+ i.rect.h = 2.1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreVector3D i;
+ i.propertyIndex = 19;
+ i.vector.xp = 9;
+ i.vector.yp = 3;
+ i.vector.zp = 92;
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "color(1, 1, 1, 1)";
+ QQmlCompiledData::Instruction::StoreVariant i;
+ i.propertyIndex = 20;
+ i.value = data->primitives.count() - 1;
+
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreObject i;
+ i.propertyIndex = 21;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreVariantObject i;
+ i.propertyIndex = 22;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreInterface i;
+ i.propertyIndex = 23;
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "console.log(1921)";
+
+ QQmlCompiledData::Instruction::StoreSignal i;
+ i.signalIndex = 2;
+ i.value = data->primitives.count() - 1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreScriptString i;
+ i.propertyIndex = 24;
+ i.value = 3;
+ i.scope = 1;
+ i.bindingId = 4;
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "mySignal";
+
+ QQmlCompiledData::Instruction::AssignSignalObject i;
+ i.signal = data->primitives.count() - 1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::AssignCustomType i;
+ i.propertyIndex = 25;
+ i.primitive = 6;
+ i.type = 9;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreBinding i;
+ i.property.coreIndex = 26;
+ i.value = 3;
+ i.context = 2;
+ i.owner = 0;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreV4Binding i;
+ i.property = 27;
+ i.value = 2;
+ i.context = 4;
+ i.owner = 0;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreValueSource i;
+ i.property.coreIndex = 29;
+ i.owner = 1;
+ i.castValue = 4;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreValueInterceptor i;
+ i.property.coreIndex = 30;
+ i.owner = 2;
+ i.castValue = -4;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::BeginObject i;
+ i.castValue = 4;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreObjectQList i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::AssignObjectList i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::FetchAttached i;
+ i.id = 23;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::FetchQList i;
+ i.property = 32;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::FetchObject i;
+ i.property = 33;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::FetchValueType i;
+ i.property = 34;
+ i.type = 6;
+ i.bindingSkipList = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::PopFetchedObject i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::PopQList i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::PopValueType i;
+ i.property = 35;
+ i.type = 8;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::Defer i;
+ i.deferCount = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::Defer i;
+ i.deferCount = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreImportedScript i;
+ i.value = 2;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreVariantInteger i;
+ i.value = 11;
+ i.propertyIndex = 32;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreVariantDouble i;
+ i.value = 33.7;
+ i.propertyIndex = 19;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::Done i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreTrString i;
+ i.propertyIndex = 99;
+ i.context = 3;
+ i.text = 14;
+ i.comment = 14;
+ i.n = 2;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreTrIdString i;
+ i.propertyIndex = 78;
+ i.text = 7;
+ i.n = -1;
+ data->addInstruction(i);
+ }
+
+ QStringList expect;
+ expect
+ << "Index\tOperation\t\tData1\tData2\tData3\tComments"
+ << "-------------------------------------------------------------------------------"
+ << "0\t\tINIT\t\t\t0\t3\t-1\t-1"
+ << "1\t\tCREATECPP\t\t\t0\t\t\t\"Test\""
+ << "2\t\tSETID\t\t\t0\t\t\t\"testId\""
+ << "3\t\tSET_DEFAULT"
+ << "4\t\tCREATE_COMPONENT\t3"
+ << "5\t\tSTORE_META\t\t3"
+ << "6\t\tSTORE_FLOAT\t\t3\t11.3"
+ << "7\t\tSTORE_DOUBLE\t\t4\t14.8"
+ << "8\t\tSTORE_INTEGER\t\t5\t9"
+ << "9\t\tSTORE_BOOL\t\t6\ttrue"
+ << "10\t\tSTORE_STRING\t\t7\t1\t\t\"Test String\""
+ << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.nokia.com\") "
+ << "12\t\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
+ << "13\t\tSTORE_DATE\t\t10\t9"
+ << "14\t\tSTORE_TIME\t\t11"
+ << "15\t\tSTORE_DATETIME\t\t12"
+ << "16\t\tSTORE_POINT\t\t13\t3\t7"
+ << "17\t\tSTORE_POINTF\t\t13\t3\t7"
+ << "18\t\tSTORE_SIZE\t\t15\t8\t11"
+ << "19\t\tSTORE_SIZEF\t\t15\t8\t11"
+ << "20\t\tSTORE_RECT\t\t17\t7\t9\t11\t13"
+ << "21\t\tSTORE_RECTF\t\t18\t11.3\t9.8\t3\t2.1"
+ << "22\t\tSTORE_VECTOR3D\t\t19\t9\t3\t92"
+ << "23\t\tSTORE_VARIANT\t\t20\t2\t\t\"color(1, 1, 1, 1)\""
+ << "24\t\tSTORE_OBJECT\t\t21"
+ << "25\t\tSTORE_VARIANT_OBJECT\t22"
+ << "26\t\tSTORE_INTERFACE\t\t23"
+ << "27\t\tSTORE_SIGNAL\t\t2\t3"
+ << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4"
+ << "29\t\tASSIGN_SIGNAL_OBJECT\t4"
+ << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9"
+ << "31\t\tSTORE_BINDING\t26\t3\t2"
+ << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4"
+ << "33\t\tSTORE_VALUE_SOURCE\t29\t4"
+ << "34\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
+ << "35\t\tBEGIN\t\t\t4"
+ << "36\t\tSTORE_OBJECT_QLIST"
+ << "37\t\tASSIGN_OBJECT_LIST"
+ << "38\t\tFETCH_ATTACHED\t\t23"
+ << "39\t\tFETCH_QLIST\t\t32"
+ << "40\t\tFETCH\t\t\t33"
+ << "41\t\tFETCH_VALUE\t\t34\t6\t7"
+ << "42\t\tPOP"
+ << "43\t\tPOP_QLIST"
+ << "44\t\tPOP_VALUE\t\t35\t8"
+ << "45\t\tDEFER\t\t\t7"
+ << "46\t\tDEFER\t\t\t7"
+ << "47\t\tSTORE_IMPORTED_SCRIPT\t2"
+ << "48\t\tSTORE_VARIANT_INTEGER\t\t32\t11"
+ << "49\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7"
+ << "50\t\tDONE"
+ << "51\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2"
+ << "52\t\tSTORE_TRID_STRING\t78\t7\t-1"
+ << "-------------------------------------------------------------------------------";
+
+ messages = QStringList();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+
+ data->dumpInstructions();
+ qInstallMsgHandler(old);
+
+ QCOMPARE(messages.count(), expect.count());
+ for (int ii = 0; ii < messages.count(); ++ii) {
+ QCOMPARE(messages.at(ii), expect.at(ii));
+ }
+
+ data->release();
+}
+
+void tst_qqmlinstruction::point()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storePoint::QPoint), sizeof(QPoint));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storePoint::QPoint), Q_ALIGNOF(QPoint));
+
+ QQmlInstruction i;
+ i.storePoint.point.xp = 8;
+ i.storePoint.point.yp = 11;
+
+ const QPoint &point = (const QPoint &)(i.storePoint.point);
+ QCOMPARE(point.x(), 8);
+ QCOMPARE(point.y(), 11);
+}
+
+void tst_qqmlinstruction::pointf()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storePointF::QPointF), sizeof(QPointF));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storePointF::QPointF), Q_ALIGNOF(QPointF));
+
+ QQmlInstruction i;
+ i.storePointF.point.xp = 8.7;
+ i.storePointF.point.yp = 11.3;
+
+ const QPointF &point = (const QPointF &)(i.storePointF.point);
+ QCOMPARE(point.x(), 8.7);
+ QCOMPARE(point.y(), 11.3);
+}
+
+void tst_qqmlinstruction::size()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeSize::QSize), sizeof(QSize));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeSize::QSize), Q_ALIGNOF(QSize));
+
+ QQmlInstruction i;
+ i.storeSize.size.wd = 8;
+ i.storeSize.size.ht = 11;
+
+ const QSize &size = (const QSize &)(i.storeSize.size);
+ QCOMPARE(size.width(), 8);
+ QCOMPARE(size.height(), 11);
+}
+
+void tst_qqmlinstruction::sizef()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeSizeF::QSizeF), sizeof(QSizeF));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeSizeF::QSizeF), Q_ALIGNOF(QSizeF));
+
+ QQmlInstruction i;
+ i.storeSizeF.size.wd = 8;
+ i.storeSizeF.size.ht = 11;
+
+ const QSizeF &size = (const QSizeF &)(i.storeSizeF.size);
+ QCOMPARE(size.width(), (qreal)8);
+ QCOMPARE(size.height(), (qreal)11);
+}
+
+void tst_qqmlinstruction::rect()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeRect::QRect), sizeof(QRect));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeRect::QRect), Q_ALIGNOF(QRect));
+
+ QQmlInstruction i;
+ i.storeRect.rect.x1 = 8;
+ i.storeRect.rect.y1 = 11;
+ i.storeRect.rect.x2 = 13;
+ i.storeRect.rect.y2 = 19;
+
+ const QRect &rect = (const QRect &)(i.storeRect.rect);
+ QCOMPARE(rect.left(), 8);
+ QCOMPARE(rect.top(), 11);
+ QCOMPARE(rect.right(), 13);
+ QCOMPARE(rect.bottom(), 19);
+}
+
+void tst_qqmlinstruction::rectf()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeRectF::QRectF), sizeof(QRectF));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeRectF::QRectF), Q_ALIGNOF(QRectF));
+
+ QQmlInstruction i;
+ i.storeRectF.rect.xp = 8;
+ i.storeRectF.rect.yp = 11;
+ i.storeRectF.rect.w = 13;
+ i.storeRectF.rect.h = 19;
+
+ const QRectF &rect = (const QRectF &)(i.storeRectF.rect);
+ QCOMPARE(rect.left(), (qreal)8);
+ QCOMPARE(rect.top(), (qreal)11);
+ QCOMPARE(rect.width(), (qreal)13);
+ QCOMPARE(rect.height(), (qreal)19);
+}
+
+void tst_qqmlinstruction::vector3d()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeVector3D::QVector3D), sizeof(QVector3D));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeVector3D::QVector3D), Q_ALIGNOF(QVector3D));
+
+ QQmlInstruction i;
+ i.storeVector3D.vector.xp = 8.2;
+ i.storeVector3D.vector.yp = 99.3;
+ i.storeVector3D.vector.zp = 12.0;
+
+ const QVector3D &vector = (const QVector3D &)(i.storeVector3D.vector);
+ QCOMPARE(vector.x(), (qreal)(float)8.2);
+ QCOMPARE(vector.y(), (qreal)(float)99.3);
+ QCOMPARE(vector.z(), (qreal)(float)12.0);
+}
+
+void tst_qqmlinstruction::vector4d()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeVector4D::QVector4D), sizeof(QVector4D));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeVector4D::QVector4D), Q_ALIGNOF(QVector4D));
+
+ QQmlInstruction i;
+ i.storeVector4D.vector.xp = 8.2;
+ i.storeVector4D.vector.yp = 99.3;
+ i.storeVector4D.vector.zp = 12.0;
+ i.storeVector4D.vector.wp = 121.1;
+
+ const QVector4D &vector = (const QVector4D &)(i.storeVector4D.vector);
+ QCOMPARE(vector.x(), (qreal)(float)8.2);
+ QCOMPARE(vector.y(), (qreal)(float)99.3);
+ QCOMPARE(vector.z(), (qreal)(float)12.0);
+ QCOMPARE(vector.w(), (qreal)(float)121.1);
+}
+
+void tst_qqmlinstruction::time()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeTime::QTime), sizeof(QTime));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeTime::QTime), Q_ALIGNOF(QTime));
+}
+
+QTEST_MAIN(tst_qqmlinstruction)
+
+#include "tst_qqmlinstruction.moc"
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml b/tests/auto/qml/qqmllanguage/data/Alias.qml
index 2cb7cbe2e0..2cb7cbe2e0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml
+++ b/tests/auto/qml/qqmllanguage/data/Alias.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml b/tests/auto/qml/qqmllanguage/data/Alias2.qml
index 134e1440b5..134e1440b5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml
+++ b/tests/auto/qml/qqmllanguage/data/Alias2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml b/tests/auto/qml/qqmllanguage/data/Alias3.qml
index 54b548e049..54b548e049 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml
+++ b/tests/auto/qml/qqmllanguage/data/Alias3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml b/tests/auto/qml/qqmllanguage/data/Alias4.qml
index e09eca2ff3..e09eca2ff3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml
+++ b/tests/auto/qml/qqmllanguage/data/Alias4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml b/tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml
index 9265ffb1df..9265ffb1df 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml
+++ b/tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml b/tests/auto/qml/qqmllanguage/data/ComponentComposite.qml
index 889450b565..889450b565 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml
+++ b/tests/auto/qml/qqmllanguage/data/ComponentComposite.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml b/tests/auto/qml/qqmllanguage/data/CompositeType.qml
index addc4265a9..addc4265a9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml
+++ b/tests/auto/qml/qqmllanguage/data/CompositeType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml b/tests/auto/qml/qqmllanguage/data/CompositeType2.qml
index 86210e9072..86210e9072 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml
+++ b/tests/auto/qml/qqmllanguage/data/CompositeType2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml b/tests/auto/qml/qqmllanguage/data/CompositeType3.qml
index f48a77598c..f48a77598c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml
+++ b/tests/auto/qml/qqmllanguage/data/CompositeType3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml b/tests/auto/qml/qqmllanguage/data/CompositeType4.qml
index a6a8168d8f..a6a8168d8f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml
+++ b/tests/auto/qml/qqmllanguage/data/CompositeType4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml b/tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml
index 1f8eac8a3b..1f8eac8a3b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml
+++ b/tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml b/tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml
index 4667adda14..4667adda14 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml
+++ b/tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml b/tests/auto/qml/qqmllanguage/data/HelperAlias.qml
index c2ab70ffd6..c2ab70ffd6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml
+++ b/tests/auto/qml/qqmllanguage/data/HelperAlias.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/I18n.qml b/tests/auto/qml/qqmllanguage/data/I18n.qml
index 558c836e52..558c836e52 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/I18n.qml
+++ b/tests/auto/qml/qqmllanguage/data/I18n.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml b/tests/auto/qml/qqmllanguage/data/I18nType30.qml
index 42dbc69044..42dbc69044 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml
+++ b/tests/auto/qml/qqmllanguage/data/I18nType30.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml
index 42513e463f..42513e463f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml
+++ b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml
index 4a45535a50..4a45535a50 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml
+++ b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml b/tests/auto/qml/qqmllanguage/data/LocalLast.qml
index 59df88216e..59df88216e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml
+++ b/tests/auto/qml/qqmllanguage/data/LocalLast.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml b/tests/auto/qml/qqmllanguage/data/MyComponent.qml
index 1a23277ff8..1a23277ff8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml
+++ b/tests/auto/qml/qqmllanguage/data/MyComponent.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml b/tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml
index e620e26490..e620e26490 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml
+++ b/tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml b/tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml
index 61f54c5eb8..61f54c5eb8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml
+++ b/tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml b/tests/auto/qml/qqmllanguage/data/NestedAlias.qml
index 7d49b0ac98..7d49b0ac98 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml
+++ b/tests/auto/qml/qqmllanguage/data/NestedAlias.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml b/tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml
index 887d7fae50..887d7fae50 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml
+++ b/tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml b/tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml
index 06a3212916..06a3212916 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml
+++ b/tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml b/tests/auto/qml/qqmllanguage/data/OnCompletedType.qml
index 947f14811f..947f14811f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml
+++ b/tests/auto/qml/qqmllanguage/data/OnCompletedType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml b/tests/auto/qml/qqmllanguage/data/OnDestructionType.qml
index 11fb9d9578..11fb9d9578 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml
+++ b/tests/auto/qml/qqmllanguage/data/OnDestructionType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml b/tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml
index 456ac762fc..456ac762fc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml
+++ b/tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml b/tests/auto/qml/qqmllanguage/data/alias.1.qml
index dbb3f06d32..dbb3f06d32 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml b/tests/auto/qml/qqmllanguage/data/alias.10.qml
index bf6352e82b..bf6352e82b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml b/tests/auto/qml/qqmllanguage/data/alias.11.qml
index fbd50d9dc9..fbd50d9dc9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml b/tests/auto/qml/qqmllanguage/data/alias.2.qml
index 5c922709fe..5c922709fe 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml b/tests/auto/qml/qqmllanguage/data/alias.3.qml
index 16a6d9d903..16a6d9d903 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml b/tests/auto/qml/qqmllanguage/data/alias.4.qml
index bd6a769367..bd6a769367 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml b/tests/auto/qml/qqmllanguage/data/alias.5.qml
index cee2a88cf7..cee2a88cf7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml b/tests/auto/qml/qqmllanguage/data/alias.6.qml
index 54d3c320e0..54d3c320e0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml b/tests/auto/qml/qqmllanguage/data/alias.7.qml
index 0dc54d6787..0dc54d6787 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml b/tests/auto/qml/qqmllanguage/data/alias.8.qml
index 3cb280ef47..3cb280ef47 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml b/tests/auto/qml/qqmllanguage/data/alias.9.qml
index 01cf9142b2..01cf9142b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml
index 60e66921d2..60e66921d2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml
+++ b/tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml
index 089130d14c..089130d14c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml
index 4e11b9174a..4e11b9174a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml
+++ b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml b/tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml
index 64acbd1576..64acbd1576 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml
+++ b/tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml b/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml
index 28a340128d..28a340128d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml b/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml
index 717cd84536..717cd84536 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml
index 399fcea04d..399fcea04d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml
index 89e66c6172..89e66c6172 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml
index f6f9a139dc..f6f9a139dc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml b/tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml
index 789cc66215..789cc66215 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml b/tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml
index 1f731c539c..1f731c539c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml b/tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml
index 20bdc559c1..20bdc559c1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml b/tests/auto/qml/qqmllanguage/data/assignSignal.qml
index 2a48df8fcf..2a48df8fcf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.errors.txt b/tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt
index 78aa4713fb..78aa4713fb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml b/tests/auto/qml/qqmllanguage/data/assignToNamespace.qml
index 54fef61ef0..54fef61ef0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignToNamespace.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml b/tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml
index 60ede525e4..60ede525e4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt
index eb1430a715..eb1430a715 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml
index 6fa1259f39..6fa1259f39 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml b/tests/auto/qml/qqmllanguage/data/attachedProperties.qml
index 3637ded26f..3637ded26f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
+++ b/tests/auto/qml/qqmllanguage/data/attachedProperties.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml b/tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml
index 5d00144eaf..5d00144eaf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml
+++ b/tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml b/tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml
index 640fb54f99..640fb54f99 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
+++ b/tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt b/tests/auto/qml/qqmllanguage/data/component.1.errors.txt
index 091aad61fa..091aad61fa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml b/tests/auto/qml/qqmllanguage/data/component.1.qml
index a22772bd89..a22772bd89 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt b/tests/auto/qml/qqmllanguage/data/component.2.errors.txt
index 76e7656a62..76e7656a62 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml b/tests/auto/qml/qqmllanguage/data/component.2.qml
index fbe315f771..fbe315f771 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt b/tests/auto/qml/qqmllanguage/data/component.3.errors.txt
index 450fc163bd..450fc163bd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml b/tests/auto/qml/qqmllanguage/data/component.3.qml
index bac23ef903..bac23ef903 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt b/tests/auto/qml/qqmllanguage/data/component.4.errors.txt
index 2ab18685c8..2ab18685c8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml b/tests/auto/qml/qqmllanguage/data/component.4.qml
index d07695477d..d07695477d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt b/tests/auto/qml/qqmllanguage/data/component.5.errors.txt
index e3c2df755f..e3c2df755f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml b/tests/auto/qml/qqmllanguage/data/component.5.qml
index 9867377bb9..9867377bb9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt b/tests/auto/qml/qqmllanguage/data/component.6.errors.txt
index 2b1c6ca606..2b1c6ca606 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml b/tests/auto/qml/qqmllanguage/data/component.6.qml
index 010949a35f..010949a35f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.7.errors.txt b/tests/auto/qml/qqmllanguage/data/component.7.errors.txt
index b144814a70..b144814a70 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.7.qml b/tests/auto/qml/qqmllanguage/data/component.7.qml
index b1a31195eb..b1a31195eb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.8.errors.txt b/tests/auto/qml/qqmllanguage/data/component.8.errors.txt
index 6f2d0d201d..6f2d0d201d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.8.qml b/tests/auto/qml/qqmllanguage/data/component.8.qml
index fb7a079d39..fb7a079d39 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.9.errors.txt b/tests/auto/qml/qqmllanguage/data/component.9.errors.txt
index 92f1456895..92f1456895 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.9.qml b/tests/auto/qml/qqmllanguage/data/component.9.qml
index 17824b4ede..17824b4ede 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml b/tests/auto/qml/qqmllanguage/data/componentCompositeType.qml
index 232b320fb0..232b320fb0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml
+++ b/tests/auto/qml/qqmllanguage/data/componentCompositeType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml b/tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml
index e3b32ca5d8..e3b32ca5d8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml b/tests/auto/qml/qqmllanguage/data/cppnamespace.qml
index e1daf3b78f..e1daf3b78f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml
+++ b/tests/auto/qml/qqmllanguage/data/cppnamespace.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml b/tests/auto/qml/qqmllanguage/data/crash2.qml
index 2b8d285348..2b8d285348 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml
+++ b/tests/auto/qml/qqmllanguage/data/crash2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml b/tests/auto/qml/qqmllanguage/data/customOnProperty.qml
index 57241ffc28..57241ffc28 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/customOnProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt
index 43a8bb28b3..43a8bb28b3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml
index c42173ddfb..c42173ddfb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml
+++ b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml b/tests/auto/qml/qqmllanguage/data/customParserTypes.qml
index 76a8a4773f..76a8a4773f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/customParserTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml b/tests/auto/qml/qqmllanguage/data/customVariantTypes.qml
index 0263ed20f2..0263ed20f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/customVariantTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml b/tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml
index 03f5c1ff7e..03f5c1ff7e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml
+++ b/tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt b/tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt
index 32055f6608..32055f6608 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml b/tests/auto/qml/qqmllanguage/data/defaultGrouped.qml
index 66a78eb67f..66a78eb67f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml
+++ b/tests/auto/qml/qqmllanguage/data/defaultGrouped.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml b/tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml
index 31d17fd55f..31d17fd55f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml
+++ b/tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt
index 3348494a8f..3348494a8f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml b/tests/auto/qml/qqmllanguage/data/destroyedSignal.qml
index b5b29148a2..b5b29148a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/destroyedSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt
index e9b449d8d9..e9b449d8d9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml
index 612bcfe0ea..612bcfe0ea 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml
+++ b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml b/tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml
index 905ee48e0b..905ee48e0b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml
+++ b/tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml b/tests/auto/qml/qqmllanguage/data/doubleSignal.qml
index fb07b9f659..fb07b9f659 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/doubleSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt b/tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt
index 66241cf1f2..66241cf1f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml b/tests/auto/qml/qqmllanguage/data/duplicateIDs.qml
index a993abdd37..a993abdd37 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml
+++ b/tests/auto/qml/qqmllanguage/data/duplicateIDs.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt
index 1f9f9169e9..1f9f9169e9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml
index 3dbd5b0b2e..3dbd5b0b2e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt
index 713d5f6272..713d5f6272 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml
index 5d4efeebb2..5d4efeebb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt
index 8226c16a1e..8226c16a1e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml
index f084947eaf..f084947eaf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt
index 028e25c37f..028e25c37f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml
index 3691529aa9..3691529aa9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt
index 015d55b03b..015d55b03b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml
index 64ba907415..64ba907415 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml b/tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml
index 2214bacda0..2214bacda0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml
index 6f822ba157..6f822ba157 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml
index 5d072b160a..5d072b160a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml b/tests/auto/qml/qqmllanguage/data/dynamicProperties.qml
index cd403b3d46..cd403b3d46 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicProperties.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml b/tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml
index b86e89b5e7..b86e89b5e7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml
index d80d94be09..d80d94be09 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt b/tests/auto/qml/qqmllanguage/data/empty.errors.txt
index 620db2bbba..620db2bbba 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/empty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/empty.qml b/tests/auto/qml/qqmllanguage/data/empty.qml
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/empty.qml
+++ b/tests/auto/qml/qqmllanguage/data/empty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt b/tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt
index 8b20434973..8b20434973 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml b/tests/auto/qml/qqmllanguage/data/emptySignal.qml
index c84fea3fe6..c84fea3fe6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/emptySignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt b/tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt
index d4e0cc0bc4..d4e0cc0bc4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml b/tests/auto/qml/qqmllanguage/data/enumTypes.qml
index ff083250f0..ff083250f0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/enumTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt b/tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt
index 364ca6747f..364ca6747f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml b/tests/auto/qml/qqmllanguage/data/failingComponentTest.qml
index 74a6acfc49..74a6acfc49 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/failingComponentTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt
index 30748234bc..30748234bc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml
index d971eee4d0..d971eee4d0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt b/tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt
index 49e06cbdf5..49e06cbdf5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml b/tests/auto/qml/qqmllanguage/data/finalOverride.qml
index a84393af94..a84393af94 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml
+++ b/tests/auto/qml/qqmllanguage/data/finalOverride.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml
index 558c836e52..558c836e52 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml
index 74918e2764..74918e2764 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml b/tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml
index c0b2f94857..c0b2f94857 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml b/tests/auto/qml/qqmllanguage/data/i18nScript.qml
index e77cb52074..e77cb52074 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nScript.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml b/tests/auto/qml/qqmllanguage/data/i18nStrings.qml
index 764c92639a..764c92639a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nStrings.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml b/tests/auto/qml/qqmllanguage/data/i18nType.qml
index d7954ef718..d7954ef718 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml b/tests/auto/qml/qqmllanguage/data/idProperty.qml
index bf048ea60a..bf048ea60a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/idProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt b/tests/auto/qml/qqmllanguage/data/importFile.errors.txt
index 3fdac0921e..3fdac0921e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importFile.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml b/tests/auto/qml/qqmllanguage/data/importFile.qml
index a0d8410ca3..a0d8410ca3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml
+++ b/tests/auto/qml/qqmllanguage/data/importFile.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml b/tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml
index 804e76b932..804e76b932 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml
+++ b/tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.1.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.1.qml b/tests/auto/qml/qqmllanguage/data/importJs.1.qml
index eaba98ecd2..eaba98ecd2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.10.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.10.qml b/tests/auto/qml/qqmllanguage/data/importJs.10.qml
index 578ca47ea5..578ca47ea5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.2.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.2.qml b/tests/auto/qml/qqmllanguage/data/importJs.2.qml
index dd3d65c5dd..dd3d65c5dd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.3.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.3.qml b/tests/auto/qml/qqmllanguage/data/importJs.3.qml
index f59d445a56..f59d445a56 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.4.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.4.qml b/tests/auto/qml/qqmllanguage/data/importJs.4.qml
index e7b74bac0a..e7b74bac0a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.5.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt
index 10dbc80297..10dbc80297 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.5.qml b/tests/auto/qml/qqmllanguage/data/importJs.5.qml
index a9ec20c72b..a9ec20c72b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.6.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt
index 41c99702a2..41c99702a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.6.qml b/tests/auto/qml/qqmllanguage/data/importJs.6.qml
index 6c4eb89551..6c4eb89551 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.7.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt
index 56bc4c548f..56bc4c548f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.7.qml b/tests/auto/qml/qqmllanguage/data/importJs.7.qml
index 5523a158bd..5523a158bd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.8.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.8.qml b/tests/auto/qml/qqmllanguage/data/importJs.8.qml
index 4ddedc31a8..4ddedc31a8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.9.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.9.qml b/tests/auto/qml/qqmllanguage/data/importJs.9.qml
index 351164ba41..351164ba41 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt
index 231998daf7..231998daf7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml
index 45ad40501b..45ad40501b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml
+++ b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.errors.txt b/tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt
index 413f096384..413f096384 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.qml b/tests/auto/qml/qqmllanguage/data/importNewerVersion.qml
index c4a0d386a4..c4a0d386a4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.qml
+++ b/tests/auto/qml/qqmllanguage/data/importNewerVersion.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.errors.txt b/tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt
index 1baf05cee0..1baf05cee0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml b/tests/auto/qml/qqmllanguage/data/importNonExist.qml
index 5cbee0264b..5cbee0264b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml
+++ b/tests/auto/qml/qqmllanguage/data/importNonExist.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt
index dfa7a369ff..dfa7a369ff 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml
index 18514b1efa..18514b1efa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml
+++ b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt
index c7d880e79e..c7d880e79e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml
index 23ed566e15..23ed566e15 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt
index 89e58ee764..89e58ee764 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml
index 97ec22280f..97ec22280f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt b/tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt
index ebc936d153..ebc936d153 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml b/tests/auto/qml/qqmllanguage/data/importscript.1.qml
index 2b2ab6ba0d..2b2ab6ba0d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/importscript.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt
index 3813680562..3813680562 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt
index abed1a73f5..abed1a73f5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml b/tests/auto/qml/qqmllanguage/data/incorrectCase.qml
index 15b6dc3a6e..15b6dc3a6e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml b/tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml
index addc4265a9..addc4265a9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml b/tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml
index 4390d22d45..4390d22d45 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml
+++ b/tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml b/tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml
index a6f277adb2..a6f277adb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml
+++ b/tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt
index 651009cf05..651009cf05 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml
index 4e561b48b2..4e561b48b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml b/tests/auto/qml/qqmllanguage/data/interfaceProperty.qml
index f85e3e4e5b..f85e3e4e5b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/interfaceProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml b/tests/auto/qml/qqmllanguage/data/interfaceQList.qml
index c87dfae785..c87dfae785 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml
+++ b/tests/auto/qml/qqmllanguage/data/interfaceQList.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt
index 9848e48579..9848e48579 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml
index 8aab61e49e..8aab61e49e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml
index 3ff7b16fd8..3ff7b16fd8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt
index 3e15628a13..3e15628a13 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml
index b85b2584eb..b85b2584eb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt
index fbf1b580e2..fbf1b580e2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml
index a363373734..a363373734 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt
index fbf1b580e2..fbf1b580e2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml
index cfdfca0590..cfdfca0590 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt
index 6f78e599d4..6f78e599d4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml
index 0c1d5d7ef1..0c1d5d7ef1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml
index edfdb24bcc..edfdb24bcc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml
index 2a09648d57..2a09648d57 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml
index 4faa52d250..4faa52d250 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml
index f1839127b0..f1839127b0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt
index 492bbb48fa..492bbb48fa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml
index 20864b9a41..20864b9a41 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt
index ff2409bd2d..ff2409bd2d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml
index 20906de606..20906de606 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt
index fee5050743..fee5050743 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml
index 95add15147..95add15147 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt
index 189a795837..189a795837 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml
index 7de503e766..7de503e766 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt
index 46d7be2ac3..46d7be2ac3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml
index 986ab855c5..986ab855c5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt
index 34de769e13..34de769e13 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml
index 050e619ff2..050e619ff2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt
index 05161c4d10..05161c4d10 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml
index 24b09a53d5..24b09a53d5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt
index a208bcfaa7..a208bcfaa7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml
index fb38ee9536..fb38ee9536 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt
index 05161c4d10..05161c4d10 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml
index 789e42f7ef..789e42f7ef 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml
index 9060a55d00..9060a55d00 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml
index 47b6cc37d8..47b6cc37d8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt
index ff2409bd2d..ff2409bd2d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml
index 146934f7ac..146934f7ac 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml
index 73724aa6e7..73724aa6e7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt
index 810fd31b41..810fd31b41 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml
index fa46b8242a..fa46b8242a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt
index 1fcb1b65f5..1fcb1b65f5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml
index 41aa3e2923..41aa3e2923 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt
index 810fd31b41..810fd31b41 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml
index 3e516738d6..3e516738d6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt
index f6d6f29fbf..f6d6f29fbf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml
index 0bbfc4f529..0bbfc4f529 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt
index 69c68716d9..69c68716d9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml
index 134fef9b0a..134fef9b0a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt
index 2c8a970da7..2c8a970da7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml
index 55cefe66b9..55cefe66b9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml
index 9ec33abe7b..9ec33abe7b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt
index 4a7e3830a8..4a7e3830a8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml
index 977539a357..977539a357 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt
index fa0da21c55..fa0da21c55 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml
index 56fca9b990..56fca9b990 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt
index 6d837a7222..6d837a7222 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml
index 982ab26051..982ab26051 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt
index 2c6b8bf0f3..2c6b8bf0f3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml b/tests/auto/qml/qqmllanguage/data/invalidID.2.qml
index 4fb3b298dd..4fb3b298dd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt
index bb811cfe9d..bb811cfe9d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml b/tests/auto/qml/qqmllanguage/data/invalidID.3.qml
index 668417286b..668417286b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt
index c721fe91bf..c721fe91bf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml b/tests/auto/qml/qqmllanguage/data/invalidID.4.qml
index 86010bf792..86010bf792 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt
index c167de382e..c167de382e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml b/tests/auto/qml/qqmllanguage/data/invalidID.5.qml
index 5b92a1a0eb..5b92a1a0eb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt
index 7251de118f..7251de118f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml b/tests/auto/qml/qqmllanguage/data/invalidID.6.qml
index 62187d9473..62187d9473 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt
index e4fd1db3f0..e4fd1db3f0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml b/tests/auto/qml/qqmllanguage/data/invalidID.7.qml
index d4bc539650..d4bc539650 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt
index b03ec6ccea..b03ec6ccea 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml b/tests/auto/qml/qqmllanguage/data/invalidID.8.qml
index 1ea615c32e..1ea615c32e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt
index c010e79492..c010e79492 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml b/tests/auto/qml/qqmllanguage/data/invalidID.9.qml
index 57474b7212..57474b7212 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.errors.txt
index c010e79492..c010e79492 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml b/tests/auto/qml/qqmllanguage/data/invalidID.qml
index 04db3eb67c..04db3eb67c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt
index 034e937366..034e937366 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml b/tests/auto/qml/qqmllanguage/data/invalidImportID.qml
index 37e7c5d4d0..37e7c5d4d0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidImportID.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidOn.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt
index b4210a11fc..b4210a11fc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidOn.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidOn.qml b/tests/auto/qml/qqmllanguage/data/invalidOn.qml
index d748bf4755..d748bf4755 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidOn.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidOn.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt
index e9e27c479b..e9e27c479b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml b/tests/auto/qml/qqmllanguage/data/invalidProperty.qml
index f9b322e35c..f9b322e35c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt
index eff7c0e6c4..eff7c0e6c4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml
index 2c63c08510..2c63c08510 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt
index 4bcc948e92..4bcc948e92 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml
index 427827ca89..427827ca89 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt
index fdce1abf06..fdce1abf06 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml
index 65e93ed55d..65e93ed55d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt
index 3b90f573a2..3b90f573a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml
index ba4c8ae1f7..ba4c8ae1f7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt
index 4bcc948e92..4bcc948e92 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml
index 658b72d9f2..658b72d9f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt
index fdce1abf06..fdce1abf06 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml
index 9c83238282..9c83238282 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt
index 208df2b84a..208df2b84a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml
index 2f7027081e..2f7027081e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt
index 3b90f573a2..3b90f573a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml
index ba4c8ae1f7..ba4c8ae1f7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js
index c7b3c8b6ca..c7b3c8b6ca 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js
index b90033eeb4..b90033eeb4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js
index b802477cb6..b802477cb6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir
index 083afb051c..083afb051c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js
index b90033eeb4..b90033eeb4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js
index b802477cb6..b802477cb6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir
index 5c3acebd39..5c3acebd39 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js
index efac613fc2..efac613fc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir
index 5c1b182028..5c1b182028 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
index 56daa9c09a..56daa9c09a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
index 59df88216e..59df88216e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml
index 26a5d6bba9..26a5d6bba9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml
index ed1b09e419..ed1b09e419 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir
index d15720a154..d15720a154 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml
index 56daa9c09a..56daa9c09a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml
index 59df88216e..59df88216e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir
index b301226099..b301226099 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt
index 35d2d3510e..35d2d3510e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.1.qml
index 1af190633d..1af190633d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt
index 8b40aa3ebb..8b40aa3ebb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.2.qml
index e3baadb46c..e3baadb46c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt
index c721fe91bf..c721fe91bf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.3.qml
index 00c4c6b543..00c4c6b543 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml b/tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml
index 74439c66d4..74439c66d4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml
+++ b/tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml b/tests/auto/qml/qqmllanguage/data/listProperties.qml
index dcfe37d6fc..dcfe37d6fc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml
+++ b/tests/auto/qml/qqmllanguage/data/listProperties.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.errors.txt b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt
index 07d05d3d21..07d05d3d21 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.qml b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml
index 717ca76f05..717ca76f05 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.qml
+++ b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt
index 29342dc46e..29342dc46e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml
index fbb37705a1..fbb37705a1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt
index 57b5764b08..57b5764b08 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml
index 8da7a2558f..8da7a2558f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt
index 45364a044f..45364a044f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml
index 195be2116a..195be2116a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt b/tests/auto/qml/qqmllanguage/data/method.1.errors.txt
index 98d0b9cefb..98d0b9cefb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/method.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml b/tests/auto/qml/qqmllanguage/data/method.1.qml
index a888b1aaf4..a888b1aaf4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/method.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt b/tests/auto/qml/qqmllanguage/data/missingObject.errors.txt
index b31b562de1..b31b562de1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/missingObject.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml b/tests/auto/qml/qqmllanguage/data/missingObject.qml
index 2f17045869..2f17045869 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml
+++ b/tests/auto/qml/qqmllanguage/data/missingObject.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt
index f562246288..f562246288 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml b/tests/auto/qml/qqmllanguage/data/missingSignal.qml
index 92aefef8c4..92aefef8c4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/missingSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt
index caf7e55ba2..caf7e55ba2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml
index 9a0fa6a26b..9a0fa6a26b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml b/tests/auto/qml/qqmllanguage/data/multiSet.1.qml
index 649c49ee3a..649c49ee3a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml b/tests/auto/qml/qqmllanguage/data/multiSet.10.qml
index bc21db98f8..bc21db98f8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.qml b/tests/auto/qml/qqmllanguage/data/multiSet.11.qml
index 7d03139056..7d03139056 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml b/tests/auto/qml/qqmllanguage/data/multiSet.2.qml
index abcd216744..abcd216744 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml b/tests/auto/qml/qqmllanguage/data/multiSet.3.qml
index 77eaba0b32..77eaba0b32 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml b/tests/auto/qml/qqmllanguage/data/multiSet.4.qml
index c16d04fea6..c16d04fea6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml b/tests/auto/qml/qqmllanguage/data/multiSet.5.qml
index 2980c5b28c..2980c5b28c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml b/tests/auto/qml/qqmllanguage/data/multiSet.6.qml
index 492c720edc..492c720edc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml b/tests/auto/qml/qqmllanguage/data/multiSet.7.qml
index 2a9c1d0de8..2a9c1d0de8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt
index 450fc163bd..450fc163bd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml b/tests/auto/qml/qqmllanguage/data/multiSet.8.qml
index 052437ea18..052437ea18 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml b/tests/auto/qml/qqmllanguage/data/multiSet.9.qml
index e2e954f778..e2e954f778 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml b/tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml
index 5e6c2a91c9..5e6c2a91c9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml
+++ b/tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt b/tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt
index 53e752b641..53e752b641 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml b/tests/auto/qml/qqmllanguage/data/nestedErrors.qml
index cc1df4d181..cc1df4d181 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml
+++ b/tests/auto/qml/qqmllanguage/data/nestedErrors.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt b/tests/auto/qml/qqmllanguage/data/noCreation.errors.txt
index 23cd3f3504..23cd3f3504 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/noCreation.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml b/tests/auto/qml/qqmllanguage/data/noCreation.qml
index 28852f1a0c..28852f1a0c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml
+++ b/tests/auto/qml/qqmllanguage/data/noCreation.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt
index cdfa4b2ef2..cdfa4b2ef2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml
index bd59bc80f9..bd59bc80f9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt
index 6bfce9a2c9..6bfce9a2c9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml
index df7406ce98..df7406ce98 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml
index 06ccd37905..06ccd37905 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml
index 5b08608862..5b08608862 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml
index 65791919ba..65791919ba 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt
index c07f2b99a2..c07f2b99a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml
index 37af05731e..37af05731e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt
index 89925b74c2..89925b74c2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml
index 5cd55d0856..5cd55d0856 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt b/tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt
index af95a53cc7..af95a53cc7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml b/tests/auto/qml/qqmllanguage/data/notAvailable.qml
index 7c3c7ee08d..7c3c7ee08d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml
+++ b/tests/auto/qml/qqmllanguage/data/notAvailable.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt
index 07a40949cd..07a40949cd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml b/tests/auto/qml/qqmllanguage/data/nullDotProperty.qml
index 4e36779b5c..4e36779b5c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/nullDotProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
index db7d9c0f60..db7d9c0f60 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml
index 99247735dd..99247735dd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml b/tests/auto/qml/qqmllanguage/data/onCompleted.qml
index 89e6777f8a..89e6777f8a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml
+++ b/tests/auto/qml/qqmllanguage/data/onCompleted.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml b/tests/auto/qml/qqmllanguage/data/onDestruction.qml
index 7d6da260b4..7d6da260b4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml
+++ b/tests/auto/qml/qqmllanguage/data/onDestruction.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt b/tests/auto/qml/qqmllanguage/data/property.1.errors.txt
index 3ae6c4601b..3ae6c4601b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml b/tests/auto/qml/qqmllanguage/data/property.1.qml
index 6b43e6cc89..6b43e6cc89 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt b/tests/auto/qml/qqmllanguage/data/property.2.errors.txt
index a18e21a01c..a18e21a01c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml b/tests/auto/qml/qqmllanguage/data/property.2.qml
index e6aa00e730..e6aa00e730 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt b/tests/auto/qml/qqmllanguage/data/property.3.errors.txt
index 5e09a25b57..5e09a25b57 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml b/tests/auto/qml/qqmllanguage/data/property.3.qml
index 978c1aa80b..978c1aa80b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt b/tests/auto/qml/qqmllanguage/data/property.4.errors.txt
index b447186849..b447186849 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml b/tests/auto/qml/qqmllanguage/data/property.4.qml
index bb94e84244..bb94e84244 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt b/tests/auto/qml/qqmllanguage/data/property.6.errors.txt
index 985c083cc3..985c083cc3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml b/tests/auto/qml/qqmllanguage/data/property.6.qml
index 88f493f9a9..88f493f9a9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt b/tests/auto/qml/qqmllanguage/data/property.7.errors.txt
index 985c083cc3..985c083cc3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml b/tests/auto/qml/qqmllanguage/data/property.7.qml
index 05eb319947..05eb319947 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml b/tests/auto/qml/qqmllanguage/data/propertyInit.1.qml
index 7d6fea24db..7d6fea24db 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/propertyInit.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml b/tests/auto/qml/qqmllanguage/data/propertyInit.2.qml
index fa690ba6bc..fa690ba6bc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/propertyInit.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml b/tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml
index e48526abec..e48526abec 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml b/tests/auto/qml/qqmllanguage/data/propertyValueSource.qml
index 22aa68250e..22aa68250e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml
+++ b/tests/auto/qml/qqmllanguage/data/propertyValueSource.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
index 55c507f67e..55c507f67e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
index db8a3da2b2..db8a3da2b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/LocalInternal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml
index 4ce04c46d2..4ce04c46d2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/LocalInternal.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/Test.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml
index f789a905f2..f789a905f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/Test.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml
index 11443ca6d5..11443ca6d5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestLocal.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestNamed.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml
index 672cb8f201..672cb8f201 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestNamed.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestSubDir.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml
index 0dfede4093..0dfede4093 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestSubDir.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/UndeclaredLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml
index 4ce04c46d2..4ce04c46d2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/UndeclaredLocal.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/WrongTestLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml
index 8dcb7be231..8dcb7be231 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/WrongTestLocal.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/noqmldir/Test.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml
index f789a905f2..f789a905f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/noqmldir/Test.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/pics/blue.png b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png
index 46f815f1ed..46f815f1ed 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/pics/blue.png
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/qmldir b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir
index 60150f837c..60150f837c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/SubTest.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml
index 1480ae8683..1480ae8683 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/SubTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/qmldir b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir
index a54f7dfa61..a54f7dfa61 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt
index b8c34042be..b8c34042be 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml b/tests/auto/qml/qqmllanguage/data/readOnly.1.qml
index 60757bd005..60757bd005 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt
index d857a0440e..d857a0440e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml b/tests/auto/qml/qqmllanguage/data/readOnly.2.qml
index 8f1633cc11..8f1633cc11 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt
index c7e9e1bb2f..c7e9e1bb2f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml b/tests/auto/qml/qqmllanguage/data/readOnly.3.qml
index e3c56b701a..e3c56b701a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt
index d857a0440e..d857a0440e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.qml b/tests/auto/qml/qqmllanguage/data/readOnly.4.qml
index 5338ac77bc..5338ac77bc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt
index e71ae4447c..e71ae4447c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml b/tests/auto/qml/qqmllanguage/data/readOnly.5.qml
index d80b27a1e3..d80b27a1e3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readonly.qml b/tests/auto/qml/qqmllanguage/data/readonly.qml
index 493a9ad502..493a9ad502 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readonly.qml
+++ b/tests/auto/qml/qqmllanguage/data/readonly.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/registrationOrder.qml b/tests/auto/qml/qqmllanguage/data/registrationOrder.qml
index 14217ad521..14217ad521 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/registrationOrder.qml
+++ b/tests/auto/qml/qqmllanguage/data/registrationOrder.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml b/tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml
index 5f237d39a2..5f237d39a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml
+++ b/tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml b/tests/auto/qml/qqmllanguage/data/revisions11.qml
index 823439acdd..823439acdd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml
+++ b/tests/auto/qml/qqmllanguage/data/revisions11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml b/tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml
index 78ab51a4b7..78ab51a4b7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml
+++ b/tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml b/tests/auto/qml/qqmllanguage/data/revisionssub11.qml
index d00758387e..d00758387e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml
+++ b/tests/auto/qml/qqmllanguage/data/revisionssub11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml b/tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml
index 8d72cd3844..8d72cd3844 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml
+++ b/tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.errors.txt b/tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt
index 14463e0941..14463e0941 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.qml b/tests/auto/qml/qqmllanguage/data/scriptString.1.qml
index f07d2231fe..f07d2231fe 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.errors.txt b/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt
index f8a776f9a0..f8a776f9a0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.qml b/tests/auto/qml/qqmllanguage/data/scriptString.2.qml
index dc825c7511..dc825c7511 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml b/tests/auto/qml/qqmllanguage/data/scriptString.qml
index 40a3bbeede..40a3bbeede 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml b/tests/auto/qml/qqmllanguage/data/scriptString2.qml
index c42da2b9e1..c42da2b9e1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml b/tests/auto/qml/qqmllanguage/data/scriptString3.qml
index 0cd82ff58f..0cd82ff58f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml b/tests/auto/qml/qqmllanguage/data/scriptString4.qml
index 3e2f9a49f1..3e2f9a49f1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.1.errors.txt
index 78d996016a..78d996016a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml b/tests/auto/qml/qqmllanguage/data/signal.1.qml
index 1c27baa4e8..1c27baa4e8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.2.errors.txt
index 0d4c33d750..0d4c33d750 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml b/tests/auto/qml/qqmllanguage/data/signal.2.qml
index 2b00ab80bb..2b00ab80bb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.3.errors.txt
index bf043ac85a..bf043ac85a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml b/tests/auto/qml/qqmllanguage/data/signal.3.qml
index 1bfcfff7b5..1bfcfff7b5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.4.errors.txt
index 513ff60ae6..513ff60ae6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml b/tests/auto/qml/qqmllanguage/data/signal.4.qml
index 653c14e6aa..653c14e6aa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.5.errors.txt
index cf772e881e..cf772e881e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml b/tests/auto/qml/qqmllanguage/data/signal.5.qml
index 63921cb2ca..63921cb2ca 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml b/tests/auto/qml/qqmllanguage/data/simpleBindings.qml
index 2fcd1a5a4f..2fcd1a5a4f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml
+++ b/tests/auto/qml/qqmllanguage/data/simpleBindings.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml b/tests/auto/qml/qqmllanguage/data/simpleContainer.qml
index c3a795f536..c3a795f536 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml
+++ b/tests/auto/qml/qqmllanguage/data/simpleContainer.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml b/tests/auto/qml/qqmllanguage/data/simpleObject.qml
index 30c78237de..30c78237de 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml
+++ b/tests/auto/qml/qqmllanguage/data/simpleObject.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt
index beae562ff0..beae562ff0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml b/tests/auto/qml/qqmllanguage/data/singularProperty.2.qml
index e2760cb418..e2760cb418 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/singularProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt
index beae562ff0..beae562ff0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml b/tests/auto/qml/qqmllanguage/data/singularProperty.qml
index ccbc6f0849..ccbc6f0849 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/singularProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml b/tests/auto/qml/qqmllanguage/data/subdir/Test.qml
index f789a905f2..f789a905f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml
+++ b/tests/auto/qml/qqmllanguage/data/subdir/Test.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml b/tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml
index f789a905f2..f789a905f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/test.js b/tests/auto/qml/qqmllanguage/data/test.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/test.js
+++ b/tests/auto/qml/qqmllanguage/data/test.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/test2.js b/tests/auto/qml/qqmllanguage/data/test2.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/test2.js
+++ b/tests/auto/qml/qqmllanguage/data/test2.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt b/tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt
index 10e5fb2d96..10e5fb2d96 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml b/tests/auto/qml/qqmllanguage/data/unregisteredObject.qml
index 4969f62ad5..4969f62ad5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml
+++ b/tests/auto/qml/qqmllanguage/data/unregisteredObject.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt
index 3cd626de86..3cd626de86 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml
index 9f19680368..9f19680368 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml b/tests/auto/qml/qqmllanguage/data/valueTypes.qml
index bf325a74ee..bf325a74ee 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/valueTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml b/tests/auto/qml/qqmllanguage/data/variantNotify.qml
index 169b245450..169b245450 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml
+++ b/tests/auto/qml/qqmllanguage/data/variantNotify.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml b/tests/auto/qml/qqmllanguage/data/versionedbase.qml
index 3e8bca0368..3e8bca0368 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml
+++ b/tests/auto/qml/qqmllanguage/data/versionedbase.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt
index ba7a0766b2..ba7a0766b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml b/tests/auto/qml/qqmllanguage/data/wrongType.1.qml
index 289d37f050..289d37f050 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt
index ae75b5289d..ae75b5289d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml b/tests/auto/qml/qqmllanguage/data/wrongType.10.qml
index 2cf0e50277..2cf0e50277 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt
index 23a4cda4c2..23a4cda4c2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml b/tests/auto/qml/qqmllanguage/data/wrongType.11.qml
index ae77ba1fe8..ae77ba1fe8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt
index 3092100280..3092100280 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml b/tests/auto/qml/qqmllanguage/data/wrongType.12.qml
index b7a366f567..b7a366f567 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.12.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt
index ba7a0766b2..ba7a0766b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml b/tests/auto/qml/qqmllanguage/data/wrongType.13.qml
index 477aff1dbe..477aff1dbe 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.13.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt
index d621fdd6cd..d621fdd6cd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml b/tests/auto/qml/qqmllanguage/data/wrongType.14.qml
index 672d693c72..672d693c72 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.14.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt
index 44768e30cb..44768e30cb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml b/tests/auto/qml/qqmllanguage/data/wrongType.15.qml
index 633a5ba2ba..633a5ba2ba 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.15.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt
index 77cf210918..77cf210918 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml b/tests/auto/qml/qqmllanguage/data/wrongType.16.qml
index 973fdada24..973fdada24 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.16.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt
index ef34d0ea95..ef34d0ea95 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.qml b/tests/auto/qml/qqmllanguage/data/wrongType.17.qml
index f678fb3136..f678fb3136 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.17.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt
index 9ff9f250c0..9ff9f250c0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml b/tests/auto/qml/qqmllanguage/data/wrongType.2.qml
index 34b74f7e01..34b74f7e01 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt
index 6d971c6499..6d971c6499 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml b/tests/auto/qml/qqmllanguage/data/wrongType.3.qml
index 384181a17f..384181a17f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt
index ef34d0ea95..ef34d0ea95 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml b/tests/auto/qml/qqmllanguage/data/wrongType.4.qml
index 0787bf5fda..0787bf5fda 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt
index cab10bddb8..cab10bddb8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml b/tests/auto/qml/qqmllanguage/data/wrongType.5.qml
index c50ae9a26d..c50ae9a26d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt
index d2b8c54c5b..d2b8c54c5b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml b/tests/auto/qml/qqmllanguage/data/wrongType.6.qml
index da10b7895f..da10b7895f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt
index 614346bd2b..614346bd2b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml b/tests/auto/qml/qqmllanguage/data/wrongType.7.qml
index ddc3835199..ddc3835199 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt
index 1773c00825..1773c00825 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml b/tests/auto/qml/qqmllanguage/data/wrongType.8.qml
index a5f6756399..a5f6756399 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt
index 8630975c57..8630975c57 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml b/tests/auto/qml/qqmllanguage/data/wrongType.9.qml
index a3db732692..a3db732692 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.9.qml
diff --git a/tests/auto/qml/qqmllanguage/qqmllanguage.pro b/tests/auto/qml/qqmllanguage/qqmllanguage.pro
new file mode 100644
index 0000000000..41b1d11764
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/qqmllanguage.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qqmllanguage
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmllanguage.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+INCLUDEPATH += ../../shared/
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += ../../shared/testhttpserver.cpp
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private network testlib
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 3c7a7c2058..3c7a7c2058 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
new file mode 100644
index 0000000000..e7294f090c
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -0,0 +1,824 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qdatetime.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqmlpropertyvaluesource.h>
+#include <QtQml/qqmlscriptstring.h>
+#include <QtQml/qqmlproperty.h>
+
+#include <private/qqmlcustomparser_p.h>
+
+QVariant myCustomVariantTypeConverter(const QString &data);
+
+class MyInterface
+{
+public:
+ MyInterface() : id(913) {}
+ int id;
+};
+
+QT_BEGIN_NAMESPACE
+#define MyInterface_iid "org.qt-project.Qt.Test.MyInterface"
+Q_DECLARE_INTERFACE(MyInterface, MyInterface_iid);
+QT_END_NAMESPACE
+QML_DECLARE_INTERFACE(MyInterface);
+
+struct MyCustomVariantType
+{
+ MyCustomVariantType() : a(0) {}
+ int a;
+};
+Q_DECLARE_METATYPE(MyCustomVariantType);
+
+class MyAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2)
+public:
+ MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { if (m_value != v) { m_value = v; emit valueChanged(); } }
+
+ int value2() const { return m_value2; }
+ void setValue2(int v) { m_value2 = v; }
+
+signals:
+ void valueChanged();
+
+private:
+ int m_value;
+ int m_value2;
+};
+
+class MyQmlObject : public QObject, public MyInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue FINAL)
+ Q_PROPERTY(QString readOnlyString READ readOnlyString)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
+ Q_PROPERTY(QRect rect READ rect WRITE setRect)
+ Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML
+ Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
+ Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal)
+ Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType)
+ Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+ Q_PROPERTY(int nonScriptable READ nonScriptable WRITE setNonScriptable SCRIPTABLE false)
+
+ Q_INTERFACES(MyInterface)
+public:
+ MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ QString readOnlyString() const { return QLatin1String(""); }
+
+ bool enabled() const { return false; }
+ void setEnabled(bool) {}
+
+ QRect rect() const { return QRect(); }
+ void setRect(const QRect&) {}
+
+ QMatrix matrix() const { return QMatrix(); }
+ void setMatrix(const QMatrix&) {}
+
+ MyInterface *interface() const { return m_interface; }
+ void setInterface(MyInterface *iface) { m_interface = iface; }
+
+ static MyAttachedObject *qmlAttachedProperties(QObject *other) {
+ return new MyAttachedObject(other);
+ }
+ Q_CLASSINFO("DefaultMethod", "basicSlot()")
+
+ int onLiteralSignal() const { return m_value; }
+ void setOnLiteralSignal(int v) { m_value = v; }
+
+ MyQmlObject *qmlobject() const { return m_qmlobject; }
+ void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
+
+ MyCustomVariantType customType() const { return m_custom; }
+ void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
+
+ int propertyWithNotify() const { return m_propertyWithNotify; }
+ void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
+
+ int nonScriptable() const { return 0; }
+ void setNonScriptable(int) {}
+public slots:
+ void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
+ void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
+
+signals:
+ void basicSignal();
+ void basicParameterizedSignal(int parameter);
+ void oddlyNamedNotifySignal();
+
+private:
+ friend class tst_qqmllanguage;
+ int m_value;
+ MyInterface *m_interface;
+ MyQmlObject *m_qmlobject;
+ MyCustomVariantType m_custom;
+ int m_propertyWithNotify;
+};
+QML_DECLARE_TYPE(MyQmlObject)
+QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+
+class MyGroupedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
+ Q_PROPERTY(int value READ value WRITE setValue)
+public:
+ QQmlScriptString script() const { return m_script; }
+ void setScript(const QQmlScriptString &s) { m_script = s; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+private:
+ int m_value;
+ QQmlScriptString m_script;
+};
+
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_FLAGS(MyFlags)
+
+ Q_PROPERTY(QString id READ id WRITE setId)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
+ Q_PROPERTY(QQmlComponent *componentProperty READ componentProperty WRITE setComponentProperty)
+ Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
+ Q_PROPERTY(MyEnum readOnlyEnumProperty READ readOnlyEnumProperty)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
+ Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
+ Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
+ Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
+ Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
+ Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
+ Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
+ Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
+ Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
+ Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
+ Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
+ Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
+ Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
+ Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
+ Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
+ Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
+ Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
+ Q_PROPERTY(QVector4D vector4Property READ vector4Property WRITE setVector4Property)
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
+
+ Q_PROPERTY(QQmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
+ Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT)
+ Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT)
+
+public:
+ MyTypeObject()
+ : objectPropertyValue(0), componentPropertyValue(0) {}
+
+ QString idValue;
+ QString id() const {
+ return idValue;
+ }
+ void setId(const QString &v) {
+ idValue = v;
+ }
+
+ QObject *objectPropertyValue;
+ QObject *objectProperty() const {
+ return objectPropertyValue;
+ }
+ void setObjectProperty(QObject *v) {
+ objectPropertyValue = v;
+ }
+
+ QQmlComponent *componentPropertyValue;
+ QQmlComponent *componentProperty() const {
+ return componentPropertyValue;
+ }
+ void setComponentProperty(QQmlComponent *v) {
+ componentPropertyValue = v;
+ }
+
+ enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
+ Q_DECLARE_FLAGS(MyFlags, MyFlag)
+ MyFlags flagPropertyValue;
+ MyFlags flagProperty() const {
+ return flagPropertyValue;
+ }
+ void setFlagProperty(MyFlags v) {
+ flagPropertyValue = v;
+ }
+
+ enum MyEnum { EnumVal1, EnumVal2 };
+ MyEnum enumPropertyValue;
+ MyEnum enumProperty() const {
+ return enumPropertyValue;
+ }
+ void setEnumProperty(MyEnum v) {
+ enumPropertyValue = v;
+ }
+
+ MyEnum readOnlyEnumProperty() const {
+ return EnumVal1;
+ }
+
+ QString stringPropertyValue;
+ QString stringProperty() const {
+ return stringPropertyValue;
+ }
+ void setStringProperty(const QString &v) {
+ stringPropertyValue = v;
+ }
+
+ uint uintPropertyValue;
+ uint uintProperty() const {
+ return uintPropertyValue;
+ }
+ void setUintProperty(const uint &v) {
+ uintPropertyValue = v;
+ }
+
+ int intPropertyValue;
+ int intProperty() const {
+ return intPropertyValue;
+ }
+ void setIntProperty(const int &v) {
+ intPropertyValue = v;
+ }
+
+ qreal realPropertyValue;
+ qreal realProperty() const {
+ return realPropertyValue;
+ }
+ void setRealProperty(const qreal &v) {
+ realPropertyValue = v;
+ }
+
+ double doublePropertyValue;
+ double doubleProperty() const {
+ return doublePropertyValue;
+ }
+ void setDoubleProperty(const double &v) {
+ doublePropertyValue = v;
+ }
+
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
+ QColor colorPropertyValue;
+ QColor colorProperty() const {
+ return colorPropertyValue;
+ }
+ void setColorProperty(const QColor &v) {
+ colorPropertyValue = v;
+ }
+
+ QDate datePropertyValue;
+ QDate dateProperty() const {
+ return datePropertyValue;
+ }
+ void setDateProperty(const QDate &v) {
+ datePropertyValue = v;
+ }
+
+ QTime timePropertyValue;
+ QTime timeProperty() const {
+ return timePropertyValue;
+ }
+ void setTimeProperty(const QTime &v) {
+ timePropertyValue = v;
+ }
+
+ QDateTime dateTimePropertyValue;
+ QDateTime dateTimeProperty() const {
+ return dateTimePropertyValue;
+ }
+ void setDateTimeProperty(const QDateTime &v) {
+ dateTimePropertyValue = v;
+ }
+
+ QPoint pointPropertyValue;
+ QPoint pointProperty() const {
+ return pointPropertyValue;
+ }
+ void setPointProperty(const QPoint &v) {
+ pointPropertyValue = v;
+ }
+
+ QPointF pointFPropertyValue;
+ QPointF pointFProperty() const {
+ return pointFPropertyValue;
+ }
+ void setPointFProperty(const QPointF &v) {
+ pointFPropertyValue = v;
+ }
+
+ QSize sizePropertyValue;
+ QSize sizeProperty() const {
+ return sizePropertyValue;
+ }
+ void setSizeProperty(const QSize &v) {
+ sizePropertyValue = v;
+ }
+
+ QSizeF sizeFPropertyValue;
+ QSizeF sizeFProperty() const {
+ return sizeFPropertyValue;
+ }
+ void setSizeFProperty(const QSizeF &v) {
+ sizeFPropertyValue = v;
+ }
+
+ QRect rectPropertyValue;
+ QRect rectProperty() const {
+ return rectPropertyValue;
+ }
+ void setRectProperty(const QRect &v) {
+ rectPropertyValue = v;
+ emit rectPropertyChanged();
+ }
+
+ QRect rectPropertyValue2;
+ QRect rectProperty2() const {
+ return rectPropertyValue2;
+ }
+ void setRectProperty2(const QRect &v) {
+ rectPropertyValue2 = v;
+ }
+
+ QRectF rectFPropertyValue;
+ QRectF rectFProperty() const {
+ return rectFPropertyValue;
+ }
+ void setRectFProperty(const QRectF &v) {
+ rectFPropertyValue = v;
+ }
+
+ bool boolPropertyValue;
+ bool boolProperty() const {
+ return boolPropertyValue;
+ }
+ void setBoolProperty(const bool &v) {
+ boolPropertyValue = v;
+ }
+
+ QVariant variantPropertyValue;
+ QVariant variantProperty() const {
+ return variantPropertyValue;
+ }
+ void setVariantProperty(const QVariant &v) {
+ variantPropertyValue = v;
+ }
+
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
+ QVector4D vector4PropertyValue;
+ QVector4D vector4Property() const {
+ return vector4PropertyValue;
+ }
+ void setVector4Property(const QVector4D &v) {
+ vector4PropertyValue = v;
+ }
+
+ QUrl urlPropertyValue;
+ QUrl urlProperty() const {
+ return urlPropertyValue;
+ }
+ void setUrlProperty(const QUrl &v) {
+ urlPropertyValue = v;
+ }
+
+ QQmlScriptString scriptPropertyValue;
+ QQmlScriptString scriptProperty() const {
+ return scriptPropertyValue;
+ }
+ void setScriptProperty(const QQmlScriptString &v) {
+ scriptPropertyValue = v;
+ }
+
+ MyGroupedObject groupedValue;
+ MyGroupedObject *grouped() { return &groupedValue; }
+
+ MyGroupedObject *nullGrouped() { return 0; }
+
+ void doAction() { emit action(); }
+signals:
+ void action();
+ void rectPropertyChanged();
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
+
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<QObject> children READ children)
+ Q_PROPERTY(QQmlListProperty<MyContainer> containerChildren READ containerChildren)
+ Q_PROPERTY(QQmlListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
+ Q_CLASSINFO("DefaultProperty", "children")
+public:
+ MyContainer() {}
+
+ QQmlListProperty<QObject> children() { return QQmlListProperty<QObject>(this, m_children); }
+ QQmlListProperty<MyContainer> containerChildren() { return QQmlListProperty<MyContainer>(this, m_containerChildren); }
+ QList<QObject *> *getChildren() { return &m_children; }
+ QQmlListProperty<MyInterface> qlistInterfaces() { return QQmlListProperty<MyInterface>(this, m_interfaces); }
+ QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
+
+ QList<MyContainer*> m_containerChildren;
+ QList<QObject*> m_children;
+ QList<MyInterface *> m_interfaces;
+};
+
+
+class MyPropertyValueSource : public QObject, public QQmlPropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueSource)
+public:
+ MyPropertyValueSource()
+ : QQmlPropertyValueSource() {}
+
+ QQmlProperty prop;
+ virtual void setTarget(const QQmlProperty &p)
+ {
+ prop = p;
+ }
+};
+
+class UnavailableType : public QObject
+{
+ Q_OBJECT
+public:
+ UnavailableType() {}
+};
+
+class MyDotPropertyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(MyQmlObject *obj READ obj)
+ Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj)
+public:
+ MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {}
+ ~MyDotPropertyObject()
+ {
+ if (m_ownRWObj)
+ delete m_rwobj;
+ }
+
+ MyQmlObject *obj() { return 0; }
+
+ MyQmlObject *readWriteObj()
+ {
+ if (!m_rwobj) {
+ m_rwobj = new MyQmlObject;
+ m_ownRWObj = true;
+ }
+ return m_rwobj;
+ }
+
+ void setReadWriteObj(MyQmlObject *obj)
+ {
+ if (m_ownRWObj) {
+ delete m_rwobj;
+ m_ownRWObj = false;
+ }
+
+ m_rwobj = obj;
+ }
+
+private:
+ MyQmlObject *m_rwobj;
+ bool m_ownRWObj;
+};
+
+
+namespace MyNamespace {
+ class MyNamespacedType : public QObject
+ {
+ Q_OBJECT
+ };
+
+ class MySecondNamespacedType : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<MyNamespace::MyNamespacedType> list READ list)
+ public:
+ QQmlListProperty<MyNamespacedType> list() { return QQmlListProperty<MyNamespacedType>(this, m_list); }
+
+ private:
+ QList<MyNamespacedType *> m_list;
+ };
+}
+
+class MyCustomParserType : public QObject
+{
+ Q_OBJECT
+};
+
+class MyCustomParserTypeParser : public QQmlCustomParser
+{
+public:
+ QByteArray compile(const QList<QQmlCustomParserProperty> &) { return QByteArray(); }
+ void setCustomData(QObject *, const QByteArray &) {}
+};
+
+class MyParserStatus : public QObject, public QQmlParserStatus
+{
+ Q_INTERFACES(QQmlParserStatus)
+ Q_OBJECT
+public:
+ MyParserStatus() : m_cbc(0), m_ccc(0) {}
+
+ int classBeginCount() const { return m_cbc; }
+ int componentCompleteCount() const { return m_ccc; }
+
+ virtual void classBegin() { m_cbc++; }
+ virtual void componentComplete() { m_ccc++; }
+private:
+ int m_cbc;
+ int m_ccc;
+};
+
+class MyRevisionedBaseClassRegistered : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
+ Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
+
+public:
+ MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
+
+ qreal propA() const { return m_pa; }
+ void setPropA(qreal p) {
+ if (p != m_pa) {
+ m_pa = p;
+ emit propAChanged();
+ }
+ }
+ qreal propB() const { return m_pb; }
+ void setPropB(qreal p) {
+ if (p != m_pb) {
+ m_pb = p;
+ emit propBChanged();
+ }
+ }
+
+ Q_INVOKABLE void methodA() { }
+ Q_INVOKABLE Q_REVISION(1) void methodB() { }
+
+signals:
+ void propAChanged();
+ void propBChanged();
+
+ void signalA();
+ Q_REVISION(1) void signalB();
+
+protected:
+ qreal m_pa;
+ qreal m_pb;
+};
+
+class MyRevisionedIllegalOverload : public MyRevisionedBaseClassRegistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal propA READ propA WRITE setPropA REVISION 1);
+};
+
+class MyRevisionedLegalOverload : public MyRevisionedBaseClassRegistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal propB READ propB WRITE setPropB REVISION 1);
+};
+
+class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
+ Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
+
+public:
+ MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
+
+ qreal propC() const { return m_pc; }
+ void setPropC(qreal p) {
+ if (p != m_pc) {
+ m_pc = p;
+ emit propCChanged();
+ }
+ }
+ qreal propD() const { return m_pd; }
+ void setPropD(qreal p) {
+ if (p != m_pd) {
+ m_pd = p;
+ emit propDChanged();
+ }
+ }
+
+ Q_INVOKABLE void methodC() { }
+ Q_INVOKABLE Q_REVISION(1) void methodD() { }
+
+signals:
+ void propCChanged();
+ void propDChanged();
+
+ void signalC();
+ Q_REVISION(1) void signalD();
+
+protected:
+ qreal m_pc;
+ qreal m_pd;
+};
+
+class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
+ Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
+
+public:
+ MyRevisionedClass() : m_p1(1), m_p2(2) {}
+
+ qreal prop1() const { return m_p1; }
+ void setProp1(qreal p) {
+ if (p != m_p1) {
+ m_p1 = p;
+ emit prop1Changed();
+ }
+ }
+ qreal prop2() const { return m_p2; }
+ void setProp2(qreal p) {
+ if (p != m_p2) {
+ m_p2 = p;
+ emit prop2Changed();
+ }
+ }
+
+ Q_INVOKABLE void method1() { }
+ Q_INVOKABLE Q_REVISION(1) void method2() { }
+
+signals:
+ void prop1Changed();
+ void prop2Changed();
+
+ void signal1();
+ Q_REVISION(1) void signal2();
+
+protected:
+ qreal m_p1;
+ qreal m_p2;
+};
+
+class MyRevisionedSubclass : public MyRevisionedClass
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
+ Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
+
+public:
+ MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
+
+ qreal prop3() const { return m_p3; }
+ void setProp3(qreal p) {
+ if (p != m_p3) {
+ m_p3 = p;
+ emit prop3Changed();
+ }
+ }
+ qreal prop4() const { return m_p4; }
+ void setProp4(qreal p) {
+ if (p != m_p4) {
+ m_p4 = p;
+ emit prop4Changed();
+ }
+ }
+
+ Q_INVOKABLE void method3() { }
+ Q_INVOKABLE Q_REVISION(1) void method4() { }
+
+signals:
+ void prop3Changed();
+ void prop4Changed();
+
+ void signal3();
+ Q_REVISION(1) void signal4();
+
+protected:
+ qreal m_p3;
+ qreal m_p4;
+};
+
+class MySubclass : public MyRevisionedClass
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop5 READ prop5 WRITE setProp5 NOTIFY prop5Changed)
+
+public:
+ MySubclass() : m_p5(5) {}
+
+ qreal prop5() const { return m_p5; }
+ void setProp5(qreal p) {
+ if (p != m_p5) {
+ m_p5 = p;
+ emit prop5Changed();
+ }
+ }
+
+ Q_INVOKABLE void method5() { }
+
+signals:
+ void prop5Changed();
+
+protected:
+ qreal m_p5;
+};
+
+class MyVersion2Class : public QObject
+{
+ Q_OBJECT
+};
+
+QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
+QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
+QML_DECLARE_TYPE(MyRevisionedClass)
+QML_DECLARE_TYPE(MyRevisionedSubclass)
+QML_DECLARE_TYPE(MySubclass)
+
+
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
new file mode 100644
index 0000000000..266cd2a52d
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -0,0 +1,2290 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmlglobal_p.h>
+
+#include "testtypes.h"
+#include "testhttpserver.h"
+
+DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
+
+/*
+ Returns the path to some testdata file or directory.
+*/
+QString testdata(QString const& name = QString())
+{
+ static const QString dataDirectory = QDir::currentPath() + QLatin1String("/data");
+ QString result = dataDirectory;
+ if (!name.isEmpty()) {
+ result += QLatin1Char('/');
+ result += name;
+ }
+ return result;
+}
+
+/*
+This test case covers QML language issues. This covers everything that does not
+involve evaluating ECMAScript expressions and bindings.
+
+Evaluation of expressions and bindings is covered in qmlecmascript
+*/
+class tst_qqmllanguage : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmllanguage() {
+ QQmlMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
+ engine.addImportPath(testdata("lib"));
+ }
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void errors_data();
+ void errors();
+
+ void insertedSemicolon_data();
+ void insertedSemicolon();
+
+ void simpleObject();
+ void simpleContainer();
+ void interfaceProperty();
+ void interfaceQList();
+ void assignObjectToSignal();
+ void assignObjectToVariant();
+ void assignLiteralSignalProperty();
+ void assignQmlComponent();
+ void assignBasicTypes();
+ void assignTypeExtremes();
+ void assignCompositeToType();
+ void assignLiteralToVariant();
+ void assignLiteralToVar();
+ void customParserTypes();
+ void rootAsQmlComponent();
+ void inlineQmlComponents();
+ void idProperty();
+ void autoNotifyConnection();
+ void assignSignal();
+ void dynamicProperties();
+ void dynamicPropertiesNested();
+ void listProperties();
+ void dynamicObjectProperties();
+ void dynamicSignalsAndSlots();
+ void simpleBindings();
+ void autoComponentCreation();
+ void propertyValueSource();
+ void attachedProperties();
+ void dynamicObjects();
+ void customVariantTypes();
+ void valueTypes();
+ void cppnamespace();
+ void aliasProperties();
+ void aliasPropertiesAndSignals();
+ void aliasPropertyChangeSignals();
+ void componentCompositeType();
+ void i18n();
+ void i18n_data();
+ void onCompleted();
+ void onDestruction();
+ void scriptString();
+ void defaultPropertyListOrder();
+ void declaredPropertyValues();
+ void dontDoubleCallClassBegin();
+ void reservedWords_data();
+ void reservedWords();
+ void inlineAssignmentsOverrideBindings();
+ void nestedComponentRoots();
+ void registrationOrder();
+ void readonly();
+
+ void basicRemote_data();
+ void basicRemote();
+ void importsBuiltin_data();
+ void importsBuiltin();
+ void importsLocal_data();
+ void importsLocal();
+ void importsRemote_data();
+ void importsRemote();
+ void importsInstalled_data();
+ void importsInstalled();
+ void importsOrder_data();
+ void importsOrder();
+ void importIncorrectCase();
+ void importJs_data();
+ void importJs();
+
+ void qmlAttachedPropertiesObjectMethod();
+ void customOnProperty();
+ void variantNotify();
+
+ void revisions();
+ void revisionOverloads();
+
+ void propertyInit();
+ void remoteLoadCrash();
+
+ // regression tests for crashes
+ void crash1();
+ void crash2();
+
+private:
+ QQmlEngine engine;
+ void testType(const QString& qml, const QString& type, const QString& error);
+};
+
+#define DETERMINE_ERRORS(errorfile,expected,actual)\
+ QList<QByteArray> expected; \
+ QList<QByteArray> actual; \
+ do { \
+ QFile file(testdata(QLatin1String(errorfile))); \
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
+ QByteArray data = file.readAll(); \
+ file.close(); \
+ expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QQmlError> errors = component.errors(); \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QQmlError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ } while (false);
+
+#define VERIFY_ERRORS(errorfile) \
+ if (!errorfile) { \
+ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
+ qWarning() << "Unexpected Errors:" << component.errors(); \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ DETERMINE_ERRORS(errorfile,actual,expected);\
+ if (qgetenv("DEBUG") != "" && expected != actual) \
+ qWarning() << "Expected:" << expected << "Actual:" << actual; \
+ if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
+ QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
+ QVERIFY(file.open(QIODevice::WriteOnly)); \
+ for (int ii = 0; ii < actual.count(); ++ii) { \
+ file.write(actual.at(ii)); file.write("\n"); \
+ } \
+ file.close(); \
+ } else { \
+ QCOMPARE(expected, actual); \
+ } \
+ }
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(testdata(filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+
+void tst_qqmllanguage::cleanupTestCase()
+{
+ QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
+}
+
+void tst_qqmllanguage::insertedSemicolon_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("create");
+
+ QTest::newRow("insertedSemicolon.1") << "insertedSemicolon.1.qml" << "insertedSemicolon.1.errors.txt" << false;
+}
+
+void tst_qqmllanguage::insertedSemicolon()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, create);
+
+ QQmlComponent component(&engine, TEST_FILE(file));
+
+ if(create) {
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
+}
+
+void tst_qqmllanguage::errors_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("create");
+
+ QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.qml" << "nonexistantProperty.1.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.qml" << "nonexistantProperty.2.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.qml" << "nonexistantProperty.3.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false;
+
+ QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false;
+ QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false;
+ QTest::newRow("wrongType (bad rect)") << "wrongType.3.qml" << "wrongType.3.errors.txt" << false;
+
+ QTest::newRow("wrongType (invalid enum)") << "wrongType.4.qml" << "wrongType.4.errors.txt" << false;
+ QTest::newRow("wrongType (int for uint)") << "wrongType.5.qml" << "wrongType.5.errors.txt" << false;
+ QTest::newRow("wrongType (string for real)") << "wrongType.6.qml" << "wrongType.6.errors.txt" << false;
+ QTest::newRow("wrongType (int for color)") << "wrongType.7.qml" << "wrongType.7.errors.txt" << false;
+ QTest::newRow("wrongType (int for date)") << "wrongType.8.qml" << "wrongType.8.errors.txt" << false;
+ QTest::newRow("wrongType (int for time)") << "wrongType.9.qml" << "wrongType.9.errors.txt" << false;
+ QTest::newRow("wrongType (int for datetime)") << "wrongType.10.qml" << "wrongType.10.errors.txt" << false;
+ QTest::newRow("wrongType (string for point)") << "wrongType.11.qml" << "wrongType.11.errors.txt" << false;
+ QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false;
+ QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false;
+ QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false;
+ QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false;
+ QTest::newRow("wrongType (invalid object)") << "wrongType.16.qml" << "wrongType.16.errors.txt" << false;
+ QTest::newRow("wrongType (int for enum)") << "wrongType.17.qml" << "wrongType.17.errors.txt" << false;
+
+ QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false;
+ QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false;
+ QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false;
+ QTest::newRow("readOnly.4") << "readOnly.4.qml" << "readOnly.4.errors.txt" << false;
+ QTest::newRow("readOnly.5") << "readOnly.5.qml" << "readOnly.5.errors.txt" << false;
+
+ QTest::newRow("listAssignment.1") << "listAssignment.1.qml" << "listAssignment.1.errors.txt" << false;
+ QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false;
+ QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false;
+
+ QTest::newRow("invalidID.1") << "invalidID.qml" << "invalidID.errors.txt" << false;
+ QTest::newRow("invalidID.2") << "invalidID.2.qml" << "invalidID.2.errors.txt" << false;
+ QTest::newRow("invalidID.3") << "invalidID.3.qml" << "invalidID.3.errors.txt" << false;
+ QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false;
+ QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false;
+ QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false;
+ QTest::newRow("invalidID.7") << "invalidID.7.qml" << "invalidID.7.errors.txt" << false;
+ QTest::newRow("invalidID.8") << "invalidID.8.qml" << "invalidID.8.errors.txt" << false;
+ QTest::newRow("invalidID.9") << "invalidID.9.qml" << "invalidID.9.errors.txt" << false;
+
+ QTest::newRow("scriptString.1") << "scriptString.1.qml" << "scriptString.1.errors.txt" << false;
+ QTest::newRow("scriptString.2") << "scriptString.2.qml" << "scriptString.2.errors.txt" << false;
+
+ QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false;
+ QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true;
+ QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false;
+ QTest::newRow("duplicateIDs") << "duplicateIDs.qml" << "duplicateIDs.errors.txt" << false;
+ QTest::newRow("unregisteredObject") << "unregisteredObject.qml" << "unregisteredObject.errors.txt" << false;
+ QTest::newRow("empty") << "empty.qml" << "empty.errors.txt" << false;
+ QTest::newRow("missingObject") << "missingObject.qml" << "missingObject.errors.txt" << false;
+ QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false;
+ QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false;
+ QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
+ QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
+
+ QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true;
+ QTest::newRow("invalidGroupedProperty.8") << "invalidGroupedProperty.8.qml" << "invalidGroupedProperty.8.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.9") << "invalidGroupedProperty.9.qml" << "invalidGroupedProperty.9.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.10") << "invalidGroupedProperty.10.qml" << "invalidGroupedProperty.10.errors.txt" << false;
+
+ QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
+ QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
+ QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
+ QTest::newRow("importNonExist (installed)") << "importNonExist.qml" << "importNonExist.errors.txt" << false;
+ 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;
+ QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false;
+ QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false;
+ QTest::newRow("signal.5") << "signal.5.qml" << "signal.5.errors.txt" << false;
+
+ QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false;
+
+ QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false;
+ QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false;
+ QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false;
+ QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false;
+ QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false;
+ QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false;
+
+ QTest::newRow("importScript.1") << "importscript.1.qml" << "importscript.1.errors.txt" << false;
+
+ QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false;
+ QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false;
+ QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false;
+ QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false;
+ QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false;
+ QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false;
+ QTest::newRow("Component.7") << "component.7.qml" << "component.7.errors.txt" << false;
+ QTest::newRow("Component.8") << "component.8.qml" << "component.8.errors.txt" << false;
+ QTest::newRow("Component.9") << "component.9.qml" << "component.9.errors.txt" << false;
+
+ QTest::newRow("MultiSet.1") << "multiSet.1.qml" << "multiSet.1.errors.txt" << false;
+ QTest::newRow("MultiSet.2") << "multiSet.2.qml" << "multiSet.2.errors.txt" << false;
+ QTest::newRow("MultiSet.3") << "multiSet.3.qml" << "multiSet.3.errors.txt" << false;
+ QTest::newRow("MultiSet.4") << "multiSet.4.qml" << "multiSet.4.errors.txt" << false;
+ QTest::newRow("MultiSet.5") << "multiSet.5.qml" << "multiSet.5.errors.txt" << false;
+ QTest::newRow("MultiSet.6") << "multiSet.6.qml" << "multiSet.6.errors.txt" << false;
+ QTest::newRow("MultiSet.7") << "multiSet.7.qml" << "multiSet.7.errors.txt" << false;
+ QTest::newRow("MultiSet.8") << "multiSet.8.qml" << "multiSet.8.errors.txt" << false;
+ QTest::newRow("MultiSet.9") << "multiSet.9.qml" << "multiSet.9.errors.txt" << false;
+ QTest::newRow("MultiSet.10") << "multiSet.10.qml" << "multiSet.10.errors.txt" << false;
+ QTest::newRow("MultiSet.11") << "multiSet.11.qml" << "multiSet.11.errors.txt" << false;
+
+ QTest::newRow("dynamicMeta.1") << "dynamicMeta.1.qml" << "dynamicMeta.1.errors.txt" << false;
+ QTest::newRow("dynamicMeta.2") << "dynamicMeta.2.qml" << "dynamicMeta.2.errors.txt" << false;
+ QTest::newRow("dynamicMeta.3") << "dynamicMeta.3.qml" << "dynamicMeta.3.errors.txt" << false;
+ QTest::newRow("dynamicMeta.4") << "dynamicMeta.4.qml" << "dynamicMeta.4.errors.txt" << false;
+ QTest::newRow("dynamicMeta.5") << "dynamicMeta.5.qml" << "dynamicMeta.5.errors.txt" << false;
+
+ QTest::newRow("invalidAlias.1") << "invalidAlias.1.qml" << "invalidAlias.1.errors.txt" << false;
+ QTest::newRow("invalidAlias.2") << "invalidAlias.2.qml" << "invalidAlias.2.errors.txt" << false;
+ QTest::newRow("invalidAlias.3") << "invalidAlias.3.qml" << "invalidAlias.3.errors.txt" << false;
+ QTest::newRow("invalidAlias.4") << "invalidAlias.4.qml" << "invalidAlias.4.errors.txt" << false;
+ QTest::newRow("invalidAlias.5") << "invalidAlias.5.qml" << "invalidAlias.5.errors.txt" << false;
+ QTest::newRow("invalidAlias.6") << "invalidAlias.6.qml" << "invalidAlias.6.errors.txt" << false;
+ QTest::newRow("invalidAlias.7") << "invalidAlias.7.qml" << "invalidAlias.7.errors.txt" << false;
+ QTest::newRow("invalidAlias.8") << "invalidAlias.8.qml" << "invalidAlias.8.errors.txt" << false;
+ QTest::newRow("invalidAlias.9") << "invalidAlias.9.qml" << "invalidAlias.9.errors.txt" << false;
+ QTest::newRow("invalidAlias.10") << "invalidAlias.10.qml" << "invalidAlias.10.errors.txt" << false;
+
+ QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.12") << "invalidAttachedProperty.12.qml" << "invalidAttachedProperty.12.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.13") << "invalidAttachedProperty.13.qml" << "invalidAttachedProperty.13.errors.txt" << false;
+
+ QTest::newRow("assignValueToSignal") << "assignValueToSignal.qml" << "assignValueToSignal.errors.txt" << false;
+ QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
+
+ QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
+ QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
+ QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
+ QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
+ QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
+ QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false;
+ QTest::newRow("noCreation") << "noCreation.qml" << "noCreation.errors.txt" << false;
+ QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false;
+ QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false;
+ QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
+ QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
+ QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false;
+ QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
+ QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false;
+ QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false;
+ QTest::newRow("incorrectCase") << "incorrectCase.qml"
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
+ << "incorrectCase.errors.insensitive.txt"
+#else
+ << "incorrectCase.errors.sensitive.txt"
+#endif
+ << false;
+
+ QTest::newRow("metaobjectRevision.1") << "metaobjectRevision.1.qml" << "metaobjectRevision.1.errors.txt" << false;
+ QTest::newRow("metaobjectRevision.2") << "metaobjectRevision.2.qml" << "metaobjectRevision.2.errors.txt" << false;
+ QTest::newRow("metaobjectRevision.3") << "metaobjectRevision.3.qml" << "metaobjectRevision.3.errors.txt" << false;
+
+ QTest::newRow("invalidRoot.1") << "invalidRoot.1.qml" << "invalidRoot.1.errors.txt" << false;
+ QTest::newRow("invalidRoot.2") << "invalidRoot.2.qml" << "invalidRoot.2.errors.txt" << false;
+ QTest::newRow("invalidRoot.3") << "invalidRoot.3.qml" << "invalidRoot.3.errors.txt" << false;
+ QTest::newRow("invalidRoot.4") << "invalidRoot.4.qml" << "invalidRoot.4.errors.txt" << false;
+
+ QTest::newRow("invalidTypeName.1") << "invalidTypeName.1.qml" << "invalidTypeName.1.errors.txt" << false;
+ QTest::newRow("invalidTypeName.2") << "invalidTypeName.2.qml" << "invalidTypeName.2.errors.txt" << false;
+ QTest::newRow("invalidTypeName.3") << "invalidTypeName.3.qml" << "invalidTypeName.3.errors.txt" << false;
+ QTest::newRow("invalidTypeName.4") << "invalidTypeName.4.qml" << "invalidTypeName.4.errors.txt" << false;
+
+ QTest::newRow("Major version isolation") << "majorVersionIsolation.qml" << "majorVersionIsolation.errors.txt" << false;
+}
+
+
+void tst_qqmllanguage::errors()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, create);
+
+ QQmlComponent component(&engine, TEST_FILE(file));
+
+ if(create) {
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
+}
+
+void tst_qqmllanguage::simpleObject()
+{
+ QQmlComponent component(&engine, TEST_FILE("simpleObject.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_qqmllanguage::simpleContainer()
+{
+ QQmlComponent component(&engine, TEST_FILE("simpleContainer.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QCOMPARE(container->getChildren()->count(),2);
+}
+
+void tst_qqmllanguage::interfaceProperty()
+{
+ QQmlComponent component(&engine, TEST_FILE("interfaceProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->interface());
+ QVERIFY(object->interface()->id == 913);
+}
+
+void tst_qqmllanguage::interfaceQList()
+{
+ QQmlComponent component(&engine, TEST_FILE("interfaceQList.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QVERIFY(container->getQListInterfaces()->count() == 2);
+ for(int ii = 0; ii < 2; ++ii)
+ QVERIFY(container->getQListInterfaces()->at(ii)->id == 913);
+}
+
+void tst_qqmllanguage::assignObjectToSignal()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignObjectToSignal.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
+ emit object->basicSignal();
+}
+
+void tst_qqmllanguage::assignObjectToVariant()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignObjectToVariant.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVariant v = object->property("a");
+ QVERIFY(v.userType() == qMetaTypeId<QObject *>());
+}
+
+void tst_qqmllanguage::assignLiteralSignalProperty()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->onLiteralSignal(), 10);
+}
+
+// Test is an external component can be loaded and assigned (to a qlist)
+void tst_qqmllanguage::assignQmlComponent()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignQmlComponent.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->getChildren()->count() == 1);
+ QObject *child = object->getChildren()->at(0);
+ QCOMPARE(child->property("x"), QVariant(10));
+ QCOMPARE(child->property("y"), QVariant(11));
+}
+
+// Test literal assignment to all the basic types
+void tst_qqmllanguage::assignBasicTypes()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ 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->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2, 2.3));
+ QUrl encoded;
+ encoded.setEncodedUrl("main.qml?with%3cencoded%3edata", QUrl::TolerantMode);
+ QCOMPARE(object->urlProperty(), component.url().resolved(encoded));
+ QVERIFY(object->objectProperty() != 0);
+ MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
+ QVERIFY(child != 0);
+ QCOMPARE(child->intProperty(), 8);
+}
+
+// Test edge case type assignments
+void tst_qqmllanguage::assignTypeExtremes()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignTypeExtremes.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->uintProperty(), 0xEE6B2800);
+ QCOMPARE(object->intProperty(), -0x77359400);
+}
+
+// Test that a composite type can assign to a property of its base type
+void tst_qqmllanguage::assignCompositeToType()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignCompositeToType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Test that literals are stored correctly in variant properties
+void tst_qqmllanguage::assignLiteralToVariant()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").userType(), (int)QVariant::Int);
+ QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
+ QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test4").userType(), (int)QVariant::Color);
+ QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF);
+ QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF);
+ QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF);
+ QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D);
+ QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool);
+ QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool);
+ QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D);
+
+ QVERIFY(object->property("test1") == QVariant(1));
+ QVERIFY(object->property("test2") == QVariant((double)1.7));
+ QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!"))));
+ QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800)));
+ QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10)));
+ QVERIFY(object->property("test6") == QVariant(QPointF(10, 10)));
+ QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10)));
+ QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100)));
+ QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800"))));
+ QVERIFY(object->property("test10") == QVariant(bool(true)));
+ QVERIFY(object->property("test11") == QVariant(bool(false)));
+ QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100)));
+
+ delete object;
+}
+
+// Test that literals are stored correctly in "var" properties
+// Note that behaviour differs from "variant" properties in that
+// no conversion from "special strings" to QVariants is performed.
+void tst_qqmllanguage::assignLiteralToVar()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignLiteralToVar.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").userType(), (int)QMetaType::Int);
+ QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
+ QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test4").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test5").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test6").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test7").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test8").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool);
+ QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool);
+ QCOMPARE(object->property("test12").userType(), (int)QVariant::Color);
+ QCOMPARE(object->property("test13").userType(), (int)QVariant::RectF);
+ QCOMPARE(object->property("test14").userType(), (int)QVariant::PointF);
+ QCOMPARE(object->property("test15").userType(), (int)QVariant::SizeF);
+ QCOMPARE(object->property("test16").userType(), (int)QVariant::Vector3D);
+ QCOMPARE(object->property("variantTest1Bound").userType(), (int)QMetaType::Int);
+ QCOMPARE(object->property("test1Bound").userType(), (int)QMetaType::Int);
+
+ QCOMPARE(object->property("test1"), QVariant(5));
+ QCOMPARE(object->property("test2"), QVariant((double)1.7));
+ QCOMPARE(object->property("test3"), QVariant(QString(QLatin1String("Hello world!"))));
+ QCOMPARE(object->property("test4"), QVariant(QString(QLatin1String("#FF008800"))));
+ QCOMPARE(object->property("test5"), QVariant(QString(QLatin1String("10,10,10x10"))));
+ QCOMPARE(object->property("test6"), QVariant(QString(QLatin1String("10,10"))));
+ QCOMPARE(object->property("test7"), QVariant(QString(QLatin1String("10x10"))));
+ QCOMPARE(object->property("test8"), QVariant(QString(QLatin1String("100,100,100"))));
+ QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800"))));
+ QCOMPARE(object->property("test10"), QVariant(bool(true)));
+ QCOMPARE(object->property("test11"), QVariant(bool(false)));
+ QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2, 0.3, 0.4, 0.5)));
+ QCOMPARE(object->property("test13"), QVariant(QRectF(10, 10, 10, 10)));
+ QCOMPARE(object->property("test14"), QVariant(QPointF(10, 10)));
+ QCOMPARE(object->property("test15"), QVariant(QSizeF(10, 10)));
+ QCOMPARE(object->property("test16"), QVariant(QVector3D(100, 100, 100)));
+ QCOMPARE(object->property("variantTest1Bound"), QVariant(9));
+ QCOMPARE(object->property("test1Bound"), QVariant(11));
+
+ delete object;
+}
+
+// Tests that custom parser types can be instantiated
+void tst_qqmllanguage::customParserTypes()
+{
+ QQmlComponent component(&engine, TEST_FILE("customParserTypes.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("count") == QVariant(2));
+}
+
+// Tests that the root item can be a custom component
+void tst_qqmllanguage::rootAsQmlComponent()
+{
+ QQmlComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("x"), QVariant(11));
+ QCOMPARE(object->getChildren()->count(), 2);
+}
+
+// Tests that components can be specified inline
+void tst_qqmllanguage::inlineQmlComponents()
+{
+ QQmlComponent component(&engine, TEST_FILE("inlineQmlComponents.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->getChildren()->count(), 1);
+ QQmlComponent *comp = qobject_cast<QQmlComponent *>(object->getChildren()->at(0));
+ QVERIFY(comp != 0);
+ MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create());
+ QVERIFY(compObject != 0);
+ QCOMPARE(compObject->value(), 11);
+}
+
+// Tests that types that have an id property have it set
+void tst_qqmllanguage::idProperty()
+{
+ QQmlComponent component(&engine, TEST_FILE("idProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->getChildren()->count(), 1);
+ MyTypeObject *child =
+ qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
+ QVERIFY(child != 0);
+ QCOMPARE(child->id(), QString("myObjectId"));
+ QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
+}
+
+// Tests automatic connection to notify signals if "onBlahChanged" syntax is used
+// even if the notify signal for "blah" is not called "blahChanged"
+void tst_qqmllanguage::autoNotifyConnection()
+{
+ QQmlComponent component(&engine, TEST_FILE("autoNotifyConnection.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify"));
+ QVERIFY(prop.isValid());
+
+ QCOMPARE(prop.read(object), QVariant::fromValue(false));
+ object->setPropertyWithNotify(1);
+ QCOMPARE(prop.read(object), QVariant::fromValue(true));
+}
+
+// Tests that signals can be assigned to
+void tst_qqmllanguage::assignSignal()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignSignal.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
+ emit object->basicSignal();
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)");
+ emit object->basicParameterizedSignal(9);
+}
+
+// Tests the creation and assignment of dynamic properties
+void tst_qqmllanguage::dynamicProperties()
+{
+ QQmlComponent component(&engine, TEST_FILE("dynamicProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("intProperty"), QVariant(10));
+ QCOMPARE(object->property("boolProperty"), QVariant(false));
+ QCOMPARE(object->property("doubleProperty"), QVariant(-10.1));
+ QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9));
+ QCOMPARE(object->property("stringProperty"), QVariant("Hello World!"));
+ QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml")));
+ QCOMPARE(object->property("colorProperty"), QVariant(QColor("red")));
+ QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2)));
+ QCOMPARE(object->property("varProperty"), QVariant("Hello World!"));
+}
+
+// Test that nested types can use dynamic properties
+void tst_qqmllanguage::dynamicPropertiesNested()
+{
+ QQmlComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("super_a").toInt(), 11); // Overridden
+ QCOMPARE(object->property("super_c").toInt(), 14); // Inherited
+ QCOMPARE(object->property("a").toInt(), 13); // New
+ QCOMPARE(object->property("b").toInt(), 12); // New
+
+ delete object;
+}
+
+// Tests the creation and assignment to dynamic list properties
+void tst_qqmllanguage::listProperties()
+{
+ QQmlComponent component(&engine, TEST_FILE("listProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 2);
+}
+
+// Tests the creation and assignment of dynamic object properties
+// ### Not complete
+void tst_qqmllanguage::dynamicObjectProperties()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0));
+ QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0));
+ }
+ {
+ QQmlComponent component(&engine, TEST_FILE("dynamicObjectProperties.2.qml"));
+ QEXPECT_FAIL("", "QTBUG-10822", Abort);
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("objectProperty") != qVariantFromValue((QObject*)0));
+ }
+}
+
+// Tests the declaration of dynamic signals and slots
+void tst_qqmllanguage::dynamicSignalsAndSlots()
+{
+ QTest::ignoreMessage(QtDebugMsg, "1921");
+
+ QQmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10)));
+ QCOMPARE(object->property("test").toInt(), 10);
+}
+
+void tst_qqmllanguage::simpleBindings()
+{
+ QQmlComponent component(&engine, TEST_FILE("simpleBindings.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value1"), QVariant(10));
+ QCOMPARE(object->property("value2"), QVariant(10));
+ QCOMPARE(object->property("value3"), QVariant(21));
+ QCOMPARE(object->property("value4"), QVariant(10));
+ QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object));
+}
+
+void tst_qqmllanguage::autoComponentCreation()
+{
+ QQmlComponent component(&engine, TEST_FILE("autoComponentCreation.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->componentProperty() != 0);
+ MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create());
+ QVERIFY(child != 0);
+ QCOMPARE(child->realProperty(), qreal(9));
+}
+
+void tst_qqmllanguage::propertyValueSource()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("propertyValueSource.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QList<QObject *> valueSources;
+ QObjectList allChildren = object->findChildren<QObject*>();
+ foreach (QObject *child, allChildren) {
+ if (qobject_cast<QQmlPropertyValueSource *>(child))
+ valueSources.append(child);
+ }
+
+ QCOMPARE(valueSources.count(), 1);
+ MyPropertyValueSource *valueSource =
+ qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
+ QVERIFY(valueSource != 0);
+ QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
+ QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("propertyValueSource.2.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QList<QObject *> valueSources;
+ QObjectList allChildren = object->findChildren<QObject*>();
+ foreach (QObject *child, allChildren) {
+ if (qobject_cast<QQmlPropertyValueSource *>(child))
+ valueSources.append(child);
+ }
+
+ QCOMPARE(valueSources.count(), 1);
+ MyPropertyValueSource *valueSource =
+ qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
+ QVERIFY(valueSource != 0);
+ QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
+ QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
+ }
+}
+
+void tst_qqmllanguage::attachedProperties()
+{
+ QQmlComponent component(&engine, TEST_FILE("attachedProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object);
+ QVERIFY(attached != 0);
+ QCOMPARE(attached->property("value"), QVariant(10));
+ QCOMPARE(attached->property("value2"), QVariant(13));
+}
+
+// Tests non-static object properties
+void tst_qqmllanguage::dynamicObjects()
+{
+ QQmlComponent component(&engine, TEST_FILE("dynamicObject.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Tests the registration of custom variant string converters
+void tst_qqmllanguage::customVariantTypes()
+{
+ QQmlComponent component(&engine, TEST_FILE("customVariantTypes.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->customType().a, 10);
+}
+
+void tst_qqmllanguage::valueTypes()
+{
+ QQmlComponent component(&engine, TEST_FILE("valueTypes.qml"));
+ VERIFY_ERRORS(0);
+
+ QString message = component.url().toString() + ":2:1: QML MyTypeObject: Binding loop detected for property \"rectProperty.width\"";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+
+
+ QCOMPARE(object->rectProperty(), QRect(10, 11, 12, 13));
+ QCOMPARE(object->rectProperty2(), QRect(10, 11, 12, 13));
+ QCOMPARE(object->intProperty(), 10);
+ object->doAction();
+ QCOMPARE(object->rectProperty(), QRect(12, 11, 14, 13));
+ QCOMPARE(object->rectProperty2(), QRect(12, 11, 14, 13));
+ QCOMPARE(object->intProperty(), 12);
+
+ // ###
+#if 0
+ QQmlProperty p(object, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(12));
+ p.write(13);
+ QCOMPARE(p.read(), QVariant(13));
+
+ quint32 r = QQmlPropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex());
+ QQmlProperty p2;
+ QQmlPropertyPrivate::restore(p2, r, object);
+ QCOMPARE(p2.read(), QVariant(13));
+#endif
+}
+
+void tst_qqmllanguage::cppnamespace()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("cppnamespace.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("cppnamespace.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+ }
+}
+
+void tst_qqmllanguage::aliasProperties()
+{
+ // Simple "int" alias
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("valueAlias").toInt(), 10);
+ object->setProperty("value", QVariant(13));
+ QCOMPARE(object->property("valueAlias").toInt(), 13);
+
+ // Write through alias
+ object->setProperty("valueAlias", QVariant(19));
+ QCOMPARE(object->property("valueAlias").toInt(), 19);
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+ }
+
+ // Complex object alias
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ MyQmlObject *v =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v != 0);
+ QCOMPARE(v->value(), 10);
+
+ // Write through alias
+ MyQmlObject *v2 = new MyQmlObject();
+ v2->setParent(object);
+ object->setProperty("aliasObject", qVariantFromValue(v2));
+ MyQmlObject *v3 =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v3 != 0);
+ QCOMPARE(v3, v2);
+
+ delete object;
+ }
+
+ // Nested aliases
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.3.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 1892);
+ QCOMPARE(object->property("value2").toInt(), 1892);
+
+ object->setProperty("value", QVariant(1313));
+ QCOMPARE(object->property("value").toInt(), 1313);
+ QCOMPARE(object->property("value2").toInt(), 1313);
+
+ object->setProperty("value2", QVariant(8080));
+ QCOMPARE(object->property("value").toInt(), 8080);
+ QCOMPARE(object->property("value2").toInt(), 8080);
+
+ delete object;
+ }
+
+ // Enum aliases
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.4.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("enumAlias").toInt(), 1);
+
+ delete object;
+ }
+
+ // Id aliases
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.5.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVariant v = object->property("otherAlias");
+ QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
+ MyQmlObject *o = qvariant_cast<MyQmlObject*>(v);
+ QCOMPARE(o->value(), 10);
+
+ delete o;
+
+ v = object->property("otherAlias");
+ QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
+ o = qvariant_cast<MyQmlObject*>(v);
+ QVERIFY(o == 0);
+
+ delete object;
+ }
+
+ // Nested aliases - this used to cause a crash
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.6.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 1923);
+ }
+
+ // Ptr Alias Cleanup - check that aliases to ptr types return 0
+ // if the object aliased to is removed
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.7.qml"));
+ VERIFY_ERRORS(0);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *object1 = qvariant_cast<QObject *>(object->property("object"));
+ QVERIFY(object1 != 0);
+ QObject *object2 = qvariant_cast<QObject *>(object1->property("object"));
+ QVERIFY(object2 != 0);
+
+ QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject"));
+ QVERIFY(alias == object2);
+
+ delete object1;
+
+ QObject *alias2 = object; // "Random" start value
+ int status = -1;
+ void *a[] = { &alias2, 0, &status };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty,
+ object->metaObject()->indexOfProperty("aliasedObject"), a);
+ QVERIFY(alias2 == 0);
+ }
+
+ // Simple composite type
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.8.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 10);
+
+ delete object;
+ }
+
+ // Complex composite type
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.9.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 10);
+
+ delete object;
+ }
+
+ // Valuetype alias
+ // Simple "int" alias
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.10.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("valueAlias").toRect(), QRect(10, 11, 9, 8));
+ object->setProperty("rectProperty", QVariant(QRect(33, 12, 99, 100)));
+ QCOMPARE(object->property("valueAlias").toRect(), QRect(33, 12, 99, 100));
+
+ // Write through alias
+ object->setProperty("valueAlias", QVariant(QRect(3, 3, 4, 9)));
+ QCOMPARE(object->property("valueAlias").toRect(), QRect(3, 3, 4, 9));
+ QCOMPARE(object->property("rectProperty").toRect(), QRect(3, 3, 4, 9));
+
+ delete object;
+ }
+
+ // Valuetype sub-alias
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.11.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("aliasProperty").toInt(), 19);
+ object->setProperty("rectProperty", QVariant(QRect(33, 8, 102, 111)));
+ QCOMPARE(object->property("aliasProperty").toInt(), 33);
+
+ // Write through alias
+ object->setProperty("aliasProperty", QVariant(4));
+ QCOMPARE(object->property("aliasProperty").toInt(), 4);
+ QCOMPARE(object->property("rectProperty").toRect(), QRect(4, 8, 102, 111));
+
+ delete object;
+ }
+}
+
+// QTBUG-13374 Test that alias properties and signals can coexist
+void tst_qqmllanguage::aliasPropertiesAndSignals()
+{
+ QQmlComponent component(&engine, TEST_FILE("aliasPropertiesAndSignals.qml"));
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+// Test that the root element in a composite type can be a Component
+void tst_qqmllanguage::componentCompositeType()
+{
+ QQmlComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+class TestType : public QObject {
+ Q_OBJECT
+public:
+ TestType(QObject *p=0) : QObject(p) {}
+};
+
+class TestType2 : public QObject {
+ Q_OBJECT
+public:
+ TestType2(QObject *p=0) : QObject(p) {}
+};
+
+void tst_qqmllanguage::i18n_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("stringProperty");
+ QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)");
+ QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10");
+ QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15");
+ QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20");
+ QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30");
+ QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40");
+}
+
+void tst_qqmllanguage::i18n()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, stringProperty);
+ QQmlComponent component(&engine, TEST_FILE(file));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), stringProperty);
+
+ delete object;
+}
+
+// Check that the Component::onCompleted attached property works
+void tst_qqmllanguage::onCompleted()
+{
+ QQmlComponent component(&engine, TEST_FILE("onCompleted.qml"));
+ VERIFY_ERRORS(0);
+ QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Completed 10 11");
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Check that the Component::onDestruction attached property works
+void tst_qqmllanguage::onDestruction()
+{
+ QQmlComponent component(&engine, TEST_FILE("onDestruction.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Destruction 10 11");
+ delete object;
+}
+
+// Check that assignments to QQmlScriptString properties work
+void tst_qqmllanguage::scriptString()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("scriptString.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("foo + bar"));
+ QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object));
+ QCOMPARE(object->scriptProperty().context(), qmlContext(object));
+
+ QVERIFY(object->grouped() != 0);
+ QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)"));
+ QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object));
+ QCOMPARE(object->grouped()->script().context(), qmlContext(object));
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("scriptString2.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("\"hello\\n\\\"world\\\"\""));
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("scriptString3.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("12.345"));
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("scriptString4.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("true"));
+ }
+}
+
+// Check that default property assignments are correctly spliced into explicit
+// property assignments
+void tst_qqmllanguage::defaultPropertyListOrder()
+{
+ QQmlComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml"));
+ VERIFY_ERRORS(0);
+
+ MyContainer *container = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->getChildren()->count(), 6);
+ QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0));
+ QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1));
+ QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2));
+ QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3));
+ QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4));
+ QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5));
+}
+
+void tst_qqmllanguage::declaredPropertyValues()
+{
+ QQmlComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
+ VERIFY_ERRORS(0);
+}
+
+void tst_qqmllanguage::dontDoubleCallClassBegin()
+{
+ QQmlComponent component(&engine, TEST_FILE("dontDoubleCallClassBegin.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ MyParserStatus *o2 = qobject_cast<MyParserStatus *>(qvariant_cast<QObject *>(o->property("object")));
+ QVERIFY(o2);
+ QCOMPARE(o2->classBeginCount(), 1);
+ QCOMPARE(o2->componentCompleteCount(), 1);
+
+ delete o;
+}
+
+void tst_qqmllanguage::reservedWords_data()
+{
+ QTest::addColumn<QByteArray>("word");
+
+ QTest::newRow("abstract") << QByteArray("abstract");
+ QTest::newRow("as") << QByteArray("as");
+ QTest::newRow("boolean") << QByteArray("boolean");
+ QTest::newRow("break") << QByteArray("break");
+ QTest::newRow("byte") << QByteArray("byte");
+ QTest::newRow("case") << QByteArray("case");
+ QTest::newRow("catch") << QByteArray("catch");
+ QTest::newRow("char") << QByteArray("char");
+ QTest::newRow("class") << QByteArray("class");
+ QTest::newRow("continue") << QByteArray("continue");
+ QTest::newRow("const") << QByteArray("const");
+ QTest::newRow("debugger") << QByteArray("debugger");
+ QTest::newRow("default") << QByteArray("default");
+ QTest::newRow("delete") << QByteArray("delete");
+ QTest::newRow("do") << QByteArray("do");
+ QTest::newRow("double") << QByteArray("double");
+ QTest::newRow("else") << QByteArray("else");
+ QTest::newRow("enum") << QByteArray("enum");
+ QTest::newRow("export") << QByteArray("export");
+ QTest::newRow("extends") << QByteArray("extends");
+ QTest::newRow("false") << QByteArray("false");
+ QTest::newRow("final") << QByteArray("final");
+ QTest::newRow("finally") << QByteArray("finally");
+ QTest::newRow("float") << QByteArray("float");
+ QTest::newRow("for") << QByteArray("for");
+ QTest::newRow("function") << QByteArray("function");
+ QTest::newRow("goto") << QByteArray("goto");
+ QTest::newRow("if") << QByteArray("if");
+ QTest::newRow("implements") << QByteArray("implements");
+ QTest::newRow("import") << QByteArray("import");
+ QTest::newRow("in") << QByteArray("in");
+ QTest::newRow("instanceof") << QByteArray("instanceof");
+ QTest::newRow("int") << QByteArray("int");
+ QTest::newRow("interface") << QByteArray("interface");
+ QTest::newRow("long") << QByteArray("long");
+ QTest::newRow("native") << QByteArray("native");
+ QTest::newRow("new") << QByteArray("new");
+ QTest::newRow("null") << QByteArray("null");
+ QTest::newRow("package") << QByteArray("package");
+ QTest::newRow("private") << QByteArray("private");
+ QTest::newRow("protected") << QByteArray("protected");
+ QTest::newRow("public") << QByteArray("public");
+ QTest::newRow("return") << QByteArray("return");
+ QTest::newRow("short") << QByteArray("short");
+ QTest::newRow("static") << QByteArray("static");
+ QTest::newRow("super") << QByteArray("super");
+ QTest::newRow("switch") << QByteArray("switch");
+ QTest::newRow("synchronized") << QByteArray("synchronized");
+ QTest::newRow("this") << QByteArray("this");
+ QTest::newRow("throw") << QByteArray("throw");
+ QTest::newRow("throws") << QByteArray("throws");
+ QTest::newRow("transient") << QByteArray("transient");
+ QTest::newRow("true") << QByteArray("true");
+ QTest::newRow("try") << QByteArray("try");
+ QTest::newRow("typeof") << QByteArray("typeof");
+ QTest::newRow("var") << QByteArray("var");
+ QTest::newRow("void") << QByteArray("void");
+ QTest::newRow("volatile") << QByteArray("volatile");
+ QTest::newRow("while") << QByteArray("while");
+ QTest::newRow("with") << QByteArray("with");
+}
+
+void tst_qqmllanguage::reservedWords()
+{
+ QFETCH(QByteArray, word);
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nQtObject { property string " + word + " }", QUrl());
+ QCOMPARE(component.errorString(), QLatin1String(":2 Expected token `identifier'\n"));
+}
+
+// Check that first child of qml is of given type. Empty type insists on error.
+void tst_qqmllanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
+{
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
+
+ QTRY_VERIFY(!component.isLoading());
+
+ if (type.isEmpty()) {
+ QVERIFY(component.isError());
+ QString actualerror;
+ foreach (const QQmlError e, component.errors()) {
+ if (!actualerror.isEmpty())
+ actualerror.append("; ");
+ actualerror.append(e.description());
+ }
+ QCOMPARE(actualerror,expectederror);
+ } else {
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(QString(object->metaObject()->className()), type);
+ delete object;
+ }
+}
+
+// QTBUG-17276
+void tst_qqmllanguage::inlineAssignmentsOverrideBindings()
+{
+ QQmlComponent component(&engine, TEST_FILE("inlineAssignmentsOverrideBindings.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toInt(), 11);
+ delete o;
+}
+
+// QTBUG-19354
+void tst_qqmllanguage::nestedComponentRoots()
+{
+ QQmlComponent component(&engine, TEST_FILE("nestedComponentRoots.qml"));
+}
+
+// Import tests (QT-558)
+void tst_qqmllanguage::importsBuiltin_data()
+{
+ // QT-610
+
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ // import built-ins
+ QTest::newRow("missing import")
+ << "Test {}"
+ << ""
+ << "Test is not a type";
+ QTest::newRow("not in version 0.0")
+ << "import com.nokia.Test 0.0\n"
+ "Test {}"
+ << ""
+ << "Test is not a type";
+ QTest::newRow("version not installed")
+ << "import com.nokia.Test 99.0\n"
+ "Test {}"
+ << ""
+ << "module \"com.nokia.Test\" version 99.0 is not installed";
+ QTest::newRow("in version 0.0")
+ << "import com.nokia.Test 0.0\n"
+ "TestTP {}"
+ << "TestType"
+ << "";
+ QTest::newRow("qualified in version 0.0")
+ << "import com.nokia.Test 0.0 as T\n"
+ "T.TestTP {}"
+ << "TestType"
+ << "";
+ QTest::newRow("in version 1.0")
+ << "import com.nokia.Test 1.0\n"
+ "Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("qualified wrong")
+ << "import com.nokia.Test 1.0 as T\n" // QT-610
+ "Test {}"
+ << ""
+ << "Test is not a type";
+ QTest::newRow("qualified right")
+ << "import com.nokia.Test 1.0 as T\n"
+ "T.Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("qualified right but not in version 0.0")
+ << "import com.nokia.Test 0.0 as T\n"
+ "T.Test {}"
+ << ""
+ << "T.Test is not a type";
+ QTest::newRow("in version 1.1")
+ << "import com.nokia.Test 1.1\n"
+ "Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("in version 1.3")
+ << "import com.nokia.Test 1.3\n"
+ "Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("in version 1.5")
+ << "import com.nokia.Test 1.5\n"
+ "Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("changed in version 1.8")
+ << "import com.nokia.Test 1.8\n"
+ "Test {}"
+ << "TestType2"
+ << "";
+ QTest::newRow("in version 1.12")
+ << "import com.nokia.Test 1.12\n"
+ "Test {}"
+ << "TestType2"
+ << "";
+ QTest::newRow("old in version 1.9")
+ << "import com.nokia.Test 1.9\n"
+ "OldTest {}"
+ << "TestType"
+ << "";
+ QTest::newRow("old in version 1.11")
+ << "import com.nokia.Test 1.11\n"
+ "OldTest {}"
+ << "TestType"
+ << "";
+ QTest::newRow("multiversion 1")
+ << "import com.nokia.Test 1.11\n"
+ "import com.nokia.Test 1.12\n"
+ "Test {}"
+ << (!qmlCheckTypes()?"TestType2":"")
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
+ QTest::newRow("multiversion 2")
+ << "import com.nokia.Test 1.11\n"
+ "import com.nokia.Test 1.12\n"
+ "OldTest {}"
+ << (!qmlCheckTypes()?"TestType":"")
+ << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
+ QTest::newRow("qualified multiversion 3")
+ << "import com.nokia.Test 1.0 as T0\n"
+ "import com.nokia.Test 1.8 as T8\n"
+ "T0.Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("qualified multiversion 4")
+ << "import com.nokia.Test 1.0 as T0\n"
+ "import com.nokia.Test 1.8 as T8\n"
+ "T8.Test {}"
+ << "TestType2"
+ << "";
+}
+
+void tst_qqmllanguage::importsBuiltin()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+ testType(qml,type,error);
+}
+
+void tst_qqmllanguage::importsLocal_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ // import locals
+ QTest::newRow("local import")
+ << "import \"subdir\"\n" // QT-613
+ "Test {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("local import second")
+ << "import QtQuick 2.0\nimport \"subdir\"\n"
+ "Test {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("local import subsubdir")
+ << "import QtQuick 2.0\nimport \"subdir/subsubdir\"\n"
+ "SubTest {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("local import QTBUG-7721 A")
+ << "subdir.Test {}" // no longer allowed (QTBUG-7721)
+ << ""
+ << "subdir.Test - subdir is not a namespace";
+ QTest::newRow("local import QTBUG-7721 B")
+ << "import \"subdir\" as X\n"
+ "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
+ << ""
+ << "X.subsubdir.SubTest - nested namespaces not allowed";
+ QTest::newRow("local import as")
+ << "import \"subdir\" as T\n"
+ "T.Test {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("wrong local import as")
+ << "import \"subdir\" as T\n"
+ "Test {}"
+ << ""
+ << "Test is not a type";
+ QTest::newRow("library precedence over local import")
+ << "import \"subdir\"\n"
+ "import com.nokia.Test 1.0\n"
+ "Test {}"
+ << (!qmlCheckTypes()?"TestType":"")
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir");
+}
+
+void tst_qqmllanguage::importsLocal()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+ testType(qml,type,error);
+}
+
+void tst_qqmllanguage::basicRemote_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ QString serverdir = "http://127.0.0.1:14447/qtest/qml/qqmllanguage/";
+
+ QTest::newRow("no need for qmldir") << QUrl(serverdir+"Test.qml") << "" << "";
+ QTest::newRow("absent qmldir") << QUrl(serverdir+"/noqmldir/Test.qml") << "" << "";
+ QTest::newRow("need qmldir") << QUrl(serverdir+"TestLocal.qml") << "" << "";
+}
+
+void tst_qqmllanguage::basicRemote()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(14447);
+ server.serveDirectory(testdata());
+
+ QQmlComponent component(&engine, url);
+
+ QTRY_VERIFY(!component.isLoading());
+
+ if (error.isEmpty()) {
+ if (component.isError())
+ qDebug() << component.errors();
+ QVERIFY(!component.isError());
+ } else {
+ QVERIFY(component.isError());
+ }
+}
+
+void tst_qqmllanguage::importsRemote_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ QString serverdir = "http://127.0.0.1:14447/qtest/qml/qqmllanguage";
+
+ QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QQuickRectangle"
+ << "";
+ QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QQuickText"
+ << "";
+ QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QQuickImage"
+ << "";
+ QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << ""
+ << "WrongTestLocal is not a type";
+ QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << ""
+ << "LocalInternal is not a type";
+ QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << ""
+ << "UndeclaredLocal is not a type";
+}
+
+void tst_qqmllanguage::importsRemote()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(14447);
+ server.serveDirectory(testdata());
+
+ testType(qml,type,error);
+}
+
+void tst_qqmllanguage::importsInstalled_data()
+{
+ // QT-610
+
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ // import installed
+ QTest::newRow("installed import 0")
+ << "import com.nokia.installedtest0 0.0\n"
+ "InstalledTestTP {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("installed import 0 as TP")
+ << "import com.nokia.installedtest0 0.0 as TP\n"
+ "TP.InstalledTestTP {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("installed import 1")
+ << "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("installed import 2")
+ << "import com.nokia.installedtest 1.3\n"
+ "InstalledTest {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("installed import 3")
+ << "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QQuickText"
+ << "";
+ QTest::newRow("installed import minor version not available") // QTBUG-11936
+ << "import com.nokia.installedtest 0.1\n"
+ "InstalledTest {}"
+ << ""
+ << "module \"com.nokia.installedtest\" version 0.1 is not installed";
+ QTest::newRow("installed import minor version not available") // QTBUG-9627
+ << "import com.nokia.installedtest 1.10\n"
+ "InstalledTest {}"
+ << ""
+ << "module \"com.nokia.installedtest\" version 1.10 is not installed";
+ QTest::newRow("installed import major version not available") // QTBUG-9627
+ << "import com.nokia.installedtest 9.0\n"
+ "InstalledTest {}"
+ << ""
+ << "module \"com.nokia.installedtest\" version 9.0 is not installed";
+ QTest::newRow("installed import visibility") // QT-614
+ << "import com.nokia.installedtest 1.4\n"
+ "PrivateType {}"
+ << ""
+ << "PrivateType is not a type";
+}
+
+void tst_qqmllanguage::importsInstalled()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+ testType(qml,type,error);
+}
+
+
+void tst_qqmllanguage::importsOrder_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("double import") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4");
+ QTest::newRow("installed import overrides 1") <<
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
+ QTest::newRow("installed import overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
+ QTest::newRow("installed import re-overrides 1") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
+ QTest::newRow("installed import re-overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
+
+ QTest::newRow("installed import versus builtin 1") <<
+ "import com.nokia.installedtest 1.5\n"
+ "import QtQuick 2.0\n"
+ "Rectangle {}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest");
+ QTest::newRow("installed import versus builtin 2") <<
+ "import QtQuick 2.0\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << (!qmlCheckTypes()?"QQuickText":"")
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt");
+ QTest::newRow("namespaces cannot be overridden by types 1") <<
+ "import QtQuick 2.0 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << ""
+ << "Namespace Rectangle cannot be used as a type";
+ QTest::newRow("namespaces cannot be overridden by types 2") <<
+ "import QtQuick 2.0 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle.Image {}"
+ << "QQuickImage"
+ << "";
+ QTest::newRow("local last 1") <<
+ "LocalLast {}"
+ << "QQuickText"
+ << "";
+ QTest::newRow("local last 2") <<
+ "import com.nokia.installedtest 1.0\n"
+ "LocalLast {}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
+}
+
+void tst_qqmllanguage::importsOrder()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+ testType(qml,type,error);
+}
+
+void tst_qqmllanguage::importIncorrectCase()
+{
+ QQmlComponent component(&engine, TEST_FILE("importIncorrectCase.qml"));
+
+ QList<QQmlError> errors = component.errors();
+ QCOMPARE(errors.count(), 1);
+
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
+ QString expectedError = QLatin1String("cannot load module \"com.Nokia.installedtest\": File name case mismatch for \"") + testdata("lib/com/Nokia/installedtest/qmldir") + QLatin1String("\"");
+#else
+ QString expectedError = QLatin1String("module \"com.Nokia.installedtest\" is not installed");
+#endif
+
+ QCOMPARE(errors.at(0).description(), expectedError);
+}
+
+void tst_qqmllanguage::importJs_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("performTest");
+
+ QTest::newRow("defaultVersion")
+ << "importJs.1.qml"
+ << "importJs.1.errors.txt"
+ << true;
+
+ QTest::newRow("specifiedVersion")
+ << "importJs.2.qml"
+ << "importJs.2.errors.txt"
+ << true;
+
+ QTest::newRow("excludeExcessiveVersion")
+ << "importJs.3.qml"
+ << "importJs.3.errors.txt"
+ << false;
+
+ QTest::newRow("includeAppropriateVersion")
+ << "importJs.4.qml"
+ << "importJs.4.errors.txt"
+ << true;
+
+ QTest::newRow("noDefaultVersion")
+ << "importJs.5.qml"
+ << "importJs.5.errors.txt"
+ << false;
+
+ QTest::newRow("repeatImportFails")
+ << "importJs.6.qml"
+ << "importJs.6.errors.txt"
+ << false;
+
+ QTest::newRow("multipleVersionImportFails")
+ << "importJs.7.qml"
+ << "importJs.7.errors.txt"
+ << false;
+
+ QTest::newRow("namespacedImport")
+ << "importJs.8.qml"
+ << "importJs.8.errors.txt"
+ << true;
+
+ QTest::newRow("namespacedVersionedImport")
+ << "importJs.9.qml"
+ << "importJs.9.errors.txt"
+ << true;
+
+ QTest::newRow("namespacedRepeatImport")
+ << "importJs.10.qml"
+ << "importJs.10.errors.txt"
+ << true;
+}
+
+void tst_qqmllanguage::importJs()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, performTest);
+
+ QQmlComponent component(&engine, TEST_FILE(file));
+
+ {
+ DETERMINE_ERRORS(errorFile.toLatin1().constData(),expected,actual);
+ QCOMPARE(expected.size(), actual.size());
+ for (int i = 0; i < expected.size(); ++i)
+ {
+ size_t compareLen = std::min(expected.at(i).length(), actual.at(i).length());
+ QCOMPARE(expected.at(i).left(compareLen), actual.at(i).left(compareLen));
+ }
+ }
+
+ if (performTest) {
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toBool(),true);
+ delete object;
+ }
+}
+
+void tst_qqmllanguage::qmlAttachedPropertiesObjectMethod()
+{
+ QObject object;
+
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0);
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0);
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(object, false), (QObject *)0);
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, false) != 0);
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
+ }
+}
+
+void tst_qqmllanguage::crash1()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nComponent {}", QUrl());
+}
+
+void tst_qqmllanguage::crash2()
+{
+ QQmlComponent component(&engine, TEST_FILE("crash2.qml"));
+}
+
+// QTBUG-8676
+void tst_qqmllanguage::customOnProperty()
+{
+ QQmlComponent component(&engine, TEST_FILE("customOnProperty.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("on").toInt(), 10);
+
+ delete object;
+}
+
+// QTBUG-12601
+void tst_qqmllanguage::variantNotify()
+{
+ QQmlComponent component(&engine, TEST_FILE("variantNotify.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("notifyCount").toInt(), 1);
+
+ delete object;
+}
+
+void tst_qqmllanguage::revisions()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("revisions11.qml"));
+
+ VERIFY_ERRORS(0);
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->prop2(), 10.0);
+
+ delete object;
+ }
+ {
+ QQmlEngine myEngine;
+ QQmlComponent component(&myEngine, TEST_FILE("revisionssub11.qml"));
+
+ VERIFY_ERRORS(0);
+ MyRevisionedSubclass *object = qobject_cast<MyRevisionedSubclass*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->prop1(), 10.0);
+ QCOMPARE(object->prop2(), 10.0);
+ QCOMPARE(object->prop3(), 10.0);
+ QCOMPARE(object->prop4(), 10.0);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, TEST_FILE("versionedbase.qml"));
+ VERIFY_ERRORS(0);
+ MySubclass *object = qobject_cast<MySubclass*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->prop1(), 10.0);
+ QCOMPARE(object->prop2(), 10.0);
+
+ delete object;
+ }
+}
+
+void tst_qqmllanguage::revisionOverloads()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("allowedRevisionOverloads.qml"));
+ VERIFY_ERRORS(0);
+ }
+ {
+ QQmlComponent component(&engine, TEST_FILE("disallowedRevisionOverloads.qml"));
+ QEXPECT_FAIL("", "QTBUG-13849", Abort);
+ QVERIFY(0);
+ VERIFY_ERRORS("disallowedRevisionOverloads.errors.txt");
+ }
+}
+
+void tst_qqmllanguage::initTestCase()
+{
+ QString testdataDir = QFileInfo(QFINDTESTDATA("data")).absolutePath();
+ QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir));
+
+ registerTypes();
+
+ // Registering the TestType class in other modules should have no adverse effects
+ qmlRegisterType<TestType>("com.nokia.TestPre", 1, 0, "Test");
+
+ qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP");
+ qmlRegisterType<TestType>("com.nokia.Test", 1, 0, "Test");
+ qmlRegisterType<TestType>("com.nokia.Test", 1, 5, "Test");
+ qmlRegisterType<TestType2>("com.nokia.Test", 1, 8, "Test");
+ qmlRegisterType<TestType>("com.nokia.Test", 1, 9, "OldTest");
+ qmlRegisterType<TestType2>("com.nokia.Test", 1, 12, "Test");
+
+ // Registering the TestType class in other modules should have no adverse effects
+ qmlRegisterType<TestType>("com.nokia.TestPost", 1, 0, "Test");
+
+ // Create locale-specific file
+ // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit
+ // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters
+ // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
+ QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
+ QVERIFY2(in.open(QIODevice::ReadOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(in.fileName(), in.errorString())));
+ QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
+ QVERIFY2(out.open(QIODevice::WriteOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(out.fileName(), out.errorString())));
+ out.write(in.readAll());
+}
+
+void tst_qqmllanguage::aliasPropertyChangeSignals()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ // QTCREATORBUG-2769
+ {
+ QQmlComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.2.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+}
+
+// Tests property initializers
+void tst_qqmllanguage::propertyInit()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("propertyInit.1.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toInt(), 1);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("propertyInit.2.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toInt(), 123);
+
+ delete o;
+ }
+}
+
+// Test that registration order doesn't break type availability
+// QTBUG-16878
+void tst_qqmllanguage::registrationOrder()
+{
+ QQmlComponent component(&engine, TEST_FILE("registrationOrder.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QVERIFY(o->metaObject() == &MyVersion2Class::staticMetaObject);
+ delete o;
+}
+
+void tst_qqmllanguage::readonly()
+{
+ QQmlComponent component(&engine, TEST_FILE("readonly.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toInt(), 10);
+ QCOMPARE(o->property("test2").toInt(), 18);
+ QCOMPARE(o->property("test3").toInt(), 13);
+
+ o->setProperty("testData", 13);
+
+ QCOMPARE(o->property("test1").toInt(), 10);
+ QCOMPARE(o->property("test2").toInt(), 22);
+ QCOMPARE(o->property("test3").toInt(), 13);
+
+ o->setProperty("testData2", 2);
+
+ QCOMPARE(o->property("test1").toInt(), 10);
+ QCOMPARE(o->property("test2").toInt(), 22);
+ QCOMPARE(o->property("test3").toInt(), 2);
+
+ o->setProperty("test1", 11);
+ o->setProperty("test2", 11);
+ o->setProperty("test3", 11);
+
+ QCOMPARE(o->property("test1").toInt(), 10);
+ QCOMPARE(o->property("test2").toInt(), 22);
+ QCOMPARE(o->property("test3").toInt(), 2);
+
+ delete o;
+}
+
+// QTBUG-18268
+void tst_qqmllanguage::remoteLoadCrash()
+{
+ TestHTTPServer server(14448);
+ server.serveDirectory(testdata());
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml"));
+ while (component.isLoading())
+ QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50);
+
+ QObject *o = component.create();
+ delete o;
+}
+
+QTEST_MAIN(tst_qqmllanguage)
+
+#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml b/tests/auto/qml/qqmllistreference/data/MyType.qml
index f48a77598c..f48a77598c 100644
--- a/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml
+++ b/tests/auto/qml/qqmllistreference/data/MyType.qml
diff --git a/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml b/tests/auto/qml/qqmllistreference/data/engineTypes.qml
index 99a61a7680..99a61a7680 100644
--- a/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml
+++ b/tests/auto/qml/qqmllistreference/data/engineTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml b/tests/auto/qml/qqmllistreference/data/variantToList.qml
index 3728cd0311..3728cd0311 100644
--- a/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml
+++ b/tests/auto/qml/qqmllistreference/data/variantToList.qml
diff --git a/tests/auto/qml/qqmllistreference/qqmllistreference.pro b/tests/auto/qml/qqmllistreference/qqmllistreference.pro
new file mode 100644
index 0000000000..baca1e7c71
--- /dev/null
+++ b/tests/auto/qml/qqmllistreference/qqmllistreference.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmllistreference
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmllistreference.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
new file mode 100644
index 0000000000..bcb8ee8963
--- /dev/null
+++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
@@ -0,0 +1,570 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDir>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlprivate.h>
+#include <QtQml/qqmlproperty.h>
+#include <QDebug>
+#include "../../shared/util.h"
+
+class tst_qqmllistreference : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmllistreference() {}
+
+private slots:
+ void initTestCase();
+ void qmllistreference();
+ void qmllistreference_invalid();
+ void isValid();
+ void object();
+ void listElementType();
+ void canAppend();
+ void canAt();
+ void canClear();
+ void canCount();
+ void append();
+ void at();
+ void clear();
+ void count();
+ void copy();
+ void qmlmetaproperty();
+ void engineTypes();
+ void variantToList();
+};
+
+class TestType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<TestType> data READ dataProperty)
+ Q_PROPERTY(int intProperty READ intProperty)
+
+public:
+ TestType() : property(this, data) {}
+ QQmlListProperty<TestType> dataProperty() { return property; }
+ int intProperty() const { return 10; }
+
+ QList<TestType *> data;
+ QQmlListProperty<TestType> property;
+};
+
+void tst_qqmllistreference::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<TestType>();
+}
+
+void tst_qqmllistreference::qmllistreference()
+{
+ TestType tt;
+
+ QQmlListReference r(&tt, "data");
+ QVERIFY(r.isValid() == true);
+ QCOMPARE(r.count(), 0);
+
+ tt.data.append(&tt);
+ QCOMPARE(r.count(), 1);
+}
+
+void tst_qqmllistreference::qmllistreference_invalid()
+{
+ TestType tt;
+
+ // Invalid
+ {
+ QQmlListReference r;
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+
+ // Non-property
+ {
+ QQmlListReference r(&tt, "blah");
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+
+ // Non-list property
+ {
+ QQmlListReference r(&tt, "intProperty");
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+}
+
+void tst_qqmllistreference::isValid()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.isValid() == true);
+ delete tt;
+ QVERIFY(ref.isValid() == false);
+ }
+}
+
+void tst_qqmllistreference::object()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.object() == tt);
+ delete tt;
+ QVERIFY(ref.object() == 0);
+ }
+}
+
+void tst_qqmllistreference::listElementType()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+ delete tt;
+ QVERIFY(ref.listElementType() == 0);
+ }
+}
+
+void tst_qqmllistreference::canAppend()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.canAppend() == true);
+ delete tt;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.canAppend() == false);
+ }
+}
+
+void tst_qqmllistreference::canAt()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.canAt() == true);
+ delete tt;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.at = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.canAt() == false);
+ }
+}
+
+void tst_qqmllistreference::canClear()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.canClear() == true);
+ delete tt;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.canClear() == false);
+ }
+}
+
+void tst_qqmllistreference::canCount()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.canCount() == true);
+ delete tt;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.count = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.canCount() == false);
+ }
+}
+
+void tst_qqmllistreference::append()
+{
+ TestType *tt = new TestType;
+ QObject object;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.append(tt) == true);
+ QVERIFY(tt->data.count() == 1);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(ref.append(&object) == false);
+ QVERIFY(tt->data.count() == 1);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(ref.append(0) == true);
+ QVERIFY(tt->data.count() == 2);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(tt->data.at(1) == 0);
+ delete tt;
+ QVERIFY(ref.append(0) == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.append(&tt) == false);
+ }
+}
+
+void tst_qqmllistreference::at()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.at(0) == tt);
+ QVERIFY(ref.at(1) == 0);
+ QVERIFY(ref.at(2) == tt);
+ delete tt;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ TestType tt;
+ tt.data.append(&tt);
+ tt.property.at = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.at(0) == 0);
+ }
+}
+
+void tst_qqmllistreference::clear()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.clear() == true);
+ QVERIFY(tt->data.count() == 0);
+ delete tt;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.clear() == false);
+ }
+}
+
+void tst_qqmllistreference::count()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.count() == 3);
+ tt->data.removeAt(1);
+ QVERIFY(ref.count() == 2);
+ delete tt;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ TestType tt;
+ tt.data.append(&tt);
+ tt.property.count = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.count() == 0);
+ }
+}
+
+void tst_qqmllistreference::copy()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QQmlListReference *r1 = new QQmlListReference(&tt, "data");
+ QVERIFY(r1->count() == 3);
+
+ QQmlListReference r2(*r1);
+ QQmlListReference r3;
+ r3 = *r1;
+
+ QVERIFY(r2.count() == 3);
+ QVERIFY(r3.count() == 3);
+
+ delete r1;
+
+ QVERIFY(r2.count() == 3);
+ QVERIFY(r3.count() == 3);
+
+ tt.data.removeAt(2);
+
+ QVERIFY(r2.count() == 2);
+ QVERIFY(r3.count() == 2);
+}
+
+void tst_qqmllistreference::qmlmetaproperty()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QQmlProperty prop(&tt, QLatin1String("data"));
+ QVariant v = prop.read();
+ QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>());
+ QQmlListReference ref = qvariant_cast<QQmlListReference>(v);
+ QVERIFY(ref.count() == 3);
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+}
+
+void tst_qqmllistreference::engineTypes()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("engineTypes.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ QQmlProperty p1(o, QLatin1String("myList"));
+ QVERIFY(p1.propertyTypeCategory() == QQmlProperty::Normal);
+
+ QQmlProperty p2(o, QLatin1String("myList"), engine.rootContext());
+ QVERIFY(p2.propertyTypeCategory() == QQmlProperty::List);
+ QVariant v = p2.read();
+ QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>());
+ QQmlListReference ref = qvariant_cast<QQmlListReference>(v);
+ QVERIFY(ref.count() == 2);
+ QVERIFY(ref.listElementType());
+ QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
+
+ delete o;
+}
+
+void tst_qqmllistreference::variantToList()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("variantToList.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ QVERIFY(o->property("value").userType() == qMetaTypeId<QQmlListReference>());
+ QCOMPARE(o->property("test").toInt(), 1);
+
+ delete o;
+}
+
+QTEST_MAIN(tst_qqmllistreference)
+
+#include "tst_qqmllistreference.moc"
diff --git a/tests/auto/declarative/qdeclarativelocale/data/date.qml b/tests/auto/qml/qqmllocale/data/date.qml
index 3f58497d22..3f58497d22 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/date.qml
+++ b/tests/auto/qml/qqmllocale/data/date.qml
diff --git a/tests/auto/declarative/qdeclarativelocale/data/functions.qml b/tests/auto/qml/qqmllocale/data/functions.qml
index 5fef6a26fb..5fef6a26fb 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/functions.qml
+++ b/tests/auto/qml/qqmllocale/data/functions.qml
diff --git a/tests/auto/declarative/qdeclarativelocale/data/localeCompare.qml b/tests/auto/qml/qqmllocale/data/localeCompare.qml
index 6851af6ef9..6851af6ef9 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/localeCompare.qml
+++ b/tests/auto/qml/qqmllocale/data/localeCompare.qml
diff --git a/tests/auto/declarative/qdeclarativelocale/data/number.qml b/tests/auto/qml/qqmllocale/data/number.qml
index 51a6c15dce..51a6c15dce 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/number.qml
+++ b/tests/auto/qml/qqmllocale/data/number.qml
diff --git a/tests/auto/declarative/qdeclarativelocale/data/properties.qml b/tests/auto/qml/qqmllocale/data/properties.qml
index 16d1f4092a..16d1f4092a 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/properties.qml
+++ b/tests/auto/qml/qqmllocale/data/properties.qml
diff --git a/tests/auto/qml/qqmllocale/qqmllocale.pro b/tests/auto/qml/qqmllocale/qqmllocale.pro
new file mode 100644
index 0000000000..1773f83f91
--- /dev/null
+++ b/tests/auto/qml/qqmllocale/qqmllocale.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmllocale
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmllocale.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += qml testlib
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
new file mode 100644
index 0000000000..46435fb8fc
--- /dev/null
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -0,0 +1,1219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QDebug>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtCore/QDateTime>
+#include <qcolor.h>
+#include "../../shared/util.h"
+
+class tst_qqmllocale : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmllocale() { }
+
+private slots:
+ void defaultLocale();
+
+ void properties_data();
+ void properties();
+ void currencySymbol_data();
+ void currencySymbol();
+ void monthName_data();
+ void monthName();
+ void standaloneMonthName_data();
+ void standaloneMonthName();
+ void dayName_data();
+ void dayName();
+ void standaloneDayName_data();
+ void standaloneDayName();
+ void firstDayOfWeek_data();
+ void firstDayOfWeek();
+ void weekDays_data();
+ void weekDays();
+ void uiLanguages_data();
+ void uiLanguages();
+ void dateFormat_data();
+ void dateFormat();
+ void dateTimeFormat_data();
+ void dateTimeFormat();
+ void timeFormat_data();
+ void timeFormat();
+
+ void dateToLocaleString_data();
+ void dateToLocaleString();
+ void dateToLocaleStringFormatted_data();
+ void dateToLocaleStringFormatted();
+ void dateToLocaleDateString_data();
+ void dateToLocaleDateString();
+ void dateToLocaleDateStringFormatted_data();
+ void dateToLocaleDateStringFormatted();
+ void dateToLocaleTimeString_data();
+ void dateToLocaleTimeString();
+ void dateToLocaleTimeStringFormatted_data();
+ void dateToLocaleTimeStringFormatted();
+ void dateFromLocaleString_data();
+ void dateFromLocaleString();
+ void dateFromLocaleDateString_data();
+ void dateFromLocaleDateString();
+ void dateFromLocaleTimeString_data();
+ void dateFromLocaleTimeString();
+
+ void numberToLocaleString_data();
+ void numberToLocaleString();
+ void numberToLocaleCurrencyString_data();
+ void numberToLocaleCurrencyString();
+ void numberFromLocaleString_data();
+ void numberFromLocaleString();
+ void numberConstToLocaleString();
+
+ void stringLocaleCompare_data();
+ void stringLocaleCompare();
+
+private:
+ void addPropertyData(const QString &l);
+ QVariant getProperty(QObject *obj, const QString &locale, const QString &property);
+ void addCurrencySymbolData(const QString &locale);
+ void addStandardFormatData();
+ void addFormatNameData(const QString &locale);
+ void addDateTimeFormatData(const QString &l);
+ void addDateFormatData(const QString &l);
+ void addTimeFormatData(const QString &l);
+ QQmlEngine engine;
+};
+
+void tst_qqmllocale::defaultLocale()
+{
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QCOMPARE(obj->property("name").toString(), QLocale().name());
+}
+
+#define LOCALE_PROP(type,prop) { #prop, QVariant(type(qlocale.prop())) }
+
+void tst_qqmllocale::addPropertyData(const QString &l)
+{
+ QLocale qlocale(l);
+
+ struct {
+ const char *name;
+ QVariant value;
+ }
+ values[] = {
+ LOCALE_PROP(QString,name),
+ LOCALE_PROP(QString,amText),
+ LOCALE_PROP(QString,pmText),
+ LOCALE_PROP(QString,nativeLanguageName),
+ LOCALE_PROP(QString,nativeCountryName),
+ LOCALE_PROP(QString,decimalPoint),
+ LOCALE_PROP(QString,groupSeparator),
+ LOCALE_PROP(QString,percent),
+ LOCALE_PROP(QString,zeroDigit),
+ LOCALE_PROP(QString,negativeSign),
+ LOCALE_PROP(QString,positiveSign),
+ LOCALE_PROP(QString,exponential),
+ LOCALE_PROP(int,measurementSystem),
+ LOCALE_PROP(int,textDirection),
+ { 0, QVariant() }
+ };
+
+ int i = 0;
+ while (values[i].name) {
+ QByteArray n = l.toLatin1() + ':' + values[i].name;
+ QTest::newRow(n.constData()) << l << QByteArray(values[i].name) << values[i].value;
+ ++i;
+ }
+}
+
+void tst_qqmllocale::properties_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QByteArray>("property");
+ QTest::addColumn<QVariant>("value");
+
+ addPropertyData("en_US");
+ addPropertyData("de_DE");
+ addPropertyData("ar_SA");
+ addPropertyData("hi_IN");
+ addPropertyData("zh_CN");
+ addPropertyData("th_TH");
+}
+
+void tst_qqmllocale::properties()
+{
+ QFETCH(QString, locale);
+ QFETCH(QByteArray, property);
+ QFETCH(QVariant, value);
+
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QCOMPARE(obj->property(property), value);
+
+ delete obj;
+}
+
+void tst_qqmllocale::addCurrencySymbolData(const QString &l)
+{
+ QByteArray locale = l.toLatin1();
+ QTest::newRow(locale.constData()) << l << -1;
+ QByteArray t(locale);
+ t += " CurrencyIsoCode";
+ QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyIsoCode;
+ t = locale + " CurrencySymbol";
+ QTest::newRow(t.constData()) << l << (int)QLocale::CurrencySymbol;
+ t = locale + " CurrencyDisplayName";
+ QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyDisplayName;
+}
+
+void tst_qqmllocale::currencySymbol_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<int>("param");
+
+ addCurrencySymbolData("en_US");
+ addCurrencySymbolData("de_DE");
+ addCurrencySymbolData("ar_SA");
+ addCurrencySymbolData("hi_IN");
+ addCurrencySymbolData("zh_CN");
+ addCurrencySymbolData("th_TH");
+}
+
+void tst_qqmllocale::currencySymbol()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol;
+
+ if (param >= 0)
+ format = QLocale::CurrencySymbolFormat(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QMetaObject::invokeMethod(obj, "currencySymbol", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ QCOMPARE(val.toString(), l.currencySymbol(format));
+
+ delete obj;
+}
+
+void tst_qqmllocale::addFormatNameData(const QString &l)
+{
+ QByteArray locale = l.toLatin1();
+ QTest::newRow(locale.constData()) << l << -1;
+ QByteArray t(locale);
+ t += " LongFormat";
+ QTest::newRow(t.constData()) << l << (int)QLocale::LongFormat;
+ t = locale + " ShortFormat";
+ QTest::newRow(t.constData()) << l << (int)QLocale::ShortFormat;
+ t = locale + " NarrowFormat";
+ QTest::newRow(t.constData()) << l << (int)QLocale::NarrowFormat;
+}
+
+void tst_qqmllocale::addStandardFormatData()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<int>("param");
+
+ addFormatNameData("en_US");
+ addFormatNameData("de_DE");
+ addFormatNameData("ar_SA");
+ addFormatNameData("hi_IN");
+ addFormatNameData("zh_CN");
+ addFormatNameData("th_TH");
+}
+
+void tst_qqmllocale::monthName_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::monthName()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::FormatType format = QLocale::LongFormat;
+ if (param >= 0)
+ format = QLocale::FormatType(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ for (int i = 0; i <= 11; ++i) {
+ QMetaObject::invokeMethod(obj, "monthName", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(i)),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ // QLocale January == 1, JS Date January == 0
+ QCOMPARE(val.toString(), l.monthName(i+1, format));
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::standaloneMonthName_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::standaloneMonthName()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::FormatType format = QLocale::LongFormat;
+ if (param >= 0)
+ format = QLocale::FormatType(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ for (int i = 0; i <= 11; ++i) {
+ QMetaObject::invokeMethod(obj, "standaloneMonthName", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(i)),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ // QLocale January == 1, JS Date January == 0
+ QCOMPARE(val.toString(), l.standaloneMonthName(i+1, format));
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::dayName_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dayName()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::FormatType format = QLocale::LongFormat;
+ if (param >= 0)
+ format = QLocale::FormatType(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ for (int i = 1; i <= 7; ++i) {
+ QMetaObject::invokeMethod(obj, "dayName", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(i)),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ QCOMPARE(val.toString(), l.dayName(i, format));
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::standaloneDayName_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::standaloneDayName()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ for (int i = 1; i <= 7; ++i) {
+ QMetaObject::invokeMethod(obj, "standaloneDayName", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(i)),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ QCOMPARE(val.toString(), l.standaloneDayName(i, format));
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::firstDayOfWeek_data()
+{
+ QTest::addColumn<QString>("locale");
+
+ QTest::newRow("en_US") << "en_US";
+ QTest::newRow("de_DE") << "de_DE";
+ QTest::newRow("ar_SA") << "ar_SA";
+ QTest::newRow("hi_IN") << "hi_IN";
+ QTest::newRow("zh_CN") << "zh_CN";
+ QTest::newRow("th_TH") << "th_TH";
+}
+
+void tst_qqmllocale::firstDayOfWeek()
+{
+ QFETCH(QString, locale);
+
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val = obj->property("firstDayOfWeek");
+ QVERIFY(val.type() == QVariant::Int);
+
+ int day = int(QLocale(locale).firstDayOfWeek());
+ if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
+ day = 0;
+ QCOMPARE(day, val.toInt());
+
+ delete obj;
+}
+
+void tst_qqmllocale::weekDays_data()
+{
+ QTest::addColumn<QString>("locale");
+
+ QTest::newRow("en_US") << "en_US";
+ QTest::newRow("de_DE") << "de_DE";
+ QTest::newRow("ar_SA") << "ar_SA";
+ QTest::newRow("hi_IN") << "hi_IN";
+ QTest::newRow("zh_CN") << "zh_CN";
+ QTest::newRow("th_TH") << "th_TH";
+}
+
+void tst_qqmllocale::weekDays()
+{
+ QFETCH(QString, locale);
+
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val = obj->property("weekDays");
+ QVERIFY(val.type() == QVariant::List);
+
+ QList<QVariant> qmlDays = val.toList();
+ QList<Qt::DayOfWeek> days = QLocale(locale).weekdays();
+
+ QVERIFY(days.count() == qmlDays.count());
+
+ for (int i = 0; i < days.count(); ++i) {
+ int day = int(days.at(i));
+ if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
+ day = 0;
+ QCOMPARE(day, qmlDays.at(i).toInt());
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::uiLanguages_data()
+{
+ QTest::addColumn<QString>("locale");
+
+ QTest::newRow("en_US") << "en_US";
+ QTest::newRow("de_DE") << "de_DE";
+ QTest::newRow("ar_SA") << "ar_SA";
+ QTest::newRow("hi_IN") << "hi_IN";
+ QTest::newRow("zh_CN") << "zh_CN";
+ QTest::newRow("th_TH") << "th_TH";
+}
+
+void tst_qqmllocale::uiLanguages()
+{
+ QFETCH(QString, locale);
+
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val = obj->property("uiLanguages");
+ QVERIFY(val.type() == QVariant::List);
+
+ QList<QVariant> qmlLangs = val.toList();
+ QStringList langs = QLocale(locale).uiLanguages();
+
+ QVERIFY(langs.count() == qmlLangs.count());
+
+ for (int i = 0; i < langs.count(); ++i) {
+ QCOMPARE(langs.at(i), qmlLangs.at(i).toString());
+ }
+
+ delete obj;
+}
+
+
+void tst_qqmllocale::dateTimeFormat_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateTimeFormat()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+ QMetaObject::invokeMethod(obj, "dateTimeFormat", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QCOMPARE(val.toString(), l.dateTimeFormat(format));
+}
+
+void tst_qqmllocale::dateFormat_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateFormat()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+ QMetaObject::invokeMethod(obj, "dateFormat", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QCOMPARE(val.toString(), l.dateFormat(format));
+}
+
+void tst_qqmllocale::timeFormat_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::timeFormat()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+ QMetaObject::invokeMethod(obj, "timeFormat", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QCOMPARE(val.toString(), l.timeFormat(format));
+}
+
+void tst_qqmllocale::dateToLocaleString_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateToLocaleString()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt, format));
+}
+
+void tst_qqmllocale::addDateTimeFormatData(const QString &l)
+{
+ const char *formats[] = {
+ "hh:mm dd.MM.yyyy",
+ "h:m:sap ddd MMMM d yy",
+ "'The date and time is: 'H:mm:ss:zzz dd/MM/yy",
+ "MMM d yyyy HH:mm t",
+ 0
+ };
+ QByteArray locale = l.toLatin1();
+ int i = 0;
+ while (formats[i]) {
+ QByteArray t(locale);
+ t += " ";
+ t += formats[i];
+ QTest::newRow(t.constData()) << l << QString(formats[i]);
+ ++i;
+ }
+}
+
+void tst_qqmllocale::dateToLocaleStringFormatted_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ addDateTimeFormatData("en_US");
+ addDateTimeFormatData("de_DE");
+ addDateTimeFormatData("ar_SA");
+ addDateTimeFormatData("hi_IN");
+ addDateTimeFormatData("zh_CN");
+ addDateTimeFormatData("th_TH");
+}
+
+void tst_qqmllocale::dateToLocaleStringFormatted()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt, format));
+}
+
+void tst_qqmllocale::dateToLocaleDateString_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateToLocaleDateString()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleDateString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt.date(), format));
+}
+
+void tst_qqmllocale::addDateFormatData(const QString &l)
+{
+ const char *formats[] = {
+ "dd.MM.yyyy",
+ "ddd MMMM d yy",
+ "'The date is: 'dd/MM/yy",
+ "MMM d yyyy",
+ 0
+ };
+ QByteArray locale = l.toLatin1();
+ int i = 0;
+ while (formats[i]) {
+ QByteArray t(locale);
+ t += " ";
+ t += formats[i];
+ QTest::newRow(t.constData()) << l << QString(formats[i]);
+ ++i;
+ }
+}
+
+void tst_qqmllocale::dateToLocaleDateStringFormatted_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ addDateFormatData("en_US");
+ addDateFormatData("de_DE");
+ addDateFormatData("ar_SA");
+ addDateFormatData("hi_IN");
+ addDateFormatData("zh_CN");
+ addDateFormatData("th_TH");
+}
+
+void tst_qqmllocale::dateToLocaleDateStringFormatted()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt.date(), format));
+}
+
+void tst_qqmllocale::dateToLocaleTimeString_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateToLocaleTimeString()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleTimeString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt.time(), format));
+}
+
+void tst_qqmllocale::addTimeFormatData(const QString &l)
+{
+ const char *formats[] = {
+ "hh:mm",
+ "h:m:sap",
+ "'The time is: 'H:mm:ss:zzz",
+ "HH:mm t",
+ 0
+ };
+ QByteArray locale = l.toLatin1();
+ int i = 0;
+ while (formats[i]) {
+ QByteArray t(locale);
+ t += " ";
+ t += formats[i];
+ QTest::newRow(t.constData()) << l << QString(formats[i]);
+ ++i;
+ }
+}
+
+void tst_qqmllocale::dateToLocaleTimeStringFormatted_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ addTimeFormatData("en_US");
+ addTimeFormatData("de_DE");
+ addTimeFormatData("ar_SA");
+ addTimeFormatData("hi_IN");
+ addTimeFormatData("zh_CN");
+ addTimeFormatData("th_TH");
+}
+
+void tst_qqmllocale::dateToLocaleTimeStringFormatted()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt.time(), format));
+}
+
+void tst_qqmllocale::dateFromLocaleString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
+ QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
+ QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
+ QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
+ QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
+ QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
+}
+
+void tst_qqmllocale::dateFromLocaleString()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7));
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(l.toString(dt, format))),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QDateTime pd = l.toDateTime(l.toString(dt, format), format);
+ QCOMPARE(val.toDateTime(), pd);
+}
+
+void tst_qqmllocale::dateFromLocaleDateString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
+ QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
+ QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
+ QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
+ QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
+ QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
+}
+
+void tst_qqmllocale::dateFromLocaleDateString()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7));
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "fromLocaleDateString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(l.toString(dt, format))),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QDate pd = l.toDate(l.toString(dt, format), format);
+ QCOMPARE(val.toDate(), pd);
+}
+
+void tst_qqmllocale::dateFromLocaleTimeString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
+ QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
+ QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
+ QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
+ QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
+ QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
+}
+
+void tst_qqmllocale::dateFromLocaleTimeString()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7));
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "fromLocaleTimeString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(l.toString(dt, format))),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QTime pd = l.toTime(l.toString(dt, format), format);
+ QCOMPARE(val.toTime(), pd);
+}
+
+void tst_qqmllocale::numberToLocaleString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<char>("format");
+ QTest::addColumn<int>("prec");
+
+ QTest::newRow("en_US 1") << "en_US" << 'f' << 2;
+ QTest::newRow("en_US 2") << "en_US" << 'g' << 3;
+ QTest::newRow("en_US 3") << "en_US" << 'f' << 0;
+ QTest::newRow("en_US 4") << "en_US" << 'f' << -1;
+ QTest::newRow("de_DE 1") << "de_DE" << 'f' << 2;
+ QTest::newRow("de_DE 2") << "de_DE" << 'g' << 3;
+ QTest::newRow("ar_SA 1") << "ar_SA" << 'f' << 2;
+ QTest::newRow("ar_SA 2") << "ar_SA" << 'g' << 3;
+}
+
+void tst_qqmllocale::numberToLocaleString()
+{
+ QFETCH(QString, locale);
+ QFETCH(char, format);
+ QFETCH(int, prec);
+
+ QQmlComponent c(&engine, testFileUrl("number.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ double number = 2344423.3289;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(number)),
+ Q_ARG(QVariant, QVariant(QString(format))),
+ Q_ARG(QVariant, QVariant(prec)));
+
+ if (prec < 0) prec = 2;
+ QCOMPARE(val.toString(), l.toString(number, format, prec));
+}
+
+void tst_qqmllocale::numberToLocaleCurrencyString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("symbol");
+
+ QTest::newRow("en_US 1") << "en_US" << QString();
+ QTest::newRow("en_US 2") << "en_US" << "USD";
+ QTest::newRow("de_DE") << "de_DE" << QString();
+ QTest::newRow("ar_SA") << "ar_SA" << QString();
+ QTest::newRow("hi_IN") << "hi_IN" << QString();
+ QTest::newRow("zh_CN") << "zh_CN" << QString();
+ QTest::newRow("th_TH") << "th_TH" << QString();
+}
+
+void tst_qqmllocale::numberToLocaleCurrencyString()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, symbol);
+
+ QQmlComponent c(&engine, testFileUrl("number.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ double number = 2344423.3289;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleCurrencyString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(number)),
+ Q_ARG(QVariant, QVariant(symbol)));
+
+ QCOMPARE(val.toString(), l.toCurrencyString(number, symbol));
+}
+
+void tst_qqmllocale::numberFromLocaleString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<double>("number");
+
+ QTest::newRow("en_US 1") << "en_US" << 1234567.2345;
+ QTest::newRow("en_US 2") << "en_US" << 0.234;
+ QTest::newRow("en_US 3") << "en_US" << 234.0;
+ QTest::newRow("de_DE") << "de_DE" << 1234567.2345;
+ QTest::newRow("ar_SA") << "ar_SA" << 1234567.2345;
+ QTest::newRow("hi_IN") << "hi_IN" << 1234567.2345;
+ QTest::newRow("zh_CN") << "zh_CN" << 1234567.2345;
+ QTest::newRow("th_TH") << "th_TH" << 1234567.2345;
+}
+
+void tst_qqmllocale::numberFromLocaleString()
+{
+ QFETCH(QString, locale);
+ QFETCH(double, number);
+
+ QQmlComponent c(&engine, testFileUrl("number.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QString strNumber = l.toString(number, 'f');
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(strNumber)));
+
+ QCOMPARE(val.toDouble(), l.toDouble(strNumber));
+}
+
+void tst_qqmllocale::numberConstToLocaleString()
+{
+ QQmlComponent c(&engine, testFileUrl("number.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant("en_US")));
+
+ QLocale l("en_US");
+ QCOMPARE(obj->property("const1").toString(), l.toString(1234.56, 'f', 2));
+ QCOMPARE(obj->property("const2").toString(), l.toString(1234., 'f', 2));
+}
+
+void tst_qqmllocale::stringLocaleCompare_data()
+{
+ QTest::addColumn<QString>("string1");
+ QTest::addColumn<QString>("string2");
+
+ QTest::newRow("before") << "a" << "b";
+ QTest::newRow("equal") << "a" << "a";
+ QTest::newRow("after") << "b" << "a";
+
+ // Copied from QString::localeAwareCompare tests
+ // We don't actually change locale - we just care that String.localeCompare()
+ // matches QString::localeAwareCompare();
+ QTest::newRow("swedish1") << QString("\xe5") << QString("\xe4");
+ QTest::newRow("swedish2") << QString("\xe4") << QString("\xf6");
+ QTest::newRow("swedish3") << QString("\xe5") << QString("\xf6");
+ QTest::newRow("swedish4") << QString("z") << QString("\xe5");
+
+ QTest::newRow("german1") << QString("z") << QString("\xe4");
+ QTest::newRow("german2") << QString("\xe4") << QString("\xf6");
+ QTest::newRow("german3") << QString("z") << QString("\xf6");
+}
+
+void tst_qqmllocale::stringLocaleCompare()
+{
+ QFETCH(QString, string1);
+ QFETCH(QString, string2);
+
+ QQmlComponent c(&engine, testFileUrl("localeCompare.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ obj->setProperty("string1", string1);
+ obj->setProperty("string2", string2);
+
+ QCOMPARE(obj->property("comparison").toInt(), QString::localeAwareCompare(string1, string2));
+}
+
+QTEST_MAIN(tst_qqmllocale)
+
+#include "tst_qqmllocale.moc"
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml b/tests/auto/qml/qqmlmetaobject/data/method.1.qml
index a021881743..a021881743 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/method.1.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml b/tests/auto/qml/qqmlmetaobject/data/method.2.qml
index d514955f47..d514955f47 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/method.2.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml b/tests/auto/qml/qqmlmetaobject/data/method.3.qml
index d6d19758c9..d6d19758c9 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/method.3.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml
index 8903bbb3e9..8903bbb3e9 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml
index 20c42b5851..20c42b5851 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml
index cae1ae6696..cae1ae6696 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml
index 86422ae367..86422ae367 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.qml
index 33a4a1c5b0..33a4a1c5b0 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml b/tests/auto/qml/qqmlmetaobject/data/property.bool.qml
index 9459cb6394..9459cb6394 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.bool.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml b/tests/auto/qml/qqmlmetaobject/data/property.color.qml
index 7451a27101..7451a27101 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.color.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml b/tests/auto/qml/qqmlmetaobject/data/property.date.qml
index 05fcb2516c..05fcb2516c 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.date.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml b/tests/auto/qml/qqmlmetaobject/data/property.int.qml
index ae419d08cb..ae419d08cb 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.int.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml
index 602762cba2..602762cba2 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml
index e774d70b42..e774d70b42 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml b/tests/auto/qml/qqmlmetaobject/data/property.real.qml
index de2baf5be2..de2baf5be2 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.real.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml b/tests/auto/qml/qqmlmetaobject/data/property.string.qml
index 2a625c4fe4..2a625c4fe4 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.string.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml b/tests/auto/qml/qqmlmetaobject/data/property.url.qml
index c820c82515..c820c82515 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.url.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml b/tests/auto/qml/qqmlmetaobject/data/property.var.qml
index 9ea9245317..9ea9245317 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.var.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml b/tests/auto/qml/qqmlmetaobject/data/property.variant.qml
index edffa173c4..edffa173c4 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/property.variant.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml b/tests/auto/qml/qqmlmetaobject/data/signal.1.qml
index 113130f3cc..113130f3cc 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.1.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml b/tests/auto/qml/qqmlmetaobject/data/signal.2.qml
index db860cc7cd..db860cc7cd 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.2.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml b/tests/auto/qml/qqmlmetaobject/data/signal.3.qml
index 4d04041f8f..4d04041f8f 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.3.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml b/tests/auto/qml/qqmlmetaobject/data/signal.4.qml
index ad9b002176..ad9b002176 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.4.qml
diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml b/tests/auto/qml/qqmlmetaobject/data/signal.5.qml
index b848bb5cb5..b848bb5cb5 100644
--- a/tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.5.qml
diff --git a/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro b/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro
new file mode 100644
index 0000000000..b87a7cd8bd
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qqmlmetaobject
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlmetaobject.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += qml testlib
diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
new file mode 100644
index 0000000000..6cadc3524b
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
@@ -0,0 +1,364 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+#include "../../shared/util.h"
+
+Q_DECLARE_METATYPE(QMetaMethod::MethodType)
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+};
+QML_DECLARE_TYPE(MyQmlObject)
+
+class tst_QQmlMetaObject : public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+
+ void property_data();
+ void property();
+ void method_data();
+ void method();
+
+private:
+ MyQmlObject myQmlObject;
+};
+
+void tst_QQmlMetaObject::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+
+ qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
+}
+
+void tst_QQmlMetaObject::property_data()
+{
+ QTest::addColumn<QString>("testFile");
+ QTest::addColumn<QByteArray>("cppTypeName");
+ QTest::addColumn<int>("cppType");
+ QTest::addColumn<bool>("isDefault");
+ QTest::addColumn<QVariant>("expectedValue");
+ QTest::addColumn<bool>("isWritable");
+ QTest::addColumn<QVariant>("newValue");
+
+ QTest::newRow("int") << "property.int.qml"
+ << QByteArray("int") << int(QMetaType::Int)
+ << false // default
+ << QVariant(19) << true << QVariant(42);
+ QTest::newRow("bool") << "property.bool.qml"
+ << QByteArray("bool") << int(QMetaType::Bool)
+ << true // default
+ << QVariant(true) << true << QVariant(false);
+ QTest::newRow("real") << "property.real.qml"
+ << QByteArray("double") << int(QMetaType::Double)
+ << false // default
+ << QVariant(double(21))
+ << true // writable
+ << QVariant(double(37));
+ QTest::newRow("string") << "property.string.qml"
+ << QByteArray("QString") << int(QMetaType::QString)
+ << true // default
+ << QVariant(QString::fromLatin1("dog"))
+ << true // writable
+ << QVariant(QString::fromLatin1("food"));
+ QTest::newRow("url") << "property.url.qml"
+ << QByteArray("QUrl") << int(QMetaType::QUrl)
+ << false // default
+ << QVariant(QUrl("http://foo.bar"))
+ << true //writable
+ << QVariant(QUrl("http://bar.baz"));
+ QTest::newRow("color") << "property.color.qml"
+ << QByteArray("QColor") << int(QMetaType::QColor)
+ << true // default
+ << QVariant(QColor("#ff0000"))
+ << true // writable
+ << QVariant(QColor("#00ff00"));
+ QTest::newRow("date") << "property.date.qml"
+ << QByteArray("QDateTime") << int(QMetaType::QDateTime)
+ << false // default
+ << QVariant(QDateTime(QDate(2012, 2, 7)))
+ << true // writable
+ << QVariant(QDateTime(QDate(2010, 7, 2)));
+ QTest::newRow("variant") << "property.variant.qml"
+ << QByteArray("QVariant") << int(QMetaType::QVariant)
+ << true // default
+ << QVariant(QPointF(12, 34))
+ << true // writable
+ << QVariant(QSizeF(45, 67));
+ QTest::newRow("var") << "property.var.qml"
+ << QByteArray("QVariant") << int(QMetaType::QVariant)
+ << false // default
+ << QVariant(QVariantList() << 5 << true << "ciao")
+ << true // writable
+ << QVariant(QVariantList() << 17.0);
+ QTest::newRow("QtObject") << "property.QtObject.qml"
+ << QByteArray("QObject*") << int(QMetaType::QObjectStar)
+ << false // default
+ << QVariant()
+ << true // writable
+ << QVariant::fromValue(static_cast<QObject*>(this));
+ QTest::newRow("list<QtObject>") << "property.list.QtObject.qml"
+ << QByteArray("QQmlListProperty<QObject>")
+ << qMetaTypeId<QQmlListProperty<QObject> >()
+ << false // default
+ << QVariant()
+ << false // writable
+ << QVariant();
+ QTest::newRow("MyQmlObject") << "property.MyQmlObject.qml"
+ << QByteArray("MyQmlObject*") << qMetaTypeId<MyQmlObject*>()
+ << false // default
+ << QVariant()
+ << true // writable
+ << QVariant::fromValue(&myQmlObject);
+ QTest::newRow("list<MyQmlObject>") << "property.list.MyQmlObject.qml"
+ << QByteArray("QQmlListProperty<MyQmlObject>")
+ << qMetaTypeId<QQmlListProperty<MyQmlObject> >()
+ << false // default
+ << QVariant()
+ << false // writable
+ << QVariant();
+ QTest::newRow("alias") << "property.alias.qml"
+ << QByteArray("QString") << int(QMetaType::QString)
+ << false // default
+ << QVariant(QString::fromLatin1("Joe"))
+ << true // writable
+ << QVariant(QString::fromLatin1("Bob"));
+ QTest::newRow("alias-2") << "property.alias.2.qml"
+ << QByteArray("QObject*") << int(QMetaType::QObjectStar)
+ << false // default
+ << QVariant()
+ << false // writable
+ << QVariant();
+ QTest::newRow("alias-3") << "property.alias.3.qml"
+ << QByteArray("QString") << int(QMetaType::QString)
+ << false // default
+ << QVariant(QString::fromLatin1("Arial"))
+ << true // writable
+ << QVariant(QString::fromLatin1("Helvetica"));
+}
+
+void tst_QQmlMetaObject::property()
+{
+ QFETCH(QString, testFile);
+ QFETCH(QByteArray, cppTypeName);
+ QFETCH(int, cppType);
+ QFETCH(bool, isDefault);
+ QFETCH(QVariant, expectedValue);
+ QFETCH(bool, isWritable);
+ QFETCH(QVariant, newValue);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl(testFile));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ const QMetaObject *mo = object->metaObject();
+ QVERIFY(mo->superClass() != 0);
+ QVERIFY(QByteArray(mo->className()).contains("_QML_"));
+ QCOMPARE(mo->propertyOffset(), mo->superClass()->propertyCount());
+ QCOMPARE(mo->propertyCount(), mo->superClass()->propertyCount() + 1);
+
+ QMetaProperty prop = mo->property(mo->propertyOffset());
+ QCOMPARE(prop.name(), "test");
+
+ QCOMPARE(QByteArray(prop.typeName()), cppTypeName);
+ QEXPECT_FAIL("QtObject", "prop.type() returns UserType for QtObject properties", Continue);
+ QEXPECT_FAIL("alias-2", "prop.type() returns UserType for QtObject properties", Continue);
+ if (prop.userType() < QMetaType::User)
+ QCOMPARE(prop.type(), QVariant::Type(cppType));
+ QCOMPARE(prop.userType(), cppType);
+
+ QVERIFY(!prop.isConstant());
+ QVERIFY(!prop.isDesignable());
+ QVERIFY(!prop.isEnumType());
+ QVERIFY(!prop.isFinal());
+ QVERIFY(!prop.isFlagType());
+ QVERIFY(prop.isReadable());
+ QVERIFY(!prop.isResettable());
+ QVERIFY(prop.isScriptable());
+ QVERIFY(!prop.isStored());
+ QVERIFY(!prop.isUser());
+ QVERIFY(prop.isValid());
+ QCOMPARE(prop.isWritable(), isWritable);
+
+ QCOMPARE(mo->classInfoOffset(), mo->superClass()->classInfoCount());
+ QCOMPARE(mo->classInfoCount(), mo->superClass()->classInfoCount() + (isDefault ? 1 : 0));
+ if (isDefault) {
+ QMetaClassInfo info = mo->classInfo(mo->classInfoOffset());
+ QCOMPARE(info.name(), "DefaultProperty");
+ QCOMPARE(info.value(), "test");
+ }
+
+ QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount());
+ QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); // the signal
+
+ QVERIFY(prop.notifySignalIndex() != -1);
+ QMetaMethod signal = prop.notifySignal();
+ QCOMPARE(signal.methodType(), QMetaMethod::Signal);
+ QCOMPARE(signal.signature(), "testChanged()");
+ QCOMPARE(signal.access(), QMetaMethod::Protected);
+ QCOMPARE(signal.parameterTypes(), QList<QByteArray>());
+ QCOMPARE(signal.parameterNames(), QList<QByteArray>());
+ QCOMPARE(signal.tag(), "");
+ QCOMPARE(signal.typeName(), "");
+
+ QSignalSpy changedSpy(object, SIGNAL(testChanged()));
+ QObject::connect(object, SIGNAL(testChanged()), object, SLOT(deleteLater()));
+
+ if (expectedValue.isValid())
+ QCOMPARE(prop.read(object), expectedValue);
+ else
+ QVERIFY(prop.read(object).isValid());
+ QCOMPARE(changedSpy.count(), 0);
+
+ if (isWritable) {
+ QVERIFY(prop.write(object, newValue));
+ QCOMPARE(changedSpy.count(), 1);
+ QCOMPARE(prop.read(object), newValue);
+ } else {
+ QVERIFY(!prop.write(object, prop.read(object)));
+ QCOMPARE(changedSpy.count(), 0);
+ }
+
+ delete object;
+}
+
+void tst_QQmlMetaObject::method_data()
+{
+ QTest::addColumn<QString>("testFile");
+ QTest::addColumn<QString>("signature");
+ QTest::addColumn<QMetaMethod::MethodType>("methodType");
+ QTest::addColumn<QString>("returnTypeName");
+ QTest::addColumn<QList<QByteArray> >("parameterTypeNames");
+ QTest::addColumn<QList<QByteArray> >("parameterNames");
+
+ QTest::newRow("testFunction()") << "method.1.qml"
+ << "testFunction()"
+ << QMetaMethod::Slot
+ << "QVariant"
+ << QList<QByteArray>()
+ << QList<QByteArray>();
+ QTest::newRow("testFunction(foo)") << "method.2.qml"
+ << "testFunction(QVariant)"
+ << QMetaMethod::Slot
+ << "QVariant"
+ << (QList<QByteArray>() << "QVariant")
+ << (QList<QByteArray>() << "foo");
+ QTest::newRow("testFunction(foo, bar, baz)") << "method.3.qml"
+ << "testFunction(QVariant,QVariant,QVariant)"
+ << QMetaMethod::Slot
+ << "QVariant"
+ << (QList<QByteArray>() << "QVariant" << "QVariant" << "QVariant")
+ << (QList<QByteArray>() << "foo" << "bar" << "baz");
+ QTest::newRow("testSignal") << "signal.1.qml"
+ << "testSignal()"
+ << QMetaMethod::Signal
+ << ""
+ << QList<QByteArray>()
+ << QList<QByteArray>();
+ QTest::newRow("testSignal(string foo)") << "signal.2.qml"
+ << "testSignal(QString)"
+ << QMetaMethod::Signal
+ << ""
+ << (QList<QByteArray>() << "QString")
+ << (QList<QByteArray>() << "foo");
+ QTest::newRow("testSignal(int foo, bool bar, real baz)") << "signal.3.qml"
+ << "testSignal(int,bool,qreal)"
+ << QMetaMethod::Signal
+ << ""
+ << (QList<QByteArray>() << "int" << "bool" << "qreal")
+ << (QList<QByteArray>() << "foo" << "bar" << "baz");
+ QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml"
+ << "testSignal(QVariant,QVariant)"
+ << QMetaMethod::Signal
+ << ""
+ << (QList<QByteArray>() << "QVariant" << "QVariant")
+ << (QList<QByteArray>() << "foo" << "bar");
+ QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml"
+ << "testSignal(QColor,QDateTime,QUrl)"
+ << QMetaMethod::Signal
+ << ""
+ << (QList<QByteArray>() << "QColor" << "QDateTime" << "QUrl")
+ << (QList<QByteArray>() << "foo" << "bar" << "baz");
+}
+
+void tst_QQmlMetaObject::method()
+{
+ QFETCH(QString, testFile);
+ QFETCH(QString, signature);
+ QFETCH(QMetaMethod::MethodType, methodType);
+ QFETCH(QString, returnTypeName);
+ QFETCH(QList<QByteArray>, parameterTypeNames);
+ QFETCH(QList<QByteArray>, parameterNames);
+
+ QCOMPARE(parameterTypeNames.size(), parameterNames.size());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl(testFile));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ const QMetaObject *mo = object->metaObject();
+ QVERIFY(mo->superClass() != 0);
+ QVERIFY(QByteArray(mo->className()).contains("_QML_"));
+ QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount());
+ QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1);
+
+ QMetaMethod method = mo->method(mo->methodOffset());
+ QCOMPARE(method.methodType(), methodType);
+ QCOMPARE(QString::fromUtf8(method.signature()), signature);
+ QCOMPARE(method.access(), QMetaMethod::Protected);
+ QCOMPARE(method.parameterTypes(), parameterTypeNames);
+ QCOMPARE(method.parameterNames(), parameterNames);
+ QCOMPARE(method.tag(), "");
+ QCOMPARE(QString::fromUtf8(method.typeName()), returnTypeName);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_QQmlMetaObject)
+
+#include "tst_qqmlmetaobject.moc"
diff --git a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
new file mode 100644
index 0000000000..7c781dd9db
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qqmlmetatype
+SOURCES += tst_qqmlmetatype.cpp
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private widgets testlib
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
new file mode 100644
index 0000000000..6e577ec095
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <qqml.h>
+
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmlpropertyvalueinterceptor_p.h>
+
+class tst_qqmlmetatype : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlmetatype() {}
+
+private slots:
+ void initTestCase();
+
+ void qmlParserStatusCast();
+ void qmlPropertyValueSourceCast();
+ void qmlPropertyValueInterceptorCast();
+
+ void isList();
+
+ void defaultObject();
+};
+
+class TestType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo)
+
+ Q_CLASSINFO("DefaultProperty", "foo")
+public:
+ int foo() { return 0; }
+};
+QML_DECLARE_TYPE(TestType);
+
+class ParserStatusTestType : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ void classBegin(){}
+ void componentComplete(){}
+ Q_CLASSINFO("DefaultProperty", "foo") // Missing default property
+ Q_INTERFACES(QQmlParserStatus)
+};
+QML_DECLARE_TYPE(ParserStatusTestType);
+
+class ValueSourceTestType : public QObject, public QQmlPropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueSource)
+public:
+ virtual void setTarget(const QQmlProperty &) {}
+};
+QML_DECLARE_TYPE(ValueSourceTestType);
+
+class ValueInterceptorTestType : public QObject, public QQmlPropertyValueInterceptor
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueInterceptor)
+public:
+ virtual void setTarget(const QQmlProperty &) {}
+ virtual void write(const QVariant &) {}
+};
+QML_DECLARE_TYPE(ValueInterceptorTestType);
+
+void tst_qqmlmetatype::initTestCase()
+{
+ qmlRegisterType<TestType>("Test", 1, 0, "TestType");
+ qmlRegisterType<ParserStatusTestType>("Test", 1, 0, "ParserStatusTestType");
+ qmlRegisterType<ValueSourceTestType>("Test", 1, 0, "ValueSourceTestType");
+ qmlRegisterType<ValueInterceptorTestType>("Test", 1, 0, "ValueInterceptorTestType");
+}
+
+void tst_qqmlmetatype::qmlParserStatusCast()
+{
+ QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->parserStatusCast(), -1);
+
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ int cast = QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->parserStatusCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ParserStatusTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QQmlParserStatus *)&t));
+
+ QQmlParserStatus *status = reinterpret_cast<QQmlParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(status, (QQmlParserStatus*)&t);
+}
+
+void tst_qqmlmetatype::qmlPropertyValueSourceCast()
+{
+ QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueSourceCast(), -1);
+
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
+ int cast = QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->propertyValueSourceCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ValueSourceTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QQmlPropertyValueSource *)&t));
+
+ QQmlPropertyValueSource *source = reinterpret_cast<QQmlPropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(source, (QQmlPropertyValueSource*)&t);
+}
+
+void tst_qqmlmetatype::qmlPropertyValueInterceptorCast()
+{
+ QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueInterceptorCast(), -1);
+
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>()) != 0);
+ int cast = QQmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>())->propertyValueInterceptorCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ValueInterceptorTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QQmlPropertyValueInterceptor *)&t));
+
+ QQmlPropertyValueInterceptor *interceptor = reinterpret_cast<QQmlPropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(interceptor, (QQmlPropertyValueInterceptor*)&t);
+}
+
+void tst_qqmlmetatype::isList()
+{
+ QCOMPARE(QQmlMetaType::isList(QVariant::Invalid), false);
+ QCOMPARE(QQmlMetaType::isList(QVariant::Int), false);
+
+ QQmlListProperty<TestType> list;
+
+ QCOMPARE(QQmlMetaType::isList(qMetaTypeId<QQmlListProperty<TestType> >()), true);
+}
+
+void tst_qqmlmetatype::defaultObject()
+{
+ QVERIFY(QQmlMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0);
+ QVERIFY(QQmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0);
+ QCOMPARE(QString(QQmlMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo"));
+
+ QObject o;
+ TestType t;
+ ParserStatusTestType p;
+
+ QVERIFY(QQmlMetaType::defaultProperty((QObject *)0).name() == 0);
+ QVERIFY(QQmlMetaType::defaultProperty(&o).name() == 0);
+ QVERIFY(QQmlMetaType::defaultProperty(&p).name() == 0);
+ QCOMPARE(QString(QQmlMetaType::defaultProperty(&t).name()), QString("foo"));
+}
+
+QTEST_MAIN(tst_qqmlmetatype)
+
+#include "tst_qqmlmetatype.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/implicitQmldir.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt
index ce3b796e16..ce3b796e16 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/implicitQmldir.errors.txt
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/qmldir b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir
index 7f5b3a362d..7f5b3a362d 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml
index 67fb18feb0..67fb18feb0 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml
index ea9611691e..ea9611691e 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/implicitQmldir.2.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt
index 9cafb78740..9cafb78740 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/implicitQmldir.2.errors.txt
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/qmldir b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir
index 7c4def92fc..7c4def92fc 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml
index 0fa9f6e051..0fa9f6e051 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml
index a0ac0c72c7..a0ac0c72c7 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml
index 1346cbdb7b..1346cbdb7b 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml b/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml
index a21ece7058..a21ece7058 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/pluginWithQmlFile.qml b/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml
index a9e28e5d8b..a9e28e5d8b 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/pluginWithQmlFile.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt
index a40c1c8211..a40c1c8211 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt
+++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml
index bda59f0a32..bda59f0a32 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt
index 2634223de7..2634223de7 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt
+++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml
index 2e556e76d6..2e556e76d6 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/works.qml b/tests/auto/qml/qqmlmoduleplugin/data/works.qml
index f29ae24ea2..f29ae24ea2 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/works.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/works.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/works2.qml b/tests/auto/qml/qqmlmoduleplugin/data/works2.qml
index cc322bf26b..cc322bf26b 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/works2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/works2.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/works21.qml b/tests/auto/qml/qqmlmoduleplugin/data/works21.qml
index c08160ac5a..c08160ac5a 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/works21.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/works21.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/empty.json b/tests/auto/qml/qqmlmoduleplugin/empty.json
index 0967ef424b..0967ef424b 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/empty.json
+++ b/tests/auto/qml/qqmlmoduleplugin/empty.json
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml
index 617bdaaf67..617bdaaf67 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir
index 858ba1450e..858ba1450e 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml
index 36d69e901f..36d69e901f 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir
index 065dc3b21f..065dc3b21f 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir
index 0a8b5d46eb..0a8b5d46eb 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir
index 0a8b5d46eb..0a8b5d46eb 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir
index 0a8b5d46eb..0a8b5d46eb 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir
index 640967fe40..640967fe40 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml
index 617bdaaf67..617bdaaf67 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml
index fac5d8f4b9..fac5d8f4b9 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir
index 167bb10c21..167bb10c21 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir
index 6c8787498f..6c8787498f 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro
new file mode 100644
index 0000000000..ccb66abe0e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2.1
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp
new file mode 100644
index 0000000000..03065b2f27
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import2.1 worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
+public:
+ MyPlugin()
+ {
+ qWarning("plugin2.1 created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
+ qmlRegisterType<MyPluginType>(uri, 2, 1, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro
new file mode 100644
index 0000000000..7f3904f695
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp
new file mode 100644
index 0000000000..e2ff43dffe
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import2 worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
+public:
+ MyPlugin()
+ {
+ qWarning("plugin2 created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
+ qmlRegisterType<MyPluginType>(uri, 2, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp
new file mode 100644
index 0000000000..5a91852d22
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
+public:
+ MyPlugin()
+ {
+ qWarning("plugin created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
+ qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro
new file mode 100644
index 0000000000..dae8696cc8
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp
new file mode 100644
index 0000000000..66c59fde81
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class BarPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value)
+
+public:
+ int value() const { return 16; }
+};
+
+
+class MyMixedPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
+public:
+ MyMixedPlugin()
+ {
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlMixedPluginType");
+ qmlRegisterType<BarPluginType>(uri, 1, 0, "Bar");
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro
new file mode 100644
index 0000000000..c0f314ab5e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlMixedPluginType
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp
new file mode 100644
index 0000000000..a3142ef9b3
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class FloorPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value);
+
+public:
+ int value() const { return 16; }
+};
+
+
+class MyMixedPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
+public:
+ MyMixedPlugin()
+ {
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlVersionPluginType");
+ qmlRegisterType<FloorPluginType>(uri, 1, 4, "Floor");
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro
new file mode 100644
index 0000000000..ba9e4846ea
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlVersionPluginType
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp
new file mode 100644
index 0000000000..a2262f15d6
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
+public:
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestPluginWithQmlFile");
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro
new file mode 100644
index 0000000000..15fe8d2f3e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestPluginWithQmlFile
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp
new file mode 100644
index 0000000000..a5fc6c1d37
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
+public:
+ MyPlugin()
+ {
+ qWarning("plugin created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.WrongCase");
+ qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro
new file mode 100644
index 0000000000..d604613300
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro
@@ -0,0 +1,8 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+TARGET = Plugin
+DESTDIR = ../imports/com/nokia/WrongCase
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
new file mode 100644
index 0000000000..42eedc20f2
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
@@ -0,0 +1,9 @@
+QT = core
+TEMPLATE = subdirs
+SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion
+tst_qqmlmoduleplugin_pro.depends += plugin
+SUBDIRS += tst_qqmlmoduleplugin.pro
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
new file mode 100644
index 0000000000..b574bad595
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -0,0 +1,353 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <qdir.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QDebug>
+
+#include "../../shared/testhttpserver.h"
+#include "../../shared/util.h"
+
+#define SERVER_ADDR "http://127.0.0.1:14450"
+#define SERVER_PORT 14450
+
+
+class tst_qqmlmoduleplugin : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ virtual void initTestCase();
+ void importsPlugin();
+ void importsPlugin2();
+ void importsPlugin21();
+ void importsMixedQmlCppPlugin();
+ void incorrectPluginCase();
+ void importPluginWithQmlFile();
+ void remoteImportWithQuotedUrl();
+ void remoteImportWithUnquotedUri();
+ void versionNotInstalled();
+ void versionNotInstalled_data();
+ void implicitQmldir();
+ void implicitQmldir_data();
+
+private:
+ QString m_importsDirectory;
+};
+
+void tst_qqmlmoduleplugin::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ m_importsDirectory = directory() + QStringLiteral("/imports");
+ QVERIFY2(QFileInfo(m_importsDirectory).isDir(),
+ qPrintable(QString::fromLatin1("Imports directory '%1' does not exist.").arg(m_importsDirectory)));
+}
+
+#define VERIFY_ERRORS(errorfile) \
+ if (!errorfile) { \
+ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
+ qWarning() << "Unexpected Errors:" << component.errors(); \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ QString verify_errors_file_name = testFile(errorfile); \
+ QFile file(verify_errors_file_name); \
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
+ QByteArray data = file.readAll(); \
+ file.close(); \
+ QList<QByteArray> expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QQmlError> errors = component.errors(); \
+ QList<QByteArray> actual; \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QQmlError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ if (qgetenv("DEBUG") != "" && expected != actual) { \
+ qWarning() << "Expected:" << expected << "Actual:" << actual; \
+ } \
+ if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
+ QFile file(testFile(errorfile)); \
+ QVERIFY(file.open(QIODevice::WriteOnly)); \
+ for (int ii = 0; ii < actual.count(); ++ii) { \
+ file.write(actual.at(ii)); file.write("\n"); \
+ } \
+ file.close(); \
+ } else { \
+ QCOMPARE(expected, actual); \
+ } \
+ }
+
+void tst_qqmlmoduleplugin::importsPlugin()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "plugin created");
+ QTest::ignoreMessage(QtWarningMsg, "import worked");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::importsPlugin2()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "plugin2 created");
+ QTest::ignoreMessage(QtWarningMsg, "import2 worked");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::importsPlugin21()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created");
+ QTest::ignoreMessage(QtWarningMsg, "import2.1 worked");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::incorrectPluginCase()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("incorrectCase.qml")));
+
+ QList<QQmlError> errors = component.errors();
+ QCOMPARE(errors.count(), 1);
+
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
+#if defined(Q_OS_MAC)
+ QString libname = "libPluGin.dylib";
+#elif defined(Q_OS_WIN32)
+ QString libname = "PluGin.dll";
+#endif
+ QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("com/nokia/WrongCase/" + libname) + QLatin1String("\"");
+#else
+ QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found");
+#endif
+
+ QCOMPARE(errors.at(0).description(), expectedError);
+}
+
+void tst_qqmlmoduleplugin::importPluginWithQmlFile()
+{
+ QString path = m_importsDirectory;
+
+ // QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure
+ // (this only happens if the plugin includes pure QML files)
+ #ifdef Q_OS_WIN
+ QVERIFY(path.at(0).isUpper() && path.at(1) == QLatin1Char(':'));
+ path = path.at(0).toLower() + path.mid(1);
+ #endif
+
+ QQmlEngine engine;
+ engine.addImportPath(path);
+
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(m_importsDirectory);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import \"http://127.0.0.1:14450/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl());
+
+ QTRY_COMPARE(component.status(), QQmlComponent::Ready);
+ QObject *object = component.create();
+ QCOMPARE(object->property("width").toInt(), 300);
+ QVERIFY(object != 0);
+ delete object;
+
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+}
+
+void tst_qqmlmoduleplugin::remoteImportWithUnquotedUri()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(m_importsDirectory);
+
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QQmlComponent component(&engine);
+ component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl());
+
+
+ QTRY_COMPARE(component.status(), QQmlComponent::Ready);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("width").toInt(), 300);
+ delete object;
+
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+}
+
+// QTBUG-17324
+
+void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+
+ {
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml")));
+
+ QObject *o = component.create();
+ QVERIFY2(o != 0, QQmlDataTest::msgComponentError(component, &engine));
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.2.qml")));
+
+ QObject *o = component.create();
+ QVERIFY2(o != 0, QQmlDataTest::msgComponentError(component, &engine));
+ QCOMPARE(o->property("test").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ delete o;
+ }
+
+
+}
+
+void tst_qqmlmoduleplugin::versionNotInstalled_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+
+ QTest::newRow("versionNotInstalled") << "versionNotInstalled.qml" << "versionNotInstalled.errors.txt";
+ QTest::newRow("versionNotInstalled") << "versionNotInstalled.2.qml" << "versionNotInstalled.2.errors.txt";
+}
+
+void tst_qqmlmoduleplugin::versionNotInstalled()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+
+ QQmlComponent component(&engine, testFileUrl(file));
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
+}
+
+
+// test that errors are reporting correctly for plugin loading and qmldir parsing
+void tst_qqmlmoduleplugin::implicitQmldir_data()
+{
+ QTest::addColumn<QString>("directory");
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+
+ // parsing qmldir succeeds, but plugin specified in the qmldir file doesn't exist
+ QTest::newRow("implicitQmldir") << "implicit1" << "temptest.qml" << "implicitQmldir.errors.txt";
+
+ // parsing qmldir fails due to syntax errors, etc.
+ QTest::newRow("implicitQmldir2") << "implicit2" << "temptest2.qml" << "implicitQmldir.2.errors.txt";
+}
+void tst_qqmlmoduleplugin::implicitQmldir()
+{
+ QFETCH(QString, directory);
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+
+ QString importPath = testFile(directory);
+ QString fileName = directory + QDir::separator() + file;
+ QString errorFileName = directory + QDir::separator() + errorFile;
+ QUrl testUrl = testFileUrl(fileName);
+
+ QQmlEngine engine;
+ engine.addImportPath(importPath);
+
+ QQmlComponent component(&engine, testUrl);
+ QList<QQmlError> errors = component.errors();
+ VERIFY_ERRORS(errorFileName.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QObject *obj = component.create();
+ QVERIFY(!obj);
+ delete obj;
+}
+
+
+QTEST_MAIN(tst_qqmlmoduleplugin)
+
+#include "tst_qqmlmoduleplugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro
new file mode 100644
index 0000000000..3d5fe7d6ae
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro
@@ -0,0 +1,19 @@
+CONFIG += testcase
+TARGET = tst_qqmlmoduleplugin
+
+HEADERS = ../../shared/testhttpserver.h
+SOURCES = tst_qqmlmoduleplugin.cpp \
+ ../../shared/testhttpserver.cpp
+CONFIG -= app_bundle
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+testImportFiles.files = imports
+testImportFiles.path = .
+DEPLOYMENT += testImportFiles
+
+QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/qqmlparser/qqmlparser.pro b/tests/auto/qml/qqmlparser/qqmlparser.pro
new file mode 100644
index 0000000000..e1b7b39402
--- /dev/null
+++ b/tests/auto/qml/qqmlparser/qqmlparser.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlparser
+QT += qmldevtools-private testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlparser.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
new file mode 100644
index 0000000000..5fb5b71533
--- /dev/null
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qqmljsengine_p.h>
+#include <private/qqmljsparser_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsastvisitor_p.h>
+#include <private/qqmljsast_p.h>
+
+#include <qtest.h>
+#include <QDir>
+#include <QDebug>
+#include <cstdlib>
+
+class tst_qqmlparser : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlparser();
+
+private slots:
+ void initTestCase();
+ void qmlParser_data();
+ void qmlParser();
+
+private:
+ QStringList excludedDirs;
+
+ QStringList findFiles(const QDir &);
+};
+
+namespace check {
+
+using namespace QQmlJS;
+
+class Check: public AST::Visitor
+{
+ Engine *engine;
+ QList<AST::Node *> nodeStack;
+
+public:
+ Check(Engine *engine)
+ : engine(engine)
+ {
+ }
+
+ void operator()(AST::Node *node)
+ {
+ AST::Node::accept(node, this);
+ }
+
+ void checkNode(AST::Node *node)
+ {
+ if (! nodeStack.isEmpty()) {
+ AST::Node *parent = nodeStack.last();
+ const quint32 parentBegin = parent->firstSourceLocation().begin();
+ const quint32 parentEnd = parent->lastSourceLocation().end();
+
+ QVERIFY(node->firstSourceLocation().begin() >= parentBegin);
+ QVERIFY(node->lastSourceLocation().end() <= parentEnd);
+ }
+ }
+
+ virtual bool preVisit(AST::Node *node)
+ {
+ checkNode(node);
+ nodeStack.append(node);
+ return true;
+ }
+
+ virtual void postVisit(AST::Node *)
+ {
+ nodeStack.removeLast();
+ }
+};
+
+}
+
+tst_qqmlparser::tst_qqmlparser()
+{
+}
+
+void tst_qqmlparser::initTestCase()
+{
+ // Add directories you want excluded here
+
+ // These snippets are not expected to run on their own.
+ excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qml/qtbinding";
+ excludedDirs << "doc/src/snippets/qml/imports";
+ excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
+ excludedDirs << "doc/src/snippets/qtquick1/imports";
+}
+
+QStringList tst_qqmlparser::findFiles(const QDir &d)
+{
+ for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ QString s = excludedDirs.at(ii);
+ if (d.absolutePath().endsWith(s))
+ return QStringList();
+ }
+
+ QStringList rv;
+
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ rv << d.absoluteFilePath(file);
+ }
+
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ rv << findFiles(sub);
+ }
+
+ return rv;
+}
+
+/*
+This test checks all the qml and js files in the QtQml UI source tree
+and ensures that the subnode's source locations are inside parent node's source locations
+*/
+
+void tst_qqmlparser::qmlParser_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
+ QString tests = QLatin1String(SRCDIR) + "/../../../../tests/";
+
+ QStringList files;
+ files << findFiles(QDir(examples));
+ files << findFiles(QDir(tests));
+
+ foreach (const QString &file, files)
+ QTest::newRow(qPrintable(file)) << file;
+}
+
+void tst_qqmlparser::qmlParser()
+{
+ QFETCH(QString, file);
+
+ using namespace QQmlJS;
+
+ QString code;
+
+ QFile f(file);
+ if (f.open(QFile::ReadOnly))
+ code = QString::fromUtf8(f.readAll());
+
+ const bool qmlMode = file.endsWith(QLatin1String(".qml"));
+
+ Engine engine;
+ Lexer lexer(&engine);
+ lexer.setCode(code, 1, qmlMode);
+ Parser parser(&engine);
+ if (qmlMode)
+ parser.parse();
+ else
+ parser.parseProgram();
+
+ check::Check chk(&engine);
+ chk(parser.rootNode());
+}
+
+QTEST_MAIN(tst_qqmlparser)
+
+#include "tst_qqmlparser.moc"
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/data/dataLeak.qml b/tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml
index 724ce5d816..724ce5d816 100644
--- a/tests/auto/declarative/qdeclarativepixmapcache/data/dataLeak.qml
+++ b/tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml b/tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml
index f58967cbb2..f58967cbb2 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml
+++ b/tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml b/tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml
index 4b3672873d..4b3672873d 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml
+++ b/tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml b/tests/auto/qml/qqmlproperty/data/TestType.qml
index 1fe150548a..1fe150548a 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml
+++ b/tests/auto/qml/qqmlproperty/data/TestType.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml b/tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml
index f101f38a2d..f101f38a2d 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml
+++ b/tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/assignEmptyVariantMap.qml b/tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml
index a9e51c1255..a9e51c1255 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/assignEmptyVariantMap.qml
+++ b/tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml b/tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml
index 55010b69a9..55010b69a9 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml
+++ b/tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml
diff --git a/tests/auto/qml/qqmlproperty/qqmlproperty.pro b/tests/auto/qml/qqmlproperty/qqmlproperty.pro
new file mode 100644
index 0000000000..689db4d7cf
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/qqmlproperty.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlproperty
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlproperty.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private widgets testlib
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
new file mode 100644
index 0000000000..ae300900c9
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -0,0 +1,1721 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlproperty.h>
+#include <QtQml/private/qqmlproperty_p.h>
+#include <private/qqmlbinding_p.h>
+#include <QtWidgets/QLineEdit>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+#include "../../shared/util.h"
+
+#include <QDebug>
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+public:
+ MyQmlObject() {}
+};
+
+QML_DECLARE_TYPE(MyQmlObject);
+
+class MyAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo WRITE setFoo)
+public:
+ MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
+
+ int foo() const { return m_foo; }
+ void setFoo(int f) { m_foo = f; }
+
+private:
+ int m_foo;
+};
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<MyQmlObject> children READ children)
+public:
+ MyContainer() {}
+
+ QQmlListProperty<MyQmlObject> children() { return QQmlListProperty<MyQmlObject>(this, m_children); }
+
+ static MyAttached *qmlAttachedProperties(QObject *o) {
+ return new MyAttached(o);
+ }
+
+private:
+ QList<MyQmlObject*> m_children;
+};
+
+QML_DECLARE_TYPE(MyContainer);
+QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES)
+
+class tst_qqmlproperty : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlproperty() {}
+
+private slots:
+ void initTestCase();
+
+ // Constructors
+ void qmlmetaproperty();
+ void qmlmetaproperty_object();
+ void qmlmetaproperty_object_string();
+ void qmlmetaproperty_object_context();
+ void qmlmetaproperty_object_string_context();
+
+ // Methods
+ void name();
+ void read();
+ void write();
+ void reset();
+
+ // Functionality
+ void writeObjectToList();
+ void writeListToList();
+
+ //writeToReadOnly();
+
+ void urlHandling_data();
+ void urlHandling();
+
+ void variantMapHandling_data();
+ void variantMapHandling();
+
+ // Bugs
+ void crashOnValueProperty();
+ void aliasPropertyBindings();
+ void noContext();
+ void assignEmptyVariantMap();
+
+ void copy();
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlproperty::qmlmetaproperty()
+{
+ QQmlProperty prop;
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+}
+
+class PropertyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int defaultProperty READ defaultProperty)
+ Q_PROPERTY(QRect rectProperty READ rectProperty)
+ Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty)
+ Q_PROPERTY(QUrl url READ url WRITE setUrl)
+ Q_PROPERTY(QVariantMap variantMap READ variantMap WRITE setVariantMap)
+ Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+ Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject)
+
+ Q_CLASSINFO("DefaultProperty", "defaultProperty")
+public:
+ PropertyObject() : m_resetProperty(9) {}
+
+ int defaultProperty() { return 10; }
+ QRect rectProperty() { return QRect(10, 10, 1, 209); }
+
+ QRect wrectProperty() { return m_rect; }
+ void setWRectProperty(const QRect &r) { m_rect = r; }
+
+ QUrl url() { return m_url; }
+ void setUrl(const QUrl &u) { m_url = u; }
+
+ QVariantMap variantMap() const { return m_variantMap; }
+ void setVariantMap(const QVariantMap &variantMap) { m_variantMap = variantMap; }
+
+ int resettableProperty() const { return m_resetProperty; }
+ void setResettableProperty(int r) { m_resetProperty = r; }
+ void resetProperty() { m_resetProperty = 9; }
+
+ int propertyWithNotify() const { return m_propertyWithNotify; }
+ void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
+
+ MyQmlObject *qmlObject() { return &m_qmlObject; }
+
+signals:
+ void clicked();
+ void oddlyNamedNotifySignal();
+
+private:
+ int m_resetProperty;
+ QRect m_rect;
+ QUrl m_url;
+ QVariantMap m_variantMap;
+ int m_propertyWithNotify;
+ MyQmlObject m_qmlObject;
+};
+
+QML_DECLARE_TYPE(PropertyObject);
+
+void tst_qqmlproperty::qmlmetaproperty_object()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QQmlProperty prop(&object);
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject);
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data());
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qqmlproperty::qmlmetaproperty_object_string()
+{
+ QObject object;
+ PropertyObject dobject;
+
+ {
+ QQmlProperty prop(&object, QString("defaultProperty"));
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("defaultProperty"));
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data());
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("onClicked"));
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onClicked"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data());
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"));
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
+ QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data());
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qqmlproperty::qmlmetaproperty_object_context()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QQmlProperty prop(&object, engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data());
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qqmlproperty::qmlmetaproperty_object_string_context()
+{
+ QObject object;
+ PropertyObject dobject;
+
+ {
+ QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data());
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onClicked"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data());
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
+ QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data());
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qqmlproperty::name()
+{
+ {
+ QQmlProperty p;
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.name(), QString("defaultProperty"));
+ }
+
+ {
+ QObject o;
+ QQmlProperty p(&o, QString("objectName"));
+ QCOMPARE(p.name(), QString("objectName"));
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onClicked");
+ QCOMPARE(p.name(), QString("onClicked"));
+ }
+
+ {
+ QObject o;
+ QQmlProperty p(&o, "onClicked");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.name(), QString("onOddlyNamedNotifySignal"));
+ }
+
+ {
+ QObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ QObject o;
+ QQmlProperty p(&o, "foo");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ QQmlProperty p(0, "foo");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty");
+ QCOMPARE(p.name(), QString("rectProperty"));
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty.x");
+ QCOMPARE(p.name(), QString("rectProperty.x"));
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty.foo");
+ QCOMPARE(p.name(), QString());
+ }
+}
+
+void tst_qqmlproperty::read()
+{
+ // Invalid
+ {
+ QQmlProperty p;
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Default prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.read(), QVariant(10));
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Value prop by name
+ {
+ QObject o;
+
+ QQmlProperty p(&o, "objectName");
+ QCOMPARE(p.read(), QVariant(QString()));
+
+ o.setObjectName("myName");
+
+ QCOMPARE(p.read(), QVariant("myName"));
+ }
+
+ // Value prop by name (static)
+ {
+ QObject o;
+
+ QCOMPARE(QQmlProperty::read(&o, "objectName"), QVariant(QString()));
+
+ o.setObjectName("myName");
+
+ QCOMPARE(QQmlProperty::read(&o, "objectName"), QVariant("myName"));
+ }
+
+ // Value-type prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(10));
+ }
+
+ // Invalid value-type prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty.foo");
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onClicked");
+ QCOMPARE(p.read(), QVariant());
+
+ QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression()));
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.read(), QVariant());
+
+ QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression()));
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+ QQmlProperty p(o, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(10));
+ delete o;
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Object property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "qmlObject");
+ QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object);
+ QCOMPARE(p.propertyType(), qMetaTypeId<MyQmlObject*>());
+ QVariant v = p.read();
+ QVERIFY(v.userType() == QMetaType::QObjectStar);
+ QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject());
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "test", &engine);
+
+ QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object);
+ QVERIFY(p.propertyType() != QMetaType::QObjectStar);
+
+ QVariant v = p.read();
+ QVERIFY(v.userType() == QMetaType::QObjectStar);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
+ }
+ { // static
+ QQmlComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVariant v = QQmlProperty::read(object, "test", &engine);
+ QVERIFY(v.userType() == QMetaType::QObjectStar);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
+ }
+
+ // Attached property
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(13));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(10));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(10));
+ delete object;
+ }
+ { // static
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(QQmlProperty::read(object, "Foo.MyContainer.foo", qmlContext(object)), QVariant(10));
+ delete object;
+ }
+}
+
+void tst_qqmlproperty::write()
+{
+ // Invalid
+ {
+ QQmlProperty p;
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Read-only default prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Read-only prop by name
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, QString("defaultProperty"));
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Writable prop by name
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, QString("objectName"));
+ QCOMPARE(o.objectName(), QString());
+ QCOMPARE(p.write(QVariant(QString("myName"))), true);
+ QCOMPARE(o.objectName(), QString("myName"));
+ }
+
+ // Writable prop by name (static)
+ {
+ PropertyObject o;
+ QCOMPARE(QQmlProperty::write(&o, QString("objectName"), QVariant(QString("myName"))), true);
+ QCOMPARE(o.objectName(), QString("myName"));
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+ QQmlProperty p(o, QString("objectName"));
+ QCOMPARE(p.write(QVariant(QString("myName"))), true);
+ QCOMPARE(o->objectName(), QString("myName"));
+
+ delete o;
+
+ QCOMPARE(p.write(QVariant(QString("myName"))), false);
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onClicked");
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression()));
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression()));
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+ }
+
+ // Value-type property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "wrectProperty");
+
+ QCOMPARE(o.wrectProperty(), QRect());
+ QCOMPARE(p.write(QRect(1, 13, 99, 8)), true);
+ QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8));
+
+ QQmlProperty p2(&o, "wrectProperty.x");
+ QCOMPARE(p2.read(), QVariant(1));
+ QCOMPARE(p2.write(QVariant(6)), true);
+ QCOMPARE(p2.read(), QVariant(6));
+ QCOMPARE(o.wrectProperty(), QRect(6, 13, 99, 8));
+ }
+
+ // URL-property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "url");
+
+ QCOMPARE(p.write(QUrl("main.qml")), true);
+ QCOMPARE(o.url(), QUrl("main.qml"));
+
+ QQmlProperty p2(&o, "url", engine.rootContext());
+
+ QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
+ QVERIFY(result != QUrl("main.qml"));
+
+ QCOMPARE(p2.write(QUrl("main.qml")), true);
+ QCOMPARE(o.url(), result);
+ }
+ { // static
+ PropertyObject o;
+
+ QCOMPARE(QQmlProperty::write(&o, "url", QUrl("main.qml")), true);
+ QCOMPARE(o.url(), QUrl("main.qml"));
+
+ QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
+ QVERIFY(result != QUrl("main.qml"));
+
+ QCOMPARE(QQmlProperty::write(&o, "url", QUrl("main.qml"), engine.rootContext()), true);
+ QCOMPARE(o.url(), result);
+ }
+
+ // VariantMap-property
+ QVariantMap vm;
+ vm.insert("key", "value");
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "variantMap");
+
+ QCOMPARE(p.write(vm), true);
+ QCOMPARE(o.variantMap(), vm);
+
+ QQmlProperty p2(&o, "variantMap", engine.rootContext());
+
+ QCOMPARE(p2.write(vm), true);
+ QCOMPARE(o.variantMap(), vm);
+ }
+ { // static
+ PropertyObject o;
+
+ QCOMPARE(QQmlProperty::write(&o, "variantMap", vm), true);
+ QCOMPARE(o.variantMap(), vm);
+
+ QCOMPARE(QQmlProperty::write(&o, "variantMap", vm, engine.rootContext()), true);
+ QCOMPARE(o.variantMap(), vm);
+ }
+
+ // Attached property
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "MyContainer.foo", qmlContext(object));
+ p.write(QVariant(99));
+ QCOMPARE(p.read(), QVariant(99));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
+ p.write(QVariant(99));
+ QCOMPARE(p.read(), QVariant(99));
+ delete object;
+ }
+}
+
+void tst_qqmlproperty::reset()
+{
+ // Invalid
+ {
+ QQmlProperty p;
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Read-only default prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Non-resettable-only prop by name
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, QString("defaultProperty"));
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Resettable prop by name
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, QString("resettableProperty"));
+
+ QCOMPARE(p.read(), QVariant(9));
+ QCOMPARE(p.write(QVariant(11)), true);
+ QCOMPARE(p.read(), QVariant(11));
+
+ QCOMPARE(p.isResettable(), true);
+ QCOMPARE(p.reset(), true);
+
+ QCOMPARE(p.read(), QVariant(9));
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+
+ QQmlProperty p(o, QString("resettableProperty"));
+
+ QCOMPARE(p.isResettable(), true);
+ QCOMPARE(p.reset(), true);
+
+ delete o;
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onClicked");
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+}
+
+void tst_qqmlproperty::writeObjectToList()
+{
+ QQmlComponent containerComponent(&engine);
+ containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QQmlListReference list(container, "children");
+ QVERIFY(list.count() == 1);
+
+ MyQmlObject *object = new MyQmlObject;
+ QQmlProperty prop(container, "children");
+ prop.write(qVariantFromValue(object));
+ QCOMPARE(list.count(), 1);
+ QCOMPARE(list.at(0), qobject_cast<QObject*>(object));
+}
+
+void tst_qqmlproperty::writeListToList()
+{
+ QQmlComponent containerComponent(&engine);
+ containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QQmlListReference list(container, "children");
+ QVERIFY(list.count() == 1);
+
+ QList<QObject*> objList;
+ objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
+ QQmlProperty prop(container, "children");
+ prop.write(qVariantFromValue(objList));
+ QCOMPARE(list.count(), 4);
+
+ //XXX need to try this with read/write prop (for read-only it correctly doesn't write)
+ /*QList<MyQmlObject*> typedObjList;
+ typedObjList << new MyQmlObject();
+ prop.write(qVariantFromValue(&typedObjList));
+ QCOMPARE(container->children()->size(), 1);*/
+}
+
+void tst_qqmlproperty::urlHandling_data()
+{
+ QTest::addColumn<QByteArray>("input");
+ QTest::addColumn<QString>("scheme");
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<QByteArray>("encoded");
+
+ QTest::newRow("unspecifiedFile")
+ << QByteArray("main.qml")
+ << QString("")
+ << QString("main.qml")
+ << QByteArray("main.qml");
+
+ QTest::newRow("specifiedFile")
+ << QByteArray("file:///main.qml")
+ << QString("file")
+ << QString("/main.qml")
+ << QByteArray("file:///main.qml");
+
+ QTest::newRow("httpFile")
+ << QByteArray("http://www.example.com/main.qml")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml");
+
+ QTest::newRow("pathFile")
+ << QByteArray("http://www.example.com/resources/main.qml")
+ << QString("http")
+ << QString("/resources/main.qml")
+ << QByteArray("http://www.example.com/resources/main.qml");
+
+ QTest::newRow("encodableName")
+ << QByteArray("http://www.example.com/main file.qml")
+ << QString("http")
+ << QString("/main file.qml")
+ << QByteArray("http://www.example.com/main%20file.qml");
+
+ QTest::newRow("preencodedName")
+ << QByteArray("http://www.example.com/resources%7cmain%20file.qml")
+ << QString("http")
+ << QString("/resources|main file.qml")
+ << QByteArray("http://www.example.com/resources%7cmain%20file.qml");
+
+ QTest::newRow("encodableQuery")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now working?")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now%20working?");
+
+ QTest::newRow("preencodedQuery")
+ << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now working%3f")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now%20working%3f");
+
+ QTest::newRow("encodableFragment")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000|volume+50%")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7Cvolume+50%25");
+
+ QTest::newRow("preencodedFragment")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%25");
+}
+
+void tst_qqmlproperty::urlHandling()
+{
+ QFETCH(QByteArray, input);
+ QFETCH(QString, scheme);
+ QFETCH(QString, path);
+ QFETCH(QByteArray, encoded);
+
+ QString inputString(QString::fromUtf8(input));
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "url");
+
+ // Test url written as QByteArray
+ QCOMPARE(p.write(input), true);
+ QUrl byteArrayResult(o.url());
+
+ QCOMPARE(byteArrayResult.scheme(), scheme);
+ QCOMPARE(byteArrayResult.path(), path);
+ QCOMPARE(byteArrayResult.toEncoded(), encoded);
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "url");
+
+ // Test url written as QString
+ QCOMPARE(p.write(inputString), true);
+ QUrl stringResult(o.url());
+
+ QCOMPARE(stringResult.scheme(), scheme);
+ QCOMPARE(stringResult.path(), path);
+ QCOMPARE(stringResult.toEncoded(), encoded);
+ }
+}
+
+void tst_qqmlproperty::variantMapHandling_data()
+{
+ QTest::addColumn<QVariantMap>("vm");
+
+ // Object literals
+ {
+ QVariantMap m;
+ QTest::newRow("{}") << m;
+ }
+ {
+ QVariantMap m;
+ m["a"] = QVariantMap();
+ QTest::newRow("{ a:{} }") << m;
+ }
+ {
+ QVariantMap m, m2;
+ m2["b"] = 10;
+ m2["c"] = 20;
+ m["a"] = m2;
+ QTest::newRow("{ a:{b:10, c:20} }") << m;
+ }
+ {
+ QVariantMap m;
+ m["a"] = 10;
+ m["b"] = QVariantList() << 20 << 30;
+ QTest::newRow("{ a:10, b:[20, 30]}") << m;
+ }
+
+ // Cyclic objects
+ {
+ QVariantMap m;
+ m["p"] = QVariantMap();
+ QTest::newRow("var o={}; o.p=o") << m;
+ }
+ {
+ QVariantMap m;
+ m["p"] = 123;
+ m["q"] = QVariantMap();
+ QTest::newRow("var o={}; o.p=123; o.q=o") << m;
+ }
+}
+
+void tst_qqmlproperty::variantMapHandling()
+{
+ QFETCH(QVariantMap, vm);
+
+ PropertyObject o;
+ QQmlProperty p(&o, "variantMap");
+
+ QCOMPARE(p.write(vm), true);
+ QCOMPARE(o.variantMap(), vm);
+}
+
+void tst_qqmlproperty::crashOnValueProperty()
+{
+ QQmlEngine *engine = new QQmlEngine;
+ QQmlComponent component(engine);
+
+ component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
+ PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
+ QVERIFY(obj != 0);
+
+ QQmlProperty p(obj, "wrectProperty.x", qmlContext(obj));
+ QCOMPARE(p.name(), QString("wrectProperty.x"));
+
+ QCOMPARE(p.read(), QVariant(10));
+
+ //don't crash once the engine is deleted
+ delete engine;
+ engine = 0;
+
+ QCOMPARE(p.propertyTypeName(), "int");
+ QCOMPARE(p.read(), QVariant(10));
+ p.write(QVariant(20));
+ QCOMPARE(p.read(), QVariant(20));
+}
+
+// QTBUG-13719
+void tst_qqmlproperty::aliasPropertyBindings()
+{
+ QQmlComponent component(&engine, testFileUrl("aliasPropertyBindings.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("realProperty").toReal(), 90.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 90.);
+
+ object->setProperty("test", 10);
+
+ QCOMPARE(object->property("realProperty").toReal(), 110.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 110.);
+
+ QQmlProperty realProperty(object, QLatin1String("realProperty"));
+ QQmlProperty aliasProperty(object, QLatin1String("aliasProperty"));
+
+ // Check there is a binding on these two properties
+ QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0);
+
+ // Check that its the same binding on these two properties
+ QCOMPARE(QQmlPropertyPrivate::binding(realProperty),
+ QQmlPropertyPrivate::binding(aliasProperty));
+
+ // Change the binding
+ object->setProperty("state", QString("switch"));
+
+ QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0);
+ QCOMPARE(QQmlPropertyPrivate::binding(realProperty),
+ QQmlPropertyPrivate::binding(aliasProperty));
+
+ QCOMPARE(object->property("realProperty").toReal(), 96.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 96.);
+
+ // Check the old binding really has not effect any more
+ object->setProperty("test", 4);
+
+ QCOMPARE(object->property("realProperty").toReal(), 96.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 96.);
+
+ object->setProperty("test2", 9);
+
+ QCOMPARE(object->property("realProperty").toReal(), 288.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 288.);
+
+ // Revert
+ object->setProperty("state", QString(""));
+
+ QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0);
+ QCOMPARE(QQmlPropertyPrivate::binding(realProperty),
+ QQmlPropertyPrivate::binding(aliasProperty));
+
+ QCOMPARE(object->property("realProperty").toReal(), 20.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 20.);
+
+ object->setProperty("test2", 3);
+
+ QCOMPARE(object->property("realProperty").toReal(), 20.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 20.);
+
+ delete object;
+}
+
+void tst_qqmlproperty::copy()
+{
+ PropertyObject object;
+
+ QQmlProperty *property = new QQmlProperty(&object, QLatin1String("defaultProperty"));
+ QCOMPARE(property->name(), QString("defaultProperty"));
+ QCOMPARE(property->read(), QVariant(10));
+ QCOMPARE(property->type(), QQmlProperty::Property);
+ QCOMPARE(property->propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(property->propertyType(), (int)QVariant::Int);
+
+ QQmlProperty p1(*property);
+ QCOMPARE(p1.name(), QString("defaultProperty"));
+ QCOMPARE(p1.read(), QVariant(10));
+ QCOMPARE(p1.type(), QQmlProperty::Property);
+ QCOMPARE(p1.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(p1.propertyType(), (int)QVariant::Int);
+
+ QQmlProperty p2(&object, QLatin1String("url"));
+ QCOMPARE(p2.name(), QString("url"));
+ p2 = *property;
+ QCOMPARE(p2.name(), QString("defaultProperty"));
+ QCOMPARE(p2.read(), QVariant(10));
+ QCOMPARE(p2.type(), QQmlProperty::Property);
+ QCOMPARE(p2.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(p2.propertyType(), (int)QVariant::Int);
+
+ delete property; property = 0;
+
+ QCOMPARE(p1.name(), QString("defaultProperty"));
+ QCOMPARE(p1.read(), QVariant(10));
+ QCOMPARE(p1.type(), QQmlProperty::Property);
+ QCOMPARE(p1.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(p1.propertyType(), (int)QVariant::Int);
+
+ QCOMPARE(p2.name(), QString("defaultProperty"));
+ QCOMPARE(p2.read(), QVariant(10));
+ QCOMPARE(p2.type(), QQmlProperty::Property);
+ QCOMPARE(p2.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(p2.propertyType(), (int)QVariant::Int);
+}
+
+void tst_qqmlproperty::noContext()
+{
+ QQmlComponent compA(&engine, testFileUrl("NoContextTypeA.qml"));
+ QQmlComponent compB(&engine, testFileUrl("NoContextTypeB.qml"));
+
+ QObject *a = compA.create();
+ QVERIFY(a != 0);
+ QObject *b = compB.create();
+ QVERIFY(b != 0);
+
+ QVERIFY(QQmlProperty::write(b, "myTypeA", QVariant::fromValue(a), &engine));
+
+ delete a;
+ delete b;
+}
+
+void tst_qqmlproperty::assignEmptyVariantMap()
+{
+ PropertyObject o;
+
+ QVariantMap map;
+ map.insert("key", "value");
+ o.setVariantMap(map);
+ QCOMPARE(o.variantMap().count(), 1);
+ QCOMPARE(o.variantMap().isEmpty(), false);
+
+ QQmlContext context(&engine);
+ context.setContextProperty("o", &o);
+
+ QQmlComponent component(&engine, testFileUrl("assignEmptyVariantMap.qml"));
+ QObject *obj = component.create(&context);
+ QVERIFY(obj);
+
+ QCOMPARE(o.variantMap().count(), 0);
+ QCOMPARE(o.variantMap().isEmpty(), true);
+
+ delete obj;
+}
+
+void tst_qqmlproperty::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<MyQmlObject>("Test",1,0,"MyQmlObject");
+ qmlRegisterType<PropertyObject>("Test",1,0,"PropertyObject");
+ qmlRegisterType<MyContainer>("Test",1,0,"MyContainer");
+}
+
+QTEST_MAIN(tst_qqmlproperty)
+
+#include "tst_qqmlproperty.moc"
diff --git a/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro
new file mode 100644
index 0000000000..4beb961895
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qqmlpropertycache
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlpropertycache.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private testlib v8-private
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
new file mode 100644
index 0000000000..b702623fee
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -0,0 +1,281 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <private/qqmlpropertycache_p.h>
+#include <QtQml/qqmlengine.h>
+#include "../../shared/util.h"
+
+class tst_qqmlpropertycache : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlpropertycache() {}
+
+private slots:
+ void properties();
+ void propertiesDerived();
+ void methods();
+ void methodsDerived();
+ void signalHandlers();
+ void signalHandlersDerived();
+
+private:
+ QQmlEngine engine;
+};
+
+class BaseObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyA READ propertyA NOTIFY propertyAChanged)
+ Q_PROPERTY(QString propertyB READ propertyB NOTIFY propertyBChanged)
+public:
+ BaseObject(QObject *parent = 0) : QObject(parent) {}
+
+ int propertyA() const { return 0; }
+ QString propertyB() const { return QString(); }
+
+public Q_SLOTS:
+ void slotA() {}
+
+Q_SIGNALS:
+ void propertyAChanged();
+ void propertyBChanged();
+ void signalA();
+};
+
+class DerivedObject : public BaseObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyC READ propertyC NOTIFY propertyCChanged)
+ Q_PROPERTY(QString propertyD READ propertyD NOTIFY propertyDChanged)
+public:
+ DerivedObject(QObject *parent = 0) : BaseObject(parent) {}
+
+ int propertyC() const { return 0; }
+ QString propertyD() const { return QString(); }
+
+public Q_SLOTS:
+ void slotB() {}
+
+Q_SIGNALS:
+ void propertyCChanged();
+ void propertyDChanged();
+ void signalB();
+};
+
+void tst_qqmlpropertycache::properties()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("propertyA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyC")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyD")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
+}
+
+void tst_qqmlpropertycache::propertiesDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("propertyA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyC")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyD")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
+}
+
+void tst_qqmlpropertycache::methods()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("slotA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("slotB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::methodsDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("slotA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("slotB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::signalHandlers()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::signalHandlersDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+QTEST_MAIN(tst_qqmlpropertycache)
+
+#include "tst_qqmlpropertycache.moc"
diff --git a/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro b/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro
new file mode 100644
index 0000000000..f67de8cea9
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlpropertymap
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlpropertymap.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
new file mode 100644
index 0000000000..0ae05ce138
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlpropertymap.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QSignalSpy>
+
+class tst_QQmlPropertyMap : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QQmlPropertyMap() {}
+
+private slots:
+ void insert();
+ void operatorInsert();
+ void operatorValue();
+ void clear();
+ void changed();
+ void count();
+
+ void crashBug();
+ void QTBUG_17868();
+};
+
+void tst_QQmlPropertyMap::insert()
+{
+ QQmlPropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(map.contains(QLatin1String("key1")));
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
+
+ map.insert(QLatin1String("key1"),"Hello World");
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+
+ //inserting property names same with existing method(signal, slot, method) names is not allowed
+ //QQmlPropertyMap has an invokable keys() method
+ QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols. ");
+ map.insert(QLatin1String("keys"), 1);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(!map.contains(QLatin1String("keys")));
+ QVERIFY(map.value(QLatin1String("keys")).isNull());
+
+ //QQmlPropertyMap has a deleteLater() slot
+ QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols. ");
+ map.insert(QLatin1String("deleteLater"), 1);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(!map.contains(QLatin1String("deleteLater")));
+ QVERIFY(map.value(QLatin1String("deleteLater")).isNull());
+
+ //QQmlPropertyMap has an valueChanged() signal
+ QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols. ");
+ map.insert(QLatin1String("valueChanged"), 1);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(!map.contains(QLatin1String("valueChanged")));
+ QVERIFY(map.value(QLatin1String("valueChanged")).isNull());
+
+ //but 'valueChange' should be ok
+ map.insert(QLatin1String("valueChange"), 1);
+ QVERIFY(map.keys().count() == 3);
+ QVERIFY(map.contains(QLatin1String("valueChange")));
+ QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1));
+
+ //'valueCHANGED' should be ok, too
+ map.insert(QLatin1String("valueCHANGED"), 1);
+ QVERIFY(map.keys().count() == 4);
+ QVERIFY(map.contains(QLatin1String("valueCHANGED")));
+ QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1));
+}
+
+void tst_QQmlPropertyMap::operatorInsert()
+{
+ QQmlPropertyMap map;
+ map[QLatin1String("key1")] = 100;
+ map[QLatin1String("key2")] = 200;
+ QVERIFY(map.keys().count() == 2);
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
+
+ map[QLatin1String("key1")] = "Hello World";
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+void tst_QQmlPropertyMap::operatorValue()
+{
+ QQmlPropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QVERIFY(map.count() == 2);
+ QVERIFY(map.contains(QLatin1String("key1")));
+
+ const QQmlPropertyMap &constMap = map;
+
+ QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200));
+ QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1")));
+ QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2")));
+}
+
+void tst_QQmlPropertyMap::clear()
+{
+ QQmlPropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ QVERIFY(map.keys().count() == 1);
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+
+ map.clear(QLatin1String("key1"));
+ QVERIFY(map.keys().count() == 1);
+ QVERIFY(map.contains(QLatin1String("key1")));
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant());
+}
+
+void tst_QQmlPropertyMap::changed()
+{
+ QQmlPropertyMap map;
+ QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&, const QVariant&)));
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QCOMPARE(spy.count(), 0);
+
+ map.clear(QLatin1String("key1"));
+ QCOMPARE(spy.count(), 0);
+
+ //make changes in QML
+ QQmlEngine engine;
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty(QLatin1String("testdata"), &map);
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
+ QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady());
+ QQuickText *txt = qobject_cast<QQuickText*>(component.create());
+ QVERIFY(txt);
+ QCOMPARE(txt->text(), QString('X'));
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.count(), 2);
+ QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
+ QCOMPARE(arguments.at(1).value<QVariant>(),QVariant("Hello World"));
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+void tst_QQmlPropertyMap::count()
+{
+ QQmlPropertyMap map;
+ QCOMPARE(map.isEmpty(), true);
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QCOMPARE(map.count(), 2);
+ QCOMPARE(map.isEmpty(), false);
+
+ map.insert(QLatin1String("key3"),"Hello World");
+ QCOMPARE(map.count(), 3);
+
+ //clearing doesn't remove the key
+ map.clear(QLatin1String("key3"));
+ QCOMPARE(map.count(), 3);
+ QCOMPARE(map.size(), map.count());
+}
+
+void tst_QQmlPropertyMap::crashBug()
+{
+ QQmlPropertyMap map;
+
+ QQmlEngine engine;
+ QQmlContext context(&engine);
+ context.setContextProperty("map", &map);
+
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0\nBinding { target: map; property: \"myProp\"; value: 10 + 23 }",QUrl());
+ QObject *obj = c.create(&context);
+ delete obj;
+}
+
+void tst_QQmlPropertyMap::QTBUG_17868()
+{
+ QQmlPropertyMap map;
+
+ QQmlEngine engine;
+ QQmlContext context(&engine);
+ context.setContextProperty("map", &map);
+ map.insert("key", 1);
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0\nItem {property bool error:false; Component.onCompleted: {try{ map.keys(); }catch(e) {error=true;}}}",QUrl());
+ QObject *obj = c.create(&context);
+ QVERIFY(obj);
+ QVERIFY(!obj->property("error").toBool());
+ delete obj;
+
+}
+
+QTEST_MAIN(tst_QQmlPropertyMap)
+
+#include "tst_qqmlpropertymap.moc"
diff --git a/tests/auto/declarative/qdeclarativeqt/data/atob.qml b/tests/auto/qml/qqmlqt/data/atob.qml
index 0d684003a1..0d684003a1 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/atob.qml
+++ b/tests/auto/qml/qqmlqt/data/atob.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/btoa.qml b/tests/auto/qml/qqmlqt/data/btoa.qml
index 0ecd01d284..0ecd01d284 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/btoa.qml
+++ b/tests/auto/qml/qqmlqt/data/btoa.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml b/tests/auto/qml/qqmlqt/data/createComponent.qml
index 3ebc9f14f8..3ebc9f14f8 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
+++ b/tests/auto/qml/qqmlqt/data/createComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml b/tests/auto/qml/qqmlqt/data/createComponentData.qml
index 2a824e5362..2a824e5362 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml
+++ b/tests/auto/qml/qqmlqt/data/createComponentData.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js b/tests/auto/qml/qqmlqt/data/createComponent_lib.js
index 30499e943e..30499e943e 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js
+++ b/tests/auto/qml/qqmlqt/data/createComponent_lib.js
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml b/tests/auto/qml/qqmlqt/data/createComponent_lib.qml
index a52453e8fa..a52453e8fa 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml
+++ b/tests/auto/qml/qqmlqt/data/createComponent_lib.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml b/tests/auto/qml/qqmlqt/data/createQmlObject.qml
index 87601b1cc8..87601b1cc8 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
+++ b/tests/auto/qml/qqmlqt/data/createQmlObject.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/darker.qml b/tests/auto/qml/qqmlqt/data/darker.qml
index ce6c705fb4..ce6c705fb4 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/darker.qml
+++ b/tests/auto/qml/qqmlqt/data/darker.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml
index 641ba6e1ca..641ba6e1ca 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml
+++ b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/enums.qml b/tests/auto/qml/qqmlqt/data/enums.qml
index 5a2ff534af..5a2ff534af 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/enums.qml
+++ b/tests/auto/qml/qqmlqt/data/enums.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml b/tests/auto/qml/qqmlqt/data/fontFamilies.qml
index 70245ab159..70245ab159 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml
+++ b/tests/auto/qml/qqmlqt/data/fontFamilies.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/qml/qqmlqt/data/formatting.qml
index 7a462c8eeb..7a462c8eeb 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
+++ b/tests/auto/qml/qqmlqt/data/formatting.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml b/tests/auto/qml/qqmlqt/data/hsla.qml
index ff9622b339..ff9622b339 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml
+++ b/tests/auto/qml/qqmlqt/data/hsla.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml b/tests/auto/qml/qqmlqt/data/isQtObject.qml
index 6829209518..6829209518 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml
+++ b/tests/auto/qml/qqmlqt/data/isQtObject.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml b/tests/auto/qml/qqmlqt/data/lighter.qml
index 7db5e1edeb..7db5e1edeb 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
+++ b/tests/auto/qml/qqmlqt/data/lighter.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/md5.qml b/tests/auto/qml/qqmlqt/data/md5.qml
index bec1ed1fe7..bec1ed1fe7 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/md5.qml
+++ b/tests/auto/qml/qqmlqt/data/md5.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml b/tests/auto/qml/qqmlqt/data/openUrlExternally.qml
index 37b9f513d9..37b9f513d9 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml
+++ b/tests/auto/qml/qqmlqt/data/openUrlExternally.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js
index 702357afbf..702357afbf 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js
+++ b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml
index 4bf584d134..4bf584d134 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml
+++ b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/point.qml b/tests/auto/qml/qqmlqt/data/point.qml
index fe12ee6232..fe12ee6232 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/point.qml
+++ b/tests/auto/qml/qqmlqt/data/point.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/quit.qml b/tests/auto/qml/qqmlqt/data/quit.qml
index e3b91660e7..e3b91660e7 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/quit.qml
+++ b/tests/auto/qml/qqmlqt/data/quit.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/rect.qml b/tests/auto/qml/qqmlqt/data/rect.qml
index b294b22c5b..b294b22c5b 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/rect.qml
+++ b/tests/auto/qml/qqmlqt/data/rect.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/resolvedUrl.qml b/tests/auto/qml/qqmlqt/data/resolvedUrl.qml
index 06ef48b82b..06ef48b82b 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/resolvedUrl.qml
+++ b/tests/auto/qml/qqmlqt/data/resolvedUrl.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml b/tests/auto/qml/qqmlqt/data/rgba.qml
index 3b010f68cb..3b010f68cb 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml
+++ b/tests/auto/qml/qqmlqt/data/rgba.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/size.qml b/tests/auto/qml/qqmlqt/data/size.qml
index 41051f4216..41051f4216 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/size.qml
+++ b/tests/auto/qml/qqmlqt/data/size.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/tint.qml b/tests/auto/qml/qqmlqt/data/tint.qml
index 816e6e9b08..816e6e9b08 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/tint.qml
+++ b/tests/auto/qml/qqmlqt/data/tint.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/vector.qml b/tests/auto/qml/qqmlqt/data/vector.qml
index 5a949515ed..5a949515ed 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/vector.qml
+++ b/tests/auto/qml/qqmlqt/data/vector.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/vector4.qml b/tests/auto/qml/qqmlqt/data/vector4.qml
index 554dd1e9d4..554dd1e9d4 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/vector4.qml
+++ b/tests/auto/qml/qqmlqt/data/vector4.qml
diff --git a/tests/auto/qml/qqmlqt/qqmlqt.pro b/tests/auto/qml/qqmlqt/qqmlqt.pro
new file mode 100644
index 0000000000..890a7e7636
--- /dev/null
+++ b/tests/auto/qml/qqmlqt/qqmlqt.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlqt
+SOURCES += tst_qqmlqt.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
new file mode 100644
index 0000000000..a679188cb7
--- /dev/null
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -0,0 +1,732 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <private/qqmlengine_p.h>
+
+#include <qtest.h>
+#include <QDebug>
+#include <QQmlEngine>
+#include <QFontDatabase>
+#include <QFileInfo>
+#include <QQmlComponent>
+#include <QDesktopServices>
+#include <QDir>
+#include <QVector3D>
+#include <QCryptographicHash>
+#include <QtQuick/QQuickItem>
+#include <QSignalSpy>
+#include "../../shared/util.h"
+
+class tst_qqmlqt : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlqt() {}
+
+private slots:
+ void enums();
+ void rgba();
+ void hsla();
+ void rect();
+ void point();
+ void size();
+ void vector();
+ void vector4d();
+ void lighter();
+ void darker();
+ void tint();
+ void openUrlExternally();
+ void openUrlExternally_pragmaLibrary();
+ void md5();
+ void createComponent();
+ void createComponent_pragmaLibrary();
+ void createQmlObject();
+ void dateTimeConversion();
+ void dateTimeFormatting();
+ void dateTimeFormatting_data();
+ void dateTimeFormattingVariants();
+ void dateTimeFormattingVariants_data();
+ void isQtObject();
+ void btoa();
+ void atob();
+ void fontFamilies();
+ void quit();
+ void resolvedUrl();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlqt::enums()
+{
+ QQmlComponent component(&engine, testFileUrl("enums.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), (int)Qt::Key_Escape);
+ QCOMPARE(object->property("test2").toInt(), (int)Qt::DescendingOrder);
+ QCOMPARE(object->property("test3").toInt(), (int)Qt::ElideMiddle);
+ QCOMPARE(object->property("test4").toInt(), (int)Qt::AlignRight);
+
+ delete object;
+}
+
+void tst_qqmlqt::rgba()
+{
+ QQmlComponent component(&engine, testFileUrl("rgba.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromRgbF(0, 0, 0, 0));
+
+ delete object;
+}
+
+void tst_qqmlqt::hsla()
+{
+ QQmlComponent component(&engine, testFileUrl("hsla.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHslF(1, 1, 1, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromHslF(0, 0, 0, 0));
+
+ delete object;
+}
+
+void tst_qqmlqt::rect()
+{
+ QQmlComponent component(&engine, testFileUrl("rect.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test1")), QRectF(10, 13, 100, 109));
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test2")), QRectF(-10, 13, 100, 109.6));
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test3")), QRectF());
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test4")), QRectF());
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF(10, 13, 100, -109));
+
+ delete object;
+}
+
+void tst_qqmlqt::point()
+{
+ QQmlComponent component(&engine, testFileUrl("point.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test1")), QPointF(19, 34));
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test2")), QPointF(-3, 109.2));
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test3")), QPointF());
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test4")), QPointF());
+
+ delete object;
+}
+
+void tst_qqmlqt::size()
+{
+ QQmlComponent component(&engine, testFileUrl("size.qml"));
+
+ QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test1")), QSizeF(19, 34));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test2")), QSizeF(3, 109.2));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test3")), QSizeF(-3, 10));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test4")), QSizeF());
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test5")), QSizeF());
+
+ delete object;
+}
+
+void tst_qqmlqt::vector()
+{
+ QQmlComponent component(&engine, testFileUrl("vector.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9));
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1));
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test3")), QVector3D());
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test4")), QVector3D());
+
+ delete object;
+}
+
+void tst_qqmlqt::vector4d()
+{
+ QQmlComponent component(&engine, testFileUrl("vector4.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test1")), QVector4D(1, 0, 0.9, 0.6));
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test2")), QVector4D(102, -10, -982.1, 10));
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test3")), QVector4D());
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test4")), QVector4D());
+
+ delete object;
+}
+
+void tst_qqmlqt::lighter()
+{
+ QQmlComponent component(&engine, testFileUrl("lighter.qml"));
+
+ QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qqmlqt::darker()
+{
+ QQmlComponent component(&engine, testFileUrl("darker.qml"));
+
+ QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qqmlqt::tint()
+{
+ QQmlComponent component(&engine, testFileUrl("tint.qml"));
+
+ QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments";
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(0, 0, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0, 0));
+ QColor test3 = qvariant_cast<QColor>(object->property("test3"));
+ QCOMPARE(test3.rgba(), 0xFF7F0080);
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+
+ delete object;
+}
+
+class MyUrlHandler : public QObject
+{
+ Q_OBJECT
+public:
+ MyUrlHandler() : called(0) { }
+ int called;
+ QUrl last;
+
+public slots:
+ void noteCall(const QUrl &url) { called++; last = url; }
+};
+
+void tst_qqmlqt::openUrlExternally()
+{
+ MyUrlHandler handler;
+
+ QDesktopServices::setUrlHandler("test", &handler, "noteCall");
+ QDesktopServices::setUrlHandler("file", &handler, "noteCall");
+
+ QQmlComponent component(&engine, testFileUrl("openUrlExternally.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(handler.called,1);
+ QCOMPARE(handler.last, QUrl("test:url"));
+
+ object->setProperty("testFile", true);
+
+ QCOMPARE(handler.called,2);
+ QCOMPARE(handler.last, testFileUrl("test.html"));
+
+ QDesktopServices::unsetUrlHandler("test");
+ QDesktopServices::unsetUrlHandler("file");
+}
+
+void tst_qqmlqt::openUrlExternally_pragmaLibrary()
+{
+ MyUrlHandler handler;
+
+ QDesktopServices::setUrlHandler("test", &handler, "noteCall");
+ QDesktopServices::setUrlHandler("file", &handler, "noteCall");
+
+ QQmlComponent component(&engine, testFileUrl("openUrlExternally_lib.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(handler.called,1);
+ QCOMPARE(handler.last, QUrl("test:url"));
+
+ object->setProperty("testFile", true);
+
+ QCOMPARE(handler.called,2);
+ QCOMPARE(handler.last, testFileUrl("test.html"));
+
+ QDesktopServices::unsetUrlHandler("test");
+ QDesktopServices::unsetUrlHandler("file");
+}
+
+void tst_qqmlqt::md5()
+{
+ QQmlComponent component(&engine, testFileUrl("md5.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
+
+ delete object;
+}
+
+void tst_qqmlqt::createComponent()
+{
+ QQmlComponent component(&engine, testFileUrl("createComponent.qml"));
+
+ QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
+ QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString());
+
+ delete object;
+}
+
+void tst_qqmlqt::createComponent_pragmaLibrary()
+{
+ // Currently, just loading createComponent_lib.qml causes crash on some platforms
+ QQmlComponent component(&engine, testFileUrl("createComponent_lib.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("status").toInt(), int(QQmlComponent::Ready));
+ QCOMPARE(object->property("readValue").toInt(), int(1913));
+ delete object;
+}
+
+void tst_qqmlqt::createQmlObject()
+{
+ QQmlComponent component(&engine, testFileUrl("createQmlObject.qml"));
+
+ QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments";
+ QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":2:10: Blah is not a type";
+ QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("main.qml").toString() + ":4:14: Duplicate property name";
+ QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object";
+ QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments";
+ QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":3: Cannot assign object type QObject with no default method";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(warning6));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("emptyArg").toBool(), true);
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QQuickItem *item = qobject_cast<QQuickItem *>(object);
+ QVERIFY(item != 0);
+ QVERIFY(item->childItems().count() == 1);
+
+ delete object;
+}
+
+
+void tst_qqmlqt::dateTimeConversion()
+{
+ QDate date(2008,12,24);
+ QTime time(14,15,38,200);
+ QDateTime dateTime(date, time);
+ //Note that when converting Date to QDateTime they can argue over historical DST data when converting to local time.
+ //Tests should use UTC or recent dates.
+ QDateTime dateTime2(QDate(2852,12,31), QTime(23,59,59,500));
+ QDateTime dateTime3(QDate(2000,1,1), QTime(0,0,0,0));
+ QDateTime dateTime4(QDate(2001,2,2), QTime(0,0,0,0));
+ QDateTime dateTime5(QDate(1999,1,1), QTime(2,3,4,0));
+ QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200));
+
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("dateTimeConversion.qml"));
+ QObject *obj = component.create();
+
+ QCOMPARE(obj->property("qdate").toDate(), date);
+ QCOMPARE(obj->property("qtime").toTime(), time);
+ QCOMPARE(obj->property("qdatetime").toDateTime(), dateTime);
+ QCOMPARE(obj->property("qdatetime2").toDateTime(), dateTime2);
+ QCOMPARE(obj->property("qdatetime3").toDateTime(), dateTime3);
+ QCOMPARE(obj->property("qdatetime4").toDateTime(), dateTime4);
+ QCOMPARE(obj->property("qdatetime5").toDateTime(), dateTime5);
+ QCOMPARE(obj->property("qdatetime6").toDateTime(), dateTime6);
+}
+
+void tst_qqmlqt::dateTimeFormatting()
+{
+ QFETCH(QString, method);
+ QFETCH(QStringList, inputProperties);
+ QFETCH(QStringList, expectedResults);
+
+ QDate date(2008,12,24);
+ QTime time(14,15,38,200);
+ QDateTime dateTime(date, time);
+
+ QQmlEngine eng;
+
+ eng.rootContext()->setContextProperty("qdate", date);
+ eng.rootContext()->setContextProperty("qtime", time);
+ eng.rootContext()->setContextProperty("qdatetime", dateTime);
+
+ QQmlComponent component(&eng, testFileUrl("formatting.qml"));
+
+ QStringList warnings;
+ warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
+ << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments"
+ << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format"
+ << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments"
+ << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format"
+ << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments";
+
+ foreach (const QString &warning, warnings)
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
+ QVERIFY(object != 0);
+
+ QVERIFY(inputProperties.count() > 0);
+ QVariant result;
+ foreach(const QString &prop, inputProperties) {
+ QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(),
+ Q_RETURN_ARG(QVariant, result),
+ Q_ARG(QVariant, prop)));
+ QStringList output = result.toStringList();
+ QCOMPARE(output.size(), expectedResults.size());
+ for (int i=0; i<output.count(); i++)
+ QCOMPARE(output[i], expectedResults[i]);
+ }
+
+ delete object;
+}
+
+void tst_qqmlqt::dateTimeFormatting_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QStringList>("inputProperties");
+ QTest::addColumn<QStringList>("expectedResults");
+
+ QDate date(2008,12,24);
+ QTime time(14,15,38,200);
+ QDateTime dateTime(date, time);
+
+ QTest::newRow("formatDate")
+ << "formatDate"
+ << (QStringList() << "dateFromString" << "jsdate" << "qdate" << "qdatetime")
+ << (QStringList() << date.toString(Qt::DefaultLocaleShortDate)
+ << date.toString(Qt::DefaultLocaleLongDate)
+ << date.toString("ddd MMMM d yy"));
+
+ QTest::newRow("formatTime")
+ << "formatTime"
+ << (QStringList() << "jsdate" << "qtime" << "qdatetime")
+ << (QStringList() << time.toString(Qt::DefaultLocaleShortDate)
+ << time.toString(Qt::DefaultLocaleLongDate)
+ << time.toString("H:m:s a")
+ << time.toString("hh:mm:ss.zzz"));
+
+ QTest::newRow("formatDateTime")
+ << "formatDateTime"
+ << (QStringList() << "jsdate" << "qdatetime")
+ << (QStringList() << dateTime.toString(Qt::DefaultLocaleShortDate)
+ << dateTime.toString(Qt::DefaultLocaleLongDate)
+ << dateTime.toString("M/d/yy H:m:s a"));
+}
+
+void tst_qqmlqt::dateTimeFormattingVariants()
+{
+ QFETCH(QString, method);
+ QFETCH(QVariant, variant);
+ QFETCH(QStringList, expectedResults);
+
+ QQmlEngine eng;
+ eng.rootContext()->setContextProperty("qvariant", variant);
+ QQmlComponent component(&eng, testFileUrl("formatting.qml"));
+
+ QStringList warnings;
+ warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
+ << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments"
+ << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format"
+ << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments"
+ << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format"
+ << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments";
+
+ foreach (const QString &warning, warnings)
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
+ QVERIFY(object != 0);
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(),
+ Q_RETURN_ARG(QVariant, result),
+ Q_ARG(QVariant, QString(QLatin1String("qvariant")))));
+ QStringList output = result.toStringList();
+ QCOMPARE(output, expectedResults);
+
+ delete object;
+}
+
+void tst_qqmlqt::dateTimeFormattingVariants_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QVariant>("variant");
+ QTest::addColumn<QStringList>("expectedResults");
+
+ QDateTime temporary;
+
+ QTime time(11, 16, 39, 755);
+ temporary = QDateTime(QDate(1970,1,1), time);
+ QTest::newRow("formatDate, qtime") << "formatDate" << QVariant::fromValue(time) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qtime") << "formatDateTime" << QVariant::fromValue(time) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qtime") << "formatTime" << QVariant::fromValue(time) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ QDate date(2011,5,31);
+ temporary = QDateTime(date);
+ QTest::newRow("formatDate, qdate") << "formatDate" << QVariant::fromValue(date) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qdate") << "formatDateTime" << QVariant::fromValue(date) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qdate") << "formatTime" << QVariant::fromValue(date) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ QDateTime dateTime(date, time);
+ temporary = dateTime;
+ QTest::newRow("formatDate, qdatetime") << "formatDate" << QVariant::fromValue(dateTime) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qdatetime") << "formatDateTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qdatetime") << "formatTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ QString string(QLatin1String("2011/05/31 11:16:39.755"));
+ temporary = QDateTime::fromString(string, "yyyy/MM/dd HH:mm:ss.zzz");
+ QTest::newRow("formatDate, qstring") << "formatDate" << QVariant::fromValue(string) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qstring") << "formatDateTime" << QVariant::fromValue(string) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qstring") << "formatTime" << QVariant::fromValue(string) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ QColor color(Qt::red);
+ temporary = QVariant::fromValue(color).toDateTime();
+ QTest::newRow("formatDate, qcolor") << "formatDate" << QVariant::fromValue(color) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qcolor") << "formatDateTime" << QVariant::fromValue(color) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qcolor") << "formatTime" << QVariant::fromValue(color) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ int integer(4);
+ temporary = QVariant::fromValue(integer).toDateTime();
+ QTest::newRow("formatDate, int") << "formatDate" << QVariant::fromValue(integer) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, int") << "formatDateTime" << QVariant::fromValue(integer) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, int") << "formatTime" << QVariant::fromValue(integer) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+}
+
+void tst_qqmlqt::isQtObject()
+{
+ QQmlComponent component(&engine, testFileUrl("isQtObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), false);
+ QCOMPARE(object->property("test3").toBool(), false);
+ QCOMPARE(object->property("test4").toBool(), false);
+ QCOMPARE(object->property("test5").toBool(), false);
+
+ delete object;
+}
+
+void tst_qqmlqt::btoa()
+{
+ QQmlComponent component(&engine, testFileUrl("btoa.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toString(), QString("SGVsbG8gd29ybGQh"));
+
+ delete object;
+}
+
+void tst_qqmlqt::atob()
+{
+ QQmlComponent component(&engine, testFileUrl("atob.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toString(), QString("Hello world!"));
+
+ delete object;
+}
+
+void tst_qqmlqt::fontFamilies()
+{
+ QQmlComponent component(&engine, testFileUrl("fontFamilies.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QFontDatabase database;
+ QCOMPARE(object->property("test2"), QVariant::fromValue(database.families()));
+
+ delete object;
+}
+
+void tst_qqmlqt::quit()
+{
+ QQmlComponent component(&engine, testFileUrl("quit.qml"));
+
+ QSignalSpy spy(&engine, SIGNAL(quit()));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(spy.count(), 1);
+
+ delete object;
+}
+
+void tst_qqmlqt::resolvedUrl()
+{
+ QQmlComponent component(&engine, testFileUrl("resolvedUrl.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("result").toString(), component.url().toString());
+ QCOMPARE(object->property("isString").toBool(), true);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmlqt)
+
+#include "tst_qqmlqt.moc"
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/README b/tests/auto/qml/qqmlsqldatabase/data/README
index 7efca3a972..7efca3a972 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/README
+++ b/tests/auto/qml/qqmlsqldatabase/data/README
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js b/tests/auto/qml/qqmlsqldatabase/data/changeversion.js
index 178ff7c4af..178ff7c4af 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/changeversion.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/creation-a.js b/tests/auto/qml/qqmlsqldatabase/data/creation-a.js
index 25cba05451..25cba05451 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/creation-a.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/creation-a.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/creation.js b/tests/auto/qml/qqmlsqldatabase/data/creation.js
index 64eb4c7b92..64eb4c7b92 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/creation.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/creation.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-a.js b/tests/auto/qml/qqmlsqldatabase/data/error-a.js
index d7e9b4fdff..d7e9b4fdff 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-a.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-a.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-b.js b/tests/auto/qml/qqmlsqldatabase/data/error-b.js
index 17e34c989e..17e34c989e 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-b.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-b.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-creation.js b/tests/auto/qml/qqmlsqldatabase/data/error-creation.js
index d66977d1e2..d66977d1e2 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-creation.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-creation.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-notransaction.js b/tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js
index 2cce3f613c..2cce3f613c 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-notransaction.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-outsidetransaction.js b/tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js
index 7af7c1c6a2..7af7c1c6a2 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-outsidetransaction.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/iteration-forwardonly.js b/tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js
index b3df1be113..b3df1be113 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/iteration-forwardonly.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/iteration.js b/tests/auto/qml/qqmlsqldatabase/data/iteration.js
index 8d96dc2154..8d96dc2154 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/iteration.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/iteration.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/readonly-error.js b/tests/auto/qml/qqmlsqldatabase/data/readonly-error.js
index 39eb398004..39eb398004 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/readonly-error.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/readonly-error.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js b/tests/auto/qml/qqmlsqldatabase/data/readonly.js
index 985c9ecab5..985c9ecab5 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/readonly.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/reopen1.js b/tests/auto/qml/qqmlsqldatabase/data/reopen1.js
index 2171fb028e..2171fb028e 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/reopen1.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/reopen1.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/reopen2.js b/tests/auto/qml/qqmlsqldatabase/data/reopen2.js
index 12c6135145..12c6135145 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/reopen2.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/reopen2.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/selection-bindnames.js b/tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js
index 9333ccfacb..9333ccfacb 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/selection-bindnames.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/selection.js b/tests/auto/qml/qqmlsqldatabase/data/selection.js
index 18d4dce80f..18d4dce80f 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/selection.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/selection.js
diff --git a/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro b/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro
new file mode 100644
index 0000000000..c17e16bfdd
--- /dev/null
+++ b/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlsqldatabase
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlsqldatabase.cpp
+
+include (../../shared/util.pri)
+
+CONFIG += parallel_test
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private v8-private qml-private quick-private sql testlib
diff --git a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
new file mode 100644
index 0000000000..c1a8a63a4d
--- /dev/null
+++ b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <private/qqmlengine_p.h>
+#include <QtCore/qcryptographichash.h>
+/*
+#include <QtWebKit/qwebpage.h>
+#include <QtWebKit/qwebframe.h>
+#include <QtWebKit/qwebdatabase.h>
+#include <QtWebKit/qwebsecurityorigin.h>
+*/
+#include <QtSql/qsqldatabase.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include "../../shared/util.h"
+
+class tst_qqmlsqldatabase : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlsqldatabase()
+ {
+ qApp->setApplicationName("tst_qqmlsqldatabase");
+ qApp->setOrganizationName("Nokia");
+ qApp->setOrganizationDomain("nokia.com");
+ engine = new QQmlEngine;
+ }
+
+ ~tst_qqmlsqldatabase()
+ {
+ delete engine;
+ }
+
+private slots:
+ void initTestCase();
+
+ void checkDatabasePath();
+
+ void testQml_data();
+ void testQml();
+ void testQml_cleanopen_data();
+ void testQml_cleanopen();
+ void totalDatabases();
+
+ void cleanupTestCase();
+
+private:
+ QString dbDir() const;
+ QQmlEngine *engine;
+};
+
+void removeRecursive(const QString& dirname)
+{
+ QDir dir(dirname);
+ QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
+ for (int i = 0; i < entries.count(); ++i)
+ if (entries[i].isDir())
+ removeRecursive(entries[i].filePath());
+ else
+ dir.remove(entries[i].fileName());
+ QDir().rmdir(dirname);
+}
+
+void tst_qqmlsqldatabase::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ removeRecursive(dbDir());
+ QDir().mkpath(dbDir());
+}
+
+void tst_qqmlsqldatabase::cleanupTestCase()
+{
+ removeRecursive(dbDir());
+}
+
+QString tst_qqmlsqldatabase::dbDir() const
+{
+ static QString tmpd = QDir::tempPath()+"/tst_qqmlsqldatabase_output-"
+ + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
+ return tmpd;
+}
+
+void tst_qqmlsqldatabase::checkDatabasePath()
+{
+ // Check default storage path (we can't use it since we don't want to mess with user's data)
+ QVERIFY(engine->offlineStoragePath().contains("tst_qqmlsqldatabase"));
+ QVERIFY(engine->offlineStoragePath().contains("OfflineStorage"));
+}
+
+static const int total_databases_created_by_tests = 12;
+void tst_qqmlsqldatabase::testQml_data()
+{
+ QTest::addColumn<QString>("jsfile"); // The input file
+
+ // Each test should use a newly named DB to avoid inter-test dependencies
+ QTest::newRow("creation") << "creation.js";
+ QTest::newRow("creation-a") << "creation-a.js";
+ QTest::newRow("creation") << "creation.js";
+ QTest::newRow("error-creation") << "error-creation.js"; // re-uses above DB
+ QTest::newRow("changeversion") << "changeversion.js";
+ QTest::newRow("readonly") << "readonly.js";
+ QTest::newRow("readonly-error") << "readonly-error.js";
+ QTest::newRow("selection") << "selection.js";
+ QTest::newRow("selection-bindnames") << "selection-bindnames.js";
+ QTest::newRow("iteration") << "iteration.js";
+ QTest::newRow("iteration-forwardonly") << "iteration-forwardonly.js";
+ QTest::newRow("error-a") << "error-a.js";
+ QTest::newRow("error-notransaction") << "error-notransaction.js";
+ QTest::newRow("error-outsidetransaction") << "error-outsidetransaction.js"; // reuse above
+ QTest::newRow("reopen1") << "reopen1.js";
+ QTest::newRow("reopen2") << "reopen2.js"; // re-uses above DB
+
+ // If you add a test, you should usually use a new database in the
+ // test - in which case increment total_databases_created_by_tests above.
+}
+
+/*
+class QWebPageWithJavaScriptConsoleMessages : public QWebPage {
+public:
+ void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
+ {
+ qWarning() << sourceID << ":" << lineNumber << ":" << message;
+ }
+};
+
+void tst_qqmlsqldatabase::validateAgainstWebkit()
+{
+ // Validates tests against WebKit (HTML5) support.
+ //
+ QFETCH(QString, jsfile);
+ QFETCH(QString, result);
+ QFETCH(int, databases);
+
+ QFile f(jsfile);
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ QString js=f.readAll();
+
+ QWebPageWithJavaScriptConsoleMessages webpage;
+ webpage.settings()->setOfflineStoragePath(dbDir());
+ webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
+
+ QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue);
+ QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result);
+
+ QTest::qWait(100); // WebKit crashes if you quit it too fast
+
+ QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin();
+ QList<QWebDatabase> dbs = origin.databases();
+ QCOMPARE(dbs.count(), databases);
+}
+*/
+
+void tst_qqmlsqldatabase::testQml()
+{
+ // Tests QML SQL Database support with tests
+ // that have been validated against Webkit.
+ //
+ QFETCH(QString, jsfile);
+
+ QString qml=
+ "import QtQuick 2.0\n"
+ "import \""+jsfile+"\" as JS\n"
+ "Text { text: JS.test() }";
+
+ engine->setOfflineStoragePath(dbDir());
+ QQmlComponent component(engine);
+ component.setData(qml.toUtf8(), testFileUrl("empty.qml")); // just a file for relative local imports
+ QVERIFY(!component.isError());
+ QQuickText *text = qobject_cast<QQuickText*>(component.create());
+ QVERIFY(text != 0);
+ QCOMPARE(text->text(),QString("passed"));
+}
+
+void tst_qqmlsqldatabase::testQml_cleanopen_data()
+{
+ QTest::addColumn<QString>("jsfile"); // The input file
+ QTest::newRow("reopen1") << "reopen1.js";
+ QTest::newRow("reopen2") << "reopen2.js";
+ QTest::newRow("error-creation") << "error-creation.js"; // re-uses creation DB
+}
+
+void tst_qqmlsqldatabase::testQml_cleanopen()
+{
+ // Same as testQml, but clean connections between tests,
+ // making it more like the tests are running in new processes.
+ testQml();
+
+ engine->collectGarbage();
+
+ foreach (QString dbname, QSqlDatabase::connectionNames()) {
+ QSqlDatabase::removeDatabase(dbname);
+ }
+}
+
+void tst_qqmlsqldatabase::totalDatabases()
+{
+ QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2);
+}
+
+QTEST_MAIN(tst_qqmlsqldatabase)
+
+#include "tst_qqmlsqldatabase.moc"
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/idtranslation.qml b/tests/auto/qml/qqmltranslation/data/idtranslation.qml
index b128a1e578..b128a1e578 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/idtranslation.qml
+++ b/tests/auto/qml/qqmltranslation/data/idtranslation.qml
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/qml_fr.qm b/tests/auto/qml/qqmltranslation/data/qml_fr.qm
index 252022515a..252022515a 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/qml_fr.qm
+++ b/tests/auto/qml/qqmltranslation/data/qml_fr.qm
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/qml_fr.ts b/tests/auto/qml/qqmltranslation/data/qml_fr.ts
index b003e239bc..b003e239bc 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/qml_fr.ts
+++ b/tests/auto/qml/qqmltranslation/data/qml_fr.ts
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.qm b/tests/auto/qml/qqmltranslation/data/qmlid_fr.qm
index 265164916f..265164916f 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.qm
+++ b/tests/auto/qml/qqmltranslation/data/qmlid_fr.qm
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.ts b/tests/auto/qml/qqmltranslation/data/qmlid_fr.ts
index bff39b80b6..bff39b80b6 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.ts
+++ b/tests/auto/qml/qqmltranslation/data/qmlid_fr.ts
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/translation.qml b/tests/auto/qml/qqmltranslation/data/translation.qml
index 8435bedb28..8435bedb28 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/translation.qml
+++ b/tests/auto/qml/qqmltranslation/data/translation.qml
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/translation.qrc b/tests/auto/qml/qqmltranslation/data/translation.qrc
index 2e2d0a0497..2e2d0a0497 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/translation.qrc
+++ b/tests/auto/qml/qqmltranslation/data/translation.qrc
diff --git a/tests/auto/qml/qqmltranslation/qqmltranslation.pro b/tests/auto/qml/qqmltranslation/qqmltranslation.pro
new file mode 100644
index 0000000000..d3f98e181f
--- /dev/null
+++ b/tests/auto/qml/qqmltranslation/qqmltranslation.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qqmltranslation
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmltranslation.cpp
+RESOURCES += data/translation.qrc
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
new file mode 100644
index 0000000000..077fa18f5f
--- /dev/null
+++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QTranslator>
+#include "../../shared/util.h"
+
+class tst_qqmltranslation : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmltranslation() {}
+
+private slots:
+ void translation();
+ void idTranslation();
+ void translationInQrc();
+};
+
+void tst_qqmltranslation::translation()
+{
+ QTranslator translator;
+ translator.load(QLatin1String("qml_fr"), dataDirectory());
+ QCoreApplication::installTranslator(&translator);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("translation.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir"));
+ QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut"));
+ QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard"));
+ QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut"));
+ QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir"));
+ QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard"));
+ QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard"));
+ QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards"));
+ QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards"));
+
+ QCoreApplication::removeTranslator(&translator);
+ delete object;
+}
+
+void tst_qqmltranslation::idTranslation()
+{
+ QTranslator translator;
+ translator.load(QLatin1String("qmlid_fr"), dataDirectory());
+ QCoreApplication::installTranslator(&translator);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("idtranslation.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("idTranslation").toString(), QLatin1String("bonjour tout le monde"));
+ QCOMPARE(object->property("idTranslation2").toString(), QLatin1String("bonjour tout le monde"));
+ QCOMPARE(object->property("idTranslation3").toString(), QLatin1String("bonjour tout le monde"));
+
+ QCoreApplication::removeTranslator(&translator);
+ delete object;
+}
+
+void tst_qqmltranslation::translationInQrc()
+{
+ QTranslator translator;
+ translator.load(":/qml_fr.qm");
+ QCoreApplication::installTranslator(&translator);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:/translation.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir"));
+ QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut"));
+ QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard"));
+ QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut"));
+ QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir"));
+ QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard"));
+ QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard"));
+ QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards"));
+ QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards"));
+
+ QCoreApplication::removeTranslator(&translator);
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmltranslation)
+
+#include "tst_qqmltranslation.moc"
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml
index f625d081e5..f625d081e5 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml
index 0bdccce5be..0bdccce5be 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml
index 151c49971e..151c49971e 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml
index ce2e82d0f8..ce2e82d0f8 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml
index d431b4ae08..d431b4ae08 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml
index a8a72f515b..a8a72f515b 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
index a65218669b..a65218669b 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml
index fd25c9f0a7..fd25c9f0a7 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml
index 538d776fba..538d776fba 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml
index 3a48c8bdb1..3a48c8bdb1 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml
index 2a1b936da6..2a1b936da6 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml
index 84b465c565..84b465c565 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml
index f1212f8039..f1212f8039 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml
index 9c5e950660..9c5e950660 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml
index 7d87ba1782..7d87ba1782 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml
index 8701dae612..8701dae612 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml b/tests/auto/qml/qqmlvaluetypes/data/color_read.qml
index bc92b1e5f9..bc92b1e5f9 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml b/tests/auto/qml/qqmlvaluetypes/data/color_write.qml
index 3f1bad4aa6..3f1bad4aa6 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml
index 923922c55a..923922c55a 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml
index 9804af4df6..9804af4df6 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml
index b5bb7f8ccc..b5bb7f8ccc 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js
index af298ffbd0..af298ffbd0 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js
+++ b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml
index 4f7ad39db0..4f7ad39db0 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml
index cb01a80669..cb01a80669 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml
index 93f1ed59bc..93f1ed59bc 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml
index cc7861a122..cc7861a122 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml
index cf41c90b90..cf41c90b90 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml
index de279dba6c..de279dba6c 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml
index efbb0e3d0b..efbb0e3d0b 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml b/tests/auto/qml/qqmlvaluetypes/data/font_read.qml
index d73bb132d3..d73bb132d3 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml
index b559389efb..b559389efb 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml
index 913ac50738..913ac50738 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml
index 2ec69d7281..2ec69d7281 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml
index 5297a8260d..5297a8260d 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml
index ff4d0a1004..ff4d0a1004 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml
index 94292302cc..94292302cc 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml
index 6c4a68258c..6c4a68258c 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml
index 2a9f154d6f..2a9f154d6f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml b/tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml
index 0ffa5eb666..0ffa5eb666 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml
index c0041b4bb1..c0041b4bb1 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml b/tests/auto/qml/qqmlvaluetypes/data/point_read.qml
index 4bb6c5384c..4bb6c5384c 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml b/tests/auto/qml/qqmlvaluetypes/data/point_write.qml
index 063525a6f0..063525a6f0 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml
index 0d70137934..0d70137934 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml
index 0eab6daabe..0eab6daabe 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml
index 9ee3fc1bda..9ee3fc1bda 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml
index 0e82f596af..0e82f596af 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml
index d1a21dc926..d1a21dc926 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml
index 0c3e5afd98..0c3e5afd98 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml
index c511c2dfc4..c511c2dfc4 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml
index c3b37a7099..c3b37a7099 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml
index 8add45305c..8add45305c 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml
index 6ac4049558..6ac4049558 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml
index 6ff3ce30bf..6ff3ce30bf 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml
index 1e6ff4ff90..1e6ff4ff90 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml b/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml
index 1f9816f666..1f9816f666 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml b/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml
index cbecb4379a..cbecb4379a 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml b/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml
index 42fccfac5a..42fccfac5a 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml
index 1fd4711c15..1fd4711c15 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml b/tests/auto/qml/qqmlvaluetypes/data/size_read.qml
index a49fd9f760..a49fd9f760 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml b/tests/auto/qml/qqmlvaluetypes/data/size_write.qml
index 2f9d10e45f..2f9d10e45f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml
index c74a049454..c74a049454 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml
index 96cd425f17..96cd425f17 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml
index f16f0bdf93..f16f0bdf93 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml
index 7f708a0899..7f708a0899 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml
index 3254557014..3254557014 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml
index 656d718b05..656d718b05 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml
index b8e3f0d41b..b8e3f0d41b 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml
index 68b54b571e..68b54b571e 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml
index b687f89eef..b687f89eef 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml b/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml
index 0897847d2d..0897847d2d 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml b/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml
index 717f3502c0..717f3502c0 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml
index 9b56abbbed..9b56abbbed 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml
index a08f3db94f..a08f3db94f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml
index eb8fb5bb76..eb8fb5bb76 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml
index fc315f7abf..fc315f7abf 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml
index f0e35ff200..f0e35ff200 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml
index 7bda1d17f4..7bda1d17f4 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml
index f1e876dbb9..f1e876dbb9 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml
index 9c1bf7620a..9c1bf7620a 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml
index 3ea42a59ce..3ea42a59ce 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml
index f9d5d6053e..f9d5d6053e 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml
index 548698126d..548698126d 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml
diff --git a/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro
new file mode 100644
index 0000000000..6051f65936
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qqmlvaluetypes
+macx:CONFIG -= app_bundle
+
+HEADERS += testtypes.h
+
+SOURCES += tst_qqmlvaluetypes.cpp \
+ testtypes.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private testlib
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp b/tests/auto/qml/qqmlvaluetypes/testtypes.cpp
index ef9f268b2f..ef9f268b2f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/testtypes.cpp
diff --git a/tests/auto/qml/qqmlvaluetypes/testtypes.h b/tests/auto/qml/qqmlvaluetypes/testtypes.h
new file mode 100644
index 0000000000..813c58567f
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/testtypes.h
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QObject>
+#include <QPoint>
+#include <QPointF>
+#include <QSize>
+#include <QSizeF>
+#include <QRect>
+#include <QRectF>
+#include <QVector2D>
+#include <QVector3D>
+#include <QVector4D>
+#include <QQuaternion>
+#include <QMatrix4x4>
+#include <QFont>
+#include <QColor>
+#include <qqml.h>
+#include <QQmlPropertyValueSource>
+#include <QQmlProperty>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlpropertyvalueinterceptor_p.h>
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed)
+ Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed)
+ Q_PROPERTY(QPointF pointfpoint READ pointfpoint WRITE setPointfpoint NOTIFY changed)
+ Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed)
+ Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed)
+ Q_PROPERTY(QSizeF sizefsize READ sizefsize WRITE setSizefsize NOTIFY changed)
+ Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed)
+ Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed)
+ Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed)
+ Q_PROPERTY(QRectF rectfrect READ rectfrect WRITE setRectfrect NOTIFY changed)
+ Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed)
+ Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed)
+ Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed)
+ Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed)
+ Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed)
+ Q_PROPERTY(QVariant variant READ variant NOTIFY changed)
+
+public:
+ MyTypeObject() :
+ m_point(10, 4),
+ m_pointf(11.3, -10.9),
+ m_pointfpoint(10.0, 4.0),
+ m_size(1912, 1913),
+ m_sizef(0.1, 100923.2),
+ m_sizefsize(1912.0, 1913.0),
+ m_rect(2, 3, 109, 102),
+ m_rectf(103.8, 99.2, 88.1, 77.6),
+ m_rectfrect(2.0, 3.0, 109.0, 102.0),
+ m_vector2(32.88, 1.3),
+ m_vector(23.88, 3.1, 4.3),
+ m_vector4(54.2, 23.88, 3.1, 4.3),
+ m_quaternion(4.3, 54.2, 23.88, 3.1),
+ m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
+ {
+ m_font.setFamily("Arial");
+ m_font.setBold(true);
+ m_font.setWeight(QFont::DemiBold);
+ m_font.setItalic(true);
+ m_font.setUnderline(true);
+ m_font.setOverline(true);
+ m_font.setStrikeOut(true);
+ m_font.setPointSize(29);
+ m_font.setCapitalization(QFont::AllLowercase);
+ m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
+ m_font.setWordSpacing(19.7);
+ m_color.setRedF(0.2);
+ m_color.setGreenF(0.88);
+ m_color.setBlueF(0.6);
+ m_color.setAlphaF(0.34);
+ }
+
+ QPoint m_point;
+ QPoint point() const { return m_point; }
+ void setPoint(const QPoint &v) { m_point = v; emit changed(); }
+
+ QPointF m_pointf;
+ QPointF pointf() const { return m_pointf; }
+ void setPointf(const QPointF &v) { m_pointf = v; emit changed(); }
+
+ QPointF m_pointfpoint;
+ QPointF pointfpoint() const { return m_pointfpoint; }
+ void setPointfpoint(const QPointF &v) { m_pointfpoint = v; emit changed(); }
+
+ QSize m_size;
+ QSize size() const { return m_size; }
+ void setSize(const QSize &v) { m_size = v; emit changed(); }
+
+ QSizeF m_sizef;
+ QSizeF sizef() const { return m_sizef; }
+ void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); }
+
+ QSizeF m_sizefsize;
+ QSizeF sizefsize() const { return m_sizefsize; }
+ void setSizefsize(const QSizeF &v) { m_sizefsize = v; emit changed(); }
+
+ QRect m_rect;
+ QRect rect() const { return m_rect; }
+ void setRect(const QRect &v) { m_rect = v; emit changed(); }
+
+ QRectF m_rectf;
+ QRectF rectf() const { return m_rectf; }
+ void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
+
+ QRectF m_rectfrect;
+ QRectF rectfrect() const { return m_rectfrect; }
+ void setRectfrect(const QRectF &v) { m_rectfrect = v; emit changed(); }
+
+ QVector2D m_vector2;
+ QVector2D vector2() const { return m_vector2; }
+ void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); }
+
+ QVector3D m_vector;
+ QVector3D vector() const { return m_vector; }
+ void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
+
+ QVector4D m_vector4;
+ QVector4D vector4() const { return m_vector4; }
+ void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); }
+
+ QQuaternion m_quaternion;
+ QQuaternion quaternion() const { return m_quaternion; }
+ void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); }
+
+ QMatrix4x4 m_matrix;
+ QMatrix4x4 matrix() const { return m_matrix; }
+ void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); }
+
+ QFont m_font;
+ QFont font() const { return m_font; }
+ void setFont(const QFont &v) { m_font = v; emit changed(); }
+
+ QColor m_color;
+ QColor color() const { return m_color; }
+ void setColor(const QColor &v) { m_color = v; emit changed(); }
+
+ QVariant variant() const { return sizef(); }
+
+ void emitRunScript() { emit runScript(); }
+
+signals:
+ void changed();
+ void runScript();
+
+public slots:
+ QSize method() { return QSize(13, 14); }
+};
+
+class MyConstantValueSource : public QObject, public QQmlPropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueSource)
+public:
+ virtual void setTarget(const QQmlProperty &p) { p.write(3345); }
+};
+
+class MyOffsetValueInterceptor : public QObject, public QQmlPropertyValueInterceptor
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueInterceptor)
+public:
+ virtual void setTarget(const QQmlProperty &p) { prop = p; }
+ virtual void write(const QVariant &value) { QQmlPropertyPrivate::write(prop, value.toInt() + 13, QQmlPropertyPrivate::BypassInterceptor); }
+
+private:
+ QQmlProperty prop;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
new file mode 100644
index 0000000000..0aa223e733
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -0,0 +1,1319 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+#include <private/qqmlvaluetype_p.h>
+#include "../../shared/util.h"
+#include "testtypes.h"
+
+QT_BEGIN_NAMESPACE
+extern int qt_defaultDpi();
+QT_END_NAMESPACE
+
+class tst_qqmlvaluetypes : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlvaluetypes() {}
+
+private slots:
+ void initTestCase();
+
+ void point();
+ void pointf();
+ void size();
+ void sizef();
+ void sizereadonly();
+ void rect();
+ void rectf();
+ void vector2d();
+ void vector3d();
+ void vector4d();
+ void quaternion();
+ void matrix4x4();
+ void font();
+ void color();
+ void variant();
+
+ void bindingAssignment();
+ void bindingRead();
+ void staticAssignment();
+ void scriptAccess();
+ void autoBindingRemoval();
+ void valueSources();
+ void valueInterceptors();
+ void bindingConflict();
+ void deletedObject();
+ void bindingVariantCopy();
+ void scriptVariantCopy();
+ void cppClasses();
+ void enums();
+ void conflictingBindings();
+ void returnValues();
+ void varAssignment();
+ void bindingsSpliceCorrectly();
+ void nonValueTypeComparison();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlvaluetypes::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+}
+
+void tst_qqmlvaluetypes::point()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("point_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("p_x").toInt(), 10);
+ QCOMPARE(object->property("p_y").toInt(), 4);
+ QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("point_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->point(), QPoint(11, 12));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("point_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QPoint(10, 4)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), true);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("pointEqualsPointf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::pointf()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ 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;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QPointF(11.3, -10.9)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), true);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("pointfEqualsPoint").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::size()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("size_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("size_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->size(), QSize(13, 88));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("size_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QSize(1912, 1913)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), true);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("sizeEqualsSizef").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::sizef()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ 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;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QSizeF(0.1, 100923)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), true);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("sizefEqualsSize").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::variant()
+{
+ QQmlComponent component(&engine, testFileUrl("variant_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ 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;
+}
+
+void tst_qqmlvaluetypes::sizereadonly()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror2.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror3.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror4.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object);
+
+ QCOMPARE(object->property("sizereadonly").toSize(), QSize(1912, 1913));
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::rect()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("r_x").toInt(), 2);
+ QCOMPARE(object->property("r_y").toInt(), 3);
+ QCOMPARE(object->property("r_width").toInt(), 109);
+ QCOMPARE(object->property("r_height").toInt(), 102);
+ QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QRect(2, 3, 109, 102)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), true);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("rectEqualsRectf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::rectf()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ 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;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QRectF(103.8, 99.2, 88.1, 77.6)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), true);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("rectfEqualsRect").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector2d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)32.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)1.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector2D(32.88, 1.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector2(), QVector2D(-0.3, -12.9));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector2D(32.88, 1.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector3d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector3D(23.88, 3.1, 4.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), true);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector4d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_w").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector4D(54.2, 23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector4(), QVector4D(-0.3, -12.9, 907.4, 88.5));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector4D(54.2, 23.88, 3.1, 4.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::quaternion()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_scalar").toDouble(), (float)4.3);
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
+ QCOMPARE(object->property("copy"), QVariant(QQuaternion(4.3, 54.2, 23.88, 3.1)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->quaternion(), QQuaternion(88.5, -0.3, -12.9, 907.4));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QQuaternion(4.3, 54.2, 23.88, 3.1)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::matrix4x4()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_m11").toDouble(), (float)1);
+ QCOMPARE((float)object->property("v_m12").toDouble(), (float)2);
+ QCOMPARE((float)object->property("v_m13").toDouble(), (float)3);
+ QCOMPARE((float)object->property("v_m14").toDouble(), (float)4);
+ QCOMPARE((float)object->property("v_m21").toDouble(), (float)5);
+ QCOMPARE((float)object->property("v_m22").toDouble(), (float)6);
+ QCOMPARE((float)object->property("v_m23").toDouble(), (float)7);
+ QCOMPARE((float)object->property("v_m24").toDouble(), (float)8);
+ QCOMPARE((float)object->property("v_m31").toDouble(), (float)9);
+ QCOMPARE((float)object->property("v_m32").toDouble(), (float)10);
+ QCOMPARE((float)object->property("v_m33").toDouble(), (float)11);
+ QCOMPARE((float)object->property("v_m34").toDouble(), (float)12);
+ QCOMPARE((float)object->property("v_m41").toDouble(), (float)13);
+ QCOMPARE((float)object->property("v_m42").toDouble(), (float)14);
+ QCOMPARE((float)object->property("v_m43").toDouble(), (float)15);
+ QCOMPARE((float)object->property("v_m44").toDouble(), (float)16);
+ QCOMPARE(object->property("copy"),
+ QVariant(QMatrix4x4(1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12,
+ 13, 14, 15, 16)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->matrix(), QMatrix4x4(11, 12, 13, 14,
+ 21, 22, 23, 24,
+ 31, 32, 33, 34,
+ 41, 42, 43, 44));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::font()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("font_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("f_family").toString(), object->font().family());
+ QCOMPARE(object->property("f_bold").toBool(), object->font().bold());
+ QCOMPARE(object->property("f_weight").toInt(), object->font().weight());
+ QCOMPARE(object->property("f_italic").toBool(), object->font().italic());
+ QCOMPARE(object->property("f_underline").toBool(), object->font().underline());
+ QCOMPARE(object->property("f_overline").toBool(), object->font().overline());
+ QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut());
+ QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF());
+ QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.)));
+ QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization());
+ QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing());
+ QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing());
+
+ QCOMPARE(object->property("copy"), QVariant(object->font()));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QFont font;
+ font.setFamily("Helvetica");
+ font.setBold(false);
+ font.setWeight(QFont::Normal);
+ font.setItalic(false);
+ font.setUnderline(false);
+ font.setStrikeOut(false);
+ font.setPointSize(15);
+ font.setCapitalization(QFont::AllLowercase);
+ font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
+ font.setWordSpacing(11.2);
+
+ QFont f = object->font();
+ QCOMPARE(f.family(), font.family());
+ QCOMPARE(f.bold(), font.bold());
+ QCOMPARE(f.weight(), font.weight());
+ QCOMPARE(f.italic(), font.italic());
+ QCOMPARE(f.underline(), font.underline());
+ QCOMPARE(f.strikeOut(), font.strikeOut());
+ QCOMPARE(f.pointSize(), font.pointSize());
+ QCOMPARE(f.capitalization(), font.capitalization());
+ QCOMPARE(f.letterSpacing(), font.letterSpacing());
+ QCOMPARE(f.wordSpacing(), font.wordSpacing());
+
+ delete object;
+ }
+
+ // Test pixelSize
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+
+ // Test pixelSize and pointSize
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.4.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.5.qml"));
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ MyTypeObject *object1 = object->findChild<MyTypeObject *>("object1");
+ QVERIFY(object1 != 0);
+ MyTypeObject *object2 = object->findChild<MyTypeObject *>("object2");
+ QVERIFY(object2 != 0);
+
+ QCOMPARE(object1->font().pixelSize(), 19);
+ QCOMPARE(object2->font().pointSize(), 14);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("font_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QFont(") + object->font().toString() + QLatin1Char(')');
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::color()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("color_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_r").toDouble(), (float)0.2);
+ QCOMPARE((float)object->property("v_g").toDouble(), (float)0.88);
+ QCOMPARE((float)object->property("v_b").toDouble(), (float)0.6);
+ QCOMPARE((float)object->property("v_a").toDouble(), (float)0.34);
+ QColor comparison;
+ comparison.setRedF(0.2);
+ comparison.setGreenF(0.88);
+ comparison.setBlueF(0.6);
+ comparison.setAlphaF(0.34);
+ QCOMPARE(object->property("copy"), QVariant(comparison));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("color_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QColor newColor;
+ newColor.setRedF(0.5);
+ newColor.setGreenF(0.38);
+ newColor.setBlueF(0.3);
+ newColor.setAlphaF(0.7);
+ QCOMPARE(object->color(), newColor);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("color_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QString colorString("#33e199");
+ QCOMPARE(object->property("colorToString").toString(), colorString);
+ QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true);
+ QCOMPARE(object->property("colorEqualsDifferentAlpha").toBool(), false);
+ QCOMPARE(object->property("colorEqualsDifferentRgba").toBool(), false);
+ QCOMPARE(object->property("colorToStringEqualsColorString").toBool(), true);
+ QCOMPARE(object->property("colorToStringEqualsDifferentAlphaString").toBool(), true);
+ QCOMPARE(object->property("colorToStringEqualsDifferentRgbaString").toBool(), false);
+ QCOMPARE(object->property("colorEqualsColorString").toBool(), true); // maintaining behaviour with QtQuick 1.0
+ QCOMPARE(object->property("colorEqualsDifferentAlphaString").toBool(), true); // maintaining behaviour with QtQuick 1.0
+ QCOMPARE(object->property("colorEqualsDifferentRgbaString").toBool(), false);
+
+ QCOMPARE(object->property("equalsColor").toBool(), true);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+
+ // Color == Property and Property == Color should return the same result.
+ QCOMPARE(object->property("equalsColorRHS").toBool(), object->property("equalsColor").toBool());
+ QCOMPARE(object->property("colorEqualsCopy").toBool(), true);
+ QCOMPARE(object->property("copyEqualsColor").toBool(), object->property("colorEqualsCopy").toBool());
+
+ delete object;
+ }
+}
+
+// Test bindings can write to value types
+void tst_qqmlvaluetypes::bindingAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingAssignment.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect().x(), 92);
+
+ delete object;
+}
+
+// Test bindings can read from value types
+void tst_qqmlvaluetypes::bindingRead()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingRead.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 2);
+
+ object->setRect(QRect(19, 3, 88, 2));
+
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+}
+
+// Test static values can assign to value types
+void tst_qqmlvaluetypes::staticAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("staticAssignment.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 9);
+
+ delete object;
+}
+
+// Test scripts can read/write value types
+void tst_qqmlvaluetypes::scriptAccess()
+{
+ QQmlComponent component(&engine, testFileUrl("scriptAccess.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("valuePre").toInt(), 2);
+ QCOMPARE(object->rect().x(), 19);
+ QCOMPARE(object->property("valuePost").toInt(), 19);
+
+ delete object;
+}
+
+// Test that assigning a constant from script removes any binding
+void tst_qqmlvaluetypes::autoBindingRemoval()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(13));
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect().x(), 42);
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect().x(), 42);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(13));
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml"));
+ QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QRect";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ object->setProperty("value", QVariant(QRect(9, 22, 33, 44)));
+
+ QCOMPARE(object->rect(), QRect(9, 22, 33, 44));
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
+
+ object->setProperty("value", QVariant(QRect(19, 3, 4, 8)));
+
+ QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
+
+ delete object;
+ }
+}
+
+// Test that property value sources assign to value types
+void tst_qqmlvaluetypes::valueSources()
+{
+ QQmlComponent component(&engine, testFileUrl("valueSources.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 3345);
+
+ delete object;
+}
+
+static void checkNoErrors(QQmlComponent& component)
+{
+ QList<QQmlError> errors = component.errors();
+ if (errors.isEmpty())
+ return;
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QQmlError &error = errors.at(ii);
+ qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
+ }
+}
+
+// Test that property value interceptors can be applied to value types
+void tst_qqmlvaluetypes::valueInterceptors()
+{
+ QQmlComponent component(&engine, testFileUrl("valueInterceptors.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ checkNoErrors(component);
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->setProperty("value", 99);
+
+ QCOMPARE(object->rect().x(), 112);
+
+ delete object;
+}
+
+// Test that you can't assign a binding to the "root" value type, and a sub-property
+void tst_qqmlvaluetypes::bindingConflict()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingConflict.qml"));
+ QCOMPARE(component.isError(), true);
+}
+
+#define CPP_TEST(type, v) \
+{ \
+ type *t = new type; \
+ QVariant value(v); \
+ t->setValue(value); \
+ QCOMPARE(t->value(), value); \
+ delete t; \
+}
+
+// Test that accessing a reference to a valuetype after the owning object is deleted
+// doesn't crash
+void tst_qqmlvaluetypes::deletedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("deletedObject.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "Test: 2");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QObject *dObject = qvariant_cast<QObject *>(object->property("object"));
+ QVERIFY(dObject != 0);
+ delete dObject;
+
+ QTest::ignoreMessage(QtDebugMsg, "Test: undefined");
+ object->emitRunScript();
+
+ delete object;
+}
+
+// Test that value types can be assigned to another value type property in a binding
+void tst_qqmlvaluetypes::bindingVariantCopy()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingVariantCopy.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
+
+ delete object;
+}
+
+// Test that value types can be assigned to another value type property in script
+void tst_qqmlvaluetypes::scriptVariantCopy()
+{
+ QQmlComponent component(&engine, testFileUrl("scriptVariantCopy.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(2, 3, 109, 102));
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
+
+ delete object;
+}
+
+
+// Test that the value type classes can be used manually
+void tst_qqmlvaluetypes::cppClasses()
+{
+ CPP_TEST(QQmlPointValueType, QPoint(19, 33));
+ CPP_TEST(QQmlPointFValueType, QPointF(33.6, -23));
+ CPP_TEST(QQmlSizeValueType, QSize(-100, 18));
+ CPP_TEST(QQmlSizeFValueType, QSizeF(-100.7, 18.2));
+ CPP_TEST(QQmlRectValueType, QRect(13, 39, 10928, 88));
+ CPP_TEST(QQmlRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
+ CPP_TEST(QQmlVector2DValueType, QVector2D(19.7, 1002));
+ CPP_TEST(QQmlVector3DValueType, QVector3D(18.2, 19.7, 1002));
+ CPP_TEST(QQmlVector4DValueType, QVector4D(18.2, 19.7, 1002, 54));
+ CPP_TEST(QQmlQuaternionValueType, QQuaternion(18.2, 19.7, 1002, 54));
+ CPP_TEST(QQmlMatrix4x4ValueType,
+ QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
+ CPP_TEST(QQmlFontValueType, QFont("Helvetica"));
+
+}
+
+void tst_qqmlvaluetypes::enums()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.1.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.4.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.5.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+}
+
+// Tests switching between "conflicting" bindings (eg. a binding on the core
+// property, to a binding on the value-type sub-property)
+void tst_qqmlvaluetypes::conflictingBindings()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 24);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::returnValues()
+{
+ QQmlComponent component(&engine, testFileUrl("returnValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("size").toSize(), QSize(13, 14));
+
+ delete object;
+}
+
+void tst_qqmlvaluetypes::varAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("varAssignment.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("x").toInt(), 1);
+ QCOMPARE(object->property("y").toInt(), 2);
+ QCOMPARE(object->property("z").toInt(), 3);
+
+ delete object;
+}
+
+// Test bindings splice together correctly
+void tst_qqmlvaluetypes::bindingsSpliceCorrectly()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::nonValueTypeComparison()
+{
+ QQmlComponent component(&engine, testFileUrl("nonValueTypeComparison.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmlvaluetypes)
+
+#include "tst_qqmlvaluetypes.moc"
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect b/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect
index d6951a8255..d6951a8255 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort.qml
index 9ba97fac4b..9ba97fac4b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply b/tests/auto/qml/qqmlxmlhttprequest/data/abort.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml
index d5bb84ddc0..d5bb84ddc0 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml
index 4f58062a26..4f58062a26 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml b/tests/auto/qml/qqmlxmlhttprequest/data/attr.qml
index b1c081c5fd..b1c081c5fd 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/attr.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml b/tests/auto/qml/qqmlxmlhttprequest/data/attr.xml
index 2aa64a3d00..2aa64a3d00 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/attr.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml b/tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml
index ee1043f97f..ee1043f97f 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml
index f558fdadc6..f558fdadc6 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml
index 061d37c0b6..061d37c0b6 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml b/tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml
index 458066736e..458066736e 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml b/tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml
index 913fe59f99..913fe59f99 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml b/tests/auto/qml/qqmlxmlhttprequest/data/document.qml
index 7695cd76a1..7695cd76a1 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/document.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml b/tests/auto/qml/qqmlxmlhttprequest/data/document.xml
index fb693ea193..fb693ea193 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/document.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml b/tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml
index 092db3443d..092db3443d 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml b/tests/auto/qml/qqmlxmlhttprequest/data/element.qml
index 9b190f3a43..9b190f3a43 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/element.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml b/tests/auto/qml/qqmlxmlhttprequest/data/element.xml
index 071ffae057..071ffae057 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/element.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml
index 580688b835..580688b835 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml
index 84a0bf3015..84a0bf3015 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml
index 27edb4c4b7..27edb4c4b7 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml
index 3d57348cc5..3d57348cc5 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect
index cf5830ed0c..cf5830ed0c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml
index 203967e539..203967e539 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply
index c4b4bb2763..c4b4bb2763 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml
index dccc71dfc3..dccc71dfc3 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml
index cff7af79e2..cff7af79e2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml
index ad2ea0bd33..ad2ea0bd33 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml b/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml
index b3a54e9b53..b3a54e9b53 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml
index 5a4093b9f1..5a4093b9f1 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open.qml
index 6e7681dfb4..6e7681dfb4 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml
index 61ef76d488..61ef76d488 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml
index 677759ccf3..677759ccf3 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml
index 0f29031e42..0f29031e42 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect
index cf5830ed0c..cf5830ed0c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml
index eafdda761f..eafdda761f 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml
index 4eaef536b3..4eaef536b3 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml
index b8ce5361f3..b8ce5361f3 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml
index e5c7b74553..e5c7b74553 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml
index 0894573ecc..0894573ecc 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml
index 003d1954e9..003d1954e9 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html b/tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html
index 95f35e01c7..95f35e01c7 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml
index 4b216d9c85..4b216d9c85 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml b/tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml
index e9265e09ef..e9265e09ef 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html b/tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html
index a33f44bcb5..a33f44bcb5 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml
index 4e0caa7171..4e0caa7171 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect
index 9c07d4b633..9c07d4b633 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml
index 6faac0242f..6faac0242f 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml
index 383a76e75e..383a76e75e 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml
index 5cb8c926c2..5cb8c926c2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect
index c2aba77881..c2aba77881 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml
index 884661c8ce..884661c8ce 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml
index c031b84418..c031b84418 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect
index b09b1bcec5..b09b1bcec5 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml
index 42eb360d14..42eb360d14 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml
index 5dc252f970..5dc252f970 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml
index 336971c919..336971c919 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect
index dd86b837f4..dd86b837f4 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect
index cf5830ed0c..cf5830ed0c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect
index 7b7b282660..7b7b282660 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml
index ef56517bf5..ef56517bf5 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect
index e7f8e10780..e7f8e10780 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml
index 4229584af2..4229584af2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml
index 1cef3e43da..1cef3e43da 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml
index e03f73431a..e03f73431a 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml
index cd047cf8dd..cd047cf8dd 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml
index 49888fdac8..49888fdac8 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml
index f528aa912c..f528aa912c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml b/tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml
index 1b701e90ff..1b701e90ff 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.400.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply
index e3f6944173..e3f6944173 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.400.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply
index 2e29f56d41..2e29f56d41 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect b/tests/auto/qml/qqmlxmlhttprequest/data/status.expect
index cf5830ed0c..cf5830ed0c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml
index f5e10d79ad..f5e10d79ad 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml
index e7f658fc29..e7f658fc29 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html b/tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html
index 8fe0f4b0e2..8fe0f4b0e2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml b/tests/auto/qml/qqmlxmlhttprequest/data/text.qml
index b79e0bc7b1..b79e0bc7b1 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/text.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml b/tests/auto/qml/qqmlxmlhttprequest/data/text.xml
index e7416888fd..e7416888fd 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/text.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.html
index b640733f1e..b640733f1e 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.html
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml
index 7c024bfda6..7c024bfda6 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml
index 0fbb126ed8..0fbb126ed8 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml
Binary files differ
diff --git a/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro b/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro
new file mode 100644
index 0000000000..ed016fd9b6
--- /dev/null
+++ b/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro
@@ -0,0 +1,19 @@
+CONFIG += testcase
+TARGET = tst_qqmlxmlhttprequest
+macx:CONFIG -= app_bundle
+
+INCLUDEPATH += ../../shared/
+HEADERS += ../../shared/testhttpserver.h
+
+SOURCES += tst_qqmlxmlhttprequest.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
new file mode 100644
index 0000000000..f8d74c3cde
--- /dev/null
+++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
@@ -0,0 +1,1160 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+#include <QScopedPointer>
+#include <QNetworkCookieJar>
+#include "testhttpserver.h"
+#include "../../shared/util.h"
+
+#define SERVER_PORT 14445
+
+class tst_qqmlxmlhttprequest : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlxmlhttprequest() {}
+
+private slots:
+ void domExceptionCodes();
+ void callbackException();
+ void callbackException_data();
+ void staticStateValues();
+ void instanceStateValues();
+ void constructor();
+ void defaultState();
+ void open();
+ void open_data();
+ void open_invalid_method();
+ void open_sync();
+ void open_arg_count();
+ void setRequestHeader();
+ void setRequestHeader_caseInsensitive();
+ void setRequestHeader_unsent();
+ void setRequestHeader_illegalName_data();
+ void setRequestHeader_illegalName();
+ void setRequestHeader_sent();
+ void setRequestHeader_args();
+ void send_unsent();
+ void send_alreadySent();
+ void send_ignoreData();
+ void send_withdata();
+ void send_withdata_data();
+ void abort();
+ void abort_unsent();
+ void abort_opened();
+ void getResponseHeader();
+ void getResponseHeader_unsent();
+ void getResponseHeader_sent();
+ void getResponseHeader_args();
+ void getAllResponseHeaders();
+ void getAllResponseHeaders_unsent();
+ void getAllResponseHeaders_sent();
+ void getAllResponseHeaders_args();
+ void status();
+ void status_data();
+ void statusText();
+ void statusText_data();
+ void responseText();
+ void responseText_data();
+ void responseXML_invalid();
+ void invalidMethodUsage();
+ void redirects();
+ void nonUtf8();
+ void nonUtf8_data();
+
+ // Attributes
+ void document();
+ void element();
+ void attr();
+ void text();
+ void cdata();
+
+ // Crashes
+ // void outstanding_request_at_shutdown();
+
+ // void network_errors()
+ // void readyState()
+
+private:
+ QQmlEngine engine;
+};
+
+// Test that the dom exception codes are correct
+void tst_qqmlxmlhttprequest::domExceptionCodes()
+{
+ QQmlComponent component(&engine, testFileUrl("domExceptionCodes.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("index_size_err").toInt(), 1);
+ QCOMPARE(object->property("domstring_size_err").toInt(), 2);
+ QCOMPARE(object->property("hierarchy_request_err").toInt(), 3);
+ QCOMPARE(object->property("wrong_document_err").toInt(), 4);
+ QCOMPARE(object->property("invalid_character_err").toInt(), 5);
+ QCOMPARE(object->property("no_data_allowed_err").toInt(), 6);
+ QCOMPARE(object->property("no_modification_allowed_err").toInt(), 7);
+ QCOMPARE(object->property("not_found_err").toInt(), 8);
+ QCOMPARE(object->property("not_supported_err").toInt(), 9);
+ QCOMPARE(object->property("inuse_attribute_err").toInt(), 10);
+ QCOMPARE(object->property("invalid_state_err").toInt(), 11);
+ QCOMPARE(object->property("syntax_err").toInt(), 12);
+ QCOMPARE(object->property("invalid_modification_err").toInt(), 13);
+ QCOMPARE(object->property("namespace_err").toInt(), 14);
+ QCOMPARE(object->property("invalid_access_err").toInt(), 15);
+ QCOMPARE(object->property("validation_err").toInt(), 16);
+ QCOMPARE(object->property("type_mismatch_err").toInt(), 17);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::callbackException_data()
+{
+ QTest::addColumn<QString>("which");
+ QTest::addColumn<int>("line");
+
+ QTest::newRow("on-opened") << "1" << 15;
+ QTest::newRow("on-loading") << "3" << 15;
+ QTest::newRow("on-done") << "4" << 15;
+}
+
+void tst_qqmlxmlhttprequest::callbackException()
+{
+ // Test exception reporting for exceptions thrown at various points.
+
+ QFETCH(QString, which);
+ QFETCH(int, line);
+
+ QString expect = testFileUrl("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QQmlComponent component(&engine, testFileUrl("callbackException.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ object->setProperty("which", which);
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("threw").toBool() == true);
+
+ delete object;
+}
+
+// Test that the state value properties on the XMLHttpRequest constructor have the correct values.
+// ### WebKit does not do this, but it seems to fit the standard and QML better
+void tst_qqmlxmlhttprequest::staticStateValues()
+{
+ QQmlComponent component(&engine, testFileUrl("staticStateValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("unsent").toInt(), 0);
+ QCOMPARE(object->property("opened").toInt(), 1);
+ QCOMPARE(object->property("headers_received").toInt(), 2);
+ QCOMPARE(object->property("loading").toInt(), 3);
+ QCOMPARE(object->property("done").toInt(), 4);
+
+ delete object;
+}
+
+// Test that the state value properties on instances have the correct values.
+void tst_qqmlxmlhttprequest::instanceStateValues()
+{
+ QQmlComponent component(&engine, testFileUrl("instanceStateValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("unsent").toInt(), 0);
+ QCOMPARE(object->property("opened").toInt(), 1);
+ QCOMPARE(object->property("headers_received").toInt(), 2);
+ QCOMPARE(object->property("loading").toInt(), 3);
+ QCOMPARE(object->property("done").toInt(), 4);
+
+ delete object;
+}
+
+// Test calling constructor
+void tst_qqmlxmlhttprequest::constructor()
+{
+ QQmlComponent component(&engine, testFileUrl("constructor.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("calledAsConstructor").toBool(), true);
+ QCOMPARE(object->property("calledAsFunction").toBool(), true);
+
+ delete object;
+}
+
+// Test that all the properties are set correctly before any request is sent
+void tst_qqmlxmlhttprequest::defaultState()
+{
+ QQmlComponent component(&engine, testFileUrl("defaultState.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("readState").toInt(), 0);
+ QCOMPARE(object->property("statusIsException").toBool(), true);
+ QCOMPARE(object->property("statusTextIsException").toBool(), true);
+ QCOMPARE(object->property("responseText").toString(), QString());
+ QCOMPARE(object->property("responseXMLIsNull").toBool(), true);
+
+ delete object;
+}
+
+// Test valid XMLHttpRequest.open() calls
+void tst_qqmlxmlhttprequest::open()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QString, url);
+ QFETCH(bool, remote);
+
+ QScopedPointer<TestHTTPServer> server; // ensure deletion in case test fails
+ if (remote) {
+ server.reset(new TestHTTPServer(SERVER_PORT));
+ QVERIFY(server->isValid());
+ QVERIFY(server->wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
+ }
+
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", url);
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::open_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QString>("url");
+ QTest::addColumn<bool>("remote");
+
+ QTest::newRow("Relative url)") << testFileUrl("open.qml") << "testdocument.html" << false;
+ QTest::newRow("Absolute url)") << testFileUrl("open.qml") << testFileUrl("testdocument.html").toString() << false;
+ QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+
+ // ### Check that the username/password were sent to the server
+ QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+}
+
+// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
+void tst_qqmlxmlhttprequest::open_invalid_method()
+{
+ QQmlComponent component(&engine, testFileUrl("open_invalid_method.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Test that calling XMLHttpRequest.open() with sync raises an exception
+void tst_qqmlxmlhttprequest::open_sync()
+{
+ QQmlComponent component(&engine, testFileUrl("open_sync.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Calling with incorrect arg count raises an exception
+void tst_qqmlxmlhttprequest::open_arg_count()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("open_arg_count.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("open_arg_count.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+ }
+}
+
+// Test valid setRequestHeader() calls
+void tst_qqmlxmlhttprequest::setRequestHeader()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
+ testFileUrl("setRequestHeader.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test valid setRequestHeader() calls with different header cases
+void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
+ testFileUrl("setRequestHeader.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+// Test setting headers before open() throws exception
+void tst_qqmlxmlhttprequest::setRequestHeader_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::setRequestHeader_illegalName_data()
+{
+ QTest::addColumn<QString>("name");
+
+ QTest::newRow("Accept-Charset") << "AccePT-CHArset";
+ QTest::newRow("Accept-Encoding") << "AccEpt-EnCOding";
+ QTest::newRow("Connection") << "ConnECtion";
+ QTest::newRow("Content-Length") << "ContEnt-LenGth";
+ QTest::newRow("Cookie") << "CookIe";
+ QTest::newRow("Cookie2") << "CoOkie2";
+ QTest::newRow("Content-Transfer-Encoding") << "ConteNT-tRANSFER-eNCOding";
+ QTest::newRow("Date") << "DaTE";
+ QTest::newRow("Expect") << "ExPect";
+ QTest::newRow("Host") << "HoST";
+ QTest::newRow("Keep-Alive") << "KEEP-aLive";
+ QTest::newRow("Referer") << "ReferEr";
+ QTest::newRow("TE") << "Te";
+ QTest::newRow("Trailer") << "TraILEr";
+ QTest::newRow("Transfer-Encoding") << "tRANsfer-Encoding";
+ QTest::newRow("Upgrade") << "UpgrADe";
+ QTest::newRow("User-Agent") << "uSEr-Agent";
+ QTest::newRow("Via") << "vIa";
+ QTest::newRow("Proxy-") << "ProXy-";
+ QTest::newRow("Sec-") << "SeC-";
+ QTest::newRow("Proxy-*") << "Proxy-BLAH";
+ QTest::newRow("Sec-*") << "Sec-F";
+}
+
+// Tests that using illegal header names has no effect
+void tst_qqmlxmlhttprequest::setRequestHeader_illegalName()
+{
+ QFETCH(QString, name);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("header", name);
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test that attempting to set a header after a request is sent throws an exception
+void tst_qqmlxmlhttprequest::setRequestHeader_sent()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_sent.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qqmlxmlhttprequest::setRequestHeader_args()
+{
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Test that calling send() in UNSENT state throws an exception
+void tst_qqmlxmlhttprequest::send_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("send_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test attempting to resend a sent request throws an exception
+void tst_qqmlxmlhttprequest::send_alreadySent()
+{
+ QQmlComponent component(&engine, testFileUrl("send_alreadySent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test that sends for GET, HEAD and DELETE ignore data
+void tst_qqmlxmlhttprequest::send_ignoreData()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"),
+ testFileUrl("send_ignoreData.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "GET");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"),
+ testFileUrl("send_ignoreData.reply"),
+ QUrl()));
+
+ QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "HEAD");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"),
+ testFileUrl("send_ignoreData.reply"),
+ QUrl()));
+
+ QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "DELETE");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+}
+
+// Test that send()'ing data works
+void tst_qqmlxmlhttprequest::send_withdata()
+{
+ QFETCH(QString, file_expected);
+ QFETCH(QString, file_qml);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl(file_expected),
+ testFileUrl("send_data.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl(file_qml));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::send_withdata_data()
+{
+ QTest::addColumn<QString>("file_expected");
+ QTest::addColumn<QString>("file_qml");
+
+ QTest::newRow("No content-type") << "send_data.1.expect" << "send_data.1.qml";
+ QTest::newRow("Correct content-type") << "send_data.1.expect" << "send_data.2.qml";
+ QTest::newRow("Incorrect content-type") << "send_data.1.expect" << "send_data.3.qml";
+ QTest::newRow("Correct content-type - out of order") << "send_data.4.expect" << "send_data.4.qml";
+ QTest::newRow("Incorrect content-type - out of order") << "send_data.4.expect" << "send_data.5.qml";
+ QTest::newRow("PUT") << "send_data.6.expect" << "send_data.6.qml";
+ QTest::newRow("Correct content-type - no charset") << "send_data.1.expect" << "send_data.7.qml";
+}
+
+// Test abort() has no effect in unsent state
+void tst_qqmlxmlhttprequest::abort_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("abort_unsent.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test abort() cancels an open (but unsent) request
+void tst_qqmlxmlhttprequest::abort_opened()
+{
+ QQmlComponent component(&engine, testFileUrl("abort_opened.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test abort() aborts in progress send
+void tst_qqmlxmlhttprequest::abort()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("abort.expect"),
+ testFileUrl("abort.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("abort.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("seenDone").toBool(), true);
+ QCOMPARE(object->property("didNotSeeUnsent").toBool(), true);
+ QCOMPARE(object->property("endStateUnsent").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::getResponseHeader()
+{
+ QQmlEngine engine; // Avoid cookie contamination
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
+ testFileUrl("getResponseHeader.reply"),
+ testFileUrl("testdocument.html")));
+
+
+ QQmlComponent component(&engine, testFileUrl("getResponseHeader.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("headersReceivedState").toBool(), true);
+ QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedValidHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedMultiValidHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedCookieHeader").toBool(), true);
+
+ QCOMPARE(object->property("doneState").toBool(), true);
+ QCOMPARE(object->property("doneNullHeader").toBool(), true);
+ QCOMPARE(object->property("doneValidHeader").toBool(), true);
+ QCOMPARE(object->property("doneMultiValidHeader").toBool(), true);
+ QCOMPARE(object->property("doneCookieHeader").toBool(), true);
+
+ delete object;
+}
+
+// Test getResponseHeader throws an exception in an invalid state
+void tst_qqmlxmlhttprequest::getResponseHeader_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("getResponseHeader_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test getResponseHeader throws an exception in an invalid state
+void tst_qqmlxmlhttprequest::getResponseHeader_sent()
+{
+ QQmlComponent component(&engine, testFileUrl("getResponseHeader_sent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qqmlxmlhttprequest::getResponseHeader_args()
+{
+ QQmlComponent component(&engine, testFileUrl("getResponseHeader_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::getAllResponseHeaders()
+{
+ QQmlEngine engine; // Avoid cookie contamination
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
+ testFileUrl("getResponseHeader.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("headersReceivedState").toBool(), true);
+ QCOMPARE(object->property("headersReceivedHeader").toBool(), true);
+
+ QCOMPARE(object->property("doneState").toBool(), true);
+ QCOMPARE(object->property("doneHeader").toBool(), true);
+
+ delete object;
+}
+
+// Test getAllResponseHeaders throws an exception in an invalid state
+void tst_qqmlxmlhttprequest::getAllResponseHeaders_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test getAllResponseHeaders throws an exception in an invalid state
+void tst_qqmlxmlhttprequest::getAllResponseHeaders_sent()
+{
+ QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_sent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qqmlxmlhttprequest::getAllResponseHeaders_args()
+{
+ QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::status()
+{
+ QFETCH(QUrl, replyUrl);
+ QFETCH(int, status);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("status.expect"),
+ replyUrl,
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("status.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", status);
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::status_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<int>("status");
+
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << 200;
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << 404;
+ QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << 400;
+}
+
+void tst_qqmlxmlhttprequest::statusText()
+{
+ QFETCH(QUrl, replyUrl);
+ QFETCH(QString, statusText);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("status.expect"),
+ replyUrl,
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("statusText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", statusText);
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::statusText_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<QString>("statusText");
+
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << "OK";
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << "Document not found";
+ QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << "Bad request";
+}
+
+void tst_qqmlxmlhttprequest::responseText()
+{
+ QFETCH(QUrl, replyUrl);
+ QFETCH(QUrl, bodyUrl);
+ QFETCH(QString, responseText);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("status.expect"),
+ replyUrl,
+ bodyUrl));
+
+ QQmlComponent component(&engine, testFileUrl("responseText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedText", responseText);
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsent").toBool(), true);
+ QCOMPARE(object->property("opened").toBool(), true);
+ QCOMPARE(object->property("sent").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("reset").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::responseText_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<QUrl>("bodyUrl");
+ QTest::addColumn<QString>("responseText");
+
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n";
+ QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << "";
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
+ QTest::newRow("Bad Request") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
+}
+
+void tst_qqmlxmlhttprequest::nonUtf8()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QString, responseText);
+ QFETCH(QString, xmlRootNodeValue);
+
+ QQmlComponent component(&engine, testFileUrl("utf16.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ object->setProperty("fileName", fileName);
+ QMetaObject::invokeMethod(object, "startRequest");
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("responseText").toString(), responseText);
+
+ if (!xmlRootNodeValue.isEmpty()) {
+ QString rootNodeValue = object->property("responseXmlRootNodeValue").toString();
+ QCOMPARE(rootNodeValue, xmlRootNodeValue);
+ }
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::nonUtf8_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QString>("responseText");
+ QTest::addColumn<QString>("xmlRootNodeValue");
+
+ QString uc;
+ uc.resize(3);
+ uc[0] = QChar(0x10e3);
+ uc[1] = QChar(' ');
+ uc[2] = QChar(0x03a3);
+
+ QTest::newRow("responseText") << "utf16.html" << uc + '\n' << "";
+ QTest::newRow("responseXML") << "utf16.xml" << "<?xml version=\"1.0\" encoding=\"UTF-16\" standalone='yes'?>\n<root>\n" + uc + "\n</root>\n" << QString('\n' + uc + '\n');
+}
+
+// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
+// throws an exception
+void tst_qqmlxmlhttprequest::invalidMethodUsage()
+{
+ QQmlComponent component(&engine, testFileUrl("invalidMethodUsage.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QCOMPARE(object->property("open").toBool(), true);
+ QCOMPARE(object->property("setRequestHeader").toBool(), true);
+ QCOMPARE(object->property("send").toBool(), true);
+ QCOMPARE(object->property("abort").toBool(), true);
+ QCOMPARE(object->property("getResponseHeader").toBool(), true);
+ QCOMPARE(object->property("getAllResponseHeaders").toBool(), true);
+
+ delete object;
+}
+
+// Test that XMLHttpRequest transparently redirects
+void tst_qqmlxmlhttprequest::redirects()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("redirects.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("done").toBool() == true);
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("redirectError.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("done").toBool() == true);
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("redirectRecur.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ for (int ii = 0; ii < 60; ++ii) {
+ if (object->property("done").toBool()) break;
+ QTest::qWait(50);
+ }
+ QVERIFY(object->property("done").toBool() == true);
+
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlxmlhttprequest::responseXML_invalid()
+{
+ QQmlComponent component(&engine, testFileUrl("responseXML_invalid.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlNull").toBool(), true);
+
+ delete object;
+}
+
+// Test the Document DOM element
+void tst_qqmlxmlhttprequest::document()
+{
+ QQmlComponent component(&engine, testFileUrl("document.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Element DOM element
+void tst_qqmlxmlhttprequest::element()
+{
+ QQmlComponent component(&engine, testFileUrl("element.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Attr DOM element
+void tst_qqmlxmlhttprequest::attr()
+{
+ QQmlComponent component(&engine, testFileUrl("attr.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Text DOM element
+void tst_qqmlxmlhttprequest::text()
+{
+ QQmlComponent component(&engine, testFileUrl("text.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the CDataSection DOM element
+void tst_qqmlxmlhttprequest::cdata()
+{
+ QQmlComponent component(&engine, testFileUrl("cdata.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmlxmlhttprequest)
+
+#include "tst_qqmlxmlhttprequest.moc"
diff --git a/tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml b/tests/auto/qml/qquickbinding/data/deletedObject.qml
index f9cf869ba3..f9cf869ba3 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml
+++ b/tests/auto/qml/qquickbinding/data/deletedObject.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/data/restoreBinding.qml b/tests/auto/qml/qquickbinding/data/restoreBinding.qml
index 9491c0f1d3..9491c0f1d3 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/restoreBinding.qml
+++ b/tests/auto/qml/qquickbinding/data/restoreBinding.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/data/restoreBindingWithLoop.qml b/tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml
index ee07104817..ee07104817 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/restoreBindingWithLoop.qml
+++ b/tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml b/tests/auto/qml/qquickbinding/data/test-binding.qml
index 87aabe975a..87aabe975a 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml
+++ b/tests/auto/qml/qquickbinding/data/test-binding.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml b/tests/auto/qml/qquickbinding/data/test-binding2.qml
index 4a08141d11..4a08141d11 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml
+++ b/tests/auto/qml/qquickbinding/data/test-binding2.qml
diff --git a/tests/auto/qml/qquickbinding/qquickbinding.pro b/tests/auto/qml/qquickbinding/qquickbinding.pro
new file mode 100644
index 0000000000..b87e93495d
--- /dev/null
+++ b/tests/auto/qml/qquickbinding/qquickbinding.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickbinding
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickbinding.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp b/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp
new file mode 100644
index 0000000000..939c4a9e3d
--- /dev/null
+++ b/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qquickbind_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include "../../shared/util.h"
+
+class tst_qquickbinding : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickbinding();
+
+private slots:
+ void binding();
+ void whenAfterValue();
+ void restoreBinding();
+ void restoreBindingWithLoop();
+ void deletedObject();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickbinding::tst_qquickbinding()
+{
+}
+
+void tst_qquickbinding::binding()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-binding.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickBind *binding3 = qobject_cast<QQuickBind*>(rect->findChild<QQuickBind*>("binding3"));
+ QVERIFY(binding3 != 0);
+
+ QCOMPARE(rect->color(), QColor("yellow"));
+ QCOMPARE(rect->property("text").toString(), QString("Hello"));
+ QCOMPARE(binding3->when(), false);
+
+ rect->setProperty("changeColor", true);
+ QCOMPARE(rect->color(), QColor("red"));
+
+ QCOMPARE(binding3->when(), true);
+
+ QQuickBind *binding = qobject_cast<QQuickBind*>(rect->findChild<QQuickBind*>("binding1"));
+ QVERIFY(binding != 0);
+ QCOMPARE(binding->object(), qobject_cast<QObject*>(rect));
+ QCOMPARE(binding->property(), QLatin1String("text"));
+ QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
+
+ delete rect;
+}
+
+void tst_qquickbinding::whenAfterValue()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-binding2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+
+ QVERIFY(rect != 0);
+ QCOMPARE(rect->color(), QColor("yellow"));
+ QCOMPARE(rect->property("text").toString(), QString("Hello"));
+
+ rect->setProperty("changeColor", true);
+ QCOMPARE(rect->color(), QColor("red"));
+
+ delete rect;
+}
+
+void tst_qquickbinding::restoreBinding()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("restoreBinding.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *myItem = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("myItem"));
+ QVERIFY(myItem != 0);
+
+ myItem->setY(25);
+ QCOMPARE(myItem->x(), qreal(100-25));
+
+ myItem->setY(13);
+ QCOMPARE(myItem->x(), qreal(100-13));
+
+ //Binding takes effect
+ myItem->setY(51);
+ QCOMPARE(myItem->x(), qreal(51));
+
+ myItem->setY(88);
+ QCOMPARE(myItem->x(), qreal(88));
+
+ //original binding restored
+ myItem->setY(49);
+ QCOMPARE(myItem->x(), qreal(100-49));
+
+ delete rect;
+}
+
+void tst_qquickbinding::restoreBindingWithLoop()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("restoreBindingWithLoop.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *myItem = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("myItem"));
+ QVERIFY(myItem != 0);
+
+ myItem->setY(25);
+ QCOMPARE(myItem->x(), qreal(25 + 100));
+
+ myItem->setY(13);
+ QCOMPARE(myItem->x(), qreal(13 + 100));
+
+ //Binding takes effect
+ rect->setProperty("activateBinding", true);
+ myItem->setY(51);
+ QCOMPARE(myItem->x(), qreal(51));
+
+ myItem->setY(88);
+ QCOMPARE(myItem->x(), qreal(88));
+
+ //original binding restored
+ QString warning = c.url().toString() + QLatin1String(":9:5: QML Rectangle: Binding loop detected for property \"x\"");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ rect->setProperty("activateBinding", false);
+ QCOMPARE(myItem->x(), qreal(88 + 100)); //if loop handling changes this could be 90 + 100
+
+ myItem->setY(49);
+ QCOMPARE(myItem->x(), qreal(49 + 100));
+
+ delete rect;
+}
+
+//QTBUG-20692
+void tst_qquickbinding::deletedObject()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("deletedObject.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QGuiApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+
+ //don't crash
+ rect->setProperty("activateBinding", true);
+
+ delete rect;
+}
+
+QTEST_MAIN(tst_qquickbinding)
+
+#include "tst_qquickbinding.moc"
diff --git a/tests/auto/qml/qquickchangeset/qquickchangeset.pro b/tests/auto/qml/qquickchangeset/qquickchangeset.pro
new file mode 100644
index 0000000000..726b18665b
--- /dev/null
+++ b/tests/auto/qml/qquickchangeset/qquickchangeset.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qquickchangeset
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickchangeset.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp b/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp
new file mode 100644
index 0000000000..4bd3df90ac
--- /dev/null
+++ b/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp
@@ -0,0 +1,812 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <private/qquickchangeset_p.h>
+
+#define VERIFY_EXPECTED_OUTPUT
+
+class tst_qquickchangeset : public QObject
+{
+ Q_OBJECT
+public:
+ struct Signal
+ {
+ int index;
+ int count;
+ int to;
+ int moveId;
+
+ bool isInsert() const { return to == -1; }
+ bool isRemove() const { return to == -2; }
+ bool isMove() const { return to >= 0; }
+ bool isChange() const { return to == -3; }
+ };
+
+ static Signal Insert(int index, int count, int moveId = -1) { Signal signal = { index, count, -1, moveId }; return signal; }
+ static Signal Remove(int index, int count, int moveId = -1) { Signal signal = { index, count, -2, moveId }; return signal; }
+ static Signal Move(int from, int to, int count) { Signal signal = { from, count, to, -1 }; return signal; }
+ static Signal Change(int index, int count) { Signal signal = { index, count, -3, -1 }; return signal; }
+
+ typedef QVector<Signal> SignalList;
+
+
+#ifdef VERIFY_EXPECTED_OUTPUT
+
+ template<typename T>
+ void move(int from, int to, int n, T *items)
+ {
+ if (from > to) {
+ // Only move forwards - flip if backwards moving
+ int tfrom = from;
+ int tto = to;
+ from = tto;
+ to = tto+n;
+ n = tfrom-tto;
+ }
+
+ T replaced;
+ int i=0;
+ typename T::ConstIterator it=items->begin(); it += from+n;
+ for (; i<to-from; ++i,++it)
+ replaced.append(*it);
+ i=0;
+ it=items->begin(); it += from;
+ for (; i<n; ++i,++it)
+ replaced.append(*it);
+ typename T::ConstIterator f=replaced.begin();
+ typename T::Iterator t=items->begin(); t += from;
+ for (; f != replaced.end(); ++f, ++t)
+ *t = *f;
+ }
+
+ QVector<int> applyChanges(const QVector<int> &list, const QVector<Signal> &changes)
+ {
+ QHash<int, QVector<int> > removedValues;
+ QVector<int> alteredList = list;
+ foreach (const Signal &signal, changes) {
+ if (signal.isInsert()) {
+ if (signal.moveId != -1) {
+ QVector<int> tail = alteredList.mid(signal.index);
+ alteredList = alteredList.mid(0, signal.index) + removedValues.take(signal.moveId) + tail;
+ } else {
+ alteredList.insert(signal.index, signal.count, 100);
+ }
+ } else if (signal.isRemove()) {
+ if (signal.moveId != -1)
+ removedValues.insert(signal.moveId, alteredList.mid(signal.index, signal.count));
+ alteredList.erase(alteredList.begin() + signal.index, alteredList.begin() + signal.index + signal.count);
+ } else if (signal.isMove()) {
+ move(signal.index, signal.to, signal.count, &alteredList);
+ } else if (signal.isChange()) {
+ for (int i = signal.index; i < signal.index + signal.count; ++i) {
+ if (alteredList[i] < 100)
+ alteredList[i] = 100;
+ }
+ }
+ }
+ return alteredList;
+ }
+
+#endif
+
+private slots:
+ void sequence_data();
+ void sequence();
+};
+
+bool operator ==(const tst_qquickchangeset::Signal &left, const tst_qquickchangeset::Signal &right)
+{
+ return left.index == right.index
+ && left.count == right.count
+ && left.to == right.to
+ && ((left.moveId == -1 && right.moveId == -1) || (left.moveId != -1 && right.moveId != -1));
+}
+
+
+QDebug operator <<(QDebug debug, const tst_qquickchangeset::Signal &signal)
+{
+ if (signal.isInsert())
+ debug.nospace() << "Insert(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
+ else if (signal.isRemove())
+ debug.nospace() << "Remove(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
+ else if (signal.isMove())
+ debug.nospace() << "Move(" << signal.index << "," << signal.to << "," << signal.count << ")";
+ else if (signal.isChange())
+ debug.nospace() << "Change(" << signal.index << "," << signal.count << ")";
+ return debug;
+}
+
+Q_DECLARE_METATYPE(tst_qquickchangeset::SignalList)
+
+void tst_qquickchangeset::sequence_data()
+{
+ QTest::addColumn<SignalList>("input");
+ QTest::addColumn<SignalList>("output");
+
+ // Insert
+ QTest::newRow("i(12,5)")
+ << (SignalList() << Insert(12,5))
+ << (SignalList() << Insert(12,5));
+ QTest::newRow("i(2,3),i(12,5)")
+ << (SignalList() << Insert(2,3) << Insert(12,5))
+ << (SignalList() << Insert(2,3) << Insert(12,5));
+ QTest::newRow("i(12,5),i(2,3)")
+ << (SignalList() << Insert(12,5) << Insert(2,3))
+ << (SignalList() << Insert(2,3) << Insert(15,5));
+ QTest::newRow("i(12,5),i(12,3)")
+ << (SignalList() << Insert(12,5) << Insert(12,3))
+ << (SignalList() << Insert(12,8));
+ QTest::newRow("i(12,5),i(17,3)")
+ << (SignalList() << Insert(12,5) << Insert(17,3))
+ << (SignalList() << Insert(12,8));
+ QTest::newRow("i(12,5),i(15,3)")
+ << (SignalList() << Insert(12,5) << Insert(15,3))
+ << (SignalList() << Insert(12,8));
+
+ // Remove
+ QTest::newRow("r(3,9)")
+ << (SignalList() << Remove(3,9))
+ << (SignalList() << Remove(3,9));
+ QTest::newRow("r(3,4),r(3,2)")
+ << (SignalList() << Remove(3,4) << Remove(3,2))
+ << (SignalList() << Remove(3,6));
+ QTest::newRow("r(4,3),r(14,5)")
+ << (SignalList() << Remove(4,3) << Remove(14,5))
+ << (SignalList() << Remove(4,3) << Remove(14,5));
+ QTest::newRow("r(14,5),r(4,3)")
+ << (SignalList() << Remove(14,5) << Remove(4,3))
+ << (SignalList() << Remove(4,3) << Remove(11,5));
+ QTest::newRow("r(4,3),r(2,9)")
+ << (SignalList() << Remove(4,3) << Remove(2,9))
+ << (SignalList() << Remove(2,12));
+
+ // Move
+ QTest::newRow("m(8-10,2)")
+ << (SignalList() << Move(8,10,2))
+ << (SignalList() << Remove(8,2,1) << Insert(10,2,1));
+
+ QTest::newRow("m(23-12,6),m(13-15,5)")
+ << (SignalList() << Move(23,12,6) << Move(13,15,5))
+ << (SignalList() << Remove(23,1,0) << Remove(23,5,1) << Insert(12,1,0) << Insert(15,5,1));
+ QTest::newRow("m(23-12,6),m(13-15,2)")
+ << (SignalList() << Move(23,12,6) << Move(13,20,2))
+ << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(12,1,0) << Insert(13,3,2) << Insert(20,2,1));
+ QTest::newRow("m(23-12,6),m(13-2,2)")
+ << (SignalList() << Move(23,12,6) << Move(13,2,2))
+ << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(2,2,1) << Insert(14,1,0) << Insert(15,3,2));
+ QTest::newRow("m(23-12,6),m(12-6,5)")
+ << (SignalList() << Move(23,12,6) << Move(12,6,5))
+ << (SignalList() << Remove(23,5,0) << Remove(23,1,1) << Insert(6,5,0) << Insert(17,1,1));
+ QTest::newRow("m(23-12,6),m(10-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(10,5,4))
+ << (SignalList() << Remove(10,2,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(5,2,0) << Insert(7,2,1) << Insert(14,4,2));
+ QTest::newRow("m(23-12,6),m(16-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(16,5,4))
+ << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(5,2,2) << Insert(7,2,0) << Insert(16,4,1));
+ QTest::newRow("m(23-12,6),m(13-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(13,5,4))
+ << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(5,4,1) << Insert(16,1,0) << Insert(17,1,2));
+ QTest::newRow("m(23-12,6),m(14-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(14,5,4))
+ << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(5,4,1) << Insert(16,2,0));
+ QTest::newRow("m(23-12,6),m(12-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(12,5,4))
+ << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(5,4,0) << Insert(16,2,1));
+ QTest::newRow("m(23-12,6),m(11-5,8)")
+ << (SignalList() << Move(23,12,6) << Move(11,5,8))
+ << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(5,1,0) << Insert(6,6,2) << Insert(12,1,1));
+ QTest::newRow("m(23-12,6),m(8-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(8,5,4))
+ << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
+ QTest::newRow("m(23-12,6),m(2-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(2,5,4))
+ << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
+ QTest::newRow("m(23-12,6),m(18-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(18,5,4))
+ << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
+ QTest::newRow("m(23-12,6),m(20-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(20,5,4))
+ << (SignalList() << Remove(14,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
+
+ QTest::newRow("m(23-12,6),m(5-13,11)")
+ << (SignalList() << Move(23,12,6) << Move(5,13,11))
+ << (SignalList() << Remove(5,7,0) << Remove(16,4,1) << Remove(16,2,2) << Insert(5,2,2) << Insert(13,7,0) << Insert(20,4,1));
+
+ QTest::newRow("m(23-12,6),m(12-23,6)")
+ << (SignalList() << Move(23,12,6) << Move(12,23,6))
+ << (SignalList() << Remove(23,6,0) << Insert(23,6,0)); // ### These cancel out.
+ QTest::newRow("m(23-12,6),m(10-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(10,23,4))
+ << (SignalList() << Remove(10,2 ,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(10,4,2) << Insert(23,2,0) << Insert(25,2,1));
+ QTest::newRow("m(23-12,6),m(16-23.4)")
+ << (SignalList() << Move(23,12,6) << Move(16,23,4))
+ << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(12,4,1) << Insert(23,2,2) << Insert(25,2,0));
+ QTest::newRow("m(23-12,6),m(13-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(13,23,4))
+ << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(12,1,0) << Insert(13,1,2) << Insert(23,4,1));
+ QTest::newRow("m(23-12,6),m(14-23,)")
+ << (SignalList() << Move(23,12,6) << Move(14,23,4))
+ << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(12,2,0) << Insert(23,4,1));
+ QTest::newRow("m(23-12,6),m(12-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(12,23,4))
+ << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(12,2,1) << Insert(23,4,0));
+ QTest::newRow("m(23-12,6),m(11-23,8)")
+ << (SignalList() << Move(23,12,6) << Move(11,23,8))
+ << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(23,1,0) << Insert(24,6,2) << Insert(30,1,1));
+ QTest::newRow("m(23-12,6),m(8-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(8,23,4))
+ << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
+ QTest::newRow("m(23-12,6),m(2-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(2,23,4))
+ << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
+ QTest::newRow("m(23-12,6),m(18-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(18,23,4))
+ << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(12,6,1) << Insert(23,4,0));
+ QTest::newRow("m(23-12,6),m(20-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(20,23,4))
+ << (SignalList() << Remove(14,4,1) << Remove(19,6,0) << Insert(12,6,0) << Insert(23,4,1));
+
+ QTest::newRow("m(23-12,6),m(11-23,10)")
+ << (SignalList() << Move(23,12,6) << Move(11,23,10))
+ << (SignalList() << Remove(11,1,3) << Remove(11,3,1) << Remove(19,6,2) << Insert(23,1,3) << Insert(24,6,2) << Insert(30,3,1));
+
+ QTest::newRow("m(3-9,12),m(13-5,12)")
+ << (SignalList() << Move(3,9,12) << Move(13,15,5))
+ << (SignalList() << Remove(3,4,2) << Remove(3,5,1) << Remove(3,2,0) << Remove(3,1,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,5,1) << Insert(20,1,3));
+ QTest::newRow("m(3-9,12),m(13-15,20)")
+ << (SignalList() << Move(3,9,12) << Move(13,15,20))
+ << (SignalList() << Remove(3,4,0) << Remove(3,8,1) << Remove(9,12,2) << Insert(9,4,0) << Insert(15,8,1) << Insert(23,12,2));
+ QTest::newRow("m(3-9,12),m(13-15,2)")
+ << (SignalList() << Move(3,9,12) << Move(13,15,2))
+ << (SignalList() << Remove(3,4,2) << Remove(3,2,1) << Remove(3,2,0) << Remove(3,4,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,2,1) << Insert(17,4,3));
+ QTest::newRow("m(3-9,12),m(12-5,6)")
+ << (SignalList() << Move(3,9,12) << Move(12,5,6))
+ << (SignalList() << Remove(3,3,0) << Remove(3,6,1) << Remove(3,3,2) << Insert(5,6,1) << Insert(15,3,0) << Insert(18,3,2));
+ QTest::newRow("m(3-9,12),m(10-14,5)")
+ << (SignalList() << Move(3,9,12) << Move(10,14,5))
+ << (SignalList() << Remove(3,1,2) << Remove(3,5,1) << Remove(3,4,0) << Remove(3,2,3) << Insert(9,1,2) << Insert(10,4,0) << Insert(14,5,1) << Insert(19,2,3));
+ QTest::newRow("m(3-9,12),m(16-20,5)")
+ << (SignalList() << Move(3,9,12) << Move(16,20,5))
+ << (SignalList() << Remove(3,7,0) << Remove(3,5,1) << Insert(9,7,0) << Insert(20,5,1));
+ QTest::newRow("m(3-9,12),m(13-17,5)")
+ << (SignalList() << Move(3,9,12) << Move(13,17,5))
+ << (SignalList() << Remove(3,4,0) << Remove(3,5,1) << Remove(3,3,2) << Insert(9,4,0) << Insert(13,3,2) << Insert(17,5,1));
+ QTest::newRow("m(3-9,12),m(14-18,5)")
+ << (SignalList() << Move(3,9,12) << Move(14,18,5))
+ << (SignalList() << Remove(3,5,0) << Remove(3,5,1) << Remove(3,2,2) << Insert(9,5,0) << Insert(14,2,2) << Insert(18,5,1));
+ QTest::newRow("m(3-9,12),m(12-16,5)")
+ << (SignalList() << Move(3,9,12) << Move(12,16,5))
+ << (SignalList() << Remove(3,3,2) << Remove(3,5,1) << Remove(3,4,0) << Insert(9,3,2) << Insert(12,4,0) << Insert(16,5,1));
+ QTest::newRow("m(3-9,12),m(11-19,5)")
+ << (SignalList() << Move(3,9,12) << Move(11,19,5))
+ << (SignalList() << Remove(3,2,0) << Remove(3,5,1) << Remove(3,5,2) << Insert(9,2,0) << Insert(11,5,2) << Insert(19,5,1));
+ QTest::newRow("m(3-9,12),m(8-12,5)")
+ << (SignalList() << Move(3,9,12) << Move(8,12,5))
+ << (SignalList() << Remove(3,4,1) << Remove(3,4,0) << Remove(3,4,4) << Remove(8,1,2) << Insert(8,4,0) << Insert(12,1,2) << Insert(13,4,1) << Insert(17,4,4));
+ QTest::newRow("m(3-9,12),m(2-6,5)")
+ << (SignalList() << Move(3,9,12) << Move(2,6,5))
+ << (SignalList() << Remove(2,1,2) << Remove(2,2,0) << Remove(2,10,3) << Remove(2,4,1) << Insert(4,2,0) << Insert(6,1,2) << Insert(7,4,1) << Insert(11,10,3));
+ QTest::newRow("m(3-9,12),m(18-22,5)")
+ << (SignalList() << Move(3,9,12) << Move(18,22,5))
+ << (SignalList() << Remove(3,9,0) << Remove(3,3,1) << Remove(9,2,2) << Insert(9,9,0) << Insert(22,3,1) << Insert(25,2,2));
+ QTest::newRow("m(3-9,12),m(20-24,5)")
+ << (SignalList() << Move(3,9,12) << Move(20,24,5))
+ << (SignalList() << Remove(3,11,0) << Remove(3,1,1) << Remove(9,4,2) << Insert(9,11,0) << Insert(24,1,1) << Insert(25,4,2));
+
+ QTest::newRow("m(3-9,12),m(5-11,8)")
+ << (SignalList() << Move(3,9,12) << Move(5,11,8))
+ << (SignalList() << Remove(3,4,1) << Remove(3,6,0) << Remove(3,2,3) << Remove(5,4,2) << Insert(5,6,0) << Insert(11,4,2) << Insert(15,2,3) << Insert(15,4,1));
+
+ QTest::newRow("m(3-9,12),m(12-23,6)")
+ << (SignalList() << Move(3,9,12) << Move(12,23,6))
+ << (SignalList() << Remove(3,3,2) << Remove(3,6,1) << Remove(3,3,0) << Insert(9,3,2) << Insert(12,3,0) << Insert(23,6,1));
+ QTest::newRow("m(3-9,12),m(10-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(10,23,4))
+ << (SignalList() << Remove(3,1,2) << Remove(3,4,1) << Remove(3,7,0) << Insert(9,1,2) << Insert(10,7,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(16-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(16,23,4))
+ << (SignalList() << Remove(3,7,2) << Remove(3,4,1) << Remove(3,1,0) << Insert(9,7,2) << Insert(16,1,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(13-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(13,23,4))
+ << (SignalList() << Remove(3,4,2) << Remove(3,4,1) << Remove(3,4,0) << Insert(9,4,2) << Insert(13,4,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(14-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(14,23,4))
+ << (SignalList() << Remove(3,5,2) << Remove(3,4,1) << Remove(3,3,0) << Insert(9,5,2) << Insert(14,3,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(12-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(12,23,4))
+ << (SignalList() << Remove(3,3,2) << Remove(3,4,1) << Remove(3,5,0) << Insert(9,3,2) << Insert(12,5,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(11-23,8)")
+ << (SignalList() << Move(3,9,12) << Move(11,23,8))
+ << (SignalList() << Remove(3,2,2) << Remove(3,8,1) << Remove(3,2,0) << Insert(9,2,2) << Insert(11,2,0) << Insert(23,8,1));
+ QTest::newRow("m(3-9,12),m(8-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(8,23,4))
+ << (SignalList() << Remove(3,3,1) << Remove(3,9,0) << Remove(8,1,2) << Insert(8,9,0) << Insert(23,1,2) << Insert(24,3,1));
+ QTest::newRow("m(3-9,12),m(2-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(2,23,4))
+ << (SignalList() << Remove(2,1,2) << Remove(2,12,0) << Remove(2,3,1) << Insert(5,12,0) << Insert(23,1,2) << Insert(24,3,1));
+ QTest::newRow("m(3-9,12),m(18-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(18,23,4))
+ << (SignalList() << Remove(3,9,3) << Remove(3,3,2) << Remove(9,1,1) << Insert(9,9,3) << Insert(23,3,2) << Insert(26,1,1));
+ QTest::newRow("m(3-9,12),m(20-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(20,23,4))
+ << (SignalList() << Remove(3,11,3) << Remove(3,1,2) << Remove(9,3,1) << Insert(9,11,3) << Insert(23,1,2) << Insert(24,3,1));
+
+ QTest::newRow("m(3-9,12),m(11-23,10)")
+ << (SignalList() << Move(3,9,12) << Move(11,23,10))
+ << (SignalList() << Remove(3,2,2) << Remove(3,10,1) << Insert(9,2,2) << Insert(23,10,1));
+
+ // Change
+ QTest::newRow("c(4,5)")
+ << (SignalList() << Change(4,5))
+ << (SignalList() << Change(4,5));
+ QTest::newRow("c(4,5),c(12,2)")
+ << (SignalList() << Change(4,5) << Change(12,2))
+ << (SignalList() << Change(4,5) << Change(12,2));
+ QTest::newRow("c(12,2),c(4,5)")
+ << (SignalList() << Change(12,2) << Change(4,5))
+ << (SignalList() << Change(4,5) << Change(12,2));
+ QTest::newRow("c(4,5),c(2,2)")
+ << (SignalList() << Change(4,5) << Change(2,2))
+ << (SignalList() << Change(2,7));
+ QTest::newRow("c(4,5),c(9,2)")
+ << (SignalList() << Change(4,5) << Change(9,2))
+ << (SignalList() << Change(4,7));
+ QTest::newRow("c(4,5),c(3,2)")
+ << (SignalList() << Change(4,5) << Change(3,2))
+ << (SignalList() << Change(3,6));
+ QTest::newRow("c(4,5),c(8,2)")
+ << (SignalList() << Change(4,5) << Change(8,2))
+ << (SignalList() << Change(4,6));
+ QTest::newRow("c(4,5),c(3,2)")
+ << (SignalList() << Change(4,5) << Change(3,2))
+ << (SignalList() << Change(3,6));
+ QTest::newRow("c(4,5),c(2,9)")
+ << (SignalList() << Change(4,5) << Change(2,9))
+ << (SignalList() << Change(2,9));
+ QTest::newRow("c(4,5),c(12,3),c(8,6)")
+ << (SignalList() << Change(4,5) << Change(12,3) << Change(8,6))
+ << (SignalList() << Change(4,11));
+
+ // Insert,then remove.
+ QTest::newRow("i(12,6),r(12,6)")
+ << (SignalList() << Insert(12,6) << Remove(12,6))
+ << (SignalList());
+ QTest::newRow("i(12,6),r(10,4)")
+ << (SignalList() << Insert(12,6) << Remove(10,4))
+ << (SignalList() << Remove(10,2) << Insert(10,4));
+ QTest::newRow("i(12,6),r(16,4)")
+ << (SignalList() << Insert(12,6) << Remove(16,4))
+ << (SignalList() << Remove(12,2) << Insert(12,4));
+ QTest::newRow("i(12,6),r(13,4)")
+ << (SignalList() << Insert(12,6) << Remove(13,4))
+ << (SignalList() << Insert(12,2));
+ QTest::newRow("i(12,6),r(14,4)")
+ << (SignalList() << Insert(12,6) << Remove(14,4))
+ << (SignalList() << Insert(12,2));
+ QTest::newRow("i(12,6),r(12,4)")
+ << (SignalList() << Insert(12,6) << Remove(12,4))
+ << (SignalList() << Insert(12,2));
+ QTest::newRow("i(12,6),r(11,8)")
+ << (SignalList() << Insert(12,6) << Remove(11,8))
+ << (SignalList() << Remove(11,2));
+ QTest::newRow("i(12,6),r(8,4)")
+ << (SignalList() << Insert(12,6) << Remove(8,4))
+ << (SignalList() << Remove(8,4) << Insert(8,6));
+ QTest::newRow("i(12,6),r(2,4)")
+ << (SignalList() << Insert(12,6) << Remove(2,4))
+ << (SignalList() << Remove(2,4) << Insert(8,6));
+ QTest::newRow("i(12,6),r(18,4)")
+ << (SignalList() << Insert(12,6) << Remove(18,4))
+ << (SignalList() << Remove(12,4) << Insert(12,6));
+ QTest::newRow("i(12,6),r(20,4)")
+ << (SignalList() << Insert(12,6) << Remove(20,4))
+ << (SignalList() << Remove(14,4) << Insert(12,6));
+
+ // Insert,then move
+ QTest::newRow("i(12,6),m(12-5,6)")
+ << (SignalList() << Insert(12,6) << Move(12,5,6))
+ << (SignalList() << Insert(5,6));
+ QTest::newRow("i(12,6),m(10-5,4)")
+ << (SignalList() << Insert(12,6) << Move(10,5,4))
+ << (SignalList() << Remove(10,2,0) << Insert(5,2,0) << Insert(7,2) << Insert(14,4));
+ QTest::newRow("i(12,6),m(16-5,4)")
+ << (SignalList() << Insert(12,6) << Move(16,5,4))
+ << (SignalList() << Remove(12,2,0) << Insert(5,2) << Insert(7,2,0) << Insert(16,4));
+ QTest::newRow("i(12,6),m(13-5,4)")
+ << (SignalList() << Insert(12,6) << Move(13,5,4))
+ << (SignalList() << Insert(5,4) << Insert(16,2));
+ QTest::newRow("i(12,6),m(14-5,4)")
+ << (SignalList() << Insert(12,6) << Move(14,5,4))
+ << (SignalList() << Insert(5,4) << Insert(16,2));
+ QTest::newRow("i(12,6),m(12-5,4)")
+ << (SignalList() << Insert(12,6) << Move(12,5,4))
+ << (SignalList() << Insert(5,4) << Insert(16,2));
+ QTest::newRow("i(12,6),m(11-5,8)")
+ << (SignalList() << Insert(12,6) << Move(11,5,8))
+ << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(5,1,0) << Insert(6,6) << Insert(12,1,1));
+ QTest::newRow("i(12,6),m(8-5,4)")
+ << (SignalList() << Insert(12,6) << Move(8,5,4))
+ << (SignalList() << Remove(8,4,0) << Insert(5,4,0) << Insert(12,6));
+ QTest::newRow("i(12,6),m(2-5,4)")
+ << (SignalList() << Insert(12,6) << Move(2,5,4))
+ << (SignalList() << Remove(2,4,0) << Insert(5,4,0) << Insert(12,6));
+ QTest::newRow("i(12,6),m(18-5,4)")
+ << (SignalList() << Insert(12,6) << Move(18,5,4))
+ << (SignalList() << Remove(12,4,0) << Insert(5,4,0) << Insert(16,6));
+ QTest::newRow("i(12,6),m(20-5,4)")
+ << (SignalList() << Insert(12,6) << Move(20,5,4))
+ << (SignalList() << Remove(14,4,0) << Insert(5,4,0) << Insert(16,6));
+
+ QTest::newRow("i(12,6),m(5-13,11)")
+ << (SignalList() << Insert(12,6) << Move(5,11,8))
+ << (SignalList() << Remove(5,7,0) << Insert(5,5) << Insert(11,7,0) << Insert(18,1));
+
+ QTest::newRow("i(12,6),m(12-23,6)")
+ << (SignalList() << Insert(12,6) << Move(12,23,6))
+ << (SignalList() << Insert(23,6));
+ QTest::newRow("i(12,6),m(10-23,4)")
+ << (SignalList() << Insert(12,6) << Move(10,23,4))
+ << (SignalList() << Remove(10,2,0) << Insert(10,4) << Insert(23,2,0) << Insert(25,2));
+ QTest::newRow("i(12,6),m(16-23,4)")
+ << (SignalList() << Insert(12,6) << Move(16,23,4))
+ << (SignalList() << Remove(12,2,0) << Insert(12,4) << Insert(23,2) << Insert(25,2,0));
+ QTest::newRow("i(12,6),m(13-23,4)")
+ << (SignalList() << Insert(12,6) << Move(13,23,4))
+ << (SignalList() << Insert(12,2) << Insert(23,4));
+ QTest::newRow("i(12,6),m(14-23,4)")
+ << (SignalList() << Insert(12,6) << Move(14,23,4))
+ << (SignalList() << Insert(12,2) << Insert(23,4));
+ QTest::newRow("i(12,6),m(12-23,4)")
+ << (SignalList() << Insert(12,6) << Move(12,23,4))
+ << (SignalList() << Insert(12,2) << Insert(23,4));
+ QTest::newRow("i(12,6),m(11-23,8)")
+ << (SignalList() << Insert(12,6) << Move(11,23,8))
+ << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(23,1,0)<< Insert(24,6) << Insert(30,1,1));
+ QTest::newRow("i(12,6),m(8-23,4)")
+ << (SignalList() << Insert(12,6) << Move(8,23,4))
+ << (SignalList() << Remove(8,4,0) << Insert(8,6) << Insert(23,4,0));
+ QTest::newRow("i(12,6),m(2-23,4)")
+ << (SignalList() << Insert(12,6) << Move(2,23,4))
+ << (SignalList() << Remove(2,4,0) << Insert(8,6) << Insert(23,4,0));
+ QTest::newRow("i(12,6),m(18-23,4)")
+ << (SignalList() << Insert(12,6) << Move(18,23,4))
+ << (SignalList() << Remove(12,4,0) << Insert(12,6) << Insert(23,4,0));
+ QTest::newRow("i(12,6),m(20-23,4)")
+ << (SignalList() << Insert(12,6) << Move(20,23,4))
+ << (SignalList() << Remove(14,4,0) << Insert(12,6) << Insert(23,4,0));
+
+ QTest::newRow("i(12,6),m(11-23,10)")
+ << (SignalList() << Insert(12,6) << Move(11,23,10))
+ << (SignalList() << Remove(11,1,0) << Remove(11,3,1) << Insert(23,1,0) << Insert(24,6) << Insert(30,3,1));
+
+ // Insert,then change
+ QTest::newRow("i(12,6),c(12,6)")
+ << (SignalList() << Insert(12,6) << Change(12,6))
+ << (SignalList() << Insert(12,6));
+ QTest::newRow("i(12,6),c(10,6)")
+ << (SignalList() << Insert(12,6) << Change(10,6))
+ << (SignalList() << Insert(12,6) << Change(10,2));
+ QTest::newRow("i(12,6),c(16,4)")
+ << (SignalList() << Insert(12,6) << Change(16,4))
+ << (SignalList() << Insert(12,6) << Change(18,2));
+ QTest::newRow("i(12,6),c(13,4)")
+ << (SignalList() << Insert(12,6) << Change(13,4))
+ << (SignalList() << Insert(12,6));
+ QTest::newRow("i(12,6),c(14,4)")
+ << (SignalList() << Insert(12,6) << Change(14,4))
+ << (SignalList() << Insert(12,6));
+ QTest::newRow("i(12,6),c(12,4)")
+ << (SignalList() << Insert(12,6) << Change(12,4))
+ << (SignalList() << Insert(12,6));
+ QTest::newRow("i(12,6),c(11,8)")
+ << (SignalList() << Insert(12,6) << Change(11,8))
+ << (SignalList() << Insert(12,6) << Change(11,1) << Change(18,1));
+ QTest::newRow("i(12,6),c(8,4)")
+ << (SignalList() << Insert(12,6) << Change(8,4))
+ << (SignalList() << Insert(12,6) << Change(8,4));
+ QTest::newRow("i(12,6),c(2,4)")
+ << (SignalList() << Insert(12,6) << Change(2,4))
+ << (SignalList() << Insert(12,6) << Change(2,4));
+ QTest::newRow("i(12,6),c(18,4)")
+ << (SignalList() << Insert(12,6) << Change(18,4))
+ << (SignalList() << Insert(12,6) << Change(18,4));
+ QTest::newRow("i(12,6),c(20,4)")
+ << (SignalList() << Insert(12,6) << Change(20,4))
+ << (SignalList() << Insert(12,6) << Change(20,4));
+
+ // Remove,then insert
+ QTest::newRow("r(12,6),i(12,6)")
+ << (SignalList() << Remove(12,6) << Insert(12,6))
+ << (SignalList() << Remove(12,6) << Insert(12,6));
+ QTest::newRow("r(12,6),i(10,4)")
+ << (SignalList() << Remove(12,6) << Insert(10,14))
+ << (SignalList() << Remove(12,6) << Insert(10,14));
+ QTest::newRow("r(12,6),i(16,4)")
+ << (SignalList() << Remove(12,6) << Insert(16,4))
+ << (SignalList() << Remove(12,6) << Insert(16,4));
+ QTest::newRow("r(12,6),i(13,4)")
+ << (SignalList() << Remove(12,6) << Insert(13,4))
+ << (SignalList() << Remove(12,6) << Insert(13,4));
+ QTest::newRow("r(12,6),i(14,4)")
+ << (SignalList() << Remove(12,6) << Insert(14,4))
+ << (SignalList() << Remove(12,6) << Insert(14,4));
+ QTest::newRow("r(12,6),i(12,4)")
+ << (SignalList() << Remove(12,6) << Insert(12,4))
+ << (SignalList() << Remove(12,6) << Insert(12,4));
+ QTest::newRow("r(12,6),i(11,8)")
+ << (SignalList() << Remove(12,6) << Insert(11,8))
+ << (SignalList() << Remove(12,6) << Insert(11,8));
+ QTest::newRow("r(12,6),i(8,4)")
+ << (SignalList() << Remove(12,6) << Insert(8,4))
+ << (SignalList() << Remove(12,6) << Insert(8,4));
+ QTest::newRow("r(12,6),i(2,4)")
+ << (SignalList() << Remove(12,6) << Insert(2,4))
+ << (SignalList() << Remove(12,6) << Insert(2,4));
+ QTest::newRow("r(12,6),i(18,4)")
+ << (SignalList() << Remove(12,6) << Insert(18,4))
+ << (SignalList() << Remove(12,6) << Insert(18,4));
+ QTest::newRow("r(12,6),i(20,4)")
+ << (SignalList() << Remove(12,6) << Insert(20,4))
+ << (SignalList() << Remove(12,6) << Insert(20,4));
+
+ // Move,then insert
+ QTest::newRow("m(12-5,6),i(12,6)")
+ << (SignalList() << Move(12,5,6) << Insert(12,6))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,6));
+ QTest::newRow("m(12-5,6),i(10,4)")
+ << (SignalList() << Move(12,5,6) << Insert(10,4))
+ << (SignalList() << Remove(12,5,0) << Remove(12,1,1) << Insert(5,5,0) << Insert(10,4) << Insert(14,1,1));
+ QTest::newRow("m(12-5,6),i(16,4)")
+ << (SignalList() << Move(12,5,6) << Insert(16,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(16,4));
+ QTest::newRow("m(12-5,6),i(13,4)")
+ << (SignalList() << Move(12,5,6) << Insert(13,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(13,4));
+ QTest::newRow("m(12-5,6),i(14,4)")
+ << (SignalList() << Move(12,5,6) << Insert(14,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(14,4));
+ QTest::newRow("m(12-5,6),i(12,4)")
+ << (SignalList() << Move(12,5,6) << Insert(12,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,4));
+ QTest::newRow("m(12-5,6),i(11,8)")
+ << (SignalList() << Move(12,5,6) << Insert(11,8))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(11,8));
+ QTest::newRow("m(12-5,6),i(8,4)")
+ << (SignalList() << Move(12,5,6) << Insert(8,4))
+ << (SignalList() << Remove(12,3,0) << Remove(12,3,1) << Insert(5,3,0) << Insert(8,4) << Insert(12,3,1));
+ QTest::newRow("m(12-5,6),i(2,4)")
+ << (SignalList() << Move(12,5,6) << Insert(2,4))
+ << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(9,6,0));
+ QTest::newRow("m(12-5,6),i(18,4)")
+ << (SignalList() << Move(12,5,6) << Insert(18,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(18,4));
+ QTest::newRow("m(12-5,6),i(20,4)")
+ << (SignalList() << Move(12,5,6) << Insert(20,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(20,4));
+
+ QTest::newRow("m(12-23,6),i(12,6)")
+ << (SignalList() << Move(12,23,6) << Insert(12,6))
+ << (SignalList() << Remove(12,6,0) << Insert(12,6) << Insert(29,6,0));
+ QTest::newRow("m(12-23,6),i(10,4)")
+ << (SignalList() << Move(12,23,6) << Insert(10,4))
+ << (SignalList() << Remove(12,6,0) << Insert(10,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(16,4)")
+ << (SignalList() << Move(12,23,6) << Insert(16,4))
+ << (SignalList() << Remove(12,6,0) << Insert(16,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(13,4)")
+ << (SignalList() << Move(12,23,6) << Insert(13,4))
+ << (SignalList() << Remove(12,6,0) << Insert(13,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(14,4)")
+ << (SignalList() << Move(12,23,6) << Insert(14,4))
+ << (SignalList() << Remove(12,6,0) << Insert(14,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(12,4)")
+ << (SignalList() << Move(12,23,6) << Insert(12,4))
+ << (SignalList() << Remove(12,6,0) << Insert(12,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(11,8)")
+ << (SignalList() << Move(12,23,6) << Insert(11,8))
+ << (SignalList() << Remove(12,6,0) << Insert(11,8) << Insert(31,6,0));
+ QTest::newRow("m(12-23,6),i(8,4)")
+ << (SignalList() << Move(12,23,6) << Insert(8,4))
+ << (SignalList() << Remove(12,6,0) << Insert(8,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(2,4)")
+ << (SignalList() << Move(12,23,6) << Insert(2,4))
+ << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(18,4)")
+ << (SignalList() << Move(12,23,6) << Insert(18,4))
+ << (SignalList() << Remove(12,6,0) << Insert(18,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(20,4)")
+ << (SignalList() << Move(12,23,6) << Insert(20,4))
+ << (SignalList() << Remove(12,6,0) << Insert(20,4) << Insert(27,6,0));
+
+ // Move,then remove
+ QTest::newRow("m(12-5,6),r(12,6)")
+ << (SignalList() << Move(12,5,6) << Remove(12,6))
+ << (SignalList() << Remove(6,6) << Remove(6,6,0) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(10,4)")
+ << (SignalList() << Move(12,5,6) << Remove(10,4))
+ << (SignalList() << Remove(5,3) << Remove(9,5,0) << Remove(9,1) << Insert(5,5,0));
+ QTest::newRow("m(12-5,6),r(16,4)")
+ << (SignalList() << Move(12,5,6) << Remove(16,4))
+ << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(13,4)")
+ << (SignalList() << Move(12,5,6) << Remove(13,4))
+ << (SignalList() << Remove(7,4) << Remove(8,6,0) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(14,4)")
+ << (SignalList() << Move(12,5,6) << Remove(14,4))
+ << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(12,4)")
+ << (SignalList() << Move(12,5,6) << Remove(12,4))
+ << (SignalList() << Remove(6,4) << Remove(8,6,0) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(11,8)")
+ << (SignalList() << Move(12,5,6) << Remove(11,8))
+ << (SignalList() << Remove(5,7) << Remove(5,6,0) << Remove(5,1) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(8,4)")
+ << (SignalList() << Move(12,5,6) << Remove(8,4))
+ << (SignalList() << Remove(5,1) << Remove(11,3,0) << Remove(11,3) << Insert(5,3,0));
+ QTest::newRow("m(12-5,6),r(2,4)")
+ << (SignalList() << Move(12,5,6) << Remove(2,4))
+ << (SignalList() << Remove(2,3) << Remove(9,1) << Remove(9,5,0) << Insert(2,5,0));
+ QTest::newRow("m(12-5,6),r(6,4)")
+ << (SignalList() << Move(12,5,6) << Remove(6,4))
+ << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(12,1,1) << Insert(5,1,0) << Insert(6,1,1));
+ QTest::newRow("m(12-5,6),r(18,4)")
+ << (SignalList() << Move(12,5,6) << Remove(18,4))
+ << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(20,4)")
+ << (SignalList() << Move(12,5,6) << Remove(20,4))
+ << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(5,6,0));
+
+ QTest::newRow("m(12-23,6),r(12,6)")
+ << (SignalList() << Move(12,23,6) << Remove(12,6))
+ << (SignalList() << Remove(12,6,0) << Remove(12,6) << Insert(17,6,0));
+ QTest::newRow("m(12-23,6),r(10,4)")
+ << (SignalList() << Move(12,23,6) << Remove(10,4))
+ << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(16,4)")
+ << (SignalList() << Move(12,23,6) << Remove(16,4))
+ << (SignalList() << Remove(12,6,0) << Remove(16,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(13,4)")
+ << (SignalList() << Move(12,23,6) << Remove(13,4))
+ << (SignalList() << Remove(12,6,0) << Remove(13,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(14,4)")
+ << (SignalList() << Move(12,23,6) << Remove(14,4))
+ << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(12,4)")
+ << (SignalList() << Move(12,23,6) << Remove(12,4))
+ << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(11,8)")
+ << (SignalList() << Move(12,23,6) << Remove(11,8))
+ << (SignalList() << Remove(11,1) << Remove(11,6,0) << Remove(11,7) << Insert(15,6,0));
+ QTest::newRow("m(12-23,6),r(8,4)")
+ << (SignalList() << Move(12,23,6) << Remove(8,4))
+ << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(2,4)")
+ << (SignalList() << Move(12,23,6) << Remove(2,4))
+ << (SignalList() << Remove(2,4) << Remove(8,6,0) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(18,4)")
+ << (SignalList() << Move(12,23,6) << Remove(18,4))
+ << (SignalList() << Remove(12,6,0) << Remove(18,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(20,4)")
+ << (SignalList() << Move(12,23,6) << Remove(20,4))
+ << (SignalList() << Remove(12,1) << Remove(12,5,0) << Remove(20,3) << Insert(20,5,0));
+
+
+ // Complex
+ QTest::newRow("r(15,1),r(22,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1))
+ << (SignalList() << Remove(15,1) << Remove(22,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1))
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1))
+ << (SignalList() << Remove(15,2) << Remove(21,1) << Remove(24,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1))
+ << (SignalList() << Remove(13,1) << Remove(14,2) << Remove(20,1) << Remove(23,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1))
+ << (SignalList() << Remove(13,4) << Remove(19,1) << Remove(22,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1),m(12,13,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1) << Move(12,13,1))
+ << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(18,1) << Remove(21,1) << Insert(13,1,0));
+
+}
+
+void tst_qquickchangeset::sequence()
+{
+ QFETCH(SignalList, input);
+ QFETCH(SignalList, output);
+
+ QQuickChangeSet set;
+
+ foreach (const Signal &signal, input) {
+ if (signal.isRemove())
+ set.remove(signal.index, signal.count);
+ else if (signal.isInsert())
+ set.insert(signal.index, signal.count);
+ else if (signal.isMove())
+ set.move(signal.index, signal.to, signal.count);
+ else if (signal.isChange())
+ set.change(signal.index, signal.count);
+ }
+
+ SignalList changes;
+ foreach (const QQuickChangeSet::Remove &remove, set.removes())
+ changes << Remove(remove.index, remove.count, remove.moveId);
+ foreach (const QQuickChangeSet::Insert &insert, set.inserts())
+ changes << Insert(insert.index, insert.count, insert.moveId);
+ foreach (const QQuickChangeSet::Change &change, set.changes())
+ changes << Change(change.index, change.count);
+
+#ifdef VERIFY_EXPECTED_OUTPUT
+ QVector<int> list;
+ for (int i = 0; i < 40; ++i)
+ list.append(i);
+ QVector<int> inputList = applyChanges(list, input);
+ QVector<int> outputList = applyChanges(list, output);
+ if (outputList != inputList /* || changes != output*/) {
+ qDebug() << input;
+ qDebug() << output;
+ qDebug() << changes;
+ qDebug() << inputList;
+ qDebug() << outputList;
+ } else if (changes != output) {
+ qDebug() << output;
+ qDebug() << changes;
+ }
+ QCOMPARE(outputList, inputList);
+#else
+
+ if (changes != output) {
+ qDebug() << output;
+ qDebug() << changes;
+ }
+
+#endif
+
+ QCOMPARE(changes, output);
+}
+
+
+QTEST_MAIN(tst_qquickchangeset)
+
+#include "tst_qquickchangeset.moc"
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml b/tests/auto/qml/qquickconnection/data/connection-targetchange.qml
index 154c309c9c..154c309c9c 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-targetchange.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml
index 05d06bda94..05d06bda94 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml
index 9d25cba649..9d25cba649 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml
index bcd281256f..bcd281256f 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml
index ad8d4d91a8..ad8d4d91a8 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml b/tests/auto/qml/qquickconnection/data/error-object.qml
index 256b2626a7..256b2626a7 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml
+++ b/tests/auto/qml/qquickconnection/data/error-object.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml b/tests/auto/qml/qquickconnection/data/error-property.qml
index a602479783..a602479783 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml
+++ b/tests/auto/qml/qquickconnection/data/error-property.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml b/tests/auto/qml/qquickconnection/data/error-property2.qml
index 8123afe707..8123afe707 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml
+++ b/tests/auto/qml/qquickconnection/data/error-property2.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/qml/qquickconnection/data/error-syntax.qml
index 16c0534b68..16c0534b68 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml
+++ b/tests/auto/qml/qquickconnection/data/error-syntax.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/moduleapi-target.qml b/tests/auto/qml/qquickconnection/data/moduleapi-target.qml
index 8803f24542..8803f24542 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/moduleapi-target.qml
+++ b/tests/auto/qml/qquickconnection/data/moduleapi-target.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml b/tests/auto/qml/qquickconnection/data/test-connection.qml
index ce851fc3db..ce851fc3db 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml
+++ b/tests/auto/qml/qquickconnection/data/test-connection.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/qml/qquickconnection/data/test-connection2.qml
index b23d2fc145..b23d2fc145 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml
+++ b/tests/auto/qml/qquickconnection/data/test-connection2.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/qml/qquickconnection/data/test-connection3.qml
index 9e88f0ff8f..9e88f0ff8f 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml
+++ b/tests/auto/qml/qquickconnection/data/test-connection3.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml b/tests/auto/qml/qquickconnection/data/trimming.qml
index 6692050deb..6692050deb 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml
+++ b/tests/auto/qml/qquickconnection/data/trimming.qml
diff --git a/tests/auto/qml/qquickconnection/qquickconnection.pro b/tests/auto/qml/qquickconnection/qquickconnection.pro
new file mode 100644
index 0000000000..bea1f1df00
--- /dev/null
+++ b/tests/auto/qml/qquickconnection/qquickconnection.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickconnection
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickconnection.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
new file mode 100644
index 0000000000..ad687dd085
--- /dev/null
+++ b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
@@ -0,0 +1,292 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qquickconnections_p.h>
+#include <private/qquickitem_p.h>
+#include "../../shared/util.h"
+#include <QtQml/qqmlscriptstring.h>
+
+class tst_qquickconnection : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickconnection();
+
+private slots:
+ void defaultValues();
+ void properties();
+ void connection();
+ void trimming();
+ void targetChanged();
+ void unknownSignals_data();
+ void unknownSignals();
+ void errors_data();
+ void errors();
+ void moduleApiTarget();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickconnection::tst_qquickconnection()
+{
+}
+
+void tst_qquickconnection::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection3.qml"));
+ QQuickConnections *item = qobject_cast<QQuickConnections*>(c.create());
+
+ QVERIFY(item != 0);
+ QVERIFY(item->target() == 0);
+
+ delete item;
+}
+
+void tst_qquickconnection::properties()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection2.qml"));
+ QQuickConnections *item = qobject_cast<QQuickConnections*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QVERIFY(item != 0);
+ QVERIFY(item->target() == item);
+
+ delete item;
+}
+
+void tst_qquickconnection::connection()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QCOMPARE(item->property("tested").toBool(), false);
+ QCOMPARE(item->width(), 50.);
+ emit item->setWidth(100.);
+ QCOMPARE(item->width(), 100.);
+ QCOMPARE(item->property("tested").toBool(), true);
+
+ delete item;
+}
+
+void tst_qquickconnection::trimming()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("trimming.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QCOMPARE(item->property("tested").toString(), QString(""));
+ int index = item->metaObject()->indexOfSignal("testMe(int,QString)");
+ QMetaMethod method = item->metaObject()->method(index);
+ method.invoke(item,
+ Qt::DirectConnection,
+ Q_ARG(int, 5),
+ Q_ARG(QString, "worked"));
+ QCOMPARE(item->property("tested").toString(), QString("worked5"));
+
+ delete item;
+}
+
+// Confirm that target can be changed by one of our signal handlers
+void tst_qquickconnection::targetChanged()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("connection-targetchange.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+ QVERIFY(item != 0);
+
+ QQuickConnections *connections = item->findChild<QQuickConnections*>("connections");
+ QVERIFY(connections);
+
+ QQuickItem *item1 = item->findChild<QQuickItem*>("item1");
+ QVERIFY(item1);
+
+ item1->setWidth(200);
+
+ QQuickItem *item2 = item->findChild<QQuickItem*>("item2");
+ QVERIFY(item2);
+ QVERIFY(connections->target() == item2);
+
+ // If we don't crash then we're OK
+
+ delete item;
+}
+
+void tst_qquickconnection::unknownSignals_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
+ QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
+ QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error
+ QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error
+}
+
+void tst_qquickconnection::unknownSignals()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, error);
+
+ QUrl url = testFileUrl(file);
+ if (!error.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1());
+ } else {
+ // QTest has no way to insist no message (i.e. fail)
+ }
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, url);
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+ QVERIFY(item != 0);
+
+ // check that connection is created (they are all runtime errors)
+ QQuickConnections *connections = item->findChild<QQuickConnections*>("connections");
+ QVERIFY(connections);
+
+ if (file == "connection-unknownsignals-ignored.qml")
+ QVERIFY(connections->ignoreUnknownSignals());
+
+ delete item;
+}
+
+void tst_qquickconnection::errors_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\"";
+ QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\"";
+ QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed";
+ QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error";
+}
+
+void tst_qquickconnection::errors()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, error);
+
+ QUrl url = testFileUrl(file);
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, url);
+ QVERIFY(c.isError() == true);
+ QList<QQmlError> errors = c.errors();
+ QVERIFY(errors.count() == 1);
+ QCOMPARE(errors.at(0).description(), error);
+}
+
+
+class MyTestModuleApi : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged)
+
+public:
+ MyTestModuleApi(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {}
+ ~MyTestModuleApi() {}
+
+ Q_INVOKABLE int otherMethod(int val) { return val + 4; }
+
+ int intProp() const { return m_intProp; }
+ void setIntProp(int val)
+ {
+ if (++m_changeCount % 3 == 0) emit otherSignal();
+ m_intProp = val; emit intPropChanged();
+ }
+
+signals:
+ void intPropChanged();
+ void otherSignal();
+
+private:
+ int m_intProp;
+ int m_changeCount;
+};
+
+static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+ MyTestModuleApi *api = new MyTestModuleApi();
+ return api;
+}
+
+// QTBUG-20937
+void tst_qquickconnection::moduleApiTarget()
+{
+ qmlRegisterModuleApi("MyTestModuleApi", 1, 0, module_api_factory);
+ QQmlComponent component(&engine, testFileUrl("moduleapi-target.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 0);
+ QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
+
+ QMetaObject::invokeMethod(object, "setModuleIntProp");
+ QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 1);
+ QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
+
+ QMetaObject::invokeMethod(object, "setModuleIntProp");
+ QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 2);
+ QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
+
+ // the module API emits otherSignal every 3 times the int property changes.
+ QMetaObject::invokeMethod(object, "setModuleIntProp");
+ QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 3);
+ QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 1);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qquickconnection)
+
+#include "tst_qquickconnection.moc"
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml b/tests/auto/qml/qquickfolderlistmodel/data/basic.qml
index 2c4977d08b..2c4977d08b 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml
+++ b/tests/auto/qml/qquickfolderlistmodel/data/basic.qml
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml b/tests/auto/qml/qquickfolderlistmodel/data/dummy.qml
index 609638bec6..609638bec6 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml
+++ b/tests/auto/qml/qquickfolderlistmodel/data/dummy.qml
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetFiltering.qml b/tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml
index d9a8ec4535..d9a8ec4535 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetFiltering.qml
+++ b/tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/innerdir/test2.txt b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt
index 97e64bb130..97e64bb130 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/innerdir/test2.txt
+++ b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/test.txt b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt
index 97e64bb130..97e64bb130 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/test.txt
+++ b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt
diff --git a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro
new file mode 100644
index 0000000000..bdf4a45865
--- /dev/null
+++ b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickfolderlistmodel
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickfolderlistmodel.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
new file mode 100644
index 0000000000..3761929362
--- /dev/null
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qabstractitemmodel.h>
+#include <QDebug>
+#include "../../shared/util.h"
+
+// From qquickfolderlistmodel.h
+const int FileNameRole = Qt::UserRole+1;
+const int FilePathRole = Qt::UserRole+2;
+enum SortField { Unsorted, Name, Time, Size, Type };
+
+class tst_qquickfolderlistmodel : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickfolderlistmodel() : removeStart(0), removeEnd(0) {}
+
+public slots:
+ void removed(const QModelIndex &, int start, int end) {
+ removeStart = start;
+ removeEnd = end;
+ }
+
+private slots:
+ void basicProperties();
+ void resetFiltering();
+ void refresh();
+
+private:
+ void checkNoErrors(const QQmlComponent& component);
+ QQmlEngine engine;
+
+ int removeStart;
+ int removeEnd;
+};
+
+void tst_qquickfolderlistmodel::checkNoErrors(const QQmlComponent& component)
+{
+ // Wait until the component is ready
+ QTRY_VERIFY(component.isReady() || component.isError());
+
+ if (component.isError()) {
+ QList<QQmlError> errors = component.errors();
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QQmlError &error = errors.at(ii);
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" +
+ QByteArray::number(error.column()) + ":" +
+ error.description().toUtf8();
+ qWarning() << errorStr;
+ }
+ }
+ QVERIFY(!component.isError());
+}
+
+void tst_qquickfolderlistmodel::basicProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("basic.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+
+ flm->setProperty("folder", dataDirectoryUrl());
+ QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
+ QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl());
+ QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath()));
+ QCOMPARE(flm->property("sortField").toInt(), int(Name));
+ QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml");
+ QCOMPARE(flm->property("sortReversed").toBool(), false);
+ QCOMPARE(flm->property("showDirs").toBool(), true);
+ QCOMPARE(flm->property("showDotAndDotDot").toBool(), false);
+ QCOMPARE(flm->property("showOnlyReadable").toBool(), false);
+ QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml"));
+ QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml"));
+
+ flm->setProperty("folder",QUrl::fromLocalFile(""));
+ QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(""));
+}
+
+void tst_qquickfolderlistmodel::resetFiltering()
+{
+ // see QTBUG-17837
+ QQmlComponent component(&engine, testFileUrl("resetFiltering.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+
+ connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+ this, SLOT(removed(const QModelIndex&,int,int)));
+
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
+ QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
+ int count = flm->rowCount();
+ QCOMPARE(removeStart, 0);
+ QCOMPARE(removeEnd, count-1);
+
+ flm->setProperty("folder", testFileUrl("resetfiltering/innerdir"));
+ QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible
+ count = flm->rowCount();
+ QCOMPARE(removeStart, 0);
+ QCOMPARE(removeEnd, count-1);
+
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
+ QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
+ count = flm->rowCount();
+ QCOMPARE(removeStart, 0);
+ QCOMPARE(removeEnd, count-1);
+}
+
+void tst_qquickfolderlistmodel::refresh()
+{
+ QQmlComponent component(&engine, testFileUrl("basic.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+
+ flm->setProperty("folder", dataDirectoryUrl());
+ QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
+
+ int count = flm->rowCount();
+
+ connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+ this, SLOT(removed(const QModelIndex&,int,int)));
+
+ flm->setProperty("sortReversed", true);
+
+ QTRY_COMPARE(removeStart, 0);
+ QTRY_COMPARE(removeEnd, count-1); // wait for refresh
+}
+
+QTEST_MAIN(tst_qquickfolderlistmodel)
+
+#include "tst_qquickfolderlistmodel.moc"
diff --git a/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro b/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro
new file mode 100644
index 0000000000..0e7a1af4c5
--- /dev/null
+++ b/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qquicklistcompositor
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicklistcompositor.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp b/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp
new file mode 100644
index 0000000000..a5d66661f0
--- /dev/null
+++ b/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp
@@ -0,0 +1,1637 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <private/qquicklistcompositor_p.h>
+
+template<typename T, int N> int lengthOf(const T (&)[N]) { return N; }
+
+typedef QQuickListCompositor C;
+
+struct Range
+{
+ Range() {}
+ Range(void *list, int index, int count, int flags)
+ : list(list), index(index), count(count), flags(flags) {}
+ void *list;
+ int index;
+ int count;
+ int flags;
+};
+
+template <typename T> struct Array
+{
+ Array() : array(0), count(0) {}
+ template<int N> Array(const T (&array)[N]) : array(array), count(N) {}
+
+ T operator [](int index) const { return array[index]; }
+
+ const T *array;
+ int count;
+};
+
+typedef Array<int> IndexArray;
+typedef Array<const void *> ListArray;
+
+typedef QVector<QQuickListCompositor::Remove> RemoveList;
+typedef QVector<QQuickListCompositor::Insert> InsertList;
+typedef QVector<QQuickListCompositor::Change> ChangeList;
+
+typedef QVector<Range> RangeList;
+
+Q_DECLARE_METATYPE(RangeList)
+Q_DECLARE_METATYPE(RemoveList)
+Q_DECLARE_METATYPE(InsertList)
+Q_DECLARE_METATYPE(ChangeList)
+Q_DECLARE_METATYPE(void *)
+Q_DECLARE_METATYPE(IndexArray)
+Q_DECLARE_METATYPE(ListArray)
+Q_DECLARE_METATYPE(C::Group)
+
+QT_BEGIN_NAMESPACE
+bool operator ==(const C::Change &left, const C::Change &right)
+{
+ return left.index[3] == right.index[3]
+ && left.index[2] == right.index[2]
+ && left.index[1] == right.index[1]
+ && left.index[0] == right.index[0]
+ && left.count == right.count
+ && left.groups() == right.groups()
+ && left.inCache() == right.inCache()
+ && (left.moveId == -1) == (right.moveId == -1);
+}
+QT_END_NAMESPACE
+
+static const C::Group Visible = C::Group(2);
+static const C::Group Selection = C::Group(3);
+
+class tst_qquicklistcompositor : public QObject
+{
+ Q_OBJECT
+
+ enum {
+ VisibleFlag = 0x04,
+ SelectionFlag = 0x08
+ };
+
+ void populateChange(
+ C::Change &change, int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId)
+ {
+ change.index[Selection] = sIndex;
+ change.index[Visible] = vIndex;
+ change.index[C::Default] = dIndex;
+ change.index[C::Cache] = cIndex;
+ change.count = count;
+ change.flags = flags;
+ change.moveId = moveId;
+ }
+
+ C::Remove Remove(
+ int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
+ {
+ C::Remove remove;
+ populateChange(remove, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
+ return remove;
+ }
+
+ C::Insert Insert(
+ int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
+ {
+ C::Insert insert;
+ populateChange(insert, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
+ return insert;
+ }
+
+ C::Change Change(
+ int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
+ {
+ C::Change change;
+ populateChange(change, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
+ return change;
+ }
+
+private slots:
+ void find_data();
+ void find();
+ void findInsertPosition_data();
+ void findInsertPosition();
+ void insert();
+ void clearFlags_data();
+ void clearFlags();
+ void setFlags_data();
+ void setFlags();
+ void move_data();
+ void move();
+ void moveFromEnd();
+ void clear();
+ void listItemsInserted_data();
+ void listItemsInserted();
+ void listItemsRemoved_data();
+ void listItemsRemoved();
+ void listItemsMoved_data();
+ void listItemsMoved();
+ void listItemsChanged_data();
+ void listItemsChanged();
+};
+
+void tst_qquicklistcompositor::find_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("startGroup");
+ QTest::addColumn<int>("startIndex");
+ QTest::addColumn<C::Group>("group");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("selectionIndex");
+ QTest::addColumn<int>("visibleIndex");
+ QTest::addColumn<int>("defaultIndex");
+ QTest::addColumn<int>("cacheIndex");
+ QTest::addColumn<uint>("rangeFlags");
+ QTest::addColumn<int>("rangeIndex");
+
+ int listA; void *a = &listA;
+
+ QTest::newRow("Start")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
+ << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
+ << C::Cache << 2
+ << Selection << 0
+ << 0 << 0 << 0 << 0
+ << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0;
+}
+
+void tst_qquicklistcompositor::find()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, startGroup);
+ QFETCH(int, startIndex);
+ QFETCH(C::Group, group);
+ QFETCH(int, index);
+ QFETCH(int, cacheIndex);
+ QFETCH(int, defaultIndex);
+ QFETCH(int, visibleIndex);
+ QFETCH(int, selectionIndex);
+ QFETCH(uint, rangeFlags);
+ QFETCH(int, rangeIndex);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ compositor.find(startGroup, startIndex);
+
+ QQuickListCompositor::iterator it = compositor.find(group, index);
+ QCOMPARE(it.index[C::Cache], cacheIndex);
+ QCOMPARE(it.index[C::Default], defaultIndex);
+ QCOMPARE(it.index[Visible], visibleIndex);
+ QCOMPARE(it.index[Selection], selectionIndex);
+ QCOMPARE(it->flags, rangeFlags);
+ QCOMPARE(it->index, rangeIndex);
+}
+
+void tst_qquicklistcompositor::findInsertPosition_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("group");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("selectionIndex");
+ QTest::addColumn<int>("visibleIndex");
+ QTest::addColumn<int>("defaultIndex");
+ QTest::addColumn<int>("cacheIndex");
+ QTest::addColumn<uint>("rangeFlags");
+ QTest::addColumn<int>("rangeIndex");
+
+ int listA; void *a = &listA;
+
+ QTest::newRow("Start")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
+ << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
+ << Selection << 0
+ << 0 << 0 << 0 << 0
+ << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0;
+ QTest::newRow("1")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
+ << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
+ << Selection << 1
+ << 1 << 0 << 1 << 1
+ << uint(C::AppendFlag | C::PrependFlag | C::CacheFlag) << 1;
+}
+
+void tst_qquicklistcompositor::findInsertPosition()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, group);
+ QFETCH(int, index);
+ QFETCH(int, cacheIndex);
+ QFETCH(int, defaultIndex);
+ QFETCH(int, visibleIndex);
+ QFETCH(int, selectionIndex);
+ QFETCH(uint, rangeFlags);
+ QFETCH(int, rangeIndex);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QQuickListCompositor::insert_iterator it = compositor.findInsertPosition(group, index);
+ QCOMPARE(it.index[C::Cache], cacheIndex);
+ QCOMPARE(it.index[C::Default], defaultIndex);
+ QCOMPARE(it.index[Visible], visibleIndex);
+ QCOMPARE(it.index[Selection], selectionIndex);
+ QCOMPARE(it->flags, rangeFlags);
+ QCOMPARE(it->index, rangeIndex);
+}
+
+void tst_qquicklistcompositor::insert()
+{
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ C::iterator it;
+
+ int listA; int *a = &listA;
+ int listB; int *b = &listB;
+ int listC; int *c = &listC;
+
+ {
+ compositor.append(a, 0, 12, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+ const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } {
+ compositor.append(b, 4, 4, C::DefaultFlag);
+ const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7};
+ const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert at end.
+ compositor.insert(
+ C::Default, 16, c, 2, 2, C::DefaultFlag);
+ const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert at start
+ compositor.insert(
+ C::Default, 0, c, 6, 4, C::DefaultFlag);
+ const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert after static range.
+ compositor.insert(
+ C::Default, 4, b, 0, 8, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+ const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert at end of dynamic range.
+ compositor.insert(
+ C::Default, 12, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+ const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert into range.
+ compositor.insert(
+ C::Default, 8, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+ const int indexes[] = {6,7,8,9,0,1,2,3,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {c,c,c,c,b,b,b,b,c,c,c,c,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ }
+}
+
+void tst_qquicklistcompositor::clearFlags_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("group");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<int>("flags");
+ QTest::addColumn<RemoveList>("expectedRemoves");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<ListArray>("cacheLists");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<ListArray>("defaultLists");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<ListArray>("visibleLists");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+ QTest::addColumn<ListArray>("selectionLists");
+
+ int listA; void *a = &listA;
+
+ { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int visibleIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ QTest::newRow("Default, 2, 2, Selection")
+ << (RangeList()
+ << Range(a, 0, 12, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << C::Default << 2 << 2 << int(SelectionFlag)
+ << (RemoveList()
+ << Remove(2, 2, 2, 2, 2, SelectionFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ QTest::newRow("Selection, 1, 2, Visible")
+ << (RangeList()
+ << Range(a, 0, 2, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 4, 8, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << Selection << 1 << 2 << int(VisibleFlag)
+ << (RemoveList()
+ << Remove(1, 1, 1, 1, 1, VisibleFlag | C::CacheFlag)
+ << Remove(2, 3, 4, 4, 1, VisibleFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0};
+ static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
+ QTest::newRow("Default, 13, 1, Prepend | Selection | Visible | Default")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << C::Default << 13 << 1 << int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag)
+ << (RemoveList()
+ << Remove(11, 11, 13, 13, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0};
+ static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
+ QTest::newRow("Cache, 11, 4, Cache")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(0, 0, 1, int(C::CacheFlag))
+ << Range(0, 0, 3, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << C::Cache << 11 << 4 << int(C::CacheFlag)
+ << (RemoveList())
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
+ static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a,0};
+ QTest::newRow("Default, 11, 3, Default | Visible | Selection")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 5, 6, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 11, 1, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag))
+ << Range(0, 0, 2, int(SelectionFlag | VisibleFlag | C::DefaultFlag))
+ << Range(0, 0, 1, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << C::Default << 11 << 3 << int(C::DefaultFlag | VisibleFlag| SelectionFlag)
+ << (RemoveList()
+ << Remove(9, 9, 11, 11, 1, SelectionFlag | VisibleFlag | C::DefaultFlag)
+ << Remove(9, 9, 11, 11, 2, SelectionFlag | VisibleFlag | C::DefaultFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ }
+}
+
+void tst_qquicklistcompositor::clearFlags()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, group);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(int, flags);
+ QFETCH(RemoveList, expectedRemoves);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(ListArray, cacheLists);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(ListArray, defaultLists);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(ListArray, visibleLists);
+ QFETCH(IndexArray, selectionIndexes);
+ QFETCH(ListArray, selectionLists);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Remove> removes;
+ compositor.clearFlags(group, index, count, flags, &removes);
+
+ QCOMPARE(removes, expectedRemoves);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Cache, i);
+ QCOMPARE(it->list, cacheLists[i]);
+ if (cacheLists[i])
+ QCOMPARE(it.modelIndex(), cacheIndexes[i]);
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Default, i);
+ QCOMPARE(it->list, defaultLists[i]);
+ if (defaultLists[i])
+ QCOMPARE(it.modelIndex(), defaultIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ C::iterator it = compositor.find(Visible, i);
+ QCOMPARE(it->list, visibleLists[i]);
+ if (visibleLists[i])
+ QCOMPARE(it.modelIndex(), visibleIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ C::iterator it = compositor.find(Selection, i);
+ QCOMPARE(it->list, selectionLists[i]);
+ if (selectionLists[i])
+ QCOMPARE(it.modelIndex(), selectionIndexes[i]);
+ }
+}
+
+void tst_qquicklistcompositor::setFlags_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("group");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<int>("flags");
+ QTest::addColumn<InsertList>("expectedInserts");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<ListArray>("cacheLists");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<ListArray>("defaultLists");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<ListArray>("visibleLists");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+ QTest::addColumn<ListArray>("selectionLists");
+
+ int listA; void *a = &listA;
+
+ { static const int cacheIndexes[] = {0,0,0,0};
+ static const void *cacheLists[] = {0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ QTest::newRow("Default, 2, 2, Default")
+ << (RangeList()
+ << Range(a, 0, 12, C::DefaultFlag)
+ << Range(0, 0, 4, C::CacheFlag))
+ << C::Default << 2 << 2 << int(C::DefaultFlag)
+ << (InsertList())
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0};
+ static const void *cacheLists[] = {0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int visibleIndexes[] = {2,3};
+ static const void *visibleLists[] = {a,a};
+ QTest::newRow("Default, 2, 2, Visible")
+ << (RangeList()
+ << Range(a, 0, 12, C::DefaultFlag)
+ << Range(0, 0, 4, C::CacheFlag))
+ << C::Default << 2 << 2 << int(VisibleFlag)
+ << (InsertList()
+ << Insert(0, 0, 2, 0, 2, VisibleFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {3,6,0,0,0,0};
+ static const void *cacheLists[] = {a,a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int visibleIndexes[] = {2,3,6,7};
+ static const void *visibleLists[] = {a,a,a,a};
+ static const int selectionIndexes[] = {3,6};
+ static const void *selectionLists[] = {a,a};
+ QTest::newRow("Visible, 1, 2, Selection | Cache")
+ << (RangeList()
+ << Range(a, 0, 2, C::DefaultFlag)
+ << Range(a, 2, 2, VisibleFlag | C::DefaultFlag)
+ << Range(a, 4, 2, C::DefaultFlag)
+ << Range(a, 6, 2, VisibleFlag | C::DefaultFlag)
+ << Range(a, 8, 4, C::DefaultFlag)
+ << Range(0, 0, 4, C::CacheFlag))
+ << Visible << 1 << 2 << int(SelectionFlag | C::CacheFlag)
+ << (InsertList()
+ << Insert(0, 1, 3, 0, 1, SelectionFlag | C::CacheFlag)
+ << Insert(1, 2, 6, 1, 1, SelectionFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {3,6,0,0,0,0};
+ static const void *cacheLists[] = {a,a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int visibleIndexes[] = {2,3,6,7,0};
+ static const void *visibleLists[] = {a,a,a,a,0};
+ static const int selectionIndexes[] = {3,6};
+ static const void *selectionLists[] = {a,a};
+ QTest::newRow("Cache, 3, 1, Visible")
+ << (RangeList()
+ << Range(a, 0, 2, C::DefaultFlag)
+ << Range(a, 2, 1, VisibleFlag | C::DefaultFlag)
+ << Range(a, 3, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 4, 2, C::DefaultFlag)
+ << Range(a, 6, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 7, 1, VisibleFlag | C::DefaultFlag)
+ << Range(a, 8, 4, C::DefaultFlag)
+ << Range(0, 0, 4, C::CacheFlag))
+ << C::Cache << 3 << 1 << int(VisibleFlag)
+ << (InsertList()
+ << Insert(2, 4, 12, 3, 1, VisibleFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int visibleIndexes[] = {0,1,3,4,5,6,7,8,9,10,11};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a, a, a};
+ static const int selectionIndexes[] = {2,6,7,8,9};
+ static const void *selectionLists[] = {a,a,a,a,a};
+ QTest::newRow("Existing flag, sparse selection")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 3, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 6, 4, C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a,10, 2, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << C::Cache << 3 << 1 << int(VisibleFlag)
+ << InsertList()
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ }
+}
+
+void tst_qquicklistcompositor::setFlags()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, group);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(int, flags);
+ QFETCH(InsertList, expectedInserts);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(ListArray, cacheLists);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(ListArray, defaultLists);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(ListArray, visibleLists);
+ QFETCH(IndexArray, selectionIndexes);
+ QFETCH(ListArray, selectionLists);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Insert> inserts;
+ compositor.setFlags(group, index, count, flags, &inserts);
+
+ QCOMPARE(inserts, expectedInserts);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Cache, i);
+ QCOMPARE(it->list, cacheLists[i]);
+ if (cacheLists[i])
+ QCOMPARE(it.modelIndex(), cacheIndexes[i]);
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Default, i);
+ QCOMPARE(it->list, defaultLists[i]);
+ if (defaultLists[i])
+ QCOMPARE(it.modelIndex(), defaultIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ C::iterator it = compositor.find(Visible, i);
+ QCOMPARE(it->list, visibleLists[i]);
+ if (visibleLists[i])
+ QCOMPARE(it.modelIndex(), visibleIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ C::iterator it = compositor.find(Selection, i);
+ QCOMPARE(it->list, selectionLists[i]);
+ if (selectionLists[i])
+ QCOMPARE(it.modelIndex(), selectionIndexes[i]);
+ }
+}
+
+void tst_qquicklistcompositor::move_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("fromGroup");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<C::Group>("toGroup");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<RemoveList>("expectedRemoves");
+ QTest::addColumn<InsertList>("expectedInserts");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<ListArray>("cacheLists");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<ListArray>("defaultLists");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<ListArray>("visibleLists");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+ QTest::addColumn<ListArray>("selectionLists");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+ int listC; void *c = &listC;
+
+ { static const int cacheIndexes[] = {0,0,0,0,2,3};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,0,1,2,3,4,5,0,1,2,3,4,5,1,2,3,0,1,2,3,4,5};
+ static const void *defaultLists[] = {0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,0,c,c,c,c,c,c};
+ QTest::newRow("15, 0, 1")
+ << (RangeList()
+ << Range(a, 0, 6, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(0, 0, 4, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 15 << C::Default << 0 << 1
+ << (RemoveList()
+ << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0,2,3};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,1,0,1,2,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5};
+ static const void *defaultLists[] = {0,0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c};
+ QTest::newRow("15, 1, 1")
+ << (RangeList()
+ << Range(0, 0, 1, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 6, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(0, 0, 3, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 15 << C::Default << 1 << 1
+ << (RemoveList()
+ << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0,2,3};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,1,2,0,1,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5};
+ static const void *defaultLists[] = {a,a,a,0,0,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c};
+ QTest::newRow("0, 3, 2")
+ << (RangeList()
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 6, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 0 << C::Default << 3 << 2
+ << (RemoveList()
+ << Remove(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 3, 0, 2, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0,2,3};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,1,2,3,4,5};
+ static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c};
+ QTest::newRow("7, 1, 10")
+ << (RangeList()
+ << Range(a, 0, 3, C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 3, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 7 << C::Default << 1 << 10
+ << (RemoveList()
+ << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 0)
+ << Remove(0, 0, 7, 2, 6, C::DefaultFlag, 1)
+ << Remove(0, 0, 7, 2, 2, C::DefaultFlag | C::CacheFlag, 2)
+ << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 3))
+ << (InsertList()
+ << Insert(0, 0, 1, 0, 1, C::DefaultFlag, 0)
+ << Insert(0, 0, 2, 0, 6, C::DefaultFlag, 1)
+ << Insert(0, 0, 8, 0, 2, C::DefaultFlag | C::CacheFlag, 2)
+ << Insert(0, 0, 10, 2, 1, C::DefaultFlag, 3))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0,3,2};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,3,4,5,1,2};
+ static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c};
+ QTest::newRow("17, 20, 2")
+ << (RangeList()
+ << Range(a, 0, 1, C::DefaultFlag)
+ << Range(a, 5, 1, C::DefaultFlag)
+ << Range(b, 0, 6, C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 1, C::DefaultFlag)
+ << Range(a, 1, 2, C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 2, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag)
+ << Range(c, 0, 1, C::PrependFlag)
+ << Range(c, 1, 1, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 17 << C::Default << 20 << 2
+ << (RemoveList()
+ << Remove(0, 0, 17, 4, 1, C::DefaultFlag, 0)
+ << Remove(0, 0, 17, 4, 1, C::DefaultFlag | C::CacheFlag, 1))
+ << (InsertList()
+ << Insert(0, 0, 20, 5, 1, C::DefaultFlag, 0)
+ << Insert(0, 0, 21, 5, 1, C::DefaultFlag | C::CacheFlag, 1))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
+ static const void *cacheLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
+ static const int defaultIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
+ static const void *defaultLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
+ static const int visibleIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
+ static const void *visibleLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
+ QTest::newRow("3, 4, 5")
+ << (RangeList()
+ << Range(a, 8, 4, VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 1, C::PrependFlag)
+ << Range(a, 2, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 8, 4, C::AppendFlag | C::PrependFlag))
+ << C::Default << 3 << C::Default << 4 << 5
+ << (RemoveList()
+ << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0)
+ << Remove(0, 3, 3, 3, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1)
+ << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2)
+ << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3))
+ << (InsertList()
+ << Insert(0, 4, 4, 4, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0)
+ << Insert(0, 5, 5, 5, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1)
+ << Insert(0, 7, 7, 7, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2)
+ << Insert(0, 8, 8, 8, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,1};
+ static const void *cacheLists[] = {a,a};
+ static const int defaultIndexes[] = {0,1};
+ static const void *defaultLists[] = {a,a};
+ QTest::newRow("0, 1, 1")
+ << (RangeList()
+ << Range(a, 0, 1, C::PrependFlag)
+ << Range(a, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 0, C::AppendFlag | C::PrependFlag)
+ << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag))
+ << C::Default << 0 << C::Default << 1 << 1
+ << (RemoveList()
+ << Remove(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ }
+}
+
+void tst_qquicklistcompositor::move()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, fromGroup);
+ QFETCH(int, from);
+ QFETCH(C::Group, toGroup);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(RemoveList, expectedRemoves);
+ QFETCH(InsertList, expectedInserts);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(ListArray, cacheLists);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(ListArray, defaultLists);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(ListArray, visibleLists);
+ QFETCH(IndexArray, selectionIndexes);
+ QFETCH(ListArray, selectionLists);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Remove> removes;
+ QVector<C::Insert> inserts;
+ compositor.move(fromGroup, from, toGroup, to, count, fromGroup, &removes, &inserts);
+
+ QCOMPARE(removes, expectedRemoves);
+ QCOMPARE(inserts, expectedInserts);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Cache, i);
+ QCOMPARE(it->list, cacheLists[i]);
+ if (cacheLists[i])
+ QCOMPARE(it.modelIndex(), cacheIndexes[i]);
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Default, i);
+ QCOMPARE(it->list, defaultLists[i]);
+ if (defaultLists[i])
+ QCOMPARE(it.modelIndex(), defaultIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ C::iterator it = compositor.find(Visible, i);
+ QCOMPARE(it->list, visibleLists[i]);
+ if (visibleLists[i])
+ QCOMPARE(it.modelIndex(), visibleIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ C::iterator it = compositor.find(Selection, i);
+ QCOMPARE(it->list, selectionLists[i]);
+ if (selectionLists[i])
+ QCOMPARE(it.modelIndex(), selectionIndexes[i]);
+ }
+}
+
+void tst_qquicklistcompositor::moveFromEnd()
+{
+ int listA; void *a = &listA;
+
+ QQuickListCompositor compositor;
+ compositor.append(a, 0, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+
+ // Moving an item anchors it to that position.
+ compositor.move(C::Default, 0, C::Default, 0, 1, C::Default);
+
+ // The existing item is anchored at 0 so prepending an item to the source will append it here
+ QVector<C::Insert> inserts;
+ compositor.listItemsInserted(a, 0, 1, &inserts);
+
+ QCOMPARE(inserts.count(), 1);
+ QCOMPARE(inserts.at(0).index[1], 1);
+ QCOMPARE(inserts.at(0).count, 1);
+
+ C::iterator it;
+ it = compositor.find(C::Default, 0);
+ QCOMPARE(it.modelIndex(), 1);
+
+ it = compositor.find(C::Default, 1);
+ QCOMPARE(it.modelIndex(), 0);
+}
+
+void tst_qquicklistcompositor::clear()
+{
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ compositor.append(a, 0, 8, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag);
+ compositor.append(b, 4, 5, VisibleFlag | C::DefaultFlag);
+ compositor.append(0, 0, 3, VisibleFlag | C::DefaultFlag | C::CacheFlag);
+
+ QCOMPARE(compositor.count(C::Default), 16);
+ QCOMPARE(compositor.count(Visible), 16);
+ QCOMPARE(compositor.count(C::Cache), 3);
+
+ compositor.clear();
+ QCOMPARE(compositor.count(C::Default), 0);
+ QCOMPARE(compositor.count(Visible), 0);
+ QCOMPARE(compositor.count(C::Cache), 0);
+}
+
+void tst_qquicklistcompositor::listItemsInserted_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<void *>("list");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<InsertList>("expectedInserts");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
+ QTest::newRow("A 10, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 10 << 2
+ << InsertList()
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
+ QTest::newRow("B 10, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << b << 10 << 2
+ << InsertList()
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,2,3,7,8,/*B*/0,1,2,3,/*A*/4,5,6};
+ static const int visibleIndexes[] = {/*A*/0,1};
+ QTest::newRow("A 0, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 0 << 2
+ << (InsertList()
+ << Insert(0, 0, 0, 0, 2, VisibleFlag | C::DefaultFlag))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,/*B*/0,1,2,3,/*A*/4,6,7};
+ static const int visibleIndexes[] = {/*A*/0,1,5};
+ QTest::newRow("A 5, 1")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag)
+ << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 4, 3, C::PrependFlag)
+ << Range(a, 7, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 4, 3, C::DefaultFlag))
+ << a << 5 << 1
+ << (InsertList()
+ << Insert(0, 2, 4, 0, 1, VisibleFlag | C::DefaultFlag))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,10,11,/*B*/0,1,2,3,/*A*/4,6,7};
+ static const int visibleIndexes[] = {/*A*/0,1,5,10,11};
+ QTest::newRow("A 10, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag)
+ << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 4, 1, C::PrependFlag)
+ << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag)
+ << Range(a, 6, 2, C::PrependFlag)
+ << Range(a, 8, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 4, 1, C::DefaultFlag)
+ << Range(a, 6, 2, C::DefaultFlag))
+ << a << 10 << 2
+ << (InsertList()
+ << Insert(0, 3, 7, 0, 2, VisibleFlag | C::DefaultFlag))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,5,6,7,8,9};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9};
+ static const int visibleIndexes[] = {/*A*/3,4};
+ QTest::newRow("Insert after remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 3, C::CacheFlag)
+ << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 3 << 2
+ << (InsertList()
+ << Insert(0, 0, 3, 6, 2, VisibleFlag | C::DefaultFlag))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6};
+ static const int visibleIndexes[] = {/*A*/0,1,2,3,4,5,6};
+ QTest::newRow("Consecutive appends")
+ << (RangeList()
+ << Range(a, 0, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag)
+ << Range(a, 6, 0, C::AppendFlag | VisibleFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 6 << 1
+ << (InsertList()
+ << Insert(0, 6, 6, 5, 1, VisibleFlag | C::DefaultFlag))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ }
+}
+
+void tst_qquicklistcompositor::listItemsInserted()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(void *, list);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(InsertList, expectedInserts);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(IndexArray, selectionIndexes);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Insert> inserts;
+ compositor.listItemsInserted(list, index, count, &inserts);
+
+ QCOMPARE(inserts, expectedInserts);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ if (cacheIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ if (defaultIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ if (visibleIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ if (selectionIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
+ }
+ }
+}
+
+void tst_qquicklistcompositor::listItemsRemoved_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<void *>("list");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<RemoveList>("expectedRemoves");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
+ QTest::newRow("12, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 12 << 2
+ << RemoveList()
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,/*B*/0,1,2,3,/*A*/2,3};
+ QTest::newRow("4, 3")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 4 << 3
+ << (RemoveList()
+ << Remove(0, 0, 2, 0, 2, C::DefaultFlag)
+ << Remove(0, 0, 8, 0, 1, C::DefaultFlag))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,-1,-1,3,4,5};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5};
+ QTest::newRow("Remove after remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 3, C::CacheFlag)
+ << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 3 << 2
+ << (RemoveList()
+ << Remove(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6};
+ QTest::newRow("Sparse remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::CacheFlag)
+ << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 1, C::CacheFlag)
+ << Range(a, 1, 5, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 1, C::CacheFlag)
+ << Range(a, 6, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 1, C::CacheFlag)
+ << Range(a, 8, 3, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 1, C::CacheFlag)
+ << Range(a, 11, 1, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 12, 5, C::DefaultFlag))
+ << a << 1 << 10
+ << (RemoveList()
+ << Remove(0, 0, 1, 4, 5, C::DefaultFlag | C::CacheFlag)
+ << Remove(0, 0, 1,10, 2, C::DefaultFlag | C::CacheFlag)
+ << Remove(0, 0, 1,13, 3, C::DefaultFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ }
+}
+
+void tst_qquicklistcompositor::listItemsRemoved()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(void *, list);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(RemoveList, expectedRemoves);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(IndexArray, selectionIndexes);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Remove> removes;
+ compositor.listItemsRemoved(list, index, count, &removes);
+
+ QCOMPARE(removes, expectedRemoves);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ if (cacheIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ if (defaultIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ if (visibleIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ if (selectionIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
+ }
+ }
+}
+
+void tst_qquicklistcompositor::listItemsMoved_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<void *>("list");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<RemoveList>("expectedRemoves");
+ QTest::addColumn<InsertList>("expectedInserts");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ { static const int defaultIndexes[] = {/*A*/0,2,3,4,/*B*/0,1,2,3,/*A*/5,6,1};
+ QTest::newRow("4, 1, 3")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 4 << 1 << 3
+ << (RemoveList()
+ << Remove(0, 0, 2, 0, 2, C::DefaultFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 1, 0, 2, C::DefaultFlag, 0))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/1,2,3,6,/*B*/0,1,2,3,/*A*/4,5,0};
+ QTest::newRow("0, 6, 1")
+ << (RangeList()
+ << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 1, 1, C::PrependFlag)
+ << Range(a, 2, 3, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 5, 2, C::PrependFlag)
+ << Range(a, 7, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 5, 2, C::DefaultFlag)
+ << Range(a, 1, 1, C::DefaultFlag))
+ << a << 0 << 6 << 1
+ << (RemoveList()
+ << Remove(0, 0, 0, 0, 1, C::DefaultFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 3, 0, 1, C::DefaultFlag, 0))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,3,4};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7};
+ QTest::newRow("6, 2, 1")
+ << (RangeList()
+ << Range(a, 0, 4, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 4, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << a << 6 << 2 << 1
+ << (RemoveList()
+ << Remove(0, 0, 6, 4, 1, C::DefaultFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 2, 2, 1, C::DefaultFlag, 0))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,3,4,5,6,7};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7};
+ QTest::newRow("Move after remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 3, C::CacheFlag)
+ << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 4 << 2 << 2
+ << (RemoveList()
+ << Remove(0, 0, 4, 7, 2, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 2, 5, 2, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,5,6,7,8,9,10,11,12};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11,12};
+ QTest::newRow("Move merge tail")
+ << (RangeList()
+ << Range(a, 0, 10, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 10, 3, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 13, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 8 << 0 << 5
+ << (RemoveList()
+ << Remove(0, 0, 8, 8, 2, C::DefaultFlag | C::CacheFlag, 0)
+ << Remove(0, 0, 8, 8, 3, C::DefaultFlag, 1))
+ << (InsertList()
+ << Insert(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0)
+ << Insert(0, 0, 2, 2, 3, C::DefaultFlag, 1))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,2,3};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3};
+ static const int selectionIndexes[] = {/*A*/3};
+ QTest::newRow("Move selection")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 2 << 3 << 1
+ << (RemoveList()
+ << Remove(0, 0, 2, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 3, 3, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray(selectionIndexes);
+ } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4,5,8,9};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11};
+ QTest::newRow("move mixed cached items")
+ << (RangeList()
+ << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 1, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 3, 7, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 10, 2, C::PrependFlag | C::DefaultFlag))
+ << a << 1 << 6 << 3
+ << (RemoveList()
+ << Remove(0, 0, 1, 1, 2, C::PrependFlag | C::DefaultFlag, 0)
+ << Remove(0, 0, 1, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
+ << (InsertList()
+ << Insert(0, 0, 6, 6, 2, C::PrependFlag | C::DefaultFlag, 0)
+ << Insert(0, 0, 8, 6, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ }
+}
+
+void tst_qquicklistcompositor::listItemsMoved()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(void *, list);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(RemoveList, expectedRemoves);
+ QFETCH(InsertList, expectedInserts);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(IndexArray, selectionIndexes);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Remove> removes;
+ QVector<C::Insert> inserts;
+ compositor.listItemsMoved(list, from, to, count, &removes, &inserts);
+
+ QCOMPARE(removes, expectedRemoves);
+ QCOMPARE(inserts, expectedInserts);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ if (cacheIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ if (defaultIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ if (visibleIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ if (selectionIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
+ }
+ }
+}
+
+void tst_qquicklistcompositor::listItemsChanged_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<void *>("list");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<ChangeList>("expectedChanges");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ QTest::newRow("overlapping")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 3 << 4
+ << (ChangeList()
+ << Change(0, 0, 2, 0, 2, C::DefaultFlag)
+ << Change(0, 0, 9, 0, 2, C::DefaultFlag));
+ QTest::newRow("Change after remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 3, C::CacheFlag)
+ << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 3 << 2
+ << (ChangeList()
+ << Change(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag));
+}
+
+void tst_qquicklistcompositor::listItemsChanged()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(void *, list);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(ChangeList, expectedChanges);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Change> changes;
+ compositor.listItemsChanged(list, index, count, &changes);
+
+ QCOMPARE(changes, expectedChanges);
+}
+
+QTEST_MAIN(tst_qquicklistcompositor)
+
+#include "tst_qquicklistcompositor.moc"
+
+
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml b/tests/auto/qml/qquicklistmodel/data/enumerate.qml
index f73d66b318..f73d66b318 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml
+++ b/tests/auto/qml/qquicklistmodel/data/enumerate.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml b/tests/auto/qml/qquicklistmodel/data/model.qml
index 5973ea8adf..5973ea8adf 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml
+++ b/tests/auto/qml/qquicklistmodel/data/model.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/qml/qquicklistmodel/data/multipleroles.qml
index 4a331e2b3e..4a331e2b3e 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml
+++ b/tests/auto/qml/qquicklistmodel/data/multipleroles.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/script.js b/tests/auto/qml/qquicklistmodel/data/script.js
index 66a4acb8a8..66a4acb8a8 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/script.js
+++ b/tests/auto/qml/qquicklistmodel/data/script.js
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml b/tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml
index 58bf1ccd04..58bf1ccd04 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml
+++ b/tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml b/tests/auto/qml/qquicklistmodel/data/signalhandlers.qml
index 750d99c5a3..750d99c5a3 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml
+++ b/tests/auto/qml/qquicklistmodel/data/signalhandlers.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.js b/tests/auto/qml/qquicklistmodel/data/workerremoveelement.js
index cb9dfa66aa..cb9dfa66aa 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.js
+++ b/tests/auto/qml/qquicklistmodel/data/workerremoveelement.js
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.qml b/tests/auto/qml/qquicklistmodel/data/workerremoveelement.qml
index e2361acf6b..e2361acf6b 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.qml
+++ b/tests/auto/qml/qquicklistmodel/data/workerremoveelement.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.js b/tests/auto/qml/qquicklistmodel/data/workerremovelist.js
index f63dd68839..f63dd68839 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.js
+++ b/tests/auto/qml/qquicklistmodel/data/workerremovelist.js
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.qml b/tests/auto/qml/qquicklistmodel/data/workerremovelist.qml
index bdb5e024d8..bdb5e024d8 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.qml
+++ b/tests/auto/qml/qquicklistmodel/data/workerremovelist.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workersync.js b/tests/auto/qml/qquicklistmodel/data/workersync.js
index 9b8d8fa7f3..9b8d8fa7f3 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workersync.js
+++ b/tests/auto/qml/qquicklistmodel/data/workersync.js
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workersync.qml b/tests/auto/qml/qquicklistmodel/data/workersync.qml
index c21cd43e7e..c21cd43e7e 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workersync.qml
+++ b/tests/auto/qml/qquicklistmodel/data/workersync.qml
diff --git a/tests/auto/qml/qquicklistmodel/qquicklistmodel.pro b/tests/auto/qml/qquicklistmodel/qquicklistmodel.pro
new file mode 100644
index 0000000000..9b96fa0659
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodel/qquicklistmodel.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquicklistmodel
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicklistmodel.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp
new file mode 100644
index 0000000000..3fcce60bfb
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp
@@ -0,0 +1,1632 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQml/private/qqmlengine_p.h>
+#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qqmlexpression_p.h>
+#include <QQmlComponent>
+
+#include <QtCore/qtimer.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qtranslator.h>
+#include <QSignalSpy>
+
+#include "../../shared/util.h"
+
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QList<QVariantHash>)
+
+#define RUNEVAL(object, string) \
+ QVERIFY(QMetaObject::invokeMethod(object, "runEval", Q_ARG(QVariant, QString(string))));
+
+inline QVariant runexpr(QQmlEngine *engine, const QString &str)
+{
+ QQmlExpression expr(engine->rootContext(), 0, str);
+ return expr.evaluate();
+}
+
+#define RUNEXPR(string) runexpr(&engine, QString(string))
+
+static bool isValidErrorMessage(const QString &msg, bool dynamicRoleTest)
+{
+ bool valid = true;
+
+ if (msg.isEmpty()) {
+ valid = false;
+ } else if (dynamicRoleTest) {
+ if (msg.contains("Can't assign to existing role") || msg.contains("Can't create role for unsupported data type"))
+ valid = false;
+ }
+
+ return valid;
+}
+
+class tst_qquicklistmodel : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquicklistmodel() {}
+
+private:
+ int roleFromName(const QQuickListModel *model, const QString &roleName);
+ QQuickItem *createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model);
+ void waitForWorker(QQuickItem *item);
+
+ static bool compareVariantList(const QVariantList &testList, QVariant object);
+
+private slots:
+ void static_types();
+ void static_types_data();
+ void static_i18n();
+ void static_i18n_data();
+ void static_nestedElements();
+ void static_nestedElements_data();
+ void dynamic_data();
+ void dynamic();
+ void dynamic_worker_data();
+ void dynamic_worker();
+ void dynamic_worker_sync_data();
+ void dynamic_worker_sync();
+ void enumerate();
+ void error_data();
+ void error();
+ void syncError();
+ void get();
+ void set_data();
+ void set();
+ void get_data();
+ void get_worker();
+ void get_worker_data();
+ void get_nested();
+ void get_nested_data();
+ void crash_model_with_multiple_roles();
+ void set_model_cache();
+ void property_changes();
+ void property_changes_data();
+ void property_changes_worker();
+ void property_changes_worker_data();
+ void clear_data();
+ void clear();
+ void signal_handlers_data();
+ void signal_handlers();
+ void worker_sync_data();
+ void worker_sync();
+ void worker_remove_element_data();
+ void worker_remove_element();
+ void worker_remove_list_data();
+ void worker_remove_list();
+ void role_mode_data();
+ void role_mode();
+ void dynamic_role();
+ void dynamic_role_data();
+};
+
+bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVariant object)
+{
+ bool allOk = true;
+
+ QQuickListModel *model = qobject_cast<QQuickListModel *>(object.value<QObject *>());
+ if (model == 0)
+ return false;
+
+ if (model->count() != testList.count())
+ return false;
+
+ for (int i=0 ; i < testList.count() ; ++i) {
+ const QVariant &testVariant = testList.at(i);
+ if (testVariant.type() != QVariant::Map)
+ return false;
+ const QVariantMap &map = testVariant.toMap();
+
+ const QList<int> &roles = model->roles();
+
+ QVariantMap::const_iterator it = map.begin();
+ QVariantMap::const_iterator end = map.end();
+
+ while (it != end) {
+ const QString &testKey = it.key();
+ const QVariant &testData = it.value();
+
+ int roleIndex = -1;
+ for (int j=0 ; j < roles.count() ; ++j) {
+ if (model->toString(roles[j]).compare(testKey) == 0) {
+ roleIndex = j;
+ break;
+ }
+ }
+
+ if (roleIndex == -1)
+ return false;
+
+ const QVariant &modelData = model->data(i, roleIndex);
+
+ if (testData.type() == QVariant::List) {
+ const QVariantList &subList = testData.toList();
+ allOk = allOk && compareVariantList(subList, modelData);
+ } else {
+ allOk = allOk && (testData == modelData);
+ }
+
+ ++it;
+ }
+ }
+
+ return allOk;
+}
+
+int tst_qquicklistmodel::roleFromName(const QQuickListModel *model, const QString &roleName)
+{
+ QList<int> roles = model->roles();
+ for (int i=0; i<roles.count(); i++) {
+ if (model->toString(roles[i]) == roleName)
+ return roles[i];
+ }
+ return -1;
+}
+
+QQuickItem *tst_qquicklistmodel::createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model)
+{
+ QQuickItem *item = qobject_cast<QQuickItem*>(component->create());
+ QQmlEngine::setContextForObject(model, eng->rootContext());
+ if (item)
+ item->setProperty("model", qVariantFromValue(model));
+ return item;
+}
+
+void tst_qquicklistmodel::waitForWorker(QQuickItem *item)
+{
+ QEventLoop loop;
+ QTimer timer;
+ timer.setSingleShot(true);
+ connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+
+ QQmlProperty prop(item, "done");
+ QVERIFY(prop.isValid());
+ QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit())));
+ timer.start(10000);
+ loop.exec();
+ QVERIFY(timer.isActive());
+}
+
+void tst_qquicklistmodel::static_types_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QVariant>("value");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("string")
+ << "ListElement { foo: \"bar\" }"
+ << QVariant(QString("bar"))
+ << QString();
+
+ QTest::newRow("real")
+ << "ListElement { foo: 10.5 }"
+ << QVariant(10.5)
+ << QString();
+
+ QTest::newRow("real0")
+ << "ListElement { foo: 0 }"
+ << QVariant(double(0))
+ << QString();
+
+ QTest::newRow("bool")
+ << "ListElement { foo: false }"
+ << QVariant(false)
+ << QString();
+
+ QTest::newRow("bool")
+ << "ListElement { foo: true }"
+ << QVariant(true)
+ << QString();
+
+ QTest::newRow("enum")
+ << "ListElement { foo: Text.AlignHCenter }"
+ << QVariant(double(QQuickText::AlignHCenter))
+ << QString();
+
+ QTest::newRow("Qt enum")
+ << "ListElement { foo: Qt.AlignBottom }"
+ << QVariant(double(Qt::AlignBottom))
+ << QString();
+
+ QTest::newRow("role error")
+ << "ListElement { foo: 1 } ListElement { foo: 'string' }"
+ << QVariant()
+ << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [String -> Number]");
+
+ QTest::newRow("list type error")
+ << "ListElement { foo: 1 } ListElement { foo: ListElement { bar: 1 } }"
+ << QVariant()
+ << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [List -> Number]");
+}
+
+void tst_qquicklistmodel::static_types()
+{
+ QFETCH(QString, qml);
+ QFETCH(QVariant, value);
+ QFETCH(QString, error);
+
+ qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
+
+ if (!error.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
+ }
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+
+ QVERIFY(!component.isError());
+
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+
+ if (error.isEmpty()) {
+ QVariant actual = obj->property("test");
+
+ QCOMPARE(actual, value);
+ QCOMPARE(actual.toString(), value.toString());
+ }
+
+ delete obj;
+}
+
+void tst_qquicklistmodel::static_i18n_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QVariant>("value");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("QT_TR_NOOP")
+ << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"na\303\257ve\") }")
+ << QVariant(QString::fromUtf8("na\303\257ve"))
+ << QString();
+
+ QTest::newRow("QT_TRANSLATE_NOOP")
+ << "ListElement { foo: QT_TRANSLATE_NOOP(\"MyListModel\", \"hello\") }"
+ << QVariant(QString("hello"))
+ << QString();
+
+ QTest::newRow("QT_TRID_NOOP")
+ << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP(\"qtn_1st_text\") }")
+ << QVariant(QString("qtn_1st_text"))
+ << QString();
+
+ QTest::newRow("QT_TR_NOOP extra param")
+ << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"hello\",\"world\") }")
+ << QVariant(QString())
+ << QString("ListElement: improperly specified QT_TR_NOOP");
+
+ QTest::newRow("QT_TRANSLATE_NOOP missing params")
+ << "ListElement { foo: QT_TRANSLATE_NOOP() }"
+ << QVariant(QString())
+ << QString("ListElement: improperly specified QT_TRANSLATE_NOOP");
+
+ QTest::newRow("QT_TRID_NOOP missing param")
+ << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP() }")
+ << QVariant(QString())
+ << QString("ListElement: improperly specified QT_TRID_NOOP");
+}
+
+void tst_qquicklistmodel::static_i18n()
+{
+ QFETCH(QString, qml);
+ QFETCH(QVariant, value);
+ QFETCH(QString, error);
+
+ qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+
+ if (!error.isEmpty()) {
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), error);
+ return;
+ }
+
+ QVERIFY(!component.isError());
+
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+
+ QVariant actual = obj->property("test");
+
+ QCOMPARE(actual, value);
+ QCOMPARE(actual.toString(), value.toString());
+
+ delete obj;
+}
+
+void tst_qquicklistmodel::static_nestedElements()
+{
+ QFETCH(int, elementCount);
+
+ QStringList elements;
+ for (int i=0; i<elementCount; i++)
+ elements.append("ListElement { a: 1; b: 2 }");
+ QString elementsStr = elements.join(",\n") + "\n";
+
+ QString componentStr =
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ " property variant count: model.get(0).attributes.count\n"
+ " ListModel {\n"
+ " id: model\n"
+ " ListElement {\n"
+ " attributes: [\n";
+ componentStr += elementsStr.toUtf8().constData();
+ componentStr +=
+ " ]\n"
+ " }\n"
+ " }\n"
+ "}";
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
+
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+
+ QVariant count = obj->property("count");
+ QCOMPARE(count.type(), QVariant::Int);
+ QCOMPARE(count.toInt(), elementCount);
+
+ delete obj;
+}
+
+void tst_qquicklistmodel::static_nestedElements_data()
+{
+ QTest::addColumn<int>("elementCount");
+
+ QTest::newRow("0 items") << 0;
+ QTest::newRow("1 item") << 1;
+ QTest::newRow("2 items") << 2;
+ QTest::newRow("many items") << 5;
+}
+
+void tst_qquicklistmodel::dynamic_data()
+{
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("result");
+ QTest::addColumn<QString>("warning");
+ QTest::addColumn<bool>("dynamicRoles");
+
+ for (int i=0 ; i < 2 ; ++i) {
+ bool dr = (i != 0);
+
+ // Simple flat model
+ QTest::newRow("count") << "count" << 0 << "" << dr;
+
+ QTest::newRow("get1") << "{get(0) === undefined}" << 1 << "" << dr;
+ QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "" << dr;
+ QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "" << dr;
+ QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "" << dr;
+ QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "" << dr;
+
+ QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "" << dr;
+ QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "" << dr;
+ QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "" << dr;
+ QTest::newRow("append4a") << "{append(123)}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
+ QTest::newRow("append4b") << "{append([{'foo':123},{'foo':456},{'foo':789}]);count}" << 3 << "" << dr;
+ QTest::newRow("append4c") << "{append([{'foo':123},{'foo':456},{'foo':789}]);get(1).foo}" << 456 << "" << dr;
+
+ QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "" << dr;
+ QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "" << dr;
+ QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << "" << dr;
+
+ QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "" << dr;
+ QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "" << dr;
+ QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << "" << dr;
+ QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [-1 - 0] out of range [0 - 1]" << dr;
+ QTest::newRow("remove4a") << "{remove(0)}" << 0 << "<Unknown File>: QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr;
+ QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << "<Unknown File>: QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr;
+ QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [1 - 2] out of range [0 - 1]" << dr;
+ QTest::newRow("remove5a") << "{append({'foo':123});append({'foo':456});remove(0,2);count}" << 0 << "" << dr;
+ QTest::newRow("remove5b") << "{append({'foo':123});append({'foo':456});remove(0,1);count}" << 1 << "" << dr;
+ QTest::newRow("remove5c") << "{append({'foo':123});append({'foo':456});remove(1,1);count}" << 1 << "" << dr;
+ QTest::newRow("remove5d") << "{append({'foo':123});append({'foo':456});remove(0,1);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("remove5e") << "{append({'foo':123});append({'foo':456});remove(1,1);get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("remove5f") << "{append({'foo':123});append({'foo':456});append({'foo':789});remove(0,1);remove(1,1);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("remove6a") << "{remove();count}" << 0 << "<Unknown File>: QML ListModel: remove: incorrect number of arguments" << dr;
+ QTest::newRow("remove6b") << "{remove(1,2,3);count}" << 0 << "<Unknown File>: QML ListModel: remove: incorrect number of arguments" << dr;
+ QTest::newRow("remove7a") << "{append({'foo':123});remove(0,0);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [0 - 0] out of range [0 - 1]" << dr;
+ QTest::newRow("remove7b") << "{append({'foo':123});remove(0,-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [0 - -1] out of range [0 - 1]" << dr;
+
+ QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "" << dr;
+ QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "<Unknown File>: QML ListModel: insert: index 1 out of range" << dr;
+ QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "" << dr;
+ QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "" << dr;
+ QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "" << dr;
+ QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << "<Unknown File>: QML ListModel: insert: index -1 out of range" << dr;
+ QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
+ QTest::newRow("insert5b") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);count}" << 3 << "" << dr;
+ QTest::newRow("insert5c") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);get(2).foo}" << 33 << "" << dr;
+
+ QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "" << dr;
+ QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "" << dr;
+ QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "" << dr;
+ QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "" << dr;
+ QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr;
+ QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr;
+ QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr;
+ QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "" << dr;
+
+ QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "" << dr;
+ QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "" << dr;
+ QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "" << dr;
+ QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index 0 out of range" << dr;
+ QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr;
+ QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << "<Unknown File>: QML ListModel: set: index 1 out of range" << dr;
+ QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "" << dr;
+
+ QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "" << dr;
+ QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "" << dr;
+ QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "" << dr;
+ QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "" << dr;
+ QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "" << dr;
+ QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "" << dr;
+ QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "" << dr;
+ QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
+ QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
+ QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
+ QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
+
+ QTest::newRow("large1") << "{append({'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8});get(0).h}" << 8 << "" << dr;
+
+ QTest::newRow("datatypes1") << "{append({'a':1});append({'a':'string'});}" << 0 << "<Unknown File>: Can't assign to existing role 'a' of different type [String -> Number]" << dr;
+
+ QTest::newRow("null") << "{append({'a':null});}" << 0 << "" << dr;
+ QTest::newRow("setNull") << "{append({'a':1});set(0, {'a':null});}" << 0 << "" << dr;
+ QTest::newRow("setString") << "{append({'a':'hello'});set(0, {'a':'world'});get(0).a == 'world'}" << 1 << "" << dr;
+ QTest::newRow("setInt") << "{append({'a':5});set(0, {'a':10});get(0).a}" << 10 << "" << dr;
+ QTest::newRow("setNumber") << "{append({'a':6});set(0, {'a':5.5});get(0).a < 5.6}" << 1 << "" << dr;
+ QTest::newRow("badType0") << "{append({'a':'hello'});set(0, {'a':1});}" << 0 << "<Unknown File>: Can't assign to existing role 'a' of different type [Number -> String]" << dr;
+ QTest::newRow("invalidInsert0") << "{insert(0);}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
+ QTest::newRow("invalidAppend0") << "{append();}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
+ QTest::newRow("invalidInsert1") << "{insert(0, 34);}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
+ QTest::newRow("invalidAppend1") << "{append(37);}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
+
+ // QObjects
+ QTest::newRow("qobject0") << "{append({'a':dummyItem0});}" << 0 << "" << dr;
+ QTest::newRow("qobject1") << "{append({'a':dummyItem0});set(0,{'a':dummyItem1});get(0).a == dummyItem1;}" << 1 << "" << dr;
+ QTest::newRow("qobject2") << "{append({'a':dummyItem0});get(0).a == dummyItem0;}" << 1 << "" << dr;
+ QTest::newRow("qobject3") << "{append({'a':dummyItem0});append({'b':1});}" << 0 << "" << dr;
+
+ // JS objects
+ QTest::newRow("js1") << "{append({'foo':{'prop':1}});count}" << 1 << "" << dr;
+ QTest::newRow("js2") << "{append({'foo':{'prop':27}});get(0).foo.prop}" << 27 << "" << dr;
+ QTest::newRow("js3") << "{append({'foo':{'prop':27}});append({'bar':1});count}" << 2 << "" << dr;
+ QTest::newRow("js4") << "{append({'foo':{'prop':27}});append({'bar':1});set(0, {'foo':{'prop':28}});get(0).foo.prop}" << 28 << "" << dr;
+ QTest::newRow("js5") << "{append({'foo':{'prop':27}});append({'bar':1});set(1, {'foo':{'prop':33}});get(1).foo.prop}" << 33 << "" << dr;
+ QTest::newRow("js6") << "{append({'foo':{'prop':27}});clear();count}" << 0 << "" << dr;
+ QTest::newRow("js7") << "{append({'foo':{'prop':27}});set(0, {'foo':null});count}" << 1 << "" << dr;
+ QTest::newRow("js8") << "{append({'foo':{'prop':27}});set(0, {'foo':{'prop2':31}});get(0).foo.prop2}" << 31 << "" << dr;
+
+ // Nested models
+ QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "" << dr;
+ QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "" << dr;
+ QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "" << dr;
+
+ QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << "" << dr;
+ QTest::newRow("nested-set") << "{append({'foo':[{'x':1}]});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << "" << dr;
+
+ QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << "" << dr;
+ QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << "" << dr;
+ }
+}
+
+void tst_qquicklistmodel::dynamic()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+ QFETCH(bool, dynamicRoles);
+
+ QQuickItem dummyItem0, dummyItem1;
+ QQmlEngine engine;
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+ engine.rootContext()->setContextProperty("dummyItem0", QVariant::fromValue(&dummyItem0));
+ engine.rootContext()->setContextProperty("dummyItem1", QVariant::fromValue(&dummyItem1));
+ QQmlExpression e(engine.rootContext(), &model, script);
+ if (isValidErrorMessage(warning, dynamicRoles))
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QSignalSpy spyCount(&model, SIGNAL(countChanged()));
+
+ int actual = e.evaluate().toInt();
+ if (e.hasError())
+ qDebug() << e.error(); // errors not expected
+
+ QCOMPARE(actual,result);
+
+ if (model.count() > 0)
+ QVERIFY(spyCount.count() > 0);
+}
+
+void tst_qquicklistmodel::dynamic_worker_data()
+{
+ dynamic_data();
+}
+
+void tst_qquicklistmodel::dynamic_worker()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+ QFETCH(bool, dynamicRoles);
+
+ if (QByteArray(QTest::currentDataTag()).startsWith("qobject"))
+ return;
+
+ // This is same as dynamic() except it applies the test to a ListModel called
+ // from a WorkerScript.
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("model.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ QSignalSpy spyCount(&model, SIGNAL(countChanged()));
+
+ if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
+ script = script.mid(1, script.length() - 2);
+ QVariantList operations;
+ foreach (const QString &s, script.split(';')) {
+ if (!s.isEmpty())
+ operations << s;
+ }
+
+ if (isValidErrorMessage(warning, dynamicRoles))
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations)));
+ waitForWorker(item);
+ QCOMPARE(QQmlProperty(item, "result").read().toInt(), result);
+
+ if (model.count() > 0)
+ QVERIFY(spyCount.count() > 0);
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::dynamic_worker_sync_data()
+{
+ dynamic_data();
+}
+
+void tst_qquicklistmodel::dynamic_worker_sync()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+ QFETCH(bool, dynamicRoles);
+
+ if (QByteArray(QTest::currentDataTag()).startsWith("qobject"))
+ return;
+
+ // This is the same as dynamic_worker() except that it executes a set of list operations
+ // from the worker script, calls sync(), and tests the changes are reflected in the
+ // list in the main thread
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("model.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
+ script = script.mid(1, script.length() - 2);
+ QVariantList operations;
+ foreach (const QString &s, script.split(';')) {
+ if (!s.isEmpty())
+ operations << s;
+ }
+
+ if (isValidErrorMessage(warning, dynamicRoles))
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ // execute a set of commands on the worker list model, then check the
+ // changes are reflected in the list model in the main thread
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
+ waitForWorker(item);
+
+ QQmlExpression e(eng.rootContext(), &model, operations.last().toString());
+ QCOMPARE(e.evaluate().toInt(), result);
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::enumerate()
+{
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("enumerate.qml"));
+ QVERIFY(!component.isError());
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item != 0);
+
+ QLatin1String expectedStrings[] = {
+ QLatin1String("val1=1Y"),
+ QLatin1String("val2=2Y"),
+ QLatin1String("val3=strY"),
+ QLatin1String("val4=falseN"),
+ QLatin1String("val5=trueY")
+ };
+
+ int expectedStringCount = sizeof(expectedStrings) / sizeof(expectedStrings[0]);
+
+ QStringList r = item->property("result").toString().split(":");
+
+ int matchCount = 0;
+ for (int i=0 ; i < expectedStringCount ; ++i) {
+ const QLatin1String &expectedString = expectedStrings[i];
+
+ QStringList::const_iterator it = r.begin();
+ QStringList::const_iterator end = r.end();
+
+ while (it != end) {
+ if (it->compare(expectedString) == 0) {
+ ++matchCount;
+ break;
+ }
+ ++it;
+ }
+ }
+
+ QVERIFY(matchCount == expectedStringCount);
+
+ delete item;
+}
+
+void tst_qquicklistmodel::error_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("id not allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { id: fred } }"
+ << "ListElement: cannot use reserved \"id\" property";
+
+ QTest::newRow("id allowed in ListModel")
+ << "import QtQuick 2.0\nListModel { id:model }"
+ << "";
+
+ QTest::newRow("random properties not allowed in ListModel")
+ << "import QtQuick 2.0\nListModel { foo:123 }"
+ << "ListModel: undefined property 'foo'";
+
+ QTest::newRow("random properties allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { foo:123 } }"
+ << "";
+
+ QTest::newRow("bindings not allowed in ListElement")
+ << "import QtQuick 2.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
+ << "ListElement: cannot use script for property value";
+
+ QTest::newRow("random object list properties allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
+ << "";
+
+ QTest::newRow("default properties not allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { Item { } } }"
+ << "ListElement: cannot contain nested elements";
+
+ QTest::newRow("QML elements not allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { a: Item { } } }"
+ << "ListElement: cannot contain nested elements";
+
+ QTest::newRow("qualified ListElement supported")
+ << "import QtQuick 2.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }"
+ << "";
+
+ QTest::newRow("qualified ListElement required")
+ << "import QtQuick 2.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }"
+ << "ListElement is not a type";
+
+ QTest::newRow("unknown qualified ListElement not allowed")
+ << "import QtQuick 2.0\nListModel { Foo.ListElement { a: 123 } }"
+ << "Foo.ListElement - Foo is not a namespace";
+}
+
+void tst_qquicklistmodel::error()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, error);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+ if (error.isEmpty()) {
+ QVERIFY(!component.isError());
+ } else {
+ QVERIFY(component.isError());
+ QList<QQmlError> errors = component.errors();
+ QCOMPARE(errors.count(),1);
+ QCOMPARE(errors.at(0).description(),error);
+ }
+}
+
+void tst_qquicklistmodel::syncError()
+{
+ QString qml = "import QtQuick 2.0\nListModel { id: lm; Component.onCompleted: lm.sync() }";
+ QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript";
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+ QTest::ignoreMessage(QtWarningMsg,error.toUtf8());
+ QObject *obj = component.create();
+ QVERIFY(obj);
+ delete obj;
+}
+
+/*
+ Test model changes from set() are available to the view
+*/
+void tst_qquicklistmodel::set_data()
+{
+ QTest::addColumn<bool>("dynamicRoles");
+
+ QTest::newRow("staticRoles") << false;
+ QTest::newRow("dynamicRoles") << true;
+}
+
+void tst_qquicklistmodel::set()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine engine;
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->setContextProperty("model", &model);
+
+ RUNEXPR("model.append({test:false})");
+ RUNEXPR("model.set(0, {test:true})");
+
+ QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache
+ QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true));
+
+ RUNEXPR("model.set(0, {test:false})");
+ QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated
+ QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false));
+
+ QString warning = QString::fromLatin1("<Unknown File>: Can't create role for unsupported data type");
+ if (isValidErrorMessage(warning, dynamicRoles))
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+ QVariant invalidData = QColor();
+ model.setProperty(0, "test", invalidData);
+}
+
+/*
+ Test model changes on values returned by get() are available to the view
+*/
+void tst_qquicklistmodel::get()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "ListModel {}\n", QUrl());
+ QQuickListModel *model = qobject_cast<QQuickListModel*>(component.create());
+ model->setDynamicRoles(dynamicRoles);
+ engine.rootContext()->setContextProperty("model", model);
+
+ RUNEXPR("model.append({roleA: 100})");
+ RUNEXPR("model.append({roleA: 200, roleB: 400})");
+ RUNEXPR("model.append({roleA: 200, roleB: 400})");
+ RUNEXPR("model.append({roleC: {} })");
+ RUNEXPR("model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })");
+
+ QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
+ QQmlExpression expr(engine.rootContext(), model, expression);
+ expr.evaluate();
+ QVERIFY(!expr.hasError());
+
+ int role = roleFromName(model, roleName);
+ QVERIFY(role >= 0);
+
+ if (roleValue.type() == QVariant::List) {
+ const QVariantList &list = roleValue.toList();
+ QVERIFY(compareVariantList(list, model->data(index, role)));
+ } else {
+ QCOMPARE(model->data(index, role), roleValue);
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
+
+ delete model;
+}
+
+void tst_qquicklistmodel::get_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<QString>("roleName");
+ QTest::addColumn<QVariant>("roleValue");
+ QTest::addColumn<bool>("dynamicRoles");
+
+ for (int i=0 ; i < 2 ; ++i) {
+ bool dr = (i != 0);
+
+ QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500) << dr;
+ QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500) << dr;
+
+ QVariantMap map;
+ QVariantList list;
+ map.clear(); map["a"] = 50; map["b"] = 500;
+ list << map;
+ map.clear(); map["c"] = 1000;
+ list << map;
+ QTest::newRow("list of objects") << "get(2).roleD = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleD" << QVariant::fromValue(list) << dr;
+ }
+}
+
+void tst_qquicklistmodel::get_worker()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("model.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ // Add some values like get() test
+ RUNEVAL(item, "model.append({roleA: 100})");
+ RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
+ RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
+ RUNEVAL(item, "model.append({roleC: {} })");
+ RUNEVAL(item, "model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })");
+
+ int role = roleFromName(&model, roleName);
+ QVERIFY(role >= 0);
+
+ QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
+
+ // in the worker thread, change the model data and call sync()
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, QStringList(expression))));
+ waitForWorker(item);
+
+ // see if we receive the model changes in the main thread's model
+ if (roleValue.type() == QVariant::List) {
+ const QVariantList &list = roleValue.toList();
+ QVERIFY(compareVariantList(list, model.data(index, role)));
+ } else {
+ QCOMPARE(model.data(index, role), roleValue);
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QVERIFY(spyResult.at(2).value<QList<int> >().contains(role));
+}
+
+void tst_qquicklistmodel::get_worker_data()
+{
+ get_data();
+}
+
+/*
+ Test that the tests run in get() also work for nested list data
+*/
+void tst_qquicklistmodel::get_nested()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+ QFETCH(bool, dynamicRoles);
+
+ if (roleValue.type() == QVariant::Map)
+ return;
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "ListModel {}", QUrl());
+ QQuickListModel *model = qobject_cast<QQuickListModel*>(component.create());
+ model->setDynamicRoles(dynamicRoles);
+ QVERIFY(component.errorString().isEmpty());
+ QQuickListModel *childModel;
+ engine.rootContext()->setContextProperty("model", model);
+
+ RUNEXPR("model.append({ listRoleA: [\n"
+ "{ roleA: 100 },\n"
+ "{ roleA: 200, roleB: 400 },\n"
+ "{ roleA: 200, roleB: 400 }, \n"
+ "{ roleC: {} }, \n"
+ "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
+ "] })\n");
+
+ RUNEXPR("model.append({ listRoleA: [\n"
+ "{ roleA: 100 },\n"
+ "{ roleA: 200, roleB: 400 },\n"
+ "{ roleA: 200, roleB: 400 }, \n"
+ "{ roleC: {} }, \n"
+ "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
+ "],\n"
+ "listRoleB: [\n"
+ "{ roleA: 100 },\n"
+ "{ roleA: 200, roleB: 400 },\n"
+ "{ roleA: 200, roleB: 400 }, \n"
+ "{ roleC: {} }, \n"
+ "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
+ "],\n"
+ "listRoleC: [\n"
+ "{ roleA: 100 },\n"
+ "{ roleA: 200, roleB: 400 },\n"
+ "{ roleA: 200, roleB: 400 }, \n"
+ "{ roleC: {} }, \n"
+ "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
+ "] })\n");
+
+ // Test setting the inner list data for:
+ // get(0).listRoleA
+ // get(1).listRoleA
+ // get(1).listRoleB
+ // get(1).listRoleC
+
+ QList<QPair<int, QString> > testData;
+ testData << qMakePair(0, QString("listRoleA"));
+ testData << qMakePair(1, QString("listRoleA"));
+ testData << qMakePair(1, QString("listRoleB"));
+ testData << qMakePair(1, QString("listRoleC"));
+
+ for (int i=0; i<testData.count(); i++) {
+ int outerListIndex = testData[i].first;
+ QString outerListRoleName = testData[i].second;
+ int outerListRole = roleFromName(model, outerListRoleName);
+ QVERIFY(outerListRole >= 0);
+
+ childModel = qobject_cast<QQuickListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>());
+ QVERIFY(childModel);
+
+ QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression);
+ QQmlExpression expr(engine.rootContext(), model, extendedExpression);
+
+ QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList<int>)));
+ expr.evaluate();
+ QVERIFY(!expr.hasError());
+
+ int role = roleFromName(childModel, roleName);
+ QVERIFY(role >= 0);
+ if (roleValue.type() == QVariant::List) {
+ QVERIFY(compareVariantList(roleValue.toList(), childModel->data(index, role)));
+ } else {
+ QCOMPARE(childModel->data(index, role), roleValue);
+ }
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
+ }
+
+ delete model;
+}
+
+void tst_qquicklistmodel::get_nested_data()
+{
+ get_data();
+}
+
+//QTBUG-13754
+void tst_qquicklistmodel::crash_model_with_multiple_roles()
+{
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("multipleroles.qml"));
+ QObject *rootItem = component.create();
+ QVERIFY(component.errorString().isEmpty());
+ QVERIFY(rootItem != 0);
+ QQuickListModel *model = rootItem->findChild<QQuickListModel*>("listModel");
+ QVERIFY(model != 0);
+
+ // used to cause a crash
+ model->setProperty(0, "black", true);
+
+ delete rootItem;
+}
+
+//QTBUG-15190
+void tst_qquicklistmodel::set_model_cache()
+{
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("setmodelcachelist.qml"));
+ QObject *model = component.create();
+ QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+ QVERIFY(model != 0);
+ QVERIFY(model->property("ok").toBool());
+
+ delete model;
+}
+
+void tst_qquicklistmodel::property_changes()
+{
+ QFETCH(QString, script_setup);
+ QFETCH(QString, script_change);
+ QFETCH(QString, roleName);
+ QFETCH(int, listIndex);
+ QFETCH(bool, itemsChanged);
+ QFETCH(QString, testExpression);
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine engine;
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine::setContextForObject(&model, engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+
+ QQmlExpression expr(engine.rootContext(), &model, script_setup);
+ expr.evaluate();
+ QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
+
+ QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:";
+ QString qml = "import QtQuick 2.0\n"
+ "Connections {\n"
+ "property bool gotSignal: false\n"
+ "target: model.get(" + QString::number(listIndex) + ")\n"
+ + signalHandler + " gotSignal = true\n"
+ "}\n";
+
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(), QUrl::fromLocalFile(""));
+ engine.rootContext()->setContextProperty("model", &model);
+ QObject *connectionsObject = component.create();
+ QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+
+ QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
+
+ expr.setExpression(script_change);
+ expr.evaluate();
+ QVERIFY2(!expr.hasError(), QTest::toString(expr.error()));
+
+ // test the object returned by get() emits the correct signals
+ QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged);
+
+ // test itemsChanged() is emitted correctly
+ if (itemsChanged) {
+ QCOMPARE(spyItemsChanged.count(), 1);
+ QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
+ QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
+ } else {
+ QCOMPARE(spyItemsChanged.count(), 0);
+ }
+
+ expr.setExpression(testExpression);
+ QCOMPARE(expr.evaluate().toBool(), true);
+
+ delete connectionsObject;
+}
+
+void tst_qquicklistmodel::property_changes_data()
+{
+ QTest::addColumn<QString>("script_setup");
+ QTest::addColumn<QString>("script_change");
+ QTest::addColumn<QString>("roleName");
+ QTest::addColumn<int>("listIndex");
+ QTest::addColumn<bool>("itemsChanged");
+ QTest::addColumn<QString>("testExpression");
+ QTest::addColumn<bool>("dynamicRoles");
+
+ for (int i=0 ; i < 2 ; ++i) {
+ bool dr = (i != 0);
+
+ QTest::newRow("set: plain") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':123});"
+ << "b" << 0 << true << "get(0).b == 123" << dr;
+ QTest::newRow("setProperty: plain") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 123);"
+ << "b" << 0 << true << "get(0).b == 123" << dr;
+
+ QTest::newRow("set: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':456});"
+ << "b" << 0 << false << "get(0).b == 456" << dr;
+ QTest::newRow("setProperty: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 456);"
+ << "b" << 0 << false << "get(0).b == 456" << dr;
+
+ QTest::newRow("set: inserted item")
+ << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
+ << "set(1, {'a':456});"
+ << "a" << 1 << true << "get(1).a == 456" << dr;
+ QTest::newRow("setProperty: inserted item")
+ << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
+ << "setProperty(1, 'a', 456);"
+ << "a" << 1 << true << "get(1).a == 456" << dr;
+ QTest::newRow("get: inserted item")
+ << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
+ << "get(1).a = 456;"
+ << "a" << 1 << true << "get(1).a == 456" << dr;
+ QTest::newRow("set: removed item")
+ << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
+ << "set(0, {'a':456});"
+ << "a" << 0 << true << "get(0).a == 456" << dr;
+ QTest::newRow("setProperty: removed item")
+ << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
+ << "setProperty(0, 'a', 456);"
+ << "a" << 0 << true << "get(0).a == 456" << dr;
+ QTest::newRow("get: removed item")
+ << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
+ << "get(0).a = 456;"
+ << "a" << 0 << true << "get(0).a == 456" << dr;
+
+ // Following tests only call set() since setProperty() only allows plain
+ // values, not lists, as the argument.
+ // Note that when a list is changed, itemsChanged() is currently always
+ // emitted regardless of whether it actually changed or not.
+
+ QTest::newRow("nested-set: list, new size") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2}]});"
+ << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2" << dr;
+
+ QTest::newRow("nested-set: list, empty -> non-empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
+ << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr;
+
+ QTest::newRow("nested-set: list, non-empty -> empty") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[]});"
+ << "b" << 0 << true << "get(0).b.count == 0" << dr;
+
+ QTest::newRow("nested-set: list, same size, different values") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':222},{'a':3}]});"
+ << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 222 && get(0).b.get(2).a == 3" << dr;
+
+ QTest::newRow("nested-set: list, no changes") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
+ << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr;
+
+ QTest::newRow("nested-set: list, no changes, empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[]});"
+ << "b" << 0 << true << "get(0).b.count == 0" << dr;
+ }
+}
+
+void tst_qquicklistmodel::property_changes_worker()
+{
+ QFETCH(QString, script_setup);
+ QFETCH(QString, script_change);
+ QFETCH(QString, roleName);
+ QFETCH(int, listIndex);
+ QFETCH(bool, itemsChanged);
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
+ QQuickItem *item = createWorkerTest(&engine, &component, &model);
+ QVERIFY(item != 0);
+
+ QQmlExpression expr(engine.rootContext(), &model, script_setup);
+ expr.evaluate();
+ QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
+
+ QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
+
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, QStringList(script_change))));
+ waitForWorker(item);
+
+ // test itemsChanged() is emitted correctly
+ if (itemsChanged) {
+ QCOMPARE(spyItemsChanged.count(), 1);
+ QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
+ QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
+ } else {
+ QCOMPARE(spyItemsChanged.count(), 0);
+ }
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::property_changes_worker_data()
+{
+ property_changes_data();
+}
+
+void tst_qquicklistmodel::clear_data()
+{
+ QTest::addColumn<bool>("dynamicRoles");
+
+ QTest::newRow("staticRoles") << false;
+ QTest::newRow("dynamicRoles") << true;
+}
+
+void tst_qquicklistmodel::clear()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine engine;
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine::setContextForObject(&model, engine.rootContext());
+ engine.rootContext()->setContextProperty("model", &model);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
+ QCOMPARE(model.count(), 1);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
+ RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
+ QCOMPARE(model.count(), 2);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ // clearing does not remove the roles
+ RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})");
+ QList<int> roles = model.roles();
+ model.clear();
+ QCOMPARE(model.count(), 0);
+ QCOMPARE(model.roles(), roles);
+ QCOMPARE(model.toString(roles[0]), QString("propertyA"));
+ QCOMPARE(model.toString(roles[1]), QString("propertyB"));
+ QCOMPARE(model.toString(roles[2]), QString("propertyC"));
+}
+
+void tst_qquicklistmodel::signal_handlers_data()
+{
+ QTest::addColumn<bool>("dynamicRoles");
+
+ QTest::newRow("staticRoles") << false;
+ QTest::newRow("dynamicRoles") << true;
+}
+
+void tst_qquicklistmodel::signal_handlers()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("signalhandlers.qml"));
+ QObject *model = component.create();
+ QQuickListModel *lm = qobject_cast<QQuickListModel *>(model);
+ QVERIFY(lm != 0);
+ lm->setDynamicRoles(dynamicRoles);
+ QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+ QVERIFY(model != 0);
+ QVERIFY(model->property("ok").toBool());
+
+ delete model;
+}
+
+void tst_qquicklistmodel::worker_sync_data()
+{
+ QTest::addColumn<bool>("dynamicRoles");
+
+ QTest::newRow("staticRoles") << false;
+ QTest::newRow("dynamicRoles") << true;
+}
+
+void tst_qquicklistmodel::worker_sync()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("workersync.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ QVERIFY(model.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItem0"));
+
+ QVERIFY(model.count() == 2);
+ QVariant childData = model.data(0, 0);
+ QQuickListModel *childModel = qobject_cast<QQuickListModel *>(childData.value<QObject *>());
+ QVERIFY(childModel);
+ QVERIFY(childModel->count() == 1);
+
+ QSignalSpy spyModelInserted(&model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyChildInserted(childModel, SIGNAL(itemsInserted(int,int)));
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 2);
+ QVERIFY(childModel->count() == 1);
+ QVERIFY(spyModelInserted.count() == 0);
+ QVERIFY(spyChildInserted.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 2);
+ QVERIFY(childModel->count() == 2);
+ QVERIFY(spyModelInserted.count() == 0);
+ QVERIFY(spyChildInserted.count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 2);
+ QVERIFY(childModel->count() == 2);
+ QVERIFY(spyModelInserted.count() == 0);
+ QVERIFY(spyChildInserted.count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 2);
+ QVERIFY(childModel->count() == 3);
+ QVERIFY(spyModelInserted.count() == 0);
+ QVERIFY(spyChildInserted.count() == 2);
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::worker_remove_element_data()
+{
+ worker_sync_data();
+}
+
+void tst_qquicklistmodel::worker_remove_element()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("workerremoveelement.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int)));
+
+ QVERIFY(model.count() == 0);
+ QVERIFY(spyModelRemoved.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
+
+ QVERIFY(model.count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 1);
+ QVERIFY(spyModelRemoved.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 0);
+ QVERIFY(spyModelRemoved.count() == 1);
+
+ delete item;
+ qApp->processEvents();
+
+ {
+ //don't crash if model was deleted earlier
+ QQuickListModel* model = new QQuickListModel;
+ model->setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("workerremoveelement.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, model);
+ QVERIFY(item != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
+
+ QVERIFY(model->count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker"));
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ delete model;
+ qApp->processEvents(); //must not crash here
+ waitForWorker(item);
+
+ delete item;
+ }
+}
+
+void tst_qquicklistmodel::worker_remove_list_data()
+{
+ worker_sync_data();
+}
+
+void tst_qquicklistmodel::worker_remove_list()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("workerremovelist.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int)));
+
+ QVERIFY(model.count() == 0);
+ QVERIFY(spyModelRemoved.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addList"));
+
+ QVERIFY(model.count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "removeListViaWorker"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 1);
+ QVERIFY(spyModelRemoved.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 0);
+ QVERIFY(spyModelRemoved.count() == 1);
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::role_mode_data()
+{
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("result");
+ QTest::addColumn<QString>("warning");
+
+ QTest::newRow("default0") << "{dynamicRoles}" << 0 << "";
+ QTest::newRow("default1") << "{append({'a':1});dynamicRoles}" << 0 << "";
+
+ QTest::newRow("enableDynamic0") << "{dynamicRoles=true;dynamicRoles}" << 1 << "";
+ QTest::newRow("enableDynamic1") << "{append({'a':1});dynamicRoles=true;dynamicRoles}" << 0 << "<Unknown File>: QML ListModel: unable to enable dynamic roles as this model is not empty!";
+ QTest::newRow("enableDynamic2") << "{dynamicRoles=true;append({'a':1});dynamicRoles=false;dynamicRoles}" << 1 << "<Unknown File>: QML ListModel: unable to enable static roles as this model is not empty!";
+}
+
+void tst_qquicklistmodel::role_mode()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+
+ QQmlEngine engine;
+ QQuickListModel model;
+ QQmlEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+ QQmlExpression e(engine.rootContext(), &model, script);
+ if (!warning.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ int actual = e.evaluate().toInt();
+ if (e.hasError())
+ qDebug() << e.error(); // errors not expected
+
+ QCOMPARE(actual,result);
+}
+
+void tst_qquicklistmodel::dynamic_role_data()
+{
+ QTest::addColumn<QString>("preamble");
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("result");
+
+ QTest::newRow("sync1") << "{append({'a':[{'b':1},{'b':2}]})}" << "{get(0).a = 'string';count}" << 1;
+}
+
+void tst_qquicklistmodel::dynamic_role()
+{
+ QFETCH(QString, preamble);
+ QFETCH(QString, script);
+ QFETCH(int, result);
+
+ QQuickListModel model;
+ model.setDynamicRoles(true);
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QQuickItem *item = createWorkerTest(&engine, &component, &model);
+ QVERIFY(item != 0);
+
+ QQmlExpression preExp(engine.rootContext(), &model, preamble);
+ QCOMPARE(preExp.evaluate().toInt(), 0);
+
+ if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
+ script = script.mid(1, script.length() - 2);
+ QVariantList operations;
+ foreach (const QString &s, script.split(';')) {
+ if (!s.isEmpty())
+ operations << s;
+ }
+
+ // execute a set of commands on the worker list model, then check the
+ // changes are reflected in the list model in the main thread
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
+ waitForWorker(item);
+
+ QQmlExpression e(engine.rootContext(), &model, operations.last().toString());
+ QCOMPARE(e.evaluate().toInt(), result);
+
+ delete item;
+ qApp->processEvents();
+}
+
+QTEST_MAIN(tst_qquicklistmodel)
+
+#include "tst_qquicklistmodel.moc"
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml
index 0ac56d9b66..0ac56d9b66 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml
+++ b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js b/tests/auto/qml/qquickworkerscript/data/Global.js
index 6bdb4a56b9..6bdb4a56b9 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js
+++ b/tests/auto/qml/qquickworkerscript/data/Global.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/externalObjectWorker.qml b/tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml
index 1dae608b50..1dae608b50 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/externalObjectWorker.qml
+++ b/tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js b/tests/auto/qml/qquickworkerscript/data/script.js
index 90aae263a1..90aae263a1 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js
+++ b/tests/auto/qml/qquickworkerscript/data/script.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js b/tests/auto/qml/qquickworkerscript/data/script_error_onCall.js
index f589b0ef40..f589b0ef40 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_error_onCall.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js b/tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js
index 1d6eab2285..1d6eab2285 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js b/tests/auto/qml/qquickworkerscript/data/script_fixed_return.js
index 14f6f178ae..14f6f178ae 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_fixed_return.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js b/tests/auto/qml/qquickworkerscript/data/script_include.js
index 0385d91170..0385d91170 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_include.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js b/tests/auto/qml/qquickworkerscript/data/script_pragma.js
index cb3b6d3398..cb3b6d3398 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_pragma.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js b/tests/auto/qml/qquickworkerscript/data/stressDispose.js
index 5c4c5ec906..5c4c5ec906 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js
+++ b/tests/auto/qml/qquickworkerscript/data/stressDispose.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml b/tests/auto/qml/qquickworkerscript/data/stressDispose.qml
index 3e8465d6fe..3e8465d6fe 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml
+++ b/tests/auto/qml/qquickworkerscript/data/stressDispose.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/qml/qquickworkerscript/data/worker.qml
index b5a92bf1f5..b5a92bf1f5 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml b/tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml
index aa20783e76..aa20783e76 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml b/tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml
index 8a33aeb44c..8a33aeb44c 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml b/tests/auto/qml/qquickworkerscript/data/worker_include.qml
index 100b8d4551..100b8d4551 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker_include.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml b/tests/auto/qml/qquickworkerscript/data/worker_pragma.qml
index 7e313b3c42..7e313b3c42 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker_pragma.qml
diff --git a/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro b/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro
new file mode 100644
index 0000000000..e9c358c3cc
--- /dev/null
+++ b/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickworkerscript
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickworkerscript.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private testlib
diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
new file mode 100644
index 0000000000..6569b877fe
--- /dev/null
+++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
@@ -0,0 +1,300 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfileinfo.h>
+#include <QtQml/qjsengine.h>
+
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+
+#include <private/qquickworkerscript_p.h>
+#include <private/qqmlengine_p.h>
+#include "../../shared/util.h"
+
+class tst_QQuickWorkerScript : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickWorkerScript() {}
+private slots:
+ void source();
+ void messaging();
+ void messaging_data();
+ void messaging_sendQObjectList();
+ void messaging_sendJsObject();
+ void messaging_sendExternalObject();
+ void script_with_pragma();
+ void script_included();
+ void scriptError_onLoad();
+ void scriptError_onCall();
+ void stressDispose();
+
+private:
+ void waitForEchoMessage(QQuickWorkerScript *worker) {
+ QEventLoop loop;
+ QVERIFY(connect(worker, SIGNAL(done()), &loop, SLOT(quit())));
+ QTimer timer;
+ timer.setSingleShot(true);
+ connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.start(10000);
+ loop.exec();
+ QVERIFY(timer.isActive());
+ }
+
+ QQmlEngine m_engine;
+};
+
+void tst_QQuickWorkerScript::source()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+ const QMetaObject *mo = worker->metaObject();
+
+ QVariant value(100);
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+
+ QUrl source = testFileUrl("script_fixed_return.js");
+ worker->setSource(source);
+ QCOMPARE(worker->source(), source);
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), qVariantFromValue(QString("Hello_World")));
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::messaging()
+{
+ QFETCH(QVariant, value);
+
+ QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::messaging_data()
+{
+ QTest::addColumn<QVariant>("value");
+
+ QTest::newRow("invalid") << QVariant();
+ QTest::newRow("bool") << qVariantFromValue(true);
+ QTest::newRow("int") << qVariantFromValue(1001);
+ QTest::newRow("real") << qVariantFromValue(10334.375);
+ QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!"));
+ QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c"));
+ QTest::newRow("date time") << qVariantFromValue(QDateTime::currentDateTime());
+#ifndef QT_NO_REGEXP
+ // QtScript's QScriptValue -> QRegExp uses RegExp2 pattern syntax
+ QTest::newRow("regexp") << qVariantFromValue(QRegExp("^\\d\\d?$", Qt::CaseInsensitive, QRegExp::RegExp2));
+#endif
+}
+
+void tst_QQuickWorkerScript::messaging_sendQObjectList()
+{
+ // Not allowed to send QObjects other than QQuickListModelWorkerAgent
+ // instances. If objects are sent in a list, they will be sent as 'undefined'
+ // js values.
+
+ QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QVariantList objects;
+ for (int i=0; i<3; i++)
+ objects << qVariantFromValue(new QObject(this));
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(objects))));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QVariantList result = mo->property(mo->indexOfProperty("response")).read(worker).value<QVariantList>();
+ QCOMPARE(result, (QVariantList() << QVariant() << QVariant() << QVariant()));
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::messaging_sendJsObject()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ // Properties are in alphabetical order to enable string-based comparison after
+ // QVariant roundtrip, since the properties will be stored in a QVariantMap.
+ QString jsObject = "{'haste': 1125, 'name': 'zyz', 'spell power': 3101}";
+
+ QVariantMap map;
+ map.insert("haste", 1125);
+ map.insert("name", "zyz");
+ map.insert("spell power", 3101);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(map))));
+ waitForEchoMessage(worker);
+
+ QVariant result = qVariantFromValue(false);
+ QVERIFY(QMetaObject::invokeMethod(worker, "compareLiteralResponse", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, jsObject)));
+ QVERIFY(result.toBool());
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::messaging_sendExternalObject()
+{
+ QQmlComponent component(&m_engine, testFileUrl("externalObjectWorker.qml"));
+ QObject *obj = component.create();
+ QVERIFY(obj);
+ QMetaObject::invokeMethod(obj, "testExternalObject");
+ QTest::qWait(100); // shouldn't crash.
+ delete obj;
+}
+
+void tst_QQuickWorkerScript::script_with_pragma()
+{
+ QVariant value(100);
+
+ QQmlComponent component(&m_engine, testFileUrl("worker_pragma.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::script_included()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker_include.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QString value("Hello");
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World");
+
+ qApp->processEvents();
+ delete worker;
+}
+
+static QString qquickworkerscript_lastWarning;
+static void qquickworkerscript_warningsHandler(QtMsgType type, const char *msg)
+{
+ if (type == QtWarningMsg)
+ qquickworkerscript_lastWarning = QString::fromUtf8(msg);
+}
+
+void tst_QQuickWorkerScript::scriptError_onLoad()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker_error_onLoad.qml"));
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(qquickworkerscript_warningsHandler);
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QTRY_COMPARE(qquickworkerscript_lastWarning,
+ testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier"));
+
+ qInstallMsgHandler(previousMsgHandler);
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::scriptError_onCall()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker_error_onCall.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(qquickworkerscript_warningsHandler);
+ QVariant value;
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+
+ QTRY_COMPARE(qquickworkerscript_lastWarning,
+ testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData"));
+
+ qInstallMsgHandler(previousMsgHandler);
+ qApp->processEvents();
+ delete worker;
+}
+
+// Rapidly create and destroy worker scripts to test resources are being disposed
+// in the correct isolate
+void tst_QQuickWorkerScript::stressDispose()
+{
+ for (int ii = 0; ii < 100; ++ii) {
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stressDispose.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+ delete o;
+ }
+}
+
+QTEST_MAIN(tst_QQuickWorkerScript)
+
+#include "tst_qquickworkerscript.moc"
diff --git a/tests/auto/qml/runall.sh b/tests/auto/qml/runall.sh
new file mode 100644
index 0000000000..9580d8445e
--- /dev/null
+++ b/tests/auto/qml/runall.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+#
+#############################################################################
+##
+## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: http://www.qt-project.org/
+##
+## This file is part of the test suite of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## GNU Lesser General Public License Usage
+## 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.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU General
+## Public License version 3.0 as published by the Free Software Foundation
+## and appearing in the file LICENSE.GPL included in the packaging of this
+## file. Please review the following information to ensure the GNU General
+## Public License version 3.0 requirements will be met:
+## http://www.gnu.org/copyleft/gpl.html.
+##
+## Other Usage
+## Alternatively, this file may be used in accordance with the terms and
+## conditions contained in a signed written agreement between you and Nokia.
+##
+##
+##
+##
+##
+##
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+if [ "$(uname)" = Linux ]
+then
+ Xnest :7 2>/dev/null &
+ sleep 1
+ trap "kill $!" EXIT
+ export DISPLAY=:7
+ export LANG=en_US
+ kwin 2>/dev/null &
+ sleep 1
+fi
+
+function filter
+{
+ exe=$1
+ skip=0
+ while read line
+ do
+ if [ $skip != 0 ]
+ then
+ let skip=skip-1
+ else
+ case "$line" in
+ make*Error) echo "$line";;
+ make*Stop) echo "$line";;
+ /*/bin/make*) ;;
+ make*) ;;
+ install*) ;;
+ QQmlDebugServer:*Waiting*) ;;
+ QQmlDebugServer:*Connection*) ;;
+ */qmake*) ;;
+ */bin/moc*) ;;
+ *targ.debug*) ;;
+ g++*) ;;
+ cd*) ;;
+ XFAIL*) skip=1;;
+ SKIP*) skip=1;;
+ PASS*) ;;
+ QDEBUG*) ;;
+ Makefile*) ;;
+ Config*) ;;
+ Totals*) ;;
+ \**) ;;
+ ./*) ;;
+ *tst_*) echo "$line" ;;
+ *) echo "$exe: $line"
+ esac
+ fi
+ done
+}
+
+make -k -j1 install 2>&1 | filter build
+for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p')
+do
+ echo $exe
+ $exe 2>&1 | filter $exe
+done
+
diff --git a/tests/auto/declarative/v4/data/colorType.qml b/tests/auto/qml/v4/data/colorType.qml
index f6a98a4a3e..f6a98a4a3e 100644
--- a/tests/auto/declarative/v4/data/colorType.qml
+++ b/tests/auto/qml/v4/data/colorType.qml
diff --git a/tests/auto/declarative/v4/data/conditionalExpr.qml b/tests/auto/qml/v4/data/conditionalExpr.qml
index b74a95a94b..b74a95a94b 100644
--- a/tests/auto/declarative/v4/data/conditionalExpr.qml
+++ b/tests/auto/qml/v4/data/conditionalExpr.qml
diff --git a/tests/auto/declarative/v4/data/doubleBoolJump.qml b/tests/auto/qml/v4/data/doubleBoolJump.qml
index 2eea73b573..2eea73b573 100644
--- a/tests/auto/declarative/v4/data/doubleBoolJump.qml
+++ b/tests/auto/qml/v4/data/doubleBoolJump.qml
diff --git a/tests/auto/declarative/v4/data/fetchException.qml b/tests/auto/qml/v4/data/fetchException.qml
index 6431fcfae8..6431fcfae8 100644
--- a/tests/auto/declarative/v4/data/fetchException.qml
+++ b/tests/auto/qml/v4/data/fetchException.qml
diff --git a/tests/auto/declarative/v4/data/logicalOr.2.qml b/tests/auto/qml/v4/data/logicalOr.2.qml
index 54fb78b127..54fb78b127 100644
--- a/tests/auto/declarative/v4/data/logicalOr.2.qml
+++ b/tests/auto/qml/v4/data/logicalOr.2.qml
diff --git a/tests/auto/declarative/v4/data/logicalOr.qml b/tests/auto/qml/v4/data/logicalOr.qml
index 406a7d83eb..406a7d83eb 100644
--- a/tests/auto/declarative/v4/data/logicalOr.qml
+++ b/tests/auto/qml/v4/data/logicalOr.qml
diff --git a/tests/auto/declarative/v4/data/nestedLogicalOr.qml b/tests/auto/qml/v4/data/nestedLogicalOr.qml
index c4478a3e7b..c4478a3e7b 100644
--- a/tests/auto/declarative/v4/data/nestedLogicalOr.qml
+++ b/tests/auto/qml/v4/data/nestedLogicalOr.qml
diff --git a/tests/auto/declarative/v4/data/nestedObjectAccess.qml b/tests/auto/qml/v4/data/nestedObjectAccess.qml
index 56cd17e41e..56cd17e41e 100644
--- a/tests/auto/declarative/v4/data/nestedObjectAccess.qml
+++ b/tests/auto/qml/v4/data/nestedObjectAccess.qml
diff --git a/tests/auto/declarative/v4/data/nullQObject.qml b/tests/auto/qml/v4/data/nullQObject.qml
index 00185b3988..00185b3988 100644
--- a/tests/auto/declarative/v4/data/nullQObject.qml
+++ b/tests/auto/qml/v4/data/nullQObject.qml
diff --git a/tests/auto/declarative/v4/data/qrealToIntRounding.qml b/tests/auto/qml/v4/data/qrealToIntRounding.qml
index ee3d405073..ee3d405073 100644
--- a/tests/auto/declarative/v4/data/qrealToIntRounding.qml
+++ b/tests/auto/qml/v4/data/qrealToIntRounding.qml
diff --git a/tests/auto/declarative/v4/data/qtbug_21883.qml b/tests/auto/qml/v4/data/qtbug_21883.qml
index a51f97c944..a51f97c944 100644
--- a/tests/auto/declarative/v4/data/qtbug_21883.qml
+++ b/tests/auto/qml/v4/data/qtbug_21883.qml
diff --git a/tests/auto/declarative/v4/data/qtbug_22816.qml b/tests/auto/qml/v4/data/qtbug_22816.qml
index bfa8d4948c..bfa8d4948c 100644
--- a/tests/auto/declarative/v4/data/qtbug_22816.qml
+++ b/tests/auto/qml/v4/data/qtbug_22816.qml
diff --git a/tests/auto/declarative/v4/data/stringComparison.qml b/tests/auto/qml/v4/data/stringComparison.qml
index 64b6798c69..64b6798c69 100644
--- a/tests/auto/declarative/v4/data/stringComparison.qml
+++ b/tests/auto/qml/v4/data/stringComparison.qml
diff --git a/tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml b/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml
index a8e05eeda1..a8e05eeda1 100644
--- a/tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml
+++ b/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml
diff --git a/tests/auto/declarative/v4/data/unaryMinus.qml b/tests/auto/qml/v4/data/unaryMinus.qml
index 410654fc3c..410654fc3c 100644
--- a/tests/auto/declarative/v4/data/unaryMinus.qml
+++ b/tests/auto/qml/v4/data/unaryMinus.qml
diff --git a/tests/auto/declarative/v4/data/unaryPlus.qml b/tests/auto/qml/v4/data/unaryPlus.qml
index cd5315a7cc..cd5315a7cc 100644
--- a/tests/auto/declarative/v4/data/unaryPlus.qml
+++ b/tests/auto/qml/v4/data/unaryPlus.qml
diff --git a/tests/auto/declarative/v4/data/unnecessaryReeval.qml b/tests/auto/qml/v4/data/unnecessaryReeval.qml
index 48662d7a2d..48662d7a2d 100644
--- a/tests/auto/declarative/v4/data/unnecessaryReeval.qml
+++ b/tests/auto/qml/v4/data/unnecessaryReeval.qml
diff --git a/tests/auto/qml/v4/testtypes.cpp b/tests/auto/qml/v4/testtypes.cpp
new file mode 100644
index 0000000000..c879cf2226
--- /dev/null
+++ b/tests/auto/qml/v4/testtypes.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+#include <QtQml/qqml.h>
+
+void registerTypes()
+{
+ qmlRegisterType<ResultObject>("Qt.v4", 1,0, "Result");
+ qmlRegisterType<NestedObject>();
+}
diff --git a/tests/auto/declarative/v4/testtypes.h b/tests/auto/qml/v4/testtypes.h
index 02ba721839..02ba721839 100644
--- a/tests/auto/declarative/v4/testtypes.h
+++ b/tests/auto/qml/v4/testtypes.h
diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp
new file mode 100644
index 0000000000..4e3e71f717
--- /dev/null
+++ b/tests/auto/qml/v4/tst_v4.cpp
@@ -0,0 +1,371 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtCore/qdebug.h>
+#include <QtGui/qcolor.h>
+
+#include <private/qv4compiler_p.h>
+
+#include "../../shared/util.h"
+#include "testtypes.h"
+
+class tst_v4 : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_v4() {}
+
+private slots:
+ void initTestCase();
+
+ void unnecessaryReeval();
+ void logicalOr();
+ void nestedLogicalOr();
+ void conditionalExpr();
+ void qtscript();
+ void qtscript_data();
+ void nestedObjectAccess();
+ void subscriptionsInConditionalExpressions();
+ void qtbug_21883();
+ void qtbug_22816();
+ void stringComparison();
+ void unaryMinus();
+ void unaryPlus();
+ void colorType();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_v4::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+}
+
+static int v4ErrorsMsgCount = 0;
+static void v4ErrorsMsgHandler(QtMsgType, const char *message)
+{
+ QByteArray m(message);
+ if (m.contains("QV4"))
+ v4ErrorsMsgCount++;
+}
+
+void tst_v4::qtscript()
+{
+ QFETCH(QString, file);
+ QV4Compiler::enableBindingsTest(true);
+
+ QQmlComponent component(&engine, testFileUrl(file));
+
+ v4ErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(v4ErrorsMsgHandler);
+
+ QObject *o = component.create();
+ delete o;
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(v4ErrorsMsgCount, 0);
+
+ QV4Compiler::enableBindingsTest(false);
+}
+
+void tst_v4::qtscript_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml";
+ QTest::newRow("exception on fetch") << "fetchException.qml";
+ QTest::newRow("logical or") << "logicalOr.qml";
+ QTest::newRow("conditional expressions") << "conditionalExpr.qml";
+ QTest::newRow("double bool jump") << "doubleBoolJump.qml";
+ QTest::newRow("unary minus") << "unaryMinus.qml";
+ QTest::newRow("null qobject") << "nullQObject.qml";
+}
+
+void tst_v4::unnecessaryReeval()
+{
+ QQmlComponent component(&engine, testFileUrl("unnecessaryReeval.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->resultCounter(), 1);
+ QCOMPARE(ro->result(), 19);
+ ro->resetResultCounter();
+
+ ro->setProperty("b", 6);
+
+ QCOMPARE(ro->resultCounter(), 1);
+ QCOMPARE(ro->result(), 6);
+ ro->resetResultCounter();
+
+ ro->setProperty("a", 14);
+
+ QCOMPARE(ro->resultCounter(), 1);
+ QCOMPARE(ro->result(), 7);
+ ro->resetResultCounter();
+
+ ro->setProperty("b", 14);
+ QCOMPARE(ro->resultCounter(), 0);
+ QCOMPARE(ro->result(), 7);
+
+ delete o;
+}
+
+void tst_v4::logicalOr()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalOr.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 0);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalOr.2.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+ }
+}
+
+void tst_v4::nestedLogicalOr()
+{
+ //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038)
+ QQmlComponent component(&engine, testFileUrl("nestedLogicalOr.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+}
+
+void tst_v4::conditionalExpr()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("conditionalExpr.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 0);
+ delete o;
+ }
+}
+
+// This would previously use the metaObject of the root element to result the nested access.
+// That is, the index for accessing "result" would have been RootObject::result, instead of
+// NestedObject::result.
+void tst_v4::nestedObjectAccess()
+{
+ QQmlComponent component(&engine, testFileUrl("nestedObjectAccess.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 37);
+
+ delete o;
+}
+
+void tst_v4::subscriptionsInConditionalExpressions()
+{
+ QQmlComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QObject *ro = qobject_cast<QObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->property("result").toReal(), qreal(2));
+
+ delete o;
+}
+
+// Crash test
+void tst_v4::qtbug_21883()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_21883.qml"));
+
+ QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+}
+
+void tst_v4::qtbug_22816()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_22816.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), false);
+ QCOMPARE(o->property("test2").toBool(), false);
+ delete o;
+}
+
+void tst_v4::stringComparison()
+{
+ QQmlComponent component(&engine, testFileUrl("stringComparison.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toBool(), true);
+ QCOMPARE(o->property("test7").toBool(), true);
+ QCOMPARE(o->property("test8").toBool(), true);
+ QCOMPARE(o->property("test9").toBool(), true);
+ QCOMPARE(o->property("test10").toBool(), true);
+ QCOMPARE(o->property("test11").toBool(), true);
+ QCOMPARE(o->property("test12").toBool(), true);
+ QCOMPARE(o->property("test13").toBool(), true);
+ QCOMPARE(o->property("test14").toBool(), true);
+ QCOMPARE(o->property("test15").toBool(), true);
+ QCOMPARE(o->property("test16").toBool(), true);
+ QCOMPARE(o->property("test17").toBool(), true);
+ QCOMPARE(o->property("test18").toBool(), true);
+ QCOMPARE(o->property("test19").toBool(), true);
+ QCOMPARE(o->property("test20").toBool(), true);
+ QCOMPARE(o->property("test21").toBool(), true);
+ QCOMPARE(o->property("test22").toBool(), true);
+ delete o;
+}
+
+void tst_v4::unaryMinus()
+{
+ QQmlComponent component(&engine, testFileUrl("unaryMinus.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toReal(), qreal(-18));
+ QCOMPARE(o->property("test2").toInt(), -18);
+ QCOMPARE(o->property("test3").toReal(), qreal(3.7));
+ QCOMPARE(o->property("test4").toInt(), 4);
+ QCOMPARE(o->property("test5").toReal(), qreal(3.3));
+ QCOMPARE(o->property("test6").toInt(), 3);
+ QCOMPARE(o->property("test7").toReal(), qreal(7));
+ QCOMPARE(o->property("test8").toInt(), 7);
+ QCOMPARE(o->property("test9").toReal(), qreal(-4.4));
+ QCOMPARE(o->property("test10").toInt(), -4);
+
+ delete o;
+}
+
+void tst_v4::unaryPlus()
+{
+ QQmlComponent component(&engine, testFileUrl("unaryPlus.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toReal(), qreal(18));
+ QCOMPARE(o->property("test2").toInt(), 18);
+ QCOMPARE(o->property("test3").toReal(), qreal(-3.7));
+ QCOMPARE(o->property("test4").toInt(), -4);
+ QCOMPARE(o->property("test5").toReal(), qreal(-3.3));
+ QCOMPARE(o->property("test6").toInt(), -3);
+ QCOMPARE(o->property("test7").toReal(), qreal(-7));
+ QCOMPARE(o->property("test8").toInt(), -7);
+ QCOMPARE(o->property("test9").toReal(), qreal(4.4));
+ QCOMPARE(o->property("test10").toInt(), 4);
+
+ delete o;
+}
+
+void tst_v4::colorType()
+{
+ QQmlComponent component(&engine, testFileUrl("colorType.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").value<QColor>(), QColor("red"));
+ QCOMPARE(o->property("test2").value<QColor>(), QColor("red"));
+ QCOMPARE(o->property("test3").value<QColor>(), QColor("red"));
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toBool(), true);
+ QCOMPARE(o->property("test7").toBool(), true);
+ delete o;
+}
+
+QTEST_MAIN(tst_v4)
+
+#include "tst_v4.moc"
diff --git a/tests/auto/qml/v4/v4.pro b/tests/auto/qml/v4/v4.pro
new file mode 100644
index 0000000000..df8e7b1c3c
--- /dev/null
+++ b/tests/auto/qml/v4/v4.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qqmlv4
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_v4.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private network testlib
diff --git a/tests/auto/qmldevtools/compile/tst_compile.cpp b/tests/auto/qmldevtools/compile/tst_compile.cpp
index bcd602b8bc..0955eb4a8e 100644
--- a/tests/auto/qmldevtools/compile/tst_compile.cpp
+++ b/tests/auto/qmldevtools/compile/tst_compile.cpp
@@ -40,11 +40,11 @@
****************************************************************************/
#include <qtest.h>
-#include <private/qdeclarativejsengine_p.h>
-#include <private/qdeclarativejslexer_p.h>
-#include <private/qdeclarativejsparser_p.h>
-#include <private/qdeclarativejsastvisitor_p.h>
-#include <private/qdeclarativejsast_p.h>
+#include <private/qqmljsengine_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsparser_p.h>
+#include <private/qqmljsastvisitor_p.h>
+#include <private/qqmljsast_p.h>
class tst_compile : public QObject
{
diff --git a/tests/auto/qmltest/createbenchmark/item.qml b/tests/auto/qmltest/createbenchmark/item.qml
index ebc50ceb13..af6c2f3f59 100644
--- a/tests/auto/qmltest/createbenchmark/item.qml
+++ b/tests/auto/qmltest/createbenchmark/item.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/auto/qmltest/qmltest.pro b/tests/auto/qmltest/qmltest.pro
index d0bc8a89cd..b1b2ee2228 100644
--- a/tests/auto/qmltest/qmltest.pro
+++ b/tests/auto/qmltest/qmltest.pro
@@ -4,7 +4,7 @@ CONFIG += warn_on qmltestcase
SOURCES += tst_qmltest.cpp
-importFiles.files = borderimage buttonclick createbenchmark events qdeclarativebinding selftests
+importFiles.files = borderimage buttonclick createbenchmark events qqmlbinding selftests
importFiles.path = .
DEPLOYMENT += importFiles
diff --git a/tests/auto/qmltest/qdeclarativebinding/tst_binding.qml b/tests/auto/qmltest/qqmlbinding/tst_binding.qml
index 0948046bcf..0948046bcf 100644
--- a/tests/auto/qmltest/qdeclarativebinding/tst_binding.qml
+++ b/tests/auto/qmltest/qqmlbinding/tst_binding.qml
diff --git a/tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml b/tests/auto/qmltest/qqmlbinding/tst_binding2.qml
index 87a30e2c14..87a30e2c14 100644
--- a/tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml
+++ b/tests/auto/qmltest/qqmlbinding/tst_binding2.qml
diff --git a/tests/auto/qtquick2/examples/examples.pro b/tests/auto/qtquick2/examples/examples.pro
deleted file mode 100644
index 577c145e77..0000000000
--- a/tests/auto/qtquick2/examples/examples.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_examples
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_examples.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-#temporary
-QT += core-private gui-private declarative-private quick-private widgets-private v8-private testlib
diff --git a/tests/auto/qtquick2/examples/tst_examples.cpp b/tests/auto/qtquick2/examples/tst_examples.cpp
deleted file mode 100644
index e80bfec0e2..0000000000
--- a/tests/auto/qtquick2/examples/tst_examples.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-#include <QDir>
-#include <QProcess>
-#include <QDebug>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickView>
-#include <QDeclarativeComponent>
-#include <QDeclarativeEngine>
-#include <QDeclarativeError>
-
-static QtMsgHandler testlibMsgHandler = 0;
-void msgHandlerFilter(QtMsgType type, const char *msg)
-{
- if (type == QtCriticalMsg || type == QtFatalMsg)
- (*testlibMsgHandler)(type, msg);
-}
-
-class tst_examples : public QObject
-{
- Q_OBJECT
-public:
- tst_examples();
-
-private slots:
- void init();
- void cleanup();
-
- void sgexamples_data();
- void sgexamples();
- void sgsnippets_data();
- void sgsnippets();
-
- void namingConvention();
-private:
- QStringList excludedDirs;
- QStringList excludedFiles;
-
- void namingConvention(const QDir &);
- QStringList findQmlFiles(const QDir &);
-
- QDeclarativeEngine engine;
-};
-
-tst_examples::tst_examples()
-{
- // Add files to exclude here
- excludedFiles << "doc/src/snippets/declarative/listmodel.qml"; //Just a ListModel, no root QQuickItem
-
- // Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/)
- excludedDirs << "shared"; //Not an example
- excludedDirs << "qtquick/text/fonts"; // QTBUG-21415
- excludedDirs << "doc/src/snippets/declarative/path"; //No root QQuickItem
- excludedDirs << "tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir
-
- // These snippets are not expected to run on their own.
- excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/declarative/qtbinding";
- excludedDirs << "doc/src/snippets/declarative/imports";
-
-#ifdef QT_NO_WEBKIT
- excludedDirs << "qtquick/modelviews/webview";
- excludedDirs << "demos/webbrowser";
- excludedDirs << "doc/src/snippets/declarative/webview";
-#endif
-
-#ifdef QT_NO_XMLPATTERNS
- excludedDirs << "demos/twitter";
- excludedDirs << "demos/flickr";
- excludedDirs << "demos/photoviewer";
-#endif
-}
-
-void tst_examples::init()
-{
- if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets"))
- testlibMsgHandler = qInstallMsgHandler(msgHandlerFilter);
-}
-
-void tst_examples::cleanup()
-{
- if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets"))
- qInstallMsgHandler(testlibMsgHandler);
-}
-
-/*
-This tests that the examples follow the naming convention required
-to have them tested by the examples() test.
-*/
-void tst_examples::namingConvention(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return;
- }
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
- QDir::Files);
-
- bool seenQml = !files.isEmpty();
- bool seenLowercase = false;
-
- foreach (const QString &file, files) {
- if (file.at(0).isLower())
- seenLowercase = true;
- }
-
- if (!seenQml) {
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- namingConvention(sub);
- }
- } else if(!seenLowercase) {
- QFAIL(qPrintable(QString(
- "Directory %1 violates naming convention; expected at least one qml file "
- "starting with lower case, got: %2"
- ).arg(d.absolutePath()).arg(files.join(","))));
- }
-}
-
-void tst_examples::namingConvention()
-{
- QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
-
- namingConvention(QDir(examples));
-}
-
-QStringList tst_examples::findQmlFiles(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return QStringList();
- }
-
- QStringList rv;
-
- QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files);
- if (cppfiles.isEmpty()) {
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
- QDir::Files);
- foreach (const QString &file, files) {
- if (file.at(0).isLower()) {
- bool superContinue = false;
- for (int ii = 0; ii < excludedFiles.count(); ++ii) {
- QString e = excludedFiles.at(ii);
- if (d.absoluteFilePath(file).endsWith(e)) {
- superContinue = true;
- break;
- }
- }
- if (superContinue)
- continue;
- rv << d.absoluteFilePath(file);
- }
- }
- }
-
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findQmlFiles(sub);
- }
-
- return rv;
-}
-
-/*
-This test runs all the examples in the declarative UI source tree and ensures
-that they start and exit cleanly.
-
-Examples are any .qml files under the examples/ directory that start
-with a lower case letter.
-*/
-void tst_examples::sgexamples_data()
-{
- QTest::addColumn<QString>("file");
-
- QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
-
- QStringList files;
- files << findQmlFiles(QDir(examples));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_examples::sgexamples()
-{
- QFETCH(QString, file);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(file));
- if (component.status() == QDeclarativeComponent::Error)
- qWarning() << component.errors();
- QCOMPARE(component.status(), QDeclarativeComponent::Ready);
-
- QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
- QQuickItem *root = qobject_cast<QQuickItem *>(object.data());
- if (!root)
- component.completeCreate();
- QVERIFY(root);
-
- QQuickCanvas canvas;
- root->setParentItem(canvas.rootItem());
- component.completeCreate();
- canvas.show();
-
- QTest::qWaitForWindowShown(&canvas);
-
-}
-
-void tst_examples::sgsnippets_data()
-{
- QTest::addColumn<QString>("file");
-
- QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/declarative";
-
- QStringList files;
- files << findQmlFiles(QDir(snippets));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_examples::sgsnippets()
-{
- QFETCH(QString, file);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(file));
- if (component.status() == QDeclarativeComponent::Error)
- qWarning() << component.errors();
- QCOMPARE(component.status(), QDeclarativeComponent::Ready);
-
- QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
- QQuickItem *root = qobject_cast<QQuickItem *>(object.data());
- if (!root)
- component.completeCreate();
- QVERIFY(root);
-
- QQuickCanvas canvas;
- root->setParentItem(canvas.rootItem());
- component.completeCreate();
- canvas.show();
-
- QTest::qWaitForWindowShown(&canvas);
-
-}
-
-QTEST_MAIN(tst_examples)
-
-#include "tst_examples.moc"
diff --git a/tests/auto/qtquick2/geometry/geometry.pro b/tests/auto/qtquick2/geometry/geometry.pro
deleted file mode 100644
index 04d529cfb8..0000000000
--- a/tests/auto/qtquick2/geometry/geometry.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_geometry
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_geometry.cpp
-
-CONFIG+=parallel_test
-
-QT += core-private gui-private declarative-private quick-private opengl testlib
diff --git a/tests/auto/qtquick2/nodes/nodes.pro b/tests/auto/qtquick2/nodes/nodes.pro
deleted file mode 100644
index 40eeb2ab78..0000000000
--- a/tests/auto/qtquick2/nodes/nodes.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_nodestest
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_nodestest.cpp
-
-CONFIG+=parallel_test
-
-QT += core-private gui-private declarative-private quick-private opengl widgets testlib
diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro b/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro
deleted file mode 100644
index 52cafc33a6..0000000000
--- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += core-private gui-private declarative-private
-TEMPLATE=app
-TARGET=tst_qdeclarativeanimationcontroller
-
-CONFIG += warn_on qmltestcase
-SOURCES += tst_qdeclarativeanimationcontroller.cpp
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp b/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp
deleted file mode 100644
index 744f92b99d..0000000000
--- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtQuickTest/quicktest.h>
-QUICK_TEST_MAIN(qdeclarativeanimationcontroller)
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro
deleted file mode 100644
index e13dbb974e..0000000000
--- a/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeanimations
-SOURCES += tst_qdeclarativeanimations.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
-
-# QTBUG-23385 - color mixing tests failing on Ubuntu 11.10 x64
-linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
deleted file mode 100644
index 348586cea8..0000000000
--- a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ /dev/null
@@ -1,1334 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/private/qanimationgroupjob_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qdeclarativeanimation_p.h>
-#include <QtQuick/private/qdeclarativeanimation_p_p.h>
-#include <QtQuick/private/qdeclarativetransition_p.h>
-#include <QtQuick/private/qquickanimation_p.h>
-#include <QtQuick/private/qdeclarativepathinterpolator_p.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include <QEasingCurve>
-
-#include <limits.h>
-#include <math.h>
-
-#include "../../shared/util.h"
-
-class tst_qdeclarativeanimations : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeanimations() {}
-
-private slots:
- void initTestCase()
- {
- QDeclarativeEngine engine; // ensure types are registered
- QDeclarativeDataTest::initTestCase();
- }
-
- void simpleProperty();
- void simpleNumber();
- void simpleColor();
- void simpleRotation();
- void simplePath();
- void simpleAnchor();
- void reparent();
- void pathInterpolator();
- void pathInterpolatorBackwardJump();
- void pathWithNoStart();
- void alwaysRunToEnd();
- void complete();
- void resume();
- void dotProperty();
- void badTypes();
- void badProperties();
- void mixedTypes();
- void properties();
- void propertiesTransition();
- void pathTransition();
- void disabledTransition();
- void invalidDuration();
- void attached();
- void propertyValueSourceDefaultStart();
- void dontStart();
- void easingProperties();
- void rotation();
- void runningTrueBug();
- void nonTransitionBug();
- void registrationBug();
- void doubleRegistrationBug();
- void alwaysRunToEndRestartBug();
- void transitionAssignmentBug();
- void pauseBindingBug();
- void pauseBug();
- void loopingBug();
- void anchorBug();
-};
-
-#define QTIMED_COMPARE(lhs, rhs) do { \
- for (int ii = 0; ii < 5; ++ii) { \
- if (lhs == rhs) \
- break; \
- QTest::qWait(50); \
- } \
- QCOMPARE(lhs, rhs); \
-} while (false)
-
-void tst_qdeclarativeanimations::simpleProperty()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to().toReal() == 200.0);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.x(), 200.0);
-
- rect.setPos(QPointF(0,0));
- animation.start();
- QVERIFY(animation.isRunning());
- animation.pause();
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.x(),100.0);
-}
-
-void tst_qdeclarativeanimations::simpleNumber()
-{
- QQuickRectangle rect;
- QDeclarativeNumberAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to() == 200);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.x(), qreal(200));
-
- rect.setX(0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.x(), qreal(100));
-}
-
-void tst_qdeclarativeanimations::simpleColor()
-{
- QQuickRectangle rect;
- QDeclarativeColorAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("color");
- animation.setTo(QColor("red"));
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "color");
- QVERIFY(animation.to() == QColor("red"));
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.color(), QColor("red"));
-
- rect.setColor(QColor("blue"));
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
-#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
- QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Abort);
-#endif
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
-
- rect.setColor(QColor("green"));
- animation.setFrom(QColor("blue"));
- QVERIFY(animation.from() == QColor("blue"));
- animation.restart();
- QCOMPARE(rect.color(), QColor("blue"));
- QVERIFY(animation.isRunning());
- animation.setCurrentTime(125);
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
-}
-
-void tst_qdeclarativeanimations::simpleRotation()
-{
- QQuickRectangle rect;
- QDeclarativeRotationAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("rotation");
- animation.setTo(270);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "rotation");
- QVERIFY(animation.to() == 270);
- QVERIFY(animation.direction() == QDeclarativeRotationAnimation::Numerical);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.rotation(), qreal(270));
-
- rect.setRotation(0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.rotation(), qreal(135));
-}
-
-void tst_qdeclarativeanimations::simplePath()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathAnimation.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(redRect);
- QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
- QVERIFY(pathAnim);
-
- QCOMPARE(pathAnim->duration(), 100);
- QCOMPARE(pathAnim->target(), redRect);
-
- pathAnim->start();
- pathAnim->pause();
-
- pathAnim->setCurrentTime(30);
- QCOMPARE(redRect->x(), qreal(167));
- QCOMPARE(redRect->y(), qreal(104));
-
- pathAnim->setCurrentTime(100);
- QCOMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
-
- //verify animation runs to end
- pathAnim->start();
- QCOMPARE(redRect->x(), qreal(50));
- QCOMPARE(redRect->y(), qreal(50));
- QTRY_COMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
-
- pathAnim->setOrientation(QQuickPathAnimation::RightFirst);
- QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
- pathAnim->start();
- QTRY_VERIFY(redRect->rotation() != 0);
- pathAnim->stop();
-
- delete rect;
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathAnimation2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(redRect);
- QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
- QVERIFY(pathAnim);
-
- QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
- QCOMPARE(pathAnim->endRotation(), qreal(0));
- QCOMPARE(pathAnim->orientationEntryDuration(), 10);
- QCOMPARE(pathAnim->orientationExitDuration(), 10);
-
- pathAnim->start();
- pathAnim->pause();
- QCOMPARE(redRect->x(), qreal(50));
- QCOMPARE(redRect->y(), qreal(50));
- QCOMPARE(redRect->rotation(), qreal(-360));
-
- pathAnim->setCurrentTime(50);
- QCOMPARE(redRect->x(), qreal(175));
- QCOMPARE(redRect->y(), qreal(175));
- QCOMPARE(redRect->rotation(), qreal(-315));
-
- pathAnim->setCurrentTime(100);
- QCOMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
- QCOMPARE(redRect->rotation(), qreal(0));
-
- delete rect;
- }
-}
-
-void tst_qdeclarativeanimations::simpleAnchor()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("reanchor.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *greenRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(greenRect);
-
- QCOMPARE(rect->state(), QLatin1String("reanchored"));
- QCOMPARE(greenRect->x(), qreal(10));
- QCOMPARE(greenRect->y(), qreal(0));
- QCOMPARE(greenRect->width(), qreal(190));
- QCOMPARE(greenRect->height(), qreal(150));
-
- rect->setState("");
-
- //verify animation in progress
- QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
- QVERIFY(greenRect->y() > 0 && greenRect->y() < 10);
- QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
- QVERIFY(greenRect->height() > 150 && greenRect->height() < 190);
-
- //verify end state ("")
- QTRY_COMPARE(greenRect->x(), qreal(0));
- QCOMPARE(greenRect->y(), qreal(10));
- QCOMPARE(greenRect->width(), qreal(150));
- QCOMPARE(greenRect->height(), qreal(190));
-
- rect->setState("reanchored2");
-
- //verify animation in progress
- QTRY_VERIFY(greenRect->y() > 10 && greenRect->y() < 50);
- QVERIFY(greenRect->height() > 125 && greenRect->height() < 190);
- //NOTE: setting left/right anchors to undefined removes the anchors, but does not resize.
- QCOMPARE(greenRect->x(), qreal(0));
- QCOMPARE(greenRect->width(), qreal(150));
-
- //verify end state ("reanchored2")
- QTRY_COMPARE(greenRect->y(), qreal(50));
- QCOMPARE(greenRect->height(), qreal(125));
- QCOMPARE(greenRect->x(), qreal(0));
- QCOMPARE(greenRect->width(), qreal(150));
-
- rect->setState("reanchored");
-
- //verify animation in progress
- QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
- QVERIFY(greenRect->y() > 0 && greenRect->y() < 50);
- QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
- QVERIFY(greenRect->height() > 125 && greenRect->height() < 150);
-
- //verify end state ("reanchored")
- QTRY_COMPARE(greenRect->x(), qreal(10));
- QCOMPARE(greenRect->y(), qreal(0));
- QCOMPARE(greenRect->width(), qreal(190));
- QCOMPARE(greenRect->height(), qreal(150));
-
- rect->setState("reanchored2");
-
- //verify animation in progress
- QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
- QVERIFY(greenRect->y() > 0 && greenRect->y() < 50);
- QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
- QVERIFY(greenRect->height() > 125 && greenRect->height() < 150);
-
- //verify end state ("reanchored2")
- QTRY_COMPARE(greenRect->x(), qreal(0));
- QCOMPARE(greenRect->y(), qreal(50));
- QCOMPARE(greenRect->width(), qreal(150));
- QCOMPARE(greenRect->height(), qreal(125));
-
- delete rect;
-}
-
-void tst_qdeclarativeanimations::reparent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("reparent.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *target = rect->findChild<QQuickRectangle*>("target");
- QVERIFY(target);
-
- QCOMPARE(target->parentItem(), rect);
- QCOMPARE(target->x(), qreal(0));
- QCOMPARE(target->y(), qreal(0));
- QCOMPARE(target->width(), qreal(50));
- QCOMPARE(target->height(), qreal(50));
- QCOMPARE(target->rotation(), qreal(0));
- QCOMPARE(target->scale(), qreal(1));
-
- rect->setState("state1");
-
- QQuickRectangle *viaParent = rect->findChild<QQuickRectangle*>("viaParent");
- QVERIFY(viaParent);
-
- QQuickRectangle *newParent = rect->findChild<QQuickRectangle*>("newParent");
- QVERIFY(newParent);
-
- QTest::qWait(100);
-
- //animation in progress
- QTRY_COMPARE(target->parentItem(), viaParent);
- QVERIFY(target->x() > -100 && target->x() < 50);
- QVERIFY(target->y() > -100 && target->y() < 50);
- QVERIFY(target->width() > 50 && target->width() < 100);
- QCOMPARE(target->height(), qreal(50));
- QCOMPARE(target->rotation(), qreal(-45));
- QCOMPARE(target->scale(), qreal(.5));
-
- //end state
- QTRY_COMPARE(target->parentItem(), newParent);
- QCOMPARE(target->x(), qreal(50));
- QCOMPARE(target->y(), qreal(50));
- QCOMPARE(target->width(), qreal(100));
- QCOMPARE(target->height(), qreal(50));
- QCOMPARE(target->rotation(), qreal(0));
- QCOMPARE(target->scale(), qreal(1));
-
- delete rect;
-}
-
-void tst_qdeclarativeanimations::pathInterpolator()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathInterpolator.qml"));
- QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
- QVERIFY(interpolator);
-
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(50));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(0));
-
- interpolator->setProgress(.5);
- QCOMPARE(interpolator->progress(), qreal(.5));
- QCOMPARE(interpolator->x(), qreal(175));
- QCOMPARE(interpolator->y(), qreal(175));
- QCOMPARE(interpolator->angle(), qreal(90));
-
- interpolator->setProgress(1);
- QCOMPARE(interpolator->progress(), qreal(1));
- QCOMPARE(interpolator->x(), qreal(300));
- QCOMPARE(interpolator->y(), qreal(300));
- QCOMPARE(interpolator->angle(), qreal(0));
-}
-
-void tst_qdeclarativeanimations::pathInterpolatorBackwardJump()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack.qml"));
- QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
- QVERIFY(interpolator);
-
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(50));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(90));
-
- interpolator->setProgress(.5);
- QCOMPARE(interpolator->progress(), qreal(.5));
- QCOMPARE(interpolator->x(), qreal(100));
- QCOMPARE(interpolator->y(), qreal(75));
- QCOMPARE(interpolator->angle(), qreal(270));
-
- interpolator->setProgress(1);
- QCOMPARE(interpolator->progress(), qreal(1));
- QCOMPARE(interpolator->x(), qreal(200));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(0));
-
- //make sure we don't get caught in infinite loop here
- interpolator->setProgress(0);
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(50));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(90));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack2.qml"));
- QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
- QVERIFY(interpolator);
-
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(200));
- QCOMPARE(interpolator->y(), qreal(280));
- QCOMPARE(interpolator->angle(), qreal(180));
-
- interpolator->setProgress(1);
- QCOMPARE(interpolator->progress(), qreal(1));
- QCOMPARE(interpolator->x(), qreal(0));
- QCOMPARE(interpolator->y(), qreal(80));
- QCOMPARE(interpolator->angle(), qreal(180));
-
- //make sure we don't get caught in infinite loop here
- interpolator->setProgress(0);
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(200));
- QCOMPARE(interpolator->y(), qreal(280));
- QCOMPARE(interpolator->angle(), qreal(180));
- }
-}
-
-void tst_qdeclarativeanimations::pathWithNoStart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathAnimationNoStart.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(redRect);
- QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
- QVERIFY(pathAnim);
-
- pathAnim->start();
- pathAnim->pause();
- QCOMPARE(redRect->x(), qreal(50));
- QCOMPARE(redRect->y(), qreal(50));
-
- pathAnim->setCurrentTime(50);
- QCOMPARE(redRect->x(), qreal(175));
- QCOMPARE(redRect->y(), qreal(175));
-
- pathAnim->setCurrentTime(100);
- QCOMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
-
- redRect->setX(100);
- redRect->setY(100);
- pathAnim->start();
- QCOMPARE(redRect->x(), qreal(100));
- QCOMPARE(redRect->y(), qreal(100));
- QTRY_COMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
-}
-
-void tst_qdeclarativeanimations::alwaysRunToEnd()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(1000);
- animation.setLoops(-1);
- animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.loops() == -1);
- QVERIFY(animation.alwaysRunToEnd() == true);
- animation.start();
- QTest::qWait(1500);
- animation.stop();
- QVERIFY(rect.x() != qreal(200));
- QTest::qWait(500);
- QTIMED_COMPARE(rect.x(), qreal(200));
-}
-
-void tst_qdeclarativeanimations::complete()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setFrom(1);
- animation.setTo(200);
- animation.setDuration(500);
- QVERIFY(animation.from() == 1);
- animation.start();
- QTest::qWait(50);
- animation.stop();
- QVERIFY(rect.x() != qreal(200));
- animation.start();
- QTest::qWait(50);
- QVERIFY(animation.isRunning());
- animation.complete();
- QCOMPARE(rect.x(), qreal(200));
-}
-
-void tst_qdeclarativeanimations::resume()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setFrom(10);
- animation.setTo(200);
- animation.setDuration(1000);
- QVERIFY(animation.from() == 10);
-
- animation.start();
- QTest::qWait(400);
- animation.pause();
- qreal x = rect.x();
- QVERIFY(x != qreal(200) && x != qreal(10));
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
-
- animation.resume();
- QVERIFY(animation.isRunning());
- QVERIFY(!animation.isPaused());
- QTest::qWait(400);
- animation.stop();
- QVERIFY(rect.x() > x);
-}
-
-void tst_qdeclarativeanimations::dotProperty()
-{
- QQuickRectangle rect;
- QDeclarativeNumberAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("border.width");
- animation.setTo(10);
- animation.start();
- QTest::qWait(animation.duration()+50);
- QTIMED_COMPARE(rect.border()->width(), 10.0);
-
- rect.border()->setWidth(0);
- animation.start();
- animation.pause();
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.border()->width(), 5.0);
-}
-
-void tst_qdeclarativeanimations::badTypes()
-{
- //don't crash
- {
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("badtype1.qml"));
-
- qApp->processEvents();
-
- delete view;
- }
-
- //make sure we get a compiler error
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("badtype2.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
- }
-
- //make sure we get a compiler error
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("badtype3.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
- }
-
- //don't crash
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("badtype4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QTest::qWait(1000 + 50);
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
- QVERIFY(myRect);
- QCOMPARE(myRect->x(),qreal(200));
- }
-}
-
-void tst_qdeclarativeanimations::badProperties()
-{
- //make sure we get a runtime error
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c1(&engine, testFileUrl("badproperty1.qml"));
- QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c1.create());
- QVERIFY(rect);
-
- QDeclarativeComponent c2(&engine, testFileUrl("badproperty2.qml"));
- message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- rect = qobject_cast<QQuickRectangle*>(c2.create());
- QVERIFY(rect);
-
- //### should we warn here are well?
- //rect->setState("state1");
- }
-}
-
-//test animating mixed types with property animation in a transition
-//for example, int + real; color + real; etc
-void tst_qdeclarativeanimations::mixedTypes()
-{
- //assumes border.width stays a real -- not real robust
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("mixedtype1.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QTest::qWait(500);
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
- QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10);
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("mixedtype2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QTest::qWait(500);
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
-#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
- QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Continue);
-#endif
- QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
- }
-}
-
-void tst_qdeclarativeanimations::properties()
-{
- const int waitDuration = 300;
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(300));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties5.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-}
-
-void tst_qdeclarativeanimations::propertiesTransition()
-{
- const int waitDuration = 300;
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition5.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- /*{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition6.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }*/
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition7.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
-}
-
-void tst_qdeclarativeanimations::pathTransition()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathTransition.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("redRect");
- QVERIFY(myRect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started
- QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(100)) && qFuzzyCompare(myRect->y(), qreal(700)));
- QTest::qWait(100);
-
- QQuickItemPrivate::get(rect)->setState("");
- QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started
- QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(500)) && qFuzzyCompare(myRect->y(), qreal(50)));
-}
-
-void tst_qdeclarativeanimations::disabledTransition()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("disabledTransition.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
-
- QDeclarativeTransition *trans = rect->findChild<QDeclarativeTransition*>();
- QVERIFY(trans);
-
- QCOMPARE(trans->enabled(), false);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
-
- trans->setEnabled(true);
-
- QQuickItemPrivate::get(rect)->setState("");
- QCOMPARE(myRect->x(),qreal(200));
- QTest::qWait(300);
- QTIMED_COMPARE(myRect->x(),qreal(100));
-}
-
-void tst_qdeclarativeanimations::invalidDuration()
-{
- QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PropertyAnimation: Cannot set a duration of < 0");
- animation->setDuration(-1);
- QCOMPARE(animation->duration(), 250);
-
- QDeclarativePauseAnimation *pauseAnimation = new QDeclarativePauseAnimation;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PauseAnimation: Cannot set a duration of < 0");
- pauseAnimation->setDuration(-1);
- QCOMPARE(pauseAnimation->duration(), 250);
-}
-
-void tst_qdeclarativeanimations::attached()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("attached.qml"));
- QTest::ignoreMessage(QtDebugMsg, "off");
- QTest::ignoreMessage(QtDebugMsg, "on");
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-}
-
-void tst_qdeclarativeanimations::propertyValueSourceDefaultStart()
-{
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("valuesource.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning());
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("valuesource2.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning() == false);
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("dontAutoStart.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
- }
-}
-
-
-void tst_qdeclarativeanimations::dontStart()
-{
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml"));
-
- QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("dontStart2.qml"));
-
- QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
- }
-}
-
-void tst_qdeclarativeanimations::easingProperties()
-{
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nNumberAnimation { easing.type: \"InOutQuad\" }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce);
- QCOMPARE(animObject->easing().amplitude(), 5.0);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic);
- QCOMPARE(animObject->easing().amplitude(), 5.0);
- QCOMPARE(animObject->easing().period(), 3.0);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack);
- QCOMPARE(animObject->easing().overshoot(), 2.0);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"Bezier\"; easing.bezierCurve: [0.5, 0.2, 0.13, 0.65, 1.0, 1.0] }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline);
- QList<QPointF> points = animObject->easing().cubicBezierSpline();
- QCOMPARE(points.count(), 3);
- QCOMPARE(points.at(0), QPointF(0.5, 0.2));
- QCOMPARE(points.at(1), QPointF(0.13, 0.65));
- QCOMPARE(points.at(2), QPointF(1.0, 1.0));
- }
-}
-
-void tst_qdeclarativeanimations::rotation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("rotation.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *rr = rect->findChild<QQuickRectangle*>("rr");
- QQuickRectangle *rr2 = rect->findChild<QQuickRectangle*>("rr2");
- QQuickRectangle *rr3 = rect->findChild<QQuickRectangle*>("rr3");
- QQuickRectangle *rr4 = rect->findChild<QQuickRectangle*>("rr4");
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QTest::qWait(800);
- qreal r1 = rr->rotation();
- qreal r2 = rr2->rotation();
- qreal r3 = rr3->rotation();
- qreal r4 = rr4->rotation();
-
- QVERIFY(r1 > qreal(0) && r1 < qreal(370));
- QVERIFY(r2 > qreal(0) && r2 < qreal(370));
- QVERIFY(r3 < qreal(0) && r3 > qreal(-350));
- QVERIFY(r4 > qreal(0) && r4 < qreal(10));
- QCOMPARE(r1,r2);
- QVERIFY(r4 < r2);
-
- QTest::qWait(800);
- QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
-}
-
-void tst_qdeclarativeanimations::runningTrueBug()
-{
- //ensure we start correctly when "running: true" is explicitly set
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("runningTrueBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *cloud = rect->findChild<QQuickRectangle*>("cloud");
- QVERIFY(cloud);
- QTest::qWait(1000);
- QVERIFY(cloud->x() > qreal(0));
-}
-
-//QTBUG-12805
-void tst_qdeclarativeanimations::nonTransitionBug()
-{
- //tests that the animation values from the previous transition are properly cleared
- //in the case where an animation in the transition doesn't match anything (but previously did)
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("nonTransitionBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("mover");
-
- mover->setX(100);
- QCOMPARE(mover->x(), qreal(100));
-
- rectPrivate->setState("left");
- QTRY_COMPARE(mover->x(), qreal(0));
-
- mover->setX(100);
- QCOMPARE(mover->x(), qreal(100));
-
- //make sure we don't try to animate back to 0
- rectPrivate->setState("free");
- QTest::qWait(300);
- QCOMPARE(mover->x(), qreal(100));
-}
-
-//QTBUG-14042
-void tst_qdeclarativeanimations::registrationBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("registrationBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QTRY_COMPARE(rect->property("value"), QVariant(int(100)));
-}
-
-void tst_qdeclarativeanimations::doubleRegistrationBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("doubleRegistrationBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation");
- QVERIFY(anim != 0);
- QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
-}
-
-//QTBUG-16736
-void tst_qdeclarativeanimations::alwaysRunToEndRestartBug()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(1000);
- animation.setLoops(-1);
- animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.loops() == -1);
- QVERIFY(animation.alwaysRunToEnd() == true);
- animation.start();
- animation.stop();
- animation.start();
- animation.stop();
- QTest::qWait(500);
- QVERIFY(rect.x() != qreal(200));
- QTest::qWait(800);
- QTIMED_COMPARE(rect.x(), qreal(200));
- QCOMPARE(static_cast<QDeclarativeAbstractAnimation*>(&animation)->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
-}
-
-//QTBUG-20227
-void tst_qdeclarativeanimations::transitionAssignmentBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("transitionAssignmentBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->property("nullObject").toBool(), false);
-}
-
-//QTBUG-19080
-void tst_qdeclarativeanimations::pauseBindingBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("pauseBindingBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation");
- QVERIFY(anim->qtAnimation()->state() == QAbstractAnimationJob::Paused);
-
- delete rect;
-}
-
-//QTBUG-13598
-void tst_qdeclarativeanimations::pauseBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("pauseBug.qml"));
- QDeclarativeAbstractAnimation *anim = qobject_cast<QDeclarativeAbstractAnimation*>(c.create());
- QVERIFY(anim != 0);
- QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Paused);
- QCOMPARE(anim->isPaused(), true);
- QCOMPARE(anim->isRunning(), true);
-
- delete anim;
-}
-
-//QTBUG-23092
-void tst_qdeclarativeanimations::loopingBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("looping.qml"));
- QObject *obj = c.create();
-
- QDeclarativeAbstractAnimation *anim = obj->findChild<QDeclarativeAbstractAnimation*>();
- QVERIFY(anim != 0);
- QCOMPARE(anim->qtAnimation()->totalDuration(), 300);
- QCOMPARE(anim->isRunning(), true);
- QTRY_COMPARE(static_cast<QAnimationGroupJob*>(anim->qtAnimation())->firstChild()->currentLoop(), 2);
- QTRY_COMPARE(anim->isRunning(), false);
-
- QQuickRectangle *rect = obj->findChild<QQuickRectangle*>();
- QVERIFY(rect != 0);
- QCOMPARE(rect->rotation(), qreal(90));
-
- delete obj;
-}
-
-//QTBUG-24532
-void tst_qdeclarativeanimations::anchorBug()
-{
- QQuickAnchorAnimation animation;
- animation.setDuration(5000);
- animation.setEasing(QEasingCurve(QEasingCurve::InOutBack));
- animation.start();
- animation.pause();
-
- QCOMPARE(animation.qtAnimation()->duration(), 5000);
- QCOMPARE(static_cast<QDeclarativeBulkValueAnimator*>(animation.qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutBack));
-}
-
-QTEST_MAIN(tst_qdeclarativeanimations)
-
-#include "tst_qdeclarativeanimations.moc"
diff --git a/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro b/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro
deleted file mode 100644
index b86f431d31..0000000000
--- a/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeapplication
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeapplication.cpp
-QT += core-private gui-private declarative-private quick-private testlib
-
diff --git a/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp b/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp
deleted file mode 100644
index 6b921a7356..0000000000
--- a/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtGui/qinputmethod.h>
-
-class tst_qdeclarativeapplication : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeapplication();
-
-private slots:
- void active();
- void layoutDirection();
- void inputPanel();
- void inputMethod();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeapplication::tst_qdeclarativeapplication()
-{
-}
-
-void tst_qdeclarativeapplication::active()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
- QVERIFY(item);
- QQuickView view;
- item->setParentItem(view.rootObject());
-
- // not active
- QVERIFY(!item->property("active").toBool());
- QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
-
- // active
- view.show();
- view.requestActivateWindow();
- QTest::qWait(50);
- QEXPECT_FAIL("", "QTBUG-21573", Abort);
- QTRY_COMPARE(view.status(), QQuickView::Ready);
- QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
-
-#if 0
- // QGuiApplication has no equivalent of setActiveWindow(0). QTBUG-21573
- // Is this different to clearing the active state of the window or can it be removed?
- // On Mac, setActiveWindow(0) on mac does not deactivate the current application,
- // must switch to a different app or hide the current app to trigger this
- // on mac, setActiveWindow(0) on mac does not deactivate the current application
- // (you have to switch to a different app or hide the current app to trigger this)
-
- // not active again
- QGuiApplication::setActiveWindow(0);
- QVERIFY(!item->property("active").toBool());
- QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
-#endif
-
-}
-
-void tst_qdeclarativeapplication::layoutDirection()
-{
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
- QVERIFY(item);
- QQuickView view;
- item->setParentItem(view.rootObject());
-
- // not mirrored
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
-
- // mirrored
- QGuiApplication::setLayoutDirection(Qt::RightToLeft);
- QEXPECT_FAIL("", "QTBUG-21573", Abort);
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft);
-
- // not mirrored again
- QGuiApplication::setLayoutDirection(Qt::LeftToRight);
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
-}
-
-void tst_qdeclarativeapplication::inputPanel()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { property variant inputPanel: Qt.application.inputPanel }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
- QVERIFY(item);
- QQuickView view;
- item->setParentItem(view.rootObject());
-
- // check that the inputPanel property maches with application's input panel
- QCOMPARE(qvariant_cast<QObject*>(item->property("inputPanel")), qApp->inputMethod());
-}
-
-void tst_qdeclarativeapplication::inputMethod()
-{
- // technically not in QDeclarativeApplication, but testing anyway here
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { property variant inputMethod: Qt.inputMethod }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
- QVERIFY(item);
- QQuickView view;
- item->setParentItem(view.rootObject());
-
- // check that the inputMethod property maches with application's input method
- QCOMPARE(qvariant_cast<QObject*>(item->property("inputMethod")), qApp->inputMethod());
-}
-
-
-QTEST_MAIN(tst_qdeclarativeapplication)
-
-#include "tst_qdeclarativeapplication.moc"
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro
deleted file mode 100644
index 7089f1ce57..0000000000
--- a/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativebehaviors
-SOURCES += tst_qdeclarativebehaviors.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
deleted file mode 100644
index c1e60f1560..0000000000
--- a/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ /dev/null
@@ -1,473 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <qsignalspy.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qdeclarativebehavior_p.h>
-#include <QtQuick/private/qdeclarativeanimation_p.h>
-#include <private/qquickitem_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativebehaviors : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativebehaviors() {}
-
-private slots:
- void init() { qApp->processEvents(); } //work around animation timer bug (QTBUG-22865)
- void simpleBehavior();
- void scriptTriggered();
- void cppTriggered();
- void loop();
- void colorBehavior();
- void parentBehavior();
- void replaceBinding();
- //void transitionOverrides();
- void group();
- void valueType();
- void emptyBehavior();
- void explicitSelection();
- void nonSelectingBehavior();
- void reassignedAnimation();
- void disabled();
- void dontStart();
- void startup();
- void groupedPropertyCrash();
- void runningTrue();
- void sameValue();
- void delayedRegistration();
- void startOnCompleted();
-};
-
-void tst_qdeclarativebehaviors::simpleBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("simple.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
- QTRY_VERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation());
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::scriptTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("scripttrigger.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- rect->setColor(QColor("red"));
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::cppTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("cpptrigger.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QTRY_VERIFY(innerRect);
-
- innerRect->setProperty("x", 200);
- QTRY_VERIFY(innerRect->x() > 0);
- QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::loop()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("loop.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- //don't crash
- QQuickItemPrivate::get(rect)->setState("moved");
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::colorBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("color.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("red");
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("red"));
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("green"));
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::parentBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("parent.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("reparented");
- QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() != rect->findChild<QQuickItem*>("NewParent"));
- QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() == rect->findChild<QQuickItem*>("NewParent"));
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::replaceBinding()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("binding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QTRY_VERIFY(innerRect);
- QTRY_VERIFY(innerRect->x() > 0);
- QTRY_VERIFY(innerRect->x() < 200);
- //i.e. the behavior has been triggered
- QTRY_COMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("basex", 10);
- QTRY_COMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("movedx", 210);
- QTRY_COMPARE(innerRect->x(), (qreal)210);
-
- QQuickItemPrivate::get(rect)->setState("");
- QTRY_VERIFY(innerRect->x() > 10);
- QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered
- QTRY_COMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("movedx", 200);
- QTRY_COMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("basex", 20);
- QTRY_COMPARE(innerRect->x(), (qreal)20);
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::group()
-{
- /* XXX TODO Create a test element for this case.
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("groupProperty.qml")));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- qDebug() << c.errorString();
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- //QTest::qWait(200);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
- }
- */
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("groupProperty2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() < 4);
- //i.e. the behavior has been triggered
-
- delete rect;
- }
-}
-
-void tst_qdeclarativebehaviors::valueType()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("valueType.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- //QTBUG-20827
- QCOMPARE(rect->color(), QColor::fromRgb(255,0,255));
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::emptyBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("empty.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::explicitSelection()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("explicit.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::nonSelectingBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("nonSelecting2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::reassignedAnimation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("reassignedAnimation.qml"));
- QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
- rect->findChild<QDeclarativeBehavior*>("MyBehavior")->animation())->duration(), 200);
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("disabled.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::dontStart()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml"));
-
- QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::startup()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("startup.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
- QVERIFY(innerRect);
-
- QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
-
- delete rect;
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("startup2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
- QVERIFY(innerRect);
-
- QQuickText *text = rect->findChild<QQuickText*>();
- QVERIFY(text);
-
- QCOMPARE(innerRect->x(), text->width()); //should be set immediately
-
- delete rect;
- }
-}
-
-//QTBUG-10799
-void tst_qdeclarativebehaviors::groupedPropertyCrash()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("groupedPropertyCrash.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect); //don't crash
-
- delete rect;
-}
-
-//QTBUG-5491
-void tst_qdeclarativebehaviors::runningTrue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("runningTrue.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *animation = rect->findChild<QDeclarativeAbstractAnimation*>("rotAnim");
- QVERIFY(animation);
-
- QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool)));
- rect->setProperty("myValue", 180);
- QTRY_VERIFY(runningSpy.count() > 0);
-
- delete rect;
-}
-
-//QTBUG-12295
-void tst_qdeclarativebehaviors::sameValue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("qtbug12295.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *target = rect->findChild<QQuickRectangle*>("myRect");
- QVERIFY(target);
-
- target->setX(100);
- QCOMPARE(target->x(), qreal(100));
-
- 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));
-
- //this is the main point of the test -- the behavior needs to be triggered again
- //even though we set 0 twice in a row.
- target->setProperty("x", 0);
- QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
-
- delete rect;
-}
-
-//QTBUG-18362
-void tst_qdeclarativebehaviors::delayedRegistration()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("delayedRegistration.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItem *innerRect = rect->property("myItem").value<QQuickItem*>();
- QVERIFY(innerRect != 0);
-
- QCOMPARE(innerRect->property("x").toInt(), int(0));
-
- QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
-}
-
-//QTBUG-22555
-void tst_qdeclarativebehaviors::startOnCompleted()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("startOnCompleted.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItem *innerRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(innerRect != 0);
-
- QCOMPARE(innerRect->property("x").toInt(), int(0));
-
- QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qdeclarativebehaviors)
-
-#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro
deleted file mode 100644
index 0e84fc9dce..0000000000
--- a/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativefontloader
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativefontloader.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
deleted file mode 100644
index e3571a411c..0000000000
--- a/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick/private/qdeclarativefontloader_p.h>
-#include "../../shared/util.h"
-#include "../../shared/testhttpserver.h"
-#include <QtQuick/QQuickView>
-#include <QtQuick/QQuickItem>
-
-#define SERVER_PORT 14448
-
-class tst_qdeclarativefontloader : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativefontloader();
-
-private slots:
- void initTestCase();
- void noFont();
- void namedFont();
- void localFont();
- void failLocalFont();
- void webFont();
- void redirWebFont();
- void failWebFont();
- void changeFont();
- void changeFontSourceViaState();
-
-private:
- QDeclarativeEngine engine;
- TestHTTPServer server;
-};
-
-tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
- server(SERVER_PORT)
-{
-}
-
-void tst_qdeclarativefontloader::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- server.serveDirectory(dataDirectory());
- QVERIFY(server.isValid());
-}
-
-void tst_qdeclarativefontloader::noFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->name(), QString(""));
- QCOMPARE(fontObject->source(), QUrl(""));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Null);
-
- delete fontObject;
-}
-
-void tst_qdeclarativefontloader::namedFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->source(), QUrl(""));
- QCOMPARE(fontObject->name(), QString("Helvetica"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::localFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::failLocalFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }";
- QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData());
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
-}
-
-void tst_qdeclarativefontloader::webFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }";
- QDeclarativeComponent component(&engine);
-
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::redirWebFont()
-{
- server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
-
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }";
- QDeclarativeComponent component(&engine);
-
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::failWebFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }";
- QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\"");
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
-}
-
-void tst_qdeclarativefontloader::changeFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
-
- QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged()));
- QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
-
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
- QCOMPARE(nameSpy.count(), 0);
- QCOMPARE(statusSpy.count(), 0);
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
-
- ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Loading);
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
- QCOMPARE(nameSpy.count(), 1);
- QCOMPARE(statusSpy.count(), 2);
- QTRY_COMPARE(fontObject->name(), QString("Daniel"));
-
- ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
- QCOMPARE(nameSpy.count(), 2);
- QCOMPARE(statusSpy.count(), 2);
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
-
- ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
- QCOMPARE(nameSpy.count(), 3);
- QCOMPARE(statusSpy.count(), 2);
- QTRY_COMPARE(fontObject->name(), QString("Daniel"));
-}
-
-void tst_qdeclarativefontloader::changeFontSourceViaState()
-{
- QQuickView canvas(testFileUrl("qtbug-20268.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(qvariant_cast<QObject *>(canvas.rootObject()->property("fontloader")));
- QVERIFY(fontObject != 0);
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
-
- canvas.rootObject()->setProperty("usename", true);
-
- // This warning should probably not be printed once QTBUG-20268 is fixed
- QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) +
- QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\"");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QEXPECT_FAIL("", "QTBUG-20268", Abort);
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
- QCOMPARE(canvas.rootObject()->property("name").toString(), QString("Tahoma"));
-}
-
-QTEST_MAIN(tst_qdeclarativefontloader)
-
-#include "tst_qdeclarativefontloader.moc"
diff --git a/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro b/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro
deleted file mode 100644
index 1936d53050..0000000000
--- a/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepath
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepath.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp b/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp
deleted file mode 100644
index cdf2566531..0000000000
--- a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qdeclarativepath_p.h>
-
-#include "../../shared/util.h"
-
-class tst_QDeclarativePath : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QDeclarativePath() {}
-
-private slots:
- void arc();
- void catmullromCurve();
- void closedCatmullromCurve();
- void svg();
-};
-
-void tst_QDeclarativePath::arc()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("arc.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->startX(), 0.);
- QCOMPARE(obj->startY(), 0.);
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 1);
-
- QDeclarativePathArc* arc = qobject_cast<QDeclarativePathArc*>(list.at(0));
- QVERIFY(arc != 0);
- QCOMPARE(arc->x(), 100.);
- QCOMPARE(arc->y(), 100.);
- QCOMPARE(arc->radiusX(), 100.);
- QCOMPARE(arc->radiusY(), 100.);
- QCOMPARE(arc->useLargeArc(), false);
- QCOMPARE(arc->direction(), QDeclarativePathArc::Clockwise);
-
- QPainterPath path = obj->path();
- QVERIFY(path != QPainterPath());
-
- QPointF pos = obj->pointAt(0);
- QCOMPARE(pos, QPointF(0,0));
- pos = obj->pointAt(.25);
- QCOMPARE(pos.toPoint(), QPoint(39,8)); //fuzzy compare
- pos = obj->pointAt(.75);
- QCOMPARE(pos.toPoint(), QPoint(92,61)); //fuzzy compare
- pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(100,100));
-}
-
-void tst_QDeclarativePath::catmullromCurve()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("curve.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->startX(), 0.);
- QCOMPARE(obj->startY(), 0.);
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 3);
-
- QDeclarativePathCatmullRomCurve* curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(0));
- QVERIFY(curve != 0);
- QCOMPARE(curve->x(), 100.);
- QCOMPARE(curve->y(), 50.);
-
- curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(2));
- QVERIFY(curve != 0);
- QCOMPARE(curve->x(), 100.);
- QCOMPARE(curve->y(), 150.);
-
- QPainterPath path = obj->path();
- QVERIFY(path != QPainterPath());
-
- QPointF pos = obj->pointAt(0);
- QCOMPARE(pos, QPointF(0,0));
- pos = obj->pointAt(.25);
- QCOMPARE(pos.toPoint(), QPoint(63,26)); //fuzzy compare
- pos = obj->pointAt(.75);
- QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare
- pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(100,150));
-}
-
-void tst_QDeclarativePath::closedCatmullromCurve()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("closedcurve.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->startX(), 50.);
- QCOMPARE(obj->startY(), 50.);
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 3);
-
- QDeclarativePathCatmullRomCurve* curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(2));
- QVERIFY(curve != 0);
- QCOMPARE(curve->x(), 50.);
- QCOMPARE(curve->y(), 50.);
-
- QVERIFY(obj->isClosed());
-
- QPainterPath path = obj->path();
- QVERIFY(path != QPainterPath());
-
- QPointF pos = obj->pointAt(0);
- QCOMPARE(pos, QPointF(50,50));
- pos = obj->pointAt(.1);
- QCOMPARE(pos.toPoint(), QPoint(67,56)); //fuzzy compare
- pos = obj->pointAt(.75);
- QCOMPARE(pos.toPoint(), QPoint(44,116)); //fuzzy compare
- pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(50,50));
-}
-
-void tst_QDeclarativePath::svg()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("svg.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->startX(), 0.);
- QCOMPARE(obj->startY(), 0.);
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 1);
-
- QDeclarativePathSvg* svg = qobject_cast<QDeclarativePathSvg*>(list.at(0));
- QVERIFY(svg != 0);
- QCOMPARE(svg->path(), QLatin1String("M200,300 Q400,50 600,300 T1000,300"));
-
- QPainterPath path = obj->path();
- QVERIFY(path != QPainterPath());
-
- QPointF pos = obj->pointAt(0);
- QCOMPARE(pos, QPointF(200,300));
- pos = obj->pointAt(.25);
- QCOMPARE(pos.toPoint(), QPoint(400,175)); //fuzzy compare
- pos = obj->pointAt(.75);
- QCOMPARE(pos.toPoint(), QPoint(800,425)); //fuzzy compare
- pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(1000,300));
-}
-
-
-QTEST_MAIN(tst_QDeclarativePath)
-
-#include "tst_qdeclarativepath.moc"
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
deleted file mode 100644
index 006489cce7..0000000000
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepixmapcache
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepixmapcache.cpp \
- ../../shared/testhttpserver.cpp
-HEADERS += ../../shared/testhttpserver.h
-INCLUDEPATH += ../../shared/
-
-include (../../shared/util.pri)
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib concurrent
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
deleted file mode 100644
index 84ea9ec3a9..0000000000
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
+++ /dev/null
@@ -1,467 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeimageprovider.h>
-#include <QNetworkReply>
-#include "../../shared/util.h"
-#include "testhttpserver.h"
-
-#ifndef QT_NO_CONCURRENT
-#include <qtconcurrentrun.h>
-#include <qfuture.h>
-#endif
-
-#define PIXMAP_DATA_LEAK_TEST 0
-
-class tst_qdeclarativepixmapcache : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativepixmapcache() : server(14452) {}
-
-private slots:
- void initTestCase();
- void single();
- void single_data();
- void parallel();
- void parallel_data();
- void massive();
- void cancelcrash();
- void shrinkcache();
-#ifndef QT_NO_CONCURRENT
- void networkCrash();
-#endif
- void lockingCrash();
-#if PIXMAP_DATA_LEAK_TEST
- void dataLeak();
-#endif
-private:
- QDeclarativeEngine engine;
- TestHTTPServer server;
-};
-
-static int slotters=0;
-
-class Slotter : public QObject
-{
- Q_OBJECT
-public:
- Slotter()
- {
- gotslot = false;
- slotters++;
- }
- bool gotslot;
-
-public slots:
- void got()
- {
- gotslot = true;
- --slotters;
- if (slotters==0)
- QTestEventLoop::instance().exitLoop();
- }
-};
-
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
-static const bool localfile_optimized = true;
-#else
-static const bool localfile_optimized = false;
-#endif
-
-
-void tst_qdeclarativepixmapcache::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- server.serveDirectory(testFile("http"));
-}
-
-void tst_qdeclarativepixmapcache::single_data()
-{
- // Note, since QDeclarativePixmapCache is shared, tests affect each other!
- // so use different files fore all test functions.
-
- QTest::addColumn<QUrl>("target");
- QTest::addColumn<bool>("incache");
- QTest::addColumn<bool>("exists");
- QTest::addColumn<bool>("neterror");
-
- // File URLs are optimized
- QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false;
- QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false;
- QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false;
- QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true;
-}
-
-void tst_qdeclarativepixmapcache::single()
-{
- QFETCH(QUrl, target);
- QFETCH(bool, incache);
- QFETCH(bool, exists);
- QFETCH(bool, neterror);
-
- QString expectedError;
- if (neterror) {
- expectedError = "Error downloading " + target.toString() + " - server replied: Not found";
- } else if (!exists) {
- expectedError = "Cannot open: " + target.toString();
- }
-
- QDeclarativePixmap pixmap;
- QVERIFY(pixmap.width() <= 0); // Check Qt assumption
-
- pixmap.load(&engine, target);
-
- if (incache) {
- QCOMPARE(pixmap.error(), expectedError);
- if (exists) {
- QVERIFY(pixmap.status() == QDeclarativePixmap::Ready);
- QVERIFY(pixmap.width() > 0);
- } else {
- QVERIFY(pixmap.status() == QDeclarativePixmap::Error);
- QVERIFY(pixmap.width() <= 0);
- }
- } else {
- QVERIFY(pixmap.width() <= 0);
-
- Slotter getter;
- pixmap.connectFinished(&getter, SLOT(got()));
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(getter.gotslot);
- if (exists) {
- QVERIFY(pixmap.status() == QDeclarativePixmap::Ready);
- QVERIFY(pixmap.width() > 0);
- } else {
- QVERIFY(pixmap.status() == QDeclarativePixmap::Error);
- QVERIFY(pixmap.width() <= 0);
- }
- QCOMPARE(pixmap.error(), expectedError);
- }
-}
-
-void tst_qdeclarativepixmapcache::parallel_data()
-{
- // Note, since QDeclarativePixmapCache is shared, tests affect each other!
- // so use different files fore all test functions.
-
- QTest::addColumn<QUrl>("target1");
- QTest::addColumn<QUrl>("target2");
- QTest::addColumn<int>("incache");
- QTest::addColumn<int>("cancel"); // which one to cancel
-
- QTest::newRow("local")
- << testFileUrl("exists1.png")
- << testFileUrl("exists2.png")
- << (localfile_optimized ? 2 : 0)
- << -1;
-
- QTest::newRow("remote")
- << QUrl("http://127.0.0.1:14452/exists2.png")
- << QUrl("http://127.0.0.1:14452/exists3.png")
- << 0
- << -1;
-
- QTest::newRow("remoteagain")
- << QUrl("http://127.0.0.1:14452/exists2.png")
- << QUrl("http://127.0.0.1:14452/exists3.png")
- << 2
- << -1;
-
- QTest::newRow("remotecopy")
- << QUrl("http://127.0.0.1:14452/exists4.png")
- << QUrl("http://127.0.0.1:14452/exists4.png")
- << 0
- << -1;
-
- QTest::newRow("remotecopycancel")
- << QUrl("http://127.0.0.1:14452/exists5.png")
- << QUrl("http://127.0.0.1:14452/exists5.png")
- << 0
- << 0;
-}
-
-void tst_qdeclarativepixmapcache::parallel()
-{
- QFETCH(QUrl, target1);
- QFETCH(QUrl, target2);
- QFETCH(int, incache);
- QFETCH(int, cancel);
-
- QList<QUrl> targets;
- targets << target1 << target2;
-
- QList<QDeclarativePixmap *> pixmaps;
- QList<bool> pending;
- QList<Slotter*> getters;
-
- for (int i=0; i<targets.count(); ++i) {
- QUrl target = targets.at(i);
- QDeclarativePixmap *pixmap = new QDeclarativePixmap;
-
- pixmap->load(&engine, target);
-
- QVERIFY(pixmap->status() != QDeclarativePixmap::Error);
- pixmaps.append(pixmap);
- if (pixmap->isReady()) {
- QVERIFY(pixmap->width() > 0);
- getters.append(0);
- pending.append(false);
- } else {
- QVERIFY(pixmap->width() <= 0);
- getters.append(new Slotter);
- pixmap->connectFinished(getters[i], SLOT(got()));
- pending.append(true);
- }
- }
-
- QCOMPARE(incache+slotters, targets.count());
-
- if (cancel >= 0) {
- pixmaps.at(cancel)->clear(getters[cancel]);
- slotters--;
- }
-
- if (slotters) {
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- }
-
- for (int i=0; i<targets.count(); ++i) {
- QDeclarativePixmap *pixmap = pixmaps[i];
-
- if (i == cancel) {
- QVERIFY(!getters[i]->gotslot);
- } else {
- if (pending[i])
- QVERIFY(getters[i]->gotslot);
-
- QVERIFY(pixmap->isReady());
- QVERIFY(pixmap->width() > 0);
- delete getters[i];
- }
- }
-
- qDeleteAll(pixmaps);
-}
-
-void tst_qdeclarativepixmapcache::massive()
-{
- QDeclarativeEngine engine;
- QUrl url = testFileUrl("massive.png");
-
- // Confirm that massive images remain in the cache while they are
- // in use by the application.
- {
- qint64 cachekey = 0;
- QDeclarativePixmap p(&engine, url);
- QVERIFY(p.isReady());
- QVERIFY(p.image().size() == QSize(10000, 1000));
- cachekey = p.image().cacheKey();
-
- QDeclarativePixmap p2(&engine, url);
- QVERIFY(p2.isReady());
- QVERIFY(p2.image().size() == QSize(10000, 1000));
-
- QVERIFY(p2.image().cacheKey() == cachekey);
- }
-
- // Confirm that massive images are removed from the cache when
- // they become unused
- {
- qint64 cachekey = 0;
- {
- QDeclarativePixmap p(&engine, url);
- QVERIFY(p.isReady());
- QVERIFY(p.image().size() == QSize(10000, 1000));
- cachekey = p.image().cacheKey();
- }
-
- QDeclarativePixmap p2(&engine, url);
- QVERIFY(p2.isReady());
- QVERIFY(p2.image().size() == QSize(10000, 1000));
-
- QVERIFY(p2.image().cacheKey() != cachekey);
- }
-}
-
-// QTBUG-12729
-void tst_qdeclarativepixmapcache::cancelcrash()
-{
- QUrl url("http://127.0.0.1:14452/cancelcrash_notexist.png");
- for (int ii = 0; ii < 1000; ++ii) {
- QDeclarativePixmap pix(&engine, url);
- }
-}
-
-class MyPixmapProvider : public QDeclarativeImageProvider
-{
-public:
- MyPixmapProvider()
- : QDeclarativeImageProvider(Pixmap) {}
-
- virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) {
- Q_UNUSED(d)
- QPixmap pix(800, 600);
- pix.fill(Qt::red);
- return pix;
- }
-};
-
-// QTBUG-13345
-void tst_qdeclarativepixmapcache::shrinkcache()
-{
- QDeclarativeEngine engine;
- engine.addImageProvider(QLatin1String("mypixmaps"), new MyPixmapProvider);
-
- for (int ii = 0; ii < 4000; ++ii) {
- QUrl url("image://mypixmaps/" + QString::number(ii));
- QDeclarativePixmap p(&engine, url);
- }
-}
-
-#ifndef QT_NO_CONCURRENT
-
-void createNetworkServer()
-{
- QEventLoop eventLoop;
- TestHTTPServer server(14453);
- server.serveDirectory(QDeclarativeDataTest::instance()->testFile("http"));
- QTimer::singleShot(100, &eventLoop, SLOT(quit()));
- eventLoop.exec();
-}
-
-#ifndef QT_NO_CONCURRENT
-// QT-3957
-void tst_qdeclarativepixmapcache::networkCrash()
-{
- QFuture<void> future = QtConcurrent::run(createNetworkServer);
- QDeclarativeEngine engine;
- for (int ii = 0; ii < 100 ; ++ii) {
- QDeclarativePixmap* pixmap = new QDeclarativePixmap;
- pixmap->load(&engine, QUrl(QString("http://127.0.0.1:14453/exists.png")));
- QTest::qSleep(1);
- pixmap->clear();
- delete pixmap;
- }
- future.cancel();
-}
-#endif
-
-#endif
-
-// QTBUG-22125
-void tst_qdeclarativepixmapcache::lockingCrash()
-{
- TestHTTPServer server(14453);
- server.serveDirectory(testFile("http"), TestHTTPServer::Delay);
-
- {
- QDeclarativePixmap* p = new QDeclarativePixmap;
- {
- QDeclarativeEngine e;
- p->load(&e, QUrl(QString("http://127.0.0.1:14453/exists6.png")));
- }
- p->clear();
- QVERIFY(p->isNull());
- delete p;
- }
-}
-
-
-#if PIXMAP_DATA_LEAK_TEST
-// This test should not be enabled by default as it
-// produces spurious output in the expected case.
-#include <QtQuick/QQuickView>
-class DataLeakView : public QQuickView
-{
- Q_OBJECT
-
-public:
- explicit DataLeakView() : QQuickView()
- {
- setSource(testFileUrl("dataLeak.qml"));
- }
-
- void showFor2Seconds()
- {
- showFullScreen();
- QTimer::singleShot(2000, this, SIGNAL(ready()));
- }
-
-signals:
- void ready();
-};
-
-// QTBUG-22742
-Q_GLOBAL_STATIC(QDeclarativePixmap, dataLeakPixmap)
-void tst_qdeclarativepixmapcache::dataLeak()
-{
- // Should not leak cached QDeclarativePixmapData.
- // Unfortunately, since the QDeclarativePixmapStore
- // is a global static, and it releases the cache
- // entries on dtor (application exit), we must use
- // valgrind to determine whether it leaks or not.
- QDeclarativePixmap *p1 = new QDeclarativePixmap;
- QDeclarativePixmap *p2 = new QDeclarativePixmap;
- {
- QScopedPointer<DataLeakView> test(new DataLeakView);
- test->showFor2Seconds();
- dataLeakPixmap()->load(test->engine(), testFileUrl("exists.png"));
- p1->load(test->engine(), testFileUrl("exists.png"));
- p2->load(test->engine(), testFileUrl("exists2.png"));
- QTest::qWait(2005); // 2 seconds + a few more millis.
- }
-
- // When the (global static) dataLeakPixmap is deleted, it
- // shouldn't attempt to dereference a QDeclarativePixmapData
- // which has been deleted by the QDeclarativePixmapStore
- // destructor.
-}
-#endif
-#undef PIXMAP_DATA_LEAK_TEST
-
-QTEST_MAIN(tst_qdeclarativepixmapcache)
-
-#include "tst_qdeclarativepixmapcache.moc"
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
deleted file mode 100644
index 41650c523f..0000000000
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativesmoothedanimation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesmoothedanimation.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp
deleted file mode 100644
index 09bde4ad76..0000000000
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qdeclarativesmoothedanimation_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativesmoothedanimation : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativesmoothedanimation();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
- void simpleAnimation();
- void valueSource();
- void behavior();
- void deleteOnUpdate();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativesmoothedanimation::tst_qdeclarativesmoothedanimation()
-{
-}
-
-void tst_qdeclarativesmoothedanimation::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation1.qml"));
- QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 0.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->duration(), -1);
- QCOMPARE(obj->maximumEasingTime(), -1);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Eased);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::values()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation2.qml"));
- QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 10.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->duration(), 300);
- QCOMPARE(obj->maximumEasingTime(), -1);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Immediate);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation3.qml"));
- QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 10.);
- QCOMPARE(obj->velocity(), 250.);
- QCOMPARE(obj->maximumEasingTime(), 150);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Sync);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::simpleAnimation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("simpleanimation.qml"));
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QQuickRectangle *rect = obj->findChild<QQuickRectangle*>("rect");
- QVERIFY(rect);
-
- QDeclarativeSmoothedAnimation *animation = obj->findChild<QDeclarativeSmoothedAnimation*>("anim");
- QVERIFY(animation);
-
- animation->setTargetObject(rect);
- animation->setProperty("x");
- animation->setTo(200);
- animation->setDuration(250);
- QVERIFY(animation->target() == rect);
- QVERIFY(animation->property() == "x");
- QVERIFY(animation->to() == 200);
- animation->start();
- QVERIFY(animation->isRunning());
- QTest::qWait(animation->duration());
- QTRY_COMPARE(rect->x(), qreal(200));
- QTest::qWait(100); //smoothed animation doesn't report stopped until delayed timer fires
-
- QVERIFY(!animation->isRunning());
- rect->setX(0);
- animation->start();
- QVERIFY(animation->isRunning());
- animation->pause();
- QVERIFY(animation->isRunning());
- QVERIFY(animation->isPaused());
- animation->setCurrentTime(125);
- QVERIFY(animation->currentTime() == 125);
- QCOMPARE(rect->x(), qreal(100));
-}
-
-void tst_qdeclarativesmoothedanimation::valueSource()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
- QVERIFY(theRect);
-
- QDeclarativeSmoothedAnimation *easeX = rect->findChild<QDeclarativeSmoothedAnimation*>("easeX");
- QVERIFY(easeX);
- QVERIFY(easeX->isRunning());
-
- QDeclarativeSmoothedAnimation *easeY = rect->findChild<QDeclarativeSmoothedAnimation*>("easeY");
- QVERIFY(easeY);
- QVERIFY(easeY->isRunning());
-
- // XXX get the proper duration
- QTest::qWait(100);
-
- QTRY_VERIFY(!easeX->isRunning());
- QTRY_VERIFY(!easeY->isRunning());
-
- QTRY_COMPARE(theRect->x(), qreal(200));
- QTRY_COMPARE(theRect->y(), qreal(200));
-
- delete rect;
-}
-
-void tst_qdeclarativesmoothedanimation::behavior()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
- QVERIFY(theRect);
-
- QDeclarativeSmoothedAnimation *easeX = rect->findChild<QDeclarativeSmoothedAnimation*>("easeX");
- QVERIFY(easeX);
-
- QDeclarativeSmoothedAnimation *easeY = rect->findChild<QDeclarativeSmoothedAnimation*>("easeY");
- QVERIFY(easeY);
-
- // XXX get the proper duration
- QTest::qWait(400);
-
- QTRY_VERIFY(!easeX->isRunning());
- QTRY_VERIFY(!easeY->isRunning());
-
- QTRY_COMPARE(theRect->x(), qreal(200));
- QTRY_COMPARE(theRect->y(), qreal(200));
-
- delete rect;
-}
-
-void tst_qdeclarativesmoothedanimation::deleteOnUpdate()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("deleteOnUpdate.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeSmoothedAnimation *anim = rect->findChild<QDeclarativeSmoothedAnimation*>("anim");
- QVERIFY(anim);
-
- //don't crash
- QTest::qWait(500);
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qdeclarativesmoothedanimation)
-
-#include "tst_qdeclarativesmoothedanimation.moc"
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro b/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro
deleted file mode 100644
index d90cf3dca3..0000000000
--- a/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativespringanimation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativespringanimation.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp b/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp
deleted file mode 100644
index 64956d7753..0000000000
--- a/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativespringanimation_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativespringanimation : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativespringanimation();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativespringanimation::tst_qdeclarativespringanimation()
-{
-}
-
-void tst_qdeclarativespringanimation::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("springanimation1.qml"));
- QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 0.);
- QCOMPARE(obj->velocity(), 0.);
- QCOMPARE(obj->spring(), 0.);
- QCOMPARE(obj->damping(), 0.);
- QCOMPARE(obj->epsilon(), 0.01);
- QCOMPARE(obj->modulus(), 0.);
- QCOMPARE(obj->mass(), 1.);
- QCOMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-void tst_qdeclarativespringanimation::values()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("springanimation2.qml"));
- QObject *root = c.create();
-
- QDeclarativeSpringAnimation *obj = root->findChild<QDeclarativeSpringAnimation*>();
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 1.44);
- QCOMPARE(obj->velocity(), 0.9);
- QCOMPARE(obj->spring(), 1.0);
- QCOMPARE(obj->damping(), 0.5);
- QCOMPARE(obj->epsilon(), 0.25);
- QCOMPARE(obj->modulus(), 360.0);
- QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->isRunning(), true);
-
- QTRY_COMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-void tst_qdeclarativespringanimation::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("springanimation3.qml"));
- QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 1.44);
- QCOMPARE(obj->velocity(), 0.9);
- QCOMPARE(obj->spring(), 1.0);
- QCOMPARE(obj->damping(), 0.5);
- QCOMPARE(obj->epsilon(), 0.25);
- QCOMPARE(obj->modulus(), 360.0);
- QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qdeclarativespringanimation)
-
-#include "tst_qdeclarativespringanimation.moc"
diff --git a/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro b/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro
deleted file mode 100644
index 74f5bef417..0000000000
--- a/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativestates
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativestates.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp
deleted file mode 100644
index 391a4f7cfe..0000000000
--- a/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp
+++ /dev/null
@@ -1,1608 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquickstateoperations_p.h>
-#include <private/qquickanchors_p_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qquickimage_p.h>
-#include <QtQuick/private/qdeclarativepropertychanges_p.h>
-#include <QtQuick/private/qdeclarativestategroup_p.h>
-#include <private/qquickitem_p.h>
-#include <private/qdeclarativeproperty_p.h>
-#include "../../shared/util.h"
-
-class MyAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo WRITE setFoo)
-public:
- MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
-
- int foo() const { return m_foo; }
- void setFoo(int f) { m_foo = f; }
-
-private:
- int m_foo;
-};
-
-class MyRect : public QQuickRectangle
-{
- Q_OBJECT
- Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
-public:
- MyRect() {}
-
- void doSomething() { emit didSomething(); }
-
- int propertyWithNotify() const { return m_prop; }
- void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); }
-
- static MyAttached *qmlAttachedProperties(QObject *o) {
- return new MyAttached(o);
- }
-Q_SIGNALS:
- void didSomething();
- void oddlyNamedNotifySignal();
-
-private:
- int m_prop;
-};
-
-QML_DECLARE_TYPE(MyRect)
-QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES)
-
-class tst_qdeclarativestates : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativestates() {}
-
-private:
- QByteArray fullDataPath(const QString &path) const;
-
-private slots:
- void initTestCase();
-
- void basicChanges();
- void attachedPropertyChanges();
- void basicExtension();
- void basicBinding();
- void signalOverride();
- void signalOverrideCrash();
- void signalOverrideCrash2();
- void signalOverrideCrash3();
- void parentChange();
- void parentChangeErrors();
- void anchorChanges();
- void anchorChanges2();
- void anchorChanges3();
- void anchorChanges4();
- void anchorChanges5();
- void anchorChangesRTL();
- void anchorChangesRTL2();
- void anchorChangesRTL3();
- void anchorChangesCrash();
- void anchorRewindBug();
- void anchorRewindBug2();
- void script();
- void restoreEntryValues();
- void explicitChanges();
- void propertyErrors();
- void incorrectRestoreBug();
- void autoStateAtStartupRestoreBug();
- void deletingChange();
- void deletingState();
- void tempState();
- void illegalTempState();
- void nonExistantProperty();
- void reset();
- void illegalObjectCreation();
- void whenOrdering();
- void urlResolution();
- void unnamedWhen();
- void returnToBase();
- void extendsBug();
- void editProperties();
- void QTBUG_14830();
- void avoidFastForward();
- void revertListBug();
-};
-
-void tst_qdeclarativestates::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<MyRect>("Qt.test", 1, 0, "MyRectangle");
-}
-
-QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) const
-{
- return testFileUrl(path).toString().toUtf8();
-}
-
-void tst_qdeclarativestates::basicChanges()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2.0);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
- //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2.0);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1.0);
-
- }
-
- {
- // Test basicChanges4.qml can magically connect to propertyWithNotify's notify
- // signal using 'onPropertyWithNotifyChanged' even though the signal name is
- // actually 'oddlyNamedNotifySignal'
-
- QDeclarativeComponent component(&engine, testFileUrl("basicChanges4.qml"));
- QVERIFY(component.isReady());
-
- MyRect *rect = qobject_cast<MyRect*>(component.create());
- QVERIFY(rect != 0);
-
- QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify"));
- QVERIFY(prop.hasNotifySignal());
- QString notifySignal = QByteArray(prop.notifySignal().signature());
- QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged("));
-
- QCOMPARE(rect->color(), QColor(Qt::red));
-
- rect->setPropertyWithNotify(100);
- QCOMPARE(rect->color(), QColor(Qt::blue));
- }
-}
-
-void tst_qdeclarativestates::attachedPropertyChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyChanges.qml"));
- QVERIFY(component.isReady());
-
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item != 0);
- QCOMPARE(item->width(), 50.0);
-
- // Ensure attached property has been changed
- QObject *attObj = qmlAttachedPropertiesObject<MyRect>(item, false);
- QVERIFY(attObj);
-
- MyAttached *att = qobject_cast<MyAttached*>(attObj);
- QVERIFY(att);
-
- QCOMPARE(att->foo(), 1);
-}
-
-void tst_qdeclarativestates::basicExtension()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicExtension.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2.0);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2.0);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("fakeExtension.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-}
-
-void tst_qdeclarativestates::basicBinding()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("red"));
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor2", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor2", QColor("green"));
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("purple"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("purple"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-}
-
-void tst_qdeclarativestates::signalOverride()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride.qml"));
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- QQuickItemPrivate::get(rect)->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride2.qml"));
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("white"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("extendedRect"));
- QQuickItemPrivate::get(innerRect)->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(innerRect->color(),QColor("green"));
- QCOMPARE(innerRect->property("extendedColor").value<QColor>(),QColor("green"));
- }
-}
-
-void tst_qdeclarativestates::signalOverrideCrash()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash.qml"));
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate::get(rect)->setState("overridden");
- rect->doSomething();
-}
-
-void tst_qdeclarativestates::signalOverrideCrash2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QQuickItemPrivate::get(rect)->setState("state2");
- QQuickItemPrivate::get(rect)->setState("state1");
-
- delete rect;
-}
-
-void tst_qdeclarativestates::signalOverrideCrash3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QQuickItemPrivate::get(rect)->setState("");
- QQuickItemPrivate::get(rect)->setState("state2");
- QQuickItemPrivate::get(rect)->setState("");
-
- delete rect;
-}
-
-void tst_qdeclarativestates::parentChange()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange1.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickParentChange *pChange = qobject_cast<QQuickParentChange*>(state->operationAt(0));
- QVERIFY(pChange != 0);
- QQuickItem *nParent = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("NewParent"));
- QVERIFY(nParent != 0);
-
- QCOMPARE(pChange->parent(), nParent);
-
- QQuickItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(-133));
- QCOMPARE(innerRect->y(), qreal(-300));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(15));
- QCOMPARE(innerRect->scale(), qreal(.5));
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075));
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(-37));
- QCOMPARE(innerRect->scale(), qreal(.25));
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- //do a non-qFuzzyCompare fuzzy compare
- QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange6.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QQuickItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(180));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(-105));
- QCOMPARE(innerRect->y(), qreal(-105));
- }
-}
-
-void tst_qdeclarativestates::parentChangeErrors()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale");
- QQuickItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange5.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform");
- QQuickItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-}
-
-void tst_qdeclarativestates::anchorChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QCOMPARE(aChanges->anchors()->left().script(), QLatin1String("undefined"));
- QCOMPARE(aChanges->anchors()->right().script(), QLatin1String("container.right"));
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QCOMPARE(aChanges->anchors()->top().script(), QLatin1String("container.top"));
- QCOMPARE(aChanges->anchors()->bottom().script(), QLatin1String("bottomGuideline.bottom"));
-
- rectPrivate->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine);
-
- QCOMPARE(innerRect->x(), qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- QCOMPARE(innerRect->width(), qreal(190));
- QCOMPARE(innerRect->height(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(0));
- QCOMPARE(innerRect->y(), qreal(10));
- QCOMPARE(innerRect->width(), qreal(150));
- QCOMPARE(innerRect->height(), qreal(190));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges4()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QCOMPARE(aChanges->anchors()->horizontalCenter().script(), QLatin1String("bottomGuideline.horizontalCenter"));
- QCOMPARE(aChanges->anchors()->verticalCenter().script(), QLatin1String("leftGuideline.verticalCenter"));
-
- QQuickItemPrivate::get(rect)->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QQuickItemPrivate::get(leftGuideline)->verticalCenter().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QQuickItemPrivate::get(leftGuideline)->verticalCenter().anchorLine);
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges5()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges5.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QCOMPARE(aChanges->anchors()->baseline().script(), QLatin1String("leftGuideline.baseline"));
-
- QQuickItemPrivate::get(rect)->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().item, QQuickItemPrivate::get(leftGuideline)->baseline().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().anchorLine, QQuickItemPrivate::get(leftGuideline)->baseline().anchorLine);
-
- delete rect;
-}
-
-void mirrorAnchors(QQuickItem *item) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->setLayoutMirror(true);
-}
-
-qreal offsetRTL(QQuickItem *anchorItem, QQuickItem *item) {
- return anchorItem->width()+2*anchorItem->x()-item->width();
-}
-
-void tst_qdeclarativestates::anchorChangesRTL()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChangesRTL2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChangesRTL3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rectPrivate->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine);
-
- QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- // between left side of parent and leftGuideline.x: 10, which has width 0
- QCOMPARE(innerRect->width(), qreal(10));
- QCOMPARE(innerRect->height(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0));
- QCOMPARE(innerRect->y(), qreal(10));
- // between right side of parent and left side of rightGuideline.x: 150, which has width 0
- QCOMPARE(innerRect->width(), qreal(50));
- QCOMPARE(innerRect->height(), qreal(190));
-
- delete rect;
-}
-
-//QTBUG-9609
-void tst_qdeclarativestates::anchorChangesCrash()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChangesCrash.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate::get(rect)->setState("reanchored");
-
- delete rect;
-}
-
-// QTBUG-12273
-void tst_qdeclarativestates::anchorRewindBug()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("anchorRewindBug.qml"));
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(view->rootObject());
- QVERIFY(rect != 0);
-
- QQuickItem * column = rect->findChild<QQuickItem*>("column");
-
- QVERIFY(column != 0);
- QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
- QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
- QCOMPARE(column->height(), 200.0);
- QQuickItemPrivate::get(rect)->setState("reanchored");
-
- // column height and width should stay implicit
- // and column's implicit resizing should still work
- QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
- QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
- QTRY_COMPARE(column->height(), 100.0);
-
- QQuickItemPrivate::get(rect)->setState("");
-
- // column height and width should stay implicit
- // and column's implicit resizing should still work
- QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
- QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
- QTRY_COMPARE(column->height(), 200.0);
-
- delete view;
-}
-
-// QTBUG-11834
-void tst_qdeclarativestates::anchorRewindBug2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorRewindBug2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("mover");
-
- QVERIFY(mover != 0);
- QCOMPARE(mover->y(), qreal(0.0));
- QCOMPARE(mover->width(), qreal(50.0));
-
- QQuickItemPrivate::get(rect)->setState("anchored");
- QCOMPARE(mover->y(), qreal(250.0));
- QCOMPARE(mover->width(), qreal(200.0));
-
- QQuickItemPrivate::get(rect)->setState("");
- QCOMPARE(mover->y(), qreal(0.0));
- QCOMPARE(mover->width(), qreal(50.0));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::script()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("script.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
- }
-}
-
-void tst_qdeclarativestates::restoreEntryValues()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("restoreEntryValues.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("blue"));
-}
-
-void tst_qdeclarativestates::explicitChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("explicit.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarativePropertyChanges *changes = qobject_cast<QDeclarativePropertyChanges*>(rect->findChild<QDeclarativePropertyChanges*>("changes"));
- QVERIFY(changes != 0);
- QVERIFY(changes->isExplicit());
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
-}
-
-void tst_qdeclarativestates::propertyErrors()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, testFileUrl("propertyErrors.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\"");
- QQuickItemPrivate::get(rect)->setState("blue");
-}
-
-void tst_qdeclarativestates::incorrectRestoreBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- // make sure if we change the base state value, we then restore to it correctly
- rect->setColor(QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("green"));
-}
-
-void tst_qdeclarativestates::autoStateAtStartupRestoreBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, testFileUrl("autoStateAtStartupRestoreBug.qml"));
- QObject *obj = component.create();
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 3);
-
- obj->setProperty("input", 2);
-
- QCOMPARE(obj->property("test").toInt(), 9);
-
- delete obj;
-}
-
-void tst_qdeclarativestates::deletingChange()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("deleting.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->radius(),qreal(5));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(0));
-
- QDeclarativePropertyChanges *pc = rect->findChild<QDeclarativePropertyChanges*>("pc1");
- QVERIFY(pc != 0);
- delete pc;
-
- QDeclarativeState *state = rect->findChild<QDeclarativeState*>();
- QVERIFY(state != 0);
- qmlExecuteDeferred(state);
- QCOMPARE(state->operationCount(), 1);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::deletingState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("deletingState.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarativeStateGroup *sg = rect->findChild<QDeclarativeStateGroup*>();
- QVERIFY(sg != 0);
- QVERIFY(sg->findState("blue") != 0);
-
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- sg->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- QDeclarativeState *state = rect->findChild<QDeclarativeState*>();
- QVERIFY(state != 0);
- delete state;
-
- QVERIFY(sg->findState("blue") == 0);
-
- //### should we warn that state doesn't exist
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::tempState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("legalTempState.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QTest::ignoreMessage(QtDebugMsg, "entering placed");
- QTest::ignoreMessage(QtDebugMsg, "entering idle");
- rectPrivate->setState("placed");
- QCOMPARE(rectPrivate->state(), QLatin1String("idle"));
-}
-
-void tst_qdeclarativestates::illegalTempState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("illegalTempState.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML StateGroup: Can't apply a state change as part of a state definition.");
- rectPrivate->setState("placed");
- QCOMPARE(rectPrivate->state(), QLatin1String("placed"));
-}
-
-void tst_qdeclarativestates::nonExistantProperty()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("nonExistantProp.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
- rectPrivate->setState("blue");
- QCOMPARE(rectPrivate->state(), QLatin1String("blue"));
-}
-
-void tst_qdeclarativestates::reset()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("reset.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickImage *image = rect->findChild<QQuickImage*>();
- QVERIFY(image != 0);
- QCOMPARE(image->width(), qreal(40.));
- QCOMPARE(image->height(), qreal(20.));
-
- QQuickItemPrivate::get(rect)->setState("state1");
-
- QCOMPARE(image->width(), 20.0);
- QCOMPARE(image->height(), qreal(20.));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::illegalObjectCreation()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, testFileUrl("illegalObj.qml"));
- QList<QDeclarativeError> errors = component.errors();
- QVERIFY(errors.count() == 1);
- const QDeclarativeError &error = errors.at(0);
- QCOMPARE(error.line(), 9);
- QCOMPARE(error.column(), 23);
- QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects.");
-}
-
-void tst_qdeclarativestates::whenOrdering()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("whenOrdering.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- rect->setProperty("condition2", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state2"));
- rect->setProperty("condition1", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition2", false);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition2", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition1", false);
- rect->setProperty("condition2", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
-}
-
-void tst_qdeclarativestates::urlResolution()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("urlResolution.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItem *myType = rect->findChild<QQuickItem*>("MyType");
- QQuickImage *image1 = rect->findChild<QQuickImage*>("image1");
- QQuickImage *image2 = rect->findChild<QQuickImage*>("image2");
- QQuickImage *image3 = rect->findChild<QQuickImage*>("image3");
- QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0);
-
- QQuickItemPrivate::get(myType)->setState("SetImageState");
- QUrl resolved = testFileUrl("Implementation/images/qt-logo.png");
- QCOMPARE(image1->source(), resolved);
- QCOMPARE(image2->source(), resolved);
- QCOMPARE(image3->source(), resolved);
-
- delete rect;
-}
-
-void tst_qdeclarativestates::unnamedWhen()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("unnamedWhen.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
- rect->setProperty("triggerState", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
- rect->setProperty("triggerState", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
-}
-
-void tst_qdeclarativestates::returnToBase()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("returnToBase.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
- rect->setProperty("triggerState", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
- rect->setProperty("triggerState", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState"));
-}
-
-//QTBUG-12559
-void tst_qdeclarativestates::extendsBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("extendsBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QQuickRectangle *greenRect = rect->findChild<QQuickRectangle*>("greenRect");
-
- rectPrivate->setState("b");
- QCOMPARE(greenRect->x(), qreal(100));
- QCOMPARE(greenRect->y(), qreal(100));
-}
-
-void tst_qdeclarativestates::editProperties()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("editProperties.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QDeclarativeStateGroup *stateGroup = rectPrivate->_states();
- QVERIFY(stateGroup != 0);
- qmlExecuteDeferred(stateGroup);
-
- QDeclarativeState *blueState = stateGroup->findState("blue");
- QVERIFY(blueState != 0);
- qmlExecuteDeferred(blueState);
-
- QDeclarativePropertyChanges *propertyChangesBlue = qobject_cast<QDeclarativePropertyChanges*>(blueState->operationAt(0));
- QVERIFY(propertyChangesBlue != 0);
-
- QDeclarativeState *greenState = stateGroup->findState("green");
- QVERIFY(greenState != 0);
- qmlExecuteDeferred(greenState);
-
- QDeclarativePropertyChanges *propertyChangesGreen = qobject_cast<QDeclarativePropertyChanges*>(greenState->operationAt(0));
- QVERIFY(propertyChangesGreen != 0);
-
- QQuickRectangle *childRect = rect->findChild<QQuickRectangle*>("rect2");
- QVERIFY(childRect != 0);
- QCOMPARE(childRect->width(), qreal(402));
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QCOMPARE(childRect->height(), qreal(200));
-
- rectPrivate->setState("blue");
- QCOMPARE(childRect->width(), qreal(50));
- QCOMPARE(childRect->height(), qreal(40));
- QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QVERIFY(blueState->bindingInRevertList(childRect, "width"));
-
-
- rectPrivate->setState("green");
- QCOMPARE(childRect->width(), qreal(200));
- QCOMPARE(childRect->height(), qreal(100));
- QVERIFY(greenState->bindingInRevertList(childRect, "width"));
-
-
- rectPrivate->setState("");
-
-
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
- QVERIFY(propertyChangesBlue->containsValue("width"));
- QVERIFY(!propertyChangesBlue->containsProperty("x"));
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
- QVERIFY(!propertyChangesBlue->value("x").isValid());
-
- propertyChangesBlue->changeValue("width", 60);
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
-
-
- propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
- QVERIFY(!propertyChangesBlue->containsValue("width"));
- QVERIFY(propertyChangesBlue->containsExpression("width"));
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
-
- propertyChangesBlue->changeValue("width", 50);
- QVERIFY(propertyChangesBlue->containsValue("width"));
- QVERIFY(!propertyChangesBlue->containsExpression("width"));
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
-
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- rectPrivate->setState("blue");
- QCOMPARE(childRect->width(), qreal(50));
- QCOMPARE(childRect->height(), qreal(40));
-
- propertyChangesBlue->changeValue("width", 60);
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
- QCOMPARE(childRect->width(), qreal(60));
- QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
-
- propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
- QVERIFY(!propertyChangesBlue->containsValue("width"));
- QVERIFY(propertyChangesBlue->containsExpression("width"));
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QCOMPARE(childRect->width(), qreal(200));
-
- propertyChangesBlue->changeValue("width", 50);
- QCOMPARE(childRect->width(), qreal(50));
-
- rectPrivate->setState("");
- QCOMPARE(childRect->width(), qreal(402));
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
-
- QCOMPARE(propertyChangesGreen->actions().length(), 2);
- rectPrivate->setState("green");
- QCOMPARE(childRect->width(), qreal(200));
- QCOMPARE(childRect->height(), qreal(100));
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QVERIFY(greenState->bindingInRevertList(childRect, "width"));
- QCOMPARE(propertyChangesGreen->actions().length(), 2);
-
-
- propertyChangesGreen->removeProperty("height");
- QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "height")));
- QCOMPARE(childRect->height(), qreal(200));
-
- QVERIFY(greenState->bindingInRevertList(childRect, "width"));
- QVERIFY(greenState->containsPropertyInRevertList(childRect, "width"));
- propertyChangesGreen->removeProperty("width");
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QCOMPARE(childRect->width(), qreal(402));
- QVERIFY(!greenState->bindingInRevertList(childRect, "width"));
- QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width"));
-
- propertyChangesBlue->removeProperty("width");
- QCOMPARE(childRect->width(), qreal(402));
-
- rectPrivate->setState("blue");
- QCOMPARE(childRect->width(), qreal(402));
- QCOMPARE(childRect->height(), qreal(40));
-}
-
-void tst_qdeclarativestates::QTBUG_14830()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("QTBUG-14830.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItem *item = rect->findChild<QQuickItem*>("area");
-
- QCOMPARE(item->width(), qreal(171));
-}
-
-void tst_qdeclarativestates::avoidFastForward()
-{
- QDeclarativeEngine engine;
-
- //shouldn't fast forward if there isn't a transition
- QDeclarativeComponent c(&engine, testFileUrl("avoidFastForward.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- rectPrivate->setState("a");
- QCOMPARE(rect->property("updateCount").toInt(), 1);
-}
-
-//QTBUG-22583
-void tst_qdeclarativestates::revertListBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("revertListBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *rect1 = rect->findChild<QQuickRectangle*>("rect1");
- QQuickRectangle *rect2 = rect->findChild<QQuickRectangle*>("rect2");
- QQuickItem *origParent1 = rect->findChild<QQuickItem*>("originalParent1");
- QQuickItem *origParent2 = rect->findChild<QQuickItem*>("originalParent2");
- QQuickItem *newParent = rect->findChild<QQuickItem*>("newParent");
-
- QCOMPARE(rect1->parentItem(), origParent1);
- QCOMPARE(rect2->parentItem(), origParent2);
-
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- rectPrivate->setState("reparented");
-
- QCOMPARE(rect1->parentItem(), newParent);
- QCOMPARE(rect2->parentItem(), origParent2);
-
- rectPrivate->setState("");
-
- QCOMPARE(rect1->parentItem(), origParent1);
- QCOMPARE(rect2->parentItem(), origParent2);
-
- QMetaObject::invokeMethod(rect, "switchTargetItem");
-
- rectPrivate->setState("reparented");
-
- QCOMPARE(rect1->parentItem(), origParent1);
- QCOMPARE(rect2->parentItem(), newParent);
-
- rectPrivate->setState("");
-
- QCOMPARE(rect1->parentItem(), origParent1);
- QCOMPARE(rect2->parentItem(), origParent2); //QTBUG-22583 causes rect2's parent item to be origParent1
-}
-
-QTEST_MAIN(tst_qdeclarativestates)
-
-#include "tst_qdeclarativestates.moc"
diff --git a/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro b/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro
deleted file mode 100644
index 84532f611e..0000000000
--- a/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativestyledtext
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativestyledtext.cpp
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp b/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp
deleted file mode 100644
index ca3855c32a..0000000000
--- a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtGui/QTextLayout>
-#include <QtCore/QList>
-#include <QtQuick/private/qdeclarativestyledtext_p.h>
-
-class tst_qdeclarativestyledtext : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativestyledtext()
- {
- }
-
- struct Format {
- enum Type {
- Bold = 0x01,
- Underline = 0x02,
- Italic = 0x04
- };
- Format(int t, int s, int l)
- : type(t), start(s), length(l) {}
- int type;
- int start;
- int length;
- };
- typedef QList<Format> FormatList;
-
- static const QChar bullet;
- static const QChar disc;
- static const QChar square;
-
-private slots:
- void textOutput();
- void textOutput_data();
-};
-
-Q_DECLARE_METATYPE(tst_qdeclarativestyledtext::FormatList);
-
-const QChar tst_qdeclarativestyledtext::bullet(0x2022);
-const QChar tst_qdeclarativestyledtext::disc(0x25e6);
-const QChar tst_qdeclarativestyledtext::square(0x25a1);
-
-// For malformed input all we test is that we get the expected text and format out.
-//
-void tst_qdeclarativestyledtext::textOutput_data()
-{
- QTest::addColumn<QString>("input");
- QTest::addColumn<QString>("output");
- QTest::addColumn<FormatList>("formats");
- QTest::addColumn<bool>("modifiesFontSize");
-
- QTest::newRow("bold") << "<b>bold</b>" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
- QTest::newRow("italic") << "<i>italic</i>" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)) << false;
- QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
- QTest::newRow("strong") << "<strong>strong</strong>" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)) << false;
- QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
- QTest::newRow("missing >") << "<b>text</b" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
- QTest::newRow("missing b>") << "<b>text</" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
- QTest::newRow("missing /b>") << "<b>text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
- QTest::newRow("missing </b>") << "<b>text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
- QTest::newRow("nested") << "<b>text <i>italic</i> bold</b>" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)) << false;
- QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)) << false;
- QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text" << (FormatList() << Format(0, 0, 8)) << false;
- QTest::newRow("font color: single quote") << "<font color='red'>red text</font>" << "red text" << (FormatList() << Format(0, 0, 8)) << false;
- QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text" << (FormatList() << Format(0, 0, 4)) << true;
- QTest::newRow("font empty") << "<font>text</font>" << "text" << FormatList() << false;
- QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text" << FormatList() << false;
- QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << "" << FormatList() << false;
- QTest::newRow("extra close") << "<b>text</b></b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
- QTest::newRow("extra space") << "<b >text</b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
- QTest::newRow("entities") << "&lt;b&gt;this &amp; that&lt;/b&gt;" << "<b>this & that</b>" << FormatList() << false;
- QTest::newRow("newline") << "text<br>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
- QTest::newRow("paragraph") << "text<p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
- QTest::newRow("paragraph closed") << "text<p>more text</p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
- QTest::newRow("paragraph closed bold") << "<b>text<p>more text</p>more text</b>" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)) << false;
- QTest::newRow("self-closing newline") << "text<br/>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
- QTest::newRow("empty") << "" << "" << FormatList() << false;
- QTest::newRow("unknown tag") << "<a href='#'><foo>underline</foo></a> not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
- QTest::newRow("ordered list") << "<ol><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false;
- QTest::newRow("ordered list closed") << "<ol><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("ordered list alpha") << "<ol type=\"a\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("ordered list upper alpha") << "<ol type=\"A\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("ordered list roman") << "<ol type=\"i\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("ordered list upper roman") << "<ol type=\"I\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("ordered list bad") << "<ol type=\"z\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("unordered list") << "<ul><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false;
- QTest::newRow("unordered list closed") << "<ul><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("unordered list disc") << "<ul type=\"disc\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("unordered list square") << "<ul type=\"square\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("unordered list bad") << "<ul type=\"bad\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
- QTest::newRow("header close") << "<h1>head</h1>more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
- QTest::newRow("h0") << "<h0>head" << "head" << FormatList() << false;
- QTest::newRow("h1") << "<h1>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
- QTest::newRow("h2") << "<h2>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
- QTest::newRow("h3") << "<h3>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
- QTest::newRow("h4") << "<h4>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
- QTest::newRow("h5") << "<h5>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
- QTest::newRow("h6") << "<h6>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
- QTest::newRow("h7") << "<h7>head" << "head" << FormatList() << false;
- QTest::newRow("pre") << "normal<pre>pre text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)) << false;
- QTest::newRow("pre lb") << "normal<pre>pre\n text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)) << false;
- QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList() << false;
- QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList() << false;
- QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList() << false;
- QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList() << false;
- QTest::newRow("space after newline") << "text<br/> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
- QTest::newRow("space after paragraph") << "text<p> more text</p> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
- QTest::newRow("space in header") << "<h1> head</h1> " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)) << true;
- QTest::newRow("space before bold") << "this is <b>bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)) << false;
- QTest::newRow("space leading bold") << "this is<b> bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)) << false;
- QTest::newRow("space trailing bold") << "this is <b>bold </b>" << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)) << false;
- QTest::newRow("img") << "a<img src=\"blah.png\"/>b" << "a b" << FormatList() << false;
-}
-
-void tst_qdeclarativestyledtext::textOutput()
-{
- QFETCH(QString, input);
- QFETCH(QString, output);
- QFETCH(FormatList, formats);
- QFETCH(bool, modifiesFontSize);
-
- QTextLayout layout;
- QList<QDeclarativeStyledTextImgTag*> imgTags;
- bool fontSizeModified = false;
- QDeclarativeStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified);
-
- QCOMPARE(layout.text(), output);
-
- QList<QTextLayout::FormatRange> layoutFormats = layout.additionalFormats();
-
- QCOMPARE(layoutFormats.count(), formats.count());
- for (int i = 0; i < formats.count(); ++i) {
- QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
- QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
- if (formats.at(i).type & Format::Bold)
- QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Bold);
- else
- QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Normal);
- QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic));
- QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline));
- }
- QCOMPARE(fontSizeModified, modifiesFontSize);
-}
-
-
-QTEST_MAIN(tst_qdeclarativestyledtext)
-
-#include "tst_qdeclarativestyledtext.moc"
diff --git a/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro
deleted file mode 100644
index 87c2af2190..0000000000
--- a/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativesystempalette
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesystempalette.cpp
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
deleted file mode 100644
index f2b1eeb602..0000000000
--- a/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qdeclarativesystempalette_p.h>
-#include <qpalette.h>
-
-class tst_qdeclarativesystempalette : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativesystempalette();
-
-private slots:
- void activePalette();
- void inactivePalette();
- void disabledPalette();
- void paletteChanged();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativesystempalette::tst_qdeclarativesystempalette()
-{
-}
-
-void tst_qdeclarativesystempalette::activePalette()
-{
- QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Active);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::inactivePalette()
-{
- QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Inactive }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QDeclarativeSystemPalette::Inactive);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Inactive);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::disabledPalette()
-{
- QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Disabled }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QDeclarativeSystemPalette::Disabled);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Disabled);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::paletteChanged()
-{
- QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
-
- QPalette p;
- p.setCurrentColorGroup(QPalette::Active);
- p.setColor(QPalette::Active, QPalette::Text, QColor("red"));
- p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green"));
- p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue"));
-
- qApp->setPalette(p);
-
- object->setColorGroup(QDeclarativeSystemPalette::Active);
- QTRY_COMPARE(QColor("red"), object->text());
- QTRY_COMPARE(QColor("green"), object->buttonText());
- QTRY_COMPARE(QColor("blue"), object->windowText());
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativesystempalette)
-
-#include "tst_qdeclarativesystempalette.moc"
diff --git a/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro
deleted file mode 100644
index d990dc449f..0000000000
--- a/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativetimer
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativetimer.cpp
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private gui testlib
diff --git a/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp
deleted file mode 100644
index 4aa35d7488..0000000000
--- a/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QSignalSpy>
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qdeclarativetimer_p.h>
-#include <QtQuick/qquickitem.h>
-#include <QDebug>
-
-class tst_qdeclarativetimer : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativetimer();
-
-private slots:
- void notRepeating();
- void notRepeatingStart();
- void repeat();
- void noTriggerIfNotRunning();
- void triggeredOnStart();
- void triggeredOnStartRepeat();
- void changeDuration();
- void restart();
- void restartFromTriggered();
- void runningFromTriggered();
- void parentProperty();
-};
-
-class TimerHelper : public QObject
-{
- Q_OBJECT
-public:
- TimerHelper() : QObject(), count(0)
- {
- }
-
- int count;
-
-public slots:
- void timeout() {
- ++count;
- }
-};
-
-#define TIMEOUT_TIMEOUT 200
-
-tst_qdeclarativetimer::tst_qdeclarativetimer()
-{
-}
-
-void tst_qdeclarativetimer::notRepeating()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(timer->isRunning());
- QVERIFY(!timer->isRepeating());
- QCOMPARE(timer->interval(), 100);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning() == false);
-}
-
-void tst_qdeclarativetimer::notRepeatingStart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100 }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(!timer->isRunning());
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 0);
-
- timer->start();
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning() == false);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::repeat()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > 0);
- int oldCount = helper.count;
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > oldCount);
- QVERIFY(timer->isRunning());
-
- oldCount = helper.count;
- timer->stop();
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count == oldCount);
- QVERIFY(timer->isRunning() == false);
-
- QSignalSpy spy(timer, SIGNAL(repeatChanged()));
-
- timer->setRepeating(false);
- QVERIFY(!timer->isRepeating());
- QCOMPARE(spy.count(),1);
-
- timer->setRepeating(false);
- QCOMPARE(spy.count(),1);
-
- timer->setRepeating(true);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::triggeredOnStart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(timer->triggeredOnStart());
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QTest::qWait(1);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 2);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning() == false);
-
- QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged()));
-
- timer->setTriggeredOnStart(false);
- QVERIFY(!timer->triggeredOnStart());
- QCOMPARE(spy.count(),1);
-
- timer->setTriggeredOnStart(false);
- QCOMPARE(spy.count(),1);
-
- timer->setTriggeredOnStart(true);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::triggeredOnStartRepeat()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QTest::qWait(1);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > 1);
- int oldCount = helper.count;
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > oldCount);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::noTriggerIfNotRunning()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 2.0\n"
- "Item { property bool ok: true\n"
- "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }"
- "Timer { interval: 10; running: true; onTriggered: t1.running=false }"
- "}"
- ), QUrl::fromLocalFile(""));
- QObject *item = component.create();
- QVERIFY(item != 0);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(item->property("ok").toBool(), true);
-
- delete item;
-}
-
-void tst_qdeclarativetimer::changeDuration()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(500);
- QCOMPARE(helper.count, 2);
-
- timer->setInterval(500);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 3);
- QVERIFY(timer->isRunning());
-
- QSignalSpy spy(timer, SIGNAL(intervalChanged()));
-
- timer->setInterval(200);
- QCOMPARE(timer->interval(), 200);
- QCOMPARE(spy.count(),1);
-
- timer->setInterval(200);
- QCOMPARE(spy.count(),1);
-
- timer->setInterval(300);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::restart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(300);
-
- timer->restart();
-
- QTest::qWait(700);
-
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::restartFromTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { "
- "interval: 500; "
- "repeat: false; "
- "running: true; "
- "onTriggered: restart()"
- " }"), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(component.create());
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(object.data());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning());
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning());
-}
-
-void tst_qdeclarativetimer::runningFromTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { "
- "property bool ok: false; "
- "interval: 500; "
- "repeat: false; "
- "running: true; "
- "onTriggered: { ok = !running; running = true }"
- " }"), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(component.create());
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(object.data());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->property("ok").toBool());
- QVERIFY(timer->isRunning());
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->property("ok").toBool());
- QVERIFY(timer->isRunning());
-}
-
-void tst_qdeclarativetimer::parentProperty()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item != 0);
- QDeclarativeTimer *timer = item->findChild<QDeclarativeTimer*>("timer");
- QVERIFY(timer != 0);
-
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-QTEST_MAIN(tst_qdeclarativetimer)
-
-#include "tst_qdeclarativetimer.moc"
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
deleted file mode 100644
index 37f1c65c92..0000000000
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativexmllistmodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativexmllistmodel.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private network testlib xmlpatterns
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
deleted file mode 100644
index 80ceb9a712..0000000000
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ /dev/null
@@ -1,962 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtGlobal>
-#include <math.h>
-#include <QMetaObject>
-#include <qtest.h>
-#include <QtTest/qsignalspy.h>
-#include <QtDeclarative/qdeclarativenetworkaccessmanagerfactory.h>
-#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QtNetwork/qnetworkrequest.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qtemporaryfile.h>
-#include "../../shared/util.h"
-#include <private/qdeclarativeengine_p.h>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qlistmodelinterface_p.h>
-#include "../../../../src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h"
-
-typedef QPair<int, int> QDeclarativeXmlListRange;
-typedef QList<QVariantList> QDeclarativeXmlModelData;
-
-Q_DECLARE_METATYPE(QList<QDeclarativeXmlListRange>)
-Q_DECLARE_METATYPE(QDeclarativeXmlModelData)
-Q_DECLARE_METATYPE(QDeclarativeXmlListModel::Status)
-
-class tst_qdeclarativexmllistmodel : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_qdeclarativexmllistmodel() {}
-
-private slots:
- void initTestCase() {
- QDeclarativeDataTest::initTestCase();
- qRegisterMetaType<QDeclarativeXmlListModel::Status>();
- }
-
- void buildModel();
- void testTypes();
- void testTypes_data();
- void cdata();
- void attributes();
- void roles();
- void roleErrors();
- void uniqueRoleNames();
- void headers();
- void xml();
- void xml_data();
- void source();
- void source_data();
- void data();
- void get();
- void reload();
- void useKeys();
- void useKeys_data();
- void noKeysValueChanges();
- void keysChanged();
- void threading();
- void threading_data();
- void propertyChanges();
-
- void roleCrash();
-
-private:
- QString errorString(QListModelInterface* model) {
- QString ret;
- QMetaObject::invokeMethod(model, "errorString", Q_RETURN_ARG(QString, ret));
- return ret;
- }
-
- QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
- {
- if (modelData)
- modelData->clear();
- QString xml;
-
- if (!data.isEmpty()) {
- QStringList items = data.split(";");
- foreach(const QString &item, items) {
- if (item.isEmpty())
- continue;
- QVariantList variants;
- xml += QLatin1String("<item>");
- QStringList fields = item.split(",");
- foreach(const QString &field, fields) {
- QStringList values = field.split("=");
- if (values.count() != 2) {
- qWarning() << "makeItemXmlAndData: invalid field:" << field;
- continue;
- }
- xml += QString("<%1>%2</%1>").arg(values[0], values[1]);
- if (!modelData)
- continue;
- bool isNum = false;
- int number = values[1].toInt(&isNum);
- if (isNum)
- variants << number;
- else
- variants << values[1];
- }
- xml += QLatin1String("</item>");
- if (modelData)
- modelData->append(variants);
- }
- }
-
- QString decl = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>";
- return decl + QLatin1String("<data>") + xml + QLatin1String("</data>");
- }
-
- QDeclarativeEngine engine;
-};
-
-class CustomNetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory
-{
- Q_OBJECT
-public:
- QVariantMap lastSentHeaders;
-
-protected:
- QNetworkAccessManager *create(QObject *parent);
-};
-
-class CustomNetworkAccessManager : public QNetworkAccessManager
-{
- Q_OBJECT
-public:
- CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent)
- : QNetworkAccessManager(parent), m_factory(factory) {}
-
-protected:
- QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0)
- {
- if (m_factory) {
- QVariantMap map;
- foreach (const QString &header, req.rawHeaderList())
- map[header] = req.rawHeader(header.toUtf8());
- m_factory->lastSentHeaders = map;
- }
- return QNetworkAccessManager::createRequest(op, req, outgoingData);
- }
-
- QPointer<CustomNetworkAccessManagerFactory> m_factory;
-};
-
-QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent)
-{
- return new CustomNetworkAccessManager(this, parent);
-}
-
-
-void tst_qdeclarativexmllistmodel::buildModel()
-{
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QCOMPARE(model->data(3, Qt::UserRole).toString(), QLatin1String("Spot"));
- QCOMPARE(model->data(3, Qt::UserRole+1).toString(), QLatin1String("Dog"));
- QCOMPARE(model->data(3, Qt::UserRole+2).toInt(), 9);
- QCOMPARE(model->data(3, Qt::UserRole+3).toString(), QLatin1String("Medium"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::testTypes()
-{
- QFETCH(QString, xml);
- QFETCH(QString, roleName);
- QFETCH(QVariant, expectedValue);
-
- QDeclarativeComponent component(&engine, testFileUrl("testtypes.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- model->setProperty("xml",xml.toUtf8());
- QMetaObject::invokeMethod(model, "reload");
- QTRY_COMPARE(model->count(), 1);
-
- int role = -1;
- foreach (int i, model->roles()) {
- if (model->toString(i) == roleName) {
- role = i;
- break;
- }
- }
- QVERIFY(role >= 0);
-
- if (expectedValue.toString() == "nan")
- QVERIFY(qIsNaN(model->data(0, role).toDouble()));
- else
- QCOMPARE(model->data(0, role), expectedValue);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::testTypes_data()
-{
- QTest::addColumn<QString>("xml");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<QVariant>("expectedValue");
-
- QTest::newRow("missing string field") << "<data></data>"
- << "stringValue" << QVariant("");
- QTest::newRow("empty string") << "<data><a-string></a-string></data>"
- << "stringValue" << QVariant("");
- QTest::newRow("1-char string") << "<data><a-string>5</a-string></data>"
- << "stringValue" << QVariant("5");
- QTest::newRow("string ok") << "<data><a-string>abc def g</a-string></data>"
- << "stringValue" << QVariant("abc def g");
-
- QTest::newRow("missing number field") << "<data></data>"
- << "numberValue" << QVariant("");
- double nan = qQNaN();
- QTest::newRow("empty number field") << "<data><a-number></a-number></data>"
- << "numberValue" << QVariant(nan);
- QTest::newRow("number field with string") << "<data><a-number>a string</a-number></data>"
- << "numberValue" << QVariant(nan);
- QTest::newRow("-1") << "<data><a-number>-1</a-number></data>"
- << "numberValue" << QVariant("-1");
- QTest::newRow("-1.5") << "<data><a-number>-1.5</a-number></data>"
- << "numberValue" << QVariant("-1.5");
- QTest::newRow("0") << "<data><a-number>0</a-number></data>"
- << "numberValue" << QVariant("0");
- QTest::newRow("+1") << "<data><a-number>1</a-number></data>"
- << "numberValue" << QVariant("1");
- QTest::newRow("+1.5") << "<data><a-number>1.5</a-number></data>"
- << "numberValue" << QVariant("1.5");
-}
-
-void tst_qdeclarativexmllistmodel::cdata()
-{
- QDeclarativeComponent component(&engine, testFileUrl("recipes.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 5);
-
- QVERIFY(model->data(2, Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::attributes()
-{
- QDeclarativeComponent component(&engine, testFileUrl("recipes.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 5);
- QCOMPARE(model->data(2, Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roles()
-{
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QList<int> roles = model->roles();
- QCOMPARE(roles.count(), 4);
- QCOMPARE(model->toString(roles.at(0)), QLatin1String("name"));
- QCOMPARE(model->toString(roles.at(1)), QLatin1String("type"));
- QCOMPARE(model->toString(roles.at(2)), QLatin1String("age"));
- QCOMPARE(model->toString(roles.at(3)), QLatin1String("size"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roleErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("roleErrors.qml"));
- QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
- QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
-
- //### make sure we receive all expected warning messages.
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
-
- //### should any of these return valid values?
- QCOMPARE(model->data(3, Qt::UserRole), QVariant());
- QCOMPARE(model->data(3, Qt::UserRole+1), QVariant());
- QCOMPARE(model->data(3, Qt::UserRole+2), QVariant());
-
- QEXPECT_FAIL("", "QTBUG-10797", Continue);
- QCOMPARE(model->data(3, Qt::UserRole+3), QVariant());
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::uniqueRoleNames()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unique.qml"));
- QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QList<int> roles = model->roles();
- QCOMPARE(roles.count(), 1);
-
- delete model;
-}
-
-
-void tst_qdeclarativexmllistmodel::xml()
-{
- QFETCH(QString, xml);
- QFETCH(int, count);
-
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
-
- QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QTest::qWait(50);
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Ready);
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
- QCOMPARE(model->count(), 9);
-
- // if xml is empty (i.e. clearing) it won't have any effect if a source is set
- if (xml.isEmpty())
- model->setProperty("source",QUrl());
- model->setProperty("xml",xml);
- QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); // immediately goes to 1.0 if using setXml()
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- if (xml.isEmpty())
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Null);
- else
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Ready);
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->count(), count);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::xml_data()
-{
- QTest::addColumn<QString>("xml");
- QTest::addColumn<int>("count");
-
- QTest::newRow("xml with no items") << "<Pets></Pets>" << 0;
- QTest::newRow("empty xml") << "" << 0;
- QTest::newRow("one item") << "<Pets><Pet><name>Hobbes</name><type>Tiger</type><age>7</age><size>Large</size></Pet></Pets>" << 1;
-}
-
-void tst_qdeclarativexmllistmodel::headers()
-{
- // ensure the QNetworkAccessManagers created for this test are immediately deleted
- QDeclarativeEngine qmlEng;
-
- CustomNetworkAccessManagerFactory factory;
- qmlEng.setNetworkAccessManagerFactory(&factory);
-
- QDeclarativeComponent component(&qmlEng, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Ready);
-
- QVariantMap expectedHeaders;
- expectedHeaders["Accept"] = "application/xml,*/*";
-
- QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count());
- foreach (const QString &header, expectedHeaders.keys()) {
- QVERIFY(factory.lastSentHeaders.contains(header));
- QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString());
- }
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::source()
-{
- QFETCH(QUrl, source);
- QFETCH(int, count);
- QFETCH(QDeclarativeXmlListModel::Status, status);
-
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
-
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Ready);
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
- QCOMPARE(model->count(), 9);
-
- model->setProperty("source",source);
- if (model->property("source").toString().isEmpty())
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Null);
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Loading);
- QVERIFY(errorString(model).isEmpty());
-
- QEventLoop loop;
- QTimer timer;
- timer.setSingleShot(true);
- connect(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)), &loop, SLOT(quit()));
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- timer.start(20000);
- loop.exec();
-
- if (spy.count() == 0 && status != QDeclarativeXmlListModel::Ready) {
- qWarning("QDeclarativeXmlListModel invalid source test timed out");
- } else {
- QCOMPARE(spy.count(), 1); spy.clear();
- }
-
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")), status);
- QCOMPARE(model->count(), count);
-
- if (status == QDeclarativeXmlListModel::Ready)
- QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
-
- QCOMPARE(errorString(model).isEmpty(), status == QDeclarativeXmlListModel::Ready);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::source_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<int>("count");
- QTest::addColumn<QDeclarativeXmlListModel::Status>("status");
-
- QTest::newRow("valid") << testFileUrl("model2.xml") << 2
- << QDeclarativeXmlListModel::Ready;
- QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0
- << QDeclarativeXmlListModel::Error;
-
- // empty file
- QTemporaryFile *temp = new QTemporaryFile(this);
- if (temp->open())
- QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0
- << QDeclarativeXmlListModel::Ready;
- temp->close();
-}
-
-void tst_qdeclarativexmllistmodel::data()
-{
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
-
- for (int i=0; i<9; i++) {
- for (int j=0; j<model->roles().count(); j++) {
- QCOMPARE(model->data(i, j), QVariant());
- }
- }
- QTRY_COMPARE(model->count(), 9);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::get()
-{
- QDeclarativeComponent component(&engine, testFileUrl("get.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
-
- QVERIFY(model != 0);
-
- QVERIFY(QMetaObject::invokeMethod(model, "runPreTest"));
- QCOMPARE(model->property("preTest").toBool(), true);
-
- QTRY_COMPARE(model->count(), 9);
-
- QVERIFY(QMetaObject::invokeMethod(model, "runPostTest"));
- QCOMPARE(model->property("postTest").toBool(), true);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::reload()
-{
- // If no keys are used, the model should be rebuilt from scratch when
- // reload() is called.
-
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
- //reload multiple times to test the xml query aborting
- QMetaObject::invokeMethod(model, "reload");
- QMetaObject::invokeMethod(model, "reload");
- QCoreApplication::processEvents();
- QMetaObject::invokeMethod(model, "reload");
- QMetaObject::invokeMethod(model, "reload");
- QTRY_COMPARE(spyCount.count(), 1);
- QTRY_COMPARE(spyInsert.count(), 1);
- QTRY_COMPARE(spyRemove.count(), 1);
-
- QCOMPARE(spyInsert[0][0].toInt(), 0);
- QCOMPARE(spyInsert[0][1].toInt(), 9);
-
- QCOMPARE(spyRemove[0][0].toInt(), 0);
- QCOMPARE(spyRemove[0][1].toInt(), 9);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::useKeys()
-{
- // If using incremental updates through keys, the model should only
- // insert & remove some of the items, instead of throwing everything
- // away and causing the view to repaint the whole view.
-
- QFETCH(QString, oldXml);
- QFETCH(int, oldCount);
- QFETCH(QString, newXml);
- QFETCH(QDeclarativeXmlModelData, newData);
- QFETCH(QList<QDeclarativeXmlListRange>, insertRanges);
- QFETCH(QList<QDeclarativeXmlListRange>, removeRanges);
-
- QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
-
- model->setProperty("xml",oldXml);
- QTRY_COMPARE(model->count(), oldCount);
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- model->setProperty("xml",newXml);
-
- if (oldCount != newData.count()) {
- QTRY_COMPARE(model->count(), newData.count());
- QCOMPARE(spyCount.count(), 1);
- } else {
- QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0);
- QCOMPARE(spyCount.count(), 0);
- }
-
- QList<int> roles = model->roles();
- for (int i=0; i<model->count(); i++) {
- for (int j=0; j<roles.count(); j++)
- QCOMPARE(model->data(i, roles[j]), newData[i][j]);
- }
-
- QCOMPARE(spyInsert.count(), insertRanges.count());
- for (int i=0; i<spyInsert.count(); i++) {
- QCOMPARE(spyInsert[i][0].toInt(), insertRanges[i].first);
- QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].second);
- }
-
- QCOMPARE(spyRemove.count(), removeRanges.count());
- for (int i=0; i<spyRemove.count(); i++) {
- QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first);
- QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second);
- }
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::useKeys_data()
-{
- QTest::addColumn<QString>("oldXml");
- QTest::addColumn<int>("oldCount");
- QTest::addColumn<QString>("newXml");
- QTest::addColumn<QDeclarativeXmlModelData>("newData");
- QTest::addColumn<QList<QDeclarativeXmlListRange> >("insertRanges");
- QTest::addColumn<QList<QDeclarativeXmlListRange> >("removeRanges");
-
- QDeclarativeXmlModelData modelData;
-
- QTest::newRow("append 1")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("append multiple")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("insert in different spots")
- << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("insert in middle")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("remove first")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
- << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
-
- QTest::newRow("remove last")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
- << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1));
-
- QTest::newRow("remove from multiple spots")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1) << qMakePair(3,2));
-
- QTest::newRow("remove all")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
- << makeItemXmlAndData("", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 3));
-
- QTest::newRow("replace item")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
-
- QTest::newRow("add and remove simultaneously, in different spots")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4
- << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2));
-
- QTest::newRow("insert at start, remove at end i.e. rss feed")
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2));
-
- QTest::newRow("remove at start, insert at end")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2));
-
- QTest::newRow("all data has changed")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2));
-}
-
-void tst_qdeclarativexmllistmodel::noKeysValueChanges()
-{
- // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml.
- // If a 'sport' value is changed, the model should not be reloaded,
- // since 'sport' is not marked as a key.
-
- QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
-
- QString xml;
-
- xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
- model->setProperty("xml",xml);
- QTRY_COMPARE(model->count(), 2);
-
- model->setProperty("xml","");
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics");
- model->setProperty("xml",xml);
-
- // wait for the new xml data to be set, and verify no signals were emitted
- QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football"));
- QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules"));
-
- QVERIFY(spyInsert.count() == 0);
- QVERIFY(spyRemove.count() == 0);
- QVERIFY(spyCount.count() == 0);
-
- QCOMPARE(model->count(), 2);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::keysChanged()
-{
- // If the key roles change, the next time the data is reloaded, it should
- // delete all its data and build a clean model (i.e. same behaviour as
- // if no keys are set).
-
- QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
-
- QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
- model->setProperty("xml",xml);
- QTRY_COMPARE(model->count(), 2);
-
- model->setProperty("xml","");
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey"));
- model->setProperty("xml",xml);
-
- QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0);
-
- QCOMPARE(spyInsert.count(), 1);
- QCOMPARE(spyInsert[0][0].toInt(), 0);
- QCOMPARE(spyInsert[0][1].toInt(), 2);
-
- QCOMPARE(spyRemove.count(), 1);
- QCOMPARE(spyRemove[0][0].toInt(), 0);
- QCOMPARE(spyRemove[0][1].toInt(), 2);
-
- QCOMPARE(spyCount.count(), 0);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::threading()
-{
- QFETCH(int, xmlDataCount);
-
- QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
-
- QListModelInterface *m1 = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(m1 != 0);
- QListModelInterface *m2 = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(m2 != 0);
- QListModelInterface *m3 = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(m3 != 0);
-
- for (int dataCount=0; dataCount<xmlDataCount; dataCount++) {
-
- QString data1, data2, data3;
- for (int i=0; i<dataCount; i++) {
- data1 += "name=A" + QString::number(i) + ",age=1" + QString::number(i) + ",sport=Football;";
- data2 += "name=B" + QString::number(i) + ",age=2" + QString::number(i) + ",sport=Athletics;";
- data3 += "name=C" + QString::number(i) + ",age=3" + QString::number(i) + ",sport=Curling;";
- }
-
- //Set the xml data multiple times with randomized order and mixed with multiple event loops
- //to test the xml query reloading/aborting, the result should be stable.
- m1->setProperty("xml",makeItemXmlAndData(data1));
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m3->setProperty("xml",makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m1->setProperty("xml",makeItemXmlAndData(data1));
- m2->setProperty("xml",makeItemXmlAndData(data2));
- QCoreApplication::processEvents();
- m3->setProperty("xml",makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m1->setProperty("xml",makeItemXmlAndData(data1));
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m3->setProperty("xml",makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m3->setProperty("xml",makeItemXmlAndData(data3));
- m3->setProperty("xml",makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
-
- QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount);
-
- for (int i=0; i<dataCount; i++) {
- QCOMPARE(m1->data(i, m1->roles()[0]).toString(), QString("A" + QString::number(i)));
- QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i)));
- QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football"));
-
- QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i)));
- QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i)));
- QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics"));
-
- QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i)));
- QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i)));
- QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling"));
- }
- }
-
- delete m1;
- delete m2;
- delete m3;
-}
-
-void tst_qdeclarativexmllistmodel::threading_data()
-{
- QTest::addColumn<int>("xmlDataCount");
-
- QTest::newRow("1") << 1;
- QTest::newRow("2") << 2;
- QTest::newRow("10") << 10;
-}
-
-void tst_qdeclarativexmllistmodel::propertyChanges()
-{
- QDeclarativeComponent component(&engine, testFileUrl("propertychanges.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QObject *role = model->findChild<QObject*>("role");
- QVERIFY(role);
-
- QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
- QSignalSpy querySpy(role, SIGNAL(queryChanged()));
- QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
-
- role->setProperty("name","size");
- role->setProperty("query","size/string()");
- role->setProperty("isKey",true);
-
- QCOMPARE(role->property("name").toString(), QString("size"));
- QCOMPARE(role->property("query").toString(), QString("size/string()"));
- QVERIFY(role->property("isKey").toBool());
-
- QCOMPARE(nameSpy.count(),1);
- QCOMPARE(querySpy.count(),1);
- QCOMPARE(isKeySpy.count(),1);
-
- role->setProperty("name","size");
- role->setProperty("query","size/string()");
- role->setProperty("isKey",true);
-
- QCOMPARE(nameSpy.count(),1);
- QCOMPARE(querySpy.count(),1);
- QCOMPARE(isKeySpy.count(),1);
-
- QSignalSpy sourceSpy(model, SIGNAL(sourceChanged()));
- QSignalSpy xmlSpy(model, SIGNAL(xmlChanged()));
- QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
- QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
-
- model->setProperty("source",QUrl(""));
- model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
- model->setProperty("query","/Pets");
- model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
-
- QCOMPARE(model->property("source").toUrl(), QUrl(""));
- QCOMPARE(model->property("xml").toString(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
- QCOMPARE(model->property("query").toString(), QString("/Pets"));
- QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
-
- QTRY_VERIFY(model->count() == 1);
-
- QCOMPARE(sourceSpy.count(),1);
- QCOMPARE(xmlSpy.count(),1);
- QCOMPARE(modelQuerySpy.count(),1);
- QCOMPARE(namespaceDeclarationsSpy.count(),1);
-
- model->setProperty("source",QUrl(""));
- model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
- model->setProperty("query","/Pets");
- model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
-
- QCOMPARE(sourceSpy.count(),1);
- QCOMPARE(xmlSpy.count(),1);
- QCOMPARE(modelQuerySpy.count(),1);
- QCOMPARE(namespaceDeclarationsSpy.count(),1);
-
- QTRY_VERIFY(model->count() == 1);
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roleCrash()
-{
- // don't crash
- QDeclarativeComponent component(&engine, testFileUrl("roleCrash.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- delete model;
-}
-
-QTEST_MAIN(tst_qdeclarativexmllistmodel)
-
-#include "tst_qdeclarativexmllistmodel.moc"
diff --git a/tests/auto/qtquick2/qquickaccessible/data/hittest.qml b/tests/auto/qtquick2/qquickaccessible/data/hittest.qml
deleted file mode 100644
index 23d3b95157..0000000000
--- a/tests/auto/qtquick2/qquickaccessible/data/hittest.qml
+++ /dev/null
@@ -1,176 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-import QtQuick 2.0
-import "widgets"
-
-Rectangle {
- id: page
- width: 640
- height: 480
- color: "white"
- Rectangle {
- id: header
- color: "#c0c0c0"
- height: usage.height + chkClip.height
- anchors.left: parent.left
- anchors.right: parent.right
- Text {
- id: usage
- text: "Use an a11y inspect tool to see if all visible rectangles can be found with hit testing."
- }
- Rectangle {
- id: chkClip
- property bool checked: true
-
- color: (checked ? "#f0f0f0" : "#c0c0c0")
- height: label.height
- width: label.width
- anchors.left: parent.left
- anchors.bottom: parent.bottom
-
- MouseArea {
- anchors.fill: parent
- onClicked: chkClip.checked = !chkClip.checked
- }
- Text {
- id: label
- text: "Click here to toggle clipping"
- }
- }
- }
- TextRect {
- clip: chkClip.checked
- z: 2
- id: rect1
- text: "rect1"
- width: 100
- height: 100
- color: "#ffc0c0"
- anchors.top: header.bottom
- TextRect {
- id: rect10
- text: "rect10"
- width: 100
- height: 100
- x: 50
- y: 50
- color: "#ffa0a0"
- TextRect {
- id: rect100
- text: "rect100"
- width: 100
- height: 100
- x: 80
- y: 80
- color: "#ff8080"
- }
- TextRect {
- id: rect101
- text: "rect101"
- x: 100
- y: 70
- z: 3
- width: 100
- height: 100
- color: "#e06060"
- }
- TextRect {
- id: rect102
- text: "rect102"
- width: 100
- height: 100
- x: 150
- y: 60
- color: "#c04040"
- }
- }
- }
-
- TextRect {
- x: 0
- y: 50
- id: rect2
- text: "rect2"
- width: 100
- height: 100
- color: "#c0c0ff"
- TextRect {
- id: rect20
- text: "rect20"
- width: 100
- height: 100
- x: 50
- y: 50
- color: "#a0a0ff"
- TextRect {
- id: rect200
- text: "rect200"
- width: 100
- height: 100
- x: 80
- y: 80
- color: "#8080ff"
- }
- TextRect {
- id: rect201
- text: "rect201"
- x: 100
- y: 70
- z: 100
- width: 100
- height: 100
- color: "#6060e0"
- }
- TextRect {
- id: rect202
- text: "rect202"
- width: 100
- height: 100
- x: 150
- y: 60
- color: "#4040c0"
- }
- }
- }
-
-}
diff --git a/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro b/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro
deleted file mode 100644
index dc32316e28..0000000000
--- a/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-CONFIG += testcase
-
-TARGET = tst_qquickaccessible
-QT += declarative-private network quick-private testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickaccessible.cpp
-
-include (../../shared/util.pri)
-
-OTHER_FILES += data/checkbuttons.qml
-OTHER_FILES += data/hittest.qml
-OTHER_FILES += data/pushbutton.qml
-OTHER_FILES += data/statictext.qml
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-wince*: {
- accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll
- accessneeded.path = accessible
- DEPLOYMENT += accessneeded
-}
-
diff --git a/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp
deleted file mode 100644
index 2e1c2b883c..0000000000
--- a/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-#include "QtTest/qtestaccessible.h"
-
-#include <QtGui/qaccessible.h>
-
-#include <QtQuick/qquickview.h>
-#include <QtQuick/qquickitem.h>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtQuick/private/qquickaccessibleattached_p.h>
-
-#include "../../shared/util.h"
-
-
-typedef QSharedPointer<QAccessibleInterface> QAI;
-
-#define EXPECT(cond) \
- do { \
- if (!errorAt && !(cond)) { \
- errorAt = __LINE__; \
- qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(), #cond); \
- } \
- } while (0)
-
-static int verifyHierarchy(QAccessibleInterface *iface)
-{
- int errorAt = 0;
- static int treelevel = 0; // for error diagnostics
- QAccessibleInterface *middleChild, *if2;
- middleChild = 0;
- ++treelevel;
- int middle = iface->childCount()/2 + 1;
- if (iface->childCount() >= 2) {
- middleChild = iface->child(middle - 1);
- }
- for (int i = 0; i < iface->childCount() && !errorAt; ++i) {
- if2 = iface->child(i);
- EXPECT(if2 != 0);
- // navigate Ancestor...
- QAccessibleInterface *parent = if2->parent();
- EXPECT(iface->object() == parent->object());
- delete parent;
-
- // verify children...
- if (!errorAt)
- errorAt = verifyHierarchy(if2);
- delete if2;
- }
- delete middleChild;
-
- --treelevel;
- return errorAt;
-}
-
-
-//TESTED_FILES=
-
-class tst_QQuickAccessible : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickAccessible();
- virtual ~tst_QQuickAccessible();
-
-private slots:
- void commonTests_data();
- void commonTests();
-
- void declarativeAttachedProperties();
- void basicPropertiesTest();
- void hitTest();
- void checkableTest();
-};
-
-tst_QQuickAccessible::tst_QQuickAccessible()
-{
-
-}
-
-tst_QQuickAccessible::~tst_QQuickAccessible()
-{
-
-}
-
-void tst_QQuickAccessible::commonTests_data()
-{
- QTest::addColumn<QString>("accessibleRoleFileName");
-
- QTest::newRow("StaticText") << SRCDIR "/data/statictext.qml";
- QTest::newRow("PushButton") << SRCDIR "/data/pushbutton.qml";
-}
-
-void tst_QQuickAccessible::commonTests()
-{
- QFETCH(QString, accessibleRoleFileName);
-
- qDebug() << "testing" << accessibleRoleFileName;
-
- QQuickView *view = new QQuickView();
-// view->setFixedSize(240,320);
- view->setSource(QUrl::fromLocalFile(accessibleRoleFileName));
- view->show();
-// view->setFocus();
- QVERIFY(view->rootObject() != 0);
-
- QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(view);
- QVERIFY(iface);
-
- delete iface;
- delete view;
-}
-
-
-
-QString eventName(const int ev)
-{
- switch (ev) {
- case 0x0001: return "SoundPlayed";
- case 0x0002: return "Alert";
- case 0x0003: return "ForegroundChanged";
- case 0x0004: return "MenuStart";
- case 0x0005: return "MenuEnd";
- case 0x0006: return "PopupMenuStart";
- case 0x0007: return "PopupMenuEnd";
- case 0x000C: return "ContextHelpStart";
- case 0x000D: return "ContextHelpEnd";
- case 0x000E: return "DragDropStart";
- case 0x000F: return "DragDropEnd";
- case 0x0010: return "DialogStart";
- case 0x0011: return "DialogEnd";
- case 0x0012: return "ScrollingStart";
- case 0x0013: return "ScrollingEnd";
- case 0x0018: return "MenuCommand";
- case 0x8000: return "ObjectCreated";
- case 0x8001: return "ObjectDestroyed";
- case 0x8002: return "ObjectShow";
- case 0x8003: return "ObjectHide";
- case 0x8004: return "ObjectReorder";
- case 0x8005: return "Focus";
- case 0x8006: return "Selection";
- case 0x8007: return "SelectionAdd";
- case 0x8008: return "SelectionRemove";
- case 0x8009: return "SelectionWithin";
- case 0x800A: return "StateChanged";
- case 0x800B: return "LocationChanged";
- case 0x800C: return "NameChanged";
- case 0x800D: return "DescriptionChanged";
- case 0x800E: return "ValueChanged";
- case 0x800F: return "ParentChanged";
- case 0x80A0: return "HelpChanged";
- case 0x80B0: return "DefaultActionChanged";
- case 0x80C0: return "AcceleratorChanged";
- default: return "Unknown Event";
- }
-}
-
-void tst_QQuickAccessible::declarativeAttachedProperties()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem {\n"
- "}", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
- QCOMPARE(attachedObject, static_cast<QObject*>(0));
- delete object;
- }
-
- // Attached property
- {
- QObject parent;
- QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent);
-
- attachedObj->name();
-
- QVariant pp = attachedObj->property("name");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem {\n"
- "Accessible.role: Accessible.Button\n"
- "}", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
- QVERIFY(attachedObject);
- if (attachedObject) {
- QVariant p = attachedObject->property("role");
- QCOMPARE(p.isNull(), false);
- QCOMPARE(p.toInt(), int(QAccessible::PushButton));
- p = attachedObject->property("name");
- QCOMPARE(p.isNull(), true);
- p = attachedObject->property("description");
- QCOMPARE(p.isNull(), true);
- }
- delete object;
- }
-
- // Attached property
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem {\n"
- "Accessible.role: Accessible.Button\n"
- "Accessible.name: \"Donald\"\n"
- "Accessible.description: \"Duck\"\n"
- "}", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
- QVERIFY(attachedObject);
- if (attachedObject) {
- QVariant p = attachedObject->property("role");
- QCOMPARE(p.isNull(), false);
- QCOMPARE(p.toInt(), int(QAccessible::PushButton));
- p = attachedObject->property("name");
- QCOMPARE(p.isNull(), false);
- QCOMPARE(p.toString(), QLatin1String("Donald"));
- p = attachedObject->property("description");
- QCOMPARE(p.isNull(), false);
- QCOMPARE(p.toString(), QLatin1String("Duck"));
- }
- delete object;
- }
-}
-
-
-void tst_QQuickAccessible::basicPropertiesTest()
-{
- QAI app = QAI(QAccessible::queryAccessibleInterface(qApp));
- QCOMPARE(app->childCount(), 0);
-
- QQuickView *canvas = new QQuickView();
- canvas->setSource(testFileUrl("statictext.qml"));
- canvas->show();
- QCOMPARE(app->childCount(), 1);
-
- QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
- QVERIFY(iface.data());
- QCOMPARE(iface->childCount(), 1);
-
- QAI item = QAI(iface->child(0));
- QVERIFY(item.data());
- QCOMPARE(item->childCount(), 2);
- QCOMPARE(item->rect().size(), QSize(400, 400));
- QCOMPARE(item->role(), QAccessible::Pane);
- QCOMPARE(iface->indexOfChild(item.data()), 0);
-
- QAI text = QAI(item->child(0));
- QVERIFY(text.data());
- QCOMPARE(text->childCount(), 0);
-
- QCOMPARE(text->text(QAccessible::Name), QLatin1String("Hello Accessibility"));
- QCOMPARE(text->rect().size(), QSize(200, 50));
- QCOMPARE(text->rect().x(), item->rect().x() + 100);
- QCOMPARE(text->rect().y(), item->rect().y() + 20);
- QCOMPARE(text->role(), QAccessible::StaticText);
- QCOMPARE(item->indexOfChild(text.data()), 0);
-
- QAI text2 = QAI(item->child(1));
- QVERIFY(text2.data());
- QCOMPARE(text2->childCount(), 0);
-
- QCOMPARE(text2->text(QAccessible::Name), QLatin1String("The Hello 2 accessible text"));
- QCOMPARE(text2->rect().size(), QSize(100, 40));
- QCOMPARE(text2->rect().x(), item->rect().x() + 100);
- QCOMPARE(text2->rect().y(), item->rect().y() + 40);
- QCOMPARE(text2->role(), QAccessible::StaticText);
- QCOMPARE(item->indexOfChild(text2.data()), 1);
-
- QCOMPARE(iface->indexOfChild(text2.data()), -1);
- QCOMPARE(text2->indexOfChild(item.data()), -1);
-
- delete canvas;
-}
-
-QAI topLevelChildAt(QAccessibleInterface *iface, int x, int y)
-{
- QAI child = QAI(iface->childAt(x, y));
- if (!child)
- return QAI();
-
- QAI childOfChild;
- while (childOfChild = QAI(child->childAt(x, y))) {
- child = childOfChild;
- }
- return child;
-}
-
-void tst_QQuickAccessible::hitTest()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("hittest.qml"));
- canvas->show();
-
- QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
- QVERIFY(iface.data());
- QAI rootItem = QAI(iface->child(0));
- QRect rootRect = rootItem->rect();
-
- // hit the root item
- QAI itemHit(iface->childAt(rootRect.x() + 200, rootRect.y() + 50));
- QVERIFY(itemHit);
- QCOMPARE(rootRect, itemHit->rect());
-
- // hit rect1
- QAI rect1(rootItem->child(1));
- QRect rect1Rect = rect1->rect();
- itemHit = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10));
- QVERIFY(itemHit);
- QCOMPARE(rect1Rect, itemHit->rect());
- QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect1"));
-
- // should also work from top level (app)
- QAI app(QAccessible::queryAccessibleInterface(qApp));
- QAI itemHit2(topLevelChildAt(app.data(), rect1Rect.x() + 10, rect1Rect.y() + 10));
- QVERIFY(itemHit2);
- QCOMPARE(itemHit2->rect(), rect1Rect);
- QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
-
- // hit rect201
- QAI rect2(rootItem->child(2));
- QAI rect20(rect2->child(1));
- QAI rect201(rect20->child(2));
- QVERIFY(rect201);
-
- QRect rect201Rect = rect201->rect();
- itemHit = QAI(iface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20));
- QVERIFY(itemHit);
- QCOMPARE(itemHit->rect(), rect201Rect);
- QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect201"));
-
- delete canvas;
-}
-
-void tst_QQuickAccessible::checkableTest()
-{
- QQuickView *canvas = new QQuickView();
- canvas->setSource(testFileUrl("checkbuttons.qml"));
- canvas->show();
-
- QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
- QVERIFY(iface.data());
- QAI root = QAI(iface->child(0));
-
- QAI button1 = QAI(root->child(0));
- QCOMPARE(button1->role(), QAccessible::Button);
- QVERIFY(!(button1->state().checked));
- QAI button2 = QAI(root->child(1));
- QVERIFY(!(button2->state().checked));
- QAI button3 = QAI(root->child(2));
- QVERIFY(button3->state().checked);
-
- QAI checkBox1 = QAI(root->child(3));
- QCOMPARE(checkBox1->role(), QAccessible::CheckBox);
- QVERIFY((checkBox1->state().checked));
- QAI checkBox2 = QAI(root->child(4));
- QVERIFY(!(checkBox2->state().checked));
-}
-
-QTEST_MAIN(tst_QQuickAccessible)
-
-#include "tst_qquickaccessible.moc"
diff --git a/tests/auto/qtquick2/qquickanchors/qquickanchors.pro b/tests/auto/qtquick2/qquickanchors/qquickanchors.pro
deleted file mode 100644
index bd94f9cceb..0000000000
--- a/tests/auto/qtquick2/qquickanchors/qquickanchors.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = tst_qquickanchors
-CONFIG += testcase
-SOURCES += tst_qquickanchors.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private v8-private testlib
diff --git a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp
deleted file mode 100644
index af43686e27..0000000000
--- a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp
+++ /dev/null
@@ -1,710 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <private/qquickitem_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickanchors_p_p.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-
-Q_DECLARE_METATYPE(QQuickAnchors::Anchor)
-Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine)
-
-using namespace QQuickVisualTestUtil;
-
-class tst_qquickanchors : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickanchors() {}
-
-private slots:
- void basicAnchors();
- void basicAnchorsRTL();
- void loops();
- void illegalSets();
- void illegalSets_data();
- void reset();
- void reset_data();
- void resetConvenience();
- void nullItem();
- void nullItem_data();
- void crash1();
- void centerIn();
- void centerInRTL();
- void centerInRotation();
- void hvCenter();
- void hvCenterRTL();
- void fill();
- void fillRTL();
- void margins();
- void marginsRTL();
- void stretch();
-};
-
-void tst_qquickanchors::basicAnchors()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("anchors.qml"));
-
- qApp->processEvents();
-
- //sibling horizontal
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
-
- //parent horizontal
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
-
- //vertical
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
-
- //stretch
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
-
- //vertical stretch
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
-
- //more parent horizontal
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
-
- //centerIn
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
-
- //margins
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
-
- // offsets
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
-
- //baseline
- QQuickText *text1 = findItem<QQuickText>(view->rootObject(), QLatin1String("text1"));
- QQuickText *text2 = findItem<QQuickText>(view->rootObject(), QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-QQuickItem* childItem(QQuickItem *parentItem, const char * itemString) {
- return findItem<QQuickItem>(parentItem, QLatin1String(itemString));
-}
-
-qreal offsetMasterRTL(QQuickItem *rootItem, const char * itemString) {
- QQuickItem* masterItem = findItem<QQuickItem>(rootItem, QLatin1String("masterRect"));
- return masterItem->width()+2*masterItem->x()-findItem<QQuickItem>(rootItem, QLatin1String(itemString))->width();
-}
-
-qreal offsetParentRTL(QQuickItem *rootItem, const char * itemString) {
- return rootItem->width()+2*rootItem->x()-findItem<QQuickItem>(rootItem, QLatin1String(itemString))->width();
-}
-
-void mirrorAnchors(QQuickItem *item) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->setLayoutMirror(true);
-}
-
-void tst_qquickanchors::basicAnchorsRTL()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("anchors.qml"));
-
- qApp->processEvents();
-
- QQuickItem* rootItem = qobject_cast<QQuickItem*>(view->rootObject());
- foreach (QObject *child, rootItem->children()) {
- bool mirrored = QQuickItemPrivate::get(qobject_cast<QQuickItem*>(child))->anchors()->property("mirrored").toBool();
- QCOMPARE(mirrored, false);
- }
-
- foreach (QObject *child, rootItem->children())
- mirrorAnchors(qobject_cast<QQuickItem*>(child));
-
- foreach (QObject *child, rootItem->children()) {
- bool mirrored = QQuickItemPrivate::get(qobject_cast<QQuickItem*>(child))->anchors()->property("mirrored").toBool();
- QCOMPARE(mirrored, true);
- }
-
- //sibling horizontal
- QCOMPARE(childItem(rootItem, "rect1")->x(), offsetMasterRTL(rootItem, "rect1")-26.0);
- QCOMPARE(childItem(rootItem, "rect2")->x(), offsetMasterRTL(rootItem, "rect2")-122.0);
- QCOMPARE(childItem(rootItem, "rect3")->x(), offsetMasterRTL(rootItem, "rect3")-74.0);
- QCOMPARE(childItem(rootItem, "rect4")->x(), offsetMasterRTL(rootItem, "rect4")-16.0);
- QCOMPARE(childItem(rootItem, "rect5")->x(), offsetMasterRTL(rootItem, "rect5")-112.0);
- QCOMPARE(childItem(rootItem, "rect6")->x(), offsetMasterRTL(rootItem, "rect6")-64.0);
-
- //parent horizontal
- QCOMPARE(childItem(rootItem, "rect7")->x(), offsetParentRTL(rootItem, "rect7")-0.0);
- QCOMPARE(childItem(rootItem, "rect8")->x(), offsetParentRTL(rootItem, "rect8")-240.0);
- QCOMPARE(childItem(rootItem, "rect9")->x(), offsetParentRTL(rootItem, "rect9")-120.0);
- QCOMPARE(childItem(rootItem, "rect10")->x(), offsetParentRTL(rootItem, "rect10")+10.0);
- QCOMPARE(childItem(rootItem, "rect11")->x(), offsetParentRTL(rootItem, "rect11")-230.0);
- QCOMPARE(childItem(rootItem, "rect12")->x(), offsetParentRTL(rootItem, "rect12")-110.0);
-
- //vertical
- QCOMPARE(childItem(rootItem, "rect13")->y(), 20.0);
- QCOMPARE(childItem(rootItem, "rect14")->y(), 155.0);
-
- //stretch
- QCOMPARE(childItem(rootItem, "rect15")->x(), offsetMasterRTL(rootItem, "rect15")-26.0);
- QCOMPARE(childItem(rootItem, "rect15")->width(), 96.0);
- QCOMPARE(childItem(rootItem, "rect16")->x(), offsetMasterRTL(rootItem, "rect16")-26.0);
- QCOMPARE(childItem(rootItem, "rect16")->width(), 192.0);
- QCOMPARE(childItem(rootItem, "rect17")->x(), offsetMasterRTL(rootItem, "rect17")+70.0);
- QCOMPARE(childItem(rootItem, "rect17")->width(), 192.0);
-
- //vertical stretch
- QCOMPARE(childItem(rootItem, "rect18")->y(), 20.0);
- QCOMPARE(childItem(rootItem, "rect18")->height(), 40.0);
-
- //more parent horizontal
- QCOMPARE(childItem(rootItem, "rect19")->x(), offsetParentRTL(rootItem, "rect19")-115.0);
- QCOMPARE(childItem(rootItem, "rect20")->x(), offsetParentRTL(rootItem, "rect20")-235.0);
- QCOMPARE(childItem(rootItem, "rect21")->x(), offsetParentRTL(rootItem, "rect21")+5.0);
-
- //centerIn
- QCOMPARE(childItem(rootItem, "rect22")->x(), offsetMasterRTL(rootItem, "rect22")-69.0);
- QCOMPARE(childItem(rootItem, "rect22")->y(), 5.0);
-
- //margins
- QCOMPARE(childItem(rootItem, "rect23")->x(), offsetMasterRTL(rootItem, "rect23")-31.0);
- QCOMPARE(childItem(rootItem, "rect23")->y(), 5.0);
- QCOMPARE(childItem(rootItem, "rect23")->width(), 86.0);
- QCOMPARE(childItem(rootItem, "rect23")->height(), 10.0);
-
- // offsets
- QCOMPARE(childItem(rootItem, "rect24")->x(), offsetMasterRTL(rootItem, "rect24")-26.0);
- QCOMPARE(childItem(rootItem, "rect25")->y(), 60.0);
- QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0);
-
- //baseline
- QQuickText *text1 = findItem<QQuickText>(rootItem, QLatin1String("text1"));
- QQuickText *text2 = findItem<QQuickText>(rootItem, QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-// mostly testing that we don't crash
-void tst_qquickanchors::loops()
-{
- {
- QUrl source(testFileUrl("loop1.qml"));
-
- QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QQuickView *view = new QQuickView;
- view->setSource(source);
- qApp->processEvents();
-
- delete view;
- }
-
- {
- QUrl source(testFileUrl("loop2.qml"));
-
- QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QQuickView *view = new QQuickView;
- view->setSource(source);
- qApp->processEvents();
-
- delete view;
- }
-}
-
-void tst_qquickanchors::illegalSets()
-{
- QFETCH(QString, qml);
- QFETCH(QString, warning);
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
- if (!component.isReady())
- qWarning() << "Test errors:" << component.errors();
- QVERIFY(component.isReady());
- QObject *o = component.create();
- delete o;
-}
-
-void tst_qquickanchors::illegalSets_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("warning");
-
- QTest::newRow("H - too many anchors")
- << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }"
- << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors.";
-
- foreach (const QString &side, QStringList() << "left" << "right") {
- QTest::newRow("H - anchor to V")
- << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side)
- << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge.";
-
- QTest::newRow("H - anchor to non parent/sibling")
- << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
- QTest::newRow("H - anchor to self")
- << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
- << "file::2:1: QML Rectangle: Cannot anchor item to self.";
- }
-
-
- QTest::newRow("V - too many anchors")
- << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }"
- << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors.";
-
- QTest::newRow("V - too many anchors with baseline")
- << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }"
- << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.";
-
- foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") {
-
- QTest::newRow("V - anchor to H")
- << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side)
- << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge.";
-
- QTest::newRow("V - anchor to non parent/sibling")
- << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
- QTest::newRow("V - anchor to self")
- << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
- << "file::2:1: QML Rectangle: Cannot anchor item to self.";
- }
-
-
- QTest::newRow("centerIn - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
-
- QTest::newRow("fill - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }"
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-}
-
-void tst_qquickanchors::reset()
-{
- QFETCH(QString, side);
- QFETCH(QQuickAnchorLine::AnchorLine, anchorLine);
- QFETCH(QQuickAnchors::Anchor, usedAnchor);
-
- QQuickItem *baseItem = new QQuickItem;
-
- QQuickAnchorLine anchor;
- anchor.item = baseItem;
- anchor.anchorLine = anchorLine;
-
- QQuickItem *item = new QQuickItem;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
-
- const QMetaObject *meta = itemPrivate->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
- QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true);
-
- QVERIFY(p.reset(itemPrivate->anchors()));
- QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false);
-
- delete item;
- delete baseItem;
-}
-
-void tst_qquickanchors::reset_data()
-{
- QTest::addColumn<QString>("side");
- QTest::addColumn<QQuickAnchorLine::AnchorLine>("anchorLine");
- QTest::addColumn<QQuickAnchors::Anchor>("usedAnchor");
-
- QTest::newRow("left") << "left" << QQuickAnchorLine::Left << QQuickAnchors::LeftAnchor;
- QTest::newRow("top") << "top" << QQuickAnchorLine::Top << QQuickAnchors::TopAnchor;
- QTest::newRow("right") << "right" << QQuickAnchorLine::Right << QQuickAnchors::RightAnchor;
- QTest::newRow("bottom") << "bottom" << QQuickAnchorLine::Bottom << QQuickAnchors::BottomAnchor;
-
- QTest::newRow("hcenter") << "horizontalCenter" << QQuickAnchorLine::HCenter << QQuickAnchors::HCenterAnchor;
- QTest::newRow("vcenter") << "verticalCenter" << QQuickAnchorLine::VCenter << QQuickAnchors::VCenterAnchor;
- QTest::newRow("baseline") << "baseline" << QQuickAnchorLine::Baseline << QQuickAnchors::BaselineAnchor;
-}
-
-void tst_qquickanchors::resetConvenience()
-{
- QQuickItem *baseItem = new QQuickItem;
- QQuickItem *item = new QQuickItem;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
-
- //fill
- itemPrivate->anchors()->setFill(baseItem);
- QVERIFY(itemPrivate->anchors()->fill() == baseItem);
- itemPrivate->anchors()->resetFill();
- QVERIFY(itemPrivate->anchors()->fill() == 0);
-
- //centerIn
- itemPrivate->anchors()->setCenterIn(baseItem);
- QVERIFY(itemPrivate->anchors()->centerIn() == baseItem);
- itemPrivate->anchors()->resetCenterIn();
- QVERIFY(itemPrivate->anchors()->centerIn() == 0);
-
- delete item;
- delete baseItem;
-}
-
-void tst_qquickanchors::nullItem()
-{
- QFETCH(QString, side);
-
- QQuickAnchorLine anchor;
- QQuickItem *item = new QQuickItem;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
-
- const QMetaObject *meta = itemPrivate->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML Item: Cannot anchor to a null item.");
- QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
-
- delete item;
-}
-
-void tst_qquickanchors::nullItem_data()
-{
- QTest::addColumn<QString>("side");
-
- QTest::newRow("left") << "left";
- QTest::newRow("top") << "top";
- QTest::newRow("right") << "right";
- QTest::newRow("bottom") << "bottom";
-
- QTest::newRow("hcenter") << "horizontalCenter";
- QTest::newRow("vcenter") << "verticalCenter";
- QTest::newRow("baseline") << "baseline";
-}
-
-//QTBUG-5428
-void tst_qquickanchors::crash1()
-{
- QUrl source(testFileUrl("crash1.qml"));
-
- QQuickView *view = new QQuickView(source);
- qApp->processEvents();
-
- delete view;
-}
-
-void tst_qquickanchors::fill()
-{
- QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rectPrivate->anchors()->leftMargin(), 10.0);
- QCOMPARE(rectPrivate->anchors()->topMargin(), 30.0);
- QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0);
- QCOMPARE(rectPrivate->anchors()->bottomMargin(), 40.0);
- QCOMPARE(rect->x(), 0.0 + 10.0);
- QCOMPARE(rect->y(), 0.0 + 30.0);
- QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setLeftMargin(20.0);
- rectPrivate->anchors()->setRightMargin(0.0);
- rectPrivate->anchors()->setBottomMargin(0.0);
- rectPrivate->anchors()->setTopMargin(10.0);
- QCOMPARE(rectPrivate->anchors()->leftMargin(), 20.0);
- QCOMPARE(rectPrivate->anchors()->topMargin(), 10.0);
- QCOMPARE(rectPrivate->anchors()->rightMargin(), 0.0);
- QCOMPARE(rectPrivate->anchors()->bottomMargin(), 0.0);
- QCOMPARE(rect->x(), 0.0 + 20.0);
- QCOMPARE(rect->y(), 0.0 + 10.0);
- QCOMPARE(rect->width(), 200.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 10.0);
-
- delete view;
-}
-
-void tst_qquickanchors::fillRTL()
-{
- QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 0.0 + 20.0);
- QCOMPARE(rect->y(), 0.0 + 30.0);
- QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setLeftMargin(20.0);
- rectPrivate->anchors()->setRightMargin(0.0);
- rectPrivate->anchors()->setBottomMargin(0.0);
- rectPrivate->anchors()->setTopMargin(10.0);
- QCOMPARE(rect->x(), 0.0 + 0.0);
- QCOMPARE(rect->y(), 0.0 + 10.0);
- QCOMPARE(rect->width(), 200.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 10.0);
-
- delete view;
-}
-
-void tst_qquickanchors::centerIn()
-{
- QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), 10.0);
- QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), 30.0);
- QCOMPARE(rect->x(), 75.0 + 10);
- QCOMPARE(rect->y(), 75.0 + 30);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
- rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
- QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), -20.0);
- QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), -10.0);
- QCOMPARE(rect->x(), 75.0 - 20.0);
- QCOMPARE(rect->y(), 75.0 - 10.0);
-
- //QTBUG-21730 (use actual center to prevent animation jitter)
- QQuickRectangle* rect2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered2"));
- QCOMPARE(rect2->x(), 94.5);
- QCOMPARE(rect2->y(), 94.5);
-
- delete view;
-}
-
-void tst_qquickanchors::centerInRTL()
-{
- QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 75.0 - 10);
- QCOMPARE(rect->y(), 75.0 + 30);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
- rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
- QCOMPARE(rect->x(), 75.0 + 20.0);
- QCOMPARE(rect->y(), 75.0 - 10.0);
-
- delete view;
-}
-
-//QTBUG-12441
-void tst_qquickanchors::centerInRotation()
-{
- QQuickView *view = new QQuickView(testFileUrl("centerinRotation.qml"));
-
- qApp->processEvents();
- QQuickRectangle* outer = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("outer"));
- QQuickRectangle* inner = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("inner"));
-
- QCOMPARE(outer->x(), qreal(49.5));
- QCOMPARE(outer->y(), qreal(49.5));
- QCOMPARE(inner->x(), qreal(25.5));
- QCOMPARE(inner->y(), qreal(25.5));
-
- delete view;
-}
-
-void tst_qquickanchors::hvCenter()
-{
- QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- // test QTBUG-10999
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 19.0);
-
- rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
- rectPrivate->anchors()->setVerticalCenterOffset(5.0);
- QCOMPARE(rect->x(), 10.0 - 5.0);
- QCOMPARE(rect->y(), 19.0 + 5.0);
-
- delete view;
-}
-
-void tst_qquickanchors::hvCenterRTL()
-{
- QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- // test QTBUG-10999
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 19.0);
-
- rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
- rectPrivate->anchors()->setVerticalCenterOffset(5.0);
- QCOMPARE(rect->x(), 10.0 + 5.0);
- QCOMPARE(rect->y(), 19.0 + 5.0);
-
- delete view;
-}
-void tst_qquickanchors::margins()
-{
- QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rectPrivate->anchors()->margins(), 10.0);
- QCOMPARE(rectPrivate->anchors()->topMargin(), 6.0);
- QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0);
- QCOMPARE(rectPrivate->anchors()->bottomMargin(), 10.0);
- QCOMPARE(rectPrivate->anchors()->rightMargin(), 10.0);
- QCOMPARE(rect->x(), 5.0);
- QCOMPARE(rect->y(), 6.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
- QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
-
- rectPrivate->anchors()->setTopMargin(0.0);
- rectPrivate->anchors()->setMargins(20.0);
-
- QCOMPARE(rectPrivate->anchors()->margins(), 20.0);
- QEXPECT_FAIL("","QTBUG-24515", Continue);
- QCOMPARE(rectPrivate->anchors()->topMargin(), 0.0);
- QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0);
- QCOMPARE(rectPrivate->anchors()->bottomMargin(), 20.0);
- QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0);
- QCOMPARE(rect->x(), 5.0);
- QCOMPARE(rect->y(), 20.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
-
- delete view;
-}
-
-void tst_qquickanchors::marginsRTL()
-{
- QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
-
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 6.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
- QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
-
- rectPrivate->anchors()->setTopMargin(0.0);
- rectPrivate->anchors()->setMargins(20.0);
-
- QCOMPARE(rect->x(), 20.0);
- QCOMPARE(rect->y(), 20.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
-
- delete view;
-}
-
-void tst_qquickanchors::stretch()
-{
- QQuickView *view = new QQuickView(testFileUrl("stretch.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("stretcher"));
- QCOMPARE(rect->x(), 160.0);
- QCOMPARE(rect->y(), 130.0);
- QCOMPARE(rect->width(), 40.0);
- QCOMPARE(rect->height(), 100.0);
-
- QQuickRectangle* rect2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("stretcher2"));
- QCOMPARE(rect2->y(), 130.0);
- QCOMPARE(rect2->height(), 100.0);
-
- delete view;
-}
-
-QTEST_MAIN(tst_qquickanchors)
-
-#include "tst_qquickanchors.moc"
diff --git a/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro b/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro
deleted file mode 100644
index d776a73b21..0000000000
--- a/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickanimatedimage
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickanimatedimage.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp
deleted file mode 100644
index c124e4f62b..0000000000
--- a/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp
+++ /dev/null
@@ -1,374 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qquickimage_p.h>
-#include <private/qquickanimatedimage_p.h>
-#include <QSignalSpy>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-#include "../../shared/testhttpserver.h"
-#include "../../shared/util.h"
-
-Q_DECLARE_METATYPE(QQuickImageBase::Status)
-
-class tst_qquickanimatedimage : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickanimatedimage() {}
-
-private slots:
- void play();
- void pause();
- void stopped();
- void setFrame();
- void frameCount();
- void mirror_running();
- void mirror_notRunning();
- void mirror_notRunning_data();
- void remote();
- void remote_data();
- void sourceSize();
- void sourceSizeReadOnly();
- void invalidSource();
- void qtbug_16520();
- void progressAndStatusChanges();
-
-};
-
-void tst_qquickanimatedimage::play()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickman.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::pause()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QVERIFY(anim->isPaused());
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::stopped()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanstopped.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(!anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 0);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::setFrame()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 2);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::frameCount()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("colors.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->frameCount(), 3);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::mirror_running()
-{
- // test where mirror is set to true after animation has started
-
- QQuickView canvas;
- canvas.show();
-
- canvas.setSource(testFileUrl("hearts.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas.rootObject());
- QVERIFY(anim);
-
- int width = anim->property("width").toInt();
-
- QCOMPARE(anim->currentFrame(), 0);
- QPixmap frame0 = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- anim->setCurrentFrame(1);
- QPixmap frame1 = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- anim->setCurrentFrame(0);
-
- QSignalSpy spy(anim, SIGNAL(frameChanged()));
- anim->setPlaying(true);
-
- QTRY_VERIFY(spy.count() == 1); spy.clear();
- anim->setProperty("mirror", true);
-
- QCOMPARE(anim->currentFrame(), 1);
- QPixmap frame1_flipped = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- QTRY_VERIFY(spy.count() == 1); spy.clear();
- QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first
- QPixmap frame0_flipped = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
-
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- QPixmap frame0_expected = frame0.transformed(transform);
- QPixmap frame1_expected = frame1.transformed(transform);
-
- QCOMPARE(frame0_flipped, frame0_expected);
- QCOMPARE(frame1_flipped, frame1_expected);
-}
-
-void tst_qquickanimatedimage::mirror_notRunning()
-{
- QFETCH(QUrl, fileUrl);
-
- QQuickView canvas;
- canvas.show();
-
- canvas.setSource(fileUrl);
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas.rootObject());
- QVERIFY(anim);
-
- int width = anim->property("width").toInt();
- QPixmap screenshot = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- QPixmap expected = screenshot.transformed(transform);
-
- int frame = anim->currentFrame();
- bool playing = anim->isPlaying();
- bool paused = anim->isPlaying();
-
- anim->setProperty("mirror", true);
- screenshot = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
- QCOMPARE(screenshot, expected);
-
- // mirroring should not change the current frame or playing status
- QCOMPARE(anim->currentFrame(), frame);
- QCOMPARE(anim->isPlaying(), playing);
- QCOMPARE(anim->isPaused(), paused);
-}
-
-void tst_qquickanimatedimage::mirror_notRunning_data()
-{
- QTest::addColumn<QUrl>("fileUrl");
-
- QTest::newRow("paused") << testFileUrl("stickmanpause.qml");
- QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml");
-}
-
-void tst_qquickanimatedimage::remote()
-{
- QFETCH(QString, fileName);
- QFETCH(bool, paused);
-
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
- QTRY_VERIFY(component.isReady());
-
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QTRY_VERIFY(anim->isPlaying());
- if (paused) {
- QTRY_VERIFY(anim->isPaused());
- QCOMPARE(anim->currentFrame(), 2);
- }
- QVERIFY(anim->status() != QQuickAnimatedImage::Error);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::sourceSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanscaled.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QCOMPARE(anim->width(),240.0);
- QCOMPARE(anim->height(),180.0);
- QCOMPARE(anim->sourceSize(),QSize(160,120));
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::sourceSizeReadOnly()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanerror1.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property"));
-}
-
-void tst_qquickanimatedimage::remote_data()
-{
- QTest::addColumn<QString>("fileName");
- QTest::addColumn<bool>("paused");
-
- QTest::newRow("playing") << "stickman.qml" << false;
- QTest::newRow("paused") << "stickmanpause.qml" << true;
-}
-
-void tst_qquickanimatedimage::invalidSource()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
-
- QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif");
-
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QVERIFY(!anim->isPlaying());
- QVERIFY(!anim->isPaused());
- QCOMPARE(anim->currentFrame(), 0);
- QCOMPARE(anim->frameCount(), 0);
- QTRY_VERIFY(anim->status() == 3);
-}
-
-void tst_qquickanimatedimage::qtbug_16520()
-{
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("qtbug-16520.qml"));
- QTRY_VERIFY(component.isReady());
-
- QQuickRectangle *root = qobject_cast<QQuickRectangle *>(component.create());
- QVERIFY(root);
- QQuickAnimatedImage *anim = root->findChild<QQuickAnimatedImage*>("anim");
-
- anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif");
-
- QTRY_VERIFY(anim->opacity() == 0);
- QTRY_VERIFY(anim->opacity() == 1);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::progressAndStatusChanges()
-{
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
-
- qRegisterMetaType<QQuickImageBase::Status>();
- QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
- QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
- QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
-
- // Loading local file
- ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 1);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 0);
-
- // Loading remote file
- ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif");
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_VERIFY(progressSpy.count() > 1);
- QTRY_COMPARE(statusSpy.count(), 2);
-
- ctxt->setContextProperty("srcImage", "");
- QTRY_VERIFY(obj->status() == QQuickImage::Null);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_COMPARE(sourceSpy.count(), 3);
- QTRY_VERIFY(progressSpy.count() > 2);
- QTRY_COMPARE(statusSpy.count(), 3);
-}
-
-QTEST_MAIN(tst_qquickanimatedimage)
-
-#include "tst_qquickanimatedimage.moc"
diff --git a/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro b/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro
deleted file mode 100644
index aad73d538d..0000000000
--- a/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickanimatedsprite
-SOURCES += tst_qquickanimatedsprite.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
deleted file mode 100644
index 3cc8f129fd..0000000000
--- a/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include "../../shared/util.h"
-#include <QtQuick/qquickview.h>
-#include <private/qquickanimatedsprite_p.h>
-
-class tst_qquickanimatedsprite : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickanimatedsprite(){}
-
-private slots:
- void test_properties();
-};
-
-void tst_qquickanimatedsprite::test_properties()
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(testFileUrl("basic.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QVERIFY(canvas->rootObject());
- QQuickAnimatedSprite* sprite = canvas->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
- QVERIFY(sprite);
-
- QVERIFY(sprite->running());
- QVERIFY(!sprite->paused());
- QVERIFY(sprite->interpolate());
- QCOMPARE(sprite->loops(), 3);
-
- sprite->setRunning(false);
- QVERIFY(!sprite->running());
- sprite->setInterpolate(false);
- QVERIFY(!sprite->interpolate());
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickanimatedsprite)
-
-#include "tst_qquickanimatedsprite.moc"
diff --git a/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro b/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro
deleted file mode 100644
index 2073b4492f..0000000000
--- a/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickborderimage
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickborderimage.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network widgets testlib
diff --git a/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp
deleted file mode 100644
index dad44d6ee7..0000000000
--- a/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp
+++ /dev/null
@@ -1,373 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-#include <QGraphicsScene>
-#include <QPainter>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qquickborderimage_p.h>
-#include <private/qquickimagebase_p.h>
-#include <private/qquickscalegrid_p_p.h>
-#include <private/qquickloader_p.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-#include "../../shared/testhttpserver.h"
-#include "../../shared/util.h"
-
-#define SERVER_PORT 14446
-#define SERVER_ADDR "http://127.0.0.1:14446"
-
-class tst_qquickborderimage : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_qquickborderimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void smooth();
- void mirror();
- void tileModes();
- void sciSource();
- void sciSource_data();
- void invalidSciFile();
- void pendingRemoteRequest();
- void pendingRemoteRequest_data();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qquickborderimage::tst_qquickborderimage()
-{
-}
-
-void tst_qquickborderimage::noSource()
-{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickborderimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << testFileUrl("colors.png").toString() << false << "";
- QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false
- << "file::2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString();
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
- << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
-}
-
-void tst_qquickborderimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, remote);
- QFETCH(QString, error);
-
- TestHTTPServer *server = 0;
- if (remote) {
- server = new TestHTTPServer(SERVER_PORT);
- QVERIFY(server->isValid());
- server->serveDirectory(dataDirectory());
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->sourceSize().width(), 120);
- QCOMPARE(obj->sourceSize().height(), 120);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
- } else {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qquickborderimage::clearSource()
-{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickBorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QQuickBorderImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
-}
-
-void tst_qquickborderimage::resized()
-{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("colors.png").toString() + "\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->sourceSize().width(), 120);
- QCOMPARE(obj->sourceSize().height(), 120);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickborderimage::smooth()
-{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickborderimage::mirror()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("mirror.qml"));
- QQuickBorderImage *image = qobject_cast<QQuickBorderImage*>(canvas->rootObject());
- QVERIFY(image != 0);
-
- QImage screenshot = canvas->grabFrameBuffer();
-
- QImage srcPixmap(screenshot);
- QTransform transform;
- transform.translate(image->width(), 0).scale(-1, 1.0);
- srcPixmap = srcPixmap.transformed(transform);
-
- image->setProperty("mirror", true);
- screenshot = canvas->grabFrameBuffer();
- QCOMPARE(screenshot, srcPixmap);
-
- delete canvas;
-}
-
-void tst_qquickborderimage::tileModes()
-{
- {
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 100.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Repeat);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
-
- delete obj;
- }
- {
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 150.);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Round);
-
- delete obj;
- }
-}
-
-void tst_qquickborderimage::sciSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, valid);
-
- bool remote = source.startsWith("http");
- TestHTTPServer *server = 0;
- if (remote) {
- server = new TestHTTPServer(SERVER_PORT);
- QVERIFY(server->isValid());
- server->serveDirectory(dataDirectory());
- }
-
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
-
- if (valid) {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
- QCOMPARE(obj->border()->left(), 10);
- QCOMPARE(obj->border()->top(), 20);
- QCOMPARE(obj->border()->right(), 30);
- QCOMPARE(obj->border()->bottom(), 40);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
- } else {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qquickborderimage::sciSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("valid");
-
- QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true;
- QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true;
- QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
- QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
- QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
-}
-
-void tst_qquickborderimage::invalidSciFile()
-{
- QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun"
- QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea"
-
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("invalid.sci").toString() +"\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->status(), QQuickImageBase::Error);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickborderimage::pendingRemoteRequest()
-{
- QFETCH(QString, source);
-
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->status(), QQuickBorderImage::Loading);
-
- // verify no crash
- // This will cause a delayed "QThread: Destroyed while thread is still running" warning
- delete obj;
- QTest::qWait(50);
-}
-
-void tst_qquickborderimage::pendingRemoteRequest_data()
-{
- QTest::addColumn<QString>("source");
-
- QTest::newRow("png file") << "http://localhost/none.png";
- QTest::newRow("sci file") << "http://localhost/none.sci";
-}
-
-QTEST_MAIN(tst_qquickborderimage)
-
-#include "tst_qquickborderimage.moc"
diff --git a/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro b/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro
deleted file mode 100644
index b21b492e0b..0000000000
--- a/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickcanvas
-SOURCES += tst_qquickcanvas.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private testlib
-
-testData.files = data
-testData.path = .
-DEPLOYMENT += testData
-
-OTHER_FILES += \
- data/AnimationsWhileHidden.qml \
- data/Headless.qml
-
-
diff --git a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp
deleted file mode 100644
index 8f0c4e6fce..0000000000
--- a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp
+++ /dev/null
@@ -1,775 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QTouchEvent>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickCanvas>
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QtDeclarative/QDeclarativeComponent>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtGui/QWindowSystemInterface>
-#include "../../shared/util.h"
-#include <QSignalSpy>
-
-struct TouchEventData {
- QEvent::Type type;
- QWidget *widget;
- QWindow *window;
- Qt::TouchPointStates states;
- QList<QTouchEvent::TouchPoint> touchPoints;
-};
-
-static QTouchEvent::TouchPoint makeTouchPoint(QQuickItem *item, const QPointF &p, const QPointF &lastPoint = QPointF())
-{
- QPointF last = lastPoint.isNull() ? p : lastPoint;
-
- QTouchEvent::TouchPoint tp;
-
- tp.setPos(p);
- tp.setLastPos(last);
- tp.setScenePos(item->mapToScene(p));
- tp.setLastScenePos(item->mapToScene(last));
- tp.setScreenPos(item->canvas()->mapToGlobal(tp.scenePos().toPoint()));
- tp.setLastScreenPos(item->canvas()->mapToGlobal(tp.lastScenePos().toPoint()));
- return tp;
-}
-
-static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states = 0,
- const QList<QTouchEvent::TouchPoint>& touchPoints = QList<QTouchEvent::TouchPoint>())
-{
- TouchEventData d = { type, 0, w, states, touchPoints };
- return d;
-}
-static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states, const QTouchEvent::TouchPoint &touchPoint)
-{
- QList<QTouchEvent::TouchPoint> points;
- points << touchPoint;
- return makeTouchData(type, w, states, points);
-}
-
-#define COMPARE_TOUCH_POINTS(tp1, tp2) \
-{ \
- QCOMPARE(tp1.pos(), tp2.pos()); \
- QCOMPARE(tp1.lastPos(), tp2.lastPos()); \
- QCOMPARE(tp1.scenePos(), tp2.scenePos()); \
- QCOMPARE(tp1.lastScenePos(), tp2.lastScenePos()); \
- QCOMPARE(tp1.screenPos(), tp2.screenPos()); \
- QCOMPARE(tp1.lastScreenPos(), tp2.lastScreenPos()); \
-}
-
-#define COMPARE_TOUCH_DATA(d1, d2) \
-{ \
- QCOMPARE((int)d1.type, (int)d2.type); \
- QCOMPARE(d1.widget, d2.widget); \
- QCOMPARE((int)d1.states, (int)d2.states); \
- QCOMPARE(d1.touchPoints.count(), d2.touchPoints.count()); \
- for (int i=0; i<d1.touchPoints.count(); i++) { \
- COMPARE_TOUCH_POINTS(d1.touchPoints[i], d2.touchPoints[i]); \
- } \
-}
-
-class TestTouchItem : public QQuickRectangle
-{
- Q_OBJECT
-public:
- TestTouchItem(QQuickItem *parent = 0)
- : QQuickRectangle(parent), acceptEvents(true), mousePressId(0)
- {
- border()->setWidth(1);
- setAcceptedMouseButtons(Qt::LeftButton);
- setFiltersChildMouseEvents(true);
- }
-
- void reset() {
- acceptEvents = true;
- setEnabled(true);
- setOpacity(1.0);
-
- lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList<QTouchEvent::TouchPoint>());//CHECK_VALID
- }
-
- static void clearMousePressCounter()
- {
- mousePressNum = 0;
- }
-
- bool acceptEvents;
- TouchEventData lastEvent;
- int mousePressId;
-protected:
- virtual void touchEvent(QTouchEvent *event) {
- if (!acceptEvents) {
- event->ignore();
- return;
- }
- lastEvent = makeTouchData(event->type(), event->window(), event->touchPointStates(), event->touchPoints());
- event->accept();
- }
-
- virtual void mousePressEvent(QMouseEvent *) {
- mousePressId = ++mousePressNum;
- }
-
- bool childMouseEventFilter(QQuickItem *, QEvent *event) {
- if (event->type() == QEvent::MouseButtonPress)
- mousePressId = ++mousePressNum;
- return false;
- }
-
- static int mousePressNum;
-};
-
-int TestTouchItem::mousePressNum = 0;
-
-class ConstantUpdateItem : public QQuickItem
-{
-Q_OBJECT
-public:
- ConstantUpdateItem(QQuickItem *parent = 0) : QQuickItem(parent), iterations(0) {setFlag(ItemHasContents);}
-
- int iterations;
-protected:
- QSGNode* updatePaintNode(QSGNode *, UpdatePaintNodeData *){
- iterations++;
- update();
- return 0;
- }
-};
-
-class tst_qquickcanvas : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- void initTestCase()
- {
- QDeclarativeDataTest::initTestCase();
- touchDevice = new QTouchDevice();
- touchDevice->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
- }
-
-
- void constantUpdates();
- void mouseFiltering();
- void headless();
-
- void touchEvent_basic();
- void touchEvent_propagation();
- void touchEvent_propagation_data();
- void touchEvent_cancel();
-
- void clearCanvas();
-
- void qmlCreation();
- void clearColor();
-
- void grab();
- void multipleWindows();
-
- void animationsWhileHidden();
-
- void focusObject();
-
- void ignoreUnhandledMouseEvents();
-
-private:
- QTouchDevice *touchDevice;
-};
-
-//If the item calls update inside updatePaintNode, it should schedule another update
-void tst_qquickcanvas::constantUpdates()
-{
- QQuickCanvas canvas;
- canvas.resize(250, 250);
- ConstantUpdateItem item(canvas.rootItem());
- canvas.show();
- QTRY_VERIFY(item.iterations > 60);
-}
-
-void tst_qquickcanvas::touchEvent_basic()
-{
- TestTouchItem::clearMousePressCounter();
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->show();
-
- TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
- bottomItem->setObjectName("Bottom Item");
- bottomItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *middleItem = new TestTouchItem(bottomItem);
- middleItem->setObjectName("Middle Item");
- middleItem->setPos(QPointF(50, 50));
- middleItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *topItem = new TestTouchItem(middleItem);
- topItem->setObjectName("Top Item");
- topItem->setPos(QPointF(50, 50));
- topItem->setSize(QSizeF(150, 150));
-
- QPointF pos(10, 10);
-
- // press single point
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas);
- QTest::qWait(50);
-
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
-
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem,pos));
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
- topItem->reset();
-
- // press multiple points
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas)
- .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
- topItem->reset();
- bottomItem->reset();
-
- // touch point on top item moves to bottom item, but top item should still receive the event
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
- makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
- topItem->reset();
-
- // touch point on bottom item moves to top item, but bottom item should still receive the event
- QTest::touchEvent(canvas, touchDevice).press(0, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).move(0, topItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
- makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos), pos)));
- bottomItem->reset();
-
- // a single stationary press on an item shouldn't cause an event
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).stationary(0)
- .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
- topItem->reset();
- bottomItem->reset();
-
- // move touch point from top item to bottom, and release
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(),canvas);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
- makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
- topItem->reset();
-
- // release while another point is pressed
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas)
- .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), canvas)
- .stationary(1);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
- makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos))));
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
- topItem->reset();
- bottomItem->reset();
-
- delete topItem;
- delete middleItem;
- delete bottomItem;
- delete canvas;
-}
-
-void tst_qquickcanvas::touchEvent_propagation()
-{
- TestTouchItem::clearMousePressCounter();
-
- QFETCH(bool, acceptEvents);
- QFETCH(bool, enableItem);
- QFETCH(qreal, itemOpacity);
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->show();
-
- TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
- bottomItem->setObjectName("Bottom Item");
- bottomItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *middleItem = new TestTouchItem(bottomItem);
- middleItem->setObjectName("Middle Item");
- middleItem->setPos(QPointF(50, 50));
- middleItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *topItem = new TestTouchItem(middleItem);
- topItem->setObjectName("Top Item");
- topItem->setPos(QPointF(50, 50));
- topItem->setSize(QSizeF(150, 150));
-
- QPointF pos(10, 10);
- QPoint pointInBottomItem = bottomItem->mapToScene(pos).toPoint(); // (10, 10)
- QPoint pointInMiddleItem = middleItem->mapToScene(pos).toPoint(); // (60, 60) overlaps with bottomItem
- QPoint pointInTopItem = topItem->mapToScene(pos).toPoint(); // (110, 110) overlaps with bottom & top items
-
- // disable topItem
- topItem->acceptEvents = acceptEvents;
- topItem->setEnabled(enableItem);
- topItem->setOpacity(itemOpacity);
-
- // single touch to top item, should be received by middle item
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
- QTest::qWait(50);
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(middleItem->lastEvent.touchPoints.count(), 1);
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))));
-
- // touch top and middle items, middle item should get both events
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
- .press(1, pointInMiddleItem, canvas);
- QTest::qWait(50);
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(middleItem->lastEvent.touchPoints.count(), 2);
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- (QList<QTouchEvent::TouchPoint>() << makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))
- << makeTouchPoint(middleItem, pos) )));
- middleItem->reset();
-
- // disable middleItem as well
- middleItem->acceptEvents = acceptEvents;
- middleItem->setEnabled(enableItem);
- middleItem->setOpacity(itemOpacity);
-
- // touch top and middle items, bottom item should get all events
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
- .press(1, pointInMiddleItem, canvas);
- QTest::qWait(50);
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 2);
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- (QList<QTouchEvent::TouchPoint>() << makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos))
- << makeTouchPoint(bottomItem, bottomItem->mapFromItem(middleItem, pos)) )));
- bottomItem->reset();
-
- // disable bottom item as well
- bottomItem->acceptEvents = acceptEvents;
- bottomItem->setEnabled(enableItem);
- bottomItem->setOpacity(itemOpacity);
-
- // no events should be received
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
- .press(1, pointInMiddleItem, canvas)
- .press(2, pointInBottomItem, canvas);
- QTest::qWait(50);
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
-
- topItem->reset();
- middleItem->reset();
- bottomItem->reset();
-
- // disable middle item, touch on top item
- middleItem->acceptEvents = acceptEvents;
- middleItem->setEnabled(enableItem);
- middleItem->setOpacity(itemOpacity);
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
- QTest::qWait(50);
- if (!enableItem || itemOpacity == 0) {
- // middle item is disabled or has 0 opacity, bottom item receives the event
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos))));
- } else {
- // middle item ignores event, sends it to the top item (top-most child)
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- makeTouchPoint(topItem, pos)));
- }
-
- delete topItem;
- delete middleItem;
- delete bottomItem;
- delete canvas;
-}
-
-void tst_qquickcanvas::touchEvent_propagation_data()
-{
- QTest::addColumn<bool>("acceptEvents");
- QTest::addColumn<bool>("enableItem");
- QTest::addColumn<qreal>("itemOpacity");
-
- QTest::newRow("disable events") << false << true << 1.0;
- QTest::newRow("disable item") << true << false << 1.0;
- QTest::newRow("opacity of 0") << true << true << 0.0;
-}
-
-void tst_qquickcanvas::touchEvent_cancel()
-{
- TestTouchItem::clearMousePressCounter();
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->show();
-
- TestTouchItem *item = new TestTouchItem(canvas->rootItem());
- item->setPos(QPointF(50, 50));
- item->setSize(QSizeF(150, 150));
-
- QPointF pos(10, 10);
- QTest::touchEvent(canvas, touchDevice).press(0, item->mapToScene(pos).toPoint(),canvas);
- QCoreApplication::processEvents();
-
- QTRY_COMPARE(item->lastEvent.touchPoints.count(), 1);
- TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(item,pos));
- COMPARE_TOUCH_DATA(item->lastEvent, d);
- item->reset();
-
- QWindowSystemInterface::handleTouchCancelEvent(0, touchDevice);
- QCoreApplication::processEvents();
- d = makeTouchData(QEvent::TouchCancel, canvas);
- COMPARE_TOUCH_DATA(item->lastEvent, d);
-
- delete item;
- delete canvas;
-}
-
-void tst_qquickcanvas::clearCanvas()
-{
- QQuickCanvas *canvas = new QQuickCanvas;
- QQuickItem *item = new QQuickItem;
- item->setParentItem(canvas->rootItem());
-
- QVERIFY(item->canvas() == canvas);
-
- delete canvas;
-
- QVERIFY(item->canvas() == 0);
-
- delete item;
-}
-
-void tst_qquickcanvas::mouseFiltering()
-{
- TestTouchItem::clearMousePressCounter();
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->show();
-
- TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
- bottomItem->setObjectName("Bottom Item");
- bottomItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *middleItem = new TestTouchItem(bottomItem);
- middleItem->setObjectName("Middle Item");
- middleItem->setPos(QPointF(50, 50));
- middleItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *topItem = new TestTouchItem(middleItem);
- topItem->setObjectName("Top Item");
- topItem->setPos(QPointF(50, 50));
- topItem->setSize(QSizeF(150, 150));
-
- QPoint pos(100, 100);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, pos);
-
- // Mouse filtering propagates down the stack, so the
- // correct order is
- // 1. middleItem filters event
- // 2. bottomItem filters event
- // 3. topItem receives event
- QTRY_COMPARE(middleItem->mousePressId, 1);
- QTRY_COMPARE(bottomItem->mousePressId, 2);
- QTRY_COMPARE(topItem->mousePressId, 3);
-
- delete canvas;
-}
-
-void tst_qquickcanvas::qmlCreation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.loadUrl(testFileUrl("window.qml"));
- QObject* created = component.create();
- QVERIFY(created);
-
- QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
- QVERIFY(canvas);
- QCOMPARE(canvas->clearColor(), QColor(Qt::green));
-
- QQuickItem* item = canvas->findChild<QQuickItem*>("item");
- QVERIFY(item);
- QCOMPARE(item->canvas(), canvas);
-
- delete canvas;
-}
-
-void tst_qquickcanvas::clearColor()
-{
- //### Can we examine rendering to make sure it is really blue?
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->setClearColor(Qt::blue);
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
- QCOMPARE(canvas->clearColor(), QColor(Qt::blue));
- delete canvas;
-}
-
-void tst_qquickcanvas::grab()
-{
- QQuickCanvas canvas;
- canvas.setClearColor(Qt::red);
-
- canvas.resize(250, 250);
- canvas.show();
-
- QTest::qWaitForWindowShown(&canvas);
-
- QImage content = canvas.grabFrameBuffer();
- QCOMPARE(content.width(), canvas.width());
- QCOMPARE(content.height(), canvas.height());
- QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000);
-}
-
-void tst_qquickcanvas::multipleWindows()
-{
- QList<QQuickCanvas *> windows;
- for (int i=0; i<6; ++i) {
- QQuickCanvas *c = new QQuickCanvas();
- c->setClearColor(Qt::GlobalColor(Qt::red + i));
- c->resize(300, 200);
- c->setPos(100 + i * 30, 100 + i * 20);
- c->show();
- windows << c;
- QVERIFY(c->visible());
- }
-
- // move them
- for (int i=0; i<windows.size(); ++i) {
- QQuickCanvas *c = windows.at(i);
- c->setPos(c->x() - 10, c->y() - 10);
- }
-
- // resize them
- for (int i=0; i<windows.size(); ++i) {
- QQuickCanvas *c = windows.at(i);
- c->resize(200, 150);
- }
-
- qDeleteAll(windows);
-}
-
-void tst_qquickcanvas::animationsWhileHidden()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.loadUrl(testFileUrl("AnimationsWhileHidden.qml"));
- QObject* created = component.create();
-
- QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
- QVERIFY(canvas);
- QVERIFY(canvas->visible());
-
- // Now hide the window and verify that it went off screen
- canvas->hide();
- QTest::qWait(10);
- QVERIFY(!canvas->visible());
-
- // Running animaiton should cause it to become visible again shortly.
- QTRY_VERIFY(canvas->visible());
-
- delete canvas;
-}
-
-
-void tst_qquickcanvas::headless()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.loadUrl(testFileUrl("Headless.qml"));
- QObject* created = component.create();
-
- QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
- QVERIFY(canvas);
-
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->visible());
-
- QSignalSpy initialized(canvas, SIGNAL(sceneGraphInitialized()));
- QSignalSpy invalidated(canvas, SIGNAL(sceneGraphInvalidated()));
-
- // Verify that the canvas is alive and kicking
- QVERIFY(canvas->openglContext() != 0);
-
- // Store the visual result
- QImage originalContent = canvas->grabFrameBuffer();
-
- // Hide the canvas and verify signal emittion and GL context deletion
- canvas->hide();
- canvas->releaseResources();
-
- QTRY_COMPARE(invalidated.size(), 1);
- QVERIFY(canvas->openglContext() == 0);
-
- // Destroy the native windowing system buffers
- canvas->destroy();
- QVERIFY(canvas->handle() == 0);
-
- // Show and verify that we are back and running
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QCOMPARE(initialized.size(), 1);
- QVERIFY(canvas->openglContext() != 0);
-
- // Verify that the visual output is the same
- QImage newContent = canvas->grabFrameBuffer();
-
- QCOMPARE(originalContent, newContent);
-
- delete canvas;
-}
-
-void tst_qquickcanvas::focusObject()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.loadUrl(testFileUrl("focus.qml"));
- QObject *created = component.create();
- QVERIFY(created);
-
- QQuickCanvas *canvas = qobject_cast<QQuickCanvas*>(created);
- QVERIFY(canvas);
-
- QQuickItem *item1 = canvas->findChild<QQuickItem*>("item1");
- QVERIFY(item1);
- item1->setFocus(true);
- QCOMPARE(item1, canvas->focusObject());
-
- QQuickItem *item2 = canvas->findChild<QQuickItem*>("item2");
- QVERIFY(item2);
- item2->setFocus(true);
- QCOMPARE(item2, canvas->focusObject());
-
- delete canvas;
-}
-
-void tst_qquickcanvas::ignoreUnhandledMouseEvents()
-{
- QQuickCanvas* canvas = new QQuickCanvas;
- canvas->resize(100, 100);
- canvas->show();
-
- QQuickItem* item = new QQuickItem;
- item->setSize(QSizeF(100, 100));
- item->setParentItem(canvas->rootItem());
-
- {
- QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- me.setAccepted(true);
- QVERIFY(QCoreApplication::sendEvent(canvas, &me));
- QVERIFY(!me.isAccepted());
- }
-
- {
- QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- me.setAccepted(true);
- QVERIFY(QCoreApplication::sendEvent(canvas, &me));
- QVERIFY(!me.isAccepted());
- }
-
- {
- QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- me.setAccepted(true);
- QVERIFY(QCoreApplication::sendEvent(canvas, &me));
- QVERIFY(!me.isAccepted());
- }
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickcanvas)
-
-#include "tst_qquickcanvas.moc"
diff --git a/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro b/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro
deleted file mode 100644
index 93539dab15..0000000000
--- a/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro
+++ /dev/null
@@ -1,34 +0,0 @@
-QT += core-private gui-private declarative-private widgets
-TEMPLATE=app
-TARGET=tst_qquickcanvasitem
-
-CONFIG += warn_on qmltestcase
-SOURCES += tst_qquickcanvasitem.cpp
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
-
-OTHER_FILES += \
- data/testhelper.js \
- data/tst_transform.qml \
- data/tst_text.qml \
- data/tst_strokeStyle.qml \
- data/tst_state.qml \
- data/tst_shadow.qml \
- data/tst_pattern.qml \
- data/tst_path.qml \
- data/tst_line.qml \
- data/tst_fillStyle.qml \
- data/tst_fillrect.qml \
- data/tst_drawimage.qml \
- data/tst_composite.qml \
- data/tst_canvas.qml \
- data/tst_pixel.qml \
- data/tst_gradient.qml \
- data/tst_arcto.qml \
- data/tst_arc.qml \
- data/tst_context.qml
-
-
-
diff --git a/tests/auto/qtquick2/qquickdrag/qquickdrag.pro b/tests/auto/qtquick2/qquickdrag/qquickdrag.pro
deleted file mode 100644
index 4fdfa7b355..0000000000
--- a/tests/auto/qtquick2/qquickdrag/qquickdrag.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = tst_qquickdrag
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickdrag.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp b/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp
deleted file mode 100644
index 91edf8c7b6..0000000000
--- a/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp
+++ /dev/null
@@ -1,1034 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-
-template <typename T> static T evaluate(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- QVariant result = expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
- return result.value<T>();
-}
-
-template <> void evaluate<void>(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
-}
-
-Q_DECLARE_METATYPE(Qt::DropActions)
-
-class TestDropTarget : public QQuickItem
-{
- Q_OBJECT
-public:
- TestDropTarget(QQuickItem *parent = 0)
- : QQuickItem(parent)
- , enterEvents(0)
- , moveEvents(0)
- , leaveEvents(0)
- , dropEvents(0)
- , acceptAction(Qt::MoveAction)
- , defaultAction(Qt::IgnoreAction)
- , proposedAction(Qt::IgnoreAction)
- , accept(true)
- {
- setFlags(ItemAcceptsDrops);
- }
-
- void reset()
- {
- enterEvents = 0;
- moveEvents = 0;
- leaveEvents = 0;
- dropEvents = 0;
- defaultAction = Qt::IgnoreAction;
- proposedAction = Qt::IgnoreAction;
- supportedActions = Qt::IgnoreAction;
- }
-
- void dragEnterEvent(QDragEnterEvent *event)
- {
- ++enterEvents;
- position = event->pos();
- defaultAction = event->dropAction();
- proposedAction = event->proposedAction();
- supportedActions = event->possibleActions();
- event->setAccepted(accept);
- }
-
- void dragMoveEvent(QDragMoveEvent *event)
- {
- ++moveEvents;
- position = event->pos();
- defaultAction = event->dropAction();
- proposedAction = event->proposedAction();
- supportedActions = event->possibleActions();
- event->setAccepted(accept);
- }
-
- void dragLeaveEvent(QDragLeaveEvent *event)
- {
- ++leaveEvents;
- event->setAccepted(accept);
- }
-
- void dropEvent(QDropEvent *event)
- {
- ++dropEvents;
- position = event->pos();
- defaultAction = event->dropAction();
- proposedAction = event->proposedAction();
- supportedActions = event->possibleActions();
- event->setDropAction(acceptAction);
- event->setAccepted(accept);
- }
-
- int enterEvents;
- int moveEvents;
- int leaveEvents;
- int dropEvents;
- Qt::DropAction acceptAction;
- Qt::DropAction defaultAction;
- Qt::DropAction proposedAction;
- Qt::DropActions supportedActions;
- QPointF position;
- bool accept;
-};
-
-class tst_QQuickDrag: public QObject
-{
- Q_OBJECT
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void active();
- void drop();
- void move();
- void hotSpot();
- void supportedActions();
- void proposedAction();
- void keys();
- void source();
- void recursion_data();
- void recursion();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_QQuickDrag::initTestCase()
-{
-
-}
-
-void tst_QQuickDrag::cleanupTestCase()
-{
-
-}
-
-void tst_QQuickDrag::active()
-{
- QQuickCanvas canvas;
- TestDropTarget dropTarget(canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property bool dragActive: Drag.active\n"
- "property Item dragTarget: Drag.target\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&dropTarget);
-
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
-
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.cancel()");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- // Start while a drag is active, cancels the previous drag and starts a new one.
- dropTarget.reset();
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 1);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.cancel()");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
-
- // Enter events aren't sent to items without the QQuickItem::ItemAcceptsDrops flag.
- dropTarget.setFlags(QQuickItem::Flags());
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.setFlags(QQuickItem::ItemAcceptsDrops);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.setFlags(QQuickItem::Flags());
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
-
- // Follow up events aren't sent to items if the enter event isn't accepted.
- dropTarget.setFlags(QQuickItem::ItemAcceptsDrops);
- dropTarget.accept = false;
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.accept = true;
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.accept = false;
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
-
- // Events are sent to hidden or disabled items.
- dropTarget.accept = true;
- dropTarget.setVisible(false);
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- evaluate<void>(item, "Drag.active = false");
- dropTarget.setVisible(true);
-
- dropTarget.setOpacity(0.0);
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- evaluate<void>(item, "Drag.active = false");
- dropTarget.setOpacity(1.0);
-
- dropTarget.setEnabled(false);
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-}
-
-void tst_QQuickDrag::drop()
-{
- QQuickCanvas canvas;
- TestDropTarget outerTarget(canvas.rootItem());
- outerTarget.setSize(QSizeF(100, 100));
- outerTarget.acceptAction = Qt::CopyAction;
- TestDropTarget innerTarget(&outerTarget);
- innerTarget.setSize(QSizeF(100, 100));
- innerTarget.acceptAction = Qt::MoveAction;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property bool dragActive: Drag.active\n"
- "property Item dragTarget: Drag.target\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&outerTarget);
-
- innerTarget.reset(); outerTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1);
-
- innerTarget.reset(); outerTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- // Inner target declines the drop so it is propagated to the outer target.
- innerTarget.accept = false;
-
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.CopyAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1);
-
-
- // Inner target doesn't accept enter so drop goes directly to outer.
- innerTarget.accept = true;
- innerTarget.setFlags(QQuickItem::Flags());
-
- innerTarget.reset(); outerTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.CopyAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- // Neither target accepts drop so Qt::IgnoreAction is returned.
- innerTarget.reset(); outerTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- outerTarget.accept = false;
-
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.IgnoreAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- // drop doesn't send an event and returns Qt.IgnoreAction if not active.
- innerTarget.accept = true;
- outerTarget.accept = true;
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.IgnoreAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-}
-
-void tst_QQuickDrag::move()
-{
- QQuickCanvas canvas;
- TestDropTarget outerTarget(canvas.rootItem());
- outerTarget.setSize(QSizeF(100, 100));
- TestDropTarget leftTarget(&outerTarget);
- leftTarget.setPos(QPointF(0, 35));
- leftTarget.setSize(QSizeF(30, 30));
- TestDropTarget rightTarget(&outerTarget);
- rightTarget.setPos(QPointF(70, 35));
- rightTarget.setSize(QSizeF(30, 30));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property bool dragActive: Drag.active\n"
- "property Item dragTarget: Drag.target\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&outerTarget);
-
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(50)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Move within the outer target.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(60, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Move into the right target.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(75, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&rightTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&rightTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(75)); QCOMPARE(outerTarget.position.y(), qreal(50));
- QCOMPARE(rightTarget.position.x(), qreal(5)); QCOMPARE(rightTarget.position.y(), qreal(15));
-
- // Move into the left target.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(25, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&leftTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&leftTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 1); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 1); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50));
- QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(15));
-
- // Move within the left target.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(25, 40));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&leftTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&leftTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 1);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(40));
- QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(5));
-
- // Move out of all targets.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(110, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.moveEvents, 0);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 1); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
-
- // Stop the right target accepting drag events and move into it.
- rightTarget.accept = false;
-
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(80, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(80)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Stop the outer target accepting drag events after it has accepted an enter event.
- outerTarget.accept = false;
-
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(60, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Clear the QQuickItem::ItemAcceptsDrops flag from the outer target after it accepted an enter event.
- outerTarget.setFlags(QQuickItem::Flags());
-
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(40, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(40)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Clear the QQuickItem::ItemAcceptsDrops flag from the left target before it accepts an enter event.
- leftTarget.setFlags(QQuickItem::Flags());
-
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(25, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50));
-}
-
-
-void tst_QQuickDrag::hotSpot()
-{
- QQuickCanvas canvas;
- TestDropTarget dropTarget(canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property real hotSpotX: Drag.hotSpot.x\n"
- "property real hotSpotY: Drag.hotSpot.y\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&dropTarget);
-
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(0));
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(0));
- QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(0));
- QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(0));
-
- evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
- QCOMPARE(dropTarget.position.x(), qreal(50));
- QCOMPARE(dropTarget.position.y(), qreal(50));
-
- evaluate<void>(item, "{ Drag.hotSpot.x = 5, Drag.hotSpot.y = 5 }");
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(5));
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(5));
- QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(5));
- QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(5));
-
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(dropTarget.position.x(), qreal(55));
- QCOMPARE(dropTarget.position.y(), qreal(55));
-
- item->setPos(QPointF(30, 20));
- QCOMPARE(dropTarget.position.x(), qreal(35));
- QCOMPARE(dropTarget.position.y(), qreal(25));
-
- evaluate<void>(item, "{ Drag.hotSpot.x = 10; Drag.hotSpot.y = 10 }");
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(10));
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(10));
- QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(10));
- QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(10));
- // Changing the hotSpot won't generate a move event so the position is unchanged. Should it?
- QCOMPARE(dropTarget.position.x(), qreal(35));
- QCOMPARE(dropTarget.position.y(), qreal(25));
-
- item->setPos(QPointF(10, 20));
- QCOMPARE(dropTarget.position.x(), qreal(20));
- QCOMPARE(dropTarget.position.y(), qreal(30));
-}
-
-void tst_QQuickDrag::supportedActions()
-{
- QQuickCanvas canvas;
- TestDropTarget dropTarget(canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property int supportedActions: Drag.supportedActions\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&dropTarget);
-
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true);
- evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
- QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction | Qt::LinkAction);
-
- evaluate<void>(item, "Drag.supportedActions = Qt.CopyAction | Qt.MoveAction");
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.CopyAction | Qt.MoveAction"), true);
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction);
-
- // Once a drag is started the proposed actions are locked in for future events.
- evaluate<void>(item, "Drag.supportedActions = Qt.MoveAction");
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
- item->setPos(QPointF(60, 60));
- QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction);
-
- // Calling start with proposed actions will override the current actions for the next sequence.
- evaluate<void>(item, "Drag.start(Qt.CopyAction)");
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
- QCOMPARE(dropTarget.supportedActions, Qt::CopyAction);
-
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
- QCOMPARE(dropTarget.supportedActions, Qt::MoveAction);
-}
-
-void tst_QQuickDrag::proposedAction()
-{
- QQuickCanvas canvas;
- TestDropTarget dropTarget(canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property int proposedAction: Drag.proposedAction\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&dropTarget);
-
-
- QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.MoveAction"), true);
- evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
- QCOMPARE(dropTarget.defaultAction, Qt::MoveAction);
- QCOMPARE(dropTarget.proposedAction, Qt::MoveAction);
-
- evaluate<void>(item, "Drag.proposedAction = Qt.CopyAction");
- QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.CopyAction"), true);
- QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.CopyAction"), true);
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(dropTarget.defaultAction, Qt::CopyAction);
- QCOMPARE(dropTarget.proposedAction, Qt::CopyAction);
-
- // The proposed action can change during a drag.
- evaluate<void>(item, "Drag.proposedAction = Qt.MoveAction");
- QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.MoveAction"), true);
- item->setPos(QPointF(60, 60));
- QCOMPARE(dropTarget.defaultAction, Qt::MoveAction);
- QCOMPARE(dropTarget.proposedAction, Qt::MoveAction);
-
- evaluate<void>(item, "Drag.proposedAction = Qt.LinkAction");
- QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.LinkAction"), true);
- QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.LinkAction"), true);
- evaluate<void>(item, "Drag.drop()");
- QCOMPARE(dropTarget.defaultAction, Qt::LinkAction);
- QCOMPARE(dropTarget.proposedAction, Qt::LinkAction);
-}
-
-void tst_QQuickDrag::keys()
-{
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property variant keys: Drag.keys\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
-
-// QCOMPARE(evaluate<QStringList>(item, "Drag.keys"), QStringList());
-// QCOMPARE(evaluate<QStringList>(item, "keys"), QStringList());
- QCOMPARE(item->property("keys").toStringList(), QStringList());
-
- evaluate<void>(item, "Drag.keys = [\"red\", \"blue\"]");
-// QCOMPARE(evaluate<QStringList>(item, "Drag.keys"), QStringList() << "red" << "blue");
-// QCOMPARE(evaluate<QStringList>(item, "keys"), QStringList() << "red" << "blue");
- QCOMPARE(item->property("keys").toStringList(), QStringList() << "red" << "blue");
-}
-
-void tst_QQuickDrag::source()
-{
-
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property Item source: Drag.source\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "Item { id: proxySource; objectName: \"proxySource\" }\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
-
- QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(item));
- QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(item));
-
- QQuickItem *proxySource = item->findChild<QQuickItem *>("proxySource");
- QVERIFY(proxySource);
-
- evaluate<void>(item, "Drag.source = proxySource");
- QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(proxySource));
- QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(proxySource));
-
- evaluate<void>(item, "Drag.source = undefined");
- QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(item));
- QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(item));
-}
-
-class RecursingDropTarget : public TestDropTarget
-{
-public:
- RecursingDropTarget(const QString &script, int type, QQuickItem *parent)
- : TestDropTarget(parent), script(script), type(type), item(0) {}
-
- void setItem(QQuickItem *i) { item = i; }
-
-protected:
- void dragEnterEvent(QDragEnterEvent *event)
- {
- TestDropTarget::dragEnterEvent(event);
- if (type == QEvent::DragEnter && enterEvents < 2)
- evaluate<void>(item, script);
- }
-
- void dragMoveEvent(QDragMoveEvent *event)
- {
- TestDropTarget::dragMoveEvent(event);
- if (type == QEvent::DragMove && moveEvents < 2)
- evaluate<void>(item, script);
- }
-
- void dragLeaveEvent(QDragLeaveEvent *event)
- {
- TestDropTarget::dragLeaveEvent(event);
- if (type == QEvent::DragLeave && leaveEvents < 2)
- evaluate<void>(item, script);
- }
-
- void dropEvent(QDropEvent *event)
- {
- TestDropTarget::dropEvent(event);
- if (type == QEvent::Drop && dropEvents < 2)
- evaluate<void>(item, script);
- }
-
-private:
- QString script;
- int type;
- QQuickItem *item;
-
-};
-
-void tst_QQuickDrag::recursion_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("type");
- QTest::addColumn<QByteArray>("warning");
-
- QTest::newRow("Drag.start() in Enter")
- << QString("Drag.start()")
- << int(QEvent::DragEnter)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
- QTest::newRow("Drag.cancel() in Enter")
- << QString("Drag.cancel()")
- << int(QEvent::DragEnter)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
- QTest::newRow("Drag.drop() in Enter")
- << QString("Drag.drop()")
- << int(QEvent::DragEnter)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
- QTest::newRow("Drag.active = true in Enter")
- << QString("Drag.active = true")
- << int(QEvent::DragEnter)
- << QByteArray();
- QTest::newRow("Drag.active = false in Enter")
- << QString("Drag.active = false")
- << int(QEvent::DragEnter)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
- QTest::newRow("move in Enter")
- << QString("x = 23")
- << int(QEvent::DragEnter)
- << QByteArray();
-
- QTest::newRow("Drag.start() in Move")
- << QString("Drag.start()")
- << int(QEvent::DragMove)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
- QTest::newRow("Drag.cancel() in Move")
- << QString("Drag.cancel()")
- << int(QEvent::DragMove)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
- QTest::newRow("Drag.drop() in Move")
- << QString("Drag.drop()")
- << int(QEvent::DragMove)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
- QTest::newRow("Drag.active = true in Move")
- << QString("Drag.active = true")
- << int(QEvent::DragMove)
- << QByteArray();
- QTest::newRow("Drag.active = false in Move")
- << QString("Drag.active = false")
- << int(QEvent::DragMove)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
- QTest::newRow("move in Move")
- << QString("x = 23")
- << int(QEvent::DragMove)
- << QByteArray();
-
- QTest::newRow("Drag.start() in Leave")
- << QString("Drag.start()")
- << int(QEvent::DragLeave)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
- QTest::newRow("Drag.cancel() in Leave")
- << QString("Drag.cancel()")
- << int(QEvent::DragLeave)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
- QTest::newRow("Drag.drop() in Leave")
- << QString("Drag.drop()")
- << int(QEvent::DragLeave)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
- QTest::newRow("Drag.active = true in Leave")
- << QString("Drag.active = true")
- << int(QEvent::DragLeave)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
- QTest::newRow("Drag.active = false in Leave")
- << QString("Drag.active = false")
- << int(QEvent::DragLeave)
- << QByteArray();
- QTest::newRow("move in Leave")
- << QString("x = 23")
- << int(QEvent::DragLeave)
- << QByteArray();
-
- QTest::newRow("Drag.start() in Drop")
- << QString("Drag.start()")
- << int(QEvent::Drop)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
- QTest::newRow("Drag.cancel() in Drop")
- << QString("Drag.cancel()")
- << int(QEvent::Drop)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
- QTest::newRow("Drag.drop() in Drop")
- << QString("Drag.drop()")
- << int(QEvent::Drop)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
- QTest::newRow("Drag.active = true in Drop")
- << QString("Drag.active = true")
- << int(QEvent::Drop)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
- QTest::newRow("Drag.active = false in Drop")
- << QString("Drag.active = false")
- << int(QEvent::Drop)
- << QByteArray();
- QTest::newRow("move in Drop")
- << QString("x = 23")
- << int(QEvent::Drop)
- << QByteArray();
-}
-
-void tst_QQuickDrag::recursion()
-{
- QFETCH(QString, script);
- QFETCH(int, type);
- QFETCH(QByteArray, warning);
-
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.constData());
-
- QQuickCanvas canvas;
- RecursingDropTarget dropTarget(script, type, canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(canvas.rootItem());
-
- dropTarget.setItem(item);
-
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 0);
- QCOMPARE(dropTarget.dropEvents, 0);
- QCOMPARE(dropTarget.leaveEvents, 0);
-
- evaluate<void>(item, "y = 15");
- QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
- QCOMPARE(dropTarget.dropEvents, 0);
- QCOMPARE(dropTarget.leaveEvents, 0);
-
- if (type == QEvent::Drop) {
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
- QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
- QCOMPARE(dropTarget.dropEvents, 1);
- QCOMPARE(dropTarget.leaveEvents, 0);
- } else {
- evaluate<void>(item, "Drag.cancel()");
- QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
- QCOMPARE(dropTarget.dropEvents, 0);
- QCOMPARE(dropTarget.leaveEvents, 1);
- }
-}
-
-
-QTEST_MAIN(tst_QQuickDrag)
-
-#include "tst_qquickdrag.moc"
diff --git a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro b/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro
deleted file mode 100644
index 6c6de13d5f..0000000000
--- a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TARGET = tst_qquickdroparea
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickdroparea.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
-
-mac: CONFIG += insignificant_test # QTBUG-24588
diff --git a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp
deleted file mode 100644
index 88cf1ec009..0000000000
--- a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp
+++ /dev/null
@@ -1,1118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-
-#include <QtGui/qwindowsysteminterface_qpa.h>
-#include <QtGui/qplatformdrag_qpa.h>
-
-template <typename T> static T evaluate(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- QVariant result = expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
- return result.value<T>();
-}
-
-template <> void evaluate<void>(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
-}
-
-class tst_QQuickDropArea: public QObject
-{
- Q_OBJECT
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void containsDrag_internal();
- void containsDrag_external();
- void keys_internal();
- void keys_external();
- void source_internal();
-// void source_external();
- void position_internal();
- void position_external();
- void drop_internal();
-// void drop_external();
- void simultaneousDrags();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_QQuickDropArea::initTestCase()
-{
-
-}
-
-void tst_QQuickDropArea::cleanupTestCase()
-{
-
-}
-
-void tst_QQuickDropArea::containsDrag_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property bool hasDrag: containsDrag\n"
- "property int enterEvents: 0\n"
- "property int exitEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents}\n"
- "onExited: {++exitEvents}\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
-
- dragItem->setPos(QPointF(150, 50));
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- dragItem->setPos(QPointF(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- dragItem->setPos(QPointF(150, 50));
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
-
- evaluate<void>(dragItem, "Drag.active = false");
-}
-
-void tst_QQuickDropArea::containsDrag_external()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property bool hasDrag: containsDrag\n"
- "property int enterEvents: 0\n"
- "property int exitEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents}\n"
- "onExited: {++exitEvents}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QMimeData data;
- QQuickCanvas alternateCanvas;
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
-
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
-}
-
-void tst_QQuickDropArea::keys_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property variant dragKeys\n"
- "property variant dropKeys: keys\n"
- "property int enterEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents; dragKeys = drag.keys }\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "Drag.keys: [\"red\", \"blue\"]\n"
- "}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = \"blue\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "blue");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "blue");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = \"red\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = \"green\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "green");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "green");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = [\"red\", \"green\"]");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red" << "green");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red" << "green");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dragItem, "Drag.keys = []");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = []");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = []");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dragItem, "Drag.keys = [\"red\", \"blue\"]");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-}
-
-void tst_QQuickDropArea::keys_external()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property variant dragKeys\n"
- "property variant dropKeys: keys\n"
- "property int enterEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents; dragKeys = drag.keys }\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- dropArea->setParentItem(canvas.rootItem());
-
- QMimeData data;
- QQuickCanvas alternateCanvas;
-
- data.setData("text/x-red", "red");
- data.setData("text/x-blue", "blue");
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- evaluate<void>(dropArea, "keys = \"text/x-blue\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- evaluate<void>(dropArea, "keys = \"text/x-red\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- evaluate<void>(dropArea, "keys = \"text/x-green\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- evaluate<void>(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- data.removeFormat("text/x-red");
- data.removeFormat("text/x-blue");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- evaluate<void>(dropArea, "keys = []");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- data.setData("text/x-red", "red");
- data.setData("text/x-blue", "blue");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
-}
-
-void tst_QQuickDropArea::source_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property Item source: drag.source\n"
- "property Item eventSource\n"
- "width: 100; height: 100\n"
- "onEntered: {eventSource = drag.source}\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}\n"
- "Item { id: dragSource; objectName: \"dragSource\" }\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- QQuickItem *dragSource = dropArea->findChild<QQuickItem *>("dragSource");
- QVERIFY(dragSource);
-
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(dragItem));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(dragItem));
- QCOMPARE(evaluate<QObject *>(dropArea, "eventSource"), static_cast<QObject *>(dragItem));
-
- evaluate<void>(dragItem, "Drag.active = false");
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
-
-
- evaluate<void>(dropArea, "{ eventSource = null }");
- evaluate<void>(dragItem, "Drag.source = dragSource");
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(dragSource));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(dragSource));
- QCOMPARE(evaluate<QObject *>(dropArea, "eventSource"), static_cast<QObject *>(dragSource));
-
- evaluate<void>(dragItem, "Drag.active = false");
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
-}
-
-// Setting a source can't be emulated using the QWindowSystemInterface API.
-
-//void tst_QQuickDropArea::source_external()
-//{
-//}
-
-void tst_QQuickDropArea::position_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property real dragX: drag.x\n"
- "property real dragY: drag.y\n"
- "property real eventX\n"
- "property real eventY\n"
- "property int enterEvents: 0\n"
- "property int moveEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n"
- "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 0);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
-
- evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- dragItem->setPos(QPointF(40, 50));
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
-
- evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- dragItem->setPos(QPointF(75, 25));
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(25));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(25));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
-
- evaluate<void>(dragItem, "Drag.active = false");
-}
-
-void tst_QQuickDropArea::position_external()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property real dragX: drag.x\n"
- "property real dragY: drag.y\n"
- "property real eventX\n"
- "property real eventY\n"
- "property int enterEvents: 0\n"
- "property int moveEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n"
- "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QMimeData data;
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
-
- evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50), Qt::CopyAction);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
-
- evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25), Qt::CopyAction);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(25));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(25));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
-
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25), Qt::CopyAction);
-}
-
-void tst_QQuickDropArea::drop_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property bool accept: false\n"
- "property bool setAccepted: false\n"
- "property bool acceptDropAction: false\n"
- "property bool setDropAction: false\n"
- "property int dropAction: Qt.IgnoreAction\n"
- "property int proposedAction: Qt.IgnoreAction\n"
- "property int supportedActions: Qt.IgnoreAction\n"
- "property int dropEvents: 0\n"
- "width: 100; height: 100\n"
- "onDropped: {\n"
- "++dropEvents\n"
- "supportedActions = drop.supportedActions\n"
- "proposedAction = drop.action\n"
- "if (setDropAction)\n"
- "drop.action = dropAction\n"
- "if (acceptDropAction)\n"
- "drop.accept(dropAction)\n"
- "else if (setAccepted)\n"
- "drop.accepted = accept\n"
- "else if (accept)\n"
- "drop.accept()\n"
- "}\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::IgnoreAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ accept = true; setDropAction = true; dropAction = Qt.LinkAction }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = true; }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ accept = false; setAccepted = true; }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::IgnoreAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = false; setDropAction = false; acceptDropAction = true; }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ acceptDropAction = false; dropAction = Qt.IgnoreAction; accept = true }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = true }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = false }");
- evaluate<void>(dragItem, "Drag.supportedActions = Qt.LinkAction");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = true }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = false }");
- evaluate<void>(dragItem, "Drag.proposedAction = Qt.LinkAction");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::LinkAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = true }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::LinkAction));
-}
-
-// Setting the supportedActions can't be emulated using the QWindowSystemInterface API.
-
-//void tst_QQuickDropArea::drop_external()
-//{
-//}
-
-void tst_QQuickDropArea::simultaneousDrags()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property int enterEvents: 0\n"
- "property int exitEvents: 0\n"
- "width: 100; height: 100\n"
- "keys: [\"red\", \"text/x-red\"]\n"
- "onEntered: {++enterEvents}\n"
- "onExited: {++exitEvents}\n"
- "DropArea {\n"
- "objectName: \"dropArea2\"\n"
- "property int enterEvents: 0\n"
- "property int exitEvents: 0\n"
- "width: 100; height: 100\n"
- "keys: [\"blue\", \"text/x-blue\"]\n"
- "onEntered: {++enterEvents}\n"
- "onExited: {++exitEvents}\n"
- "}\n"
- "Item {\n"
- "objectName: \"dragItem1\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "Drag.keys: [\"red\", \"blue\"]"
- "}\n"
- "Item {\n"
- "objectName: \"dragItem2\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "Drag.keys: [\"red\", \"blue\"]"
- "}\n"
- "}", QUrl());
-
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea1 = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea1);
- dropArea1->setParentItem(canvas.rootItem());
-
- QQuickItem *dropArea2 = dropArea1->findChild<QQuickItem *>("dropArea2");
- QVERIFY(dropArea2);
-
- QQuickItem *dragItem1 = dropArea1->findChild<QQuickItem *>("dragItem1");
- QVERIFY(dragItem1);
-
- QQuickItem *dragItem2 = dropArea1->findChild<QQuickItem *>("dragItem2");
- QVERIFY(dragItem2);
-
- QMimeData data;
- data.setData("text/x-red", "red");
- data.setData("text/x-blue", "blue");
-
- QQuickCanvas alternateCanvas;
-
- // Mixed internal drags.
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem1, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- // internal then external.
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem1, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- // external then internal.
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- // Different acceptance
- evaluate<void>(dragItem1, "Drag.keys = \"red\"");
- evaluate<void>(dragItem2, "Drag.keys = \"blue\"");
- data.removeFormat("text/x-red");
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- // internal then external
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
-}
-
-QTEST_MAIN(tst_QQuickDropArea)
-
-#include "tst_qquickdroparea.moc"
diff --git a/tests/auto/qtquick2/qquickflickable/qquickflickable.pro b/tests/auto/qtquick2/qquickflickable/qquickflickable.pro
deleted file mode 100644
index d1b8b6948f..0000000000
--- a/tests/auto/qtquick2/qquickflickable/qquickflickable.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickflickable
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickflickable.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp b/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp
deleted file mode 100644
index d357877ed5..0000000000
--- a/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp
+++ /dev/null
@@ -1,663 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquickflickable_p.h>
-#include <private/qquickflickable_p_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <math.h>
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-#include <QtOpenGL/QGLShaderProgram>
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-class tst_qquickflickable : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- void create();
- void horizontalViewportSize();
- void verticalViewportSize();
- void properties();
- void boundsBehavior();
- void maximumFlickVelocity();
- void flickDeceleration();
- void pressDelay();
- void nestedPressDelay();
- void flickableDirection();
- void resizeContent();
- void returnToBounds();
- void wheel();
- void movingAndDragging();
- void disabled();
- void flickVelocity();
- void margins();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qquickflickable::create()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("flickable01.qml"));
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
-
- QCOMPARE(obj->horizontalVelocity(), 0.);
- QCOMPARE(obj->verticalVelocity(), 0.);
-
- QCOMPARE(obj->isInteractive(), true);
- QCOMPARE(obj->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds);
- QCOMPARE(obj->pressDelay(), 0);
- QCOMPARE(obj->maximumFlickVelocity(), 2500.);
-
- delete obj;
-}
-
-void tst_qquickflickable::horizontalViewportSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("flickable02.qml"));
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentWidth(), 800.);
- QCOMPARE(obj->contentHeight(), 300.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qquickflickable::verticalViewportSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("flickable03.qml"));
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentWidth(), 200.);
- QCOMPARE(obj->contentHeight(), 6000.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qquickflickable::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("flickable04.qml"));
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isInteractive(), false);
- QCOMPARE(obj->boundsBehavior(), QQuickFlickable::StopAtBounds);
- QCOMPARE(obj->pressDelay(), 200);
- QCOMPARE(obj->maximumFlickVelocity(), 2000.);
-
- QVERIFY(obj->property("ok").toBool() == false);
- QMetaObject::invokeMethod(obj, "check");
- QVERIFY(obj->property("ok").toBool() == true);
-
- delete obj;
-}
-
-void tst_qquickflickable::boundsBehavior()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
-
- QVERIFY(flickable);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
-
- flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds);
- QCOMPARE(spy.count(),1);
- flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
- QCOMPARE(spy.count(),1);
-
- flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds);
- QCOMPARE(spy.count(),2);
- flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
- QCOMPARE(spy.count(),2);
-
- flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
- QCOMPARE(spy.count(),3);
- flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
- QCOMPARE(spy.count(),3);
-}
-
-void tst_qquickflickable::maximumFlickVelocity()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
-
- flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
- QCOMPARE(spy.count(),1);
- flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qquickflickable::flickDeceleration()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->flickDeceleration(), 1.0);
-
- flickable->setFlickDeceleration(2.0);
- QCOMPARE(flickable->flickDeceleration(), 2.0);
- QCOMPARE(spy.count(),1);
- flickable->setFlickDeceleration(2.0);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qquickflickable::pressDelay()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->pressDelay(), 100);
-
- flickable->setPressDelay(200);
- QCOMPARE(flickable->pressDelay(), 200);
- QCOMPARE(spy.count(),1);
- flickable->setPressDelay(200);
- QCOMPARE(spy.count(),1);
-}
-
-// QTBUG-17361
-void tst_qquickflickable::nestedPressDelay()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("nestedPressDelay.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(canvas->rootObject());
- QVERIFY(outer != 0);
-
- QQuickFlickable *inner = canvas->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
- QVERIFY(inner != 0);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(150, 150));
- // the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
-
- // The outer pressDelay will prevail (50ms, vs. 10sec)
- // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
- QTRY_VERIFY(outer->property("pressed").toBool() == true);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(150, 150));
-
- delete canvas;
-}
-
-void tst_qquickflickable::flickableDirection()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::VerticalFlick);
-
- flickable->setFlickableDirection(QQuickFlickable::HorizontalAndVerticalFlick);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalAndVerticalFlick);
- QCOMPARE(spy.count(),1);
-
- flickable->setFlickableDirection(QQuickFlickable::AutoFlickDirection);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::AutoFlickDirection);
- QCOMPARE(spy.count(),2);
-
- flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
- QCOMPARE(spy.count(),3);
-
- flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
- QCOMPARE(spy.count(),3);
-}
-
-// QtQuick 1.1
-void tst_qquickflickable::resizeContent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("resize.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
- QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
- QCOMPARE(obj->contentWidth(), 300.);
- QCOMPARE(obj->contentHeight(), 300.);
-
- QMetaObject::invokeMethod(root, "resizeContent");
-
- QCOMPARE(obj->contentX(), 100.);
- QCOMPARE(obj->contentY(), 100.);
- QCOMPARE(obj->contentWidth(), 600.);
- QCOMPARE(obj->contentHeight(), 600.);
-
- delete root;
-}
-
-// QtQuick 1.1
-void tst_qquickflickable::returnToBounds()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("resize.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
- QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
- QCOMPARE(obj->contentWidth(), 300.);
- QCOMPARE(obj->contentHeight(), 300.);
-
- obj->setContentX(100);
- obj->setContentY(400);
- QTRY_COMPARE(obj->contentX(), 100.);
- QTRY_COMPARE(obj->contentY(), 400.);
-
- QMetaObject::invokeMethod(root, "returnToBounds");
-
- QTRY_COMPARE(obj->contentX(), 0.);
- QTRY_COMPARE(obj->contentY(), 0.);
-
- delete root;
-}
-
-void tst_qquickflickable::wheel()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("wheel.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flick = canvas->rootObject()->findChild<QQuickFlickable*>("flick");
- QVERIFY(flick != 0);
-
- {
- QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
- event.setAccepted(false);
- QGuiApplication::sendEvent(canvas, &event);
- }
-
- QTRY_VERIFY(flick->contentY() > 0);
- QVERIFY(flick->contentX() == 0);
-
- flick->setContentY(0);
- QVERIFY(flick->contentY() == 0);
-
- {
- QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Horizontal);
- event.setAccepted(false);
- QGuiApplication::sendEvent(canvas, &event);
- }
-
- QTRY_VERIFY(flick->contentX() > 0);
- QVERIFY(flick->contentY() == 0);
-
- delete canvas;
-}
-
-void tst_qquickflickable::movingAndDragging()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("flickable03.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- QSignalSpy vDragSpy(flickable, SIGNAL(draggingVerticallyChanged()));
- QSignalSpy hDragSpy(flickable, SIGNAL(draggingHorizontallyChanged()));
- QSignalSpy dragSpy(flickable, SIGNAL(draggingChanged()));
- QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
- QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
- QSignalSpy moveSpy(flickable, SIGNAL(movingChanged()));
- QSignalSpy dragStartSpy(flickable, SIGNAL(dragStarted()));
- QSignalSpy dragEndSpy(flickable, SIGNAL(dragEnded()));
-
- //Vertical
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
-
- QTest::mouseMove(canvas, QPoint(50, 80));
- QTest::mouseMove(canvas, QPoint(50, 70));
- QTest::mouseMove(canvas, QPoint(50, 60));
-
- QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0);
-
- QVERIFY(!flickable->isDraggingHorizontally());
- QVERIFY(flickable->isDraggingVertically());
- QVERIFY(flickable->isDragging());
- QCOMPARE(vDragSpy.count(), 1);
- QCOMPARE(dragSpy.count(), 1);
- QCOMPARE(hDragSpy.count(), 0);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 0);
-
- QVERIFY(!flickable->isMovingHorizontally());
- QVERIFY(flickable->isMovingVertically());
- QVERIFY(flickable->isMoving());
- QCOMPARE(vMoveSpy.count(), 1);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(hMoveSpy.count(), 0);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
-
- QTRY_VERIFY(!flickable->isDraggingVertically());
- QVERIFY(!flickable->isDragging());
- QCOMPARE(vDragSpy.count(), 2);
- QCOMPARE(dragSpy.count(), 2);
- QCOMPARE(hDragSpy.count(), 0);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 1);
-
- // wait for any motion to end
- QTRY_VERIFY(flickable->isMoving() == false);
-
- //Horizontal
- vDragSpy.clear();
- hDragSpy.clear();
- dragSpy.clear();
- vMoveSpy.clear();
- hMoveSpy.clear();
- moveSpy.clear();
- dragStartSpy.clear();
- dragEndSpy.clear();
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(90, 50));
-
- QTest::mouseMove(canvas, QPoint(80, 50));
- QTest::mouseMove(canvas, QPoint(70, 50));
- QTest::mouseMove(canvas, QPoint(60, 50));
-
- QVERIFY(!flickable->isDraggingVertically());
- QVERIFY(flickable->isDraggingHorizontally());
- QVERIFY(flickable->isDragging());
- QCOMPARE(vDragSpy.count(), 0);
- QCOMPARE(dragSpy.count(), 1);
- QCOMPARE(hDragSpy.count(), 1);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 0);
-
- QVERIFY(!flickable->isMovingVertically());
- QVERIFY(flickable->isMovingHorizontally());
- QVERIFY(flickable->isMoving());
- QCOMPARE(vMoveSpy.count(), 0);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(hMoveSpy.count(), 1);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(60, 50));
-
- QTRY_VERIFY(!flickable->isDraggingHorizontally());
- QVERIFY(!flickable->isDragging());
- QCOMPARE(vDragSpy.count(), 0);
- QCOMPARE(dragSpy.count(), 2);
- QCOMPARE(hDragSpy.count(), 2);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 1);
- // Don't test moving because a flick could occur
-
-#ifdef Q_OS_MAC
- QSKIP("Producing flicks on Mac CI impossible due to timing problems");
-#endif
-
- QTRY_VERIFY(!flickable->isMoving());
-
- vMoveSpy.clear();
- hMoveSpy.clear();
- moveSpy.clear();
- QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
- QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged()));
- QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged()));
-
- // flick then press while it is still moving
- // flicking == false, moving == true;
- flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
- QVERIFY(flickable->verticalVelocity() > 0.0);
- QVERIFY(flickable->isFlicking());
- QVERIFY(flickable->isFlickingVertically());
- QVERIFY(!flickable->isFlickingHorizontally());
- QVERIFY(flickable->isMoving());
- QVERIFY(flickable->isMovingVertically());
- QVERIFY(!flickable->isMovingHorizontally());
- QCOMPARE(vMoveSpy.count(), 1);
- QCOMPARE(hMoveSpy.count(), 0);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(vFlickSpy.count(), 1);
- QCOMPARE(hFlickSpy.count(), 0);
- QCOMPARE(flickSpy.count(), 1);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20, 50));
- QTRY_VERIFY(!flickable->isFlicking());
- QVERIFY(!flickable->isFlickingVertically());
- QVERIFY(flickable->isMoving());
- QVERIFY(flickable->isMovingVertically());
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,50));
- QVERIFY(!flickable->isFlicking());
- QVERIFY(!flickable->isFlickingVertically());
- QTRY_VERIFY(!flickable->isMoving());
- QVERIFY(!flickable->isMovingVertically());
-
- delete canvas;
-}
-
-void tst_qquickflickable::disabled()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("disabled.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flick = canvas->rootObject()->findChild<QQuickFlickable*>("flickable");
- QVERIFY(flick != 0);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
-
- QTest::mouseMove(canvas, QPoint(50, 80));
- QTest::mouseMove(canvas, QPoint(50, 70));
- QTest::mouseMove(canvas, QPoint(50, 60));
-
- QVERIFY(flick->isMoving() == false);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
-
- // verify that mouse clicks on other elements still work (QTBUG-20584)
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10));
-
- QTRY_VERIFY(canvas->rootObject()->property("clicked").toBool() == true);
-}
-
-void tst_qquickflickable::flickVelocity()
-{
-#ifdef Q_OS_MAC
- QSKIP("Producing flicks on Mac CI impossible due to timing problems");
-#endif
-
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("flickable03.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- // flick up
- flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
- QVERIFY(flickable->verticalVelocity() > 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
-
- // flick down
- flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
- QVERIFY(flickable->verticalVelocity() < 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
-
- // Flick multiple times and verify that flick acceleration is applied.
- QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable);
- bool boosted = false;
- for (int i = 0; i < 6; ++i) {
- flick(canvas, QPoint(20,390), QPoint(20, 50), 200);
- boosted |= fp->flickBoost > 1.0;
- }
- QVERIFY(boosted);
-
- // Flick in opposite direction -> boost cancelled.
- flick(canvas, QPoint(20,10), QPoint(20, 340), 200);
- QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
- QVERIFY(fp->flickBoost == 1.0);
-
- delete canvas;
-}
-
-void tst_qquickflickable::margins()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("margins.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root);
- QVERIFY(obj != 0);
-
- // starting state
- QCOMPARE(obj->contentX(), -40.);
- QCOMPARE(obj->contentY(), -20.);
- QCOMPARE(obj->contentWidth(), 1600.);
- QCOMPARE(obj->contentHeight(), 600.);
- QCOMPARE(obj->xOrigin(), 0.);
- QCOMPARE(obj->yOrigin(), 0.);
-
- // Reduce left margin
- obj->setLeftMargin(30);
- QTRY_COMPARE(obj->contentX(), -30.);
-
- // Reduce top margin
- obj->setTopMargin(20);
- QTRY_COMPARE(obj->contentY(), -20.);
-
- // position to the far right, including margin
- obj->setContentX(1600 + 50 - obj->width());
- obj->returnToBounds();
- QTest::qWait(200);
- QCOMPARE(obj->contentX(), 1600. + 50. - obj->width());
-
- // position beyond the far right, including margin
- obj->setContentX(1600 + 50 - obj->width() + 1.);
- obj->returnToBounds();
- QTRY_COMPARE(obj->contentX(), 1600. + 50. - obj->width());
-
- // Reduce right margin
- obj->setRightMargin(40);
- QTRY_COMPARE(obj->contentX(), 1600. + 40. - obj->width());
- QCOMPARE(obj->contentWidth(), 1600.);
-
- // position to the far bottom, including margin
- obj->setContentY(600 + 30 - obj->height());
- obj->returnToBounds();
- QTest::qWait(200);
- QCOMPARE(obj->contentY(), 600. + 30. - obj->height());
-
- // position beyond the far bottom, including margin
- obj->setContentY(600 + 30 - obj->height() + 1.);
- obj->returnToBounds();
- QTRY_COMPARE(obj->contentY(), 600. + 30. - obj->height());
-
- // Reduce bottom margin
- obj->setBottomMargin(20);
- QTRY_COMPARE(obj->contentY(), 600. + 20. - obj->height());
- QCOMPARE(obj->contentHeight(), 600.);
-
- delete root;
-}
-
-QTEST_MAIN(tst_qquickflickable)
-
-#include "tst_qquickflickable.moc"
diff --git a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro b/tests/auto/qtquick2/qquickflipable/qquickflipable.pro
deleted file mode 100644
index 3afad837fe..0000000000
--- a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickflipable
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickflipable.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp b/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp
deleted file mode 100644
index c2c40c9746..0000000000
--- a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquickflipable_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <QFontMetrics>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <math.h>
-#include <QtOpenGL/QGLShaderProgram>
-#include "../../shared/util.h"
-
-class tst_qquickflipable : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- void create();
- void checkFrontAndBack();
- void setFrontAndBack();
-
- // below here task issues
- void QTBUG_9161_crash();
- void QTBUG_8474_qgv_abort();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qquickflipable::create()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml"));
- QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- delete obj;
-}
-
-void tst_qquickflipable::checkFrontAndBack()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml"));
- QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
- delete obj;
-}
-
-void tst_qquickflipable::setFrontAndBack()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml"));
- QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
-
- QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setFront(new QQuickRectangle());
-
- message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setBack(new QQuickRectangle());
- delete obj;
-}
-
-void tst_qquickflipable::QTBUG_9161_crash()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("crash.qml"));
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
- canvas->show();
- delete canvas;
-}
-
-void tst_qquickflipable::QTBUG_8474_qgv_abort()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("flipable-abort.qml"));
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
- canvas->show();
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickflipable)
-
-#include "tst_qquickflipable.moc"
diff --git a/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro b/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro
deleted file mode 100644
index d83f6ca7a3..0000000000
--- a/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickfocusscope
-SOURCES += tst_qquickfocusscope.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp
deleted file mode 100644
index 4264c68d92..0000000000
--- a/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp
+++ /dev/null
@@ -1,636 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qquicktextedit_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickfocusscope_p.h>
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-
-using namespace QQuickVisualTestUtil;
-
-class tst_qquickfocusscope : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickfocusscope() {}
-
-private slots:
- void basic();
- void nested();
- void noFocus();
- void textEdit();
- void forceFocus();
- void noParentFocus();
- void signalEmission();
- void qtBug13380();
- void forceActiveFocus();
- void canvasFocus();
-};
-
-void tst_qquickfocusscope::basic()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("test.qml"));
-
- QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
- QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(view->isTopLevel());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QTest::qWait(50);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QTest::qWait(50);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qquickfocusscope::nested()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("test2.qml"));
-
- QQuickFocusScope *item1 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item1"));
- QQuickFocusScope *item2 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item2"));
- QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
- QQuickFocusScope *item4 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item4"));
- QQuickFocusScope *item5 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item5"));
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
- QVERIFY(item5 != 0);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == true);
- QVERIFY(item4->hasActiveFocus() == true);
- QVERIFY(item5->hasActiveFocus() == true);
- delete view;
-}
-
-void tst_qquickfocusscope::noFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("test4.qml"));
-
- QQuickRectangle *item0 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item0"));
- QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- delete view;
-}
-
-void tst_qquickfocusscope::textEdit()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("test5.qml"));
-
- QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
- QQuickTextEdit *item1 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickTextEdit *item3 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view == qGuiApp->focusWindow());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qquickfocusscope::forceFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("forcefocus.qml"));
-
- QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
- QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
- QQuickRectangle *item4 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item4"));
- QQuickRectangle *item5 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item5"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
- QVERIFY(item5 != 0);
-
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_4);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_5);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qquickfocusscope::noParentFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("chain.qml"));
- QVERIFY(view->rootObject());
-
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(view->rootObject()->property("focus1") == false);
- QVERIFY(view->rootObject()->property("focus2") == false);
- QVERIFY(view->rootObject()->property("focus3") == true);
- QVERIFY(view->rootObject()->property("focus4") == true);
- QVERIFY(view->rootObject()->property("focus5") == true);
-
- delete view;
-}
-
-void tst_qquickfocusscope::signalEmission()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("signalEmission.qml"));
-
- QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
- QQuickRectangle *item4 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item4"));
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVariant blue(QColor("blue"));
- QVariant red(QColor("red"));
-
- item1->setFocus(true);
- QCOMPARE(item1->property("color"), red);
- QCOMPARE(item2->property("color"), blue);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- item2->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- item3->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), red);
- QCOMPARE(item4->property("color"), blue);
-
- item4->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), red);
-
- item4->setFocus(false);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- delete view;
-}
-
-void tst_qquickfocusscope::qtBug13380()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("qtBug13380.qml"));
-
- view->show();
- QVERIFY(view->rootObject());
- view->requestActivateWindow();
- qApp->processEvents();
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view == qGuiApp->focusWindow());
- QVERIFY(view->rootObject()->property("noFocus").toBool());
-
- view->rootObject()->setProperty("showRect", true);
- QVERIFY(view->rootObject()->property("noFocus").toBool());
-
- delete view;
-}
-
-void tst_qquickfocusscope::forceActiveFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("forceActiveFocus.qml"));
-
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QQuickItem *rootObject = view->rootObject();
- QVERIFY(rootObject);
-
- QQuickItem *scope = findItem<QQuickItem>(rootObject, QLatin1String("scope"));
- QQuickItem *itemA1 = findItem<QQuickItem>(rootObject, QLatin1String("item-a1"));
- QQuickItem *scopeA = findItem<QQuickItem>(rootObject, QLatin1String("scope-a"));
- QQuickItem *itemA2 = findItem<QQuickItem>(rootObject, QLatin1String("item-a2"));
- QQuickItem *itemB1 = findItem<QQuickItem>(rootObject, QLatin1String("item-b1"));
- QQuickItem *scopeB = findItem<QQuickItem>(rootObject, QLatin1String("scope-b"));
- QQuickItem *itemB2 = findItem<QQuickItem>(rootObject, QLatin1String("item-b2"));
-
- QVERIFY(scope);
- QVERIFY(itemA1);
- QVERIFY(scopeA);
- QVERIFY(itemA2);
- QVERIFY(itemB1);
- QVERIFY(scopeB);
- QVERIFY(itemB2);
-
- QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool)));
-
- // First, walk the focus from item-a1 down to item-a2 and back again
- itemA1->forceActiveFocus();
- QVERIFY(itemA1->hasActiveFocus());
- QVERIFY(!rootObject->hasActiveFocus());
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA2->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA1->forceActiveFocus();
- QVERIFY(itemA1->hasActiveFocus());
- QVERIFY(!scopeA->hasActiveFocus());
- QVERIFY(!itemA2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 2);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- // Then jump back and forth between branch 'a' and 'b'
- itemB1->forceActiveFocus();
- QVERIFY(itemB1->hasActiveFocus());
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(!itemB1->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 3);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeB->forceActiveFocus();
- QVERIFY(!scopeA->hasActiveFocus());
- QVERIFY(!itemB1->hasActiveFocus());
- QVERIFY(scopeB->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 4);
- QCOMPARE(scopeBSpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA2->forceActiveFocus();
- QVERIFY(!scopeB->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 5);
- QCOMPARE(scopeBSpy.count(), 2);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemB2->forceActiveFocus();
- QVERIFY(!itemA2->hasActiveFocus());
- QVERIFY(itemB2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 6);
- QCOMPARE(scopeBSpy.count(), 3);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- delete view;
-}
-
-void tst_qquickfocusscope::canvasFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("canvasFocus.qml"));
-
- QQuickView alternateView;
-
- QQuickItem *rootObject = view->rootObject();
- QVERIFY(rootObject);
-
- QQuickItem *rootItem = view->rootItem();
- QQuickItem *scope1 = findItem<QQuickItem>(rootObject, QLatin1String("scope1"));
- QQuickItem *item1 = findItem<QQuickItem>(rootObject, QLatin1String("item1"));
- QQuickItem *scope2 = findItem<QQuickItem>(rootObject, QLatin1String("scope2"));
- QQuickItem *item2 = findItem<QQuickItem>(rootObject, QLatin1String("item2"));
-
- QVERIFY(scope1);
- QVERIFY(item1);
- QVERIFY(scope2);
- QVERIFY(item2);
-
- QSignalSpy rootFocusSpy(rootItem, SIGNAL(focusChanged(bool)));
- QSignalSpy scope1FocusSpy(scope1, SIGNAL(focusChanged(bool)));
- QSignalSpy item1FocusSpy(item1, SIGNAL(focusChanged(bool)));
- QSignalSpy scope2FocusSpy(scope2, SIGNAL(focusChanged(bool)));
- QSignalSpy item2FocusSpy(item2, SIGNAL(focusChanged(bool)));
- QSignalSpy rootActiveFocusSpy(rootItem, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scope1ActiveFocusSpy(scope1, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy item1ActiveFocusSpy(item1, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scope2ActiveFocusSpy(scope2, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool)));
-
- QEXPECT_FAIL("", "QTBUG-22415", Abort);
- QCOMPARE(rootItem->hasFocus(), false);
- QCOMPARE(rootItem->hasActiveFocus(), false);
- QCOMPARE(scope1->hasFocus(), true);
- QCOMPARE(scope1->hasActiveFocus(), false);
- QCOMPARE(item1->hasFocus(), true);
- QCOMPARE(item1->hasActiveFocus(), false);
- QCOMPARE(scope2->hasFocus(), false);
- QCOMPARE(scope2->hasActiveFocus(), false);
- QCOMPARE(item2->hasFocus(), false);
- QCOMPARE(item2->hasActiveFocus(), false);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- // Now the canvas has focus, active focus given to item1
- QCOMPARE(rootItem->hasFocus(), true);
- QCOMPARE(rootItem->hasActiveFocus(), true);
- QCOMPARE(scope1->hasFocus(), true);
- QCOMPARE(scope1->hasActiveFocus(), true);
- QCOMPARE(item1->hasFocus(), true);
- QCOMPARE(item1->hasActiveFocus(), true);
- QCOMPARE(scope2->hasFocus(), false);
- QCOMPARE(scope2->hasActiveFocus(), false);
- QCOMPARE(item2->hasFocus(), false);
- QCOMPARE(item2->hasActiveFocus(), false);
-
- QCOMPARE(rootFocusSpy.count(), 1);
- QCOMPARE(rootActiveFocusSpy.count(), 1);
- QCOMPARE(scope1FocusSpy.count(), 0);
- QCOMPARE(scope1ActiveFocusSpy.count(), 1);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 1);
-
-
- // view->hide(); // seemingly doesn't remove focus, so have an another view steal it.
- alternateView.show();
- alternateView.requestActivateWindow();
- QTest::qWaitForWindowShown(&alternateView);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &alternateView);
-
- QCOMPARE(rootItem->hasFocus(), false);
- QCOMPARE(rootItem->hasActiveFocus(), false);
- QCOMPARE(scope1->hasFocus(), true);
- QCOMPARE(scope1->hasActiveFocus(), false);
- QCOMPARE(item1->hasFocus(), true);
- QCOMPARE(item1->hasActiveFocus(), false);
-
- QCOMPARE(rootFocusSpy.count(), 2);
- QCOMPARE(rootActiveFocusSpy.count(), 2);
- QCOMPARE(scope1FocusSpy.count(), 0);
- QCOMPARE(scope1ActiveFocusSpy.count(), 2);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 2);
-
-
- // canvas does not have focus, so item2 will not get active focus
- item2->forceActiveFocus();
-
- QCOMPARE(rootItem->hasFocus(), false);
- QCOMPARE(rootItem->hasActiveFocus(), false);
- QCOMPARE(scope1->hasFocus(), false);
- QCOMPARE(scope1->hasActiveFocus(), false);
- QCOMPARE(item1->hasFocus(), true);
- QCOMPARE(item1->hasActiveFocus(), false);
- QCOMPARE(scope2->hasFocus(), true);
- QCOMPARE(scope2->hasActiveFocus(), false);
- QCOMPARE(item2->hasFocus(), true);
- QCOMPARE(item2->hasActiveFocus(), false);
-
- QCOMPARE(rootFocusSpy.count(), 2);
- QCOMPARE(rootActiveFocusSpy.count(), 2);
- QCOMPARE(scope1FocusSpy.count(), 1);
- QCOMPARE(scope1ActiveFocusSpy.count(), 2);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 2);
- QCOMPARE(scope2FocusSpy.count(), 1);
- QCOMPARE(scope2ActiveFocusSpy.count(), 0);
- QCOMPARE(item2FocusSpy.count(), 1);
- QCOMPARE(item2ActiveFocusSpy.count(), 0);
-
- // give the canvas focus, and item2 will get active focus
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(QGuiApplication::focusWindow() == view);
-
- QCOMPARE(rootItem->hasFocus(), true);
- QCOMPARE(rootItem->hasActiveFocus(), true);
- QCOMPARE(scope2->hasFocus(), true);
- QCOMPARE(scope2->hasActiveFocus(), true);
- QCOMPARE(item2->hasFocus(), true);
- QCOMPARE(item2->hasActiveFocus(), true);
- QCOMPARE(rootFocusSpy.count(), 3);
- QCOMPARE(rootActiveFocusSpy.count(), 3);
- QCOMPARE(scope2FocusSpy.count(), 1);
- QCOMPARE(scope2ActiveFocusSpy.count(), 1);
- QCOMPARE(item2FocusSpy.count(), 1);
- QCOMPARE(item2ActiveFocusSpy.count(), 1);
-
- delete view;
-}
-
-QTEST_MAIN(tst_qquickfocusscope)
-
-#include "tst_qquickfocusscope.moc"
diff --git a/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml
deleted file mode 100644
index faea02a50d..0000000000
--- a/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml
+++ /dev/null
@@ -1,129 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 550
- height: 600
-
- property int duration: 10
- property int count: grid.count
-
- Component {
- id: myDelegate
-
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- width: 80
- height: 60
- border.width: 1
- Column {
- Text { text: index }
- Text {
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- id: textName
- objectName: "textName"
- text: name
- }
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionFrom)
- model_targetItems_transitionFrom.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
-
- GridView {
- id: grid
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- anchors.centerIn: parent
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- add: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
- NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
- }
-
- ScriptAction { script: grid.targetTransitionsDone += 1 }
- }
- }
-
- addDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
- NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: grid.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: grid
- color: "lightsteelblue"
- opacity: 0.2
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml
deleted file mode 100644
index 3599dcfea0..0000000000
--- a/tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml
+++ /dev/null
@@ -1,143 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: grid.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- width: 80
- height: 60
- border.width: 1
- Column {
- Text { text: index }
- Text {
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- id: textName
- objectName: "textName"
- text: name
- }
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionVia)
- model_targetItems_transitionVia.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
-
- GridView {
- id: grid
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- anchors.centerIn: parent
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- move: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; to: targetItems_transitionVia.x; duration: root.duration }
- NumberAnimation { properties: "y"; to: targetItems_transitionVia.y; duration: root.duration }
- }
-
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: grid.targetTransitionsDone += 1 }
- }
- }
-
- moveDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation {
- properties: "x"; duration: root.duration
- to: displacedItems_transitionVia.x
- }
- NumberAnimation {
- properties: "y"; duration: root.duration
- to: displacedItems_transitionVia.y
- }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: grid.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: grid
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml
deleted file mode 100644
index b07a03580a..0000000000
--- a/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml
+++ /dev/null
@@ -1,146 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: grid.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- width: 80
- height: 60
- border.width: 1
- Column {
- Text { text: index }
- Text {
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- id: textName
- objectName: "textName"
- text: name
- }
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionTo) {
- model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item
- }
- if (Qt.point(x, y) == displacedItems_transitionVia) {
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
- }
-
- GridView {
- id: grid
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- anchors.centerIn: parent
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- remove: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; to: targetItems_transitionTo.x; duration: root.duration }
- NumberAnimation { properties: "y"; to: targetItems_transitionTo.y; duration: root.duration }
- }
- ScriptAction { script: grid.targetTransitionsDone += 1 }
-
- // delay deleting this item so that it stays valid for the tests
- // (this doesn't delay the test itself)
- PauseAnimation { duration: 10000 }
- }
- }
-
- removeDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation {
- properties: "x"; duration: root.duration
- to: displacedItems_transitionVia.x
- }
- NumberAnimation {
- properties: "y"; duration: root.duration
- to: displacedItems_transitionVia.y
- }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: grid.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: grid
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquickgridview/qquickgridview.pro b/tests/auto/qtquick2/qquickgridview/qquickgridview.pro
deleted file mode 100644
index 583aedae8c..0000000000
--- a/tests/auto/qtquick2/qquickgridview/qquickgridview.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickgridview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickgridview.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib widgets
diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp
deleted file mode 100644
index 077cd2b26a..0000000000
--- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp
+++ /dev/null
@@ -1,5310 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtCore/qstringlistmodel.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquickgridview_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualitemmodel_p.h>
-#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
-#include <QtDeclarative/private/qlistmodelinterface_p.h>
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-#include <QtGui/qguiapplication.h>
-
-Q_DECLARE_METATYPE(Qt::LayoutDirection)
-Q_DECLARE_METATYPE(QQuickGridView::Flow)
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-class tst_QQuickGridView : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickGridView();
-
-private slots:
- void items();
- void changed();
- void inserted();
- void inserted_more();
- void inserted_more_data();
- void insertBeforeVisible();
- void insertBeforeVisible_data();
- void removed();
- void removed_more();
- void removed_more_data();
- void addOrRemoveBeforeVisible();
- void addOrRemoveBeforeVisible_data();
- void clear();
- void moved();
- void moved_data();
- void multipleChanges();
- void multipleChanges_data();
- void swapWithFirstItem();
- void changeFlow();
- void currentIndex();
- void noCurrentIndex();
- void defaultValues();
- void properties();
- void propertyChanges();
- void componentChanges();
- void modelChanges();
- void positionViewAtIndex();
- void positionViewAtIndex_rightToLeft();
- void mirroring();
- void snapping();
- void resetModel();
- void enforceRange();
- void enforceRange_rightToLeft();
- void QTBUG_8456();
- void manualHighlight();
- void footer();
- void footer_data();
- void header();
- void header_data();
- void resizeViewAndRepaint();
- void changeColumnCount();
- void indexAt_itemAt_data();
- void indexAt_itemAt();
- void onAdd();
- void onAdd_data();
- void onRemove();
- void onRemove_data();
- void columnCount();
- void margins();
- void creationContext();
- void snapToRow_data();
- void snapToRow();
- void snapOneRow_data();
- void snapOneRow();
- void unaligned();
- void cacheBuffer();
- void asynchronous();
- void unrequestedVisibility();
-
- void populateTransitions();
- void populateTransitions_data();
- void addTransitions();
- void addTransitions_data();
- void moveTransitions();
- void moveTransitions_data();
- void removeTransitions();
- void removeTransitions_data();
- void displacedTransitions();
- void displacedTransitions_data();
- void multipleTransitions();
- void multipleTransitions_data();
-
-private:
- QList<int> toIntList(const QVariantList &list);
- void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
- void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
- void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
-};
-
-tst_QQuickGridView::tst_QQuickGridView()
-{
-}
-
-void tst_QQuickGridView::items()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->count(), model.count());
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- for (int i = 0; i < model.count(); ++i) {
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // set an empty model and confirm that items are destroyed
- QaimModel model2;
- ctxt->setContextProperty("testModel", &model2);
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(itemCount == 0);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::changed()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickFlickable *gridview = findItem<QQuickFlickable>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.modifyItem(1, "Will", "9876");
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- delete canvas;
-}
-
-void tst_QQuickGridView::inserted()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.insertItem(1, "Will", "9876");
-
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Checks that onAdd is called
- int added = canvas->rootObject()->property("added").toInt();
- QTRY_COMPARE(added, 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- QTRY_COMPARE(gridview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
-
- gridview->setContentY(120);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
-
- QTRY_VERIFY(gridview->contentY() == 120);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::inserted_more()
-{
- QFETCH(qreal, contentY);
- QFETCH(int, insertIndex);
- QFETCH(int, insertCount);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QList<QPair<QString, QString> > newData;
- for (int i=0; i<insertCount; i++)
- newData << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.insertItems(insertIndex, newData);
- QTRY_COMPARE(gridview->property("count").toInt(), model.count());
-
- // check visibleItems.first() is in correct position
- QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item0);
- QCOMPARE(item0->y(), 0.0);
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QQuickText *name;
- QQuickText *number;
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
-
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
-
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::inserted_more_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("insertIndex");
- QTest::addColumn<int>("insertCount");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- QTest::newRow("add 1, before visible items")
- << 120.0 // show 6-23
- << 5 << 1
- << 0.0; // insert 1 above first visible, grid is rearranged; first visible moves forward within its row
- // new 1st visible item is at 0
-
- QTest::newRow("add 2, before visible items")
- << 120.0 // show 6-23
- << 5 << 2
- << 0.0; // insert 2 above first visible, grid is rearranged; first visible moves forward within its row
-
- QTest::newRow("add 3, before visible items")
- << 120.0 // show 6-23
- << 5 << 3
- << -60.0; // insert 3 (1 row) above first visible in negative pos, first visible does not move
-
- QTest::newRow("add 5, before visible items")
- << 120.0 // show 6-23
- << 5 << 5
- << -60.0; // insert 1 row + 2 items above first visible, 1 row added at negative pos,
- // grid is rearranged and first visible moves forward within its row
-
- QTest::newRow("add 6, before visible items")
- << 120.0 // show 6-23
- << 5 << 6
- << -60.0 * 2; // insert 2 rows above first visible in negative pos, first visible does not move
-
-
-
- QTest::newRow("add 1, at start of visible, content at start")
- << 0.0
- << 0 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at start of visible, content at start")
- << 0.0
- << 0 << 3
- << 0.0;
-
- QTest::newRow("add 1, at start of visible, content not at start")
- << 120.0 // show 6-23
- << 6 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at start of visible, content not at start")
- << 120.0 // show 6-23
- << 6 << 3
- << 0.0;
-
-
- QTest::newRow("add 1, at end of visible, content at start")
- << 0.0
- << 17 << 1
- << 0.0;
-
- QTest::newRow("add 1, at end of visible, content at start")
- << 0.0
- << 17 << 3
- << 0.0;
-
- QTest::newRow("add 1, at end of visible, content not at start")
- << 120.0 // show 6-23
- << 23 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at end of visible, content not at start")
- << 120.0 // show 6-23
- << 23 << 3
- << 0.0;
-
-
- QTest::newRow("add 1, after visible, content at start")
- << 0.0
- << 20 << 1
- << 0.0;
-
- QTest::newRow("add 1, after visible, content at start")
- << 0.0
- << 20 << 3
- << 0.0;
-
- QTest::newRow("add 1, after visible, content not at start")
- << 120.0 // show 6-23
- << 24 << 1
- << 0.0;
-
- QTest::newRow("add multiple, after visible, content not at start")
- << 120.0 // show 6-23
- << 24 << 3
- << 0.0;
-}
-
-void tst_QQuickGridView::insertBeforeVisible()
-{
- QFETCH(int, insertIndex);
- QFETCH(int, insertCount);
- QFETCH(int, cacheBuffer);
-
- QQuickText *name;
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- gridview->setCacheBuffer(cacheBuffer);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // trigger a refill (not just setting contentY) so that the visibleItems grid is updated
- int firstVisibleIndex = 12; // move to an index where the top item is not visible
- gridview->setContentY(firstVisibleIndex/3 * 60.0);
- gridview->setCurrentIndex(firstVisibleIndex);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QTRY_COMPARE(gridview->currentIndex(), firstVisibleIndex);
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
- QVERIFY(item);
- QCOMPARE(item->y(), gridview->contentY());
-
- QList<QPair<QString, QString> > newData;
- for (int i=0; i<insertCount; i++)
- newData << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.insertItems(insertIndex, newData);
- QTRY_COMPARE(gridview->property("count").toInt(), model.count());
-
- // now, moving to the top of the view should position the inserted items correctly
- int itemsOffsetAfterMove = (insertCount / 3) * -60.0;
- gridview->setCurrentIndex(0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::insertBeforeVisible_data()
-{
- QTest::addColumn<int>("insertIndex");
- QTest::addColumn<int>("insertCount");
- QTest::addColumn<int>("cacheBuffer");
-
- QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0;
- QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100;
- QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500;
-
- QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0;
- QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100;
- QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500;
-
- QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 6 << 0;
- QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 6 << 100;
- QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 6 << 500;
-
- QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 6 << 0;
- QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 6 << 100;
- QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 6 << 500;
-}
-
-void tst_QQuickGridView::removed()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- model.removeItem(1);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
-
- // Checks that onRemove is called
- QString removed = canvas->rootObject()->property("removed").toString();
- QTRY_COMPARE(removed, QString("Item1"));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items not visible
- model.removeItem(25);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items before visible
- gridview->setContentY(120);
- gridview->setCurrentIndex(10);
-
- // Setting currentIndex above shouldn't cause view to scroll
- QTRY_COMPARE(gridview->contentY(), 120.0);
-
- model.removeItem(1);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- // Confirm items positioned correctly
- for (int i = 6; i < 18; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove currentIndex
- QQuickItem *oldCurrent = gridview->currentItem();
- model.removeItem(9);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QTRY_COMPARE(gridview->currentIndex(), 9);
- QTRY_VERIFY(gridview->currentItem() != oldCurrent);
-
- gridview->setContentY(0);
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // remove item outside current view.
- gridview->setCurrentIndex(32);
- gridview->setContentY(240);
-
- model.removeItem(30);
- QTRY_VERIFY(gridview->currentIndex() == 31);
-
- // remove current item beyond visible items.
- gridview->setCurrentIndex(20);
- gridview->setContentY(0);
- model.removeItem(20);
-
- QTRY_COMPARE(gridview->currentIndex(), 20);
- QTRY_VERIFY(gridview->currentItem() != 0);
-
- // remove item before current, but visible
- gridview->setCurrentIndex(8);
- gridview->setContentY(240);
- oldCurrent = gridview->currentItem();
- model.removeItem(6);
-
- QTRY_COMPARE(gridview->currentIndex(), 7);
- QTRY_VERIFY(gridview->currentItem() == oldCurrent);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::removed_more()
-{
- QFETCH(qreal, contentY);
- QFETCH(int, removeIndex);
- QFETCH(int, removeCount);
- QFETCH(qreal, itemsOffsetAfterMove);
- QFETCH(QString, firstVisible);
-
- QQuickText *name;
- QQuickText *number;
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- model.removeItems(removeIndex, removeCount);
- QTRY_COMPARE(gridview->property("count").toInt(), model.count());
-
- QString firstName;
- int firstVisibleIndex = -1;
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- QDeclarativeExpression en(qmlContext(items[i]), items[i], "name");
- firstName = en.evaluate().toString();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
- QCOMPARE(firstName, firstVisible);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
-
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
-
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::removed_more_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("removeIndex");
- QTest::addColumn<int>("removeCount");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
- QTest::addColumn<QString>("firstVisible");
-
- QTest::newRow("remove 1, before visible items")
- << 120.0 // show 6-23
- << 2 << 1
- << 0.0 << "Item7";
-
- QTest::newRow("remove 1, before visible position")
- << 120.0 // show 6-23
- << 3 << 1
- << 0.0 << "Item7";
-
- QTest::newRow("remove multiple, all before visible items")
- << 120.0
- << 1 << 3
- << 60.0 << "Item6"; // removed top row, slide down by 1 row
-
- QTest::newRow("remove multiple, all before visible items, remove item 0")
- << 120.0
- << 0 << 4
- << 60.0 << "Item7"; // removed top row, slide down by 1 row
-
- QTest::newRow("remove multiple rows, all before visible items")
- << 240.0 // show 12-29
- << 1 << 7
- << 120.0 << "Item13";
-
- QTest::newRow("remove one row before visible, content y not on item border")
- << 100.0
- << 0 << 3
- << 60.0 << "Item6"; // 1 row removed
-
- QTest::newRow("remove mix of visible/non-visible")
- << 120.0 // show 6-23
- << 2 << 3
- << 60.0 << "Item6"; // 1 row removed
-
-
- // remove 3,4,5 before the visible pos, first row moves down to just before the visible pos,
- // items 6,7 are removed from view, item 8 slides up to original pos of item 6 (120px)
- QTest::newRow("remove multiple, mix of items from before and within visible items")
- << 120.0
- << 3 << 5
- << 60.0 << "Item8"; // adjust for the 1 row removed before the visible
-
- QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0")
- << 120.0
- << 0 << 8
- << 60.0 * 2 << "Item8"; // adjust for the 2 rows removed before the visible
-
-
- QTest::newRow("remove 1, from start of visible, content at start")
- << 0.0
- << 0 << 1
- << 0.0 << "Item1";
-
- QTest::newRow("remove multiple, from start of visible, content at start")
- << 0.0
- << 0 << 3
- << 0.0 << "Item3";
-
- QTest::newRow("remove 1, from start of visible, content not at start")
- << 120.0 // show 6-23
- << 4 << 1
- << 0.0 << "Item7";
-
- QTest::newRow("remove multiple, from start of visible, content not at start")
- << 120.0 // show 6-23
- << 4 << 3
- << 0.0 << "Item9";
-
-
- QTest::newRow("remove 1, from middle of visible, content at start")
- << 0.0
- << 10 << 1
- << 0.0 << "Item0";
-
- QTest::newRow("remove multiple, from middle of visible, content at start")
- << 0.0
- << 10 << 5
- << 0.0 << "Item0";
-
- QTest::newRow("remove 1, from middle of visible, content not at start")
- << 120.0 // show 6-23
- << 10 << 1
- << 0.0 << "Item6";
-
- QTest::newRow("remove multiple, from middle of visible, content not at start")
- << 120.0 // show 6-23
- << 10 << 5
- << 0.0 << "Item6";
-
-
- QTest::newRow("remove 1, after visible, content at start")
- << 0.0
- << 16 << 1
- << 0.0 << "Item0";
-
- QTest::newRow("remove multiple, after visible, content at start")
- << 0.0
- << 16 << 5
- << 0.0 << "Item0";
-
- QTest::newRow("remove 1, after visible, content not at start")
- << 120.0 // show 6-23
- << 16+4 << 1
- << 0.0 << "Item6";
-
- QTest::newRow("remove multiple, after visible, content not at start")
- << 120.0 // show 6-23
- << 16+4 << 5
- << 0.0 << "Item6";
-
- QTest::newRow("remove multiple, mix of items from within and after visible items")
- << 120.0 // show 6-23
- << 20 << 5
- << 0.0 << "Item6";
-}
-
-void tst_QQuickGridView::addOrRemoveBeforeVisible()
-{
- // QTBUG-21588: ensure re-layout is done on grid after adding or removing
- // items from before the visible area
-
- QFETCH(bool, doAdd);
- QFETCH(qreal, newTopContentY);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(testFileUrl("gridview1.qml"));
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_COMPARE(name->text(), QString("Item0"));
-
- gridview->setCurrentIndex(0);
- qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // scroll down until item 0 is no longer drawn
- // (bug not triggered if we just move using content y, since that doesn't
- // refill and change the visible items)
- gridview->setCurrentIndex(24);
- qApp->processEvents();
-
- QTRY_COMPARE(gridview->currentIndex(), 24);
- QTRY_COMPARE(gridview->contentY(), 220.0);
-
- QTest::qWait(100); // wait for refill to complete
- QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 0)); // 0 shouldn't be visible
-
- if (doAdd) {
- model.insertItem(0, "New Item", "New Item number");
- QTRY_COMPARE(gridview->count(), 31);
- } else {
- model.removeItem(0);
- QTRY_COMPARE(gridview->count(), 29);
- }
-
- // scroll back up and item 0 should be gone
- gridview->setCurrentIndex(0);
- qApp->processEvents();
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->contentY(), newTopContentY);
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- if (doAdd)
- QCOMPARE(name->text(), QString("New Item"));
- else
- QCOMPARE(name->text(), QString("Item1"));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", i));
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60 + newTopContentY);
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::addOrRemoveBeforeVisible_data()
-{
- QTest::addColumn<bool>("doAdd");
- QTest::addColumn<qreal>("newTopContentY");
-
- QTest::newRow("add") << true << -60.0;
- QTest::newRow("remove") << false << -60.0;
-}
-
-void tst_QQuickGridView::clear()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- model.clear();
-
- QVERIFY(gridview->count() == 0);
- QVERIFY(gridview->currentItem() == 0);
- QVERIFY(gridview->contentY() == 0);
- QVERIFY(gridview->currentIndex() == -1);
-
- // confirm sanity when adding an item to cleared list
- model.addItem("New", "1");
- QTRY_COMPARE(gridview->count(), 1);
- QVERIFY(gridview->currentItem() != 0);
- QVERIFY(gridview->currentIndex() == 0);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::moved()
-{
- QFETCH(qreal, contentY);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- QQuickText *name;
- QQuickText *number;
- QScopedPointer<QQuickView> canvas(createView());
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *currentItem = gridview->currentItem();
- QTRY_VERIFY(currentItem != 0);
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- model.moveItems(from, to, count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // Confirm items positioned correctly and indexes correct
- int firstVisibleIndex = qCeil(contentY / 60.0) * 3;
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- if (i >= firstVisibleIndex + 18) // index has moved out of view
- continue;
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
-
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
-
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
-
- // current index should have been updated
- if (item == currentItem)
- QTRY_COMPARE(gridview->currentIndex(), i);
- }
-}
-
-void tst_QQuickGridView::moved_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- // model starts with 30 items, each 80x60, in area 240x320
- // 18 items should be visible at a time
-
- // The first visible item should not move upwards and out of the view
- // if items are moved/removed before it.
-
-
- QTest::newRow("move 1 forwards, within visible items")
- << 0.0
- << 1 << 8 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from non-visible -> visible")
- << 120.0 // show 6-23
- << 1 << 23 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)")
- << 120.0 // // show 6-23
- << 0 << 6 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from visible -> non-visible")
- << 0.0
- << 1 << 20 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)")
- << 0.0
- << 0 << 20 << 1
- << 0.0;
-
-
- QTest::newRow("move 1 backwards, within visible items")
- << 0.0
- << 10 << 5 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, within visible items (to first index)")
- << 0.0
- << 10 << 0 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from non-visible -> visible")
- << 0.0
- << 28 << 8 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)")
- << 0.0
- << 29 << 14 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from visible -> non-visible")
- << 120.0 // show 6-23
- << 7 << 1 << 1
- << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move
-
- QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)")
- << 120.0 // show 6-23
- << 7 << 0 << 1
- << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move
-
-
- QTest::newRow("move multiple forwards, within visible items")
- << 0.0
- << 0 << 5 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, within visible items (move first item)")
- << 0.0
- << 10 << 0 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, before visible items")
- << 120.0 // show 6-23
- << 3 << 4 << 3 // 3, 4, 5 move to after 6
- << 60.0; // row of 3,4,5 has moved down
-
- QTest::newRow("move multiple forwards, from non-visible -> visible")
- << 120.0 // show 6-23
- << 1 << 6 << 3
- << 60.0; // 1st row (it's above visible area) disappears, 0 drops down 1 row, first visible item (6) stays where it is
-
- QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)")
- << 120.0 // show 6-23
- << 0 << 6 << 3
- << 60.0; // top row moved and shifted to below 3rd row, all items should shift down by 1 row
-
- QTest::newRow("move multiple forwards, mix of non-visible/visible")
- << 120.0
- << 3 << 16 << 6
- << 60.0; // top two rows removed, third row is now the first visible
-
- QTest::newRow("move multiple forwards, to bottom of view")
- << 0.0
- << 5 << 13 << 5
- << 0.0;
-
- QTest::newRow("move multiple forwards, to bottom of view, first row -> last")
- << 0.0
- << 0 << 15 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
- << 120.0
- << 5+4 << 13+4 << 5
- << 0.0;
-
- QTest::newRow("move multiple forwards, from visible -> non-visible")
- << 0.0
- << 1 << 16 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)")
- << 0.0
- << 0 << 16 << 3
- << 0.0;
-
-
- QTest::newRow("move multiple backwards, within visible items")
- << 0.0
- << 4 << 1 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from non-visible -> visible")
- << 0.0
- << 20 << 4 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)")
- << 0.0
- << 27 << 10 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from visible -> non-visible")
- << 120.0 // show 6-23
- << 16 << 1 << 3
- << -60.0; // to minimize movement, items are added above visible area, all items move up by 1 row
-
- QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)")
- << 120.0 // show 6-23
- << 16 << 0 << 3
- << -60.0; // 16,17,18 move to above item 0, all items move up by 1 row
-}
-
-void tst_QQuickGridView::multipleChanges()
-{
- QSKIP("QTBUG-24523");
-
- QFETCH(int, startCount);
- QFETCH(QList<ListChange>, changes);
- QFETCH(int, newCount);
- QFETCH(int, newCurrentIndex);
-
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < startCount; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- for (int i=0; i<changes.count(); i++) {
- switch (changes[i].type) {
- case ListChange::Inserted:
- {
- QList<QPair<QString, QString> > items;
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- items << qMakePair(QString("new item " + j), QString::number(j));
- model.insertItems(changes[i].index, items);
- break;
- }
- case ListChange::Removed:
- model.removeItems(changes[i].index, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::Moved:
- model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::SetCurrent:
- gridview->setCurrentIndex(changes[i].index);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::SetContentY:
- gridview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- }
- }
-
- QTRY_COMPARE(gridview->count(), newCount);
- QCOMPARE(gridview->count(), model.count());
- QTRY_COMPARE(gridview->currentIndex(), newCurrentIndex);
-
- QQuickText *name;
- QQuickText *number;
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::multipleChanges_data()
-{
- QTest::addColumn<int>("startCount");
- QTest::addColumn<QList<ListChange> >("changes");
- QTest::addColumn<int>("newCount");
- QTest::addColumn<int>("newCurrentIndex");
-
- QList<ListChange> changes;
-
- for (int i=1; i<30; i++)
- changes << ListChange::remove(0);
- QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0;
-
- changes << ListChange::remove(0);
- QTest::newRow("remove all") << 30 << changes << 0 << -1;
-
- changes.clear();
- changes << ListChange::setCurrent(29);
- for (int i=29; i>0; i--)
- changes << ListChange::remove(i);
- QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0;
-
- QTest::newRow("remove then insert at 0") << 10 << (QList<ListChange>()
- << ListChange::remove(0, 1)
- << ListChange::insert(0, 1)
- ) << 10 << 1;
-
- QTest::newRow("remove then insert at non-zero index") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::remove(2, 1)
- << ListChange::insert(2, 1)
- ) << 10 << 3;
-
- QTest::newRow("remove current then insert below it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::remove(1, 3)
- << ListChange::insert(2, 2)
- ) << 9 << 1;
-
- QTest::newRow("remove current index then move it down") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::remove(1, 3)
- << ListChange::move(1, 5, 1)
- ) << 7 << 5;
-
- QTest::newRow("remove current index then move it up") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::remove(4, 3)
- << ListChange::move(4, 1, 1)
- ) << 7 << 1;
-
-
- QTest::newRow("insert multiple times") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 2)
- << ListChange::insert(0, 4)
- << ListChange::insert(0, 6)
- ) << 12 << 10;
-
- QTest::newRow("insert multiple times with current index changes") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 2)
- << ListChange::insert(0, 4)
- << ListChange::insert(0, 6)
- << ListChange::setCurrent(3)
- << ListChange::insert(3, 2)
- ) << 14 << 5;
-
- QTest::newRow("insert and remove all") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 30)
- << ListChange::remove(0, 30)
- ) << 0 << -1;
-
- QTest::newRow("insert and remove current") << 30 << (QList<ListChange>()
- << ListChange::insert(1)
- << ListChange::setCurrent(1)
- << ListChange::remove(1)
- ) << 30 << 1;
-
- QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 10)
- << ListChange::remove(5, 10)
- ) << 10 << 5;
-
- QTest::newRow("insert multiple, then move new items to end") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 3)
- << ListChange::move(0, 10, 3)
- ) << 13 << 0;
-
- QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 3)
- << ListChange::move(0, 8, 5)
- ) << 13 << 11;
-
- QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(9)
- << ListChange::insert(10, 3)
- << ListChange::move(8, 0, 5)
- ) << 13 << 1;
-
-
- QTest::newRow("move back and forth to same index") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::move(1, 2, 2)
- << ListChange::move(2, 1, 2)
- ) << 10 << 1;
-
- QTest::newRow("move forwards then back") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::move(1, 2, 3)
- << ListChange::move(3, 0, 5)
- ) << 10 << 0;
-
- QTest::newRow("move current, then remove it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 0, 1)
- << ListChange::remove(0)
- ) << 9 << 0;
-
- QTest::newRow("move current, then insert before it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 0, 1)
- << ListChange::insert(0)
- ) << 11 << 1;
-
- QTest::newRow("move multiple, then remove them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::move(5, 1, 3)
- << ListChange::remove(1, 3)
- ) << 7 << 1;
-
- QTest::newRow("move multiple, then insert before them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 1, 3)
- << ListChange::insert(1, 5)
- ) << 15 << 6;
-
- QTest::newRow("move multiple, then insert after them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(3)
- << ListChange::move(0, 1, 2)
- << ListChange::insert(3, 5)
- ) << 15 << 8;
-
-
- QTest::newRow("clear current") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 5)
- << ListChange::setCurrent(-1)
- << ListChange::remove(0, 5)
- << ListChange::insert(0, 5)
- ) << 5 << -1;
-}
-
-
-void tst_QQuickGridView::swapWithFirstItem()
-{
- // QTBUG_9697
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- // ensure content position is stable
- gridview->setContentY(0);
- model.moveItem(10, 0);
- QTRY_VERIFY(gridview->contentY() == 0);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::currentIndex()
-{
- QaimModel model;
- for (int i = 0; i < 60; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
- canvas->show();
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(testFile("gridview-initCurrent.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
- QTRY_VERIFY(!QQuickItemPrivate::get(gridview)->polishScheduled);
-
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- // current item should be third item
- QCOMPARE(gridview->currentIndex(), 35);
- QCOMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 35));
- QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
- QCOMPARE(gridview->contentY(), 400.0);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 36);
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), 39);
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 36);
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 35);
-
- // wait until motion stops
- QTRY_VERIFY(gridview->verticalVelocity() == 0.0);
-
- // no wrap
- gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
- // confirm that the velocity is updated
- QTRY_VERIFY(gridview->verticalVelocity() != 0.0);
-
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->setCurrentIndex(model.count()-1);
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- // with wrap
- gridview->setWrapEnabled(true);
-
- gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- qApp->processEvents();
- QTRY_COMPARE(gridview->contentY(), 880.0);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
-
- // footer should become visible if it is out of view, and then current index moves to the first row
- canvas->rootObject()->setProperty("showFooter", true);
- QTRY_VERIFY(gridview->footerItem());
- gridview->setCurrentIndex(model.count()-3);
- QTRY_VERIFY(gridview->footerItem()->y() > gridview->contentY() + gridview->height());
- gridview->setCurrentIndex(model.count()-2);
- QTRY_COMPARE(gridview->contentY() + gridview->height(), (60.0 * model.count()/3) + gridview->footerItem()->height());
- canvas->rootObject()->setProperty("showFooter", false);
-
- // header should become visible if it is out of view, and then current index moves to the last row
- canvas->rootObject()->setProperty("showHeader", true);
- QTRY_VERIFY(gridview->headerItem());
- gridview->setCurrentIndex(3);
- QTRY_VERIFY(gridview->headerItem()->y() + gridview->headerItem()->height() < gridview->contentY());
- gridview->setCurrentIndex(1);
- QTRY_COMPARE(gridview->contentY(), -gridview->headerItem()->height());
- canvas->rootObject()->setProperty("showHeader", false);
-
-
- // Test keys
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
-
- gridview->setCurrentIndex(0);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 3);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
- // hold down Key_Down
- for (int i=0; i<(model.count() / 3) - 1; i++) {
- QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true);
- QTRY_COMPARE(gridview->currentIndex(), i*3 + 3);
- }
- QTest::keyRelease(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 57);
- QTRY_COMPARE(gridview->contentY(), 880.0);
-
- // hold down Key_Up
- for (int i=(model.count() / 3) - 1; i > 0; i--) {
- QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true);
- QTRY_COMPARE(gridview->currentIndex(), i*3 - 3);
- }
- QTest::keyRelease(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
-
- gridview->setFlow(QQuickGridView::TopToBottom);
-
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(qGuiApp->focusWindow() == canvas);
- qApp->processEvents();
-
- QTest::keyClick(canvas, Qt::Key_Right);
- QCOMPARE(gridview->currentIndex(), 5);
-
- QTest::keyClick(canvas, Qt::Key_Left);
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 1);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
- // hold down Key_Right
- for (int i=0; i<(model.count() / 5) - 1; i++) {
- QTest::simulateEvent(canvas, true, Qt::Key_Right, Qt::NoModifier, "", true);
- QTRY_COMPARE(gridview->currentIndex(), i*5 + 5);
- }
-
- QTest::keyRelease(canvas, Qt::Key_Right);
- QTRY_COMPARE(gridview->currentIndex(), 55);
- QTRY_COMPARE(gridview->contentX(), 720.0);
-
- // hold down Key_Left
- for (int i=(model.count() / 5) - 1; i > 0; i--) {
- QTest::simulateEvent(canvas, true, Qt::Key_Left, Qt::NoModifier, "", true);
- QTRY_COMPARE(gridview->currentIndex(), i*5 - 5);
- }
- QTest::keyRelease(canvas, Qt::Key_Left);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->contentX(), 0.0);
-
-
- // turn off auto highlight
- gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
- QVERIFY(gridview->highlightItem());
- qreal hlPosX = gridview->highlightItem()->x();
- qreal hlPosY = gridview->highlightItem()->y();
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
- QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
-
- // insert item before currentIndex
- gridview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- gridview->setCurrentIndex(-1);
-
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->highlightItem());
- QVERIFY(!gridview->currentItem());
-
- gridview->setHighlightFollowsCurrentItem(true);
-
- gridview->setFlow(QQuickGridView::LeftToRight);
- gridview->setLayoutDirection(Qt::RightToLeft);
-
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
- qApp->processEvents();
-
- gridview->setCurrentIndex(35);
-
- QTest::keyClick(canvas, Qt::Key_Right);
- QCOMPARE(gridview->currentIndex(), 34);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 37);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 34);
-
- QTest::keyClick(canvas, Qt::Key_Left);
- QCOMPARE(gridview->currentIndex(), 35);
-
-
- // turn off auto highlight
- gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
- QVERIFY(gridview->highlightItem());
- hlPosX = gridview->highlightItem()->x();
- hlPosY = gridview->highlightItem()->y();
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
- QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
-
- // insert item before currentIndex
- gridview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- gridview->setCurrentIndex(-1);
-
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->highlightItem());
- QVERIFY(!gridview->currentItem());
-
- delete canvas;
-}
-
-void tst_QQuickGridView::noCurrentIndex()
-{
- QaimModel model;
- for (int i = 0; i < 60; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(testFile("gridview-noCurrent.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // current index should be -1
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->currentItem());
- QVERIFY(!gridview->highlightItem());
- QCOMPARE(gridview->contentY(), 0.0);
-
- gridview->setCurrentIndex(5);
- QCOMPARE(gridview->currentIndex(), 5);
- QVERIFY(gridview->currentItem());
- QVERIFY(gridview->highlightItem());
-
- delete canvas;
-}
-
-void tst_QQuickGridView::changeFlow()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i%3)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i/5)*80));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
- gridview->setContentX(100);
- QTRY_COMPARE(gridview->contentX(), 100.);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- QTRY_COMPARE(gridview->contentX(), 0.);
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("gridview3.qml"));
- QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->model() == QVariant());
- QTRY_VERIFY(obj->delegate() == 0);
- QTRY_COMPARE(obj->currentIndex(), -1);
- QTRY_VERIFY(obj->currentItem() == 0);
- QTRY_COMPARE(obj->count(), 0);
- QTRY_VERIFY(obj->highlight() == 0);
- QTRY_VERIFY(obj->highlightItem() == 0);
- QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true);
- QTRY_VERIFY(obj->flow() == 0);
- QTRY_COMPARE(obj->isWrapEnabled(), false);
- QTRY_COMPARE(obj->cacheBuffer(), 0);
- QTRY_COMPARE(obj->cellWidth(), qreal(100)); //### Should 100 be the default?
- QTRY_COMPARE(obj->cellHeight(), qreal(100));
- delete obj;
-}
-
-void tst_QQuickGridView::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("gridview2.qml"));
- QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->model() != QVariant());
- QTRY_VERIFY(obj->delegate() != 0);
- QTRY_COMPARE(obj->currentIndex(), 0);
- QTRY_VERIFY(obj->currentItem() != 0);
- QTRY_COMPARE(obj->count(), 4);
- QTRY_VERIFY(obj->highlight() != 0);
- QTRY_VERIFY(obj->highlightItem() != 0);
- QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false);
- QTRY_VERIFY(obj->flow() == 0);
- QTRY_COMPARE(obj->isWrapEnabled(), true);
- QTRY_COMPARE(obj->cacheBuffer(), 200);
- QTRY_COMPARE(obj->cellWidth(), qreal(100));
- QTRY_COMPARE(obj->cellHeight(), qreal(100));
- delete obj;
-}
-
-void tst_QQuickGridView::propertyChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged()));
- QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged()));
- QSignalSpy layoutSpy(gridView, SIGNAL(layoutDirectionChanged()));
- QSignalSpy flowSpy(gridView, SIGNAL(flowChanged()));
-
- QTRY_COMPARE(gridView->isWrapEnabled(), true);
- QTRY_COMPARE(gridView->cacheBuffer(), 10);
- QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight);
-
- gridView->setWrapEnabled(false);
- gridView->setCacheBuffer(3);
- gridView->setFlow(QQuickGridView::TopToBottom);
-
- QTRY_COMPARE(gridView->isWrapEnabled(), false);
- QTRY_COMPARE(gridView->cacheBuffer(), 3);
- QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),1);
-
- gridView->setWrapEnabled(false);
- gridView->setCacheBuffer(3);
- gridView->setFlow(QQuickGridView::TopToBottom);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),1);
-
- gridView->setFlow(QQuickGridView::LeftToRight);
- QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight);
-
- gridView->setWrapEnabled(true);
- gridView->setCacheBuffer(5);
- gridView->setLayoutDirection(Qt::RightToLeft);
-
- QTRY_COMPARE(gridView->isWrapEnabled(), true);
- QTRY_COMPARE(gridView->cacheBuffer(), 5);
- QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
- QTRY_COMPARE(cacheBufferSpy.count(),2);
- QTRY_COMPARE(layoutSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),2);
-
- gridView->setWrapEnabled(true);
- gridView->setCacheBuffer(5);
- gridView->setLayoutDirection(Qt::RightToLeft);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
- QTRY_COMPARE(cacheBufferSpy.count(),2);
- QTRY_COMPARE(layoutSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),2);
-
- gridView->setFlow(QQuickGridView::TopToBottom);
- QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom);
- QTRY_COMPARE(flowSpy.count(),3);
-
- gridView->setFlow(QQuickGridView::TopToBottom);
- QTRY_COMPARE(flowSpy.count(),3);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::componentChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QDeclarativeComponent component(canvas->engine());
- component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 1.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
-
- QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged()));
- QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged()));
- QSignalSpy headerSpy(gridView, SIGNAL(headerChanged()));
- QSignalSpy footerSpy(gridView, SIGNAL(footerChanged()));
-
- gridView->setHighlight(&component);
- gridView->setDelegate(&delegateComponent);
- gridView->setHeader(&component);
- gridView->setFooter(&component);
-
- QTRY_COMPARE(gridView->highlight(), &component);
- QTRY_COMPARE(gridView->delegate(), &delegateComponent);
- QTRY_COMPARE(gridView->header(), &component);
- QTRY_COMPARE(gridView->footer(), &component);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- gridView->setHighlight(&component);
- gridView->setDelegate(&delegateComponent);
- gridView->setHeader(&component);
- gridView->setFooter(&component);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::modelChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
- QTRY_VERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
- QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
-
- gridView->setModel(modelVariant);
- QTRY_COMPARE(gridView->model(), modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- gridView->setModel(modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- gridView->setModel(QVariant());
- QTRY_COMPARE(modelSpy.count(),2);
- delete canvas;
-}
-
-void tst_QQuickGridView::positionViewAtIndex()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on a currently visible item
- gridview->positionViewAtIndex(4, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(120, 90), 4);
- QTRY_COMPARE(gridview->contentY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item beyond the visible items
- gridview->positionViewAtIndex(21, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(40, 450), 21);
- QTRY_COMPARE(gridview->contentY(), 420.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(120, 630), 31);
- QTRY_COMPARE(gridview->contentY(), 520.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position at the beginning again
- gridview->positionViewAtIndex(0, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(0, 0), 0);
- QTRY_COMPARE(gridview->indexAt(40, 30), 0);
- QTRY_COMPARE(gridview->indexAt(80, 60), 4);
- QTRY_COMPARE(gridview->contentY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QQuickGridView::End);
- QTRY_COMPARE(gridview->contentY(), 340.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QQuickGridView::Center);
- QTRY_COMPARE(gridview->contentY(), 170.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 170.);
-
- gridview->setContentY(302);
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 302.);
-
- gridview->setContentY(360);
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 300.);
-
- gridview->setContentY(60);
- gridview->positionViewAtIndex(20, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 60.);
-
- gridview->setContentY(20);
- gridview->positionViewAtIndex(20, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- // Ensure completely visible
- gridview->setContentY(120);
- gridview->positionViewAtIndex(20, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 120.);
-
- gridview->setContentY(302);
- gridview->positionViewAtIndex(15, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 300.);
-
- gridview->setContentY(60);
- gridview->positionViewAtIndex(20, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- // Test for Top To Bottom layout
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i/5)*80.);
- QTRY_COMPARE(item->y(), (i%5)*60.);
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QQuickGridView::End);
- QTRY_COMPARE(gridview->contentX(), 320.);
- QTRY_COMPARE(gridview->contentY(), 0.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QQuickGridView::Center);
- QTRY_COMPARE(gridview->contentX(), 160.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 160.);
-
- gridview->setContentX(170);
- gridview->positionViewAtIndex(25, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 170.);
-
- gridview->positionViewAtIndex(30, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 320.);
-
- gridview->setContentX(170);
- gridview->positionViewAtIndex(25, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentX(), 240.);
-
- // positionViewAtBeginning
- gridview->positionViewAtBeginning();
- QTRY_COMPARE(gridview->contentX(), 0.);
-
- gridview->setContentX(80);
- canvas->rootObject()->setProperty("showHeader", true);
- gridview->positionViewAtBeginning();
- QTRY_COMPARE(gridview->contentX(), -30.);
-
- // positionViewAtEnd
- gridview->positionViewAtEnd();
- QTRY_COMPARE(gridview->contentX(), 400.); // 8*80 - 240 (8 columns)
-
- gridview->setContentX(80);
- canvas->rootObject()->setProperty("showFooter", true);
- gridview->positionViewAtEnd();
- QTRY_COMPARE(gridview->contentX(), 430.);
-
- // set current item to outside visible view, position at beginning
- // and ensure highlight moves to current item
- gridview->setCurrentIndex(6);
- gridview->positionViewAtBeginning();
- QTRY_COMPARE(gridview->contentX(), -30.);
- QVERIFY(gridview->highlightItem());
- QCOMPARE(gridview->highlightItem()->x(), 80.);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::snapping()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- gridview->setHeight(220);
- QCOMPARE(gridview->height(), 220.);
-
- gridview->positionViewAtIndex(12, QQuickGridView::Visible);
- QCOMPARE(gridview->contentY(), 80.);
-
- gridview->setContentY(0);
- QCOMPARE(gridview->contentY(), 0.);
-
- gridview->setSnapMode(QQuickGridView::SnapToRow);
- QCOMPARE(gridview->snapMode(), QQuickGridView::SnapToRow);
-
- gridview->positionViewAtIndex(12, QQuickGridView::Visible);
- QCOMPARE(gridview->contentY(), 60.);
-
- gridview->positionViewAtIndex(15, QQuickGridView::End);
- QCOMPARE(gridview->contentY(), 120.);
-
- delete canvas;
-
-}
-
-void tst_QQuickGridView::mirroring()
-{
- QQuickView *canvasA = createView();
- canvasA->setSource(testFileUrl("mirroring.qml"));
- QQuickGridView *gridviewA = findItem<QQuickGridView>(canvasA->rootObject(), "view");
- QTRY_VERIFY(gridviewA != 0);
-
- QQuickView *canvasB = createView();
- canvasB->setSource(testFileUrl("mirroring.qml"));
- QQuickGridView *gridviewB = findItem<QQuickGridView>(canvasB->rootObject(), "view");
- QTRY_VERIFY(gridviewA != 0);
- qApp->processEvents();
-
- QList<QString> objectNames;
- objectNames << "item1" << "item2"; // << "item3"
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
- gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
- QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection());
-
- // LTR != RTL
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
- gridviewB->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == LTR
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
-
- QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection());
- QQuickItemPrivate::get(gridviewB)->setLayoutMirror(true);
- QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection());
-
- // LTR != LTR+mirror
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL == LTR+mirror
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
-
- gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL != RTL+mirror
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == RTL+mirror
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
-
- delete canvasA;
- delete canvasB;
-}
-
-void tst_QQuickGridView::positionViewAtIndex_rightToLeft()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on a currently visible item
- gridview->positionViewAtIndex(6, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on an item beyond the visible items
- gridview->positionViewAtIndex(21, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -640.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position at the beginning again
- gridview->positionViewAtIndex(0, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -240.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QQuickGridView::End);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QQuickGridView::Center);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-555.);
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -555.);
-
- gridview->setContentX(-239);
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- gridview->setContentX(-239);
- gridview->positionViewAtIndex(20, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-640);
- gridview->positionViewAtIndex(20, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Ensure completely visible
- gridview->setContentX(-400);
- gridview->positionViewAtIndex(20, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-315);
- gridview->positionViewAtIndex(15, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- gridview->setContentX(-640);
- gridview->positionViewAtIndex(20, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::resetModel()
-{
- QQuickView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaygrid.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QTRY_COMPARE(gridview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QTRY_COMPARE(gridview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::enforceRange()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
- canvas->show();
- qApp->processEvents();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0);
- QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
- QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QTRY_VERIFY(item);
- QTRY_COMPARE(gridview->contentY(), -100.0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- gridview->setContentY(0);
- QTRY_COMPARE(gridview->currentIndex(), 2);
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- QaimModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(gridview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::enforceRange_rightToLeft()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
- qApp->processEvents();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QCOMPARE(gridview->preferredHighlightBegin(), 100.0);
- QCOMPARE(gridview->preferredHighlightEnd(), 100.0);
- QCOMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
-
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QTRY_COMPARE(gridview->contentX(), -140.);
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- gridview->setContentX(-240);
- QTRY_COMPARE(gridview->currentIndex(), 3);
-
- gridview->setCurrentIndex(7);
- QTRY_COMPARE(gridview->contentX(), -340.);
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
- QaimModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(gridview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::QTBUG_8456()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("setindex.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QTRY_COMPARE(gridview->currentIndex(), 0);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::manualHighlight()
-{
- QQuickView *canvas = createView();
-
- QString filename(testFile("manual-highlight.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->setCurrentIndex(2);
-
- QTRY_COMPARE(gridview->currentIndex(), 2);
- QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->positionViewAtIndex(8, QQuickGridView::Contain);
-
- QTRY_COMPARE(gridview->currentIndex(), 2);
- QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->setFlow(QQuickGridView::TopToBottom);
- QTRY_COMPARE(gridview->flow(), QQuickGridView::TopToBottom);
-
- gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- delete canvas;
-}
-
-
-void tst_QQuickGridView::footer()
-{
- QFETCH(QQuickGridView::Flow, flow);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(QPointF, initialFooterPos);
- QFETCH(QPointF, changedFooterPos);
- QFETCH(QPointF, initialContentPos);
- QFETCH(QPointF, changedContentPos);
- QFETCH(QPointF, firstDelegatePos);
- QFETCH(QPointF, resizeContentPos);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 7; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("footer.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
- QVERIFY(footer);
-
- QVERIFY(footer == gridview->footerItem());
-
- QCOMPARE(footer->pos(), initialFooterPos);
- QCOMPARE(footer->width(), 100.);
- QCOMPARE(footer->height(), 30.);
- QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- if (flow == QQuickGridView::LeftToRight) {
- // shrink by one row
- model.removeItem(2);
- QTRY_COMPARE(footer->y(), initialFooterPos.y() - gridview->cellHeight());
- } else {
- // shrink by one column
- model.removeItem(2);
- model.removeItem(3);
- if (layoutDirection == Qt::LeftToRight)
- QTRY_COMPARE(footer->x(), initialFooterPos.x() - gridview->cellWidth());
- else
- QTRY_COMPARE(footer->x(), initialFooterPos.x() + gridview->cellWidth());
- }
-
- // remove all items
- model.clear();
-
- QPointF posWhenNoItems(0, 0);
- if (layoutDirection == Qt::RightToLeft)
- posWhenNoItems.setX(flow == QQuickGridView::LeftToRight ? gridview->width() - footer->width() : -footer->width());
- QTRY_COMPARE(footer->pos(), posWhenNoItems);
-
- // if header is present, it's at a negative pos, so the footer should not move
- canvas->rootObject()->setProperty("showHeader", true);
- QVERIFY(findItem<QQuickItem>(contentItem, "header") != 0);
- QTRY_COMPARE(footer->pos(), posWhenNoItems);
- canvas->rootObject()->setProperty("showHeader", false);
-
- // add 30 items
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QSignalSpy footerItemSpy(gridview, SIGNAL(footerItemChanged()));
- QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
-
- QCOMPARE(footerItemSpy.count(), 1);
-
- footer = findItem<QQuickText>(contentItem, "footer");
- QVERIFY(!footer);
- footer = findItem<QQuickText>(contentItem, "footer2");
- QVERIFY(footer);
-
- QVERIFY(footer == gridview->footerItem());
-
- QCOMPARE(footer->pos(), changedFooterPos);
- QCOMPARE(footer->width(), 50.);
- QCOMPARE(footer->height(), 20.);
- QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- gridview->positionViewAtEnd();
- footer->setHeight(10);
- footer->setWidth(40);
- QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::footer_data()
-{
- QTest::addColumn<QQuickGridView::Flow>("flow");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<QPointF>("initialFooterPos");
- QTest::addColumn<QPointF>("changedFooterPos");
- QTest::addColumn<QPointF>("initialContentPos");
- QTest::addColumn<QPointF>("changedContentPos");
- QTest::addColumn<QPointF>("firstDelegatePos");
- QTest::addColumn<QPointF>("resizeContentPos");
-
- // footer1 = 100 x 30
- // footer2 = 50 x 20
- // cells = 80 * 60
- // view width = 240
- // view height = 320
-
- // footer below items, bottom left
- QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight
- << QPointF(0, 3 * 60) // 180 = height of 3 rows (cell height is 60)
- << QPointF(0, 10 * 60) // 30 items = 10 rows
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 10 * 60 - 320 + 10);
-
- // footer below items, bottom right
- QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft
- << QPointF(240 - 100, 3 * 60)
- << QPointF((240 - 100) + 50, 10 * 60) // 50 = width diff between old and new footers
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(240 - 80, 0)
- << QPointF(0, 10 * 60 - 320 + 10);
-
- // footer to right of items
- QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight
- << QPointF(2 * 80, 0) // 2 columns, cell width 80
- << QPointF(6 * 80, 0) // 30 items = 6 columns
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(6 * 80 - 240 + 40, 0);
-
- // footer to left of items
- QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft
- << QPointF(-(2 * 80) - 100, 0)
- << QPointF(-(6 * 80) - 50, 0) // 50 = new footer width
- << QPointF(-240, 0)
- << QPointF(-240, 0) // unchanged, footer change doesn't change content pos
- << QPointF(-80, 0)
- << QPointF(-(6 * 80) - 40, 0);
-}
-
-void tst_QQuickGridView::header()
-{
- QFETCH(QQuickGridView::Flow, flow);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(QPointF, initialHeaderPos);
- QFETCH(QPointF, changedHeaderPos);
- QFETCH(QPointF, initialContentPos);
- QFETCH(QPointF, changedContentPos);
- QFETCH(QPointF, firstDelegatePos);
- QFETCH(QPointF, resizeContentPos);
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("initialViewWidth", 240);
- canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(testFileUrl("header.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *header = findItem<QQuickText>(contentItem, "header");
- QVERIFY(header);
-
- QVERIFY(header == gridview->headerItem());
-
- QCOMPARE(header->pos(), initialHeaderPos);
- QCOMPARE(header->width(), 100.);
- QCOMPARE(header->height(), 30.);
- QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- model.clear();
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is
-
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QSignalSpy headerItemSpy(gridview, SIGNAL(headerItemChanged()));
- QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
-
- QCOMPARE(headerItemSpy.count(), 1);
-
- header = findItem<QQuickText>(contentItem, "header");
- QVERIFY(!header);
- header = findItem<QQuickText>(contentItem, "header2");
- QVERIFY(header);
-
- QVERIFY(header == gridview->headerItem());
-
- QCOMPARE(header->pos(), changedHeaderPos);
- QCOMPARE(header->width(), 50.);
- QCOMPARE(header->height(), 20.);
- QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- header->setHeight(10);
- header->setWidth(40);
- QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
-
- delete canvas;
-
-
- // QTBUG-21207 header should become visible if view resizes from initial empty size
-
- canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("initialViewWidth", 240);
- canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(testFileUrl("header.qml"));
- canvas->show();
- qApp->processEvents();
-
- gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- gridview->setWidth(240);
- gridview->setHeight(320);
- QTRY_COMPARE(gridview->headerItem()->pos(), initialHeaderPos);
- QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::header_data()
-{
- QTest::addColumn<QQuickGridView::Flow>("flow");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<QPointF>("initialHeaderPos");
- QTest::addColumn<QPointF>("changedHeaderPos");
- QTest::addColumn<QPointF>("initialContentPos");
- QTest::addColumn<QPointF>("changedContentPos");
- QTest::addColumn<QPointF>("firstDelegatePos");
- QTest::addColumn<QPointF>("resizeContentPos");
-
- // header1 = 100 x 30
- // header2 = 50 x 20
- // cells = 80 x 60
- // view width = 240
-
- // header above items, top left
- QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, 0)
- << QPointF(0, -10);
-
- // header above items, top right
- QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft
- << QPointF(240 - 100, -30)
- << QPointF((240 - 100) + 50, -20) // 50 = width diff between old and new headers
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(160, 0)
- << QPointF(0, -10);
-
- // header to left of items
- QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight
- << QPointF(-100, 0)
- << QPointF(-50, 0)
- << QPointF(-100, 0)
- << QPointF(-50, 0)
- << QPointF(0, 0)
- << QPointF(-40, 0);
-
- // header to right of items
- QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(-(240 - 100), 0)
- << QPointF(-(240 - 50), 0)
- << QPointF(-80, 0)
- << QPointF(-(240 - 40), 0);
-}
-
-void tst_QQuickGridView::resizeViewAndRepaint()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("initialWidth", 240);
- ctxt->setContextProperty("initialHeight", 100);
-
- canvas->setSource(testFileUrl("resizeview.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // item at index 10 should not be currently visible
- QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- gridview->setHeight(320);
- QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- gridview->setHeight(100);
- QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- // Ensure we handle -ve sizes
- gridview->setHeight(-100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 3);
-
- gridview->setCacheBuffer(120);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 9);
-
- // ensure items in cache become visible
- gridview->setHeight(120);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 15);
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i%3)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QCOMPARE(item->isVisible(), i < 9); // inside view visible, outside not visible
- }
-
- // ensure items outside view become invisible
- gridview->setHeight(60);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 12);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i%3)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::changeColumnCount()
-{
- QmlListModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("initialWidth", 100);
- ctxt->setContextProperty("initialHeight", 320);
- canvas->setSource(testFileUrl("resizeview.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // a single column of 6 items are visible
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 6);
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), qreal(i*60));
- }
-
- // now 6x3 grid is visible, plus 1 extra below for refill
- gridview->setWidth(240);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 6*3 + 1);
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), qreal((i%3)*80));
- QCOMPARE(item->y(), qreal((i/3)*60));
- }
-
- // back to single column
- gridview->setWidth(100);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 6);
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), qreal(i*60));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::indexAt_itemAt_data()
-{
- QTest::addColumn<qreal>("x");
- QTest::addColumn<qreal>("y");
- QTest::addColumn<int>("index");
-
- QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0;
- QTest::newRow("Item 0 - 79, 59") << 79. << 59. << 0;
- QTest::newRow("Item 1 - 80, 0") << 80. << 0. << 1;
- QTest::newRow("Item 3 - 0, 60") << 0. << 60. << 3;
- QTest::newRow("No Item - 240, 0") << 240. << 0. << -1;
-}
-
-void tst_QQuickGridView::indexAt_itemAt()
-{
- QFETCH(qreal, x);
- QFETCH(qreal, y);
- QFETCH(int, index);
-
- QQuickView *canvas = createView();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->count(), model.count());
-
- QQuickItem *item = 0;
- if (index >= 0) {
- item = findItem<QQuickItem>(contentItem, "wrapper", index);
- QVERIFY(item);
- }
- QCOMPARE(gridview->indexAt(x, y), index);
- QVERIFY(gridview->itemAt(x, y) == item);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::onAdd()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, itemsToAdd);
-
- const int delegateWidth = 50;
- const int delegateHeight = 100;
- QaimModel model;
- QQuickView *canvas = createView();
- canvas->setGeometry(0,0,5 * delegateWidth, 5 * delegateHeight); // just ensure all items fit
-
- // these initial items should not trigger GridView.onAdd
- for (int i=0; i<initialItemCount; i++)
- model.addItem("dummy value", "dummy value");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateWidth", delegateWidth);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(testFileUrl("attachedSignals.qml"));
-
- QObject *object = canvas->rootObject();
- object->setProperty("width", canvas->width());
- object->setProperty("height", canvas->height());
- qApp->processEvents();
-
- QList<QPair<QString, QString> > items;
- for (int i=0; i<itemsToAdd; i++)
- items << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.addItems(items);
-
- QTRY_COMPARE(model.count(), qobject_cast<QQuickGridView*>(canvas->rootObject())->count());
- qApp->processEvents();
-
- QVariantList result = object->property("addedDelegates").toList();
- QTRY_COMPARE(result.count(), items.count());
- for (int i=0; i<items.count(); i++)
- QCOMPARE(result[i].toString(), items[i].first);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::onAdd_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("itemsToAdd");
-
- QTest::newRow("0, add 1") << 0 << 1;
- QTest::newRow("0, add 2") << 0 << 2;
- QTest::newRow("0, add 10") << 0 << 10;
-
- QTest::newRow("1, add 1") << 1 << 1;
- QTest::newRow("1, add 2") << 1 << 2;
- QTest::newRow("1, add 10") << 1 << 10;
-
- QTest::newRow("5, add 1") << 5 << 1;
- QTest::newRow("5, add 2") << 5 << 2;
- QTest::newRow("5, add 10") << 5 << 10;
-}
-
-void tst_QQuickGridView::onRemove()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, indexToRemove);
- QFETCH(int, removeCount);
-
- const int delegateWidth = 50;
- const int delegateHeight = 100;
- QaimModel model;
- for (int i=0; i<initialItemCount; i++)
- model.addItem(QString("value %1").arg(i), "dummy value");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateWidth", delegateWidth);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(testFileUrl("attachedSignals.qml"));
- QObject *object = canvas->rootObject();
-
- model.removeItems(indexToRemove, removeCount);
- QTRY_COMPARE(model.count(), qobject_cast<QQuickGridView*>(canvas->rootObject())->count());
- QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
-
- delete canvas;
-}
-
-void tst_QQuickGridView::onRemove_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("indexToRemove");
- QTest::addColumn<int>("removeCount");
-
- QTest::newRow("remove first") << 1 << 0 << 1;
- QTest::newRow("two items, remove first") << 2 << 0 << 1;
- QTest::newRow("two items, remove last") << 2 << 1 << 1;
- QTest::newRow("two items, remove all") << 2 << 0 << 2;
-
- QTest::newRow("four items, remove first") << 4 << 0 << 1;
- QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
- QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
- QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
- QTest::newRow("four items, remove last") << 4 << 3 << 1;
- QTest::newRow("four items, remove all") << 4 << 0 << 4;
-
- QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
- QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
- QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
-}
-
-void tst_QQuickGridView::columnCount()
-{
- QQuickView canvas;
- canvas.setSource(testFileUrl("gridview4.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickGridView *view = qobject_cast<QQuickGridView*>(canvas.rootObject());
-
- QCOMPARE(view->cellWidth(), qreal(405)/qreal(9));
- QCOMPARE(view->cellHeight(), qreal(100));
-
- QList<QQuickItem*> items = findItems<QQuickItem>(view, "delegate");
- QCOMPARE(items.size(), 18);
- QCOMPARE(items.at(8)->y(), qreal(0));
- QCOMPARE(items.at(9)->y(), qreal(100));
-}
-
-void tst_QQuickGridView::margins()
-{
- {
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
-
- canvas->setSource(testFileUrl("margins.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QCOMPARE(gridview->contentX(), -30.);
- QCOMPARE(gridview->xOrigin(), 0.);
-
- // check end bound
- gridview->positionViewAtEnd();
- qreal pos = gridview->contentX();
- gridview->setContentX(pos + 80);
- gridview->returnToBounds();
- QTRY_COMPARE(gridview->contentX(), pos + 50);
-
- // remove item before visible and check that left margin is maintained
- // and xOrigin is updated
- gridview->setContentX(200);
- model.removeItems(0, 4);
- QTest::qWait(100);
- gridview->setContentX(-50);
- gridview->returnToBounds();
- QCOMPARE(gridview->xOrigin(), 100.);
- QTRY_COMPARE(gridview->contentX(), 70.);
-
- // reduce left margin
- gridview->setLeftMargin(20);
- QCOMPARE(gridview->xOrigin(), 100.);
- QTRY_COMPARE(gridview->contentX(), 80.);
-
- // check end bound
- gridview->positionViewAtEnd();
- QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin
- pos = gridview->contentX();
- gridview->setContentX(pos + 80);
- gridview->returnToBounds();
- QTRY_COMPARE(gridview->contentX(), pos + 50);
-
- // reduce right margin
- pos = gridview->contentX();
- gridview->setRightMargin(40);
- QCOMPARE(gridview->xOrigin(), 0.);
- QTRY_COMPARE(gridview->contentX(), pos-10);
-
- delete canvas;
- }
- {
- //RTL
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
-
- canvas->setSource(testFileUrl("margins.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QCOMPARE(gridview->contentX(), -240+30.);
- QCOMPARE(gridview->xOrigin(), 0.);
-
- // check end bound
- gridview->positionViewAtEnd();
- qreal pos = gridview->contentX();
- gridview->setContentX(pos - 80);
- gridview->returnToBounds();
- QTRY_COMPARE(gridview->contentX(), pos - 50);
-
- // remove item before visible and check that left margin is maintained
- // and xOrigin is updated
- gridview->setContentX(-400);
- model.removeItems(0, 4);
- QTest::qWait(100);
- gridview->setContentX(-240+50);
- gridview->returnToBounds();
- QCOMPARE(gridview->xOrigin(), -100.);
- QTRY_COMPARE(gridview->contentX(), -240-70.);
-
- // reduce left margin (i.e. right side due to RTL)
- pos = gridview->contentX();
- gridview->setLeftMargin(20);
- QCOMPARE(gridview->xOrigin(), -100.);
- QTRY_COMPARE(gridview->contentX(), -240-80.);
-
- // check end bound
- gridview->positionViewAtEnd();
- QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin
- pos = gridview->contentX();
- gridview->setContentX(pos - 80);
- gridview->returnToBounds();
- QTRY_COMPARE(gridview->contentX(), pos - 50);
-
- // reduce right margin (i.e. left side due to RTL)
- pos = gridview->contentX();
- gridview->setRightMargin(40);
- QCOMPARE(gridview->xOrigin(), 0.);
- QTRY_COMPARE(gridview->contentX(), pos+10);
-
- delete canvas;
- }
-}
-
-void tst_QQuickGridView::creationContext()
-{
- QQuickView canvas;
- canvas.setGeometry(0,0,240,320);
- canvas.setSource(testFileUrl("creationContext.qml"));
- qApp->processEvents();
-
- QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
- QVERIFY(rootItem);
- QVERIFY(rootItem->property("count").toInt() > 0);
-
- QQuickItem *item;
- QVERIFY(item = rootItem->findChild<QQuickItem *>("listItem"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
-}
-
-void tst_QQuickGridView::snapToRow_data()
-{
- QTest::addColumn<QQuickGridView::Flow>("flow");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<int>("highlightRangeMode");
- QTest::addColumn<QPoint>("flickStart");
- QTest::addColumn<QPoint>("flickEnd");
- QTest::addColumn<qreal>("snapAlignment");
- QTest::addColumn<qreal>("endExtent");
- QTest::addColumn<qreal>("startExtent");
-
- QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
-
- QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
-
- QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
-
- QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
-
- QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
-
- QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
-}
-
-void tst_QQuickGridView::snapToRow()
-{
- QFETCH(QQuickGridView::Flow, flow);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(int, highlightRangeMode);
- QFETCH(QPoint, flickStart);
- QFETCH(QPoint, flickEnd);
- QFETCH(qreal, snapAlignment);
- QFETCH(qreal, endExtent);
- QFETCH(qreal, startExtent);
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("snapToRow.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
- gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // confirm that a flick hits an item boundary
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(qreal(fmod(gridview->contentY(),80.0)), snapAlignment);
- else
- QCOMPARE(qreal(fmod(gridview->contentX(),80.0)), snapAlignment);
-
- // flick to end
- do {
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- } while (flow == QQuickGridView::LeftToRight
- ? !gridview->isAtYEnd()
- : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
-
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), endExtent);
- else
- QCOMPARE(gridview->contentX(), endExtent);
-
- // flick to start
- do {
- flick(canvas, flickEnd, flickStart, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- } while (flow == QQuickGridView::LeftToRight
- ? !gridview->isAtYBeginning()
- : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd());
-
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), startExtent);
- else
- QCOMPARE(gridview->contentX(), startExtent);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::snapOneRow_data()
-{
- QTest::addColumn<QQuickGridView::Flow>("flow");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<int>("highlightRangeMode");
- QTest::addColumn<QPoint>("flickStart");
- QTest::addColumn<QPoint>("flickEnd");
- QTest::addColumn<qreal>("snapAlignment");
- QTest::addColumn<qreal>("endExtent");
- QTest::addColumn<qreal>("startExtent");
-
- QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
-
- QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
-
- QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 << -240.0;
-
- QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
-
- QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
-
- QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 - 100.0 << -220.0;
-}
-
-void tst_QQuickGridView::snapOneRow()
-{
- QFETCH(QQuickGridView::Flow, flow);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(int, highlightRangeMode);
- QFETCH(QPoint, flickStart);
- QFETCH(QPoint, flickEnd);
- QFETCH(qreal, snapAlignment);
- QFETCH(qreal, endExtent);
- QFETCH(qreal, startExtent);
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("snapOneRow.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
- gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QSignalSpy currentIndexSpy(gridview, SIGNAL(currentIndexChanged()));
-
- // confirm that a flick hits next row boundary
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), snapAlignment);
- else
- QCOMPARE(gridview->contentX(), snapAlignment);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(gridview->currentIndex(), 2);
- QCOMPARE(currentIndexSpy.count(), 1);
- }
-
- // flick to end
- do {
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- } while (flow == QQuickGridView::LeftToRight
- ? !gridview->isAtYEnd()
- : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(gridview->currentIndex(), 8);
- QCOMPARE(currentIndexSpy.count(), 4);
- }
-
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), endExtent);
- else
- QCOMPARE(gridview->contentX(), endExtent);
-
- // flick to start
- do {
- flick(canvas, flickEnd, flickStart, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- } while (flow == QQuickGridView::LeftToRight
- ? !gridview->isAtYBeginning()
- : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd());
-
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), startExtent);
- else
- QCOMPARE(gridview->contentX(), startExtent);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(gridview->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 8);
- }
-
- delete canvas;
-}
-
-
-void tst_QQuickGridView::unaligned()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 10; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("unaligned.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = qobject_cast<QQuickGridView*>(canvas->rootObject());
- QVERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- for (int i = 0; i < 10; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
- QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
- }
-
- // appending
- for (int i = 10; i < 18; ++i) {
- model.addItem("Item" + QString::number(i), "");
- QQuickItem *item = 0;
- QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
- QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
- QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
- }
-
- // inserting
- for (int i = 0; i < 10; ++i) {
- model.insertItem(i, "Item" + QString::number(i), "");
- QQuickItem *item = 0;
- QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
- QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
- QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
- }
-
- // removing
- model.removeItems(7, 10);
- QTRY_COMPARE(model.count(), gridview->count());
- for (int i = 0; i < 18; ++i) {
- QQuickItem *item = 0;
- QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
- QCOMPARE(item->x(), qreal(i%9)*gridview->cellWidth());
- QCOMPARE(item->y(), qreal(i/9)*gridview->cellHeight());
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::populateTransitions()
-{
- QFETCH(bool, staticallyPopulate);
- QFETCH(bool, dynamicallyPopulate);
- QFETCH(bool, usePopulateTransition);
-
- QPointF transitionFrom(-50, -50);
- QPointF transitionVia(100, 100);
- QaimModel model_transitionFrom;
- QaimModel model_transitionVia;
-
- QaimModel model;
- if (staticallyPopulate) {
- for (int i = 0; i < 30; i++)
- model.addItem("item" + QString::number(i), "");
- }
-
- QQuickView *canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
- canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
- canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom);
- canvas->rootContext()->setContextProperty("transitionVia", transitionVia);
- canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom);
- canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
- canvas->setSource(testFileUrl("populateTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem);
-
- if (staticallyPopulate || dynamicallyPopulate) {
- // check the populate transition is run
- if (usePopulateTransition) {
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 19);
- } else {
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0);
- }
- QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
- } else {
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- // add an item and check this is done with add transition, not populate
- model.insertItem(0, "another item", "");
- QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 1);
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(),
- (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 19 : 0);
-
- // clear the model
- canvas->rootContext()->setContextProperty("testModel", QVariant());
- QTRY_COMPARE(gridview->count(), 0);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
- gridview->setProperty("countPopulateTransitions", 0);
- gridview->setProperty("countAddTransitions", 0);
-
- // set to a valid model and check populate transition is run a second time
- model.clear();
- for (int i = 0; i < 30; i++)
- model.addItem("item" + QString::number(i), "");
- canvas->rootContext()->setContextProperty("testModel", &model);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0);
- QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- // reset model and check populate transition is run again
- gridview->setProperty("countPopulateTransitions", 0);
- gridview->setProperty("countAddTransitions", 0);
- model.reset();
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0);
- QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::populateTransitions_data()
-{
- QTest::addColumn<bool>("staticallyPopulate");
- QTest::addColumn<bool>("dynamicallyPopulate");
- QTest::addColumn<bool>("usePopulateTransition");
-
- QTest::newRow("static") << true << false << true;
- QTest::newRow("static, no populate") << true << false << false;
-
- QTest::newRow("dynamic") << false << true << true;
- QTest::newRow("dynamic, no populate") << false << true << false;
-
- QTest::newRow("empty to start with") << false << false << true;
- QTest::newRow("empty to start with, no populate") << false << false << false;
-}
-
-void tst_QQuickGridView::addTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(bool, shouldAnimateTargets);
- QFETCH(qreal, contentY);
- QFETCH(int, insertionIndex);
- QFETCH(int, insertionCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // added items should start here
- QPointF targetItems_transitionFrom(-50, -50);
-
- // displaced items should pass through this point
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionFrom;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- canvas->setSource(testFileUrl("addTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // only target items that will become visible should be animated
- QList<QPair<QString, QString> > newData;
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- if (shouldAnimateTargets) {
- for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
- newData << qMakePair(QString("New item %1").arg(i), QString(""));
-
- // last visible item is the first item of the row beneath the view
- if (i >= (contentY / 60)*3 && i < qCeil((contentY + gridview->height()) / 60.0)*3) {
- expectedTargetData << newData.last();
- targetIndexes << i;
- }
- }
- QVERIFY(expectedTargetData.count() > 0);
- }
-
- // start animation
- if (!newData.isEmpty()) {
- model.insertItems(insertionIndex, newData);
- QTRY_COMPARE(model.count(), gridview->count());
- }
-
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
-
- if (shouldAnimateTargets) {
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- // check the target and displaced items were animated
- model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
- matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
- }
- } else {
- QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0);
- QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::addTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<bool>("shouldAnimateTargets");
- QTest::addColumn<int>("insertionIndex");
- QTest::addColumn<int>("insertionCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // if inserting a full row before visible index, items don't appear or animate in, even if there are > 1 new items
- QTest::newRow("insert 1, just before start")
- << 30 << 20.0 << false
- << 0 << 1 << ListRange();
- QTest::newRow("insert 1, way before start")
- << 30 << 20.0 << false
- << 0 << 1 << ListRange();
- QTest::newRow("insert multiple, just before start")
- << 30 << 100.0 << false
- << 0 << 3 << ListRange();
- QTest::newRow("insert multiple (< 1 row), just before start")
- << 30 << 100.0 << false
- << 0 << 2 << ListRange();
- QTest::newRow("insert multiple, way before start")
- << 30 << 100.0 << false
- << 0 << 3 << ListRange();
-
- QTest::newRow("insert 1 at start")
- << 30 << 0.0 << true
- << 0 << 1 << ListRange(0, 17);
- QTest::newRow("insert multiple at start")
- << 30 << 0.0 << true
- << 0 << 3 << ListRange(0, 17);
- QTest::newRow("insert multiple (> 1 row) at start")
- << 30 << 0.0 << true
- << 0 << 5 << ListRange(0, 17);
- QTest::newRow("insert 1 at start, content y not 0")
- << 30 << 60.0 << true // first visible is index 3
- << 3 << 1 << ListRange(0 + 3, 17 + 3);
- QTest::newRow("insert multiple at start, content y not 0")
- << 30 << 60.0 << true // first visible is index 3
- << 3 << 3 << ListRange(0 + 3, 17 + 3);
- QTest::newRow("insert multiple (> 1 row) at start, content y not 0")
- << 30 << 60.0 << true // first visible is index 3
- << 3 << 5 << ListRange(0 + 3, 17 + 3);
-
- QTest::newRow("insert 1 at start, to empty grid")
- << 0 << 0.0 << true
- << 0 << 1 << ListRange();
- QTest::newRow("insert multiple at start, to empty grid")
- << 0 << 0.0 << true
- << 0 << 3 << ListRange();
-
- QTest::newRow("insert 1 at middle")
- << 30 << 0.0 << true
- << 7 << 1 << ListRange(7, 17);
- QTest::newRow("insert multiple at middle")
- << 30 << 0.0 << true
- << 7 << 3 << ListRange(7, 17);
- QTest::newRow("insert multiple (> 1 row) at middle")
- << 30 << 0.0 << true
- << 7 << 5 << ListRange(7, 17);
-
- QTest::newRow("insert 1 at bottom")
- << 30 << 0.0 << true
- << 17 << 1 << ListRange(17, 17);
- QTest::newRow("insert multiple at bottom")
- << 30 << 0.0 << true
- << 17 << 3 << ListRange(17, 17);
- QTest::newRow("insert 1 at bottom, content y not 0")
- << 30 << 20.0 * 3 << true
- << 17 + 3 << 1 << ListRange(17 + 3, 17 + 3);
- QTest::newRow("insert multiple at bottom, content y not 0")
- << 30 << 20.0 * 3 << true
- << 17 + 3 << 3 << ListRange(17 + 3, 17 + 3);
-
-
- // items added after the last visible will not be animated in, since they
- // do not appear in the final view
- QTest::newRow("insert 1 after end")
- << 30 << 0.0 << false
- << 18 << 1 << ListRange();
- QTest::newRow("insert multiple after end")
- << 30 << 0.0 << false
- << 18 << 3 << ListRange();
-}
-
-void tst_QQuickGridView::moveTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(qreal, contentY);
- QFETCH(qreal, itemsOffsetAfterMove);
- QFETCH(int, moveFrom);
- QFETCH(int, moveTo);
- QFETCH(int, moveCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // target and displaced items should pass through these points
- QPointF targetItems_transitionVia(-50, 50);
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionVia;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- canvas->setSource(testFileUrl("moveTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QQuickText *name;
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // Items moving to *or* from visible positions should be animated.
- // Otherwise, they should not be animated.
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- for (int i=moveFrom; i<moveFrom+moveCount; i++) {
- int toIndex = moveTo + (i - moveFrom);
- int firstVisibleIndex = (contentY / 60) * 3;
- int lastVisibleIndex = (qCeil((contentY + gridview->height()) / 60.0)*3) - 1;
- if ((i >= firstVisibleIndex && i <= lastVisibleIndex)
- || (toIndex >= firstVisibleIndex && toIndex <= lastVisibleIndex)) {
- expectedTargetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- }
- // ViewTransition.index provides the indices that items are moving to, not from
- targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount);
-
- // start animation
- model.moveItems(moveFrom, moveTo, moveCount);
-
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
-
- // check the target and displaced items were animated
- model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount);
- matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::moveTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
- QTest::addColumn<int>("moveFrom");
- QTest::addColumn<int>("moveTo");
- QTest::addColumn<int>("moveCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- QTest::newRow("move from above view, outside visible items, move 1") << 30 << 120.0 << 0.0
- << 1 << 10 << 1 << ListRange(6, 10);
- QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 120.0 << 0.0
- << 0 << 10 << 1 << ListRange(6, 10);
- QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 120.0 << 60.0
- << 1 << 10 << 3 << ListRange(13, 23);
- QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 120.0 << 60.0
- << 1 << 10 << 6 << (ListRange(7, 15) + ListRange(16, 23));
- QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 120.0 << 120.0
- << 0 << 10 << 6 << ListRange(16, 23);
-
- QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0
- << 1 << 10 << 1 << ListRange(2, 10);
- QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0
- << 0 << 10 << 1 << ListRange(1, 10);
- QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 120.0 << 0.0
- << 0+6 << 10+6 << 1 << ListRange(1+6, 10+6);
- QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0
- << 10 << 17 << 1 << ListRange(11, 17);
- QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0
- << 0 << 17 << 1 << ListRange(1, 17);
-
- QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0
- << 1 << 10 << 3 << ListRange(4, 12);
- QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0
- << 0 << 10 << 3 << ListRange(3, 12);
- QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 60.0 << 0.0
- << 0+3 << 10+3 << 3 << ListRange(3+3, 12+3);
- QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0
- << 5 << 15 << 3 << ListRange(8, 17);
- QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0
- << 0 << 15 << 3 << ListRange(3, 17);
-
- QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0
- << 10 << 1 << 1 << ListRange(1, 9);
- QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0
- << 10 << 0 << 1 << ListRange(0, 9);
- QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 120.0 << 0.0
- << 10+6 << 0+6 << 1 << ListRange(0+6, 9+6);
- QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 80.0 << 0.0
- << 10+3 << 0+3 << 1 << ListRange(0+3, 9+3);
- QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0
- << 17 << 10 << 1 << ListRange(10, 16);
- QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0
- << 17 << 0 << 1 << ListRange(0, 16);
-
- QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0
- << 10 << 1 << 3 << ListRange(1, 9);
- QTest::newRow("move within view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0
- << 10 << 1 << 5 << ListRange(1, 9);
- QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0
- << 10 << 0 << 3 << ListRange(0, 9);
- QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 60.0 << 0.0
- << 10+3 << 0+3 << 3 << ListRange(0+3, 9+3);
- QTest::newRow("move within view, move multiple up (> 1 row), move to first index, contentY not on border") << 30 << 80.0 << 0.0
- << 10+3 << 0+3 << 5 << ListRange(0+3, 9+3);
- QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0
- << 15 << 5 << 3 << ListRange(5, 14);
- QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0
- << 15 << 0 << 3 << ListRange(0, 14);
-
- QTest::newRow("move from below view, move 1 up") << 30 << 0.0 << 0.0
- << 20 << 5 << 1 << ListRange(5, 17);
- QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0
- << 20 << 0 << 1 << ListRange(0, 17);
- QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 60.0 << 0.0
- << 25 << 3 << 1 << ListRange(0+3, 17+3);
- QTest::newRow("move from below view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0
- << 20 << 5 << 5 << ListRange(5, 17);
- QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0
- << 20 << 0 << 3 << ListRange(0, 17);
- QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 60.0 << 0.0
- << 25 << 3 << 3 << ListRange(0+3, 17+3);
-
- QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0
- << 20 << 17 << 1 << ListRange(17, 17);
- QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0
- << 25 << 17+3 << 1 << ListRange(17+3, 17+3);
- QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0
- << 20 << 17 << 3 << ListRange(17, 17);
- QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0
- << 25 << 17+3 << 3 << ListRange(17+3, 17+3);
-}
-
-void tst_QQuickGridView::removeTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(bool, shouldAnimateTargets);
- QFETCH(qreal, contentY);
- QFETCH(int, removalIndex);
- QFETCH(int, removalCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // added items should end here
- QPointF targetItems_transitionTo(-50, -50);
-
- // displaced items should pass through this points
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionTo;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- canvas->setSource(testFileUrl("removeTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // only target items that are visible should be animated
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- if (shouldAnimateTargets) {
- for (int i=removalIndex; i<removalIndex+removalCount; i++) {
- int firstVisibleIndex = (contentY / 60.0)*3;
- int lastVisibleIndex = (qCeil((contentY + gridview->height()) / 60.0)*3) - 1;
- if (i >= firstVisibleIndex && i <= lastVisibleIndex) {
- expectedTargetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- }
- QVERIFY(expectedTargetData.count() > 0);
- }
-
- // calculate targetItems and expectedTargets before model changes
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
- QVariantMap expectedTargets;
- for (int i=0; i<targetIndexes.count(); i++)
- expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
-
- // start animation
- model.removeItems(removalIndex, removalCount);
- QTRY_COMPARE(model.count(), gridview->count());
-
- if (shouldAnimateTargets || expectedDisplacedIndexes.isValid()) {
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- // check the target and displaced items were animated
- model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- QCOMPARE(gridview->property("targetTrans_items").toMap(), expectedTargets);
- matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount);
- matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
- }
- } else {
- QTRY_COMPARE(model_targetItems_transitionTo.count(), 0);
- QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int itemCount = items.count();
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- int index = e.evaluate().toInt();
- if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
- firstVisibleIndex = index;
- else if (index < 0)
- itemCount--; // exclude deleted items
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), contentY + ((i-firstVisibleIndex)/3) * 60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::removeTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<bool>("shouldAnimateTargets");
- QTest::addColumn<int>("removalIndex");
- QTest::addColumn<int>("removalCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // All items that are visible following the remove operation should be animated.
- // Remove targets that are outside of the view should not be animated.
-
- // For a GridView, removing any number of items other than a full row before the start
- // should displace all items in the view
- QTest::newRow("remove 1 before start")
- << 30 << 120.0 << false
- << 2 << 1 << ListRange(6, 24); // 6-24 are displaced
- QTest::newRow("remove 1 row, before start")
- << 30 << 120.0 << false
- << 3 << 3 << ListRange();
- QTest::newRow("remove between 1-2 rows, before start")
- << 30 << 120.0 << false
- << 0 << 5 << ListRange(6, 25);
- QTest::newRow("remove 2 rows, before start")
- << 30 << 120.0 << false
- << 0 << 6 << ListRange();
- QTest::newRow("remove mix of before and after start")
- << 30 << 60.0 << true
- << 2 << 3 << ListRange(5, 23); // 5-23 are displaced into view
-
-
- QTest::newRow("remove 1 from start")
- << 30 << 0.0 << true
- << 0 << 1 << ListRange(1, 18); // 1-18 are displaced into view
- QTest::newRow("remove multiple from start")
- << 30 << 0.0 << true
- << 0 << 3 << ListRange(3, 20); // 3-18 are displaced into view
- QTest::newRow("remove 1 from start, content y not 0")
- << 30 << 60.0 << true
- << 3 << 1 << ListRange(1 + 3, 18 + 3);
- QTest::newRow("remove multiple from start, content y not 0")
- << 30 << 60.0 << true
- << 3 << 3 << ListRange(3 + 3, 20 + 3);
-
-
- QTest::newRow("remove 1 from middle")
- << 30 << 0.0 << true
- << 5 << 1 << ListRange(6, 18);
- QTest::newRow("remove multiple from middle")
- << 30 << 0.0 << true
- << 5 << 3 << ListRange(8, 20);
-
-
- QTest::newRow("remove 1 from bottom")
- << 30 << 0.0 << true
- << 17 << 1 << ListRange(18, 18);
- QTest::newRow("remove multiple (1 row) from bottom")
- << 30 << 0.0 << true
- << 15 << 3 << ListRange(18, 20);
- QTest::newRow("remove multiple (> 1 row) from bottom")
- << 30 << 0.0 << true
- << 15 << 5 << ListRange(20, 22);
- QTest::newRow("remove 1 from bottom, content y not 0")
- << 30 << 60.0 << true
- << 17 + 3 << 1 << ListRange(18 + 3, 18 + 3);
- QTest::newRow("remove multiple (1 row) from bottom, content y not 0")
- << 30 << 60.0 << true
- << 15 + 3 << 3 << ListRange(18 + 3, 20 + 3);
-
-
- QTest::newRow("remove 1 after end")
- << 30 << 0.0 << false
- << 18 << 1 << ListRange();
- QTest::newRow("remove multiple after end")
- << 30 << 0.0 << false
- << 18 << 3 << ListRange();
-}
-
-void tst_QQuickGridView::displacedTransitions()
-{
- QFETCH(bool, useDisplaced);
- QFETCH(bool, displacedEnabled);
- QFETCH(bool, useAddDisplaced);
- QFETCH(bool, addDisplacedEnabled);
- QFETCH(bool, useMoveDisplaced);
- QFETCH(bool, moveDisplacedEnabled);
- QFETCH(bool, useRemoveDisplaced);
- QFETCH(bool, removeDisplacedEnabled);
- QFETCH(ListChange, change);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_displaced_transitionVia;
- QaimModel model_addDisplaced_transitionVia;
- QaimModel model_moveDisplaced_transitionVia;
- QaimModel model_removeDisplaced_transitionVia;
-
- QPointF displaced_transitionVia(-50, -100);
- QPointF addDisplaced_transitionVia(-150, 100);
- QPointF moveDisplaced_transitionVia(50, -100);
- QPointF removeDisplaced_transitionVia(150, 100);
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia);
- ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia);
- ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia);
- ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia);
- ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia);
- ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia);
- ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia);
- ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia);
- ctxt->setContextProperty("useDisplaced", useDisplaced);
- ctxt->setContextProperty("displacedEnabled", displacedEnabled);
- ctxt->setContextProperty("useAddDisplaced", useAddDisplaced);
- ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled);
- ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced);
- ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled);
- ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced);
- ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled);
- canvas->setSource(testFileUrl("displacedTransitions.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
- gridview->setProperty("displaceTransitionsDone", false);
-
- switch (change.type) {
- case ListChange::Inserted:
- {
- QList<QPair<QString, QString> > targetItemData;
- for (int i=change.index; i<change.index + change.count; ++i)
- targetItemData << qMakePair(QString("new item %1").arg(i), QString::number(i));
- model.insertItems(change.index, targetItemData);
- QTRY_COMPARE(model.count(), gridview->count());
- break;
- }
- case ListChange::Removed:
- model.removeItems(change.index, change.count);
- QTRY_COMPARE(model.count(), gridview->count());
- break;
- case ListChange::Moved:
- model.moveItems(change.index, change.to, change.count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::SetCurrent:
- case ListChange::SetContentY:
- break;
- }
- if ((useDisplaced && displacedEnabled)
- || (useAddDisplaced && addDisplacedEnabled)
- || (useMoveDisplaced && moveDisplacedEnabled)
- || (useRemoveDisplaced && removeDisplacedEnabled)) {
- QTRY_VERIFY(gridview->property("displaceTransitionsDone").toBool());
- }
-
- if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled)
- model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced");
- else
- QCOMPARE(model_addDisplaced_transitionVia.count(), 0);
- if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled)
- model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced");
- else
- QCOMPARE(model_moveDisplaced_transitionVia.count(), 0);
- if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled)
- model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced");
- else
- QCOMPARE(model_removeDisplaced_transitionVia.count(), 0);
-
- if (useDisplaced && displacedEnabled
- && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled))
- || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled))
- || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) {
- model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced");
- } else {
- QCOMPARE(model_displaced_transitionVia.count(), 0);
- }
-
- // verify all items moved to the correct final positions
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i < model.count() && i < items.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::displacedTransitions_data()
-{
- QTest::addColumn<bool>("useDisplaced");
- QTest::addColumn<bool>("displacedEnabled");
- QTest::addColumn<bool>("useAddDisplaced");
- QTest::addColumn<bool>("addDisplacedEnabled");
- QTest::addColumn<bool>("useMoveDisplaced");
- QTest::addColumn<bool>("moveDisplacedEnabled");
- QTest::addColumn<bool>("useRemoveDisplaced");
- QTest::addColumn<bool>("removeDisplacedEnabled");
- QTest::addColumn<ListChange>("change");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- QTest::newRow("no displaced transitions at all")
- << false << false
- << false << false
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 17);
-
- QTest::newRow("just displaced")
- << true << true
- << false << false
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 17);
-
- QTest::newRow("just displaced (not enabled)")
- << true << false
- << false << false
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 17);
-
- QTest::newRow("displaced + addDisplaced")
- << true << true
- << true << true
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 17);
-
- QTest::newRow("displaced + addDisplaced (not enabled)")
- << true << true
- << true << false
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 17);
-
- QTest::newRow("displaced + moveDisplaced")
- << true << true
- << false << false
- << true << true
- << false << false
- << ListChange::move(0, 10, 1) << ListRange(1, 10);
-
- QTest::newRow("displaced + moveDisplaced (not enabled)")
- << true << true
- << false << false
- << true << false
- << false << false
- << ListChange::move(0, 10, 1) << ListRange(1, 10);
-
- QTest::newRow("displaced + removeDisplaced")
- << true << true
- << false << false
- << false << false
- << true << true
- << ListChange::remove(0, 1) << ListRange(1, 18);
-
- QTest::newRow("displaced + removeDisplaced (not enabled)")
- << true << true
- << false << false
- << false << false
- << true << false
- << ListChange::remove(0, 1) << ListRange(1, 18);
-
-
- QTest::newRow("displaced + add, should use generic displaced for a remove")
- << true << true
- << true << true
- << false << false
- << true << false
- << ListChange::remove(0, 1) << ListRange(1, 18);
-}
-
-void tst_QQuickGridView::multipleTransitions()
-{
- // Tests that if you interrupt a transition in progress with another action that
- // cancels the previous transition, the resulting items are still placed correctly.
-
- QFETCH(int, initialCount);
- QFETCH(qreal, contentY);
- QFETCH(QList<ListChange>, changes);
- QFETCH(bool, rippleAddDisplaced);
-
- // add transitions on the left, moves on the right
- QPointF addTargets_transitionFrom(-50, -50);
- QPointF addDisplaced_transitionFrom(-50, 50);
- QPointF moveTargets_transitionFrom(50, -50);
- QPointF moveDisplaced_transitionFrom(50, 50);
- QPointF removeTargets_transitionTo(-100, 300);
- QPointF removeDisplaced_transitionFrom(100, 300);
-
- QmlListModel model;
- for (int i = 0; i < initialCount; i++)
- model.addItem("Original item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
- ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
- ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
- ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
- ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo);
- ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom);
- ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced);
- canvas->setSource(testFileUrl("multipleTransitions.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
-
- QList<QPair<QString, QString> > targetItems;
- for (int i=0; i<changes.count(); i++) {
- switch (changes[i].type) {
- case ListChange::Inserted:
- {
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
- model.insertItems(changes[i].index, targetItems);
- QTRY_COMPARE(model.count(), gridview->count());
- QTRY_VERIFY(gridview->property("runningAddTargets").toBool());
- QTRY_VERIFY(gridview->property("runningAddDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!gridview->property("runningAddTargets").toBool());
- QTRY_VERIFY(!gridview->property("runningAddDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- }
- case ListChange::Removed:
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(model.name(i), model.number(i));
- model.removeItems(changes[i].index, changes[i].count);
- QTRY_COMPARE(model.count(), gridview->count());
- QTRY_VERIFY(gridview->property("runningRemoveTargets").toBool());
- QTRY_VERIFY(gridview->property("runningRemoveDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!gridview->property("runningRemoveTargets").toBool());
- QTRY_VERIFY(!gridview->property("runningRemoveDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- case ListChange::Moved:
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(model.name(i), model.number(i));
- model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_VERIFY(gridview->property("runningMoveTargets").toBool());
- QTRY_VERIFY(gridview->property("runningMoveDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool());
- QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- case ListChange::SetCurrent:
- gridview->setCurrentIndex(changes[i].index);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::SetContentY:
- gridview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- }
- }
- QCOMPARE(gridview->count(), model.count());
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::multipleTransitions_data()
-{
- QTest::addColumn<int>("initialCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<QList<ListChange> >("changes");
- QTest::addColumn<bool>("rippleAddDisplaced");
-
- // the added item and displaced items should move to final dest correctly
- QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::move(0, 3, 1)
- )
- << false;
-
- // items affected by the add should change from move to add transition
- QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::move(1, 10, 3)
- << ListChange::insert(0, 1)
- )
- << false;
-
- // items should be placed correctly if you trigger a transition then refill for that index
- QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::setContentY(160.0)
- << ListChange::setContentY(0.0)
- << ListChange::insert(0, 1)
- )
- << false;
-
- QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::insert(1, 1)
- << ListChange::remove(1, 1)
- )
- << true;
-}
-
-void tst_QQuickGridView::cacheBuffer()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 90; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QVERIFY(gridview->delegate() != 0);
- QVERIFY(gridview->model() != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->rootObject()->setProperty("cacheBuffer", 200);
- QTRY_VERIFY(gridview->cacheBuffer() == 200);
-
- // items will be created one at a time
- for (int i = itemCount; i < qMin(itemCount+9,model.count()); ++i) {
- QVERIFY(findItem<QQuickItem>(gridview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(gridview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- int newItemCount = 0;
- newItemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- // move view and confirm items in view are visible immediately and outside are created async
- gridview->setContentY(300);
-
- for (int i = 15; i < 34; ++i) { // 34 due to staggered item creation
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- QVERIFY(findItem<QQuickItem>(gridview, "wrapper", 34) == 0);
-
- // ensure buffered items are created
- for (int i = 34; i < qMin(44,model.count()); ++i) {
- QQuickItem *item = 0;
- while (!item) {
- qGuiApp->processEvents(); // allow refill to happen
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(gridview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::asynchronous()
-{
- QQuickView *canvas = createView();
- canvas->show();
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->setSource(testFile("asyncloader.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootObject);
-
- QQuickGridView *gridview = 0;
- while (!gridview) {
- bool b = false;
- controller.incubateWhile(&b);
- gridview = rootObject->findChild<QQuickGridView*>("view");
- }
-
- // items will be created one at a time
- for (int i = 0; i < 12; ++i) {
- QVERIFY(findItem<QQuickItem>(gridview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(gridview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- // verify positioning
- QQuickItem *contentItem = gridview->contentItem();
- for (int i = 0; i < 12; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item->x() == (i%3)*100);
- QVERIFY(item->y() == (i/3)*100);
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::unrequestedVisibility()
-{
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- canvas->setSource(testFileUrl("unrequestedItems.qml"));
-
- canvas->show();
-
- qApp->processEvents();
-
- QQuickGridView *leftview = findItem<QQuickGridView>(canvas->rootObject(), "leftGrid");
- QTRY_VERIFY(leftview != 0);
-
- QQuickGridView *rightview = findItem<QQuickGridView>(canvas->rootObject(), "rightGrid");
- QTRY_VERIFY(rightview != 0);
-
- QQuickItem *leftContent = leftview->contentItem();
- QTRY_VERIFY(leftContent != 0);
-
- QQuickItem *rightContent = rightview->contentItem();
- QTRY_VERIFY(rightContent != 0);
-
- rightview->setCurrentIndex(12);
-
- QTRY_COMPARE(leftview->contentY(), 0.0);
- QTRY_COMPARE(rightview->contentY(), 240.0);
-
- QQuickItem *item;
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), true);
-
- rightview->setCurrentIndex(0);
-
- QTRY_COMPARE(leftview->contentY(), 0.0);
- QTRY_COMPARE(rightview->contentY(), 0.0);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QTRY_COMPARE(item->isVisible(), true);
-
- QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 11));
- QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 11));
-
- leftview->setCurrentIndex(12);
-
- QTRY_COMPARE(leftview->contentY(), 240.0);
- QTRY_COMPARE(rightview->contentY(), 0.0);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QTRY_COMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a non-visible item into view
- model.moveItems(10, 9, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a visible item out of view
- model.moveItems(5, 3, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a non-visible item into view
- model.moveItems(3, 5, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a visible item out of view
- model.moveItems(9, 10, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a non-visible item into view
- model.moveItems(10, 9, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- delete canvas;
-}
-
-QList<int> tst_QQuickGridView::toIntList(const QVariantList &list)
-{
- QList<int> ret;
- bool ok = true;
- for (int i=0; i<list.count(); i++) {
- ret << list[i].toInt(&ok);
- if (!ok)
- qWarning() << "tst_QQuickGridView::toIntList(): not a number:" << list[i];
- }
-
- return ret;
-}
-
-void tst_QQuickGridView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
-{
- for (int i=0; i<indexLists.count(); i++) {
- QSet<int> current = indexLists[i].value<QList<int> >().toSet();
- if (current != expectedIndexes.toSet())
- qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
- QCOMPARE(current, expectedIndexes.toSet());
- }
-}
-
-void tst_QQuickGridView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
-{
- for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
- QVERIFY(it.value().type() == QVariant::Int);
- QString name = it.key();
- int itemIndex = it.value().toInt();
- QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
- if (model.name(itemIndex) != name)
- qDebug() << itemIndex;
- QCOMPARE(model.name(itemIndex), name);
- }
- QCOMPARE(items.count(), expectedIndexes.count());
-}
-
-void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
-{
- for (int i=0; i<itemLists.count(); i++) {
- QVariantList current = itemLists[i].toList();
- for (int j=0; j<current.count(); j++) {
- QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
- QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
- QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
- }
- QCOMPARE(current.count(), expectedItems.count());
- }
-}
-
-QTEST_MAIN(tst_QQuickGridView)
-
-#include "tst_qquickgridview.moc"
-
diff --git a/tests/auto/qtquick2/qquickimage/qquickimage.pro b/tests/auto/qtquick2/qquickimage/qquickimage.pro
deleted file mode 100644
index 43e95a2bed..0000000000
--- a/tests/auto/qtquick2/qquickimage/qquickimage.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickimage
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickimage.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp b/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp
deleted file mode 100644
index 7602f1b1d5..0000000000
--- a/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp
+++ /dev/null
@@ -1,749 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquickimage_p.h>
-#include <private/qquickimagebase_p.h>
-#include <private/qquickloader_p.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtTest/QSignalSpy>
-#include <QtGui/QPainter>
-#include <QtGui/QImageReader>
-
-#include "../../shared/util.h"
-#include "../../shared/testhttpserver.h"
-#include "../shared/visualtestutil.h"
-
-#define SERVER_PORT 14451
-#define SERVER_ADDR "http://127.0.0.1:14451"
-
-
-using namespace QQuickVisualTestUtil;
-
-Q_DECLARE_METATYPE(QQuickImageBase::Status)
-
-class tst_qquickimage : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void preserveAspectRatio();
- void smooth();
- void mirror();
- void svg();
- void geometry();
- void geometry_data();
- void big();
- void tiling_QTBUG_6716();
- void tiling_QTBUG_6716_data();
- void noLoading();
- void paintedWidthHeight();
- void sourceSize_QTBUG_14303();
- void sourceSize_QTBUG_16389();
- void nullPixmapPaint();
- void imageCrash_QTBUG_22125();
- void sourceSize_data();
- void sourceSize();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qquickimage::tst_qquickimage()
-{
-}
-
-void tst_qquickimage::noSource()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: \"\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QVERIFY(obj->status() == QQuickImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
- QCOMPARE(obj->progress(), 0.0);
-
- delete obj;
-}
-
-void tst_qquickimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<double>("width");
- QTest::addColumn<double>("height");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<bool>("async");
- QTest::addColumn<bool>("cache");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << true << "";
- QTest::newRow("local no cache") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << false << "";
- QTest::newRow("local async") << testFileUrl("colors1.png").toString() << 120.0 << 120.0 << false << true << true << "";
- QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << 0.0 << 0.0 << false
- << false << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString();
- QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false
- << true << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString();
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << "";
- QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
- if (QImageReader::supportedImageFormats().contains("svg"))
- QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
-
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true
- << false << true << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
-
-}
-
-void tst_qquickimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(double, width);
- QFETCH(double, height);
- QFETCH(bool, remote);
- QFETCH(bool, async);
- QFETCH(bool, cache);
- QFETCH(QString, error);
-
- TestHTTPServer server(SERVER_PORT);
- if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
- server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; asynchronous: "
- + (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: "
- + (cache ? QLatin1String("true") : QLatin1String("false")) + " }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (async)
- QVERIFY(obj->asynchronous() == true);
- else
- QVERIFY(obj->asynchronous() == false);
-
- if (cache)
- QVERIFY(obj->cache() == true);
- else
- QVERIFY(obj->cache() == false);
-
- if (remote || async)
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QCOMPARE(obj->width(), qreal(width));
- QCOMPARE(obj->height(), qreal(height));
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- QTRY_VERIFY(obj->status() == QQuickImage::Error);
- }
-
- delete obj;
-}
-
-void tst_qquickimage::clearSource()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->progress(), 1.0);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QQuickImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->progress(), 0.0);
-
- delete obj;
-}
-
-void tst_qquickimage::resized()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
- delete obj;
-}
-
-
-void tst_qquickimage::preserveAspectRatio()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->show();
-
- canvas->setSource(testFileUrl("aspectratio.qml"));
- QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
- QVERIFY(image != 0);
- image->setWidth(80.0);
- QCOMPARE(image->width(), 80.);
- QCOMPARE(image->height(), 80.);
-
- canvas->setSource(testFileUrl("aspectratio.qml"));
- image = qobject_cast<QQuickImage*>(canvas->rootObject());
- image->setHeight(60.0);
- QVERIFY(image != 0);
- QCOMPARE(image->height(), 60.);
- QCOMPARE(image->width(), 60.);
- delete canvas;
-}
-
-void tst_qquickimage::smooth()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickimage::mirror()
-{
- QSKIP("Test is broken on multiple levels, will need incremental fixes");
-
- QMap<QQuickImage::FillMode, QImage> screenshots;
- QList<QQuickImage::FillMode> fillModes;
- fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop
- << QQuickImage::Tile << QQuickImage::TileVertically << QQuickImage::TileHorizontally;
-
- qreal width = 300;
- qreal height = 250;
-
- foreach (QQuickImage::FillMode fillMode, fillModes) {
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("mirror.qml"));
-
- QQuickImage *obj = canvas->rootObject()->findChild<QQuickImage*>("image");
- QVERIFY(obj != 0);
-
- obj->setFillMode(fillMode);
- obj->setProperty("mirror", true);
- canvas->show();
-
- QImage screenshot = canvas->grabFrameBuffer();
- screenshots[fillMode] = screenshot;
- delete canvas;
- }
-
- foreach (QQuickImage::FillMode fillMode, fillModes) {
- QPixmap srcPixmap;
- QVERIFY(srcPixmap.load(testFile("pattern.png")));
-
- QPixmap expected(width, height);
- expected.fill();
- QPainter p_e(&expected);
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- p_e.setTransform(transform);
-
- switch (fillMode) {
- case QQuickImage::Stretch:
- p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- case QQuickImage::PreserveAspectFit:
- p_e.drawPixmap(QRect(25, 0, height, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- case QQuickImage::PreserveAspectCrop:
- {
- qreal ratio = width/srcPixmap.width(); // width is the longer side
- QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio);
- rect.moveCenter(QRect(0, 0, width, height).center());
- p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- }
- case QQuickImage::Tile:
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- case QQuickImage::TileVertically:
- transform.scale(width / srcPixmap.width(), 1.0);
- p_e.setTransform(transform);
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- case QQuickImage::TileHorizontally:
- transform.scale(1.0, height / srcPixmap.height());
- p_e.setTransform(transform);
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- case QQuickImage::Pad:
- break;
- }
-
- QImage img = expected.toImage();
- QEXPECT_FAIL("", "QTBUG-21005 fails", Continue);
- QCOMPARE(screenshots[fillMode], img);
- }
-}
-
-void tst_qquickimage::svg()
-{
- if (!QImageReader::supportedImageFormats().contains("svg"))
- QSKIP("svg support not available");
-
- QString src = testFileUrl("heart.svg").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.0);
- QCOMPARE(obj->height(), 300.0);
- obj->setSourceSize(QSize(200,200));
-
- QCOMPARE(obj->width(), 200.0);
- QCOMPARE(obj->height(), 200.0);
- delete obj;
-}
-
-void tst_qquickimage::geometry_data()
-{
- QTest::addColumn<QString>("fillMode");
- QTest::addColumn<bool>("explicitWidth");
- QTest::addColumn<bool>("explicitHeight");
- QTest::addColumn<double>("itemWidth");
- QTest::addColumn<double>("paintedWidth");
- QTest::addColumn<double>("boundingWidth");
- QTest::addColumn<double>("itemHeight");
- QTest::addColumn<double>("paintedHeight");
- QTest::addColumn<double>("boundingHeight");
-
- // tested image has width 200, height 100
-
- // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match
- QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0;
- QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0;
-
- // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match
- QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0;
- QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
- QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
-
- // bounding rect, painted rect and item rect are equal in stretching and tiling images
- QStringList fillModes;
- fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally";
- foreach (QString fillMode, fillModes) {
- QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0;
- QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0;
- }
-}
-
-void tst_qquickimage::geometry()
-{
- QFETCH(QString, fillMode);
- QFETCH(bool, explicitWidth);
- QFETCH(bool, explicitHeight);
- QFETCH(double, itemWidth);
- QFETCH(double, itemHeight);
- QFETCH(double, paintedWidth);
- QFETCH(double, paintedHeight);
- QFETCH(double, boundingWidth);
- QFETCH(double, boundingHeight);
-
- QString src = testFileUrl("rect.png").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; ";
-
- if (explicitWidth)
- componentStr.append("width: 300; ");
- if (explicitHeight)
- componentStr.append("height: 400; ");
- componentStr.append("}");
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->width(), itemWidth);
- QCOMPARE(obj->paintedWidth(), paintedWidth);
- QCOMPARE(obj->boundingRect().width(), boundingWidth);
-
- QCOMPARE(obj->height(), itemHeight);
- QCOMPARE(obj->paintedHeight(), paintedHeight);
- QCOMPARE(obj->boundingRect().height(), boundingHeight);
- delete obj;
-}
-
-void tst_qquickimage::big()
-{
- // If the JPEG loader does not implement scaling efficiently, it would
- // have to build a 400 MB image. That would be a bug in the JPEG loader.
-
- QString src = testFileUrl("big.jpeg").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 100.0);
- QCOMPARE(obj->height(), 256.0);
-
- delete obj;
-}
-
-// As tiling_QTBUG_6716 doesn't complete, it doesn't delete the
-// canvas which causes leak warnings. Use this delete on stack
-// destruction pattern to work around this.
-template<typename T>
-struct AutoDelete {
- AutoDelete(T *t) : t(t) {}
- ~AutoDelete() { delete t; }
-private:
- T *t;
-};
-
-void tst_qquickimage::tiling_QTBUG_6716()
-{
- QSKIP("Test is broken on multiple levels, will need incremental fixes");
-
- QFETCH(QString, source);
-
- QQuickView *canvas = new QQuickView(0);
- AutoDelete<QQuickView> del(canvas);
-
- canvas->setSource(testFileUrl(source));
- canvas->show();
- qApp->processEvents();
-
- QQuickImage *tiling = findItem<QQuickImage>(canvas->rootObject(), "tiling");
-
- QVERIFY(tiling != 0);
- QImage img = canvas->grabFrameBuffer();
- for (int x = 0; x < tiling->width(); ++x) {
- for (int y = 0; y < tiling->height(); ++y) {
- QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
- }
- }
-
- delete canvas;
-}
-
-void tst_qquickimage::tiling_QTBUG_6716_data()
-{
- QTest::addColumn<QString>("source");
- QTest::newRow("vertical_tiling") << "vtiling.qml";
- QTest::newRow("horizontal_tiling") << "htiling.qml";
-}
-
-void tst_qquickimage::noLoading()
-{
- qRegisterMetaType<QQuickImageBase::Status>();
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
- server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
-
- QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
-
- QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
- QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
- QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
-
- // Loading local file
- ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 1);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 0);
-
- // Loading remote file
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_COMPARE(progressSpy.count(), 2);
- QTRY_COMPARE(statusSpy.count(), 2);
-
- // Loading remote file again - should not go through 'Loading' state.
- ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 4);
- QTRY_COMPARE(progressSpy.count(), 2);
- QTRY_COMPARE(statusSpy.count(), 2);
-
- delete obj;
-}
-
-void tst_qquickimage::paintedWidthHeight()
-{
- {
- QString src = testFileUrl("heart.png").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 200.0);
- QCOMPARE(obj->height(), 25.0);
- QCOMPARE(obj->paintedWidth(), 25.0);
- QCOMPARE(obj->paintedHeight(), 25.0);
-
- delete obj;
- }
-
- {
- QString src = testFileUrl("heart.png").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 26.0);
- QCOMPARE(obj->height(), 175.0);
- QCOMPARE(obj->paintedWidth(), 26.0);
- QCOMPARE(obj->paintedHeight(), 26.0);
-
- delete obj;
- }
-}
-
-void tst_qquickimage::sourceSize_QTBUG_14303()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
-
- QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged()));
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
-
- QTRY_COMPARE(obj->sourceSize().width(), 200);
- QTRY_COMPARE(obj->sourceSize().height(), 200);
- QTRY_COMPARE(sourceSizeSpy.count(), 0);
-
- ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
- QTRY_COMPARE(obj->sourceSize().width(), 120);
- QTRY_COMPARE(obj->sourceSize().height(), 120);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
-
- ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
- QTRY_COMPARE(obj->sourceSize().width(), 200);
- QTRY_COMPARE(obj->sourceSize().height(), 200);
- QTRY_COMPARE(sourceSizeSpy.count(), 2);
-
- delete obj;
-}
-
-void tst_qquickimage::sourceSize_QTBUG_16389()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("qtbug_16389.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickImage *image = findItem<QQuickImage>(canvas->rootObject(), "iconImage");
- QQuickItem *handle = findItem<QQuickItem>(canvas->rootObject(), "blueHandle");
-
- QCOMPARE(image->sourceSize().width(), 200);
- QCOMPARE(image->sourceSize().height(), 200);
- QCOMPARE(image->paintedWidth(), 0.0);
- QCOMPARE(image->paintedHeight(), 0.0);
-
- handle->setY(20);
-
- QCOMPARE(image->sourceSize().width(), 200);
- QCOMPARE(image->sourceSize().height(), 200);
- QCOMPARE(image->paintedWidth(), 20.0);
- QCOMPARE(image->paintedHeight(), 20.0);
-
- delete canvas;
-}
-
-static int numberOfWarnings = 0;
-static void checkWarnings(QtMsgType, const char *msg)
-{
- if (!QString(msg).contains("QGLContext::makeCurrent(): Failed."))
- numberOfWarnings++;
-}
-
-// QTBUG-15690
-void tst_qquickimage::nullPixmapPaint()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("nullpixmap.qml"));
- canvas->show();
-
- QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
- QTRY_VERIFY(image != 0);
- image->setSource(SERVER_ADDR + QString("/no-such-file.png"));
-
- QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
-
- // used to print "QTransform::translate with NaN called"
- QPixmap pm = QPixmap::fromImage(canvas->grabFrameBuffer());
- qInstallMsgHandler(previousMsgHandler);
- QVERIFY(numberOfWarnings == 0);
- delete image;
-
- delete canvas;
-}
-
-void tst_qquickimage::imageCrash_QTBUG_22125()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
-
- {
- QQuickView view(testFileUrl("qtbug_22125.qml"));
- view.show();
- qApp->processEvents();
- qApp->processEvents();
- // shouldn't crash when the view drops out of scope due to
- // QDeclarativePixmapData attempting to dereference a pointer to
- // the destroyed reader.
- }
-
- // shouldn't crash when deleting cancelled QDeclarativePixmapReplys.
- QTest::qWait(520); // Delay mode delays for 500 ms.
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-}
-
-void tst_qquickimage::sourceSize_data()
-{
- QTest::addColumn<int>("sourceWidth");
- QTest::addColumn<int>("sourceHeight");
- QTest::addColumn<qreal>("implicitWidth");
- QTest::addColumn<qreal>("implicitHeight");
-
- QTest::newRow("unscaled") << 0 << 0 << 300.0 << 300.0;
- QTest::newRow("scale width") << 100 << 0 << 100.0 << 100.0;
- QTest::newRow("scale height") << 0 << 150 << 150.0 << 150.0;
- QTest::newRow("larger sourceSize") << 400 << 400 << 300.0 << 300.0;
-}
-
-void tst_qquickimage::sourceSize()
-{
- QFETCH(int, sourceWidth);
- QFETCH(int, sourceHeight);
- QFETCH(qreal, implicitWidth);
- QFETCH(qreal, implicitHeight);
-
- QQuickView *canvas = new QQuickView(0);
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("srcWidth", sourceWidth);
- ctxt->setContextProperty("srcHeight", sourceHeight);
-
- canvas->setSource(testFileUrl("sourceSize.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
- QVERIFY(image);
-
- QCOMPARE(image->sourceSize().width(), sourceWidth);
- QCOMPARE(image->sourceSize().height(), sourceHeight);
- QCOMPARE(image->implicitWidth(), implicitWidth);
- QCOMPARE(image->implicitHeight(), implicitHeight);
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickimage)
-
-#include "tst_qquickimage.moc"
diff --git a/tests/auto/qtquick2/qquickitem/qquickitem.pro b/tests/auto/qtquick2/qquickitem/qquickitem.pro
deleted file mode 100644
index 70f6b15b3d..0000000000
--- a/tests/auto/qtquick2/qquickitem/qquickitem.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickitem
-SOURCES += tst_qquickitem.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp
deleted file mode 100644
index be3aef80bd..0000000000
--- a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp
+++ /dev/null
@@ -1,1468 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickcanvas.h>
-#include <QtQuick/qquickview.h>
-#include <QtWidgets/QGraphicsSceneMouseEvent>
-#include "private/qquickfocusscope_p.h"
-#include "private/qquickitem_p.h"
-#include <QDebug>
-#include <QTimer>
-#include "../../shared/util.h"
-
-class TestItem : public QQuickItem
-{
-Q_OBJECT
-public:
- TestItem(QQuickItem *parent = 0)
- : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0)
- , wheelCount(0), acceptIncomingTouchEvents(true)
- , touchEventReached(false) {}
-
- bool focused;
- int pressCount;
- int releaseCount;
- int wheelCount;
- bool acceptIncomingTouchEvents;
- bool touchEventReached;
-protected:
- virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
- virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
- virtual void mousePressEvent(QMouseEvent *event) { event->accept(); ++pressCount; }
- virtual void mouseReleaseEvent(QMouseEvent *event) { event->accept(); ++releaseCount; }
- virtual void touchEvent(QTouchEvent *event) {
- touchEventReached = true;
- event->setAccepted(acceptIncomingTouchEvents);
- }
- virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; }
-};
-
-class TestCanvas: public QQuickCanvas
-{
-public:
- TestCanvas()
- : QQuickCanvas()
- {}
-
- virtual bool event(QEvent *event)
- {
- return QQuickCanvas::event(event);
- }
-};
-
-class TestPolishItem : public QQuickItem
-{
-Q_OBJECT
-public:
- TestPolishItem(QQuickItem *parent = 0)
- : QQuickItem(parent), wasPolished(false) {
-
- }
-
- bool wasPolished;
-
-protected:
- virtual void updatePolish() {
- wasPolished = true;
- }
-
-public slots:
- void doPolish() {
- polish();
- }
-};
-
-class TestFocusScope : public QQuickFocusScope
-{
-Q_OBJECT
-public:
- TestFocusScope(QQuickItem *parent = 0) : QQuickFocusScope(parent), focused(false) {}
-
- bool focused;
-protected:
- virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
- virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
-};
-
-class tst_qquickitem : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- void initTestCase();
-
- void noCanvas();
- void simpleFocus();
- void scopedFocus();
- void addedToCanvas();
- void changeParent();
-
- void constructor();
- void setParentItem();
-
- void visible();
- void enabled();
- void enabledFocus();
-
- void mouseGrab();
- void touchEventAcceptIgnore_data();
- void touchEventAcceptIgnore();
- void polishOutsideAnimation();
- void polishOnCompleted();
-
- void wheelEvent_data();
- void wheelEvent();
- void hoverEvent_data();
- void hoverEvent();
- void hoverEventInParent();
-
- void paintOrder_data();
- void paintOrder();
-
-private:
-
- enum PaintOrderOp {
- NoOp, Append, Remove, StackBefore, StackAfter, SetZ
- };
-
- void ensureFocus(QWindow *w) {
- w->show();
- w->requestActivateWindow();
- qApp->processEvents();
- }
-};
-
-void tst_qquickitem::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<TestPolishItem>("Qt.test", 1, 0, "TestPolishItem");
-}
-
-// Focus has no effect when outside a canvas
-void tst_qquickitem::noCanvas()
-{
- QQuickItem *root = new TestItem;
- QQuickItem *child = new TestItem(root);
- QQuickItem *scope = new TestItem(root);
- QQuickFocusScope *scopedChild = new TestFocusScope(scope);
- QQuickFocusScope *scopedChild2 = new TestFocusScope(scope);
-
- QCOMPARE(root->hasFocus(), false);
- QCOMPARE(child->hasFocus(), false);
- QCOMPARE(scope->hasFocus(), false);
- QCOMPARE(scopedChild->hasFocus(), false);
- QCOMPARE(scopedChild2->hasFocus(), false);
-
- root->setFocus(true);
- scope->setFocus(true);
- scopedChild2->setFocus(true);
- QCOMPARE(root->hasFocus(), true);
- QCOMPARE(child->hasFocus(), false);
- QCOMPARE(scope->hasFocus(), true);
- QCOMPARE(scopedChild->hasFocus(), false);
- QCOMPARE(scopedChild2->hasFocus(), true);
-
- root->setFocus(false);
- child->setFocus(true);
- scopedChild->setFocus(true);
- scope->setFocus(false);
- QCOMPARE(root->hasFocus(), false);
- QCOMPARE(child->hasFocus(), true);
- QCOMPARE(scope->hasFocus(), false);
- QCOMPARE(scopedChild->hasFocus(), true);
- QCOMPARE(scopedChild2->hasFocus(), true);
-
- delete root;
-}
-
-struct FocusData {
- FocusData() : focus(false), activeFocus(false) {}
-
- void set(bool f, bool af) { focus = f; activeFocus = af; }
- bool focus;
- bool activeFocus;
-};
-struct FocusState : public QHash<QQuickItem *, FocusData>
-{
- FocusState() : activeFocusItem(0) {}
- FocusState &operator<<(QQuickItem *item) {
- insert(item, FocusData());
- return *this;
- }
-
- void active(QQuickItem *i) {
- activeFocusItem = i;
- }
- QQuickItem *activeFocusItem;
-};
-
-#define FVERIFY() \
- do { \
- if (focusState.activeFocusItem) { \
- QCOMPARE(canvas.activeFocusItem(), focusState.activeFocusItem); \
- if (qobject_cast<TestItem *>(canvas.activeFocusItem())) \
- QCOMPARE(qobject_cast<TestItem *>(canvas.activeFocusItem())->focused, true); \
- else if (qobject_cast<TestFocusScope *>(canvas.activeFocusItem())) \
- QCOMPARE(qobject_cast<TestFocusScope *>(canvas.activeFocusItem())->focused, true); \
- } else { \
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); \
- } \
- for (QHash<QQuickItem *, FocusData>::Iterator iter = focusState.begin(); \
- iter != focusState.end(); \
- iter++) { \
- QCOMPARE(iter.key()->hasFocus(), iter.value().focus); \
- QCOMPARE(iter.key()->hasActiveFocus(), iter.value().activeFocus); \
- } \
- } while (false)
-
-// Tests a simple set of top-level scoped items
-void tst_qquickitem::simpleFocus()
-{
- QQuickCanvas canvas;
- ensureFocus(&canvas);
-
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-24094: fails on Mac OS X 10.7");
-#endif
-
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *l1c1 = new TestItem(canvas.rootItem());
- QQuickItem *l1c2 = new TestItem(canvas.rootItem());
- QQuickItem *l1c3 = new TestItem(canvas.rootItem());
-
- QQuickItem *l2c1 = new TestItem(l1c1);
- QQuickItem *l2c2 = new TestItem(l1c1);
- QQuickItem *l2c3 = new TestItem(l1c3);
-
- FocusState focusState;
- focusState << l1c1 << l1c2 << l1c3
- << l2c1 << l2c2 << l2c3;
- FVERIFY();
-
- l1c1->setFocus(true);
- focusState[l1c1].set(true, true);
- focusState.active(l1c1);
- FVERIFY();
-
- l2c3->setFocus(true);
- focusState[l1c1].set(false, false);
- focusState[l2c3].set(true, true);
- focusState.active(l2c3);
- FVERIFY();
-
- l1c3->setFocus(true);
- focusState[l2c3].set(false, false);
- focusState[l1c3].set(true, true);
- focusState.active(l1c3);
- FVERIFY();
-
- l1c2->setFocus(false);
- FVERIFY();
-
- l1c3->setFocus(false);
- focusState[l1c3].set(false, false);
- focusState.active(0);
- FVERIFY();
-
- l2c1->setFocus(true);
- focusState[l2c1].set(true, true);
- focusState.active(l2c1);
- FVERIFY();
-}
-
-// Items with a focus scope
-void tst_qquickitem::scopedFocus()
-{
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *l1c1 = new TestItem(canvas.rootItem());
- QQuickItem *l1c2 = new TestItem(canvas.rootItem());
- QQuickItem *l1c3 = new TestItem(canvas.rootItem());
-
- QQuickItem *l2c1 = new TestItem(l1c1);
- QQuickItem *l2c2 = new TestItem(l1c1);
- QQuickItem *l2c3 = new TestFocusScope(l1c3);
-
- QQuickItem *l3c1 = new TestItem(l2c3);
- QQuickItem *l3c2 = new TestFocusScope(l2c3);
-
- QQuickItem *l4c1 = new TestItem(l3c2);
- QQuickItem *l4c2 = new TestItem(l3c2);
-
- FocusState focusState;
- focusState << l1c1 << l1c2 << l1c3
- << l2c1 << l2c2 << l2c3
- << l3c1 << l3c2
- << l4c1 << l4c2;
- FVERIFY();
-
- l4c2->setFocus(true);
- focusState[l4c2].set(true, false);
- FVERIFY();
-
- l4c1->setFocus(true);
- focusState[l4c2].set(false, false);
- focusState[l4c1].set(true, false);
- FVERIFY();
-
- l1c1->setFocus(true);
- focusState[l1c1].set(true, true);
- focusState.active(l1c1);
- FVERIFY();
-
- l3c2->setFocus(true);
- focusState[l3c2].set(true, false);
- FVERIFY();
-
- l2c3->setFocus(true);
- focusState[l1c1].set(false, false);
- focusState[l2c3].set(true, true);
- focusState[l3c2].set(true, true);
- focusState[l4c1].set(true, true);
- focusState.active(l4c1);
- FVERIFY();
-
- l3c2->setFocus(false);
- focusState[l3c2].set(false, false);
- focusState[l4c1].set(true, false);
- focusState.active(l2c3);
- FVERIFY();
-
- l3c2->setFocus(true);
- focusState[l3c2].set(true, true);
- focusState[l4c1].set(true, true);
- focusState.active(l4c1);
- FVERIFY();
-
- l4c1->setFocus(false);
- focusState[l4c1].set(false, false);
- focusState.active(l3c2);
- FVERIFY();
-
- l1c3->setFocus(true);
- focusState[l1c3].set(true, true);
- focusState[l2c3].set(false, false);
- focusState[l3c2].set(true, false);
- focusState.active(l1c3);
- FVERIFY();
-}
-
-// Tests focus corrects itself when a tree is added to a canvas for the first time
-void tst_qquickitem::addedToCanvas()
-{
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *item = new TestItem;
-
- FocusState focusState;
- focusState << item;
-
- item->setFocus(true);
- focusState[item].set(true, false);
- FVERIFY();
-
- item->setParentItem(canvas.rootItem());
- focusState[item].set(true, true);
- focusState.active(item);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *item = new TestItem(canvas.rootItem());
-
- QQuickItem *tree = new TestItem;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << item << tree << c1 << c2;
-
- item->setFocus(true);
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[item].set(true, true);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- focusState.active(item);
- FVERIFY();
-
- tree->setParentItem(item);
- focusState[c1].set(false, false);
- focusState[c2].set(false, false);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *tree = new TestItem;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << tree << c1 << c2;
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- FVERIFY();
-
- tree->setParentItem(canvas.rootItem());
- focusState[c1].set(true, true);
- focusState[c2].set(false, false);
- focusState.active(c1);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *tree = new TestFocusScope;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << tree << c1 << c2;
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- FVERIFY();
-
- tree->setParentItem(canvas.rootItem());
- focusState[c1].set(true, false);
- focusState[c2].set(false, false);
- FVERIFY();
-
- tree->setFocus(true);
- focusState[tree].set(true, true);
- focusState[c1].set(true, true);
- focusState.active(c1);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *tree = new TestFocusScope;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << tree << c1 << c2;
- tree->setFocus(true);
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[tree].set(true, false);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- FVERIFY();
-
- tree->setParentItem(canvas.rootItem());
- focusState[tree].set(true, true);
- focusState[c1].set(true, true);
- focusState[c2].set(false, false);
- focusState.active(c1);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *tree = new TestFocusScope;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << child << tree << c1 << c2;
- child->setFocus(true);
- tree->setFocus(true);
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[child].set(true, true);
- focusState[tree].set(true, false);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- focusState.active(child);
- FVERIFY();
-
- tree->setParentItem(canvas.rootItem());
- focusState[tree].set(false, false);
- focusState[c1].set(true, false);
- focusState[c2].set(false, false);
- FVERIFY();
-
- tree->setFocus(true);
- focusState[child].set(false, false);
- focusState[tree].set(true, true);
- focusState[c1].set(true, true);
- focusState.active(c1);
- FVERIFY();
- }
-}
-
-void tst_qquickitem::changeParent()
-{
- // Parent to no parent
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
-
- FocusState focusState;
- focusState << child;
- FVERIFY();
-
- child->setFocus(true);
- focusState[child].set(true, true);
- focusState.active(child);
- FVERIFY();
-
- child->setParentItem(0);
- focusState[child].set(true, false);
- focusState.active(0);
- FVERIFY();
- }
-
- // Different parent, same focus scope
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *child2 = new TestItem(canvas.rootItem());
-
- FocusState focusState;
- focusState << child << child2;
- FVERIFY();
-
- child->setFocus(true);
- focusState[child].set(true, true);
- focusState.active(child);
- FVERIFY();
-
- child->setParentItem(child2);
- FVERIFY();
- }
-
- // Different parent, different focus scope
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
- QQuickItem *item = new TestItem(child);
-
- FocusState focusState;
- focusState << child << child2 << item;
- FVERIFY();
-
- item->setFocus(true);
- focusState[item].set(true, true);
- focusState.active(item);
- FVERIFY();
-
- item->setParentItem(child2);
- focusState[item].set(true, false);
- focusState.active(0);
- FVERIFY();
- }
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
- QQuickItem *item = new TestItem(child2);
-
- FocusState focusState;
- focusState << child << child2 << item;
- FVERIFY();
-
- item->setFocus(true);
- focusState[item].set(true, false);
- focusState.active(0);
- FVERIFY();
-
- item->setParentItem(child);
- focusState[item].set(true, true);
- focusState.active(item);
- FVERIFY();
- }
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
- QQuickItem *item = new TestItem(child2);
-
- FocusState focusState;
- focusState << child << child2 << item;
- FVERIFY();
-
- child->setFocus(true);
- item->setFocus(true);
- focusState[child].set(true, true);
- focusState[item].set(true, false);
- focusState.active(child);
- FVERIFY();
-
- item->setParentItem(child);
- focusState[item].set(false, false);
- FVERIFY();
- }
-
-}
-
-void tst_qquickitem::constructor()
-{
- QQuickItem *root = new QQuickItem;
- QVERIFY(root->parent() == 0);
- QVERIFY(root->parentItem() == 0);
-
- QQuickItem *child1 = new QQuickItem(root);
- QVERIFY(child1->parent() == root);
- QVERIFY(child1->parentItem() == root);
- QCOMPARE(root->childItems().count(), 1);
- QCOMPARE(root->childItems().at(0), child1);
-
- QQuickItem *child2 = new QQuickItem(root);
- QVERIFY(child2->parent() == root);
- QVERIFY(child2->parentItem() == root);
- QCOMPARE(root->childItems().count(), 2);
- QCOMPARE(root->childItems().at(0), child1);
- QCOMPARE(root->childItems().at(1), child2);
-
- delete root;
-}
-
-void tst_qquickitem::setParentItem()
-{
- QQuickItem *root = new QQuickItem;
- QVERIFY(root->parent() == 0);
- QVERIFY(root->parentItem() == 0);
-
- QQuickItem *child1 = new QQuickItem;
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
-
- child1->setParentItem(root);
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == root);
- QCOMPARE(root->childItems().count(), 1);
- QCOMPARE(root->childItems().at(0), child1);
-
- QQuickItem *child2 = new QQuickItem;
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == 0);
- child2->setParentItem(root);
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == root);
- QCOMPARE(root->childItems().count(), 2);
- QCOMPARE(root->childItems().at(0), child1);
- QCOMPARE(root->childItems().at(1), child2);
-
- child1->setParentItem(0);
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
- QCOMPARE(root->childItems().count(), 1);
- QCOMPARE(root->childItems().at(0), child2);
-
- delete root;
-
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == 0);
-
- delete child1;
- delete child2;
-}
-
-void tst_qquickitem::visible()
-{
- QQuickItem *root = new QQuickItem;
-
- QQuickItem *child1 = new QQuickItem;
- child1->setParentItem(root);
-
- QQuickItem *child2 = new QQuickItem;
- child2->setParentItem(root);
-
- QVERIFY(child1->isVisible());
- QVERIFY(child2->isVisible());
-
- root->setVisible(false);
- QVERIFY(!child1->isVisible());
- QVERIFY(!child2->isVisible());
-
- root->setVisible(true);
- QVERIFY(child1->isVisible());
- QVERIFY(child2->isVisible());
-
- child1->setVisible(false);
- QVERIFY(!child1->isVisible());
- QVERIFY(child2->isVisible());
-
- child2->setParentItem(child1);
- QVERIFY(!child1->isVisible());
- QVERIFY(!child2->isVisible());
-
- child2->setParentItem(root);
- QVERIFY(!child1->isVisible());
- QVERIFY(child2->isVisible());
-
- delete root;
- delete child1;
- delete child2;
-}
-
-void tst_qquickitem::enabled()
-{
- QQuickItem *root = new QQuickItem;
-
- QQuickItem *child1 = new QQuickItem;
- child1->setParentItem(root);
-
- QQuickItem *child2 = new QQuickItem;
- child2->setParentItem(root);
-
- QVERIFY(child1->isEnabled());
- QVERIFY(child2->isEnabled());
-
- root->setEnabled(false);
- QVERIFY(!child1->isEnabled());
- QVERIFY(!child2->isEnabled());
-
- root->setEnabled(true);
- QVERIFY(child1->isEnabled());
- QVERIFY(child2->isEnabled());
-
- child1->setEnabled(false);
- QVERIFY(!child1->isEnabled());
- QVERIFY(child2->isEnabled());
-
- child2->setParentItem(child1);
- QVERIFY(!child1->isEnabled());
- QVERIFY(!child2->isEnabled());
-
- child2->setParentItem(root);
- QVERIFY(!child1->isEnabled());
- QVERIFY(child2->isEnabled());
-
- delete root;
- delete child1;
- delete child2;
-}
-
-void tst_qquickitem::enabledFocus()
-{
- QQuickCanvas canvas;
- ensureFocus(&canvas);
-
- QQuickFocusScope root;
-
- root.setFocus(true);
- root.setEnabled(false);
-
- QCOMPARE(root.isEnabled(), false);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), false);
-
- root.setParentItem(canvas.rootItem());
-
- QCOMPARE(root.isEnabled(), false);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
-
- root.setEnabled(true);
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- QQuickItem child1;
- child1.setParentItem(&root);
-
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- QQuickItem child2;
- child2.setFocus(true);
- child2.setParentItem(&root);
-
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(child2.isEnabled(), true);
- QCOMPARE(child2.hasFocus(), true);
- QCOMPARE(child2.hasActiveFocus(), true);
- QCOMPARE(canvas.activeFocusItem(), &child2);
-
- child2.setEnabled(false);
-
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), true);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- child1.setEnabled(false);
- QCOMPARE(child1.isEnabled(), false);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
-
- child1.setFocus(true);
- QCOMPARE(child1.isEnabled(), false);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), false);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- child1.setEnabled(true);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), true);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&child1));
-
- root.setFocus(false);
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), false);
- QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
-
- child2.forceActiveFocus();
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), true);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- root.setEnabled(false);
- QCOMPARE(root.isEnabled(), false);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(child1.isEnabled(), false);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), true);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
-
- child1.forceActiveFocus();
- QCOMPARE(root.isEnabled(), false);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(child1.isEnabled(), false);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), false);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
-
- root.setEnabled(true);
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), true);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), false);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&child1));
-}
-
-void tst_qquickitem::mouseGrab()
-{
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(200, 200);
- canvas->show();
-
- TestItem *child1 = new TestItem;
- child1->setAcceptedMouseButtons(Qt::LeftButton);
- child1->setSize(QSizeF(200, 100));
- child1->setParentItem(canvas->rootItem());
-
- TestItem *child2 = new TestItem;
- child2->setAcceptedMouseButtons(Qt::LeftButton);
- child2->setY(51);
- child2->setSize(QSizeF(200, 100));
- child2->setParentItem(canvas->rootItem());
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(100);
- QVERIFY(canvas->mouseGrabberItem() == child1);
- QTest::qWait(100);
-
- QCOMPARE(child1->pressCount, 1);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QVERIFY(canvas->mouseGrabberItem() == 0);
- QCOMPARE(child1->releaseCount, 1);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QVERIFY(canvas->mouseGrabberItem() == child1);
- QCOMPARE(child1->pressCount, 2);
- child1->setEnabled(false);
- QVERIFY(canvas->mouseGrabberItem() == 0);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QCOMPARE(child1->releaseCount, 1);
- child1->setEnabled(true);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QVERIFY(canvas->mouseGrabberItem() == child1);
- QCOMPARE(child1->pressCount, 3);
- child1->setVisible(false);
- QVERIFY(canvas->mouseGrabberItem() == 0);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QCOMPARE(child1->releaseCount, 1);
- child1->setVisible(true);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QVERIFY(canvas->mouseGrabberItem() == child1);
- QCOMPARE(child1->pressCount, 4);
- child2->grabMouse();
- QVERIFY(canvas->mouseGrabberItem() == child2);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QCOMPARE(child1->releaseCount, 1);
- QCOMPARE(child2->releaseCount, 1);
-
- child2->grabMouse();
- QVERIFY(canvas->mouseGrabberItem() == child2);
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QCOMPARE(child1->pressCount, 4);
- QCOMPARE(child2->pressCount, 1);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QCOMPARE(child1->releaseCount, 1);
- QCOMPARE(child2->releaseCount, 2);
-
- delete child1;
- delete child2;
- delete canvas;
-}
-
-void tst_qquickitem::touchEventAcceptIgnore_data()
-{
- QTest::addColumn<bool>("itemSupportsTouch");
-
- QTest::newRow("with touch") << true;
- QTest::newRow("without touch") << false;
-}
-
-void tst_qquickitem::touchEventAcceptIgnore()
-{
- QFETCH(bool, itemSupportsTouch);
-
- TestCanvas *canvas = new TestCanvas;
- canvas->resize(100, 100);
- canvas->show();
-
- TestItem *item = new TestItem;
- item->setSize(QSizeF(100, 100));
- item->setParentItem(canvas->rootItem());
- item->acceptIncomingTouchEvents = itemSupportsTouch;
-
- static QTouchDevice* device = 0;
- if (!device) {
- device =new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
- }
-
- // Send Begin, Update & End touch sequence
- {
- QTouchEvent::TouchPoint point;
- point.setId(1);
- point.setPos(QPointF(50, 50));
- point.setScreenPos(point.pos());
- point.setState(Qt::TouchPointPressed);
-
- QTouchEvent event(QEvent::TouchBegin, device,
- Qt::NoModifier,
- Qt::TouchPointPressed,
- QList<QTouchEvent::TouchPoint>() << point);
- event.setAccepted(true);
-
- item->touchEventReached = false;
-
- bool accepted = canvas->event(&event);
-
- QVERIFY(item->touchEventReached);
- QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
- }
- {
- QTouchEvent::TouchPoint point;
- point.setId(1);
- point.setPos(QPointF(60, 60));
- point.setScreenPos(point.pos());
- point.setState(Qt::TouchPointMoved);
-
- QTouchEvent event(QEvent::TouchUpdate, device,
- Qt::NoModifier,
- Qt::TouchPointMoved,
- QList<QTouchEvent::TouchPoint>() << point);
- event.setAccepted(true);
-
- item->touchEventReached = false;
-
- bool accepted = canvas->event(&event);
-
- QCOMPARE(item->touchEventReached, itemSupportsTouch);
- QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
- }
- {
- QTouchEvent::TouchPoint point;
- point.setId(1);
- point.setPos(QPointF(60, 60));
- point.setScreenPos(point.pos());
- point.setState(Qt::TouchPointReleased);
-
- QTouchEvent event(QEvent::TouchEnd, device,
- Qt::NoModifier,
- Qt::TouchPointReleased,
- QList<QTouchEvent::TouchPoint>() << point);
- event.setAccepted(true);
-
- item->touchEventReached = false;
-
- bool accepted = canvas->event(&event);
-
- QCOMPARE(item->touchEventReached, itemSupportsTouch);
- QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
- }
-
- delete item;
- delete canvas;
-}
-
-void tst_qquickitem::polishOutsideAnimation()
-{
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(200, 200);
- canvas->show();
-
- TestPolishItem *item = new TestPolishItem(canvas->rootItem());
- item->setSize(QSizeF(200, 100));
- QTest::qWait(50);
-
- QTimer::singleShot(10, item, SLOT(doPolish()));
- QTRY_VERIFY(item->wasPolished);
-
- delete item;
- delete canvas;
-}
-
-void tst_qquickitem::polishOnCompleted()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("polishOnCompleted.qml"));
- view->show();
-
- TestPolishItem *item = qobject_cast<TestPolishItem*>(view->rootObject());
- QVERIFY(item);
-
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation");
-#endif
-
- QTRY_VERIFY(item->wasPolished);
-
- delete view;
-}
-
-void tst_qquickitem::wheelEvent_data()
-{
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("enabled");
-
- QTest::newRow("visible and enabled") << true << true;
- QTest::newRow("visible and disabled") << true << false;
- QTest::newRow("invisible and enabled") << false << true;
- QTest::newRow("invisible and disabled") << false << false;
-}
-
-void tst_qquickitem::wheelEvent()
-{
- QFETCH(bool, visible);
- QFETCH(bool, enabled);
-
- const bool shouldReceiveWheelEvents = visible && enabled;
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(200, 200);
- canvas->show();
-
- TestItem *item = new TestItem;
- item->setSize(QSizeF(200, 100));
- item->setParentItem(canvas->rootItem());
-
- item->setEnabled(enabled);
- item->setVisible(visible);
-
- QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
- event.setAccepted(false);
- QGuiApplication::sendEvent(canvas, &event);
-
- if (shouldReceiveWheelEvents) {
- QVERIFY(event.isAccepted());
- QCOMPARE(item->wheelCount, 1);
- } else {
- QVERIFY(!event.isAccepted());
- QCOMPARE(item->wheelCount, 0);
- }
-
- delete canvas;
-}
-
-class HoverItem : public QQuickItem
-{
-Q_OBJECT
-public:
- HoverItem(QQuickItem *parent = 0)
- : QQuickItem(parent), hoverEnterCount(0), hoverMoveCount(0), hoverLeaveCount(0)
- { }
- void resetCounters() {
- hoverEnterCount = 0;
- hoverMoveCount = 0;
- hoverLeaveCount = 0;
- }
- int hoverEnterCount;
- int hoverMoveCount;
- int hoverLeaveCount;
-protected:
- virtual void hoverEnterEvent(QHoverEvent *event) {
- event->accept();
- ++hoverEnterCount;
- }
- virtual void hoverMoveEvent(QHoverEvent *event) {
- event->accept();
- ++hoverMoveCount;
- }
- virtual void hoverLeaveEvent(QHoverEvent *event) {
- event->accept();
- ++hoverLeaveCount;
- }
-};
-
-void tst_qquickitem::hoverEvent_data()
-{
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("enabled");
- QTest::addColumn<bool>("acceptHoverEvents");
-
- QTest::newRow("visible, enabled, accept hover") << true << true << true;
- QTest::newRow("visible, disabled, accept hover") << true << false << true;
- QTest::newRow("invisible, enabled, accept hover") << false << true << true;
- QTest::newRow("invisible, disabled, accept hover") << false << false << true;
-
- QTest::newRow("visible, enabled, not accept hover") << true << true << false;
- QTest::newRow("visible, disabled, not accept hover") << true << false << false;
- QTest::newRow("invisible, enabled, not accept hover") << false << true << false;
- QTest::newRow("invisible, disabled, not accept hover") << false << false << false;
-}
-
-// ### For some unknown reason QTest::mouseMove() isn't working correctly.
-static void sendMouseMove(QObject *object, const QPoint &position)
-{
- QMouseEvent moveEvent(QEvent::MouseMove, position, Qt::NoButton, Qt::NoButton, 0);
- QGuiApplication::sendEvent(object, &moveEvent);
-}
-
-void tst_qquickitem::hoverEvent()
-{
- QFETCH(bool, visible);
- QFETCH(bool, enabled);
- QFETCH(bool, acceptHoverEvents);
-
- QQuickCanvas *canvas = new QQuickCanvas();
- canvas->resize(200, 200);
- canvas->show();
-
- HoverItem *item = new HoverItem;
- item->setSize(QSizeF(100, 100));
- item->setParentItem(canvas->rootItem());
-
- item->setEnabled(enabled);
- item->setVisible(visible);
- item->setAcceptHoverEvents(acceptHoverEvents);
-
- const QPoint outside(150, 150);
- const QPoint inside(50, 50);
- const QPoint anotherInside(51, 51);
-
- sendMouseMove(canvas, outside);
- item->resetCounters();
-
- // Enter, then move twice inside, then leave.
- sendMouseMove(canvas, inside);
- sendMouseMove(canvas, anotherInside);
- sendMouseMove(canvas, inside);
- sendMouseMove(canvas, outside);
-
- const bool shouldReceiveHoverEvents = visible && enabled && acceptHoverEvents;
- if (shouldReceiveHoverEvents) {
- QCOMPARE(item->hoverEnterCount, 1);
- QCOMPARE(item->hoverMoveCount, 2);
- QCOMPARE(item->hoverLeaveCount, 1);
- } else {
- QCOMPARE(item->hoverEnterCount, 0);
- QCOMPARE(item->hoverMoveCount, 0);
- QCOMPARE(item->hoverLeaveCount, 0);
- }
-
- delete canvas;
-}
-
-void tst_qquickitem::hoverEventInParent()
-{
- QQuickCanvas *canvas = new QQuickCanvas();
- canvas->resize(200, 200);
- canvas->show();
-
- HoverItem *parentItem = new HoverItem(canvas->rootItem());
- parentItem->setSize(QSizeF(200, 200));
- parentItem->setAcceptHoverEvents(true);
-
- HoverItem *leftItem = new HoverItem(parentItem);
- leftItem->setSize(QSizeF(100, 200));
- leftItem->setAcceptHoverEvents(true);
-
- HoverItem *rightItem = new HoverItem(parentItem);
- rightItem->setSize(QSizeF(100, 200));
- rightItem->setPos(QPointF(100, 0));
- rightItem->setAcceptHoverEvents(true);
-
- const QPoint insideLeft(50, 100);
- const QPoint insideRight(150, 100);
-
- sendMouseMove(canvas, insideLeft);
- parentItem->resetCounters();
- leftItem->resetCounters();
- rightItem->resetCounters();
-
- sendMouseMove(canvas, insideRight);
- QCOMPARE(parentItem->hoverEnterCount, 0);
- QCOMPARE(parentItem->hoverLeaveCount, 0);
- QCOMPARE(leftItem->hoverEnterCount, 0);
- QCOMPARE(leftItem->hoverLeaveCount, 1);
- QCOMPARE(rightItem->hoverEnterCount, 1);
- QCOMPARE(rightItem->hoverLeaveCount, 0);
-
- sendMouseMove(canvas, insideLeft);
- QCOMPARE(parentItem->hoverEnterCount, 0);
- QCOMPARE(parentItem->hoverLeaveCount, 0);
- QCOMPARE(leftItem->hoverEnterCount, 1);
- QCOMPARE(leftItem->hoverLeaveCount, 1);
- QCOMPARE(rightItem->hoverEnterCount, 1);
- QCOMPARE(rightItem->hoverLeaveCount, 1);
-
- delete canvas;
-}
-
-void tst_qquickitem::paintOrder_data()
-{
- const QUrl order1Url = testFileUrl("order.1.qml");
- const QUrl order2Url = testFileUrl("order.2.qml");
-
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<int>("op");
- QTest::addColumn<QVariant>("param1");
- QTest::addColumn<QVariant>("param2");
- QTest::addColumn<QStringList>("expected");
-
- QTest::newRow("test 1 noop") << order1Url
- << int(NoOp) << QVariant() << QVariant()
- << (QStringList() << "1" << "2" << "3");
- QTest::newRow("test 1 add") << order1Url
- << int(Append) << QVariant("new") << QVariant()
- << (QStringList() << "1" << "2" << "3" << "new");
- QTest::newRow("test 1 remove") << order1Url
- << int(Remove) << QVariant(1) << QVariant()
- << (QStringList() << "1" << "3");
- QTest::newRow("test 1 stack before") << order1Url
- << int(StackBefore) << QVariant(2) << QVariant(1)
- << (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 1 stack after") << order1Url
- << int(StackAfter) << QVariant(0) << QVariant(1)
- << (QStringList() << "2" << "1" << "3");
- QTest::newRow("test 1 set z") << order1Url
- << int(SetZ) << QVariant(1) << QVariant(qreal(1.))
- << (QStringList() << "1" << "3" << "2");
-
- QTest::newRow("test 2 noop") << order2Url
- << int(NoOp) << QVariant() << QVariant()
- << (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 add") << order2Url
- << int(Append) << QVariant("new") << QVariant()
- << (QStringList() << "1" << "3" << "new" << "2");
- QTest::newRow("test 2 remove 1") << order2Url
- << int(Remove) << QVariant(1) << QVariant()
- << (QStringList() << "1" << "3");
- QTest::newRow("test 2 remove 2") << order2Url
- << int(Remove) << QVariant(2) << QVariant()
- << (QStringList() << "1" << "2");
- QTest::newRow("test 2 stack before 1") << order2Url
- << int(StackBefore) << QVariant(1) << QVariant(0)
- << (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 stack before 2") << order2Url
- << int(StackBefore) << QVariant(2) << QVariant(0)
- << (QStringList() << "3" << "1" << "2");
- QTest::newRow("test 2 stack after 1") << order2Url
- << int(StackAfter) << QVariant(0) << QVariant(1)
- << (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 stack after 2") << order2Url
- << int(StackAfter) << QVariant(0) << QVariant(2)
- << (QStringList() << "3" << "1" << "2");
- QTest::newRow("test 1 set z") << order1Url
- << int(SetZ) << QVariant(2) << QVariant(qreal(2.))
- << (QStringList() << "1" << "2" << "3");
-}
-
-void tst_qquickitem::paintOrder()
-{
- QFETCH(QUrl, source);
- QFETCH(int, op);
- QFETCH(QVariant, param1);
- QFETCH(QVariant, param2);
- QFETCH(QStringList, expected);
-
- QQuickView view;
- view.setSource(source);
-
- QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject());
- QVERIFY(root);
-
- switch (op) {
- case Append: {
- QQuickItem *item = new QQuickItem(root);
- item->setObjectName(param1.toString());
- }
- break;
- case Remove: {
- QQuickItem *item = root->childItems().at(param1.toInt());
- delete item;
- }
- break;
- case StackBefore: {
- QQuickItem *item1 = root->childItems().at(param1.toInt());
- QQuickItem *item2 = root->childItems().at(param2.toInt());
- item1->stackBefore(item2);
- }
- break;
- case StackAfter: {
- QQuickItem *item1 = root->childItems().at(param1.toInt());
- QQuickItem *item2 = root->childItems().at(param2.toInt());
- item1->stackAfter(item2);
- }
- break;
- case SetZ: {
- QQuickItem *item = root->childItems().at(param1.toInt());
- item->setZ(param2.toReal());
- }
- break;
- default:
- break;
- }
-
- QList<QQuickItem*> list = QQuickItemPrivate::get(root)->paintOrderChildItems();
-
- QStringList items;
- for (int i = 0; i < list.count(); ++i)
- items << list.at(i)->objectName();
-
- QCOMPARE(items, expected);
-}
-
-
-QTEST_MAIN(tst_qquickitem)
-
-#include "tst_qquickitem.moc"
diff --git a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro b/tests/auto/qtquick2/qquickitem2/qquickitem2.pro
deleted file mode 100644
index 44d3ba37c8..0000000000
--- a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickitem2
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickitem.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp
deleted file mode 100644
index 9891b8718a..0000000000
--- a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp
+++ /dev/null
@@ -1,1380 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick/qquickview.h>
-#include <QtGui/private/qinputmethod_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquicktextinput_p.h>
-#include <private/qquickitem_p.h>
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-#include "../../shared/platforminputcontext.h"
-
-using namespace QQuickVisualTestUtil;
-
-class tst_QQuickItem : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickItem();
-
-private slots:
- void initTestCase();
- void cleanup();
-
- void keys();
- void keysProcessingOrder();
- void keysim();
- void keyNavigation();
- void keyNavigation_RightToLeft();
- void keyNavigation_skipNotVisible();
- void keyNavigation_implicitSetting();
- void layoutMirroring();
- void layoutMirroringIllegalParent();
- void smooth();
- void clip();
- void mapCoordinates();
- void mapCoordinates_data();
- void propertyChanges();
- void transforms();
- void transforms_data();
- void childrenRect();
- void childrenRectBug();
- void childrenRectBug2();
- void childrenRectBug3();
-
- void childrenProperty();
- void resourcesProperty();
-
- void transformCrash();
- void implicitSize();
- void qtbug_16871();
- void visibleChildren();
- void parentLoop();
-private:
- QDeclarativeEngine engine;
-};
-
-class KeysTestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged)
-
-public:
- KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {}
-
- void reset() {
- mKey = 0;
- mText = QString();
- mModifiers = 0;
- mForwardedKey = 0;
- }
-
- bool processLast() const { return mLast; }
- void setProcessLast(bool b) {
- if (b != mLast) {
- mLast = b;
- emit processLastChanged();
- }
- }
-
-public slots:
- void keyPress(int key, QString text, int modifiers) {
- mKey = key;
- mText = text;
- mModifiers = modifiers;
- }
- void keyRelease(int key, QString text, int modifiers) {
- mKey = key;
- mText = text;
- mModifiers = modifiers;
- }
- void forwardedKey(int key) {
- mForwardedKey = key;
- }
-
-signals:
- void processLastChanged();
-
-public:
- int mKey;
- QString mText;
- int mModifiers;
- int mForwardedKey;
- bool mLast;
-
-private:
-};
-
-class KeyTestItem : public QQuickItem
-{
- Q_OBJECT
-public:
- KeyTestItem(QQuickItem *parent=0) : QQuickItem(parent), mKey(0) {}
-
-protected:
- void keyPressEvent(QKeyEvent *e) {
- mKey = e->key();
-
- if (e->key() == Qt::Key_A)
- e->accept();
- else
- e->ignore();
- }
-
- void keyReleaseEvent(QKeyEvent *e) {
- if (e->key() == Qt::Key_B)
- e->accept();
- else
- e->ignore();
- }
-
-public:
- int mKey;
-};
-
-QML_DECLARE_TYPE(KeyTestItem);
-
-
-tst_QQuickItem::tst_QQuickItem()
-{
-}
-
-void tst_QQuickItem::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem");
-}
-
-void tst_QQuickItem::cleanup()
-{
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = 0;
-}
-
-void tst_QQuickItem::keys()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- KeysTestObject *testObject = new KeysTestObject;
- canvas->rootContext()->setContextProperty("keysTestObject", testObject);
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
- canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true));
-
- canvas->setSource(testFileUrl("keystest.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QVERIFY(canvas->rootObject());
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::ShiftModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Return));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return));
- QCOMPARE(testObject->mText, QLatin1String("Return"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_0));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0));
- QCOMPARE(testObject->mText, QLatin1String("0"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_9));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9));
- QCOMPARE(testObject->mText, QLatin1String("9"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Tab));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab));
- QCOMPARE(testObject->mText, QLatin1String("Tab"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Backtab));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab));
- QCOMPARE(testObject->mText, QLatin1String("Backtab"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false));
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, 0);
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(!key.isAccepted());
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Return));
- QVERIFY(key.isAccepted());
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickItem::keysProcessingOrder()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- KeysTestObject *testObject = new KeysTestObject;
- canvas->rootContext()->setContextProperty("keysTestObject", testObject);
-
- canvas->setSource(testFileUrl("keyspriority.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- KeyTestItem *testItem = qobject_cast<KeyTestItem*>(canvas->rootObject());
- QVERIFY(testItem);
-
- QCOMPARE(testItem->property("priorityTest").toInt(), 0);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- testObject->setProcessLast(true);
-
- QCOMPARE(testItem->property("priorityTest").toInt(), 1);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_B));
- QCOMPARE(testObject->mText, QLatin1String("B"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(key.isAccepted());
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickItem::keysim()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keysim.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QVERIFY(canvas->rootObject());
- QVERIFY(canvas->rootObject()->hasFocus() && canvas->rootObject()->hasActiveFocus());
-
- QQuickTextInput *input = canvas->rootObject()->findChild<QQuickTextInput*>();
- QVERIFY(input);
-
- QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev);
-
- QEXPECT_FAIL("", "QTBUG-24280", Continue);
- QCOMPARE(input->text(), QLatin1String("Hello world!"));
-
- delete canvas;
-}
-
-QQuickItemPrivate *childPrivate(QQuickItem *rootItem, const char * itemString)
-{
- QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
- QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item);
- return itemPrivate;
-}
-
-QVariant childProperty(QQuickItem *rootItem, const char * itemString, const char * property)
-{
- QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
- return item->property(property);
-}
-
-bool anchorsMirrored(QQuickItem *rootItem, const char * itemString)
-{
- QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
- QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item);
- return itemPrivate->anchors()->mirrored();
-}
-
-void tst_QQuickItem::layoutMirroring()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("layoutmirroring.qml"));
- canvas->show();
-
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem);
- QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(rootItem);
- QVERIFY(rootPrivate);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
-
- QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true);
- QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true);
- QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false);
- QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false);
- QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true);
- QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false);
-
- // load dynamic content using Loader that needs to inherit mirroring
- rootItem->setProperty("state", "newContent");
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
-
- // disable inheritance
- rootItem->setProperty("childrenInherit", false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false);
-
- // re-enable inheritance
- rootItem->setProperty("childrenInherit", true);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
-
- //
- // dynamic parenting
- //
- QQuickItem *parentItem1 = new QQuickItem();
- QQuickItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
- QQuickItemPrivate::get(parentItem1)->isMirrorImplicit = false;
- QQuickItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true
- QQuickItemPrivate::get(parentItem1)->resolveLayoutMirror();
-
- // inherit in constructor
- QQuickItem *childItem1 = new QQuickItem(parentItem1);
- QCOMPARE(QQuickItemPrivate::get(childItem1)->effectiveLayoutMirror, true);
- QCOMPARE(QQuickItemPrivate::get(childItem1)->inheritMirrorFromParent, true);
-
- // inherit through a parent change
- QQuickItem *childItem2 = new QQuickItem();
- QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
- childItem2->setParentItem(parentItem1);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, true);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, true);
-
- // stop inherting through a parent change
- QQuickItem *parentItem2 = new QQuickItem();
- QQuickItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
- QQuickItemPrivate::get(parentItem2)->resolveLayoutMirror();
- childItem2->setParentItem(parentItem2);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
-
- delete parentItem1;
- delete parentItem2;
-}
-
-void tst_QQuickItem::layoutMirroringIllegalParent()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile(""));
- QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items");
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_QQuickItem::keyNavigation()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keynavigationtest.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // down
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // up
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QQuickItem::keyNavigation_RightToLeft()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keynavigationtest.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem);
- QQuickItemPrivate* rootItemPrivate = QQuickItemPrivate::get(rootItem);
-
- rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true
- rootItemPrivate->isMirrorImplicit = false;
- rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true
- rootItemPrivate->resolveLayoutMirror();
-
- QEvent wa(QEvent::WindowActivate);
- QGuiApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QGuiApplication::sendEvent(canvas, &fe);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QQuickItem::keyNavigation_skipNotVisible()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keynavigationtest.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // Set item 2 to not visible
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- item->setVisible(false);
- QVERIFY(!item->isVisible());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- //Set item 3 to not visible
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- item->setVisible(false);
- QVERIFY(!item->isVisible());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QQuickItem::keyNavigation_implicitSetting()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keynavigationtest_implicit.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QEvent wa(QEvent::WindowActivate);
- QGuiApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QGuiApplication::sendEvent(canvas, &fe);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item1
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // down
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // move to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // up
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QQuickItem::smooth()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { smooth: false; }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(smoothChanged(bool)));
-
- QVERIFY(item);
- QVERIFY(!item->smooth());
-
- item->setSmooth(true);
- QVERIFY(item->smooth());
- QCOMPARE(spy.count(),1);
- QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
-
- item->setSmooth(true);
- QCOMPARE(spy.count(),1);
-
- item->setSmooth(false);
- QVERIFY(!item->smooth());
- QCOMPARE(spy.count(),2);
- item->setSmooth(false);
- QCOMPARE(spy.count(),2);
-
- delete item;
-}
-
-void tst_QQuickItem::clip()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem { clip: false\n }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(clipChanged(bool)));
-
- QVERIFY(item);
- QVERIFY(!item->clip());
-
- item->setClip(true);
- QVERIFY(item->clip());
-
- QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
-
- QCOMPARE(spy.count(),1);
- item->setClip(true);
- QCOMPARE(spy.count(),1);
-
- item->setClip(false);
- QVERIFY(!item->clip());
- QCOMPARE(spy.count(),2);
- item->setClip(false);
- QCOMPARE(spy.count(),2);
-
- delete item;
-}
-
-void tst_QQuickItem::mapCoordinates()
-{
- QFETCH(int, x);
- QFETCH(int, y);
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(300, 300));
- canvas->setSource(testFileUrl("mapCoordinates.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root != 0);
- QQuickItem *a = findItem<QQuickItem>(canvas->rootObject(), "itemA");
- QVERIFY(a != 0);
- QQuickItem *b = findItem<QQuickItem>(canvas->rootObject(), "itemB");
- QVERIFY(b != 0);
-
- QVariant result;
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAToB",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToItem(b, QPointF(x, y)));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromItem(b, QPointF(x, y)));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToScene(QPointF(x, y)));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromScene(QPointF(x, y)));
-
- QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
- QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QVERIFY(result.toBool());
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QVERIFY(result.toBool());
-
- delete canvas;
-}
-
-void tst_QQuickItem::mapCoordinates_data()
-{
- QTest::addColumn<int>("x");
- QTest::addColumn<int>("y");
-
- for (int i=-20; i<=20; i+=10)
- QTest::newRow(QTest::toString(i)) << i << i;
-}
-
-void tst_QQuickItem::transforms_data()
-{
- QTest::addColumn<QByteArray>("qml");
- QTest::addColumn<QTransform>("transform");
- QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }")
- << QTransform(1,0,0,0,1,0,10,20,1);
- QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }")
- << QTransform(0,1,0,-1,0,0,0,0,1);
- QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }")
- << QTransform(1.5,0,0,0,-2,0,0,0,1);
- QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]")
- << QTransform(1,0,0,0,1,0,10,20,1) * QTransform(1.5,0,0,0,-2,0,0,0,1);
-}
-
-void tst_QQuickItem::transforms()
-{
- QFETCH(QByteArray, qml);
- QFETCH(QTransform, transform);
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(item->itemTransform(0,0), transform);
-}
-
-void tst_QQuickItem::childrenProperty()
-{
- QDeclarativeComponent component(&engine, testFileUrl("childrenProperty.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- delete o;
-}
-
-void tst_QQuickItem::resourcesProperty()
-{
- QDeclarativeComponent component(&engine, testFileUrl("resourcesProperty.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- delete o;
-}
-
-void tst_QQuickItem::propertyChanges()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(300, 300));
- canvas->setSource(testFileUrl("propertychanges.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item");
- QQuickItem *parentItem = findItem<QQuickItem>(canvas->rootObject(), "parentItem");
-
- QVERIFY(item);
- QVERIFY(parentItem);
-
- QSignalSpy parentSpy(item, SIGNAL(parentChanged(QQuickItem *)));
- QSignalSpy widthSpy(item, SIGNAL(widthChanged()));
- QSignalSpy heightSpy(item, SIGNAL(heightChanged()));
- QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
- QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
- QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
- QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged()));
- QSignalSpy xSpy(item, SIGNAL(xChanged()));
- QSignalSpy ySpy(item, SIGNAL(yChanged()));
-
- item->setParentItem(parentItem);
- item->setWidth(100.0);
- item->setHeight(200.0);
- item->setFocus(true);
- item->setBaselineOffset(10.0);
-
- QCOMPARE(item->parentItem(), parentItem);
- QCOMPARE(parentSpy.count(),1);
- QList<QVariant> parentArguments = parentSpy.first();
- QVERIFY(parentArguments.count() == 1);
- QCOMPARE(item->parentItem(), qvariant_cast<QQuickItem *>(parentArguments.at(0)));
- QCOMPARE(childrenChangedSpy.count(),1);
-
- item->setParentItem(parentItem);
- QCOMPARE(childrenChangedSpy.count(),1);
-
- QCOMPARE(item->width(), 100.0);
- QCOMPARE(widthSpy.count(),1);
-
- QCOMPARE(item->height(), 200.0);
- QCOMPARE(heightSpy.count(),1);
-
- QCOMPARE(item->baselineOffset(), 10.0);
- QCOMPARE(baselineOffsetSpy.count(),1);
- QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
- QVERIFY(baselineOffsetArguments.count() == 1);
- QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
-
- QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
- QCOMPARE(childrenRectSpy.count(),1);
- QList<QVariant> childrenRectArguments = childrenRectSpy.at(0);
- QVERIFY(childrenRectArguments.count() == 1);
- QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
-
- QCOMPARE(item->hasActiveFocus(), true);
- QCOMPARE(focusSpy.count(),1);
- QList<QVariant> focusArguments = focusSpy.first();
- QVERIFY(focusArguments.count() == 1);
- QCOMPARE(focusArguments.at(0).toBool(), true);
-
- QCOMPARE(parentItem->hasActiveFocus(), false);
- QCOMPARE(parentItem->hasFocus(), false);
- QCOMPARE(wantsFocusSpy.count(),0);
-
- item->setX(10.0);
- QCOMPARE(item->x(), 10.0);
- QCOMPARE(xSpy.count(), 1);
-
- item->setY(10.0);
- QCOMPARE(item->y(), 10.0);
- QCOMPARE(ySpy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QQuickItem::childrenRect()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("childrenRect.qml"));
- canvas->setBaseSize(QSize(240,320));
- canvas->show();
-
- QQuickItem *o = canvas->rootObject();
- QQuickItem *item = o->findChild<QQuickItem*>("testItem");
- QCOMPARE(item->width(), qreal(0));
- QCOMPARE(item->height(), qreal(0));
-
- o->setProperty("childCount", 1);
- QCOMPARE(item->width(), qreal(10));
- QCOMPARE(item->height(), qreal(20));
-
- o->setProperty("childCount", 5);
- QCOMPARE(item->width(), qreal(50));
- QCOMPARE(item->height(), qreal(100));
-
- o->setProperty("childCount", 0);
- QCOMPARE(item->width(), qreal(0));
- QCOMPARE(item->height(), qreal(0));
-
- delete o;
- delete canvas;
-}
-
-// QTBUG-11383
-void tst_QQuickItem::childrenRectBug()
-{
- QQuickView *canvas = new QQuickView(0);
-
- QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- canvas->setSource(testFileUrl("childrenRectBug.qml"));
- canvas->show();
-
- QQuickItem *o = canvas->rootObject();
- QQuickItem *item = o->findChild<QQuickItem*>("theItem");
- QCOMPARE(item->width(), qreal(200));
- QCOMPARE(item->height(), qreal(100));
- QCOMPARE(item->x(), qreal(100));
-
- delete canvas;
-}
-
-// QTBUG-11465
-void tst_QQuickItem::childrenRectBug2()
-{
- QQuickView *canvas = new QQuickView(0);
-
- QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\"";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- canvas->setSource(testFileUrl("childrenRectBug2.qml"));
- canvas->show();
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(canvas->rootObject());
- QVERIFY(rect);
- QQuickItem *item = rect->findChild<QQuickItem*>("theItem");
- QCOMPARE(item->width(), qreal(100));
- QCOMPARE(item->height(), qreal(110));
- QCOMPARE(item->x(), qreal(130));
-
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- rectPrivate->setState("row");
- QCOMPARE(item->width(), qreal(210));
- QCOMPARE(item->height(), qreal(50));
- QCOMPARE(item->x(), qreal(75));
-
- delete canvas;
-}
-
-// QTBUG-12722
-void tst_QQuickItem::childrenRectBug3()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("childrenRectBug3.qml"));
- canvas->show();
-
- //don't crash on delete
- delete canvas;
-}
-
-// QTBUG-13893
-void tst_QQuickItem::transformCrash()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("transformCrash.qml"));
- canvas->show();
-
- delete canvas;
-}
-
-void tst_QQuickItem::implicitSize()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("implicitsize.qml"));
- canvas->show();
-
- QQuickItem *item = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(item);
- QCOMPARE(item->width(), qreal(80));
- QCOMPARE(item->height(), qreal(60));
-
- QCOMPARE(item->implicitWidth(), qreal(200));
- QCOMPARE(item->implicitHeight(), qreal(100));
-
- QMetaObject::invokeMethod(item, "resetSize");
-
- QCOMPARE(item->width(), qreal(200));
- QCOMPARE(item->height(), qreal(100));
-
- QMetaObject::invokeMethod(item, "changeImplicit");
-
- QCOMPARE(item->implicitWidth(), qreal(150));
- QCOMPARE(item->implicitHeight(), qreal(80));
- QCOMPARE(item->width(), qreal(150));
- QCOMPARE(item->height(), qreal(80));
-
- delete canvas;
-}
-
-void tst_QQuickItem::qtbug_16871()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_16871.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- delete o;
-}
-
-
-void tst_QQuickItem::visibleChildren()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("visiblechildren.qml"));
- canvas->show();
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
-
- QCOMPARE(root->property("test1_1").toBool(), true);
- QCOMPARE(root->property("test1_2").toBool(), true);
- QCOMPARE(root->property("test1_3").toBool(), true);
- QCOMPARE(root->property("test1_4").toBool(), true);
-
- QMetaObject::invokeMethod(root, "hideFirstAndLastRowChild");
- QCOMPARE(root->property("test2_1").toBool(), true);
- QCOMPARE(root->property("test2_2").toBool(), true);
- QCOMPARE(root->property("test2_3").toBool(), true);
- QCOMPARE(root->property("test2_4").toBool(), true);
-
- QMetaObject::invokeMethod(root, "showLastRowChildsLastChild");
- QCOMPARE(root->property("test3_1").toBool(), true);
- QCOMPARE(root->property("test3_2").toBool(), true);
- QCOMPARE(root->property("test3_3").toBool(), true);
- QCOMPARE(root->property("test3_4").toBool(), true);
-
- QMetaObject::invokeMethod(root, "showLastRowChild");
- QCOMPARE(root->property("test4_1").toBool(), true);
- QCOMPARE(root->property("test4_2").toBool(), true);
- QCOMPARE(root->property("test4_3").toBool(), true);
- QCOMPARE(root->property("test4_4").toBool(), true);
-
- QString warning1 = testFileUrl("visiblechildren.qml").toString() + ":96:32: QML Item: QQuickItem: visibleChildren property is readonly and cannot be assigned to.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QMetaObject::invokeMethod(root, "tryWriteToReadonlyVisibleChildren");
- QCOMPARE(root->property("test5_1").toBool(), true);
-
- QMetaObject::invokeMethod(root, "reparentVisibleItem3");
- QCOMPARE(root->property("test6_1").toBool(), true);
- QCOMPARE(root->property("test6_2").toBool(), true);
- QCOMPARE(root->property("test6_3").toBool(), true);
- QCOMPARE(root->property("test6_4").toBool(), true);
-
- QMetaObject::invokeMethod(root, "reparentImlicitlyInvisibleItem4_1");
- QCOMPARE(root->property("test7_1").toBool(), true);
- QCOMPARE(root->property("test7_2").toBool(), true);
- QCOMPARE(root->property("test7_3").toBool(), true);
- QCOMPARE(root->property("test7_4").toBool(), true);
-
- // FINALLY TEST THAT EVERYTHING IS AS EXPECTED
- QCOMPARE(root->property("test8_1").toBool(), true);
- QCOMPARE(root->property("test8_2").toBool(), true);
- QCOMPARE(root->property("test8_3").toBool(), true);
- QCOMPARE(root->property("test8_4").toBool(), true);
- QCOMPARE(root->property("test8_5").toBool(), true);
-
- delete canvas;
-}
-
-void tst_QQuickItem::parentLoop()
-{
- QQuickView *canvas = new QQuickView(0);
-
- QTest::ignoreMessage(QtWarningMsg, "QQuickItem::setParentItem: Parent is already part of this items subtree.");
- canvas->setSource(testFileUrl("parentLoop.qml"));
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
-
- QQuickItem *item1 = root->findChild<QQuickItem*>("item1");
- QVERIFY(item1);
- QCOMPARE(item1->parentItem(), root);
-
- QQuickItem *item2 = root->findChild<QQuickItem*>("item2");
- QVERIFY(item2);
- QCOMPARE(item2->parentItem(), item1);
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_QQuickItem)
-
-#include "tst_qquickitem.moc"
diff --git a/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro b/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro
deleted file mode 100644
index 557e23d150..0000000000
--- a/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro
+++ /dev/null
@@ -1,38 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickitemlayer
-SOURCES += tst_qquickitemlayer.cpp
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-include(../../shared/util.pri)
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private testlib
-
-OTHER_FILES += \
- data/Smooth.qml \
- data/Enabled.qml \
- data/Mipmap.qml \
- data/Effect.qml \
- data/SourceRect.qml \
- data/TextureProvider.qml \
- data/Visible.qml \
- data/ZOrder.qml \
- data/ZOrderChange.qml \
- data/ToggleLayerAndEffect.qml \
- data/DisableLayer.qml \
- data/SamplerNameChange.qml \
- data/ItemEffect.qml \
- data/RectangleEffect.qml
-
-
-
-
-
-
-
-
diff --git a/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp
deleted file mode 100644
index 2a856707ba..0000000000
--- a/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtGui/qopenglcontext.h>
-
-#include "../../shared/util.h"
-
-class tst_QQuickItemLayer: public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickItemLayer();
-
- QImage runTest(const QString &url)
- {
- QQuickView view;
- view.setSource(QUrl(url));
-
- view.show();
- QTest::qWaitForWindowShown(&view);
-
- return view.grabFrameBuffer();
- }
-
-private slots:
- void layerEnabled();
- void layerSmooth();
- void layerMipmap();
- void layerEffect();
-
- void layerVisibility_data();
- void layerVisibility();
-
- void layerSourceRect();
-
- void layerZOrder_data();
- void layerZOrder();
-
- void layerIsTextureProvider();
-
- void changeZOrder_data();
- void changeZOrder();
-
- void toggleLayerAndEffect();
- void disableLayer();
- void changeSamplerName();
- void itemEffect();
- void rectangleEffect();
-
-private:
- bool m_isMesaSoftwareRasterizer;
- int m_mesaVersion;
-};
-
-tst_QQuickItemLayer::tst_QQuickItemLayer()
- : m_mesaVersion(0)
-{
- QWindow window;
- QOpenGLContext context;
- window.setSurfaceType(QWindow::OpenGLSurface);
- window.create();
- context.create();
- context.makeCurrent(&window);
- const char *vendor = (const char *)glGetString(GL_VENDOR);
- const char *renderer = (const char *)glGetString(GL_RENDERER);
- m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0
- && strcmp(renderer, "Software Rasterizer") == 0;
- if (m_isMesaSoftwareRasterizer) {
- // Expects format: <OpenGL version> Mesa <Mesa version>[-devel] [...]
- const char *version = (const char *)glGetString(GL_VERSION);
- QList<QByteArray> list = QByteArray(version).split(' ');
- if (list.size() >= 3) {
- list = list.at(2).split('-').at(0).split('.');
- int major = 0;
- int minor = 0;
- int patch = 0;
- if (list.size() >= 1)
- major = list.at(0).toInt();
- if (list.size() >= 2)
- minor = list.at(1).toInt();
- if (list.size() >= 3)
- patch = list.at(2).toInt();
- m_mesaVersion = QT_VERSION_CHECK(major, minor, patch);
- }
- }
-}
-
-// The test draws a red and a blue box next to each other and tests that the
-// output is still red and blue on the left and right and a combination of
-// the two in the middle.
-
-void tst_QQuickItemLayer::layerSmooth()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("Smooth.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
-
- uint pixel = fb.pixel(fb.width() / 2, 0);
- QVERIFY(qRed(pixel) > 0);
- QVERIFY(qBlue(pixel) > 0);
-}
-
-
-
-// The test draws a gradient at a small size into a layer and scales the
-// layer. If the layer is enabled there should be very visible bands in
-// the gradient.
-
-void tst_QQuickItemLayer::layerEnabled()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("Enabled.qml"));
- // Verify the banding
- QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1));
- // Verify the gradient
- QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1));
-}
-
-
-
-// The test draws a one pixel wide line and scales it down by more than a a factor 2
-// If mipmpping works, the pixels should be gray, not white or black
-
-void tst_QQuickItemLayer::layerMipmap()
-{
- if (m_isMesaSoftwareRasterizer)
- QSKIP("Mipmapping does not work with the Mesa Software Rasterizer.");
- QImage fb = runTest(testFile("Mipmap.qml"));
- QVERIFY(fb.pixel(0, 0) != 0xff000000);
- QVERIFY(fb.pixel(0, 0) != 0xffffffff);
-}
-
-
-
-// The test implements an rgb swapping effect sourced from a blue rectangle. The
-// resulting pixel should be red
-
-void tst_QQuickItemLayer::layerEffect()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("Effect.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
-}
-
-
-
-// The test draws a rectangle and verifies that there is padding on each side
-// as the source rect spans outside the item. The padding is verified using
-// a shader that pads transparent to blue. Everything else is red.
-void tst_QQuickItemLayer::layerSourceRect()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-
- QImage fb = runTest(testFile("SourceRect.qml"));
-
- // Check that the edges are converted to blue
- QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(0, fb.height() - 1), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(fb.width() - 1, fb.height() - 1), qRgb(0, 0, 0xff));
-
- // The center pixel should be red
- QCOMPARE(fb.pixel(fb.width() / 2, fb.height() / 2), qRgb(0xff, 0, 0));
-}
-
-
-
-// Same as the effect test up above, but this time use the item
-// directly in a stand alone ShaderEffect
-void tst_QQuickItemLayer::layerIsTextureProvider()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("TextureProvider.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
-}
-
-
-void tst_QQuickItemLayer::layerVisibility_data()
-{
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("effect");
- QTest::addColumn<qreal>("opacity");
-
- QTest::newRow("!effect, !visible, a=1") << false << false << 1.;
- QTest::newRow("!effect, visible, a=1") << false << true << 1.;
- QTest::newRow("effect, !visible, a=1") << true << false << 1.;
- QTest::newRow("effect, visible, a=1") << true << true << 1.;
-
- QTest::newRow("!effect, !visible, a=.5") << false << false << .5;
- QTest::newRow("!effect, visible, a=.5") << false << true << .5;
- QTest::newRow("effect, !visible, a=.5") << true << false << .5;
- QTest::newRow("effect, visible, a=.5") << true << true << .5;
-
- QTest::newRow("!effect, !visible, a=0") << false << false << 0.;
- QTest::newRow("!effect, visible, a=0") << false << true << 0.;
- QTest::newRow("effect, !visible, a=0") << true << false << 0.;
- QTest::newRow("effect, visible, a=0") << true << true << 0.;
-}
-
-void tst_QQuickItemLayer::layerVisibility()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-
- QFETCH(bool, visible);
- QFETCH(bool, effect);
- QFETCH(qreal, opacity);
-
- QQuickView view;
- view.setSource(testFile("Visible.qml"));
-
- QQuickItem *child = view.rootItem()->childItems().at(0);
- child->setProperty("layerVisible", visible);
- child->setProperty("layerEffect", effect);
- child->setProperty("layerOpacity", opacity);
-
- view.show();
-
- QTest::qWaitForWindowShown(&view);
-
- QImage fb = view.grabFrameBuffer();
- uint pixel = fb.pixel(0, 0);
-
- if (!visible || opacity == 0) {
- QCOMPARE(pixel, qRgb(0xff, 0xff, 0xff));
- } else if (effect) {
- QCOMPARE(qRed(pixel), 0xff);
- QVERIFY(qGreen(pixel) < 0xff);
- QVERIFY(qBlue(pixel) < 0xff);
- } else { // no effect
- QCOMPARE(qBlue(pixel), 0xff);
- QVERIFY(qGreen(pixel) < 0xff);
- QVERIFY(qRed(pixel) < 0xff);
- }
-}
-
-
-
-
-void tst_QQuickItemLayer::layerZOrder_data()
-{
- QTest::addColumn<bool>("effect");
-
- QTest::newRow("!effect") << false;
- QTest::newRow("effect") << true;
-}
-
-void tst_QQuickItemLayer::layerZOrder()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-
- QFETCH(bool, effect);
-
- QQuickView view;
- view.setSource(testFile("ZOrder.qml"));
-
- QQuickItem *child = view.rootItem()->childItems().at(0);
- child->setProperty("layerEffect", effect);
-
- view.show();
-
- QTest::qWaitForWindowShown(&view);
-
- QImage fb = view.grabFrameBuffer();
-
- QCOMPARE(fb.pixel(50, 50), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(150, 150), qRgb(0, 0xff, 00));
-
-}
-
-void tst_QQuickItemLayer::changeZOrder_data()
-{
- QTest::addColumn<bool>("layered");
- QTest::addColumn<bool>("effect");
-
- QTest::newRow("layered, effect") << true << true;
- QTest::newRow("layered, !effect") << true << false;
- QTest::newRow("!layered") << false << false;
-}
-
-void tst_QQuickItemLayer::changeZOrder()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-
- QFETCH(bool, layered);
- QFETCH(bool, effect);
-
- QQuickView view;
- view.setSource(testFile("ZOrderChange.qml"));
-
- QQuickItem *child = view.rootItem()->childItems().at(0);
- child->setProperty("layerEnabled", layered);
- child->setProperty("layerEffect", effect);
- child->setProperty("layerZ", 1);
-
- view.show();
-
- QTest::qWaitForWindowShown(&view);
-
- QImage fb = view.grabFrameBuffer();
-
- QRgb topLeft = fb.pixel(50, 50);
- QRgb topRight = fb.pixel(150, 50);
- QRgb bottomLeft = fb.pixel(50, 150);
- QRgb bottomRight = fb.pixel(150, 150);
-
- QCOMPARE(bottomLeft, qRgb(0, 0, 0xff));
-
- if (layered) {
- QCOMPARE(topLeft, qRgb(0, 0xff, 0xff));
- } else {
- QCOMPARE(qGreen(topLeft), 0xff);
- QVERIFY(qAbs(qRed(topLeft) - 0x3f) < 4);
- QVERIFY(qAbs(qBlue(topLeft) - 0xbf) < 4);
- }
-
- if (layered && effect) {
- QCOMPARE(qRed(topRight), 0xff);
- QCOMPARE(qGreen(topRight), 0x00);
- QVERIFY(qAbs(qBlue(topRight) - 0x7f) < 4);
-
- QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4);
- QCOMPARE(qBlue(bottomRight), 0xff);
- QVERIFY(qAbs(qGreen(bottomRight) - 0x7f) < 4);
- } else {
- QCOMPARE(qRed(topRight), 0xff);
- QCOMPARE(qBlue(topRight), 0x00);
- QVERIFY(qAbs(qGreen(topRight) - 0x7f) < 4);
-
- QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4);
- QCOMPARE(qGreen(bottomRight), 0xff);
- QVERIFY(qAbs(qBlue(bottomRight) - 0x7f) < 4);
- }
-}
-
-void tst_QQuickItemLayer::toggleLayerAndEffect()
-{
- // This test passes if it doesn't crash.
- runTest(testFile("ToggleLayerAndEffect.qml"));
-}
-
-void tst_QQuickItemLayer::disableLayer()
-{
- // This test passes if it doesn't crash.
- runTest(testFile("DisableLayer.qml"));
-}
-
-void tst_QQuickItemLayer::changeSamplerName()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("SamplerNameChange.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
-}
-
-void tst_QQuickItemLayer::itemEffect()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("ItemEffect.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(199, 199), qRgb(0, 0, 0xff));
-}
-
-void tst_QQuickItemLayer::rectangleEffect()
-{
- QImage fb = runTest(testFile("RectangleEffect.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
- QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
- QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
- QCOMPARE(fb.pixel(199, 199), qRgb(0, 0xff, 0));
-
- QCOMPARE(fb.pixel(100, 0), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(199, 100), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(100, 199), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff));
-}
-
-
-QTEST_MAIN(tst_QQuickItemLayer)
-
-#include "tst_qquickitemlayer.moc"
diff --git a/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml
deleted file mode 100644
index ff90ead8a6..0000000000
--- a/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml
+++ /dev/null
@@ -1,134 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: list.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- height: 20
- width: 240
- Text { text: index }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionFrom)
- model_targetItems_transitionFrom.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
-
- ListView {
- id: list
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "list"
- focus: true
- anchors.centerIn: parent
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- add: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
- NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
- }
-
- ScriptAction { script: list.targetTransitionsDone += 1 }
- }
- }
-
- addDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
- NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: list.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: list
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- // XXX will it pass without these if I just wait for polish?
- // check all of these tests - if not, then mark this bit with the bug number!
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 100000 }
- }
-}
-
diff --git a/tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml
deleted file mode 100644
index 744db3110e..0000000000
--- a/tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml
+++ /dev/null
@@ -1,141 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: list.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- height: 20
- width: 240
- Text { text: index }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionVia)
- model_targetItems_transitionVia.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
-
- ListView {
- id: list
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "list"
- focus: true
- anchors.centerIn: parent
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- move: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; to: targetItems_transitionVia.x; duration: root.duration }
- NumberAnimation { properties: "y"; to: targetItems_transitionVia.y; duration: root.duration }
- }
-
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: list.targetTransitionsDone += 1 }
- }
- }
-
- moveDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation {
- properties: "x"; duration: root.duration
- to: displacedItems_transitionVia.x
- }
- NumberAnimation {
- properties: "y"; duration: root.duration
- to: displacedItems_transitionVia.y
- }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: list.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: list
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml
deleted file mode 100644
index 95f76f0200..0000000000
--- a/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml
+++ /dev/null
@@ -1,144 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: list.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- height: 20
- width: 240
- Text { text: index }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionTo) {
- model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item
- }
- if (Qt.point(x, y) == displacedItems_transitionVia) {
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
- }
-
- ListView {
- id: list
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "list"
- focus: true
- anchors.centerIn: parent
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- remove: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; to: targetItems_transitionTo.x; duration: root.duration }
- NumberAnimation { properties: "y"; to: targetItems_transitionTo.y; duration: root.duration }
- }
- ScriptAction { script: list.targetTransitionsDone += 1 }
-
- // delay deleting this item so that it stays valid for the tests
- // (this doesn't delay the test itself)
- PauseAnimation { duration: 10000 }
- }
- }
-
- removeDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation {
- properties: "x"; duration: root.duration
- to: displacedItems_transitionVia.x
- }
- NumberAnimation {
- properties: "y"; duration: root.duration
- to: displacedItems_transitionVia.y
- }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: list.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: list
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquicklistview/qquicklistview.pro b/tests/auto/qtquick2/qquicklistview/qquicklistview.pro
deleted file mode 100644
index 6828bf2f13..0000000000
--- a/tests/auto/qtquick2/qquicklistview/qquicklistview.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquicklistview
-macx:CONFIG -= app_bundle
-
-HEADERS += incrementalmodel.h
-SOURCES += tst_qquicklistview.cpp \
- incrementalmodel.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private declarative-private quick-private widgets widgets-private v8-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
deleted file mode 100644
index 8f1527fa36..0000000000
--- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
+++ /dev/null
@@ -1,5997 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtCore/QStringListModel>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquicklistview_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualitemmodel_p.h>
-#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-#include "incrementalmodel.h"
-#include <math.h>
-
-Q_DECLARE_METATYPE(Qt::LayoutDirection)
-Q_DECLARE_METATYPE(QQuickListView::Orientation)
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-class tst_QQuickListView : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickListView();
-
-private slots:
- // Test both QListModelInterface and QAbstractItemModel model types
- void qListModelInterface_items();
- void qListModelInterface_package_items();
- void qAbstractItemModel_items();
-
- void qListModelInterface_changed();
- void qListModelInterface_package_changed();
- void qAbstractItemModel_changed();
-
- void qListModelInterface_inserted();
- void qListModelInterface_inserted_more();
- void qListModelInterface_inserted_more_data();
- void qListModelInterface_package_inserted();
- void qAbstractItemModel_inserted();
- void qAbstractItemModel_inserted_more();
- void qAbstractItemModel_inserted_more_data();
-
- void qListModelInterface_removed();
- void qListModelInterface_removed_more();
- void qListModelInterface_removed_more_data();
- void qListModelInterface_package_removed();
- void qAbstractItemModel_removed();
- void qAbstractItemModel_removed_more();
- void qAbstractItemModel_removed_more_data();
-
- void qListModelInterface_moved();
- void qListModelInterface_moved_data();
- void qListModelInterface_package_moved();
- void qListModelInterface_package_moved_data();
- void qAbstractItemModel_moved();
- void qAbstractItemModel_moved_data();
-
- void multipleChanges();
- void multipleChanges_data();
-
- void qListModelInterface_clear();
- void qListModelInterface_package_clear();
- void qAbstractItemModel_clear();
-
- void insertBeforeVisible();
- void insertBeforeVisible_data();
- void swapWithFirstItem();
- void itemList();
- void currentIndex_delayedItemCreation();
- void currentIndex_delayedItemCreation_data();
- void currentIndex();
- void noCurrentIndex();
- void enforceRange();
- void enforceRange_withoutHighlight();
- void spacing();
- void qListModelInterface_sections();
- void qListModelInterface_package_sections();
- void qAbstractItemModel_sections();
- void sectionsPositioning();
- void sectionsDelegate();
- void sectionPropertyChange();
- void cacheBuffer();
- void positionViewAtIndex();
- void resetModel();
- void propertyChanges();
- void componentChanges();
- void modelChanges();
- void manualHighlight();
- void header();
- void header_data();
- void header_delayItemCreation();
- void footer();
- void footer_data();
- void headerFooter();
- void resizeView();
- void resizeViewAndRepaint();
- void sizeLessThan1();
- void QTBUG_14821();
- void resizeDelegate();
- void resizeFirstDelegate();
- void QTBUG_16037();
- void indexAt_itemAt_data();
- void indexAt_itemAt();
- void incrementalModel();
- void onAdd();
- void onAdd_data();
- void onRemove();
- void onRemove_data();
- void rightToLeft();
- void test_mirroring();
- void margins();
- void marginsResize();
- void marginsResize_data();
- void creationContext();
- void snapToItem_data();
- void snapToItem();
- void snapOneItem_data();
- void snapOneItem();
-
- void QTBUG_9791();
- void QTBUG_11105();
- void QTBUG_21742();
-
- void asynchronous();
- void unrequestedVisibility();
-
- void populateTransitions();
- void populateTransitions_data();
- void addTransitions();
- void addTransitions_data();
- void moveTransitions();
- void moveTransitions_data();
- void removeTransitions();
- void removeTransitions_data();
- void displacedTransitions();
- void displacedTransitions_data();
- void multipleTransitions();
- void multipleTransitions_data();
-
-private:
- template <class T> void items(const QUrl &source, bool forceLayout);
- template <class T> void changed(const QUrl &source, bool forceLayout);
- template <class T> void inserted(const QUrl &source);
- template <class T> void inserted_more();
- template <class T> void removed(const QUrl &source, bool animated);
- template <class T> void removed_more(const QUrl &source);
- template <class T> void moved(const QUrl &source);
- template <class T> void clear(const QUrl &source);
- template <class T> void sections(const QUrl &source);
-
- QList<int> toIntList(const QVariantList &list);
- void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
- void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
- void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
-
- void inserted_more_data();
- void removed_more_data();
- void moved_data();
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError)
- Q_PROPERTY(bool animate READ animate NOTIFY changedAnim)
- Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer)
-
-public:
- TestObject(QObject *parent = 0)
- : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false)
- , mCacheBuffer(0) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; emit changedError(); }
-
- bool animate() const { return mAnimate; }
- void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); }
-
- bool invalidHighlight() const { return mInvalidHighlight; }
- void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); }
-
- int cacheBuffer() const { return mCacheBuffer; }
- void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); }
-
-signals:
- void changedError();
- void changedAnim();
- void changedHl();
- void changedCacheBuffer();
-
-public:
- bool mError;
- bool mAnimate;
- bool mInvalidHighlight;
- int mCacheBuffer;
-};
-
-tst_QQuickListView::tst_QQuickListView()
-{
-}
-
-template <class T>
-void tst_QQuickListView::items(const QUrl &source, bool forceLayout)
-{
- QQuickView *canvas = createView();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
-
- QTRY_VERIFY(listview->highlightItem() != 0);
- QTRY_COMPARE(listview->count(), model.count());
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- // current item should be first item
- QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
-
- for (int i = 0; i < model.count(); ++i) {
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // switch to other delegate
- testObject->setAnimate(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
-
- // set invalid highlight
- testObject->setInvalidHighlight(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
- QTRY_VERIFY(listview->highlightItem() == 0);
-
- // back to normal highlight
- testObject->setInvalidHighlight(false);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
- QTRY_VERIFY(listview->highlightItem() != 0);
-
- // set an empty model and confirm that items are destroyed
- T model2;
- ctxt->setContextProperty("testModel", &model2);
-
- // Force a layout, necessary if ListView is completed before VisualDataModel.
- if (forceLayout)
- QCOMPARE(listview->property("count").toInt(), 0);
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(itemCount == 0);
-
- QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
- QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0);
-
- delete canvas;
- delete testObject;
-}
-
-
-template <class T>
-void tst_QQuickListView::changed(const QUrl &source, bool forceLayout)
-{
- QQuickView *canvas = createView();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- qApp->processEvents();
-
- QQuickFlickable *listview = findItem<QQuickFlickable>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Force a layout, necessary if ListView is completed before VisualDataModel.
- if (forceLayout)
- QCOMPARE(listview->property("count").toInt(), model.count());
-
- model.modifyItem(1, "Will", "9876");
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QQuickListView::inserted(const QUrl &source)
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.insertItem(1, "Will", "9876");
-
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- QTRY_COMPARE(listview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
-
- listview->setContentY(80);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
-
- QTRY_VERIFY(listview->contentY() == 80);
-
- // Confirm items positioned correctly
- for (int i = 5; i < 5+15; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.0 - 20.0);
- }
-
-// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
-
- // QTBUG-19675
- model.clear();
- model.insertItem(0, "Hello", "1234");
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->y(), 0.);
- QTRY_VERIFY(listview->contentY() == 0);
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QQuickListView::inserted_more()
-{
- QFETCH(qreal, contentY);
- QFETCH(int, insertIndex);
- QFETCH(int, insertCount);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QList<QPair<QString, QString> > newData;
- for (int i=0; i<insertCount; i++)
- newData << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.insertItems(insertIndex, newData);
- QTRY_COMPARE(listview->property("count").toInt(), model.count());
-
- // check visibleItems.first() is in correct position
- QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item0);
- QCOMPARE(item0->y(), itemsOffsetAfterMove);
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QQuickText *name;
- QQuickText *number;
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::inserted_more_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("insertIndex");
- QTest::addColumn<int>("insertCount");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- QTest::newRow("add 1, before visible items")
- << 80.0 // show 4-19
- << 3 << 1
- << -20.0; // insert above first visible i.e. 0 is at -20, first visible should not move
-
- QTest::newRow("add multiple, before visible")
- << 80.0 // show 4-19
- << 3 << 3
- << -20.0 * 3; // again first visible should not move
-
- QTest::newRow("add 1, at start of visible, content at start")
- << 0.0
- << 0 << 1
- << 0.0;
-
- QTest::newRow("add multiple, start of visible, content at start")
- << 0.0
- << 0 << 3
- << 0.0;
-
- QTest::newRow("add 1, at start of visible, content not at start")
- << 80.0 // show 4-19
- << 4 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at start of visible, content not at start")
- << 80.0 // show 4-19
- << 4 << 3
- << 0.0;
-
-
- QTest::newRow("add 1, at end of visible, content at start")
- << 0.0
- << 15 << 1
- << 0.0;
-
- QTest::newRow("add 1, at end of visible, content at start")
- << 0.0
- << 15 << 3
- << 0.0;
-
- QTest::newRow("add 1, at end of visible, content not at start")
- << 80.0 // show 4-19
- << 19 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at end of visible, content not at start")
- << 80.0 // show 4-19
- << 19 << 3
- << 0.0;
-
-
- QTest::newRow("add 1, after visible, content at start")
- << 0.0
- << 16 << 1
- << 0.0;
-
- QTest::newRow("add 1, after visible, content at start")
- << 0.0
- << 16 << 3
- << 0.0;
-
- QTest::newRow("add 1, after visible, content not at start")
- << 80.0 // show 4-19
- << 20 << 1
- << 0.0;
-
- QTest::newRow("add multiple, after visible, content not at start")
- << 80.0 // show 4-19
- << 20 << 3
- << 0.0;
-}
-
-void tst_QQuickListView::insertBeforeVisible()
-{
- QFETCH(int, insertIndex);
- QFETCH(int, insertCount);
- QFETCH(int, cacheBuffer);
-
- QQuickText *name;
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- listview->setCacheBuffer(cacheBuffer);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // trigger a refill (not just setting contentY) so that the visibleItems grid is updated
- int firstVisibleIndex = 20; // move to an index where the top item is not visible
- listview->setContentY(firstVisibleIndex * 20.0);
- listview->setCurrentIndex(firstVisibleIndex);
-
- qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex);
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
- QVERIFY(item);
- QCOMPARE(item->y(), listview->contentY());
-
- QList<QPair<QString, QString> > newData;
- for (int i=0; i<insertCount; i++)
- newData << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.insertItems(insertIndex, newData);
- QTRY_COMPARE(listview->property("count").toInt(), model.count());
-
- // now, moving to the top of the view should position the inserted items correctly
- int itemsOffsetAfterMove = -(insertCount * 20);
- listview->setCurrentIndex(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::insertBeforeVisible_data()
-{
- QTest::addColumn<int>("insertIndex");
- QTest::addColumn<int>("insertCount");
- QTest::addColumn<int>("cacheBuffer");
-
- QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0;
- QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100;
- QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500;
-
- QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0;
- QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100;
- QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500;
-
- QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 3 << 0;
- QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 3 << 100;
- QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 3 << 500;
-
- QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 3 << 0;
- QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 3 << 100;
- QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 3 << 500;
-}
-
-template <class T>
-void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
-{
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- canvas->show();
- qApp->processEvents();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- model.removeItem(1);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),i*20.0);
- }
-
- // Remove items not visible
- model.removeItem(18);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),i*20.0);
- }
-
- // Remove items before visible
- listview->setContentY(80);
- listview->setCurrentIndex(10);
-
- model.removeItem(1); // post: top item will be at 20
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- // Confirm items positioned correctly
- for (int i = 2; i < 18; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),20+i*20.0);
- }
-
- // Remove current index
- QTRY_VERIFY(listview->currentIndex() == 9);
- QQuickItem *oldCurrent = listview->currentItem();
- model.removeItem(9);
-
- QTRY_COMPARE(listview->currentIndex(), 9);
- QTRY_VERIFY(listview->currentItem() != oldCurrent);
-
- listview->setContentY(20); // That's the top now
- // let transitions settle.
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),20+i*20.0);
- }
-
- // remove current item beyond visible items.
- listview->setCurrentIndex(20);
- listview->setContentY(40);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- model.removeItem(20);
- QTRY_COMPARE(listview->currentIndex(), 20);
- QTRY_VERIFY(listview->currentItem() != 0);
-
- // remove item before current, but visible
- listview->setCurrentIndex(8);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- oldCurrent = listview->currentItem();
- model.removeItem(6);
-
- QTRY_COMPARE(listview->currentIndex(), 7);
- QTRY_VERIFY(listview->currentItem() == oldCurrent);
-
- listview->setContentY(80);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTest::qWait(300);
-
- // remove all visible items
- model.removeItems(1, 18);
- QTRY_COMPARE(listview->count() , model.count());
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i+1);
- if (!item) qWarning() << "Item" << i+1 << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),80+i*20.0);
- }
-
- model.removeItems(1, 17);
- QTRY_COMPARE(listview->count() , model.count());
-
- model.removeItems(2, 1);
- QTRY_COMPARE(listview->count() , model.count());
-
- model.addItem("New", "1");
- QTRY_COMPARE(listview->count() , model.count());
-
- QTRY_VERIFY(name = findItem<QQuickText>(contentItem, "textName", model.count()-1));
- QCOMPARE(name->text(), QString("New"));
-
- // Add some more items so that we don't run out
- model.clear();
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- // QTBUG-QTBUG-20575
- listview->setCurrentIndex(0);
- listview->setContentY(30);
- model.removeItem(0);
- QTRY_VERIFY(name = findItem<QQuickText>(contentItem, "textName", 0));
-
- // QTBUG-19198 move to end and remove all visible items one at a time.
- listview->positionViewAtEnd();
- for (int i = 0; i < 18; ++i)
- model.removeItems(model.count() - 1, 1);
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() > 16);
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QQuickListView::removed_more(const QUrl &source)
-{
- QFETCH(qreal, contentY);
- QFETCH(int, removeIndex);
- QFETCH(int, removeCount);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- QQuickText *name;
- QQuickText *number;
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- canvas->show();
- qApp->processEvents();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // wait for refill (after refill, items above the firstVisibleIndex-1 should not be rendered)
- int firstVisibleIndex = contentY / 20;
- if (firstVisibleIndex - 2 >= 0)
- QTRY_VERIFY(!findItem<QQuickText>(contentItem, "textName", firstVisibleIndex - 2));
-
- model.removeItems(removeIndex, removeCount);
- QTRY_COMPARE(listview->property("count").toInt(), model.count());
-
- // check visibleItems.first() is in correct position
- QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item0);
- QCOMPARE(item0->y(), itemsOffsetAfterMove);
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::removed_more_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("removeIndex");
- QTest::addColumn<int>("removeCount");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- QTest::newRow("remove 1, before visible items")
- << 80.0 // show 4-19
- << 3 << 1
- << 20.0; // visible items slide down by 1 item so that first visible does not move
-
- QTest::newRow("remove multiple, all before visible items")
- << 80.0
- << 1 << 3
- << 20.0 * 3;
-
- QTest::newRow("remove multiple, all before visible items, remove item 0")
- << 80.0
- << 0 << 4
- << 20.0 * 4;
-
- // remove 1,2,3 before the visible pos, 0 moves down to just before the visible pos,
- // items 4,5 are removed from view, item 6 slides up to original pos of item 4 (80px)
- QTest::newRow("remove multiple, mix of items from before and within visible items")
- << 80.0
- << 1 << 5
- << 20.0 * 3; // adjust for the 3 items removed before the visible
-
- QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0")
- << 80.0
- << 0 << 6
- << 20.0 * 4; // adjust for the 3 items removed before the visible
-
-
- QTest::newRow("remove 1, from start of visible, content at start")
- << 0.0
- << 0 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, from start of visible, content at start")
- << 0.0
- << 0 << 3
- << 0.0;
-
- QTest::newRow("remove 1, from start of visible, content not at start")
- << 80.0 // show 4-19
- << 4 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, from start of visible, content not at start")
- << 80.0 // show 4-19
- << 4 << 3
- << 0.0;
-
-
- QTest::newRow("remove 1, from middle of visible, content at start")
- << 0.0
- << 10 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, from middle of visible, content at start")
- << 0.0
- << 10 << 5
- << 0.0;
-
- QTest::newRow("remove 1, from middle of visible, content not at start")
- << 80.0 // show 4-19
- << 10 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, from middle of visible, content not at start")
- << 80.0 // show 4-19
- << 10 << 5
- << 0.0;
-
-
- QTest::newRow("remove 1, after visible, content at start")
- << 0.0
- << 16 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, after visible, content at start")
- << 0.0
- << 16 << 5
- << 0.0;
-
- QTest::newRow("remove 1, after visible, content not at middle")
- << 80.0 // show 4-19
- << 16+4 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, after visible, content not at start")
- << 80.0 // show 4-19
- << 16+4 << 5
- << 0.0;
-
- QTest::newRow("remove multiple, mix of items from within and after visible items")
- << 80.0
- << 18 << 5
- << 0.0;
-}
-
-template <class T>
-void tst_QQuickListView::clear(const QUrl &source)
-{
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- model.clear();
-
- QTRY_VERIFY(listview->count() == 0);
- QTRY_VERIFY(listview->currentItem() == 0);
- QTRY_VERIFY(listview->contentY() == 0);
- QVERIFY(listview->currentIndex() == -1);
-
- // confirm sanity when adding an item to cleared list
- model.addItem("New", "1");
- QTRY_VERIFY(listview->count() == 1);
- QVERIFY(listview->currentItem() != 0);
- QVERIFY(listview->currentIndex() == 0);
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QQuickListView::moved(const QUrl &source)
-{
- QFETCH(qreal, contentY);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- QQuickText *name;
- QQuickText *number;
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- canvas->show();
- qApp->processEvents();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *currentItem = listview->currentItem();
- QTRY_VERIFY(currentItem != 0);
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- model.moveItems(from, to, count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- if (i >= firstVisibleIndex + 16) // index has moved out of view
- continue;
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
-
- // current index should have been updated
- if (item == currentItem)
- QTRY_COMPARE(listview->currentIndex(), i);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::moved_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- // model starts with 30 items, each 20px high, in area 320px high
- // 16 items should be visible at a time
- // itemsOffsetAfterMove should be > 0 whenever items above the visible pos have moved
-
- QTest::newRow("move 1 forwards, within visible items")
- << 0.0
- << 1 << 4 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from non-visible -> visible")
- << 80.0 // show 4-19
- << 1 << 18 << 1
- << 20.0; // removed 1 item above the first visible, so item 0 should drop down by 1 to minimize movement
-
- QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)")
- << 80.0 // show 4-19
- << 0 << 4 << 1
- << 20.0; // first item has moved to below item4, everything drops down by size of 1 item
-
- QTest::newRow("move 1 forwards, from visible -> non-visible")
- << 0.0
- << 1 << 16 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)")
- << 0.0
- << 0 << 16 << 1
- << 0.0;
-
-
- QTest::newRow("move 1 backwards, within visible items")
- << 0.0
- << 4 << 1 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, within visible items (to first index)")
- << 0.0
- << 4 << 0 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from non-visible -> visible")
- << 0.0
- << 20 << 4 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)")
- << 0.0
- << 29 << 15 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from visible -> non-visible")
- << 80.0 // show 4-19
- << 16 << 1 << 1
- << -20.0; // to minimize movement, item 0 moves to -20, and other items do not move
-
- QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)")
- << 80.0 // show 4-19
- << 16 << 0 << 1
- << -20.0; // to minimize movement, item 16 (now at 0) moves to -20, and other items do not move
-
-
- QTest::newRow("move multiple forwards, within visible items")
- << 0.0
- << 0 << 5 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, before visible items")
- << 140.0 // show 7-22
- << 4 << 5 << 3 // 4,5,6 move to below 7
- << 20.0 * 3; // 4,5,6 moved down
-
- QTest::newRow("move multiple forwards, from non-visible -> visible")
- << 80.0 // show 4-19
- << 1 << 5 << 3
- << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
-
- QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)")
- << 80.0 // show 4-19
- << 0 << 5 << 3
- << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
-
- QTest::newRow("move multiple forwards, mix of non-visible/visible")
- << 40.0
- << 1 << 16 << 2
- << 20.0; // item 1,2 are removed, item 3 is now first visible
-
- QTest::newRow("move multiple forwards, to bottom of view")
- << 0.0
- << 5 << 13 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, to bottom of view, first->last")
- << 0.0
- << 0 << 13 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
- << 80.0
- << 5+4 << 13+4 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, from visible -> non-visible")
- << 0.0
- << 1 << 16 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)")
- << 0.0
- << 0 << 16 << 3
- << 0.0;
-
-
- QTest::newRow("move multiple backwards, within visible items")
- << 0.0
- << 4 << 1 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, within visible items (move first item)")
- << 0.0
- << 10 << 0 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from non-visible -> visible")
- << 0.0
- << 20 << 4 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)")
- << 0.0
- << 27 << 10 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from visible -> non-visible")
- << 80.0 // show 4-19
- << 16 << 1 << 3
- << -20.0 * 3; // to minimize movement, 0 moves by -60, and other items do not move
-
- QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)")
- << 80.0 // show 4-19
- << 16 << 0 << 3
- << -20.0 * 3; // to minimize movement, 16,17,18 move to above item 0, and other items do not move
-}
-
-void tst_QQuickListView::multipleChanges()
-{
- QFETCH(int, startCount);
- QFETCH(QList<ListChange>, changes);
- QFETCH(int, newCount);
- QFETCH(int, newCurrentIndex);
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < startCount; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i=0; i<changes.count(); i++) {
- switch (changes[i].type) {
- case ListChange::Inserted:
- {
- QList<QPair<QString, QString> > items;
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- items << qMakePair(QString("new item %1").arg(j), QString::number(j));
- model.insertItems(changes[i].index, items);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- }
- case ListChange::Removed:
- model.removeItems(changes[i].index, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- case ListChange::Moved:
- model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- case ListChange::SetCurrent:
- listview->setCurrentIndex(changes[i].index);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- case ListChange::SetContentY:
- listview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- }
- }
-
- QTRY_COMPARE(listview->count(), newCount);
- QCOMPARE(listview->count(), model.count());
- QTRY_COMPARE(listview->currentIndex(), newCurrentIndex);
-
- QQuickText *name;
- QQuickText *number;
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickListView::multipleChanges_data()
-{
- QTest::addColumn<int>("startCount");
- QTest::addColumn<QList<ListChange> >("changes");
- QTest::addColumn<int>("newCount");
- QTest::addColumn<int>("newCurrentIndex");
-
- QList<ListChange> changes;
-
- for (int i=1; i<30; i++)
- changes << ListChange::remove(0);
- QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0;
-
- changes << ListChange::remove(0);
- QTest::newRow("remove all") << 30 << changes << 0 << -1;
-
- changes.clear();
- changes << ListChange::setCurrent(29);
- for (int i=29; i>0; i--)
- changes << ListChange::remove(i);
- QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0;
-
- QTest::newRow("remove then insert at 0") << 10 << (QList<ListChange>()
- << ListChange::remove(0, 1)
- << ListChange::insert(0, 1)
- ) << 10 << 1;
-
- QTest::newRow("remove then insert at non-zero index") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::remove(2, 1)
- << ListChange::insert(2, 1)
- ) << 10 << 3;
-
- QTest::newRow("remove current then insert below it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::remove(1, 3)
- << ListChange::insert(2, 2)
- ) << 9 << 1;
-
- QTest::newRow("remove current index then move it down") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::remove(1, 3)
- << ListChange::move(1, 5, 1)
- ) << 7 << 5;
-
- QTest::newRow("remove current index then move it up") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::remove(4, 3)
- << ListChange::move(4, 1, 1)
- ) << 7 << 1;
-
-
- QTest::newRow("insert multiple times") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 2)
- << ListChange::insert(0, 4)
- << ListChange::insert(0, 6)
- ) << 12 << 10;
-
- QTest::newRow("insert multiple times with current index changes") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 2)
- << ListChange::insert(0, 4)
- << ListChange::insert(0, 6)
- << ListChange::setCurrent(3)
- << ListChange::insert(3, 2)
- ) << 14 << 5;
-
- QTest::newRow("insert and remove all") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 30)
- << ListChange::remove(0, 30)
- ) << 0 << -1;
-
- QTest::newRow("insert and remove current") << 30 << (QList<ListChange>()
- << ListChange::insert(1)
- << ListChange::setCurrent(1)
- << ListChange::remove(1)
- ) << 30 << 1;
-
- QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 10)
- << ListChange::remove(5, 10)
- ) << 10 << 5;
-
- QTest::newRow("insert multiple, then move new items to end") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 3)
- << ListChange::move(0, 10, 3)
- ) << 13 << 0;
-
- QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 3)
- << ListChange::move(0, 8, 5)
- ) << 13 << 11;
-
- QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(9)
- << ListChange::insert(10, 3)
- << ListChange::move(8, 0, 5)
- ) << 13 << 1;
-
-
- QTest::newRow("move back and forth to same index") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::move(1, 2, 2)
- << ListChange::move(2, 1, 2)
- ) << 10 << 1;
-
- QTest::newRow("move forwards then back") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::move(1, 2, 3)
- << ListChange::move(3, 0, 5)
- ) << 10 << 0;
-
- QTest::newRow("move current, then remove it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 0, 1)
- << ListChange::remove(0)
- ) << 9 << 0;
-
- QTest::newRow("move current, then insert before it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 0, 1)
- << ListChange::insert(0)
- ) << 11 << 1;
-
- QTest::newRow("move multiple, then remove them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::move(5, 1, 3)
- << ListChange::remove(1, 3)
- ) << 7 << 1;
-
- QTest::newRow("move multiple, then insert before them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 1, 3)
- << ListChange::insert(1, 5)
- ) << 15 << 6;
-
- QTest::newRow("move multiple, then insert after them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(3)
- << ListChange::move(0, 1, 2)
- << ListChange::insert(3, 5)
- ) << 15 << 8;
-
-
- QTest::newRow("clear current") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 5)
- << ListChange::setCurrent(-1)
- << ListChange::remove(0, 5)
- << ListChange::insert(0, 5)
- ) << 5 << -1;
-}
-
-void tst_QQuickListView::swapWithFirstItem()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // ensure content position is stable
- listview->setContentY(0);
- model.moveItem(1, 0);
- QTRY_VERIFY(listview->contentY() == 0);
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickListView::enforceRange()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("listview-enforcerange.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0);
- QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
- QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QTRY_VERIFY(item);
- QTRY_COMPARE(listview->contentY(), -100.0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- listview->setContentY(20);
-
- QTRY_COMPARE(listview->currentIndex(), 6);
-
- // change model
- QmlListModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(listview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QQuickListView::enforceRange_withoutHighlight()
-{
- // QTBUG-20287
- // If no highlight is set but StrictlyEnforceRange is used, the content should still move
- // to the correct position (i.e. to the next/previous item, not next/previous section)
- // when moving up/down via incrementCurrentIndex() and decrementCurrentIndex()
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- model.addItem("Item 0", "a");
- model.addItem("Item 1", "b");
- model.addItem("Item 2", "b");
- model.addItem("Item 3", "c");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("listview-enforcerange-nohighlight.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- qreal expectedPos = -100.0;
-
- expectedPos += 10.0; // scroll past 1st section's delegate (10px height)
- QTRY_COMPARE(listview->contentY(), expectedPos);
-
- expectedPos += 20 + 10; // scroll past 1st section and section delegate of 2nd section
- QTest::keyClick(canvas, Qt::Key_Down);
-
- QTRY_COMPARE(listview->contentY(), expectedPos);
-
- expectedPos += 20; // scroll past 1st item of 2nd section
- QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->contentY(), expectedPos);
-
- expectedPos += 20 + 10; // scroll past 2nd item of 2nd section and section delegate of 3rd section
- QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->contentY(), expectedPos);
-
- delete canvas;
-}
-
-void tst_QQuickListView::spacing()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- listview->setSpacing(10);
- QTRY_VERIFY(listview->spacing() == 10);
-
- // Confirm items positioned correctly
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() == 11);
- for (int i = 0; i < 11; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*30);
- }
-
- listview->setSpacing(0);
-
- // Confirm items positioned correctly
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() >= 16);
- for (int i = 0; i < 16; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- delete canvas;
- delete testObject;
-}
-
-template <typename T>
-void tst_QQuickListView::sections(const QUrl &source)
-{
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(source);
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
- QQuickText *next = findItem<QQuickText>(item, "nextSection");
- QCOMPARE(next->text().toInt(), (i+1)/5);
- }
-
- QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged()));
-
- // Remove section boundary
- model.removeItem(5);
- QTRY_COMPARE(listview->count(), model.count());
-
- // New section header created
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 5);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- model.insertItem(3, "New Item", "0");
- QTRY_COMPARE(listview->count(), model.count());
-
- // Section header moved
- item = findItem<QQuickItem>(contentItem, "wrapper", 5);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 6);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- // insert item which will become a section header
- model.insertItem(6, "Replace header", "1");
- QTRY_COMPARE(listview->count(), model.count());
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 6);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 7);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- QTRY_COMPARE(listview->currentSection(), QString("0"));
-
- listview->setContentY(140);
- QTRY_COMPARE(listview->currentSection(), QString("1"));
-
- QTRY_COMPARE(currentSectionChangedSpy.count(), 1);
-
- listview->setContentY(20);
- QTRY_COMPARE(listview->currentSection(), QString("0"));
-
- QTRY_COMPARE(currentSectionChangedSpy.count(), 2);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 1);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- // check that headers change when item changes
- listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- model.modifyItem(0, "changed", "2");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 1);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::sectionsDelegate()
-{
- QSKIP("QTBUG-24395");
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20));
- QQuickText *next = findItem<QQuickText>(item, "nextSection");
- QCOMPARE(next->text().toInt(), (i+1)/5);
- }
-
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- // ensure section header is maintained in view
- listview->setCurrentIndex(20);
- QTRY_VERIFY(listview->contentY() >= 200.0);
- listview->setCurrentIndex(0);
- QTRY_COMPARE(listview->contentY(), 0.0);
-
- // change section
- model.modifyItem(0, "One", "aaa");
- model.modifyItem(1, "Two", "aaa");
- model.modifyItem(2, "Three", "aaa");
- model.modifyItem(3, "Four", "aaa");
- model.modifyItem(4, "Five", "aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- // remove section boundary
- model.removeItem(5);
- QTRY_COMPARE(listview->count(), model.count());
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- }
-
- // QTBUG-17606
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "sect_1");
- QCOMPARE(items.count(), 1);
-
- // QTBUG-17759
- model.modifyItem(0, "One", "aaa");
- model.modifyItem(1, "One", "aaa");
- model.modifyItem(2, "One", "aaa");
- model.modifyItem(3, "Four", "aaa");
- model.modifyItem(4, "Four", "aaa");
- model.modifyItem(5, "Four", "aaa");
- model.modifyItem(6, "Five", "aaa");
- model.modifyItem(7, "Five", "aaa");
- model.modifyItem(8, "Five", "aaa");
- model.modifyItem(9, "Two", "aaa");
- model.modifyItem(10, "Two", "aaa");
- model.modifyItem(11, "Two", "aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").count(), 1);
- canvas->rootObject()->setProperty("sectionProperty", "name");
- // ensure view has settled.
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_Four").count(), 1);
- for (int i = 0; i < 4; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + model.name(i*3));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*4));
- }
-
- // QTBUG-17769
- model.removeItems(10, 20);
- // ensure view has settled.
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 10);
- // Drag view up beyond bounds
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20,20));
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(20,0), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(20,-50), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(20,-200), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,-200));
- // view should settle back at 0
- QTRY_COMPARE(listview->contentY(), 0.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::sectionsPositioning()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
- canvas->show();
- qApp->processEvents();
- canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd)));
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- QQuickItem *topItem = findVisibleChild(contentItem, "sect_0"); // section header
- QVERIFY(topItem);
- QCOMPARE(topItem->y(), 0.);
-
- QQuickItem *bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
- QVERIFY(bottomItem);
- QCOMPARE(bottomItem->y(), 300.);
-
- // move down a little and check that section header is at top
- listview->setContentY(10);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QCOMPARE(topItem->y(), 0.);
-
- // push the top header up
- listview->setContentY(110);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- topItem = findVisibleChild(contentItem, "sect_0"); // section header
- QVERIFY(topItem);
- QCOMPARE(topItem->y(), 100.);
-
- QQuickItem *item = findVisibleChild(contentItem, "sect_1");
- QVERIFY(item);
- QCOMPARE(item->y(), 120.);
-
- bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
- QVERIFY(bottomItem);
- QCOMPARE(bottomItem->y(), 410.);
-
- // Move past section 0
- listview->setContentY(120);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- topItem = findVisibleChild(contentItem, "sect_0"); // section header
- QVERIFY(!topItem);
-
- // Push section footer down
- listview->setContentY(70);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
- QVERIFY(bottomItem);
- QCOMPARE(bottomItem->y(), 380.);
-
- // Change current section
- listview->setContentY(10);
- model.modifyItem(0, "One", "aaa");
- model.modifyItem(1, "Two", "aaa");
- model.modifyItem(2, "Three", "aaa");
- model.modifyItem(3, "Four", "aaa");
- model.modifyItem(4, "Five", "aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QTRY_COMPARE(listview->currentSection(), QString("aaa"));
-
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header
- QCOMPARE(topItem->y(), 10.);
-
- // remove section boundary
- listview->setContentY(120);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- model.removeItem(5);
- QTRY_COMPARE(listview->count(), model.count());
- for (int i = 1; i < 3; ++i) {
- QQuickItem *item = findVisibleChild(contentItem,
- "sect_" + QString::number(i));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- QVERIFY(topItem = findVisibleChild(contentItem, "sect_1"));
- QTRY_COMPARE(topItem->y(), 120.);
-
- // Change the next section
- listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
- QVERIFY(bottomItem);
- QTRY_COMPARE(bottomItem->y(), 300.);
-
- model.modifyItem(14, "New", "new");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer
- QTRY_COMPARE(bottomItem->y(), 300.);
-
- // Turn sticky footer off
- listview->setContentY(20);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart)));
- QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored
- QCOMPARE(item->y(), 340.);
-
- // Turn sticky header off
- listview->setContentY(30);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels)));
- QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored
- QCOMPARE(item->y(), 0.);
-
- delete canvas;
-}
-
-void tst_QQuickListView::sectionPropertyChange()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("sectionpropertychange.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- for (int i = 0; i < 2; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(25. + i*75.));
- }
-
- QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- for (int i = 0; i < 2; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(25. + i*75.));
- }
-
- QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- for (int i = 0; i < 2; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(25. + i*75.));
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::currentIndex_delayedItemCreation()
-{
- QFETCH(bool, setCurrentToZero);
-
- QQuickView *canvas = createView();
-
- // test currentIndexChanged() is emitted even if currentIndex = 0 on start up
- // (since the currentItem will have changed and that shares the same index)
- canvas->rootContext()->setContextProperty("setCurrentToZero", setCurrentToZero);
-
- canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QSignalSpy spy(listview, SIGNAL(currentItemChanged()));
- QCOMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(spy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QQuickListView::currentIndex_delayedItemCreation_data()
-{
- QTest::addColumn<bool>("setCurrentToZero");
-
- QTest::newRow("set to 0") << true;
- QTest::newRow("don't set to 0") << false;
-}
-
-void tst_QQuickListView::currentIndex()
-{
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- QString filename(testFile("listview-initCurrent.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // current item should be 20th item at startup
- // and current item should be in view
- QCOMPARE(listview->currentIndex(), 20);
- QCOMPARE(listview->contentY(), 100.0);
- QCOMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 20));
- QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
-
- // no wrap
- listview->setCurrentIndex(0);
- QCOMPARE(listview->currentIndex(), 0);
- // confirm that the velocity is updated
- QTRY_VERIFY(listview->verticalVelocity() != 0.0);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 1);
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- // with wrap
- ctxt->setContextProperty("testWrap", QVariant(true));
- QVERIFY(listview->isWrapEnabled());
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), model.count()-1);
-
- QTRY_COMPARE(listview->contentY(), 280.0);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- QTRY_COMPARE(listview->contentY(), 0.0);
-
-
- // footer should become visible if it is out of view, and then current index is set to count-1
- canvas->rootObject()->setProperty("showFooter", true);
- QTRY_VERIFY(listview->footerItem());
- listview->setCurrentIndex(model.count()-2);
- QTRY_VERIFY(listview->footerItem()->y() > listview->contentY() + listview->height());
- listview->setCurrentIndex(model.count()-1);
- QTRY_COMPARE(listview->contentY() + listview->height(), (20.0 * model.count()) + listview->footerItem()->height());
- canvas->rootObject()->setProperty("showFooter", false);
-
- // header should become visible if it is out of view, and then current index is set to 0
- canvas->rootObject()->setProperty("showHeader", true);
- QTRY_VERIFY(listview->headerItem());
- listview->setCurrentIndex(1);
- QTRY_VERIFY(listview->headerItem()->y() + listview->headerItem()->height() < listview->contentY());
- listview->setCurrentIndex(0);
- QTRY_COMPARE(listview->contentY(), -listview->headerItem()->height());
- canvas->rootObject()->setProperty("showHeader", false);
-
-
- // Test keys
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
-
- listview->setCurrentIndex(0);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(listview->currentIndex(), 1);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(listview->currentIndex(), 0);
-
- // hold down Key_Down
- for (int i=0; i<model.count()-1; i++) {
- QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true);
- QTRY_COMPARE(listview->currentIndex(), i+1);
- }
- QTest::keyRelease(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->currentIndex(), model.count()-1);
- QTRY_COMPARE(listview->contentY(), 280.0);
-
- // hold down Key_Up
- for (int i=model.count()-1; i > 0; i--) {
- QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true);
- QTRY_COMPARE(listview->currentIndex(), i-1);
- }
- QTest::keyRelease(canvas, Qt::Key_Up);
- QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->contentY(), 0.0);
-
-
- // turn off auto highlight
- listview->setHighlightFollowsCurrentItem(false);
- QVERIFY(listview->highlightFollowsCurrentItem() == false);
-
- QVERIFY(listview->highlightItem());
- qreal hlPos = listview->highlightItem()->y();
-
- listview->setCurrentIndex(4);
- QTRY_COMPARE(listview->highlightItem()->y(), hlPos);
-
- // insert item before currentIndex
- listview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- listview->setCurrentIndex(-1);
-
- QCOMPARE(listview->currentIndex(), -1);
- QVERIFY(!listview->highlightItem());
- QVERIFY(!listview->currentItem());
-
- delete canvas;
-}
-
-void tst_QQuickListView::noCurrentIndex()
-{
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(testFile("listview-noCurrent.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // current index should be -1 at startup
- // and we should not have a currentItem or highlightItem
- QCOMPARE(listview->currentIndex(), -1);
- QCOMPARE(listview->contentY(), 0.0);
- QVERIFY(!listview->highlightItem());
- QVERIFY(!listview->currentItem());
-
- listview->setCurrentIndex(2);
- QCOMPARE(listview->currentIndex(), 2);
- QVERIFY(listview->highlightItem());
- QVERIFY(listview->currentItem());
-
- delete canvas;
-}
-
-void tst_QQuickListView::itemList()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("itemlist.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickVisualItemModel *model = canvas->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
- QTRY_VERIFY(model != 0);
-
- QTRY_VERIFY(model->count() == 3);
- QTRY_COMPARE(listview->currentIndex(), 0);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), 0.0);
- QCOMPARE(item->height(), listview->height());
-
- QQuickText *text = findItem<QQuickText>(contentItem, "text1");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
-
- listview->setCurrentIndex(2);
-
- item = findItem<QQuickItem>(contentItem, "item3");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), 480.0);
-
- text = findItem<QQuickText>(contentItem, "text3");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
-
- delete canvas;
-}
-
-void tst_QQuickListView::cacheBuffer()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 90; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_VERIFY(listview->delegate() != 0);
- QTRY_VERIFY(listview->model() != 0);
- QTRY_VERIFY(listview->highlight() != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- testObject->setCacheBuffer(200);
- QTRY_VERIFY(listview->cacheBuffer() == 200);
-
- // items will be created one at a time
- for (int i = itemCount; i < qMin(itemCount+10,model.count()); ++i) {
- QVERIFY(findItem<QQuickItem>(listview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(listview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- int newItemCount = 0;
- newItemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- // move view and confirm items in view are visible immediately and outside are created async
- listview->setContentY(300);
-
- for (int i = 15; i < 32; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- QVERIFY(findItem<QQuickItem>(listview, "wrapper", 32) == 0);
-
- // ensure buffered items are created
- for (int i = 32; i < qMin(41,model.count()); ++i) {
- QQuickItem *item = 0;
- while (!item) {
- qGuiApp->processEvents(); // allow refill to happen
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(listview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::positionViewAtIndex()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
- canvas->show();
- canvas->setSource(testFileUrl("listviewtest.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on a currently visible item
- listview->positionViewAtIndex(3, QQuickListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on an item beyond the visible items
- listview->positionViewAtIndex(22, QQuickListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 440.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- listview->positionViewAtIndex(28, QQuickListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 480.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at the beginning again
- listview->positionViewAtIndex(0, QQuickListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at End using last index
- listview->positionViewAtIndex(model.count()-1, QQuickListView::End);
- QTRY_COMPARE(listview->contentY(), 480.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at End
- listview->positionViewAtIndex(20, QQuickListView::End);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // Position in Center
- listview->positionViewAtIndex(15, QQuickListView::Center);
- QTRY_COMPARE(listview->contentY(), 150.);
-
- // Ensure at least partially visible
- listview->positionViewAtIndex(15, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 150.);
-
- listview->setContentY(302);
- listview->positionViewAtIndex(15, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 302.);
-
- listview->setContentY(320);
- listview->positionViewAtIndex(15, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 300.);
-
- listview->setContentY(85);
- listview->positionViewAtIndex(20, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 85.);
-
- listview->setContentY(75);
- listview->positionViewAtIndex(20, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // Ensure completely visible
- listview->setContentY(120);
- listview->positionViewAtIndex(20, QQuickListView::Contain);
- QTRY_COMPARE(listview->contentY(), 120.);
-
- listview->setContentY(302);
- listview->positionViewAtIndex(15, QQuickListView::Contain);
- QTRY_COMPARE(listview->contentY(), 300.);
-
- listview->setContentY(85);
- listview->positionViewAtIndex(20, QQuickListView::Contain);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // positionAtBeginnging
- listview->positionViewAtBeginning();
- QTRY_COMPARE(listview->contentY(), 0.);
-
- listview->setContentY(80);
- canvas->rootObject()->setProperty("showHeader", true);
- listview->positionViewAtBeginning();
- QTRY_COMPARE(listview->contentY(), -30.);
-
- // positionAtEnd
- listview->positionViewAtEnd();
- QTRY_COMPARE(listview->contentY(), 480.); // 40*20 - 320
-
- listview->setContentY(80);
- canvas->rootObject()->setProperty("showFooter", true);
- listview->positionViewAtEnd();
- QTRY_COMPARE(listview->contentY(), 510.);
-
- // set current item to outside visible view, position at beginning
- // and ensure highlight moves to current item
- listview->setCurrentIndex(1);
- listview->positionViewAtBeginning();
- QTRY_COMPARE(listview->contentY(), -30.);
- QVERIFY(listview->highlightItem());
- QCOMPARE(listview->highlightItem()->y(), 20.);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::resetModel()
-{
- QQuickView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaylist.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QTRY_COMPARE(listview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QTRY_COMPARE(listview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::propertyChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
- QTRY_VERIFY(listView);
-
- QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged()));
- QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged()));
- QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged()));
- QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged()));
- QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged()));
- QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged()));
- QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged()));
-
- QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true);
- QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0);
- QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0);
- QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::ApplyRange);
- QTRY_COMPARE(listView->isWrapEnabled(), true);
- QTRY_COMPARE(listView->cacheBuffer(), 10);
- QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapToItem);
-
- listView->setHighlightFollowsCurrentItem(false);
- listView->setPreferredHighlightBegin(1.0);
- listView->setPreferredHighlightEnd(1.0);
- listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
- listView->setWrapEnabled(false);
- listView->setCacheBuffer(3);
- listView->setSnapMode(QQuickListView::SnapOneItem);
-
- QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false);
- QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0);
- QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0);
- QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
- QTRY_COMPARE(listView->isWrapEnabled(), false);
- QTRY_COMPARE(listView->cacheBuffer(), 3);
- QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapOneItem);
-
- QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
- QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
- QTRY_COMPARE(highlightRangeModeSpy.count(),1);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(snapModeSpy.count(),1);
-
- listView->setHighlightFollowsCurrentItem(false);
- listView->setPreferredHighlightBegin(1.0);
- listView->setPreferredHighlightEnd(1.0);
- listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
- listView->setWrapEnabled(false);
- listView->setCacheBuffer(3);
- listView->setSnapMode(QQuickListView::SnapOneItem);
-
- QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
- QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
- QTRY_COMPARE(highlightRangeModeSpy.count(),1);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(snapModeSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QQuickListView::componentChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
- QTRY_VERIFY(listView);
-
- QDeclarativeComponent component(canvas->engine());
- component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
-
- QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged()));
- QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged()));
- QSignalSpy headerSpy(listView, SIGNAL(headerChanged()));
- QSignalSpy footerSpy(listView, SIGNAL(footerChanged()));
-
- listView->setHighlight(&component);
- listView->setHeader(&component);
- listView->setFooter(&component);
- listView->setDelegate(&delegateComponent);
-
- QTRY_COMPARE(listView->highlight(), &component);
- QTRY_COMPARE(listView->header(), &component);
- QTRY_COMPARE(listView->footer(), &component);
- QTRY_COMPARE(listView->delegate(), &delegateComponent);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- listView->setHighlight(&component);
- listView->setHeader(&component);
- listView->setFooter(&component);
- listView->setDelegate(&delegateComponent);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QQuickListView::modelChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
- QTRY_VERIFY(listView);
-
- QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
- QTRY_VERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
- QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
-
- listView->setModel(modelVariant);
- QTRY_COMPARE(listView->model(), modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- listView->setModel(modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- listView->setModel(QVariant());
- QTRY_COMPARE(modelSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_QQuickListView::QTBUG_9791()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("strictlyenforcerange.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_VERIFY(listview->delegate() != 0);
- QTRY_VERIFY(listview->model() != 0);
-
- QMetaObject::invokeMethod(listview, "fillModel");
- qApp->processEvents();
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- QCOMPARE(itemCount, 3);
-
- for (int i = 0; i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), i*300.0);
- }
-
- // check that view is positioned correctly
- QTRY_COMPARE(listview->contentX(), 590.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::manualHighlight()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QString filename(testFile("manual-highlight.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- listview->setCurrentIndex(2);
-
- QTRY_COMPARE(listview->currentIndex(), 2);
- QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- // QTBUG-15972
- listview->positionViewAtIndex(3, QQuickListView::Contain);
-
- QTRY_COMPARE(listview->currentIndex(), 2);
- QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- delete canvas;
-}
-
-void tst_QQuickListView::QTBUG_11105()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- listview->positionViewAtIndex(20, QQuickListView::Beginning);
- QCOMPARE(listview->contentY(), 280.);
-
- QmlListModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 5);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::header()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(QPointF, initialHeaderPos);
- QFETCH(QPointF, firstDelegatePos);
- QFETCH(QPointF, initialContentPos);
- QFETCH(QPointF, changedHeaderPos);
- QFETCH(QPointF, changedContentPos);
- QFETCH(QPointF, resizeContentPos);
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("initialViewWidth", 240);
- canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(testFileUrl("header.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *header = 0;
- QTRY_VERIFY(header = findItem<QQuickText>(contentItem, "header"));
- QVERIFY(header == listview->headerItem());
-
- QCOMPARE(header->width(), 100.);
- QCOMPARE(header->height(), 30.);
- QCOMPARE(header->pos(), initialHeaderPos);
- QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- model.clear();
- QTRY_COMPARE(listview->count(), model.count());
- QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is
-
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QSignalSpy headerItemSpy(listview, SIGNAL(headerItemChanged()));
- QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
-
- QCOMPARE(headerItemSpy.count(), 1);
-
- header = findItem<QQuickText>(contentItem, "header");
- QVERIFY(!header);
- header = findItem<QQuickText>(contentItem, "header2");
- QVERIFY(header);
-
- QVERIFY(header == listview->headerItem());
-
- QCOMPARE(header->pos(), changedHeaderPos);
- QCOMPARE(header->width(), 50.);
- QCOMPARE(header->height(), 20.);
- QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- delete canvas;
-
-
- // QTBUG-21207 header should become visible if view resizes from initial empty size
-
- canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("initialViewWidth", 0.0);
- canvas->rootContext()->setContextProperty("initialViewHeight", 0.0);
- canvas->setSource(testFileUrl("header.qml"));
- canvas->show();
- qApp->processEvents();
-
- listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- listview->setWidth(240);
- listview->setHeight(320);
- QTRY_COMPARE(listview->headerItem()->pos(), initialHeaderPos);
- QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
-
-
- delete canvas;
-}
-
-void tst_QQuickListView::header_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<QPointF>("initialHeaderPos");
- QTest::addColumn<QPointF>("changedHeaderPos");
- QTest::addColumn<QPointF>("initialContentPos");
- QTest::addColumn<QPointF>("changedContentPos");
- QTest::addColumn<QPointF>("firstDelegatePos");
- QTest::addColumn<QPointF>("resizeContentPos");
-
- // header1 = 100 x 30
- // header2 = 50 x 20
- // delegates = 240 x 20
- // view width = 240
-
- // header above items, top left
- QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, 0)
- << QPointF(0, -10);
-
- // header above items, top right
- QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, 0)
- << QPointF(0, -10);
-
- // header to left of items
- QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight
- << QPointF(-100, 0)
- << QPointF(-50, 0)
- << QPointF(-100, 0)
- << QPointF(-50, 0)
- << QPointF(0, 0)
- << QPointF(-40, 0);
-
- // header to right of items
- QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(-240 + 100, 0)
- << QPointF(-240 + 50, 0)
- << QPointF(-240, 0)
- << QPointF(-240 + 40, 0);
-}
-
-void tst_QQuickListView::header_delayItemCreation()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
-
- canvas->rootContext()->setContextProperty("setCurrentToZero", QVariant(false));
- canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *header = findItem<QQuickText>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->y(), -header->height());
-
- QCOMPARE(listview->contentY(), -header->height());
-
- model.clear();
- QTRY_COMPARE(header->y(), -header->height());
-
- delete canvas;
-}
-
-void tst_QQuickListView::footer()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(QPointF, initialFooterPos);
- QFETCH(QPointF, firstDelegatePos);
- QFETCH(QPointF, initialContentPos);
- QFETCH(QPointF, changedFooterPos);
- QFETCH(QPointF, changedContentPos);
- QFETCH(QPointF, resizeContentPos);
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 3; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("footer.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
- QVERIFY(footer);
-
- QVERIFY(footer == listview->footerItem());
-
- QCOMPARE(footer->pos(), initialFooterPos);
- QCOMPARE(footer->width(), 100.);
- QCOMPARE(footer->height(), 30.);
- QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- // remove one item
- model.removeItem(1);
-
- if (orientation == QQuickListView::Vertical) {
- QTRY_COMPARE(footer->y(), initialFooterPos.y() - 20); // delegate height = 20
- } else {
- QTRY_COMPARE(footer->x(), layoutDirection == Qt::LeftToRight ?
- initialFooterPos.x() - 40 : initialFooterPos.x() + 40); // delegate width = 40
- }
-
- // remove all items
- model.clear();
-
- QPointF posWhenNoItems(0, 0);
- if (orientation == QQuickListView::Horizontal && layoutDirection == Qt::RightToLeft)
- posWhenNoItems.setX(-100);
- QTRY_COMPARE(footer->pos(), posWhenNoItems);
-
- // if header is present, it's at a negative pos, so the footer should not move
- canvas->rootObject()->setProperty("showHeader", true);
- QTRY_COMPARE(footer->pos(), posWhenNoItems);
- canvas->rootObject()->setProperty("showHeader", false);
-
- // add 30 items
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QSignalSpy footerItemSpy(listview, SIGNAL(footerItemChanged()));
- QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
-
- QCOMPARE(footerItemSpy.count(), 1);
-
- footer = findItem<QQuickText>(contentItem, "footer");
- QVERIFY(!footer);
- footer = findItem<QQuickText>(contentItem, "footer2");
- QVERIFY(footer);
-
- QVERIFY(footer == listview->footerItem());
-
- QCOMPARE(footer->pos(), changedFooterPos);
- QCOMPARE(footer->width(), 50.);
- QCOMPARE(footer->height(), 20.);
- QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- listview->positionViewAtEnd();
- footer->setHeight(10);
- footer->setWidth(40);
- QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), resizeContentPos);
-
- delete canvas;
-}
-
-void tst_QQuickListView::footer_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<QPointF>("initialFooterPos");
- QTest::addColumn<QPointF>("changedFooterPos");
- QTest::addColumn<QPointF>("initialContentPos");
- QTest::addColumn<QPointF>("changedContentPos");
- QTest::addColumn<QPointF>("firstDelegatePos");
- QTest::addColumn<QPointF>("resizeContentPos");
-
- // footer1 = 100 x 30
- // footer2 = 50 x 20
- // delegates = 40 x 20
- // view width = 240
- // view height = 320
-
- // footer below items, bottom left
- QTest::newRow("vertical, layout left to right") << QQuickListView::Vertical << Qt::LeftToRight
- << QPointF(0, 3 * 20)
- << QPointF(0, 30 * 20) // added 30 items
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 30 * 20 - 320 + 10);
-
- // footer below items, bottom right
- QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft
- << QPointF(0, 3 * 20)
- << QPointF(0, 30 * 20)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 30 * 20 - 320 + 10);
-
- // footer to right of items
- QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight
- << QPointF(40 * 3, 0)
- << QPointF(40 * 30, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(40 * 30 - 240 + 40, 0);
-
- // footer to left of items
- QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft
- << QPointF(-(40 * 3) - 100, 0)
- << QPointF(-(40 * 30) - 50, 0) // 50 = new footer width
- << QPointF(-240, 0)
- << QPointF(-240, 0)
- << QPointF(-40, 0)
- << QPointF(-(40 * 30) - 40, 0);
-}
-
-class LVAccessor : public QQuickListView
-{
-public:
- qreal minY() const { return minYExtent(); }
- qreal maxY() const { return maxYExtent(); }
- qreal minX() const { return minXExtent(); }
- qreal maxX() const { return maxXExtent(); }
-};
-
-void tst_QQuickListView::headerFooter()
-{
- {
- // Vertical
- QQuickView *canvas = createView();
-
- QmlListModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("headerfooter.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->y(), -header->height());
-
- QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->y(), 0.);
-
- QCOMPARE(static_cast<LVAccessor*>(listview)->minY(), header->height());
- QCOMPARE(static_cast<LVAccessor*>(listview)->maxY(), header->height());
-
- delete canvas;
- }
- {
- // Horizontal
- QQuickView *canvas = createView();
-
- QmlListModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("headerfooter.qml"));
- canvas->rootObject()->setProperty("horizontal", true);
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->x(), -header->width());
-
- QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->x(), 0.);
-
- QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), header->width());
- QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), header->width());
-
- delete canvas;
- }
- {
- // Horizontal RTL
- QQuickView *canvas = createView();
-
- QmlListModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("headerfooter.qml"));
- canvas->rootObject()->setProperty("horizontal", true);
- canvas->rootObject()->setProperty("rtl", true);
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->x(), 0.);
-
- QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->x(), -footer->width());
-
- QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), 240. - header->width());
- QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), 240. - header->width());
-
- delete canvas;
- }
-}
-
-void tst_QQuickListView::resizeView()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- QVariant heightRatio;
- QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
- QCOMPARE(heightRatio.toReal(), 0.4);
-
- listview->setHeight(200);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
- QCOMPARE(heightRatio.toReal(), 0.25);
-
- // Ensure we handle -ve sizes
- listview->setHeight(-100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 1);
-
- listview->setCacheBuffer(200);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 11);
-
- // ensure items in cache become visible
- listview->setHeight(200);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 21);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- QCOMPARE(item->isVisible(), i < 11); // inside view visible, outside not visible
- }
-
- // ensure items outside view become invisible
- listview->setHeight(100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 16);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::resizeViewAndRepaint()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("initialHeight", 100);
-
- canvas->setSource(testFileUrl("resizeview.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // item at index 10 should not be currently visible
- QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- listview->setHeight(320);
-
- QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- listview->setHeight(100);
- QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- delete canvas;
-}
-
-void tst_QQuickListView::sizeLessThan1()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("sizelessthan1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*0.5);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::QTBUG_14821()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("qtbug14821.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 99);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::resizeDelegate()
-{
- QQuickView *canvas = createView();
-
- QStringList strings;
- for (int i = 0; i < 30; ++i)
- strings << QString::number(i);
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaylist.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QCOMPARE(listview->count(), model.rowCount());
-
- listview->setCurrentIndex(25);
- listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 0; i < 16; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QCOMPARE(item->y(), i*20.0);
- }
-
- QCOMPARE(listview->currentItem()->y(), 500.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 500.0);
-
- canvas->rootObject()->setProperty("delegateHeight", 30);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 0; i < 11; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QTRY_COMPARE(item->y(), i*30.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 750.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 750.0);
-
- listview->setCurrentIndex(1);
- listview->positionViewAtIndex(25, QQuickListView::Beginning);
- listview->positionViewAtIndex(5, QQuickListView::Beginning);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 5; i < 16; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QCOMPARE(item->y(), i*30.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 30.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 30.0);
-
- canvas->rootObject()->setProperty("delegateHeight", 20);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 5; i < 11; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QTRY_COMPARE(item->y(), 150 + (i-5)*20.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 70.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 70.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::resizeFirstDelegate()
-{
- // QTBUG-20712: Content Y jumps constantly if first delegate height == 0
- // and other delegates have height > 0
-
- QQuickView *canvas = createView();
-
- // bug only occurs when all items in the model are visible
- QmlListModel model;
- for (int i = 0; i < 10; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *item = 0;
- for (int i = 0; i < model.count(); ++i) {
- item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QCOMPARE(item->y(), i*20.0);
- }
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- item->setHeight(0);
-
- // check the content y has not jumped up and down
- QCOMPARE(listview->contentY(), 0.0);
- QSignalSpy spy(listview, SIGNAL(contentYChanged()));
- QTest::qWait(100);
- QCOMPARE(spy.count(), 0);
-
- for (int i = 1; i < model.count(); ++i) {
- item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QTRY_COMPARE(item->y(), (i-1)*20.0);
- }
-
-
- // QTBUG-22014: refill doesn't clear items scrolling off the top of the
- // list if they follow a zero-sized delegate
-
- for (int i = 0; i < 10; i++)
- model.addItem("Item" + QString::number(i), "");
- QTRY_COMPARE(listview->count(), model.count());
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 1);
- QVERIFY(item);
- item->setHeight(0);
-
- listview->setCurrentIndex(19);
- qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // items 0-2 should have been deleted
- for (int i=0; i<3; i++) {
- QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", i));
- }
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickListView::QTBUG_16037()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- canvas->setSource(testFileUrl("qtbug16037.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
- QTRY_VERIFY(listview != 0);
-
- QVERIFY(listview->contentHeight() <= 0.0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "setModel");
-
- QTRY_COMPARE(listview->contentHeight(), 80.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::indexAt_itemAt_data()
-{
- QTest::addColumn<qreal>("x");
- QTest::addColumn<qreal>("y");
- QTest::addColumn<int>("index");
-
- QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0;
- QTest::newRow("Item 0 - 0, 19") << 0. << 19. << 0;
- QTest::newRow("Item 0 - 239, 19") << 239. << 19. << 0;
- QTest::newRow("Item 1 - 0, 20") << 0. << 20. << 1;
- QTest::newRow("No Item - 240, 20") << 240. << 20. << -1;
-}
-
-void tst_QQuickListView::indexAt_itemAt()
-{
- QFETCH(qreal, x);
- QFETCH(qreal, y);
- QFETCH(int, index);
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *item = 0;
- if (index >= 0) {
- item = findItem<QQuickItem>(contentItem, "wrapper", index);
- QVERIFY(item);
- }
- QCOMPARE(listview->indexAt(x,y), index);
- QVERIFY(listview->itemAt(x,y) == item);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::incrementalModel()
-{
- QQuickView *canvas = createView();
-
- IncrementalModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaylist.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(listview->count(), 20);
-
- listview->positionViewAtIndex(10, QQuickListView::Beginning);
-
- QTRY_COMPARE(listview->count(), 25);
-
- delete canvas;
-}
-
-void tst_QQuickListView::onAdd()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, itemsToAdd);
-
- const int delegateHeight = 10;
- QaimModel model;
-
- // these initial items should not trigger ListView.onAdd
- for (int i=0; i<initialItemCount; i++)
- model.addItem("dummy value", "dummy value");
-
- QQuickView *canvas = createView();
- canvas->setGeometry(0,0,200, delegateHeight * (initialItemCount + itemsToAdd));
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(testFileUrl("attachedSignals.qml"));
-
- QObject *object = canvas->rootObject();
- object->setProperty("width", canvas->width());
- object->setProperty("height", canvas->height());
- qApp->processEvents();
-
- QList<QPair<QString, QString> > items;
- for (int i=0; i<itemsToAdd; i++)
- items << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.addItems(items);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QVariantList result = object->property("addedDelegates").toList();
- QCOMPARE(result.count(), items.count());
- for (int i=0; i<items.count(); i++)
- QCOMPARE(result[i].toString(), items[i].first);
-
- delete canvas;
-}
-
-void tst_QQuickListView::onAdd_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("itemsToAdd");
-
- QTest::newRow("0, add 1") << 0 << 1;
- QTest::newRow("0, add 2") << 0 << 2;
- QTest::newRow("0, add 10") << 0 << 10;
-
- QTest::newRow("1, add 1") << 1 << 1;
- QTest::newRow("1, add 2") << 1 << 2;
- QTest::newRow("1, add 10") << 1 << 10;
-
- QTest::newRow("5, add 1") << 5 << 1;
- QTest::newRow("5, add 2") << 5 << 2;
- QTest::newRow("5, add 10") << 5 << 10;
-}
-
-void tst_QQuickListView::onRemove()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, indexToRemove);
- QFETCH(int, removeCount);
-
- const int delegateHeight = 10;
- QaimModel model;
- for (int i=0; i<initialItemCount; i++)
- model.addItem(QString("value %1").arg(i), "dummy value");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(testFileUrl("attachedSignals.qml"));
-
- QObject *object = canvas->rootObject();
-
- model.removeItems(indexToRemove, removeCount);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
-
- delete canvas;
-}
-
-void tst_QQuickListView::onRemove_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("indexToRemove");
- QTest::addColumn<int>("removeCount");
-
- QTest::newRow("remove first") << 1 << 0 << 1;
- QTest::newRow("two items, remove first") << 2 << 0 << 1;
- QTest::newRow("two items, remove last") << 2 << 1 << 1;
- QTest::newRow("two items, remove all") << 2 << 0 << 2;
-
- QTest::newRow("four items, remove first") << 4 << 0 << 1;
- QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
- QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
- QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
- QTest::newRow("four items, remove last") << 4 << 3 << 1;
- QTest::newRow("four items, remove all") << 4 << 0 << 4;
-
- QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
- QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
- QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
-}
-
-void tst_QQuickListView::rightToLeft()
-{
- QQuickView *canvas = createView();
- canvas->setGeometry(0,0,640,320);
- canvas->setSource(testFileUrl("rightToLeft.qml"));
- canvas->show();
- qApp->processEvents();
-
- QVERIFY(canvas->rootObject() != 0);
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickVisualItemModel *model = canvas->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
- QTRY_VERIFY(model != 0);
-
- QTRY_VERIFY(model->count() == 3);
- QTRY_COMPARE(listview->currentIndex(), 0);
-
- // initial position at first item, right edge aligned
- QCOMPARE(listview->contentX(), -640.);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), -100.0);
- QCOMPARE(item->height(), listview->height());
-
- QQuickText *text = findItem<QQuickText>(contentItem, "text1");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
-
- listview->setCurrentIndex(2);
-
- item = findItem<QQuickItem>(contentItem, "item3");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), -540.0);
-
- text = findItem<QQuickText>(contentItem, "text3");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
-
- QCOMPARE(listview->contentX(), -640.);
-
- // Ensure resizing maintains position relative to right edge
- qobject_cast<QQuickItem*>(canvas->rootObject())->setWidth(600);
- QTRY_COMPARE(listview->contentX(), -600.);
-
- delete canvas;
-}
-
-void tst_QQuickListView::test_mirroring()
-{
- QQuickView *canvasA = createView();
- canvasA->setSource(testFileUrl("rightToLeft.qml"));
- QQuickListView *listviewA = findItem<QQuickListView>(canvasA->rootObject(), "view");
- QTRY_VERIFY(listviewA != 0);
-
- QQuickView *canvasB = createView();
- canvasB->setSource(testFileUrl("rightToLeft.qml"));
- QQuickListView *listviewB = findItem<QQuickListView>(canvasB->rootObject(), "view");
- QTRY_VERIFY(listviewA != 0);
- qApp->processEvents();
-
- QList<QString> objectNames;
- objectNames << "item1" << "item2"; // << "item3"
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
- listviewB->setProperty("layoutDirection", Qt::RightToLeft);
- QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection());
-
- // LTR != RTL
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
- listviewB->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == LTR
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
-
- QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection());
- QQuickItemPrivate::get(listviewB)->setLayoutMirror(true);
- QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection());
-
- // LTR != LTR+mirror
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL == LTR+mirror
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
-
- listviewB->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL != RTL+mirror
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == RTL+mirror
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
-
- delete canvasA;
- delete canvasB;
-}
-
-void tst_QQuickListView::margins()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("margins.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QCOMPARE(listview->contentY(), -30.);
- QCOMPARE(listview->yOrigin(), 0.);
-
- // check end bound
- listview->positionViewAtEnd();
- qreal pos = listview->contentY();
- listview->setContentY(pos + 80);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- listview->returnToBounds();
- QTRY_COMPARE(listview->contentY(), pos + 50);
-
- // remove item before visible and check that top margin is maintained
- // and yOrigin is updated
- listview->setContentY(100);
- model.removeItem(1);
- QTRY_COMPARE(listview->count(), model.count());
- listview->setContentY(-50);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- listview->returnToBounds();
- QCOMPARE(listview->yOrigin(), 20.);
- QTRY_COMPARE(listview->contentY(), -10.);
-
- // reduce top margin
- listview->setTopMargin(20);
- QCOMPARE(listview->yOrigin(), 20.);
- QTRY_COMPARE(listview->contentY(), 0.);
-
- // check end bound
- listview->positionViewAtEnd();
- pos = listview->contentY();
- listview->setContentY(pos + 80);
- listview->returnToBounds();
- QTRY_COMPARE(listview->contentY(), pos + 50);
-
- // reduce bottom margin
- pos = listview->contentY();
- listview->setBottomMargin(40);
- QCOMPARE(listview->yOrigin(), 20.);
- QTRY_COMPARE(listview->contentY(), pos-10);
-
- delete canvas;
-}
-
-// QTBUG-24028
-void tst_QQuickListView::marginsResize()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(qreal, start);
- QFETCH(qreal, end);
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("margins2.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
- QTRY_VERIFY(listview != 0);
-
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // view is resized after componentCompleted - top margin should still be visible
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), start);
- else
- QCOMPARE(listview->contentX(), start);
-
- // move to last index and ensure bottom margin is visible.
- listview->setCurrentIndex(19);
- if (orientation == QQuickListView::Vertical)
- QTRY_COMPARE(listview->contentY(), end);
- else
- QTRY_COMPARE(listview->contentX(), end);
-
- // back to top - top margin should be visible.
- listview->setCurrentIndex(0);
- if (orientation == QQuickListView::Vertical)
- QTRY_COMPARE(listview->contentY(), start);
- else
- QTRY_COMPARE(listview->contentX(), start);
-
- delete canvas;
-}
-
-void tst_QQuickListView::marginsResize_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<qreal>("start");
- QTest::addColumn<qreal>("end");
-
- QTest::newRow("vertical") << QQuickListView::Vertical << Qt::LeftToRight << -20.0 << 1020.0;
- QTest::newRow("horizontal") << QQuickListView::Horizontal << Qt::LeftToRight << -20.0 << 1020.0;
- QTest::newRow("horizontal, rtl") << QQuickListView::Horizontal << Qt::RightToLeft << -180.0 << -1220.0;
-}
-
-void tst_QQuickListView::snapToItem_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<int>("highlightRangeMode");
- QTest::addColumn<QPoint>("flickStart");
- QTest::addColumn<QPoint>("flickEnd");
- QTest::addColumn<qreal>("snapAlignment");
- QTest::addColumn<qreal>("endExtent");
- QTest::addColumn<qreal>("startExtent");
-
- QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
-
- QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
-
- QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
-
- QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
-
- QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
-
- QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
-}
-
-void tst_QQuickListView::snapToItem()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(int, highlightRangeMode);
- QFETCH(QPoint, flickStart);
- QFETCH(QPoint, flickEnd);
- QFETCH(qreal, snapAlignment);
- QFETCH(qreal, endExtent);
- QFETCH(qreal, startExtent);
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("snapToItem.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // confirm that a flick hits an item boundary
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(qreal(fmod(listview->contentY(),80.0)), snapAlignment);
- else
- QCOMPARE(qreal(fmod(listview->contentX(),80.0)), snapAlignment);
-
- // flick to end
- do {
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- } while (orientation == QQuickListView::Vertical
- ? !listview->isAtYEnd()
- : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning());
-
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), endExtent);
- else
- QCOMPARE(listview->contentX(), endExtent);
-
- // flick to start
- do {
- flick(canvas, flickEnd, flickStart, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- } while (orientation == QQuickListView::Vertical
- ? !listview->isAtYBeginning()
- : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd());
-
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), startExtent);
- else
- QCOMPARE(listview->contentX(), startExtent);
-
- delete canvas;
-}
-
-void tst_QQuickListView::qListModelInterface_items()
-{
- items<QmlListModel>(testFileUrl("listviewtest.qml"), false);
-}
-
-void tst_QQuickListView::qListModelInterface_package_items()
-{
- items<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
-}
-
-void tst_QQuickListView::qAbstractItemModel_items()
-{
- items<QaimModel>(testFileUrl("listviewtest.qml"), false);
-}
-
-void tst_QQuickListView::qListModelInterface_changed()
-{
- changed<QmlListModel>(testFileUrl("listviewtest.qml"), false);
-}
-
-void tst_QQuickListView::qListModelInterface_package_changed()
-{
- changed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
-}
-
-void tst_QQuickListView::qAbstractItemModel_changed()
-{
- changed<QaimModel>(testFileUrl("listviewtest.qml"), false);
-}
-
-void tst_QQuickListView::qListModelInterface_inserted()
-{
- inserted<QmlListModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_package_inserted()
-{
- inserted<QmlListModel>(testFileUrl("listviewtest-package.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_inserted_more()
-{
- inserted_more<QmlListModel>();
-}
-
-void tst_QQuickListView::qListModelInterface_inserted_more_data()
-{
- inserted_more_data();
-}
-
-void tst_QQuickListView::qAbstractItemModel_inserted()
-{
- inserted<QaimModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_inserted_more()
-{
- inserted_more<QaimModel>();
-}
-
-void tst_QQuickListView::qAbstractItemModel_inserted_more_data()
-{
- inserted_more_data();
-}
-
-void tst_QQuickListView::qListModelInterface_removed()
-{
- removed<QmlListModel>(testFileUrl("listviewtest.qml"), false);
- removed<QmlListModel>(testFileUrl("listviewtest.qml"), true);
-}
-
-void tst_QQuickListView::qListModelInterface_removed_more()
-{
- removed_more<QmlListModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_removed_more_data()
-{
- removed_more_data();
-}
-
-void tst_QQuickListView::qListModelInterface_package_removed()
-{
- removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), false);
- removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
-}
-
-void tst_QQuickListView::qAbstractItemModel_removed()
-{
- removed<QaimModel>(testFileUrl("listviewtest.qml"), false);
- removed<QaimModel>(testFileUrl("listviewtest.qml"), true);
-}
-
-void tst_QQuickListView::qAbstractItemModel_removed_more()
-{
- removed_more<QaimModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_removed_more_data()
-{
- removed_more_data();
-}
-
-void tst_QQuickListView::qListModelInterface_moved()
-{
- moved<QmlListModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_moved_data()
-{
- moved_data();
-}
-
-void tst_QQuickListView::qListModelInterface_package_moved()
-{
- moved<QmlListModel>(testFileUrl("listviewtest-package.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_package_moved_data()
-{
- moved_data();
-}
-
-void tst_QQuickListView::qAbstractItemModel_moved()
-{
- moved<QaimModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_moved_data()
-{
- moved_data();
-}
-
-void tst_QQuickListView::qListModelInterface_clear()
-{
- clear<QmlListModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_package_clear()
-{
- clear<QmlListModel>(testFileUrl("listviewtest-package.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_clear()
-{
- clear<QaimModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_sections()
-{
- sections<QmlListModel>(testFileUrl("listview-sections.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_package_sections()
-{
- sections<QmlListModel>(testFileUrl("listview-sections-package.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_sections()
-{
- sections<QaimModel>(testFileUrl("listview-sections.qml"));
-}
-
-void tst_QQuickListView::creationContext()
-{
- QQuickView canvas;
- canvas.setGeometry(0,0,240,320);
- canvas.setSource(testFileUrl("creationContext.qml"));
- qApp->processEvents();
-
- QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
- QVERIFY(rootItem);
- QVERIFY(rootItem->property("count").toInt() > 0);
-
- QQuickItem *item;
- QVERIFY(item = rootItem->findChild<QQuickItem *>("listItem"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("section"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
-}
-
-void tst_QQuickListView::QTBUG_21742()
-{
- QQuickView canvas;
- canvas.setGeometry(0,0,200,200);
- canvas.setSource(testFileUrl("qtbug-21742.qml"));
- qApp->processEvents();
-
- QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
- QVERIFY(rootItem);
- QCOMPARE(rootItem->property("count").toInt(), 1);
-}
-
-void tst_QQuickListView::asynchronous()
-{
- QQuickView *canvas = createView();
- canvas->show();
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->setSource(testFileUrl("asyncloader.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootObject);
-
- QQuickListView *listview = 0;
- while (!listview) {
- bool b = false;
- controller.incubateWhile(&b);
- listview = rootObject->findChild<QQuickListView*>("view");
- }
-
- // items will be created one at a time
- for (int i = 0; i < 8; ++i) {
- QVERIFY(findItem<QQuickItem>(listview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(listview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- // verify positioning
- QQuickItem *contentItem = listview->contentItem();
- for (int i = 0; i < 8; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->y(), i*50.0);
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::snapOneItem_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<int>("highlightRangeMode");
- QTest::addColumn<QPoint>("flickStart");
- QTest::addColumn<QPoint>("flickEnd");
- QTest::addColumn<qreal>("snapAlignment");
- QTest::addColumn<qreal>("endExtent");
- QTest::addColumn<qreal>("startExtent");
-
- QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
-
- QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
-
- QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0;
-
- QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
-
- QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
-
- QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0;
-}
-
-void tst_QQuickListView::snapOneItem()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(int, highlightRangeMode);
- QFETCH(QPoint, flickStart);
- QFETCH(QPoint, flickEnd);
- QFETCH(qreal, snapAlignment);
- QFETCH(qreal, endExtent);
- QFETCH(qreal, startExtent);
-
-#ifdef Q_OS_MAC
- // This test seems to be unreliable - different test data fails on different runs
- QSKIP("QTBUG-24338");
-#endif
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("snapOneItem.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
-
- // confirm that a flick hits the next item boundary
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), snapAlignment);
- else
- QCOMPARE(listview->contentX(), snapAlignment);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(listview->currentIndex(), 1);
- QCOMPARE(currentIndexSpy.count(), 1);
- }
-
- // flick to end
- do {
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- } while (orientation == QQuickListView::Vertical
- ? !listview->isAtYEnd()
- : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning());
-
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), endExtent);
- else
- QCOMPARE(listview->contentX(), endExtent);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(listview->currentIndex(), 3);
- QCOMPARE(currentIndexSpy.count(), 3);
- }
-
- // flick to start
- do {
- flick(canvas, flickEnd, flickStart, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- } while (orientation == QQuickListView::Vertical
- ? !listview->isAtYBeginning()
- : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd());
-
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), startExtent);
- else
- QCOMPARE(listview->contentX(), startExtent);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(listview->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 6);
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::unrequestedVisibility()
-{
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- canvas->setSource(testFileUrl("unrequestedItems.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *leftview = findItem<QQuickListView>(canvas->rootObject(), "leftList");
- QTRY_VERIFY(leftview != 0);
-
- QQuickListView *rightview = findItem<QQuickListView>(canvas->rootObject(), "rightList");
- QTRY_VERIFY(rightview != 0);
-
- QQuickItem *leftContent = leftview->contentItem();
- QTRY_VERIFY(leftContent != 0);
-
- QQuickItem *rightContent = rightview->contentItem();
- QTRY_VERIFY(rightContent != 0);
-
- rightview->setCurrentIndex(20);
-
- QTRY_COMPARE(leftview->contentY(), 0.0);
- QTRY_COMPARE(rightview->contentY(), 100.0);
-
- QQuickItem *item;
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), true);
-
- rightview->setCurrentIndex(0);
-
- QTRY_COMPARE(leftview->contentY(), 0.0);
- QTRY_COMPARE(rightview->contentY(), 0.0);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QTRY_COMPARE(item->isVisible(), true);
-
- QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 19));
- QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 19));
-
- leftview->setCurrentIndex(20);
-
- QTRY_COMPARE(leftview->contentY(), 100.0);
- QTRY_COMPARE(rightview->contentY(), 0.0);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QTRY_COMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(19, 1, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(3, 4, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(4, 3, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(16, 17, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(17, 16, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- delete canvas;
-}
-
-void tst_QQuickListView::populateTransitions()
-{
- QFETCH(bool, staticallyPopulate);
- QFETCH(bool, dynamicallyPopulate);
- QFETCH(bool, usePopulateTransition);
-
- QPointF transitionFrom(-50, -50);
- QPointF transitionVia(100, 100);
- QaimModel model_transitionFrom;
- QaimModel model_transitionVia;
-
- QaimModel model;
- if (staticallyPopulate) {
- for (int i = 0; i < 30; i++)
- model.addItem("item" + QString::number(i), "");
- }
-
- QQuickView *canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("testObject", new TestObject(canvas->rootContext()));
- canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
- canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
- canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom);
- canvas->rootContext()->setContextProperty("transitionVia", transitionVia);
- canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom);
- canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
- canvas->setSource(testFileUrl("populateTransitions.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QVERIFY(listview);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem);
-
- if (staticallyPopulate || dynamicallyPopulate) {
- // check the populate transition is run
- if (usePopulateTransition) {
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 17);
- } else {
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0);
- }
- QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
- } else {
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->x(), 0.0);
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- // add an item and check this is done with add trantion, not populate
- model.insertItem(0, "another item", "");
- QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 1);
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(),
- (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 17 : 0);
-
- // clear the model
- canvas->rootContext()->setContextProperty("testModel", QVariant());
- QTRY_COMPARE(listview->count(), 0);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
- listview->setProperty("countPopulateTransitions", 0);
- listview->setProperty("countAddTransitions", 0);
-
- // set to a valid model and check populate transition is run a second time
- model.clear();
- for (int i = 0; i < 30; i++)
- model.addItem("item" + QString::number(i), "");
- canvas->rootContext()->setContextProperty("testModel", &model);
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0);
- QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->x(), 0.0);
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- // reset model and check populate transition is run again
- listview->setProperty("countPopulateTransitions", 0);
- listview->setProperty("countAddTransitions", 0);
- model.reset();
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0);
- QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->x(), 0.0);
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::populateTransitions_data()
-{
- QTest::addColumn<bool>("staticallyPopulate");
- QTest::addColumn<bool>("dynamicallyPopulate");
- QTest::addColumn<bool>("usePopulateTransition");
-
- QTest::newRow("static") << true << false << true;
- QTest::newRow("static, no populate") << true << false << false;
-
- QTest::newRow("dynamic") << false << true << true;
- QTest::newRow("dynamic, no populate") << false << true << false;
-
- QTest::newRow("empty to start with") << false << false << true;
- QTest::newRow("empty to start with, no populate") << false << false << false;
-}
-
-void tst_QQuickListView::addTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(bool, shouldAnimateTargets);
- QFETCH(qreal, contentY);
- QFETCH(int, insertionIndex);
- QFETCH(int, insertionCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // added items should start here
- QPointF targetItems_transitionFrom(-50, -50);
-
- // displaced items should pass through this point
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionFrom;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(testFileUrl("addTransitions.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // only target items that will become visible should be animated
- QList<QPair<QString, QString> > newData;
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- if (shouldAnimateTargets) {
- for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
- newData << qMakePair(QString("New item %1").arg(i), QString(""));
-
- if (i >= contentY / 20 && i < (contentY + listview->height()) / 20) { // only grab visible items
- expectedTargetData << newData.last();
- targetIndexes << i;
- }
- }
- QVERIFY(expectedTargetData.count() > 0);
- }
-
- // start animation
- if (!newData.isEmpty()) {
- model.insertItems(insertionIndex, newData);
- QTRY_COMPARE(model.count(), listview->count());
- }
-
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
-
- if (shouldAnimateTargets) {
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- // check the target and displaced items were animated
- model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
- matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
- }
-
- } else {
- QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0);
- QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- int itemCount = items.count();
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::addTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<bool>("shouldAnimateTargets");
- QTest::addColumn<int>("insertionIndex");
- QTest::addColumn<int>("insertionCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // if inserting before visible index, items should not appear or animate in, even if there are > 1 new items
- QTest::newRow("insert 1, just before start")
- << 30 << 20.0 << false
- << 0 << 1 << ListRange();
- QTest::newRow("insert 1, way before start")
- << 30 << 20.0 << false
- << 0 << 1 << ListRange();
- QTest::newRow("insert multiple, just before start")
- << 30 << 100.0 << false
- << 0 << 3 << ListRange();
- QTest::newRow("insert multiple, way before start")
- << 30 << 100.0 << false
- << 0 << 3 << ListRange();
-
- QTest::newRow("insert 1 at start")
- << 30 << 0.0 << true
- << 0 << 1 << ListRange(0, 15);
- QTest::newRow("insert multiple at start")
- << 30 << 0.0 << true
- << 0 << 3 << ListRange(0, 15);
- QTest::newRow("insert 1 at start, content y not 0")
- << 30 << 40.0 << true // first visible is index 2, so translate the displaced indexes by 2
- << 2 << 1 << ListRange(0 + 2, 15 + 2);
- QTest::newRow("insert multiple at start, content y not 0")
- << 30 << 40.0 << true // first visible is index 2
- << 2 << 3 << ListRange(0 + 2, 15 + 2);
-
- QTest::newRow("insert 1 at start, to empty list")
- << 0 << 0.0 << true
- << 0 << 1 << ListRange();
- QTest::newRow("insert multiple at start, to empty list")
- << 0 << 0.0 << true
- << 0 << 3 << ListRange();
-
- QTest::newRow("insert 1 at middle")
- << 30 << 0.0 << true
- << 5 << 1 << ListRange(5, 15);
- QTest::newRow("insert multiple at middle")
- << 30 << 0.0 << true
- << 5 << 3 << ListRange(5, 15);
-
- QTest::newRow("insert 1 at bottom")
- << 30 << 0.0 << true
- << 15 << 1 << ListRange(15, 15);
- QTest::newRow("insert multiple at bottom")
- << 30 << 0.0 << true
- << 15 << 3 << ListRange(15, 15);
- QTest::newRow("insert 1 at bottom, content y not 0")
- << 30 << 20.0 * 3 << true
- << 15 + 3 << 1 << ListRange(15 + 3, 15 + 3);
- QTest::newRow("insert multiple at bottom, content y not 0")
- << 30 << 20.0 * 3 << true
- << 15 + 3 << 3 << ListRange(15 + 3, 15 + 3);
-
- // items added after the last visible will not be animated in, since they
- // do not appear in the final view
- QTest::newRow("insert 1 after end")
- << 30 << 0.0 << false
- << 17 << 1 << ListRange();
- QTest::newRow("insert multiple after end")
- << 30 << 0.0 << false
- << 17 << 3 << ListRange();
-}
-
-void tst_QQuickListView::moveTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(qreal, contentY);
- QFETCH(qreal, itemsOffsetAfterMove);
- QFETCH(int, moveFrom);
- QFETCH(int, moveTo);
- QFETCH(int, moveCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // target and displaced items should pass through these points
- QPointF targetItems_transitionVia(-50, 50);
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionVia;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(testFileUrl("moveTransitions.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QQuickText *name;
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // Items moving to *or* from visible positions should be animated.
- // Otherwise, they should not be animated.
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- for (int i=moveFrom; i<moveFrom+moveCount; i++) {
- int toIndex = moveTo + (i - moveFrom);
- if (i <= (contentY + listview->height()) / 20
- || toIndex < (contentY + listview->height()) / 20) {
- expectedTargetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- }
- // ViewTransition.index provides the indices that items are moving to, not from
- targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount);
-
- // start animation
- model.moveItems(moveFrom, moveTo, moveCount);
-
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
-
- // check the target and displaced items were animated
- model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount);
- matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::moveTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
- QTest::addColumn<int>("moveFrom");
- QTest::addColumn<int>("moveTo");
- QTest::addColumn<int>("moveCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // when removing from above the visible, all items shift down depending on how many
- // items have been removed from above the visible
- QTest::newRow("move from above view, outside visible items, move 1") << 30 << 4*20.0 << 20.0
- << 1 << 10 << 1 << ListRange(11, 15+4);
- QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 4*20.0 << 20.0
- << 0 << 10 << 1 << ListRange(11, 15+4);
- QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 4*20.0 << 2*20.0
- << 1 << 10 << 2 << ListRange(12, 15+4);
- QTest::newRow("move from above view, outside visible items, move multiple (first item)") << 30 << 4*20.0 << 3*20.0
- << 0 << 10 << 3 << ListRange(13, 15+4);
- QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 4*20.0 << 3*20.0
- << 1 << 10 << 5 << ListRange(6, 14) + ListRange(15, 15+4);
- QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 4*20.0 << 4*20.0
- << 0 << 10 << 5 << ListRange(5, 14) + ListRange(15, 15+4);
-
- QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0
- << 1 << 10 << 1 << ListRange(2, 10);
- QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0
- << 0 << 10 << 1 << ListRange(1, 10);
- QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0
- << 0+4 << 10+4 << 1 << ListRange(1+4, 10+4);
- QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0
- << 10 << 15 << 1 << ListRange(11, 15);
- QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0
- << 0 << 15 << 1 << ListRange(1, 15);
-
- QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0
- << 1 << 10 << 3 << ListRange(4, 12);
- QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0
- << 0 << 10 << 3 << ListRange(3, 12);
- QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0
- << 0+4 << 10+4 << 3 << ListRange(3+4, 12+4);
- QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0
- << 5 << 13 << 3 << ListRange(8, 15);
- QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0
- << 0 << 13 << 3 << ListRange(3, 15);
-
- QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0
- << 10 << 1 << 1 << ListRange(1, 9);
- QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0
- << 10 << 0 << 1 << ListRange(0, 9);
- QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0
- << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4);
- QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 4*20.0 - 10 << 0.0
- << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4);
- QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0
- << 15 << 10 << 1 << ListRange(10, 14);
- QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0
- << 15 << 0 << 1 << ListRange(0, 14);
-
- QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0
- << 10 << 1 << 3 << ListRange(1, 9);
- QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0
- << 10 << 0 << 3 << ListRange(0, 9);
- QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0
- << 10+4 << 0+4 << 3 << ListRange(0+4, 9+4);
- QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0
- << 13 << 5 << 3 << ListRange(5, 12);
- QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0
- << 13 << 0 << 3 << ListRange(0, 12);
-
- QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0
- << 20 << 0 << 1 << ListRange(0, 15);
- QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0
- << 25 << 4 << 1 << ListRange(0+4, 15+4);
- QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0
- << 20 << 0 << 3 << ListRange(0, 15);
- QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0
- << 25 << 4 << 3 << ListRange(0+4, 15+4);
-
- QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0
- << 20 << 15 << 1 << ListRange(15, 15);
- QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0
- << 25 << 15+4 << 1 << ListRange(15+4, 15+4);
- QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0
- << 20 << 15 << 3 << ListRange(15, 15);
- QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0
- << 25 << 15+4 << 3 << ListRange(15+4, 15+4);
-}
-
-void tst_QQuickListView::removeTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(bool, shouldAnimateTargets);
- QFETCH(qreal, contentY);
- QFETCH(int, removalIndex);
- QFETCH(int, removalCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // added items should end here
- QPointF targetItems_transitionTo(-50, -50);
-
- // displaced items should pass through this points
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionTo;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(testFileUrl("removeTransitions.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // only target items that are visible should be animated
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- if (shouldAnimateTargets) {
- for (int i=removalIndex; i<removalIndex+removalCount; i++) {
- if (i >= contentY / 20 && i < (contentY + listview->height()) / 20) {
- expectedTargetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- }
- QVERIFY(expectedTargetData.count() > 0);
- }
-
- // calculate targetItems and expectedTargets before model changes
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
- QVariantMap expectedTargets;
- for (int i=0; i<targetIndexes.count(); i++)
- expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
-
- // start animation
- model.removeItems(removalIndex, removalCount);
- QTRY_COMPARE(model.count(), listview->count());
-
- if (shouldAnimateTargets) {
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- // check the target and displaced items were animated
- model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- QCOMPARE(listview->property("targetTrans_items").toMap(), expectedTargets);
- matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount);
- matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
- }
- } else {
- QTRY_COMPARE(model_targetItems_transitionTo.count(), 0);
- QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- int itemCount = items.count();
-
- for (int i=0; i<items.count(); i++) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- int index = e.evaluate().toInt();
- if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
- firstVisibleIndex = index;
- if (index < 0)
- itemCount--; // exclude deleted items
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), contentY + (i-firstVisibleIndex) * 20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::removeTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<bool>("shouldAnimateTargets");
- QTest::addColumn<int>("removalIndex");
- QTest::addColumn<int>("removalCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // All items that are visible following the remove operation should be animated.
- // Remove targets that are outside of the view should not be animated.
-
- QTest::newRow("remove 1 before start")
- << 30 << 20.0 * 3 << false
- << 2 << 1 << ListRange();
- QTest::newRow("remove multiple, all before start")
- << 30 << 20.0 * 3 << false
- << 0 << 3 << ListRange();
- QTest::newRow("remove mix of before and after start")
- << 30 << 20.0 * 3 << true
- << 2 << 3 << ListRange(5, 20); // 5-20 are visible after the remove
-
- QTest::newRow("remove 1 from start")
- << 30 << 0.0 << true
- << 0 << 1 << ListRange(1, 16); // 1-16 are visible after the remove
- QTest::newRow("remove multiple from start")
- << 30 << 0.0 << true
- << 0 << 3 << ListRange(3, 18); // 3-18 are visible after the remove
- QTest::newRow("remove 1 from start, content y not 0")
- << 30 << 20.0 * 2 << true // first visible is index 2, so translate the displaced indexes by 2
- << 2 << 1 << ListRange(1 + 2, 16 + 2);
- QTest::newRow("remove multiple from start, content y not 0")
- << 30 << 20.0 * 2 << true // first visible is index 2
- << 2 << 3 << ListRange(3 + 2, 18 + 2);
-
- QTest::newRow("remove 1 from middle")
- << 30 << 0.0 << true
- << 5 << 1 << ListRange(6, 16);
- QTest::newRow("remove multiple from middle")
- << 30 << 0.0 << true
- << 5 << 3 << ListRange(8, 18);
-
-
- QTest::newRow("remove 1 from bottom")
- << 30 << 0.0 << true
- << 15 << 1 << ListRange(16, 16);
-
- // remove 15, 16, 17
- // 15 will animate as the target item, 16 & 17 won't be animated since they are outside
- // the view, and 18 will be animated as the displaced item to replace the last item
- QTest::newRow("remove multiple from bottom")
- << 30 << 0.0 << true
- << 15 << 3 << ListRange(18, 18);
-
- QTest::newRow("remove 1 from bottom, content y not 0")
- << 30 << 20.0 * 2 << true
- << 15 + 2 << 1 << ListRange(16 + 2, 16 + 2);
- QTest::newRow("remove multiple from bottom, content y not 0")
- << 30 << 20.0 * 2 << true
- << 15 + 2 << 3 << ListRange(18 + 2, 18 + 2);
-
-
- QTest::newRow("remove 1 after end")
- << 30 << 0.0 << false
- << 17 << 1 << ListRange();
- QTest::newRow("remove multiple after end")
- << 30 << 0.0 << false
- << 17 << 3 << ListRange();
-}
-
-void tst_QQuickListView::displacedTransitions()
-{
- QFETCH(bool, useDisplaced);
- QFETCH(bool, displacedEnabled);
- QFETCH(bool, useAddDisplaced);
- QFETCH(bool, addDisplacedEnabled);
- QFETCH(bool, useMoveDisplaced);
- QFETCH(bool, moveDisplacedEnabled);
- QFETCH(bool, useRemoveDisplaced);
- QFETCH(bool, removeDisplacedEnabled);
- QFETCH(ListChange, change);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_displaced_transitionVia;
- QaimModel model_addDisplaced_transitionVia;
- QaimModel model_moveDisplaced_transitionVia;
- QaimModel model_removeDisplaced_transitionVia;
-
- QPointF displaced_transitionVia(-50, -100);
- QPointF addDisplaced_transitionVia(-150, 100);
- QPointF moveDisplaced_transitionVia(50, -100);
- QPointF removeDisplaced_transitionVia(150, 100);
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject(canvas);
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testObject", testObject);
- ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia);
- ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia);
- ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia);
- ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia);
- ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia);
- ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia);
- ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia);
- ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia);
- ctxt->setContextProperty("useDisplaced", useDisplaced);
- ctxt->setContextProperty("displacedEnabled", displacedEnabled);
- ctxt->setContextProperty("useAddDisplaced", useAddDisplaced);
- ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled);
- ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced);
- ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled);
- ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced);
- ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled);
- canvas->setSource(testFileUrl("displacedTransitions.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
- listview->setProperty("displaceTransitionsDone", false);
-
- switch (change.type) {
- case ListChange::Inserted:
- {
- QList<QPair<QString, QString> > targetItemData;
- for (int i=change.index; i<change.index + change.count; ++i)
- targetItemData << qMakePair(QString("new item %1").arg(i), QString::number(i));
- model.insertItems(change.index, targetItemData);
- QTRY_COMPARE(model.count(), listview->count());
- break;
- }
- case ListChange::Removed:
- model.removeItems(change.index, change.count);
- QTRY_COMPARE(model.count(), listview->count());
- break;
- case ListChange::Moved:
- model.moveItems(change.index, change.to, change.count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- case ListChange::SetCurrent:
- case ListChange::SetContentY:
- break;
- }
- if ((useDisplaced && displacedEnabled)
- || (useAddDisplaced && addDisplacedEnabled)
- || (useMoveDisplaced && moveDisplacedEnabled)
- || (useRemoveDisplaced && removeDisplacedEnabled)) {
- QTRY_VERIFY(listview->property("displaceTransitionsDone").toBool());
- }
-
- if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled)
- model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced");
- else
- QCOMPARE(model_addDisplaced_transitionVia.count(), 0);
- if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled)
- model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced");
- else
- QCOMPARE(model_moveDisplaced_transitionVia.count(), 0);
- if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled)
- model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced");
- else
- QCOMPARE(model_removeDisplaced_transitionVia.count(), 0);
-
- if (useDisplaced && displacedEnabled
- && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled))
- || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled))
- || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) {
- model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced");
- } else {
- QCOMPARE(model_displaced_transitionVia.count(), 0);
- }
-
- // verify all items moved to the correct final positions
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i < model.count() && i < items.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), i * 20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::displacedTransitions_data()
-{
- QTest::addColumn<bool>("useDisplaced");
- QTest::addColumn<bool>("displacedEnabled");
- QTest::addColumn<bool>("useAddDisplaced");
- QTest::addColumn<bool>("addDisplacedEnabled");
- QTest::addColumn<bool>("useMoveDisplaced");
- QTest::addColumn<bool>("moveDisplacedEnabled");
- QTest::addColumn<bool>("useRemoveDisplaced");
- QTest::addColumn<bool>("removeDisplacedEnabled");
- QTest::addColumn<ListChange>("change");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- QTest::newRow("no displaced transitions at all")
- << false << false
- << false << false
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 15);
-
- QTest::newRow("just displaced")
- << true << true
- << false << false
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 15);
-
- QTest::newRow("just displaced (not enabled)")
- << true << false
- << false << false
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 15);
-
- QTest::newRow("displaced + addDisplaced")
- << true << true
- << true << true
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 15);
-
- QTest::newRow("displaced + addDisplaced (not enabled)")
- << true << true
- << true << false
- << false << false
- << false << false
- << ListChange::insert(0, 1) << ListRange(0, 15);
-
- QTest::newRow("displaced + moveDisplaced")
- << true << true
- << false << false
- << true << true
- << false << false
- << ListChange::move(0, 10, 1) << ListRange(1, 10);
-
- QTest::newRow("displaced + moveDisplaced (not enabled)")
- << true << true
- << false << false
- << true << false
- << false << false
- << ListChange::move(0, 10, 1) << ListRange(1, 10);
-
- QTest::newRow("displaced + removeDisplaced")
- << true << true
- << false << false
- << false << false
- << true << true
- << ListChange::remove(0, 1) << ListRange(1, 16);
-
- QTest::newRow("displaced + removeDisplaced (not enabled)")
- << true << true
- << false << false
- << false << false
- << true << false
- << ListChange::remove(0, 1) << ListRange(1, 16);
-
-
- QTest::newRow("displaced + add, should use generic displaced for a remove")
- << true << true
- << true << true
- << false << false
- << true << false
- << ListChange::remove(0, 1) << ListRange(1, 16);
-}
-
-void tst_QQuickListView::multipleTransitions()
-{
- QSKIP("QTBUG-24523");
-
- // Tests that if you interrupt a transition in progress with another action that
- // cancels the previous transition, the resulting items are still placed correctly.
-
- QFETCH(int, initialCount);
- QFETCH(qreal, contentY);
- QFETCH(QList<ListChange>, changes);
- QFETCH(bool, rippleAddDisplaced);
-
- QPointF addTargets_transitionFrom(-50, -50);
- QPointF addDisplaced_transitionFrom(-50, 50);
- QPointF moveTargets_transitionFrom(50, -50);
- QPointF moveDisplaced_transitionFrom(50, 50);
- QPointF removeTargets_transitionTo(-100, 300);
- QPointF removeDisplaced_transitionFrom(100, 300);
-
- QmlListModel model;
- for (int i = 0; i < initialCount; i++)
- model.addItem("Original item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testObject", testObject);
- ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
- ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
- ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
- ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
- ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo);
- ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom);
- ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced);
- canvas->setSource(testFileUrl("multipleTransitions.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
-
- QList<QPair<QString, QString> > targetItems;
- for (int i=0; i<changes.count(); i++) {
- switch (changes[i].type) {
- case ListChange::Inserted:
- {
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
- model.insertItems(changes[i].index, targetItems);
- QTRY_COMPARE(model.count(), listview->count());
- QTRY_VERIFY(listview->property("runningAddTargets").toBool());
- QTRY_VERIFY(listview->property("runningAddDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!listview->property("runningAddTargets").toBool());
- QTRY_VERIFY(!listview->property("runningAddDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- }
- case ListChange::Removed:
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(model.name(i), model.number(i));
- model.removeItems(changes[i].index, changes[i].count);
- QTRY_COMPARE(model.count(), listview->count());
- QTRY_VERIFY(listview->property("runningRemoveTargets").toBool());
- QTRY_VERIFY(listview->property("runningRemoveDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!listview->property("runningRemoveTargets").toBool());
- QTRY_VERIFY(!listview->property("runningRemoveDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- case ListChange::Moved:
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(model.name(i), model.number(i));
- model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_VERIFY(listview->property("runningMoveTargets").toBool());
- QTRY_VERIFY(listview->property("runningMoveDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!listview->property("runningMoveTargets").toBool());
- QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- case ListChange::SetCurrent:
- listview->setCurrentIndex(changes[i].index);
- break;
- case ListChange::SetContentY:
- listview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- }
- }
- QCOMPARE(listview->count(), model.count());
-
- // verify all items moved to the correct final positions
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i < model.count() && i < items.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->x(), 0.0);
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::multipleTransitions_data()
-{
- QTest::addColumn<int>("initialCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<QList<ListChange> >("changes");
- QTest::addColumn<bool>("rippleAddDisplaced");
-
- // the added item and displaced items should move to final dest correctly
- QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::move(0, 3, 1)
- )
- << false;
-
- // items affected by the add should change from move to add transition
- QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::move(1, 10, 3)
- << ListChange::insert(0, 1)
- )
- << false;
-
- // items should be placed correctly if you trigger a transition then refill for that index
- QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::setContentY(80.0)
- << ListChange::setContentY(0.0)
- << ListChange::insert(0, 1)
- )
- << false;
-
- QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::insert(1, 1)
- << ListChange::remove(1, 1)
- )
- << true;
-}
-
-QList<int> tst_QQuickListView::toIntList(const QVariantList &list)
-{
- QList<int> ret;
- bool ok = true;
- for (int i=0; i<list.count(); i++) {
- ret << list[i].toInt(&ok);
- if (!ok)
- qWarning() << "tst_QQuickListView::toIntList(): not a number:" << list[i];
- }
-
- return ret;
-}
-
-void tst_QQuickListView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
-{
- for (int i=0; i<indexLists.count(); i++) {
- QSet<int> current = indexLists[i].value<QList<int> >().toSet();
- if (current != expectedIndexes.toSet())
- qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
- QCOMPARE(current, expectedIndexes.toSet());
- }
-}
-
-void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
-{
- for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
- QVERIFY(it.value().type() == QVariant::Int);
- QString name = it.key();
- int itemIndex = it.value().toInt();
- QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
- if (model.name(itemIndex) != name)
- qDebug() << itemIndex;
- QCOMPARE(model.name(itemIndex), name);
- }
- QCOMPARE(items.count(), expectedIndexes.count());
-}
-
-void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
-{
- for (int i=0; i<itemLists.count(); i++) {
- QVERIFY(itemLists[i].type() == QVariant::List);
- QVariantList current = itemLists[i].toList();
- for (int j=0; j<current.count(); j++) {
- QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
- QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
- QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
- }
- QCOMPARE(current.count(), expectedItems.count());
- }
-}
-
-
-QTEST_MAIN(tst_QQuickListView)
-
-#include "tst_qquicklistview.moc"
-
diff --git a/tests/auto/qtquick2/qquickloader/qquickloader.pro b/tests/auto/qtquick2/qquickloader/qquickloader.pro
deleted file mode 100644
index 33c8c207af..0000000000
--- a/tests/auto/qtquick2/qquickloader/qquickloader.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickloader
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-
-SOURCES += tst_qquickloader.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp b/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp
deleted file mode 100644
index 33148db7b1..0000000000
--- a/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp
+++ /dev/null
@@ -1,987 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-
-#include <QSignalSpy>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <private/qquickloader_p.h>
-#include "testhttpserver.h"
-#include "../../shared/util.h"
-
-#define SERVER_PORT 14450
-
-class PeriodicIncubationController : public QObject,
- public QDeclarativeIncubationController
-{
-public:
- PeriodicIncubationController() {
- startTimer(16);
- }
-
-protected:
- virtual void timerEvent(QTimerEvent *) {
- incubateFor(15);
- }
-};
-
-class tst_QQuickLoader : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_QQuickLoader();
-
-private slots:
- void sourceOrComponent();
- void sourceOrComponent_data();
- void clear();
- void urlToComponent();
- void componentToUrl();
- void anchoredLoader();
- void sizeLoaderToItem();
- void sizeItemToLoader();
- void noResize();
- void networkRequestUrl();
- void failNetworkRequest();
-// void networkComponent();
- void active();
- void initialPropertyValues_data();
- void initialPropertyValues();
- void initialPropertyValuesBinding();
- void initialPropertyValuesError_data();
- void initialPropertyValuesError();
-
- void deleteComponentCrash();
- void nonItem();
- void vmeErrors();
- void creationContext();
- void QTBUG_16928();
- void implicitSize();
- void QTBUG_17114();
- void asynchronous_data();
- void asynchronous();
- void asynchronous_clear();
-
- void parented();
- void sizeBound();
-
-private:
- QDeclarativeEngine engine;
-};
-
-
-tst_QQuickLoader::tst_QQuickLoader()
-{
-}
-
-void tst_QQuickLoader::sourceOrComponent()
-{
- QFETCH(QString, sourceOrComponent);
- QFETCH(QString, sourceDefinition);
- QFETCH(QUrl, sourceUrl);
- QFETCH(QString, errorString);
-
- bool error = !errorString.isEmpty();
- if (error)
- QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData());
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 2.0\n"
- "Loader {\n"
- " property int onItemChangedCount: 0\n"
- " property int onSourceChangedCount: 0\n"
- " property int onSourceComponentChangedCount: 0\n"
- " property int onStatusChangedCount: 0\n"
- " property int onProgressChangedCount: 0\n"
- " property int onLoadedCount: 0\n")
- + sourceDefinition.toUtf8()
- + QByteArray(
- " onItemChanged: onItemChangedCount += 1\n"
- " onSourceChanged: onSourceChangedCount += 1\n"
- " onSourceComponentChanged: onSourceComponentChangedCount += 1\n"
- " onStatusChanged: onStatusChangedCount += 1\n"
- " onProgressChanged: onProgressChangedCount += 1\n"
- " onLoaded: onLoadedCount += 1\n"
- "}")
- , dataDirectoryUrl());
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->item() == 0, error);
- QCOMPARE(loader->source(), sourceUrl);
- QCOMPARE(loader->progress(), 1.0);
-
- QCOMPARE(loader->status(), error ? QQuickLoader::Error : QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), error ? 0: 1);
-
- if (!error) {
- bool sourceComponentIsChildOfLoader = false;
- for (int ii = 0; ii < loader->children().size(); ++ii) {
- QDeclarativeComponent *c = qobject_cast<QDeclarativeComponent*>(loader->children().at(ii));
- if (c && c == loader->sourceComponent()) {
- sourceComponentIsChildOfLoader = true;
- }
- }
- QVERIFY(sourceComponentIsChildOfLoader);
- }
-
- if (sourceOrComponent == "component") {
- QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 1);
- QCOMPARE(loader->property("onSourceChangedCount").toInt(), 0);
- } else {
- QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 0);
- QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1);
- }
- QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1);
- QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1);
-
- QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1);
- QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1);
-
- delete loader;
-}
-
-void tst_QQuickLoader::sourceOrComponent_data()
-{
- QTest::addColumn<QString>("sourceOrComponent");
- QTest::addColumn<QString>("sourceDefinition");
- QTest::addColumn<QUrl>("sourceUrl");
- QTest::addColumn<QString>("errorString");
-
- QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << "";
- QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
- QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml")
- << QString(testFileUrl("IDontExist.qml").toString() + ": File not found");
-}
-
-void tst_QQuickLoader::clear()
-{
- {
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 2.0\n"
- " Loader { id: loader\n"
- " source: 'Rect120x60.qml'\n"
- " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
- " }")
- , dataDirectoryUrl());
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- QTRY_VERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- delete loader;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- loader->setSourceComponent(0);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- delete item;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- QMetaObject::invokeMethod(item, "clear");
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- delete item;
- }
-}
-
-void tst_QQuickLoader::urlToComponent()
-{
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\n"
- "Loader {\n"
- " id: loader\n"
- " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n"
- " source: \"Rect120x60.qml\"\n"
- " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n"
- "}" )
- , dataDirectoryUrl());
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QTest::qWait(200);
- QTRY_VERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QCOMPARE(loader->width(), 10.0);
- QCOMPARE(loader->height(), 10.0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::componentToUrl()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- loader->setSource(testFileUrl("/Rect120x60.qml"));
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- delete item;
-}
-
-void tst_QQuickLoader::anchoredLoader()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/AnchoredLoader.qml"));
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(rootItem != 0);
- QQuickItem *loader = rootItem->findChild<QQuickItem*>("loader");
- QQuickItem *sourceElement = rootItem->findChild<QQuickItem*>("sourceElement");
-
- QVERIFY(loader != 0);
- QVERIFY(sourceElement != 0);
-
- QCOMPARE(rootItem->width(), 300.0);
- QCOMPARE(rootItem->height(), 200.0);
-
- QCOMPARE(loader->width(), 300.0);
- QCOMPARE(loader->height(), 200.0);
-
- QCOMPARE(sourceElement->width(), 300.0);
- QCOMPARE(sourceElement->height(), 200.0);
-}
-
-void tst_QQuickLoader::sizeLoaderToItem()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/SizeToItem.qml"));
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- // Check resize
- QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item());
- QVERIFY(rect);
- rect->setWidth(150);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 150.0);
- QCOMPARE(loader->height(), 45.0);
-
- // Check explicit width
- loader->setWidth(200.0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(rect->width(), 200.0);
- rect->setWidth(100.0); // when rect changes ...
- QCOMPARE(rect->width(), 100.0); // ... it changes
- QCOMPARE(loader->width(), 200.0); // ... but loader stays the same
-
- // Check explicit height
- loader->setHeight(200.0);
- QCOMPARE(loader->height(), 200.0);
- QCOMPARE(rect->height(), 200.0);
- rect->setHeight(100.0); // when rect changes ...
- QCOMPARE(rect->height(), 100.0); // ... it changes
- QCOMPARE(loader->height(), 200.0); // ... but loader stays the same
-
- // Switch mode
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::sizeItemToLoader()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/SizeToLoader.qml"));
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item());
- QVERIFY(rect);
- QCOMPARE(rect->width(), 200.0);
- QCOMPARE(rect->height(), 80.0);
-
- // Check resize
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- // Switch mode
- loader->resetWidth(); // reset explicit size
- loader->resetHeight();
- rect->setWidth(160);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 160.0);
- QCOMPARE(loader->height(), 45.0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::noResize()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/NoResize.qml"));
- QQuickItem* item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item != 0);
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 80.0);
-
- delete item;
-}
-
-void tst_QQuickLoader::networkRequestUrl()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml"));
- if (component.isError())
- qDebug() << component.errors();
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
-
- QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->property("signalCount").toInt(), 1);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- delete loader;
-}
-
-/* XXX Component waits until all dependencies are loaded. Is this actually possible?
-void tst_QQuickLoader::networkComponent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory("slowdata", TestHTTPServer::Delay);
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 2.0\n"
- "import \"http://127.0.0.1:14450/\" as NW\n"
- "Item {\n"
- " Component { id: comp; NW.SlowRect {} }\n"
- " Loader { sourceComponent: comp } }")
- , dataDirectoryUrl());
-
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::children().at(1));
- QVERIFY(loader);
- QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-*/
-
-void tst_QQuickLoader::failNetworkRequest()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml"));
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
-
- QTRY_VERIFY(loader->status() == QQuickLoader::Error);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->property("did_load").toInt(), 123);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::active()
-{
- // check that the item isn't instantiated until active is set to true
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == false); // set manually to false
- QVERIFY(loader->item() == 0);
- QMetaObject::invokeMethod(object, "doSetSourceComponent");
- QVERIFY(loader->item() == 0);
- QMetaObject::invokeMethod(object, "doSetSource");
- QVERIFY(loader->item() == 0);
- QMetaObject::invokeMethod(object, "doSetActive");
- QVERIFY(loader->item() != 0);
-
- delete object;
- }
-
- // check that the status is Null if active is set to false
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- int currStatusChangedCount = loader->property("statusChangedCount").toInt();
- QMetaObject::invokeMethod(object, "doSetInactive");
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(loader->property("statusChangedCount").toInt(), (currStatusChangedCount+1));
-
- delete object;
- }
-
- // check that the source is not cleared if active is set to false
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- QVERIFY(!loader->source().isEmpty());
- int currSourceChangedCount = loader->property("sourceChangedCount").toInt();
- QMetaObject::invokeMethod(object, "doSetInactive");
- QVERIFY(!loader->source().isEmpty());
- QCOMPARE(loader->property("sourceChangedCount").toInt(), currSourceChangedCount);
-
- delete object;
- }
-
- // check that the sourceComponent is not cleared if active is set to false
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- QVERIFY(loader->sourceComponent() != 0);
- int currSourceComponentChangedCount = loader->property("sourceComponentChangedCount").toInt();
- QMetaObject::invokeMethod(object, "doSetInactive");
- QVERIFY(loader->sourceComponent() != 0);
- QCOMPARE(loader->property("sourceComponentChangedCount").toInt(), currSourceComponentChangedCount);
-
- delete object;
- }
-
- // check that the item is released if active is set to false
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- QVERIFY(loader->item() != 0);
- int currItemChangedCount = loader->property("itemChangedCount").toInt();
- QMetaObject::invokeMethod(object, "doSetInactive");
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->property("itemChangedCount").toInt(), (currItemChangedCount+1));
-
- delete object;
- }
-
- // check that the activeChanged signal is emitted correctly
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.6.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- loader->setActive(true); // no effect
- QCOMPARE(loader->property("activeChangedCount").toInt(), 0);
- loader->setActive(false); // change signal should be emitted
- QCOMPARE(loader->property("activeChangedCount").toInt(), 1);
- loader->setActive(false); // no effect
- QCOMPARE(loader->property("activeChangedCount").toInt(), 1);
- loader->setActive(true); // change signal should be emitted
- QCOMPARE(loader->property("activeChangedCount").toInt(), 2);
- loader->setActive(false); // change signal should be emitted
- QCOMPARE(loader->property("activeChangedCount").toInt(), 3);
- QMetaObject::invokeMethod(object, "doSetActive");
- QCOMPARE(loader->property("activeChangedCount").toInt(), 4);
- QMetaObject::invokeMethod(object, "doSetActive");
- QCOMPARE(loader->property("activeChangedCount").toInt(), 4);
- QMetaObject::invokeMethod(object, "doSetInactive");
- QCOMPARE(loader->property("activeChangedCount").toInt(), 5);
- loader->setActive(true); // change signal should be emitted
- QCOMPARE(loader->property("activeChangedCount").toInt(), 6);
-
- delete object;
- }
-
- // check that the component isn't loaded until active is set to true
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.7.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("success").toBool(), true);
- delete object;
- }
-
- // check that the component is loaded if active is not set (true by default)
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.8.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("success").toBool(), true);
- delete object;
- }
-}
-
-void tst_QQuickLoader::initialPropertyValues_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<QStringList>("expectedWarnings");
- QTest::addColumn<QStringList>("propertyNames");
- QTest::addColumn<QVariantList>("propertyValues");
-
- QTest::newRow("source url with value set in onLoaded, initially active = true") << testFileUrl("initialPropertyValues.1.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 1 << 1);
-
- QTest::newRow("set source with initial property values specified, active = true") << testFileUrl("initialPropertyValues.2.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 2 << 0);
-
- QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml")
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null")))
- << (QStringList())
- << (QVariantList());
-
- QTest::newRow("set source with initial property values specified, active = false, with active set true later") << testFileUrl("initialPropertyValues.4.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 4 << 0);
-
- QTest::newRow("set source without initial property values specified, active = true") << testFileUrl("initialPropertyValues.5.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 0 << 0);
-
- QTest::newRow("set source with initial property values specified with binding, active = true") << testFileUrl("initialPropertyValues.6.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 6 << 0);
-
- QTest::newRow("ensure initial property value semantics mimic createObject") << testFileUrl("initialPropertyValues.7.qml")
- << QStringList()
- << (QStringList() << "loaderValue" << "createObjectValue")
- << (QVariantList() << 1 << 1);
-
- QTest::newRow("ensure initial property values aren't disposed prior to component completion") << testFileUrl("initialPropertyValues.8.qml")
- << QStringList()
- << (QStringList() << "initialValue")
- << (QVariantList() << 6);
-}
-
-void tst_QQuickLoader::initialPropertyValues()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(QStringList, expectedWarnings);
- QFETCH(QStringList, propertyNames);
- QFETCH(QVariantList, propertyValues);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- foreach (const QString &warning, expectedWarnings)
- QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
-
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- qApp->processEvents();
- QTest::qWait(50);
-
- for (int i = 0; i < propertyNames.size(); ++i)
- QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i));
-
- delete object;
-}
-
-void tst_QQuickLoader::initialPropertyValuesBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("initialPropertyValues.binding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->setProperty("bindable", QVariant(8)));
- QCOMPARE(object->property("canaryValue").toInt(), 8);
-
- delete object;
-}
-
-void tst_QQuickLoader::initialPropertyValuesError_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<QStringList>("expectedWarnings");
-
- QTest::newRow("invalid initial property values object") << testFileUrl("initialPropertyValues.error.1.qml")
- << (QStringList() << QString(testFileUrl("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object"));
-
- QTest::newRow("nonexistent source url") << testFileUrl("initialPropertyValues.error.2.qml")
- << (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": File not found"));
-
- QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml")
- << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
-
- QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml")
- << (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object")
- << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null"));
-}
-
-void tst_QQuickLoader::initialPropertyValuesError()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(QStringList, expectedWarnings);
-
- foreach (const QString &warning, expectedWarnings)
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData());
-
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
- QVERIFY(loader != 0);
- QVERIFY(loader->item() == 0);
- delete object;
-}
-
-// QTBUG-9241
-void tst_QQuickLoader::deleteComponentCrash()
-{
- QDeclarativeComponent component(&engine, testFileUrl("crash.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- item->metaObject()->invokeMethod(item, "setLoaderSource");
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->item()->objectName(), QLatin1String("blue"));
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QVERIFY(loader->source() == testFileUrl("BlueRect.qml"));
-
- delete item;
-}
-
-void tst_QQuickLoader::nonItem()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nonItem.qml"));
- QString err = testFileUrl("nonItem.qml").toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements.";
-
- QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader);
- QVERIFY(loader->item() == 0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::vmeErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("vmeErrors.qml"));
- QString err = testFileUrl("VmeError.qml").toString() + ":6: Cannot assign object type QObject with no default method";
- QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader);
- QVERIFY(loader->item() == 0);
-
- delete loader;
-}
-
-// QTBUG-13481
-void tst_QQuickLoader::creationContext()
-{
- QDeclarativeComponent component(&engine, testFileUrl("creationContext.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
-}
-
-void tst_QQuickLoader::QTBUG_16928()
-{
- QDeclarativeComponent component(&engine, testFileUrl("QTBUG_16928.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->width(), 250.);
- QCOMPARE(item->height(), 250.);
-
- delete item;
-}
-
-void tst_QQuickLoader::implicitSize()
-{
- QDeclarativeComponent component(&engine, testFileUrl("implicitSize.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->width(), 150.);
- QCOMPARE(item->height(), 150.);
-
- QCOMPARE(item->property("implHeight").toReal(), 100.);
- QCOMPARE(item->property("implWidth").toReal(), 100.);
-
- delete item;
-}
-
-void tst_QQuickLoader::QTBUG_17114()
-{
- QDeclarativeComponent component(&engine, testFileUrl("QTBUG_17114.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->property("loaderWidth").toReal(), 32.);
- QCOMPARE(item->property("loaderHeight").toReal(), 32.);
-
- delete item;
-}
-
-void tst_QQuickLoader::asynchronous_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<QStringList>("expectedWarnings");
-
- QTest::newRow("Valid component") << testFileUrl("BigComponent.qml")
- << QStringList();
-
- QTest::newRow("Non-existant component") << testFileUrl("IDoNotExist.qml")
- << (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": File not found"));
-
- QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml")
- << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
-}
-
-void tst_QQuickLoader::asynchronous()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(QStringList, expectedWarnings);
-
- if (!engine.incubationController())
- engine.setIncubationController(new PeriodicIncubationController);
- QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(root);
-
- QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
- QVERIFY(loader);
-
- foreach (const QString &warning, expectedWarnings)
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData());
-
- QVERIFY(!loader->item());
- root->setProperty("comp", qmlFile.toString());
- QMetaObject::invokeMethod(root, "loadComponent");
- QVERIFY(!loader->item());
-
- if (expectedWarnings.isEmpty()) {
- QCOMPARE(loader->status(), QQuickLoader::Loading);
- QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
-
- QTRY_VERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- } else {
- QCOMPARE(loader->progress(), 1.0);
- QTRY_COMPARE(loader->status(), QQuickLoader::Error);
- }
-
- delete root;
-}
-
-void tst_QQuickLoader::asynchronous_clear()
-{
- if (!engine.incubationController())
- engine.setIncubationController(new PeriodicIncubationController);
- QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(root);
-
- QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
- QVERIFY(loader);
-
- QVERIFY(!loader->item());
- root->setProperty("comp", "BigComponent.qml");
- QMetaObject::invokeMethod(root, "loadComponent");
- QVERIFY(!loader->item());
-
- QCOMPARE(loader->status(), QQuickLoader::Loading);
- QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
-
- // clear before component created
- root->setProperty("comp", "");
- QMetaObject::invokeMethod(root, "loadComponent");
- QVERIFY(!loader->item());
- QCOMPARE(engine.incubationController()->incubatingObjectCount(), 0);
-
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- // check loading component
- root->setProperty("comp", "Rect120x60.qml");
- QMetaObject::invokeMethod(root, "loadComponent");
- QVERIFY(!loader->item());
-
- QCOMPARE(loader->status(), QQuickLoader::Loading);
- QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
-
- QTRY_VERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-}
-
-void tst_QQuickLoader::parented()
-{
- QDeclarativeComponent component(&engine, testFileUrl("parented.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(root);
-
- QQuickItem *item = root->findChild<QQuickItem*>("comp");
- QVERIFY(item);
-
- QVERIFY(item->parentItem() == root);
-
- QCOMPARE(item->width(), 300.);
- QCOMPARE(item->height(), 300.);
-
- delete root;
-}
-
-void tst_QQuickLoader::sizeBound()
-{
- QDeclarativeComponent component(&engine, testFileUrl("sizebound.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(root);
- QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
- QVERIFY(loader != 0);
-
- QVERIFY(loader->item());
-
- QCOMPARE(loader->width(), 50.0);
- QCOMPARE(loader->height(), 60.0);
-
- QMetaObject::invokeMethod(root, "switchComponent");
-
- QCOMPARE(loader->width(), 80.0);
- QCOMPARE(loader->height(), 90.0);
-
- delete root;
-}
-
-
-QTEST_MAIN(tst_QQuickLoader)
-
-#include "tst_qquickloader.moc"
diff --git a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro b/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro
deleted file mode 100644
index 67d77dc05a..0000000000
--- a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickmousearea
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickmousearea.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp
deleted file mode 100644
index 66f651329a..0000000000
--- a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp
+++ /dev/null
@@ -1,806 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick/private/qquickmousearea_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qquickflickable_p.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtOpenGL/QGLShaderProgram>
-#include "../../shared/util.h"
-
-//#define OLDWAY
-
-class tst_QQuickMouseArea: public QDeclarativeDataTest
-{
- Q_OBJECT
-private slots:
- void dragProperties();
- void resetDrag();
- void dragging();
- void updateMouseAreaPosOnClick();
- void updateMouseAreaPosOnResize();
- void noOnClickedWithPressAndHold();
- void onMousePressRejected();
- void pressedCanceledOnWindowDeactivate();
- void doubleClick();
- void clickTwice();
- void pressedOrdering();
- void preventStealing();
- void clickThrough();
- void hoverPosition();
- void hoverPropagation();
- void hoverVisible();
-
-private:
- QQuickView *createView();
-};
-
-void tst_QQuickMouseArea::dragProperties()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("dragproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QQuickDrag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
- drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
- drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
-
- // axis
- QCOMPARE(drag->axis(), QQuickDrag::XandYAxis);
- QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
- drag->setAxis(QQuickDrag::XAxis);
- QCOMPARE(drag->axis(), QQuickDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
- drag->setAxis(QQuickDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
-
- // minimum and maximum properties
- QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
- QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged()));
- QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged()));
- QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged()));
-
- QCOMPARE(drag->xmin(), 0.0);
- QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width());
- QCOMPARE(drag->ymin(), 0.0);
- QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height());
-
- drag->setXmin(10);
- drag->setXmax(10);
- drag->setYmin(10);
- drag->setYmax(10);
-
- QCOMPARE(drag->xmin(), 10.0);
- QCOMPARE(drag->xmax(), 10.0);
- QCOMPARE(drag->ymin(), 10.0);
- QCOMPARE(drag->ymax(), 10.0);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- drag->setXmin(10);
- drag->setXmax(10);
- drag->setYmin(10);
- drag->setYmax(10);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- // filterChildren
- QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged()));
-
- drag->setFilterChildren(true);
-
- QVERIFY(drag->filterChildren());
- QCOMPARE(filterChildrenSpy.count(), 1);
-
- drag->setFilterChildren(true);
- QCOMPARE(filterChildrenSpy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::resetDrag()
-{
- QQuickView *canvas = createView();
-
- canvas->rootContext()->setContextProperty("haveTarget", QVariant(true));
- canvas->setSource(testFileUrl("dragreset.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QQuickDrag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
- QVERIFY(drag->target() != 0);
- canvas->rootContext()->setContextProperty("haveTarget", QVariant(false));
- QCOMPARE(targetSpy.count(),1);
- QVERIFY(drag->target() == 0);
-
- delete canvas;
-}
-
-
-void tst_QQuickMouseArea::dragging()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("dragging.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWait(20);
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QQuickDrag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
-
- QVERIFY(!drag->active());
-
-#ifdef OLDWAY
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-#else
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
-#endif
-
- QVERIFY(!drag->active());
- QCOMPARE(blackRect->x(), 50.0);
- QCOMPARE(blackRect->y(), 50.0);
-
- // First move event triggers drag, second is acted upon.
- // This is due to possibility of higher stacked area taking precedence.
-
- QTest::mouseMove(canvas, QPoint(111,111));
- QTest::qWait(50);
- QTest::mouseMove(canvas, QPoint(122,122));
- QTest::qWait(50);
-
- QVERIFY(drag->active());
- QCOMPARE(blackRect->x(), 72.0);
- QCOMPARE(blackRect->y(), 72.0);
-
-#ifdef OLDWAY
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-#else
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(122,122));
- QTest::qWait(50);
-#endif
-
- QVERIFY(!drag->active());
- QCOMPARE(blackRect->x(), 72.0);
- QCOMPARE(blackRect->y(), 72.0);
-
- delete canvas;
-}
-
-QQuickView *tst_QQuickMouseArea::createView()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- return canvas;
-}
-
-void tst_QQuickMouseArea::updateMouseAreaPosOnClick()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("updateMousePosOnClick.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QVERIFY(mouseRegion != 0);
-
- QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("ball");
- QVERIFY(rect != 0);
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- QMouseEvent event(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &event);
-
- QCOMPARE(mouseRegion->mouseX(), 100.0);
- QCOMPARE(mouseRegion->mouseY(), 100.0);
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::updateMouseAreaPosOnResize()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("updateMousePosOnResize.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QVERIFY(mouseRegion != 0);
-
- QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("brother");
- QVERIFY(rect != 0);
-
- QCOMPARE(mouseRegion->mouseX(), 0.0);
- QCOMPARE(mouseRegion->mouseY(), 0.0);
-
- QMouseEvent event(QEvent::MouseButtonPress, rect->pos().toPoint(), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &event);
-
- QVERIFY(!mouseRegion->property("emitPositionChanged").toBool());
- QVERIFY(mouseRegion->property("mouseMatchesPos").toBool());
-
- QCOMPARE(mouseRegion->property("x1").toReal(), 0.0);
- QCOMPARE(mouseRegion->property("y1").toReal(), 0.0);
-
- QCOMPARE(mouseRegion->property("x2").toReal(), rect->x());
- QCOMPARE(mouseRegion->property("y2").toReal(), rect->y());
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::noOnClickedWithPressAndHold()
-{
- {
- // We handle onPressAndHold, therefore no onClicked
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("clickandhold.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QVERIFY(!canvas->rootObject()->property("clicked").toBool());
- QVERIFY(!canvas->rootObject()->property("held").toBool());
-
- QTest::qWait(1000);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QVERIFY(!canvas->rootObject()->property("clicked").toBool());
- QVERIFY(canvas->rootObject()->property("held").toBool());
-
- delete canvas;
- }
-
- {
- // We do not handle onPressAndHold, therefore we get onClicked
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("noclickandhold.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QVERIFY(!canvas->rootObject()->property("clicked").toBool());
-
- QTest::qWait(1000);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QVERIFY(canvas->rootObject()->property("clicked").toBool());
-
- delete canvas;
- }
-}
-
-void tst_QQuickMouseArea::onMousePressRejected()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("rejectEvent.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
- QVERIFY(canvas->rootObject()->property("enabled").toBool());
-
- QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool());
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
- QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool());
-
- QTest::qWait(200);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QVERIFY(canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
-
- delete canvas;
-}
-void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pressedCanceled.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
- QVERIFY(!canvas->rootObject()->property("pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("released").toBool());
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QVERIFY(canvas->rootObject()->property("pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("released").toBool());
-
- QTest::qWait(200);
-
- QEvent windowDeactivateEvent(QEvent::WindowDeactivate);
- QGuiApplication::sendEvent(canvas, &windowDeactivateEvent);
- QVERIFY(!canvas->rootObject()->property("pressed").toBool());
- QVERIFY(canvas->rootObject()->property("canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("released").toBool());
-
- QTest::qWait(200);
-
- //press again
- QGuiApplication::sendEvent(canvas, &pressEvent);
- QVERIFY(canvas->rootObject()->property("pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("released").toBool());
-
- QTest::qWait(200);
-
- //release
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
- QVERIFY(!canvas->rootObject()->property("pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("canceled").toBool());
- QVERIFY(canvas->rootObject()->property("released").toBool());
-
- delete canvas;
-}
-void tst_QQuickMouseArea::doubleClick()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("doubleclick.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
-
- pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
-
- delete canvas;
-}
-
-// QTBUG-14832
-void tst_QQuickMouseArea::clickTwice()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("clicktwice.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
-
- pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QGuiApplication::sendEvent(canvas, &pressEvent);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2);
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::pressedOrdering()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pressedOrdering.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base"));
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled"));
-
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::preventStealing()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("preventstealing.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- QQuickMouseArea *mouseArea = canvas->rootObject()->findChild<QQuickMouseArea*>("mousearea");
- QVERIFY(mouseArea != 0);
-
- QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QQuickMouseEvent*)));
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80));
-
- // Without preventStealing, mouse movement over MouseArea would
- // cause the Flickable to steal mouse and trigger content movement.
-
- QTest::mouseMove(canvas,QPoint(69,69));
- QTest::mouseMove(canvas,QPoint(58,58));
- QTest::mouseMove(canvas,QPoint(47,47));
-
- // We should have received all three move events
- QCOMPARE(mousePositionSpy.count(), 3);
- QVERIFY(mouseArea->pressed());
-
- // Flickable content should not have moved.
- QCOMPARE(flickable->contentX(), 0.);
- QCOMPARE(flickable->contentY(), 0.);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(47, 47));
-
- // Now allow stealing and confirm Flickable does its thing.
- canvas->rootObject()->setProperty("stealing", false);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80));
-
- // Without preventStealing, mouse movement over MouseArea would
- // cause the Flickable to steal mouse and trigger content movement.
-
- QTest::mouseMove(canvas,QPoint(69,69));
- QTest::mouseMove(canvas,QPoint(58,58));
- QTest::mouseMove(canvas,QPoint(47,47));
-
- // We should only have received the first move event
- QCOMPARE(mousePositionSpy.count(), 4);
- // Our press should be taken away
- QVERIFY(!mouseArea->pressed());
-
- // Flickable content should have moved.
-
- QCOMPARE(flickable->contentX(), 11.);
- QCOMPARE(flickable->contentY(), 11.);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 50));
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::clickThrough()
-{
- QSKIP("QTBUG-23976 Unstable");
- //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("clickThrough.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
-
- QTest::qWait(800); // to avoid generating a double click.
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(1000);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
- QTRY_COMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
- QTRY_COMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- delete canvas;
-
- //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored
- canvas = createView();
- canvas->setSource(testFileUrl("clickThrough2.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
-
- QTest::qWait(800); // to avoid generating a double click.
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(1000);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0);
-
- QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0);
-
- canvas->rootObject()->setProperty("letThrough", QVariant(true));
-
- QTest::qWait(800); // to avoid generating a double click.
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
-
- QTest::qWait(800); // to avoid generating a double click.
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(1000);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- canvas->rootObject()->setProperty("noPropagation", QVariant(true));
-
- QTest::qWait(800); // to avoid generating a double click.
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QTest::qWait(800); // to avoid generating a double click.
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(1000);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::hoverPosition()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("hoverPosition.qml"));
-
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
-
- QCOMPARE(root->property("mouseX").toReal(), qreal(0));
- QCOMPARE(root->property("mouseY").toReal(), qreal(0));
-
- QTest::mouseMove(canvas,QPoint(10,32));
-
-
- QCOMPARE(root->property("mouseX").toReal(), qreal(10));
- QCOMPARE(root->property("mouseY").toReal(), qreal(32));
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::hoverPropagation()
-{
- //QTBUG-18175, to behave like GV did.
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("hoverPropagation.qml"));
-
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
-
- QCOMPARE(root->property("point1").toBool(), false);
- QCOMPARE(root->property("point2").toBool(), false);
-
- QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0);
- QGuiApplication::sendEvent(canvas, &moveEvent);
-
- QCOMPARE(root->property("point1").toBool(), true);
- QCOMPARE(root->property("point2").toBool(), false);
-
- QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0);
- QGuiApplication::sendEvent(canvas, &moveEvent2);
- QCOMPARE(root->property("point1").toBool(), false);
- QCOMPARE(root->property("point2").toBool(), true);
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::hoverVisible()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("hoverVisible.qml"));
-
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
-
- QQuickMouseArea *mouseTracker = canvas->rootObject()->findChild<QQuickMouseArea*>("mousetracker");
- QVERIFY(mouseTracker != 0);
-
- QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered()));
-
- QTest::mouseMove(canvas,QPoint(10,32));
-
- QCOMPARE(mouseTracker->hovered(), false);
- QCOMPARE(enteredSpy.count(), 0);
-
- mouseTracker->setVisible(true);
-
- QCOMPARE(mouseTracker->hovered(), true);
- QCOMPARE(enteredSpy.count(), 1);
-
- QEXPECT_FAIL("", "QTBUG-24282", Continue);
- QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32));
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_QQuickMouseArea)
-
-#include "tst_qquickmousearea.moc"
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro b/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
deleted file mode 100644
index 38c32099b0..0000000000
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TARGET = tst_qquickmultipointtoucharea
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickmultipointtoucharea.cpp
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
deleted file mode 100644
index 0a154d0a7b..0000000000
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ /dev/null
@@ -1,727 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qquickmultipointtoucharea_p.h>
-#include <private/qquickflickable_p.h>
-#include <QtQuick/qquickview.h>
-
-class tst_QQuickMultiPointTouchArea: public QObject
-{
- Q_OBJECT
-public:
- tst_QQuickMultiPointTouchArea() : device(0) { }
-private slots:
- void initTestCase() {
- if (!device) {
- device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
- }
- }
- void cleanupTestCase() {}
-
- void properties();
- void signalTest();
- void release();
- void reuse();
- void nonOverlapping();
- void nested();
- void inFlickable();
- void invisible();
-
-private:
- QQuickView *createAndShowView(const QString &file);
- QTouchDevice *device;
-};
-
-void tst_QQuickMultiPointTouchArea::properties()
-{
- QQuickView *canvas = createAndShowView("properties.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
- QVERIFY(area != 0);
-
- QCOMPARE(area->minimumTouchPoints(), 2);
- QCOMPARE(area->maximumTouchPoints(), 4);
-
- QDeclarativeListReference ref(area, "touchPoints");
- QCOMPARE(ref.count(), 4);
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::signalTest()
-{
- QQuickView *canvas = createAndShowView("signalTest.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
- QVERIFY(area != 0);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
- QPoint p3(60,100);
- QPoint p4(80,100);
- QPoint p5(100,100);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).press(1, p2).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 2);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
- QCOMPARE(area->property("touchCount").toInt(), 2);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- sequence.stationary(0).stationary(1).press(2, p3).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 1);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
- QCOMPARE(area->property("touchCount").toInt(), 3);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- sequence.move(0, p1).move(1, p2).stationary(2).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 2);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
- QCOMPARE(area->property("touchCount").toInt(), 3);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- p3 += QPoint(10,10);
- sequence.release(0, p1).release(1, p2)
- .move(2, p3).press(3, p4).press(4, p5).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 2);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 1);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 2);
- QCOMPARE(area->property("touchCount").toInt(), 3);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- sequence.release(2, p3).release(3, p4).release(4, p5).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 3);
- QCOMPARE(area->property("touchCount").toInt(), 0);
- QCOMPARE(area->property("touchUpdatedHandled").toBool(), true);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::release()
-{
- QQuickView *canvas = createAndShowView("basic.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickTouchPoint *point1 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
-
- QCOMPARE(point1->pressed(), false);
-
- QPoint p1(20,100);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).commit();
-
- QCOMPARE(point1->pressed(), true);
-
- p1 += QPoint(0,10);
-
- sequence.move(0, p1).commit();
-
- QCOMPARE(point1->pressed(), true);
- QCOMPARE(point1->x(), qreal(20)); QCOMPARE(point1->y(), qreal(110));
-
- p1 += QPoint(4,10);
-
- sequence.release(0, p1).commit();
-
- //test that a release without a prior move to the release position successfully updates the point's position
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point1->x(), qreal(24)); QCOMPARE(point1->y(), qreal(120));
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::reuse()
-{
- QQuickView *canvas = createAndShowView("basic.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickTouchPoint *point1 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
- QQuickTouchPoint *point2 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point2");
- QQuickTouchPoint *point3 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point3");
-
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point2->pressed(), false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
- QPoint p3(60,100);
- QPoint p4(80,100);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).press(1, p2).commit();
-
- QCOMPARE(point1->pressed(), true);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), false);
-
- sequence.release(0, p1).stationary(1).press(2, p3).commit();
-
- //we shouldn't reuse point 1 yet
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), true);
-
- //back to base state (no touches)
- sequence.release(1, p2).release(2, p3).commit();
-
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point2->pressed(), false);
- QCOMPARE(point3->pressed(), false);
-
- sequence.press(0, p1).press(1, p2).commit();
-
- QCOMPARE(point1->pressed(), true);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), false);
-
- sequence.release(0, p1).stationary(1).commit();
-
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), false);
-
- sequence.press(4, p4).stationary(1).commit();
-
- //the new touch point should reuse point 1
- QCOMPARE(point1->pressed(), true);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), false);
-
- QCOMPARE(point1->x(), qreal(80)); QCOMPARE(point1->y(), qreal(100));
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::nonOverlapping()
-{
- QQuickView *canvas = createAndShowView("nonOverlapping.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point11");
- QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point12");
- QQuickTouchPoint *point21 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point21");
- QQuickTouchPoint *point22 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point22");
- QQuickTouchPoint *point23 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point23");
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
- QPoint p3(60,180);
- QPoint p4(80,180);
- QPoint p5(100,180);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- sequence.stationary(0).press(1, p2).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100));
- QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100));
-
- p1 += QPoint(0,10);
- p2 += QPoint(5,0);
- sequence.move(0, p1).move(1, p2).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
-
- sequence.stationary(0).stationary(1).press(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- sequence.stationary(0).stationary(1).stationary(2).press(3, p4).press(4, p5).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
- QCOMPARE(point21->x(), qreal(60)); QCOMPARE(point21->y(), qreal(20));
- QCOMPARE(point22->x(), qreal(80)); QCOMPARE(point22->y(), qreal(20));
- QCOMPARE(point23->x(), qreal(100)); QCOMPARE(point23->y(), qreal(20));
-
- p1 += QPoint(4,10);
- p2 += QPoint(17,17);
- p3 += QPoint(3,0);
- p4 += QPoint(1,-1);
- p5 += QPoint(-7,10);
- sequence.move(0, p1).move(1, p2).move(2, p3).move(3, p4).move(4, p5).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120));
- QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117));
- QCOMPARE(point21->x(), qreal(63)); QCOMPARE(point21->y(), qreal(20));
- QCOMPARE(point22->x(), qreal(81)); QCOMPARE(point22->y(), qreal(19));
- QCOMPARE(point23->x(), qreal(93)); QCOMPARE(point23->y(), qreal(30));
-
- sequence.release(0, p1).release(1, p2).release(2, p3).release(3, p4).release(4, p5).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::nested()
-{
- QQuickView *canvas = createAndShowView("nested.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point11");
- QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point12");
- QQuickTouchPoint *point21 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point21");
- QQuickTouchPoint *point22 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point22");
- QQuickTouchPoint *point23 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point23");
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
- QPoint p3(60,180);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- sequence.stationary(0).press(1, p2).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100));
- QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100));
-
- p1 += QPoint(0,10);
- p2 += QPoint(5,0);
- sequence.move(0, p1).move(1, p2).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
-
- sequence.stationary(0).stationary(1).press(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- //point11 should be same as point21, point12 same as point22
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
- QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
- QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
- QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
-
- sequence.stationary(0).stationary(1).stationary(2).press(3, QPoint(80,180)).press(4, QPoint(100,180)).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- //new touch points should be ignored (have no impact on our existing touch points)
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
- QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
- QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
- QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
-
- sequence.stationary(0).stationary(1).stationary(2).release(3, QPoint(80,180)).release(4, QPoint(100,180)).commit();
-
- p1 += QPoint(4,10);
- p2 += QPoint(17,17);
- p3 += QPoint(3,0);
- sequence.move(0, p1).move(1, p2).move(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
- QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
- QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
- QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
- QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180));
-
- p1 += QPoint(4,10);
- p2 += QPoint(17,17);
- p3 += QPoint(3,0);
- sequence.move(0, p1).move(1, p2).move(2, p3).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- //first two remain the same (touches now grabbed by inner touch area)
- QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120));
- QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117));
- QCOMPARE(point21->x(), qreal(28)); QCOMPARE(point21->y(), qreal(130));
- QCOMPARE(point22->x(), qreal(79)); QCOMPARE(point22->y(), qreal(134));
- QCOMPARE(point23->x(), qreal(66)); QCOMPARE(point23->y(), qreal(180));
-
- sequence.release(0, p1).release(1, p2).release(2, p3).commit();
-
- sequence.press(0, p1).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- sequence.release(0, p1).commit();
-
- //test with grabbing turned off
- canvas->rootObject()->setProperty("grabInnerArea", false);
-
- sequence.press(0, p1).press(1, p2).press(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- p1 -= QPoint(4,10);
- p2 -= QPoint(17,17);
- p3 -= QPoint(3,0);
- sequence.move(0, p1).move(1, p2).move(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
- QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
- QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
- QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
- QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180));
-
- p1 -= QPoint(4,10);
- p2 -= QPoint(17,17);
- p3 -= QPoint(3,0);
- sequence.move(0, p1).move(1, p2).move(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- //all change (touches not grabbed by inner touch area)
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
- QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
- QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
- QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
-
- sequence.release(0, p1).release(1, p2).release(2, p3).commit();
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::inFlickable()
-{
- QQuickView *canvas = createAndShowView("inFlickable.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
- QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point2");
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
-
- //moving one point vertically
- QTest::touchEvent(canvas, device).press(0, p1);
- QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
-
- p1 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1);
- QTest::mouseMove(canvas, p1);
-
- QVERIFY(flickable->contentY() < 0);
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
-
- QTest::touchEvent(canvas, device).release(0, p1);
- QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
- QTest::qWait(50);
-
- QTRY_VERIFY(!flickable->isMoving());
-
- //moving two points vertically
- p1 = QPoint(20,100);
- QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
- QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(flickable->property("cancelCount").toInt(), 0);
- QCOMPARE(flickable->property("touchCount").toInt(), 2);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- QVERIFY(flickable->contentY() < 0);
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(flickable->property("cancelCount").toInt(), 2);
- QCOMPARE(flickable->property("touchCount").toInt(), 0);
-
- QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
- QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
- QTest::qWait(50);
-
- QTRY_VERIFY(!flickable->isMoving());
-
- //moving two points horizontally, then one point vertically
- p1 = QPoint(20,100);
- p2 = QPoint(40,100);
- QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
- QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
-
- p1 += QPoint(15,0); p2 += QPoint(15,0);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(15,0); p2 += QPoint(15,0);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(15,0); p2 += QPoint(15,0);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(15,0); p2 += QPoint(15,0);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- QVERIFY(flickable->contentY() == 0);
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
-
- QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
- QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
- QTest::qWait(50);
-
- delete canvas;
-}
-
-// QTBUG-23327
-void tst_QQuickMultiPointTouchArea::invisible()
-{
- QQuickView *canvas = createAndShowView("signalTest.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
- QVERIFY(area != 0);
-
- area->setVisible(false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).press(1, p2).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
- QCOMPARE(area->property("touchCount").toInt(), 0);
-
- delete canvas;
-}
-
-
-QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file)
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QLatin1String("/data/") + file));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
-
- return canvas;
-}
-
-QTEST_MAIN(tst_QQuickMultiPointTouchArea)
-
-#include "tst_qquickmultipointtoucharea.moc"
diff --git a/tests/auto/qtquick2/qquickpathview/qquickpathview.pro b/tests/auto/qtquick2/qquickpathview/qquickpathview.pro
deleted file mode 100644
index 027abb60e6..0000000000
--- a/tests/auto/qtquick2/qquickpathview/qquickpathview.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickpathview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickpathview.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp b/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp
deleted file mode 100644
index 8ed2ee75a6..0000000000
--- a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp
+++ /dev/null
@@ -1,1458 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <QtQuick/private/qquickpathview_p.h>
-#include <QtQuick/private/qdeclarativepath_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
-#include <QtDeclarative/private/qdeclarativevaluetype_p.h>
-#include <QStringListModel>
-#include <QStandardItemModel>
-#include <QFile>
-
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-
-static void initStandardTreeModel(QStandardItemModel *model)
-{
- QStandardItem *item;
- item = new QStandardItem(QLatin1String("Row 1 Item"));
- model->insertRow(0, item);
-
- item = new QStandardItem(QLatin1String("Row 2 Item"));
- item->setCheckable(true);
- model->insertRow(1, item);
-
- QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
- item->setChild(0, childItem);
-
- item = new QStandardItem(QLatin1String("Row 3 Item"));
- item->setIcon(QIcon());
- model->insertRow(2, item);
-}
-
-
-class tst_QQuickPathView : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickPathView();
-
-private slots:
- void initValues();
- void items();
- void dataModel();
- void pathview2();
- void pathview3();
- void insertModel_data();
- void insertModel();
- void removeModel_data();
- void removeModel();
- void moveModel_data();
- void moveModel();
- void path();
- void pathMoved();
- void setCurrentIndex();
- void resetModel();
- void propertyChanges();
- void pathChanges();
- void componentChanges();
- void modelChanges();
- void pathUpdateOnStartChanged();
- void package();
- void emptyModel();
- void closed();
- void pathUpdate();
- void visualDataModel();
- void undefinedPath();
- void mouseDrag();
- void treeModel();
- void changePreferredHighlight();
- void missingPercent();
- void creationContext();
- void currentOffsetOnInsertion();
- void asynchronous();
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError)
- Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
- Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged)
-
-public:
- TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; }
-
- bool useModel() const { return mUseModel; }
- void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
-
- int pathItemCount() const { return mPathItemCount; }
- void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); }
-
-signals:
- void useModelChanged();
- void pathItemCountChanged();
-
-private:
- bool mError;
- bool mUseModel;
- int mPathItemCount;
-};
-
-tst_QQuickPathView::tst_QQuickPathView()
-{
-}
-
-void tst_QQuickPathView::initValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathview1.qml"));
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() == 0);
- QVERIFY(obj->delegate() == 0);
- QCOMPARE(obj->model(), QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->preferredHighlightBegin(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 0);
- QCOMPARE(obj->pathItemCount(), -1);
-
- delete obj;
-}
-
-void tst_QQuickPathView::items()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->count(), model.count());
- QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
-
- for (int i = 0; i < model.count(); ++i) {
- QQuickText *name = findItem<QQuickText>(pathview, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(pathview, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
-
- QVERIFY(pathview->highlightItem());
- QPointF start = path->pointAt(0.0);
- QPointF offset;
- offset.setX(pathview->highlightItem()->width()/2);
- offset.setY(pathview->highlightItem()->height()/2);
- QCOMPARE(pathview->highlightItem()->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::pathview2()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathview2.qml"));
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->preferredHighlightBegin(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 10);
-
- delete obj;
-}
-
-void tst_QQuickPathView::pathview3()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathview3.qml"));
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 1.0);
- QCOMPARE(obj->preferredHighlightBegin(), 0.5);
- QCOMPARE(obj->dragMargin(), 24.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 4);
-
- delete obj;
-}
-
-void tst_QQuickPathView::insertModel_data()
-{
- QTest::addColumn<int>("mode");
- QTest::addColumn<int>("idx");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("offset");
-
- // We have 8 items, with currentIndex == 4
- QTest::newRow("insert after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 5.;
- QTest::newRow("insert before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.;
- QTest::newRow("insert multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 6.;
- QTest::newRow("insert multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.;
- QTest::newRow("insert at end")
- << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << 5.;
- QTest::newRow("insert at beginning")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.;
- QTest::newRow("insert at current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 4.;
-
- QTest::newRow("no range - insert after current")
- << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 5.;
- QTest::newRow("no range - insert before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.;
- QTest::newRow("no range - insert multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 6.;
- QTest::newRow("no range - insert multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.;
- QTest::newRow("no range - insert at end")
- << int(QQuickPathView::NoHighlightRange) << 8 << 1 << 5.;
- QTest::newRow("no range - insert at beginning")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.;
- QTest::newRow("no range - insert at current")
- << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.;
-}
-
-void tst_QQuickPathView::insertModel()
-{
- QFETCH(int, mode);
- QFETCH(int, idx);
- QFETCH(int, count);
- QFETCH(qreal, offset);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
- model.addItem("Jinny", "679");
- model.addItem("Milly", "73378");
- model.addItem("Jimmy", "3535");
- model.addItem("Barb", "9039");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
-
- pathview->setCurrentIndex(4);
- if (mode == QQuickPathView::StrictlyEnforceRange)
- QTRY_COMPARE(pathview->offset(), 4.0);
- else
- pathview->setOffset(4);
-
- QList<QPair<QString, QString> > items;
- for (int i = 0; i < count; ++i)
- items.append(qMakePair(QString("New"), QString::number(i)));
-
- model.insertItems(idx, items);
- QTRY_COMPARE(pathview->offset(), offset);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::removeModel_data()
-{
- QTest::addColumn<int>("mode");
- QTest::addColumn<int>("idx");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("offset");
-
- // We have 8 items, with currentIndex == 4
- QTest::newRow("remove after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 3.;
- QTest::newRow("remove before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.;
- QTest::newRow("remove multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 2.;
- QTest::newRow("remove multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.;
- QTest::newRow("remove last")
- << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << 3.;
- QTest::newRow("remove first")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.;
- QTest::newRow("remove current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 3.;
-
- QTest::newRow("no range - remove after current")
- << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 3.;
- QTest::newRow("no range - remove before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.;
- QTest::newRow("no range - remove multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 2.;
- QTest::newRow("no range - remove multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.;
- QTest::newRow("no range - remove last")
- << int(QQuickPathView::NoHighlightRange) << 7 << 1 << 3.;
- QTest::newRow("no range - remove first")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.;
- QTest::newRow("no range - remove current offset")
- << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.;
-}
-
-void tst_QQuickPathView::removeModel()
-{
- QFETCH(int, mode);
- QFETCH(int, idx);
- QFETCH(int, count);
- QFETCH(qreal, offset);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
- model.addItem("Jinny", "679");
- model.addItem("Milly", "73378");
- model.addItem("Jimmy", "3535");
- model.addItem("Barb", "9039");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
-
- pathview->setCurrentIndex(4);
- if (mode == QQuickPathView::StrictlyEnforceRange)
- QTRY_COMPARE(pathview->offset(), 4.0);
- else
- pathview->setOffset(4);
-
- model.removeItems(idx, count);
- QTRY_COMPARE(pathview->offset(), offset);
-
- delete canvas;
-}
-
-
-void tst_QQuickPathView::moveModel_data()
-{
- QTest::addColumn<int>("mode");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("offset");
-
- // We have 8 items, with currentIndex == 4
- QTest::newRow("move after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4.;
- QTest::newRow("move before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4.;
- QTest::newRow("move before current to after")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5.;
- QTest::newRow("move multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4.;
- QTest::newRow("move multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4.;
- QTest::newRow("move before current to end")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5.;
- QTest::newRow("move last to beginning")
- << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3.;
- QTest::newRow("move current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2.;
-
- QTest::newRow("no range - move after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << 4.;
- QTest::newRow("no range - move before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << 4.;
- QTest::newRow("no range - move before current to after")
- << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << 5.;
- QTest::newRow("no range - move multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << 4.;
- QTest::newRow("no range - move multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << 4.;
- QTest::newRow("no range - move before current to end")
- << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << 5.;
- QTest::newRow("no range - move last to beginning")
- << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << 3.;
- QTest::newRow("no range - move current")
- << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << 4.;
- QTest::newRow("no range - move multiple incl. current")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << 4.;
-}
-
-void tst_QQuickPathView::moveModel()
-{
- QFETCH(int, mode);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(qreal, offset);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
- model.addItem("Jinny", "679");
- model.addItem("Milly", "73378");
- model.addItem("Jimmy", "3535");
- model.addItem("Barb", "9039");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
-
- pathview->setCurrentIndex(4);
- if (mode == QQuickPathView::StrictlyEnforceRange)
- QTRY_COMPARE(pathview->offset(), 4.0);
- else
- pathview->setOffset(4);
-
- model.moveItems(from, to, count);
- QTRY_COMPARE(pathview->offset(), offset);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::path()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathtest.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->startX(), 120.);
- QCOMPARE(obj->startY(), 100.);
- QVERIFY(obj->path() != QPainterPath());
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 5);
-
- QDeclarativePathAttribute* attr = qobject_cast<QDeclarativePathAttribute*>(list.at(0));
- QVERIFY(attr != 0);
- QCOMPARE(attr->name(), QString("scale"));
- QCOMPARE(attr->value(), 1.0);
-
- QDeclarativePathQuad* quad = qobject_cast<QDeclarativePathQuad*>(list.at(1));
- QVERIFY(quad != 0);
- QCOMPARE(quad->x(), 120.);
- QCOMPARE(quad->y(), 25.);
- QCOMPARE(quad->controlX(), 260.);
- QCOMPARE(quad->controlY(), 75.);
-
- QDeclarativePathPercent* perc = qobject_cast<QDeclarativePathPercent*>(list.at(2));
- QVERIFY(perc != 0);
- QCOMPARE(perc->value(), 0.3);
-
- QDeclarativePathLine* line = qobject_cast<QDeclarativePathLine*>(list.at(3));
- QVERIFY(line != 0);
- QCOMPARE(line->x(), 120.);
- QCOMPARE(line->y(), 100.);
-
- QDeclarativePathCubic* cubic = qobject_cast<QDeclarativePathCubic*>(list.at(4));
- QVERIFY(cubic != 0);
- QCOMPARE(cubic->x(), 180.);
- QCOMPARE(cubic->y(), 0.);
- QCOMPARE(cubic->control1X(), -10.);
- QCOMPARE(cubic->control1Y(), 90.);
- QCOMPARE(cubic->control2X(), 210.);
- QCOMPARE(cubic->control2Y(), 90.);
-
- delete obj;
-}
-
-void tst_QQuickPathView::dataModel()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- QaimModel model;
- model.addItem("red", "1");
- model.addItem("green", "2");
- model.addItem("blue", "3");
- model.addItem("purple", "4");
- model.addItem("gray", "5");
- model.addItem("brown", "6");
- model.addItem("yellow", "7");
- model.addItem("thistle", "8");
- model.addItem("cyan", "9");
- model.addItem("peachpuff", "10");
- model.addItem("powderblue", "11");
- model.addItem("gold", "12");
- model.addItem("sandybrown", "13");
-
- ctxt->setContextProperty("testData", &model);
-
- canvas->setSource(testFileUrl("datamodel.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QQuickItem *item = findItem<QQuickItem>(pathview, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), 110.0);
- QCOMPARE(item->y(), 10.0);
-
- model.insertItem(4, "orange", "10");
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 14);
-
- QVERIFY(pathview->currentIndex() == 0);
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
-
- QQuickText *text = findItem<QQuickText>(pathview, "myText", 4);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(4));
-
- model.removeItem(2);
- QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
- text = findItem<QQuickText>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
-
- testObject->setPathItemCount(5);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
-
- QQuickRectangle *testItem = findItem<QQuickRectangle>(pathview, "wrapper", 4);
- QVERIFY(testItem != 0);
- testItem = findItem<QQuickRectangle>(pathview, "wrapper", 5);
- QVERIFY(testItem == 0);
-
- pathview->setCurrentIndex(1);
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
- QTest::qWait(100);
-
- model.insertItem(2, "pink", "2");
- QTest::qWait(100);
-
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
- QVERIFY(pathview->currentIndex() == 1);
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
-
- text = findItem<QQuickText>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
-
- model.removeItem(3);
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
- text = findItem<QQuickText>(pathview, "myText", 3);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(3));
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
-
- model.moveItem(3, 5);
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
- QList<QQuickItem*> items = findItems<QQuickItem>(pathview, "wrapper");
- foreach (QQuickItem *item, items) {
- QVERIFY(item->property("onPath").toBool());
- }
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
-
- // QTBUG-14199
- pathview->setOffset(7);
- pathview->setOffset(0);
- QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
-
- pathview->setCurrentIndex(model.count()-1);
- model.removeItem(model.count()-1);
- QCOMPARE(pathview->currentIndex(), model.count()-1);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickPathView::pathMoved()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- pathview->setOffset(1.0);
-
- for (int i=0; i<model.count(); i++) {
- QQuickRectangle *curItem = findItem<QQuickRectangle>(pathview, "wrapper", i);
- QPointF itemPos(path->pointAt(0.25 + i*0.25));
- QCOMPARE(curItem->pos() + offset, QPointF(itemPos.x(), itemPos.y()));
- }
-
- pathview->setOffset(0.0);
- QCOMPARE(firstItem->pos() + offset, start);
-
- // Change delegate size
- pathview->setOffset(0.1);
- pathview->setOffset(0.0);
- canvas->rootObject()->setProperty("delegateWidth", 30);
- QCOMPARE(firstItem->width(), 30.0);
- offset.setX(firstItem->width()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- // Change delegate scale
- pathview->setOffset(0.1);
- pathview->setOffset(0.0);
- canvas->rootObject()->setProperty("delegateScale", 1.2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::setCurrentIndex()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QCOMPARE(firstItem->pos() + offset, start);
- QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0);
-
- pathview->setCurrentIndex(2);
-
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 1);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 1);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 3);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->incrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- // move an item, set move duration to 0, and change currentIndex to moved item. QTBUG-22786
- model.moveItem(0, 3);
- pathview->setHighlightMoveDuration(0);
- pathview->setCurrentIndex(3);
- QCOMPARE(pathview->currentIndex(), 3);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- model.moveItem(3, 0);
- pathview->setCurrentIndex(0);
- pathview->setHighlightMoveDuration(300);
-
- // Check the current item is still created when outside the bounds of pathItemCount.
- pathview->setPathItemCount(2);
- pathview->setHighlightRangeMode(QQuickPathView::NoHighlightRange);
- QVERIFY(findItem<QQuickRectangle>(pathview, "wrapper", 0));
- QVERIFY(findItem<QQuickRectangle>(pathview, "wrapper", 1));
- QVERIFY(!findItem<QQuickRectangle>(pathview, "wrapper", 2));
- QVERIFY(!findItem<QQuickRectangle>(pathview, "wrapper", 3));
-
- pathview->setCurrentIndex(2);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 2);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(false));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 1);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 1);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 3);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(false));
-
- pathview->incrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- delete canvas;
-}
-
-void tst_QQuickPathView::resetModel()
-{
- QQuickView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaypath.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(pathview, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QCOMPARE(pathview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(pathview, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickPathView::propertyChanges()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("propertychanges.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged()));
- QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged()));
-
- QCOMPARE(pathView->preferredHighlightBegin(), 0.1);
- QCOMPARE(pathView->dragMargin(), 5.0);
-
- pathView->setPreferredHighlightBegin(0.4);
- pathView->setPreferredHighlightEnd(0.4);
- pathView->setDragMargin(20.0);
-
- QCOMPARE(pathView->preferredHighlightBegin(), 0.4);
- QCOMPARE(pathView->preferredHighlightEnd(), 0.4);
- QCOMPARE(pathView->dragMargin(), 20.0);
-
- QCOMPARE(snapPositionSpy.count(), 1);
- QCOMPARE(dragMarginSpy.count(), 1);
-
- pathView->setPreferredHighlightBegin(0.4);
- pathView->setPreferredHighlightEnd(0.4);
- pathView->setDragMargin(20.0);
-
- QCOMPARE(snapPositionSpy.count(), 1);
- QCOMPARE(dragMarginSpy.count(), 1);
- delete canvas;
-}
-
-void tst_QQuickPathView::pathChanges()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("propertychanges.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path");
- QVERIFY(path);
-
- QSignalSpy startXSpy(path, SIGNAL(startXChanged()));
- QSignalSpy startYSpy(path, SIGNAL(startYChanged()));
-
- QCOMPARE(path->startX(), 220.0);
- QCOMPARE(path->startY(), 200.0);
-
- path->setStartX(240.0);
- path->setStartY(220.0);
-
- QCOMPARE(path->startX(), 240.0);
- QCOMPARE(path->startY(), 220.0);
-
- QCOMPARE(startXSpy.count(),1);
- QCOMPARE(startYSpy.count(),1);
-
- path->setStartX(240);
- path->setStartY(220);
-
- QCOMPARE(startXSpy.count(),1);
- QCOMPARE(startYSpy.count(),1);
-
- QDeclarativePath *alternatePath = canvas->rootObject()->findChild<QDeclarativePath*>("alternatePath");
- QVERIFY(alternatePath);
-
- QSignalSpy pathSpy(pathView, SIGNAL(pathChanged()));
-
- QCOMPARE(pathView->path(), path);
-
- pathView->setPath(alternatePath);
- QCOMPARE(pathView->path(), alternatePath);
- QCOMPARE(pathSpy.count(),1);
-
- pathView->setPath(alternatePath);
- QCOMPARE(pathSpy.count(),1);
-
- QDeclarativePathAttribute *pathAttribute = canvas->rootObject()->findChild<QDeclarativePathAttribute*>("pathAttribute");
- QVERIFY(pathAttribute);
-
- QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged()));
- QCOMPARE(pathAttribute->name(), QString("opacity"));
-
- pathAttribute->setName("scale");
- QCOMPARE(pathAttribute->name(), QString("scale"));
- QCOMPARE(nameSpy.count(),1);
-
- pathAttribute->setName("scale");
- QCOMPARE(nameSpy.count(),1);
- delete canvas;
-}
-
-void tst_QQuickPathView::componentChanges()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("propertychanges.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
-
- QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged()));
-
- pathView->setDelegate(&delegateComponent);
- QCOMPARE(pathView->delegate(), &delegateComponent);
- QCOMPARE(delegateSpy.count(),1);
-
- pathView->setDelegate(&delegateComponent);
- QCOMPARE(delegateSpy.count(),1);
- delete canvas;
-}
-
-void tst_QQuickPathView::modelChanges()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("propertychanges.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
- QVERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
- QSignalSpy modelSpy(pathView, SIGNAL(modelChanged()));
-
- pathView->setModel(modelVariant);
- QCOMPARE(pathView->model(), modelVariant);
- QCOMPARE(modelSpy.count(),1);
-
- pathView->setModel(modelVariant);
- QCOMPARE(modelSpy.count(),1);
-
- pathView->setModel(QVariant());
- QCOMPARE(modelSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::pathUpdateOnStartChanged()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("pathUpdateOnStartChanged.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path");
- QVERIFY(path);
- QCOMPARE(path->startX(), 400.0);
- QCOMPARE(path->startY(), 300.0);
-
- QQuickItem *item = findItem<QQuickItem>(pathView, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), path->startX() - item->width() / 2.0);
- QCOMPARE(item->y(), path->startY() - item->height() / 2.0);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::package()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("pathview_package.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("photoPathView");
- QVERIFY(pathView);
-
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation");
-#endif
-
- QQuickItem *item = findItem<QQuickItem>(pathView, "pathItem");
- QVERIFY(item);
- QVERIFY(item->scale() != 1.0);
-
- delete canvas;
-}
-
-//QTBUG-13017
-void tst_QQuickPathView::emptyModel()
-{
- QQuickView *canvas = createView();
-
- QStringListModel model;
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("emptyModel", &model);
-
- canvas->setSource(testFileUrl("emptymodel.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->offset(), qreal(0.0));
-
- delete canvas;
-}
-
-void tst_QQuickPathView::closed()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent c(&engine, testFileUrl("openPath.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->isClosed(), false);
- delete obj;
- }
-
- {
- QDeclarativeComponent c(&engine, testFileUrl("closedPath.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->isClosed(), true);
- delete obj;
- }
-}
-
-// QTBUG-14239
-void tst_QQuickPathView::pathUpdate()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("pathUpdate.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QQuickItem *item = findItem<QQuickItem>(pathView, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), 150.0);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::visualDataModel()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("vdm.qml"));
-
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->count(), 3);
-
- delete obj;
-}
-
-void tst_QQuickPathView::undefinedPath()
-{
- QDeclarativeEngine engine;
-
- // QPainterPath warnings are only received if QT_NO_DEBUG is not defined
- if (QLibraryInfo::isDebugBuild()) {
- QString warning1("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call");
- QTest::ignoreMessage(QtWarningMsg,qPrintable(warning1));
-
- QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call");
- QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2));
- }
-
- QDeclarativeComponent c(&engine, testFileUrl("undefinedpath.qml"));
-
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->count(), 3);
-
- delete obj;
-}
-
-void tst_QQuickPathView::mouseDrag()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("dragpath.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(canvas, qGuiApp->focusWindow());
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- int current = pathview->currentIndex();
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100));
- QTest::qWait(100);
-
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
-
- QVERIFY(pathview->currentIndex() != current);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100));
-
- delete canvas;
-}
-
-void tst_QQuickPathView::treeModel()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
- canvas->engine()->rootContext()->setContextProperty("myModel", &model);
-
- canvas->setSource(testFileUrl("treemodel.qml"));
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
- QCOMPARE(pathview->count(), 3);
-
- QQuickText *item = findItem<QQuickText>(pathview, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->text(), QLatin1String("Row 1 Item"));
-
- QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1)));
- QCOMPARE(pathview->count(), 1);
-
- QTRY_VERIFY(item = findItem<QQuickText>(pathview, "wrapper", 0));
- QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item"));
-
- delete canvas;
-}
-
-void tst_QQuickPathView::changePreferredHighlight()
-{
- QQuickView *canvas = createView();
- canvas->setGeometry(0,0,400,200);
- canvas->setSource(testFileUrl("dragpath.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(canvas, qGuiApp->focusWindow());
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- int current = pathview->currentIndex();
- QCOMPARE(current, 0);
-
- QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.5);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- pathview->setPreferredHighlightBegin(0.8);
- pathview->setPreferredHighlightEnd(0.8);
- start = path->pointAt(0.8);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentIndex(), 0);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::creationContext()
-{
- QQuickView canvas;
- canvas.setGeometry(0,0,240,320);
- canvas.setSource(testFileUrl("creationContext.qml"));
-
- QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
- QVERIFY(rootItem);
- QVERIFY(rootItem->property("count").toInt() > 0);
-
- QQuickItem *item;
- QVERIFY(item = findItem<QQuickItem>(rootItem, "listItem", 0));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
-}
-
-// QTBUG-21320
-void tst_QQuickPathView::currentOffsetOnInsertion()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathline.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- pathview->setPreferredHighlightBegin(0.5);
- pathview->setPreferredHighlightEnd(0.5);
-
- QCOMPARE(pathview->count(), model.count());
-
- model.addItem("item0", "0");
-
- QCOMPARE(pathview->count(), model.count());
-
- QQuickRectangle *item = 0;
- QTRY_VERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 0));
-
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
-
- QPointF start = path->pointAt(0.5);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(item->width()/2);
- offset.setY(item->height()/2);
- QCOMPARE(item->pos() + offset, start);
-
- QSignalSpy currentIndexSpy(pathview, SIGNAL(currentIndexChanged()));
-
- // insert an item at the beginning
- model.insertItem(0, "item1", "1");
- qApp->processEvents();
-
- QCOMPARE(currentIndexSpy.count(), 1);
-
- // currentIndex is now 1
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
-
- // verify that current item (item 1) is still at offset 0.5
- QCOMPARE(item->pos() + offset, start);
-
- // insert another item at the beginning
- model.insertItem(0, "item2", "2");
- qApp->processEvents();
-
- QCOMPARE(currentIndexSpy.count(), 2);
-
- // currentIndex is now 2
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 2));
-
- // verify that current item (item 2) is still at offset 0.5
- QCOMPARE(item->pos() + offset, start);
-
- // verify that remove before current maintains current item
- model.removeItem(0);
- qApp->processEvents();
-
- QCOMPARE(currentIndexSpy.count(), 3);
-
- // currentIndex is now 1
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
-
- // verify that current item (item 1) is still at offset 0.5
- QCOMPARE(item->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::asynchronous()
-{
- QQuickView *canvas = createView();
- canvas->show();
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->setSource(testFileUrl("asyncloader.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootObject);
-
- QQuickPathView *pathview = 0;
- while (!pathview) {
- bool b = false;
- controller.incubateWhile(&b);
- pathview = rootObject->findChild<QQuickPathView*>("view");
- }
-
- // items will be created one at a time
- for (int i = 0; i < 5; ++i) {
- QVERIFY(findItem<QQuickItem>(pathview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(pathview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- // verify positioning
- QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- pathview->setOffset(1.0);
-
- for (int i=0; i<5; i++) {
- QQuickItem *curItem = findItem<QQuickItem>(pathview, "wrapper", i);
- QPointF itemPos(path->pointAt(0.2 + i*0.2));
- QCOMPARE(curItem->pos() + offset, itemPos);
- }
-
- delete canvas;
-}
-
-void tst_QQuickPathView::missingPercent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("missingPercent.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->attributeAt("_qfx_percent", 1.0), qreal(1.0));
- delete obj;
-}
-
-QTEST_MAIN(tst_QQuickPathView)
-
-#include "tst_qquickpathview.moc"
diff --git a/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro b/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro
deleted file mode 100644
index 3c75079ca5..0000000000
--- a/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickpincharea
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickpincharea.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp
deleted file mode 100644
index e1eaa7879e..0000000000
--- a/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp
+++ /dev/null
@@ -1,404 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qquickpincharea_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include "../../shared/util.h"
-
-class tst_QQuickPinchArea: public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickPinchArea() : device(0) { }
-private slots:
- void initTestCase();
- void cleanupTestCase();
- void pinchProperties();
- void scale();
- void pan();
- void retouch();
-
-private:
- QQuickView *createView();
- QTouchDevice *device;
-};
-void tst_QQuickPinchArea::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- if (!device) {
- device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
- }
-}
-
-void tst_QQuickPinchArea::cleanupTestCase()
-{
-
-}
-void tst_QQuickPinchArea::pinchProperties()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pinchproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
- QQuickPinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == pinch->target());
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(pinch, SIGNAL(targetChanged()));
- pinch->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
- pinch->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
-
- // axis
- QCOMPARE(pinch->axis(), QQuickPinch::XandYAxis);
- QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged()));
- pinch->setAxis(QQuickPinch::XAxis);
- QCOMPARE(pinch->axis(), QQuickPinch::XAxis);
- QCOMPARE(axisSpy.count(),1);
- pinch->setAxis(QQuickPinch::XAxis);
- QCOMPARE(axisSpy.count(),1);
-
- // minimum and maximum drag properties
- QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged()));
- QSignalSpy xmaxSpy(pinch, SIGNAL(maximumXChanged()));
- QSignalSpy yminSpy(pinch, SIGNAL(minimumYChanged()));
- QSignalSpy ymaxSpy(pinch, SIGNAL(maximumYChanged()));
-
- QCOMPARE(pinch->xmin(), 0.0);
- QCOMPARE(pinch->xmax(), rootItem->width()-blackRect->width());
- QCOMPARE(pinch->ymin(), 0.0);
- QCOMPARE(pinch->ymax(), rootItem->height()-blackRect->height());
-
- pinch->setXmin(10);
- pinch->setXmax(10);
- pinch->setYmin(10);
- pinch->setYmax(10);
-
- QCOMPARE(pinch->xmin(), 10.0);
- QCOMPARE(pinch->xmax(), 10.0);
- QCOMPARE(pinch->ymin(), 10.0);
- QCOMPARE(pinch->ymax(), 10.0);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- pinch->setXmin(10);
- pinch->setXmax(10);
- pinch->setYmin(10);
- pinch->setYmax(10);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- // minimum and maximum scale properties
- QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged()));
- QSignalSpy scaleMaxSpy(pinch, SIGNAL(maximumScaleChanged()));
-
- QCOMPARE(pinch->minimumScale(), 1.0);
- QCOMPARE(pinch->maximumScale(), 2.0);
-
- pinch->setMinimumScale(0.5);
- pinch->setMaximumScale(1.5);
-
- QCOMPARE(pinch->minimumScale(), 0.5);
- QCOMPARE(pinch->maximumScale(), 1.5);
-
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
-
- pinch->setMinimumScale(0.5);
- pinch->setMaximumScale(1.5);
-
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
-
- // minimum and maximum rotation properties
- QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged()));
- QSignalSpy rotMaxSpy(pinch, SIGNAL(maximumRotationChanged()));
-
- QCOMPARE(pinch->minimumRotation(), 0.0);
- QCOMPARE(pinch->maximumRotation(), 90.0);
-
- pinch->setMinimumRotation(-90.0);
- pinch->setMaximumRotation(45.0);
-
- QCOMPARE(pinch->minimumRotation(), -90.0);
- QCOMPARE(pinch->maximumRotation(), 45.0);
-
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
-
- pinch->setMinimumRotation(-90.0);
- pinch->setMaximumRotation(45.0);
-
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
-
- delete canvas;
-}
-
-QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i)
-{
- QTouchEvent::TouchPoint touchPoint(id);
- touchPoint.setPos(i->mapFromScene(p));
- touchPoint.setScreenPos(v->mapToGlobal(p));
- touchPoint.setScenePos(p);
- return touchPoint;
-}
-
-void tst_QQuickPinchArea::scale()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pinchproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
- QQuickPinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
-
- QPoint p1(80, 80);
- QPoint p2(100, 100);
-
- QTest::touchEvent(canvas, device).press(0, p1, canvas);
- QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.5);
- QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
- QCOMPARE(blackRect->scale(), 1.5);
-
- // scale beyond bound
- p1 -= QPoint(50,50);
- p2 += QPoint(50,50);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(blackRect->scale(), 2.0);
-
- QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
-
- delete canvas;
-}
-
-void tst_QQuickPinchArea::pan()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pinchproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
- QQuickPinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
-
- QPoint p1(80, 80);
- QPoint p2(100, 100);
-
- QTest::touchEvent(canvas, device).press(0, p1, canvas);
- QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
- p1 += QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 += QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50
-
- QCOMPARE(blackRect->x(), 60.0);
- QCOMPARE(blackRect->y(), 60.0);
-
- // pan x beyond bound
- p1 += QPoint(100,100);
- p2 += QPoint(100,100);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(blackRect->x(), 140.0);
- QCOMPARE(blackRect->y(), 160.0);
-
- QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
-
- delete canvas;
-}
-
-// test pinch, release one point, touch again to continue pinch
-void tst_QQuickPinchArea::retouch()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pinchproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
- QQuickPinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- QSignalSpy startedSpy(pinchArea, SIGNAL(pinchStarted(QQuickPinchEvent *)));
- QSignalSpy finishedSpy(pinchArea, SIGNAL(pinchFinished(QQuickPinchEvent *)));
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
-
- QPoint p1(80, 80);
- QPoint p2(100, 100);
-
- QTest::touchEvent(canvas, device).press(0, p1, canvas);
- QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(startedSpy.count(), 1);
-
- QCOMPARE(root->property("scale").toReal(), 1.5);
- QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
- QCOMPARE(blackRect->scale(), 1.5);
-
- QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
-
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
-
- QTest::touchEvent(canvas, device).stationary(0).release(1, p2, canvas);
-
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
-
- QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 1);
-
- QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- // Lifting and retouching results in onPinchStarted being called again
- QCOMPARE(startedSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 0);
-
- QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
-
- QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
-
- QCOMPARE(startedSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 1);
-
- delete canvas;
-}
-
-
-QQuickView *tst_QQuickPinchArea::createView()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- return canvas;
-}
-
-QTEST_MAIN(tst_QQuickPinchArea)
-
-#include "tst_qquickpincharea.moc"
diff --git a/tests/auto/qtquick2/qquickpositioners/data/transitions.qml b/tests/auto/qtquick2/qquickpositioners/data/transitions.qml
deleted file mode 100644
index 982e64141c..0000000000
--- a/tests/auto/qtquick2/qquickpositioners/data/transitions.qml
+++ /dev/null
@@ -1,196 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 500
-
- property int duration: 50
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- function checkPos(x, y, name) {
- if (Qt.point(x, y) == targetItems_transitionFrom)
- model_targetItems_transitionFrom.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
-
- Transition {
- id: targetTransition
- enabled: enableAddTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- root.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- root.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- root.targetTrans_targetItems.push(root.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
- NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
- }
-
- ScriptAction { script: root.targetTransitionsDone += 1 }
- }
- }
-
- Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- root.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- root.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- root.displacedTrans_targetItems.push(root.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
- NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: root.displaceTransitionsDone += 1 }
- }
-
- }
-
- Row {
- objectName: "row"
-
- property int count: children.length - 1 // omit Repeater
-
- x: 50; y: 50
- width: 400; height: 400
- Repeater {
- objectName: "repeater"
- Rectangle {
- property string nameData: name
- objectName: "wrapper"
- width: 30 + index*5
- height: 30 + index*5
- border.width: 1
- Column {
- Text { text: index }
- Text { objectName: "name"; text: name }
- Text { text: parent.parent.y }
- }
- onXChanged: root.checkPos(x, y, name)
- onYChanged: root.checkPos(x, y, name)
- }
- }
-
- add: targetTransition
- move: displaced
- }
-
- Column {
- objectName: "column"
-
- property int count: children.length - 1 // omit Repeater
-
- x: 50; y: 50
- width: 400; height: 400
- Repeater {
- objectName: "repeater"
- Rectangle {
- property string nameData: name
- objectName: "wrapper"
- width: 30 + index*5
- height: 30 + index*5
- border.width: 1
- Column {
- Text { text: index }
- Text { objectName: "name"; text: name }
- Text { text: parent.parent.y }
- }
- onXChanged: root.checkPos(x, y, name)
- onYChanged: root.checkPos(x, y, name)
- }
- }
-
- add: targetTransition
- move: displaced
- }
-
- Grid {
- objectName: "grid"
-
- property int count: children.length - 1 // omit Repeater
-
- x: 50; y: 50
- width: 400; height: 400
- Repeater {
- objectName: "repeater"
- Rectangle {
- property string nameData: name
- objectName: "wrapper"
- width: 30 + index*5
- height: 30 + index*5
- border.width: 1
- Column {
- Text { text: index }
- Text { objectName: "name"; text: name }
- Text { text: parent.parent.y }
- }
-
- onXChanged: root.checkPos(x, y, name)
- onYChanged: root.checkPos(x, y, name)
- }
- }
-
- add: targetTransition
- move: displaced
- }
-
- Flow {
- objectName: "flow"
-
- property int count: children.length - 1 // omit Repeater
-
- x: 50; y: 50
- width: 400; height: 400
- Repeater {
- objectName: "repeater"
- Rectangle {
- property string nameData: name
- objectName: "wrapper"
- width: 30 + index*5
- height: 30 + index*5
- border.width: 1
- Column {
- Text { text: index }
- Text { objectName: "name"; text: name }
- Text { text: parent.parent.x + " " + parent.parent.y }
- }
- onXChanged: root.checkPos(x, y, name)
- onYChanged: root.checkPos(x, y, name)
- }
- }
-
- add: targetTransition
- move: displaced
- }
-}
-
diff --git a/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro b/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro
deleted file mode 100644
index 699a54ed7b..0000000000
--- a/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickpositioners
-SOURCES += tst_qquickpositioners.cpp
-
-include (../shared/util.pri)
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp
deleted file mode 100644
index f7e14bee3e..0000000000
--- a/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp
+++ /dev/null
@@ -1,1927 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <QtQuick/qquickview.h>
-#include <qdeclarativeengine.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquickpositioners_p.h>
-#include <QtQuick/private/qdeclarativetransition_p.h>
-#include <private/qquickitem_p.h>
-#include <qdeclarativeexpression.h>
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-#include "../../shared/util.h"
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-class tst_qquickpositioners : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickpositioners();
-
-private slots:
- void test_horizontal();
- void test_horizontal_rtl();
- void test_horizontal_spacing();
- void test_horizontal_spacing_rightToLeft();
- void test_horizontal_animated();
- void test_horizontal_animated_rightToLeft();
- void test_horizontal_animated_disabled();
- void test_vertical();
- void test_vertical_spacing();
- void test_vertical_animated();
- void test_grid();
- void test_grid_topToBottom();
- void test_grid_rightToLeft();
- void test_grid_spacing();
- void test_grid_row_column_spacing();
- void test_grid_animated();
- void test_grid_animated_rightToLeft();
- void test_grid_zero_columns();
- void test_propertychanges();
- void test_repeater();
- void test_flow();
- void test_flow_rightToLeft();
- void test_flow_topToBottom();
- void test_flow_resize();
- void test_flow_resize_rightToLeft();
- void test_flow_implicit_resize();
- void test_conflictinganchors();
- void test_mirroring();
- void test_allInvisible();
- void test_attachedproperties();
- void test_attachedproperties_data();
- void test_attachedproperties_dynamic();
- void addTransitions_row();
- void addTransitions_row_data();
- void addTransitions_column();
- void addTransitions_column_data();
- void addTransitions_grid();
- void addTransitions_grid_data();
- void addTransitions_flow();
- void addTransitions_flow_data();
- void moveTransitions_row();
- void moveTransitions_row_data();
- void moveTransitions_column();
- void moveTransitions_column_data();
- void moveTransitions_grid();
- void moveTransitions_grid_data();
- void moveTransitions_flow();
- void moveTransitions_flow_data();
-
-private:
- QQuickView *createView(const QString &filename, bool wait=true);
-
- void addTransitions(const QString &positionerObjectName);
- void addTransitions_data();
- void moveTransitions(const QString &positionerObjectName);
- void moveTransitions_data();
- void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
- void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
- void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
- void checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize);
-};
-
-void tst_qquickpositioners::addTransitions_row()
-{
- addTransitions("row");
-}
-
-void tst_qquickpositioners::addTransitions_row_data()
-{
- addTransitions_data();
-}
-
-void tst_qquickpositioners::addTransitions_column()
-{
- addTransitions("column");
-}
-
-void tst_qquickpositioners::addTransitions_column_data()
-{
- addTransitions_data();
-}
-
-void tst_qquickpositioners::addTransitions_grid()
-{
- addTransitions("grid");
-}
-
-void tst_qquickpositioners::addTransitions_grid_data()
-{
- // don't use addTransitions_data() because grid displaces items differently
- // (adding items further down the grid can cause displace transitions at
- // previous indexes, since grid is auto-resized to tightly fit all of its items)
-
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("insertionIndex");
- QTest::addColumn<int>("insertionCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9);
- QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9);
- QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7);
-
- QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9);
- QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9);
- QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9);
-}
-
-void tst_qquickpositioners::addTransitions_flow()
-{
- addTransitions("flow");
-}
-
-void tst_qquickpositioners::addTransitions_flow_data()
-{
- addTransitions_data();
-}
-
-void tst_qquickpositioners::moveTransitions_row()
-{
- moveTransitions("row");
-}
-
-void tst_qquickpositioners::moveTransitions_row_data()
-{
- moveTransitions_data();
-}
-
-void tst_qquickpositioners::moveTransitions_column()
-{
- moveTransitions("column");
-}
-
-void tst_qquickpositioners::moveTransitions_column_data()
-{
- moveTransitions_data();
-}
-
-void tst_qquickpositioners::moveTransitions_grid()
-{
- moveTransitions("grid");
-}
-
-void tst_qquickpositioners::moveTransitions_grid_data()
-{
- // don't use moveTransitions_data() because grid displaces items differently
- // (removing items further down the grid can cause displace transitions at
- // previous indexes, since grid is auto-resized to tightly fit all of its items)
-
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<ListChange>("change");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
- QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(2, 3) + ListRange(5, 9);
- QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange(2, 3) + ListRange(6, 7);
-
- QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
- QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(1, 3) + ListRange(7, 9);
- QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange(1, 3) + ListRange(5, 6);
-}
-
-void tst_qquickpositioners::moveTransitions_flow()
-{
- moveTransitions("flow");
-}
-
-void tst_qquickpositioners::moveTransitions_flow_data()
-{
- moveTransitions_data();
-}
-
-tst_qquickpositioners::tst_qquickpositioners()
-{
-}
-
-void tst_qquickpositioners::test_horizontal()
-{
- QQuickView *canvas = createView(testFile("horizontal.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QCOMPARE(row->width(), 110.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_rtl()
-{
- QQuickView *canvas = createView(testFile("horizontal.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 60.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 40.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 0.0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QCOMPARE(row->width(), 110.0);
- QCOMPARE(row->height(), 50.0);
-
- // Change the width of the row and check that items stay to the right
- row->setWidth(200);
- QTRY_COMPARE(one->x(), 150.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 130.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 90.0);
- QCOMPARE(three->y(), 0.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_spacing()
-{
- QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 60.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 90.0);
- QCOMPARE(three->y(), 0.0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QCOMPARE(row->width(), 130.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 80.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 00.0);
- QCOMPARE(three->y(), 0.0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QCOMPARE(row->width(), 130.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_animated()
-{
- QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- //Note that they animate in
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QVERIFY(row);
- QCOMPARE(row->width(), 100.0);
- QCOMPARE(row->height(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QTRY_COMPARE(two->isVisible(), true);
- QTRY_COMPARE(row->width(), 150.0);
- QTRY_COMPARE(row->height(), 50.0);
-
- QTest::qWait(0);//Let the animation start
- QVERIFY(two->x() >= -100.0 && two->x() < 50.0);
- QVERIFY(three->x() >= 50.0 && three->x() < 100.0);
-
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(three->x(), 100.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- //Note that they animate in
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QVERIFY(row);
- QCOMPARE(row->width(), 100.0);
- QCOMPARE(row->height(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->x(), 50.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 0.0);
- QTRY_COMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QTRY_COMPARE(two->isVisible(), true);
-
- // New size should propagate after visible change
- QTRY_COMPARE(row->width(), 150.0);
- QTRY_COMPARE(row->height(), 50.0);
-
- QTest::qWait(0);//Let the animation start
- QVERIFY(one->x() >= 50.0 && one->x() < 100);
- QVERIFY(two->x() >= -100.0 && two->x() < 50.0);
-
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(two->x(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_animated_disabled()
-{
- QQuickView *canvas = createView(testFile("horizontal-animated-disabled.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QVERIFY(row);
-
- qApp->processEvents();
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->isVisible(), false);
- QCOMPARE(two->x(), -100.0);//Not 'in' yet
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QCOMPARE(two->isVisible(), true);
- QTRY_COMPARE(row->width(), 150.0);
- QTRY_COMPARE(row->height(), 50.0);
-
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(three->x(), 100.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, insertionIndex);
- QFETCH(int, insertionCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- QPointF targetItems_transitionFrom(-50, -50);
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionFrom;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = QQuickViewTestUtil::createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("enableAddTransition", true);
- ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- canvas->setSource(testFile("transitions.qml"));
- canvas->show();
- qApp->processEvents();
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- QQuickItem *positioner = canvas->rootObject()->findChild<QQuickItem*>(positionerObjectName);
- QVERIFY(positioner);
- positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model));
-
- QList<QPair<QString, QString> > targetData;
- QList<int> targetIndexes;
- for (int i=0; i<model.count(); i++) {
- targetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(positioner, "wrapper", targetIndexes);
-
- // check initial add transition
- // (positioners run the add transition on all items that are initially created for the view)
- QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), initialItemCount);
- QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), 0);
- model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems);
-
- model_targetItems_transitionFrom.clear();
- canvas->rootObject()->setProperty("targetTransitionsDone", 0);
- canvas->rootObject()->setProperty("targetTrans_items", QVariantMap());
- canvas->rootObject()->setProperty("targetTrans_targetIndexes", QVariantList());
- canvas->rootObject()->setProperty("targetTrans_targetItems", QVariantList());
-
- // do insertion
- targetData.clear();
- targetIndexes.clear();
- for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
- targetData << qMakePair(QString("New item %1").arg(i), QString(""));
- targetIndexes << i;
- }
- model.insertItems(insertionIndex, targetData);
- QTRY_COMPARE(model.count(), positioner->property("count").toInt());
-
- targetItems = findItems<QQuickItem>(positioner, "wrapper", targetIndexes);
-
- QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), targetData.count());
- QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count());
-
- // check the target and displaced items were animated
- model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
- matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(canvas->rootObject()->property("displacedTrans_targetItems").toList(), targetItems);
- }
-
- checkItemPositions(positioner, &model, 5.0); // XXX fetch from qml?
-
- delete canvas;
-}
-
-void tst_qquickpositioners::addTransitions_data()
-{
- // If this data changes, update addTransitions_grid_data() also
-
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("insertionIndex");
- QTest::addColumn<int>("insertionCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9);
- QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(5, 9);
- QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange();
-
- QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9);
- QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(5, 9);
- QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange();
-}
-
-void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
-{
- QFETCH(int, initialItemCount);
- QFETCH(ListChange, change);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- QPointF targetItems_transitionFrom(-50, -50);
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Item" + QString::number(i), "");
- QaimModel model_targetItems_transitionFrom;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = QQuickViewTestUtil::createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("enableAddTransition", false);
- ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- canvas->setSource(testFile("transitions.qml"));
- canvas->show();
- qApp->processEvents();
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- QQuickItem *positioner = canvas->rootObject()->findChild<QQuickItem*>(positionerObjectName);
- QVERIFY(positioner);
- positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model));
- QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
-
- switch (change.type) {
- case ListChange::Removed:
- model.removeItems(change.index, change.count);
- QTRY_COMPARE(model.count(), positioner->property("count").toInt());
- break;
- case ListChange::Moved:
- model.moveItems(change.index, change.to, change.count);
- QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
- break;
- case ListChange::Inserted:
- case ListChange::SetCurrent:
- case ListChange::SetContentY:
- QVERIFY(false);
- break;
- }
-
- QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count());
- QCOMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), 0);
-
- // check the target and displaced items were animated
- QCOMPARE(model_targetItems_transitionFrom.count(), 0);
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- QCOMPARE(canvas->rootObject()->property("targetTrans_items").toMap().count(), 0);
- QCOMPARE(canvas->rootObject()->property("targetTrans_targetIndexes").toList().count(), 0);
- QCOMPARE(canvas->rootObject()->property("targetTrans_targetItems").toList().count(), 0);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes;
- if (change.type == ListChange::Inserted)
- displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count);
- else if (change.type == ListChange::Moved)
- displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, change.index, change.to, change.count);
- else if (change.type == ListChange::Removed)
- displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count);
- else
- QVERIFY(false);
- matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes);
-
- QVariantList listOfEmptyIntLists;
- for (int i=0; i<displacedIndexes.count(); i++)
- listOfEmptyIntLists << QVariant::fromValue(QList<int>());
- QCOMPARE(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), listOfEmptyIntLists);
- QVariantList listOfEmptyObjectLists;
- for (int i=0; i<displacedIndexes.count(); i++)
- listOfEmptyObjectLists.insert(listOfEmptyObjectLists.count(), QVariantList());
- QCOMPARE(canvas->rootObject()->property("displacedTrans_targetItems").toList(), listOfEmptyObjectLists);
- }
-
- checkItemPositions(positioner, &model, 5.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::moveTransitions_data()
-{
- // If this data changes, update moveTransitions_grid_data() also
-
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<ListChange>("change");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
- QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(5, 9);
- QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange();
-
- QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
- QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(7, 9);
- QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange();
-}
-
-
-void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize)
-{
- QVERIFY(model->count() > 0);
- qreal padding = 0;
- qreal currentSize = 30;
- qreal rowX = 0;
- qreal rowY = 0;
-
- for (int i=0; i<model->count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(positioner, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
-
- QCOMPARE(item->width(), currentSize);
- QCOMPARE(item->height(), currentSize);
-
- if (qobject_cast<QQuickRow*>(positioner)) {
- QCOMPARE(item->x(), (i * 30.0) + padding);
- QCOMPARE(item->y(), 0.0);
- } else if (qobject_cast<QQuickColumn*>(positioner)) {
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), (i * 30.0) + padding);
- } else if (qobject_cast<QQuickGrid*>(positioner)) {
- int columns = 4;
- int rows = qCeil(model->count() / qreal(columns));
- int lastMatchingRowIndex = (rows * columns) - (columns - i%columns);
- if (lastMatchingRowIndex >= model->count())
- lastMatchingRowIndex -= columns;
- if (i % columns > 0) {
- QQuickItem *finalAlignedRowItem = findItem<QQuickItem>(positioner, "wrapper", lastMatchingRowIndex);
- QVERIFY(finalAlignedRowItem);
- QCOMPARE(item->x(), finalAlignedRowItem->x());
- } else {
- QCOMPARE(item->x(), 0.0);
- }
- if (i / columns > 0) {
- QQuickItem *prevRowLastItem = findItem<QQuickItem>(positioner, "wrapper", (i/columns * columns) - 1);
- QVERIFY(prevRowLastItem);
- QCOMPARE(item->y(), prevRowLastItem->y() + prevRowLastItem->height());
- } else {
- QCOMPARE(item->y(), 0.0);
- }
- } else if (qobject_cast<QQuickFlow*>(positioner)) {
- if (rowX + item->width() > positioner->width()) {
- QQuickItem *prevItem = findItem<QQuickItem>(positioner, "wrapper", i-1);
- QVERIFY(prevItem);
- rowX = 0;
- rowY = prevItem->y() + prevItem->height();
- }
- QCOMPARE(item->x(), rowX);
- QCOMPARE(item->y(), rowY);
- rowX += item->width();
- } else {
- QVERIFY2(false, "Unknown positioner type");
- }
- QQuickText *name = findItem<QQuickText>(positioner, "name", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model->name(i));
-
- padding += i * incrementalSize;
- currentSize += incrementalSize;
- }
-}
-
-void tst_qquickpositioners::test_vertical()
-{
- QQuickView *canvas = createView(testFile("vertical.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 60.0);
-
- QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
- QVERIFY(column);
- QCOMPARE(column->height(), 80.0);
- QCOMPARE(column->width(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_vertical_spacing()
-{
- QQuickView *canvas = createView(testFile("vertical-spacing.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 60.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 80.0);
-
- QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
- QCOMPARE(column->height(), 100.0);
- QCOMPARE(column->width(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_vertical_animated()
-{
- QQuickView *canvas = createView(testFile("vertical-animated.qml"), false);
-
- //Note that they animate in
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->y(), -100.0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->y(), -100.0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->y(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
- QVERIFY(column);
- QCOMPARE(column->height(), 100.0);
- QCOMPARE(column->width(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->x(), 0.0);
- QTRY_COMPARE(three->y(), 50.0);
- QTRY_COMPARE(three->x(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QTRY_COMPARE(two->isVisible(), true);
- QTRY_COMPARE(column->height(), 150.0);
- QTRY_COMPARE(column->width(), 50.0);
- QTest::qWait(0);//Let the animation start
- QVERIFY(two->y() >= -100.0 && two->y() < 50.0);
- QVERIFY(three->y() >= 50.0 && three->y() < 100.0);
-
- QTRY_COMPARE(two->y(), 50.0);
- QTRY_COMPARE(three->y(), 100.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid()
-{
- QQuickView *canvas = createView(testFile("gridtest.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
- QCOMPARE(grid->flow(), QQuickGrid::LeftToRight);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 100.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_topToBottom()
-{
- QQuickView *canvas = createView(testFile("grid-toptobottom.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 100.0);
- QCOMPARE(four->x(), 50.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
- QCOMPARE(grid->flow(), QQuickGrid::TopToBottom);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("gridtest.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 50.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 30.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 50.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 40.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
- QCOMPARE(grid->layoutDirection(), Qt::RightToLeft);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 100.0);
-
- // Change the width of the grid and check that items stay to the right
- grid->setWidth(200);
- QTRY_COMPARE(one->x(), 150.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 130.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 150.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 140.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_spacing()
-{
- QQuickView *canvas = createView(testFile("grid-spacing.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 54.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 78.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 54.0);
- QCOMPARE(five->x(), 54.0);
- QCOMPARE(five->y(), 54.0);
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QCOMPARE(grid->width(), 128.0);
- QCOMPARE(grid->height(), 104.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_row_column_spacing()
-{
- QQuickView *canvas = createView(testFile("grid-row-column-spacing.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 61.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 92.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 57.0);
- QCOMPARE(five->x(), 61.0);
- QCOMPARE(five->y(), 57.0);
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QCOMPARE(grid->width(), 142.0);
- QCOMPARE(grid->height(), 107.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_animated()
-{
- QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- //Note that all animate in
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(one->y(), -100.0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->x(), -100.0);
- QCOMPARE(three->y(), -100.0);
-
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QCOMPARE(four->x(), -100.0);
- QCOMPARE(four->y(), -100.0);
-
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
- QCOMPARE(five->x(), -100.0);
- QCOMPARE(five->y(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QVERIFY(grid);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->y(), -100.0);
- QTRY_COMPARE(two->x(), -100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(four->y(), 0.0);
- QTRY_COMPARE(four->x(), 100.0);
- QTRY_COMPARE(five->y(), 50.0);
- QTRY_COMPARE(five->x(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QCOMPARE(two->isVisible(), true);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 0.0);
- QCOMPARE(five->y(), 50.0);
- //Let the animation complete
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(three->x(), 100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_animated_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- //Note that all animate in
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(one->y(), -100.0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->x(), -100.0);
- QCOMPARE(three->y(), -100.0);
-
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QCOMPARE(four->x(), -100.0);
- QCOMPARE(four->y(), -100.0);
-
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
- QCOMPARE(five->x(), -100.0);
- QCOMPARE(five->y(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QVERIFY(grid);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->y(), -100.0);
- QTRY_COMPARE(two->x(), -100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(four->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(five->y(), 50.0);
- QTRY_COMPARE(five->x(), 100.0);
-
- //Add 'two'
- two->setVisible(true);
- QCOMPARE(two->isVisible(), true);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(one->x(), 100.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 100.0);
- QCOMPARE(five->y(), 50.0);
- //Let the animation complete
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(three->x(), 0.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 100.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_zero_columns()
-{
- QQuickView *canvas = createView(testFile("gridzerocolumns.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 120.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 0.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QCOMPARE(grid->width(), 170.0);
- QCOMPARE(grid->height(), 60.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_propertychanges()
-{
- QQuickView *canvas = createView(testFile("propertychangestest.qml"));
-
- QQuickGrid *grid = qobject_cast<QQuickGrid*>(canvas->rootObject());
- QVERIFY(grid != 0);
- QDeclarativeTransition *rowTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("rowTransition");
- QDeclarativeTransition *columnTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("columnTransition");
-
- QSignalSpy addSpy(grid, SIGNAL(addChanged()));
- QSignalSpy moveSpy(grid, SIGNAL(moveChanged()));
- QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged()));
- QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged()));
-
- QVERIFY(grid);
- QVERIFY(rowTransition);
- QVERIFY(columnTransition);
- QCOMPARE(grid->add(), columnTransition);
- QCOMPARE(grid->move(), columnTransition);
- QCOMPARE(grid->columns(), 4);
- QCOMPARE(grid->rows(), -1);
-
- grid->setAdd(rowTransition);
- grid->setMove(rowTransition);
- QCOMPARE(grid->add(), rowTransition);
- QCOMPARE(grid->move(), rowTransition);
- QCOMPARE(addSpy.count(),1);
- QCOMPARE(moveSpy.count(),1);
-
- grid->setAdd(rowTransition);
- grid->setMove(rowTransition);
- QCOMPARE(addSpy.count(),1);
- QCOMPARE(moveSpy.count(),1);
-
- grid->setAdd(0);
- grid->setMove(0);
- QCOMPARE(addSpy.count(),2);
- QCOMPARE(moveSpy.count(),2);
-
- grid->setColumns(-1);
- grid->setRows(3);
- QCOMPARE(grid->columns(), -1);
- QCOMPARE(grid->rows(), 3);
- QCOMPARE(columnsSpy.count(),1);
- QCOMPARE(rowsSpy.count(),1);
-
- grid->setColumns(-1);
- grid->setRows(3);
- QCOMPARE(columnsSpy.count(),1);
- QCOMPARE(rowsSpy.count(),1);
-
- grid->setColumns(2);
- grid->setRows(2);
- QCOMPARE(columnsSpy.count(),2);
- QCOMPARE(rowsSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_repeater()
-{
- QQuickView *canvas = createView(testFile("repeatertest.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow()
-{
- QQuickView *canvas = createView(testFile("flowtest.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 70.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 70.0);
-
- QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->width(), 90.0);
- QCOMPARE(flow->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("flowtest.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 40.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 20.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 40.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 40.0);
- QCOMPARE(four->y(), 70.0);
- QCOMPARE(five->x(), 30.0);
- QCOMPARE(five->y(), 70.0);
-
- QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->width(), 90.0);
- QCOMPARE(flow->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_topToBottom()
-{
- QQuickView *canvas = createView(testFile("flowtest-toptobottom.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 00.0);
- QCOMPARE(five->x(), 100.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->height(), 90.0);
- QCOMPARE(flow->width(), 150.0);
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QVERIFY(flow);
- QCOMPARE(flow->height(), 90.0);
- QCOMPARE(flow->width(), 150.0);
-
- QCOMPARE(one->x(), 100.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 80.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 40.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_resize()
-{
- QQuickView *canvas = createView(testFile("flowtest.qml"));
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
- root->setWidth(125);
- root->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 70.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_resize_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("flowtest.qml"));
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
- root->setWidth(125);
- root->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QTRY_VERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 75.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 55.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 5.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 75.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 65.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_implicit_resize()
-{
- QQuickView *canvas = createView(testFile("flow-testimplicitsize.qml"));
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlow *flow = canvas->rootObject()->findChild<QQuickFlow*>("flow");
- QVERIFY(flow != 0);
-
- QCOMPARE(flow->width(), 100.0);
- QCOMPARE(flow->height(), 120.0);
-
- canvas->rootObject()->setProperty("flowLayout", 0);
- QCOMPARE(flow->flow(), QQuickFlow::LeftToRight);
- QCOMPARE(flow->width(), 220.0);
- QCOMPARE(flow->height(), 50.0);
-
- canvas->rootObject()->setProperty("flowLayout", 1);
- QCOMPARE(flow->flow(), QQuickFlow::TopToBottom);
- QCOMPARE(flow->width(), 100.0);
- QCOMPARE(flow->height(), 120.0);
-
- canvas->rootObject()->setProperty("flowLayout", 2);
- QCOMPARE(flow->layoutDirection(), Qt::RightToLeft);
- QCOMPARE(flow->width(), 220.0);
- QCOMPARE(flow->height(), 50.0);
-
- delete canvas;
-}
-
-QString warningMessage;
-
-void interceptWarnings(QtMsgType type, const char *msg)
-{
- Q_UNUSED( type );
- warningMessage = msg;
-}
-
-void tst_qquickpositioners::test_conflictinganchors()
-{
- QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
-
- component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nRow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function."));
- delete item;
-
- component.setData("import QtQuick 2.0\nFlow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function."));
- qInstallMsgHandler(oldMsgHandler);
- delete item;
-}
-
-void tst_qquickpositioners::test_mirroring()
-{
- QList<QString> qmlFiles;
- qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml";
- QList<QString> objectNames;
- objectNames << "one" << "two" << "three" << "four" << "five";
-
- foreach (const QString qmlFile, qmlFiles) {
- QQuickView *canvasA = createView(testFile(qmlFile));
- QQuickItem *rootA = qobject_cast<QQuickItem*>(canvasA->rootObject());
-
- QQuickView *canvasB = createView(testFile(qmlFile));
- QQuickItem *rootB = qobject_cast<QQuickItem*>(canvasB->rootObject());
-
- rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
-
- // LTR != RTL
- foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
- QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
- QTRY_VERIFY(itemA->x() != itemB->x());
- }
-
- QDeclarativeProperty enabledProp(rootB, "LayoutMirroring.enabled", qmlContext(rootB));
- enabledProp.write(true);
- QDeclarativeProperty inheritProp(rootB, "LayoutMirroring.childrenInherit", qmlContext(rootB));
- inheritProp.write(true);
-
- // RTL == mirror
- foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
- QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
- QTRY_COMPARE(itemA->x(), itemB->x());
- }
-
- rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight
- rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
-
- // LTR == RTL + mirror
- foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
- QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
- QTRY_COMPARE(itemA->x(), itemB->x());
- }
- delete canvasA;
- delete canvasB;
- }
-}
-
-void tst_qquickpositioners::test_allInvisible()
-{
- //QTBUG-19361
- QQuickView *canvas = createView(testFile("allInvisible.qml"));
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
-
- QQuickRow *row = canvas->rootObject()->findChild<QQuickRow*>("row");
- QVERIFY(row != 0);
- QVERIFY(row->width() == 0);
- QVERIFY(row->height() == 0);
- QQuickColumn *column = canvas->rootObject()->findChild<QQuickColumn*>("column");
- QVERIFY(column != 0);
- QVERIFY(column->width() == 0);
- QVERIFY(column->height() == 0);
-}
-
-void tst_qquickpositioners::test_attachedproperties()
-{
- QFETCH(QString, filename);
-
- QQuickView *canvas = createView(filename);
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickRectangle *greenRect = canvas->rootObject()->findChild<QQuickRectangle *>("greenRect");
- QVERIFY(greenRect != 0);
-
- int posIndex = greenRect->property("posIndex").toInt();
- QVERIFY(posIndex == 0);
- bool isFirst = greenRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == true);
- bool isLast = greenRect->property("isLastItem").toBool();
- QVERIFY(isLast == false);
-
- QQuickRectangle *yellowRect = canvas->rootObject()->findChild<QQuickRectangle *>("yellowRect");
- QVERIFY(yellowRect != 0);
-
- posIndex = yellowRect->property("posIndex").toInt();
- QVERIFY(posIndex == -1);
- isFirst = yellowRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == false);
- isLast = yellowRect->property("isLastItem").toBool();
- QVERIFY(isLast == false);
-
- yellowRect->metaObject()->invokeMethod(yellowRect, "onDemandPositioner");
-
- posIndex = yellowRect->property("posIndex").toInt();
- QVERIFY(posIndex == 1);
- isFirst = yellowRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == false);
- isLast = yellowRect->property("isLastItem").toBool();
- QVERIFY(isLast == true);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_attachedproperties_data()
-{
- QTest::addColumn<QString>("filename");
-
- QTest::newRow("column") << testFile("attachedproperties-column.qml");
- QTest::newRow("row") << testFile("attachedproperties-row.qml");
- QTest::newRow("grid") << testFile("attachedproperties-grid.qml");
- QTest::newRow("flow") << testFile("attachedproperties-flow.qml");
-}
-
-void tst_qquickpositioners::test_attachedproperties_dynamic()
-{
- QQuickView *canvas = createView(testFile("attachedproperties-dynamic.qml"));
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickRow *row = canvas->rootObject()->findChild<QQuickRow *>("pos");
- QVERIFY(row != 0);
-
- QQuickRectangle *rect0 = canvas->rootObject()->findChild<QQuickRectangle *>("rect0");
- QVERIFY(rect0 != 0);
-
- int posIndex = rect0->property("index").toInt();
- QVERIFY(posIndex == 0);
- bool isFirst = rect0->property("firstItem").toBool();
- QVERIFY(isFirst == true);
- bool isLast = rect0->property("lastItem").toBool();
- QVERIFY(isLast == false);
-
- QQuickRectangle *rect1 = canvas->rootObject()->findChild<QQuickRectangle *>("rect1");
- QVERIFY(rect1 != 0);
-
- posIndex = rect1->property("index").toInt();
- QVERIFY(posIndex == 1);
- isFirst = rect1->property("firstItem").toBool();
- QVERIFY(isFirst == false);
- isLast = rect1->property("lastItem").toBool();
- QVERIFY(isLast == true);
-
- row->metaObject()->invokeMethod(row, "createSubRect");
-
- QTRY_VERIFY(rect1->property("index").toInt() == 1);
- QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
- QTRY_VERIFY(rect1->property("lastItem").toBool() == false);
-
- QQuickRectangle *rect2 = canvas->rootObject()->findChild<QQuickRectangle *>("rect2");
- QVERIFY(rect2 != 0);
-
- posIndex = rect2->property("index").toInt();
- QVERIFY(posIndex == 2);
- isFirst = rect2->property("firstItem").toBool();
- QVERIFY(isFirst == false);
- isLast = rect2->property("lastItem").toBool();
- QVERIFY(isLast == true);
-
- row->metaObject()->invokeMethod(row, "destroySubRect");
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QTRY_VERIFY(rect1->property("index").toInt() == 1);
- QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
- QTRY_VERIFY(rect1->property("lastItem").toBool() == true);
-
- delete canvas;
-}
-
-QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->show();
- if (wait)
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- return canvas;
-}
-
-void tst_qquickpositioners::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
-{
- for (int i=0; i<indexLists.count(); i++) {
- QSet<int> current = indexLists[i].value<QList<int> >().toSet();
- if (current != expectedIndexes.toSet())
- qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
- QCOMPARE(current, expectedIndexes.toSet());
- }
-}
-
-void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
-{
- for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
- QVERIFY(it.value().type() == QVariant::Int);
- QString name = it.key();
- int itemIndex = it.value().toInt();
- QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
- if (model.name(itemIndex) != name)
- qDebug() << itemIndex;
- QCOMPARE(model.name(itemIndex), name);
- }
- QCOMPARE(items.count(), expectedIndexes.count());
-}
-
-void tst_qquickpositioners::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
-{
- for (int i=0; i<itemLists.count(); i++) {
- QVERIFY(itemLists[i].type() == QVariant::List);
- QVariantList current = itemLists[i].toList();
- for (int j=0; j<current.count(); j++) {
- QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
- QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
- QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
- }
- QCOMPARE(current.count(), expectedItems.count());
- }
-}
-
-QTEST_MAIN(tst_qquickpositioners)
-
-#include "tst_qquickpositioners.moc"
diff --git a/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro b/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro
deleted file mode 100644
index b791faf78a..0000000000
--- a/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickrepeater
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickrepeater.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testFiles.files = data
-testFiles.path = .
-DEPLOYMENT += testFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp
deleted file mode 100644
index 59322704f5..0000000000
--- a/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp
+++ /dev/null
@@ -1,644 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qlistmodelinterface_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <private/qquickrepeater_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-
-class tst_QQuickRepeater : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickRepeater();
-
-private slots:
- void numberModel();
- void objectList();
- void stringList();
- void dataModel_adding();
- void dataModel_removing();
- void dataModel_changes();
- void itemModel();
- void resetModel();
- void modelChanged();
- void properties();
- void asynchronous();
- void initParent();
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError)
- Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
-
-public:
- TestObject() : QObject(), mError(true), mUseModel(false) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; }
-
- bool useModel() const { return mUseModel; }
- void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
-
-signals:
- void useModelChanged();
-
-private:
- bool mError;
- bool mUseModel;
-};
-
-tst_QQuickRepeater::tst_QQuickRepeater()
-{
-}
-
-void tst_QQuickRepeater::numberModel()
-{
- QQuickView *canvas = createView();
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", 5);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("intmodel.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
-
- QVERIFY(!repeater->itemAt(-1));
- for (int i=0; i<repeater->count(); i++)
- QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
- QVERIFY(!repeater->itemAt(repeater->count()));
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- delete testObject;
- delete canvas;
-}
-
-class MyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int idx READ idx CONSTANT)
-public:
- MyObject(int i) : QObject(), m_idx(i) {}
-
- int idx() const { return m_idx; }
-
- int m_idx;
-};
-
-void tst_QQuickRepeater::objectList()
-{
- QQuickView *canvas = createView();
- QObjectList data;
- for (int i=0; i<100; i++)
- data << new MyObject(i);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", QVariant::fromValue(data));
-
- canvas->setSource(testFileUrl("objlist.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
- QCOMPARE(repeater->property("instantiated").toInt(), 100);
-
- QVERIFY(!repeater->itemAt(-1));
- for (int i=0; i<data.count(); i++)
- QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
- QVERIFY(!repeater->itemAt(data.count()));
-
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
- ctxt->setContextProperty("testData", QVariant::fromValue(data));
- QCOMPARE(addedSpy.count(), data.count());
- QCOMPARE(removedSpy.count(), data.count());
-
- qDeleteAll(data);
- delete canvas;
-}
-
-/*
-The Repeater element creates children at its own position in its parent's
-stacking order. In this test we insert a repeater between two other Text
-elements to test this.
-*/
-void tst_QQuickRepeater::stringList()
-{
- QQuickView *canvas = createView();
-
- QStringList data;
- data << "One";
- data << "Two";
- data << "Three";
- data << "Four";
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", data);
-
- canvas->setSource(testFileUrl("repeater1.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), data.count() + 3);
-
- bool saw_repeater = false;
- for (int i = 0; i < container->childItems().count(); ++i) {
-
- if (i == 0) {
- QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Zero"));
- } else if (i == container->childItems().count() - 2) {
- // The repeater itself
- QQuickRepeater *rep = qobject_cast<QQuickRepeater*>(container->childItems().at(i));
- QCOMPARE(rep, repeater);
- saw_repeater = true;
- continue;
- } else if (i == container->childItems().count() - 1) {
- QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Last"));
- } else {
- QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), data.at(i-1));
- }
- }
- QVERIFY(saw_repeater);
-
- delete canvas;
-}
-
-void tst_QQuickRepeater::dataModel_adding()
-{
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- QaimModel testModel;
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(testFileUrl("repeater2.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QVERIFY(!repeater->itemAt(0));
-
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
-
- // add to empty model
- testModel.addItem("two", "2");
- QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
- addedSpy.clear();
-
- // insert at start
- testModel.insertItem(0, "one", "1");
- QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
- addedSpy.clear();
-
- // insert at end
- testModel.insertItem(2, "four", "4");
- QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
- QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
- addedSpy.clear();
-
- // insert in middle
- testModel.insertItem(2, "three", "3");
- QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
- QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
- addedSpy.clear();
-
- delete testObject;
- addedSpy.clear();
- countSpy.clear();
- delete canvas;
-}
-
-void tst_QQuickRepeater::dataModel_removing()
-{
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- QaimModel testModel;
- testModel.addItem("one", "1");
- testModel.addItem("two", "2");
- testModel.addItem("three", "3");
- testModel.addItem("four", "4");
- testModel.addItem("five", "5");
-
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(testFileUrl("repeater2.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
- QCOMPARE(container->childItems().count(), repeater->count()+1);
-
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
-
- // remove at start
- QQuickItem *item = repeater->itemAt(0);
- QCOMPARE(item, container->childItems().at(0));
-
- testModel.removeItem(0);
- QVERIFY(repeater->itemAt(0) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
- removedSpy.clear();
-
- // remove at end
- int lastIndex = testModel.count()-1;
- item = repeater->itemAt(lastIndex);
- QCOMPARE(item, container->childItems().at(lastIndex));
-
- testModel.removeItem(lastIndex);
- QVERIFY(repeater->itemAt(lastIndex) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex);
- QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
- removedSpy.clear();
-
- // remove from middle
- item = repeater->itemAt(1);
- QCOMPARE(item, container->childItems().at(1));
-
- testModel.removeItem(1);
- QVERIFY(repeater->itemAt(lastIndex) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), 1);
- QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
- removedSpy.clear();
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickRepeater::dataModel_changes()
-{
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- QaimModel testModel;
- testModel.addItem("one", "1");
- testModel.addItem("two", "2");
- testModel.addItem("three", "3");
-
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(testFileUrl("repeater2.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
- QCOMPARE(container->childItems().count(), repeater->count()+1);
-
- // Check that model changes are propagated
- QQuickText *text = findItem<QQuickText>(canvas->rootObject(), "myName", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("two"));
-
- testModel.modifyItem(1, "Item two", "_2");
- text = findItem<QQuickText>(canvas->rootObject(), "myName", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("Item two"));
-
- text = findItem<QQuickText>(canvas->rootObject(), "myNumber", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("_2"));
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickRepeater::itemModel()
-{
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("itemlist.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), 1);
-
- testObject->setUseModel(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QCOMPARE(container->childItems().count(), 4);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item1");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item2");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3");
- QVERIFY(container->childItems().at(3) == repeater);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "switchModel");
- QCOMPARE(container->childItems().count(), 3);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item4");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item5");
- QVERIFY(container->childItems().at(2) == repeater);
-
- testObject->setUseModel(false);
- QCOMPARE(container->childItems().count(), 1);
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickRepeater::resetModel()
-{
- QQuickView *canvas = createView();
-
- QStringList dataA;
- for (int i=0; i<10; i++)
- dataA << QString::number(i);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", dataA);
- canvas->setSource(testFileUrl("repeater1.qml"));
- qApp->processEvents();
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(repeater->count(), dataA.count());
- for (int i=0; i<repeater->count(); i++)
- QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object
-
- QSignalSpy modelChangedSpy(repeater, SIGNAL(modelChanged()));
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
-
- QStringList dataB;
- for (int i=0; i<20; i++)
- dataB << QString::number(i);
-
- // reset context property
- ctxt->setContextProperty("testData", dataB);
- QCOMPARE(repeater->count(), dataB.count());
-
- QCOMPARE(modelChangedSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), dataA.count());
- QCOMPARE(addedSpy.count(), dataB.count());
- for (int i=0; i<dataB.count(); i++) {
- QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
- QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
- }
- modelChangedSpy.clear();
- countSpy.clear();
- removedSpy.clear();
- addedSpy.clear();
-
- // reset via setModel()
- repeater->setModel(dataA);
- QCOMPARE(repeater->count(), dataA.count());
-
- QCOMPARE(modelChangedSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), dataB.count());
- QCOMPARE(addedSpy.count(), dataA.count());
- for (int i=0; i<dataA.count(); i++) {
- QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
- QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
- }
-
- modelChangedSpy.clear();
- countSpy.clear();
- removedSpy.clear();
- addedSpy.clear();
-
- delete canvas;
-}
-
-// QTBUG-17156
-void tst_QQuickRepeater::modelChanged()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("modelChanged.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(rootObject);
- QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
- QVERIFY(repeater);
-
- repeater->setModel(4);
- QCOMPARE(repeater->count(), 4);
- QCOMPARE(repeater->property("itemsCount").toInt(), 4);
- QCOMPARE(repeater->property("itemsFound").toList().count(), 4);
-
- repeater->setModel(10);
- QCOMPARE(repeater->count(), 10);
- QCOMPARE(repeater->property("itemsCount").toInt(), 10);
- QCOMPARE(repeater->property("itemsFound").toList().count(), 10);
-
- delete rootObject;
-}
-
-void tst_QQuickRepeater::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("properties.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(rootObject);
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
- QVERIFY(repeater);
-
- QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
- repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
- repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
-
- QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
-
- QDeclarativeComponent rectComponent(&engine);
- rectComponent.setData("import QtQuick 2.0; Rectangle {}", QUrl::fromLocalFile(""));
-
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
-
- delete rootObject;
-}
-
-void tst_QQuickRepeater::asynchronous()
-{
- QQuickView *canvas = createView();
- canvas->show();
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->setSource(testFileUrl("asyncloader.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootObject);
-
- QQuickItem *container = findItem<QQuickItem>(rootObject, "container");
- QVERIFY(!container);
- while (!container) {
- bool b = false;
- controller.incubateWhile(&b);
- container = findItem<QQuickItem>(rootObject, "container");
- }
-
- QQuickRepeater *repeater = 0;
- while (!repeater) {
- bool b = false;
- controller.incubateWhile(&b);
- repeater = findItem<QQuickRepeater>(rootObject, "repeater");
- }
-
- // items will be created one at a time
- for (int i = 0; i < 10; ++i) {
- QString name("delegate");
- name += QString::number(i);
- QVERIFY(findItem<QQuickItem>(container, name) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(container, name);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- // verify positioning
- for (int i = 0; i < 10; ++i) {
- QString name("delegate");
- name += QString::number(i);
- QQuickItem *item = findItem<QQuickItem>(container, name);
- QTRY_COMPARE(item->y(), i * 50.0);
- }
-
- delete canvas;
-}
-
-void tst_QQuickRepeater::initParent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("initparent.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(rootObject);
-
- QCOMPARE(qvariant_cast<QQuickItem*>(rootObject->property("parentItem")), rootObject);
-}
-
-QTEST_MAIN(tst_QQuickRepeater)
-
-#include "tst_qquickrepeater.moc"
diff --git a/tests/auto/qtquick2/qquickscreen/qquickscreen.pro b/tests/auto/qtquick2/qquickscreen/qquickscreen.pro
deleted file mode 100644
index 6d0a5e1650..0000000000
--- a/tests/auto/qtquick2/qquickscreen/qquickscreen.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickscreen
-SOURCES += tst_qquickscreen.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private testlib quick-private
diff --git a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp b/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp
deleted file mode 100644
index bb687f7596..0000000000
--- a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickView>
-#include <QtGui/QScreen>
-#include "../../shared/util.h"
-
-class tst_qquickscreen : public QDeclarativeDataTest
-{
- Q_OBJECT
-private slots:
- void basicProperties();
-};
-
-void tst_qquickscreen::basicProperties()
-{
- QQuickView view;
- view.setSource(testFileUrl("screen.qml"));
- view.show();
- QTest::qWaitForWindowShown(&view);
-
- QQuickItem* root = view.rootObject();
- QVERIFY(root);
-
- QScreen* screen = view.screen();
- QVERIFY(screen);
-
- QCOMPARE(screen->size().width(), root->property("w").toInt());
- QCOMPARE(screen->size().height(), root->property("h").toInt());
- QCOMPARE(int(screen->orientation()), root->property("curOrientation").toInt());
- QCOMPARE(int(screen->primaryOrientation()), root->property("priOrientation").toInt());
-}
-
-QTEST_MAIN(tst_qquickscreen)
-
-#include "tst_qquickscreen.moc"
diff --git a/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro b/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro
deleted file mode 100644
index de8b247340..0000000000
--- a/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickshadereffect
-SOURCES += tst_qquickshadereffect.cpp
-
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro b/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro
deleted file mode 100644
index 16c20ef75b..0000000000
--- a/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickspritesequence
-SOURCES += tst_qquickspritesequence.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp b/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp
deleted file mode 100644
index 848d6a343c..0000000000
--- a/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include "../../shared/util.h"
-#include <QtQuick/qquickview.h>
-#include <private/qquickspritesequence_p.h>
-
-class tst_qquickspritesequence : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickspritesequence(){}
-
-private slots:
- void test_properties();
- void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine
-};
-
-void tst_qquickspritesequence::test_properties()
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(testFileUrl("basic.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QVERIFY(canvas->rootObject());
- QQuickSpriteSequence* sprite = canvas->rootObject()->findChild<QQuickSpriteSequence*>("sprite");
- QVERIFY(sprite);
-
- QVERIFY(sprite->running());
- QVERIFY(sprite->interpolate());
-
- sprite->setRunning(false);
- QVERIFY(!sprite->running());
- sprite->setInterpolate(false);
- QVERIFY(!sprite->interpolate());
-
- delete canvas;
-}
-
-void tst_qquickspritesequence::test_framerateAdvance()
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(testFileUrl("advance.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QVERIFY(canvas->rootObject());
- QQuickSpriteSequence* sprite = canvas->rootObject()->findChild<QQuickSpriteSequence*>("sprite");
- QVERIFY(sprite);
-
- QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState"));
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickspritesequence)
-
-#include "tst_qquickspritesequence.moc"
diff --git a/tests/auto/qtquick2/qquicktext/qquicktext.pro b/tests/auto/qtquick2/qquicktext/qquicktext.pro
deleted file mode 100644
index b483bebc61..0000000000
--- a/tests/auto/qtquick2/qquicktext/qquicktext.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquicktext
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquicktext.cpp
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private widgets-private opengl-private network testlib
diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
deleted file mode 100644
index 3fd05dbcb2..0000000000
--- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
+++ /dev/null
@@ -1,2484 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QTextDocument>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <private/qquicktext_p_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <QFontMetrics>
-#include <QGraphicsSceneMouseEvent>
-#include <qmath.h>
-#include <QtQuick/QQuickView>
-#include <private/qapplication_p.h>
-#include <limits.h>
-#include <QtGui/QMouseEvent>
-#include "../../shared/util.h"
-#include "testhttpserver.h"
-
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-
-Q_DECLARE_METATYPE(QQuickText::TextFormat)
-
-class tst_qquicktext : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquicktext();
-
-private slots:
- void text();
- void width();
- void wrap();
- void elide();
- void multilineElide_data();
- void multilineElide();
- void textFormat();
-
- void alignments_data();
- void alignments();
-
- void baseUrl();
- void embeddedImages_data();
- void embeddedImages();
-
- void lineCount();
- void lineHeight();
-
- // ### these tests may be trivial
- void horizontalAlignment();
- void horizontalAlignment_RightToLeft();
- void verticalAlignment();
- void font();
- void style();
- void color();
- void smooth();
-
- // QDeclarativeFontValueType
- void weight();
- void underline();
- void overline();
- void strikeout();
- void capitalization();
- void letterSpacing();
- void wordSpacing();
-
- void clickLink();
-
- void implicitSize_data();
- void implicitSize();
- void contentSize();
-
- void lineLaidOut();
-
- void imgTagsBaseUrl_data();
- void imgTagsBaseUrl();
- void imgTagsAlign_data();
- void imgTagsAlign();
- void imgTagsMultipleImages();
- void imgTagsElide();
- void imgTagsUpdates();
- void imgTagsError();
- void fontSizeMode_data();
- void fontSizeMode();
- void fontSizeModeMultiline_data();
- void fontSizeModeMultiline();
- void multilengthStrings_data();
- void multilengthStrings();
- void fontFormatSizes_data();
- void fontFormatSizes();
-
-private:
- QStringList standard;
- QStringList richText;
-
- QStringList horizontalAlignmentmentStrings;
- QStringList verticalAlignmentmentStrings;
-
- QList<Qt::Alignment> verticalAlignmentments;
- QList<Qt::Alignment> horizontalAlignmentments;
-
- QStringList styleStrings;
- QList<QQuickText::TextStyle> styles;
-
- QStringList colorStrings;
-
- QDeclarativeEngine engine;
-
- QQuickView *createView(const QString &filename);
-};
-
-tst_qquicktext::tst_qquicktext()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "the quick brown fox\n jumped over the lazy dog";
-
- richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
- << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
-
- horizontalAlignmentmentStrings << "AlignLeft"
- << "AlignRight"
- << "AlignHCenter";
-
- verticalAlignmentmentStrings << "AlignTop"
- << "AlignBottom"
- << "AlignVCenter";
-
- horizontalAlignmentments << Qt::AlignLeft
- << Qt::AlignRight
- << Qt::AlignHCenter;
-
- verticalAlignmentments << Qt::AlignTop
- << Qt::AlignBottom
- << Qt::AlignVCenter;
-
- styleStrings << "Normal"
- << "Outline"
- << "Raised"
- << "Sunken";
-
- styles << QQuickText::Normal
- << QQuickText::Outline
- << QQuickText::Raised
- << QQuickText::Sunken;
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
- //
- // need a different test to do alpha channel test
- // << "#AA0011DD"
- // << "#00F16B11";
- //
-}
-
-QQuickView *tst_qquicktext::createView(const QString &filename)
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- return canvas;
-}
-
-void tst_qquicktext::text()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), QString(""));
- QVERIFY(textObject->width() == 0);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
-
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), standard.at(i));
- QVERIFY(textObject->width() > 0);
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QString expected = richText.at(i);
- QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
- QVERIFY(textObject->width() > 0);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 0.);
-
- delete textObject;
- }
-
- bool requiresUnhintedMetrics = !qmlDisableDistanceField();
-
- for (int i = 0; i < standard.size(); i++)
- {
- QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
-
- QFont f;
- qreal metricWidth = 0.0;
-
- if (requiresUnhintedMetrics) {
- QString s = standard.at(i);
- s.replace(QLatin1Char('\n'), QChar::LineSeparator);
-
- QTextLayout layout(s);
- layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
- {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
-
- layout.beginLayout();
- forever {
- QTextLine line = layout.createLine();
- if (!line.isValid())
- break;
- }
-
- layout.endLayout();
-
- metricWidth = layout.boundingRect().width();
- } else {
- QFontMetricsF fm(f);
- metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- }
-
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->boundingRect().width() > 0);
- QCOMPARE(textObject->width(), qreal(metricWidth));
- QVERIFY(textObject->textFormat() == QQuickText::AutoText); // setting text doesn't change format
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
-
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\"; textFormat: Text.RichText }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QVERIFY(textObject != 0);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->extra.isAllocated());
-
- QTextDocument *doc = textPrivate->extra->doc;
- QVERIFY(doc != 0);
-
- QCOMPARE(int(textObject->width()), int(doc->idealWidth()));
- QVERIFY(textObject->textFormat() == QQuickText::RichText);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::wrap()
-{
- int textHeight = 0;
- // for specified width and wrap set true
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- textHeight = textObject->height();
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->wrapMode() == QQuickText::WordWrap);
- QCOMPARE(textObject->width(), 300.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- int oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- qreal oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
-
- delete textObject;
- }
-
- // richtext again with a fixed height
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->implicitHeight() > textHeight);
-
- qreal oldHeight = textObject->implicitHeight();
- textObject->setWidth(100);
- QVERIFY(textObject->implicitHeight() < oldHeight);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::elide()
-{
- for (QQuickText::TextElideMode m = QQuickText::ElideLeft; m<=QQuickText::ElideNone; m=QQuickText::TextElideMode(int(m)+1)) {
- const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
- QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
-
- // XXX Poor coverage.
-
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(("import QtQuick 2.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- if (m != QQuickText::ElideNone && !standard.at(i).contains('\n'))
- QVERIFY(textObject->contentWidth() <= textObject->width());
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- if (m != QQuickText::ElideNone && standard.at(i).contains("<br>"))
- QVERIFY(textObject->contentWidth() <= textObject->width());
-
- delete textObject;
- }
- }
-}
-
-void tst_qquicktext::multilineElide_data()
-{
- QTest::addColumn<QQuickText::TextFormat>("format");
- QTest::newRow("plain") << QQuickText::PlainText;
- QTest::newRow("styled") << QQuickText::StyledText;
-}
-
-void tst_qquicktext::multilineElide()
-{
- QFETCH(QQuickText::TextFormat, format);
- QQuickView *canvas = createView(testFile("multilineelide.qml"));
-
- QQuickText *myText = qobject_cast<QQuickText*>(canvas->rootObject());
- QVERIFY(myText != 0);
- myText->setTextFormat(format);
-
- QCOMPARE(myText->lineCount(), 3);
- QCOMPARE(myText->truncated(), true);
-
- qreal lineHeight = myText->contentHeight() / 3.;
-
- // Set a valid height greater than the truncated content height and ensure the line count is
- // unchanged.
- myText->setHeight(200);
- QCOMPARE(myText->lineCount(), 3);
- QCOMPARE(myText->truncated(), true);
-
- // reduce size and ensure fewer lines are drawn
- myText->setHeight(lineHeight * 2);
- QCOMPARE(myText->lineCount(), 2);
-
- myText->setHeight(lineHeight);
- QCOMPARE(myText->lineCount(), 1);
-
- myText->setHeight(5);
- QCOMPARE(myText->lineCount(), 1);
-
- myText->setHeight(lineHeight * 3);
- QCOMPARE(myText->lineCount(), 3);
-
- // remove max count and show all lines.
- myText->setHeight(1000);
- myText->resetMaximumLineCount();
-
- QCOMPARE(myText->truncated(), false);
-
- // reduce size again
- myText->setHeight(lineHeight * 2);
- QCOMPARE(myText->lineCount(), 2);
- QCOMPARE(myText->truncated(), true);
-
- // change line height
- myText->setLineHeight(1.1);
- QCOMPARE(myText->lineCount(), 1);
-
- delete canvas;
-}
-
-void tst_qquicktext::textFormat()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::RichText);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->richText == true);
-
- delete textObject;
- }
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"<b>Hello</b>\" }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::AutoText);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->styledText == true);
-
- delete textObject;
- }
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::PlainText);
-
- delete textObject;
- }
-}
-
-
-void tst_qquicktext::alignments_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<int>("vAlign");
- QTest::addColumn<QString>("expectfile");
-
- QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << testFile("alignments_lt.png");
- QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << testFile("alignments_rt.png");
- QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << testFile("alignments_ct.png");
-
- QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << testFile("alignments_lb.png");
- QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << testFile("alignments_rb.png");
- QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << testFile("alignments_cb.png");
-
- QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << testFile("alignments_lc.png");
- QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << testFile("alignments_rc.png");
- QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << testFile("alignments_cc.png");
-}
-
-
-void tst_qquicktext::alignments()
-{
- QSKIP("Text alignment pixmap comparison tests will not work with scenegraph");
-#if (0)// No widgets in scenegraph
- QFETCH(int, hAlign);
- QFETCH(int, vAlign);
- QFETCH(QString, expectfile);
-
- QQuickView *canvas = createView(testFile("alignments.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWait(50);
- QTRY_COMPARE(QGuiApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QObject *ob = canvas->rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- ob->setProperty("verticalAlignment",vAlign);
- QTRY_COMPARE(ob->property("running").toBool(),false);
- QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
- actual.fill(qRgb(255,255,255));
- QPainter p(&actual);
- canvas->render(&p);
-
- QImage expect(expectfile);
- if (QGuiApplicationPrivate::graphics_system_name == "raster" || QGuiApplicationPrivate::graphics_system_name == "") {
- QCOMPARE(actual,expect);
- }
- delete canvas;
-#endif
-}
-
-//the alignment tests may be trivial o.oa
-void tst_qquicktext::horizontalAlignment()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
-}
-
-void tst_qquicktext::horizontalAlignment_RightToLeft()
-{
- QQuickView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml"));
- QQuickText *text = canvas->rootObject()->findChild<QQuickText*>("text");
- QVERIFY(text != 0);
- canvas->show();
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(text);
- QVERIFY(textPrivate != 0);
-
- QTRY_VERIFY(textPrivate->layout.lineCount());
-
- // implicit alignment should follow the reading direction of RTL text
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // explicitly left aligned text
- text->setHAlign(QQuickText::AlignLeft);
- QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
- // explicitly right aligned text
- text->setHAlign(QQuickText::AlignRight);
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // change to rich text
- QString textString = text->text();
- text->setText(QString("<i>") + textString + QString("</i>"));
- text->setTextFormat(QQuickText::RichText);
- text->resetHAlign();
-
- // implicitly aligned rich text should follow the reading direction of text
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->extra.isAllocated());
- QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft);
-
- // explicitly left aligned rich text
- text->setHAlign(QQuickText::AlignLeft);
- QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignRight);
-
- // explicitly right aligned rich text
- text->setHAlign(QQuickText::AlignRight);
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft);
-
- text->setText(textString);
- text->setTextFormat(QQuickText::PlainText);
-
- // explicitly center aligned
- text->setHAlign(QQuickText::AlignHCenter);
- QCOMPARE(text->hAlign(), QQuickText::AlignHCenter);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2);
-
- // reseted alignment should go back to following the text reading direction
- text->resetHAlign();
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // mirror the text item
- QQuickItemPrivate::get(text)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // mirrored explicitly right aligned behaves as left aligned
- text->setHAlign(QQuickText::AlignRight);
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), QQuickText::AlignLeft);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
- // mirrored explicitly left aligned behaves as right aligned
- text->setHAlign(QQuickText::AlignLeft);
- QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // disable mirroring
- QQuickItemPrivate::get(text)->setLayoutMirror(false);
- text->resetHAlign();
-
- // English text should be implicitly left aligned
- text->setText("Hello world!");
- QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from QInputMethod::inputDirection()
- text->setText("");
- QCOMPARE(text->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
- QQuickText::AlignLeft : QQuickText::AlignRight);
- text->setHAlign(QQuickText::AlignRight);
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
-
- delete canvas;
-
- // alignment of Text with no text set to it
- QString componentStr = "import QtQuick 2.0\nText {}";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
- QQuickText::AlignLeft : QQuickText::AlignRight);
- delete textObject;
-}
-
-void tst_qquicktext::verticalAlignment()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
-}
-
-void tst_qquicktext::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 2.0\nText { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().pointSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.pixelSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().pixelSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().bold(), true);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().italic(), true);
- QCOMPARE(textObject->font().bold(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString("Helvetica"));
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString(""));
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::style()
-{
- //test style
- for (int i = 0; i < styles.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE((int)textObject->style(), (int)styles.at(i));
- QCOMPARE(textObject->styleColor(), QColor("white"));
-
- delete textObject;
- }
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QRectF brPre = textObject->boundingRect();
- textObject->setStyle(QQuickText::Outline);
- QRectF brPost = textObject->boundingRect();
-
- QVERIFY(brPre.width() < brPost.width());
- QVERIFY(brPre.height() < brPost.height());
-
- delete textObject;
-}
-
-void tst_qquicktext::color()
-{
- //test style
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor("black"));
- QCOMPARE(textObject->linkColor(), QColor("blue"));
-
- delete textObject;
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
- // default color to black?
- QCOMPARE(textObject->color(), QColor("black"));
- QCOMPARE(textObject->linkColor(), QColor("blue"));
-
- delete textObject;
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->styleColor(), QColor("black"));
- QCOMPARE(textObject->color(), QColor("black"));
- QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(i)));
-
- delete textObject;
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- for (int j = 0; j < colorStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { "
- "color: \"" + colorStrings.at(i) + "\"; "
- "styleColor: \"" + colorStrings.at(j) + "\"; "
- "linkColor: \"" + colorStrings.at(j) + "\"; "
- "text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
- QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(j)));
-
- delete textObject;
- }
- }
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), testColor);
-
- delete textObject;
- } {
- QString colorStr = "#001234";
- QColor testColor(colorStr);
-
- QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(colorChanged()));
-
- QCOMPARE(textObject->color(), testColor);
- textObject->setColor(testColor);
- QCOMPARE(textObject->color(), testColor);
- QCOMPARE(spy.count(), 0);
-
- testColor = QColor("black");
- textObject->setColor(testColor);
- QCOMPARE(textObject->color(), testColor);
- QCOMPARE(spy.count(), 1);
- } {
- QString colorStr = "#001234";
- QColor testColor(colorStr);
-
- QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(styleColorChanged()));
-
- QCOMPARE(textObject->styleColor(), testColor);
- textObject->setStyleColor(testColor);
- QCOMPARE(textObject->styleColor(), testColor);
- QCOMPARE(spy.count(), 0);
-
- testColor = QColor("black");
- textObject->setStyleColor(testColor);
- QCOMPARE(textObject->styleColor(), testColor);
- QCOMPARE(spy.count(), 1);
- } {
- QString colorStr = "#001234";
- QColor testColor(colorStr);
-
- QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(linkColorChanged()));
-
- QCOMPARE(textObject->linkColor(), testColor);
- textObject->setLinkColor(testColor);
- QCOMPARE(textObject->linkColor(), testColor);
- QCOMPARE(spy.count(), 0);
-
- testColor = QColor("black");
- textObject->setLinkColor(testColor);
- QCOMPARE(textObject->linkColor(), testColor);
- QCOMPARE(spy.count(), 1);
- }
-}
-
-void tst_qquicktext::smooth()
-{
- for (int i = 0; i < standard.size(); i++)
- {
- {
- QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
-
- delete textObject;
- }
- }
- for (int i = 0; i < richText.size(); i++)
- {
- {
- QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
-
- delete textObject;
- }
- }
-}
-
-void tst_qquicktext::weight()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Normal);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Bold);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::underline()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { font.underline: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), true);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::overline()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { font.overline: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), true);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::strikeout()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { font.strikeout: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), true);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::capitalization()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::MixedCase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllUppercase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllLowercase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::SmallCaps);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::Capitalize);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::letterSpacing()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 0.0);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), -2.);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 3.);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::wordSpacing()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 0.0);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), -50.);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 200.);
-
- delete textObject;
- }
-}
-
-
-
-
-class EventSender : public QQuickItem
-{
-public:
- void sendEvent(QMouseEvent *event) {
- if (event->type() == QEvent::MouseButtonPress)
- mousePressEvent(event);
- else if (event->type() == QEvent::MouseButtonRelease)
- mouseReleaseEvent(event);
- else
- qWarning() << "Trying to send unsupported event type";
- }
-};
-
-class LinkTest : public QObject
-{
- Q_OBJECT
-public:
- LinkTest() {}
-
- QString link;
-
-public slots:
- void linkClicked(QString l) { link = l; }
-};
-
-void tst_qquicktext::clickLink()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
-
- LinkTest test;
- QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
-
- {
- QMouseEvent me(QEvent::MouseButtonPress,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me);
-
- }
-
- {
- QMouseEvent me(QEvent::MouseButtonRelease,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me);
-
- }
-
-
- QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::baseUrl()
-{
- QUrl localUrl("file:///tests/text.qml");
- QUrl remoteUrl("http://qt.nokia.com/test.qml");
-
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\n Text {}", localUrl);
- QQuickText *textObject = qobject_cast<QQuickText *>(textComponent.create());
-
- QCOMPARE(textObject->baseUrl(), localUrl);
-
- QSignalSpy spy(textObject, SIGNAL(baseUrlChanged()));
-
- textObject->setBaseUrl(localUrl);
- QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 0);
-
- textObject->setBaseUrl(remoteUrl);
- QCOMPARE(textObject->baseUrl(), remoteUrl);
- QCOMPARE(spy.count(), 1);
-
- textObject->resetBaseUrl();
- QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktext::embeddedImages_data()
-{
- QTest::addColumn<QUrl>("qmlfile");
- QTest::addColumn<QString>("error");
- QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
- QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
- << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString();
- QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
- QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
- << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
-}
-
-void tst_qquicktext::embeddedImages()
-{
- // Tests QTBUG-9900
-
- QFETCH(QUrl, qmlfile);
- QFETCH(QString, error);
-
- TestHTTPServer server(14453);
- server.serveDirectory(testFile("http"));
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
-
- QDeclarativeComponent textComponent(&engine, qmlfile);
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
-
- QTRY_COMPARE(textObject->resourcesLoading(), 0);
-
- QPixmap pm(testFile("http/exists.png"));
- if (error.isEmpty()) {
- QCOMPARE(textObject->width(), double(pm.width()));
- QCOMPARE(textObject->height(), double(pm.height()));
- } else {
- QVERIFY(16 != pm.width()); // check test is effective
- QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
- QCOMPARE(textObject->height(), 16.0);
- }
-
- delete textObject;
-}
-
-void tst_qquicktext::lineCount()
-{
- QQuickView *canvas = createView(testFile("lineCount.qml"));
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QVERIFY(myText->lineCount() > 1);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->maximumLineCount(), INT_MAX);
-
- myText->setMaximumLineCount(2);
- QCOMPARE(myText->lineCount(), 2);
- QCOMPARE(myText->truncated(), true);
- QCOMPARE(myText->maximumLineCount(), 2);
-
- myText->resetMaximumLineCount();
- QCOMPARE(myText->maximumLineCount(), INT_MAX);
- QCOMPARE(myText->truncated(), false);
-
- myText->setElideMode(QQuickText::ElideRight);
- myText->setMaximumLineCount(2);
- QCOMPARE(myText->lineCount(), 2);
- QCOMPARE(myText->truncated(), true);
- QCOMPARE(myText->maximumLineCount(), 2);
-
- delete canvas;
-}
-
-void tst_qquicktext::lineHeight()
-{
- QQuickView *canvas = createView(testFile("lineHeight.qml"));
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QVERIFY(myText->lineHeight() == 1);
- QVERIFY(myText->lineHeightMode() == QQuickText::ProportionalHeight);
-
- qreal h = myText->height();
- myText->setLineHeight(1.5);
- QCOMPARE(myText->height(), qreal(qCeil(h * 1.5)));
-
- myText->setLineHeightMode(QQuickText::FixedHeight);
- myText->setLineHeight(20);
- QCOMPARE(myText->height(), myText->lineCount() * 20.0);
-
- myText->setText("Lorem ipsum sit <b>amet</b>, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum.");
- myText->setLineHeightMode(QQuickText::ProportionalHeight);
- myText->setLineHeight(1.0);
-
- qreal h2 = myText->height();
- myText->setLineHeight(2.0);
- QVERIFY(myText->height() == h2 * 2.0);
-
- myText->setLineHeightMode(QQuickText::FixedHeight);
- myText->setLineHeight(10);
- QCOMPARE(myText->height(), myText->lineCount() * 10.0);
-
- delete canvas;
-}
-
-void tst_qquicktext::implicitSize_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("width");
- QTest::addColumn<QString>("wrap");
- QTest::addColumn<QString>("elide");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideNone";
- QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" <<" 50" << "Text.NoWrap" << "Text.ElideNone";
- QTest::newRow("plain, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideNone";
- QTest::newRow("plain, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideRight";
- QTest::newRow("plain, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideRight";
- QTest::newRow("richtext, 0 width") << "<b>The quick red fox jumped over the lazy brown dog</b>" <<" 0" << "Text.NoWrap" << "Text.ElideNone";
- QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideNone";
- QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "50" << "Text.Wrap" << "Text.ElideNone";
- QTest::newRow("plain_wrap, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideNone";
- QTest::newRow("plain_wrap, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideRight";
- QTest::newRow("plain_wrap, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideRight";
- QTest::newRow("richtext_wrap, 0 width") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "0" << "Text.Wrap" << "Text.ElideNone";
-}
-
-void tst_qquicktext::implicitSize()
-{
- QFETCH(QString, text);
- QFETCH(QString, width);
- QFETCH(QString, wrap);
- QFETCH(QString, elide);
- QString componentStr = "import QtQuick 2.0\nText { "
- "text: \"" + text + "\"; "
- "width: " + width + "; "
- "wrapMode: " + wrap + "; "
- "elide: " + elide + "; "
- "maximumLineCount: 1 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- delete textObject;
-}
-
-void tst_qquicktext::contentSize()
-{
- QString componentStr = "import QtQuick 2.0\nText { width: 75; height: 16; font.pixelSize: 10 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
-
- textObject->setText("The quick red fox jumped over the lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
-
- textObject->setWrapMode(QQuickText::WordWrap);
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
-
- textObject->setElideMode(QQuickText::ElideRight);
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 3);
- int spyCount = 3;
- qreal elidedWidth = textObject->contentWidth();
-
- textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- // this text probably won't have the same elided width, but it's not guaranteed.
- if (textObject->contentWidth() != elidedWidth)
- QCOMPARE(spy.count(), ++spyCount);
- else
- QCOMPARE(spy.count(), spyCount);
-
- textObject->setElideMode(QQuickText::ElideNone);
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), ++spyCount);
-}
-
-void tst_qquicktext::lineLaidOut()
-{
- QQuickView *canvas = createView(testFile("lineLayout.qml"));
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
- QVERIFY(textPrivate != 0);
-
- QVERIFY(!textPrivate->extra.isAllocated());
-
-#if defined(Q_OS_MAC)
- QVERIFY(myText->lineCount() == textPrivate->linesRects.count());
-#endif
-
- for (int i = 0; i < textPrivate->layout.lineCount(); ++i) {
- QRectF r = textPrivate->layout.lineAt(i).rect();
- QVERIFY(r.width() == i * 15);
- if (i >= 30)
- QVERIFY(r.x() == r.width() + 30);
- if (i >= 60) {
- QVERIFY(r.x() == r.width() * 2 + 60);
- QVERIFY(r.height() == 20);
- }
- }
-
- delete canvas;
-}
-
-void tst_qquicktext::imgTagsBaseUrl_data()
-{
- QTest::addColumn<QUrl>("src");
- QTest::addColumn<QUrl>("baseUrl");
- QTest::addColumn<QUrl>("contextUrl");
- QTest::addColumn<qreal>("imgHeight");
-
- QTest::newRow("absolute local")
- << testFileUrl("images/heart200.png")
- << QUrl()
- << QUrl()
- << 181.;
- QTest::newRow("relative local context 1")
- << QUrl("images/heart200.png")
- << QUrl()
- << testFileUrl("/app.qml")
- << 181.;
- QTest::newRow("relative local context 2")
- << QUrl("heart200.png")
- << QUrl()
- << testFileUrl("images/app.qml")
- << 181.;
- QTest::newRow("relative local base 1")
- << QUrl("images/heart200.png")
- << testFileUrl("")
- << testFileUrl("nonexistant/app.qml")
- << 181.;
- QTest::newRow("relative local base 2")
- << QUrl("heart200.png")
- << testFileUrl("images/")
- << testFileUrl("nonexistant/app.qml")
- << 181.;
- QTest::newRow("base relative to local context")
- << QUrl("heart200.png")
- << testFileUrl("images/")
- << testFileUrl("/app.qml")
- << 181.;
-
- QTest::newRow("absolute remote")
- << QUrl("http://127.0.0.1:14453/images/heart200.png")
- << QUrl()
- << QUrl()
- << 181.;
- QTest::newRow("relative remote base 1")
- << QUrl("images/heart200.png")
- << QUrl("http://127.0.0.1:14453/")
- << testFileUrl("nonexistant/app.qml")
- << 181.;
- QTest::newRow("relative remote base 2")
- << QUrl("heart200.png")
- << QUrl("http://127.0.0.1:14453/images/")
- << testFileUrl("nonexistant/app.qml")
- << 181.;
-}
-
-void tst_qquicktext::imgTagsBaseUrl()
-{
- QFETCH(QUrl, src);
- QFETCH(QUrl, baseUrl);
- QFETCH(QUrl, contextUrl);
- QFETCH(qreal, imgHeight);
-
- TestHTTPServer server(14453);
- server.serveDirectory(testFile(""));
-
- QByteArray baseUrlFragment;
- if (!baseUrl.isEmpty())
- baseUrlFragment = "; baseUrl: \"" + baseUrl.toEncoded() + "\"";
- QByteArray componentStr = "import QtQuick 2.0\nText { text: \"This is a test <img src=\\\"" + src.toEncoded() + "\\\">\"" + baseUrlFragment + " }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr, contextUrl);
- QScopedPointer<QObject> object(component.create());
- QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
- QVERIFY(textObject);
-
- QCoreApplication::processEvents();
-
- QTRY_COMPARE(textObject->height(), imgHeight);
-}
-
-void tst_qquicktext::imgTagsAlign_data()
-{
- QTest::addColumn<QString>("src");
- QTest::addColumn<int>("imgHeight");
- QTest::addColumn<QString>("align");
- QTest::newRow("heart-bottom") << "data/images/heart200.png" << 181 << "bottom";
- QTest::newRow("heart-middle") << "data/images/heart200.png" << 181 << "middle";
- QTest::newRow("heart-top") << "data/images/heart200.png" << 181 << "top";
- QTest::newRow("starfish-bottom") << "data/images/starfish_2.png" << 217 << "bottom";
- QTest::newRow("starfish-middle") << "data/images/starfish_2.png" << 217 << "middle";
- QTest::newRow("starfish-top") << "data/images/starfish_2.png" << 217 << "top";
-}
-
-void tst_qquicktext::imgTagsAlign()
-{
- QFETCH(QString, src);
- QFETCH(int, imgHeight);
- QFETCH(QString, align);
- QString componentStr = "import QtQuick 2.0\nText { text: \"This is a test <img src=\\\"" + src + "\\\" align=\\\"" + align + "\\\"> of image.\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->height() == imgHeight);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
-
- QRectF br = textPrivate->layout.boundingRect();
- if (align == "bottom")
- QVERIFY(br.y() == imgHeight - br.height());
- else if (align == "middle")
- QVERIFY(br.y() == imgHeight / 2.0 - br.height() / 2.0);
- else if (align == "top")
- QVERIFY(br.y() == 0);
-
- delete textObject;
-}
-
-void tst_qquicktext::imgTagsMultipleImages()
-{
- QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish<img src=\\\"data/images/starfish_2.png\\\" width=\\\"60\\\" height=\\\"60\\\" > and another one<img src=\\\"data/images/heart200.png\\\" width=\\\"85\\\" height=\\\"85\\\">.\" }";
-
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->height() == 85);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->visibleImgTags.count() == 2);
-
- delete textObject;
-}
-
-void tst_qquicktext::imgTagsElide()
-{
- QQuickView *canvas = createView(testFile("imgTagsElide.qml"));
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->visibleImgTags.count() == 0);
- myText->setMaximumLineCount(20);
- QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1);
-
- delete myText;
- delete canvas;
-}
-
-void tst_qquicktext::imgTagsUpdates()
-{
- QQuickView *canvas = createView(testFile("imgTagsUpdates.qml"));
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QSignalSpy spy(myText, SIGNAL(contentSizeChanged()));
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
- QVERIFY(textPrivate != 0);
-
- myText->setText("This is a heart<img src=\"images/heart200.png\">.");
- QVERIFY(textPrivate->visibleImgTags.count() == 1);
- QVERIFY(spy.count() == 1);
-
- myText->setMaximumLineCount(2);
- myText->setText("This is another heart<img src=\"images/heart200.png\">.");
- QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1);
-
- // if maximumLineCount is set and the img tag doesn't have an explicit size
- // we relayout twice.
- QVERIFY(spy.count() == 3);
-
- delete myText;
- delete canvas;
-}
-
-void tst_qquicktext::imgTagsError()
-{
- QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish<img src=\\\"data/images/starfish_2.pn\\\" width=\\\"60\\\" height=\\\"60\\\">.\" }";
-
- QDeclarativeComponent textComponent(&engine);
- QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML Text: Cannot open: file:data/images/starfish_2.pn");
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- delete textObject;
-}
-
-void tst_qquicktext::fontSizeMode_data()
-{
- QTest::addColumn<QString>("text");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog";
- QTest::newRow("styled") << "<b>The quick red fox jumped over the lazy brown dog</b>";
-}
-
-void tst_qquicktext::fontSizeMode()
-{
- QFETCH(QString, text);
-
- QScopedPointer<QQuickView> canvas(createView(testFile("fontSizeMode.qml")));
- canvas->show();
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- myText->setText(text);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- qreal originalWidth = myText->contentWidth();
- qreal originalHeight = myText->contentHeight();
-
- // The original text unwrapped should exceed the width of the item.
- QVERIFY(originalWidth > myText->width());
- QVERIFY(originalHeight < myText->height());
-
- QFont font = myText->font();
- font.setPixelSize(64);
-
- myText->setFont(font);
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Font size reduced to fit within the width of the item.
- qreal horizontalFitWidth = myText->contentWidth();
- qreal horizontalFitHeight = myText->contentHeight();
- QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
- QVERIFY(horizontalFitHeight <= myText->height() + 2);
-
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Font size increased to fill the height of the item.
- qreal verticalFitHeight = myText->contentHeight();
- QVERIFY(myText->contentWidth() > myText->width());
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight > originalHeight);
-
- // Elide won't affect the height of a single line with VerticalFit but will crop the width.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as HorizontalFit with no wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::FixedSize);
- myText->setWrapMode(QQuickText::Wrap);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- originalWidth = myText->contentWidth();
- originalHeight = myText->contentHeight();
-
- // The original text wrapped should exceed the height of the item.
- QVERIFY(originalWidth <= myText->width() + 2);
- QVERIFY(originalHeight > myText->height());
-
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
- // same size as without text wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // VerticalFit should reduce the size to the wrapped text within the vertical height.
- verticalFitHeight = myText->contentHeight();
- qreal verticalFitWidth = myText->contentWidth();
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight < originalHeight);
-
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::FixedSize);
- myText->setMaximumLineCount(2);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- // The original text wrapped should exceed the height of the item.
- QVERIFY(originalWidth <= myText->width() + 2);
- QVERIFY(originalHeight > myText->height());
-
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
- // same size as without text wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // VerticalFit should reduce the size to the wrapped text within the vertical height.
- verticalFitHeight = myText->contentHeight();
- verticalFitWidth = myText->contentWidth();
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight < originalHeight);
-
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-}
-
-void tst_qquicktext::fontSizeModeMultiline_data()
-{
- QTest::addColumn<QString>("text");
- QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog";
- QTest::newRow("styledtext") << "<b>The quick red fox jumped<br/> over the lazy brown dog</b>";
-}
-
-void tst_qquicktext::fontSizeModeMultiline()
-{
- QFETCH(QString, text);
-
- QScopedPointer<QQuickView> canvas(createView(testFile("fontSizeMode.qml")));
- canvas->show();
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- myText->setText(text);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- qreal originalWidth = myText->contentWidth();
- qreal originalHeight = myText->contentHeight();
- QCOMPARE(myText->lineCount(), 2);
-
- // The original text unwrapped should exceed the width and height of the item.
- QVERIFY(originalWidth > myText->width());
- QVERIFY(originalHeight > myText->height());
-
- QFont font = myText->font();
- font.setPixelSize(64);
-
- myText->setFont(font);
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Font size reduced to fit within the width of the item.
- QCOMPARE(myText->lineCount(), 2);
- qreal horizontalFitWidth = myText->contentWidth();
- qreal horizontalFitHeight = myText->contentHeight();
- QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
- QVERIFY(horizontalFitHeight > myText->height());
-
- // Right eliding will remove the last line
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QCOMPARE(myText->lineCount(), 1);
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
-
- // Left or middle eliding wont have any effect.
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Font size reduced to fit within the height of the item.
- qreal verticalFitWidth = myText->contentWidth();
- qreal verticalFitHeight = myText->contentHeight();
- QVERIFY(verticalFitWidth <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
-
- // Elide will have no effect.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with no wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::FixedSize);
- myText->setWrapMode(QQuickText::Wrap);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- originalWidth = myText->contentWidth();
- originalHeight = myText->contentHeight();
-
- // The original text wrapped should exceed the height of the item.
- QVERIFY(originalWidth <= myText->width() + 2);
- QVERIFY(originalHeight > myText->height());
-
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
- // same size as without text wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- // Text will be elided vertically with HorizontalFit
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // VerticalFit should reduce the size to the wrapped text within the vertical height.
- verticalFitHeight = myText->contentHeight();
- verticalFitWidth = myText->contentWidth();
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight < originalHeight);
-
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::FixedSize);
- myText->setMaximumLineCount(2);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- // The original text wrapped should exceed the height of the item.
- QVERIFY(originalWidth <= myText->width() + 2);
- QVERIFY(originalHeight > myText->height());
-
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
- // same size as without text wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // VerticalFit should reduce the size to the wrapped text within the vertical height.
- verticalFitHeight = myText->contentHeight();
- verticalFitWidth = myText->contentWidth();
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight < originalHeight);
-
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-}
-
-void tst_qquicktext::multilengthStrings_data()
-{
- QTest::addColumn<QString>("source");
- QTest::newRow("No Wrap") << testFile("multilengthStrings.qml");
- QTest::newRow("Wrap") << testFile("multilengthStringsWrapped.qml");
-}
-
-void tst_qquicktext::multilengthStrings()
-{
- QFETCH(QString, source);
-
- QScopedPointer<QQuickView> canvas(createView(source));
- canvas->show();
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- const QString longText = "the quick brown fox jumped over the lazy dog";
- const QString mediumText = "the brown fox jumped over the dog";
- const QString shortText = "fox jumped dog";
-
- myText->setText(longText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- const qreal longWidth = myText->contentWidth();
- const qreal longHeight = myText->contentHeight();
-
- myText->setText(mediumText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- const qreal mediumWidth = myText->contentWidth();
- const qreal mediumHeight = myText->contentHeight();
-
- myText->setText(shortText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- const qreal shortWidth = myText->contentWidth();
- const qreal shortHeight = myText->contentHeight();
-
- myText->setElideMode(QQuickText::ElideRight);
- myText->setText(longText + QLatin1Char('\x9c') + mediumText + QLatin1Char('\x9c') + shortText);
-
- myText->setSize(QSizeF(longWidth, longHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- QCOMPARE(myText->contentWidth(), longWidth);
- QCOMPARE(myText->contentHeight(), longHeight);
- QCOMPARE(myText->truncated(), false);
-
- myText->setSize(QSizeF(mediumWidth, mediumHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- QCOMPARE(myText->contentWidth(), mediumWidth);
- QCOMPARE(myText->contentHeight(), mediumHeight);
- QCOMPARE(myText->truncated(), true);
-
- myText->setSize(QSizeF(shortWidth, shortHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- QCOMPARE(myText->contentWidth(), shortWidth);
- QCOMPARE(myText->contentHeight(), shortHeight);
- QCOMPARE(myText->truncated(), true);
-}
-
-void tst_qquicktext::fontFormatSizes_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("textWithTag");
- QTest::addColumn<bool>("fontIsBigger");
-
- QTest::newRow("fs1") << "Hello world!" << "Hello <font size=\"1\">world</font>!" << false;
- QTest::newRow("fs2") << "Hello world!" << "Hello <font size=\"2\">world</font>!" << false;
- QTest::newRow("fs3") << "Hello world!" << "Hello <font size=\"3\">world</font>!" << false;
- QTest::newRow("fs4") << "Hello world!" << "Hello <font size=\"4\">world</font>!" << true;
- QTest::newRow("fs5") << "Hello world!" << "Hello <font size=\"5\">world</font>!" << true;
- QTest::newRow("fs6") << "Hello world!" << "Hello <font size=\"6\">world</font>!" << true;
- QTest::newRow("fs7") << "Hello world!" << "Hello <font size=\"7\">world</font>!" << true;
- QTest::newRow("h1") << "This is<br/>a font<br/> size test." << "This is <h1>a font</h1> size test." << true;
- QTest::newRow("h2") << "This is<br/>a font<br/> size test." << "This is <h2>a font</h2> size test." << true;
- QTest::newRow("h3") << "This is<br/>a font<br/> size test." << "This is <h3>a font</h3> size test." << true;
- QTest::newRow("h4") << "This is<br/>a font<br/> size test." << "This is <h4>a font</h4> size test." << true;
- QTest::newRow("h5") << "This is<br/>a font<br/> size test." << "This is <h5>a font</h5> size test." << false;
- QTest::newRow("h6") << "This is<br/>a font<br/> size test." << "This is <h6>a font</h6> size test." << false;
-}
-
-void tst_qquicktext::fontFormatSizes()
-{
- QFETCH(QString, text);
- QFETCH(QString, textWithTag);
- QFETCH(bool, fontIsBigger);
-
- QQuickView *view = new QQuickView;
- {
- view->setSource(testFileUrl("pointFontSizes.qml"));
- view->show();
-
- QQuickText *qtext = view->rootObject()->findChild<QQuickText*>("text");
- QQuickText *qtextWithTag = view->rootObject()->findChild<QQuickText*>("textWithTag");
- QVERIFY(qtext != 0);
- QVERIFY(qtextWithTag != 0);
-
- qtext->setText(text);
- qtextWithTag->setText(textWithTag);
-
- for (int size = 6; size < 100; size += 4) {
- view->rootObject()->setProperty("pointSize", size);
- if (fontIsBigger)
- QVERIFY(qtext->height() <= qtextWithTag->height());
- else
- QVERIFY(qtext->height() >= qtextWithTag->height());
- }
- }
-
- {
- view->setSource(testFileUrl("pixelFontSizes.qml"));
- QQuickText *qtext = view->rootObject()->findChild<QQuickText*>("text");
- QQuickText *qtextWithTag = view->rootObject()->findChild<QQuickText*>("textWithTag");
- QVERIFY(qtext != 0);
- QVERIFY(qtextWithTag != 0);
-
- qtext->setText(text);
- qtextWithTag->setText(textWithTag);
-
- for (int size = 6; size < 100; size += 4) {
- view->rootObject()->setProperty("pixelSize", size);
- if (fontIsBigger)
- QVERIFY(qtext->height() <= qtextWithTag->height());
- else
- QVERIFY(qtext->height() >= qtextWithTag->height());
- }
- }
- delete view;
-}
-
-QTEST_MAIN(tst_qquicktext)
-
-#include "tst_qquicktext.moc"
diff --git a/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro b/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro
deleted file mode 100644
index 6f74761b7b..0000000000
--- a/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquicktextedit
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquicktextedit.cpp \
- ../../shared/testhttpserver.cpp
-
-HEADERS += ../../shared/testhttpserver.h
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private network widgets-private testlib
diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
deleted file mode 100644
index e2673c1f17..0000000000
--- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
+++ /dev/null
@@ -1,3881 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include "../../shared/testhttpserver.h"
-#include <math.h>
-#include <QFile>
-#include <QTextDocument>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtGui/qguiapplication.h>
-#include <private/qquicktextedit_p.h>
-#include <private/qquicktextedit_p_p.h>
-#include <private/qquicktext_p_p.h>
-#include <QFontMetrics>
-#include <QtQuick/QQuickView>
-#include <QDir>
-#include <QStyle>
-#include <QInputMethod>
-#include <QClipboard>
-#include <QMimeData>
-#include <private/qquicktextcontrol_p.h>
-#include "../../shared/util.h"
-#include "../../shared/platforminputcontext.h"
-#include <private/qinputmethod_p.h>
-
-#ifdef Q_OS_MAC
-#include <Carbon/Carbon.h>
-#endif
-
-
-Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode)
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-
-QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
-{
- // XXX This will be replaced by some clever persistent platform image store.
- QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory();
- 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;
-}
-
-typedef QPair<int, QChar> Key;
-
-class tst_qquicktextedit : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_qquicktextedit();
-
-private slots:
- void cleanup();
- void text();
- void width();
- void wrap();
- void textFormat();
- void alignments();
- void alignments_data();
-
- // ### these tests may be trivial
- void hAlign();
- void hAlign_RightToLeft();
- void vAlign();
- void font();
- void color();
- void textMargin();
- void persistentSelection();
- void focusOnPress();
- void selection();
- void isRightToLeft_data();
- void isRightToLeft();
- void keySelection();
- void moveCursorSelection_data();
- void moveCursorSelection();
- void moveCursorSelectionSequence_data();
- void moveCursorSelectionSequence();
- void mouseSelection_data();
- void mouseSelection();
- void mouseSelectionMode_data();
- void mouseSelectionMode();
- void dragMouseSelection();
- void inputMethodHints();
-
- void positionAt();
-
- void linkActivated();
-
- void cursorDelegate_data();
- void cursorDelegate();
- void cursorVisible();
- void delegateLoading_data();
- void delegateLoading();
- void navigation();
- void readOnly();
- void copyAndPaste();
- void canPaste();
- void canPasteEmpty();
- void textInput();
- void inputMethodUpdate();
- void openInputPanel();
- void geometrySignals();
- void pastingRichText_QTBUG_14003();
- void implicitSize_data();
- void implicitSize();
- void contentSize();
-
- void preeditCursorRectangle();
- void inputMethodComposing();
- void cursorRectangleSize();
-
- void getText_data();
- void getText();
- void getFormattedText_data();
- void getFormattedText();
- void insert_data();
- void insert();
- void remove_data();
- void remove();
-
- void keySequence_data();
- void keySequence();
-
- void undo_data();
- void undo();
- void redo_data();
- void redo();
- void undo_keypressevents_data();
- void undo_keypressevents();
-
- void baseUrl();
- void embeddedImages();
- void embeddedImages_data();
-
- void emptytags_QTBUG_22058();
-
-private:
- void simulateKeys(QWindow *window, const QList<Key> &keys);
- void simulateKeys(QWindow *window, const QKeySequence &sequence);
-
- void simulateKey(QQuickView *, int key, Qt::KeyboardModifiers modifiers = 0);
-
- QStringList standard;
- QStringList richText;
-
- QStringList hAlignmentStrings;
- QStringList vAlignmentStrings;
-
- QList<Qt::Alignment> vAlignments;
- QList<Qt::Alignment> hAlignments;
-
- QStringList colorStrings;
-
- QDeclarativeEngine engine;
-};
-
-typedef QList<int> IntList;
-Q_DECLARE_METATYPE(IntList)
-
-typedef QList<Key> KeyList;
-Q_DECLARE_METATYPE(KeyList)
-
-Q_DECLARE_METATYPE(QQuickTextEdit::TextFormat)
-
-void tst_qquicktextedit::simulateKeys(QWindow *window, const QList<Key> &keys)
-{
- for (int i = 0; i < keys.count(); ++i) {
- const int key = keys.at(i).first;
- const int modifiers = key & Qt::KeyboardModifierMask;
- const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
-
- QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
- QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
-
- QGuiApplication::sendEvent(window, &press);
- QGuiApplication::sendEvent(window, &release);
- }
-}
-
-void tst_qquicktextedit::simulateKeys(QWindow *window, const QKeySequence &sequence)
-{
- for (int i = 0; i < sequence.count(); ++i) {
- const int key = sequence[i];
- const int modifiers = key & Qt::KeyboardModifierMask;
-
- QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers));
- }
-}
-
-QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
-{
- for (int i = 0; i < sequence.count(); ++i)
- keys << Key(sequence[i], QChar());
- return keys;
-}
-
-template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
-{
- for (int i = 0; i < N - 1; ++i) {
- int key = QTest::asciiToKey(characters[i]);
- QChar character = QLatin1Char(characters[i]);
- keys << Key(key, character);
- }
- return keys;
-}
-
-QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
-{
- keys << Key(key, QChar());
- return keys;
-}
-
-tst_qquicktextedit::tst_qquicktextedit()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "the quick brown fox\n jumped over the lazy dog"
- << "Hello, world!"
- << "!dlrow ,olleH";
-
- richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
- << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
-
- hAlignmentStrings << "AlignLeft"
- << "AlignRight"
- << "AlignHCenter";
-
- vAlignmentStrings << "AlignTop"
- << "AlignBottom"
- << "AlignVCenter";
-
- hAlignments << Qt::AlignLeft
- << Qt::AlignRight
- << Qt::AlignHCenter;
-
- vAlignments << Qt::AlignTop
- << Qt::AlignBottom
- << Qt::AlignVCenter;
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
- //
- // need a different test to do alpha channel test
- // << "#AA0011DD"
- // << "#00F16B11";
- //
-}
-
-void tst_qquicktextedit::cleanup()
-{
- // ensure not even skipped tests with custom input context leave it dangling
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = 0;
-}
-
-void tst_qquicktextedit::text()
-{
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), QString(""));
- QCOMPARE(textEditObject->length(), 0);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), standard.at(i));
- QCOMPARE(textEditObject->length(), standard.at(i).length());
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
-
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
-
- QString expected = richText.at(i);
- expected.replace(QRegExp("\\\\(.)"),"\\1");
- QCOMPARE(textEditObject->text(), expected);
- QCOMPARE(textEditObject->length(), expected.length());
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
-
- QString actual = textEditObject->text();
- QString expected = standard.at(i);
- actual.remove(QRegExp(".*<body[^>]*>"));
- actual.remove(QRegExp("(<[^>]*>)+"));
- expected.remove("\n");
- QCOMPARE(actual.simplified(), expected);
- QCOMPARE(textEditObject->length(), expected.length());
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QString actual = textEditObject->text();
- QString expected = richText.at(i);
- actual.replace(QRegExp(".*<body[^>]*>"),"");
- actual.replace(QRegExp("(<[^>]*>)+"),"<>");
- expected.replace(QRegExp("(<[^>]*>)+"),"<>");
- QCOMPARE(actual.simplified(),expected.simplified());
-
- expected.replace("<>", " ");
- QCOMPARE(textEditObject->length(), expected.simplified().length());
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), standard.at(i));
- QCOMPARE(textEditObject->length(), standard.at(i).length());
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QString actual = textEditObject->text();
- QString expected = richText.at(i);
- actual.replace(QRegExp(".*<body[^>]*>"),"");
- actual.replace(QRegExp("(<[^>]*>)+"),"<>");
- expected.replace(QRegExp("(<[^>]*>)+"),"<>");
- QCOMPARE(actual.simplified(),expected.simplified());
-
- expected.replace("<>", " ");
- QCOMPARE(textEditObject->length(), expected.simplified().length());
- }
-}
-
-void tst_qquicktextedit::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 0.0);
- }
-
- bool requiresUnhintedMetrics = !qmlDisableDistanceField();
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QString s = standard.at(i);
- s.replace(QLatin1Char('\n'), QChar::LineSeparator);
-
- QTextLayout layout(s);
- layout.setFont(textEditObject->font());
- layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
- if (requiresUnhintedMetrics) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
-
- layout.beginLayout();
- forever {
- QTextLine line = layout.createLine();
- if (!line.isValid())
- break;
- }
-
- layout.endLayout();
-
- qreal metricWidth = layout.boundingRect().width();
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), metricWidth);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QTextDocument document;
- document.setHtml(richText.at(i));
- document.setDocumentMargin(0);
- if (requiresUnhintedMetrics)
- document.setUseDesignMetrics(true);
-
- qreal documentWidth = document.idealWidth();
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), documentWidth);
- }
-}
-
-void tst_qquicktextedit::wrap()
-{
- // for specified width and wrap set true
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
-}
-
-void tst_qquicktextedit::textFormat()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickTextEdit::RichText);
- }
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickTextEdit::PlainText);
- }
-}
-
-void tst_qquicktextedit::alignments_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<int>("vAlign");
- QTest::addColumn<QString>("expectfile");
-
- 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) << "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) << "alignments_lc";
- QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc";
- QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc";
-}
-
-
-void tst_qquicktextedit::alignments()
-{
- QSKIP("Image comparison of text is almost guaranteed to fail during development");
-
- QFETCH(int, hAlign);
- QFETCH(int, vAlign);
- QFETCH(QString, expectfile);
-
- QQuickView canvas(testFileUrl("alignments.qml"));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QObject *ob = canvas.rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- ob->setProperty("verticalAlignment",vAlign);
- QTRY_COMPARE(ob->property("running").toBool(),false);
- QImage actual = canvas.grabFrameBuffer();
-
- expectfile = createExpectedFileIfNotFound(expectfile, actual);
-
- QImage expect(expectfile);
-
- QCOMPARE(actual,expect);
-}
-
-
-//the alignment tests may be trivial o.oa
-void tst_qquicktextedit::hAlign()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < hAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < hAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
-}
-
-void tst_qquicktextedit::hAlign_RightToLeft()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
- QQuickTextEdit *textEdit = canvas.rootObject()->findChild<QQuickTextEdit*>("text");
- QVERIFY(textEdit != 0);
- canvas.show();
-
- const QString rtlText = textEdit->text();
-
- // implicit alignment should follow the reading direction of text
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // explicitly left aligned
- textEdit->setHAlign(QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- // explicitly right aligned
- textEdit->setHAlign(QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- QString textString = textEdit->text();
- textEdit->setText(QString("<i>") + textString + QString("</i>"));
- textEdit->resetHAlign();
-
- // implicitly aligned rich text should follow the reading direction of RTL text
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // explicitly left aligned rich text
- textEdit->setHAlign(QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- // explicitly right aligned rich text
- textEdit->setHAlign(QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- textEdit->setText(textString);
-
- // explicitly center aligned
- textEdit->setHAlign(QQuickTextEdit::AlignHCenter);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignHCenter);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // reseted alignment should go back to following the text reading direction
- textEdit->resetHAlign();
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // mirror the text item
- QQuickItemPrivate::get(textEdit)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // mirrored explicitly right aligned behaves as left aligned
- textEdit->setHAlign(QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- // mirrored explicitly left aligned behaves as right aligned
- textEdit->setHAlign(QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // disable mirroring
- QQuickItemPrivate::get(textEdit)->setLayoutMirror(false);
- textEdit->resetHAlign();
-
- // English text should be implicitly left aligned
- textEdit->setText("Hello world!");
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- textEdit->setText(QString());
- { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
-
- // Clear pre-edit text. TextEdit should maybe do this itself on setText, but that may be
- // redundant as an actual input method may take care of it.
- { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
-
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from qApp->inputMethod()->inputDirection
- textEdit->setText("");
- platformInputContext.setInputDirection(Qt::LeftToRight);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- QSignalSpy cursorRectangleSpy(textEdit, SIGNAL(cursorRectangleChanged()));
-
- platformInputContext.setInputDirection(Qt::RightToLeft);
- QCOMPARE(cursorRectangleSpy.count(), 1);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // set input direction while having content
- platformInputContext.setInputDirection(Qt::LeftToRight);
- textEdit->setText("a");
- textEdit->setCursorPosition(1);
- platformInputContext.setInputDirection(Qt::RightToLeft);
- QTest::keyClick(&canvas, Qt::Key_Backspace);
- QVERIFY(textEdit->text().isEmpty());
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2);
-
- // input direction changed while not having focus
- platformInputContext.setInputDirection(Qt::LeftToRight);
- textEdit->setFocus(false);
- platformInputContext.setInputDirection(Qt::RightToLeft);
- textEdit->setFocus(true);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2);
-
- textEdit->setHAlign(QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-}
-
-void tst_qquicktextedit::vAlign()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < vAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < vAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(
- "import QtQuick 2.0\n"
- "TextEdit { width: 100; height: 100; text: \"Hello World\" }", QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
-
- QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignTop);
- QVERIFY(textEditObject->cursorRectangle().bottom() < 50);
- QVERIFY(textEditObject->positionToRectangle(0).bottom() < 50);
-
- // bottom aligned
- textEditObject->setVAlign(QQuickTextEdit::AlignBottom);
- QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignBottom);
- QVERIFY(textEditObject->cursorRectangle().top() > 50);
- QVERIFY(textEditObject->positionToRectangle(0).top() > 50);
-
- // explicitly center aligned
- textEditObject->setVAlign(QQuickTextEdit::AlignVCenter);
- QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignVCenter);
- QVERIFY(textEditObject->cursorRectangle().top() < 50);
- QVERIFY(textEditObject->cursorRectangle().bottom() > 50);
- QVERIFY(textEditObject->positionToRectangle(0).top() < 50);
- QVERIFY(textEditObject->positionToRectangle(0).bottom() > 50);
-}
-
-void tst_qquicktextedit::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().pointSize(), 40);
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().bold(), true);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().italic(), true);
- QCOMPARE(textEditObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString(""));
- }
-}
-
-void tst_qquicktextedit::color()
-{
- //test initial color
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QQuickTextEditPrivate *textEditPrivate = static_cast<QQuickTextEditPrivate*>(QQuickItemPrivate::get(textEditObject));
-
- QVERIFY(textEditObject);
- QVERIFY(textEditPrivate);
- QVERIFY(textEditPrivate->control);
- QCOMPARE(textEditPrivate->color, QColor("black"));
- }
- //test normal
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
- }
-
- //test selection
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i)));
- }
-
- //test selected text
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), testColor);
- }
-}
-
-void tst_qquicktextedit::textMargin()
-{
- for (qreal i=0; i<=10; i+=0.3) {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->textMargin(), i);
- }
-}
-
-void tst_qquicktextedit::persistentSelection()
-{
- QQuickView canvas(testFileUrl("persistentSelection.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
- canvas.requestActivateWindow();
-
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(edit);
- QVERIFY(edit->hasActiveFocus());
-
- QSignalSpy spy(edit, SIGNAL(persistentSelectionChanged(bool)));
-
- QCOMPARE(edit->persistentSelection(), false);
-
- edit->setPersistentSelection(false);
- QCOMPARE(edit->persistentSelection(), false);
- QCOMPARE(spy.count(), 0);
-
- edit->select(1, 4);
- QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
-
- edit->setFocus(false);
- QCOMPARE(edit->property("selected").toString(), QString());
-
- edit->setFocus(true);
- QCOMPARE(edit->property("selected").toString(), QString());
-
- edit->setPersistentSelection(true);
- QCOMPARE(edit->persistentSelection(), true);
- QCOMPARE(spy.count(), 1);
-
- edit->select(1, 4);
- QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
-
- edit->setFocus(false);
- QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
-
- edit->setFocus(true);
- QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
-
-}
-
-void tst_qquicktextedit::focusOnPress()
-{
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), true);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), false);
- }
-}
-
-void tst_qquicktextedit::selection()
-{
- QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
-
-
- //Test selection follows cursor
- for (int i=0; i<= testStr.size(); i++) {
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorPosition(), i);
- QCOMPARE(textEditObject->selectionStart(), i);
- QCOMPARE(textEditObject->selectionEnd(), i);
- QVERIFY(textEditObject->selectedText().isNull());
- }
-
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- // Verify invalid positions are ignored.
- textEditObject->setCursorPosition(-1);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- textEditObject->setCursorPosition(textEditObject->text().count()+1);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- //Test selection
- for (int i=0; i<= testStr.size(); i++) {
- textEditObject->select(0,i);
- QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
- }
- for (int i=0; i<= testStr.size(); i++) {
- textEditObject->select(i,testStr.size());
- QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
- }
-
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- //Test Error Ignoring behaviour
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(-10,0);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(100,101);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,-10);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,100);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(-10,0);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(100,101);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(0,-10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(0,100);
- QVERIFY(textEditObject->selectedText().size() == 10);
-
- textEditObject->deselect();
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->deselect();
- QVERIFY(textEditObject->selectedText().isNull());
-}
-
-void tst_qquicktextedit::isRightToLeft_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("emptyString");
- QTest::addColumn<bool>("firstCharacter");
- QTest::addColumn<bool>("lastCharacter");
- QTest::addColumn<bool>("middleCharacter");
- QTest::addColumn<bool>("startString");
- QTest::addColumn<bool>("midString");
- QTest::addColumn<bool>("endString");
-
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
- QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
- QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
- QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
- QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
- QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
-}
-
-void tst_qquicktextedit::isRightToLeft()
-{
- QFETCH(QString, text);
- QFETCH(bool, emptyString);
- QFETCH(bool, firstCharacter);
- QFETCH(bool, lastCharacter);
- QFETCH(bool, middleCharacter);
- QFETCH(bool, startString);
- QFETCH(bool, midString);
- QFETCH(bool, endString);
-
- QQuickTextEdit textEdit;
- textEdit.setText(text);
-
- // first test that the right string is delivered to the QString::isRightToLeft()
- QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
-
- // then test that the feature actually works
- QCOMPARE(textEdit.isRightToLeft(0,0), emptyString);
- QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter);
- QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
- QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
- QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), startString);
- QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), midString);
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), endString);
-}
-
-void tst_qquicktextedit::keySelection()
-{
- QQuickView canvas(testFileUrl("navigation.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
-
- QSignalSpy spy(input, SIGNAL(selectionChanged()));
-
- simulateKey(&canvas, Qt::Key_Right, Qt::ShiftModifier);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString("a"));
- QCOMPARE(spy.count(), 1);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 2);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 2);
-
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(spy.count(), 2);
- simulateKey(&canvas, Qt::Key_Left, Qt::ShiftModifier);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString("a"));
- QCOMPARE(spy.count(), 3);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 4);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 4);
-}
-
-void tst_qquicktextedit::moveCursorSelection_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition");
- QTest::addColumn<QQuickTextEdit::SelectionMode>("mode");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<bool>("reversible");
-
- QTest::newRow("(t)he|characters")
- << standard[0] << 0 << 1 << QQuickTextEdit::SelectCharacters << 0 << 1 << true;
- QTest::newRow("do(g)|characters")
- << standard[0] << 43 << 44 << QQuickTextEdit::SelectCharacters << 43 << 44 << true;
- QTest::newRow("jum(p)ed|characters")
- << standard[0] << 23 << 24 << QQuickTextEdit::SelectCharacters << 23 << 24 << true;
- QTest::newRow("jumped( )over|characters")
- << standard[0] << 26 << 27 << QQuickTextEdit::SelectCharacters << 26 << 27 << true;
- QTest::newRow("(the )|characters")
- << standard[0] << 0 << 4 << QQuickTextEdit::SelectCharacters << 0 << 4 << true;
- QTest::newRow("( dog)|characters")
- << standard[0] << 40 << 44 << QQuickTextEdit::SelectCharacters << 40 << 44 << true;
- QTest::newRow("( jumped )|characters")
- << standard[0] << 19 << 27 << QQuickTextEdit::SelectCharacters << 19 << 27 << true;
- QTest::newRow("th(e qu)ick|characters")
- << standard[0] << 2 << 6 << QQuickTextEdit::SelectCharacters << 2 << 6 << true;
- QTest::newRow("la(zy d)og|characters")
- << standard[0] << 38 << 42 << QQuickTextEdit::SelectCharacters << 38 << 42 << true;
- QTest::newRow("jum(ped ov)er|characters")
- << standard[0] << 23 << 29 << QQuickTextEdit::SelectCharacters << 23 << 29 << true;
- QTest::newRow("()the|characters")
- << standard[0] << 0 << 0 << QQuickTextEdit::SelectCharacters << 0 << 0 << true;
- QTest::newRow("dog()|characters")
- << standard[0] << 44 << 44 << QQuickTextEdit::SelectCharacters << 44 << 44 << true;
- QTest::newRow("jum()ped|characters")
- << standard[0] << 23 << 23 << QQuickTextEdit::SelectCharacters << 23 << 23 << true;
-
- QTest::newRow("<(t)he>|words")
- << standard[0] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 3 << true;
- QTest::newRow("<do(g)>|words")
- << standard[0] << 43 << 44 << QQuickTextEdit::SelectWords << 41 << 44 << true;
- QTest::newRow("<jum(p)ed>|words")
- << standard[0] << 23 << 24 << QQuickTextEdit::SelectWords << 20 << 26 << true;
- QTest::newRow("<jumped( )>over|words")
- << standard[0] << 26 << 27 << QQuickTextEdit::SelectWords << 20 << 27 << false;
- QTest::newRow("jumped<( )over>|words,reversed")
- << standard[0] << 27 << 26 << QQuickTextEdit::SelectWords << 26 << 31 << false;
- QTest::newRow("<(the )>quick|words")
- << standard[0] << 0 << 4 << QQuickTextEdit::SelectWords << 0 << 4 << false;
- QTest::newRow("<(the )quick>|words,reversed")
- << standard[0] << 4 << 0 << QQuickTextEdit::SelectWords << 0 << 9 << false;
- QTest::newRow("<lazy( dog)>|words")
- << standard[0] << 40 << 44 << QQuickTextEdit::SelectWords << 36 << 44 << false;
- QTest::newRow("lazy<( dog)>|words,reversed")
- << standard[0] << 44 << 40 << QQuickTextEdit::SelectWords << 40 << 44 << false;
- QTest::newRow("<fox( jumped )>over|words")
- << standard[0] << 19 << 27 << QQuickTextEdit::SelectWords << 16 << 27 << false;
- QTest::newRow("fox<( jumped )over>|words,reversed")
- << standard[0] << 27 << 19 << QQuickTextEdit::SelectWords << 19 << 31 << false;
- QTest::newRow("<th(e qu)ick>|words")
- << standard[0] << 2 << 6 << QQuickTextEdit::SelectWords << 0 << 9 << true;
- QTest::newRow("<la(zy d)og|words>")
- << standard[0] << 38 << 42 << QQuickTextEdit::SelectWords << 36 << 44 << true;
- QTest::newRow("<jum(ped ov)er>|words")
- << standard[0] << 23 << 29 << QQuickTextEdit::SelectWords << 20 << 31 << true;
- QTest::newRow("<()>the|words")
- << standard[0] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true;
- QTest::newRow("dog<()>|words")
- << standard[0] << 44 << 44 << QQuickTextEdit::SelectWords << 44 << 44 << true;
- QTest::newRow("jum<()>ped|words")
- << standard[0] << 23 << 23 << QQuickTextEdit::SelectWords << 23 << 23 << true;
-
- QTest::newRow("Hello<(,)> |words")
- << standard[2] << 5 << 6 << QQuickTextEdit::SelectWords << 5 << 6 << true;
- QTest::newRow("Hello<(, )>world|words")
- << standard[2] << 5 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello<(, )world>|words,reversed")
- << standard[2] << 7 << 5 << QQuickTextEdit::SelectWords << 5 << 12 << false;
- QTest::newRow("<Hel(lo, )>world|words")
- << standard[2] << 3 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false;
- QTest::newRow("<Hel(lo, )world>|words,reversed")
- << standard[2] << 7 << 3 << QQuickTextEdit::SelectWords << 0 << 12 << false;
- QTest::newRow("<Hel(lo)>,|words")
- << standard[2] << 3 << 5 << QQuickTextEdit::SelectWords << 0 << 5 << true;
- QTest::newRow("Hello<()>,|words")
- << standard[2] << 5 << 5 << QQuickTextEdit::SelectWords << 5 << 5 << true;
- QTest::newRow("Hello,<()>|words")
- << standard[2] << 6 << 6 << QQuickTextEdit::SelectWords << 6 << 6 << true;
- QTest::newRow("Hello<,( )>world|words")
- << standard[2] << 6 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello,<( )world>|words,reversed")
- << standard[2] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world)>|words")
- << standard[2] << 6 << 12 << QQuickTextEdit::SelectWords << 5 << 12 << false;
- QTest::newRow("Hello,<( world)>|words,reversed")
- << standard[2] << 12 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world!)>|words")
- << standard[2] << 6 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << false;
- QTest::newRow("Hello,<( world!)>|words,reversed")
- << standard[2] << 13 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false;
- QTest::newRow("Hello<(, world!)>|words")
- << standard[2] << 5 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << true;
- QTest::newRow("world<(!)>|words")
- << standard[2] << 12 << 13 << QQuickTextEdit::SelectWords << 12 << 13 << true;
- QTest::newRow("world!<()>)|words")
- << standard[2] << 13 << 13 << QQuickTextEdit::SelectWords << 13 << 13 << true;
- QTest::newRow("world<()>!)|words")
- << standard[2] << 12 << 12 << QQuickTextEdit::SelectWords << 12 << 12 << true;
-
- QTest::newRow("<(,)>olleH |words")
- << standard[3] << 7 << 8 << QQuickTextEdit::SelectWords << 7 << 8 << true;
- QTest::newRow("<dlrow( ,)>olleH|words")
- << standard[3] << 6 << 8 << QQuickTextEdit::SelectWords << 1 << 8 << false;
- QTest::newRow("dlrow<( ,)>olleH|words,reversed")
- << standard[3] << 8 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false;
- QTest::newRow("<dlrow( ,ol)leH>|words")
- << standard[3] << 6 << 10 << QQuickTextEdit::SelectWords << 1 << 13 << false;
- QTest::newRow("dlrow<( ,ol)leH>|words,reversed")
- << standard[3] << 10 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false;
- QTest::newRow(",<(ol)leH>,|words")
- << standard[3] << 8 << 10 << QQuickTextEdit::SelectWords << 8 << 13 << true;
- QTest::newRow(",<()>olleH|words")
- << standard[3] << 8 << 8 << QQuickTextEdit::SelectWords << 8 << 8 << true;
- QTest::newRow("<()>,olleH|words")
- << standard[3] << 7 << 7 << QQuickTextEdit::SelectWords << 7 << 7 << true;
- QTest::newRow("<dlrow( )>,olleH|words")
- << standard[3] << 6 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false;
- QTest::newRow("dlrow<( ),>olleH|words,reversed")
- << standard[3] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false;
- QTest::newRow("<(dlrow )>,olleH|words")
- << standard[3] << 1 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false;
- QTest::newRow("<(dlrow ),>olleH|words,reversed")
- << standard[3] << 7 << 1 << QQuickTextEdit::SelectWords << 1 << 8 << false;
- QTest::newRow("<(!dlrow )>,olleH|words")
- << standard[3] << 0 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false;
- QTest::newRow("<(!dlrow ),>olleH|words,reversed")
- << standard[3] << 7 << 0 << QQuickTextEdit::SelectWords << 0 << 8 << false;
- QTest::newRow("(!dlrow ,)olleH|words")
- << standard[3] << 0 << 8 << QQuickTextEdit::SelectWords << 0 << 8 << true;
- QTest::newRow("<(!)>dlrow|words")
- << standard[3] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 1 << true;
- QTest::newRow("<()>!dlrow|words")
- << standard[3] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true;
- QTest::newRow("!<()>dlrow|words")
- << standard[3] << 1 << 1 << QQuickTextEdit::SelectWords << 1 << 1 << true;
-}
-
-void tst_qquicktextedit::moveCursorSelection()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition);
- QFETCH(QQuickTextEdit::SelectionMode, mode);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(bool, reversible);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit*>(textinputComponent.create());
- QVERIFY(texteditObject != 0);
-
- texteditObject->setCursorPosition(cursorPosition);
- texteditObject->moveCursorSelection(movePosition, mode);
-
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(texteditObject->selectionStart(), selectionStart);
- QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
-
- if (reversible) {
- texteditObject->setCursorPosition(movePosition);
- texteditObject->moveCursorSelection(cursorPosition, mode);
-
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(texteditObject->selectionStart(), selectionStart);
- QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
- }
-}
-
-void tst_qquicktextedit::moveCursorSelectionSequence_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition1");
- QTest::addColumn<int>("movePosition2");
- QTest::addColumn<int>("selection1Start");
- QTest::addColumn<int>("selection1End");
- QTest::addColumn<int>("selection2Start");
- QTest::addColumn<int>("selection2End");
-
- QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
- << standard[0]
- << 9 << 13 << 17
- << 4 << 15
- << 4 << 19;
- QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
- << standard[0]
- << 13 << 9 << 17
- << 9 << 15
- << 10 << 19;
- QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 16
- << 4 << 15
- << 4 << 16;
- QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
- << standard[0]
- << 13 << 9 << 16
- << 9 << 15
- << 10 << 16;
- QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 15
- << 4 << 15
- << 4 << 15;
- QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
- << standard[0]
- << 13 << 9 << 15
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 10
- << 4 << 15
- << 4 << 10;
- QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 10
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 9
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 9
- << 9 << 15
- << 9 << 15;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 7
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 7
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 4
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 4
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 3
- << 4 << 15
- << 3 << 9;
- QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 3
- << 9 << 15
- << 3 << 15;
- QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 1
- << 4 << 15
- << 0 << 9;
- QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 1
- << 9 << 15
- << 0 << 15;
-
- QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
- << standard[2]
- << 2 << 4 << 8
- << 0 << 5
- << 0 << 12;
- QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
- << standard[2]
- << 4 << 2 << 8
- << 0 << 5
- << 0 << 12;
-
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
- << standard[3]
- << 9 << 11 << 5
- << 8 << 13
- << 1 << 13;
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
- << standard[3]
- << 11 << 9 << 5
- << 8 << 13
- << 1 << 13;
-}
-
-void tst_qquicktextedit::moveCursorSelectionSequence()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition1);
- QFETCH(int, movePosition2);
- QFETCH(int, selection1Start);
- QFETCH(int, selection1End);
- QFETCH(int, selection2Start);
- QFETCH(int, selection2End);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(texteditObject != 0);
-
- texteditObject->setCursorPosition(cursorPosition);
-
- texteditObject->moveCursorSelection(movePosition1, QQuickTextEdit::SelectWords);
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
- QCOMPARE(texteditObject->selectionStart(), selection1Start);
- QCOMPARE(texteditObject->selectionEnd(), selection1End);
-
- texteditObject->moveCursorSelection(movePosition2, QQuickTextEdit::SelectWords);
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
- QCOMPARE(texteditObject->selectionStart(), selection2Start);
- QCOMPARE(texteditObject->selectionEnd(), selection2End);
-}
-
-
-void tst_qquicktextedit::mouseSelection_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<QString>("selectedText");
-
- // import installed
- QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678";
- QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString();
- QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString();
- QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString();
- QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789";
- QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-}
-
-void tst_qquicktextedit::mouseSelection()
-{
- QFETCH(QString, qmlfile);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(QString, selectedText);
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- QPoint p1 = textEditObject->positionToRectangle(from).center().toPoint();
- QPoint p2 = textEditObject->positionToRectangle(to).center().toPoint();
- QTest::mousePress(&canvas, Qt::LeftButton, 0, p1);
- QTest::mouseMove(&canvas, p2);
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, p2);
- QTest::qWait(50);
- QTRY_COMPARE(textEditObject->selectedText(), selectedText);
-
- // Clicking and shift to clicking between the same points should select the same text.
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(&canvas, Qt::LeftButton, Qt::NoModifier, p1);
- QTest::mouseClick(&canvas, Qt::LeftButton, Qt::ShiftModifier, p2);
- QTest::qWait(50);
- QTRY_COMPARE(textEditObject->selectedText(), selectedText);
-}
-
-void tst_qquicktextedit::dragMouseSelection()
-{
- QString qmlfile = testFile("mouseselection_true.qml");
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textEditObject->height()/2;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(300);
- QString str1;
- QTRY_VERIFY((str1 = textEditObject->selectedText()).length() > 3);
-
- // press and drag the current selection.
- x1 = 40;
- x2 = 100;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(300);
- QString str2;
- QTRY_VERIFY((str2 = textEditObject->selectedText()).length() > 3);
-
- QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and not the first moved.
-}
-
-void tst_qquicktextedit::mouseSelectionMode_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<bool>("selectWords");
-
- // import installed
- QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
- QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
- QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
-}
-
-void tst_qquicktextedit::mouseSelectionMode()
-{
- QFETCH(QString, qmlfile);
- QFETCH(bool, selectWords);
-
- QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textEditObject->height()/2;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- //QTest::mouseMove(canvas, QPoint(x2,y)); // doesn't work
-// QMouseEvent mv(QEvent::MouseMove, QPoint(x2,y), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
-// QGuiApplication::sendEvent(&canvas, &mv);
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QString str = textEditObject->selectedText();
- if (selectWords) {
- QTRY_COMPARE(textEditObject->selectedText(), text);
- } else {
- QTRY_VERIFY(textEditObject->selectedText().length() > 3);
- QVERIFY(str != text);
- }
-}
-
-void tst_qquicktextedit::inputMethodHints()
-{
- QQuickView canvas(testFileUrl("inputmethodhints.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
- QSignalSpy inputMethodHintSpy(textEditObject, SIGNAL(inputMethodHintsChanged()));
- textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
- textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
-
- QQuickTextEdit plainTextEdit;
- QCOMPARE(plainTextEdit.inputMethodHints(), Qt::ImhNone);
-}
-
-void tst_qquicktextedit::positionAt()
-{
- QQuickView canvas(testFileUrl("positionAt.qml"));
- QVERIFY(canvas.rootObject() != 0);
- canvas.show();
- canvas.requestActivateWindow();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(texteditObject != 0);
-
- QTextLayout layout(texteditObject->text());
- layout.setFont(texteditObject->font());
-
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
-
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- const int y0 = line.height() / 2;
- const int y1 = line.height() * 3 / 2;
-
- int pos = texteditObject->positionAt(texteditObject->width()/2, y0);
-
- int widthBegin = floor(line.cursorToX(pos - 1));
- int widthEnd = ceil(line.cursorToX(pos + 1));
-
- QVERIFY(widthBegin <= texteditObject->width() / 2);
- QVERIFY(widthEnd >= texteditObject->width() / 2);
-
- const qreal x0 = texteditObject->positionToRectangle(pos).x();
- const qreal x1 = texteditObject->positionToRectangle(pos + 1).x();
-
- QString preeditText = texteditObject->text().mid(0, pos);
- texteditObject->setText(texteditObject->text().mid(pos));
- texteditObject->setCursorPosition(0);
-
- QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent);
-
- // Check all points within the preedit text return the same position.
- QCOMPARE(texteditObject->positionAt(0, y0), 0);
- QCOMPARE(texteditObject->positionAt(x0 / 2, y0), 0);
- QCOMPARE(texteditObject->positionAt(x0, y0), 0);
-
- // Verify positioning returns to normal after the preedit text.
- QCOMPARE(texteditObject->positionAt(x1, y0), 1);
- QCOMPARE(texteditObject->positionToRectangle(1).x(), x1);
-
- QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0);
-}
-
-void tst_qquicktextedit::linkActivated()
-{
- QQuickView canvas(testFileUrl("linkActivated.qml"));
- QVERIFY(canvas.rootObject() != 0);
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(texteditObject != 0);
-
- QSignalSpy spy(texteditObject, SIGNAL(linkActivated(QString)));
-
- const QString link("http://example.com/");
-
- const QPointF linkPos = texteditObject->positionToRectangle(7).center();
- const QPointF textPos = texteditObject->positionToRectangle(2).center();
-
- QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint());
- QTRY_COMPARE(spy.count(), 1);
- QCOMPARE(spy.last()[0].toString(), link);
-
- QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint());
- QTest::qWait(50);
- QCOMPARE(spy.count(), 1);
-
- texteditObject->setReadOnly(true);
-
- QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint());
- QTRY_COMPARE(spy.count(), 2);
- QCOMPARE(spy.last()[0].toString(), link);
-
- QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint());
- QTest::qWait(50);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::cursorDelegate_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::newRow("out of line") << testFileUrl("cursorTest.qml");
- QTest::newRow("in line") << testFileUrl("cursorTestInline.qml");
- QTest::newRow("external") << testFileUrl("cursorTestExternal.qml");
-}
-
-void tst_qquicktextedit::cursorDelegate()
-{
- QFETCH(QUrl, source);
- QQuickView view(source);
- view.show();
- view.requestActivateWindow();
- QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->findChild<QQuickItem*>("cursorInstance"));
- //Test Delegate gets created
- textEditObject->setFocus(true);
- QQuickItem* delegateObject = textEditObject->findChild<QQuickItem*>("cursorInstance");
- QVERIFY(delegateObject);
- QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
- //Test Delegate gets moved
- for (int i=0; i<= textEditObject->text().length(); i++) {
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
- QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
- }
- // Clear preedit text;
- QInputMethodEvent event;
- QGuiApplication::sendEvent(&view, &event);
-
-
- // Test delegate gets moved on mouse press.
- textEditObject->setSelectByMouse(true);
- textEditObject->setCursorPosition(0);
- const QPoint point1 = textEditObject->positionToRectangle(5).center().toPoint();
- QTest::mouseClick(&view, Qt::LeftButton, 0, point1);
- QTest::qWait(50);
- QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
- QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
-
- // Test delegate gets moved on mouse drag
- textEditObject->setCursorPosition(0);
- const QPoint point2 = textEditObject->positionToRectangle(10).center().toPoint();
- QTest::mousePress(&view, Qt::LeftButton, 0, point1);
- QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(&view, &mv);
- QTest::mouseRelease(&view, Qt::LeftButton, 0, point2);
- QTest::qWait(50);
- QTRY_COMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
- QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
-
- textEditObject->setReadOnly(true);
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
- QTest::qWait(50);
- QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
- QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
-
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
- QTest::qWait(50);
- QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
- QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
-
- textEditObject->setCursorPosition(0);
- QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
- QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
- //Test Delegate gets deleted
- textEditObject->setCursorDelegate(0);
- QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
-}
-
-void tst_qquicktextedit::cursorVisible()
-{
- QQuickView view(testFileUrl("cursorVisible.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextEdit edit;
- QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool)));
-
- QCOMPARE(edit.isCursorVisible(), false);
-
- edit.setCursorVisible(true);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 1);
-
- edit.setCursorVisible(false);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- edit.setFocus(true);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- edit.setParentItem(view.rootObject());
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 3);
-
- edit.setFocus(false);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 4);
-
- edit.setFocus(true);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 5);
-
- QQuickView alternateView;
- alternateView.show();
- alternateView.requestActivateWindow();
- QTest::qWaitForWindowShown(&alternateView);
-
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 6);
-
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 7);
-}
-
-void tst_qquicktextedit::delegateLoading_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<QString>("error");
-
- // import installed
- QTest::newRow("pass") << "cursorHttpTestPass.qml" << "";
- QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection ";
- QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type ";
-}
-
-void tst_qquicktextedit::delegateLoading()
-{
-#ifdef Q_OS_MAC
- QSKIP("Test crashes during canvas tear down. QTBUG-23010");
-#endif
- QFETCH(QString, qmlfile);
- QFETCH(QString, error);
-
- TestHTTPServer server(42332);
- server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect);
- server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay);
- server.serveDirectory(testFile("http"));
-
- QQuickView view(QUrl(QLatin1String("http://localhost:42332/") + qmlfile));
- view.show();
- view.requestActivateWindow();
-
- if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
- QTRY_VERIFY(view.status()==QQuickView::Error);
- QTRY_VERIFY(!view.rootObject()); // there is fail item inside this test
- } else {
- QTRY_VERIFY(view.rootObject());//Wait for loading to finish.
- QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
- // view.rootObject()->dumpObjectTree();
- QVERIFY(textEditObject != 0);
- textEditObject->setFocus(true);
- QQuickItem *delegate;
- delegate = view.rootObject()->findChild<QQuickItem*>("delegateOkay");
- QVERIFY(delegate);
- delegate = view.rootObject()->findChild<QQuickItem*>("delegateSlow");
- QVERIFY(delegate);
-
- delete delegate;
- }
-
-
- //A test should be added here with a component which is ready but component.create() returns null
- //Not sure how to accomplish this with QQuickTextEdits cursor delegate
- //###This was only needed for code coverage, and could be a case of overzealous defensive programming
- //delegate = view.rootObject()->findChild<QQuickItem*>("delegateErrorB");
- //QVERIFY(!delegate);
-}
-
-/*
-TextEdit element should only handle left/right keys until the cursor reaches
-the extent of the text, then they should ignore the keys.
-*/
-void tst_qquicktextedit::navigation()
-{
- QQuickView canvas(testFileUrl("navigation.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickItem *input = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-}
-
-void tst_qquicktextedit::copyAndPaste() {
-#ifndef QT_NO_CLIPBOARD
-
-#ifdef Q_OS_MAC
- {
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- else
- QSKIP("This machine doesn't support the clipboard");
- }
-#endif
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // copy and paste
- QCOMPARE(textEdit->text().length(), 12);
- textEdit->select(0, textEdit->text().length());;
- textEdit->copy();
- QCOMPARE(textEdit->selectedText(), QString("Hello world!"));
- QCOMPARE(textEdit->selectedText().length(), 12);
- textEdit->setCursorPosition(0);
- QVERIFY(textEdit->canPaste());
- textEdit->paste();
- QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
-
- // canPaste
- QVERIFY(textEdit->canPaste());
- textEdit->setReadOnly(true);
- QVERIFY(!textEdit->canPaste());
- textEdit->setReadOnly(false);
- QVERIFY(textEdit->canPaste());
-
- // QTBUG-12339
- // test that document and internal text attribute are in sync
- QQuickItemPrivate* pri = QQuickItemPrivate::get(textEdit);
- QQuickTextEditPrivate *editPrivate = static_cast<QQuickTextEditPrivate*>(pri);
- QCOMPARE(textEdit->text(), editPrivate->text);
-
- // select word
- textEdit->setCursorPosition(0);
- textEdit->selectWord();
- QCOMPARE(textEdit->selectedText(), QString("Hello"));
-
- // select all and cut
- textEdit->selectAll();
- textEdit->cut();
- QCOMPARE(textEdit->text().length(), 0);
- textEdit->paste();
- QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
-#endif
-}
-
-void tst_qquicktextedit::canPaste() {
-#ifndef QT_NO_CLIPBOARD
-
- QGuiApplication::clipboard()->setText("Some text");
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // check initial value - QTBUG-17765
- QQuickTextControl tc(0);
- QCOMPARE(textEdit->canPaste(), tc.canPaste());
-
-#endif
-}
-
-void tst_qquicktextedit::canPasteEmpty() {
-#ifndef QT_NO_CLIPBOARD
-
- QGuiApplication::clipboard()->clear();
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // check initial value - QTBUG-17765
- QQuickTextControl tc(0);
- QCOMPARE(textEdit->canPaste(), tc.canPaste());
-
-#endif
-}
-
-void tst_qquicktextedit::readOnly()
-{
- QQuickView canvas(testFileUrl("readOnly.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(edit != 0);
- QTRY_VERIFY(edit->hasActiveFocus() == true);
- QVERIFY(edit->isReadOnly() == true);
- QString initial = edit->text();
- for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
- simulateKey(&canvas, k);
- simulateKey(&canvas, Qt::Key_Return);
- simulateKey(&canvas, Qt::Key_Space);
- simulateKey(&canvas, Qt::Key_Escape);
- QCOMPARE(edit->text(), initial);
-
- edit->setCursorPosition(3);
- edit->setReadOnly(false);
- QCOMPARE(edit->isReadOnly(), false);
- QCOMPARE(edit->cursorPosition(), edit->text().length());
-}
-
-void tst_qquicktextedit::simulateKey(QQuickView *view, int key, Qt::KeyboardModifiers modifiers)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, modifiers);
- QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers);
-
- QGuiApplication::sendEvent(view, &press);
- QGuiApplication::sendEvent(view, &release);
-}
-
-void tst_qquicktextedit::textInput()
-{
- QQuickView view(testFileUrl("inputMethodEvent.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
- QVERIFY(edit->hasActiveFocus() == true);
-
- // test that input method event is committed and change signal is emitted
- QSignalSpy spy(edit, SIGNAL(textChanged()));
- QInputMethodEvent event;
- event.setCommitString( "Hello world!", 0, 0);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(edit->text(), QString("Hello world!"));
- QCOMPARE(spy.count(), 1);
-
- // QTBUG-12339
- // test that document and internal text attribute are in sync
- QQuickTextEditPrivate *editPrivate = static_cast<QQuickTextEditPrivate*>(QQuickItemPrivate::get(edit));
- QCOMPARE(editPrivate->text, QString("Hello world!"));
-
- // test that tentative commit is included in text property
- edit->setText("");
- spy.clear();
- QList<QInputMethodEvent::Attribute> attributes;
- QInputMethodEvent event2("preedit", attributes);
- event2.setTentativeCommitString("string");
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event2);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(edit->text(), QString("string"));
-
- QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &queryEvent);
- QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), true);
-
- edit->setReadOnly(true);
- QGuiApplication::sendEvent(edit, &queryEvent);
- QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false);
-}
-
-void tst_qquicktextedit::inputMethodUpdate()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView view(testFileUrl("inputMethodEvent.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
- QVERIFY(edit->hasActiveFocus() == true);
-
- // text change even without cursor position change needs to trigger update
- edit->setText("test");
- platformInputContext.clear();
- edit->setText("xxxx");
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // input method event replacing text
- platformInputContext.clear();
- {
- QInputMethodEvent inputMethodEvent;
- inputMethodEvent.setCommitString("y", -1, 1);
- QGuiApplication::sendEvent(edit, &inputMethodEvent);
- }
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // input method changing selection
- platformInputContext.clear();
- {
- QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
- QInputMethodEvent inputMethodEvent("", attributes);
- QGuiApplication::sendEvent(edit, &inputMethodEvent);
- }
- QVERIFY(edit->selectionStart() != edit->selectionEnd());
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // font changes
- platformInputContext.clear();
- QFont font = edit->font();
- font.setBold(!font.bold());
- edit->setFont(font);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // normal input
- platformInputContext.clear();
- {
- QInputMethodEvent inputMethodEvent;
- inputMethodEvent.setCommitString("y");
- QGuiApplication::sendEvent(edit, &inputMethodEvent);
- }
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // changing cursor position
- platformInputContext.clear();
- edit->setCursorPosition(0);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // continuing with selection
- platformInputContext.clear();
- edit->moveCursorSelection(1);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // read only disabled input method
- platformInputContext.clear();
- edit->setReadOnly(true);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
- edit->setReadOnly(false);
-
- // no updates while no focus
- edit->setFocus(false);
- platformInputContext.clear();
- edit->setText("Foo");
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- edit->setCursorPosition(1);
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- edit->selectAll();
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- edit->setReadOnly(true);
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
-}
-
-void tst_qquicktextedit::openInputPanel()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView view(testFileUrl("openInputPanel.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
-
- // check default values
- QVERIFY(edit->focusOnPress());
- QVERIFY(!edit->hasActiveFocus());
- qDebug() << &edit << qApp->focusObject();
- QVERIFY(qApp->focusObject() != edit);
-
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should open on focus
- QPoint centerPoint(view.width()/2, view.height()/2);
- Qt::KeyboardModifiers noModifiers = 0;
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QVERIFY(edit->hasActiveFocus());
- QCOMPARE(qApp->focusObject(), edit);
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-
- // input panel should be re-opened when pressing already focused TextEdit
- qApp->inputMethod()->hide();
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QVERIFY(edit->hasActiveFocus());
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-
- // input panel should stay visible if focus is lost to another text editor
- QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
- QQuickTextEdit anotherEdit;
- anotherEdit.setParentItem(view.rootObject());
- anotherEdit.setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherEdit));
- QCOMPARE(inputPanelVisibilitySpy.count(), 0);
-
- anotherEdit.setFocus(false);
- QVERIFY(qApp->focusObject() != &anotherEdit);
- QCOMPARE(view.activeFocusItem(), view.rootItem());
- anotherEdit.setFocus(true);
-
- qApp->inputMethod()->hide();
-
- // input panel should not be opened if TextEdit is read only
- edit->setReadOnly(true);
- edit->setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should not be opened if focusOnPress is set to false
- edit->setFocusOnPress(false);
- edit->setFocus(false);
- edit->setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should open when openSoftwareInputPanel is called
- edit->openSoftwareInputPanel();
- QCOMPARE(qApp->inputMethod()->visible(), true);
-
- // input panel should close when closeSoftwareInputPanel is called
- edit->closeSoftwareInputPanel();
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- inputMethodPrivate->testContext = 0;
-}
-
-void tst_qquicktextedit::geometrySignals()
-{
- QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml"));
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("bindingWidth").toInt(), 400);
- QCOMPARE(o->property("bindingHeight").toInt(), 500);
- delete o;
-}
-
-void tst_qquicktextedit::pastingRichText_QTBUG_14003()
-{
-#ifndef QT_NO_CLIPBOARD
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickTextEdit *obj = qobject_cast<QQuickTextEdit*>(component.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
-
- QMimeData *mData = new QMimeData;
- mData->setHtml("<font color=\"red\">Hello</font>");
- QGuiApplication::clipboard()->setMimeData(mData);
-
- obj->paste();
- QTRY_VERIFY(obj->text() == "");
- QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
-#endif
-}
-
-void tst_qquicktextedit::implicitSize_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("wrap");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap";
- QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.NoWrap";
- QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap";
- QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.Wrap";
-}
-
-void tst_qquicktextedit::implicitSize()
-{
- QFETCH(QString, text);
- QFETCH(QString, wrap);
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
-
- QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-}
-
-void tst_qquicktextedit::contentSize()
-{
- QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
-
- textObject->setText("The quick red fox jumped over the lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
-
- textObject->setWrapMode(QQuickTextEdit::WordWrap);
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
-
- textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_qquicktextedit::preeditCursorRectangle()
-{
- QString preeditText = "super";
-
- QQuickView view(testFileUrl("inputMethodEvent.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
-
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
-
- QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged()));
- QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
-
- QRect currentRect;
-
- QInputMethodQueryEvent query(Qt::ImCursorRectangle);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
-
- // Verify that the micro focus rect is positioned the same for position 0 as
- // it would be if there was no preedit text.
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.length(), QVariant()));
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QCOMPARE(currentRect, previousRect);
- QCOMPARE(editSpy.count(), 0);
- QCOMPARE(panelSpy.count(), 0);
-
- // Verify that the micro focus rect moves to the left as the cursor position
- // is incremented.
- for (int i = 1; i <= 5; ++i) {
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant()));
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QVERIFY(previousRect.left() < currentRect.left());
- QVERIFY(editSpy.count() > 0); editSpy.clear();
- QVERIFY(panelSpy.count() > 0); panelSpy.clear();
- previousRect = currentRect;
- }
-
- // Verify that if there is no preedit cursor then the micro focus rect is the
- // same as it would be if it were positioned at the end of the preedit text.
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- editSpy.clear();
- panelSpy.clear();
- { QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); }
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QCOMPARE(currentRect, previousRect);
- QVERIFY(editSpy.count() > 0);
- QVERIFY(panelSpy.count() > 0);
-}
-
-void tst_qquicktextedit::inputMethodComposing()
-{
- QString text = "supercalifragisiticexpialidocious!";
-
- QQuickView view(testFileUrl("inputContext.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
- QSignalSpy spy(edit, SIGNAL(inputMethodComposingChanged()));
- edit->setCursorPosition(12);
-
- QCOMPARE(edit->isInputMethodComposing(), false);
-
- {
- QInputMethodEvent event(text.mid(3), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(edit, &event);
- }
-
- QCOMPARE(edit->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(edit, &event);
- }
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent event;
- QGuiApplication::sendEvent(edit, &event);
- }
- QCOMPARE(edit->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::cursorRectangleSize()
-{
- QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
- QVERIFY(canvas->rootObject() != 0);
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit *>(canvas->rootObject());
-
- // make sure cursor rectangle is not at (0,0)
- textEdit->setX(10);
- textEdit->setY(10);
- textEdit->setCursorPosition(3);
- QVERIFY(textEdit != 0);
- textEdit->setFocus(true);
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
-
- QInputMethodQueryEvent event(Qt::ImCursorRectangle);
- qApp->sendEvent(qApp->focusObject(), &event);
- QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
-
- QRectF cursorRectFromItem = textEdit->cursorRectangle();
- QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition());
-
- // item and input query cursor rectangles match
- QCOMPARE(cursorRectFromItem, cursorRectFromQuery);
-
- // item cursor rectangle and positionToRectangle calculations match
- QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle);
-
- // item-canvas transform and input item transform match
- QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
-
- // input panel cursorRectangle property and tranformed item cursor rectangle match
- QRectF sceneCursorRect = QQuickItemPrivate::get(textEdit)->itemToCanvasTransform().mapRect(cursorRectFromItem);
- QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
-
- delete canvas;
-}
-
-void tst_qquicktextedit::getText_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<int>("start");
- QTest::addColumn<int>("end");
- QTest::addColumn<QString>("expectedText");
-
- const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
- const QString plainBoldText = QStringLiteral("This is some bold text");
-
- QTest::newRow("all plain text")
- << standard.at(0)
- << 0 << standard.at(0).length()
- << standard.at(0);
-
- QTest::newRow("plain text sub string")
- << standard.at(0)
- << 0 << 12
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text sub string reversed")
- << standard.at(0)
- << 12 << 0
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text cropped beginning")
- << standard.at(0)
- << -3 << 4
- << standard.at(0).mid(0, 4);
-
- QTest::newRow("plain text cropped end")
- << standard.at(0)
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(23);
-
- QTest::newRow("plain text cropped beginning and end")
- << standard.at(0)
- << -9 << standard.at(0).length() + 4
- << standard.at(0);
-
- QTest::newRow("all rich text")
- << richBoldText
- << 0 << plainBoldText.length()
- << plainBoldText;
-
- QTest::newRow("rich text sub string")
- << richBoldText
- << 14 << 21
- << plainBoldText.mid(14, 7);
-}
-
-void tst_qquicktextedit::getText()
-{
- QFETCH(QString, text);
- QFETCH(int, start);
- QFETCH(int, end);
- QFETCH(QString, expectedText);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + text + "\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QCOMPARE(textEdit->getText(start, end), expectedText);
-}
-
-void tst_qquicktextedit::getFormattedText_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
- QTest::addColumn<int>("start");
- QTest::addColumn<int>("end");
- QTest::addColumn<QString>("expectedText");
-
- const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
- const QString plainBoldText = QStringLiteral("This is some bold text");
-
- QTest::newRow("all plain text")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << 0 << standard.at(0).length()
- << standard.at(0);
-
- QTest::newRow("plain text sub string")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << 0 << 12
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text sub string reversed")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << 12 << 0
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text cropped beginning")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << -3 << 4
- << standard.at(0).mid(0, 4);
-
- QTest::newRow("plain text cropped end")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(23);
-
- QTest::newRow("plain text cropped beginning and end")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << -9 << standard.at(0).length() + 4
- << standard.at(0);
-
- QTest::newRow("all rich (Auto) text")
- << richBoldText
- << QQuickTextEdit::AutoText
- << 0 << plainBoldText.length()
- << QString("This is some \\<.*\\>bold\\</.*\\> text");
-
- QTest::newRow("all rich (Rich) text")
- << richBoldText
- << QQuickTextEdit::RichText
- << 0 << plainBoldText.length()
- << QString("This is some \\<.*\\>bold\\</.*\\> text");
-
- QTest::newRow("all rich (Plain) text")
- << richBoldText
- << QQuickTextEdit::PlainText
- << 0 << richBoldText.length()
- << richBoldText;
-
- QTest::newRow("rich (Auto) text sub string")
- << richBoldText
- << QQuickTextEdit::AutoText
- << 14 << 21
- << QString("\\<.*\\>old\\</.*\\> tex");
-
- QTest::newRow("rich (Rich) text sub string")
- << richBoldText
- << QQuickTextEdit::RichText
- << 14 << 21
- << QString("\\<.*\\>old\\</.*\\> tex");
-
- QTest::newRow("rich (Plain) text sub string")
- << richBoldText
- << QQuickTextEdit::PlainText
- << 17 << 27
- << richBoldText.mid(17, 10);
-}
-
-void tst_qquicktextedit::getFormattedText()
-{
- QFETCH(QString, text);
- QFETCH(QQuickTextEdit::TextFormat, textFormat);
- QFETCH(int, start);
- QFETCH(int, end);
- QFETCH(QString, expectedText);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit {}";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- textEdit->setTextFormat(textFormat);
- textEdit->setText(text);
-
- if (textFormat == QQuickTextEdit::RichText
- || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
- QVERIFY(textEdit->getFormattedText(start, end).contains(QRegExp(expectedText)));
- } else {
- QCOMPARE(textEdit->getFormattedText(start, end), expectedText);
- }
-}
-
-void tst_qquicktextedit::insert_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("insertPosition");
- QTest::addColumn<QString>("insertText");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<int>("expectedSelectionStart");
- QTest::addColumn<int>("expectedSelectionEnd");
- QTest::addColumn<int>("expectedCursorPosition");
- QTest::addColumn<bool>("selectionChanged");
- QTest::addColumn<bool>("cursorPositionChanged");
-
- QTest::newRow("at cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 5 << 5 << 5
- << false << true;
-
- QTest::newRow("at cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
- << false << true;
-
- QTest::newRow("at cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 23 << 23 << 23
- << false << true;
-
- QTest::newRow("after cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("before cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length() << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
- << false << true;
-
- QTest::newRow("before cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 23 << 23 << 23
- << false << true;
-
- QTest::newRow("after cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("before selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 19 << 24 << 24
- << false << true;
-
- QTest::newRow("before reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 19 << 24 << 19
- << false << true;
-
- QTest::newRow("after selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 14 << 19 << 19
- << false << false;
-
- QTest::newRow("after reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 14 << 19 << 14
- << false << false;
-
- QTest::newRow("into selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 14 << 24 << 24
- << true << true;
-
- QTest::newRow("into reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 14 << 24 << 14
- << true << false;
-
- QTest::newRow("rich text into plain text")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << 0
- << QString("<b>Hello</b>")
- << QString("<b>Hello</b>") + standard.at(0)
- << 12 << 12 << 12
- << false << true;
-
- QTest::newRow("rich text into rich text")
- << standard.at(0) << QQuickTextEdit::RichText
- << 0 << 0 << 0
- << QString("<b>Hello</b>")
- << QString("Hello") + standard.at(0)
- << 5 << 5 << 5
- << false << true;
-
- QTest::newRow("rich text into auto text")
- << standard.at(0) << QQuickTextEdit::AutoText
- << 0 << 0 << 0
- << QString("<b>Hello</b>")
- << QString("Hello") + standard.at(0)
- << 5 << 5 << 5
- << false << true;
-
- QTest::newRow("before start")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << -3
- << QString("Hello")
- << standard.at(0)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("past end")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << standard.at(0).length() + 3
- << QString("Hello")
- << standard.at(0)
- << 0 << 0 << 0
- << false << false;
-}
-
-void tst_qquicktextedit::insert()
-{
- QFETCH(QString, text);
- QFETCH(QQuickTextEdit::TextFormat, textFormat);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, insertPosition);
- QFETCH(QString, insertText);
- QFETCH(QString, expectedText);
- QFETCH(int, expectedSelectionStart);
- QFETCH(int, expectedSelectionEnd);
- QFETCH(int, expectedCursorPosition);
- QFETCH(bool, selectionChanged);
- QFETCH(bool, cursorPositionChanged);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- textEdit->setTextFormat(textFormat);
- textEdit->select(selectionStart, selectionEnd);
-
- QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged()));
- QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged()));
- QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged()));
- QSignalSpy textSpy(textEdit, SIGNAL(textChanged()));
- QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged()));
-
- textEdit->insert(insertPosition, insertText);
-
- if (textFormat == QQuickTextEdit::RichText || (textFormat == QQuickTextEdit::AutoText && (
- Qt::mightBeRichText(text) || Qt::mightBeRichText(insertText)))) {
- QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
- } else {
- QCOMPARE(textEdit->text(), expectedText);
-
- }
- QCOMPARE(textEdit->length(), expectedText.length());
-
- QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
- QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
- QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
-
- if (selectionStart > selectionEnd)
- qSwap(selectionStart, selectionEnd);
-
- QEXPECT_FAIL("into selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("into reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
- QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
-}
-
-void tst_qquicktextedit::remove_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("removeStart");
- QTest::addColumn<int>("removeEnd");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<int>("expectedSelectionStart");
- QTest::addColumn<int>("expectedSelectionEnd");
- QTest::addColumn<int>("expectedCursorPosition");
- QTest::addColumn<bool>("selectionChanged");
- QTest::addColumn<bool>("cursorPositionChanged");
-
- const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
- const QString plainBoldText = QStringLiteral("This is some bold text");
-
- QTest::newRow("from cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << 0 << 5
- << standard.at(0).mid(5)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("to cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << 5 << 0
- << standard.at(0).mid(5)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("to cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() << standard.at(0).length() - 5
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("to cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("from cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("to cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 23 << 23
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << true;
-
- QTest::newRow("after cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("before cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("before cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 23 << 23
- << 0 << 5
- << standard.at(0).mid(5)
- << 18 << 18 << 18
- << false << true;
-
- QTest::newRow("after cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("before selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19
- << 0 << 5
- << standard.at(0).mid(5)
- << 9 << 14 << 14
- << false << true;
-
- QTest::newRow("before reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14
- << 0 << 5
- << standard.at(0).mid(5)
- << 9 << 14 << 9
- << false << true;
-
- QTest::newRow("after selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << 14 << 19 << 19
- << false << false;
-
- QTest::newRow("after reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << 14 << 19 << 14
- << false << false;
-
- QTest::newRow("from selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 24
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 14 << 19 << 19
- << true << true;
-
- QTest::newRow("from reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 24 << 14
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 14 << 19 << 14
- << true << false;
-
- QTest::newRow("plain text cropped beginning")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << -3 << 4
- << standard.at(0).mid(4)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("plain text cropped end")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(0, 23)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("plain text cropped beginning and end")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << -9 << standard.at(0).length() + 4
- << QString()
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("all rich text")
- << richBoldText << QQuickTextEdit::RichText
- << 0 << 0
- << 0 << plainBoldText.length()
- << QString()
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("rick text sub string")
- << richBoldText << QQuickTextEdit::RichText
- << 0 << 0
- << 14 << 21
- << plainBoldText.mid(0, 14) + plainBoldText.mid(21)
- << 0 << 0 << 0
- << false << false;
-}
-
-void tst_qquicktextedit::remove()
-{
- QFETCH(QString, text);
- QFETCH(QQuickTextEdit::TextFormat, textFormat);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, removeStart);
- QFETCH(int, removeEnd);
- QFETCH(QString, expectedText);
- QFETCH(int, expectedSelectionStart);
- QFETCH(int, expectedSelectionEnd);
- QFETCH(int, expectedCursorPosition);
- QFETCH(bool, selectionChanged);
- QFETCH(bool, cursorPositionChanged);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- textEdit->setTextFormat(textFormat);
- textEdit->select(selectionStart, selectionEnd);
-
- QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged()));
- QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged()));
- QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged()));
- QSignalSpy textSpy(textEdit, SIGNAL(textChanged()));
- QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged()));
-
- textEdit->remove(removeStart, removeEnd);
-
- if (textFormat == QQuickTextEdit::RichText
- || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
- QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
- } else {
- QCOMPARE(textEdit->text(), expectedText);
- }
- QCOMPARE(textEdit->length(), expectedText.length());
-
- if (selectionStart > selectionEnd) //
- qSwap(selectionStart, selectionEnd);
-
- QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
- QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
- QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
-
- QEXPECT_FAIL("from selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("from reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("from reversed selection", "selectionEndChanged signal not emitted", Continue);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
-
-
- if (cursorPositionChanged) //
- QVERIFY(cursorPositionSpy.count() > 0);
-}
-
-
-void tst_qquicktextedit::keySequence_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QKeySequence>("sequence");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<QString>("selectedText");
-
- // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
-
- QTest::newRow("select all")
- << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
- << 44 << standard.at(0) << standard.at(0);
- QTest::newRow("select end of line")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
- << 44 << standard.at(0) << standard.at(0).mid(5);
- QTest::newRow("select end of document")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
- << 44 << standard.at(0) << standard.at(0).mid(3);
- QTest::newRow("select end of block")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
- << 44 << standard.at(0) << standard.at(0).mid(18);
- QTest::newRow("delete end of line")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
- << 24 << standard.at(0).mid(0, 24) << QString();
- QTest::newRow("move to start of line")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
- << 0 << standard.at(0) << QString();
- QTest::newRow("move to start of block")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
- << 0 << standard.at(0) << QString();
- QTest::newRow("move to next char")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
- << 13 << standard.at(0) << QString();
- QTest::newRow("move to previous char")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
- << 2 << standard.at(0) << QString();
- QTest::newRow("select next char")
- << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
- << 24 << standard.at(0) << standard.at(0).mid(23, 1);
- QTest::newRow("select previous char")
- << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
- << 18 << standard.at(0) << standard.at(0).mid(18, 1);
- QTest::newRow("move to next word")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
- << 10 << standard.at(0) << QString();
- QTest::newRow("move to previous word")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
- << 4 << standard.at(0) << QString();
- QTest::newRow("select previous word")
- << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
- << 10 << standard.at(0) << standard.at(0).mid(10, 1);
- QTest::newRow("delete (selection)")
- << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
- << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
- QTest::newRow("delete (no selection)")
- << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
- << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
- QTest::newRow("delete end of word")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
- << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
- QTest::newRow("delete start of word")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
- << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
-}
-
-void tst_qquicktextedit::keySequence()
-{
- QFETCH(QString, text);
- QFETCH(QKeySequence, sequence);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, cursorPosition);
- QFETCH(QString, expectedText);
- QFETCH(QString, selectedText);
-
- if (sequence.isEmpty()) {
- QSKIP("Key sequence is undefined");
- }
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true; text: \"" + text + "\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QQuickCanvas canvas;
- textEdit->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- textEdit->select(selectionStart, selectionEnd);
-
- simulateKeys(&canvas, sequence);
-
- QCOMPARE(textEdit->cursorPosition(), cursorPosition);
- QCOMPARE(textEdit->text(), expectedText);
- QCOMPARE(textEdit->selectedText(), selectedText);
-}
-
-#define NORMAL 0
-#define REPLACE_UNTIL_END 1
-
-void tst_qquicktextedit::undo_data()
-{
- QTest::addColumn<QStringList>("insertString");
- QTest::addColumn<IntList>("insertIndex");
- QTest::addColumn<IntList>("insertMode");
- QTest::addColumn<QStringList>("expectedString");
- QTest::addColumn<bool>("use_keys");
-
- for (int i=0; i<2; i++) {
- QString keys_str = "keyboard";
- bool use_keys = true;
- if (i==0) {
- keys_str = "insert";
- use_keys = false;
- }
-
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "1";
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "5";
-
- insertIndex << 1;
- insertMode << NORMAL;
- insertString << "3";
-
- insertIndex << 1;
- insertMode << NORMAL;
- insertString << "2";
-
- insertIndex << 3;
- insertMode << NORMAL;
- insertString << "4";
-
- expectedString << "12345";
- expectedString << "1235";
- expectedString << "135";
- expectedString << "15";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "World"; // World
-
- insertIndex << 0;
- insertMode << NORMAL;
- insertString << "Hello"; // HelloWorld
-
- insertIndex << 0;
- insertMode << NORMAL;
- insertString << "Well"; // WellHelloWorld
-
- insertIndex << 9;
- insertMode << NORMAL;
- insertString << "There"; // WellHelloThereWorld;
-
- expectedString << "WellHelloThereWorld";
- expectedString << "WellHelloWorld";
- expectedString << "HelloWorld";
- expectedString << "World";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "Ensuring";
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << " instan";
-
- insertIndex << 9;
- insertMode << NORMAL;
- insertString << "an ";
-
- insertIndex << 10;
- insertMode << REPLACE_UNTIL_END;
- insertString << " unique instance.";
-
- expectedString << "Ensuring a unique instance.";
- expectedString << "Ensuring a "; // ### Not present in TextInput.
- expectedString << "Ensuring an instan";
- expectedString << "Ensuring instan";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- }
-}
-
-void tst_qquicktextedit::undo()
-{
- QFETCH(QStringList, insertString);
- QFETCH(IntList, insertIndex);
- QFETCH(IntList, insertMode);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QQuickCanvas canvas;
- textEdit->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- QVERIFY(!textEdit->canUndo());
-
- QSignalSpy spy(textEdit, SIGNAL(canUndoChanged()));
-
- int i;
-
-// STEP 1: First build up an undo history by inserting or typing some strings...
- for (i = 0; i < insertString.size(); ++i) {
- if (insertIndex[i] > -1)
- textEdit->setCursorPosition(insertIndex[i]);
-
- // experimental stuff
- if (insertMode[i] == REPLACE_UNTIL_END) {
- textEdit->select(insertIndex[i], insertIndex[i] + 8);
-
- // This is what I actually want...
- // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
- }
-
- for (int j = 0; j < insertString.at(i).length(); j++)
- QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
- }
-
- QCOMPARE(spy.count(), 1);
-
-// STEP 2: Next call undo several times and see if we can restore to the previous state
- for (i = 0; i < expectedString.size() - 1; ++i) {
- QCOMPARE(textEdit->text(), expectedString[i]);
- QVERIFY(textEdit->canUndo());
- textEdit->undo();
- }
-
-// STEP 3: Verify that we have undone everything
- QVERIFY(textEdit->text().isEmpty());
- QVERIFY(!textEdit->canUndo());
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::redo_data()
-{
- QTest::addColumn<QStringList>("insertString");
- QTest::addColumn<IntList>("insertIndex");
- QTest::addColumn<QStringList>("expectedString");
-
- {
- IntList insertIndex;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertString << "World"; // World
- insertIndex << 0;
- insertString << "Hello"; // HelloWorld
- insertIndex << 0;
- insertString << "Well"; // WellHelloWorld
- insertIndex << 9;
- insertString << "There"; // WellHelloThereWorld;
-
- expectedString << "World";
- expectedString << "HelloWorld";
- expectedString << "WellHelloWorld";
- expectedString << "WellHelloThereWorld";
-
- QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
- }
-}
-
-void tst_qquicktextedit::redo()
-{
- QFETCH(QStringList, insertString);
- QFETCH(IntList, insertIndex);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QQuickCanvas canvas;
- textEdit->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- QVERIFY(!textEdit->canUndo());
- QVERIFY(!textEdit->canRedo());
-
- QSignalSpy spy(textEdit, SIGNAL(canRedoChanged()));
-
- int i;
- // inserts the diff strings at diff positions
- for (i = 0; i < insertString.size(); ++i) {
- if (insertIndex[i] > -1)
- textEdit->setCursorPosition(insertIndex[i]);
- for (int j = 0; j < insertString.at(i).length(); j++)
- QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
- QVERIFY(textEdit->canUndo());
- QVERIFY(!textEdit->canRedo());
- }
-
- QCOMPARE(spy.count(), 0);
-
- // undo everything
- while (!textEdit->text().isEmpty()) {
- QVERIFY(textEdit->canUndo());
- textEdit->undo();
- QVERIFY(textEdit->canRedo());
- }
-
- QCOMPARE(spy.count(), 1);
-
- for (i = 0; i < expectedString.size(); ++i) {
- QVERIFY(textEdit->canRedo());
- textEdit->redo();
- QCOMPARE(textEdit->text() , expectedString[i]);
- QVERIFY(textEdit->canUndo());
- }
- QVERIFY(!textEdit->canRedo());
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::undo_keypressevents_data()
-{
- QTest::addColumn<KeyList>("keys");
- QTest::addColumn<QStringList>("expectedString");
-
- {
- KeyList keys;
- QStringList expectedString;
-
- keys << "AFRAID"
- << Qt::Key_Home
- << "VERY"
- << Qt::Key_Left
- << Qt::Key_Left
- << Qt::Key_Left
- << Qt::Key_Left
- << "BE"
- << Qt::Key_End
- << "!";
-
- expectedString << "BEVERYAFRAID!";
- expectedString << "BEVERYAFRAID";
- expectedString << "VERYAFRAID";
- expectedString << "AFRAID";
-
- QTest::newRow("Inserts and moving cursor") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting '1234'
- keys << "1234" << Qt::Key_Home
- // skipping '12'
- << Qt::Key_Right << Qt::Key_Right
- // selecting '34'
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- // deleting '34'
- << Qt::Key_Delete;
-
- expectedString << "12";
- expectedString << "1234";
-
- QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'AB12'
- keys << "AB12"
- << Qt::Key_Home
- // selecting 'AB'
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- << Qt::Key_Delete
- << QKeySequence::Undo
- // ### Text is selected in text input
-// << Qt::Key_Right
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- << Qt::Key_Delete;
-
- expectedString << "AB";
- expectedString << "AB12";
-
- QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'ABCD'
- keys << "abcd"
- //move left two
- << Qt::Key_Left << Qt::Key_Left
- // inserting '1234'
- << "1234"
- // selecting '1234'
- << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
- // overwriting '1234' with '5'
- << "5"
- // undoing deletion of 'AB'
- << QKeySequence::Undo
- // ### Text is selected in text input
- << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
- // overwriting '1234' with '6'
- << "6";
-
- expectedString << "ab6cd";
- // for versions previous to 3.2 we overwrite needed two undo operations
- expectedString << "ab1234cd";
- expectedString << "abcd";
-
- QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'ABC'
- keys << "ABC"
- // removes 'C'
- << Qt::Key_Backspace;
-
- expectedString << "AB";
- expectedString << "ABC";
-
- QTest::newRow("Inserts,backspace") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- keys << "ABC"
- // removes 'C'
- << Qt::Key_Backspace
- // inserting 'Z'
- << "Z";
-
- expectedString << "ABZ";
- expectedString << "AB";
- expectedString << "ABC";
-
- QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting '123'
- keys << "123" << Qt::Key_Home
- // selecting '123'
- << (Qt::Key_End | Qt::ShiftModifier)
- // overwriting '123' with 'ABC'
- << "ABC";
-
- expectedString << "ABC";
- // ### One operation in TextInput.
- expectedString << "A";
- expectedString << "123";
-
- QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
- }
-}
-
-void tst_qquicktextedit::undo_keypressevents()
-{
- QFETCH(KeyList, keys);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QQuickCanvas canvas;
- textEdit->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- simulateKeys(&canvas, keys);
-
- for (int i = 0; i < expectedString.size(); ++i) {
- QCOMPARE(textEdit->text() , expectedString[i]);
- textEdit->undo();
- }
- QVERIFY(textEdit->text().isEmpty());
-}
-
-void tst_qquicktextedit::baseUrl()
-{
- QUrl localUrl("file:///tests/text.qml");
- QUrl remoteUrl("http://qt.nokia.com/test.qml");
-
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\n TextEdit {}", localUrl);
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(textComponent.create());
-
- QCOMPARE(textObject->baseUrl(), localUrl);
-
- QSignalSpy spy(textObject, SIGNAL(baseUrlChanged()));
-
- textObject->setBaseUrl(localUrl);
- QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 0);
-
- textObject->setBaseUrl(remoteUrl);
- QCOMPARE(textObject->baseUrl(), remoteUrl);
- QCOMPARE(spy.count(), 1);
-
- textObject->resetBaseUrl();
- QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::embeddedImages_data()
-{
- QTest::addColumn<QUrl>("qmlfile");
- QTest::addColumn<QString>("error");
- QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
- QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
- << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML TextEdit: Cannot open: " + testFileUrl("http/notexists.png").toString();
- QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
- QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
- << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading http://127.0.0.1:42332/notexists.png - server replied: Not found";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
-}
-
-void tst_qquicktextedit::embeddedImages()
-{
- QFETCH(QUrl, qmlfile);
- QFETCH(QString, error);
-
- TestHTTPServer server(42332);
- server.serveDirectory(testFile("http"));
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
-
- QDeclarativeComponent textComponent(&engine, qmlfile);
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QTRY_COMPARE(QQuickTextEditPrivate::get(textObject)->document->resourcesLoading(), 0);
-
- QPixmap pm(testFile("http/exists.png"));
- if (error.isEmpty()) {
- QCOMPARE(textObject->width(), double(pm.width()));
- QCOMPARE(textObject->height(), double(pm.height()));
- } else {
- QVERIFY(16 != pm.width()); // check test is effective
- QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
- QCOMPARE(textObject->height(), 16.0);
- }
-
- delete textObject;
-}
-
-void tst_qquicktextedit::emptytags_QTBUG_22058()
-{
- QQuickView canvas(testFileUrl("qtbug-22058.qml"));
- QVERIFY(canvas.rootObject() != 0);
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("inputField")));
- QVERIFY(input->hasActiveFocus());
-
- QInputMethodEvent event("", QList<QInputMethodEvent::Attribute>());
- event.setCommitString("<b>Bold<");
- QGuiApplication::sendEvent(input, &event);
- QCOMPARE(input->text(), QString("<b>Bold<"));
- event.setCommitString(">");
- QGuiApplication::sendEvent(input, &event);
- QCOMPARE(input->text(), QString("<b>Bold<>"));
-}
-
-QTEST_MAIN(tst_qquicktextedit)
-
-#include "tst_qquicktextedit.moc"
diff --git a/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro b/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro
deleted file mode 100644
index 08ce675a03..0000000000
--- a/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquicktextinput
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquicktextinput.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
deleted file mode 100644
index 236b12002e..0000000000
--- a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
+++ /dev/null
@@ -1,4703 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include "../../shared/util.h"
-#include <private/qinputmethod_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QFile>
-#include <QtQuick/qquickview.h>
-#include <QtGui/qguiapplication.h>
-#include <QtGui/qstylehints.h>
-#include <QInputMethod>
-#include <private/qquicktextinput_p.h>
-#include <private/qquicktextinput_p_p.h>
-#include <QDebug>
-#include <QDir>
-#include <QStyle>
-#include <QtOpenGL/QGLShaderProgram>
-#include <math.h>
-
-#ifdef Q_OS_MAC
-#include <Carbon/Carbon.h>
-#endif
-
-#include "qplatformdefs.h"
-#include "../../shared/platforminputcontext.h"
-
-Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode)
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-
-QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
-{
- // XXX This will be replaced by some clever persistent platform image store.
- QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory();
- 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;
-}
-
-template <typename T> static T evaluate(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- T result = expr.evaluate().value<T>();
- if (expr.hasError())
- qWarning() << expr.error().toString();
- return result;
-}
-
-typedef QPair<int, QChar> Key;
-
-class tst_qquicktextinput : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_qquicktextinput();
-
-private slots:
- void cleanup();
- void text();
- void width();
- void font();
- void color();
- void wrap();
- void selection();
- void persistentSelection();
- void isRightToLeft_data();
- void isRightToLeft();
- void moveCursorSelection_data();
- void moveCursorSelection();
- void moveCursorSelectionSequence_data();
- void moveCursorSelectionSequence();
- void dragMouseSelection();
- void mouseSelectionMode_data();
- void mouseSelectionMode();
- void tripleClickSelectsAll();
-
- void horizontalAlignment_data();
- void horizontalAlignment();
- void horizontalAlignment_RightToLeft();
- void verticalAlignment();
-
- void boundingRect();
-
- void positionAt();
-
- void maxLength();
- void masks();
- void validators();
- void inputMethods();
-
- void passwordCharacter();
- void cursorDelegate_data();
- void cursorDelegate();
- void cursorVisible();
- void cursorRectangle();
- void navigation();
- void navigation_RTL();
- void copyAndPaste();
- void copyAndPasteKeySequence();
- void canPasteEmpty();
- void canPaste();
- void readOnly();
-
- void openInputPanel();
- void setHAlignClearCache();
- void focusOutClearSelection();
-
- void echoMode();
-#ifdef QT_GUI_PASSWORD_ECHO_DELAY
- void passwordEchoDelay();
-#endif
- void geometrySignals();
- void contentSize();
-
- void preeditAutoScroll();
- void preeditCursorRectangle();
- void inputContextMouseHandler();
- void inputMethodComposing();
- void inputMethodUpdate();
- void cursorRectangleSize();
-
- void getText_data();
- void getText();
- void insert_data();
- void insert();
- void remove_data();
- void remove();
-
- void keySequence_data();
- void keySequence();
-
- void undo_data();
- void undo();
- void redo_data();
- void redo();
- void undo_keypressevents_data();
- void undo_keypressevents();
-
- void QTBUG_19956();
- void QTBUG_19956_data();
- void QTBUG_19956_regexp();
-
- void negativeDimensions();
-
-private:
- void simulateKey(QQuickView *, int key);
-
- void simulateKeys(QWindow *window, const QList<Key> &keys);
- void simulateKeys(QWindow *window, const QKeySequence &sequence);
-
- QDeclarativeEngine engine;
- QStringList standard;
- QStringList colorStrings;
-};
-
-typedef QList<int> IntList;
-Q_DECLARE_METATYPE(IntList)
-
-typedef QList<Key> KeyList;
-Q_DECLARE_METATYPE(KeyList)
-
-void tst_qquicktextinput::simulateKeys(QWindow *window, const QList<Key> &keys)
-{
- for (int i = 0; i < keys.count(); ++i) {
- const int key = keys.at(i).first;
- const int modifiers = key & Qt::KeyboardModifierMask;
- const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
-
- QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
- QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
-
- QGuiApplication::sendEvent(window, &press);
- QGuiApplication::sendEvent(window, &release);
- }
-}
-
-void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence)
-{
- for (int i = 0; i < sequence.count(); ++i) {
- const int key = sequence[i];
- const int modifiers = key & Qt::KeyboardModifierMask;
-
- QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers));
- }
-}
-
-QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
-{
- for (int i = 0; i < sequence.count(); ++i)
- keys << Key(sequence[i], QChar());
- return keys;
-}
-
-template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
-{
- for (int i = 0; i < N - 1; ++i) {
- int key = QTest::asciiToKey(characters[i]);
- QChar character = QLatin1Char(characters[i]);
- keys << Key(key, character);
- }
- return keys;
-}
-
-QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
-{
- keys << Key(key, QChar());
- return keys;
-}
-
-void tst_qquicktextinput::cleanup()
-{
- // ensure not even skipped tests with custom input context leave it dangling
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = 0;
-}
-
-tst_qquicktextinput::tst_qquicktextinput()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "It's supercalifragisiticexpialidocious!"
- << "Hello, world!"
- << "!dlrow ,olleH"
- << " spacey text ";
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
-}
-
-void tst_qquicktextinput::text()
-{
- {
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), QString(""));
- QCOMPARE(textinputObject->length(), 0);
-
- delete textinputObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), standard.at(i));
- QCOMPARE(textinputObject->length(), standard.at(i).length());
-
- delete textinputObject;
- }
-
-}
-
-void tst_qquicktextinput::width()
-{
- // uses Font metrics to find the width for standard
- {
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->width(), 0.0);
-
- delete textinputObject;
- }
-
- bool requiresUnhintedMetrics = !qmlDisableDistanceField();
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QString s = standard.at(i);
- s.replace(QLatin1Char('\n'), QChar::LineSeparator);
-
- QTextLayout layout(s);
- layout.setFont(textinputObject->font());
- layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
- if (requiresUnhintedMetrics) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
-
- layout.beginLayout();
- forever {
- QTextLine line = layout.createLine();
- if (!line.isValid())
- break;
- }
-
- layout.endLayout();
-
- qreal metricWidth = ceil(layout.boundingRect().width());
-
- QVERIFY(textinputObject != 0);
- int delta = abs(int(int(textinputObject->width()) - metricWidth));
- QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform.
-
- delete textinputObject;
- }
-}
-
-void tst_qquicktextinput::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().pointSize(), 40);
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().bold(), true);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().italic(), true);
- QCOMPARE(textinputObject->font().bold(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString(""));
-
- delete textinputObject;
- }
-}
-
-void tst_qquicktextinput::color()
-{
- //test color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- //test selection color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- //test selected text color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), testColor);
-
- delete textinputObject;
- }
-}
-
-void tst_qquicktextinput::wrap()
-{
- int textHeight = 0;
- // for specified width and wrap set true
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nTextInput { text: \"Hello\"; wrapMode: Text.WrapAnywhere; width: 300 }", QUrl::fromLocalFile(""));
- QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
- textHeight = textObject->height();
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->wrapMode() == QQuickTextInput::WrapAnywhere);
- QCOMPARE(textObject->width(), 300.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.count(); i++) {
- QString componentStr = "import QtQuick 2.0\nTextInput { wrapMode: Text.WrapAnywhere; width: 30; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- int oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
-
- delete textObject;
- }
-}
-
-void tst_qquicktextinput::selection()
-{
- QString testStr = standard[0];
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
-
- //Test selection follows cursor
- for (int i=0; i<= testStr.size(); i++) {
- textinputObject->setCursorPosition(i);
- QCOMPARE(textinputObject->cursorPosition(), i);
- QCOMPARE(textinputObject->selectionStart(), i);
- QCOMPARE(textinputObject->selectionEnd(), i);
- QVERIFY(textinputObject->selectedText().isNull());
- }
-
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- // Verify invalid positions are ignored.
- textinputObject->setCursorPosition(-1);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- textinputObject->setCursorPosition(textinputObject->text().count()+1);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- //Test selection
- for (int i=0; i<= testStr.size(); i++) {
- textinputObject->select(0,i);
- QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
- }
- for (int i=0; i<= testStr.size(); i++) {
- textinputObject->select(i,testStr.size());
- QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
- }
-
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- //Test Error Ignoring behaviour
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(-10,0);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(100,110);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,-10);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,100);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(-10,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(100,101);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(0,-10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(0,100);
- QVERIFY(textinputObject->selectedText().size() == 10);
-
- textinputObject->deselect();
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->deselect();
- QVERIFY(textinputObject->selectedText().isNull());
-
- // test input method selection
- QSignalSpy selectionSpy(textinputObject, SIGNAL(selectedTextChanged()));
- textinputObject->setFocus(true);
- {
- QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant());
- QInputMethodEvent event("", attributes);
- QGuiApplication::sendEvent(textinputObject, &event);
- }
- QCOMPARE(selectionSpy.count(), 1);
- QCOMPARE(textinputObject->selectionStart(), 12);
- QCOMPARE(textinputObject->selectionEnd(), 17);
-
- delete textinputObject;
-}
-
-void tst_qquicktextinput::persistentSelection()
-{
- QQuickView canvas(testFileUrl("persistentSelection.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
- canvas.requestActivateWindow();
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(input);
- QVERIFY(input->hasActiveFocus());
-
- QSignalSpy spy(input, SIGNAL(persistentSelectionChanged()));
-
- QCOMPARE(input->persistentSelection(), false);
-
- input->setPersistentSelection(false);
- QCOMPARE(input->persistentSelection(), false);
- QCOMPARE(spy.count(), 0);
-
- input->select(1, 4);
- QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
-
- input->setFocus(false);
- QCOMPARE(input->property("selected").toString(), QString());
-
- input->setFocus(true);
- QCOMPARE(input->property("selected").toString(), QString());
-
- input->setPersistentSelection(true);
- QCOMPARE(input->persistentSelection(), true);
- QCOMPARE(spy.count(), 1);
-
- input->select(1, 4);
- QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
-
- input->setFocus(false);
- QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
-
- input->setFocus(true);
- QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
-}
-
-void tst_qquicktextinput::isRightToLeft_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("emptyString");
- QTest::addColumn<bool>("firstCharacter");
- QTest::addColumn<bool>("lastCharacter");
- QTest::addColumn<bool>("middleCharacter");
- QTest::addColumn<bool>("startString");
- QTest::addColumn<bool>("midString");
- QTest::addColumn<bool>("endString");
-
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
- QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
- QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
- QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
- QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
- QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
-}
-
-void tst_qquicktextinput::isRightToLeft()
-{
- QFETCH(QString, text);
- QFETCH(bool, emptyString);
- QFETCH(bool, firstCharacter);
- QFETCH(bool, lastCharacter);
- QFETCH(bool, middleCharacter);
- QFETCH(bool, startString);
- QFETCH(bool, midString);
- QFETCH(bool, endString);
-
- QQuickTextInput textInput;
- textInput.setText(text);
-
- // first test that the right string is delivered to the QString::isRightToLeft()
- QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
-
- // then test that the feature actually works
- QCOMPARE(textInput.isRightToLeft(0,0), emptyString);
- QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter);
- QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
- QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
- QCOMPARE(textInput.isRightToLeft(0,text.count()/4), startString);
- QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), midString);
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), endString);
-}
-
-void tst_qquicktextinput::moveCursorSelection_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition");
- QTest::addColumn<QQuickTextInput::SelectionMode>("mode");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<bool>("reversible");
-
- // () contains the text selected by the cursor.
- // <> contains the actual selection.
-
- QTest::newRow("(t)he|characters")
- << standard[0] << 0 << 1 << QQuickTextInput::SelectCharacters << 0 << 1 << true;
- QTest::newRow("do(g)|characters")
- << standard[0] << 43 << 44 << QQuickTextInput::SelectCharacters << 43 << 44 << true;
- QTest::newRow("jum(p)ed|characters")
- << standard[0] << 23 << 24 << QQuickTextInput::SelectCharacters << 23 << 24 << true;
- QTest::newRow("jumped( )over|characters")
- << standard[0] << 26 << 27 << QQuickTextInput::SelectCharacters << 26 << 27 << true;
- QTest::newRow("(the )|characters")
- << standard[0] << 0 << 4 << QQuickTextInput::SelectCharacters << 0 << 4 << true;
- QTest::newRow("( dog)|characters")
- << standard[0] << 40 << 44 << QQuickTextInput::SelectCharacters << 40 << 44 << true;
- QTest::newRow("( jumped )|characters")
- << standard[0] << 19 << 27 << QQuickTextInput::SelectCharacters << 19 << 27 << true;
- QTest::newRow("th(e qu)ick|characters")
- << standard[0] << 2 << 6 << QQuickTextInput::SelectCharacters << 2 << 6 << true;
- QTest::newRow("la(zy d)og|characters")
- << standard[0] << 38 << 42 << QQuickTextInput::SelectCharacters << 38 << 42 << true;
- QTest::newRow("jum(ped ov)er|characters")
- << standard[0] << 23 << 29 << QQuickTextInput::SelectCharacters << 23 << 29 << true;
- QTest::newRow("()the|characters")
- << standard[0] << 0 << 0 << QQuickTextInput::SelectCharacters << 0 << 0 << true;
- QTest::newRow("dog()|characters")
- << standard[0] << 44 << 44 << QQuickTextInput::SelectCharacters << 44 << 44 << true;
- QTest::newRow("jum()ped|characters")
- << standard[0] << 23 << 23 << QQuickTextInput::SelectCharacters << 23 << 23 << true;
-
- QTest::newRow("<(t)he>|words")
- << standard[0] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 3 << true;
- QTest::newRow("<do(g)>|words")
- << standard[0] << 43 << 44 << QQuickTextInput::SelectWords << 41 << 44 << true;
- QTest::newRow("<jum(p)ed>|words")
- << standard[0] << 23 << 24 << QQuickTextInput::SelectWords << 20 << 26 << true;
- QTest::newRow("<jumped( )>over|words,ltr")
- << standard[0] << 26 << 27 << QQuickTextInput::SelectWords << 20 << 27 << false;
- QTest::newRow("jumped<( )over>|words,rtl")
- << standard[0] << 27 << 26 << QQuickTextInput::SelectWords << 26 << 31 << false;
- QTest::newRow("<(the )>quick|words,ltr")
- << standard[0] << 0 << 4 << QQuickTextInput::SelectWords << 0 << 4 << false;
- QTest::newRow("<(the )quick>|words,rtl")
- << standard[0] << 4 << 0 << QQuickTextInput::SelectWords << 0 << 9 << false;
- QTest::newRow("<lazy( dog)>|words,ltr")
- << standard[0] << 40 << 44 << QQuickTextInput::SelectWords << 36 << 44 << false;
- QTest::newRow("lazy<( dog)>|words,rtl")
- << standard[0] << 44 << 40 << QQuickTextInput::SelectWords << 40 << 44 << false;
- QTest::newRow("<fox( jumped )>over|words,ltr")
- << standard[0] << 19 << 27 << QQuickTextInput::SelectWords << 16 << 27 << false;
- QTest::newRow("fox<( jumped )over>|words,rtl")
- << standard[0] << 27 << 19 << QQuickTextInput::SelectWords << 19 << 31 << false;
- QTest::newRow("<th(e qu)ick>|words")
- << standard[0] << 2 << 6 << QQuickTextInput::SelectWords << 0 << 9 << true;
- QTest::newRow("<la(zy d)og|words>")
- << standard[0] << 38 << 42 << QQuickTextInput::SelectWords << 36 << 44 << true;
- QTest::newRow("<jum(ped ov)er>|words")
- << standard[0] << 23 << 29 << QQuickTextInput::SelectWords << 20 << 31 << true;
- QTest::newRow("<()>the|words")
- << standard[0] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true;
- QTest::newRow("dog<()>|words")
- << standard[0] << 44 << 44 << QQuickTextInput::SelectWords << 44 << 44 << true;
- QTest::newRow("jum<()>ped|words")
- << standard[0] << 23 << 23 << QQuickTextInput::SelectWords << 23 << 23 << true;
-
- QTest::newRow("Hello<(,)> |words")
- << standard[2] << 5 << 6 << QQuickTextInput::SelectWords << 5 << 6 << true;
- QTest::newRow("Hello<(, )>world|words,ltr")
- << standard[2] << 5 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello<(, )world>|words,rtl")
- << standard[2] << 7 << 5 << QQuickTextInput::SelectWords << 5 << 12 << false;
- QTest::newRow("<Hel(lo, )>world|words,ltr")
- << standard[2] << 3 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("<Hel(lo, )world>|words,rtl")
- << standard[2] << 7 << 3 << QQuickTextInput::SelectWords << 0 << 12 << false;
- QTest::newRow("<Hel(lo)>,|words")
- << standard[2] << 3 << 5 << QQuickTextInput::SelectWords << 0 << 5 << true;
- QTest::newRow("Hello<()>,|words")
- << standard[2] << 5 << 5 << QQuickTextInput::SelectWords << 5 << 5 << true;
- QTest::newRow("Hello,<()>|words")
- << standard[2] << 6 << 6 << QQuickTextInput::SelectWords << 6 << 6 << true;
- QTest::newRow("Hello<,( )>world|words,ltr")
- << standard[2] << 6 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello,<( )world>|words,rtl")
- << standard[2] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world)>|words,ltr")
- << standard[2] << 6 << 12 << QQuickTextInput::SelectWords << 5 << 12 << false;
- QTest::newRow("Hello,<( world)>|words,rtl")
- << standard[2] << 12 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world!)>|words,ltr")
- << standard[2] << 6 << 13 << QQuickTextInput::SelectWords << 5 << 13 << false;
- QTest::newRow("Hello,<( world!)>|words,rtl")
- << standard[2] << 13 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false;
- QTest::newRow("Hello<(, world!)>|words")
- << standard[2] << 5 << 13 << QQuickTextInput::SelectWords << 5 << 13 << true;
- // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings.
- // QTBUG-11365
- // QTest::newRow("world<(!)>|words")
- // << standard[2] << 12 << 13 << QQuickTextInput::SelectWords << 12 << 13 << true;
- QTest::newRow("world!<()>)|words")
- << standard[2] << 13 << 13 << QQuickTextInput::SelectWords << 13 << 13 << true;
- QTest::newRow("world<()>!)|words")
- << standard[2] << 12 << 12 << QQuickTextInput::SelectWords << 12 << 12 << true;
-
- QTest::newRow("<(,)>olleH |words")
- << standard[3] << 7 << 8 << QQuickTextInput::SelectWords << 7 << 8 << true;
- QTest::newRow("<dlrow( ,)>olleH|words,ltr")
- << standard[3] << 6 << 8 << QQuickTextInput::SelectWords << 1 << 8 << false;
- QTest::newRow("dlrow<( ,)>olleH|words,rtl")
- << standard[3] << 8 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false;
- QTest::newRow("<dlrow( ,ol)leH>|words,ltr")
- << standard[3] << 6 << 10 << QQuickTextInput::SelectWords << 1 << 13 << false;
- QTest::newRow("dlrow<( ,ol)leH>|words,rtl")
- << standard[3] << 10 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false;
- QTest::newRow(",<(ol)leH>,|words")
- << standard[3] << 8 << 10 << QQuickTextInput::SelectWords << 8 << 13 << true;
- QTest::newRow(",<()>olleH|words")
- << standard[3] << 8 << 8 << QQuickTextInput::SelectWords << 8 << 8 << true;
- QTest::newRow("<()>,olleH|words")
- << standard[3] << 7 << 7 << QQuickTextInput::SelectWords << 7 << 7 << true;
- QTest::newRow("<dlrow( )>,olleH|words,ltr")
- << standard[3] << 6 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false;
- QTest::newRow("dlrow<( ),>olleH|words,rtl")
- << standard[3] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false;
- QTest::newRow("<(dlrow )>,olleH|words,ltr")
- << standard[3] << 1 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false;
- QTest::newRow("<(dlrow ),>olleH|words,rtl")
- << standard[3] << 7 << 1 << QQuickTextInput::SelectWords << 1 << 8 << false;
- QTest::newRow("<(!dlrow )>,olleH|words,ltr")
- << standard[3] << 0 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("<(!dlrow ),>olleH|words,rtl")
- << standard[3] << 7 << 0 << QQuickTextInput::SelectWords << 0 << 8 << false;
- QTest::newRow("(!dlrow ,)olleH|words")
- << standard[3] << 0 << 8 << QQuickTextInput::SelectWords << 0 << 8 << true;
- QTest::newRow("<(!)>dlrow|words")
- << standard[3] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << true;
- QTest::newRow("<()>!dlrow|words")
- << standard[3] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true;
- QTest::newRow("!<()>dlrow|words")
- << standard[3] << 1 << 1 << QQuickTextInput::SelectWords << 1 << 1 << true;
-
- QTest::newRow(" <s(pac)ey> text |words")
- << standard[4] << 1 << 4 << QQuickTextInput::SelectWords << 1 << 7 << true;
- QTest::newRow(" spacey <t(ex)t> |words")
- << standard[4] << 11 << 13 << QQuickTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365
- QTest::newRow("<( )>spacey text |words|ltr")
- << standard[4] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << false;
- QTest::newRow("<( )spacey> text |words|rtl")
- << standard[4] << 1 << 0 << QQuickTextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("spacey <text( )>|words|ltr")
- << standard[4] << 14 << 15 << QQuickTextInput::SelectWords << 10 << 15 << false;
-// QTBUG-11365
-// QTest::newRow("spacey text<( )>|words|rtl")
-// << standard[4] << 15 << 14 << QQuickTextInput::SelectWords << 14 << 15 << false;
- QTest::newRow("<()> spacey text |words")
- << standard[4] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << false;
- QTest::newRow(" spacey text <()>|words")
- << standard[4] << 15 << 15 << QQuickTextInput::SelectWords << 15 << 15 << false;
-}
-
-void tst_qquicktextinput::moveCursorSelection()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition);
- QFETCH(QQuickTextInput::SelectionMode, mode);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(bool, reversible);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
- textinputObject->setCursorPosition(cursorPosition);
- textinputObject->moveCursorSelection(movePosition, mode);
-
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(textinputObject->selectionStart(), selectionStart);
- QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
-
- if (reversible) {
- textinputObject->setCursorPosition(movePosition);
- textinputObject->moveCursorSelection(cursorPosition, mode);
-
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(textinputObject->selectionStart(), selectionStart);
- QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
- }
-
- delete textinputObject;
-}
-
-void tst_qquicktextinput::moveCursorSelectionSequence_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition1");
- QTest::addColumn<int>("movePosition2");
- QTest::addColumn<int>("selection1Start");
- QTest::addColumn<int>("selection1End");
- QTest::addColumn<int>("selection2Start");
- QTest::addColumn<int>("selection2End");
-
- // () contains the text selected by the cursor.
- // <> contains the actual selection.
- // ^ is the revised cursor position.
- // {} contains the revised selection.
-
- QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
- << standard[0]
- << 9 << 13 << 17
- << 4 << 15
- << 4 << 19;
- QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
- << standard[0]
- << 13 << 9 << 17
- << 9 << 15
- << 10 << 19;
- QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 16
- << 4 << 15
- << 4 << 16;
- QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
- << standard[0]
- << 13 << 9 << 16
- << 9 << 15
- << 10 << 16;
- QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 15
- << 4 << 15
- << 4 << 15;
- QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
- << standard[0]
- << 13 << 9 << 15
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 10
- << 4 << 15
- << 4 << 10;
- QTest::newRow("the quick<( {^bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 10
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 9
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 9
- << 9 << 15
- << 9 << 15;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 7
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 7
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 4
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 4
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 3
- << 4 << 15
- << 3 << 9;
- QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 3
- << 9 << 15
- << 3 << 15;
- QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 1
- << 4 << 15
- << 0 << 9;
- QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 1
- << 9 << 15
- << 0 << 15;
-
- QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
- << standard[2]
- << 2 << 4 << 8
- << 0 << 5
- << 0 << 12;
- QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
- << standard[2]
- << 4 << 2 << 8
- << 0 << 5
- << 0 << 12;
-
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
- << standard[3]
- << 9 << 11 << 5
- << 8 << 13
- << 1 << 13;
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
- << standard[3]
- << 11 << 9 << 5
- << 8 << 13
- << 1 << 13;
-
- QTest::newRow("{<(^} sp)acey> text |ltr")
- << standard[4]
- << 0 << 3 << 0
- << 0 << 7
- << 0 << 0;
- QTest::newRow("{<( ^}sp)acey> text |ltr")
- << standard[4]
- << 0 << 3 << 1
- << 0 << 7
- << 0 << 1;
- QTest::newRow("<( {s^p)acey>} text |rtl")
- << standard[4]
- << 3 << 0 << 2
- << 0 << 7
- << 1 << 7;
- QTest::newRow("<( {^sp)acey>} text |rtl")
- << standard[4]
- << 3 << 0 << 1
- << 0 << 7
- << 1 << 7;
-
- QTest::newRow(" spacey <te(xt {^)>}|rtl")
- << standard[4]
- << 15 << 12 << 15
- << 10 << 15
- << 15 << 15;
-// QTBUG-11365
-// QTest::newRow(" spacey <te(xt{^ )>}|rtl")
-// << standard[4]
-// << 15 << 12 << 14
-// << 10 << 15
-// << 14 << 15;
- QTest::newRow(" spacey {<te(x^t} )>|ltr")
- << standard[4]
- << 12 << 15 << 13
- << 10 << 15
- << 10 << 14;
-// QTBUG-11365
-// QTest::newRow(" spacey {<te(xt^} )>|ltr")
-// << standard[4]
-// << 12 << 15 << 14
-// << 10 << 15
-// << 10 << 14;
-}
-
-void tst_qquicktextinput::moveCursorSelectionSequence()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition1);
- QFETCH(int, movePosition2);
- QFETCH(int, selection1Start);
- QFETCH(int, selection1End);
- QFETCH(int, selection2Start);
- QFETCH(int, selection2End);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
- textinputObject->setCursorPosition(cursorPosition);
-
- textinputObject->moveCursorSelection(movePosition1, QQuickTextInput::SelectWords);
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
- QCOMPARE(textinputObject->selectionStart(), selection1Start);
- QCOMPARE(textinputObject->selectionEnd(), selection1End);
-
- textinputObject->moveCursorSelection(movePosition2, QQuickTextInput::SelectWords);
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
- QCOMPARE(textinputObject->selectionStart(), selection2Start);
- QCOMPARE(textinputObject->selectionEnd(), selection2End);
-
- delete textinputObject;
-}
-
-void tst_qquicktextinput::dragMouseSelection()
-{
- QString qmlfile = testFile("mouseselection_true.qml");
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *textInputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(100);
- QString str1;
- QVERIFY((str1 = textInputObject->selectedText()).length() > 3);
- QVERIFY(str1.length() > 3);
-
- // press and drag the current selection.
- x1 = 40;
- x2 = 100;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(300);
- QString str2 = textInputObject->selectedText();
- QVERIFY(str2.length() > 3);
-
- QVERIFY(str1 != str2);
-}
-
-void tst_qquicktextinput::mouseSelectionMode_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<bool>("selectWords");
-
- // import installed
- QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
- QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
- QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
-}
-
-void tst_qquicktextinput::mouseSelectionMode()
-{
- QFETCH(QString, qmlfile);
- QFETCH(bool, selectWords);
-
- QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *textInputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2,y)); // doesn't work
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(300);
- if (selectWords) {
- QTRY_COMPARE(textInputObject->selectedText(), text);
- } else {
- QTRY_VERIFY(textInputObject->selectedText().length() > 3);
- QVERIFY(textInputObject->selectedText() != text);
- }
-}
-
-void tst_qquicktextinput::horizontalAlignment_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<QString>("expectfile");
-
- 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_qquicktextinput::horizontalAlignment()
-{
- QSKIP("Image comparison of text is almost guaranteed to fail during development");
-
- QFETCH(int, hAlign);
- QFETCH(QString, expectfile);
-
- QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
- QObject *ob = canvas.rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- QImage actual = canvas.grabFrameBuffer();
-
- expectfile = createExpectedFileIfNotFound(expectfile, actual);
-
- QImage expect(expectfile);
-
- QCOMPARE(actual,expect);
-}
-
-void tst_qquicktextinput::horizontalAlignment_RightToLeft()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
- QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
- QVERIFY(textInput != 0);
- canvas.show();
-
- const QString rtlText = textInput->text();
-
- QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput);
- QVERIFY(textInputPrivate != 0);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // implicit alignment should follow the reading direction of RTL text
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // explicitly left aligned
- textInput->setHAlign(QQuickTextInput::AlignLeft);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
-
- // explicitly right aligned
- textInput->setHAlign(QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // explicitly center aligned
- textInput->setHAlign(QQuickTextInput::AlignHCenter);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignHCenter);
- QVERIFY(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll > 0);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll < textInput->width());
-
- // reseted alignment should go back to following the text reading direction
- textInput->resetHAlign();
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // mirror the text item
- QQuickItemPrivate::get(textInput)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // explicitly right aligned behaves as left aligned
- textInput->setHAlign(QQuickTextInput::AlignRight);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
-
- // mirrored explicitly left aligned behaves as right aligned
- textInput->setHAlign(QQuickTextInput::AlignLeft);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // disable mirroring
- QQuickItemPrivate::get(textInput)->setLayoutMirror(false);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- textInput->resetHAlign();
-
- // English text should be implicitly left aligned
- textInput->setText("Hello world!");
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
-
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- // If there is no commited text, the preedit text should determine the alignment.
- textInput->setText(QString());
- { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
-
- // Clear pre-edit text. TextInput should maybe do this itself on setText, but that may be
- // redundant as an actual input method may take care of it.
- { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
-
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from QInputMethod::inputDirection()
- textInput->setText("");
- platformInputContext.setInputDirection(Qt::LeftToRight);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
-
- QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged()));
- platformInputContext.setInputDirection(Qt::RightToLeft);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
- QCOMPARE(cursorRectangleSpy.count(), 1);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // set input direction while having content
- platformInputContext.setInputDirection(Qt::LeftToRight);
- textInput->setText("a");
- platformInputContext.setInputDirection(Qt::RightToLeft);
- QTest::keyClick(&canvas, Qt::Key_Backspace);
- QVERIFY(textInput->text().isEmpty());
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // input direction changed while not having focus
- platformInputContext.setInputDirection(Qt::LeftToRight);
- textInput->setFocus(false);
- platformInputContext.setInputDirection(Qt::RightToLeft);
- textInput->setFocus(true);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- textInput->setHAlign(QQuickTextInput::AlignRight);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-}
-
-void tst_qquicktextinput::verticalAlignment()
-{
- QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
- QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
- QVERIFY(textInput != 0);
- canvas.show();
-
- QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput);
- QVERIFY(textInputPrivate != 0);
-
- QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignTop);
- QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll < canvas.height() / 2);
- QVERIFY(textInput->cursorRectangle().bottom() < canvas.height() / 2);
- QVERIFY(textInput->positionToRectangle(0).bottom() < canvas.height() / 2);
-
- // bottom aligned
- textInput->setVAlign(QQuickTextInput::AlignBottom);
- QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignBottom);
- QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll > canvas.height() / 2);
- QVERIFY(textInput->cursorRectangle().top() > canvas.height() / 2);
- QVERIFY(textInput->positionToRectangle(0).top() > canvas.height() / 2);
-
- // explicitly center aligned
- textInput->setVAlign(QQuickTextInput::AlignVCenter);
- QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignVCenter);
- QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll < canvas.height() / 2);
- QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll > canvas.height() / 2);
- QVERIFY(textInput->cursorRectangle().top() < canvas.height() / 2);
- QVERIFY(textInput->cursorRectangle().bottom() > canvas.height() / 2);
- QVERIFY(textInput->positionToRectangle(0).top() < canvas.height() / 2);
- QVERIFY(textInput->positionToRectangle(0).bottom() > canvas.height() / 2);
-}
-
-void tst_qquicktextinput::boundingRect()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\n TextInput {}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(object.data());
- QVERIFY(input);
-
- QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-
- input->setText("Hello World");
- QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-
- // bounding rect shouldn't exceed the size of the item, expect for the cursor width;
- input->setWidth(input->width() / 2);
- QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-
- input->setHeight(input->height() * 2);
- QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-
- QDeclarativeComponent cursorComponent(&engine);
- cursorComponent.setData("import QtQuick 2.0\nRectangle { height: 20; width: 8 }", QUrl());
-
- input->setCursorDelegate(&cursorComponent);
-
- // If a cursor delegate is used it's size should determine the excess width.
- QCOMPARE(input->width() + 8, input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-}
-
-void tst_qquicktextinput::positionAt()
-{
- QQuickView canvas(testFileUrl("positionAt.qml"));
- QVERIFY(canvas.rootObject() != 0);
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textinputObject != 0);
-
- // Check autoscrolled...
-
- int pos = evaluate<int>(textinputObject, QString("positionAt(%1)").arg(textinputObject->width()/2));
-
- QTextLayout layout(textinputObject->text());
- layout.setFont(textinputObject->font());
-
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- int textLeftWidthBegin = floor(line.cursorToX(pos - 1));
- int textLeftWidthEnd = ceil(line.cursorToX(pos + 1));
- int textWidth = floor(line.horizontalAdvance());
-
- QVERIFY(textLeftWidthBegin <= textWidth - textinputObject->width() / 2);
- QVERIFY(textLeftWidthEnd >= textWidth - textinputObject->width() / 2);
-
- int x = textinputObject->positionToRectangle(pos + 1).x() - 1;
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos);
-
- // Check without autoscroll...
- textinputObject->setAutoScroll(false);
- pos = evaluate<int>(textinputObject, QString("positionAt(%1)").arg(textinputObject->width() / 2));
-
- textLeftWidthBegin = floor(line.cursorToX(pos - 1));
- textLeftWidthEnd = ceil(line.cursorToX(pos + 1));
-
- QVERIFY(textLeftWidthBegin <= textinputObject->width() / 2);
- QVERIFY(textLeftWidthEnd >= textinputObject->width() / 2);
-
- x = textinputObject->positionToRectangle(pos + 1).x() - 1;
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos);
-
- const qreal x0 = textinputObject->positionToRectangle(pos).x();
- const qreal x1 = textinputObject->positionToRectangle(pos + 1).x();
-
- QString preeditText = textinputObject->text().mid(0, pos);
- textinputObject->setText(textinputObject->text().mid(pos));
- textinputObject->setCursorPosition(0);
-
- { QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QVERIFY(qGuiApp->focusObject());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); }
-
- // Check all points within the preedit text return the same position.
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(0)), 0);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x0 / 2)), 0);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x0)), 0);
-
- // Verify positioning returns to normal after the preedit text.
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x1)), 1);
- QCOMPARE(textinputObject->positionToRectangle(1).x(), x1);
-
- { QInputMethodEvent inputEvent;
- QVERIFY(qGuiApp->focusObject());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); }
-
- // With wrapping.
- textinputObject->setWrapMode(QQuickTextInput::WrapAnywhere);
-
- const qreal y0 = line.height() / 2;
- const qreal y1 = line.height() * 3 / 2;
-
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y0)), pos);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y0)), pos + 1);
-
- int newLinePos = evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y1));
- QVERIFY(newLinePos > pos);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y1)), newLinePos + 1);
-}
-
-void tst_qquicktextinput::maxLength()
-{
- QQuickView canvas(testFileUrl("maxLength.qml"));
- QVERIFY(canvas.rootObject() != 0);
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textinputObject != 0);
- QVERIFY(textinputObject->text().isEmpty());
- QVERIFY(textinputObject->maxLength() == 10);
- foreach (const QString &str, standard) {
- QVERIFY(textinputObject->text().length() <= 10);
- textinputObject->setText(str);
- QVERIFY(textinputObject->text().length() <= 10);
- }
-
- textinputObject->setText("");
- QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
- for (int i=0; i<20; i++) {
- QTRY_COMPARE(textinputObject->text().length(), qMin(i,10));
- //simulateKey(&canvas, Qt::Key_A);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- }
-}
-
-void tst_qquicktextinput::masks()
-{
- //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
- //QString componentStr = "import QtQuick 2.0\nTextInput { inputMask: 'HHHHhhhh'; }";
- QQuickView canvas(testFileUrl("masks.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textinputObject != 0);
- QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
- QVERIFY(textinputObject->text().length() == 0);
- QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
- QCOMPARE(textinputObject->length(), 8);
- for (int i=0; i<10; i++) {
- QTRY_COMPARE(qMin(i,8), textinputObject->text().length());
- QCOMPARE(textinputObject->length(), 8);
- QCOMPARE(textinputObject->getText(0, qMin(i, 8)), QString(qMin(i, 8), 'a'));
- QCOMPARE(textinputObject->getText(qMin(i, 8), 8), QString(8 - qMin(i, 8), ' '));
- QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
- //simulateKey(&canvas, Qt::Key_A);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- }
-}
-
-void tst_qquicktextinput::validators()
-{
- // Note that this test assumes that the validators are working properly
- // so you may need to run their tests first. All validators are checked
- // here to ensure that their exposure to QML is working.
-
- QLocale::setDefault(QLocale(QStringLiteral("C")));
-
- QQuickView canvas(testFileUrl("validators.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QLocale defaultLocale;
- QLocale enLocale("en");
- QLocale deLocale("de_DE");
-
- QQuickTextInput *intInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("intInput")));
- QVERIFY(intInput);
- QSignalSpy intSpy(intInput, SIGNAL(acceptableInputChanged()));
-
- QQuickIntValidator *intValidator = qobject_cast<QQuickIntValidator *>(intInput->validator());
- QVERIFY(intValidator);
- QCOMPARE(intValidator->localeName(), defaultLocale.name());
- QCOMPARE(intInput->validator()->locale(), defaultLocale);
- intValidator->setLocaleName(enLocale.name());
- QCOMPARE(intValidator->localeName(), enLocale.name());
- QCOMPARE(intInput->validator()->locale(), enLocale);
- intValidator->resetLocaleName();
- QCOMPARE(intValidator->localeName(), defaultLocale.name());
- QCOMPARE(intInput->validator()->locale(), defaultLocale);
-
- intInput->setFocus(true);
- QTRY_VERIFY(intInput->hasActiveFocus());
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QCOMPARE(intInput->property("acceptable").toBool(), false);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QCOMPARE(intInput->property("acceptable").toBool(), false);
- QCOMPARE(intSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_2);
- QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QCOMPARE(intInput->property("acceptable").toBool(), false);
- QCOMPARE(intSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_Period);
- QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(&canvas, Qt::Key_Comma);
- QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1,"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- intValidator->setLocaleName(deLocale.name());
- QTest::keyPress(&canvas, Qt::Key_Period);
- QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1."));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- intValidator->resetLocaleName();
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
- QCOMPARE(intInput->property("acceptable").toBool(), true);
- QCOMPARE(intSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_0);
- QTest::keyRelease(&canvas, Qt::Key_0, Qt::NoModifier ,10);
- QTest::qWait(50);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
- QCOMPARE(intInput->property("acceptable").toBool(), true);
- QCOMPARE(intSpy.count(), 1);
-
- QQuickTextInput *dblInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("dblInput")));
- QVERIFY(dblInput);
- QSignalSpy dblSpy(dblInput, SIGNAL(acceptableInputChanged()));
-
- QQuickDoubleValidator *dblValidator = qobject_cast<QQuickDoubleValidator *>(dblInput->validator());
- QVERIFY(dblValidator);
- QCOMPARE(dblValidator->localeName(), defaultLocale.name());
- QCOMPARE(dblInput->validator()->locale(), defaultLocale);
- dblValidator->setLocaleName(enLocale.name());
- QCOMPARE(dblValidator->localeName(), enLocale.name());
- QCOMPARE(dblInput->validator()->locale(), enLocale);
- dblValidator->resetLocaleName();
- QCOMPARE(dblValidator->localeName(), defaultLocale.name());
- QCOMPARE(dblInput->validator()->locale(), defaultLocale);
-
- dblInput->setFocus(true);
- QVERIFY(dblInput->hasActiveFocus() == true);
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_2);
- QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_Comma);
- QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- dblValidator->setLocaleName(deLocale.name());
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- dblValidator->resetLocaleName();
- QTest::keyPress(&canvas, Qt::Key_Period);
- QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
-
- // Ensure the validator doesn't prevent characters being removed.
- dblInput->setValidator(intInput->validator());
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- // Once unacceptable input is in anything goes until it reaches an acceptable state again.
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QCOMPARE(dblInput->text(), QLatin1String("11"));
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblSpy.count(), 3);
-
- QQuickTextInput *strInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("strInput")));
- QVERIFY(strInput);
- QSignalSpy strSpy(strInput, SIGNAL(acceptableInputChanged()));
- strInput->setFocus(true);
- QVERIFY(strInput->hasActiveFocus() == true);
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QCOMPARE(strInput->property("acceptable").toBool(), false);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String(""));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QCOMPARE(strInput->property("acceptable").toBool(), false);
- QCOMPARE(strSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("a"));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QCOMPARE(strInput->property("acceptable").toBool(), false);
- QCOMPARE(strSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("aa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("aaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
-
- QQuickTextInput *unvalidatedInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("unvalidatedInput")));
- QVERIFY(unvalidatedInput);
- QSignalSpy unvalidatedSpy(unvalidatedInput, SIGNAL(acceptableInputChanged()));
- unvalidatedInput->setFocus(true);
- QVERIFY(unvalidatedInput->hasActiveFocus() == true);
- QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
- QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1"));
- QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
- QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
- QCOMPARE(unvalidatedSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1a"));
- QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
- QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
- QCOMPARE(unvalidatedSpy.count(), 0);
-}
-
-void tst_qquicktextinput::inputMethods()
-{
- QQuickView canvas(testFileUrl("inputmethods.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- // test input method hints
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(input != 0);
- QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText);
- QSignalSpy inputMethodHintSpy(input, SIGNAL(inputMethodHintsChanged()));
- input->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
- input->setInputMethodHints(Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
-
- // default value
- QQuickTextInput plainInput;
- QCOMPARE(plainInput.inputMethodHints(), Qt::ImhNone);
-
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus() == true);
- // test that input method event is committed
- QInputMethodEvent event;
- event.setCommitString( "My ", -12, 0);
- QTRY_COMPARE(qGuiApp->focusObject(), input);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->text(), QString("My Hello world!"));
-
- input->setCursorPosition(2);
- event.setCommitString("Your", -2, 2);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->text(), QString("Your Hello world!"));
- QCOMPARE(input->cursorPosition(), 4);
-
- input->setCursorPosition(7);
- event.setCommitString("Goodbye", -2, 5);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->text(), QString("Your Goodbye world!"));
- QCOMPARE(input->cursorPosition(), 12);
-
- input->setCursorPosition(8);
- event.setCommitString("Our", -8, 4);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->text(), QString("Our Goodbye world!"));
- QCOMPARE(input->cursorPosition(), 7);
-
- // test that basic tentative commit gets to text property on preedit state
- input->setText("");
- QList<QInputMethodEvent::Attribute> attributes;
- QInputMethodEvent preeditEvent("test", attributes);
- preeditEvent.setTentativeCommitString("test");
- QGuiApplication::sendEvent(input, &preeditEvent);
- QCOMPARE(input->text(), QString("test"));
-
- // tentative commit not allowed present in surrounding text
- QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText);
- QGuiApplication::sendEvent(input, &queryEvent);
- QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString(""));
-
- // if text with tentative commit does not validate, not allowed to be part of text property
- input->setText(""); // ensure input state is reset
- QValidator *validator = new QIntValidator(0, 100);
- input->setValidator(validator);
- QGuiApplication::sendEvent(input, &preeditEvent);
- QCOMPARE(input->text(), QString(""));
- input->setValidator(0);
- delete validator;
-
- // input should reset selection even if replacement parameters are out of bounds
- input->setText("text");
- input->setCursorPosition(0);
- input->moveCursorSelection(input->text().length());
- event.setCommitString("replacement", -input->text().length(), input->text().length());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->selectionStart(), input->selectionEnd());
-
- QInputMethodQueryEvent enabledQueryEvent(Qt::ImEnabled);
- QGuiApplication::sendEvent(input, &enabledQueryEvent);
- QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), true);
-
- input->setReadOnly(true);
- QGuiApplication::sendEvent(input, &enabledQueryEvent);
- QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), false);
-}
-
-/*
-TextInput element should only handle left/right keys until the cursor reaches
-the extent of the text, then they should ignore the keys.
-
-*/
-void tst_qquicktextinput::navigation()
-{
- QQuickView canvas(testFileUrl("navigation.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- input->setCursorPosition(0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- //QT-2944: If text is selected, ensure we deselect upon cursor motion
- input->setCursorPosition(input->text().length());
- input->select(0,input->text().length());
- QVERIFY(input->selectionStart() != input->selectionEnd());
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->selectionStart() == input->selectionEnd());
- QVERIFY(input->selectionStart() == input->text().length());
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-
- // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438).
- input->setCursorPosition(2);
- QCOMPARE(input->cursorPosition(),2);
- simulateKey(&canvas, Qt::Key_Up);
- QCOMPARE(input->cursorPosition(),2);
- simulateKey(&canvas, Qt::Key_Down);
- QCOMPARE(input->cursorPosition(),2);
-}
-
-void tst_qquicktextinput::navigation_RTL()
-{
- QQuickView canvas(testFileUrl("navigation.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- input->setText(QString::fromUtf16(arabic_str, 11));
-
- input->setCursorPosition(0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
-
- // move off
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
-
- // move back
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-
- input->setCursorPosition(input->text().length());
- QVERIFY(input->hasActiveFocus() == true);
-
- // move off
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
-
- // move back
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
-}
-
-void tst_qquicktextinput::copyAndPaste() {
-#ifndef QT_NO_CLIPBOARD
-
-#ifdef Q_OS_MAC
- {
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- else
- QSKIP("This machine doesn't support the clipboard");
- }
-#endif
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- // copy and paste
- QCOMPARE(textInput->text().length(), 12);
- textInput->select(0, textInput->text().length());;
- textInput->copy();
- QCOMPARE(textInput->selectedText(), QString("Hello world!"));
- QCOMPARE(textInput->selectedText().length(), 12);
- textInput->setCursorPosition(0);
- QVERIFY(textInput->canPaste());
- textInput->paste();
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // can paste
- QVERIFY(textInput->canPaste());
- textInput->setReadOnly(true);
- QVERIFY(!textInput->canPaste());
- textInput->setReadOnly(false);
- QVERIFY(textInput->canPaste());
-
- // select word
- textInput->setCursorPosition(0);
- textInput->selectWord();
- QCOMPARE(textInput->selectedText(), QString("Hello"));
-
- // select all and cut
- textInput->selectAll();
- textInput->cut();
- QCOMPARE(textInput->text().length(), 0);
- textInput->paste();
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // clear copy buffer
- QClipboard *clipboard = QGuiApplication::clipboard();
- QVERIFY(clipboard);
- clipboard->clear();
- QVERIFY(!textInput->canPaste());
-
- // test that copy functionality is disabled
- // when echo mode is set to hide text/password mode
- int index = 0;
- while (index < 4) {
- QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
- textInput->setEchoMode(echoMode);
- textInput->setText("My password");
- textInput->select(0, textInput->text().length());;
- textInput->copy();
- if (echoMode == QQuickTextInput::Normal) {
- QVERIFY(!clipboard->text().isEmpty());
- QCOMPARE(clipboard->text(), QString("My password"));
- clipboard->clear();
- } else {
- QVERIFY(clipboard->text().isEmpty());
- }
- index++;
- }
-
- delete textInput;
-#endif
-}
-
-void tst_qquicktextinput::copyAndPasteKeySequence() {
-#ifndef QT_NO_CLIPBOARD
-
-#ifdef Q_OS_MAC
- {
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- else
- QSKIP("This machine doesn't support the clipboard");
- }
-#endif
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; focus: true }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- // copy and paste
- QVERIFY(textInput->hasActiveFocus());
- QCOMPARE(textInput->text().length(), 12);
- textInput->select(0, textInput->text().length());
- simulateKeys(&canvas, QKeySequence::Copy);
- QCOMPARE(textInput->selectedText(), QString("Hello world!"));
- QCOMPARE(textInput->selectedText().length(), 12);
- textInput->setCursorPosition(0);
- QVERIFY(textInput->canPaste());
- simulateKeys(&canvas, QKeySequence::Paste);
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // select all and cut
- simulateKeys(&canvas, QKeySequence::SelectAll);
- simulateKeys(&canvas, QKeySequence::Cut);
- QCOMPARE(textInput->text().length(), 0);
- simulateKeys(&canvas, QKeySequence::Paste);
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // clear copy buffer
- QClipboard *clipboard = QGuiApplication::clipboard();
- QVERIFY(clipboard);
- clipboard->clear();
- QVERIFY(!textInput->canPaste());
-
- // test that copy functionality is disabled
- // when echo mode is set to hide text/password mode
- int index = 0;
- while (index < 4) {
- QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
- textInput->setEchoMode(echoMode);
- textInput->setText("My password");
- textInput->select(0, textInput->text().length());;
- simulateKeys(&canvas, QKeySequence::Copy);
- if (echoMode == QQuickTextInput::Normal) {
- QVERIFY(!clipboard->text().isEmpty());
- QCOMPARE(clipboard->text(), QString("My password"));
- clipboard->clear();
- } else {
- QVERIFY(clipboard->text().isEmpty());
- }
- index++;
- }
-
- delete textInput;
-#endif
-}
-
-void tst_qquicktextinput::canPasteEmpty() {
-#ifndef QT_NO_CLIPBOARD
-
- QGuiApplication::clipboard()->clear();
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
- QCOMPARE(textInput->canPaste(), cp);
-
-#endif
-}
-
-void tst_qquicktextinput::canPaste() {
-#ifndef QT_NO_CLIPBOARD
-
- QGuiApplication::clipboard()->setText("Some text");
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
- QCOMPARE(textInput->canPaste(), cp);
-
-#endif
-}
-
-void tst_qquicktextinput::passwordCharacter()
-{
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- textInput->setPasswordCharacter("X");
- qreal implicitWidth = textInput->implicitWidth();
- textInput->setPasswordCharacter(".");
-
- // QTBUG-12383 content is updated and redrawn
- QVERIFY(textInput->implicitWidth() < implicitWidth);
-
- delete textInput;
-}
-
-void tst_qquicktextinput::cursorDelegate_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::newRow("out of line") << testFileUrl("cursorTest.qml");
- QTest::newRow("in line") << testFileUrl("cursorTestInline.qml");
- QTest::newRow("external") << testFileUrl("cursorTestExternal.qml");
-}
-
-void tst_qquicktextinput::cursorDelegate()
-{
- QFETCH(QUrl, source);
- QQuickView view(source);
- view.show();
- view.requestActivateWindow();
- QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject");
- QVERIFY(textInputObject != 0);
- QVERIFY(textInputObject->findChild<QQuickItem*>("cursorInstance"));
- //Test Delegate gets created
- textInputObject->setFocus(true);
- QQuickItem* delegateObject = textInputObject->findChild<QQuickItem*>("cursorInstance");
- QVERIFY(delegateObject);
- QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
- //Test Delegate gets moved
- for (int i=0; i<= textInputObject->text().length(); i++) {
- textInputObject->setCursorPosition(i);
- QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
- QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
- }
- textInputObject->setCursorPosition(0);
- QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
- QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
- //Test Delegate gets deleted
- textInputObject->setCursorDelegate(0);
- QVERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
-}
-
-void tst_qquicktextinput::cursorVisible()
-{
- QQuickView view(testFileUrl("cursorVisible.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextInput input;
- input.componentComplete();
- QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool)));
-
- QCOMPARE(input.isCursorVisible(), false);
-
- input.setCursorVisible(true);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 1);
-
- input.setCursorVisible(false);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- input.setFocus(true);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- input.setParentItem(view.rootObject());
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 3);
-
- input.setFocus(false);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 4);
-
- input.setFocus(true);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 5);
-
- QQuickView alternateView;
- alternateView.show();
- alternateView.requestActivateWindow();
- QTest::qWaitForWindowShown(&alternateView);
-
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 6);
-
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 7);
-}
-
-void tst_qquicktextinput::cursorRectangle()
-{
-
- QString text = "Hello World!";
-
- QQuickTextInput input;
- input.setText(text);
- input.componentComplete();
-
- QTextLayout layout(text);
- layout.setFont(input.font());
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- input.setWidth(line.cursorToX(5, QTextLine::Leading));
- input.setHeight(qCeil(line.height() * 3 / 2));
-
- QRectF r;
-
- // some tolerance for different fonts.
-#ifdef Q_OS_LINUX
- const int error = 2;
-#else
- const int error = 5;
-#endif
-
- for (int i = 0; i <= 5; ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
-
- QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
- QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- // Check the cursor rectangle remains within the input bounding rect when auto scrolling.
- QVERIFY(r.left() < input.width() + error);
- QVERIFY(r.right() >= input.width() - error);
-
- for (int i = 6; i < text.length(); ++i) {
- input.setCursorPosition(i);
- QCOMPARE(r, input.cursorRectangle());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- for (int i = text.length() - 2; i >= 0; --i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QCOMPARE(r.top(), 0.);
- QVERIFY(r.right() >= 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- // Check position with word wrap.
- input.setWrapMode(QQuickTextInput::WordWrap);
- input.setAutoScroll(false);
- for (int i = 0; i <= 5; ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
-
- QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
- QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(r.top(), 0.);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- input.setCursorPosition(6);
- r = input.cursorRectangle();
- QCOMPARE(r.left(), 0.);
- QVERIFY(r.top() > line.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(6), r);
-
- for (int i = 7; i < text.length(); ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QVERIFY(r.top() > line.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- // Check vertical scrolling with word wrap.
- input.setAutoScroll(true);
- for (int i = 0; i <= 5; ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
-
- QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
- QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(r.top(), 0.);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- input.setCursorPosition(6);
- r = input.cursorRectangle();
- QCOMPARE(r.left(), 0.);
- QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(6), r);
-
- for (int i = 7; i < text.length(); ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- for (int i = text.length() - 2; i >= 6; --i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- for (int i = 5; i >= 0; --i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QCOMPARE(r.top(), 0.);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
- QCOMPARE(input.positionToRectangle(i), r);
- }
-
- input.setText("Hi!");
- input.setHAlign(QQuickTextInput::AlignRight);
- r = input.cursorRectangle();
- QVERIFY(r.left() < input.width() + error);
- QVERIFY(r.right() >= input.width() - error);
-}
-
-void tst_qquicktextinput::readOnly()
-{
- QQuickView canvas(testFileUrl("readOnly.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- QVERIFY(input->isReadOnly() == true);
- QString initial = input->text();
- for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
- simulateKey(&canvas, k);
- simulateKey(&canvas, Qt::Key_Return);
- simulateKey(&canvas, Qt::Key_Space);
- simulateKey(&canvas, Qt::Key_Escape);
- QCOMPARE(input->text(), initial);
-
- input->setCursorPosition(3);
- input->setReadOnly(false);
- QCOMPARE(input->isReadOnly(), false);
- QCOMPARE(input->cursorPosition(), input->text().length());
-}
-
-void tst_qquicktextinput::echoMode()
-{
- QQuickView canvas(testFileUrl("echoMode.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- QString initial = input->text();
- Qt::InputMethodHints ref;
- QCOMPARE(initial, QLatin1String("ABCDefgh"));
- QCOMPARE(input->echoMode(), QQuickTextInput::Normal);
- QCOMPARE(input->displayText(), input->text());
- //Normal
- ref &= ~Qt::ImhHiddenText;
- ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- input->setEchoMode(QQuickTextInput::NoEcho);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String(""));
- QCOMPARE(input->passwordCharacter(), QLatin1String("*"));
- //NoEcho
- ref |= Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- input->setEchoMode(QQuickTextInput::Password);
- //Password
- ref |= Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("********"));
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- // clearing input hints do not clear bits set by echo mode
- input->setInputMethodHints(Qt::ImhNone);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- input->setPasswordCharacter(QChar('Q'));
- QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
- input->setEchoMode(QQuickTextInput::PasswordEchoOnEdit);
- //PasswordEchoOnEdit
- ref &= ~Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));
- QTest::keyPress(&canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(input->text(), QLatin1String("a"));
- QCOMPARE(input->displayText(), QLatin1String("a"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a"));
- input->setFocus(false);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->displayText(), QLatin1String("Q"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q"));
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus());
- QInputMethodEvent inputEvent;
- inputEvent.setCommitString(initial);
- QGuiApplication::sendEvent(input, &inputEvent);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), initial);
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);
-}
-
-#ifdef QT_GUI_PASSWORD_ECHO_DELAY
-void tst_qquicktextinput::passwordEchoDelay()
-{
- QQuickView canvas(testFileUrl("echoMode.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QChar fillChar = QLatin1Char('*');
-
- input->setEchoMode(QQuickTextInput::Password);
- QCOMPARE(input->displayText(), QString(8, fillChar));
- input->setText(QString());
- QCOMPARE(input->displayText(), QString());
-
- QTest::keyPress(&canvas, '0');
- QTest::keyPress(&canvas, '1');
- QTest::keyPress(&canvas, '2');
- QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2'));
- QTest::keyPress(&canvas, '3');
- QTest::keyPress(&canvas, '4');
- QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QCOMPARE(input->displayText(), QString(4, fillChar));
- QTest::keyPress(&canvas, '4');
- QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
- QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY);
- QTRY_COMPARE(input->displayText(), QString(5, fillChar));
- QTest::keyPress(&canvas, '5');
- QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5'));
- input->setFocus(false);
- QVERIFY(!input->hasFocus());
- QCOMPARE(input->displayText(), QString(6, fillChar));
- input->setFocus(true);
- QTRY_VERIFY(input->hasFocus());
- QCOMPARE(input->displayText(), QString(6, fillChar));
- QTest::keyPress(&canvas, '6');
- QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6'));
-
- QInputMethodEvent ev;
- ev.setCommitString(QLatin1String("7"));
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev);
- QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
-
- input->setCursorPosition(3);
- QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
- QTest::keyPress(&canvas, 'a');
- QCOMPARE(input->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar));
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QCOMPARE(input->displayText(), QString(8, fillChar));
-}
-#endif
-
-
-void tst_qquicktextinput::simulateKey(QQuickView *view, int key)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, 0);
- QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
-
- QGuiApplication::sendEvent(view, &press);
- QGuiApplication::sendEvent(view, &release);
-}
-
-
-void tst_qquicktextinput::openInputPanel()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView view(testFileUrl("openInputPanel.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
-
- // check default values
- QVERIFY(input->focusOnPress());
- QVERIFY(!input->hasActiveFocus());
- QVERIFY(qApp->focusObject() != input);
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should open on focus
- QPoint centerPoint(view.width()/2, view.height()/2);
- Qt::KeyboardModifiers noModifiers = 0;
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QVERIFY(input->hasActiveFocus());
- QCOMPARE(qApp->focusObject(), input);
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-
- // input panel should be re-opened when pressing already focused TextInput
- qApp->inputMethod()->hide();
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QVERIFY(input->hasActiveFocus());
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-
- // input panel should stay visible if focus is lost to another text inputor
- QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
- QQuickTextInput anotherInput;
- anotherInput.componentComplete();
- anotherInput.setParentItem(view.rootObject());
- anotherInput.setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherInput));
- QCOMPARE(inputPanelVisibilitySpy.count(), 0);
-
- anotherInput.setFocus(false);
- QVERIFY(qApp->focusObject() != &anotherInput);
- QCOMPARE(view.activeFocusItem(), view.rootItem());
- anotherInput.setFocus(true);
-
- qApp->inputMethod()->hide();
-
- // input panel should not be opened if TextInput is read only
- input->setReadOnly(true);
- input->setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should not be opened if focusOnPress is set to false
- input->setFocusOnPress(false);
- input->setFocus(false);
- input->setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should open when openSoftwareInputPanel is called
- input->openSoftwareInputPanel();
- QCOMPARE(qApp->inputMethod()->visible(), true);
-
- // input panel should close when closeSoftwareInputPanel is called
- input->closeSoftwareInputPanel();
- QCOMPARE(qApp->inputMethod()->visible(), false);
-}
-
-class MyTextInput : public QQuickTextInput
-{
-public:
- MyTextInput(QQuickItem *parent = 0) : QQuickTextInput(parent)
- {
- nbPaint = 0;
- }
- virtual QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data)
- {
- nbPaint++;
- return QQuickTextInput::updatePaintNode(node, data);
- }
- int nbPaint;
-};
-
-void tst_qquicktextinput::setHAlignClearCache()
-{
- QQuickView view;
- MyTextInput input;
- input.setText("Hello world");
- input.setParentItem(view.rootItem());
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", "QTBUG-23485", Abort);
-#endif
- QTRY_COMPARE(input.nbPaint, 1);
- input.setHAlign(QQuickTextInput::AlignRight);
- //Changing the alignment should trigger a repaint
- QTRY_COMPARE(input.nbPaint, 2);
-}
-
-void tst_qquicktextinput::focusOutClearSelection()
-{
- QQuickView view;
- QQuickTextInput input;
- QQuickTextInput input2;
- input.setText(QLatin1String("Hello world"));
- input.setFocus(true);
- input2.setParentItem(view.rootItem());
- input.setParentItem(view.rootItem());
- input.componentComplete();
- input2.componentComplete();
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- input.select(2,5);
- //The selection should work
- QTRY_COMPARE(input.selectedText(), QLatin1String("llo"));
- input2.setFocus(true);
- QGuiApplication::processEvents();
- //The input lost the focus selection should be cleared
- QTRY_COMPARE(input.selectedText(), QLatin1String(""));
-}
-
-void tst_qquicktextinput::geometrySignals()
-{
- QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml"));
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("bindingWidth").toInt(), 400);
- QCOMPARE(o->property("bindingHeight").toInt(), 500);
- delete o;
-}
-
-void tst_qquicktextinput::contentSize()
-{
- QString componentStr = "import QtQuick 2.0\nTextInput { width: 75; height: 16; font.pixelSize: 10 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickTextInput *textObject = qobject_cast<QQuickTextInput *>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
-
- textObject->setText("The quick red fox jumped over the lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
-
- textObject->setWrapMode(QQuickTextInput::WordWrap);
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
-
- textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 3);
-}
-
-static void sendPreeditText(const QString &text, int cursor)
-{
- QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.length(), QVariant()));
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &event);
-}
-
-void tst_qquicktextinput::preeditAutoScroll()
-{
- QString preeditText = "califragisiticexpialidocious!";
-
- QQuickView view(testFileUrl("preeditAutoScroll.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
- QVERIFY(input->hasActiveFocus());
-
- input->setWidth(input->implicitWidth());
-
- QSignalSpy cursorRectangleSpy(input, SIGNAL(cursorRectangleChanged()));
- int cursorRectangleChanges = 0;
-
- // test the text is scrolled so the preedit is visible.
- sendPreeditText(preeditText.mid(0, 3), 1);
- QVERIFY(evaluate<int>(input, QString("positionAt(0)")) != 0);
- QVERIFY(input->cursorRectangle().left() < input->boundingRect().width());
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
-
- // test the text is scrolled back when the preedit is removed.
- QInputMethodEvent imEvent;
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
- QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
-
- QTextLayout layout(preeditText);
- layout.setFont(input->font());
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- // test if the preedit is larger than the text input that the
- // character preceding the cursor is still visible.
- qreal x = input->positionToRectangle(0).x();
- for (int i = 0; i < 3; ++i) {
- sendPreeditText(preeditText, i + 1);
- int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
- QVERIFY(input->cursorRectangle().right() >= width - 3);
- QVERIFY(input->positionToRectangle(0).x() < x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input->positionToRectangle(0).x();
- }
- for (int i = 1; i >= 0; --i) {
- sendPreeditText(preeditText, i + 1);
- int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
- QVERIFY(input->cursorRectangle().right() >= width - 3);
- QVERIFY(input->positionToRectangle(0).x() > x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input->positionToRectangle(0).x();
- }
-
- // Test incrementing the preedit cursor doesn't cause further
- // scrolling when right most text is visible.
- sendPreeditText(preeditText, preeditText.length() - 3);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input->positionToRectangle(0).x();
- for (int i = 2; i >= 0; --i) {
- sendPreeditText(preeditText, preeditText.length() - i);
- QCOMPARE(input->positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- }
- for (int i = 1; i < 3; ++i) {
- sendPreeditText(preeditText, preeditText.length() - i);
- QCOMPARE(input->positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- }
-
- // Test disabling auto scroll.
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
-
- input->setAutoScroll(false);
- sendPreeditText(preeditText.mid(0, 3), 1);
- QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
- QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
-}
-
-void tst_qquicktextinput::preeditCursorRectangle()
-{
- QString preeditText = "super";
-
- QQuickView view(testFileUrl("inputMethodEvent.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
-
- QRect currentRect;
-
- QInputMethodQueryEvent query(Qt::ImCursorRectangle);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
-
- // Verify that the micro focus rect is positioned the same for position 0 as
- // it would be if there was no preedit text.
- sendPreeditText(preeditText, 0);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QCOMPARE(currentRect, previousRect);
-
- QSignalSpy inputSpy(input, SIGNAL(cursorRectangleChanged()));
- QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
-
- // Verify that the micro focus rect moves to the left as the cursor position
- // is incremented.
- for (int i = 1; i <= 5; ++i) {
- sendPreeditText(preeditText, i);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QVERIFY(previousRect.left() < currentRect.left());
- QVERIFY(inputSpy.count() > 0); inputSpy.clear();
- QVERIFY(panelSpy.count() > 0); panelSpy.clear();
- previousRect = currentRect;
- }
-
- // Verify that if there is no preedit cursor then the micro focus rect is the
- // same as it would be if it were positioned at the end of the preedit text.
- sendPreeditText(preeditText, 0);
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QCOMPARE(currentRect, previousRect);
- QVERIFY(inputSpy.count() > 0);
- QVERIFY(panelSpy.count() > 0);
-}
-
-void tst_qquicktextinput::inputContextMouseHandler()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QString text = "supercalifragisiticexpialidocious!";
- QQuickView view(testFileUrl("inputContext.qml"));
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
-
- input->setFocus(true);
- input->setText("");
-
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QTextLayout layout(text);
- layout.setFont(input->font());
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- const qreal x = line.cursorToX(2, QTextLine::Leading);
- const qreal y = line.height() / 2;
- QPoint position = QPointF(x, y).toPoint();
-
- QInputMethodEvent inputEvent(text.mid(0, 5), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(input, &inputEvent);
-
- QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, position);
- QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, position);
- QGuiApplication::processEvents();
-
- QCOMPARE(platformInputContext.m_action, QInputMethod::Click);
- QCOMPARE(platformInputContext.m_invokeActionCallCount, 1);
- QCOMPARE(platformInputContext.m_cursorPosition, 2);
-}
-
-void tst_qquicktextinput::inputMethodComposing()
-{
- QString text = "supercalifragisiticexpialidocious!";
-
- QQuickView view(testFileUrl("inputContext.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
- QSignalSpy spy(input, SIGNAL(inputMethodComposingChanged()));
-
- QCOMPARE(input->isInputMethodComposing(), false);
- {
- QInputMethodEvent event(text.mid(3), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(input, &event);
- }
- QCOMPARE(input->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(input, &event);
- }
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent event;
- QGuiApplication::sendEvent(input, &event);
- }
- QCOMPARE(input->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextinput::inputMethodUpdate()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView view(testFileUrl("inputContext.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
-
- // text change even without cursor position change needs to trigger update
- input->setText("test");
- platformInputContext.clear();
- input->setText("xxxx");
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // input method event replacing text
- platformInputContext.clear();
- {
- QInputMethodEvent inputMethodEvent;
- inputMethodEvent.setCommitString("y", -1, 1);
- QGuiApplication::sendEvent(input, &inputMethodEvent);
- }
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // input method changing selection
- platformInputContext.clear();
- {
- QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
- QInputMethodEvent inputMethodEvent("", attributes);
- QGuiApplication::sendEvent(input, &inputMethodEvent);
- }
- QVERIFY(input->selectionStart() != input->selectionEnd());
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // programmatical selections trigger update
- platformInputContext.clear();
- input->selectAll();
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // font changes
- platformInputContext.clear();
- QFont font = input->font();
- font.setBold(!font.bold());
- input->setFont(font);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // normal input
- platformInputContext.clear();
- {
- QInputMethodEvent inputMethodEvent;
- inputMethodEvent.setCommitString("y");
- QGuiApplication::sendEvent(input, &inputMethodEvent);
- }
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // changing cursor position
- platformInputContext.clear();
- input->setCursorPosition(0);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // read only disabled input method
- platformInputContext.clear();
- input->setReadOnly(true);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
- input->setReadOnly(false);
-
- // no updates while no focus
- input->setFocus(false);
- platformInputContext.clear();
- input->setText("Foo");
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- input->setCursorPosition(1);
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- input->selectAll();
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- input->setReadOnly(true);
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
-}
-
-void tst_qquicktextinput::cursorRectangleSize()
-{
- QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
- QVERIFY(canvas->rootObject() != 0);
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput *>(canvas->rootObject());
-
- // make sure cursor rectangle is not at (0,0)
- textInput->setX(10);
- textInput->setY(10);
- textInput->setCursorPosition(3);
- QVERIFY(textInput != 0);
- textInput->setFocus(true);
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(qApp->focusObject());
-
- QInputMethodQueryEvent event(Qt::ImCursorRectangle);
- qApp->sendEvent(qApp->focusObject(), &event);
- QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
-
- QRectF cursorRectFromItem = textInput->cursorRectangle();
- QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition());
-
- // item and input query cursor rectangles match
- QCOMPARE(cursorRectFromItem, cursorRectFromQuery);
-
- // item cursor rectangle and positionToRectangle calculations match
- QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle);
-
- // item-canvas transform and input item transform match
- QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
-
- // input panel cursorRectangle property and tranformed item cursor rectangle match
- QRectF sceneCursorRect = QQuickItemPrivate::get(textInput)->itemToCanvasTransform().mapRect(cursorRectFromItem);
- QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
-
- delete canvas;
-}
-
-void tst_qquicktextinput::tripleClickSelectsAll()
-{
- QString qmlfile = testFile("positionAt.qml");
- QQuickView view(QUrl::fromLocalFile(qmlfile));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
-
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextInput* input = qobject_cast<QQuickTextInput*>(view.rootObject());
- QVERIFY(input);
-
- QLatin1String hello("Hello world!");
- input->setSelectByMouse(true);
- input->setText(hello);
-
- // Clicking on the same point inside TextInput three times in a row
- // should trigger a triple click, thus selecting all the text.
- QPoint pointInside = input->pos().toPoint() + QPoint(2,2);
- QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
- QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
- QGuiApplication::processEvents();
- QCOMPARE(input->selectedText(), hello);
-
- // Now it simulates user moving the mouse between the second and the third click.
- // In this situation, we don't expect a triple click.
- QPoint pointInsideButFar = QPoint(input->width(),input->height()) - QPoint(2,2);
- QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
- QTest::mouseClick(&view, Qt::LeftButton, 0, pointInsideButFar);
- QGuiApplication::processEvents();
- QVERIFY(input->selectedText().isEmpty());
-
- // And now we press the third click too late, so no triple click event is triggered.
- QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
- QGuiApplication::processEvents();
- QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 1);
- QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
- QGuiApplication::processEvents();
- QVERIFY(input->selectedText().isEmpty());
-}
-
-void tst_qquicktextinput::QTBUG_19956_data()
-{
- QTest::addColumn<QString>("url");
- QTest::newRow("intvalidator") << "qtbug-19956int.qml";
- QTest::newRow("doublevalidator") << "qtbug-19956double.qml";
-}
-
-
-void tst_qquicktextinput::getText_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("inputMask");
- QTest::addColumn<int>("start");
- QTest::addColumn<int>("end");
- QTest::addColumn<QString>("expectedText");
-
- QTest::newRow("all plain text")
- << standard.at(0)
- << QString()
- << 0 << standard.at(0).length()
- << standard.at(0);
-
- QTest::newRow("plain text sub string")
- << standard.at(0)
- << QString()
- << 0 << 12
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text sub string reversed")
- << standard.at(0)
- << QString()
- << 12 << 0
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text cropped beginning")
- << standard.at(0)
- << QString()
- << -3 << 4
- << standard.at(0).mid(0, 4);
-
- QTest::newRow("plain text cropped end")
- << standard.at(0)
- << QString()
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(23);
-
- QTest::newRow("plain text cropped beginning and end")
- << standard.at(0)
- << QString()
- << -9 << standard.at(0).length() + 4
- << standard.at(0);
-}
-
-void tst_qquicktextinput::getText()
-{
- QFETCH(QString, text);
- QFETCH(QString, inputMask);
- QFETCH(int, start);
- QFETCH(int, end);
- QFETCH(QString, expectedText);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QCOMPARE(textInput->getText(start, end), expectedText);
-}
-
-void tst_qquicktextinput::insert_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("inputMask");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("insertPosition");
- QTest::addColumn<QString>("insertText");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<int>("expectedSelectionStart");
- QTest::addColumn<int>("expectedSelectionEnd");
- QTest::addColumn<int>("expectedCursorPosition");
- QTest::addColumn<bool>("selectionChanged");
- QTest::addColumn<bool>("cursorPositionChanged");
-
- QTest::newRow("at cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 5 << 5 << 5
- << false << true;
-
- QTest::newRow("at cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
- << false << true;
-
- QTest::newRow("at cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 23 << 23 << 23
- << false << true;
-
- QTest::newRow("after cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("before cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length() << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
- << false << true;
-
- QTest::newRow("before cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 23 << 23 << 23
- << false << true;
-
- QTest::newRow("after cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("before selection")
- << standard.at(0)
- << QString()
- << 14 << 19 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 19 << 24 << 24
- << false << true;
-
- QTest::newRow("before reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 19 << 24 << 19
- << false << true;
-
- QTest::newRow("after selection")
- << standard.at(0)
- << QString()
- << 14 << 19 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 14 << 19 << 19
- << false << false;
-
- QTest::newRow("after reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 14 << 19 << 14
- << false << false;
-
- QTest::newRow("into selection")
- << standard.at(0)
- << QString()
- << 14 << 19 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 14 << 24 << 24
- << true << true;
-
- QTest::newRow("into reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 14 << 24 << 14
- << true << false;
-
- QTest::newRow("rich text into plain text")
- << standard.at(0)
- << QString()
- << 0 << 0 << 0
- << QString("<b>Hello</b>")
- << QString("<b>Hello</b>") + standard.at(0)
- << 12 << 12 << 12
- << false << true;
-
- QTest::newRow("before start")
- << standard.at(0)
- << QString()
- << 0 << 0 << -3
- << QString("Hello")
- << standard.at(0)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("past end")
- << standard.at(0)
- << QString()
- << 0 << 0 << standard.at(0).length() + 3
- << QString("Hello")
- << standard.at(0)
- << 0 << 0 << 0
- << false << false;
-
- const QString inputMask = "009.009.009.009";
- const QString ip = "192.168.2.14";
-
- QTest::newRow("mask: at cursor position (beginning)")
- << ip
- << inputMask
- << 0 << 0 << 0
- << QString("125")
- << QString("125.168.2.14")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: at cursor position (end)")
- << ip
- << inputMask
- << inputMask.length() << inputMask.length() << inputMask.length()
- << QString("8")
- << ip
- << inputMask.length() << inputMask.length() << inputMask.length()
- << false << false;
-
- QTest::newRow("mask: at cursor position (middle)")
- << ip
- << inputMask
- << 6 << 6 << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: after cursor position (beginning)")
- << ip
- << inputMask
- << 0 << 0 << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: before cursor position (end)")
- << ip
- << inputMask
- << inputMask.length() << inputMask.length() << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << inputMask.length() << inputMask.length() << inputMask.length()
- << false << false;
-
- QTest::newRow("mask: before cursor position (middle)")
- << ip
- << inputMask
- << 6 << 6 << 0
- << QString("125")
- << QString("125.168.2.14")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: after cursor position (middle)")
- << ip
- << inputMask
- << 6 << 6 << 13
- << QString("8")
- << "192.168.2.18"
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: before selection")
- << ip
- << inputMask
- << 6 << 8 << 0
- << QString("125")
- << QString("125.168.2.14")
- << 6 << 8 << 8
- << false << false;
-
- QTest::newRow("mask: before reversed selection")
- << ip
- << inputMask
- << 8 << 6 << 0
- << QString("125")
- << QString("125.168.2.14")
- << 6 << 8 << 6
- << false << false;
-
- QTest::newRow("mask: after selection")
- << ip
- << inputMask
- << 6 << 8 << 13
- << QString("8")
- << "192.168.2.18"
- << 6 << 8 << 8
- << false << false;
-
- QTest::newRow("mask: after reversed selection")
- << ip
- << inputMask
- << 8 << 6 << 13
- << QString("8")
- << "192.168.2.18"
- << 6 << 8 << 6
- << false << false;
-
- QTest::newRow("mask: into selection")
- << ip
- << inputMask
- << 5 << 8 << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << 5 << 8 << 8
- << true << false;
-
- QTest::newRow("mask: into reversed selection")
- << ip
- << inputMask
- << 8 << 5 << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << 5 << 8 << 5
- << true << false;
-
- QTest::newRow("mask: before start")
- << ip
- << inputMask
- << 0 << 0 << -3
- << QString("4")
- << ip
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: past end")
- << ip
- << inputMask
- << 0 << 0 << ip.length() + 3
- << QString("4")
- << ip
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: invalid characters")
- << ip
- << inputMask
- << 0 << 0 << 0
- << QString("abc")
- << QString("192.168.2.14")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: mixed validity")
- << ip
- << inputMask
- << 0 << 0 << 0
- << QString("a1b2c5")
- << QString("125.168.2.14")
- << 0 << 0 << 0
- << false << false;
-}
-
-void tst_qquicktextinput::insert()
-{
- QFETCH(QString, text);
- QFETCH(QString, inputMask);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, insertPosition);
- QFETCH(QString, insertText);
- QFETCH(QString, expectedText);
- QFETCH(int, expectedSelectionStart);
- QFETCH(int, expectedSelectionEnd);
- QFETCH(int, expectedCursorPosition);
- QFETCH(bool, selectionChanged);
- QFETCH(bool, cursorPositionChanged);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- textInput->select(selectionStart, selectionEnd);
-
- QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged()));
- QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged()));
- QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged()));
- QSignalSpy textSpy(textInput, SIGNAL(textChanged()));
- QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged()));
-
- textInput->insert(insertPosition, insertText);
-
- QCOMPARE(textInput->text(), expectedText);
- QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
-
- QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
- QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
- QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
-
- if (selectionStart > selectionEnd)
- qSwap(selectionStart, selectionEnd);
-
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
- QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
-}
-
-void tst_qquicktextinput::remove_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("inputMask");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("removeStart");
- QTest::addColumn<int>("removeEnd");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<int>("expectedSelectionStart");
- QTest::addColumn<int>("expectedSelectionEnd");
- QTest::addColumn<int>("expectedCursorPosition");
- QTest::addColumn<bool>("selectionChanged");
- QTest::addColumn<bool>("cursorPositionChanged");
-
- QTest::newRow("from cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0
- << 0 << 5
- << standard.at(0).mid(5)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("to cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0
- << 5 << 0
- << standard.at(0).mid(5)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("to cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() << standard.at(0).length() - 5
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("to cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("from cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("to cursor position (middle)")
- << standard.at(0)
- << QString()
- << 23 << 23
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << true;
-
- QTest::newRow("after cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("before cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length()
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("before cursor position (middle)")
- << standard.at(0)
- << QString()
- << 23 << 23
- << 0 << 5
- << standard.at(0).mid(5)
- << 18 << 18 << 18
- << false << true;
-
- QTest::newRow("after cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("before selection")
- << standard.at(0)
- << QString()
- << 14 << 19
- << 0 << 5
- << standard.at(0).mid(5)
- << 9 << 14 << 14
- << false << true;
-
- QTest::newRow("before reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14
- << 0 << 5
- << standard.at(0).mid(5)
- << 9 << 14 << 9
- << false << true;
-
- QTest::newRow("after selection")
- << standard.at(0)
- << QString()
- << 14 << 19
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << 14 << 19 << 19
- << false << false;
-
- QTest::newRow("after reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << 14 << 19 << 14
- << false << false;
-
- QTest::newRow("from selection")
- << standard.at(0)
- << QString()
- << 14 << 24
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 14 << 19 << 19
- << true << true;
-
- QTest::newRow("from reversed selection")
- << standard.at(0)
- << QString()
- << 24 << 14
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 14 << 19 << 14
- << true << false;
-
- QTest::newRow("cropped beginning")
- << standard.at(0)
- << QString()
- << 0 << 0
- << -3 << 4
- << standard.at(0).mid(4)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("cropped end")
- << standard.at(0)
- << QString()
- << 0 << 0
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(0, 23)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("cropped beginning and end")
- << standard.at(0)
- << QString()
- << 0 << 0
- << -9 << standard.at(0).length() + 4
- << QString()
- << 0 << 0 << 0
- << false << false;
-
- const QString inputMask = "009.009.009.009";
- const QString ip = "192.168.2.14";
-
- QTest::newRow("mask: from cursor position")
- << ip
- << inputMask
- << 6 << 6
- << 6 << 9
- << QString("192.16..14")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: to cursor position")
- << ip
- << inputMask
- << 6 << 6
- << 2 << 6
- << QString("19.8.2.14")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: before cursor position")
- << ip
- << inputMask
- << 6 << 6
- << 0 << 2
- << QString("2.168.2.14")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: after cursor position")
- << ip
- << inputMask
- << 6 << 6
- << 12 << 16
- << QString("192.168.2.")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: before selection")
- << ip
- << inputMask
- << 6 << 8
- << 0 << 2
- << QString("2.168.2.14")
- << 6 << 8 << 8
- << false << false;
-
- QTest::newRow("mask: before reversed selection")
- << ip
- << inputMask
- << 8 << 6
- << 0 << 2
- << QString("2.168.2.14")
- << 6 << 8 << 6
- << false << false;
-
- QTest::newRow("mask: after selection")
- << ip
- << inputMask
- << 6 << 8
- << 12 << 16
- << QString("192.168.2.")
- << 6 << 8 << 8
- << false << false;
-
- QTest::newRow("mask: after reversed selection")
- << ip
- << inputMask
- << 8 << 6
- << 12 << 16
- << QString("192.168.2.")
- << 6 << 8 << 6
- << false << false;
-
- QTest::newRow("mask: from selection")
- << ip
- << inputMask
- << 6 << 13
- << 8 << 10
- << QString("192.168..14")
- << 6 << 13 << 13
- << true << false;
-
- QTest::newRow("mask: from reversed selection")
- << ip
- << inputMask
- << 13 << 6
- << 8 << 10
- << QString("192.168..14")
- << 6 << 13 << 6
- << true << false;
-
- QTest::newRow("mask: cropped beginning")
- << ip
- << inputMask
- << 0 << 0
- << -3 << 4
- << QString(".168.2.14")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: cropped end")
- << ip
- << inputMask
- << 0 << 0
- << 13 << 28
- << QString("192.168.2.1")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: cropped beginning and end")
- << ip
- << inputMask
- << 0 << 0
- << -9 << 28
- << QString("...")
- << 0 << 0 << 0
- << false << false;
-}
-
-void tst_qquicktextinput::remove()
-{
- QFETCH(QString, text);
- QFETCH(QString, inputMask);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, removeStart);
- QFETCH(int, removeEnd);
- QFETCH(QString, expectedText);
- QFETCH(int, expectedSelectionStart);
- QFETCH(int, expectedSelectionEnd);
- QFETCH(int, expectedCursorPosition);
- QFETCH(bool, selectionChanged);
- QFETCH(bool, cursorPositionChanged);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- textInput->select(selectionStart, selectionEnd);
-
- QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged()));
- QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged()));
- QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged()));
- QSignalSpy textSpy(textInput, SIGNAL(textChanged()));
- QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged()));
-
- textInput->remove(removeStart, removeEnd);
-
- QCOMPARE(textInput->text(), expectedText);
- QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
-
- if (selectionStart > selectionEnd) //
- qSwap(selectionStart, selectionEnd);
-
- QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
- QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
- QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
-
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
-
- if (cursorPositionChanged) //
- QVERIFY(cursorPositionSpy.count() > 0);
-}
-
-void tst_qquicktextinput::keySequence_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QKeySequence>("sequence");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<QString>("selectedText");
-
- // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
-
- QTest::newRow("select all")
- << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
- << 44 << standard.at(0) << standard.at(0);
- QTest::newRow("select end of line")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
- << 44 << standard.at(0) << standard.at(0).mid(5);
- QTest::newRow("select end of document") // ### Not handled.
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
- << 3 << standard.at(0) << QString();
- QTest::newRow("select end of block")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
- << 44 << standard.at(0) << standard.at(0).mid(18);
- QTest::newRow("delete end of line")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
- << 24 << standard.at(0).mid(0, 24) << QString();
- QTest::newRow("move to start of line")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
- << 0 << standard.at(0) << QString();
- QTest::newRow("move to start of block")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
- << 0 << standard.at(0) << QString();
- QTest::newRow("move to next char")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
- << 13 << standard.at(0) << QString();
- QTest::newRow("move to previous char")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
- << 2 << standard.at(0) << QString();
- QTest::newRow("select next char")
- << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
- << 24 << standard.at(0) << standard.at(0).mid(23, 1);
- QTest::newRow("select previous char")
- << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
- << 18 << standard.at(0) << standard.at(0).mid(18, 1);
- QTest::newRow("move to next word")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
- << 10 << standard.at(0) << QString();
- QTest::newRow("move to previous word")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
- << 4 << standard.at(0) << QString();
- QTest::newRow("select previous word")
- << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
- << 10 << standard.at(0) << standard.at(0).mid(10, 1);
- QTest::newRow("delete (selection)")
- << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
- << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
- QTest::newRow("delete (no selection)")
- << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
- << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
- QTest::newRow("delete end of word")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
- << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
- QTest::newRow("delete start of word")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
- << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
-}
-
-void tst_qquicktextinput::keySequence()
-{
- QFETCH(QString, text);
- QFETCH(QKeySequence, sequence);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, cursorPosition);
- QFETCH(QString, expectedText);
- QFETCH(QString, selectedText);
-
- if (sequence.isEmpty()) {
- QSKIP("Key sequence is undefined");
- }
-
- QString componentStr = "import QtQuick 2.0\nTextInput { focus: true; text: \"" + text + "\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- textInput->select(selectionStart, selectionEnd);
-
- simulateKeys(&canvas, sequence);
-
- QCOMPARE(textInput->cursorPosition(), cursorPosition);
- QCOMPARE(textInput->text(), expectedText);
- QCOMPARE(textInput->selectedText(), selectedText);
-}
-
-#define NORMAL 0
-#define REPLACE_UNTIL_END 1
-
-void tst_qquicktextinput::undo_data()
-{
- QTest::addColumn<QStringList>("insertString");
- QTest::addColumn<IntList>("insertIndex");
- QTest::addColumn<IntList>("insertMode");
- QTest::addColumn<QStringList>("expectedString");
- QTest::addColumn<bool>("use_keys");
-
- for (int i=0; i<2; i++) {
- QString keys_str = "keyboard";
- bool use_keys = true;
- if (i==0) {
- keys_str = "insert";
- use_keys = false;
- }
-
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "1";
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "5";
-
- insertIndex << 1;
- insertMode << NORMAL;
- insertString << "3";
-
- insertIndex << 1;
- insertMode << NORMAL;
- insertString << "2";
-
- insertIndex << 3;
- insertMode << NORMAL;
- insertString << "4";
-
- expectedString << "12345";
- expectedString << "1235";
- expectedString << "135";
- expectedString << "15";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "World"; // World
-
- insertIndex << 0;
- insertMode << NORMAL;
- insertString << "Hello"; // HelloWorld
-
- insertIndex << 0;
- insertMode << NORMAL;
- insertString << "Well"; // WellHelloWorld
-
- insertIndex << 9;
- insertMode << NORMAL;
- insertString << "There"; // WellHelloThereWorld;
-
- expectedString << "WellHelloThereWorld";
- expectedString << "WellHelloWorld";
- expectedString << "HelloWorld";
- expectedString << "World";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "Ensuring";
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << " instan";
-
- insertIndex << 9;
- insertMode << NORMAL;
- insertString << "an ";
-
- insertIndex << 10;
- insertMode << REPLACE_UNTIL_END;
- insertString << " unique instance.";
-
- expectedString << "Ensuring a unique instance.";
- expectedString << "Ensuring an instan";
- expectedString << "Ensuring instan";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- }
-}
-
-void tst_qquicktextinput::undo()
-{
- QFETCH(QStringList, insertString);
- QFETCH(IntList, insertIndex);
- QFETCH(IntList, insertMode);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- QVERIFY(!textInput->canUndo());
-
- QSignalSpy spy(textInput, SIGNAL(canUndoChanged()));
-
- int i;
-
-// STEP 1: First build up an undo history by inserting or typing some strings...
- for (i = 0; i < insertString.size(); ++i) {
- if (insertIndex[i] > -1)
- textInput->setCursorPosition(insertIndex[i]);
-
- // experimental stuff
- if (insertMode[i] == REPLACE_UNTIL_END) {
- textInput->select(insertIndex[i], insertIndex[i] + 8);
-
- // This is what I actually want...
- // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
- }
-
- for (int j = 0; j < insertString.at(i).length(); j++)
- QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
- }
-
- QCOMPARE(spy.count(), 1);
-
-// STEP 2: Next call undo several times and see if we can restore to the previous state
- for (i = 0; i < expectedString.size() - 1; ++i) {
- QCOMPARE(textInput->text(), expectedString[i]);
- QVERIFY(textInput->canUndo());
- textInput->undo();
- }
-
-// STEP 3: Verify that we have undone everything
- QVERIFY(textInput->text().isEmpty());
- QVERIFY(!textInput->canUndo());
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextinput::redo_data()
-{
- QTest::addColumn<QStringList>("insertString");
- QTest::addColumn<IntList>("insertIndex");
- QTest::addColumn<QStringList>("expectedString");
-
- {
- IntList insertIndex;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertString << "World"; // World
- insertIndex << 0;
- insertString << "Hello"; // HelloWorld
- insertIndex << 0;
- insertString << "Well"; // WellHelloWorld
- insertIndex << 9;
- insertString << "There"; // WellHelloThereWorld;
-
- expectedString << "World";
- expectedString << "HelloWorld";
- expectedString << "WellHelloWorld";
- expectedString << "WellHelloThereWorld";
-
- QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
- }
-}
-
-void tst_qquicktextinput::redo()
-{
- QFETCH(QStringList, insertString);
- QFETCH(IntList, insertIndex);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- QVERIFY(!textInput->canUndo());
- QVERIFY(!textInput->canRedo());
-
- QSignalSpy spy(textInput, SIGNAL(canRedoChanged()));
-
- int i;
- // inserts the diff strings at diff positions
- for (i = 0; i < insertString.size(); ++i) {
- if (insertIndex[i] > -1)
- textInput->setCursorPosition(insertIndex[i]);
- for (int j = 0; j < insertString.at(i).length(); j++)
- QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
- QVERIFY(textInput->canUndo());
- QVERIFY(!textInput->canRedo());
- }
-
- QCOMPARE(spy.count(), 0);
-
- // undo everything
- while (!textInput->text().isEmpty()) {
- QVERIFY(textInput->canUndo());
- textInput->undo();
- QVERIFY(textInput->canRedo());
- }
-
- QCOMPARE(spy.count(), 1);
-
- for (i = 0; i < expectedString.size(); ++i) {
- QVERIFY(textInput->canRedo());
- textInput->redo();
- QCOMPARE(textInput->text() , expectedString[i]);
- QVERIFY(textInput->canUndo());
- }
- QVERIFY(!textInput->canRedo());
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextinput::undo_keypressevents_data()
-{
- QTest::addColumn<KeyList>("keys");
- QTest::addColumn<QStringList>("expectedString");
-
- {
- KeyList keys;
- QStringList expectedString;
-
- keys << "AFRAID"
- << QKeySequence::MoveToStartOfLine
- << "VERY"
- << Qt::Key_Left
- << Qt::Key_Left
- << Qt::Key_Left
- << Qt::Key_Left
- << "BE"
- << QKeySequence::MoveToEndOfLine
- << "!";
-
- expectedString << "BEVERYAFRAID!";
- expectedString << "BEVERYAFRAID";
- expectedString << "VERYAFRAID";
- expectedString << "AFRAID";
-
- QTest::newRow("Inserts and moving cursor") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting '1234'
- keys << "1234" << QKeySequence::MoveToStartOfLine
- // skipping '12'
- << Qt::Key_Right << Qt::Key_Right
- // selecting '34'
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- // deleting '34'
- << Qt::Key_Delete;
-
- expectedString << "12";
- expectedString << "1234";
-
- QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'AB12'
- keys << "AB12"
- << QKeySequence::MoveToStartOfLine
- // selecting 'AB'
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- << Qt::Key_Delete
- << QKeySequence::Undo
- << Qt::Key_Right
-#ifdef Q_OS_WIN //Mac(?) has a specialcase to handle jumping to the end of a selection
- << Qt::Key_Left
-#endif
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- << Qt::Key_Delete;
-
- expectedString << "AB";
- expectedString << "AB12";
-
- QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'ABCD'
- keys << "abcd"
- //move left two
- << Qt::Key_Left << Qt::Key_Left
- // inserting '1234'
- << "1234"
- // selecting '1234'
- << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
- // overwriting '1234' with '5'
- << "5"
- // undoing deletion of 'AB'
- << QKeySequence::Undo
- // overwriting '1234' with '6'
- << "6";
-
- expectedString << "ab6cd";
- // for versions previous to 3.2 we overwrite needed two undo operations
- expectedString << "ab1234cd";
- expectedString << "abcd";
-
- QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'ABC'
- keys << "ABC"
- // removes 'C'
- << Qt::Key_Backspace;
-
- expectedString << "AB";
- expectedString << "ABC";
-
- QTest::newRow("Inserts,backspace") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- keys << "ABC"
- // removes 'C'
- << Qt::Key_Backspace
- // inserting 'Z'
- << "Z";
-
- expectedString << "ABZ";
- expectedString << "AB";
- expectedString << "ABC";
-
- QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting '123'
- keys << "123" << QKeySequence::MoveToStartOfLine
- // selecting '123'
- << QKeySequence::SelectEndOfLine
- // overwriting '123' with 'ABC'
- << "ABC";
-
- expectedString << "ABC";
- // for versions previous to 3.2 we overwrite needed two undo operations
- expectedString << "123";
-
- QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
- }
-}
-
-void tst_qquicktextinput::undo_keypressevents()
-{
- QFETCH(KeyList, keys);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- simulateKeys(&canvas, keys);
-
- for (int i = 0; i < expectedString.size(); ++i) {
- QCOMPARE(textInput->text() , expectedString[i]);
- textInput->undo();
- }
- QVERIFY(textInput->text().isEmpty());
-}
-
-void tst_qquicktextinput::QTBUG_19956()
-{
- QFETCH(QString, url);
-
- QQuickView canvas(testFileUrl(url));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *input = qobject_cast<QQuickTextInput*>(canvas.rootObject());
- QVERIFY(input);
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus());
-
- QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 30);
- QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10);
- QCOMPARE(canvas.rootObject()->property("text").toString(), QString("20"));
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("topvalue", 15);
- QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 15);
- QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("topvalue", 25);
- QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 25);
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("bottomvalue", 21);
- QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 21);
- QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("bottomvalue", 10);
- QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10);
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-}
-
-void tst_qquicktextinput::QTBUG_19956_regexp()
-{
- QUrl url = testFileUrl("qtbug-19956regexp.qml");
-
- QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QQuickView canvas(url);
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *input = qobject_cast<QQuickTextInput*>(canvas.rootObject());
- QVERIFY(input);
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus());
-
- canvas.rootObject()->setProperty("regexvalue", QRegExp("abc"));
- QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc"));
- QCOMPARE(canvas.rootObject()->property("text").toString(), QString("abc"));
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("regexvalue", QRegExp("abcd"));
- QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abcd"));
- QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("regexvalue", QRegExp("abc"));
- QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc"));
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-}
-
-
-void tst_qquicktextinput::negativeDimensions()
-{
- // Verify this doesn't assert during initialization.
- QDeclarativeComponent component(&engine, testFileUrl("negativeDimensions.qml"));
- QScopedPointer<QObject> o(component.create());
- QVERIFY(o);
- QQuickTextInput *input = o->findChild<QQuickTextInput *>("input");
- QVERIFY(input);
- QCOMPARE(input->width(), qreal(-1));
- QCOMPARE(input->height(), qreal(-1));
-}
-
-QTEST_MAIN(tst_qquicktextinput)
-
-#include "tst_qquicktextinput.moc"
diff --git a/tests/auto/qtquick2/qquickview/qquickview.pro b/tests/auto/qtquick2/qquickview/qquickview.pro
deleted file mode 100644
index c3bc0ddcaf..0000000000
--- a/tests/auto/qtquick2/qquickview/qquickview.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickview.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickview/tst_qquickview.cpp b/tests/auto/qtquick2/qquickview/tst_qquickview.cpp
deleted file mode 100644
index fe290456eb..0000000000
--- a/tests/auto/qtquick2/qquickview/tst_qquickview.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/qquickitem.h>
-#include "../../shared/util.h"
-#include <QtGui/QWindow>
-#include <QtCore/QDebug>
-
-class tst_QQuickView : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickView();
-
-private slots:
- void resizemodeitem();
- void errors();
-};
-
-
-tst_QQuickView::tst_QQuickView()
-{
-}
-
-void tst_QQuickView::resizemodeitem()
-{
- QWindow window;
- window.setGeometry(0, 0, 400, 400);
-
- QQuickView *canvas = new QQuickView(&window);
- QVERIFY(canvas);
- canvas->setResizeMode(QQuickView::SizeRootObjectToView);
- QCOMPARE(QSize(0,0), canvas->initialSize());
- canvas->setSource(testFileUrl("resizemodeitem.qml"));
- QQuickItem* item = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(item);
- window.show();
-
- canvas->show();
-
- // initial size from root object
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 200.0);
- QCOMPARE(canvas->size(), QSize(200, 200));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->size(), canvas->initialSize());
-
- // size update from view
- canvas->resize(QSize(80,100));
-
- QTRY_COMPARE(item->width(), 80.0);
- QCOMPARE(item->height(), 100.0);
- QCOMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
-
- canvas->setResizeMode(QQuickView::SizeViewToRootObject);
-
- // size update from view disabled
- canvas->resize(QSize(60,80));
- QCOMPARE(item->width(), 80.0);
- QCOMPARE(item->height(), 100.0);
- QTest::qWait(50);
- QCOMPARE(canvas->size(), QSize(60, 80));
-
- // size update from root object
- item->setWidth(250);
- item->setHeight(350);
- QCOMPARE(item->width(), 250.0);
- QCOMPARE(item->height(), 350.0);
- QTRY_COMPARE(canvas->size(), QSize(250, 350));
- QCOMPARE(canvas->size(), QSize(250, 350));
- QCOMPARE(canvas->size(), canvas->sizeHint());
-
- // reset canvas
- window.hide();
- delete canvas;
- canvas = new QQuickView(&window);
- QVERIFY(canvas);
- canvas->setResizeMode(QQuickView::SizeViewToRootObject);
- canvas->setSource(testFileUrl("resizemodeitem.qml"));
- item = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(item);
- window.show();
-
- canvas->show();
-
- // initial size for root object
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 200.0);
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->size(), canvas->initialSize());
-
- // size update from root object
- item->setWidth(80);
- item->setHeight(100);
- QCOMPARE(item->width(), 80.0);
- QCOMPARE(item->height(), 100.0);
- QTRY_COMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
-
- // size update from root object disabled
- canvas->setResizeMode(QQuickView::SizeRootObjectToView);
- item->setWidth(60);
- item->setHeight(80);
- QCOMPARE(canvas->width(), 80);
- QCOMPARE(canvas->height(), 100);
- QCOMPARE(QSize(item->width(), item->height()), canvas->sizeHint());
-
- // size update from view
- canvas->resize(QSize(200,300));
- QTest::qWait(50);
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 300.0);
- QCOMPARE(canvas->size(), QSize(200, 300));
- QCOMPARE(canvas->size(), canvas->sizeHint());
-
- window.hide();
- delete canvas;
-
- // if we set a specific size for the view then it should keep that size
- // for SizeRootObjectToView mode.
- canvas = new QQuickView(&window);
- canvas->resize(300, 300);
- canvas->setResizeMode(QQuickView::SizeRootObjectToView);
- QCOMPARE(QSize(0,0), canvas->initialSize());
- canvas->setSource(testFileUrl("resizemodeitem.qml"));
- canvas->resize(300, 300);
- item = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(item);
- window.show();
-
- canvas->show();
- QTest::qWait(50);
-
- // initial size from root object
- QCOMPARE(item->width(), 300.0);
- QCOMPARE(item->height(), 300.0);
- QCOMPARE(canvas->size(), QSize(300, 300));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->initialSize(), QSize(200, 200)); // initial object size
-
- delete canvas;
-}
-
-static void silentErrorsMsgHandler(QtMsgType, const char *)
-{
-}
-
-void tst_QQuickView::errors()
-{
- QQuickView *canvas = new QQuickView;
- QVERIFY(canvas);
- QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
- canvas->setSource(testFileUrl("error1.qml"));
- qInstallMsgHandler(old);
- QVERIFY(canvas->status() == QQuickView::Error);
- QVERIFY(canvas->errors().count() == 1);
- delete canvas;
-}
-
-
-QTEST_MAIN(tst_QQuickView)
-
-#include "tst_qquickview.moc"
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro
deleted file mode 100644
index 6db887d747..0000000000
--- a/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickvisualdatamodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickvisualdatamodel.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
deleted file mode 100644
index 1b6a7629d9..0000000000
--- a/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ /dev/null
@@ -1,3446 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QStandardItemModel>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquicklistview_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualdatamodel_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <private/qdeclarativechangeset_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <math.h>
-
-using namespace QQuickVisualTestUtil;
-
-template <typename T, int N> int lengthOf(const T (&)[N]) { return N; }
-
-static void initStandardTreeModel(QStandardItemModel *model)
-{
- QStandardItem *item;
- item = new QStandardItem(QLatin1String("Row 1 Item"));
- model->insertRow(0, item);
-
- item = new QStandardItem(QLatin1String("Row 2 Item"));
- item->setCheckable(true);
- model->insertRow(1, item);
-
- QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
- item->setChild(0, childItem);
-
- item = new QStandardItem(QLatin1String("Row 3 Item"));
- item->setIcon(QIcon());
- model->insertRow(2, item);
-}
-
-class SingleRoleModel : public QAbstractListModel
-{
- Q_OBJECT
- Q_PROPERTY(QStringList values WRITE setList)
-public:
- SingleRoleModel(const QByteArray &role = "name", QObject *parent = 0)
- : QAbstractListModel(parent)
- {
- QHash<int, QByteArray> roles;
- roles.insert(Qt::DisplayRole , role);
- setRoleNames(roles);
- list << "one" << "two" << "three" << "four";
- }
-
- void emitMove(int sourceFirst, int sourceLast, int destinationChild) {
- emit beginMoveRows(QModelIndex(), sourceFirst, sourceLast, QModelIndex(), destinationChild);
- emit endMoveRows();
- }
-
- QStringList list;
-
- void setList(const QStringList &l) { list = l; }
-
-public slots:
- void set(int idx, QString string) {
- list[idx] = string;
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-protected:
- int rowCount(const QModelIndex & /* parent */ = QModelIndex()) const {
- return list.count();
- }
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
- if (role == Qt::DisplayRole)
- return list.at(index.row());
- return QVariant();
- }
-};
-
-class StandardItem : public QObject, public QStandardItem
-{
- Q_OBJECT
- Q_PROPERTY(QString text WRITE setText)
-
-public:
- void writeText(const QString &text) { setText(text); }
-};
-
-class StandardItemModel : public QStandardItemModel
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<StandardItem> items READ items CONSTANT)
- Q_CLASSINFO("DefaultProperty", "items")
-public:
- QDeclarativeListProperty<StandardItem> items() { return QDeclarativeListProperty<StandardItem>(this, 0, append); }
-
- static void append(QDeclarativeListProperty<StandardItem> *property, StandardItem *item)
- {
- static_cast<QStandardItemModel *>(property->object)->appendRow(item);
- }
-};
-
-class DataObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
-
-public:
- DataObject(QObject *parent=0) : QObject(parent) {}
- DataObject(const QString &name, const QString &color, QObject *parent=0)
- : QObject(parent), m_name(name), m_color(color) { }
-
-
- QString name() const { return m_name; }
- void setName(const QString &name) {
- if (name != m_name) {
- m_name = name;
- emit nameChanged();
- }
- }
-
- QString color() const { return m_color; }
- void setColor(const QString &color) {
- if (color != m_color) {
- m_color = color;
- emit colorChanged();
- }
- }
-
-signals:
- void nameChanged();
- void colorChanged();
-
-private:
- QString m_name;
- QString m_color;
-};
-
-QML_DECLARE_TYPE(SingleRoleModel)
-QML_DECLARE_TYPE(StandardItem)
-QML_DECLARE_TYPE(StandardItemModel)
-QML_DECLARE_TYPE(DataObject)
-
-class tst_qquickvisualdatamodel : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickvisualdatamodel();
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
- void rootIndex();
- void updateLayout_data();
- void updateLayout();
- void childChanged_data();
- void childChanged();
- void objectListModel();
- void singleRole();
- void modelProperties();
- void noDelegate_data();
- void noDelegate();
- void itemsDestroyed_data();
- void itemsDestroyed();
- void packagesDestroyed();
- void qaimRowsMoved();
- void qaimRowsMoved_data();
- void remove_data();
- void remove();
- void move_data();
- void move();
- void groups_data();
- void groups();
- void invalidGroups();
- void get();
- void onChanged_data();
- void onChanged();
- void create();
- void incompleteModel();
- void insert_data();
- void insert();
- void resolve_data();
- void resolve();
- void warnings_data();
- void warnings();
-
-private:
- template <int N> void groups_verify(
- const SingleRoleModel &model,
- QQuickItem *contentItem,
- const int (&mIndex)[N],
- const int (&iIndex)[N],
- const int (&vIndex)[N],
- const int (&sIndex)[N],
- const bool (&vMember)[N],
- const bool (&sMember)[N]);
-
- template <int N> void get_verify(
- const SingleRoleModel &model,
- QQuickVisualDataModel *visualModel,
- QQuickVisualDataGroup *visibleItems,
- QQuickVisualDataGroup *selectedItems,
- const int (&mIndex)[N],
- const int (&iIndex)[N],
- const int (&vIndex)[N],
- const int (&sIndex)[N],
- const bool (&vMember)[N],
- const bool (&sMember)[N]);
-
- bool failed;
- QDeclarativeEngine engine;
-};
-
-Q_DECLARE_METATYPE(QDeclarativeChangeSet)
-
-template <typename T> static T evaluate(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- T result = expr.evaluate().value<T>();
- if (expr.hasError())
- qWarning() << expr.error().toString();
- return result;
-}
-
-template <> void evaluate<void>(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
-}
-
-void tst_qquickvisualdatamodel::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qRegisterMetaType<QDeclarativeChangeSet>();
-
- qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel");
- qmlRegisterType<StandardItem>("tst_qquickvisualdatamodel", 1, 0, "StandardItem");
- qmlRegisterType<StandardItemModel>("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel");
- qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject");
-}
-
-void tst_qquickvisualdatamodel::cleanupTestCase()
-{
-
-}
-
-tst_qquickvisualdatamodel::tst_qquickvisualdatamodel()
-{
-}
-
-void tst_qquickvisualdatamodel::rootIndex()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml"));
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- engine.rootContext()->setContextProperty("myModel", &model);
-
- QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
- QVERIFY(obj != 0);
-
- QMetaObject::invokeMethod(obj, "setRoot");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
-
- QMetaObject::invokeMethod(obj, "setRootToParent");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
-
- QMetaObject::invokeMethod(obj, "setRoot");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
- model.clear(); // will emit modelReset()
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
-
- delete obj;
-}
-
-void tst_qquickvisualdatamodel::updateLayout_data()
-{
- QTest::addColumn<QUrl>("source");
-
- QTest::newRow("item delegate") << testFileUrl("datalist.qml");
- QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
-}
-
-void tst_qquickvisualdatamodel::updateLayout()
-{
- QFETCH(QUrl, source);
-
- QQuickView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QQuickText>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
-
- model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
-
- name = findItem<QQuickText>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QQuickText>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
-}
-
-void tst_qquickvisualdatamodel::childChanged_data()
-{
- QTest::addColumn<QUrl>("source");
-
- QTest::newRow("item delegate") << testFileUrl("datalist.qml");
- QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
-}
-
-void tst_qquickvisualdatamodel::childChanged()
-{
- QFETCH(QUrl, source);
-
- QQuickView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
- vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
- QCOMPARE(listview->count(), 1);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Child Item"));
-
- model.item(1,0)->child(0,0)->setText("Row 2 updated child");
-
- name = findItem<QQuickText>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 updated child"));
-
- model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2")));
- QCOMPARE(listview->count(), 2);
-
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
-
- model.item(1,0)->takeRow(1);
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name == 0);
-
- vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
- QCOMPARE(listview->count(), 3);
- name = findItem<QQuickText>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QQuickText>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
-}
-
-void tst_qquickvisualdatamodel::objectListModel()
-{
- QQuickView view;
-
- QList<QObject*> dataList;
- dataList.append(new DataObject("Item 1", "red"));
- dataList.append(new DataObject("Item 2", "green"));
- dataList.append(new DataObject("Item 3", "blue"));
- dataList.append(new DataObject("Item 4", "yellow"));
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-
- view.setSource(testFileUrl("objectlist.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "name", 0);
- QCOMPARE(name->text(), QString("Item 1"));
-
- QQuickText *section = findItem<QQuickText>(contentItem, "section", 0);
- QCOMPARE(section->text(), QString("Item 1"));
-
- dataList[0]->setProperty("name", QLatin1String("Changed"));
- QCOMPARE(name->text(), QString("Changed"));
-}
-
-void tst_qquickvisualdatamodel::singleRole()
-{
- {
- QQuickView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("singlerole1.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
- QCOMPARE(name->text(), QString("two"));
-
- model.set(1, "Changed");
- QCOMPARE(name->text(), QString("Changed"));
- }
- {
- QQuickView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("singlerole2.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
- QCOMPARE(name->text(), QString("two"));
-
- model.set(1, "Changed");
- QCOMPARE(name->text(), QString("Changed"));
- }
- {
- QQuickView view;
-
- SingleRoleModel model("modelData");
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("singlerole2.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
- QCOMPARE(name->text(), QString("two"));
-
- model.set(1, "Changed");
- QCOMPARE(name->text(), QString("Changed"));
- }
-}
-
-void tst_qquickvisualdatamodel::modelProperties()
-{
- {
- QQuickView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("modelproperties.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(),QString("two"));
- QCOMPARE(delegate->property("test2").toString(),QString("two"));
- QCOMPARE(delegate->property("test3").toString(),QString("two"));
- QCOMPARE(delegate->property("test4").toString(),QString("two"));
- QVERIFY(!delegate->property("test9").isValid());
- QCOMPARE(delegate->property("test5").toString(),QString(""));
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- {
- QQuickView view;
-
- QList<QObject*> dataList;
- dataList.append(new DataObject("Item 1", "red"));
- dataList.append(new DataObject("Item 2", "green"));
- dataList.append(new DataObject("Item 3", "blue"));
- dataList.append(new DataObject("Item 4", "yellow"));
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-
- view.setSource(testFileUrl("modelproperties.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(),QString("Item 2"));
- QCOMPARE(delegate->property("test2").toString(),QString("Item 2"));
- QVERIFY(qobject_cast<DataObject*>(delegate->property("test3").value<QObject*>()) != 0);
- QVERIFY(qobject_cast<DataObject*>(delegate->property("test4").value<QObject*>()) != 0);
- QCOMPARE(delegate->property("test5").toString(),QString("Item 2"));
- QCOMPARE(delegate->property("test9").toString(),QString("Item 2"));
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- {
- QQuickView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- QUrl source(testFileUrl("modelproperties2.qml"));
-
- //3 items, 3 i each
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(),QString("Row 2 Item"));
- QCOMPARE(delegate->property("test2").toString(),QString("Row 2 Item"));
- QVERIFY(!delegate->property("test3").isValid());
- QVERIFY(!delegate->property("test4").isValid());
- QVERIFY(!delegate->property("test5").isValid());
- QVERIFY(!delegate->property("test9").isValid());
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- //### should also test QStringList and QVariantList
-}
-
-void tst_qquickvisualdatamodel::noDelegate_data()
-{
- QTest::addColumn<QUrl>("source");
-
- QTest::newRow("item delegate") << testFileUrl("datalist.qml");
- QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
-}
-
-void tst_qquickvisualdatamodel::noDelegate()
-{
- QFETCH(QUrl, source);
-
- QQuickView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
- QVERIFY(vdm != 0);
- QCOMPARE(vdm->count(), 3);
-
- vdm->setDelegate(0);
- QCOMPARE(vdm->count(), 0);
-}
-
-void tst_qquickvisualdatamodel::itemsDestroyed_data()
-{
- QTest::addColumn<QUrl>("source");
-
- QTest::newRow("listView") << testFileUrl("itemsDestroyed_listView.qml");
- QTest::newRow("package") << testFileUrl("itemsDestroyed_package.qml");
- QTest::newRow("pathView") << testFileUrl("itemsDestroyed_pathView.qml");
- QTest::newRow("repeater") << testFileUrl("itemsDestroyed_repeater.qml");
-}
-
-void tst_qquickvisualdatamodel::itemsDestroyed()
-{
- QFETCH(QUrl, source);
-
- QDeclarativeGuard<QQuickItem> delegate;
-
- {
- QQuickView view;
- QStandardItemModel model;
- initStandardTreeModel(&model);
- view.rootContext()->setContextProperty("myModel", &model);
- view.setSource(source);
-
- view.show();
- QTest::qWaitForWindowShown(&view);
-
- QVERIFY(delegate = findItem<QQuickItem>(view.rootItem(), "delegate", 1));
- }
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(!delegate);
-}
-
-void tst_qquickvisualdatamodel::packagesDestroyed()
-{
- SingleRoleModel model;
- model.list.clear();
- for (int i=0; i<30; i++)
- model.list << ("item " + i);
-
- QQuickView view;
- view.rootContext()->setContextProperty("testModel", &model);
-
- QString filename(testFile("packageView.qml"));
- view.setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QQuickListView *leftview = findItem<QQuickListView>(view.rootObject(), "leftList");
- QTRY_VERIFY(leftview != 0);
-
- QQuickListView *rightview = findItem<QQuickListView>(view.rootObject(), "rightList");
- QTRY_VERIFY(rightview != 0);
-
- QQuickItem *leftContent = leftview->contentItem();
- QTRY_VERIFY(leftContent != 0);
-
- QQuickItem *rightContent = rightview->contentItem();
- QTRY_VERIFY(rightContent != 0);
-
- QCOMPARE(leftview->currentIndex(), 0);
- QCOMPARE(rightview->currentIndex(), 0);
-
- rightview->setCurrentIndex(20);
- QTRY_COMPARE(rightview->contentY(), 100.0);
-
- QDeclarativeGuard<QQuickItem> left;
- QDeclarativeGuard<QQuickItem> right;
-
- QVERIFY(findItem<QQuickItem>(leftContent, "wrapper", 1));
- QVERIFY(findItem<QQuickItem>(rightContent, "wrapper", 1));
-
- QVERIFY(left = findItem<QQuickItem>(leftContent, "wrapper", 19));
- QVERIFY(right = findItem<QQuickItem>(rightContent, "wrapper", 19));
-
- rightview->setCurrentIndex(0);
- QCOMPARE(rightview->currentIndex(), 0);
-
- QTRY_COMPARE(rightview->contentY(), 0.0);
- QCoreApplication::sendPostedEvents();
-
- QVERIFY(!left);
- QVERIFY(!right);
-
- QVERIFY(left = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QVERIFY(right = findItem<QQuickItem>(rightContent, "wrapper", 1));
-
- rightview->setCurrentIndex(20);
- QTRY_COMPARE(rightview->contentY(), 100.0);
-
- QVERIFY(left);
- QVERIFY(right);
-
- QVERIFY(findItem<QQuickItem>(leftContent, "wrapper", 19));
- QVERIFY(findItem<QQuickItem>(rightContent, "wrapper", 19));
-
- leftview->setCurrentIndex(20);
- QTRY_COMPARE(leftview->contentY(), 100.0);
-
- QVERIFY(!left);
- QVERIFY(!right);
-}
-
-void tst_qquickvisualdatamodel::qaimRowsMoved()
-{
- // Test parameters passed in QAIM::rowsMoved() signal are converted correctly
- // when translated and emitted as the QListModelInterface::itemsMoved() signal
- QFETCH(int, sourceFirst);
- QFETCH(int, sourceLast);
- QFETCH(int, destinationChild);
- QFETCH(int, expectFrom);
- QFETCH(int, expectTo);
- QFETCH(int, expectCount);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml"));
-
- SingleRoleModel model;
- model.list.clear();
- for (int i=0; i<30; i++)
- model.list << ("item " + i);
- engine.rootContext()->setContextProperty("myModel", &model);
-
- QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
- QVERIFY(obj != 0);
-
- QSignalSpy spy(obj, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)));
- model.emitMove(sourceFirst, sourceLast, destinationChild);
- QCOMPARE(spy.count(), 1);
-
- QCOMPARE(spy[0].count(), 2);
- QDeclarativeChangeSet changeSet = spy[0][0].value<QDeclarativeChangeSet>();
- QCOMPARE(changeSet.removes().count(), 1);
- QCOMPARE(changeSet.removes().at(0).index, expectFrom);
- QCOMPARE(changeSet.removes().at(0).count, expectCount);
- QCOMPARE(changeSet.inserts().count(), 1);
- QCOMPARE(changeSet.inserts().at(0).index, expectTo);
- QCOMPARE(changeSet.inserts().at(0).count, expectCount);
- QCOMPARE(changeSet.removes().at(0).moveId, changeSet.inserts().at(0).moveId);
- QCOMPARE(spy[0][1].toBool(), false);
-
- delete obj;
-}
-
-void tst_qquickvisualdatamodel::qaimRowsMoved_data()
-{
- QTest::addColumn<int>("sourceFirst");
- QTest::addColumn<int>("sourceLast");
- QTest::addColumn<int>("destinationChild");
- QTest::addColumn<int>("expectFrom");
- QTest::addColumn<int>("expectTo");
- QTest::addColumn<int>("expectCount");
-
- QTest::newRow("move 1 forward")
- << 1 << 1 << 6
- << 1 << 5 << 1;
-
- QTest::newRow("move 1 backwards")
- << 4 << 4 << 1
- << 4 << 1 << 1;
-
- QTest::newRow("move multiple forwards")
- << 0 << 2 << 13
- << 0 << 10 << 3;
-
- QTest::newRow("move multiple forwards, with same to")
- << 0 << 1 << 3
- << 0 << 1 << 2;
-
- QTest::newRow("move multiple backwards")
- << 10 << 14 << 1
- << 10 << 1 << 5;
-}
-
-void tst_qquickvisualdatamodel::remove_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("package delegate");
-
- QTest::newRow("item delegate")
- << testFileUrl("groups.qml")
- << QString();
- QTest::newRow("package")
- << testFileUrl("groups-package.qml")
- << QString("package.");
-}
-
-void tst_qquickvisualdatamodel::remove()
-{
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("groups.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
- QVERIFY(visualModel);
-
- {
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.remove(2)");
- QCOMPARE(listview->count(), 11);
- QCOMPARE(visualModel->items()->count(), 11);
- static const int mIndex[] = { 0, 1, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.remove(1, 4)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- static const int mIndex[] = { 0, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: index out of range");
- evaluate<void>(visualModel, "items.remove(-8, 4)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: index out of range");
- evaluate<void>(visualModel, "items.remove(12, 2)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: invalid count");
- evaluate<void>(visualModel, "items.remove(5, 3)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: invalid count");
- evaluate<void>(visualModel, "items.remove(5, -2)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- }
-}
-
-void tst_qquickvisualdatamodel::move_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("package delegate");
-
- QTest::newRow("item delegate")
- << testFileUrl("groups.qml")
- << QString();
- QTest::newRow("package")
- << testFileUrl("groups-package.qml")
- << QString("package.");
-}
-
-void tst_qquickvisualdatamodel::move()
-{
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("groups.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
- QVERIFY(visualModel);
-
- {
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.move(2, 4)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 0, 1, 3, 4, 2, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.move(4, 2)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.move(8, 0, 4)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 8, 9,10,11, 0, 1, 2, 3, 4, 5, 6, 7 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.move(3, 4, 5)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 8, 9,10,4, 11, 0, 1, 2, 3, 5, 6, 7 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: invalid count");
- evaluate<void>(visualModel, "items.move(5, 2, -2)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
- evaluate<void>(visualModel, "items.move(-6, 2, 1)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
- evaluate<void>(visualModel, "items.move(15, 2, 1)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
- evaluate<void>(visualModel, "items.move(11, 1, 3)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
- evaluate<void>(visualModel, "items.move(2, -5, 1)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
- evaluate<void>(visualModel, "items.move(2, 14, 1)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
- evaluate<void>(visualModel, "items.move(2, 11, 4)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- }
-}
-
-void tst_qquickvisualdatamodel::groups_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("part");
-
- QTest::newRow("item delegate")
- << testFileUrl("groups.qml")
- << QString();
- QTest::newRow("package")
- << testFileUrl("groups-package.qml")
- << QString("visualModel.parts.package.");
-}
-
-template <int N> void tst_qquickvisualdatamodel::groups_verify(
- const SingleRoleModel &model,
- QQuickItem *contentItem,
- const int (&mIndex)[N],
- const int (&iIndex)[N],
- const int (&vIndex)[N],
- const int (&sIndex)[N],
- const bool (&vMember)[N],
- const bool (&sMember)[N])
-{
- failed = true;
- for (int i = 0; i < N; ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(evaluate<QString>(delegate, "test1"), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<int>(delegate, "test2") , mIndex[i]);
- QCOMPARE(evaluate<int>(delegate, "test3") , iIndex[i]);
- QCOMPARE(evaluate<bool>(delegate, "test4"), true);
- QCOMPARE(evaluate<int>(delegate, "test5") , vIndex[i]);
- QCOMPARE(evaluate<bool>(delegate, "test6"), vMember[i]);
- QCOMPARE(evaluate<int>(delegate, "test7") , sIndex[i]);
- QCOMPARE(evaluate<bool>(delegate, "test8"), sMember[i]);
- QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("items") , bool(true));
- QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("visible") , bool(vMember[i]));
- QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("selected"), bool(sMember[i]));
- }
- failed = false;
-}
-
-#define VERIFY_GROUPS \
- groups_verify(model, contentItem, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \
- QVERIFY(!failed)
-
-
-void tst_qquickvisualdatamodel::groups()
-{
- QFETCH(QUrl, source);
- QFETCH(QString, part);
-
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = listview->findChild<QQuickVisualDataModel *>("visualModel");
- QVERIFY(visualModel);
-
- QQuickVisualDataGroup *visibleItems = listview->findChild<QQuickVisualDataGroup *>("visibleItems");
- QVERIFY(visibleItems);
-
- QQuickVisualDataGroup *selectedItems = listview->findChild<QQuickVisualDataGroup *>("selectedItems");
- QVERIFY(selectedItems);
-
- const bool f = false;
- const bool t = true;
-
- {
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 0);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(visualModel, "items.addGroups(8, \"selected\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 1);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 4);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
- static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(visualModel, "items.setGroups(2, [\"items\", \"selected\"])");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 11);
- QCOMPARE(selectedItems->count(), 5);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 };
- static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 };
- static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(selectedItems, "setGroups(0, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
- static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GROUPS;
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: invalid count");
- evaluate<void>(visualModel, "items.addGroups(11, -4, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: index out of range");
- evaluate<void>(visualModel, "items.addGroups(-1, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: index out of range");
- evaluate<void>(visualModel, "items.addGroups(14, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: invalid count");
- evaluate<void>(visualModel, "items.addGroups(11, 5, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: invalid count");
- evaluate<void>(visualModel, "items.setGroups(11, -4, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: index out of range");
- evaluate<void>(visualModel, "items.setGroups(-1, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: index out of range");
- evaluate<void>(visualModel, "items.setGroups(14, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: invalid count");
- evaluate<void>(visualModel, "items.setGroups(11, 5, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: invalid count");
- evaluate<void>(visualModel, "items.removeGroups(11, -4, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: index out of range");
- evaluate<void>(visualModel, "items.removeGroups(-1, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: index out of range");
- evaluate<void>(visualModel, "items.removeGroups(14, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: invalid count");
- evaluate<void>(visualModel, "items.removeGroups(11, 5, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- evaluate<void>(visualModel, part + "filterOnGroup = \"visible\"");
- QCOMPARE(listview->count(), 9);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("visible"));
- } {
- evaluate<void>(visualModel, part + "filterOnGroup = \"selected\"");
- QCOMPARE(listview->count(), 2);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("selected"));
- } {
- evaluate<void>(visualModel, part + "filterOnGroup = undefined");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("items"));
- } {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 5);
- QVERIFY(delegate);
-
- evaluate<void>(delegate, "hide()");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GROUPS;
- } {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 5);
- QVERIFY(delegate);
-
- evaluate<void>(delegate, "select()");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 3);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 };
- static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(visualModel, "items.move(2, 6, 3)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 3);
- static const int mIndex [] = { 0, 1, 5, 6, 7, 8, 2, 3, 4, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, f, f, t, f, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3 };
- static const bool sMember[] = { f, f, t, f, f, t, f, f, f, t, f, f };
- VERIFY_GROUPS;
- }
-}
-
-template <int N> void tst_qquickvisualdatamodel::get_verify(
- const SingleRoleModel &model,
- QQuickVisualDataModel *visualModel,
- QQuickVisualDataGroup *visibleItems,
- QQuickVisualDataGroup *selectedItems,
- const int (&mIndex)[N],
- const int (&iIndex)[N],
- const int (&vIndex)[N],
- const int (&sIndex)[N],
- const bool (&vMember)[N],
- const bool (&sMember)[N])
-{
- failed = true;
- for (int i = 0; i < N; ++i) {
- QCOMPARE(evaluate<QString>(visualModel, QString("items.get(%1).model.name").arg(i)), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<QString>(visualModel, QString("items.get(%1).model.modelData").arg(i)), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).model.index").arg(i)), mIndex[i]);
- QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).itemsIndex").arg(i)), iIndex[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inItems").arg(i)), true);
- QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).visibleIndex").arg(i)), vIndex[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inVisible").arg(i)), vMember[i]);
- QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).selectedIndex").arg(i)), sIndex[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inSelected").arg(i)), sMember[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"items\")").arg(i)), true);
- QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"visible\")").arg(i)), vMember[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"selected\")").arg(i)), sMember[i]);
-
- if (vMember[i]) {
- QCOMPARE(evaluate<QString>(visibleItems, QString("get(%1).model.name").arg(vIndex[i])), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<QString>(visibleItems, QString("get(%1).model.modelData").arg(vIndex[i])), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).model.index").arg(vIndex[i])), mIndex[i]);
- QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).itemsIndex").arg(vIndex[i])), iIndex[i]);
- QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inItems").arg(vIndex[i])), true);
- QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).visibleIndex").arg(vIndex[i])), vIndex[i]);
- QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inVisible").arg(vIndex[i])), vMember[i]);
- QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).selectedIndex").arg(vIndex[i])), sIndex[i]);
- QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inSelected").arg(vIndex[i])), sMember[i]);
-
- QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"items\")").arg(vIndex[i])), true);
- QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"visible\")").arg(vIndex[i])), vMember[i]);
- QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"selected\")").arg(vIndex[i])), sMember[i]);
- }
- if (sMember[i]) {
- QCOMPARE(evaluate<QString>(selectedItems, QString("get(%1).model.name").arg(sIndex[i])), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<QString>(selectedItems, QString("get(%1).model.modelData").arg(sIndex[i])), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).model.index").arg(sIndex[i])), mIndex[i]);
- QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).itemsIndex").arg(sIndex[i])), iIndex[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inItems").arg(sIndex[i])), true);
- QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).visibleIndex").arg(sIndex[i])), vIndex[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inVisible").arg(sIndex[i])), vMember[i]);
- QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).selectedIndex").arg(sIndex[i])), sIndex[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inSelected").arg(sIndex[i])), sMember[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"items\")").arg(sIndex[i])), true);
- QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"visible\")").arg(sIndex[i])), vMember[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"selected\")").arg(sIndex[i])), sMember[i]);
- }
- }
- failed = false;
-}
-
-#define VERIFY_GET \
- get_verify(model, visualModel, visibleItems, selectedItems, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \
- QVERIFY(!failed)
-
-void tst_qquickvisualdatamodel::get()
-{
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("groups.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
- QVERIFY(visualModel);
-
- QQuickVisualDataGroup *visibleItems = visualModel->findChild<QQuickVisualDataGroup *>("visibleItems");
- QVERIFY(visibleItems);
-
- QQuickVisualDataGroup *selectedItems = visualModel->findChild<QQuickVisualDataGroup *>("selectedItems");
- QVERIFY(selectedItems);
-
- QV8Engine *v8Engine = QDeclarativeEnginePrivate::getV8Engine(ctxt->engine());
- QVERIFY(v8Engine);
-
- const bool f = false;
- const bool t = true;
-
- {
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 0);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.addGroups(8, \"selected\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 1);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 4);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
- static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.setGroups(2, [\"items\", \"selected\"])");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 11);
- QCOMPARE(selectedItems->count(), 5);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 };
- static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 };
- static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(selectedItems, "setGroups(0, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
- static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.get(5).inVisible = false");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.get(5).inSelected = true");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 3);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 };
- static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.get(5).groups = [\"visible\", \"items\"]");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
- static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GET;
- }
-}
-
-void tst_qquickvisualdatamodel::invalidGroups()
-{
- QUrl source = testFileUrl("groups-invalid.qml");
- QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8());
-
- QDeclarativeComponent component(&engine, source);
- QScopedPointer<QObject> object(component.create());
- QVERIFY(object);
-
- QCOMPARE(evaluate<int>(object.data(), "groups.length"), 4);
- QCOMPARE(evaluate<QString>(object.data(), "groups[0].name"), QString("items"));
- QCOMPARE(evaluate<QString>(object.data(), "groups[1].name"), QString("persistedItems"));
- QCOMPARE(evaluate<QString>(object.data(), "groups[2].name"), QString("visible"));
- QCOMPARE(evaluate<QString>(object.data(), "groups[3].name"), QString("selected"));
-}
-
-void tst_qquickvisualdatamodel::onChanged_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QStringList>("tests");
-
- QTest::newRow("item appended")
- << QString("listModel.append({\"number\": \"five\"})")
- << (QStringList()
- << "verify(vm.removed, [], [], [])"
- << "verify(vm.inserted, [4], [1], [undefined])"
- << "verify(vi.removed, [], [], [])"
- << "verify(vi.inserted, [4], [1], [undefined])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item prepended")
- << QString("listModel.insert(0, {\"number\": \"five\"})")
- << (QStringList()
- << "verify(vm.removed, [], [], [])"
- << "verify(vm.inserted, [0], [1], [undefined])"
- << "verify(vi.removed, [], [], [])"
- << "verify(vi.inserted, [0], [1], [undefined])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item inserted")
- << QString("listModel.insert(2, {\"number\": \"five\"})")
- << (QStringList()
- << "verify(vm.removed, [], [], [])"
- << "verify(vm.inserted, [2], [1], [undefined])"
- << "verify(vi.removed, [], [], [])"
- << "verify(vi.inserted, [2], [1], [undefined])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
-
- QTest::newRow("item removed tail")
- << QString("listModel.remove(3)")
- << (QStringList()
- << "verify(vm.removed, [3], [1], [undefined])"
- << "verify(vm.inserted, [], [], [])"
- << "verify(vi.removed, [3], [1], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item removed head")
- << QString("listModel.remove(0)")
- << (QStringList()
- << "verify(vm.removed, [0], [1], [undefined])"
- << "verify(vm.inserted, [], [], [])"
- << "verify(vi.removed, [0], [1], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item removed middle")
- << QString("listModel.remove(1)")
- << (QStringList()
- << "verify(vm.removed, [1], [1], [undefined])"
- << "verify(vm.inserted, [], [], [])"
- << "verify(vi.removed, [1], [1], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
-
-
- QTest::newRow("item moved from tail")
- << QString("listModel.move(3, 0, 1)")
- << (QStringList()
- << "verify(vm.removed, [3], [1], [vm.inserted[0].moveId])"
- << "verify(vm.inserted, [0], [1], [vm.removed[0].moveId])"
- << "verify(vi.removed, [3], [1], [vi.inserted[0].moveId])"
- << "verify(vi.inserted, [0], [1], [vi.removed[0].moveId])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item moved from head")
- << QString("listModel.move(0, 2, 2)")
- << (QStringList()
- << "verify(vm.removed, [0], [2], [vm.inserted[0].moveId])"
- << "verify(vm.inserted, [2], [2], [vm.removed[0].moveId])"
- << "verify(vi.removed, [0], [2], [vi.inserted[0].moveId])"
- << "verify(vi.inserted, [2], [2], [vi.removed[0].moveId])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
-
- QTest::newRow("groups changed")
- << QString("items.setGroups(1, 2, [\"items\", \"selected\"])")
- << (QStringList()
- << "verify(vm.inserted, [], [], [])"
- << "verify(vm.removed, [], [], [])"
- << "verify(vi.removed, [1], [2], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [0], [2], [undefined])");
-
- QTest::newRow("multiple removes")
- << QString("{ vi.remove(1, 1); "
- "vi.removeGroups(0, 2, \"items\") }")
- << (QStringList()
- << "verify(vm.removed, [0, 1], [1, 1], [undefined, undefined])"
- << "verify(vm.inserted, [], [], [])"
- << "verify(vi.removed, [1], [1], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
-}
-
-void tst_qquickvisualdatamodel::onChanged()
-{
- QFETCH(QString, expression);
- QFETCH(QStringList, tests);
-
- QDeclarativeComponent component(&engine, testFileUrl("onChanged.qml"));
- QScopedPointer<QObject> object(component.create());
- QVERIFY(object);
-
- evaluate<void>(object.data(), expression);
-
- foreach (const QString &test, tests) {
- bool passed = evaluate<bool>(object.data(), test);
- if (!passed)
- qWarning() << test;
- QVERIFY(passed);
- }
-}
-
-void tst_qquickvisualdatamodel::create()
-{
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve"
- << "thirteen"
- << "fourteen"
- << "fifteen"
- << "sixteen"
- << "seventeen"
- << "eighteen"
- << "nineteen"
- << "twenty";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("create.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
- QVERIFY(visualModel);
-
- QCOMPARE(listview->count(), 20);
-
- QDeclarativeGuard<QQuickItem> delegate;
-
- // persistedItems.includeByDefault is true, so all items belong to persistedItems initially.
- QVERIFY(delegate = findItem<QQuickItem>(contentItem, "delegate", 1));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
-
- // changing include by default doesn't remove persistance.
- evaluate<void>(visualModel, "persistedItems.includeByDefault = false");
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
-
- // removing from persistedItems does.
- evaluate<void>(visualModel, "persistedItems.remove(0, 20)");
- QCOMPARE(listview->count(), 20);
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
-
- // Request an item instantiated by the view.
- QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(1)")));
- QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 1));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
-
- evaluate<void>(delegate, "VisualDataModel.inPersistedItems = false");
- QCOMPARE(listview->count(), 20);
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
-
- // Request an item not instantiated by the view.
- QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 15));
- QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(15)")));
- QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 15));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
-
- evaluate<void>(visualModel, "persistedItems.remove(0)");
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(!delegate);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
-
- // Request an item not instantiated by the view, then scroll the view so it will request it.
- QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 16));
- QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(16)")));
- QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 16));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
-
- evaluate<void>(listview, "positionViewAtIndex(19, ListView.End)");
- QCOMPARE(listview->count(), 20);
- evaluate<void>(delegate, "VisualDataModel.groups = [\"items\"]");
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
-
- // Request and release an item instantiated by the view, then scroll the view so it releases it.
- QVERIFY(findItem<QQuickItem>(contentItem, "delegate", 17));
- QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(17)")));
- QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 17));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
-
- evaluate<void>(visualModel, "items.removeGroups(17, \"persistedItems\")");
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
- evaluate<void>(listview, "positionViewAtIndex(1, ListView.Beginning)");
- QCOMPARE(listview->count(), 20);
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(!delegate);
-
- // Adding an item to the persistedItems group won't instantiate it, but if later requested by
- // the view it will be persisted.
- evaluate<void>(visualModel, "items.addGroups(18, \"persistedItems\")");
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
- QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 18));
- evaluate<void>(listview, "positionViewAtIndex(19, ListView.End)");
- QCOMPARE(listview->count(), 20);
- QVERIFY(delegate = findItem<QQuickItem>(contentItem, "delegate", 18));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
- evaluate<void>(listview, "positionViewAtIndex(1, ListView.Beginning)");
- QCOMPARE(listview->count(), 20);
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
-
- // Remove an uninstantiated but cached item from the persistedItems group.
- evaluate<void>(visualModel, "items.addGroups(19, \"persistedItems\")");
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 2);
- QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 19));
- // Store a reference to the item so it is retained in the cache.
- evaluate<void>(visualModel, "persistentHandle = items.get(19)");
- QCOMPARE(evaluate<bool>(visualModel, "persistentHandle.inPersistedItems"), true);
- evaluate<void>(visualModel, "items.removeGroups(19, \"persistedItems\")");
- QCOMPARE(evaluate<bool>(visualModel, "persistentHandle.inPersistedItems"), false);
-}
-
-void tst_qquickvisualdatamodel::incompleteModel()
-{
- // VisualDataModel is first populated in componentComplete. Verify various functions are
- // harmlessly ignored until then.
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\n VisualDataModel {}", testFileUrl(""));
-
- QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
-
- QQuickVisualDataModel *model = qobject_cast<QQuickVisualDataModel *>(object.data());
- QVERIFY(model);
-
- QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged()));
- QSignalSpy persistedItemsSpy(model->items(), SIGNAL(countChanged()));
-
- evaluate<void>(model, "items.removeGroups(0, items.count, \"items\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- evaluate<void>(model, "items.setGroups(0, items.count, \"persistedItems\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- evaluate<void>(model, "items.addGroups(0, items.count, \"persistedItems\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- evaluate<void>(model, "items.remove(0, items.count)");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- evaluate<void>(model, "items.insert([ \"color\": \"blue\" ])");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: get: index out of range");
- QVERIFY(evaluate<bool>(model, "items.get(0) === undefined"));
-
- component.completeCreate();
-}
-
-void tst_qquickvisualdatamodel::insert_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("expression");
- QTest::addColumn<int>("modelCount");
- QTest::addColumn<int>("visualCount");
- QTest::addColumn<int>("index");
- QTest::addColumn<bool>("inItems");
- QTest::addColumn<bool>("persisted");
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("selected");
- QTest::addColumn<bool>("modelData");
- QTest::addColumn<QString>("property");
- QTest::addColumn<QStringList>("propertyData");
-
- const QUrl listModelSource[] = {
- testFileUrl("listmodelproperties.qml"),
- testFileUrl("listmodelproperties-package.qml") };
- const QUrl singleRoleSource[] = {
- testFileUrl("singleroleproperties.qml"),
- testFileUrl("singleroleproperties-package.qml") };
- const QUrl multipleRoleSource[] = {
- testFileUrl("multipleroleproperties.qml"),
- testFileUrl("multipleroleproperties-package.qml") };
- const QUrl stringListSource[] = {
- testFileUrl("stringlistproperties.qml"),
- testFileUrl("stringlistproperties-package.qml") };
- const QUrl objectListSource[] = {
- testFileUrl("objectlistproperties.qml"),
- testFileUrl("objectlistproperties-package.qml") };
-
- for (int i = 0; i < 2; ++i) {
- // List Model.
- QTest::newRow("ListModel.items prepend")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << 4 << 5 << 4 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items insert at 2")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items insert at items.get(2)")
- << listModelSource[i]
- << QString("items.insert(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items insert at visibleItems.get(2)")
- << listModelSource[i]
- << QString("items.insert(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems insert at items.get(2)")
- << listModelSource[i]
- << QString("selectedItems.insert(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << false << false << false << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems insert at visibleItems.get(2)")
- << listModelSource[i]
- << QString("selectedItems.insert(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << false << false << false << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend modelData")
- << listModelSource[i]
- << QString("items.insert(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, edit number")
- << listModelSource[i]
- << QString("{ "
- "items.insert(0, {\"number\": \"eight\"}); "
- "items.get(0).model.number = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, edit modelData")
- << listModelSource[i]
- << QString("{ "
- "items.insert(0, {\"number\": \"eight\"}); "
- "items.get(0).model.modelData = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, edit resolved")
- << listModelSource[i]
- << QString("{ "
- "items.insert(0, {\"number\": \"eight\"}); "
- "items.get(2).model.number = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend with groups")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])")
- << 4 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append with groups")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"}, [\"visible\", \"selected\"])")
- << 4 << 5 << 4 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items insert at 2 with groups")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"}, \"visible\")")
- << 4 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- // create ListModel
- QTest::newRow("ListModel.items prepend")
- << listModelSource[i]
- << QString("items.create(0, {\"number\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append")
- << listModelSource[i]
- << QString("items.create({\"number\": \"eight\"})")
- << 4 << 5 << 4 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items create at 2")
- << listModelSource[i]
- << QString("items.create(2, {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create at items.get(2)")
- << listModelSource[i]
- << QString("items.create(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create at visibleItems.get(2)")
- << listModelSource[i]
- << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems create at items.get(2)")
- << listModelSource[i]
- << QString("selectedItems.create(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << false << true << false << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems create at visibleItems.get(2)")
- << listModelSource[i]
- << QString("selectedItems.create(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << false << true << false << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended")
- << listModelSource[i]
- << QString("items.create(0, {\"number\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create appended")
- << listModelSource[i]
- << QString("items.create({\"number\": \"eight\"})")
- << 4 << 5 << 4 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items create at 2")
- << listModelSource[i]
- << QString("items.create(2, {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create at items.get(2)")
- << listModelSource[i]
- << QString("items.create(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create at visibleItems.get(2)")
- << listModelSource[i]
- << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.create prepend modelData")
- << listModelSource[i]
- << QString("items.create(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended, edit number")
- << listModelSource[i]
- << QString("{ "
- "var item = items.create(0, {\"number\": \"eight\"}); "
- "item.setTest3(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended, edit model.number")
- << listModelSource[i]
- << QString("{ "
- "var item = items.create(0, {\"number\": \"eight\"}); "
- "item.setTest4(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended, edit modelData")
- << listModelSource[i]
- << QString("{ "
- "var item = items.create(0, {\"number\": \"eight\"}); "
- "item.setTest5(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended, edit model.modelData")
- << listModelSource[i]
- << QString("{ "
- "var item = items.create(0, {\"number\": \"eight\"}); "
- "item.setTest6(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended with groups")
- << listModelSource[i]
- << QString("items.create(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])")
- << 4 << 5 << 0 << true << true << true << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create appended with groups")
- << listModelSource[i]
- << QString("items.create({\"number\": \"eight\"}, [\"visible\", \"selected\"])")
- << 4 << 5 << 4 << true << true << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items create inserted with groups")
- << listModelSource[i]
- << QString("items.create(2, {\"number\": \"eight\"}, \"visible\")")
- << 4 << 5 << 2 << true << true << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended clear persistence")
- << listModelSource[i]
- << QString("{ items.create(0, {\"number\": \"eight\"}); "
- "items.get(0).inPersistedItems = false }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create appended clear persistence")
- << listModelSource[i]
- << QString("{ items.create({\"number\": \"eight\"}); "
- "items.get(4).inPersistedItems = false }")
- << 4 << 5 << 4 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items create inserted clear persistence")
- << listModelSource[i]
- << QString("{ items.create(2, {\"number\": \"eight\"}); "
- "items.get(2).inPersistedItems = false }")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- // AbstractItemModel (Single Role).
- QTest::newRow("AbstractItemModel.items prepend")
- << singleRoleSource[i]
- << QString("items.insert(0, {\"name\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items append")
- << singleRoleSource[i]
- << QString("items.insert({\"name\": \"eight\"})")
- << 4 << 5 << 4 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("AbstractItemModel.items insert at 2")
- << singleRoleSource[i]
- << QString("items.insert(2, {\"name\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items prepend modelData")
- << singleRoleSource[i]
- << QString("items.insert(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items prepend, edit name")
- << singleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"name\": \"eight\"}); "
- "items.get(0).model.name = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items prepend, edit modelData")
- << singleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"name\": \"eight\"}); "
- "items.get(0).model.modelData = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items prepend, edit resolved")
- << singleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"name\": \"eight\"}); "
- "items.get(2).model.name = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.create prepend modelData")
- << singleRoleSource[i]
- << QString("items.create(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items create prepended, edit name")
- << singleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"name\": \"eight\"}); "
- "item.setTest3(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items create prepended, edit model.name")
- << singleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"name\": \"eight\"}); "
- "item.setTest4(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items create prepended, edit modelData")
- << singleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"name\": \"eight\"}); "
- "item.setTest5(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items create prepended, edit model.modelData")
- << singleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"name\": \"eight\"}); "
- "item.setTest6(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- // AbstractItemModel (Multiple Roles).
- QTest::newRow("StandardItemModel.items prepend")
- << multipleRoleSource[i]
- << QString("items.insert(0, {\"display\": \"Row 8 Item\"})")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items append")
- << multipleRoleSource[i]
- << QString("items.insert({\"display\": \"Row 8 Item\"})")
- << 4 << 5 << 4 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item" << "Row 8 Item");
-
- QTest::newRow("StandardItemModel.items insert at 2")
- << multipleRoleSource[i]
- << QString("items.insert(2, {\"display\": \"Row 8 Item\"})")
- << 4 << 5 << 2 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 8 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items prepend modelData")
- << multipleRoleSource[i]
- << QString("items.insert(0, {\"modelData\": \"Row 8 Item\"})")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items prepend, edit display")
- << multipleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"display\": \"Row 8 Item\"}); "
- "items.get(0).model.display = \"Row 7 Item\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items prepend, edit modelData")
- << multipleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"display\": \"Row 8 Item\"}); "
- "items.get(0).model.modelData = \"Row 7 Item\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items prepend, edit resolved")
- << multipleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"display\": \"Row 8 Item\"}); "
- "items.get(2).model.display = \"Row 7 Item\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.create prepend modelData")
- << multipleRoleSource[i]
- << QString("items.create(0, {\"modelData\": \"Row 8 Item\"})")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("display")
- << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items create prepended, edit display")
- << multipleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"display\": \"Row 8 Item\"}); "
- "item.setTest3(\"Row 7 Item\"); }")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("display")
- << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items create prepended, edit model.display")
- << multipleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"display\": \"Row 8 Item\"}); "
- "item.setTest4(\"Row 7 Item\"); }")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("display")
- << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- // StringList.
- QTest::newRow("StringList.items prepend")
- << stringListSource[i]
- << QString("items.insert(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items append")
- << stringListSource[i]
- << QString("items.insert({\"modelData\": \"eight\"})")
- << 4 << 5 << 4 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("StringList.items insert at 2")
- << stringListSource[i]
- << QString("items.insert(2, {\"modelData\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("StringList.items prepend, edit modelData")
- << stringListSource[i]
- << QString("{ "
- "items.insert(0, {\"modelData\": \"eight\"}); "
- "items.get(0).model.modelData = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items prepend, edit resolved")
- << stringListSource[i]
- << QString("{ "
- "items.insert(0, {\"modelData\": \"eight\"}); "
- "items.get(2).model.modelData = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.create prepend modelData")
- << stringListSource[i]
- << QString("items.create(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("modelData")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items create prepended, edit modelData")
- << stringListSource[i]
- << QString("{ "
- "var item = items.create(0, {\"modelData\": \"eight\"}); "
- "item.setTest3(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("modelData")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items create prepended, edit model.modelData")
- << stringListSource[i]
- << QString("{ "
- "var item = items.create(0, {\"modelData\": \"eight\"}); "
- "item.setTest4(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("modelData")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- // ObjectList
- QTest::newRow("ObjectList.items prepend")
- << objectListSource[i]
- << QString("items.insert(0, {\"name\": \"Item 8\"})")
- << 4 << 4 << 4 << false << false << false << false << false
- << QString("name")
- << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
-
- QTest::newRow("ObjectList.items append")
- << objectListSource[i]
- << QString("items.insert({\"name\": \"Item 8\"})")
- << 4 << 4 << 4 << false << false << false << false << false
- << QString("name")
- << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
-
- QTest::newRow("ObjectList.items insert at 2")
- << objectListSource[i]
- << QString("items.insert(2, {\"name\": \"Item 8\"})")
- << 4 << 4 << 4 << false << false << false << false << false
- << QString("name")
- << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
- }
-}
-
-void tst_qquickvisualdatamodel::insert()
-{
- QFETCH(QUrl, source);
- QFETCH(QString, expression);
- QFETCH(int, modelCount);
- QFETCH(int, visualCount);
- QFETCH(int, index);
- QFETCH(bool, inItems);
- QFETCH(bool, persisted);
- QFETCH(bool, visible);
- QFETCH(bool, selected);
- QFETCH(bool, modelData);
- QFETCH(QString, property);
- QFETCH(QStringList, propertyData);
-
- QQuickCanvas canvas;
-
- QDeclarativeComponent component(&engine);
- component.loadUrl(source);
- QScopedPointer<QObject> object(component.create());
- QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
- QVERIFY(listView);
- listView->setParentItem(canvas.rootItem());
-
- QQuickItem *contentItem = listView->contentItem();
- QVERIFY(contentItem);
-
- QObject *visualModel = listView->findChild<QObject *>("visualModel");
- QVERIFY(visualModel);
-
- evaluate<void>(visualModel, expression);
-
- QCOMPARE(evaluate<int>(listView, "count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "items.count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), persisted ? 1 : 0);
- QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
-
- QCOMPARE(propertyData.count(), visualCount);
- for (int i = 0; i < visualCount; ++i) {
- int modelIndex = i;
- if (modelIndex > index)
- modelIndex -= 1;
- else if (modelIndex == index)
- modelIndex = -1;
-
- const int itemsIndex = inItems || i <= index ? i : i - 1;
- QString get;
-
- if (i != index) {
- get = QString("items.get(%1)").arg(itemsIndex);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "delegate", modelIndex);
- QVERIFY(item);
-
- QCOMPARE(evaluate<int>(item, "test1"), modelIndex);
- QCOMPARE(evaluate<int>(item, "test2"), modelIndex);
- QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(i));
- QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(i));
-
- if (modelData) {
- QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(i));
- QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(i));
- }
-
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), false);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
-
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0);
- } else if (inItems) {
- get = QString("items.get(%1)").arg(index);
- } else if (persisted) {
- get = "persistedItems.get(0)";
- } else if (visible) {
- get = QString("visibleItems.get(%1)").arg(index);
- } else if (selected) {
- get = "selectedItems.get(0)";
- } else {
- continue;
- }
-
- QCOMPARE(evaluate<int>(visualModel, get + ".model.index"), modelIndex);
-
- QCOMPARE(evaluate<QString>(visualModel, get + ".model." + property), propertyData.at(i));
-
- QCOMPARE(evaluate<bool>(visualModel, get + ".inItems"), inItems || i != index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inPersistedItems"), persisted && i == index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inVisible"), visible || i != index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inSelected"), selected && i == index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".isUnresolved"), i == index);
-
- QCOMPARE(evaluate<int>(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0);
- QCOMPARE(evaluate<int>(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0);
- }
-
- QObject *item = 0;
-
- if (inItems)
- item = evaluate<QObject *>(visualModel, QString("items.create(%1)").arg(index));
- else if (persisted)
- item = evaluate<QObject *>(visualModel, QString("persistedItems.create(%1)").arg(0));
- else if (visible)
- item = evaluate<QObject *>(visualModel, QString("visibleItems.create(%1)").arg(index));
- else if (selected)
- item = evaluate<QObject *>(visualModel, QString("selectedItems.create(%1)").arg(0));
- else
- return;
-
- QVERIFY(item);
-
- QCOMPARE(evaluate<int>(item, "test1"), -1);
- QCOMPARE(evaluate<int>(item, "test2"), -1);
- QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(index));
- QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(index));
-
- if (modelData) {
- QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(index));
- QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(index));
- }
-
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), inItems);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), visible);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), selected);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), true);
-
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), index);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), 0);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), index);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), 0);
-}
-
-void tst_qquickvisualdatamodel::resolve_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("setupExpression");
- QTest::addColumn<QString>("resolveExpression");
- QTest::addColumn<int>("unresolvedCount");
- QTest::addColumn<int>("modelCount");
- QTest::addColumn<int>("visualCount");
- QTest::addColumn<int>("index");
- QTest::addColumn<bool>("inItems");
- QTest::addColumn<bool>("persisted");
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("selected");
- QTest::addColumn<bool>("modelData");
- QTest::addColumn<QString>("property");
- QTest::addColumn<QStringList>("propertyData");
-
- const QUrl listModelSource[] = {
- testFileUrl("listmodelproperties.qml"),
- testFileUrl("listmodelproperties-package.qml") };
- const QUrl singleRoleSource[] = {
- testFileUrl("singleroleproperties.qml"),
- testFileUrl("singleroleproperties-package.qml") };
- const QUrl multipleRoleSource[] = {
- testFileUrl("multipleroleproperties.qml"),
- testFileUrl("multipleroleproperties-package.qml") };
- const QUrl stringListSource[] = {
- testFileUrl("stringlistproperties.qml"),
- testFileUrl("stringlistproperties-package.qml") };
- const QUrl objectListSource[] = {
- testFileUrl("objectlistproperties.qml"),
- testFileUrl("objectlistproperties-package.qml") };
-
- for (int i = 0; i < 2; ++i) {
- // List Model.
- QTest::newRow("ListModel.items prepend, resolve prepended")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(0, 1) }")
- << 5 << 5 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, resolve appended")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(0, 5) }")
- << 5 << 5 << 5 << 4 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.items prepend, resolve inserted")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(0, 3) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items append, resolve prepended")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(5, 0) }")
- << 5 << 5 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append, resolve appended")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(5, 4) }")
- << 5 << 5 << 5 << 4 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.items append, resolve inserted")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(5, 2) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, resolve prepended")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(3, 0) }")
- << 5 << 5 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, resolve appended")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(2, 5) }")
- << 5 << 5 << 5 << 4 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.items insert, resolve inserted")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(2, 3) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, move resolved")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
- "items.resolve(0, 1); "
- "listModel.move(0, 2, 1) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items append, move resolved")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); "
- "items.resolve(5, 4); "
- "listModel.move(4, 2, 1) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, move resolved")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
- "items.resolve(2, 3);"
- "listModel.move(2, 0, 1) }")
- << 5 << 5 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, remove resolved")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
- "items.resolve(0, 1); "
- "listModel.remove(0, 1) }")
- << 5 << 4 << 4 << 4 << false << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append, remove resolved")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); "
- "items.resolve(5, 4); "
- "listModel.remove(4, 1) }")
- << 5 << 4 << 4 << 4 << false << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, remove resolved")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
- "items.resolve(2, 3);"
- "listModel.remove(2, 1) }")
- << 5 << 4 << 4 << 4 << false << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems prepend, resolve prepended")
- << listModelSource[i]
- << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(0)) }")
- << 4 << 5 << 5 << 0 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems prepend, resolve appended")
- << listModelSource[i]
- << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(4)) }")
- << 4 << 5 << 5 << 4 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.selectedItems prepend, resolve inserted")
- << listModelSource[i]
- << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(2)) }")
- << 4 << 5 << 5 << 2 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems append, resolve prepended")
- << listModelSource[i]
- << QString("selectedItems.insert({\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(0)) }")
- << 4 << 5 << 5 << 0 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems append, resolve appended")
- << listModelSource[i]
- << QString("selectedItems.insert({\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(4)) }")
- << 4 << 5 << 5 << 4 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.selectedItems append, resolve inserted")
- << listModelSource[i]
- << QString("selectedItems.insert({\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(2)) }")
- << 4 << 5 << 5 << 2 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- // AbstractItemModel (Single Role)
- QTest::newRow("ListModel.items prepend, resolve prepended")
- << singleRoleSource[i]
- << QString("items.insert(0, {\"name\": \"eight\"})")
- << QString("{ items.resolve(0, 1) }")
- << 5 << 4 << 4 << 0 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
-
- QTest::newRow("ListModel.items append, resolve appended")
- << singleRoleSource[i]
- << QString("items.insert({\"name\": \"eight\"})")
- << QString("{ items.resolve(4, 3) }")
- << 5 << 4 << 4 << 3 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, resolve inserted")
- << singleRoleSource[i]
- << QString("items.insert(2, {\"name\": \"eight\"})")
- << QString("{ items.resolve(2, 3) }")
- << 5 << 4 << 4 << 2 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- // AbstractItemModel (Single Role)
- QTest::newRow("AbstractItemModel.items prepend, resolve prepended")
- << singleRoleSource[i]
- << QString("items.insert(0, {\"name\": \"eight\"})")
- << QString("{ items.resolve(0, 1) }")
- << 5 << 4 << 4 << 0 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items append, resolve appended")
- << singleRoleSource[i]
- << QString("items.insert({\"name\": \"eight\"})")
- << QString("{ items.resolve(4, 3) }")
- << 5 << 4 << 4 << 3 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items insert, resolve inserted")
- << singleRoleSource[i]
- << QString("items.insert(2, {\"name\": \"eight\"})")
- << QString("{ items.resolve(2, 3) }")
- << 5 << 4 << 4 << 2 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- // AbstractItemModel (Multiple Roles)
- QTest::newRow("StandardItemModel.items prepend, resolve prepended")
- << multipleRoleSource[i]
- << QString("items.insert(0, {\"display\": \"Row 8 Item\"})")
- << QString("{ items.resolve(0, 1) }")
- << 5 << 4 << 4 << 0 << true << false << true << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items append, resolve appended")
- << multipleRoleSource[i]
- << QString("items.insert({\"display\": \"Row 8 Item\"})")
- << QString("{ items.resolve(4, 3) }")
- << 5 << 4 << 4 << 3 << true << false << true << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items insert, resolve inserted")
- << multipleRoleSource[i]
- << QString("items.insert(2, {\"display\": \"Row 8 Item\"})")
- << QString("{ items.resolve(2, 3) }")
- << 5 << 4 << 4 << 2 << true << false << true << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- // StringList
- QTest::newRow("StringList.items prepend, resolve prepended")
- << stringListSource[i]
- << QString("items.insert(0, {\"modelData\": \"eight\"})")
- << QString("{ items.resolve(0, 1) }")
- << 5 << 4 << 4 << 0 << true << false << true << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items append, resolve appended")
- << stringListSource[i]
- << QString("items.insert({\"modelData\": \"eight\"})")
- << QString("{ items.resolve(4, 3) }")
- << 5 << 4 << 4 << 3 << true << false << true << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items insert, resolve inserted")
- << stringListSource[i]
- << QString("items.insert(2, {\"modelData\": \"eight\"})")
- << QString("{ items.resolve(2, 3) }")
- << 5 << 4 << 4 << 2 << true << false << true << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "three" << "four");
- }
-}
-
-void tst_qquickvisualdatamodel::resolve()
-{
- QFETCH(QUrl, source);
- QFETCH(QString, setupExpression);
- QFETCH(QString, resolveExpression);
- QFETCH(int, unresolvedCount);
- QFETCH(int, modelCount);
- QFETCH(int, visualCount);
- QFETCH(int, index);
- QFETCH(bool, inItems);
- QFETCH(bool, persisted);
- QFETCH(bool, visible);
- QFETCH(bool, selected);
- QFETCH(bool, modelData);
- QFETCH(QString, property);
- QFETCH(QStringList, propertyData);
-
- QQuickCanvas canvas;
-
- QDeclarativeComponent component(&engine);
- component.loadUrl(source);
- QScopedPointer<QObject> object(component.create());
- QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
- QVERIFY(listView);
- listView->setParentItem(canvas.rootItem());
-
- QQuickItem *contentItem = listView->contentItem();
- QVERIFY(contentItem);
-
- QObject *visualModel = listView->findChild<QObject *>("visualModel");
- QVERIFY(visualModel);
-
- evaluate<void>(visualModel, setupExpression);
- QCOMPARE(evaluate<int>(listView, "count"), unresolvedCount);
-
- evaluate<void>(visualModel, resolveExpression);
-
- QCOMPARE(evaluate<int>(listView, "count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "items.count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), persisted ? 1 : 0);
- QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
-
- QCOMPARE(propertyData.count(), visualCount);
- for (int i = 0; i < visualCount; ++i) {
- int modelIndex = i;
-
- const int itemsIndex = inItems || i <= index ? i : i - 1;
- QString get;
-
- if (i != index) {
- get = QString("items.get(%1)").arg(itemsIndex);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "delegate", modelIndex);
- QVERIFY(item);
-
- QCOMPARE(evaluate<int>(item, "test1"), modelIndex);
- QCOMPARE(evaluate<int>(item, "test2"), modelIndex);
- QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(i));
- QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(i));
-
- if (modelData) {
- QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(i));
- QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(i));
- }
-
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), false);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
-
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0);
- } else if (inItems) {
- get = QString("items.get(%1)").arg(index);
- } else if (persisted) {
- get = "persistedItems.get(0)";
- } else if (visible) {
- get = QString("visibleItems.get(%1)").arg(index);
- } else if (selected) {
- get = "selectedItems.get(0)";
- } else {
- continue;
- }
-
- QCOMPARE(evaluate<int>(visualModel, get + ".model.index"), modelIndex);
-
- QCOMPARE(evaluate<QString>(visualModel, get + ".model." + property), propertyData.at(i));
-
- QCOMPARE(evaluate<bool>(visualModel, get + ".inItems"), inItems || i != index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inPersistedItems"), persisted && i == index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inVisible"), visible || i != index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inSelected"), selected && i == index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".isUnresolved"), false);
-
- QCOMPARE(evaluate<int>(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0);
- QCOMPARE(evaluate<int>(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0);
- }
-
- QObject *item = 0;
-
- if (inItems)
- item = evaluate<QObject *>(visualModel, QString("items.create(%1)").arg(index));
- else if (persisted)
- item = evaluate<QObject *>(visualModel, QString("persistedItems.create(%1)").arg(0));
- else if (visible)
- item = evaluate<QObject *>(visualModel, QString("visibleItems.create(%1)").arg(index));
- else if (selected)
- item = evaluate<QObject *>(visualModel, QString("selectedItems.create(%1)").arg(0));
- else
- return;
-
- QVERIFY(item);
-
- QCOMPARE(evaluate<int>(item, "test1"), index);
- QCOMPARE(evaluate<int>(item, "test2"), index);
- QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(index));
- QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(index));
-
- if (modelData) {
- QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(index));
- QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(index));
- }
-
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), inItems);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), visible);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), selected);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
-
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), index);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), 0);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), index);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), 0);
-}
-
-void tst_qquickvisualdatamodel::warnings_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<int>("count");
-
- QTest::newRow("insert < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.insert(-2, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
- << 4;
-
- QTest::newRow("insert > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.insert(8, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
- << 4;
-
- QTest::newRow("create < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.create(-2, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
- << 4;
-
- QTest::newRow("create > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.create(8, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
- << 4;
-
- QTest::newRow("resolve from < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(-2, 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
- << 4;
-
- QTest::newRow("resolve from > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(8, 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
- << 4;
-
- QTest::newRow("resolve to < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(3, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
- << 4;
-
- QTest::newRow("resolve to > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(3, 8)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
- << 4;
-
- QTest::newRow("resolve from invalid index")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(\"two\", 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid"))
- << 4;
-
- QTest::newRow("resolve to invalid index")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(3, \"two\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid"))
- << 4;
-
- QTest::newRow("resolve already resolved item")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(3, 2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item"))
- << 4;
-
- QTest::newRow("resolve already resolved item")
- << testFileUrl("listmodelproperties.qml")
- << QString("{ items.insert(0, {\"number\": \"eight\"});"
- "items.insert(1, {\"number\": \"seven\"});"
- "items.resolve(0, 1)}")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item"))
- << 6;
-
- QTest::newRow("remove index < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(-2, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
- << 4;
-
- QTest::newRow("remove index == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(4, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
- << 4;
-
- QTest::newRow("remove index > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(9, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
- << 4;
-
- QTest::newRow("remove invalid index")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(\"nine\", 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index"))
- << 4;
-
- QTest::newRow("remove count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(1, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
- << 4;
-
- QTest::newRow("remove index + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
- << 4;
-
- QTest::newRow("addGroups index < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
- << 4;
-
- QTest::newRow("addGroups index == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
- << 4;
-
- QTest::newRow("addGroups index > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
- << 4;
-
- QTest::newRow("addGroups count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
- << 4;
-
- QTest::newRow("addGroups index + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
- << 4;
-
- QTest::newRow("removeGroups index < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
- << 4;
-
- QTest::newRow("removeGroups index == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
- << 4;
-
- QTest::newRow("removeGroups index > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
- << 4;
-
- QTest::newRow("removeGroups count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
- << 4;
-
- QTest::newRow("removeGroups index + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
- << 4;
-
- QTest::newRow("setGroups index < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
- << 4;
-
- QTest::newRow("setGroups index == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
- << 4;
-
- QTest::newRow("setGroups index > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
- << 4;
-
- QTest::newRow("setGroups count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
- << 4;
-
- QTest::newRow("setGroups index + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
- << 4;
-
- QTest::newRow("move from < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(-2, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
- << 4;
-
- QTest::newRow("move from == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(4, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
- << 4;
-
- QTest::newRow("move from > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(9, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
- << 4;
-
- QTest::newRow("move invalid from")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(\"nine\", 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index"))
- << 4;
-
- QTest::newRow("move to < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, -2, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
- << 4;
-
- QTest::newRow("move to == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, 4, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
- << 4;
-
- QTest::newRow("move to > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, 9, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
- << 4;
-
- QTest::newRow("move invalid to")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, \"nine\", 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index"))
- << 4;
-
- QTest::newRow("move count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, 1, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count"))
- << 4;
-
- QTest::newRow("move from + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(2, 1, 4)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
- << 4;
-}
-
-void tst_qquickvisualdatamodel::warnings()
-{
- QFETCH(QUrl, source);
- QFETCH(QString, expression);
- QFETCH(QString, warning);
- QFETCH(int, count);
-
- QQuickCanvas canvas;
-
- QDeclarativeComponent component(&engine);
- component.loadUrl(source);
- QScopedPointer<QObject> object(component.create());
- QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
- QVERIFY(listView);
- listView->setParentItem(canvas.rootItem());
-
- QQuickItem *contentItem = listView->contentItem();
- QVERIFY(contentItem);
-
- QObject *visualModel = evaluate<QObject *>(listView, "model");
- QVERIFY(visualModel);
-
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
-
- evaluate<void>(visualModel, expression);
- QCOMPARE(evaluate<int>(listView, "count"), count);
-}
-
-
-QTEST_MAIN(tst_qquickvisualdatamodel)
-
-#include "tst_qquickvisualdatamodel.moc"
diff --git a/tests/auto/qtquick2/qtquick2.pro b/tests/auto/qtquick2/qtquick2.pro
deleted file mode 100644
index 9034cb445a..0000000000
--- a/tests/auto/qtquick2/qtquick2.pro
+++ /dev/null
@@ -1,71 +0,0 @@
-TEMPLATE = subdirs
-
-PUBLICTESTS += \
- examples \
- geometry \
- nodes \
- rendernode \
- qdeclarativepixmapcache
-
-# This test requires the qtconcurrent module
-!contains(QT_CONFIG, concurrent):PUBLICTESTS -= qdeclarativepixmapcache
-
-PRIVATETESTS += \
- qdeclarativeanimations \
- qdeclarativeapplication \
- qdeclarativebehaviors \
- qdeclarativefontloader \
- qdeclarativepath \
- qdeclarativesmoothedanimation \
- qdeclarativespringanimation \
- qdeclarativestyledtext \
- qdeclarativestates \
- qdeclarativesystempalette \
- qdeclarativetimer \
- qdeclarativexmllistmodel
-
-# This test requires the xmlpatterns module
-!contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qdeclarativexmllistmodel
-
-QUICKTESTS = \
- qquickaccessible \
- qquickanchors \
- qquickanimatedimage \
- qquickanimatedsprite \
- qquickborderimage \
- qquickcanvas \
- qquickdrag \
- qquickdroparea \
- qquickflickable \
- qquickflipable \
- qquickfocusscope \
- qquickgridview \
- qquickimage \
- qquickitem \
- qquickitem2 \
- qquickitemlayer \
- qquicklistview \
- qquickloader \
- qquickmousearea \
- qquickmultipointtoucharea \
- qquickpathview \
- qquickpincharea \
- qquickpositioners \
- qquickrepeater \
- qquickshadereffect \
- qquickspritesequence \
- qquicktext \
- qquicktextedit \
- qquicktextinput \
- qquickvisualdatamodel \
- qquickview \
- qquickcanvasitem \
- qquickscreen \
-
-
-SUBDIRS += $$PUBLICTESTS
-
-contains(QT_CONFIG, private_tests) {
- SUBDIRS += $$PRIVATETESTS
- SUBDIRS += $$QUICKTESTS
-}
diff --git a/tests/auto/qtquick2/rendernode/rendernode.pro b/tests/auto/qtquick2/rendernode/rendernode.pro
deleted file mode 100644
index f915a58900..0000000000
--- a/tests/auto/qtquick2/rendernode/rendernode.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_rendernode
-SOURCES += tst_rendernode.cpp
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-include(../../shared/util.pri)
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private testlib
-
-OTHER_FILES += \
- data/RenderOrder.qml \
- data/MessUpState.qml \
diff --git a/tests/auto/qtquick2/rendernode/tst_rendernode.cpp b/tests/auto/qtquick2/rendernode/tst_rendernode.cpp
deleted file mode 100644
index f0e385152e..0000000000
--- a/tests/auto/qtquick2/rendernode/tst_rendernode.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtGui/qopenglcontext.h>
-#include <private/qsgrendernode_p.h>
-
-#include "../../shared/util.h"
-
-class tst_rendernode: public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_rendernode();
-
- QImage runTest(const QString &url)
- {
- QQuickView view;
- view.setSource(QUrl(url));
-
- view.show();
- QTest::qWaitForWindowShown(&view);
-
- return view.grabFrameBuffer();
- }
-
-private slots:
- void renderOrder();
- void messUpState();
-};
-
-class ClearNode : public QSGRenderNode
-{
-public:
- virtual StateFlags changedStates()
- {
- return ColorState;
- }
-
- virtual void render(const RenderState &)
- {
- // If clip has been set, scissoring will make sure the right area is cleared.
- glClearColor(color.redF(), color.greenF(), color.blueF(), 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- }
-
- QColor color;
-};
-
-class ClearItem : public QQuickItem
-{
- Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
-public:
- ClearItem() : m_color(Qt::black)
- {
- setFlag(ItemHasContents, true);
- }
-
- QColor color() const { return m_color; }
- void setColor(const QColor &color)
- {
- if (color == m_color)
- return;
- m_color = color;
- emit colorChanged();
- }
-
-protected:
- virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
- {
- ClearNode *node = static_cast<ClearNode *>(oldNode);
- if (!node)
- node = new ClearNode;
- node->color = m_color;
- return node;
- }
-
-Q_SIGNALS:
- void colorChanged();
-
-private:
- QColor m_color;
-};
-
-class MessUpNode : public QSGRenderNode
-{
-public:
- virtual StateFlags changedStates()
- {
- return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState
- | CullState | ViewportState;
- }
-
- virtual void render(const RenderState &)
- {
- // Don't draw anything, just mess up the state
- glViewport(10, 10, 10, 10);
- glDisable(GL_SCISSOR_TEST);
- glDepthMask(true);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_EQUAL);
-#if defined(QT_OPENGL_ES)
- glClearDepthf(1);
-#else
- glClearDepth(1);
-#endif
- glClearStencil(42);
- glClearColor(1.0f, 0.5f, 1.0f, 0.0f);
- glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- glEnable(GL_SCISSOR_TEST);
- glScissor(190, 190, 10, 10);
- glStencilFunc(GL_EQUAL, 28, 0xff);
- glBlendFunc(GL_ZERO, GL_ZERO);
- GLint frontFace;
- glGetIntegerv(GL_FRONT_FACE, &frontFace);
- glFrontFace(frontFace == GL_CW ? GL_CCW : GL_CW);
- glEnable(GL_CULL_FACE);
- }
-};
-
-class MessUpItem : public QQuickItem
-{
- Q_OBJECT
-public:
- MessUpItem()
- {
- setFlag(ItemHasContents, true);
- }
-
-protected:
- virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
- {
- MessUpNode *node = static_cast<MessUpNode *>(oldNode);
- if (!node)
- node = new MessUpNode;
- return node;
- }
-};
-
-tst_rendernode::tst_rendernode()
-{
- qmlRegisterType<ClearItem>("Test", 1, 0, "ClearItem");
- qmlRegisterType<MessUpItem>("Test", 1, 0, "MessUpItem");
-}
-
-static void fuzzyCompareColor(QRgb x, QRgb y)
-{
- QVERIFY(qAbs(qRed(x) - qRed(y)) < 4);
- QVERIFY(qAbs(qGreen(x) - qGreen(y)) < 4);
- QVERIFY(qAbs(qBlue(x) - qBlue(y)) < 4);
-}
-
-void tst_rendernode::renderOrder()
-{
- QImage fb = runTest(testFile("RenderOrder.qml"));
- int x1 = fb.width() / 8;
- int x2 = fb.width() * 3 / 8;
- int x3 = fb.width() * 5 / 8;
- int x4 = fb.width() * 7 / 8;
- int y1 = fb.height() / 8;
- int y2 = fb.height() * 3 / 8;
- int y3 = fb.height() * 5 / 8;
- int y4 = fb.height() * 7 / 8;
-
- fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00));
- QCOMPARE(fb.pixel(x2, y2), qRgb(0xff, 0xff, 0xff));
- QCOMPARE(fb.pixel(x3, y2), qRgb(0x00, 0x00, 0xff));
- QCOMPARE(fb.pixel(x4, y1), qRgb(0x00, 0x00, 0xff));
- QCOMPARE(fb.pixel(x1, y4), qRgb(0xff, 0x00, 0x00));
- QCOMPARE(fb.pixel(x2, y3), qRgb(0xff, 0xff, 0xff));
- fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff));
- fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f));
-}
-
-void tst_rendernode::messUpState()
-{
- QImage fb = runTest(testFile("MessUpState.qml"));
- int x1 = 0;
- int x2 = fb.width() / 2;
- int x3 = fb.width() - 1;
- int y1 = 0;
- int y2 = fb.height() * 3 / 16;
- int y3 = fb.height() / 2;
- int y4 = fb.height() * 13 / 16;
- int y5 = fb.height() - 1;
-
- QCOMPARE(fb.pixel(x1, y3), qRgb(0xff, 0xff, 0xff));
- QCOMPARE(fb.pixel(x3, y3), qRgb(0xff, 0xff, 0xff));
-
- QCOMPARE(fb.pixel(x2, y1), qRgb(0x00, 0x00, 0x00));
- QCOMPARE(fb.pixel(x2, y2), qRgb(0x00, 0x00, 0x00));
- fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f));
- QCOMPARE(fb.pixel(x2, y4), qRgb(0x00, 0x00, 0x00));
- QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00));
-}
-
-
-QTEST_MAIN(tst_rendernode)
-
-#include "tst_rendernode.moc"
diff --git a/tests/auto/qtquick2/shared/util.pri b/tests/auto/qtquick2/shared/util.pri
deleted file mode 100644
index eddbe4b6aa..0000000000
--- a/tests/auto/qtquick2/shared/util.pri
+++ /dev/null
@@ -1,7 +0,0 @@
-
-HEADERS += $$PWD/visualtestutil.h \
- $$PWD/viewtestutil.h
-SOURCES += $$PWD/visualtestutil.cpp \
- $$PWD/viewtestutil.cpp
-
-DEFINES += QT_DECLARATIVETEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
diff --git a/tests/auto/qtquick2/shared/viewtestutil.cpp b/tests/auto/qtquick2/shared/viewtestutil.cpp
deleted file mode 100644
index eeef23001e..0000000000
--- a/tests/auto/qtquick2/shared/viewtestutil.cpp
+++ /dev/null
@@ -1,493 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "viewtestutil.h"
-
-#include <QtQuick/QQuickView>
-
-#include <QtTest/QTest>
-
-template<typename T>
-static void qdeclarativemodelviewstestutil_move(int from, int to, int n, T *items)
-{
- if (from > to) {
- // Only move forwards - flip if backwards moving
- int tfrom = from;
- int tto = to;
- from = tto;
- to = tto+n;
- n = tfrom-tto;
- }
-
- T replaced;
- int i=0;
- typename T::ConstIterator it=items->begin(); it += from+n;
- for (; i<to-from; ++i,++it)
- replaced.append(*it);
- i=0;
- it=items->begin(); it += from;
- for (; i<n; ++i,++it)
- replaced.append(*it);
- typename T::ConstIterator f=replaced.begin();
- typename T::Iterator t=items->begin(); t += from;
- for (; f != replaced.end(); ++f, ++t)
- *t = *f;
-}
-
-QQuickView *QQuickViewTestUtil::createView()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- return canvas;
-}
-
-void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration)
-{
- const int pointCount = 5;
- QPoint diff = to - from;
-
- // send press, five equally spaced moves, and release.
- QTest::mousePress(canvas, Qt::LeftButton, 0, from);
-
- for (int i = 0; i < pointCount; ++i) {
- QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- QTest::qWait(duration/pointCount);
- QCoreApplication::processEvents();
- }
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, to);
- QTest::qWait(50);
-}
-
-QList<int> QQuickViewTestUtil::adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count)
-{
- QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
- int num = indexes[i];
- if (num >= index) {
- num += count;
- }
- result << num;
- }
- return result;
-}
-
-QList<int> QQuickViewTestUtil::adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count)
-{
- QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
- int num = indexes[i];
- if (from < to) {
- if (num >= from && num < from + count)
- num += (to - from); // target
- else if (num >= from && num < to + count)
- num -= count; // displaced
- } else if (from > to) {
- if (num >= from && num < from + count)
- num -= (from - to); // target
- else if (num >= to && num < from + count)
- num += count; // displaced
- }
- result << num;
- }
- return result;
-}
-
-QList<int> QQuickViewTestUtil::adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count)
-{
- QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
- int num = indexes[i];
- if (num >= index)
- num -= count;
- result << num;
- }
- return result;
-}
-
-
-QQuickViewTestUtil::QmlListModel::QmlListModel(QObject *parent)
- : QListModelInterface(parent)
-{
-}
-
-QQuickViewTestUtil::QmlListModel::~QmlListModel()
-{
-}
-
-QString QQuickViewTestUtil::QmlListModel::name(int index) const
-{
- return list.at(index).first;
-}
-
-QString QQuickViewTestUtil::QmlListModel::number(int index) const
-{
- return list.at(index).second;
-}
-
-int QQuickViewTestUtil::QmlListModel::count() const
-{
- return list.count();
-}
-
-QList<int> QQuickViewTestUtil::QmlListModel::roles() const
-{
- return QList<int>() << Name << Number;
-}
-
-QString QQuickViewTestUtil::QmlListModel::toString(int role) const
-{
- switch (role) {
- case Name:
- return "name";
- case Number:
- return "number";
- default:
- return "";
- }
-}
-
-QVariant QQuickViewTestUtil::QmlListModel::data(int index, int role) const
-{
- if (role==0)
- return list.at(index).first;
- if (role==1)
- return list.at(index).second;
- return QVariant();
-}
-
-QHash<int, QVariant> QQuickViewTestUtil::QmlListModel::data(int index, const QList<int> &roles) const
-{
- QHash<int,QVariant> returnHash;
-
- for (int i = 0; i < roles.size(); ++i) {
- int role = roles.at(i);
- QVariant info;
- switch (role) {
- case Name:
- info = list.at(index).first;
- break;
- case Number:
- info = list.at(index).second;
- break;
- default:
- break;
- }
- returnHash.insert(role, info);
- }
- return returnHash;
-}
-
-void QQuickViewTestUtil::QmlListModel::addItem(const QString &name, const QString &number)
-{
- list.append(QPair<QString,QString>(name, number));
- emit itemsInserted(list.count()-1, 1);
-}
-
-void QQuickViewTestUtil::QmlListModel::insertItem(int index, const QString &name, const QString &number)
-{
- list.insert(index, QPair<QString,QString>(name, number));
- emit itemsInserted(index, 1);
-}
-
-void QQuickViewTestUtil::QmlListModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
-{
- for (int i=0; i<items.count(); i++)
- list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
- emit itemsInserted(index, items.count());
-}
-
-void QQuickViewTestUtil::QmlListModel::removeItem(int index)
-{
- list.removeAt(index);
- emit itemsRemoved(index, 1);
-}
-
-void QQuickViewTestUtil::QmlListModel::removeItems(int index, int count)
-{
- int c = count;
- while (c--)
- list.removeAt(index);
- emit itemsRemoved(index, count);
-}
-
-void QQuickViewTestUtil::QmlListModel::moveItem(int from, int to)
-{
- list.move(from, to);
- emit itemsMoved(from, to, 1);
-}
-
-void QQuickViewTestUtil::QmlListModel::moveItems(int from, int to, int count)
-{
- qdeclarativemodelviewstestutil_move(from, to, count, &list);
- emit itemsMoved(from, to, count);
-}
-
-void QQuickViewTestUtil::QmlListModel::modifyItem(int index, const QString &name, const QString &number)
-{
- list[index] = QPair<QString,QString>(name, number);
- emit itemsChanged(index, 1, roles());
-}
-
-void QQuickViewTestUtil::QmlListModel::clear() {
- int count = list.count();
- list.clear();
- emit itemsRemoved(0, count);
-}
-
-void QQuickViewTestUtil::QmlListModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
- for (int i=0; i<other.count(); i++) {
- QVERIFY2(list.contains(other[i]),
- QTest::toString(other[i].first + " " + other[i].second + " " + error1));
- }
- for (int i=0; i<list.count(); i++) {
- QVERIFY2(other.contains(list[i]),
- QTest::toString(list[i].first + " " + list[i].second + " " + error2));
- }
-}
-
-
-QQuickViewTestUtil::QaimModel::QaimModel(QObject *parent)
- : QAbstractListModel(parent)
-{
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
-}
-
-int QQuickViewTestUtil::QaimModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return list.count();
-}
-
-QVariant QQuickViewTestUtil::QaimModel::data(const QModelIndex &index, int role) const
-{
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
-}
-
-int QQuickViewTestUtil::QaimModel::count() const
-{
- return rowCount();
-}
-
-QString QQuickViewTestUtil::QaimModel::name(int index) const
-{
- return list.at(index).first;
-}
-
-QString QQuickViewTestUtil::QaimModel::number(int index) const
-{
- return list.at(index).second;
-}
-
-void QQuickViewTestUtil::QaimModel::addItem(const QString &name, const QString &number)
-{
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
-}
-
-void QQuickViewTestUtil::QaimModel::addItems(const QList<QPair<QString, QString> > &items)
-{
- emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1);
- for (int i=0; i<items.count(); i++)
- list.append(QPair<QString,QString>(items[i].first, items[i].second));
- emit endInsertRows();
-}
-
-void QQuickViewTestUtil::QaimModel::insertItem(int index, const QString &name, const QString &number)
-{
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
-}
-
-void QQuickViewTestUtil::QaimModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
-{
- emit beginInsertRows(QModelIndex(), index, index+items.count()-1);
- for (int i=0; i<items.count(); i++)
- list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
- emit endInsertRows();
-}
-
-void QQuickViewTestUtil::QaimModel::removeItem(int index)
-{
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::removeItems(int index, int count)
-{
- emit beginRemoveRows(QModelIndex(), index, index+count-1);
- while (count--)
- list.removeAt(index);
- emit endRemoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::moveItem(int from, int to)
-{
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::moveItems(int from, int to, int count)
-{
- emit beginMoveRows(QModelIndex(), from, from+count-1, QModelIndex(), to > from ? to+count : to);
- qdeclarativemodelviewstestutil_move(from, to, count, &list);
- emit endMoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::modifyItem(int idx, const QString &name, const QString &number)
-{
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
-}
-
-void QQuickViewTestUtil::QaimModel::clear()
-{
- int count = list.count();
- emit beginRemoveRows(QModelIndex(), 0, count-1);
- list.clear();
- emit endRemoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::reset()
-{
- emit beginResetModel();
- emit endResetModel();
-}
-
-void QQuickViewTestUtil::QaimModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
- for (int i=0; i<other.count(); i++) {
- QVERIFY2(list.contains(other[i]),
- QTest::toString(other[i].first + " " + other[i].second + " " + error1));
- }
- for (int i=0; i<list.count(); i++) {
- QVERIFY2(other.contains(list[i]),
- QTest::toString(list[i].first + " " + list[i].second + " " + error2));
- }
-}
-
-
-
-QQuickViewTestUtil::ListRange::ListRange()
- : valid(false)
-{
-}
-
-QQuickViewTestUtil::ListRange::ListRange(const ListRange &other)
- : valid(other.valid)
-{
- indexes = other.indexes;
-}
-
-QQuickViewTestUtil::ListRange::ListRange(int start, int end)
- : valid(true)
-{
- for (int i=start; i<=end; i++)
- indexes << i;
-}
-
-QQuickViewTestUtil::ListRange::~ListRange()
-{
-}
-
-QQuickViewTestUtil::ListRange QQuickViewTestUtil::ListRange::operator+(const ListRange &other) const
-{
- if (other == *this)
- return *this;
- ListRange a(*this);
- a.indexes.append(other.indexes);
- return a;
-}
-
-bool QQuickViewTestUtil::ListRange::operator==(const ListRange &other) const
-{
- return indexes.toSet() == other.indexes.toSet();
-}
-
-bool QQuickViewTestUtil::ListRange::operator!=(const ListRange &other) const
-{
- return !(*this == other);
-}
-
-bool QQuickViewTestUtil::ListRange::isValid() const
-{
- return valid;
-}
-
-int QQuickViewTestUtil::ListRange::count() const
-{
- return indexes.count();
-}
-
-QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QmlListModel &model)
-{
- QList<QPair<QString,QString> > data;
- if (!valid)
- return data;
- for (int i=0; i<indexes.count(); i++)
- data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
- return data;
-}
-
-QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QaimModel &model)
-{
- QList<QPair<QString,QString> > data;
- if (!valid)
- return data;
- for (int i=0; i<indexes.count(); i++)
- data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
- return data;
-}
-
diff --git a/tests/auto/qtquick2/shared/viewtestutil.h b/tests/auto/qtquick2/shared/viewtestutil.h
deleted file mode 100644
index 9833fcd5cc..0000000000
--- a/tests/auto/qtquick2/shared/viewtestutil.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKVIEWTESTUTIL_H
-#define QQUICKVIEWTESTUTIL_H
-
-#include <QtQuick/QQuickItem>
-#include <QtDeclarative/QDeclarativeExpression>
-#include <QtDeclarative/private/qlistmodelinterface_p.h>
-#include <QtCore/QAbstractListModel>
-
-QT_FORWARD_DECLARE_CLASS(QQuickView)
-
-namespace QQuickViewTestUtil
-{
- QQuickView *createView();
-
- void flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration);
-
- QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count);
- QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count);
- QList<int> adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count);
-
- struct ListChange {
- enum { Inserted, Removed, Moved, SetCurrent, SetContentY } type;
- int index;
- int count;
- int to; // Move
- qreal pos; // setContentY
-
- static ListChange insert(int index, int count = 1) { ListChange c = { Inserted, index, count, -1, 0.0 }; return c; }
- static ListChange remove(int index, int count = 1) { ListChange c = { Removed, index, count, -1, 0.0 }; return c; }
- static ListChange move(int index, int to, int count) { ListChange c = { Moved, index, count, to, 0.0 }; return c; }
- static ListChange setCurrent(int index) { ListChange c = { SetCurrent, index, -1, -1, 0.0 }; return c; }
- static ListChange setContentY(qreal pos) { ListChange c = { SetContentY, -1, -1, -1, pos }; return c; }
- };
-
- class QmlListModel : public QListModelInterface
- {
- Q_OBJECT
- public:
- QmlListModel(QObject *parent = 0);
- ~QmlListModel();
-
- enum Roles { Name, Number };
-
- QString name(int index) const;
- QString number(int index) const;
-
- int count() const;
-
- QList<int> roles() const;
- QString toString(int role) const;
-
- QVariant data(int index, int role) const;
- QHash<int, QVariant> data(int index, const QList<int> &roles) const;
-
- Q_INVOKABLE void addItem(const QString &name, const QString &number);
- void insertItem(int index, const QString &name, const QString &number);
- void insertItems(int index, const QList<QPair<QString, QString> > &items);
-
- void removeItem(int index);
- void removeItems(int index, int count);
-
- void moveItem(int from, int to);
- void moveItems(int from, int to, int count);
-
- void modifyItem(int index, const QString &name, const QString &number);
-
- void clear();
-
- void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
-
- private:
- QList<QPair<QString,QString> > list;
- };
-
- class QaimModel : public QAbstractListModel
- {
- Q_OBJECT
- public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- QaimModel(QObject *parent=0);
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
-
- int count() const;
- QString name(int index) const;
- QString number(int index) const;
-
- Q_INVOKABLE void addItem(const QString &name, const QString &number);
- void addItems(const QList<QPair<QString, QString> > &items);
- void insertItem(int index, const QString &name, const QString &number);
- void insertItems(int index, const QList<QPair<QString, QString> > &items);
-
- void removeItem(int index);
- void removeItems(int index, int count);
-
- void moveItem(int from, int to);
- void moveItems(int from, int to, int count);
-
- void modifyItem(int idx, const QString &name, const QString &number);
-
- void clear();
- void reset();
-
- void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
-
- private:
- QList<QPair<QString,QString> > list;
- };
-
- class ListRange
- {
- public:
- ListRange();
- ListRange(const ListRange &other);
- ListRange(int start, int end);
-
- ~ListRange();
-
- ListRange operator+(const ListRange &other) const;
- bool operator==(const ListRange &other) const;
- bool operator!=(const ListRange &other) const;
-
- bool isValid() const;
- int count() const;
-
- QList<QPair<QString,QString> > getModelDataValues(const QmlListModel &model);
- QList<QPair<QString,QString> > getModelDataValues(const QaimModel &model);
-
- QList<int> indexes;
- bool valid;
- };
-}
-
-Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*)
-Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange)
-Q_DECLARE_METATYPE(QList<QQuickViewTestUtil::ListChange>)
-Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange)
-
-#endif // QQUICKVIEWTESTUTIL_H
diff --git a/tests/auto/qtquick2/shared/visualtestutil.h b/tests/auto/qtquick2/shared/visualtestutil.h
deleted file mode 100644
index 09bb03c002..0000000000
--- a/tests/auto/qtquick2/shared/visualtestutil.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKVISUALTESTUTIL_H
-#define QQUICKVISUALTESTUTIL_H
-
-#include <QtQuick/QQuickItem>
-#include <QtDeclarative/QDeclarativeExpression>
-
-namespace QQuickVisualTestUtil
-{
- QQuickItem *findVisibleChild(QQuickItem *parent, const QString &objectName);
-
- void dumpTree(QQuickItem *parent, int depth = 0);
-
-
- /*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
- */
- template<typename T>
- T *findItem(QQuickItem *parent, const QString &objectName, int index = -1)
- {
- const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
- if (!item)
- continue;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QDeclarativeExpression e(qmlContext(item), item, "index");
- if (e.evaluate().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
- }
-
- template<typename T>
- QList<T*> findItems(QQuickItem *parent, const QString &objectName, bool visibleOnly = true)
- {
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
- if (!item || (visibleOnly && !item->isVisible()))
- continue;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- items.append(static_cast<T*>(item));
- items += findItems<T>(item, objectName);
- }
-
- return items;
- }
-
- template<typename T>
- QList<T*> findItems(QQuickItem *parent, const QString &objectName, const QList<int> &indexes)
- {
- QList<T*> items;
- for (int i=0; i<indexes.count(); i++)
- items << qobject_cast<QQuickItem*>(findItem<T>(parent, objectName, indexes[i]));
- return items;
- }
-
-}
-
-#endif // QQUICKVISUALTESTUTIL_H
diff --git a/tests/auto/qtquick2/examples/data/dummytest.qml b/tests/auto/quick/examples/data/dummytest.qml
index b20e907f27..b20e907f27 100644
--- a/tests/auto/qtquick2/examples/data/dummytest.qml
+++ b/tests/auto/quick/examples/data/dummytest.qml
diff --git a/tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml b/tests/auto/quick/examples/data/webbrowser/webbrowser.qml
index d31787b939..d31787b939 100644
--- a/tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml
+++ b/tests/auto/quick/examples/data/webbrowser/webbrowser.qml
diff --git a/tests/auto/quick/examples/examples.pro b/tests/auto/quick/examples/examples.pro
new file mode 100644
index 0000000000..e67120d7c2
--- /dev/null
+++ b/tests/auto/quick/examples/examples.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TARGET = tst_examples
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_examples.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+#temporary
+QT += core-private gui-private qml-private quick-private widgets-private v8-private testlib
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
new file mode 100644
index 0000000000..482053e158
--- /dev/null
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -0,0 +1,299 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLibraryInfo>
+#include <QDir>
+#include <QProcess>
+#include <QDebug>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickView>
+#include <QQmlComponent>
+#include <QQmlEngine>
+#include <QQmlError>
+
+static QtMsgHandler testlibMsgHandler = 0;
+void msgHandlerFilter(QtMsgType type, const char *msg)
+{
+ if (type == QtCriticalMsg || type == QtFatalMsg)
+ (*testlibMsgHandler)(type, msg);
+}
+
+class tst_examples : public QObject
+{
+ Q_OBJECT
+public:
+ tst_examples();
+
+private slots:
+ void init();
+ void cleanup();
+
+ void sgexamples_data();
+ void sgexamples();
+ void sgsnippets_data();
+ void sgsnippets();
+
+ void namingConvention();
+private:
+ QStringList excludedDirs;
+ QStringList excludedFiles;
+
+ void namingConvention(const QDir &);
+ QStringList findQmlFiles(const QDir &);
+
+ QQmlEngine engine;
+};
+
+tst_examples::tst_examples()
+{
+ // Add files to exclude here
+ excludedFiles << "doc/src/snippets/qml/listmodel.qml"; //Just a ListModel, no root QQuickItem
+
+ // Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/)
+ excludedDirs << "shared"; //Not an example
+ excludedDirs << "qtquick/text/fonts"; // QTBUG-21415
+ excludedDirs << "doc/src/snippets/qml/path"; //No root QQuickItem
+ excludedDirs << "tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir
+
+ // These snippets are not expected to run on their own.
+ excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qml/qtbinding";
+ excludedDirs << "doc/src/snippets/qml/imports";
+
+#ifdef QT_NO_WEBKIT
+ excludedDirs << "qtquick/modelviews/webview";
+ excludedDirs << "demos/webbrowser";
+ excludedDirs << "doc/src/snippets/qml/webview";
+#endif
+
+#ifdef QT_NO_XMLPATTERNS
+ excludedDirs << "demos/twitter";
+ excludedDirs << "demos/flickr";
+ excludedDirs << "demos/photoviewer";
+#endif
+}
+
+void tst_examples::init()
+{
+ if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets"))
+ testlibMsgHandler = qInstallMsgHandler(msgHandlerFilter);
+}
+
+void tst_examples::cleanup()
+{
+ if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets"))
+ qInstallMsgHandler(testlibMsgHandler);
+}
+
+/*
+This tests that the examples follow the naming convention required
+to have them tested by the examples() test.
+*/
+void tst_examples::namingConvention(const QDir &d)
+{
+ for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ QString s = excludedDirs.at(ii);
+ if (d.absolutePath().endsWith(s))
+ return;
+ }
+
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QDir::Files);
+
+ bool seenQml = !files.isEmpty();
+ bool seenLowercase = false;
+
+ foreach (const QString &file, files) {
+ if (file.at(0).isLower())
+ seenLowercase = true;
+ }
+
+ if (!seenQml) {
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ namingConvention(sub);
+ }
+ } else if(!seenLowercase) {
+ QFAIL(qPrintable(QString(
+ "Directory %1 violates naming convention; expected at least one qml file "
+ "starting with lower case, got: %2"
+ ).arg(d.absolutePath()).arg(files.join(","))));
+ }
+}
+
+void tst_examples::namingConvention()
+{
+ QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
+
+ namingConvention(QDir(examples));
+}
+
+QStringList tst_examples::findQmlFiles(const QDir &d)
+{
+ for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ QString s = excludedDirs.at(ii);
+ if (d.absolutePath().endsWith(s))
+ return QStringList();
+ }
+
+ QStringList rv;
+
+ QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files);
+ if (cppfiles.isEmpty()) {
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ if (file.at(0).isLower()) {
+ bool superContinue = false;
+ for (int ii = 0; ii < excludedFiles.count(); ++ii) {
+ QString e = excludedFiles.at(ii);
+ if (d.absoluteFilePath(file).endsWith(e)) {
+ superContinue = true;
+ break;
+ }
+ }
+ if (superContinue)
+ continue;
+ rv << d.absoluteFilePath(file);
+ }
+ }
+ }
+
+
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ rv << findQmlFiles(sub);
+ }
+
+ return rv;
+}
+
+/*
+This test runs all the examples in the QtQml UI source tree and ensures
+that they start and exit cleanly.
+
+Examples are any .qml files under the examples/ directory that start
+with a lower case letter.
+*/
+void tst_examples::sgexamples_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
+
+ QStringList files;
+ files << findQmlFiles(QDir(examples));
+
+ foreach (const QString &file, files)
+ QTest::newRow(qPrintable(file)) << file;
+}
+
+void tst_examples::sgexamples()
+{
+ QFETCH(QString, file);
+
+ QQmlComponent component(&engine, QUrl::fromLocalFile(file));
+ if (component.status() == QQmlComponent::Error)
+ qWarning() << component.errors();
+ QCOMPARE(component.status(), QQmlComponent::Ready);
+
+ QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
+ QQuickItem *root = qobject_cast<QQuickItem *>(object.data());
+ if (!root)
+ component.completeCreate();
+ QVERIFY(root);
+
+ QQuickCanvas canvas;
+ root->setParentItem(canvas.rootItem());
+ component.completeCreate();
+ canvas.show();
+
+ QTest::qWaitForWindowShown(&canvas);
+
+}
+
+void tst_examples::sgsnippets_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/qml";
+
+ QStringList files;
+ files << findQmlFiles(QDir(snippets));
+
+ foreach (const QString &file, files)
+ QTest::newRow(qPrintable(file)) << file;
+}
+
+void tst_examples::sgsnippets()
+{
+ QFETCH(QString, file);
+
+ QQmlComponent component(&engine, QUrl::fromLocalFile(file));
+ if (component.status() == QQmlComponent::Error)
+ qWarning() << component.errors();
+ QCOMPARE(component.status(), QQmlComponent::Ready);
+
+ QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
+ QQuickItem *root = qobject_cast<QQuickItem *>(object.data());
+ if (!root)
+ component.completeCreate();
+ QVERIFY(root);
+
+ QQuickCanvas canvas;
+ root->setParentItem(canvas.rootItem());
+ component.completeCreate();
+ canvas.show();
+
+ QTest::qWaitForWindowShown(&canvas);
+
+}
+
+QTEST_MAIN(tst_examples)
+
+#include "tst_examples.moc"
diff --git a/tests/auto/quick/geometry/geometry.pro b/tests/auto/quick/geometry/geometry.pro
new file mode 100644
index 0000000000..41fcab7c8f
--- /dev/null
+++ b/tests/auto/quick/geometry/geometry.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_geometry
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_geometry.cpp
+
+CONFIG+=parallel_test
+
+QT += core-private gui-private qml-private quick-private opengl testlib
diff --git a/tests/auto/qtquick2/geometry/tst_geometry.cpp b/tests/auto/quick/geometry/tst_geometry.cpp
index 8d8f45b8cb..8d8f45b8cb 100644
--- a/tests/auto/qtquick2/geometry/tst_geometry.cpp
+++ b/tests/auto/quick/geometry/tst_geometry.cpp
diff --git a/tests/auto/quick/nodes/nodes.pro b/tests/auto/quick/nodes/nodes.pro
new file mode 100644
index 0000000000..51e3e2a156
--- /dev/null
+++ b/tests/auto/quick/nodes/nodes.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_nodestest
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_nodestest.cpp
+
+CONFIG+=parallel_test
+
+QT += core-private gui-private qml-private quick-private opengl widgets testlib
diff --git a/tests/auto/qtquick2/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp
index 6a6de625d5..6a6de625d5 100644
--- a/tests/auto/qtquick2/nodes/tst_nodestest.cpp
+++ b/tests/auto/quick/nodes/tst_nodestest.cpp
diff --git a/tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml
index 22cdad1377..22cdad1377 100644
--- a/tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml
+++ b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml
diff --git a/tests/auto/quick/qquickaccessible/data/hittest.qml b/tests/auto/quick/qquickaccessible/data/hittest.qml
new file mode 100644
index 0000000000..e8003e648a
--- /dev/null
+++ b/tests/auto/quick/qquickaccessible/data/hittest.qml
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+import QtQuick 2.0
+import "widgets"
+
+Rectangle {
+ id: page
+ width: 640
+ height: 480
+ color: "white"
+ Rectangle {
+ id: header
+ color: "#c0c0c0"
+ height: usage.height + chkClip.height
+ anchors.left: parent.left
+ anchors.right: parent.right
+ Text {
+ id: usage
+ text: "Use an a11y inspect tool to see if all visible rectangles can be found with hit testing."
+ }
+ Rectangle {
+ id: chkClip
+ property bool checked: true
+
+ color: (checked ? "#f0f0f0" : "#c0c0c0")
+ height: label.height
+ width: label.width
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: chkClip.checked = !chkClip.checked
+ }
+ Text {
+ id: label
+ text: "Click here to toggle clipping"
+ }
+ }
+ }
+ TextRect {
+ clip: chkClip.checked
+ z: 2
+ id: rect1
+ text: "rect1"
+ width: 100
+ height: 100
+ color: "#ffc0c0"
+ anchors.top: header.bottom
+ TextRect {
+ id: rect10
+ text: "rect10"
+ width: 100
+ height: 100
+ x: 50
+ y: 50
+ color: "#ffa0a0"
+ TextRect {
+ id: rect100
+ text: "rect100"
+ width: 100
+ height: 100
+ x: 80
+ y: 80
+ color: "#ff8080"
+ }
+ TextRect {
+ id: rect101
+ text: "rect101"
+ x: 100
+ y: 70
+ z: 3
+ width: 100
+ height: 100
+ color: "#e06060"
+ }
+ TextRect {
+ id: rect102
+ text: "rect102"
+ width: 100
+ height: 100
+ x: 150
+ y: 60
+ color: "#c04040"
+ }
+ }
+ }
+
+ TextRect {
+ x: 0
+ y: 50
+ id: rect2
+ text: "rect2"
+ width: 100
+ height: 100
+ color: "#c0c0ff"
+ TextRect {
+ id: rect20
+ text: "rect20"
+ width: 100
+ height: 100
+ x: 50
+ y: 50
+ color: "#a0a0ff"
+ TextRect {
+ id: rect200
+ text: "rect200"
+ width: 100
+ height: 100
+ x: 80
+ y: 80
+ color: "#8080ff"
+ }
+ TextRect {
+ id: rect201
+ text: "rect201"
+ x: 100
+ y: 70
+ z: 100
+ width: 100
+ height: 100
+ color: "#6060e0"
+ }
+ TextRect {
+ id: rect202
+ text: "rect202"
+ width: 100
+ height: 100
+ x: 150
+ y: 60
+ color: "#4040c0"
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml b/tests/auto/quick/qquickaccessible/data/pushbutton.qml
index df19231703..df19231703 100644
--- a/tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml
+++ b/tests/auto/quick/qquickaccessible/data/pushbutton.qml
diff --git a/tests/auto/qtquick2/qquickaccessible/data/statictext.qml b/tests/auto/quick/qquickaccessible/data/statictext.qml
index a0821cfc4d..a0821cfc4d 100644
--- a/tests/auto/qtquick2/qquickaccessible/data/statictext.qml
+++ b/tests/auto/quick/qquickaccessible/data/statictext.qml
diff --git a/tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml b/tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml
index 937686974b..937686974b 100644
--- a/tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml
+++ b/tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml
diff --git a/tests/auto/quick/qquickaccessible/qquickaccessible.pro b/tests/auto/quick/qquickaccessible/qquickaccessible.pro
new file mode 100644
index 0000000000..ca50f5d8af
--- /dev/null
+++ b/tests/auto/quick/qquickaccessible/qquickaccessible.pro
@@ -0,0 +1,25 @@
+CONFIG += testcase
+
+TARGET = tst_qquickaccessible
+QT += qml-private network quick-private testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickaccessible.cpp
+
+include (../../shared/util.pri)
+
+OTHER_FILES += data/checkbuttons.qml
+OTHER_FILES += data/hittest.qml
+OTHER_FILES += data/pushbutton.qml
+OTHER_FILES += data/statictext.qml
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
+wince*: {
+ accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll
+ accessneeded.path = accessible
+ DEPLOYMENT += accessneeded
+}
+
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
new file mode 100644
index 0000000000..d65666162d
--- /dev/null
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -0,0 +1,410 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include "QtTest/qtestaccessible.h"
+
+#include <QtGui/qaccessible.h>
+
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitem.h>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlproperty.h>
+#include <QtQuick/private/qquickaccessibleattached_p.h>
+
+#include "../../shared/util.h"
+
+
+typedef QSharedPointer<QAccessibleInterface> QAI;
+
+#define EXPECT(cond) \
+ do { \
+ if (!errorAt && !(cond)) { \
+ errorAt = __LINE__; \
+ qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(), #cond); \
+ } \
+ } while (0)
+
+static int verifyHierarchy(QAccessibleInterface *iface)
+{
+ int errorAt = 0;
+ static int treelevel = 0; // for error diagnostics
+ QAccessibleInterface *middleChild, *if2;
+ middleChild = 0;
+ ++treelevel;
+ int middle = iface->childCount()/2 + 1;
+ if (iface->childCount() >= 2) {
+ middleChild = iface->child(middle - 1);
+ }
+ for (int i = 0; i < iface->childCount() && !errorAt; ++i) {
+ if2 = iface->child(i);
+ EXPECT(if2 != 0);
+ // navigate Ancestor...
+ QAccessibleInterface *parent = if2->parent();
+ EXPECT(iface->object() == parent->object());
+ delete parent;
+
+ // verify children...
+ if (!errorAt)
+ errorAt = verifyHierarchy(if2);
+ delete if2;
+ }
+ delete middleChild;
+
+ --treelevel;
+ return errorAt;
+}
+
+
+//TESTED_FILES=
+
+class tst_QQuickAccessible : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickAccessible();
+ virtual ~tst_QQuickAccessible();
+
+private slots:
+ void commonTests_data();
+ void commonTests();
+
+ void quickAttachedProperties();
+ void basicPropertiesTest();
+ void hitTest();
+ void checkableTest();
+};
+
+tst_QQuickAccessible::tst_QQuickAccessible()
+{
+
+}
+
+tst_QQuickAccessible::~tst_QQuickAccessible()
+{
+
+}
+
+void tst_QQuickAccessible::commonTests_data()
+{
+ QTest::addColumn<QString>("accessibleRoleFileName");
+
+ QTest::newRow("StaticText") << SRCDIR "/data/statictext.qml";
+ QTest::newRow("PushButton") << SRCDIR "/data/pushbutton.qml";
+}
+
+void tst_QQuickAccessible::commonTests()
+{
+ QFETCH(QString, accessibleRoleFileName);
+
+ qDebug() << "testing" << accessibleRoleFileName;
+
+ QQuickView *view = new QQuickView();
+// view->setFixedSize(240,320);
+ view->setSource(QUrl::fromLocalFile(accessibleRoleFileName));
+ view->show();
+// view->setFocus();
+ QVERIFY(view->rootObject() != 0);
+
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(view);
+ QVERIFY(iface);
+
+ delete iface;
+ delete view;
+}
+
+
+
+QString eventName(const int ev)
+{
+ switch (ev) {
+ case 0x0001: return "SoundPlayed";
+ case 0x0002: return "Alert";
+ case 0x0003: return "ForegroundChanged";
+ case 0x0004: return "MenuStart";
+ case 0x0005: return "MenuEnd";
+ case 0x0006: return "PopupMenuStart";
+ case 0x0007: return "PopupMenuEnd";
+ case 0x000C: return "ContextHelpStart";
+ case 0x000D: return "ContextHelpEnd";
+ case 0x000E: return "DragDropStart";
+ case 0x000F: return "DragDropEnd";
+ case 0x0010: return "DialogStart";
+ case 0x0011: return "DialogEnd";
+ case 0x0012: return "ScrollingStart";
+ case 0x0013: return "ScrollingEnd";
+ case 0x0018: return "MenuCommand";
+ case 0x8000: return "ObjectCreated";
+ case 0x8001: return "ObjectDestroyed";
+ case 0x8002: return "ObjectShow";
+ case 0x8003: return "ObjectHide";
+ case 0x8004: return "ObjectReorder";
+ case 0x8005: return "Focus";
+ case 0x8006: return "Selection";
+ case 0x8007: return "SelectionAdd";
+ case 0x8008: return "SelectionRemove";
+ case 0x8009: return "SelectionWithin";
+ case 0x800A: return "StateChanged";
+ case 0x800B: return "LocationChanged";
+ case 0x800C: return "NameChanged";
+ case 0x800D: return "DescriptionChanged";
+ case 0x800E: return "ValueChanged";
+ case 0x800F: return "ParentChanged";
+ case 0x80A0: return "HelpChanged";
+ case 0x80B0: return "DefaultActionChanged";
+ case 0x80C0: return "AcceleratorChanged";
+ default: return "Unknown Event";
+ }
+}
+
+void tst_QQuickAccessible::quickAttachedProperties()
+{
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem {\n"
+ "}", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ QCOMPARE(attachedObject, static_cast<QObject*>(0));
+ delete object;
+ }
+
+ // Attached property
+ {
+ QObject parent;
+ QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent);
+
+ attachedObj->name();
+
+ QVariant pp = attachedObj->property("name");
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem {\n"
+ "Accessible.role: Accessible.Button\n"
+ "}", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ QVERIFY(attachedObject);
+ if (attachedObject) {
+ QVariant p = attachedObject->property("role");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toInt(), int(QAccessible::PushButton));
+ p = attachedObject->property("name");
+ QCOMPARE(p.isNull(), true);
+ p = attachedObject->property("description");
+ QCOMPARE(p.isNull(), true);
+ }
+ delete object;
+ }
+
+ // Attached property
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem {\n"
+ "Accessible.role: Accessible.Button\n"
+ "Accessible.name: \"Donald\"\n"
+ "Accessible.description: \"Duck\"\n"
+ "}", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ QVERIFY(attachedObject);
+ if (attachedObject) {
+ QVariant p = attachedObject->property("role");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toInt(), int(QAccessible::PushButton));
+ p = attachedObject->property("name");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toString(), QLatin1String("Donald"));
+ p = attachedObject->property("description");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toString(), QLatin1String("Duck"));
+ }
+ delete object;
+ }
+}
+
+
+void tst_QQuickAccessible::basicPropertiesTest()
+{
+ QAI app = QAI(QAccessible::queryAccessibleInterface(qApp));
+ QCOMPARE(app->childCount(), 0);
+
+ QQuickView *canvas = new QQuickView();
+ canvas->setSource(testFileUrl("statictext.qml"));
+ canvas->show();
+ QCOMPARE(app->childCount(), 1);
+
+ QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
+ QVERIFY(iface.data());
+ QCOMPARE(iface->childCount(), 1);
+
+ QAI item = QAI(iface->child(0));
+ QVERIFY(item.data());
+ QCOMPARE(item->childCount(), 2);
+ QCOMPARE(item->rect().size(), QSize(400, 400));
+ QCOMPARE(item->role(), QAccessible::Pane);
+ QCOMPARE(iface->indexOfChild(item.data()), 0);
+
+ QAI text = QAI(item->child(0));
+ QVERIFY(text.data());
+ QCOMPARE(text->childCount(), 0);
+
+ QCOMPARE(text->text(QAccessible::Name), QLatin1String("Hello Accessibility"));
+ QCOMPARE(text->rect().size(), QSize(200, 50));
+ QCOMPARE(text->rect().x(), item->rect().x() + 100);
+ QCOMPARE(text->rect().y(), item->rect().y() + 20);
+ QCOMPARE(text->role(), QAccessible::StaticText);
+ QCOMPARE(item->indexOfChild(text.data()), 0);
+
+ QAI text2 = QAI(item->child(1));
+ QVERIFY(text2.data());
+ QCOMPARE(text2->childCount(), 0);
+
+ QCOMPARE(text2->text(QAccessible::Name), QLatin1String("The Hello 2 accessible text"));
+ QCOMPARE(text2->rect().size(), QSize(100, 40));
+ QCOMPARE(text2->rect().x(), item->rect().x() + 100);
+ QCOMPARE(text2->rect().y(), item->rect().y() + 40);
+ QCOMPARE(text2->role(), QAccessible::StaticText);
+ QCOMPARE(item->indexOfChild(text2.data()), 1);
+
+ QCOMPARE(iface->indexOfChild(text2.data()), -1);
+ QCOMPARE(text2->indexOfChild(item.data()), -1);
+
+ delete canvas;
+}
+
+QAI topLevelChildAt(QAccessibleInterface *iface, int x, int y)
+{
+ QAI child = QAI(iface->childAt(x, y));
+ if (!child)
+ return QAI();
+
+ QAI childOfChild;
+ while (childOfChild = QAI(child->childAt(x, y))) {
+ child = childOfChild;
+ }
+ return child;
+}
+
+void tst_QQuickAccessible::hitTest()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("hittest.qml"));
+ canvas->show();
+
+ QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
+ QVERIFY(iface.data());
+ QAI rootItem = QAI(iface->child(0));
+ QRect rootRect = rootItem->rect();
+
+ // hit the root item
+ QAI itemHit(iface->childAt(rootRect.x() + 200, rootRect.y() + 50));
+ QVERIFY(itemHit);
+ QCOMPARE(rootRect, itemHit->rect());
+
+ // hit rect1
+ QAI rect1(rootItem->child(1));
+ QRect rect1Rect = rect1->rect();
+ itemHit = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10));
+ QVERIFY(itemHit);
+ QCOMPARE(rect1Rect, itemHit->rect());
+ QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect1"));
+
+ // should also work from top level (app)
+ QAI app(QAccessible::queryAccessibleInterface(qApp));
+ QAI itemHit2(topLevelChildAt(app.data(), rect1Rect.x() + 10, rect1Rect.y() + 10));
+ QVERIFY(itemHit2);
+ QCOMPARE(itemHit2->rect(), rect1Rect);
+ QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
+
+ // hit rect201
+ QAI rect2(rootItem->child(2));
+ QAI rect20(rect2->child(1));
+ QAI rect201(rect20->child(2));
+ QVERIFY(rect201);
+
+ QRect rect201Rect = rect201->rect();
+ itemHit = QAI(iface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20));
+ QVERIFY(itemHit);
+ QCOMPARE(itemHit->rect(), rect201Rect);
+ QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect201"));
+
+ delete canvas;
+}
+
+void tst_QQuickAccessible::checkableTest()
+{
+ QQuickView *canvas = new QQuickView();
+ canvas->setSource(testFileUrl("checkbuttons.qml"));
+ canvas->show();
+
+ QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
+ QVERIFY(iface.data());
+ QAI root = QAI(iface->child(0));
+
+ QAI button1 = QAI(root->child(0));
+ QCOMPARE(button1->role(), QAccessible::Button);
+ QVERIFY(!(button1->state().checked));
+ QAI button2 = QAI(root->child(1));
+ QVERIFY(!(button2->state().checked));
+ QAI button3 = QAI(root->child(2));
+ QVERIFY(button3->state().checked);
+
+ QAI checkBox1 = QAI(root->child(3));
+ QCOMPARE(checkBox1->role(), QAccessible::CheckBox);
+ QVERIFY((checkBox1->state().checked));
+ QAI checkBox2 = QAI(root->child(4));
+ QVERIFY(!(checkBox2->state().checked));
+}
+
+QTEST_MAIN(tst_QQuickAccessible)
+
+#include "tst_qquickaccessible.moc"
diff --git a/tests/auto/qtquick2/qquickanchors/data/anchors.qml b/tests/auto/quick/qquickanchors/data/anchors.qml
index 4be49a3468..4be49a3468 100644
--- a/tests/auto/qtquick2/qquickanchors/data/anchors.qml
+++ b/tests/auto/quick/qquickanchors/data/anchors.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/centerin.qml b/tests/auto/quick/qquickanchors/data/centerin.qml
index e6c9179116..e6c9179116 100644
--- a/tests/auto/qtquick2/qquickanchors/data/centerin.qml
+++ b/tests/auto/quick/qquickanchors/data/centerin.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml b/tests/auto/quick/qquickanchors/data/centerinRotation.qml
index 933a25c100..933a25c100 100644
--- a/tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml
+++ b/tests/auto/quick/qquickanchors/data/centerinRotation.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/crash1.qml b/tests/auto/quick/qquickanchors/data/crash1.qml
index 98dd6cfa41..98dd6cfa41 100644
--- a/tests/auto/qtquick2/qquickanchors/data/crash1.qml
+++ b/tests/auto/quick/qquickanchors/data/crash1.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/fill.qml b/tests/auto/quick/qquickanchors/data/fill.qml
index 08db199d7b..08db199d7b 100644
--- a/tests/auto/qtquick2/qquickanchors/data/fill.qml
+++ b/tests/auto/quick/qquickanchors/data/fill.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/hvCenter.qml b/tests/auto/quick/qquickanchors/data/hvCenter.qml
index 6763f8eb75..6763f8eb75 100644
--- a/tests/auto/qtquick2/qquickanchors/data/hvCenter.qml
+++ b/tests/auto/quick/qquickanchors/data/hvCenter.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/loop1.qml b/tests/auto/quick/qquickanchors/data/loop1.qml
index 342b2af052..342b2af052 100644
--- a/tests/auto/qtquick2/qquickanchors/data/loop1.qml
+++ b/tests/auto/quick/qquickanchors/data/loop1.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/loop2.qml b/tests/auto/quick/qquickanchors/data/loop2.qml
index 044152989e..044152989e 100644
--- a/tests/auto/qtquick2/qquickanchors/data/loop2.qml
+++ b/tests/auto/quick/qquickanchors/data/loop2.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/margins.qml b/tests/auto/quick/qquickanchors/data/margins.qml
index 9403f65a61..9403f65a61 100644
--- a/tests/auto/qtquick2/qquickanchors/data/margins.qml
+++ b/tests/auto/quick/qquickanchors/data/margins.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/stretch.qml b/tests/auto/quick/qquickanchors/data/stretch.qml
index 64e23e30b5..64e23e30b5 100644
--- a/tests/auto/qtquick2/qquickanchors/data/stretch.qml
+++ b/tests/auto/quick/qquickanchors/data/stretch.qml
diff --git a/tests/auto/quick/qquickanchors/qquickanchors.pro b/tests/auto/quick/qquickanchors/qquickanchors.pro
new file mode 100644
index 0000000000..30e6e6dcf8
--- /dev/null
+++ b/tests/auto/quick/qquickanchors/qquickanchors.pro
@@ -0,0 +1,16 @@
+TARGET = tst_qquickanchors
+CONFIG += testcase
+SOURCES += tst_qquickanchors.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private v8-private testlib
diff --git a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
new file mode 100644
index 0000000000..dd1f9f77ae
--- /dev/null
+++ b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
@@ -0,0 +1,710 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <private/qquickitem_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickanchors_p_p.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+Q_DECLARE_METATYPE(QQuickAnchors::Anchor)
+Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine)
+
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickanchors : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickanchors() {}
+
+private slots:
+ void basicAnchors();
+ void basicAnchorsRTL();
+ void loops();
+ void illegalSets();
+ void illegalSets_data();
+ void reset();
+ void reset_data();
+ void resetConvenience();
+ void nullItem();
+ void nullItem_data();
+ void crash1();
+ void centerIn();
+ void centerInRTL();
+ void centerInRotation();
+ void hvCenter();
+ void hvCenterRTL();
+ void fill();
+ void fillRTL();
+ void margins();
+ void marginsRTL();
+ void stretch();
+};
+
+void tst_qquickanchors::basicAnchors()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("anchors.qml"));
+
+ qApp->processEvents();
+
+ //sibling horizontal
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
+
+ //parent horizontal
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
+
+ //vertical
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
+
+ //stretch
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
+
+ //vertical stretch
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
+
+ //more parent horizontal
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
+
+ //centerIn
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
+
+ //margins
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
+
+ // offsets
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
+
+ //baseline
+ QQuickText *text1 = findItem<QQuickText>(view->rootObject(), QLatin1String("text1"));
+ QQuickText *text2 = findItem<QQuickText>(view->rootObject(), QLatin1String("text2"));
+ QCOMPARE(text1->y(), text2->y());
+
+ delete view;
+}
+
+QQuickItem* childItem(QQuickItem *parentItem, const char * itemString) {
+ return findItem<QQuickItem>(parentItem, QLatin1String(itemString));
+}
+
+qreal offsetMasterRTL(QQuickItem *rootItem, const char * itemString) {
+ QQuickItem* masterItem = findItem<QQuickItem>(rootItem, QLatin1String("masterRect"));
+ return masterItem->width()+2*masterItem->x()-findItem<QQuickItem>(rootItem, QLatin1String(itemString))->width();
+}
+
+qreal offsetParentRTL(QQuickItem *rootItem, const char * itemString) {
+ return rootItem->width()+2*rootItem->x()-findItem<QQuickItem>(rootItem, QLatin1String(itemString))->width();
+}
+
+void mirrorAnchors(QQuickItem *item) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->setLayoutMirror(true);
+}
+
+void tst_qquickanchors::basicAnchorsRTL()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("anchors.qml"));
+
+ qApp->processEvents();
+
+ QQuickItem* rootItem = qobject_cast<QQuickItem*>(view->rootObject());
+ foreach (QObject *child, rootItem->children()) {
+ bool mirrored = QQuickItemPrivate::get(qobject_cast<QQuickItem*>(child))->anchors()->property("mirrored").toBool();
+ QCOMPARE(mirrored, false);
+ }
+
+ foreach (QObject *child, rootItem->children())
+ mirrorAnchors(qobject_cast<QQuickItem*>(child));
+
+ foreach (QObject *child, rootItem->children()) {
+ bool mirrored = QQuickItemPrivate::get(qobject_cast<QQuickItem*>(child))->anchors()->property("mirrored").toBool();
+ QCOMPARE(mirrored, true);
+ }
+
+ //sibling horizontal
+ QCOMPARE(childItem(rootItem, "rect1")->x(), offsetMasterRTL(rootItem, "rect1")-26.0);
+ QCOMPARE(childItem(rootItem, "rect2")->x(), offsetMasterRTL(rootItem, "rect2")-122.0);
+ QCOMPARE(childItem(rootItem, "rect3")->x(), offsetMasterRTL(rootItem, "rect3")-74.0);
+ QCOMPARE(childItem(rootItem, "rect4")->x(), offsetMasterRTL(rootItem, "rect4")-16.0);
+ QCOMPARE(childItem(rootItem, "rect5")->x(), offsetMasterRTL(rootItem, "rect5")-112.0);
+ QCOMPARE(childItem(rootItem, "rect6")->x(), offsetMasterRTL(rootItem, "rect6")-64.0);
+
+ //parent horizontal
+ QCOMPARE(childItem(rootItem, "rect7")->x(), offsetParentRTL(rootItem, "rect7")-0.0);
+ QCOMPARE(childItem(rootItem, "rect8")->x(), offsetParentRTL(rootItem, "rect8")-240.0);
+ QCOMPARE(childItem(rootItem, "rect9")->x(), offsetParentRTL(rootItem, "rect9")-120.0);
+ QCOMPARE(childItem(rootItem, "rect10")->x(), offsetParentRTL(rootItem, "rect10")+10.0);
+ QCOMPARE(childItem(rootItem, "rect11")->x(), offsetParentRTL(rootItem, "rect11")-230.0);
+ QCOMPARE(childItem(rootItem, "rect12")->x(), offsetParentRTL(rootItem, "rect12")-110.0);
+
+ //vertical
+ QCOMPARE(childItem(rootItem, "rect13")->y(), 20.0);
+ QCOMPARE(childItem(rootItem, "rect14")->y(), 155.0);
+
+ //stretch
+ QCOMPARE(childItem(rootItem, "rect15")->x(), offsetMasterRTL(rootItem, "rect15")-26.0);
+ QCOMPARE(childItem(rootItem, "rect15")->width(), 96.0);
+ QCOMPARE(childItem(rootItem, "rect16")->x(), offsetMasterRTL(rootItem, "rect16")-26.0);
+ QCOMPARE(childItem(rootItem, "rect16")->width(), 192.0);
+ QCOMPARE(childItem(rootItem, "rect17")->x(), offsetMasterRTL(rootItem, "rect17")+70.0);
+ QCOMPARE(childItem(rootItem, "rect17")->width(), 192.0);
+
+ //vertical stretch
+ QCOMPARE(childItem(rootItem, "rect18")->y(), 20.0);
+ QCOMPARE(childItem(rootItem, "rect18")->height(), 40.0);
+
+ //more parent horizontal
+ QCOMPARE(childItem(rootItem, "rect19")->x(), offsetParentRTL(rootItem, "rect19")-115.0);
+ QCOMPARE(childItem(rootItem, "rect20")->x(), offsetParentRTL(rootItem, "rect20")-235.0);
+ QCOMPARE(childItem(rootItem, "rect21")->x(), offsetParentRTL(rootItem, "rect21")+5.0);
+
+ //centerIn
+ QCOMPARE(childItem(rootItem, "rect22")->x(), offsetMasterRTL(rootItem, "rect22")-69.0);
+ QCOMPARE(childItem(rootItem, "rect22")->y(), 5.0);
+
+ //margins
+ QCOMPARE(childItem(rootItem, "rect23")->x(), offsetMasterRTL(rootItem, "rect23")-31.0);
+ QCOMPARE(childItem(rootItem, "rect23")->y(), 5.0);
+ QCOMPARE(childItem(rootItem, "rect23")->width(), 86.0);
+ QCOMPARE(childItem(rootItem, "rect23")->height(), 10.0);
+
+ // offsets
+ QCOMPARE(childItem(rootItem, "rect24")->x(), offsetMasterRTL(rootItem, "rect24")-26.0);
+ QCOMPARE(childItem(rootItem, "rect25")->y(), 60.0);
+ QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0);
+
+ //baseline
+ QQuickText *text1 = findItem<QQuickText>(rootItem, QLatin1String("text1"));
+ QQuickText *text2 = findItem<QQuickText>(rootItem, QLatin1String("text2"));
+ QCOMPARE(text1->y(), text2->y());
+
+ delete view;
+}
+
+// mostly testing that we don't crash
+void tst_qquickanchors::loops()
+{
+ {
+ QUrl source(testFileUrl("loop1.qml"));
+
+ QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QQuickView *view = new QQuickView;
+ view->setSource(source);
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ {
+ QUrl source(testFileUrl("loop2.qml"));
+
+ QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QQuickView *view = new QQuickView;
+ view->setSource(source);
+ qApp->processEvents();
+
+ delete view;
+ }
+}
+
+void tst_qquickanchors::illegalSets()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, warning);
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
+ if (!component.isReady())
+ qWarning() << "Test errors:" << component.errors();
+ QVERIFY(component.isReady());
+ QObject *o = component.create();
+ delete o;
+}
+
+void tst_qquickanchors::illegalSets_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("warning");
+
+ QTest::newRow("H - too many anchors")
+ << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }"
+ << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors.";
+
+ foreach (const QString &side, QStringList() << "left" << "right") {
+ QTest::newRow("H - anchor to V")
+ << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side)
+ << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge.";
+
+ QTest::newRow("H - anchor to non parent/sibling")
+ << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
+ << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
+
+ QTest::newRow("H - anchor to self")
+ << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
+ << "file::2:1: QML Rectangle: Cannot anchor item to self.";
+ }
+
+
+ QTest::newRow("V - too many anchors")
+ << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }"
+ << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors.";
+
+ QTest::newRow("V - too many anchors with baseline")
+ << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }"
+ << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.";
+
+ foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") {
+
+ QTest::newRow("V - anchor to H")
+ << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side)
+ << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge.";
+
+ QTest::newRow("V - anchor to non parent/sibling")
+ << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
+ << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
+
+ QTest::newRow("V - anchor to self")
+ << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
+ << "file::2:1: QML Rectangle: Cannot anchor item to self.";
+ }
+
+
+ QTest::newRow("centerIn - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
+ << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
+
+
+ QTest::newRow("fill - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }"
+ << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
+}
+
+void tst_qquickanchors::reset()
+{
+ QFETCH(QString, side);
+ QFETCH(QQuickAnchorLine::AnchorLine, anchorLine);
+ QFETCH(QQuickAnchors::Anchor, usedAnchor);
+
+ QQuickItem *baseItem = new QQuickItem;
+
+ QQuickAnchorLine anchor;
+ anchor.item = baseItem;
+ anchor.anchorLine = anchorLine;
+
+ QQuickItem *item = new QQuickItem;
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+
+ const QMetaObject *meta = itemPrivate->anchors()->metaObject();
+ QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
+
+ QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
+ QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true);
+
+ QVERIFY(p.reset(itemPrivate->anchors()));
+ QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false);
+
+ delete item;
+ delete baseItem;
+}
+
+void tst_qquickanchors::reset_data()
+{
+ QTest::addColumn<QString>("side");
+ QTest::addColumn<QQuickAnchorLine::AnchorLine>("anchorLine");
+ QTest::addColumn<QQuickAnchors::Anchor>("usedAnchor");
+
+ QTest::newRow("left") << "left" << QQuickAnchorLine::Left << QQuickAnchors::LeftAnchor;
+ QTest::newRow("top") << "top" << QQuickAnchorLine::Top << QQuickAnchors::TopAnchor;
+ QTest::newRow("right") << "right" << QQuickAnchorLine::Right << QQuickAnchors::RightAnchor;
+ QTest::newRow("bottom") << "bottom" << QQuickAnchorLine::Bottom << QQuickAnchors::BottomAnchor;
+
+ QTest::newRow("hcenter") << "horizontalCenter" << QQuickAnchorLine::HCenter << QQuickAnchors::HCenterAnchor;
+ QTest::newRow("vcenter") << "verticalCenter" << QQuickAnchorLine::VCenter << QQuickAnchors::VCenterAnchor;
+ QTest::newRow("baseline") << "baseline" << QQuickAnchorLine::Baseline << QQuickAnchors::BaselineAnchor;
+}
+
+void tst_qquickanchors::resetConvenience()
+{
+ QQuickItem *baseItem = new QQuickItem;
+ QQuickItem *item = new QQuickItem;
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+
+ //fill
+ itemPrivate->anchors()->setFill(baseItem);
+ QVERIFY(itemPrivate->anchors()->fill() == baseItem);
+ itemPrivate->anchors()->resetFill();
+ QVERIFY(itemPrivate->anchors()->fill() == 0);
+
+ //centerIn
+ itemPrivate->anchors()->setCenterIn(baseItem);
+ QVERIFY(itemPrivate->anchors()->centerIn() == baseItem);
+ itemPrivate->anchors()->resetCenterIn();
+ QVERIFY(itemPrivate->anchors()->centerIn() == 0);
+
+ delete item;
+ delete baseItem;
+}
+
+void tst_qquickanchors::nullItem()
+{
+ QFETCH(QString, side);
+
+ QQuickAnchorLine anchor;
+ QQuickItem *item = new QQuickItem;
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+
+ const QMetaObject *meta = itemPrivate->anchors()->metaObject();
+ QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML Item: Cannot anchor to a null item.");
+ QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
+
+ delete item;
+}
+
+void tst_qquickanchors::nullItem_data()
+{
+ QTest::addColumn<QString>("side");
+
+ QTest::newRow("left") << "left";
+ QTest::newRow("top") << "top";
+ QTest::newRow("right") << "right";
+ QTest::newRow("bottom") << "bottom";
+
+ QTest::newRow("hcenter") << "horizontalCenter";
+ QTest::newRow("vcenter") << "verticalCenter";
+ QTest::newRow("baseline") << "baseline";
+}
+
+//QTBUG-5428
+void tst_qquickanchors::crash1()
+{
+ QUrl source(testFileUrl("crash1.qml"));
+
+ QQuickView *view = new QQuickView(source);
+ qApp->processEvents();
+
+ delete view;
+}
+
+void tst_qquickanchors::fill()
+{
+ QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 30.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 40.0);
+ QCOMPARE(rect->x(), 0.0 + 10.0);
+ QCOMPARE(rect->y(), 0.0 + 30.0);
+ QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
+ //Alter Offsets (tests QTBUG-6631)
+ rectPrivate->anchors()->setLeftMargin(20.0);
+ rectPrivate->anchors()->setRightMargin(0.0);
+ rectPrivate->anchors()->setBottomMargin(0.0);
+ rectPrivate->anchors()->setTopMargin(10.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 0.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 0.0);
+ QCOMPARE(rect->x(), 0.0 + 20.0);
+ QCOMPARE(rect->y(), 0.0 + 10.0);
+ QCOMPARE(rect->width(), 200.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 10.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::fillRTL()
+{
+ QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ mirrorAnchors(rect);
+
+ QCOMPARE(rect->x(), 0.0 + 20.0);
+ QCOMPARE(rect->y(), 0.0 + 30.0);
+ QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
+ //Alter Offsets (tests QTBUG-6631)
+ rectPrivate->anchors()->setLeftMargin(20.0);
+ rectPrivate->anchors()->setRightMargin(0.0);
+ rectPrivate->anchors()->setBottomMargin(0.0);
+ rectPrivate->anchors()->setTopMargin(10.0);
+ QCOMPARE(rect->x(), 0.0 + 0.0);
+ QCOMPARE(rect->y(), 0.0 + 10.0);
+ QCOMPARE(rect->width(), 200.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 10.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::centerIn()
+{
+ QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), 30.0);
+ QCOMPARE(rect->x(), 75.0 + 10);
+ QCOMPARE(rect->y(), 75.0 + 30);
+ //Alter Offsets (tests QTBUG-6631)
+ rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), -20.0);
+ QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), -10.0);
+ QCOMPARE(rect->x(), 75.0 - 20.0);
+ QCOMPARE(rect->y(), 75.0 - 10.0);
+
+ //QTBUG-21730 (use actual center to prevent animation jitter)
+ QQuickRectangle* rect2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered2"));
+ QCOMPARE(rect2->x(), 94.5);
+ QCOMPARE(rect2->y(), 94.5);
+
+ delete view;
+}
+
+void tst_qquickanchors::centerInRTL()
+{
+ QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ mirrorAnchors(rect);
+
+ QCOMPARE(rect->x(), 75.0 - 10);
+ QCOMPARE(rect->y(), 75.0 + 30);
+ //Alter Offsets (tests QTBUG-6631)
+ rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rect->x(), 75.0 + 20.0);
+ QCOMPARE(rect->y(), 75.0 - 10.0);
+
+ delete view;
+}
+
+//QTBUG-12441
+void tst_qquickanchors::centerInRotation()
+{
+ QQuickView *view = new QQuickView(testFileUrl("centerinRotation.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* outer = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("outer"));
+ QQuickRectangle* inner = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("inner"));
+
+ QCOMPARE(outer->x(), qreal(49.5));
+ QCOMPARE(outer->y(), qreal(49.5));
+ QCOMPARE(inner->x(), qreal(25.5));
+ QCOMPARE(inner->y(), qreal(25.5));
+
+ delete view;
+}
+
+void tst_qquickanchors::hvCenter()
+{
+ QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ // test QTBUG-10999
+ QCOMPARE(rect->x(), 10.0);
+ QCOMPARE(rect->y(), 19.0);
+
+ rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(5.0);
+ QCOMPARE(rect->x(), 10.0 - 5.0);
+ QCOMPARE(rect->y(), 19.0 + 5.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::hvCenterRTL()
+{
+ QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ mirrorAnchors(rect);
+
+ // test QTBUG-10999
+ QCOMPARE(rect->x(), 10.0);
+ QCOMPARE(rect->y(), 19.0);
+
+ rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(5.0);
+ QCOMPARE(rect->x(), 10.0 + 5.0);
+ QCOMPARE(rect->y(), 19.0 + 5.0);
+
+ delete view;
+}
+void tst_qquickanchors::margins()
+{
+ QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rectPrivate->anchors()->margins(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 6.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 10.0);
+ QCOMPARE(rect->x(), 5.0);
+ QCOMPARE(rect->y(), 6.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
+ QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
+
+ rectPrivate->anchors()->setTopMargin(0.0);
+ rectPrivate->anchors()->setMargins(20.0);
+
+ QCOMPARE(rectPrivate->anchors()->margins(), 20.0);
+ QEXPECT_FAIL("","QTBUG-24515", Continue);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 0.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0);
+ QCOMPARE(rect->x(), 5.0);
+ QCOMPARE(rect->y(), 20.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::marginsRTL()
+{
+ QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
+
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ mirrorAnchors(rect);
+
+ QCOMPARE(rect->x(), 10.0);
+ QCOMPARE(rect->y(), 6.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
+ QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
+
+ rectPrivate->anchors()->setTopMargin(0.0);
+ rectPrivate->anchors()->setMargins(20.0);
+
+ QCOMPARE(rect->x(), 20.0);
+ QCOMPARE(rect->y(), 20.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::stretch()
+{
+ QQuickView *view = new QQuickView(testFileUrl("stretch.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("stretcher"));
+ QCOMPARE(rect->x(), 160.0);
+ QCOMPARE(rect->y(), 130.0);
+ QCOMPARE(rect->width(), 40.0);
+ QCOMPARE(rect->height(), 100.0);
+
+ QQuickRectangle* rect2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("stretcher2"));
+ QCOMPARE(rect2->y(), 130.0);
+ QCOMPARE(rect2->height(), 100.0);
+
+ delete view;
+}
+
+QTEST_MAIN(tst_qquickanchors)
+
+#include "tst_qquickanchors.moc"
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/colors.gif b/tests/auto/quick/qquickanimatedimage/data/colors.gif
index 1270bfaa79..1270bfaa79 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/colors.gif
+++ b/tests/auto/quick/qquickanimatedimage/data/colors.gif
Binary files differ
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/colors.qml b/tests/auto/quick/qquickanimatedimage/data/colors.qml
index 5ccc0148dd..5ccc0148dd 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/colors.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/colors.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif b/tests/auto/quick/qquickanimatedimage/data/hearts.gif
index cfb55f27f5..cfb55f27f5 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif
+++ b/tests/auto/quick/qquickanimatedimage/data/hearts.gif
Binary files differ
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml b/tests/auto/quick/qquickanimatedimage/data/hearts.qml
index 717bab430b..717bab430b 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/hearts.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/qmldir b/tests/auto/quick/qquickanimatedimage/data/qmldir
index ef7c1f44f3..ef7c1f44f3 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/qmldir
+++ b/tests/auto/quick/qquickanimatedimage/data/qmldir
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml b/tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml
index da77a4063b..da77a4063b 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif b/tests/auto/quick/qquickanimatedimage/data/stickman.gif
index 7c4cd18687..7c4cd18687 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif
+++ b/tests/auto/quick/qquickanimatedimage/data/stickman.gif
Binary files differ
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml b/tests/auto/quick/qquickanimatedimage/data/stickman.qml
index a47924de21..a47924de21 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickman.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml
index 4f823b3d70..4f823b3d70 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml
index ef771ed56f..ef771ed56f 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml
index 1ef1f95165..1ef1f95165 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml
index 0bf80b8972..0bf80b8972 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml
diff --git a/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro b/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro
new file mode 100644
index 0000000000..468a3253f8
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickanimatedimage
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickanimatedimage.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
new file mode 100644
index 0000000000..7775e395cb
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
@@ -0,0 +1,374 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qquickimage_p.h>
+#include <private/qquickanimatedimage_p.h>
+#include <QSignalSpy>
+#include <QtQml/qqmlcontext.h>
+
+#include "../../shared/testhttpserver.h"
+#include "../../shared/util.h"
+
+Q_DECLARE_METATYPE(QQuickImageBase::Status)
+
+class tst_qquickanimatedimage : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickanimatedimage() {}
+
+private slots:
+ void play();
+ void pause();
+ void stopped();
+ void setFrame();
+ void frameCount();
+ void mirror_running();
+ void mirror_notRunning();
+ void mirror_notRunning_data();
+ void remote();
+ void remote_data();
+ void sourceSize();
+ void sourceSizeReadOnly();
+ void invalidSource();
+ void qtbug_16520();
+ void progressAndStatusChanges();
+
+};
+
+void tst_qquickanimatedimage::play()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickman.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::pause()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanpause.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QVERIFY(anim->isPaused());
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::stopped()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanstopped.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(!anim->isPlaying());
+ QCOMPARE(anim->currentFrame(), 0);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::setFrame()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanpause.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QCOMPARE(anim->currentFrame(), 2);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::frameCount()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("colors.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QCOMPARE(anim->frameCount(), 3);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::mirror_running()
+{
+ // test where mirror is set to true after animation has started
+
+ QQuickView canvas;
+ canvas.show();
+
+ canvas.setSource(testFileUrl("hearts.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas.rootObject());
+ QVERIFY(anim);
+
+ int width = anim->property("width").toInt();
+
+ QCOMPARE(anim->currentFrame(), 0);
+ QPixmap frame0 = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ anim->setCurrentFrame(1);
+ QPixmap frame1 = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ anim->setCurrentFrame(0);
+
+ QSignalSpy spy(anim, SIGNAL(frameChanged()));
+ anim->setPlaying(true);
+
+ QTRY_VERIFY(spy.count() == 1); spy.clear();
+ anim->setProperty("mirror", true);
+
+ QCOMPARE(anim->currentFrame(), 1);
+ QPixmap frame1_flipped = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ QTRY_VERIFY(spy.count() == 1); spy.clear();
+ QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first
+ QPixmap frame0_flipped = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
+
+ QTransform transform;
+ transform.translate(width, 0).scale(-1, 1.0);
+ QPixmap frame0_expected = frame0.transformed(transform);
+ QPixmap frame1_expected = frame1.transformed(transform);
+
+ QCOMPARE(frame0_flipped, frame0_expected);
+ QCOMPARE(frame1_flipped, frame1_expected);
+}
+
+void tst_qquickanimatedimage::mirror_notRunning()
+{
+ QFETCH(QUrl, fileUrl);
+
+ QQuickView canvas;
+ canvas.show();
+
+ canvas.setSource(fileUrl);
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas.rootObject());
+ QVERIFY(anim);
+
+ int width = anim->property("width").toInt();
+ QPixmap screenshot = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ QTransform transform;
+ transform.translate(width, 0).scale(-1, 1.0);
+ QPixmap expected = screenshot.transformed(transform);
+
+ int frame = anim->currentFrame();
+ bool playing = anim->isPlaying();
+ bool paused = anim->isPlaying();
+
+ anim->setProperty("mirror", true);
+ screenshot = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
+ QCOMPARE(screenshot, expected);
+
+ // mirroring should not change the current frame or playing status
+ QCOMPARE(anim->currentFrame(), frame);
+ QCOMPARE(anim->isPlaying(), playing);
+ QCOMPARE(anim->isPaused(), paused);
+}
+
+void tst_qquickanimatedimage::mirror_notRunning_data()
+{
+ QTest::addColumn<QUrl>("fileUrl");
+
+ QTest::newRow("paused") << testFileUrl("stickmanpause.qml");
+ QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml");
+}
+
+void tst_qquickanimatedimage::remote()
+{
+ QFETCH(QString, fileName);
+ QFETCH(bool, paused);
+
+ TestHTTPServer server(14449);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
+ QTRY_VERIFY(component.isReady());
+
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ QTRY_VERIFY(anim->isPlaying());
+ if (paused) {
+ QTRY_VERIFY(anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 2);
+ }
+ QVERIFY(anim->status() != QQuickAnimatedImage::Error);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::sourceSize()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanscaled.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QCOMPARE(anim->width(),240.0);
+ QCOMPARE(anim->height(),180.0);
+ QCOMPARE(anim->sourceSize(),QSize(160,120));
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::sourceSizeReadOnly()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanerror1.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property"));
+}
+
+void tst_qquickanimatedimage::remote_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<bool>("paused");
+
+ QTest::newRow("playing") << "stickman.qml" << false;
+ QTest::newRow("paused") << "stickmanpause.qml" << true;
+}
+
+void tst_qquickanimatedimage::invalidSource()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady());
+
+ QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif");
+
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ QVERIFY(!anim->isPlaying());
+ QVERIFY(!anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 0);
+ QCOMPARE(anim->frameCount(), 0);
+ QTRY_VERIFY(anim->status() == 3);
+}
+
+void tst_qquickanimatedimage::qtbug_16520()
+{
+ TestHTTPServer server(14449);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("qtbug-16520.qml"));
+ QTRY_VERIFY(component.isReady());
+
+ QQuickRectangle *root = qobject_cast<QQuickRectangle *>(component.create());
+ QVERIFY(root);
+ QQuickAnimatedImage *anim = root->findChild<QQuickAnimatedImage*>("anim");
+
+ anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif");
+
+ QTRY_VERIFY(anim->opacity() == 0);
+ QTRY_VERIFY(anim->opacity() == 1);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::progressAndStatusChanges()
+{
+ TestHTTPServer server(14449);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+
+ qRegisterMetaType<QQuickImageBase::Status>();
+ QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
+ QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
+ QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
+
+ // Loading local file
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 1);
+ QTRY_COMPARE(progressSpy.count(), 0);
+ QTRY_COMPARE(statusSpy.count(), 0);
+
+ // Loading remote file
+ ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif");
+ QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+ QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 2);
+ QTRY_VERIFY(progressSpy.count() > 1);
+ QTRY_COMPARE(statusSpy.count(), 2);
+
+ ctxt->setContextProperty("srcImage", "");
+ QTRY_VERIFY(obj->status() == QQuickImage::Null);
+ QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_COMPARE(sourceSpy.count(), 3);
+ QTRY_VERIFY(progressSpy.count() > 2);
+ QTRY_COMPARE(statusSpy.count(), 3);
+}
+
+QTEST_MAIN(tst_qquickanimatedimage)
+
+#include "tst_qquickanimatedimage.moc"
diff --git a/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml b/tests/auto/quick/qquickanimatedsprite/data/basic.qml
index 2dd20630d9..2dd20630d9 100644
--- a/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml
+++ b/tests/auto/quick/qquickanimatedsprite/data/basic.qml
diff --git a/tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png b/tests/auto/quick/qquickanimatedsprite/data/squarefacesprite.png
index f9a5d5fcce..f9a5d5fcce 100644
--- a/tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png
+++ b/tests/auto/quick/qquickanimatedsprite/data/squarefacesprite.png
Binary files differ
diff --git a/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro b/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro
new file mode 100644
index 0000000000..3c20ccea66
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickanimatedsprite
+SOURCES += tst_qquickanimatedsprite.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
new file mode 100644
index 0000000000..37625cfed6
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+#include <QtQuick/qquickview.h>
+#include <private/qquickanimatedsprite_p.h>
+
+class tst_qquickanimatedsprite : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickanimatedsprite(){}
+
+private slots:
+ void test_properties();
+};
+
+void tst_qquickanimatedsprite::test_properties()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("basic.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickAnimatedSprite* sprite = canvas->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
+ QVERIFY(sprite);
+
+ QVERIFY(sprite->running());
+ QVERIFY(!sprite->paused());
+ QVERIFY(sprite->interpolate());
+ QCOMPARE(sprite->loops(), 3);
+
+ sprite->setRunning(false);
+ QVERIFY(!sprite->running());
+ sprite->setInterpolate(false);
+ QVERIFY(!sprite->interpolate());
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickanimatedsprite)
+
+#include "tst_qquickanimatedsprite.moc"
diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml b/tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml
index 7c4496b206..7c4496b206 100644
--- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml
+++ b/tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml
diff --git a/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro b/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro
new file mode 100644
index 0000000000..72a09fcb9c
--- /dev/null
+++ b/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro
@@ -0,0 +1,10 @@
+QT += core-private gui-private qml-private
+TEMPLATE=app
+TARGET=tst_qquickanimationcontroller
+
+CONFIG += warn_on qmltestcase
+SOURCES += tst_qquickanimationcontroller.cpp
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
diff --git a/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp b/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp
new file mode 100644
index 0000000000..8c851bcf65
--- /dev/null
+++ b/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(qquickanimationcontroller)
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml b/tests/auto/quick/qquickanimations/data/Double.qml
index 99ffca1d62..99ffca1d62 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml
+++ b/tests/auto/quick/qquickanimations/data/Double.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml b/tests/auto/quick/qquickanimations/data/attached.qml
index 9dcfcd8752..9dcfcd8752 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml
+++ b/tests/auto/quick/qquickanimations/data/attached.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml b/tests/auto/quick/qquickanimations/data/badproperty1.qml
index 9634c2c169..9634c2c169 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml
+++ b/tests/auto/quick/qquickanimations/data/badproperty1.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml b/tests/auto/quick/qquickanimations/data/badproperty2.qml
index c121172a99..c121172a99 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml
+++ b/tests/auto/quick/qquickanimations/data/badproperty2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml b/tests/auto/quick/qquickanimations/data/badtype1.qml
index 43e1ec8572..43e1ec8572 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml
+++ b/tests/auto/quick/qquickanimations/data/badtype1.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml b/tests/auto/quick/qquickanimations/data/badtype2.qml
index 5341cb3d1c..5341cb3d1c 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml
+++ b/tests/auto/quick/qquickanimations/data/badtype2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml b/tests/auto/quick/qquickanimations/data/badtype3.qml
index 182efa0840..182efa0840 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml
+++ b/tests/auto/quick/qquickanimations/data/badtype3.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml b/tests/auto/quick/qquickanimations/data/badtype4.qml
index f091e2430f..f091e2430f 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml
+++ b/tests/auto/quick/qquickanimations/data/badtype4.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml b/tests/auto/quick/qquickanimations/data/disabledTransition.qml
index 0fbafead8b..0fbafead8b 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml
+++ b/tests/auto/quick/qquickanimations/data/disabledTransition.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/quick/qquickanimations/data/dontAutoStart.qml
index c0c0c65e3f..c0c0c65e3f 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml
+++ b/tests/auto/quick/qquickanimations/data/dontAutoStart.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml b/tests/auto/quick/qquickanimations/data/dontStart.qml
index 3eee0cfd35..3eee0cfd35 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml
+++ b/tests/auto/quick/qquickanimations/data/dontStart.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml b/tests/auto/quick/qquickanimations/data/dontStart2.qml
index e7b4164e4e..e7b4164e4e 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml
+++ b/tests/auto/quick/qquickanimations/data/dontStart2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml b/tests/auto/quick/qquickanimations/data/dotproperty.qml
index e0e46dcef5..e0e46dcef5 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml
+++ b/tests/auto/quick/qquickanimations/data/dotproperty.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml b/tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml
index 9ef3da20c0..9ef3da20c0 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml
+++ b/tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml b/tests/auto/quick/qquickanimations/data/looping.qml
index a3d40ae837..a3d40ae837 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml
+++ b/tests/auto/quick/qquickanimations/data/looping.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml b/tests/auto/quick/qquickanimations/data/mixedtype1.qml
index 76129dd15e..76129dd15e 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml
+++ b/tests/auto/quick/qquickanimations/data/mixedtype1.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml b/tests/auto/quick/qquickanimations/data/mixedtype2.qml
index 1a7166e3f3..1a7166e3f3 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml
+++ b/tests/auto/quick/qquickanimations/data/mixedtype2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/quick/qquickanimations/data/nonTransitionBug.qml
index 909c533e7b..909c533e7b 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml
+++ b/tests/auto/quick/qquickanimations/data/nonTransitionBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml b/tests/auto/quick/qquickanimations/data/pathAnimation.qml
index d2006a1c6a..d2006a1c6a 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml
+++ b/tests/auto/quick/qquickanimations/data/pathAnimation.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml b/tests/auto/quick/qquickanimations/data/pathAnimation2.qml
index 2f64dac2cc..2f64dac2cc 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml
+++ b/tests/auto/quick/qquickanimations/data/pathAnimation2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml b/tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml
index be3501fabb..be3501fabb 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml
+++ b/tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml b/tests/auto/quick/qquickanimations/data/pathInterpolator.qml
index 0104412d7c..0104412d7c 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml
+++ b/tests/auto/quick/qquickanimations/data/pathInterpolator.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml
index 41366ef798..41366ef798 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml
+++ b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml
index eb3d4c3f86..eb3d4c3f86 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml
+++ b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml b/tests/auto/quick/qquickanimations/data/pathTransition.qml
index 55ffc33f95..55ffc33f95 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml
+++ b/tests/auto/quick/qquickanimations/data/pathTransition.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml b/tests/auto/quick/qquickanimations/data/pauseBindingBug.qml
index 359cda166f..359cda166f 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml
+++ b/tests/auto/quick/qquickanimations/data/pauseBindingBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml b/tests/auto/quick/qquickanimations/data/pauseBug.qml
index fa2c4be4ba..fa2c4be4ba 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml
+++ b/tests/auto/quick/qquickanimations/data/pauseBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml b/tests/auto/quick/qquickanimations/data/properties.qml
index f0f730967c..f0f730967c 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml
+++ b/tests/auto/quick/qquickanimations/data/properties.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml b/tests/auto/quick/qquickanimations/data/properties2.qml
index 6b7f026e0b..6b7f026e0b 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml
+++ b/tests/auto/quick/qquickanimations/data/properties2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml b/tests/auto/quick/qquickanimations/data/properties3.qml
index 5eb65496d4..5eb65496d4 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml
+++ b/tests/auto/quick/qquickanimations/data/properties3.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml b/tests/auto/quick/qquickanimations/data/properties4.qml
index dfe8ad17e7..dfe8ad17e7 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml
+++ b/tests/auto/quick/qquickanimations/data/properties4.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml b/tests/auto/quick/qquickanimations/data/properties5.qml
index 075fc9bc5a..075fc9bc5a 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml
+++ b/tests/auto/quick/qquickanimations/data/properties5.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition.qml
index 968c5f6285..968c5f6285 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition2.qml
index f06165604a..f06165604a 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition3.qml
index 7d3b3b9c6d..7d3b3b9c6d 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition3.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition4.qml
index 1c31a79634..1c31a79634 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition4.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition5.qml
index a2ff746900..a2ff746900 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition5.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition6.qml
index d3db01efb0..d3db01efb0 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition6.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition7.qml
index 98898de8ef..98898de8ef 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition7.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml b/tests/auto/quick/qquickanimations/data/reanchor.qml
index 241cc81a96..241cc81a96 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml
+++ b/tests/auto/quick/qquickanimations/data/reanchor.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml b/tests/auto/quick/qquickanimations/data/registrationBug.qml
index 633da4e17f..633da4e17f 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml
+++ b/tests/auto/quick/qquickanimations/data/registrationBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml b/tests/auto/quick/qquickanimations/data/reparent.qml
index 39f1e7a6d2..39f1e7a6d2 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml
+++ b/tests/auto/quick/qquickanimations/data/reparent.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml b/tests/auto/quick/qquickanimations/data/rotation.qml
index 4dc42a1bd2..4dc42a1bd2 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml
+++ b/tests/auto/quick/qquickanimations/data/rotation.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/quick/qquickanimations/data/runningTrueBug.qml
index bec6fab368..bec6fab368 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml
+++ b/tests/auto/quick/qquickanimations/data/runningTrueBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml b/tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml
index 508693e0fc..508693e0fc 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml
+++ b/tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml b/tests/auto/quick/qquickanimations/data/valuesource.qml
index 7a636b4003..7a636b4003 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml
+++ b/tests/auto/quick/qquickanimations/data/valuesource.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/quick/qquickanimations/data/valuesource2.qml
index 9788761ee8..9788761ee8 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml
+++ b/tests/auto/quick/qquickanimations/data/valuesource2.qml
diff --git a/tests/auto/quick/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro
new file mode 100644
index 0000000000..0e432ab9f1
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/qquickanimations.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qquickanimations
+SOURCES += tst_qquickanimations.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
+
+# QTBUG-23385 - color mixing tests failing on Ubuntu 11.10 x64
+linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
new file mode 100644
index 0000000000..dd010999b4
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -0,0 +1,1334 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/private/qanimationgroupjob_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquickitemanimation_p.h>
+#include <QtQuick/private/qquickitemanimation_p_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
+#include <QtQuick/private/qquickanimation_p.h>
+#include <QtQuick/private/qquickpathinterpolator_p.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QEasingCurve>
+
+#include <limits.h>
+#include <math.h>
+
+#include "../../shared/util.h"
+
+class tst_qquickanimations : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickanimations() {}
+
+private slots:
+ void initTestCase()
+ {
+ QQmlEngine engine; // ensure types are registered
+ QQmlDataTest::initTestCase();
+ }
+
+ void simpleProperty();
+ void simpleNumber();
+ void simpleColor();
+ void simpleRotation();
+ void simplePath();
+ void simpleAnchor();
+ void reparent();
+ void pathInterpolator();
+ void pathInterpolatorBackwardJump();
+ void pathWithNoStart();
+ void alwaysRunToEnd();
+ void complete();
+ void resume();
+ void dotProperty();
+ void badTypes();
+ void badProperties();
+ void mixedTypes();
+ void properties();
+ void propertiesTransition();
+ void pathTransition();
+ void disabledTransition();
+ void invalidDuration();
+ void attached();
+ void propertyValueSourceDefaultStart();
+ void dontStart();
+ void easingProperties();
+ void rotation();
+ void runningTrueBug();
+ void nonTransitionBug();
+ void registrationBug();
+ void doubleRegistrationBug();
+ void alwaysRunToEndRestartBug();
+ void transitionAssignmentBug();
+ void pauseBindingBug();
+ void pauseBug();
+ void loopingBug();
+ void anchorBug();
+};
+
+#define QTIMED_COMPARE(lhs, rhs) do { \
+ for (int ii = 0; ii < 5; ++ii) { \
+ if (lhs == rhs) \
+ break; \
+ QTest::qWait(50); \
+ } \
+ QCOMPARE(lhs, rhs); \
+} while (false)
+
+void tst_qquickanimations::simpleProperty()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "x");
+ QVERIFY(animation.to().toReal() == 200.0);
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.x(), 200.0);
+
+ rect.setPos(QPointF(0,0));
+ animation.start();
+ QVERIFY(animation.isRunning());
+ animation.pause();
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.x(),100.0);
+}
+
+void tst_qquickanimations::simpleNumber()
+{
+ QQuickRectangle rect;
+ QQuickNumberAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "x");
+ QVERIFY(animation.to() == 200);
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.x(), qreal(200));
+
+ rect.setX(0);
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.x(), qreal(100));
+}
+
+void tst_qquickanimations::simpleColor()
+{
+ QQuickRectangle rect;
+ QQuickColorAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("color");
+ animation.setTo(QColor("red"));
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "color");
+ QVERIFY(animation.to() == QColor("red"));
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.color(), QColor("red"));
+
+ rect.setColor(QColor("blue"));
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
+ QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Abort);
+#endif
+ QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
+
+ rect.setColor(QColor("green"));
+ animation.setFrom(QColor("blue"));
+ QVERIFY(animation.from() == QColor("blue"));
+ animation.restart();
+ QCOMPARE(rect.color(), QColor("blue"));
+ QVERIFY(animation.isRunning());
+ animation.setCurrentTime(125);
+ QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
+}
+
+void tst_qquickanimations::simpleRotation()
+{
+ QQuickRectangle rect;
+ QQuickRotationAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("rotation");
+ animation.setTo(270);
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "rotation");
+ QVERIFY(animation.to() == 270);
+ QVERIFY(animation.direction() == QQuickRotationAnimation::Numerical);
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.rotation(), qreal(270));
+
+ rect.setRotation(0);
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.rotation(), qreal(135));
+}
+
+void tst_qquickanimations::simplePath()
+{
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathAnimation.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(redRect);
+ QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
+ QVERIFY(pathAnim);
+
+ QCOMPARE(pathAnim->duration(), 100);
+ QCOMPARE(pathAnim->target(), redRect);
+
+ pathAnim->start();
+ pathAnim->pause();
+
+ pathAnim->setCurrentTime(30);
+ QCOMPARE(redRect->x(), qreal(167));
+ QCOMPARE(redRect->y(), qreal(104));
+
+ pathAnim->setCurrentTime(100);
+ QCOMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+
+ //verify animation runs to end
+ pathAnim->start();
+ QCOMPARE(redRect->x(), qreal(50));
+ QCOMPARE(redRect->y(), qreal(50));
+ QTRY_COMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+
+ pathAnim->setOrientation(QQuickPathAnimation::RightFirst);
+ QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
+ pathAnim->start();
+ QTRY_VERIFY(redRect->rotation() != 0);
+ pathAnim->stop();
+
+ delete rect;
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathAnimation2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(redRect);
+ QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
+ QVERIFY(pathAnim);
+
+ QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
+ QCOMPARE(pathAnim->endRotation(), qreal(0));
+ QCOMPARE(pathAnim->orientationEntryDuration(), 10);
+ QCOMPARE(pathAnim->orientationExitDuration(), 10);
+
+ pathAnim->start();
+ pathAnim->pause();
+ QCOMPARE(redRect->x(), qreal(50));
+ QCOMPARE(redRect->y(), qreal(50));
+ QCOMPARE(redRect->rotation(), qreal(-360));
+
+ pathAnim->setCurrentTime(50);
+ QCOMPARE(redRect->x(), qreal(175));
+ QCOMPARE(redRect->y(), qreal(175));
+ QCOMPARE(redRect->rotation(), qreal(-315));
+
+ pathAnim->setCurrentTime(100);
+ QCOMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+ QCOMPARE(redRect->rotation(), qreal(0));
+
+ delete rect;
+ }
+}
+
+void tst_qquickanimations::simpleAnchor()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("reanchor.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *greenRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(greenRect);
+
+ QCOMPARE(rect->state(), QLatin1String("reanchored"));
+ QCOMPARE(greenRect->x(), qreal(10));
+ QCOMPARE(greenRect->y(), qreal(0));
+ QCOMPARE(greenRect->width(), qreal(190));
+ QCOMPARE(greenRect->height(), qreal(150));
+
+ rect->setState("");
+
+ //verify animation in progress
+ QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
+ QVERIFY(greenRect->y() > 0 && greenRect->y() < 10);
+ QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
+ QVERIFY(greenRect->height() > 150 && greenRect->height() < 190);
+
+ //verify end state ("")
+ QTRY_COMPARE(greenRect->x(), qreal(0));
+ QCOMPARE(greenRect->y(), qreal(10));
+ QCOMPARE(greenRect->width(), qreal(150));
+ QCOMPARE(greenRect->height(), qreal(190));
+
+ rect->setState("reanchored2");
+
+ //verify animation in progress
+ QTRY_VERIFY(greenRect->y() > 10 && greenRect->y() < 50);
+ QVERIFY(greenRect->height() > 125 && greenRect->height() < 190);
+ //NOTE: setting left/right anchors to undefined removes the anchors, but does not resize.
+ QCOMPARE(greenRect->x(), qreal(0));
+ QCOMPARE(greenRect->width(), qreal(150));
+
+ //verify end state ("reanchored2")
+ QTRY_COMPARE(greenRect->y(), qreal(50));
+ QCOMPARE(greenRect->height(), qreal(125));
+ QCOMPARE(greenRect->x(), qreal(0));
+ QCOMPARE(greenRect->width(), qreal(150));
+
+ rect->setState("reanchored");
+
+ //verify animation in progress
+ QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
+ QVERIFY(greenRect->y() > 0 && greenRect->y() < 50);
+ QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
+ QVERIFY(greenRect->height() > 125 && greenRect->height() < 150);
+
+ //verify end state ("reanchored")
+ QTRY_COMPARE(greenRect->x(), qreal(10));
+ QCOMPARE(greenRect->y(), qreal(0));
+ QCOMPARE(greenRect->width(), qreal(190));
+ QCOMPARE(greenRect->height(), qreal(150));
+
+ rect->setState("reanchored2");
+
+ //verify animation in progress
+ QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
+ QVERIFY(greenRect->y() > 0 && greenRect->y() < 50);
+ QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
+ QVERIFY(greenRect->height() > 125 && greenRect->height() < 150);
+
+ //verify end state ("reanchored2")
+ QTRY_COMPARE(greenRect->x(), qreal(0));
+ QCOMPARE(greenRect->y(), qreal(50));
+ QCOMPARE(greenRect->width(), qreal(150));
+ QCOMPARE(greenRect->height(), qreal(125));
+
+ delete rect;
+}
+
+void tst_qquickanimations::reparent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("reparent.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *target = rect->findChild<QQuickRectangle*>("target");
+ QVERIFY(target);
+
+ QCOMPARE(target->parentItem(), rect);
+ QCOMPARE(target->x(), qreal(0));
+ QCOMPARE(target->y(), qreal(0));
+ QCOMPARE(target->width(), qreal(50));
+ QCOMPARE(target->height(), qreal(50));
+ QCOMPARE(target->rotation(), qreal(0));
+ QCOMPARE(target->scale(), qreal(1));
+
+ rect->setState("state1");
+
+ QQuickRectangle *viaParent = rect->findChild<QQuickRectangle*>("viaParent");
+ QVERIFY(viaParent);
+
+ QQuickRectangle *newParent = rect->findChild<QQuickRectangle*>("newParent");
+ QVERIFY(newParent);
+
+ QTest::qWait(100);
+
+ //animation in progress
+ QTRY_COMPARE(target->parentItem(), viaParent);
+ QVERIFY(target->x() > -100 && target->x() < 50);
+ QVERIFY(target->y() > -100 && target->y() < 50);
+ QVERIFY(target->width() > 50 && target->width() < 100);
+ QCOMPARE(target->height(), qreal(50));
+ QCOMPARE(target->rotation(), qreal(-45));
+ QCOMPARE(target->scale(), qreal(.5));
+
+ //end state
+ QTRY_COMPARE(target->parentItem(), newParent);
+ QCOMPARE(target->x(), qreal(50));
+ QCOMPARE(target->y(), qreal(50));
+ QCOMPARE(target->width(), qreal(100));
+ QCOMPARE(target->height(), qreal(50));
+ QCOMPARE(target->rotation(), qreal(0));
+ QCOMPARE(target->scale(), qreal(1));
+
+ delete rect;
+}
+
+void tst_qquickanimations::pathInterpolator()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathInterpolator.qml"));
+ QQuickPathInterpolator *interpolator = qobject_cast<QQuickPathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(0));
+
+ interpolator->setProgress(.5);
+ QCOMPARE(interpolator->progress(), qreal(.5));
+ QCOMPARE(interpolator->x(), qreal(175));
+ QCOMPARE(interpolator->y(), qreal(175));
+ QCOMPARE(interpolator->angle(), qreal(90));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(300));
+ QCOMPARE(interpolator->y(), qreal(300));
+ QCOMPARE(interpolator->angle(), qreal(0));
+}
+
+void tst_qquickanimations::pathInterpolatorBackwardJump()
+{
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathInterpolatorBack.qml"));
+ QQuickPathInterpolator *interpolator = qobject_cast<QQuickPathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(90));
+
+ interpolator->setProgress(.5);
+ QCOMPARE(interpolator->progress(), qreal(.5));
+ QCOMPARE(interpolator->x(), qreal(100));
+ QCOMPARE(interpolator->y(), qreal(75));
+ QCOMPARE(interpolator->angle(), qreal(270));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(0));
+
+ //make sure we don't get caught in infinite loop here
+ interpolator->setProgress(0);
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(90));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathInterpolatorBack2.qml"));
+ QQuickPathInterpolator *interpolator = qobject_cast<QQuickPathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(280));
+ QCOMPARE(interpolator->angle(), qreal(180));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(0));
+ QCOMPARE(interpolator->y(), qreal(80));
+ QCOMPARE(interpolator->angle(), qreal(180));
+
+ //make sure we don't get caught in infinite loop here
+ interpolator->setProgress(0);
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(280));
+ QCOMPARE(interpolator->angle(), qreal(180));
+ }
+}
+
+void tst_qquickanimations::pathWithNoStart()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathAnimationNoStart.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(redRect);
+ QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
+ QVERIFY(pathAnim);
+
+ pathAnim->start();
+ pathAnim->pause();
+ QCOMPARE(redRect->x(), qreal(50));
+ QCOMPARE(redRect->y(), qreal(50));
+
+ pathAnim->setCurrentTime(50);
+ QCOMPARE(redRect->x(), qreal(175));
+ QCOMPARE(redRect->y(), qreal(175));
+
+ pathAnim->setCurrentTime(100);
+ QCOMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+
+ redRect->setX(100);
+ redRect->setY(100);
+ pathAnim->start();
+ QCOMPARE(redRect->x(), qreal(100));
+ QCOMPARE(redRect->y(), qreal(100));
+ QTRY_COMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+}
+
+void tst_qquickanimations::alwaysRunToEnd()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ animation.setDuration(1000);
+ animation.setLoops(-1);
+ animation.setAlwaysRunToEnd(true);
+ QVERIFY(animation.loops() == -1);
+ QVERIFY(animation.alwaysRunToEnd() == true);
+ animation.start();
+ QTest::qWait(1500);
+ animation.stop();
+ QVERIFY(rect.x() != qreal(200));
+ QTest::qWait(500);
+ QTIMED_COMPARE(rect.x(), qreal(200));
+}
+
+void tst_qquickanimations::complete()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setFrom(1);
+ animation.setTo(200);
+ animation.setDuration(500);
+ QVERIFY(animation.from() == 1);
+ animation.start();
+ QTest::qWait(50);
+ animation.stop();
+ QVERIFY(rect.x() != qreal(200));
+ animation.start();
+ QTest::qWait(50);
+ QVERIFY(animation.isRunning());
+ animation.complete();
+ QCOMPARE(rect.x(), qreal(200));
+}
+
+void tst_qquickanimations::resume()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setFrom(10);
+ animation.setTo(200);
+ animation.setDuration(1000);
+ QVERIFY(animation.from() == 10);
+
+ animation.start();
+ QTest::qWait(400);
+ animation.pause();
+ qreal x = rect.x();
+ QVERIFY(x != qreal(200) && x != qreal(10));
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+
+ animation.resume();
+ QVERIFY(animation.isRunning());
+ QVERIFY(!animation.isPaused());
+ QTest::qWait(400);
+ animation.stop();
+ QVERIFY(rect.x() > x);
+}
+
+void tst_qquickanimations::dotProperty()
+{
+ QQuickRectangle rect;
+ QQuickNumberAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("border.width");
+ animation.setTo(10);
+ animation.start();
+ QTest::qWait(animation.duration()+50);
+ QTIMED_COMPARE(rect.border()->width(), 10.0);
+
+ rect.border()->setWidth(0);
+ animation.start();
+ animation.pause();
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.border()->width(), 5.0);
+}
+
+void tst_qquickanimations::badTypes()
+{
+ //don't crash
+ {
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("badtype1.qml"));
+
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ //make sure we get a compiler error
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("badtype2.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ c.create();
+
+ QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
+ }
+
+ //make sure we get a compiler error
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("badtype3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ c.create();
+
+ QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
+ }
+
+ //don't crash
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("badtype4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QTest::qWait(1000 + 50);
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
+ QVERIFY(myRect);
+ QCOMPARE(myRect->x(),qreal(200));
+ }
+}
+
+void tst_qquickanimations::badProperties()
+{
+ //make sure we get a runtime error
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c1(&engine, testFileUrl("badproperty1.qml"));
+ QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
+ QTest::ignoreMessage(QtWarningMsg, message);
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c1.create());
+ QVERIFY(rect);
+
+ QQmlComponent c2(&engine, testFileUrl("badproperty2.qml"));
+ message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
+ QTest::ignoreMessage(QtWarningMsg, message);
+ rect = qobject_cast<QQuickRectangle*>(c2.create());
+ QVERIFY(rect);
+
+ //### should we warn here are well?
+ //rect->setState("state1");
+ }
+}
+
+//test animating mixed types with property animation in a transition
+//for example, int + real; color + real; etc
+void tst_qquickanimations::mixedTypes()
+{
+ //assumes border.width stays a real -- not real robust
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("mixedtype1.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QTest::qWait(500);
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
+ QVERIFY(myRect);
+
+ //rather inexact -- is there a better way?
+ QVERIFY(myRect->x() > 100 && myRect->x() < 200);
+ QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10);
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("mixedtype2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QTest::qWait(500);
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
+ QVERIFY(myRect);
+
+ //rather inexact -- is there a better way?
+ QVERIFY(myRect->x() > 100 && myRect->x() < 200);
+#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
+ QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Continue);
+#endif
+ QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
+ }
+}
+
+void tst_qquickanimations::properties()
+{
+ const int waitDuration = 300;
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(300));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties5.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ }
+}
+
+void tst_qquickanimations::propertiesTransition()
+{
+ const int waitDuration = 300;
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->y(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->y(),qreal(100));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition5.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ /*{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition6.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }*/
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition7.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+}
+
+void tst_qquickanimations::pathTransition()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathTransition.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("redRect");
+ QVERIFY(myRect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started
+ QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(100)) && qFuzzyCompare(myRect->y(), qreal(700)));
+ QTest::qWait(100);
+
+ QQuickItemPrivate::get(rect)->setState("");
+ QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started
+ QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(500)) && qFuzzyCompare(myRect->y(), qreal(50)));
+}
+
+void tst_qquickanimations::disabledTransition()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("disabledTransition.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+
+ QQuickTransition *trans = rect->findChild<QQuickTransition*>();
+ QVERIFY(trans);
+
+ QCOMPARE(trans->enabled(), false);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+
+ trans->setEnabled(true);
+
+ QQuickItemPrivate::get(rect)->setState("");
+ QCOMPARE(myRect->x(),qreal(200));
+ QTest::qWait(300);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+}
+
+void tst_qquickanimations::invalidDuration()
+{
+ QQuickPropertyAnimation *animation = new QQuickPropertyAnimation;
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PropertyAnimation: Cannot set a duration of < 0");
+ animation->setDuration(-1);
+ QCOMPARE(animation->duration(), 250);
+
+ QQuickPauseAnimation *pauseAnimation = new QQuickPauseAnimation;
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PauseAnimation: Cannot set a duration of < 0");
+ pauseAnimation->setDuration(-1);
+ QCOMPARE(pauseAnimation->duration(), 250);
+}
+
+void tst_qquickanimations::attached()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("attached.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "off");
+ QTest::ignoreMessage(QtDebugMsg, "on");
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+}
+
+void tst_qquickanimations::propertyValueSourceDefaultStart()
+{
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("valuesource.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim);
+ QVERIFY(myAnim->isRunning());
+ }
+
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("valuesource2.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim);
+ QVERIFY(myAnim->isRunning() == false);
+ }
+
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("dontAutoStart.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && !myAnim->qtAnimation());
+ //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ }
+}
+
+
+void tst_qquickanimations::dontStart()
+{
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("dontStart.qml"));
+
+ QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && !myAnim->qtAnimation());
+ //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ }
+
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("dontStart2.qml"));
+
+ QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && !myAnim->qtAnimation());
+ //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ }
+}
+
+void tst_qquickanimations::easingProperties()
+{
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nNumberAnimation { easing.type: \"InOutQuad\" }";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad);
+ }
+
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce);
+ QCOMPARE(animObject->easing().amplitude(), 5.0);
+ }
+
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic);
+ QCOMPARE(animObject->easing().amplitude(), 5.0);
+ QCOMPARE(animObject->easing().period(), 3.0);
+ }
+
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack);
+ QCOMPARE(animObject->easing().overshoot(), 2.0);
+ }
+
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"Bezier\"; easing.bezierCurve: [0.5, 0.2, 0.13, 0.65, 1.0, 1.0] }";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline);
+ QList<QPointF> points = animObject->easing().cubicBezierSpline();
+ QCOMPARE(points.count(), 3);
+ QCOMPARE(points.at(0), QPointF(0.5, 0.2));
+ QCOMPARE(points.at(1), QPointF(0.13, 0.65));
+ QCOMPARE(points.at(2), QPointF(1.0, 1.0));
+ }
+}
+
+void tst_qquickanimations::rotation()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("rotation.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *rr = rect->findChild<QQuickRectangle*>("rr");
+ QQuickRectangle *rr2 = rect->findChild<QQuickRectangle*>("rr2");
+ QQuickRectangle *rr3 = rect->findChild<QQuickRectangle*>("rr3");
+ QQuickRectangle *rr4 = rect->findChild<QQuickRectangle*>("rr4");
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QTest::qWait(800);
+ qreal r1 = rr->rotation();
+ qreal r2 = rr2->rotation();
+ qreal r3 = rr3->rotation();
+ qreal r4 = rr4->rotation();
+
+ QVERIFY(r1 > qreal(0) && r1 < qreal(370));
+ QVERIFY(r2 > qreal(0) && r2 < qreal(370));
+ QVERIFY(r3 < qreal(0) && r3 > qreal(-350));
+ QVERIFY(r4 > qreal(0) && r4 < qreal(10));
+ QCOMPARE(r1,r2);
+ QVERIFY(r4 < r2);
+
+ QTest::qWait(800);
+ QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
+}
+
+void tst_qquickanimations::runningTrueBug()
+{
+ //ensure we start correctly when "running: true" is explicitly set
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("runningTrueBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *cloud = rect->findChild<QQuickRectangle*>("cloud");
+ QVERIFY(cloud);
+ QTest::qWait(1000);
+ QVERIFY(cloud->x() > qreal(0));
+}
+
+//QTBUG-12805
+void tst_qquickanimations::nonTransitionBug()
+{
+ //tests that the animation values from the previous transition are properly cleared
+ //in the case where an animation in the transition doesn't match anything (but previously did)
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("nonTransitionBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("mover");
+
+ mover->setX(100);
+ QCOMPARE(mover->x(), qreal(100));
+
+ rectPrivate->setState("left");
+ QTRY_COMPARE(mover->x(), qreal(0));
+
+ mover->setX(100);
+ QCOMPARE(mover->x(), qreal(100));
+
+ //make sure we don't try to animate back to 0
+ rectPrivate->setState("free");
+ QTest::qWait(300);
+ QCOMPARE(mover->x(), qreal(100));
+}
+
+//QTBUG-14042
+void tst_qquickanimations::registrationBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("registrationBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QTRY_COMPARE(rect->property("value"), QVariant(int(100)));
+}
+
+void tst_qquickanimations::doubleRegistrationBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("doubleRegistrationBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickAbstractAnimation *anim = rect->findChild<QQuickAbstractAnimation*>("animation");
+ QVERIFY(anim != 0);
+ QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
+}
+
+//QTBUG-16736
+void tst_qquickanimations::alwaysRunToEndRestartBug()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ animation.setDuration(1000);
+ animation.setLoops(-1);
+ animation.setAlwaysRunToEnd(true);
+ QVERIFY(animation.loops() == -1);
+ QVERIFY(animation.alwaysRunToEnd() == true);
+ animation.start();
+ animation.stop();
+ animation.start();
+ animation.stop();
+ QTest::qWait(500);
+ QVERIFY(rect.x() != qreal(200));
+ QTest::qWait(800);
+ QTIMED_COMPARE(rect.x(), qreal(200));
+ QCOMPARE(static_cast<QQuickAbstractAnimation*>(&animation)->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
+}
+
+//QTBUG-20227
+void tst_qquickanimations::transitionAssignmentBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("transitionAssignmentBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->property("nullObject").toBool(), false);
+}
+
+//QTBUG-19080
+void tst_qquickanimations::pauseBindingBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("pauseBindingBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickAbstractAnimation *anim = rect->findChild<QQuickAbstractAnimation*>("animation");
+ QVERIFY(anim->qtAnimation()->state() == QAbstractAnimationJob::Paused);
+
+ delete rect;
+}
+
+//QTBUG-13598
+void tst_qquickanimations::pauseBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("pauseBug.qml"));
+ QQuickAbstractAnimation *anim = qobject_cast<QQuickAbstractAnimation*>(c.create());
+ QVERIFY(anim != 0);
+ QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Paused);
+ QCOMPARE(anim->isPaused(), true);
+ QCOMPARE(anim->isRunning(), true);
+
+ delete anim;
+}
+
+//QTBUG-23092
+void tst_qquickanimations::loopingBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("looping.qml"));
+ QObject *obj = c.create();
+
+ QQuickAbstractAnimation *anim = obj->findChild<QQuickAbstractAnimation*>();
+ QVERIFY(anim != 0);
+ QCOMPARE(anim->qtAnimation()->totalDuration(), 300);
+ QCOMPARE(anim->isRunning(), true);
+ QTRY_COMPARE(static_cast<QAnimationGroupJob*>(anim->qtAnimation())->firstChild()->currentLoop(), 2);
+ QTRY_COMPARE(anim->isRunning(), false);
+
+ QQuickRectangle *rect = obj->findChild<QQuickRectangle*>();
+ QVERIFY(rect != 0);
+ QCOMPARE(rect->rotation(), qreal(90));
+
+ delete obj;
+}
+
+//QTBUG-24532
+void tst_qquickanimations::anchorBug()
+{
+ QQuickAnchorAnimation animation;
+ animation.setDuration(5000);
+ animation.setEasing(QEasingCurve(QEasingCurve::InOutBack));
+ animation.start();
+ animation.pause();
+
+ QCOMPARE(animation.qtAnimation()->duration(), 5000);
+ QCOMPARE(static_cast<QQuickBulkValueAnimator*>(animation.qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutBack));
+}
+
+QTEST_MAIN(tst_qquickanimations)
+
+#include "tst_qquickanimations.moc"
diff --git a/tests/auto/quick/qquickapplication/qquickapplication.pro b/tests/auto/quick/qquickapplication/qquickapplication.pro
new file mode 100644
index 0000000000..96cfe82a82
--- /dev/null
+++ b/tests/auto/quick/qquickapplication/qquickapplication.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qquickapplication
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickapplication.cpp
+QT += core-private gui-private qml-private quick-private testlib
+
diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
new file mode 100644
index 0000000000..61675d980d
--- /dev/null
+++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtGui/qinputmethod.h>
+
+class tst_qquickapplication : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qquickapplication();
+
+private slots:
+ void active();
+ void layoutDirection();
+ void inputPanel();
+ void inputMethod();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickapplication::tst_qquickapplication()
+{
+}
+
+void tst_qquickapplication::active()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(item);
+ QQuickView view;
+ item->setParentItem(view.rootObject());
+
+ // not active
+ QVERIFY(!item->property("active").toBool());
+ QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
+
+ // active
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWait(50);
+ QEXPECT_FAIL("", "QTBUG-21573", Abort);
+ QTRY_COMPARE(view.status(), QQuickView::Ready);
+ QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
+
+#if 0
+ // QGuiApplication has no equivalent of setActiveWindow(0). QTBUG-21573
+ // Is this different to clearing the active state of the window or can it be removed?
+ // On Mac, setActiveWindow(0) on mac does not deactivate the current application,
+ // must switch to a different app or hide the current app to trigger this
+ // on mac, setActiveWindow(0) on mac does not deactivate the current application
+ // (you have to switch to a different app or hide the current app to trigger this)
+
+ // not active again
+ QGuiApplication::setActiveWindow(0);
+ QVERIFY(!item->property("active").toBool());
+ QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
+#endif
+
+}
+
+void tst_qquickapplication::layoutDirection()
+{
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(item);
+ QQuickView view;
+ item->setParentItem(view.rootObject());
+
+ // not mirrored
+ QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
+
+ // mirrored
+ QGuiApplication::setLayoutDirection(Qt::RightToLeft);
+ QEXPECT_FAIL("", "QTBUG-21573", Abort);
+ QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft);
+
+ // not mirrored again
+ QGuiApplication::setLayoutDirection(Qt::LeftToRight);
+ QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
+}
+
+void tst_qquickapplication::inputPanel()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { property variant inputPanel: Qt.application.inputPanel }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(item);
+ QQuickView view;
+ item->setParentItem(view.rootObject());
+
+ // check that the inputPanel property maches with application's input panel
+ QCOMPARE(qvariant_cast<QObject*>(item->property("inputPanel")), qApp->inputMethod());
+}
+
+void tst_qquickapplication::inputMethod()
+{
+ // technically not in QQuickApplication, but testing anyway here
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { property variant inputMethod: Qt.inputMethod }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(item);
+ QQuickView view;
+ item->setParentItem(view.rootObject());
+
+ // check that the inputMethod property maches with application's input method
+ QCOMPARE(qvariant_cast<QObject*>(item->property("inputMethod")), qApp->inputMethod());
+}
+
+
+QTEST_MAIN(tst_qquickapplication)
+
+#include "tst_qquickapplication.moc"
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml b/tests/auto/quick/qquickbehaviors/data/binding.qml
index 5aceefa743..5aceefa743 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml
+++ b/tests/auto/quick/qquickbehaviors/data/binding.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml b/tests/auto/quick/qquickbehaviors/data/color.qml
index a318578a9b..a318578a9b 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml
+++ b/tests/auto/quick/qquickbehaviors/data/color.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/quick/qquickbehaviors/data/cpptrigger.qml
index f033ec5aeb..f033ec5aeb 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml
+++ b/tests/auto/quick/qquickbehaviors/data/cpptrigger.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml
index ed35a308f7..ed35a308f7 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml
+++ b/tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml b/tests/auto/quick/qquickbehaviors/data/disabled.qml
index 20860d8dde..20860d8dde 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml
+++ b/tests/auto/quick/qquickbehaviors/data/disabled.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/quick/qquickbehaviors/data/dontStart.qml
index 38e1ea9d9e..38e1ea9d9e 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml
+++ b/tests/auto/quick/qquickbehaviors/data/dontStart.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml b/tests/auto/quick/qquickbehaviors/data/empty.qml
index d8f115390a..d8f115390a 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml
+++ b/tests/auto/quick/qquickbehaviors/data/empty.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml b/tests/auto/quick/qquickbehaviors/data/explicit.qml
index 20875c30e3..20875c30e3 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml
+++ b/tests/auto/quick/qquickbehaviors/data/explicit.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/quick/qquickbehaviors/data/groupProperty.qml
index a05ab7d54b..a05ab7d54b 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml
+++ b/tests/auto/quick/qquickbehaviors/data/groupProperty.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/quick/qquickbehaviors/data/groupProperty2.qml
index 2f3de5131c..2f3de5131c 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml
+++ b/tests/auto/quick/qquickbehaviors/data/groupProperty2.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml
index 6835902bc5..6835902bc5 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml
+++ b/tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml b/tests/auto/quick/qquickbehaviors/data/loop.qml
index 3e8d88734d..3e8d88734d 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml
+++ b/tests/auto/quick/qquickbehaviors/data/loop.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml
index 6357094cfe..6357094cfe 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml
+++ b/tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml b/tests/auto/quick/qquickbehaviors/data/parent.qml
index f8c2731d86..f8c2731d86 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml
+++ b/tests/auto/quick/qquickbehaviors/data/parent.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/quick/qquickbehaviors/data/qtbug12295.qml
index c6bef581a4..c6bef581a4 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml
+++ b/tests/auto/quick/qquickbehaviors/data/qtbug12295.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml
index 5731cb3efd..5731cb3efd 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml
+++ b/tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/quick/qquickbehaviors/data/runningTrue.qml
index 4fd1136f3a..4fd1136f3a 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml
+++ b/tests/auto/quick/qquickbehaviors/data/runningTrue.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/quick/qquickbehaviors/data/scripttrigger.qml
index ff71f2b1b0..ff71f2b1b0 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml
+++ b/tests/auto/quick/qquickbehaviors/data/scripttrigger.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml b/tests/auto/quick/qquickbehaviors/data/simple.qml
index c64a6e1928..c64a6e1928 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml
+++ b/tests/auto/quick/qquickbehaviors/data/simple.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml b/tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml
index fdc3779a5c..fdc3779a5c 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml
+++ b/tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml b/tests/auto/quick/qquickbehaviors/data/startup.qml
index 9fa74ca39e..9fa74ca39e 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml
+++ b/tests/auto/quick/qquickbehaviors/data/startup.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml b/tests/auto/quick/qquickbehaviors/data/startup2.qml
index 0654ef3644..0654ef3644 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml
+++ b/tests/auto/quick/qquickbehaviors/data/startup2.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml b/tests/auto/quick/qquickbehaviors/data/valueType.qml
index 7bc8297dc7..7bc8297dc7 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml
+++ b/tests/auto/quick/qquickbehaviors/data/valueType.qml
diff --git a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro
new file mode 100644
index 0000000000..fc103ed4c2
--- /dev/null
+++ b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickbehaviors
+SOURCES += tst_qquickbehaviors.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
new file mode 100644
index 0000000000..bd17bf4143
--- /dev/null
+++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
@@ -0,0 +1,473 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <qsignalspy.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickbehavior_p.h>
+#include <QtQuick/private/qquickanimation_p.h>
+#include <private/qquickitem_p.h>
+#include "../../shared/util.h"
+
+class tst_qquickbehaviors : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickbehaviors() {}
+
+private slots:
+ void init() { qApp->processEvents(); } //work around animation timer bug (QTBUG-22865)
+ void simpleBehavior();
+ void scriptTriggered();
+ void cppTriggered();
+ void loop();
+ void colorBehavior();
+ void parentBehavior();
+ void replaceBinding();
+ //void transitionOverrides();
+ void group();
+ void valueType();
+ void emptyBehavior();
+ void explicitSelection();
+ void nonSelectingBehavior();
+ void reassignedAnimation();
+ void disabled();
+ void dontStart();
+ void startup();
+ void groupedPropertyCrash();
+ void runningTrue();
+ void sameValue();
+ void delayedRegistration();
+ void startOnCompleted();
+};
+
+void tst_qquickbehaviors::simpleBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("simple.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+ QTRY_VERIFY(qobject_cast<QQuickBehavior*>(rect->findChild<QQuickBehavior*>("MyBehavior"))->animation());
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::scriptTriggered()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("scripttrigger.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ rect->setColor(QColor("red"));
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::cppTriggered()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("cpptrigger.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QTRY_VERIFY(innerRect);
+
+ innerRect->setProperty("x", 200);
+ QTRY_VERIFY(innerRect->x() > 0);
+ QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::loop()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("loop.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ //don't crash
+ QQuickItemPrivate::get(rect)->setState("moved");
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::colorBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("color.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("red");
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("red"));
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("green"));
+ //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::parentBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("parent.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() != rect->findChild<QQuickItem*>("NewParent"));
+ QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() == rect->findChild<QQuickItem*>("NewParent"));
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::replaceBinding()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("binding.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QTRY_VERIFY(innerRect);
+ QTRY_VERIFY(innerRect->x() > 0);
+ QTRY_VERIFY(innerRect->x() < 200);
+ //i.e. the behavior has been triggered
+ QTRY_COMPARE(innerRect->x(), (qreal)200);
+ rect->setProperty("basex", 10);
+ QTRY_COMPARE(innerRect->x(), (qreal)200);
+ rect->setProperty("movedx", 210);
+ QTRY_COMPARE(innerRect->x(), (qreal)210);
+
+ QQuickItemPrivate::get(rect)->setState("");
+ QTRY_VERIFY(innerRect->x() > 10);
+ QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered
+ QTRY_COMPARE(innerRect->x(), (qreal)10);
+ rect->setProperty("movedx", 200);
+ QTRY_COMPARE(innerRect->x(), (qreal)10);
+ rect->setProperty("basex", 20);
+ QTRY_COMPARE(innerRect->x(), (qreal)20);
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::group()
+{
+ /* XXX TODO Create a test element for this case.
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("groupProperty.qml")));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ qDebug() << c.errorString();
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ //QTest::qWait(200);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+ }
+ */
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("groupProperty2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() < 4);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+ }
+}
+
+void tst_qquickbehaviors::valueType()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("valueType.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ //QTBUG-20827
+ QCOMPARE(rect->color(), QColor::fromRgb(255,0,255));
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::emptyBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("empty.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::explicitSelection()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("explicit.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::nonSelectingBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("nonSelecting2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::reassignedAnimation()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("reassignedAnimation.qml"));
+ QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+ QCOMPARE(qobject_cast<QQuickNumberAnimation*>(
+ rect->findChild<QQuickBehavior*>("MyBehavior")->animation())->duration(), 200);
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::disabled()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("disabled.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+ QCOMPARE(rect->findChild<QQuickBehavior*>("MyBehavior")->enabled(), false);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::dontStart()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("dontStart.qml"));
+
+ QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && !myAnim->qtAnimation());
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::startup()
+{
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("startup.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
+ QVERIFY(innerRect);
+
+ QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
+
+ delete rect;
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("startup2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
+ QVERIFY(innerRect);
+
+ QQuickText *text = rect->findChild<QQuickText*>();
+ QVERIFY(text);
+
+ QCOMPARE(innerRect->x(), text->width()); //should be set immediately
+
+ delete rect;
+ }
+}
+
+//QTBUG-10799
+void tst_qquickbehaviors::groupedPropertyCrash()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("groupedPropertyCrash.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect); //don't crash
+
+ delete rect;
+}
+
+//QTBUG-5491
+void tst_qquickbehaviors::runningTrue()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("runningTrue.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *animation = rect->findChild<QQuickAbstractAnimation*>("rotAnim");
+ QVERIFY(animation);
+
+ QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool)));
+ rect->setProperty("myValue", 180);
+ QTRY_VERIFY(runningSpy.count() > 0);
+
+ delete rect;
+}
+
+//QTBUG-12295
+void tst_qquickbehaviors::sameValue()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("qtbug12295.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *target = rect->findChild<QQuickRectangle*>("myRect");
+ QVERIFY(target);
+
+ target->setX(100);
+ QCOMPARE(target->x(), qreal(100));
+
+ 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));
+
+ //this is the main point of the test -- the behavior needs to be triggered again
+ //even though we set 0 twice in a row.
+ target->setProperty("x", 0);
+ QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
+
+ delete rect;
+}
+
+//QTBUG-18362
+void tst_qquickbehaviors::delayedRegistration()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("delayedRegistration.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItem *innerRect = rect->property("myItem").value<QQuickItem*>();
+ QVERIFY(innerRect != 0);
+
+ QCOMPARE(innerRect->property("x").toInt(), int(0));
+
+ QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
+}
+
+//QTBUG-22555
+void tst_qquickbehaviors::startOnCompleted()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("startOnCompleted.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItem *innerRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(innerRect != 0);
+
+ QCOMPARE(innerRect->property("x").toInt(), int(0));
+
+ QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
+
+ delete rect;
+}
+
+QTEST_MAIN(tst_qquickbehaviors)
+
+#include "tst_qquickbehaviors.moc"
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png b/tests/auto/quick/qquickborderimage/data/colors-mirror.png
index e30870dd1e..e30870dd1e 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png
+++ b/tests/auto/quick/qquickborderimage/data/colors-mirror.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci b/tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci
index 294f3cfe48..294f3cfe48 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci
+++ b/tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci b/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci
index c673bed598..c673bed598 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci
+++ b/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round.sci b/tests/auto/quick/qquickborderimage/data/colors-round.sci
index 5d2f49f0e1..5d2f49f0e1 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors-round.sci
+++ b/tests/auto/quick/qquickborderimage/data/colors-round.sci
diff --git a/tests/auto/qtquick2/qquickcanvas/data/colors.png b/tests/auto/quick/qquickborderimage/data/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/colors.png
+++ b/tests/auto/quick/qquickborderimage/data/colors.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickborderimage/data/heart200.png b/tests/auto/quick/qquickborderimage/data/heart200.png
index 5a31ae8f4d..5a31ae8f4d 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/heart200.png
+++ b/tests/auto/quick/qquickborderimage/data/heart200.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickborderimage/data/invalid.sci b/tests/auto/quick/qquickborderimage/data/invalid.sci
index 98c72c9bf1..98c72c9bf1 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/invalid.sci
+++ b/tests/auto/quick/qquickborderimage/data/invalid.sci
diff --git a/tests/auto/qtquick2/qquickborderimage/data/mirror.qml b/tests/auto/quick/qquickborderimage/data/mirror.qml
index abab076e08..abab076e08 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/mirror.qml
+++ b/tests/auto/quick/qquickborderimage/data/mirror.qml
diff --git a/tests/auto/quick/qquickborderimage/qquickborderimage.pro b/tests/auto/quick/qquickborderimage/qquickborderimage.pro
new file mode 100644
index 0000000000..f50149aead
--- /dev/null
+++ b/tests/auto/quick/qquickborderimage/qquickborderimage.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickborderimage
+macx:CONFIG -= app_bundle
+
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickborderimage.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network widgets testlib
diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
new file mode 100644
index 0000000000..13b12f6020
--- /dev/null
+++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
@@ -0,0 +1,373 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+#include <QGraphicsScene>
+#include <QPainter>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qquickborderimage_p.h>
+#include <private/qquickimagebase_p.h>
+#include <private/qquickscalegrid_p_p.h>
+#include <private/qquickloader_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+
+#include "../../shared/testhttpserver.h"
+#include "../../shared/util.h"
+
+#define SERVER_PORT 14446
+#define SERVER_ADDR "http://127.0.0.1:14446"
+
+class tst_qquickborderimage : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_qquickborderimage();
+
+private slots:
+ void noSource();
+ void imageSource();
+ void imageSource_data();
+ void clearSource();
+ void resized();
+ void smooth();
+ void mirror();
+ void tileModes();
+ void sciSource();
+ void sciSource_data();
+ void invalidSciFile();
+ void pendingRemoteRequest();
+ void pendingRemoteRequest_data();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickborderimage::tst_qquickborderimage()
+{
+}
+
+void tst_qquickborderimage::noSource()
+{
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickborderimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("local") << testFileUrl("colors.png").toString() << false << "";
+ QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false
+ << "file::2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString();
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
+ << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
+}
+
+void tst_qquickborderimage::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(QString, error);
+
+ TestHTTPServer *server = 0;
+ if (remote) {
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(dataDirectory());
+ }
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote)
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+
+ if (error.isEmpty()) {
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->sourceSize().width(), 120);
+ QCOMPARE(obj->sourceSize().height(), 120);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+ } else {
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
+ }
+
+ delete obj;
+ delete server;
+}
+
+void tst_qquickborderimage::clearSource()
+{
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QQuickBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+
+ ctxt->setContextProperty("srcImage", "");
+ QVERIFY(obj->source().isEmpty());
+ QVERIFY(obj->status() == QQuickBorderImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+}
+
+void tst_qquickborderimage::resized()
+{
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("colors.png").toString() + "\"; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->sourceSize().width(), 120);
+ QCOMPARE(obj->sourceSize().height(), 120);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickborderimage::smooth()
+{
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->smooth(), true);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickborderimage::mirror()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("mirror.qml"));
+ QQuickBorderImage *image = qobject_cast<QQuickBorderImage*>(canvas->rootObject());
+ QVERIFY(image != 0);
+
+ QImage screenshot = canvas->grabFrameBuffer();
+
+ QImage srcPixmap(screenshot);
+ QTransform transform;
+ transform.translate(image->width(), 0).scale(-1, 1.0);
+ srcPixmap = srcPixmap.transformed(transform);
+
+ image->setProperty("mirror", true);
+ screenshot = canvas->grabFrameBuffer();
+ QCOMPARE(screenshot, srcPixmap);
+
+ delete canvas;
+}
+
+void tst_qquickborderimage::tileModes()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 100.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Repeat);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
+
+ delete obj;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 150.);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Round);
+
+ delete obj;
+ }
+}
+
+void tst_qquickborderimage::sciSource()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, valid);
+
+ bool remote = source.startsWith("http");
+ TestHTTPServer *server = 0;
+ if (remote) {
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(dataDirectory());
+ }
+
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote)
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+
+ if (valid) {
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
+ QCOMPARE(obj->border()->left(), 10);
+ QCOMPARE(obj->border()->top(), 20);
+ QCOMPARE(obj->border()->right(), 30);
+ QCOMPARE(obj->border()->bottom(), 40);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
+ } else {
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
+ }
+
+ delete obj;
+ delete server;
+}
+
+void tst_qquickborderimage::sciSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true;
+ QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true;
+ QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+ QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
+ QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
+}
+
+void tst_qquickborderimage::invalidSciFile()
+{
+ QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun"
+ QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea"
+
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("invalid.sci").toString() +"\"; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->status(), QQuickImageBase::Error);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickborderimage::pendingRemoteRequest()
+{
+ QFETCH(QString, source);
+
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->status(), QQuickBorderImage::Loading);
+
+ // verify no crash
+ // This will cause a delayed "QThread: Destroyed while thread is still running" warning
+ delete obj;
+ QTest::qWait(50);
+}
+
+void tst_qquickborderimage::pendingRemoteRequest_data()
+{
+ QTest::addColumn<QString>("source");
+
+ QTest::newRow("png file") << "http://localhost/none.png";
+ QTest::newRow("sci file") << "http://localhost/none.sci";
+}
+
+QTEST_MAIN(tst_qquickborderimage)
+
+#include "tst_qquickborderimage.moc"
diff --git a/tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml b/tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml
index e95b029210..e95b029210 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml
+++ b/tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml
diff --git a/tests/auto/qtquick2/qquickcanvas/data/Headless.qml b/tests/auto/quick/qquickcanvas/data/Headless.qml
index 2e09cb1f24..2e09cb1f24 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/Headless.qml
+++ b/tests/auto/quick/qquickcanvas/data/Headless.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/colors.png b/tests/auto/quick/qquickcanvas/data/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/qtquick2/qquickimage/data/colors.png
+++ b/tests/auto/quick/qquickcanvas/data/colors.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvas/data/focus.qml b/tests/auto/quick/qquickcanvas/data/focus.qml
index 901f2fcf2e..901f2fcf2e 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/focus.qml
+++ b/tests/auto/quick/qquickcanvas/data/focus.qml
diff --git a/tests/auto/qtquick2/qquickcanvas/data/window.qml b/tests/auto/quick/qquickcanvas/data/window.qml
index d79d5161b5..d79d5161b5 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/window.qml
+++ b/tests/auto/quick/qquickcanvas/data/window.qml
diff --git a/tests/auto/quick/qquickcanvas/qquickcanvas.pro b/tests/auto/quick/qquickcanvas/qquickcanvas.pro
new file mode 100644
index 0000000000..7f27a05243
--- /dev/null
+++ b/tests/auto/quick/qquickcanvas/qquickcanvas.pro
@@ -0,0 +1,20 @@
+CONFIG += testcase
+TARGET = tst_qquickcanvas
+SOURCES += tst_qquickcanvas.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private testlib
+
+testData.files = data
+testData.path = .
+DEPLOYMENT += testData
+
+OTHER_FILES += \
+ data/AnimationsWhileHidden.qml \
+ data/Headless.qml
+
+
diff --git a/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp
new file mode 100644
index 0000000000..3a27d179c5
--- /dev/null
+++ b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp
@@ -0,0 +1,775 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QTouchEvent>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickCanvas>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlComponent>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtGui/QWindowSystemInterface>
+#include "../../shared/util.h"
+#include <QSignalSpy>
+
+struct TouchEventData {
+ QEvent::Type type;
+ QWidget *widget;
+ QWindow *window;
+ Qt::TouchPointStates states;
+ QList<QTouchEvent::TouchPoint> touchPoints;
+};
+
+static QTouchEvent::TouchPoint makeTouchPoint(QQuickItem *item, const QPointF &p, const QPointF &lastPoint = QPointF())
+{
+ QPointF last = lastPoint.isNull() ? p : lastPoint;
+
+ QTouchEvent::TouchPoint tp;
+
+ tp.setPos(p);
+ tp.setLastPos(last);
+ tp.setScenePos(item->mapToScene(p));
+ tp.setLastScenePos(item->mapToScene(last));
+ tp.setScreenPos(item->canvas()->mapToGlobal(tp.scenePos().toPoint()));
+ tp.setLastScreenPos(item->canvas()->mapToGlobal(tp.lastScenePos().toPoint()));
+ return tp;
+}
+
+static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states = 0,
+ const QList<QTouchEvent::TouchPoint>& touchPoints = QList<QTouchEvent::TouchPoint>())
+{
+ TouchEventData d = { type, 0, w, states, touchPoints };
+ return d;
+}
+static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states, const QTouchEvent::TouchPoint &touchPoint)
+{
+ QList<QTouchEvent::TouchPoint> points;
+ points << touchPoint;
+ return makeTouchData(type, w, states, points);
+}
+
+#define COMPARE_TOUCH_POINTS(tp1, tp2) \
+{ \
+ QCOMPARE(tp1.pos(), tp2.pos()); \
+ QCOMPARE(tp1.lastPos(), tp2.lastPos()); \
+ QCOMPARE(tp1.scenePos(), tp2.scenePos()); \
+ QCOMPARE(tp1.lastScenePos(), tp2.lastScenePos()); \
+ QCOMPARE(tp1.screenPos(), tp2.screenPos()); \
+ QCOMPARE(tp1.lastScreenPos(), tp2.lastScreenPos()); \
+}
+
+#define COMPARE_TOUCH_DATA(d1, d2) \
+{ \
+ QCOMPARE((int)d1.type, (int)d2.type); \
+ QCOMPARE(d1.widget, d2.widget); \
+ QCOMPARE((int)d1.states, (int)d2.states); \
+ QCOMPARE(d1.touchPoints.count(), d2.touchPoints.count()); \
+ for (int i=0; i<d1.touchPoints.count(); i++) { \
+ COMPARE_TOUCH_POINTS(d1.touchPoints[i], d2.touchPoints[i]); \
+ } \
+}
+
+class TestTouchItem : public QQuickRectangle
+{
+ Q_OBJECT
+public:
+ TestTouchItem(QQuickItem *parent = 0)
+ : QQuickRectangle(parent), acceptEvents(true), mousePressId(0)
+ {
+ border()->setWidth(1);
+ setAcceptedMouseButtons(Qt::LeftButton);
+ setFiltersChildMouseEvents(true);
+ }
+
+ void reset() {
+ acceptEvents = true;
+ setEnabled(true);
+ setOpacity(1.0);
+
+ lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList<QTouchEvent::TouchPoint>());//CHECK_VALID
+ }
+
+ static void clearMousePressCounter()
+ {
+ mousePressNum = 0;
+ }
+
+ bool acceptEvents;
+ TouchEventData lastEvent;
+ int mousePressId;
+protected:
+ virtual void touchEvent(QTouchEvent *event) {
+ if (!acceptEvents) {
+ event->ignore();
+ return;
+ }
+ lastEvent = makeTouchData(event->type(), event->window(), event->touchPointStates(), event->touchPoints());
+ event->accept();
+ }
+
+ virtual void mousePressEvent(QMouseEvent *) {
+ mousePressId = ++mousePressNum;
+ }
+
+ bool childMouseEventFilter(QQuickItem *, QEvent *event) {
+ if (event->type() == QEvent::MouseButtonPress)
+ mousePressId = ++mousePressNum;
+ return false;
+ }
+
+ static int mousePressNum;
+};
+
+int TestTouchItem::mousePressNum = 0;
+
+class ConstantUpdateItem : public QQuickItem
+{
+Q_OBJECT
+public:
+ ConstantUpdateItem(QQuickItem *parent = 0) : QQuickItem(parent), iterations(0) {setFlag(ItemHasContents);}
+
+ int iterations;
+protected:
+ QSGNode* updatePaintNode(QSGNode *, UpdatePaintNodeData *){
+ iterations++;
+ update();
+ return 0;
+ }
+};
+
+class tst_qquickcanvas : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void initTestCase()
+ {
+ QQmlDataTest::initTestCase();
+ touchDevice = new QTouchDevice();
+ touchDevice->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(touchDevice);
+ }
+
+
+ void constantUpdates();
+ void mouseFiltering();
+ void headless();
+
+ void touchEvent_basic();
+ void touchEvent_propagation();
+ void touchEvent_propagation_data();
+ void touchEvent_cancel();
+
+ void clearCanvas();
+
+ void qmlCreation();
+ void clearColor();
+
+ void grab();
+ void multipleWindows();
+
+ void animationsWhileHidden();
+
+ void focusObject();
+
+ void ignoreUnhandledMouseEvents();
+
+private:
+ QTouchDevice *touchDevice;
+};
+
+//If the item calls update inside updatePaintNode, it should schedule another update
+void tst_qquickcanvas::constantUpdates()
+{
+ QQuickCanvas canvas;
+ canvas.resize(250, 250);
+ ConstantUpdateItem item(canvas.rootItem());
+ canvas.show();
+ QTRY_VERIFY(item.iterations > 60);
+}
+
+void tst_qquickcanvas::touchEvent_basic()
+{
+ TestTouchItem::clearMousePressCounter();
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->show();
+
+ TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
+ bottomItem->setObjectName("Bottom Item");
+ bottomItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *middleItem = new TestTouchItem(bottomItem);
+ middleItem->setObjectName("Middle Item");
+ middleItem->setPos(QPointF(50, 50));
+ middleItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *topItem = new TestTouchItem(middleItem);
+ topItem->setObjectName("Top Item");
+ topItem->setPos(QPointF(50, 50));
+ topItem->setSize(QSizeF(150, 150));
+
+ QPointF pos(10, 10);
+
+ // press single point
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas);
+ QTest::qWait(50);
+
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+ TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem,pos));
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
+ topItem->reset();
+
+ // press multiple points
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
+ topItem->reset();
+ bottomItem->reset();
+
+ // touch point on top item moves to bottom item, but top item should still receive the event
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
+ makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
+ topItem->reset();
+
+ // touch point on bottom item moves to top item, but bottom item should still receive the event
+ QTest::touchEvent(canvas, touchDevice).press(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).move(0, topItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
+ makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos), pos)));
+ bottomItem->reset();
+
+ // a single stationary press on an item shouldn't cause an event
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).stationary(0)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
+ topItem->reset();
+ bottomItem->reset();
+
+ // move touch point from top item to bottom, and release
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(),canvas);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
+ makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
+ topItem->reset();
+
+ // release while another point is pressed
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), canvas)
+ .stationary(1);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
+ makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos))));
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
+ topItem->reset();
+ bottomItem->reset();
+
+ delete topItem;
+ delete middleItem;
+ delete bottomItem;
+ delete canvas;
+}
+
+void tst_qquickcanvas::touchEvent_propagation()
+{
+ TestTouchItem::clearMousePressCounter();
+
+ QFETCH(bool, acceptEvents);
+ QFETCH(bool, enableItem);
+ QFETCH(qreal, itemOpacity);
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->show();
+
+ TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
+ bottomItem->setObjectName("Bottom Item");
+ bottomItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *middleItem = new TestTouchItem(bottomItem);
+ middleItem->setObjectName("Middle Item");
+ middleItem->setPos(QPointF(50, 50));
+ middleItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *topItem = new TestTouchItem(middleItem);
+ topItem->setObjectName("Top Item");
+ topItem->setPos(QPointF(50, 50));
+ topItem->setSize(QSizeF(150, 150));
+
+ QPointF pos(10, 10);
+ QPoint pointInBottomItem = bottomItem->mapToScene(pos).toPoint(); // (10, 10)
+ QPoint pointInMiddleItem = middleItem->mapToScene(pos).toPoint(); // (60, 60) overlaps with bottomItem
+ QPoint pointInTopItem = topItem->mapToScene(pos).toPoint(); // (110, 110) overlaps with bottom & top items
+
+ // disable topItem
+ topItem->acceptEvents = acceptEvents;
+ topItem->setEnabled(enableItem);
+ topItem->setOpacity(itemOpacity);
+
+ // single touch to top item, should be received by middle item
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
+ QTest::qWait(50);
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(middleItem->lastEvent.touchPoints.count(), 1);
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+ COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))));
+
+ // touch top and middle items, middle item should get both events
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
+ .press(1, pointInMiddleItem, canvas);
+ QTest::qWait(50);
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(middleItem->lastEvent.touchPoints.count(), 2);
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+ COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ (QList<QTouchEvent::TouchPoint>() << makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))
+ << makeTouchPoint(middleItem, pos) )));
+ middleItem->reset();
+
+ // disable middleItem as well
+ middleItem->acceptEvents = acceptEvents;
+ middleItem->setEnabled(enableItem);
+ middleItem->setOpacity(itemOpacity);
+
+ // touch top and middle items, bottom item should get all events
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
+ .press(1, pointInMiddleItem, canvas);
+ QTest::qWait(50);
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 2);
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ (QList<QTouchEvent::TouchPoint>() << makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos))
+ << makeTouchPoint(bottomItem, bottomItem->mapFromItem(middleItem, pos)) )));
+ bottomItem->reset();
+
+ // disable bottom item as well
+ bottomItem->acceptEvents = acceptEvents;
+ bottomItem->setEnabled(enableItem);
+ bottomItem->setOpacity(itemOpacity);
+
+ // no events should be received
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
+ .press(1, pointInMiddleItem, canvas)
+ .press(2, pointInBottomItem, canvas);
+ QTest::qWait(50);
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+
+ topItem->reset();
+ middleItem->reset();
+ bottomItem->reset();
+
+ // disable middle item, touch on top item
+ middleItem->acceptEvents = acceptEvents;
+ middleItem->setEnabled(enableItem);
+ middleItem->setOpacity(itemOpacity);
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
+ QTest::qWait(50);
+ if (!enableItem || itemOpacity == 0) {
+ // middle item is disabled or has 0 opacity, bottom item receives the event
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos))));
+ } else {
+ // middle item ignores event, sends it to the top item (top-most child)
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ makeTouchPoint(topItem, pos)));
+ }
+
+ delete topItem;
+ delete middleItem;
+ delete bottomItem;
+ delete canvas;
+}
+
+void tst_qquickcanvas::touchEvent_propagation_data()
+{
+ QTest::addColumn<bool>("acceptEvents");
+ QTest::addColumn<bool>("enableItem");
+ QTest::addColumn<qreal>("itemOpacity");
+
+ QTest::newRow("disable events") << false << true << 1.0;
+ QTest::newRow("disable item") << true << false << 1.0;
+ QTest::newRow("opacity of 0") << true << true << 0.0;
+}
+
+void tst_qquickcanvas::touchEvent_cancel()
+{
+ TestTouchItem::clearMousePressCounter();
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->show();
+
+ TestTouchItem *item = new TestTouchItem(canvas->rootItem());
+ item->setPos(QPointF(50, 50));
+ item->setSize(QSizeF(150, 150));
+
+ QPointF pos(10, 10);
+ QTest::touchEvent(canvas, touchDevice).press(0, item->mapToScene(pos).toPoint(),canvas);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(item->lastEvent.touchPoints.count(), 1);
+ TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(item,pos));
+ COMPARE_TOUCH_DATA(item->lastEvent, d);
+ item->reset();
+
+ QWindowSystemInterface::handleTouchCancelEvent(0, touchDevice);
+ QCoreApplication::processEvents();
+ d = makeTouchData(QEvent::TouchCancel, canvas);
+ COMPARE_TOUCH_DATA(item->lastEvent, d);
+
+ delete item;
+ delete canvas;
+}
+
+void tst_qquickcanvas::clearCanvas()
+{
+ QQuickCanvas *canvas = new QQuickCanvas;
+ QQuickItem *item = new QQuickItem;
+ item->setParentItem(canvas->rootItem());
+
+ QVERIFY(item->canvas() == canvas);
+
+ delete canvas;
+
+ QVERIFY(item->canvas() == 0);
+
+ delete item;
+}
+
+void tst_qquickcanvas::mouseFiltering()
+{
+ TestTouchItem::clearMousePressCounter();
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->show();
+
+ TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
+ bottomItem->setObjectName("Bottom Item");
+ bottomItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *middleItem = new TestTouchItem(bottomItem);
+ middleItem->setObjectName("Middle Item");
+ middleItem->setPos(QPointF(50, 50));
+ middleItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *topItem = new TestTouchItem(middleItem);
+ topItem->setObjectName("Top Item");
+ topItem->setPos(QPointF(50, 50));
+ topItem->setSize(QSizeF(150, 150));
+
+ QPoint pos(100, 100);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, pos);
+
+ // Mouse filtering propagates down the stack, so the
+ // correct order is
+ // 1. middleItem filters event
+ // 2. bottomItem filters event
+ // 3. topItem receives event
+ QTRY_COMPARE(middleItem->mousePressId, 1);
+ QTRY_COMPARE(bottomItem->mousePressId, 2);
+ QTRY_COMPARE(topItem->mousePressId, 3);
+
+ delete canvas;
+}
+
+void tst_qquickcanvas::qmlCreation()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("window.qml"));
+ QObject* created = component.create();
+ QVERIFY(created);
+
+ QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+ QCOMPARE(canvas->clearColor(), QColor(Qt::green));
+
+ QQuickItem* item = canvas->findChild<QQuickItem*>("item");
+ QVERIFY(item);
+ QCOMPARE(item->canvas(), canvas);
+
+ delete canvas;
+}
+
+void tst_qquickcanvas::clearColor()
+{
+ //### Can we examine rendering to make sure it is really blue?
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->setClearColor(Qt::blue);
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+ QCOMPARE(canvas->clearColor(), QColor(Qt::blue));
+ delete canvas;
+}
+
+void tst_qquickcanvas::grab()
+{
+ QQuickCanvas canvas;
+ canvas.setClearColor(Qt::red);
+
+ canvas.resize(250, 250);
+ canvas.show();
+
+ QTest::qWaitForWindowShown(&canvas);
+
+ QImage content = canvas.grabFrameBuffer();
+ QCOMPARE(content.width(), canvas.width());
+ QCOMPARE(content.height(), canvas.height());
+ QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000);
+}
+
+void tst_qquickcanvas::multipleWindows()
+{
+ QList<QQuickCanvas *> windows;
+ for (int i=0; i<6; ++i) {
+ QQuickCanvas *c = new QQuickCanvas();
+ c->setClearColor(Qt::GlobalColor(Qt::red + i));
+ c->resize(300, 200);
+ c->setPos(100 + i * 30, 100 + i * 20);
+ c->show();
+ windows << c;
+ QVERIFY(c->visible());
+ }
+
+ // move them
+ for (int i=0; i<windows.size(); ++i) {
+ QQuickCanvas *c = windows.at(i);
+ c->setPos(c->x() - 10, c->y() - 10);
+ }
+
+ // resize them
+ for (int i=0; i<windows.size(); ++i) {
+ QQuickCanvas *c = windows.at(i);
+ c->resize(200, 150);
+ }
+
+ qDeleteAll(windows);
+}
+
+void tst_qquickcanvas::animationsWhileHidden()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("AnimationsWhileHidden.qml"));
+ QObject* created = component.create();
+
+ QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+ QVERIFY(canvas->visible());
+
+ // Now hide the window and verify that it went off screen
+ canvas->hide();
+ QTest::qWait(10);
+ QVERIFY(!canvas->visible());
+
+ // Running animaiton should cause it to become visible again shortly.
+ QTRY_VERIFY(canvas->visible());
+
+ delete canvas;
+}
+
+
+void tst_qquickcanvas::headless()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("Headless.qml"));
+ QObject* created = component.create();
+
+ QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->visible());
+
+ QSignalSpy initialized(canvas, SIGNAL(sceneGraphInitialized()));
+ QSignalSpy invalidated(canvas, SIGNAL(sceneGraphInvalidated()));
+
+ // Verify that the canvas is alive and kicking
+ QVERIFY(canvas->openglContext() != 0);
+
+ // Store the visual result
+ QImage originalContent = canvas->grabFrameBuffer();
+
+ // Hide the canvas and verify signal emittion and GL context deletion
+ canvas->hide();
+ canvas->releaseResources();
+
+ QTRY_COMPARE(invalidated.size(), 1);
+ QVERIFY(canvas->openglContext() == 0);
+
+ // Destroy the native windowing system buffers
+ canvas->destroy();
+ QVERIFY(canvas->handle() == 0);
+
+ // Show and verify that we are back and running
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QCOMPARE(initialized.size(), 1);
+ QVERIFY(canvas->openglContext() != 0);
+
+ // Verify that the visual output is the same
+ QImage newContent = canvas->grabFrameBuffer();
+
+ QCOMPARE(originalContent, newContent);
+
+ delete canvas;
+}
+
+void tst_qquickcanvas::focusObject()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("focus.qml"));
+ QObject *created = component.create();
+ QVERIFY(created);
+
+ QQuickCanvas *canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+
+ QQuickItem *item1 = canvas->findChild<QQuickItem*>("item1");
+ QVERIFY(item1);
+ item1->setFocus(true);
+ QCOMPARE(item1, canvas->focusObject());
+
+ QQuickItem *item2 = canvas->findChild<QQuickItem*>("item2");
+ QVERIFY(item2);
+ item2->setFocus(true);
+ QCOMPARE(item2, canvas->focusObject());
+
+ delete canvas;
+}
+
+void tst_qquickcanvas::ignoreUnhandledMouseEvents()
+{
+ QQuickCanvas* canvas = new QQuickCanvas;
+ canvas->resize(100, 100);
+ canvas->show();
+
+ QQuickItem* item = new QQuickItem;
+ item->setSize(QSizeF(100, 100));
+ item->setParentItem(canvas->rootItem());
+
+ {
+ QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickcanvas)
+
+#include "tst_qquickcanvas.moc"
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif b/tests/auto/quick/qquickcanvasitem/data/anim-gr.gif
index 45263e0afb..45263e0afb 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif
+++ b/tests/auto/quick/qquickcanvasitem/data/anim-gr.gif
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png b/tests/auto/quick/qquickcanvasitem/data/anim-gr.png
index 925e2efc9a..925e2efc9a 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png
+++ b/tests/auto/quick/qquickcanvasitem/data/anim-gr.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png b/tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png
index 6941207373..6941207373 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png
+++ b/tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/background.png b/tests/auto/quick/qquickcanvasitem/data/background.png
index 6db6c6b1b9..6db6c6b1b9 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/background.png
+++ b/tests/auto/quick/qquickcanvasitem/data/background.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/broken.png b/tests/auto/quick/qquickcanvasitem/data/broken.png
index f2581017b4..f2581017b4 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/broken.png
+++ b/tests/auto/quick/qquickcanvasitem/data/broken.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png b/tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png
index 0342e4a384..0342e4a384 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png b/tests/auto/quick/qquickcanvasitem/data/green-16x16.png
index e19a3ffddd..e19a3ffddd 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green-16x16.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png b/tests/auto/quick/qquickcanvasitem/data/green-1x1.png
index 862d1dd10c..862d1dd10c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green-1x1.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png b/tests/auto/quick/qquickcanvasitem/data/green-256x256.png
index b06945c310..b06945c310 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png b/tests/auto/quick/qquickcanvasitem/data/green-2x2.png
index adc059449c..adc059449c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green-2x2.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green.png b/tests/auto/quick/qquickcanvasitem/data/green.png
index 28a1faab37..28a1faab37 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png b/tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png
index b8c7189d62..b8c7189d62 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png b/tests/auto/quick/qquickcanvasitem/data/red-16x16.png
index 9038fef784..9038fef784 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png
+++ b/tests/auto/quick/qquickcanvasitem/data/red-16x16.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/red.png b/tests/auto/quick/qquickcanvasitem/data/red.png
index a6e195d59c..a6e195d59c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/red.png
+++ b/tests/auto/quick/qquickcanvasitem/data/red.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png b/tests/auto/quick/qquickcanvasitem/data/redtransparent.png
index 75da08c3d6..75da08c3d6 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png
+++ b/tests/auto/quick/qquickcanvasitem/data/redtransparent.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png b/tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png
index e6fba3daa5..e6fba3daa5 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png b/tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png
index 7f63515654..7f63515654 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js b/tests/auto/quick/qquickcanvasitem/data/testhelper.js
index bac0210e16..bac0210e16 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js
+++ b/tests/auto/quick/qquickcanvasitem/data/testhelper.js
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/transparent.png b/tests/auto/quick/qquickcanvasitem/data/transparent.png
index 2b498699a8..2b498699a8 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/transparent.png
+++ b/tests/auto/quick/qquickcanvasitem/data/transparent.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png b/tests/auto/quick/qquickcanvasitem/data/transparent50.png
index 55f8e69325..55f8e69325 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png
+++ b/tests/auto/quick/qquickcanvasitem/data/transparent50.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml
index 6006a5a4c0..6006a5a4c0 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml
index cc1d88672b..cc1d88672b 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
index a00ccc3c3f..a00ccc3c3f 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml
index 11e1dce902..11e1dce902 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml
index b72e755ed9..b72e755ed9 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml b/tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml
index 102217dc0c..102217dc0c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml b/tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml
index 8f5a78cec0..8f5a78cec0 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml b/tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml
index 08197816e9..08197816e9 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml b/tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml
index d454c2efe1..d454c2efe1 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml b/tests/auto/quick/qquickcanvasitem/data/tst_line.qml
index baf9987ce3..baf9987ce3 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_line.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml
index b04ccf5458..b04ccf5458 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml b/tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml
index dd5b6628e8..dd5b6628e8 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml
index 1a3793d7a3..1a3793d7a3 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml b/tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml
index 4405ca6c0e..4405ca6c0e 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml b/tests/auto/quick/qquickcanvasitem/data/tst_state.qml
index 8042cf6a1d..8042cf6a1d 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_state.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml b/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml
index 6b42f8a770..6b42f8a770 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml b/tests/auto/quick/qquickcanvasitem/data/tst_text.qml
index baeb17c9fb..baeb17c9fb 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_text.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml b/tests/auto/quick/qquickcanvasitem/data/tst_transform.qml
index 834a22f549..834a22f549 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_transform.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/yellow.png b/tests/auto/quick/qquickcanvasitem/data/yellow.png
index 51e8aaf38c..51e8aaf38c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/yellow.png
+++ b/tests/auto/quick/qquickcanvasitem/data/yellow.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png b/tests/auto/quick/qquickcanvasitem/data/yellow75.png
index 2bb82c9834..2bb82c9834 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png
+++ b/tests/auto/quick/qquickcanvasitem/data/yellow75.png
Binary files differ
diff --git a/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
new file mode 100644
index 0000000000..ccf894715f
--- /dev/null
+++ b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
@@ -0,0 +1,34 @@
+QT += core-private gui-private qml-private widgets
+TEMPLATE=app
+TARGET=tst_qquickcanvasitem
+
+CONFIG += warn_on qmltestcase
+SOURCES += tst_qquickcanvasitem.cpp
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
+
+OTHER_FILES += \
+ data/testhelper.js \
+ data/tst_transform.qml \
+ data/tst_text.qml \
+ data/tst_strokeStyle.qml \
+ data/tst_state.qml \
+ data/tst_shadow.qml \
+ data/tst_pattern.qml \
+ data/tst_path.qml \
+ data/tst_line.qml \
+ data/tst_fillStyle.qml \
+ data/tst_fillrect.qml \
+ data/tst_drawimage.qml \
+ data/tst_composite.qml \
+ data/tst_canvas.qml \
+ data/tst_pixel.qml \
+ data/tst_gradient.qml \
+ data/tst_arcto.qml \
+ data/tst_arc.qml \
+ data/tst_context.qml
+
+
+
diff --git a/tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp b/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp
index 468c7cb9db..468c7cb9db 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp
+++ b/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp
diff --git a/tests/auto/quick/qquickdrag/qquickdrag.pro b/tests/auto/quick/qquickdrag/qquickdrag.pro
new file mode 100644
index 0000000000..820661ac23
--- /dev/null
+++ b/tests/auto/quick/qquickdrag/qquickdrag.pro
@@ -0,0 +1,9 @@
+TARGET = tst_qquickdrag
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickdrag.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
new file mode 100644
index 0000000000..37fb6d2d1f
--- /dev/null
+++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
@@ -0,0 +1,1034 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlexpression.h>
+
+template <typename T> static T evaluate(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ QVariant result = expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+ return result.value<T>();
+}
+
+template <> void evaluate<void>(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+}
+
+Q_DECLARE_METATYPE(Qt::DropActions)
+
+class TestDropTarget : public QQuickItem
+{
+ Q_OBJECT
+public:
+ TestDropTarget(QQuickItem *parent = 0)
+ : QQuickItem(parent)
+ , enterEvents(0)
+ , moveEvents(0)
+ , leaveEvents(0)
+ , dropEvents(0)
+ , acceptAction(Qt::MoveAction)
+ , defaultAction(Qt::IgnoreAction)
+ , proposedAction(Qt::IgnoreAction)
+ , accept(true)
+ {
+ setFlags(ItemAcceptsDrops);
+ }
+
+ void reset()
+ {
+ enterEvents = 0;
+ moveEvents = 0;
+ leaveEvents = 0;
+ dropEvents = 0;
+ defaultAction = Qt::IgnoreAction;
+ proposedAction = Qt::IgnoreAction;
+ supportedActions = Qt::IgnoreAction;
+ }
+
+ void dragEnterEvent(QDragEnterEvent *event)
+ {
+ ++enterEvents;
+ position = event->pos();
+ defaultAction = event->dropAction();
+ proposedAction = event->proposedAction();
+ supportedActions = event->possibleActions();
+ event->setAccepted(accept);
+ }
+
+ void dragMoveEvent(QDragMoveEvent *event)
+ {
+ ++moveEvents;
+ position = event->pos();
+ defaultAction = event->dropAction();
+ proposedAction = event->proposedAction();
+ supportedActions = event->possibleActions();
+ event->setAccepted(accept);
+ }
+
+ void dragLeaveEvent(QDragLeaveEvent *event)
+ {
+ ++leaveEvents;
+ event->setAccepted(accept);
+ }
+
+ void dropEvent(QDropEvent *event)
+ {
+ ++dropEvents;
+ position = event->pos();
+ defaultAction = event->dropAction();
+ proposedAction = event->proposedAction();
+ supportedActions = event->possibleActions();
+ event->setDropAction(acceptAction);
+ event->setAccepted(accept);
+ }
+
+ int enterEvents;
+ int moveEvents;
+ int leaveEvents;
+ int dropEvents;
+ Qt::DropAction acceptAction;
+ Qt::DropAction defaultAction;
+ Qt::DropAction proposedAction;
+ Qt::DropActions supportedActions;
+ QPointF position;
+ bool accept;
+};
+
+class tst_QQuickDrag: public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void active();
+ void drop();
+ void move();
+ void hotSpot();
+ void supportedActions();
+ void proposedAction();
+ void keys();
+ void source();
+ void recursion_data();
+ void recursion();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_QQuickDrag::initTestCase()
+{
+
+}
+
+void tst_QQuickDrag::cleanupTestCase()
+{
+
+}
+
+void tst_QQuickDrag::active()
+{
+ QQuickCanvas canvas;
+ TestDropTarget dropTarget(canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property bool dragActive: Drag.active\n"
+ "property Item dragTarget: Drag.target\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.cancel()");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ // Start while a drag is active, cancels the previous drag and starts a new one.
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.cancel()");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ // Enter events aren't sent to items without the QQuickItem::ItemAcceptsDrops flag.
+ dropTarget.setFlags(QQuickItem::Flags());
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.setFlags(QQuickItem::ItemAcceptsDrops);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.setFlags(QQuickItem::Flags());
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ // Follow up events aren't sent to items if the enter event isn't accepted.
+ dropTarget.setFlags(QQuickItem::ItemAcceptsDrops);
+ dropTarget.accept = false;
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.accept = true;
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.accept = false;
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ // Events are sent to hidden or disabled items.
+ dropTarget.accept = true;
+ dropTarget.setVisible(false);
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ evaluate<void>(item, "Drag.active = false");
+ dropTarget.setVisible(true);
+
+ dropTarget.setOpacity(0.0);
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ evaluate<void>(item, "Drag.active = false");
+ dropTarget.setOpacity(1.0);
+
+ dropTarget.setEnabled(false);
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+}
+
+void tst_QQuickDrag::drop()
+{
+ QQuickCanvas canvas;
+ TestDropTarget outerTarget(canvas.rootItem());
+ outerTarget.setSize(QSizeF(100, 100));
+ outerTarget.acceptAction = Qt::CopyAction;
+ TestDropTarget innerTarget(&outerTarget);
+ innerTarget.setSize(QSizeF(100, 100));
+ innerTarget.acceptAction = Qt::MoveAction;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property bool dragActive: Drag.active\n"
+ "property Item dragTarget: Drag.target\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&outerTarget);
+
+ innerTarget.reset(); outerTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1);
+
+ innerTarget.reset(); outerTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ // Inner target declines the drop so it is propagated to the outer target.
+ innerTarget.accept = false;
+
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.CopyAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1);
+
+
+ // Inner target doesn't accept enter so drop goes directly to outer.
+ innerTarget.accept = true;
+ innerTarget.setFlags(QQuickItem::Flags());
+
+ innerTarget.reset(); outerTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.CopyAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ // Neither target accepts drop so Qt::IgnoreAction is returned.
+ innerTarget.reset(); outerTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ outerTarget.accept = false;
+
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.IgnoreAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ // drop doesn't send an event and returns Qt.IgnoreAction if not active.
+ innerTarget.accept = true;
+ outerTarget.accept = true;
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.IgnoreAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+}
+
+void tst_QQuickDrag::move()
+{
+ QQuickCanvas canvas;
+ TestDropTarget outerTarget(canvas.rootItem());
+ outerTarget.setSize(QSizeF(100, 100));
+ TestDropTarget leftTarget(&outerTarget);
+ leftTarget.setPos(QPointF(0, 35));
+ leftTarget.setSize(QSizeF(30, 30));
+ TestDropTarget rightTarget(&outerTarget);
+ rightTarget.setPos(QPointF(70, 35));
+ rightTarget.setSize(QSizeF(30, 30));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property bool dragActive: Drag.active\n"
+ "property Item dragTarget: Drag.target\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&outerTarget);
+
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(50)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Move within the outer target.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(60, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Move into the right target.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(75, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&rightTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&rightTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(75)); QCOMPARE(outerTarget.position.y(), qreal(50));
+ QCOMPARE(rightTarget.position.x(), qreal(5)); QCOMPARE(rightTarget.position.y(), qreal(15));
+
+ // Move into the left target.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(25, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&leftTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&leftTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 1); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 1); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50));
+ QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(15));
+
+ // Move within the left target.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(25, 40));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&leftTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&leftTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 1);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(40));
+ QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(5));
+
+ // Move out of all targets.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(110, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.moveEvents, 0);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 1); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+
+ // Stop the right target accepting drag events and move into it.
+ rightTarget.accept = false;
+
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(80, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(80)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Stop the outer target accepting drag events after it has accepted an enter event.
+ outerTarget.accept = false;
+
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(60, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Clear the QQuickItem::ItemAcceptsDrops flag from the outer target after it accepted an enter event.
+ outerTarget.setFlags(QQuickItem::Flags());
+
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(40, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(40)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Clear the QQuickItem::ItemAcceptsDrops flag from the left target before it accepts an enter event.
+ leftTarget.setFlags(QQuickItem::Flags());
+
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(25, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50));
+}
+
+
+void tst_QQuickDrag::hotSpot()
+{
+ QQuickCanvas canvas;
+ TestDropTarget dropTarget(canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property real hotSpotX: Drag.hotSpot.x\n"
+ "property real hotSpotY: Drag.hotSpot.y\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(0));
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(0));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(0));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(0));
+
+ evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
+ QCOMPARE(dropTarget.position.x(), qreal(50));
+ QCOMPARE(dropTarget.position.y(), qreal(50));
+
+ evaluate<void>(item, "{ Drag.hotSpot.x = 5, Drag.hotSpot.y = 5 }");
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(5));
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(5));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(5));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(5));
+
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(dropTarget.position.x(), qreal(55));
+ QCOMPARE(dropTarget.position.y(), qreal(55));
+
+ item->setPos(QPointF(30, 20));
+ QCOMPARE(dropTarget.position.x(), qreal(35));
+ QCOMPARE(dropTarget.position.y(), qreal(25));
+
+ evaluate<void>(item, "{ Drag.hotSpot.x = 10; Drag.hotSpot.y = 10 }");
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(10));
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(10));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(10));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(10));
+ // Changing the hotSpot won't generate a move event so the position is unchanged. Should it?
+ QCOMPARE(dropTarget.position.x(), qreal(35));
+ QCOMPARE(dropTarget.position.y(), qreal(25));
+
+ item->setPos(QPointF(10, 20));
+ QCOMPARE(dropTarget.position.x(), qreal(20));
+ QCOMPARE(dropTarget.position.y(), qreal(30));
+}
+
+void tst_QQuickDrag::supportedActions()
+{
+ QQuickCanvas canvas;
+ TestDropTarget dropTarget(canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property int supportedActions: Drag.supportedActions\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true);
+ evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
+ QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction | Qt::LinkAction);
+
+ evaluate<void>(item, "Drag.supportedActions = Qt.CopyAction | Qt.MoveAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.CopyAction | Qt.MoveAction"), true);
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction);
+
+ // Once a drag is started the proposed actions are locked in for future events.
+ evaluate<void>(item, "Drag.supportedActions = Qt.MoveAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
+ item->setPos(QPointF(60, 60));
+ QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction);
+
+ // Calling start with proposed actions will override the current actions for the next sequence.
+ evaluate<void>(item, "Drag.start(Qt.CopyAction)");
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(dropTarget.supportedActions, Qt::CopyAction);
+
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(dropTarget.supportedActions, Qt::MoveAction);
+}
+
+void tst_QQuickDrag::proposedAction()
+{
+ QQuickCanvas canvas;
+ TestDropTarget dropTarget(canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property int proposedAction: Drag.proposedAction\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+
+ QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.MoveAction"), true);
+ evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
+ QCOMPARE(dropTarget.defaultAction, Qt::MoveAction);
+ QCOMPARE(dropTarget.proposedAction, Qt::MoveAction);
+
+ evaluate<void>(item, "Drag.proposedAction = Qt.CopyAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.CopyAction"), true);
+ QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.CopyAction"), true);
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(dropTarget.defaultAction, Qt::CopyAction);
+ QCOMPARE(dropTarget.proposedAction, Qt::CopyAction);
+
+ // The proposed action can change during a drag.
+ evaluate<void>(item, "Drag.proposedAction = Qt.MoveAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.MoveAction"), true);
+ item->setPos(QPointF(60, 60));
+ QCOMPARE(dropTarget.defaultAction, Qt::MoveAction);
+ QCOMPARE(dropTarget.proposedAction, Qt::MoveAction);
+
+ evaluate<void>(item, "Drag.proposedAction = Qt.LinkAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.LinkAction"), true);
+ QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.LinkAction"), true);
+ evaluate<void>(item, "Drag.drop()");
+ QCOMPARE(dropTarget.defaultAction, Qt::LinkAction);
+ QCOMPARE(dropTarget.proposedAction, Qt::LinkAction);
+}
+
+void tst_QQuickDrag::keys()
+{
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property variant keys: Drag.keys\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+
+// QCOMPARE(evaluate<QStringList>(item, "Drag.keys"), QStringList());
+// QCOMPARE(evaluate<QStringList>(item, "keys"), QStringList());
+ QCOMPARE(item->property("keys").toStringList(), QStringList());
+
+ evaluate<void>(item, "Drag.keys = [\"red\", \"blue\"]");
+// QCOMPARE(evaluate<QStringList>(item, "Drag.keys"), QStringList() << "red" << "blue");
+// QCOMPARE(evaluate<QStringList>(item, "keys"), QStringList() << "red" << "blue");
+ QCOMPARE(item->property("keys").toStringList(), QStringList() << "red" << "blue");
+}
+
+void tst_QQuickDrag::source()
+{
+
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property Item source: Drag.source\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "Item { id: proxySource; objectName: \"proxySource\" }\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(item));
+ QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(item));
+
+ QQuickItem *proxySource = item->findChild<QQuickItem *>("proxySource");
+ QVERIFY(proxySource);
+
+ evaluate<void>(item, "Drag.source = proxySource");
+ QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(proxySource));
+ QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(proxySource));
+
+ evaluate<void>(item, "Drag.source = undefined");
+ QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(item));
+ QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(item));
+}
+
+class RecursingDropTarget : public TestDropTarget
+{
+public:
+ RecursingDropTarget(const QString &script, int type, QQuickItem *parent)
+ : TestDropTarget(parent), script(script), type(type), item(0) {}
+
+ void setItem(QQuickItem *i) { item = i; }
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event)
+ {
+ TestDropTarget::dragEnterEvent(event);
+ if (type == QEvent::DragEnter && enterEvents < 2)
+ evaluate<void>(item, script);
+ }
+
+ void dragMoveEvent(QDragMoveEvent *event)
+ {
+ TestDropTarget::dragMoveEvent(event);
+ if (type == QEvent::DragMove && moveEvents < 2)
+ evaluate<void>(item, script);
+ }
+
+ void dragLeaveEvent(QDragLeaveEvent *event)
+ {
+ TestDropTarget::dragLeaveEvent(event);
+ if (type == QEvent::DragLeave && leaveEvents < 2)
+ evaluate<void>(item, script);
+ }
+
+ void dropEvent(QDropEvent *event)
+ {
+ TestDropTarget::dropEvent(event);
+ if (type == QEvent::Drop && dropEvents < 2)
+ evaluate<void>(item, script);
+ }
+
+private:
+ QString script;
+ int type;
+ QQuickItem *item;
+
+};
+
+void tst_QQuickDrag::recursion_data()
+{
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("type");
+ QTest::addColumn<QByteArray>("warning");
+
+ QTest::newRow("Drag.start() in Enter")
+ << QString("Drag.start()")
+ << int(QEvent::DragEnter)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.cancel() in Enter")
+ << QString("Drag.cancel()")
+ << int(QEvent::DragEnter)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.drop() in Enter")
+ << QString("Drag.drop()")
+ << int(QEvent::DragEnter)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.active = true in Enter")
+ << QString("Drag.active = true")
+ << int(QEvent::DragEnter)
+ << QByteArray();
+ QTest::newRow("Drag.active = false in Enter")
+ << QString("Drag.active = false")
+ << int(QEvent::DragEnter)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
+ QTest::newRow("move in Enter")
+ << QString("x = 23")
+ << int(QEvent::DragEnter)
+ << QByteArray();
+
+ QTest::newRow("Drag.start() in Move")
+ << QString("Drag.start()")
+ << int(QEvent::DragMove)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.cancel() in Move")
+ << QString("Drag.cancel()")
+ << int(QEvent::DragMove)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.drop() in Move")
+ << QString("Drag.drop()")
+ << int(QEvent::DragMove)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.active = true in Move")
+ << QString("Drag.active = true")
+ << int(QEvent::DragMove)
+ << QByteArray();
+ QTest::newRow("Drag.active = false in Move")
+ << QString("Drag.active = false")
+ << int(QEvent::DragMove)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
+ QTest::newRow("move in Move")
+ << QString("x = 23")
+ << int(QEvent::DragMove)
+ << QByteArray();
+
+ QTest::newRow("Drag.start() in Leave")
+ << QString("Drag.start()")
+ << int(QEvent::DragLeave)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.cancel() in Leave")
+ << QString("Drag.cancel()")
+ << int(QEvent::DragLeave)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.drop() in Leave")
+ << QString("Drag.drop()")
+ << int(QEvent::DragLeave)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.active = true in Leave")
+ << QString("Drag.active = true")
+ << int(QEvent::DragLeave)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
+ QTest::newRow("Drag.active = false in Leave")
+ << QString("Drag.active = false")
+ << int(QEvent::DragLeave)
+ << QByteArray();
+ QTest::newRow("move in Leave")
+ << QString("x = 23")
+ << int(QEvent::DragLeave)
+ << QByteArray();
+
+ QTest::newRow("Drag.start() in Drop")
+ << QString("Drag.start()")
+ << int(QEvent::Drop)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.cancel() in Drop")
+ << QString("Drag.cancel()")
+ << int(QEvent::Drop)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.drop() in Drop")
+ << QString("Drag.drop()")
+ << int(QEvent::Drop)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.active = true in Drop")
+ << QString("Drag.active = true")
+ << int(QEvent::Drop)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
+ QTest::newRow("Drag.active = false in Drop")
+ << QString("Drag.active = false")
+ << int(QEvent::Drop)
+ << QByteArray();
+ QTest::newRow("move in Drop")
+ << QString("x = 23")
+ << int(QEvent::Drop)
+ << QByteArray();
+}
+
+void tst_QQuickDrag::recursion()
+{
+ QFETCH(QString, script);
+ QFETCH(int, type);
+ QFETCH(QByteArray, warning);
+
+ if (!warning.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, warning.constData());
+
+ QQuickCanvas canvas;
+ RecursingDropTarget dropTarget(script, type, canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(canvas.rootItem());
+
+ dropTarget.setItem(item);
+
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(dropTarget.enterEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, 0);
+ QCOMPARE(dropTarget.dropEvents, 0);
+ QCOMPARE(dropTarget.leaveEvents, 0);
+
+ evaluate<void>(item, "y = 15");
+ QCOMPARE(dropTarget.enterEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.dropEvents, 0);
+ QCOMPARE(dropTarget.leaveEvents, 0);
+
+ if (type == QEvent::Drop) {
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
+ QCOMPARE(dropTarget.enterEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.dropEvents, 1);
+ QCOMPARE(dropTarget.leaveEvents, 0);
+ } else {
+ evaluate<void>(item, "Drag.cancel()");
+ QCOMPARE(dropTarget.enterEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.dropEvents, 0);
+ QCOMPARE(dropTarget.leaveEvents, 1);
+ }
+}
+
+
+QTEST_MAIN(tst_QQuickDrag)
+
+#include "tst_qquickdrag.moc"
diff --git a/tests/auto/quick/qquickdroparea/qquickdroparea.pro b/tests/auto/quick/qquickdroparea/qquickdroparea.pro
new file mode 100644
index 0000000000..41bcaacf79
--- /dev/null
+++ b/tests/auto/quick/qquickdroparea/qquickdroparea.pro
@@ -0,0 +1,11 @@
+TARGET = tst_qquickdroparea
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickdroparea.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
+
+mac: CONFIG += insignificant_test # QTBUG-24588
diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
new file mode 100644
index 0000000000..38fb02d085
--- /dev/null
+++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
@@ -0,0 +1,1118 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlexpression.h>
+
+#include <QtGui/qwindowsysteminterface_qpa.h>
+#include <QtGui/qplatformdrag_qpa.h>
+
+template <typename T> static T evaluate(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ QVariant result = expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+ return result.value<T>();
+}
+
+template <> void evaluate<void>(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+}
+
+class tst_QQuickDropArea: public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void containsDrag_internal();
+ void containsDrag_external();
+ void keys_internal();
+ void keys_external();
+ void source_internal();
+// void source_external();
+ void position_internal();
+ void position_external();
+ void drop_internal();
+// void drop_external();
+ void simultaneousDrags();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_QQuickDropArea::initTestCase()
+{
+
+}
+
+void tst_QQuickDropArea::cleanupTestCase()
+{
+
+}
+
+void tst_QQuickDropArea::containsDrag_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property bool hasDrag: containsDrag\n"
+ "property int enterEvents: 0\n"
+ "property int exitEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents}\n"
+ "onExited: {++exitEvents}\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+
+ dragItem->setPos(QPointF(150, 50));
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ dragItem->setPos(QPointF(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+ dragItem->setPos(QPointF(150, 50));
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
+
+ evaluate<void>(dragItem, "Drag.active = false");
+}
+
+void tst_QQuickDropArea::containsDrag_external()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property bool hasDrag: containsDrag\n"
+ "property int enterEvents: 0\n"
+ "property int exitEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents}\n"
+ "onExited: {++exitEvents}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QMimeData data;
+ QQuickCanvas alternateCanvas;
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
+
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
+}
+
+void tst_QQuickDropArea::keys_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property variant dragKeys\n"
+ "property variant dropKeys: keys\n"
+ "property int enterEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents; dragKeys = drag.keys }\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "Drag.keys: [\"red\", \"blue\"]\n"
+ "}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = \"blue\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "blue");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "blue");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = \"red\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = \"green\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "green");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "green");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = [\"red\", \"green\"]");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red" << "green");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red" << "green");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dragItem, "Drag.keys = []");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = []");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = []");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dragItem, "Drag.keys = [\"red\", \"blue\"]");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+}
+
+void tst_QQuickDropArea::keys_external()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property variant dragKeys\n"
+ "property variant dropKeys: keys\n"
+ "property int enterEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents; dragKeys = drag.keys }\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ dropArea->setParentItem(canvas.rootItem());
+
+ QMimeData data;
+ QQuickCanvas alternateCanvas;
+
+ data.setData("text/x-red", "red");
+ data.setData("text/x-blue", "blue");
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ evaluate<void>(dropArea, "keys = \"text/x-blue\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ evaluate<void>(dropArea, "keys = \"text/x-red\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ evaluate<void>(dropArea, "keys = \"text/x-green\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ evaluate<void>(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ data.removeFormat("text/x-red");
+ data.removeFormat("text/x-blue");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ evaluate<void>(dropArea, "keys = []");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ data.setData("text/x-red", "red");
+ data.setData("text/x-blue", "blue");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+}
+
+void tst_QQuickDropArea::source_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property Item source: drag.source\n"
+ "property Item eventSource\n"
+ "width: 100; height: 100\n"
+ "onEntered: {eventSource = drag.source}\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}\n"
+ "Item { id: dragSource; objectName: \"dragSource\" }\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ QQuickItem *dragSource = dropArea->findChild<QQuickItem *>("dragSource");
+ QVERIFY(dragSource);
+
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(dragItem));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(dragItem));
+ QCOMPARE(evaluate<QObject *>(dropArea, "eventSource"), static_cast<QObject *>(dragItem));
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
+
+
+ evaluate<void>(dropArea, "{ eventSource = null }");
+ evaluate<void>(dragItem, "Drag.source = dragSource");
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(dragSource));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(dragSource));
+ QCOMPARE(evaluate<QObject *>(dropArea, "eventSource"), static_cast<QObject *>(dragSource));
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
+}
+
+// Setting a source can't be emulated using the QWindowSystemInterface API.
+
+//void tst_QQuickDropArea::source_external()
+//{
+//}
+
+void tst_QQuickDropArea::position_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property real dragX: drag.x\n"
+ "property real dragY: drag.y\n"
+ "property real eventX\n"
+ "property real eventY\n"
+ "property int enterEvents: 0\n"
+ "property int moveEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n"
+ "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 0);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
+ dragItem->setPos(QPointF(40, 50));
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
+ dragItem->setPos(QPointF(75, 25));
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(25));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(25));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
+
+ evaluate<void>(dragItem, "Drag.active = false");
+}
+
+void tst_QQuickDropArea::position_external()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property real dragX: drag.x\n"
+ "property real dragY: drag.y\n"
+ "property real eventX\n"
+ "property real eventY\n"
+ "property int enterEvents: 0\n"
+ "property int moveEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n"
+ "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QMimeData data;
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25), Qt::CopyAction);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(25));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(25));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
+
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25), Qt::CopyAction);
+}
+
+void tst_QQuickDropArea::drop_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property bool accept: false\n"
+ "property bool setAccepted: false\n"
+ "property bool acceptDropAction: false\n"
+ "property bool setDropAction: false\n"
+ "property int dropAction: Qt.IgnoreAction\n"
+ "property int proposedAction: Qt.IgnoreAction\n"
+ "property int supportedActions: Qt.IgnoreAction\n"
+ "property int dropEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onDropped: {\n"
+ "++dropEvents\n"
+ "supportedActions = drop.supportedActions\n"
+ "proposedAction = drop.action\n"
+ "if (setDropAction)\n"
+ "drop.action = dropAction\n"
+ "if (acceptDropAction)\n"
+ "drop.accept(dropAction)\n"
+ "else if (setAccepted)\n"
+ "drop.accepted = accept\n"
+ "else if (accept)\n"
+ "drop.accept()\n"
+ "}\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::IgnoreAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ accept = true; setDropAction = true; dropAction = Qt.LinkAction }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = true; }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ accept = false; setAccepted = true; }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::IgnoreAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = false; setDropAction = false; acceptDropAction = true; }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ acceptDropAction = false; dropAction = Qt.IgnoreAction; accept = true }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = true }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = false }");
+ evaluate<void>(dragItem, "Drag.supportedActions = Qt.LinkAction");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = true }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = false }");
+ evaluate<void>(dragItem, "Drag.proposedAction = Qt.LinkAction");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::LinkAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = true }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::LinkAction));
+}
+
+// Setting the supportedActions can't be emulated using the QWindowSystemInterface API.
+
+//void tst_QQuickDropArea::drop_external()
+//{
+//}
+
+void tst_QQuickDropArea::simultaneousDrags()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property int enterEvents: 0\n"
+ "property int exitEvents: 0\n"
+ "width: 100; height: 100\n"
+ "keys: [\"red\", \"text/x-red\"]\n"
+ "onEntered: {++enterEvents}\n"
+ "onExited: {++exitEvents}\n"
+ "DropArea {\n"
+ "objectName: \"dropArea2\"\n"
+ "property int enterEvents: 0\n"
+ "property int exitEvents: 0\n"
+ "width: 100; height: 100\n"
+ "keys: [\"blue\", \"text/x-blue\"]\n"
+ "onEntered: {++enterEvents}\n"
+ "onExited: {++exitEvents}\n"
+ "}\n"
+ "Item {\n"
+ "objectName: \"dragItem1\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "Drag.keys: [\"red\", \"blue\"]"
+ "}\n"
+ "Item {\n"
+ "objectName: \"dragItem2\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "Drag.keys: [\"red\", \"blue\"]"
+ "}\n"
+ "}", QUrl());
+
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea1 = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea1);
+ dropArea1->setParentItem(canvas.rootItem());
+
+ QQuickItem *dropArea2 = dropArea1->findChild<QQuickItem *>("dropArea2");
+ QVERIFY(dropArea2);
+
+ QQuickItem *dragItem1 = dropArea1->findChild<QQuickItem *>("dragItem1");
+ QVERIFY(dragItem1);
+
+ QQuickItem *dragItem2 = dropArea1->findChild<QQuickItem *>("dragItem2");
+ QVERIFY(dragItem2);
+
+ QMimeData data;
+ data.setData("text/x-red", "red");
+ data.setData("text/x-blue", "blue");
+
+ QQuickCanvas alternateCanvas;
+
+ // Mixed internal drags.
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem1, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ // internal then external.
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem1, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ // external then internal.
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ // Different acceptance
+ evaluate<void>(dragItem1, "Drag.keys = \"red\"");
+ evaluate<void>(dragItem2, "Drag.keys = \"blue\"");
+ data.removeFormat("text/x-red");
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ // internal then external
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
+}
+
+QTEST_MAIN(tst_QQuickDropArea)
+
+#include "tst_qquickdroparea.moc"
diff --git a/tests/auto/qtquick2/qquickflickable/data/disabled.qml b/tests/auto/quick/qquickflickable/data/disabled.qml
index 9b679827c7..9b679827c7 100644
--- a/tests/auto/qtquick2/qquickflickable/data/disabled.qml
+++ b/tests/auto/quick/qquickflickable/data/disabled.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable01.qml b/tests/auto/quick/qquickflickable/data/flickable01.qml
index cbec44bb4f..cbec44bb4f 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickable01.qml
+++ b/tests/auto/quick/qquickflickable/data/flickable01.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable02.qml b/tests/auto/quick/qquickflickable/data/flickable02.qml
index 80caa32da5..80caa32da5 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickable02.qml
+++ b/tests/auto/quick/qquickflickable/data/flickable02.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable03.qml b/tests/auto/quick/qquickflickable/data/flickable03.qml
index 719c682ee6..719c682ee6 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickable03.qml
+++ b/tests/auto/quick/qquickflickable/data/flickable03.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable04.qml b/tests/auto/quick/qquickflickable/data/flickable04.qml
index b2f30b84ec..b2f30b84ec 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickable04.qml
+++ b/tests/auto/quick/qquickflickable/data/flickable04.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml b/tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml
index bb8f1eefc6..bb8f1eefc6 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml
+++ b/tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/margins.qml b/tests/auto/quick/qquickflickable/data/margins.qml
index 4866bd8301..4866bd8301 100644
--- a/tests/auto/qtquick2/qquickflickable/data/margins.qml
+++ b/tests/auto/quick/qquickflickable/data/margins.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
index 60dadcc73c..60dadcc73c 100644
--- a/tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml
+++ b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/resize.qml b/tests/auto/quick/qquickflickable/data/resize.qml
index 1a9ef54107..1a9ef54107 100644
--- a/tests/auto/qtquick2/qquickflickable/data/resize.qml
+++ b/tests/auto/quick/qquickflickable/data/resize.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/wheel.qml b/tests/auto/quick/qquickflickable/data/wheel.qml
index 2928bbcd72..2928bbcd72 100644
--- a/tests/auto/qtquick2/qquickflickable/data/wheel.qml
+++ b/tests/auto/quick/qquickflickable/data/wheel.qml
diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro
new file mode 100644
index 0000000000..0ca03b2497
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/qquickflickable.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickflickable
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickflickable.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
new file mode 100644
index 0000000000..e46659e6d0
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -0,0 +1,663 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickflickable_p.h>
+#include <private/qquickflickable_p_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <math.h>
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+#include <QtOpenGL/QGLShaderProgram>
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickflickable : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void create();
+ void horizontalViewportSize();
+ void verticalViewportSize();
+ void properties();
+ void boundsBehavior();
+ void maximumFlickVelocity();
+ void flickDeceleration();
+ void pressDelay();
+ void nestedPressDelay();
+ void flickableDirection();
+ void resizeContent();
+ void returnToBounds();
+ void wheel();
+ void movingAndDragging();
+ void disabled();
+ void flickVelocity();
+ void margins();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qquickflickable::create()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flickable01.qml"));
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+ QCOMPARE(obj->contentX(), 0.);
+ QCOMPARE(obj->contentY(), 0.);
+
+ QCOMPARE(obj->horizontalVelocity(), 0.);
+ QCOMPARE(obj->verticalVelocity(), 0.);
+
+ QCOMPARE(obj->isInteractive(), true);
+ QCOMPARE(obj->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds);
+ QCOMPARE(obj->pressDelay(), 0);
+ QCOMPARE(obj->maximumFlickVelocity(), 2500.);
+
+ delete obj;
+}
+
+void tst_qquickflickable::horizontalViewportSize()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flickable02.qml"));
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentWidth(), 800.);
+ QCOMPARE(obj->contentHeight(), 300.);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+
+ delete obj;
+}
+
+void tst_qquickflickable::verticalViewportSize()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flickable03.qml"));
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentWidth(), 200.);
+ QCOMPARE(obj->contentHeight(), 6000.);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+
+ delete obj;
+}
+
+void tst_qquickflickable::properties()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flickable04.qml"));
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->isInteractive(), false);
+ QCOMPARE(obj->boundsBehavior(), QQuickFlickable::StopAtBounds);
+ QCOMPARE(obj->pressDelay(), 200);
+ QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+
+ QVERIFY(obj->property("ok").toBool() == false);
+ QMetaObject::invokeMethod(obj, "check");
+ QVERIFY(obj->property("ok").toBool() == true);
+
+ delete obj;
+}
+
+void tst_qquickflickable::boundsBehavior()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
+
+ QVERIFY(flickable);
+ QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
+
+ flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
+ QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds);
+ QCOMPARE(spy.count(),1);
+ flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
+ QCOMPARE(spy.count(),1);
+
+ flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
+ QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds);
+ QCOMPARE(spy.count(),2);
+ flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
+ QCOMPARE(spy.count(),2);
+
+ flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
+ QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
+ QCOMPARE(spy.count(),3);
+ flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
+ QCOMPARE(spy.count(),3);
+}
+
+void tst_qquickflickable::maximumFlickVelocity()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
+
+ flickable->setMaximumFlickVelocity(2.0);
+ QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
+ QCOMPARE(spy.count(),1);
+ flickable->setMaximumFlickVelocity(2.0);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qquickflickable::flickDeceleration()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->flickDeceleration(), 1.0);
+
+ flickable->setFlickDeceleration(2.0);
+ QCOMPARE(flickable->flickDeceleration(), 2.0);
+ QCOMPARE(spy.count(),1);
+ flickable->setFlickDeceleration(2.0);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qquickflickable::pressDelay()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->pressDelay(), 100);
+
+ flickable->setPressDelay(200);
+ QCOMPARE(flickable->pressDelay(), 200);
+ QCOMPARE(spy.count(),1);
+ flickable->setPressDelay(200);
+ QCOMPARE(spy.count(),1);
+}
+
+// QTBUG-17361
+void tst_qquickflickable::nestedPressDelay()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("nestedPressDelay.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(canvas->rootObject());
+ QVERIFY(outer != 0);
+
+ QQuickFlickable *inner = canvas->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
+ QVERIFY(inner != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(150, 150));
+ // the MouseArea is not pressed immediately
+ QVERIFY(outer->property("pressed").toBool() == false);
+
+ // The outer pressDelay will prevail (50ms, vs. 10sec)
+ // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
+ QTRY_VERIFY(outer->property("pressed").toBool() == true);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(150, 150));
+
+ delete canvas;
+}
+
+void tst_qquickflickable::flickableDirection()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::VerticalFlick);
+
+ flickable->setFlickableDirection(QQuickFlickable::HorizontalAndVerticalFlick);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalAndVerticalFlick);
+ QCOMPARE(spy.count(),1);
+
+ flickable->setFlickableDirection(QQuickFlickable::AutoFlickDirection);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::AutoFlickDirection);
+ QCOMPARE(spy.count(),2);
+
+ flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
+ QCOMPARE(spy.count(),3);
+
+ flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
+ QCOMPARE(spy.count(),3);
+}
+
+// QtQuick 1.1
+void tst_qquickflickable::resizeContent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("resize.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
+ QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentX(), 0.);
+ QCOMPARE(obj->contentY(), 0.);
+ QCOMPARE(obj->contentWidth(), 300.);
+ QCOMPARE(obj->contentHeight(), 300.);
+
+ QMetaObject::invokeMethod(root, "resizeContent");
+
+ QCOMPARE(obj->contentX(), 100.);
+ QCOMPARE(obj->contentY(), 100.);
+ QCOMPARE(obj->contentWidth(), 600.);
+ QCOMPARE(obj->contentHeight(), 600.);
+
+ delete root;
+}
+
+// QtQuick 1.1
+void tst_qquickflickable::returnToBounds()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("resize.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
+ QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentX(), 0.);
+ QCOMPARE(obj->contentY(), 0.);
+ QCOMPARE(obj->contentWidth(), 300.);
+ QCOMPARE(obj->contentHeight(), 300.);
+
+ obj->setContentX(100);
+ obj->setContentY(400);
+ QTRY_COMPARE(obj->contentX(), 100.);
+ QTRY_COMPARE(obj->contentY(), 400.);
+
+ QMetaObject::invokeMethod(root, "returnToBounds");
+
+ QTRY_COMPARE(obj->contentX(), 0.);
+ QTRY_COMPARE(obj->contentY(), 0.);
+
+ delete root;
+}
+
+void tst_qquickflickable::wheel()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("wheel.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flick = canvas->rootObject()->findChild<QQuickFlickable*>("flick");
+ QVERIFY(flick != 0);
+
+ {
+ QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
+ event.setAccepted(false);
+ QGuiApplication::sendEvent(canvas, &event);
+ }
+
+ QTRY_VERIFY(flick->contentY() > 0);
+ QVERIFY(flick->contentX() == 0);
+
+ flick->setContentY(0);
+ QVERIFY(flick->contentY() == 0);
+
+ {
+ QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Horizontal);
+ event.setAccepted(false);
+ QGuiApplication::sendEvent(canvas, &event);
+ }
+
+ QTRY_VERIFY(flick->contentX() > 0);
+ QVERIFY(flick->contentY() == 0);
+
+ delete canvas;
+}
+
+void tst_qquickflickable::movingAndDragging()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("flickable03.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ QSignalSpy vDragSpy(flickable, SIGNAL(draggingVerticallyChanged()));
+ QSignalSpy hDragSpy(flickable, SIGNAL(draggingHorizontallyChanged()));
+ QSignalSpy dragSpy(flickable, SIGNAL(draggingChanged()));
+ QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
+ QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
+ QSignalSpy moveSpy(flickable, SIGNAL(movingChanged()));
+ QSignalSpy dragStartSpy(flickable, SIGNAL(dragStarted()));
+ QSignalSpy dragEndSpy(flickable, SIGNAL(dragEnded()));
+
+ //Vertical
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
+
+ QTest::mouseMove(canvas, QPoint(50, 80));
+ QTest::mouseMove(canvas, QPoint(50, 70));
+ QTest::mouseMove(canvas, QPoint(50, 60));
+
+ QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0);
+
+ QVERIFY(!flickable->isDraggingHorizontally());
+ QVERIFY(flickable->isDraggingVertically());
+ QVERIFY(flickable->isDragging());
+ QCOMPARE(vDragSpy.count(), 1);
+ QCOMPARE(dragSpy.count(), 1);
+ QCOMPARE(hDragSpy.count(), 0);
+ QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(dragEndSpy.count(), 0);
+
+ QVERIFY(!flickable->isMovingHorizontally());
+ QVERIFY(flickable->isMovingVertically());
+ QVERIFY(flickable->isMoving());
+ QCOMPARE(vMoveSpy.count(), 1);
+ QCOMPARE(moveSpy.count(), 1);
+ QCOMPARE(hMoveSpy.count(), 0);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
+
+ QTRY_VERIFY(!flickable->isDraggingVertically());
+ QVERIFY(!flickable->isDragging());
+ QCOMPARE(vDragSpy.count(), 2);
+ QCOMPARE(dragSpy.count(), 2);
+ QCOMPARE(hDragSpy.count(), 0);
+ QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(dragEndSpy.count(), 1);
+
+ // wait for any motion to end
+ QTRY_VERIFY(flickable->isMoving() == false);
+
+ //Horizontal
+ vDragSpy.clear();
+ hDragSpy.clear();
+ dragSpy.clear();
+ vMoveSpy.clear();
+ hMoveSpy.clear();
+ moveSpy.clear();
+ dragStartSpy.clear();
+ dragEndSpy.clear();
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(90, 50));
+
+ QTest::mouseMove(canvas, QPoint(80, 50));
+ QTest::mouseMove(canvas, QPoint(70, 50));
+ QTest::mouseMove(canvas, QPoint(60, 50));
+
+ QVERIFY(!flickable->isDraggingVertically());
+ QVERIFY(flickable->isDraggingHorizontally());
+ QVERIFY(flickable->isDragging());
+ QCOMPARE(vDragSpy.count(), 0);
+ QCOMPARE(dragSpy.count(), 1);
+ QCOMPARE(hDragSpy.count(), 1);
+ QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(dragEndSpy.count(), 0);
+
+ QVERIFY(!flickable->isMovingVertically());
+ QVERIFY(flickable->isMovingHorizontally());
+ QVERIFY(flickable->isMoving());
+ QCOMPARE(vMoveSpy.count(), 0);
+ QCOMPARE(moveSpy.count(), 1);
+ QCOMPARE(hMoveSpy.count(), 1);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(60, 50));
+
+ QTRY_VERIFY(!flickable->isDraggingHorizontally());
+ QVERIFY(!flickable->isDragging());
+ QCOMPARE(vDragSpy.count(), 0);
+ QCOMPARE(dragSpy.count(), 2);
+ QCOMPARE(hDragSpy.count(), 2);
+ QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(dragEndSpy.count(), 1);
+ // Don't test moving because a flick could occur
+
+#ifdef Q_OS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems");
+#endif
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ vMoveSpy.clear();
+ hMoveSpy.clear();
+ moveSpy.clear();
+ QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
+ QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged()));
+ QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged()));
+
+ // flick then press while it is still moving
+ // flicking == false, moving == true;
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QVERIFY(flickable->isFlicking());
+ QVERIFY(flickable->isFlickingVertically());
+ QVERIFY(!flickable->isFlickingHorizontally());
+ QVERIFY(flickable->isMoving());
+ QVERIFY(flickable->isMovingVertically());
+ QVERIFY(!flickable->isMovingHorizontally());
+ QCOMPARE(vMoveSpy.count(), 1);
+ QCOMPARE(hMoveSpy.count(), 0);
+ QCOMPARE(moveSpy.count(), 1);
+ QCOMPARE(vFlickSpy.count(), 1);
+ QCOMPARE(hFlickSpy.count(), 0);
+ QCOMPARE(flickSpy.count(), 1);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20, 50));
+ QTRY_VERIFY(!flickable->isFlicking());
+ QVERIFY(!flickable->isFlickingVertically());
+ QVERIFY(flickable->isMoving());
+ QVERIFY(flickable->isMovingVertically());
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,50));
+ QVERIFY(!flickable->isFlicking());
+ QVERIFY(!flickable->isFlickingVertically());
+ QTRY_VERIFY(!flickable->isMoving());
+ QVERIFY(!flickable->isMovingVertically());
+
+ delete canvas;
+}
+
+void tst_qquickflickable::disabled()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("disabled.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flick = canvas->rootObject()->findChild<QQuickFlickable*>("flickable");
+ QVERIFY(flick != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
+
+ QTest::mouseMove(canvas, QPoint(50, 80));
+ QTest::mouseMove(canvas, QPoint(50, 70));
+ QTest::mouseMove(canvas, QPoint(50, 60));
+
+ QVERIFY(flick->isMoving() == false);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
+
+ // verify that mouse clicks on other elements still work (QTBUG-20584)
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+
+ QTRY_VERIFY(canvas->rootObject()->property("clicked").toBool() == true);
+}
+
+void tst_qquickflickable::flickVelocity()
+{
+#ifdef Q_OS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems");
+#endif
+
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("flickable03.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ // flick up
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // flick down
+ flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
+ QVERIFY(flickable->verticalVelocity() < 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // Flick multiple times and verify that flick acceleration is applied.
+ QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable);
+ bool boosted = false;
+ for (int i = 0; i < 6; ++i) {
+ flick(canvas, QPoint(20,390), QPoint(20, 50), 200);
+ boosted |= fp->flickBoost > 1.0;
+ }
+ QVERIFY(boosted);
+
+ // Flick in opposite direction -> boost cancelled.
+ flick(canvas, QPoint(20,10), QPoint(20, 340), 200);
+ QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
+ QVERIFY(fp->flickBoost == 1.0);
+
+ delete canvas;
+}
+
+void tst_qquickflickable::margins()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("margins.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root);
+ QVERIFY(obj != 0);
+
+ // starting state
+ QCOMPARE(obj->contentX(), -40.);
+ QCOMPARE(obj->contentY(), -20.);
+ QCOMPARE(obj->contentWidth(), 1600.);
+ QCOMPARE(obj->contentHeight(), 600.);
+ QCOMPARE(obj->xOrigin(), 0.);
+ QCOMPARE(obj->yOrigin(), 0.);
+
+ // Reduce left margin
+ obj->setLeftMargin(30);
+ QTRY_COMPARE(obj->contentX(), -30.);
+
+ // Reduce top margin
+ obj->setTopMargin(20);
+ QTRY_COMPARE(obj->contentY(), -20.);
+
+ // position to the far right, including margin
+ obj->setContentX(1600 + 50 - obj->width());
+ obj->returnToBounds();
+ QTest::qWait(200);
+ QCOMPARE(obj->contentX(), 1600. + 50. - obj->width());
+
+ // position beyond the far right, including margin
+ obj->setContentX(1600 + 50 - obj->width() + 1.);
+ obj->returnToBounds();
+ QTRY_COMPARE(obj->contentX(), 1600. + 50. - obj->width());
+
+ // Reduce right margin
+ obj->setRightMargin(40);
+ QTRY_COMPARE(obj->contentX(), 1600. + 40. - obj->width());
+ QCOMPARE(obj->contentWidth(), 1600.);
+
+ // position to the far bottom, including margin
+ obj->setContentY(600 + 30 - obj->height());
+ obj->returnToBounds();
+ QTest::qWait(200);
+ QCOMPARE(obj->contentY(), 600. + 30. - obj->height());
+
+ // position beyond the far bottom, including margin
+ obj->setContentY(600 + 30 - obj->height() + 1.);
+ obj->returnToBounds();
+ QTRY_COMPARE(obj->contentY(), 600. + 30. - obj->height());
+
+ // Reduce bottom margin
+ obj->setBottomMargin(20);
+ QTRY_COMPARE(obj->contentY(), 600. + 20. - obj->height());
+ QCOMPARE(obj->contentHeight(), 600.);
+
+ delete root;
+}
+
+QTEST_MAIN(tst_qquickflickable)
+
+#include "tst_qquickflickable.moc"
diff --git a/tests/auto/qtquick2/qquickflipable/data/crash.qml b/tests/auto/quick/qquickflipable/data/crash.qml
index a0327918cb..a0327918cb 100644
--- a/tests/auto/qtquick2/qquickflipable/data/crash.qml
+++ b/tests/auto/quick/qquickflipable/data/crash.qml
diff --git a/tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml b/tests/auto/quick/qquickflipable/data/flipable-abort.qml
index 90fc03a5f9..90fc03a5f9 100644
--- a/tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml
+++ b/tests/auto/quick/qquickflipable/data/flipable-abort.qml
diff --git a/tests/auto/qtquick2/qquickflipable/data/test-flipable.qml b/tests/auto/quick/qquickflipable/data/test-flipable.qml
index dff6d3fe39..dff6d3fe39 100644
--- a/tests/auto/qtquick2/qquickflipable/data/test-flipable.qml
+++ b/tests/auto/quick/qquickflipable/data/test-flipable.qml
diff --git a/tests/auto/quick/qquickflipable/qquickflipable.pro b/tests/auto/quick/qquickflipable/qquickflipable.pro
new file mode 100644
index 0000000000..ca98cbe279
--- /dev/null
+++ b/tests/auto/quick/qquickflipable/qquickflipable.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickflipable
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickflipable.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
new file mode 100644
index 0000000000..2f399359ef
--- /dev/null
+++ b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickflipable_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <QFontMetrics>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <math.h>
+#include <QtOpenGL/QGLShaderProgram>
+#include "../../shared/util.h"
+
+class tst_qquickflipable : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void create();
+ void checkFrontAndBack();
+ void setFrontAndBack();
+
+ // below here task issues
+ void QTBUG_9161_crash();
+ void QTBUG_8474_qgv_abort();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qquickflipable::create()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-flipable.qml"));
+ QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ delete obj;
+}
+
+void tst_qquickflipable::checkFrontAndBack()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-flipable.qml"));
+ QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->front() != 0);
+ QVERIFY(obj->back() != 0);
+ delete obj;
+}
+
+void tst_qquickflipable::setFrontAndBack()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-flipable.qml"));
+ QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->front() != 0);
+ QVERIFY(obj->back() != 0);
+
+ QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ obj->setFront(new QQuickRectangle());
+
+ message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ obj->setBack(new QQuickRectangle());
+ delete obj;
+}
+
+void tst_qquickflipable::QTBUG_9161_crash()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("crash.qml"));
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+ canvas->show();
+ delete canvas;
+}
+
+void tst_qquickflipable::QTBUG_8474_qgv_abort()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("flipable-abort.qml"));
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+ canvas->show();
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickflipable)
+
+#include "tst_qquickflipable.moc"
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml b/tests/auto/quick/qquickfocusscope/data/canvasFocus.qml
index 7d8dac5a22..7d8dac5a22 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml
+++ b/tests/auto/quick/qquickfocusscope/data/canvasFocus.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/chain.qml b/tests/auto/quick/qquickfocusscope/data/chain.qml
index 4b96662318..4b96662318 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/chain.qml
+++ b/tests/auto/quick/qquickfocusscope/data/chain.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml b/tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml
index 74d2106888..74d2106888 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml
+++ b/tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml b/tests/auto/quick/qquickfocusscope/data/forcefocus.qml
index f41582a951..f41582a951 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml
+++ b/tests/auto/quick/qquickfocusscope/data/forcefocus.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml b/tests/auto/quick/qquickfocusscope/data/qtBug13380.qml
index 29de046b38..29de046b38 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml
+++ b/tests/auto/quick/qquickfocusscope/data/qtBug13380.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml b/tests/auto/quick/qquickfocusscope/data/signalEmission.qml
index 999a40c5ad..999a40c5ad 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml
+++ b/tests/auto/quick/qquickfocusscope/data/signalEmission.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test.qml b/tests/auto/quick/qquickfocusscope/data/test.qml
index 67be29c3fb..67be29c3fb 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test2.qml b/tests/auto/quick/qquickfocusscope/data/test2.qml
index ad74f3e9f4..ad74f3e9f4 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test2.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test2.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test3.qml b/tests/auto/quick/qquickfocusscope/data/test3.qml
index 537c30816e..537c30816e 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test3.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test3.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test4.qml b/tests/auto/quick/qquickfocusscope/data/test4.qml
index 0eea649f5d..0eea649f5d 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test4.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test4.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test5.qml b/tests/auto/quick/qquickfocusscope/data/test5.qml
index 9c37cd1303..9c37cd1303 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test5.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test5.qml
diff --git a/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro b/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro
new file mode 100644
index 0000000000..34de32b173
--- /dev/null
+++ b/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickfocusscope
+SOURCES += tst_qquickfocusscope.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
new file mode 100644
index 0000000000..3571392b17
--- /dev/null
+++ b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
@@ -0,0 +1,636 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qquicktextedit_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickfocusscope_p.h>
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickfocusscope : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickfocusscope() {}
+
+private slots:
+ void basic();
+ void nested();
+ void noFocus();
+ void textEdit();
+ void forceFocus();
+ void noParentFocus();
+ void signalEmission();
+ void qtBug13380();
+ void forceActiveFocus();
+ void canvasFocus();
+};
+
+void tst_qquickfocusscope::basic()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("test.qml"));
+
+ QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
+ QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(view->isTopLevel());
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::qWait(50);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QTest::qWait(50);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::nested()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("test2.qml"));
+
+ QQuickFocusScope *item1 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item1"));
+ QQuickFocusScope *item2 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item2"));
+ QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
+ QQuickFocusScope *item4 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item4"));
+ QQuickFocusScope *item5 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item5"));
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+ QVERIFY(item4 != 0);
+ QVERIFY(item5 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == true);
+ QVERIFY(item4->hasActiveFocus() == true);
+ QVERIFY(item5->hasActiveFocus() == true);
+ delete view;
+}
+
+void tst_qquickfocusscope::noFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("test4.qml"));
+
+ QQuickRectangle *item0 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item0"));
+ QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::textEdit()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("test5.qml"));
+
+ QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
+ QQuickTextEdit *item1 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickTextEdit *item3 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::forceFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("forcefocus.qml"));
+
+ QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
+ QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
+ QQuickRectangle *item4 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item4"));
+ QQuickRectangle *item5 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item5"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+ QVERIFY(item4 != 0);
+ QVERIFY(item5 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_4);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_5);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == true);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::noParentFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("chain.qml"));
+ QVERIFY(view->rootObject());
+
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(view->rootObject()->property("focus1") == false);
+ QVERIFY(view->rootObject()->property("focus2") == false);
+ QVERIFY(view->rootObject()->property("focus3") == true);
+ QVERIFY(view->rootObject()->property("focus4") == true);
+ QVERIFY(view->rootObject()->property("focus5") == true);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::signalEmission()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("signalEmission.qml"));
+
+ QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
+ QQuickRectangle *item4 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item4"));
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+ QVERIFY(item4 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVariant blue(QColor("blue"));
+ QVariant red(QColor("red"));
+
+ item1->setFocus(true);
+ QCOMPARE(item1->property("color"), red);
+ QCOMPARE(item2->property("color"), blue);
+ QCOMPARE(item3->property("color"), blue);
+ QCOMPARE(item4->property("color"), blue);
+
+ item2->setFocus(true);
+ QCOMPARE(item1->property("color"), blue);
+ QCOMPARE(item2->property("color"), red);
+ QCOMPARE(item3->property("color"), blue);
+ QCOMPARE(item4->property("color"), blue);
+
+ item3->setFocus(true);
+ QCOMPARE(item1->property("color"), blue);
+ QCOMPARE(item2->property("color"), red);
+ QCOMPARE(item3->property("color"), red);
+ QCOMPARE(item4->property("color"), blue);
+
+ item4->setFocus(true);
+ QCOMPARE(item1->property("color"), blue);
+ QCOMPARE(item2->property("color"), red);
+ QCOMPARE(item3->property("color"), blue);
+ QCOMPARE(item4->property("color"), red);
+
+ item4->setFocus(false);
+ QCOMPARE(item1->property("color"), blue);
+ QCOMPARE(item2->property("color"), red);
+ QCOMPARE(item3->property("color"), blue);
+ QCOMPARE(item4->property("color"), blue);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::qtBug13380()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("qtBug13380.qml"));
+
+ view->show();
+ QVERIFY(view->rootObject());
+ view->requestActivateWindow();
+ qApp->processEvents();
+
+ QTest::qWaitForWindowShown(view);
+
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QVERIFY(view->rootObject()->property("noFocus").toBool());
+
+ view->rootObject()->setProperty("showRect", true);
+ QVERIFY(view->rootObject()->property("noFocus").toBool());
+
+ delete view;
+}
+
+void tst_qquickfocusscope::forceActiveFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("forceActiveFocus.qml"));
+
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QQuickItem *rootObject = view->rootObject();
+ QVERIFY(rootObject);
+
+ QQuickItem *scope = findItem<QQuickItem>(rootObject, QLatin1String("scope"));
+ QQuickItem *itemA1 = findItem<QQuickItem>(rootObject, QLatin1String("item-a1"));
+ QQuickItem *scopeA = findItem<QQuickItem>(rootObject, QLatin1String("scope-a"));
+ QQuickItem *itemA2 = findItem<QQuickItem>(rootObject, QLatin1String("item-a2"));
+ QQuickItem *itemB1 = findItem<QQuickItem>(rootObject, QLatin1String("item-b1"));
+ QQuickItem *scopeB = findItem<QQuickItem>(rootObject, QLatin1String("scope-b"));
+ QQuickItem *itemB2 = findItem<QQuickItem>(rootObject, QLatin1String("item-b2"));
+
+ QVERIFY(scope);
+ QVERIFY(itemA1);
+ QVERIFY(scopeA);
+ QVERIFY(itemA2);
+ QVERIFY(itemB1);
+ QVERIFY(scopeB);
+ QVERIFY(itemB2);
+
+ QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool)));
+
+ // First, walk the focus from item-a1 down to item-a2 and back again
+ itemA1->forceActiveFocus();
+ QVERIFY(itemA1->hasActiveFocus());
+ QVERIFY(!rootObject->hasActiveFocus());
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ scopeA->forceActiveFocus();
+ QVERIFY(!itemA1->hasActiveFocus());
+ QVERIFY(scopeA->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 1);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ itemA2->forceActiveFocus();
+ QVERIFY(!itemA1->hasActiveFocus());
+ QVERIFY(itemA2->hasActiveFocus());
+ QVERIFY(scopeA->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 1);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ scopeA->forceActiveFocus();
+ QVERIFY(!itemA1->hasActiveFocus());
+ QVERIFY(itemA2->hasActiveFocus());
+ QVERIFY(scopeA->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 1);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ itemA1->forceActiveFocus();
+ QVERIFY(itemA1->hasActiveFocus());
+ QVERIFY(!scopeA->hasActiveFocus());
+ QVERIFY(!itemA2->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 2);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ // Then jump back and forth between branch 'a' and 'b'
+ itemB1->forceActiveFocus();
+ QVERIFY(itemB1->hasActiveFocus());
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ scopeA->forceActiveFocus();
+ QVERIFY(!itemA1->hasActiveFocus());
+ QVERIFY(!itemB1->hasActiveFocus());
+ QVERIFY(scopeA->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 3);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ scopeB->forceActiveFocus();
+ QVERIFY(!scopeA->hasActiveFocus());
+ QVERIFY(!itemB1->hasActiveFocus());
+ QVERIFY(scopeB->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 4);
+ QCOMPARE(scopeBSpy.count(), 1);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ itemA2->forceActiveFocus();
+ QVERIFY(!scopeB->hasActiveFocus());
+ QVERIFY(itemA2->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 5);
+ QCOMPARE(scopeBSpy.count(), 2);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ itemB2->forceActiveFocus();
+ QVERIFY(!itemA2->hasActiveFocus());
+ QVERIFY(itemB2->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 6);
+ QCOMPARE(scopeBSpy.count(), 3);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::canvasFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("canvasFocus.qml"));
+
+ QQuickView alternateView;
+
+ QQuickItem *rootObject = view->rootObject();
+ QVERIFY(rootObject);
+
+ QQuickItem *rootItem = view->rootItem();
+ QQuickItem *scope1 = findItem<QQuickItem>(rootObject, QLatin1String("scope1"));
+ QQuickItem *item1 = findItem<QQuickItem>(rootObject, QLatin1String("item1"));
+ QQuickItem *scope2 = findItem<QQuickItem>(rootObject, QLatin1String("scope2"));
+ QQuickItem *item2 = findItem<QQuickItem>(rootObject, QLatin1String("item2"));
+
+ QVERIFY(scope1);
+ QVERIFY(item1);
+ QVERIFY(scope2);
+ QVERIFY(item2);
+
+ QSignalSpy rootFocusSpy(rootItem, SIGNAL(focusChanged(bool)));
+ QSignalSpy scope1FocusSpy(scope1, SIGNAL(focusChanged(bool)));
+ QSignalSpy item1FocusSpy(item1, SIGNAL(focusChanged(bool)));
+ QSignalSpy scope2FocusSpy(scope2, SIGNAL(focusChanged(bool)));
+ QSignalSpy item2FocusSpy(item2, SIGNAL(focusChanged(bool)));
+ QSignalSpy rootActiveFocusSpy(rootItem, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scope1ActiveFocusSpy(scope1, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy item1ActiveFocusSpy(item1, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scope2ActiveFocusSpy(scope2, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool)));
+
+ QEXPECT_FAIL("", "QTBUG-22415", Abort);
+ QCOMPARE(rootItem->hasFocus(), false);
+ QCOMPARE(rootItem->hasActiveFocus(), false);
+ QCOMPARE(scope1->hasFocus(), true);
+ QCOMPARE(scope1->hasActiveFocus(), false);
+ QCOMPARE(item1->hasFocus(), true);
+ QCOMPARE(item1->hasActiveFocus(), false);
+ QCOMPARE(scope2->hasFocus(), false);
+ QCOMPARE(scope2->hasActiveFocus(), false);
+ QCOMPARE(item2->hasFocus(), false);
+ QCOMPARE(item2->hasActiveFocus(), false);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ // Now the canvas has focus, active focus given to item1
+ QCOMPARE(rootItem->hasFocus(), true);
+ QCOMPARE(rootItem->hasActiveFocus(), true);
+ QCOMPARE(scope1->hasFocus(), true);
+ QCOMPARE(scope1->hasActiveFocus(), true);
+ QCOMPARE(item1->hasFocus(), true);
+ QCOMPARE(item1->hasActiveFocus(), true);
+ QCOMPARE(scope2->hasFocus(), false);
+ QCOMPARE(scope2->hasActiveFocus(), false);
+ QCOMPARE(item2->hasFocus(), false);
+ QCOMPARE(item2->hasActiveFocus(), false);
+
+ QCOMPARE(rootFocusSpy.count(), 1);
+ QCOMPARE(rootActiveFocusSpy.count(), 1);
+ QCOMPARE(scope1FocusSpy.count(), 0);
+ QCOMPARE(scope1ActiveFocusSpy.count(), 1);
+ QCOMPARE(item1FocusSpy.count(), 0);
+ QCOMPARE(item1ActiveFocusSpy.count(), 1);
+
+
+ // view->hide(); // seemingly doesn't remove focus, so have an another view steal it.
+ alternateView.show();
+ alternateView.requestActivateWindow();
+ QTest::qWaitForWindowShown(&alternateView);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &alternateView);
+
+ QCOMPARE(rootItem->hasFocus(), false);
+ QCOMPARE(rootItem->hasActiveFocus(), false);
+ QCOMPARE(scope1->hasFocus(), true);
+ QCOMPARE(scope1->hasActiveFocus(), false);
+ QCOMPARE(item1->hasFocus(), true);
+ QCOMPARE(item1->hasActiveFocus(), false);
+
+ QCOMPARE(rootFocusSpy.count(), 2);
+ QCOMPARE(rootActiveFocusSpy.count(), 2);
+ QCOMPARE(scope1FocusSpy.count(), 0);
+ QCOMPARE(scope1ActiveFocusSpy.count(), 2);
+ QCOMPARE(item1FocusSpy.count(), 0);
+ QCOMPARE(item1ActiveFocusSpy.count(), 2);
+
+
+ // canvas does not have focus, so item2 will not get active focus
+ item2->forceActiveFocus();
+
+ QCOMPARE(rootItem->hasFocus(), false);
+ QCOMPARE(rootItem->hasActiveFocus(), false);
+ QCOMPARE(scope1->hasFocus(), false);
+ QCOMPARE(scope1->hasActiveFocus(), false);
+ QCOMPARE(item1->hasFocus(), true);
+ QCOMPARE(item1->hasActiveFocus(), false);
+ QCOMPARE(scope2->hasFocus(), true);
+ QCOMPARE(scope2->hasActiveFocus(), false);
+ QCOMPARE(item2->hasFocus(), true);
+ QCOMPARE(item2->hasActiveFocus(), false);
+
+ QCOMPARE(rootFocusSpy.count(), 2);
+ QCOMPARE(rootActiveFocusSpy.count(), 2);
+ QCOMPARE(scope1FocusSpy.count(), 1);
+ QCOMPARE(scope1ActiveFocusSpy.count(), 2);
+ QCOMPARE(item1FocusSpy.count(), 0);
+ QCOMPARE(item1ActiveFocusSpy.count(), 2);
+ QCOMPARE(scope2FocusSpy.count(), 1);
+ QCOMPARE(scope2ActiveFocusSpy.count(), 0);
+ QCOMPARE(item2FocusSpy.count(), 1);
+ QCOMPARE(item2ActiveFocusSpy.count(), 0);
+
+ // give the canvas focus, and item2 will get active focus
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == view);
+
+ QCOMPARE(rootItem->hasFocus(), true);
+ QCOMPARE(rootItem->hasActiveFocus(), true);
+ QCOMPARE(scope2->hasFocus(), true);
+ QCOMPARE(scope2->hasActiveFocus(), true);
+ QCOMPARE(item2->hasFocus(), true);
+ QCOMPARE(item2->hasActiveFocus(), true);
+ QCOMPARE(rootFocusSpy.count(), 3);
+ QCOMPARE(rootActiveFocusSpy.count(), 3);
+ QCOMPARE(scope2FocusSpy.count(), 1);
+ QCOMPARE(scope2ActiveFocusSpy.count(), 1);
+ QCOMPARE(item2FocusSpy.count(), 1);
+ QCOMPARE(item2ActiveFocusSpy.count(), 1);
+
+ delete view;
+}
+
+QTEST_MAIN(tst_qquickfocusscope)
+
+#include "tst_qquickfocusscope.moc"
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf b/tests/auto/quick/qquickfontloader/data/daniel.ttf
index aae50d5035..aae50d5035 100644
--- a/tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf
+++ b/tests/auto/quick/qquickfontloader/data/daniel.ttf
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf b/tests/auto/quick/qquickfontloader/data/dummy.ttf
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf
+++ b/tests/auto/quick/qquickfontloader/data/dummy.ttf
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml
index 0eafdfa17b..0eafdfa17b 100644
--- a/tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml
+++ b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml
diff --git a/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf b/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf
new file mode 100644
index 0000000000..cf93f9651f
--- /dev/null
+++ b/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf
Binary files differ
diff --git a/tests/auto/quick/qquickfontloader/qquickfontloader.pro b/tests/auto/quick/qquickfontloader/qquickfontloader.pro
new file mode 100644
index 0000000000..7c34c43d04
--- /dev/null
+++ b/tests/auto/quick/qquickfontloader/qquickfontloader.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickfontloader
+macx:CONFIG -= app_bundle
+
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickfontloader.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
new file mode 100644
index 0000000000..d8f368cf3e
--- /dev/null
+++ b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
@@ -0,0 +1,255 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/private/qquickfontloader_p.h>
+#include "../../shared/util.h"
+#include "../../shared/testhttpserver.h"
+#include <QtQuick/QQuickView>
+#include <QtQuick/QQuickItem>
+
+#define SERVER_PORT 14448
+
+class tst_qquickfontloader : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickfontloader();
+
+private slots:
+ void initTestCase();
+ void noFont();
+ void namedFont();
+ void localFont();
+ void failLocalFont();
+ void webFont();
+ void redirWebFont();
+ void failWebFont();
+ void changeFont();
+ void changeFontSourceViaState();
+
+private:
+ QQmlEngine engine;
+ TestHTTPServer server;
+};
+
+tst_qquickfontloader::tst_qquickfontloader() :
+ server(SERVER_PORT)
+{
+}
+
+void tst_qquickfontloader::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ server.serveDirectory(dataDirectory());
+ QVERIFY(server.isValid());
+}
+
+void tst_qquickfontloader::noFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QCOMPARE(fontObject->name(), QString(""));
+ QCOMPARE(fontObject->source(), QUrl(""));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Null);
+
+ delete fontObject;
+}
+
+void tst_qquickfontloader::namedFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QCOMPARE(fontObject->source(), QUrl(""));
+ QCOMPARE(fontObject->name(), QString("Helvetica"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+}
+
+void tst_qquickfontloader::localFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+}
+
+void tst_qquickfontloader::failLocalFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }";
+ QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData());
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Error);
+}
+
+void tst_qquickfontloader::webFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }";
+ QQmlComponent component(&engine);
+
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+}
+
+void tst_qquickfontloader::redirWebFont()
+{
+ server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
+
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }";
+ QQmlComponent component(&engine);
+
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+}
+
+void tst_qquickfontloader::failWebFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }";
+ QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\"");
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Error);
+}
+
+void tst_qquickfontloader::changeFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+
+ QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged()));
+ QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
+
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 0);
+ QCOMPARE(statusSpy.count(), 0);
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Loading);
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 1);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+
+ ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 2);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 3);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+}
+
+void tst_qquickfontloader::changeFontSourceViaState()
+{
+ QQuickView canvas(testFileUrl("qtbug-20268.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(qvariant_cast<QObject *>(canvas.rootObject()->property("fontloader")));
+ QVERIFY(fontObject != 0);
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ canvas.rootObject()->setProperty("usename", true);
+
+ // This warning should probably not be printed once QTBUG-20268 is fixed
+ QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) +
+ QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\"");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QEXPECT_FAIL("", "QTBUG-20268", Abort);
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QCOMPARE(canvas.rootObject()->property("name").toString(), QString("Tahoma"));
+}
+
+QTEST_MAIN(tst_qquickfontloader)
+
+#include "tst_qquickfontloader.moc"
diff --git a/tests/auto/qtquick2/qquickgridview/data/ComponentView.qml b/tests/auto/quick/qquickgridview/data/ComponentView.qml
index 12ab6c92d1..12ab6c92d1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/ComponentView.qml
+++ b/tests/auto/quick/qquickgridview/data/ComponentView.qml
diff --git a/tests/auto/quick/qquickgridview/data/addTransitions.qml b/tests/auto/quick/qquickgridview/data/addTransitions.qml
new file mode 100644
index 0000000000..3f47cbd7b7
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/addTransitions.qml
@@ -0,0 +1,129 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 550
+ height: 600
+
+ property int duration: 10
+ property int count: grid.count
+
+ Component {
+ id: myDelegate
+
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text {
+ text: wrapper.x + ", " + wrapper.y
+ }
+ Text {
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionFrom)
+ model_targetItems_transitionFrom.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ GridView {
+ id: grid
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ anchors.centerIn: parent
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ add: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
+ }
+
+ ScriptAction { script: grid.targetTransitionsDone += 1 }
+ }
+ }
+
+ addDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
+ NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: grid.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: grid
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquickgridview/data/asyncloader.qml b/tests/auto/quick/qquickgridview/data/asyncloader.qml
index ab66f20a1e..ab66f20a1e 100644
--- a/tests/auto/qtquick2/qquickgridview/data/asyncloader.qml
+++ b/tests/auto/quick/qquickgridview/data/asyncloader.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/attachedSignals.qml b/tests/auto/quick/qquickgridview/data/attachedSignals.qml
index 73c10d8caf..73c10d8caf 100644
--- a/tests/auto/qtquick2/qquickgridview/data/attachedSignals.qml
+++ b/tests/auto/quick/qquickgridview/data/attachedSignals.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/creationContext.qml b/tests/auto/quick/qquickgridview/data/creationContext.qml
index 79a682788b..79a682788b 100644
--- a/tests/auto/qtquick2/qquickgridview/data/creationContext.qml
+++ b/tests/auto/quick/qquickgridview/data/creationContext.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml b/tests/auto/quick/qquickgridview/data/displacedTransitions.qml
index d9353c0639..d9353c0639 100644
--- a/tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml
+++ b/tests/auto/quick/qquickgridview/data/displacedTransitions.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/displaygrid.qml b/tests/auto/quick/qquickgridview/data/displaygrid.qml
index 1da4fe50ac..1da4fe50ac 100644
--- a/tests/auto/qtquick2/qquickgridview/data/displaygrid.qml
+++ b/tests/auto/quick/qquickgridview/data/displaygrid.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/footer.qml b/tests/auto/quick/qquickgridview/data/footer.qml
index 9083f9f57c..9083f9f57c 100644
--- a/tests/auto/qtquick2/qquickgridview/data/footer.qml
+++ b/tests/auto/quick/qquickgridview/data/footer.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview-enforcerange.qml b/tests/auto/quick/qquickgridview/data/gridview-enforcerange.qml
index 2bfe7da78e..2bfe7da78e 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview-enforcerange.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview-enforcerange.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview-initCurrent.qml b/tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml
index 624f639962..624f639962 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview-initCurrent.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview-noCurrent.qml b/tests/auto/quick/qquickgridview/data/gridview-noCurrent.qml
index 600716e2d4..600716e2d4 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview-noCurrent.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview-noCurrent.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview1.qml b/tests/auto/quick/qquickgridview/data/gridview1.qml
index 4bf6f0b952..4bf6f0b952 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview1.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview1.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview2.qml b/tests/auto/quick/qquickgridview/data/gridview2.qml
index 5fb45a1613..5fb45a1613 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview2.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview2.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview3.qml b/tests/auto/quick/qquickgridview/data/gridview3.qml
index a8c1c5a0f7..a8c1c5a0f7 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview3.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview3.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview4.qml b/tests/auto/quick/qquickgridview/data/gridview4.qml
index eed3a2bdb1..eed3a2bdb1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview4.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview4.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/header.qml b/tests/auto/quick/qquickgridview/data/header.qml
index 648e2a2298..648e2a2298 100644
--- a/tests/auto/qtquick2/qquickgridview/data/header.qml
+++ b/tests/auto/quick/qquickgridview/data/header.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/manual-highlight.qml b/tests/auto/quick/qquickgridview/data/manual-highlight.qml
index c2f1d20fb1..c2f1d20fb1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/manual-highlight.qml
+++ b/tests/auto/quick/qquickgridview/data/manual-highlight.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/margins.qml b/tests/auto/quick/qquickgridview/data/margins.qml
index d369658a91..d369658a91 100644
--- a/tests/auto/qtquick2/qquickgridview/data/margins.qml
+++ b/tests/auto/quick/qquickgridview/data/margins.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/mirroring.qml b/tests/auto/quick/qquickgridview/data/mirroring.qml
index b9aff501c1..b9aff501c1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/mirroring.qml
+++ b/tests/auto/quick/qquickgridview/data/mirroring.qml
diff --git a/tests/auto/quick/qquickgridview/data/moveTransitions.qml b/tests/auto/quick/qquickgridview/data/moveTransitions.qml
new file mode 100644
index 0000000000..a91f5a3295
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/moveTransitions.qml
@@ -0,0 +1,143 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: grid.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text {
+ text: wrapper.x + ", " + wrapper.y
+ }
+ Text {
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionVia)
+ model_targetItems_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ GridView {
+ id: grid
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ anchors.centerIn: parent
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ move: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: targetItems_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: targetItems_transitionVia.y; duration: root.duration }
+ }
+
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: grid.targetTransitionsDone += 1 }
+ }
+ }
+
+ moveDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "x"; duration: root.duration
+ to: displacedItems_transitionVia.x
+ }
+ NumberAnimation {
+ properties: "y"; duration: root.duration
+ to: displacedItems_transitionVia.y
+ }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: grid.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: grid
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml b/tests/auto/quick/qquickgridview/data/multipleTransitions.qml
index 909ec3a0b7..909ec3a0b7 100644
--- a/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml
+++ b/tests/auto/quick/qquickgridview/data/multipleTransitions.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/populateTransitions.qml b/tests/auto/quick/qquickgridview/data/populateTransitions.qml
index c12d5ac39d..c12d5ac39d 100644
--- a/tests/auto/qtquick2/qquickgridview/data/populateTransitions.qml
+++ b/tests/auto/quick/qquickgridview/data/populateTransitions.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/propertychangestest.qml b/tests/auto/quick/qquickgridview/data/propertychangestest.qml
index 97efbe78f5..97efbe78f5 100644
--- a/tests/auto/qtquick2/qquickgridview/data/propertychangestest.qml
+++ b/tests/auto/quick/qquickgridview/data/propertychangestest.qml
diff --git a/tests/auto/quick/qquickgridview/data/removeTransitions.qml b/tests/auto/quick/qquickgridview/data/removeTransitions.qml
new file mode 100644
index 0000000000..3e82cf7f96
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/removeTransitions.qml
@@ -0,0 +1,146 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: grid.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text {
+ text: wrapper.x + ", " + wrapper.y
+ }
+ Text {
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionTo) {
+ model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item
+ }
+ if (Qt.point(x, y) == displacedItems_transitionVia) {
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+ }
+
+ GridView {
+ id: grid
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ anchors.centerIn: parent
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ remove: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: targetItems_transitionTo.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: targetItems_transitionTo.y; duration: root.duration }
+ }
+ ScriptAction { script: grid.targetTransitionsDone += 1 }
+
+ // delay deleting this item so that it stays valid for the tests
+ // (this doesn't delay the test itself)
+ PauseAnimation { duration: 10000 }
+ }
+ }
+
+ removeDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "x"; duration: root.duration
+ to: displacedItems_transitionVia.x
+ }
+ NumberAnimation {
+ properties: "y"; duration: root.duration
+ to: displacedItems_transitionVia.y
+ }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: grid.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: grid
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquickgridview/data/resizeview.qml b/tests/auto/quick/qquickgridview/data/resizeview.qml
index 130a0defc1..130a0defc1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/resizeview.qml
+++ b/tests/auto/quick/qquickgridview/data/resizeview.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/setindex.qml b/tests/auto/quick/qquickgridview/data/setindex.qml
index ef80f3a2fb..ef80f3a2fb 100644
--- a/tests/auto/qtquick2/qquickgridview/data/setindex.qml
+++ b/tests/auto/quick/qquickgridview/data/setindex.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/snapOneRow.qml b/tests/auto/quick/qquickgridview/data/snapOneRow.qml
index 3d32d75c45..3d32d75c45 100644
--- a/tests/auto/qtquick2/qquickgridview/data/snapOneRow.qml
+++ b/tests/auto/quick/qquickgridview/data/snapOneRow.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/snapToRow.qml b/tests/auto/quick/qquickgridview/data/snapToRow.qml
index f079a048f0..f079a048f0 100644
--- a/tests/auto/qtquick2/qquickgridview/data/snapToRow.qml
+++ b/tests/auto/quick/qquickgridview/data/snapToRow.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/unaligned.qml b/tests/auto/quick/qquickgridview/data/unaligned.qml
index 445400e8b4..445400e8b4 100644
--- a/tests/auto/qtquick2/qquickgridview/data/unaligned.qml
+++ b/tests/auto/quick/qquickgridview/data/unaligned.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/unrequestedItems.qml b/tests/auto/quick/qquickgridview/data/unrequestedItems.qml
index 79f845fd25..79f845fd25 100644
--- a/tests/auto/qtquick2/qquickgridview/data/unrequestedItems.qml
+++ b/tests/auto/quick/qquickgridview/data/unrequestedItems.qml
diff --git a/tests/auto/quick/qquickgridview/qquickgridview.pro b/tests/auto/quick/qquickgridview/qquickgridview.pro
new file mode 100644
index 0000000000..cabf4396b4
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/qquickgridview.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickgridview
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickgridview.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib widgets
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
new file mode 100644
index 0000000000..c0f2b02a7e
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -0,0 +1,5310 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/qstringlistmodel.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquickgridview_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickvisualitemmodel_p.h>
+#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qlistmodelinterface_p.h>
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+#include <QtGui/qguiapplication.h>
+
+Q_DECLARE_METATYPE(Qt::LayoutDirection)
+Q_DECLARE_METATYPE(QQuickGridView::Flow)
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+class tst_QQuickGridView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickGridView();
+
+private slots:
+ void items();
+ void changed();
+ void inserted();
+ void inserted_more();
+ void inserted_more_data();
+ void insertBeforeVisible();
+ void insertBeforeVisible_data();
+ void removed();
+ void removed_more();
+ void removed_more_data();
+ void addOrRemoveBeforeVisible();
+ void addOrRemoveBeforeVisible_data();
+ void clear();
+ void moved();
+ void moved_data();
+ void multipleChanges();
+ void multipleChanges_data();
+ void swapWithFirstItem();
+ void changeFlow();
+ void currentIndex();
+ void noCurrentIndex();
+ void defaultValues();
+ void properties();
+ void propertyChanges();
+ void componentChanges();
+ void modelChanges();
+ void positionViewAtIndex();
+ void positionViewAtIndex_rightToLeft();
+ void mirroring();
+ void snapping();
+ void resetModel();
+ void enforceRange();
+ void enforceRange_rightToLeft();
+ void QTBUG_8456();
+ void manualHighlight();
+ void footer();
+ void footer_data();
+ void header();
+ void header_data();
+ void resizeViewAndRepaint();
+ void changeColumnCount();
+ void indexAt_itemAt_data();
+ void indexAt_itemAt();
+ void onAdd();
+ void onAdd_data();
+ void onRemove();
+ void onRemove_data();
+ void columnCount();
+ void margins();
+ void creationContext();
+ void snapToRow_data();
+ void snapToRow();
+ void snapOneRow_data();
+ void snapOneRow();
+ void unaligned();
+ void cacheBuffer();
+ void asynchronous();
+ void unrequestedVisibility();
+
+ void populateTransitions();
+ void populateTransitions_data();
+ void addTransitions();
+ void addTransitions_data();
+ void moveTransitions();
+ void moveTransitions_data();
+ void removeTransitions();
+ void removeTransitions_data();
+ void displacedTransitions();
+ void displacedTransitions_data();
+ void multipleTransitions();
+ void multipleTransitions_data();
+
+private:
+ QList<int> toIntList(const QVariantList &list);
+ void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
+ void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
+ void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
+};
+
+tst_QQuickGridView::tst_QQuickGridView()
+{
+}
+
+void tst_QQuickGridView::items()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(gridview->count(), model.count());
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ // set an empty model and confirm that items are destroyed
+ QaimModel model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QTRY_VERIFY(itemCount == 0);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::changed()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickFlickable *gridview = findItem<QQuickFlickable>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ model.modifyItem(1, "Will", "9876");
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::inserted()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ // Checks that onAdd is called
+ int added = canvas->rootObject()->property("added").toInt();
+ QTRY_COMPARE(added, 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ QTRY_COMPARE(gridview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+
+ gridview->setContentY(120);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+
+ QTRY_VERIFY(gridview->contentY() == 120);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::inserted_more()
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, insertIndex);
+ QFETCH(int, insertCount);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QList<QPair<QString, QString> > newData;
+ for (int i=0; i<insertCount; i++)
+ newData << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.insertItems(insertIndex, newData);
+ QTRY_COMPARE(gridview->property("count").toInt(), model.count());
+
+ // check visibleItems.first() is in correct position
+ QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item0);
+ QCOMPARE(item0->y(), 0.0);
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QQuickText *name;
+ QQuickText *number;
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::inserted_more_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("insertCount");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ QTest::newRow("add 1, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 1
+ << 0.0; // insert 1 above first visible, grid is rearranged; first visible moves forward within its row
+ // new 1st visible item is at 0
+
+ QTest::newRow("add 2, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 2
+ << 0.0; // insert 2 above first visible, grid is rearranged; first visible moves forward within its row
+
+ QTest::newRow("add 3, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 3
+ << -60.0; // insert 3 (1 row) above first visible in negative pos, first visible does not move
+
+ QTest::newRow("add 5, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 5
+ << -60.0; // insert 1 row + 2 items above first visible, 1 row added at negative pos,
+ // grid is rearranged and first visible moves forward within its row
+
+ QTest::newRow("add 6, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 6
+ << -60.0 * 2; // insert 2 rows above first visible in negative pos, first visible does not move
+
+
+
+ QTest::newRow("add 1, at start of visible, content at start")
+ << 0.0
+ << 0 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at start of visible, content at start")
+ << 0.0
+ << 0 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, at start of visible, content not at start")
+ << 120.0 // show 6-23
+ << 6 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at start of visible, content not at start")
+ << 120.0 // show 6-23
+ << 6 << 3
+ << 0.0;
+
+
+ QTest::newRow("add 1, at end of visible, content at start")
+ << 0.0
+ << 17 << 1
+ << 0.0;
+
+ QTest::newRow("add 1, at end of visible, content at start")
+ << 0.0
+ << 17 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, at end of visible, content not at start")
+ << 120.0 // show 6-23
+ << 23 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at end of visible, content not at start")
+ << 120.0 // show 6-23
+ << 23 << 3
+ << 0.0;
+
+
+ QTest::newRow("add 1, after visible, content at start")
+ << 0.0
+ << 20 << 1
+ << 0.0;
+
+ QTest::newRow("add 1, after visible, content at start")
+ << 0.0
+ << 20 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, after visible, content not at start")
+ << 120.0 // show 6-23
+ << 24 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, after visible, content not at start")
+ << 120.0 // show 6-23
+ << 24 << 3
+ << 0.0;
+}
+
+void tst_QQuickGridView::insertBeforeVisible()
+{
+ QFETCH(int, insertIndex);
+ QFETCH(int, insertCount);
+ QFETCH(int, cacheBuffer);
+
+ QQuickText *name;
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ gridview->setCacheBuffer(cacheBuffer);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // trigger a refill (not just setting contentY) so that the visibleItems grid is updated
+ int firstVisibleIndex = 12; // move to an index where the top item is not visible
+ gridview->setContentY(firstVisibleIndex/3 * 60.0);
+ gridview->setCurrentIndex(firstVisibleIndex);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QTRY_COMPARE(gridview->currentIndex(), firstVisibleIndex);
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
+ QVERIFY(item);
+ QCOMPARE(item->y(), gridview->contentY());
+
+ QList<QPair<QString, QString> > newData;
+ for (int i=0; i<insertCount; i++)
+ newData << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.insertItems(insertIndex, newData);
+ QTRY_COMPARE(gridview->property("count").toInt(), model.count());
+
+ // now, moving to the top of the view should position the inserted items correctly
+ int itemsOffsetAfterMove = (insertCount / 3) * -60.0;
+ gridview->setCurrentIndex(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::insertBeforeVisible_data()
+{
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("insertCount");
+ QTest::addColumn<int>("cacheBuffer");
+
+ QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0;
+ QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100;
+ QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500;
+
+ QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0;
+ QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100;
+ QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500;
+
+ QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 6 << 0;
+ QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 6 << 100;
+ QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 6 << 500;
+
+ QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 6 << 0;
+ QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 6 << 100;
+ QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 6 << 500;
+}
+
+void tst_QQuickGridView::removed()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ model.removeItem(1);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+
+ // Checks that onRemove is called
+ QString removed = canvas->rootObject()->property("removed").toString();
+ QTRY_COMPARE(removed, QString("Item1"));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove items not visible
+ model.removeItem(25);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove items before visible
+ gridview->setContentY(120);
+ gridview->setCurrentIndex(10);
+
+ // Setting currentIndex above shouldn't cause view to scroll
+ QTRY_COMPARE(gridview->contentY(), 120.0);
+
+ model.removeItem(1);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ // Confirm items positioned correctly
+ for (int i = 6; i < 18; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove currentIndex
+ QQuickItem *oldCurrent = gridview->currentItem();
+ model.removeItem(9);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QTRY_COMPARE(gridview->currentIndex(), 9);
+ QTRY_VERIFY(gridview->currentItem() != oldCurrent);
+
+ gridview->setContentY(0);
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // remove item outside current view.
+ gridview->setCurrentIndex(32);
+ gridview->setContentY(240);
+
+ model.removeItem(30);
+ QTRY_VERIFY(gridview->currentIndex() == 31);
+
+ // remove current item beyond visible items.
+ gridview->setCurrentIndex(20);
+ gridview->setContentY(0);
+ model.removeItem(20);
+
+ QTRY_COMPARE(gridview->currentIndex(), 20);
+ QTRY_VERIFY(gridview->currentItem() != 0);
+
+ // remove item before current, but visible
+ gridview->setCurrentIndex(8);
+ gridview->setContentY(240);
+ oldCurrent = gridview->currentItem();
+ model.removeItem(6);
+
+ QTRY_COMPARE(gridview->currentIndex(), 7);
+ QTRY_VERIFY(gridview->currentItem() == oldCurrent);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::removed_more()
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, removeIndex);
+ QFETCH(int, removeCount);
+ QFETCH(qreal, itemsOffsetAfterMove);
+ QFETCH(QString, firstVisible);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ model.removeItems(removeIndex, removeCount);
+ QTRY_COMPARE(gridview->property("count").toInt(), model.count());
+
+ QString firstName;
+ int firstVisibleIndex = -1;
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ QQmlExpression en(qmlContext(items[i]), items[i], "name");
+ firstName = en.evaluate().toString();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+ QCOMPARE(firstName, firstVisible);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::removed_more_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("removeIndex");
+ QTest::addColumn<int>("removeCount");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+ QTest::addColumn<QString>("firstVisible");
+
+ QTest::newRow("remove 1, before visible items")
+ << 120.0 // show 6-23
+ << 2 << 1
+ << 0.0 << "Item7";
+
+ QTest::newRow("remove 1, before visible position")
+ << 120.0 // show 6-23
+ << 3 << 1
+ << 0.0 << "Item7";
+
+ QTest::newRow("remove multiple, all before visible items")
+ << 120.0
+ << 1 << 3
+ << 60.0 << "Item6"; // removed top row, slide down by 1 row
+
+ QTest::newRow("remove multiple, all before visible items, remove item 0")
+ << 120.0
+ << 0 << 4
+ << 60.0 << "Item7"; // removed top row, slide down by 1 row
+
+ QTest::newRow("remove multiple rows, all before visible items")
+ << 240.0 // show 12-29
+ << 1 << 7
+ << 120.0 << "Item13";
+
+ QTest::newRow("remove one row before visible, content y not on item border")
+ << 100.0
+ << 0 << 3
+ << 60.0 << "Item6"; // 1 row removed
+
+ QTest::newRow("remove mix of visible/non-visible")
+ << 120.0 // show 6-23
+ << 2 << 3
+ << 60.0 << "Item6"; // 1 row removed
+
+
+ // remove 3,4,5 before the visible pos, first row moves down to just before the visible pos,
+ // items 6,7 are removed from view, item 8 slides up to original pos of item 6 (120px)
+ QTest::newRow("remove multiple, mix of items from before and within visible items")
+ << 120.0
+ << 3 << 5
+ << 60.0 << "Item8"; // adjust for the 1 row removed before the visible
+
+ QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0")
+ << 120.0
+ << 0 << 8
+ << 60.0 * 2 << "Item8"; // adjust for the 2 rows removed before the visible
+
+
+ QTest::newRow("remove 1, from start of visible, content at start")
+ << 0.0
+ << 0 << 1
+ << 0.0 << "Item1";
+
+ QTest::newRow("remove multiple, from start of visible, content at start")
+ << 0.0
+ << 0 << 3
+ << 0.0 << "Item3";
+
+ QTest::newRow("remove 1, from start of visible, content not at start")
+ << 120.0 // show 6-23
+ << 4 << 1
+ << 0.0 << "Item7";
+
+ QTest::newRow("remove multiple, from start of visible, content not at start")
+ << 120.0 // show 6-23
+ << 4 << 3
+ << 0.0 << "Item9";
+
+
+ QTest::newRow("remove 1, from middle of visible, content at start")
+ << 0.0
+ << 10 << 1
+ << 0.0 << "Item0";
+
+ QTest::newRow("remove multiple, from middle of visible, content at start")
+ << 0.0
+ << 10 << 5
+ << 0.0 << "Item0";
+
+ QTest::newRow("remove 1, from middle of visible, content not at start")
+ << 120.0 // show 6-23
+ << 10 << 1
+ << 0.0 << "Item6";
+
+ QTest::newRow("remove multiple, from middle of visible, content not at start")
+ << 120.0 // show 6-23
+ << 10 << 5
+ << 0.0 << "Item6";
+
+
+ QTest::newRow("remove 1, after visible, content at start")
+ << 0.0
+ << 16 << 1
+ << 0.0 << "Item0";
+
+ QTest::newRow("remove multiple, after visible, content at start")
+ << 0.0
+ << 16 << 5
+ << 0.0 << "Item0";
+
+ QTest::newRow("remove 1, after visible, content not at start")
+ << 120.0 // show 6-23
+ << 16+4 << 1
+ << 0.0 << "Item6";
+
+ QTest::newRow("remove multiple, after visible, content not at start")
+ << 120.0 // show 6-23
+ << 16+4 << 5
+ << 0.0 << "Item6";
+
+ QTest::newRow("remove multiple, mix of items from within and after visible items")
+ << 120.0 // show 6-23
+ << 20 << 5
+ << 0.0 << "Item6";
+}
+
+void tst_QQuickGridView::addOrRemoveBeforeVisible()
+{
+ // QTBUG-21588: ensure re-layout is done on grid after adding or removing
+ // items from before the visible area
+
+ QFETCH(bool, doAdd);
+ QFETCH(qreal, newTopContentY);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ canvas->setSource(testFileUrl("gridview1.qml"));
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_COMPARE(name->text(), QString("Item0"));
+
+ gridview->setCurrentIndex(0);
+ qApp->processEvents();
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // scroll down until item 0 is no longer drawn
+ // (bug not triggered if we just move using content y, since that doesn't
+ // refill and change the visible items)
+ gridview->setCurrentIndex(24);
+ qApp->processEvents();
+
+ QTRY_COMPARE(gridview->currentIndex(), 24);
+ QTRY_COMPARE(gridview->contentY(), 220.0);
+
+ QTest::qWait(100); // wait for refill to complete
+ QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 0)); // 0 shouldn't be visible
+
+ if (doAdd) {
+ model.insertItem(0, "New Item", "New Item number");
+ QTRY_COMPARE(gridview->count(), 31);
+ } else {
+ model.removeItem(0);
+ QTRY_COMPARE(gridview->count(), 29);
+ }
+
+ // scroll back up and item 0 should be gone
+ gridview->setCurrentIndex(0);
+ qApp->processEvents();
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->contentY(), newTopContentY);
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ if (doAdd)
+ QCOMPARE(name->text(), QString("New Item"));
+ else
+ QCOMPARE(name->text(), QString("Item1"));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", i));
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60 + newTopContentY);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::addOrRemoveBeforeVisible_data()
+{
+ QTest::addColumn<bool>("doAdd");
+ QTest::addColumn<qreal>("newTopContentY");
+
+ QTest::newRow("add") << true << -60.0;
+ QTest::newRow("remove") << false << -60.0;
+}
+
+void tst_QQuickGridView::clear()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ model.clear();
+
+ QVERIFY(gridview->count() == 0);
+ QVERIFY(gridview->currentItem() == 0);
+ QVERIFY(gridview->contentY() == 0);
+ QVERIFY(gridview->currentIndex() == -1);
+
+ // confirm sanity when adding an item to cleared list
+ model.addItem("New", "1");
+ QTRY_COMPARE(gridview->count(), 1);
+ QVERIFY(gridview->currentItem() != 0);
+ QVERIFY(gridview->currentIndex() == 0);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::moved()
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ QQuickText *name;
+ QQuickText *number;
+ QScopedPointer<QQuickView> canvas(createView());
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *currentItem = gridview->currentItem();
+ QTRY_VERIFY(currentItem != 0);
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ model.moveItems(from, to, count);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // Confirm items positioned correctly and indexes correct
+ int firstVisibleIndex = qCeil(contentY / 60.0) * 3;
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ if (i >= firstVisibleIndex + 18) // index has moved out of view
+ continue;
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+
+ // current index should have been updated
+ if (item == currentItem)
+ QTRY_COMPARE(gridview->currentIndex(), i);
+ }
+}
+
+void tst_QQuickGridView::moved_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ // model starts with 30 items, each 80x60, in area 240x320
+ // 18 items should be visible at a time
+
+ // The first visible item should not move upwards and out of the view
+ // if items are moved/removed before it.
+
+
+ QTest::newRow("move 1 forwards, within visible items")
+ << 0.0
+ << 1 << 8 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from non-visible -> visible")
+ << 120.0 // show 6-23
+ << 1 << 23 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)")
+ << 120.0 // // show 6-23
+ << 0 << 6 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from visible -> non-visible")
+ << 0.0
+ << 1 << 20 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)")
+ << 0.0
+ << 0 << 20 << 1
+ << 0.0;
+
+
+ QTest::newRow("move 1 backwards, within visible items")
+ << 0.0
+ << 10 << 5 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, within visible items (to first index)")
+ << 0.0
+ << 10 << 0 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from non-visible -> visible")
+ << 0.0
+ << 28 << 8 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)")
+ << 0.0
+ << 29 << 14 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from visible -> non-visible")
+ << 120.0 // show 6-23
+ << 7 << 1 << 1
+ << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move
+
+ QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)")
+ << 120.0 // show 6-23
+ << 7 << 0 << 1
+ << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move
+
+
+ QTest::newRow("move multiple forwards, within visible items")
+ << 0.0
+ << 0 << 5 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, within visible items (move first item)")
+ << 0.0
+ << 10 << 0 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, before visible items")
+ << 120.0 // show 6-23
+ << 3 << 4 << 3 // 3, 4, 5 move to after 6
+ << 60.0; // row of 3,4,5 has moved down
+
+ QTest::newRow("move multiple forwards, from non-visible -> visible")
+ << 120.0 // show 6-23
+ << 1 << 6 << 3
+ << 60.0; // 1st row (it's above visible area) disappears, 0 drops down 1 row, first visible item (6) stays where it is
+
+ QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)")
+ << 120.0 // show 6-23
+ << 0 << 6 << 3
+ << 60.0; // top row moved and shifted to below 3rd row, all items should shift down by 1 row
+
+ QTest::newRow("move multiple forwards, mix of non-visible/visible")
+ << 120.0
+ << 3 << 16 << 6
+ << 60.0; // top two rows removed, third row is now the first visible
+
+ QTest::newRow("move multiple forwards, to bottom of view")
+ << 0.0
+ << 5 << 13 << 5
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, first row -> last")
+ << 0.0
+ << 0 << 15 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
+ << 120.0
+ << 5+4 << 13+4 << 5
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, from visible -> non-visible")
+ << 0.0
+ << 1 << 16 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)")
+ << 0.0
+ << 0 << 16 << 3
+ << 0.0;
+
+
+ QTest::newRow("move multiple backwards, within visible items")
+ << 0.0
+ << 4 << 1 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from non-visible -> visible")
+ << 0.0
+ << 20 << 4 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)")
+ << 0.0
+ << 27 << 10 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from visible -> non-visible")
+ << 120.0 // show 6-23
+ << 16 << 1 << 3
+ << -60.0; // to minimize movement, items are added above visible area, all items move up by 1 row
+
+ QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)")
+ << 120.0 // show 6-23
+ << 16 << 0 << 3
+ << -60.0; // 16,17,18 move to above item 0, all items move up by 1 row
+}
+
+void tst_QQuickGridView::multipleChanges()
+{
+ QSKIP("QTBUG-24523");
+
+ QFETCH(int, startCount);
+ QFETCH(QList<ListChange>, changes);
+ QFETCH(int, newCount);
+ QFETCH(int, newCurrentIndex);
+
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < startCount; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ for (int i=0; i<changes.count(); i++) {
+ switch (changes[i].type) {
+ case ListChange::Inserted:
+ {
+ QList<QPair<QString, QString> > items;
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ items << qMakePair(QString("new item " + j), QString::number(j));
+ model.insertItems(changes[i].index, items);
+ break;
+ }
+ case ListChange::Removed:
+ model.removeItems(changes[i].index, changes[i].count);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::Moved:
+ model.moveItems(changes[i].index, changes[i].to, changes[i].count);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::SetCurrent:
+ gridview->setCurrentIndex(changes[i].index);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::SetContentY:
+ gridview->setContentY(changes[i].pos);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ }
+ }
+
+ QTRY_COMPARE(gridview->count(), newCount);
+ QCOMPARE(gridview->count(), model.count());
+ QTRY_COMPARE(gridview->currentIndex(), newCurrentIndex);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::multipleChanges_data()
+{
+ QTest::addColumn<int>("startCount");
+ QTest::addColumn<QList<ListChange> >("changes");
+ QTest::addColumn<int>("newCount");
+ QTest::addColumn<int>("newCurrentIndex");
+
+ QList<ListChange> changes;
+
+ for (int i=1; i<30; i++)
+ changes << ListChange::remove(0);
+ QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0;
+
+ changes << ListChange::remove(0);
+ QTest::newRow("remove all") << 30 << changes << 0 << -1;
+
+ changes.clear();
+ changes << ListChange::setCurrent(29);
+ for (int i=29; i>0; i--)
+ changes << ListChange::remove(i);
+ QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0;
+
+ QTest::newRow("remove then insert at 0") << 10 << (QList<ListChange>()
+ << ListChange::remove(0, 1)
+ << ListChange::insert(0, 1)
+ ) << 10 << 1;
+
+ QTest::newRow("remove then insert at non-zero index") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::remove(2, 1)
+ << ListChange::insert(2, 1)
+ ) << 10 << 3;
+
+ QTest::newRow("remove current then insert below it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::remove(1, 3)
+ << ListChange::insert(2, 2)
+ ) << 9 << 1;
+
+ QTest::newRow("remove current index then move it down") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::remove(1, 3)
+ << ListChange::move(1, 5, 1)
+ ) << 7 << 5;
+
+ QTest::newRow("remove current index then move it up") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::remove(4, 3)
+ << ListChange::move(4, 1, 1)
+ ) << 7 << 1;
+
+
+ QTest::newRow("insert multiple times") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 2)
+ << ListChange::insert(0, 4)
+ << ListChange::insert(0, 6)
+ ) << 12 << 10;
+
+ QTest::newRow("insert multiple times with current index changes") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 2)
+ << ListChange::insert(0, 4)
+ << ListChange::insert(0, 6)
+ << ListChange::setCurrent(3)
+ << ListChange::insert(3, 2)
+ ) << 14 << 5;
+
+ QTest::newRow("insert and remove all") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 30)
+ << ListChange::remove(0, 30)
+ ) << 0 << -1;
+
+ QTest::newRow("insert and remove current") << 30 << (QList<ListChange>()
+ << ListChange::insert(1)
+ << ListChange::setCurrent(1)
+ << ListChange::remove(1)
+ ) << 30 << 1;
+
+ QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 10)
+ << ListChange::remove(5, 10)
+ ) << 10 << 5;
+
+ QTest::newRow("insert multiple, then move new items to end") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 3)
+ << ListChange::move(0, 10, 3)
+ ) << 13 << 0;
+
+ QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 3)
+ << ListChange::move(0, 8, 5)
+ ) << 13 << 11;
+
+ QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(9)
+ << ListChange::insert(10, 3)
+ << ListChange::move(8, 0, 5)
+ ) << 13 << 1;
+
+
+ QTest::newRow("move back and forth to same index") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::move(1, 2, 2)
+ << ListChange::move(2, 1, 2)
+ ) << 10 << 1;
+
+ QTest::newRow("move forwards then back") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::move(1, 2, 3)
+ << ListChange::move(3, 0, 5)
+ ) << 10 << 0;
+
+ QTest::newRow("move current, then remove it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 0, 1)
+ << ListChange::remove(0)
+ ) << 9 << 0;
+
+ QTest::newRow("move current, then insert before it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 0, 1)
+ << ListChange::insert(0)
+ ) << 11 << 1;
+
+ QTest::newRow("move multiple, then remove them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::move(5, 1, 3)
+ << ListChange::remove(1, 3)
+ ) << 7 << 1;
+
+ QTest::newRow("move multiple, then insert before them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 1, 3)
+ << ListChange::insert(1, 5)
+ ) << 15 << 6;
+
+ QTest::newRow("move multiple, then insert after them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(3)
+ << ListChange::move(0, 1, 2)
+ << ListChange::insert(3, 5)
+ ) << 15 << 8;
+
+
+ QTest::newRow("clear current") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 5)
+ << ListChange::setCurrent(-1)
+ << ListChange::remove(0, 5)
+ << ListChange::insert(0, 5)
+ ) << 5 << -1;
+}
+
+
+void tst_QQuickGridView::swapWithFirstItem()
+{
+ // QTBUG_9697
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ // ensure content position is stable
+ gridview->setContentY(0);
+ model.moveItem(10, 0);
+ QTRY_VERIFY(gridview->contentY() == 0);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::currentIndex()
+{
+ QaimModel model;
+ for (int i = 0; i < 60; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+ canvas->show();
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QString filename(testFile("gridview-initCurrent.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+ QTRY_VERIFY(!QQuickItemPrivate::get(gridview)->polishScheduled);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ // current item should be third item
+ QCOMPARE(gridview->currentIndex(), 35);
+ QCOMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 35));
+ QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->contentY(), 400.0);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), 36);
+ gridview->moveCurrentIndexDown();
+ QCOMPARE(gridview->currentIndex(), 39);
+ gridview->moveCurrentIndexUp();
+ QCOMPARE(gridview->currentIndex(), 36);
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), 35);
+
+ // wait until motion stops
+ QTRY_VERIFY(gridview->verticalVelocity() == 0.0);
+
+ // no wrap
+ gridview->setCurrentIndex(0);
+ QCOMPARE(gridview->currentIndex(), 0);
+ // confirm that the velocity is updated
+ QTRY_VERIFY(gridview->verticalVelocity() != 0.0);
+
+ gridview->moveCurrentIndexUp();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->setCurrentIndex(model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ gridview->moveCurrentIndexDown();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ // with wrap
+ gridview->setWrapEnabled(true);
+
+ gridview->setCurrentIndex(0);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ qApp->processEvents();
+ QTRY_COMPARE(gridview->contentY(), 880.0);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ QTRY_COMPARE(gridview->contentY(), 0.0);
+
+
+ // footer should become visible if it is out of view, and then current index moves to the first row
+ canvas->rootObject()->setProperty("showFooter", true);
+ QTRY_VERIFY(gridview->footerItem());
+ gridview->setCurrentIndex(model.count()-3);
+ QTRY_VERIFY(gridview->footerItem()->y() > gridview->contentY() + gridview->height());
+ gridview->setCurrentIndex(model.count()-2);
+ QTRY_COMPARE(gridview->contentY() + gridview->height(), (60.0 * model.count()/3) + gridview->footerItem()->height());
+ canvas->rootObject()->setProperty("showFooter", false);
+
+ // header should become visible if it is out of view, and then current index moves to the last row
+ canvas->rootObject()->setProperty("showHeader", true);
+ QTRY_VERIFY(gridview->headerItem());
+ gridview->setCurrentIndex(3);
+ QTRY_VERIFY(gridview->headerItem()->y() + gridview->headerItem()->height() < gridview->contentY());
+ gridview->setCurrentIndex(1);
+ QTRY_COMPARE(gridview->contentY(), -gridview->headerItem()->height());
+ canvas->rootObject()->setProperty("showHeader", false);
+
+
+ // Test keys
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
+
+ gridview->setCurrentIndex(0);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 3);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ // hold down Key_Down
+ for (int i=0; i<(model.count() / 3) - 1; i++) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true);
+ QTRY_COMPARE(gridview->currentIndex(), i*3 + 3);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Down);
+ QTRY_COMPARE(gridview->currentIndex(), 57);
+ QTRY_COMPARE(gridview->contentY(), 880.0);
+
+ // hold down Key_Up
+ for (int i=(model.count() / 3) - 1; i > 0; i--) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true);
+ QTRY_COMPARE(gridview->currentIndex(), i*3 - 3);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Up);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->contentY(), 0.0);
+
+
+ gridview->setFlow(QQuickGridView::TopToBottom);
+
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(qGuiApp->focusWindow() == canvas);
+ qApp->processEvents();
+
+ QTest::keyClick(canvas, Qt::Key_Right);
+ QCOMPARE(gridview->currentIndex(), 5);
+
+ QTest::keyClick(canvas, Qt::Key_Left);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 1);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ // hold down Key_Right
+ for (int i=0; i<(model.count() / 5) - 1; i++) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Right, Qt::NoModifier, "", true);
+ QTRY_COMPARE(gridview->currentIndex(), i*5 + 5);
+ }
+
+ QTest::keyRelease(canvas, Qt::Key_Right);
+ QTRY_COMPARE(gridview->currentIndex(), 55);
+ QTRY_COMPARE(gridview->contentX(), 720.0);
+
+ // hold down Key_Left
+ for (int i=(model.count() / 5) - 1; i > 0; i--) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Left, Qt::NoModifier, "", true);
+ QTRY_COMPARE(gridview->currentIndex(), i*5 - 5);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Left);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->contentX(), 0.0);
+
+
+ // turn off auto highlight
+ gridview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(gridview->highlightItem());
+ qreal hlPosX = gridview->highlightItem()->x();
+ qreal hlPosY = gridview->highlightItem()->y();
+
+ gridview->setCurrentIndex(5);
+ QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
+ QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
+
+ // insert item before currentIndex
+ gridview->setCurrentIndex(28);
+ model.insertItem(0, "Foo", "1111");
+ QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
+
+ // check removing highlight by setting currentIndex to -1;
+ gridview->setCurrentIndex(-1);
+
+ QCOMPARE(gridview->currentIndex(), -1);
+ QVERIFY(!gridview->highlightItem());
+ QVERIFY(!gridview->currentItem());
+
+ gridview->setHighlightFollowsCurrentItem(true);
+
+ gridview->setFlow(QQuickGridView::LeftToRight);
+ gridview->setLayoutDirection(Qt::RightToLeft);
+
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
+ qApp->processEvents();
+
+ gridview->setCurrentIndex(35);
+
+ QTest::keyClick(canvas, Qt::Key_Right);
+ QCOMPARE(gridview->currentIndex(), 34);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 37);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 34);
+
+ QTest::keyClick(canvas, Qt::Key_Left);
+ QCOMPARE(gridview->currentIndex(), 35);
+
+
+ // turn off auto highlight
+ gridview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(gridview->highlightItem());
+ hlPosX = gridview->highlightItem()->x();
+ hlPosY = gridview->highlightItem()->y();
+
+ gridview->setCurrentIndex(5);
+ QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
+ QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
+
+ // insert item before currentIndex
+ gridview->setCurrentIndex(28);
+ model.insertItem(0, "Foo", "1111");
+ QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
+
+ // check removing highlight by setting currentIndex to -1;
+ gridview->setCurrentIndex(-1);
+
+ QCOMPARE(gridview->currentIndex(), -1);
+ QVERIFY(!gridview->highlightItem());
+ QVERIFY(!gridview->currentItem());
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::noCurrentIndex()
+{
+ QaimModel model;
+ for (int i = 0; i < 60; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QString filename(testFile("gridview-noCurrent.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // current index should be -1
+ QCOMPARE(gridview->currentIndex(), -1);
+ QVERIFY(!gridview->currentItem());
+ QVERIFY(!gridview->highlightItem());
+ QCOMPARE(gridview->contentY(), 0.0);
+
+ gridview->setCurrentIndex(5);
+ QCOMPARE(gridview->currentIndex(), 5);
+ QVERIFY(gridview->currentItem());
+ QVERIFY(gridview->highlightItem());
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::changeFlow()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i/5)*80));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ ctxt->setContextProperty("testRightToLeft", QVariant(true));
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+ gridview->setContentX(100);
+ QTRY_COMPARE(gridview->contentX(), 100.);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ QTRY_COMPARE(gridview->contentX(), 0.);
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("gridview3.qml"));
+ QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->model() == QVariant());
+ QTRY_VERIFY(obj->delegate() == 0);
+ QTRY_COMPARE(obj->currentIndex(), -1);
+ QTRY_VERIFY(obj->currentItem() == 0);
+ QTRY_COMPARE(obj->count(), 0);
+ QTRY_VERIFY(obj->highlight() == 0);
+ QTRY_VERIFY(obj->highlightItem() == 0);
+ QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true);
+ QTRY_VERIFY(obj->flow() == 0);
+ QTRY_COMPARE(obj->isWrapEnabled(), false);
+ QTRY_COMPARE(obj->cacheBuffer(), 0);
+ QTRY_COMPARE(obj->cellWidth(), qreal(100)); //### Should 100 be the default?
+ QTRY_COMPARE(obj->cellHeight(), qreal(100));
+ delete obj;
+}
+
+void tst_QQuickGridView::properties()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("gridview2.qml"));
+ QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->model() != QVariant());
+ QTRY_VERIFY(obj->delegate() != 0);
+ QTRY_COMPARE(obj->currentIndex(), 0);
+ QTRY_VERIFY(obj->currentItem() != 0);
+ QTRY_COMPARE(obj->count(), 4);
+ QTRY_VERIFY(obj->highlight() != 0);
+ QTRY_VERIFY(obj->highlightItem() != 0);
+ QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false);
+ QTRY_VERIFY(obj->flow() == 0);
+ QTRY_COMPARE(obj->isWrapEnabled(), true);
+ QTRY_COMPARE(obj->cacheBuffer(), 200);
+ QTRY_COMPARE(obj->cellWidth(), qreal(100));
+ QTRY_COMPARE(obj->cellHeight(), qreal(100));
+ delete obj;
+}
+
+void tst_QQuickGridView::propertyChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
+ QTRY_VERIFY(gridView);
+
+ QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged()));
+ QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged()));
+ QSignalSpy layoutSpy(gridView, SIGNAL(layoutDirectionChanged()));
+ QSignalSpy flowSpy(gridView, SIGNAL(flowChanged()));
+
+ QTRY_COMPARE(gridView->isWrapEnabled(), true);
+ QTRY_COMPARE(gridView->cacheBuffer(), 10);
+ QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight);
+
+ gridView->setWrapEnabled(false);
+ gridView->setCacheBuffer(3);
+ gridView->setFlow(QQuickGridView::TopToBottom);
+
+ QTRY_COMPARE(gridView->isWrapEnabled(), false);
+ QTRY_COMPARE(gridView->cacheBuffer(), 3);
+ QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom);
+
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),1);
+
+ gridView->setWrapEnabled(false);
+ gridView->setCacheBuffer(3);
+ gridView->setFlow(QQuickGridView::TopToBottom);
+
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),1);
+
+ gridView->setFlow(QQuickGridView::LeftToRight);
+ QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight);
+
+ gridView->setWrapEnabled(true);
+ gridView->setCacheBuffer(5);
+ gridView->setLayoutDirection(Qt::RightToLeft);
+
+ QTRY_COMPARE(gridView->isWrapEnabled(), true);
+ QTRY_COMPARE(gridView->cacheBuffer(), 5);
+ QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft);
+
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
+ QTRY_COMPARE(cacheBufferSpy.count(),2);
+ QTRY_COMPARE(layoutSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),2);
+
+ gridView->setWrapEnabled(true);
+ gridView->setCacheBuffer(5);
+ gridView->setLayoutDirection(Qt::RightToLeft);
+
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
+ QTRY_COMPARE(cacheBufferSpy.count(),2);
+ QTRY_COMPARE(layoutSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),2);
+
+ gridView->setFlow(QQuickGridView::TopToBottom);
+ QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom);
+ QTRY_COMPARE(flowSpy.count(),3);
+
+ gridView->setFlow(QQuickGridView::TopToBottom);
+ QTRY_COMPARE(flowSpy.count(),3);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::componentChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
+ QTRY_VERIFY(gridView);
+
+ QQmlComponent component(canvas->engine());
+ component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
+
+ QQmlComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import QtQuick 1.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged()));
+ QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged()));
+ QSignalSpy headerSpy(gridView, SIGNAL(headerChanged()));
+ QSignalSpy footerSpy(gridView, SIGNAL(footerChanged()));
+
+ gridView->setHighlight(&component);
+ gridView->setDelegate(&delegateComponent);
+ gridView->setHeader(&component);
+ gridView->setFooter(&component);
+
+ QTRY_COMPARE(gridView->highlight(), &component);
+ QTRY_COMPARE(gridView->delegate(), &delegateComponent);
+ QTRY_COMPARE(gridView->header(), &component);
+ QTRY_COMPARE(gridView->footer(), &component);
+
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
+
+ gridView->setHighlight(&component);
+ gridView->setDelegate(&delegateComponent);
+ gridView->setHeader(&component);
+ gridView->setFooter(&component);
+
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::modelChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
+ QTRY_VERIFY(gridView);
+
+ QQuickListModel *alternateModel = canvas->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QTRY_VERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
+ QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
+
+ gridView->setModel(modelVariant);
+ QTRY_COMPARE(gridView->model(), modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
+
+ gridView->setModel(modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
+
+ gridView->setModel(QVariant());
+ QTRY_COMPARE(modelSpy.count(),2);
+ delete canvas;
+}
+
+void tst_QQuickGridView::positionViewAtIndex()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on a currently visible item
+ gridview->positionViewAtIndex(4, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->indexAt(120, 90), 4);
+ QTRY_COMPARE(gridview->contentY(), 60.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on an item beyond the visible items
+ gridview->positionViewAtIndex(21, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->indexAt(40, 450), 21);
+ QTRY_COMPARE(gridview->contentY(), 420.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ gridview->positionViewAtIndex(31, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->indexAt(120, 630), 31);
+ QTRY_COMPARE(gridview->contentY(), 520.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position at the beginning again
+ gridview->positionViewAtIndex(0, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->indexAt(0, 0), 0);
+ QTRY_COMPARE(gridview->indexAt(40, 30), 0);
+ QTRY_COMPARE(gridview->indexAt(80, 60), 4);
+ QTRY_COMPARE(gridview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position at End
+ gridview->positionViewAtIndex(30, QQuickGridView::End);
+ QTRY_COMPARE(gridview->contentY(), 340.);
+
+ // Position in Center
+ gridview->positionViewAtIndex(15, QQuickGridView::Center);
+ QTRY_COMPARE(gridview->contentY(), 170.);
+
+ // Ensure at least partially visible
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 170.);
+
+ gridview->setContentY(302);
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 302.);
+
+ gridview->setContentY(360);
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 300.);
+
+ gridview->setContentY(60);
+ gridview->positionViewAtIndex(20, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 60.);
+
+ gridview->setContentY(20);
+ gridview->positionViewAtIndex(20, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 100.);
+
+ // Ensure completely visible
+ gridview->setContentY(120);
+ gridview->positionViewAtIndex(20, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentY(), 120.);
+
+ gridview->setContentY(302);
+ gridview->positionViewAtIndex(15, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentY(), 300.);
+
+ gridview->setContentY(60);
+ gridview->positionViewAtIndex(20, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentY(), 100.);
+
+ // Test for Top To Bottom layout
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i/5)*80.);
+ QTRY_COMPARE(item->y(), (i%5)*60.);
+ }
+
+ // Position at End
+ gridview->positionViewAtIndex(30, QQuickGridView::End);
+ QTRY_COMPARE(gridview->contentX(), 320.);
+ QTRY_COMPARE(gridview->contentY(), 0.);
+
+ // Position in Center
+ gridview->positionViewAtIndex(15, QQuickGridView::Center);
+ QTRY_COMPARE(gridview->contentX(), 160.);
+
+ // Ensure at least partially visible
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), 160.);
+
+ gridview->setContentX(170);
+ gridview->positionViewAtIndex(25, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), 170.);
+
+ gridview->positionViewAtIndex(30, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), 320.);
+
+ gridview->setContentX(170);
+ gridview->positionViewAtIndex(25, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentX(), 240.);
+
+ // positionViewAtBeginning
+ gridview->positionViewAtBeginning();
+ QTRY_COMPARE(gridview->contentX(), 0.);
+
+ gridview->setContentX(80);
+ canvas->rootObject()->setProperty("showHeader", true);
+ gridview->positionViewAtBeginning();
+ QTRY_COMPARE(gridview->contentX(), -30.);
+
+ // positionViewAtEnd
+ gridview->positionViewAtEnd();
+ QTRY_COMPARE(gridview->contentX(), 400.); // 8*80 - 240 (8 columns)
+
+ gridview->setContentX(80);
+ canvas->rootObject()->setProperty("showFooter", true);
+ gridview->positionViewAtEnd();
+ QTRY_COMPARE(gridview->contentX(), 430.);
+
+ // set current item to outside visible view, position at beginning
+ // and ensure highlight moves to current item
+ gridview->setCurrentIndex(6);
+ gridview->positionViewAtBeginning();
+ QTRY_COMPARE(gridview->contentX(), -30.);
+ QVERIFY(gridview->highlightItem());
+ QCOMPARE(gridview->highlightItem()->x(), 80.);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::snapping()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ gridview->setHeight(220);
+ QCOMPARE(gridview->height(), 220.);
+
+ gridview->positionViewAtIndex(12, QQuickGridView::Visible);
+ QCOMPARE(gridview->contentY(), 80.);
+
+ gridview->setContentY(0);
+ QCOMPARE(gridview->contentY(), 0.);
+
+ gridview->setSnapMode(QQuickGridView::SnapToRow);
+ QCOMPARE(gridview->snapMode(), QQuickGridView::SnapToRow);
+
+ gridview->positionViewAtIndex(12, QQuickGridView::Visible);
+ QCOMPARE(gridview->contentY(), 60.);
+
+ gridview->positionViewAtIndex(15, QQuickGridView::End);
+ QCOMPARE(gridview->contentY(), 120.);
+
+ delete canvas;
+
+}
+
+void tst_QQuickGridView::mirroring()
+{
+ QQuickView *canvasA = createView();
+ canvasA->setSource(testFileUrl("mirroring.qml"));
+ QQuickGridView *gridviewA = findItem<QQuickGridView>(canvasA->rootObject(), "view");
+ QTRY_VERIFY(gridviewA != 0);
+
+ QQuickView *canvasB = createView();
+ canvasB->setSource(testFileUrl("mirroring.qml"));
+ QQuickGridView *gridviewB = findItem<QQuickGridView>(canvasB->rootObject(), "view");
+ QTRY_VERIFY(gridviewA != 0);
+ qApp->processEvents();
+
+ QList<QString> objectNames;
+ objectNames << "item1" << "item2"; // << "item3"
+
+ gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
+ gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
+ QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection());
+
+ // LTR != RTL
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
+ gridviewB->setProperty("layoutDirection", Qt::LeftToRight);
+
+ // LTR == LTR
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection());
+ QQuickItemPrivate::get(gridviewB)->setLayoutMirror(true);
+ QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection());
+
+ // LTR != LTR+mirror
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ gridviewA->setProperty("layoutDirection", Qt::RightToLeft);
+
+ // RTL == LTR+mirror
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
+
+ // RTL != RTL+mirror
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
+
+ // LTR == RTL+mirror
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ delete canvasA;
+ delete canvasB;
+}
+
+void tst_QQuickGridView::positionViewAtIndex_rightToLeft()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+ ctxt->setContextProperty("testRightToLeft", QVariant(true));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position on a currently visible item
+ gridview->positionViewAtIndex(6, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->contentX(), -320.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position on an item beyond the visible items
+ gridview->positionViewAtIndex(21, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->contentX(), -560.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ gridview->positionViewAtIndex(31, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->contentX(), -640.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position at the beginning again
+ gridview->positionViewAtIndex(0, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->contentX(), -240.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position at End
+ gridview->positionViewAtIndex(30, QQuickGridView::End);
+ QTRY_COMPARE(gridview->contentX(), -560.);
+
+ // Position in Center
+ gridview->positionViewAtIndex(15, QQuickGridView::Center);
+ QTRY_COMPARE(gridview->contentX(), -400.);
+
+ // Ensure at least partially visible
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -400.);
+
+ gridview->setContentX(-555.);
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -555.);
+
+ gridview->setContentX(-239);
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -320.);
+
+ gridview->setContentX(-239);
+ gridview->positionViewAtIndex(20, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -400.);
+
+ gridview->setContentX(-640);
+ gridview->positionViewAtIndex(20, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -560.);
+
+ // Ensure completely visible
+ gridview->setContentX(-400);
+ gridview->positionViewAtIndex(20, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentX(), -400.);
+
+ gridview->setContentX(-315);
+ gridview->positionViewAtIndex(15, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentX(), -320.);
+
+ gridview->setContentX(-640);
+ gridview->positionViewAtIndex(20, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentX(), -560.);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::resetModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaygrid.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QTRY_COMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QTRY_COMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::enforceRange()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
+ canvas->show();
+ qApp->processEvents();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0);
+ QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
+ QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // view should be positioned at the top of the range.
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(gridview->contentY(), -100.0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ // Check currentIndex is updated when contentItem moves
+ gridview->setContentY(0);
+ QTRY_COMPARE(gridview->currentIndex(), 2);
+
+ gridview->setCurrentIndex(5);
+ QTRY_COMPARE(gridview->contentY(), 100.);
+
+ QaimModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+ QCOMPARE(gridview->count(), 5);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::enforceRange_rightToLeft()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(true));
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+
+ canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
+ qApp->processEvents();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QCOMPARE(gridview->preferredHighlightBegin(), 100.0);
+ QCOMPARE(gridview->preferredHighlightEnd(), 100.0);
+ QCOMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ // view should be positioned at the top of the range.
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QTRY_COMPARE(gridview->contentX(), -140.);
+ QTRY_COMPARE(gridview->contentY(), 0.0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ // Check currentIndex is updated when contentItem moves
+ gridview->setContentX(-240);
+ QTRY_COMPARE(gridview->currentIndex(), 3);
+
+ gridview->setCurrentIndex(7);
+ QTRY_COMPARE(gridview->contentX(), -340.);
+ QTRY_COMPARE(gridview->contentY(), 0.0);
+
+ QaimModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+ QCOMPARE(gridview->count(), 5);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::QTBUG_8456()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("setindex.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::manualHighlight()
+{
+ QQuickView *canvas = createView();
+
+ QString filename(testFile("manual-highlight.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ gridview->setCurrentIndex(2);
+
+ QTRY_COMPARE(gridview->currentIndex(), 2);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ gridview->positionViewAtIndex(8, QQuickGridView::Contain);
+
+ QTRY_COMPARE(gridview->currentIndex(), 2);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ gridview->setFlow(QQuickGridView::TopToBottom);
+ QTRY_COMPARE(gridview->flow(), QQuickGridView::TopToBottom);
+
+ gridview->setCurrentIndex(0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ delete canvas;
+}
+
+
+void tst_QQuickGridView::footer()
+{
+ QFETCH(QQuickGridView::Flow, flow);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QPointF, initialFooterPos);
+ QFETCH(QPointF, changedFooterPos);
+ QFETCH(QPointF, initialContentPos);
+ QFETCH(QPointF, changedContentPos);
+ QFETCH(QPointF, firstDelegatePos);
+ QFETCH(QPointF, resizeContentPos);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 7; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("footer.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
+ QVERIFY(footer);
+
+ QVERIFY(footer == gridview->footerItem());
+
+ QCOMPARE(footer->pos(), initialFooterPos);
+ QCOMPARE(footer->width(), 100.);
+ QCOMPARE(footer->height(), 30.);
+ QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ if (flow == QQuickGridView::LeftToRight) {
+ // shrink by one row
+ model.removeItem(2);
+ QTRY_COMPARE(footer->y(), initialFooterPos.y() - gridview->cellHeight());
+ } else {
+ // shrink by one column
+ model.removeItem(2);
+ model.removeItem(3);
+ if (layoutDirection == Qt::LeftToRight)
+ QTRY_COMPARE(footer->x(), initialFooterPos.x() - gridview->cellWidth());
+ else
+ QTRY_COMPARE(footer->x(), initialFooterPos.x() + gridview->cellWidth());
+ }
+
+ // remove all items
+ model.clear();
+
+ QPointF posWhenNoItems(0, 0);
+ if (layoutDirection == Qt::RightToLeft)
+ posWhenNoItems.setX(flow == QQuickGridView::LeftToRight ? gridview->width() - footer->width() : -footer->width());
+ QTRY_COMPARE(footer->pos(), posWhenNoItems);
+
+ // if header is present, it's at a negative pos, so the footer should not move
+ canvas->rootObject()->setProperty("showHeader", true);
+ QVERIFY(findItem<QQuickItem>(contentItem, "header") != 0);
+ QTRY_COMPARE(footer->pos(), posWhenNoItems);
+ canvas->rootObject()->setProperty("showHeader", false);
+
+ // add 30 items
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QSignalSpy footerItemSpy(gridview, SIGNAL(footerItemChanged()));
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
+
+ QCOMPARE(footerItemSpy.count(), 1);
+
+ footer = findItem<QQuickText>(contentItem, "footer");
+ QVERIFY(!footer);
+ footer = findItem<QQuickText>(contentItem, "footer2");
+ QVERIFY(footer);
+
+ QVERIFY(footer == gridview->footerItem());
+
+ QCOMPARE(footer->pos(), changedFooterPos);
+ QCOMPARE(footer->width(), 50.);
+ QCOMPARE(footer->height(), 20.);
+ QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ gridview->positionViewAtEnd();
+ footer->setHeight(10);
+ footer->setWidth(40);
+ QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::footer_data()
+{
+ QTest::addColumn<QQuickGridView::Flow>("flow");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QPointF>("initialFooterPos");
+ QTest::addColumn<QPointF>("changedFooterPos");
+ QTest::addColumn<QPointF>("initialContentPos");
+ QTest::addColumn<QPointF>("changedContentPos");
+ QTest::addColumn<QPointF>("firstDelegatePos");
+ QTest::addColumn<QPointF>("resizeContentPos");
+
+ // footer1 = 100 x 30
+ // footer2 = 50 x 20
+ // cells = 80 * 60
+ // view width = 240
+ // view height = 320
+
+ // footer below items, bottom left
+ QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight
+ << QPointF(0, 3 * 60) // 180 = height of 3 rows (cell height is 60)
+ << QPointF(0, 10 * 60) // 30 items = 10 rows
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 10 * 60 - 320 + 10);
+
+ // footer below items, bottom right
+ QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft
+ << QPointF(240 - 100, 3 * 60)
+ << QPointF((240 - 100) + 50, 10 * 60) // 50 = width diff between old and new footers
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(240 - 80, 0)
+ << QPointF(0, 10 * 60 - 320 + 10);
+
+ // footer to right of items
+ QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight
+ << QPointF(2 * 80, 0) // 2 columns, cell width 80
+ << QPointF(6 * 80, 0) // 30 items = 6 columns
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(6 * 80 - 240 + 40, 0);
+
+ // footer to left of items
+ QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft
+ << QPointF(-(2 * 80) - 100, 0)
+ << QPointF(-(6 * 80) - 50, 0) // 50 = new footer width
+ << QPointF(-240, 0)
+ << QPointF(-240, 0) // unchanged, footer change doesn't change content pos
+ << QPointF(-80, 0)
+ << QPointF(-(6 * 80) - 40, 0);
+}
+
+void tst_QQuickGridView::header()
+{
+ QFETCH(QQuickGridView::Flow, flow);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QPointF, initialHeaderPos);
+ QFETCH(QPointF, changedHeaderPos);
+ QFETCH(QPointF, initialContentPos);
+ QFETCH(QPointF, changedContentPos);
+ QFETCH(QPointF, firstDelegatePos);
+ QFETCH(QPointF, resizeContentPos);
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("initialViewWidth", 240);
+ canvas->rootContext()->setContextProperty("initialViewHeight", 320);
+ canvas->setSource(testFileUrl("header.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *header = findItem<QQuickText>(contentItem, "header");
+ QVERIFY(header);
+
+ QVERIFY(header == gridview->headerItem());
+
+ QCOMPARE(header->pos(), initialHeaderPos);
+ QCOMPARE(header->width(), 100.);
+ QCOMPARE(header->height(), 30.);
+ QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ model.clear();
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is
+
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QSignalSpy headerItemSpy(gridview, SIGNAL(headerItemChanged()));
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
+
+ QCOMPARE(headerItemSpy.count(), 1);
+
+ header = findItem<QQuickText>(contentItem, "header");
+ QVERIFY(!header);
+ header = findItem<QQuickText>(contentItem, "header2");
+ QVERIFY(header);
+
+ QVERIFY(header == gridview->headerItem());
+
+ QCOMPARE(header->pos(), changedHeaderPos);
+ QCOMPARE(header->width(), 50.);
+ QCOMPARE(header->height(), 20.);
+ QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ header->setHeight(10);
+ header->setWidth(40);
+ QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
+
+ delete canvas;
+
+
+ // QTBUG-21207 header should become visible if view resizes from initial empty size
+
+ canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("initialViewWidth", 240);
+ canvas->rootContext()->setContextProperty("initialViewHeight", 320);
+ canvas->setSource(testFileUrl("header.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ gridview->setWidth(240);
+ gridview->setHeight(320);
+ QTRY_COMPARE(gridview->headerItem()->pos(), initialHeaderPos);
+ QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::header_data()
+{
+ QTest::addColumn<QQuickGridView::Flow>("flow");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QPointF>("initialHeaderPos");
+ QTest::addColumn<QPointF>("changedHeaderPos");
+ QTest::addColumn<QPointF>("initialContentPos");
+ QTest::addColumn<QPointF>("changedContentPos");
+ QTest::addColumn<QPointF>("firstDelegatePos");
+ QTest::addColumn<QPointF>("resizeContentPos");
+
+ // header1 = 100 x 30
+ // header2 = 50 x 20
+ // cells = 80 x 60
+ // view width = 240
+
+ // header above items, top left
+ QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, 0)
+ << QPointF(0, -10);
+
+ // header above items, top right
+ QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft
+ << QPointF(240 - 100, -30)
+ << QPointF((240 - 100) + 50, -20) // 50 = width diff between old and new headers
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(160, 0)
+ << QPointF(0, -10);
+
+ // header to left of items
+ QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight
+ << QPointF(-100, 0)
+ << QPointF(-50, 0)
+ << QPointF(-100, 0)
+ << QPointF(-50, 0)
+ << QPointF(0, 0)
+ << QPointF(-40, 0);
+
+ // header to right of items
+ QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(-(240 - 100), 0)
+ << QPointF(-(240 - 50), 0)
+ << QPointF(-80, 0)
+ << QPointF(-(240 - 40), 0);
+}
+
+void tst_QQuickGridView::resizeViewAndRepaint()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("initialWidth", 240);
+ ctxt->setContextProperty("initialHeight", 100);
+
+ canvas->setSource(testFileUrl("resizeview.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // item at index 10 should not be currently visible
+ QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ gridview->setHeight(320);
+ QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ gridview->setHeight(100);
+ QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ // Ensure we handle -ve sizes
+ gridview->setHeight(-100);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 3);
+
+ gridview->setCacheBuffer(120);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 9);
+
+ // ensure items in cache become visible
+ gridview->setHeight(120);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 15);
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
+ QCOMPARE(item->isVisible(), i < 9); // inside view visible, outside not visible
+ }
+
+ // ensure items outside view become invisible
+ gridview->setHeight(60);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 12);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
+ QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::changeColumnCount()
+{
+ QmlListModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("initialWidth", 100);
+ ctxt->setContextProperty("initialHeight", 320);
+ canvas->setSource(testFileUrl("resizeview.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // a single column of 6 items are visible
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QCOMPARE(itemCount, 6);
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), qreal(i*60));
+ }
+
+ // now 6x3 grid is visible, plus 1 extra below for refill
+ gridview->setWidth(240);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QCOMPARE(itemCount, 6*3 + 1);
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), qreal((i%3)*80));
+ QCOMPARE(item->y(), qreal((i/3)*60));
+ }
+
+ // back to single column
+ gridview->setWidth(100);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QCOMPARE(itemCount, 6);
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), qreal(i*60));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::indexAt_itemAt_data()
+{
+ QTest::addColumn<qreal>("x");
+ QTest::addColumn<qreal>("y");
+ QTest::addColumn<int>("index");
+
+ QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0;
+ QTest::newRow("Item 0 - 79, 59") << 79. << 59. << 0;
+ QTest::newRow("Item 1 - 80, 0") << 80. << 0. << 1;
+ QTest::newRow("Item 3 - 0, 60") << 0. << 60. << 3;
+ QTest::newRow("No Item - 240, 0") << 240. << 0. << -1;
+}
+
+void tst_QQuickGridView::indexAt_itemAt()
+{
+ QFETCH(qreal, x);
+ QFETCH(qreal, y);
+ QFETCH(int, index);
+
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(gridview->count(), model.count());
+
+ QQuickItem *item = 0;
+ if (index >= 0) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", index);
+ QVERIFY(item);
+ }
+ QCOMPARE(gridview->indexAt(x, y), index);
+ QVERIFY(gridview->itemAt(x, y) == item);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::onAdd()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, itemsToAdd);
+
+ const int delegateWidth = 50;
+ const int delegateHeight = 100;
+ QaimModel model;
+ QQuickView *canvas = createView();
+ canvas->setGeometry(0,0,5 * delegateWidth, 5 * delegateHeight); // just ensure all items fit
+
+ // these initial items should not trigger GridView.onAdd
+ for (int i=0; i<initialItemCount; i++)
+ model.addItem("dummy value", "dummy value");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("delegateWidth", delegateWidth);
+ ctxt->setContextProperty("delegateHeight", delegateHeight);
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
+
+ QObject *object = canvas->rootObject();
+ object->setProperty("width", canvas->width());
+ object->setProperty("height", canvas->height());
+ qApp->processEvents();
+
+ QList<QPair<QString, QString> > items;
+ for (int i=0; i<itemsToAdd; i++)
+ items << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.addItems(items);
+
+ QTRY_COMPARE(model.count(), qobject_cast<QQuickGridView*>(canvas->rootObject())->count());
+ qApp->processEvents();
+
+ QVariantList result = object->property("addedDelegates").toList();
+ QTRY_COMPARE(result.count(), items.count());
+ for (int i=0; i<items.count(); i++)
+ QCOMPARE(result[i].toString(), items[i].first);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::onAdd_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("itemsToAdd");
+
+ QTest::newRow("0, add 1") << 0 << 1;
+ QTest::newRow("0, add 2") << 0 << 2;
+ QTest::newRow("0, add 10") << 0 << 10;
+
+ QTest::newRow("1, add 1") << 1 << 1;
+ QTest::newRow("1, add 2") << 1 << 2;
+ QTest::newRow("1, add 10") << 1 << 10;
+
+ QTest::newRow("5, add 1") << 5 << 1;
+ QTest::newRow("5, add 2") << 5 << 2;
+ QTest::newRow("5, add 10") << 5 << 10;
+}
+
+void tst_QQuickGridView::onRemove()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, indexToRemove);
+ QFETCH(int, removeCount);
+
+ const int delegateWidth = 50;
+ const int delegateHeight = 100;
+ QaimModel model;
+ for (int i=0; i<initialItemCount; i++)
+ model.addItem(QString("value %1").arg(i), "dummy value");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("delegateWidth", delegateWidth);
+ ctxt->setContextProperty("delegateHeight", delegateHeight);
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
+ QObject *object = canvas->rootObject();
+
+ model.removeItems(indexToRemove, removeCount);
+ QTRY_COMPARE(model.count(), qobject_cast<QQuickGridView*>(canvas->rootObject())->count());
+ QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::onRemove_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("indexToRemove");
+ QTest::addColumn<int>("removeCount");
+
+ QTest::newRow("remove first") << 1 << 0 << 1;
+ QTest::newRow("two items, remove first") << 2 << 0 << 1;
+ QTest::newRow("two items, remove last") << 2 << 1 << 1;
+ QTest::newRow("two items, remove all") << 2 << 0 << 2;
+
+ QTest::newRow("four items, remove first") << 4 << 0 << 1;
+ QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
+ QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
+ QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
+ QTest::newRow("four items, remove last") << 4 << 3 << 1;
+ QTest::newRow("four items, remove all") << 4 << 0 << 4;
+
+ QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
+ QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
+ QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
+}
+
+void tst_QQuickGridView::columnCount()
+{
+ QQuickView canvas;
+ canvas.setSource(testFileUrl("gridview4.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickGridView *view = qobject_cast<QQuickGridView*>(canvas.rootObject());
+
+ QCOMPARE(view->cellWidth(), qreal(405)/qreal(9));
+ QCOMPARE(view->cellHeight(), qreal(100));
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(view, "delegate");
+ QCOMPARE(items.size(), 18);
+ QCOMPARE(items.at(8)->y(), qreal(0));
+ QCOMPARE(items.at(9)->y(), qreal(100));
+}
+
+void tst_QQuickGridView::margins()
+{
+ {
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+
+ canvas->setSource(testFileUrl("margins.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QCOMPARE(gridview->contentX(), -30.);
+ QCOMPARE(gridview->xOrigin(), 0.);
+
+ // check end bound
+ gridview->positionViewAtEnd();
+ qreal pos = gridview->contentX();
+ gridview->setContentX(pos + 80);
+ gridview->returnToBounds();
+ QTRY_COMPARE(gridview->contentX(), pos + 50);
+
+ // remove item before visible and check that left margin is maintained
+ // and xOrigin is updated
+ gridview->setContentX(200);
+ model.removeItems(0, 4);
+ QTest::qWait(100);
+ gridview->setContentX(-50);
+ gridview->returnToBounds();
+ QCOMPARE(gridview->xOrigin(), 100.);
+ QTRY_COMPARE(gridview->contentX(), 70.);
+
+ // reduce left margin
+ gridview->setLeftMargin(20);
+ QCOMPARE(gridview->xOrigin(), 100.);
+ QTRY_COMPARE(gridview->contentX(), 80.);
+
+ // check end bound
+ gridview->positionViewAtEnd();
+ QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin
+ pos = gridview->contentX();
+ gridview->setContentX(pos + 80);
+ gridview->returnToBounds();
+ QTRY_COMPARE(gridview->contentX(), pos + 50);
+
+ // reduce right margin
+ pos = gridview->contentX();
+ gridview->setRightMargin(40);
+ QCOMPARE(gridview->xOrigin(), 0.);
+ QTRY_COMPARE(gridview->contentX(), pos-10);
+
+ delete canvas;
+ }
+ {
+ //RTL
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(true));
+
+ canvas->setSource(testFileUrl("margins.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QCOMPARE(gridview->contentX(), -240+30.);
+ QCOMPARE(gridview->xOrigin(), 0.);
+
+ // check end bound
+ gridview->positionViewAtEnd();
+ qreal pos = gridview->contentX();
+ gridview->setContentX(pos - 80);
+ gridview->returnToBounds();
+ QTRY_COMPARE(gridview->contentX(), pos - 50);
+
+ // remove item before visible and check that left margin is maintained
+ // and xOrigin is updated
+ gridview->setContentX(-400);
+ model.removeItems(0, 4);
+ QTest::qWait(100);
+ gridview->setContentX(-240+50);
+ gridview->returnToBounds();
+ QCOMPARE(gridview->xOrigin(), -100.);
+ QTRY_COMPARE(gridview->contentX(), -240-70.);
+
+ // reduce left margin (i.e. right side due to RTL)
+ pos = gridview->contentX();
+ gridview->setLeftMargin(20);
+ QCOMPARE(gridview->xOrigin(), -100.);
+ QTRY_COMPARE(gridview->contentX(), -240-80.);
+
+ // check end bound
+ gridview->positionViewAtEnd();
+ QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin
+ pos = gridview->contentX();
+ gridview->setContentX(pos - 80);
+ gridview->returnToBounds();
+ QTRY_COMPARE(gridview->contentX(), pos - 50);
+
+ // reduce right margin (i.e. left side due to RTL)
+ pos = gridview->contentX();
+ gridview->setRightMargin(40);
+ QCOMPARE(gridview->xOrigin(), 0.);
+ QTRY_COMPARE(gridview->contentX(), pos+10);
+
+ delete canvas;
+ }
+}
+
+void tst_QQuickGridView::creationContext()
+{
+ QQuickView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(testFileUrl("creationContext.qml"));
+ qApp->processEvents();
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QQuickItem *item;
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("listItem"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
+void tst_QQuickGridView::snapToRow_data()
+{
+ QTest::addColumn<QQuickGridView::Flow>("flow");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<int>("highlightRangeMode");
+ QTest::addColumn<QPoint>("flickStart");
+ QTest::addColumn<QPoint>("flickEnd");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+
+ QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
+
+ QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+
+ QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+
+ QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
+}
+
+void tst_QQuickGridView::snapToRow()
+{
+ QFETCH(QQuickGridView::Flow, flow);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(int, highlightRangeMode);
+ QFETCH(QPoint, flickStart);
+ QFETCH(QPoint, flickEnd);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("snapToRow.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+ gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // confirm that a flick hits an item boundary
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(qreal(fmod(gridview->contentY(),80.0)), snapAlignment);
+ else
+ QCOMPARE(qreal(fmod(gridview->contentX(),80.0)), snapAlignment);
+
+ // flick to end
+ do {
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ } while (flow == QQuickGridView::LeftToRight
+ ? !gridview->isAtYEnd()
+ : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
+
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), endExtent);
+ else
+ QCOMPARE(gridview->contentX(), endExtent);
+
+ // flick to start
+ do {
+ flick(canvas, flickEnd, flickStart, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ } while (flow == QQuickGridView::LeftToRight
+ ? !gridview->isAtYBeginning()
+ : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd());
+
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), startExtent);
+ else
+ QCOMPARE(gridview->contentX(), startExtent);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::snapOneRow_data()
+{
+ QTest::addColumn<QQuickGridView::Flow>("flow");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<int>("highlightRangeMode");
+ QTest::addColumn<QPoint>("flickStart");
+ QTest::addColumn<QPoint>("flickEnd");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+
+ QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 << -240.0;
+
+ QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
+
+ QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
+
+ QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 - 100.0 << -220.0;
+}
+
+void tst_QQuickGridView::snapOneRow()
+{
+ QFETCH(QQuickGridView::Flow, flow);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(int, highlightRangeMode);
+ QFETCH(QPoint, flickStart);
+ QFETCH(QPoint, flickEnd);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("snapOneRow.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+ gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QSignalSpy currentIndexSpy(gridview, SIGNAL(currentIndexChanged()));
+
+ // confirm that a flick hits next row boundary
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), snapAlignment);
+ else
+ QCOMPARE(gridview->contentX(), snapAlignment);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(gridview->currentIndex(), 2);
+ QCOMPARE(currentIndexSpy.count(), 1);
+ }
+
+ // flick to end
+ do {
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ } while (flow == QQuickGridView::LeftToRight
+ ? !gridview->isAtYEnd()
+ : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(gridview->currentIndex(), 8);
+ QCOMPARE(currentIndexSpy.count(), 4);
+ }
+
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), endExtent);
+ else
+ QCOMPARE(gridview->contentX(), endExtent);
+
+ // flick to start
+ do {
+ flick(canvas, flickEnd, flickStart, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ } while (flow == QQuickGridView::LeftToRight
+ ? !gridview->isAtYBeginning()
+ : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd());
+
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), startExtent);
+ else
+ QCOMPARE(gridview->contentX(), startExtent);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(currentIndexSpy.count(), 8);
+ }
+
+ delete canvas;
+}
+
+
+void tst_QQuickGridView::unaligned()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 10; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("unaligned.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = qobject_cast<QQuickGridView*>(canvas->rootObject());
+ QVERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ for (int i = 0; i < 10; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
+ QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
+ }
+
+ // appending
+ for (int i = 10; i < 18; ++i) {
+ model.addItem("Item" + QString::number(i), "");
+ QQuickItem *item = 0;
+ QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
+ QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
+ QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
+ }
+
+ // inserting
+ for (int i = 0; i < 10; ++i) {
+ model.insertItem(i, "Item" + QString::number(i), "");
+ QQuickItem *item = 0;
+ QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
+ QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
+ QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
+ }
+
+ // removing
+ model.removeItems(7, 10);
+ QTRY_COMPARE(model.count(), gridview->count());
+ for (int i = 0; i < 18; ++i) {
+ QQuickItem *item = 0;
+ QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
+ QCOMPARE(item->x(), qreal(i%9)*gridview->cellWidth());
+ QCOMPARE(item->y(), qreal(i/9)*gridview->cellHeight());
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::populateTransitions()
+{
+ QFETCH(bool, staticallyPopulate);
+ QFETCH(bool, dynamicallyPopulate);
+ QFETCH(bool, usePopulateTransition);
+
+ QPointF transitionFrom(-50, -50);
+ QPointF transitionVia(100, 100);
+ QaimModel model_transitionFrom;
+ QaimModel model_transitionVia;
+
+ QaimModel model;
+ if (staticallyPopulate) {
+ for (int i = 0; i < 30; i++)
+ model.addItem("item" + QString::number(i), "");
+ }
+
+ QQuickView *canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
+ canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
+ canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom);
+ canvas->rootContext()->setContextProperty("transitionVia", transitionVia);
+ canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom);
+ canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
+ canvas->setSource(testFileUrl("populateTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem);
+
+ if (staticallyPopulate || dynamicallyPopulate) {
+ // check the populate transition is run
+ if (usePopulateTransition) {
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 19);
+ } else {
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0);
+ }
+ QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
+ } else {
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ // add an item and check this is done with add transition, not populate
+ model.insertItem(0, "another item", "");
+ QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 1);
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(),
+ (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 19 : 0);
+
+ // clear the model
+ canvas->rootContext()->setContextProperty("testModel", QVariant());
+ QTRY_COMPARE(gridview->count(), 0);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
+ gridview->setProperty("countPopulateTransitions", 0);
+ gridview->setProperty("countAddTransitions", 0);
+
+ // set to a valid model and check populate transition is run a second time
+ model.clear();
+ for (int i = 0; i < 30; i++)
+ model.addItem("item" + QString::number(i), "");
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0);
+ QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ // reset model and check populate transition is run again
+ gridview->setProperty("countPopulateTransitions", 0);
+ gridview->setProperty("countAddTransitions", 0);
+ model.reset();
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0);
+ QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::populateTransitions_data()
+{
+ QTest::addColumn<bool>("staticallyPopulate");
+ QTest::addColumn<bool>("dynamicallyPopulate");
+ QTest::addColumn<bool>("usePopulateTransition");
+
+ QTest::newRow("static") << true << false << true;
+ QTest::newRow("static, no populate") << true << false << false;
+
+ QTest::newRow("dynamic") << false << true << true;
+ QTest::newRow("dynamic, no populate") << false << true << false;
+
+ QTest::newRow("empty to start with") << false << false << true;
+ QTest::newRow("empty to start with, no populate") << false << false << false;
+}
+
+void tst_QQuickGridView::addTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(bool, shouldAnimateTargets);
+ QFETCH(qreal, contentY);
+ QFETCH(int, insertionIndex);
+ QFETCH(int, insertionCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // added items should start here
+ QPointF targetItems_transitionFrom(-50, -50);
+
+ // displaced items should pass through this point
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionFrom;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFileUrl("addTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // only target items that will become visible should be animated
+ QList<QPair<QString, QString> > newData;
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ if (shouldAnimateTargets) {
+ for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
+ newData << qMakePair(QString("New item %1").arg(i), QString(""));
+
+ // last visible item is the first item of the row beneath the view
+ if (i >= (contentY / 60)*3 && i < qCeil((contentY + gridview->height()) / 60.0)*3) {
+ expectedTargetData << newData.last();
+ targetIndexes << i;
+ }
+ }
+ QVERIFY(expectedTargetData.count() > 0);
+ }
+
+ // start animation
+ if (!newData.isEmpty()) {
+ model.insertItems(insertionIndex, newData);
+ QTRY_COMPARE(model.count(), gridview->count());
+ }
+
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+
+ if (shouldAnimateTargets) {
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
+ matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+ } else {
+ QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0);
+ QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::addTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<bool>("shouldAnimateTargets");
+ QTest::addColumn<int>("insertionIndex");
+ QTest::addColumn<int>("insertionCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // if inserting a full row before visible index, items don't appear or animate in, even if there are > 1 new items
+ QTest::newRow("insert 1, just before start")
+ << 30 << 20.0 << false
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert 1, way before start")
+ << 30 << 20.0 << false
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert multiple, just before start")
+ << 30 << 100.0 << false
+ << 0 << 3 << ListRange();
+ QTest::newRow("insert multiple (< 1 row), just before start")
+ << 30 << 100.0 << false
+ << 0 << 2 << ListRange();
+ QTest::newRow("insert multiple, way before start")
+ << 30 << 100.0 << false
+ << 0 << 3 << ListRange();
+
+ QTest::newRow("insert 1 at start")
+ << 30 << 0.0 << true
+ << 0 << 1 << ListRange(0, 17);
+ QTest::newRow("insert multiple at start")
+ << 30 << 0.0 << true
+ << 0 << 3 << ListRange(0, 17);
+ QTest::newRow("insert multiple (> 1 row) at start")
+ << 30 << 0.0 << true
+ << 0 << 5 << ListRange(0, 17);
+ QTest::newRow("insert 1 at start, content y not 0")
+ << 30 << 60.0 << true // first visible is index 3
+ << 3 << 1 << ListRange(0 + 3, 17 + 3);
+ QTest::newRow("insert multiple at start, content y not 0")
+ << 30 << 60.0 << true // first visible is index 3
+ << 3 << 3 << ListRange(0 + 3, 17 + 3);
+ QTest::newRow("insert multiple (> 1 row) at start, content y not 0")
+ << 30 << 60.0 << true // first visible is index 3
+ << 3 << 5 << ListRange(0 + 3, 17 + 3);
+
+ QTest::newRow("insert 1 at start, to empty grid")
+ << 0 << 0.0 << true
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert multiple at start, to empty grid")
+ << 0 << 0.0 << true
+ << 0 << 3 << ListRange();
+
+ QTest::newRow("insert 1 at middle")
+ << 30 << 0.0 << true
+ << 7 << 1 << ListRange(7, 17);
+ QTest::newRow("insert multiple at middle")
+ << 30 << 0.0 << true
+ << 7 << 3 << ListRange(7, 17);
+ QTest::newRow("insert multiple (> 1 row) at middle")
+ << 30 << 0.0 << true
+ << 7 << 5 << ListRange(7, 17);
+
+ QTest::newRow("insert 1 at bottom")
+ << 30 << 0.0 << true
+ << 17 << 1 << ListRange(17, 17);
+ QTest::newRow("insert multiple at bottom")
+ << 30 << 0.0 << true
+ << 17 << 3 << ListRange(17, 17);
+ QTest::newRow("insert 1 at bottom, content y not 0")
+ << 30 << 20.0 * 3 << true
+ << 17 + 3 << 1 << ListRange(17 + 3, 17 + 3);
+ QTest::newRow("insert multiple at bottom, content y not 0")
+ << 30 << 20.0 * 3 << true
+ << 17 + 3 << 3 << ListRange(17 + 3, 17 + 3);
+
+
+ // items added after the last visible will not be animated in, since they
+ // do not appear in the final view
+ QTest::newRow("insert 1 after end")
+ << 30 << 0.0 << false
+ << 18 << 1 << ListRange();
+ QTest::newRow("insert multiple after end")
+ << 30 << 0.0 << false
+ << 18 << 3 << ListRange();
+}
+
+void tst_QQuickGridView::moveTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(qreal, contentY);
+ QFETCH(qreal, itemsOffsetAfterMove);
+ QFETCH(int, moveFrom);
+ QFETCH(int, moveTo);
+ QFETCH(int, moveCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // target and displaced items should pass through these points
+ QPointF targetItems_transitionVia(-50, 50);
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionVia;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFileUrl("moveTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QQuickText *name;
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // Items moving to *or* from visible positions should be animated.
+ // Otherwise, they should not be animated.
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ for (int i=moveFrom; i<moveFrom+moveCount; i++) {
+ int toIndex = moveTo + (i - moveFrom);
+ int firstVisibleIndex = (contentY / 60) * 3;
+ int lastVisibleIndex = (qCeil((contentY + gridview->height()) / 60.0)*3) - 1;
+ if ((i >= firstVisibleIndex && i <= lastVisibleIndex)
+ || (toIndex >= firstVisibleIndex && toIndex <= lastVisibleIndex)) {
+ expectedTargetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ }
+ // ViewTransition.index provides the indices that items are moving to, not from
+ targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount);
+
+ // start animation
+ model.moveItems(moveFrom, moveTo, moveCount);
+
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount);
+ matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::moveTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+ QTest::addColumn<int>("moveFrom");
+ QTest::addColumn<int>("moveTo");
+ QTest::addColumn<int>("moveCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("move from above view, outside visible items, move 1") << 30 << 120.0 << 0.0
+ << 1 << 10 << 1 << ListRange(6, 10);
+ QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 120.0 << 0.0
+ << 0 << 10 << 1 << ListRange(6, 10);
+ QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 120.0 << 60.0
+ << 1 << 10 << 3 << ListRange(13, 23);
+ QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 120.0 << 60.0
+ << 1 << 10 << 6 << (ListRange(7, 15) + ListRange(16, 23));
+ QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 120.0 << 120.0
+ << 0 << 10 << 6 << ListRange(16, 23);
+
+ QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0
+ << 1 << 10 << 1 << ListRange(2, 10);
+ QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0
+ << 0 << 10 << 1 << ListRange(1, 10);
+ QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 120.0 << 0.0
+ << 0+6 << 10+6 << 1 << ListRange(1+6, 10+6);
+ QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0
+ << 10 << 17 << 1 << ListRange(11, 17);
+ QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0
+ << 0 << 17 << 1 << ListRange(1, 17);
+
+ QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0
+ << 1 << 10 << 3 << ListRange(4, 12);
+ QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0
+ << 0 << 10 << 3 << ListRange(3, 12);
+ QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 60.0 << 0.0
+ << 0+3 << 10+3 << 3 << ListRange(3+3, 12+3);
+ QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0
+ << 5 << 15 << 3 << ListRange(8, 17);
+ QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0
+ << 0 << 15 << 3 << ListRange(3, 17);
+
+ QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 1 << ListRange(1, 9);
+ QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0
+ << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 120.0 << 0.0
+ << 10+6 << 0+6 << 1 << ListRange(0+6, 9+6);
+ QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 80.0 << 0.0
+ << 10+3 << 0+3 << 1 << ListRange(0+3, 9+3);
+ QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0
+ << 17 << 10 << 1 << ListRange(10, 16);
+ QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0
+ << 17 << 0 << 1 << ListRange(0, 16);
+
+ QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 3 << ListRange(1, 9);
+ QTest::newRow("move within view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 5 << ListRange(1, 9);
+ QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0
+ << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 60.0 << 0.0
+ << 10+3 << 0+3 << 3 << ListRange(0+3, 9+3);
+ QTest::newRow("move within view, move multiple up (> 1 row), move to first index, contentY not on border") << 30 << 80.0 << 0.0
+ << 10+3 << 0+3 << 5 << ListRange(0+3, 9+3);
+ QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0
+ << 15 << 5 << 3 << ListRange(5, 14);
+ QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0
+ << 15 << 0 << 3 << ListRange(0, 14);
+
+ QTest::newRow("move from below view, move 1 up") << 30 << 0.0 << 0.0
+ << 20 << 5 << 1 << ListRange(5, 17);
+ QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0
+ << 20 << 0 << 1 << ListRange(0, 17);
+ QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 60.0 << 0.0
+ << 25 << 3 << 1 << ListRange(0+3, 17+3);
+ QTest::newRow("move from below view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0
+ << 20 << 5 << 5 << ListRange(5, 17);
+ QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0
+ << 20 << 0 << 3 << ListRange(0, 17);
+ QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 60.0 << 0.0
+ << 25 << 3 << 3 << ListRange(0+3, 17+3);
+
+ QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0
+ << 20 << 17 << 1 << ListRange(17, 17);
+ QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0
+ << 25 << 17+3 << 1 << ListRange(17+3, 17+3);
+ QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0
+ << 20 << 17 << 3 << ListRange(17, 17);
+ QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0
+ << 25 << 17+3 << 3 << ListRange(17+3, 17+3);
+}
+
+void tst_QQuickGridView::removeTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(bool, shouldAnimateTargets);
+ QFETCH(qreal, contentY);
+ QFETCH(int, removalIndex);
+ QFETCH(int, removalCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // added items should end here
+ QPointF targetItems_transitionTo(-50, -50);
+
+ // displaced items should pass through this points
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionTo;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFileUrl("removeTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // only target items that are visible should be animated
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ if (shouldAnimateTargets) {
+ for (int i=removalIndex; i<removalIndex+removalCount; i++) {
+ int firstVisibleIndex = (contentY / 60.0)*3;
+ int lastVisibleIndex = (qCeil((contentY + gridview->height()) / 60.0)*3) - 1;
+ if (i >= firstVisibleIndex && i <= lastVisibleIndex) {
+ expectedTargetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ }
+ QVERIFY(expectedTargetData.count() > 0);
+ }
+
+ // calculate targetItems and expectedTargets before model changes
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+ QVariantMap expectedTargets;
+ for (int i=0; i<targetIndexes.count(); i++)
+ expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
+
+ // start animation
+ model.removeItems(removalIndex, removalCount);
+ QTRY_COMPARE(model.count(), gridview->count());
+
+ if (shouldAnimateTargets || expectedDisplacedIndexes.isValid()) {
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ QCOMPARE(gridview->property("targetTrans_items").toMap(), expectedTargets);
+ matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount);
+ matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+ } else {
+ QTRY_COMPARE(model_targetItems_transitionTo.count(), 0);
+ QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int itemCount = items.count();
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ int index = e.evaluate().toInt();
+ if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
+ firstVisibleIndex = index;
+ else if (index < 0)
+ itemCount--; // exclude deleted items
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), contentY + ((i-firstVisibleIndex)/3) * 60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::removeTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<bool>("shouldAnimateTargets");
+ QTest::addColumn<int>("removalIndex");
+ QTest::addColumn<int>("removalCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // All items that are visible following the remove operation should be animated.
+ // Remove targets that are outside of the view should not be animated.
+
+ // For a GridView, removing any number of items other than a full row before the start
+ // should displace all items in the view
+ QTest::newRow("remove 1 before start")
+ << 30 << 120.0 << false
+ << 2 << 1 << ListRange(6, 24); // 6-24 are displaced
+ QTest::newRow("remove 1 row, before start")
+ << 30 << 120.0 << false
+ << 3 << 3 << ListRange();
+ QTest::newRow("remove between 1-2 rows, before start")
+ << 30 << 120.0 << false
+ << 0 << 5 << ListRange(6, 25);
+ QTest::newRow("remove 2 rows, before start")
+ << 30 << 120.0 << false
+ << 0 << 6 << ListRange();
+ QTest::newRow("remove mix of before and after start")
+ << 30 << 60.0 << true
+ << 2 << 3 << ListRange(5, 23); // 5-23 are displaced into view
+
+
+ QTest::newRow("remove 1 from start")
+ << 30 << 0.0 << true
+ << 0 << 1 << ListRange(1, 18); // 1-18 are displaced into view
+ QTest::newRow("remove multiple from start")
+ << 30 << 0.0 << true
+ << 0 << 3 << ListRange(3, 20); // 3-18 are displaced into view
+ QTest::newRow("remove 1 from start, content y not 0")
+ << 30 << 60.0 << true
+ << 3 << 1 << ListRange(1 + 3, 18 + 3);
+ QTest::newRow("remove multiple from start, content y not 0")
+ << 30 << 60.0 << true
+ << 3 << 3 << ListRange(3 + 3, 20 + 3);
+
+
+ QTest::newRow("remove 1 from middle")
+ << 30 << 0.0 << true
+ << 5 << 1 << ListRange(6, 18);
+ QTest::newRow("remove multiple from middle")
+ << 30 << 0.0 << true
+ << 5 << 3 << ListRange(8, 20);
+
+
+ QTest::newRow("remove 1 from bottom")
+ << 30 << 0.0 << true
+ << 17 << 1 << ListRange(18, 18);
+ QTest::newRow("remove multiple (1 row) from bottom")
+ << 30 << 0.0 << true
+ << 15 << 3 << ListRange(18, 20);
+ QTest::newRow("remove multiple (> 1 row) from bottom")
+ << 30 << 0.0 << true
+ << 15 << 5 << ListRange(20, 22);
+ QTest::newRow("remove 1 from bottom, content y not 0")
+ << 30 << 60.0 << true
+ << 17 + 3 << 1 << ListRange(18 + 3, 18 + 3);
+ QTest::newRow("remove multiple (1 row) from bottom, content y not 0")
+ << 30 << 60.0 << true
+ << 15 + 3 << 3 << ListRange(18 + 3, 20 + 3);
+
+
+ QTest::newRow("remove 1 after end")
+ << 30 << 0.0 << false
+ << 18 << 1 << ListRange();
+ QTest::newRow("remove multiple after end")
+ << 30 << 0.0 << false
+ << 18 << 3 << ListRange();
+}
+
+void tst_QQuickGridView::displacedTransitions()
+{
+ QFETCH(bool, useDisplaced);
+ QFETCH(bool, displacedEnabled);
+ QFETCH(bool, useAddDisplaced);
+ QFETCH(bool, addDisplacedEnabled);
+ QFETCH(bool, useMoveDisplaced);
+ QFETCH(bool, moveDisplacedEnabled);
+ QFETCH(bool, useRemoveDisplaced);
+ QFETCH(bool, removeDisplacedEnabled);
+ QFETCH(ListChange, change);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_displaced_transitionVia;
+ QaimModel model_addDisplaced_transitionVia;
+ QaimModel model_moveDisplaced_transitionVia;
+ QaimModel model_removeDisplaced_transitionVia;
+
+ QPointF displaced_transitionVia(-50, -100);
+ QPointF addDisplaced_transitionVia(-150, 100);
+ QPointF moveDisplaced_transitionVia(50, -100);
+ QPointF removeDisplaced_transitionVia(150, 100);
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia);
+ ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia);
+ ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia);
+ ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia);
+ ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia);
+ ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia);
+ ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia);
+ ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia);
+ ctxt->setContextProperty("useDisplaced", useDisplaced);
+ ctxt->setContextProperty("displacedEnabled", displacedEnabled);
+ ctxt->setContextProperty("useAddDisplaced", useAddDisplaced);
+ ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled);
+ ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced);
+ ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled);
+ ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced);
+ ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled);
+ canvas->setSource(testFileUrl("displacedTransitions.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+ gridview->setProperty("displaceTransitionsDone", false);
+
+ switch (change.type) {
+ case ListChange::Inserted:
+ {
+ QList<QPair<QString, QString> > targetItemData;
+ for (int i=change.index; i<change.index + change.count; ++i)
+ targetItemData << qMakePair(QString("new item %1").arg(i), QString::number(i));
+ model.insertItems(change.index, targetItemData);
+ QTRY_COMPARE(model.count(), gridview->count());
+ break;
+ }
+ case ListChange::Removed:
+ model.removeItems(change.index, change.count);
+ QTRY_COMPARE(model.count(), gridview->count());
+ break;
+ case ListChange::Moved:
+ model.moveItems(change.index, change.to, change.count);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::SetCurrent:
+ case ListChange::SetContentY:
+ break;
+ }
+ if ((useDisplaced && displacedEnabled)
+ || (useAddDisplaced && addDisplacedEnabled)
+ || (useMoveDisplaced && moveDisplacedEnabled)
+ || (useRemoveDisplaced && removeDisplacedEnabled)) {
+ QTRY_VERIFY(gridview->property("displaceTransitionsDone").toBool());
+ }
+
+ if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled)
+ model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced");
+ else
+ QCOMPARE(model_addDisplaced_transitionVia.count(), 0);
+ if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled)
+ model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced");
+ else
+ QCOMPARE(model_moveDisplaced_transitionVia.count(), 0);
+ if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled)
+ model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced");
+ else
+ QCOMPARE(model_removeDisplaced_transitionVia.count(), 0);
+
+ if (useDisplaced && displacedEnabled
+ && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled))
+ || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled))
+ || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) {
+ model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced");
+ } else {
+ QCOMPARE(model_displaced_transitionVia.count(), 0);
+ }
+
+ // verify all items moved to the correct final positions
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i < model.count() && i < items.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::displacedTransitions_data()
+{
+ QTest::addColumn<bool>("useDisplaced");
+ QTest::addColumn<bool>("displacedEnabled");
+ QTest::addColumn<bool>("useAddDisplaced");
+ QTest::addColumn<bool>("addDisplacedEnabled");
+ QTest::addColumn<bool>("useMoveDisplaced");
+ QTest::addColumn<bool>("moveDisplacedEnabled");
+ QTest::addColumn<bool>("useRemoveDisplaced");
+ QTest::addColumn<bool>("removeDisplacedEnabled");
+ QTest::addColumn<ListChange>("change");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("no displaced transitions at all")
+ << false << false
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("just displaced")
+ << true << true
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("just displaced (not enabled)")
+ << true << false
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("displaced + addDisplaced")
+ << true << true
+ << true << true
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("displaced + addDisplaced (not enabled)")
+ << true << true
+ << true << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("displaced + moveDisplaced")
+ << true << true
+ << false << false
+ << true << true
+ << false << false
+ << ListChange::move(0, 10, 1) << ListRange(1, 10);
+
+ QTest::newRow("displaced + moveDisplaced (not enabled)")
+ << true << true
+ << false << false
+ << true << false
+ << false << false
+ << ListChange::move(0, 10, 1) << ListRange(1, 10);
+
+ QTest::newRow("displaced + removeDisplaced")
+ << true << true
+ << false << false
+ << false << false
+ << true << true
+ << ListChange::remove(0, 1) << ListRange(1, 18);
+
+ QTest::newRow("displaced + removeDisplaced (not enabled)")
+ << true << true
+ << false << false
+ << false << false
+ << true << false
+ << ListChange::remove(0, 1) << ListRange(1, 18);
+
+
+ QTest::newRow("displaced + add, should use generic displaced for a remove")
+ << true << true
+ << true << true
+ << false << false
+ << true << false
+ << ListChange::remove(0, 1) << ListRange(1, 18);
+}
+
+void tst_QQuickGridView::multipleTransitions()
+{
+ // Tests that if you interrupt a transition in progress with another action that
+ // cancels the previous transition, the resulting items are still placed correctly.
+
+ QFETCH(int, initialCount);
+ QFETCH(qreal, contentY);
+ QFETCH(QList<ListChange>, changes);
+ QFETCH(bool, rippleAddDisplaced);
+
+ // add transitions on the left, moves on the right
+ QPointF addTargets_transitionFrom(-50, -50);
+ QPointF addDisplaced_transitionFrom(-50, 50);
+ QPointF moveTargets_transitionFrom(50, -50);
+ QPointF moveDisplaced_transitionFrom(50, 50);
+ QPointF removeTargets_transitionTo(-100, 300);
+ QPointF removeDisplaced_transitionFrom(100, 300);
+
+ QmlListModel model;
+ for (int i = 0; i < initialCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
+ ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
+ ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
+ ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
+ ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo);
+ ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom);
+ ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced);
+ canvas->setSource(testFileUrl("multipleTransitions.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
+
+ QList<QPair<QString, QString> > targetItems;
+ for (int i=0; i<changes.count(); i++) {
+ switch (changes[i].type) {
+ case ListChange::Inserted:
+ {
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
+ model.insertItems(changes[i].index, targetItems);
+ QTRY_COMPARE(model.count(), gridview->count());
+ QTRY_VERIFY(gridview->property("runningAddTargets").toBool());
+ QTRY_VERIFY(gridview->property("runningAddDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!gridview->property("runningAddTargets").toBool());
+ QTRY_VERIFY(!gridview->property("runningAddDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ }
+ case ListChange::Removed:
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(model.name(i), model.number(i));
+ model.removeItems(changes[i].index, changes[i].count);
+ QTRY_COMPARE(model.count(), gridview->count());
+ QTRY_VERIFY(gridview->property("runningRemoveTargets").toBool());
+ QTRY_VERIFY(gridview->property("runningRemoveDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!gridview->property("runningRemoveTargets").toBool());
+ QTRY_VERIFY(!gridview->property("runningRemoveDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ case ListChange::Moved:
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(model.name(i), model.number(i));
+ model.moveItems(changes[i].index, changes[i].to, changes[i].count);
+ QTRY_VERIFY(gridview->property("runningMoveTargets").toBool());
+ QTRY_VERIFY(gridview->property("runningMoveDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool());
+ QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ case ListChange::SetCurrent:
+ gridview->setCurrentIndex(changes[i].index);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::SetContentY:
+ gridview->setContentY(changes[i].pos);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ }
+ }
+ QCOMPARE(gridview->count(), model.count());
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::multipleTransitions_data()
+{
+ QTest::addColumn<int>("initialCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<QList<ListChange> >("changes");
+ QTest::addColumn<bool>("rippleAddDisplaced");
+
+ // the added item and displaced items should move to final dest correctly
+ QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(0, 1)
+ << ListChange::move(0, 3, 1)
+ )
+ << false;
+
+ // items affected by the add should change from move to add transition
+ QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::move(1, 10, 3)
+ << ListChange::insert(0, 1)
+ )
+ << false;
+
+ // items should be placed correctly if you trigger a transition then refill for that index
+ QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(0, 1)
+ << ListChange::setContentY(160.0)
+ << ListChange::setContentY(0.0)
+ << ListChange::insert(0, 1)
+ )
+ << false;
+
+ QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(1, 1)
+ << ListChange::remove(1, 1)
+ )
+ << true;
+}
+
+void tst_QQuickGridView::cacheBuffer()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 90; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QVERIFY(gridview->delegate() != 0);
+ QVERIFY(gridview->model() != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
+ }
+
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->rootObject()->setProperty("cacheBuffer", 200);
+ QTRY_VERIFY(gridview->cacheBuffer() == 200);
+
+ // items will be created one at a time
+ for (int i = itemCount; i < qMin(itemCount+9,model.count()); ++i) {
+ QVERIFY(findItem<QQuickItem>(gridview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(gridview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ int newItemCount = 0;
+ newItemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < newItemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
+ }
+
+ // move view and confirm items in view are visible immediately and outside are created async
+ gridview->setContentY(300);
+
+ for (int i = 15; i < 34; ++i) { // 34 due to staggered item creation
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
+ }
+
+ QVERIFY(findItem<QQuickItem>(gridview, "wrapper", 34) == 0);
+
+ // ensure buffered items are created
+ for (int i = 34; i < qMin(44,model.count()); ++i) {
+ QQuickItem *item = 0;
+ while (!item) {
+ qGuiApp->processEvents(); // allow refill to happen
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(gridview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::asynchronous()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->setSource(testFile("asyncloader.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootObject);
+
+ QQuickGridView *gridview = 0;
+ while (!gridview) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ gridview = rootObject->findChild<QQuickGridView*>("view");
+ }
+
+ // items will be created one at a time
+ for (int i = 0; i < 12; ++i) {
+ QVERIFY(findItem<QQuickItem>(gridview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(gridview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ // verify positioning
+ QQuickItem *contentItem = gridview->contentItem();
+ for (int i = 0; i < 12; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item->x() == (i%3)*100);
+ QVERIFY(item->y() == (i/3)*100);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::unrequestedVisibility()
+{
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testWrap", QVariant(false));
+
+ canvas->setSource(testFileUrl("unrequestedItems.qml"));
+
+ canvas->show();
+
+ qApp->processEvents();
+
+ QQuickGridView *leftview = findItem<QQuickGridView>(canvas->rootObject(), "leftGrid");
+ QTRY_VERIFY(leftview != 0);
+
+ QQuickGridView *rightview = findItem<QQuickGridView>(canvas->rootObject(), "rightGrid");
+ QTRY_VERIFY(rightview != 0);
+
+ QQuickItem *leftContent = leftview->contentItem();
+ QTRY_VERIFY(leftContent != 0);
+
+ QQuickItem *rightContent = rightview->contentItem();
+ QTRY_VERIFY(rightContent != 0);
+
+ rightview->setCurrentIndex(12);
+
+ QTRY_COMPARE(leftview->contentY(), 0.0);
+ QTRY_COMPARE(rightview->contentY(), 240.0);
+
+ QQuickItem *item;
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), true);
+
+ rightview->setCurrentIndex(0);
+
+ QTRY_COMPARE(leftview->contentY(), 0.0);
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QTRY_COMPARE(item->isVisible(), true);
+
+ QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 11));
+ QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 11));
+
+ leftview->setCurrentIndex(12);
+
+ QTRY_COMPARE(leftview->contentY(), 240.0);
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QTRY_COMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a non-visible item into view
+ model.moveItems(10, 9, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a visible item out of view
+ model.moveItems(5, 3, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a non-visible item into view
+ model.moveItems(3, 5, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a visible item out of view
+ model.moveItems(9, 10, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a non-visible item into view
+ model.moveItems(10, 9, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ delete canvas;
+}
+
+QList<int> tst_QQuickGridView::toIntList(const QVariantList &list)
+{
+ QList<int> ret;
+ bool ok = true;
+ for (int i=0; i<list.count(); i++) {
+ ret << list[i].toInt(&ok);
+ if (!ok)
+ qWarning() << "tst_QQuickGridView::toIntList(): not a number:" << list[i];
+ }
+
+ return ret;
+}
+
+void tst_QQuickGridView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
+{
+ for (int i=0; i<indexLists.count(); i++) {
+ QSet<int> current = indexLists[i].value<QList<int> >().toSet();
+ if (current != expectedIndexes.toSet())
+ qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
+ QCOMPARE(current, expectedIndexes.toSet());
+ }
+}
+
+void tst_QQuickGridView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
+{
+ for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
+ QVERIFY(it.value().type() == QVariant::Int);
+ QString name = it.key();
+ int itemIndex = it.value().toInt();
+ QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
+ if (model.name(itemIndex) != name)
+ qDebug() << itemIndex;
+ QCOMPARE(model.name(itemIndex), name);
+ }
+ QCOMPARE(items.count(), expectedIndexes.count());
+}
+
+void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
+{
+ for (int i=0; i<itemLists.count(); i++) {
+ QVariantList current = itemLists[i].toList();
+ for (int j=0; j<current.count(); j++) {
+ QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
+ QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
+ QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
+ }
+ QCOMPARE(current.count(), expectedItems.count());
+ }
+}
+
+QTEST_MAIN(tst_QQuickGridView)
+
+#include "tst_qquickgridview.moc"
+
diff --git a/tests/auto/qtquick2/qquickimage/data/aspectratio.qml b/tests/auto/quick/qquickimage/data/aspectratio.qml
index b26f0e1f04..b26f0e1f04 100644
--- a/tests/auto/qtquick2/qquickimage/data/aspectratio.qml
+++ b/tests/auto/quick/qquickimage/data/aspectratio.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/big.jpeg b/tests/auto/quick/qquickimage/data/big.jpeg
index bed7bd65c3..bed7bd65c3 100644
--- a/tests/auto/qtquick2/qquickimage/data/big.jpeg
+++ b/tests/auto/quick/qquickimage/data/big.jpeg
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/big256.png b/tests/auto/quick/qquickimage/data/big256.png
index 1dc1596d03..1dc1596d03 100644
--- a/tests/auto/qtquick2/qquickimage/data/big256.png
+++ b/tests/auto/quick/qquickimage/data/big256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/colors1.png b/tests/auto/quick/qquickimage/data/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/qtquick2/qquickimage/data/colors1.png
+++ b/tests/auto/quick/qquickimage/data/colors.png
Binary files differ
diff --git a/tests/auto/quick/qquickimage/data/colors1.png b/tests/auto/quick/qquickimage/data/colors1.png
new file mode 100644
index 0000000000..dfb62f3d64
--- /dev/null
+++ b/tests/auto/quick/qquickimage/data/colors1.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/green.png b/tests/auto/quick/qquickimage/data/green.png
index 0a2e153ba1..0a2e153ba1 100644
--- a/tests/auto/qtquick2/qquickimage/data/green.png
+++ b/tests/auto/quick/qquickimage/data/green.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/heart-win32.png b/tests/auto/quick/qquickimage/data/heart-win32.png
index 351da13772..351da13772 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart-win32.png
+++ b/tests/auto/quick/qquickimage/data/heart-win32.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/heart.png b/tests/auto/quick/qquickimage/data/heart.png
index abe97fee4b..abe97fee4b 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart.png
+++ b/tests/auto/quick/qquickimage/data/heart.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/heart.svg b/tests/auto/quick/qquickimage/data/heart.svg
index 8c982cd93c..8c982cd93c 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart.svg
+++ b/tests/auto/quick/qquickimage/data/heart.svg
diff --git a/tests/auto/qtquick2/qquickimage/data/heart200-win32.png b/tests/auto/quick/qquickimage/data/heart200-win32.png
index 4976ff98ba..4976ff98ba 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart200-win32.png
+++ b/tests/auto/quick/qquickimage/data/heart200-win32.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/heart200.png b/tests/auto/quick/qquickimage/data/heart200.png
index 7fbb13c5bb..7fbb13c5bb 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart200.png
+++ b/tests/auto/quick/qquickimage/data/heart200.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/htiling.qml b/tests/auto/quick/qquickimage/data/htiling.qml
index f192f931c9..f192f931c9 100644
--- a/tests/auto/qtquick2/qquickimage/data/htiling.qml
+++ b/tests/auto/quick/qquickimage/data/htiling.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/mirror.qml b/tests/auto/quick/qquickimage/data/mirror.qml
index 98fddf083e..98fddf083e 100644
--- a/tests/auto/qtquick2/qquickimage/data/mirror.qml
+++ b/tests/auto/quick/qquickimage/data/mirror.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/nullpixmap.qml b/tests/auto/quick/qquickimage/data/nullpixmap.qml
index d52f41f164..d52f41f164 100644
--- a/tests/auto/qtquick2/qquickimage/data/nullpixmap.qml
+++ b/tests/auto/quick/qquickimage/data/nullpixmap.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/pattern.png b/tests/auto/quick/qquickimage/data/pattern.png
index d3d5e1e007..d3d5e1e007 100644
--- a/tests/auto/qtquick2/qquickimage/data/pattern.png
+++ b/tests/auto/quick/qquickimage/data/pattern.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml b/tests/auto/quick/qquickimage/data/qtbug_16389.qml
index 7b8adecb11..7b8adecb11 100644
--- a/tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml
+++ b/tests/auto/quick/qquickimage/data/qtbug_16389.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml b/tests/auto/quick/qquickimage/data/qtbug_22125.qml
index 9b68c0a125..9b68c0a125 100644
--- a/tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml
+++ b/tests/auto/quick/qquickimage/data/qtbug_22125.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/rect.png b/tests/auto/quick/qquickimage/data/rect.png
index d564a2d5a5..d564a2d5a5 100644
--- a/tests/auto/qtquick2/qquickimage/data/rect.png
+++ b/tests/auto/quick/qquickimage/data/rect.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/sourceSize.qml b/tests/auto/quick/qquickimage/data/sourceSize.qml
index 8e25c254d3..8e25c254d3 100644
--- a/tests/auto/qtquick2/qquickimage/data/sourceSize.qml
+++ b/tests/auto/quick/qquickimage/data/sourceSize.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/vtiling.qml b/tests/auto/quick/qquickimage/data/vtiling.qml
index f730f6e050..f730f6e050 100644
--- a/tests/auto/qtquick2/qquickimage/data/vtiling.qml
+++ b/tests/auto/quick/qquickimage/data/vtiling.qml
diff --git a/tests/auto/quick/qquickimage/qquickimage.pro b/tests/auto/quick/qquickimage/qquickimage.pro
new file mode 100644
index 0000000000..a68a7870d8
--- /dev/null
+++ b/tests/auto/quick/qquickimage/qquickimage.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickimage
+macx:CONFIG -= app_bundle
+
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickimage.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
new file mode 100644
index 0000000000..eda56fa789
--- /dev/null
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -0,0 +1,749 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickimage_p.h>
+#include <private/qquickimagebase_p.h>
+#include <private/qquickloader_p.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtTest/QSignalSpy>
+#include <QtGui/QPainter>
+#include <QtGui/QImageReader>
+
+#include "../../shared/util.h"
+#include "../../shared/testhttpserver.h"
+#include "../shared/visualtestutil.h"
+
+#define SERVER_PORT 14451
+#define SERVER_ADDR "http://127.0.0.1:14451"
+
+
+using namespace QQuickVisualTestUtil;
+
+Q_DECLARE_METATYPE(QQuickImageBase::Status)
+
+class tst_qquickimage : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickimage();
+
+private slots:
+ void noSource();
+ void imageSource();
+ void imageSource_data();
+ void clearSource();
+ void resized();
+ void preserveAspectRatio();
+ void smooth();
+ void mirror();
+ void svg();
+ void geometry();
+ void geometry_data();
+ void big();
+ void tiling_QTBUG_6716();
+ void tiling_QTBUG_6716_data();
+ void noLoading();
+ void paintedWidthHeight();
+ void sourceSize_QTBUG_14303();
+ void sourceSize_QTBUG_16389();
+ void nullPixmapPaint();
+ void imageCrash_QTBUG_22125();
+ void sourceSize_data();
+ void sourceSize();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickimage::tst_qquickimage()
+{
+}
+
+void tst_qquickimage::noSource()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QVERIFY(obj->status() == QQuickImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+ QCOMPARE(obj->progress(), 0.0);
+
+ delete obj;
+}
+
+void tst_qquickimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<double>("width");
+ QTest::addColumn<double>("height");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("async");
+ QTest::addColumn<bool>("cache");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("local") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << true << "";
+ QTest::newRow("local no cache") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << false << "";
+ QTest::newRow("local async") << testFileUrl("colors1.png").toString() << 120.0 << 120.0 << false << true << true << "";
+ QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << 0.0 << 0.0 << false
+ << false << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString();
+ QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false
+ << true << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString();
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << "";
+ QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
+ if (QImageReader::supportedImageFormats().contains("svg"))
+ QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
+
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true
+ << false << true << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
+
+}
+
+void tst_qquickimage::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(double, width);
+ QFETCH(double, height);
+ QFETCH(bool, remote);
+ QFETCH(bool, async);
+ QFETCH(bool, cache);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(SERVER_PORT);
+ if (remote) {
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+ server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
+ }
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; asynchronous: "
+ + (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: "
+ + (cache ? QLatin1String("true") : QLatin1String("false")) + " }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (async)
+ QVERIFY(obj->asynchronous() == true);
+ else
+ QVERIFY(obj->asynchronous() == false);
+
+ if (cache)
+ QVERIFY(obj->cache() == true);
+ else
+ QVERIFY(obj->cache() == false);
+
+ if (remote || async)
+ QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+
+ if (error.isEmpty()) {
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QCOMPARE(obj->width(), qreal(width));
+ QCOMPARE(obj->height(), qreal(height));
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ QTRY_VERIFY(obj->status() == QQuickImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qquickimage::clearSource()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QQuickImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->progress(), 1.0);
+
+ ctxt->setContextProperty("srcImage", "");
+ QVERIFY(obj->source().isEmpty());
+ QVERIFY(obj->status() == QQuickImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->progress(), 0.0);
+
+ delete obj;
+}
+
+void tst_qquickimage::resized()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+ delete obj;
+}
+
+
+void tst_qquickimage::preserveAspectRatio()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->show();
+
+ canvas->setSource(testFileUrl("aspectratio.qml"));
+ QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
+ QVERIFY(image != 0);
+ image->setWidth(80.0);
+ QCOMPARE(image->width(), 80.);
+ QCOMPARE(image->height(), 80.);
+
+ canvas->setSource(testFileUrl("aspectratio.qml"));
+ image = qobject_cast<QQuickImage*>(canvas->rootObject());
+ image->setHeight(60.0);
+ QVERIFY(image != 0);
+ QCOMPARE(image->height(), 60.);
+ QCOMPARE(image->width(), 60.);
+ delete canvas;
+}
+
+void tst_qquickimage::smooth()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->smooth(), true);
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickimage::mirror()
+{
+ QSKIP("Test is broken on multiple levels, will need incremental fixes");
+
+ QMap<QQuickImage::FillMode, QImage> screenshots;
+ QList<QQuickImage::FillMode> fillModes;
+ fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop
+ << QQuickImage::Tile << QQuickImage::TileVertically << QQuickImage::TileHorizontally;
+
+ qreal width = 300;
+ qreal height = 250;
+
+ foreach (QQuickImage::FillMode fillMode, fillModes) {
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("mirror.qml"));
+
+ QQuickImage *obj = canvas->rootObject()->findChild<QQuickImage*>("image");
+ QVERIFY(obj != 0);
+
+ obj->setFillMode(fillMode);
+ obj->setProperty("mirror", true);
+ canvas->show();
+
+ QImage screenshot = canvas->grabFrameBuffer();
+ screenshots[fillMode] = screenshot;
+ delete canvas;
+ }
+
+ foreach (QQuickImage::FillMode fillMode, fillModes) {
+ QPixmap srcPixmap;
+ QVERIFY(srcPixmap.load(testFile("pattern.png")));
+
+ QPixmap expected(width, height);
+ expected.fill();
+ QPainter p_e(&expected);
+ QTransform transform;
+ transform.translate(width, 0).scale(-1, 1.0);
+ p_e.setTransform(transform);
+
+ switch (fillMode) {
+ case QQuickImage::Stretch:
+ p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
+ break;
+ case QQuickImage::PreserveAspectFit:
+ p_e.drawPixmap(QRect(25, 0, height, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
+ break;
+ case QQuickImage::PreserveAspectCrop:
+ {
+ qreal ratio = width/srcPixmap.width(); // width is the longer side
+ QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio);
+ rect.moveCenter(QRect(0, 0, width, height).center());
+ p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
+ break;
+ }
+ case QQuickImage::Tile:
+ p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
+ break;
+ case QQuickImage::TileVertically:
+ transform.scale(width / srcPixmap.width(), 1.0);
+ p_e.setTransform(transform);
+ p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
+ break;
+ case QQuickImage::TileHorizontally:
+ transform.scale(1.0, height / srcPixmap.height());
+ p_e.setTransform(transform);
+ p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
+ break;
+ case QQuickImage::Pad:
+ break;
+ }
+
+ QImage img = expected.toImage();
+ QEXPECT_FAIL("", "QTBUG-21005 fails", Continue);
+ QCOMPARE(screenshots[fillMode], img);
+ }
+}
+
+void tst_qquickimage::svg()
+{
+ if (!QImageReader::supportedImageFormats().contains("svg"))
+ QSKIP("svg support not available");
+
+ QString src = testFileUrl("heart.svg").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 300.0);
+ obj->setSourceSize(QSize(200,200));
+
+ QCOMPARE(obj->width(), 200.0);
+ QCOMPARE(obj->height(), 200.0);
+ delete obj;
+}
+
+void tst_qquickimage::geometry_data()
+{
+ QTest::addColumn<QString>("fillMode");
+ QTest::addColumn<bool>("explicitWidth");
+ QTest::addColumn<bool>("explicitHeight");
+ QTest::addColumn<double>("itemWidth");
+ QTest::addColumn<double>("paintedWidth");
+ QTest::addColumn<double>("boundingWidth");
+ QTest::addColumn<double>("itemHeight");
+ QTest::addColumn<double>("paintedHeight");
+ QTest::addColumn<double>("boundingHeight");
+
+ // tested image has width 200, height 100
+
+ // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match
+ QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0;
+ QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0;
+
+ // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match
+ QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0;
+ QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
+ QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
+
+ // bounding rect, painted rect and item rect are equal in stretching and tiling images
+ QStringList fillModes;
+ fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally";
+ foreach (QString fillMode, fillModes) {
+ QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0;
+ QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0;
+ }
+}
+
+void tst_qquickimage::geometry()
+{
+ QFETCH(QString, fillMode);
+ QFETCH(bool, explicitWidth);
+ QFETCH(bool, explicitHeight);
+ QFETCH(double, itemWidth);
+ QFETCH(double, itemHeight);
+ QFETCH(double, paintedWidth);
+ QFETCH(double, paintedHeight);
+ QFETCH(double, boundingWidth);
+ QFETCH(double, boundingHeight);
+
+ QString src = testFileUrl("rect.png").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; ";
+
+ if (explicitWidth)
+ componentStr.append("width: 300; ");
+ if (explicitHeight)
+ componentStr.append("height: 400; ");
+ componentStr.append("}");
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->width(), itemWidth);
+ QCOMPARE(obj->paintedWidth(), paintedWidth);
+ QCOMPARE(obj->boundingRect().width(), boundingWidth);
+
+ QCOMPARE(obj->height(), itemHeight);
+ QCOMPARE(obj->paintedHeight(), paintedHeight);
+ QCOMPARE(obj->boundingRect().height(), boundingHeight);
+ delete obj;
+}
+
+void tst_qquickimage::big()
+{
+ // If the JPEG loader does not implement scaling efficiently, it would
+ // have to build a 400 MB image. That would be a bug in the JPEG loader.
+
+ QString src = testFileUrl("big.jpeg").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
+
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 100.0);
+ QCOMPARE(obj->height(), 256.0);
+
+ delete obj;
+}
+
+// As tiling_QTBUG_6716 doesn't complete, it doesn't delete the
+// canvas which causes leak warnings. Use this delete on stack
+// destruction pattern to work around this.
+template<typename T>
+struct AutoDelete {
+ AutoDelete(T *t) : t(t) {}
+ ~AutoDelete() { delete t; }
+private:
+ T *t;
+};
+
+void tst_qquickimage::tiling_QTBUG_6716()
+{
+ QSKIP("Test is broken on multiple levels, will need incremental fixes");
+
+ QFETCH(QString, source);
+
+ QQuickView *canvas = new QQuickView(0);
+ AutoDelete<QQuickView> del(canvas);
+
+ canvas->setSource(testFileUrl(source));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickImage *tiling = findItem<QQuickImage>(canvas->rootObject(), "tiling");
+
+ QVERIFY(tiling != 0);
+ QImage img = canvas->grabFrameBuffer();
+ for (int x = 0; x < tiling->width(); ++x) {
+ for (int y = 0; y < tiling->height(); ++y) {
+ QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
+ }
+ }
+
+ delete canvas;
+}
+
+void tst_qquickimage::tiling_QTBUG_6716_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::newRow("vertical_tiling") << "vtiling.qml";
+ QTest::newRow("horizontal_tiling") << "htiling.qml";
+}
+
+void tst_qquickimage::noLoading()
+{
+ qRegisterMetaType<QQuickImageBase::Status>();
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+ server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
+
+ QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QQuickImage::Ready);
+
+ QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
+ QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
+ QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
+
+ // Loading local file
+ ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 1);
+ QTRY_COMPARE(progressSpy.count(), 0);
+ QTRY_COMPARE(statusSpy.count(), 0);
+
+ // Loading remote file
+ ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
+ QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+ QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 2);
+ QTRY_COMPARE(progressSpy.count(), 2);
+ QTRY_COMPARE(statusSpy.count(), 2);
+
+ // Loading remote file again - should not go through 'Loading' state.
+ ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
+ ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 4);
+ QTRY_COMPARE(progressSpy.count(), 2);
+ QTRY_COMPARE(statusSpy.count(), 2);
+
+ delete obj;
+}
+
+void tst_qquickimage::paintedWidthHeight()
+{
+ {
+ QString src = testFileUrl("heart.png").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }";
+
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 200.0);
+ QCOMPARE(obj->height(), 25.0);
+ QCOMPARE(obj->paintedWidth(), 25.0);
+ QCOMPARE(obj->paintedHeight(), 25.0);
+
+ delete obj;
+ }
+
+ {
+ QString src = testFileUrl("heart.png").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 26.0);
+ QCOMPARE(obj->height(), 175.0);
+ QCOMPARE(obj->paintedWidth(), 26.0);
+ QCOMPARE(obj->paintedHeight(), 26.0);
+
+ delete obj;
+ }
+}
+
+void tst_qquickimage::sourceSize_QTBUG_14303()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+
+ QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged()));
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+
+ QTRY_COMPARE(obj->sourceSize().width(), 200);
+ QTRY_COMPARE(obj->sourceSize().height(), 200);
+ QTRY_COMPARE(sourceSizeSpy.count(), 0);
+
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
+ QTRY_COMPARE(obj->sourceSize().width(), 120);
+ QTRY_COMPARE(obj->sourceSize().height(), 120);
+ QTRY_COMPARE(sourceSizeSpy.count(), 1);
+
+ ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
+ QTRY_COMPARE(obj->sourceSize().width(), 200);
+ QTRY_COMPARE(obj->sourceSize().height(), 200);
+ QTRY_COMPARE(sourceSizeSpy.count(), 2);
+
+ delete obj;
+}
+
+void tst_qquickimage::sourceSize_QTBUG_16389()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("qtbug_16389.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickImage *image = findItem<QQuickImage>(canvas->rootObject(), "iconImage");
+ QQuickItem *handle = findItem<QQuickItem>(canvas->rootObject(), "blueHandle");
+
+ QCOMPARE(image->sourceSize().width(), 200);
+ QCOMPARE(image->sourceSize().height(), 200);
+ QCOMPARE(image->paintedWidth(), 0.0);
+ QCOMPARE(image->paintedHeight(), 0.0);
+
+ handle->setY(20);
+
+ QCOMPARE(image->sourceSize().width(), 200);
+ QCOMPARE(image->sourceSize().height(), 200);
+ QCOMPARE(image->paintedWidth(), 20.0);
+ QCOMPARE(image->paintedHeight(), 20.0);
+
+ delete canvas;
+}
+
+static int numberOfWarnings = 0;
+static void checkWarnings(QtMsgType, const char *msg)
+{
+ if (!QString(msg).contains("QGLContext::makeCurrent(): Failed."))
+ numberOfWarnings++;
+}
+
+// QTBUG-15690
+void tst_qquickimage::nullPixmapPaint()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("nullpixmap.qml"));
+ canvas->show();
+
+ QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
+ QTRY_VERIFY(image != 0);
+ image->setSource(SERVER_ADDR + QString("/no-such-file.png"));
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
+
+ // used to print "QTransform::translate with NaN called"
+ QPixmap pm = QPixmap::fromImage(canvas->grabFrameBuffer());
+ qInstallMsgHandler(previousMsgHandler);
+ QVERIFY(numberOfWarnings == 0);
+ delete image;
+
+ delete canvas;
+}
+
+void tst_qquickimage::imageCrash_QTBUG_22125()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
+
+ {
+ QQuickView view(testFileUrl("qtbug_22125.qml"));
+ view.show();
+ qApp->processEvents();
+ qApp->processEvents();
+ // shouldn't crash when the view drops out of scope due to
+ // QQuickPixmapData attempting to dereference a pointer to
+ // the destroyed reader.
+ }
+
+ // shouldn't crash when deleting cancelled QQmlPixmapReplys.
+ QTest::qWait(520); // Delay mode delays for 500 ms.
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+}
+
+void tst_qquickimage::sourceSize_data()
+{
+ QTest::addColumn<int>("sourceWidth");
+ QTest::addColumn<int>("sourceHeight");
+ QTest::addColumn<qreal>("implicitWidth");
+ QTest::addColumn<qreal>("implicitHeight");
+
+ QTest::newRow("unscaled") << 0 << 0 << 300.0 << 300.0;
+ QTest::newRow("scale width") << 100 << 0 << 100.0 << 100.0;
+ QTest::newRow("scale height") << 0 << 150 << 150.0 << 150.0;
+ QTest::newRow("larger sourceSize") << 400 << 400 << 300.0 << 300.0;
+}
+
+void tst_qquickimage::sourceSize()
+{
+ QFETCH(int, sourceWidth);
+ QFETCH(int, sourceHeight);
+ QFETCH(qreal, implicitWidth);
+ QFETCH(qreal, implicitHeight);
+
+ QQuickView *canvas = new QQuickView(0);
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("srcWidth", sourceWidth);
+ ctxt->setContextProperty("srcHeight", sourceHeight);
+
+ canvas->setSource(testFileUrl("sourceSize.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
+ QVERIFY(image);
+
+ QCOMPARE(image->sourceSize().width(), sourceWidth);
+ QCOMPARE(image->sourceSize().height(), sourceHeight);
+ QCOMPARE(image->implicitWidth(), implicitWidth);
+ QCOMPARE(image->implicitHeight(), implicitHeight);
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickimage)
+
+#include "tst_qquickimage.moc"
diff --git a/tests/auto/qtquick2/qquickitem/data/order.1.qml b/tests/auto/quick/qquickitem/data/order.1.qml
index 963288b257..963288b257 100644
--- a/tests/auto/qtquick2/qquickitem/data/order.1.qml
+++ b/tests/auto/quick/qquickitem/data/order.1.qml
diff --git a/tests/auto/qtquick2/qquickitem/data/order.2.qml b/tests/auto/quick/qquickitem/data/order.2.qml
index 5609c77e28..5609c77e28 100644
--- a/tests/auto/qtquick2/qquickitem/data/order.2.qml
+++ b/tests/auto/quick/qquickitem/data/order.2.qml
diff --git a/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml b/tests/auto/quick/qquickitem/data/polishOnCompleted.qml
index 7008cdc67e..7008cdc67e 100644
--- a/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml
+++ b/tests/auto/quick/qquickitem/data/polishOnCompleted.qml
diff --git a/tests/auto/quick/qquickitem/qquickitem.pro b/tests/auto/quick/qquickitem/qquickitem.pro
new file mode 100644
index 0000000000..cf24e63d05
--- /dev/null
+++ b/tests/auto/quick/qquickitem/qquickitem.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickitem
+SOURCES += tst_qquickitem.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private widgets testlib
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
new file mode 100644
index 0000000000..7a589a48cd
--- /dev/null
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -0,0 +1,1468 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickcanvas.h>
+#include <QtQuick/qquickview.h>
+#include <QtWidgets/QGraphicsSceneMouseEvent>
+#include "private/qquickfocusscope_p.h"
+#include "private/qquickitem_p.h"
+#include <QDebug>
+#include <QTimer>
+#include "../../shared/util.h"
+
+class TestItem : public QQuickItem
+{
+Q_OBJECT
+public:
+ TestItem(QQuickItem *parent = 0)
+ : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0)
+ , wheelCount(0), acceptIncomingTouchEvents(true)
+ , touchEventReached(false) {}
+
+ bool focused;
+ int pressCount;
+ int releaseCount;
+ int wheelCount;
+ bool acceptIncomingTouchEvents;
+ bool touchEventReached;
+protected:
+ virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
+ virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
+ virtual void mousePressEvent(QMouseEvent *event) { event->accept(); ++pressCount; }
+ virtual void mouseReleaseEvent(QMouseEvent *event) { event->accept(); ++releaseCount; }
+ virtual void touchEvent(QTouchEvent *event) {
+ touchEventReached = true;
+ event->setAccepted(acceptIncomingTouchEvents);
+ }
+ virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; }
+};
+
+class TestCanvas: public QQuickCanvas
+{
+public:
+ TestCanvas()
+ : QQuickCanvas()
+ {}
+
+ virtual bool event(QEvent *event)
+ {
+ return QQuickCanvas::event(event);
+ }
+};
+
+class TestPolishItem : public QQuickItem
+{
+Q_OBJECT
+public:
+ TestPolishItem(QQuickItem *parent = 0)
+ : QQuickItem(parent), wasPolished(false) {
+
+ }
+
+ bool wasPolished;
+
+protected:
+ virtual void updatePolish() {
+ wasPolished = true;
+ }
+
+public slots:
+ void doPolish() {
+ polish();
+ }
+};
+
+class TestFocusScope : public QQuickFocusScope
+{
+Q_OBJECT
+public:
+ TestFocusScope(QQuickItem *parent = 0) : QQuickFocusScope(parent), focused(false) {}
+
+ bool focused;
+protected:
+ virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
+ virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
+};
+
+class tst_qquickitem : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void initTestCase();
+
+ void noCanvas();
+ void simpleFocus();
+ void scopedFocus();
+ void addedToCanvas();
+ void changeParent();
+
+ void constructor();
+ void setParentItem();
+
+ void visible();
+ void enabled();
+ void enabledFocus();
+
+ void mouseGrab();
+ void touchEventAcceptIgnore_data();
+ void touchEventAcceptIgnore();
+ void polishOutsideAnimation();
+ void polishOnCompleted();
+
+ void wheelEvent_data();
+ void wheelEvent();
+ void hoverEvent_data();
+ void hoverEvent();
+ void hoverEventInParent();
+
+ void paintOrder_data();
+ void paintOrder();
+
+private:
+
+ enum PaintOrderOp {
+ NoOp, Append, Remove, StackBefore, StackAfter, SetZ
+ };
+
+ void ensureFocus(QWindow *w) {
+ w->show();
+ w->requestActivateWindow();
+ qApp->processEvents();
+ }
+};
+
+void tst_qquickitem::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<TestPolishItem>("Qt.test", 1, 0, "TestPolishItem");
+}
+
+// Focus has no effect when outside a canvas
+void tst_qquickitem::noCanvas()
+{
+ QQuickItem *root = new TestItem;
+ QQuickItem *child = new TestItem(root);
+ QQuickItem *scope = new TestItem(root);
+ QQuickFocusScope *scopedChild = new TestFocusScope(scope);
+ QQuickFocusScope *scopedChild2 = new TestFocusScope(scope);
+
+ QCOMPARE(root->hasFocus(), false);
+ QCOMPARE(child->hasFocus(), false);
+ QCOMPARE(scope->hasFocus(), false);
+ QCOMPARE(scopedChild->hasFocus(), false);
+ QCOMPARE(scopedChild2->hasFocus(), false);
+
+ root->setFocus(true);
+ scope->setFocus(true);
+ scopedChild2->setFocus(true);
+ QCOMPARE(root->hasFocus(), true);
+ QCOMPARE(child->hasFocus(), false);
+ QCOMPARE(scope->hasFocus(), true);
+ QCOMPARE(scopedChild->hasFocus(), false);
+ QCOMPARE(scopedChild2->hasFocus(), true);
+
+ root->setFocus(false);
+ child->setFocus(true);
+ scopedChild->setFocus(true);
+ scope->setFocus(false);
+ QCOMPARE(root->hasFocus(), false);
+ QCOMPARE(child->hasFocus(), true);
+ QCOMPARE(scope->hasFocus(), false);
+ QCOMPARE(scopedChild->hasFocus(), true);
+ QCOMPARE(scopedChild2->hasFocus(), true);
+
+ delete root;
+}
+
+struct FocusData {
+ FocusData() : focus(false), activeFocus(false) {}
+
+ void set(bool f, bool af) { focus = f; activeFocus = af; }
+ bool focus;
+ bool activeFocus;
+};
+struct FocusState : public QHash<QQuickItem *, FocusData>
+{
+ FocusState() : activeFocusItem(0) {}
+ FocusState &operator<<(QQuickItem *item) {
+ insert(item, FocusData());
+ return *this;
+ }
+
+ void active(QQuickItem *i) {
+ activeFocusItem = i;
+ }
+ QQuickItem *activeFocusItem;
+};
+
+#define FVERIFY() \
+ do { \
+ if (focusState.activeFocusItem) { \
+ QCOMPARE(canvas.activeFocusItem(), focusState.activeFocusItem); \
+ if (qobject_cast<TestItem *>(canvas.activeFocusItem())) \
+ QCOMPARE(qobject_cast<TestItem *>(canvas.activeFocusItem())->focused, true); \
+ else if (qobject_cast<TestFocusScope *>(canvas.activeFocusItem())) \
+ QCOMPARE(qobject_cast<TestFocusScope *>(canvas.activeFocusItem())->focused, true); \
+ } else { \
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); \
+ } \
+ for (QHash<QQuickItem *, FocusData>::Iterator iter = focusState.begin(); \
+ iter != focusState.end(); \
+ iter++) { \
+ QCOMPARE(iter.key()->hasFocus(), iter.value().focus); \
+ QCOMPARE(iter.key()->hasActiveFocus(), iter.value().activeFocus); \
+ } \
+ } while (false)
+
+// Tests a simple set of top-level scoped items
+void tst_qquickitem::simpleFocus()
+{
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-24094: fails on Mac OS X 10.7");
+#endif
+
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *l1c1 = new TestItem(canvas.rootItem());
+ QQuickItem *l1c2 = new TestItem(canvas.rootItem());
+ QQuickItem *l1c3 = new TestItem(canvas.rootItem());
+
+ QQuickItem *l2c1 = new TestItem(l1c1);
+ QQuickItem *l2c2 = new TestItem(l1c1);
+ QQuickItem *l2c3 = new TestItem(l1c3);
+
+ FocusState focusState;
+ focusState << l1c1 << l1c2 << l1c3
+ << l2c1 << l2c2 << l2c3;
+ FVERIFY();
+
+ l1c1->setFocus(true);
+ focusState[l1c1].set(true, true);
+ focusState.active(l1c1);
+ FVERIFY();
+
+ l2c3->setFocus(true);
+ focusState[l1c1].set(false, false);
+ focusState[l2c3].set(true, true);
+ focusState.active(l2c3);
+ FVERIFY();
+
+ l1c3->setFocus(true);
+ focusState[l2c3].set(false, false);
+ focusState[l1c3].set(true, true);
+ focusState.active(l1c3);
+ FVERIFY();
+
+ l1c2->setFocus(false);
+ FVERIFY();
+
+ l1c3->setFocus(false);
+ focusState[l1c3].set(false, false);
+ focusState.active(0);
+ FVERIFY();
+
+ l2c1->setFocus(true);
+ focusState[l2c1].set(true, true);
+ focusState.active(l2c1);
+ FVERIFY();
+}
+
+// Items with a focus scope
+void tst_qquickitem::scopedFocus()
+{
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *l1c1 = new TestItem(canvas.rootItem());
+ QQuickItem *l1c2 = new TestItem(canvas.rootItem());
+ QQuickItem *l1c3 = new TestItem(canvas.rootItem());
+
+ QQuickItem *l2c1 = new TestItem(l1c1);
+ QQuickItem *l2c2 = new TestItem(l1c1);
+ QQuickItem *l2c3 = new TestFocusScope(l1c3);
+
+ QQuickItem *l3c1 = new TestItem(l2c3);
+ QQuickItem *l3c2 = new TestFocusScope(l2c3);
+
+ QQuickItem *l4c1 = new TestItem(l3c2);
+ QQuickItem *l4c2 = new TestItem(l3c2);
+
+ FocusState focusState;
+ focusState << l1c1 << l1c2 << l1c3
+ << l2c1 << l2c2 << l2c3
+ << l3c1 << l3c2
+ << l4c1 << l4c2;
+ FVERIFY();
+
+ l4c2->setFocus(true);
+ focusState[l4c2].set(true, false);
+ FVERIFY();
+
+ l4c1->setFocus(true);
+ focusState[l4c2].set(false, false);
+ focusState[l4c1].set(true, false);
+ FVERIFY();
+
+ l1c1->setFocus(true);
+ focusState[l1c1].set(true, true);
+ focusState.active(l1c1);
+ FVERIFY();
+
+ l3c2->setFocus(true);
+ focusState[l3c2].set(true, false);
+ FVERIFY();
+
+ l2c3->setFocus(true);
+ focusState[l1c1].set(false, false);
+ focusState[l2c3].set(true, true);
+ focusState[l3c2].set(true, true);
+ focusState[l4c1].set(true, true);
+ focusState.active(l4c1);
+ FVERIFY();
+
+ l3c2->setFocus(false);
+ focusState[l3c2].set(false, false);
+ focusState[l4c1].set(true, false);
+ focusState.active(l2c3);
+ FVERIFY();
+
+ l3c2->setFocus(true);
+ focusState[l3c2].set(true, true);
+ focusState[l4c1].set(true, true);
+ focusState.active(l4c1);
+ FVERIFY();
+
+ l4c1->setFocus(false);
+ focusState[l4c1].set(false, false);
+ focusState.active(l3c2);
+ FVERIFY();
+
+ l1c3->setFocus(true);
+ focusState[l1c3].set(true, true);
+ focusState[l2c3].set(false, false);
+ focusState[l3c2].set(true, false);
+ focusState.active(l1c3);
+ FVERIFY();
+}
+
+// Tests focus corrects itself when a tree is added to a canvas for the first time
+void tst_qquickitem::addedToCanvas()
+{
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *item = new TestItem;
+
+ FocusState focusState;
+ focusState << item;
+
+ item->setFocus(true);
+ focusState[item].set(true, false);
+ FVERIFY();
+
+ item->setParentItem(canvas.rootItem());
+ focusState[item].set(true, true);
+ focusState.active(item);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *item = new TestItem(canvas.rootItem());
+
+ QQuickItem *tree = new TestItem;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << item << tree << c1 << c2;
+
+ item->setFocus(true);
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[item].set(true, true);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ focusState.active(item);
+ FVERIFY();
+
+ tree->setParentItem(item);
+ focusState[c1].set(false, false);
+ focusState[c2].set(false, false);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *tree = new TestItem;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << tree << c1 << c2;
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ FVERIFY();
+
+ tree->setParentItem(canvas.rootItem());
+ focusState[c1].set(true, true);
+ focusState[c2].set(false, false);
+ focusState.active(c1);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *tree = new TestFocusScope;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << tree << c1 << c2;
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ FVERIFY();
+
+ tree->setParentItem(canvas.rootItem());
+ focusState[c1].set(true, false);
+ focusState[c2].set(false, false);
+ FVERIFY();
+
+ tree->setFocus(true);
+ focusState[tree].set(true, true);
+ focusState[c1].set(true, true);
+ focusState.active(c1);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *tree = new TestFocusScope;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << tree << c1 << c2;
+ tree->setFocus(true);
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[tree].set(true, false);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ FVERIFY();
+
+ tree->setParentItem(canvas.rootItem());
+ focusState[tree].set(true, true);
+ focusState[c1].set(true, true);
+ focusState[c2].set(false, false);
+ focusState.active(c1);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *tree = new TestFocusScope;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << child << tree << c1 << c2;
+ child->setFocus(true);
+ tree->setFocus(true);
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[child].set(true, true);
+ focusState[tree].set(true, false);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ focusState.active(child);
+ FVERIFY();
+
+ tree->setParentItem(canvas.rootItem());
+ focusState[tree].set(false, false);
+ focusState[c1].set(true, false);
+ focusState[c2].set(false, false);
+ FVERIFY();
+
+ tree->setFocus(true);
+ focusState[child].set(false, false);
+ focusState[tree].set(true, true);
+ focusState[c1].set(true, true);
+ focusState.active(c1);
+ FVERIFY();
+ }
+}
+
+void tst_qquickitem::changeParent()
+{
+ // Parent to no parent
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+
+ FocusState focusState;
+ focusState << child;
+ FVERIFY();
+
+ child->setFocus(true);
+ focusState[child].set(true, true);
+ focusState.active(child);
+ FVERIFY();
+
+ child->setParentItem(0);
+ focusState[child].set(true, false);
+ focusState.active(0);
+ FVERIFY();
+ }
+
+ // Different parent, same focus scope
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *child2 = new TestItem(canvas.rootItem());
+
+ FocusState focusState;
+ focusState << child << child2;
+ FVERIFY();
+
+ child->setFocus(true);
+ focusState[child].set(true, true);
+ focusState.active(child);
+ FVERIFY();
+
+ child->setParentItem(child2);
+ FVERIFY();
+ }
+
+ // Different parent, different focus scope
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
+ QQuickItem *item = new TestItem(child);
+
+ FocusState focusState;
+ focusState << child << child2 << item;
+ FVERIFY();
+
+ item->setFocus(true);
+ focusState[item].set(true, true);
+ focusState.active(item);
+ FVERIFY();
+
+ item->setParentItem(child2);
+ focusState[item].set(true, false);
+ focusState.active(0);
+ FVERIFY();
+ }
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
+ QQuickItem *item = new TestItem(child2);
+
+ FocusState focusState;
+ focusState << child << child2 << item;
+ FVERIFY();
+
+ item->setFocus(true);
+ focusState[item].set(true, false);
+ focusState.active(0);
+ FVERIFY();
+
+ item->setParentItem(child);
+ focusState[item].set(true, true);
+ focusState.active(item);
+ FVERIFY();
+ }
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
+ QQuickItem *item = new TestItem(child2);
+
+ FocusState focusState;
+ focusState << child << child2 << item;
+ FVERIFY();
+
+ child->setFocus(true);
+ item->setFocus(true);
+ focusState[child].set(true, true);
+ focusState[item].set(true, false);
+ focusState.active(child);
+ FVERIFY();
+
+ item->setParentItem(child);
+ focusState[item].set(false, false);
+ FVERIFY();
+ }
+
+}
+
+void tst_qquickitem::constructor()
+{
+ QQuickItem *root = new QQuickItem;
+ QVERIFY(root->parent() == 0);
+ QVERIFY(root->parentItem() == 0);
+
+ QQuickItem *child1 = new QQuickItem(root);
+ QVERIFY(child1->parent() == root);
+ QVERIFY(child1->parentItem() == root);
+ QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().at(0), child1);
+
+ QQuickItem *child2 = new QQuickItem(root);
+ QVERIFY(child2->parent() == root);
+ QVERIFY(child2->parentItem() == root);
+ QCOMPARE(root->childItems().count(), 2);
+ QCOMPARE(root->childItems().at(0), child1);
+ QCOMPARE(root->childItems().at(1), child2);
+
+ delete root;
+}
+
+void tst_qquickitem::setParentItem()
+{
+ QQuickItem *root = new QQuickItem;
+ QVERIFY(root->parent() == 0);
+ QVERIFY(root->parentItem() == 0);
+
+ QQuickItem *child1 = new QQuickItem;
+ QVERIFY(child1->parent() == 0);
+ QVERIFY(child1->parentItem() == 0);
+
+ child1->setParentItem(root);
+ QVERIFY(child1->parent() == 0);
+ QVERIFY(child1->parentItem() == root);
+ QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().at(0), child1);
+
+ QQuickItem *child2 = new QQuickItem;
+ QVERIFY(child2->parent() == 0);
+ QVERIFY(child2->parentItem() == 0);
+ child2->setParentItem(root);
+ QVERIFY(child2->parent() == 0);
+ QVERIFY(child2->parentItem() == root);
+ QCOMPARE(root->childItems().count(), 2);
+ QCOMPARE(root->childItems().at(0), child1);
+ QCOMPARE(root->childItems().at(1), child2);
+
+ child1->setParentItem(0);
+ QVERIFY(child1->parent() == 0);
+ QVERIFY(child1->parentItem() == 0);
+ QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().at(0), child2);
+
+ delete root;
+
+ QVERIFY(child1->parent() == 0);
+ QVERIFY(child1->parentItem() == 0);
+ QVERIFY(child2->parent() == 0);
+ QVERIFY(child2->parentItem() == 0);
+
+ delete child1;
+ delete child2;
+}
+
+void tst_qquickitem::visible()
+{
+ QQuickItem *root = new QQuickItem;
+
+ QQuickItem *child1 = new QQuickItem;
+ child1->setParentItem(root);
+
+ QQuickItem *child2 = new QQuickItem;
+ child2->setParentItem(root);
+
+ QVERIFY(child1->isVisible());
+ QVERIFY(child2->isVisible());
+
+ root->setVisible(false);
+ QVERIFY(!child1->isVisible());
+ QVERIFY(!child2->isVisible());
+
+ root->setVisible(true);
+ QVERIFY(child1->isVisible());
+ QVERIFY(child2->isVisible());
+
+ child1->setVisible(false);
+ QVERIFY(!child1->isVisible());
+ QVERIFY(child2->isVisible());
+
+ child2->setParentItem(child1);
+ QVERIFY(!child1->isVisible());
+ QVERIFY(!child2->isVisible());
+
+ child2->setParentItem(root);
+ QVERIFY(!child1->isVisible());
+ QVERIFY(child2->isVisible());
+
+ delete root;
+ delete child1;
+ delete child2;
+}
+
+void tst_qquickitem::enabled()
+{
+ QQuickItem *root = new QQuickItem;
+
+ QQuickItem *child1 = new QQuickItem;
+ child1->setParentItem(root);
+
+ QQuickItem *child2 = new QQuickItem;
+ child2->setParentItem(root);
+
+ QVERIFY(child1->isEnabled());
+ QVERIFY(child2->isEnabled());
+
+ root->setEnabled(false);
+ QVERIFY(!child1->isEnabled());
+ QVERIFY(!child2->isEnabled());
+
+ root->setEnabled(true);
+ QVERIFY(child1->isEnabled());
+ QVERIFY(child2->isEnabled());
+
+ child1->setEnabled(false);
+ QVERIFY(!child1->isEnabled());
+ QVERIFY(child2->isEnabled());
+
+ child2->setParentItem(child1);
+ QVERIFY(!child1->isEnabled());
+ QVERIFY(!child2->isEnabled());
+
+ child2->setParentItem(root);
+ QVERIFY(!child1->isEnabled());
+ QVERIFY(child2->isEnabled());
+
+ delete root;
+ delete child1;
+ delete child2;
+}
+
+void tst_qquickitem::enabledFocus()
+{
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+
+ QQuickFocusScope root;
+
+ root.setFocus(true);
+ root.setEnabled(false);
+
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+
+ root.setParentItem(canvas.rootItem());
+
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
+
+ root.setEnabled(true);
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ QQuickItem child1;
+ child1.setParentItem(&root);
+
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ QQuickItem child2;
+ child2.setFocus(true);
+ child2.setParentItem(&root);
+
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child2.isEnabled(), true);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), true);
+ QCOMPARE(canvas.activeFocusItem(), &child2);
+
+ child2.setEnabled(false);
+
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ child1.setEnabled(false);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+
+ child1.setFocus(true);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), false);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ child1.setEnabled(true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), true);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&child1));
+
+ root.setFocus(false);
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), false);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
+
+ child2.forceActiveFocus();
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ root.setEnabled(false);
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
+
+ child1.forceActiveFocus();
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), false);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
+
+ root.setEnabled(true);
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), true);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), false);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&child1));
+}
+
+void tst_qquickitem::mouseGrab()
+{
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(200, 200);
+ canvas->show();
+
+ TestItem *child1 = new TestItem;
+ child1->setAcceptedMouseButtons(Qt::LeftButton);
+ child1->setSize(QSizeF(200, 100));
+ child1->setParentItem(canvas->rootItem());
+
+ TestItem *child2 = new TestItem;
+ child2->setAcceptedMouseButtons(Qt::LeftButton);
+ child2->setY(51);
+ child2->setSize(QSizeF(200, 100));
+ child2->setParentItem(canvas->rootItem());
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(100);
+ QVERIFY(canvas->mouseGrabberItem() == child1);
+ QTest::qWait(100);
+
+ QCOMPARE(child1->pressCount, 1);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QVERIFY(canvas->mouseGrabberItem() == 0);
+ QCOMPARE(child1->releaseCount, 1);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QVERIFY(canvas->mouseGrabberItem() == child1);
+ QCOMPARE(child1->pressCount, 2);
+ child1->setEnabled(false);
+ QVERIFY(canvas->mouseGrabberItem() == 0);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QCOMPARE(child1->releaseCount, 1);
+ child1->setEnabled(true);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QVERIFY(canvas->mouseGrabberItem() == child1);
+ QCOMPARE(child1->pressCount, 3);
+ child1->setVisible(false);
+ QVERIFY(canvas->mouseGrabberItem() == 0);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QCOMPARE(child1->releaseCount, 1);
+ child1->setVisible(true);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QVERIFY(canvas->mouseGrabberItem() == child1);
+ QCOMPARE(child1->pressCount, 4);
+ child2->grabMouse();
+ QVERIFY(canvas->mouseGrabberItem() == child2);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QCOMPARE(child1->releaseCount, 1);
+ QCOMPARE(child2->releaseCount, 1);
+
+ child2->grabMouse();
+ QVERIFY(canvas->mouseGrabberItem() == child2);
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QCOMPARE(child1->pressCount, 4);
+ QCOMPARE(child2->pressCount, 1);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QCOMPARE(child1->releaseCount, 1);
+ QCOMPARE(child2->releaseCount, 2);
+
+ delete child1;
+ delete child2;
+ delete canvas;
+}
+
+void tst_qquickitem::touchEventAcceptIgnore_data()
+{
+ QTest::addColumn<bool>("itemSupportsTouch");
+
+ QTest::newRow("with touch") << true;
+ QTest::newRow("without touch") << false;
+}
+
+void tst_qquickitem::touchEventAcceptIgnore()
+{
+ QFETCH(bool, itemSupportsTouch);
+
+ TestCanvas *canvas = new TestCanvas;
+ canvas->resize(100, 100);
+ canvas->show();
+
+ TestItem *item = new TestItem;
+ item->setSize(QSizeF(100, 100));
+ item->setParentItem(canvas->rootItem());
+ item->acceptIncomingTouchEvents = itemSupportsTouch;
+
+ static QTouchDevice* device = 0;
+ if (!device) {
+ device =new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+
+ // Send Begin, Update & End touch sequence
+ {
+ QTouchEvent::TouchPoint point;
+ point.setId(1);
+ point.setPos(QPointF(50, 50));
+ point.setScreenPos(point.pos());
+ point.setState(Qt::TouchPointPressed);
+
+ QTouchEvent event(QEvent::TouchBegin, device,
+ Qt::NoModifier,
+ Qt::TouchPointPressed,
+ QList<QTouchEvent::TouchPoint>() << point);
+ event.setAccepted(true);
+
+ item->touchEventReached = false;
+
+ bool accepted = canvas->event(&event);
+
+ QVERIFY(item->touchEventReached);
+ QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
+ }
+ {
+ QTouchEvent::TouchPoint point;
+ point.setId(1);
+ point.setPos(QPointF(60, 60));
+ point.setScreenPos(point.pos());
+ point.setState(Qt::TouchPointMoved);
+
+ QTouchEvent event(QEvent::TouchUpdate, device,
+ Qt::NoModifier,
+ Qt::TouchPointMoved,
+ QList<QTouchEvent::TouchPoint>() << point);
+ event.setAccepted(true);
+
+ item->touchEventReached = false;
+
+ bool accepted = canvas->event(&event);
+
+ QCOMPARE(item->touchEventReached, itemSupportsTouch);
+ QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
+ }
+ {
+ QTouchEvent::TouchPoint point;
+ point.setId(1);
+ point.setPos(QPointF(60, 60));
+ point.setScreenPos(point.pos());
+ point.setState(Qt::TouchPointReleased);
+
+ QTouchEvent event(QEvent::TouchEnd, device,
+ Qt::NoModifier,
+ Qt::TouchPointReleased,
+ QList<QTouchEvent::TouchPoint>() << point);
+ event.setAccepted(true);
+
+ item->touchEventReached = false;
+
+ bool accepted = canvas->event(&event);
+
+ QCOMPARE(item->touchEventReached, itemSupportsTouch);
+ QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
+ }
+
+ delete item;
+ delete canvas;
+}
+
+void tst_qquickitem::polishOutsideAnimation()
+{
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(200, 200);
+ canvas->show();
+
+ TestPolishItem *item = new TestPolishItem(canvas->rootItem());
+ item->setSize(QSizeF(200, 100));
+ QTest::qWait(50);
+
+ QTimer::singleShot(10, item, SLOT(doPolish()));
+ QTRY_VERIFY(item->wasPolished);
+
+ delete item;
+ delete canvas;
+}
+
+void tst_qquickitem::polishOnCompleted()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("polishOnCompleted.qml"));
+ view->show();
+
+ TestPolishItem *item = qobject_cast<TestPolishItem*>(view->rootObject());
+ QVERIFY(item);
+
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation");
+#endif
+
+ QTRY_VERIFY(item->wasPolished);
+
+ delete view;
+}
+
+void tst_qquickitem::wheelEvent_data()
+{
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("enabled");
+
+ QTest::newRow("visible and enabled") << true << true;
+ QTest::newRow("visible and disabled") << true << false;
+ QTest::newRow("invisible and enabled") << false << true;
+ QTest::newRow("invisible and disabled") << false << false;
+}
+
+void tst_qquickitem::wheelEvent()
+{
+ QFETCH(bool, visible);
+ QFETCH(bool, enabled);
+
+ const bool shouldReceiveWheelEvents = visible && enabled;
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(200, 200);
+ canvas->show();
+
+ TestItem *item = new TestItem;
+ item->setSize(QSizeF(200, 100));
+ item->setParentItem(canvas->rootItem());
+
+ item->setEnabled(enabled);
+ item->setVisible(visible);
+
+ QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
+ event.setAccepted(false);
+ QGuiApplication::sendEvent(canvas, &event);
+
+ if (shouldReceiveWheelEvents) {
+ QVERIFY(event.isAccepted());
+ QCOMPARE(item->wheelCount, 1);
+ } else {
+ QVERIFY(!event.isAccepted());
+ QCOMPARE(item->wheelCount, 0);
+ }
+
+ delete canvas;
+}
+
+class HoverItem : public QQuickItem
+{
+Q_OBJECT
+public:
+ HoverItem(QQuickItem *parent = 0)
+ : QQuickItem(parent), hoverEnterCount(0), hoverMoveCount(0), hoverLeaveCount(0)
+ { }
+ void resetCounters() {
+ hoverEnterCount = 0;
+ hoverMoveCount = 0;
+ hoverLeaveCount = 0;
+ }
+ int hoverEnterCount;
+ int hoverMoveCount;
+ int hoverLeaveCount;
+protected:
+ virtual void hoverEnterEvent(QHoverEvent *event) {
+ event->accept();
+ ++hoverEnterCount;
+ }
+ virtual void hoverMoveEvent(QHoverEvent *event) {
+ event->accept();
+ ++hoverMoveCount;
+ }
+ virtual void hoverLeaveEvent(QHoverEvent *event) {
+ event->accept();
+ ++hoverLeaveCount;
+ }
+};
+
+void tst_qquickitem::hoverEvent_data()
+{
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("enabled");
+ QTest::addColumn<bool>("acceptHoverEvents");
+
+ QTest::newRow("visible, enabled, accept hover") << true << true << true;
+ QTest::newRow("visible, disabled, accept hover") << true << false << true;
+ QTest::newRow("invisible, enabled, accept hover") << false << true << true;
+ QTest::newRow("invisible, disabled, accept hover") << false << false << true;
+
+ QTest::newRow("visible, enabled, not accept hover") << true << true << false;
+ QTest::newRow("visible, disabled, not accept hover") << true << false << false;
+ QTest::newRow("invisible, enabled, not accept hover") << false << true << false;
+ QTest::newRow("invisible, disabled, not accept hover") << false << false << false;
+}
+
+// ### For some unknown reason QTest::mouseMove() isn't working correctly.
+static void sendMouseMove(QObject *object, const QPoint &position)
+{
+ QMouseEvent moveEvent(QEvent::MouseMove, position, Qt::NoButton, Qt::NoButton, 0);
+ QGuiApplication::sendEvent(object, &moveEvent);
+}
+
+void tst_qquickitem::hoverEvent()
+{
+ QFETCH(bool, visible);
+ QFETCH(bool, enabled);
+ QFETCH(bool, acceptHoverEvents);
+
+ QQuickCanvas *canvas = new QQuickCanvas();
+ canvas->resize(200, 200);
+ canvas->show();
+
+ HoverItem *item = new HoverItem;
+ item->setSize(QSizeF(100, 100));
+ item->setParentItem(canvas->rootItem());
+
+ item->setEnabled(enabled);
+ item->setVisible(visible);
+ item->setAcceptHoverEvents(acceptHoverEvents);
+
+ const QPoint outside(150, 150);
+ const QPoint inside(50, 50);
+ const QPoint anotherInside(51, 51);
+
+ sendMouseMove(canvas, outside);
+ item->resetCounters();
+
+ // Enter, then move twice inside, then leave.
+ sendMouseMove(canvas, inside);
+ sendMouseMove(canvas, anotherInside);
+ sendMouseMove(canvas, inside);
+ sendMouseMove(canvas, outside);
+
+ const bool shouldReceiveHoverEvents = visible && enabled && acceptHoverEvents;
+ if (shouldReceiveHoverEvents) {
+ QCOMPARE(item->hoverEnterCount, 1);
+ QCOMPARE(item->hoverMoveCount, 2);
+ QCOMPARE(item->hoverLeaveCount, 1);
+ } else {
+ QCOMPARE(item->hoverEnterCount, 0);
+ QCOMPARE(item->hoverMoveCount, 0);
+ QCOMPARE(item->hoverLeaveCount, 0);
+ }
+
+ delete canvas;
+}
+
+void tst_qquickitem::hoverEventInParent()
+{
+ QQuickCanvas *canvas = new QQuickCanvas();
+ canvas->resize(200, 200);
+ canvas->show();
+
+ HoverItem *parentItem = new HoverItem(canvas->rootItem());
+ parentItem->setSize(QSizeF(200, 200));
+ parentItem->setAcceptHoverEvents(true);
+
+ HoverItem *leftItem = new HoverItem(parentItem);
+ leftItem->setSize(QSizeF(100, 200));
+ leftItem->setAcceptHoverEvents(true);
+
+ HoverItem *rightItem = new HoverItem(parentItem);
+ rightItem->setSize(QSizeF(100, 200));
+ rightItem->setPos(QPointF(100, 0));
+ rightItem->setAcceptHoverEvents(true);
+
+ const QPoint insideLeft(50, 100);
+ const QPoint insideRight(150, 100);
+
+ sendMouseMove(canvas, insideLeft);
+ parentItem->resetCounters();
+ leftItem->resetCounters();
+ rightItem->resetCounters();
+
+ sendMouseMove(canvas, insideRight);
+ QCOMPARE(parentItem->hoverEnterCount, 0);
+ QCOMPARE(parentItem->hoverLeaveCount, 0);
+ QCOMPARE(leftItem->hoverEnterCount, 0);
+ QCOMPARE(leftItem->hoverLeaveCount, 1);
+ QCOMPARE(rightItem->hoverEnterCount, 1);
+ QCOMPARE(rightItem->hoverLeaveCount, 0);
+
+ sendMouseMove(canvas, insideLeft);
+ QCOMPARE(parentItem->hoverEnterCount, 0);
+ QCOMPARE(parentItem->hoverLeaveCount, 0);
+ QCOMPARE(leftItem->hoverEnterCount, 1);
+ QCOMPARE(leftItem->hoverLeaveCount, 1);
+ QCOMPARE(rightItem->hoverEnterCount, 1);
+ QCOMPARE(rightItem->hoverLeaveCount, 1);
+
+ delete canvas;
+}
+
+void tst_qquickitem::paintOrder_data()
+{
+ const QUrl order1Url = testFileUrl("order.1.qml");
+ const QUrl order2Url = testFileUrl("order.2.qml");
+
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<int>("op");
+ QTest::addColumn<QVariant>("param1");
+ QTest::addColumn<QVariant>("param2");
+ QTest::addColumn<QStringList>("expected");
+
+ QTest::newRow("test 1 noop") << order1Url
+ << int(NoOp) << QVariant() << QVariant()
+ << (QStringList() << "1" << "2" << "3");
+ QTest::newRow("test 1 add") << order1Url
+ << int(Append) << QVariant("new") << QVariant()
+ << (QStringList() << "1" << "2" << "3" << "new");
+ QTest::newRow("test 1 remove") << order1Url
+ << int(Remove) << QVariant(1) << QVariant()
+ << (QStringList() << "1" << "3");
+ QTest::newRow("test 1 stack before") << order1Url
+ << int(StackBefore) << QVariant(2) << QVariant(1)
+ << (QStringList() << "1" << "3" << "2");
+ QTest::newRow("test 1 stack after") << order1Url
+ << int(StackAfter) << QVariant(0) << QVariant(1)
+ << (QStringList() << "2" << "1" << "3");
+ QTest::newRow("test 1 set z") << order1Url
+ << int(SetZ) << QVariant(1) << QVariant(qreal(1.))
+ << (QStringList() << "1" << "3" << "2");
+
+ QTest::newRow("test 2 noop") << order2Url
+ << int(NoOp) << QVariant() << QVariant()
+ << (QStringList() << "1" << "3" << "2");
+ QTest::newRow("test 2 add") << order2Url
+ << int(Append) << QVariant("new") << QVariant()
+ << (QStringList() << "1" << "3" << "new" << "2");
+ QTest::newRow("test 2 remove 1") << order2Url
+ << int(Remove) << QVariant(1) << QVariant()
+ << (QStringList() << "1" << "3");
+ QTest::newRow("test 2 remove 2") << order2Url
+ << int(Remove) << QVariant(2) << QVariant()
+ << (QStringList() << "1" << "2");
+ QTest::newRow("test 2 stack before 1") << order2Url
+ << int(StackBefore) << QVariant(1) << QVariant(0)
+ << (QStringList() << "1" << "3" << "2");
+ QTest::newRow("test 2 stack before 2") << order2Url
+ << int(StackBefore) << QVariant(2) << QVariant(0)
+ << (QStringList() << "3" << "1" << "2");
+ QTest::newRow("test 2 stack after 1") << order2Url
+ << int(StackAfter) << QVariant(0) << QVariant(1)
+ << (QStringList() << "1" << "3" << "2");
+ QTest::newRow("test 2 stack after 2") << order2Url
+ << int(StackAfter) << QVariant(0) << QVariant(2)
+ << (QStringList() << "3" << "1" << "2");
+ QTest::newRow("test 1 set z") << order1Url
+ << int(SetZ) << QVariant(2) << QVariant(qreal(2.))
+ << (QStringList() << "1" << "2" << "3");
+}
+
+void tst_qquickitem::paintOrder()
+{
+ QFETCH(QUrl, source);
+ QFETCH(int, op);
+ QFETCH(QVariant, param1);
+ QFETCH(QVariant, param2);
+ QFETCH(QStringList, expected);
+
+ QQuickView view;
+ view.setSource(source);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject());
+ QVERIFY(root);
+
+ switch (op) {
+ case Append: {
+ QQuickItem *item = new QQuickItem(root);
+ item->setObjectName(param1.toString());
+ }
+ break;
+ case Remove: {
+ QQuickItem *item = root->childItems().at(param1.toInt());
+ delete item;
+ }
+ break;
+ case StackBefore: {
+ QQuickItem *item1 = root->childItems().at(param1.toInt());
+ QQuickItem *item2 = root->childItems().at(param2.toInt());
+ item1->stackBefore(item2);
+ }
+ break;
+ case StackAfter: {
+ QQuickItem *item1 = root->childItems().at(param1.toInt());
+ QQuickItem *item2 = root->childItems().at(param2.toInt());
+ item1->stackAfter(item2);
+ }
+ break;
+ case SetZ: {
+ QQuickItem *item = root->childItems().at(param1.toInt());
+ item->setZ(param2.toReal());
+ }
+ break;
+ default:
+ break;
+ }
+
+ QList<QQuickItem*> list = QQuickItemPrivate::get(root)->paintOrderChildItems();
+
+ QStringList items;
+ for (int i = 0; i < list.count(); ++i)
+ items << list.at(i)->objectName();
+
+ QCOMPARE(items, expected);
+}
+
+
+QTEST_MAIN(tst_qquickitem)
+
+#include "tst_qquickitem.moc"
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml b/tests/auto/quick/qquickitem2/data/childrenProperty.qml
index 85ddbc1446..85ddbc1446 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenProperty.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml b/tests/auto/quick/qquickitem2/data/childrenRect.qml
index ebc57aefbe..ebc57aefbe 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenRect.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug.qml
index 86a4f19c5c..86a4f19c5c 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenRectBug.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml
index 6e80ed28af..6e80ed28af 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml
index 518e76509e..518e76509e 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml b/tests/auto/quick/qquickitem2/data/implicitsize.qml
index cc6aaf7d60..cc6aaf7d60 100644
--- a/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml
+++ b/tests/auto/quick/qquickitem2/data/implicitsize.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest.qml
index aacb621fb0..aacb621fb0 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml
+++ b/tests/auto/quick/qquickitem2/data/keynavigationtest.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml
index 92d4ae23de..92d4ae23de 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml
+++ b/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keysim.qml b/tests/auto/quick/qquickitem2/data/keysim.qml
index 7da8a47681..7da8a47681 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keysim.qml
+++ b/tests/auto/quick/qquickitem2/data/keysim.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml b/tests/auto/quick/qquickitem2/data/keyspriority.qml
index ae51aae776..ae51aae776 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml
+++ b/tests/auto/quick/qquickitem2/data/keyspriority.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keystest.qml b/tests/auto/quick/qquickitem2/data/keystest.qml
index c70e0061f5..c70e0061f5 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keystest.qml
+++ b/tests/auto/quick/qquickitem2/data/keystest.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml b/tests/auto/quick/qquickitem2/data/layoutmirroring.qml
index 036819740c..036819740c 100644
--- a/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml
+++ b/tests/auto/quick/qquickitem2/data/layoutmirroring.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml
index 7b979a54b3..7b979a54b3 100644
--- a/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml
+++ b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml b/tests/auto/quick/qquickitem2/data/parentLoop.qml
index 7b6560fbf7..7b6560fbf7 100644
--- a/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml
+++ b/tests/auto/quick/qquickitem2/data/parentLoop.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml b/tests/auto/quick/qquickitem2/data/propertychanges.qml
index 3fa5ea9c23..3fa5ea9c23 100644
--- a/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml
+++ b/tests/auto/quick/qquickitem2/data/propertychanges.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml b/tests/auto/quick/qquickitem2/data/qtbug_16871.qml
index f1e7377730..f1e7377730 100644
--- a/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml
+++ b/tests/auto/quick/qquickitem2/data/qtbug_16871.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml b/tests/auto/quick/qquickitem2/data/resourcesProperty.qml
index b8f18bb375..b8f18bb375 100644
--- a/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml
+++ b/tests/auto/quick/qquickitem2/data/resourcesProperty.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml b/tests/auto/quick/qquickitem2/data/transformCrash.qml
index 284e85f0e0..284e85f0e0 100644
--- a/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml
+++ b/tests/auto/quick/qquickitem2/data/transformCrash.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml b/tests/auto/quick/qquickitem2/data/visiblechildren.qml
index e51eb3551b..e51eb3551b 100644
--- a/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml
+++ b/tests/auto/quick/qquickitem2/data/visiblechildren.qml
diff --git a/tests/auto/quick/qquickitem2/qquickitem2.pro b/tests/auto/quick/qquickitem2/qquickitem2.pro
new file mode 100644
index 0000000000..29897ba3c1
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/qquickitem2.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickitem2
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickitem.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
new file mode 100644
index 0000000000..c2390c4525
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -0,0 +1,1380 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/qquickview.h>
+#include <QtGui/private/qinputmethod_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquicktextinput_p.h>
+#include <private/qquickitem_p.h>
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+#include "../../shared/platforminputcontext.h"
+
+using namespace QQuickVisualTestUtil;
+
+class tst_QQuickItem : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickItem();
+
+private slots:
+ void initTestCase();
+ void cleanup();
+
+ void keys();
+ void keysProcessingOrder();
+ void keysim();
+ void keyNavigation();
+ void keyNavigation_RightToLeft();
+ void keyNavigation_skipNotVisible();
+ void keyNavigation_implicitSetting();
+ void layoutMirroring();
+ void layoutMirroringIllegalParent();
+ void smooth();
+ void clip();
+ void mapCoordinates();
+ void mapCoordinates_data();
+ void propertyChanges();
+ void transforms();
+ void transforms_data();
+ void childrenRect();
+ void childrenRectBug();
+ void childrenRectBug2();
+ void childrenRectBug3();
+
+ void childrenProperty();
+ void resourcesProperty();
+
+ void transformCrash();
+ void implicitSize();
+ void qtbug_16871();
+ void visibleChildren();
+ void parentLoop();
+private:
+ QQmlEngine engine;
+};
+
+class KeysTestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged)
+
+public:
+ KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {}
+
+ void reset() {
+ mKey = 0;
+ mText = QString();
+ mModifiers = 0;
+ mForwardedKey = 0;
+ }
+
+ bool processLast() const { return mLast; }
+ void setProcessLast(bool b) {
+ if (b != mLast) {
+ mLast = b;
+ emit processLastChanged();
+ }
+ }
+
+public slots:
+ void keyPress(int key, QString text, int modifiers) {
+ mKey = key;
+ mText = text;
+ mModifiers = modifiers;
+ }
+ void keyRelease(int key, QString text, int modifiers) {
+ mKey = key;
+ mText = text;
+ mModifiers = modifiers;
+ }
+ void forwardedKey(int key) {
+ mForwardedKey = key;
+ }
+
+signals:
+ void processLastChanged();
+
+public:
+ int mKey;
+ QString mText;
+ int mModifiers;
+ int mForwardedKey;
+ bool mLast;
+
+private:
+};
+
+class KeyTestItem : public QQuickItem
+{
+ Q_OBJECT
+public:
+ KeyTestItem(QQuickItem *parent=0) : QQuickItem(parent), mKey(0) {}
+
+protected:
+ void keyPressEvent(QKeyEvent *e) {
+ mKey = e->key();
+
+ if (e->key() == Qt::Key_A)
+ e->accept();
+ else
+ e->ignore();
+ }
+
+ void keyReleaseEvent(QKeyEvent *e) {
+ if (e->key() == Qt::Key_B)
+ e->accept();
+ else
+ e->ignore();
+ }
+
+public:
+ int mKey;
+};
+
+QML_DECLARE_TYPE(KeyTestItem);
+
+
+tst_QQuickItem::tst_QQuickItem()
+{
+}
+
+void tst_QQuickItem::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem");
+}
+
+void tst_QQuickItem::cleanup()
+{
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
+void tst_QQuickItem::keys()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ KeysTestObject *testObject = new KeysTestObject;
+ canvas->rootContext()->setContextProperty("keysTestObject", testObject);
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
+ canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true));
+
+ canvas->setSource(testFileUrl("keystest.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QVERIFY(canvas->rootObject());
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::ShiftModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Return));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return));
+ QCOMPARE(testObject->mText, QLatin1String("Return"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_0));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0));
+ QCOMPARE(testObject->mText, QLatin1String("0"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_9));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9));
+ QCOMPARE(testObject->mText, QLatin1String("9"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Tab));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab));
+ QCOMPARE(testObject->mText, QLatin1String("Tab"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Backtab));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab));
+ QCOMPARE(testObject->mText, QLatin1String("Backtab"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false));
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mForwardedKey, 0);
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, 0);
+ QVERIFY(!key.isAccepted());
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Return));
+ QVERIFY(key.isAccepted());
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickItem::keysProcessingOrder()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ KeysTestObject *testObject = new KeysTestObject;
+ canvas->rootContext()->setContextProperty("keysTestObject", testObject);
+
+ canvas->setSource(testFileUrl("keyspriority.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ KeyTestItem *testItem = qobject_cast<KeyTestItem*>(canvas->rootObject());
+ QVERIFY(testItem);
+
+ QCOMPARE(testItem->property("priorityTest").toInt(), 0);
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ testObject->setProcessLast(true);
+
+ QCOMPARE(testItem->property("priorityTest").toInt(), 1);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, 0);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_B));
+ QCOMPARE(testObject->mText, QLatin1String("B"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, 0);
+ QVERIFY(key.isAccepted());
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickItem::keysim()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keysim.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QVERIFY(canvas->rootObject());
+ QVERIFY(canvas->rootObject()->hasFocus() && canvas->rootObject()->hasActiveFocus());
+
+ QQuickTextInput *input = canvas->rootObject()->findChild<QQuickTextInput*>();
+ QVERIFY(input);
+
+ QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev);
+
+ QEXPECT_FAIL("", "QTBUG-24280", Continue);
+ QCOMPARE(input->text(), QLatin1String("Hello world!"));
+
+ delete canvas;
+}
+
+QQuickItemPrivate *childPrivate(QQuickItem *rootItem, const char * itemString)
+{
+ QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
+ QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item);
+ return itemPrivate;
+}
+
+QVariant childProperty(QQuickItem *rootItem, const char * itemString, const char * property)
+{
+ QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
+ return item->property(property);
+}
+
+bool anchorsMirrored(QQuickItem *rootItem, const char * itemString)
+{
+ QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
+ QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item);
+ return itemPrivate->anchors()->mirrored();
+}
+
+void tst_QQuickItem::layoutMirroring()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("layoutmirroring.qml"));
+ canvas->show();
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem);
+ QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(rootItem);
+ QVERIFY(rootPrivate);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
+
+ QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true);
+ QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true);
+ QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false);
+ QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false);
+ QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true);
+ QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false);
+
+ // load dynamic content using Loader that needs to inherit mirroring
+ rootItem->setProperty("state", "newContent");
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true);
+
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true);
+
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true);
+
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true);
+
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
+
+ // disable inheritance
+ rootItem->setProperty("childrenInherit", false);
+
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
+
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false);
+
+ // re-enable inheritance
+ rootItem->setProperty("childrenInherit", true);
+
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
+
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
+
+ //
+ // dynamic parenting
+ //
+ QQuickItem *parentItem1 = new QQuickItem();
+ QQuickItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
+ QQuickItemPrivate::get(parentItem1)->isMirrorImplicit = false;
+ QQuickItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true
+ QQuickItemPrivate::get(parentItem1)->resolveLayoutMirror();
+
+ // inherit in constructor
+ QQuickItem *childItem1 = new QQuickItem(parentItem1);
+ QCOMPARE(QQuickItemPrivate::get(childItem1)->effectiveLayoutMirror, true);
+ QCOMPARE(QQuickItemPrivate::get(childItem1)->inheritMirrorFromParent, true);
+
+ // inherit through a parent change
+ QQuickItem *childItem2 = new QQuickItem();
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
+ childItem2->setParentItem(parentItem1);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, true);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, true);
+
+ // stop inherting through a parent change
+ QQuickItem *parentItem2 = new QQuickItem();
+ QQuickItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
+ QQuickItemPrivate::get(parentItem2)->resolveLayoutMirror();
+ childItem2->setParentItem(parentItem2);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
+
+ delete parentItem1;
+ delete parentItem2;
+}
+
+void tst_QQuickItem::layoutMirroringIllegalParent()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile(""));
+ QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items");
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_QQuickItem::keyNavigation()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // down
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // left
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // up
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::keyNavigation_RightToLeft()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem);
+ QQuickItemPrivate* rootItemPrivate = QQuickItemPrivate::get(rootItem);
+
+ rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true
+ rootItemPrivate->isMirrorImplicit = false;
+ rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true
+ rootItemPrivate->resolveLayoutMirror();
+
+ QEvent wa(QEvent::WindowActivate);
+ QGuiApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QGuiApplication::sendEvent(canvas, &fe);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // left
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::keyNavigation_skipNotVisible()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Set item 2 to not visible
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ item->setVisible(false);
+ QVERIFY(!item->isVisible());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ //Set item 3 to not visible
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ item->setVisible(false);
+ QVERIFY(!item->isVisible());
+
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::keyNavigation_implicitSetting()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keynavigationtest_implicit.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QEvent wa(QEvent::WindowActivate);
+ QGuiApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QGuiApplication::sendEvent(canvas, &fe);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // back to item1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // down
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // move to item4
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // left
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // back to item4
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // up
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // back to item4
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // back to item4
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::smooth()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { smooth: false; }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(smoothChanged(bool)));
+
+ QVERIFY(item);
+ QVERIFY(!item->smooth());
+
+ item->setSmooth(true);
+ QVERIFY(item->smooth());
+ QCOMPARE(spy.count(),1);
+ QList<QVariant> arguments = spy.first();
+ QVERIFY(arguments.count() == 1);
+ QVERIFY(arguments.at(0).toBool() == true);
+
+ item->setSmooth(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setSmooth(false);
+ QVERIFY(!item->smooth());
+ QCOMPARE(spy.count(),2);
+ item->setSmooth(false);
+ QCOMPARE(spy.count(),2);
+
+ delete item;
+}
+
+void tst_QQuickItem::clip()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem { clip: false\n }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(clipChanged(bool)));
+
+ QVERIFY(item);
+ QVERIFY(!item->clip());
+
+ item->setClip(true);
+ QVERIFY(item->clip());
+
+ QList<QVariant> arguments = spy.first();
+ QVERIFY(arguments.count() == 1);
+ QVERIFY(arguments.at(0).toBool() == true);
+
+ QCOMPARE(spy.count(),1);
+ item->setClip(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setClip(false);
+ QVERIFY(!item->clip());
+ QCOMPARE(spy.count(),2);
+ item->setClip(false);
+ QCOMPARE(spy.count(),2);
+
+ delete item;
+}
+
+void tst_QQuickItem::mapCoordinates()
+{
+ QFETCH(int, x);
+ QFETCH(int, y);
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(300, 300));
+ canvas->setSource(testFileUrl("mapCoordinates.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+ QQuickItem *a = findItem<QQuickItem>(canvas->rootObject(), "itemA");
+ QVERIFY(a != 0);
+ QQuickItem *b = findItem<QQuickItem>(canvas->rootObject(), "itemB");
+ QVERIFY(b != 0);
+
+ QVariant result;
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAToB",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToItem(b, QPointF(x, y)));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromItem(b, QPointF(x, y)));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToScene(QPointF(x, y)));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromScene(QPointF(x, y)));
+
+ QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
+ QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QVERIFY(result.toBool());
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QVERIFY(result.toBool());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::mapCoordinates_data()
+{
+ QTest::addColumn<int>("x");
+ QTest::addColumn<int>("y");
+
+ for (int i=-20; i<=20; i+=10)
+ QTest::newRow(QTest::toString(i)) << i << i;
+}
+
+void tst_QQuickItem::transforms_data()
+{
+ QTest::addColumn<QByteArray>("qml");
+ QTest::addColumn<QTransform>("transform");
+ QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }")
+ << QTransform(1,0,0,0,1,0,10,20,1);
+ QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }")
+ << QTransform(0,1,0,-1,0,0,0,0,1);
+ QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }")
+ << QTransform(1.5,0,0,0,-2,0,0,0,1);
+ QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]")
+ << QTransform(1,0,0,0,1,0,10,20,1) * QTransform(1.5,0,0,0,-2,0,0,0,1);
+}
+
+void tst_QQuickItem::transforms()
+{
+ QFETCH(QByteArray, qml);
+ QFETCH(QTransform, transform);
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(item->itemTransform(0,0), transform);
+}
+
+void tst_QQuickItem::childrenProperty()
+{
+ QQmlComponent component(&engine, testFileUrl("childrenProperty.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ delete o;
+}
+
+void tst_QQuickItem::resourcesProperty()
+{
+ QQmlComponent component(&engine, testFileUrl("resourcesProperty.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ delete o;
+}
+
+void tst_QQuickItem::propertyChanges()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(300, 300));
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item");
+ QQuickItem *parentItem = findItem<QQuickItem>(canvas->rootObject(), "parentItem");
+
+ QVERIFY(item);
+ QVERIFY(parentItem);
+
+ QSignalSpy parentSpy(item, SIGNAL(parentChanged(QQuickItem *)));
+ QSignalSpy widthSpy(item, SIGNAL(widthChanged()));
+ QSignalSpy heightSpy(item, SIGNAL(heightChanged()));
+ QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
+ QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
+ QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
+ QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged()));
+ QSignalSpy xSpy(item, SIGNAL(xChanged()));
+ QSignalSpy ySpy(item, SIGNAL(yChanged()));
+
+ item->setParentItem(parentItem);
+ item->setWidth(100.0);
+ item->setHeight(200.0);
+ item->setFocus(true);
+ item->setBaselineOffset(10.0);
+
+ QCOMPARE(item->parentItem(), parentItem);
+ QCOMPARE(parentSpy.count(),1);
+ QList<QVariant> parentArguments = parentSpy.first();
+ QVERIFY(parentArguments.count() == 1);
+ QCOMPARE(item->parentItem(), qvariant_cast<QQuickItem *>(parentArguments.at(0)));
+ QCOMPARE(childrenChangedSpy.count(),1);
+
+ item->setParentItem(parentItem);
+ QCOMPARE(childrenChangedSpy.count(),1);
+
+ QCOMPARE(item->width(), 100.0);
+ QCOMPARE(widthSpy.count(),1);
+
+ QCOMPARE(item->height(), 200.0);
+ QCOMPARE(heightSpy.count(),1);
+
+ QCOMPARE(item->baselineOffset(), 10.0);
+ QCOMPARE(baselineOffsetSpy.count(),1);
+ QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
+ QVERIFY(baselineOffsetArguments.count() == 1);
+ QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
+
+ QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
+ QCOMPARE(childrenRectSpy.count(),1);
+ QList<QVariant> childrenRectArguments = childrenRectSpy.at(0);
+ QVERIFY(childrenRectArguments.count() == 1);
+ QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
+
+ QCOMPARE(item->hasActiveFocus(), true);
+ QCOMPARE(focusSpy.count(),1);
+ QList<QVariant> focusArguments = focusSpy.first();
+ QVERIFY(focusArguments.count() == 1);
+ QCOMPARE(focusArguments.at(0).toBool(), true);
+
+ QCOMPARE(parentItem->hasActiveFocus(), false);
+ QCOMPARE(parentItem->hasFocus(), false);
+ QCOMPARE(wantsFocusSpy.count(),0);
+
+ item->setX(10.0);
+ QCOMPARE(item->x(), 10.0);
+ QCOMPARE(xSpy.count(), 1);
+
+ item->setY(10.0);
+ QCOMPARE(item->y(), 10.0);
+ QCOMPARE(ySpy.count(), 1);
+
+ delete canvas;
+}
+
+void tst_QQuickItem::childrenRect()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("childrenRect.qml"));
+ canvas->setBaseSize(QSize(240,320));
+ canvas->show();
+
+ QQuickItem *o = canvas->rootObject();
+ QQuickItem *item = o->findChild<QQuickItem*>("testItem");
+ QCOMPARE(item->width(), qreal(0));
+ QCOMPARE(item->height(), qreal(0));
+
+ o->setProperty("childCount", 1);
+ QCOMPARE(item->width(), qreal(10));
+ QCOMPARE(item->height(), qreal(20));
+
+ o->setProperty("childCount", 5);
+ QCOMPARE(item->width(), qreal(50));
+ QCOMPARE(item->height(), qreal(100));
+
+ o->setProperty("childCount", 0);
+ QCOMPARE(item->width(), qreal(0));
+ QCOMPARE(item->height(), qreal(0));
+
+ delete o;
+ delete canvas;
+}
+
+// QTBUG-11383
+void tst_QQuickItem::childrenRectBug()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ canvas->setSource(testFileUrl("childrenRectBug.qml"));
+ canvas->show();
+
+ QQuickItem *o = canvas->rootObject();
+ QQuickItem *item = o->findChild<QQuickItem*>("theItem");
+ QCOMPARE(item->width(), qreal(200));
+ QCOMPARE(item->height(), qreal(100));
+ QCOMPARE(item->x(), qreal(100));
+
+ delete canvas;
+}
+
+// QTBUG-11465
+void tst_QQuickItem::childrenRectBug2()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\"";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ canvas->setSource(testFileUrl("childrenRectBug2.qml"));
+ canvas->show();
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(canvas->rootObject());
+ QVERIFY(rect);
+ QQuickItem *item = rect->findChild<QQuickItem*>("theItem");
+ QCOMPARE(item->width(), qreal(100));
+ QCOMPARE(item->height(), qreal(110));
+ QCOMPARE(item->x(), qreal(130));
+
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ rectPrivate->setState("row");
+ QCOMPARE(item->width(), qreal(210));
+ QCOMPARE(item->height(), qreal(50));
+ QCOMPARE(item->x(), qreal(75));
+
+ delete canvas;
+}
+
+// QTBUG-12722
+void tst_QQuickItem::childrenRectBug3()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("childrenRectBug3.qml"));
+ canvas->show();
+
+ //don't crash on delete
+ delete canvas;
+}
+
+// QTBUG-13893
+void tst_QQuickItem::transformCrash()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("transformCrash.qml"));
+ canvas->show();
+
+ delete canvas;
+}
+
+void tst_QQuickItem::implicitSize()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("implicitsize.qml"));
+ canvas->show();
+
+ QQuickItem *item = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(item);
+ QCOMPARE(item->width(), qreal(80));
+ QCOMPARE(item->height(), qreal(60));
+
+ QCOMPARE(item->implicitWidth(), qreal(200));
+ QCOMPARE(item->implicitHeight(), qreal(100));
+
+ QMetaObject::invokeMethod(item, "resetSize");
+
+ QCOMPARE(item->width(), qreal(200));
+ QCOMPARE(item->height(), qreal(100));
+
+ QMetaObject::invokeMethod(item, "changeImplicit");
+
+ QCOMPARE(item->implicitWidth(), qreal(150));
+ QCOMPARE(item->implicitHeight(), qreal(80));
+ QCOMPARE(item->width(), qreal(150));
+ QCOMPARE(item->height(), qreal(80));
+
+ delete canvas;
+}
+
+void tst_QQuickItem::qtbug_16871()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_16871.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+}
+
+
+void tst_QQuickItem::visibleChildren()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("visiblechildren.qml"));
+ canvas->show();
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+
+ QCOMPARE(root->property("test1_1").toBool(), true);
+ QCOMPARE(root->property("test1_2").toBool(), true);
+ QCOMPARE(root->property("test1_3").toBool(), true);
+ QCOMPARE(root->property("test1_4").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "hideFirstAndLastRowChild");
+ QCOMPARE(root->property("test2_1").toBool(), true);
+ QCOMPARE(root->property("test2_2").toBool(), true);
+ QCOMPARE(root->property("test2_3").toBool(), true);
+ QCOMPARE(root->property("test2_4").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "showLastRowChildsLastChild");
+ QCOMPARE(root->property("test3_1").toBool(), true);
+ QCOMPARE(root->property("test3_2").toBool(), true);
+ QCOMPARE(root->property("test3_3").toBool(), true);
+ QCOMPARE(root->property("test3_4").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "showLastRowChild");
+ QCOMPARE(root->property("test4_1").toBool(), true);
+ QCOMPARE(root->property("test4_2").toBool(), true);
+ QCOMPARE(root->property("test4_3").toBool(), true);
+ QCOMPARE(root->property("test4_4").toBool(), true);
+
+ QString warning1 = testFileUrl("visiblechildren.qml").toString() + ":96:32: QML Item: QQuickItem: visibleChildren property is readonly and cannot be assigned to.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QMetaObject::invokeMethod(root, "tryWriteToReadonlyVisibleChildren");
+ QCOMPARE(root->property("test5_1").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "reparentVisibleItem3");
+ QCOMPARE(root->property("test6_1").toBool(), true);
+ QCOMPARE(root->property("test6_2").toBool(), true);
+ QCOMPARE(root->property("test6_3").toBool(), true);
+ QCOMPARE(root->property("test6_4").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "reparentImlicitlyInvisibleItem4_1");
+ QCOMPARE(root->property("test7_1").toBool(), true);
+ QCOMPARE(root->property("test7_2").toBool(), true);
+ QCOMPARE(root->property("test7_3").toBool(), true);
+ QCOMPARE(root->property("test7_4").toBool(), true);
+
+ // FINALLY TEST THAT EVERYTHING IS AS EXPECTED
+ QCOMPARE(root->property("test8_1").toBool(), true);
+ QCOMPARE(root->property("test8_2").toBool(), true);
+ QCOMPARE(root->property("test8_3").toBool(), true);
+ QCOMPARE(root->property("test8_4").toBool(), true);
+ QCOMPARE(root->property("test8_5").toBool(), true);
+
+ delete canvas;
+}
+
+void tst_QQuickItem::parentLoop()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQuickItem::setParentItem: Parent is already part of this items subtree.");
+ canvas->setSource(testFileUrl("parentLoop.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+
+ QQuickItem *item1 = root->findChild<QQuickItem*>("item1");
+ QVERIFY(item1);
+ QCOMPARE(item1->parentItem(), root);
+
+ QQuickItem *item2 = root->findChild<QQuickItem*>("item2");
+ QVERIFY(item2);
+ QCOMPARE(item2->parentItem(), item1);
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_QQuickItem)
+
+#include "tst_qquickitem.moc"
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml b/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml
index 70fc05e937..70fc05e937 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml
+++ b/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Effect.qml b/tests/auto/quick/qquickitemlayer/data/Effect.qml
index 630c8f90ed..630c8f90ed 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Effect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Effect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml b/tests/auto/quick/qquickitemlayer/data/Enabled.qml
index 0e7d4f56b8..0e7d4f56b8 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Enabled.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml b/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml
index 2f17d78efd..2f17d78efd 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml b/tests/auto/quick/qquickitemlayer/data/Mipmap.qml
index 8de41076e9..8de41076e9 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Mipmap.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml b/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml
index 94c43f2caf..94c43f2caf 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml b/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml
index a4c2ebff6b..a4c2ebff6b 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml
+++ b/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml b/tests/auto/quick/qquickitemlayer/data/Smooth.qml
index 3f9575bb0b..3f9575bb0b 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Smooth.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml
index 7cc7e8b21e..7cc7e8b21e 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml b/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml
index ccd515652a..ccd515652a 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml
+++ b/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml b/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml
index 174b669b6c..174b669b6c 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Visible.qml b/tests/auto/quick/qquickitemlayer/data/Visible.qml
index 8267f18250..8267f18250 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Visible.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Visible.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml b/tests/auto/quick/qquickitemlayer/data/ZOrder.qml
index 59ccb32224..59ccb32224 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml
+++ b/tests/auto/quick/qquickitemlayer/data/ZOrder.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml b/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml
index ebbd3b7e15..ebbd3b7e15 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml
+++ b/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml
diff --git a/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro
new file mode 100644
index 0000000000..a2d5f401ff
--- /dev/null
+++ b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro
@@ -0,0 +1,38 @@
+CONFIG += testcase
+TARGET = tst_qquickitemlayer
+SOURCES += tst_qquickitemlayer.cpp
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+include(../../shared/util.pri)
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private testlib
+
+OTHER_FILES += \
+ data/Smooth.qml \
+ data/Enabled.qml \
+ data/Mipmap.qml \
+ data/Effect.qml \
+ data/SourceRect.qml \
+ data/TextureProvider.qml \
+ data/Visible.qml \
+ data/ZOrder.qml \
+ data/ZOrderChange.qml \
+ data/ToggleLayerAndEffect.qml \
+ data/DisableLayer.qml \
+ data/SamplerNameChange.qml \
+ data/ItemEffect.qml \
+ data/RectangleEffect.qml
+
+
+
+
+
+
+
+
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
new file mode 100644
index 0000000000..44d0d6d09c
--- /dev/null
+++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
@@ -0,0 +1,436 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtGui/qopenglcontext.h>
+
+#include "../../shared/util.h"
+
+class tst_QQuickItemLayer: public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickItemLayer();
+
+ QImage runTest(const QString &url)
+ {
+ QQuickView view;
+ view.setSource(QUrl(url));
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ return view.grabFrameBuffer();
+ }
+
+private slots:
+ void layerEnabled();
+ void layerSmooth();
+ void layerMipmap();
+ void layerEffect();
+
+ void layerVisibility_data();
+ void layerVisibility();
+
+ void layerSourceRect();
+
+ void layerZOrder_data();
+ void layerZOrder();
+
+ void layerIsTextureProvider();
+
+ void changeZOrder_data();
+ void changeZOrder();
+
+ void toggleLayerAndEffect();
+ void disableLayer();
+ void changeSamplerName();
+ void itemEffect();
+ void rectangleEffect();
+
+private:
+ bool m_isMesaSoftwareRasterizer;
+ int m_mesaVersion;
+};
+
+tst_QQuickItemLayer::tst_QQuickItemLayer()
+ : m_mesaVersion(0)
+{
+ QWindow window;
+ QOpenGLContext context;
+ window.setSurfaceType(QWindow::OpenGLSurface);
+ window.create();
+ context.create();
+ context.makeCurrent(&window);
+ const char *vendor = (const char *)glGetString(GL_VENDOR);
+ const char *renderer = (const char *)glGetString(GL_RENDERER);
+ m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0
+ && strcmp(renderer, "Software Rasterizer") == 0;
+ if (m_isMesaSoftwareRasterizer) {
+ // Expects format: <OpenGL version> Mesa <Mesa version>[-devel] [...]
+ const char *version = (const char *)glGetString(GL_VERSION);
+ QList<QByteArray> list = QByteArray(version).split(' ');
+ if (list.size() >= 3) {
+ list = list.at(2).split('-').at(0).split('.');
+ int major = 0;
+ int minor = 0;
+ int patch = 0;
+ if (list.size() >= 1)
+ major = list.at(0).toInt();
+ if (list.size() >= 2)
+ minor = list.at(1).toInt();
+ if (list.size() >= 3)
+ patch = list.at(2).toInt();
+ m_mesaVersion = QT_VERSION_CHECK(major, minor, patch);
+ }
+ }
+}
+
+// The test draws a red and a blue box next to each other and tests that the
+// output is still red and blue on the left and right and a combination of
+// the two in the middle.
+
+void tst_QQuickItemLayer::layerSmooth()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("Smooth.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
+
+ uint pixel = fb.pixel(fb.width() / 2, 0);
+ QVERIFY(qRed(pixel) > 0);
+ QVERIFY(qBlue(pixel) > 0);
+}
+
+
+
+// The test draws a gradient at a small size into a layer and scales the
+// layer. If the layer is enabled there should be very visible bands in
+// the gradient.
+
+void tst_QQuickItemLayer::layerEnabled()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("Enabled.qml"));
+ // Verify the banding
+ QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1));
+ // Verify the gradient
+ QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1));
+}
+
+
+
+// The test draws a one pixel wide line and scales it down by more than a a factor 2
+// If mipmpping works, the pixels should be gray, not white or black
+
+void tst_QQuickItemLayer::layerMipmap()
+{
+ if (m_isMesaSoftwareRasterizer)
+ QSKIP("Mipmapping does not work with the Mesa Software Rasterizer.");
+ QImage fb = runTest(testFile("Mipmap.qml"));
+ QVERIFY(fb.pixel(0, 0) != 0xff000000);
+ QVERIFY(fb.pixel(0, 0) != 0xffffffff);
+}
+
+
+
+// The test implements an rgb swapping effect sourced from a blue rectangle. The
+// resulting pixel should be red
+
+void tst_QQuickItemLayer::layerEffect()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("Effect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
+}
+
+
+
+// The test draws a rectangle and verifies that there is padding on each side
+// as the source rect spans outside the item. The padding is verified using
+// a shader that pads transparent to blue. Everything else is red.
+void tst_QQuickItemLayer::layerSourceRect()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+
+ QImage fb = runTest(testFile("SourceRect.qml"));
+
+ // Check that the edges are converted to blue
+ QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(0, fb.height() - 1), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(fb.width() - 1, fb.height() - 1), qRgb(0, 0, 0xff));
+
+ // The center pixel should be red
+ QCOMPARE(fb.pixel(fb.width() / 2, fb.height() / 2), qRgb(0xff, 0, 0));
+}
+
+
+
+// Same as the effect test up above, but this time use the item
+// directly in a stand alone ShaderEffect
+void tst_QQuickItemLayer::layerIsTextureProvider()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("TextureProvider.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
+}
+
+
+void tst_QQuickItemLayer::layerVisibility_data()
+{
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("effect");
+ QTest::addColumn<qreal>("opacity");
+
+ QTest::newRow("!effect, !visible, a=1") << false << false << 1.;
+ QTest::newRow("!effect, visible, a=1") << false << true << 1.;
+ QTest::newRow("effect, !visible, a=1") << true << false << 1.;
+ QTest::newRow("effect, visible, a=1") << true << true << 1.;
+
+ QTest::newRow("!effect, !visible, a=.5") << false << false << .5;
+ QTest::newRow("!effect, visible, a=.5") << false << true << .5;
+ QTest::newRow("effect, !visible, a=.5") << true << false << .5;
+ QTest::newRow("effect, visible, a=.5") << true << true << .5;
+
+ QTest::newRow("!effect, !visible, a=0") << false << false << 0.;
+ QTest::newRow("!effect, visible, a=0") << false << true << 0.;
+ QTest::newRow("effect, !visible, a=0") << true << false << 0.;
+ QTest::newRow("effect, visible, a=0") << true << true << 0.;
+}
+
+void tst_QQuickItemLayer::layerVisibility()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+
+ QFETCH(bool, visible);
+ QFETCH(bool, effect);
+ QFETCH(qreal, opacity);
+
+ QQuickView view;
+ view.setSource(testFile("Visible.qml"));
+
+ QQuickItem *child = view.rootItem()->childItems().at(0);
+ child->setProperty("layerVisible", visible);
+ child->setProperty("layerEffect", effect);
+ child->setProperty("layerOpacity", opacity);
+
+ view.show();
+
+ QTest::qWaitForWindowShown(&view);
+
+ QImage fb = view.grabFrameBuffer();
+ uint pixel = fb.pixel(0, 0);
+
+ if (!visible || opacity == 0) {
+ QCOMPARE(pixel, qRgb(0xff, 0xff, 0xff));
+ } else if (effect) {
+ QCOMPARE(qRed(pixel), 0xff);
+ QVERIFY(qGreen(pixel) < 0xff);
+ QVERIFY(qBlue(pixel) < 0xff);
+ } else { // no effect
+ QCOMPARE(qBlue(pixel), 0xff);
+ QVERIFY(qGreen(pixel) < 0xff);
+ QVERIFY(qRed(pixel) < 0xff);
+ }
+}
+
+
+
+
+void tst_QQuickItemLayer::layerZOrder_data()
+{
+ QTest::addColumn<bool>("effect");
+
+ QTest::newRow("!effect") << false;
+ QTest::newRow("effect") << true;
+}
+
+void tst_QQuickItemLayer::layerZOrder()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+
+ QFETCH(bool, effect);
+
+ QQuickView view;
+ view.setSource(testFile("ZOrder.qml"));
+
+ QQuickItem *child = view.rootItem()->childItems().at(0);
+ child->setProperty("layerEffect", effect);
+
+ view.show();
+
+ QTest::qWaitForWindowShown(&view);
+
+ QImage fb = view.grabFrameBuffer();
+
+ QCOMPARE(fb.pixel(50, 50), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(150, 150), qRgb(0, 0xff, 00));
+
+}
+
+void tst_QQuickItemLayer::changeZOrder_data()
+{
+ QTest::addColumn<bool>("layered");
+ QTest::addColumn<bool>("effect");
+
+ QTest::newRow("layered, effect") << true << true;
+ QTest::newRow("layered, !effect") << true << false;
+ QTest::newRow("!layered") << false << false;
+}
+
+void tst_QQuickItemLayer::changeZOrder()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+
+ QFETCH(bool, layered);
+ QFETCH(bool, effect);
+
+ QQuickView view;
+ view.setSource(testFile("ZOrderChange.qml"));
+
+ QQuickItem *child = view.rootItem()->childItems().at(0);
+ child->setProperty("layerEnabled", layered);
+ child->setProperty("layerEffect", effect);
+ child->setProperty("layerZ", 1);
+
+ view.show();
+
+ QTest::qWaitForWindowShown(&view);
+
+ QImage fb = view.grabFrameBuffer();
+
+ QRgb topLeft = fb.pixel(50, 50);
+ QRgb topRight = fb.pixel(150, 50);
+ QRgb bottomLeft = fb.pixel(50, 150);
+ QRgb bottomRight = fb.pixel(150, 150);
+
+ QCOMPARE(bottomLeft, qRgb(0, 0, 0xff));
+
+ if (layered) {
+ QCOMPARE(topLeft, qRgb(0, 0xff, 0xff));
+ } else {
+ QCOMPARE(qGreen(topLeft), 0xff);
+ QVERIFY(qAbs(qRed(topLeft) - 0x3f) < 4);
+ QVERIFY(qAbs(qBlue(topLeft) - 0xbf) < 4);
+ }
+
+ if (layered && effect) {
+ QCOMPARE(qRed(topRight), 0xff);
+ QCOMPARE(qGreen(topRight), 0x00);
+ QVERIFY(qAbs(qBlue(topRight) - 0x7f) < 4);
+
+ QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4);
+ QCOMPARE(qBlue(bottomRight), 0xff);
+ QVERIFY(qAbs(qGreen(bottomRight) - 0x7f) < 4);
+ } else {
+ QCOMPARE(qRed(topRight), 0xff);
+ QCOMPARE(qBlue(topRight), 0x00);
+ QVERIFY(qAbs(qGreen(topRight) - 0x7f) < 4);
+
+ QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4);
+ QCOMPARE(qGreen(bottomRight), 0xff);
+ QVERIFY(qAbs(qBlue(bottomRight) - 0x7f) < 4);
+ }
+}
+
+void tst_QQuickItemLayer::toggleLayerAndEffect()
+{
+ // This test passes if it doesn't crash.
+ runTest(testFile("ToggleLayerAndEffect.qml"));
+}
+
+void tst_QQuickItemLayer::disableLayer()
+{
+ // This test passes if it doesn't crash.
+ runTest(testFile("DisableLayer.qml"));
+}
+
+void tst_QQuickItemLayer::changeSamplerName()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("SamplerNameChange.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
+}
+
+void tst_QQuickItemLayer::itemEffect()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("ItemEffect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(199, 199), qRgb(0, 0, 0xff));
+}
+
+void tst_QQuickItemLayer::rectangleEffect()
+{
+ QImage fb = runTest(testFile("RectangleEffect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(199, 199), qRgb(0, 0xff, 0));
+
+ QCOMPARE(fb.pixel(100, 0), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(199, 100), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(100, 199), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff));
+}
+
+
+QTEST_MAIN(tst_QQuickItemLayer)
+
+#include "tst_qquickitemlayer.moc"
diff --git a/tests/auto/qtquick2/qquicklistview/data/ComponentView.qml b/tests/auto/quick/qquicklistview/data/ComponentView.qml
index 3e87be8799..3e87be8799 100644
--- a/tests/auto/qtquick2/qquicklistview/data/ComponentView.qml
+++ b/tests/auto/quick/qquicklistview/data/ComponentView.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/Page.qml b/tests/auto/quick/qquicklistview/data/Page.qml
index abe4364315..abe4364315 100644
--- a/tests/auto/qtquick2/qquicklistview/data/Page.qml
+++ b/tests/auto/quick/qquicklistview/data/Page.qml
diff --git a/tests/auto/quick/qquicklistview/data/addTransitions.qml b/tests/auto/quick/qquicklistview/data/addTransitions.qml
new file mode 100644
index 0000000000..6a7c3234f6
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/addTransitions.qml
@@ -0,0 +1,134 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: list.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text { text: index }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionFrom)
+ model_targetItems_transitionFrom.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ ListView {
+ id: list
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "list"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ add: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
+ }
+
+ ScriptAction { script: list.targetTransitionsDone += 1 }
+ }
+ }
+
+ addDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
+ NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: list.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: list
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ // XXX will it pass without these if I just wait for polish?
+ // check all of these tests - if not, then mark this bit with the bug number!
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 100000 }
+ }
+}
+
diff --git a/tests/auto/qtquick2/qquicklistview/data/asyncloader.qml b/tests/auto/quick/qquicklistview/data/asyncloader.qml
index f038f0960c..f038f0960c 100644
--- a/tests/auto/qtquick2/qquicklistview/data/asyncloader.qml
+++ b/tests/auto/quick/qquicklistview/data/asyncloader.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/attachedSignals.qml b/tests/auto/quick/qquicklistview/data/attachedSignals.qml
index 2c3c0bbada..2c3c0bbada 100644
--- a/tests/auto/qtquick2/qquicklistview/data/attachedSignals.qml
+++ b/tests/auto/quick/qquicklistview/data/attachedSignals.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/creationContext.qml b/tests/auto/quick/qquicklistview/data/creationContext.qml
index 79a682788b..79a682788b 100644
--- a/tests/auto/qtquick2/qquicklistview/data/creationContext.qml
+++ b/tests/auto/quick/qquicklistview/data/creationContext.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml b/tests/auto/quick/qquicklistview/data/displacedTransitions.qml
index cc7892e930..cc7892e930 100644
--- a/tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/displacedTransitions.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/displaylist.qml b/tests/auto/quick/qquicklistview/data/displaylist.qml
index 4e8fd32f6a..4e8fd32f6a 100644
--- a/tests/auto/qtquick2/qquicklistview/data/displaylist.qml
+++ b/tests/auto/quick/qquicklistview/data/displaylist.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/fillModelOnComponentCompleted.qml b/tests/auto/quick/qquicklistview/data/fillModelOnComponentCompleted.qml
index 906e6adb6b..906e6adb6b 100644
--- a/tests/auto/qtquick2/qquicklistview/data/fillModelOnComponentCompleted.qml
+++ b/tests/auto/quick/qquicklistview/data/fillModelOnComponentCompleted.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/footer.qml b/tests/auto/quick/qquicklistview/data/footer.qml
index 2a5619999e..2a5619999e 100644
--- a/tests/auto/qtquick2/qquicklistview/data/footer.qml
+++ b/tests/auto/quick/qquicklistview/data/footer.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/header.qml b/tests/auto/quick/qquicklistview/data/header.qml
index bf70310630..bf70310630 100644
--- a/tests/auto/qtquick2/qquicklistview/data/header.qml
+++ b/tests/auto/quick/qquicklistview/data/header.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/headerfooter.qml b/tests/auto/quick/qquicklistview/data/headerfooter.qml
index 8e8463d645..8e8463d645 100644
--- a/tests/auto/qtquick2/qquicklistview/data/headerfooter.qml
+++ b/tests/auto/quick/qquicklistview/data/headerfooter.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/itemlist.qml b/tests/auto/quick/qquicklistview/data/itemlist.qml
index 5c7ecdd5e8..5c7ecdd5e8 100644
--- a/tests/auto/qtquick2/qquicklistview/data/itemlist.qml
+++ b/tests/auto/quick/qquicklistview/data/itemlist.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-enforcerange-nohighlight.qml b/tests/auto/quick/qquicklistview/data/listview-enforcerange-nohighlight.qml
index 1db1096499..1db1096499 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-enforcerange-nohighlight.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-enforcerange-nohighlight.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-enforcerange.qml b/tests/auto/quick/qquicklistview/data/listview-enforcerange.qml
index f1bf6c2b57..f1bf6c2b57 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-enforcerange.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-enforcerange.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-initCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
index c4f1860eda..c4f1860eda 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-initCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-noCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
index 079966d8e4..079966d8e4 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-noCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-sections-package.qml b/tests/auto/quick/qquicklistview/data/listview-sections-package.qml
index 8e5a4c4aa7..8e5a4c4aa7 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-sections-package.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-sections-package.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-sections.qml b/tests/auto/quick/qquicklistview/data/listview-sections.qml
index d5b8a4400d..d5b8a4400d 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-sections.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-sections.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-sections_delegate.qml b/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml
index 496d8d7784..496d8d7784 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-sections_delegate.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listviewtest-package.qml b/tests/auto/quick/qquicklistview/data/listviewtest-package.qml
index 54d4dabc86..54d4dabc86 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listviewtest-package.qml
+++ b/tests/auto/quick/qquicklistview/data/listviewtest-package.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listviewtest.qml b/tests/auto/quick/qquicklistview/data/listviewtest.qml
index 47b341c1fc..47b341c1fc 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listviewtest.qml
+++ b/tests/auto/quick/qquicklistview/data/listviewtest.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/manual-highlight.qml b/tests/auto/quick/qquicklistview/data/manual-highlight.qml
index aac4599f01..aac4599f01 100644
--- a/tests/auto/qtquick2/qquicklistview/data/manual-highlight.qml
+++ b/tests/auto/quick/qquicklistview/data/manual-highlight.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/margins.qml b/tests/auto/quick/qquicklistview/data/margins.qml
index 19bbef500f..19bbef500f 100644
--- a/tests/auto/qtquick2/qquicklistview/data/margins.qml
+++ b/tests/auto/quick/qquicklistview/data/margins.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/margins2.qml b/tests/auto/quick/qquicklistview/data/margins2.qml
index e11c803c4b..e11c803c4b 100644
--- a/tests/auto/qtquick2/qquicklistview/data/margins2.qml
+++ b/tests/auto/quick/qquicklistview/data/margins2.qml
diff --git a/tests/auto/quick/qquicklistview/data/moveTransitions.qml b/tests/auto/quick/qquicklistview/data/moveTransitions.qml
new file mode 100644
index 0000000000..2f907bdc8a
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/moveTransitions.qml
@@ -0,0 +1,141 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: list.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text { text: index }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionVia)
+ model_targetItems_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ ListView {
+ id: list
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "list"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ move: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: targetItems_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: targetItems_transitionVia.y; duration: root.duration }
+ }
+
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: list.targetTransitionsDone += 1 }
+ }
+ }
+
+ moveDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "x"; duration: root.duration
+ to: displacedItems_transitionVia.x
+ }
+ NumberAnimation {
+ properties: "y"; duration: root.duration
+ to: displacedItems_transitionVia.y
+ }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: list.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: list
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
index 8264b42b64..8264b42b64 100644
--- a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/populateTransitions.qml b/tests/auto/quick/qquicklistview/data/populateTransitions.qml
index 0994e0943d..0994e0943d 100644
--- a/tests/auto/qtquick2/qquicklistview/data/populateTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/populateTransitions.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/propertychangestest.qml b/tests/auto/quick/qquicklistview/data/propertychangestest.qml
index 146f3f13b0..146f3f13b0 100644
--- a/tests/auto/qtquick2/qquicklistview/data/propertychangestest.qml
+++ b/tests/auto/quick/qquicklistview/data/propertychangestest.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml b/tests/auto/quick/qquicklistview/data/qtbug-21742.qml
index 774f9041fb..774f9041fb 100644
--- a/tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml
+++ b/tests/auto/quick/qquicklistview/data/qtbug-21742.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml b/tests/auto/quick/qquicklistview/data/qtbug14821.qml
index 0a5e0acbb4..0a5e0acbb4 100644
--- a/tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml
+++ b/tests/auto/quick/qquicklistview/data/qtbug14821.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml b/tests/auto/quick/qquicklistview/data/qtbug16037.qml
index 21faeb3f32..21faeb3f32 100644
--- a/tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml
+++ b/tests/auto/quick/qquicklistview/data/qtbug16037.qml
diff --git a/tests/auto/quick/qquicklistview/data/removeTransitions.qml b/tests/auto/quick/qquicklistview/data/removeTransitions.qml
new file mode 100644
index 0000000000..a85b217138
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/removeTransitions.qml
@@ -0,0 +1,144 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: list.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text { text: index }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionTo) {
+ model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item
+ }
+ if (Qt.point(x, y) == displacedItems_transitionVia) {
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+ }
+
+ ListView {
+ id: list
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "list"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ remove: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: targetItems_transitionTo.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: targetItems_transitionTo.y; duration: root.duration }
+ }
+ ScriptAction { script: list.targetTransitionsDone += 1 }
+
+ // delay deleting this item so that it stays valid for the tests
+ // (this doesn't delay the test itself)
+ PauseAnimation { duration: 10000 }
+ }
+ }
+
+ removeDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "x"; duration: root.duration
+ to: displacedItems_transitionVia.x
+ }
+ NumberAnimation {
+ properties: "y"; duration: root.duration
+ to: displacedItems_transitionVia.y
+ }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: list.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: list
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquicklistview/data/resizeview.qml b/tests/auto/quick/qquicklistview/data/resizeview.qml
index 8b13adba40..8b13adba40 100644
--- a/tests/auto/qtquick2/qquicklistview/data/resizeview.qml
+++ b/tests/auto/quick/qquicklistview/data/resizeview.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/rightToLeft.qml b/tests/auto/quick/qquicklistview/data/rightToLeft.qml
index 6d77de26f4..6d77de26f4 100644
--- a/tests/auto/qtquick2/qquicklistview/data/rightToLeft.qml
+++ b/tests/auto/quick/qquicklistview/data/rightToLeft.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
index f4679b5af0..f4679b5af0 100644
--- a/tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml
+++ b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/sizelessthan1.qml b/tests/auto/quick/qquicklistview/data/sizelessthan1.qml
index aa9dc20ae9..aa9dc20ae9 100644
--- a/tests/auto/qtquick2/qquicklistview/data/sizelessthan1.qml
+++ b/tests/auto/quick/qquicklistview/data/sizelessthan1.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/snapOneItem.qml b/tests/auto/quick/qquicklistview/data/snapOneItem.qml
index d67d8040ca..d67d8040ca 100644
--- a/tests/auto/qtquick2/qquicklistview/data/snapOneItem.qml
+++ b/tests/auto/quick/qquicklistview/data/snapOneItem.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/snapToItem.qml b/tests/auto/quick/qquicklistview/data/snapToItem.qml
index 6f201072f0..6f201072f0 100644
--- a/tests/auto/qtquick2/qquicklistview/data/snapToItem.qml
+++ b/tests/auto/quick/qquicklistview/data/snapToItem.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/strictlyenforcerange.qml b/tests/auto/quick/qquicklistview/data/strictlyenforcerange.qml
index 7960ac4abb..7960ac4abb 100644
--- a/tests/auto/qtquick2/qquicklistview/data/strictlyenforcerange.qml
+++ b/tests/auto/quick/qquicklistview/data/strictlyenforcerange.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/unrequestedItems.qml b/tests/auto/quick/qquicklistview/data/unrequestedItems.qml
index 682f3833d1..682f3833d1 100644
--- a/tests/auto/qtquick2/qquicklistview/data/unrequestedItems.qml
+++ b/tests/auto/quick/qquicklistview/data/unrequestedItems.qml
diff --git a/tests/auto/qtquick2/qquicklistview/incrementalmodel.cpp b/tests/auto/quick/qquicklistview/incrementalmodel.cpp
index bbdcabf253..bbdcabf253 100644
--- a/tests/auto/qtquick2/qquicklistview/incrementalmodel.cpp
+++ b/tests/auto/quick/qquicklistview/incrementalmodel.cpp
diff --git a/tests/auto/qtquick2/qquicklistview/incrementalmodel.h b/tests/auto/quick/qquicklistview/incrementalmodel.h
index bf524d16e6..bf524d16e6 100644
--- a/tests/auto/qtquick2/qquicklistview/incrementalmodel.h
+++ b/tests/auto/quick/qquicklistview/incrementalmodel.h
diff --git a/tests/auto/quick/qquicklistview/qquicklistview.pro b/tests/auto/quick/qquicklistview/qquicklistview.pro
new file mode 100644
index 0000000000..4cac8e7665
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/qquicklistview.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qquicklistview
+macx:CONFIG -= app_bundle
+
+HEADERS += incrementalmodel.h
+SOURCES += tst_qquicklistview.cpp \
+ incrementalmodel.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private qml-private quick-private widgets widgets-private v8-private opengl-private testlib
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
new file mode 100644
index 0000000000..9195aab632
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -0,0 +1,5997 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QStringListModel>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquicklistview_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickvisualitemmodel_p.h>
+#include <QtQml/private/qquicklistmodel_p.h>
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+#include "incrementalmodel.h"
+#include <math.h>
+
+Q_DECLARE_METATYPE(Qt::LayoutDirection)
+Q_DECLARE_METATYPE(QQuickListView::Orientation)
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+class tst_QQuickListView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickListView();
+
+private slots:
+ // Test both QListModelInterface and QAbstractItemModel model types
+ void qListModelInterface_items();
+ void qListModelInterface_package_items();
+ void qAbstractItemModel_items();
+
+ void qListModelInterface_changed();
+ void qListModelInterface_package_changed();
+ void qAbstractItemModel_changed();
+
+ void qListModelInterface_inserted();
+ void qListModelInterface_inserted_more();
+ void qListModelInterface_inserted_more_data();
+ void qListModelInterface_package_inserted();
+ void qAbstractItemModel_inserted();
+ void qAbstractItemModel_inserted_more();
+ void qAbstractItemModel_inserted_more_data();
+
+ void qListModelInterface_removed();
+ void qListModelInterface_removed_more();
+ void qListModelInterface_removed_more_data();
+ void qListModelInterface_package_removed();
+ void qAbstractItemModel_removed();
+ void qAbstractItemModel_removed_more();
+ void qAbstractItemModel_removed_more_data();
+
+ void qListModelInterface_moved();
+ void qListModelInterface_moved_data();
+ void qListModelInterface_package_moved();
+ void qListModelInterface_package_moved_data();
+ void qAbstractItemModel_moved();
+ void qAbstractItemModel_moved_data();
+
+ void multipleChanges();
+ void multipleChanges_data();
+
+ void qListModelInterface_clear();
+ void qListModelInterface_package_clear();
+ void qAbstractItemModel_clear();
+
+ void insertBeforeVisible();
+ void insertBeforeVisible_data();
+ void swapWithFirstItem();
+ void itemList();
+ void currentIndex_delayedItemCreation();
+ void currentIndex_delayedItemCreation_data();
+ void currentIndex();
+ void noCurrentIndex();
+ void enforceRange();
+ void enforceRange_withoutHighlight();
+ void spacing();
+ void qListModelInterface_sections();
+ void qListModelInterface_package_sections();
+ void qAbstractItemModel_sections();
+ void sectionsPositioning();
+ void sectionsDelegate();
+ void sectionPropertyChange();
+ void cacheBuffer();
+ void positionViewAtIndex();
+ void resetModel();
+ void propertyChanges();
+ void componentChanges();
+ void modelChanges();
+ void manualHighlight();
+ void header();
+ void header_data();
+ void header_delayItemCreation();
+ void footer();
+ void footer_data();
+ void headerFooter();
+ void resizeView();
+ void resizeViewAndRepaint();
+ void sizeLessThan1();
+ void QTBUG_14821();
+ void resizeDelegate();
+ void resizeFirstDelegate();
+ void QTBUG_16037();
+ void indexAt_itemAt_data();
+ void indexAt_itemAt();
+ void incrementalModel();
+ void onAdd();
+ void onAdd_data();
+ void onRemove();
+ void onRemove_data();
+ void rightToLeft();
+ void test_mirroring();
+ void margins();
+ void marginsResize();
+ void marginsResize_data();
+ void creationContext();
+ void snapToItem_data();
+ void snapToItem();
+ void snapOneItem_data();
+ void snapOneItem();
+
+ void QTBUG_9791();
+ void QTBUG_11105();
+ void QTBUG_21742();
+
+ void asynchronous();
+ void unrequestedVisibility();
+
+ void populateTransitions();
+ void populateTransitions_data();
+ void addTransitions();
+ void addTransitions_data();
+ void moveTransitions();
+ void moveTransitions_data();
+ void removeTransitions();
+ void removeTransitions_data();
+ void displacedTransitions();
+ void displacedTransitions_data();
+ void multipleTransitions();
+ void multipleTransitions_data();
+
+private:
+ template <class T> void items(const QUrl &source, bool forceLayout);
+ template <class T> void changed(const QUrl &source, bool forceLayout);
+ template <class T> void inserted(const QUrl &source);
+ template <class T> void inserted_more();
+ template <class T> void removed(const QUrl &source, bool animated);
+ template <class T> void removed_more(const QUrl &source);
+ template <class T> void moved(const QUrl &source);
+ template <class T> void clear(const QUrl &source);
+ template <class T> void sections(const QUrl &source);
+
+ QList<int> toIntList(const QVariantList &list);
+ void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
+ void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
+ void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
+
+ void inserted_more_data();
+ void removed_more_data();
+ void moved_data();
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError)
+ Q_PROPERTY(bool animate READ animate NOTIFY changedAnim)
+ Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer)
+
+public:
+ TestObject(QObject *parent = 0)
+ : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false)
+ , mCacheBuffer(0) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; emit changedError(); }
+
+ bool animate() const { return mAnimate; }
+ void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); }
+
+ bool invalidHighlight() const { return mInvalidHighlight; }
+ void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); }
+
+ int cacheBuffer() const { return mCacheBuffer; }
+ void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); }
+
+signals:
+ void changedError();
+ void changedAnim();
+ void changedHl();
+ void changedCacheBuffer();
+
+public:
+ bool mError;
+ bool mAnimate;
+ bool mInvalidHighlight;
+ int mCacheBuffer;
+};
+
+tst_QQuickListView::tst_QQuickListView()
+{
+}
+
+template <class T>
+void tst_QQuickListView::items(const QUrl &source, bool forceLayout)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QTRY_VERIFY(testObject->error() == false);
+
+ QTRY_VERIFY(listview->highlightItem() != 0);
+ QTRY_COMPARE(listview->count(), model.count());
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ // current item should be first item
+ QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
+
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ // switch to other delegate
+ testObject->setAnimate(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
+
+ // set invalid highlight
+ testObject->setInvalidHighlight(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
+ QTRY_VERIFY(listview->highlightItem() == 0);
+
+ // back to normal highlight
+ testObject->setInvalidHighlight(false);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
+ QTRY_VERIFY(listview->highlightItem() != 0);
+
+ // set an empty model and confirm that items are destroyed
+ T model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ // Force a layout, necessary if ListView is completed before VisualDataModel.
+ if (forceLayout)
+ QCOMPARE(listview->property("count").toInt(), 0);
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QTRY_VERIFY(itemCount == 0);
+
+ QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
+ QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0);
+
+ delete canvas;
+ delete testObject;
+}
+
+
+template <class T>
+void tst_QQuickListView::changed(const QUrl &source, bool forceLayout)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ qApp->processEvents();
+
+ QQuickFlickable *listview = findItem<QQuickFlickable>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Force a layout, necessary if ListView is completed before VisualDataModel.
+ if (forceLayout)
+ QCOMPARE(listview->property("count").toInt(), model.count());
+
+ model.modifyItem(1, "Will", "9876");
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ delete canvas;
+ delete testObject;
+}
+
+template <class T>
+void tst_QQuickListView::inserted(const QUrl &source)
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->y(), i*20.0);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ QTRY_COMPARE(listview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->y(), i*20.0);
+ }
+
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+
+ listview->setContentY(80);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+
+ QTRY_VERIFY(listview->contentY() == 80);
+
+ // Confirm items positioned correctly
+ for (int i = 5; i < 5+15; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.0 - 20.0);
+ }
+
+// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
+
+ // QTBUG-19675
+ model.clear();
+ model.insertItem(0, "Hello", "1234");
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->y(), 0.);
+ QTRY_VERIFY(listview->contentY() == 0);
+
+ delete canvas;
+ delete testObject;
+}
+
+template <class T>
+void tst_QQuickListView::inserted_more()
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, insertIndex);
+ QFETCH(int, insertCount);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QList<QPair<QString, QString> > newData;
+ for (int i=0; i<insertCount; i++)
+ newData << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.insertItems(insertIndex, newData);
+ QTRY_COMPARE(listview->property("count").toInt(), model.count());
+
+ // check visibleItems.first() is in correct position
+ QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item0);
+ QCOMPARE(item0->y(), itemsOffsetAfterMove);
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QQuickText *name;
+ QQuickText *number;
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::inserted_more_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("insertCount");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ QTest::newRow("add 1, before visible items")
+ << 80.0 // show 4-19
+ << 3 << 1
+ << -20.0; // insert above first visible i.e. 0 is at -20, first visible should not move
+
+ QTest::newRow("add multiple, before visible")
+ << 80.0 // show 4-19
+ << 3 << 3
+ << -20.0 * 3; // again first visible should not move
+
+ QTest::newRow("add 1, at start of visible, content at start")
+ << 0.0
+ << 0 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, start of visible, content at start")
+ << 0.0
+ << 0 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, at start of visible, content not at start")
+ << 80.0 // show 4-19
+ << 4 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at start of visible, content not at start")
+ << 80.0 // show 4-19
+ << 4 << 3
+ << 0.0;
+
+
+ QTest::newRow("add 1, at end of visible, content at start")
+ << 0.0
+ << 15 << 1
+ << 0.0;
+
+ QTest::newRow("add 1, at end of visible, content at start")
+ << 0.0
+ << 15 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, at end of visible, content not at start")
+ << 80.0 // show 4-19
+ << 19 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at end of visible, content not at start")
+ << 80.0 // show 4-19
+ << 19 << 3
+ << 0.0;
+
+
+ QTest::newRow("add 1, after visible, content at start")
+ << 0.0
+ << 16 << 1
+ << 0.0;
+
+ QTest::newRow("add 1, after visible, content at start")
+ << 0.0
+ << 16 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, after visible, content not at start")
+ << 80.0 // show 4-19
+ << 20 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, after visible, content not at start")
+ << 80.0 // show 4-19
+ << 20 << 3
+ << 0.0;
+}
+
+void tst_QQuickListView::insertBeforeVisible()
+{
+ QFETCH(int, insertIndex);
+ QFETCH(int, insertCount);
+ QFETCH(int, cacheBuffer);
+
+ QQuickText *name;
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ listview->setCacheBuffer(cacheBuffer);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // trigger a refill (not just setting contentY) so that the visibleItems grid is updated
+ int firstVisibleIndex = 20; // move to an index where the top item is not visible
+ listview->setContentY(firstVisibleIndex * 20.0);
+ listview->setCurrentIndex(firstVisibleIndex);
+
+ qApp->processEvents();
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex);
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
+ QVERIFY(item);
+ QCOMPARE(item->y(), listview->contentY());
+
+ QList<QPair<QString, QString> > newData;
+ for (int i=0; i<insertCount; i++)
+ newData << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.insertItems(insertIndex, newData);
+ QTRY_COMPARE(listview->property("count").toInt(), model.count());
+
+ // now, moving to the top of the view should position the inserted items correctly
+ int itemsOffsetAfterMove = -(insertCount * 20);
+ listview->setCurrentIndex(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::insertBeforeVisible_data()
+{
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("insertCount");
+ QTest::addColumn<int>("cacheBuffer");
+
+ QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0;
+ QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100;
+ QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500;
+
+ QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0;
+ QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100;
+ QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500;
+
+ QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 3 << 0;
+ QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 3 << 100;
+ QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 3 << 500;
+
+ QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 3 << 0;
+ QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 3 << 100;
+ QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 3 << 500;
+}
+
+template <class T>
+void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 50; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ model.removeItem(1);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),i*20.0);
+ }
+
+ // Remove items not visible
+ model.removeItem(18);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),i*20.0);
+ }
+
+ // Remove items before visible
+ listview->setContentY(80);
+ listview->setCurrentIndex(10);
+
+ model.removeItem(1); // post: top item will be at 20
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ // Confirm items positioned correctly
+ for (int i = 2; i < 18; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),20+i*20.0);
+ }
+
+ // Remove current index
+ QTRY_VERIFY(listview->currentIndex() == 9);
+ QQuickItem *oldCurrent = listview->currentItem();
+ model.removeItem(9);
+
+ QTRY_COMPARE(listview->currentIndex(), 9);
+ QTRY_VERIFY(listview->currentItem() != oldCurrent);
+
+ listview->setContentY(20); // That's the top now
+ // let transitions settle.
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),20+i*20.0);
+ }
+
+ // remove current item beyond visible items.
+ listview->setCurrentIndex(20);
+ listview->setContentY(40);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ model.removeItem(20);
+ QTRY_COMPARE(listview->currentIndex(), 20);
+ QTRY_VERIFY(listview->currentItem() != 0);
+
+ // remove item before current, but visible
+ listview->setCurrentIndex(8);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ oldCurrent = listview->currentItem();
+ model.removeItem(6);
+
+ QTRY_COMPARE(listview->currentIndex(), 7);
+ QTRY_VERIFY(listview->currentItem() == oldCurrent);
+
+ listview->setContentY(80);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTest::qWait(300);
+
+ // remove all visible items
+ model.removeItems(1, 18);
+ QTRY_COMPARE(listview->count() , model.count());
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i+1);
+ if (!item) qWarning() << "Item" << i+1 << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),80+i*20.0);
+ }
+
+ model.removeItems(1, 17);
+ QTRY_COMPARE(listview->count() , model.count());
+
+ model.removeItems(2, 1);
+ QTRY_COMPARE(listview->count() , model.count());
+
+ model.addItem("New", "1");
+ QTRY_COMPARE(listview->count() , model.count());
+
+ QTRY_VERIFY(name = findItem<QQuickText>(contentItem, "textName", model.count()-1));
+ QCOMPARE(name->text(), QString("New"));
+
+ // Add some more items so that we don't run out
+ model.clear();
+ for (int i = 0; i < 50; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ // QTBUG-QTBUG-20575
+ listview->setCurrentIndex(0);
+ listview->setContentY(30);
+ model.removeItem(0);
+ QTRY_VERIFY(name = findItem<QQuickText>(contentItem, "textName", 0));
+
+ // QTBUG-19198 move to end and remove all visible items one at a time.
+ listview->positionViewAtEnd();
+ for (int i = 0; i < 18; ++i)
+ model.removeItems(model.count() - 1, 1);
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() > 16);
+
+ delete canvas;
+ delete testObject;
+}
+
+template <class T>
+void tst_QQuickListView::removed_more(const QUrl &source)
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, removeIndex);
+ QFETCH(int, removeCount);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // wait for refill (after refill, items above the firstVisibleIndex-1 should not be rendered)
+ int firstVisibleIndex = contentY / 20;
+ if (firstVisibleIndex - 2 >= 0)
+ QTRY_VERIFY(!findItem<QQuickText>(contentItem, "textName", firstVisibleIndex - 2));
+
+ model.removeItems(removeIndex, removeCount);
+ QTRY_COMPARE(listview->property("count").toInt(), model.count());
+
+ // check visibleItems.first() is in correct position
+ QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item0);
+ QCOMPARE(item0->y(), itemsOffsetAfterMove);
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::removed_more_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("removeIndex");
+ QTest::addColumn<int>("removeCount");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ QTest::newRow("remove 1, before visible items")
+ << 80.0 // show 4-19
+ << 3 << 1
+ << 20.0; // visible items slide down by 1 item so that first visible does not move
+
+ QTest::newRow("remove multiple, all before visible items")
+ << 80.0
+ << 1 << 3
+ << 20.0 * 3;
+
+ QTest::newRow("remove multiple, all before visible items, remove item 0")
+ << 80.0
+ << 0 << 4
+ << 20.0 * 4;
+
+ // remove 1,2,3 before the visible pos, 0 moves down to just before the visible pos,
+ // items 4,5 are removed from view, item 6 slides up to original pos of item 4 (80px)
+ QTest::newRow("remove multiple, mix of items from before and within visible items")
+ << 80.0
+ << 1 << 5
+ << 20.0 * 3; // adjust for the 3 items removed before the visible
+
+ QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0")
+ << 80.0
+ << 0 << 6
+ << 20.0 * 4; // adjust for the 3 items removed before the visible
+
+
+ QTest::newRow("remove 1, from start of visible, content at start")
+ << 0.0
+ << 0 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, from start of visible, content at start")
+ << 0.0
+ << 0 << 3
+ << 0.0;
+
+ QTest::newRow("remove 1, from start of visible, content not at start")
+ << 80.0 // show 4-19
+ << 4 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, from start of visible, content not at start")
+ << 80.0 // show 4-19
+ << 4 << 3
+ << 0.0;
+
+
+ QTest::newRow("remove 1, from middle of visible, content at start")
+ << 0.0
+ << 10 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, from middle of visible, content at start")
+ << 0.0
+ << 10 << 5
+ << 0.0;
+
+ QTest::newRow("remove 1, from middle of visible, content not at start")
+ << 80.0 // show 4-19
+ << 10 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, from middle of visible, content not at start")
+ << 80.0 // show 4-19
+ << 10 << 5
+ << 0.0;
+
+
+ QTest::newRow("remove 1, after visible, content at start")
+ << 0.0
+ << 16 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, after visible, content at start")
+ << 0.0
+ << 16 << 5
+ << 0.0;
+
+ QTest::newRow("remove 1, after visible, content not at middle")
+ << 80.0 // show 4-19
+ << 16+4 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, after visible, content not at start")
+ << 80.0 // show 4-19
+ << 16+4 << 5
+ << 0.0;
+
+ QTest::newRow("remove multiple, mix of items from within and after visible items")
+ << 80.0
+ << 18 << 5
+ << 0.0;
+}
+
+template <class T>
+void tst_QQuickListView::clear(const QUrl &source)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ model.clear();
+
+ QTRY_VERIFY(listview->count() == 0);
+ QTRY_VERIFY(listview->currentItem() == 0);
+ QTRY_VERIFY(listview->contentY() == 0);
+ QVERIFY(listview->currentIndex() == -1);
+
+ // confirm sanity when adding an item to cleared list
+ model.addItem("New", "1");
+ QTRY_VERIFY(listview->count() == 1);
+ QVERIFY(listview->currentItem() != 0);
+ QVERIFY(listview->currentIndex() == 0);
+
+ delete canvas;
+ delete testObject;
+}
+
+template <class T>
+void tst_QQuickListView::moved(const QUrl &source)
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *currentItem = listview->currentItem();
+ QTRY_VERIFY(currentItem != 0);
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ model.moveItems(from, to, count);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ if (i >= firstVisibleIndex + 16) // index has moved out of view
+ continue;
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+
+ // current index should have been updated
+ if (item == currentItem)
+ QTRY_COMPARE(listview->currentIndex(), i);
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::moved_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ // model starts with 30 items, each 20px high, in area 320px high
+ // 16 items should be visible at a time
+ // itemsOffsetAfterMove should be > 0 whenever items above the visible pos have moved
+
+ QTest::newRow("move 1 forwards, within visible items")
+ << 0.0
+ << 1 << 4 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from non-visible -> visible")
+ << 80.0 // show 4-19
+ << 1 << 18 << 1
+ << 20.0; // removed 1 item above the first visible, so item 0 should drop down by 1 to minimize movement
+
+ QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)")
+ << 80.0 // show 4-19
+ << 0 << 4 << 1
+ << 20.0; // first item has moved to below item4, everything drops down by size of 1 item
+
+ QTest::newRow("move 1 forwards, from visible -> non-visible")
+ << 0.0
+ << 1 << 16 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)")
+ << 0.0
+ << 0 << 16 << 1
+ << 0.0;
+
+
+ QTest::newRow("move 1 backwards, within visible items")
+ << 0.0
+ << 4 << 1 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, within visible items (to first index)")
+ << 0.0
+ << 4 << 0 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from non-visible -> visible")
+ << 0.0
+ << 20 << 4 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)")
+ << 0.0
+ << 29 << 15 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from visible -> non-visible")
+ << 80.0 // show 4-19
+ << 16 << 1 << 1
+ << -20.0; // to minimize movement, item 0 moves to -20, and other items do not move
+
+ QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)")
+ << 80.0 // show 4-19
+ << 16 << 0 << 1
+ << -20.0; // to minimize movement, item 16 (now at 0) moves to -20, and other items do not move
+
+
+ QTest::newRow("move multiple forwards, within visible items")
+ << 0.0
+ << 0 << 5 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, before visible items")
+ << 140.0 // show 7-22
+ << 4 << 5 << 3 // 4,5,6 move to below 7
+ << 20.0 * 3; // 4,5,6 moved down
+
+ QTest::newRow("move multiple forwards, from non-visible -> visible")
+ << 80.0 // show 4-19
+ << 1 << 5 << 3
+ << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
+
+ QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)")
+ << 80.0 // show 4-19
+ << 0 << 5 << 3
+ << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
+
+ QTest::newRow("move multiple forwards, mix of non-visible/visible")
+ << 40.0
+ << 1 << 16 << 2
+ << 20.0; // item 1,2 are removed, item 3 is now first visible
+
+ QTest::newRow("move multiple forwards, to bottom of view")
+ << 0.0
+ << 5 << 13 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, first->last")
+ << 0.0
+ << 0 << 13 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
+ << 80.0
+ << 5+4 << 13+4 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, from visible -> non-visible")
+ << 0.0
+ << 1 << 16 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)")
+ << 0.0
+ << 0 << 16 << 3
+ << 0.0;
+
+
+ QTest::newRow("move multiple backwards, within visible items")
+ << 0.0
+ << 4 << 1 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, within visible items (move first item)")
+ << 0.0
+ << 10 << 0 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from non-visible -> visible")
+ << 0.0
+ << 20 << 4 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)")
+ << 0.0
+ << 27 << 10 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from visible -> non-visible")
+ << 80.0 // show 4-19
+ << 16 << 1 << 3
+ << -20.0 * 3; // to minimize movement, 0 moves by -60, and other items do not move
+
+ QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)")
+ << 80.0 // show 4-19
+ << 16 << 0 << 3
+ << -20.0 * 3; // to minimize movement, 16,17,18 move to above item 0, and other items do not move
+}
+
+void tst_QQuickListView::multipleChanges()
+{
+ QFETCH(int, startCount);
+ QFETCH(QList<ListChange>, changes);
+ QFETCH(int, newCount);
+ QFETCH(int, newCurrentIndex);
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < startCount; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i=0; i<changes.count(); i++) {
+ switch (changes[i].type) {
+ case ListChange::Inserted:
+ {
+ QList<QPair<QString, QString> > items;
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ items << qMakePair(QString("new item %1").arg(j), QString::number(j));
+ model.insertItems(changes[i].index, items);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ }
+ case ListChange::Removed:
+ model.removeItems(changes[i].index, changes[i].count);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ case ListChange::Moved:
+ model.moveItems(changes[i].index, changes[i].to, changes[i].count);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ case ListChange::SetCurrent:
+ listview->setCurrentIndex(changes[i].index);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ case ListChange::SetContentY:
+ listview->setContentY(changes[i].pos);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ }
+ }
+
+ QTRY_COMPARE(listview->count(), newCount);
+ QCOMPARE(listview->count(), model.count());
+ QTRY_COMPARE(listview->currentIndex(), newCurrentIndex);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickListView::multipleChanges_data()
+{
+ QTest::addColumn<int>("startCount");
+ QTest::addColumn<QList<ListChange> >("changes");
+ QTest::addColumn<int>("newCount");
+ QTest::addColumn<int>("newCurrentIndex");
+
+ QList<ListChange> changes;
+
+ for (int i=1; i<30; i++)
+ changes << ListChange::remove(0);
+ QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0;
+
+ changes << ListChange::remove(0);
+ QTest::newRow("remove all") << 30 << changes << 0 << -1;
+
+ changes.clear();
+ changes << ListChange::setCurrent(29);
+ for (int i=29; i>0; i--)
+ changes << ListChange::remove(i);
+ QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0;
+
+ QTest::newRow("remove then insert at 0") << 10 << (QList<ListChange>()
+ << ListChange::remove(0, 1)
+ << ListChange::insert(0, 1)
+ ) << 10 << 1;
+
+ QTest::newRow("remove then insert at non-zero index") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::remove(2, 1)
+ << ListChange::insert(2, 1)
+ ) << 10 << 3;
+
+ QTest::newRow("remove current then insert below it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::remove(1, 3)
+ << ListChange::insert(2, 2)
+ ) << 9 << 1;
+
+ QTest::newRow("remove current index then move it down") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::remove(1, 3)
+ << ListChange::move(1, 5, 1)
+ ) << 7 << 5;
+
+ QTest::newRow("remove current index then move it up") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::remove(4, 3)
+ << ListChange::move(4, 1, 1)
+ ) << 7 << 1;
+
+
+ QTest::newRow("insert multiple times") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 2)
+ << ListChange::insert(0, 4)
+ << ListChange::insert(0, 6)
+ ) << 12 << 10;
+
+ QTest::newRow("insert multiple times with current index changes") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 2)
+ << ListChange::insert(0, 4)
+ << ListChange::insert(0, 6)
+ << ListChange::setCurrent(3)
+ << ListChange::insert(3, 2)
+ ) << 14 << 5;
+
+ QTest::newRow("insert and remove all") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 30)
+ << ListChange::remove(0, 30)
+ ) << 0 << -1;
+
+ QTest::newRow("insert and remove current") << 30 << (QList<ListChange>()
+ << ListChange::insert(1)
+ << ListChange::setCurrent(1)
+ << ListChange::remove(1)
+ ) << 30 << 1;
+
+ QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 10)
+ << ListChange::remove(5, 10)
+ ) << 10 << 5;
+
+ QTest::newRow("insert multiple, then move new items to end") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 3)
+ << ListChange::move(0, 10, 3)
+ ) << 13 << 0;
+
+ QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 3)
+ << ListChange::move(0, 8, 5)
+ ) << 13 << 11;
+
+ QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(9)
+ << ListChange::insert(10, 3)
+ << ListChange::move(8, 0, 5)
+ ) << 13 << 1;
+
+
+ QTest::newRow("move back and forth to same index") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::move(1, 2, 2)
+ << ListChange::move(2, 1, 2)
+ ) << 10 << 1;
+
+ QTest::newRow("move forwards then back") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::move(1, 2, 3)
+ << ListChange::move(3, 0, 5)
+ ) << 10 << 0;
+
+ QTest::newRow("move current, then remove it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 0, 1)
+ << ListChange::remove(0)
+ ) << 9 << 0;
+
+ QTest::newRow("move current, then insert before it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 0, 1)
+ << ListChange::insert(0)
+ ) << 11 << 1;
+
+ QTest::newRow("move multiple, then remove them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::move(5, 1, 3)
+ << ListChange::remove(1, 3)
+ ) << 7 << 1;
+
+ QTest::newRow("move multiple, then insert before them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 1, 3)
+ << ListChange::insert(1, 5)
+ ) << 15 << 6;
+
+ QTest::newRow("move multiple, then insert after them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(3)
+ << ListChange::move(0, 1, 2)
+ << ListChange::insert(3, 5)
+ ) << 15 << 8;
+
+
+ QTest::newRow("clear current") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 5)
+ << ListChange::setCurrent(-1)
+ << ListChange::remove(0, 5)
+ << ListChange::insert(0, 5)
+ ) << 5 << -1;
+}
+
+void tst_QQuickListView::swapWithFirstItem()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // ensure content position is stable
+ listview->setContentY(0);
+ model.moveItem(1, 0);
+ QTRY_VERIFY(listview->contentY() == 0);
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickListView::enforceRange()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("listview-enforcerange.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0);
+ QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
+ QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // view should be positioned at the top of the range.
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(listview->contentY(), -100.0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ // Check currentIndex is updated when contentItem moves
+ listview->setContentY(20);
+
+ QTRY_COMPARE(listview->currentIndex(), 6);
+
+ // change model
+ QmlListModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+ QCOMPARE(listview->count(), 5);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::enforceRange_withoutHighlight()
+{
+ // QTBUG-20287
+ // If no highlight is set but StrictlyEnforceRange is used, the content should still move
+ // to the correct position (i.e. to the next/previous item, not next/previous section)
+ // when moving up/down via incrementCurrentIndex() and decrementCurrentIndex()
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ model.addItem("Item 0", "a");
+ model.addItem("Item 1", "b");
+ model.addItem("Item 2", "b");
+ model.addItem("Item 3", "c");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("listview-enforcerange-nohighlight.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ qreal expectedPos = -100.0;
+
+ expectedPos += 10.0; // scroll past 1st section's delegate (10px height)
+ QTRY_COMPARE(listview->contentY(), expectedPos);
+
+ expectedPos += 20 + 10; // scroll past 1st section and section delegate of 2nd section
+ QTest::keyClick(canvas, Qt::Key_Down);
+
+ QTRY_COMPARE(listview->contentY(), expectedPos);
+
+ expectedPos += 20; // scroll past 1st item of 2nd section
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QTRY_COMPARE(listview->contentY(), expectedPos);
+
+ expectedPos += 20 + 10; // scroll past 2nd item of 2nd section and section delegate of 3rd section
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QTRY_COMPARE(listview->contentY(), expectedPos);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::spacing()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ listview->setSpacing(10);
+ QTRY_VERIFY(listview->spacing() == 10);
+
+ // Confirm items positioned correctly
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() == 11);
+ for (int i = 0; i < 11; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*30);
+ }
+
+ listview->setSpacing(0);
+
+ // Confirm items positioned correctly
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() >= 16);
+ for (int i = 0; i < 16; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.0);
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+template <typename T>
+void tst_QQuickListView::sections(const QUrl &source)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i/5));
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
+ QQuickText *next = findItem<QQuickText>(item, "nextSection");
+ QCOMPARE(next->text().toInt(), (i+1)/5);
+ }
+
+ QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged()));
+
+ // Remove section boundary
+ model.removeItem(5);
+ QTRY_COMPARE(listview->count(), model.count());
+
+ // New section header created
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 5);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
+
+ model.insertItem(3, "New Item", "0");
+ QTRY_COMPARE(listview->count(), model.count());
+
+ // Section header moved
+ item = findItem<QQuickItem>(contentItem, "wrapper", 5);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 6);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
+
+ // insert item which will become a section header
+ model.insertItem(6, "Replace header", "1");
+ QTRY_COMPARE(listview->count(), model.count());
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 6);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 7);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
+
+ QTRY_COMPARE(listview->currentSection(), QString("0"));
+
+ listview->setContentY(140);
+ QTRY_COMPARE(listview->currentSection(), QString("1"));
+
+ QTRY_COMPARE(currentSectionChangedSpy.count(), 1);
+
+ listview->setContentY(20);
+ QTRY_COMPARE(listview->currentSection(), QString("0"));
+
+ QTRY_COMPARE(currentSectionChangedSpy.count(), 2);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 1);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
+
+ // check that headers change when item changes
+ listview->setContentY(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ model.modifyItem(0, "changed", "2");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 1);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::sectionsDelegate()
+{
+ QSKIP("QTBUG-24395");
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i/5));
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20));
+ QQuickText *next = findItem<QQuickText>(item, "nextSection");
+ QCOMPARE(next->text().toInt(), (i+1)/5);
+ }
+
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ // ensure section header is maintained in view
+ listview->setCurrentIndex(20);
+ QTRY_VERIFY(listview->contentY() >= 200.0);
+ listview->setCurrentIndex(0);
+ QTRY_COMPARE(listview->contentY(), 0.0);
+
+ // change section
+ model.modifyItem(0, "One", "aaa");
+ model.modifyItem(1, "Two", "aaa");
+ model.modifyItem(2, "Three", "aaa");
+ model.modifyItem(3, "Four", "aaa");
+ model.modifyItem(4, "Five", "aaa");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ // remove section boundary
+ model.removeItem(5);
+ QTRY_COMPARE(listview->count(), model.count());
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
+ QVERIFY(item);
+ }
+
+ // QTBUG-17606
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "sect_1");
+ QCOMPARE(items.count(), 1);
+
+ // QTBUG-17759
+ model.modifyItem(0, "One", "aaa");
+ model.modifyItem(1, "One", "aaa");
+ model.modifyItem(2, "One", "aaa");
+ model.modifyItem(3, "Four", "aaa");
+ model.modifyItem(4, "Four", "aaa");
+ model.modifyItem(5, "Four", "aaa");
+ model.modifyItem(6, "Five", "aaa");
+ model.modifyItem(7, "Five", "aaa");
+ model.modifyItem(8, "Five", "aaa");
+ model.modifyItem(9, "Two", "aaa");
+ model.modifyItem(10, "Two", "aaa");
+ model.modifyItem(11, "Two", "aaa");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").count(), 1);
+ canvas->rootObject()->setProperty("sectionProperty", "name");
+ // ensure view has settled.
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_Four").count(), 1);
+ for (int i = 0; i < 4; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + model.name(i*3));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*4));
+ }
+
+ // QTBUG-17769
+ model.removeItems(10, 20);
+ // ensure view has settled.
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 10);
+ // Drag view up beyond bounds
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20,20));
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(20,0), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(20,-50), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(20,-200), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,-200));
+ // view should settle back at 0
+ QTRY_COMPARE(listview->contentY(), 0.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::sectionsPositioning()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i/5));
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
+ canvas->show();
+ qApp->processEvents();
+ canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd)));
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ QQuickItem *topItem = findVisibleChild(contentItem, "sect_0"); // section header
+ QVERIFY(topItem);
+ QCOMPARE(topItem->y(), 0.);
+
+ QQuickItem *bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
+ QVERIFY(bottomItem);
+ QCOMPARE(bottomItem->y(), 300.);
+
+ // move down a little and check that section header is at top
+ listview->setContentY(10);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QCOMPARE(topItem->y(), 0.);
+
+ // push the top header up
+ listview->setContentY(110);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ topItem = findVisibleChild(contentItem, "sect_0"); // section header
+ QVERIFY(topItem);
+ QCOMPARE(topItem->y(), 100.);
+
+ QQuickItem *item = findVisibleChild(contentItem, "sect_1");
+ QVERIFY(item);
+ QCOMPARE(item->y(), 120.);
+
+ bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
+ QVERIFY(bottomItem);
+ QCOMPARE(bottomItem->y(), 410.);
+
+ // Move past section 0
+ listview->setContentY(120);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ topItem = findVisibleChild(contentItem, "sect_0"); // section header
+ QVERIFY(!topItem);
+
+ // Push section footer down
+ listview->setContentY(70);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
+ QVERIFY(bottomItem);
+ QCOMPARE(bottomItem->y(), 380.);
+
+ // Change current section
+ listview->setContentY(10);
+ model.modifyItem(0, "One", "aaa");
+ model.modifyItem(1, "Two", "aaa");
+ model.modifyItem(2, "Three", "aaa");
+ model.modifyItem(3, "Four", "aaa");
+ model.modifyItem(4, "Five", "aaa");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QTRY_COMPARE(listview->currentSection(), QString("aaa"));
+
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header
+ QCOMPARE(topItem->y(), 10.);
+
+ // remove section boundary
+ listview->setContentY(120);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ model.removeItem(5);
+ QTRY_COMPARE(listview->count(), model.count());
+ for (int i = 1; i < 3; ++i) {
+ QQuickItem *item = findVisibleChild(contentItem,
+ "sect_" + QString::number(i));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ QVERIFY(topItem = findVisibleChild(contentItem, "sect_1"));
+ QTRY_COMPARE(topItem->y(), 120.);
+
+ // Change the next section
+ listview->setContentY(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
+ QVERIFY(bottomItem);
+ QTRY_COMPARE(bottomItem->y(), 300.);
+
+ model.modifyItem(14, "New", "new");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer
+ QTRY_COMPARE(bottomItem->y(), 300.);
+
+ // Turn sticky footer off
+ listview->setContentY(20);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart)));
+ QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored
+ QCOMPARE(item->y(), 340.);
+
+ // Turn sticky header off
+ listview->setContentY(30);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels)));
+ QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored
+ QCOMPARE(item->y(), 0.);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::sectionPropertyChange()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("sectionpropertychange.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 2; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(25. + i*75.));
+ }
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 2; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(25. + i*75.));
+ }
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 2; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(25. + i*75.));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::currentIndex_delayedItemCreation()
+{
+ QFETCH(bool, setCurrentToZero);
+
+ QQuickView *canvas = createView();
+
+ // test currentIndexChanged() is emitted even if currentIndex = 0 on start up
+ // (since the currentItem will have changed and that shares the same index)
+ canvas->rootContext()->setContextProperty("setCurrentToZero", setCurrentToZero);
+
+ canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QSignalSpy spy(listview, SIGNAL(currentItemChanged()));
+ QCOMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(spy.count(), 1);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::currentIndex_delayedItemCreation_data()
+{
+ QTest::addColumn<bool>("setCurrentToZero");
+
+ QTest::newRow("set to 0") << true;
+ QTest::newRow("don't set to 0") << false;
+}
+
+void tst_QQuickListView::currentIndex()
+{
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testWrap", QVariant(false));
+
+ QString filename(testFile("listview-initCurrent.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // current item should be 20th item at startup
+ // and current item should be in view
+ QCOMPARE(listview->currentIndex(), 20);
+ QCOMPARE(listview->contentY(), 100.0);
+ QCOMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 20));
+ QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+
+ // no wrap
+ listview->setCurrentIndex(0);
+ QCOMPARE(listview->currentIndex(), 0);
+ // confirm that the velocity is updated
+ QTRY_VERIFY(listview->verticalVelocity() != 0.0);
+
+ listview->incrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 1);
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ // with wrap
+ ctxt->setContextProperty("testWrap", QVariant(true));
+ QVERIFY(listview->isWrapEnabled());
+
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), model.count()-1);
+
+ QTRY_COMPARE(listview->contentY(), 280.0);
+
+ listview->incrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ QTRY_COMPARE(listview->contentY(), 0.0);
+
+
+ // footer should become visible if it is out of view, and then current index is set to count-1
+ canvas->rootObject()->setProperty("showFooter", true);
+ QTRY_VERIFY(listview->footerItem());
+ listview->setCurrentIndex(model.count()-2);
+ QTRY_VERIFY(listview->footerItem()->y() > listview->contentY() + listview->height());
+ listview->setCurrentIndex(model.count()-1);
+ QTRY_COMPARE(listview->contentY() + listview->height(), (20.0 * model.count()) + listview->footerItem()->height());
+ canvas->rootObject()->setProperty("showFooter", false);
+
+ // header should become visible if it is out of view, and then current index is set to 0
+ canvas->rootObject()->setProperty("showHeader", true);
+ QTRY_VERIFY(listview->headerItem());
+ listview->setCurrentIndex(1);
+ QTRY_VERIFY(listview->headerItem()->y() + listview->headerItem()->height() < listview->contentY());
+ listview->setCurrentIndex(0);
+ QTRY_COMPARE(listview->contentY(), -listview->headerItem()->height());
+ canvas->rootObject()->setProperty("showHeader", false);
+
+
+ // Test keys
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
+
+ listview->setCurrentIndex(0);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(listview->currentIndex(), 1);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(listview->currentIndex(), 0);
+
+ // hold down Key_Down
+ for (int i=0; i<model.count()-1; i++) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true);
+ QTRY_COMPARE(listview->currentIndex(), i+1);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Down);
+ QTRY_COMPARE(listview->currentIndex(), model.count()-1);
+ QTRY_COMPARE(listview->contentY(), 280.0);
+
+ // hold down Key_Up
+ for (int i=model.count()-1; i > 0; i--) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true);
+ QTRY_COMPARE(listview->currentIndex(), i-1);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Up);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->contentY(), 0.0);
+
+
+ // turn off auto highlight
+ listview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(listview->highlightFollowsCurrentItem() == false);
+
+ QVERIFY(listview->highlightItem());
+ qreal hlPos = listview->highlightItem()->y();
+
+ listview->setCurrentIndex(4);
+ QTRY_COMPARE(listview->highlightItem()->y(), hlPos);
+
+ // insert item before currentIndex
+ listview->setCurrentIndex(28);
+ model.insertItem(0, "Foo", "1111");
+ QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
+
+ // check removing highlight by setting currentIndex to -1;
+ listview->setCurrentIndex(-1);
+
+ QCOMPARE(listview->currentIndex(), -1);
+ QVERIFY(!listview->highlightItem());
+ QVERIFY(!listview->currentItem());
+
+ delete canvas;
+}
+
+void tst_QQuickListView::noCurrentIndex()
+{
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QString filename(testFile("listview-noCurrent.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // current index should be -1 at startup
+ // and we should not have a currentItem or highlightItem
+ QCOMPARE(listview->currentIndex(), -1);
+ QCOMPARE(listview->contentY(), 0.0);
+ QVERIFY(!listview->highlightItem());
+ QVERIFY(!listview->currentItem());
+
+ listview->setCurrentIndex(2);
+ QCOMPARE(listview->currentIndex(), 2);
+ QVERIFY(listview->highlightItem());
+ QVERIFY(listview->currentItem());
+
+ delete canvas;
+}
+
+void tst_QQuickListView::itemList()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("itemlist.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickVisualItemModel *model = canvas->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
+ QTRY_VERIFY(model != 0);
+
+ QTRY_VERIFY(model->count() == 3);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), 0.0);
+ QCOMPARE(item->height(), listview->height());
+
+ QQuickText *text = findItem<QQuickText>(contentItem, "text1");
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
+
+ listview->setCurrentIndex(2);
+
+ item = findItem<QQuickItem>(contentItem, "item3");
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), 480.0);
+
+ text = findItem<QQuickText>(contentItem, "text3");
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
+
+ delete canvas;
+}
+
+void tst_QQuickListView::cacheBuffer()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 90; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_VERIFY(listview->delegate() != 0);
+ QTRY_VERIFY(listview->model() != 0);
+ QTRY_VERIFY(listview->highlight() != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ testObject->setCacheBuffer(200);
+ QTRY_VERIFY(listview->cacheBuffer() == 200);
+
+ // items will be created one at a time
+ for (int i = itemCount; i < qMin(itemCount+10,model.count()); ++i) {
+ QVERIFY(findItem<QQuickItem>(listview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(listview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ int newItemCount = 0;
+ newItemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < newItemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ // move view and confirm items in view are visible immediately and outside are created async
+ listview->setContentY(300);
+
+ for (int i = 15; i < 32; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ QVERIFY(findItem<QQuickItem>(listview, "wrapper", 32) == 0);
+
+ // ensure buffered items are created
+ for (int i = 32; i < qMin(41,model.count()); ++i) {
+ QQuickItem *item = 0;
+ while (!item) {
+ qGuiApp->processEvents(); // allow refill to happen
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(listview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::positionViewAtIndex()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+ canvas->show();
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position on a currently visible item
+ listview->positionViewAtIndex(3, QQuickListView::Beginning);
+ QTRY_COMPARE(listview->contentY(), 60.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position on an item beyond the visible items
+ listview->positionViewAtIndex(22, QQuickListView::Beginning);
+ QTRY_COMPARE(listview->contentY(), 440.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ listview->positionViewAtIndex(28, QQuickListView::Beginning);
+ QTRY_COMPARE(listview->contentY(), 480.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position at the beginning again
+ listview->positionViewAtIndex(0, QQuickListView::Beginning);
+ QTRY_COMPARE(listview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position at End using last index
+ listview->positionViewAtIndex(model.count()-1, QQuickListView::End);
+ QTRY_COMPARE(listview->contentY(), 480.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position at End
+ listview->positionViewAtIndex(20, QQuickListView::End);
+ QTRY_COMPARE(listview->contentY(), 100.);
+
+ // Position in Center
+ listview->positionViewAtIndex(15, QQuickListView::Center);
+ QTRY_COMPARE(listview->contentY(), 150.);
+
+ // Ensure at least partially visible
+ listview->positionViewAtIndex(15, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 150.);
+
+ listview->setContentY(302);
+ listview->positionViewAtIndex(15, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 302.);
+
+ listview->setContentY(320);
+ listview->positionViewAtIndex(15, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 300.);
+
+ listview->setContentY(85);
+ listview->positionViewAtIndex(20, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 85.);
+
+ listview->setContentY(75);
+ listview->positionViewAtIndex(20, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 100.);
+
+ // Ensure completely visible
+ listview->setContentY(120);
+ listview->positionViewAtIndex(20, QQuickListView::Contain);
+ QTRY_COMPARE(listview->contentY(), 120.);
+
+ listview->setContentY(302);
+ listview->positionViewAtIndex(15, QQuickListView::Contain);
+ QTRY_COMPARE(listview->contentY(), 300.);
+
+ listview->setContentY(85);
+ listview->positionViewAtIndex(20, QQuickListView::Contain);
+ QTRY_COMPARE(listview->contentY(), 100.);
+
+ // positionAtBeginnging
+ listview->positionViewAtBeginning();
+ QTRY_COMPARE(listview->contentY(), 0.);
+
+ listview->setContentY(80);
+ canvas->rootObject()->setProperty("showHeader", true);
+ listview->positionViewAtBeginning();
+ QTRY_COMPARE(listview->contentY(), -30.);
+
+ // positionAtEnd
+ listview->positionViewAtEnd();
+ QTRY_COMPARE(listview->contentY(), 480.); // 40*20 - 320
+
+ listview->setContentY(80);
+ canvas->rootObject()->setProperty("showFooter", true);
+ listview->positionViewAtEnd();
+ QTRY_COMPARE(listview->contentY(), 510.);
+
+ // set current item to outside visible view, position at beginning
+ // and ensure highlight moves to current item
+ listview->setCurrentIndex(1);
+ listview->positionViewAtBeginning();
+ QTRY_COMPARE(listview->contentY(), -30.);
+ QVERIFY(listview->highlightItem());
+ QCOMPARE(listview->highlightItem()->y(), 20.);
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::resetModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaylist.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QTRY_COMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QTRY_COMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::propertyChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
+ QTRY_VERIFY(listView);
+
+ QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged()));
+ QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged()));
+ QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged()));
+ QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged()));
+ QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged()));
+ QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged()));
+ QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged()));
+
+ QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true);
+ QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0);
+ QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0);
+ QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::ApplyRange);
+ QTRY_COMPARE(listView->isWrapEnabled(), true);
+ QTRY_COMPARE(listView->cacheBuffer(), 10);
+ QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapToItem);
+
+ listView->setHighlightFollowsCurrentItem(false);
+ listView->setPreferredHighlightBegin(1.0);
+ listView->setPreferredHighlightEnd(1.0);
+ listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
+ listView->setWrapEnabled(false);
+ listView->setCacheBuffer(3);
+ listView->setSnapMode(QQuickListView::SnapOneItem);
+
+ QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false);
+ QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0);
+ QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0);
+ QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
+ QTRY_COMPARE(listView->isWrapEnabled(), false);
+ QTRY_COMPARE(listView->cacheBuffer(), 3);
+ QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapOneItem);
+
+ QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
+ QTRY_COMPARE(highlightRangeModeSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(snapModeSpy.count(),1);
+
+ listView->setHighlightFollowsCurrentItem(false);
+ listView->setPreferredHighlightBegin(1.0);
+ listView->setPreferredHighlightEnd(1.0);
+ listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
+ listView->setWrapEnabled(false);
+ listView->setCacheBuffer(3);
+ listView->setSnapMode(QQuickListView::SnapOneItem);
+
+ QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
+ QTRY_COMPARE(highlightRangeModeSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(snapModeSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::componentChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
+ QTRY_VERIFY(listView);
+
+ QQmlComponent component(canvas->engine());
+ component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
+
+ QQmlComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged()));
+ QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged()));
+ QSignalSpy headerSpy(listView, SIGNAL(headerChanged()));
+ QSignalSpy footerSpy(listView, SIGNAL(footerChanged()));
+
+ listView->setHighlight(&component);
+ listView->setHeader(&component);
+ listView->setFooter(&component);
+ listView->setDelegate(&delegateComponent);
+
+ QTRY_COMPARE(listView->highlight(), &component);
+ QTRY_COMPARE(listView->header(), &component);
+ QTRY_COMPARE(listView->footer(), &component);
+ QTRY_COMPARE(listView->delegate(), &delegateComponent);
+
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
+
+ listView->setHighlight(&component);
+ listView->setHeader(&component);
+ listView->setFooter(&component);
+ listView->setDelegate(&delegateComponent);
+
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::modelChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
+ QTRY_VERIFY(listView);
+
+ QQuickListModel *alternateModel = canvas->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QTRY_VERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
+ QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
+
+ listView->setModel(modelVariant);
+ QTRY_COMPARE(listView->model(), modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
+
+ listView->setModel(modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
+
+ listView->setModel(QVariant());
+ QTRY_COMPARE(modelSpy.count(),2);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::QTBUG_9791()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("strictlyenforcerange.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_VERIFY(listview->delegate() != 0);
+ QTRY_VERIFY(listview->model() != 0);
+
+ QMetaObject::invokeMethod(listview, "fillModel");
+ qApp->processEvents();
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ QCOMPARE(itemCount, 3);
+
+ for (int i = 0; i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), i*300.0);
+ }
+
+ // check that view is positioned correctly
+ QTRY_COMPARE(listview->contentX(), 590.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::manualHighlight()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QString filename(testFile("manual-highlight.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
+
+ listview->setCurrentIndex(2);
+
+ QTRY_COMPARE(listview->currentIndex(), 2);
+ QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
+
+ // QTBUG-15972
+ listview->positionViewAtIndex(3, QQuickListView::Contain);
+
+ QTRY_COMPARE(listview->currentIndex(), 2);
+ QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
+
+ delete canvas;
+}
+
+void tst_QQuickListView::QTBUG_11105()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ listview->positionViewAtIndex(20, QQuickListView::Beginning);
+ QCOMPARE(listview->contentY(), 280.);
+
+ QmlListModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::header()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QPointF, initialHeaderPos);
+ QFETCH(QPointF, firstDelegatePos);
+ QFETCH(QPointF, initialContentPos);
+ QFETCH(QPointF, changedHeaderPos);
+ QFETCH(QPointF, changedContentPos);
+ QFETCH(QPointF, resizeContentPos);
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("initialViewWidth", 240);
+ canvas->rootContext()->setContextProperty("initialViewHeight", 320);
+ canvas->setSource(testFileUrl("header.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *header = 0;
+ QTRY_VERIFY(header = findItem<QQuickText>(contentItem, "header"));
+ QVERIFY(header == listview->headerItem());
+
+ QCOMPARE(header->width(), 100.);
+ QCOMPARE(header->height(), 30.);
+ QCOMPARE(header->pos(), initialHeaderPos);
+ QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ model.clear();
+ QTRY_COMPARE(listview->count(), model.count());
+ QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is
+
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QSignalSpy headerItemSpy(listview, SIGNAL(headerItemChanged()));
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
+
+ QCOMPARE(headerItemSpy.count(), 1);
+
+ header = findItem<QQuickText>(contentItem, "header");
+ QVERIFY(!header);
+ header = findItem<QQuickText>(contentItem, "header2");
+ QVERIFY(header);
+
+ QVERIFY(header == listview->headerItem());
+
+ QCOMPARE(header->pos(), changedHeaderPos);
+ QCOMPARE(header->width(), 50.);
+ QCOMPARE(header->height(), 20.);
+ QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ delete canvas;
+
+
+ // QTBUG-21207 header should become visible if view resizes from initial empty size
+
+ canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("initialViewWidth", 0.0);
+ canvas->rootContext()->setContextProperty("initialViewHeight", 0.0);
+ canvas->setSource(testFileUrl("header.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ listview->setWidth(240);
+ listview->setHeight(320);
+ QTRY_COMPARE(listview->headerItem()->pos(), initialHeaderPos);
+ QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
+
+
+ delete canvas;
+}
+
+void tst_QQuickListView::header_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QPointF>("initialHeaderPos");
+ QTest::addColumn<QPointF>("changedHeaderPos");
+ QTest::addColumn<QPointF>("initialContentPos");
+ QTest::addColumn<QPointF>("changedContentPos");
+ QTest::addColumn<QPointF>("firstDelegatePos");
+ QTest::addColumn<QPointF>("resizeContentPos");
+
+ // header1 = 100 x 30
+ // header2 = 50 x 20
+ // delegates = 240 x 20
+ // view width = 240
+
+ // header above items, top left
+ QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, 0)
+ << QPointF(0, -10);
+
+ // header above items, top right
+ QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, 0)
+ << QPointF(0, -10);
+
+ // header to left of items
+ QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight
+ << QPointF(-100, 0)
+ << QPointF(-50, 0)
+ << QPointF(-100, 0)
+ << QPointF(-50, 0)
+ << QPointF(0, 0)
+ << QPointF(-40, 0);
+
+ // header to right of items
+ QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(-240 + 100, 0)
+ << QPointF(-240 + 50, 0)
+ << QPointF(-240, 0)
+ << QPointF(-240 + 40, 0);
+}
+
+void tst_QQuickListView::header_delayItemCreation()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+
+ canvas->rootContext()->setContextProperty("setCurrentToZero", QVariant(false));
+ canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *header = findItem<QQuickText>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->y(), -header->height());
+
+ QCOMPARE(listview->contentY(), -header->height());
+
+ model.clear();
+ QTRY_COMPARE(header->y(), -header->height());
+
+ delete canvas;
+}
+
+void tst_QQuickListView::footer()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QPointF, initialFooterPos);
+ QFETCH(QPointF, firstDelegatePos);
+ QFETCH(QPointF, initialContentPos);
+ QFETCH(QPointF, changedFooterPos);
+ QFETCH(QPointF, changedContentPos);
+ QFETCH(QPointF, resizeContentPos);
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 3; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("footer.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
+ QVERIFY(footer);
+
+ QVERIFY(footer == listview->footerItem());
+
+ QCOMPARE(footer->pos(), initialFooterPos);
+ QCOMPARE(footer->width(), 100.);
+ QCOMPARE(footer->height(), 30.);
+ QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ // remove one item
+ model.removeItem(1);
+
+ if (orientation == QQuickListView::Vertical) {
+ QTRY_COMPARE(footer->y(), initialFooterPos.y() - 20); // delegate height = 20
+ } else {
+ QTRY_COMPARE(footer->x(), layoutDirection == Qt::LeftToRight ?
+ initialFooterPos.x() - 40 : initialFooterPos.x() + 40); // delegate width = 40
+ }
+
+ // remove all items
+ model.clear();
+
+ QPointF posWhenNoItems(0, 0);
+ if (orientation == QQuickListView::Horizontal && layoutDirection == Qt::RightToLeft)
+ posWhenNoItems.setX(-100);
+ QTRY_COMPARE(footer->pos(), posWhenNoItems);
+
+ // if header is present, it's at a negative pos, so the footer should not move
+ canvas->rootObject()->setProperty("showHeader", true);
+ QTRY_COMPARE(footer->pos(), posWhenNoItems);
+ canvas->rootObject()->setProperty("showHeader", false);
+
+ // add 30 items
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QSignalSpy footerItemSpy(listview, SIGNAL(footerItemChanged()));
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
+
+ QCOMPARE(footerItemSpy.count(), 1);
+
+ footer = findItem<QQuickText>(contentItem, "footer");
+ QVERIFY(!footer);
+ footer = findItem<QQuickText>(contentItem, "footer2");
+ QVERIFY(footer);
+
+ QVERIFY(footer == listview->footerItem());
+
+ QCOMPARE(footer->pos(), changedFooterPos);
+ QCOMPARE(footer->width(), 50.);
+ QCOMPARE(footer->height(), 20.);
+ QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ listview->positionViewAtEnd();
+ footer->setHeight(10);
+ footer->setWidth(40);
+ QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), resizeContentPos);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::footer_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QPointF>("initialFooterPos");
+ QTest::addColumn<QPointF>("changedFooterPos");
+ QTest::addColumn<QPointF>("initialContentPos");
+ QTest::addColumn<QPointF>("changedContentPos");
+ QTest::addColumn<QPointF>("firstDelegatePos");
+ QTest::addColumn<QPointF>("resizeContentPos");
+
+ // footer1 = 100 x 30
+ // footer2 = 50 x 20
+ // delegates = 40 x 20
+ // view width = 240
+ // view height = 320
+
+ // footer below items, bottom left
+ QTest::newRow("vertical, layout left to right") << QQuickListView::Vertical << Qt::LeftToRight
+ << QPointF(0, 3 * 20)
+ << QPointF(0, 30 * 20) // added 30 items
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 30 * 20 - 320 + 10);
+
+ // footer below items, bottom right
+ QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft
+ << QPointF(0, 3 * 20)
+ << QPointF(0, 30 * 20)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 30 * 20 - 320 + 10);
+
+ // footer to right of items
+ QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight
+ << QPointF(40 * 3, 0)
+ << QPointF(40 * 30, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(40 * 30 - 240 + 40, 0);
+
+ // footer to left of items
+ QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft
+ << QPointF(-(40 * 3) - 100, 0)
+ << QPointF(-(40 * 30) - 50, 0) // 50 = new footer width
+ << QPointF(-240, 0)
+ << QPointF(-240, 0)
+ << QPointF(-40, 0)
+ << QPointF(-(40 * 30) - 40, 0);
+}
+
+class LVAccessor : public QQuickListView
+{
+public:
+ qreal minY() const { return minYExtent(); }
+ qreal maxY() const { return maxYExtent(); }
+ qreal minX() const { return minXExtent(); }
+ qreal maxX() const { return maxXExtent(); }
+};
+
+void tst_QQuickListView::headerFooter()
+{
+ {
+ // Vertical
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("headerfooter.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->y(), -header->height());
+
+ QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->y(), 0.);
+
+ QCOMPARE(static_cast<LVAccessor*>(listview)->minY(), header->height());
+ QCOMPARE(static_cast<LVAccessor*>(listview)->maxY(), header->height());
+
+ delete canvas;
+ }
+ {
+ // Horizontal
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("headerfooter.qml"));
+ canvas->rootObject()->setProperty("horizontal", true);
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->x(), -header->width());
+
+ QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->x(), 0.);
+
+ QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), header->width());
+ QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), header->width());
+
+ delete canvas;
+ }
+ {
+ // Horizontal RTL
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("headerfooter.qml"));
+ canvas->rootObject()->setProperty("horizontal", true);
+ canvas->rootObject()->setProperty("rtl", true);
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->x(), 0.);
+
+ QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->x(), -footer->width());
+
+ QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), 240. - header->width());
+ QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), 240. - header->width());
+
+ delete canvas;
+ }
+}
+
+void tst_QQuickListView::resizeView()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ QVariant heightRatio;
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.4);
+
+ listview->setHeight(200);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.25);
+
+ // Ensure we handle -ve sizes
+ listview->setHeight(-100);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 1);
+
+ listview->setCacheBuffer(200);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 11);
+
+ // ensure items in cache become visible
+ listview->setHeight(200);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 21);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ QCOMPARE(item->isVisible(), i < 11); // inside view visible, outside not visible
+ }
+
+ // ensure items outside view become invisible
+ listview->setHeight(100);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 16);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::resizeViewAndRepaint()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("initialHeight", 100);
+
+ canvas->setSource(testFileUrl("resizeview.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // item at index 10 should not be currently visible
+ QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ listview->setHeight(320);
+
+ QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ listview->setHeight(100);
+ QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ delete canvas;
+}
+
+void tst_QQuickListView::sizeLessThan1()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("sizelessthan1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*0.5);
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::QTBUG_14821()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("qtbug14821.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 99);
+
+ listview->incrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::resizeDelegate()
+{
+ QQuickView *canvas = createView();
+
+ QStringList strings;
+ for (int i = 0; i < 30; ++i)
+ strings << QString::number(i);
+ QStringListModel model(strings);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaylist.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QCOMPARE(listview->count(), model.rowCount());
+
+ listview->setCurrentIndex(25);
+ listview->setContentY(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 0; i < 16; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ QCOMPARE(listview->currentItem()->y(), 500.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 500.0);
+
+ canvas->rootObject()->setProperty("delegateHeight", 30);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 0; i < 11; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QTRY_COMPARE(item->y(), i*30.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 750.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 750.0);
+
+ listview->setCurrentIndex(1);
+ listview->positionViewAtIndex(25, QQuickListView::Beginning);
+ listview->positionViewAtIndex(5, QQuickListView::Beginning);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 5; i < 16; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*30.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 30.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 30.0);
+
+ canvas->rootObject()->setProperty("delegateHeight", 20);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 5; i < 11; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QTRY_COMPARE(item->y(), 150 + (i-5)*20.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 70.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 70.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::resizeFirstDelegate()
+{
+ // QTBUG-20712: Content Y jumps constantly if first delegate height == 0
+ // and other delegates have height > 0
+
+ QQuickView *canvas = createView();
+
+ // bug only occurs when all items in the model are visible
+ QmlListModel model;
+ for (int i = 0; i < 10; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *item = 0;
+ for (int i = 0; i < model.count(); ++i) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ item->setHeight(0);
+
+ // check the content y has not jumped up and down
+ QCOMPARE(listview->contentY(), 0.0);
+ QSignalSpy spy(listview, SIGNAL(contentYChanged()));
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 0);
+
+ for (int i = 1; i < model.count(); ++i) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QTRY_COMPARE(item->y(), (i-1)*20.0);
+ }
+
+
+ // QTBUG-22014: refill doesn't clear items scrolling off the top of the
+ // list if they follow a zero-sized delegate
+
+ for (int i = 0; i < 10; i++)
+ model.addItem("Item" + QString::number(i), "");
+ QTRY_COMPARE(listview->count(), model.count());
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 1);
+ QVERIFY(item);
+ item->setHeight(0);
+
+ listview->setCurrentIndex(19);
+ qApp->processEvents();
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // items 0-2 should have been deleted
+ for (int i=0; i<3; i++) {
+ QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", i));
+ }
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickListView::QTBUG_16037()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ canvas->setSource(testFileUrl("qtbug16037.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
+ QTRY_VERIFY(listview != 0);
+
+ QVERIFY(listview->contentHeight() <= 0.0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "setModel");
+
+ QTRY_COMPARE(listview->contentHeight(), 80.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::indexAt_itemAt_data()
+{
+ QTest::addColumn<qreal>("x");
+ QTest::addColumn<qreal>("y");
+ QTest::addColumn<int>("index");
+
+ QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0;
+ QTest::newRow("Item 0 - 0, 19") << 0. << 19. << 0;
+ QTest::newRow("Item 0 - 239, 19") << 239. << 19. << 0;
+ QTest::newRow("Item 1 - 0, 20") << 0. << 20. << 1;
+ QTest::newRow("No Item - 240, 20") << 240. << 20. << -1;
+}
+
+void tst_QQuickListView::indexAt_itemAt()
+{
+ QFETCH(qreal, x);
+ QFETCH(qreal, y);
+ QFETCH(int, index);
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *item = 0;
+ if (index >= 0) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", index);
+ QVERIFY(item);
+ }
+ QCOMPARE(listview->indexAt(x,y), index);
+ QVERIFY(listview->itemAt(x,y) == item);
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::incrementalModel()
+{
+ QQuickView *canvas = createView();
+
+ IncrementalModel model;
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaylist.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(listview->count(), 20);
+
+ listview->positionViewAtIndex(10, QQuickListView::Beginning);
+
+ QTRY_COMPARE(listview->count(), 25);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::onAdd()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, itemsToAdd);
+
+ const int delegateHeight = 10;
+ QaimModel model;
+
+ // these initial items should not trigger ListView.onAdd
+ for (int i=0; i<initialItemCount; i++)
+ model.addItem("dummy value", "dummy value");
+
+ QQuickView *canvas = createView();
+ canvas->setGeometry(0,0,200, delegateHeight * (initialItemCount + itemsToAdd));
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("delegateHeight", delegateHeight);
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
+
+ QObject *object = canvas->rootObject();
+ object->setProperty("width", canvas->width());
+ object->setProperty("height", canvas->height());
+ qApp->processEvents();
+
+ QList<QPair<QString, QString> > items;
+ for (int i=0; i<itemsToAdd; i++)
+ items << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.addItems(items);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QVariantList result = object->property("addedDelegates").toList();
+ QCOMPARE(result.count(), items.count());
+ for (int i=0; i<items.count(); i++)
+ QCOMPARE(result[i].toString(), items[i].first);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::onAdd_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("itemsToAdd");
+
+ QTest::newRow("0, add 1") << 0 << 1;
+ QTest::newRow("0, add 2") << 0 << 2;
+ QTest::newRow("0, add 10") << 0 << 10;
+
+ QTest::newRow("1, add 1") << 1 << 1;
+ QTest::newRow("1, add 2") << 1 << 2;
+ QTest::newRow("1, add 10") << 1 << 10;
+
+ QTest::newRow("5, add 1") << 5 << 1;
+ QTest::newRow("5, add 2") << 5 << 2;
+ QTest::newRow("5, add 10") << 5 << 10;
+}
+
+void tst_QQuickListView::onRemove()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, indexToRemove);
+ QFETCH(int, removeCount);
+
+ const int delegateHeight = 10;
+ QaimModel model;
+ for (int i=0; i<initialItemCount; i++)
+ model.addItem(QString("value %1").arg(i), "dummy value");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("delegateHeight", delegateHeight);
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
+
+ QObject *object = canvas->rootObject();
+
+ model.removeItems(indexToRemove, removeCount);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
+
+ delete canvas;
+}
+
+void tst_QQuickListView::onRemove_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("indexToRemove");
+ QTest::addColumn<int>("removeCount");
+
+ QTest::newRow("remove first") << 1 << 0 << 1;
+ QTest::newRow("two items, remove first") << 2 << 0 << 1;
+ QTest::newRow("two items, remove last") << 2 << 1 << 1;
+ QTest::newRow("two items, remove all") << 2 << 0 << 2;
+
+ QTest::newRow("four items, remove first") << 4 << 0 << 1;
+ QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
+ QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
+ QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
+ QTest::newRow("four items, remove last") << 4 << 3 << 1;
+ QTest::newRow("four items, remove all") << 4 << 0 << 4;
+
+ QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
+ QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
+ QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
+}
+
+void tst_QQuickListView::rightToLeft()
+{
+ QQuickView *canvas = createView();
+ canvas->setGeometry(0,0,640,320);
+ canvas->setSource(testFileUrl("rightToLeft.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QVERIFY(canvas->rootObject() != 0);
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickVisualItemModel *model = canvas->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
+ QTRY_VERIFY(model != 0);
+
+ QTRY_VERIFY(model->count() == 3);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+
+ // initial position at first item, right edge aligned
+ QCOMPARE(listview->contentX(), -640.);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), -100.0);
+ QCOMPARE(item->height(), listview->height());
+
+ QQuickText *text = findItem<QQuickText>(contentItem, "text1");
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
+
+ listview->setCurrentIndex(2);
+
+ item = findItem<QQuickItem>(contentItem, "item3");
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), -540.0);
+
+ text = findItem<QQuickText>(contentItem, "text3");
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
+
+ QCOMPARE(listview->contentX(), -640.);
+
+ // Ensure resizing maintains position relative to right edge
+ qobject_cast<QQuickItem*>(canvas->rootObject())->setWidth(600);
+ QTRY_COMPARE(listview->contentX(), -600.);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::test_mirroring()
+{
+ QQuickView *canvasA = createView();
+ canvasA->setSource(testFileUrl("rightToLeft.qml"));
+ QQuickListView *listviewA = findItem<QQuickListView>(canvasA->rootObject(), "view");
+ QTRY_VERIFY(listviewA != 0);
+
+ QQuickView *canvasB = createView();
+ canvasB->setSource(testFileUrl("rightToLeft.qml"));
+ QQuickListView *listviewB = findItem<QQuickListView>(canvasB->rootObject(), "view");
+ QTRY_VERIFY(listviewA != 0);
+ qApp->processEvents();
+
+ QList<QString> objectNames;
+ objectNames << "item1" << "item2"; // << "item3"
+
+ listviewA->setProperty("layoutDirection", Qt::LeftToRight);
+ listviewB->setProperty("layoutDirection", Qt::RightToLeft);
+ QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection());
+
+ // LTR != RTL
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
+
+ listviewA->setProperty("layoutDirection", Qt::LeftToRight);
+ listviewB->setProperty("layoutDirection", Qt::LeftToRight);
+
+ // LTR == LTR
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
+
+ QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection());
+ QQuickItemPrivate::get(listviewB)->setLayoutMirror(true);
+ QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection());
+
+ // LTR != LTR+mirror
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
+
+ listviewA->setProperty("layoutDirection", Qt::RightToLeft);
+
+ // RTL == LTR+mirror
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
+
+ listviewB->setProperty("layoutDirection", Qt::RightToLeft);
+
+ // RTL != RTL+mirror
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
+
+ listviewA->setProperty("layoutDirection", Qt::LeftToRight);
+
+ // LTR == RTL+mirror
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
+
+ delete canvasA;
+ delete canvasB;
+}
+
+void tst_QQuickListView::margins()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 50; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("margins.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QCOMPARE(listview->contentY(), -30.);
+ QCOMPARE(listview->yOrigin(), 0.);
+
+ // check end bound
+ listview->positionViewAtEnd();
+ qreal pos = listview->contentY();
+ listview->setContentY(pos + 80);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ listview->returnToBounds();
+ QTRY_COMPARE(listview->contentY(), pos + 50);
+
+ // remove item before visible and check that top margin is maintained
+ // and yOrigin is updated
+ listview->setContentY(100);
+ model.removeItem(1);
+ QTRY_COMPARE(listview->count(), model.count());
+ listview->setContentY(-50);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ listview->returnToBounds();
+ QCOMPARE(listview->yOrigin(), 20.);
+ QTRY_COMPARE(listview->contentY(), -10.);
+
+ // reduce top margin
+ listview->setTopMargin(20);
+ QCOMPARE(listview->yOrigin(), 20.);
+ QTRY_COMPARE(listview->contentY(), 0.);
+
+ // check end bound
+ listview->positionViewAtEnd();
+ pos = listview->contentY();
+ listview->setContentY(pos + 80);
+ listview->returnToBounds();
+ QTRY_COMPARE(listview->contentY(), pos + 50);
+
+ // reduce bottom margin
+ pos = listview->contentY();
+ listview->setBottomMargin(40);
+ QCOMPARE(listview->yOrigin(), 20.);
+ QTRY_COMPARE(listview->contentY(), pos-10);
+
+ delete canvas;
+}
+
+// QTBUG-24028
+void tst_QQuickListView::marginsResize()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(qreal, start);
+ QFETCH(qreal, end);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("margins2.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
+ QTRY_VERIFY(listview != 0);
+
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // view is resized after componentCompleted - top margin should still be visible
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), start);
+ else
+ QCOMPARE(listview->contentX(), start);
+
+ // move to last index and ensure bottom margin is visible.
+ listview->setCurrentIndex(19);
+ if (orientation == QQuickListView::Vertical)
+ QTRY_COMPARE(listview->contentY(), end);
+ else
+ QTRY_COMPARE(listview->contentX(), end);
+
+ // back to top - top margin should be visible.
+ listview->setCurrentIndex(0);
+ if (orientation == QQuickListView::Vertical)
+ QTRY_COMPARE(listview->contentY(), start);
+ else
+ QTRY_COMPARE(listview->contentX(), start);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::marginsResize_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<qreal>("start");
+ QTest::addColumn<qreal>("end");
+
+ QTest::newRow("vertical") << QQuickListView::Vertical << Qt::LeftToRight << -20.0 << 1020.0;
+ QTest::newRow("horizontal") << QQuickListView::Horizontal << Qt::LeftToRight << -20.0 << 1020.0;
+ QTest::newRow("horizontal, rtl") << QQuickListView::Horizontal << Qt::RightToLeft << -180.0 << -1220.0;
+}
+
+void tst_QQuickListView::snapToItem_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<int>("highlightRangeMode");
+ QTest::addColumn<QPoint>("flickStart");
+ QTest::addColumn<QPoint>("flickEnd");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+
+ QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
+
+ QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+
+ QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+
+ QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
+}
+
+void tst_QQuickListView::snapToItem()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(int, highlightRangeMode);
+ QFETCH(QPoint, flickStart);
+ QFETCH(QPoint, flickEnd);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("snapToItem.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // confirm that a flick hits an item boundary
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(qreal(fmod(listview->contentY(),80.0)), snapAlignment);
+ else
+ QCOMPARE(qreal(fmod(listview->contentX(),80.0)), snapAlignment);
+
+ // flick to end
+ do {
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ } while (orientation == QQuickListView::Vertical
+ ? !listview->isAtYEnd()
+ : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning());
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), endExtent);
+ else
+ QCOMPARE(listview->contentX(), endExtent);
+
+ // flick to start
+ do {
+ flick(canvas, flickEnd, flickStart, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ } while (orientation == QQuickListView::Vertical
+ ? !listview->isAtYBeginning()
+ : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd());
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), startExtent);
+ else
+ QCOMPARE(listview->contentX(), startExtent);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::qListModelInterface_items()
+{
+ items<QmlListModel>(testFileUrl("listviewtest.qml"), false);
+}
+
+void tst_QQuickListView::qListModelInterface_package_items()
+{
+ items<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
+}
+
+void tst_QQuickListView::qAbstractItemModel_items()
+{
+ items<QaimModel>(testFileUrl("listviewtest.qml"), false);
+}
+
+void tst_QQuickListView::qListModelInterface_changed()
+{
+ changed<QmlListModel>(testFileUrl("listviewtest.qml"), false);
+}
+
+void tst_QQuickListView::qListModelInterface_package_changed()
+{
+ changed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
+}
+
+void tst_QQuickListView::qAbstractItemModel_changed()
+{
+ changed<QaimModel>(testFileUrl("listviewtest.qml"), false);
+}
+
+void tst_QQuickListView::qListModelInterface_inserted()
+{
+ inserted<QmlListModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_package_inserted()
+{
+ inserted<QmlListModel>(testFileUrl("listviewtest-package.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_inserted_more()
+{
+ inserted_more<QmlListModel>();
+}
+
+void tst_QQuickListView::qListModelInterface_inserted_more_data()
+{
+ inserted_more_data();
+}
+
+void tst_QQuickListView::qAbstractItemModel_inserted()
+{
+ inserted<QaimModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_inserted_more()
+{
+ inserted_more<QaimModel>();
+}
+
+void tst_QQuickListView::qAbstractItemModel_inserted_more_data()
+{
+ inserted_more_data();
+}
+
+void tst_QQuickListView::qListModelInterface_removed()
+{
+ removed<QmlListModel>(testFileUrl("listviewtest.qml"), false);
+ removed<QmlListModel>(testFileUrl("listviewtest.qml"), true);
+}
+
+void tst_QQuickListView::qListModelInterface_removed_more()
+{
+ removed_more<QmlListModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_removed_more_data()
+{
+ removed_more_data();
+}
+
+void tst_QQuickListView::qListModelInterface_package_removed()
+{
+ removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), false);
+ removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
+}
+
+void tst_QQuickListView::qAbstractItemModel_removed()
+{
+ removed<QaimModel>(testFileUrl("listviewtest.qml"), false);
+ removed<QaimModel>(testFileUrl("listviewtest.qml"), true);
+}
+
+void tst_QQuickListView::qAbstractItemModel_removed_more()
+{
+ removed_more<QaimModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_removed_more_data()
+{
+ removed_more_data();
+}
+
+void tst_QQuickListView::qListModelInterface_moved()
+{
+ moved<QmlListModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_moved_data()
+{
+ moved_data();
+}
+
+void tst_QQuickListView::qListModelInterface_package_moved()
+{
+ moved<QmlListModel>(testFileUrl("listviewtest-package.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_package_moved_data()
+{
+ moved_data();
+}
+
+void tst_QQuickListView::qAbstractItemModel_moved()
+{
+ moved<QaimModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_moved_data()
+{
+ moved_data();
+}
+
+void tst_QQuickListView::qListModelInterface_clear()
+{
+ clear<QmlListModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_package_clear()
+{
+ clear<QmlListModel>(testFileUrl("listviewtest-package.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_clear()
+{
+ clear<QaimModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_sections()
+{
+ sections<QmlListModel>(testFileUrl("listview-sections.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_package_sections()
+{
+ sections<QmlListModel>(testFileUrl("listview-sections-package.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_sections()
+{
+ sections<QaimModel>(testFileUrl("listview-sections.qml"));
+}
+
+void tst_QQuickListView::creationContext()
+{
+ QQuickView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(testFileUrl("creationContext.qml"));
+ qApp->processEvents();
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QQuickItem *item;
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("listItem"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("section"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
+void tst_QQuickListView::QTBUG_21742()
+{
+ QQuickView canvas;
+ canvas.setGeometry(0,0,200,200);
+ canvas.setSource(testFileUrl("qtbug-21742.qml"));
+ qApp->processEvents();
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QCOMPARE(rootItem->property("count").toInt(), 1);
+}
+
+void tst_QQuickListView::asynchronous()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->setSource(testFileUrl("asyncloader.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootObject);
+
+ QQuickListView *listview = 0;
+ while (!listview) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ listview = rootObject->findChild<QQuickListView*>("view");
+ }
+
+ // items will be created one at a time
+ for (int i = 0; i < 8; ++i) {
+ QVERIFY(findItem<QQuickItem>(listview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(listview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ // verify positioning
+ QQuickItem *contentItem = listview->contentItem();
+ for (int i = 0; i < 8; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->y(), i*50.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::snapOneItem_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<int>("highlightRangeMode");
+ QTest::addColumn<QPoint>("flickStart");
+ QTest::addColumn<QPoint>("flickEnd");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+
+ QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0;
+
+ QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
+
+ QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
+
+ QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0;
+}
+
+void tst_QQuickListView::snapOneItem()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(int, highlightRangeMode);
+ QFETCH(QPoint, flickStart);
+ QFETCH(QPoint, flickEnd);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+
+#ifdef Q_OS_MAC
+ // This test seems to be unreliable - different test data fails on different runs
+ QSKIP("QTBUG-24338");
+#endif
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("snapOneItem.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
+
+ // confirm that a flick hits the next item boundary
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), snapAlignment);
+ else
+ QCOMPARE(listview->contentX(), snapAlignment);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(listview->currentIndex(), 1);
+ QCOMPARE(currentIndexSpy.count(), 1);
+ }
+
+ // flick to end
+ do {
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ } while (orientation == QQuickListView::Vertical
+ ? !listview->isAtYEnd()
+ : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning());
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), endExtent);
+ else
+ QCOMPARE(listview->contentX(), endExtent);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(listview->currentIndex(), 3);
+ QCOMPARE(currentIndexSpy.count(), 3);
+ }
+
+ // flick to start
+ do {
+ flick(canvas, flickEnd, flickStart, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ } while (orientation == QQuickListView::Vertical
+ ? !listview->isAtYBeginning()
+ : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd());
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), startExtent);
+ else
+ QCOMPARE(listview->contentX(), startExtent);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(listview->currentIndex(), 0);
+ QCOMPARE(currentIndexSpy.count(), 6);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::unrequestedVisibility()
+{
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testWrap", QVariant(false));
+
+ canvas->setSource(testFileUrl("unrequestedItems.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *leftview = findItem<QQuickListView>(canvas->rootObject(), "leftList");
+ QTRY_VERIFY(leftview != 0);
+
+ QQuickListView *rightview = findItem<QQuickListView>(canvas->rootObject(), "rightList");
+ QTRY_VERIFY(rightview != 0);
+
+ QQuickItem *leftContent = leftview->contentItem();
+ QTRY_VERIFY(leftContent != 0);
+
+ QQuickItem *rightContent = rightview->contentItem();
+ QTRY_VERIFY(rightContent != 0);
+
+ rightview->setCurrentIndex(20);
+
+ QTRY_COMPARE(leftview->contentY(), 0.0);
+ QTRY_COMPARE(rightview->contentY(), 100.0);
+
+ QQuickItem *item;
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), true);
+
+ rightview->setCurrentIndex(0);
+
+ QTRY_COMPARE(leftview->contentY(), 0.0);
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QTRY_COMPARE(item->isVisible(), true);
+
+ QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 19));
+
+ leftview->setCurrentIndex(20);
+
+ QTRY_COMPARE(leftview->contentY(), 100.0);
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QTRY_COMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(19, 1, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(3, 4, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(4, 3, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(16, 17, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(17, 16, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::populateTransitions()
+{
+ QFETCH(bool, staticallyPopulate);
+ QFETCH(bool, dynamicallyPopulate);
+ QFETCH(bool, usePopulateTransition);
+
+ QPointF transitionFrom(-50, -50);
+ QPointF transitionVia(100, 100);
+ QaimModel model_transitionFrom;
+ QaimModel model_transitionVia;
+
+ QaimModel model;
+ if (staticallyPopulate) {
+ for (int i = 0; i < 30; i++)
+ model.addItem("item" + QString::number(i), "");
+ }
+
+ QQuickView *canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("testObject", new TestObject(canvas->rootContext()));
+ canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
+ canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
+ canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom);
+ canvas->rootContext()->setContextProperty("transitionVia", transitionVia);
+ canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom);
+ canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
+ canvas->setSource(testFileUrl("populateTransitions.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QVERIFY(listview);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem);
+
+ if (staticallyPopulate || dynamicallyPopulate) {
+ // check the populate transition is run
+ if (usePopulateTransition) {
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 17);
+ } else {
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0);
+ }
+ QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
+ } else {
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->x(), 0.0);
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ // add an item and check this is done with add trantion, not populate
+ model.insertItem(0, "another item", "");
+ QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 1);
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(),
+ (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 17 : 0);
+
+ // clear the model
+ canvas->rootContext()->setContextProperty("testModel", QVariant());
+ QTRY_COMPARE(listview->count(), 0);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
+ listview->setProperty("countPopulateTransitions", 0);
+ listview->setProperty("countAddTransitions", 0);
+
+ // set to a valid model and check populate transition is run a second time
+ model.clear();
+ for (int i = 0; i < 30; i++)
+ model.addItem("item" + QString::number(i), "");
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0);
+ QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->x(), 0.0);
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ // reset model and check populate transition is run again
+ listview->setProperty("countPopulateTransitions", 0);
+ listview->setProperty("countAddTransitions", 0);
+ model.reset();
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0);
+ QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->x(), 0.0);
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::populateTransitions_data()
+{
+ QTest::addColumn<bool>("staticallyPopulate");
+ QTest::addColumn<bool>("dynamicallyPopulate");
+ QTest::addColumn<bool>("usePopulateTransition");
+
+ QTest::newRow("static") << true << false << true;
+ QTest::newRow("static, no populate") << true << false << false;
+
+ QTest::newRow("dynamic") << false << true << true;
+ QTest::newRow("dynamic, no populate") << false << true << false;
+
+ QTest::newRow("empty to start with") << false << false << true;
+ QTest::newRow("empty to start with, no populate") << false << false << false;
+}
+
+void tst_QQuickListView::addTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(bool, shouldAnimateTargets);
+ QFETCH(qreal, contentY);
+ QFETCH(int, insertionIndex);
+ QFETCH(int, insertionCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // added items should start here
+ QPointF targetItems_transitionFrom(-50, -50);
+
+ // displaced items should pass through this point
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionFrom;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ ctxt->setContextProperty("testObject", testObject);
+ canvas->setSource(testFileUrl("addTransitions.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // only target items that will become visible should be animated
+ QList<QPair<QString, QString> > newData;
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ if (shouldAnimateTargets) {
+ for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
+ newData << qMakePair(QString("New item %1").arg(i), QString(""));
+
+ if (i >= contentY / 20 && i < (contentY + listview->height()) / 20) { // only grab visible items
+ expectedTargetData << newData.last();
+ targetIndexes << i;
+ }
+ }
+ QVERIFY(expectedTargetData.count() > 0);
+ }
+
+ // start animation
+ if (!newData.isEmpty()) {
+ model.insertItems(insertionIndex, newData);
+ QTRY_COMPARE(model.count(), listview->count());
+ }
+
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+
+ if (shouldAnimateTargets) {
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
+ matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+
+ } else {
+ QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0);
+ QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ int itemCount = items.count();
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::addTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<bool>("shouldAnimateTargets");
+ QTest::addColumn<int>("insertionIndex");
+ QTest::addColumn<int>("insertionCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // if inserting before visible index, items should not appear or animate in, even if there are > 1 new items
+ QTest::newRow("insert 1, just before start")
+ << 30 << 20.0 << false
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert 1, way before start")
+ << 30 << 20.0 << false
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert multiple, just before start")
+ << 30 << 100.0 << false
+ << 0 << 3 << ListRange();
+ QTest::newRow("insert multiple, way before start")
+ << 30 << 100.0 << false
+ << 0 << 3 << ListRange();
+
+ QTest::newRow("insert 1 at start")
+ << 30 << 0.0 << true
+ << 0 << 1 << ListRange(0, 15);
+ QTest::newRow("insert multiple at start")
+ << 30 << 0.0 << true
+ << 0 << 3 << ListRange(0, 15);
+ QTest::newRow("insert 1 at start, content y not 0")
+ << 30 << 40.0 << true // first visible is index 2, so translate the displaced indexes by 2
+ << 2 << 1 << ListRange(0 + 2, 15 + 2);
+ QTest::newRow("insert multiple at start, content y not 0")
+ << 30 << 40.0 << true // first visible is index 2
+ << 2 << 3 << ListRange(0 + 2, 15 + 2);
+
+ QTest::newRow("insert 1 at start, to empty list")
+ << 0 << 0.0 << true
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert multiple at start, to empty list")
+ << 0 << 0.0 << true
+ << 0 << 3 << ListRange();
+
+ QTest::newRow("insert 1 at middle")
+ << 30 << 0.0 << true
+ << 5 << 1 << ListRange(5, 15);
+ QTest::newRow("insert multiple at middle")
+ << 30 << 0.0 << true
+ << 5 << 3 << ListRange(5, 15);
+
+ QTest::newRow("insert 1 at bottom")
+ << 30 << 0.0 << true
+ << 15 << 1 << ListRange(15, 15);
+ QTest::newRow("insert multiple at bottom")
+ << 30 << 0.0 << true
+ << 15 << 3 << ListRange(15, 15);
+ QTest::newRow("insert 1 at bottom, content y not 0")
+ << 30 << 20.0 * 3 << true
+ << 15 + 3 << 1 << ListRange(15 + 3, 15 + 3);
+ QTest::newRow("insert multiple at bottom, content y not 0")
+ << 30 << 20.0 * 3 << true
+ << 15 + 3 << 3 << ListRange(15 + 3, 15 + 3);
+
+ // items added after the last visible will not be animated in, since they
+ // do not appear in the final view
+ QTest::newRow("insert 1 after end")
+ << 30 << 0.0 << false
+ << 17 << 1 << ListRange();
+ QTest::newRow("insert multiple after end")
+ << 30 << 0.0 << false
+ << 17 << 3 << ListRange();
+}
+
+void tst_QQuickListView::moveTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(qreal, contentY);
+ QFETCH(qreal, itemsOffsetAfterMove);
+ QFETCH(int, moveFrom);
+ QFETCH(int, moveTo);
+ QFETCH(int, moveCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // target and displaced items should pass through these points
+ QPointF targetItems_transitionVia(-50, 50);
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionVia;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ ctxt->setContextProperty("testObject", testObject);
+ canvas->setSource(testFileUrl("moveTransitions.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QQuickText *name;
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // Items moving to *or* from visible positions should be animated.
+ // Otherwise, they should not be animated.
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ for (int i=moveFrom; i<moveFrom+moveCount; i++) {
+ int toIndex = moveTo + (i - moveFrom);
+ if (i <= (contentY + listview->height()) / 20
+ || toIndex < (contentY + listview->height()) / 20) {
+ expectedTargetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ }
+ // ViewTransition.index provides the indices that items are moving to, not from
+ targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount);
+
+ // start animation
+ model.moveItems(moveFrom, moveTo, moveCount);
+
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount);
+ matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::moveTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+ QTest::addColumn<int>("moveFrom");
+ QTest::addColumn<int>("moveTo");
+ QTest::addColumn<int>("moveCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // when removing from above the visible, all items shift down depending on how many
+ // items have been removed from above the visible
+ QTest::newRow("move from above view, outside visible items, move 1") << 30 << 4*20.0 << 20.0
+ << 1 << 10 << 1 << ListRange(11, 15+4);
+ QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 4*20.0 << 20.0
+ << 0 << 10 << 1 << ListRange(11, 15+4);
+ QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 4*20.0 << 2*20.0
+ << 1 << 10 << 2 << ListRange(12, 15+4);
+ QTest::newRow("move from above view, outside visible items, move multiple (first item)") << 30 << 4*20.0 << 3*20.0
+ << 0 << 10 << 3 << ListRange(13, 15+4);
+ QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 4*20.0 << 3*20.0
+ << 1 << 10 << 5 << ListRange(6, 14) + ListRange(15, 15+4);
+ QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 4*20.0 << 4*20.0
+ << 0 << 10 << 5 << ListRange(5, 14) + ListRange(15, 15+4);
+
+ QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0
+ << 1 << 10 << 1 << ListRange(2, 10);
+ QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0
+ << 0 << 10 << 1 << ListRange(1, 10);
+ QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 0+4 << 10+4 << 1 << ListRange(1+4, 10+4);
+ QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0
+ << 10 << 15 << 1 << ListRange(11, 15);
+ QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0
+ << 0 << 15 << 1 << ListRange(1, 15);
+
+ QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0
+ << 1 << 10 << 3 << ListRange(4, 12);
+ QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0
+ << 0 << 10 << 3 << ListRange(3, 12);
+ QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 0+4 << 10+4 << 3 << ListRange(3+4, 12+4);
+ QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0
+ << 5 << 13 << 3 << ListRange(8, 15);
+ QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0
+ << 0 << 13 << 3 << ListRange(3, 15);
+
+ QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 1 << ListRange(1, 9);
+ QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0
+ << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4);
+ QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 4*20.0 - 10 << 0.0
+ << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4);
+ QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0
+ << 15 << 10 << 1 << ListRange(10, 14);
+ QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0
+ << 15 << 0 << 1 << ListRange(0, 14);
+
+ QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 3 << ListRange(1, 9);
+ QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0
+ << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 10+4 << 0+4 << 3 << ListRange(0+4, 9+4);
+ QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0
+ << 13 << 5 << 3 << ListRange(5, 12);
+ QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0
+ << 13 << 0 << 3 << ListRange(0, 12);
+
+ QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0
+ << 20 << 0 << 1 << ListRange(0, 15);
+ QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 25 << 4 << 1 << ListRange(0+4, 15+4);
+ QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0
+ << 20 << 0 << 3 << ListRange(0, 15);
+ QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 25 << 4 << 3 << ListRange(0+4, 15+4);
+
+ QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0
+ << 20 << 15 << 1 << ListRange(15, 15);
+ QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 25 << 15+4 << 1 << ListRange(15+4, 15+4);
+ QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0
+ << 20 << 15 << 3 << ListRange(15, 15);
+ QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 25 << 15+4 << 3 << ListRange(15+4, 15+4);
+}
+
+void tst_QQuickListView::removeTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(bool, shouldAnimateTargets);
+ QFETCH(qreal, contentY);
+ QFETCH(int, removalIndex);
+ QFETCH(int, removalCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // added items should end here
+ QPointF targetItems_transitionTo(-50, -50);
+
+ // displaced items should pass through this points
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionTo;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ ctxt->setContextProperty("testObject", testObject);
+ canvas->setSource(testFileUrl("removeTransitions.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // only target items that are visible should be animated
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ if (shouldAnimateTargets) {
+ for (int i=removalIndex; i<removalIndex+removalCount; i++) {
+ if (i >= contentY / 20 && i < (contentY + listview->height()) / 20) {
+ expectedTargetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ }
+ QVERIFY(expectedTargetData.count() > 0);
+ }
+
+ // calculate targetItems and expectedTargets before model changes
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+ QVariantMap expectedTargets;
+ for (int i=0; i<targetIndexes.count(); i++)
+ expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
+
+ // start animation
+ model.removeItems(removalIndex, removalCount);
+ QTRY_COMPARE(model.count(), listview->count());
+
+ if (shouldAnimateTargets) {
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ QCOMPARE(listview->property("targetTrans_items").toMap(), expectedTargets);
+ matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount);
+ matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+ } else {
+ QTRY_COMPARE(model_targetItems_transitionTo.count(), 0);
+ QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ int itemCount = items.count();
+
+ for (int i=0; i<items.count(); i++) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ int index = e.evaluate().toInt();
+ if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
+ firstVisibleIndex = index;
+ if (index < 0)
+ itemCount--; // exclude deleted items
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), contentY + (i-firstVisibleIndex) * 20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::removeTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<bool>("shouldAnimateTargets");
+ QTest::addColumn<int>("removalIndex");
+ QTest::addColumn<int>("removalCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // All items that are visible following the remove operation should be animated.
+ // Remove targets that are outside of the view should not be animated.
+
+ QTest::newRow("remove 1 before start")
+ << 30 << 20.0 * 3 << false
+ << 2 << 1 << ListRange();
+ QTest::newRow("remove multiple, all before start")
+ << 30 << 20.0 * 3 << false
+ << 0 << 3 << ListRange();
+ QTest::newRow("remove mix of before and after start")
+ << 30 << 20.0 * 3 << true
+ << 2 << 3 << ListRange(5, 20); // 5-20 are visible after the remove
+
+ QTest::newRow("remove 1 from start")
+ << 30 << 0.0 << true
+ << 0 << 1 << ListRange(1, 16); // 1-16 are visible after the remove
+ QTest::newRow("remove multiple from start")
+ << 30 << 0.0 << true
+ << 0 << 3 << ListRange(3, 18); // 3-18 are visible after the remove
+ QTest::newRow("remove 1 from start, content y not 0")
+ << 30 << 20.0 * 2 << true // first visible is index 2, so translate the displaced indexes by 2
+ << 2 << 1 << ListRange(1 + 2, 16 + 2);
+ QTest::newRow("remove multiple from start, content y not 0")
+ << 30 << 20.0 * 2 << true // first visible is index 2
+ << 2 << 3 << ListRange(3 + 2, 18 + 2);
+
+ QTest::newRow("remove 1 from middle")
+ << 30 << 0.0 << true
+ << 5 << 1 << ListRange(6, 16);
+ QTest::newRow("remove multiple from middle")
+ << 30 << 0.0 << true
+ << 5 << 3 << ListRange(8, 18);
+
+
+ QTest::newRow("remove 1 from bottom")
+ << 30 << 0.0 << true
+ << 15 << 1 << ListRange(16, 16);
+
+ // remove 15, 16, 17
+ // 15 will animate as the target item, 16 & 17 won't be animated since they are outside
+ // the view, and 18 will be animated as the displaced item to replace the last item
+ QTest::newRow("remove multiple from bottom")
+ << 30 << 0.0 << true
+ << 15 << 3 << ListRange(18, 18);
+
+ QTest::newRow("remove 1 from bottom, content y not 0")
+ << 30 << 20.0 * 2 << true
+ << 15 + 2 << 1 << ListRange(16 + 2, 16 + 2);
+ QTest::newRow("remove multiple from bottom, content y not 0")
+ << 30 << 20.0 * 2 << true
+ << 15 + 2 << 3 << ListRange(18 + 2, 18 + 2);
+
+
+ QTest::newRow("remove 1 after end")
+ << 30 << 0.0 << false
+ << 17 << 1 << ListRange();
+ QTest::newRow("remove multiple after end")
+ << 30 << 0.0 << false
+ << 17 << 3 << ListRange();
+}
+
+void tst_QQuickListView::displacedTransitions()
+{
+ QFETCH(bool, useDisplaced);
+ QFETCH(bool, displacedEnabled);
+ QFETCH(bool, useAddDisplaced);
+ QFETCH(bool, addDisplacedEnabled);
+ QFETCH(bool, useMoveDisplaced);
+ QFETCH(bool, moveDisplacedEnabled);
+ QFETCH(bool, useRemoveDisplaced);
+ QFETCH(bool, removeDisplacedEnabled);
+ QFETCH(ListChange, change);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_displaced_transitionVia;
+ QaimModel model_addDisplaced_transitionVia;
+ QaimModel model_moveDisplaced_transitionVia;
+ QaimModel model_removeDisplaced_transitionVia;
+
+ QPointF displaced_transitionVia(-50, -100);
+ QPointF addDisplaced_transitionVia(-150, 100);
+ QPointF moveDisplaced_transitionVia(50, -100);
+ QPointF removeDisplaced_transitionVia(150, 100);
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject(canvas);
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia);
+ ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia);
+ ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia);
+ ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia);
+ ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia);
+ ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia);
+ ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia);
+ ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia);
+ ctxt->setContextProperty("useDisplaced", useDisplaced);
+ ctxt->setContextProperty("displacedEnabled", displacedEnabled);
+ ctxt->setContextProperty("useAddDisplaced", useAddDisplaced);
+ ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled);
+ ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced);
+ ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled);
+ ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced);
+ ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled);
+ canvas->setSource(testFileUrl("displacedTransitions.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+ listview->setProperty("displaceTransitionsDone", false);
+
+ switch (change.type) {
+ case ListChange::Inserted:
+ {
+ QList<QPair<QString, QString> > targetItemData;
+ for (int i=change.index; i<change.index + change.count; ++i)
+ targetItemData << qMakePair(QString("new item %1").arg(i), QString::number(i));
+ model.insertItems(change.index, targetItemData);
+ QTRY_COMPARE(model.count(), listview->count());
+ break;
+ }
+ case ListChange::Removed:
+ model.removeItems(change.index, change.count);
+ QTRY_COMPARE(model.count(), listview->count());
+ break;
+ case ListChange::Moved:
+ model.moveItems(change.index, change.to, change.count);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ case ListChange::SetCurrent:
+ case ListChange::SetContentY:
+ break;
+ }
+ if ((useDisplaced && displacedEnabled)
+ || (useAddDisplaced && addDisplacedEnabled)
+ || (useMoveDisplaced && moveDisplacedEnabled)
+ || (useRemoveDisplaced && removeDisplacedEnabled)) {
+ QTRY_VERIFY(listview->property("displaceTransitionsDone").toBool());
+ }
+
+ if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled)
+ model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced");
+ else
+ QCOMPARE(model_addDisplaced_transitionVia.count(), 0);
+ if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled)
+ model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced");
+ else
+ QCOMPARE(model_moveDisplaced_transitionVia.count(), 0);
+ if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled)
+ model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced");
+ else
+ QCOMPARE(model_removeDisplaced_transitionVia.count(), 0);
+
+ if (useDisplaced && displacedEnabled
+ && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled))
+ || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled))
+ || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) {
+ model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced");
+ } else {
+ QCOMPARE(model_displaced_transitionVia.count(), 0);
+ }
+
+ // verify all items moved to the correct final positions
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i < model.count() && i < items.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), i * 20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::displacedTransitions_data()
+{
+ QTest::addColumn<bool>("useDisplaced");
+ QTest::addColumn<bool>("displacedEnabled");
+ QTest::addColumn<bool>("useAddDisplaced");
+ QTest::addColumn<bool>("addDisplacedEnabled");
+ QTest::addColumn<bool>("useMoveDisplaced");
+ QTest::addColumn<bool>("moveDisplacedEnabled");
+ QTest::addColumn<bool>("useRemoveDisplaced");
+ QTest::addColumn<bool>("removeDisplacedEnabled");
+ QTest::addColumn<ListChange>("change");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("no displaced transitions at all")
+ << false << false
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("just displaced")
+ << true << true
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("just displaced (not enabled)")
+ << true << false
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("displaced + addDisplaced")
+ << true << true
+ << true << true
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("displaced + addDisplaced (not enabled)")
+ << true << true
+ << true << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("displaced + moveDisplaced")
+ << true << true
+ << false << false
+ << true << true
+ << false << false
+ << ListChange::move(0, 10, 1) << ListRange(1, 10);
+
+ QTest::newRow("displaced + moveDisplaced (not enabled)")
+ << true << true
+ << false << false
+ << true << false
+ << false << false
+ << ListChange::move(0, 10, 1) << ListRange(1, 10);
+
+ QTest::newRow("displaced + removeDisplaced")
+ << true << true
+ << false << false
+ << false << false
+ << true << true
+ << ListChange::remove(0, 1) << ListRange(1, 16);
+
+ QTest::newRow("displaced + removeDisplaced (not enabled)")
+ << true << true
+ << false << false
+ << false << false
+ << true << false
+ << ListChange::remove(0, 1) << ListRange(1, 16);
+
+
+ QTest::newRow("displaced + add, should use generic displaced for a remove")
+ << true << true
+ << true << true
+ << false << false
+ << true << false
+ << ListChange::remove(0, 1) << ListRange(1, 16);
+}
+
+void tst_QQuickListView::multipleTransitions()
+{
+ QSKIP("QTBUG-24523");
+
+ // Tests that if you interrupt a transition in progress with another action that
+ // cancels the previous transition, the resulting items are still placed correctly.
+
+ QFETCH(int, initialCount);
+ QFETCH(qreal, contentY);
+ QFETCH(QList<ListChange>, changes);
+ QFETCH(bool, rippleAddDisplaced);
+
+ QPointF addTargets_transitionFrom(-50, -50);
+ QPointF addDisplaced_transitionFrom(-50, 50);
+ QPointF moveTargets_transitionFrom(50, -50);
+ QPointF moveDisplaced_transitionFrom(50, 50);
+ QPointF removeTargets_transitionTo(-100, 300);
+ QPointF removeDisplaced_transitionFrom(100, 300);
+
+ QmlListModel model;
+ for (int i = 0; i < initialCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
+ ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
+ ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
+ ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
+ ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo);
+ ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom);
+ ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced);
+ canvas->setSource(testFileUrl("multipleTransitions.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
+
+ QList<QPair<QString, QString> > targetItems;
+ for (int i=0; i<changes.count(); i++) {
+ switch (changes[i].type) {
+ case ListChange::Inserted:
+ {
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
+ model.insertItems(changes[i].index, targetItems);
+ QTRY_COMPARE(model.count(), listview->count());
+ QTRY_VERIFY(listview->property("runningAddTargets").toBool());
+ QTRY_VERIFY(listview->property("runningAddDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!listview->property("runningAddTargets").toBool());
+ QTRY_VERIFY(!listview->property("runningAddDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ }
+ case ListChange::Removed:
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(model.name(i), model.number(i));
+ model.removeItems(changes[i].index, changes[i].count);
+ QTRY_COMPARE(model.count(), listview->count());
+ QTRY_VERIFY(listview->property("runningRemoveTargets").toBool());
+ QTRY_VERIFY(listview->property("runningRemoveDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!listview->property("runningRemoveTargets").toBool());
+ QTRY_VERIFY(!listview->property("runningRemoveDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ case ListChange::Moved:
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(model.name(i), model.number(i));
+ model.moveItems(changes[i].index, changes[i].to, changes[i].count);
+ QTRY_VERIFY(listview->property("runningMoveTargets").toBool());
+ QTRY_VERIFY(listview->property("runningMoveDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!listview->property("runningMoveTargets").toBool());
+ QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ case ListChange::SetCurrent:
+ listview->setCurrentIndex(changes[i].index);
+ break;
+ case ListChange::SetContentY:
+ listview->setContentY(changes[i].pos);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ }
+ }
+ QCOMPARE(listview->count(), model.count());
+
+ // verify all items moved to the correct final positions
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i < model.count() && i < items.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->x(), 0.0);
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::multipleTransitions_data()
+{
+ QTest::addColumn<int>("initialCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<QList<ListChange> >("changes");
+ QTest::addColumn<bool>("rippleAddDisplaced");
+
+ // the added item and displaced items should move to final dest correctly
+ QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(0, 1)
+ << ListChange::move(0, 3, 1)
+ )
+ << false;
+
+ // items affected by the add should change from move to add transition
+ QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::move(1, 10, 3)
+ << ListChange::insert(0, 1)
+ )
+ << false;
+
+ // items should be placed correctly if you trigger a transition then refill for that index
+ QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(0, 1)
+ << ListChange::setContentY(80.0)
+ << ListChange::setContentY(0.0)
+ << ListChange::insert(0, 1)
+ )
+ << false;
+
+ QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(1, 1)
+ << ListChange::remove(1, 1)
+ )
+ << true;
+}
+
+QList<int> tst_QQuickListView::toIntList(const QVariantList &list)
+{
+ QList<int> ret;
+ bool ok = true;
+ for (int i=0; i<list.count(); i++) {
+ ret << list[i].toInt(&ok);
+ if (!ok)
+ qWarning() << "tst_QQuickListView::toIntList(): not a number:" << list[i];
+ }
+
+ return ret;
+}
+
+void tst_QQuickListView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
+{
+ for (int i=0; i<indexLists.count(); i++) {
+ QSet<int> current = indexLists[i].value<QList<int> >().toSet();
+ if (current != expectedIndexes.toSet())
+ qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
+ QCOMPARE(current, expectedIndexes.toSet());
+ }
+}
+
+void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
+{
+ for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
+ QVERIFY(it.value().type() == QVariant::Int);
+ QString name = it.key();
+ int itemIndex = it.value().toInt();
+ QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
+ if (model.name(itemIndex) != name)
+ qDebug() << itemIndex;
+ QCOMPARE(model.name(itemIndex), name);
+ }
+ QCOMPARE(items.count(), expectedIndexes.count());
+}
+
+void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
+{
+ for (int i=0; i<itemLists.count(); i++) {
+ QVERIFY(itemLists[i].type() == QVariant::List);
+ QVariantList current = itemLists[i].toList();
+ for (int j=0; j<current.count(); j++) {
+ QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
+ QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
+ QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
+ }
+ QCOMPARE(current.count(), expectedItems.count());
+ }
+}
+
+
+QTEST_MAIN(tst_QQuickListView)
+
+#include "tst_qquicklistview.moc"
+
diff --git a/tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml b/tests/auto/quick/qquickloader/data/ActiveComponent.qml
index 24c6f7ad91..24c6f7ad91 100644
--- a/tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml
+++ b/tests/auto/quick/qquickloader/data/ActiveComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml b/tests/auto/quick/qquickloader/data/AnchoredLoader.qml
index 1a2a620d7f..1a2a620d7f 100644
--- a/tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml
+++ b/tests/auto/quick/qquickloader/data/AnchoredLoader.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/BigComponent.qml b/tests/auto/quick/qquickloader/data/BigComponent.qml
index df92532c43..df92532c43 100644
--- a/tests/auto/qtquick2/qquickloader/data/BigComponent.qml
+++ b/tests/auto/quick/qquickloader/data/BigComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/BlueRect.qml b/tests/auto/quick/qquickloader/data/BlueRect.qml
index e96ac00f21..e96ac00f21 100644
--- a/tests/auto/qtquick2/qquickloader/data/BlueRect.qml
+++ b/tests/auto/quick/qquickloader/data/BlueRect.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml b/tests/auto/quick/qquickloader/data/CreationContextLoader.qml
index 4dd73e797c..4dd73e797c 100644
--- a/tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml
+++ b/tests/auto/quick/qquickloader/data/CreationContextLoader.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml b/tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml
index dae8e3fbbb..dae8e3fbbb 100644
--- a/tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml
+++ b/tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/GreenRect.qml b/tests/auto/quick/qquickloader/data/GreenRect.qml
index 99cefaf176..99cefaf176 100644
--- a/tests/auto/qtquick2/qquickloader/data/GreenRect.qml
+++ b/tests/auto/quick/qquickloader/data/GreenRect.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml b/tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml
index 24c6f7ad91..24c6f7ad91 100644
--- a/tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml
+++ b/tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml b/tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml
index 7efa4a5f61..7efa4a5f61 100644
--- a/tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml
+++ b/tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/NoResize.qml b/tests/auto/quick/qquickloader/data/NoResize.qml
index 9b3ea6410b..9b3ea6410b 100644
--- a/tests/auto/qtquick2/qquickloader/data/NoResize.qml
+++ b/tests/auto/quick/qquickloader/data/NoResize.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml b/tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml
index c0f51d8c35..c0f51d8c35 100644
--- a/tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml
+++ b/tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml b/tests/auto/quick/qquickloader/data/QTBUG_16928.qml
index 903d7f0812..903d7f0812 100644
--- a/tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml
+++ b/tests/auto/quick/qquickloader/data/QTBUG_16928.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml b/tests/auto/quick/qquickloader/data/QTBUG_17114.qml
index 7402037553..7402037553 100644
--- a/tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml
+++ b/tests/auto/quick/qquickloader/data/QTBUG_17114.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/Rect120x60.qml b/tests/auto/quick/qquickloader/data/Rect120x60.qml
index fc9e447e69..fc9e447e69 100644
--- a/tests/auto/qtquick2/qquickloader/data/Rect120x60.qml
+++ b/tests/auto/quick/qquickloader/data/Rect120x60.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml b/tests/auto/quick/qquickloader/data/SetSourceComponent.qml
index 83cc358f7d..83cc358f7d 100644
--- a/tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml
+++ b/tests/auto/quick/qquickloader/data/SetSourceComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml
index 2a63b4d34f..2a63b4d34f 100644
--- a/tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml
+++ b/tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml
index a9875d8e21..a9875d8e21 100644
--- a/tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml
+++ b/tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SizeToItem.qml b/tests/auto/quick/qquickloader/data/SizeToItem.qml
index 866365754f..866365754f 100644
--- a/tests/auto/qtquick2/qquickloader/data/SizeToItem.qml
+++ b/tests/auto/quick/qquickloader/data/SizeToItem.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml b/tests/auto/quick/qquickloader/data/SizeToLoader.qml
index dad18c6939..dad18c6939 100644
--- a/tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml
+++ b/tests/auto/quick/qquickloader/data/SizeToLoader.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/VmeError.qml b/tests/auto/quick/qquickloader/data/VmeError.qml
index 0443aa9054..0443aa9054 100644
--- a/tests/auto/qtquick2/qquickloader/data/VmeError.qml
+++ b/tests/auto/quick/qquickloader/data/VmeError.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.1.qml b/tests/auto/quick/qquickloader/data/active.1.qml
index 2dbd1a0887..2dbd1a0887 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.1.qml
+++ b/tests/auto/quick/qquickloader/data/active.1.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.2.qml b/tests/auto/quick/qquickloader/data/active.2.qml
index e561744c63..e561744c63 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.2.qml
+++ b/tests/auto/quick/qquickloader/data/active.2.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.3.qml b/tests/auto/quick/qquickloader/data/active.3.qml
index 0fbba959bb..0fbba959bb 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.3.qml
+++ b/tests/auto/quick/qquickloader/data/active.3.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.4.qml b/tests/auto/quick/qquickloader/data/active.4.qml
index 63fd46e2da..63fd46e2da 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.4.qml
+++ b/tests/auto/quick/qquickloader/data/active.4.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.5.qml b/tests/auto/quick/qquickloader/data/active.5.qml
index 903f458a41..903f458a41 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.5.qml
+++ b/tests/auto/quick/qquickloader/data/active.5.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.6.qml b/tests/auto/quick/qquickloader/data/active.6.qml
index f769a4e184..f769a4e184 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.6.qml
+++ b/tests/auto/quick/qquickloader/data/active.6.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.7.qml b/tests/auto/quick/qquickloader/data/active.7.qml
index a29e932f5e..a29e932f5e 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.7.qml
+++ b/tests/auto/quick/qquickloader/data/active.7.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.8.qml b/tests/auto/quick/qquickloader/data/active.8.qml
index 3a66d3e99a..3a66d3e99a 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.8.qml
+++ b/tests/auto/quick/qquickloader/data/active.8.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/asynchronous.qml b/tests/auto/quick/qquickloader/data/asynchronous.qml
index 29570525ad..29570525ad 100644
--- a/tests/auto/qtquick2/qquickloader/data/asynchronous.qml
+++ b/tests/auto/quick/qquickloader/data/asynchronous.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/crash.qml b/tests/auto/quick/qquickloader/data/crash.qml
index e6ddc33a10..e6ddc33a10 100644
--- a/tests/auto/qtquick2/qquickloader/data/crash.qml
+++ b/tests/auto/quick/qquickloader/data/crash.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/creationContext.qml b/tests/auto/quick/qquickloader/data/creationContext.qml
index 17a596cc74..17a596cc74 100644
--- a/tests/auto/qtquick2/qquickloader/data/creationContext.qml
+++ b/tests/auto/quick/qquickloader/data/creationContext.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/differentorigin.qml b/tests/auto/quick/qquickloader/data/differentorigin.qml
index 56a3034fe0..56a3034fe0 100644
--- a/tests/auto/qtquick2/qquickloader/data/differentorigin.qml
+++ b/tests/auto/quick/qquickloader/data/differentorigin.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/implicitSize.qml b/tests/auto/quick/qquickloader/data/implicitSize.qml
index 5c8c8348ed..5c8c8348ed 100644
--- a/tests/auto/qtquick2/qquickloader/data/implicitSize.qml
+++ b/tests/auto/quick/qquickloader/data/implicitSize.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml
index ae371797ce..ae371797ce 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml
index 76c7bc2fd6..76c7bc2fd6 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml
index 3b08e6ee42..3b08e6ee42 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml
index e8310044e8..e8310044e8 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml
index 03ee599aba..03ee599aba 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml
index 66452b512b..66452b512b 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml
index 02349f7ddf..02349f7ddf 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml
index 79e9264d4a..79e9264d4a 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml
index e0df50a74a..e0df50a74a 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml
index f324dbddac..f324dbddac 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml
index 89aba313c7..89aba313c7 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml
index c862007402..c862007402 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml
index 9a80b2156d..9a80b2156d 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/nonItem.qml b/tests/auto/quick/qquickloader/data/nonItem.qml
index 8cfa0d8efb..8cfa0d8efb 100644
--- a/tests/auto/qtquick2/qquickloader/data/nonItem.qml
+++ b/tests/auto/quick/qquickloader/data/nonItem.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/parented.qml b/tests/auto/quick/qquickloader/data/parented.qml
index 1c19d4d1a5..1c19d4d1a5 100644
--- a/tests/auto/qtquick2/qquickloader/data/parented.qml
+++ b/tests/auto/quick/qquickloader/data/parented.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/qmldir b/tests/auto/quick/qquickloader/data/qmldir
index bf42b507c0..bf42b507c0 100644
--- a/tests/auto/qtquick2/qquickloader/data/qmldir
+++ b/tests/auto/quick/qquickloader/data/qmldir
diff --git a/tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml b/tests/auto/quick/qquickloader/data/sameorigin-load.qml
index 3332500be6..3332500be6 100644
--- a/tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml
+++ b/tests/auto/quick/qquickloader/data/sameorigin-load.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/sameorigin.qml b/tests/auto/quick/qquickloader/data/sameorigin.qml
index 84846b6aba..84846b6aba 100644
--- a/tests/auto/qtquick2/qquickloader/data/sameorigin.qml
+++ b/tests/auto/quick/qquickloader/data/sameorigin.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/sizebound.qml b/tests/auto/quick/qquickloader/data/sizebound.qml
index 09cf32426a..09cf32426a 100644
--- a/tests/auto/qtquick2/qquickloader/data/sizebound.qml
+++ b/tests/auto/quick/qquickloader/data/sizebound.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/vmeErrors.qml b/tests/auto/quick/qquickloader/data/vmeErrors.qml
index 8e6c89dc8e..8e6c89dc8e 100644
--- a/tests/auto/qtquick2/qquickloader/data/vmeErrors.qml
+++ b/tests/auto/quick/qquickloader/data/vmeErrors.qml
diff --git a/tests/auto/quick/qquickloader/qquickloader.pro b/tests/auto/quick/qquickloader/qquickloader.pro
new file mode 100644
index 0000000000..fd525351ab
--- /dev/null
+++ b/tests/auto/quick/qquickloader/qquickloader.pro
@@ -0,0 +1,19 @@
+CONFIG += testcase
+TARGET = tst_qquickloader
+macx:CONFIG -= app_bundle
+
+INCLUDEPATH += ../../shared/
+HEADERS += ../../shared/testhttpserver.h
+
+SOURCES += tst_qquickloader.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
new file mode 100644
index 0000000000..77d0c29220
--- /dev/null
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -0,0 +1,987 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+
+#include <QSignalSpy>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlincubator.h>
+#include <private/qquickloader_p.h>
+#include "testhttpserver.h"
+#include "../../shared/util.h"
+
+#define SERVER_PORT 14450
+
+class PeriodicIncubationController : public QObject,
+ public QQmlIncubationController
+{
+public:
+ PeriodicIncubationController() {
+ startTimer(16);
+ }
+
+protected:
+ virtual void timerEvent(QTimerEvent *) {
+ incubateFor(15);
+ }
+};
+
+class tst_QQuickLoader : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_QQuickLoader();
+
+private slots:
+ void sourceOrComponent();
+ void sourceOrComponent_data();
+ void clear();
+ void urlToComponent();
+ void componentToUrl();
+ void anchoredLoader();
+ void sizeLoaderToItem();
+ void sizeItemToLoader();
+ void noResize();
+ void networkRequestUrl();
+ void failNetworkRequest();
+// void networkComponent();
+ void active();
+ void initialPropertyValues_data();
+ void initialPropertyValues();
+ void initialPropertyValuesBinding();
+ void initialPropertyValuesError_data();
+ void initialPropertyValuesError();
+
+ void deleteComponentCrash();
+ void nonItem();
+ void vmeErrors();
+ void creationContext();
+ void QTBUG_16928();
+ void implicitSize();
+ void QTBUG_17114();
+ void asynchronous_data();
+ void asynchronous();
+ void asynchronous_clear();
+
+ void parented();
+ void sizeBound();
+
+private:
+ QQmlEngine engine;
+};
+
+
+tst_QQuickLoader::tst_QQuickLoader()
+{
+}
+
+void tst_QQuickLoader::sourceOrComponent()
+{
+ QFETCH(QString, sourceOrComponent);
+ QFETCH(QString, sourceDefinition);
+ QFETCH(QUrl, sourceUrl);
+ QFETCH(QString, errorString);
+
+ bool error = !errorString.isEmpty();
+ if (error)
+ QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData());
+
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ "Loader {\n"
+ " property int onItemChangedCount: 0\n"
+ " property int onSourceChangedCount: 0\n"
+ " property int onSourceComponentChangedCount: 0\n"
+ " property int onStatusChangedCount: 0\n"
+ " property int onProgressChangedCount: 0\n"
+ " property int onLoadedCount: 0\n")
+ + sourceDefinition.toUtf8()
+ + QByteArray(
+ " onItemChanged: onItemChangedCount += 1\n"
+ " onSourceChanged: onSourceChangedCount += 1\n"
+ " onSourceComponentChanged: onSourceComponentChangedCount += 1\n"
+ " onStatusChanged: onStatusChangedCount += 1\n"
+ " onProgressChanged: onProgressChangedCount += 1\n"
+ " onLoaded: onLoadedCount += 1\n"
+ "}")
+ , dataDirectoryUrl());
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->item() == 0, error);
+ QCOMPARE(loader->source(), sourceUrl);
+ QCOMPARE(loader->progress(), 1.0);
+
+ QCOMPARE(loader->status(), error ? QQuickLoader::Error : QQuickLoader::Ready);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), error ? 0: 1);
+
+ if (!error) {
+ bool sourceComponentIsChildOfLoader = false;
+ for (int ii = 0; ii < loader->children().size(); ++ii) {
+ QQmlComponent *c = qobject_cast<QQmlComponent*>(loader->children().at(ii));
+ if (c && c == loader->sourceComponent()) {
+ sourceComponentIsChildOfLoader = true;
+ }
+ }
+ QVERIFY(sourceComponentIsChildOfLoader);
+ }
+
+ if (sourceOrComponent == "component") {
+ QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 1);
+ QCOMPARE(loader->property("onSourceChangedCount").toInt(), 0);
+ } else {
+ QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 0);
+ QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1);
+ }
+ QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1);
+ QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1);
+
+ QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1);
+ QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::sourceOrComponent_data()
+{
+ QTest::addColumn<QString>("sourceOrComponent");
+ QTest::addColumn<QString>("sourceDefinition");
+ QTest::addColumn<QUrl>("sourceUrl");
+ QTest::addColumn<QString>("errorString");
+
+ QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << "";
+ QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
+ QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml")
+ << QString(testFileUrl("IDontExist.qml").toString() + ": File not found");
+}
+
+void tst_QQuickLoader::clear()
+{
+ {
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ " Loader { id: loader\n"
+ " source: 'Rect120x60.qml'\n"
+ " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
+ " }")
+ , dataDirectoryUrl());
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ QTRY_VERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ delete loader;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ loader->setSourceComponent(0);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ delete item;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ QMetaObject::invokeMethod(item, "clear");
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ delete item;
+ }
+}
+
+void tst_QQuickLoader::urlToComponent()
+{
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\n"
+ "Loader {\n"
+ " id: loader\n"
+ " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n"
+ " source: \"Rect120x60.qml\"\n"
+ " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n"
+ "}" )
+ , dataDirectoryUrl());
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QTest::qWait(200);
+ QTRY_VERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(loader->width(), 10.0);
+ QCOMPARE(loader->height(), 10.0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::componentToUrl()
+{
+ QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ loader->setSource(testFileUrl("/Rect120x60.qml"));
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ delete item;
+}
+
+void tst_QQuickLoader::anchoredLoader()
+{
+ QQmlComponent component(&engine, testFileUrl("/AnchoredLoader.qml"));
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootItem != 0);
+ QQuickItem *loader = rootItem->findChild<QQuickItem*>("loader");
+ QQuickItem *sourceElement = rootItem->findChild<QQuickItem*>("sourceElement");
+
+ QVERIFY(loader != 0);
+ QVERIFY(sourceElement != 0);
+
+ QCOMPARE(rootItem->width(), 300.0);
+ QCOMPARE(rootItem->height(), 200.0);
+
+ QCOMPARE(loader->width(), 300.0);
+ QCOMPARE(loader->height(), 200.0);
+
+ QCOMPARE(sourceElement->width(), 300.0);
+ QCOMPARE(sourceElement->height(), 200.0);
+}
+
+void tst_QQuickLoader::sizeLoaderToItem()
+{
+ QQmlComponent component(&engine, testFileUrl("/SizeToItem.qml"));
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ // Check resize
+ QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item());
+ QVERIFY(rect);
+ rect->setWidth(150);
+ rect->setHeight(45);
+ QCOMPARE(loader->width(), 150.0);
+ QCOMPARE(loader->height(), 45.0);
+
+ // Check explicit width
+ loader->setWidth(200.0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(rect->width(), 200.0);
+ rect->setWidth(100.0); // when rect changes ...
+ QCOMPARE(rect->width(), 100.0); // ... it changes
+ QCOMPARE(loader->width(), 200.0); // ... but loader stays the same
+
+ // Check explicit height
+ loader->setHeight(200.0);
+ QCOMPARE(loader->height(), 200.0);
+ QCOMPARE(rect->height(), 200.0);
+ rect->setHeight(100.0); // when rect changes ...
+ QCOMPARE(rect->height(), 100.0); // ... it changes
+ QCOMPARE(loader->height(), 200.0); // ... but loader stays the same
+
+ // Switch mode
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(rect->width(), 180.0);
+ QCOMPARE(rect->height(), 30.0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::sizeItemToLoader()
+{
+ QQmlComponent component(&engine, testFileUrl("/SizeToLoader.qml"));
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item());
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 200.0);
+ QCOMPARE(rect->height(), 80.0);
+
+ // Check resize
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(rect->width(), 180.0);
+ QCOMPARE(rect->height(), 30.0);
+
+ // Switch mode
+ loader->resetWidth(); // reset explicit size
+ loader->resetHeight();
+ rect->setWidth(160);
+ rect->setHeight(45);
+ QCOMPARE(loader->width(), 160.0);
+ QCOMPARE(loader->height(), 45.0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::noResize()
+{
+ QQmlComponent component(&engine, testFileUrl("/NoResize.qml"));
+ QQuickItem* item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item != 0);
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 80.0);
+
+ delete item;
+}
+
+void tst_QQuickLoader::networkRequestUrl()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml"));
+ if (component.isError())
+ qDebug() << component.errors();
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+
+ QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
+
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->property("signalCount").toInt(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ delete loader;
+}
+
+/* XXX Component waits until all dependencies are loaded. Is this actually possible?
+void tst_QQuickLoader::networkComponent()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory("slowdata", TestHTTPServer::Delay);
+
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ "import \"http://127.0.0.1:14450/\" as NW\n"
+ "Item {\n"
+ " Component { id: comp; NW.SlowRect {} }\n"
+ " Loader { sourceComponent: comp } }")
+ , dataDirectoryUrl());
+
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::children().at(1));
+ QVERIFY(loader);
+ QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
+
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+*/
+
+void tst_QQuickLoader::failNetworkRequest()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
+
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml"));
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+
+ QTRY_VERIFY(loader->status() == QQuickLoader::Error);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->property("did_load").toInt(), 123);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::active()
+{
+ // check that the item isn't instantiated until active is set to true
+ {
+ QQmlComponent component(&engine, testFileUrl("active.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == false); // set manually to false
+ QVERIFY(loader->item() == 0);
+ QMetaObject::invokeMethod(object, "doSetSourceComponent");
+ QVERIFY(loader->item() == 0);
+ QMetaObject::invokeMethod(object, "doSetSource");
+ QVERIFY(loader->item() == 0);
+ QMetaObject::invokeMethod(object, "doSetActive");
+ QVERIFY(loader->item() != 0);
+
+ delete object;
+ }
+
+ // check that the status is Null if active is set to false
+ {
+ QQmlComponent component(&engine, testFileUrl("active.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ int currStatusChangedCount = loader->property("statusChangedCount").toInt();
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(loader->property("statusChangedCount").toInt(), (currStatusChangedCount+1));
+
+ delete object;
+ }
+
+ // check that the source is not cleared if active is set to false
+ {
+ QQmlComponent component(&engine, testFileUrl("active.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ QVERIFY(!loader->source().isEmpty());
+ int currSourceChangedCount = loader->property("sourceChangedCount").toInt();
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QVERIFY(!loader->source().isEmpty());
+ QCOMPARE(loader->property("sourceChangedCount").toInt(), currSourceChangedCount);
+
+ delete object;
+ }
+
+ // check that the sourceComponent is not cleared if active is set to false
+ {
+ QQmlComponent component(&engine, testFileUrl("active.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ QVERIFY(loader->sourceComponent() != 0);
+ int currSourceComponentChangedCount = loader->property("sourceComponentChangedCount").toInt();
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QVERIFY(loader->sourceComponent() != 0);
+ QCOMPARE(loader->property("sourceComponentChangedCount").toInt(), currSourceComponentChangedCount);
+
+ delete object;
+ }
+
+ // check that the item is released if active is set to false
+ {
+ QQmlComponent component(&engine, testFileUrl("active.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ QVERIFY(loader->item() != 0);
+ int currItemChangedCount = loader->property("itemChangedCount").toInt();
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->property("itemChangedCount").toInt(), (currItemChangedCount+1));
+
+ delete object;
+ }
+
+ // check that the activeChanged signal is emitted correctly
+ {
+ QQmlComponent component(&engine, testFileUrl("active.6.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ loader->setActive(true); // no effect
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 0);
+ loader->setActive(false); // change signal should be emitted
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 1);
+ loader->setActive(false); // no effect
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 1);
+ loader->setActive(true); // change signal should be emitted
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 2);
+ loader->setActive(false); // change signal should be emitted
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 3);
+ QMetaObject::invokeMethod(object, "doSetActive");
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 4);
+ QMetaObject::invokeMethod(object, "doSetActive");
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 4);
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 5);
+ loader->setActive(true); // change signal should be emitted
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 6);
+
+ delete object;
+ }
+
+ // check that the component isn't loaded until active is set to true
+ {
+ QQmlComponent component(&engine, testFileUrl("active.7.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("success").toBool(), true);
+ delete object;
+ }
+
+ // check that the component is loaded if active is not set (true by default)
+ {
+ QQmlComponent component(&engine, testFileUrl("active.8.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("success").toBool(), true);
+ delete object;
+ }
+}
+
+void tst_QQuickLoader::initialPropertyValues_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QStringList>("expectedWarnings");
+ QTest::addColumn<QStringList>("propertyNames");
+ QTest::addColumn<QVariantList>("propertyValues");
+
+ QTest::newRow("source url with value set in onLoaded, initially active = true") << testFileUrl("initialPropertyValues.1.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 1 << 1);
+
+ QTest::newRow("set source with initial property values specified, active = true") << testFileUrl("initialPropertyValues.2.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 2 << 0);
+
+ QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml")
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null")))
+ << (QStringList())
+ << (QVariantList());
+
+ QTest::newRow("set source with initial property values specified, active = false, with active set true later") << testFileUrl("initialPropertyValues.4.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 4 << 0);
+
+ QTest::newRow("set source without initial property values specified, active = true") << testFileUrl("initialPropertyValues.5.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 0 << 0);
+
+ QTest::newRow("set source with initial property values specified with binding, active = true") << testFileUrl("initialPropertyValues.6.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 6 << 0);
+
+ QTest::newRow("ensure initial property value semantics mimic createObject") << testFileUrl("initialPropertyValues.7.qml")
+ << QStringList()
+ << (QStringList() << "loaderValue" << "createObjectValue")
+ << (QVariantList() << 1 << 1);
+
+ QTest::newRow("ensure initial property values aren't disposed prior to component completion") << testFileUrl("initialPropertyValues.8.qml")
+ << QStringList()
+ << (QStringList() << "initialValue")
+ << (QVariantList() << 6);
+}
+
+void tst_QQuickLoader::initialPropertyValues()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QStringList, expectedWarnings);
+ QFETCH(QStringList, propertyNames);
+ QFETCH(QVariantList, propertyValues);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ foreach (const QString &warning, expectedWarnings)
+ QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
+
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ qApp->processEvents();
+ QTest::qWait(50);
+
+ for (int i = 0; i < propertyNames.size(); ++i)
+ QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i));
+
+ delete object;
+}
+
+void tst_QQuickLoader::initialPropertyValuesBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("initialPropertyValues.binding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->setProperty("bindable", QVariant(8)));
+ QCOMPARE(object->property("canaryValue").toInt(), 8);
+
+ delete object;
+}
+
+void tst_QQuickLoader::initialPropertyValuesError_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QStringList>("expectedWarnings");
+
+ QTest::newRow("invalid initial property values object") << testFileUrl("initialPropertyValues.error.1.qml")
+ << (QStringList() << QString(testFileUrl("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object"));
+
+ QTest::newRow("nonexistent source url") << testFileUrl("initialPropertyValues.error.2.qml")
+ << (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": File not found"));
+
+ QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml")
+ << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
+
+ QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml")
+ << (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object")
+ << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null"));
+}
+
+void tst_QQuickLoader::initialPropertyValuesError()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QStringList, expectedWarnings);
+
+ foreach (const QString &warning, expectedWarnings)
+ QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData());
+
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item() == 0);
+ delete object;
+}
+
+// QTBUG-9241
+void tst_QQuickLoader::deleteComponentCrash()
+{
+ QQmlComponent component(&engine, testFileUrl("crash.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ item->metaObject()->invokeMethod(item, "setLoaderSource");
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->item()->objectName(), QLatin1String("blue"));
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QVERIFY(loader->source() == testFileUrl("BlueRect.qml"));
+
+ delete item;
+}
+
+void tst_QQuickLoader::nonItem()
+{
+ QQmlComponent component(&engine, testFileUrl("nonItem.qml"));
+ QString err = testFileUrl("nonItem.qml").toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements.";
+
+ QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader);
+ QVERIFY(loader->item() == 0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::vmeErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("vmeErrors.qml"));
+ QString err = testFileUrl("VmeError.qml").toString() + ":6: Cannot assign object type QObject with no default method";
+ QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader);
+ QVERIFY(loader->item() == 0);
+
+ delete loader;
+}
+
+// QTBUG-13481
+void tst_QQuickLoader::creationContext()
+{
+ QQmlComponent component(&engine, testFileUrl("creationContext.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+}
+
+void tst_QQuickLoader::QTBUG_16928()
+{
+ QQmlComponent component(&engine, testFileUrl("QTBUG_16928.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QCOMPARE(item->width(), 250.);
+ QCOMPARE(item->height(), 250.);
+
+ delete item;
+}
+
+void tst_QQuickLoader::implicitSize()
+{
+ QQmlComponent component(&engine, testFileUrl("implicitSize.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QCOMPARE(item->width(), 150.);
+ QCOMPARE(item->height(), 150.);
+
+ QCOMPARE(item->property("implHeight").toReal(), 100.);
+ QCOMPARE(item->property("implWidth").toReal(), 100.);
+
+ delete item;
+}
+
+void tst_QQuickLoader::QTBUG_17114()
+{
+ QQmlComponent component(&engine, testFileUrl("QTBUG_17114.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QCOMPARE(item->property("loaderWidth").toReal(), 32.);
+ QCOMPARE(item->property("loaderHeight").toReal(), 32.);
+
+ delete item;
+}
+
+void tst_QQuickLoader::asynchronous_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QStringList>("expectedWarnings");
+
+ QTest::newRow("Valid component") << testFileUrl("BigComponent.qml")
+ << QStringList();
+
+ QTest::newRow("Non-existant component") << testFileUrl("IDoNotExist.qml")
+ << (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": File not found"));
+
+ QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml")
+ << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
+}
+
+void tst_QQuickLoader::asynchronous()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QStringList, expectedWarnings);
+
+ if (!engine.incubationController())
+ engine.setIncubationController(new PeriodicIncubationController);
+ QQmlComponent component(&engine, testFileUrl("asynchronous.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+
+ QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader);
+
+ foreach (const QString &warning, expectedWarnings)
+ QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData());
+
+ QVERIFY(!loader->item());
+ root->setProperty("comp", qmlFile.toString());
+ QMetaObject::invokeMethod(root, "loadComponent");
+ QVERIFY(!loader->item());
+
+ if (expectedWarnings.isEmpty()) {
+ QCOMPARE(loader->status(), QQuickLoader::Loading);
+ QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
+
+ QTRY_VERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ } else {
+ QCOMPARE(loader->progress(), 1.0);
+ QTRY_COMPARE(loader->status(), QQuickLoader::Error);
+ }
+
+ delete root;
+}
+
+void tst_QQuickLoader::asynchronous_clear()
+{
+ if (!engine.incubationController())
+ engine.setIncubationController(new PeriodicIncubationController);
+ QQmlComponent component(&engine, testFileUrl("asynchronous.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+
+ QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader);
+
+ QVERIFY(!loader->item());
+ root->setProperty("comp", "BigComponent.qml");
+ QMetaObject::invokeMethod(root, "loadComponent");
+ QVERIFY(!loader->item());
+
+ QCOMPARE(loader->status(), QQuickLoader::Loading);
+ QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
+
+ // clear before component created
+ root->setProperty("comp", "");
+ QMetaObject::invokeMethod(root, "loadComponent");
+ QVERIFY(!loader->item());
+ QCOMPARE(engine.incubationController()->incubatingObjectCount(), 0);
+
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ // check loading component
+ root->setProperty("comp", "Rect120x60.qml");
+ QMetaObject::invokeMethod(root, "loadComponent");
+ QVERIFY(!loader->item());
+
+ QCOMPARE(loader->status(), QQuickLoader::Loading);
+ QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
+
+ QTRY_VERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+}
+
+void tst_QQuickLoader::parented()
+{
+ QQmlComponent component(&engine, testFileUrl("parented.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+
+ QQuickItem *item = root->findChild<QQuickItem*>("comp");
+ QVERIFY(item);
+
+ QVERIFY(item->parentItem() == root);
+
+ QCOMPARE(item->width(), 300.);
+ QCOMPARE(item->height(), 300.);
+
+ delete root;
+}
+
+void tst_QQuickLoader::sizeBound()
+{
+ QQmlComponent component(&engine, testFileUrl("sizebound.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+ QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader != 0);
+
+ QVERIFY(loader->item());
+
+ QCOMPARE(loader->width(), 50.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ QMetaObject::invokeMethod(root, "switchComponent");
+
+ QCOMPARE(loader->width(), 80.0);
+ QCOMPARE(loader->height(), 90.0);
+
+ delete root;
+}
+
+
+QTEST_MAIN(tst_QQuickLoader)
+
+#include "tst_qquickloader.moc"
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml b/tests/auto/quick/qquickmousearea/data/clickThrough.qml
index 3c03161faa..3c03161faa 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml
+++ b/tests/auto/quick/qquickmousearea/data/clickThrough.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml b/tests/auto/quick/qquickmousearea/data/clickThrough2.qml
index 2624108225..2624108225 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml
+++ b/tests/auto/quick/qquickmousearea/data/clickThrough2.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml b/tests/auto/quick/qquickmousearea/data/clickandhold.qml
index 5e4e48f6db..5e4e48f6db 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml
+++ b/tests/auto/quick/qquickmousearea/data/clickandhold.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml b/tests/auto/quick/qquickmousearea/data/clicktwice.qml
index 002d1b9047..002d1b9047 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml
+++ b/tests/auto/quick/qquickmousearea/data/clicktwice.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml b/tests/auto/quick/qquickmousearea/data/doubleclick.qml
index 1030d0c33e..1030d0c33e 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml
+++ b/tests/auto/quick/qquickmousearea/data/doubleclick.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragging.qml b/tests/auto/quick/qquickmousearea/data/dragging.qml
index d9b6ac4083..d9b6ac4083 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/dragging.qml
+++ b/tests/auto/quick/qquickmousearea/data/dragging.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml b/tests/auto/quick/qquickmousearea/data/dragproperties.qml
index 421dfe26b7..421dfe26b7 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml
+++ b/tests/auto/quick/qquickmousearea/data/dragproperties.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml b/tests/auto/quick/qquickmousearea/data/dragreset.qml
index d7949f9139..d7949f9139 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml
+++ b/tests/auto/quick/qquickmousearea/data/dragreset.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml b/tests/auto/quick/qquickmousearea/data/hoverPosition.qml
index 834f91ff29..834f91ff29 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml
+++ b/tests/auto/quick/qquickmousearea/data/hoverPosition.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml b/tests/auto/quick/qquickmousearea/data/hoverPropagation.qml
index c47c794132..c47c794132 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml
+++ b/tests/auto/quick/qquickmousearea/data/hoverPropagation.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml b/tests/auto/quick/qquickmousearea/data/hoverVisible.qml
index 2d65b5573e..2d65b5573e 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml
+++ b/tests/auto/quick/qquickmousearea/data/hoverVisible.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml b/tests/auto/quick/qquickmousearea/data/noclickandhold.qml
index 6647de001d..6647de001d 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml
+++ b/tests/auto/quick/qquickmousearea/data/noclickandhold.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml b/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml
index 231436d0f2..231436d0f2 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml
+++ b/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml b/tests/auto/quick/qquickmousearea/data/pressedOrdering.qml
index 7aa3098100..7aa3098100 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml
+++ b/tests/auto/quick/qquickmousearea/data/pressedOrdering.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml b/tests/auto/quick/qquickmousearea/data/preventstealing.qml
index fb0d6955c1..fb0d6955c1 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml
+++ b/tests/auto/quick/qquickmousearea/data/preventstealing.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml b/tests/auto/quick/qquickmousearea/data/rejectEvent.qml
index 816fc76fac..816fc76fac 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml
+++ b/tests/auto/quick/qquickmousearea/data/rejectEvent.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml b/tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml
index 7377a2e86c..7377a2e86c 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml
+++ b/tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml b/tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml
index 55af864060..55af864060 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml
+++ b/tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml
diff --git a/tests/auto/quick/qquickmousearea/qquickmousearea.pro b/tests/auto/quick/qquickmousearea/qquickmousearea.pro
new file mode 100644
index 0000000000..c75db5ea55
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/qquickmousearea.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickmousearea
+macx:CONFIG -= app_bundle
+
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickmousearea.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
new file mode 100644
index 0000000000..0fb82a66bc
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -0,0 +1,806 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <QtQuick/private/qquickmousearea_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qquickflickable_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlengine.h>
+#include <QtOpenGL/QGLShaderProgram>
+#include "../../shared/util.h"
+
+//#define OLDWAY
+
+class tst_QQuickMouseArea: public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void dragProperties();
+ void resetDrag();
+ void dragging();
+ void updateMouseAreaPosOnClick();
+ void updateMouseAreaPosOnResize();
+ void noOnClickedWithPressAndHold();
+ void onMousePressRejected();
+ void pressedCanceledOnWindowDeactivate();
+ void doubleClick();
+ void clickTwice();
+ void pressedOrdering();
+ void preventStealing();
+ void clickThrough();
+ void hoverPosition();
+ void hoverPropagation();
+ void hoverVisible();
+
+private:
+ QQuickView *createView();
+};
+
+void tst_QQuickMouseArea::dragProperties()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("dragproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+ QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
+ drag->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+ drag->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+
+ // axis
+ QCOMPARE(drag->axis(), QQuickDrag::XandYAxis);
+ QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
+ drag->setAxis(QQuickDrag::XAxis);
+ QCOMPARE(drag->axis(), QQuickDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+ drag->setAxis(QQuickDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+
+ // minimum and maximum properties
+ QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
+ QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged()));
+ QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged()));
+ QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged()));
+
+ QCOMPARE(drag->xmin(), 0.0);
+ QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width());
+ QCOMPARE(drag->ymin(), 0.0);
+ QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height());
+
+ drag->setXmin(10);
+ drag->setXmax(10);
+ drag->setYmin(10);
+ drag->setYmax(10);
+
+ QCOMPARE(drag->xmin(), 10.0);
+ QCOMPARE(drag->xmax(), 10.0);
+ QCOMPARE(drag->ymin(), 10.0);
+ QCOMPARE(drag->ymax(), 10.0);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ drag->setXmin(10);
+ drag->setXmax(10);
+ drag->setYmin(10);
+ drag->setYmax(10);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ // filterChildren
+ QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged()));
+
+ drag->setFilterChildren(true);
+
+ QVERIFY(drag->filterChildren());
+ QCOMPARE(filterChildrenSpy.count(), 1);
+
+ drag->setFilterChildren(true);
+ QCOMPARE(filterChildrenSpy.count(), 1);
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::resetDrag()
+{
+ QQuickView *canvas = createView();
+
+ canvas->rootContext()->setContextProperty("haveTarget", QVariant(true));
+ canvas->setSource(testFileUrl("dragreset.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+ QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
+ QVERIFY(drag->target() != 0);
+ canvas->rootContext()->setContextProperty("haveTarget", QVariant(false));
+ QCOMPARE(targetSpy.count(),1);
+ QVERIFY(drag->target() == 0);
+
+ delete canvas;
+}
+
+
+void tst_QQuickMouseArea::dragging()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("dragging.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWait(20);
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+
+ QVERIFY(!drag->active());
+
+#ifdef OLDWAY
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+#else
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+#endif
+
+ QVERIFY(!drag->active());
+ QCOMPARE(blackRect->x(), 50.0);
+ QCOMPARE(blackRect->y(), 50.0);
+
+ // First move event triggers drag, second is acted upon.
+ // This is due to possibility of higher stacked area taking precedence.
+
+ QTest::mouseMove(canvas, QPoint(111,111));
+ QTest::qWait(50);
+ QTest::mouseMove(canvas, QPoint(122,122));
+ QTest::qWait(50);
+
+ QVERIFY(drag->active());
+ QCOMPARE(blackRect->x(), 72.0);
+ QCOMPARE(blackRect->y(), 72.0);
+
+#ifdef OLDWAY
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+#else
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(122,122));
+ QTest::qWait(50);
+#endif
+
+ QVERIFY(!drag->active());
+ QCOMPARE(blackRect->x(), 72.0);
+ QCOMPARE(blackRect->y(), 72.0);
+
+ delete canvas;
+}
+
+QQuickView *tst_QQuickMouseArea::createView()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ return canvas;
+}
+
+void tst_QQuickMouseArea::updateMouseAreaPosOnClick()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("updateMousePosOnClick.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QVERIFY(mouseRegion != 0);
+
+ QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("ball");
+ QVERIFY(rect != 0);
+
+ QCOMPARE(mouseRegion->mouseX(), rect->x());
+ QCOMPARE(mouseRegion->mouseY(), rect->y());
+
+ QMouseEvent event(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &event);
+
+ QCOMPARE(mouseRegion->mouseX(), 100.0);
+ QCOMPARE(mouseRegion->mouseY(), 100.0);
+
+ QCOMPARE(mouseRegion->mouseX(), rect->x());
+ QCOMPARE(mouseRegion->mouseY(), rect->y());
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::updateMouseAreaPosOnResize()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("updateMousePosOnResize.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QVERIFY(mouseRegion != 0);
+
+ QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("brother");
+ QVERIFY(rect != 0);
+
+ QCOMPARE(mouseRegion->mouseX(), 0.0);
+ QCOMPARE(mouseRegion->mouseY(), 0.0);
+
+ QMouseEvent event(QEvent::MouseButtonPress, rect->pos().toPoint(), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &event);
+
+ QVERIFY(!mouseRegion->property("emitPositionChanged").toBool());
+ QVERIFY(mouseRegion->property("mouseMatchesPos").toBool());
+
+ QCOMPARE(mouseRegion->property("x1").toReal(), 0.0);
+ QCOMPARE(mouseRegion->property("y1").toReal(), 0.0);
+
+ QCOMPARE(mouseRegion->property("x2").toReal(), rect->x());
+ QCOMPARE(mouseRegion->property("y2").toReal(), rect->y());
+
+ QCOMPARE(mouseRegion->mouseX(), rect->x());
+ QCOMPARE(mouseRegion->mouseY(), rect->y());
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::noOnClickedWithPressAndHold()
+{
+ {
+ // We handle onPressAndHold, therefore no onClicked
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("clickandhold.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QVERIFY(!canvas->rootObject()->property("clicked").toBool());
+ QVERIFY(!canvas->rootObject()->property("held").toBool());
+
+ QTest::qWait(1000);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QVERIFY(!canvas->rootObject()->property("clicked").toBool());
+ QVERIFY(canvas->rootObject()->property("held").toBool());
+
+ delete canvas;
+ }
+
+ {
+ // We do not handle onPressAndHold, therefore we get onClicked
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("noclickandhold.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QVERIFY(!canvas->rootObject()->property("clicked").toBool());
+
+ QTest::qWait(1000);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QVERIFY(canvas->rootObject()->property("clicked").toBool());
+
+ delete canvas;
+ }
+}
+
+void tst_QQuickMouseArea::onMousePressRejected()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("rejectEvent.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+ QVERIFY(canvas->rootObject()->property("enabled").toBool());
+
+ QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool());
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+ QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool());
+
+ QTest::qWait(200);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QVERIFY(canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+
+ delete canvas;
+}
+void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pressedCanceled.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+ QVERIFY(!canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("released").toBool());
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QVERIFY(canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("released").toBool());
+
+ QTest::qWait(200);
+
+ QEvent windowDeactivateEvent(QEvent::WindowDeactivate);
+ QGuiApplication::sendEvent(canvas, &windowDeactivateEvent);
+ QVERIFY(!canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("released").toBool());
+
+ QTest::qWait(200);
+
+ //press again
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+ QVERIFY(canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("released").toBool());
+
+ QTest::qWait(200);
+
+ //release
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+ QVERIFY(!canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(canvas->rootObject()->property("released").toBool());
+
+ delete canvas;
+}
+void tst_QQuickMouseArea::doubleClick()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("doubleclick.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
+
+ pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
+
+ delete canvas;
+}
+
+// QTBUG-14832
+void tst_QQuickMouseArea::clickTwice()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("clicktwice.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
+
+ pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2);
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::pressedOrdering()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pressedOrdering.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base"));
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled"));
+
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::preventStealing()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("preventstealing.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ QQuickMouseArea *mouseArea = canvas->rootObject()->findChild<QQuickMouseArea*>("mousearea");
+ QVERIFY(mouseArea != 0);
+
+ QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QQuickMouseEvent*)));
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80));
+
+ // Without preventStealing, mouse movement over MouseArea would
+ // cause the Flickable to steal mouse and trigger content movement.
+
+ QTest::mouseMove(canvas,QPoint(69,69));
+ QTest::mouseMove(canvas,QPoint(58,58));
+ QTest::mouseMove(canvas,QPoint(47,47));
+
+ // We should have received all three move events
+ QCOMPARE(mousePositionSpy.count(), 3);
+ QVERIFY(mouseArea->pressed());
+
+ // Flickable content should not have moved.
+ QCOMPARE(flickable->contentX(), 0.);
+ QCOMPARE(flickable->contentY(), 0.);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(47, 47));
+
+ // Now allow stealing and confirm Flickable does its thing.
+ canvas->rootObject()->setProperty("stealing", false);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80));
+
+ // Without preventStealing, mouse movement over MouseArea would
+ // cause the Flickable to steal mouse and trigger content movement.
+
+ QTest::mouseMove(canvas,QPoint(69,69));
+ QTest::mouseMove(canvas,QPoint(58,58));
+ QTest::mouseMove(canvas,QPoint(47,47));
+
+ // We should only have received the first move event
+ QCOMPARE(mousePositionSpy.count(), 4);
+ // Our press should be taken away
+ QVERIFY(!mouseArea->pressed());
+
+ // Flickable content should have moved.
+
+ QCOMPARE(flickable->contentX(), 11.);
+ QCOMPARE(flickable->contentY(), 11.);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 50));
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::clickThrough()
+{
+ QSKIP("QTBUG-23976 Unstable");
+ //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("clickThrough.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
+
+ QTest::qWait(800); // to avoid generating a double click.
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(1000);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
+ QTRY_COMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
+ QTRY_COMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ delete canvas;
+
+ //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored
+ canvas = createView();
+ canvas->setSource(testFileUrl("clickThrough2.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
+
+ QTest::qWait(800); // to avoid generating a double click.
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(1000);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0);
+
+ QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0);
+
+ canvas->rootObject()->setProperty("letThrough", QVariant(true));
+
+ QTest::qWait(800); // to avoid generating a double click.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
+
+ QTest::qWait(800); // to avoid generating a double click.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(1000);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ canvas->rootObject()->setProperty("noPropagation", QVariant(true));
+
+ QTest::qWait(800); // to avoid generating a double click.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QTest::qWait(800); // to avoid generating a double click.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(1000);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::hoverPosition()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("hoverPosition.qml"));
+
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+
+ QCOMPARE(root->property("mouseX").toReal(), qreal(0));
+ QCOMPARE(root->property("mouseY").toReal(), qreal(0));
+
+ QTest::mouseMove(canvas,QPoint(10,32));
+
+
+ QCOMPARE(root->property("mouseX").toReal(), qreal(10));
+ QCOMPARE(root->property("mouseY").toReal(), qreal(32));
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::hoverPropagation()
+{
+ //QTBUG-18175, to behave like GV did.
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("hoverPropagation.qml"));
+
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+
+ QCOMPARE(root->property("point1").toBool(), false);
+ QCOMPARE(root->property("point2").toBool(), false);
+
+ QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0);
+ QGuiApplication::sendEvent(canvas, &moveEvent);
+
+ QCOMPARE(root->property("point1").toBool(), true);
+ QCOMPARE(root->property("point2").toBool(), false);
+
+ QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0);
+ QGuiApplication::sendEvent(canvas, &moveEvent2);
+ QCOMPARE(root->property("point1").toBool(), false);
+ QCOMPARE(root->property("point2").toBool(), true);
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::hoverVisible()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("hoverVisible.qml"));
+
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+
+ QQuickMouseArea *mouseTracker = canvas->rootObject()->findChild<QQuickMouseArea*>("mousetracker");
+ QVERIFY(mouseTracker != 0);
+
+ QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered()));
+
+ QTest::mouseMove(canvas,QPoint(10,32));
+
+ QCOMPARE(mouseTracker->hovered(), false);
+ QCOMPARE(enteredSpy.count(), 0);
+
+ mouseTracker->setVisible(true);
+
+ QCOMPARE(mouseTracker->hovered(), true);
+ QCOMPARE(enteredSpy.count(), 1);
+
+ QEXPECT_FAIL("", "QTBUG-24282", Continue);
+ QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32));
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_QQuickMouseArea)
+
+#include "tst_qquickmousearea.moc"
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml b/tests/auto/quick/qquickmultipointtoucharea/data/basic.qml
index cd6ce8146f..cd6ce8146f 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/basic.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml b/tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml
index 9c9132d0b0..9c9132d0b0 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml b/tests/auto/quick/qquickmultipointtoucharea/data/nested.qml
index 37b8820aa0..37b8820aa0 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/nested.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml b/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml
index 039607e26c..039607e26c 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml b/tests/auto/quick/qquickmultipointtoucharea/data/properties.qml
index 98ef1a9cbe..98ef1a9cbe 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/properties.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml b/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml
index 54b160c182..54b160c182 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml
diff --git a/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro b/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
new file mode 100644
index 0000000000..3c6f304284
--- /dev/null
+++ b/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
@@ -0,0 +1,11 @@
+TARGET = tst_qquickmultipointtoucharea
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickmultipointtoucharea.cpp
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
new file mode 100644
index 0000000000..507612f8ce
--- /dev/null
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -0,0 +1,727 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qquickmultipointtoucharea_p.h>
+#include <private/qquickflickable_p.h>
+#include <QtQuick/qquickview.h>
+
+class tst_QQuickMultiPointTouchArea: public QObject
+{
+ Q_OBJECT
+public:
+ tst_QQuickMultiPointTouchArea() : device(0) { }
+private slots:
+ void initTestCase() {
+ if (!device) {
+ device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+ }
+ void cleanupTestCase() {}
+
+ void properties();
+ void signalTest();
+ void release();
+ void reuse();
+ void nonOverlapping();
+ void nested();
+ void inFlickable();
+ void invisible();
+
+private:
+ QQuickView *createAndShowView(const QString &file);
+ QTouchDevice *device;
+};
+
+void tst_QQuickMultiPointTouchArea::properties()
+{
+ QQuickView *canvas = createAndShowView("properties.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
+ QVERIFY(area != 0);
+
+ QCOMPARE(area->minimumTouchPoints(), 2);
+ QCOMPARE(area->maximumTouchPoints(), 4);
+
+ QQmlListReference ref(area, "touchPoints");
+ QCOMPARE(ref.count(), 4);
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::signalTest()
+{
+ QQuickView *canvas = createAndShowView("signalTest.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
+ QVERIFY(area != 0);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+ QPoint p3(60,100);
+ QPoint p4(80,100);
+ QPoint p5(100,100);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).press(1, p2).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 2);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+ QCOMPARE(area->property("touchCount").toInt(), 2);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ sequence.stationary(0).stationary(1).press(2, p3).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 1);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+ QCOMPARE(area->property("touchCount").toInt(), 3);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ sequence.move(0, p1).move(1, p2).stationary(2).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 2);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+ QCOMPARE(area->property("touchCount").toInt(), 3);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ p3 += QPoint(10,10);
+ sequence.release(0, p1).release(1, p2)
+ .move(2, p3).press(3, p4).press(4, p5).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 2);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 1);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 2);
+ QCOMPARE(area->property("touchCount").toInt(), 3);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ sequence.release(2, p3).release(3, p4).release(4, p5).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 3);
+ QCOMPARE(area->property("touchCount").toInt(), 0);
+ QCOMPARE(area->property("touchUpdatedHandled").toBool(), true);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::release()
+{
+ QQuickView *canvas = createAndShowView("basic.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickTouchPoint *point1 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
+
+ QCOMPARE(point1->pressed(), false);
+
+ QPoint p1(20,100);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).commit();
+
+ QCOMPARE(point1->pressed(), true);
+
+ p1 += QPoint(0,10);
+
+ sequence.move(0, p1).commit();
+
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point1->x(), qreal(20)); QCOMPARE(point1->y(), qreal(110));
+
+ p1 += QPoint(4,10);
+
+ sequence.release(0, p1).commit();
+
+ //test that a release without a prior move to the release position successfully updates the point's position
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point1->x(), qreal(24)); QCOMPARE(point1->y(), qreal(120));
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::reuse()
+{
+ QQuickView *canvas = createAndShowView("basic.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickTouchPoint *point1 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
+ QQuickTouchPoint *point2 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point2");
+ QQuickTouchPoint *point3 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point3");
+
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point2->pressed(), false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+ QPoint p3(60,100);
+ QPoint p4(80,100);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).press(1, p2).commit();
+
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), false);
+
+ sequence.release(0, p1).stationary(1).press(2, p3).commit();
+
+ //we shouldn't reuse point 1 yet
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), true);
+
+ //back to base state (no touches)
+ sequence.release(1, p2).release(2, p3).commit();
+
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point2->pressed(), false);
+ QCOMPARE(point3->pressed(), false);
+
+ sequence.press(0, p1).press(1, p2).commit();
+
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), false);
+
+ sequence.release(0, p1).stationary(1).commit();
+
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), false);
+
+ sequence.press(4, p4).stationary(1).commit();
+
+ //the new touch point should reuse point 1
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), false);
+
+ QCOMPARE(point1->x(), qreal(80)); QCOMPARE(point1->y(), qreal(100));
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::nonOverlapping()
+{
+ QQuickView *canvas = createAndShowView("nonOverlapping.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point11");
+ QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point12");
+ QQuickTouchPoint *point21 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point21");
+ QQuickTouchPoint *point22 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point22");
+ QQuickTouchPoint *point23 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point23");
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+ QPoint p3(60,180);
+ QPoint p4(80,180);
+ QPoint p5(100,180);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ sequence.stationary(0).press(1, p2).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100));
+ QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100));
+
+ p1 += QPoint(0,10);
+ p2 += QPoint(5,0);
+ sequence.move(0, p1).move(1, p2).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+
+ sequence.stationary(0).stationary(1).press(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ sequence.stationary(0).stationary(1).stationary(2).press(3, p4).press(4, p5).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+ QCOMPARE(point21->x(), qreal(60)); QCOMPARE(point21->y(), qreal(20));
+ QCOMPARE(point22->x(), qreal(80)); QCOMPARE(point22->y(), qreal(20));
+ QCOMPARE(point23->x(), qreal(100)); QCOMPARE(point23->y(), qreal(20));
+
+ p1 += QPoint(4,10);
+ p2 += QPoint(17,17);
+ p3 += QPoint(3,0);
+ p4 += QPoint(1,-1);
+ p5 += QPoint(-7,10);
+ sequence.move(0, p1).move(1, p2).move(2, p3).move(3, p4).move(4, p5).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120));
+ QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117));
+ QCOMPARE(point21->x(), qreal(63)); QCOMPARE(point21->y(), qreal(20));
+ QCOMPARE(point22->x(), qreal(81)); QCOMPARE(point22->y(), qreal(19));
+ QCOMPARE(point23->x(), qreal(93)); QCOMPARE(point23->y(), qreal(30));
+
+ sequence.release(0, p1).release(1, p2).release(2, p3).release(3, p4).release(4, p5).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::nested()
+{
+ QQuickView *canvas = createAndShowView("nested.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point11");
+ QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point12");
+ QQuickTouchPoint *point21 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point21");
+ QQuickTouchPoint *point22 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point22");
+ QQuickTouchPoint *point23 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point23");
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+ QPoint p3(60,180);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ sequence.stationary(0).press(1, p2).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100));
+ QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100));
+
+ p1 += QPoint(0,10);
+ p2 += QPoint(5,0);
+ sequence.move(0, p1).move(1, p2).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+
+ sequence.stationary(0).stationary(1).press(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ //point11 should be same as point21, point12 same as point22
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+ QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
+ QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
+ QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
+
+ sequence.stationary(0).stationary(1).stationary(2).press(3, QPoint(80,180)).press(4, QPoint(100,180)).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ //new touch points should be ignored (have no impact on our existing touch points)
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+ QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
+ QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
+ QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
+
+ sequence.stationary(0).stationary(1).stationary(2).release(3, QPoint(80,180)).release(4, QPoint(100,180)).commit();
+
+ p1 += QPoint(4,10);
+ p2 += QPoint(17,17);
+ p3 += QPoint(3,0);
+ sequence.move(0, p1).move(1, p2).move(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
+ QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
+ QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
+ QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
+ QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180));
+
+ p1 += QPoint(4,10);
+ p2 += QPoint(17,17);
+ p3 += QPoint(3,0);
+ sequence.move(0, p1).move(1, p2).move(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ //first two remain the same (touches now grabbed by inner touch area)
+ QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120));
+ QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117));
+ QCOMPARE(point21->x(), qreal(28)); QCOMPARE(point21->y(), qreal(130));
+ QCOMPARE(point22->x(), qreal(79)); QCOMPARE(point22->y(), qreal(134));
+ QCOMPARE(point23->x(), qreal(66)); QCOMPARE(point23->y(), qreal(180));
+
+ sequence.release(0, p1).release(1, p2).release(2, p3).commit();
+
+ sequence.press(0, p1).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ sequence.release(0, p1).commit();
+
+ //test with grabbing turned off
+ canvas->rootObject()->setProperty("grabInnerArea", false);
+
+ sequence.press(0, p1).press(1, p2).press(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ p1 -= QPoint(4,10);
+ p2 -= QPoint(17,17);
+ p3 -= QPoint(3,0);
+ sequence.move(0, p1).move(1, p2).move(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
+ QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
+ QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
+ QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
+ QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180));
+
+ p1 -= QPoint(4,10);
+ p2 -= QPoint(17,17);
+ p3 -= QPoint(3,0);
+ sequence.move(0, p1).move(1, p2).move(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ //all change (touches not grabbed by inner touch area)
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+ QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
+ QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
+ QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
+
+ sequence.release(0, p1).release(1, p2).release(2, p3).commit();
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::inFlickable()
+{
+ QQuickView *canvas = createAndShowView("inFlickable.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
+ QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point2");
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+
+ //moving one point vertically
+ QTest::touchEvent(canvas, device).press(0, p1);
+ QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
+
+ p1 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1);
+ QTest::mouseMove(canvas, p1);
+
+ QVERIFY(flickable->contentY() < 0);
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+
+ QTest::touchEvent(canvas, device).release(0, p1);
+ QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
+ QTest::qWait(50);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ //moving two points vertically
+ p1 = QPoint(20,100);
+ QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
+ QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(flickable->property("cancelCount").toInt(), 0);
+ QCOMPARE(flickable->property("touchCount").toInt(), 2);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ QVERIFY(flickable->contentY() < 0);
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(flickable->property("cancelCount").toInt(), 2);
+ QCOMPARE(flickable->property("touchCount").toInt(), 0);
+
+ QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
+ QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
+ QTest::qWait(50);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ //moving two points horizontally, then one point vertically
+ p1 = QPoint(20,100);
+ p2 = QPoint(40,100);
+ QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
+ QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+
+ p1 += QPoint(15,0); p2 += QPoint(15,0);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(15,0); p2 += QPoint(15,0);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(15,0); p2 += QPoint(15,0);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(15,0); p2 += QPoint(15,0);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ QVERIFY(flickable->contentY() == 0);
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+
+ QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
+ QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
+ QTest::qWait(50);
+
+ delete canvas;
+}
+
+// QTBUG-23327
+void tst_QQuickMultiPointTouchArea::invisible()
+{
+ QQuickView *canvas = createAndShowView("signalTest.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
+ QVERIFY(area != 0);
+
+ area->setVisible(false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).press(1, p2).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+ QCOMPARE(area->property("touchCount").toInt(), 0);
+
+ delete canvas;
+}
+
+
+QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file)
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QLatin1String("/data/") + file));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_QQuickMultiPointTouchArea)
+
+#include "tst_qquickmultipointtoucharea.moc"
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/arc.qml b/tests/auto/quick/qquickpath/data/arc.qml
index 000221c784..000221c784 100644
--- a/tests/auto/qtquick2/qdeclarativepath/data/arc.qml
+++ b/tests/auto/quick/qquickpath/data/arc.qml
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml b/tests/auto/quick/qquickpath/data/closedcurve.qml
index bb4a715e28..bb4a715e28 100644
--- a/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml
+++ b/tests/auto/quick/qquickpath/data/closedcurve.qml
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/curve.qml b/tests/auto/quick/qquickpath/data/curve.qml
index c571186496..c571186496 100644
--- a/tests/auto/qtquick2/qdeclarativepath/data/curve.qml
+++ b/tests/auto/quick/qquickpath/data/curve.qml
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/svg.qml b/tests/auto/quick/qquickpath/data/svg.qml
index cec0f75061..cec0f75061 100644
--- a/tests/auto/qtquick2/qdeclarativepath/data/svg.qml
+++ b/tests/auto/quick/qquickpath/data/svg.qml
diff --git a/tests/auto/quick/qquickpath/qquickpath.pro b/tests/auto/quick/qquickpath/qquickpath.pro
new file mode 100644
index 0000000000..e1f0f7b278
--- /dev/null
+++ b/tests/auto/quick/qquickpath/qquickpath.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickpath
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpath.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
new file mode 100644
index 0000000000..73e7e6ea38
--- /dev/null
+++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquickpath_p.h>
+
+#include "../../shared/util.h"
+
+class tst_QuickPath : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QuickPath() {}
+
+private slots:
+ void arc();
+ void catmullromCurve();
+ void closedCatmullromCurve();
+ void svg();
+};
+
+void tst_QuickPath::arc()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("arc.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 1);
+
+ QQuickPathArc* arc = qobject_cast<QQuickPathArc*>(list.at(0));
+ QVERIFY(arc != 0);
+ QCOMPARE(arc->x(), 100.);
+ QCOMPARE(arc->y(), 100.);
+ QCOMPARE(arc->radiusX(), 100.);
+ QCOMPARE(arc->radiusY(), 100.);
+ QCOMPARE(arc->useLargeArc(), false);
+ QCOMPARE(arc->direction(), QQuickPathArc::Clockwise);
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(0,0));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(39,8)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(92,61)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(100,100));
+}
+
+void tst_QuickPath::catmullromCurve()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("curve.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 3);
+
+ QQuickPathCatmullRomCurve* curve = qobject_cast<QQuickPathCatmullRomCurve*>(list.at(0));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 100.);
+ QCOMPARE(curve->y(), 50.);
+
+ curve = qobject_cast<QQuickPathCatmullRomCurve*>(list.at(2));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 100.);
+ QCOMPARE(curve->y(), 150.);
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(0,0));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(63,26)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(100,150));
+}
+
+void tst_QuickPath::closedCatmullromCurve()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("closedcurve.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 50.);
+ QCOMPARE(obj->startY(), 50.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 3);
+
+ QQuickPathCatmullRomCurve* curve = qobject_cast<QQuickPathCatmullRomCurve*>(list.at(2));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 50.);
+ QCOMPARE(curve->y(), 50.);
+
+ QVERIFY(obj->isClosed());
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(50,50));
+ pos = obj->pointAt(.1);
+ QCOMPARE(pos.toPoint(), QPoint(67,56)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(44,116)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(50,50));
+}
+
+void tst_QuickPath::svg()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("svg.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 1);
+
+ QQuickPathSvg* svg = qobject_cast<QQuickPathSvg*>(list.at(0));
+ QVERIFY(svg != 0);
+ QCOMPARE(svg->path(), QLatin1String("M200,300 Q400,50 600,300 T1000,300"));
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(200,300));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(400,175)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(800,425)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(1000,300));
+}
+
+
+QTEST_MAIN(tst_QuickPath)
+
+#include "tst_qquickpath.moc"
diff --git a/tests/auto/qtquick2/qquickpathview/data/ComponentView.qml b/tests/auto/quick/qquickpathview/data/ComponentView.qml
index b61033d375..b61033d375 100644
--- a/tests/auto/qtquick2/qquickpathview/data/ComponentView.qml
+++ b/tests/auto/quick/qquickpathview/data/ComponentView.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/asyncloader.qml b/tests/auto/quick/qquickpathview/data/asyncloader.qml
index 94f560f3e7..94f560f3e7 100644
--- a/tests/auto/qtquick2/qquickpathview/data/asyncloader.qml
+++ b/tests/auto/quick/qquickpathview/data/asyncloader.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/closedPath.qml b/tests/auto/quick/qquickpathview/data/closedPath.qml
index 3ca34056c8..3ca34056c8 100644
--- a/tests/auto/qtquick2/qquickpathview/data/closedPath.qml
+++ b/tests/auto/quick/qquickpathview/data/closedPath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/creationContext.qml b/tests/auto/quick/qquickpathview/data/creationContext.qml
index 79a682788b..79a682788b 100644
--- a/tests/auto/qtquick2/qquickpathview/data/creationContext.qml
+++ b/tests/auto/quick/qquickpathview/data/creationContext.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/datamodel.qml b/tests/auto/quick/qquickpathview/data/datamodel.qml
index 44f2aecc0a..44f2aecc0a 100644
--- a/tests/auto/qtquick2/qquickpathview/data/datamodel.qml
+++ b/tests/auto/quick/qquickpathview/data/datamodel.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/displaypath.qml b/tests/auto/quick/qquickpathview/data/displaypath.qml
index af0f381fc4..af0f381fc4 100644
--- a/tests/auto/qtquick2/qquickpathview/data/displaypath.qml
+++ b/tests/auto/quick/qquickpathview/data/displaypath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/dragpath.qml b/tests/auto/quick/qquickpathview/data/dragpath.qml
index f9c6615b04..f9c6615b04 100644
--- a/tests/auto/qtquick2/qquickpathview/data/dragpath.qml
+++ b/tests/auto/quick/qquickpathview/data/dragpath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/emptymodel.qml b/tests/auto/quick/qquickpathview/data/emptymodel.qml
index eb4d3006f4..eb4d3006f4 100644
--- a/tests/auto/qtquick2/qquickpathview/data/emptymodel.qml
+++ b/tests/auto/quick/qquickpathview/data/emptymodel.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/missingPercent.qml b/tests/auto/quick/qquickpathview/data/missingPercent.qml
index 97af8e8982..97af8e8982 100644
--- a/tests/auto/qtquick2/qquickpathview/data/missingPercent.qml
+++ b/tests/auto/quick/qquickpathview/data/missingPercent.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/openPath.qml b/tests/auto/quick/qquickpathview/data/openPath.qml
index 1bd8375d9e..1bd8375d9e 100644
--- a/tests/auto/qtquick2/qquickpathview/data/openPath.qml
+++ b/tests/auto/quick/qquickpathview/data/openPath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml b/tests/auto/quick/qquickpathview/data/pathUpdate.qml
index e729291025..e729291025 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml
+++ b/tests/auto/quick/qquickpathview/data/pathUpdate.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml b/tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml
index 89084b2a37..89084b2a37 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml
+++ b/tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathline.qml b/tests/auto/quick/qquickpathview/data/pathline.qml
index 4c1c785bce..4c1c785bce 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathline.qml
+++ b/tests/auto/quick/qquickpathview/data/pathline.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathtest.qml b/tests/auto/quick/qquickpathview/data/pathtest.qml
index 736d58d2a9..736d58d2a9 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathtest.qml
+++ b/tests/auto/quick/qquickpathview/data/pathtest.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview0.qml b/tests/auto/quick/qquickpathview/data/pathview0.qml
index 8b9378163f..8b9378163f 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview0.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview0.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview1.qml b/tests/auto/quick/qquickpathview/data/pathview1.qml
index 53d375e596..53d375e596 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview1.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview1.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview2.qml b/tests/auto/quick/qquickpathview/data/pathview2.qml
index 1d279c42a0..1d279c42a0 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview2.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview2.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview3.qml b/tests/auto/quick/qquickpathview/data/pathview3.qml
index ded5a3911c..ded5a3911c 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview3.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview3.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview_package.qml b/tests/auto/quick/qquickpathview/data/pathview_package.qml
index 2af57e6bb1..2af57e6bb1 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview_package.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview_package.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/propertychanges.qml b/tests/auto/quick/qquickpathview/data/propertychanges.qml
index 09b309f86f..09b309f86f 100644
--- a/tests/auto/qtquick2/qquickpathview/data/propertychanges.qml
+++ b/tests/auto/quick/qquickpathview/data/propertychanges.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/treemodel.qml b/tests/auto/quick/qquickpathview/data/treemodel.qml
index fcf6922d00..fcf6922d00 100644
--- a/tests/auto/qtquick2/qquickpathview/data/treemodel.qml
+++ b/tests/auto/quick/qquickpathview/data/treemodel.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml b/tests/auto/quick/qquickpathview/data/undefinedpath.qml
index 674e7cca8d..674e7cca8d 100644
--- a/tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml
+++ b/tests/auto/quick/qquickpathview/data/undefinedpath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/vdm.qml b/tests/auto/quick/qquickpathview/data/vdm.qml
index 839393d9bd..839393d9bd 100644
--- a/tests/auto/qtquick2/qquickpathview/data/vdm.qml
+++ b/tests/auto/quick/qquickpathview/data/vdm.qml
diff --git a/tests/auto/quick/qquickpathview/qquickpathview.pro b/tests/auto/quick/qquickpathview/qquickpathview.pro
new file mode 100644
index 0000000000..52f00ce3f8
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/qquickpathview.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickpathview
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpathview.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private widgets testlib
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
new file mode 100644
index 0000000000..8866cafd80
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -0,0 +1,1458 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <QtQuick/private/qquickpathview_p.h>
+#include <QtQuick/private/qquickpath_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qqmlvaluetype_p.h>
+#include <QStringListModel>
+#include <QStandardItemModel>
+#include <QFile>
+
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+
+static void initStandardTreeModel(QStandardItemModel *model)
+{
+ QStandardItem *item;
+ item = new QStandardItem(QLatin1String("Row 1 Item"));
+ model->insertRow(0, item);
+
+ item = new QStandardItem(QLatin1String("Row 2 Item"));
+ item->setCheckable(true);
+ model->insertRow(1, item);
+
+ QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
+ item->setChild(0, childItem);
+
+ item = new QStandardItem(QLatin1String("Row 3 Item"));
+ item->setIcon(QIcon());
+ model->insertRow(2, item);
+}
+
+
+class tst_QQuickPathView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickPathView();
+
+private slots:
+ void initValues();
+ void items();
+ void dataModel();
+ void pathview2();
+ void pathview3();
+ void insertModel_data();
+ void insertModel();
+ void removeModel_data();
+ void removeModel();
+ void moveModel_data();
+ void moveModel();
+ void path();
+ void pathMoved();
+ void setCurrentIndex();
+ void resetModel();
+ void propertyChanges();
+ void pathChanges();
+ void componentChanges();
+ void modelChanges();
+ void pathUpdateOnStartChanged();
+ void package();
+ void emptyModel();
+ void closed();
+ void pathUpdate();
+ void visualDataModel();
+ void undefinedPath();
+ void mouseDrag();
+ void treeModel();
+ void changePreferredHighlight();
+ void missingPercent();
+ void creationContext();
+ void currentOffsetOnInsertion();
+ void asynchronous();
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError)
+ Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
+ Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged)
+
+public:
+ TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; }
+
+ bool useModel() const { return mUseModel; }
+ void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
+
+ int pathItemCount() const { return mPathItemCount; }
+ void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); }
+
+signals:
+ void useModelChanged();
+ void pathItemCountChanged();
+
+private:
+ bool mError;
+ bool mUseModel;
+ int mPathItemCount;
+};
+
+tst_QQuickPathView::tst_QQuickPathView()
+{
+}
+
+void tst_QQuickPathView::initValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathview1.qml"));
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() == 0);
+ QVERIFY(obj->delegate() == 0);
+ QCOMPARE(obj->model(), QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 0.);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.);
+ QCOMPARE(obj->dragMargin(), 0.);
+ QCOMPARE(obj->count(), 0);
+ QCOMPARE(obj->pathItemCount(), -1);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::items()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->count(), model.count());
+ QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
+
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickText *name = findItem<QQuickText>(pathview, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(pathview, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+
+ QVERIFY(pathview->highlightItem());
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;
+ offset.setX(pathview->highlightItem()->width()/2);
+ offset.setY(pathview->highlightItem()->height()/2);
+ QCOMPARE(pathview->highlightItem()->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::pathview2()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathview2.qml"));
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() != 0);
+ QVERIFY(obj->delegate() != 0);
+ QVERIFY(obj->model() != QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 0.);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.);
+ QCOMPARE(obj->dragMargin(), 0.);
+ QCOMPARE(obj->count(), 8);
+ QCOMPARE(obj->pathItemCount(), 10);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::pathview3()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathview3.qml"));
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() != 0);
+ QVERIFY(obj->delegate() != 0);
+ QVERIFY(obj->model() != QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 1.0);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.5);
+ QCOMPARE(obj->dragMargin(), 24.);
+ QCOMPARE(obj->count(), 8);
+ QCOMPARE(obj->pathItemCount(), 4);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::insertModel_data()
+{
+ QTest::addColumn<int>("mode");
+ QTest::addColumn<int>("idx");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("offset");
+
+ // We have 8 items, with currentIndex == 4
+ QTest::newRow("insert after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 5.;
+ QTest::newRow("insert before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.;
+ QTest::newRow("insert multiple after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 6.;
+ QTest::newRow("insert multiple before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.;
+ QTest::newRow("insert at end")
+ << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << 5.;
+ QTest::newRow("insert at beginning")
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.;
+ QTest::newRow("insert at current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 4.;
+
+ QTest::newRow("no range - insert after current")
+ << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 5.;
+ QTest::newRow("no range - insert before current")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.;
+ QTest::newRow("no range - insert multiple after current")
+ << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 6.;
+ QTest::newRow("no range - insert multiple before current")
+ << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.;
+ QTest::newRow("no range - insert at end")
+ << int(QQuickPathView::NoHighlightRange) << 8 << 1 << 5.;
+ QTest::newRow("no range - insert at beginning")
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.;
+ QTest::newRow("no range - insert at current")
+ << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.;
+}
+
+void tst_QQuickPathView::insertModel()
+{
+ QFETCH(int, mode);
+ QFETCH(int, idx);
+ QFETCH(int, count);
+ QFETCH(qreal, offset);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+ model.addItem("Jinny", "679");
+ model.addItem("Milly", "73378");
+ model.addItem("Jimmy", "3535");
+ model.addItem("Barb", "9039");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
+
+ pathview->setCurrentIndex(4);
+ if (mode == QQuickPathView::StrictlyEnforceRange)
+ QTRY_COMPARE(pathview->offset(), 4.0);
+ else
+ pathview->setOffset(4);
+
+ QList<QPair<QString, QString> > items;
+ for (int i = 0; i < count; ++i)
+ items.append(qMakePair(QString("New"), QString::number(i)));
+
+ model.insertItems(idx, items);
+ QTRY_COMPARE(pathview->offset(), offset);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::removeModel_data()
+{
+ QTest::addColumn<int>("mode");
+ QTest::addColumn<int>("idx");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("offset");
+
+ // We have 8 items, with currentIndex == 4
+ QTest::newRow("remove after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 3.;
+ QTest::newRow("remove before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.;
+ QTest::newRow("remove multiple after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 2.;
+ QTest::newRow("remove multiple before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.;
+ QTest::newRow("remove last")
+ << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << 3.;
+ QTest::newRow("remove first")
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.;
+ QTest::newRow("remove current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 3.;
+
+ QTest::newRow("no range - remove after current")
+ << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 3.;
+ QTest::newRow("no range - remove before current")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.;
+ QTest::newRow("no range - remove multiple after current")
+ << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 2.;
+ QTest::newRow("no range - remove multiple before current")
+ << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.;
+ QTest::newRow("no range - remove last")
+ << int(QQuickPathView::NoHighlightRange) << 7 << 1 << 3.;
+ QTest::newRow("no range - remove first")
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.;
+ QTest::newRow("no range - remove current offset")
+ << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.;
+}
+
+void tst_QQuickPathView::removeModel()
+{
+ QFETCH(int, mode);
+ QFETCH(int, idx);
+ QFETCH(int, count);
+ QFETCH(qreal, offset);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+ model.addItem("Jinny", "679");
+ model.addItem("Milly", "73378");
+ model.addItem("Jimmy", "3535");
+ model.addItem("Barb", "9039");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
+
+ pathview->setCurrentIndex(4);
+ if (mode == QQuickPathView::StrictlyEnforceRange)
+ QTRY_COMPARE(pathview->offset(), 4.0);
+ else
+ pathview->setOffset(4);
+
+ model.removeItems(idx, count);
+ QTRY_COMPARE(pathview->offset(), offset);
+
+ delete canvas;
+}
+
+
+void tst_QQuickPathView::moveModel_data()
+{
+ QTest::addColumn<int>("mode");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("offset");
+
+ // We have 8 items, with currentIndex == 4
+ QTest::newRow("move after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4.;
+ QTest::newRow("move before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4.;
+ QTest::newRow("move before current to after")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5.;
+ QTest::newRow("move multiple after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4.;
+ QTest::newRow("move multiple before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4.;
+ QTest::newRow("move before current to end")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5.;
+ QTest::newRow("move last to beginning")
+ << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3.;
+ QTest::newRow("move current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2.;
+
+ QTest::newRow("no range - move after current")
+ << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << 4.;
+ QTest::newRow("no range - move before current")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << 4.;
+ QTest::newRow("no range - move before current to after")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << 5.;
+ QTest::newRow("no range - move multiple after current")
+ << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << 4.;
+ QTest::newRow("no range - move multiple before current")
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << 4.;
+ QTest::newRow("no range - move before current to end")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << 5.;
+ QTest::newRow("no range - move last to beginning")
+ << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << 3.;
+ QTest::newRow("no range - move current")
+ << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << 4.;
+ QTest::newRow("no range - move multiple incl. current")
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << 4.;
+}
+
+void tst_QQuickPathView::moveModel()
+{
+ QFETCH(int, mode);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(qreal, offset);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+ model.addItem("Jinny", "679");
+ model.addItem("Milly", "73378");
+ model.addItem("Jimmy", "3535");
+ model.addItem("Barb", "9039");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
+
+ pathview->setCurrentIndex(4);
+ if (mode == QQuickPathView::StrictlyEnforceRange)
+ QTRY_COMPARE(pathview->offset(), 4.0);
+ else
+ pathview->setOffset(4);
+
+ model.moveItems(from, to, count);
+ QTRY_COMPARE(pathview->offset(), offset);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::path()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathtest.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->startX(), 120.);
+ QCOMPARE(obj->startY(), 100.);
+ QVERIFY(obj->path() != QPainterPath());
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 5);
+
+ QQuickPathAttribute* attr = qobject_cast<QQuickPathAttribute*>(list.at(0));
+ QVERIFY(attr != 0);
+ QCOMPARE(attr->name(), QString("scale"));
+ QCOMPARE(attr->value(), 1.0);
+
+ QQuickPathQuad* quad = qobject_cast<QQuickPathQuad*>(list.at(1));
+ QVERIFY(quad != 0);
+ QCOMPARE(quad->x(), 120.);
+ QCOMPARE(quad->y(), 25.);
+ QCOMPARE(quad->controlX(), 260.);
+ QCOMPARE(quad->controlY(), 75.);
+
+ QQuickPathPercent* perc = qobject_cast<QQuickPathPercent*>(list.at(2));
+ QVERIFY(perc != 0);
+ QCOMPARE(perc->value(), 0.3);
+
+ QQuickPathLine* line = qobject_cast<QQuickPathLine*>(list.at(3));
+ QVERIFY(line != 0);
+ QCOMPARE(line->x(), 120.);
+ QCOMPARE(line->y(), 100.);
+
+ QQuickPathCubic* cubic = qobject_cast<QQuickPathCubic*>(list.at(4));
+ QVERIFY(cubic != 0);
+ QCOMPARE(cubic->x(), 180.);
+ QCOMPARE(cubic->y(), 0.);
+ QCOMPARE(cubic->control1X(), -10.);
+ QCOMPARE(cubic->control1Y(), 90.);
+ QCOMPARE(cubic->control2X(), 210.);
+ QCOMPARE(cubic->control2Y(), 90.);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::dataModel()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ QaimModel model;
+ model.addItem("red", "1");
+ model.addItem("green", "2");
+ model.addItem("blue", "3");
+ model.addItem("purple", "4");
+ model.addItem("gray", "5");
+ model.addItem("brown", "6");
+ model.addItem("yellow", "7");
+ model.addItem("thistle", "8");
+ model.addItem("cyan", "9");
+ model.addItem("peachpuff", "10");
+ model.addItem("powderblue", "11");
+ model.addItem("gold", "12");
+ model.addItem("sandybrown", "13");
+
+ ctxt->setContextProperty("testData", &model);
+
+ canvas->setSource(testFileUrl("datamodel.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QQuickItem *item = findItem<QQuickItem>(pathview, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), 110.0);
+ QCOMPARE(item->y(), 10.0);
+
+ model.insertItem(4, "orange", "10");
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 14);
+
+ QVERIFY(pathview->currentIndex() == 0);
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
+
+ QQuickText *text = findItem<QQuickText>(pathview, "myText", 4);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(4));
+
+ model.removeItem(2);
+ QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
+ text = findItem<QQuickText>(pathview, "myText", 2);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(2));
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
+
+ testObject->setPathItemCount(5);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+
+ QQuickRectangle *testItem = findItem<QQuickRectangle>(pathview, "wrapper", 4);
+ QVERIFY(testItem != 0);
+ testItem = findItem<QQuickRectangle>(pathview, "wrapper", 5);
+ QVERIFY(testItem == 0);
+
+ pathview->setCurrentIndex(1);
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+ QTest::qWait(100);
+
+ model.insertItem(2, "pink", "2");
+ QTest::qWait(100);
+
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QVERIFY(pathview->currentIndex() == 1);
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+
+ text = findItem<QQuickText>(pathview, "myText", 2);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(2));
+
+ model.removeItem(3);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ text = findItem<QQuickText>(pathview, "myText", 3);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(3));
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+
+ model.moveItem(3, 5);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QList<QQuickItem*> items = findItems<QQuickItem>(pathview, "wrapper");
+ foreach (QQuickItem *item, items) {
+ QVERIFY(item->property("onPath").toBool());
+ }
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+
+ // QTBUG-14199
+ pathview->setOffset(7);
+ pathview->setOffset(0);
+ QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+
+ pathview->setCurrentIndex(model.count()-1);
+ model.removeItem(model.count()-1);
+ QCOMPARE(pathview->currentIndex(), model.count()-1);
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickPathView::pathMoved()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ pathview->setOffset(1.0);
+
+ for (int i=0; i<model.count(); i++) {
+ QQuickRectangle *curItem = findItem<QQuickRectangle>(pathview, "wrapper", i);
+ QPointF itemPos(path->pointAt(0.25 + i*0.25));
+ QCOMPARE(curItem->pos() + offset, QPointF(itemPos.x(), itemPos.y()));
+ }
+
+ pathview->setOffset(0.0);
+ QCOMPARE(firstItem->pos() + offset, start);
+
+ // Change delegate size
+ pathview->setOffset(0.1);
+ pathview->setOffset(0.0);
+ canvas->rootObject()->setProperty("delegateWidth", 30);
+ QCOMPARE(firstItem->width(), 30.0);
+ offset.setX(firstItem->width()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+
+ // Change delegate scale
+ pathview->setOffset(0.1);
+ pathview->setOffset(0.0);
+ canvas->rootObject()->setProperty("delegateScale", 1.2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::setCurrentIndex()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QCOMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0);
+
+ pathview->setCurrentIndex(2);
+
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 1);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 1);
+ QVERIFY(firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 3);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
+ QVERIFY(firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->incrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ // move an item, set move duration to 0, and change currentIndex to moved item. QTBUG-22786
+ model.moveItem(0, 3);
+ pathview->setHighlightMoveDuration(0);
+ pathview->setCurrentIndex(3);
+ QCOMPARE(pathview->currentIndex(), 3);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ model.moveItem(3, 0);
+ pathview->setCurrentIndex(0);
+ pathview->setHighlightMoveDuration(300);
+
+ // Check the current item is still created when outside the bounds of pathItemCount.
+ pathview->setPathItemCount(2);
+ pathview->setHighlightRangeMode(QQuickPathView::NoHighlightRange);
+ QVERIFY(findItem<QQuickRectangle>(pathview, "wrapper", 0));
+ QVERIFY(findItem<QQuickRectangle>(pathview, "wrapper", 1));
+ QVERIFY(!findItem<QQuickRectangle>(pathview, "wrapper", 2));
+ QVERIFY(!findItem<QQuickRectangle>(pathview, "wrapper", 3));
+
+ pathview->setCurrentIndex(2);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 2);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(false));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 1);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 1);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 3);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(false));
+
+ pathview->incrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::resetModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaypath.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::propertyChanges()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged()));
+ QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged()));
+
+ QCOMPARE(pathView->preferredHighlightBegin(), 0.1);
+ QCOMPARE(pathView->dragMargin(), 5.0);
+
+ pathView->setPreferredHighlightBegin(0.4);
+ pathView->setPreferredHighlightEnd(0.4);
+ pathView->setDragMargin(20.0);
+
+ QCOMPARE(pathView->preferredHighlightBegin(), 0.4);
+ QCOMPARE(pathView->preferredHighlightEnd(), 0.4);
+ QCOMPARE(pathView->dragMargin(), 20.0);
+
+ QCOMPARE(snapPositionSpy.count(), 1);
+ QCOMPARE(dragMarginSpy.count(), 1);
+
+ pathView->setPreferredHighlightBegin(0.4);
+ pathView->setPreferredHighlightEnd(0.4);
+ pathView->setDragMargin(20.0);
+
+ QCOMPARE(snapPositionSpy.count(), 1);
+ QCOMPARE(dragMarginSpy.count(), 1);
+ delete canvas;
+}
+
+void tst_QQuickPathView::pathChanges()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQuickPath *path = canvas->rootObject()->findChild<QQuickPath*>("path");
+ QVERIFY(path);
+
+ QSignalSpy startXSpy(path, SIGNAL(startXChanged()));
+ QSignalSpy startYSpy(path, SIGNAL(startYChanged()));
+
+ QCOMPARE(path->startX(), 220.0);
+ QCOMPARE(path->startY(), 200.0);
+
+ path->setStartX(240.0);
+ path->setStartY(220.0);
+
+ QCOMPARE(path->startX(), 240.0);
+ QCOMPARE(path->startY(), 220.0);
+
+ QCOMPARE(startXSpy.count(),1);
+ QCOMPARE(startYSpy.count(),1);
+
+ path->setStartX(240);
+ path->setStartY(220);
+
+ QCOMPARE(startXSpy.count(),1);
+ QCOMPARE(startYSpy.count(),1);
+
+ QQuickPath *alternatePath = canvas->rootObject()->findChild<QQuickPath*>("alternatePath");
+ QVERIFY(alternatePath);
+
+ QSignalSpy pathSpy(pathView, SIGNAL(pathChanged()));
+
+ QCOMPARE(pathView->path(), path);
+
+ pathView->setPath(alternatePath);
+ QCOMPARE(pathView->path(), alternatePath);
+ QCOMPARE(pathSpy.count(),1);
+
+ pathView->setPath(alternatePath);
+ QCOMPARE(pathSpy.count(),1);
+
+ QQuickPathAttribute *pathAttribute = canvas->rootObject()->findChild<QQuickPathAttribute*>("pathAttribute");
+ QVERIFY(pathAttribute);
+
+ QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged()));
+ QCOMPARE(pathAttribute->name(), QString("opacity"));
+
+ pathAttribute->setName("scale");
+ QCOMPARE(pathAttribute->name(), QString("scale"));
+ QCOMPARE(nameSpy.count(),1);
+
+ pathAttribute->setName("scale");
+ QCOMPARE(nameSpy.count(),1);
+ delete canvas;
+}
+
+void tst_QQuickPathView::componentChanges()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQmlComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged()));
+
+ pathView->setDelegate(&delegateComponent);
+ QCOMPARE(pathView->delegate(), &delegateComponent);
+ QCOMPARE(delegateSpy.count(),1);
+
+ pathView->setDelegate(&delegateComponent);
+ QCOMPARE(delegateSpy.count(),1);
+ delete canvas;
+}
+
+void tst_QQuickPathView::modelChanges()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQuickListModel *alternateModel = canvas->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QVERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
+ QSignalSpy modelSpy(pathView, SIGNAL(modelChanged()));
+
+ pathView->setModel(modelVariant);
+ QCOMPARE(pathView->model(), modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ pathView->setModel(modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ pathView->setModel(QVariant());
+ QCOMPARE(modelSpy.count(),2);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::pathUpdateOnStartChanged()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("pathUpdateOnStartChanged.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQuickPath *path = canvas->rootObject()->findChild<QQuickPath*>("path");
+ QVERIFY(path);
+ QCOMPARE(path->startX(), 400.0);
+ QCOMPARE(path->startY(), 300.0);
+
+ QQuickItem *item = findItem<QQuickItem>(pathView, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), path->startX() - item->width() / 2.0);
+ QCOMPARE(item->y(), path->startY() - item->height() / 2.0);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::package()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("pathview_package.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("photoPathView");
+ QVERIFY(pathView);
+
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation");
+#endif
+
+ QQuickItem *item = findItem<QQuickItem>(pathView, "pathItem");
+ QVERIFY(item);
+ QVERIFY(item->scale() != 1.0);
+
+ delete canvas;
+}
+
+//QTBUG-13017
+void tst_QQuickPathView::emptyModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringListModel model;
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("emptyModel", &model);
+
+ canvas->setSource(testFileUrl("emptymodel.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->offset(), qreal(0.0));
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::closed()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent c(&engine, testFileUrl("openPath.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->isClosed(), false);
+ delete obj;
+ }
+
+ {
+ QQmlComponent c(&engine, testFileUrl("closedPath.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->isClosed(), true);
+ delete obj;
+ }
+}
+
+// QTBUG-14239
+void tst_QQuickPathView::pathUpdate()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("pathUpdate.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQuickItem *item = findItem<QQuickItem>(pathView, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), 150.0);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::visualDataModel()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("vdm.qml"));
+
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->count(), 3);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::undefinedPath()
+{
+ QQmlEngine engine;
+
+ // QPainterPath warnings are only received if QT_NO_DEBUG is not defined
+ if (QLibraryInfo::isDebugBuild()) {
+ QString warning1("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call");
+ QTest::ignoreMessage(QtWarningMsg,qPrintable(warning1));
+
+ QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call");
+ QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2));
+ }
+
+ QQmlComponent c(&engine, testFileUrl("undefinedpath.qml"));
+
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->count(), 3);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::mouseDrag()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("dragpath.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(canvas, qGuiApp->focusWindow());
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ int current = pathview->currentIndex();
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100));
+ QTest::qWait(100);
+
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+
+ QVERIFY(pathview->currentIndex() != current);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100));
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::treeModel()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+ canvas->engine()->rootContext()->setContextProperty("myModel", &model);
+
+ canvas->setSource(testFileUrl("treemodel.qml"));
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+ QCOMPARE(pathview->count(), 3);
+
+ QQuickText *item = findItem<QQuickText>(pathview, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->text(), QLatin1String("Row 1 Item"));
+
+ QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1)));
+ QCOMPARE(pathview->count(), 1);
+
+ QTRY_VERIFY(item = findItem<QQuickText>(pathview, "wrapper", 0));
+ QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item"));
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::changePreferredHighlight()
+{
+ QQuickView *canvas = createView();
+ canvas->setGeometry(0,0,400,200);
+ canvas->setSource(testFileUrl("dragpath.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(canvas, qGuiApp->focusWindow());
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ int current = pathview->currentIndex();
+ QCOMPARE(current, 0);
+
+ QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.5);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+
+ pathview->setPreferredHighlightBegin(0.8);
+ pathview->setPreferredHighlightEnd(0.8);
+ start = path->pointAt(0.8);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentIndex(), 0);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::creationContext()
+{
+ QQuickView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(testFileUrl("creationContext.qml"));
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QQuickItem *item;
+ QVERIFY(item = findItem<QQuickItem>(rootItem, "listItem", 0));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
+// QTBUG-21320
+void tst_QQuickPathView::currentOffsetOnInsertion()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathline.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setPreferredHighlightBegin(0.5);
+ pathview->setPreferredHighlightEnd(0.5);
+
+ QCOMPARE(pathview->count(), model.count());
+
+ model.addItem("item0", "0");
+
+ QCOMPARE(pathview->count(), model.count());
+
+ QQuickRectangle *item = 0;
+ QTRY_VERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 0));
+
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+
+ QPointF start = path->pointAt(0.5);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(item->width()/2);
+ offset.setY(item->height()/2);
+ QCOMPARE(item->pos() + offset, start);
+
+ QSignalSpy currentIndexSpy(pathview, SIGNAL(currentIndexChanged()));
+
+ // insert an item at the beginning
+ model.insertItem(0, "item1", "1");
+ qApp->processEvents();
+
+ QCOMPARE(currentIndexSpy.count(), 1);
+
+ // currentIndex is now 1
+ QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
+
+ // verify that current item (item 1) is still at offset 0.5
+ QCOMPARE(item->pos() + offset, start);
+
+ // insert another item at the beginning
+ model.insertItem(0, "item2", "2");
+ qApp->processEvents();
+
+ QCOMPARE(currentIndexSpy.count(), 2);
+
+ // currentIndex is now 2
+ QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 2));
+
+ // verify that current item (item 2) is still at offset 0.5
+ QCOMPARE(item->pos() + offset, start);
+
+ // verify that remove before current maintains current item
+ model.removeItem(0);
+ qApp->processEvents();
+
+ QCOMPARE(currentIndexSpy.count(), 3);
+
+ // currentIndex is now 1
+ QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
+
+ // verify that current item (item 1) is still at offset 0.5
+ QCOMPARE(item->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::asynchronous()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->setSource(testFileUrl("asyncloader.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootObject);
+
+ QQuickPathView *pathview = 0;
+ while (!pathview) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ pathview = rootObject->findChild<QQuickPathView*>("view");
+ }
+
+ // items will be created one at a time
+ for (int i = 0; i < 5; ++i) {
+ QVERIFY(findItem<QQuickItem>(pathview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(pathview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ // verify positioning
+ QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ pathview->setOffset(1.0);
+
+ for (int i=0; i<5; i++) {
+ QQuickItem *curItem = findItem<QQuickItem>(pathview, "wrapper", i);
+ QPointF itemPos(path->pointAt(0.2 + i*0.2));
+ QCOMPARE(curItem->pos() + offset, itemPos);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::missingPercent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("missingPercent.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->attributeAt("_qfx_percent", 1.0), qreal(1.0));
+ delete obj;
+}
+
+QTEST_MAIN(tst_QQuickPathView)
+
+#include "tst_qquickpathview.moc"
diff --git a/tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml b/tests/auto/quick/qquickpincharea/data/pinchproperties.qml
index 44d116184e..44d116184e 100644
--- a/tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml
+++ b/tests/auto/quick/qquickpincharea/data/pinchproperties.qml
diff --git a/tests/auto/quick/qquickpincharea/qquickpincharea.pro b/tests/auto/quick/qquickpincharea/qquickpincharea.pro
new file mode 100644
index 0000000000..514dd25a5a
--- /dev/null
+++ b/tests/auto/quick/qquickpincharea/qquickpincharea.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickpincharea
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpincharea.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
new file mode 100644
index 0000000000..6e83d41c4e
--- /dev/null
+++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
@@ -0,0 +1,404 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qquickpincharea_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include "../../shared/util.h"
+
+class tst_QQuickPinchArea: public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickPinchArea() : device(0) { }
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void pinchProperties();
+ void scale();
+ void pan();
+ void retouch();
+
+private:
+ QQuickView *createView();
+ QTouchDevice *device;
+};
+void tst_QQuickPinchArea::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ if (!device) {
+ device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+}
+
+void tst_QQuickPinchArea::cleanupTestCase()
+{
+
+}
+void tst_QQuickPinchArea::pinchProperties()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == pinch->target());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+ QSignalSpy targetSpy(pinch, SIGNAL(targetChanged()));
+ pinch->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+ pinch->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+
+ // axis
+ QCOMPARE(pinch->axis(), QQuickPinch::XandYAxis);
+ QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged()));
+ pinch->setAxis(QQuickPinch::XAxis);
+ QCOMPARE(pinch->axis(), QQuickPinch::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+ pinch->setAxis(QQuickPinch::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+
+ // minimum and maximum drag properties
+ QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged()));
+ QSignalSpy xmaxSpy(pinch, SIGNAL(maximumXChanged()));
+ QSignalSpy yminSpy(pinch, SIGNAL(minimumYChanged()));
+ QSignalSpy ymaxSpy(pinch, SIGNAL(maximumYChanged()));
+
+ QCOMPARE(pinch->xmin(), 0.0);
+ QCOMPARE(pinch->xmax(), rootItem->width()-blackRect->width());
+ QCOMPARE(pinch->ymin(), 0.0);
+ QCOMPARE(pinch->ymax(), rootItem->height()-blackRect->height());
+
+ pinch->setXmin(10);
+ pinch->setXmax(10);
+ pinch->setYmin(10);
+ pinch->setYmax(10);
+
+ QCOMPARE(pinch->xmin(), 10.0);
+ QCOMPARE(pinch->xmax(), 10.0);
+ QCOMPARE(pinch->ymin(), 10.0);
+ QCOMPARE(pinch->ymax(), 10.0);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ pinch->setXmin(10);
+ pinch->setXmax(10);
+ pinch->setYmin(10);
+ pinch->setYmax(10);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ // minimum and maximum scale properties
+ QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged()));
+ QSignalSpy scaleMaxSpy(pinch, SIGNAL(maximumScaleChanged()));
+
+ QCOMPARE(pinch->minimumScale(), 1.0);
+ QCOMPARE(pinch->maximumScale(), 2.0);
+
+ pinch->setMinimumScale(0.5);
+ pinch->setMaximumScale(1.5);
+
+ QCOMPARE(pinch->minimumScale(), 0.5);
+ QCOMPARE(pinch->maximumScale(), 1.5);
+
+ QCOMPARE(scaleMinSpy.count(),1);
+ QCOMPARE(scaleMaxSpy.count(),1);
+
+ pinch->setMinimumScale(0.5);
+ pinch->setMaximumScale(1.5);
+
+ QCOMPARE(scaleMinSpy.count(),1);
+ QCOMPARE(scaleMaxSpy.count(),1);
+
+ // minimum and maximum rotation properties
+ QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged()));
+ QSignalSpy rotMaxSpy(pinch, SIGNAL(maximumRotationChanged()));
+
+ QCOMPARE(pinch->minimumRotation(), 0.0);
+ QCOMPARE(pinch->maximumRotation(), 90.0);
+
+ pinch->setMinimumRotation(-90.0);
+ pinch->setMaximumRotation(45.0);
+
+ QCOMPARE(pinch->minimumRotation(), -90.0);
+ QCOMPARE(pinch->maximumRotation(), 45.0);
+
+ QCOMPARE(rotMinSpy.count(),1);
+ QCOMPARE(rotMaxSpy.count(),1);
+
+ pinch->setMinimumRotation(-90.0);
+ pinch->setMaximumRotation(45.0);
+
+ QCOMPARE(rotMinSpy.count(),1);
+ QCOMPARE(rotMaxSpy.count(),1);
+
+ delete canvas;
+}
+
+QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i)
+{
+ QTouchEvent::TouchPoint touchPoint(id);
+ touchPoint.setPos(i->mapFromScene(p));
+ touchPoint.setScreenPos(v->mapToGlobal(p));
+ touchPoint.setScenePos(p);
+ return touchPoint;
+}
+
+void tst_QQuickPinchArea::scale()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+ qApp->processEvents();
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+
+ QPoint p1(80, 80);
+ QPoint p2(100, 100);
+
+ QTest::touchEvent(canvas, device).press(0, p1, canvas);
+ QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
+
+ QCOMPARE(root->property("scale").toReal(), 1.5);
+ QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
+ QCOMPARE(blackRect->scale(), 1.5);
+
+ // scale beyond bound
+ p1 -= QPoint(50,50);
+ p2 += QPoint(50,50);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(blackRect->scale(), 2.0);
+
+ QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
+
+ delete canvas;
+}
+
+void tst_QQuickPinchArea::pan()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+ qApp->processEvents();
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+
+ QPoint p1(80, 80);
+ QPoint p2(100, 100);
+
+ QTest::touchEvent(canvas, device).press(0, p1, canvas);
+ QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
+ p1 += QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+
+ p1 += QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50
+
+ QCOMPARE(blackRect->x(), 60.0);
+ QCOMPARE(blackRect->y(), 60.0);
+
+ // pan x beyond bound
+ p1 += QPoint(100,100);
+ p2 += QPoint(100,100);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(blackRect->x(), 140.0);
+ QCOMPARE(blackRect->y(), 160.0);
+
+ QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
+
+ delete canvas;
+}
+
+// test pinch, release one point, touch again to continue pinch
+void tst_QQuickPinchArea::retouch()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+ qApp->processEvents();
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+
+ QSignalSpy startedSpy(pinchArea, SIGNAL(pinchStarted(QQuickPinchEvent *)));
+ QSignalSpy finishedSpy(pinchArea, SIGNAL(pinchFinished(QQuickPinchEvent *)));
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+
+ QPoint p1(80, 80);
+ QPoint p2(100, 100);
+
+ QTest::touchEvent(canvas, device).press(0, p1, canvas);
+ QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(startedSpy.count(), 1);
+
+ QCOMPARE(root->property("scale").toReal(), 1.5);
+ QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
+ QCOMPARE(blackRect->scale(), 1.5);
+
+ QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
+
+ QCOMPARE(startedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ QTest::touchEvent(canvas, device).stationary(0).release(1, p2, canvas);
+
+ QCOMPARE(startedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 1);
+
+ QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ // Lifting and retouching results in onPinchStarted being called again
+ QCOMPARE(startedSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
+
+ QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
+
+ QCOMPARE(startedSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 1);
+
+ delete canvas;
+}
+
+
+QQuickView *tst_QQuickPinchArea::createView()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_QQuickPinchArea)
+
+#include "tst_qquickpincharea.moc"
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png b/tests/auto/quick/qquickpixmapcache/data/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png
+++ b/tests/auto/quick/qquickpixmapcache/data/exists.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png b/tests/auto/quick/qquickpixmapcache/data/exists1.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png
+++ b/tests/auto/quick/qquickpixmapcache/data/exists1.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png b/tests/auto/quick/qquickpixmapcache/data/exists2.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png
+++ b/tests/auto/quick/qquickpixmapcache/data/exists2.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png b/tests/auto/quick/qquickpixmapcache/data/http/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png b/tests/auto/quick/qquickpixmapcache/data/http/exists1.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists1.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png b/tests/auto/quick/qquickpixmapcache/data/http/exists2.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists2.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png b/tests/auto/quick/qquickpixmapcache/data/http/exists3.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists3.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png b/tests/auto/quick/qquickpixmapcache/data/http/exists4.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists4.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png b/tests/auto/quick/qquickpixmapcache/data/http/exists5.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists5.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png b/tests/auto/quick/qquickpixmapcache/data/http/exists6.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists6.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png b/tests/auto/quick/qquickpixmapcache/data/http/exists7.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists7.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png b/tests/auto/quick/qquickpixmapcache/data/http/exists8.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists8.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png b/tests/auto/quick/qquickpixmapcache/data/massive.png
index bc6cc9e6ca..bc6cc9e6ca 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png
+++ b/tests/auto/quick/qquickpixmapcache/data/massive.png
Binary files differ
diff --git a/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro b/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro
new file mode 100644
index 0000000000..7611e37b49
--- /dev/null
+++ b/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro
@@ -0,0 +1,21 @@
+CONFIG += testcase
+TARGET = tst_qquickpixmapcache
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpixmapcache.cpp \
+ ../../shared/testhttpserver.cpp
+HEADERS += ../../shared/testhttpserver.h
+INCLUDEPATH += ../../shared/
+
+include (../../shared/util.pri)
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib concurrent
diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
new file mode 100644
index 0000000000..855322e376
--- /dev/null
+++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
@@ -0,0 +1,467 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtQuick/private/qquickpixmapcache_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlimageprovider.h>
+#include <QNetworkReply>
+#include "../../shared/util.h"
+#include "testhttpserver.h"
+
+#ifndef QT_NO_CONCURRENT
+#include <qtconcurrentrun.h>
+#include <qfuture.h>
+#endif
+
+#define PIXMAP_DATA_LEAK_TEST 0
+
+class tst_qquickpixmapcache : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickpixmapcache() : server(14452) {}
+
+private slots:
+ void initTestCase();
+ void single();
+ void single_data();
+ void parallel();
+ void parallel_data();
+ void massive();
+ void cancelcrash();
+ void shrinkcache();
+#ifndef QT_NO_CONCURRENT
+ void networkCrash();
+#endif
+ void lockingCrash();
+#if PIXMAP_DATA_LEAK_TEST
+ void dataLeak();
+#endif
+private:
+ QQmlEngine engine;
+ TestHTTPServer server;
+};
+
+static int slotters=0;
+
+class Slotter : public QObject
+{
+ Q_OBJECT
+public:
+ Slotter()
+ {
+ gotslot = false;
+ slotters++;
+ }
+ bool gotslot;
+
+public slots:
+ void got()
+ {
+ gotslot = true;
+ --slotters;
+ if (slotters==0)
+ QTestEventLoop::instance().exitLoop();
+ }
+};
+
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+static const bool localfile_optimized = true;
+#else
+static const bool localfile_optimized = false;
+#endif
+
+
+void tst_qquickpixmapcache::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ server.serveDirectory(testFile("http"));
+}
+
+void tst_qquickpixmapcache::single_data()
+{
+ // Note, since QQuickPixmapCache is shared, tests affect each other!
+ // so use different files fore all test functions.
+
+ QTest::addColumn<QUrl>("target");
+ QTest::addColumn<bool>("incache");
+ QTest::addColumn<bool>("exists");
+ QTest::addColumn<bool>("neterror");
+
+ // File URLs are optimized
+ QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false;
+ QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false;
+ QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false;
+ QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true;
+}
+
+void tst_qquickpixmapcache::single()
+{
+ QFETCH(QUrl, target);
+ QFETCH(bool, incache);
+ QFETCH(bool, exists);
+ QFETCH(bool, neterror);
+
+ QString expectedError;
+ if (neterror) {
+ expectedError = "Error downloading " + target.toString() + " - server replied: Not found";
+ } else if (!exists) {
+ expectedError = "Cannot open: " + target.toString();
+ }
+
+ QQuickPixmap pixmap;
+ QVERIFY(pixmap.width() <= 0); // Check Qt assumption
+
+ pixmap.load(&engine, target);
+
+ if (incache) {
+ QCOMPARE(pixmap.error(), expectedError);
+ if (exists) {
+ QVERIFY(pixmap.status() == QQuickPixmap::Ready);
+ QVERIFY(pixmap.width() > 0);
+ } else {
+ QVERIFY(pixmap.status() == QQuickPixmap::Error);
+ QVERIFY(pixmap.width() <= 0);
+ }
+ } else {
+ QVERIFY(pixmap.width() <= 0);
+
+ Slotter getter;
+ pixmap.connectFinished(&getter, SLOT(got()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(getter.gotslot);
+ if (exists) {
+ QVERIFY(pixmap.status() == QQuickPixmap::Ready);
+ QVERIFY(pixmap.width() > 0);
+ } else {
+ QVERIFY(pixmap.status() == QQuickPixmap::Error);
+ QVERIFY(pixmap.width() <= 0);
+ }
+ QCOMPARE(pixmap.error(), expectedError);
+ }
+}
+
+void tst_qquickpixmapcache::parallel_data()
+{
+ // Note, since QQuickPixmapCache is shared, tests affect each other!
+ // so use different files fore all test functions.
+
+ QTest::addColumn<QUrl>("target1");
+ QTest::addColumn<QUrl>("target2");
+ QTest::addColumn<int>("incache");
+ QTest::addColumn<int>("cancel"); // which one to cancel
+
+ QTest::newRow("local")
+ << testFileUrl("exists1.png")
+ << testFileUrl("exists2.png")
+ << (localfile_optimized ? 2 : 0)
+ << -1;
+
+ QTest::newRow("remote")
+ << QUrl("http://127.0.0.1:14452/exists2.png")
+ << QUrl("http://127.0.0.1:14452/exists3.png")
+ << 0
+ << -1;
+
+ QTest::newRow("remoteagain")
+ << QUrl("http://127.0.0.1:14452/exists2.png")
+ << QUrl("http://127.0.0.1:14452/exists3.png")
+ << 2
+ << -1;
+
+ QTest::newRow("remotecopy")
+ << QUrl("http://127.0.0.1:14452/exists4.png")
+ << QUrl("http://127.0.0.1:14452/exists4.png")
+ << 0
+ << -1;
+
+ QTest::newRow("remotecopycancel")
+ << QUrl("http://127.0.0.1:14452/exists5.png")
+ << QUrl("http://127.0.0.1:14452/exists5.png")
+ << 0
+ << 0;
+}
+
+void tst_qquickpixmapcache::parallel()
+{
+ QFETCH(QUrl, target1);
+ QFETCH(QUrl, target2);
+ QFETCH(int, incache);
+ QFETCH(int, cancel);
+
+ QList<QUrl> targets;
+ targets << target1 << target2;
+
+ QList<QQuickPixmap *> pixmaps;
+ QList<bool> pending;
+ QList<Slotter*> getters;
+
+ for (int i=0; i<targets.count(); ++i) {
+ QUrl target = targets.at(i);
+ QQuickPixmap *pixmap = new QQuickPixmap;
+
+ pixmap->load(&engine, target);
+
+ QVERIFY(pixmap->status() != QQuickPixmap::Error);
+ pixmaps.append(pixmap);
+ if (pixmap->isReady()) {
+ QVERIFY(pixmap->width() > 0);
+ getters.append(0);
+ pending.append(false);
+ } else {
+ QVERIFY(pixmap->width() <= 0);
+ getters.append(new Slotter);
+ pixmap->connectFinished(getters[i], SLOT(got()));
+ pending.append(true);
+ }
+ }
+
+ QCOMPARE(incache+slotters, targets.count());
+
+ if (cancel >= 0) {
+ pixmaps.at(cancel)->clear(getters[cancel]);
+ slotters--;
+ }
+
+ if (slotters) {
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ }
+
+ for (int i=0; i<targets.count(); ++i) {
+ QQuickPixmap *pixmap = pixmaps[i];
+
+ if (i == cancel) {
+ QVERIFY(!getters[i]->gotslot);
+ } else {
+ if (pending[i])
+ QVERIFY(getters[i]->gotslot);
+
+ QVERIFY(pixmap->isReady());
+ QVERIFY(pixmap->width() > 0);
+ delete getters[i];
+ }
+ }
+
+ qDeleteAll(pixmaps);
+}
+
+void tst_qquickpixmapcache::massive()
+{
+ QQmlEngine engine;
+ QUrl url = testFileUrl("massive.png");
+
+ // Confirm that massive images remain in the cache while they are
+ // in use by the application.
+ {
+ qint64 cachekey = 0;
+ QQuickPixmap p(&engine, url);
+ QVERIFY(p.isReady());
+ QVERIFY(p.image().size() == QSize(10000, 1000));
+ cachekey = p.image().cacheKey();
+
+ QQuickPixmap p2(&engine, url);
+ QVERIFY(p2.isReady());
+ QVERIFY(p2.image().size() == QSize(10000, 1000));
+
+ QVERIFY(p2.image().cacheKey() == cachekey);
+ }
+
+ // Confirm that massive images are removed from the cache when
+ // they become unused
+ {
+ qint64 cachekey = 0;
+ {
+ QQuickPixmap p(&engine, url);
+ QVERIFY(p.isReady());
+ QVERIFY(p.image().size() == QSize(10000, 1000));
+ cachekey = p.image().cacheKey();
+ }
+
+ QQuickPixmap p2(&engine, url);
+ QVERIFY(p2.isReady());
+ QVERIFY(p2.image().size() == QSize(10000, 1000));
+
+ QVERIFY(p2.image().cacheKey() != cachekey);
+ }
+}
+
+// QTBUG-12729
+void tst_qquickpixmapcache::cancelcrash()
+{
+ QUrl url("http://127.0.0.1:14452/cancelcrash_notexist.png");
+ for (int ii = 0; ii < 1000; ++ii) {
+ QQuickPixmap pix(&engine, url);
+ }
+}
+
+class MyPixmapProvider : public QQmlImageProvider
+{
+public:
+ MyPixmapProvider()
+ : QQmlImageProvider(Pixmap) {}
+
+ virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) {
+ Q_UNUSED(d)
+ QPixmap pix(800, 600);
+ pix.fill(Qt::red);
+ return pix;
+ }
+};
+
+// QTBUG-13345
+void tst_qquickpixmapcache::shrinkcache()
+{
+ QQmlEngine engine;
+ engine.addImageProvider(QLatin1String("mypixmaps"), new MyPixmapProvider);
+
+ for (int ii = 0; ii < 4000; ++ii) {
+ QUrl url("image://mypixmaps/" + QString::number(ii));
+ QQuickPixmap p(&engine, url);
+ }
+}
+
+#ifndef QT_NO_CONCURRENT
+
+void createNetworkServer()
+{
+ QEventLoop eventLoop;
+ TestHTTPServer server(14453);
+ server.serveDirectory(QQmlDataTest::instance()->testFile("http"));
+ QTimer::singleShot(100, &eventLoop, SLOT(quit()));
+ eventLoop.exec();
+}
+
+#ifndef QT_NO_CONCURRENT
+// QT-3957
+void tst_qquickpixmapcache::networkCrash()
+{
+ QFuture<void> future = QtConcurrent::run(createNetworkServer);
+ QQmlEngine engine;
+ for (int ii = 0; ii < 100 ; ++ii) {
+ QQuickPixmap* pixmap = new QQuickPixmap;
+ pixmap->load(&engine, QUrl(QString("http://127.0.0.1:14453/exists.png")));
+ QTest::qSleep(1);
+ pixmap->clear();
+ delete pixmap;
+ }
+ future.cancel();
+}
+#endif
+
+#endif
+
+// QTBUG-22125
+void tst_qquickpixmapcache::lockingCrash()
+{
+ TestHTTPServer server(14453);
+ server.serveDirectory(testFile("http"), TestHTTPServer::Delay);
+
+ {
+ QQuickPixmap* p = new QQuickPixmap;
+ {
+ QQmlEngine e;
+ p->load(&e, QUrl(QString("http://127.0.0.1:14453/exists6.png")));
+ }
+ p->clear();
+ QVERIFY(p->isNull());
+ delete p;
+ }
+}
+
+
+#if PIXMAP_DATA_LEAK_TEST
+// This test should not be enabled by default as it
+// produces spurious output in the expected case.
+#include <QtQuick/QQuickView>
+class DataLeakView : public QQuickView
+{
+ Q_OBJECT
+
+public:
+ explicit DataLeakView() : QQuickView()
+ {
+ setSource(testFileUrl("dataLeak.qml"));
+ }
+
+ void showFor2Seconds()
+ {
+ showFullScreen();
+ QTimer::singleShot(2000, this, SIGNAL(ready()));
+ }
+
+signals:
+ void ready();
+};
+
+// QTBUG-22742
+Q_GLOBAL_STATIC(QQuickPixmap, dataLeakPixmap)
+void tst_qquickpixmapcache::dataLeak()
+{
+ // Should not leak cached QQuickPixmapData.
+ // Unfortunately, since the QQuickPixmapStore
+ // is a global static, and it releases the cache
+ // entries on dtor (application exit), we must use
+ // valgrind to determine whether it leaks or not.
+ QQuickPixmap *p1 = new QQuickPixmap;
+ QQuickPixmap *p2 = new QQuickPixmap;
+ {
+ QScopedPointer<DataLeakView> test(new DataLeakView);
+ test->showFor2Seconds();
+ dataLeakPixmap()->load(test->engine(), testFileUrl("exists.png"));
+ p1->load(test->engine(), testFileUrl("exists.png"));
+ p2->load(test->engine(), testFileUrl("exists2.png"));
+ QTest::qWait(2005); // 2 seconds + a few more millis.
+ }
+
+ // When the (global static) dataLeakPixmap is deleted, it
+ // shouldn't attempt to dereference a QQuickPixmapData
+ // which has been deleted by the QQuickPixmapStore
+ // destructor.
+}
+#endif
+#undef PIXMAP_DATA_LEAK_TEST
+
+QTEST_MAIN(tst_qquickpixmapcache)
+
+#include "tst_qquickpixmapcache.moc"
diff --git a/tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml b/tests/auto/quick/qquickpositioners/data/allInvisible.qml
index 5894171434..5894171434 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml
+++ b/tests/auto/quick/qquickpositioners/data/allInvisible.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml
index 4c667aa205..4c667aa205 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml
index 894749dc16..894749dc16 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml
index e7f9a63e2a..e7f9a63e2a 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml
index 2094309b9f..2094309b9f 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml
index 212a26b431..212a26b431 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml b/tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml
index c32b78676c..c32b78676c 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml
+++ b/tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml b/tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml
index a7d3ee13c7..a7d3ee13c7 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml
+++ b/tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/flowtest.qml b/tests/auto/quick/qquickpositioners/data/flowtest.qml
index 40b042dd79..40b042dd79 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/flowtest.qml
+++ b/tests/auto/quick/qquickpositioners/data/flowtest.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml b/tests/auto/quick/qquickpositioners/data/grid-animated.qml
index b8ee8f9a52..b8ee8f9a52 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml
+++ b/tests/auto/quick/qquickpositioners/data/grid-animated.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml b/tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml
index 49bbd337e7..49bbd337e7 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml
+++ b/tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml b/tests/auto/quick/qquickpositioners/data/grid-spacing.qml
index 535a39037f..535a39037f 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml
+++ b/tests/auto/quick/qquickpositioners/data/grid-spacing.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml b/tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml
index 45559aab5d..45559aab5d 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml
+++ b/tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/gridtest.qml b/tests/auto/quick/qquickpositioners/data/gridtest.qml
index 50bec1377b..50bec1377b 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/gridtest.qml
+++ b/tests/auto/quick/qquickpositioners/data/gridtest.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml b/tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml
index a252f279c3..a252f279c3 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml
+++ b/tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml b/tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml
index 8723ffc78f..8723ffc78f 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml
+++ b/tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml b/tests/auto/quick/qquickpositioners/data/horizontal-animated.qml
index a88c26b66c..a88c26b66c 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml
+++ b/tests/auto/quick/qquickpositioners/data/horizontal-animated.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml b/tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml
index c6ff75ac6b..c6ff75ac6b 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml
+++ b/tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal.qml b/tests/auto/quick/qquickpositioners/data/horizontal.qml
index 235ee78c9b..235ee78c9b 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/horizontal.qml
+++ b/tests/auto/quick/qquickpositioners/data/horizontal.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml b/tests/auto/quick/qquickpositioners/data/propertychangestest.qml
index c9fd62b012..c9fd62b012 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml
+++ b/tests/auto/quick/qquickpositioners/data/propertychangestest.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml b/tests/auto/quick/qquickpositioners/data/rectangleComponent.qml
index de1bb99593..de1bb99593 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml
+++ b/tests/auto/quick/qquickpositioners/data/rectangleComponent.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml b/tests/auto/quick/qquickpositioners/data/repeatertest.qml
index d90e1cf160..d90e1cf160 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml
+++ b/tests/auto/quick/qquickpositioners/data/repeatertest.qml
diff --git a/tests/auto/quick/qquickpositioners/data/transitions.qml b/tests/auto/quick/qquickpositioners/data/transitions.qml
new file mode 100644
index 0000000000..54f5705c68
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/transitions.qml
@@ -0,0 +1,196 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 500
+
+ property int duration: 50
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ function checkPos(x, y, name) {
+ if (Qt.point(x, y) == targetItems_transitionFrom)
+ model_targetItems_transitionFrom.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+
+ Transition {
+ id: targetTransition
+ enabled: enableAddTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ root.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ root.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ root.targetTrans_targetItems.push(root.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
+ }
+
+ ScriptAction { script: root.targetTransitionsDone += 1 }
+ }
+ }
+
+ Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ root.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ root.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ root.displacedTrans_targetItems.push(root.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
+ NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: root.displaceTransitionsDone += 1 }
+ }
+
+ }
+
+ Row {
+ objectName: "row"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ Repeater {
+ objectName: "repeater"
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*5
+ height: 30 + index*5
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ add: targetTransition
+ move: displaced
+ }
+
+ Column {
+ objectName: "column"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ Repeater {
+ objectName: "repeater"
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*5
+ height: 30 + index*5
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ add: targetTransition
+ move: displaced
+ }
+
+ Grid {
+ objectName: "grid"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ Repeater {
+ objectName: "repeater"
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*5
+ height: 30 + index*5
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ add: targetTransition
+ move: displaced
+ }
+
+ Flow {
+ objectName: "flow"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ Repeater {
+ objectName: "repeater"
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*5
+ height: 30 + index*5
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.x + " " + parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ add: targetTransition
+ move: displaced
+ }
+}
+
diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml b/tests/auto/quick/qquickpositioners/data/vertical-animated.qml
index ecf593cd70..ecf593cd70 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml
+++ b/tests/auto/quick/qquickpositioners/data/vertical-animated.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml b/tests/auto/quick/qquickpositioners/data/vertical-spacing.qml
index 7087961651..7087961651 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml
+++ b/tests/auto/quick/qquickpositioners/data/vertical-spacing.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical.qml b/tests/auto/quick/qquickpositioners/data/vertical.qml
index 0c3a81f008..0c3a81f008 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/vertical.qml
+++ b/tests/auto/quick/qquickpositioners/data/vertical.qml
diff --git a/tests/auto/quick/qquickpositioners/qquickpositioners.pro b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
new file mode 100644
index 0000000000..563379652b
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickpositioners
+SOURCES += tst_qquickpositioners.cpp
+
+include (../shared/util.pri)
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
new file mode 100644
index 0000000000..8f517a4fe3
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -0,0 +1,1927 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <private/qlistmodelinterface_p.h>
+#include <QtQuick/qquickview.h>
+#include <qqmlengine.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquickpositioners_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
+#include <private/qquickitem_p.h>
+#include <qqmlexpression.h>
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+#include "../../shared/util.h"
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickpositioners : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickpositioners();
+
+private slots:
+ void test_horizontal();
+ void test_horizontal_rtl();
+ void test_horizontal_spacing();
+ void test_horizontal_spacing_rightToLeft();
+ void test_horizontal_animated();
+ void test_horizontal_animated_rightToLeft();
+ void test_horizontal_animated_disabled();
+ void test_vertical();
+ void test_vertical_spacing();
+ void test_vertical_animated();
+ void test_grid();
+ void test_grid_topToBottom();
+ void test_grid_rightToLeft();
+ void test_grid_spacing();
+ void test_grid_row_column_spacing();
+ void test_grid_animated();
+ void test_grid_animated_rightToLeft();
+ void test_grid_zero_columns();
+ void test_propertychanges();
+ void test_repeater();
+ void test_flow();
+ void test_flow_rightToLeft();
+ void test_flow_topToBottom();
+ void test_flow_resize();
+ void test_flow_resize_rightToLeft();
+ void test_flow_implicit_resize();
+ void test_conflictinganchors();
+ void test_mirroring();
+ void test_allInvisible();
+ void test_attachedproperties();
+ void test_attachedproperties_data();
+ void test_attachedproperties_dynamic();
+ void addTransitions_row();
+ void addTransitions_row_data();
+ void addTransitions_column();
+ void addTransitions_column_data();
+ void addTransitions_grid();
+ void addTransitions_grid_data();
+ void addTransitions_flow();
+ void addTransitions_flow_data();
+ void moveTransitions_row();
+ void moveTransitions_row_data();
+ void moveTransitions_column();
+ void moveTransitions_column_data();
+ void moveTransitions_grid();
+ void moveTransitions_grid_data();
+ void moveTransitions_flow();
+ void moveTransitions_flow_data();
+
+private:
+ QQuickView *createView(const QString &filename, bool wait=true);
+
+ void addTransitions(const QString &positionerObjectName);
+ void addTransitions_data();
+ void moveTransitions(const QString &positionerObjectName);
+ void moveTransitions_data();
+ void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
+ void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
+ void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
+ void checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize);
+};
+
+void tst_qquickpositioners::addTransitions_row()
+{
+ addTransitions("row");
+}
+
+void tst_qquickpositioners::addTransitions_row_data()
+{
+ addTransitions_data();
+}
+
+void tst_qquickpositioners::addTransitions_column()
+{
+ addTransitions("column");
+}
+
+void tst_qquickpositioners::addTransitions_column_data()
+{
+ addTransitions_data();
+}
+
+void tst_qquickpositioners::addTransitions_grid()
+{
+ addTransitions("grid");
+}
+
+void tst_qquickpositioners::addTransitions_grid_data()
+{
+ // don't use addTransitions_data() because grid displaces items differently
+ // (adding items further down the grid can cause displace transitions at
+ // previous indexes, since grid is auto-resized to tightly fit all of its items)
+
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("insertionIndex");
+ QTest::addColumn<int>("insertionCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9);
+ QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7);
+
+ QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9);
+ QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9);
+}
+
+void tst_qquickpositioners::addTransitions_flow()
+{
+ addTransitions("flow");
+}
+
+void tst_qquickpositioners::addTransitions_flow_data()
+{
+ addTransitions_data();
+}
+
+void tst_qquickpositioners::moveTransitions_row()
+{
+ moveTransitions("row");
+}
+
+void tst_qquickpositioners::moveTransitions_row_data()
+{
+ moveTransitions_data();
+}
+
+void tst_qquickpositioners::moveTransitions_column()
+{
+ moveTransitions("column");
+}
+
+void tst_qquickpositioners::moveTransitions_column_data()
+{
+ moveTransitions_data();
+}
+
+void tst_qquickpositioners::moveTransitions_grid()
+{
+ moveTransitions("grid");
+}
+
+void tst_qquickpositioners::moveTransitions_grid_data()
+{
+ // don't use moveTransitions_data() because grid displaces items differently
+ // (removing items further down the grid can cause displace transitions at
+ // previous indexes, since grid is auto-resized to tightly fit all of its items)
+
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<ListChange>("change");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
+ QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(2, 3) + ListRange(5, 9);
+ QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange(2, 3) + ListRange(6, 7);
+
+ QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
+ QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(1, 3) + ListRange(7, 9);
+ QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange(1, 3) + ListRange(5, 6);
+}
+
+void tst_qquickpositioners::moveTransitions_flow()
+{
+ moveTransitions("flow");
+}
+
+void tst_qquickpositioners::moveTransitions_flow_data()
+{
+ moveTransitions_data();
+}
+
+tst_qquickpositioners::tst_qquickpositioners()
+{
+}
+
+void tst_qquickpositioners::test_horizontal()
+{
+ QQuickView *canvas = createView(testFile("horizontal.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 110.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_rtl()
+{
+ QQuickView *canvas = createView(testFile("horizontal.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 60.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 40.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 110.0);
+ QCOMPARE(row->height(), 50.0);
+
+ // Change the width of the row and check that items stay to the right
+ row->setWidth(200);
+ QTRY_COMPARE(one->x(), 150.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 130.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_spacing()
+{
+ QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 60.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 130.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 80.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 00.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 130.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_animated()
+{
+ QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+ QCOMPARE(row->width(), 100.0);
+ QCOMPARE(row->height(), 50.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(three->y(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+ QTRY_COMPARE(row->width(), 150.0);
+ QTRY_COMPARE(row->height(), 50.0);
+
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(two->x() >= -100.0 && two->x() < 50.0);
+ QVERIFY(three->x() >= 50.0 && three->x() < 100.0);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+ QCOMPARE(row->width(), 100.0);
+ QCOMPARE(row->height(), 50.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->x(), 50.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 0.0);
+ QTRY_COMPARE(three->y(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+
+ // New size should propagate after visible change
+ QTRY_COMPARE(row->width(), 150.0);
+ QTRY_COMPARE(row->height(), 50.0);
+
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(one->x() >= 50.0 && one->x() < 100);
+ QVERIFY(two->x() >= -100.0 && two->x() < 50.0);
+
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(two->x(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_animated_disabled()
+{
+ QQuickView *canvas = createView(testFile("horizontal-animated-disabled.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+
+ qApp->processEvents();
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->isVisible(), false);
+ QCOMPARE(two->x(), -100.0);//Not 'in' yet
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QTRY_COMPARE(row->width(), 150.0);
+ QTRY_COMPARE(row->height(), 50.0);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, insertionIndex);
+ QFETCH(int, insertionCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ QPointF targetItems_transitionFrom(-50, -50);
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionFrom;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = QQuickViewTestUtil::createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("enableAddTransition", true);
+ ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFile("transitions.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ QQuickItem *positioner = canvas->rootObject()->findChild<QQuickItem*>(positionerObjectName);
+ QVERIFY(positioner);
+ positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model));
+
+ QList<QPair<QString, QString> > targetData;
+ QList<int> targetIndexes;
+ for (int i=0; i<model.count(); i++) {
+ targetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(positioner, "wrapper", targetIndexes);
+
+ // check initial add transition
+ // (positioners run the add transition on all items that are initially created for the view)
+ QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), initialItemCount);
+ QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), 0);
+ model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems);
+
+ model_targetItems_transitionFrom.clear();
+ canvas->rootObject()->setProperty("targetTransitionsDone", 0);
+ canvas->rootObject()->setProperty("targetTrans_items", QVariantMap());
+ canvas->rootObject()->setProperty("targetTrans_targetIndexes", QVariantList());
+ canvas->rootObject()->setProperty("targetTrans_targetItems", QVariantList());
+
+ // do insertion
+ targetData.clear();
+ targetIndexes.clear();
+ for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
+ targetData << qMakePair(QString("New item %1").arg(i), QString(""));
+ targetIndexes << i;
+ }
+ model.insertItems(insertionIndex, targetData);
+ QTRY_COMPARE(model.count(), positioner->property("count").toInt());
+
+ targetItems = findItems<QQuickItem>(positioner, "wrapper", targetIndexes);
+
+ QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), targetData.count());
+ QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count());
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
+ matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(canvas->rootObject()->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+
+ checkItemPositions(positioner, &model, 5.0); // XXX fetch from qml?
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::addTransitions_data()
+{
+ // If this data changes, update addTransitions_grid_data() also
+
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("insertionIndex");
+ QTest::addColumn<int>("insertionCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(5, 9);
+ QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange();
+
+ QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(5, 9);
+ QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange();
+}
+
+void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(ListChange, change);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ QPointF targetItems_transitionFrom(-50, -50);
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionFrom;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = QQuickViewTestUtil::createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("enableAddTransition", false);
+ ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFile("transitions.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ QQuickItem *positioner = canvas->rootObject()->findChild<QQuickItem*>(positionerObjectName);
+ QVERIFY(positioner);
+ positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model));
+ QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
+
+ switch (change.type) {
+ case ListChange::Removed:
+ model.removeItems(change.index, change.count);
+ QTRY_COMPARE(model.count(), positioner->property("count").toInt());
+ break;
+ case ListChange::Moved:
+ model.moveItems(change.index, change.to, change.count);
+ QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
+ break;
+ case ListChange::Inserted:
+ case ListChange::SetCurrent:
+ case ListChange::SetContentY:
+ QVERIFY(false);
+ break;
+ }
+
+ QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count());
+ QCOMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), 0);
+
+ // check the target and displaced items were animated
+ QCOMPARE(model_targetItems_transitionFrom.count(), 0);
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ QCOMPARE(canvas->rootObject()->property("targetTrans_items").toMap().count(), 0);
+ QCOMPARE(canvas->rootObject()->property("targetTrans_targetIndexes").toList().count(), 0);
+ QCOMPARE(canvas->rootObject()->property("targetTrans_targetItems").toList().count(), 0);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes;
+ if (change.type == ListChange::Inserted)
+ displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count);
+ else if (change.type == ListChange::Moved)
+ displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, change.index, change.to, change.count);
+ else if (change.type == ListChange::Removed)
+ displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count);
+ else
+ QVERIFY(false);
+ matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes);
+
+ QVariantList listOfEmptyIntLists;
+ for (int i=0; i<displacedIndexes.count(); i++)
+ listOfEmptyIntLists << QVariant::fromValue(QList<int>());
+ QCOMPARE(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), listOfEmptyIntLists);
+ QVariantList listOfEmptyObjectLists;
+ for (int i=0; i<displacedIndexes.count(); i++)
+ listOfEmptyObjectLists.insert(listOfEmptyObjectLists.count(), QVariantList());
+ QCOMPARE(canvas->rootObject()->property("displacedTrans_targetItems").toList(), listOfEmptyObjectLists);
+ }
+
+ checkItemPositions(positioner, &model, 5.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::moveTransitions_data()
+{
+ // If this data changes, update moveTransitions_grid_data() also
+
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<ListChange>("change");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
+ QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(5, 9);
+ QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange();
+
+ QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
+ QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(7, 9);
+ QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange();
+}
+
+
+void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize)
+{
+ QVERIFY(model->count() > 0);
+ qreal padding = 0;
+ qreal currentSize = 30;
+ qreal rowX = 0;
+ qreal rowY = 0;
+
+ for (int i=0; i<model->count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(positioner, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+
+ QCOMPARE(item->width(), currentSize);
+ QCOMPARE(item->height(), currentSize);
+
+ if (qobject_cast<QQuickRow*>(positioner)) {
+ QCOMPARE(item->x(), (i * 30.0) + padding);
+ QCOMPARE(item->y(), 0.0);
+ } else if (qobject_cast<QQuickColumn*>(positioner)) {
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), (i * 30.0) + padding);
+ } else if (qobject_cast<QQuickGrid*>(positioner)) {
+ int columns = 4;
+ int rows = qCeil(model->count() / qreal(columns));
+ int lastMatchingRowIndex = (rows * columns) - (columns - i%columns);
+ if (lastMatchingRowIndex >= model->count())
+ lastMatchingRowIndex -= columns;
+ if (i % columns > 0) {
+ QQuickItem *finalAlignedRowItem = findItem<QQuickItem>(positioner, "wrapper", lastMatchingRowIndex);
+ QVERIFY(finalAlignedRowItem);
+ QCOMPARE(item->x(), finalAlignedRowItem->x());
+ } else {
+ QCOMPARE(item->x(), 0.0);
+ }
+ if (i / columns > 0) {
+ QQuickItem *prevRowLastItem = findItem<QQuickItem>(positioner, "wrapper", (i/columns * columns) - 1);
+ QVERIFY(prevRowLastItem);
+ QCOMPARE(item->y(), prevRowLastItem->y() + prevRowLastItem->height());
+ } else {
+ QCOMPARE(item->y(), 0.0);
+ }
+ } else if (qobject_cast<QQuickFlow*>(positioner)) {
+ if (rowX + item->width() > positioner->width()) {
+ QQuickItem *prevItem = findItem<QQuickItem>(positioner, "wrapper", i-1);
+ QVERIFY(prevItem);
+ rowX = 0;
+ rowY = prevItem->y() + prevItem->height();
+ }
+ QCOMPARE(item->x(), rowX);
+ QCOMPARE(item->y(), rowY);
+ rowX += item->width();
+ } else {
+ QVERIFY2(false, "Unknown positioner type");
+ }
+ QQuickText *name = findItem<QQuickText>(positioner, "name", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model->name(i));
+
+ padding += i * incrementalSize;
+ currentSize += incrementalSize;
+ }
+}
+
+void tst_qquickpositioners::test_vertical()
+{
+ QQuickView *canvas = createView(testFile("vertical.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 60.0);
+
+ QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_vertical_spacing()
+{
+ QQuickView *canvas = createView(testFile("vertical-spacing.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 60.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 80.0);
+
+ QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
+ QCOMPARE(column->height(), 100.0);
+ QCOMPARE(column->width(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_vertical_animated()
+{
+ QQuickView *canvas = createView(testFile("vertical-animated.qml"), false);
+
+ //Note that they animate in
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->y(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 100.0);
+ QCOMPARE(column->width(), 50.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->x(), 0.0);
+ QTRY_COMPARE(three->y(), 50.0);
+ QTRY_COMPARE(three->x(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+ QTRY_COMPARE(column->height(), 150.0);
+ QTRY_COMPARE(column->width(), 50.0);
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(two->y() >= -100.0 && two->y() < 50.0);
+ QVERIFY(three->y() >= 50.0 && three->y() < 100.0);
+
+ QTRY_COMPARE(two->y(), 50.0);
+ QTRY_COMPARE(three->y(), 100.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid()
+{
+ QQuickView *canvas = createView(testFile("gridtest.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
+ QCOMPARE(grid->flow(), QQuickGrid::LeftToRight);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_topToBottom()
+{
+ QQuickView *canvas = createView(testFile("grid-toptobottom.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 100.0);
+ QCOMPARE(four->x(), 50.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
+ QCOMPARE(grid->flow(), QQuickGrid::TopToBottom);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 120.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("gridtest.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 50.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 30.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 50.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 40.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
+ QCOMPARE(grid->layoutDirection(), Qt::RightToLeft);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ // Change the width of the grid and check that items stay to the right
+ grid->setWidth(200);
+ QTRY_COMPARE(one->x(), 150.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 130.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 100.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 150.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 140.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_spacing()
+{
+ QQuickView *canvas = createView(testFile("grid-spacing.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 54.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 78.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 54.0);
+ QCOMPARE(five->x(), 54.0);
+ QCOMPARE(five->y(), 54.0);
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 128.0);
+ QCOMPARE(grid->height(), 104.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_row_column_spacing()
+{
+ QQuickView *canvas = createView(testFile("grid-row-column-spacing.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 61.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 92.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 57.0);
+ QCOMPARE(five->x(), 61.0);
+ QCOMPARE(five->y(), 57.0);
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 142.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_animated()
+{
+ QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ //Note that all animate in
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+ QCOMPARE(five->x(), -100.0);
+ QCOMPARE(five->y(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QVERIFY(grid);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 100.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 0.0);
+ QCOMPARE(five->y(), 50.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_animated_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ //Note that all animate in
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+ QCOMPARE(five->x(), -100.0);
+ QCOMPARE(five->y(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QVERIFY(grid);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 100.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(one->x(), 100.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 100.0);
+ QCOMPARE(five->y(), 50.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 0.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_zero_columns()
+{
+ QQuickView *canvas = createView(testFile("gridzerocolumns.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 120.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 0.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 170.0);
+ QCOMPARE(grid->height(), 60.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_propertychanges()
+{
+ QQuickView *canvas = createView(testFile("propertychangestest.qml"));
+
+ QQuickGrid *grid = qobject_cast<QQuickGrid*>(canvas->rootObject());
+ QVERIFY(grid != 0);
+ QQuickTransition *rowTransition = canvas->rootObject()->findChild<QQuickTransition*>("rowTransition");
+ QQuickTransition *columnTransition = canvas->rootObject()->findChild<QQuickTransition*>("columnTransition");
+
+ QSignalSpy addSpy(grid, SIGNAL(addChanged()));
+ QSignalSpy moveSpy(grid, SIGNAL(moveChanged()));
+ QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged()));
+ QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged()));
+
+ QVERIFY(grid);
+ QVERIFY(rowTransition);
+ QVERIFY(columnTransition);
+ QCOMPARE(grid->add(), columnTransition);
+ QCOMPARE(grid->move(), columnTransition);
+ QCOMPARE(grid->columns(), 4);
+ QCOMPARE(grid->rows(), -1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(grid->add(), rowTransition);
+ QCOMPARE(grid->move(), rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(0);
+ grid->setMove(0);
+ QCOMPARE(addSpy.count(),2);
+ QCOMPARE(moveSpy.count(),2);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(grid->columns(), -1);
+ QCOMPARE(grid->rows(), 3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(2);
+ grid->setRows(2);
+ QCOMPARE(columnsSpy.count(),2);
+ QCOMPARE(rowsSpy.count(),2);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_repeater()
+{
+ QQuickView *canvas = createView(testFile("repeatertest.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 100.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow()
+{
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 70.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 70.0);
+
+ QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->width(), 90.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 40.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 20.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 40.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 40.0);
+ QCOMPARE(four->y(), 70.0);
+ QCOMPARE(five->x(), 30.0);
+ QCOMPARE(five->y(), 70.0);
+
+ QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->width(), 90.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_topToBottom()
+{
+ QQuickView *canvas = createView(testFile("flowtest-toptobottom.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 100.0);
+ QCOMPARE(four->y(), 00.0);
+ QCOMPARE(five->x(), 100.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->height(), 90.0);
+ QCOMPARE(flow->width(), 150.0);
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QVERIFY(flow);
+ QCOMPARE(flow->height(), 90.0);
+ QCOMPARE(flow->width(), 150.0);
+
+ QCOMPARE(one->x(), 100.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 80.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 40.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_resize()
+{
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+ root->setWidth(125);
+ root->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 70.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_resize_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+ root->setWidth(125);
+ root->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QTRY_VERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 75.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 55.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 5.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 75.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 65.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_implicit_resize()
+{
+ QQuickView *canvas = createView(testFile("flow-testimplicitsize.qml"));
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlow *flow = canvas->rootObject()->findChild<QQuickFlow*>("flow");
+ QVERIFY(flow != 0);
+
+ QCOMPARE(flow->width(), 100.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 0);
+ QCOMPARE(flow->flow(), QQuickFlow::LeftToRight);
+ QCOMPARE(flow->width(), 220.0);
+ QCOMPARE(flow->height(), 50.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 1);
+ QCOMPARE(flow->flow(), QQuickFlow::TopToBottom);
+ QCOMPARE(flow->width(), 100.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 2);
+ QCOMPARE(flow->layoutDirection(), Qt::RightToLeft);
+ QCOMPARE(flow->width(), 220.0);
+ QCOMPARE(flow->height(), 50.0);
+
+ delete canvas;
+}
+
+QString warningMessage;
+
+void interceptWarnings(QtMsgType type, const char *msg)
+{
+ Q_UNUSED( type );
+ warningMessage = msg;
+}
+
+void tst_qquickpositioners::test_conflictinganchors()
+{
+ QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings);
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+
+ component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nRow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function."));
+ delete item;
+
+ component.setData("import QtQuick 2.0\nFlow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function."));
+ qInstallMsgHandler(oldMsgHandler);
+ delete item;
+}
+
+void tst_qquickpositioners::test_mirroring()
+{
+ QList<QString> qmlFiles;
+ qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml";
+ QList<QString> objectNames;
+ objectNames << "one" << "two" << "three" << "four" << "five";
+
+ foreach (const QString qmlFile, qmlFiles) {
+ QQuickView *canvasA = createView(testFile(qmlFile));
+ QQuickItem *rootA = qobject_cast<QQuickItem*>(canvasA->rootObject());
+
+ QQuickView *canvasB = createView(testFile(qmlFile));
+ QQuickItem *rootB = qobject_cast<QQuickItem*>(canvasB->rootObject());
+
+ rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
+
+ // LTR != RTL
+ foreach (const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
+ QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
+ QTRY_VERIFY(itemA->x() != itemB->x());
+ }
+
+ QQmlProperty enabledProp(rootB, "LayoutMirroring.enabled", qmlContext(rootB));
+ enabledProp.write(true);
+ QQmlProperty inheritProp(rootB, "LayoutMirroring.childrenInherit", qmlContext(rootB));
+ inheritProp.write(true);
+
+ // RTL == mirror
+ foreach (const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
+ QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
+ QTRY_COMPARE(itemA->x(), itemB->x());
+ }
+
+ rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight
+ rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
+
+ // LTR == RTL + mirror
+ foreach (const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
+ QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
+ QTRY_COMPARE(itemA->x(), itemB->x());
+ }
+ delete canvasA;
+ delete canvasB;
+ }
+}
+
+void tst_qquickpositioners::test_allInvisible()
+{
+ //QTBUG-19361
+ QQuickView *canvas = createView(testFile("allInvisible.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+
+ QQuickRow *row = canvas->rootObject()->findChild<QQuickRow*>("row");
+ QVERIFY(row != 0);
+ QVERIFY(row->width() == 0);
+ QVERIFY(row->height() == 0);
+ QQuickColumn *column = canvas->rootObject()->findChild<QQuickColumn*>("column");
+ QVERIFY(column != 0);
+ QVERIFY(column->width() == 0);
+ QVERIFY(column->height() == 0);
+}
+
+void tst_qquickpositioners::test_attachedproperties()
+{
+ QFETCH(QString, filename);
+
+ QQuickView *canvas = createView(filename);
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickRectangle *greenRect = canvas->rootObject()->findChild<QQuickRectangle *>("greenRect");
+ QVERIFY(greenRect != 0);
+
+ int posIndex = greenRect->property("posIndex").toInt();
+ QVERIFY(posIndex == 0);
+ bool isFirst = greenRect->property("isFirstItem").toBool();
+ QVERIFY(isFirst == true);
+ bool isLast = greenRect->property("isLastItem").toBool();
+ QVERIFY(isLast == false);
+
+ QQuickRectangle *yellowRect = canvas->rootObject()->findChild<QQuickRectangle *>("yellowRect");
+ QVERIFY(yellowRect != 0);
+
+ posIndex = yellowRect->property("posIndex").toInt();
+ QVERIFY(posIndex == -1);
+ isFirst = yellowRect->property("isFirstItem").toBool();
+ QVERIFY(isFirst == false);
+ isLast = yellowRect->property("isLastItem").toBool();
+ QVERIFY(isLast == false);
+
+ yellowRect->metaObject()->invokeMethod(yellowRect, "onDemandPositioner");
+
+ posIndex = yellowRect->property("posIndex").toInt();
+ QVERIFY(posIndex == 1);
+ isFirst = yellowRect->property("isFirstItem").toBool();
+ QVERIFY(isFirst == false);
+ isLast = yellowRect->property("isLastItem").toBool();
+ QVERIFY(isLast == true);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_attachedproperties_data()
+{
+ QTest::addColumn<QString>("filename");
+
+ QTest::newRow("column") << testFile("attachedproperties-column.qml");
+ QTest::newRow("row") << testFile("attachedproperties-row.qml");
+ QTest::newRow("grid") << testFile("attachedproperties-grid.qml");
+ QTest::newRow("flow") << testFile("attachedproperties-flow.qml");
+}
+
+void tst_qquickpositioners::test_attachedproperties_dynamic()
+{
+ QQuickView *canvas = createView(testFile("attachedproperties-dynamic.qml"));
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickRow *row = canvas->rootObject()->findChild<QQuickRow *>("pos");
+ QVERIFY(row != 0);
+
+ QQuickRectangle *rect0 = canvas->rootObject()->findChild<QQuickRectangle *>("rect0");
+ QVERIFY(rect0 != 0);
+
+ int posIndex = rect0->property("index").toInt();
+ QVERIFY(posIndex == 0);
+ bool isFirst = rect0->property("firstItem").toBool();
+ QVERIFY(isFirst == true);
+ bool isLast = rect0->property("lastItem").toBool();
+ QVERIFY(isLast == false);
+
+ QQuickRectangle *rect1 = canvas->rootObject()->findChild<QQuickRectangle *>("rect1");
+ QVERIFY(rect1 != 0);
+
+ posIndex = rect1->property("index").toInt();
+ QVERIFY(posIndex == 1);
+ isFirst = rect1->property("firstItem").toBool();
+ QVERIFY(isFirst == false);
+ isLast = rect1->property("lastItem").toBool();
+ QVERIFY(isLast == true);
+
+ row->metaObject()->invokeMethod(row, "createSubRect");
+
+ QTRY_VERIFY(rect1->property("index").toInt() == 1);
+ QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
+ QTRY_VERIFY(rect1->property("lastItem").toBool() == false);
+
+ QQuickRectangle *rect2 = canvas->rootObject()->findChild<QQuickRectangle *>("rect2");
+ QVERIFY(rect2 != 0);
+
+ posIndex = rect2->property("index").toInt();
+ QVERIFY(posIndex == 2);
+ isFirst = rect2->property("firstItem").toBool();
+ QVERIFY(isFirst == false);
+ isLast = rect2->property("lastItem").toBool();
+ QVERIFY(isLast == true);
+
+ row->metaObject()->invokeMethod(row, "destroySubRect");
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QTRY_VERIFY(rect1->property("index").toInt() == 1);
+ QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
+ QTRY_VERIFY(rect1->property("lastItem").toBool() == true);
+
+ delete canvas;
+}
+
+QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->show();
+ if (wait)
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ return canvas;
+}
+
+void tst_qquickpositioners::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
+{
+ for (int i=0; i<indexLists.count(); i++) {
+ QSet<int> current = indexLists[i].value<QList<int> >().toSet();
+ if (current != expectedIndexes.toSet())
+ qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
+ QCOMPARE(current, expectedIndexes.toSet());
+ }
+}
+
+void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
+{
+ for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
+ QVERIFY(it.value().type() == QVariant::Int);
+ QString name = it.key();
+ int itemIndex = it.value().toInt();
+ QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
+ if (model.name(itemIndex) != name)
+ qDebug() << itemIndex;
+ QCOMPARE(model.name(itemIndex), name);
+ }
+ QCOMPARE(items.count(), expectedIndexes.count());
+}
+
+void tst_qquickpositioners::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
+{
+ for (int i=0; i<itemLists.count(); i++) {
+ QVERIFY(itemLists[i].type() == QVariant::List);
+ QVariantList current = itemLists[i].toList();
+ for (int j=0; j<current.count(); j++) {
+ QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
+ QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
+ QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
+ }
+ QCOMPARE(current.count(), expectedItems.count());
+ }
+}
+
+QTEST_MAIN(tst_qquickpositioners)
+
+#include "tst_qquickpositioners.moc"
diff --git a/tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml b/tests/auto/quick/qquickrepeater/data/asyncloader.qml
index 82094e2666..82094e2666 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml
+++ b/tests/auto/quick/qquickrepeater/data/asyncloader.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/initparent.qml b/tests/auto/quick/qquickrepeater/data/initparent.qml
index e6571f09d3..e6571f09d3 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/initparent.qml
+++ b/tests/auto/quick/qquickrepeater/data/initparent.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/intmodel.qml b/tests/auto/quick/qquickrepeater/data/intmodel.qml
index 30a650dd52..30a650dd52 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/intmodel.qml
+++ b/tests/auto/quick/qquickrepeater/data/intmodel.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/itemlist.qml b/tests/auto/quick/qquickrepeater/data/itemlist.qml
index 174bfd4d18..174bfd4d18 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/itemlist.qml
+++ b/tests/auto/quick/qquickrepeater/data/itemlist.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml b/tests/auto/quick/qquickrepeater/data/modelChanged.qml
index 23af127e79..23af127e79 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml
+++ b/tests/auto/quick/qquickrepeater/data/modelChanged.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/objlist.qml b/tests/auto/quick/qquickrepeater/data/objlist.qml
index c49d5926e5..c49d5926e5 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/objlist.qml
+++ b/tests/auto/quick/qquickrepeater/data/objlist.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/properties.qml b/tests/auto/quick/qquickrepeater/data/properties.qml
index 035431c784..035431c784 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/properties.qml
+++ b/tests/auto/quick/qquickrepeater/data/properties.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/repeater1.qml b/tests/auto/quick/qquickrepeater/data/repeater1.qml
index 3e6f4071ff..3e6f4071ff 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/repeater1.qml
+++ b/tests/auto/quick/qquickrepeater/data/repeater1.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/repeater2.qml b/tests/auto/quick/qquickrepeater/data/repeater2.qml
index 691fbda1e5..691fbda1e5 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/repeater2.qml
+++ b/tests/auto/quick/qquickrepeater/data/repeater2.qml
diff --git a/tests/auto/quick/qquickrepeater/qquickrepeater.pro b/tests/auto/quick/qquickrepeater/qquickrepeater.pro
new file mode 100644
index 0000000000..c3d96ee6d5
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/qquickrepeater.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickrepeater
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickrepeater.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testFiles.files = data
+testFiles.path = .
+DEPLOYMENT += testFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
new file mode 100644
index 0000000000..1b07a6e9f8
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -0,0 +1,644 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qlistmodelinterface_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <private/qquickrepeater_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+
+class tst_QQuickRepeater : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickRepeater();
+
+private slots:
+ void numberModel();
+ void objectList();
+ void stringList();
+ void dataModel_adding();
+ void dataModel_removing();
+ void dataModel_changes();
+ void itemModel();
+ void resetModel();
+ void modelChanged();
+ void properties();
+ void asynchronous();
+ void initParent();
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError)
+ Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
+
+public:
+ TestObject() : QObject(), mError(true), mUseModel(false) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; }
+
+ bool useModel() const { return mUseModel; }
+ void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
+
+signals:
+ void useModelChanged();
+
+private:
+ bool mError;
+ bool mUseModel;
+};
+
+tst_QQuickRepeater::tst_QQuickRepeater()
+{
+}
+
+void tst_QQuickRepeater::numberModel()
+{
+ QQuickView *canvas = createView();
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", 5);
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("intmodel.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
+
+ QVERIFY(!repeater->itemAt(-1));
+ for (int i=0; i<repeater->count(); i++)
+ QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
+ QVERIFY(!repeater->itemAt(repeater->count()));
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ delete testObject;
+ delete canvas;
+}
+
+class MyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int idx READ idx CONSTANT)
+public:
+ MyObject(int i) : QObject(), m_idx(i) {}
+
+ int idx() const { return m_idx; }
+
+ int m_idx;
+};
+
+void tst_QQuickRepeater::objectList()
+{
+ QQuickView *canvas = createView();
+ QObjectList data;
+ for (int i=0; i<100; i++)
+ data << new MyObject(i);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", QVariant::fromValue(data));
+
+ canvas->setSource(testFileUrl("objlist.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
+ QCOMPARE(repeater->property("instantiated").toInt(), 100);
+
+ QVERIFY(!repeater->itemAt(-1));
+ for (int i=0; i<data.count(); i++)
+ QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
+ QVERIFY(!repeater->itemAt(data.count()));
+
+ QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
+ QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
+ ctxt->setContextProperty("testData", QVariant::fromValue(data));
+ QCOMPARE(addedSpy.count(), data.count());
+ QCOMPARE(removedSpy.count(), data.count());
+
+ qDeleteAll(data);
+ delete canvas;
+}
+
+/*
+The Repeater element creates children at its own position in its parent's
+stacking order. In this test we insert a repeater between two other Text
+elements to test this.
+*/
+void tst_QQuickRepeater::stringList()
+{
+ QQuickView *canvas = createView();
+
+ QStringList data;
+ data << "One";
+ data << "Two";
+ data << "Three";
+ data << "Four";
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", data);
+
+ canvas->setSource(testFileUrl("repeater1.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->childItems().count(), data.count() + 3);
+
+ bool saw_repeater = false;
+ for (int i = 0; i < container->childItems().count(); ++i) {
+
+ if (i == 0) {
+ QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Zero"));
+ } else if (i == container->childItems().count() - 2) {
+ // The repeater itself
+ QQuickRepeater *rep = qobject_cast<QQuickRepeater*>(container->childItems().at(i));
+ QCOMPARE(rep, repeater);
+ saw_repeater = true;
+ continue;
+ } else if (i == container->childItems().count() - 1) {
+ QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Last"));
+ } else {
+ QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), data.at(i-1));
+ }
+ }
+ QVERIFY(saw_repeater);
+
+ delete canvas;
+}
+
+void tst_QQuickRepeater::dataModel_adding()
+{
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ QaimModel testModel;
+ ctxt->setContextProperty("testData", &testModel);
+ canvas->setSource(testFileUrl("repeater2.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QVERIFY(!repeater->itemAt(0));
+
+ QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
+ QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
+
+ // add to empty model
+ testModel.addItem("two", "2");
+ QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
+ addedSpy.clear();
+
+ // insert at start
+ testModel.insertItem(0, "one", "1");
+ QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
+ addedSpy.clear();
+
+ // insert at end
+ testModel.insertItem(2, "four", "4");
+ QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
+ QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
+ addedSpy.clear();
+
+ // insert in middle
+ testModel.insertItem(2, "three", "3");
+ QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
+ QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
+ addedSpy.clear();
+
+ delete testObject;
+ addedSpy.clear();
+ countSpy.clear();
+ delete canvas;
+}
+
+void tst_QQuickRepeater::dataModel_removing()
+{
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ QaimModel testModel;
+ testModel.addItem("one", "1");
+ testModel.addItem("two", "2");
+ testModel.addItem("three", "3");
+ testModel.addItem("four", "4");
+ testModel.addItem("five", "5");
+
+ ctxt->setContextProperty("testData", &testModel);
+ canvas->setSource(testFileUrl("repeater2.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+ QCOMPARE(container->childItems().count(), repeater->count()+1);
+
+ QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
+ QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
+
+ // remove at start
+ QQuickItem *item = repeater->itemAt(0);
+ QCOMPARE(item, container->childItems().at(0));
+
+ testModel.removeItem(0);
+ QVERIFY(repeater->itemAt(0) != item);
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(removedSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
+ removedSpy.clear();
+
+ // remove at end
+ int lastIndex = testModel.count()-1;
+ item = repeater->itemAt(lastIndex);
+ QCOMPARE(item, container->childItems().at(lastIndex));
+
+ testModel.removeItem(lastIndex);
+ QVERIFY(repeater->itemAt(lastIndex) != item);
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex);
+ QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
+ removedSpy.clear();
+
+ // remove from middle
+ item = repeater->itemAt(1);
+ QCOMPARE(item, container->childItems().at(1));
+
+ testModel.removeItem(1);
+ QVERIFY(repeater->itemAt(lastIndex) != item);
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(removedSpy.at(0).at(0).toInt(), 1);
+ QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
+ removedSpy.clear();
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickRepeater::dataModel_changes()
+{
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ QaimModel testModel;
+ testModel.addItem("one", "1");
+ testModel.addItem("two", "2");
+ testModel.addItem("three", "3");
+
+ ctxt->setContextProperty("testData", &testModel);
+ canvas->setSource(testFileUrl("repeater2.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+ QCOMPARE(container->childItems().count(), repeater->count()+1);
+
+ // Check that model changes are propagated
+ QQuickText *text = findItem<QQuickText>(canvas->rootObject(), "myName", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("two"));
+
+ testModel.modifyItem(1, "Item two", "_2");
+ text = findItem<QQuickText>(canvas->rootObject(), "myName", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("Item two"));
+
+ text = findItem<QQuickText>(canvas->rootObject(), "myNumber", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("_2"));
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickRepeater::itemModel()
+{
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("itemlist.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->childItems().count(), 1);
+
+ testObject->setUseModel(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QCOMPARE(container->childItems().count(), 4);
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item1");
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item2");
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3");
+ QVERIFY(container->childItems().at(3) == repeater);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "switchModel");
+ QCOMPARE(container->childItems().count(), 3);
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item4");
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item5");
+ QVERIFY(container->childItems().at(2) == repeater);
+
+ testObject->setUseModel(false);
+ QCOMPARE(container->childItems().count(), 1);
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickRepeater::resetModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringList dataA;
+ for (int i=0; i<10; i++)
+ dataA << QString::number(i);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", dataA);
+ canvas->setSource(testFileUrl("repeater1.qml"));
+ qApp->processEvents();
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(repeater->count(), dataA.count());
+ for (int i=0; i<repeater->count(); i++)
+ QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object
+
+ QSignalSpy modelChangedSpy(repeater, SIGNAL(modelChanged()));
+ QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
+ QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
+ QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
+
+ QStringList dataB;
+ for (int i=0; i<20; i++)
+ dataB << QString::number(i);
+
+ // reset context property
+ ctxt->setContextProperty("testData", dataB);
+ QCOMPARE(repeater->count(), dataB.count());
+
+ QCOMPARE(modelChangedSpy.count(), 1);
+ QCOMPARE(countSpy.count(), 1);
+ QCOMPARE(removedSpy.count(), dataA.count());
+ QCOMPARE(addedSpy.count(), dataB.count());
+ for (int i=0; i<dataB.count(); i++) {
+ QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
+ QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
+ }
+ modelChangedSpy.clear();
+ countSpy.clear();
+ removedSpy.clear();
+ addedSpy.clear();
+
+ // reset via setModel()
+ repeater->setModel(dataA);
+ QCOMPARE(repeater->count(), dataA.count());
+
+ QCOMPARE(modelChangedSpy.count(), 1);
+ QCOMPARE(countSpy.count(), 1);
+ QCOMPARE(removedSpy.count(), dataB.count());
+ QCOMPARE(addedSpy.count(), dataA.count());
+ for (int i=0; i<dataA.count(); i++) {
+ QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
+ QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
+ }
+
+ modelChangedSpy.clear();
+ countSpy.clear();
+ removedSpy.clear();
+ addedSpy.clear();
+
+ delete canvas;
+}
+
+// QTBUG-17156
+void tst_QQuickRepeater::modelChanged()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("modelChanged.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+
+ repeater->setModel(4);
+ QCOMPARE(repeater->count(), 4);
+ QCOMPARE(repeater->property("itemsCount").toInt(), 4);
+ QCOMPARE(repeater->property("itemsFound").toList().count(), 4);
+
+ repeater->setModel(10);
+ QCOMPARE(repeater->count(), 10);
+ QCOMPARE(repeater->property("itemsCount").toInt(), 10);
+ QCOMPARE(repeater->property("itemsFound").toList().count(), 10);
+
+ delete rootObject;
+}
+
+void tst_QQuickRepeater::properties()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("properties.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+
+ QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
+ repeater->setModel(3);
+ QCOMPARE(modelSpy.count(),1);
+ repeater->setModel(3);
+ QCOMPARE(modelSpy.count(),1);
+
+ QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
+
+ QQmlComponent rectComponent(&engine);
+ rectComponent.setData("import QtQuick 2.0; Rectangle {}", QUrl::fromLocalFile(""));
+
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+
+ delete rootObject;
+}
+
+void tst_QQuickRepeater::asynchronous()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->setSource(testFileUrl("asyncloader.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootObject);
+
+ QQuickItem *container = findItem<QQuickItem>(rootObject, "container");
+ QVERIFY(!container);
+ while (!container) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ container = findItem<QQuickItem>(rootObject, "container");
+ }
+
+ QQuickRepeater *repeater = 0;
+ while (!repeater) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ }
+
+ // items will be created one at a time
+ for (int i = 0; i < 10; ++i) {
+ QString name("delegate");
+ name += QString::number(i);
+ QVERIFY(findItem<QQuickItem>(container, name) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(container, name);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ // verify positioning
+ for (int i = 0; i < 10; ++i) {
+ QString name("delegate");
+ name += QString::number(i);
+ QQuickItem *item = findItem<QQuickItem>(container, name);
+ QTRY_COMPARE(item->y(), i * 50.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickRepeater::initParent()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("initparent.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QCOMPARE(qvariant_cast<QQuickItem*>(rootObject->property("parentItem")), rootObject);
+}
+
+QTEST_MAIN(tst_QQuickRepeater)
+
+#include "tst_qquickrepeater.moc"
diff --git a/tests/auto/qtquick2/qquickscreen/data/screen.qml b/tests/auto/quick/qquickscreen/data/screen.qml
index 780b22f23d..780b22f23d 100644
--- a/tests/auto/qtquick2/qquickscreen/data/screen.qml
+++ b/tests/auto/quick/qquickscreen/data/screen.qml
diff --git a/tests/auto/quick/qquickscreen/qquickscreen.pro b/tests/auto/quick/qquickscreen/qquickscreen.pro
new file mode 100644
index 0000000000..00ec51ef33
--- /dev/null
+++ b/tests/auto/quick/qquickscreen/qquickscreen.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TARGET = tst_qquickscreen
+SOURCES += tst_qquickscreen.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private testlib quick-private
diff --git a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp
new file mode 100644
index 0000000000..cbf9438f24
--- /dev/null
+++ b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickView>
+#include <QtGui/QScreen>
+#include "../../shared/util.h"
+
+class tst_qquickscreen : public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void basicProperties();
+};
+
+void tst_qquickscreen::basicProperties()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("screen.qml"));
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QQuickItem* root = view.rootObject();
+ QVERIFY(root);
+
+ QScreen* screen = view.screen();
+ QVERIFY(screen);
+
+ QCOMPARE(screen->size().width(), root->property("w").toInt());
+ QCOMPARE(screen->size().height(), root->property("h").toInt());
+ QCOMPARE(int(screen->orientation()), root->property("curOrientation").toInt());
+ QCOMPARE(int(screen->primaryOrientation()), root->property("priOrientation").toInt());
+}
+
+QTEST_MAIN(tst_qquickscreen)
+
+#include "tst_qquickscreen.moc"
diff --git a/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro b/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro
new file mode 100644
index 0000000000..6ff50a0553
--- /dev/null
+++ b/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qquickshadereffect
+SOURCES += tst_qquickshadereffect.cpp
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp
index 00ae8fc76d..00ae8fc76d 100644
--- a/tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp
+++ b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml b/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml
index ff8dfaa846..ff8dfaa846 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml b/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml
index b2be63ec94..b2be63ec94 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml
index 3631f971f0..3631f971f0 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml
index b07120234a..b07120234a 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml
index 8d5dc4a92b..8d5dc4a92b 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml
index 81d36bf015..81d36bf015 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml
index e136df84f6..e136df84f6 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml
diff --git a/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro
new file mode 100644
index 0000000000..0d5567da8d
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquicksmoothedanimation
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicksmoothedanimation.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
new file mode 100644
index 0000000000..a3e0e46f97
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicksmoothedanimation_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include "../../shared/util.h"
+
+class tst_qquicksmoothedanimation : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquicksmoothedanimation();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+ void simpleAnimation();
+ void valueSource();
+ void behavior();
+ void deleteOnUpdate();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquicksmoothedanimation::tst_qquicksmoothedanimation()
+{
+}
+
+void tst_qquicksmoothedanimation::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation1.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 0.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->duration(), -1);
+ QCOMPARE(obj->maximumEasingTime(), -1);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Eased);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::values()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation2.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 10.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->duration(), 300);
+ QCOMPARE(obj->maximumEasingTime(), -1);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Immediate);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::disabled()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation3.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 10.);
+ QCOMPARE(obj->velocity(), 250.);
+ QCOMPARE(obj->maximumEasingTime(), 150);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Sync);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::simpleAnimation()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("simpleanimation.qml"));
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QQuickRectangle *rect = obj->findChild<QQuickRectangle*>("rect");
+ QVERIFY(rect);
+
+ QQuickSmoothedAnimation *animation = obj->findChild<QQuickSmoothedAnimation*>("anim");
+ QVERIFY(animation);
+
+ animation->setTargetObject(rect);
+ animation->setProperty("x");
+ animation->setTo(200);
+ animation->setDuration(250);
+ QVERIFY(animation->target() == rect);
+ QVERIFY(animation->property() == "x");
+ QVERIFY(animation->to() == 200);
+ animation->start();
+ QVERIFY(animation->isRunning());
+ QTest::qWait(animation->duration());
+ QTRY_COMPARE(rect->x(), qreal(200));
+ QTest::qWait(100); //smoothed animation doesn't report stopped until delayed timer fires
+
+ QVERIFY(!animation->isRunning());
+ rect->setX(0);
+ animation->start();
+ QVERIFY(animation->isRunning());
+ animation->pause();
+ QVERIFY(animation->isRunning());
+ QVERIFY(animation->isPaused());
+ animation->setCurrentTime(125);
+ QVERIFY(animation->currentTime() == 125);
+ QCOMPARE(rect->x(), qreal(100));
+}
+
+void tst_qquicksmoothedanimation::valueSource()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
+ QVERIFY(theRect);
+
+ QQuickSmoothedAnimation *easeX = rect->findChild<QQuickSmoothedAnimation*>("easeX");
+ QVERIFY(easeX);
+ QVERIFY(easeX->isRunning());
+
+ QQuickSmoothedAnimation *easeY = rect->findChild<QQuickSmoothedAnimation*>("easeY");
+ QVERIFY(easeY);
+ QVERIFY(easeY->isRunning());
+
+ // XXX get the proper duration
+ QTest::qWait(100);
+
+ QTRY_VERIFY(!easeX->isRunning());
+ QTRY_VERIFY(!easeY->isRunning());
+
+ QTRY_COMPARE(theRect->x(), qreal(200));
+ QTRY_COMPARE(theRect->y(), qreal(200));
+
+ delete rect;
+}
+
+void tst_qquicksmoothedanimation::behavior()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
+ QVERIFY(theRect);
+
+ QQuickSmoothedAnimation *easeX = rect->findChild<QQuickSmoothedAnimation*>("easeX");
+ QVERIFY(easeX);
+
+ QQuickSmoothedAnimation *easeY = rect->findChild<QQuickSmoothedAnimation*>("easeY");
+ QVERIFY(easeY);
+
+ // XXX get the proper duration
+ QTest::qWait(400);
+
+ QTRY_VERIFY(!easeX->isRunning());
+ QTRY_VERIFY(!easeY->isRunning());
+
+ QTRY_COMPARE(theRect->x(), qreal(200));
+ QTRY_COMPARE(theRect->y(), qreal(200));
+
+ delete rect;
+}
+
+void tst_qquicksmoothedanimation::deleteOnUpdate()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("deleteOnUpdate.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickSmoothedAnimation *anim = rect->findChild<QQuickSmoothedAnimation*>("anim");
+ QVERIFY(anim);
+
+ //don't crash
+ QTest::qWait(500);
+
+ delete rect;
+}
+
+QTEST_MAIN(tst_qquicksmoothedanimation)
+
+#include "tst_qquicksmoothedanimation.moc"
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/quick/qquickspringanimation/data/springanimation1.qml
index 9f52aa56c1..9f52aa56c1 100644
--- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml
+++ b/tests/auto/quick/qquickspringanimation/data/springanimation1.qml
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml b/tests/auto/quick/qquickspringanimation/data/springanimation2.qml
index 9f72e51533..9f72e51533 100644
--- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml
+++ b/tests/auto/quick/qquickspringanimation/data/springanimation2.qml
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml b/tests/auto/quick/qquickspringanimation/data/springanimation3.qml
index f4dc121eb8..f4dc121eb8 100644
--- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml
+++ b/tests/auto/quick/qquickspringanimation/data/springanimation3.qml
diff --git a/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro b/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro
new file mode 100644
index 0000000000..8ad472f8cc
--- /dev/null
+++ b/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickspringanimation
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickspringanimation.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp b/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp
new file mode 100644
index 0000000000..4fa512d9b6
--- /dev/null
+++ b/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qquickspringanimation_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include "../../shared/util.h"
+
+class tst_qquickspringanimation : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickspringanimation();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickspringanimation::tst_qquickspringanimation()
+{
+}
+
+void tst_qquickspringanimation::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("springanimation1.qml"));
+ QQuickSpringAnimation *obj = qobject_cast<QQuickSpringAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 0.);
+ QCOMPARE(obj->velocity(), 0.);
+ QCOMPARE(obj->spring(), 0.);
+ QCOMPARE(obj->damping(), 0.);
+ QCOMPARE(obj->epsilon(), 0.01);
+ QCOMPARE(obj->modulus(), 0.);
+ QCOMPARE(obj->mass(), 1.);
+ QCOMPARE(obj->isRunning(), false);
+
+ delete obj;
+}
+
+void tst_qquickspringanimation::values()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("springanimation2.qml"));
+ QObject *root = c.create();
+
+ QQuickSpringAnimation *obj = root->findChild<QQuickSpringAnimation*>();
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 1.44);
+ QCOMPARE(obj->velocity(), 0.9);
+ QCOMPARE(obj->spring(), 1.0);
+ QCOMPARE(obj->damping(), 0.5);
+ QCOMPARE(obj->epsilon(), 0.25);
+ QCOMPARE(obj->modulus(), 360.0);
+ QCOMPARE(obj->mass(), 2.0);
+ QCOMPARE(obj->isRunning(), true);
+
+ QTRY_COMPARE(obj->isRunning(), false);
+
+ delete obj;
+}
+
+void tst_qquickspringanimation::disabled()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("springanimation3.qml"));
+ QQuickSpringAnimation *obj = qobject_cast<QQuickSpringAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 1.44);
+ QCOMPARE(obj->velocity(), 0.9);
+ QCOMPARE(obj->spring(), 1.0);
+ QCOMPARE(obj->damping(), 0.5);
+ QCOMPARE(obj->epsilon(), 0.25);
+ QCOMPARE(obj->modulus(), 360.0);
+ QCOMPARE(obj->mass(), 2.0);
+ QCOMPARE(obj->isRunning(), false);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qquickspringanimation)
+
+#include "tst_qquickspringanimation.moc"
diff --git a/tests/auto/quick/qquickspriteimage/data/advance.qml b/tests/auto/quick/qquickspriteimage/data/advance.qml
new file mode 100644
index 0000000000..46a49ca673
--- /dev/null
+++ b/tests/auto/quick/qquickspriteimage/data/advance.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "black"
+ width: 320
+ height: 320
+
+ SpriteImage {
+ objectName: "sprite"
+ sprites: [Sprite {
+ name: "firstState"
+ source: "squarefacesprite.png"
+ frames: 3
+ frameSync: true
+ to: {"secondState":1}
+ }, Sprite {
+ name: "secondState"
+ source: "squarefacesprite.png"
+ frames: 6
+ frameSync: true
+ } ]
+ width: 160
+ height: 160
+ }
+}
diff --git a/tests/auto/quick/qquickspriteimage/data/basic.qml b/tests/auto/quick/qquickspriteimage/data/basic.qml
new file mode 100644
index 0000000000..2f2b1c96fa
--- /dev/null
+++ b/tests/auto/quick/qquickspriteimage/data/basic.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "black"
+ width: 320
+ height: 320
+
+ SpriteImage {
+ objectName: "sprite"
+ sprites: Sprite {
+ name: "happy"
+ source: "squarefacesprite.png"
+ frames: 6
+ frameDuration: 120
+ }
+ width: 160
+ height: 160
+ }
+}
diff --git a/tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png b/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png
index f9a5d5fcce..f9a5d5fcce 100644
--- a/tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png
+++ b/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png
Binary files differ
diff --git a/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro b/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro
new file mode 100644
index 0000000000..50613792de
--- /dev/null
+++ b/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickspriteimage
+SOURCES += tst_qquickspriteimage.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp
new file mode 100644
index 0000000000..7aff77334d
--- /dev/null
+++ b/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+#include <QtQuick/qquickview.h>
+#include <private/qquickspriteimage_p.h>
+
+class tst_qquickspriteimage : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickspriteimage(){}
+
+private slots:
+ void test_properties();
+ void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine
+};
+
+void tst_qquickspriteimage::test_properties()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("basic.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickSpriteImage* sprite = canvas->rootObject()->findChild<QQuickSpriteImage*>("sprite");
+ QVERIFY(sprite);
+
+ QVERIFY(sprite->running());
+ QVERIFY(sprite->interpolate());
+
+ sprite->setRunning(false);
+ QVERIFY(!sprite->running());
+ sprite->setInterpolate(false);
+ QVERIFY(!sprite->interpolate());
+
+ delete canvas;
+}
+
+void tst_qquickspriteimage::test_framerateAdvance()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("advance.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickSpriteImage* sprite = canvas->rootObject()->findChild<QQuickSpriteImage*>("sprite");
+ QVERIFY(sprite);
+
+ QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState"));
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickspriteimage)
+
+#include "tst_qquickspriteimage.moc"
diff --git a/tests/auto/qtquick2/qquickspritesequence/data/advance.qml b/tests/auto/quick/qquickspritesequence/data/advance.qml
index 5866dcbfac..5866dcbfac 100644
--- a/tests/auto/qtquick2/qquickspritesequence/data/advance.qml
+++ b/tests/auto/quick/qquickspritesequence/data/advance.qml
diff --git a/tests/auto/qtquick2/qquickspritesequence/data/basic.qml b/tests/auto/quick/qquickspritesequence/data/basic.qml
index 5eb7475f11..5eb7475f11 100644
--- a/tests/auto/qtquick2/qquickspritesequence/data/basic.qml
+++ b/tests/auto/quick/qquickspritesequence/data/basic.qml
diff --git a/tests/auto/quick/qquickspritesequence/data/squarefacesprite.png b/tests/auto/quick/qquickspritesequence/data/squarefacesprite.png
new file mode 100644
index 0000000000..f9a5d5fcce
--- /dev/null
+++ b/tests/auto/quick/qquickspritesequence/data/squarefacesprite.png
Binary files differ
diff --git a/tests/auto/quick/qquickspritesequence/qquickspritesequence.pro b/tests/auto/quick/qquickspritesequence/qquickspritesequence.pro
new file mode 100644
index 0000000000..3dabd065a0
--- /dev/null
+++ b/tests/auto/quick/qquickspritesequence/qquickspritesequence.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickspritesequence
+SOURCES += tst_qquickspritesequence.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp b/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp
new file mode 100644
index 0000000000..8469a949c6
--- /dev/null
+++ b/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+#include <QtQuick/qquickview.h>
+#include <private/qquickspritesequence_p.h>
+
+class tst_qquickspritesequence : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickspritesequence(){}
+
+private slots:
+ void test_properties();
+ void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine
+};
+
+void tst_qquickspritesequence::test_properties()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("basic.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickSpriteSequence* sprite = canvas->rootObject()->findChild<QQuickSpriteSequence*>("sprite");
+ QVERIFY(sprite);
+
+ QVERIFY(sprite->running());
+ QVERIFY(sprite->interpolate());
+
+ sprite->setRunning(false);
+ QVERIFY(!sprite->running());
+ sprite->setInterpolate(false);
+ QVERIFY(!sprite->interpolate());
+
+ delete canvas;
+}
+
+void tst_qquickspritesequence::test_framerateAdvance()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("advance.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickSpriteSequence* sprite = canvas->rootObject()->findChild<QQuickSpriteSequence*>("sprite");
+ QVERIFY(sprite);
+
+ QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState"));
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickspritesequence)
+
+#include "tst_qquickspritesequence.moc"
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml b/tests/auto/quick/qquickstates/data/ExtendedRectangle.qml
index 1ea346b841..1ea346b841 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml
+++ b/tests/auto/quick/qquickstates/data/ExtendedRectangle.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/quick/qquickstates/data/Implementation/MyType.qml
index 01eb32cd4d..01eb32cd4d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml
+++ b/tests/auto/quick/qquickstates/data/Implementation/MyType.qml
diff --git a/tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png b/tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png
new file mode 100644
index 0000000000..14ddf2a028
--- /dev/null
+++ b/tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml b/tests/auto/quick/qquickstates/data/QTBUG-14830.qml
index 5ba7c3ad6f..5ba7c3ad6f 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml
+++ b/tests/auto/quick/qquickstates/data/QTBUG-14830.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/quick/qquickstates/data/anchorChanges1.qml
index 378f5390f9..378f5390f9 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges1.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/quick/qquickstates/data/anchorChanges2.qml
index dc7f8ef0d1..dc7f8ef0d1 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/quick/qquickstates/data/anchorChanges3.qml
index af49575854..af49575854 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/quick/qquickstates/data/anchorChanges4.qml
index 28b55818bd..28b55818bd 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges4.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/quick/qquickstates/data/anchorChanges5.qml
index b1ca968fb9..b1ca968fb9 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges5.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/quick/qquickstates/data/anchorChangesCrash.qml
index 9af0e4645a..9af0e4645a 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChangesCrash.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/quick/qquickstates/data/anchorRewindBug.qml
index 60c537b1ed..60c537b1ed 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml
+++ b/tests/auto/quick/qquickstates/data/anchorRewindBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/quick/qquickstates/data/anchorRewindBug2.qml
index 574ef473ce..574ef473ce 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml
+++ b/tests/auto/quick/qquickstates/data/anchorRewindBug2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml b/tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml
index 413af2ee42..413af2ee42 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml
+++ b/tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml
index 6cbf524ec2..6cbf524ec2 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml
+++ b/tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml b/tests/auto/quick/qquickstates/data/avoidFastForward.qml
index 519befc31e..519befc31e 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml
+++ b/tests/auto/quick/qquickstates/data/avoidFastForward.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml b/tests/auto/quick/qquickstates/data/basicBinding.qml
index 59b67d0863..59b67d0863 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml
+++ b/tests/auto/quick/qquickstates/data/basicBinding.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml b/tests/auto/quick/qquickstates/data/basicBinding2.qml
index 55f88120aa..55f88120aa 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml
+++ b/tests/auto/quick/qquickstates/data/basicBinding2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml b/tests/auto/quick/qquickstates/data/basicBinding3.qml
index 361ab0b091..361ab0b091 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml
+++ b/tests/auto/quick/qquickstates/data/basicBinding3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml b/tests/auto/quick/qquickstates/data/basicBinding4.qml
index b29f0fcf22..b29f0fcf22 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml
+++ b/tests/auto/quick/qquickstates/data/basicBinding4.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml b/tests/auto/quick/qquickstates/data/basicChanges.qml
index 3e2b73acde..3e2b73acde 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml
+++ b/tests/auto/quick/qquickstates/data/basicChanges.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml b/tests/auto/quick/qquickstates/data/basicChanges2.qml
index 5ff46cc60c..5ff46cc60c 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml
+++ b/tests/auto/quick/qquickstates/data/basicChanges2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml b/tests/auto/quick/qquickstates/data/basicChanges3.qml
index e46e98f75e..e46e98f75e 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml
+++ b/tests/auto/quick/qquickstates/data/basicChanges3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml b/tests/auto/quick/qquickstates/data/basicChanges4.qml
index 7da1e0fb2e..7da1e0fb2e 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml
+++ b/tests/auto/quick/qquickstates/data/basicChanges4.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml b/tests/auto/quick/qquickstates/data/basicExtension.qml
index 00f5fee287..00f5fee287 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml
+++ b/tests/auto/quick/qquickstates/data/basicExtension.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/deleting.qml b/tests/auto/quick/qquickstates/data/deleting.qml
index b8e8d33c17..b8e8d33c17 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/deleting.qml
+++ b/tests/auto/quick/qquickstates/data/deleting.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml b/tests/auto/quick/qquickstates/data/deletingState.qml
index 68a9c2a24d..68a9c2a24d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml
+++ b/tests/auto/quick/qquickstates/data/deletingState.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml b/tests/auto/quick/qquickstates/data/editProperties.qml
index 9bff3657ba..9bff3657ba 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml
+++ b/tests/auto/quick/qquickstates/data/editProperties.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/explicit.qml b/tests/auto/quick/qquickstates/data/explicit.qml
index d09893a1db..d09893a1db 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/explicit.qml
+++ b/tests/auto/quick/qquickstates/data/explicit.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml b/tests/auto/quick/qquickstates/data/extendsBug.qml
index 573341520d..573341520d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml
+++ b/tests/auto/quick/qquickstates/data/extendsBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml b/tests/auto/quick/qquickstates/data/fakeExtension.qml
index 6a5c7003f6..6a5c7003f6 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml
+++ b/tests/auto/quick/qquickstates/data/fakeExtension.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml b/tests/auto/quick/qquickstates/data/illegalObj.qml
index a2bbd5d32b..a2bbd5d32b 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml
+++ b/tests/auto/quick/qquickstates/data/illegalObj.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml b/tests/auto/quick/qquickstates/data/illegalTempState.qml
index 9cb39c0728..9cb39c0728 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml
+++ b/tests/auto/quick/qquickstates/data/illegalTempState.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/image.png b/tests/auto/quick/qquickstates/data/image.png
index ed1833c95b..ed1833c95b 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/image.png
+++ b/tests/auto/quick/qquickstates/data/image.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml b/tests/auto/quick/qquickstates/data/legalTempState.qml
index a93860f5cc..a93860f5cc 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml
+++ b/tests/auto/quick/qquickstates/data/legalTempState.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml b/tests/auto/quick/qquickstates/data/nonExistantProp.qml
index ce502699bb..ce502699bb 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml
+++ b/tests/auto/quick/qquickstates/data/nonExistantProp.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml b/tests/auto/quick/qquickstates/data/parentChange1.qml
index 663ad1a264..663ad1a264 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange1.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml b/tests/auto/quick/qquickstates/data/parentChange2.qml
index ae290e961e..ae290e961e 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml b/tests/auto/quick/qquickstates/data/parentChange3.qml
index 46665cb4c8..46665cb4c8 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml b/tests/auto/quick/qquickstates/data/parentChange4.qml
index 22de72f8c9..22de72f8c9 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange4.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml b/tests/auto/quick/qquickstates/data/parentChange5.qml
index c353d2637f..c353d2637f 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange5.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml b/tests/auto/quick/qquickstates/data/parentChange6.qml
index b373dbba20..b373dbba20 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange6.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml b/tests/auto/quick/qquickstates/data/propertyErrors.qml
index ddd636493d..ddd636493d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml
+++ b/tests/auto/quick/qquickstates/data/propertyErrors.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/reset.qml b/tests/auto/quick/qquickstates/data/reset.qml
index f0ecab0950..f0ecab0950 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/reset.qml
+++ b/tests/auto/quick/qquickstates/data/reset.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml b/tests/auto/quick/qquickstates/data/restoreEntryValues.qml
index 950a522841..950a522841 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml
+++ b/tests/auto/quick/qquickstates/data/restoreEntryValues.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml b/tests/auto/quick/qquickstates/data/returnToBase.qml
index 9a0ee82397..9a0ee82397 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml
+++ b/tests/auto/quick/qquickstates/data/returnToBase.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml b/tests/auto/quick/qquickstates/data/revertListBug.qml
index fbc4bc5ecc..fbc4bc5ecc 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml
+++ b/tests/auto/quick/qquickstates/data/revertListBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/script.qml b/tests/auto/quick/qquickstates/data/script.qml
index 218f0fae74..218f0fae74 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/script.qml
+++ b/tests/auto/quick/qquickstates/data/script.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml b/tests/auto/quick/qquickstates/data/signalOverride.qml
index 9ab8037e51..9ab8037e51 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverride.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml b/tests/auto/quick/qquickstates/data/signalOverride2.qml
index 4e5e335b8b..4e5e335b8b 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverride2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash.qml
index 3e2ae1e93d..3e2ae1e93d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml
index 3937874aa2..3937874aa2 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml
index 98d4c57219..98d4c57219 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/quick/qquickstates/data/unnamedWhen.qml
index 35eacff07b..35eacff07b 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml
+++ b/tests/auto/quick/qquickstates/data/unnamedWhen.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml b/tests/auto/quick/qquickstates/data/urlResolution.qml
index 516ac034d6..516ac034d6 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml
+++ b/tests/auto/quick/qquickstates/data/urlResolution.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml b/tests/auto/quick/qquickstates/data/whenOrdering.qml
index 92025a2054..92025a2054 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml
+++ b/tests/auto/quick/qquickstates/data/whenOrdering.qml
diff --git a/tests/auto/quick/qquickstates/qquickstates.pro b/tests/auto/quick/qquickstates/qquickstates.pro
new file mode 100644
index 0000000000..ec881680ea
--- /dev/null
+++ b/tests/auto/quick/qquickstates/qquickstates.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickstates
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickstates.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
new file mode 100644
index 0000000000..fc8194f6ca
--- /dev/null
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -0,0 +1,1608 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickstateoperations_p.h>
+#include <private/qquickanchors_p_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qquickimage_p.h>
+#include <QtQuick/private/qquickpropertychanges_p.h>
+#include <QtQuick/private/qquickstategroup_p.h>
+#include <private/qquickitem_p.h>
+#include <private/qqmlproperty_p.h>
+#include "../../shared/util.h"
+
+class MyAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo WRITE setFoo)
+public:
+ MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
+
+ int foo() const { return m_foo; }
+ void setFoo(int f) { m_foo = f; }
+
+private:
+ int m_foo;
+};
+
+class MyRect : public QQuickRectangle
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+public:
+ MyRect() {}
+
+ void doSomething() { emit didSomething(); }
+
+ int propertyWithNotify() const { return m_prop; }
+ void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); }
+
+ static MyAttached *qmlAttachedProperties(QObject *o) {
+ return new MyAttached(o);
+ }
+Q_SIGNALS:
+ void didSomething();
+ void oddlyNamedNotifySignal();
+
+private:
+ int m_prop;
+};
+
+QML_DECLARE_TYPE(MyRect)
+QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES)
+
+class tst_qquickstates : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickstates() {}
+
+private:
+ QByteArray fullDataPath(const QString &path) const;
+
+private slots:
+ void initTestCase();
+
+ void basicChanges();
+ void attachedPropertyChanges();
+ void basicExtension();
+ void basicBinding();
+ void signalOverride();
+ void signalOverrideCrash();
+ void signalOverrideCrash2();
+ void signalOverrideCrash3();
+ void parentChange();
+ void parentChangeErrors();
+ void anchorChanges();
+ void anchorChanges2();
+ void anchorChanges3();
+ void anchorChanges4();
+ void anchorChanges5();
+ void anchorChangesRTL();
+ void anchorChangesRTL2();
+ void anchorChangesRTL3();
+ void anchorChangesCrash();
+ void anchorRewindBug();
+ void anchorRewindBug2();
+ void script();
+ void restoreEntryValues();
+ void explicitChanges();
+ void propertyErrors();
+ void incorrectRestoreBug();
+ void autoStateAtStartupRestoreBug();
+ void deletingChange();
+ void deletingState();
+ void tempState();
+ void illegalTempState();
+ void nonExistantProperty();
+ void reset();
+ void illegalObjectCreation();
+ void whenOrdering();
+ void urlResolution();
+ void unnamedWhen();
+ void returnToBase();
+ void extendsBug();
+ void editProperties();
+ void QTBUG_14830();
+ void avoidFastForward();
+ void revertListBug();
+};
+
+void tst_qquickstates::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<MyRect>("Qt.test", 1, 0, "MyRectangle");
+}
+
+QByteArray tst_qquickstates::fullDataPath(const QString &path) const
+{
+ return testFileUrl(path).toString().toUtf8();
+}
+
+void tst_qquickstates::basicChanges()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicChanges2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicChanges3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2.0);
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+ //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
+
+ rectPrivate->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2.0);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ }
+
+ {
+ // Test basicChanges4.qml can magically connect to propertyWithNotify's notify
+ // signal using 'onPropertyWithNotifyChanged' even though the signal name is
+ // actually 'oddlyNamedNotifySignal'
+
+ QQmlComponent component(&engine, testFileUrl("basicChanges4.qml"));
+ QVERIFY(component.isReady());
+
+ MyRect *rect = qobject_cast<MyRect*>(component.create());
+ QVERIFY(rect != 0);
+
+ QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify"));
+ QVERIFY(prop.hasNotifySignal());
+ QString notifySignal = QByteArray(prop.notifySignal().signature());
+ QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged("));
+
+ QCOMPARE(rect->color(), QColor(Qt::red));
+
+ rect->setPropertyWithNotify(100);
+ QCOMPARE(rect->color(), QColor(Qt::blue));
+ }
+}
+
+void tst_qquickstates::attachedPropertyChanges()
+{
+ QQmlEngine engine;
+
+ QQmlComponent component(&engine, testFileUrl("attachedPropertyChanges.qml"));
+ QVERIFY(component.isReady());
+
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item != 0);
+ QCOMPARE(item->width(), 50.0);
+
+ // Ensure attached property has been changed
+ QObject *attObj = qmlAttachedPropertiesObject<MyRect>(item, false);
+ QVERIFY(attObj);
+
+ MyAttached *att = qobject_cast<MyAttached*>(attObj);
+ QVERIFY(att);
+
+ QCOMPARE(att->foo(), 1);
+}
+
+void tst_qquickstates::basicExtension()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicExtension.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2.0);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2.0);
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("fakeExtension.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+}
+
+void tst_qquickstates::basicBinding()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicBinding.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicBinding2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicBinding3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("red"));
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor2", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor2", QColor("green"));
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicBinding4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("purple"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("purple"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+}
+
+void tst_qquickstates::signalOverride()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverride.qml"));
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ QQuickItemPrivate::get(rect)->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverride2.qml"));
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("white"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("extendedRect"));
+ QQuickItemPrivate::get(innerRect)->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(innerRect->color(),QColor("green"));
+ QCOMPARE(innerRect->property("extendedColor").value<QColor>(),QColor("green"));
+ }
+}
+
+void tst_qquickstates::signalOverrideCrash()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash.qml"));
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("overridden");
+ rect->doSomething();
+}
+
+void tst_qquickstates::signalOverrideCrash2()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QQuickItemPrivate::get(rect)->setState("state2");
+ QQuickItemPrivate::get(rect)->setState("state1");
+
+ delete rect;
+}
+
+void tst_qquickstates::signalOverrideCrash3()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QQuickItemPrivate::get(rect)->setState("");
+ QQuickItemPrivate::get(rect)->setState("state2");
+ QQuickItemPrivate::get(rect)->setState("");
+
+ delete rect;
+}
+
+void tst_qquickstates::parentChange()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange1.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickParentChange *pChange = qobject_cast<QQuickParentChange*>(state->operationAt(0));
+ QVERIFY(pChange != 0);
+ QQuickItem *nParent = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("NewParent"));
+ QVERIFY(nParent != 0);
+
+ QCOMPARE(pChange->parent(), nParent);
+
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(-133));
+ QCOMPARE(innerRect->y(), qreal(-300));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rectPrivate->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(15));
+ QCOMPARE(innerRect->scale(), qreal(.5));
+ QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075));
+ QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rectPrivate->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(-37));
+ QCOMPARE(innerRect->scale(), qreal(.25));
+ QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
+ QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ //do a non-qFuzzyCompare fuzzy compare
+ QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange6.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(180));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(-105));
+ QCOMPARE(innerRect->y(), qreal(-105));
+ }
+}
+
+void tst_qquickstates::parentChangeErrors()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale");
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ QCOMPARE(innerRect->y(), qreal(5));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange5.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform");
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ QCOMPARE(innerRect->y(), qreal(5));
+ }
+}
+
+void tst_qquickstates::anchorChanges()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ QCOMPARE(aChanges->anchors()->left().script(), QLatin1String("undefined"));
+ QCOMPARE(aChanges->anchors()->right().script(), QLatin1String("container.right"));
+
+ rectPrivate->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChanges2()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rectPrivate->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChanges3()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ QCOMPARE(aChanges->anchors()->top().script(), QLatin1String("container.top"));
+ QCOMPARE(aChanges->anchors()->bottom().script(), QLatin1String("bottomGuideline.bottom"));
+
+ rectPrivate->setState("reanchored");
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine);
+
+ QCOMPARE(innerRect->x(), qreal(10));
+ QCOMPARE(innerRect->y(), qreal(0));
+ QCOMPARE(innerRect->width(), qreal(190));
+ QCOMPARE(innerRect->height(), qreal(150));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), qreal(0));
+ QCOMPARE(innerRect->y(), qreal(10));
+ QCOMPARE(innerRect->width(), qreal(150));
+ QCOMPARE(innerRect->height(), qreal(190));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChanges4()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ QCOMPARE(aChanges->anchors()->horizontalCenter().script(), QLatin1String("bottomGuideline.horizontalCenter"));
+ QCOMPARE(aChanges->anchors()->verticalCenter().script(), QLatin1String("leftGuideline.verticalCenter"));
+
+ QQuickItemPrivate::get(rect)->setState("reanchored");
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QQuickItemPrivate::get(leftGuideline)->verticalCenter().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QQuickItemPrivate::get(leftGuideline)->verticalCenter().anchorLine);
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChanges5()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges5.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ QCOMPARE(aChanges->anchors()->baseline().script(), QLatin1String("leftGuideline.baseline"));
+
+ QQuickItemPrivate::get(rect)->setState("reanchored");
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().item, QQuickItemPrivate::get(leftGuideline)->baseline().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().anchorLine, QQuickItemPrivate::get(leftGuideline)->baseline().anchorLine);
+
+ delete rect;
+}
+
+void mirrorAnchors(QQuickItem *item) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->setLayoutMirror(true);
+}
+
+qreal offsetRTL(QQuickItem *anchorItem, QQuickItem *item) {
+ return anchorItem->width()+2*anchorItem->x()-item->width();
+}
+
+void tst_qquickstates::anchorChangesRTL()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+ mirrorAnchors(innerRect);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rectPrivate->setState("right");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChangesRTL2()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+ mirrorAnchors(innerRect);
+
+ rectPrivate->setState("right");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChangesRTL3()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+ mirrorAnchors(innerRect);
+
+ QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rectPrivate->setState("reanchored");
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine);
+
+ QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10));
+ QCOMPARE(innerRect->y(), qreal(0));
+ // between left side of parent and leftGuideline.x: 10, which has width 0
+ QCOMPARE(innerRect->width(), qreal(10));
+ QCOMPARE(innerRect->height(), qreal(150));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0));
+ QCOMPARE(innerRect->y(), qreal(10));
+ // between right side of parent and left side of rightGuideline.x: 150, which has width 0
+ QCOMPARE(innerRect->width(), qreal(50));
+ QCOMPARE(innerRect->height(), qreal(190));
+
+ delete rect;
+}
+
+//QTBUG-9609
+void tst_qquickstates::anchorChangesCrash()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChangesCrash.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("reanchored");
+
+ delete rect;
+}
+
+// QTBUG-12273
+void tst_qquickstates::anchorRewindBug()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("anchorRewindBug.qml"));
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(view->rootObject());
+ QVERIFY(rect != 0);
+
+ QQuickItem * column = rect->findChild<QQuickItem*>("column");
+
+ QVERIFY(column != 0);
+ QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
+ QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
+ QCOMPARE(column->height(), 200.0);
+ QQuickItemPrivate::get(rect)->setState("reanchored");
+
+ // column height and width should stay implicit
+ // and column's implicit resizing should still work
+ QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
+ QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
+ QTRY_COMPARE(column->height(), 100.0);
+
+ QQuickItemPrivate::get(rect)->setState("");
+
+ // column height and width should stay implicit
+ // and column's implicit resizing should still work
+ QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
+ QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
+ QTRY_COMPARE(column->height(), 200.0);
+
+ delete view;
+}
+
+// QTBUG-11834
+void tst_qquickstates::anchorRewindBug2()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorRewindBug2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("mover");
+
+ QVERIFY(mover != 0);
+ QCOMPARE(mover->y(), qreal(0.0));
+ QCOMPARE(mover->width(), qreal(50.0));
+
+ QQuickItemPrivate::get(rect)->setState("anchored");
+ QCOMPARE(mover->y(), qreal(250.0));
+ QCOMPARE(mover->width(), qreal(200.0));
+
+ QQuickItemPrivate::get(rect)->setState("");
+ QCOMPARE(mover->y(), qreal(0.0));
+ QCOMPARE(mover->width(), qreal(50.0));
+
+ delete rect;
+}
+
+void tst_qquickstates::script()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("script.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
+ }
+}
+
+void tst_qquickstates::restoreEntryValues()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("restoreEntryValues.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("blue"));
+}
+
+void tst_qquickstates::explicitChanges()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("explicit.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickPropertyChanges *changes = qobject_cast<QQuickPropertyChanges*>(rect->findChild<QQuickPropertyChanges*>("changes"));
+ QVERIFY(changes != 0);
+ QVERIFY(changes->isExplicit());
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+}
+
+void tst_qquickstates::propertyErrors()
+{
+ QQmlEngine engine;
+ QQmlComponent rectComponent(&engine, testFileUrl("propertyErrors.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\"");
+ QQuickItemPrivate::get(rect)->setState("blue");
+}
+
+void tst_qquickstates::incorrectRestoreBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ // make sure if we change the base state value, we then restore to it correctly
+ rect->setColor(QColor("green"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+}
+
+void tst_qquickstates::autoStateAtStartupRestoreBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent component(&engine, testFileUrl("autoStateAtStartupRestoreBug.qml"));
+ QObject *obj = component.create();
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 3);
+
+ obj->setProperty("input", 2);
+
+ QCOMPARE(obj->property("test").toInt(), 9);
+
+ delete obj;
+}
+
+void tst_qquickstates::deletingChange()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("deleting.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(0));
+
+ QQuickPropertyChanges *pc = rect->findChild<QQuickPropertyChanges*>("pc1");
+ QVERIFY(pc != 0);
+ delete pc;
+
+ QQuickState *state = rect->findChild<QQuickState*>();
+ QVERIFY(state != 0);
+ qmlExecuteDeferred(state);
+ QCOMPARE(state->operationCount(), 1);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::deletingState()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("deletingState.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickStateGroup *sg = rect->findChild<QQuickStateGroup*>();
+ QVERIFY(sg != 0);
+ QVERIFY(sg->findState("blue") != 0);
+
+ sg->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ sg->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ QQuickState *state = rect->findChild<QQuickState*>();
+ QVERIFY(state != 0);
+ delete state;
+
+ QVERIFY(sg->findState("blue") == 0);
+
+ //### should we warn that state doesn't exist
+ sg->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ delete rect;
+}
+
+void tst_qquickstates::tempState()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("legalTempState.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QTest::ignoreMessage(QtDebugMsg, "entering placed");
+ QTest::ignoreMessage(QtDebugMsg, "entering idle");
+ rectPrivate->setState("placed");
+ QCOMPARE(rectPrivate->state(), QLatin1String("idle"));
+}
+
+void tst_qquickstates::illegalTempState()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("illegalTempState.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML StateGroup: Can't apply a state change as part of a state definition.");
+ rectPrivate->setState("placed");
+ QCOMPARE(rectPrivate->state(), QLatin1String("placed"));
+}
+
+void tst_qquickstates::nonExistantProperty()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("nonExistantProp.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
+ rectPrivate->setState("blue");
+ QCOMPARE(rectPrivate->state(), QLatin1String("blue"));
+}
+
+void tst_qquickstates::reset()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("reset.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickImage *image = rect->findChild<QQuickImage*>();
+ QVERIFY(image != 0);
+ QCOMPARE(image->width(), qreal(40.));
+ QCOMPARE(image->height(), qreal(20.));
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+
+ QCOMPARE(image->width(), 20.0);
+ QCOMPARE(image->height(), qreal(20.));
+
+ delete rect;
+}
+
+void tst_qquickstates::illegalObjectCreation()
+{
+ QQmlEngine engine;
+
+ QQmlComponent component(&engine, testFileUrl("illegalObj.qml"));
+ QList<QQmlError> errors = component.errors();
+ QVERIFY(errors.count() == 1);
+ const QQmlError &error = errors.at(0);
+ QCOMPARE(error.line(), 9);
+ QCOMPARE(error.column(), 23);
+ QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects.");
+}
+
+void tst_qquickstates::whenOrdering()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("whenOrdering.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ rect->setProperty("condition2", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("state2"));
+ rect->setProperty("condition1", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
+ rect->setProperty("condition2", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
+ rect->setProperty("condition2", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
+ rect->setProperty("condition1", false);
+ rect->setProperty("condition2", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+}
+
+void tst_qquickstates::urlResolution()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("urlResolution.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItem *myType = rect->findChild<QQuickItem*>("MyType");
+ QQuickImage *image1 = rect->findChild<QQuickImage*>("image1");
+ QQuickImage *image2 = rect->findChild<QQuickImage*>("image2");
+ QQuickImage *image3 = rect->findChild<QQuickImage*>("image3");
+ QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0);
+
+ QQuickItemPrivate::get(myType)->setState("SetImageState");
+ QUrl resolved = testFileUrl("Implementation/images/qt-logo.png");
+ QCOMPARE(image1->source(), resolved);
+ QCOMPARE(image2->source(), resolved);
+ QCOMPARE(image3->source(), resolved);
+
+ delete rect;
+}
+
+void tst_qquickstates::unnamedWhen()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("unnamedWhen.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+ rect->setProperty("triggerState", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
+ rect->setProperty("triggerState", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+}
+
+void tst_qquickstates::returnToBase()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("returnToBase.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+ rect->setProperty("triggerState", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
+ rect->setProperty("triggerState", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState"));
+}
+
+//QTBUG-12559
+void tst_qquickstates::extendsBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("extendsBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQuickRectangle *greenRect = rect->findChild<QQuickRectangle*>("greenRect");
+
+ rectPrivate->setState("b");
+ QCOMPARE(greenRect->x(), qreal(100));
+ QCOMPARE(greenRect->y(), qreal(100));
+}
+
+void tst_qquickstates::editProperties()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("editProperties.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickStateGroup *stateGroup = rectPrivate->_states();
+ QVERIFY(stateGroup != 0);
+ qmlExecuteDeferred(stateGroup);
+
+ QQuickState *blueState = stateGroup->findState("blue");
+ QVERIFY(blueState != 0);
+ qmlExecuteDeferred(blueState);
+
+ QQuickPropertyChanges *propertyChangesBlue = qobject_cast<QQuickPropertyChanges*>(blueState->operationAt(0));
+ QVERIFY(propertyChangesBlue != 0);
+
+ QQuickState *greenState = stateGroup->findState("green");
+ QVERIFY(greenState != 0);
+ qmlExecuteDeferred(greenState);
+
+ QQuickPropertyChanges *propertyChangesGreen = qobject_cast<QQuickPropertyChanges*>(greenState->operationAt(0));
+ QVERIFY(propertyChangesGreen != 0);
+
+ QQuickRectangle *childRect = rect->findChild<QQuickRectangle*>("rect2");
+ QVERIFY(childRect != 0);
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ QCOMPARE(childRect->height(), qreal(200));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(50));
+ QCOMPARE(childRect->height(), qreal(40));
+ QVERIFY(!QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ QVERIFY(blueState->bindingInRevertList(childRect, "width"));
+
+
+ rectPrivate->setState("green");
+ QCOMPARE(childRect->width(), qreal(200));
+ QCOMPARE(childRect->height(), qreal(100));
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+
+
+ rectPrivate->setState("");
+
+
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QVERIFY(propertyChangesBlue->containsValue("width"));
+ QVERIFY(!propertyChangesBlue->containsProperty("x"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
+ QVERIFY(!propertyChangesBlue->value("x").isValid());
+
+ propertyChangesBlue->changeValue("width", 60);
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+
+ propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
+ QVERIFY(!propertyChangesBlue->containsValue("width"));
+ QVERIFY(propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+ propertyChangesBlue->changeValue("width", 50);
+ QVERIFY(propertyChangesBlue->containsValue("width"));
+ QVERIFY(!propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(50));
+ QCOMPARE(childRect->height(), qreal(40));
+
+ propertyChangesBlue->changeValue("width", 60);
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(childRect->width(), qreal(60));
+ QVERIFY(!QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+
+ propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
+ QVERIFY(!propertyChangesBlue->containsValue("width"));
+ QVERIFY(propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ QCOMPARE(childRect->width(), qreal(200));
+
+ propertyChangesBlue->changeValue("width", 50);
+ QCOMPARE(childRect->width(), qreal(50));
+
+ rectPrivate->setState("");
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+
+ QCOMPARE(propertyChangesGreen->actions().length(), 2);
+ rectPrivate->setState("green");
+ QCOMPARE(childRect->width(), qreal(200));
+ QCOMPARE(childRect->height(), qreal(100));
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+ QCOMPARE(propertyChangesGreen->actions().length(), 2);
+
+
+ propertyChangesGreen->removeProperty("height");
+ QVERIFY(!QQmlPropertyPrivate::binding(QQmlProperty(childRect, "height")));
+ QCOMPARE(childRect->height(), qreal(200));
+
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+ QVERIFY(greenState->containsPropertyInRevertList(childRect, "width"));
+ propertyChangesGreen->removeProperty("width");
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(!greenState->bindingInRevertList(childRect, "width"));
+ QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width"));
+
+ propertyChangesBlue->removeProperty("width");
+ QCOMPARE(childRect->width(), qreal(402));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(402));
+ QCOMPARE(childRect->height(), qreal(40));
+}
+
+void tst_qquickstates::QTBUG_14830()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("QTBUG-14830.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItem *item = rect->findChild<QQuickItem*>("area");
+
+ QCOMPARE(item->width(), qreal(171));
+}
+
+void tst_qquickstates::avoidFastForward()
+{
+ QQmlEngine engine;
+
+ //shouldn't fast forward if there isn't a transition
+ QQmlComponent c(&engine, testFileUrl("avoidFastForward.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ rectPrivate->setState("a");
+ QCOMPARE(rect->property("updateCount").toInt(), 1);
+}
+
+//QTBUG-22583
+void tst_qquickstates::revertListBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("revertListBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *rect1 = rect->findChild<QQuickRectangle*>("rect1");
+ QQuickRectangle *rect2 = rect->findChild<QQuickRectangle*>("rect2");
+ QQuickItem *origParent1 = rect->findChild<QQuickItem*>("originalParent1");
+ QQuickItem *origParent2 = rect->findChild<QQuickItem*>("originalParent2");
+ QQuickItem *newParent = rect->findChild<QQuickItem*>("newParent");
+
+ QCOMPARE(rect1->parentItem(), origParent1);
+ QCOMPARE(rect2->parentItem(), origParent2);
+
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ rectPrivate->setState("reparented");
+
+ QCOMPARE(rect1->parentItem(), newParent);
+ QCOMPARE(rect2->parentItem(), origParent2);
+
+ rectPrivate->setState("");
+
+ QCOMPARE(rect1->parentItem(), origParent1);
+ QCOMPARE(rect2->parentItem(), origParent2);
+
+ QMetaObject::invokeMethod(rect, "switchTargetItem");
+
+ rectPrivate->setState("reparented");
+
+ QCOMPARE(rect1->parentItem(), origParent1);
+ QCOMPARE(rect2->parentItem(), newParent);
+
+ rectPrivate->setState("");
+
+ QCOMPARE(rect1->parentItem(), origParent1);
+ QCOMPARE(rect2->parentItem(), origParent2); //QTBUG-22583 causes rect2's parent item to be origParent1
+}
+
+QTEST_MAIN(tst_qquickstates)
+
+#include "tst_qquickstates.moc"
diff --git a/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro b/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro
new file mode 100644
index 0000000000..bd367d5ce2
--- /dev/null
+++ b/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qquickstyledtext
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickstyledtext.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
new file mode 100644
index 0000000000..35ce724a64
--- /dev/null
+++ b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtGui/QTextLayout>
+#include <QtCore/QList>
+#include <QtQuick/private/qquickstyledtext_p.h>
+
+class tst_qquickstyledtext : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qquickstyledtext()
+ {
+ }
+
+ struct Format {
+ enum Type {
+ Bold = 0x01,
+ Underline = 0x02,
+ Italic = 0x04
+ };
+ Format(int t, int s, int l)
+ : type(t), start(s), length(l) {}
+ int type;
+ int start;
+ int length;
+ };
+ typedef QList<Format> FormatList;
+
+ static const QChar bullet;
+ static const QChar disc;
+ static const QChar square;
+
+private slots:
+ void textOutput();
+ void textOutput_data();
+};
+
+Q_DECLARE_METATYPE(tst_qquickstyledtext::FormatList);
+
+const QChar tst_qquickstyledtext::bullet(0x2022);
+const QChar tst_qquickstyledtext::disc(0x25e6);
+const QChar tst_qquickstyledtext::square(0x25a1);
+
+// For malformed input all we test is that we get the expected text and format out.
+//
+void tst_qquickstyledtext::textOutput_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("output");
+ QTest::addColumn<FormatList>("formats");
+ QTest::addColumn<bool>("modifiesFontSize");
+
+ QTest::newRow("bold") << "<b>bold</b>" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("italic") << "<i>italic</i>" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)) << false;
+ QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
+ QTest::newRow("strong") << "<strong>strong</strong>" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)) << false;
+ QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
+ QTest::newRow("missing >") << "<b>text</b" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("missing b>") << "<b>text</" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("missing /b>") << "<b>text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("missing </b>") << "<b>text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("nested") << "<b>text <i>italic</i> bold</b>" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)) << false;
+ QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)) << false;
+ QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text" << (FormatList() << Format(0, 0, 8)) << false;
+ QTest::newRow("font color: single quote") << "<font color='red'>red text</font>" << "red text" << (FormatList() << Format(0, 0, 8)) << false;
+ QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text" << (FormatList() << Format(0, 0, 4)) << true;
+ QTest::newRow("font empty") << "<font>text</font>" << "text" << FormatList() << false;
+ QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text" << FormatList() << false;
+ QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << "" << FormatList() << false;
+ QTest::newRow("extra close") << "<b>text</b></b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("extra space") << "<b >text</b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("entities") << "&lt;b&gt;this &amp; that&lt;/b&gt;" << "<b>this & that</b>" << FormatList() << false;
+ QTest::newRow("newline") << "text<br>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("paragraph") << "text<p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("paragraph closed") << "text<p>more text</p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("paragraph closed bold") << "<b>text<p>more text</p>more text</b>" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)) << false;
+ QTest::newRow("self-closing newline") << "text<br/>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("empty") << "" << "" << FormatList() << false;
+ QTest::newRow("unknown tag") << "<a href='#'><foo>underline</foo></a> not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
+ QTest::newRow("ordered list") << "<ol><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false;
+ QTest::newRow("ordered list closed") << "<ol><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list alpha") << "<ol type=\"a\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list upper alpha") << "<ol type=\"A\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list roman") << "<ol type=\"i\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list upper roman") << "<ol type=\"I\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list bad") << "<ol type=\"z\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("unordered list") << "<ul><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false;
+ QTest::newRow("unordered list closed") << "<ul><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("unordered list disc") << "<ul type=\"disc\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("unordered list square") << "<ul type=\"square\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("unordered list bad") << "<ul type=\"bad\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("header close") << "<h1>head</h1>more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h0") << "<h0>head" << "head" << FormatList() << false;
+ QTest::newRow("h1") << "<h1>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h2") << "<h2>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h3") << "<h3>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h4") << "<h4>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h5") << "<h5>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h6") << "<h6>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h7") << "<h7>head" << "head" << FormatList() << false;
+ QTest::newRow("pre") << "normal<pre>pre text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)) << false;
+ QTest::newRow("pre lb") << "normal<pre>pre\n text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)) << false;
+ QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList() << false;
+ QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList() << false;
+ QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList() << false;
+ QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList() << false;
+ QTest::newRow("space after newline") << "text<br/> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("space after paragraph") << "text<p> more text</p> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("space in header") << "<h1> head</h1> " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("space before bold") << "this is <b>bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)) << false;
+ QTest::newRow("space leading bold") << "this is<b> bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)) << false;
+ QTest::newRow("space trailing bold") << "this is <b>bold </b>" << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)) << false;
+ QTest::newRow("img") << "a<img src=\"blah.png\"/>b" << "a b" << FormatList() << false;
+}
+
+void tst_qquickstyledtext::textOutput()
+{
+ QFETCH(QString, input);
+ QFETCH(QString, output);
+ QFETCH(FormatList, formats);
+ QFETCH(bool, modifiesFontSize);
+
+ QTextLayout layout;
+ QList<QQuickStyledTextImgTag*> imgTags;
+ bool fontSizeModified = false;
+ QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified);
+
+ QCOMPARE(layout.text(), output);
+
+ QList<QTextLayout::FormatRange> layoutFormats = layout.additionalFormats();
+
+ QCOMPARE(layoutFormats.count(), formats.count());
+ for (int i = 0; i < formats.count(); ++i) {
+ QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
+ QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
+ if (formats.at(i).type & Format::Bold)
+ QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Bold);
+ else
+ QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Normal);
+ QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic));
+ QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline));
+ }
+ QCOMPARE(fontSizeModified, modifiesFontSize);
+}
+
+
+QTEST_MAIN(tst_qquickstyledtext)
+
+#include "tst_qquickstyledtext.moc"
diff --git a/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro b/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro
new file mode 100644
index 0000000000..c8825c07fb
--- /dev/null
+++ b/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qquicksystempalette
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicksystempalette.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private widgets testlib
diff --git a/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp b/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp
new file mode 100644
index 0000000000..3b74dfd0ed
--- /dev/null
+++ b/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicksystempalette_p.h>
+#include <qpalette.h>
+
+class tst_qquicksystempalette : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qquicksystempalette();
+
+private slots:
+ void activePalette();
+ void inactivePalette();
+ void disabledPalette();
+ void paletteChanged();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquicksystempalette::tst_qquicksystempalette()
+{
+}
+
+void tst_qquicksystempalette::activePalette()
+{
+ QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Active);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qquicksystempalette::inactivePalette()
+{
+ QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Inactive }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+ QVERIFY(object->colorGroup() == QQuickSystemPalette::Inactive);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Inactive);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qquicksystempalette::disabledPalette()
+{
+ QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Disabled }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+ QVERIFY(object->colorGroup() == QQuickSystemPalette::Disabled);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Disabled);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qquicksystempalette::paletteChanged()
+{
+ QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+
+ QPalette p;
+ p.setCurrentColorGroup(QPalette::Active);
+ p.setColor(QPalette::Active, QPalette::Text, QColor("red"));
+ p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green"));
+ p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue"));
+
+ qApp->setPalette(p);
+
+ object->setColorGroup(QQuickSystemPalette::Active);
+ QTRY_COMPARE(QColor("red"), object->text());
+ QTRY_COMPARE(QColor("green"), object->buttonText());
+ QTRY_COMPARE(QColor("blue"), object->windowText());
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qquicksystempalette)
+
+#include "tst_qquicksystempalette.moc"
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments.qml b/tests/auto/quick/qquicktext/data/alignments.qml
index 9798d9c736..9798d9c736 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments.qml
+++ b/tests/auto/quick/qquicktext/data/alignments.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_cb.png b/tests/auto/quick/qquicktext/data/alignments_cb.png
index cf6199a418..cf6199a418 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_cb.png
+++ b/tests/auto/quick/qquicktext/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_cc.png b/tests/auto/quick/qquicktext/data/alignments_cc.png
index f81ccb4238..f81ccb4238 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_cc.png
+++ b/tests/auto/quick/qquicktext/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_ct.png b/tests/auto/quick/qquicktext/data/alignments_ct.png
index 9ba64125d5..9ba64125d5 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_ct.png
+++ b/tests/auto/quick/qquicktext/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lb.png b/tests/auto/quick/qquicktext/data/alignments_lb.png
index 1b50a81f3d..1b50a81f3d 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_lb.png
+++ b/tests/auto/quick/qquicktext/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lc.png b/tests/auto/quick/qquicktext/data/alignments_lc.png
index f041b868f8..f041b868f8 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_lc.png
+++ b/tests/auto/quick/qquicktext/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lt.png b/tests/auto/quick/qquicktext/data/alignments_lt.png
index c75e0d158e..c75e0d158e 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_lt.png
+++ b/tests/auto/quick/qquicktext/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rb.png b/tests/auto/quick/qquicktext/data/alignments_rb.png
index b06a5da715..b06a5da715 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_rb.png
+++ b/tests/auto/quick/qquicktext/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rc.png b/tests/auto/quick/qquicktext/data/alignments_rc.png
index e468857cd0..e468857cd0 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_rc.png
+++ b/tests/auto/quick/qquicktext/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rt.png b/tests/auto/quick/qquicktext/data/alignments_rt.png
index 576715ffce..576715ffce 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_rt.png
+++ b/tests/auto/quick/qquicktext/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml
index 74b2ab817a..74b2ab817a 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml
index a2f7e0c89f..a2f7e0c89f 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml
index 8de7364d08..8de7364d08 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml
index 702633c538..702633c538 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml
index 5762f3e47d..5762f3e47d 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml
index cee19740f9..cee19740f9 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
index 84f7ce8d50..84f7ce8d50 100644
--- a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml
+++ b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml
index 5ba4d35684..5ba4d35684 100644
--- a/tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml
+++ b/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/http/exists.png b/tests/auto/quick/qquicktext/data/http/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qquicktext/data/http/exists.png
+++ b/tests/auto/quick/qquicktext/data/http/exists.png
Binary files differ
diff --git a/tests/auto/quick/qquicktext/data/images/face-sad.png b/tests/auto/quick/qquicktext/data/images/face-sad.png
new file mode 100644
index 0000000000..24188b7985
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/images/face-sad.png
Binary files differ
diff --git a/tests/auto/quick/qquicktext/data/images/heart200.png b/tests/auto/quick/qquicktext/data/images/heart200.png
new file mode 100644
index 0000000000..cedd3ea608
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/images/heart200.png
Binary files differ
diff --git a/tests/auto/quick/qquicktext/data/images/starfish_2.png b/tests/auto/quick/qquicktext/data/images/starfish_2.png
new file mode 100644
index 0000000000..132c20ffd0
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/images/starfish_2.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml b/tests/auto/quick/qquicktext/data/imgTagsElide.qml
index fbd64cc5bf..fbd64cc5bf 100644
--- a/tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml
+++ b/tests/auto/quick/qquicktext/data/imgTagsElide.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml b/tests/auto/quick/qquicktext/data/imgTagsUpdates.qml
index baf5113e52..baf5113e52 100644
--- a/tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml
+++ b/tests/auto/quick/qquicktext/data/imgTagsUpdates.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/lineCount.qml b/tests/auto/quick/qquicktext/data/lineCount.qml
index b672863684..b672863684 100644
--- a/tests/auto/qtquick2/qquicktext/data/lineCount.qml
+++ b/tests/auto/quick/qquicktext/data/lineCount.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/lineHeight.qml b/tests/auto/quick/qquicktext/data/lineHeight.qml
index c1f337aa05..c1f337aa05 100644
--- a/tests/auto/qtquick2/qquicktext/data/lineHeight.qml
+++ b/tests/auto/quick/qquicktext/data/lineHeight.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/lineLayout.qml b/tests/auto/quick/qquicktext/data/lineLayout.qml
index cb2474791e..cb2474791e 100644
--- a/tests/auto/qtquick2/qquicktext/data/lineLayout.qml
+++ b/tests/auto/quick/qquicktext/data/lineLayout.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml b/tests/auto/quick/qquicktext/data/multilengthStrings.qml
index 6b9dc71fbc..6b9dc71fbc 100644
--- a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml
+++ b/tests/auto/quick/qquicktext/data/multilengthStrings.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml b/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml
index 21f1b20619..21f1b20619 100644
--- a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml
+++ b/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml b/tests/auto/quick/qquicktext/data/multilineelide.qml
index ffca0d638a..ffca0d638a 100644
--- a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml
+++ b/tests/auto/quick/qquicktext/data/multilineelide.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml b/tests/auto/quick/qquicktext/data/pixelFontSizes.qml
index e3d81b682e..e3d81b682e 100644
--- a/tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml
+++ b/tests/auto/quick/qquicktext/data/pixelFontSizes.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml b/tests/auto/quick/qquicktext/data/pointFontSizes.qml
index 6feb8fecf8..6feb8fecf8 100644
--- a/tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml
+++ b/tests/auto/quick/qquicktext/data/pointFontSizes.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml b/tests/auto/quick/qquicktext/data/qtbug_14734.qml
index e71a798421..e71a798421 100644
--- a/tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml
+++ b/tests/auto/quick/qquicktext/data/qtbug_14734.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/rotated.qml b/tests/auto/quick/qquicktext/data/rotated.qml
index fecf64b249..fecf64b249 100644
--- a/tests/auto/qtquick2/qquicktext/data/rotated.qml
+++ b/tests/auto/quick/qquicktext/data/rotated.qml
diff --git a/tests/auto/quick/qquicktext/qquicktext.pro b/tests/auto/quick/qquicktext/qquicktext.pro
new file mode 100644
index 0000000000..67e0b9fb90
--- /dev/null
+++ b/tests/auto/quick/qquicktext/qquicktext.pro
@@ -0,0 +1,19 @@
+CONFIG += testcase
+TARGET = tst_qquicktext
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktext.cpp
+
+INCLUDEPATH += ../../shared/
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private widgets-private opengl-private network testlib
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
new file mode 100644
index 0000000000..54b5a04466
--- /dev/null
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -0,0 +1,2484 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QTextDocument>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <private/qquicktext_p_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <QFontMetrics>
+#include <QGraphicsSceneMouseEvent>
+#include <qmath.h>
+#include <QtQuick/QQuickView>
+#include <private/qapplication_p.h>
+#include <limits.h>
+#include <QtGui/QMouseEvent>
+#include "../../shared/util.h"
+#include "testhttpserver.h"
+
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
+
+Q_DECLARE_METATYPE(QQuickText::TextFormat)
+
+class tst_qquicktext : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquicktext();
+
+private slots:
+ void text();
+ void width();
+ void wrap();
+ void elide();
+ void multilineElide_data();
+ void multilineElide();
+ void textFormat();
+
+ void alignments_data();
+ void alignments();
+
+ void baseUrl();
+ void embeddedImages_data();
+ void embeddedImages();
+
+ void lineCount();
+ void lineHeight();
+
+ // ### these tests may be trivial
+ void horizontalAlignment();
+ void horizontalAlignment_RightToLeft();
+ void verticalAlignment();
+ void font();
+ void style();
+ void color();
+ void smooth();
+
+ // QQmlFontValueType
+ void weight();
+ void underline();
+ void overline();
+ void strikeout();
+ void capitalization();
+ void letterSpacing();
+ void wordSpacing();
+
+ void clickLink();
+
+ void implicitSize_data();
+ void implicitSize();
+ void contentSize();
+
+ void lineLaidOut();
+
+ void imgTagsBaseUrl_data();
+ void imgTagsBaseUrl();
+ void imgTagsAlign_data();
+ void imgTagsAlign();
+ void imgTagsMultipleImages();
+ void imgTagsElide();
+ void imgTagsUpdates();
+ void imgTagsError();
+ void fontSizeMode_data();
+ void fontSizeMode();
+ void fontSizeModeMultiline_data();
+ void fontSizeModeMultiline();
+ void multilengthStrings_data();
+ void multilengthStrings();
+ void fontFormatSizes_data();
+ void fontFormatSizes();
+
+private:
+ QStringList standard;
+ QStringList richText;
+
+ QStringList horizontalAlignmentmentStrings;
+ QStringList verticalAlignmentmentStrings;
+
+ QList<Qt::Alignment> verticalAlignmentments;
+ QList<Qt::Alignment> horizontalAlignmentments;
+
+ QStringList styleStrings;
+ QList<QQuickText::TextStyle> styles;
+
+ QStringList colorStrings;
+
+ QQmlEngine engine;
+
+ QQuickView *createView(const QString &filename);
+};
+
+tst_qquicktext::tst_qquicktext()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "the quick brown fox\n jumped over the lazy dog";
+
+ richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
+ << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
+
+ horizontalAlignmentmentStrings << "AlignLeft"
+ << "AlignRight"
+ << "AlignHCenter";
+
+ verticalAlignmentmentStrings << "AlignTop"
+ << "AlignBottom"
+ << "AlignVCenter";
+
+ horizontalAlignmentments << Qt::AlignLeft
+ << Qt::AlignRight
+ << Qt::AlignHCenter;
+
+ verticalAlignmentments << Qt::AlignTop
+ << Qt::AlignBottom
+ << Qt::AlignVCenter;
+
+ styleStrings << "Normal"
+ << "Outline"
+ << "Raised"
+ << "Sunken";
+
+ styles << QQuickText::Normal
+ << QQuickText::Outline
+ << QQuickText::Raised
+ << QQuickText::Sunken;
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+ //
+ // need a different test to do alpha channel test
+ // << "#AA0011DD"
+ // << "#00F16B11";
+ //
+}
+
+QQuickView *tst_qquicktext::createView(const QString &filename)
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ return canvas;
+}
+
+void tst_qquicktext::text()
+{
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), QString(""));
+ QVERIFY(textObject->width() == 0);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), standard.at(i));
+ QVERIFY(textObject->width() > 0);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QString expected = richText.at(i);
+ QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
+ QVERIFY(textObject->width() > 0);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 0.);
+
+ delete textObject;
+ }
+
+ bool requiresUnhintedMetrics = !qmlDisableDistanceField();
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
+
+ QFont f;
+ qreal metricWidth = 0.0;
+
+ if (requiresUnhintedMetrics) {
+ QString s = standard.at(i);
+ s.replace(QLatin1Char('\n'), QChar::LineSeparator);
+
+ QTextLayout layout(s);
+ layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
+ {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ }
+
+ layout.endLayout();
+
+ metricWidth = layout.boundingRect().width();
+ } else {
+ QFontMetricsF fm(f);
+ metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ }
+
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->boundingRect().width() > 0);
+ QCOMPARE(textObject->width(), qreal(metricWidth));
+ QVERIFY(textObject->textFormat() == QQuickText::AutoText); // setting text doesn't change format
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
+
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\"; textFormat: Text.RichText }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QVERIFY(textObject != 0);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->extra.isAllocated());
+
+ QTextDocument *doc = textPrivate->extra->doc;
+ QVERIFY(doc != 0);
+
+ QCOMPARE(int(textObject->width()), int(doc->idealWidth()));
+ QVERIFY(textObject->textFormat() == QQuickText::RichText);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::wrap()
+{
+ int textHeight = 0;
+ // for specified width and wrap set true
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ textHeight = textObject->height();
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->wrapMode() == QQuickText::WordWrap);
+ QCOMPARE(textObject->width(), 300.);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+
+ int oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+
+ qreal oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
+
+ delete textObject;
+ }
+
+ // richtext again with a fixed height
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->implicitHeight() > textHeight);
+
+ qreal oldHeight = textObject->implicitHeight();
+ textObject->setWidth(100);
+ QVERIFY(textObject->implicitHeight() < oldHeight);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::elide()
+{
+ for (QQuickText::TextElideMode m = QQuickText::ElideLeft; m<=QQuickText::ElideNone; m=QQuickText::TextElideMode(int(m)+1)) {
+ const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
+ QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
+
+ // XXX Poor coverage.
+
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(("import QtQuick 2.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+
+ if (m != QQuickText::ElideNone && !standard.at(i).contains('\n'))
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+
+ if (m != QQuickText::ElideNone && standard.at(i).contains("<br>"))
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+
+ delete textObject;
+ }
+ }
+}
+
+void tst_qquicktext::multilineElide_data()
+{
+ QTest::addColumn<QQuickText::TextFormat>("format");
+ QTest::newRow("plain") << QQuickText::PlainText;
+ QTest::newRow("styled") << QQuickText::StyledText;
+}
+
+void tst_qquicktext::multilineElide()
+{
+ QFETCH(QQuickText::TextFormat, format);
+ QQuickView *canvas = createView(testFile("multilineelide.qml"));
+
+ QQuickText *myText = qobject_cast<QQuickText*>(canvas->rootObject());
+ QVERIFY(myText != 0);
+ myText->setTextFormat(format);
+
+ QCOMPARE(myText->lineCount(), 3);
+ QCOMPARE(myText->truncated(), true);
+
+ qreal lineHeight = myText->contentHeight() / 3.;
+
+ // Set a valid height greater than the truncated content height and ensure the line count is
+ // unchanged.
+ myText->setHeight(200);
+ QCOMPARE(myText->lineCount(), 3);
+ QCOMPARE(myText->truncated(), true);
+
+ // reduce size and ensure fewer lines are drawn
+ myText->setHeight(lineHeight * 2);
+ QCOMPARE(myText->lineCount(), 2);
+
+ myText->setHeight(lineHeight);
+ QCOMPARE(myText->lineCount(), 1);
+
+ myText->setHeight(5);
+ QCOMPARE(myText->lineCount(), 1);
+
+ myText->setHeight(lineHeight * 3);
+ QCOMPARE(myText->lineCount(), 3);
+
+ // remove max count and show all lines.
+ myText->setHeight(1000);
+ myText->resetMaximumLineCount();
+
+ QCOMPARE(myText->truncated(), false);
+
+ // reduce size again
+ myText->setHeight(lineHeight * 2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+
+ // change line height
+ myText->setLineHeight(1.1);
+ QCOMPARE(myText->lineCount(), 1);
+
+ delete canvas;
+}
+
+void tst_qquicktext::textFormat()
+{
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickText::RichText);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->richText == true);
+
+ delete textObject;
+ }
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"<b>Hello</b>\" }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickText::AutoText);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->styledText == true);
+
+ delete textObject;
+ }
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickText::PlainText);
+
+ delete textObject;
+ }
+}
+
+
+void tst_qquicktext::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << testFile("alignments_lt.png");
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << testFile("alignments_rt.png");
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << testFile("alignments_ct.png");
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << testFile("alignments_lb.png");
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << testFile("alignments_rb.png");
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << testFile("alignments_cb.png");
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << testFile("alignments_lc.png");
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << testFile("alignments_rc.png");
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << testFile("alignments_cc.png");
+}
+
+
+void tst_qquicktext::alignments()
+{
+ QSKIP("Text alignment pixmap comparison tests will not work with scenegraph");
+#if (0)// No widgets in scenegraph
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+ QQuickView *canvas = createView(testFile("alignments.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWait(50);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QObject *ob = canvas->rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
+ actual.fill(qRgb(255,255,255));
+ QPainter p(&actual);
+ canvas->render(&p);
+
+ QImage expect(expectfile);
+ if (QGuiApplicationPrivate::graphics_system_name == "raster" || QGuiApplicationPrivate::graphics_system_name == "") {
+ QCOMPARE(actual,expect);
+ }
+ delete canvas;
+#endif
+}
+
+//the alignment tests may be trivial o.oa
+void tst_qquicktext::horizontalAlignment()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
+
+ delete textObject;
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
+
+ delete textObject;
+ }
+ }
+
+}
+
+void tst_qquicktext::horizontalAlignment_RightToLeft()
+{
+ QQuickView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml"));
+ QQuickText *text = canvas->rootObject()->findChild<QQuickText*>("text");
+ QVERIFY(text != 0);
+ canvas->show();
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(text);
+ QVERIFY(textPrivate != 0);
+
+ QTRY_VERIFY(textPrivate->layout.lineCount());
+
+ // implicit alignment should follow the reading direction of RTL text
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // explicitly left aligned text
+ text->setHAlign(QQuickText::AlignLeft);
+ QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
+
+ // explicitly right aligned text
+ text->setHAlign(QQuickText::AlignRight);
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // change to rich text
+ QString textString = text->text();
+ text->setText(QString("<i>") + textString + QString("</i>"));
+ text->setTextFormat(QQuickText::RichText);
+ text->resetHAlign();
+
+ // implicitly aligned rich text should follow the reading direction of text
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->extra.isAllocated());
+ QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft);
+
+ // explicitly left aligned rich text
+ text->setHAlign(QQuickText::AlignLeft);
+ QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignRight);
+
+ // explicitly right aligned rich text
+ text->setHAlign(QQuickText::AlignRight);
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft);
+
+ text->setText(textString);
+ text->setTextFormat(QQuickText::PlainText);
+
+ // explicitly center aligned
+ text->setHAlign(QQuickText::AlignHCenter);
+ QCOMPARE(text->hAlign(), QQuickText::AlignHCenter);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2);
+
+ // reseted alignment should go back to following the text reading direction
+ text->resetHAlign();
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // mirror the text item
+ QQuickItemPrivate::get(text)->setLayoutMirror(true);
+
+ // mirrored implicit alignment should continue to follow the reading direction of the text
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // mirrored explicitly right aligned behaves as left aligned
+ text->setHAlign(QQuickText::AlignRight);
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), QQuickText::AlignLeft);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
+
+ // mirrored explicitly left aligned behaves as right aligned
+ text->setHAlign(QQuickText::AlignLeft);
+ QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
+ QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // disable mirroring
+ QQuickItemPrivate::get(text)->setLayoutMirror(false);
+ text->resetHAlign();
+
+ // English text should be implicitly left aligned
+ text->setText("Hello world!");
+ QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
+
+ // empty text with implicit alignment follows the system locale-based
+ // keyboard input direction from QInputMethod::inputDirection()
+ text->setText("");
+ QCOMPARE(text->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
+ QQuickText::AlignLeft : QQuickText::AlignRight);
+ text->setHAlign(QQuickText::AlignRight);
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+
+ delete canvas;
+
+ // alignment of Text with no text set to it
+ QString componentStr = "import QtQuick 2.0\nText {}";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
+ QQuickText::AlignLeft : QQuickText::AlignRight);
+ delete textObject;
+}
+
+void tst_qquicktext::verticalAlignment()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
+
+ delete textObject;
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
+
+ delete textObject;
+ }
+ }
+
+}
+
+void tst_qquicktext::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.pointSize: 40; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().pointSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.pixelSize: 40; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().pixelSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.bold: true; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().bold(), true);
+ QCOMPARE(textObject->font().italic(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.italic: true; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().italic(), true);
+ QCOMPARE(textObject->font().bold(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.family: \"\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().family(), QString(""));
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::style()
+{
+ //test style
+ for (int i = 0; i < styles.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->style(), (int)styles.at(i));
+ QCOMPARE(textObject->styleColor(), QColor("white"));
+
+ delete textObject;
+ }
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QRectF brPre = textObject->boundingRect();
+ textObject->setStyle(QQuickText::Outline);
+ QRectF brPost = textObject->boundingRect();
+
+ QVERIFY(brPre.width() < brPost.width());
+ QVERIFY(brPre.height() < brPost.height());
+
+ delete textObject;
+}
+
+void tst_qquicktext::color()
+{
+ //test style
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor("black"));
+ QCOMPARE(textObject->linkColor(), QColor("blue"));
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
+ // default color to black?
+ QCOMPARE(textObject->color(), QColor("black"));
+ QCOMPARE(textObject->linkColor(), QColor("blue"));
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->styleColor(), QColor("black"));
+ QCOMPARE(textObject->color(), QColor("black"));
+ QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(i)));
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ for (int j = 0; j < colorStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { "
+ "color: \"" + colorStrings.at(i) + "\"; "
+ "styleColor: \"" + colorStrings.at(j) + "\"; "
+ "linkColor: \"" + colorStrings.at(j) + "\"; "
+ "text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
+ QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(j)));
+
+ delete textObject;
+ }
+ }
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), testColor);
+
+ delete textObject;
+ } {
+ QString colorStr = "#001234";
+ QColor testColor(colorStr);
+
+ QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(colorChanged()));
+
+ QCOMPARE(textObject->color(), testColor);
+ textObject->setColor(testColor);
+ QCOMPARE(textObject->color(), testColor);
+ QCOMPARE(spy.count(), 0);
+
+ testColor = QColor("black");
+ textObject->setColor(testColor);
+ QCOMPARE(textObject->color(), testColor);
+ QCOMPARE(spy.count(), 1);
+ } {
+ QString colorStr = "#001234";
+ QColor testColor(colorStr);
+
+ QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(styleColorChanged()));
+
+ QCOMPARE(textObject->styleColor(), testColor);
+ textObject->setStyleColor(testColor);
+ QCOMPARE(textObject->styleColor(), testColor);
+ QCOMPARE(spy.count(), 0);
+
+ testColor = QColor("black");
+ textObject->setStyleColor(testColor);
+ QCOMPARE(textObject->styleColor(), testColor);
+ QCOMPARE(spy.count(), 1);
+ } {
+ QString colorStr = "#001234";
+ QColor testColor(colorStr);
+
+ QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(linkColorChanged()));
+
+ QCOMPARE(textObject->linkColor(), testColor);
+ textObject->setLinkColor(testColor);
+ QCOMPARE(textObject->linkColor(), testColor);
+ QCOMPARE(spy.count(), 0);
+
+ testColor = QColor("black");
+ textObject->setLinkColor(testColor);
+ QCOMPARE(textObject->linkColor(), testColor);
+ QCOMPARE(spy.count(), 1);
+ }
+}
+
+void tst_qquicktext::smooth()
+{
+ for (int i = 0; i < standard.size(); i++)
+ {
+ {
+ QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), true);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), false);
+
+ delete textObject;
+ }
+ }
+ for (int i = 0; i < richText.size(); i++)
+ {
+ {
+ QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), true);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), false);
+
+ delete textObject;
+ }
+ }
+}
+
+void tst_qquicktext::weight()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().weight(), (int)QQmlFontValueType::Normal);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().weight(), (int)QQmlFontValueType::Bold);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::underline()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().underline(), false);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.underline: true; text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().underline(), true);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::overline()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().overline(), false);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.overline: true; text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().overline(), true);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::strikeout()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().strikeOut(), false);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.strikeout: true; text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().strikeOut(), true);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::capitalization()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::MixedCase);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::AllUppercase);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::AllLowercase);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::SmallCaps);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::Capitalize);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::letterSpacing()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), 0.0);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), -2.);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), 3.);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::wordSpacing()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), 0.0);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), -50.);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), 200.);
+
+ delete textObject;
+ }
+}
+
+
+
+
+class EventSender : public QQuickItem
+{
+public:
+ void sendEvent(QMouseEvent *event) {
+ if (event->type() == QEvent::MouseButtonPress)
+ mousePressEvent(event);
+ else if (event->type() == QEvent::MouseButtonRelease)
+ mouseReleaseEvent(event);
+ else
+ qWarning() << "Trying to send unsupported event type";
+ }
+};
+
+class LinkTest : public QObject
+{
+ Q_OBJECT
+public:
+ LinkTest() {}
+
+ QString link;
+
+public slots:
+ void linkClicked(QString l) { link = l; }
+};
+
+void tst_qquicktext::clickLink()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+
+ LinkTest test;
+ QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
+
+ {
+ QMouseEvent me(QEvent::MouseButtonPress,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
+ static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me);
+
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseButtonRelease,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
+ static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me);
+
+ }
+
+
+ QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::baseUrl()
+{
+ QUrl localUrl("file:///tests/text.qml");
+ QUrl remoteUrl("http://qt.nokia.com/test.qml");
+
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\n Text {}", localUrl);
+ QQuickText *textObject = qobject_cast<QQuickText *>(textComponent.create());
+
+ QCOMPARE(textObject->baseUrl(), localUrl);
+
+ QSignalSpy spy(textObject, SIGNAL(baseUrlChanged()));
+
+ textObject->setBaseUrl(localUrl);
+ QCOMPARE(textObject->baseUrl(), localUrl);
+ QCOMPARE(spy.count(), 0);
+
+ textObject->setBaseUrl(remoteUrl);
+ QCOMPARE(textObject->baseUrl(), remoteUrl);
+ QCOMPARE(spy.count(), 1);
+
+ textObject->resetBaseUrl();
+ QCOMPARE(textObject->baseUrl(), localUrl);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktext::embeddedImages_data()
+{
+ QTest::addColumn<QUrl>("qmlfile");
+ QTest::addColumn<QString>("error");
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
+ QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
+ << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString();
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
+ QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
+ << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
+}
+
+void tst_qquicktext::embeddedImages()
+{
+ // Tests QTBUG-9900
+
+ QFETCH(QUrl, qmlfile);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(14453);
+ server.serveDirectory(testFile("http"));
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
+
+ QQmlComponent textComponent(&engine, qmlfile);
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+
+ QTRY_COMPARE(textObject->resourcesLoading(), 0);
+
+ QPixmap pm(testFile("http/exists.png"));
+ if (error.isEmpty()) {
+ QCOMPARE(textObject->width(), double(pm.width()));
+ QCOMPARE(textObject->height(), double(pm.height()));
+ } else {
+ QVERIFY(16 != pm.width()); // check test is effective
+ QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
+ QCOMPARE(textObject->height(), 16.0);
+ }
+
+ delete textObject;
+}
+
+void tst_qquicktext::lineCount()
+{
+ QQuickView *canvas = createView(testFile("lineCount.qml"));
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QVERIFY(myText->lineCount() > 1);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->maximumLineCount(), INT_MAX);
+
+ myText->setMaximumLineCount(2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+ QCOMPARE(myText->maximumLineCount(), 2);
+
+ myText->resetMaximumLineCount();
+ QCOMPARE(myText->maximumLineCount(), INT_MAX);
+ QCOMPARE(myText->truncated(), false);
+
+ myText->setElideMode(QQuickText::ElideRight);
+ myText->setMaximumLineCount(2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+ QCOMPARE(myText->maximumLineCount(), 2);
+
+ delete canvas;
+}
+
+void tst_qquicktext::lineHeight()
+{
+ QQuickView *canvas = createView(testFile("lineHeight.qml"));
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QVERIFY(myText->lineHeight() == 1);
+ QVERIFY(myText->lineHeightMode() == QQuickText::ProportionalHeight);
+
+ qreal h = myText->height();
+ myText->setLineHeight(1.5);
+ QCOMPARE(myText->height(), qreal(qCeil(h * 1.5)));
+
+ myText->setLineHeightMode(QQuickText::FixedHeight);
+ myText->setLineHeight(20);
+ QCOMPARE(myText->height(), myText->lineCount() * 20.0);
+
+ myText->setText("Lorem ipsum sit <b>amet</b>, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum.");
+ myText->setLineHeightMode(QQuickText::ProportionalHeight);
+ myText->setLineHeight(1.0);
+
+ qreal h2 = myText->height();
+ myText->setLineHeight(2.0);
+ QVERIFY(myText->height() == h2 * 2.0);
+
+ myText->setLineHeightMode(QQuickText::FixedHeight);
+ myText->setLineHeight(10);
+ QCOMPARE(myText->height(), myText->lineCount() * 10.0);
+
+ delete canvas;
+}
+
+void tst_qquicktext::implicitSize_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("width");
+ QTest::addColumn<QString>("wrap");
+ QTest::addColumn<QString>("elide");
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideNone";
+ QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" <<" 50" << "Text.NoWrap" << "Text.ElideNone";
+ QTest::newRow("plain, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideNone";
+ QTest::newRow("plain, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideRight";
+ QTest::newRow("plain, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideRight";
+ QTest::newRow("richtext, 0 width") << "<b>The quick red fox jumped over the lazy brown dog</b>" <<" 0" << "Text.NoWrap" << "Text.ElideNone";
+ QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideNone";
+ QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "50" << "Text.Wrap" << "Text.ElideNone";
+ QTest::newRow("plain_wrap, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideNone";
+ QTest::newRow("plain_wrap, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideRight";
+ QTest::newRow("plain_wrap, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideRight";
+ QTest::newRow("richtext_wrap, 0 width") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "0" << "Text.Wrap" << "Text.ElideNone";
+}
+
+void tst_qquicktext::implicitSize()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, width);
+ QFETCH(QString, wrap);
+ QFETCH(QString, elide);
+ QString componentStr = "import QtQuick 2.0\nText { "
+ "text: \"" + text + "\"; "
+ "width: " + width + "; "
+ "wrapMode: " + wrap + "; "
+ "elide: " + elide + "; "
+ "maximumLineCount: 1 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject->width() < textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+
+ textObject->resetWidth();
+ QVERIFY(textObject->width() == textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+
+ delete textObject;
+}
+
+void tst_qquicktext::contentSize()
+{
+ QString componentStr = "import QtQuick 2.0\nText { width: 75; height: 16; font.pixelSize: 10 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+ textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ QCOMPARE(spy.count(), 1);
+
+ textObject->setWrapMode(QQuickText::WordWrap);
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 2);
+
+ textObject->setElideMode(QQuickText::ElideRight);
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ QCOMPARE(spy.count(), 3);
+ int spyCount = 3;
+ qreal elidedWidth = textObject->contentWidth();
+
+ textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ // this text probably won't have the same elided width, but it's not guaranteed.
+ if (textObject->contentWidth() != elidedWidth)
+ QCOMPARE(spy.count(), ++spyCount);
+ else
+ QCOMPARE(spy.count(), spyCount);
+
+ textObject->setElideMode(QQuickText::ElideNone);
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), ++spyCount);
+}
+
+void tst_qquicktext::lineLaidOut()
+{
+ QQuickView *canvas = createView(testFile("lineLayout.qml"));
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
+ QVERIFY(textPrivate != 0);
+
+ QVERIFY(!textPrivate->extra.isAllocated());
+
+#if defined(Q_OS_MAC)
+ QVERIFY(myText->lineCount() == textPrivate->linesRects.count());
+#endif
+
+ for (int i = 0; i < textPrivate->layout.lineCount(); ++i) {
+ QRectF r = textPrivate->layout.lineAt(i).rect();
+ QVERIFY(r.width() == i * 15);
+ if (i >= 30)
+ QVERIFY(r.x() == r.width() + 30);
+ if (i >= 60) {
+ QVERIFY(r.x() == r.width() * 2 + 60);
+ QVERIFY(r.height() == 20);
+ }
+ }
+
+ delete canvas;
+}
+
+void tst_qquicktext::imgTagsBaseUrl_data()
+{
+ QTest::addColumn<QUrl>("src");
+ QTest::addColumn<QUrl>("baseUrl");
+ QTest::addColumn<QUrl>("contextUrl");
+ QTest::addColumn<qreal>("imgHeight");
+
+ QTest::newRow("absolute local")
+ << testFileUrl("images/heart200.png")
+ << QUrl()
+ << QUrl()
+ << 181.;
+ QTest::newRow("relative local context 1")
+ << QUrl("images/heart200.png")
+ << QUrl()
+ << testFileUrl("/app.qml")
+ << 181.;
+ QTest::newRow("relative local context 2")
+ << QUrl("heart200.png")
+ << QUrl()
+ << testFileUrl("images/app.qml")
+ << 181.;
+ QTest::newRow("relative local base 1")
+ << QUrl("images/heart200.png")
+ << testFileUrl("")
+ << testFileUrl("nonexistant/app.qml")
+ << 181.;
+ QTest::newRow("relative local base 2")
+ << QUrl("heart200.png")
+ << testFileUrl("images/")
+ << testFileUrl("nonexistant/app.qml")
+ << 181.;
+ QTest::newRow("base relative to local context")
+ << QUrl("heart200.png")
+ << testFileUrl("images/")
+ << testFileUrl("/app.qml")
+ << 181.;
+
+ QTest::newRow("absolute remote")
+ << QUrl("http://127.0.0.1:14453/images/heart200.png")
+ << QUrl()
+ << QUrl()
+ << 181.;
+ QTest::newRow("relative remote base 1")
+ << QUrl("images/heart200.png")
+ << QUrl("http://127.0.0.1:14453/")
+ << testFileUrl("nonexistant/app.qml")
+ << 181.;
+ QTest::newRow("relative remote base 2")
+ << QUrl("heart200.png")
+ << QUrl("http://127.0.0.1:14453/images/")
+ << testFileUrl("nonexistant/app.qml")
+ << 181.;
+}
+
+void tst_qquicktext::imgTagsBaseUrl()
+{
+ QFETCH(QUrl, src);
+ QFETCH(QUrl, baseUrl);
+ QFETCH(QUrl, contextUrl);
+ QFETCH(qreal, imgHeight);
+
+ TestHTTPServer server(14453);
+ server.serveDirectory(testFile(""));
+
+ QByteArray baseUrlFragment;
+ if (!baseUrl.isEmpty())
+ baseUrlFragment = "; baseUrl: \"" + baseUrl.toEncoded() + "\"";
+ QByteArray componentStr = "import QtQuick 2.0\nText { text: \"This is a test <img src=\\\"" + src.toEncoded() + "\\\">\"" + baseUrlFragment + " }";
+
+ QQmlComponent component(&engine);
+ component.setData(componentStr, contextUrl);
+ QScopedPointer<QObject> object(component.create());
+ QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
+ QVERIFY(textObject);
+
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(textObject->height(), imgHeight);
+}
+
+void tst_qquicktext::imgTagsAlign_data()
+{
+ QTest::addColumn<QString>("src");
+ QTest::addColumn<int>("imgHeight");
+ QTest::addColumn<QString>("align");
+ QTest::newRow("heart-bottom") << "data/images/heart200.png" << 181 << "bottom";
+ QTest::newRow("heart-middle") << "data/images/heart200.png" << 181 << "middle";
+ QTest::newRow("heart-top") << "data/images/heart200.png" << 181 << "top";
+ QTest::newRow("starfish-bottom") << "data/images/starfish_2.png" << 217 << "bottom";
+ QTest::newRow("starfish-middle") << "data/images/starfish_2.png" << 217 << "middle";
+ QTest::newRow("starfish-top") << "data/images/starfish_2.png" << 217 << "top";
+}
+
+void tst_qquicktext::imgTagsAlign()
+{
+ QFETCH(QString, src);
+ QFETCH(int, imgHeight);
+ QFETCH(QString, align);
+ QString componentStr = "import QtQuick 2.0\nText { text: \"This is a test <img src=\\\"" + src + "\\\" align=\\\"" + align + "\\\"> of image.\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->height() == imgHeight);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+
+ QRectF br = textPrivate->layout.boundingRect();
+ if (align == "bottom")
+ QVERIFY(br.y() == imgHeight - br.height());
+ else if (align == "middle")
+ QVERIFY(br.y() == imgHeight / 2.0 - br.height() / 2.0);
+ else if (align == "top")
+ QVERIFY(br.y() == 0);
+
+ delete textObject;
+}
+
+void tst_qquicktext::imgTagsMultipleImages()
+{
+ QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish<img src=\\\"data/images/starfish_2.png\\\" width=\\\"60\\\" height=\\\"60\\\" > and another one<img src=\\\"data/images/heart200.png\\\" width=\\\"85\\\" height=\\\"85\\\">.\" }";
+
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->height() == 85);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->visibleImgTags.count() == 2);
+
+ delete textObject;
+}
+
+void tst_qquicktext::imgTagsElide()
+{
+ QQuickView *canvas = createView(testFile("imgTagsElide.qml"));
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->visibleImgTags.count() == 0);
+ myText->setMaximumLineCount(20);
+ QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1);
+
+ delete myText;
+ delete canvas;
+}
+
+void tst_qquicktext::imgTagsUpdates()
+{
+ QQuickView *canvas = createView(testFile("imgTagsUpdates.qml"));
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QSignalSpy spy(myText, SIGNAL(contentSizeChanged()));
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
+ QVERIFY(textPrivate != 0);
+
+ myText->setText("This is a heart<img src=\"images/heart200.png\">.");
+ QVERIFY(textPrivate->visibleImgTags.count() == 1);
+ QVERIFY(spy.count() == 1);
+
+ myText->setMaximumLineCount(2);
+ myText->setText("This is another heart<img src=\"images/heart200.png\">.");
+ QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1);
+
+ // if maximumLineCount is set and the img tag doesn't have an explicit size
+ // we relayout twice.
+ QVERIFY(spy.count() == 3);
+
+ delete myText;
+ delete canvas;
+}
+
+void tst_qquicktext::imgTagsError()
+{
+ QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish<img src=\\\"data/images/starfish_2.pn\\\" width=\\\"60\\\" height=\\\"60\\\">.\" }";
+
+ QQmlComponent textComponent(&engine);
+ QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML Text: Cannot open: file:data/images/starfish_2.pn");
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ delete textObject;
+}
+
+void tst_qquicktext::fontSizeMode_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog";
+ QTest::newRow("styled") << "<b>The quick red fox jumped over the lazy brown dog</b>";
+}
+
+void tst_qquicktext::fontSizeMode()
+{
+ QFETCH(QString, text);
+
+ QScopedPointer<QQuickView> canvas(createView(testFile("fontSizeMode.qml")));
+ canvas->show();
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ myText->setText(text);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ qreal originalWidth = myText->contentWidth();
+ qreal originalHeight = myText->contentHeight();
+
+ // The original text unwrapped should exceed the width of the item.
+ QVERIFY(originalWidth > myText->width());
+ QVERIFY(originalHeight < myText->height());
+
+ QFont font = myText->font();
+ font.setPixelSize(64);
+
+ myText->setFont(font);
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Font size reduced to fit within the width of the item.
+ qreal horizontalFitWidth = myText->contentWidth();
+ qreal horizontalFitHeight = myText->contentHeight();
+ QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
+ QVERIFY(horizontalFitHeight <= myText->height() + 2);
+
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Font size increased to fill the height of the item.
+ qreal verticalFitHeight = myText->contentHeight();
+ QVERIFY(myText->contentWidth() > myText->width());
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight > originalHeight);
+
+ // Elide won't affect the height of a single line with VerticalFit but will crop the width.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as HorizontalFit with no wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::FixedSize);
+ myText->setWrapMode(QQuickText::Wrap);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ originalWidth = myText->contentWidth();
+ originalHeight = myText->contentHeight();
+
+ // The original text wrapped should exceed the height of the item.
+ QVERIFY(originalWidth <= myText->width() + 2);
+ QVERIFY(originalHeight > myText->height());
+
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
+ // same size as without text wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // VerticalFit should reduce the size to the wrapped text within the vertical height.
+ verticalFitHeight = myText->contentHeight();
+ qreal verticalFitWidth = myText->contentWidth();
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight < originalHeight);
+
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::FixedSize);
+ myText->setMaximumLineCount(2);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ // The original text wrapped should exceed the height of the item.
+ QVERIFY(originalWidth <= myText->width() + 2);
+ QVERIFY(originalHeight > myText->height());
+
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
+ // same size as without text wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // VerticalFit should reduce the size to the wrapped text within the vertical height.
+ verticalFitHeight = myText->contentHeight();
+ verticalFitWidth = myText->contentWidth();
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight < originalHeight);
+
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+}
+
+void tst_qquicktext::fontSizeModeMultiline_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog";
+ QTest::newRow("styledtext") << "<b>The quick red fox jumped<br/> over the lazy brown dog</b>";
+}
+
+void tst_qquicktext::fontSizeModeMultiline()
+{
+ QFETCH(QString, text);
+
+ QScopedPointer<QQuickView> canvas(createView(testFile("fontSizeMode.qml")));
+ canvas->show();
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ myText->setText(text);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ qreal originalWidth = myText->contentWidth();
+ qreal originalHeight = myText->contentHeight();
+ QCOMPARE(myText->lineCount(), 2);
+
+ // The original text unwrapped should exceed the width and height of the item.
+ QVERIFY(originalWidth > myText->width());
+ QVERIFY(originalHeight > myText->height());
+
+ QFont font = myText->font();
+ font.setPixelSize(64);
+
+ myText->setFont(font);
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Font size reduced to fit within the width of the item.
+ QCOMPARE(myText->lineCount(), 2);
+ qreal horizontalFitWidth = myText->contentWidth();
+ qreal horizontalFitHeight = myText->contentHeight();
+ QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
+ QVERIFY(horizontalFitHeight > myText->height());
+
+ // Right eliding will remove the last line
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QCOMPARE(myText->lineCount(), 1);
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
+
+ // Left or middle eliding wont have any effect.
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Font size reduced to fit within the height of the item.
+ qreal verticalFitWidth = myText->contentWidth();
+ qreal verticalFitHeight = myText->contentHeight();
+ QVERIFY(verticalFitWidth <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+
+ // Elide will have no effect.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with no wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::FixedSize);
+ myText->setWrapMode(QQuickText::Wrap);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ originalWidth = myText->contentWidth();
+ originalHeight = myText->contentHeight();
+
+ // The original text wrapped should exceed the height of the item.
+ QVERIFY(originalWidth <= myText->width() + 2);
+ QVERIFY(originalHeight > myText->height());
+
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
+ // same size as without text wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ // Text will be elided vertically with HorizontalFit
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // VerticalFit should reduce the size to the wrapped text within the vertical height.
+ verticalFitHeight = myText->contentHeight();
+ verticalFitWidth = myText->contentWidth();
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight < originalHeight);
+
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::FixedSize);
+ myText->setMaximumLineCount(2);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ // The original text wrapped should exceed the height of the item.
+ QVERIFY(originalWidth <= myText->width() + 2);
+ QVERIFY(originalHeight > myText->height());
+
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
+ // same size as without text wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // VerticalFit should reduce the size to the wrapped text within the vertical height.
+ verticalFitHeight = myText->contentHeight();
+ verticalFitWidth = myText->contentWidth();
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight < originalHeight);
+
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+}
+
+void tst_qquicktext::multilengthStrings_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::newRow("No Wrap") << testFile("multilengthStrings.qml");
+ QTest::newRow("Wrap") << testFile("multilengthStringsWrapped.qml");
+}
+
+void tst_qquicktext::multilengthStrings()
+{
+ QFETCH(QString, source);
+
+ QScopedPointer<QQuickView> canvas(createView(source));
+ canvas->show();
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ const QString longText = "the quick brown fox jumped over the lazy dog";
+ const QString mediumText = "the brown fox jumped over the dog";
+ const QString shortText = "fox jumped dog";
+
+ myText->setText(longText);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ const qreal longWidth = myText->contentWidth();
+ const qreal longHeight = myText->contentHeight();
+
+ myText->setText(mediumText);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ const qreal mediumWidth = myText->contentWidth();
+ const qreal mediumHeight = myText->contentHeight();
+
+ myText->setText(shortText);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ const qreal shortWidth = myText->contentWidth();
+ const qreal shortHeight = myText->contentHeight();
+
+ myText->setElideMode(QQuickText::ElideRight);
+ myText->setText(longText + QLatin1Char('\x9c') + mediumText + QLatin1Char('\x9c') + shortText);
+
+ myText->setSize(QSizeF(longWidth, longHeight));
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ QCOMPARE(myText->contentWidth(), longWidth);
+ QCOMPARE(myText->contentHeight(), longHeight);
+ QCOMPARE(myText->truncated(), false);
+
+ myText->setSize(QSizeF(mediumWidth, mediumHeight));
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ QCOMPARE(myText->contentWidth(), mediumWidth);
+ QCOMPARE(myText->contentHeight(), mediumHeight);
+ QCOMPARE(myText->truncated(), true);
+
+ myText->setSize(QSizeF(shortWidth, shortHeight));
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ QCOMPARE(myText->contentWidth(), shortWidth);
+ QCOMPARE(myText->contentHeight(), shortHeight);
+ QCOMPARE(myText->truncated(), true);
+}
+
+void tst_qquicktext::fontFormatSizes_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("textWithTag");
+ QTest::addColumn<bool>("fontIsBigger");
+
+ QTest::newRow("fs1") << "Hello world!" << "Hello <font size=\"1\">world</font>!" << false;
+ QTest::newRow("fs2") << "Hello world!" << "Hello <font size=\"2\">world</font>!" << false;
+ QTest::newRow("fs3") << "Hello world!" << "Hello <font size=\"3\">world</font>!" << false;
+ QTest::newRow("fs4") << "Hello world!" << "Hello <font size=\"4\">world</font>!" << true;
+ QTest::newRow("fs5") << "Hello world!" << "Hello <font size=\"5\">world</font>!" << true;
+ QTest::newRow("fs6") << "Hello world!" << "Hello <font size=\"6\">world</font>!" << true;
+ QTest::newRow("fs7") << "Hello world!" << "Hello <font size=\"7\">world</font>!" << true;
+ QTest::newRow("h1") << "This is<br/>a font<br/> size test." << "This is <h1>a font</h1> size test." << true;
+ QTest::newRow("h2") << "This is<br/>a font<br/> size test." << "This is <h2>a font</h2> size test." << true;
+ QTest::newRow("h3") << "This is<br/>a font<br/> size test." << "This is <h3>a font</h3> size test." << true;
+ QTest::newRow("h4") << "This is<br/>a font<br/> size test." << "This is <h4>a font</h4> size test." << true;
+ QTest::newRow("h5") << "This is<br/>a font<br/> size test." << "This is <h5>a font</h5> size test." << false;
+ QTest::newRow("h6") << "This is<br/>a font<br/> size test." << "This is <h6>a font</h6> size test." << false;
+}
+
+void tst_qquicktext::fontFormatSizes()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, textWithTag);
+ QFETCH(bool, fontIsBigger);
+
+ QQuickView *view = new QQuickView;
+ {
+ view->setSource(testFileUrl("pointFontSizes.qml"));
+ view->show();
+
+ QQuickText *qtext = view->rootObject()->findChild<QQuickText*>("text");
+ QQuickText *qtextWithTag = view->rootObject()->findChild<QQuickText*>("textWithTag");
+ QVERIFY(qtext != 0);
+ QVERIFY(qtextWithTag != 0);
+
+ qtext->setText(text);
+ qtextWithTag->setText(textWithTag);
+
+ for (int size = 6; size < 100; size += 4) {
+ view->rootObject()->setProperty("pointSize", size);
+ if (fontIsBigger)
+ QVERIFY(qtext->height() <= qtextWithTag->height());
+ else
+ QVERIFY(qtext->height() >= qtextWithTag->height());
+ }
+ }
+
+ {
+ view->setSource(testFileUrl("pixelFontSizes.qml"));
+ QQuickText *qtext = view->rootObject()->findChild<QQuickText*>("text");
+ QQuickText *qtextWithTag = view->rootObject()->findChild<QQuickText*>("textWithTag");
+ QVERIFY(qtext != 0);
+ QVERIFY(qtextWithTag != 0);
+
+ qtext->setText(text);
+ qtextWithTag->setText(textWithTag);
+
+ for (int size = 6; size < 100; size += 4) {
+ view->rootObject()->setProperty("pixelSize", size);
+ if (fontIsBigger)
+ QVERIFY(qtext->height() <= qtextWithTag->height());
+ else
+ QVERIFY(qtext->height() >= qtextWithTag->height());
+ }
+ }
+ delete view;
+}
+
+QTEST_MAIN(tst_qquicktext)
+
+#include "tst_qquicktext.moc"
diff --git a/tests/auto/qtquick2/qquicktextedit/data/Cursor.qml b/tests/auto/quick/qquicktextedit/data/Cursor.qml
index e5c1853fc5..e5c1853fc5 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/Cursor.qml
+++ b/tests/auto/quick/qquicktextedit/data/Cursor.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml b/tests/auto/quick/qquicktextedit/data/CursorRect.qml
index cae3e63b72..cae3e63b72 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml
+++ b/tests/auto/quick/qquicktextedit/data/CursorRect.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments.qml b/tests/auto/quick/qquicktextedit/data/alignments.qml
index 7d365da8cb..7d365da8cb 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments.qml
+++ b/tests/auto/quick/qquicktextedit/data/alignments.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png b/tests/auto/quick/qquicktextedit/data/alignments_cb.png
index 99de2192de..99de2192de 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png b/tests/auto/quick/qquicktextedit/data/alignments_cc.png
index cb85251180..cb85251180 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png b/tests/auto/quick/qquicktextedit/data/alignments_ct.png
index ddca549c82..ddca549c82 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png b/tests/auto/quick/qquicktextedit/data/alignments_lb.png
index 1b50a81f3d..1b50a81f3d 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png b/tests/auto/quick/qquicktextedit/data/alignments_lc.png
index f041b868f8..f041b868f8 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png b/tests/auto/quick/qquicktextedit/data/alignments_lt.png
index c75e0d158e..c75e0d158e 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png b/tests/auto/quick/qquicktextedit/data/alignments_rb.png
index b06a5da715..b06a5da715 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png b/tests/auto/quick/qquicktextedit/data/alignments_rc.png
index e468857cd0..e468857cd0 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png b/tests/auto/quick/qquicktextedit/data/alignments_rt.png
index 576715ffce..576715ffce 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml b/tests/auto/quick/qquicktextedit/data/cursorTest.qml
index 7bfc869403..7bfc869403 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml
+++ b/tests/auto/quick/qquicktextedit/data/cursorTest.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml b/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml
index 7e916ec818..7e916ec818 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml
+++ b/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml b/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml
index 786f39113c..786f39113c 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml
+++ b/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml b/tests/auto/quick/qquicktextedit/data/cursorVisible.qml
index 49e9386947..49e9386947 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml
+++ b/tests/auto/quick/qquicktextedit/data/cursorVisible.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml
index 150f7bd898..150f7bd898 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml
index 067b6d72da..067b6d72da 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml
index 200ded196d..200ded196d 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml
index a823882692..a823882692 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml
index c6172b68dc..c6172b68dc 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml
index ee39e089ea..ee39e089ea 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml b/tests/auto/quick/qquicktextedit/data/geometrySignals.qml
index 3dbe61c74b..3dbe61c74b 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml
+++ b/tests/auto/quick/qquicktextedit/data/geometrySignals.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml
index 2163838488..2163838488 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml
+++ b/tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml b/tests/auto/quick/qquicktextedit/data/http/ErrItem.qml
index 68c0e0c093..68c0e0c093 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/ErrItem.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml b/tests/auto/quick/qquicktextedit/data/http/NormItem.qml
index 2e4c1ed440..2e4c1ed440 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/NormItem.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml
index be4526e22b..be4526e22b 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml
index 1d7763f913..1d7763f913 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml
index c82ec02e68..c82ec02e68 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml
index 96d582c95d..96d582c95d 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/exists.png b/tests/auto/quick/qquicktextedit/data/http/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/exists.png
+++ b/tests/auto/quick/qquicktextedit/data/http/exists.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/qmldir b/tests/auto/quick/qquicktextedit/data/http/qmldir
index 886e6ffec0..886e6ffec0 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/qmldir
+++ b/tests/auto/quick/qquicktextedit/data/http/qmldir
diff --git a/tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml b/tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml
index 8161843479..8161843479 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml
+++ b/tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml b/tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml
index 8161843479..8161843479 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml
+++ b/tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputContext.qml b/tests/auto/quick/qquicktextedit/data/inputContext.qml
index a37c77e3bf..a37c77e3bf 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/inputContext.qml
+++ b/tests/auto/quick/qquicktextedit/data/inputContext.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml b/tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml
index e3f629ce3e..e3f629ce3e 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml
+++ b/tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml b/tests/auto/quick/qquicktextedit/data/inputmethodhints.qml
index dec3b978e7..dec3b978e7 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml
+++ b/tests/auto/quick/qquicktextedit/data/inputmethodhints.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml b/tests/auto/quick/qquicktextedit/data/linkActivated.qml
index d3bba82b59..d3bba82b59 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml
+++ b/tests/auto/quick/qquicktextedit/data/linkActivated.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_default.qml
index ac32f4ced7..ac32f4ced7 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_default.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_false.qml
index ac32f4ced7..ac32f4ced7 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_false.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml
index 86aea46a85..86aea46a85 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_true.qml
index 7c7cb0b6fc..7c7cb0b6fc 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_true.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml
index c356999220..c356999220 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml
index c1fe42fd57..c1fe42fd57 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml
index 7c7cb0b6fc..7c7cb0b6fc 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml
index 0a372bbf83..0a372bbf83 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/navigation.qml b/tests/auto/quick/qquicktextedit/data/navigation.qml
index 0201c62b3c..0201c62b3c 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/navigation.qml
+++ b/tests/auto/quick/qquicktextedit/data/navigation.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml b/tests/auto/quick/qquicktextedit/data/openInputPanel.qml
index d3aecf21be..d3aecf21be 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml
+++ b/tests/auto/quick/qquicktextedit/data/openInputPanel.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml b/tests/auto/quick/qquicktextedit/data/persistentSelection.qml
index fb2fe0cd6c..fb2fe0cd6c 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml
+++ b/tests/auto/quick/qquicktextedit/data/persistentSelection.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/positionAt.qml b/tests/auto/quick/qquicktextedit/data/positionAt.qml
index 19093281fe..19093281fe 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/positionAt.qml
+++ b/tests/auto/quick/qquicktextedit/data/positionAt.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml b/tests/auto/quick/qquicktextedit/data/qtbug-22058.qml
index 8ad1514fbf..8ad1514fbf 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml
+++ b/tests/auto/quick/qquicktextedit/data/qtbug-22058.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/readOnly.qml b/tests/auto/quick/qquicktextedit/data/readOnly.qml
index 085adba5fb..085adba5fb 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/readOnly.qml
+++ b/tests/auto/quick/qquicktextedit/data/readOnly.qml
diff --git a/tests/auto/quick/qquicktextedit/qquicktextedit.pro b/tests/auto/quick/qquicktextedit/qquicktextedit.pro
new file mode 100644
index 0000000000..39a5178c7d
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/qquicktextedit.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qquicktextedit
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktextedit.cpp \
+ ../../shared/testhttpserver.cpp
+
+HEADERS += ../../shared/testhttpserver.h
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private network widgets-private testlib
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
new file mode 100644
index 0000000000..85a9033dd7
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -0,0 +1,3881 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include "../../shared/testhttpserver.h"
+#include <math.h>
+#include <QFile>
+#include <QTextDocument>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtGui/qguiapplication.h>
+#include <private/qquicktextedit_p.h>
+#include <private/qquicktextedit_p_p.h>
+#include <private/qquicktext_p_p.h>
+#include <QFontMetrics>
+#include <QtQuick/QQuickView>
+#include <QDir>
+#include <QStyle>
+#include <QInputMethod>
+#include <QClipboard>
+#include <QMimeData>
+#include <private/qquicktextcontrol_p.h>
+#include "../../shared/util.h"
+#include "../../shared/platforminputcontext.h"
+#include <private/qinputmethod_p.h>
+
+#ifdef Q_OS_MAC
+#include <Carbon/Carbon.h>
+#endif
+
+
+Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode)
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
+
+QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
+{
+ // XXX This will be replaced by some clever persistent platform image store.
+ QString persistent_dir = QQmlDataTest::instance()->dataDirectory();
+ 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;
+}
+
+typedef QPair<int, QChar> Key;
+
+class tst_qquicktextedit : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_qquicktextedit();
+
+private slots:
+ void cleanup();
+ void text();
+ void width();
+ void wrap();
+ void textFormat();
+ void alignments();
+ void alignments_data();
+
+ // ### these tests may be trivial
+ void hAlign();
+ void hAlign_RightToLeft();
+ void vAlign();
+ void font();
+ void color();
+ void textMargin();
+ void persistentSelection();
+ void focusOnPress();
+ void selection();
+ void isRightToLeft_data();
+ void isRightToLeft();
+ void keySelection();
+ void moveCursorSelection_data();
+ void moveCursorSelection();
+ void moveCursorSelectionSequence_data();
+ void moveCursorSelectionSequence();
+ void mouseSelection_data();
+ void mouseSelection();
+ void mouseSelectionMode_data();
+ void mouseSelectionMode();
+ void dragMouseSelection();
+ void inputMethodHints();
+
+ void positionAt();
+
+ void linkActivated();
+
+ void cursorDelegate_data();
+ void cursorDelegate();
+ void cursorVisible();
+ void delegateLoading_data();
+ void delegateLoading();
+ void navigation();
+ void readOnly();
+ void copyAndPaste();
+ void canPaste();
+ void canPasteEmpty();
+ void textInput();
+ void inputMethodUpdate();
+ void openInputPanel();
+ void geometrySignals();
+ void pastingRichText_QTBUG_14003();
+ void implicitSize_data();
+ void implicitSize();
+ void contentSize();
+
+ void preeditCursorRectangle();
+ void inputMethodComposing();
+ void cursorRectangleSize();
+
+ void getText_data();
+ void getText();
+ void getFormattedText_data();
+ void getFormattedText();
+ void insert_data();
+ void insert();
+ void remove_data();
+ void remove();
+
+ void keySequence_data();
+ void keySequence();
+
+ void undo_data();
+ void undo();
+ void redo_data();
+ void redo();
+ void undo_keypressevents_data();
+ void undo_keypressevents();
+
+ void baseUrl();
+ void embeddedImages();
+ void embeddedImages_data();
+
+ void emptytags_QTBUG_22058();
+
+private:
+ void simulateKeys(QWindow *window, const QList<Key> &keys);
+ void simulateKeys(QWindow *window, const QKeySequence &sequence);
+
+ void simulateKey(QQuickView *, int key, Qt::KeyboardModifiers modifiers = 0);
+
+ QStringList standard;
+ QStringList richText;
+
+ QStringList hAlignmentStrings;
+ QStringList vAlignmentStrings;
+
+ QList<Qt::Alignment> vAlignments;
+ QList<Qt::Alignment> hAlignments;
+
+ QStringList colorStrings;
+
+ QQmlEngine engine;
+};
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(IntList)
+
+typedef QList<Key> KeyList;
+Q_DECLARE_METATYPE(KeyList)
+
+Q_DECLARE_METATYPE(QQuickTextEdit::TextFormat)
+
+void tst_qquicktextedit::simulateKeys(QWindow *window, const QList<Key> &keys)
+{
+ for (int i = 0; i < keys.count(); ++i) {
+ const int key = keys.at(i).first;
+ const int modifiers = key & Qt::KeyboardModifierMask;
+ const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
+
+ QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
+ QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
+
+ QGuiApplication::sendEvent(window, &press);
+ QGuiApplication::sendEvent(window, &release);
+ }
+}
+
+void tst_qquicktextedit::simulateKeys(QWindow *window, const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i) {
+ const int key = sequence[i];
+ const int modifiers = key & Qt::KeyboardModifierMask;
+
+ QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers));
+ }
+}
+
+QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i)
+ keys << Key(sequence[i], QChar());
+ return keys;
+}
+
+template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
+{
+ for (int i = 0; i < N - 1; ++i) {
+ int key = QTest::asciiToKey(characters[i]);
+ QChar character = QLatin1Char(characters[i]);
+ keys << Key(key, character);
+ }
+ return keys;
+}
+
+QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
+{
+ keys << Key(key, QChar());
+ return keys;
+}
+
+tst_qquicktextedit::tst_qquicktextedit()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "the quick brown fox\n jumped over the lazy dog"
+ << "Hello, world!"
+ << "!dlrow ,olleH";
+
+ richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
+ << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
+
+ hAlignmentStrings << "AlignLeft"
+ << "AlignRight"
+ << "AlignHCenter";
+
+ vAlignmentStrings << "AlignTop"
+ << "AlignBottom"
+ << "AlignVCenter";
+
+ hAlignments << Qt::AlignLeft
+ << Qt::AlignRight
+ << Qt::AlignHCenter;
+
+ vAlignments << Qt::AlignTop
+ << Qt::AlignBottom
+ << Qt::AlignVCenter;
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+ //
+ // need a different test to do alpha channel test
+ // << "#AA0011DD"
+ // << "#00F16B11";
+ //
+}
+
+void tst_qquicktextedit::cleanup()
+{
+ // ensure not even skipped tests with custom input context leave it dangling
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
+void tst_qquicktextedit::text()
+{
+ {
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), QString(""));
+ QCOMPARE(textEditObject->length(), 0);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), standard.at(i));
+ QCOMPARE(textEditObject->length(), standard.at(i).length());
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+
+ QString expected = richText.at(i);
+ expected.replace(QRegExp("\\\\(.)"),"\\1");
+ QCOMPARE(textEditObject->text(), expected);
+ QCOMPARE(textEditObject->length(), expected.length());
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+
+ QString actual = textEditObject->text();
+ QString expected = standard.at(i);
+ actual.remove(QRegExp(".*<body[^>]*>"));
+ actual.remove(QRegExp("(<[^>]*>)+"));
+ expected.remove("\n");
+ QCOMPARE(actual.simplified(), expected);
+ QCOMPARE(textEditObject->length(), expected.length());
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QString actual = textEditObject->text();
+ QString expected = richText.at(i);
+ actual.replace(QRegExp(".*<body[^>]*>"),"");
+ actual.replace(QRegExp("(<[^>]*>)+"),"<>");
+ expected.replace(QRegExp("(<[^>]*>)+"),"<>");
+ QCOMPARE(actual.simplified(),expected.simplified());
+
+ expected.replace("<>", " ");
+ QCOMPARE(textEditObject->length(), expected.simplified().length());
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), standard.at(i));
+ QCOMPARE(textEditObject->length(), standard.at(i).length());
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QString actual = textEditObject->text();
+ QString expected = richText.at(i);
+ actual.replace(QRegExp(".*<body[^>]*>"),"");
+ actual.replace(QRegExp("(<[^>]*>)+"),"<>");
+ expected.replace(QRegExp("(<[^>]*>)+"),"<>");
+ QCOMPARE(actual.simplified(),expected.simplified());
+
+ expected.replace("<>", " ");
+ QCOMPARE(textEditObject->length(), expected.simplified().length());
+ }
+}
+
+void tst_qquicktextedit::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 0.0);
+ }
+
+ bool requiresUnhintedMetrics = !qmlDisableDistanceField();
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QString s = standard.at(i);
+ s.replace(QLatin1Char('\n'), QChar::LineSeparator);
+
+ QTextLayout layout(s);
+ layout.setFont(textEditObject->font());
+ layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
+ if (requiresUnhintedMetrics) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ }
+
+ layout.endLayout();
+
+ qreal metricWidth = layout.boundingRect().width();
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), metricWidth);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QTextDocument document;
+ document.setHtml(richText.at(i));
+ document.setDocumentMargin(0);
+ if (requiresUnhintedMetrics)
+ document.setUseDesignMetrics(true);
+
+ qreal documentWidth = document.idealWidth();
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), documentWidth);
+ }
+}
+
+void tst_qquicktextedit::wrap()
+{
+ // for specified width and wrap set true
+ {
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+}
+
+void tst_qquicktextedit::textFormat()
+{
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickTextEdit::RichText);
+ }
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickTextEdit::PlainText);
+ }
+}
+
+void tst_qquicktextedit::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ 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) << "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) << "alignments_lc";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc";
+}
+
+
+void tst_qquicktextedit::alignments()
+{
+ QSKIP("Image comparison of text is almost guaranteed to fail during development");
+
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+ QQuickView canvas(testFileUrl("alignments.qml"));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QObject *ob = canvas.rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual = canvas.grabFrameBuffer();
+
+ expectfile = createExpectedFileIfNotFound(expectfile, actual);
+
+ QImage expect(expectfile);
+
+ QCOMPARE(actual,expect);
+}
+
+
+//the alignment tests may be trivial o.oa
+void tst_qquicktextedit::hAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qquicktextedit::hAlign_RightToLeft()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
+ QQuickTextEdit *textEdit = canvas.rootObject()->findChild<QQuickTextEdit*>("text");
+ QVERIFY(textEdit != 0);
+ canvas.show();
+
+ const QString rtlText = textEdit->text();
+
+ // implicit alignment should follow the reading direction of text
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // explicitly left aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ // explicitly right aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ QString textString = textEdit->text();
+ textEdit->setText(QString("<i>") + textString + QString("</i>"));
+ textEdit->resetHAlign();
+
+ // implicitly aligned rich text should follow the reading direction of RTL text
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // explicitly left aligned rich text
+ textEdit->setHAlign(QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ // explicitly right aligned rich text
+ textEdit->setHAlign(QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ textEdit->setText(textString);
+
+ // explicitly center aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignHCenter);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignHCenter);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // reseted alignment should go back to following the text reading direction
+ textEdit->resetHAlign();
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // mirror the text item
+ QQuickItemPrivate::get(textEdit)->setLayoutMirror(true);
+
+ // mirrored implicit alignment should continue to follow the reading direction of the text
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // mirrored explicitly right aligned behaves as left aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ // mirrored explicitly left aligned behaves as right aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // disable mirroring
+ QQuickItemPrivate::get(textEdit)->setLayoutMirror(false);
+ textEdit->resetHAlign();
+
+ // English text should be implicitly left aligned
+ textEdit->setText("Hello world!");
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ textEdit->setText(QString());
+ { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+
+ // Clear pre-edit text. TextEdit should maybe do this itself on setText, but that may be
+ // redundant as an actual input method may take care of it.
+ { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+
+ // empty text with implicit alignment follows the system locale-based
+ // keyboard input direction from qApp->inputMethod()->inputDirection
+ textEdit->setText("");
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ QSignalSpy cursorRectangleSpy(textEdit, SIGNAL(cursorRectangleChanged()));
+
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ QCOMPARE(cursorRectangleSpy.count(), 1);
+ QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // set input direction while having content
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ textEdit->setText("a");
+ textEdit->setCursorPosition(1);
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ QTest::keyClick(&canvas, Qt::Key_Backspace);
+ QVERIFY(textEdit->text().isEmpty());
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2);
+
+ // input direction changed while not having focus
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ textEdit->setFocus(false);
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ textEdit->setFocus(true);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2);
+
+ textEdit->setHAlign(QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+}
+
+void tst_qquicktextedit::vAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(
+ "import QtQuick 2.0\n"
+ "TextEdit { width: 100; height: 100; text: \"Hello World\" }", QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+
+ QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignTop);
+ QVERIFY(textEditObject->cursorRectangle().bottom() < 50);
+ QVERIFY(textEditObject->positionToRectangle(0).bottom() < 50);
+
+ // bottom aligned
+ textEditObject->setVAlign(QQuickTextEdit::AlignBottom);
+ QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignBottom);
+ QVERIFY(textEditObject->cursorRectangle().top() > 50);
+ QVERIFY(textEditObject->positionToRectangle(0).top() > 50);
+
+ // explicitly center aligned
+ textEditObject->setVAlign(QQuickTextEdit::AlignVCenter);
+ QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignVCenter);
+ QVERIFY(textEditObject->cursorRectangle().top() < 50);
+ QVERIFY(textEditObject->cursorRectangle().bottom() > 50);
+ QVERIFY(textEditObject->positionToRectangle(0).top() < 50);
+ QVERIFY(textEditObject->positionToRectangle(0).bottom() > 50);
+}
+
+void tst_qquicktextedit::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().pointSize(), 40);
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.bold: true; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().bold(), true);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.italic: true; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().italic(), true);
+ QCOMPARE(textEditObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().family(), QString(""));
+ }
+}
+
+void tst_qquicktextedit::color()
+{
+ //test initial color
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QQuickTextEditPrivate *textEditPrivate = static_cast<QQuickTextEditPrivate*>(QQuickItemPrivate::get(textEditObject));
+
+ QVERIFY(textEditObject);
+ QVERIFY(textEditPrivate);
+ QVERIFY(textEditPrivate->control);
+ QCOMPARE(textEditPrivate->color, QColor("black"));
+ }
+ //test normal
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
+ }
+
+ //test selection
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i)));
+ }
+
+ //test selected text
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->color(), testColor);
+ }
+}
+
+void tst_qquicktextedit::textMargin()
+{
+ for (qreal i=0; i<=10; i+=0.3) {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->textMargin(), i);
+ }
+}
+
+void tst_qquicktextedit::persistentSelection()
+{
+ QQuickView canvas(testFileUrl("persistentSelection.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+ canvas.requestActivateWindow();
+
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(edit);
+ QVERIFY(edit->hasActiveFocus());
+
+ QSignalSpy spy(edit, SIGNAL(persistentSelectionChanged(bool)));
+
+ QCOMPARE(edit->persistentSelection(), false);
+
+ edit->setPersistentSelection(false);
+ QCOMPARE(edit->persistentSelection(), false);
+ QCOMPARE(spy.count(), 0);
+
+ edit->select(1, 4);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(false);
+ QCOMPARE(edit->property("selected").toString(), QString());
+
+ edit->setFocus(true);
+ QCOMPARE(edit->property("selected").toString(), QString());
+
+ edit->setPersistentSelection(true);
+ QCOMPARE(edit->persistentSelection(), true);
+ QCOMPARE(spy.count(), 1);
+
+ edit->select(1, 4);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(false);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(true);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+}
+
+void tst_qquicktextedit::focusOnPress()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->focusOnPress(), true);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->focusOnPress(), false);
+ }
+}
+
+void tst_qquicktextedit::selection()
+{
+ QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+
+
+ //Test selection follows cursor
+ for (int i=0; i<= testStr.size(); i++) {
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorPosition(), i);
+ QCOMPARE(textEditObject->selectionStart(), i);
+ QCOMPARE(textEditObject->selectionEnd(), i);
+ QVERIFY(textEditObject->selectedText().isNull());
+ }
+
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ // Verify invalid positions are ignored.
+ textEditObject->setCursorPosition(-1);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ textEditObject->setCursorPosition(textEditObject->text().count()+1);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ //Test selection
+ for (int i=0; i<= testStr.size(); i++) {
+ textEditObject->select(0,i);
+ QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
+ }
+ for (int i=0; i<= testStr.size(); i++) {
+ textEditObject->select(i,testStr.size());
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
+ }
+
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ //Test Error Ignoring behaviour
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(-10,0);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(100,101);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(0,-10);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(0,100);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(0,10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->select(-10,0);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->select(100,101);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->select(0,-10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->select(0,100);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+
+ textEditObject->deselect();
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(0,10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->deselect();
+ QVERIFY(textEditObject->selectedText().isNull());
+}
+
+void tst_qquicktextedit::isRightToLeft_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<bool>("emptyString");
+ QTest::addColumn<bool>("firstCharacter");
+ QTest::addColumn<bool>("lastCharacter");
+ QTest::addColumn<bool>("middleCharacter");
+ QTest::addColumn<bool>("startString");
+ QTest::addColumn<bool>("midString");
+ QTest::addColumn<bool>("endString");
+
+ const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
+ QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
+ QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
+ QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
+ QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
+ QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
+ QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
+}
+
+void tst_qquicktextedit::isRightToLeft()
+{
+ QFETCH(QString, text);
+ QFETCH(bool, emptyString);
+ QFETCH(bool, firstCharacter);
+ QFETCH(bool, lastCharacter);
+ QFETCH(bool, middleCharacter);
+ QFETCH(bool, startString);
+ QFETCH(bool, midString);
+ QFETCH(bool, endString);
+
+ QQuickTextEdit textEdit;
+ textEdit.setText(text);
+
+ // first test that the right string is delivered to the QString::isRightToLeft()
+ QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
+ if (text.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
+ QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
+
+ // then test that the feature actually works
+ QCOMPARE(textEdit.isRightToLeft(0,0), emptyString);
+ QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter);
+ QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
+ QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
+ QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), startString);
+ QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), midString);
+ if (text.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
+ QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), endString);
+}
+
+void tst_qquicktextedit::keySelection()
+{
+ QQuickView canvas(testFileUrl("navigation.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+
+ QSignalSpy spy(input, SIGNAL(selectionChanged()));
+
+ simulateKey(&canvas, Qt::Key_Right, Qt::ShiftModifier);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectedText(), QString("a"));
+ QCOMPARE(spy.count(), 1);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectedText(), QString());
+ QCOMPARE(spy.count(), 2);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == false);
+ QCOMPARE(input->selectedText(), QString());
+ QCOMPARE(spy.count(), 2);
+
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(spy.count(), 2);
+ simulateKey(&canvas, Qt::Key_Left, Qt::ShiftModifier);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectedText(), QString("a"));
+ QCOMPARE(spy.count(), 3);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectedText(), QString());
+ QCOMPARE(spy.count(), 4);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == false);
+ QCOMPARE(input->selectedText(), QString());
+ QCOMPARE(spy.count(), 4);
+}
+
+void tst_qquicktextedit::moveCursorSelection_data()
+{
+ QTest::addColumn<QString>("testStr");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<int>("movePosition");
+ QTest::addColumn<QQuickTextEdit::SelectionMode>("mode");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<bool>("reversible");
+
+ QTest::newRow("(t)he|characters")
+ << standard[0] << 0 << 1 << QQuickTextEdit::SelectCharacters << 0 << 1 << true;
+ QTest::newRow("do(g)|characters")
+ << standard[0] << 43 << 44 << QQuickTextEdit::SelectCharacters << 43 << 44 << true;
+ QTest::newRow("jum(p)ed|characters")
+ << standard[0] << 23 << 24 << QQuickTextEdit::SelectCharacters << 23 << 24 << true;
+ QTest::newRow("jumped( )over|characters")
+ << standard[0] << 26 << 27 << QQuickTextEdit::SelectCharacters << 26 << 27 << true;
+ QTest::newRow("(the )|characters")
+ << standard[0] << 0 << 4 << QQuickTextEdit::SelectCharacters << 0 << 4 << true;
+ QTest::newRow("( dog)|characters")
+ << standard[0] << 40 << 44 << QQuickTextEdit::SelectCharacters << 40 << 44 << true;
+ QTest::newRow("( jumped )|characters")
+ << standard[0] << 19 << 27 << QQuickTextEdit::SelectCharacters << 19 << 27 << true;
+ QTest::newRow("th(e qu)ick|characters")
+ << standard[0] << 2 << 6 << QQuickTextEdit::SelectCharacters << 2 << 6 << true;
+ QTest::newRow("la(zy d)og|characters")
+ << standard[0] << 38 << 42 << QQuickTextEdit::SelectCharacters << 38 << 42 << true;
+ QTest::newRow("jum(ped ov)er|characters")
+ << standard[0] << 23 << 29 << QQuickTextEdit::SelectCharacters << 23 << 29 << true;
+ QTest::newRow("()the|characters")
+ << standard[0] << 0 << 0 << QQuickTextEdit::SelectCharacters << 0 << 0 << true;
+ QTest::newRow("dog()|characters")
+ << standard[0] << 44 << 44 << QQuickTextEdit::SelectCharacters << 44 << 44 << true;
+ QTest::newRow("jum()ped|characters")
+ << standard[0] << 23 << 23 << QQuickTextEdit::SelectCharacters << 23 << 23 << true;
+
+ QTest::newRow("<(t)he>|words")
+ << standard[0] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 3 << true;
+ QTest::newRow("<do(g)>|words")
+ << standard[0] << 43 << 44 << QQuickTextEdit::SelectWords << 41 << 44 << true;
+ QTest::newRow("<jum(p)ed>|words")
+ << standard[0] << 23 << 24 << QQuickTextEdit::SelectWords << 20 << 26 << true;
+ QTest::newRow("<jumped( )>over|words")
+ << standard[0] << 26 << 27 << QQuickTextEdit::SelectWords << 20 << 27 << false;
+ QTest::newRow("jumped<( )over>|words,reversed")
+ << standard[0] << 27 << 26 << QQuickTextEdit::SelectWords << 26 << 31 << false;
+ QTest::newRow("<(the )>quick|words")
+ << standard[0] << 0 << 4 << QQuickTextEdit::SelectWords << 0 << 4 << false;
+ QTest::newRow("<(the )quick>|words,reversed")
+ << standard[0] << 4 << 0 << QQuickTextEdit::SelectWords << 0 << 9 << false;
+ QTest::newRow("<lazy( dog)>|words")
+ << standard[0] << 40 << 44 << QQuickTextEdit::SelectWords << 36 << 44 << false;
+ QTest::newRow("lazy<( dog)>|words,reversed")
+ << standard[0] << 44 << 40 << QQuickTextEdit::SelectWords << 40 << 44 << false;
+ QTest::newRow("<fox( jumped )>over|words")
+ << standard[0] << 19 << 27 << QQuickTextEdit::SelectWords << 16 << 27 << false;
+ QTest::newRow("fox<( jumped )over>|words,reversed")
+ << standard[0] << 27 << 19 << QQuickTextEdit::SelectWords << 19 << 31 << false;
+ QTest::newRow("<th(e qu)ick>|words")
+ << standard[0] << 2 << 6 << QQuickTextEdit::SelectWords << 0 << 9 << true;
+ QTest::newRow("<la(zy d)og|words>")
+ << standard[0] << 38 << 42 << QQuickTextEdit::SelectWords << 36 << 44 << true;
+ QTest::newRow("<jum(ped ov)er>|words")
+ << standard[0] << 23 << 29 << QQuickTextEdit::SelectWords << 20 << 31 << true;
+ QTest::newRow("<()>the|words")
+ << standard[0] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true;
+ QTest::newRow("dog<()>|words")
+ << standard[0] << 44 << 44 << QQuickTextEdit::SelectWords << 44 << 44 << true;
+ QTest::newRow("jum<()>ped|words")
+ << standard[0] << 23 << 23 << QQuickTextEdit::SelectWords << 23 << 23 << true;
+
+ QTest::newRow("Hello<(,)> |words")
+ << standard[2] << 5 << 6 << QQuickTextEdit::SelectWords << 5 << 6 << true;
+ QTest::newRow("Hello<(, )>world|words")
+ << standard[2] << 5 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false;
+ QTest::newRow("Hello<(, )world>|words,reversed")
+ << standard[2] << 7 << 5 << QQuickTextEdit::SelectWords << 5 << 12 << false;
+ QTest::newRow("<Hel(lo, )>world|words")
+ << standard[2] << 3 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false;
+ QTest::newRow("<Hel(lo, )world>|words,reversed")
+ << standard[2] << 7 << 3 << QQuickTextEdit::SelectWords << 0 << 12 << false;
+ QTest::newRow("<Hel(lo)>,|words")
+ << standard[2] << 3 << 5 << QQuickTextEdit::SelectWords << 0 << 5 << true;
+ QTest::newRow("Hello<()>,|words")
+ << standard[2] << 5 << 5 << QQuickTextEdit::SelectWords << 5 << 5 << true;
+ QTest::newRow("Hello,<()>|words")
+ << standard[2] << 6 << 6 << QQuickTextEdit::SelectWords << 6 << 6 << true;
+ QTest::newRow("Hello<,( )>world|words")
+ << standard[2] << 6 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false;
+ QTest::newRow("Hello,<( )world>|words,reversed")
+ << standard[2] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false;
+ QTest::newRow("Hello<,( world)>|words")
+ << standard[2] << 6 << 12 << QQuickTextEdit::SelectWords << 5 << 12 << false;
+ QTest::newRow("Hello,<( world)>|words,reversed")
+ << standard[2] << 12 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false;
+ QTest::newRow("Hello<,( world!)>|words")
+ << standard[2] << 6 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << false;
+ QTest::newRow("Hello,<( world!)>|words,reversed")
+ << standard[2] << 13 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false;
+ QTest::newRow("Hello<(, world!)>|words")
+ << standard[2] << 5 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << true;
+ QTest::newRow("world<(!)>|words")
+ << standard[2] << 12 << 13 << QQuickTextEdit::SelectWords << 12 << 13 << true;
+ QTest::newRow("world!<()>)|words")
+ << standard[2] << 13 << 13 << QQuickTextEdit::SelectWords << 13 << 13 << true;
+ QTest::newRow("world<()>!)|words")
+ << standard[2] << 12 << 12 << QQuickTextEdit::SelectWords << 12 << 12 << true;
+
+ QTest::newRow("<(,)>olleH |words")
+ << standard[3] << 7 << 8 << QQuickTextEdit::SelectWords << 7 << 8 << true;
+ QTest::newRow("<dlrow( ,)>olleH|words")
+ << standard[3] << 6 << 8 << QQuickTextEdit::SelectWords << 1 << 8 << false;
+ QTest::newRow("dlrow<( ,)>olleH|words,reversed")
+ << standard[3] << 8 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false;
+ QTest::newRow("<dlrow( ,ol)leH>|words")
+ << standard[3] << 6 << 10 << QQuickTextEdit::SelectWords << 1 << 13 << false;
+ QTest::newRow("dlrow<( ,ol)leH>|words,reversed")
+ << standard[3] << 10 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false;
+ QTest::newRow(",<(ol)leH>,|words")
+ << standard[3] << 8 << 10 << QQuickTextEdit::SelectWords << 8 << 13 << true;
+ QTest::newRow(",<()>olleH|words")
+ << standard[3] << 8 << 8 << QQuickTextEdit::SelectWords << 8 << 8 << true;
+ QTest::newRow("<()>,olleH|words")
+ << standard[3] << 7 << 7 << QQuickTextEdit::SelectWords << 7 << 7 << true;
+ QTest::newRow("<dlrow( )>,olleH|words")
+ << standard[3] << 6 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false;
+ QTest::newRow("dlrow<( ),>olleH|words,reversed")
+ << standard[3] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false;
+ QTest::newRow("<(dlrow )>,olleH|words")
+ << standard[3] << 1 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false;
+ QTest::newRow("<(dlrow ),>olleH|words,reversed")
+ << standard[3] << 7 << 1 << QQuickTextEdit::SelectWords << 1 << 8 << false;
+ QTest::newRow("<(!dlrow )>,olleH|words")
+ << standard[3] << 0 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false;
+ QTest::newRow("<(!dlrow ),>olleH|words,reversed")
+ << standard[3] << 7 << 0 << QQuickTextEdit::SelectWords << 0 << 8 << false;
+ QTest::newRow("(!dlrow ,)olleH|words")
+ << standard[3] << 0 << 8 << QQuickTextEdit::SelectWords << 0 << 8 << true;
+ QTest::newRow("<(!)>dlrow|words")
+ << standard[3] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 1 << true;
+ QTest::newRow("<()>!dlrow|words")
+ << standard[3] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true;
+ QTest::newRow("!<()>dlrow|words")
+ << standard[3] << 1 << 1 << QQuickTextEdit::SelectWords << 1 << 1 << true;
+}
+
+void tst_qquicktextedit::moveCursorSelection()
+{
+ QFETCH(QString, testStr);
+ QFETCH(int, cursorPosition);
+ QFETCH(int, movePosition);
+ QFETCH(QQuickTextEdit::SelectionMode, mode);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(bool, reversible);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit*>(textinputComponent.create());
+ QVERIFY(texteditObject != 0);
+
+ texteditObject->setCursorPosition(cursorPosition);
+ texteditObject->moveCursorSelection(movePosition, mode);
+
+ QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
+ QCOMPARE(texteditObject->selectionStart(), selectionStart);
+ QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
+
+ if (reversible) {
+ texteditObject->setCursorPosition(movePosition);
+ texteditObject->moveCursorSelection(cursorPosition, mode);
+
+ QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
+ QCOMPARE(texteditObject->selectionStart(), selectionStart);
+ QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
+ }
+}
+
+void tst_qquicktextedit::moveCursorSelectionSequence_data()
+{
+ QTest::addColumn<QString>("testStr");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<int>("movePosition1");
+ QTest::addColumn<int>("movePosition2");
+ QTest::addColumn<int>("selection1Start");
+ QTest::addColumn<int>("selection1End");
+ QTest::addColumn<int>("selection2Start");
+ QTest::addColumn<int>("selection2End");
+
+ QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 17
+ << 4 << 15
+ << 4 << 19;
+ QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 17
+ << 9 << 15
+ << 10 << 19;
+ QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 16
+ << 4 << 15
+ << 4 << 16;
+ QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 16
+ << 9 << 15
+ << 10 << 16;
+ QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 15
+ << 4 << 15
+ << 4 << 15;
+ QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 15
+ << 9 << 15
+ << 10 << 15;
+ QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 10
+ << 4 << 15
+ << 4 << 10;
+ QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl")
+ << standard[0]
+ << 13 << 9 << 10
+ << 9 << 15
+ << 10 << 15;
+ QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 9
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
+ << standard[0]
+ << 13 << 9 << 9
+ << 9 << 15
+ << 9 << 15;
+ QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 7
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 7
+ << 9 << 15
+ << 4 << 15;
+ QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 4
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 4
+ << 9 << 15
+ << 4 << 15;
+ QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 3
+ << 4 << 15
+ << 3 << 9;
+ QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 3
+ << 9 << 15
+ << 3 << 15;
+ QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 1
+ << 4 << 15
+ << 0 << 9;
+ QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 1
+ << 9 << 15
+ << 0 << 15;
+
+ QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
+ << standard[2]
+ << 2 << 4 << 8
+ << 0 << 5
+ << 0 << 12;
+ QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
+ << standard[2]
+ << 4 << 2 << 8
+ << 0 << 5
+ << 0 << 12;
+
+ QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
+ << standard[3]
+ << 9 << 11 << 5
+ << 8 << 13
+ << 1 << 13;
+ QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
+ << standard[3]
+ << 11 << 9 << 5
+ << 8 << 13
+ << 1 << 13;
+}
+
+void tst_qquicktextedit::moveCursorSelectionSequence()
+{
+ QFETCH(QString, testStr);
+ QFETCH(int, cursorPosition);
+ QFETCH(int, movePosition1);
+ QFETCH(int, movePosition2);
+ QFETCH(int, selection1Start);
+ QFETCH(int, selection1End);
+ QFETCH(int, selection2Start);
+ QFETCH(int, selection2End);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(texteditObject != 0);
+
+ texteditObject->setCursorPosition(cursorPosition);
+
+ texteditObject->moveCursorSelection(movePosition1, QQuickTextEdit::SelectWords);
+ QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
+ QCOMPARE(texteditObject->selectionStart(), selection1Start);
+ QCOMPARE(texteditObject->selectionEnd(), selection1End);
+
+ texteditObject->moveCursorSelection(movePosition2, QQuickTextEdit::SelectWords);
+ QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
+ QCOMPARE(texteditObject->selectionStart(), selection2Start);
+ QCOMPARE(texteditObject->selectionEnd(), selection2End);
+}
+
+
+void tst_qquicktextedit::mouseSelection_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<QString>("selectedText");
+
+ // import installed
+ QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678";
+ QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString();
+ QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString();
+ QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString();
+ QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789";
+ QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+}
+
+void tst_qquicktextedit::mouseSelection()
+{
+ QFETCH(QString, qmlfile);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(QString, selectedText);
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ QPoint p1 = textEditObject->positionToRectangle(from).center().toPoint();
+ QPoint p2 = textEditObject->positionToRectangle(to).center().toPoint();
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, p1);
+ QTest::mouseMove(&canvas, p2);
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, p2);
+ QTest::qWait(50);
+ QTRY_COMPARE(textEditObject->selectedText(), selectedText);
+
+ // Clicking and shift to clicking between the same points should select the same text.
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(&canvas, Qt::LeftButton, Qt::NoModifier, p1);
+ QTest::mouseClick(&canvas, Qt::LeftButton, Qt::ShiftModifier, p2);
+ QTest::qWait(50);
+ QTRY_COMPARE(textEditObject->selectedText(), selectedText);
+}
+
+void tst_qquicktextedit::dragMouseSelection()
+{
+ QString qmlfile = testFile("mouseselection_true.qml");
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textEditObject->height()/2;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(300);
+ QString str1;
+ QTRY_VERIFY((str1 = textEditObject->selectedText()).length() > 3);
+
+ // press and drag the current selection.
+ x1 = 40;
+ x2 = 100;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(300);
+ QString str2;
+ QTRY_VERIFY((str2 = textEditObject->selectedText()).length() > 3);
+
+ QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and not the first moved.
+}
+
+void tst_qquicktextedit::mouseSelectionMode_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<bool>("selectWords");
+
+ // import installed
+ QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
+ QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
+ QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
+}
+
+void tst_qquicktextedit::mouseSelectionMode()
+{
+ QFETCH(QString, qmlfile);
+ QFETCH(bool, selectWords);
+
+ QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textEditObject->height()/2;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ //QTest::mouseMove(canvas, QPoint(x2,y)); // doesn't work
+// QMouseEvent mv(QEvent::MouseMove, QPoint(x2,y), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+// QGuiApplication::sendEvent(&canvas, &mv);
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QString str = textEditObject->selectedText();
+ if (selectWords) {
+ QTRY_COMPARE(textEditObject->selectedText(), text);
+ } else {
+ QTRY_VERIFY(textEditObject->selectedText().length() > 3);
+ QVERIFY(str != text);
+ }
+}
+
+void tst_qquicktextedit::inputMethodHints()
+{
+ QQuickView canvas(testFileUrl("inputmethodhints.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
+ QSignalSpy inputMethodHintSpy(textEditObject, SIGNAL(inputMethodHintsChanged()));
+ textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+ textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+
+ QQuickTextEdit plainTextEdit;
+ QCOMPARE(plainTextEdit.inputMethodHints(), Qt::ImhNone);
+}
+
+void tst_qquicktextedit::positionAt()
+{
+ QQuickView canvas(testFileUrl("positionAt.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+ canvas.show();
+ canvas.requestActivateWindow();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(texteditObject != 0);
+
+ QTextLayout layout(texteditObject->text());
+ layout.setFont(texteditObject->font());
+
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ const int y0 = line.height() / 2;
+ const int y1 = line.height() * 3 / 2;
+
+ int pos = texteditObject->positionAt(texteditObject->width()/2, y0);
+
+ int widthBegin = floor(line.cursorToX(pos - 1));
+ int widthEnd = ceil(line.cursorToX(pos + 1));
+
+ QVERIFY(widthBegin <= texteditObject->width() / 2);
+ QVERIFY(widthEnd >= texteditObject->width() / 2);
+
+ const qreal x0 = texteditObject->positionToRectangle(pos).x();
+ const qreal x1 = texteditObject->positionToRectangle(pos + 1).x();
+
+ QString preeditText = texteditObject->text().mid(0, pos);
+ texteditObject->setText(texteditObject->text().mid(pos));
+ texteditObject->setCursorPosition(0);
+
+ QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent);
+
+ // Check all points within the preedit text return the same position.
+ QCOMPARE(texteditObject->positionAt(0, y0), 0);
+ QCOMPARE(texteditObject->positionAt(x0 / 2, y0), 0);
+ QCOMPARE(texteditObject->positionAt(x0, y0), 0);
+
+ // Verify positioning returns to normal after the preedit text.
+ QCOMPARE(texteditObject->positionAt(x1, y0), 1);
+ QCOMPARE(texteditObject->positionToRectangle(1).x(), x1);
+
+ QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0);
+}
+
+void tst_qquicktextedit::linkActivated()
+{
+ QQuickView canvas(testFileUrl("linkActivated.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(texteditObject != 0);
+
+ QSignalSpy spy(texteditObject, SIGNAL(linkActivated(QString)));
+
+ const QString link("http://example.com/");
+
+ const QPointF linkPos = texteditObject->positionToRectangle(7).center();
+ const QPointF textPos = texteditObject->positionToRectangle(2).center();
+
+ QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint());
+ QTRY_COMPARE(spy.count(), 1);
+ QCOMPARE(spy.last()[0].toString(), link);
+
+ QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint());
+ QTest::qWait(50);
+ QCOMPARE(spy.count(), 1);
+
+ texteditObject->setReadOnly(true);
+
+ QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint());
+ QTRY_COMPARE(spy.count(), 2);
+ QCOMPARE(spy.last()[0].toString(), link);
+
+ QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint());
+ QTest::qWait(50);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::cursorDelegate_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::newRow("out of line") << testFileUrl("cursorTest.qml");
+ QTest::newRow("in line") << testFileUrl("cursorTestInline.qml");
+ QTest::newRow("external") << testFileUrl("cursorTestExternal.qml");
+}
+
+void tst_qquicktextedit::cursorDelegate()
+{
+ QFETCH(QUrl, source);
+ QQuickView view(source);
+ view.show();
+ view.requestActivateWindow();
+ QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->findChild<QQuickItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textEditObject->setFocus(true);
+ QQuickItem* delegateObject = textEditObject->findChild<QQuickItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
+ //Test Delegate gets moved
+ for (int i=0; i<= textEditObject->text().length(); i++) {
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+ }
+ // Clear preedit text;
+ QInputMethodEvent event;
+ QGuiApplication::sendEvent(&view, &event);
+
+
+ // Test delegate gets moved on mouse press.
+ textEditObject->setSelectByMouse(true);
+ textEditObject->setCursorPosition(0);
+ const QPoint point1 = textEditObject->positionToRectangle(5).center().toPoint();
+ QTest::mouseClick(&view, Qt::LeftButton, 0, point1);
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+
+ // Test delegate gets moved on mouse drag
+ textEditObject->setCursorPosition(0);
+ const QPoint point2 = textEditObject->positionToRectangle(10).center().toPoint();
+ QTest::mousePress(&view, Qt::LeftButton, 0, point1);
+ QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(&view, &mv);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, point2);
+ QTest::qWait(50);
+ QTRY_COMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+
+ textEditObject->setReadOnly(true);
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+
+ textEditObject->setCursorPosition(0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
+ //Test Delegate gets deleted
+ textEditObject->setCursorDelegate(0);
+ QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
+}
+
+void tst_qquicktextedit::cursorVisible()
+{
+ QQuickView view(testFileUrl("cursorVisible.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextEdit edit;
+ QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool)));
+
+ QCOMPARE(edit.isCursorVisible(), false);
+
+ edit.setCursorVisible(true);
+ QCOMPARE(edit.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 1);
+
+ edit.setCursorVisible(false);
+ QCOMPARE(edit.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 2);
+
+ edit.setFocus(true);
+ QCOMPARE(edit.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 2);
+
+ edit.setParentItem(view.rootObject());
+ QCOMPARE(edit.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 3);
+
+ edit.setFocus(false);
+ QCOMPARE(edit.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 4);
+
+ edit.setFocus(true);
+ QCOMPARE(edit.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 5);
+
+ QQuickView alternateView;
+ alternateView.show();
+ alternateView.requestActivateWindow();
+ QTest::qWaitForWindowShown(&alternateView);
+
+ QCOMPARE(edit.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 6);
+
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QCOMPARE(edit.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 7);
+}
+
+void tst_qquicktextedit::delegateLoading_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<QString>("error");
+
+ // import installed
+ QTest::newRow("pass") << "cursorHttpTestPass.qml" << "";
+ QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection ";
+ QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type ";
+}
+
+void tst_qquicktextedit::delegateLoading()
+{
+#ifdef Q_OS_MAC
+ QSKIP("Test crashes during canvas tear down. QTBUG-23010");
+#endif
+ QFETCH(QString, qmlfile);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(42332);
+ server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect);
+ server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay);
+ server.serveDirectory(testFile("http"));
+
+ QQuickView view(QUrl(QLatin1String("http://localhost:42332/") + qmlfile));
+ view.show();
+ view.requestActivateWindow();
+
+ if (!error.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+ QTRY_VERIFY(view.status()==QQuickView::Error);
+ QTRY_VERIFY(!view.rootObject()); // there is fail item inside this test
+ } else {
+ QTRY_VERIFY(view.rootObject());//Wait for loading to finish.
+ QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
+ // view.rootObject()->dumpObjectTree();
+ QVERIFY(textEditObject != 0);
+ textEditObject->setFocus(true);
+ QQuickItem *delegate;
+ delegate = view.rootObject()->findChild<QQuickItem*>("delegateOkay");
+ QVERIFY(delegate);
+ delegate = view.rootObject()->findChild<QQuickItem*>("delegateSlow");
+ QVERIFY(delegate);
+
+ delete delegate;
+ }
+
+
+ //A test should be added here with a component which is ready but component.create() returns null
+ //Not sure how to accomplish this with QQuickTextEdits cursor delegate
+ //###This was only needed for code coverage, and could be a case of overzealous defensive programming
+ //delegate = view.rootObject()->findChild<QQuickItem*>("delegateErrorB");
+ //QVERIFY(!delegate);
+}
+
+/*
+TextEdit element should only handle left/right keys until the cursor reaches
+the extent of the text, then they should ignore the keys.
+*/
+void tst_qquicktextedit::navigation()
+{
+ QQuickView canvas(testFileUrl("navigation.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickItem *input = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == false);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == false);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+}
+
+void tst_qquicktextedit::copyAndPaste() {
+#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_OS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard");
+ }
+#endif
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ // copy and paste
+ QCOMPARE(textEdit->text().length(), 12);
+ textEdit->select(0, textEdit->text().length());;
+ textEdit->copy();
+ QCOMPARE(textEdit->selectedText(), QString("Hello world!"));
+ QCOMPARE(textEdit->selectedText().length(), 12);
+ textEdit->setCursorPosition(0);
+ QVERIFY(textEdit->canPaste());
+ textEdit->paste();
+ QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textEdit->text().length(), 24);
+
+ // canPaste
+ QVERIFY(textEdit->canPaste());
+ textEdit->setReadOnly(true);
+ QVERIFY(!textEdit->canPaste());
+ textEdit->setReadOnly(false);
+ QVERIFY(textEdit->canPaste());
+
+ // QTBUG-12339
+ // test that document and internal text attribute are in sync
+ QQuickItemPrivate* pri = QQuickItemPrivate::get(textEdit);
+ QQuickTextEditPrivate *editPrivate = static_cast<QQuickTextEditPrivate*>(pri);
+ QCOMPARE(textEdit->text(), editPrivate->text);
+
+ // select word
+ textEdit->setCursorPosition(0);
+ textEdit->selectWord();
+ QCOMPARE(textEdit->selectedText(), QString("Hello"));
+
+ // select all and cut
+ textEdit->selectAll();
+ textEdit->cut();
+ QCOMPARE(textEdit->text().length(), 0);
+ textEdit->paste();
+ QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textEdit->text().length(), 24);
+#endif
+}
+
+void tst_qquicktextedit::canPaste() {
+#ifndef QT_NO_CLIPBOARD
+
+ QGuiApplication::clipboard()->setText("Some text");
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ // check initial value - QTBUG-17765
+ QQuickTextControl tc(0);
+ QCOMPARE(textEdit->canPaste(), tc.canPaste());
+
+#endif
+}
+
+void tst_qquicktextedit::canPasteEmpty() {
+#ifndef QT_NO_CLIPBOARD
+
+ QGuiApplication::clipboard()->clear();
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ // check initial value - QTBUG-17765
+ QQuickTextControl tc(0);
+ QCOMPARE(textEdit->canPaste(), tc.canPaste());
+
+#endif
+}
+
+void tst_qquicktextedit::readOnly()
+{
+ QQuickView canvas(testFileUrl("readOnly.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(edit != 0);
+ QTRY_VERIFY(edit->hasActiveFocus() == true);
+ QVERIFY(edit->isReadOnly() == true);
+ QString initial = edit->text();
+ for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
+ simulateKey(&canvas, k);
+ simulateKey(&canvas, Qt::Key_Return);
+ simulateKey(&canvas, Qt::Key_Space);
+ simulateKey(&canvas, Qt::Key_Escape);
+ QCOMPARE(edit->text(), initial);
+
+ edit->setCursorPosition(3);
+ edit->setReadOnly(false);
+ QCOMPARE(edit->isReadOnly(), false);
+ QCOMPARE(edit->cursorPosition(), edit->text().length());
+}
+
+void tst_qquicktextedit::simulateKey(QQuickView *view, int key, Qt::KeyboardModifiers modifiers)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, modifiers);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers);
+
+ QGuiApplication::sendEvent(view, &press);
+ QGuiApplication::sendEvent(view, &release);
+}
+
+void tst_qquicktextedit::textInput()
+{
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+ QVERIFY(edit->hasActiveFocus() == true);
+
+ // test that input method event is committed and change signal is emitted
+ QSignalSpy spy(edit, SIGNAL(textChanged()));
+ QInputMethodEvent event;
+ event.setCommitString( "Hello world!", 0, 0);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(edit->text(), QString("Hello world!"));
+ QCOMPARE(spy.count(), 1);
+
+ // QTBUG-12339
+ // test that document and internal text attribute are in sync
+ QQuickTextEditPrivate *editPrivate = static_cast<QQuickTextEditPrivate*>(QQuickItemPrivate::get(edit));
+ QCOMPARE(editPrivate->text, QString("Hello world!"));
+
+ // test that tentative commit is included in text property
+ edit->setText("");
+ spy.clear();
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event2("preedit", attributes);
+ event2.setTentativeCommitString("string");
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event2);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(edit->text(), QString("string"));
+
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), true);
+
+ edit->setReadOnly(true);
+ QGuiApplication::sendEvent(edit, &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false);
+}
+
+void tst_qquicktextedit::inputMethodUpdate()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+ QVERIFY(edit->hasActiveFocus() == true);
+
+ // text change even without cursor position change needs to trigger update
+ edit->setText("test");
+ platformInputContext.clear();
+ edit->setText("xxxx");
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method event replacing text
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y", -1, 1);
+ QGuiApplication::sendEvent(edit, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method changing selection
+ platformInputContext.clear();
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
+ QInputMethodEvent inputMethodEvent("", attributes);
+ QGuiApplication::sendEvent(edit, &inputMethodEvent);
+ }
+ QVERIFY(edit->selectionStart() != edit->selectionEnd());
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // font changes
+ platformInputContext.clear();
+ QFont font = edit->font();
+ font.setBold(!font.bold());
+ edit->setFont(font);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // normal input
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y");
+ QGuiApplication::sendEvent(edit, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // changing cursor position
+ platformInputContext.clear();
+ edit->setCursorPosition(0);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // continuing with selection
+ platformInputContext.clear();
+ edit->moveCursorSelection(1);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // read only disabled input method
+ platformInputContext.clear();
+ edit->setReadOnly(true);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+ edit->setReadOnly(false);
+
+ // no updates while no focus
+ edit->setFocus(false);
+ platformInputContext.clear();
+ edit->setText("Foo");
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ edit->setCursorPosition(1);
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ edit->selectAll();
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ edit->setReadOnly(true);
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+}
+
+void tst_qquicktextedit::openInputPanel()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("openInputPanel.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+
+ // check default values
+ QVERIFY(edit->focusOnPress());
+ QVERIFY(!edit->hasActiveFocus());
+ qDebug() << &edit << qApp->focusObject();
+ QVERIFY(qApp->focusObject() != edit);
+
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should open on focus
+ QPoint centerPoint(view.width()/2, view.height()/2);
+ Qt::KeyboardModifiers noModifiers = 0;
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QVERIFY(edit->hasActiveFocus());
+ QCOMPARE(qApp->focusObject(), edit);
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+
+ // input panel should be re-opened when pressing already focused TextEdit
+ qApp->inputMethod()->hide();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QVERIFY(edit->hasActiveFocus());
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+
+ // input panel should stay visible if focus is lost to another text editor
+ QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
+ QQuickTextEdit anotherEdit;
+ anotherEdit.setParentItem(view.rootObject());
+ anotherEdit.setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherEdit));
+ QCOMPARE(inputPanelVisibilitySpy.count(), 0);
+
+ anotherEdit.setFocus(false);
+ QVERIFY(qApp->focusObject() != &anotherEdit);
+ QCOMPARE(view.activeFocusItem(), view.rootItem());
+ anotherEdit.setFocus(true);
+
+ qApp->inputMethod()->hide();
+
+ // input panel should not be opened if TextEdit is read only
+ edit->setReadOnly(true);
+ edit->setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should not be opened if focusOnPress is set to false
+ edit->setFocusOnPress(false);
+ edit->setFocus(false);
+ edit->setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should open when openSoftwareInputPanel is called
+ edit->openSoftwareInputPanel();
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+
+ // input panel should close when closeSoftwareInputPanel is called
+ edit->closeSoftwareInputPanel();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ inputMethodPrivate->testContext = 0;
+}
+
+void tst_qquicktextedit::geometrySignals()
+{
+ QQmlComponent component(&engine, testFileUrl("geometrySignals.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("bindingWidth").toInt(), 400);
+ QCOMPARE(o->property("bindingHeight").toInt(), 500);
+ delete o;
+}
+
+void tst_qquicktextedit::pastingRichText_QTBUG_14003()
+{
+#ifndef QT_NO_CLIPBOARD
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickTextEdit *obj = qobject_cast<QQuickTextEdit*>(component.create());
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
+
+ QMimeData *mData = new QMimeData;
+ mData->setHtml("<font color=\"red\">Hello</font>");
+ QGuiApplication::clipboard()->setMimeData(mData);
+
+ obj->paste();
+ QTRY_VERIFY(obj->text() == "");
+ QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
+#endif
+}
+
+void tst_qquicktextedit::implicitSize_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("wrap");
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap";
+ QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.NoWrap";
+ QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap";
+ QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.Wrap";
+}
+
+void tst_qquicktextedit::implicitSize()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, wrap);
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject->width() < textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+
+ textObject->resetWidth();
+ QVERIFY(textObject->width() == textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+}
+
+void tst_qquicktextedit::contentSize()
+{
+ QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+ textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ QCOMPARE(spy.count(), 1);
+
+ textObject->setWrapMode(QQuickTextEdit::WordWrap);
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 2);
+
+ textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_qquicktextedit::preeditCursorRectangle()
+{
+ QString preeditText = "super";
+
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+
+ QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged()));
+ QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
+
+ QRect currentRect;
+
+ QInputMethodQueryEvent query(Qt::ImCursorRectangle);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
+
+ // Verify that the micro focus rect is positioned the same for position 0 as
+ // it would be if there was no preedit text.
+ QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.length(), QVariant()));
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QCOMPARE(currentRect, previousRect);
+ QCOMPARE(editSpy.count(), 0);
+ QCOMPARE(panelSpy.count(), 0);
+
+ // Verify that the micro focus rect moves to the left as the cursor position
+ // is incremented.
+ for (int i = 1; i <= 5; ++i) {
+ QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant()));
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QVERIFY(previousRect.left() < currentRect.left());
+ QVERIFY(editSpy.count() > 0); editSpy.clear();
+ QVERIFY(panelSpy.count() > 0); panelSpy.clear();
+ previousRect = currentRect;
+ }
+
+ // Verify that if there is no preedit cursor then the micro focus rect is the
+ // same as it would be if it were positioned at the end of the preedit text.
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ editSpy.clear();
+ panelSpy.clear();
+ { QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); }
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QCOMPARE(currentRect, previousRect);
+ QVERIFY(editSpy.count() > 0);
+ QVERIFY(panelSpy.count() > 0);
+}
+
+void tst_qquicktextedit::inputMethodComposing()
+{
+ QString text = "supercalifragisiticexpialidocious!";
+
+ QQuickView view(testFileUrl("inputContext.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+ QSignalSpy spy(edit, SIGNAL(inputMethodComposingChanged()));
+ edit->setCursorPosition(12);
+
+ QCOMPARE(edit->isInputMethodComposing(), false);
+
+ {
+ QInputMethodEvent event(text.mid(3), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(edit, &event);
+ }
+
+ QCOMPARE(edit->isInputMethodComposing(), true);
+ QCOMPARE(spy.count(), 1);
+
+ {
+ QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(edit, &event);
+ }
+ QCOMPARE(spy.count(), 1);
+
+ {
+ QInputMethodEvent event;
+ QGuiApplication::sendEvent(edit, &event);
+ }
+ QCOMPARE(edit->isInputMethodComposing(), false);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::cursorRectangleSize()
+{
+ QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
+ QVERIFY(canvas->rootObject() != 0);
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit *>(canvas->rootObject());
+
+ // make sure cursor rectangle is not at (0,0)
+ textEdit->setX(10);
+ textEdit->setY(10);
+ textEdit->setCursorPosition(3);
+ QVERIFY(textEdit != 0);
+ textEdit->setFocus(true);
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+
+ QInputMethodQueryEvent event(Qt::ImCursorRectangle);
+ qApp->sendEvent(qApp->focusObject(), &event);
+ QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
+
+ QRectF cursorRectFromItem = textEdit->cursorRectangle();
+ QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition());
+
+ // item and input query cursor rectangles match
+ QCOMPARE(cursorRectFromItem, cursorRectFromQuery);
+
+ // item cursor rectangle and positionToRectangle calculations match
+ QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle);
+
+ // item-canvas transform and input item transform match
+ QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
+
+ // input panel cursorRectangle property and tranformed item cursor rectangle match
+ QRectF sceneCursorRect = QQuickItemPrivate::get(textEdit)->itemToCanvasTransform().mapRect(cursorRectFromItem);
+ QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
+
+ delete canvas;
+}
+
+void tst_qquicktextedit::getText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("end");
+ QTest::addColumn<QString>("expectedText");
+
+ const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
+ const QString plainBoldText = QStringLiteral("This is some bold text");
+
+ QTest::newRow("all plain text")
+ << standard.at(0)
+ << 0 << standard.at(0).length()
+ << standard.at(0);
+
+ QTest::newRow("plain text sub string")
+ << standard.at(0)
+ << 0 << 12
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text sub string reversed")
+ << standard.at(0)
+ << 12 << 0
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text cropped beginning")
+ << standard.at(0)
+ << -3 << 4
+ << standard.at(0).mid(0, 4);
+
+ QTest::newRow("plain text cropped end")
+ << standard.at(0)
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(23);
+
+ QTest::newRow("plain text cropped beginning and end")
+ << standard.at(0)
+ << -9 << standard.at(0).length() + 4
+ << standard.at(0);
+
+ QTest::newRow("all rich text")
+ << richBoldText
+ << 0 << plainBoldText.length()
+ << plainBoldText;
+
+ QTest::newRow("rich text sub string")
+ << richBoldText
+ << 14 << 21
+ << plainBoldText.mid(14, 7);
+}
+
+void tst_qquicktextedit::getText()
+{
+ QFETCH(QString, text);
+ QFETCH(int, start);
+ QFETCH(int, end);
+ QFETCH(QString, expectedText);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + text + "\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QCOMPARE(textEdit->getText(start, end), expectedText);
+}
+
+void tst_qquicktextedit::getFormattedText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("end");
+ QTest::addColumn<QString>("expectedText");
+
+ const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
+ const QString plainBoldText = QStringLiteral("This is some bold text");
+
+ QTest::newRow("all plain text")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << 0 << standard.at(0).length()
+ << standard.at(0);
+
+ QTest::newRow("plain text sub string")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << 0 << 12
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text sub string reversed")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << 12 << 0
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text cropped beginning")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << -3 << 4
+ << standard.at(0).mid(0, 4);
+
+ QTest::newRow("plain text cropped end")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(23);
+
+ QTest::newRow("plain text cropped beginning and end")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << -9 << standard.at(0).length() + 4
+ << standard.at(0);
+
+ QTest::newRow("all rich (Auto) text")
+ << richBoldText
+ << QQuickTextEdit::AutoText
+ << 0 << plainBoldText.length()
+ << QString("This is some \\<.*\\>bold\\</.*\\> text");
+
+ QTest::newRow("all rich (Rich) text")
+ << richBoldText
+ << QQuickTextEdit::RichText
+ << 0 << plainBoldText.length()
+ << QString("This is some \\<.*\\>bold\\</.*\\> text");
+
+ QTest::newRow("all rich (Plain) text")
+ << richBoldText
+ << QQuickTextEdit::PlainText
+ << 0 << richBoldText.length()
+ << richBoldText;
+
+ QTest::newRow("rich (Auto) text sub string")
+ << richBoldText
+ << QQuickTextEdit::AutoText
+ << 14 << 21
+ << QString("\\<.*\\>old\\</.*\\> tex");
+
+ QTest::newRow("rich (Rich) text sub string")
+ << richBoldText
+ << QQuickTextEdit::RichText
+ << 14 << 21
+ << QString("\\<.*\\>old\\</.*\\> tex");
+
+ QTest::newRow("rich (Plain) text sub string")
+ << richBoldText
+ << QQuickTextEdit::PlainText
+ << 17 << 27
+ << richBoldText.mid(17, 10);
+}
+
+void tst_qquicktextedit::getFormattedText()
+{
+ QFETCH(QString, text);
+ QFETCH(QQuickTextEdit::TextFormat, textFormat);
+ QFETCH(int, start);
+ QFETCH(int, end);
+ QFETCH(QString, expectedText);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit {}";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ textEdit->setTextFormat(textFormat);
+ textEdit->setText(text);
+
+ if (textFormat == QQuickTextEdit::RichText
+ || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
+ QVERIFY(textEdit->getFormattedText(start, end).contains(QRegExp(expectedText)));
+ } else {
+ QCOMPARE(textEdit->getFormattedText(start, end), expectedText);
+ }
+}
+
+void tst_qquicktextedit::insert_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("insertPosition");
+ QTest::addColumn<QString>("insertText");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedSelectionStart");
+ QTest::addColumn<int>("expectedSelectionEnd");
+ QTest::addColumn<int>("expectedCursorPosition");
+ QTest::addColumn<bool>("selectionChanged");
+ QTest::addColumn<bool>("cursorPositionChanged");
+
+ QTest::newRow("at cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 5 << 5 << 5
+ << false << true;
+
+ QTest::newRow("at cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << false << true;
+
+ QTest::newRow("at cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 23 << 23 << 23
+ << false << true;
+
+ QTest::newRow("after cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("before cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length() << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << false << true;
+
+ QTest::newRow("before cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 23 << 23 << 23
+ << false << true;
+
+ QTest::newRow("after cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("before selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 19 << 24 << 24
+ << false << true;
+
+ QTest::newRow("before reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 19 << 24 << 19
+ << false << true;
+
+ QTest::newRow("after selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 14 << 19 << 19
+ << false << false;
+
+ QTest::newRow("after reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 14 << 19 << 14
+ << false << false;
+
+ QTest::newRow("into selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 14 << 24 << 24
+ << true << true;
+
+ QTest::newRow("into reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 14 << 24 << 14
+ << true << false;
+
+ QTest::newRow("rich text into plain text")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << 0
+ << QString("<b>Hello</b>")
+ << QString("<b>Hello</b>") + standard.at(0)
+ << 12 << 12 << 12
+ << false << true;
+
+ QTest::newRow("rich text into rich text")
+ << standard.at(0) << QQuickTextEdit::RichText
+ << 0 << 0 << 0
+ << QString("<b>Hello</b>")
+ << QString("Hello") + standard.at(0)
+ << 5 << 5 << 5
+ << false << true;
+
+ QTest::newRow("rich text into auto text")
+ << standard.at(0) << QQuickTextEdit::AutoText
+ << 0 << 0 << 0
+ << QString("<b>Hello</b>")
+ << QString("Hello") + standard.at(0)
+ << 5 << 5 << 5
+ << false << true;
+
+ QTest::newRow("before start")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << -3
+ << QString("Hello")
+ << standard.at(0)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("past end")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << standard.at(0).length() + 3
+ << QString("Hello")
+ << standard.at(0)
+ << 0 << 0 << 0
+ << false << false;
+}
+
+void tst_qquicktextedit::insert()
+{
+ QFETCH(QString, text);
+ QFETCH(QQuickTextEdit::TextFormat, textFormat);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, insertPosition);
+ QFETCH(QString, insertText);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedSelectionStart);
+ QFETCH(int, expectedSelectionEnd);
+ QFETCH(int, expectedCursorPosition);
+ QFETCH(bool, selectionChanged);
+ QFETCH(bool, cursorPositionChanged);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ textEdit->setTextFormat(textFormat);
+ textEdit->select(selectionStart, selectionEnd);
+
+ QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged()));
+ QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged()));
+ QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged()));
+ QSignalSpy textSpy(textEdit, SIGNAL(textChanged()));
+ QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged()));
+
+ textEdit->insert(insertPosition, insertText);
+
+ if (textFormat == QQuickTextEdit::RichText || (textFormat == QQuickTextEdit::AutoText && (
+ Qt::mightBeRichText(text) || Qt::mightBeRichText(insertText)))) {
+ QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
+ } else {
+ QCOMPARE(textEdit->text(), expectedText);
+
+ }
+ QCOMPARE(textEdit->length(), expectedText.length());
+
+ QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
+ QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
+ QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
+
+ if (selectionStart > selectionEnd)
+ qSwap(selectionStart, selectionEnd);
+
+ QEXPECT_FAIL("into selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
+ QEXPECT_FAIL("into reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
+ QCOMPARE(selectionSpy.count() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
+ QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue);
+ QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.count() > 0, text != expectedText);
+ QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
+}
+
+void tst_qquicktextedit::remove_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("removeStart");
+ QTest::addColumn<int>("removeEnd");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedSelectionStart");
+ QTest::addColumn<int>("expectedSelectionEnd");
+ QTest::addColumn<int>("expectedCursorPosition");
+ QTest::addColumn<bool>("selectionChanged");
+ QTest::addColumn<bool>("cursorPositionChanged");
+
+ const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
+ const QString plainBoldText = QStringLiteral("This is some bold text");
+
+ QTest::newRow("from cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("to cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << 5 << 0
+ << standard.at(0).mid(5)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("to cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).length() << standard.at(0).length() - 5
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("to cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("from cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("to cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 23 << 23
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << true;
+
+ QTest::newRow("after cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("before cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length()
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("before cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 23 << 23
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 18 << 18 << 18
+ << false << true;
+
+ QTest::newRow("after cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("before selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 9 << 14 << 14
+ << false << true;
+
+ QTest::newRow("before reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 9 << 14 << 9
+ << false << true;
+
+ QTest::newRow("after selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << 14 << 19 << 19
+ << false << false;
+
+ QTest::newRow("after reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << 14 << 19 << 14
+ << false << false;
+
+ QTest::newRow("from selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 24
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 14 << 19 << 19
+ << true << true;
+
+ QTest::newRow("from reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 24 << 14
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 14 << 19 << 14
+ << true << false;
+
+ QTest::newRow("plain text cropped beginning")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << -3 << 4
+ << standard.at(0).mid(4)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("plain text cropped end")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(0, 23)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("plain text cropped beginning and end")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << -9 << standard.at(0).length() + 4
+ << QString()
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("all rich text")
+ << richBoldText << QQuickTextEdit::RichText
+ << 0 << 0
+ << 0 << plainBoldText.length()
+ << QString()
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("rick text sub string")
+ << richBoldText << QQuickTextEdit::RichText
+ << 0 << 0
+ << 14 << 21
+ << plainBoldText.mid(0, 14) + plainBoldText.mid(21)
+ << 0 << 0 << 0
+ << false << false;
+}
+
+void tst_qquicktextedit::remove()
+{
+ QFETCH(QString, text);
+ QFETCH(QQuickTextEdit::TextFormat, textFormat);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, removeStart);
+ QFETCH(int, removeEnd);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedSelectionStart);
+ QFETCH(int, expectedSelectionEnd);
+ QFETCH(int, expectedCursorPosition);
+ QFETCH(bool, selectionChanged);
+ QFETCH(bool, cursorPositionChanged);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ textEdit->setTextFormat(textFormat);
+ textEdit->select(selectionStart, selectionEnd);
+
+ QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged()));
+ QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged()));
+ QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged()));
+ QSignalSpy textSpy(textEdit, SIGNAL(textChanged()));
+ QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged()));
+
+ textEdit->remove(removeStart, removeEnd);
+
+ if (textFormat == QQuickTextEdit::RichText
+ || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
+ QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
+ } else {
+ QCOMPARE(textEdit->text(), expectedText);
+ }
+ QCOMPARE(textEdit->length(), expectedText.length());
+
+ if (selectionStart > selectionEnd) //
+ qSwap(selectionStart, selectionEnd);
+
+ QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
+ QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
+ QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
+
+ QEXPECT_FAIL("from selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
+ QEXPECT_FAIL("from reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
+ QCOMPARE(selectionSpy.count() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
+ QEXPECT_FAIL("from reversed selection", "selectionEndChanged signal not emitted", Continue);
+ QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.count() > 0, text != expectedText);
+
+
+ if (cursorPositionChanged) //
+ QVERIFY(cursorPositionSpy.count() > 0);
+}
+
+
+void tst_qquicktextedit::keySequence_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QKeySequence>("sequence");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QString>("selectedText");
+
+ // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
+
+ QTest::newRow("select all")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
+ << 44 << standard.at(0) << standard.at(0);
+ QTest::newRow("select end of line")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
+ << 44 << standard.at(0) << standard.at(0).mid(5);
+ QTest::newRow("select end of document")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
+ << 44 << standard.at(0) << standard.at(0).mid(3);
+ QTest::newRow("select end of block")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
+ << 44 << standard.at(0) << standard.at(0).mid(18);
+ QTest::newRow("delete end of line")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
+ << 24 << standard.at(0).mid(0, 24) << QString();
+ QTest::newRow("move to start of line")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
+ << 0 << standard.at(0) << QString();
+ QTest::newRow("move to start of block")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
+ << 0 << standard.at(0) << QString();
+ QTest::newRow("move to next char")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
+ << 13 << standard.at(0) << QString();
+ QTest::newRow("move to previous char")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
+ << 2 << standard.at(0) << QString();
+ QTest::newRow("select next char")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
+ << 24 << standard.at(0) << standard.at(0).mid(23, 1);
+ QTest::newRow("select previous char")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
+ << 18 << standard.at(0) << standard.at(0).mid(18, 1);
+ QTest::newRow("move to next word")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
+ << 10 << standard.at(0) << QString();
+ QTest::newRow("move to previous word")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
+ << 4 << standard.at(0) << QString();
+ QTest::newRow("select previous word")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
+ << 10 << standard.at(0) << standard.at(0).mid(10, 1);
+ QTest::newRow("delete (selection)")
+ << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
+ << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
+ QTest::newRow("delete (no selection)")
+ << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
+ << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
+ QTest::newRow("delete end of word")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
+ << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
+ QTest::newRow("delete start of word")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
+ << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
+}
+
+void tst_qquicktextedit::keySequence()
+{
+ QFETCH(QString, text);
+ QFETCH(QKeySequence, sequence);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, cursorPosition);
+ QFETCH(QString, expectedText);
+ QFETCH(QString, selectedText);
+
+ if (sequence.isEmpty()) {
+ QSKIP("Key sequence is undefined");
+ }
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true; text: \"" + text + "\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QQuickCanvas canvas;
+ textEdit->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ textEdit->select(selectionStart, selectionEnd);
+
+ simulateKeys(&canvas, sequence);
+
+ QCOMPARE(textEdit->cursorPosition(), cursorPosition);
+ QCOMPARE(textEdit->text(), expectedText);
+ QCOMPARE(textEdit->selectedText(), selectedText);
+}
+
+#define NORMAL 0
+#define REPLACE_UNTIL_END 1
+
+void tst_qquicktextedit::undo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<IntList>("insertMode");
+ QTest::addColumn<QStringList>("expectedString");
+ QTest::addColumn<bool>("use_keys");
+
+ for (int i=0; i<2; i++) {
+ QString keys_str = "keyboard";
+ bool use_keys = true;
+ if (i==0) {
+ keys_str = "insert";
+ use_keys = false;
+ }
+
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "1";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "5";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "3";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "2";
+
+ insertIndex << 3;
+ insertMode << NORMAL;
+ insertString << "4";
+
+ expectedString << "12345";
+ expectedString << "1235";
+ expectedString << "135";
+ expectedString << "15";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "World"; // World
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Hello"; // HelloWorld
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Well"; // WellHelloWorld
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "WellHelloThereWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "HelloWorld";
+ expectedString << "World";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "Ensuring";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << " instan";
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "an ";
+
+ insertIndex << 10;
+ insertMode << REPLACE_UNTIL_END;
+ insertString << " unique instance.";
+
+ expectedString << "Ensuring a unique instance.";
+ expectedString << "Ensuring a "; // ### Not present in TextInput.
+ expectedString << "Ensuring an instan";
+ expectedString << "Ensuring instan";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ }
+}
+
+void tst_qquicktextedit::undo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(IntList, insertMode);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QQuickCanvas canvas;
+ textEdit->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ QVERIFY(!textEdit->canUndo());
+
+ QSignalSpy spy(textEdit, SIGNAL(canUndoChanged()));
+
+ int i;
+
+// STEP 1: First build up an undo history by inserting or typing some strings...
+ for (i = 0; i < insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ textEdit->setCursorPosition(insertIndex[i]);
+
+ // experimental stuff
+ if (insertMode[i] == REPLACE_UNTIL_END) {
+ textEdit->select(insertIndex[i], insertIndex[i] + 8);
+
+ // This is what I actually want...
+ // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
+ }
+
+ for (int j = 0; j < insertString.at(i).length(); j++)
+ QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+// STEP 2: Next call undo several times and see if we can restore to the previous state
+ for (i = 0; i < expectedString.size() - 1; ++i) {
+ QCOMPARE(textEdit->text(), expectedString[i]);
+ QVERIFY(textEdit->canUndo());
+ textEdit->undo();
+ }
+
+// STEP 3: Verify that we have undone everything
+ QVERIFY(textEdit->text().isEmpty());
+ QVERIFY(!textEdit->canUndo());
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::redo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ IntList insertIndex;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertString << "World"; // World
+ insertIndex << 0;
+ insertString << "Hello"; // HelloWorld
+ insertIndex << 0;
+ insertString << "Well"; // WellHelloWorld
+ insertIndex << 9;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "World";
+ expectedString << "HelloWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "WellHelloThereWorld";
+
+ QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
+ }
+}
+
+void tst_qquicktextedit::redo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QQuickCanvas canvas;
+ textEdit->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ QVERIFY(!textEdit->canUndo());
+ QVERIFY(!textEdit->canRedo());
+
+ QSignalSpy spy(textEdit, SIGNAL(canRedoChanged()));
+
+ int i;
+ // inserts the diff strings at diff positions
+ for (i = 0; i < insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ textEdit->setCursorPosition(insertIndex[i]);
+ for (int j = 0; j < insertString.at(i).length(); j++)
+ QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
+ QVERIFY(textEdit->canUndo());
+ QVERIFY(!textEdit->canRedo());
+ }
+
+ QCOMPARE(spy.count(), 0);
+
+ // undo everything
+ while (!textEdit->text().isEmpty()) {
+ QVERIFY(textEdit->canUndo());
+ textEdit->undo();
+ QVERIFY(textEdit->canRedo());
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+ for (i = 0; i < expectedString.size(); ++i) {
+ QVERIFY(textEdit->canRedo());
+ textEdit->redo();
+ QCOMPARE(textEdit->text() , expectedString[i]);
+ QVERIFY(textEdit->canUndo());
+ }
+ QVERIFY(!textEdit->canRedo());
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::undo_keypressevents_data()
+{
+ QTest::addColumn<KeyList>("keys");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ KeyList keys;
+ QStringList expectedString;
+
+ keys << "AFRAID"
+ << Qt::Key_Home
+ << "VERY"
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << "BE"
+ << Qt::Key_End
+ << "!";
+
+ expectedString << "BEVERYAFRAID!";
+ expectedString << "BEVERYAFRAID";
+ expectedString << "VERYAFRAID";
+ expectedString << "AFRAID";
+
+ QTest::newRow("Inserts and moving cursor") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '1234'
+ keys << "1234" << Qt::Key_Home
+ // skipping '12'
+ << Qt::Key_Right << Qt::Key_Right
+ // selecting '34'
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ // deleting '34'
+ << Qt::Key_Delete;
+
+ expectedString << "12";
+ expectedString << "1234";
+
+ QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'AB12'
+ keys << "AB12"
+ << Qt::Key_Home
+ // selecting 'AB'
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ << Qt::Key_Delete
+ << QKeySequence::Undo
+ // ### Text is selected in text input
+// << Qt::Key_Right
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ << Qt::Key_Delete;
+
+ expectedString << "AB";
+ expectedString << "AB12";
+
+ QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'ABCD'
+ keys << "abcd"
+ //move left two
+ << Qt::Key_Left << Qt::Key_Left
+ // inserting '1234'
+ << "1234"
+ // selecting '1234'
+ << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
+ // overwriting '1234' with '5'
+ << "5"
+ // undoing deletion of 'AB'
+ << QKeySequence::Undo
+ // ### Text is selected in text input
+ << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
+ // overwriting '1234' with '6'
+ << "6";
+
+ expectedString << "ab6cd";
+ // for versions previous to 3.2 we overwrite needed two undo operations
+ expectedString << "ab1234cd";
+ expectedString << "abcd";
+
+ QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'ABC'
+ keys << "ABC"
+ // removes 'C'
+ << Qt::Key_Backspace;
+
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ keys << "ABC"
+ // removes 'C'
+ << Qt::Key_Backspace
+ // inserting 'Z'
+ << "Z";
+
+ expectedString << "ABZ";
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '123'
+ keys << "123" << Qt::Key_Home
+ // selecting '123'
+ << (Qt::Key_End | Qt::ShiftModifier)
+ // overwriting '123' with 'ABC'
+ << "ABC";
+
+ expectedString << "ABC";
+ // ### One operation in TextInput.
+ expectedString << "A";
+ expectedString << "123";
+
+ QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
+ }
+}
+
+void tst_qquicktextedit::undo_keypressevents()
+{
+ QFETCH(KeyList, keys);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QQuickCanvas canvas;
+ textEdit->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ simulateKeys(&canvas, keys);
+
+ for (int i = 0; i < expectedString.size(); ++i) {
+ QCOMPARE(textEdit->text() , expectedString[i]);
+ textEdit->undo();
+ }
+ QVERIFY(textEdit->text().isEmpty());
+}
+
+void tst_qquicktextedit::baseUrl()
+{
+ QUrl localUrl("file:///tests/text.qml");
+ QUrl remoteUrl("http://qt.nokia.com/test.qml");
+
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\n TextEdit {}", localUrl);
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(textComponent.create());
+
+ QCOMPARE(textObject->baseUrl(), localUrl);
+
+ QSignalSpy spy(textObject, SIGNAL(baseUrlChanged()));
+
+ textObject->setBaseUrl(localUrl);
+ QCOMPARE(textObject->baseUrl(), localUrl);
+ QCOMPARE(spy.count(), 0);
+
+ textObject->setBaseUrl(remoteUrl);
+ QCOMPARE(textObject->baseUrl(), remoteUrl);
+ QCOMPARE(spy.count(), 1);
+
+ textObject->resetBaseUrl();
+ QCOMPARE(textObject->baseUrl(), localUrl);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::embeddedImages_data()
+{
+ QTest::addColumn<QUrl>("qmlfile");
+ QTest::addColumn<QString>("error");
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
+ QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
+ << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML TextEdit: Cannot open: " + testFileUrl("http/notexists.png").toString();
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
+ QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
+ << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading http://127.0.0.1:42332/notexists.png - server replied: Not found";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
+}
+
+void tst_qquicktextedit::embeddedImages()
+{
+ QFETCH(QUrl, qmlfile);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(42332);
+ server.serveDirectory(testFile("http"));
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
+
+ QQmlComponent textComponent(&engine, qmlfile);
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QTRY_COMPARE(QQuickTextEditPrivate::get(textObject)->document->resourcesLoading(), 0);
+
+ QPixmap pm(testFile("http/exists.png"));
+ if (error.isEmpty()) {
+ QCOMPARE(textObject->width(), double(pm.width()));
+ QCOMPARE(textObject->height(), double(pm.height()));
+ } else {
+ QVERIFY(16 != pm.width()); // check test is effective
+ QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
+ QCOMPARE(textObject->height(), 16.0);
+ }
+
+ delete textObject;
+}
+
+void tst_qquicktextedit::emptytags_QTBUG_22058()
+{
+ QQuickView canvas(testFileUrl("qtbug-22058.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("inputField")));
+ QVERIFY(input->hasActiveFocus());
+
+ QInputMethodEvent event("", QList<QInputMethodEvent::Attribute>());
+ event.setCommitString("<b>Bold<");
+ QGuiApplication::sendEvent(input, &event);
+ QCOMPARE(input->text(), QString("<b>Bold<"));
+ event.setCommitString(">");
+ QGuiApplication::sendEvent(input, &event);
+ QCOMPARE(input->text(), QString("<b>Bold<>"));
+}
+
+QTEST_MAIN(tst_qquicktextedit)
+
+#include "tst_qquicktextedit.moc"
diff --git a/tests/auto/qtquick2/qquicktextinput/data/Cursor.qml b/tests/auto/quick/qquicktextinput/data/Cursor.qml
index e5c1853fc5..e5c1853fc5 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/Cursor.qml
+++ b/tests/auto/quick/qquicktextinput/data/Cursor.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml b/tests/auto/quick/qquicktextinput/data/cursorTest.qml
index 71a420ee7c..71a420ee7c 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml
+++ b/tests/auto/quick/qquicktextinput/data/cursorTest.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml b/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml
index 9277dcc518..9277dcc518 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml
+++ b/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml b/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml
index efc4b191da..efc4b191da 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml
+++ b/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml b/tests/auto/quick/qquicktextinput/data/cursorVisible.qml
index 49e9386947..49e9386947 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml
+++ b/tests/auto/quick/qquicktextinput/data/cursorVisible.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/echoMode.qml b/tests/auto/quick/qquicktextinput/data/echoMode.qml
index f8a6cf1c89..f8a6cf1c89 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/echoMode.qml
+++ b/tests/auto/quick/qquicktextinput/data/echoMode.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml b/tests/auto/quick/qquicktextinput/data/geometrySignals.qml
index 90855a61cf..90855a61cf 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml
+++ b/tests/auto/quick/qquicktextinput/data/geometrySignals.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_center.png b/tests/auto/quick/qquicktextinput/data/halign_center.png
index 53e09a8e5b..53e09a8e5b 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/halign_center.png
+++ b/tests/auto/quick/qquicktextinput/data/halign_center.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_left.png b/tests/auto/quick/qquicktextinput/data/halign_left.png
index 247acbc9df..247acbc9df 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/halign_left.png
+++ b/tests/auto/quick/qquicktextinput/data/halign_left.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_right.png b/tests/auto/quick/qquicktextinput/data/halign_right.png
index 691bc75c89..691bc75c89 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/halign_right.png
+++ b/tests/auto/quick/qquicktextinput/data/halign_right.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml b/tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml
index 89934532e3..89934532e3 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml
+++ b/tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
index 5f88025536..5f88025536 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
+++ b/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputContext.qml b/tests/auto/quick/qquicktextinput/data/inputContext.qml
index dfc80990c6..dfc80990c6 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/inputContext.qml
+++ b/tests/auto/quick/qquicktextinput/data/inputContext.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml b/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml
index 7aefdf28f4..7aefdf28f4 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml
+++ b/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml b/tests/auto/quick/qquicktextinput/data/inputmethods.qml
index 711e89144c..711e89144c 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml
+++ b/tests/auto/quick/qquicktextinput/data/inputmethods.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/masks.qml b/tests/auto/quick/qquicktextinput/data/masks.qml
index 589b6a3c15..589b6a3c15 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/masks.qml
+++ b/tests/auto/quick/qquicktextinput/data/masks.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/maxLength.qml b/tests/auto/quick/qquicktextinput/data/maxLength.qml
index cca537ed6b..cca537ed6b 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/maxLength.qml
+++ b/tests/auto/quick/qquicktextinput/data/maxLength.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml b/tests/auto/quick/qquicktextinput/data/mouseselection_true.qml
index 974041b04a..974041b04a 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml
+++ b/tests/auto/quick/qquicktextinput/data/mouseselection_true.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml
index f7c658b618..f7c658b618 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml
+++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml
index 974041b04a..974041b04a 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml
+++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml
index 20e777e470..20e777e470 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml
+++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/navigation.qml b/tests/auto/quick/qquicktextinput/data/navigation.qml
index 3a7d07b3c7..3a7d07b3c7 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/navigation.qml
+++ b/tests/auto/quick/qquicktextinput/data/navigation.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml b/tests/auto/quick/qquicktextinput/data/negativeDimensions.qml
index 7a58c85b1d..7a58c85b1d 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml
+++ b/tests/auto/quick/qquicktextinput/data/negativeDimensions.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml b/tests/auto/quick/qquicktextinput/data/openInputPanel.qml
index ca5cb263aa..ca5cb263aa 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml
+++ b/tests/auto/quick/qquicktextinput/data/openInputPanel.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml b/tests/auto/quick/qquicktextinput/data/persistentSelection.qml
index dea6e48b08..dea6e48b08 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml
+++ b/tests/auto/quick/qquicktextinput/data/persistentSelection.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/positionAt.qml b/tests/auto/quick/qquicktextinput/data/positionAt.qml
index edb4744107..edb4744107 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/positionAt.qml
+++ b/tests/auto/quick/qquicktextinput/data/positionAt.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml b/tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml
index 9d98a2e220..9d98a2e220 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml
+++ b/tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml
index e9b80fceb2..e9b80fceb2 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml
+++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml
index 0d70eedb80..0d70eedb80 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml
+++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml
index b5af13cc4c..b5af13cc4c 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml
+++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/readOnly.qml b/tests/auto/quick/qquicktextinput/data/readOnly.qml
index 9cda7fbd1d..9cda7fbd1d 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/readOnly.qml
+++ b/tests/auto/quick/qquicktextinput/data/readOnly.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/validators.qml b/tests/auto/quick/qquicktextinput/data/validators.qml
index 0ba87e0592..0ba87e0592 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/validators.qml
+++ b/tests/auto/quick/qquicktextinput/data/validators.qml
diff --git a/tests/auto/quick/qquicktextinput/qquicktextinput.pro b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
new file mode 100644
index 0000000000..78b39a2981
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TARGET = tst_qquicktextinput
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktextinput.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
new file mode 100644
index 0000000000..bdd18d620e
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -0,0 +1,4703 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include "../../shared/util.h"
+#include <private/qinputmethod_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlexpression.h>
+#include <QFile>
+#include <QtQuick/qquickview.h>
+#include <QtGui/qguiapplication.h>
+#include <QtGui/qstylehints.h>
+#include <QInputMethod>
+#include <private/qquicktextinput_p.h>
+#include <private/qquicktextinput_p_p.h>
+#include <QDebug>
+#include <QDir>
+#include <QStyle>
+#include <QtOpenGL/QGLShaderProgram>
+#include <math.h>
+
+#ifdef Q_OS_MAC
+#include <Carbon/Carbon.h>
+#endif
+
+#include "qplatformdefs.h"
+#include "../../shared/platforminputcontext.h"
+
+Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode)
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
+
+QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
+{
+ // XXX This will be replaced by some clever persistent platform image store.
+ QString persistent_dir = QQmlDataTest::instance()->dataDirectory();
+ 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;
+}
+
+template <typename T> static T evaluate(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ T result = expr.evaluate().value<T>();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+ return result;
+}
+
+typedef QPair<int, QChar> Key;
+
+class tst_qquicktextinput : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_qquicktextinput();
+
+private slots:
+ void cleanup();
+ void text();
+ void width();
+ void font();
+ void color();
+ void wrap();
+ void selection();
+ void persistentSelection();
+ void isRightToLeft_data();
+ void isRightToLeft();
+ void moveCursorSelection_data();
+ void moveCursorSelection();
+ void moveCursorSelectionSequence_data();
+ void moveCursorSelectionSequence();
+ void dragMouseSelection();
+ void mouseSelectionMode_data();
+ void mouseSelectionMode();
+ void tripleClickSelectsAll();
+
+ void horizontalAlignment_data();
+ void horizontalAlignment();
+ void horizontalAlignment_RightToLeft();
+ void verticalAlignment();
+
+ void boundingRect();
+
+ void positionAt();
+
+ void maxLength();
+ void masks();
+ void validators();
+ void inputMethods();
+
+ void passwordCharacter();
+ void cursorDelegate_data();
+ void cursorDelegate();
+ void cursorVisible();
+ void cursorRectangle();
+ void navigation();
+ void navigation_RTL();
+ void copyAndPaste();
+ void copyAndPasteKeySequence();
+ void canPasteEmpty();
+ void canPaste();
+ void readOnly();
+
+ void openInputPanel();
+ void setHAlignClearCache();
+ void focusOutClearSelection();
+
+ void echoMode();
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+ void passwordEchoDelay();
+#endif
+ void geometrySignals();
+ void contentSize();
+
+ void preeditAutoScroll();
+ void preeditCursorRectangle();
+ void inputContextMouseHandler();
+ void inputMethodComposing();
+ void inputMethodUpdate();
+ void cursorRectangleSize();
+
+ void getText_data();
+ void getText();
+ void insert_data();
+ void insert();
+ void remove_data();
+ void remove();
+
+ void keySequence_data();
+ void keySequence();
+
+ void undo_data();
+ void undo();
+ void redo_data();
+ void redo();
+ void undo_keypressevents_data();
+ void undo_keypressevents();
+
+ void QTBUG_19956();
+ void QTBUG_19956_data();
+ void QTBUG_19956_regexp();
+
+ void negativeDimensions();
+
+private:
+ void simulateKey(QQuickView *, int key);
+
+ void simulateKeys(QWindow *window, const QList<Key> &keys);
+ void simulateKeys(QWindow *window, const QKeySequence &sequence);
+
+ QQmlEngine engine;
+ QStringList standard;
+ QStringList colorStrings;
+};
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(IntList)
+
+typedef QList<Key> KeyList;
+Q_DECLARE_METATYPE(KeyList)
+
+void tst_qquicktextinput::simulateKeys(QWindow *window, const QList<Key> &keys)
+{
+ for (int i = 0; i < keys.count(); ++i) {
+ const int key = keys.at(i).first;
+ const int modifiers = key & Qt::KeyboardModifierMask;
+ const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
+
+ QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
+ QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
+
+ QGuiApplication::sendEvent(window, &press);
+ QGuiApplication::sendEvent(window, &release);
+ }
+}
+
+void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i) {
+ const int key = sequence[i];
+ const int modifiers = key & Qt::KeyboardModifierMask;
+
+ QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers));
+ }
+}
+
+QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i)
+ keys << Key(sequence[i], QChar());
+ return keys;
+}
+
+template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
+{
+ for (int i = 0; i < N - 1; ++i) {
+ int key = QTest::asciiToKey(characters[i]);
+ QChar character = QLatin1Char(characters[i]);
+ keys << Key(key, character);
+ }
+ return keys;
+}
+
+QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
+{
+ keys << Key(key, QChar());
+ return keys;
+}
+
+void tst_qquicktextinput::cleanup()
+{
+ // ensure not even skipped tests with custom input context leave it dangling
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
+tst_qquicktextinput::tst_qquicktextinput()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "It's supercalifragisiticexpialidocious!"
+ << "Hello, world!"
+ << "!dlrow ,olleH"
+ << " spacey text ";
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+}
+
+void tst_qquicktextinput::text()
+{
+ {
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), QString(""));
+ QCOMPARE(textinputObject->length(), 0);
+
+ delete textinputObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), standard.at(i));
+ QCOMPARE(textinputObject->length(), standard.at(i).length());
+
+ delete textinputObject;
+ }
+
+}
+
+void tst_qquicktextinput::width()
+{
+ // uses Font metrics to find the width for standard
+ {
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), 0.0);
+
+ delete textinputObject;
+ }
+
+ bool requiresUnhintedMetrics = !qmlDisableDistanceField();
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QString s = standard.at(i);
+ s.replace(QLatin1Char('\n'), QChar::LineSeparator);
+
+ QTextLayout layout(s);
+ layout.setFont(textinputObject->font());
+ layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
+ if (requiresUnhintedMetrics) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ }
+
+ layout.endLayout();
+
+ qreal metricWidth = ceil(layout.boundingRect().width());
+
+ QVERIFY(textinputObject != 0);
+ int delta = abs(int(int(textinputObject->width()) - metricWidth));
+ QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform.
+
+ delete textinputObject;
+ }
+}
+
+void tst_qquicktextinput::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().pointSize(), 40);
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+
+ delete textinputObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.bold: true; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().bold(), true);
+ QCOMPARE(textinputObject->font().italic(), false);
+
+ delete textinputObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.italic: true; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().italic(), true);
+ QCOMPARE(textinputObject->font().bold(), false);
+
+ delete textinputObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+
+ delete textinputObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString(""));
+
+ delete textinputObject;
+ }
+}
+
+void tst_qquicktextinput::color()
+{
+ //test color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
+
+ delete textinputObject;
+ }
+
+ //test selection color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
+
+ delete textinputObject;
+ }
+
+ //test selected text color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
+
+ delete textinputObject;
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), testColor);
+
+ delete textinputObject;
+ }
+}
+
+void tst_qquicktextinput::wrap()
+{
+ int textHeight = 0;
+ // for specified width and wrap set true
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nTextInput { text: \"Hello\"; wrapMode: Text.WrapAnywhere; width: 300 }", QUrl::fromLocalFile(""));
+ QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
+ textHeight = textObject->height();
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->wrapMode() == QQuickTextInput::WrapAnywhere);
+ QCOMPARE(textObject->width(), 300.);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.count(); i++) {
+ QString componentStr = "import QtQuick 2.0\nTextInput { wrapMode: Text.WrapAnywhere; width: 30; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+
+ int oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktextinput::selection()
+{
+ QString testStr = standard[0];
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+
+ //Test selection follows cursor
+ for (int i=0; i<= testStr.size(); i++) {
+ textinputObject->setCursorPosition(i);
+ QCOMPARE(textinputObject->cursorPosition(), i);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QVERIFY(textinputObject->selectedText().isNull());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ // Verify invalid positions are ignored.
+ textinputObject->setCursorPosition(-1);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ textinputObject->setCursorPosition(textinputObject->text().count()+1);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ //Test selection
+ for (int i=0; i<= testStr.size(); i++) {
+ textinputObject->select(0,i);
+ QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
+ }
+ for (int i=0; i<= testStr.size(); i++) {
+ textinputObject->select(i,testStr.size());
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ //Test Error Ignoring behaviour
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(-10,0);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(100,110);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(0,-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(0,100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(0,10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->select(-10,10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->select(100,101);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->select(0,-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->select(0,100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+
+ textinputObject->deselect();
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(0,10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->deselect();
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ // test input method selection
+ QSignalSpy selectionSpy(textinputObject, SIGNAL(selectedTextChanged()));
+ textinputObject->setFocus(true);
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant());
+ QInputMethodEvent event("", attributes);
+ QGuiApplication::sendEvent(textinputObject, &event);
+ }
+ QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(textinputObject->selectionStart(), 12);
+ QCOMPARE(textinputObject->selectionEnd(), 17);
+
+ delete textinputObject;
+}
+
+void tst_qquicktextinput::persistentSelection()
+{
+ QQuickView canvas(testFileUrl("persistentSelection.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+ canvas.requestActivateWindow();
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(input);
+ QVERIFY(input->hasActiveFocus());
+
+ QSignalSpy spy(input, SIGNAL(persistentSelectionChanged()));
+
+ QCOMPARE(input->persistentSelection(), false);
+
+ input->setPersistentSelection(false);
+ QCOMPARE(input->persistentSelection(), false);
+ QCOMPARE(spy.count(), 0);
+
+ input->select(1, 4);
+ QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
+
+ input->setFocus(false);
+ QCOMPARE(input->property("selected").toString(), QString());
+
+ input->setFocus(true);
+ QCOMPARE(input->property("selected").toString(), QString());
+
+ input->setPersistentSelection(true);
+ QCOMPARE(input->persistentSelection(), true);
+ QCOMPARE(spy.count(), 1);
+
+ input->select(1, 4);
+ QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
+
+ input->setFocus(false);
+ QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
+
+ input->setFocus(true);
+ QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
+}
+
+void tst_qquicktextinput::isRightToLeft_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<bool>("emptyString");
+ QTest::addColumn<bool>("firstCharacter");
+ QTest::addColumn<bool>("lastCharacter");
+ QTest::addColumn<bool>("middleCharacter");
+ QTest::addColumn<bool>("startString");
+ QTest::addColumn<bool>("midString");
+ QTest::addColumn<bool>("endString");
+
+ const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
+ QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
+ QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
+ QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
+ QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
+ QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
+ QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
+}
+
+void tst_qquicktextinput::isRightToLeft()
+{
+ QFETCH(QString, text);
+ QFETCH(bool, emptyString);
+ QFETCH(bool, firstCharacter);
+ QFETCH(bool, lastCharacter);
+ QFETCH(bool, middleCharacter);
+ QFETCH(bool, startString);
+ QFETCH(bool, midString);
+ QFETCH(bool, endString);
+
+ QQuickTextInput textInput;
+ textInput.setText(text);
+
+ // first test that the right string is delivered to the QString::isRightToLeft()
+ QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
+ if (text.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
+ QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
+
+ // then test that the feature actually works
+ QCOMPARE(textInput.isRightToLeft(0,0), emptyString);
+ QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter);
+ QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
+ QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
+ QCOMPARE(textInput.isRightToLeft(0,text.count()/4), startString);
+ QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), midString);
+ if (text.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
+ QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), endString);
+}
+
+void tst_qquicktextinput::moveCursorSelection_data()
+{
+ QTest::addColumn<QString>("testStr");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<int>("movePosition");
+ QTest::addColumn<QQuickTextInput::SelectionMode>("mode");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<bool>("reversible");
+
+ // () contains the text selected by the cursor.
+ // <> contains the actual selection.
+
+ QTest::newRow("(t)he|characters")
+ << standard[0] << 0 << 1 << QQuickTextInput::SelectCharacters << 0 << 1 << true;
+ QTest::newRow("do(g)|characters")
+ << standard[0] << 43 << 44 << QQuickTextInput::SelectCharacters << 43 << 44 << true;
+ QTest::newRow("jum(p)ed|characters")
+ << standard[0] << 23 << 24 << QQuickTextInput::SelectCharacters << 23 << 24 << true;
+ QTest::newRow("jumped( )over|characters")
+ << standard[0] << 26 << 27 << QQuickTextInput::SelectCharacters << 26 << 27 << true;
+ QTest::newRow("(the )|characters")
+ << standard[0] << 0 << 4 << QQuickTextInput::SelectCharacters << 0 << 4 << true;
+ QTest::newRow("( dog)|characters")
+ << standard[0] << 40 << 44 << QQuickTextInput::SelectCharacters << 40 << 44 << true;
+ QTest::newRow("( jumped )|characters")
+ << standard[0] << 19 << 27 << QQuickTextInput::SelectCharacters << 19 << 27 << true;
+ QTest::newRow("th(e qu)ick|characters")
+ << standard[0] << 2 << 6 << QQuickTextInput::SelectCharacters << 2 << 6 << true;
+ QTest::newRow("la(zy d)og|characters")
+ << standard[0] << 38 << 42 << QQuickTextInput::SelectCharacters << 38 << 42 << true;
+ QTest::newRow("jum(ped ov)er|characters")
+ << standard[0] << 23 << 29 << QQuickTextInput::SelectCharacters << 23 << 29 << true;
+ QTest::newRow("()the|characters")
+ << standard[0] << 0 << 0 << QQuickTextInput::SelectCharacters << 0 << 0 << true;
+ QTest::newRow("dog()|characters")
+ << standard[0] << 44 << 44 << QQuickTextInput::SelectCharacters << 44 << 44 << true;
+ QTest::newRow("jum()ped|characters")
+ << standard[0] << 23 << 23 << QQuickTextInput::SelectCharacters << 23 << 23 << true;
+
+ QTest::newRow("<(t)he>|words")
+ << standard[0] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 3 << true;
+ QTest::newRow("<do(g)>|words")
+ << standard[0] << 43 << 44 << QQuickTextInput::SelectWords << 41 << 44 << true;
+ QTest::newRow("<jum(p)ed>|words")
+ << standard[0] << 23 << 24 << QQuickTextInput::SelectWords << 20 << 26 << true;
+ QTest::newRow("<jumped( )>over|words,ltr")
+ << standard[0] << 26 << 27 << QQuickTextInput::SelectWords << 20 << 27 << false;
+ QTest::newRow("jumped<( )over>|words,rtl")
+ << standard[0] << 27 << 26 << QQuickTextInput::SelectWords << 26 << 31 << false;
+ QTest::newRow("<(the )>quick|words,ltr")
+ << standard[0] << 0 << 4 << QQuickTextInput::SelectWords << 0 << 4 << false;
+ QTest::newRow("<(the )quick>|words,rtl")
+ << standard[0] << 4 << 0 << QQuickTextInput::SelectWords << 0 << 9 << false;
+ QTest::newRow("<lazy( dog)>|words,ltr")
+ << standard[0] << 40 << 44 << QQuickTextInput::SelectWords << 36 << 44 << false;
+ QTest::newRow("lazy<( dog)>|words,rtl")
+ << standard[0] << 44 << 40 << QQuickTextInput::SelectWords << 40 << 44 << false;
+ QTest::newRow("<fox( jumped )>over|words,ltr")
+ << standard[0] << 19 << 27 << QQuickTextInput::SelectWords << 16 << 27 << false;
+ QTest::newRow("fox<( jumped )over>|words,rtl")
+ << standard[0] << 27 << 19 << QQuickTextInput::SelectWords << 19 << 31 << false;
+ QTest::newRow("<th(e qu)ick>|words")
+ << standard[0] << 2 << 6 << QQuickTextInput::SelectWords << 0 << 9 << true;
+ QTest::newRow("<la(zy d)og|words>")
+ << standard[0] << 38 << 42 << QQuickTextInput::SelectWords << 36 << 44 << true;
+ QTest::newRow("<jum(ped ov)er>|words")
+ << standard[0] << 23 << 29 << QQuickTextInput::SelectWords << 20 << 31 << true;
+ QTest::newRow("<()>the|words")
+ << standard[0] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true;
+ QTest::newRow("dog<()>|words")
+ << standard[0] << 44 << 44 << QQuickTextInput::SelectWords << 44 << 44 << true;
+ QTest::newRow("jum<()>ped|words")
+ << standard[0] << 23 << 23 << QQuickTextInput::SelectWords << 23 << 23 << true;
+
+ QTest::newRow("Hello<(,)> |words")
+ << standard[2] << 5 << 6 << QQuickTextInput::SelectWords << 5 << 6 << true;
+ QTest::newRow("Hello<(, )>world|words,ltr")
+ << standard[2] << 5 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false;
+ QTest::newRow("Hello<(, )world>|words,rtl")
+ << standard[2] << 7 << 5 << QQuickTextInput::SelectWords << 5 << 12 << false;
+ QTest::newRow("<Hel(lo, )>world|words,ltr")
+ << standard[2] << 3 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false;
+ QTest::newRow("<Hel(lo, )world>|words,rtl")
+ << standard[2] << 7 << 3 << QQuickTextInput::SelectWords << 0 << 12 << false;
+ QTest::newRow("<Hel(lo)>,|words")
+ << standard[2] << 3 << 5 << QQuickTextInput::SelectWords << 0 << 5 << true;
+ QTest::newRow("Hello<()>,|words")
+ << standard[2] << 5 << 5 << QQuickTextInput::SelectWords << 5 << 5 << true;
+ QTest::newRow("Hello,<()>|words")
+ << standard[2] << 6 << 6 << QQuickTextInput::SelectWords << 6 << 6 << true;
+ QTest::newRow("Hello<,( )>world|words,ltr")
+ << standard[2] << 6 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false;
+ QTest::newRow("Hello,<( )world>|words,rtl")
+ << standard[2] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false;
+ QTest::newRow("Hello<,( world)>|words,ltr")
+ << standard[2] << 6 << 12 << QQuickTextInput::SelectWords << 5 << 12 << false;
+ QTest::newRow("Hello,<( world)>|words,rtl")
+ << standard[2] << 12 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false;
+ QTest::newRow("Hello<,( world!)>|words,ltr")
+ << standard[2] << 6 << 13 << QQuickTextInput::SelectWords << 5 << 13 << false;
+ QTest::newRow("Hello,<( world!)>|words,rtl")
+ << standard[2] << 13 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false;
+ QTest::newRow("Hello<(, world!)>|words")
+ << standard[2] << 5 << 13 << QQuickTextInput::SelectWords << 5 << 13 << true;
+ // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings.
+ // QTBUG-11365
+ // QTest::newRow("world<(!)>|words")
+ // << standard[2] << 12 << 13 << QQuickTextInput::SelectWords << 12 << 13 << true;
+ QTest::newRow("world!<()>)|words")
+ << standard[2] << 13 << 13 << QQuickTextInput::SelectWords << 13 << 13 << true;
+ QTest::newRow("world<()>!)|words")
+ << standard[2] << 12 << 12 << QQuickTextInput::SelectWords << 12 << 12 << true;
+
+ QTest::newRow("<(,)>olleH |words")
+ << standard[3] << 7 << 8 << QQuickTextInput::SelectWords << 7 << 8 << true;
+ QTest::newRow("<dlrow( ,)>olleH|words,ltr")
+ << standard[3] << 6 << 8 << QQuickTextInput::SelectWords << 1 << 8 << false;
+ QTest::newRow("dlrow<( ,)>olleH|words,rtl")
+ << standard[3] << 8 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false;
+ QTest::newRow("<dlrow( ,ol)leH>|words,ltr")
+ << standard[3] << 6 << 10 << QQuickTextInput::SelectWords << 1 << 13 << false;
+ QTest::newRow("dlrow<( ,ol)leH>|words,rtl")
+ << standard[3] << 10 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false;
+ QTest::newRow(",<(ol)leH>,|words")
+ << standard[3] << 8 << 10 << QQuickTextInput::SelectWords << 8 << 13 << true;
+ QTest::newRow(",<()>olleH|words")
+ << standard[3] << 8 << 8 << QQuickTextInput::SelectWords << 8 << 8 << true;
+ QTest::newRow("<()>,olleH|words")
+ << standard[3] << 7 << 7 << QQuickTextInput::SelectWords << 7 << 7 << true;
+ QTest::newRow("<dlrow( )>,olleH|words,ltr")
+ << standard[3] << 6 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false;
+ QTest::newRow("dlrow<( ),>olleH|words,rtl")
+ << standard[3] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false;
+ QTest::newRow("<(dlrow )>,olleH|words,ltr")
+ << standard[3] << 1 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false;
+ QTest::newRow("<(dlrow ),>olleH|words,rtl")
+ << standard[3] << 7 << 1 << QQuickTextInput::SelectWords << 1 << 8 << false;
+ QTest::newRow("<(!dlrow )>,olleH|words,ltr")
+ << standard[3] << 0 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false;
+ QTest::newRow("<(!dlrow ),>olleH|words,rtl")
+ << standard[3] << 7 << 0 << QQuickTextInput::SelectWords << 0 << 8 << false;
+ QTest::newRow("(!dlrow ,)olleH|words")
+ << standard[3] << 0 << 8 << QQuickTextInput::SelectWords << 0 << 8 << true;
+ QTest::newRow("<(!)>dlrow|words")
+ << standard[3] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << true;
+ QTest::newRow("<()>!dlrow|words")
+ << standard[3] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true;
+ QTest::newRow("!<()>dlrow|words")
+ << standard[3] << 1 << 1 << QQuickTextInput::SelectWords << 1 << 1 << true;
+
+ QTest::newRow(" <s(pac)ey> text |words")
+ << standard[4] << 1 << 4 << QQuickTextInput::SelectWords << 1 << 7 << true;
+ QTest::newRow(" spacey <t(ex)t> |words")
+ << standard[4] << 11 << 13 << QQuickTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365
+ QTest::newRow("<( )>spacey text |words|ltr")
+ << standard[4] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << false;
+ QTest::newRow("<( )spacey> text |words|rtl")
+ << standard[4] << 1 << 0 << QQuickTextInput::SelectWords << 0 << 7 << false;
+ QTest::newRow("spacey <text( )>|words|ltr")
+ << standard[4] << 14 << 15 << QQuickTextInput::SelectWords << 10 << 15 << false;
+// QTBUG-11365
+// QTest::newRow("spacey text<( )>|words|rtl")
+// << standard[4] << 15 << 14 << QQuickTextInput::SelectWords << 14 << 15 << false;
+ QTest::newRow("<()> spacey text |words")
+ << standard[4] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << false;
+ QTest::newRow(" spacey text <()>|words")
+ << standard[4] << 15 << 15 << QQuickTextInput::SelectWords << 15 << 15 << false;
+}
+
+void tst_qquicktextinput::moveCursorSelection()
+{
+ QFETCH(QString, testStr);
+ QFETCH(int, cursorPosition);
+ QFETCH(int, movePosition);
+ QFETCH(QQuickTextInput::SelectionMode, mode);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(bool, reversible);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+ textinputObject->setCursorPosition(cursorPosition);
+ textinputObject->moveCursorSelection(movePosition, mode);
+
+ QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
+ QCOMPARE(textinputObject->selectionStart(), selectionStart);
+ QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
+
+ if (reversible) {
+ textinputObject->setCursorPosition(movePosition);
+ textinputObject->moveCursorSelection(cursorPosition, mode);
+
+ QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
+ QCOMPARE(textinputObject->selectionStart(), selectionStart);
+ QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
+ }
+
+ delete textinputObject;
+}
+
+void tst_qquicktextinput::moveCursorSelectionSequence_data()
+{
+ QTest::addColumn<QString>("testStr");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<int>("movePosition1");
+ QTest::addColumn<int>("movePosition2");
+ QTest::addColumn<int>("selection1Start");
+ QTest::addColumn<int>("selection1End");
+ QTest::addColumn<int>("selection2Start");
+ QTest::addColumn<int>("selection2End");
+
+ // () contains the text selected by the cursor.
+ // <> contains the actual selection.
+ // ^ is the revised cursor position.
+ // {} contains the revised selection.
+
+ QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 17
+ << 4 << 15
+ << 4 << 19;
+ QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 17
+ << 9 << 15
+ << 10 << 19;
+ QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 16
+ << 4 << 15
+ << 4 << 16;
+ QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 16
+ << 9 << 15
+ << 10 << 16;
+ QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 15
+ << 4 << 15
+ << 4 << 15;
+ QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 15
+ << 9 << 15
+ << 10 << 15;
+ QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 10
+ << 4 << 15
+ << 4 << 10;
+ QTest::newRow("the quick<( {^bro)wn>} fox|rtl")
+ << standard[0]
+ << 13 << 9 << 10
+ << 9 << 15
+ << 10 << 15;
+ QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 9
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
+ << standard[0]
+ << 13 << 9 << 9
+ << 9 << 15
+ << 9 << 15;
+ QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 7
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 7
+ << 9 << 15
+ << 4 << 15;
+ QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 4
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 4
+ << 9 << 15
+ << 4 << 15;
+ QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 3
+ << 4 << 15
+ << 3 << 9;
+ QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 3
+ << 9 << 15
+ << 3 << 15;
+ QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 1
+ << 4 << 15
+ << 0 << 9;
+ QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 1
+ << 9 << 15
+ << 0 << 15;
+
+ QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
+ << standard[2]
+ << 2 << 4 << 8
+ << 0 << 5
+ << 0 << 12;
+ QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
+ << standard[2]
+ << 4 << 2 << 8
+ << 0 << 5
+ << 0 << 12;
+
+ QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
+ << standard[3]
+ << 9 << 11 << 5
+ << 8 << 13
+ << 1 << 13;
+ QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
+ << standard[3]
+ << 11 << 9 << 5
+ << 8 << 13
+ << 1 << 13;
+
+ QTest::newRow("{<(^} sp)acey> text |ltr")
+ << standard[4]
+ << 0 << 3 << 0
+ << 0 << 7
+ << 0 << 0;
+ QTest::newRow("{<( ^}sp)acey> text |ltr")
+ << standard[4]
+ << 0 << 3 << 1
+ << 0 << 7
+ << 0 << 1;
+ QTest::newRow("<( {s^p)acey>} text |rtl")
+ << standard[4]
+ << 3 << 0 << 2
+ << 0 << 7
+ << 1 << 7;
+ QTest::newRow("<( {^sp)acey>} text |rtl")
+ << standard[4]
+ << 3 << 0 << 1
+ << 0 << 7
+ << 1 << 7;
+
+ QTest::newRow(" spacey <te(xt {^)>}|rtl")
+ << standard[4]
+ << 15 << 12 << 15
+ << 10 << 15
+ << 15 << 15;
+// QTBUG-11365
+// QTest::newRow(" spacey <te(xt{^ )>}|rtl")
+// << standard[4]
+// << 15 << 12 << 14
+// << 10 << 15
+// << 14 << 15;
+ QTest::newRow(" spacey {<te(x^t} )>|ltr")
+ << standard[4]
+ << 12 << 15 << 13
+ << 10 << 15
+ << 10 << 14;
+// QTBUG-11365
+// QTest::newRow(" spacey {<te(xt^} )>|ltr")
+// << standard[4]
+// << 12 << 15 << 14
+// << 10 << 15
+// << 10 << 14;
+}
+
+void tst_qquicktextinput::moveCursorSelectionSequence()
+{
+ QFETCH(QString, testStr);
+ QFETCH(int, cursorPosition);
+ QFETCH(int, movePosition1);
+ QFETCH(int, movePosition2);
+ QFETCH(int, selection1Start);
+ QFETCH(int, selection1End);
+ QFETCH(int, selection2Start);
+ QFETCH(int, selection2End);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+ textinputObject->setCursorPosition(cursorPosition);
+
+ textinputObject->moveCursorSelection(movePosition1, QQuickTextInput::SelectWords);
+ QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
+ QCOMPARE(textinputObject->selectionStart(), selection1Start);
+ QCOMPARE(textinputObject->selectionEnd(), selection1End);
+
+ textinputObject->moveCursorSelection(movePosition2, QQuickTextInput::SelectWords);
+ QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
+ QCOMPARE(textinputObject->selectionStart(), selection2Start);
+ QCOMPARE(textinputObject->selectionEnd(), selection2End);
+
+ delete textinputObject;
+}
+
+void tst_qquicktextinput::dragMouseSelection()
+{
+ QString qmlfile = testFile("mouseselection_true.qml");
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *textInputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textInputObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textInputObject->height()/2;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(100);
+ QString str1;
+ QVERIFY((str1 = textInputObject->selectedText()).length() > 3);
+ QVERIFY(str1.length() > 3);
+
+ // press and drag the current selection.
+ x1 = 40;
+ x2 = 100;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(300);
+ QString str2 = textInputObject->selectedText();
+ QVERIFY(str2.length() > 3);
+
+ QVERIFY(str1 != str2);
+}
+
+void tst_qquicktextinput::mouseSelectionMode_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<bool>("selectWords");
+
+ // import installed
+ QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
+ QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
+ QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
+}
+
+void tst_qquicktextinput::mouseSelectionMode()
+{
+ QFETCH(QString, qmlfile);
+ QFETCH(bool, selectWords);
+
+ QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *textInputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textInputObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textInputObject->height()/2;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2,y)); // doesn't work
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(300);
+ if (selectWords) {
+ QTRY_COMPARE(textInputObject->selectedText(), text);
+ } else {
+ QTRY_VERIFY(textInputObject->selectedText().length() > 3);
+ QVERIFY(textInputObject->selectedText() != text);
+ }
+}
+
+void tst_qquicktextinput::horizontalAlignment_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ 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_qquicktextinput::horizontalAlignment()
+{
+ QSKIP("Image comparison of text is almost guaranteed to fail during development");
+
+ QFETCH(int, hAlign);
+ QFETCH(QString, expectfile);
+
+ QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+ QObject *ob = canvas.rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ QImage actual = canvas.grabFrameBuffer();
+
+ expectfile = createExpectedFileIfNotFound(expectfile, actual);
+
+ QImage expect(expectfile);
+
+ QCOMPARE(actual,expect);
+}
+
+void tst_qquicktextinput::horizontalAlignment_RightToLeft()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
+ QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
+ QVERIFY(textInput != 0);
+ canvas.show();
+
+ const QString rtlText = textInput->text();
+
+ QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput);
+ QVERIFY(textInputPrivate != 0);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // implicit alignment should follow the reading direction of RTL text
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // explicitly left aligned
+ textInput->setHAlign(QQuickTextInput::AlignLeft);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
+
+ // explicitly right aligned
+ textInput->setHAlign(QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // explicitly center aligned
+ textInput->setHAlign(QQuickTextInput::AlignHCenter);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignHCenter);
+ QVERIFY(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll > 0);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll < textInput->width());
+
+ // reseted alignment should go back to following the text reading direction
+ textInput->resetHAlign();
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // mirror the text item
+ QQuickItemPrivate::get(textInput)->setLayoutMirror(true);
+
+ // mirrored implicit alignment should continue to follow the reading direction of the text
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // explicitly right aligned behaves as left aligned
+ textInput->setHAlign(QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
+
+ // mirrored explicitly left aligned behaves as right aligned
+ textInput->setHAlign(QQuickTextInput::AlignLeft);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // disable mirroring
+ QQuickItemPrivate::get(textInput)->setLayoutMirror(false);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ textInput->resetHAlign();
+
+ // English text should be implicitly left aligned
+ textInput->setText("Hello world!");
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
+
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ // If there is no commited text, the preedit text should determine the alignment.
+ textInput->setText(QString());
+ { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+
+ // Clear pre-edit text. TextInput should maybe do this itself on setText, but that may be
+ // redundant as an actual input method may take care of it.
+ { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+
+ // empty text with implicit alignment follows the system locale-based
+ // keyboard input direction from QInputMethod::inputDirection()
+ textInput->setText("");
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
+
+ QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged()));
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
+ QCOMPARE(cursorRectangleSpy.count(), 1);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // set input direction while having content
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ textInput->setText("a");
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ QTest::keyClick(&canvas, Qt::Key_Backspace);
+ QVERIFY(textInput->text().isEmpty());
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // input direction changed while not having focus
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ textInput->setFocus(false);
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ textInput->setFocus(true);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ textInput->setHAlign(QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+}
+
+void tst_qquicktextinput::verticalAlignment()
+{
+ QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
+ QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
+ QVERIFY(textInput != 0);
+ canvas.show();
+
+ QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput);
+ QVERIFY(textInputPrivate != 0);
+
+ QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignTop);
+ QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll < canvas.height() / 2);
+ QVERIFY(textInput->cursorRectangle().bottom() < canvas.height() / 2);
+ QVERIFY(textInput->positionToRectangle(0).bottom() < canvas.height() / 2);
+
+ // bottom aligned
+ textInput->setVAlign(QQuickTextInput::AlignBottom);
+ QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignBottom);
+ QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll > canvas.height() / 2);
+ QVERIFY(textInput->cursorRectangle().top() > canvas.height() / 2);
+ QVERIFY(textInput->positionToRectangle(0).top() > canvas.height() / 2);
+
+ // explicitly center aligned
+ textInput->setVAlign(QQuickTextInput::AlignVCenter);
+ QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignVCenter);
+ QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll < canvas.height() / 2);
+ QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll > canvas.height() / 2);
+ QVERIFY(textInput->cursorRectangle().top() < canvas.height() / 2);
+ QVERIFY(textInput->cursorRectangle().bottom() > canvas.height() / 2);
+ QVERIFY(textInput->positionToRectangle(0).top() < canvas.height() / 2);
+ QVERIFY(textInput->positionToRectangle(0).bottom() > canvas.height() / 2);
+}
+
+void tst_qquicktextinput::boundingRect()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\n TextInput {}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(object.data());
+ QVERIFY(input);
+
+ QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+
+ input->setText("Hello World");
+ QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+
+ // bounding rect shouldn't exceed the size of the item, expect for the cursor width;
+ input->setWidth(input->width() / 2);
+ QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+
+ input->setHeight(input->height() * 2);
+ QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+
+ QQmlComponent cursorComponent(&engine);
+ cursorComponent.setData("import QtQuick 2.0\nRectangle { height: 20; width: 8 }", QUrl());
+
+ input->setCursorDelegate(&cursorComponent);
+
+ // If a cursor delegate is used it's size should determine the excess width.
+ QCOMPARE(input->width() + 8, input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+}
+
+void tst_qquicktextinput::positionAt()
+{
+ QQuickView canvas(testFileUrl("positionAt.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textinputObject != 0);
+
+ // Check autoscrolled...
+
+ int pos = evaluate<int>(textinputObject, QString("positionAt(%1)").arg(textinputObject->width()/2));
+
+ QTextLayout layout(textinputObject->text());
+ layout.setFont(textinputObject->font());
+
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ int textLeftWidthBegin = floor(line.cursorToX(pos - 1));
+ int textLeftWidthEnd = ceil(line.cursorToX(pos + 1));
+ int textWidth = floor(line.horizontalAdvance());
+
+ QVERIFY(textLeftWidthBegin <= textWidth - textinputObject->width() / 2);
+ QVERIFY(textLeftWidthEnd >= textWidth - textinputObject->width() / 2);
+
+ int x = textinputObject->positionToRectangle(pos + 1).x() - 1;
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos);
+
+ // Check without autoscroll...
+ textinputObject->setAutoScroll(false);
+ pos = evaluate<int>(textinputObject, QString("positionAt(%1)").arg(textinputObject->width() / 2));
+
+ textLeftWidthBegin = floor(line.cursorToX(pos - 1));
+ textLeftWidthEnd = ceil(line.cursorToX(pos + 1));
+
+ QVERIFY(textLeftWidthBegin <= textinputObject->width() / 2);
+ QVERIFY(textLeftWidthEnd >= textinputObject->width() / 2);
+
+ x = textinputObject->positionToRectangle(pos + 1).x() - 1;
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos);
+
+ const qreal x0 = textinputObject->positionToRectangle(pos).x();
+ const qreal x1 = textinputObject->positionToRectangle(pos + 1).x();
+
+ QString preeditText = textinputObject->text().mid(0, pos);
+ textinputObject->setText(textinputObject->text().mid(pos));
+ textinputObject->setCursorPosition(0);
+
+ { QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QVERIFY(qGuiApp->focusObject());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); }
+
+ // Check all points within the preedit text return the same position.
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(0)), 0);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x0 / 2)), 0);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x0)), 0);
+
+ // Verify positioning returns to normal after the preedit text.
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x1)), 1);
+ QCOMPARE(textinputObject->positionToRectangle(1).x(), x1);
+
+ { QInputMethodEvent inputEvent;
+ QVERIFY(qGuiApp->focusObject());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); }
+
+ // With wrapping.
+ textinputObject->setWrapMode(QQuickTextInput::WrapAnywhere);
+
+ const qreal y0 = line.height() / 2;
+ const qreal y1 = line.height() * 3 / 2;
+
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y0)), pos);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y0)), pos + 1);
+
+ int newLinePos = evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y1));
+ QVERIFY(newLinePos > pos);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y1)), newLinePos + 1);
+}
+
+void tst_qquicktextinput::maxLength()
+{
+ QQuickView canvas(testFileUrl("maxLength.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textinputObject != 0);
+ QVERIFY(textinputObject->text().isEmpty());
+ QVERIFY(textinputObject->maxLength() == 10);
+ foreach (const QString &str, standard) {
+ QVERIFY(textinputObject->text().length() <= 10);
+ textinputObject->setText(str);
+ QVERIFY(textinputObject->text().length() <= 10);
+ }
+
+ textinputObject->setText("");
+ QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
+ for (int i=0; i<20; i++) {
+ QTRY_COMPARE(textinputObject->text().length(), qMin(i,10));
+ //simulateKey(&canvas, Qt::Key_A);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ }
+}
+
+void tst_qquicktextinput::masks()
+{
+ //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
+ //QString componentStr = "import QtQuick 2.0\nTextInput { inputMask: 'HHHHhhhh'; }";
+ QQuickView canvas(testFileUrl("masks.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textinputObject != 0);
+ QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
+ QVERIFY(textinputObject->text().length() == 0);
+ QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
+ QCOMPARE(textinputObject->length(), 8);
+ for (int i=0; i<10; i++) {
+ QTRY_COMPARE(qMin(i,8), textinputObject->text().length());
+ QCOMPARE(textinputObject->length(), 8);
+ QCOMPARE(textinputObject->getText(0, qMin(i, 8)), QString(qMin(i, 8), 'a'));
+ QCOMPARE(textinputObject->getText(qMin(i, 8), 8), QString(8 - qMin(i, 8), ' '));
+ QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
+ //simulateKey(&canvas, Qt::Key_A);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ }
+}
+
+void tst_qquicktextinput::validators()
+{
+ // Note that this test assumes that the validators are working properly
+ // so you may need to run their tests first. All validators are checked
+ // here to ensure that their exposure to QML is working.
+
+ QLocale::setDefault(QLocale(QStringLiteral("C")));
+
+ QQuickView canvas(testFileUrl("validators.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QLocale defaultLocale;
+ QLocale enLocale("en");
+ QLocale deLocale("de_DE");
+
+ QQuickTextInput *intInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("intInput")));
+ QVERIFY(intInput);
+ QSignalSpy intSpy(intInput, SIGNAL(acceptableInputChanged()));
+
+ QQuickIntValidator *intValidator = qobject_cast<QQuickIntValidator *>(intInput->validator());
+ QVERIFY(intValidator);
+ QCOMPARE(intValidator->localeName(), defaultLocale.name());
+ QCOMPARE(intInput->validator()->locale(), defaultLocale);
+ intValidator->setLocaleName(enLocale.name());
+ QCOMPARE(intValidator->localeName(), enLocale.name());
+ QCOMPARE(intInput->validator()->locale(), enLocale);
+ intValidator->resetLocaleName();
+ QCOMPARE(intValidator->localeName(), defaultLocale.name());
+ QCOMPARE(intInput->validator()->locale(), defaultLocale);
+
+ intInput->setFocus(true);
+ QTRY_VERIFY(intInput->hasActiveFocus());
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QCOMPARE(intInput->property("acceptable").toBool(), false);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QCOMPARE(intInput->property("acceptable").toBool(), false);
+ QCOMPARE(intSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_2);
+ QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QCOMPARE(intInput->property("acceptable").toBool(), false);
+ QCOMPARE(intSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_Period);
+ QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(&canvas, Qt::Key_Comma);
+ QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1,"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ intValidator->setLocaleName(deLocale.name());
+ QTest::keyPress(&canvas, Qt::Key_Period);
+ QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1."));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ intValidator->resetLocaleName();
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QCOMPARE(intInput->text(), QLatin1String("11"));
+ QCOMPARE(intInput->hasAcceptableInput(), true);
+ QCOMPARE(intInput->property("acceptable").toBool(), true);
+ QCOMPARE(intSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_0);
+ QTest::keyRelease(&canvas, Qt::Key_0, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QCOMPARE(intInput->text(), QLatin1String("11"));
+ QCOMPARE(intInput->hasAcceptableInput(), true);
+ QCOMPARE(intInput->property("acceptable").toBool(), true);
+ QCOMPARE(intSpy.count(), 1);
+
+ QQuickTextInput *dblInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("dblInput")));
+ QVERIFY(dblInput);
+ QSignalSpy dblSpy(dblInput, SIGNAL(acceptableInputChanged()));
+
+ QQuickDoubleValidator *dblValidator = qobject_cast<QQuickDoubleValidator *>(dblInput->validator());
+ QVERIFY(dblValidator);
+ QCOMPARE(dblValidator->localeName(), defaultLocale.name());
+ QCOMPARE(dblInput->validator()->locale(), defaultLocale);
+ dblValidator->setLocaleName(enLocale.name());
+ QCOMPARE(dblValidator->localeName(), enLocale.name());
+ QCOMPARE(dblInput->validator()->locale(), enLocale);
+ dblValidator->resetLocaleName();
+ QCOMPARE(dblValidator->localeName(), defaultLocale.name());
+ QCOMPARE(dblInput->validator()->locale(), defaultLocale);
+
+ dblInput->setFocus(true);
+ QVERIFY(dblInput->hasActiveFocus() == true);
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_2);
+ QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_Comma);
+ QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ dblValidator->setLocaleName(deLocale.name());
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ dblValidator->resetLocaleName();
+ QTest::keyPress(&canvas, Qt::Key_Period);
+ QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+
+ // Ensure the validator doesn't prevent characters being removed.
+ dblInput->setValidator(intInput->validator());
+ QCOMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ // Once unacceptable input is in anything goes until it reaches an acceptable state again.
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QCOMPARE(dblInput->text(), QLatin1String("11"));
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblSpy.count(), 3);
+
+ QQuickTextInput *strInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("strInput")));
+ QVERIFY(strInput);
+ QSignalSpy strSpy(strInput, SIGNAL(acceptableInputChanged()));
+ strInput->setFocus(true);
+ QVERIFY(strInput->hasActiveFocus() == true);
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QCOMPARE(strInput->property("acceptable").toBool(), false);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String(""));
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QCOMPARE(strInput->property("acceptable").toBool(), false);
+ QCOMPARE(strSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("a"));
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QCOMPARE(strInput->property("acceptable").toBool(), false);
+ QCOMPARE(strSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QCOMPARE(strInput->property("acceptable").toBool(), true);
+ QCOMPARE(strSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QCOMPARE(strInput->property("acceptable").toBool(), true);
+ QCOMPARE(strSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QCOMPARE(strInput->property("acceptable").toBool(), true);
+ QCOMPARE(strSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QCOMPARE(strInput->property("acceptable").toBool(), true);
+ QCOMPARE(strSpy.count(), 1);
+
+ QQuickTextInput *unvalidatedInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("unvalidatedInput")));
+ QVERIFY(unvalidatedInput);
+ QSignalSpy unvalidatedSpy(unvalidatedInput, SIGNAL(acceptableInputChanged()));
+ unvalidatedInput->setFocus(true);
+ QVERIFY(unvalidatedInput->hasActiveFocus() == true);
+ QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
+ QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1"));
+ QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
+ QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
+ QCOMPARE(unvalidatedSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1a"));
+ QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
+ QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
+ QCOMPARE(unvalidatedSpy.count(), 0);
+}
+
+void tst_qquicktextinput::inputMethods()
+{
+ QQuickView canvas(testFileUrl("inputmethods.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ // test input method hints
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(input != 0);
+ QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText);
+ QSignalSpy inputMethodHintSpy(input, SIGNAL(inputMethodHintsChanged()));
+ input->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+ input->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+
+ // default value
+ QQuickTextInput plainInput;
+ QCOMPARE(plainInput.inputMethodHints(), Qt::ImhNone);
+
+ input->setFocus(true);
+ QVERIFY(input->hasActiveFocus() == true);
+ // test that input method event is committed
+ QInputMethodEvent event;
+ event.setCommitString( "My ", -12, 0);
+ QTRY_COMPARE(qGuiApp->focusObject(), input);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->text(), QString("My Hello world!"));
+
+ input->setCursorPosition(2);
+ event.setCommitString("Your", -2, 2);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->text(), QString("Your Hello world!"));
+ QCOMPARE(input->cursorPosition(), 4);
+
+ input->setCursorPosition(7);
+ event.setCommitString("Goodbye", -2, 5);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->text(), QString("Your Goodbye world!"));
+ QCOMPARE(input->cursorPosition(), 12);
+
+ input->setCursorPosition(8);
+ event.setCommitString("Our", -8, 4);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->text(), QString("Our Goodbye world!"));
+ QCOMPARE(input->cursorPosition(), 7);
+
+ // test that basic tentative commit gets to text property on preedit state
+ input->setText("");
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent preeditEvent("test", attributes);
+ preeditEvent.setTentativeCommitString("test");
+ QGuiApplication::sendEvent(input, &preeditEvent);
+ QCOMPARE(input->text(), QString("test"));
+
+ // tentative commit not allowed present in surrounding text
+ QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText);
+ QGuiApplication::sendEvent(input, &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString(""));
+
+ // if text with tentative commit does not validate, not allowed to be part of text property
+ input->setText(""); // ensure input state is reset
+ QValidator *validator = new QIntValidator(0, 100);
+ input->setValidator(validator);
+ QGuiApplication::sendEvent(input, &preeditEvent);
+ QCOMPARE(input->text(), QString(""));
+ input->setValidator(0);
+ delete validator;
+
+ // input should reset selection even if replacement parameters are out of bounds
+ input->setText("text");
+ input->setCursorPosition(0);
+ input->moveCursorSelection(input->text().length());
+ event.setCommitString("replacement", -input->text().length(), input->text().length());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->selectionStart(), input->selectionEnd());
+
+ QInputMethodQueryEvent enabledQueryEvent(Qt::ImEnabled);
+ QGuiApplication::sendEvent(input, &enabledQueryEvent);
+ QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), true);
+
+ input->setReadOnly(true);
+ QGuiApplication::sendEvent(input, &enabledQueryEvent);
+ QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), false);
+}
+
+/*
+TextInput element should only handle left/right keys until the cursor reaches
+the extent of the text, then they should ignore the keys.
+
+*/
+void tst_qquicktextinput::navigation()
+{
+ QQuickView canvas(testFileUrl("navigation.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ input->setCursorPosition(0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == false);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+ //QT-2944: If text is selected, ensure we deselect upon cursor motion
+ input->setCursorPosition(input->text().length());
+ input->select(0,input->text().length());
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->selectionStart() == input->selectionEnd());
+ QVERIFY(input->selectionStart() == input->text().length());
+ QVERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == false);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+
+ // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438).
+ input->setCursorPosition(2);
+ QCOMPARE(input->cursorPosition(),2);
+ simulateKey(&canvas, Qt::Key_Up);
+ QCOMPARE(input->cursorPosition(),2);
+ simulateKey(&canvas, Qt::Key_Down);
+ QCOMPARE(input->cursorPosition(),2);
+}
+
+void tst_qquicktextinput::navigation_RTL()
+{
+ QQuickView canvas(testFileUrl("navigation.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
+ input->setText(QString::fromUtf16(arabic_str, 11));
+
+ input->setCursorPosition(0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+
+ // move off
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == false);
+
+ // move back
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+
+ input->setCursorPosition(input->text().length());
+ QVERIFY(input->hasActiveFocus() == true);
+
+ // move off
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == false);
+
+ // move back
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+}
+
+void tst_qquicktextinput::copyAndPaste() {
+#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_OS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard");
+ }
+#endif
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ // copy and paste
+ QCOMPARE(textInput->text().length(), 12);
+ textInput->select(0, textInput->text().length());;
+ textInput->copy();
+ QCOMPARE(textInput->selectedText(), QString("Hello world!"));
+ QCOMPARE(textInput->selectedText().length(), 12);
+ textInput->setCursorPosition(0);
+ QVERIFY(textInput->canPaste());
+ textInput->paste();
+ QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textInput->text().length(), 24);
+
+ // can paste
+ QVERIFY(textInput->canPaste());
+ textInput->setReadOnly(true);
+ QVERIFY(!textInput->canPaste());
+ textInput->setReadOnly(false);
+ QVERIFY(textInput->canPaste());
+
+ // select word
+ textInput->setCursorPosition(0);
+ textInput->selectWord();
+ QCOMPARE(textInput->selectedText(), QString("Hello"));
+
+ // select all and cut
+ textInput->selectAll();
+ textInput->cut();
+ QCOMPARE(textInput->text().length(), 0);
+ textInput->paste();
+ QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textInput->text().length(), 24);
+
+ // clear copy buffer
+ QClipboard *clipboard = QGuiApplication::clipboard();
+ QVERIFY(clipboard);
+ clipboard->clear();
+ QVERIFY(!textInput->canPaste());
+
+ // test that copy functionality is disabled
+ // when echo mode is set to hide text/password mode
+ int index = 0;
+ while (index < 4) {
+ QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
+ textInput->setEchoMode(echoMode);
+ textInput->setText("My password");
+ textInput->select(0, textInput->text().length());;
+ textInput->copy();
+ if (echoMode == QQuickTextInput::Normal) {
+ QVERIFY(!clipboard->text().isEmpty());
+ QCOMPARE(clipboard->text(), QString("My password"));
+ clipboard->clear();
+ } else {
+ QVERIFY(clipboard->text().isEmpty());
+ }
+ index++;
+ }
+
+ delete textInput;
+#endif
+}
+
+void tst_qquicktextinput::copyAndPasteKeySequence() {
+#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_OS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard");
+ }
+#endif
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; focus: true }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ // copy and paste
+ QVERIFY(textInput->hasActiveFocus());
+ QCOMPARE(textInput->text().length(), 12);
+ textInput->select(0, textInput->text().length());
+ simulateKeys(&canvas, QKeySequence::Copy);
+ QCOMPARE(textInput->selectedText(), QString("Hello world!"));
+ QCOMPARE(textInput->selectedText().length(), 12);
+ textInput->setCursorPosition(0);
+ QVERIFY(textInput->canPaste());
+ simulateKeys(&canvas, QKeySequence::Paste);
+ QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textInput->text().length(), 24);
+
+ // select all and cut
+ simulateKeys(&canvas, QKeySequence::SelectAll);
+ simulateKeys(&canvas, QKeySequence::Cut);
+ QCOMPARE(textInput->text().length(), 0);
+ simulateKeys(&canvas, QKeySequence::Paste);
+ QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textInput->text().length(), 24);
+
+ // clear copy buffer
+ QClipboard *clipboard = QGuiApplication::clipboard();
+ QVERIFY(clipboard);
+ clipboard->clear();
+ QVERIFY(!textInput->canPaste());
+
+ // test that copy functionality is disabled
+ // when echo mode is set to hide text/password mode
+ int index = 0;
+ while (index < 4) {
+ QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
+ textInput->setEchoMode(echoMode);
+ textInput->setText("My password");
+ textInput->select(0, textInput->text().length());;
+ simulateKeys(&canvas, QKeySequence::Copy);
+ if (echoMode == QQuickTextInput::Normal) {
+ QVERIFY(!clipboard->text().isEmpty());
+ QCOMPARE(clipboard->text(), QString("My password"));
+ clipboard->clear();
+ } else {
+ QVERIFY(clipboard->text().isEmpty());
+ }
+ index++;
+ }
+
+ delete textInput;
+#endif
+}
+
+void tst_qquicktextinput::canPasteEmpty() {
+#ifndef QT_NO_CLIPBOARD
+
+ QGuiApplication::clipboard()->clear();
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
+ QCOMPARE(textInput->canPaste(), cp);
+
+#endif
+}
+
+void tst_qquicktextinput::canPaste() {
+#ifndef QT_NO_CLIPBOARD
+
+ QGuiApplication::clipboard()->setText("Some text");
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
+ QCOMPARE(textInput->canPaste(), cp);
+
+#endif
+}
+
+void tst_qquicktextinput::passwordCharacter()
+{
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ textInput->setPasswordCharacter("X");
+ qreal implicitWidth = textInput->implicitWidth();
+ textInput->setPasswordCharacter(".");
+
+ // QTBUG-12383 content is updated and redrawn
+ QVERIFY(textInput->implicitWidth() < implicitWidth);
+
+ delete textInput;
+}
+
+void tst_qquicktextinput::cursorDelegate_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::newRow("out of line") << testFileUrl("cursorTest.qml");
+ QTest::newRow("in line") << testFileUrl("cursorTestInline.qml");
+ QTest::newRow("external") << testFileUrl("cursorTestExternal.qml");
+}
+
+void tst_qquicktextinput::cursorDelegate()
+{
+ QFETCH(QUrl, source);
+ QQuickView view(source);
+ view.show();
+ view.requestActivateWindow();
+ QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject");
+ QVERIFY(textInputObject != 0);
+ QVERIFY(textInputObject->findChild<QQuickItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textInputObject->setFocus(true);
+ QQuickItem* delegateObject = textInputObject->findChild<QQuickItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
+ //Test Delegate gets moved
+ for (int i=0; i<= textInputObject->text().length(); i++) {
+ textInputObject->setCursorPosition(i);
+ QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
+ }
+ textInputObject->setCursorPosition(0);
+ QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
+ //Test Delegate gets deleted
+ textInputObject->setCursorDelegate(0);
+ QVERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
+}
+
+void tst_qquicktextinput::cursorVisible()
+{
+ QQuickView view(testFileUrl("cursorVisible.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextInput input;
+ input.componentComplete();
+ QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool)));
+
+ QCOMPARE(input.isCursorVisible(), false);
+
+ input.setCursorVisible(true);
+ QCOMPARE(input.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 1);
+
+ input.setCursorVisible(false);
+ QCOMPARE(input.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 2);
+
+ input.setFocus(true);
+ QCOMPARE(input.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 2);
+
+ input.setParentItem(view.rootObject());
+ QCOMPARE(input.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 3);
+
+ input.setFocus(false);
+ QCOMPARE(input.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 4);
+
+ input.setFocus(true);
+ QCOMPARE(input.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 5);
+
+ QQuickView alternateView;
+ alternateView.show();
+ alternateView.requestActivateWindow();
+ QTest::qWaitForWindowShown(&alternateView);
+
+ QCOMPARE(input.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 6);
+
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QCOMPARE(input.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 7);
+}
+
+void tst_qquicktextinput::cursorRectangle()
+{
+
+ QString text = "Hello World!";
+
+ QQuickTextInput input;
+ input.setText(text);
+ input.componentComplete();
+
+ QTextLayout layout(text);
+ layout.setFont(input.font());
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ input.setWidth(line.cursorToX(5, QTextLine::Leading));
+ input.setHeight(qCeil(line.height() * 3 / 2));
+
+ QRectF r;
+
+ // some tolerance for different fonts.
+#ifdef Q_OS_LINUX
+ const int error = 2;
+#else
+ const int error = 5;
+#endif
+
+ for (int i = 0; i <= 5; ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+
+ QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
+ QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ // Check the cursor rectangle remains within the input bounding rect when auto scrolling.
+ QVERIFY(r.left() < input.width() + error);
+ QVERIFY(r.right() >= input.width() - error);
+
+ for (int i = 6; i < text.length(); ++i) {
+ input.setCursorPosition(i);
+ QCOMPARE(r, input.cursorRectangle());
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ for (int i = text.length() - 2; i >= 0; --i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QCOMPARE(r.top(), 0.);
+ QVERIFY(r.right() >= 0);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ // Check position with word wrap.
+ input.setWrapMode(QQuickTextInput::WordWrap);
+ input.setAutoScroll(false);
+ for (int i = 0; i <= 5; ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+
+ QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
+ QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
+ QCOMPARE(r.top(), 0.);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ input.setCursorPosition(6);
+ r = input.cursorRectangle();
+ QCOMPARE(r.left(), 0.);
+ QVERIFY(r.top() > line.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(6), r);
+
+ for (int i = 7; i < text.length(); ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QVERIFY(r.top() > line.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ // Check vertical scrolling with word wrap.
+ input.setAutoScroll(true);
+ for (int i = 0; i <= 5; ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+
+ QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
+ QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
+ QCOMPARE(r.top(), 0.);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ input.setCursorPosition(6);
+ r = input.cursorRectangle();
+ QCOMPARE(r.left(), 0.);
+ QVERIFY(r.bottom() >= input.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(6), r);
+
+ for (int i = 7; i < text.length(); ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QVERIFY(r.bottom() >= input.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ for (int i = text.length() - 2; i >= 6; --i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QVERIFY(r.bottom() >= input.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ for (int i = 5; i >= 0; --i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QCOMPARE(r.top(), 0.);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
+ }
+
+ input.setText("Hi!");
+ input.setHAlign(QQuickTextInput::AlignRight);
+ r = input.cursorRectangle();
+ QVERIFY(r.left() < input.width() + error);
+ QVERIFY(r.right() >= input.width() - error);
+}
+
+void tst_qquicktextinput::readOnly()
+{
+ QQuickView canvas(testFileUrl("readOnly.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->isReadOnly() == true);
+ QString initial = input->text();
+ for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
+ simulateKey(&canvas, k);
+ simulateKey(&canvas, Qt::Key_Return);
+ simulateKey(&canvas, Qt::Key_Space);
+ simulateKey(&canvas, Qt::Key_Escape);
+ QCOMPARE(input->text(), initial);
+
+ input->setCursorPosition(3);
+ input->setReadOnly(false);
+ QCOMPARE(input->isReadOnly(), false);
+ QCOMPARE(input->cursorPosition(), input->text().length());
+}
+
+void tst_qquicktextinput::echoMode()
+{
+ QQuickView canvas(testFileUrl("echoMode.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+ QString initial = input->text();
+ Qt::InputMethodHints ref;
+ QCOMPARE(initial, QLatin1String("ABCDefgh"));
+ QCOMPARE(input->echoMode(), QQuickTextInput::Normal);
+ QCOMPARE(input->displayText(), input->text());
+ //Normal
+ ref &= ~Qt::ImhHiddenText;
+ ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ input->setEchoMode(QQuickTextInput::NoEcho);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String(""));
+ QCOMPARE(input->passwordCharacter(), QLatin1String("*"));
+ //NoEcho
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ input->setEchoMode(QQuickTextInput::Password);
+ //Password
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("********"));
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ // clearing input hints do not clear bits set by echo mode
+ input->setInputMethodHints(Qt::ImhNone);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ input->setPasswordCharacter(QChar('Q'));
+ QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
+ input->setEchoMode(QQuickTextInput::PasswordEchoOnEdit);
+ //PasswordEchoOnEdit
+ ref &= ~Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));
+ QTest::keyPress(&canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(input->text(), QLatin1String("a"));
+ QCOMPARE(input->displayText(), QLatin1String("a"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a"));
+ input->setFocus(false);
+ QVERIFY(input->hasActiveFocus() == false);
+ QCOMPARE(input->displayText(), QLatin1String("Q"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q"));
+ input->setFocus(true);
+ QVERIFY(input->hasActiveFocus());
+ QInputMethodEvent inputEvent;
+ inputEvent.setCommitString(initial);
+ QGuiApplication::sendEvent(input, &inputEvent);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), initial);
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);
+}
+
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+void tst_qquicktextinput::passwordEchoDelay()
+{
+ QQuickView canvas(testFileUrl("echoMode.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QChar fillChar = QLatin1Char('*');
+
+ input->setEchoMode(QQuickTextInput::Password);
+ QCOMPARE(input->displayText(), QString(8, fillChar));
+ input->setText(QString());
+ QCOMPARE(input->displayText(), QString());
+
+ QTest::keyPress(&canvas, '0');
+ QTest::keyPress(&canvas, '1');
+ QTest::keyPress(&canvas, '2');
+ QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2'));
+ QTest::keyPress(&canvas, '3');
+ QTest::keyPress(&canvas, '4');
+ QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QCOMPARE(input->displayText(), QString(4, fillChar));
+ QTest::keyPress(&canvas, '4');
+ QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY);
+ QTRY_COMPARE(input->displayText(), QString(5, fillChar));
+ QTest::keyPress(&canvas, '5');
+ QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5'));
+ input->setFocus(false);
+ QVERIFY(!input->hasFocus());
+ QCOMPARE(input->displayText(), QString(6, fillChar));
+ input->setFocus(true);
+ QTRY_VERIFY(input->hasFocus());
+ QCOMPARE(input->displayText(), QString(6, fillChar));
+ QTest::keyPress(&canvas, '6');
+ QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6'));
+
+ QInputMethodEvent ev;
+ ev.setCommitString(QLatin1String("7"));
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev);
+ QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+
+ input->setCursorPosition(3);
+ QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+ QTest::keyPress(&canvas, 'a');
+ QCOMPARE(input->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar));
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QCOMPARE(input->displayText(), QString(8, fillChar));
+}
+#endif
+
+
+void tst_qquicktextinput::simulateKey(QQuickView *view, int key)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, 0);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
+
+ QGuiApplication::sendEvent(view, &press);
+ QGuiApplication::sendEvent(view, &release);
+}
+
+
+void tst_qquicktextinput::openInputPanel()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("openInputPanel.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ // check default values
+ QVERIFY(input->focusOnPress());
+ QVERIFY(!input->hasActiveFocus());
+ QVERIFY(qApp->focusObject() != input);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should open on focus
+ QPoint centerPoint(view.width()/2, view.height()/2);
+ Qt::KeyboardModifiers noModifiers = 0;
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QVERIFY(input->hasActiveFocus());
+ QCOMPARE(qApp->focusObject(), input);
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+
+ // input panel should be re-opened when pressing already focused TextInput
+ qApp->inputMethod()->hide();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QVERIFY(input->hasActiveFocus());
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+
+ // input panel should stay visible if focus is lost to another text inputor
+ QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
+ QQuickTextInput anotherInput;
+ anotherInput.componentComplete();
+ anotherInput.setParentItem(view.rootObject());
+ anotherInput.setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherInput));
+ QCOMPARE(inputPanelVisibilitySpy.count(), 0);
+
+ anotherInput.setFocus(false);
+ QVERIFY(qApp->focusObject() != &anotherInput);
+ QCOMPARE(view.activeFocusItem(), view.rootItem());
+ anotherInput.setFocus(true);
+
+ qApp->inputMethod()->hide();
+
+ // input panel should not be opened if TextInput is read only
+ input->setReadOnly(true);
+ input->setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should not be opened if focusOnPress is set to false
+ input->setFocusOnPress(false);
+ input->setFocus(false);
+ input->setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should open when openSoftwareInputPanel is called
+ input->openSoftwareInputPanel();
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+
+ // input panel should close when closeSoftwareInputPanel is called
+ input->closeSoftwareInputPanel();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+}
+
+class MyTextInput : public QQuickTextInput
+{
+public:
+ MyTextInput(QQuickItem *parent = 0) : QQuickTextInput(parent)
+ {
+ nbPaint = 0;
+ }
+ virtual QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data)
+ {
+ nbPaint++;
+ return QQuickTextInput::updatePaintNode(node, data);
+ }
+ int nbPaint;
+};
+
+void tst_qquicktextinput::setHAlignClearCache()
+{
+ QQuickView view;
+ MyTextInput input;
+ input.setText("Hello world");
+ input.setParentItem(view.rootItem());
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+#ifdef Q_OS_MAC
+ QEXPECT_FAIL("", "QTBUG-23485", Abort);
+#endif
+ QTRY_COMPARE(input.nbPaint, 1);
+ input.setHAlign(QQuickTextInput::AlignRight);
+ //Changing the alignment should trigger a repaint
+ QTRY_COMPARE(input.nbPaint, 2);
+}
+
+void tst_qquicktextinput::focusOutClearSelection()
+{
+ QQuickView view;
+ QQuickTextInput input;
+ QQuickTextInput input2;
+ input.setText(QLatin1String("Hello world"));
+ input.setFocus(true);
+ input2.setParentItem(view.rootItem());
+ input.setParentItem(view.rootItem());
+ input.componentComplete();
+ input2.componentComplete();
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ input.select(2,5);
+ //The selection should work
+ QTRY_COMPARE(input.selectedText(), QLatin1String("llo"));
+ input2.setFocus(true);
+ QGuiApplication::processEvents();
+ //The input lost the focus selection should be cleared
+ QTRY_COMPARE(input.selectedText(), QLatin1String(""));
+}
+
+void tst_qquicktextinput::geometrySignals()
+{
+ QQmlComponent component(&engine, testFileUrl("geometrySignals.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("bindingWidth").toInt(), 400);
+ QCOMPARE(o->property("bindingHeight").toInt(), 500);
+ delete o;
+}
+
+void tst_qquicktextinput::contentSize()
+{
+ QString componentStr = "import QtQuick 2.0\nTextInput { width: 75; height: 16; font.pixelSize: 10 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickTextInput *textObject = qobject_cast<QQuickTextInput *>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+ textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ QCOMPARE(spy.count(), 1);
+
+ textObject->setWrapMode(QQuickTextInput::WordWrap);
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 2);
+
+ textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 3);
+}
+
+static void sendPreeditText(const QString &text, int cursor)
+{
+ QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.length(), QVariant()));
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &event);
+}
+
+void tst_qquicktextinput::preeditAutoScroll()
+{
+ QString preeditText = "califragisiticexpialidocious!";
+
+ QQuickView view(testFileUrl("preeditAutoScroll.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+ QVERIFY(input->hasActiveFocus());
+
+ input->setWidth(input->implicitWidth());
+
+ QSignalSpy cursorRectangleSpy(input, SIGNAL(cursorRectangleChanged()));
+ int cursorRectangleChanges = 0;
+
+ // test the text is scrolled so the preedit is visible.
+ sendPreeditText(preeditText.mid(0, 3), 1);
+ QVERIFY(evaluate<int>(input, QString("positionAt(0)")) != 0);
+ QVERIFY(input->cursorRectangle().left() < input->boundingRect().width());
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+
+ // test the text is scrolled back when the preedit is removed.
+ QInputMethodEvent imEvent;
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
+ QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+
+ QTextLayout layout(preeditText);
+ layout.setFont(input->font());
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ // test if the preedit is larger than the text input that the
+ // character preceding the cursor is still visible.
+ qreal x = input->positionToRectangle(0).x();
+ for (int i = 0; i < 3; ++i) {
+ sendPreeditText(preeditText, i + 1);
+ int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
+ QVERIFY(input->cursorRectangle().right() >= width - 3);
+ QVERIFY(input->positionToRectangle(0).x() < x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ x = input->positionToRectangle(0).x();
+ }
+ for (int i = 1; i >= 0; --i) {
+ sendPreeditText(preeditText, i + 1);
+ int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
+ QVERIFY(input->cursorRectangle().right() >= width - 3);
+ QVERIFY(input->positionToRectangle(0).x() > x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ x = input->positionToRectangle(0).x();
+ }
+
+ // Test incrementing the preedit cursor doesn't cause further
+ // scrolling when right most text is visible.
+ sendPreeditText(preeditText, preeditText.length() - 3);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ x = input->positionToRectangle(0).x();
+ for (int i = 2; i >= 0; --i) {
+ sendPreeditText(preeditText, preeditText.length() - i);
+ QCOMPARE(input->positionToRectangle(0).x(), x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ }
+ for (int i = 1; i < 3; ++i) {
+ sendPreeditText(preeditText, preeditText.length() - i);
+ QCOMPARE(input->positionToRectangle(0).x(), x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ }
+
+ // Test disabling auto scroll.
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+
+ input->setAutoScroll(false);
+ sendPreeditText(preeditText.mid(0, 3), 1);
+ QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
+ QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
+}
+
+void tst_qquicktextinput::preeditCursorRectangle()
+{
+ QString preeditText = "super";
+
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ QRect currentRect;
+
+ QInputMethodQueryEvent query(Qt::ImCursorRectangle);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
+
+ // Verify that the micro focus rect is positioned the same for position 0 as
+ // it would be if there was no preedit text.
+ sendPreeditText(preeditText, 0);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QCOMPARE(currentRect, previousRect);
+
+ QSignalSpy inputSpy(input, SIGNAL(cursorRectangleChanged()));
+ QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
+
+ // Verify that the micro focus rect moves to the left as the cursor position
+ // is incremented.
+ for (int i = 1; i <= 5; ++i) {
+ sendPreeditText(preeditText, i);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QVERIFY(previousRect.left() < currentRect.left());
+ QVERIFY(inputSpy.count() > 0); inputSpy.clear();
+ QVERIFY(panelSpy.count() > 0); panelSpy.clear();
+ previousRect = currentRect;
+ }
+
+ // Verify that if there is no preedit cursor then the micro focus rect is the
+ // same as it would be if it were positioned at the end of the preedit text.
+ sendPreeditText(preeditText, 0);
+ QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QCOMPARE(currentRect, previousRect);
+ QVERIFY(inputSpy.count() > 0);
+ QVERIFY(panelSpy.count() > 0);
+}
+
+void tst_qquicktextinput::inputContextMouseHandler()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QString text = "supercalifragisiticexpialidocious!";
+ QQuickView view(testFileUrl("inputContext.qml"));
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ input->setFocus(true);
+ input->setText("");
+
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QTextLayout layout(text);
+ layout.setFont(input->font());
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ const qreal x = line.cursorToX(2, QTextLine::Leading);
+ const qreal y = line.height() / 2;
+ QPoint position = QPointF(x, y).toPoint();
+
+ QInputMethodEvent inputEvent(text.mid(0, 5), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(input, &inputEvent);
+
+ QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, position);
+ QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, position);
+ QGuiApplication::processEvents();
+
+ QCOMPARE(platformInputContext.m_action, QInputMethod::Click);
+ QCOMPARE(platformInputContext.m_invokeActionCallCount, 1);
+ QCOMPARE(platformInputContext.m_cursorPosition, 2);
+}
+
+void tst_qquicktextinput::inputMethodComposing()
+{
+ QString text = "supercalifragisiticexpialidocious!";
+
+ QQuickView view(testFileUrl("inputContext.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+ QSignalSpy spy(input, SIGNAL(inputMethodComposingChanged()));
+
+ QCOMPARE(input->isInputMethodComposing(), false);
+ {
+ QInputMethodEvent event(text.mid(3), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(input, &event);
+ }
+ QCOMPARE(input->isInputMethodComposing(), true);
+ QCOMPARE(spy.count(), 1);
+
+ {
+ QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(input, &event);
+ }
+ QCOMPARE(spy.count(), 1);
+
+ {
+ QInputMethodEvent event;
+ QGuiApplication::sendEvent(input, &event);
+ }
+ QCOMPARE(input->isInputMethodComposing(), false);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextinput::inputMethodUpdate()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("inputContext.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ // text change even without cursor position change needs to trigger update
+ input->setText("test");
+ platformInputContext.clear();
+ input->setText("xxxx");
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method event replacing text
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y", -1, 1);
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method changing selection
+ platformInputContext.clear();
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
+ QInputMethodEvent inputMethodEvent("", attributes);
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // programmatical selections trigger update
+ platformInputContext.clear();
+ input->selectAll();
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // font changes
+ platformInputContext.clear();
+ QFont font = input->font();
+ font.setBold(!font.bold());
+ input->setFont(font);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // normal input
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y");
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // changing cursor position
+ platformInputContext.clear();
+ input->setCursorPosition(0);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // read only disabled input method
+ platformInputContext.clear();
+ input->setReadOnly(true);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+ input->setReadOnly(false);
+
+ // no updates while no focus
+ input->setFocus(false);
+ platformInputContext.clear();
+ input->setText("Foo");
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ input->setCursorPosition(1);
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ input->selectAll();
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ input->setReadOnly(true);
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+}
+
+void tst_qquicktextinput::cursorRectangleSize()
+{
+ QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
+ QVERIFY(canvas->rootObject() != 0);
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput *>(canvas->rootObject());
+
+ // make sure cursor rectangle is not at (0,0)
+ textInput->setX(10);
+ textInput->setY(10);
+ textInput->setCursorPosition(3);
+ QVERIFY(textInput != 0);
+ textInput->setFocus(true);
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(qApp->focusObject());
+
+ QInputMethodQueryEvent event(Qt::ImCursorRectangle);
+ qApp->sendEvent(qApp->focusObject(), &event);
+ QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
+
+ QRectF cursorRectFromItem = textInput->cursorRectangle();
+ QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition());
+
+ // item and input query cursor rectangles match
+ QCOMPARE(cursorRectFromItem, cursorRectFromQuery);
+
+ // item cursor rectangle and positionToRectangle calculations match
+ QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle);
+
+ // item-canvas transform and input item transform match
+ QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
+
+ // input panel cursorRectangle property and tranformed item cursor rectangle match
+ QRectF sceneCursorRect = QQuickItemPrivate::get(textInput)->itemToCanvasTransform().mapRect(cursorRectFromItem);
+ QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
+
+ delete canvas;
+}
+
+void tst_qquicktextinput::tripleClickSelectsAll()
+{
+ QString qmlfile = testFile("positionAt.qml");
+ QQuickView view(QUrl::fromLocalFile(qmlfile));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextInput* input = qobject_cast<QQuickTextInput*>(view.rootObject());
+ QVERIFY(input);
+
+ QLatin1String hello("Hello world!");
+ input->setSelectByMouse(true);
+ input->setText(hello);
+
+ // Clicking on the same point inside TextInput three times in a row
+ // should trigger a triple click, thus selecting all the text.
+ QPoint pointInside = input->pos().toPoint() + QPoint(2,2);
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QCOMPARE(input->selectedText(), hello);
+
+ // Now it simulates user moving the mouse between the second and the third click.
+ // In this situation, we don't expect a triple click.
+ QPoint pointInsideButFar = QPoint(input->width(),input->height()) - QPoint(2,2);
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInsideButFar);
+ QGuiApplication::processEvents();
+ QVERIFY(input->selectedText().isEmpty());
+
+ // And now we press the third click too late, so no triple click event is triggered.
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 1);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QVERIFY(input->selectedText().isEmpty());
+}
+
+void tst_qquicktextinput::QTBUG_19956_data()
+{
+ QTest::addColumn<QString>("url");
+ QTest::newRow("intvalidator") << "qtbug-19956int.qml";
+ QTest::newRow("doublevalidator") << "qtbug-19956double.qml";
+}
+
+
+void tst_qquicktextinput::getText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("inputMask");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("end");
+ QTest::addColumn<QString>("expectedText");
+
+ QTest::newRow("all plain text")
+ << standard.at(0)
+ << QString()
+ << 0 << standard.at(0).length()
+ << standard.at(0);
+
+ QTest::newRow("plain text sub string")
+ << standard.at(0)
+ << QString()
+ << 0 << 12
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text sub string reversed")
+ << standard.at(0)
+ << QString()
+ << 12 << 0
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text cropped beginning")
+ << standard.at(0)
+ << QString()
+ << -3 << 4
+ << standard.at(0).mid(0, 4);
+
+ QTest::newRow("plain text cropped end")
+ << standard.at(0)
+ << QString()
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(23);
+
+ QTest::newRow("plain text cropped beginning and end")
+ << standard.at(0)
+ << QString()
+ << -9 << standard.at(0).length() + 4
+ << standard.at(0);
+}
+
+void tst_qquicktextinput::getText()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, inputMask);
+ QFETCH(int, start);
+ QFETCH(int, end);
+ QFETCH(QString, expectedText);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QCOMPARE(textInput->getText(start, end), expectedText);
+}
+
+void tst_qquicktextinput::insert_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("inputMask");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("insertPosition");
+ QTest::addColumn<QString>("insertText");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedSelectionStart");
+ QTest::addColumn<int>("expectedSelectionEnd");
+ QTest::addColumn<int>("expectedCursorPosition");
+ QTest::addColumn<bool>("selectionChanged");
+ QTest::addColumn<bool>("cursorPositionChanged");
+
+ QTest::newRow("at cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 5 << 5 << 5
+ << false << true;
+
+ QTest::newRow("at cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << false << true;
+
+ QTest::newRow("at cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 23 << 23 << 23
+ << false << true;
+
+ QTest::newRow("after cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("before cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length() << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << false << true;
+
+ QTest::newRow("before cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 23 << 23 << 23
+ << false << true;
+
+ QTest::newRow("after cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("before selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 19 << 24 << 24
+ << false << true;
+
+ QTest::newRow("before reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 19 << 24 << 19
+ << false << true;
+
+ QTest::newRow("after selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 14 << 19 << 19
+ << false << false;
+
+ QTest::newRow("after reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 14 << 19 << 14
+ << false << false;
+
+ QTest::newRow("into selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 14 << 24 << 24
+ << true << true;
+
+ QTest::newRow("into reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 14 << 24 << 14
+ << true << false;
+
+ QTest::newRow("rich text into plain text")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << 0
+ << QString("<b>Hello</b>")
+ << QString("<b>Hello</b>") + standard.at(0)
+ << 12 << 12 << 12
+ << false << true;
+
+ QTest::newRow("before start")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << -3
+ << QString("Hello")
+ << standard.at(0)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("past end")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << standard.at(0).length() + 3
+ << QString("Hello")
+ << standard.at(0)
+ << 0 << 0 << 0
+ << false << false;
+
+ const QString inputMask = "009.009.009.009";
+ const QString ip = "192.168.2.14";
+
+ QTest::newRow("mask: at cursor position (beginning)")
+ << ip
+ << inputMask
+ << 0 << 0 << 0
+ << QString("125")
+ << QString("125.168.2.14")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: at cursor position (end)")
+ << ip
+ << inputMask
+ << inputMask.length() << inputMask.length() << inputMask.length()
+ << QString("8")
+ << ip
+ << inputMask.length() << inputMask.length() << inputMask.length()
+ << false << false;
+
+ QTest::newRow("mask: at cursor position (middle)")
+ << ip
+ << inputMask
+ << 6 << 6 << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: after cursor position (beginning)")
+ << ip
+ << inputMask
+ << 0 << 0 << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: before cursor position (end)")
+ << ip
+ << inputMask
+ << inputMask.length() << inputMask.length() << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << inputMask.length() << inputMask.length() << inputMask.length()
+ << false << false;
+
+ QTest::newRow("mask: before cursor position (middle)")
+ << ip
+ << inputMask
+ << 6 << 6 << 0
+ << QString("125")
+ << QString("125.168.2.14")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: after cursor position (middle)")
+ << ip
+ << inputMask
+ << 6 << 6 << 13
+ << QString("8")
+ << "192.168.2.18"
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: before selection")
+ << ip
+ << inputMask
+ << 6 << 8 << 0
+ << QString("125")
+ << QString("125.168.2.14")
+ << 6 << 8 << 8
+ << false << false;
+
+ QTest::newRow("mask: before reversed selection")
+ << ip
+ << inputMask
+ << 8 << 6 << 0
+ << QString("125")
+ << QString("125.168.2.14")
+ << 6 << 8 << 6
+ << false << false;
+
+ QTest::newRow("mask: after selection")
+ << ip
+ << inputMask
+ << 6 << 8 << 13
+ << QString("8")
+ << "192.168.2.18"
+ << 6 << 8 << 8
+ << false << false;
+
+ QTest::newRow("mask: after reversed selection")
+ << ip
+ << inputMask
+ << 8 << 6 << 13
+ << QString("8")
+ << "192.168.2.18"
+ << 6 << 8 << 6
+ << false << false;
+
+ QTest::newRow("mask: into selection")
+ << ip
+ << inputMask
+ << 5 << 8 << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << 5 << 8 << 8
+ << true << false;
+
+ QTest::newRow("mask: into reversed selection")
+ << ip
+ << inputMask
+ << 8 << 5 << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << 5 << 8 << 5
+ << true << false;
+
+ QTest::newRow("mask: before start")
+ << ip
+ << inputMask
+ << 0 << 0 << -3
+ << QString("4")
+ << ip
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: past end")
+ << ip
+ << inputMask
+ << 0 << 0 << ip.length() + 3
+ << QString("4")
+ << ip
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: invalid characters")
+ << ip
+ << inputMask
+ << 0 << 0 << 0
+ << QString("abc")
+ << QString("192.168.2.14")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: mixed validity")
+ << ip
+ << inputMask
+ << 0 << 0 << 0
+ << QString("a1b2c5")
+ << QString("125.168.2.14")
+ << 0 << 0 << 0
+ << false << false;
+}
+
+void tst_qquicktextinput::insert()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, inputMask);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, insertPosition);
+ QFETCH(QString, insertText);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedSelectionStart);
+ QFETCH(int, expectedSelectionEnd);
+ QFETCH(int, expectedCursorPosition);
+ QFETCH(bool, selectionChanged);
+ QFETCH(bool, cursorPositionChanged);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ textInput->select(selectionStart, selectionEnd);
+
+ QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged()));
+ QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged()));
+ QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged()));
+ QSignalSpy textSpy(textInput, SIGNAL(textChanged()));
+ QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged()));
+
+ textInput->insert(insertPosition, insertText);
+
+ QCOMPARE(textInput->text(), expectedText);
+ QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
+
+ QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
+ QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
+ QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
+
+ if (selectionStart > selectionEnd)
+ qSwap(selectionStart, selectionEnd);
+
+ QCOMPARE(selectionSpy.count() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.count() > 0, text != expectedText);
+ QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
+}
+
+void tst_qquicktextinput::remove_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("inputMask");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("removeStart");
+ QTest::addColumn<int>("removeEnd");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedSelectionStart");
+ QTest::addColumn<int>("expectedSelectionEnd");
+ QTest::addColumn<int>("expectedCursorPosition");
+ QTest::addColumn<bool>("selectionChanged");
+ QTest::addColumn<bool>("cursorPositionChanged");
+
+ QTest::newRow("from cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("to cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << 5 << 0
+ << standard.at(0).mid(5)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("to cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).length() << standard.at(0).length() - 5
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("to cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("from cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("to cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 23 << 23
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << true;
+
+ QTest::newRow("after cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("before cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length()
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("before cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 23 << 23
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 18 << 18 << 18
+ << false << true;
+
+ QTest::newRow("after cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("before selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 9 << 14 << 14
+ << false << true;
+
+ QTest::newRow("before reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 9 << 14 << 9
+ << false << true;
+
+ QTest::newRow("after selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << 14 << 19 << 19
+ << false << false;
+
+ QTest::newRow("after reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << 14 << 19 << 14
+ << false << false;
+
+ QTest::newRow("from selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 24
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 14 << 19 << 19
+ << true << true;
+
+ QTest::newRow("from reversed selection")
+ << standard.at(0)
+ << QString()
+ << 24 << 14
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 14 << 19 << 14
+ << true << false;
+
+ QTest::newRow("cropped beginning")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << -3 << 4
+ << standard.at(0).mid(4)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("cropped end")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(0, 23)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("cropped beginning and end")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << -9 << standard.at(0).length() + 4
+ << QString()
+ << 0 << 0 << 0
+ << false << false;
+
+ const QString inputMask = "009.009.009.009";
+ const QString ip = "192.168.2.14";
+
+ QTest::newRow("mask: from cursor position")
+ << ip
+ << inputMask
+ << 6 << 6
+ << 6 << 9
+ << QString("192.16..14")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: to cursor position")
+ << ip
+ << inputMask
+ << 6 << 6
+ << 2 << 6
+ << QString("19.8.2.14")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: before cursor position")
+ << ip
+ << inputMask
+ << 6 << 6
+ << 0 << 2
+ << QString("2.168.2.14")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: after cursor position")
+ << ip
+ << inputMask
+ << 6 << 6
+ << 12 << 16
+ << QString("192.168.2.")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: before selection")
+ << ip
+ << inputMask
+ << 6 << 8
+ << 0 << 2
+ << QString("2.168.2.14")
+ << 6 << 8 << 8
+ << false << false;
+
+ QTest::newRow("mask: before reversed selection")
+ << ip
+ << inputMask
+ << 8 << 6
+ << 0 << 2
+ << QString("2.168.2.14")
+ << 6 << 8 << 6
+ << false << false;
+
+ QTest::newRow("mask: after selection")
+ << ip
+ << inputMask
+ << 6 << 8
+ << 12 << 16
+ << QString("192.168.2.")
+ << 6 << 8 << 8
+ << false << false;
+
+ QTest::newRow("mask: after reversed selection")
+ << ip
+ << inputMask
+ << 8 << 6
+ << 12 << 16
+ << QString("192.168.2.")
+ << 6 << 8 << 6
+ << false << false;
+
+ QTest::newRow("mask: from selection")
+ << ip
+ << inputMask
+ << 6 << 13
+ << 8 << 10
+ << QString("192.168..14")
+ << 6 << 13 << 13
+ << true << false;
+
+ QTest::newRow("mask: from reversed selection")
+ << ip
+ << inputMask
+ << 13 << 6
+ << 8 << 10
+ << QString("192.168..14")
+ << 6 << 13 << 6
+ << true << false;
+
+ QTest::newRow("mask: cropped beginning")
+ << ip
+ << inputMask
+ << 0 << 0
+ << -3 << 4
+ << QString(".168.2.14")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: cropped end")
+ << ip
+ << inputMask
+ << 0 << 0
+ << 13 << 28
+ << QString("192.168.2.1")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: cropped beginning and end")
+ << ip
+ << inputMask
+ << 0 << 0
+ << -9 << 28
+ << QString("...")
+ << 0 << 0 << 0
+ << false << false;
+}
+
+void tst_qquicktextinput::remove()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, inputMask);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, removeStart);
+ QFETCH(int, removeEnd);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedSelectionStart);
+ QFETCH(int, expectedSelectionEnd);
+ QFETCH(int, expectedCursorPosition);
+ QFETCH(bool, selectionChanged);
+ QFETCH(bool, cursorPositionChanged);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ textInput->select(selectionStart, selectionEnd);
+
+ QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged()));
+ QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged()));
+ QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged()));
+ QSignalSpy textSpy(textInput, SIGNAL(textChanged()));
+ QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged()));
+
+ textInput->remove(removeStart, removeEnd);
+
+ QCOMPARE(textInput->text(), expectedText);
+ QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
+
+ if (selectionStart > selectionEnd) //
+ qSwap(selectionStart, selectionEnd);
+
+ QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
+ QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
+ QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
+
+ QCOMPARE(selectionSpy.count() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.count() > 0, text != expectedText);
+
+ if (cursorPositionChanged) //
+ QVERIFY(cursorPositionSpy.count() > 0);
+}
+
+void tst_qquicktextinput::keySequence_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QKeySequence>("sequence");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QString>("selectedText");
+
+ // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
+
+ QTest::newRow("select all")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
+ << 44 << standard.at(0) << standard.at(0);
+ QTest::newRow("select end of line")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
+ << 44 << standard.at(0) << standard.at(0).mid(5);
+ QTest::newRow("select end of document") // ### Not handled.
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
+ << 3 << standard.at(0) << QString();
+ QTest::newRow("select end of block")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
+ << 44 << standard.at(0) << standard.at(0).mid(18);
+ QTest::newRow("delete end of line")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
+ << 24 << standard.at(0).mid(0, 24) << QString();
+ QTest::newRow("move to start of line")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
+ << 0 << standard.at(0) << QString();
+ QTest::newRow("move to start of block")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
+ << 0 << standard.at(0) << QString();
+ QTest::newRow("move to next char")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
+ << 13 << standard.at(0) << QString();
+ QTest::newRow("move to previous char")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
+ << 2 << standard.at(0) << QString();
+ QTest::newRow("select next char")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
+ << 24 << standard.at(0) << standard.at(0).mid(23, 1);
+ QTest::newRow("select previous char")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
+ << 18 << standard.at(0) << standard.at(0).mid(18, 1);
+ QTest::newRow("move to next word")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
+ << 10 << standard.at(0) << QString();
+ QTest::newRow("move to previous word")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
+ << 4 << standard.at(0) << QString();
+ QTest::newRow("select previous word")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
+ << 10 << standard.at(0) << standard.at(0).mid(10, 1);
+ QTest::newRow("delete (selection)")
+ << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
+ << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
+ QTest::newRow("delete (no selection)")
+ << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
+ << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
+ QTest::newRow("delete end of word")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
+ << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
+ QTest::newRow("delete start of word")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
+ << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
+}
+
+void tst_qquicktextinput::keySequence()
+{
+ QFETCH(QString, text);
+ QFETCH(QKeySequence, sequence);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, cursorPosition);
+ QFETCH(QString, expectedText);
+ QFETCH(QString, selectedText);
+
+ if (sequence.isEmpty()) {
+ QSKIP("Key sequence is undefined");
+ }
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { focus: true; text: \"" + text + "\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ textInput->select(selectionStart, selectionEnd);
+
+ simulateKeys(&canvas, sequence);
+
+ QCOMPARE(textInput->cursorPosition(), cursorPosition);
+ QCOMPARE(textInput->text(), expectedText);
+ QCOMPARE(textInput->selectedText(), selectedText);
+}
+
+#define NORMAL 0
+#define REPLACE_UNTIL_END 1
+
+void tst_qquicktextinput::undo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<IntList>("insertMode");
+ QTest::addColumn<QStringList>("expectedString");
+ QTest::addColumn<bool>("use_keys");
+
+ for (int i=0; i<2; i++) {
+ QString keys_str = "keyboard";
+ bool use_keys = true;
+ if (i==0) {
+ keys_str = "insert";
+ use_keys = false;
+ }
+
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "1";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "5";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "3";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "2";
+
+ insertIndex << 3;
+ insertMode << NORMAL;
+ insertString << "4";
+
+ expectedString << "12345";
+ expectedString << "1235";
+ expectedString << "135";
+ expectedString << "15";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "World"; // World
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Hello"; // HelloWorld
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Well"; // WellHelloWorld
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "WellHelloThereWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "HelloWorld";
+ expectedString << "World";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "Ensuring";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << " instan";
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "an ";
+
+ insertIndex << 10;
+ insertMode << REPLACE_UNTIL_END;
+ insertString << " unique instance.";
+
+ expectedString << "Ensuring a unique instance.";
+ expectedString << "Ensuring an instan";
+ expectedString << "Ensuring instan";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ }
+}
+
+void tst_qquicktextinput::undo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(IntList, insertMode);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ QVERIFY(!textInput->canUndo());
+
+ QSignalSpy spy(textInput, SIGNAL(canUndoChanged()));
+
+ int i;
+
+// STEP 1: First build up an undo history by inserting or typing some strings...
+ for (i = 0; i < insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ textInput->setCursorPosition(insertIndex[i]);
+
+ // experimental stuff
+ if (insertMode[i] == REPLACE_UNTIL_END) {
+ textInput->select(insertIndex[i], insertIndex[i] + 8);
+
+ // This is what I actually want...
+ // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
+ }
+
+ for (int j = 0; j < insertString.at(i).length(); j++)
+ QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+// STEP 2: Next call undo several times and see if we can restore to the previous state
+ for (i = 0; i < expectedString.size() - 1; ++i) {
+ QCOMPARE(textInput->text(), expectedString[i]);
+ QVERIFY(textInput->canUndo());
+ textInput->undo();
+ }
+
+// STEP 3: Verify that we have undone everything
+ QVERIFY(textInput->text().isEmpty());
+ QVERIFY(!textInput->canUndo());
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextinput::redo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ IntList insertIndex;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertString << "World"; // World
+ insertIndex << 0;
+ insertString << "Hello"; // HelloWorld
+ insertIndex << 0;
+ insertString << "Well"; // WellHelloWorld
+ insertIndex << 9;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "World";
+ expectedString << "HelloWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "WellHelloThereWorld";
+
+ QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
+ }
+}
+
+void tst_qquicktextinput::redo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ QVERIFY(!textInput->canUndo());
+ QVERIFY(!textInput->canRedo());
+
+ QSignalSpy spy(textInput, SIGNAL(canRedoChanged()));
+
+ int i;
+ // inserts the diff strings at diff positions
+ for (i = 0; i < insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ textInput->setCursorPosition(insertIndex[i]);
+ for (int j = 0; j < insertString.at(i).length(); j++)
+ QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
+ QVERIFY(textInput->canUndo());
+ QVERIFY(!textInput->canRedo());
+ }
+
+ QCOMPARE(spy.count(), 0);
+
+ // undo everything
+ while (!textInput->text().isEmpty()) {
+ QVERIFY(textInput->canUndo());
+ textInput->undo();
+ QVERIFY(textInput->canRedo());
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+ for (i = 0; i < expectedString.size(); ++i) {
+ QVERIFY(textInput->canRedo());
+ textInput->redo();
+ QCOMPARE(textInput->text() , expectedString[i]);
+ QVERIFY(textInput->canUndo());
+ }
+ QVERIFY(!textInput->canRedo());
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextinput::undo_keypressevents_data()
+{
+ QTest::addColumn<KeyList>("keys");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ KeyList keys;
+ QStringList expectedString;
+
+ keys << "AFRAID"
+ << QKeySequence::MoveToStartOfLine
+ << "VERY"
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << "BE"
+ << QKeySequence::MoveToEndOfLine
+ << "!";
+
+ expectedString << "BEVERYAFRAID!";
+ expectedString << "BEVERYAFRAID";
+ expectedString << "VERYAFRAID";
+ expectedString << "AFRAID";
+
+ QTest::newRow("Inserts and moving cursor") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '1234'
+ keys << "1234" << QKeySequence::MoveToStartOfLine
+ // skipping '12'
+ << Qt::Key_Right << Qt::Key_Right
+ // selecting '34'
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ // deleting '34'
+ << Qt::Key_Delete;
+
+ expectedString << "12";
+ expectedString << "1234";
+
+ QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'AB12'
+ keys << "AB12"
+ << QKeySequence::MoveToStartOfLine
+ // selecting 'AB'
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ << Qt::Key_Delete
+ << QKeySequence::Undo
+ << Qt::Key_Right
+#ifdef Q_OS_WIN //Mac(?) has a specialcase to handle jumping to the end of a selection
+ << Qt::Key_Left
+#endif
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ << Qt::Key_Delete;
+
+ expectedString << "AB";
+ expectedString << "AB12";
+
+ QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'ABCD'
+ keys << "abcd"
+ //move left two
+ << Qt::Key_Left << Qt::Key_Left
+ // inserting '1234'
+ << "1234"
+ // selecting '1234'
+ << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
+ // overwriting '1234' with '5'
+ << "5"
+ // undoing deletion of 'AB'
+ << QKeySequence::Undo
+ // overwriting '1234' with '6'
+ << "6";
+
+ expectedString << "ab6cd";
+ // for versions previous to 3.2 we overwrite needed two undo operations
+ expectedString << "ab1234cd";
+ expectedString << "abcd";
+
+ QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'ABC'
+ keys << "ABC"
+ // removes 'C'
+ << Qt::Key_Backspace;
+
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ keys << "ABC"
+ // removes 'C'
+ << Qt::Key_Backspace
+ // inserting 'Z'
+ << "Z";
+
+ expectedString << "ABZ";
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '123'
+ keys << "123" << QKeySequence::MoveToStartOfLine
+ // selecting '123'
+ << QKeySequence::SelectEndOfLine
+ // overwriting '123' with 'ABC'
+ << "ABC";
+
+ expectedString << "ABC";
+ // for versions previous to 3.2 we overwrite needed two undo operations
+ expectedString << "123";
+
+ QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
+ }
+}
+
+void tst_qquicktextinput::undo_keypressevents()
+{
+ QFETCH(KeyList, keys);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ simulateKeys(&canvas, keys);
+
+ for (int i = 0; i < expectedString.size(); ++i) {
+ QCOMPARE(textInput->text() , expectedString[i]);
+ textInput->undo();
+ }
+ QVERIFY(textInput->text().isEmpty());
+}
+
+void tst_qquicktextinput::QTBUG_19956()
+{
+ QFETCH(QString, url);
+
+ QQuickView canvas(testFileUrl(url));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *input = qobject_cast<QQuickTextInput*>(canvas.rootObject());
+ QVERIFY(input);
+ input->setFocus(true);
+ QVERIFY(input->hasActiveFocus());
+
+ QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 30);
+ QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10);
+ QCOMPARE(canvas.rootObject()->property("text").toString(), QString("20"));
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("topvalue", 15);
+ QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 15);
+ QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("topvalue", 25);
+ QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 25);
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("bottomvalue", 21);
+ QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 21);
+ QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("bottomvalue", 10);
+ QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10);
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+}
+
+void tst_qquicktextinput::QTBUG_19956_regexp()
+{
+ QUrl url = testFileUrl("qtbug-19956regexp.qml");
+
+ QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QQuickView canvas(url);
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *input = qobject_cast<QQuickTextInput*>(canvas.rootObject());
+ QVERIFY(input);
+ input->setFocus(true);
+ QVERIFY(input->hasActiveFocus());
+
+ canvas.rootObject()->setProperty("regexvalue", QRegExp("abc"));
+ QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc"));
+ QCOMPARE(canvas.rootObject()->property("text").toString(), QString("abc"));
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("regexvalue", QRegExp("abcd"));
+ QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abcd"));
+ QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("regexvalue", QRegExp("abc"));
+ QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc"));
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+}
+
+
+void tst_qquicktextinput::negativeDimensions()
+{
+ // Verify this doesn't assert during initialization.
+ QQmlComponent component(&engine, testFileUrl("negativeDimensions.qml"));
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(o);
+ QQuickTextInput *input = o->findChild<QQuickTextInput *>("input");
+ QVERIFY(input);
+ QCOMPARE(input->width(), qreal(-1));
+ QCOMPARE(input->height(), qreal(-1));
+}
+
+QTEST_MAIN(tst_qquicktextinput)
+
+#include "tst_qquicktextinput.moc"
diff --git a/tests/auto/quick/qquicktimer/qquicktimer.pro b/tests/auto/quick/qquicktimer/qquicktimer.pro
new file mode 100644
index 0000000000..7b399c778d
--- /dev/null
+++ b/tests/auto/quick/qquicktimer/qquicktimer.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qquicktimer
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktimer.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private gui testlib
diff --git a/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp b/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp
new file mode 100644
index 0000000000..ff33609c06
--- /dev/null
+++ b/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp
@@ -0,0 +1,393 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QSignalSpy>
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicktimer_p.h>
+#include <QtQuick/qquickitem.h>
+#include <QDebug>
+
+class tst_qquicktimer : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qquicktimer();
+
+private slots:
+ void notRepeating();
+ void notRepeatingStart();
+ void repeat();
+ void noTriggerIfNotRunning();
+ void triggeredOnStart();
+ void triggeredOnStartRepeat();
+ void changeDuration();
+ void restart();
+ void restartFromTriggered();
+ void runningFromTriggered();
+ void parentProperty();
+};
+
+class TimerHelper : public QObject
+{
+ Q_OBJECT
+public:
+ TimerHelper() : QObject(), count(0)
+ {
+ }
+
+ int count;
+
+public slots:
+ void timeout() {
+ ++count;
+ }
+};
+
+#define TIMEOUT_TIMEOUT 200
+
+tst_qquicktimer::tst_qquicktimer()
+{
+}
+
+void tst_qquicktimer::notRepeating()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(timer->isRunning());
+ QVERIFY(!timer->isRepeating());
+ QCOMPARE(timer->interval(), 100);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->isRunning() == false);
+}
+
+void tst_qquicktimer::notRepeatingStart()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100 }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(!timer->isRunning());
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 0);
+
+ timer->start();
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->isRunning() == false);
+
+ delete timer;
+}
+
+void tst_qquicktimer::repeat()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > 0);
+ int oldCount = helper.count;
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > oldCount);
+ QVERIFY(timer->isRunning());
+
+ oldCount = helper.count;
+ timer->stop();
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count == oldCount);
+ QVERIFY(timer->isRunning() == false);
+
+ QSignalSpy spy(timer, SIGNAL(repeatChanged()));
+
+ timer->setRepeating(false);
+ QVERIFY(!timer->isRepeating());
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(true);
+ QCOMPARE(spy.count(),2);
+
+ delete timer;
+}
+
+void tst_qquicktimer::triggeredOnStart()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(timer->triggeredOnStart());
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QTest::qWait(1);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 2);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->isRunning() == false);
+
+ QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged()));
+
+ timer->setTriggeredOnStart(false);
+ QVERIFY(!timer->triggeredOnStart());
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(true);
+ QCOMPARE(spy.count(),2);
+
+ delete timer;
+}
+
+void tst_qquicktimer::triggeredOnStartRepeat()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QTest::qWait(1);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > 1);
+ int oldCount = helper.count;
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > oldCount);
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+void tst_qquicktimer::noTriggerIfNotRunning()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ "Item { property bool ok: true\n"
+ "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }"
+ "Timer { interval: 10; running: true; onTriggered: t1.running=false }"
+ "}"
+ ), QUrl::fromLocalFile(""));
+ QObject *item = component.create();
+ QVERIFY(item != 0);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(item->property("ok").toBool(), true);
+
+ delete item;
+}
+
+void tst_qquicktimer::changeDuration()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 2);
+
+ timer->setInterval(500);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 3);
+ QVERIFY(timer->isRunning());
+
+ QSignalSpy spy(timer, SIGNAL(intervalChanged()));
+
+ timer->setInterval(200);
+ QCOMPARE(timer->interval(), 200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(300);
+ QCOMPARE(spy.count(),2);
+
+ delete timer;
+}
+
+void tst_qquicktimer::restart()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(300);
+
+ timer->restart();
+
+ QTest::qWait(700);
+
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+void tst_qquicktimer::restartFromTriggered()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { "
+ "interval: 500; "
+ "repeat: false; "
+ "running: true; "
+ "onTriggered: restart()"
+ " }"), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(component.create());
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(object.data());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->isRunning());
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->isRunning());
+}
+
+void tst_qquicktimer::runningFromTriggered()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { "
+ "property bool ok: false; "
+ "interval: 500; "
+ "repeat: false; "
+ "running: true; "
+ "onTriggered: { ok = !running; running = true }"
+ " }"), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(component.create());
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(object.data());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->property("ok").toBool());
+ QVERIFY(timer->isRunning());
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->property("ok").toBool());
+ QVERIFY(timer->isRunning());
+}
+
+void tst_qquicktimer::parentProperty()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item != 0);
+ QQuickTimer *timer = item->findChild<QQuickTimer*>("timer");
+ QVERIFY(timer != 0);
+
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+QTEST_MAIN(tst_qquicktimer)
+
+#include "tst_qquicktimer.moc"
diff --git a/tests/auto/qtquick2/qquickview/data/error1.qml b/tests/auto/quick/qquickview/data/error1.qml
index 09df679555..09df679555 100644
--- a/tests/auto/qtquick2/qquickview/data/error1.qml
+++ b/tests/auto/quick/qquickview/data/error1.qml
diff --git a/tests/auto/qtquick2/qquickview/data/resizemodeitem.qml b/tests/auto/quick/qquickview/data/resizemodeitem.qml
index ed73009b26..ed73009b26 100644
--- a/tests/auto/qtquick2/qquickview/data/resizemodeitem.qml
+++ b/tests/auto/quick/qquickview/data/resizemodeitem.qml
diff --git a/tests/auto/quick/qquickview/qquickview.pro b/tests/auto/quick/qquickview/qquickview.pro
new file mode 100644
index 0000000000..77b0f7d86a
--- /dev/null
+++ b/tests/auto/quick/qquickview/qquickview.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TARGET = tst_qquickview
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickview.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp
new file mode 100644
index 0000000000..e5e8a83424
--- /dev/null
+++ b/tests/auto/quick/qquickview/tst_qquickview.cpp
@@ -0,0 +1,207 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitem.h>
+#include "../../shared/util.h"
+#include <QtGui/QWindow>
+#include <QtCore/QDebug>
+
+class tst_QQuickView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickView();
+
+private slots:
+ void resizemodeitem();
+ void errors();
+};
+
+
+tst_QQuickView::tst_QQuickView()
+{
+}
+
+void tst_QQuickView::resizemodeitem()
+{
+ QWindow window;
+ window.setGeometry(0, 0, 400, 400);
+
+ QQuickView *canvas = new QQuickView(&window);
+ QVERIFY(canvas);
+ canvas->setResizeMode(QQuickView::SizeRootObjectToView);
+ QCOMPARE(QSize(0,0), canvas->initialSize());
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
+ QQuickItem* item = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(item);
+ window.show();
+
+ canvas->show();
+
+ // initial size from root object
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 200.0);
+ QCOMPARE(canvas->size(), QSize(200, 200));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(canvas->size(), canvas->initialSize());
+
+ // size update from view
+ canvas->resize(QSize(80,100));
+
+ QTRY_COMPARE(item->width(), 80.0);
+ QCOMPARE(item->height(), 100.0);
+ QCOMPARE(canvas->size(), QSize(80, 100));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+
+ canvas->setResizeMode(QQuickView::SizeViewToRootObject);
+
+ // size update from view disabled
+ canvas->resize(QSize(60,80));
+ QCOMPARE(item->width(), 80.0);
+ QCOMPARE(item->height(), 100.0);
+ QTest::qWait(50);
+ QCOMPARE(canvas->size(), QSize(60, 80));
+
+ // size update from root object
+ item->setWidth(250);
+ item->setHeight(350);
+ QCOMPARE(item->width(), 250.0);
+ QCOMPARE(item->height(), 350.0);
+ QTRY_COMPARE(canvas->size(), QSize(250, 350));
+ QCOMPARE(canvas->size(), QSize(250, 350));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+
+ // reset canvas
+ window.hide();
+ delete canvas;
+ canvas = new QQuickView(&window);
+ QVERIFY(canvas);
+ canvas->setResizeMode(QQuickView::SizeViewToRootObject);
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
+ item = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(item);
+ window.show();
+
+ canvas->show();
+
+ // initial size for root object
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 200.0);
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(canvas->size(), canvas->initialSize());
+
+ // size update from root object
+ item->setWidth(80);
+ item->setHeight(100);
+ QCOMPARE(item->width(), 80.0);
+ QCOMPARE(item->height(), 100.0);
+ QTRY_COMPARE(canvas->size(), QSize(80, 100));
+ QCOMPARE(canvas->size(), QSize(80, 100));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+
+ // size update from root object disabled
+ canvas->setResizeMode(QQuickView::SizeRootObjectToView);
+ item->setWidth(60);
+ item->setHeight(80);
+ QCOMPARE(canvas->width(), 80);
+ QCOMPARE(canvas->height(), 100);
+ QCOMPARE(QSize(item->width(), item->height()), canvas->sizeHint());
+
+ // size update from view
+ canvas->resize(QSize(200,300));
+ QTest::qWait(50);
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 300.0);
+ QCOMPARE(canvas->size(), QSize(200, 300));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+
+ window.hide();
+ delete canvas;
+
+ // if we set a specific size for the view then it should keep that size
+ // for SizeRootObjectToView mode.
+ canvas = new QQuickView(&window);
+ canvas->resize(300, 300);
+ canvas->setResizeMode(QQuickView::SizeRootObjectToView);
+ QCOMPARE(QSize(0,0), canvas->initialSize());
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
+ canvas->resize(300, 300);
+ item = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(item);
+ window.show();
+
+ canvas->show();
+ QTest::qWait(50);
+
+ // initial size from root object
+ QCOMPARE(item->width(), 300.0);
+ QCOMPARE(item->height(), 300.0);
+ QCOMPARE(canvas->size(), QSize(300, 300));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(canvas->initialSize(), QSize(200, 200)); // initial object size
+
+ delete canvas;
+}
+
+static void silentErrorsMsgHandler(QtMsgType, const char *)
+{
+}
+
+void tst_QQuickView::errors()
+{
+ QQuickView *canvas = new QQuickView;
+ QVERIFY(canvas);
+ QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
+ canvas->setSource(testFileUrl("error1.qml"));
+ qInstallMsgHandler(old);
+ QVERIFY(canvas->status() == QQuickView::Error);
+ QVERIFY(canvas->errors().count() == 1);
+ delete canvas;
+}
+
+
+QTEST_MAIN(tst_QQuickView)
+
+#include "tst_qquickview.moc"
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml b/tests/auto/quick/qquickvisualdatamodel/data/create.qml
index 9f4b754552..9f4b754552 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/create.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml
index ae3bd81d91..ae3bd81d91 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml b/tests/auto/quick/qquickvisualdatamodel/data/datalist.qml
index 8ce59caddc..8ce59caddc 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/datalist.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml
index 70c6f9f995..70c6f9f995 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml
index ea5ad5d3bd..ea5ad5d3bd 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups.qml
index 7502dd2502..7502dd2502 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/groups.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml
index 103c4d2eb6..103c4d2eb6 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml
index b47f22dc34..b47f22dc34 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml
index bc619124fd..bc619124fd 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml
index e97e0dad2e..e97e0dad2e 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml
index b6b56727e8..b6b56727e8 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml
index d2dfc37e07..d2dfc37e07 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml
index 73b766f1af..73b766f1af 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml
index ea5c240b29..ea5c240b29 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml
index 964ac426f8..964ac426f8 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml
index 77e30b69b9..77e30b69b9 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml
index b3952a8a4d..b3952a8a4d 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml
index c69e54c2f8..c69e54c2f8 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml
index 0dbe2f5459..0dbe2f5459 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml b/tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml
index 71dc7d72d7..71dc7d72d7 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml b/tests/auto/quick/qquickvisualdatamodel/data/packageView.qml
index 682f3833d1..682f3833d1 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/packageView.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml b/tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml
index c471893e1d..c471893e1d 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml b/tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml
index ab1798999d..ab1798999d 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml
index 910df816f3..910df816f3 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml
index 6133c61bc5..6133c61bc5 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml
index d1a4604b77..d1a4604b77 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml
index a075ccb4d9..a075ccb4d9 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml b/tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml
index 0d4d9e2e46..0d4d9e2e46 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml
diff --git a/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
new file mode 100644
index 0000000000..bfadf196f9
--- /dev/null
+++ b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qquickvisualdatamodel
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickvisualdatamodel.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private widgets testlib
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
new file mode 100644
index 0000000000..dbfd4919b9
--- /dev/null
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -0,0 +1,3446 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QStandardItemModel>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquicklistview_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickvisualdatamodel_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <private/qquickchangeset_p.h>
+#include <private/qqmlengine_p.h>
+#include <math.h>
+
+using namespace QQuickVisualTestUtil;
+
+template <typename T, int N> int lengthOf(const T (&)[N]) { return N; }
+
+static void initStandardTreeModel(QStandardItemModel *model)
+{
+ QStandardItem *item;
+ item = new QStandardItem(QLatin1String("Row 1 Item"));
+ model->insertRow(0, item);
+
+ item = new QStandardItem(QLatin1String("Row 2 Item"));
+ item->setCheckable(true);
+ model->insertRow(1, item);
+
+ QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
+ item->setChild(0, childItem);
+
+ item = new QStandardItem(QLatin1String("Row 3 Item"));
+ item->setIcon(QIcon());
+ model->insertRow(2, item);
+}
+
+class SingleRoleModel : public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList values WRITE setList)
+public:
+ SingleRoleModel(const QByteArray &role = "name", QObject *parent = 0)
+ : QAbstractListModel(parent)
+ {
+ QHash<int, QByteArray> roles;
+ roles.insert(Qt::DisplayRole , role);
+ setRoleNames(roles);
+ list << "one" << "two" << "three" << "four";
+ }
+
+ void emitMove(int sourceFirst, int sourceLast, int destinationChild) {
+ emit beginMoveRows(QModelIndex(), sourceFirst, sourceLast, QModelIndex(), destinationChild);
+ emit endMoveRows();
+ }
+
+ QStringList list;
+
+ void setList(const QStringList &l) { list = l; }
+
+public slots:
+ void set(int idx, QString string) {
+ list[idx] = string;
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+protected:
+ int rowCount(const QModelIndex & /* parent */ = QModelIndex()) const {
+ return list.count();
+ }
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
+ if (role == Qt::DisplayRole)
+ return list.at(index.row());
+ return QVariant();
+ }
+};
+
+class StandardItem : public QObject, public QStandardItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text WRITE setText)
+
+public:
+ void writeText(const QString &text) { setText(text); }
+};
+
+class StandardItemModel : public QStandardItemModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<StandardItem> items READ items CONSTANT)
+ Q_CLASSINFO("DefaultProperty", "items")
+public:
+ QQmlListProperty<StandardItem> items() { return QQmlListProperty<StandardItem>(this, 0, append); }
+
+ static void append(QQmlListProperty<StandardItem> *property, StandardItem *item)
+ {
+ static_cast<QStandardItemModel *>(property->object)->appendRow(item);
+ }
+};
+
+class DataObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
+
+public:
+ DataObject(QObject *parent=0) : QObject(parent) {}
+ DataObject(const QString &name, const QString &color, QObject *parent=0)
+ : QObject(parent), m_name(name), m_color(color) { }
+
+
+ QString name() const { return m_name; }
+ void setName(const QString &name) {
+ if (name != m_name) {
+ m_name = name;
+ emit nameChanged();
+ }
+ }
+
+ QString color() const { return m_color; }
+ void setColor(const QString &color) {
+ if (color != m_color) {
+ m_color = color;
+ emit colorChanged();
+ }
+ }
+
+signals:
+ void nameChanged();
+ void colorChanged();
+
+private:
+ QString m_name;
+ QString m_color;
+};
+
+QML_DECLARE_TYPE(SingleRoleModel)
+QML_DECLARE_TYPE(StandardItem)
+QML_DECLARE_TYPE(StandardItemModel)
+QML_DECLARE_TYPE(DataObject)
+
+class tst_qquickvisualdatamodel : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickvisualdatamodel();
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void rootIndex();
+ void updateLayout_data();
+ void updateLayout();
+ void childChanged_data();
+ void childChanged();
+ void objectListModel();
+ void singleRole();
+ void modelProperties();
+ void noDelegate_data();
+ void noDelegate();
+ void itemsDestroyed_data();
+ void itemsDestroyed();
+ void packagesDestroyed();
+ void qaimRowsMoved();
+ void qaimRowsMoved_data();
+ void remove_data();
+ void remove();
+ void move_data();
+ void move();
+ void groups_data();
+ void groups();
+ void invalidGroups();
+ void get();
+ void onChanged_data();
+ void onChanged();
+ void create();
+ void incompleteModel();
+ void insert_data();
+ void insert();
+ void resolve_data();
+ void resolve();
+ void warnings_data();
+ void warnings();
+
+private:
+ template <int N> void groups_verify(
+ const SingleRoleModel &model,
+ QQuickItem *contentItem,
+ const int (&mIndex)[N],
+ const int (&iIndex)[N],
+ const int (&vIndex)[N],
+ const int (&sIndex)[N],
+ const bool (&vMember)[N],
+ const bool (&sMember)[N]);
+
+ template <int N> void get_verify(
+ const SingleRoleModel &model,
+ QQuickVisualDataModel *visualModel,
+ QQuickVisualDataGroup *visibleItems,
+ QQuickVisualDataGroup *selectedItems,
+ const int (&mIndex)[N],
+ const int (&iIndex)[N],
+ const int (&vIndex)[N],
+ const int (&sIndex)[N],
+ const bool (&vMember)[N],
+ const bool (&sMember)[N]);
+
+ bool failed;
+ QQmlEngine engine;
+};
+
+Q_DECLARE_METATYPE(QQuickChangeSet)
+
+template <typename T> static T evaluate(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ T result = expr.evaluate().value<T>();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+ return result;
+}
+
+template <> void evaluate<void>(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+}
+
+void tst_qquickvisualdatamodel::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qRegisterMetaType<QQuickChangeSet>();
+
+ qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel");
+ qmlRegisterType<StandardItem>("tst_qquickvisualdatamodel", 1, 0, "StandardItem");
+ qmlRegisterType<StandardItemModel>("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel");
+ qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject");
+}
+
+void tst_qquickvisualdatamodel::cleanupTestCase()
+{
+
+}
+
+tst_qquickvisualdatamodel::tst_qquickvisualdatamodel()
+{
+}
+
+void tst_qquickvisualdatamodel::rootIndex()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml"));
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ engine.rootContext()->setContextProperty("myModel", &model);
+
+ QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QVERIFY(obj != 0);
+
+ QMetaObject::invokeMethod(obj, "setRoot");
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
+
+ QMetaObject::invokeMethod(obj, "setRootToParent");
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
+
+ QMetaObject::invokeMethod(obj, "setRoot");
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
+ model.clear(); // will emit modelReset()
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
+
+ delete obj;
+}
+
+void tst_qquickvisualdatamodel::updateLayout_data()
+{
+ QTest::addColumn<QUrl>("source");
+
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
+}
+
+void tst_qquickvisualdatamodel::updateLayout()
+{
+ QFETCH(QUrl, source);
+
+ QQuickView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+
+ model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
+
+ name = findItem<QQuickText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+}
+
+void tst_qquickvisualdatamodel::childChanged_data()
+{
+ QTest::addColumn<QUrl>("source");
+
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
+}
+
+void tst_qquickvisualdatamodel::childChanged()
+{
+ QFETCH(QUrl, source);
+
+ QQuickView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
+ vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
+ QCOMPARE(listview->count(), 1);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Child Item"));
+
+ model.item(1,0)->child(0,0)->setText("Row 2 updated child");
+
+ name = findItem<QQuickText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 updated child"));
+
+ model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2")));
+ QCOMPARE(listview->count(), 2);
+
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
+
+ model.item(1,0)->takeRow(1);
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name == 0);
+
+ vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
+ QCOMPARE(listview->count(), 3);
+ name = findItem<QQuickText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+}
+
+void tst_qquickvisualdatamodel::objectListModel()
+{
+ QQuickView view;
+
+ QList<QObject*> dataList;
+ dataList.append(new DataObject("Item 1", "red"));
+ dataList.append(new DataObject("Item 2", "green"));
+ dataList.append(new DataObject("Item 3", "blue"));
+ dataList.append(new DataObject("Item 4", "yellow"));
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+
+ view.setSource(testFileUrl("objectlist.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "name", 0);
+ QCOMPARE(name->text(), QString("Item 1"));
+
+ QQuickText *section = findItem<QQuickText>(contentItem, "section", 0);
+ QCOMPARE(section->text(), QString("Item 1"));
+
+ dataList[0]->setProperty("name", QLatin1String("Changed"));
+ QCOMPARE(name->text(), QString("Changed"));
+}
+
+void tst_qquickvisualdatamodel::singleRole()
+{
+ {
+ QQuickView view;
+
+ SingleRoleModel model;
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("singlerole1.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+ {
+ QQuickView view;
+
+ SingleRoleModel model;
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("singlerole2.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+ {
+ QQuickView view;
+
+ SingleRoleModel model("modelData");
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("singlerole2.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+}
+
+void tst_qquickvisualdatamodel::modelProperties()
+{
+ {
+ QQuickView view;
+
+ SingleRoleModel model;
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("modelproperties.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(),QString("two"));
+ QCOMPARE(delegate->property("test2").toString(),QString("two"));
+ QCOMPARE(delegate->property("test3").toString(),QString("two"));
+ QCOMPARE(delegate->property("test4").toString(),QString("two"));
+ QVERIFY(!delegate->property("test9").isValid());
+ QCOMPARE(delegate->property("test5").toString(),QString(""));
+ QVERIFY(delegate->property("test6").value<QObject*>() != 0);
+ QCOMPARE(delegate->property("test7").toInt(),1);
+ QCOMPARE(delegate->property("test8").toInt(),1);
+ }
+
+ {
+ QQuickView view;
+
+ QList<QObject*> dataList;
+ dataList.append(new DataObject("Item 1", "red"));
+ dataList.append(new DataObject("Item 2", "green"));
+ dataList.append(new DataObject("Item 3", "blue"));
+ dataList.append(new DataObject("Item 4", "yellow"));
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+
+ view.setSource(testFileUrl("modelproperties.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(),QString("Item 2"));
+ QCOMPARE(delegate->property("test2").toString(),QString("Item 2"));
+ QVERIFY(qobject_cast<DataObject*>(delegate->property("test3").value<QObject*>()) != 0);
+ QVERIFY(qobject_cast<DataObject*>(delegate->property("test4").value<QObject*>()) != 0);
+ QCOMPARE(delegate->property("test5").toString(),QString("Item 2"));
+ QCOMPARE(delegate->property("test9").toString(),QString("Item 2"));
+ QVERIFY(delegate->property("test6").value<QObject*>() != 0);
+ QCOMPARE(delegate->property("test7").toInt(),1);
+ QCOMPARE(delegate->property("test8").toInt(),1);
+ }
+
+ {
+ QQuickView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ QUrl source(testFileUrl("modelproperties2.qml"));
+
+ //3 items, 3 i each
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(),QString("Row 2 Item"));
+ QCOMPARE(delegate->property("test2").toString(),QString("Row 2 Item"));
+ QVERIFY(!delegate->property("test3").isValid());
+ QVERIFY(!delegate->property("test4").isValid());
+ QVERIFY(!delegate->property("test5").isValid());
+ QVERIFY(!delegate->property("test9").isValid());
+ QVERIFY(delegate->property("test6").value<QObject*>() != 0);
+ QCOMPARE(delegate->property("test7").toInt(),1);
+ QCOMPARE(delegate->property("test8").toInt(),1);
+ }
+
+ //### should also test QStringList and QVariantList
+}
+
+void tst_qquickvisualdatamodel::noDelegate_data()
+{
+ QTest::addColumn<QUrl>("source");
+
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
+}
+
+void tst_qquickvisualdatamodel::noDelegate()
+{
+ QFETCH(QUrl, source);
+
+ QQuickView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
+ QVERIFY(vdm != 0);
+ QCOMPARE(vdm->count(), 3);
+
+ vdm->setDelegate(0);
+ QCOMPARE(vdm->count(), 0);
+}
+
+void tst_qquickvisualdatamodel::itemsDestroyed_data()
+{
+ QTest::addColumn<QUrl>("source");
+
+ QTest::newRow("listView") << testFileUrl("itemsDestroyed_listView.qml");
+ QTest::newRow("package") << testFileUrl("itemsDestroyed_package.qml");
+ QTest::newRow("pathView") << testFileUrl("itemsDestroyed_pathView.qml");
+ QTest::newRow("repeater") << testFileUrl("itemsDestroyed_repeater.qml");
+}
+
+void tst_qquickvisualdatamodel::itemsDestroyed()
+{
+ QFETCH(QUrl, source);
+
+ QQmlGuard<QQuickItem> delegate;
+
+ {
+ QQuickView view;
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+ view.rootContext()->setContextProperty("myModel", &model);
+ view.setSource(source);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QVERIFY(delegate = findItem<QQuickItem>(view.rootItem(), "delegate", 1));
+ }
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(!delegate);
+}
+
+void tst_qquickvisualdatamodel::packagesDestroyed()
+{
+ SingleRoleModel model;
+ model.list.clear();
+ for (int i=0; i<30; i++)
+ model.list << ("item " + i);
+
+ QQuickView view;
+ view.rootContext()->setContextProperty("testModel", &model);
+
+ QString filename(testFile("packageView.qml"));
+ view.setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QQuickListView *leftview = findItem<QQuickListView>(view.rootObject(), "leftList");
+ QTRY_VERIFY(leftview != 0);
+
+ QQuickListView *rightview = findItem<QQuickListView>(view.rootObject(), "rightList");
+ QTRY_VERIFY(rightview != 0);
+
+ QQuickItem *leftContent = leftview->contentItem();
+ QTRY_VERIFY(leftContent != 0);
+
+ QQuickItem *rightContent = rightview->contentItem();
+ QTRY_VERIFY(rightContent != 0);
+
+ QCOMPARE(leftview->currentIndex(), 0);
+ QCOMPARE(rightview->currentIndex(), 0);
+
+ rightview->setCurrentIndex(20);
+ QTRY_COMPARE(rightview->contentY(), 100.0);
+
+ QQmlGuard<QQuickItem> left;
+ QQmlGuard<QQuickItem> right;
+
+ QVERIFY(findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QVERIFY(findItem<QQuickItem>(rightContent, "wrapper", 1));
+
+ QVERIFY(left = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QVERIFY(right = findItem<QQuickItem>(rightContent, "wrapper", 19));
+
+ rightview->setCurrentIndex(0);
+ QCOMPARE(rightview->currentIndex(), 0);
+
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+ QCoreApplication::sendPostedEvents();
+
+ QVERIFY(!left);
+ QVERIFY(!right);
+
+ QVERIFY(left = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QVERIFY(right = findItem<QQuickItem>(rightContent, "wrapper", 1));
+
+ rightview->setCurrentIndex(20);
+ QTRY_COMPARE(rightview->contentY(), 100.0);
+
+ QVERIFY(left);
+ QVERIFY(right);
+
+ QVERIFY(findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QVERIFY(findItem<QQuickItem>(rightContent, "wrapper", 19));
+
+ leftview->setCurrentIndex(20);
+ QTRY_COMPARE(leftview->contentY(), 100.0);
+
+ QVERIFY(!left);
+ QVERIFY(!right);
+}
+
+void tst_qquickvisualdatamodel::qaimRowsMoved()
+{
+ // Test parameters passed in QAIM::rowsMoved() signal are converted correctly
+ // when translated and emitted as the QListModelInterface::itemsMoved() signal
+ QFETCH(int, sourceFirst);
+ QFETCH(int, sourceLast);
+ QFETCH(int, destinationChild);
+ QFETCH(int, expectFrom);
+ QFETCH(int, expectTo);
+ QFETCH(int, expectCount);
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml"));
+
+ SingleRoleModel model;
+ model.list.clear();
+ for (int i=0; i<30; i++)
+ model.list << ("item " + i);
+ engine.rootContext()->setContextProperty("myModel", &model);
+
+ QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QVERIFY(obj != 0);
+
+ QSignalSpy spy(obj, SIGNAL(modelUpdated(QQuickChangeSet,bool)));
+ model.emitMove(sourceFirst, sourceLast, destinationChild);
+ QCOMPARE(spy.count(), 1);
+
+ QCOMPARE(spy[0].count(), 2);
+ QQuickChangeSet changeSet = spy[0][0].value<QQuickChangeSet>();
+ QCOMPARE(changeSet.removes().count(), 1);
+ QCOMPARE(changeSet.removes().at(0).index, expectFrom);
+ QCOMPARE(changeSet.removes().at(0).count, expectCount);
+ QCOMPARE(changeSet.inserts().count(), 1);
+ QCOMPARE(changeSet.inserts().at(0).index, expectTo);
+ QCOMPARE(changeSet.inserts().at(0).count, expectCount);
+ QCOMPARE(changeSet.removes().at(0).moveId, changeSet.inserts().at(0).moveId);
+ QCOMPARE(spy[0][1].toBool(), false);
+
+ delete obj;
+}
+
+void tst_qquickvisualdatamodel::qaimRowsMoved_data()
+{
+ QTest::addColumn<int>("sourceFirst");
+ QTest::addColumn<int>("sourceLast");
+ QTest::addColumn<int>("destinationChild");
+ QTest::addColumn<int>("expectFrom");
+ QTest::addColumn<int>("expectTo");
+ QTest::addColumn<int>("expectCount");
+
+ QTest::newRow("move 1 forward")
+ << 1 << 1 << 6
+ << 1 << 5 << 1;
+
+ QTest::newRow("move 1 backwards")
+ << 4 << 4 << 1
+ << 4 << 1 << 1;
+
+ QTest::newRow("move multiple forwards")
+ << 0 << 2 << 13
+ << 0 << 10 << 3;
+
+ QTest::newRow("move multiple forwards, with same to")
+ << 0 << 1 << 3
+ << 0 << 1 << 2;
+
+ QTest::newRow("move multiple backwards")
+ << 10 << 14 << 1
+ << 10 << 1 << 5;
+}
+
+void tst_qquickvisualdatamodel::remove_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("package delegate");
+
+ QTest::newRow("item delegate")
+ << testFileUrl("groups.qml")
+ << QString();
+ QTest::newRow("package")
+ << testFileUrl("groups-package.qml")
+ << QString("package.");
+}
+
+void tst_qquickvisualdatamodel::remove()
+{
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("groups.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QVERIFY(visualModel);
+
+ {
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.remove(2)");
+ QCOMPARE(listview->count(), 11);
+ QCOMPARE(visualModel->items()->count(), 11);
+ static const int mIndex[] = { 0, 1, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.remove(1, 4)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ static const int mIndex[] = { 0, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: index out of range");
+ evaluate<void>(visualModel, "items.remove(-8, 4)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: index out of range");
+ evaluate<void>(visualModel, "items.remove(12, 2)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: invalid count");
+ evaluate<void>(visualModel, "items.remove(5, 3)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: invalid count");
+ evaluate<void>(visualModel, "items.remove(5, -2)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ }
+}
+
+void tst_qquickvisualdatamodel::move_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("package delegate");
+
+ QTest::newRow("item delegate")
+ << testFileUrl("groups.qml")
+ << QString();
+ QTest::newRow("package")
+ << testFileUrl("groups-package.qml")
+ << QString("package.");
+}
+
+void tst_qquickvisualdatamodel::move()
+{
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("groups.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QVERIFY(visualModel);
+
+ {
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.move(2, 4)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 0, 1, 3, 4, 2, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.move(4, 2)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.move(8, 0, 4)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 8, 9,10,11, 0, 1, 2, 3, 4, 5, 6, 7 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.move(3, 4, 5)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 8, 9,10,4, 11, 0, 1, 2, 3, 5, 6, 7 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: invalid count");
+ evaluate<void>(visualModel, "items.move(5, 2, -2)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
+ evaluate<void>(visualModel, "items.move(-6, 2, 1)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
+ evaluate<void>(visualModel, "items.move(15, 2, 1)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
+ evaluate<void>(visualModel, "items.move(11, 1, 3)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
+ evaluate<void>(visualModel, "items.move(2, -5, 1)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
+ evaluate<void>(visualModel, "items.move(2, 14, 1)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
+ evaluate<void>(visualModel, "items.move(2, 11, 4)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ }
+}
+
+void tst_qquickvisualdatamodel::groups_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("part");
+
+ QTest::newRow("item delegate")
+ << testFileUrl("groups.qml")
+ << QString();
+ QTest::newRow("package")
+ << testFileUrl("groups-package.qml")
+ << QString("visualModel.parts.package.");
+}
+
+template <int N> void tst_qquickvisualdatamodel::groups_verify(
+ const SingleRoleModel &model,
+ QQuickItem *contentItem,
+ const int (&mIndex)[N],
+ const int (&iIndex)[N],
+ const int (&vIndex)[N],
+ const int (&sIndex)[N],
+ const bool (&vMember)[N],
+ const bool (&sMember)[N])
+{
+ failed = true;
+ for (int i = 0; i < N; ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(evaluate<QString>(delegate, "test1"), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<int>(delegate, "test2") , mIndex[i]);
+ QCOMPARE(evaluate<int>(delegate, "test3") , iIndex[i]);
+ QCOMPARE(evaluate<bool>(delegate, "test4"), true);
+ QCOMPARE(evaluate<int>(delegate, "test5") , vIndex[i]);
+ QCOMPARE(evaluate<bool>(delegate, "test6"), vMember[i]);
+ QCOMPARE(evaluate<int>(delegate, "test7") , sIndex[i]);
+ QCOMPARE(evaluate<bool>(delegate, "test8"), sMember[i]);
+ QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("items") , bool(true));
+ QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("visible") , bool(vMember[i]));
+ QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("selected"), bool(sMember[i]));
+ }
+ failed = false;
+}
+
+#define VERIFY_GROUPS \
+ groups_verify(model, contentItem, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \
+ QVERIFY(!failed)
+
+
+void tst_qquickvisualdatamodel::groups()
+{
+ QFETCH(QUrl, source);
+ QFETCH(QString, part);
+
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = listview->findChild<QQuickVisualDataModel *>("visualModel");
+ QVERIFY(visualModel);
+
+ QQuickVisualDataGroup *visibleItems = listview->findChild<QQuickVisualDataGroup *>("visibleItems");
+ QVERIFY(visibleItems);
+
+ QQuickVisualDataGroup *selectedItems = listview->findChild<QQuickVisualDataGroup *>("selectedItems");
+ QVERIFY(selectedItems);
+
+ const bool f = false;
+ const bool t = true;
+
+ {
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 0);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(visualModel, "items.addGroups(8, \"selected\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 1);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 4);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
+ static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(visualModel, "items.setGroups(2, [\"items\", \"selected\"])");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 11);
+ QCOMPARE(selectedItems->count(), 5);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 };
+ static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 };
+ static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(selectedItems, "setGroups(0, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
+ static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: invalid count");
+ evaluate<void>(visualModel, "items.addGroups(11, -4, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: index out of range");
+ evaluate<void>(visualModel, "items.addGroups(-1, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: index out of range");
+ evaluate<void>(visualModel, "items.addGroups(14, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: invalid count");
+ evaluate<void>(visualModel, "items.addGroups(11, 5, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: invalid count");
+ evaluate<void>(visualModel, "items.setGroups(11, -4, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: index out of range");
+ evaluate<void>(visualModel, "items.setGroups(-1, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: index out of range");
+ evaluate<void>(visualModel, "items.setGroups(14, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: invalid count");
+ evaluate<void>(visualModel, "items.setGroups(11, 5, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: invalid count");
+ evaluate<void>(visualModel, "items.removeGroups(11, -4, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: index out of range");
+ evaluate<void>(visualModel, "items.removeGroups(-1, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: index out of range");
+ evaluate<void>(visualModel, "items.removeGroups(14, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: invalid count");
+ evaluate<void>(visualModel, "items.removeGroups(11, 5, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ evaluate<void>(visualModel, part + "filterOnGroup = \"visible\"");
+ QCOMPARE(listview->count(), 9);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("visible"));
+ } {
+ evaluate<void>(visualModel, part + "filterOnGroup = \"selected\"");
+ QCOMPARE(listview->count(), 2);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("selected"));
+ } {
+ evaluate<void>(visualModel, part + "filterOnGroup = undefined");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("items"));
+ } {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 5);
+ QVERIFY(delegate);
+
+ evaluate<void>(delegate, "hide()");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 5);
+ QVERIFY(delegate);
+
+ evaluate<void>(delegate, "select()");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 3);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 };
+ static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(visualModel, "items.move(2, 6, 3)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 3);
+ static const int mIndex [] = { 0, 1, 5, 6, 7, 8, 2, 3, 4, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, f, f, t, f, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3 };
+ static const bool sMember[] = { f, f, t, f, f, t, f, f, f, t, f, f };
+ VERIFY_GROUPS;
+ }
+}
+
+template <int N> void tst_qquickvisualdatamodel::get_verify(
+ const SingleRoleModel &model,
+ QQuickVisualDataModel *visualModel,
+ QQuickVisualDataGroup *visibleItems,
+ QQuickVisualDataGroup *selectedItems,
+ const int (&mIndex)[N],
+ const int (&iIndex)[N],
+ const int (&vIndex)[N],
+ const int (&sIndex)[N],
+ const bool (&vMember)[N],
+ const bool (&sMember)[N])
+{
+ failed = true;
+ for (int i = 0; i < N; ++i) {
+ QCOMPARE(evaluate<QString>(visualModel, QString("items.get(%1).model.name").arg(i)), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<QString>(visualModel, QString("items.get(%1).model.modelData").arg(i)), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).model.index").arg(i)), mIndex[i]);
+ QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).itemsIndex").arg(i)), iIndex[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inItems").arg(i)), true);
+ QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).visibleIndex").arg(i)), vIndex[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inVisible").arg(i)), vMember[i]);
+ QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).selectedIndex").arg(i)), sIndex[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inSelected").arg(i)), sMember[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"items\")").arg(i)), true);
+ QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"visible\")").arg(i)), vMember[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"selected\")").arg(i)), sMember[i]);
+
+ if (vMember[i]) {
+ QCOMPARE(evaluate<QString>(visibleItems, QString("get(%1).model.name").arg(vIndex[i])), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<QString>(visibleItems, QString("get(%1).model.modelData").arg(vIndex[i])), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).model.index").arg(vIndex[i])), mIndex[i]);
+ QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).itemsIndex").arg(vIndex[i])), iIndex[i]);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inItems").arg(vIndex[i])), true);
+ QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).visibleIndex").arg(vIndex[i])), vIndex[i]);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inVisible").arg(vIndex[i])), vMember[i]);
+ QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).selectedIndex").arg(vIndex[i])), sIndex[i]);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inSelected").arg(vIndex[i])), sMember[i]);
+
+ QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"items\")").arg(vIndex[i])), true);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"visible\")").arg(vIndex[i])), vMember[i]);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"selected\")").arg(vIndex[i])), sMember[i]);
+ }
+ if (sMember[i]) {
+ QCOMPARE(evaluate<QString>(selectedItems, QString("get(%1).model.name").arg(sIndex[i])), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<QString>(selectedItems, QString("get(%1).model.modelData").arg(sIndex[i])), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).model.index").arg(sIndex[i])), mIndex[i]);
+ QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).itemsIndex").arg(sIndex[i])), iIndex[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inItems").arg(sIndex[i])), true);
+ QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).visibleIndex").arg(sIndex[i])), vIndex[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inVisible").arg(sIndex[i])), vMember[i]);
+ QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).selectedIndex").arg(sIndex[i])), sIndex[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inSelected").arg(sIndex[i])), sMember[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"items\")").arg(sIndex[i])), true);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"visible\")").arg(sIndex[i])), vMember[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"selected\")").arg(sIndex[i])), sMember[i]);
+ }
+ }
+ failed = false;
+}
+
+#define VERIFY_GET \
+ get_verify(model, visualModel, visibleItems, selectedItems, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \
+ QVERIFY(!failed)
+
+void tst_qquickvisualdatamodel::get()
+{
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("groups.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QVERIFY(visualModel);
+
+ QQuickVisualDataGroup *visibleItems = visualModel->findChild<QQuickVisualDataGroup *>("visibleItems");
+ QVERIFY(visibleItems);
+
+ QQuickVisualDataGroup *selectedItems = visualModel->findChild<QQuickVisualDataGroup *>("selectedItems");
+ QVERIFY(selectedItems);
+
+ QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(ctxt->engine());
+ QVERIFY(v8Engine);
+
+ const bool f = false;
+ const bool t = true;
+
+ {
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 0);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.addGroups(8, \"selected\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 1);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 4);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
+ static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.setGroups(2, [\"items\", \"selected\"])");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 11);
+ QCOMPARE(selectedItems->count(), 5);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 };
+ static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 };
+ static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(selectedItems, "setGroups(0, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
+ static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.get(5).inVisible = false");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.get(5).inSelected = true");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 3);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 };
+ static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.get(5).groups = [\"visible\", \"items\"]");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
+ static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GET;
+ }
+}
+
+void tst_qquickvisualdatamodel::invalidGroups()
+{
+ QUrl source = testFileUrl("groups-invalid.qml");
+ QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8());
+
+ QQmlComponent component(&engine, source);
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+
+ QCOMPARE(evaluate<int>(object.data(), "groups.length"), 4);
+ QCOMPARE(evaluate<QString>(object.data(), "groups[0].name"), QString("items"));
+ QCOMPARE(evaluate<QString>(object.data(), "groups[1].name"), QString("persistedItems"));
+ QCOMPARE(evaluate<QString>(object.data(), "groups[2].name"), QString("visible"));
+ QCOMPARE(evaluate<QString>(object.data(), "groups[3].name"), QString("selected"));
+}
+
+void tst_qquickvisualdatamodel::onChanged_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QStringList>("tests");
+
+ QTest::newRow("item appended")
+ << QString("listModel.append({\"number\": \"five\"})")
+ << (QStringList()
+ << "verify(vm.removed, [], [], [])"
+ << "verify(vm.inserted, [4], [1], [undefined])"
+ << "verify(vi.removed, [], [], [])"
+ << "verify(vi.inserted, [4], [1], [undefined])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item prepended")
+ << QString("listModel.insert(0, {\"number\": \"five\"})")
+ << (QStringList()
+ << "verify(vm.removed, [], [], [])"
+ << "verify(vm.inserted, [0], [1], [undefined])"
+ << "verify(vi.removed, [], [], [])"
+ << "verify(vi.inserted, [0], [1], [undefined])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item inserted")
+ << QString("listModel.insert(2, {\"number\": \"five\"})")
+ << (QStringList()
+ << "verify(vm.removed, [], [], [])"
+ << "verify(vm.inserted, [2], [1], [undefined])"
+ << "verify(vi.removed, [], [], [])"
+ << "verify(vi.inserted, [2], [1], [undefined])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+
+ QTest::newRow("item removed tail")
+ << QString("listModel.remove(3)")
+ << (QStringList()
+ << "verify(vm.removed, [3], [1], [undefined])"
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vi.removed, [3], [1], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item removed head")
+ << QString("listModel.remove(0)")
+ << (QStringList()
+ << "verify(vm.removed, [0], [1], [undefined])"
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vi.removed, [0], [1], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item removed middle")
+ << QString("listModel.remove(1)")
+ << (QStringList()
+ << "verify(vm.removed, [1], [1], [undefined])"
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vi.removed, [1], [1], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+
+
+ QTest::newRow("item moved from tail")
+ << QString("listModel.move(3, 0, 1)")
+ << (QStringList()
+ << "verify(vm.removed, [3], [1], [vm.inserted[0].moveId])"
+ << "verify(vm.inserted, [0], [1], [vm.removed[0].moveId])"
+ << "verify(vi.removed, [3], [1], [vi.inserted[0].moveId])"
+ << "verify(vi.inserted, [0], [1], [vi.removed[0].moveId])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item moved from head")
+ << QString("listModel.move(0, 2, 2)")
+ << (QStringList()
+ << "verify(vm.removed, [0], [2], [vm.inserted[0].moveId])"
+ << "verify(vm.inserted, [2], [2], [vm.removed[0].moveId])"
+ << "verify(vi.removed, [0], [2], [vi.inserted[0].moveId])"
+ << "verify(vi.inserted, [2], [2], [vi.removed[0].moveId])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+
+ QTest::newRow("groups changed")
+ << QString("items.setGroups(1, 2, [\"items\", \"selected\"])")
+ << (QStringList()
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vm.removed, [], [], [])"
+ << "verify(vi.removed, [1], [2], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [0], [2], [undefined])");
+
+ QTest::newRow("multiple removes")
+ << QString("{ vi.remove(1, 1); "
+ "vi.removeGroups(0, 2, \"items\") }")
+ << (QStringList()
+ << "verify(vm.removed, [0, 1], [1, 1], [undefined, undefined])"
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vi.removed, [1], [1], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+}
+
+void tst_qquickvisualdatamodel::onChanged()
+{
+ QFETCH(QString, expression);
+ QFETCH(QStringList, tests);
+
+ QQmlComponent component(&engine, testFileUrl("onChanged.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+
+ evaluate<void>(object.data(), expression);
+
+ foreach (const QString &test, tests) {
+ bool passed = evaluate<bool>(object.data(), test);
+ if (!passed)
+ qWarning() << test;
+ QVERIFY(passed);
+ }
+}
+
+void tst_qquickvisualdatamodel::create()
+{
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve"
+ << "thirteen"
+ << "fourteen"
+ << "fifteen"
+ << "sixteen"
+ << "seventeen"
+ << "eighteen"
+ << "nineteen"
+ << "twenty";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("create.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QVERIFY(visualModel);
+
+ QCOMPARE(listview->count(), 20);
+
+ QQmlGuard<QQuickItem> delegate;
+
+ // persistedItems.includeByDefault is true, so all items belong to persistedItems initially.
+ QVERIFY(delegate = findItem<QQuickItem>(contentItem, "delegate", 1));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+
+ // changing include by default doesn't remove persistance.
+ evaluate<void>(visualModel, "persistedItems.includeByDefault = false");
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+
+ // removing from persistedItems does.
+ evaluate<void>(visualModel, "persistedItems.remove(0, 20)");
+ QCOMPARE(listview->count(), 20);
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
+
+ // Request an item instantiated by the view.
+ QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(1)")));
+ QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 1));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+
+ evaluate<void>(delegate, "VisualDataModel.inPersistedItems = false");
+ QCOMPARE(listview->count(), 20);
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
+
+ // Request an item not instantiated by the view.
+ QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 15));
+ QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(15)")));
+ QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 15));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+
+ evaluate<void>(visualModel, "persistedItems.remove(0)");
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(!delegate);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
+
+ // Request an item not instantiated by the view, then scroll the view so it will request it.
+ QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 16));
+ QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(16)")));
+ QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 16));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+
+ evaluate<void>(listview, "positionViewAtIndex(19, ListView.End)");
+ QCOMPARE(listview->count(), 20);
+ evaluate<void>(delegate, "VisualDataModel.groups = [\"items\"]");
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
+
+ // Request and release an item instantiated by the view, then scroll the view so it releases it.
+ QVERIFY(findItem<QQuickItem>(contentItem, "delegate", 17));
+ QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(17)")));
+ QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 17));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+
+ evaluate<void>(visualModel, "items.removeGroups(17, \"persistedItems\")");
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
+ evaluate<void>(listview, "positionViewAtIndex(1, ListView.Beginning)");
+ QCOMPARE(listview->count(), 20);
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(!delegate);
+
+ // Adding an item to the persistedItems group won't instantiate it, but if later requested by
+ // the view it will be persisted.
+ evaluate<void>(visualModel, "items.addGroups(18, \"persistedItems\")");
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+ QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 18));
+ evaluate<void>(listview, "positionViewAtIndex(19, ListView.End)");
+ QCOMPARE(listview->count(), 20);
+ QVERIFY(delegate = findItem<QQuickItem>(contentItem, "delegate", 18));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+ evaluate<void>(listview, "positionViewAtIndex(1, ListView.Beginning)");
+ QCOMPARE(listview->count(), 20);
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+
+ // Remove an uninstantiated but cached item from the persistedItems group.
+ evaluate<void>(visualModel, "items.addGroups(19, \"persistedItems\")");
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 2);
+ QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 19));
+ // Store a reference to the item so it is retained in the cache.
+ evaluate<void>(visualModel, "persistentHandle = items.get(19)");
+ QCOMPARE(evaluate<bool>(visualModel, "persistentHandle.inPersistedItems"), true);
+ evaluate<void>(visualModel, "items.removeGroups(19, \"persistedItems\")");
+ QCOMPARE(evaluate<bool>(visualModel, "persistentHandle.inPersistedItems"), false);
+}
+
+void tst_qquickvisualdatamodel::incompleteModel()
+{
+ // VisualDataModel is first populated in componentComplete. Verify various functions are
+ // harmlessly ignored until then.
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\n VisualDataModel {}", testFileUrl(""));
+
+ QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
+
+ QQuickVisualDataModel *model = qobject_cast<QQuickVisualDataModel *>(object.data());
+ QVERIFY(model);
+
+ QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged()));
+ QSignalSpy persistedItemsSpy(model->items(), SIGNAL(countChanged()));
+
+ evaluate<void>(model, "items.removeGroups(0, items.count, \"items\")");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ evaluate<void>(model, "items.setGroups(0, items.count, \"persistedItems\")");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ evaluate<void>(model, "items.addGroups(0, items.count, \"persistedItems\")");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ evaluate<void>(model, "items.remove(0, items.count)");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ evaluate<void>(model, "items.insert([ \"color\": \"blue\" ])");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: get: index out of range");
+ QVERIFY(evaluate<bool>(model, "items.get(0) === undefined"));
+
+ component.completeCreate();
+}
+
+void tst_qquickvisualdatamodel::insert_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<int>("modelCount");
+ QTest::addColumn<int>("visualCount");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<bool>("inItems");
+ QTest::addColumn<bool>("persisted");
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("selected");
+ QTest::addColumn<bool>("modelData");
+ QTest::addColumn<QString>("property");
+ QTest::addColumn<QStringList>("propertyData");
+
+ const QUrl listModelSource[] = {
+ testFileUrl("listmodelproperties.qml"),
+ testFileUrl("listmodelproperties-package.qml") };
+ const QUrl singleRoleSource[] = {
+ testFileUrl("singleroleproperties.qml"),
+ testFileUrl("singleroleproperties-package.qml") };
+ const QUrl multipleRoleSource[] = {
+ testFileUrl("multipleroleproperties.qml"),
+ testFileUrl("multipleroleproperties-package.qml") };
+ const QUrl stringListSource[] = {
+ testFileUrl("stringlistproperties.qml"),
+ testFileUrl("stringlistproperties-package.qml") };
+ const QUrl objectListSource[] = {
+ testFileUrl("objectlistproperties.qml"),
+ testFileUrl("objectlistproperties-package.qml") };
+
+ for (int i = 0; i < 2; ++i) {
+ // List Model.
+ QTest::newRow("ListModel.items prepend")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << 4 << 5 << 4 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items insert at 2")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert at items.get(2)")
+ << listModelSource[i]
+ << QString("items.insert(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("items.insert(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems insert at items.get(2)")
+ << listModelSource[i]
+ << QString("selectedItems.insert(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << false << false << false << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems insert at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("selectedItems.insert(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << false << false << false << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend modelData")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, edit number")
+ << listModelSource[i]
+ << QString("{ "
+ "items.insert(0, {\"number\": \"eight\"}); "
+ "items.get(0).model.number = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, edit modelData")
+ << listModelSource[i]
+ << QString("{ "
+ "items.insert(0, {\"number\": \"eight\"}); "
+ "items.get(0).model.modelData = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, edit resolved")
+ << listModelSource[i]
+ << QString("{ "
+ "items.insert(0, {\"number\": \"eight\"}); "
+ "items.get(2).model.number = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend with groups")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])")
+ << 4 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append with groups")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"}, [\"visible\", \"selected\"])")
+ << 4 << 5 << 4 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items insert at 2 with groups")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"}, \"visible\")")
+ << 4 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ // create ListModel
+ QTest::newRow("ListModel.items prepend")
+ << listModelSource[i]
+ << QString("items.create(0, {\"number\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append")
+ << listModelSource[i]
+ << QString("items.create({\"number\": \"eight\"})")
+ << 4 << 5 << 4 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items create at 2")
+ << listModelSource[i]
+ << QString("items.create(2, {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create at items.get(2)")
+ << listModelSource[i]
+ << QString("items.create(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems create at items.get(2)")
+ << listModelSource[i]
+ << QString("selectedItems.create(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << false << true << false << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems create at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("selectedItems.create(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << false << true << false << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended")
+ << listModelSource[i]
+ << QString("items.create(0, {\"number\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create appended")
+ << listModelSource[i]
+ << QString("items.create({\"number\": \"eight\"})")
+ << 4 << 5 << 4 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items create at 2")
+ << listModelSource[i]
+ << QString("items.create(2, {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create at items.get(2)")
+ << listModelSource[i]
+ << QString("items.create(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.create prepend modelData")
+ << listModelSource[i]
+ << QString("items.create(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended, edit number")
+ << listModelSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"number\": \"eight\"}); "
+ "item.setTest3(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended, edit model.number")
+ << listModelSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"number\": \"eight\"}); "
+ "item.setTest4(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended, edit modelData")
+ << listModelSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"number\": \"eight\"}); "
+ "item.setTest5(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended, edit model.modelData")
+ << listModelSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"number\": \"eight\"}); "
+ "item.setTest6(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended with groups")
+ << listModelSource[i]
+ << QString("items.create(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])")
+ << 4 << 5 << 0 << true << true << true << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create appended with groups")
+ << listModelSource[i]
+ << QString("items.create({\"number\": \"eight\"}, [\"visible\", \"selected\"])")
+ << 4 << 5 << 4 << true << true << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items create inserted with groups")
+ << listModelSource[i]
+ << QString("items.create(2, {\"number\": \"eight\"}, \"visible\")")
+ << 4 << 5 << 2 << true << true << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended clear persistence")
+ << listModelSource[i]
+ << QString("{ items.create(0, {\"number\": \"eight\"}); "
+ "items.get(0).inPersistedItems = false }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create appended clear persistence")
+ << listModelSource[i]
+ << QString("{ items.create({\"number\": \"eight\"}); "
+ "items.get(4).inPersistedItems = false }")
+ << 4 << 5 << 4 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items create inserted clear persistence")
+ << listModelSource[i]
+ << QString("{ items.create(2, {\"number\": \"eight\"}); "
+ "items.get(2).inPersistedItems = false }")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ // AbstractItemModel (Single Role).
+ QTest::newRow("AbstractItemModel.items prepend")
+ << singleRoleSource[i]
+ << QString("items.insert(0, {\"name\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items append")
+ << singleRoleSource[i]
+ << QString("items.insert({\"name\": \"eight\"})")
+ << 4 << 5 << 4 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("AbstractItemModel.items insert at 2")
+ << singleRoleSource[i]
+ << QString("items.insert(2, {\"name\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items prepend modelData")
+ << singleRoleSource[i]
+ << QString("items.insert(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items prepend, edit name")
+ << singleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"name\": \"eight\"}); "
+ "items.get(0).model.name = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items prepend, edit modelData")
+ << singleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"name\": \"eight\"}); "
+ "items.get(0).model.modelData = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items prepend, edit resolved")
+ << singleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"name\": \"eight\"}); "
+ "items.get(2).model.name = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.create prepend modelData")
+ << singleRoleSource[i]
+ << QString("items.create(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items create prepended, edit name")
+ << singleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"name\": \"eight\"}); "
+ "item.setTest3(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items create prepended, edit model.name")
+ << singleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"name\": \"eight\"}); "
+ "item.setTest4(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items create prepended, edit modelData")
+ << singleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"name\": \"eight\"}); "
+ "item.setTest5(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items create prepended, edit model.modelData")
+ << singleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"name\": \"eight\"}); "
+ "item.setTest6(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ // AbstractItemModel (Multiple Roles).
+ QTest::newRow("StandardItemModel.items prepend")
+ << multipleRoleSource[i]
+ << QString("items.insert(0, {\"display\": \"Row 8 Item\"})")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items append")
+ << multipleRoleSource[i]
+ << QString("items.insert({\"display\": \"Row 8 Item\"})")
+ << 4 << 5 << 4 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item" << "Row 8 Item");
+
+ QTest::newRow("StandardItemModel.items insert at 2")
+ << multipleRoleSource[i]
+ << QString("items.insert(2, {\"display\": \"Row 8 Item\"})")
+ << 4 << 5 << 2 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 8 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items prepend modelData")
+ << multipleRoleSource[i]
+ << QString("items.insert(0, {\"modelData\": \"Row 8 Item\"})")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items prepend, edit display")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"display\": \"Row 8 Item\"}); "
+ "items.get(0).model.display = \"Row 7 Item\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items prepend, edit modelData")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"display\": \"Row 8 Item\"}); "
+ "items.get(0).model.modelData = \"Row 7 Item\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items prepend, edit resolved")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"display\": \"Row 8 Item\"}); "
+ "items.get(2).model.display = \"Row 7 Item\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.create prepend modelData")
+ << multipleRoleSource[i]
+ << QString("items.create(0, {\"modelData\": \"Row 8 Item\"})")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("display")
+ << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items create prepended, edit display")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"display\": \"Row 8 Item\"}); "
+ "item.setTest3(\"Row 7 Item\"); }")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items create prepended, edit model.display")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"display\": \"Row 8 Item\"}); "
+ "item.setTest4(\"Row 7 Item\"); }")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ // StringList.
+ QTest::newRow("StringList.items prepend")
+ << stringListSource[i]
+ << QString("items.insert(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items append")
+ << stringListSource[i]
+ << QString("items.insert({\"modelData\": \"eight\"})")
+ << 4 << 5 << 4 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("StringList.items insert at 2")
+ << stringListSource[i]
+ << QString("items.insert(2, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("StringList.items prepend, edit modelData")
+ << stringListSource[i]
+ << QString("{ "
+ "items.insert(0, {\"modelData\": \"eight\"}); "
+ "items.get(0).model.modelData = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items prepend, edit resolved")
+ << stringListSource[i]
+ << QString("{ "
+ "items.insert(0, {\"modelData\": \"eight\"}); "
+ "items.get(2).model.modelData = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.create prepend modelData")
+ << stringListSource[i]
+ << QString("items.create(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("modelData")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items create prepended, edit modelData")
+ << stringListSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"modelData\": \"eight\"}); "
+ "item.setTest3(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("modelData")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items create prepended, edit model.modelData")
+ << stringListSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"modelData\": \"eight\"}); "
+ "item.setTest4(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("modelData")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ // ObjectList
+ QTest::newRow("ObjectList.items prepend")
+ << objectListSource[i]
+ << QString("items.insert(0, {\"name\": \"Item 8\"})")
+ << 4 << 4 << 4 << false << false << false << false << false
+ << QString("name")
+ << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
+
+ QTest::newRow("ObjectList.items append")
+ << objectListSource[i]
+ << QString("items.insert({\"name\": \"Item 8\"})")
+ << 4 << 4 << 4 << false << false << false << false << false
+ << QString("name")
+ << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
+
+ QTest::newRow("ObjectList.items insert at 2")
+ << objectListSource[i]
+ << QString("items.insert(2, {\"name\": \"Item 8\"})")
+ << 4 << 4 << 4 << false << false << false << false << false
+ << QString("name")
+ << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
+ }
+}
+
+void tst_qquickvisualdatamodel::insert()
+{
+ QFETCH(QUrl, source);
+ QFETCH(QString, expression);
+ QFETCH(int, modelCount);
+ QFETCH(int, visualCount);
+ QFETCH(int, index);
+ QFETCH(bool, inItems);
+ QFETCH(bool, persisted);
+ QFETCH(bool, visible);
+ QFETCH(bool, selected);
+ QFETCH(bool, modelData);
+ QFETCH(QString, property);
+ QFETCH(QStringList, propertyData);
+
+ QQuickCanvas canvas;
+
+ QQmlComponent component(&engine);
+ component.loadUrl(source);
+ QScopedPointer<QObject> object(component.create());
+ QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
+ QVERIFY(listView);
+ listView->setParentItem(canvas.rootItem());
+
+ QQuickItem *contentItem = listView->contentItem();
+ QVERIFY(contentItem);
+
+ QObject *visualModel = listView->findChild<QObject *>("visualModel");
+ QVERIFY(visualModel);
+
+ evaluate<void>(visualModel, expression);
+
+ QCOMPARE(evaluate<int>(listView, "count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "items.count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), persisted ? 1 : 0);
+ QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
+
+ QCOMPARE(propertyData.count(), visualCount);
+ for (int i = 0; i < visualCount; ++i) {
+ int modelIndex = i;
+ if (modelIndex > index)
+ modelIndex -= 1;
+ else if (modelIndex == index)
+ modelIndex = -1;
+
+ const int itemsIndex = inItems || i <= index ? i : i - 1;
+ QString get;
+
+ if (i != index) {
+ get = QString("items.get(%1)").arg(itemsIndex);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "delegate", modelIndex);
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<int>(item, "test1"), modelIndex);
+ QCOMPARE(evaluate<int>(item, "test2"), modelIndex);
+ QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(i));
+ QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(i));
+
+ if (modelData) {
+ QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(i));
+ QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(i));
+ }
+
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), false);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
+
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0);
+ } else if (inItems) {
+ get = QString("items.get(%1)").arg(index);
+ } else if (persisted) {
+ get = "persistedItems.get(0)";
+ } else if (visible) {
+ get = QString("visibleItems.get(%1)").arg(index);
+ } else if (selected) {
+ get = "selectedItems.get(0)";
+ } else {
+ continue;
+ }
+
+ QCOMPARE(evaluate<int>(visualModel, get + ".model.index"), modelIndex);
+
+ QCOMPARE(evaluate<QString>(visualModel, get + ".model." + property), propertyData.at(i));
+
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inItems"), inItems || i != index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inPersistedItems"), persisted && i == index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inVisible"), visible || i != index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inSelected"), selected && i == index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".isUnresolved"), i == index);
+
+ QCOMPARE(evaluate<int>(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0);
+ QCOMPARE(evaluate<int>(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0);
+ }
+
+ QObject *item = 0;
+
+ if (inItems)
+ item = evaluate<QObject *>(visualModel, QString("items.create(%1)").arg(index));
+ else if (persisted)
+ item = evaluate<QObject *>(visualModel, QString("persistedItems.create(%1)").arg(0));
+ else if (visible)
+ item = evaluate<QObject *>(visualModel, QString("visibleItems.create(%1)").arg(index));
+ else if (selected)
+ item = evaluate<QObject *>(visualModel, QString("selectedItems.create(%1)").arg(0));
+ else
+ return;
+
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<int>(item, "test1"), -1);
+ QCOMPARE(evaluate<int>(item, "test2"), -1);
+ QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(index));
+ QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(index));
+
+ if (modelData) {
+ QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(index));
+ QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(index));
+ }
+
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), inItems);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), visible);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), selected);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), true);
+
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), index);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), 0);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), index);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), 0);
+}
+
+void tst_qquickvisualdatamodel::resolve_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("setupExpression");
+ QTest::addColumn<QString>("resolveExpression");
+ QTest::addColumn<int>("unresolvedCount");
+ QTest::addColumn<int>("modelCount");
+ QTest::addColumn<int>("visualCount");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<bool>("inItems");
+ QTest::addColumn<bool>("persisted");
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("selected");
+ QTest::addColumn<bool>("modelData");
+ QTest::addColumn<QString>("property");
+ QTest::addColumn<QStringList>("propertyData");
+
+ const QUrl listModelSource[] = {
+ testFileUrl("listmodelproperties.qml"),
+ testFileUrl("listmodelproperties-package.qml") };
+ const QUrl singleRoleSource[] = {
+ testFileUrl("singleroleproperties.qml"),
+ testFileUrl("singleroleproperties-package.qml") };
+ const QUrl multipleRoleSource[] = {
+ testFileUrl("multipleroleproperties.qml"),
+ testFileUrl("multipleroleproperties-package.qml") };
+ const QUrl stringListSource[] = {
+ testFileUrl("stringlistproperties.qml"),
+ testFileUrl("stringlistproperties-package.qml") };
+ const QUrl objectListSource[] = {
+ testFileUrl("objectlistproperties.qml"),
+ testFileUrl("objectlistproperties-package.qml") };
+
+ for (int i = 0; i < 2; ++i) {
+ // List Model.
+ QTest::newRow("ListModel.items prepend, resolve prepended")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(0, 1) }")
+ << 5 << 5 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, resolve appended")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(0, 5) }")
+ << 5 << 5 << 5 << 4 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.items prepend, resolve inserted")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(0, 3) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items append, resolve prepended")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(5, 0) }")
+ << 5 << 5 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append, resolve appended")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(5, 4) }")
+ << 5 << 5 << 5 << 4 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.items append, resolve inserted")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(5, 2) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, resolve prepended")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(3, 0) }")
+ << 5 << 5 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, resolve appended")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(2, 5) }")
+ << 5 << 5 << 5 << 4 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.items insert, resolve inserted")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(2, 3) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, move resolved")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
+ "items.resolve(0, 1); "
+ "listModel.move(0, 2, 1) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items append, move resolved")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); "
+ "items.resolve(5, 4); "
+ "listModel.move(4, 2, 1) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, move resolved")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
+ "items.resolve(2, 3);"
+ "listModel.move(2, 0, 1) }")
+ << 5 << 5 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, remove resolved")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
+ "items.resolve(0, 1); "
+ "listModel.remove(0, 1) }")
+ << 5 << 4 << 4 << 4 << false << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append, remove resolved")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); "
+ "items.resolve(5, 4); "
+ "listModel.remove(4, 1) }")
+ << 5 << 4 << 4 << 4 << false << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, remove resolved")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
+ "items.resolve(2, 3);"
+ "listModel.remove(2, 1) }")
+ << 5 << 4 << 4 << 4 << false << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems prepend, resolve prepended")
+ << listModelSource[i]
+ << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(0)) }")
+ << 4 << 5 << 5 << 0 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems prepend, resolve appended")
+ << listModelSource[i]
+ << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(4)) }")
+ << 4 << 5 << 5 << 4 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.selectedItems prepend, resolve inserted")
+ << listModelSource[i]
+ << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(2)) }")
+ << 4 << 5 << 5 << 2 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems append, resolve prepended")
+ << listModelSource[i]
+ << QString("selectedItems.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(0)) }")
+ << 4 << 5 << 5 << 0 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems append, resolve appended")
+ << listModelSource[i]
+ << QString("selectedItems.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(4)) }")
+ << 4 << 5 << 5 << 4 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.selectedItems append, resolve inserted")
+ << listModelSource[i]
+ << QString("selectedItems.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(2)) }")
+ << 4 << 5 << 5 << 2 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ // AbstractItemModel (Single Role)
+ QTest::newRow("ListModel.items prepend, resolve prepended")
+ << singleRoleSource[i]
+ << QString("items.insert(0, {\"name\": \"eight\"})")
+ << QString("{ items.resolve(0, 1) }")
+ << 5 << 4 << 4 << 0 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+
+ QTest::newRow("ListModel.items append, resolve appended")
+ << singleRoleSource[i]
+ << QString("items.insert({\"name\": \"eight\"})")
+ << QString("{ items.resolve(4, 3) }")
+ << 5 << 4 << 4 << 3 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, resolve inserted")
+ << singleRoleSource[i]
+ << QString("items.insert(2, {\"name\": \"eight\"})")
+ << QString("{ items.resolve(2, 3) }")
+ << 5 << 4 << 4 << 2 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ // AbstractItemModel (Single Role)
+ QTest::newRow("AbstractItemModel.items prepend, resolve prepended")
+ << singleRoleSource[i]
+ << QString("items.insert(0, {\"name\": \"eight\"})")
+ << QString("{ items.resolve(0, 1) }")
+ << 5 << 4 << 4 << 0 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items append, resolve appended")
+ << singleRoleSource[i]
+ << QString("items.insert({\"name\": \"eight\"})")
+ << QString("{ items.resolve(4, 3) }")
+ << 5 << 4 << 4 << 3 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items insert, resolve inserted")
+ << singleRoleSource[i]
+ << QString("items.insert(2, {\"name\": \"eight\"})")
+ << QString("{ items.resolve(2, 3) }")
+ << 5 << 4 << 4 << 2 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ // AbstractItemModel (Multiple Roles)
+ QTest::newRow("StandardItemModel.items prepend, resolve prepended")
+ << multipleRoleSource[i]
+ << QString("items.insert(0, {\"display\": \"Row 8 Item\"})")
+ << QString("{ items.resolve(0, 1) }")
+ << 5 << 4 << 4 << 0 << true << false << true << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items append, resolve appended")
+ << multipleRoleSource[i]
+ << QString("items.insert({\"display\": \"Row 8 Item\"})")
+ << QString("{ items.resolve(4, 3) }")
+ << 5 << 4 << 4 << 3 << true << false << true << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items insert, resolve inserted")
+ << multipleRoleSource[i]
+ << QString("items.insert(2, {\"display\": \"Row 8 Item\"})")
+ << QString("{ items.resolve(2, 3) }")
+ << 5 << 4 << 4 << 2 << true << false << true << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ // StringList
+ QTest::newRow("StringList.items prepend, resolve prepended")
+ << stringListSource[i]
+ << QString("items.insert(0, {\"modelData\": \"eight\"})")
+ << QString("{ items.resolve(0, 1) }")
+ << 5 << 4 << 4 << 0 << true << false << true << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items append, resolve appended")
+ << stringListSource[i]
+ << QString("items.insert({\"modelData\": \"eight\"})")
+ << QString("{ items.resolve(4, 3) }")
+ << 5 << 4 << 4 << 3 << true << false << true << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items insert, resolve inserted")
+ << stringListSource[i]
+ << QString("items.insert(2, {\"modelData\": \"eight\"})")
+ << QString("{ items.resolve(2, 3) }")
+ << 5 << 4 << 4 << 2 << true << false << true << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "three" << "four");
+ }
+}
+
+void tst_qquickvisualdatamodel::resolve()
+{
+ QFETCH(QUrl, source);
+ QFETCH(QString, setupExpression);
+ QFETCH(QString, resolveExpression);
+ QFETCH(int, unresolvedCount);
+ QFETCH(int, modelCount);
+ QFETCH(int, visualCount);
+ QFETCH(int, index);
+ QFETCH(bool, inItems);
+ QFETCH(bool, persisted);
+ QFETCH(bool, visible);
+ QFETCH(bool, selected);
+ QFETCH(bool, modelData);
+ QFETCH(QString, property);
+ QFETCH(QStringList, propertyData);
+
+ QQuickCanvas canvas;
+
+ QQmlComponent component(&engine);
+ component.loadUrl(source);
+ QScopedPointer<QObject> object(component.create());
+ QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
+ QVERIFY(listView);
+ listView->setParentItem(canvas.rootItem());
+
+ QQuickItem *contentItem = listView->contentItem();
+ QVERIFY(contentItem);
+
+ QObject *visualModel = listView->findChild<QObject *>("visualModel");
+ QVERIFY(visualModel);
+
+ evaluate<void>(visualModel, setupExpression);
+ QCOMPARE(evaluate<int>(listView, "count"), unresolvedCount);
+
+ evaluate<void>(visualModel, resolveExpression);
+
+ QCOMPARE(evaluate<int>(listView, "count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "items.count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), persisted ? 1 : 0);
+ QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
+
+ QCOMPARE(propertyData.count(), visualCount);
+ for (int i = 0; i < visualCount; ++i) {
+ int modelIndex = i;
+
+ const int itemsIndex = inItems || i <= index ? i : i - 1;
+ QString get;
+
+ if (i != index) {
+ get = QString("items.get(%1)").arg(itemsIndex);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "delegate", modelIndex);
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<int>(item, "test1"), modelIndex);
+ QCOMPARE(evaluate<int>(item, "test2"), modelIndex);
+ QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(i));
+ QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(i));
+
+ if (modelData) {
+ QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(i));
+ QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(i));
+ }
+
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), false);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
+
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0);
+ } else if (inItems) {
+ get = QString("items.get(%1)").arg(index);
+ } else if (persisted) {
+ get = "persistedItems.get(0)";
+ } else if (visible) {
+ get = QString("visibleItems.get(%1)").arg(index);
+ } else if (selected) {
+ get = "selectedItems.get(0)";
+ } else {
+ continue;
+ }
+
+ QCOMPARE(evaluate<int>(visualModel, get + ".model.index"), modelIndex);
+
+ QCOMPARE(evaluate<QString>(visualModel, get + ".model." + property), propertyData.at(i));
+
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inItems"), inItems || i != index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inPersistedItems"), persisted && i == index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inVisible"), visible || i != index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inSelected"), selected && i == index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".isUnresolved"), false);
+
+ QCOMPARE(evaluate<int>(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0);
+ QCOMPARE(evaluate<int>(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0);
+ }
+
+ QObject *item = 0;
+
+ if (inItems)
+ item = evaluate<QObject *>(visualModel, QString("items.create(%1)").arg(index));
+ else if (persisted)
+ item = evaluate<QObject *>(visualModel, QString("persistedItems.create(%1)").arg(0));
+ else if (visible)
+ item = evaluate<QObject *>(visualModel, QString("visibleItems.create(%1)").arg(index));
+ else if (selected)
+ item = evaluate<QObject *>(visualModel, QString("selectedItems.create(%1)").arg(0));
+ else
+ return;
+
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<int>(item, "test1"), index);
+ QCOMPARE(evaluate<int>(item, "test2"), index);
+ QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(index));
+ QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(index));
+
+ if (modelData) {
+ QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(index));
+ QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(index));
+ }
+
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), inItems);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), visible);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), selected);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
+
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), index);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), 0);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), index);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), 0);
+}
+
+void tst_qquickvisualdatamodel::warnings_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QString>("warning");
+ QTest::addColumn<int>("count");
+
+ QTest::newRow("insert < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.insert(-2, {\"number\": \"eight\"})")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
+ << 4;
+
+ QTest::newRow("insert > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.insert(8, {\"number\": \"eight\"})")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
+ << 4;
+
+ QTest::newRow("create < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.create(-2, {\"number\": \"eight\"})")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
+ << 4;
+
+ QTest::newRow("create > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.create(8, {\"number\": \"eight\"})")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
+ << 4;
+
+ QTest::newRow("resolve from < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(-2, 3)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
+ << 4;
+
+ QTest::newRow("resolve from > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(8, 3)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
+ << 4;
+
+ QTest::newRow("resolve to < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(3, -2)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
+ << 4;
+
+ QTest::newRow("resolve to > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(3, 8)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
+ << 4;
+
+ QTest::newRow("resolve from invalid index")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(\"two\", 3)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid"))
+ << 4;
+
+ QTest::newRow("resolve to invalid index")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(3, \"two\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid"))
+ << 4;
+
+ QTest::newRow("resolve already resolved item")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(3, 2)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item"))
+ << 4;
+
+ QTest::newRow("resolve already resolved item")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("{ items.insert(0, {\"number\": \"eight\"});"
+ "items.insert(1, {\"number\": \"seven\"});"
+ "items.resolve(0, 1)}")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item"))
+ << 6;
+
+ QTest::newRow("remove index < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(-2, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << 4;
+
+ QTest::newRow("remove index == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(4, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << 4;
+
+ QTest::newRow("remove index > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(9, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << 4;
+
+ QTest::newRow("remove invalid index")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(\"nine\", 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index"))
+ << 4;
+
+ QTest::newRow("remove count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(1, -2)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
+ << 4;
+
+ QTest::newRow("remove index + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(2, 4, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
+ << 4;
+
+ QTest::newRow("addGroups index < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(-2, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("addGroups index == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(4, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("addGroups index > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(9, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("addGroups count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(1, -2, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("addGroups index + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(2, 4, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("removeGroups index < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(-2, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("removeGroups index == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(4, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("removeGroups index > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(9, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("removeGroups count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(1, -2, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("removeGroups index + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(2, 4, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("setGroups index < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(-2, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("setGroups index == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(4, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("setGroups index > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(9, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("setGroups count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(1, -2, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("setGroups index + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(2, 4, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("move from < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(-2, 1, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << 4;
+
+ QTest::newRow("move from == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(4, 1, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << 4;
+
+ QTest::newRow("move from > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(9, 1, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << 4;
+
+ QTest::newRow("move invalid from")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(\"nine\", 1, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index"))
+ << 4;
+
+ QTest::newRow("move to < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, -2, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << 4;
+
+ QTest::newRow("move to == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, 4, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << 4;
+
+ QTest::newRow("move to > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, 9, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << 4;
+
+ QTest::newRow("move invalid to")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, \"nine\", 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index"))
+ << 4;
+
+ QTest::newRow("move count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, 1, -2)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count"))
+ << 4;
+
+ QTest::newRow("move from + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(2, 1, 4)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << 4;
+}
+
+void tst_qquickvisualdatamodel::warnings()
+{
+ QFETCH(QUrl, source);
+ QFETCH(QString, expression);
+ QFETCH(QString, warning);
+ QFETCH(int, count);
+
+ QQuickCanvas canvas;
+
+ QQmlComponent component(&engine);
+ component.loadUrl(source);
+ QScopedPointer<QObject> object(component.create());
+ QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
+ QVERIFY(listView);
+ listView->setParentItem(canvas.rootItem());
+
+ QQuickItem *contentItem = listView->contentItem();
+ QVERIFY(contentItem);
+
+ QObject *visualModel = evaluate<QObject *>(listView, "model");
+ QVERIFY(visualModel);
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
+
+ evaluate<void>(visualModel, expression);
+ QCOMPARE(evaluate<int>(listView, "count"), count);
+}
+
+
+QTEST_MAIN(tst_qquickvisualdatamodel)
+
+#include "tst_qquickvisualdatamodel.moc"
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml b/tests/auto/quick/qquickxmllistmodel/data/empty.xml
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml
+++ b/tests/auto/quick/qquickxmllistmodel/data/empty.xml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml b/tests/auto/quick/qquickxmllistmodel/data/get.qml
index 509da7174b..509da7174b 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/get.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml b/tests/auto/quick/qquickxmllistmodel/data/model.qml
index 2df3927479..2df3927479 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/model.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml b/tests/auto/quick/qquickxmllistmodel/data/model.xml
index 40cd6d0432..40cd6d0432 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml
+++ b/tests/auto/quick/qquickxmllistmodel/data/model.xml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml b/tests/auto/quick/qquickxmllistmodel/data/model2.xml
index dab2ec6dc0..dab2ec6dc0 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml
+++ b/tests/auto/quick/qquickxmllistmodel/data/model2.xml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml
index f8a97bffc3..f8a97bffc3 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml b/tests/auto/quick/qquickxmllistmodel/data/recipes.qml
index dc609e95e3..dc609e95e3 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/recipes.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml b/tests/auto/quick/qquickxmllistmodel/data/recipes.xml
index d71de60710..d71de60710 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml
+++ b/tests/auto/quick/qquickxmllistmodel/data/recipes.xml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml
index 6a7059bb45..6a7059bb45 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml b/tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml
index 91664b6d4a..91664b6d4a 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml
index 9f667d86e5..9f667d86e5 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml b/tests/auto/quick/qquickxmllistmodel/data/testtypes.qml
index 5ec1ffa35f..5ec1ffa35f 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/testtypes.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml b/tests/auto/quick/qquickxmllistmodel/data/unique.qml
index 322a2e4e5c..322a2e4e5c 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/unique.qml
diff --git a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro
new file mode 100644
index 0000000000..b18af50c9e
--- /dev/null
+++ b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickxmllistmodel
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickxmllistmodel.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private network testlib xmlpatterns
diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
new file mode 100644
index 0000000000..4d337564c0
--- /dev/null
+++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
@@ -0,0 +1,962 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtGlobal>
+#include <math.h>
+#include <QMetaObject>
+#include <qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtQml/qqmlnetworkaccessmanagerfactory.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qtemporaryfile.h>
+#include "../../shared/util.h"
+#include <private/qqmlengine_p.h>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qlistmodelinterface_p.h>
+#include "../../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h"
+
+typedef QPair<int, int> QQuickXmlListRange;
+typedef QList<QVariantList> QQmlXmlModelData;
+
+Q_DECLARE_METATYPE(QList<QQuickXmlListRange>)
+Q_DECLARE_METATYPE(QQmlXmlModelData)
+Q_DECLARE_METATYPE(QQuickXmlListModel::Status)
+
+class tst_qquickxmllistmodel : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_qquickxmllistmodel() {}
+
+private slots:
+ void initTestCase() {
+ QQmlDataTest::initTestCase();
+ qRegisterMetaType<QQuickXmlListModel::Status>();
+ }
+
+ void buildModel();
+ void testTypes();
+ void testTypes_data();
+ void cdata();
+ void attributes();
+ void roles();
+ void roleErrors();
+ void uniqueRoleNames();
+ void headers();
+ void xml();
+ void xml_data();
+ void source();
+ void source_data();
+ void data();
+ void get();
+ void reload();
+ void useKeys();
+ void useKeys_data();
+ void noKeysValueChanges();
+ void keysChanged();
+ void threading();
+ void threading_data();
+ void propertyChanges();
+
+ void roleCrash();
+
+private:
+ QString errorString(QListModelInterface* model) {
+ QString ret;
+ QMetaObject::invokeMethod(model, "errorString", Q_RETURN_ARG(QString, ret));
+ return ret;
+ }
+
+ QString makeItemXmlAndData(const QString &data, QQmlXmlModelData *modelData = 0) const
+ {
+ if (modelData)
+ modelData->clear();
+ QString xml;
+
+ if (!data.isEmpty()) {
+ QStringList items = data.split(";");
+ foreach(const QString &item, items) {
+ if (item.isEmpty())
+ continue;
+ QVariantList variants;
+ xml += QLatin1String("<item>");
+ QStringList fields = item.split(",");
+ foreach(const QString &field, fields) {
+ QStringList values = field.split("=");
+ if (values.count() != 2) {
+ qWarning() << "makeItemXmlAndData: invalid field:" << field;
+ continue;
+ }
+ xml += QString("<%1>%2</%1>").arg(values[0], values[1]);
+ if (!modelData)
+ continue;
+ bool isNum = false;
+ int number = values[1].toInt(&isNum);
+ if (isNum)
+ variants << number;
+ else
+ variants << values[1];
+ }
+ xml += QLatin1String("</item>");
+ if (modelData)
+ modelData->append(variants);
+ }
+ }
+
+ QString decl = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>";
+ return decl + QLatin1String("<data>") + xml + QLatin1String("</data>");
+ }
+
+ QQmlEngine engine;
+};
+
+class CustomNetworkAccessManagerFactory : public QObject, public QQmlNetworkAccessManagerFactory
+{
+ Q_OBJECT
+public:
+ QVariantMap lastSentHeaders;
+
+protected:
+ QNetworkAccessManager *create(QObject *parent);
+};
+
+class CustomNetworkAccessManager : public QNetworkAccessManager
+{
+ Q_OBJECT
+public:
+ CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent)
+ : QNetworkAccessManager(parent), m_factory(factory) {}
+
+protected:
+ QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0)
+ {
+ if (m_factory) {
+ QVariantMap map;
+ foreach (const QString &header, req.rawHeaderList())
+ map[header] = req.rawHeader(header.toUtf8());
+ m_factory->lastSentHeaders = map;
+ }
+ return QNetworkAccessManager::createRequest(op, req, outgoingData);
+ }
+
+ QPointer<CustomNetworkAccessManagerFactory> m_factory;
+};
+
+QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent)
+{
+ return new CustomNetworkAccessManager(this, parent);
+}
+
+
+void tst_qquickxmllistmodel::buildModel()
+{
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QCOMPARE(model->data(3, Qt::UserRole).toString(), QLatin1String("Spot"));
+ QCOMPARE(model->data(3, Qt::UserRole+1).toString(), QLatin1String("Dog"));
+ QCOMPARE(model->data(3, Qt::UserRole+2).toInt(), 9);
+ QCOMPARE(model->data(3, Qt::UserRole+3).toString(), QLatin1String("Medium"));
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::testTypes()
+{
+ QFETCH(QString, xml);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, expectedValue);
+
+ QQmlComponent component(&engine, testFileUrl("testtypes.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ model->setProperty("xml",xml.toUtf8());
+ QMetaObject::invokeMethod(model, "reload");
+ QTRY_COMPARE(model->count(), 1);
+
+ int role = -1;
+ foreach (int i, model->roles()) {
+ if (model->toString(i) == roleName) {
+ role = i;
+ break;
+ }
+ }
+ QVERIFY(role >= 0);
+
+ if (expectedValue.toString() == "nan")
+ QVERIFY(qIsNaN(model->data(0, role).toDouble()));
+ else
+ QCOMPARE(model->data(0, role), expectedValue);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::testTypes_data()
+{
+ QTest::addColumn<QString>("xml");
+ QTest::addColumn<QString>("roleName");
+ QTest::addColumn<QVariant>("expectedValue");
+
+ QTest::newRow("missing string field") << "<data></data>"
+ << "stringValue" << QVariant("");
+ QTest::newRow("empty string") << "<data><a-string></a-string></data>"
+ << "stringValue" << QVariant("");
+ QTest::newRow("1-char string") << "<data><a-string>5</a-string></data>"
+ << "stringValue" << QVariant("5");
+ QTest::newRow("string ok") << "<data><a-string>abc def g</a-string></data>"
+ << "stringValue" << QVariant("abc def g");
+
+ QTest::newRow("missing number field") << "<data></data>"
+ << "numberValue" << QVariant("");
+ double nan = qQNaN();
+ QTest::newRow("empty number field") << "<data><a-number></a-number></data>"
+ << "numberValue" << QVariant(nan);
+ QTest::newRow("number field with string") << "<data><a-number>a string</a-number></data>"
+ << "numberValue" << QVariant(nan);
+ QTest::newRow("-1") << "<data><a-number>-1</a-number></data>"
+ << "numberValue" << QVariant("-1");
+ QTest::newRow("-1.5") << "<data><a-number>-1.5</a-number></data>"
+ << "numberValue" << QVariant("-1.5");
+ QTest::newRow("0") << "<data><a-number>0</a-number></data>"
+ << "numberValue" << QVariant("0");
+ QTest::newRow("+1") << "<data><a-number>1</a-number></data>"
+ << "numberValue" << QVariant("1");
+ QTest::newRow("+1.5") << "<data><a-number>1.5</a-number></data>"
+ << "numberValue" << QVariant("1.5");
+}
+
+void tst_qquickxmllistmodel::cdata()
+{
+ QQmlComponent component(&engine, testFileUrl("recipes.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 5);
+
+ QVERIFY(model->data(2, Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::attributes()
+{
+ QQmlComponent component(&engine, testFileUrl("recipes.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 5);
+ QCOMPARE(model->data(2, Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::roles()
+{
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QList<int> roles = model->roles();
+ QCOMPARE(roles.count(), 4);
+ QCOMPARE(model->toString(roles.at(0)), QLatin1String("name"));
+ QCOMPARE(model->toString(roles.at(1)), QLatin1String("type"));
+ QCOMPARE(model->toString(roles.at(2)), QLatin1String("age"));
+ QCOMPARE(model->toString(roles.at(3)), QLatin1String("size"));
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::roleErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("roleErrors.qml"));
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
+
+ //### make sure we receive all expected warning messages.
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+
+ //### should any of these return valid values?
+ QCOMPARE(model->data(3, Qt::UserRole), QVariant());
+ QCOMPARE(model->data(3, Qt::UserRole+1), QVariant());
+ QCOMPARE(model->data(3, Qt::UserRole+2), QVariant());
+
+ QEXPECT_FAIL("", "QTBUG-10797", Continue);
+ QCOMPARE(model->data(3, Qt::UserRole+3), QVariant());
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::uniqueRoleNames()
+{
+ QQmlComponent component(&engine, testFileUrl("unique.qml"));
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QList<int> roles = model->roles();
+ QCOMPARE(roles.count(), 1);
+
+ delete model;
+}
+
+
+void tst_qquickxmllistmodel::xml()
+{
+ QFETCH(QString, xml);
+ QFETCH(int, count);
+
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+
+ QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)));
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Loading);
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ QTest::qWait(50);
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Ready);
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
+ QCOMPARE(model->count(), 9);
+
+ // if xml is empty (i.e. clearing) it won't have any effect if a source is set
+ if (xml.isEmpty())
+ model->setProperty("source",QUrl());
+ model->setProperty("xml",xml);
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); // immediately goes to 1.0 if using setXml()
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Loading);
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ if (xml.isEmpty())
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Null);
+ else
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Ready);
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->count(), count);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::xml_data()
+{
+ QTest::addColumn<QString>("xml");
+ QTest::addColumn<int>("count");
+
+ QTest::newRow("xml with no items") << "<Pets></Pets>" << 0;
+ QTest::newRow("empty xml") << "" << 0;
+ QTest::newRow("one item") << "<Pets><Pet><name>Hobbes</name><type>Tiger</type><age>7</age><size>Large</size></Pet></Pets>" << 1;
+}
+
+void tst_qquickxmllistmodel::headers()
+{
+ // ensure the QNetworkAccessManagers created for this test are immediately deleted
+ QQmlEngine qmlEng;
+
+ CustomNetworkAccessManagerFactory factory;
+ qmlEng.setNetworkAccessManagerFactory(&factory);
+
+ QQmlComponent component(&qmlEng, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Ready);
+
+ QVariantMap expectedHeaders;
+ expectedHeaders["Accept"] = "application/xml,*/*";
+
+ QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count());
+ foreach (const QString &header, expectedHeaders.keys()) {
+ QVERIFY(factory.lastSentHeaders.contains(header));
+ QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString());
+ }
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::source()
+{
+ QFETCH(QUrl, source);
+ QFETCH(int, count);
+ QFETCH(QQuickXmlListModel::Status, status);
+
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)));
+
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Loading);
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Ready);
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
+ QCOMPARE(model->count(), 9);
+
+ model->setProperty("source",source);
+ if (model->property("source").toString().isEmpty())
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Null);
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Loading);
+ QVERIFY(errorString(model).isEmpty());
+
+ QEventLoop loop;
+ QTimer timer;
+ timer.setSingleShot(true);
+ connect(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)), &loop, SLOT(quit()));
+ connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.start(20000);
+ loop.exec();
+
+ if (spy.count() == 0 && status != QQuickXmlListModel::Ready) {
+ qWarning("QQuickXmlListModel invalid source test timed out");
+ } else {
+ QCOMPARE(spy.count(), 1); spy.clear();
+ }
+
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")), status);
+ QCOMPARE(model->count(), count);
+
+ if (status == QQuickXmlListModel::Ready)
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
+
+ QCOMPARE(errorString(model).isEmpty(), status == QQuickXmlListModel::Ready);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::source_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<QQuickXmlListModel::Status>("status");
+
+ QTest::newRow("valid") << testFileUrl("model2.xml") << 2
+ << QQuickXmlListModel::Ready;
+ QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0
+ << QQuickXmlListModel::Error;
+
+ // empty file
+ QTemporaryFile *temp = new QTemporaryFile(this);
+ if (temp->open())
+ QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0
+ << QQuickXmlListModel::Ready;
+ temp->close();
+}
+
+void tst_qquickxmllistmodel::data()
+{
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+
+ for (int i=0; i<9; i++) {
+ for (int j=0; j<model->roles().count(); j++) {
+ QCOMPARE(model->data(i, j), QVariant());
+ }
+ }
+ QTRY_COMPARE(model->count(), 9);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::get()
+{
+ QQmlComponent component(&engine, testFileUrl("get.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+
+ QVERIFY(model != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(model, "runPreTest"));
+ QCOMPARE(model->property("preTest").toBool(), true);
+
+ QTRY_COMPARE(model->count(), 9);
+
+ QVERIFY(QMetaObject::invokeMethod(model, "runPostTest"));
+ QCOMPARE(model->property("postTest").toBool(), true);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::reload()
+{
+ // If no keys are used, the model should be rebuilt from scratch when
+ // reload() is called.
+
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+ //reload multiple times to test the xml query aborting
+ QMetaObject::invokeMethod(model, "reload");
+ QMetaObject::invokeMethod(model, "reload");
+ QCoreApplication::processEvents();
+ QMetaObject::invokeMethod(model, "reload");
+ QMetaObject::invokeMethod(model, "reload");
+ QTRY_COMPARE(spyCount.count(), 1);
+ QTRY_COMPARE(spyInsert.count(), 1);
+ QTRY_COMPARE(spyRemove.count(), 1);
+
+ QCOMPARE(spyInsert[0][0].toInt(), 0);
+ QCOMPARE(spyInsert[0][1].toInt(), 9);
+
+ QCOMPARE(spyRemove[0][0].toInt(), 0);
+ QCOMPARE(spyRemove[0][1].toInt(), 9);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::useKeys()
+{
+ // If using incremental updates through keys, the model should only
+ // insert & remove some of the items, instead of throwing everything
+ // away and causing the view to repaint the whole view.
+
+ QFETCH(QString, oldXml);
+ QFETCH(int, oldCount);
+ QFETCH(QString, newXml);
+ QFETCH(QQmlXmlModelData, newData);
+ QFETCH(QList<QQuickXmlListRange>, insertRanges);
+ QFETCH(QList<QQuickXmlListRange>, removeRanges);
+
+ QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+
+ model->setProperty("xml",oldXml);
+ QTRY_COMPARE(model->count(), oldCount);
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ model->setProperty("xml",newXml);
+
+ if (oldCount != newData.count()) {
+ QTRY_COMPARE(model->count(), newData.count());
+ QCOMPARE(spyCount.count(), 1);
+ } else {
+ QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0);
+ QCOMPARE(spyCount.count(), 0);
+ }
+
+ QList<int> roles = model->roles();
+ for (int i=0; i<model->count(); i++) {
+ for (int j=0; j<roles.count(); j++)
+ QCOMPARE(model->data(i, roles[j]), newData[i][j]);
+ }
+
+ QCOMPARE(spyInsert.count(), insertRanges.count());
+ for (int i=0; i<spyInsert.count(); i++) {
+ QCOMPARE(spyInsert[i][0].toInt(), insertRanges[i].first);
+ QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].second);
+ }
+
+ QCOMPARE(spyRemove.count(), removeRanges.count());
+ for (int i=0; i<spyRemove.count(); i++) {
+ QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first);
+ QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second);
+ }
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::useKeys_data()
+{
+ QTest::addColumn<QString>("oldXml");
+ QTest::addColumn<int>("oldCount");
+ QTest::addColumn<QString>("newXml");
+ QTest::addColumn<QQmlXmlModelData>("newData");
+ QTest::addColumn<QList<QQuickXmlListRange> >("insertRanges");
+ QTest::addColumn<QList<QQuickXmlListRange> >("removeRanges");
+
+ QQmlXmlModelData modelData;
+
+ QTest::newRow("append 1")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 1))
+ << QList<QQuickXmlListRange>();
+
+ QTest::newRow("append multiple")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 2))
+ << QList<QQuickXmlListRange>();
+
+ QTest::newRow("insert in different spots")
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2))
+ << QList<QQuickXmlListRange>();
+
+ QTest::newRow("insert in middle")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 2))
+ << QList<QQuickXmlListRange>();
+
+ QTest::newRow("remove first")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData)
+ << modelData
+ << QList<QQuickXmlListRange>()
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1));
+
+ QTest::newRow("remove last")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
+ << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData)
+ << modelData
+ << QList<QQuickXmlListRange>()
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 1));
+
+ QTest::newRow("remove from multiple spots")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData)
+ << modelData
+ << QList<QQuickXmlListRange>()
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 1) << qMakePair(3,2));
+
+ QTest::newRow("remove all")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
+ << makeItemXmlAndData("", &modelData)
+ << modelData
+ << QList<QQuickXmlListRange>()
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 3));
+
+ QTest::newRow("replace item")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1))
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1));
+
+ QTest::newRow("add and remove simultaneously, in different spots")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 1))
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2));
+
+ QTest::newRow("insert at start, remove at end i.e. rss feed")
+ << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 2))
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 2));
+
+ QTest::newRow("remove at start, insert at end")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
+ << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 2))
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 2));
+
+ QTest::newRow("all data has changed")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2
+ << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 2))
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 2));
+}
+
+void tst_qquickxmllistmodel::noKeysValueChanges()
+{
+ // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml.
+ // If a 'sport' value is changed, the model should not be reloaded,
+ // since 'sport' is not marked as a key.
+
+ QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+
+ QString xml;
+
+ xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
+ model->setProperty("xml",xml);
+ QTRY_COMPARE(model->count(), 2);
+
+ model->setProperty("xml","");
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics");
+ model->setProperty("xml",xml);
+
+ // wait for the new xml data to be set, and verify no signals were emitted
+ QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football"));
+ QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules"));
+
+ QVERIFY(spyInsert.count() == 0);
+ QVERIFY(spyRemove.count() == 0);
+ QVERIFY(spyCount.count() == 0);
+
+ QCOMPARE(model->count(), 2);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::keysChanged()
+{
+ // If the key roles change, the next time the data is reloaded, it should
+ // delete all its data and build a clean model (i.e. same behaviour as
+ // if no keys are set).
+
+ QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+
+ QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
+ model->setProperty("xml",xml);
+ QTRY_COMPARE(model->count(), 2);
+
+ model->setProperty("xml","");
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey"));
+ model->setProperty("xml",xml);
+
+ QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0);
+
+ QCOMPARE(spyInsert.count(), 1);
+ QCOMPARE(spyInsert[0][0].toInt(), 0);
+ QCOMPARE(spyInsert[0][1].toInt(), 2);
+
+ QCOMPARE(spyRemove.count(), 1);
+ QCOMPARE(spyRemove[0][0].toInt(), 0);
+ QCOMPARE(spyRemove[0][1].toInt(), 2);
+
+ QCOMPARE(spyCount.count(), 0);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::threading()
+{
+ QFETCH(int, xmlDataCount);
+
+ QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
+
+ QListModelInterface *m1 = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(m1 != 0);
+ QListModelInterface *m2 = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(m2 != 0);
+ QListModelInterface *m3 = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(m3 != 0);
+
+ for (int dataCount=0; dataCount<xmlDataCount; dataCount++) {
+
+ QString data1, data2, data3;
+ for (int i=0; i<dataCount; i++) {
+ data1 += "name=A" + QString::number(i) + ",age=1" + QString::number(i) + ",sport=Football;";
+ data2 += "name=B" + QString::number(i) + ",age=2" + QString::number(i) + ",sport=Athletics;";
+ data3 += "name=C" + QString::number(i) + ",age=3" + QString::number(i) + ",sport=Curling;";
+ }
+
+ //Set the xml data multiple times with randomized order and mixed with multiple event loops
+ //to test the xml query reloading/aborting, the result should be stable.
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ QCoreApplication::processEvents();
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ QCoreApplication::processEvents();
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ QCoreApplication::processEvents();
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ QCoreApplication::processEvents();
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ QCoreApplication::processEvents();
+
+ QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount);
+
+ for (int i=0; i<dataCount; i++) {
+ QCOMPARE(m1->data(i, m1->roles()[0]).toString(), QString("A" + QString::number(i)));
+ QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i)));
+ QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football"));
+
+ QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i)));
+ QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i)));
+ QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics"));
+
+ QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i)));
+ QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i)));
+ QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling"));
+ }
+ }
+
+ delete m1;
+ delete m2;
+ delete m3;
+}
+
+void tst_qquickxmllistmodel::threading_data()
+{
+ QTest::addColumn<int>("xmlDataCount");
+
+ QTest::newRow("1") << 1;
+ QTest::newRow("2") << 2;
+ QTest::newRow("10") << 10;
+}
+
+void tst_qquickxmllistmodel::propertyChanges()
+{
+ QQmlComponent component(&engine, testFileUrl("propertychanges.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QObject *role = model->findChild<QObject*>("role");
+ QVERIFY(role);
+
+ QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
+ QSignalSpy querySpy(role, SIGNAL(queryChanged()));
+ QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
+
+ role->setProperty("name","size");
+ role->setProperty("query","size/string()");
+ role->setProperty("isKey",true);
+
+ QCOMPARE(role->property("name").toString(), QString("size"));
+ QCOMPARE(role->property("query").toString(), QString("size/string()"));
+ QVERIFY(role->property("isKey").toBool());
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ role->setProperty("name","size");
+ role->setProperty("query","size/string()");
+ role->setProperty("isKey",true);
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ QSignalSpy sourceSpy(model, SIGNAL(sourceChanged()));
+ QSignalSpy xmlSpy(model, SIGNAL(xmlChanged()));
+ QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
+ QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
+
+ model->setProperty("source",QUrl(""));
+ model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setProperty("query","/Pets");
+ model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(model->property("source").toUrl(), QUrl(""));
+ QCOMPARE(model->property("xml").toString(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
+ QCOMPARE(model->property("query").toString(), QString("/Pets"));
+ QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
+
+ QTRY_VERIFY(model->count() == 1);
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+
+ model->setProperty("source",QUrl(""));
+ model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setProperty("query","/Pets");
+ model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+
+ QTRY_VERIFY(model->count() == 1);
+ delete model;
+}
+
+void tst_qquickxmllistmodel::roleCrash()
+{
+ // don't crash
+ QQmlComponent component(&engine, testFileUrl("roleCrash.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ delete model;
+}
+
+QTEST_MAIN(tst_qquickxmllistmodel)
+
+#include "tst_qquickxmllistmodel.moc"
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
new file mode 100644
index 0000000000..4065dbf508
--- /dev/null
+++ b/tests/auto/quick/quick.pro
@@ -0,0 +1,75 @@
+TEMPLATE = subdirs
+
+PUBLICTESTS += \
+ examples \
+ geometry \
+ nodes \
+ rendernode \
+ qquickpixmapcache
+
+# This test requires the qtconcurrent module
+!contains(QT_CONFIG, concurrent):PUBLICTESTS -= qquickpixmapcache
+
+PRIVATETESTS += \
+ qquickanimations \
+ qquickapplication \
+ qquickbehaviors \
+ qquickfontloader \
+ qquickpath \
+ qquicksmoothedanimation \
+ qquickspringanimation \
+ qquickstyledtext \
+ qquickstates \
+ qquicksystempalette \
+ qquicktimer \
+ qquickxmllistmodel
+
+# This test requires the xmlpatterns module
+!contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qquickxmllistmodel
+
+# FIXME
+# qquickdroparea is disabled because it depends on changes that
+# have not been merged from qtbase/master to qtbase/api_changes yet:
+ #qquickdroparea \
+
+QUICKTESTS = \
+ qquickaccessible \
+ qquickanchors \
+ qquickanimatedimage \
+ qquickanimatedsprite \
+ qquickborderimage \
+ qquickcanvas \
+ qquickdrag \
+ qquickflickable \
+ qquickflipable \
+ qquickfocusscope \
+ qquickgridview \
+ qquickimage \
+ qquickitem \
+ qquickitem2 \
+ qquickitemlayer \
+ qquicklistview \
+ qquickloader \
+ qquickmousearea \
+ qquickmultipointtoucharea \
+ qquickpathview \
+ qquickpincharea \
+ qquickpositioners \
+ qquickrepeater \
+ qquickshadereffect \
+ qquickspritesequence \
+ qquicktext \
+ qquicktextedit \
+ qquicktextinput \
+ qquickvisualdatamodel \
+ qquickview \
+ qquickcanvasitem \
+ qquickscreen \
+
+
+SUBDIRS += $$PUBLICTESTS
+
+contains(QT_CONFIG, private_tests) {
+ SUBDIRS += $$PRIVATETESTS
+ SUBDIRS += $$QUICKTESTS
+}
diff --git a/tests/auto/qtquick2/rendernode/data/MessUpState.qml b/tests/auto/quick/rendernode/data/MessUpState.qml
index 58f6e80a2c..58f6e80a2c 100644
--- a/tests/auto/qtquick2/rendernode/data/MessUpState.qml
+++ b/tests/auto/quick/rendernode/data/MessUpState.qml
diff --git a/tests/auto/qtquick2/rendernode/data/RenderOrder.qml b/tests/auto/quick/rendernode/data/RenderOrder.qml
index 3342756e06..3342756e06 100644
--- a/tests/auto/qtquick2/rendernode/data/RenderOrder.qml
+++ b/tests/auto/quick/rendernode/data/RenderOrder.qml
diff --git a/tests/auto/quick/rendernode/rendernode.pro b/tests/auto/quick/rendernode/rendernode.pro
new file mode 100644
index 0000000000..8484d591e5
--- /dev/null
+++ b/tests/auto/quick/rendernode/rendernode.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_rendernode
+SOURCES += tst_rendernode.cpp
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+include(../../shared/util.pri)
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private testlib
+
+OTHER_FILES += \
+ data/RenderOrder.qml \
+ data/MessUpState.qml \
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp
new file mode 100644
index 0000000000..b456a5980e
--- /dev/null
+++ b/tests/auto/quick/rendernode/tst_rendernode.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtGui/qopenglcontext.h>
+#include <private/qsgrendernode_p.h>
+
+#include "../../shared/util.h"
+
+class tst_rendernode: public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_rendernode();
+
+ QImage runTest(const QString &url)
+ {
+ QQuickView view;
+ view.setSource(QUrl(url));
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ return view.grabFrameBuffer();
+ }
+
+private slots:
+ void renderOrder();
+ void messUpState();
+};
+
+class ClearNode : public QSGRenderNode
+{
+public:
+ virtual StateFlags changedStates()
+ {
+ return ColorState;
+ }
+
+ virtual void render(const RenderState &)
+ {
+ // If clip has been set, scissoring will make sure the right area is cleared.
+ glClearColor(color.redF(), color.greenF(), color.blueF(), 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+
+ QColor color;
+};
+
+class ClearItem : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+public:
+ ClearItem() : m_color(Qt::black)
+ {
+ setFlag(ItemHasContents, true);
+ }
+
+ QColor color() const { return m_color; }
+ void setColor(const QColor &color)
+ {
+ if (color == m_color)
+ return;
+ m_color = color;
+ emit colorChanged();
+ }
+
+protected:
+ virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+ {
+ ClearNode *node = static_cast<ClearNode *>(oldNode);
+ if (!node)
+ node = new ClearNode;
+ node->color = m_color;
+ return node;
+ }
+
+Q_SIGNALS:
+ void colorChanged();
+
+private:
+ QColor m_color;
+};
+
+class MessUpNode : public QSGRenderNode
+{
+public:
+ virtual StateFlags changedStates()
+ {
+ return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState
+ | CullState | ViewportState;
+ }
+
+ virtual void render(const RenderState &)
+ {
+ // Don't draw anything, just mess up the state
+ glViewport(10, 10, 10, 10);
+ glDisable(GL_SCISSOR_TEST);
+ glDepthMask(true);
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_EQUAL);
+#if defined(QT_OPENGL_ES)
+ glClearDepthf(1);
+#else
+ glClearDepth(1);
+#endif
+ glClearStencil(42);
+ glClearColor(1.0f, 0.5f, 1.0f, 0.0f);
+ glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(190, 190, 10, 10);
+ glStencilFunc(GL_EQUAL, 28, 0xff);
+ glBlendFunc(GL_ZERO, GL_ZERO);
+ GLint frontFace;
+ glGetIntegerv(GL_FRONT_FACE, &frontFace);
+ glFrontFace(frontFace == GL_CW ? GL_CCW : GL_CW);
+ glEnable(GL_CULL_FACE);
+ }
+};
+
+class MessUpItem : public QQuickItem
+{
+ Q_OBJECT
+public:
+ MessUpItem()
+ {
+ setFlag(ItemHasContents, true);
+ }
+
+protected:
+ virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+ {
+ MessUpNode *node = static_cast<MessUpNode *>(oldNode);
+ if (!node)
+ node = new MessUpNode;
+ return node;
+ }
+};
+
+tst_rendernode::tst_rendernode()
+{
+ qmlRegisterType<ClearItem>("Test", 1, 0, "ClearItem");
+ qmlRegisterType<MessUpItem>("Test", 1, 0, "MessUpItem");
+}
+
+static void fuzzyCompareColor(QRgb x, QRgb y)
+{
+ QVERIFY(qAbs(qRed(x) - qRed(y)) < 4);
+ QVERIFY(qAbs(qGreen(x) - qGreen(y)) < 4);
+ QVERIFY(qAbs(qBlue(x) - qBlue(y)) < 4);
+}
+
+void tst_rendernode::renderOrder()
+{
+ QImage fb = runTest(testFile("RenderOrder.qml"));
+ int x1 = fb.width() / 8;
+ int x2 = fb.width() * 3 / 8;
+ int x3 = fb.width() * 5 / 8;
+ int x4 = fb.width() * 7 / 8;
+ int y1 = fb.height() / 8;
+ int y2 = fb.height() * 3 / 8;
+ int y3 = fb.height() * 5 / 8;
+ int y4 = fb.height() * 7 / 8;
+
+ fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00));
+ QCOMPARE(fb.pixel(x2, y2), qRgb(0xff, 0xff, 0xff));
+ QCOMPARE(fb.pixel(x3, y2), qRgb(0x00, 0x00, 0xff));
+ QCOMPARE(fb.pixel(x4, y1), qRgb(0x00, 0x00, 0xff));
+ QCOMPARE(fb.pixel(x1, y4), qRgb(0xff, 0x00, 0x00));
+ QCOMPARE(fb.pixel(x2, y3), qRgb(0xff, 0xff, 0xff));
+ fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff));
+ fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f));
+}
+
+void tst_rendernode::messUpState()
+{
+ QImage fb = runTest(testFile("MessUpState.qml"));
+ int x1 = 0;
+ int x2 = fb.width() / 2;
+ int x3 = fb.width() - 1;
+ int y1 = 0;
+ int y2 = fb.height() * 3 / 16;
+ int y3 = fb.height() / 2;
+ int y4 = fb.height() * 13 / 16;
+ int y5 = fb.height() - 1;
+
+ QCOMPARE(fb.pixel(x1, y3), qRgb(0xff, 0xff, 0xff));
+ QCOMPARE(fb.pixel(x3, y3), qRgb(0xff, 0xff, 0xff));
+
+ QCOMPARE(fb.pixel(x2, y1), qRgb(0x00, 0x00, 0x00));
+ QCOMPARE(fb.pixel(x2, y2), qRgb(0x00, 0x00, 0x00));
+ fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f));
+ QCOMPARE(fb.pixel(x2, y4), qRgb(0x00, 0x00, 0x00));
+ QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00));
+}
+
+
+QTEST_MAIN(tst_rendernode)
+
+#include "tst_rendernode.moc"
diff --git a/tests/auto/quick/shared/util.pri b/tests/auto/quick/shared/util.pri
new file mode 100644
index 0000000000..aa79c7ca98
--- /dev/null
+++ b/tests/auto/quick/shared/util.pri
@@ -0,0 +1,7 @@
+
+HEADERS += $$PWD/visualtestutil.h \
+ $$PWD/viewtestutil.h
+SOURCES += $$PWD/visualtestutil.cpp \
+ $$PWD/viewtestutil.cpp
+
+DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
new file mode 100644
index 0000000000..d00a0e2a96
--- /dev/null
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -0,0 +1,493 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "viewtestutil.h"
+
+#include <QtQuick/QQuickView>
+
+#include <QtTest/QTest>
+
+template<typename T>
+static void qquickmodelviewstestutil_move(int from, int to, int n, T *items)
+{
+ if (from > to) {
+ // Only move forwards - flip if backwards moving
+ int tfrom = from;
+ int tto = to;
+ from = tto;
+ to = tto+n;
+ n = tfrom-tto;
+ }
+
+ T replaced;
+ int i=0;
+ typename T::ConstIterator it=items->begin(); it += from+n;
+ for (; i<to-from; ++i,++it)
+ replaced.append(*it);
+ i=0;
+ it=items->begin(); it += from;
+ for (; i<n; ++i,++it)
+ replaced.append(*it);
+ typename T::ConstIterator f=replaced.begin();
+ typename T::Iterator t=items->begin(); t += from;
+ for (; f != replaced.end(); ++f, ++t)
+ *t = *f;
+}
+
+QQuickView *QQuickViewTestUtil::createView()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ return canvas;
+}
+
+void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration)
+{
+ const int pointCount = 5;
+ QPoint diff = to - from;
+
+ // send press, five equally spaced moves, and release.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, from);
+
+ for (int i = 0; i < pointCount; ++i) {
+ QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ QTest::qWait(duration/pointCount);
+ QCoreApplication::processEvents();
+ }
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, to);
+ QTest::qWait(50);
+}
+
+QList<int> QQuickViewTestUtil::adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count)
+{
+ QList<int> result;
+ for (int i=0; i<indexes.count(); i++) {
+ int num = indexes[i];
+ if (num >= index) {
+ num += count;
+ }
+ result << num;
+ }
+ return result;
+}
+
+QList<int> QQuickViewTestUtil::adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count)
+{
+ QList<int> result;
+ for (int i=0; i<indexes.count(); i++) {
+ int num = indexes[i];
+ if (from < to) {
+ if (num >= from && num < from + count)
+ num += (to - from); // target
+ else if (num >= from && num < to + count)
+ num -= count; // displaced
+ } else if (from > to) {
+ if (num >= from && num < from + count)
+ num -= (from - to); // target
+ else if (num >= to && num < from + count)
+ num += count; // displaced
+ }
+ result << num;
+ }
+ return result;
+}
+
+QList<int> QQuickViewTestUtil::adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count)
+{
+ QList<int> result;
+ for (int i=0; i<indexes.count(); i++) {
+ int num = indexes[i];
+ if (num >= index)
+ num -= count;
+ result << num;
+ }
+ return result;
+}
+
+
+QQuickViewTestUtil::QmlListModel::QmlListModel(QObject *parent)
+ : QListModelInterface(parent)
+{
+}
+
+QQuickViewTestUtil::QmlListModel::~QmlListModel()
+{
+}
+
+QString QQuickViewTestUtil::QmlListModel::name(int index) const
+{
+ return list.at(index).first;
+}
+
+QString QQuickViewTestUtil::QmlListModel::number(int index) const
+{
+ return list.at(index).second;
+}
+
+int QQuickViewTestUtil::QmlListModel::count() const
+{
+ return list.count();
+}
+
+QList<int> QQuickViewTestUtil::QmlListModel::roles() const
+{
+ return QList<int>() << Name << Number;
+}
+
+QString QQuickViewTestUtil::QmlListModel::toString(int role) const
+{
+ switch (role) {
+ case Name:
+ return "name";
+ case Number:
+ return "number";
+ default:
+ return "";
+ }
+}
+
+QVariant QQuickViewTestUtil::QmlListModel::data(int index, int role) const
+{
+ if (role==0)
+ return list.at(index).first;
+ if (role==1)
+ return list.at(index).second;
+ return QVariant();
+}
+
+QHash<int, QVariant> QQuickViewTestUtil::QmlListModel::data(int index, const QList<int> &roles) const
+{
+ QHash<int,QVariant> returnHash;
+
+ for (int i = 0; i < roles.size(); ++i) {
+ int role = roles.at(i);
+ QVariant info;
+ switch (role) {
+ case Name:
+ info = list.at(index).first;
+ break;
+ case Number:
+ info = list.at(index).second;
+ break;
+ default:
+ break;
+ }
+ returnHash.insert(role, info);
+ }
+ return returnHash;
+}
+
+void QQuickViewTestUtil::QmlListModel::addItem(const QString &name, const QString &number)
+{
+ list.append(QPair<QString,QString>(name, number));
+ emit itemsInserted(list.count()-1, 1);
+}
+
+void QQuickViewTestUtil::QmlListModel::insertItem(int index, const QString &name, const QString &number)
+{
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit itemsInserted(index, 1);
+}
+
+void QQuickViewTestUtil::QmlListModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
+{
+ for (int i=0; i<items.count(); i++)
+ list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
+ emit itemsInserted(index, items.count());
+}
+
+void QQuickViewTestUtil::QmlListModel::removeItem(int index)
+{
+ list.removeAt(index);
+ emit itemsRemoved(index, 1);
+}
+
+void QQuickViewTestUtil::QmlListModel::removeItems(int index, int count)
+{
+ int c = count;
+ while (c--)
+ list.removeAt(index);
+ emit itemsRemoved(index, count);
+}
+
+void QQuickViewTestUtil::QmlListModel::moveItem(int from, int to)
+{
+ list.move(from, to);
+ emit itemsMoved(from, to, 1);
+}
+
+void QQuickViewTestUtil::QmlListModel::moveItems(int from, int to, int count)
+{
+ qquickmodelviewstestutil_move(from, to, count, &list);
+ emit itemsMoved(from, to, count);
+}
+
+void QQuickViewTestUtil::QmlListModel::modifyItem(int index, const QString &name, const QString &number)
+{
+ list[index] = QPair<QString,QString>(name, number);
+ emit itemsChanged(index, 1, roles());
+}
+
+void QQuickViewTestUtil::QmlListModel::clear() {
+ int count = list.count();
+ list.clear();
+ emit itemsRemoved(0, count);
+}
+
+void QQuickViewTestUtil::QmlListModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
+ for (int i=0; i<other.count(); i++) {
+ QVERIFY2(list.contains(other[i]),
+ QTest::toString(other[i].first + " " + other[i].second + " " + error1));
+ }
+ for (int i=0; i<list.count(); i++) {
+ QVERIFY2(other.contains(list[i]),
+ QTest::toString(list[i].first + " " + list[i].second + " " + error2));
+ }
+}
+
+
+QQuickViewTestUtil::QaimModel::QaimModel(QObject *parent)
+ : QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+}
+
+int QQuickViewTestUtil::QaimModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+ return list.count();
+}
+
+QVariant QQuickViewTestUtil::QaimModel::data(const QModelIndex &index, int role) const
+{
+ QVariant rv;
+ if (role == Name)
+ rv = list.at(index.row()).first;
+ else if (role == Number)
+ rv = list.at(index.row()).second;
+
+ return rv;
+}
+
+int QQuickViewTestUtil::QaimModel::count() const
+{
+ return rowCount();
+}
+
+QString QQuickViewTestUtil::QaimModel::name(int index) const
+{
+ return list.at(index).first;
+}
+
+QString QQuickViewTestUtil::QaimModel::number(int index) const
+{
+ return list.at(index).second;
+}
+
+void QQuickViewTestUtil::QaimModel::addItem(const QString &name, const QString &number)
+{
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+}
+
+void QQuickViewTestUtil::QaimModel::addItems(const QList<QPair<QString, QString> > &items)
+{
+ emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1);
+ for (int i=0; i<items.count(); i++)
+ list.append(QPair<QString,QString>(items[i].first, items[i].second));
+ emit endInsertRows();
+}
+
+void QQuickViewTestUtil::QaimModel::insertItem(int index, const QString &name, const QString &number)
+{
+ emit beginInsertRows(QModelIndex(), index, index);
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit endInsertRows();
+}
+
+void QQuickViewTestUtil::QaimModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
+{
+ emit beginInsertRows(QModelIndex(), index, index+items.count()-1);
+ for (int i=0; i<items.count(); i++)
+ list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
+ emit endInsertRows();
+}
+
+void QQuickViewTestUtil::QaimModel::removeItem(int index)
+{
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::removeItems(int index, int count)
+{
+ emit beginRemoveRows(QModelIndex(), index, index+count-1);
+ while (count--)
+ list.removeAt(index);
+ emit endRemoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::moveItem(int from, int to)
+{
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::moveItems(int from, int to, int count)
+{
+ emit beginMoveRows(QModelIndex(), from, from+count-1, QModelIndex(), to > from ? to+count : to);
+ qquickmodelviewstestutil_move(from, to, count, &list);
+ emit endMoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::modifyItem(int idx, const QString &name, const QString &number)
+{
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+}
+
+void QQuickViewTestUtil::QaimModel::clear()
+{
+ int count = list.count();
+ emit beginRemoveRows(QModelIndex(), 0, count-1);
+ list.clear();
+ emit endRemoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::reset()
+{
+ emit beginResetModel();
+ emit endResetModel();
+}
+
+void QQuickViewTestUtil::QaimModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
+ for (int i=0; i<other.count(); i++) {
+ QVERIFY2(list.contains(other[i]),
+ QTest::toString(other[i].first + " " + other[i].second + " " + error1));
+ }
+ for (int i=0; i<list.count(); i++) {
+ QVERIFY2(other.contains(list[i]),
+ QTest::toString(list[i].first + " " + list[i].second + " " + error2));
+ }
+}
+
+
+
+QQuickViewTestUtil::ListRange::ListRange()
+ : valid(false)
+{
+}
+
+QQuickViewTestUtil::ListRange::ListRange(const ListRange &other)
+ : valid(other.valid)
+{
+ indexes = other.indexes;
+}
+
+QQuickViewTestUtil::ListRange::ListRange(int start, int end)
+ : valid(true)
+{
+ for (int i=start; i<=end; i++)
+ indexes << i;
+}
+
+QQuickViewTestUtil::ListRange::~ListRange()
+{
+}
+
+QQuickViewTestUtil::ListRange QQuickViewTestUtil::ListRange::operator+(const ListRange &other) const
+{
+ if (other == *this)
+ return *this;
+ ListRange a(*this);
+ a.indexes.append(other.indexes);
+ return a;
+}
+
+bool QQuickViewTestUtil::ListRange::operator==(const ListRange &other) const
+{
+ return indexes.toSet() == other.indexes.toSet();
+}
+
+bool QQuickViewTestUtil::ListRange::operator!=(const ListRange &other) const
+{
+ return !(*this == other);
+}
+
+bool QQuickViewTestUtil::ListRange::isValid() const
+{
+ return valid;
+}
+
+int QQuickViewTestUtil::ListRange::count() const
+{
+ return indexes.count();
+}
+
+QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QmlListModel &model)
+{
+ QList<QPair<QString,QString> > data;
+ if (!valid)
+ return data;
+ for (int i=0; i<indexes.count(); i++)
+ data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
+ return data;
+}
+
+QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QaimModel &model)
+{
+ QList<QPair<QString,QString> > data;
+ if (!valid)
+ return data;
+ for (int i=0; i<indexes.count(); i++)
+ data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
+ return data;
+}
+
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
new file mode 100644
index 0000000000..6ab754cff6
--- /dev/null
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKVIEWTESTUTIL_H
+#define QQUICKVIEWTESTUTIL_H
+
+#include <QtQuick/QQuickItem>
+#include <QtQml/QQmlExpression>
+#include <QtQml/private/qlistmodelinterface_p.h>
+#include <QtCore/QAbstractListModel>
+
+QT_FORWARD_DECLARE_CLASS(QQuickView)
+
+namespace QQuickViewTestUtil
+{
+ QQuickView *createView();
+
+ void flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration);
+
+ QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count);
+ QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count);
+ QList<int> adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count);
+
+ struct ListChange {
+ enum { Inserted, Removed, Moved, SetCurrent, SetContentY } type;
+ int index;
+ int count;
+ int to; // Move
+ qreal pos; // setContentY
+
+ static ListChange insert(int index, int count = 1) { ListChange c = { Inserted, index, count, -1, 0.0 }; return c; }
+ static ListChange remove(int index, int count = 1) { ListChange c = { Removed, index, count, -1, 0.0 }; return c; }
+ static ListChange move(int index, int to, int count) { ListChange c = { Moved, index, count, to, 0.0 }; return c; }
+ static ListChange setCurrent(int index) { ListChange c = { SetCurrent, index, -1, -1, 0.0 }; return c; }
+ static ListChange setContentY(qreal pos) { ListChange c = { SetContentY, -1, -1, -1, pos }; return c; }
+ };
+
+ class QmlListModel : public QListModelInterface
+ {
+ Q_OBJECT
+ public:
+ QmlListModel(QObject *parent = 0);
+ ~QmlListModel();
+
+ enum Roles { Name, Number };
+
+ QString name(int index) const;
+ QString number(int index) const;
+
+ int count() const;
+
+ QList<int> roles() const;
+ QString toString(int role) const;
+
+ QVariant data(int index, int role) const;
+ QHash<int, QVariant> data(int index, const QList<int> &roles) const;
+
+ Q_INVOKABLE void addItem(const QString &name, const QString &number);
+ void insertItem(int index, const QString &name, const QString &number);
+ void insertItems(int index, const QList<QPair<QString, QString> > &items);
+
+ void removeItem(int index);
+ void removeItems(int index, int count);
+
+ void moveItem(int from, int to);
+ void moveItems(int from, int to, int count);
+
+ void modifyItem(int index, const QString &name, const QString &number);
+
+ void clear();
+
+ void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
+
+ private:
+ QList<QPair<QString,QString> > list;
+ };
+
+ class QaimModel : public QAbstractListModel
+ {
+ Q_OBJECT
+ public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ QaimModel(QObject *parent=0);
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
+
+ int count() const;
+ QString name(int index) const;
+ QString number(int index) const;
+
+ Q_INVOKABLE void addItem(const QString &name, const QString &number);
+ void addItems(const QList<QPair<QString, QString> > &items);
+ void insertItem(int index, const QString &name, const QString &number);
+ void insertItems(int index, const QList<QPair<QString, QString> > &items);
+
+ void removeItem(int index);
+ void removeItems(int index, int count);
+
+ void moveItem(int from, int to);
+ void moveItems(int from, int to, int count);
+
+ void modifyItem(int idx, const QString &name, const QString &number);
+
+ void clear();
+ void reset();
+
+ void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
+
+ private:
+ QList<QPair<QString,QString> > list;
+ };
+
+ class ListRange
+ {
+ public:
+ ListRange();
+ ListRange(const ListRange &other);
+ ListRange(int start, int end);
+
+ ~ListRange();
+
+ ListRange operator+(const ListRange &other) const;
+ bool operator==(const ListRange &other) const;
+ bool operator!=(const ListRange &other) const;
+
+ bool isValid() const;
+ int count() const;
+
+ QList<QPair<QString,QString> > getModelDataValues(const QmlListModel &model);
+ QList<QPair<QString,QString> > getModelDataValues(const QaimModel &model);
+
+ QList<int> indexes;
+ bool valid;
+ };
+}
+
+Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*)
+Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange)
+Q_DECLARE_METATYPE(QList<QQuickViewTestUtil::ListChange>)
+Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange)
+
+#endif // QQUICKVIEWTESTUTIL_H
diff --git a/tests/auto/qtquick2/shared/visualtestutil.cpp b/tests/auto/quick/shared/visualtestutil.cpp
index 8680df10e9..8680df10e9 100644
--- a/tests/auto/qtquick2/shared/visualtestutil.cpp
+++ b/tests/auto/quick/shared/visualtestutil.cpp
diff --git a/tests/auto/quick/shared/visualtestutil.h b/tests/auto/quick/shared/visualtestutil.h
new file mode 100644
index 0000000000..9407ff8e8f
--- /dev/null
+++ b/tests/auto/quick/shared/visualtestutil.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKVISUALTESTUTIL_H
+#define QQUICKVISUALTESTUTIL_H
+
+#include <QtQuick/QQuickItem>
+#include <QtQml/QQmlExpression>
+
+namespace QQuickVisualTestUtil
+{
+ QQuickItem *findVisibleChild(QQuickItem *parent, const QString &objectName);
+
+ void dumpTree(QQuickItem *parent, int depth = 0);
+
+
+ /*
+ Find an item with the specified objectName. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+ */
+ template<typename T>
+ T *findItem(QQuickItem *parent, const QString &objectName, int index = -1)
+ {
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
+ if (!item)
+ continue;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QQmlExpression e(qmlContext(item), item, "index");
+ if (e.evaluate().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, objectName, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+ }
+
+ template<typename T>
+ QList<T*> findItems(QQuickItem *parent, const QString &objectName, bool visibleOnly = true)
+ {
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
+ if (!item || (visibleOnly && !item->isVisible()))
+ continue;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ items.append(static_cast<T*>(item));
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+ }
+
+ template<typename T>
+ QList<T*> findItems(QQuickItem *parent, const QString &objectName, const QList<int> &indexes)
+ {
+ QList<T*> items;
+ for (int i=0; i<indexes.count(); i++)
+ items << qobject_cast<QQuickItem*>(findItem<T>(parent, objectName, indexes[i]));
+ return items;
+ }
+
+}
+
+#endif // QQUICKVISUALTESTUTIL_H
diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp
index 5a3d50f695..c015898ab7 100644
--- a/tests/auto/shared/util.cpp
+++ b/tests/auto/shared/util.cpp
@@ -41,19 +41,19 @@
#include "util.h"
-#include <QtDeclarative/QDeclarativeComponent>
-#include <QtDeclarative/QDeclarativeError>
-#include <QtDeclarative/QDeclarativeContext>
-#include <QtDeclarative/QDeclarativeEngine>
+#include <QtQml/QQmlComponent>
+#include <QtQml/QQmlError>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
#include <QtCore/QTextStream>
-QDeclarativeDataTest *QDeclarativeDataTest::m_instance = 0;
+QQmlDataTest *QQmlDataTest::m_instance = 0;
-QDeclarativeDataTest::QDeclarativeDataTest() :
+QQmlDataTest::QQmlDataTest() :
#ifdef QT_TESTCASE_BUILDDIR
- m_dataDirectory(QTest::qFindTestData("data", QT_DECLARATIVETEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)),
+ m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)),
#else
- m_dataDirectory(QTest::qFindTestData("data", QT_DECLARATIVETEST_DATADIR, 0)),
+ m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0)),
#endif
m_dataDirectoryUrl(QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/')))
@@ -61,33 +61,33 @@ QDeclarativeDataTest::QDeclarativeDataTest() :
m_instance = this;
}
-QDeclarativeDataTest::~QDeclarativeDataTest()
+QQmlDataTest::~QQmlDataTest()
{
m_instance = 0;
}
-void QDeclarativeDataTest::initTestCase()
+void QQmlDataTest::initTestCase()
{
QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found");
m_directory = QFileInfo(m_dataDirectory).absolutePath();
QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory));
}
-QString QDeclarativeDataTest::testFile(const QString &fileName) const
+QString QQmlDataTest::testFile(const QString &fileName) const
{
if (m_directory.isEmpty())
- qFatal("QDeclarativeDataTest::initTestCase() not called.");
+ qFatal("QQmlDataTest::initTestCase() not called.");
QString result = m_dataDirectory;
result += QLatin1Char('/');
result += fileName;
return result;
}
-QByteArray QDeclarativeDataTest::msgComponentError(const QDeclarativeComponent &c,
- const QDeclarativeEngine *engine /* = 0 */)
+QByteArray QQmlDataTest::msgComponentError(const QQmlComponent &c,
+ const QQmlEngine *engine /* = 0 */)
{
QString result;
- const QList<QDeclarativeError> errors = c.errors();
+ const QList<QQmlError> errors = c.errors();
QTextStream str(&result);
str << "Component '" << c.url().toString() << "' has " << errors.size()
<< " errors: '";
@@ -98,7 +98,7 @@ QByteArray QDeclarativeDataTest::msgComponentError(const QDeclarativeComponent &
}
if (!engine)
- if (QDeclarativeContext *context = c.creationContext())
+ if (QQmlContext *context = c.creationContext())
engine = context->engine();
if (engine) {
str << " Import paths: (" << engine->importPathList().join(QStringLiteral(", "))
diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h
index 9f73d9eb05..5a31ebd719 100644
--- a/tests/auto/shared/util.h
+++ b/tests/auto/shared/util.h
@@ -39,25 +39,25 @@
**
****************************************************************************/
-#ifndef QDECLARATIVETESTUTILS_H
-#define QDECLARATIVETESTUTILS_H
+#ifndef QQMLTESTUTILS_H
+#define QQMLTESTUTILS_H
#include <QtCore/QDir>
#include <QtCore/QUrl>
#include <QtCore/QCoreApplication>
#include <QtTest/QTest>
-QT_FORWARD_DECLARE_CLASS(QDeclarativeComponent)
-QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine)
+QT_FORWARD_DECLARE_CLASS(QQmlComponent)
+QT_FORWARD_DECLARE_CLASS(QQmlEngine)
/* Base class for tests with data that are located in a "data" subfolder. */
-class QDeclarativeDataTest : public QObject
+class QQmlDataTest : public QObject
{
Q_OBJECT
public:
- QDeclarativeDataTest();
- virtual ~QDeclarativeDataTest();
+ QQmlDataTest();
+ virtual ~QQmlDataTest();
QString testFile(const QString &fileName) const;
inline QString testFile(const char *fileName) const
@@ -71,20 +71,20 @@ public:
inline QUrl dataDirectoryUrl() const { return m_dataDirectoryUrl; }
inline QString directory() const { return m_directory; }
- static inline QDeclarativeDataTest *instance() { return m_instance; }
+ static inline QQmlDataTest *instance() { return m_instance; }
- static QByteArray msgComponentError(const QDeclarativeComponent &,
- const QDeclarativeEngine *engine = 0);
+ static QByteArray msgComponentError(const QQmlComponent &,
+ const QQmlEngine *engine = 0);
public slots:
virtual void initTestCase();
private:
- static QDeclarativeDataTest *m_instance;
+ static QQmlDataTest *m_instance;
const QString m_dataDirectory;
const QUrl m_dataDirectoryUrl;
QString m_directory;
};
-#endif // QDECLARATIVETESTUTILS_H
+#endif // QQMLTESTUTILS_H
diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri
index 916e5fb32a..8e82dcb33b 100644
--- a/tests/auto/shared/util.pri
+++ b/tests/auto/shared/util.pri
@@ -2,4 +2,4 @@
HEADERS += $$PWD/util.h
SOURCES += $$PWD/util.cpp
-DEFINES += QT_DECLARATIVETEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
+DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
diff --git a/tests/benchmarks/declarative/animation/animation.pro b/tests/benchmarks/declarative/animation/animation.pro
deleted file mode 100644
index fc72040a3d..0000000000
--- a/tests/benchmarks/declarative/animation/animation.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = app
-TARGET = tst_animation
-QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_animation.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-QT += testlib core-private gui-private declarative-private quick-private v8-private
diff --git a/tests/benchmarks/declarative/animation/tst_animation.cpp b/tests/benchmarks/declarative/animation/tst_animation.cpp
deleted file mode 100644
index 6273d9740e..0000000000
--- a/tests/benchmarks/declarative/animation/tst_animation.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativeanimation_p_p.h>
-#include <QDeclarativeContext>
-
-class tst_animation : public QObject
-{
- Q_OBJECT
-public:
- tst_animation();
-
-private slots:
- void abstractAnimation();
- void bulkValueAnimator();
- void propertyUpdater();
-
- void animationtree_qml();
-
- void animationelements_data();
- void animationelements();
-
- void numberAnimation();
- void numberAnimationStarted();
- void numberAnimationMultipleTargets();
- void numberAnimationEmpty();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_animation::tst_animation()
-{
-}
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_animation::abstractAnimation()
-{
- QBENCHMARK {
- QAbstractAnimationJob *animation = new QAbstractAnimationJob;
- delete animation;
- }
-}
-
-void tst_animation::bulkValueAnimator()
-{
- QBENCHMARK {
- QDeclarativeBulkValueAnimator *animator = new QDeclarativeBulkValueAnimator;
- delete animator;
- }
-}
-
-void tst_animation::propertyUpdater()
-{
- QBENCHMARK {
- QDeclarativeAnimationPropertyUpdater *updater = new QDeclarativeAnimationPropertyUpdater;
- delete updater;
- }
-}
-
-void tst_animation::animationtree_qml()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("animation.qml"));
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-void tst_animation::animationelements_data()
-{
- QTest::addColumn<QString>("type");
-
- QSet<QString> types = QDeclarativeMetaType::qmlTypeNames().toSet();
- foreach (const QString &type, types) {
- if (type.contains(QLatin1String("Animation")))
- QTest::newRow(type.toLatin1()) << type;
- }
-
- QTest::newRow("QtQuick/Behavior") << "QtQuick/Behavior";
- QTest::newRow("QtQuick/Transition") << "QtQuick/Transition";
-}
-
-void tst_animation::animationelements()
-{
- QFETCH(QString, type);
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 2, 0);
- if (!t || !t->isCreatable())
- QSKIP("Non-creatable type");
-
- QBENCHMARK {
- QObject *obj = t->create();
- delete obj;
- }
-}
-
-void tst_animation::numberAnimation()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; property: \"x\"; to: 100; duration: 500; easing.type: Easing.InOutQuad } } }", QUrl());
-
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-void tst_animation::numberAnimationStarted()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; property: \"x\"; to: 100; duration: 500; easing.type: Easing.InOutQuad; running: true; paused: true } } }", QUrl());
-
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-void tst_animation::numberAnimationMultipleTargets()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; properties: \"x,y,z,width,height,implicitWidth,implicitHeight\"; to: 100; duration: 500; easing.type: Easing.InOutQuad; running: true; paused: true } } }", QUrl());
-
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-void tst_animation::numberAnimationEmpty()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nNumberAnimation { }", QUrl());
-
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-QTEST_MAIN(tst_animation)
-
-#include "tst_animation.moc"
diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro
deleted file mode 100644
index ba59080232..0000000000
--- a/tests/benchmarks/declarative/binding/binding.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_binding
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_binding.cpp testtypes.cpp
-HEADERS += testtypes.h
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/binding/testtypes.h b/tests/benchmarks/declarative/binding/testtypes.h
deleted file mode 100644
index 1c99842e33..0000000000
--- a/tests/benchmarks/declarative/binding/testtypes.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qdeclarative.h>
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int result READ result WRITE setResult)
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data)
- Q_CLASSINFO("DefaultProperty", "data")
-public:
- MyQmlObject() : m_result(0), m_value(0), m_object(0) {}
-
- int result() const { return m_result; }
- void setResult(int r) { m_result = r; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; emit valueChanged(); }
-
- QDeclarativeListProperty<QObject> data() { return QDeclarativeListProperty<QObject>(this, m_data); }
-
- MyQmlObject *object() const { return m_object; }
- void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); }
-
-signals:
- void valueChanged();
- void objectChanged();
-
-private:
- QList<QObject *> m_data;
- int m_result;
- int m_value;
- MyQmlObject *m_object;
-};
-QML_DECLARE_TYPE(MyQmlObject);
-
-void registerTypes();
-
-#endif // TESTTYPES_H
diff --git a/tests/benchmarks/declarative/binding/tst_binding.cpp b/tests/benchmarks/declarative/binding/tst_binding.cpp
deleted file mode 100644
index 858e99016b..0000000000
--- a/tests/benchmarks/declarative/binding/tst_binding.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-#include <QDeclarativeComponent>
-#include <QFile>
-#include <QDebug>
-#include "testtypes.h"
-
-class tst_binding : public QObject
-{
- Q_OBJECT
-
-public:
- tst_binding();
- virtual ~tst_binding();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
-
-private slots:
- void objectproperty_data();
- void objectproperty();
- void basicproperty_data();
- void basicproperty();
- void creation_data();
- void creation();
-
-private:
- QDeclarativeEngine engine;
- MyQmlObject tstObject;
-};
-
-tst_binding::tst_binding()
-{
-}
-
-tst_binding::~tst_binding()
-{
-}
-
-void tst_binding::initTestCase()
-{
- registerTypes();
- engine.rootContext()->setContextProperty("tstObject", &tstObject);
-}
-
-void tst_binding::cleanupTestCase()
-{
-}
-
-#define COMPONENT(filename, binding) \
- QDeclarativeComponent c(&engine); \
- { \
- QFile f(filename); \
- QVERIFY(f.open(QIODevice::ReadOnly)); \
- QByteArray data = f.readAll(); \
- data.replace("###", binding.toUtf8()); \
- c.setData(data, QUrl()); \
- QVERIFY(c.isReady()); \
- }
-
-void tst_binding::objectproperty_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("binding");
-
- QTest::newRow("object.value") << SRCDIR "/data/objectproperty.txt" << "object.value";
- QTest::newRow("object.value + 10") << SRCDIR "/data/objectproperty.txt" << "object.value + 10";
-}
-
-void tst_binding::objectproperty()
-{
- QFETCH(QString, file);
- QFETCH(QString, binding);
-
- COMPONENT(file, binding);
-
- MyQmlObject object1;
- MyQmlObject object2;
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(c.create());
- QVERIFY(object != 0);
- object->setObject(&object2);
-
- QBENCHMARK {
- object->setObject(&object1);
- object->setObject(&object2);
- }
-}
-
-void tst_binding::basicproperty_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("binding");
-
- QTest::newRow("value") << SRCDIR "/data/localproperty.txt" << "value";
- QTest::newRow("value + 10") << SRCDIR "/data/localproperty.txt" << "value + 10";
- QTest::newRow("value + value + 10") << SRCDIR "/data/localproperty.txt" << "value + value + 10";
-
- QTest::newRow("myObject.value") << SRCDIR "/data/idproperty.txt" << "myObject.value";
- QTest::newRow("myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + 10";
- QTest::newRow("myObject.value + myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + myObject.value + 10";
-}
-
-void tst_binding::basicproperty()
-{
- QFETCH(QString, file);
- QFETCH(QString, binding);
-
- COMPONENT(file, binding);
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(c.create());
- QVERIFY(object != 0);
- object->setValue(10);
-
- QBENCHMARK {
- object->setValue(1);
- }
-}
-
-void tst_binding::creation_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("binding");
-
- QTest::newRow("constant") << SRCDIR "/data/creation.txt" << "10";
- QTest::newRow("ownProperty") << SRCDIR "/data/creation.txt" << "myObject.value";
- QTest::newRow("declaredProperty") << SRCDIR "/data/creation.txt" << "myObject.myValue";
- QTest::newRow("contextProperty") << SRCDIR "/data/creation.txt" << "tstObject.value";
-}
-
-void tst_binding::creation()
-{
- QFETCH(QString, file);
- QFETCH(QString, binding);
-
- COMPONENT(file, binding);
-
- QBENCHMARK {
- QObject *o = c.create();
- delete o;
- }
-}
-
-QTEST_MAIN(tst_binding)
-#include "tst_binding.moc"
diff --git a/tests/benchmarks/declarative/compilation/compilation.pro b/tests/benchmarks/declarative/compilation/compilation.pro
deleted file mode 100644
index 44ea3d0c68..0000000000
--- a/tests/benchmarks/declarative/compilation/compilation.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_compilation
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-
-CONFIG += release
-
-SOURCES += tst_compilation.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/compilation/data/BoomBlock.qml b/tests/benchmarks/declarative/compilation/data/BoomBlock.qml
deleted file mode 100644
index 58ef377b71..0000000000
--- a/tests/benchmarks/declarative/compilation/data/BoomBlock.qml
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.particles 1.0
-
-Item {
- id: block
- property bool dying: false
- property bool spawned: false
- property int type: 0
- property int targetX: 0
- property int targetY: 0
-
- SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 }
- SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
-
- Image {
- id: img
- source: {
- if(type == 0){
- "pics/redStone.png";
- } else if(type == 1) {
- "pics/blueStone.png";
- } else {
- "pics/greenStone.png";
- }
- }
- opacity: 0
- Behavior on opacity { NumberAnimation { duration: 200 } }
- anchors.fill: parent
- }
-
- Particles {
- id: particles
-
- width: 1; height: 1
- anchors.centerIn: parent
-
- emissionRate: 0
- lifeSpan: 700; lifeSpanDeviation: 600
- angle: 0; angleDeviation: 360;
- velocity: 100; velocityDeviation: 30
- source: {
- if(type == 0){
- "pics/redStar.png";
- } else if (type == 1) {
- "pics/blueStar.png";
- } else {
- "pics/greenStar.png";
- }
- }
- }
-
- states: [
- State {
- name: "AliveState"; when: spawned == true && dying == false
- PropertyChanges { target: img; opacity: 1 }
- },
-
- State {
- name: "DeathState"; when: dying == true
- StateChangeScript { script: particles.burst(50); }
- PropertyChanges { target: img; opacity: 0 }
- StateChangeScript { script: block.destroy(1000); }
- }
- ]
-}
diff --git a/tests/benchmarks/declarative/compilation/tst_compilation.cpp b/tests/benchmarks/declarative/compilation/tst_compilation.cpp
deleted file mode 100644
index b9c619af31..0000000000
--- a/tests/benchmarks/declarative/compilation/tst_compilation.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/private/qdeclarativejsengine_p.h>
-#include <QtDeclarative/private/qdeclarativejsmemorypool_p.h>
-#include <QtDeclarative/private/qdeclarativejsparser_p.h>
-#include <QtDeclarative/private/qdeclarativejslexer_p.h>
-#include <QtDeclarative/private/qdeclarativescript_p.h>
-
-#include <QFile>
-#include <QDebug>
-#include <QTextStream>
-
-class tst_compilation : public QObject
-{
- Q_OBJECT
-public:
- tst_compilation();
-
-private slots:
- void boomblock();
-
- void jsparser_data();
- void jsparser();
-
- void scriptparser_data();
- void scriptparser();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_compilation::tst_compilation()
-{
-}
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_compilation::boomblock()
-{
- QFile f(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
- QVERIFY(f.open(QIODevice::ReadOnly));
- QByteArray data = f.readAll();
-
- //get rid of initialization effects
- {
- QDeclarativeComponent c(&engine);
- c.setData(data, QUrl());
- }
-
- QBENCHMARK {
- QDeclarativeComponent c(&engine);
- c.setData(data, QUrl());
-// QVERIFY(c.isReady());
- }
-}
-
-void tst_compilation::jsparser_data()
-{
- QTest::addColumn<QString>("file");
-
- QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
-}
-
-void tst_compilation::jsparser()
-{
- QFETCH(QString, file);
-
- QFile f(file);
- QVERIFY(f.open(QIODevice::ReadOnly));
- QByteArray data = f.readAll();
-
- QTextStream stream(data, QIODevice::ReadOnly);
- const QString code = stream.readAll();
-
- QBENCHMARK {
- QDeclarativeJS::Engine engine;
- QDeclarativeJS::NodePool nodePool(file, &engine);
-
- QDeclarativeJS::Lexer lexer(&engine);
- lexer.setCode(code, -1);
-
- QDeclarativeJS::Parser parser(&engine);
- parser.parse();
- parser.ast();
- }
-}
-
-void tst_compilation::scriptparser_data()
-{
- QTest::addColumn<QString>("file");
-
- QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
-}
-
-void tst_compilation::scriptparser()
-{
- QFETCH(QString, file);
-
- QFile f(file);
- QVERIFY(f.open(QIODevice::ReadOnly));
- QByteArray data = f.readAll();
-
- QUrl url = QUrl::fromLocalFile(file);
-
- QBENCHMARK {
- QDeclarativeScript::Parser parser;
- parser.parse(data, url);
- parser.tree();
- }
-}
-
-QTEST_MAIN(tst_compilation)
-
-#include "tst_compilation.moc"
diff --git a/tests/benchmarks/declarative/creation/creation.pro b/tests/benchmarks/declarative/creation/creation.pro
deleted file mode 100644
index 6d0d9d7e8f..0000000000
--- a/tests/benchmarks/declarative/creation/creation.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_creation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_creation.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-QT += core-private gui-private declarative-private qtquick1-private widgets testlib
diff --git a/tests/benchmarks/declarative/creation/data/item.qml b/tests/benchmarks/declarative/creation/data/item.qml
deleted file mode 100644
index ebc50ceb13..0000000000
--- a/tests/benchmarks/declarative/creation/data/item.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
- Item {}
-}
diff --git a/tests/benchmarks/declarative/creation/data/qobject.qml b/tests/benchmarks/declarative/creation/data/qobject.qml
deleted file mode 100644
index 4b59535bcb..0000000000
--- a/tests/benchmarks/declarative/creation/data/qobject.qml
+++ /dev/null
@@ -1,45 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-QtObject {
-}
diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp
deleted file mode 100644
index 809271e4d2..0000000000
--- a/tests/benchmarks/declarative/creation/tst_creation.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <private/qdeclarativemetatype_p.h>
-#include <QDebug>
-#include <QGraphicsScene>
-#include <QGraphicsItem>
-#include <QDeclarativeItem>
-#include <QDeclarativeContext>
-#include <QtQuick1/private/qdeclarativetextinput_p.h>
-#include <private/qobject_p.h>
-
-class tst_creation : public QObject
-{
- Q_OBJECT
-public:
- tst_creation();
-
-private slots:
- void qobject_cpp();
- void qobject_qml();
- void qobject_qmltype();
- void qobject_alloc();
-
- void qobject_10flat_qml();
- void qobject_10flat_cpp();
-
- void qobject_10tree_qml();
- void qobject_10tree_cpp();
-
- void itemtree_notree_cpp();
- void itemtree_objtree_cpp();
- void itemtree_cpp();
- void itemtree_data_cpp();
- void itemtree_qml();
- void itemtree_scene_cpp();
-
- void elements_data();
- void elements();
-
-private:
- QDeclarativeEngine engine;
-};
-
-class TestType : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources)
-Q_CLASSINFO("DefaultProperty", "resources")
-public:
- TestType(QObject *parent = 0)
- : QObject(parent) {}
-
- QDeclarativeListProperty<QObject> resources() {
- return QDeclarativeListProperty<QObject>(this, 0, resources_append);
- }
-
- static void resources_append(QDeclarativeListProperty<QObject> *p, QObject *o) {
- o->setParent(p->object);
- }
-};
-
-tst_creation::tst_creation()
-{
- qmlRegisterType<TestType>("Qt.test", 1, 0, "TestType");
-
- //get rid of initialization effects
- QDeclarative1TextInput te;
-}
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_creation::qobject_cpp()
-{
- QBENCHMARK {
- QObject *obj = new QObject;
- delete obj;
- }
-}
-
-void tst_creation::qobject_qml()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nQtObject {}", QUrl());
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-void tst_creation::qobject_10flat_qml()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import Qt.test 1.0\nTestType { resources: [ TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{} ] }", QUrl());
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-void tst_creation::qobject_10flat_cpp()
-{
- QBENCHMARK {
- QObject *item = new TestType;
- new TestType(item);
- new TestType(item);
- new TestType(item);
- new TestType(item);
- new TestType(item);
- new TestType(item);
- new TestType(item);
- new TestType(item);
- new TestType(item);
- new TestType(item);
- delete item;
- }
-}
-
-void tst_creation::qobject_10tree_qml()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import Qt.test 1.0\nTestType { TestType{ TestType { TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ } } } } } } } } } } }", QUrl());
-
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-void tst_creation::qobject_10tree_cpp()
-{
- QBENCHMARK {
- QObject *item = new TestType;
- QObject *root = item;
- item = new TestType(item);
- item = new TestType(item);
- item = new TestType(item);
- item = new TestType(item);
- item = new TestType(item);
- item = new TestType(item);
- item = new TestType(item);
- item = new TestType(item);
- item = new TestType(item);
- item = new TestType(item);
- delete root;
- }
-}
-
-void tst_creation::qobject_qmltype()
-{
- QDeclarativeType *t = QDeclarativeMetaType::qmlType("QtQuick/QtObject", 2, 0);
-
- QBENCHMARK {
- QObject *obj = t->create();
- delete obj;
- }
-}
-
-struct QObjectFakeData {
- char data[sizeof(QObjectPrivate)];
-};
-
-struct QObjectFake {
- QObjectFake();
- virtual ~QObjectFake();
-private:
- QObjectFakeData *d;
-};
-
-QObjectFake::QObjectFake()
-{
- d = new QObjectFakeData;
-}
-
-QObjectFake::~QObjectFake()
-{
- delete d;
-}
-
-void tst_creation::qobject_alloc()
-{
- QBENCHMARK {
- QObjectFake *obj = new QObjectFake;
- delete obj;
- }
-}
-
-struct QDeclarativeGraphics_Derived : public QObject
-{
- void setParent_noEvent(QObject *parent) {
- bool sce = d_ptr->sendChildEvents;
- d_ptr->sendChildEvents = false;
- setParent(parent);
- d_ptr->sendChildEvents = sce;
- }
-};
-
-inline void QDeclarativeGraphics_setParent_noEvent(QObject *object, QObject *parent)
-{
- static_cast<QDeclarativeGraphics_Derived *>(object)->setParent_noEvent(parent);
-}
-
-void tst_creation::itemtree_notree_cpp()
-{
- QBENCHMARK {
- QDeclarativeItem *item = new QDeclarativeItem;
- for (int i = 0; i < 30; ++i) {
- QDeclarativeItem *child = new QDeclarativeItem;
- Q_UNUSED(child);
- }
- delete item;
- }
-}
-
-void tst_creation::itemtree_objtree_cpp()
-{
- QBENCHMARK {
- QDeclarativeItem *item = new QDeclarativeItem;
- for (int i = 0; i < 30; ++i) {
- QDeclarativeItem *child = new QDeclarativeItem;
- QDeclarativeGraphics_setParent_noEvent(child,item);
- }
- delete item;
- }
-}
-
-void tst_creation::itemtree_cpp()
-{
- QBENCHMARK {
- QDeclarativeItem *item = new QDeclarativeItem;
- for (int i = 0; i < 30; ++i) {
- QDeclarativeItem *child = new QDeclarativeItem;
- QDeclarativeGraphics_setParent_noEvent(child,item);
- child->setParentItem(item);
- }
- delete item;
- }
-}
-
-void tst_creation::itemtree_data_cpp()
-{
- QBENCHMARK {
- QDeclarativeItem *item = new QDeclarativeItem;
- for (int i = 0; i < 30; ++i) {
- QDeclarativeItem *child = new QDeclarativeItem;
- QDeclarativeGraphics_setParent_noEvent(child,item);
- QDeclarativeListReference ref(item, "data");
- ref.append(child);
- }
- delete item;
- }
-}
-
-void tst_creation::itemtree_qml()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("item.qml"));
- QObject *obj = component.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = component.create();
- delete obj;
- }
-}
-
-void tst_creation::itemtree_scene_cpp()
-{
- QGraphicsScene scene;
- QDeclarativeItem *root = new QDeclarativeItem;
- scene.addItem(root);
- QBENCHMARK {
- QDeclarativeItem *item = new QDeclarativeItem;
- for (int i = 0; i < 30; ++i) {
- QDeclarativeItem *child = new QDeclarativeItem;
- QDeclarativeGraphics_setParent_noEvent(child,item);
- child->setParentItem(item);
- }
- item->setParentItem(root);
- delete item;
- }
- delete root;
-}
-
-void tst_creation::elements_data()
-{
- QTest::addColumn<QString>("type");
-
- QList<QString> types = QDeclarativeMetaType::qmlTypeNames();
- foreach (QString type, types)
- QTest::newRow(type.toLatin1()) << type;
-}
-
-void tst_creation::elements()
-{
- QFETCH(QString, type);
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 2, 0);
- if (!t || !t->isCreatable())
- QSKIP("Non-creatable type");
-
- QBENCHMARK {
- QObject *obj = t->create();
- delete obj;
- }
-}
-
-QTEST_MAIN(tst_creation)
-
-#include "tst_creation.moc"
diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro
deleted file mode 100644
index 820d84b0a2..0000000000
--- a/tests/benchmarks/declarative/declarative.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += \
- binding \
- creation \
- javascript \
- holistic \
- pointers \
- qdeclarativecomponent \
- qdeclarativeimage \
- qdeclarativemetaproperty \
- script \
- qmltime \
- js
-
-contains(QT_CONFIG, opengl): SUBDIRS += painting
-
-include(../trusted-benchmarks.pri)
diff --git a/tests/benchmarks/declarative/holistic/holistic.pro b/tests/benchmarks/declarative/holistic/holistic.pro
deleted file mode 100644
index 586af79275..0000000000
--- a/tests/benchmarks/declarative/holistic/holistic.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_holistic
-QT += declarative network testlib
-macx:CONFIG -= app_bundle
-
-CONFIG += release
-
-SOURCES += tst_holistic.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/holistic/testtypes.cpp b/tests/benchmarks/declarative/holistic/testtypes.cpp
deleted file mode 100644
index 872a3be7b1..0000000000
--- a/tests/benchmarks/declarative/holistic/testtypes.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-#include <QWidget>
-#include <QPlainTextEdit>
-#include <QDeclarativeEngine>
-#include <QScriptEngine>
-
-static QScriptValue script_api(QDeclarativeEngine *engine, QScriptEngine *scriptEngine)
-{
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
-
- static int testProperty = 13;
- QScriptValue v = scriptEngine->newObject();
- v.setProperty("scriptTestProperty", testProperty++);
- return v;
-}
-
-static QObject *qobject_api(QDeclarativeEngine *engine, QScriptEngine *scriptEngine)
-{
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
-
- testQObjectApi *o = new testQObjectApi();
- o->setQObjectTestProperty(20);
- return o;
-}
-
-static QObject *qobject_api_engine_parent(QDeclarativeEngine *engine, QScriptEngine *scriptEngine)
-{
- Q_UNUSED(scriptEngine)
-
- static int testProperty = 26;
- testQObjectApi *o = new testQObjectApi(engine);
- o->setQObjectTestProperty(testProperty++);
- return o;
-}
-
-void registerTypes()
-{
- qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias");
- qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
-
- qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
- qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
-
- qmlRegisterType<ScarceResourceProvider>("Qt.test", 1,0, "MyScarceResourceProvider");
- qmlRegisterType<ArbitraryVariantProvider>("Qt.test", 1,0, "MyArbitraryVariantProvider");
-
- qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements
- qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace!
- qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set
- qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
- qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
-}
-
-//#include "testtypes.moc"
diff --git a/tests/benchmarks/declarative/holistic/testtypes.h b/tests/benchmarks/declarative/holistic/testtypes.h
deleted file mode 100644
index c3824d2352..0000000000
--- a/tests/benchmarks/declarative/holistic/testtypes.h
+++ /dev/null
@@ -1,355 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtDeclarative/qdeclarativelist.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qpixmap.h>
-#include <QtGui/qvector3d.h>
-#include <QtCore/qdatetime.h>
-#include <QtScript/qjsvalue.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-
-class MyQmlAttachedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value CONSTANT)
- Q_PROPERTY(int value2 READ value2 WRITE setValue2)
-public:
- MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
-
- int value() const { return 19; }
- int value2() const { return m_value2; }
- void setValue2(int v) { m_value2 = v; }
-
- void emitMySignal() { emit mySignal(); }
-
-signals:
- void mySignal();
-
-private:
- int m_value2;
-};
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_ENUMS(MyEnum2)
- Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
- Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
- Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int console READ console CONSTANT)
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
- Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
- Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
- Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false)
-
-public:
- MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
-
- enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
- enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
-
- bool trueProperty() const { return true; }
- bool falseProperty() const { return false; }
-
- QString stringProperty() const { return m_string; }
- void setStringProperty(const QString &s)
- {
- if (s == m_string)
- return;
- m_string = s;
- emit stringChanged();
- }
-
- QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) {
- if (obj == m_object)
- return;
- m_object = obj;
- emit objectChanged();
- }
-
- QDeclarativeListProperty<QObject> objectListProperty() { return QDeclarativeListProperty<QObject>(this, m_objectQList); }
-
- bool methodCalled() const { return m_methodCalled; }
- bool methodIntCalled() const { return m_methodIntCalled; }
-
- QString string() const { return m_string; }
-
- static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
- return new MyQmlAttachedObject(o);
- }
-
- int deleteOnSet() const { return 1; }
- void setDeleteOnSet(int v) { if(v) delete this; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
- int resettableProperty() const { return m_resetProperty; }
- void setResettableProperty(int v) { m_resetProperty = v; }
- void resetProperty() { m_resetProperty = 13; }
-
- QRegExp regExp() { return m_regExp; }
- void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
-
- int console() const { return 11; }
-
- int nonscriptable() const { return 0; }
- void setNonscriptable(int) {}
-
- MyQmlObject *myinvokableObject;
- Q_INVOKABLE MyQmlObject *returnme() { return this; }
-
- struct MyType {
- int value;
- };
- QVariant variant() const { return m_variant; }
-
-signals:
- void basicSignal();
- void argumentSignal(int a, QString b, qreal c);
- void stringChanged();
- void objectChanged();
- void anotherBasicSignal();
- void thirdBasicSignal();
- void signalWithUnknownType(const MyQmlObject::MyType &arg);
-
-public slots:
- void deleteMe() { delete this; }
- void methodNoArgs() { m_methodCalled = true; }
- void method(int a) { if(a == 163) m_methodIntCalled = true; }
- void setString(const QString &s) { m_string = s; }
- void myinvokable(MyQmlObject *o) { myinvokableObject = o; }
- void variantMethod(const QVariant &v) { m_variant = v; }
-
-private:
- friend class tst_qdeclarativeecmascript;
- bool m_methodCalled;
- bool m_methodIntCalled;
-
- QObject *m_object;
- QString m_string;
- QList<QObject *> m_objectQList;
- int m_value;
- int m_resetProperty;
- QRegExp m_regExp;
- QVariant m_variant;
-};
-
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-Q_DECLARE_METATYPE(MyQmlObject::MyType)
-
-class testQObjectApi : public QObject
-{
- Q_OBJECT
- Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged)
-
-public:
- testQObjectApi(QObject* parent = 0)
- : QObject(parent), m_testProperty(0)
- {
- }
-
- ~testQObjectApi() {}
-
- int qobjectTestProperty() const { return m_testProperty; }
- void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); }
-
-signals:
- void qobjectTestPropertyChanged(int testProperty);
-
-private:
- int m_testProperty;
-};
-
-class ArbitraryVariantProvider : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QVariant arbitraryVariant READ arbitraryVariant WRITE setArbitraryVariant NOTIFY arbitraryVariantChanged)
-
-public:
- ArbitraryVariantProvider(QObject *parent = 0)
- : QObject(parent), m_value(QVariant(QString(QLatin1String("random string value")))), m_count(1)
- {
- }
-
- ~ArbitraryVariantProvider() {}
-
- // the variant provided by the provider
- QVariant arbitraryVariant() const { return m_value; }
- void setArbitraryVariant(const QVariant& value) { m_value = value; emit arbitraryVariantChanged(); }
- Q_INVOKABLE int changeVariant()
- {
- QPixmap pv(150, 150);
- pv.fill(Qt::green);
- int choice = qrand() % 4;
- switch (choice) {
- case 0: setArbitraryVariant(QVariant(QString(QLatin1String("string variant value")))); break;
- case 1: setArbitraryVariant(QVariant(QColor(110, 120, 130))); break;
- case 2: setArbitraryVariant(QVariant(55)); break;
- default: setArbitraryVariant(QVariant(pv)); break;
- }
-
- m_count += 1;
- return m_count;
- }
- Q_INVOKABLE QVariant setVariantToFilledPixmap(int width, int height, int r, int g, int b)
- {
- QPixmap pv(width % 300, height % 300);
- pv.fill(QColor(r % 256, g % 256, b % 256));
- m_value = pv;
- m_count += 1;
- return m_value;
- }
- Q_INVOKABLE QVariant setVariantAddCount(int addToCount, const QVariant& newValue)
- {
- m_value = newValue;
- m_count += addToCount;
- return m_value;
- }
- Q_INVOKABLE QVariant possibleVariant(int randomFactorOne, int randomFactorTwo, int randomFactorThree) const
- {
- QVariant retn;
- QPixmap pv(randomFactorOne % 300, randomFactorTwo % 300);
- pv.fill(QColor(randomFactorOne % 256, randomFactorTwo % 256, randomFactorThree % 256));
- int choice = qrand() % 4;
- switch (choice) {
- case 0: retn = QVariant(QString(QLatin1String("string variant value"))); break;
- case 1: retn = QVariant(QColor(randomFactorThree % 256, randomFactorTwo % 256, randomFactorOne % 256)); break;
- case 2: retn = QVariant((55 + randomFactorThree)); break;
- default: retn = QVariant(pv); break;
- }
- return retn;
- }
-
- // the following functions cover permutations of return value and arguments.
- // functions with no return value:
- Q_INVOKABLE void doNothing() const { /* does nothing */ } // no args, const
- Q_INVOKABLE void incrementVariantChangeCount() { m_count = m_count + 1; } // no args, nonconst
- Q_INVOKABLE void doNothing(int) const { /* does nothing. */ } // arg, const
- Q_INVOKABLE void setVariantChangeCount(int newCount) { m_count = newCount; } // arg, nonconst
- // functions with return value:
- Q_INVOKABLE int variantChangeCount() const { return m_count; } // no args, const
- Q_INVOKABLE int modifyVariantChangeCount() { m_count += 3; return m_count; } // no args, nonconst
- Q_INVOKABLE int countPlus(int value) const { return m_count + value; } // arg, const
- Q_INVOKABLE int modifyVariantChangeCount(int modifier) { m_count += modifier; return m_count; } // arg, nonconst.
-
-signals:
- void arbitraryVariantChanged();
-
-private:
- QVariant m_value;
- int m_count;
-};
-
-class ScarceResourceProvider : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QPixmap smallScarceResource READ smallScarceResource WRITE setSmallScarceResource NOTIFY smallScarceResourceChanged)
- Q_PROPERTY(QPixmap largeScarceResource READ largeScarceResource WRITE setLargeScarceResource NOTIFY largeScarceResourceChanged)
-
-public:
- ScarceResourceProvider(QObject *parent = 0)
- : QObject(parent), m_small(100, 100), m_large(1000, 1000), m_colour(1)
- {
- m_small.fill(Qt::blue);
- m_large.fill(Qt::blue);
- }
-
- ~ScarceResourceProvider() {}
-
- QPixmap smallScarceResource() const { return m_small; }
- void setSmallScarceResource(QPixmap v) { m_small = v; emit smallScarceResourceChanged(); }
- bool smallScarceResourceIsDetached() const { return m_small.isDetached(); }
-
- QPixmap largeScarceResource() const { return m_large; }
- void setLargeScarceResource(QPixmap v) { m_large = v; emit largeScarceResourceChanged(); }
- bool largeScarceResourceIsDetached() const { return m_large.isDetached(); }
-
- Q_INVOKABLE void changeResources()
- {
- QPixmap newSmall(100, 100);
- QPixmap newLarge(1000, 1000);
-
- if (m_colour == 1) {
- m_colour = 2;
- newSmall.fill(Qt::red);
- newLarge.fill(Qt::red);
- } else {
- m_colour = 1;
- newSmall.fill(Qt::blue);
- newLarge.fill(Qt::blue);
- }
-
- setSmallScarceResource(newSmall);
- setLargeScarceResource(newLarge);
- }
-
-signals:
- void smallScarceResourceChanged();
- void largeScarceResourceChanged();
-
-private:
- QPixmap m_small;
- QPixmap m_large;
-
- int m_colour;
-};
-
-void registerTypes();
-
-#endif // TESTTYPES_H
-
diff --git a/tests/benchmarks/declarative/holistic/tst_holistic.cpp b/tests/benchmarks/declarative/holistic/tst_holistic.cpp
deleted file mode 100644
index 6a2aa19804..0000000000
--- a/tests/benchmarks/declarative/holistic/tst_holistic.cpp
+++ /dev/null
@@ -1,607 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "testtypes.h"
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDeclarativeContext>
-#include <QDeclarativeProperty>
-#include <QFile>
-#include <QDebug>
-
-// Conceptually, there are several different "holistic" areas to benchmark:
-// 1) Loading
-// - read file from disk
-// - parse/lex file
-// - handle nested imports
-// 2) Compilation
-// - create meta object templates etc
-// - compile to bytecode and cache it
-// 3) Instantiation
-// - running the bytecode to create an object tree, assign properties, etc
-// - and, importantly, to evaluate bindings for the first time (incl. js expressions)
-// 4) Dynamicism
-// - bindings evaluation
-// - signal handlers
-//
-// Aside from this, we also need to determine:
-// 1) JavaScript Metrics
-// - simple expressions
-// - complex expressions
-// - instantiation vs evaluation time
-// - imports and nested imports
-// 2) Context-switch costs
-// - how expensive is it to call a cpp function from QML
-// - how expensive is it to call a js function from cpp via QML
-// - how expensive is it to pass around objects between them
-// 3) Complete creation time.
-// - loading + compilation + instantiation (for "application startup time" metric)
-//
-// In some cases, we want to include "initialization costs";
-// i.e., we need to tell the engine not to cache type data resulting
-// in compilation between rounds, and we need to tell the engine not
-// to cache whatever it caches between instantiations of components.
-// The reason for this is that it is often the "first start of application"
-// performance which we're attempting to benchmark.
-
-// define some custom types we use in test data functions.
-typedef QList<QString> PropertyNameList;
-Q_DECLARE_METATYPE(PropertyNameList);
-typedef QList<QVariant> PropertyValueList;
-Q_DECLARE_METATYPE(PropertyValueList);
-
-class tst_holistic : public QObject
-{
- Q_OBJECT
-
-public:
- tst_holistic();
-
-private slots:
- void initTestCase()
- {
- registerTypes();
- qRegisterMetaType<PropertyNameList>("PropertyNameList");
- qRegisterMetaType<PropertyValueList>("PropertyValueList");
- }
-
- void compilation_data();
- void compilation();
- void instantiation_data() { compilation_data(); }
- void instantiation();
- void creation_data() { compilation_data(); }
- void creation();
- void dynamicity_data();
- void dynamicity();
-
- void cppToJsDirect_data();
- void cppToJsDirect();
- void cppToJsIndirect();
-
- void typeResolution_data();
- void typeResolution();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_holistic::tst_holistic()
-{
-}
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-
-void tst_holistic::compilation_data()
-{
- QTest::addColumn<QStringList>("files");
- QTest::addColumn<int>("repetitions");
-
- QStringList f;
-
- // Benchmarks: a single, small component once with no caching.
- f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallOne.qml"));
- QTest::newRow("single small component") << f << 1;
-
- // Benchmarks: a single, small component ten times with caching.
- QTest::newRow("single small component cached") << f << 10; f.clear();
-
- // Benchmarks: a single, large component once with no caching.
- f << QString(SRCDIR + QLatin1String("/data/largeTargets/mousearea-example.qml"));
- QTest::newRow("single large component") << f << 1;
-
- // Benchmarks: a single, large component ten times with caching.
- QTest::newRow("single large component cached") << f << 10; f.clear();
-
- // Benchmarks: 4 small components once each with no caching
- f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallOne.qml"));
- f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallTwo.qml"));
- f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallThree.qml"));
- f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallFour.qml"));
- QTest::newRow("multiple small components") << f << 1;
-
- // Benchmarks: 4 small components ten times each with caching
- QTest::newRow("multiple small components cached") << f << 10; f.clear();
-
- // Benchmarks: 3 large components once each with no caching.
- f << QString(SRCDIR + QLatin1String("/data/largeTargets/mousearea-example.qml"));
- f << QString(SRCDIR + QLatin1String("/data/largeTargets/gridview-example.qml"));
- f << QString(SRCDIR + QLatin1String("/data/largeTargets/layoutdirection.qml"));
- QTest::newRow("multiple large components") << f << 1;
-
- // Benchmarks: 3 large components ten times each with caching.
- QTest::newRow("multiple large components cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports a single small js file, no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/Sssi.qml"));
- QTest::newRow("single small js import") << f << 1;
-
- // Benchmarks: single small component which imports a single small js file, 10 reps, with caching
- QTest::newRow("single small js import, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports multiple small js files (no deep nesting), no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/Msbsi.qml"));
- QTest::newRow("multiple small js imports, shallow") << f << 1;
-
- // Benchmarks: single small component which imports multiple small js files (no deep nesting), 10 reps, with caching
- QTest::newRow("multiple small js imports, shallow, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports multiple small js files (with deep nesting), no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/Msdsi.qml"));
- QTest::newRow("multiple small js imports, deeply nested") << f << 1;
-
- // Benchmarks: single small component which imports multiple small js files (with deep nesting), 10 reps, with caching
- QTest::newRow("multiple small js imports, deeply nested, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports multiple small js files (nested and unnested), no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/Mssi.qml"));
- QTest::newRow("muliple small js imports, both") << f << 1;
-
- // Benchmarks: single small component which imports multiple small js files (nested and unnested), 10 reps, with caching
- QTest::newRow("muliple small js imports, both, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports a single large js file, no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/Slsi.qml"));
- QTest::newRow("single large js import") << f << 1;
-
- // Benchmarks: single small component which imports a single large js file, 10 reps, with caching
- QTest::newRow("single large js import, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports multiple large js files (no deep nesting), no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/Mlbsi.qml"));
- QTest::newRow("multiple large js imports, shallow") << f << 1;
-
- // Benchmarks: single small component which imports multiple large js files (no deep nesting), 10 reps, with caching
- QTest::newRow("multiple large js imports, shallow, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports multiple large js files (with deep nesting), no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/Mldsi.qml"));
- QTest::newRow("multiple large js imports, deeply nested") << f << 1;
-
- // Benchmarks: single small component which imports multiple large js files (with deep nesting), 10 reps, with caching
- QTest::newRow("multiple large js imports, deeply nested, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports multiple large js files (nested and unnested), no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/Mlsi.qml"));
- QTest::newRow("multiple large js imports, both") << f << 1;
-
- // Benchmarks: single small component which imports multiple large js files (nested and unnested), 10 reps, with caching
- QTest::newRow("multiple large js imports, both, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file, no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/PragmaBm.qml"));
- QTest::newRow(".pragma library js import") << f << 1;
-
- // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file, 10 reps, with caching
- QTest::newRow(".pragma library js import, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports a js file which imports a QML module, no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/ModuleBm.qml"));
- QTest::newRow("import js with QML import") << f << 1;
-
- // Benchmarks: single small component which imports a js file which imports a QML module, 10 reps, with caching
- QTest::newRow("import js with QML import, cached") << f << 10; f.clear();
-
- // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file and a QML module, no caching
- f << QString(SRCDIR + QLatin1String("/data/jsImports/PragmaModuleBm.qml"));
- QTest::newRow("import js with QML import and .pragma library") << f << 1;
-
- // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file and a QML module, 10 reps, with caching
- QTest::newRow("import js with QML import and .pragma library, cached") << f << 10; f.clear();
-}
-
-void tst_holistic::compilation()
-{
- // This function benchmarks the cost of loading and compiling specified QML files.
- // If "repetitions" is non-zero, each file from "files" will be compiled "repetitions"
- // times, without clearing the engine's component cache between compilations.
-
- QFETCH(QStringList, files);
- QFETCH(int, repetitions);
- Q_ASSERT(files.size() > 0);
- Q_ASSERT(repetitions > 0);
-
- QBENCHMARK {
- engine.clearComponentCache();
- for (int i = 0; i < repetitions; ++i) {
- for (int j = 0; j < files.size(); ++j) {
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(files.at(j)));
- }
- }
- }
-}
-
-void tst_holistic::instantiation()
-{
- // This function benchmarks the cost of instantiating components compiled from specified QML files.
- // If "repetitions" is non-zero, each component compiled from "files" will be instantiated "repetitions"
- // times, without clearing the component's instantiation cache between instantiations.
-
- QFETCH(QStringList, files);
- QFETCH(int, repetitions);
- Q_ASSERT(files.size() > 0);
- Q_ASSERT(repetitions > 0);
-
- QList<QDeclarativeComponent*> components;
- for (int i = 0; i < files.size(); ++i) {
- QDeclarativeComponent *c = new QDeclarativeComponent(&engine, QUrl::fromLocalFile(files.at(i)));
- components.append(c);
- }
-
- QBENCHMARK {
- // XXX TODO: clear each component's instantiation cache
-
- for (int i = 0; i < repetitions; ++i) {
- for (int j = 0; j < components.size(); ++j) {
- QObject *obj = components.at(j)->create();
- delete obj;
- }
- }
- }
-
- // cleanup
- for (int i = 0; i < components.size(); ++i) {
- delete components.at(i);
- }
-}
-
-void tst_holistic::creation()
-{
- // This function benchmarks the cost of loading, compiling and instantiating specified QML files.
- // If "repetitions" is non-zero, each file from "files" will be created "repetitions"
- // times, without clearing the engine's component cache between component creation.
-
- QFETCH(QStringList, files);
- QFETCH(int, repetitions);
- Q_ASSERT(files.size() > 0);
- Q_ASSERT(repetitions > 0);
-
- QBENCHMARK {
- engine.clearComponentCache();
- for (int i = 0; i < repetitions; ++i) {
- for (int j = 0; j < files.size(); ++j) {
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(files.at(j)));
- QObject *obj = c.create();
- delete obj;
- }
- }
- }
-}
-
-void tst_holistic::dynamicity_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("writeProperty");
- QTest::addColumn<QVariant>("writeValueOne");
- QTest::addColumn<QVariant>("writeValueTwo");
- QTest::addColumn<QString>("readProperty");
-
- QString f;
-
- // Benchmarks: single simple property binding
- f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicOne.qml"));
- QTest::newRow("single simple property binding") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("height"));
-
- // Benchmarks: multiple simple property bindings in one component
- f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicTwo.qml"));
- QTest::newRow("multiple simple property bindings") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth"));
-
- // Benchmarks: single simple property binding plus onPropertyChanged slot
- f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicThree.qml"));
- QTest::newRow("single simple plus slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth"));
-
- // Benchmarks: multiple simple property bindings plus multiple onPropertyChanged slots in one component
- f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicFour.qml"));
- QTest::newRow("multiple simple plus slots") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicHeight"));
-
- // Benchmarks: single simple js expression in a slot
- f = QString(SRCDIR + QLatin1String("/data/jsTargets/JsOne.qml"));
- QTest::newRow("single simple js expression slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth"));
-
- // Benchmarks: single complex js expression in a slot
- f = QString(SRCDIR + QLatin1String("/data/jsTargets/JsTwo.qml"));
- QTest::newRow("single complex js expression slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth"));
-
- // Benchmarks: simple property assignment and bindings update
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/CppToQml.qml"));
- QTest::newRow("single simple property binding") << f << QString(QLatin1String("arbitrary")) << QVariant(36) << QVariant(35) << QString(QLatin1String("arbitrary"));
-}
-
-void tst_holistic::dynamicity()
-{
- // This function benchmarks the cost of "continued operation" - signal invocation,
- // updating bindings, etc. Note that we take two different writeValues in order
- // to force updates to occur, and we read to force lazy evaluation to occur.
-
- QFETCH(QString, file);
- QFETCH(QString, writeProperty);
- QFETCH(QVariant, writeValueOne);
- QFETCH(QVariant, writeValueTwo);
- QFETCH(QString, readProperty);
-
- QDeclarativeComponent c(&engine, file);
- QObject *obj = c.create();
-
- QVariant readValue;
- QVariant writeValue;
- bool usedFirst = false;
-
- QBENCHMARK {
- if (usedFirst) {
- writeValue = writeValueTwo;
- usedFirst = false;
- } else {
- writeValue = writeValueOne;
- usedFirst = true;
- }
-
- obj->setProperty(writeProperty.toAscii().constData(), writeValue);
- readValue = obj->property(readProperty.toAscii().constData());
- }
-
- delete obj;
-}
-
-
-
-
-
-
-
-void tst_holistic::cppToJsDirect_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("methodName");
-
- QString f;
-
- // Benchmarks: cost of calling a js function from cpp directly
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/CppToJs.qml"));
- QTest::newRow("cpp-to-js") << f << QString(QLatin1String("callJsFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // const CPP function with no return value and no arguments.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppOne.qml"));
- QTest::newRow("cpp-to-js-to-cpp: no retn, no args") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // nonconst CPP function with no return value and no arguments.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppTwo.qml"));
- QTest::newRow("cpp-to-js-to-cpp: nonconst, no retn, no args") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // const CPP function with no return value and a single integer argument.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppThree.qml"));
- QTest::newRow("cpp-to-js-to-cpp: const, no retn, int arg") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // nonconst CPP function with no return value and a single integer argument.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppFour.qml"));
- QTest::newRow("cpp-to-js-to-cpp: nonconst, no retn, int arg") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // const CPP function with an integer return value and no arguments.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppFive.qml"));
- QTest::newRow("cpp-to-js-to-cpp: const, int retn, no args") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // nonconst CPP function with an integer return value and no arguments.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppSix.qml"));
- QTest::newRow("cpp-to-js-to-cpp: nonconst, int retn, no args") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // const CPP function with an integer return value and a single integer argument.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppSeven.qml"));
- QTest::newRow("cpp-to-js-to-cpp: const, int retn, int arg") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // nonconst CPP function with an integer return value and a single integer argument.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppEight.qml"));
- QTest::newRow("cpp-to-js-to-cpp: nonconst, int retn, int arg") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // const CPP function with a variant return value and multiple integer arguments.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppNine.qml"));
- QTest::newRow("cpp-to-js-to-cpp: const, variant retn, int args") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // nonconst CPP function with a variant return value and multiple integer arguments.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppTen.qml"));
- QTest::newRow("cpp-to-js-to-cpp: nonconst, variant retn, int args") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: cost of calling js function which calls cpp function:
- // nonconst CPP function with a variant return value and multiple integer arguments.
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppEleven.qml"));
- QTest::newRow("cpp-to-js-to-cpp: nonconst, variant retn, variant + int args") << f << QString(QLatin1String("callCppFunction"));
-
- // Benchmarks: calling js function which copies scarce resources by calling back into cpp scope
- f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceOne.qml"));
- QTest::newRow("cpp-to-js-to-coo: copy scarce resources") << f << QString(QLatin1String("copyScarceResources"));
-}
-
-
-void tst_holistic::cppToJsDirect()
-{
- // This function benchmarks the cost of calling from CPP scope to JS scope
- // (and possibly vice versa, if the invoked js method then calls to cpp).
-
- QFETCH(QString, file);
- QFETCH(QString, methodName);
-
- QDeclarativeComponent c(&engine, file);
- QObject *obj = c.create();
-
- QBENCHMARK {
- QMetaObject::invokeMethod(obj, methodName.toLatin1().constData());
- }
-
- delete obj;
-}
-
-
-void tst_holistic::cppToJsIndirect()
-{
- // This function benchmarks the cost of binding scarce resources
- // to properties of a QML component. The engine should automatically release such
- // resources when they are no longer used.
- // The benchmark deliberately causes change signals to be emitted (and
- // modifies the scarce resources) so that the properties are updated.
-
- QDeclarativeComponent c(&engine, QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceTwo.qml")));
- QObject *obj = c.create();
-
- ScarceResourceProvider *srp = 0;
- srp = qobject_cast<ScarceResourceProvider*>(QDeclarativeProperty::read(obj, "a").value<QObject*>());
-
- QBENCHMARK {
- srp->changeResources(); // will cause small+large scarce resources changed signals to be emitted.
- }
-
- delete obj;
-}
-
-
-
-
-
-void tst_holistic::typeResolution_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<PropertyNameList>("propertyNameOne");
- QTest::addColumn<PropertyValueList>("propertyValueOne");
- QTest::addColumn<PropertyNameList>("propertyNameTwo");
- QTest::addColumn<PropertyValueList>("propertyValueTwo");
- QTest::addColumn<int>("repetitions");
-
- QString f;
- PropertyNameList pn1;
- PropertyValueList pv1;
- PropertyNameList pn2;
- PropertyValueList pv2;
-
- // Benchmarks: resolving nested ids and types, no caching
- f = QString(SRCDIR + QLatin1String("/data/resolutionTargets/ResolveOne.qml"));
- pn1 << QString(QLatin1String("baseWidth")) << QString(QLatin1String("baseHeight")) << QString(QLatin1String("baseColor"));
- pv1 << QVariant(401) << QVariant(402) << QVariant(QString(QLatin1String("brown")));
- pn2 << QString(QLatin1String("baseWidth")) << QString(QLatin1String("baseHeight")) << QString(QLatin1String("baseColor"));
- pv2 << QVariant(403) << QVariant(404) << QVariant(QString(QLatin1String("orange")));
- QTest::newRow("nested id resolution") << f << pn1 << pv1 << pn2 << pv2 << 1;
-
- // Benchmarks: resolving nested ids and types, 10 reps with caching
- QTest::newRow("nested id resolution, cached") << f << pn1 << pv1 << pn2 << pv2 << 10;
- pn1.clear(); pn2.clear(); pv1.clear(); pv2.clear();
-}
-
-void tst_holistic::typeResolution()
-{
- // This function benchmarks the cost of "continued operation" (signal invocation,
- // updating bindings, etc) where the component has lots of nested items with
- // lots of resolving required. Note that we take two different writeValues in order
- // to force updates to occur.
-
- QFETCH(QString, file);
- QFETCH(PropertyNameList, propertyNameOne);
- QFETCH(PropertyValueList, propertyValueOne);
- QFETCH(PropertyNameList, propertyNameTwo);
- QFETCH(PropertyValueList, propertyValueTwo);
- QFETCH(int, repetitions);
-
- Q_ASSERT(propertyNameOne.size() == propertyValueOne.size());
- Q_ASSERT(propertyNameTwo.size() == propertyValueTwo.size());
- Q_ASSERT(repetitions > 0);
-
- QDeclarativeComponent c(&engine, file);
- QObject *obj = c.create();
-
- PropertyNameList writeProperty;
- PropertyValueList writeValue;
- bool usedFirst = false;
-
- QBENCHMARK {
- for (int i = 0; i < repetitions; ++i) {
- if (usedFirst) {
- writeProperty = propertyNameOne;
- writeValue = propertyValueOne;
- usedFirst = false;
- } else {
- writeProperty = propertyNameTwo;
- writeValue = propertyValueTwo;
- usedFirst = true;
- }
-
- for (int j = 0; j < writeProperty.size(); ++j) {
- obj->setProperty(writeProperty.at(j).toAscii().constData(), writeValue.at(j));
- }
- }
- }
-
- delete obj;
-}
-
-
-QTEST_MAIN(tst_holistic)
-
-#include "tst_holistic.moc"
diff --git a/tests/benchmarks/declarative/javascript/javascript.pro b/tests/benchmarks/declarative/javascript/javascript.pro
deleted file mode 100644
index 8026540309..0000000000
--- a/tests/benchmarks/declarative/javascript/javascript.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_javascript
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_javascript.cpp testtypes.cpp
-HEADERS += testtypes.h
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/javascript/testtypes.cpp b/tests/benchmarks/declarative/javascript/testtypes.cpp
deleted file mode 100644
index 0ba82a495d..0000000000
--- a/tests/benchmarks/declarative/javascript/testtypes.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "testtypes.h"
-#include <QtDeclarative/qdeclarative.h>
-
-void registerTypes()
-{
- qmlRegisterType<TestObject>("Qt.test", 1,0, "TestObject");
-}
diff --git a/tests/benchmarks/declarative/javascript/tst_javascript.cpp b/tests/benchmarks/declarative/javascript/tst_javascript.cpp
deleted file mode 100644
index f27c7e5b73..0000000000
--- a/tests/benchmarks/declarative/javascript/tst_javascript.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDir>
-#include <QDebug>
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-
-#include "testtypes.h"
-
-class tst_javascript : public QObject
-{
- Q_OBJECT
-
-public:
- tst_javascript();
- virtual ~tst_javascript();
-
-private slots:
- void run_data();
- void run();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_javascript::tst_javascript()
-{
- registerTypes();
-}
-
-tst_javascript::~tst_javascript()
-{
-}
-
-void tst_javascript::run_data()
-{
- QTest::addColumn<QString>("file");
-
- QDir dir(SRCDIR "/data");
-
- QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
-
- for (int ii = 0; ii < files.count(); ++ii) {
- QString file = files.at(ii);
- if (file.endsWith(".qml") && file.at(0).isLower()) {
-
- QString testName = file.left(file.length() - 4 /* strlen(".qml") */);
- QString fileName = QLatin1String(SRCDIR) + QLatin1String("/data/") + file;
-
-
- QTest::newRow(qPrintable(testName)) << fileName;
-
- }
- }
-}
-
-void tst_javascript::run()
-{
- QFETCH(QString, file);
-
- QDeclarativeComponent c(&engine, file);
-
- if (c.isError()) {
- qWarning() << c.errors();
- }
-
- QVERIFY(!c.isError());
-
- QObject *o = c.create();
- QVERIFY(o != 0);
-
- QMetaMethod method = o->metaObject()->method(o->metaObject()->indexOfMethod("runtest()"));
-
- QBENCHMARK {
- method.invoke(o);
- }
-
- delete o;
-}
-
-QTEST_MAIN(tst_javascript)
-
-#include "tst_javascript.moc"
diff --git a/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro b/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro
deleted file mode 100644
index f04da8ec95..0000000000
--- a/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_bench_qjsengine
-
-SOURCES += tst_qjsengine.cpp
-
-QT += declarative testlib
diff --git a/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp b/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp
deleted file mode 100644
index c7011e40a0..0000000000
--- a/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp
+++ /dev/null
@@ -1,600 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtDeclarative/qjsengine.h>
-
-
-Q_DECLARE_METATYPE(QJSValue)
-
-class tst_QJSEngine : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QJSEngine();
- virtual ~tst_QJSEngine();
-
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void constructor();
-#if 0 // No defaultPrototype for now
- void defaultPrototype();
- void setDefaultPrototype();
-#endif
- void evaluate_data();
- void evaluate();
-#if 0 // No program
- void evaluateProgram_data();
- void evaluateProgram();
-#endif
-#if 0 // no connections for now
- void connectAndDisconnect();
-#endif
- void globalObject();
- void hasUncaughtException();
-#if 0 // no is Evaluating for now
- void isEvaluating();
-#endif
- void newArray_data();
- void newArray();
- void newDate();
- void newObject();
-#if 0 // No ScriptClass
- void newObjectWithScriptClass();
-#endif
-#if 0 // no qmetaobject
- void newQMetaObject();
-#endif
- void newQObject();
-#if 0 // no native functions for now
- void newFunction();
-#endif
- void newRegExp();
- void newVariant();
- void undefinedValue();
- void collectGarbage();
-#if 0 // No extensions
- void availableExtensions();
- void importedExtensions();
-#endif
-#if 0 // no context
- void currentContext();
- void pushAndPopContext();
-#endif
-#if 0 // no stringhandle
- void toStringHandle();
-#endif
- void castValueToQreal();
-#if 0 // no native functions for now
- void nativeCall();
-#endif
-#if 0 // no translations
- void installTranslatorFunctions();
- void translation_data();
- void translation();
-#endif
-#if 0 // no declarative class
- void readScopeProperty_data();
- void readScopeProperty();
-#endif
-#if 0 // no context
- void evaluateInNewContext();
- void evaluateInNewContextWithScope();
-#endif
-#if 0 // no pushScope
- void evaluateBindingExpression();
-#endif
-
-private:
- void defineStandardTestValues();
- void newEngine()
- {
- delete m_engine;
- m_engine = new QJSEngine;
- }
-
- QJSEngine *m_engine;
-};
-
-tst_QJSEngine::tst_QJSEngine()
- : m_engine(0)
-{
-}
-
-tst_QJSEngine::~tst_QJSEngine()
-{
- delete m_engine;
-}
-
-void tst_QJSEngine::init()
-{
-}
-
-void tst_QJSEngine::cleanup()
-{
-}
-
-void tst_QJSEngine::constructor()
-{
- QBENCHMARK {
- QJSEngine engine;
- (void)engine.parent();
- }
-}
-
-#if 0 // No defaultPrototype for now
-void tst_QJSEngine::defaultPrototype()
-{
- newEngine();
- int type = qMetaTypeId<int>();
- m_engine->setDefaultPrototype(type, m_engine->newObject());
- QBENCHMARK {
- m_engine->defaultPrototype(type);
- }
-}
-
-void tst_QJSEngine::setDefaultPrototype()
-{
- newEngine();
- int type = qMetaTypeId<int>();
- QJSValue proto = m_engine->newObject();
- QBENCHMARK {
- m_engine->setDefaultPrototype(type, proto);
- }
-}
-
-#endif
-
-void tst_QJSEngine::evaluate_data()
-{
- QTest::addColumn<QString>("code");
- QTest::newRow("empty script") << QString::fromLatin1("");
- QTest::newRow("number literal") << QString::fromLatin1("123");
- QTest::newRow("string literal") << QString::fromLatin1("'ciao'");
- QTest::newRow("regexp literal") << QString::fromLatin1("/foo/gim");
- QTest::newRow("null literal") << QString::fromLatin1("null");
- QTest::newRow("undefined literal") << QString::fromLatin1("undefined");
- QTest::newRow("null literal") << QString::fromLatin1("null");
- QTest::newRow("empty object literal") << QString::fromLatin1("{}");
- QTest::newRow("this") << QString::fromLatin1("this");
- QTest::newRow("object literal with one property") << QString::fromLatin1("{ foo: 123 }");
- QTest::newRow("object literal with two properties") << QString::fromLatin1("{ foo: 123, bar: 456 }");
- QTest::newRow("object literal with many properties") << QString::fromLatin1("{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }");
- QTest::newRow("empty array literal") << QString::fromLatin1("[]");
- QTest::newRow("array literal with one element") << QString::fromLatin1("[1]");
- QTest::newRow("array literal with two elements") << QString::fromLatin1("[1,2]");
- QTest::newRow("array literal with many elements") << QString::fromLatin1("[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]");
- QTest::newRow("empty function definition") << QString::fromLatin1("function foo() { }");
- QTest::newRow("function definition") << QString::fromLatin1("function foo() { return 123; }");
- QTest::newRow("for loop with empty body (1000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000; ++i) {}");
- QTest::newRow("for loop with empty body (10000 iterations)") << QString::fromLatin1("for (i = 0; i < 10000; ++i) {}");
- QTest::newRow("for loop with empty body (100000 iterations)") << QString::fromLatin1("for (i = 0; i < 100000; ++i) {}");
- QTest::newRow("for loop with empty body (1000000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000000; ++i) {}");
- QTest::newRow("for loop (1000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000; ++i) { j += i; }; j");
- QTest::newRow("for loop (10000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 10000; ++i) { j += i; }; j");
- QTest::newRow("for loop (100000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 100000; ++i) { j += i; }; j");
- QTest::newRow("for loop (1000000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000000; ++i) { j += i; }; j");
- QTest::newRow("assignments") << QString::fromLatin1("a = 1; b = 2; c = 3; d = 4");
- QTest::newRow("while loop (1000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000) { ++i; }; i");
- QTest::newRow("while loop (10000 iterations)") << QString::fromLatin1("i = 0; while (i < 10000) { ++i; }; i");
- QTest::newRow("while loop (100000 iterations)") << QString::fromLatin1("i = 0; while (i < 100000) { ++i; }; i");
- QTest::newRow("while loop (1000000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000000) { ++i; }; i");
- QTest::newRow("function expression") << QString::fromLatin1("(function(a, b, c){ return a + b + c; })(1, 2, 3)");
-}
-
-void tst_QJSEngine::evaluate()
-{
- QFETCH(QString, code);
- newEngine();
-
- QBENCHMARK {
- (void)m_engine->evaluate(code);
- }
-}
-
-#if 0
-void tst_QJSEngine::connectAndDisconnect()
-{
- newEngine();
- QJSValue fun = m_engine->evaluate("(function() { })");
- QBENCHMARK {
- qScriptConnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun);
- qScriptDisconnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun);
- }
-}
-
-void tst_QJSEngine::evaluateProgram_data()
-{
- evaluate_data();
-}
-
-void tst_QJSEngine::evaluateProgram()
-{
- QFETCH(QString, code);
- QScriptProgram program(code);
- newEngine();
-
- QBENCHMARK {
- (void)m_engine->evaluate(program);
- }
-}
-#endif
-
-void tst_QJSEngine::globalObject()
-{
- newEngine();
- QBENCHMARK {
- m_engine->globalObject();
- }
-}
-
-void tst_QJSEngine::hasUncaughtException()
-{
- newEngine();
- QBENCHMARK {
- m_engine->hasUncaughtException();
- }
-}
-
-#if 0
-void tst_QJSEngine::isEvaluating()
-{
- newEngine();
- QBENCHMARK {
- m_engine->isEvaluating();
- }
-}
-#endif
-
-void tst_QJSEngine::newArray_data()
-{
- QTest::addColumn<int>("size");
- QTest::newRow("size=0") << 0;
- QTest::newRow("size=10") << 10;
- QTest::newRow("size=100") << 0;
- QTest::newRow("size=1000") << 0;
- QTest::newRow("size=10000") << 0;
- QTest::newRow("size=50000") << 0;
-}
-
-void tst_QJSEngine::newArray()
-{
- QFETCH(int, size);
- newEngine();
- QBENCHMARK {
- m_engine->newArray(size);
- }
-}
-
-void tst_QJSEngine::newDate()
-{
- newEngine();
- QDateTime dt = QDateTime::currentDateTime();
- QBENCHMARK {
- m_engine->toScriptValue(dt);
- }
-}
-
-void tst_QJSEngine::newObject()
-{
- newEngine();
- QBENCHMARK {
- (void)m_engine->newObject();
- }
-}
-
-#if 0
-void tst_QJSEngine::newObjectWithScriptClass()
-{
- newEngine();
- QScriptClass cls(m_engine);
- QBENCHMARK {
- m_engine->newObject(&cls);
- }
-}
-
-void tst_QJSEngine::newQMetaObject()
-{
- newEngine();
- QBENCHMARK {
- m_engine->newQMetaObject(&QJSEngine::staticMetaObject);
- }
-}
-#endif
-
-void tst_QJSEngine::newQObject()
-{
- newEngine();
- QBENCHMARK {
- (void)m_engine->newQObject(QCoreApplication::instance());
- }
-}
-
-#if 0
-static QJSValue testFunction(QScriptContext *, QJSEngine *)
-{
- return 0;
-}
-
-void tst_QJSEngine::newFunction()
-{
- newEngine();
- QBENCHMARK {
- (void)m_engine->newFunction(testFunction);
- }
-}
-#endif
-
-void tst_QJSEngine::newRegExp()
-{
- newEngine();
- QRegExp re = QRegExp("foo");
- QBENCHMARK {
- m_engine->toScriptValue(re);
- }
-}
-
-void tst_QJSEngine::newVariant()
-{
- newEngine();
- QVariant var(QPoint(10, 20));
- QBENCHMARK {
- (void)m_engine->toScriptValue(var);
- }
-}
-
-void tst_QJSEngine::undefinedValue()
-{
- newEngine();
- QVariant var;
- QBENCHMARK {
- m_engine->toScriptValue(var);
- }
-}
-
-void tst_QJSEngine::collectGarbage()
-{
- newEngine();
- QBENCHMARK {
- m_engine->collectGarbage();
- }
-}
-
-#if 0
-void tst_QJSEngine::availableExtensions()
-{
- newEngine();
- QBENCHMARK {
- m_engine->availableExtensions();
- }
-}
-
-void tst_QJSEngine::importedExtensions()
-{
- newEngine();
- QBENCHMARK {
- m_engine->importedExtensions();
- }
-}
-
-void tst_QJSEngine::currentContext()
-{
- newEngine();
- QBENCHMARK {
- m_engine->currentContext();
- }
-}
-
-void tst_QJSEngine::pushAndPopContext()
-{
- newEngine();
- QBENCHMARK {
- (void)m_engine->pushContext();
- m_engine->popContext();
- }
-}
-#endif
-
-#if 0
-void tst_QJSEngine::toStringHandle()
-{
- newEngine();
- QString str = QString::fromLatin1("foobarbaz");
- QBENCHMARK {
- (void)m_engine->toStringHandle(str);
- }
-}
-#endif
-
-void tst_QJSEngine::castValueToQreal()
-{
- QJSValue val(123);
- QBENCHMARK {
- (void)qjsvalue_cast<qreal>(val);
- }
-}
-
-#if 0
-static QJSValue native_function(QScriptContext *, QJSEngine *)
-{
- return 42;
-}
-
-void tst_QJSEngine::nativeCall()
-{
- newEngine();
- m_engine->globalObject().setProperty("fun", m_engine->newFunction(native_function));
- QBENCHMARK{
- m_engine->evaluate("var w = 0; for (i = 0; i < 100000; ++i) {\n"
- " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }");
- }
-}
-
-void tst_QJSEngine::installTranslatorFunctions()
-{
- newEngine();
- QBENCHMARK {
- m_engine->installTranslatorFunctions();
- }
-}
-
-void tst_QJSEngine::translation_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("fileName");
- QTest::newRow("no translation") << "\"hello world\"" << "";
- QTest::newRow("qsTr") << "qsTr(\"hello world\")" << "";
- QTest::newRow("qsTranslate") << "qsTranslate(\"\", \"hello world\")" << "";
- QTest::newRow("qsTr:script.js") << "qsTr(\"hello world\")" << "script.js";
-}
-
-void tst_QJSEngine::translation()
-{
- QFETCH(QString, text);
- QFETCH(QString, fileName);
- newEngine();
- m_engine->installTranslatorFunctions();
-
- QBENCHMARK {
- (void)m_engine->evaluate(text, fileName);
- }
-}
-#endif
-
-#if 0
-void tst_QJSEngine::readScopeProperty_data()
-{
- QTest::addColumn<bool>("staticScope");
- QTest::addColumn<bool>("nestedScope");
- QTest::newRow("single dynamic scope") << false << false;
- QTest::newRow("single static scope") << true << false;
- QTest::newRow("double dynamic scope") << false << true;
- QTest::newRow("double static scope") << true << true;
-}
-
-void tst_QJSEngine::readScopeProperty()
-{
- QFETCH(bool, staticScope);
- QFETCH(bool, nestedScope);
-
- newEngine();
- QScriptContext *ctx = m_engine->pushContext();
-
- QJSValue scope;
- if (staticScope)
- scope = QScriptDeclarativeClass::newStaticScopeObject(m_engine);
- else
- scope = m_engine->newObject();
- scope.setProperty("foo", 123);
- ctx->pushScope(scope);
-
- if (nestedScope) {
- QJSValue scope2;
- if (staticScope)
- scope2 = QScriptDeclarativeClass::newStaticScopeObject(m_engine);
- else
- scope2 = m_engine->newObject();
- scope2.setProperty("bar", 456); // ensure a miss in inner scope
- ctx->pushScope(scope2);
- }
-
- QJSValue fun = m_engine->evaluate("(function() {\n"
- " for (var i = 0; i < 10000; ++i) {\n"
- " foo; foo; foo; foo; foo; foo; foo; foo;\n"
- " }\n"
- "})");
- m_engine->popContext();
- QVERIFY(fun.isFunction());
- QBENCHMARK {
- fun.call();
- }
-}
-
-void tst_QJSEngine::evaluateInNewContext()
-{
- QJSEngine engine;
- QBENCHMARK {
- engine.pushContext();
- engine.evaluate("var a = 10");
- engine.popContext();
- }
-}
-
-void tst_QJSEngine::evaluateInNewContextWithScope()
-{
- QJSEngine engine;
- QJSValue scope = engine.newObject();
- scope.setProperty("foo", 123);
- QBENCHMARK {
- QScriptContext *ctx = engine.pushContext();
- ctx->pushScope(scope);
- engine.evaluate("foo");
- engine.popContext();
- }
-}
-
-// Binding expressions in QML are implemented as anonymous functions
-// with custom scopes.
-void tst_QJSEngine::evaluateBindingExpression()
-{
- QJSEngine engine;
- QScriptContext *ctx = engine.pushContext();
- QJSValue scope = engine.newObject();
- scope.setProperty("foo", 123);
- ctx->pushScope(scope);
- QJSValue fun = engine.evaluate("(function() { return foo; })");
- QVERIFY(fun.isFunction());
- engine.popContext();
- QVERIFY(fun.call().equals(scope.property("foo")));
- QJSValue receiver = engine.globalObject();
- QBENCHMARK {
- fun.call(receiver);
- }
-}
-#endif
-
-QTEST_MAIN(tst_QJSEngine)
-#include "tst_qjsengine.moc"
diff --git a/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro b/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro
deleted file mode 100644
index 2dc917d3aa..0000000000
--- a/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_bench_qjsvalue
-
-SOURCES += tst_qjsvalue.cpp
-
-QT += declarative testlib
diff --git a/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp b/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp
deleted file mode 100644
index 4c085ab437..0000000000
--- a/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp
+++ /dev/null
@@ -1,979 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtDeclarative/qjsengine.h>
-
-Q_DECLARE_METATYPE(QJSValue)
-
-class tst_QJSValue : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QJSValue();
- virtual ~tst_QJSValue();
-
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void boolConstructor();
- void floatConstructor();
- void numberConstructor();
- void stringConstructor();
- void nullConstructor();
- void undefinedConstructor();
- void boolConstructorWithEngine();
- void floatConstructorWithEngine();
- void intConstructorWithEngine();
- void stringConstructorWithEngine();
- void undefinedConstructorWithEngine();
- void copyConstructor_data();
- void copyConstructor();
- void call_data();
- void call();
- void construct_data();
- void construct();
-#if 0 // no data
- void data();
- void setData();
- void data_noData_data();
- void data_noData();
-#endif
- void equalsSelf_data();
- void equalsSelf();
-#if 0 // no less then
- void lessThanSelf_data();
- void lessThanSelf();
-#endif
- void strictlyEqualsSelf_data();
- void strictlyEqualsSelf();
- void isArray_data();
- void isArray();
- void isBool_data();
- void isBool();
- void isDate_data();
- void isDate();
- void isError_data();
- void isError();
- void isCallable_data();
- void isCallable();
- void isNull_data();
- void isNull();
- void isNumber_data();
- void isNumber();
- void isObject_data();
- void isObject();
-#if 0 // no qmetaobject
- void isQMetaObject_data();
- void isQMetaObject();
-#endif
- void isQObject_data();
- void isQObject();
- void isRegExp_data();
- void isRegExp();
- void isString_data();
- void isString();
- void isUndefined_data();
- void isUndefined();
- void isVariant_data();
- void isVariant();
- void toBool_data();
- void toBool();
- void toDateTime_data();
- void toDateTime();
- void toInt_data();
- void toInt();
- void toNumber_data();
- void toNumber();
- void toRegExp_data();
- void toRegExp();
- void toString_data();
- void toString();
- void toUInt_data();
- void toUInt();
-#if 0 // no qmetaobject
- void toQMetaObject_data();
- void toQMetaObject();
-#endif
- void toQObject_data();
- void toQObject();
- void toVariant_data();
- void toVariant();
- void property_data();
- void property();
-#if 0 // no string handle
- void propertyById_data();
- void propertyById();
-#endif
- void propertyByIndex();
- void setProperty_data();
- void setProperty();
-#if 0 // no string handle
- void setPropertyById_data();
- void setPropertyById();
-#endif
- void setPropertyByIndex();
-#if 0 // no propertyFlags for now
- void propertyFlags_data();
- void propertyFlags();
- void propertyFlagsById_data();
- void propertyFlagsById();
-#endif
- void prototype_data();
- void prototype();
- void setPrototype();
-#if 0 // no script class
- void scriptClass_data();
- void scriptClass();
- void setScriptClass();
-#endif
-#if 0 // no string handle
- void readMetaProperty();
- void writeMetaProperty();
-#endif
-
-private:
- void defineStandardTestValues();
- void newEngine()
- {
- delete m_engine;
- m_engine = new QJSEngine;
- }
-
- QJSEngine *m_engine;
-};
-
-tst_QJSValue::tst_QJSValue()
- : m_engine(0)
-{
-}
-
-tst_QJSValue::~tst_QJSValue()
-{
- delete m_engine;
-}
-
-void tst_QJSValue::init()
-{
-}
-
-void tst_QJSValue::cleanup()
-{
-}
-
-void tst_QJSValue::boolConstructor()
-{
- QBENCHMARK {
- QJSValue val(true);
- }
-}
-
-void tst_QJSValue::floatConstructor()
-{
- QBENCHMARK {
- QJSValue val(123.0);
- }
-}
-
-void tst_QJSValue::numberConstructor()
-{
- QBENCHMARK {
- (void)QJSValue(123);
- }
-}
-
-void tst_QJSValue::stringConstructor()
-{
- QString str = QString::fromLatin1("ciao");
- QBENCHMARK {
- (void)QJSValue(str);
- }
-}
-
-void tst_QJSValue::nullConstructor()
-{
- QBENCHMARK {
- QJSValue val(QJSValue::NullValue);
- }
-}
-
-void tst_QJSValue::undefinedConstructor()
-{
- QBENCHMARK {
- QJSValue val(QJSValue::UndefinedValue);
- }
-}
-
-void tst_QJSValue::boolConstructorWithEngine()
-{
- newEngine();
- QBENCHMARK {
- m_engine->toScriptValue(true);
- }
-}
-
-void tst_QJSValue::floatConstructorWithEngine()
-{
- newEngine();
- QBENCHMARK {
- m_engine->toScriptValue(123.0);
- }
-}
-
-void tst_QJSValue::intConstructorWithEngine()
-{
- newEngine();
- QBENCHMARK {
- m_engine->toScriptValue(123);
- }
-}
-
-void tst_QJSValue::stringConstructorWithEngine()
-{
- newEngine();
- QString str = QString::fromLatin1("ciao");
- QBENCHMARK {
- m_engine->toScriptValue(str);
- }
-}
-
-void tst_QJSValue::undefinedConstructorWithEngine()
-{
- newEngine();
- QVariant var;
- QBENCHMARK {
- m_engine->toScriptValue(var);
- }
-}
-
-void tst_QJSValue::copyConstructor_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::copyConstructor()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- QJSValue copy(val);
- }
-}
-
-void tst_QJSValue::call_data()
-{
- newEngine();
- QTest::addColumn<QString>("code");
- QTest::newRow("empty function") << QString::fromLatin1("(function(){})");
- QTest::newRow("function returning number") << QString::fromLatin1("(function(){ return 123; })");
- QTest::newRow("closure") << QString::fromLatin1("(function(a, b){ return function() { return a + b; }; })(1, 2)");
-}
-
-void tst_QJSValue::call()
-{
- QFETCH(QString, code);
- QJSValue fun = m_engine->evaluate(code);
- QVERIFY(fun.isCallable());
- QBENCHMARK {
- (void)fun.call();
- }
-}
-
-void tst_QJSValue::construct_data()
-{
- newEngine();
- QTest::addColumn<QString>("code");
- QTest::newRow("empty function") << QString::fromLatin1("(function(){})");
- QTest::newRow("simple constructor") << QString::fromLatin1("(function(){ this.x = 10; this.y = 20; })");
-}
-
-void tst_QJSValue::construct()
-{
- QFETCH(QString, code);
- QJSValue fun = m_engine->evaluate(code);
- QVERIFY(fun.isCallable());
- QBENCHMARK {
- (void)fun.callAsConstructor();
- }
-}
-
-#if 0
-void tst_QJSValue::data()
-{
- newEngine();
- QJSValue obj = m_engine->newObject();
- obj.setData(QJSValue(m_engine, 123));
- QBENCHMARK {
- obj.data();
- }
-}
-
-void tst_QJSValue::setData()
-{
- newEngine();
- QJSValue obj = m_engine->newObject();
- QJSValue val(m_engine, 123);
- QBENCHMARK {
- obj.setData(val);
- }
-}
-
-void tst_QJSValue::data_noData_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::data_noData()
-{
- QFETCH(QJSValue, val);
- QVERIFY(!val.data().isValid());
- QBENCHMARK {
- val.data();
- }
-}
-#endif
-
-void tst_QJSValue::equalsSelf_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::equalsSelf()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.equals(val);
- }
-}
-
-#if 0
-void tst_QJSValue::lessThanSelf_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::lessThanSelf()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.lessThan(val);
- }
-}
-#endif
-
-void tst_QJSValue::strictlyEqualsSelf_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::strictlyEqualsSelf()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.strictlyEquals(val);
- }
-}
-
-void tst_QJSValue::isArray_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isArray()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isArray();
- }
-}
-
-void tst_QJSValue::isBool_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isBool()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isBool();
- }
-}
-
-void tst_QJSValue::isDate_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isDate()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isDate();
- }
-}
-
-void tst_QJSValue::isError_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isError()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isError();
- }
-}
-
-void tst_QJSValue::isCallable_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isCallable()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isCallable();
- }
-}
-
-void tst_QJSValue::isNull_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isNull()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isNull();
- }
-}
-
-void tst_QJSValue::isNumber_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isNumber()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isNumber();
- }
-}
-
-void tst_QJSValue::isObject_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isObject()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isObject();
- }
-}
-
-#if 0
-void tst_QJSValue::isQMetaObject_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isQMetaObject()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isQMetaObject();
- }
-}
-#endif
-
-void tst_QJSValue::isQObject_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isQObject()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isQObject();
- }
-}
-
-void tst_QJSValue::isRegExp_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isRegExp()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isRegExp();
- }
-}
-
-void tst_QJSValue::isString_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isString()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isString();
- }
-}
-
-void tst_QJSValue::isUndefined_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isUndefined()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isUndefined();
- }
-}
-
-void tst_QJSValue::isVariant_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isVariant()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isVariant();
- }
-}
-
-void tst_QJSValue::toBool_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toBool()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toBool();
- }
-}
-
-void tst_QJSValue::toDateTime_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toDateTime()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toDateTime();
- }
-}
-
-void tst_QJSValue::toInt_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toInt()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toInt();
- }
-}
-
-void tst_QJSValue::toNumber_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toNumber()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toNumber();
- }
-}
-
-void tst_QJSValue::toRegExp_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toRegExp()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- qjsvalue_cast<QRegExp>(val);
- }
-}
-
-void tst_QJSValue::toString_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toString()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- (void)val.toString();
- }
-}
-
-#if 0
-void tst_QJSValue::toQMetaObject_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toQMetaObject()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toQMetaObject();
- }
-}
-#endif
-
-void tst_QJSValue::toQObject_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toQObject()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- (void)val.toQObject();
- }
-}
-
-void tst_QJSValue::toUInt_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toUInt()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toUInt();
- }
-}
-
-void tst_QJSValue::toVariant_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toVariant()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toVariant();
- }
-}
-void tst_QJSValue::property_data()
-{
- QTest::addColumn<QString>("propertyName");
- QTest::addColumn<bool>("create");
- QTest::newRow("foo") << QString::fromLatin1("foo") << true;
- QTest::newRow("hasOwnProperty") << QString::fromLatin1("hasOwnProperty") << false; // From Object.prototype.
- QTest::newRow("noSuchProperty") << QString::fromLatin1("noSuchProperty") << false;
-}
-
-void tst_QJSValue::property()
-{
- QFETCH(QString, propertyName);
- QFETCH(bool, create);
- newEngine();
- QJSValue obj = m_engine->newObject();
- if (create)
- obj.setProperty(propertyName, 123);
- QBENCHMARK {
- (void)obj.property(propertyName);
- }
-}
-
-#if 0
-void tst_QJSValue::propertyById_data()
-{
- property_data();
-}
-
-void tst_QJSValue::propertyById()
-{
- QFETCH(QString, propertyName);
- QFETCH(bool, create);
- newEngine();
- QJSValue obj = m_engine->newObject();
- QJSString id = m_engine->toStringHandle(propertyName);
- if (create)
- obj.setProperty(id, 123);
- QBENCHMARK {
- obj.property(id);
- }
-}
-#endif
-
-void tst_QJSValue::propertyByIndex()
-{
- newEngine();
- QJSValue obj = m_engine->newObject();
- obj.setProperty(123, 456);
- QBENCHMARK {
- obj.property(123);
- }
-}
-
-void tst_QJSValue::setProperty_data()
-{
- newEngine();
- QTest::addColumn<QString>("propertyName");
- QTest::addColumn<QJSValue>("val");
- QTest::newRow("foo") << QString::fromLatin1("foo") << QJSValue(123);
- QTest::newRow("bar") << QString::fromLatin1("bar") << m_engine->toScriptValue(123);
- QTest::newRow("baz") << QString::fromLatin1("baz") << QJSValue();
- QTest::newRow("toString") << QString::fromLatin1("toString") << m_engine->toScriptValue(true);
-}
-
-void tst_QJSValue::setProperty()
-{
- QFETCH(QString, propertyName);
- QFETCH(QJSValue, val);
- QJSValue obj = m_engine->newObject();
- QBENCHMARK {
- obj.setProperty(propertyName, val);
- }
-}
-
-#if 0
-void tst_QJSValue::setPropertyById_data()
-{
- setProperty_data();
-}
-
-void tst_QJSValue::setPropertyById()
-{
- QFETCH(QString, propertyName);
- QFETCH(QJSValue, val);
- QJSValue obj = m_engine->newObject();
- QJSString id = m_engine->toStringHandle(propertyName);
- QBENCHMARK {
- obj.setProperty(id, val);
- }
-}
-#endif
-
-void tst_QJSValue::setPropertyByIndex()
-{
- newEngine();
- QJSValue obj = m_engine->newObject();
- QJSValue val(456);
- QBENCHMARK {
- obj.setProperty(123, 456);
- }
-}
-
-#if 0
-void tst_QJSValue::propertyFlags_data()
-{
- property_data();
-}
-
-void tst_QJSValue::propertyFlags()
-{
- QFETCH(QString, propertyName);
- QFETCH(bool, create);
- newEngine();
- QJSValue obj = m_engine->newObject();
- if (create)
- obj.setProperty(propertyName, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly);
- QBENCHMARK {
- (void)obj.propertyFlags(propertyName);
- }
-}
-
-void tst_QJSValue::propertyFlagsById_data()
-{
- propertyFlags_data();
-}
-
-void tst_QJSValue::propertyFlagsById()
-{
- QFETCH(QString, propertyName);
- QFETCH(bool, create);
- newEngine();
- QJSValue obj = m_engine->newObject();
- QJSString id = m_engine->toStringHandle(propertyName);
- if (create)
- obj.setProperty(id, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly);
- QBENCHMARK {
- obj.propertyFlags(id);
- }
-}
-#endif
-
-void tst_QJSValue::prototype_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::prototype()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.prototype();
- }
-}
-
-void tst_QJSValue::setPrototype()
-{
- newEngine();
- QJSValue obj = m_engine->newObject();
- QJSValue proto = m_engine->newObject();
- QBENCHMARK {
- obj.setPrototype(proto);
- }
-}
-
-#if 0
-void tst_QJSValue::scriptClass_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::scriptClass()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.scriptClass();
- }
-}
-
-void tst_QJSValue::setScriptClass()
-{
- newEngine();
- QJSValue obj = m_engine->newObject();
- QJSClass cls(m_engine);
- QBENCHMARK {
- obj.setScriptClass(&cls);
- }
-}
-
-void tst_QJSValue::readMetaProperty()
-{
- newEngine();
- QJSValue object = m_engine->newQObject(QCoreApplication::instance());
- QJSString propertyName = m_engine->toStringHandle("objectName");
- QBENCHMARK {
- for (int i = 0; i < 10000; ++i)
- object.property(propertyName);
- }
-}
-
-void tst_QJSValue::writeMetaProperty()
-{
- newEngine();
- QJSValue object = m_engine->newQObject(QCoreApplication::instance());
- QJSString propertyName = m_engine->toStringHandle("objectName");
- QJSValue value(m_engine, "foo");
- QBENCHMARK {
- for (int i = 0; i < 10000; ++i)
- object.setProperty(propertyName, value);
- }
-}
-#endif
-
-void tst_QJSValue::defineStandardTestValues()
-{
- newEngine();
- QTest::addColumn<QJSValue>("val");
- QTest::newRow("bool") << m_engine->evaluate("true");
- QTest::newRow("number") << m_engine->evaluate("123");
- QTest::newRow("string") << m_engine->evaluate("'ciao'");
- QTest::newRow("null") << m_engine->evaluate("null");
- QTest::newRow("undefined") << m_engine->evaluate("undefined");
- QTest::newRow("object") << m_engine->evaluate("({foo:123})");
- QTest::newRow("array") << m_engine->evaluate("[10,20,30]");
- QTest::newRow("function") << m_engine->evaluate("(function foo(a, b, c) { return a + b + c; })");
- QTest::newRow("date") << m_engine->evaluate("new Date");
- QTest::newRow("regexp") << m_engine->evaluate("new RegExp('foo')");
- QTest::newRow("error") << m_engine->evaluate("new Error");
-
- QTest::newRow("qobject") << m_engine->newQObject(this);
-#if 0 // no qmetaobject
- QTest::newRow("qmetaobject") << m_engine->newQMetaObject(&QJSEngine::staticMetaObject);
-#endif
- QTest::newRow("variant") << m_engine->toScriptValue(QPoint(10, 20));
-#if 0 // no classess
- QTest::newRow("qscriptclassobject") << m_engine->newObject(new QJSClass(m_engine));
-#endif
-
- QTest::newRow("invalid") << QJSValue();
- QTest::newRow("bool-no-engine") << QJSValue(true);
- QTest::newRow("number-no-engine") << QJSValue(123.0);
- QTest::newRow("string-no-engine") << QJSValue(QString::fromLatin1("hello"));
- QTest::newRow("null-no-engine") << QJSValue(QJSValue::NullValue);
- QTest::newRow("undefined-no-engine") << QJSValue(QJSValue::UndefinedValue);
-}
-
-QTEST_MAIN(tst_QJSValue)
-#include "tst_qjsvalue.moc"
diff --git a/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro b/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro
deleted file mode 100644
index a15ceba9a4..0000000000
--- a/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_bench_qjsvalueiterator
-
-SOURCES += tst_qjsvalueiterator.cpp
-
-QT = core declarative testlib
diff --git a/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp
deleted file mode 100644
index f8426fbefb..0000000000
--- a/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qjsengine.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtDeclarative/qjsvalueiterator.h>
-
-class tst_QJSValueIterator : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QJSValueIterator();
- virtual ~tst_QJSValueIterator();
-
- void dataHelper();
-
-private slots:
- void init();
- void cleanup();
-
- void hasNextAndNext();
-
- void constructAndNext_data();
- void constructAndNext();
-
- void name_data();
- void name();
-#if 0 // No string handle
- void scriptName_data();
- void scriptName();
-#endif
-
- void value_data();
- void value();
-#if 0 // no setValue
- void setValue_data();
- void setValue();
-#endif
-#if 0 // no flags
- void flags();
-#endif
-
-#if 0 // no array index
- void iterateArrayAndConvertNameToIndex();
-#endif
-#if 0 // no setValue
- void iterateArrayAndDoubleElements();
-#endif
-#if 0 // no remove
- void iterateArrayAndRemoveAllElements();
-#endif
-};
-
-tst_QJSValueIterator::tst_QJSValueIterator()
-{
-}
-
-tst_QJSValueIterator::~tst_QJSValueIterator()
-{
-}
-
-void tst_QJSValueIterator::init()
-{
-}
-
-void tst_QJSValueIterator::cleanup()
-{
-}
-
-void tst_QJSValueIterator::dataHelper()
-{
- QTest::addColumn<QString>("code");
- QTest::newRow("{ foo: 123 }") << QString::fromLatin1("({ foo: 123 })");
- QTest::newRow("Math") << QString::fromLatin1("Math");
- QTest::newRow("Array.prototype") << QString::fromLatin1("Array.prototype");
- QTest::newRow("Global Object") << QString::fromLatin1("this");
- QTest::newRow("['foo']") << QString::fromLatin1("['foo']");
- QTest::newRow("array with 1000 elements")
- << QString::fromLatin1("(function() {"
- " var a = new Array;"
- " for (i = 0; i < 1000; ++i)"
- " a[i] = i;"
- " return a;"
- "})()");
-}
-
-void tst_QJSValueIterator::hasNextAndNext()
-{
- QJSEngine engine;
- QJSValue object = engine.newObject();
- for (int i = 0; i < 2000; ++i)
- object.setProperty(i, i);
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i) {
- QJSValueIterator it(object);
- while (it.hasNext())
- it.next();
- }
- }
-}
-
-void tst_QJSValueIterator::constructAndNext_data()
-{
- dataHelper();
-}
-
-void tst_QJSValueIterator::constructAndNext()
-{
- QFETCH(QString, code);
- QJSEngine engine;
- QJSValue object = engine.evaluate(code);
- Q_ASSERT(object.isObject());
-
- QBENCHMARK {
- for (int i = 0; i < 100; ++i) {
- QJSValueIterator it(object);
- it.next();
- }
- }
-}
-
-void tst_QJSValueIterator::name_data()
-{
- dataHelper();
-}
-
-void tst_QJSValueIterator::name()
-{
- QFETCH(QString, code);
- QJSEngine engine;
- QJSValue object = engine.evaluate(code);
- Q_ASSERT(object.isObject());
-
- QJSValueIterator it(object);
- it.next();
- QBENCHMARK {
- for (int i = 0; i < 200000; ++i)
- it.name();
- }
-}
-
-#if 0
-void tst_QJSValueIterator::scriptName_data()
-{
- dataHelper();
-}
-
-void tst_QJSValueIterator::scriptName()
-{
- QFETCH(QString, code);
- QJSEngine engine;
- QJSValue object = engine.evaluate(code);
- Q_ASSERT(object.isObject());
-
- QJSValueIterator it(object);
- it.next();
- QBENCHMARK {
- for (int i = 0; i < 50000; ++i)
- it.scriptName();
- }
-}
-#endif
-
-void tst_QJSValueIterator::value_data()
-{
- dataHelper();
-}
-
-void tst_QJSValueIterator::value()
-{
- QFETCH(QString, code);
- QJSEngine engine;
- QJSValue object = engine.evaluate(code);
- Q_ASSERT(object.isObject());
-
- QJSValueIterator it(object);
- it.next();
- QBENCHMARK {
- for (int i = 0; i < 50000; ++i)
- it.value();
- }
-}
-
-#if 0
-void tst_QJSValueIterator::setValue_data()
-{
- dataHelper();
-}
-
-void tst_QJSValueIterator::setValue()
-{
- QFETCH(QString, code);
- QJSEngine engine;
- QJSValue object = engine.evaluate(code);
- Q_ASSERT(object.isObject());
-
- QJSValueIterator it(object);
- it.next();
- QJSValue newValue(&engine, 456);
- QBENCHMARK {
- for (int i = 0; i < 50000; ++i)
- it.setValue(newValue);
- }
-}
-
-void tst_QJSValueIterator::flags()
-{
- QJSEngine engine;
- QJSValue object = engine.newObject();
- QJSValue::PropertyFlags flags = flags;
- object.setProperty("foo", 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly | QJSValue::Undeletable);
- QJSValueIterator it(object);
- it.next();
- QBENCHMARK {
- for (int i = 0; i < 50000; ++i)
- it.flags();
- }
-}
-#endif
-
-#if 0
-void tst_QJSValueIterator::iterateArrayAndConvertNameToIndex()
-{
- QJSEngine engine;
- QJSValue array = engine.newArray();
- for (int i = 0; i < 20000; ++i)
- array.setProperty(i, i);
- QBENCHMARK {
- QJSValueIterator it(array);
- while (it.hasNext()) {
- it.next();
- it.scriptName().toArrayIndex();
- }
- }
-}
-
-void tst_QJSValueIterator::iterateArrayAndDoubleElements()
-{
- QJSEngine engine;
- QJSValue array = engine.newArray();
- for (int i = 0; i < 20000; ++i)
- array.setProperty(i, i);
- QBENCHMARK {
- QJSValueIterator it(array);
- while (it.hasNext()) {
- it.next();
- it.setValue(QJSValue(&engine, it.value().toNumber() * 2));
- }
- }
-}
-
-void tst_QJSValueIterator::iterateArrayAndRemoveAllElements()
-{
- QJSEngine engine;
- QJSValue array = engine.newArray();
- for (int i = 0; i < 20000; ++i)
- array.setProperty(i, i);
- QBENCHMARK {
- QJSValueIterator it(array);
- while (it.hasNext()) {
- it.next();
- it.remove();
- }
- }
-}
-#endif
-
-QTEST_MAIN(tst_QJSValueIterator)
-#include "tst_qjsvalueiterator.moc"
diff --git a/tests/benchmarks/declarative/pointers/pointers.pro b/tests/benchmarks/declarative/pointers/pointers.pro
deleted file mode 100644
index d4112f94ec..0000000000
--- a/tests/benchmarks/declarative/pointers/pointers.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-QT += declarative testlib
-TEMPLATE = app
-TARGET = tst_pointers
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_pointers.cpp
-
diff --git a/tests/benchmarks/declarative/pointers/tst_pointers.cpp b/tests/benchmarks/declarative/pointers/tst_pointers.cpp
deleted file mode 100644
index ce81c7f5c9..0000000000
--- a/tests/benchmarks/declarative/pointers/tst_pointers.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include "private/qdeclarativeguard_p.h"
-#include <QWeakPointer>
-
-class tst_pointers : public QObject
-{
- Q_OBJECT
-
-public:
- tst_pointers() {}
-
-private slots:
- void qmlguard();
- void weakPointer();
-};
-
-void tst_pointers::qmlguard()
-{
- QObject *obj = new QObject;
- QBENCHMARK {
- QDeclarativeGuard<QObject> guardedObject;
- guardedObject = obj;
- }
-}
-
-void tst_pointers::weakPointer()
-{
- QObject *obj = new QObject;
- QBENCHMARK {
- QWeakPointer<QObject> guardedObject;
- guardedObject = obj;
- }
-}
-
-QTEST_MAIN(tst_pointers)
-#include "tst_pointers.moc"
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml
deleted file mode 100644
index a7db476f70..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 4.6
-
-MyQmlObject {}
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml
deleted file mode 100644
index a8add75aee..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 4.6
-
-MyQmlObject {
- result: value
-}
-
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml
deleted file mode 100644
index 91371c80d6..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-QtObject {}
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml
deleted file mode 100644
index 240f27b4ac..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-QtObject {
- id: blah
-}
-
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml
deleted file mode 100644
index dbe9e99260..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: block
- property bool dying: false
- property bool spawned: false
- property int type: 0
- property ParticleSystem particleSystem
-
- Behavior on x {
- enabled: spawned;
- SpringAnimation{ spring: 2; damping: 0.2 }
- }
- Behavior on y {
- SpringAnimation{ spring: 2; damping: 0.2 }
- }
-
- Image {
- id: img
- source: {
- if(type == 0){
- "pics/redStone.png";
- } else if(type == 1) {
- "pics/blueStone.png";
- } else {
- "pics/greenStone.png";
- }
- }
- opacity: 0
- Behavior on opacity { NumberAnimation { duration: 200 } }
- anchors.fill: parent
- }
- Emitter {
- id: particles
- system: particleSystem
- group: {
- if(type == 0){
- "red";
- } else if (type == 1) {
- "blue";
- } else {
- "green";
- }
- }
- anchors.fill: parent
-
- speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
- shape: EllipseShape{fill:true}
- enabled: false;
- lifeSpan: 700; lifeSpanVariation: 100
- emitRate: 1000
- maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
- size: 28
- endSize: 14
- }
-
- states: [
- State {
- name: "AliveState"; when: spawned == true && dying == false
- PropertyChanges { target: img; opacity: 1 }
- },
-
- State {
- name: "DeathState"; when: dying == true
- StateChangeScript { script: particles.pulse(0.1); }
- PropertyChanges { target: img; opacity: 0 }
- StateChangeScript { script: block.destroy(1000); }
- }
- ]
-}
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml
deleted file mode 100644
index 3a86c48af1..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-QtObject {
- property int a
- property bool b
- property double c
- property real d
- property string e
- property url f
- property color g
- property date h
- property variant i
- property variant j
-}
-
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml
deleted file mode 100644
index 9d4dc03c82..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-QtObject {
- property int a
-}
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
deleted file mode 100644
index 0d415db8ba..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_qdeclarativecomponent
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativecomponent.cpp testtypes.cpp
-HEADERS += testtypes.h
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h
deleted file mode 100644
index 1c99842e33..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qdeclarative.h>
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int result READ result WRITE setResult)
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data)
- Q_CLASSINFO("DefaultProperty", "data")
-public:
- MyQmlObject() : m_result(0), m_value(0), m_object(0) {}
-
- int result() const { return m_result; }
- void setResult(int r) { m_result = r; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; emit valueChanged(); }
-
- QDeclarativeListProperty<QObject> data() { return QDeclarativeListProperty<QObject>(this, m_data); }
-
- MyQmlObject *object() const { return m_object; }
- void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); }
-
-signals:
- void valueChanged();
- void objectChanged();
-
-private:
- QList<QObject *> m_data;
- int m_result;
- int m_value;
- MyQmlObject *m_object;
-};
-QML_DECLARE_TYPE(MyQmlObject);
-
-void registerTypes();
-
-#endif // TESTTYPES_H
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
deleted file mode 100644
index d20126b132..0000000000
--- a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QFile>
-#include <QDebug>
-#include "testtypes.h"
-
-class tst_qmlcomponent : public QObject
-{
- Q_OBJECT
-
-public:
- tst_qmlcomponent();
- virtual ~tst_qmlcomponent();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
-
-private slots:
- void creation_data();
- void creation();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qmlcomponent::tst_qmlcomponent()
-{
-}
-
-tst_qmlcomponent::~tst_qmlcomponent()
-{
-}
-
-void tst_qmlcomponent::initTestCase()
-{
- registerTypes();
-}
-
-void tst_qmlcomponent::cleanupTestCase()
-{
-}
-
-void tst_qmlcomponent::creation_data()
-{
- QTest::addColumn<QString>("file");
-
- QTest::newRow("Object") << SRCDIR "/data/object.qml";
- QTest::newRow("Object - Id") << SRCDIR "/data/object_id.qml";
- QTest::newRow("MyQmlObject") << SRCDIR "/data/myqmlobject.qml";
- QTest::newRow("MyQmlObject: basic binding") << SRCDIR "/data/myqmlobject_binding.qml";
- QTest::newRow("Synthesized properties") << SRCDIR "/data/synthesized_properties.qml";
- QTest::newRow("Synthesized properties.2") << SRCDIR "/data/synthesized_properties.2.qml";
- QTest::newRow("SameGame - BoomBlock") << SRCDIR "/data/samegame/BoomBlock.qml";
-}
-
-void tst_qmlcomponent::creation()
-{
- QFETCH(QString, file);
-
- QDeclarativeComponent c(&engine, file);
- QVERIFY(c.isReady());
-
- QObject *obj = c.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = c.create();
- delete obj;
- }
-}
-
-QTEST_MAIN(tst_qmlcomponent)
-#include "tst_qdeclarativecomponent.moc"
diff --git a/tests/benchmarks/declarative/qdeclarativedebugtrace/qdeclarativedebugtrace.pro b/tests/benchmarks/declarative/qdeclarativedebugtrace/qdeclarativedebugtrace.pro
deleted file mode 100644
index 6f2712adec..0000000000
--- a/tests/benchmarks/declarative/qdeclarativedebugtrace/qdeclarativedebugtrace.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-QT += declarative testlib
-TEMPLATE = app
-TARGET = tst_qdeclarativedebugtrace
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativedebugtrace.cpp
-
diff --git a/tests/benchmarks/declarative/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp b/tests/benchmarks/declarative/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp
deleted file mode 100644
index a8ac44a008..0000000000
--- a/tests/benchmarks/declarative/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QElapsedTimer>
-#include <QObject>
-#include <qtest.h>
-
-class tst_qdeclarativedebugtrace : public QObject
-{
- Q_OBJECT
-
-public:
- tst_qdeclarativedebugtrace() {}
-
-private slots:
- void all();
- void startElapsed();
- void doubleElapsed();
- void trace();
-};
-
-void tst_qdeclarativedebugtrace::all()
-{
- QBENCHMARK {
- QElapsedTimer t;
- t.start();
- t.nsecsElapsed();
- }
-}
-
-void tst_qdeclarativedebugtrace::startElapsed()
-{
- QElapsedTimer t;
- QBENCHMARK {
- t.start();
- t.nsecsElapsed();
- }
-}
-
-void tst_qdeclarativedebugtrace::doubleElapsed()
-{
- QElapsedTimer t;
- t.start();
- QBENCHMARK {
- t.nsecsElapsed();
- t.nsecsElapsed();
- }
-}
-
-void tst_qdeclarativedebugtrace::trace()
-{
- QString s("A decent sized string of text here.");
- QBENCHMARK {
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (qint64)100 << (int)5 << (int)5 << s;
- }
-}
-
-QTEST_MAIN(tst_qdeclarativedebugtrace)
-
-#include "tst_qdeclarativedebugtrace.moc"
diff --git a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro
deleted file mode 100644
index 6a46e8f40c..0000000000
--- a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_qdeclarativeimage
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-CONFIG += release
-
-SOURCES += tst_qdeclarativeimage.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
diff --git a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
deleted file mode 100644
index fcebd35671..0000000000
--- a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <private/qdeclarativeimage_p.h>
-
-class tst_qmlgraphicsimage : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsimage() {}
-
-private slots:
- void qmlgraphicsimage();
- void qmlgraphicsimage_file();
- void qmlgraphicsimage_url();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qmlgraphicsimage::qmlgraphicsimage()
-{
- int x = 0;
- QUrl url(SRCDIR "/image.png");
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QDeclarativeImage *image = new QDeclarativeImage;
- QDeclarativeEngine::setContextForObject(image, engine.rootContext());
- delete image;
- }
-}
-
-void tst_qmlgraphicsimage::qmlgraphicsimage_file()
-{
- int x = 0;
- QUrl url(SRCDIR "/image.png");
- //get rid of initialization effects
- {
- QDeclarativeImage *image = new QDeclarativeImage;
- QDeclarativeEngine::setContextForObject(image, engine.rootContext());
- image->setSource(url);
- }
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QDeclarativeImage *image = new QDeclarativeImage;
- QDeclarativeEngine::setContextForObject(image, engine.rootContext());
- image->setSource(url);
- delete image;
- }
-}
-
-void tst_qmlgraphicsimage::qmlgraphicsimage_url()
-{
- int x = 0;
- QUrl url(SRCDIR "/image.png");
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QDeclarativeImage *image = new QDeclarativeImage;
- QDeclarativeEngine::setContextForObject(image, engine.rootContext());
- image->setSource(url2);
- delete image;
- }
-}
-
-QTEST_MAIN(tst_qmlgraphicsimage)
-
-#include "tst_qdeclarativeimage.moc"
diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml
deleted file mode 100644
index c386df72a3..0000000000
--- a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {}
diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml
deleted file mode 100644
index 6eec87aea1..0000000000
--- a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- property int blah
-}
-
diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro
deleted file mode 100644
index 1ac0bb240a..0000000000
--- a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_qdeclarativemetaproperty
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativemetaproperty.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp b/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp
deleted file mode 100644
index 7726c051ac..0000000000
--- a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDeclarativeProperty>
-#include <QFile>
-#include <QDebug>
-
-class tst_qmlmetaproperty : public QObject
-{
- Q_OBJECT
-
-public:
- tst_qmlmetaproperty();
- virtual ~tst_qmlmetaproperty();
-
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void lookup_data();
- void lookup();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qmlmetaproperty::tst_qmlmetaproperty()
-{
-}
-
-tst_qmlmetaproperty::~tst_qmlmetaproperty()
-{
-}
-
-void tst_qmlmetaproperty::init()
-{
-}
-
-void tst_qmlmetaproperty::cleanup()
-{
-}
-
-void tst_qmlmetaproperty::lookup_data()
-{
- QTest::addColumn<QString>("file");
-
- QTest::newRow("Simple Object") << SRCDIR "/data/object.qml";
- QTest::newRow("Synthesized Object") << SRCDIR "/data/synthesized_object.qml";
-}
-
-void tst_qmlmetaproperty::lookup()
-{
- QFETCH(QString, file);
-
- QDeclarativeComponent c(&engine, file);
- QVERIFY(c.isReady());
-
- QObject *obj = c.create();
-
- QBENCHMARK {
- QDeclarativeProperty p(obj, "x");
- }
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qmlmetaproperty)
-#include "tst_qdeclarativemetaproperty.moc"
diff --git a/tests/benchmarks/declarative/qmltime/example.qml b/tests/benchmarks/declarative/qmltime/example.qml
deleted file mode 100644
index f608963930..0000000000
--- a/tests/benchmarks/declarative/qmltime/example.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- property string name: "Bob Smith"
-
- QmlTime.Timer {
- component: Item {
- Text { text: name }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp
deleted file mode 100644
index f33b9205e7..0000000000
--- a/tests/benchmarks/declarative/qmltime/qmltime.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-#include <QApplication>
-#include <QTime>
-#include <QDeclarativeContext>
-#include <QGraphicsScene>
-#include <QGraphicsRectItem>
-
-class Timer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent)
-
-public:
- Timer();
-
- QDeclarativeComponent *component() const;
- void setComponent(QDeclarativeComponent *);
-
- static Timer *timerInstance();
-
- void run(uint);
-
- bool willParent() const;
- void setWillParent(bool p);
-
-private:
- void runTest(QDeclarativeContext *, uint);
-
- QDeclarativeComponent *m_component;
- static Timer *m_timer;
-
- bool m_willparent;
- QGraphicsScene m_scene;
- QGraphicsRectItem m_item;
-};
-QML_DECLARE_TYPE(Timer);
-
-Timer *Timer::m_timer = 0;
-
-Timer::Timer()
-: m_component(0), m_willparent(false)
-{
- if (m_timer)
- qWarning("Timer: Timer already registered");
- m_timer = this;
-
- m_scene.setItemIndexMethod(QGraphicsScene::NoIndex);
- m_scene.addItem(&m_item);
-}
-
-QDeclarativeComponent *Timer::component() const
-{
- return m_component;
-}
-
-void Timer::setComponent(QDeclarativeComponent *c)
-{
- m_component = c;
-}
-
-Timer *Timer::timerInstance()
-{
- return m_timer;
-}
-
-void Timer::run(uint iterations)
-{
- QDeclarativeContext context(qmlContext(this));
-
- QObject *o = m_component->create(&context);
- QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
- if (m_willparent && go)
- go->setParentItem(&m_item);
- delete o;
-
- runTest(&context, iterations);
-}
-
-bool Timer::willParent() const
-{
- return m_willparent;
-}
-
-void Timer::setWillParent(bool p)
-{
- m_willparent = p;
-}
-
-void Timer::runTest(QDeclarativeContext *context, uint iterations)
-{
- QTime t;
- t.start();
- for (uint ii = 0; ii < iterations; ++ii) {
- QObject *o = m_component->create(context);
- QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
- if (m_willparent && go)
- go->setParentItem(&m_item);
- delete o;
- }
-
- int e = t.elapsed();
-
- qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms";
-
-}
-
-void usage(const char *name)
-{
- qWarning("Usage: %s [-iterations <count>] [-parent] <qml file>\n", name);
-
- qWarning("qmltime is a tool for benchmarking the runtime cost of instantiating\n"
- "a QML component. It is typically run as follows:\n"
- "\n"
- "%s path/to/benchmark.qml\n"
- "\n"
- "If the -parent option is specified, the component being measured will also\n"
- "be parented to an item already in the scene.\n"
- "\n"
- "If the -iterations option is specified, the benchmark will run the specified\n"
- "number of iterations. If -iterations is not specified, 1024 iterations\n"
- "are performed.\n"
- "\n"
- "qmltime expects the file to be benchmarked to contain a certain structure.\n"
- "Specifically, it requires the presence of a QmlTime.Timer element. For example,\n"
- "say we wanted to benchmark the following list delegate:\n"
- "\n"
- "Rectangle {\n"
- " color: \"green\"\n"
- " width: 400; height: 100\n"
- " Text {\n"
- " anchors.centerIn: parent\n"
- " text: name\n"
- " }\n"
- "}\n"
- "\n"
- "we would create a benchmark file that looks like this:\n"
- "\n"
- "import QtQuick 2.0\n"
- "import QmlTime 1.0 as QmlTime\n"
- "\n"
- "Item {\n"
- "\n"
- " property string name: \"Bob Smith\"\n"
- "\n"
- " QmlTime.Timer {\n"
- " component: Rectangle {\n"
- " color: \"green\"\n"
- " width: 400; height: 100\n"
- " Text {\n"
- " anchors.centerIn: parent\n"
- " text: name\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n"
- "\n"
- "The outer Item functions as a dummy data provider for any additional\n"
- "data required by the bindings in the component being benchmarked (in the\n"
- "example above we provide a \"name\" property).\n"
- "\n"
- "When started, the component is instantiated once before running\n"
- "the benchmark, which means that the reported time does not include\n"
- "compile time (as the results of compilation are cached internally).\n"
- "In this sense the times reported by qmltime best correspond to the\n"
- "costs associated with delegate creation in the view classes, where the\n"
- "same delegate is instantiated over and over. Conversely, it is not a\n"
- "good approximation for e.g. Loader, which typically only instantiates\n"
- "an element once (and so for Loader the compile time is very relevant\n"
- "to the overall cost).", name);
-
- exit(-1);
-}
-
-int main(int argc, char ** argv)
-{
- QApplication app(argc, argv);
-
- qmlRegisterType<Timer>("QmlTime", 1, 0, "Timer");
-
- uint iterations = 1024;
- QString filename;
- bool willParent = false;
-
- for (int ii = 1; ii < argc; ++ii) {
- QByteArray arg(argv[ii]);
-
- if (arg == "-iterations") {
- if (ii + 1 < argc) {
- ++ii;
- QByteArray its(argv[ii]);
- bool ok = false;
- iterations = its.toUInt(&ok);
- if (!ok)
- usage(argv[0]);
- } else {
- usage(argv[0]);
- }
- } else if (arg == "-parent") {
- willParent = true;
- } else if (arg == "-help") {
- usage(argv[0]);
- } else {
- filename = QLatin1String(argv[ii]);
- }
- }
-
- if (filename.isEmpty())
- usage(argv[0]);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, filename);
- if (component.isError()) {
- qWarning() << component.errors();
- return -1;
- }
-
- QObject *obj = component.create();
- if (!obj) {
- qWarning() << component.errors();
- return -1;
- }
-
- Timer *timer = Timer::timerInstance();
- if (!timer) {
- qWarning() << "A Tester.Timer instance is required.";
- return -1;
- }
-
- timer->setWillParent(willParent);
-
- if (!timer->component()) {
- qWarning() << "The timer has no component";
- return -1;
- }
-
- timer->run(iterations);
-
- return 0;
-}
-
-#include "qmltime.moc"
diff --git a/tests/benchmarks/declarative/qmltime/qmltime.pro b/tests/benchmarks/declarative/qmltime/qmltime.pro
deleted file mode 100644
index e1948981bf..0000000000
--- a/tests/benchmarks/declarative/qmltime/qmltime.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = qmltime
-QT += declarative widgets testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += qmltime.cpp
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml
deleted file mode 100644
index b08b43268c..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml
deleted file mode 100644
index a173050427..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml
deleted file mode 100644
index ea01839e14..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Item {
- }
- Item {
- }
- Item {
- }
- Item {
- }
- Item {
- }
- Item {
- }
- Item {
- }
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/large.qml b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml
deleted file mode 100644
index b58de4955b..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/animation/large.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- ParallelAnimation {
- NumberAnimation { duration: 500 }
- NumberAnimation { duration: 4000; }
- NumberAnimation { duration: 2000; easing.type: "OutBack"}
- ColorAnimation { duration: 3000}
- SequentialAnimation {
- PauseAnimation { duration: 1000 }
- ScriptAction { script: doSomething(); }
- PauseAnimation { duration: 800 }
- ScriptAction { script: doSomethingElse(); }
- PauseAnimation { duration: 800 }
- ParallelAnimation {
- NumberAnimation { duration: 200;}
- SequentialAnimation {
- PauseAnimation { duration: 200}
- ParallelAnimation {
- NumberAnimation { duration: 300;}
- NumberAnimation { duration: 300;}
- }
- NumberAnimation { from: 0; to: 1; duration: 500 }
- PauseAnimation { duration: 200 }
- NumberAnimation { from: 1; to: 0; duration: 500 }
- }
- SequentialAnimation {
- PauseAnimation { duration: 150}
- NumberAnimation { duration: 300; easing.type: "OutBounce" }
- }
- }
- }
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml
deleted file mode 100644
index fbe4acb8d3..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- ParallelAnimation {
- NumberAnimation { }
- NumberAnimation { }
- NumberAnimation { }
- ColorAnimation { }
- SequentialAnimation {
- PauseAnimation { }
- ScriptAction { }
- PauseAnimation { }
- ScriptAction { }
- PauseAnimation { }
- ParallelAnimation {
- NumberAnimation { }
- SequentialAnimation {
- PauseAnimation { }
- ParallelAnimation {
- NumberAnimation { }
- NumberAnimation { }
- }
- NumberAnimation { }
- PauseAnimation { }
- NumberAnimation { }
- }
- SequentialAnimation {
- PauseAnimation { }
- NumberAnimation { }
- }
- }
- }
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
deleted file mode 100644
index 85698d6bf6..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- children: [
- Rectangle { },
- Rectangle { },
- Item { },
- Image { },
- Text { },
- Item { },
- Item { },
- Image { },
- Image { },
- Row { },
- Image { },
- Image { },
- Column { },
- Row { },
- Text { },
- Text { },
- Text { },
- MouseArea { }
- ]
-
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
deleted file mode 100644
index 6a8ca1b968..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- data: [
- Rectangle { },
- Rectangle { },
- Item { },
- Image { },
- Text { },
- Item { },
- Item { },
- Image { },
- Image { },
- Row { },
- Image { },
- Image { },
- Column { },
- Row { },
- Text { },
- Text { },
- Text { },
- MouseArea { }
- ]
-
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml
deleted file mode 100644
index 4dde9f289e..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- }
- }
- }
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
deleted file mode 100644
index 802598839c..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- resources: [
- Rectangle { },
- Rectangle { },
- Item { },
- Image { },
- Text { },
- Item { },
- Item { },
- Image { },
- Image { },
- Row { },
- Image { },
- Image { },
- Column { },
- Row { },
- Text { },
- Text { },
- Text { },
- MouseArea { }
- ]
-
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml
deleted file mode 100644
index d5d22f948c..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- Rectangle {}
- Text {}
- Image {}
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml
deleted file mode 100644
index ab42dfb2f9..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Loader {
- sourceComponent: Loaded {}
- }
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml
deleted file mode 100644
index c32ca2e61b..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Loader {}
- Loaded {}
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml
deleted file mode 100644
index dff5f11f99..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Loaded {}
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml
deleted file mode 100644
index 6b16afc1c4..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Loader {
- source: "Loaded.qml"
- }
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
deleted file mode 100644
index e9f13e9deb..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
- QmlTime.Timer {
- component: Component {
- Item {
- Rectangle { }
- Rectangle { }
- Item {
- Image { }
- Text { }
- }
-
- Item {
- Item {
- Image { }
- Image { }
- Item {
- Image { }
- Image { }
- }
- }
-
- Item {
- Item {
- Text { }
- Text { }
- }
- Text { }
- }
- }
- MouseArea { }
- }
- }
- }
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml
deleted file mode 100644
index d50da90764..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
- QmlTime.Timer {
- component: Component {
- Item {
- Rectangle { }
- Rectangle { }
- Item {
- Image { }
- Text { }
- }
-
- Item {
- Item {
- Image { }
- Image { }
- Row { }
- Image { }
- Image { }
- }
-
- Column { }
- Row { }
- Text { }
- Text { }
- Text { }
- }
- MouseArea { }
- }
- }
- }
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
deleted file mode 100644
index 8f7814be6a..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
- QmlTime.Timer {
- component: Component {
- Item {
- Rectangle { }
- Rectangle { }
- Item {
- Image { }
- Text { }
- }
-
- Item {
- Item {
- Image { }
- Image { }
- Row {
- Image { }
- Image { }
- }
- }
-
- Column {
- Row {
- Text { }
- Text { }
- }
- Text { }
- }
- }
- MouseArea { }
- }
- }
- }
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml b/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml
deleted file mode 100644
index 34d6b30670..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- QtObject {
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml b/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml
deleted file mode 100644
index 4dd63bb36e..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- QtObject {
- property string s
- property string s2
- property string s3
- property string s4
- }
- }
- }
-
-}
-
diff --git a/tests/benchmarks/declarative/script/data/CustomObject.qml b/tests/benchmarks/declarative/script/data/CustomObject.qml
deleted file mode 100644
index 7c8c561114..0000000000
--- a/tests/benchmarks/declarative/script/data/CustomObject.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-QtObject {
- property real prop1: 0
- property real prop2: 1
- property real prop3: 0
-}
diff --git a/tests/benchmarks/declarative/script/data/block.qml b/tests/benchmarks/declarative/script/data/block.qml
deleted file mode 100644
index 67ad5cbed2..0000000000
--- a/tests/benchmarks/declarative/script/data/block.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- width: 200; height: 200
- CustomObject { id: theObject }
- function doSomethingDirect() {
- theObject.prop1 = 0;
-
- for (var i = 0; i < 1000; ++i)
- theObject.prop1 += theObject.prop2;
-
- theObject.prop3 = theObject.prop1;
- }
-
- function doSomethingLocalObj() {
- theObject.prop1 = 0;
-
- var incrementObj = theObject;
- for (var i = 0; i < 1000; ++i)
- incrementObj.prop1 += incrementObj.prop2;
-
- incrementObj.prop3 = incrementObj.prop1;
- }
-
- function doSomethingLocal() {
- theObject.prop1 = 0;
-
- var increment = theObject.prop2;
- for (var i = 0; i < 1000; ++i)
- theObject.prop1 += increment;
-
- theObject.prop3 = theObject.prop1;
- }
-}
diff --git a/tests/benchmarks/declarative/script/data/enums.qml b/tests/benchmarks/declarative/script/data/enums.qml
deleted file mode 100644
index 8450b15732..0000000000
--- a/tests/benchmarks/declarative/script/data/enums.qml
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the Declarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- function runtest() {
- var a = 0;
- for (var ii = 0; ii < 100000; ++ii)
- a += Text.RichText;
- return a;
- }
-}
diff --git a/tests/benchmarks/declarative/script/data/namespacedEnums.qml b/tests/benchmarks/declarative/script/data/namespacedEnums.qml
deleted file mode 100644
index e49bf7e1ad..0000000000
--- a/tests/benchmarks/declarative/script/data/namespacedEnums.qml
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the Declarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0 as QtQuick
-
-QtQuick.Item {
- function runtest() {
- var a = 0;
- for (var ii = 0; ii < 100000; ++ii)
- a += QtQuick.Text.RichText;
- return a;
- }
-}
-
diff --git a/tests/benchmarks/declarative/script/data/scriptCall.qml b/tests/benchmarks/declarative/script/data/scriptCall.qml
deleted file mode 100644
index 420f621dfc..0000000000
--- a/tests/benchmarks/declarative/script/data/scriptCall.qml
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the Declarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "script.js" as Script
-import "script2.js" as OtherScript
-
-Item {
- function runtest() {
- var a = 0;
- for (var ii = 0; ii < 1000000; ++ii)
- a += Script.func();
- return a;
- }
-}
-
diff --git a/tests/benchmarks/declarative/script/data/signal_args.qml b/tests/benchmarks/declarative/script/data/signal_args.qml
deleted file mode 100644
index ed5c56a197..0000000000
--- a/tests/benchmarks/declarative/script/data/signal_args.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-
-TestObject {
- onMySignalWithArgs: { var a = n; return a; }
-}
-
diff --git a/tests/benchmarks/declarative/script/data/signal_heavyArgsAccess.qml b/tests/benchmarks/declarative/script/data/signal_heavyArgsAccess.qml
deleted file mode 100644
index a9675c333b..0000000000
--- a/tests/benchmarks/declarative/script/data/signal_heavyArgsAccess.qml
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-
-TestObject {
- onMySignalWithArgs: {
- var a = 0;
- for (var i = 0; i < 10000; ++i)
- a += n;
- return a;
- }
-}
diff --git a/tests/benchmarks/declarative/script/data/signal_heavyIdAccess.qml b/tests/benchmarks/declarative/script/data/signal_heavyIdAccess.qml
deleted file mode 100644
index e426ee5116..0000000000
--- a/tests/benchmarks/declarative/script/data/signal_heavyIdAccess.qml
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-
-TestObject {
- id: obj
- property real inc: 3
-
- onMySignalWithArgs: {
- var a = 0;
- for (var i = 0; i < 10000; ++i)
- a += obj.inc;
- return a;
- }
-}
diff --git a/tests/benchmarks/declarative/script/data/signal_qml.qml b/tests/benchmarks/declarative/script/data/signal_qml.qml
deleted file mode 100644
index c5bda7d18e..0000000000
--- a/tests/benchmarks/declarative/script/data/signal_qml.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-
-TestObject {
- onMySignal: { var a = 1; return a; }
-}
-
diff --git a/tests/benchmarks/declarative/script/data/signal_unconnected.qml b/tests/benchmarks/declarative/script/data/signal_unconnected.qml
deleted file mode 100644
index 90fe2bc6f5..0000000000
--- a/tests/benchmarks/declarative/script/data/signal_unconnected.qml
+++ /dev/null
@@ -1,45 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-
-TestObject {
-}
diff --git a/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml b/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml
deleted file mode 100644
index 6de5815939..0000000000
--- a/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-
-TestObject {
- onMySignalWithArgs: { var a = 1; return a; }
-}
-
diff --git a/tests/benchmarks/declarative/script/data/slot_complex.qml b/tests/benchmarks/declarative/script/data/slot_complex.qml
deleted file mode 100644
index 8e2cb30089..0000000000
--- a/tests/benchmarks/declarative/script/data/slot_complex.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-
-TestObject {
- function myCustomFunction(b) {
- var n = b;
- var a = 1;
- while (n > 0) {
- a = a * n;
- n--;
- }
- return a;
- }
-
- onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(10); } }
-}
-
diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.qml b/tests/benchmarks/declarative/script/data/slot_complex_js.qml
deleted file mode 100644
index ca06046389..0000000000
--- a/tests/benchmarks/declarative/script/data/slot_complex_js.qml
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-import "slot_complex_js.js" as Logic
-
-TestObject {
- onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(10); } }
-}
-
-
diff --git a/tests/benchmarks/declarative/script/data/slot_simple.qml b/tests/benchmarks/declarative/script/data/slot_simple.qml
deleted file mode 100644
index c93fbcc757..0000000000
--- a/tests/benchmarks/declarative/script/data/slot_simple.qml
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-
-TestObject {
- function myCustomFunction() {
- return 0;
- }
-
- onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(); } }
-}
diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.qml b/tests/benchmarks/declarative/script/data/slot_simple_js.qml
deleted file mode 100644
index 07334ab4fa..0000000000
--- a/tests/benchmarks/declarative/script/data/slot_simple_js.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 1.0
-import "slot_simple_js.js" as Logic
-
-TestObject {
- onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(); } }
-}
-
diff --git a/tests/benchmarks/declarative/script/script.pro b/tests/benchmarks/declarative/script/script.pro
deleted file mode 100644
index 6b454beed5..0000000000
--- a/tests/benchmarks/declarative/script/script.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_script
-macx:CONFIG -= app_bundle
-CONFIG += release
-
-SOURCES += tst_script.cpp
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp
deleted file mode 100644
index 77a0d36d3a..0000000000
--- a/tests/benchmarks/declarative/script/tst_script.cpp
+++ /dev/null
@@ -1,852 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qquickrectangle_p.h>
-#include <QJSEngine>
-#include <QJSValue>
-
-class tst_script : public QObject
-{
- Q_OBJECT
-public:
- tst_script() {}
-
-private slots:
- void initTestCase();
-
- void property_js();
- void property_getter_js();
-#if 0
- //no native functions for now
- void property_getter();
- void property_getter_qobject();
- void property_getter_qmetaproperty();
-#endif
- void property_qobject();
- void property_qmlobject();
-
- void setproperty_js();
- void setproperty_qmlobject();
-
- void function_js();
-#if 0
- //no native functions for now
- void function_cpp();
-#endif
- void function_qobject();
- void function_qmlobject();
-
- void function_args_js();
-#if 0
- //no native functions for now
- void function_args_cpp();
-#endif
- void function_args_qobject();
- void function_args_qmlobject();
-
- void signal_unconnected();
- void signal_qml();
- void signal_args();
- void signal_unusedArgs();
- void signal_heavyArgsAccess();
- void signal_heavyIdAccess();
-
- void slot_simple();
- void slot_simple_js();
- void slot_complex();
- void slot_complex_js();
-
- void block_data();
- void block();
-
- void global_property_js();
- void global_property_qml();
- void global_property_qml_js();
-
- void scriptfile_property();
-
- void enums();
- void namespacedEnums();
- void scriptCall();
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-class TestObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int x READ x WRITE setX)
-
-public:
- TestObject(QObject *parent = 0);
-
- int x();
- void setX(int x) { m_x = x; }
-
- void emitMySignal() { emit mySignal(); }
- void emitMySignalWithArgs(int n) { emit mySignalWithArgs(n); }
-
-signals:
- void mySignal();
- void mySignalWithArgs(int n);
-
-public slots:
- int method() {
- return x();
- }
-
- int methodArgs(int val) {
- return val + x();
- }
-
-private:
- int m_x;
-};
-QML_DECLARE_TYPE(TestObject);
-
-TestObject::TestObject(QObject *parent)
-: QObject(parent), m_x(0)
-{
-}
-
-int TestObject::x()
-{
- return m_x++;
-}
-
-void tst_script::initTestCase()
-{
- qmlRegisterType<TestObject>("Qt.test", 1, 0, "TestObject");
-}
-
-
-#define PROPERTY_PROGRAM \
- "(function(testObject) { return (function() { " \
- " var test = 0; " \
- " for (var ii = 0; ii < 10000; ++ii) { " \
- " test += testObject.x; " \
- " } " \
- " return test; " \
- "}); })"
-
-void tst_script::property_js()
-{
- QJSEngine engine;
-
- QJSValue v = engine.newObject();
- v.setProperty(QLatin1String("x"), 10);
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call().toNumber();
- }
-}
-
-#if 0
-static QJSValue property_getter_method(QScriptContext *, QJSEngine *engine)
-{
- static int x = 0;
- return QJSValue(engine,x++);
-}
-
-void tst_script::property_getter()
-{
- QJSEngine engine;
-
- QJSValue v = engine.newObject();
- v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_method),
- QJSValue::PropertyGetter);
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-static TestObject *property_getter_qobject_object = 0;
-static QJSValue property_getter_qobject_method(QScriptContext *, QJSEngine *)
-{
- static int idx = -1;
- if (idx == -1)
- idx = TestObject::staticMetaObject.indexOfProperty("x");
-
- int value = 0;
- void *args[] = { &value, 0 };
- QMetaObject::metacall(property_getter_qobject_object, QMetaObject::ReadProperty, idx, args);
-
- return QJSValue(value);
-}
-
-static QJSValue property_getter_qmetaproperty_method(QScriptContext *, QJSEngine *)
-{
- static int idx = -1;
- if (idx == -1)
- idx = TestObject::staticMetaObject.indexOfProperty("x");
-
- int value = 0;
- value = property_getter_qobject_object->metaObject()->property(idx).read(property_getter_qobject_object).toInt();
-
- return QJSValue(value);
-}
-
-void tst_script::property_getter_qobject()
-{
- QJSEngine engine;
-
- TestObject to;
- property_getter_qobject_object = &to;
- QJSValue v = engine.newObject();
- v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qobject_method),
- QJSValue::PropertyGetter);
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
- property_getter_qobject_object = 0;
-}
-
-void tst_script::property_getter_qmetaproperty()
-{
- QJSEngine engine;
-
- TestObject to;
- property_getter_qobject_object = &to;
- QJSValue v = engine.newObject();
- v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qmetaproperty_method),
- QJSValue::PropertyGetter);
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
- property_getter_qobject_object = 0;
-}
-#endif
-
-void tst_script::property_getter_js()
-{
- QJSEngine engine;
-
- QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.__defineGetter__(\"x\", function() { return this._x++; }); return o; })").call();
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-void tst_script::property_qobject()
-{
- QJSEngine engine;
-
- TestObject to;
- QJSValue v = engine.newQObject(&to);
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-void tst_script::property_qmlobject()
-{
- QDeclarativeEngine qmlengine;
-
- TestObject to;
- QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(&qmlengine);
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
- QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
-
- QJSValueList args;
- args << v;
- QJSValue prog = qmlengine.evaluate(PROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-#define SETPROPERTY_PROGRAM \
- "(function(testObject) { return (function() { " \
- " for (var ii = 0; ii < 10000; ++ii) { " \
- " testObject.x = ii; " \
- " } " \
- "}); })"
-
-void tst_script::setproperty_js()
-{
- QJSEngine engine;
-
- QJSValue v = engine.newObject();
- v.setProperty(QLatin1String("x"), 0);
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-void tst_script::setproperty_qmlobject()
-{
- QDeclarativeEngine qmlengine;
-
- TestObject to;
-
- QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(&qmlengine);
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
- QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
-
- QJSValueList args;
- args << v;
- QJSValue prog = qmlengine.evaluate(SETPROPERTY_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-#define FUNCTION_PROGRAM \
- "(function(testObject) { return (function() { " \
- " var test = 0; " \
- " for (var ii = 0; ii < 10000; ++ii) { " \
- " test += testObject.method(); " \
- " } " \
- " return test; " \
- "}); })"
-
-void tst_script::function_js()
-{
- QJSEngine engine;
-
- QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.method = (function() { return this._x++; }); return o; })").call();
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-#if 0
-static QJSValue function_method(QScriptContext *, QJSEngine *)
-{
- static int x = 0;
- return QJSValue(x++);
-}
-
-void tst_script::function_cpp()
-{
- QJSEngine engine;
-
- QJSValue v = engine.newObject();
- v.setProperty(QLatin1String("method"), engine.newFunction(function_method));
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-#endif
-
-void tst_script::function_qobject()
-{
- QJSEngine engine;
-
- TestObject to;
- QJSValue v = engine.newQObject(&to);
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-void tst_script::function_qmlobject()
-{
- QDeclarativeEngine qmlengine;
-
- TestObject to;
-
- QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(&qmlengine);
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
- QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
-
- QJSValueList args;
- args << v;
- QJSValue prog = qmlengine.evaluate(FUNCTION_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-#define FUNCTION_ARGS_PROGRAM \
- "(function(testObject) { return (function() { " \
- " var test = 0; " \
- " for (var ii = 0; ii < 10000; ++ii) { " \
- " test += testObject.methodArgs(ii); " \
- " } " \
- " return test; " \
- "}); })"
-
-void tst_script::function_args_js()
-{
- QJSEngine engine;
-
- QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.methodArgs = (function(a) { return a + this._x++; }); return o; })").call();
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-#if 0
-static QJSValue function_args_method(QScriptContext *ctxt, QJSEngine *)
-{
- static int x = 0;
- return QJSValue(ctxt->argument(0).toNumber() + x++);
-}
-
-void tst_script::function_args_cpp()
-{
- QJSEngine engine;
-
- QJSValue v = engine.newObject();
- v.setProperty(QLatin1String("methodArgs"), engine.newFunction(function_args_method));
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-#endif
-
-void tst_script::function_args_qobject()
-{
- QJSEngine engine;
-
- TestObject to;
- QJSValue v = engine.newQObject(&to);
-
- QJSValueList args;
- args << v;
- QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-void tst_script::function_args_qmlobject()
-{
- QDeclarativeEngine qmlengine;
-
- TestObject to;
-
- QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(&qmlengine);
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
- QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
-
- QJSValueList args;
- args << v;
- QJSValue prog = qmlengine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-void tst_script::signal_unconnected()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("signal_unconnected.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignal();
- }
-
- delete object;
-}
-
-void tst_script::signal_qml()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("signal_qml.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignal();
- }
-
- delete object;
-}
-
-void tst_script::signal_args()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("signal_args.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignalWithArgs(11);
- }
-
- delete object;
-}
-
-void tst_script::signal_unusedArgs()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("signal_unusedArgs.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignalWithArgs(11);
- }
-
- delete object;
-}
-
-void tst_script::signal_heavyArgsAccess()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("signal_heavyArgsAccess.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignalWithArgs(11);
- }
-
- delete object;
-}
-
-void tst_script::signal_heavyIdAccess()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("signal_heavyIdAccess.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignalWithArgs(11);
- }
-
- delete object;
-}
-
-void tst_script::slot_simple()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("slot_simple.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignal();
- }
-
- delete object;
-}
-
-void tst_script::slot_simple_js()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("slot_simple_js.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignal();
- }
-
- delete object;
-}
-
-void tst_script::slot_complex()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("slot_complex.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignal();
- }
-
- delete object;
-}
-
-void tst_script::slot_complex_js()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("slot_complex_js.qml"));
- TestObject *object = qobject_cast<TestObject *>(component.create());
- QVERIFY(object != 0);
-
- QBENCHMARK {
- object->emitMySignal();
- }
-
- delete object;
-}
-
-void tst_script::block_data()
-{
- QTest::addColumn<QString>("methodName");
- QTest::newRow("direct") << "doSomethingDirect()";
- QTest::newRow("localObj") << "doSomethingLocalObj()";
- QTest::newRow("local") << "doSomethingLocal()";
-}
-
-void tst_script::block()
-{
- QFETCH(QString, methodName);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("block.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(component.create());
- QVERIFY(rect != 0);
-
- int index = rect->metaObject()->indexOfMethod(methodName.toUtf8());
- QVERIFY(index != -1);
- QMetaMethod method = rect->metaObject()->method(index);
-
- QBENCHMARK {
- method.invoke(rect, Qt::DirectConnection);
- }
-
- delete rect;
-}
-
-#define GLOBALPROPERTY_PROGRAM \
- "(function() { " \
- " for (var ii = 0; ii < 10000; ++ii) { " \
- " Math.sin(90); " \
- " } " \
- "})"
-
-void tst_script::global_property_js()
-{
- QJSEngine engine;
-
- QJSValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-void tst_script::global_property_qml()
-{
- QDeclarativeEngine qmlengine;
-
- QJSValue prog = qmlengine.evaluate(GLOBALPROPERTY_PROGRAM);
- prog.call();
-
- QBENCHMARK {
- prog.call();
- }
-}
-
-void tst_script::global_property_qml_js()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(component.create());
- QVERIFY(rect != 0);
-
- int index = rect->metaObject()->indexOfMethod("triggered()");
- QVERIFY(index != -1);
- QMetaMethod method = rect->metaObject()->method(index);
-
- QBENCHMARK {
- method.invoke(rect, Qt::DirectConnection);
- }
-
- delete rect;
-}
-
-void tst_script::scriptfile_property()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(component.create());
- QVERIFY(rect != 0);
-
- int index = rect->metaObject()->indexOfMethod("incrementTriggered()");
- QVERIFY(index != -1);
- QMetaMethod method = rect->metaObject()->method(index);
-
- QBENCHMARK {
- method.invoke(rect, Qt::DirectConnection);
- }
-
- delete rect;
-}
-
-void tst_script::enums()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("enums.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- int index = o->metaObject()->indexOfMethod("runtest()");
- QVERIFY(index != -1);
- QMetaMethod method = o->metaObject()->method(index);
-
- QBENCHMARK {
- method.invoke(o, Qt::DirectConnection);
- }
-
- delete o;
-}
-
-void tst_script::namespacedEnums()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("namespacedEnums.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- int index = o->metaObject()->indexOfMethod("runtest()");
- QVERIFY(index != -1);
- QMetaMethod method = o->metaObject()->method(index);
-
- QBENCHMARK {
- method.invoke(o, Qt::DirectConnection);
- }
-
- delete o;
-}
-
-void tst_script::scriptCall()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("scriptCall.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- int index = o->metaObject()->indexOfMethod("runtest()");
- QVERIFY(index != -1);
- QMetaMethod method = o->metaObject()->method(index);
-
- QBENCHMARK {
- method.invoke(o, Qt::DirectConnection);
- }
-
- delete o;
-}
-
-QTEST_MAIN(tst_script)
-
-#include "tst_script.moc"
diff --git a/tests/benchmarks/declarative/typeimports/data/QmlTestType1.qml b/tests/benchmarks/declarative/typeimports/data/QmlTestType1.qml
deleted file mode 100644
index 47467a64a6..0000000000
--- a/tests/benchmarks/declarative/typeimports/data/QmlTestType1.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 2.0
-TestType1 { }
diff --git a/tests/benchmarks/declarative/typeimports/data/QmlTestType2.qml b/tests/benchmarks/declarative/typeimports/data/QmlTestType2.qml
deleted file mode 100644
index 2547d44ec0..0000000000
--- a/tests/benchmarks/declarative/typeimports/data/QmlTestType2.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 2.0
-TestType2 { }
diff --git a/tests/benchmarks/declarative/typeimports/data/QmlTestType3.qml b/tests/benchmarks/declarative/typeimports/data/QmlTestType3.qml
deleted file mode 100644
index b07f70a802..0000000000
--- a/tests/benchmarks/declarative/typeimports/data/QmlTestType3.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 2.0
-TestType3 { }
diff --git a/tests/benchmarks/declarative/typeimports/data/QmlTestType4.qml b/tests/benchmarks/declarative/typeimports/data/QmlTestType4.qml
deleted file mode 100644
index 3407b3b0bd..0000000000
--- a/tests/benchmarks/declarative/typeimports/data/QmlTestType4.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 2.0
-TestType4 { }
diff --git a/tests/benchmarks/declarative/typeimports/data/cpp.qml b/tests/benchmarks/declarative/typeimports/data/cpp.qml
deleted file mode 100644
index 28bc3222d3..0000000000
--- a/tests/benchmarks/declarative/typeimports/data/cpp.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt.test 2.0
-
-TestType1 {
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
-
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
- TestType1 { } TestType2 { } TestType3 { } TestType4 { }
-}
diff --git a/tests/benchmarks/declarative/typeimports/data/qml.qml b/tests/benchmarks/declarative/typeimports/data/qml.qml
deleted file mode 100644
index c6a71b30c5..0000000000
--- a/tests/benchmarks/declarative/typeimports/data/qml.qml
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-QmlTestType1 {
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
-
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
- QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
-}
diff --git a/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp b/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp
deleted file mode 100644
index a4fb034eb2..0000000000
--- a/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-
-class tst_typeimports : public QObject
-{
- Q_OBJECT
-public:
- tst_typeimports();
-
-private slots:
- void cpp();
- void qml();
-
-private:
- QDeclarativeEngine engine;
-};
-
-class TestType1 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources);
- Q_CLASSINFO("DefaultProperty", "resources");
-public:
- TestType1(QObject *parent = 0) : QObject(parent) {}
-
- QDeclarativeListProperty<QObject> resources() {
- return QDeclarativeListProperty<QObject>(this, 0, resources_append);
- }
-
- static void resources_append(QDeclarativeListProperty<QObject> *p, QObject *o) {
- o->setParent(p->object);
- }
-};
-
-class TestType2 : public TestType1
-{
- Q_OBJECT
-public:
- TestType2(QObject *parent = 0) : TestType1(parent) {}
-};
-
-
-class TestType3 : public TestType1
-{
- Q_OBJECT
-public:
- TestType3(QObject *parent = 0) : TestType1(parent) {}
-};
-
-class TestType4 : public TestType1
-{
- Q_OBJECT
-public:
- TestType4(QObject *parent = 0) : TestType1(parent) {}
-};
-
-
-tst_typeimports::tst_typeimports()
-{
- qmlRegisterType<TestType1>("Qt.test", 1, 0, "TestType1");
- qmlRegisterType<TestType2>("Qt.test", 1, 0, "TestType2");
- qmlRegisterType<TestType3>("Qt.test", 2, 0, "TestType3");
- qmlRegisterType<TestType4>("Qt.test", 2, 0, "TestType4");
-}
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_typeimports::cpp()
-{
- QBENCHMARK {
- QDeclarativeComponent component(&engine, TEST_FILE("cpp.qml"));
- QVERIFY(component.isReady());
- }
-}
-
-void tst_typeimports::qml()
-{
- //get rid of initialization effects
- { QDeclarativeComponent component(&engine, TEST_FILE("qml.qml")); }
-
- QBENCHMARK {
- QDeclarativeComponent component(&engine, TEST_FILE("qml.qml"));
- QVERIFY(component.isReady());
- }
-}
-
-QTEST_MAIN(tst_typeimports)
-
-#include "tst_typeimports.moc"
diff --git a/tests/benchmarks/declarative/typeimports/typeimports.pro b/tests/benchmarks/declarative/typeimports/typeimports.pro
deleted file mode 100644
index 403387f0ce..0000000000
--- a/tests/benchmarks/declarative/typeimports/typeimports.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TEMPLATE = app
-TARGET = tst_typeimports
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_typeimports.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/particles/affectors/affectors.pro b/tests/benchmarks/particles/affectors/affectors.pro
index 17b23255ac..654f788465 100644
--- a/tests/benchmarks/particles/affectors/affectors.pro
+++ b/tests/benchmarks/particles/affectors/affectors.pro
@@ -7,4 +7,4 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/benchmarks/particles/emission/emission.pro b/tests/benchmarks/particles/emission/emission.pro
index 343bdf0430..7c00c68c90 100644
--- a/tests/benchmarks/particles/emission/emission.pro
+++ b/tests/benchmarks/particles/emission/emission.pro
@@ -7,4 +7,4 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/benchmarks/qml/animation/animation.pro b/tests/benchmarks/qml/animation/animation.pro
new file mode 100644
index 0000000000..5efac8da1c
--- /dev/null
+++ b/tests/benchmarks/qml/animation/animation.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = tst_animation
+QT += qml
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_animation.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+QT += testlib core-private gui-private qml-private quick-private v8-private
diff --git a/tests/benchmarks/declarative/animation/data/animation.qml b/tests/benchmarks/qml/animation/data/animation.qml
index c48f5ccbe3..c48f5ccbe3 100644
--- a/tests/benchmarks/declarative/animation/data/animation.qml
+++ b/tests/benchmarks/qml/animation/data/animation.qml
diff --git a/tests/benchmarks/qml/animation/tst_animation.cpp b/tests/benchmarks/qml/animation/tst_animation.cpp
new file mode 100644
index 0000000000..e5619caa6c
--- /dev/null
+++ b/tests/benchmarks/qml/animation/tst_animation.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <private/qqmlmetatype_p.h>
+#include <private/qquickanimation_p_p.h>
+#include <QQmlContext>
+
+class tst_animation : public QObject
+{
+ Q_OBJECT
+public:
+ tst_animation();
+
+private slots:
+ void abstractAnimation();
+ void bulkValueAnimator();
+ void propertyUpdater();
+
+ void animationtree_qml();
+
+ void animationelements_data();
+ void animationelements();
+
+ void numberAnimation();
+ void numberAnimationStarted();
+ void numberAnimationMultipleTargets();
+ void numberAnimationEmpty();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_animation::tst_animation()
+{
+}
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_animation::abstractAnimation()
+{
+ QBENCHMARK {
+ QAbstractAnimationJob *animation = new QAbstractAnimationJob;
+ delete animation;
+ }
+}
+
+void tst_animation::bulkValueAnimator()
+{
+ QBENCHMARK {
+ QQuickBulkValueAnimator *animator = new QQuickBulkValueAnimator;
+ delete animator;
+ }
+}
+
+void tst_animation::propertyUpdater()
+{
+ QBENCHMARK {
+ QQuickAnimationPropertyUpdater *updater = new QQuickAnimationPropertyUpdater;
+ delete updater;
+ }
+}
+
+void tst_animation::animationtree_qml()
+{
+ QQmlComponent component(&engine, TEST_FILE("animation.qml"));
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_animation::animationelements_data()
+{
+ QTest::addColumn<QString>("type");
+
+ QSet<QString> types = QQmlMetaType::qmlTypeNames().toSet();
+ foreach (const QString &type, types) {
+ if (type.contains(QLatin1String("Animation")))
+ QTest::newRow(type.toLatin1()) << type;
+ }
+
+ QTest::newRow("QtQuick/Behavior") << "QtQuick/Behavior";
+ QTest::newRow("QtQuick/Transition") << "QtQuick/Transition";
+}
+
+void tst_animation::animationelements()
+{
+ QFETCH(QString, type);
+ QQmlType *t = QQmlMetaType::qmlType(type, 2, 0);
+ if (!t || !t->isCreatable())
+ QSKIP("Non-creatable type");
+
+ QBENCHMARK {
+ QObject *obj = t->create();
+ delete obj;
+ }
+}
+
+void tst_animation::numberAnimation()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; property: \"x\"; to: 100; duration: 500; easing.type: Easing.InOutQuad } } }", QUrl());
+
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_animation::numberAnimationStarted()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; property: \"x\"; to: 100; duration: 500; easing.type: Easing.InOutQuad; running: true; paused: true } } }", QUrl());
+
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_animation::numberAnimationMultipleTargets()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; properties: \"x,y,z,width,height,implicitWidth,implicitHeight\"; to: 100; duration: 500; easing.type: Easing.InOutQuad; running: true; paused: true } } }", QUrl());
+
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_animation::numberAnimationEmpty()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nNumberAnimation { }", QUrl());
+
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+QTEST_MAIN(tst_animation)
+
+#include "tst_animation.moc"
diff --git a/tests/benchmarks/qml/binding/binding.pro b/tests/benchmarks/qml/binding/binding.pro
new file mode 100644
index 0000000000..776c8390a3
--- /dev/null
+++ b/tests/benchmarks/qml/binding/binding.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_binding
+QT += qml testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_binding.cpp testtypes.cpp
+HEADERS += testtypes.h
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/binding/data/creation.txt b/tests/benchmarks/qml/binding/data/creation.txt
index 05704fa341..05704fa341 100644
--- a/tests/benchmarks/declarative/binding/data/creation.txt
+++ b/tests/benchmarks/qml/binding/data/creation.txt
diff --git a/tests/benchmarks/declarative/binding/data/idproperty.txt b/tests/benchmarks/qml/binding/data/idproperty.txt
index 4e474ba49a..4e474ba49a 100644
--- a/tests/benchmarks/declarative/binding/data/idproperty.txt
+++ b/tests/benchmarks/qml/binding/data/idproperty.txt
diff --git a/tests/benchmarks/declarative/binding/data/localproperty.txt b/tests/benchmarks/qml/binding/data/localproperty.txt
index c7ca0efdb4..c7ca0efdb4 100644
--- a/tests/benchmarks/declarative/binding/data/localproperty.txt
+++ b/tests/benchmarks/qml/binding/data/localproperty.txt
diff --git a/tests/benchmarks/declarative/binding/data/objectproperty.txt b/tests/benchmarks/qml/binding/data/objectproperty.txt
index 06409f2dd1..06409f2dd1 100644
--- a/tests/benchmarks/declarative/binding/data/objectproperty.txt
+++ b/tests/benchmarks/qml/binding/data/objectproperty.txt
diff --git a/tests/benchmarks/declarative/binding/testtypes.cpp b/tests/benchmarks/qml/binding/testtypes.cpp
index 31af4f15b0..31af4f15b0 100644
--- a/tests/benchmarks/declarative/binding/testtypes.cpp
+++ b/tests/benchmarks/qml/binding/testtypes.cpp
diff --git a/tests/benchmarks/qml/binding/testtypes.h b/tests/benchmarks/qml/binding/testtypes.h
new file mode 100644
index 0000000000..03542ca24c
--- /dev/null
+++ b/tests/benchmarks/qml/binding/testtypes.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int result READ result WRITE setResult)
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+ Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data)
+ Q_CLASSINFO("DefaultProperty", "data")
+public:
+ MyQmlObject() : m_result(0), m_value(0), m_object(0) {}
+
+ int result() const { return m_result; }
+ void setResult(int r) { m_result = r; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; emit valueChanged(); }
+
+ QQmlListProperty<QObject> data() { return QQmlListProperty<QObject>(this, m_data); }
+
+ MyQmlObject *object() const { return m_object; }
+ void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); }
+
+signals:
+ void valueChanged();
+ void objectChanged();
+
+private:
+ QList<QObject *> m_data;
+ int m_result;
+ int m_value;
+ MyQmlObject *m_object;
+};
+QML_DECLARE_TYPE(MyQmlObject);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/benchmarks/qml/binding/tst_binding.cpp b/tests/benchmarks/qml/binding/tst_binding.cpp
new file mode 100644
index 0000000000..cd854e06e0
--- /dev/null
+++ b/tests/benchmarks/qml/binding/tst_binding.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QQmlComponent>
+#include <QFile>
+#include <QDebug>
+#include "testtypes.h"
+
+class tst_binding : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_binding();
+ virtual ~tst_binding();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+private slots:
+ void objectproperty_data();
+ void objectproperty();
+ void basicproperty_data();
+ void basicproperty();
+ void creation_data();
+ void creation();
+
+private:
+ QQmlEngine engine;
+ MyQmlObject tstObject;
+};
+
+tst_binding::tst_binding()
+{
+}
+
+tst_binding::~tst_binding()
+{
+}
+
+void tst_binding::initTestCase()
+{
+ registerTypes();
+ engine.rootContext()->setContextProperty("tstObject", &tstObject);
+}
+
+void tst_binding::cleanupTestCase()
+{
+}
+
+#define COMPONENT(filename, binding) \
+ QQmlComponent c(&engine); \
+ { \
+ QFile f(filename); \
+ QVERIFY(f.open(QIODevice::ReadOnly)); \
+ QByteArray data = f.readAll(); \
+ data.replace("###", binding.toUtf8()); \
+ c.setData(data, QUrl()); \
+ QVERIFY(c.isReady()); \
+ }
+
+void tst_binding::objectproperty_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("binding");
+
+ QTest::newRow("object.value") << SRCDIR "/data/objectproperty.txt" << "object.value";
+ QTest::newRow("object.value + 10") << SRCDIR "/data/objectproperty.txt" << "object.value + 10";
+}
+
+void tst_binding::objectproperty()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, binding);
+
+ COMPONENT(file, binding);
+
+ MyQmlObject object1;
+ MyQmlObject object2;
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(c.create());
+ QVERIFY(object != 0);
+ object->setObject(&object2);
+
+ QBENCHMARK {
+ object->setObject(&object1);
+ object->setObject(&object2);
+ }
+}
+
+void tst_binding::basicproperty_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("binding");
+
+ QTest::newRow("value") << SRCDIR "/data/localproperty.txt" << "value";
+ QTest::newRow("value + 10") << SRCDIR "/data/localproperty.txt" << "value + 10";
+ QTest::newRow("value + value + 10") << SRCDIR "/data/localproperty.txt" << "value + value + 10";
+
+ QTest::newRow("myObject.value") << SRCDIR "/data/idproperty.txt" << "myObject.value";
+ QTest::newRow("myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + 10";
+ QTest::newRow("myObject.value + myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + myObject.value + 10";
+}
+
+void tst_binding::basicproperty()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, binding);
+
+ COMPONENT(file, binding);
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(c.create());
+ QVERIFY(object != 0);
+ object->setValue(10);
+
+ QBENCHMARK {
+ object->setValue(1);
+ }
+}
+
+void tst_binding::creation_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("binding");
+
+ QTest::newRow("constant") << SRCDIR "/data/creation.txt" << "10";
+ QTest::newRow("ownProperty") << SRCDIR "/data/creation.txt" << "myObject.value";
+ QTest::newRow("declaredProperty") << SRCDIR "/data/creation.txt" << "myObject.myValue";
+ QTest::newRow("contextProperty") << SRCDIR "/data/creation.txt" << "tstObject.value";
+}
+
+void tst_binding::creation()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, binding);
+
+ COMPONENT(file, binding);
+
+ QBENCHMARK {
+ QObject *o = c.create();
+ delete o;
+ }
+}
+
+QTEST_MAIN(tst_binding)
+#include "tst_binding.moc"
diff --git a/tests/benchmarks/qml/compilation/compilation.pro b/tests/benchmarks/qml/compilation/compilation.pro
new file mode 100644
index 0000000000..4fa9e49918
--- /dev/null
+++ b/tests/benchmarks/qml/compilation/compilation.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_compilation
+QT += qml qml-private testlib core-private v8-private
+macx:CONFIG -= app_bundle
+
+CONFIG += release
+
+SOURCES += tst_compilation.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/qml/compilation/data/BoomBlock.qml b/tests/benchmarks/qml/compilation/data/BoomBlock.qml
new file mode 100644
index 0000000000..65d253e074
--- /dev/null
+++ b/tests/benchmarks/qml/compilation/data/BoomBlock.qml
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Qt.labs.particles 1.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property int targetX: 0
+ property int targetY: 0
+
+ SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 }
+ SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
+
+ Image {
+ id: img
+ source: {
+ if(type == 0){
+ "pics/redStone.png";
+ } else if(type == 1) {
+ "pics/blueStone.png";
+ } else {
+ "pics/greenStone.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation: 30
+ source: {
+ if(type == 0){
+ "pics/redStar.png";
+ } else if (type == 1) {
+ "pics/blueStar.png";
+ } else {
+ "pics/greenStar.png";
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp
new file mode 100644
index 0000000000..9eeed7e9ed
--- /dev/null
+++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/private/qqmljsengine_p.h>
+#include <QtQml/private/qqmljsmemorypool_p.h>
+#include <QtQml/private/qqmljsparser_p.h>
+#include <QtQml/private/qqmljslexer_p.h>
+#include <QtQml/private/qqmlscript_p.h>
+
+#include <QFile>
+#include <QDebug>
+#include <QTextStream>
+
+class tst_compilation : public QObject
+{
+ Q_OBJECT
+public:
+ tst_compilation();
+
+private slots:
+ void boomblock();
+
+ void jsparser_data();
+ void jsparser();
+
+ void scriptparser_data();
+ void scriptparser();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_compilation::tst_compilation()
+{
+}
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_compilation::boomblock()
+{
+ QFile f(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ QByteArray data = f.readAll();
+
+ //get rid of initialization effects
+ {
+ QQmlComponent c(&engine);
+ c.setData(data, QUrl());
+ }
+
+ QBENCHMARK {
+ QQmlComponent c(&engine);
+ c.setData(data, QUrl());
+// QVERIFY(c.isReady());
+ }
+}
+
+void tst_compilation::jsparser_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
+}
+
+void tst_compilation::jsparser()
+{
+ QFETCH(QString, file);
+
+ QFile f(file);
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ QByteArray data = f.readAll();
+
+ QTextStream stream(data, QIODevice::ReadOnly);
+ const QString code = stream.readAll();
+
+ QBENCHMARK {
+ QQmlJS::Engine engine;
+ QQmlJS::NodePool nodePool(file, &engine);
+
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(code, -1);
+
+ QQmlJS::Parser parser(&engine);
+ parser.parse();
+ parser.ast();
+ }
+}
+
+void tst_compilation::scriptparser_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
+}
+
+void tst_compilation::scriptparser()
+{
+ QFETCH(QString, file);
+
+ QFile f(file);
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ QByteArray data = f.readAll();
+
+ QUrl url = QUrl::fromLocalFile(file);
+
+ QBENCHMARK {
+ QQmlScript::Parser parser;
+ parser.parse(data, url);
+ parser.tree();
+ }
+}
+
+QTEST_MAIN(tst_compilation)
+
+#include "tst_compilation.moc"
diff --git a/tests/benchmarks/qml/creation/creation.pro b/tests/benchmarks/qml/creation/creation.pro
new file mode 100644
index 0000000000..d887a1ffbf
--- /dev/null
+++ b/tests/benchmarks/qml/creation/creation.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_creation
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_creation.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+QT += core-private gui-private qml-private qtquick1-private widgets testlib
diff --git a/tests/benchmarks/qml/creation/data/item.qml b/tests/benchmarks/qml/creation/data/item.qml
new file mode 100644
index 0000000000..af6c2f3f59
--- /dev/null
+++ b/tests/benchmarks/qml/creation/data/item.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+}
diff --git a/tests/benchmarks/qml/creation/data/qobject.qml b/tests/benchmarks/qml/creation/data/qobject.qml
new file mode 100644
index 0000000000..90620ab35e
--- /dev/null
+++ b/tests/benchmarks/qml/creation/data/qobject.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+QtObject {
+}
diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp
new file mode 100644
index 0000000000..6bdaae48fd
--- /dev/null
+++ b/tests/benchmarks/qml/creation/tst_creation.cpp
@@ -0,0 +1,361 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <private/qqmlmetatype_p.h>
+#include <QDebug>
+#include <QGraphicsScene>
+#include <QGraphicsItem>
+#include <QQuickItem>
+#include <QQmlContext>
+#include <QtQuick1/private/qdeclarativetextinput_p.h>
+#include <private/qobject_p.h>
+
+class tst_creation : public QObject
+{
+ Q_OBJECT
+public:
+ tst_creation();
+
+private slots:
+ void qobject_cpp();
+ void qobject_qml();
+ void qobject_qmltype();
+ void qobject_alloc();
+
+ void qobject_10flat_qml();
+ void qobject_10flat_cpp();
+
+ void qobject_10tree_qml();
+ void qobject_10tree_cpp();
+
+ void itemtree_notree_cpp();
+ void itemtree_objtree_cpp();
+ void itemtree_cpp();
+ void itemtree_data_cpp();
+ void itemtree_qml();
+ void itemtree_scene_cpp();
+
+ void elements_data();
+ void elements();
+
+private:
+ QQmlEngine engine;
+};
+
+class TestType : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QQmlListProperty<QObject> resources READ resources)
+Q_CLASSINFO("DefaultProperty", "resources")
+public:
+ TestType(QObject *parent = 0)
+ : QObject(parent) {}
+
+ QQmlListProperty<QObject> resources() {
+ return QQmlListProperty<QObject>(this, 0, resources_append);
+ }
+
+ static void resources_append(QQmlListProperty<QObject> *p, QObject *o) {
+ o->setParent(p->object);
+ }
+};
+
+tst_creation::tst_creation()
+{
+ qmlRegisterType<TestType>("Qt.test", 1, 0, "TestType");
+
+ //get rid of initialization effects
+ QDeclarative1TextInput te;
+}
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_creation::qobject_cpp()
+{
+ QBENCHMARK {
+ QObject *obj = new QObject;
+ delete obj;
+ }
+}
+
+void tst_creation::qobject_qml()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nQtObject {}", QUrl());
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_creation::qobject_10flat_qml()
+{
+ QQmlComponent component(&engine);
+ component.setData("import Qt.test 1.0\nTestType { resources: [ TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{} ] }", QUrl());
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_creation::qobject_10flat_cpp()
+{
+ QBENCHMARK {
+ QObject *item = new TestType;
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ new TestType(item);
+ delete item;
+ }
+}
+
+void tst_creation::qobject_10tree_qml()
+{
+ QQmlComponent component(&engine);
+ component.setData("import Qt.test 1.0\nTestType { TestType{ TestType { TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ } } } } } } } } } } }", QUrl());
+
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_creation::qobject_10tree_cpp()
+{
+ QBENCHMARK {
+ QObject *item = new TestType;
+ QObject *root = item;
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ item = new TestType(item);
+ delete root;
+ }
+}
+
+void tst_creation::qobject_qmltype()
+{
+ QQmlType *t = QQmlMetaType::qmlType("QtQuick/QtObject", 2, 0);
+
+ QBENCHMARK {
+ QObject *obj = t->create();
+ delete obj;
+ }
+}
+
+struct QObjectFakeData {
+ char data[sizeof(QObjectPrivate)];
+};
+
+struct QObjectFake {
+ QObjectFake();
+ virtual ~QObjectFake();
+private:
+ QObjectFakeData *d;
+};
+
+QObjectFake::QObjectFake()
+{
+ d = new QObjectFakeData;
+}
+
+QObjectFake::~QObjectFake()
+{
+ delete d;
+}
+
+void tst_creation::qobject_alloc()
+{
+ QBENCHMARK {
+ QObjectFake *obj = new QObjectFake;
+ delete obj;
+ }
+}
+
+struct QQmlGraphics_Derived : public QObject
+{
+ void setParent_noEvent(QObject *parent) {
+ bool sce = d_ptr->sendChildEvents;
+ d_ptr->sendChildEvents = false;
+ setParent(parent);
+ d_ptr->sendChildEvents = sce;
+ }
+};
+
+inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent)
+{
+ static_cast<QQmlGraphics_Derived *>(object)->setParent_noEvent(parent);
+}
+
+void tst_creation::itemtree_notree_cpp()
+{
+ QBENCHMARK {
+ QQuickItem *item = new QQuickItem;
+ for (int i = 0; i < 30; ++i) {
+ QQuickItem *child = new QQuickItem;
+ Q_UNUSED(child);
+ }
+ delete item;
+ }
+}
+
+void tst_creation::itemtree_objtree_cpp()
+{
+ QBENCHMARK {
+ QQuickItem *item = new QQuickItem;
+ for (int i = 0; i < 30; ++i) {
+ QQuickItem *child = new QQuickItem;
+ QQmlGraphics_setParent_noEvent(child,item);
+ }
+ delete item;
+ }
+}
+
+void tst_creation::itemtree_cpp()
+{
+ QBENCHMARK {
+ QQuickItem *item = new QQuickItem;
+ for (int i = 0; i < 30; ++i) {
+ QQuickItem *child = new QQuickItem;
+ QQmlGraphics_setParent_noEvent(child,item);
+ child->setParentItem(item);
+ }
+ delete item;
+ }
+}
+
+void tst_creation::itemtree_data_cpp()
+{
+ QBENCHMARK {
+ QQuickItem *item = new QQuickItem;
+ for (int i = 0; i < 30; ++i) {
+ QQuickItem *child = new QQuickItem;
+ QQmlGraphics_setParent_noEvent(child,item);
+ QQmlListReference ref(item, "data");
+ ref.append(child);
+ }
+ delete item;
+ }
+}
+
+void tst_creation::itemtree_qml()
+{
+ QQmlComponent component(&engine, TEST_FILE("item.qml"));
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_creation::itemtree_scene_cpp()
+{
+ QGraphicsScene scene;
+ QQuickItem *root = new QQuickItem;
+ scene.addItem(root);
+ QBENCHMARK {
+ QQuickItem *item = new QQuickItem;
+ for (int i = 0; i < 30; ++i) {
+ QQuickItem *child = new QQuickItem;
+ QQmlGraphics_setParent_noEvent(child,item);
+ child->setParentItem(item);
+ }
+ item->setParentItem(root);
+ delete item;
+ }
+ delete root;
+}
+
+void tst_creation::elements_data()
+{
+ QTest::addColumn<QString>("type");
+
+ QList<QString> types = QQmlMetaType::qmlTypeNames();
+ foreach (QString type, types)
+ QTest::newRow(type.toLatin1()) << type;
+}
+
+void tst_creation::elements()
+{
+ QFETCH(QString, type);
+ QQmlType *t = QQmlMetaType::qmlType(type, 2, 0);
+ if (!t || !t->isCreatable())
+ QSKIP("Non-creatable type");
+
+ QBENCHMARK {
+ QObject *obj = t->create();
+ delete obj;
+ }
+}
+
+QTEST_MAIN(tst_creation)
+
+#include "tst_creation.moc"
diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicFour.qml
index ccccc371ac..ccccc371ac 100644
--- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml
+++ b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicFour.qml
diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicOne.qml
index 154f9db9a3..154f9db9a3 100644
--- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml
+++ b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicOne.qml
diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicThree.qml
index 064ba57254..064ba57254 100644
--- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml
+++ b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicThree.qml
diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicTwo.qml
index a3aac3ebd6..a3aac3ebd6 100644
--- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml
+++ b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicTwo.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Mlbsi.qml
index 854cc3258d..854cc3258d 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/Mlbsi.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Mldsi.qml
index 919fce1c46..919fce1c46 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/Mldsi.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Mlsi.qml
index 74451f85fd..74451f85fd 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/Mlsi.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml b/tests/benchmarks/qml/holistic/data/jsImports/ModuleBm.qml
index 18ef8a2599..18ef8a2599 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/ModuleBm.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Msbsi.qml
index d7a8b74dd1..d7a8b74dd1 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/Msbsi.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Msdsi.qml
index 266a26ef8e..266a26ef8e 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/Msdsi.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Mssi.qml
index e589981252..e589981252 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/Mssi.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml b/tests/benchmarks/qml/holistic/data/jsImports/PragmaBm.qml
index f5753af88b..f5753af88b 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/PragmaBm.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml b/tests/benchmarks/qml/holistic/data/jsImports/PragmaModuleBm.qml
index 8e1baa8572..8e1baa8572 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/PragmaModuleBm.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Slsi.qml
index aa21358b47..aa21358b47 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/Slsi.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Sssi.qml
index 0ed7a3ee72..0ed7a3ee72 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml
+++ b/tests/benchmarks/qml/holistic/data/jsImports/Sssi.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi.js
index 36a5fea77f..36a5fea77f 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi1.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi1.js
index 459451609b..459451609b 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi1.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi1.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi10.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi10.js
index 69202e63eb..69202e63eb 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi10.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi10.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi11.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi11.js
index 9f3e28a1f6..9f3e28a1f6 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi11.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi11.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi12.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi12.js
index 349c7cdd3f..349c7cdd3f 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi12.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi12.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi13.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi13.js
index 925178fadb..925178fadb 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi13.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi13.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi14.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi14.js
index 25f17ca1b8..25f17ca1b8 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi14.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi14.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi15.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi15.js
index 9445222cd9..9445222cd9 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi15.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi15.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi2.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi2.js
index f375c57663..f375c57663 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi2.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi2.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi3.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi3.js
index 0bfe7f021d..0bfe7f021d 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi3.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi3.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi4.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi4.js
index 8707e296ec..8707e296ec 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi4.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi4.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi5.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi5.js
index 0b1e8cf3de..0b1e8cf3de 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi5.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi5.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi6.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi6.js
index eb839108de..eb839108de 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi6.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi6.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi7.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi7.js
index fb22fa8f73..fb22fa8f73 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi7.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi7.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi8.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi8.js
index 736703c5bc..736703c5bc 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi8.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi8.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi9.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi9.js
index a1587a7de9..a1587a7de9 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi9.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi9.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi.js
index c0bad9c5a6..c0bad9c5a6 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi1.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi1.js
index b2a513da3b..b2a513da3b 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi1.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi1.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi10.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi10.js
index 864f027a6e..864f027a6e 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi10.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi10.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi11.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi11.js
index 2c126ec1c6..2c126ec1c6 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi11.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi11.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi12.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi12.js
index 76c14d8771..76c14d8771 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi12.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi12.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi13.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi13.js
index aaa2c6ab14..aaa2c6ab14 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi13.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi13.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi14.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi14.js
index 11394a87fb..11394a87fb 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi14.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi14.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi15.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi15.js
index 2978dbedf3..2978dbedf3 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi15.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi15.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi2.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi2.js
index f9105c07f2..f9105c07f2 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi2.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi2.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi3.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi3.js
index 046988b47a..046988b47a 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi3.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi3.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi4.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi4.js
index 7996c0d3f1..7996c0d3f1 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi4.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi4.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi5.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi5.js
index 183a09153a..183a09153a 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi5.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi5.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi6.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi6.js
index ad17faa47d..ad17faa47d 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi6.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi6.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi7.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi7.js
index 07e69fe6ee..07e69fe6ee 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi7.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi7.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi8.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi8.js
index cf245f461c..cf245f461c 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi8.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi8.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi9.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi9.js
index 2286e15d79..2286e15d79 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi9.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi9.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlsi.js b/tests/benchmarks/qml/holistic/data/jsImports/mlsi.js
index 8c05cfb8bd..8c05cfb8bd 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mlsi.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mlsi.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/moduleBm.js b/tests/benchmarks/qml/holistic/data/jsImports/moduleBm.js
index 29bd1f83af..29bd1f83af 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/moduleBm.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/moduleBm.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi.js
index 5126faca00..5126faca00 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi1.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi1.js
index d5ba35fc97..d5ba35fc97 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi1.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi1.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi10.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi10.js
index f24ad0f7ee..f24ad0f7ee 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi10.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi10.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi11.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi11.js
index 30e072ab04..30e072ab04 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi11.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi11.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi12.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi12.js
index 3bf414a0ec..3bf414a0ec 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi12.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi12.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi13.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi13.js
index 7487b7f1a9..7487b7f1a9 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi13.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi13.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi14.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi14.js
index 504b365752..504b365752 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi14.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi14.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi15.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi15.js
index 1887f157c1..1887f157c1 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi15.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi15.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi2.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi2.js
index 56997c1394..56997c1394 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi2.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi2.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi3.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi3.js
index ce84ab63e4..ce84ab63e4 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi3.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi3.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi4.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi4.js
index 61d15d11af..61d15d11af 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi4.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi4.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi5.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi5.js
index e5bf0e1527..e5bf0e1527 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi5.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi5.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi6.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi6.js
index 8f25ad23d8..8f25ad23d8 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi6.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi6.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi7.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi7.js
index 70d521d3dc..70d521d3dc 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi7.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi7.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi8.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi8.js
index ed9f473ff9..ed9f473ff9 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi8.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi8.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi9.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi9.js
index 73a8eaf37b..73a8eaf37b 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi9.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi9.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi.js
index f88af5b416..f88af5b416 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi1.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi1.js
index 1d60d24b5e..1d60d24b5e 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi1.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi1.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi10.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi10.js
index 8b1151f3e2..8b1151f3e2 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi10.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi10.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi11.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi11.js
index b27d0f37af..b27d0f37af 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi11.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi11.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi12.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi12.js
index ba62852113..ba62852113 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi12.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi12.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi13.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi13.js
index f4b17ff627..f4b17ff627 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi13.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi13.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi14.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi14.js
index 4f96539faf..4f96539faf 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi14.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi14.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi15.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi15.js
index 113ed1bdc8..113ed1bdc8 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi15.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi15.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi2.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi2.js
index 67a35bc3ae..67a35bc3ae 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi2.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi2.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi3.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi3.js
index 81b4747409..81b4747409 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi3.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi3.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi4.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi4.js
index 37a4d9d2aa..37a4d9d2aa 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi4.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi4.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi5.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi5.js
index df57e75cea..df57e75cea 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi5.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi5.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi6.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi6.js
index 43e0b43877..43e0b43877 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi6.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi6.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi7.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi7.js
index 569b613e92..569b613e92 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi7.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi7.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi8.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi8.js
index b1a5bd514b..b1a5bd514b 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi8.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi8.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi9.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi9.js
index 3a0c4d0354..3a0c4d0354 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi9.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi9.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mssi.js b/tests/benchmarks/qml/holistic/data/jsImports/mssi.js
index 7a82033d88..7a82033d88 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/mssi.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/mssi.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmOne.js b/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmOne.js
index b92b79afaf..b92b79afaf 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmOne.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmOne.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmTwo.js b/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmTwo.js
index c086016bef..c086016bef 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmTwo.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmTwo.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaLib.js b/tests/benchmarks/qml/holistic/data/jsImports/pragmaLib.js
index 8b65a68111..8b65a68111 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaLib.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/pragmaLib.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaModuleBm.js b/tests/benchmarks/qml/holistic/data/jsImports/pragmaModuleBm.js
index df710f1acf..df710f1acf 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaModuleBm.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/pragmaModuleBm.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/slsi.js b/tests/benchmarks/qml/holistic/data/jsImports/slsi.js
index 98af47885f..98af47885f 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/slsi.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/slsi.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/sssi.js b/tests/benchmarks/qml/holistic/data/jsImports/sssi.js
index 88d9fb643b..88d9fb643b 100644
--- a/tests/benchmarks/declarative/holistic/data/jsImports/sssi.js
+++ b/tests/benchmarks/qml/holistic/data/jsImports/sssi.js
diff --git a/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml b/tests/benchmarks/qml/holistic/data/jsTargets/JsOne.qml
index 41d4ff5bbd..41d4ff5bbd 100644
--- a/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml
+++ b/tests/benchmarks/qml/holistic/data/jsTargets/JsOne.qml
diff --git a/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml b/tests/benchmarks/qml/holistic/data/jsTargets/JsTwo.qml
index cb5da5a22d..cb5da5a22d 100644
--- a/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml
+++ b/tests/benchmarks/qml/holistic/data/jsTargets/JsTwo.qml
diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml b/tests/benchmarks/qml/holistic/data/largeTargets/gridview-example.qml
index 373b1b8ced..373b1b8ced 100644
--- a/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml
+++ b/tests/benchmarks/qml/holistic/data/largeTargets/gridview-example.qml
diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml b/tests/benchmarks/qml/holistic/data/largeTargets/layoutdirection.qml
index 9f039594b3..9f039594b3 100644
--- a/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml
+++ b/tests/benchmarks/qml/holistic/data/largeTargets/layoutdirection.qml
diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml b/tests/benchmarks/qml/holistic/data/largeTargets/mousearea-example.qml
index 4c82b58302..4c82b58302 100644
--- a/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml
+++ b/tests/benchmarks/qml/holistic/data/largeTargets/mousearea-example.qml
diff --git a/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml b/tests/benchmarks/qml/holistic/data/resolutionTargets/ResolveOne.qml
index 2673ac36ed..2673ac36ed 100644
--- a/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml
+++ b/tests/benchmarks/qml/holistic/data/resolutionTargets/ResolveOne.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToJs.qml
index d319f6e8cb..d319f6e8cb 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToJs.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToQml.qml
index a9d064f740..a9d064f740 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToQml.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEight.qml
index 97bb125bfc..97bb125bfc 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEight.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEleven.qml
index 2258e82500..2258e82500 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEleven.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFive.qml
index f349d0fcbf..f349d0fcbf 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFive.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFour.qml
index 267d36fba2..267d36fba2 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFour.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppNine.qml
index ec3772ea62..ec3772ea62 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppNine.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppOne.qml
index e4a3c1acc2..e4a3c1acc2 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppOne.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSeven.qml
index 56c18a02db..56c18a02db 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSeven.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSix.qml
index c14c43075b..c14c43075b 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSix.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTen.qml
index 05ededef38..05ededef38 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTen.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppThree.qml
index 2f11f9acb3..2f11f9acb3 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppThree.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTwo.qml
index 0fe6d18507..0fe6d18507 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTwo.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceOne.qml
index d604242a99..d604242a99 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceOne.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceTwo.qml
index cd79bb8074..cd79bb8074 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceTwo.qml
diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/cppToJs.js b/tests/benchmarks/qml/holistic/data/scopeSwitching/cppToJs.js
index e62c2f27d6..e62c2f27d6 100644
--- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/cppToJs.js
+++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/cppToJs.js
diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml b/tests/benchmarks/qml/holistic/data/smallTargets/SmallFour.qml
index 80af3bfee9..80af3bfee9 100644
--- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml
+++ b/tests/benchmarks/qml/holistic/data/smallTargets/SmallFour.qml
diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml b/tests/benchmarks/qml/holistic/data/smallTargets/SmallOne.qml
index 58d52fe25d..58d52fe25d 100644
--- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml
+++ b/tests/benchmarks/qml/holistic/data/smallTargets/SmallOne.qml
diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml b/tests/benchmarks/qml/holistic/data/smallTargets/SmallThree.qml
index a3e27f9ad6..a3e27f9ad6 100644
--- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml
+++ b/tests/benchmarks/qml/holistic/data/smallTargets/SmallThree.qml
diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml b/tests/benchmarks/qml/holistic/data/smallTargets/SmallTwo.qml
index 3ff2c5e8b0..3ff2c5e8b0 100644
--- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml
+++ b/tests/benchmarks/qml/holistic/data/smallTargets/SmallTwo.qml
diff --git a/tests/benchmarks/qml/holistic/holistic.pro b/tests/benchmarks/qml/holistic/holistic.pro
new file mode 100644
index 0000000000..82f2ef6e4e
--- /dev/null
+++ b/tests/benchmarks/qml/holistic/holistic.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_holistic
+QT += qml network testlib
+macx:CONFIG -= app_bundle
+
+CONFIG += release
+
+SOURCES += tst_holistic.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/qml/holistic/testtypes.cpp b/tests/benchmarks/qml/holistic/testtypes.cpp
new file mode 100644
index 0000000000..65d3ee8522
--- /dev/null
+++ b/tests/benchmarks/qml/holistic/testtypes.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+#include <QWidget>
+#include <QPlainTextEdit>
+#include <QQmlEngine>
+#include <QScriptEngine>
+
+static QScriptValue script_api(QQmlEngine *engine, QScriptEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+
+ static int testProperty = 13;
+ QScriptValue v = scriptEngine->newObject();
+ v.setProperty("scriptTestProperty", testProperty++);
+ return v;
+}
+
+static QObject *qobject_api(QQmlEngine *engine, QScriptEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+
+ testQObjectApi *o = new testQObjectApi();
+ o->setQObjectTestProperty(20);
+ return o;
+}
+
+static QObject *qobject_api_engine_parent(QQmlEngine *engine, QScriptEngine *scriptEngine)
+{
+ Q_UNUSED(scriptEngine)
+
+ static int testProperty = 26;
+ testQObjectApi *o = new testQObjectApi(engine);
+ o->setQObjectTestProperty(testProperty++);
+ return o;
+}
+
+void registerTypes()
+{
+ qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias");
+ qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
+
+ qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
+ qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
+
+ qmlRegisterType<ScarceResourceProvider>("Qt.test", 1,0, "MyScarceResourceProvider");
+ qmlRegisterType<ArbitraryVariantProvider>("Qt.test", 1,0, "MyArbitraryVariantProvider");
+
+ qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements
+ qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace!
+ qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements
+ qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements
+ qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set
+ qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
+ qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
+}
+
+//#include "testtypes.moc"
diff --git a/tests/benchmarks/qml/holistic/testtypes.h b/tests/benchmarks/qml/holistic/testtypes.h
new file mode 100644
index 0000000000..66d755d944
--- /dev/null
+++ b/tests/benchmarks/qml/holistic/testtypes.h
@@ -0,0 +1,355 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+#include <QtQml/qqmllist.h>
+#include <QtCore/qrect.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qpixmap.h>
+#include <QtGui/qvector3d.h>
+#include <QtCore/qdatetime.h>
+#include <QtScript/qjsvalue.h>
+#include <QtQml/qqmlscriptstring.h>
+#include <QtQml/qqmlcomponent.h>
+
+class MyQmlAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value CONSTANT)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2)
+public:
+ MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
+
+ int value() const { return 19; }
+ int value2() const { return m_value2; }
+ void setValue2(int v) { m_value2 = v; }
+
+ void emitMySignal() { emit mySignal(); }
+
+signals:
+ void mySignal();
+
+private:
+ int m_value2;
+};
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_ENUMS(MyEnum2)
+ Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
+ Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
+ Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int console READ console CONSTANT)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
+ Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
+ Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
+ Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false)
+
+public:
+ MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
+
+ enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
+ enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
+
+ bool trueProperty() const { return true; }
+ bool falseProperty() const { return false; }
+
+ QString stringProperty() const { return m_string; }
+ void setStringProperty(const QString &s)
+ {
+ if (s == m_string)
+ return;
+ m_string = s;
+ emit stringChanged();
+ }
+
+ QObject *objectProperty() const { return m_object; }
+ void setObjectProperty(QObject *obj) {
+ if (obj == m_object)
+ return;
+ m_object = obj;
+ emit objectChanged();
+ }
+
+ QQmlListProperty<QObject> objectListProperty() { return QQmlListProperty<QObject>(this, m_objectQList); }
+
+ bool methodCalled() const { return m_methodCalled; }
+ bool methodIntCalled() const { return m_methodIntCalled; }
+
+ QString string() const { return m_string; }
+
+ static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
+ return new MyQmlAttachedObject(o);
+ }
+
+ int deleteOnSet() const { return 1; }
+ void setDeleteOnSet(int v) { if(v) delete this; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ int resettableProperty() const { return m_resetProperty; }
+ void setResettableProperty(int v) { m_resetProperty = v; }
+ void resetProperty() { m_resetProperty = 13; }
+
+ QRegExp regExp() { return m_regExp; }
+ void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
+
+ int console() const { return 11; }
+
+ int nonscriptable() const { return 0; }
+ void setNonscriptable(int) {}
+
+ MyQmlObject *myinvokableObject;
+ Q_INVOKABLE MyQmlObject *returnme() { return this; }
+
+ struct MyType {
+ int value;
+ };
+ QVariant variant() const { return m_variant; }
+
+signals:
+ void basicSignal();
+ void argumentSignal(int a, QString b, qreal c);
+ void stringChanged();
+ void objectChanged();
+ void anotherBasicSignal();
+ void thirdBasicSignal();
+ void signalWithUnknownType(const MyQmlObject::MyType &arg);
+
+public slots:
+ void deleteMe() { delete this; }
+ void methodNoArgs() { m_methodCalled = true; }
+ void method(int a) { if(a == 163) m_methodIntCalled = true; }
+ void setString(const QString &s) { m_string = s; }
+ void myinvokable(MyQmlObject *o) { myinvokableObject = o; }
+ void variantMethod(const QVariant &v) { m_variant = v; }
+
+private:
+ friend class tst_qdeclarativeecmascript;
+ bool m_methodCalled;
+ bool m_methodIntCalled;
+
+ QObject *m_object;
+ QString m_string;
+ QList<QObject *> m_objectQList;
+ int m_value;
+ int m_resetProperty;
+ QRegExp m_regExp;
+ QVariant m_variant;
+};
+
+QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+Q_DECLARE_METATYPE(MyQmlObject::MyType)
+
+class testQObjectApi : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged)
+
+public:
+ testQObjectApi(QObject* parent = 0)
+ : QObject(parent), m_testProperty(0)
+ {
+ }
+
+ ~testQObjectApi() {}
+
+ int qobjectTestProperty() const { return m_testProperty; }
+ void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); }
+
+signals:
+ void qobjectTestPropertyChanged(int testProperty);
+
+private:
+ int m_testProperty;
+};
+
+class ArbitraryVariantProvider : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QVariant arbitraryVariant READ arbitraryVariant WRITE setArbitraryVariant NOTIFY arbitraryVariantChanged)
+
+public:
+ ArbitraryVariantProvider(QObject *parent = 0)
+ : QObject(parent), m_value(QVariant(QString(QLatin1String("random string value")))), m_count(1)
+ {
+ }
+
+ ~ArbitraryVariantProvider() {}
+
+ // the variant provided by the provider
+ QVariant arbitraryVariant() const { return m_value; }
+ void setArbitraryVariant(const QVariant& value) { m_value = value; emit arbitraryVariantChanged(); }
+ Q_INVOKABLE int changeVariant()
+ {
+ QPixmap pv(150, 150);
+ pv.fill(Qt::green);
+ int choice = qrand() % 4;
+ switch (choice) {
+ case 0: setArbitraryVariant(QVariant(QString(QLatin1String("string variant value")))); break;
+ case 1: setArbitraryVariant(QVariant(QColor(110, 120, 130))); break;
+ case 2: setArbitraryVariant(QVariant(55)); break;
+ default: setArbitraryVariant(QVariant(pv)); break;
+ }
+
+ m_count += 1;
+ return m_count;
+ }
+ Q_INVOKABLE QVariant setVariantToFilledPixmap(int width, int height, int r, int g, int b)
+ {
+ QPixmap pv(width % 300, height % 300);
+ pv.fill(QColor(r % 256, g % 256, b % 256));
+ m_value = pv;
+ m_count += 1;
+ return m_value;
+ }
+ Q_INVOKABLE QVariant setVariantAddCount(int addToCount, const QVariant& newValue)
+ {
+ m_value = newValue;
+ m_count += addToCount;
+ return m_value;
+ }
+ Q_INVOKABLE QVariant possibleVariant(int randomFactorOne, int randomFactorTwo, int randomFactorThree) const
+ {
+ QVariant retn;
+ QPixmap pv(randomFactorOne % 300, randomFactorTwo % 300);
+ pv.fill(QColor(randomFactorOne % 256, randomFactorTwo % 256, randomFactorThree % 256));
+ int choice = qrand() % 4;
+ switch (choice) {
+ case 0: retn = QVariant(QString(QLatin1String("string variant value"))); break;
+ case 1: retn = QVariant(QColor(randomFactorThree % 256, randomFactorTwo % 256, randomFactorOne % 256)); break;
+ case 2: retn = QVariant((55 + randomFactorThree)); break;
+ default: retn = QVariant(pv); break;
+ }
+ return retn;
+ }
+
+ // the following functions cover permutations of return value and arguments.
+ // functions with no return value:
+ Q_INVOKABLE void doNothing() const { /* does nothing */ } // no args, const
+ Q_INVOKABLE void incrementVariantChangeCount() { m_count = m_count + 1; } // no args, nonconst
+ Q_INVOKABLE void doNothing(int) const { /* does nothing. */ } // arg, const
+ Q_INVOKABLE void setVariantChangeCount(int newCount) { m_count = newCount; } // arg, nonconst
+ // functions with return value:
+ Q_INVOKABLE int variantChangeCount() const { return m_count; } // no args, const
+ Q_INVOKABLE int modifyVariantChangeCount() { m_count += 3; return m_count; } // no args, nonconst
+ Q_INVOKABLE int countPlus(int value) const { return m_count + value; } // arg, const
+ Q_INVOKABLE int modifyVariantChangeCount(int modifier) { m_count += modifier; return m_count; } // arg, nonconst.
+
+signals:
+ void arbitraryVariantChanged();
+
+private:
+ QVariant m_value;
+ int m_count;
+};
+
+class ScarceResourceProvider : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QPixmap smallScarceResource READ smallScarceResource WRITE setSmallScarceResource NOTIFY smallScarceResourceChanged)
+ Q_PROPERTY(QPixmap largeScarceResource READ largeScarceResource WRITE setLargeScarceResource NOTIFY largeScarceResourceChanged)
+
+public:
+ ScarceResourceProvider(QObject *parent = 0)
+ : QObject(parent), m_small(100, 100), m_large(1000, 1000), m_colour(1)
+ {
+ m_small.fill(Qt::blue);
+ m_large.fill(Qt::blue);
+ }
+
+ ~ScarceResourceProvider() {}
+
+ QPixmap smallScarceResource() const { return m_small; }
+ void setSmallScarceResource(QPixmap v) { m_small = v; emit smallScarceResourceChanged(); }
+ bool smallScarceResourceIsDetached() const { return m_small.isDetached(); }
+
+ QPixmap largeScarceResource() const { return m_large; }
+ void setLargeScarceResource(QPixmap v) { m_large = v; emit largeScarceResourceChanged(); }
+ bool largeScarceResourceIsDetached() const { return m_large.isDetached(); }
+
+ Q_INVOKABLE void changeResources()
+ {
+ QPixmap newSmall(100, 100);
+ QPixmap newLarge(1000, 1000);
+
+ if (m_colour == 1) {
+ m_colour = 2;
+ newSmall.fill(Qt::red);
+ newLarge.fill(Qt::red);
+ } else {
+ m_colour = 1;
+ newSmall.fill(Qt::blue);
+ newLarge.fill(Qt::blue);
+ }
+
+ setSmallScarceResource(newSmall);
+ setLargeScarceResource(newLarge);
+ }
+
+signals:
+ void smallScarceResourceChanged();
+ void largeScarceResourceChanged();
+
+private:
+ QPixmap m_small;
+ QPixmap m_large;
+
+ int m_colour;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
+
diff --git a/tests/benchmarks/qml/holistic/tst_holistic.cpp b/tests/benchmarks/qml/holistic/tst_holistic.cpp
new file mode 100644
index 0000000000..db8cc1cecb
--- /dev/null
+++ b/tests/benchmarks/qml/holistic/tst_holistic.cpp
@@ -0,0 +1,607 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtypes.h"
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QQmlContext>
+#include <QQmlProperty>
+#include <QFile>
+#include <QDebug>
+
+// Conceptually, there are several different "holistic" areas to benchmark:
+// 1) Loading
+// - read file from disk
+// - parse/lex file
+// - handle nested imports
+// 2) Compilation
+// - create meta object templates etc
+// - compile to bytecode and cache it
+// 3) Instantiation
+// - running the bytecode to create an object tree, assign properties, etc
+// - and, importantly, to evaluate bindings for the first time (incl. js expressions)
+// 4) Dynamicism
+// - bindings evaluation
+// - signal handlers
+//
+// Aside from this, we also need to determine:
+// 1) JavaScript Metrics
+// - simple expressions
+// - complex expressions
+// - instantiation vs evaluation time
+// - imports and nested imports
+// 2) Context-switch costs
+// - how expensive is it to call a cpp function from QML
+// - how expensive is it to call a js function from cpp via QML
+// - how expensive is it to pass around objects between them
+// 3) Complete creation time.
+// - loading + compilation + instantiation (for "application startup time" metric)
+//
+// In some cases, we want to include "initialization costs";
+// i.e., we need to tell the engine not to cache type data resulting
+// in compilation between rounds, and we need to tell the engine not
+// to cache whatever it caches between instantiations of components.
+// The reason for this is that it is often the "first start of application"
+// performance which we're attempting to benchmark.
+
+// define some custom types we use in test data functions.
+typedef QList<QString> PropertyNameList;
+Q_DECLARE_METATYPE(PropertyNameList);
+typedef QList<QVariant> PropertyValueList;
+Q_DECLARE_METATYPE(PropertyValueList);
+
+class tst_holistic : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_holistic();
+
+private slots:
+ void initTestCase()
+ {
+ registerTypes();
+ qRegisterMetaType<PropertyNameList>("PropertyNameList");
+ qRegisterMetaType<PropertyValueList>("PropertyValueList");
+ }
+
+ void compilation_data();
+ void compilation();
+ void instantiation_data() { compilation_data(); }
+ void instantiation();
+ void creation_data() { compilation_data(); }
+ void creation();
+ void dynamicity_data();
+ void dynamicity();
+
+ void cppToJsDirect_data();
+ void cppToJsDirect();
+ void cppToJsIndirect();
+
+ void typeResolution_data();
+ void typeResolution();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_holistic::tst_holistic()
+{
+}
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+
+void tst_holistic::compilation_data()
+{
+ QTest::addColumn<QStringList>("files");
+ QTest::addColumn<int>("repetitions");
+
+ QStringList f;
+
+ // Benchmarks: a single, small component once with no caching.
+ f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallOne.qml"));
+ QTest::newRow("single small component") << f << 1;
+
+ // Benchmarks: a single, small component ten times with caching.
+ QTest::newRow("single small component cached") << f << 10; f.clear();
+
+ // Benchmarks: a single, large component once with no caching.
+ f << QString(SRCDIR + QLatin1String("/data/largeTargets/mousearea-example.qml"));
+ QTest::newRow("single large component") << f << 1;
+
+ // Benchmarks: a single, large component ten times with caching.
+ QTest::newRow("single large component cached") << f << 10; f.clear();
+
+ // Benchmarks: 4 small components once each with no caching
+ f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallOne.qml"));
+ f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallTwo.qml"));
+ f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallThree.qml"));
+ f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallFour.qml"));
+ QTest::newRow("multiple small components") << f << 1;
+
+ // Benchmarks: 4 small components ten times each with caching
+ QTest::newRow("multiple small components cached") << f << 10; f.clear();
+
+ // Benchmarks: 3 large components once each with no caching.
+ f << QString(SRCDIR + QLatin1String("/data/largeTargets/mousearea-example.qml"));
+ f << QString(SRCDIR + QLatin1String("/data/largeTargets/gridview-example.qml"));
+ f << QString(SRCDIR + QLatin1String("/data/largeTargets/layoutdirection.qml"));
+ QTest::newRow("multiple large components") << f << 1;
+
+ // Benchmarks: 3 large components ten times each with caching.
+ QTest::newRow("multiple large components cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports a single small js file, no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/Sssi.qml"));
+ QTest::newRow("single small js import") << f << 1;
+
+ // Benchmarks: single small component which imports a single small js file, 10 reps, with caching
+ QTest::newRow("single small js import, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports multiple small js files (no deep nesting), no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/Msbsi.qml"));
+ QTest::newRow("multiple small js imports, shallow") << f << 1;
+
+ // Benchmarks: single small component which imports multiple small js files (no deep nesting), 10 reps, with caching
+ QTest::newRow("multiple small js imports, shallow, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports multiple small js files (with deep nesting), no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/Msdsi.qml"));
+ QTest::newRow("multiple small js imports, deeply nested") << f << 1;
+
+ // Benchmarks: single small component which imports multiple small js files (with deep nesting), 10 reps, with caching
+ QTest::newRow("multiple small js imports, deeply nested, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports multiple small js files (nested and unnested), no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/Mssi.qml"));
+ QTest::newRow("muliple small js imports, both") << f << 1;
+
+ // Benchmarks: single small component which imports multiple small js files (nested and unnested), 10 reps, with caching
+ QTest::newRow("muliple small js imports, both, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports a single large js file, no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/Slsi.qml"));
+ QTest::newRow("single large js import") << f << 1;
+
+ // Benchmarks: single small component which imports a single large js file, 10 reps, with caching
+ QTest::newRow("single large js import, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports multiple large js files (no deep nesting), no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/Mlbsi.qml"));
+ QTest::newRow("multiple large js imports, shallow") << f << 1;
+
+ // Benchmarks: single small component which imports multiple large js files (no deep nesting), 10 reps, with caching
+ QTest::newRow("multiple large js imports, shallow, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports multiple large js files (with deep nesting), no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/Mldsi.qml"));
+ QTest::newRow("multiple large js imports, deeply nested") << f << 1;
+
+ // Benchmarks: single small component which imports multiple large js files (with deep nesting), 10 reps, with caching
+ QTest::newRow("multiple large js imports, deeply nested, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports multiple large js files (nested and unnested), no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/Mlsi.qml"));
+ QTest::newRow("multiple large js imports, both") << f << 1;
+
+ // Benchmarks: single small component which imports multiple large js files (nested and unnested), 10 reps, with caching
+ QTest::newRow("multiple large js imports, both, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file, no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/PragmaBm.qml"));
+ QTest::newRow(".pragma library js import") << f << 1;
+
+ // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file, 10 reps, with caching
+ QTest::newRow(".pragma library js import, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports a js file which imports a QML module, no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/ModuleBm.qml"));
+ QTest::newRow("import js with QML import") << f << 1;
+
+ // Benchmarks: single small component which imports a js file which imports a QML module, 10 reps, with caching
+ QTest::newRow("import js with QML import, cached") << f << 10; f.clear();
+
+ // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file and a QML module, no caching
+ f << QString(SRCDIR + QLatin1String("/data/jsImports/PragmaModuleBm.qml"));
+ QTest::newRow("import js with QML import and .pragma library") << f << 1;
+
+ // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file and a QML module, 10 reps, with caching
+ QTest::newRow("import js with QML import and .pragma library, cached") << f << 10; f.clear();
+}
+
+void tst_holistic::compilation()
+{
+ // This function benchmarks the cost of loading and compiling specified QML files.
+ // If "repetitions" is non-zero, each file from "files" will be compiled "repetitions"
+ // times, without clearing the engine's component cache between compilations.
+
+ QFETCH(QStringList, files);
+ QFETCH(int, repetitions);
+ Q_ASSERT(files.size() > 0);
+ Q_ASSERT(repetitions > 0);
+
+ QBENCHMARK {
+ engine.clearComponentCache();
+ for (int i = 0; i < repetitions; ++i) {
+ for (int j = 0; j < files.size(); ++j) {
+ QQmlComponent c(&engine, QUrl::fromLocalFile(files.at(j)));
+ }
+ }
+ }
+}
+
+void tst_holistic::instantiation()
+{
+ // This function benchmarks the cost of instantiating components compiled from specified QML files.
+ // If "repetitions" is non-zero, each component compiled from "files" will be instantiated "repetitions"
+ // times, without clearing the component's instantiation cache between instantiations.
+
+ QFETCH(QStringList, files);
+ QFETCH(int, repetitions);
+ Q_ASSERT(files.size() > 0);
+ Q_ASSERT(repetitions > 0);
+
+ QList<QQmlComponent*> components;
+ for (int i = 0; i < files.size(); ++i) {
+ QQmlComponent *c = new QQmlComponent(&engine, QUrl::fromLocalFile(files.at(i)));
+ components.append(c);
+ }
+
+ QBENCHMARK {
+ // XXX TODO: clear each component's instantiation cache
+
+ for (int i = 0; i < repetitions; ++i) {
+ for (int j = 0; j < components.size(); ++j) {
+ QObject *obj = components.at(j)->create();
+ delete obj;
+ }
+ }
+ }
+
+ // cleanup
+ for (int i = 0; i < components.size(); ++i) {
+ delete components.at(i);
+ }
+}
+
+void tst_holistic::creation()
+{
+ // This function benchmarks the cost of loading, compiling and instantiating specified QML files.
+ // If "repetitions" is non-zero, each file from "files" will be created "repetitions"
+ // times, without clearing the engine's component cache between component creation.
+
+ QFETCH(QStringList, files);
+ QFETCH(int, repetitions);
+ Q_ASSERT(files.size() > 0);
+ Q_ASSERT(repetitions > 0);
+
+ QBENCHMARK {
+ engine.clearComponentCache();
+ for (int i = 0; i < repetitions; ++i) {
+ for (int j = 0; j < files.size(); ++j) {
+ QQmlComponent c(&engine, QUrl::fromLocalFile(files.at(j)));
+ QObject *obj = c.create();
+ delete obj;
+ }
+ }
+ }
+}
+
+void tst_holistic::dynamicity_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("writeProperty");
+ QTest::addColumn<QVariant>("writeValueOne");
+ QTest::addColumn<QVariant>("writeValueTwo");
+ QTest::addColumn<QString>("readProperty");
+
+ QString f;
+
+ // Benchmarks: single simple property binding
+ f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicOne.qml"));
+ QTest::newRow("single simple property binding") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("height"));
+
+ // Benchmarks: multiple simple property bindings in one component
+ f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicTwo.qml"));
+ QTest::newRow("multiple simple property bindings") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth"));
+
+ // Benchmarks: single simple property binding plus onPropertyChanged slot
+ f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicThree.qml"));
+ QTest::newRow("single simple plus slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth"));
+
+ // Benchmarks: multiple simple property bindings plus multiple onPropertyChanged slots in one component
+ f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicFour.qml"));
+ QTest::newRow("multiple simple plus slots") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicHeight"));
+
+ // Benchmarks: single simple js expression in a slot
+ f = QString(SRCDIR + QLatin1String("/data/jsTargets/JsOne.qml"));
+ QTest::newRow("single simple js expression slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth"));
+
+ // Benchmarks: single complex js expression in a slot
+ f = QString(SRCDIR + QLatin1String("/data/jsTargets/JsTwo.qml"));
+ QTest::newRow("single complex js expression slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth"));
+
+ // Benchmarks: simple property assignment and bindings update
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/CppToQml.qml"));
+ QTest::newRow("single simple property binding") << f << QString(QLatin1String("arbitrary")) << QVariant(36) << QVariant(35) << QString(QLatin1String("arbitrary"));
+}
+
+void tst_holistic::dynamicity()
+{
+ // This function benchmarks the cost of "continued operation" - signal invocation,
+ // updating bindings, etc. Note that we take two different writeValues in order
+ // to force updates to occur, and we read to force lazy evaluation to occur.
+
+ QFETCH(QString, file);
+ QFETCH(QString, writeProperty);
+ QFETCH(QVariant, writeValueOne);
+ QFETCH(QVariant, writeValueTwo);
+ QFETCH(QString, readProperty);
+
+ QQmlComponent c(&engine, file);
+ QObject *obj = c.create();
+
+ QVariant readValue;
+ QVariant writeValue;
+ bool usedFirst = false;
+
+ QBENCHMARK {
+ if (usedFirst) {
+ writeValue = writeValueTwo;
+ usedFirst = false;
+ } else {
+ writeValue = writeValueOne;
+ usedFirst = true;
+ }
+
+ obj->setProperty(writeProperty.toAscii().constData(), writeValue);
+ readValue = obj->property(readProperty.toAscii().constData());
+ }
+
+ delete obj;
+}
+
+
+
+
+
+
+
+void tst_holistic::cppToJsDirect_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("methodName");
+
+ QString f;
+
+ // Benchmarks: cost of calling a js function from cpp directly
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/CppToJs.qml"));
+ QTest::newRow("cpp-to-js") << f << QString(QLatin1String("callJsFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // const CPP function with no return value and no arguments.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppOne.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: no retn, no args") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // nonconst CPP function with no return value and no arguments.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppTwo.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: nonconst, no retn, no args") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // const CPP function with no return value and a single integer argument.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppThree.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: const, no retn, int arg") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // nonconst CPP function with no return value and a single integer argument.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppFour.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: nonconst, no retn, int arg") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // const CPP function with an integer return value and no arguments.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppFive.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: const, int retn, no args") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // nonconst CPP function with an integer return value and no arguments.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppSix.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: nonconst, int retn, no args") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // const CPP function with an integer return value and a single integer argument.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppSeven.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: const, int retn, int arg") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // nonconst CPP function with an integer return value and a single integer argument.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppEight.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: nonconst, int retn, int arg") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // const CPP function with a variant return value and multiple integer arguments.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppNine.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: const, variant retn, int args") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // nonconst CPP function with a variant return value and multiple integer arguments.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppTen.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: nonconst, variant retn, int args") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: cost of calling js function which calls cpp function:
+ // nonconst CPP function with a variant return value and multiple integer arguments.
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppEleven.qml"));
+ QTest::newRow("cpp-to-js-to-cpp: nonconst, variant retn, variant + int args") << f << QString(QLatin1String("callCppFunction"));
+
+ // Benchmarks: calling js function which copies scarce resources by calling back into cpp scope
+ f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceOne.qml"));
+ QTest::newRow("cpp-to-js-to-coo: copy scarce resources") << f << QString(QLatin1String("copyScarceResources"));
+}
+
+
+void tst_holistic::cppToJsDirect()
+{
+ // This function benchmarks the cost of calling from CPP scope to JS scope
+ // (and possibly vice versa, if the invoked js method then calls to cpp).
+
+ QFETCH(QString, file);
+ QFETCH(QString, methodName);
+
+ QQmlComponent c(&engine, file);
+ QObject *obj = c.create();
+
+ QBENCHMARK {
+ QMetaObject::invokeMethod(obj, methodName.toLatin1().constData());
+ }
+
+ delete obj;
+}
+
+
+void tst_holistic::cppToJsIndirect()
+{
+ // This function benchmarks the cost of binding scarce resources
+ // to properties of a QML component. The engine should automatically release such
+ // resources when they are no longer used.
+ // The benchmark deliberately causes change signals to be emitted (and
+ // modifies the scarce resources) so that the properties are updated.
+
+ QQmlComponent c(&engine, QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceTwo.qml")));
+ QObject *obj = c.create();
+
+ ScarceResourceProvider *srp = 0;
+ srp = qobject_cast<ScarceResourceProvider*>(QQmlProperty::read(obj, "a").value<QObject*>());
+
+ QBENCHMARK {
+ srp->changeResources(); // will cause small+large scarce resources changed signals to be emitted.
+ }
+
+ delete obj;
+}
+
+
+
+
+
+void tst_holistic::typeResolution_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<PropertyNameList>("propertyNameOne");
+ QTest::addColumn<PropertyValueList>("propertyValueOne");
+ QTest::addColumn<PropertyNameList>("propertyNameTwo");
+ QTest::addColumn<PropertyValueList>("propertyValueTwo");
+ QTest::addColumn<int>("repetitions");
+
+ QString f;
+ PropertyNameList pn1;
+ PropertyValueList pv1;
+ PropertyNameList pn2;
+ PropertyValueList pv2;
+
+ // Benchmarks: resolving nested ids and types, no caching
+ f = QString(SRCDIR + QLatin1String("/data/resolutionTargets/ResolveOne.qml"));
+ pn1 << QString(QLatin1String("baseWidth")) << QString(QLatin1String("baseHeight")) << QString(QLatin1String("baseColor"));
+ pv1 << QVariant(401) << QVariant(402) << QVariant(QString(QLatin1String("brown")));
+ pn2 << QString(QLatin1String("baseWidth")) << QString(QLatin1String("baseHeight")) << QString(QLatin1String("baseColor"));
+ pv2 << QVariant(403) << QVariant(404) << QVariant(QString(QLatin1String("orange")));
+ QTest::newRow("nested id resolution") << f << pn1 << pv1 << pn2 << pv2 << 1;
+
+ // Benchmarks: resolving nested ids and types, 10 reps with caching
+ QTest::newRow("nested id resolution, cached") << f << pn1 << pv1 << pn2 << pv2 << 10;
+ pn1.clear(); pn2.clear(); pv1.clear(); pv2.clear();
+}
+
+void tst_holistic::typeResolution()
+{
+ // This function benchmarks the cost of "continued operation" (signal invocation,
+ // updating bindings, etc) where the component has lots of nested items with
+ // lots of resolving required. Note that we take two different writeValues in order
+ // to force updates to occur.
+
+ QFETCH(QString, file);
+ QFETCH(PropertyNameList, propertyNameOne);
+ QFETCH(PropertyValueList, propertyValueOne);
+ QFETCH(PropertyNameList, propertyNameTwo);
+ QFETCH(PropertyValueList, propertyValueTwo);
+ QFETCH(int, repetitions);
+
+ Q_ASSERT(propertyNameOne.size() == propertyValueOne.size());
+ Q_ASSERT(propertyNameTwo.size() == propertyValueTwo.size());
+ Q_ASSERT(repetitions > 0);
+
+ QQmlComponent c(&engine, file);
+ QObject *obj = c.create();
+
+ PropertyNameList writeProperty;
+ PropertyValueList writeValue;
+ bool usedFirst = false;
+
+ QBENCHMARK {
+ for (int i = 0; i < repetitions; ++i) {
+ if (usedFirst) {
+ writeProperty = propertyNameOne;
+ writeValue = propertyValueOne;
+ usedFirst = false;
+ } else {
+ writeProperty = propertyNameTwo;
+ writeValue = propertyValueTwo;
+ usedFirst = true;
+ }
+
+ for (int j = 0; j < writeProperty.size(); ++j) {
+ obj->setProperty(writeProperty.at(j).toAscii().constData(), writeValue.at(j));
+ }
+ }
+ }
+
+ delete obj;
+}
+
+
+QTEST_MAIN(tst_holistic)
+
+#include "tst_holistic.moc"
diff --git a/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml b/tests/benchmarks/qml/javascript/data/NestedIdObject.qml
index 753d547ace..753d547ace 100644
--- a/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml
+++ b/tests/benchmarks/qml/javascript/data/NestedIdObject.qml
diff --git a/tests/benchmarks/declarative/javascript/data/intQObjectProperty.qml b/tests/benchmarks/qml/javascript/data/intQObjectProperty.qml
index c3e6ebc16a..c3e6ebc16a 100644
--- a/tests/benchmarks/declarative/javascript/data/intQObjectProperty.qml
+++ b/tests/benchmarks/qml/javascript/data/intQObjectProperty.qml
diff --git a/tests/benchmarks/declarative/javascript/data/localId.qml b/tests/benchmarks/qml/javascript/data/localId.qml
index d42b891092..d42b891092 100644
--- a/tests/benchmarks/declarative/javascript/data/localId.qml
+++ b/tests/benchmarks/qml/javascript/data/localId.qml
diff --git a/tests/benchmarks/declarative/javascript/data/nestedId.qml b/tests/benchmarks/qml/javascript/data/nestedId.qml
index 538699d452..538699d452 100644
--- a/tests/benchmarks/declarative/javascript/data/nestedId.qml
+++ b/tests/benchmarks/qml/javascript/data/nestedId.qml
diff --git a/tests/benchmarks/declarative/javascript/data/stringQObjectProperty.qml b/tests/benchmarks/qml/javascript/data/stringQObjectProperty.qml
index ccd8a791b6..ccd8a791b6 100644
--- a/tests/benchmarks/declarative/javascript/data/stringQObjectProperty.qml
+++ b/tests/benchmarks/qml/javascript/data/stringQObjectProperty.qml
diff --git a/tests/benchmarks/qml/javascript/javascript.pro b/tests/benchmarks/qml/javascript/javascript.pro
new file mode 100644
index 0000000000..281bbd0069
--- /dev/null
+++ b/tests/benchmarks/qml/javascript/javascript.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_javascript
+QT += qml testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_javascript.cpp testtypes.cpp
+HEADERS += testtypes.h
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/qml/javascript/testtypes.cpp b/tests/benchmarks/qml/javascript/testtypes.cpp
new file mode 100644
index 0000000000..43abef2d03
--- /dev/null
+++ b/tests/benchmarks/qml/javascript/testtypes.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtypes.h"
+#include <QtQml/qqml.h>
+
+void registerTypes()
+{
+ qmlRegisterType<TestObject>("Qt.test", 1,0, "TestObject");
+}
diff --git a/tests/benchmarks/declarative/javascript/testtypes.h b/tests/benchmarks/qml/javascript/testtypes.h
index 91be9078ed..91be9078ed 100644
--- a/tests/benchmarks/declarative/javascript/testtypes.h
+++ b/tests/benchmarks/qml/javascript/testtypes.h
diff --git a/tests/benchmarks/qml/javascript/tst_javascript.cpp b/tests/benchmarks/qml/javascript/tst_javascript.cpp
new file mode 100644
index 0000000000..d506951b9f
--- /dev/null
+++ b/tests/benchmarks/qml/javascript/tst_javascript.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDir>
+#include <QDebug>
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+
+#include "testtypes.h"
+
+class tst_javascript : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_javascript();
+ virtual ~tst_javascript();
+
+private slots:
+ void run_data();
+ void run();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_javascript::tst_javascript()
+{
+ registerTypes();
+}
+
+tst_javascript::~tst_javascript()
+{
+}
+
+void tst_javascript::run_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QDir dir(SRCDIR "/data");
+
+ QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
+
+ for (int ii = 0; ii < files.count(); ++ii) {
+ QString file = files.at(ii);
+ if (file.endsWith(".qml") && file.at(0).isLower()) {
+
+ QString testName = file.left(file.length() - 4 /* strlen(".qml") */);
+ QString fileName = QLatin1String(SRCDIR) + QLatin1String("/data/") + file;
+
+
+ QTest::newRow(qPrintable(testName)) << fileName;
+
+ }
+ }
+}
+
+void tst_javascript::run()
+{
+ QFETCH(QString, file);
+
+ QQmlComponent c(&engine, file);
+
+ if (c.isError()) {
+ qWarning() << c.errors();
+ }
+
+ QVERIFY(!c.isError());
+
+ QObject *o = c.create();
+ QVERIFY(o != 0);
+
+ QMetaMethod method = o->metaObject()->method(o->metaObject()->indexOfMethod("runtest()"));
+
+ QBENCHMARK {
+ method.invoke(o);
+ }
+
+ delete o;
+}
+
+QTEST_MAIN(tst_javascript)
+
+#include "tst_javascript.moc"
diff --git a/tests/benchmarks/declarative/js/js.pro b/tests/benchmarks/qml/js/js.pro
index b1448d8eb8..b1448d8eb8 100644
--- a/tests/benchmarks/declarative/js/js.pro
+++ b/tests/benchmarks/qml/js/js.pro
diff --git a/tests/benchmarks/qml/js/qjsengine/qjsengine.pro b/tests/benchmarks/qml/js/qjsengine/qjsengine.pro
new file mode 100644
index 0000000000..f8f2874a63
--- /dev/null
+++ b/tests/benchmarks/qml/js/qjsengine/qjsengine.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_bench_qjsengine
+
+SOURCES += tst_qjsengine.cpp
+
+QT += qml testlib
diff --git a/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp b/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp
new file mode 100644
index 0000000000..5713eb2f2e
--- /dev/null
+++ b/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp
@@ -0,0 +1,600 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtQml/qjsvalue.h>
+#include <QtQml/qjsengine.h>
+
+
+Q_DECLARE_METATYPE(QJSValue)
+
+class tst_QJSEngine : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QJSEngine();
+ virtual ~tst_QJSEngine();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void constructor();
+#if 0 // No defaultPrototype for now
+ void defaultPrototype();
+ void setDefaultPrototype();
+#endif
+ void evaluate_data();
+ void evaluate();
+#if 0 // No program
+ void evaluateProgram_data();
+ void evaluateProgram();
+#endif
+#if 0 // no connections for now
+ void connectAndDisconnect();
+#endif
+ void globalObject();
+ void hasUncaughtException();
+#if 0 // no is Evaluating for now
+ void isEvaluating();
+#endif
+ void newArray_data();
+ void newArray();
+ void newDate();
+ void newObject();
+#if 0 // No ScriptClass
+ void newObjectWithScriptClass();
+#endif
+#if 0 // no qmetaobject
+ void newQMetaObject();
+#endif
+ void newQObject();
+#if 0 // no native functions for now
+ void newFunction();
+#endif
+ void newRegExp();
+ void newVariant();
+ void undefinedValue();
+ void collectGarbage();
+#if 0 // No extensions
+ void availableExtensions();
+ void importedExtensions();
+#endif
+#if 0 // no context
+ void currentContext();
+ void pushAndPopContext();
+#endif
+#if 0 // no stringhandle
+ void toStringHandle();
+#endif
+ void castValueToQreal();
+#if 0 // no native functions for now
+ void nativeCall();
+#endif
+#if 0 // no translations
+ void installTranslatorFunctions();
+ void translation_data();
+ void translation();
+#endif
+#if 0 // no declarative class
+ void readScopeProperty_data();
+ void readScopeProperty();
+#endif
+#if 0 // no context
+ void evaluateInNewContext();
+ void evaluateInNewContextWithScope();
+#endif
+#if 0 // no pushScope
+ void evaluateBindingExpression();
+#endif
+
+private:
+ void defineStandardTestValues();
+ void newEngine()
+ {
+ delete m_engine;
+ m_engine = new QJSEngine;
+ }
+
+ QJSEngine *m_engine;
+};
+
+tst_QJSEngine::tst_QJSEngine()
+ : m_engine(0)
+{
+}
+
+tst_QJSEngine::~tst_QJSEngine()
+{
+ delete m_engine;
+}
+
+void tst_QJSEngine::init()
+{
+}
+
+void tst_QJSEngine::cleanup()
+{
+}
+
+void tst_QJSEngine::constructor()
+{
+ QBENCHMARK {
+ QJSEngine engine;
+ (void)engine.parent();
+ }
+}
+
+#if 0 // No defaultPrototype for now
+void tst_QJSEngine::defaultPrototype()
+{
+ newEngine();
+ int type = qMetaTypeId<int>();
+ m_engine->setDefaultPrototype(type, m_engine->newObject());
+ QBENCHMARK {
+ m_engine->defaultPrototype(type);
+ }
+}
+
+void tst_QJSEngine::setDefaultPrototype()
+{
+ newEngine();
+ int type = qMetaTypeId<int>();
+ QJSValue proto = m_engine->newObject();
+ QBENCHMARK {
+ m_engine->setDefaultPrototype(type, proto);
+ }
+}
+
+#endif
+
+void tst_QJSEngine::evaluate_data()
+{
+ QTest::addColumn<QString>("code");
+ QTest::newRow("empty script") << QString::fromLatin1("");
+ QTest::newRow("number literal") << QString::fromLatin1("123");
+ QTest::newRow("string literal") << QString::fromLatin1("'ciao'");
+ QTest::newRow("regexp literal") << QString::fromLatin1("/foo/gim");
+ QTest::newRow("null literal") << QString::fromLatin1("null");
+ QTest::newRow("undefined literal") << QString::fromLatin1("undefined");
+ QTest::newRow("null literal") << QString::fromLatin1("null");
+ QTest::newRow("empty object literal") << QString::fromLatin1("{}");
+ QTest::newRow("this") << QString::fromLatin1("this");
+ QTest::newRow("object literal with one property") << QString::fromLatin1("{ foo: 123 }");
+ QTest::newRow("object literal with two properties") << QString::fromLatin1("{ foo: 123, bar: 456 }");
+ QTest::newRow("object literal with many properties") << QString::fromLatin1("{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }");
+ QTest::newRow("empty array literal") << QString::fromLatin1("[]");
+ QTest::newRow("array literal with one element") << QString::fromLatin1("[1]");
+ QTest::newRow("array literal with two elements") << QString::fromLatin1("[1,2]");
+ QTest::newRow("array literal with many elements") << QString::fromLatin1("[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]");
+ QTest::newRow("empty function definition") << QString::fromLatin1("function foo() { }");
+ QTest::newRow("function definition") << QString::fromLatin1("function foo() { return 123; }");
+ QTest::newRow("for loop with empty body (1000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000; ++i) {}");
+ QTest::newRow("for loop with empty body (10000 iterations)") << QString::fromLatin1("for (i = 0; i < 10000; ++i) {}");
+ QTest::newRow("for loop with empty body (100000 iterations)") << QString::fromLatin1("for (i = 0; i < 100000; ++i) {}");
+ QTest::newRow("for loop with empty body (1000000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000000; ++i) {}");
+ QTest::newRow("for loop (1000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000; ++i) { j += i; }; j");
+ QTest::newRow("for loop (10000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 10000; ++i) { j += i; }; j");
+ QTest::newRow("for loop (100000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 100000; ++i) { j += i; }; j");
+ QTest::newRow("for loop (1000000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000000; ++i) { j += i; }; j");
+ QTest::newRow("assignments") << QString::fromLatin1("a = 1; b = 2; c = 3; d = 4");
+ QTest::newRow("while loop (1000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000) { ++i; }; i");
+ QTest::newRow("while loop (10000 iterations)") << QString::fromLatin1("i = 0; while (i < 10000) { ++i; }; i");
+ QTest::newRow("while loop (100000 iterations)") << QString::fromLatin1("i = 0; while (i < 100000) { ++i; }; i");
+ QTest::newRow("while loop (1000000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000000) { ++i; }; i");
+ QTest::newRow("function expression") << QString::fromLatin1("(function(a, b, c){ return a + b + c; })(1, 2, 3)");
+}
+
+void tst_QJSEngine::evaluate()
+{
+ QFETCH(QString, code);
+ newEngine();
+
+ QBENCHMARK {
+ (void)m_engine->evaluate(code);
+ }
+}
+
+#if 0
+void tst_QJSEngine::connectAndDisconnect()
+{
+ newEngine();
+ QJSValue fun = m_engine->evaluate("(function() { })");
+ QBENCHMARK {
+ qScriptConnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun);
+ qScriptDisconnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun);
+ }
+}
+
+void tst_QJSEngine::evaluateProgram_data()
+{
+ evaluate_data();
+}
+
+void tst_QJSEngine::evaluateProgram()
+{
+ QFETCH(QString, code);
+ QScriptProgram program(code);
+ newEngine();
+
+ QBENCHMARK {
+ (void)m_engine->evaluate(program);
+ }
+}
+#endif
+
+void tst_QJSEngine::globalObject()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->globalObject();
+ }
+}
+
+void tst_QJSEngine::hasUncaughtException()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->hasUncaughtException();
+ }
+}
+
+#if 0
+void tst_QJSEngine::isEvaluating()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->isEvaluating();
+ }
+}
+#endif
+
+void tst_QJSEngine::newArray_data()
+{
+ QTest::addColumn<int>("size");
+ QTest::newRow("size=0") << 0;
+ QTest::newRow("size=10") << 10;
+ QTest::newRow("size=100") << 0;
+ QTest::newRow("size=1000") << 0;
+ QTest::newRow("size=10000") << 0;
+ QTest::newRow("size=50000") << 0;
+}
+
+void tst_QJSEngine::newArray()
+{
+ QFETCH(int, size);
+ newEngine();
+ QBENCHMARK {
+ m_engine->newArray(size);
+ }
+}
+
+void tst_QJSEngine::newDate()
+{
+ newEngine();
+ QDateTime dt = QDateTime::currentDateTime();
+ QBENCHMARK {
+ m_engine->toScriptValue(dt);
+ }
+}
+
+void tst_QJSEngine::newObject()
+{
+ newEngine();
+ QBENCHMARK {
+ (void)m_engine->newObject();
+ }
+}
+
+#if 0
+void tst_QJSEngine::newObjectWithScriptClass()
+{
+ newEngine();
+ QScriptClass cls(m_engine);
+ QBENCHMARK {
+ m_engine->newObject(&cls);
+ }
+}
+
+void tst_QJSEngine::newQMetaObject()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->newQMetaObject(&QJSEngine::staticMetaObject);
+ }
+}
+#endif
+
+void tst_QJSEngine::newQObject()
+{
+ newEngine();
+ QBENCHMARK {
+ (void)m_engine->newQObject(QCoreApplication::instance());
+ }
+}
+
+#if 0
+static QJSValue testFunction(QScriptContext *, QJSEngine *)
+{
+ return 0;
+}
+
+void tst_QJSEngine::newFunction()
+{
+ newEngine();
+ QBENCHMARK {
+ (void)m_engine->newFunction(testFunction);
+ }
+}
+#endif
+
+void tst_QJSEngine::newRegExp()
+{
+ newEngine();
+ QRegExp re = QRegExp("foo");
+ QBENCHMARK {
+ m_engine->toScriptValue(re);
+ }
+}
+
+void tst_QJSEngine::newVariant()
+{
+ newEngine();
+ QVariant var(QPoint(10, 20));
+ QBENCHMARK {
+ (void)m_engine->toScriptValue(var);
+ }
+}
+
+void tst_QJSEngine::undefinedValue()
+{
+ newEngine();
+ QVariant var;
+ QBENCHMARK {
+ m_engine->toScriptValue(var);
+ }
+}
+
+void tst_QJSEngine::collectGarbage()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->collectGarbage();
+ }
+}
+
+#if 0
+void tst_QJSEngine::availableExtensions()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->availableExtensions();
+ }
+}
+
+void tst_QJSEngine::importedExtensions()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->importedExtensions();
+ }
+}
+
+void tst_QJSEngine::currentContext()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->currentContext();
+ }
+}
+
+void tst_QJSEngine::pushAndPopContext()
+{
+ newEngine();
+ QBENCHMARK {
+ (void)m_engine->pushContext();
+ m_engine->popContext();
+ }
+}
+#endif
+
+#if 0
+void tst_QJSEngine::toStringHandle()
+{
+ newEngine();
+ QString str = QString::fromLatin1("foobarbaz");
+ QBENCHMARK {
+ (void)m_engine->toStringHandle(str);
+ }
+}
+#endif
+
+void tst_QJSEngine::castValueToQreal()
+{
+ QJSValue val(123);
+ QBENCHMARK {
+ (void)qjsvalue_cast<qreal>(val);
+ }
+}
+
+#if 0
+static QJSValue native_function(QScriptContext *, QJSEngine *)
+{
+ return 42;
+}
+
+void tst_QJSEngine::nativeCall()
+{
+ newEngine();
+ m_engine->globalObject().setProperty("fun", m_engine->newFunction(native_function));
+ QBENCHMARK{
+ m_engine->evaluate("var w = 0; for (i = 0; i < 100000; ++i) {\n"
+ " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }");
+ }
+}
+
+void tst_QJSEngine::installTranslatorFunctions()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->installTranslatorFunctions();
+ }
+}
+
+void tst_QJSEngine::translation_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("fileName");
+ QTest::newRow("no translation") << "\"hello world\"" << "";
+ QTest::newRow("qsTr") << "qsTr(\"hello world\")" << "";
+ QTest::newRow("qsTranslate") << "qsTranslate(\"\", \"hello world\")" << "";
+ QTest::newRow("qsTr:script.js") << "qsTr(\"hello world\")" << "script.js";
+}
+
+void tst_QJSEngine::translation()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, fileName);
+ newEngine();
+ m_engine->installTranslatorFunctions();
+
+ QBENCHMARK {
+ (void)m_engine->evaluate(text, fileName);
+ }
+}
+#endif
+
+#if 0
+void tst_QJSEngine::readScopeProperty_data()
+{
+ QTest::addColumn<bool>("staticScope");
+ QTest::addColumn<bool>("nestedScope");
+ QTest::newRow("single dynamic scope") << false << false;
+ QTest::newRow("single static scope") << true << false;
+ QTest::newRow("double dynamic scope") << false << true;
+ QTest::newRow("double static scope") << true << true;
+}
+
+void tst_QJSEngine::readScopeProperty()
+{
+ QFETCH(bool, staticScope);
+ QFETCH(bool, nestedScope);
+
+ newEngine();
+ QScriptContext *ctx = m_engine->pushContext();
+
+ QJSValue scope;
+ if (staticScope)
+ scope = QScriptDeclarativeClass::newStaticScopeObject(m_engine);
+ else
+ scope = m_engine->newObject();
+ scope.setProperty("foo", 123);
+ ctx->pushScope(scope);
+
+ if (nestedScope) {
+ QJSValue scope2;
+ if (staticScope)
+ scope2 = QScriptDeclarativeClass::newStaticScopeObject(m_engine);
+ else
+ scope2 = m_engine->newObject();
+ scope2.setProperty("bar", 456); // ensure a miss in inner scope
+ ctx->pushScope(scope2);
+ }
+
+ QJSValue fun = m_engine->evaluate("(function() {\n"
+ " for (var i = 0; i < 10000; ++i) {\n"
+ " foo; foo; foo; foo; foo; foo; foo; foo;\n"
+ " }\n"
+ "})");
+ m_engine->popContext();
+ QVERIFY(fun.isFunction());
+ QBENCHMARK {
+ fun.call();
+ }
+}
+
+void tst_QJSEngine::evaluateInNewContext()
+{
+ QJSEngine engine;
+ QBENCHMARK {
+ engine.pushContext();
+ engine.evaluate("var a = 10");
+ engine.popContext();
+ }
+}
+
+void tst_QJSEngine::evaluateInNewContextWithScope()
+{
+ QJSEngine engine;
+ QJSValue scope = engine.newObject();
+ scope.setProperty("foo", 123);
+ QBENCHMARK {
+ QScriptContext *ctx = engine.pushContext();
+ ctx->pushScope(scope);
+ engine.evaluate("foo");
+ engine.popContext();
+ }
+}
+
+// Binding expressions in QML are implemented as anonymous functions
+// with custom scopes.
+void tst_QJSEngine::evaluateBindingExpression()
+{
+ QJSEngine engine;
+ QScriptContext *ctx = engine.pushContext();
+ QJSValue scope = engine.newObject();
+ scope.setProperty("foo", 123);
+ ctx->pushScope(scope);
+ QJSValue fun = engine.evaluate("(function() { return foo; })");
+ QVERIFY(fun.isFunction());
+ engine.popContext();
+ QVERIFY(fun.call().equals(scope.property("foo")));
+ QJSValue receiver = engine.globalObject();
+ QBENCHMARK {
+ fun.call(receiver);
+ }
+}
+#endif
+
+QTEST_MAIN(tst_QJSEngine)
+#include "tst_qjsengine.moc"
diff --git a/tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro b/tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro
new file mode 100644
index 0000000000..772aa5da8c
--- /dev/null
+++ b/tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_bench_qjsvalue
+
+SOURCES += tst_qjsvalue.cpp
+
+QT += qml testlib
diff --git a/tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp b/tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp
new file mode 100644
index 0000000000..6c760f37aa
--- /dev/null
+++ b/tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp
@@ -0,0 +1,979 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtQml/qjsvalue.h>
+#include <QtQml/qjsengine.h>
+
+Q_DECLARE_METATYPE(QJSValue)
+
+class tst_QJSValue : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QJSValue();
+ virtual ~tst_QJSValue();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void boolConstructor();
+ void floatConstructor();
+ void numberConstructor();
+ void stringConstructor();
+ void nullConstructor();
+ void undefinedConstructor();
+ void boolConstructorWithEngine();
+ void floatConstructorWithEngine();
+ void intConstructorWithEngine();
+ void stringConstructorWithEngine();
+ void undefinedConstructorWithEngine();
+ void copyConstructor_data();
+ void copyConstructor();
+ void call_data();
+ void call();
+ void construct_data();
+ void construct();
+#if 0 // no data
+ void data();
+ void setData();
+ void data_noData_data();
+ void data_noData();
+#endif
+ void equalsSelf_data();
+ void equalsSelf();
+#if 0 // no less then
+ void lessThanSelf_data();
+ void lessThanSelf();
+#endif
+ void strictlyEqualsSelf_data();
+ void strictlyEqualsSelf();
+ void isArray_data();
+ void isArray();
+ void isBool_data();
+ void isBool();
+ void isDate_data();
+ void isDate();
+ void isError_data();
+ void isError();
+ void isCallable_data();
+ void isCallable();
+ void isNull_data();
+ void isNull();
+ void isNumber_data();
+ void isNumber();
+ void isObject_data();
+ void isObject();
+#if 0 // no qmetaobject
+ void isQMetaObject_data();
+ void isQMetaObject();
+#endif
+ void isQObject_data();
+ void isQObject();
+ void isRegExp_data();
+ void isRegExp();
+ void isString_data();
+ void isString();
+ void isUndefined_data();
+ void isUndefined();
+ void isVariant_data();
+ void isVariant();
+ void toBool_data();
+ void toBool();
+ void toDateTime_data();
+ void toDateTime();
+ void toInt_data();
+ void toInt();
+ void toNumber_data();
+ void toNumber();
+ void toRegExp_data();
+ void toRegExp();
+ void toString_data();
+ void toString();
+ void toUInt_data();
+ void toUInt();
+#if 0 // no qmetaobject
+ void toQMetaObject_data();
+ void toQMetaObject();
+#endif
+ void toQObject_data();
+ void toQObject();
+ void toVariant_data();
+ void toVariant();
+ void property_data();
+ void property();
+#if 0 // no string handle
+ void propertyById_data();
+ void propertyById();
+#endif
+ void propertyByIndex();
+ void setProperty_data();
+ void setProperty();
+#if 0 // no string handle
+ void setPropertyById_data();
+ void setPropertyById();
+#endif
+ void setPropertyByIndex();
+#if 0 // no propertyFlags for now
+ void propertyFlags_data();
+ void propertyFlags();
+ void propertyFlagsById_data();
+ void propertyFlagsById();
+#endif
+ void prototype_data();
+ void prototype();
+ void setPrototype();
+#if 0 // no script class
+ void scriptClass_data();
+ void scriptClass();
+ void setScriptClass();
+#endif
+#if 0 // no string handle
+ void readMetaProperty();
+ void writeMetaProperty();
+#endif
+
+private:
+ void defineStandardTestValues();
+ void newEngine()
+ {
+ delete m_engine;
+ m_engine = new QJSEngine;
+ }
+
+ QJSEngine *m_engine;
+};
+
+tst_QJSValue::tst_QJSValue()
+ : m_engine(0)
+{
+}
+
+tst_QJSValue::~tst_QJSValue()
+{
+ delete m_engine;
+}
+
+void tst_QJSValue::init()
+{
+}
+
+void tst_QJSValue::cleanup()
+{
+}
+
+void tst_QJSValue::boolConstructor()
+{
+ QBENCHMARK {
+ QJSValue val(true);
+ }
+}
+
+void tst_QJSValue::floatConstructor()
+{
+ QBENCHMARK {
+ QJSValue val(123.0);
+ }
+}
+
+void tst_QJSValue::numberConstructor()
+{
+ QBENCHMARK {
+ (void)QJSValue(123);
+ }
+}
+
+void tst_QJSValue::stringConstructor()
+{
+ QString str = QString::fromLatin1("ciao");
+ QBENCHMARK {
+ (void)QJSValue(str);
+ }
+}
+
+void tst_QJSValue::nullConstructor()
+{
+ QBENCHMARK {
+ QJSValue val(QJSValue::NullValue);
+ }
+}
+
+void tst_QJSValue::undefinedConstructor()
+{
+ QBENCHMARK {
+ QJSValue val(QJSValue::UndefinedValue);
+ }
+}
+
+void tst_QJSValue::boolConstructorWithEngine()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->toScriptValue(true);
+ }
+}
+
+void tst_QJSValue::floatConstructorWithEngine()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->toScriptValue(123.0);
+ }
+}
+
+void tst_QJSValue::intConstructorWithEngine()
+{
+ newEngine();
+ QBENCHMARK {
+ m_engine->toScriptValue(123);
+ }
+}
+
+void tst_QJSValue::stringConstructorWithEngine()
+{
+ newEngine();
+ QString str = QString::fromLatin1("ciao");
+ QBENCHMARK {
+ m_engine->toScriptValue(str);
+ }
+}
+
+void tst_QJSValue::undefinedConstructorWithEngine()
+{
+ newEngine();
+ QVariant var;
+ QBENCHMARK {
+ m_engine->toScriptValue(var);
+ }
+}
+
+void tst_QJSValue::copyConstructor_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::copyConstructor()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ QJSValue copy(val);
+ }
+}
+
+void tst_QJSValue::call_data()
+{
+ newEngine();
+ QTest::addColumn<QString>("code");
+ QTest::newRow("empty function") << QString::fromLatin1("(function(){})");
+ QTest::newRow("function returning number") << QString::fromLatin1("(function(){ return 123; })");
+ QTest::newRow("closure") << QString::fromLatin1("(function(a, b){ return function() { return a + b; }; })(1, 2)");
+}
+
+void tst_QJSValue::call()
+{
+ QFETCH(QString, code);
+ QJSValue fun = m_engine->evaluate(code);
+ QVERIFY(fun.isCallable());
+ QBENCHMARK {
+ (void)fun.call();
+ }
+}
+
+void tst_QJSValue::construct_data()
+{
+ newEngine();
+ QTest::addColumn<QString>("code");
+ QTest::newRow("empty function") << QString::fromLatin1("(function(){})");
+ QTest::newRow("simple constructor") << QString::fromLatin1("(function(){ this.x = 10; this.y = 20; })");
+}
+
+void tst_QJSValue::construct()
+{
+ QFETCH(QString, code);
+ QJSValue fun = m_engine->evaluate(code);
+ QVERIFY(fun.isCallable());
+ QBENCHMARK {
+ (void)fun.callAsConstructor();
+ }
+}
+
+#if 0
+void tst_QJSValue::data()
+{
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ obj.setData(QJSValue(m_engine, 123));
+ QBENCHMARK {
+ obj.data();
+ }
+}
+
+void tst_QJSValue::setData()
+{
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ QJSValue val(m_engine, 123);
+ QBENCHMARK {
+ obj.setData(val);
+ }
+}
+
+void tst_QJSValue::data_noData_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::data_noData()
+{
+ QFETCH(QJSValue, val);
+ QVERIFY(!val.data().isValid());
+ QBENCHMARK {
+ val.data();
+ }
+}
+#endif
+
+void tst_QJSValue::equalsSelf_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::equalsSelf()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.equals(val);
+ }
+}
+
+#if 0
+void tst_QJSValue::lessThanSelf_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::lessThanSelf()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.lessThan(val);
+ }
+}
+#endif
+
+void tst_QJSValue::strictlyEqualsSelf_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::strictlyEqualsSelf()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.strictlyEquals(val);
+ }
+}
+
+void tst_QJSValue::isArray_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isArray()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isArray();
+ }
+}
+
+void tst_QJSValue::isBool_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isBool()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isBool();
+ }
+}
+
+void tst_QJSValue::isDate_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isDate()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isDate();
+ }
+}
+
+void tst_QJSValue::isError_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isError()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isError();
+ }
+}
+
+void tst_QJSValue::isCallable_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isCallable()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isCallable();
+ }
+}
+
+void tst_QJSValue::isNull_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isNull()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isNull();
+ }
+}
+
+void tst_QJSValue::isNumber_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isNumber()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isNumber();
+ }
+}
+
+void tst_QJSValue::isObject_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isObject()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isObject();
+ }
+}
+
+#if 0
+void tst_QJSValue::isQMetaObject_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isQMetaObject()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isQMetaObject();
+ }
+}
+#endif
+
+void tst_QJSValue::isQObject_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isQObject()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isQObject();
+ }
+}
+
+void tst_QJSValue::isRegExp_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isRegExp()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isRegExp();
+ }
+}
+
+void tst_QJSValue::isString_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isString()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isString();
+ }
+}
+
+void tst_QJSValue::isUndefined_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isUndefined()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isUndefined();
+ }
+}
+
+void tst_QJSValue::isVariant_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::isVariant()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.isVariant();
+ }
+}
+
+void tst_QJSValue::toBool_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toBool()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.toBool();
+ }
+}
+
+void tst_QJSValue::toDateTime_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toDateTime()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.toDateTime();
+ }
+}
+
+void tst_QJSValue::toInt_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toInt()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.toInt();
+ }
+}
+
+void tst_QJSValue::toNumber_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toNumber()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.toNumber();
+ }
+}
+
+void tst_QJSValue::toRegExp_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toRegExp()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ qjsvalue_cast<QRegExp>(val);
+ }
+}
+
+void tst_QJSValue::toString_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toString()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ (void)val.toString();
+ }
+}
+
+#if 0
+void tst_QJSValue::toQMetaObject_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toQMetaObject()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.toQMetaObject();
+ }
+}
+#endif
+
+void tst_QJSValue::toQObject_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toQObject()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ (void)val.toQObject();
+ }
+}
+
+void tst_QJSValue::toUInt_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toUInt()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.toUInt();
+ }
+}
+
+void tst_QJSValue::toVariant_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::toVariant()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.toVariant();
+ }
+}
+void tst_QJSValue::property_data()
+{
+ QTest::addColumn<QString>("propertyName");
+ QTest::addColumn<bool>("create");
+ QTest::newRow("foo") << QString::fromLatin1("foo") << true;
+ QTest::newRow("hasOwnProperty") << QString::fromLatin1("hasOwnProperty") << false; // From Object.prototype.
+ QTest::newRow("noSuchProperty") << QString::fromLatin1("noSuchProperty") << false;
+}
+
+void tst_QJSValue::property()
+{
+ QFETCH(QString, propertyName);
+ QFETCH(bool, create);
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ if (create)
+ obj.setProperty(propertyName, 123);
+ QBENCHMARK {
+ (void)obj.property(propertyName);
+ }
+}
+
+#if 0
+void tst_QJSValue::propertyById_data()
+{
+ property_data();
+}
+
+void tst_QJSValue::propertyById()
+{
+ QFETCH(QString, propertyName);
+ QFETCH(bool, create);
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ QJSString id = m_engine->toStringHandle(propertyName);
+ if (create)
+ obj.setProperty(id, 123);
+ QBENCHMARK {
+ obj.property(id);
+ }
+}
+#endif
+
+void tst_QJSValue::propertyByIndex()
+{
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ obj.setProperty(123, 456);
+ QBENCHMARK {
+ obj.property(123);
+ }
+}
+
+void tst_QJSValue::setProperty_data()
+{
+ newEngine();
+ QTest::addColumn<QString>("propertyName");
+ QTest::addColumn<QJSValue>("val");
+ QTest::newRow("foo") << QString::fromLatin1("foo") << QJSValue(123);
+ QTest::newRow("bar") << QString::fromLatin1("bar") << m_engine->toScriptValue(123);
+ QTest::newRow("baz") << QString::fromLatin1("baz") << QJSValue();
+ QTest::newRow("toString") << QString::fromLatin1("toString") << m_engine->toScriptValue(true);
+}
+
+void tst_QJSValue::setProperty()
+{
+ QFETCH(QString, propertyName);
+ QFETCH(QJSValue, val);
+ QJSValue obj = m_engine->newObject();
+ QBENCHMARK {
+ obj.setProperty(propertyName, val);
+ }
+}
+
+#if 0
+void tst_QJSValue::setPropertyById_data()
+{
+ setProperty_data();
+}
+
+void tst_QJSValue::setPropertyById()
+{
+ QFETCH(QString, propertyName);
+ QFETCH(QJSValue, val);
+ QJSValue obj = m_engine->newObject();
+ QJSString id = m_engine->toStringHandle(propertyName);
+ QBENCHMARK {
+ obj.setProperty(id, val);
+ }
+}
+#endif
+
+void tst_QJSValue::setPropertyByIndex()
+{
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ QJSValue val(456);
+ QBENCHMARK {
+ obj.setProperty(123, 456);
+ }
+}
+
+#if 0
+void tst_QJSValue::propertyFlags_data()
+{
+ property_data();
+}
+
+void tst_QJSValue::propertyFlags()
+{
+ QFETCH(QString, propertyName);
+ QFETCH(bool, create);
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ if (create)
+ obj.setProperty(propertyName, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly);
+ QBENCHMARK {
+ (void)obj.propertyFlags(propertyName);
+ }
+}
+
+void tst_QJSValue::propertyFlagsById_data()
+{
+ propertyFlags_data();
+}
+
+void tst_QJSValue::propertyFlagsById()
+{
+ QFETCH(QString, propertyName);
+ QFETCH(bool, create);
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ QJSString id = m_engine->toStringHandle(propertyName);
+ if (create)
+ obj.setProperty(id, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly);
+ QBENCHMARK {
+ obj.propertyFlags(id);
+ }
+}
+#endif
+
+void tst_QJSValue::prototype_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::prototype()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.prototype();
+ }
+}
+
+void tst_QJSValue::setPrototype()
+{
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ QJSValue proto = m_engine->newObject();
+ QBENCHMARK {
+ obj.setPrototype(proto);
+ }
+}
+
+#if 0
+void tst_QJSValue::scriptClass_data()
+{
+ defineStandardTestValues();
+}
+
+void tst_QJSValue::scriptClass()
+{
+ QFETCH(QJSValue, val);
+ QBENCHMARK {
+ val.scriptClass();
+ }
+}
+
+void tst_QJSValue::setScriptClass()
+{
+ newEngine();
+ QJSValue obj = m_engine->newObject();
+ QJSClass cls(m_engine);
+ QBENCHMARK {
+ obj.setScriptClass(&cls);
+ }
+}
+
+void tst_QJSValue::readMetaProperty()
+{
+ newEngine();
+ QJSValue object = m_engine->newQObject(QCoreApplication::instance());
+ QJSString propertyName = m_engine->toStringHandle("objectName");
+ QBENCHMARK {
+ for (int i = 0; i < 10000; ++i)
+ object.property(propertyName);
+ }
+}
+
+void tst_QJSValue::writeMetaProperty()
+{
+ newEngine();
+ QJSValue object = m_engine->newQObject(QCoreApplication::instance());
+ QJSString propertyName = m_engine->toStringHandle("objectName");
+ QJSValue value(m_engine, "foo");
+ QBENCHMARK {
+ for (int i = 0; i < 10000; ++i)
+ object.setProperty(propertyName, value);
+ }
+}
+#endif
+
+void tst_QJSValue::defineStandardTestValues()
+{
+ newEngine();
+ QTest::addColumn<QJSValue>("val");
+ QTest::newRow("bool") << m_engine->evaluate("true");
+ QTest::newRow("number") << m_engine->evaluate("123");
+ QTest::newRow("string") << m_engine->evaluate("'ciao'");
+ QTest::newRow("null") << m_engine->evaluate("null");
+ QTest::newRow("undefined") << m_engine->evaluate("undefined");
+ QTest::newRow("object") << m_engine->evaluate("({foo:123})");
+ QTest::newRow("array") << m_engine->evaluate("[10,20,30]");
+ QTest::newRow("function") << m_engine->evaluate("(function foo(a, b, c) { return a + b + c; })");
+ QTest::newRow("date") << m_engine->evaluate("new Date");
+ QTest::newRow("regexp") << m_engine->evaluate("new RegExp('foo')");
+ QTest::newRow("error") << m_engine->evaluate("new Error");
+
+ QTest::newRow("qobject") << m_engine->newQObject(this);
+#if 0 // no qmetaobject
+ QTest::newRow("qmetaobject") << m_engine->newQMetaObject(&QJSEngine::staticMetaObject);
+#endif
+ QTest::newRow("variant") << m_engine->toScriptValue(QPoint(10, 20));
+#if 0 // no classess
+ QTest::newRow("qscriptclassobject") << m_engine->newObject(new QJSClass(m_engine));
+#endif
+
+ QTest::newRow("invalid") << QJSValue();
+ QTest::newRow("bool-no-engine") << QJSValue(true);
+ QTest::newRow("number-no-engine") << QJSValue(123.0);
+ QTest::newRow("string-no-engine") << QJSValue(QString::fromLatin1("hello"));
+ QTest::newRow("null-no-engine") << QJSValue(QJSValue::NullValue);
+ QTest::newRow("undefined-no-engine") << QJSValue(QJSValue::UndefinedValue);
+}
+
+QTEST_MAIN(tst_QJSValue)
+#include "tst_qjsvalue.moc"
diff --git a/tests/benchmarks/qml/js/qjsvalueiterator/qjsvalueiterator.pro b/tests/benchmarks/qml/js/qjsvalueiterator/qjsvalueiterator.pro
new file mode 100644
index 0000000000..7601789ca9
--- /dev/null
+++ b/tests/benchmarks/qml/js/qjsvalueiterator/qjsvalueiterator.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_bench_qjsvalueiterator
+
+SOURCES += tst_qjsvalueiterator.cpp
+
+QT = core qml testlib
diff --git a/tests/benchmarks/qml/js/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/benchmarks/qml/js/qjsvalueiterator/tst_qjsvalueiterator.cpp
new file mode 100644
index 0000000000..51c6cffd99
--- /dev/null
+++ b/tests/benchmarks/qml/js/qjsvalueiterator/tst_qjsvalueiterator.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtQml/qjsengine.h>
+#include <QtQml/qjsvalue.h>
+#include <QtQml/qjsvalueiterator.h>
+
+class tst_QJSValueIterator : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QJSValueIterator();
+ virtual ~tst_QJSValueIterator();
+
+ void dataHelper();
+
+private slots:
+ void init();
+ void cleanup();
+
+ void hasNextAndNext();
+
+ void constructAndNext_data();
+ void constructAndNext();
+
+ void name_data();
+ void name();
+#if 0 // No string handle
+ void scriptName_data();
+ void scriptName();
+#endif
+
+ void value_data();
+ void value();
+#if 0 // no setValue
+ void setValue_data();
+ void setValue();
+#endif
+#if 0 // no flags
+ void flags();
+#endif
+
+#if 0 // no array index
+ void iterateArrayAndConvertNameToIndex();
+#endif
+#if 0 // no setValue
+ void iterateArrayAndDoubleElements();
+#endif
+#if 0 // no remove
+ void iterateArrayAndRemoveAllElements();
+#endif
+};
+
+tst_QJSValueIterator::tst_QJSValueIterator()
+{
+}
+
+tst_QJSValueIterator::~tst_QJSValueIterator()
+{
+}
+
+void tst_QJSValueIterator::init()
+{
+}
+
+void tst_QJSValueIterator::cleanup()
+{
+}
+
+void tst_QJSValueIterator::dataHelper()
+{
+ QTest::addColumn<QString>("code");
+ QTest::newRow("{ foo: 123 }") << QString::fromLatin1("({ foo: 123 })");
+ QTest::newRow("Math") << QString::fromLatin1("Math");
+ QTest::newRow("Array.prototype") << QString::fromLatin1("Array.prototype");
+ QTest::newRow("Global Object") << QString::fromLatin1("this");
+ QTest::newRow("['foo']") << QString::fromLatin1("['foo']");
+ QTest::newRow("array with 1000 elements")
+ << QString::fromLatin1("(function() {"
+ " var a = new Array;"
+ " for (i = 0; i < 1000; ++i)"
+ " a[i] = i;"
+ " return a;"
+ "})()");
+}
+
+void tst_QJSValueIterator::hasNextAndNext()
+{
+ QJSEngine engine;
+ QJSValue object = engine.newObject();
+ for (int i = 0; i < 2000; ++i)
+ object.setProperty(i, i);
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i) {
+ QJSValueIterator it(object);
+ while (it.hasNext())
+ it.next();
+ }
+ }
+}
+
+void tst_QJSValueIterator::constructAndNext_data()
+{
+ dataHelper();
+}
+
+void tst_QJSValueIterator::constructAndNext()
+{
+ QFETCH(QString, code);
+ QJSEngine engine;
+ QJSValue object = engine.evaluate(code);
+ Q_ASSERT(object.isObject());
+
+ QBENCHMARK {
+ for (int i = 0; i < 100; ++i) {
+ QJSValueIterator it(object);
+ it.next();
+ }
+ }
+}
+
+void tst_QJSValueIterator::name_data()
+{
+ dataHelper();
+}
+
+void tst_QJSValueIterator::name()
+{
+ QFETCH(QString, code);
+ QJSEngine engine;
+ QJSValue object = engine.evaluate(code);
+ Q_ASSERT(object.isObject());
+
+ QJSValueIterator it(object);
+ it.next();
+ QBENCHMARK {
+ for (int i = 0; i < 200000; ++i)
+ it.name();
+ }
+}
+
+#if 0
+void tst_QJSValueIterator::scriptName_data()
+{
+ dataHelper();
+}
+
+void tst_QJSValueIterator::scriptName()
+{
+ QFETCH(QString, code);
+ QJSEngine engine;
+ QJSValue object = engine.evaluate(code);
+ Q_ASSERT(object.isObject());
+
+ QJSValueIterator it(object);
+ it.next();
+ QBENCHMARK {
+ for (int i = 0; i < 50000; ++i)
+ it.scriptName();
+ }
+}
+#endif
+
+void tst_QJSValueIterator::value_data()
+{
+ dataHelper();
+}
+
+void tst_QJSValueIterator::value()
+{
+ QFETCH(QString, code);
+ QJSEngine engine;
+ QJSValue object = engine.evaluate(code);
+ Q_ASSERT(object.isObject());
+
+ QJSValueIterator it(object);
+ it.next();
+ QBENCHMARK {
+ for (int i = 0; i < 50000; ++i)
+ it.value();
+ }
+}
+
+#if 0
+void tst_QJSValueIterator::setValue_data()
+{
+ dataHelper();
+}
+
+void tst_QJSValueIterator::setValue()
+{
+ QFETCH(QString, code);
+ QJSEngine engine;
+ QJSValue object = engine.evaluate(code);
+ Q_ASSERT(object.isObject());
+
+ QJSValueIterator it(object);
+ it.next();
+ QJSValue newValue(&engine, 456);
+ QBENCHMARK {
+ for (int i = 0; i < 50000; ++i)
+ it.setValue(newValue);
+ }
+}
+
+void tst_QJSValueIterator::flags()
+{
+ QJSEngine engine;
+ QJSValue object = engine.newObject();
+ QJSValue::PropertyFlags flags = flags;
+ object.setProperty("foo", 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly | QJSValue::Undeletable);
+ QJSValueIterator it(object);
+ it.next();
+ QBENCHMARK {
+ for (int i = 0; i < 50000; ++i)
+ it.flags();
+ }
+}
+#endif
+
+#if 0
+void tst_QJSValueIterator::iterateArrayAndConvertNameToIndex()
+{
+ QJSEngine engine;
+ QJSValue array = engine.newArray();
+ for (int i = 0; i < 20000; ++i)
+ array.setProperty(i, i);
+ QBENCHMARK {
+ QJSValueIterator it(array);
+ while (it.hasNext()) {
+ it.next();
+ it.scriptName().toArrayIndex();
+ }
+ }
+}
+
+void tst_QJSValueIterator::iterateArrayAndDoubleElements()
+{
+ QJSEngine engine;
+ QJSValue array = engine.newArray();
+ for (int i = 0; i < 20000; ++i)
+ array.setProperty(i, i);
+ QBENCHMARK {
+ QJSValueIterator it(array);
+ while (it.hasNext()) {
+ it.next();
+ it.setValue(QJSValue(&engine, it.value().toNumber() * 2));
+ }
+ }
+}
+
+void tst_QJSValueIterator::iterateArrayAndRemoveAllElements()
+{
+ QJSEngine engine;
+ QJSValue array = engine.newArray();
+ for (int i = 0; i < 20000; ++i)
+ array.setProperty(i, i);
+ QBENCHMARK {
+ QJSValueIterator it(array);
+ while (it.hasNext()) {
+ it.next();
+ it.remove();
+ }
+ }
+}
+#endif
+
+QTEST_MAIN(tst_QJSValueIterator)
+#include "tst_qjsvalueiterator.moc"
diff --git a/tests/benchmarks/declarative/painting/data/63x63.png b/tests/benchmarks/qml/painting/data/63x63.png
index d9efda8a7a..d9efda8a7a 100644
--- a/tests/benchmarks/declarative/painting/data/63x63.png
+++ b/tests/benchmarks/qml/painting/data/63x63.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/data/63x63_opaque.png b/tests/benchmarks/qml/painting/data/63x63_opaque.png
index d1429080db..d1429080db 100644
--- a/tests/benchmarks/declarative/painting/data/63x63_opaque.png
+++ b/tests/benchmarks/qml/painting/data/63x63_opaque.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/data/64x64.png b/tests/benchmarks/qml/painting/data/64x64.png
index b149f33c3d..b149f33c3d 100644
--- a/tests/benchmarks/declarative/painting/data/64x64.png
+++ b/tests/benchmarks/qml/painting/data/64x64.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/data/64x64_opaque.png b/tests/benchmarks/qml/painting/data/64x64_opaque.png
index 94c07f3b3e..94c07f3b3e 100644
--- a/tests/benchmarks/declarative/painting/data/64x64_opaque.png
+++ b/tests/benchmarks/qml/painting/data/64x64_opaque.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.cpp b/tests/benchmarks/qml/painting/paintbenchmark.cpp
index 548a9269f6..548a9269f6 100644
--- a/tests/benchmarks/declarative/painting/paintbenchmark.cpp
+++ b/tests/benchmarks/qml/painting/paintbenchmark.cpp
diff --git a/tests/benchmarks/declarative/painting/painting.pro b/tests/benchmarks/qml/painting/painting.pro
index ff85b5f5f2..ff85b5f5f2 100644
--- a/tests/benchmarks/declarative/painting/painting.pro
+++ b/tests/benchmarks/qml/painting/painting.pro
diff --git a/tests/benchmarks/qml/pointers/pointers.pro b/tests/benchmarks/qml/pointers/pointers.pro
new file mode 100644
index 0000000000..d2f9729a14
--- /dev/null
+++ b/tests/benchmarks/qml/pointers/pointers.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+QT += qml testlib
+TEMPLATE = app
+TARGET = tst_pointers
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_pointers.cpp
+
diff --git a/tests/benchmarks/qml/pointers/tst_pointers.cpp b/tests/benchmarks/qml/pointers/tst_pointers.cpp
new file mode 100644
index 0000000000..d65376460a
--- /dev/null
+++ b/tests/benchmarks/qml/pointers/tst_pointers.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include "private/qqmlguard_p.h"
+#include <QWeakPointer>
+
+class tst_pointers : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_pointers() {}
+
+private slots:
+ void qmlguard();
+ void weakPointer();
+};
+
+void tst_pointers::qmlguard()
+{
+ QObject *obj = new QObject;
+ QBENCHMARK {
+ QQmlGuard<QObject> guardedObject;
+ guardedObject = obj;
+ }
+}
+
+void tst_pointers::weakPointer()
+{
+ QObject *obj = new QObject;
+ QBENCHMARK {
+ QWeakPointer<QObject> guardedObject;
+ guardedObject = obj;
+ }
+}
+
+QTEST_MAIN(tst_pointers)
+#include "tst_pointers.moc"
diff --git a/tests/benchmarks/qml/qml.pro b/tests/benchmarks/qml/qml.pro
new file mode 100644
index 0000000000..7a75c69dd1
--- /dev/null
+++ b/tests/benchmarks/qml/qml.pro
@@ -0,0 +1,18 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ binding \
+ creation \
+ javascript \
+ holistic \
+ pointers \
+ qqmlcomponent \
+ qqmlimage \
+ qqmlmetaproperty \
+ script \
+ qmltime \
+ js
+
+contains(QT_CONFIG, opengl): SUBDIRS += painting
+
+include(../trusted-benchmarks.pri)
diff --git a/tests/benchmarks/qml/qmltime/example.qml b/tests/benchmarks/qml/qmltime/example.qml
new file mode 100644
index 0000000000..66c4fdacaa
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/example.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ property string name: "Bob Smith"
+
+ QmlTime.Timer {
+ component: Item {
+ Text { text: name }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/qml/qmltime/qmltime.cpp b/tests/benchmarks/qml/qmltime/qmltime.cpp
new file mode 100644
index 0000000000..7bca7e6544
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/qmltime.cpp
@@ -0,0 +1,283 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+#include <QApplication>
+#include <QTime>
+#include <QQmlContext>
+#include <QGraphicsScene>
+#include <QGraphicsRectItem>
+
+class Timer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlComponent *component READ component WRITE setComponent)
+
+public:
+ Timer();
+
+ QQmlComponent *component() const;
+ void setComponent(QQmlComponent *);
+
+ static Timer *timerInstance();
+
+ void run(uint);
+
+ bool willParent() const;
+ void setWillParent(bool p);
+
+private:
+ void runTest(QQmlContext *, uint);
+
+ QQmlComponent *m_component;
+ static Timer *m_timer;
+
+ bool m_willparent;
+ QGraphicsScene m_scene;
+ QGraphicsRectItem m_item;
+};
+QML_DECLARE_TYPE(Timer);
+
+Timer *Timer::m_timer = 0;
+
+Timer::Timer()
+: m_component(0), m_willparent(false)
+{
+ if (m_timer)
+ qWarning("Timer: Timer already registered");
+ m_timer = this;
+
+ m_scene.setItemIndexMethod(QGraphicsScene::NoIndex);
+ m_scene.addItem(&m_item);
+}
+
+QQmlComponent *Timer::component() const
+{
+ return m_component;
+}
+
+void Timer::setComponent(QQmlComponent *c)
+{
+ m_component = c;
+}
+
+Timer *Timer::timerInstance()
+{
+ return m_timer;
+}
+
+void Timer::run(uint iterations)
+{
+ QQmlContext context(qmlContext(this));
+
+ QObject *o = m_component->create(&context);
+ QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
+ if (m_willparent && go)
+ go->setParentItem(&m_item);
+ delete o;
+
+ runTest(&context, iterations);
+}
+
+bool Timer::willParent() const
+{
+ return m_willparent;
+}
+
+void Timer::setWillParent(bool p)
+{
+ m_willparent = p;
+}
+
+void Timer::runTest(QQmlContext *context, uint iterations)
+{
+ QTime t;
+ t.start();
+ for (uint ii = 0; ii < iterations; ++ii) {
+ QObject *o = m_component->create(context);
+ QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
+ if (m_willparent && go)
+ go->setParentItem(&m_item);
+ delete o;
+ }
+
+ int e = t.elapsed();
+
+ qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms";
+
+}
+
+void usage(const char *name)
+{
+ qWarning("Usage: %s [-iterations <count>] [-parent] <qml file>\n", name);
+
+ qWarning("qmltime is a tool for benchmarking the runtime cost of instantiating\n"
+ "a QML component. It is typically run as follows:\n"
+ "\n"
+ "%s path/to/benchmark.qml\n"
+ "\n"
+ "If the -parent option is specified, the component being measured will also\n"
+ "be parented to an item already in the scene.\n"
+ "\n"
+ "If the -iterations option is specified, the benchmark will run the specified\n"
+ "number of iterations. If -iterations is not specified, 1024 iterations\n"
+ "are performed.\n"
+ "\n"
+ "qmltime expects the file to be benchmarked to contain a certain structure.\n"
+ "Specifically, it requires the presence of a QmlTime.Timer element. For example,\n"
+ "say we wanted to benchmark the following list delegate:\n"
+ "\n"
+ "Rectangle {\n"
+ " color: \"green\"\n"
+ " width: 400; height: 100\n"
+ " Text {\n"
+ " anchors.centerIn: parent\n"
+ " text: name\n"
+ " }\n"
+ "}\n"
+ "\n"
+ "we would create a benchmark file that looks like this:\n"
+ "\n"
+ "import QtQuick 2.0\n"
+ "import QmlTime 1.0 as QmlTime\n"
+ "\n"
+ "Item {\n"
+ "\n"
+ " property string name: \"Bob Smith\"\n"
+ "\n"
+ " QmlTime.Timer {\n"
+ " component: Rectangle {\n"
+ " color: \"green\"\n"
+ " width: 400; height: 100\n"
+ " Text {\n"
+ " anchors.centerIn: parent\n"
+ " text: name\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}\n"
+ "\n"
+ "The outer Item functions as a dummy data provider for any additional\n"
+ "data required by the bindings in the component being benchmarked (in the\n"
+ "example above we provide a \"name\" property).\n"
+ "\n"
+ "When started, the component is instantiated once before running\n"
+ "the benchmark, which means that the reported time does not include\n"
+ "compile time (as the results of compilation are cached internally).\n"
+ "In this sense the times reported by qmltime best correspond to the\n"
+ "costs associated with delegate creation in the view classes, where the\n"
+ "same delegate is instantiated over and over. Conversely, it is not a\n"
+ "good approximation for e.g. Loader, which typically only instantiates\n"
+ "an element once (and so for Loader the compile time is very relevant\n"
+ "to the overall cost).", name);
+
+ exit(-1);
+}
+
+int main(int argc, char ** argv)
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Timer>("QmlTime", 1, 0, "Timer");
+
+ uint iterations = 1024;
+ QString filename;
+ bool willParent = false;
+
+ for (int ii = 1; ii < argc; ++ii) {
+ QByteArray arg(argv[ii]);
+
+ if (arg == "-iterations") {
+ if (ii + 1 < argc) {
+ ++ii;
+ QByteArray its(argv[ii]);
+ bool ok = false;
+ iterations = its.toUInt(&ok);
+ if (!ok)
+ usage(argv[0]);
+ } else {
+ usage(argv[0]);
+ }
+ } else if (arg == "-parent") {
+ willParent = true;
+ } else if (arg == "-help") {
+ usage(argv[0]);
+ } else {
+ filename = QLatin1String(argv[ii]);
+ }
+ }
+
+ if (filename.isEmpty())
+ usage(argv[0]);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, filename);
+ if (component.isError()) {
+ qWarning() << component.errors();
+ return -1;
+ }
+
+ QObject *obj = component.create();
+ if (!obj) {
+ qWarning() << component.errors();
+ return -1;
+ }
+
+ Timer *timer = Timer::timerInstance();
+ if (!timer) {
+ qWarning() << "A Tester.Timer instance is required.";
+ return -1;
+ }
+
+ timer->setWillParent(willParent);
+
+ if (!timer->component()) {
+ qWarning() << "The timer has no component";
+ return -1;
+ }
+
+ timer->run(iterations);
+
+ return 0;
+}
+
+#include "qmltime.moc"
diff --git a/tests/benchmarks/qml/qmltime/qmltime.pro b/tests/benchmarks/qml/qmltime/qmltime.pro
new file mode 100644
index 0000000000..6cc6d13b34
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/qmltime.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = qmltime
+QT += qml widgets testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += qmltime.cpp
+
diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/empty.qml b/tests/benchmarks/qml/qmltime/tests/anchors/empty.qml
new file mode 100644
index 0000000000..6ecfb3d48f
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/anchors/empty.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/fill.qml b/tests/benchmarks/qml/qmltime/tests/anchors/fill.qml
new file mode 100644
index 0000000000..c2e3b3decb
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/anchors/fill.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/null.qml b/tests/benchmarks/qml/qmltime/tests/anchors/null.qml
new file mode 100644
index 0000000000..677281f162
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/anchors/null.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/qml/qmltime/tests/animation/large.qml b/tests/benchmarks/qml/qmltime/tests/animation/large.qml
new file mode 100644
index 0000000000..16aad5c9ec
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/animation/large.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ ParallelAnimation {
+ NumberAnimation { duration: 500 }
+ NumberAnimation { duration: 4000; }
+ NumberAnimation { duration: 2000; easing.type: "OutBack"}
+ ColorAnimation { duration: 3000}
+ SequentialAnimation {
+ PauseAnimation { duration: 1000 }
+ ScriptAction { script: doSomething(); }
+ PauseAnimation { duration: 800 }
+ ScriptAction { script: doSomethingElse(); }
+ PauseAnimation { duration: 800 }
+ ParallelAnimation {
+ NumberAnimation { duration: 200;}
+ SequentialAnimation {
+ PauseAnimation { duration: 200}
+ ParallelAnimation {
+ NumberAnimation { duration: 300;}
+ NumberAnimation { duration: 300;}
+ }
+ NumberAnimation { from: 0; to: 1; duration: 500 }
+ PauseAnimation { duration: 200 }
+ NumberAnimation { from: 1; to: 0; duration: 500 }
+ }
+ SequentialAnimation {
+ PauseAnimation { duration: 150}
+ NumberAnimation { duration: 300; easing.type: "OutBounce" }
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml b/tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml
new file mode 100644
index 0000000000..5538182646
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ ParallelAnimation {
+ NumberAnimation { }
+ NumberAnimation { }
+ NumberAnimation { }
+ ColorAnimation { }
+ SequentialAnimation {
+ PauseAnimation { }
+ ScriptAction { }
+ PauseAnimation { }
+ ScriptAction { }
+ PauseAnimation { }
+ ParallelAnimation {
+ NumberAnimation { }
+ SequentialAnimation {
+ PauseAnimation { }
+ ParallelAnimation {
+ NumberAnimation { }
+ NumberAnimation { }
+ }
+ NumberAnimation { }
+ PauseAnimation { }
+ NumberAnimation { }
+ }
+ SequentialAnimation {
+ PauseAnimation { }
+ NumberAnimation { }
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/children.qml b/tests/benchmarks/qml/qmltime/tests/item_creation/children.qml
new file mode 100644
index 0000000000..4677bb6e72
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/item_creation/children.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ children: [
+ Rectangle { },
+ Rectangle { },
+ Item { },
+ Image { },
+ Text { },
+ Item { },
+ Item { },
+ Image { },
+ Image { },
+ Row { },
+ Image { },
+ Image { },
+ Column { },
+ Row { },
+ Text { },
+ Text { },
+ Text { },
+ MouseArea { }
+ ]
+
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/data.qml b/tests/benchmarks/qml/qmltime/tests/item_creation/data.qml
new file mode 100644
index 0000000000..af54e9c9e9
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/item_creation/data.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ data: [
+ Rectangle { },
+ Rectangle { },
+ Item { },
+ Image { },
+ Text { },
+ Item { },
+ Item { },
+ Image { },
+ Image { },
+ Row { },
+ Image { },
+ Image { },
+ Column { },
+ Row { },
+ Text { },
+ Text { },
+ Text { },
+ MouseArea { }
+ ]
+
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml b/tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml
new file mode 100644
index 0000000000..87d61b810e
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ }
+ }
+ }
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml
new file mode 100644
index 0000000000..029f782ef5
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ resources: [
+ Rectangle { },
+ Rectangle { },
+ Item { },
+ Image { },
+ Text { },
+ Item { },
+ Item { },
+ Image { },
+ Image { },
+ Row { },
+ Image { },
+ Image { },
+ Column { },
+ Row { },
+ Text { },
+ Text { },
+ Text { },
+ MouseArea { }
+ ]
+
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml b/tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml
new file mode 100644
index 0000000000..1310115c43
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ Rectangle {}
+ Text {}
+ Image {}
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml b/tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml
new file mode 100644
index 0000000000..bed709991e
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Loader {
+ sourceComponent: Loaded {}
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml b/tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml
new file mode 100644
index 0000000000..a25cbb8f45
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Loader {}
+ Loaded {}
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml b/tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml
new file mode 100644
index 0000000000..ae2ad3e60e
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Loaded {}
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml b/tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml
new file mode 100644
index 0000000000..a077f448d5
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Loader {
+ source: "Loaded.qml"
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml
new file mode 100644
index 0000000000..0377a8e1a2
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Rectangle { }
+ Rectangle { }
+ Item {
+ Image { }
+ Text { }
+ }
+
+ Item {
+ Item {
+ Image { }
+ Image { }
+ Item {
+ Image { }
+ Image { }
+ }
+ }
+
+ Item {
+ Item {
+ Text { }
+ Text { }
+ }
+ Text { }
+ }
+ }
+ MouseArea { }
+ }
+ }
+ }
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml
new file mode 100644
index 0000000000..e9fc2c06ec
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Rectangle { }
+ Rectangle { }
+ Item {
+ Image { }
+ Text { }
+ }
+
+ Item {
+ Item {
+ Image { }
+ Image { }
+ Row { }
+ Image { }
+ Image { }
+ }
+
+ Column { }
+ Row { }
+ Text { }
+ Text { }
+ Text { }
+ }
+ MouseArea { }
+ }
+ }
+ }
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml
new file mode 100644
index 0000000000..3a5daec0a5
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+ QmlTime.Timer {
+ component: Component {
+ Item {
+ Rectangle { }
+ Rectangle { }
+ Item {
+ Image { }
+ Text { }
+ }
+
+ Item {
+ Item {
+ Image { }
+ Image { }
+ Row {
+ Image { }
+ Image { }
+ }
+ }
+
+ Column {
+ Row {
+ Text { }
+ Text { }
+ }
+ Text { }
+ }
+ }
+ MouseArea { }
+ }
+ }
+ }
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml b/tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml
new file mode 100644
index 0000000000..c283261dd5
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ QtObject {
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml b/tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml
new file mode 100644
index 0000000000..4722150d98
--- /dev/null
+++ b/tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QmlTime 1.0 as QmlTime
+
+Item {
+
+ QmlTime.Timer {
+ component: Component {
+ QtObject {
+ property string s
+ property string s2
+ property string s3
+ property string s4
+ }
+ }
+ }
+
+}
+
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject.qml b/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject.qml
new file mode 100644
index 0000000000..4c7e48fc7c
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 4.6
+
+MyQmlObject {}
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject_binding.qml b/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject_binding.qml
new file mode 100644
index 0000000000..918f93c30e
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject_binding.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 4.6
+
+MyQmlObject {
+ result: value
+}
+
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/object.qml b/tests/benchmarks/qml/qqmlcomponent/data/object.qml
new file mode 100644
index 0000000000..726871b8ea
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/object.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+QtObject {}
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/object_id.qml b/tests/benchmarks/qml/qqmlcomponent/data/object_id.qml
new file mode 100644
index 0000000000..eb99567717
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/object_id.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+QtObject {
+ id: blah
+}
+
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/qml/qqmlcomponent/data/samegame/BoomBlock.qml
new file mode 100644
index 0000000000..5678fa400e
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/samegame/BoomBlock.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+
+ Image {
+ id: img
+ source: {
+ if(type == 0){
+ "pics/redStone.png";
+ } else if(type == 1) {
+ "pics/blueStone.png";
+ } else {
+ "pics/greenStone.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+ Emitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if(type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else {
+ "green";
+ }
+ }
+ anchors.fill: parent
+
+ speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
+ shape: EllipseShape{fill:true}
+ enabled: false;
+ lifeSpan: 700; lifeSpanVariation: 100
+ emitRate: 1000
+ maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
+ size: 28
+ endSize: 14
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.pulse(0.1); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/blueStone.png b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/blueStone.png
new file mode 100644
index 0000000000..20e43c75b6
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/blueStone.png
Binary files differ
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/greenStone.png b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/greenStone.png
new file mode 100644
index 0000000000..b568a1900c
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/greenStone.png
Binary files differ
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/redStone.png b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/redStone.png
new file mode 100644
index 0000000000..36b09a2686
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/redStone.png
Binary files differ
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/yellowStone.png b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/yellowStone.png
new file mode 100644
index 0000000000..b1ce76212c
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/yellowStone.png
Binary files differ
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.2.qml b/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.2.qml
new file mode 100644
index 0000000000..ec987defb3
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.2.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+QtObject {
+ property int a
+ property bool b
+ property double c
+ property real d
+ property string e
+ property url f
+ property color g
+ property date h
+ property variant i
+ property variant j
+}
+
diff --git a/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.qml b/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.qml
new file mode 100644
index 0000000000..397efae5f8
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+QtObject {
+ property int a
+}
diff --git a/tests/benchmarks/qml/qqmlcomponent/qqmlcomponent.pro b/tests/benchmarks/qml/qqmlcomponent/qqmlcomponent.pro
new file mode 100644
index 0000000000..ba41f5a95b
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/qqmlcomponent.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_qqmlcomponent
+QT += qml testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlcomponent.cpp testtypes.cpp
+HEADERS += testtypes.h
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp b/tests/benchmarks/qml/qqmlcomponent/testtypes.cpp
index 4d2932aa79..4d2932aa79 100644
--- a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp
+++ b/tests/benchmarks/qml/qqmlcomponent/testtypes.cpp
diff --git a/tests/benchmarks/qml/qqmlcomponent/testtypes.h b/tests/benchmarks/qml/qqmlcomponent/testtypes.h
new file mode 100644
index 0000000000..03542ca24c
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/testtypes.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int result READ result WRITE setResult)
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+ Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data)
+ Q_CLASSINFO("DefaultProperty", "data")
+public:
+ MyQmlObject() : m_result(0), m_value(0), m_object(0) {}
+
+ int result() const { return m_result; }
+ void setResult(int r) { m_result = r; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; emit valueChanged(); }
+
+ QQmlListProperty<QObject> data() { return QQmlListProperty<QObject>(this, m_data); }
+
+ MyQmlObject *object() const { return m_object; }
+ void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); }
+
+signals:
+ void valueChanged();
+ void objectChanged();
+
+private:
+ QList<QObject *> m_data;
+ int m_result;
+ int m_value;
+ MyQmlObject *m_object;
+};
+QML_DECLARE_TYPE(MyQmlObject);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/benchmarks/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/benchmarks/qml/qqmlcomponent/tst_qqmlcomponent.cpp
new file mode 100644
index 0000000000..47b7455a94
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QFile>
+#include <QDebug>
+#include "testtypes.h"
+
+class tst_qmlcomponent : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_qmlcomponent();
+ virtual ~tst_qmlcomponent();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+private slots:
+ void creation_data();
+ void creation();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qmlcomponent::tst_qmlcomponent()
+{
+}
+
+tst_qmlcomponent::~tst_qmlcomponent()
+{
+}
+
+void tst_qmlcomponent::initTestCase()
+{
+ registerTypes();
+}
+
+void tst_qmlcomponent::cleanupTestCase()
+{
+}
+
+void tst_qmlcomponent::creation_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("Object") << SRCDIR "/data/object.qml";
+ QTest::newRow("Object - Id") << SRCDIR "/data/object_id.qml";
+ QTest::newRow("MyQmlObject") << SRCDIR "/data/myqmlobject.qml";
+ QTest::newRow("MyQmlObject: basic binding") << SRCDIR "/data/myqmlobject_binding.qml";
+ QTest::newRow("Synthesized properties") << SRCDIR "/data/synthesized_properties.qml";
+ QTest::newRow("Synthesized properties.2") << SRCDIR "/data/synthesized_properties.2.qml";
+ QTest::newRow("SameGame - BoomBlock") << SRCDIR "/data/samegame/BoomBlock.qml";
+}
+
+void tst_qmlcomponent::creation()
+{
+ QFETCH(QString, file);
+
+ QQmlComponent c(&engine, file);
+ QVERIFY(c.isReady());
+
+ QObject *obj = c.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = c.create();
+ delete obj;
+ }
+}
+
+QTEST_MAIN(tst_qmlcomponent)
+#include "tst_qqmlcomponent.moc"
diff --git a/tests/benchmarks/qml/qqmldebugtrace/qqmldebugtrace.pro b/tests/benchmarks/qml/qqmldebugtrace/qqmldebugtrace.pro
new file mode 100644
index 0000000000..ebf0ae074f
--- /dev/null
+++ b/tests/benchmarks/qml/qqmldebugtrace/qqmldebugtrace.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+QT += qml testlib
+TEMPLATE = app
+TARGET = tst_qqmldebugtrace
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmldebugtrace.cpp
+
diff --git a/tests/benchmarks/qml/qqmldebugtrace/tst_qqmldebugtrace.cpp b/tests/benchmarks/qml/qqmldebugtrace/tst_qqmldebugtrace.cpp
new file mode 100644
index 0000000000..36144f6a76
--- /dev/null
+++ b/tests/benchmarks/qml/qqmldebugtrace/tst_qqmldebugtrace.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QElapsedTimer>
+#include <QObject>
+#include <qtest.h>
+
+class tst_qqmldebugtrace : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_qqmldebugtrace() {}
+
+private slots:
+ void all();
+ void startElapsed();
+ void doubleElapsed();
+ void trace();
+};
+
+void tst_qqmldebugtrace::all()
+{
+ QBENCHMARK {
+ QElapsedTimer t;
+ t.start();
+ t.nsecsElapsed();
+ }
+}
+
+void tst_qqmldebugtrace::startElapsed()
+{
+ QElapsedTimer t;
+ QBENCHMARK {
+ t.start();
+ t.nsecsElapsed();
+ }
+}
+
+void tst_qqmldebugtrace::doubleElapsed()
+{
+ QElapsedTimer t;
+ t.start();
+ QBENCHMARK {
+ t.nsecsElapsed();
+ t.nsecsElapsed();
+ }
+}
+
+void tst_qqmldebugtrace::trace()
+{
+ QString s("A decent sized string of text here.");
+ QBENCHMARK {
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (qint64)100 << (int)5 << (int)5 << s;
+ }
+}
+
+QTEST_MAIN(tst_qqmldebugtrace)
+
+#include "tst_qqmldebugtrace.moc"
diff --git a/tests/benchmarks/declarative/qdeclarativeimage/image.png b/tests/benchmarks/qml/qqmlimage/image.png
index 623d36233d..623d36233d 100644
--- a/tests/benchmarks/declarative/qdeclarativeimage/image.png
+++ b/tests/benchmarks/qml/qqmlimage/image.png
Binary files differ
diff --git a/tests/benchmarks/qml/qqmlimage/qqmlimage.pro b/tests/benchmarks/qml/qqmlimage/qqmlimage.pro
new file mode 100644
index 0000000000..21d3efdd1f
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlimage/qqmlimage.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_qqmlimage
+QT += qml quick-private testlib
+macx:CONFIG -= app_bundle
+CONFIG += release
+
+SOURCES += tst_qqmlimage.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
diff --git a/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp b/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp
new file mode 100644
index 0000000000..ec872b881a
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <private/qquickimage_p.h>
+
+class tst_qmlgraphicsimage : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qmlgraphicsimage() {}
+
+private slots:
+ void qmlgraphicsimage();
+ void qmlgraphicsimage_file();
+ void qmlgraphicsimage_url();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qmlgraphicsimage::qmlgraphicsimage()
+{
+ int x = 0;
+ QUrl url(SRCDIR "/image.png");
+ QBENCHMARK {
+ QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
+ QQuickImage *image = new QQuickImage;
+ QQmlEngine::setContextForObject(image, engine.rootContext());
+ delete image;
+ }
+}
+
+void tst_qmlgraphicsimage::qmlgraphicsimage_file()
+{
+ int x = 0;
+ QUrl url(SRCDIR "/image.png");
+ //get rid of initialization effects
+ {
+ QQuickImage *image = new QQuickImage;
+ QQmlEngine::setContextForObject(image, engine.rootContext());
+ image->setSource(url);
+ }
+ QBENCHMARK {
+ QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
+ QQuickImage *image = new QQuickImage;
+ QQmlEngine::setContextForObject(image, engine.rootContext());
+ image->setSource(url);
+ delete image;
+ }
+}
+
+void tst_qmlgraphicsimage::qmlgraphicsimage_url()
+{
+ int x = 0;
+ QUrl url(SRCDIR "/image.png");
+ QBENCHMARK {
+ QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
+ QQuickImage *image = new QQuickImage;
+ QQmlEngine::setContextForObject(image, engine.rootContext());
+ image->setSource(url2);
+ delete image;
+ }
+}
+
+QTEST_MAIN(tst_qmlgraphicsimage)
+
+#include "tst_qqmlimage.moc"
diff --git a/tests/benchmarks/qml/qqmlmetaproperty/data/object.qml b/tests/benchmarks/qml/qqmlmetaproperty/data/object.qml
new file mode 100644
index 0000000000..47c0442d29
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlmetaproperty/data/object.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {}
diff --git a/tests/benchmarks/qml/qqmlmetaproperty/data/synthesized_object.qml b/tests/benchmarks/qml/qqmlmetaproperty/data/synthesized_object.qml
new file mode 100644
index 0000000000..a4609cb6e0
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlmetaproperty/data/synthesized_object.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property int blah
+}
+
diff --git a/tests/benchmarks/qml/qqmlmetaproperty/qqmlmetaproperty.pro b/tests/benchmarks/qml/qqmlmetaproperty/qqmlmetaproperty.pro
new file mode 100644
index 0000000000..9d507e9581
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlmetaproperty/qqmlmetaproperty.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_qqmlmetaproperty
+QT += qml testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlmetaproperty.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp b/tests/benchmarks/qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp
new file mode 100644
index 0000000000..216d603da8
--- /dev/null
+++ b/tests/benchmarks/qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QQmlProperty>
+#include <QFile>
+#include <QDebug>
+
+class tst_qmlmetaproperty : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_qmlmetaproperty();
+ virtual ~tst_qmlmetaproperty();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void lookup_data();
+ void lookup();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qmlmetaproperty::tst_qmlmetaproperty()
+{
+}
+
+tst_qmlmetaproperty::~tst_qmlmetaproperty()
+{
+}
+
+void tst_qmlmetaproperty::init()
+{
+}
+
+void tst_qmlmetaproperty::cleanup()
+{
+}
+
+void tst_qmlmetaproperty::lookup_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("Simple Object") << SRCDIR "/data/object.qml";
+ QTest::newRow("Synthesized Object") << SRCDIR "/data/synthesized_object.qml";
+}
+
+void tst_qmlmetaproperty::lookup()
+{
+ QFETCH(QString, file);
+
+ QQmlComponent c(&engine, file);
+ QVERIFY(c.isReady());
+
+ QObject *obj = c.create();
+
+ QBENCHMARK {
+ QQmlProperty p(obj, "x");
+ }
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qmlmetaproperty)
+#include "tst_qqmlmetaproperty.moc"
diff --git a/tests/benchmarks/qml/script/data/CustomObject.qml b/tests/benchmarks/qml/script/data/CustomObject.qml
new file mode 100644
index 0000000000..485f8a1354
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/CustomObject.qml
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+QtObject {
+ property real prop1: 0
+ property real prop2: 1
+ property real prop3: 0
+}
diff --git a/tests/benchmarks/qml/script/data/block.qml b/tests/benchmarks/qml/script/data/block.qml
new file mode 100644
index 0000000000..3816b9f64b
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/block.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 200; height: 200
+ CustomObject { id: theObject }
+ function doSomethingDirect() {
+ theObject.prop1 = 0;
+
+ for (var i = 0; i < 1000; ++i)
+ theObject.prop1 += theObject.prop2;
+
+ theObject.prop3 = theObject.prop1;
+ }
+
+ function doSomethingLocalObj() {
+ theObject.prop1 = 0;
+
+ var incrementObj = theObject;
+ for (var i = 0; i < 1000; ++i)
+ incrementObj.prop1 += incrementObj.prop2;
+
+ incrementObj.prop3 = incrementObj.prop1;
+ }
+
+ function doSomethingLocal() {
+ theObject.prop1 = 0;
+
+ var increment = theObject.prop2;
+ for (var i = 0; i < 1000; ++i)
+ theObject.prop1 += increment;
+
+ theObject.prop3 = theObject.prop1;
+ }
+}
diff --git a/tests/benchmarks/qml/script/data/enums.qml b/tests/benchmarks/qml/script/data/enums.qml
new file mode 100644
index 0000000000..f2da9b068e
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/enums.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ function runtest() {
+ var a = 0;
+ for (var ii = 0; ii < 100000; ++ii)
+ a += Text.RichText;
+ return a;
+ }
+}
diff --git a/tests/benchmarks/declarative/script/data/global.js b/tests/benchmarks/qml/script/data/global.js
index 4e3a4780f9..4e3a4780f9 100644
--- a/tests/benchmarks/declarative/script/data/global.js
+++ b/tests/benchmarks/qml/script/data/global.js
diff --git a/tests/benchmarks/declarative/script/data/global_prop.qml b/tests/benchmarks/qml/script/data/global_prop.qml
index c77faaf9f4..c77faaf9f4 100644
--- a/tests/benchmarks/declarative/script/data/global_prop.qml
+++ b/tests/benchmarks/qml/script/data/global_prop.qml
diff --git a/tests/benchmarks/qml/script/data/namespacedEnums.qml b/tests/benchmarks/qml/script/data/namespacedEnums.qml
new file mode 100644
index 0000000000..0f24112d7c
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/namespacedEnums.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0 as QtQuick
+
+QtQuick.Item {
+ function runtest() {
+ var a = 0;
+ for (var ii = 0; ii < 100000; ++ii)
+ a += QtQuick.Text.RichText;
+ return a;
+ }
+}
+
diff --git a/tests/benchmarks/declarative/script/data/script.js b/tests/benchmarks/qml/script/data/script.js
index 9f46570004..9f46570004 100644
--- a/tests/benchmarks/declarative/script/data/script.js
+++ b/tests/benchmarks/qml/script/data/script.js
diff --git a/tests/benchmarks/declarative/script/data/script2.js b/tests/benchmarks/qml/script/data/script2.js
index 102f081140..102f081140 100644
--- a/tests/benchmarks/declarative/script/data/script2.js
+++ b/tests/benchmarks/qml/script/data/script2.js
diff --git a/tests/benchmarks/qml/script/data/scriptCall.qml b/tests/benchmarks/qml/script/data/scriptCall.qml
new file mode 100644
index 0000000000..b4a49b1908
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/scriptCall.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "script.js" as Script
+import "script2.js" as OtherScript
+
+Item {
+ function runtest() {
+ var a = 0;
+ for (var ii = 0; ii < 1000000; ++ii)
+ a += Script.func();
+ return a;
+ }
+}
+
diff --git a/tests/benchmarks/qml/script/data/signal_args.qml b/tests/benchmarks/qml/script/data/signal_args.qml
new file mode 100644
index 0000000000..757ac1a1f9
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/signal_args.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ onMySignalWithArgs: { var a = n; return a; }
+}
+
diff --git a/tests/benchmarks/qml/script/data/signal_heavyArgsAccess.qml b/tests/benchmarks/qml/script/data/signal_heavyArgsAccess.qml
new file mode 100644
index 0000000000..37ef64efef
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/signal_heavyArgsAccess.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ onMySignalWithArgs: {
+ var a = 0;
+ for (var i = 0; i < 10000; ++i)
+ a += n;
+ return a;
+ }
+}
diff --git a/tests/benchmarks/qml/script/data/signal_heavyIdAccess.qml b/tests/benchmarks/qml/script/data/signal_heavyIdAccess.qml
new file mode 100644
index 0000000000..610fcd001a
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/signal_heavyIdAccess.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ id: obj
+ property real inc: 3
+
+ onMySignalWithArgs: {
+ var a = 0;
+ for (var i = 0; i < 10000; ++i)
+ a += obj.inc;
+ return a;
+ }
+}
diff --git a/tests/benchmarks/qml/script/data/signal_qml.qml b/tests/benchmarks/qml/script/data/signal_qml.qml
new file mode 100644
index 0000000000..c7314a6b1e
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/signal_qml.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ onMySignal: { var a = 1; return a; }
+}
+
diff --git a/tests/benchmarks/qml/script/data/signal_unconnected.qml b/tests/benchmarks/qml/script/data/signal_unconnected.qml
new file mode 100644
index 0000000000..a33942dd2d
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/signal_unconnected.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+}
diff --git a/tests/benchmarks/qml/script/data/signal_unusedArgs.qml b/tests/benchmarks/qml/script/data/signal_unusedArgs.qml
new file mode 100644
index 0000000000..52b4e1a54f
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/signal_unusedArgs.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ onMySignalWithArgs: { var a = 1; return a; }
+}
+
diff --git a/tests/benchmarks/qml/script/data/slot_complex.qml b/tests/benchmarks/qml/script/data/slot_complex.qml
new file mode 100644
index 0000000000..4763146c65
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/slot_complex.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ function myCustomFunction(b) {
+ var n = b;
+ var a = 1;
+ while (n > 0) {
+ a = a * n;
+ n--;
+ }
+ return a;
+ }
+
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(10); } }
+}
+
diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.js b/tests/benchmarks/qml/script/data/slot_complex_js.js
index 64a1f65daa..64a1f65daa 100644
--- a/tests/benchmarks/declarative/script/data/slot_complex_js.js
+++ b/tests/benchmarks/qml/script/data/slot_complex_js.js
diff --git a/tests/benchmarks/qml/script/data/slot_complex_js.qml b/tests/benchmarks/qml/script/data/slot_complex_js.qml
new file mode 100644
index 0000000000..e44fc73f8e
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/slot_complex_js.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+import "slot_complex_js.js" as Logic
+
+TestObject {
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(10); } }
+}
+
+
diff --git a/tests/benchmarks/qml/script/data/slot_simple.qml b/tests/benchmarks/qml/script/data/slot_simple.qml
new file mode 100644
index 0000000000..b788970d12
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/slot_simple.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ function myCustomFunction() {
+ return 0;
+ }
+
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(); } }
+}
diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.js b/tests/benchmarks/qml/script/data/slot_simple_js.js
index d6e60608da..d6e60608da 100644
--- a/tests/benchmarks/declarative/script/data/slot_simple_js.js
+++ b/tests/benchmarks/qml/script/data/slot_simple_js.js
diff --git a/tests/benchmarks/qml/script/data/slot_simple_js.qml b/tests/benchmarks/qml/script/data/slot_simple_js.qml
new file mode 100644
index 0000000000..5af1b0868f
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/slot_simple_js.qml
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+import "slot_simple_js.js" as Logic
+
+TestObject {
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(); } }
+}
+
diff --git a/tests/benchmarks/qml/script/script.pro b/tests/benchmarks/qml/script/script.pro
new file mode 100644
index 0000000000..1f836a84f1
--- /dev/null
+++ b/tests/benchmarks/qml/script/script.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_script
+macx:CONFIG -= app_bundle
+CONFIG += release
+
+SOURCES += tst_script.cpp
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/qml/script/tst_script.cpp b/tests/benchmarks/qml/script/tst_script.cpp
new file mode 100644
index 0000000000..e7418d5fc0
--- /dev/null
+++ b/tests/benchmarks/qml/script/tst_script.cpp
@@ -0,0 +1,852 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <private/qqmlengine_p.h>
+#include <private/qquickrectangle_p.h>
+#include <QJSEngine>
+#include <QJSValue>
+
+class tst_script : public QObject
+{
+ Q_OBJECT
+public:
+ tst_script() {}
+
+private slots:
+ void initTestCase();
+
+ void property_js();
+ void property_getter_js();
+#if 0
+ //no native functions for now
+ void property_getter();
+ void property_getter_qobject();
+ void property_getter_qmetaproperty();
+#endif
+ void property_qobject();
+ void property_qmlobject();
+
+ void setproperty_js();
+ void setproperty_qmlobject();
+
+ void function_js();
+#if 0
+ //no native functions for now
+ void function_cpp();
+#endif
+ void function_qobject();
+ void function_qmlobject();
+
+ void function_args_js();
+#if 0
+ //no native functions for now
+ void function_args_cpp();
+#endif
+ void function_args_qobject();
+ void function_args_qmlobject();
+
+ void signal_unconnected();
+ void signal_qml();
+ void signal_args();
+ void signal_unusedArgs();
+ void signal_heavyArgsAccess();
+ void signal_heavyIdAccess();
+
+ void slot_simple();
+ void slot_simple_js();
+ void slot_complex();
+ void slot_complex_js();
+
+ void block_data();
+ void block();
+
+ void global_property_js();
+ void global_property_qml();
+ void global_property_qml_js();
+
+ void scriptfile_property();
+
+ void enums();
+ void namespacedEnums();
+ void scriptCall();
+};
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int x READ x WRITE setX)
+
+public:
+ TestObject(QObject *parent = 0);
+
+ int x();
+ void setX(int x) { m_x = x; }
+
+ void emitMySignal() { emit mySignal(); }
+ void emitMySignalWithArgs(int n) { emit mySignalWithArgs(n); }
+
+signals:
+ void mySignal();
+ void mySignalWithArgs(int n);
+
+public slots:
+ int method() {
+ return x();
+ }
+
+ int methodArgs(int val) {
+ return val + x();
+ }
+
+private:
+ int m_x;
+};
+QML_DECLARE_TYPE(TestObject);
+
+TestObject::TestObject(QObject *parent)
+: QObject(parent), m_x(0)
+{
+}
+
+int TestObject::x()
+{
+ return m_x++;
+}
+
+void tst_script::initTestCase()
+{
+ qmlRegisterType<TestObject>("Qt.test", 1, 0, "TestObject");
+}
+
+
+#define PROPERTY_PROGRAM \
+ "(function(testObject) { return (function() { " \
+ " var test = 0; " \
+ " for (var ii = 0; ii < 10000; ++ii) { " \
+ " test += testObject.x; " \
+ " } " \
+ " return test; " \
+ "}); })"
+
+void tst_script::property_js()
+{
+ QJSEngine engine;
+
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), 10);
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call().toNumber();
+ }
+}
+
+#if 0
+static QJSValue property_getter_method(QScriptContext *, QJSEngine *engine)
+{
+ static int x = 0;
+ return QJSValue(engine,x++);
+}
+
+void tst_script::property_getter()
+{
+ QJSEngine engine;
+
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_method),
+ QJSValue::PropertyGetter);
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+static TestObject *property_getter_qobject_object = 0;
+static QJSValue property_getter_qobject_method(QScriptContext *, QJSEngine *)
+{
+ static int idx = -1;
+ if (idx == -1)
+ idx = TestObject::staticMetaObject.indexOfProperty("x");
+
+ int value = 0;
+ void *args[] = { &value, 0 };
+ QMetaObject::metacall(property_getter_qobject_object, QMetaObject::ReadProperty, idx, args);
+
+ return QJSValue(value);
+}
+
+static QJSValue property_getter_qmetaproperty_method(QScriptContext *, QJSEngine *)
+{
+ static int idx = -1;
+ if (idx == -1)
+ idx = TestObject::staticMetaObject.indexOfProperty("x");
+
+ int value = 0;
+ value = property_getter_qobject_object->metaObject()->property(idx).read(property_getter_qobject_object).toInt();
+
+ return QJSValue(value);
+}
+
+void tst_script::property_getter_qobject()
+{
+ QJSEngine engine;
+
+ TestObject to;
+ property_getter_qobject_object = &to;
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qobject_method),
+ QJSValue::PropertyGetter);
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+ property_getter_qobject_object = 0;
+}
+
+void tst_script::property_getter_qmetaproperty()
+{
+ QJSEngine engine;
+
+ TestObject to;
+ property_getter_qobject_object = &to;
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qmetaproperty_method),
+ QJSValue::PropertyGetter);
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+ property_getter_qobject_object = 0;
+}
+#endif
+
+void tst_script::property_getter_js()
+{
+ QJSEngine engine;
+
+ QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.__defineGetter__(\"x\", function() { return this._x++; }); return o; })").call();
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::property_qobject()
+{
+ QJSEngine engine;
+
+ TestObject to;
+ QJSValue v = engine.newQObject(&to);
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::property_qmlobject()
+{
+ QQmlEngine qmlengine;
+
+ TestObject to;
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(&qmlengine);
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+ QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = qmlengine.evaluate(PROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+#define SETPROPERTY_PROGRAM \
+ "(function(testObject) { return (function() { " \
+ " for (var ii = 0; ii < 10000; ++ii) { " \
+ " testObject.x = ii; " \
+ " } " \
+ "}); })"
+
+void tst_script::setproperty_js()
+{
+ QJSEngine engine;
+
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), 0);
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::setproperty_qmlobject()
+{
+ QQmlEngine qmlengine;
+
+ TestObject to;
+
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(&qmlengine);
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+ QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = qmlengine.evaluate(SETPROPERTY_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+#define FUNCTION_PROGRAM \
+ "(function(testObject) { return (function() { " \
+ " var test = 0; " \
+ " for (var ii = 0; ii < 10000; ++ii) { " \
+ " test += testObject.method(); " \
+ " } " \
+ " return test; " \
+ "}); })"
+
+void tst_script::function_js()
+{
+ QJSEngine engine;
+
+ QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.method = (function() { return this._x++; }); return o; })").call();
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+#if 0
+static QJSValue function_method(QScriptContext *, QJSEngine *)
+{
+ static int x = 0;
+ return QJSValue(x++);
+}
+
+void tst_script::function_cpp()
+{
+ QJSEngine engine;
+
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("method"), engine.newFunction(function_method));
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+#endif
+
+void tst_script::function_qobject()
+{
+ QJSEngine engine;
+
+ TestObject to;
+ QJSValue v = engine.newQObject(&to);
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::function_qmlobject()
+{
+ QQmlEngine qmlengine;
+
+ TestObject to;
+
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(&qmlengine);
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+ QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = qmlengine.evaluate(FUNCTION_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+#define FUNCTION_ARGS_PROGRAM \
+ "(function(testObject) { return (function() { " \
+ " var test = 0; " \
+ " for (var ii = 0; ii < 10000; ++ii) { " \
+ " test += testObject.methodArgs(ii); " \
+ " } " \
+ " return test; " \
+ "}); })"
+
+void tst_script::function_args_js()
+{
+ QJSEngine engine;
+
+ QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.methodArgs = (function(a) { return a + this._x++; }); return o; })").call();
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+#if 0
+static QJSValue function_args_method(QScriptContext *ctxt, QJSEngine *)
+{
+ static int x = 0;
+ return QJSValue(ctxt->argument(0).toNumber() + x++);
+}
+
+void tst_script::function_args_cpp()
+{
+ QJSEngine engine;
+
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("methodArgs"), engine.newFunction(function_args_method));
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+#endif
+
+void tst_script::function_args_qobject()
+{
+ QJSEngine engine;
+
+ TestObject to;
+ QJSValue v = engine.newQObject(&to);
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::function_args_qmlobject()
+{
+ QQmlEngine qmlengine;
+
+ TestObject to;
+
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(&qmlengine);
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+ QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
+
+ QJSValueList args;
+ args << v;
+ QJSValue prog = qmlengine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::signal_unconnected()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("signal_unconnected.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::signal_qml()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("signal_qml.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::signal_args()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("signal_args.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignalWithArgs(11);
+ }
+
+ delete object;
+}
+
+void tst_script::signal_unusedArgs()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("signal_unusedArgs.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignalWithArgs(11);
+ }
+
+ delete object;
+}
+
+void tst_script::signal_heavyArgsAccess()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("signal_heavyArgsAccess.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignalWithArgs(11);
+ }
+
+ delete object;
+}
+
+void tst_script::signal_heavyIdAccess()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("signal_heavyIdAccess.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignalWithArgs(11);
+ }
+
+ delete object;
+}
+
+void tst_script::slot_simple()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("slot_simple.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::slot_simple_js()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("slot_simple_js.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::slot_complex()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("slot_complex.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::slot_complex_js()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("slot_complex_js.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignal();
+ }
+
+ delete object;
+}
+
+void tst_script::block_data()
+{
+ QTest::addColumn<QString>("methodName");
+ QTest::newRow("direct") << "doSomethingDirect()";
+ QTest::newRow("localObj") << "doSomethingLocalObj()";
+ QTest::newRow("local") << "doSomethingLocal()";
+}
+
+void tst_script::block()
+{
+ QFETCH(QString, methodName);
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("block.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(component.create());
+ QVERIFY(rect != 0);
+
+ int index = rect->metaObject()->indexOfMethod(methodName.toUtf8());
+ QVERIFY(index != -1);
+ QMetaMethod method = rect->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(rect, Qt::DirectConnection);
+ }
+
+ delete rect;
+}
+
+#define GLOBALPROPERTY_PROGRAM \
+ "(function() { " \
+ " for (var ii = 0; ii < 10000; ++ii) { " \
+ " Math.sin(90); " \
+ " } " \
+ "})"
+
+void tst_script::global_property_js()
+{
+ QJSEngine engine;
+
+ QJSValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::global_property_qml()
+{
+ QQmlEngine qmlengine;
+
+ QJSValue prog = qmlengine.evaluate(GLOBALPROPERTY_PROGRAM);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::global_property_qml_js()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("global_prop.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(component.create());
+ QVERIFY(rect != 0);
+
+ int index = rect->metaObject()->indexOfMethod("triggered()");
+ QVERIFY(index != -1);
+ QMetaMethod method = rect->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(rect, Qt::DirectConnection);
+ }
+
+ delete rect;
+}
+
+void tst_script::scriptfile_property()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("global_prop.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(component.create());
+ QVERIFY(rect != 0);
+
+ int index = rect->metaObject()->indexOfMethod("incrementTriggered()");
+ QVERIFY(index != -1);
+ QMetaMethod method = rect->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(rect, Qt::DirectConnection);
+ }
+
+ delete rect;
+}
+
+void tst_script::enums()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("enums.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ int index = o->metaObject()->indexOfMethod("runtest()");
+ QVERIFY(index != -1);
+ QMetaMethod method = o->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(o, Qt::DirectConnection);
+ }
+
+ delete o;
+}
+
+void tst_script::namespacedEnums()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("namespacedEnums.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ int index = o->metaObject()->indexOfMethod("runtest()");
+ QVERIFY(index != -1);
+ QMetaMethod method = o->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(o, Qt::DirectConnection);
+ }
+
+ delete o;
+}
+
+void tst_script::scriptCall()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("scriptCall.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ int index = o->metaObject()->indexOfMethod("runtest()");
+ QVERIFY(index != -1);
+ QMetaMethod method = o->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(o, Qt::DirectConnection);
+ }
+
+ delete o;
+}
+
+QTEST_MAIN(tst_script)
+
+#include "tst_script.moc"
diff --git a/tests/benchmarks/qml/typeimports/data/QmlTestType1.qml b/tests/benchmarks/qml/typeimports/data/QmlTestType1.qml
new file mode 100644
index 0000000000..eb1ae13881
--- /dev/null
+++ b/tests/benchmarks/qml/typeimports/data/QmlTestType1.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 2.0
+TestType1 { }
diff --git a/tests/benchmarks/qml/typeimports/data/QmlTestType2.qml b/tests/benchmarks/qml/typeimports/data/QmlTestType2.qml
new file mode 100644
index 0000000000..f6801cddef
--- /dev/null
+++ b/tests/benchmarks/qml/typeimports/data/QmlTestType2.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 2.0
+TestType2 { }
diff --git a/tests/benchmarks/qml/typeimports/data/QmlTestType3.qml b/tests/benchmarks/qml/typeimports/data/QmlTestType3.qml
new file mode 100644
index 0000000000..21ade835ec
--- /dev/null
+++ b/tests/benchmarks/qml/typeimports/data/QmlTestType3.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 2.0
+TestType3 { }
diff --git a/tests/benchmarks/qml/typeimports/data/QmlTestType4.qml b/tests/benchmarks/qml/typeimports/data/QmlTestType4.qml
new file mode 100644
index 0000000000..45fdbfbb09
--- /dev/null
+++ b/tests/benchmarks/qml/typeimports/data/QmlTestType4.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 2.0
+TestType4 { }
diff --git a/tests/benchmarks/qml/typeimports/data/cpp.qml b/tests/benchmarks/qml/typeimports/data/cpp.qml
new file mode 100644
index 0000000000..8700846b5a
--- /dev/null
+++ b/tests/benchmarks/qml/typeimports/data/cpp.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 2.0
+
+TestType1 {
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+ TestType1 { } TestType2 { } TestType3 { } TestType4 { }
+}
diff --git a/tests/benchmarks/qml/typeimports/data/qml.qml b/tests/benchmarks/qml/typeimports/data/qml.qml
new file mode 100644
index 0000000000..1235cde924
--- /dev/null
+++ b/tests/benchmarks/qml/typeimports/data/qml.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+QmlTestType1 {
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+ QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { }
+}
diff --git a/tests/benchmarks/qml/typeimports/tst_typeimports.cpp b/tests/benchmarks/qml/typeimports/tst_typeimports.cpp
new file mode 100644
index 0000000000..69b3f2e215
--- /dev/null
+++ b/tests/benchmarks/qml/typeimports/tst_typeimports.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+
+class tst_typeimports : public QObject
+{
+ Q_OBJECT
+public:
+ tst_typeimports();
+
+private slots:
+ void cpp();
+ void qml();
+
+private:
+ QQmlEngine engine;
+};
+
+class TestType1 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<QObject> resources READ resources);
+ Q_CLASSINFO("DefaultProperty", "resources");
+public:
+ TestType1(QObject *parent = 0) : QObject(parent) {}
+
+ QQmlListProperty<QObject> resources() {
+ return QQmlListProperty<QObject>(this, 0, resources_append);
+ }
+
+ static void resources_append(QQmlListProperty<QObject> *p, QObject *o) {
+ o->setParent(p->object);
+ }
+};
+
+class TestType2 : public TestType1
+{
+ Q_OBJECT
+public:
+ TestType2(QObject *parent = 0) : TestType1(parent) {}
+};
+
+
+class TestType3 : public TestType1
+{
+ Q_OBJECT
+public:
+ TestType3(QObject *parent = 0) : TestType1(parent) {}
+};
+
+class TestType4 : public TestType1
+{
+ Q_OBJECT
+public:
+ TestType4(QObject *parent = 0) : TestType1(parent) {}
+};
+
+
+tst_typeimports::tst_typeimports()
+{
+ qmlRegisterType<TestType1>("Qt.test", 1, 0, "TestType1");
+ qmlRegisterType<TestType2>("Qt.test", 1, 0, "TestType2");
+ qmlRegisterType<TestType3>("Qt.test", 2, 0, "TestType3");
+ qmlRegisterType<TestType4>("Qt.test", 2, 0, "TestType4");
+}
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_typeimports::cpp()
+{
+ QBENCHMARK {
+ QQmlComponent component(&engine, TEST_FILE("cpp.qml"));
+ QVERIFY(component.isReady());
+ }
+}
+
+void tst_typeimports::qml()
+{
+ //get rid of initialization effects
+ { QQmlComponent component(&engine, TEST_FILE("qml.qml")); }
+
+ QBENCHMARK {
+ QQmlComponent component(&engine, TEST_FILE("qml.qml"));
+ QVERIFY(component.isReady());
+ }
+}
+
+QTEST_MAIN(tst_typeimports)
+
+#include "tst_typeimports.moc"
diff --git a/tests/benchmarks/qml/typeimports/typeimports.pro b/tests/benchmarks/qml/typeimports/typeimports.pro
new file mode 100644
index 0000000000..dc58e4044b
--- /dev/null
+++ b/tests/benchmarks/qml/typeimports/typeimports.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_typeimports
+QT += qml testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_typeimports.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/global/global.cfg b/tests/global/global.cfg
index 80e064a74f..e01462a5a0 100644
--- a/tests/global/global.cfg
+++ b/tests/global/global.cfg
@@ -1,5 +1,5 @@
<config>
<modules>
-<module name="QtDeclarative" qtname="declarative"/>
+<module name="QtQml" qtname="declarative"/>
</modules>
</config>
diff --git a/tests/manual/accessibility/animation.qml b/tests/manual/accessibility/animation.qml
index 3d75f28573..bb5c7ac192 100644
--- a/tests/manual/accessibility/animation.qml
+++ b/tests/manual/accessibility/animation.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/manual/accessibility/behavior.qml b/tests/manual/accessibility/behavior.qml
index de86284dcd..614330fbb5 100644
--- a/tests/manual/accessibility/behavior.qml
+++ b/tests/manual/accessibility/behavior.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/manual/accessibility/flickable.qml b/tests/manual/accessibility/flickable.qml
index 24a3b93edc..1014d307ee 100644
--- a/tests/manual/accessibility/flickable.qml
+++ b/tests/manual/accessibility/flickable.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/manual/accessibility/hittest.qml b/tests/manual/accessibility/hittest.qml
index 9f94b7e999..10d65707b0 100644
--- a/tests/manual/accessibility/hittest.qml
+++ b/tests/manual/accessibility/hittest.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/manual/accessibility/numberanimation.qml b/tests/manual/accessibility/numberanimation.qml
index 91c54ecbd3..c35c022272 100644
--- a/tests/manual/accessibility/numberanimation.qml
+++ b/tests/manual/accessibility/numberanimation.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/manual/accessibility/textandbuttons.qml b/tests/manual/accessibility/textandbuttons.qml
index 893cb071b2..6abdb1ea49 100644
--- a/tests/manual/accessibility/textandbuttons.qml
+++ b/tests/manual/accessibility/textandbuttons.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/manual/accessibility/transition.qml b/tests/manual/accessibility/transition.qml
index 05714503a2..d606da7744 100644
--- a/tests/manual/accessibility/transition.qml
+++ b/tests/manual/accessibility/transition.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/testapplications/qsgimage/ImageNG.qml b/tests/testapplications/qsgimage/ImageNG.qml
index fbcef04662..afc4d0c22e 100644
--- a/tests/testapplications/qsgimage/ImageNG.qml
+++ b/tests/testapplications/qsgimage/ImageNG.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/testapplications/qsgimage/img-align.qml b/tests/testapplications/qsgimage/img-align.qml
index b751e006a5..7d118f7538 100644
--- a/tests/testapplications/qsgimage/img-align.qml
+++ b/tests/testapplications/qsgimage/img-align.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tools/qmleasing/TextField.qml b/tools/qmleasing/TextField.qml
index ccdb562cfa..2d7cb5ec28 100644
--- a/tools/qmleasing/TextField.qml
+++ b/tools/qmleasing/TextField.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tools/qmleasing/easing.qml b/tools/qmleasing/easing.qml
index 50a349357f..437bc7da3d 100644
--- a/tools/qmleasing/easing.qml
+++ b/tools/qmleasing/easing.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tools/qmleasing/qmleasing.pro b/tools/qmleasing/qmleasing.pro
index 6f5e56b147..488ec5748a 100644
--- a/tools/qmleasing/qmleasing.pro
+++ b/tools/qmleasing/qmleasing.pro
@@ -1,4 +1,4 @@
-QT += declarative quick widgets
+QT += qml quick widgets
CONFIG -= app_bundle
SOURCES += main.cpp
diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp
index f59eedec84..8baa131b9a 100644
--- a/tools/qmlmin/main.cpp
+++ b/tools/qmlmin/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -39,9 +39,9 @@
**
****************************************************************************/
-#include <private/qdeclarativejsengine_p.h>
-#include <private/qdeclarativejslexer_p.h>
-#include <private/qdeclarativejsparser_p.h>
+#include <private/qqmljsengine_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsparser_p.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
#include <QtCore/QFile>
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
//
// QML/JS minifier
//
-namespace QDeclarativeJS {
+namespace QQmlJS {
enum RegExpFlag {
Global = 0x01,
@@ -66,7 +66,7 @@ enum RegExpFlag {
class QmlminLexer: protected Lexer, public Directives
{
- QDeclarativeJS::Engine _engine;
+ QQmlJS::Engine _engine;
QString _fileName;
QString _directives;
@@ -492,7 +492,7 @@ bool Tokenize::parse(int startToken)
return false;
}
-} // end of QDeclarativeJS namespace
+} // end of QQmlJS namespace
static void usage(bool showHelp = false)
{
@@ -571,7 +571,7 @@ int runQmlmin(int argc, char *argv[])
const QString code = QString::fromUtf8(file.readAll()); // QML files are UTF-8 encoded.
file.close();
- QDeclarativeJS::Minify minify;
+ QQmlJS::Minify minify;
if (! minify(fileName, code)) {
std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << "' (not a valid QML/JS file)" << std::endl;
return EXIT_FAILURE;
@@ -580,13 +580,13 @@ int runQmlmin(int argc, char *argv[])
//
// verify the output
//
- QDeclarativeJS::Minify secondMinify;
+ QQmlJS::Minify secondMinify;
if (! secondMinify(fileName, minify.minifiedCode()) || secondMinify.minifiedCode() != minify.minifiedCode()) {
std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << "'" << std::endl;
return EXIT_FAILURE;
}
- QDeclarativeJS::Tokenize originalTokens, minimizedTokens;
+ QQmlJS::Tokenize originalTokens, minimizedTokens;
originalTokens(fileName, code);
minimizedTokens(fileName, minify.minifiedCode());
diff --git a/tools/qmlmin/qmlmin.pro b/tools/qmlmin/qmlmin.pro
index 67c7004c18..c57ec29d5b 100644
--- a/tools/qmlmin/qmlmin.pro
+++ b/tools/qmlmin/qmlmin.pro
@@ -1,7 +1,7 @@
QT = core qmldevtools-private
CONFIG += console
CONFIG -= app_bundle
-DESTDIR = $$QT.declarative.bins
+DESTDIR = $$QT.qml.bins
SOURCES += main.cpp
target.path = $$[QT_INSTALL_BINS]
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index ad8a3a6d64..cea29158f9 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -39,9 +39,9 @@
**
****************************************************************************/
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/private/qdeclarativemetatype_p.h>
-#include <QtDeclarative/private/qdeclarativeopenmetaobject_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/private/qqmlmetatype_p.h>
+#include <QtQml/private/qqmlopenmetaobject_p.h>
#include <QtQuick/private/qquickevents_p_p.h>
#include <QtQuick/private/qquickpincharea_p.h>
@@ -101,14 +101,14 @@ void collectReachableMetaObjects(QObject *object, QSet<const QMetaObject *> *met
for (int index = 0; index < meta->propertyCount(); ++index) {
QMetaProperty prop = meta->property(index);
- if (QDeclarativeMetaType::isQObject(prop.userType())) {
+ if (QQmlMetaType::isQObject(prop.userType())) {
if (verbose)
qDebug() << " Processing property" << prop.name();
currentProperty = QString("%1::%2").arg(meta->className(), prop.name());
// if the property was not initialized during construction,
// accessing a member of oo is going to cause a segmentation fault
- QObject *oo = QDeclarativeMetaType::toQObject(prop.read(object));
+ QObject *oo = QQmlMetaType::toQObject(prop.read(object));
if (oo && !metas->contains(oo->metaObject()))
collectReachableMetaObjects(oo, metas);
currentProperty.clear();
@@ -116,7 +116,7 @@ void collectReachableMetaObjects(QObject *object, QSet<const QMetaObject *> *met
}
}
-void collectReachableMetaObjects(const QDeclarativeType *ty, QSet<const QMetaObject *> *metas)
+void collectReachableMetaObjects(const QQmlType *ty, QSet<const QMetaObject *> *metas)
{
collectReachableMetaObjects(ty->metaObject(), metas, ty->isExtendedType());
if (ty->attachedPropertiesType())
@@ -133,10 +133,10 @@ public:
};
/* When we dump a QMetaObject, we want to list all the types it is exported as.
- To do this, we need to find the QDeclarativeTypes associated with this
+ To do this, we need to find the QQmlTypes associated with this
QMetaObject.
*/
-static QHash<QByteArray, QSet<const QDeclarativeType *> > qmlTypesByCppName;
+static QHash<QByteArray, QSet<const QQmlType *> > qmlTypesByCppName;
static QHash<QByteArray, QByteArray> cppToId;
@@ -187,13 +187,13 @@ public:
};
QList<ModuleApi> moduleApis;
-QSet<const QMetaObject *> collectReachableMetaObjects(QDeclarativeEngine *engine, const QList<QDeclarativeType *> &skip = QList<QDeclarativeType *>())
+QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine, const QList<QQmlType *> &skip = QList<QQmlType *>())
{
QSet<const QMetaObject *> metas;
metas.insert(FriendlyQObject::qtMeta());
QHash<QByteArray, QSet<QByteArray> > extensions;
- foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) {
+ foreach (const QQmlType *ty, QQmlMetaType::qmlTypes()) {
qmlTypesByCppName[ty->metaObject()->className()].insert(ty);
if (ty->isExtendedType()) {
extensions[ty->typeName()].insert(ty->metaObject()->className());
@@ -206,18 +206,18 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QDeclarativeEngine *engine
// Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export
// of QGraphicsWidget.
foreach (const QByteArray &baseCpp, extensions.keys()) {
- QSet<const QDeclarativeType *> baseExports = qmlTypesByCppName.value(baseCpp);
+ QSet<const QQmlType *> baseExports = qmlTypesByCppName.value(baseCpp);
const QSet<QByteArray> extensionCppNames = extensions.value(baseCpp);
foreach (const QByteArray &extensionCppName, extensionCppNames) {
- const QSet<const QDeclarativeType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
+ const QSet<const QQmlType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
// remove extension exports from base imports
- // unfortunately the QDeclarativeType pointers don't match, so can't use QSet::substract
- QSet<const QDeclarativeType *> newBaseExports;
- foreach (const QDeclarativeType *baseExport, baseExports) {
+ // unfortunately the QQmlType pointers don't match, so can't use QSet::substract
+ QSet<const QQmlType *> newBaseExports;
+ foreach (const QQmlType *baseExport, baseExports) {
bool match = false;
- foreach (const QDeclarativeType *extensionExport, extensionExports) {
+ foreach (const QQmlType *extensionExport, extensionExports) {
if (baseExport->qmlTypeName() == extensionExport->qmlTypeName()
&& baseExport->majorVersion() == extensionExport->majorVersion()
&& baseExport->minorVersion() == extensionExport->minorVersion()) {
@@ -235,14 +235,14 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QDeclarativeEngine *engine
// find even more QMetaObjects by instantiating QML types and running
// over the instances
- foreach (QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) {
+ foreach (QQmlType *ty, QQmlMetaType::qmlTypes()) {
if (skip.contains(ty))
continue;
if (ty->isExtendedType())
continue;
if (!ty->isCreatable())
continue;
- if (ty->typeName() == "QDeclarativeComponent")
+ if (ty->typeName() == "QQmlComponent")
continue;
QString tyName = ty->qmlTypeName();
@@ -261,10 +261,10 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QDeclarativeEngine *engine
}
// extract exported module api
- QHashIterator<QString, QList<QDeclarativeMetaType::ModuleApi> > moduleApiIt(QDeclarativeMetaType::moduleApis());
+ QHashIterator<QString, QList<QQmlMetaType::ModuleApi> > moduleApiIt(QQmlMetaType::moduleApis());
while (moduleApiIt.hasNext()) {
moduleApiIt.next();
- foreach (const QDeclarativeMetaType::ModuleApi &api, moduleApiIt.value()) {
+ foreach (const QQmlMetaType::ModuleApi &api, moduleApiIt.value()) {
ModuleApi moduleApi;
moduleApi.uri = moduleApiIt.key();
moduleApi.majorVersion = api.major;
@@ -322,11 +322,11 @@ public:
if (meta->superClass())
qml->writeScriptBinding(QLatin1String("prototype"), enquote(convertToId(meta->superClass())));
- QSet<const QDeclarativeType *> qmlTypes = qmlTypesByCppName.value(meta->className());
+ QSet<const QQmlType *> qmlTypes = qmlTypesByCppName.value(meta->className());
if (!qmlTypes.isEmpty()) {
- QHash<QString, const QDeclarativeType *> exports;
+ QHash<QString, const QQmlType *> exports;
- foreach (const QDeclarativeType *qmlTy, qmlTypes) {
+ foreach (const QQmlType *qmlTy, qmlTypes) {
QString qmlTyName = qmlTy->qmlTypeName();
if (qmlTyName.startsWith(relocatableModuleUri + QLatin1Char('/'))) {
qmlTyName.remove(0, relocatableModuleUri.size() + 1);
@@ -432,7 +432,7 @@ public:
{
qml->writeStartObject(QLatin1String("Component"));
qml->writeScriptBinding(QLatin1String("name"), enquote(QLatin1String("QEasingCurve")));
- qml->writeScriptBinding(QLatin1String("prototype"), enquote(QLatin1String("QDeclarativeEasingValueType")));
+ qml->writeScriptBinding(QLatin1String("prototype"), enquote(QLatin1String("QQmlEasingValueType")));
qml->writeEndObject();
}
@@ -447,7 +447,7 @@ private:
*/
static void removePointerAndList(QByteArray *typeName, bool *isList, bool *isPointer)
{
- static QByteArray declListPrefix = "QDeclarativeListProperty<";
+ static QByteArray declListPrefix = "QQmlListProperty<";
if (typeName->endsWith('*')) {
*isPointer = true;
@@ -670,7 +670,7 @@ int main(int argc, char *argv[])
}
}
- QDeclarativeEngine engine;
+ QQmlEngine engine;
if (!pluginImportPath.isEmpty()) {
QDir cur = QDir::current();
cur.cd(pluginImportPath);
@@ -682,11 +682,11 @@ int main(int argc, char *argv[])
// load the QtQuick 2 plugin
{
QByteArray code("import QtQuick 2.0\nQtObject {}");
- QDeclarativeComponent c(&engine);
+ QQmlComponent c(&engine);
c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/loadqtquick2.qml"));
c.create();
if (!c.errors().isEmpty()) {
- foreach (const QDeclarativeError &error, c.errors())
+ foreach (const QQmlError &error, c.errors())
qWarning() << error.toString();
return EXIT_IMPORTERROR;
}
@@ -694,7 +694,7 @@ int main(int argc, char *argv[])
// find all QMetaObjects reachable from the builtin module
QSet<const QMetaObject *> defaultReachable = collectReachableMetaObjects(&engine);
- QList<QDeclarativeType *> defaultTypes = QDeclarativeMetaType::qmlTypes();
+ QList<QQmlType *> defaultTypes = QQmlMetaType::qmlTypes();
// add some otherwise unreachable QMetaObjects
defaultReachable.insert(&QQuickMouseEvent::staticMetaObject);
@@ -708,7 +708,7 @@ int main(int argc, char *argv[])
} else {
// find a valid QtQuick import
QByteArray importCode;
- QDeclarativeType *qtObjectType = QDeclarativeMetaType::qmlType(&QObject::staticMetaObject);
+ QQmlType *qtObjectType = QQmlMetaType::qmlType(&QObject::staticMetaObject);
if (!qtObjectType) {
qWarning() << "Could not find QtObject type";
importCode = QByteArray("import QtQuick 2.0\n");
@@ -733,12 +733,12 @@ int main(int argc, char *argv[])
{
QByteArray code = importCode;
code += "QtObject {}";
- QDeclarativeComponent c(&engine);
+ QQmlComponent c(&engine);
c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/typelist.qml"));
c.create();
if (!c.errors().isEmpty()) {
- foreach (const QDeclarativeError &error, c.errors())
+ foreach (const QQmlError &error, c.errors())
qWarning() << error.toString();
return EXIT_IMPORTERROR;
}
@@ -761,7 +761,7 @@ int main(int argc, char *argv[])
// setup static rewrites of type names
cppToId.insert("QString", "string");
- cppToId.insert("QDeclarativeEasingValueType::Type", "Type");
+ cppToId.insert("QQmlEasingValueType::Type", "Type");
// start dumping data
QByteArray bytes;
@@ -787,7 +787,7 @@ int main(int argc, char *argv[])
dumper.dump(meta);
}
- // define QEasingCurve as an extension of QDeclarativeEasingValueType, this way
+ // define QEasingCurve as an extension of QQmlEasingValueType, this way
// properties using the QEasingCurve type get useful type information.
if (pluginImportUri.isEmpty())
dumper.writeEasingCurve();
diff --git a/tools/qmlplugindump/qmlplugindump.pro b/tools/qmlplugindump/qmlplugindump.pro
index e1c8485e27..7662fd79c8 100644
--- a/tools/qmlplugindump/qmlplugindump.pro
+++ b/tools/qmlplugindump/qmlplugindump.pro
@@ -1,8 +1,8 @@
TEMPLATE = app
CONFIG += qt uic console
-DESTDIR = $$QT.declarative.bins
+DESTDIR = $$QT.qml.bins
-QT += declarative declarative-private quick-private core-private
+QT += qml qml-private quick-private core-private
TARGET = qmlplugindump
diff --git a/tools/qmlprofiler/commandlistener.cpp b/tools/qmlprofiler/commandlistener.cpp
index cc969160d6..aa3659636d 100644
--- a/tools/qmlprofiler/commandlistener.cpp
+++ b/tools/qmlprofiler/commandlistener.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tools/qmlprofiler/commandlistener.h b/tools/qmlprofiler/commandlistener.h
index 77fd79362d..abe302cb8a 100644
--- a/tools/qmlprofiler/commandlistener.h
+++ b/tools/qmlprofiler/commandlistener.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tools/qmlprofiler/constants.h b/tools/qmlprofiler/constants.h
index 2e6acda275..e5a1f8025d 100644
--- a/tools/qmlprofiler/constants.h
+++ b/tools/qmlprofiler/constants.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tools/qmlprofiler/profileclient.cpp b/tools/qmlprofiler/profileclient.cpp
index 3e84569f2f..85287464cf 100644
--- a/tools/qmlprofiler/profileclient.cpp
+++ b/tools/qmlprofiler/profileclient.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -45,8 +45,8 @@
#include <QtCore/QStringList>
ProfileClient::ProfileClient(const QString &clientName,
- QDeclarativeDebugConnection *client)
- : QDeclarativeDebugClient(clientName, client),
+ QQmlDebugConnection *client)
+ : QQmlDebugClient(clientName, client),
m_recording(false),
m_enabled(false)
{
@@ -103,45 +103,45 @@ void ProfileClient::stateChanged(State status)
}
-class DeclarativeProfileClientPrivate
+class QmlProfileClientPrivate
{
public:
- DeclarativeProfileClientPrivate()
+ QmlProfileClientPrivate()
: inProgressRanges(0)
, maximumTime(0)
{
::memset(rangeCount, 0,
- QDeclarativeProfilerService::MaximumRangeType * sizeof(int));
+ QQmlProfilerService::MaximumRangeType * sizeof(int));
}
qint64 inProgressRanges;
- QStack<qint64> rangeStartTimes[QDeclarativeProfilerService::MaximumRangeType];
- QStack<QStringList> rangeDatas[QDeclarativeProfilerService::MaximumRangeType];
- QStack<EventLocation> rangeLocations[QDeclarativeProfilerService::MaximumRangeType];
- int rangeCount[QDeclarativeProfilerService::MaximumRangeType];
+ QStack<qint64> rangeStartTimes[QQmlProfilerService::MaximumRangeType];
+ QStack<QStringList> rangeDatas[QQmlProfilerService::MaximumRangeType];
+ QStack<EventLocation> rangeLocations[QQmlProfilerService::MaximumRangeType];
+ int rangeCount[QQmlProfilerService::MaximumRangeType];
qint64 maximumTime;
};
-DeclarativeProfileClient::DeclarativeProfileClient(
- QDeclarativeDebugConnection *client)
+QmlProfileClient::QmlProfileClient(
+ QQmlDebugConnection *client)
: ProfileClient(QLatin1String("CanvasFrameRate"), client),
- d(new DeclarativeProfileClientPrivate)
+ d(new QmlProfileClientPrivate)
{
}
-DeclarativeProfileClient::~DeclarativeProfileClient()
+QmlProfileClient::~QmlProfileClient()
{
delete d;
}
-void DeclarativeProfileClient::clearData()
+void QmlProfileClient::clearData()
{
::memset(d->rangeCount, 0,
- QDeclarativeProfilerService::MaximumRangeType * sizeof(int));
+ QQmlProfilerService::MaximumRangeType * sizeof(int));
ProfileClient::clearData();
}
-void DeclarativeProfileClient::sendRecordingStatus()
+void QmlProfileClient::sendRecordingStatus()
{
QByteArray ba;
QDataStream stream(&ba, QIODevice::WriteOnly);
@@ -149,7 +149,7 @@ void DeclarativeProfileClient::sendRecordingStatus()
sendMessage(ba);
}
-void DeclarativeProfileClient::messageReceived(const QByteArray &data)
+void QmlProfileClient::messageReceived(const QByteArray &data)
{
QByteArray rwData = data;
QDataStream stream(&rwData, QIODevice::ReadOnly);
@@ -159,43 +159,43 @@ void DeclarativeProfileClient::messageReceived(const QByteArray &data)
stream >> time >> messageType;
- if (messageType >= QDeclarativeProfilerService::MaximumMessage)
+ if (messageType >= QQmlProfilerService::MaximumMessage)
return;
- if (messageType == QDeclarativeProfilerService::Event) {
+ if (messageType == QQmlProfilerService::Event) {
int event;
stream >> event;
- if (event == QDeclarativeProfilerService::EndTrace) {
+ if (event == QQmlProfilerService::EndTrace) {
emit this->traceFinished(time);
d->maximumTime = time;
d->maximumTime = qMax(time, d->maximumTime);
- } else if (event == QDeclarativeProfilerService::AnimationFrame) {
+ } else if (event == QQmlProfilerService::AnimationFrame) {
int frameRate, animationCount;
stream >> frameRate >> animationCount;
emit this->frame(time, frameRate, animationCount);
d->maximumTime = qMax(time, d->maximumTime);
- } else if (event == QDeclarativeProfilerService::StartTrace) {
+ } else if (event == QQmlProfilerService::StartTrace) {
emit this->traceStarted(time);
d->maximumTime = time;
- } else if (event < QDeclarativeProfilerService::MaximumEventType) {
+ } else if (event < QQmlProfilerService::MaximumEventType) {
d->maximumTime = qMax(time, d->maximumTime);
}
- } else if (messageType == QDeclarativeProfilerService::Complete) {
+ } else if (messageType == QQmlProfilerService::Complete) {
emit complete();
} else {
int range;
stream >> range;
- if (range >= QDeclarativeProfilerService::MaximumRangeType)
+ if (range >= QQmlProfilerService::MaximumRangeType)
return;
- if (messageType == QDeclarativeProfilerService::RangeStart) {
+ if (messageType == QQmlProfilerService::RangeStart) {
d->rangeStartTimes[range].push(time);
d->inProgressRanges |= (static_cast<qint64>(1) << range);
++d->rangeCount[range];
- } else if (messageType == QDeclarativeProfilerService::RangeData) {
+ } else if (messageType == QQmlProfilerService::RangeData) {
QString data;
stream >> data;
@@ -206,7 +206,7 @@ void DeclarativeProfileClient::messageReceived(const QByteArray &data)
d->rangeDatas[range][count-1] << data;
}
- } else if (messageType == QDeclarativeProfilerService::RangeLocation) {
+ } else if (messageType == QQmlProfilerService::RangeLocation) {
QString fileName;
int line;
int column = -1;
@@ -232,7 +232,7 @@ void DeclarativeProfileClient::messageReceived(const QByteArray &data)
d->rangeLocations[range].pop() : EventLocation();
qint64 startTime = d->rangeStartTimes[range].pop();
- emit this->range((QDeclarativeProfilerService::RangeType)range,
+ emit this->range((QQmlProfilerService::RangeType)range,
startTime, time - startTime, data, location);
if (d->rangeCount[range] == 0) {
int count = d->rangeDatas[range].count() +
@@ -246,7 +246,7 @@ void DeclarativeProfileClient::messageReceived(const QByteArray &data)
}
}
-V8ProfileClient::V8ProfileClient(QDeclarativeDebugConnection *client)
+V8ProfileClient::V8ProfileClient(QQmlDebugConnection *client)
: ProfileClient(QLatin1String("V8Profiler"), client)
{
}
diff --git a/tools/qmlprofiler/profileclient.h b/tools/qmlprofiler/profileclient.h
index 87e9dbc508..8aa4e67982 100644
--- a/tools/qmlprofiler/profileclient.h
+++ b/tools/qmlprofiler/profileclient.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -44,11 +44,11 @@
#include "profiledata.h"
-#include <QtDeclarative/private/qdeclarativedebugclient_p.h>
-#include <QtDeclarative/private/qdeclarativeprofilerservice_p.h>
+#include <QtQml/private/qqmldebugclient_p.h>
+#include <QtQml/private/qqmlprofilerservice_p.h>
class ProfileClientPrivate;
-class ProfileClient : public QDeclarativeDebugClient
+class ProfileClient : public QQmlDebugClient
{
Q_OBJECT
@@ -58,7 +58,7 @@ class ProfileClient : public QDeclarativeDebugClient
public:
ProfileClient(const QString & clientName,
- QDeclarativeDebugConnection *client);
+ QQmlDebugConnection *client);
~ProfileClient();
bool isEnabled() const;
@@ -83,13 +83,13 @@ protected:
bool m_enabled;
};
-class DeclarativeProfileClient : public ProfileClient
+class QmlProfileClient : public ProfileClient
{
Q_OBJECT
public:
- DeclarativeProfileClient(QDeclarativeDebugConnection *client);
- ~DeclarativeProfileClient();
+ QmlProfileClient(QQmlDebugConnection *client);
+ ~QmlProfileClient();
public slots:
void clearData();
@@ -98,7 +98,7 @@ public slots:
signals:
void traceFinished( qint64 time );
void traceStarted( qint64 time );
- void range(QDeclarativeProfilerService::RangeType type, qint64 startTime,
+ void range(QQmlProfilerService::RangeType type, qint64 startTime,
qint64 length, const QStringList &data,
const EventLocation &location);
void frame(qint64 time, int frameRate, int animationCount);
@@ -107,7 +107,7 @@ protected:
virtual void messageReceived(const QByteArray &);
private:
- class DeclarativeProfileClientPrivate *d;
+ class QmlProfileClientPrivate *d;
};
class V8ProfileClient : public ProfileClient
@@ -122,7 +122,7 @@ public:
V8MaximumMessage
};
- V8ProfileClient(QDeclarativeDebugConnection *client);
+ V8ProfileClient(QQmlDebugConnection *client);
~V8ProfileClient();
public slots:
diff --git a/tools/qmlprofiler/profiledata.cpp b/tools/qmlprofiler/profiledata.cpp
index 19c282b97c..6082f4aa94 100644
--- a/tools/qmlprofiler/profiledata.cpp
+++ b/tools/qmlprofiler/profiledata.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -50,9 +50,9 @@
using namespace Constants;
-DeclarativeEvent::DeclarativeEvent()
+QmlEvent::QmlEvent()
{
- eventType = QDeclarativeProfilerService::MaximumRangeType;
+ eventType = QQmlProfilerService::MaximumRangeType;
eventId = -1;
duration = 0;
calls = 0;
@@ -64,7 +64,7 @@ DeclarativeEvent::DeclarativeEvent()
isBindingLoop = false;
}
-DeclarativeEvent::~DeclarativeEvent()
+QmlEvent::~QmlEvent()
{
qDeleteAll(parentHash.values());
parentHash.clear();
@@ -72,7 +72,7 @@ DeclarativeEvent::~DeclarativeEvent()
childrenHash.clear();
}
-DeclarativeEvent &DeclarativeEvent::operator=(const DeclarativeEvent &ref)
+QmlEvent &QmlEvent::operator=(const QmlEvent &ref)
{
if (this == &ref)
return *this;
@@ -96,14 +96,14 @@ DeclarativeEvent &DeclarativeEvent::operator=(const DeclarativeEvent &ref)
parentHash.clear();
foreach (const QString &key, ref.parentHash.keys()) {
parentHash.insert(key,
- new DeclarativeEventSub(ref.parentHash.value(key)));
+ new QmlEventSub(ref.parentHash.value(key)));
}
qDeleteAll(childrenHash.values());
childrenHash.clear();
foreach (const QString &key, ref.childrenHash.keys()) {
childrenHash.insert(key,
- new DeclarativeEventSub(ref.childrenHash.value(key)));
+ new QmlEventSub(ref.childrenHash.value(key)));
}
return *this;
@@ -157,21 +157,21 @@ V8Event &V8Event::operator=(const V8Event &ref)
}
// endtimedata
-struct DeclarativeEventEndTime {
+struct QmlEventEndTime {
qint64 endTime;
int startTimeIndex;
- DeclarativeEvent *description;
+ QmlEvent *description;
};
// starttimedata
-struct DeclarativeEventStartTime{
+struct QmlEventStartTime{
qint64 startTime;
qint64 length;
qint64 level;
int endTimeIndex;
qint64 nestingLevel;
qint64 nestingDepth;
- DeclarativeEvent *description;
+ QmlEvent *description;
// animation-related data
int frameRate;
@@ -180,46 +180,46 @@ struct DeclarativeEventStartTime{
int bindingLoopHead;
};
-struct DeclarativeEventTypeCount {
+struct QmlEventTypeCount {
QList <int> eventIds;
int nestingCount;
};
// used by quicksort
-bool compareEndTimes(const DeclarativeEventEndTime &t1,
- const DeclarativeEventEndTime &t2)
+bool compareEndTimes(const QmlEventEndTime &t1,
+ const QmlEventEndTime &t2)
{
return t1.endTime < t2.endTime;
}
-bool compareStartTimes(const DeclarativeEventStartTime &t1,
- const DeclarativeEventStartTime &t2)
+bool compareStartTimes(const QmlEventStartTime &t1,
+ const QmlEventStartTime &t2)
{
return t1.startTime < t2.startTime;
}
-bool compareStartIndexes(const DeclarativeEventEndTime &t1,
- const DeclarativeEventEndTime &t2)
+bool compareStartIndexes(const QmlEventEndTime &t1,
+ const QmlEventEndTime &t2)
{
return t1.startTimeIndex < t2.startTimeIndex;
}
-QString declarativeEventType(QDeclarativeProfilerService::RangeType typeEnum)
+QString qmlEventType(QQmlProfilerService::RangeType typeEnum)
{
switch (typeEnum) {
- case QDeclarativeProfilerService::Painting:
+ case QQmlProfilerService::Painting:
return QLatin1String(TYPE_PAINTING_STR);
break;
- case QDeclarativeProfilerService::Compiling:
+ case QQmlProfilerService::Compiling:
return QLatin1String(TYPE_COMPILING_STR);
break;
- case QDeclarativeProfilerService::Creating:
+ case QQmlProfilerService::Creating:
return QLatin1String(TYPE_CREATING_STR);
break;
- case QDeclarativeProfilerService::Binding:
+ case QQmlProfilerService::Binding:
return QLatin1String(TYPE_BINDING_STR);
break;
- case QDeclarativeProfilerService::HandlingSignal:
+ case QQmlProfilerService::HandlingSignal:
return QLatin1String(TYPE_HANDLINGSIGNAL_STR);
break;
default:
@@ -227,32 +227,32 @@ QString declarativeEventType(QDeclarativeProfilerService::RangeType typeEnum)
}
}
-QDeclarativeProfilerService::RangeType declarativeEventType(const QString &typeString)
+QQmlProfilerService::RangeType qmlEventType(const QString &typeString)
{
if (typeString == QLatin1String(TYPE_PAINTING_STR)) {
- return QDeclarativeProfilerService::Painting;
+ return QQmlProfilerService::Painting;
} else if (typeString == QLatin1String(TYPE_COMPILING_STR)) {
- return QDeclarativeProfilerService::Compiling;
+ return QQmlProfilerService::Compiling;
} else if (typeString == QLatin1String(TYPE_CREATING_STR)) {
- return QDeclarativeProfilerService::Creating;
+ return QQmlProfilerService::Creating;
} else if (typeString == QLatin1String(TYPE_BINDING_STR)) {
- return QDeclarativeProfilerService::Binding;
+ return QQmlProfilerService::Binding;
} else if (typeString == QLatin1String(TYPE_HANDLINGSIGNAL_STR)) {
- return QDeclarativeProfilerService::HandlingSignal;
+ return QQmlProfilerService::HandlingSignal;
} else {
bool isNumber = false;
int type = typeString.toUInt(&isNumber);
if (isNumber) {
- return (QDeclarativeProfilerService::RangeType)type;
+ return (QQmlProfilerService::RangeType)type;
} else {
- return QDeclarativeProfilerService::MaximumRangeType;
+ return QQmlProfilerService::MaximumRangeType;
}
}
}
-QString getHashStringForDeclarativeEvent(
+QString getHashStringForQmlEvent(
EventLocation location,
- QDeclarativeProfilerService::RangeType eventType)
+ QQmlProfilerService::RangeType eventType)
{
return QString("%1:%2:%3:%4").arg(location.filename,
QString::number(location.line),
@@ -265,31 +265,31 @@ class ProfileDataPrivate
public:
// convenience functions
- void clearDeclarativeRootEvent();
+ void clearQmlRootEvent();
void clearV8RootEvent();
// Stored data
- DeclarativeEventHash m_eventDescriptions;
- QList<DeclarativeEventEndTime> m_endTimeSortedList;
- QList<DeclarativeEventStartTime> m_startTimeSortedList;
+ QmlEventHash m_eventDescriptions;
+ QList<QmlEventEndTime> m_endTimeSortedList;
+ QList<QmlEventStartTime> m_startTimeSortedList;
void collectV8Statistics();
V8Events m_v8EventList;
QHash<int, V8Event *> m_v8parents;
- DeclarativeEvent m_qmlRootEvent;
+ QmlEvent m_qmlRootEvent;
V8Event m_v8RootEvent;
QString m_rootEventName;
QString m_rootEventDesc;
- QHash<int, DeclarativeEventTypeCount *> m_typeCounts;
+ QHash<int, QmlEventTypeCount *> m_typeCounts;
qint64 m_traceEndTime;
qint64 m_traceStartTime;
qint64 m_qmlMeasuredTime;
qint64 m_v8MeasuredTime;
- DeclarativeEventStartTime *m_lastFrameEvent;
+ QmlEventStartTime *m_lastFrameEvent;
qint64 m_maximumAnimationCount;
qint64 m_minimumAnimationCount;
@@ -309,7 +309,7 @@ ProfileData::ProfileData(QObject *parent) :
d->m_v8MeasuredTime = 0;
d->m_rootEventName = tr("<program>");
d->m_rootEventDesc = tr("Main Program");
- d->clearDeclarativeRootEvent();
+ d->clearQmlRootEvent();
d->clearV8RootEvent();
d->m_lastFrameEvent = 0;
d->m_maximumAnimationCount = 0;
@@ -334,10 +334,10 @@ void ProfileData::clear()
d->m_v8parents.clear();
- d->clearDeclarativeRootEvent();
+ d->clearQmlRootEvent();
d->clearV8RootEvent();
- foreach (DeclarativeEventTypeCount *typeCount, d->m_typeCounts.values())
+ foreach (QmlEventTypeCount *typeCount, d->m_typeCounts.values())
delete typeCount;
d->m_typeCounts.clear();
@@ -354,14 +354,14 @@ void ProfileData::clear()
emit dataClear();
}
-DeclarativeEvents ProfileData::getDeclarativeEvents() const
+QmlEvents ProfileData::getQmlEvents() const
{
return d->m_eventDescriptions.values();
}
-DeclarativeEvent *ProfileData::declarativeEvent(int eventId) const
+QmlEvent *ProfileData::qmlEvent(int eventId) const
{
- foreach (DeclarativeEvent *event, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *event, d->m_eventDescriptions.values()) {
if (event->eventId == eventId)
return event;
}
@@ -382,8 +382,8 @@ const V8Events& ProfileData::getV8Events() const
return d->m_v8EventList;
}
-void ProfileData::addDeclarativeEvent(
- QDeclarativeProfilerService::RangeType type, qint64 startTime, qint64 length,
+void ProfileData::addQmlEvent(
+ QQmlProfilerService::RangeType type, qint64 startTime, qint64 length,
const QStringList &data, const EventLocation &location)
{
const QChar colon = QLatin1Char(':');
@@ -408,7 +408,7 @@ void ProfileData::addDeclarativeEvent(
// backwards compatibility: "compiling" events don't have a proper location in older
// version of the protocol, but the filename is passed in the details string
- if (type == QDeclarativeProfilerService::Compiling && eventLocation.filename.isEmpty()) {
+ if (type == QQmlProfilerService::Compiling && eventLocation.filename.isEmpty()) {
eventLocation.filename = details;
eventLocation.line = 1;
eventLocation.column = 1;
@@ -417,18 +417,18 @@ void ProfileData::addDeclarativeEvent(
// generate hash
if (eventLocation.filename.isEmpty()) {
displayName = tr("<bytecode>");
- eventHashStr = getHashStringForDeclarativeEvent(eventLocation, type);
+ eventHashStr = getHashStringForQmlEvent(eventLocation, type);
} else {
const QString filePath = QUrl(eventLocation.filename).path();
displayName = filePath.mid(filePath.lastIndexOf(QChar('/')) + 1) + colon + QString::number(eventLocation.line);
- eventHashStr = getHashStringForDeclarativeEvent(eventLocation, type);
+ eventHashStr = getHashStringForQmlEvent(eventLocation, type);
}
- DeclarativeEvent *newEvent;
+ QmlEvent *newEvent;
if (d->m_eventDescriptions.contains(eventHashStr)) {
newEvent = d->m_eventDescriptions[eventHashStr];
} else {
- newEvent = new DeclarativeEvent;
+ newEvent = new QmlEvent;
newEvent->displayname = displayName;
newEvent->location = eventLocation;
newEvent->eventHashStr = eventHashStr;
@@ -437,12 +437,12 @@ void ProfileData::addDeclarativeEvent(
d->m_eventDescriptions.insert(eventHashStr, newEvent);
}
- DeclarativeEventEndTime endTimeData;
+ QmlEventEndTime endTimeData;
endTimeData.endTime = startTime + length;
endTimeData.description = newEvent;
endTimeData.startTimeIndex = d->m_startTimeSortedList.count();
- DeclarativeEventStartTime startTimeData;
+ QmlEventStartTime startTimeData;
startTimeData.startTime = startTime;
startTimeData.length = length;
startTimeData.description = newEvent;
@@ -537,14 +537,14 @@ void ProfileData::addFrameEvent(qint64 time, int framerate, int animationcount)
displayName = tr("<Animation Update>");
eventHashStr = displayName;
- DeclarativeEvent *newEvent;
+ QmlEvent *newEvent;
if (d->m_eventDescriptions.contains(eventHashStr)) {
newEvent = d->m_eventDescriptions[eventHashStr];
} else {
- newEvent = new DeclarativeEvent;
+ newEvent = new QmlEvent;
newEvent->displayname = displayName;
newEvent->eventHashStr = eventHashStr;
- newEvent->eventType = QDeclarativeProfilerService::Painting;
+ newEvent->eventType = QQmlProfilerService::Painting;
newEvent->details = details;
d->m_eventDescriptions.insert(eventHashStr, newEvent);
}
@@ -558,12 +558,12 @@ void ProfileData::addFrameEvent(qint64 time, int framerate, int animationcount)
d->m_lastFrameEvent->startTime + d->m_lastFrameEvent->length;
}
- DeclarativeEventEndTime endTimeData;
+ QmlEventEndTime endTimeData;
endTimeData.endTime = time + length;
endTimeData.description = newEvent;
endTimeData.startTimeIndex = d->m_startTimeSortedList.count();
- DeclarativeEventStartTime startTimeData;
+ QmlEventStartTime startTimeData;
startTimeData.startTime = time;
startTimeData.length = length;
startTimeData.description = newEvent;
@@ -645,13 +645,13 @@ void ProfileData::complete()
postProcess();
}
-void ProfileDataPrivate::clearDeclarativeRootEvent()
+void ProfileDataPrivate::clearQmlRootEvent()
{
m_qmlRootEvent.displayname = m_rootEventName;
m_qmlRootEvent.location = EventLocation();
m_qmlRootEvent.eventHashStr = m_rootEventName;
m_qmlRootEvent.details = m_rootEventDesc;
- m_qmlRootEvent.eventType = QDeclarativeProfilerService::Binding;
+ m_qmlRootEvent.eventType = QQmlProfilerService::Binding;
m_qmlRootEvent.duration = 0;
m_qmlRootEvent.calls = 0;
m_qmlRootEvent.minTime = 0;
@@ -692,7 +692,7 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
double totalTime = 0;
// clear existing statistics
- foreach (DeclarativeEvent *eventDescription,
+ foreach (QmlEvent *eventDescription,
d->m_eventDescriptions.values()) {
eventDescription->calls = 0;
// maximum possible value
@@ -707,12 +707,12 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
}
// create root event for statistics
- d->clearDeclarativeRootEvent();
+ d->clearQmlRootEvent();
// compute parent-child relationship and call count
- QHash<int, DeclarativeEvent*> lastParent;
+ QHash<int, QmlEvent*> lastParent;
for (index = fromIndex; index <= toIndex; index++) {
- DeclarativeEvent *eventDescription =
+ QmlEvent *eventDescription =
d->m_startTimeSortedList[index].description;
if (d->m_startTimeSortedList[index].startTime > endTime ||
@@ -721,7 +721,7 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
continue;
}
- if (eventDescription->eventType == QDeclarativeProfilerService::Painting) {
+ if (eventDescription->eventType == QQmlProfilerService::Painting) {
// skip animation/paint events
continue;
}
@@ -736,36 +736,36 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
int level = d->m_startTimeSortedList[index].level;
- DeclarativeEvent *parentEvent = &d->m_qmlRootEvent;
+ QmlEvent *parentEvent = &d->m_qmlRootEvent;
if (level > MIN_LEVEL && lastParent.contains(level-1)) {
parentEvent = lastParent[level-1];
}
if (!eventDescription->parentHash.contains(parentEvent->eventHashStr)) {
- DeclarativeEventSub *newParentEvent =
- new DeclarativeEventSub(parentEvent);
+ QmlEventSub *newParentEvent =
+ new QmlEventSub(parentEvent);
newParentEvent->calls = 1;
newParentEvent->duration = duration;
eventDescription->parentHash.insert(parentEvent->eventHashStr,
newParentEvent);
} else {
- DeclarativeEventSub *newParentEvent =
+ QmlEventSub *newParentEvent =
eventDescription->parentHash.value(parentEvent->eventHashStr);
newParentEvent->duration += duration;
newParentEvent->calls++;
}
if (!parentEvent->childrenHash.contains(eventDescription->eventHashStr)) {
- DeclarativeEventSub *newChildEvent =
- new DeclarativeEventSub(eventDescription);
+ QmlEventSub *newChildEvent =
+ new QmlEventSub(eventDescription);
newChildEvent->calls = 1;
newChildEvent->duration = duration;
parentEvent->childrenHash.insert(eventDescription->eventHashStr,
newChildEvent);
} else {
- DeclarativeEventSub *newChildEvent =
+ QmlEventSub *newChildEvent =
parentEvent->childrenHash.value(eventDescription->eventHashStr);
newChildEvent->duration += duration;
newChildEvent->calls++;
@@ -788,29 +788,29 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
d->m_qmlRootEvent.calls = 1;
// insert into list
- DeclarativeEvent *listedRootEvent =
+ QmlEvent *listedRootEvent =
d->m_eventDescriptions.value(d->m_rootEventName);
if (!listedRootEvent) {
- listedRootEvent = new DeclarativeEvent;
+ listedRootEvent = new QmlEvent;
d->m_eventDescriptions.insert(d->m_rootEventName, listedRootEvent);
}
*listedRootEvent = d->m_qmlRootEvent;
// compute percentages
- foreach (DeclarativeEvent *binding, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *binding, d->m_eventDescriptions.values()) {
binding->percentOfTime = binding->duration * 100.0 / totalTime;
binding->timePerCall = binding->calls > 0 ?
double(binding->duration) / binding->calls : 0;
}
// compute median time
- QHash < DeclarativeEvent* , QList<qint64> > durationLists;
+ QHash < QmlEvent* , QList<qint64> > durationLists;
for (index = fromIndex; index <= toIndex; index++) {
- DeclarativeEvent *desc = d->m_startTimeSortedList[index].description;
+ QmlEvent *desc = d->m_startTimeSortedList[index].description;
qint64 len = d->m_startTimeSortedList[index].length;
durationLists[desc].append(len);
}
- QMutableHashIterator < DeclarativeEvent* , QList<qint64> > iter(durationLists);
+ QMutableHashIterator < QmlEvent* , QList<qint64> > iter(durationLists);
while (iter.hasNext()) {
iter.next();
if (!iter.value().isEmpty()) {
@@ -824,16 +824,16 @@ void ProfileData::prepareForDisplay()
{
// generate numeric ids
int ndx = 0;
- foreach (DeclarativeEvent *binding, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *binding, d->m_eventDescriptions.values()) {
binding->eventId = ndx++;
}
// collect type counts
- foreach (const DeclarativeEventStartTime &eventStartData,
+ foreach (const QmlEventStartTime &eventStartData,
d->m_startTimeSortedList) {
int typeNumber = eventStartData.description->eventType;
if (!d->m_typeCounts.contains(typeNumber)) {
- d->m_typeCounts[typeNumber] = new DeclarativeEventTypeCount;
+ d->m_typeCounts[typeNumber] = new QmlEventTypeCount;
d->m_typeCounts[typeNumber]->nestingCount = 0;
}
if (eventStartData.nestingLevel >
@@ -853,9 +853,9 @@ void ProfileData::sortStartTimes()
// assuming startTimes is partially sorted
// identify blocks of events and sort them with quicksort
- QList<DeclarativeEventStartTime>::iterator itFrom =
+ QList<QmlEventStartTime>::iterator itFrom =
d->m_startTimeSortedList.end() - 2;
- QList<DeclarativeEventStartTime>::iterator itTo =
+ QList<QmlEventStartTime>::iterator itTo =
d->m_startTimeSortedList.end() - 1;
while (itFrom != d->m_startTimeSortedList.begin() &&
@@ -899,9 +899,9 @@ void ProfileData::sortEndTimes()
if (d->m_endTimeSortedList.count() < 2)
return;
- QList<DeclarativeEventEndTime>::iterator itFrom =
+ QList<QmlEventEndTime>::iterator itFrom =
d->m_endTimeSortedList.begin();
- QList<DeclarativeEventEndTime>::iterator itTo =
+ QList<QmlEventEndTime>::iterator itTo =
d->m_endTimeSortedList.begin() + 1;
while (itTo != d->m_endTimeSortedList.end() &&
@@ -948,7 +948,7 @@ void ProfileData::findAnimationLimits()
for (int i = 0; i < d->m_startTimeSortedList.count(); i++) {
if (d->m_startTimeSortedList[i].description->eventType ==
- QDeclarativeProfilerService::Painting &&
+ QQmlProfilerService::Painting &&
d->m_startTimeSortedList[i].animationCount >= 0) {
int animationcount = d->m_startTimeSortedList[i].animationCount;
if (d->m_lastFrameEvent) {
@@ -974,7 +974,7 @@ void ProfileData::computeNestingLevels()
int level = MIN_LEVEL;
endtimesPerLevel[MIN_LEVEL] = 0;
- for (int i = 0; i < QDeclarativeProfilerService::MaximumRangeType; i++) {
+ for (int i = 0; i < QQmlProfilerService::MaximumRangeType; i++) {
nestingLevels << MIN_LEVEL;
QHash <int, qint64> dummyHash;
dummyHash[MIN_LEVEL] = 0;
@@ -985,7 +985,7 @@ void ProfileData::computeNestingLevels()
qint64 st = d->m_startTimeSortedList[i].startTime;
int type = d->m_startTimeSortedList[i].description->eventType;
- if (type == QDeclarativeProfilerService::Painting) {
+ if (type == QQmlProfilerService::Painting) {
// animation/paint events have level 1 by definition,
// but are not considered parents of other events for
// statistical purposes
@@ -1074,9 +1074,9 @@ void ProfileData::computeLevels()
void ProfileData::reloadDetails()
{
// request binding/signal details from the AST
- foreach (DeclarativeEvent *event, d->m_eventDescriptions.values()) {
- if (event->eventType != QDeclarativeProfilerService::Binding &&
- event->eventType != QDeclarativeProfilerService::HandlingSignal)
+ foreach (QmlEvent *event, d->m_eventDescriptions.values()) {
+ if (event->eventType != QQmlProfilerService::Binding &&
+ event->eventType != QQmlProfilerService::HandlingSignal)
continue;
// This skips anonymous bindings in Qt4.8 (we don't have valid location data for them)
@@ -1095,22 +1095,22 @@ void ProfileData::reloadDetails()
void ProfileData::findBindingLoops(qint64 startTime, qint64 endTime)
{
// first clear existing data
- foreach (DeclarativeEvent *event, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *event, d->m_eventDescriptions.values()) {
event->isBindingLoop = false;
- foreach (DeclarativeEventSub *parentEvent, event->parentHash.values())
+ foreach (QmlEventSub *parentEvent, event->parentHash.values())
parentEvent->inLoopPath = false;
- foreach (DeclarativeEventSub *childEvent, event->childrenHash.values())
+ foreach (QmlEventSub *childEvent, event->childrenHash.values())
childEvent->inLoopPath = false;
}
- QList <DeclarativeEvent *> stackRefs;
- QList <DeclarativeEventStartTime *> stack;
+ QList <QmlEvent *> stackRefs;
+ QList <QmlEventStartTime *> stack;
int fromIndex = findFirstIndex(startTime);
int toIndex = findLastIndex(endTime);
for (int i = 0; i < d->m_startTimeSortedList.count(); i++) {
- DeclarativeEvent *currentEvent = d->m_startTimeSortedList[i].description;
- DeclarativeEventStartTime *inTimeEvent = &d->m_startTimeSortedList[i];
+ QmlEvent *currentEvent = d->m_startTimeSortedList[i].description;
+ QmlEventStartTime *inTimeEvent = &d->m_startTimeSortedList[i];
inTimeEvent->bindingLoopHead = -1;
// managing call stack
@@ -1130,15 +1130,15 @@ void ProfileData::findBindingLoops(qint64 startTime, qint64 endTime)
// for the statistics
currentEvent->isBindingLoop = true;
for (int j = stackRefs.indexOf(currentEvent); j < stackRefs.count()-1; j++) {
- DeclarativeEventSub *nextEventSub = stackRefs[j]->childrenHash.value(stackRefs[j+1]->eventHashStr);
+ QmlEventSub *nextEventSub = stackRefs[j]->childrenHash.value(stackRefs[j+1]->eventHashStr);
nextEventSub->inLoopPath = true;
- DeclarativeEventSub *prevEventSub = stackRefs[j+1]->parentHash.value(stackRefs[j]->eventHashStr);
+ QmlEventSub *prevEventSub = stackRefs[j+1]->parentHash.value(stackRefs[j]->eventHashStr);
prevEventSub->inLoopPath = true;
}
}
// use crossed references to find index in starttimesortedlist
- DeclarativeEventStartTime *head = stack[stackRefs.indexOf(currentEvent)];
+ QmlEventStartTime *head = stack[stackRefs.indexOf(currentEvent)];
inTimeEvent->bindingLoopHead = d->m_endTimeSortedList[head->endTimeIndex].startTimeIndex;
d->m_startTimeSortedList[inTimeEvent->bindingLoopHead].bindingLoopHead = i;
}
@@ -1146,10 +1146,10 @@ void ProfileData::findBindingLoops(qint64 startTime, qint64 endTime)
}
void ProfileData::rewriteDetailsString(
- QDeclarativeProfilerService::RangeType eventType,
+ QQmlProfilerService::RangeType eventType,
const EventLocation &location, const QString &newString)
{
- QString eventHashStr = getHashStringForDeclarativeEvent(location,
+ QString eventHashStr = getHashStringForQmlEvent(location,
eventType);
Q_ASSERT(d->m_eventDescriptions.contains(eventHashStr));
d->m_eventDescriptions.value(eventHashStr)->details = newString;
@@ -1293,7 +1293,7 @@ qint64 ProfileData::traceDuration() const
return traceEndTime() - traceStartTime();
}
-qint64 ProfileData::declarativeMeasuredTime() const
+qint64 ProfileData::qmlMeasuredTime() const
{
return d->m_qmlMeasuredTime;
}
@@ -1336,14 +1336,14 @@ bool ProfileData::save(const QString &filename)
stream.writeStartElement("eventData");
stream.writeAttribute("totalTime", QString::number(d->m_qmlMeasuredTime));
- foreach (const DeclarativeEvent *eventData, d->m_eventDescriptions.values()) {
+ foreach (const QmlEvent *eventData, d->m_eventDescriptions.values()) {
stream.writeStartElement("event");
stream.writeAttribute("index",
QString::number(
d->m_eventDescriptions.keys().indexOf(
eventData->eventHashStr)));
stream.writeTextElement("displayname", eventData->displayname);
- stream.writeTextElement("type", declarativeEventType(eventData->eventType));
+ stream.writeTextElement("type", qmlEventType(eventData->eventType));
if (!eventData->location.filename.isEmpty()) {
stream.writeTextElement("filename", eventData->location.filename);
stream.writeTextElement("line",
@@ -1357,7 +1357,7 @@ bool ProfileData::save(const QString &filename)
stream.writeEndElement(); // eventData
stream.writeStartElement("eventList");
- foreach (const DeclarativeEventStartTime &rangedEvent,
+ foreach (const QmlEventStartTime &rangedEvent,
d->m_startTimeSortedList) {
stream.writeStartElement("range");
stream.writeAttribute("startTime", QString::number(rangedEvent.startTime));
@@ -1366,7 +1366,7 @@ bool ProfileData::save(const QString &filename)
QString::number(d->m_eventDescriptions.keys().indexOf(
rangedEvent.description->eventHashStr)));
if (rangedEvent.description->eventType ==
- QDeclarativeProfilerService::Painting && rangedEvent.animationCount >= 0) {
+ QQmlProfilerService::Painting && rangedEvent.animationCount >= 0) {
// animation frame
stream.writeAttribute("framerate",
QString::number(rangedEvent.frameRate));
@@ -1453,8 +1453,8 @@ void ProfileData::load()
bool readingQmlEvents = false;
bool readingV8Events = false;
- QHash <int, DeclarativeEvent *> descriptionBuffer;
- DeclarativeEvent *currentEvent = 0;
+ QHash <int, QmlEvent *> descriptionBuffer;
+ QmlEvent *currentEvent = 0;
QHash <int, V8Event *> v8eventBuffer;
QHash <int, QString> childrenIndexes;
QHash <int, QString> childrenTimes;
@@ -1519,7 +1519,7 @@ void ProfileData::load()
}
if (elementName == "range") {
- DeclarativeEventStartTime rangedEvent;
+ QmlEventStartTime rangedEvent;
QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("startTime"))
rangedEvent.startTime = attributes.value("startTime").
@@ -1538,7 +1538,7 @@ void ProfileData::load()
if (attributes.hasAttribute("eventIndex")) {
int ndx = attributes.value("eventIndex").toString().toInt();
if (!descriptionBuffer.value(ndx))
- descriptionBuffer[ndx] = new DeclarativeEvent;
+ descriptionBuffer[ndx] = new QmlEvent;
rangedEvent.description = descriptionBuffer.value(ndx);
}
rangedEvent.endTimeIndex = d->m_endTimeSortedList.length();
@@ -1549,7 +1549,7 @@ void ProfileData::load()
startTimesAreSorted = false;
d->m_startTimeSortedList << rangedEvent;
- DeclarativeEventEndTime endTimeEvent;
+ QmlEventEndTime endTimeEvent;
endTimeEvent.endTime = rangedEvent.startTime + rangedEvent.length;
endTimeEvent.startTimeIndex = d->m_startTimeSortedList.length()-1;
endTimeEvent.description = rangedEvent.description;
@@ -1563,7 +1563,7 @@ void ProfileData::load()
if (attributes.hasAttribute("index")) {
int ndx = attributes.value("index").toString().toInt();
if (!descriptionBuffer.value(ndx))
- descriptionBuffer[ndx] = new DeclarativeEvent;
+ descriptionBuffer[ndx] = new QmlEvent;
currentEvent = descriptionBuffer[ndx];
} else {
currentEvent = 0;
@@ -1585,7 +1585,7 @@ void ProfileData::load()
break;
}
if (elementName == "type") {
- currentEvent->eventType = declarativeEventType(readData);
+ currentEvent->eventType = qmlEventType(readData);
break;
}
if (elementName == "filename") {
@@ -1720,8 +1720,8 @@ void ProfileData::load()
d->m_v8MeasuredTime = cumulatedV8Time;
// move the buffered data to the details cache
- foreach (DeclarativeEvent *desc, descriptionBuffer.values()) {
- desc->eventHashStr = getHashStringForDeclarativeEvent(
+ foreach (QmlEvent *desc, descriptionBuffer.values()) {
+ desc->eventHashStr = getHashStringForQmlEvent(
desc->location, desc->eventType);;
d->m_eventDescriptions[desc->eventHashStr] = desc;
}
@@ -1731,7 +1731,7 @@ void ProfileData::load()
qSort(d->m_startTimeSortedList.begin(),
d->m_startTimeSortedList.end(), compareStartTimes);
for (int i = 0; i< d->m_startTimeSortedList.length(); i++) {
- DeclarativeEventStartTime startTimeData = d->m_startTimeSortedList[i];
+ QmlEventStartTime startTimeData = d->m_startTimeSortedList[i];
d->m_endTimeSortedList[startTimeData.endTimeIndex].startTimeIndex = i;
}
qSort(d->m_endTimeSortedList.begin(),
@@ -1825,7 +1825,7 @@ QString ProfileData::getDetails(int index) const
{
// special: animations
if (d->m_startTimeSortedList[index].description->eventType ==
- QDeclarativeProfilerService::Painting &&
+ QQmlProfilerService::Painting &&
d->m_startTimeSortedList[index].animationCount >= 0)
return tr("%1 animations at %2 FPS").arg(
QString::number(d->m_startTimeSortedList[index].animationCount),
diff --git a/tools/qmlprofiler/profiledata.h b/tools/qmlprofiler/profiledata.h
index eaa2127f4a..f5d726916c 100644
--- a/tools/qmlprofiler/profiledata.h
+++ b/tools/qmlprofiler/profiledata.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -42,16 +42,16 @@
#ifndef PROFILEDATA_H
#define PROFILEDATA_H
-#include <QtDeclarative/private/qdeclarativeprofilerservice_p.h>
+#include <QtQml/private/qqmlprofilerservice_p.h>
#include <QtCore/QObject>
#include <QtCore/QHash>
-struct DeclarativeEvent;
+struct QmlEvent;
struct V8Event;
-typedef QHash<QString, DeclarativeEvent *> DeclarativeEventHash;
-typedef QList<DeclarativeEvent *> DeclarativeEvents;
+typedef QHash<QString, QmlEvent *> QmlEventHash;
+typedef QList<QmlEvent *> QmlEvents;
typedef QList<V8Event *> V8Events;
struct EventLocation
@@ -64,32 +64,32 @@ struct EventLocation
int column;
};
-struct DeclarativeEventSub {
- DeclarativeEventSub(DeclarativeEvent *from)
+struct QmlEventSub {
+ QmlEventSub(QmlEvent *from)
: reference(from), duration(0), calls(0), inLoopPath(false)
{}
- DeclarativeEventSub(DeclarativeEventSub *from)
+ QmlEventSub(QmlEventSub *from)
: reference(from->reference), duration(from->duration),
calls(from->calls), inLoopPath(from->inLoopPath)
{}
- DeclarativeEvent *reference;
+ QmlEvent *reference;
qint64 duration;
qint64 calls;
bool inLoopPath;
};
-struct DeclarativeEvent
+struct QmlEvent
{
- DeclarativeEvent();
- ~DeclarativeEvent();
+ QmlEvent();
+ ~QmlEvent();
QString displayname;
QString eventHashStr;
QString details;
EventLocation location;
- QDeclarativeProfilerService::RangeType eventType;
- QHash <QString, DeclarativeEventSub *> parentHash;
- QHash <QString, DeclarativeEventSub *> childrenHash;
+ QQmlProfilerService::RangeType eventType;
+ QHash <QString, QmlEventSub *> parentHash;
+ QHash <QString, QmlEventSub *> childrenHash;
qint64 duration;
qint64 calls;
qint64 minTime;
@@ -100,7 +100,7 @@ struct DeclarativeEvent
int eventId;
bool isBindingLoop;
- DeclarativeEvent &operator=(const DeclarativeEvent &ref);
+ QmlEvent &operator=(const QmlEvent &ref);
};
struct V8EventSub {
@@ -143,8 +143,8 @@ public:
explicit ProfileData(QObject *parent = 0);
~ProfileData();
- DeclarativeEvents getDeclarativeEvents() const;
- DeclarativeEvent *declarativeEvent(int eventId) const;
+ QmlEvents getQmlEvents() const;
+ QmlEvent *qmlEvent(int eventId) const;
const V8Events& getV8Events() const;
V8Event *v8Event(int eventId) const;
@@ -184,7 +184,7 @@ public:
Q_INVOKABLE qint64 traceStartTime() const;
Q_INVOKABLE qint64 traceEndTime() const;
Q_INVOKABLE qint64 traceDuration() const;
- Q_INVOKABLE qint64 declarativeMeasuredTime() const;
+ Q_INVOKABLE qint64 qmlMeasuredTime() const;
Q_INVOKABLE qint64 v8MeasuredTime() const;
void showErrorDialog(const QString &st ) const;
@@ -205,7 +205,7 @@ signals:
public slots:
void clear();
- void addDeclarativeEvent(QDeclarativeProfilerService::RangeType type,
+ void addQmlEvent(QQmlProfilerService::RangeType type,
qint64 startTime, qint64 length,
const QStringList &data,
const EventLocation &location);
@@ -222,7 +222,7 @@ public slots:
void setTraceEndTime( qint64 time );
void setTraceStartTime( qint64 time );
- void rewriteDetailsString(QDeclarativeProfilerService::RangeType eventType,
+ void rewriteDetailsString(QQmlProfilerService::RangeType eventType,
const EventLocation &location,
const QString &newString);
void finishedRewritingDetails();
diff --git a/tools/qmlprofiler/qmlprofiler.pro b/tools/qmlprofiler/qmlprofiler.pro
index 1d8f89a150..ec5f50e376 100644
--- a/tools/qmlprofiler/qmlprofiler.pro
+++ b/tools/qmlprofiler/qmlprofiler.pro
@@ -1,8 +1,8 @@
TEMPLATE = app
TARGET = qmlprofiler
-DESTDIR = $$QT.declarative.bins
+DESTDIR = $$QT.qml.bins
-QT += declarative declarative-private network
+QT += qml qml-private network
target.path = $$[QT_INSTALL_BINS]
INSTALLS += target
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index af5f4298a8..0b10ec0b15 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -89,10 +89,10 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
m_port(3768),
m_verbose(false),
m_quitAfterSave(false),
- m_declarativeProfilerClient(&m_connection),
+ m_qmlProfilerClient(&m_connection),
m_v8profilerClient(&m_connection),
m_connectionAttempts(0),
- m_declarativeDataReady(false),
+ m_qmlDataReady(false),
m_v8DataReady(false)
{
m_connectTimer.setInterval(1000);
@@ -102,14 +102,14 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
connect(&m_connection, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(connectionStateChanged(QAbstractSocket::SocketState)));
connect(&m_connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
- connect(&m_declarativeProfilerClient, SIGNAL(enabledChanged()), this, SLOT(traceClientEnabled()));
- connect(&m_declarativeProfilerClient, SIGNAL(recordingChanged(bool)), this, SLOT(recordingChanged()));
- connect(&m_declarativeProfilerClient, SIGNAL(range(QDeclarativeProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)),
- &m_profileData, SLOT(addDeclarativeEvent(QDeclarativeProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)));
- connect(&m_declarativeProfilerClient, SIGNAL(traceFinished(qint64)), &m_profileData, SLOT(setTraceEndTime(qint64)));
- connect(&m_declarativeProfilerClient, SIGNAL(traceStarted(qint64)), &m_profileData, SLOT(setTraceStartTime(qint64)));
- connect(&m_declarativeProfilerClient, SIGNAL(frame(qint64,int,int)), &m_profileData, SLOT(addFrameEvent(qint64,int,int)));
- connect(&m_declarativeProfilerClient, SIGNAL(complete()), this, SLOT(declarativeComplete()));
+ connect(&m_qmlProfilerClient, SIGNAL(enabledChanged()), this, SLOT(traceClientEnabled()));
+ connect(&m_qmlProfilerClient, SIGNAL(recordingChanged(bool)), this, SLOT(recordingChanged()));
+ connect(&m_qmlProfilerClient, SIGNAL(range(QQmlProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)),
+ &m_profileData, SLOT(addQmlEvent(QQmlProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)));
+ connect(&m_qmlProfilerClient, SIGNAL(traceFinished(qint64)), &m_profileData, SLOT(setTraceEndTime(qint64)));
+ connect(&m_qmlProfilerClient, SIGNAL(traceStarted(qint64)), &m_profileData, SLOT(setTraceStartTime(qint64)));
+ connect(&m_qmlProfilerClient, SIGNAL(frame(qint64,int,int)), &m_profileData, SLOT(addFrameEvent(qint64,int,int)));
+ connect(&m_qmlProfilerClient, SIGNAL(complete()), this, SLOT(qmlComplete()));
connect(&m_v8profilerClient, SIGNAL(enabledChanged()), this, SLOT(profilerClientEnabled()));
connect(&m_v8profilerClient, SIGNAL(range(int,QString,QString,int,double,double)),
@@ -157,7 +157,7 @@ bool QmlProfilerApplication::parseArguments()
return false;
}
} else if (arg == QLatin1String("-fromStart")) {
- m_declarativeProfilerClient.setRecording(true);
+ m_qmlProfilerClient.setRecording(true);
m_v8profilerClient.setRecording(true);
} else if (arg == QLatin1String("-help") || arg == QLatin1String("-h") || arg == QLatin1String("/h") || arg == QLatin1String("/?")) {
return false;
@@ -232,19 +232,19 @@ void QmlProfilerApplication::userCommand(const QString &command)
printCommands();
} else if (cmd == Constants::CMD_RECORD
|| cmd == Constants::CMD_RECORD2) {
- m_declarativeProfilerClient.setRecording(
- !m_declarativeProfilerClient.isRecording());
+ m_qmlProfilerClient.setRecording(
+ !m_qmlProfilerClient.isRecording());
m_v8profilerClient.setRecording(!m_v8profilerClient.isRecording());
- m_declarativeDataReady = false;
+ m_qmlDataReady = false;
m_v8DataReady = false;
} else if (cmd == Constants::CMD_QUIT
|| cmd == Constants::CMD_QUIT2) {
print(QLatin1String("Quit"));
- if (m_declarativeProfilerClient.isRecording()) {
+ if (m_qmlProfilerClient.isRecording()) {
m_quitAfterSave = true;
- m_declarativeDataReady = false;
+ m_qmlDataReady = false;
m_v8DataReady = false;
- m_declarativeProfilerClient.setRecording(false);
+ m_qmlProfilerClient.setRecording(false);
m_v8profilerClient.setRecording(false);
} else {
quit();
@@ -304,7 +304,7 @@ void QmlProfilerApplication::connected()
"(type 'help'' to show list of commands).")
).arg(m_hostName).arg((m_port)));
QString recordingStatus(QLatin1String("Recording Status: %1"));
- if (!m_declarativeProfilerClient.isRecording() &&
+ if (!m_qmlProfilerClient.isRecording() &&
!m_v8profilerClient.isRecording())
recordingStatus = recordingStatus.arg(QLatin1String("Off"));
else
@@ -340,7 +340,7 @@ void QmlProfilerApplication::processFinished()
if (m_process->exitStatus() == QProcess::NormalExit) {
logStatus(QString("Process exited (%1).").arg(m_process->exitCode()));
- if (m_declarativeProfilerClient.isRecording()) {
+ if (m_qmlProfilerClient.isRecording()) {
logError("Process exited while recording, last trace is lost!");
exit(2);
} else {
@@ -357,7 +357,7 @@ void QmlProfilerApplication::traceClientEnabled()
logStatus("Trace client is attached.");
// blocked server is waiting for recording message from both clients
// once the last one is connected, both messages should be sent
- m_declarativeProfilerClient.sendRecordingStatus();
+ m_qmlProfilerClient.sendRecordingStatus();
m_v8profilerClient.sendRecordingStatus();
}
@@ -367,7 +367,7 @@ void QmlProfilerApplication::profilerClientEnabled()
// blocked server is waiting for recording message from both clients
// once the last one is connected, both messages should be sent
- m_declarativeProfilerClient.sendRecordingStatus();
+ m_qmlProfilerClient.sendRecordingStatus();
m_v8profilerClient.sendRecordingStatus();
}
@@ -384,7 +384,7 @@ void QmlProfilerApplication::traceFinished()
void QmlProfilerApplication::recordingChanged()
{
- if (m_declarativeProfilerClient.isRecording()) {
+ if (m_qmlProfilerClient.isRecording()) {
print(QLatin1String("Recording is on."));
} else {
print(QLatin1String("Recording is off."));
@@ -411,22 +411,22 @@ void QmlProfilerApplication::logStatus(const QString &status)
err << status << endl;
}
-void QmlProfilerApplication::declarativeComplete()
+void QmlProfilerApplication::qmlComplete()
{
- m_declarativeDataReady = true;
- if (m_v8profilerClient.state() != QDeclarativeDebugClient::Enabled ||
+ m_qmlDataReady = true;
+ if (m_v8profilerClient.state() != QQmlDebugClient::Enabled ||
m_v8DataReady) {
m_profileData.complete();
// once complete is sent, reset the flag
- m_declarativeDataReady = false;
+ m_qmlDataReady = false;
}
}
void QmlProfilerApplication::v8Complete()
{
m_v8DataReady = true;
- if (m_declarativeProfilerClient.state() != QDeclarativeDebugClient::Enabled ||
- m_declarativeDataReady) {
+ if (m_qmlProfilerClient.state() != QQmlDebugClient::Enabled ||
+ m_qmlDataReady) {
m_profileData.complete();
// once complete is sent, reset the flag
m_v8DataReady = false;
diff --git a/tools/qmlprofiler/qmlprofilerapplication.h b/tools/qmlprofiler/qmlprofilerapplication.h
index 49ddaf88cd..3937db7e5f 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.h
+++ b/tools/qmlprofiler/qmlprofilerapplication.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -80,7 +80,7 @@ private slots:
void logError(const QString &error);
void logStatus(const QString &status);
- void declarativeComplete();
+ void qmlComplete();
void v8Complete();
private:
@@ -103,14 +103,14 @@ private:
bool m_verbose;
bool m_quitAfterSave;
- QDeclarativeDebugConnection m_connection;
- DeclarativeProfileClient m_declarativeProfilerClient;
+ QQmlDebugConnection m_connection;
+ QmlProfileClient m_qmlProfilerClient;
V8ProfileClient m_v8profilerClient;
ProfileData m_profileData;
QTimer m_connectTimer;
uint m_connectionAttempts;
- bool m_declarativeDataReady;
+ bool m_qmlDataReady;
bool m_v8DataReady;
};
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index d586131845..327dfc6889 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -47,10 +47,10 @@
#include <QtGui/QGuiApplication>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
@@ -308,7 +308,7 @@ static void displayFileDialog(Options *options)
#endif
}
-static void loadDummyDataFiles(QDeclarativeEngine &engine, const QString& directory)
+static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory)
{
QDir dir(directory+"/dummydata", "*.qml");
QStringList list = dir.entryList();
@@ -317,13 +317,13 @@ static void loadDummyDataFiles(QDeclarativeEngine &engine, const QString& direct
QFile f(dir.filePath(qml));
f.open(QIODevice::ReadOnly);
QByteArray data = f.readAll();
- QDeclarativeComponent comp(&engine);
+ QQmlComponent comp(&engine);
comp.setData(data, QUrl());
QObject *dummyData = comp.create();
if(comp.isError()) {
- QList<QDeclarativeError> errors = comp.errors();
- foreach (const QDeclarativeError &error, errors) {
+ QList<QQmlError> errors = comp.errors();
+ foreach (const QQmlError &error, errors) {
qWarning() << error;
}
}
@@ -401,7 +401,7 @@ int main(int argc, char ** argv)
#endif
QWindow *window = 0;
- QDeclarativeEngine *engine = 0;
+ QQmlEngine *engine = 0;
int exitCode = 0;
diff --git a/tools/qmlscene/qmlscene.pro b/tools/qmlscene/qmlscene.pro
index 5e4d79253e..392e607b88 100644
--- a/tools/qmlscene/qmlscene.pro
+++ b/tools/qmlscene/qmlscene.pro
@@ -1,8 +1,8 @@
TEMPLATE = app
TARGET = qmlscene
-DESTDIR= $$QT.declarative.bins
+DESTDIR= $$QT.qml.bins
-QT += declarative quick core-private
+QT += qml quick core-private
!isEmpty(QT.widgets.name): QT += widgets
target.path = $$[QT_INSTALL_BINS]
diff --git a/tools/qmltestrunner/qmltestrunner.pro b/tools/qmltestrunner/qmltestrunner.pro
index 72990d6f98..a6c9533e0a 100644
--- a/tools/qmltestrunner/qmltestrunner.pro
+++ b/tools/qmltestrunner/qmltestrunner.pro
@@ -1,11 +1,11 @@
TEMPLATE = app
TARGET = qmltestrunner
-DESTDIR= $$QT.declarative.bins
+DESTDIR= $$QT.qml.bins
CONFIG += warn_on
SOURCES += main.cpp
-QT += declarative qmltest
+QT += qml qmltest
macx: CONFIG -= app_bundle